From 4c34be6b52a699cc7287e3b937a69ca90fd2ced9 Mon Sep 17 00:00:00 2001 From: mycroft Date: Wed, 1 Mar 1995 00:00:00 +0000 Subject: [PATCH] Clean up deleted files. --- bin/ed/test/e3.ed | 6 - bin/ed/test/e3.o | 1 - bin/ed/test/g1.ed | 11 - bin/ed/test/g1.o | 15 - bin/ed/test/g2.ed | 7 - bin/ed/test/g2.o | 1 - bin/ed/test/i.ed | 14 - bin/ed/test/i.o | 8 - bin/ed/test/j.ed | 7 - bin/ed/test/j.o | 4 - bin/ed/test/l.ed | 5 - bin/ed/test/l.o | 0 bin/ed/test/m.ed | 12 - bin/ed/test/m.o | 5 - bin/ed/test/n.ed | 5 - bin/ed/test/n.o | 0 bin/ed/test/nl.r | 8 - bin/ed/test/nl.t | 8 - bin/ed/test/p.ed | 5 - bin/ed/test/p.o | 0 bin/ed/test/r1.ed | 8 - bin/ed/test/r1.o | 7 - bin/ed/test/r2.ed | 6 - bin/ed/test/r2.o | 10 - bin/ed/test/r3.ed | 6 - bin/ed/test/r3.o | 2 - bin/ed/test/s1.ed | 11 - bin/ed/test/s1.o | 5 - bin/ed/test/s2.ed | 9 - bin/ed/test/s2.o | 5 - bin/ed/test/t.ed | 8 - bin/ed/test/t.o | 16 - bin/ed/test/t.t | 3 - bin/ed/test/u.ed | 36 - bin/ed/test/u.o | 9 - bin/ed/test/v.ed | 11 - bin/ed/test/v.o | 11 - bin/ed/test/w.ed | 7 - bin/ed/test/w.o | 10 - bin/expr/TODO | 2 - gnu/games/chess/Xchess/bishop_mask.bitmap | 71 - gnu/games/chess/Xchess/bishop_outline.bitmap | 71 - gnu/games/chess/Xchess/bishop_small.bitmap | 15 - .../chess/Xchess/bishop_small_outline.bitmap | 15 - gnu/games/chess/Xchess/board.c | 180 - gnu/games/chess/Xchess/button.c | 338 - gnu/games/chess/Xchess/clock.c | 292 - gnu/games/chess/Xchess/control.c | 517 - gnu/games/chess/Xchess/jail.c | 328 - gnu/games/chess/Xchess/king.bitmap | 71 - gnu/games/chess/Xchess/king_mask.bitmap | 71 - gnu/games/chess/Xchess/king_outline.bitmap | 71 - gnu/games/chess/Xchess/king_small.bitmap | 15 - .../chess/Xchess/king_small_outline.bitmap | 15 - gnu/games/chess/Xchess/knight.bitmap | 71 - gnu/games/chess/Xchess/knight_mask.bitmap | 71 - gnu/games/chess/Xchess/knight_outline.bitmap | 71 - gnu/games/chess/Xchess/knight_small.bitmap | 15 - .../chess/Xchess/knight_small_outline.bitmap | 15 - gnu/games/chess/Xchess/message.c | 102 - gnu/games/chess/Xchess/parse.c | 388 - gnu/games/chess/Xchess/pawn.bitmap | 71 - gnu/games/chess/Xchess/pawn_mask.bitmap | 71 - gnu/games/chess/Xchess/pawn_outline.bitmap | 71 - gnu/games/chess/Xchess/pawn_small.bitmap | 15 - .../chess/Xchess/pawn_small_outline.bitmap | 15 - gnu/games/chess/Xchess/popup.c | 113 - gnu/games/chess/Xchess/program.c | 201 - gnu/games/chess/Xchess/queen.bitmap | 71 - gnu/games/chess/Xchess/queen_mask.bitmap | 71 - gnu/games/chess/Xchess/queen_outline.bitmap | 71 - gnu/games/chess/Xchess/queen_small.bitmap | 15 - .../chess/Xchess/queen_small_outline.bitmap | 15 - gnu/games/chess/Xchess/record.c | 316 - gnu/games/chess/Xchess/rook.bitmap | 71 - gnu/games/chess/Xchess/rook_mask.bitmap | 71 - gnu/games/chess/Xchess/rook_outline.bitmap | 71 - gnu/games/chess/Xchess/rook_small.bitmap | 15 - .../chess/Xchess/rook_small_outline.bitmap | 15 - gnu/games/chess/Xchess/scrollText.c | 1862 --- gnu/games/chess/Xchess/scrollText.h | 34 - gnu/games/chess/Xchess/shade.bitmap | 71 - gnu/games/chess/Xchess/std.c | 426 - gnu/games/chess/Xchess/std.h | 106 - gnu/games/chess/Xchess/valid.c | 265 - gnu/games/chess/Xchess/window.c | 954 -- gnu/games/chess/Xchess/window.c.bm | 928 -- gnu/games/chess/Xchess/xchess.1 | 217 - gnu/games/chess/Xchess/xchess.c | 206 - gnu/games/chess/Xchess/xchess.c.150 | 197 - gnu/games/chess/Xchess/xchess.cur | 9 - gnu/games/chess/Xchess/xchess.game | 8 - gnu/games/chess/Xchess/xchess.h | 302 - gnu/games/chess/Xchess/xchess.icon | 28 - gnu/games/chess/Xchess/xchess_mask.cur | 7 - gnu/lib/libg++/g++-include/CursesW.h | 397 - gnu/lib/libg++/g++-include/DiscUnif.h | 79 - gnu/lib/libg++/g++-include/Erlang.h | 77 - gnu/lib/libg++/g++-include/File.h | 302 - gnu/lib/libg++/g++-include/Filebuf.h | 32 - gnu/lib/libg++/g++-include/Fix.h | 468 - gnu/lib/libg++/g++-include/Fix16.h | 647 - gnu/lib/libg++/g++-include/Fix24.h | 595 - gnu/lib/libg++/g++-include/Fmodes.h | 34 - gnu/lib/libg++/g++-include/Geom.h | 59 - gnu/lib/libg++/g++-include/GetOpt.h | 131 - gnu/lib/libg++/g++-include/HypGeom.h | 78 - gnu/lib/libg++/g++-include/Incremental.h | 13 - gnu/lib/libg++/g++-include/Integer.h | 1114 -- gnu/lib/libg++/g++-include/LogNorm.h | 84 - gnu/lib/libg++/g++-include/MLCG.h | 97 - gnu/lib/libg++/g++-include/Makefile | 58 - gnu/lib/libg++/g++-include/NegExp.h | 63 - gnu/lib/libg++/g++-include/Normal.h | 74 - gnu/lib/libg++/g++-include/Obstack.h | 226 - gnu/lib/libg++/g++-include/Pix.h | 9 - gnu/lib/libg++/g++-include/PlotFile.h | 154 - gnu/lib/libg++/g++-include/Poisson.h | 60 - gnu/lib/libg++/g++-include/RNG.h | 88 - gnu/lib/libg++/g++-include/Random.h | 67 - gnu/lib/libg++/g++-include/Rational.h | 270 - gnu/lib/libg++/g++-include/Regex.h | 76 - gnu/lib/libg++/g++-include/RndInt.h | 169 - gnu/lib/libg++/g++-include/SFile.h | 88 - gnu/lib/libg++/g++-include/SmplHist.h | 82 - gnu/lib/libg++/g++-include/SmplStat.h | 73 - gnu/lib/libg++/g++-include/String.h | 1341 -- gnu/lib/libg++/g++-include/Uniform.h | 81 - gnu/lib/libg++/g++-include/Weibull.h | 83 - gnu/lib/libg++/g++-include/abs.h | 1 - gnu/lib/libg++/g++-include/bool.h | 10 - gnu/lib/libg++/g++-include/builtin.h | 276 - gnu/lib/libg++/g++-include/compare.h | 98 - gnu/lib/libg++/g++-include/complex.h | 9 - gnu/lib/libg++/g++-include/fcntl.h | 31 - gnu/lib/libg++/g++-include/file.h | 8 - gnu/lib/libg++/g++-include/filebuf.h | 63 - gnu/lib/libg++/g++-include/generic.h | 63 - gnu/lib/libg++/g++-include/grp.h | 43 - gnu/lib/libg++/g++-include/istream.h | 259 - gnu/lib/libg++/g++-include/malloc.h | 1 - gnu/lib/libg++/g++-include/math-68881.h | 518 - gnu/lib/libg++/g++-include/math.h | 223 - gnu/lib/libg++/g++-include/max.h | 1 - gnu/lib/libg++/g++-include/memory.h | 43 - gnu/lib/libg++/g++-include/min.h | 1 - gnu/lib/libg++/g++-include/minmax.h | 1 - gnu/lib/libg++/g++-include/netdb.h | 6 - gnu/lib/libg++/g++-include/new.h | 33 - gnu/lib/libg++/g++-include/open.h | 39 - gnu/lib/libg++/g++-include/osfcn.h | 4 - gnu/lib/libg++/g++-include/ostream.h | 256 - gnu/lib/libg++/g++-include/pwd.h | 38 - gnu/lib/libg++/g++-include/regex.h | 280 - gnu/lib/libg++/g++-include/setjmp.h | 31 - gnu/lib/libg++/g++-include/signal.h | 82 - gnu/lib/libg++/g++-include/std.h | 4 - gnu/lib/libg++/g++-include/stdarg.h | 5 - gnu/lib/libg++/g++-include/stddef.h | 14 - gnu/lib/libg++/g++-include/stdio.h | 182 - gnu/lib/libg++/g++-include/stdlib.h | 81 - gnu/lib/libg++/g++-include/strclass.h | 8 - gnu/lib/libg++/g++-include/stream.h | 13 - gnu/lib/libg++/g++-include/streambuf.h | 165 - gnu/lib/libg++/g++-include/string.h | 47 - gnu/lib/libg++/g++-include/strings.h | 3 - gnu/lib/libg++/g++-include/swap.h | 3 - gnu/lib/libg++/g++-include/sys/signal.h | 39 - gnu/lib/libg++/g++-include/sys/socket.h | 65 - gnu/lib/libg++/g++-include/sys/stat.h | 49 - gnu/lib/libg++/g++-include/sys/time.h | 43 - gnu/lib/libg++/g++-include/sys/times.h | 22 - gnu/lib/libg++/g++-include/sys/types.h | 27 - gnu/lib/libg++/g++-include/sys/wait.h | 44 - gnu/lib/libg++/g++-include/time.h | 110 - gnu/lib/libg++/g++-include/unistd.h | 189 - gnu/lib/libg++/libg++/SFile.cc | 53 - gnu/lib/libg++/libg++/Sample.cc | 241 - gnu/lib/libg++/libg++/ctype.cc | 4 - gnu/lib/libg++/libg++/curses.cc | 4 - gnu/lib/libg++/libg++/delete.cc | 38 - gnu/lib/libg++/libg++/filebuf.cc | 192 - gnu/lib/libg++/libg++/form.cc | 56 - gnu/lib/libg++/libg++/g++.order | 70 - gnu/lib/libg++/libg++/gnulib3.c | 109 - gnu/lib/libg++/libg++/istream.cc | 507 - gnu/lib/libg++/libg++/itoa.cc | 226 - gnu/lib/libg++/libg++/malloc.c | 1261 -- gnu/lib/libg++/libg++/max.cc | 4 - gnu/lib/libg++/libg++/min.cc | 4 - gnu/lib/libg++/libg++/open.cc | 46 - gnu/lib/libg++/libg++/ostream.cc | 224 - gnu/lib/libg++/libg++/std.cc | 4 - gnu/lib/libg++/libg++/streambuf.cc | 138 - gnu/lib/libg++/libg++/xyzzy.cc | 12 - gnu/lib/libregex/Makefile.in | 100 - gnu/lib/libregex/NEWS | 62 - gnu/lib/libregex/README | 60 - gnu/lib/libregex/VERSION | 3 - gnu/lib/libregex/config.status | 59 - gnu/lib/libregex/configure | 462 - gnu/lib/libregex/configure.in | 23 - gnu/lib/libregex/doc/regex.info | 2836 ---- gnu/lib/libregex/doc/regex.texi | 3138 ----- gnu/lib/libregex/doc/texinfo.tex | 3941 ------ gnu/lib/libregex/doc/xregex.texi | 3021 ----- gnu/lib/libregex/regex.c | 4952 ------- gnu/lib/libregex/regex.h | 493 - gnu/lib/libregex/shlib_version | 2 - gnu/lib/libregex/test/debugmalloc.c | 277 - gnu/lib/libregex/test/emacsmalloc.c | 846 -- gnu/lib/libregex/test/fileregex.c | 81 - gnu/lib/libregex/test/g++malloc.c | 1290 -- gnu/lib/libregex/test/getpagesize.h | 27 - gnu/lib/libregex/test/iregex.c | 168 - gnu/lib/libregex/test/main.c | 53 - gnu/lib/libregex/test/malloc-test.c | 49 - gnu/lib/libregex/test/other.c | 507 - gnu/lib/libregex/test/printchar.c | 18 - gnu/lib/libregex/test/psx-basic.c | 257 - gnu/lib/libregex/test/psx-extend.c | 1248 -- gnu/lib/libregex/test/psx-generic.c | 340 - gnu/lib/libregex/test/psx-group.c | 444 - gnu/lib/libregex/test/psx-interf.c | 628 - gnu/lib/libregex/test/psx-interv.c | 144 - gnu/lib/libregex/test/regexcpp.sed | 8 - gnu/lib/libregex/test/syntax.skel | 74 - gnu/lib/libregex/test/test.c | 786 -- gnu/lib/libregex/test/test.h | 141 - gnu/lib/libregex/test/tregress.c | 468 - gnu/lib/libregex/test/upcase.c | 43 - gnu/lib/libregex/test/xmalloc.c | 25 - gnu/lib/regex-0.12/Makefile.in | 98 - gnu/lib/regex-0.12/NEWS | 62 - gnu/lib/regex-0.12/README | 60 - gnu/lib/regex-0.12/config.status | 59 - gnu/lib/regex-0.12/configure | 462 - gnu/lib/regex-0.12/configure.in | 23 - gnu/lib/regex-0.12/doc/regex.info | 2836 ---- gnu/lib/regex-0.12/doc/regex.texi | 3138 ----- gnu/lib/regex-0.12/doc/texinfo.tex | 3941 ------ gnu/lib/regex-0.12/doc/xregex.texi | 3021 ----- gnu/lib/regex-0.12/regex.c | 4948 ------- gnu/lib/regex-0.12/regex.h | 490 - gnu/lib/regex-0.12/test/debugmalloc.c | 273 - gnu/lib/regex-0.12/test/emacsmalloc.c | 844 -- gnu/lib/regex-0.12/test/fileregex.c | 77 - gnu/lib/regex-0.12/test/g++malloc.c | 1288 -- gnu/lib/regex-0.12/test/getpagesize.h | 25 - gnu/lib/regex-0.12/test/iregex.c | 164 - gnu/lib/regex-0.12/test/main.c | 49 - gnu/lib/regex-0.12/test/malloc-test.c | 47 - gnu/lib/regex-0.12/test/other.c | 503 - gnu/lib/regex-0.12/test/printchar.c | 14 - gnu/lib/regex-0.12/test/psx-basic.c | 253 - gnu/lib/regex-0.12/test/psx-extend.c | 1244 -- gnu/lib/regex-0.12/test/psx-generic.c | 336 - gnu/lib/regex-0.12/test/psx-group.c | 440 - gnu/lib/regex-0.12/test/psx-interf.c | 624 - gnu/lib/regex-0.12/test/psx-interv.c | 140 - gnu/lib/regex-0.12/test/regexcpp.sed | 8 - gnu/lib/regex-0.12/test/syntax.skel | 74 - gnu/lib/regex-0.12/test/test.c | 782 -- gnu/lib/regex-0.12/test/test.h | 141 - gnu/lib/regex-0.12/test/tregress.c | 464 - gnu/lib/regex-0.12/test/upcase.c | 39 - gnu/lib/regex-0.12/test/xmalloc.c | 21 - gnu/libexec/uucp/config.c | 1044 -- gnu/libexec/uucp/config.status | 11 - gnu/libexec/uucp/configure | 936 -- gnu/libexec/uucp/configure.in | 589 - gnu/libexec/uucp/copy.c | 207 - gnu/libexec/uucp/file.c | 589 - gnu/libexec/uucp/getopt.c | 682 - gnu/libexec/uucp/getopt.h | 124 - gnu/libexec/uucp/log.c | 740 - gnu/libexec/uucp/parse.c | 162 - gnu/libexec/uucp/policy.h | 419 - gnu/libexec/uucp/port.c | 602 - gnu/libexec/uucp/port.h | 509 - gnu/libexec/uucp/prot.c | 1255 -- gnu/libexec/uucp/prot.h | 266 - gnu/libexec/uucp/prote.c | 401 - gnu/libexec/uucp/protf.c | 673 - gnu/libexec/uucp/protg.c | 1932 --- gnu/libexec/uucp/prott.c | 375 - gnu/libexec/uucp/prtinf.c | 1072 -- gnu/libexec/uucp/sys1.unx | 2543 ---- gnu/libexec/uucp/sys2.unx | 2746 ---- gnu/libexec/uucp/sys3.unx | 2650 ---- gnu/libexec/uucp/sys4.unx | 769 -- gnu/libexec/uucp/sys5.unx | 877 -- gnu/libexec/uucp/sys6.unx | 234 - gnu/libexec/uucp/sys7.unx | 606 - gnu/libexec/uucp/sysh.unx | 606 - gnu/libexec/uucp/sysinf.c | 1797 --- gnu/libexec/uucp/system.h | 668 - gnu/libexec/uucp/tcp.c | 363 - gnu/libexec/uucp/time.c | 705 - gnu/libexec/uucp/util.c | 684 - gnu/libexec/uucp/uuchk.c | 908 -- gnu/libexec/uucp/uucico.8 | 242 - gnu/libexec/uucp/uucico.c | 3496 ----- gnu/libexec/uucp/uucp.1 | 183 - gnu/libexec/uucp/uucp.c | 809 -- gnu/libexec/uucp/uucp.h | 1208 -- gnu/libexec/uucp/uucp.info | 98 - gnu/libexec/uucp/uucp.info-1 | 1149 -- gnu/libexec/uucp/uucp.info-2 | 1142 -- gnu/libexec/uucp/uucp.info-3 | 1194 -- gnu/libexec/uucp/uucp.info-4 | 946 -- gnu/libexec/uucp/uucp.texi | 4495 ------ gnu/libexec/uucp/uudir.c | 109 - gnu/libexec/uucp/uulog.c | 264 - gnu/libexec/uucp/uuname.c | 183 - gnu/libexec/uucp/uustat.1 | 253 - gnu/libexec/uucp/uustat.c | 1071 -- gnu/libexec/uucp/uutime.h | 137 - gnu/libexec/uucp/uux.1 | 260 - gnu/libexec/uucp/uux.c | 1280 -- gnu/libexec/uucp/uuxqt.8 | 109 - gnu/libexec/uucp/uuxqt.c | 1370 -- gnu/libexec/uucp/v2.c | 652 - gnu/libexec/uucp/version.c | 55 - gnu/usr.bin/awk/bi_funct.c | 892 -- gnu/usr.bin/awk/bi_funct.h | 63 - gnu/usr.bin/awk/bi_vars.c | 92 - gnu/usr.bin/awk/bi_vars.h | 59 - gnu/usr.bin/awk/cast.c | 452 - gnu/usr.bin/awk/code.c | 164 - gnu/usr.bin/awk/code.h | 153 - gnu/usr.bin/awk/config.h | 38 - gnu/usr.bin/awk/config/msc_dos.h | 53 - gnu/usr.bin/awk/config/next.h | 34 - gnu/usr.bin/awk/config/sgi.h | 33 - gnu/usr.bin/awk/config/sun_os40.h | 68 - gnu/usr.bin/awk/config/sun_os41.h | 32 - gnu/usr.bin/awk/config/sysV.h | 50 - gnu/usr.bin/awk/config/sysV_ieeefp.h | 49 - gnu/usr.bin/awk/config/tcc_dos.h | 66 - gnu/usr.bin/awk/config/template.h | 17 - gnu/usr.bin/awk/config/think_c.h | 31 - gnu/usr.bin/awk/config/ultrix42mips.h | 35 - gnu/usr.bin/awk/config/ultrix_vax.h | 50 - gnu/usr.bin/awk/config/xenix_r2.h | 55 - gnu/usr.bin/awk/da.c | 370 - gnu/usr.bin/awk/error.c | 393 - gnu/usr.bin/awk/execute.c | 1266 -- gnu/usr.bin/awk/fcall.c | 365 - gnu/usr.bin/awk/field.c | 635 - gnu/usr.bin/awk/field.h | 100 - gnu/usr.bin/awk/files.c | 471 - gnu/usr.bin/awk/files.h | 57 - gnu/usr.bin/awk/fin.c | 529 - gnu/usr.bin/awk/fin.h | 56 - gnu/usr.bin/awk/hash.c | 229 - gnu/usr.bin/awk/init.c | 361 - gnu/usr.bin/awk/init.h | 58 - gnu/usr.bin/awk/jmp.c | 215 - gnu/usr.bin/awk/jmp.h | 35 - gnu/usr.bin/awk/kw.c | 83 - gnu/usr.bin/awk/main.c | 73 - gnu/usr.bin/awk/makescan.c | 123 - gnu/usr.bin/awk/matherr.c | 191 - gnu/usr.bin/awk/mawk.h | 205 - gnu/usr.bin/awk/memory.c | 74 - gnu/usr.bin/awk/memory.h | 50 - gnu/usr.bin/awk/parse.y | 1294 -- gnu/usr.bin/awk/parse2.xc | 46 - gnu/usr.bin/awk/patchlev.h | 4 - gnu/usr.bin/awk/print.c | 523 - gnu/usr.bin/awk/re_cmpl.c | 337 - gnu/usr.bin/awk/regexp.h | 32 - gnu/usr.bin/awk/repl.h | 37 - gnu/usr.bin/awk/scan.c | 861 -- gnu/usr.bin/awk/scan.h | 102 - gnu/usr.bin/awk/scancode.c | 23 - gnu/usr.bin/awk/sizes.h | 89 - gnu/usr.bin/awk/split.c | 263 - gnu/usr.bin/awk/symtype.h | 192 - gnu/usr.bin/awk/types.h | 117 - gnu/usr.bin/awk/vargs.h | 59 - gnu/usr.bin/awk/version.c | 184 - gnu/usr.bin/awk/zmalloc.c | 161 - gnu/usr.bin/awk/zmalloc.h | 49 - gnu/usr.bin/bc-1.02/Test/ln.b | 3 - gnu/usr.bin/bc-1.02/Test/mul.b | 7 - gnu/usr.bin/bc-1.02/Test/raise.b | 3 - gnu/usr.bin/bc-1.02/Test/sine.b | 3 - gnu/usr.bin/bc-1.02/Test/sqrt.b | 4 - gnu/usr.bin/bc-1.02/Test/testfn.b | 47 - gnu/usr.bin/bc-1.02/Test/timetest | 14 - gnu/usr.bin/bc-1.02/bc.c.dist | 1369 -- gnu/usr.bin/bc-1.02/bc.y | 612 - gnu/usr.bin/bc-1.02/bcdefs.h | 154 - gnu/usr.bin/bc-1.02/config.h | 4 - gnu/usr.bin/bc-1.02/configure | 119 - gnu/usr.bin/bc-1.02/const.h | 87 - gnu/usr.bin/bc-1.02/execute.c | 783 -- gnu/usr.bin/bc-1.02/fix_math.h | 8 - gnu/usr.bin/bc-1.02/global.c | 42 - gnu/usr.bin/bc-1.02/global.h | 108 - gnu/usr.bin/bc-1.02/libmath.b | 255 - gnu/usr.bin/bc-1.02/load.c | 333 - gnu/usr.bin/bc-1.02/main.c | 204 - gnu/usr.bin/bc-1.02/math.h | 40 - gnu/usr.bin/bc-1.02/number.c | 1405 -- gnu/usr.bin/bc-1.02/number.h | 60 - gnu/usr.bin/bc-1.02/proto.h | 165 - gnu/usr.bin/bc-1.02/sbc.y | 448 - gnu/usr.bin/bc-1.02/scan.c.dist | 1368 -- gnu/usr.bin/bc-1.02/scan.l | 189 - gnu/usr.bin/bc-1.02/storage.c | 967 -- gnu/usr.bin/bc-1.02/util.c | 794 -- gnu/usr.bin/bc-1.02/version.h | 3 - gnu/usr.bin/bc-1.02/vfprintf.c | 13 - gnu/usr.bin/bc-1.02/y.tab.h.dist | 40 - gnu/usr.bin/fgrep/fgrep | Bin 37700 -> 0 bytes gnu/usr.bin/fgrep/obstack.c | 326 - gnu/usr.bin/fgrep/obstack.h | 410 - gnu/usr.bin/fgrep/std.c | 55 - gnu/usr.bin/fgrep/std.h | 145 - gnu/usr.bin/fgrep/unix.h | 79 - gnu/usr.bin/g++/cc1plus/cplus-class.c | 6277 --------- gnu/usr.bin/g++/cc1plus/cplus-cvt.c | 1841 --- gnu/usr.bin/g++/cc1plus/cplus-decl.c | 8825 ------------ gnu/usr.bin/g++/cc1plus/cplus-decl.h | 40 - gnu/usr.bin/g++/cc1plus/cplus-decl2.c | 2323 ---- gnu/usr.bin/g++/cc1plus/cplus-except.c | 1027 -- gnu/usr.bin/g++/cc1plus/cplus-expr.c | 174 - gnu/usr.bin/g++/cc1plus/cplus-field.c | 918 -- gnu/usr.bin/g++/cc1plus/cplus-init.c | 3687 ----- gnu/usr.bin/g++/cc1plus/cplus-lex.c | 4037 ------ gnu/usr.bin/g++/cc1plus/cplus-method.c | 2504 ---- gnu/usr.bin/g++/cc1plus/cplus-parse.h | 64 - gnu/usr.bin/g++/cc1plus/cplus-parse.y | 3174 ----- gnu/usr.bin/g++/cc1plus/cplus-ptree.c | 234 - gnu/usr.bin/g++/cc1plus/cplus-search.c | 3225 ----- gnu/usr.bin/g++/cc1plus/cplus-tree.c | 1320 -- gnu/usr.bin/g++/cc1plus/cplus-tree.def | 28 - gnu/usr.bin/g++/cc1plus/cplus-tree.h | 1604 --- gnu/usr.bin/g++/cc1plus/cplus-type2.c | 1529 --- gnu/usr.bin/g++/cc1plus/cplus-typeck.c | 6017 --------- gnu/usr.bin/g++/cc1plus/dbxout.c | 1643 --- gnu/usr.bin/g++/cc1plus/expr.c | 5748 -------- gnu/usr.bin/g++/cc1plus/expr.h | 463 - gnu/usr.bin/g++/cc1plus/flags.h | 212 - gnu/usr.bin/g++/cc1plus/gplus.gperf | 76 - gnu/usr.bin/g++/cc1plus/input.h | 22 - gnu/usr.bin/g++/cc1plus/integrate.c | 2793 ---- gnu/usr.bin/g++/cc1plus/print-tree.c | 673 - gnu/usr.bin/g++/cc1plus/stab.def | 171 - gnu/usr.bin/g++/cc1plus/stab.h | 16 - gnu/usr.bin/g++/cc1plus/stack.h | 21 - gnu/usr.bin/g++/cc1plus/stmt.c | 4929 ------- gnu/usr.bin/g++/cc1plus/stor-layout.c | 1049 -- gnu/usr.bin/g++/cc1plus/symout.c | 1267 -- gnu/usr.bin/g++/cc1plus/toplev.c | 2426 ---- gnu/usr.bin/g++/cc1plus/tree.c | 2717 ---- gnu/usr.bin/g++/cc1plus/tree.def | 624 - gnu/usr.bin/g++/cc1plus/tree.h | 979 -- gnu/usr.bin/g++/cc1plus/varasm.c | 2241 --- gnu/usr.bin/g++/cc1plus/version.c | 1 - gnu/usr.bin/g++/cc1plus/y.tab.h | 71 - gnu/usr.bin/gas/config/i860.h | 51 - gnu/usr.bin/gas/config/m-hpux.h | 27 - gnu/usr.bin/gas/config/m-sun3.h | 34 - gnu/usr.bin/gas/config/m68k-opcode.h | 1683 --- gnu/usr.bin/gas/config/m68k.c | 3544 ----- gnu/usr.bin/gas/config/m68k.h | 23 - gnu/usr.bin/gas/config/ns32k-opcode.h | 437 - gnu/usr.bin/gas/config/ns32k.c | 1772 --- gnu/usr.bin/gas/config/sparc-opcode.h | 639 - gnu/usr.bin/gas/config/sparc.c | 1288 -- gnu/usr.bin/gas/config/sparc.h | 55 - gnu/usr.bin/gas/config/vax-opcode.h | 385 - gnu/usr.bin/gas/config/vax.c | 3368 ----- gnu/usr.bin/gas/md.h | 60 - gnu/usr.bin/gas/objrecdef.h | 257 - gnu/usr.bin/gawk-2.15.2/POSIX | 95 - gnu/usr.bin/gawk-2.15.2/PROBLEMS | 6 - gnu/usr.bin/gawk-2.15.2/README | 116 - gnu/usr.bin/gawk-2.15.2/array.c | 293 - gnu/usr.bin/gawk-2.15.2/awk.1 | 1873 --- gnu/usr.bin/gawk-2.15.2/awk.h | 763 -- gnu/usr.bin/gawk-2.15.2/awk.y | 1804 --- gnu/usr.bin/gawk-2.15.2/builtin.c | 1133 -- gnu/usr.bin/gawk-2.15.2/config.h | 272 - gnu/usr.bin/gawk-2.15.2/dfa.c | 2291 ---- gnu/usr.bin/gawk-2.15.2/dfa.h | 543 - gnu/usr.bin/gawk-2.15.2/eval.c | 1225 -- gnu/usr.bin/gawk-2.15.2/field.c | 645 - gnu/usr.bin/gawk-2.15.2/gawk.texi | 11270 ---------------- gnu/usr.bin/gawk-2.15.2/getopt.c | 662 - gnu/usr.bin/gawk-2.15.2/getopt.h | 128 - gnu/usr.bin/gawk-2.15.2/getopt1.c | 160 - gnu/usr.bin/gawk-2.15.2/io.c | 1207 -- gnu/usr.bin/gawk-2.15.2/iop.c | 318 - gnu/usr.bin/gawk-2.15.2/main.c | 731 - gnu/usr.bin/gawk-2.15.2/msg.c | 106 - gnu/usr.bin/gawk-2.15.2/node.c | 429 - gnu/usr.bin/gawk-2.15.2/patchlevel.h | 1 - gnu/usr.bin/gawk-2.15.2/protos.h | 115 - gnu/usr.bin/gawk-2.15.2/re.c | 208 - gnu/usr.bin/gawk-2.15.2/regex.c | 2854 ---- gnu/usr.bin/gawk-2.15.2/regex.h | 260 - gnu/usr.bin/gawk-2.15.2/version.c | 46 - gnu/usr.bin/gcc2/arch/da30/insn-attrtab.c | 14 - gnu/usr.bin/gcc2/arch/da30/insn-codes.h | 184 - gnu/usr.bin/gcc2/arch/da30/insn-config.h | 12 - gnu/usr.bin/gcc2/arch/da30/insn-emit.c | 1897 --- gnu/usr.bin/gcc2/arch/da30/insn-extract.c | 558 - gnu/usr.bin/gcc2/arch/da30/insn-flags.h | 537 - gnu/usr.bin/gcc2/arch/da30/insn-opinit.c | 221 - gnu/usr.bin/gcc2/arch/da30/insn-output.c | 7826 ----------- gnu/usr.bin/gcc2/arch/da30/insn-peep.c | 410 - gnu/usr.bin/gcc2/arch/da30/insn-recog.c | 6589 --------- gnu/usr.bin/gcc2/arch/da30/m68k.h | 1796 --- gnu/usr.bin/gcc2/arch/da30/md | 5628 -------- gnu/usr.bin/gcc2/arch/da30/tconfig.h | 50 - gnu/usr.bin/gcc2/arch/da30/tm.h | 92 - gnu/usr.bin/gcc2/arch/hp300/insn-codes.h | 184 - gnu/usr.bin/gcc2/arch/hp300/insn-config.h | 12 - gnu/usr.bin/gcc2/arch/hp300/insn-emit.c | 1907 --- gnu/usr.bin/gcc2/arch/hp300/insn-extract.c | 558 - gnu/usr.bin/gcc2/arch/hp300/insn-flags.h | 537 - gnu/usr.bin/gcc2/arch/hp300/insn-opinit.c | 221 - gnu/usr.bin/gcc2/arch/hp300/insn-output.c | 7822 ----------- gnu/usr.bin/gcc2/arch/hp300/insn-peep.c | 410 - gnu/usr.bin/gcc2/arch/hp300/insn-recog.c | 6589 --------- gnu/usr.bin/gcc2/arch/hp300/m68k.h | 1789 --- gnu/usr.bin/gcc2/arch/hp300/md | 5642 -------- gnu/usr.bin/gcc2/arch/hp300/tconfig.h | 50 - gnu/usr.bin/gcc2/arch/hp300/tm.h | 56 - gnu/usr.bin/gcc2/common/insn-config.h | 12 - gnu/usr.bin/gcc2/common/insn-emit.c | 2708 ---- gnu/usr.bin/gcc2/common/insn-extract.c | 505 - gnu/usr.bin/gcc2/common/insn-flags.h | 510 - gnu/usr.bin/gcc2/common/insn-opinit.c | 179 - gnu/usr.bin/gcc2/common/insn-output.c | 5899 -------- gnu/usr.bin/gcc2/common/insn-peep.c | 28 - gnu/usr.bin/gcc2/common/insn-recog.c | 6158 --------- gnu/usr.bin/gcc2/common/tconfig.h | 48 - gnu/usr.bin/gcc2/common/tm.h | 81 - gnu/usr.bin/gcc2/i386/insn-attr.h | 22 - gnu/usr.bin/gcc2/i386/insn-attrtab.c | 18 - gnu/usr.bin/gcc2/i386/insn-codes.h | 177 - gnu/usr.bin/gcc2/i386/insn-config.h | 15 - gnu/usr.bin/gcc2/i386/insn-emit.c | 2712 ---- gnu/usr.bin/gcc2/i386/insn-extract.c | 509 - gnu/usr.bin/gcc2/i386/insn-flags.h | 513 - gnu/usr.bin/gcc2/i386/insn-opinit.c | 183 - gnu/usr.bin/gcc2/i386/insn-output.c | 5903 -------- gnu/usr.bin/gcc2/i386/insn-peep.c | 32 - gnu/usr.bin/gcc2/i386/insn-recog.c | 6162 --------- gnu/usr.bin/gcc2/i386/perform.h | 96 - gnu/usr.bin/gcc2/i386/tconfig.h | 51 - gnu/usr.bin/gcc2/i386/tm.h | 84 - gnu/usr.bin/gcc2/i386/unix.h | 148 - gnu/usr.bin/gcc2/libgcc/_ashlsi3.c | 33 - gnu/usr.bin/gcc2/libgcc/_ashrdi3.c | 112 - gnu/usr.bin/gcc2/libgcc/_ashrsi3.c | 33 - gnu/usr.bin/gcc2/libgcc/_bb.c | 89 - gnu/usr.bin/gcc2/libgcc/_clear_cache.c | 91 - gnu/usr.bin/gcc2/libgcc/_cmpdi2.c | 102 - gnu/usr.bin/gcc2/libgcc/_ctors.c | 93 - gnu/usr.bin/gcc2/libgcc/_divdf3.c | 33 - gnu/usr.bin/gcc2/libgcc/_divdi3.c | 119 - gnu/usr.bin/gcc2/libgcc/_divsf3.c | 34 - gnu/usr.bin/gcc2/libgcc/_divsi3.c | 33 - gnu/usr.bin/gcc2/libgcc/_eprintf.c | 205 - gnu/usr.bin/gcc2/libgcc/_eqdf2.c | 34 - gnu/usr.bin/gcc2/libgcc/_eqsf2.c | 35 - gnu/usr.bin/gcc2/libgcc/_exit.c | 92 - gnu/usr.bin/gcc2/libgcc/_extendsfdf2.c | 34 - gnu/usr.bin/gcc2/libgcc/_ffsdi2.c | 104 - gnu/usr.bin/gcc2/libgcc/_fixdfdi.c | 94 - gnu/usr.bin/gcc2/libgcc/_fixdfsi.c | 33 - gnu/usr.bin/gcc2/libgcc/_fixsfdi.c | 93 - gnu/usr.bin/gcc2/libgcc/_fixsfsi.c | 34 - gnu/usr.bin/gcc2/libgcc/_fixunsdfdi.c | 107 - gnu/usr.bin/gcc2/libgcc/_fixunsdfsi.c | 94 - gnu/usr.bin/gcc2/libgcc/_fixunssfdi.c | 109 - gnu/usr.bin/gcc2/libgcc/_fixunssfsi.c | 93 - gnu/usr.bin/gcc2/libgcc/_fixunsxfdi.c | 86 - gnu/usr.bin/gcc2/libgcc/_fixunsxfsi.c | 86 - gnu/usr.bin/gcc2/libgcc/_fixxfdi.c | 86 - gnu/usr.bin/gcc2/libgcc/_floatdidf.c | 100 - gnu/usr.bin/gcc2/libgcc/_floatdisf.c | 101 - gnu/usr.bin/gcc2/libgcc/_floatdixf.c | 86 - gnu/usr.bin/gcc2/libgcc/_floatsidf.c | 33 - gnu/usr.bin/gcc2/libgcc/_floatsisf.c | 34 - gnu/usr.bin/gcc2/libgcc/_gedf2.c | 34 - gnu/usr.bin/gcc2/libgcc/_gesf2.c | 35 - gnu/usr.bin/gcc2/libgcc/_gtdf2.c | 34 - gnu/usr.bin/gcc2/libgcc/_gtsf2.c | 35 - gnu/usr.bin/gcc2/libgcc/_ledf2.c | 34 - gnu/usr.bin/gcc2/libgcc/_lesf2.c | 35 - gnu/usr.bin/gcc2/libgcc/_lshldi3.c | 111 - gnu/usr.bin/gcc2/libgcc/_lshlsi3.c | 33 - gnu/usr.bin/gcc2/libgcc/_lshrdi3.c | 111 - gnu/usr.bin/gcc2/libgcc/_lshrsi3.c | 33 - gnu/usr.bin/gcc2/libgcc/_ltdf2.c | 34 - gnu/usr.bin/gcc2/libgcc/_ltsf2.c | 35 - gnu/usr.bin/gcc2/libgcc/_moddi3.c | 118 - gnu/usr.bin/gcc2/libgcc/_modsi3.c | 33 - gnu/usr.bin/gcc2/libgcc/_muldf3.c | 33 - gnu/usr.bin/gcc2/libgcc/_muldi3.c | 99 - gnu/usr.bin/gcc2/libgcc/_mulsf3.c | 34 - gnu/usr.bin/gcc2/libgcc/_mulsi3.c | 33 - gnu/usr.bin/gcc2/libgcc/_nedf2.c | 34 - gnu/usr.bin/gcc2/libgcc/_negdf2.c | 33 - gnu/usr.bin/gcc2/libgcc/_negdi2.c | 97 - gnu/usr.bin/gcc2/libgcc/_negsf2.c | 34 - gnu/usr.bin/gcc2/libgcc/_nesf2.c | 35 - gnu/usr.bin/gcc2/libgcc/_new_handler.c | 223 - gnu/usr.bin/gcc2/libgcc/_op_delete.c | 92 - gnu/usr.bin/gcc2/libgcc/_op_new.c | 100 - gnu/usr.bin/gcc2/libgcc/_shtab.c | 96 - gnu/usr.bin/gcc2/libgcc/_subdf3.c | 33 - gnu/usr.bin/gcc2/libgcc/_subsf3.c | 34 - gnu/usr.bin/gcc2/libgcc/_trampoline.c | 83 - gnu/usr.bin/gcc2/libgcc/_truncdfsf2.c | 34 - gnu/usr.bin/gcc2/libgcc/_ucmpdi2.c | 102 - gnu/usr.bin/gcc2/libgcc/_udiv_w_sdiv.c | 176 - gnu/usr.bin/gcc2/libgcc/_udivdi3.c | 93 - gnu/usr.bin/gcc2/libgcc/_udivmoddi4.c | 213 - gnu/usr.bin/gcc2/libgcc/_udivsi3.c | 33 - gnu/usr.bin/gcc2/libgcc/_umoddi3.c | 95 - gnu/usr.bin/gcc2/libgcc/_umodsi3.c | 33 - gnu/usr.bin/gcc2/libgcc/_varargs.c | 90 - gnu/usr.bin/gcc2/libgcc/clean.sed | 4 - gnu/usr.bin/gdb/Xgdb.ad | 8 - gnu/usr.bin/gdb/blockframe.c | 623 - gnu/usr.bin/gdb/breakpoint.c | 1384 -- gnu/usr.bin/gdb/command.c | 860 -- gnu/usr.bin/gdb/command.h | 80 - gnu/usr.bin/gdb/config/altos-dep.c | 589 - gnu/usr.bin/gdb/config/convex-dep.c | 1952 --- gnu/usr.bin/gdb/config/convex-opcode.h | 1677 --- gnu/usr.bin/gdb/config/convex-pinsn.c | 318 - gnu/usr.bin/gdb/config/default-dep.c | 586 - gnu/usr.bin/gdb/config/gld-pinsn.c | 294 - gnu/usr.bin/gdb/config/gould-dep.c | 564 - gnu/usr.bin/gdb/config/hp300bsd-dep.c | 1160 -- gnu/usr.bin/gdb/config/hp9k320-dep.c | 702 - gnu/usr.bin/gdb/config/i386-dep.c | 1279 -- gnu/usr.bin/gdb/config/i386-pinsn.c | 1816 --- gnu/usr.bin/gdb/config/i386bsd-dep.c | 1868 --- gnu/usr.bin/gdb/config/isi-dep.c | 630 - gnu/usr.bin/gdb/config/m-altos.h | 804 -- gnu/usr.bin/gdb/config/m-convex.h | 612 - gnu/usr.bin/gdb/config/m-hp9k320.h | 583 - gnu/usr.bin/gdb/config/m-i386-sv32.h | 31 - gnu/usr.bin/gdb/config/m-i386.h | 397 - gnu/usr.bin/gdb/config/m-i386bsd.h | 374 - gnu/usr.bin/gdb/config/m-i386g-sv32.h | 31 - gnu/usr.bin/gdb/config/m-i386gas.h | 40 - gnu/usr.bin/gdb/config/m-isi.h | 525 - gnu/usr.bin/gdb/config/m-m68kbsd.h | 543 - gnu/usr.bin/gdb/config/m-merlin.h | 479 - gnu/usr.bin/gdb/config/m-news.h | 600 - gnu/usr.bin/gdb/config/m-newsos3.h | 120 - gnu/usr.bin/gdb/config/m-npl.h | 534 - gnu/usr.bin/gdb/config/m-pn.h | 518 - gnu/usr.bin/gdb/config/m-pyr.h | 615 - gnu/usr.bin/gdb/config/m-sparc.h | 501 - gnu/usr.bin/gdb/config/m-sun2.h | 465 - gnu/usr.bin/gdb/config/m-sun2os4.h | 24 - gnu/usr.bin/gdb/config/m-sun3.h | 519 - gnu/usr.bin/gdb/config/m-sun3os4.h | 32 - gnu/usr.bin/gdb/config/m-sun4os4.h | 27 - gnu/usr.bin/gdb/config/m-symmetry.h | 617 - gnu/usr.bin/gdb/config/m-tahoe.h | 477 - gnu/usr.bin/gdb/config/m-umax.h | 469 - gnu/usr.bin/gdb/config/m-vax.h | 475 - gnu/usr.bin/gdb/config/m68k-opcode.h | 1683 --- gnu/usr.bin/gdb/config/m68k-pinsn.c | 902 -- gnu/usr.bin/gdb/config/m68kbsd-dep.c | 1160 -- gnu/usr.bin/gdb/config/news-dep.c | 643 - gnu/usr.bin/gdb/config/npl-opcode.h | 425 - gnu/usr.bin/gdb/config/ns32k-opcode.h | 331 - gnu/usr.bin/gdb/config/ns32k-pinsn.c | 526 - gnu/usr.bin/gdb/config/pn-opcode.h | 285 - gnu/usr.bin/gdb/config/pyr-dep.c | 823 -- gnu/usr.bin/gdb/config/pyr-opcode.h | 290 - gnu/usr.bin/gdb/config/pyr-pinsn.c | 350 - gnu/usr.bin/gdb/config/sparc-dep.c | 1457 -- gnu/usr.bin/gdb/config/sparc-opcode.h | 635 - gnu/usr.bin/gdb/config/sparc-pinsn.c | 452 - gnu/usr.bin/gdb/config/sun3-dep.c | 632 - gnu/usr.bin/gdb/config/symmetry-dep.c | 1291 -- gnu/usr.bin/gdb/config/tahoe-opcode.h | 215 - gnu/usr.bin/gdb/config/tahoe-pinsn.c | 260 - gnu/usr.bin/gdb/config/umax-dep.c | 592 - gnu/usr.bin/gdb/config/vax-opcode.h | 385 - gnu/usr.bin/gdb/config/vax-pinsn.c | 252 - gnu/usr.bin/gdb/copying.c | 216 - gnu/usr.bin/gdb/core.c | 580 - gnu/usr.bin/gdb/cplus-dem.c | 1000 -- gnu/usr.bin/gdb/dbxread.c | 5738 -------- gnu/usr.bin/gdb/defs.h | 123 - gnu/usr.bin/gdb/environ.c | 186 - gnu/usr.bin/gdb/environ.h | 42 - gnu/usr.bin/gdb/eval.c | 1066 -- gnu/usr.bin/gdb/expprint.c | 328 - gnu/usr.bin/gdb/expread.y | 1783 --- gnu/usr.bin/gdb/expression.h | 194 - gnu/usr.bin/gdb/findvar.c | 583 - gnu/usr.bin/gdb/frame.h | 118 - gnu/usr.bin/gdb/gdb.1 | 2 - gnu/usr.bin/gdb/getpagesize.h | 27 - gnu/usr.bin/gdb/infcmd.c | 1199 -- gnu/usr.bin/gdb/inferior.h | 143 - gnu/usr.bin/gdb/inflow.c | 566 - gnu/usr.bin/gdb/infrun.c | 1459 -- gnu/usr.bin/gdb/kgdb_proto.h | 62 - gnu/usr.bin/gdb/main.c | 2242 --- gnu/usr.bin/gdb/obstack.c | 316 - gnu/usr.bin/gdb/obstack.h | 375 - gnu/usr.bin/gdb/printcmd.c | 1872 --- gnu/usr.bin/gdb/regex.c | 1741 --- gnu/usr.bin/gdb/regex.h | 188 - gnu/usr.bin/gdb/remote-sl.c | 12 - gnu/usr.bin/gdb/remote.c | 627 - gnu/usr.bin/gdb/source.c | 1167 -- gnu/usr.bin/gdb/stab.def | 115 - gnu/usr.bin/gdb/stack.c | 961 -- gnu/usr.bin/gdb/symmisc.c | 587 - gnu/usr.bin/gdb/symseg.h | 524 - gnu/usr.bin/gdb/symtab.c | 2472 ---- gnu/usr.bin/gdb/symtab.h | 385 - gnu/usr.bin/gdb/utils.c | 1091 -- gnu/usr.bin/gdb/valarith.c | 691 - gnu/usr.bin/gdb/valops.c | 1419 -- gnu/usr.bin/gdb/valprint.c | 1443 -- gnu/usr.bin/gdb/value.h | 215 - gnu/usr.bin/gdb/values.c | 1060 -- gnu/usr.bin/gdb/wait.h | 82 - gnu/usr.bin/groff/Makefile.gnu | 285 - gnu/usr.bin/groff/devices/devdvi/texex.map | 100 - gnu/usr.bin/groff/devices/devdvi/texi.map | 125 - gnu/usr.bin/groff/devices/devdvi/texmi.map | 29 - gnu/usr.bin/groff/devices/devdvi/texr.map | 125 - gnu/usr.bin/groff/devices/devdvi/texsy.map | 100 - gnu/usr.bin/groff/devices/devdvi/textt.map | 126 - gnu/usr.bin/groff/devices/devps/symbol.diff | 65 - gnu/usr.bin/groff/devices/devps/symbolchars | 3 - gnu/usr.bin/groff/devices/devps/symbolsl.afm | 203 - gnu/usr.bin/groff/devices/devps/symbolsl.ps | 40 - gnu/usr.bin/groff/devices/devps/textmap | 492 - gnu/usr.bin/groff/devices/devps/zapfdr.ps | 222 - gnu/usr.bin/groff/grops/Makefile.dep | 6 - gnu/usr.bin/groff/libXdvi/Makefile.gnu | 25 - gnu/usr.bin/groff/libXdvi/Menu.h | 46 - gnu/usr.bin/groff/libXdvi/XFontName.c | 254 - gnu/usr.bin/groff/libXdvi/XFontName.h | 45 - gnu/usr.bin/groff/libXdvi/draw.c | 368 - gnu/usr.bin/groff/libXdvi/font.c | 350 - gnu/usr.bin/groff/libXdvi/lex.c | 103 - gnu/usr.bin/groff/libXdvi/page.c | 85 - gnu/usr.bin/groff/libXdvi/parse.c | 419 - gnu/usr.bin/groff/libgroff/getpagesize.h | 25 - gnu/usr.bin/groff/libgroff/groff.order | 21 - gnu/usr.bin/groff/libgroff/iftoa.cc | 75 - gnu/usr.bin/groff/libgroff/itoa.cc | 53 - gnu/usr.bin/groff/libgroff/lib.h | 94 - gnu/usr.bin/groff/libgroff/ptable.h | 159 - gnu/usr.bin/groff/libgroff/stringclass.h | 174 - gnu/usr.bin/groff/libgroff/version.cc | 3 - gnu/usr.bin/groff/macros/tmac.pic | 10 - gnu/usr.bin/groff/macros/tmac.ps | 115 - gnu/usr.bin/groff/macros/tmac.psfig | 86 - gnu/usr.bin/groff/macros/tmac.s | 1808 --- gnu/usr.bin/groff/macros/tmac.tty | 44 - gnu/usr.bin/groff/man/groff_me.man | 271 - gnu/usr.bin/groff/man/groff_ms.man | 209 - gnu/usr.bin/groff/man/groff_out.man | 215 - gnu/usr.bin/groff/man/grog.man | 54 - gnu/usr.bin/groff/man/gsoelim.man | 42 - gnu/usr.bin/groff/man/tfmtodit.man | 144 - gnu/usr.bin/gzip-1.0.7/THANKS | 136 - gnu/usr.bin/gzip-1.0.7/TODO | 58 - gnu/usr.bin/gzip-1.0.7/algorithm.doc | 148 - gnu/usr.bin/gzip-1.0.7/alloca.c | 195 - gnu/usr.bin/gzip-1.0.7/bits.c | 205 - gnu/usr.bin/gzip-1.0.7/configure | 674 - gnu/usr.bin/gzip-1.0.7/configure.in | 116 - gnu/usr.bin/gzip-1.0.7/crypt.c | 6 - gnu/usr.bin/gzip-1.0.7/crypt.h | 12 - gnu/usr.bin/gzip-1.0.7/deflate.c | 733 - gnu/usr.bin/gzip-1.0.7/getopt.c | 711 - gnu/usr.bin/gzip-1.0.7/getopt.h | 128 - gnu/usr.bin/gzip-1.0.7/gpl.texinfo | 394 - gnu/usr.bin/gzip-1.0.7/gzexe.1 | 36 - gnu/usr.bin/gzip-1.0.7/gzexe.in | 135 - gnu/usr.bin/gzip-1.0.7/gzip-tar.patch | 124 - gnu/usr.bin/gzip-1.0.7/gzip.1 | 340 - gnu/usr.bin/gzip-1.0.7/gzip.c | 1369 -- gnu/usr.bin/gzip-1.0.7/gzip.doc | 214 - gnu/usr.bin/gzip-1.0.7/gzip.h | 288 - gnu/usr.bin/gzip-1.0.7/gzip.info | 678 - gnu/usr.bin/gzip-1.0.7/gzip.texi | 339 - gnu/usr.bin/gzip-1.0.7/inflate.c | 952 -- gnu/usr.bin/gzip-1.0.7/lzw.c | 26 - gnu/usr.bin/gzip-1.0.7/lzw.h | 42 - gnu/usr.bin/gzip-1.0.7/makecrc.c | 64 - gnu/usr.bin/gzip-1.0.7/match.S | 377 - gnu/usr.bin/gzip-1.0.7/msdos/match.asm | 240 - gnu/usr.bin/gzip-1.0.7/msdos/tailor.c | 53 - gnu/usr.bin/gzip-1.0.7/revision.h | 16 - gnu/usr.bin/gzip-1.0.7/tailor.h | 207 - gnu/usr.bin/gzip-1.0.7/texinfo.tex | 3350 ----- gnu/usr.bin/gzip-1.0.7/trees.c | 1076 -- gnu/usr.bin/gzip-1.0.7/unlzw.c | 365 - gnu/usr.bin/gzip-1.0.7/unpack.c | 238 - gnu/usr.bin/gzip-1.0.7/unzip.c | 186 - gnu/usr.bin/gzip-1.0.7/util.c | 414 - gnu/usr.bin/gzip-1.0.7/zdiff.1 | 45 - gnu/usr.bin/gzip-1.0.7/zdiff.in | 68 - gnu/usr.bin/gzip-1.0.7/zforce.1 | 23 - gnu/usr.bin/gzip-1.0.7/zforce.in | 45 - gnu/usr.bin/gzip-1.0.7/zip.c | 113 - gnu/usr.bin/gzip-1.0.7/zmore.1 | 134 - gnu/usr.bin/gzip-1.0.7/zmore.in | 42 - gnu/usr.bin/gzip-1.0.7/znew.1 | 31 - gnu/usr.bin/gzip-1.0.7/znew.in | 126 - gnu/usr.bin/gzip-1.0.7/zread.c | 53 - gnu/usr.bin/gzip-1.1.1/algorithm.doc | 141 - gnu/usr.bin/gzip-1.1.1/bits.c | 205 - gnu/usr.bin/gzip-1.1.1/crypt.c | 6 - gnu/usr.bin/gzip-1.1.1/crypt.h | 12 - gnu/usr.bin/gzip-1.1.1/deflate.c | 730 - gnu/usr.bin/gzip-1.1.1/getopt.c | 711 - gnu/usr.bin/gzip-1.1.1/getopt.h | 128 - gnu/usr.bin/gzip-1.1.1/gzexe | 134 - gnu/usr.bin/gzip-1.1.1/gzexe.1 | 36 - gnu/usr.bin/gzip-1.1.1/gzexe.in | 135 - gnu/usr.bin/gzip-1.1.1/gzip.1 | 360 - gnu/usr.bin/gzip-1.1.1/gzip.c | 1458 -- gnu/usr.bin/gzip-1.1.1/gzip.h | 302 - gnu/usr.bin/gzip-1.1.1/inflate.c | 954 -- gnu/usr.bin/gzip-1.1.1/lzw.c | 27 - gnu/usr.bin/gzip-1.1.1/lzw.h | 42 - gnu/usr.bin/gzip-1.1.1/match.S | 379 - gnu/usr.bin/gzip-1.1.1/revision.h | 16 - gnu/usr.bin/gzip-1.1.1/tailor.h | 268 - gnu/usr.bin/gzip-1.1.1/trees.c | 1076 -- gnu/usr.bin/gzip-1.1.1/unlzw.c | 369 - gnu/usr.bin/gzip-1.1.1/unpack.c | 241 - gnu/usr.bin/gzip-1.1.1/unzip.c | 201 - gnu/usr.bin/gzip-1.1.1/util.c | 419 - gnu/usr.bin/gzip-1.1.1/zcmp | 67 - gnu/usr.bin/gzip-1.1.1/zdiff | 67 - gnu/usr.bin/gzip-1.1.1/zdiff.1 | 44 - gnu/usr.bin/gzip-1.1.1/zforce | 39 - gnu/usr.bin/gzip-1.1.1/zforce.1 | 20 - gnu/usr.bin/gzip-1.1.1/zip.c | 118 - gnu/usr.bin/gzip-1.1.1/zmore | 42 - gnu/usr.bin/gzip-1.1.1/zmore.1 | 134 - gnu/usr.bin/gzip-1.1.1/znew | 140 - gnu/usr.bin/gzip-1.1.1/znew.1 | 36 - gnu/usr.bin/lex/flex.skl | 1051 -- gnu/usr.bin/lex/flexdef.h | 895 -- gnu/usr.bin/lex/flexdoc.1 | 3059 ----- gnu/usr.bin/lex/gen.c | 1448 -- gnu/usr.bin/lex/initscan.c | 2534 ---- gnu/usr.bin/lex/main.c | 989 -- gnu/usr.bin/lex/misc.c | 773 -- gnu/usr.bin/lex/mkskel.sh | 16 - gnu/usr.bin/lex/nfa.c | 707 - gnu/usr.bin/lex/parse.y | 822 -- gnu/usr.bin/lex/pathnames.h | 37 - gnu/usr.bin/lex/scan.l | 550 - gnu/usr.bin/lex/sym.c | 262 - gnu/usr.bin/lex/tblcmp.c | 888 -- gnu/usr.bin/lex/version.h | 1 - gnu/usr.bin/lex/yylex.c | 199 - gnu/usr.bin/tar-1.11.2/create.c | 1454 -- gnu/usr.bin/tar-1.11.2/diffarch.c | 759 -- gnu/usr.bin/tar-1.11.2/extract.c | 907 -- gnu/usr.bin/tar-1.11.2/fnmatch.c | 173 - gnu/usr.bin/tar-1.11.2/fnmatch.h | 62 - gnu/usr.bin/tar-1.11.2/getdate.y | 969 -- gnu/usr.bin/tar-1.11.2/getoldopt.c | 96 - gnu/usr.bin/tar-1.11.2/getopt.c | 712 - gnu/usr.bin/tar-1.11.2/getopt.h | 125 - gnu/usr.bin/tar-1.11.2/getopt1.c | 161 - gnu/usr.bin/tar-1.11.2/getpagesize.h | 38 - gnu/usr.bin/tar-1.11.2/gnu.c | 677 - gnu/usr.bin/tar-1.11.2/list.c | 881 -- gnu/usr.bin/tar-1.11.2/mangle.c | 270 - gnu/usr.bin/tar-1.11.2/msd_dir.h | 44 - gnu/usr.bin/tar-1.11.2/names.c | 149 - gnu/usr.bin/tar-1.11.2/open3.h | 67 - gnu/usr.bin/tar-1.11.2/pathmax.h | 53 - gnu/usr.bin/tar-1.11.2/port.c | 1256 -- gnu/usr.bin/tar-1.11.2/port.h | 215 - gnu/usr.bin/tar-1.11.2/regex.c | 4932 ------- gnu/usr.bin/tar-1.11.2/regex.h | 490 - gnu/usr.bin/tar-1.11.2/rmt.h | 98 - gnu/usr.bin/tar-1.11.2/rtapelib.c | 582 - gnu/usr.bin/tar-1.11.2/tar.c | 1504 --- gnu/usr.bin/tar-1.11.2/tar.h | 291 - gnu/usr.bin/tar-1.11.2/update.c | 585 - gnu/usr.bin/tar-1.11.2/version.c | 1 - include/rpcsvc/nlm_prot.x | 182 - include/rpcsvc/rex.x | 234 - include/rpcsvc/rnusers.x | 91 - include/rpcsvc/rquota.x | 66 - include/rpcsvc/rstat.x | 150 - include/rpcsvc/rwall.x | 46 - include/rpcsvc/sm_inter.x | 120 - include/rpcsvc/spray.x | 89 - include/rpcsvc/yp.x | 296 - include/rpcsvc/yppasswd.x | 69 - lib/csu/mips/crt0.s | 111 - lib/libc/DB/btree/bt_get.c | 222 - lib/libc/DB/btree/bt_open.c | 428 - lib/libc/DB/btree/bt_overflow.c | 224 - lib/libc/DB/btree/bt_page.c | 94 - lib/libc/DB/btree/bt_put.c | 313 - lib/libc/DB/btree/bt_search.c | 119 - lib/libc/DB/btree/bt_seq.c | 365 - lib/libc/DB/btree/bt_split.c | 826 -- lib/libc/DB/btree/bt_stack.c | 92 - lib/libc/DB/btree/bt_utils.c | 227 - lib/libc/DB/btree/btree.h | 345 - lib/libc/DB/btree/extern.h | 71 - lib/libc/DB/hash/hash_buf.c | 344 - lib/libc/DB/hash/hash_func.c | 191 - lib/libc/DB/hash/hash_log2.c | 52 - lib/libc/DB/hash/hash_page.c | 941 -- lib/libc/DB/hash/hsearch.c | 108 - lib/libc/DB/hash/ndbm.c | 202 - lib/libc/DB/hash/page.h | 92 - lib/libc/DB/hash/search.h | 51 - lib/libc/DB/hash/tests/tseq.c | 88 - lib/libc/DB/hash/tests/tverify.c | 107 - lib/libc/DB/recno/rec_open.c | 229 - lib/libc/DB/recno/rec_put.c | 237 - lib/libc/DB/recno/rec_search.c | 127 - lib/libc/DB/recno/rec_seq.c | 122 - lib/libc/DB/recno/rec_utils.c | 103 - lib/libc/DB/recno/recno.h | 39 - lib/libc/arch/hp300/gen/cmpdf2.S | 58 - lib/libc/arch/hp300/gen/cmpdf2.s | 58 - lib/libc/arch/hp300/gen/cmpsf2.S | 58 - lib/libc/arch/hp300/gen/cmpsf2.s | 58 - lib/libc/arch/hp300/gen/divdf3.S | 53 - lib/libc/arch/hp300/gen/divdf3.s | 53 - lib/libc/arch/hp300/gen/divsf3.S | 51 - lib/libc/arch/hp300/gen/divsf3.s | 51 - lib/libc/arch/hp300/gen/divsi3.S | 50 - lib/libc/arch/hp300/gen/divsi3.s | 50 - lib/libc/arch/hp300/gen/extendsfdf2.S | 52 - lib/libc/arch/hp300/gen/extendsfdf2.s | 52 - lib/libc/arch/hp300/gen/fabs.S | 56 - lib/libc/arch/hp300/gen/fabs.s | 56 - lib/libc/arch/hp300/gen/fixdfsi.S | 50 - lib/libc/arch/hp300/gen/fixdfsi.s | 50 - lib/libc/arch/hp300/gen/fixunsdfsi.S | 57 - lib/libc/arch/hp300/gen/fixunsdfsi.s | 57 - lib/libc/arch/hp300/gen/floatsidf.S | 53 - lib/libc/arch/hp300/gen/floatsidf.s | 53 - lib/libc/arch/hp300/gen/frexp.c | 66 - lib/libc/arch/hp300/gen/infinity.c | 10 - lib/libc/arch/hp300/gen/isinf.c | 65 - lib/libc/arch/hp300/gen/ldexp.S | 59 - lib/libc/arch/hp300/gen/ldexp.s | 59 - lib/libc/arch/hp300/gen/lshlsi3.S | 51 - lib/libc/arch/hp300/gen/lshlsi3.s | 51 - lib/libc/arch/hp300/gen/lshrsi3.S | 51 - lib/libc/arch/hp300/gen/lshrsi3.s | 51 - lib/libc/arch/hp300/gen/modf.S | 59 - lib/libc/arch/hp300/gen/modf.s | 59 - lib/libc/arch/hp300/gen/modsi3.S | 50 - lib/libc/arch/hp300/gen/modsi3.s | 50 - lib/libc/arch/hp300/gen/muldf3.S | 53 - lib/libc/arch/hp300/gen/muldf3.s | 53 - lib/libc/arch/hp300/gen/mulsf3.S | 51 - lib/libc/arch/hp300/gen/mulsf3.s | 51 - lib/libc/arch/hp300/gen/mulsi3.S | 50 - lib/libc/arch/hp300/gen/mulsi3.s | 50 - lib/libc/arch/hp300/gen/negdf2.S | 51 - lib/libc/arch/hp300/gen/negdf2.s | 51 - lib/libc/arch/hp300/gen/negsf2.S | 50 - lib/libc/arch/hp300/gen/negsf2.s | 50 - lib/libc/arch/hp300/gen/saveregs.c | 46 - lib/libc/arch/hp300/gen/setjmp.S | 93 - lib/libc/arch/hp300/gen/setjmp.s | 93 - lib/libc/arch/hp300/gen/subdf3.S | 53 - lib/libc/arch/hp300/gen/subdf3.s | 53 - lib/libc/arch/hp300/gen/subsf3.S | 51 - lib/libc/arch/hp300/gen/subsf3.s | 51 - lib/libc/arch/hp300/gen/truncdfsf2.S | 50 - lib/libc/arch/hp300/gen/truncdfsf2.s | 50 - lib/libc/arch/hp300/gen/udivsi3.S | 50 - lib/libc/arch/hp300/gen/udivsi3.s | 50 - lib/libc/arch/hp300/gen/umodsi3.S | 50 - lib/libc/arch/hp300/gen/umodsi3.s | 50 - lib/libc/arch/hp300/gen/umulsi3.S | 50 - lib/libc/arch/hp300/gen/umulsi3.s | 50 - lib/libc/arch/hp300/string/strcpy.S | 53 - lib/libc/arch/hp300/string/strcpy.s | 53 - lib/libc/arch/hp300/string/strlen.S | 53 - lib/libc/arch/hp300/string/strlen.s | 53 - lib/libc/arch/hp300/string/strncmp.S | 71 - lib/libc/arch/hp300/string/strncmp.s | 71 - lib/libc/arch/hp300/string/strncpy.S | 63 - lib/libc/arch/hp300/string/strncpy.s | 63 - lib/libc/arch/hp300/sys/reboot.S | 48 - lib/libc/arch/hp300/sys/reboot.s | 48 - lib/libc/arch/hp300/sys/sbrk.S | 67 - lib/libc/arch/hp300/sys/sbrk.s | 67 - lib/libc/arch/hp300/sys/setlogin.S | 46 - lib/libc/arch/hp300/sys/setlogin.s | 46 - lib/libc/arch/hp300/sys/sigpending.S | 50 - lib/libc/arch/hp300/sys/sigpending.s | 50 - lib/libc/arch/hp300/sys/sigprocmask.S | 69 - lib/libc/arch/hp300/sys/sigprocmask.s | 69 - lib/libc/arch/hp300/sys/sigreturn.S | 59 - lib/libc/arch/hp300/sys/sigreturn.s | 59 - lib/libc/arch/hp300/sys/sigsuspend.S | 57 - lib/libc/arch/hp300/sys/sigsuspend.s | 57 - lib/libc/arch/hp300/sys/syscall.S | 52 - lib/libc/arch/hp300/sys/syscall.s | 52 - lib/libc/arch/i386/gen/modf.s | 79 - lib/libc/arch/i386/gen/setjmp.s | 91 - lib/libc/arch/i386/gen/sigsetjmp.s | 88 - lib/libc/arch/i386/gen/udivsi3.s | 51 - lib/libc/arch/i386/string/memmove.s | 90 - lib/libc/arch/i386/string/memset.s | 97 - lib/libc/arch/i386/string/rindex.s | 70 - lib/libc/arch/i386/string/strcat.s | 106 - lib/libc/arch/i386/string/strchr.s | 69 - lib/libc/arch/i386/string/strcmp.s | 125 - lib/libc/arch/i386/string/strcpy.s | 95 - lib/libc/arch/i386/string/strlen.s | 59 - lib/libc/arch/i386/string/strncmp.s | 157 - lib/libc/arch/i386/string/strrchr.s | 70 - lib/libc/arch/i386/string/swab.s | 106 - lib/libc/arch/i386/sys/reboot.s | 48 - lib/libc/arch/i386/sys/sbrk.s | 91 - lib/libc/arch/i386/sys/setlogin.s | 60 - lib/libc/arch/i386/sys/sigpending.s | 51 - lib/libc/arch/i386/sys/sigprocmask.s | 68 - lib/libc/arch/i386/sys/sigreturn.s | 58 - lib/libc/arch/i386/sys/sigsuspend.s | 58 - lib/libc/arch/i386/sys/syscall.s | 56 - lib/libc/arch/m68k/gen/cmpdf2.s | 58 - lib/libc/arch/m68k/gen/cmpsf2.s | 58 - lib/libc/arch/m68k/gen/divdf3.s | 53 - lib/libc/arch/m68k/gen/divsf3.s | 51 - lib/libc/arch/m68k/gen/divsi3.s | 50 - lib/libc/arch/m68k/gen/extendsfdf2.s | 52 - lib/libc/arch/m68k/gen/fabs.s | 56 - lib/libc/arch/m68k/gen/fixdfsi.s | 50 - lib/libc/arch/m68k/gen/fixunsdfsi.s | 57 - lib/libc/arch/m68k/gen/floatsidf.s | 53 - lib/libc/arch/m68k/gen/ldexp.s | 59 - lib/libc/arch/m68k/gen/lshlsi3.s | 51 - lib/libc/arch/m68k/gen/lshrsi3.s | 51 - lib/libc/arch/m68k/gen/modf.s | 59 - lib/libc/arch/m68k/gen/modsi3.s | 50 - lib/libc/arch/m68k/gen/muldf3.s | 53 - lib/libc/arch/m68k/gen/mulsf3.s | 51 - lib/libc/arch/m68k/gen/mulsi3.s | 50 - lib/libc/arch/m68k/gen/negdf2.s | 51 - lib/libc/arch/m68k/gen/negsf2.s | 50 - lib/libc/arch/m68k/gen/setjmp.s | 93 - lib/libc/arch/m68k/gen/subdf3.s | 53 - lib/libc/arch/m68k/gen/subsf3.s | 51 - lib/libc/arch/m68k/gen/truncdfsf2.s | 50 - lib/libc/arch/m68k/gen/udivsi3.s | 50 - lib/libc/arch/m68k/gen/umodsi3.s | 50 - lib/libc/arch/m68k/gen/umulsi3.s | 50 - lib/libc/arch/m68k/string/strcpy.s | 53 - lib/libc/arch/m68k/string/strlen.s | 53 - lib/libc/arch/m68k/string/strncmp.s | 71 - lib/libc/arch/m68k/string/strncpy.s | 63 - lib/libc/arch/m68k/sys/reboot.s | 48 - lib/libc/arch/m68k/sys/sbrk.s | 82 - lib/libc/arch/m68k/sys/setlogin.s | 53 - lib/libc/arch/m68k/sys/sigpending.s | 50 - lib/libc/arch/m68k/sys/sigprocmask.s | 72 - lib/libc/arch/m68k/sys/sigreturn.s | 62 - lib/libc/arch/m68k/sys/sigsuspend.s | 60 - lib/libc/arch/m68k/sys/syscall.s | 55 - lib/libc/arch/mips/gen/_setjmp.s | 125 - lib/libc/arch/mips/gen/fabs.s | 55 - lib/libc/arch/mips/gen/isinf.s | 96 - lib/libc/arch/mips/gen/ldexp.s | 216 - lib/libc/arch/mips/gen/modf.s | 61 - lib/libc/arch/mips/gen/setjmp.s | 119 - lib/libc/arch/mips/net/htonl.s | 68 - lib/libc/arch/mips/net/htons.s | 64 - lib/libc/arch/mips/string/bcmp.s | 133 - lib/libc/arch/mips/string/bcopy.s | 139 - lib/libc/arch/mips/string/bzero.s | 74 - lib/libc/arch/mips/string/ffs.s | 56 - lib/libc/arch/mips/string/index.s | 55 - lib/libc/arch/mips/string/rindex.s | 54 - lib/libc/arch/mips/string/strcmp.s | 65 - lib/libc/arch/mips/string/strlen.s | 52 - lib/libc/arch/mips/sys/Ovfork.s | 61 - lib/libc/arch/mips/sys/brk.s | 59 - lib/libc/arch/mips/sys/cerror.s | 51 - lib/libc/arch/mips/sys/exect.s | 51 - lib/libc/arch/mips/sys/fork.s | 54 - lib/libc/arch/mips/sys/pipe.s | 54 - lib/libc/arch/mips/sys/ptrace.s | 52 - lib/libc/arch/mips/sys/reboot.s | 51 - lib/libc/arch/mips/sys/sbrk.s | 66 - lib/libc/arch/mips/sys/setlogin.s | 52 - lib/libc/arch/mips/sys/sigpending.s | 53 - lib/libc/arch/mips/sys/sigprocmask.s | 61 - lib/libc/arch/mips/sys/sigreturn.s | 48 - lib/libc/arch/mips/sys/sigsuspend.s | 53 - lib/libc/arch/mips/sys/syscall.s | 46 - lib/libc/arch/ns32k/gen/_setjmp.s | 64 - lib/libc/arch/ns32k/gen/alloca.s | 37 - lib/libc/arch/ns32k/gen/fabs.s | 28 - lib/libc/arch/ns32k/gen/frexp.s | 62 - lib/libc/arch/ns32k/gen/ldexp.s | 84 - lib/libc/arch/ns32k/gen/modf.s | 68 - lib/libc/arch/ns32k/gen/setjmp.s | 70 - lib/libc/arch/ns32k/net/ntoh.S | 52 - lib/libc/arch/ns32k/net/ntoh.s | 52 - lib/libc/arch/ns32k/stdlib/abs.s | 28 - lib/libc/arch/ns32k/sys/Ovfork.s | 36 - lib/libc/arch/ns32k/sys/brk.s | 43 - lib/libc/arch/ns32k/sys/cerror.s | 32 - lib/libc/arch/ns32k/sys/exect.s | 34 - lib/libc/arch/ns32k/sys/fork.s | 34 - lib/libc/arch/ns32k/sys/mount.s | 29 - lib/libc/arch/ns32k/sys/pipe.s | 32 - lib/libc/arch/ns32k/sys/ptrace.s | 39 - lib/libc/arch/ns32k/sys/reboot.s | 27 - lib/libc/arch/ns32k/sys/sbrk.s | 43 - lib/libc/arch/ns32k/sys/setlogin.s | 31 - lib/libc/arch/ns32k/sys/sigpending.s | 31 - lib/libc/arch/ns32k/sys/sigprocmask.s | 50 - lib/libc/arch/ns32k/sys/sigreturn.s | 38 - lib/libc/arch/ns32k/sys/sigsuspend.s | 35 - lib/libc/arch/ns32k/sys/syscall.s | 31 - lib/libc/arch/pc532/gen/ldexp.S | 84 - lib/libc/arch/pc532/gen/modf.S | 68 - lib/libc/arch/pc532/gen/setjmp.S | 70 - lib/libc/arch/pc532/sys/reboot.S | 27 - lib/libc/arch/pc532/sys/reboot.s | 27 - lib/libc/arch/pc532/sys/sbrk.S | 43 - lib/libc/arch/pc532/sys/sbrk.s | 43 - lib/libc/arch/pc532/sys/setlogin.S | 31 - lib/libc/arch/pc532/sys/setlogin.s | 31 - lib/libc/arch/pc532/sys/sigpending.S | 31 - lib/libc/arch/pc532/sys/sigpending.s | 31 - lib/libc/arch/pc532/sys/sigprocmask.S | 50 - lib/libc/arch/pc532/sys/sigprocmask.s | 50 - lib/libc/arch/pc532/sys/sigreturn.S | 38 - lib/libc/arch/pc532/sys/sigreturn.s | 38 - lib/libc/arch/pc532/sys/sigsuspend.S | 35 - lib/libc/arch/pc532/sys/sigsuspend.s | 35 - lib/libc/arch/pc532/sys/syscall.S | 31 - lib/libc/arch/pc532/sys/syscall.s | 31 - lib/libc/arch/sparc/gen/umul.s | 188 - lib/libc/arch/sparc/sys/reboot.s | 48 - lib/libc/arch/sparc/sys/sbrk.s | 66 - lib/libc/arch/sparc/sys/setlogin.s | 52 - lib/libc/arch/sparc/sys/sigpending.s | 56 - lib/libc/arch/sparc/sys/sigprocmask.s | 67 - lib/libc/arch/sparc/sys/sigreturn.s | 50 - lib/libc/arch/sparc/sys/sigsuspend.s | 51 - lib/libc/arch/sparc/sys/syscall.s | 51 - lib/libc/compat-43/creat.2 | 69 - lib/libc/compat-43/killpg.2 | 96 - lib/libc/compat-43/setregid.2 | 93 - lib/libc/compat-43/setreuid.2 | 91 - lib/libc/compat-43/sigblock.2 | 85 - lib/libc/compat-43/sigpause.2 | 75 - lib/libc/compat-43/sigsetmask.2 | 83 - lib/libc/compat-43/sigvec.2 | 326 - lib/libc/db/btree/lrucache.c | 377 - lib/libc/db/btree/lrucache.h | 110 - lib/libc/db/btree/lruhash.c | 173 - lib/libc/db/btree/lrutils.c | 244 - lib/libc/db/btree/search.c | 296 - lib/libc/db/btree/seq.c | 318 - lib/libc/db/btree/split.c | 691 - lib/libc/db/btree/storage.c | 664 - lib/libc/db/btree/updutils.c | 174 - lib/libc/db/btree/utils.c | 350 - lib/libc/db/hash/hfunc.c | 179 - lib/libc/db/hash/log2.c | 49 - lib/libc/db/hash/page.c | 905 -- lib/libc/gen/regexp/regmagic.h | 7 - lib/libc/gen/regexp/regsub.c | 86 - lib/libc/gen/semget.c | 19 - lib/libc/gen/semop.c | 19 - lib/libc/gen/shmat.c | 19 - lib/libc/gen/shmctl.c | 19 - lib/libc/gen/shmdt.c | 17 - lib/libc/gen/shmget.c | 19 - lib/libc/hp300/gen/cmpdf2.s | 58 - lib/libc/hp300/gen/cmpsf2.s | 58 - lib/libc/hp300/gen/divdf3.s | 53 - lib/libc/hp300/gen/divsf3.s | 51 - lib/libc/hp300/gen/divsi3.s | 50 - lib/libc/hp300/gen/extendsfdf2.s | 52 - lib/libc/hp300/gen/fabs.s | 56 - lib/libc/hp300/gen/fixdfsi.s | 50 - lib/libc/hp300/gen/fixunsdfsi.s | 57 - lib/libc/hp300/gen/floatsidf.s | 53 - lib/libc/hp300/gen/frexp.c | 66 - lib/libc/hp300/gen/infinity.c | 10 - lib/libc/hp300/gen/isinf.c | 65 - lib/libc/hp300/gen/ldexp.s | 59 - lib/libc/hp300/gen/lshlsi3.s | 51 - lib/libc/hp300/gen/lshrsi3.s | 51 - lib/libc/hp300/gen/modf.s | 59 - lib/libc/hp300/gen/modsi3.s | 50 - lib/libc/hp300/gen/muldf3.s | 53 - lib/libc/hp300/gen/mulsf3.s | 51 - lib/libc/hp300/gen/mulsi3.s | 50 - lib/libc/hp300/gen/negdf2.s | 51 - lib/libc/hp300/gen/negsf2.s | 50 - lib/libc/hp300/gen/saveregs.c | 46 - lib/libc/hp300/gen/setjmp.s | 93 - lib/libc/hp300/gen/subdf3.s | 53 - lib/libc/hp300/gen/subsf3.s | 51 - lib/libc/hp300/gen/truncdfsf2.s | 50 - lib/libc/hp300/gen/udivsi3.s | 50 - lib/libc/hp300/gen/umodsi3.s | 50 - lib/libc/hp300/gen/umulsi3.s | 50 - lib/libc/hp300/string/strcpy.s | 53 - lib/libc/hp300/string/strlen.s | 53 - lib/libc/hp300/string/strncmp.s | 71 - lib/libc/hp300/string/strncpy.s | 63 - lib/libc/i386/gen/frexp.c | 66 - lib/libc/i386/gen/infinity.c | 10 - lib/libc/i386/gen/isinf.c | 65 - lib/libc/i386/gen/ldexp.c | 61 - lib/libc/i386/gen/modf.s | 77 - lib/libc/i386/gen/setjmp.s | 89 - lib/libc/i386/gen/udivsi3.s | 48 - lib/libc/i386/string/memmove.s | 90 - lib/libc/i386/string/memset.s | 97 - lib/libc/i386/string/rindex.s | 70 - lib/libc/i386/string/strcat.s | 106 - lib/libc/i386/string/strchr.s | 69 - lib/libc/i386/string/strcmp.s | 125 - lib/libc/i386/string/strcpy.s | 95 - lib/libc/i386/string/strlen.s | 59 - lib/libc/i386/string/strncmp.s | 157 - lib/libc/i386/string/strrchr.s | 70 - lib/libc/i386/string/swab.s | 107 - lib/libc/i386/sys/reboot.s | 46 - lib/libc/i386/sys/sbrk.s | 89 - lib/libc/i386/sys/setlogin.s | 58 - lib/libc/i386/sys/sigpending.s | 49 - lib/libc/i386/sys/sigprocmask.s | 66 - lib/libc/i386/sys/sigreturn.s | 56 - lib/libc/i386/sys/sigsuspend.s | 56 - lib/libc/i386/sys/syscall.s | 54 - lib/libc/pc532/gen/ldexp.s | 84 - lib/libc/pc532/gen/modf.s | 68 - lib/libc/pc532/gen/setjmp.s | 70 - lib/libc/pc532/sys/reboot.s | 27 - lib/libc/pc532/sys/sbrk.s | 43 - lib/libc/pc532/sys/setlogin.s | 31 - lib/libc/pc532/sys/sigpending.s | 31 - lib/libc/pc532/sys/sigprocmask.s | 50 - lib/libc/pc532/sys/sigreturn.s | 38 - lib/libc/pc532/sys/sigsuspend.s | 35 - lib/libc/pc532/sys/syscall.s | 31 - lib/libc/regex/regcomp.ih | 51 - lib/libc/regex/regerror.ih | 12 - lib/libc/regex/regex.h | 73 - lib/libc/regex/split.c | 316 - lib/libc/regex/tests | 475 - lib/libc/sparc/gen/isnan.c | 55 - lib/libc/sparc/gen/ldexp.c | 148 - lib/libc/sparc/gen/modf.s | 185 - lib/libc/sparc/gen/mul.s | 155 - lib/libc/sparc/gen/saveregs.s | 60 - lib/libc/sparc/gen/setjmp.s | 114 - lib/libc/sparc/gen/umul.s | 188 - lib/libc/sparc/sys/reboot.s | 48 - lib/libc/sparc/sys/sbrk.s | 66 - lib/libc/sparc/sys/setlogin.s | 52 - lib/libc/sparc/sys/sigpending.s | 56 - lib/libc/sparc/sys/sigprocmask.s | 67 - lib/libc/sparc/sys/sigreturn.s | 50 - lib/libc/sparc/sys/sigsuspend.s | 51 - lib/libc/sparc/sys/syscall.s | 51 - lib/libc/sys/uname.2 | 101 - lib/libcompat/4.3/m68k/insque.s | 54 - lib/libcompat/4.3/m68k/remque.s | 52 - lib/libm/common_source/atan.c | 88 - lib/libm/common_source/atan2.3 | 189 - lib/libm/common_source/atanh.3 | 84 - lib/libm/common_source/atanh.c | 84 - lib/libm/common_source/ceil.3 | 66 - lib/libm/common_source/cos.3 | 74 - lib/libm/common_source/cosh.3 | 75 - lib/libm/common_source/cosh.c | 134 - lib/libm/common_source/erf.3 | 83 - lib/libm/common_source/erf.c | 397 - lib/libm/common_source/exp.3 | 299 - lib/libm/common_source/exp.c | 165 - lib/libm/common_source/exp__D.c | 167 - lib/libm/common_source/exp__E.c | 137 - lib/libm/common_source/expm1.c | 168 - lib/libm/common_source/fabs.3 | 67 - lib/libm/common_source/floor.3 | 66 - lib/libm/common_source/floor.c | 138 - lib/libm/common_source/fmod.3 | 76 - lib/libm/common_source/fmod.c | 156 - lib/libm/common_source/gamma.c | 337 - lib/libm/common_source/hypot.3 | 125 - lib/libm/common_source/ieee.3 | 268 - lib/libm/common_source/infnan.3 | 181 - lib/libm/common_source/j0.3 | 128 - lib/libm/common_source/j0.c | 440 - lib/libm/common_source/j1.c | 447 - lib/libm/common_source/jn.c | 313 - lib/libm/common_source/lgamma.3 | 124 - lib/libm/common_source/lgamma.c | 308 - lib/libm/common_source/log.c | 149 - lib/libm/common_source/log.h | 90 - lib/libm/common_source/log10.c | 96 - lib/libm/common_source/log1p.c | 171 - lib/libm/common_source/log__D.c | 140 - lib/libm/common_source/log__L.c | 111 - lib/libm/common_source/logtab.c | 355 - lib/libm/common_source/math.3 | 633 - lib/libm/common_source/mathimpl.h | 99 - lib/libm/common_source/pow.c | 216 - lib/libm/common_source/rint.3 | 116 - lib/libm/common_source/sin.3 | 73 - lib/libm/common_source/sinh.3 | 75 - lib/libm/common_source/sinh.c | 122 - lib/libm/common_source/sqrt.3 | 121 - lib/libm/common_source/tan.3 | 74 - lib/libm/common_source/tanh.3 | 71 - lib/libm/common_source/tanh.c | 100 - lib/libm/i387/exp.S | 83 - lib/libm/i387/exp10.S | 83 - lib/libm/i387/exp10.s | 83 - lib/libm/i387/exp2.S | 80 - lib/libm/i387/exp2.s | 80 - lib/libm/i387/finite.S | 44 - lib/libm/i387/finite.s | 44 - lib/libm/i387/floor.S | 56 - lib/libm/i387/floor.s | 56 - lib/libm/i387/log.S | 42 - lib/libm/i387/log.s | 42 - lib/libm/i387/log10.S | 42 - lib/libm/i387/log10.s | 42 - lib/libm/i387/log1p.S | 42 - lib/libm/i387/log1p.s | 42 - lib/libm/i387/log2.S | 42 - lib/libm/i387/log2.s | 42 - lib/libm/i387/logb.S | 42 - lib/libm/i387/logb.s | 42 - lib/libm/i387/rint.S | 41 - lib/libm/i387/rint.s | 41 - lib/libm/i387/scalb.S | 43 - lib/libm/i387/scalb.s | 43 - lib/libm/i387/sin.S | 48 - lib/libm/i387/sin.s | 48 - lib/libm/i387/sqrt.S | 41 - lib/libm/i387/sqrt.s | 41 - lib/libm/i387/tan.S | 49 - lib/libm/i387/tan.s | 49 - lib/libm/mc68881/floor.S | 83 - lib/libm/mc68881/log.S | 55 - lib/libm/mc68881/log10.S | 55 - lib/libm/mc68881/log10.s | 55 - lib/libm/mc68881/log1p.S | 55 - lib/libm/mc68881/log1p.s | 55 - lib/libm/mc68881/mcount.sed | 8 - lib/libm/mc68881/sincos.S | 62 - lib/libm/mc68881/sincos.s | 62 - lib/libm/mc68881/sinh.S | 55 - lib/libm/mc68881/sinh.s | 55 - lib/libm/mc68881/sqrt.S | 59 - lib/libm/mc68881/sqrt.s | 59 - lib/libm/mc68881/support.S | 160 - lib/libm/mc68881/support.s | 160 - lib/libm/mc68881/tan.S | 55 - lib/libm/mc68881/tan.s | 55 - lib/libm/mc68881/tanh.S | 55 - lib/libm/mc68881/tanh.s | 55 - lib/libm/vax/sqrt.S | 123 - lib/libm/vax/support.S | 228 - lib/libm/vax/support.s | 228 - lib/libm/vax/tan.S | 97 - lib/libm/vax/tan.s | 97 - lib/librpc/rpc/bindresvport.c | 84 - lib/librpc/rpc/clnt_generic.c | 113 - lib/librpc/rpc/clnt_perror.c | 303 - lib/librpc/rpc/clnt_raw.c | 240 - lib/librpc/rpc/clnt_simple.c | 115 - lib/librpc/rpc/clnt_tcp.c | 468 - lib/librpc/rpc/clnt_udp.c | 444 - lib/librpc/rpc/get_myaddress.c | 99 - lib/librpc/rpc/getrpcent.c | 298 - lib/librpc/rpc/getrpcport.c | 57 - lib/librpc/rpc/pmap_clnt.c | 117 - lib/librpc/rpc/pmap_getmaps.c | 86 - lib/librpc/rpc/pmap_getport.c | 89 - lib/librpc/rpc/pmap_prot.c | 59 - lib/librpc/rpc/pmap_prot2.c | 118 - lib/librpc/rpc/pmap_rmt.c | 397 - lib/librpc/rpc/rpc.h | 80 - lib/librpc/rpc/rpc_callmsg.c | 192 - lib/librpc/rpc/rpc_commondata.c | 46 - lib/librpc/rpc/rpc_dtablesize.c | 48 - lib/librpc/rpc/rpc_msg.h | 187 - lib/librpc/rpc/rpc_prot.c | 291 - lib/librpc/rpc/svc.c | 481 - lib/librpc/rpc/svc.h | 280 - lib/librpc/rpc/svc_auth.c | 117 - lib/librpc/rpc/svc_auth.h | 42 - lib/librpc/rpc/svc_auth_unix.c | 136 - lib/librpc/rpc/svc_raw.c | 168 - lib/librpc/rpc/svc_run.c | 73 - lib/librpc/rpc/svc_simple.c | 145 - lib/librpc/rpc/svc_tcp.c | 421 - lib/librpc/rpc/svc_udp.c | 480 - lib/librpc/rpc/types.h | 63 - lib/librpc/rpc/xdr.c | 578 - lib/librpc/rpc/xdr.h | 270 - lib/librpc/rpc/xdr_array.c | 155 - lib/librpc/rpc/xdr_float.c | 283 - lib/librpc/rpc/xdr_mem.c | 186 - lib/librpc/rpc/xdr_rec.c | 586 - lib/librpc/rpc/xdr_reference.c | 134 - lib/librpc/rpc/xdr_stdio.c | 191 - lib/librpcsvc/src/rex.x | 234 - lib/librpcsvc/src/rnusers.x | 192 - lib/librpcsvc/src/rquota.x | 66 - lib/librpcsvc/src/rstat.x | 150 - lib/librpcsvc/src/rusers.x | 91 - lib/librpcsvc/src/rwall.x | 46 - lib/librpcsvc/src/sm_inter.x | 126 - lib/librpcsvc/src/spray.x | 103 - lib/librpcsvc/src/yp.x | 296 - lib/librpcsvc/src/yppasswd.x | 69 - lib/libtelnet/krb_des.c | 558 - lib/libutil/pwcache.c | 113 - libexec/bootpd/Installation | 29 - libexec/bootpd/Makefile | 14 - libexec/bootpd/NewMake | Bin 8468 -> 0 bytes libexec/bootpd/Problems | 47 - libexec/bootpd/README | 133 - libexec/bootpd/bootp.h | 144 - libexec/bootpd/bootpd.8 | 305 - libexec/bootpd/bootpd.c | 1334 -- libexec/bootpd/bootpd.h | 202 - libexec/bootpd/bootpef.8 | 52 - libexec/bootpd/bootpef.c | 347 - libexec/bootpd/bootpgw.c | 675 - libexec/bootpd/bootptab.5 | 395 - libexec/bootpd/bootptab.cmu | 124 - libexec/bootpd/bootptab.mcs | 93 - libexec/bootpd/bootptest.8 | 56 - libexec/bootpd/bootptest.c | 484 - libexec/bootpd/bootptest.h | 30 - libexec/bootpd/bptypes.h | 23 - libexec/bootpd/dovend.c | 413 - libexec/bootpd/dovend.h | 13 - libexec/bootpd/dumptab.c | 370 - libexec/bootpd/getether.c | 374 - libexec/bootpd/getif.c | 145 - libexec/bootpd/getif.h | 7 - libexec/bootpd/hash.c | 425 - libexec/bootpd/hash.h | 158 - libexec/bootpd/hwaddr.c | 283 - libexec/bootpd/hwaddr.h | 39 - libexec/bootpd/lookup.c | 126 - libexec/bootpd/lookup.h | 15 - libexec/bootpd/patchlevel.h | 3 - libexec/bootpd/print-bootp.c | 500 - libexec/bootpd/readfile.c | 2048 --- libexec/bootpd/readfile.h | 19 - libexec/bootpd/report.c | 154 - libexec/bootpd/report.h | 13 - libexec/bootpd/syslog.conf | 63 - libexec/bootpd/syslog.h | 25 - libexec/bootpd/trygetea.c | 46 - libexec/bootpd/trygetif.c | 68 - libexec/bootpd/trylook.c | 50 - libexec/bootpd/tzone.c | 44 - libexec/bootpd/tzone.h | 3 - libexec/bugfiler/gethead.c | 161 - libexec/bugfiler/pathnames.h | 39 - libexec/bugfiler/process.c | 109 - libexec/bugfiler/redist.c | 128 - libexec/bugfiler/reply.c | 109 - libexec/bugfiler/sendbug.1 | 86 - libexec/bugfiler/sendbug.sh | 70 - libexec/cron/THANKS | 29 - libexec/cron/crontab.1 | 100 - libexec/cron/crontab.5 | 187 - libexec/cron/crontab.c | 574 - libexec/cron/database.c | 261 - libexec/cron/do_command.c | 501 - libexec/cron/entry.c | 526 - libexec/cron/env.c | 174 - libexec/cron/externs.h | 145 - libexec/cron/job.c | 74 - libexec/cron/misc.c | 664 - libexec/cron/pathnames.h | 81 - libexec/cron/popen.c | 166 - libexec/cron/user.c | 102 - libexec/crond/Makefile.vixie | 112 - libexec/crond/README | 96 - libexec/crond/THANKS | 29 - libexec/crond/arpadate.c | 31 - libexec/crond/config.h | 158 - libexec/crond/cron.h | 237 - libexec/crond/crond.8 | 58 - libexec/crond/crond.c | 309 - libexec/crond/database.c | 271 - libexec/crond/do_command.c | 571 - libexec/crond/entry.c | 479 - libexec/crond/env.c | 155 - libexec/crond/job.c | 76 - libexec/crond/misc.c | 729 - libexec/crond/user.c | 122 - regress/lib/libc/db/hash.tests/tseq.c | 89 - regress/lib/libc/db/hash.tests/tverify.c | 108 - sbin/dump/rdump.8 | 78 - sbin/mount_miscfs/Makefile | 7 - sbin/mount_miscfs/mount_fdesc.8 | 145 - sbin/mount_miscfs/mount_kernfs.8 | 115 - sbin/mount_miscfs/mount_miscfs.c | 133 - share/doc/ps1/04.pascal/comments.p | 18 - share/doc/ps1/04.pascal/copydata.p | 15 - share/doc/ps1/04.pascal/csfix.c | 219 - share/doc/ps1/04.pascal/data | 3 - share/doc/ps1/04.pascal/digits.p | 9 - share/doc/ps1/04.pascal/expr.p | 21 - share/doc/ps1/04.pascal/first.p | 4 - share/doc/ps1/04.pascal/fixcomments | 6 - share/doc/ps1/04.pascal/fixkatscript | 6 - share/doc/ps1/04.pascal/kat.p | 13 - share/doc/ps1/04.pascal/kat2.p | 23 - share/doc/ps1/04.pascal/kat3.p | 23 - share/doc/ps1/04.pascal/katin | 2 - share/doc/ps1/04.pascal/mism.p | 5 - share/doc/ps1/04.pascal/primes.p | 30 - share/doc/ps1/04.pascal/primes2.p | 30 - share/doc/ps1/04.pascal/puman0.n | 154 - share/doc/ps1/04.pascal/puman1.n | 449 - share/doc/ps1/04.pascal/puman2.n | 858 -- share/doc/ps1/04.pascal/puman3.n | 753 -- share/doc/ps1/04.pascal/puman4.n | 609 - share/doc/ps1/04.pascal/puman5.n | 940 -- share/doc/ps1/04.pascal/pumanA.n | 965 -- share/doc/ps1/04.pascal/sin1.p | 13 - share/doc/ps1/04.pascal/sin2.p | 13 - share/doc/ps1/04.pascal/synerr.p | 9 - share/doc/ps1/04.pascal/synerr2.p | 7 - share/doc/ps1/04.pascal/tmac.p | 79 - share/doc/ps1/04.pascal/typequ.p | 10 - share/doc/ps1/06.sysman/2.1.t | 138 - share/doc/ps1/06.sysman/2.2.t | 470 - share/doc/ps1/06.sysman/2.3.t | 412 - share/doc/ps1/06.sysman/2.4.t | 174 - share/doc/ps1/06.sysman/2.5.t | 39 - share/doc/ps1/06.sysman/Makefile | 14 - share/doc/ps1/06.sysman/a.t | 242 - share/doc/ps1/06.sysman/spell.ok | 332 - share/doc/ps1/07.ipctut/pipe.grn | 405 - share/doc/ps1/07.ipctut/socketpair.c | 78 - share/doc/ps1/07.ipctut/socketpair.grn | 407 - share/doc/ps1/07.ipctut/strchkread.c | 107 - share/doc/ps1/07.ipctut/streamread.c | 103 - share/doc/ps1/07.ipctut/streamwrite.c | 82 - share/doc/ps1/07.ipctut/tutor.me | 950 -- share/doc/ps1/07.ipctut/udgramread.c | 81 - share/doc/ps1/07.ipctut/udgramsend.c | 69 - share/doc/ps1/07.ipctut/ustreamread.c | 97 - share/doc/ps1/07.ipctut/ustreamwrite.c | 72 - share/doc/ps1/13.rcs/man/rcsintro.1 | 24 - share/doc/ps1/13.rcs/man/rcsmerge.1 | 72 - share/doc/ps1/13.rcs/man/rlog.1 | 132 - share/doc/ps1/13.rcs/man/sccstorcs.1 | 52 - share/doc/ps1/18.curses/doc.III | 343 - share/doc/ps1/18.curses/doc.IV | 110 - share/doc/ps1/18.curses/intro.0 | 97 - share/doc/ps1/18.curses/intro.1 | 282 - share/doc/ps1/18.curses/intro.2 | 91 - share/doc/ps1/18.curses/intro.3 | 231 - share/doc/ps1/18.curses/intro.4 | 250 - share/doc/ps1/18.curses/intro.5 | 61 - share/doc/ps1/18.curses/life.c | 164 - share/doc/ps1/18.curses/macros | 110 - share/doc/ps1/18.curses/twinkle1.c | 158 - share/doc/ps1/18.curses/twinkle2.c | 97 - share/doc/ps1/18.curses/win_st.c | 59 - share/doc/smm/02.config/spell.ok | 306 - share/doc/smm/11.named/manage.me | 243 - share/doc/smm/11.named/named.boot.cache | 52 - share/doc/smm/11.named/named.boot.primary | 55 - share/doc/smm/11.named/named.boot.secondary | 54 - share/doc/smm/11.named/named.local | 48 - share/doc/smm/11.named/resolv.conf | 43 - share/doc/smm/11.named/root.cache | 67 - share/doc/smm/11.named/setup.me | 71 - share/doc/smm/11.named/spell.ok | 161 - share/doc/smm/11.named/types.me | 100 - share/doc/smm/11.named/ucbhosts | 90 - share/doc/smm/11.named/ucbhosts.rev | 62 - share/doc/smm/15.net/d.t | 73 - share/doc/smm/15.net/e.t | 129 - share/doc/smm/15.net/f.t | 117 - share/doc/smm/15.net/spell.ok | 307 - share/doc/usd/07.Mail/mail6.nr | 125 - share/doc/usd/07.Mail/mail7.nr | 107 - share/doc/usd/07.Mail/mail8.nr | 75 - share/doc/usd/07.Mail/mail9.nr | 203 - share/doc/usd/07.Mail/maila.nr | 33 - share/doc/usd/11.notes/4.7 | 81 - share/doc/usd/11.notes/5 | 153 - share/doc/usd/11.notes/Makefile | 87 - share/doc/usd/11.notes/a.checklist | 504 - share/doc/usd/11.notes/acks | 63 - share/doc/usd/11.notes/b.interface | 462 - share/doc/usd/11.notes/c.changes | 412 - share/doc/usd/11.notes/macros | 320 - share/doc/usd/11.notes/vtoc | 76 - sys/arch/amiga/README.CHOPPS-CONSOLE2 | 54 - sys/arch/amiga/README.scsi | 14 - sys/arch/amiga/README.st | 96 - sys/arch/amiga/amiga/cc_blitter.h | 64 - sys/arch/amiga/amiga/cc_chipmem.c | 289 - sys/arch/amiga/amiga/cc_chipmem.h | 89 - sys/arch/amiga/amiga/cc_copper.c | 132 - sys/arch/amiga/amiga/cc_copper.h | 85 - sys/arch/amiga/amiga/cc_types.h | 52 - sys/arch/amiga/amiga/cc_vbl.c | 291 - sys/arch/amiga/amiga/cc_vbl.h | 69 - sys/arch/amiga/amiga/pte.h | 131 - sys/arch/amiga/compile/AMIGA/ioconf.c | 43 - sys/arch/amiga/compile/AMIGA/ite.X | 129 - sys/arch/amiga/compile/AMIGA/ite.h | 1 - sys/arch/amiga/compile/AMIGA/loop.h | 1 - sys/arch/amiga/compile/AMIGA/param.c | 143 - sys/arch/amiga/compile/AMIGA/ppp.h | 1 - sys/arch/amiga/compile/AMIGA/pty.h | 1 - sys/arch/amiga/compile/AMIGA/scsi.h | 1 - sys/arch/amiga/compile/AMIGA/sd.h | 1 - sys/arch/amiga/compile/AMIGA/ser.h | 1 - sys/arch/amiga/compile/AMIGA/sl.h | 1 - sys/arch/amiga/compile/AMIGA/st.h | 1 - sys/arch/amiga/compile/AMIGA/swappager.h | 1 - sys/arch/amiga/compile/AMIGA/swapvmunix.c | 10 - sys/arch/amiga/compile/AMIGA/tb.h | 1 - sys/arch/amiga/compile/AMIGA/tun.h | 1 - sys/arch/amiga/compile/AMIGA/vers.c | 1 - sys/arch/amiga/compile/AMIGA/version | 1 - sys/arch/amiga/compile/AMIGA/vn.h | 1 - sys/arch/amiga/compile/AMIGA/vnodepager.h | 1 - sys/arch/amiga/dev/grf/grf_cc/grf_cc_h_mode.c | 241 - .../amiga/dev/grf/grf_cc/grf_cc_hdl_mode.c | 296 - .../amiga/dev/grf/grf_cc/grf_cc_hl_mode.c | 275 - sys/arch/amiga/dev/grf/grf_cc/grf_cc_mode.c | 350 - .../dev/grf/grf_cc/grf_cc_pal_a2024_mode.c | 320 - .../amiga/dev/grf/grf_cc/grf_cc_ph_mode.c | 236 - .../amiga/dev/grf/grf_cc/grf_cc_phdl_mode.c | 291 - .../amiga/dev/grf/grf_cc/grf_cc_phl_mode.c | 272 - sys/arch/amiga/dev/grf/grf_cc/grf_cc_priv.h | 187 - sys/arch/amiga/dev/grf/grf_cc/grf_cc_view.c | 87 - sys/arch/amiga/dev/grf/grf_cc/grf_ccc.c | 270 - sys/arch/amiga/dev/grf/grf_monitor.c | 64 - sys/arch/amiga/dev/grf/grf_monitor.h | 81 - sys/arch/amiga/dev/grf/grf_types.h | 72 - sys/arch/amiga/dev/grf/grf_view.c | 87 - sys/arch/amiga/dev/grf/grf_view.h | 80 - sys/arch/amiga/dev/grf/grfcc.c | 132 - sys/arch/amiga/dev/grf_tg.c | 21 - sys/arch/amiga/dev/gvp11dma.c | 293 - sys/arch/amiga/dev/gvp11dmareg.h | 69 - sys/arch/amiga/dev/ite_tg.c | 35 - sys/arch/amiga/dev/ivsdma.c | 49 - sys/arch/amiga/dev/magnumdma.c | 50 - sys/arch/amiga/dev/mlhdma.c | 417 - sys/arch/amiga/dev/retina-mondefs.c | 200 - sys/arch/amiga/dev/retina-monitors | 71 - sys/arch/amiga/dev/rtclocka.c | 207 - sys/arch/amiga/dev/rtclocka_var.h | 58 - sys/arch/amiga/dev/rtclockb.c | 219 - sys/arch/amiga/dev/rtclockb_var.h | 51 - sys/arch/amiga/dev/scsi.c | 1954 --- sys/arch/amiga/dev/scsireg.h | 423 - sys/arch/amiga/dev/scsivar.h | 107 - sys/arch/amiga/dev/supradma.c | 497 - sys/arch/amiga/dev/zeusdma.c | 49 - sys/arch/amiga/fpsp/README | 1232 -- sys/arch/amiga/fpsp/README.source | 5 - sys/arch/amiga/fpsp/README_FIRST | 40 - sys/arch/amiga/fpsp/fpsp.o.uu | 4494 ------ sys/arch/amiga/fpsp/fpspnull.s | 19 - sys/arch/amiga/sunos/sun_exec_aout.c | 233 - sys/arch/amiga/sunos/sun_ioctl.c | 517 - sys/arch/amiga/sunos/sun_misc.c | 566 - sys/arch/amiga/sunos/sun_syscall.h | 154 - sys/arch/amiga/sunos/sun_syscalls.c | 203 - sys/arch/amiga/sunos/sun_sysent.c | 367 - sys/arch/amiga/sunos/syscalls.master | 216 - sys/arch/hp300/hpux/hpux_sig.c | 447 - sys/arch/hp300/hpux/hpux_syscall.h | 146 - sys/arch/hp300/hpux/hpux_syscalls.c | 356 - sys/arch/hp300/hpux/hpux_sysent.c | 547 - sys/arch/hp300/hpux/hpux_termio.h | 191 - sys/arch/hp300/hpux/hpux_tty.c | 539 - sys/arch/hp300/hpux/makesyscalls.sh | 181 - sys/arch/hp300/hpux/syscalls.master | 373 - sys/arch/i386/conf/GENERICAHB | 90 - sys/arch/i386/conf/GENERICISA | 81 - sys/arch/i386/conf/SMALL | 40 - sys/arch/i386/conf/SUMNER | 42 - sys/arch/i386/isa/comreg.h | 118 - sys/arch/i386/isa/cy.c | 1646 --- sys/arch/i386/isa/elink.c | 78 - sys/arch/i386/isa/elink.h | 39 - sys/arch/i386/isa/ic/ns16550.h | 53 - sys/arch/i386/isa/if_ed.c | 2321 ---- sys/arch/i386/isa/if_edreg.h | 932 -- sys/arch/i386/isa/if_eg.c | 847 -- sys/arch/i386/isa/if_egreg.h | 105 - sys/arch/i386/isa/if_el.c | 772 -- sys/arch/i386/isa/if_elreg.h | 82 - sys/arch/i386/isa/if_ep.c | 1167 -- sys/arch/i386/isa/if_epreg.h | 337 - sys/arch/i386/isa/if_hp.c | 1000 -- sys/arch/i386/isa/if_ie.c | 1958 --- sys/arch/i386/isa/if_ie507.h | 22 - sys/arch/i386/isa/if_ieatt.h | 25 - sys/arch/i386/isa/if_le.c | 1241 -- sys/arch/i386/isa/if_lereg.h | 136 - sys/arch/i386/isa/lpt.c | 533 - sys/arch/i386/isa/lptreg.h | 64 - sys/arch/i386/isa/mcd.c | 1338 -- sys/arch/i386/isa/mcdreg.h | 137 - sys/arch/i386/isa/rtfps.c | 173 - sys/arch/i386/isa/seagate.c | 1434 -- sys/arch/i386/isa/ultra14f.c | 1353 -- sys/arch/i386/isa/wd.c | 1734 --- sys/arch/i386/isa/wd7000.c | 743 - sys/arch/i386/isa/wdreg.h | 161 - sys/arch/i386/isa/wt.c | 1038 -- sys/arch/i386/isa/wtreg.h | 125 - sys/arch/i386/stand/wdboot.x | Bin 512 -> 0 bytes sys/arch/mac68k/conf/AAAA | 53 - sys/arch/mac68k/conf/ALBASIC | 53 - sys/arch/mac68k/conf/BASIC | 53 - sys/arch/mac68k/conf/GENERIC.mac | 73 - sys/arch/mac68k/conf/LINT.mac | 67 - sys/arch/mac68k/conf/devices.mac | 1 - sys/arch/mac68k/conf/files.mac | 33 - sys/arch/mac68k/dev/scc_8530.h | 381 - sys/arch/mac68k/dev/scc_8530_hdw.c | 1038 -- sys/arch/mac68k/include/nubus.h | 45 - sys/arch/mac68k/mac68k/symbols.raw | 89 - sys/arch/mac68k/scsi/README | 215 - sys/arch/mac68k/scsi/README.AHA1742 | 24 - sys/arch/mac68k/scsi/scsi_debug.h | 53 - sys/arch/mac68k/scsi/scsi_disk.h | 216 - sys/arch/mac68k/scsi/scsi_generic.h | 61 - sys/arch/mac68k/scsi/scsi_ioctl.c | 335 - sys/arch/mac68k/scsi/scsi_tape.h | 204 - sys/arch/mac68k/scsi/scsiconf.c | 581 - sys/arch/mac68k/scsi/scsiconf.h | 251 - sys/arch/mac68k/scsi/sd.c | 994 -- sys/arch/mac68k/scsi/sg.c | 758 -- sys/arch/mac68k/scsi/st.c | 1810 --- sys/arch/mac68k/scsi/su.c | 6 - sys/arch/mac68k/scsi/uk.c | 159 - sys/arch/pc532/scsi/scsi_debug.h | 53 - sys/arch/pc532/scsi/scsi_disk.h | 240 - sys/arch/pc532/scsi/scsi_tape.h | 149 - sys/arch/pc532/scsi/scsiconf.c | 600 - sys/arch/pc532/scsi/scsiconf.h | 132 - sys/arch/pc532/scsi/sd.c | 1348 -- sys/arch/pc532/scsi/sddefs.h | 57 - sys/arch/pc532/scsi/st.c | 1422 -- sys/arch/pc532/scsi/stdefs.h | 54 - sys/arch/pmax/conf/AMSTEL | 56 - sys/arch/pmax/conf/ECSTASY | 55 - sys/arch/pmax/conf/GENERIC.3100 | 57 - sys/arch/pmax/conf/GENERIC.5000 | 69 - sys/arch/pmax/conf/MAXINE | 62 - sys/arch/pmax/conf/MAXP | 65 - sys/arch/pmax/dist/get1 | 146 - sys/arch/pmax/pmax/Locore.c | 335 - sys/arch/pmax/pmax/locore.s.sav | 3085 ----- sys/arch/pmax/pmax/trap.c.sav | 1821 --- sys/arch/pmax/pmax/trap.c.sav2 | 1846 --- sys/arch/pmax/test/Makefile | 32 - sys/arch/pmax/test/coff.c | 95 - sys/arch/pmax/test/fp.c | 27 - sys/arch/pmax/test/fp1.c | 30 - sys/arch/pmax/test/fp2.c | 56 - sys/arch/pmax/test/fp2_out | 27 - sys/arch/pmax/test/fp2_t | 27 - sys/arch/pmax/test/fp3.c | 52 - sys/arch/pmax/test/fp3_out | 10 - sys/arch/pmax/test/fp3_t | 10 - sys/arch/pmax/test/fp4.c | 52 - sys/arch/pmax/test/fp4_out | 12 - sys/arch/pmax/test/fp4_t | 12 - sys/arch/pmax/test/fp5.c | 52 - sys/arch/pmax/test/fp6.c | 52 - sys/arch/pmax/test/fp6_out | 23 - sys/arch/pmax/test/fp6_t | 26 - sys/arch/pmax/test/fp7.c | 50 - sys/arch/pmax/test/fp7_t | 12 - sys/arch/pmax/test/fp8.c | 52 - sys/arch/pmax/test/fp8_t | 15 - sys/arch/pmax/test/fp_t | 844 -- sys/arch/pmax/test/fptest.c | 202 - sys/arch/pmax/test/fptest1.s | 324 - sys/arch/pmax/test/sum.c | 56 - sys/arch/pmax/test/t01.c | 9 - sys/arch/pmax/test/t02.c | 13 - sys/arch/pmax/test/t03.c | 12 - sys/arch/pmax/test/t04.c | 23 - sys/arch/pmax/test/t05.c | 19 - sys/arch/pmax/test/t05.s | 720 - sys/arch/pmax/test/t06.c | 30 - sys/arch/pmax/test/t07.c | 48 - sys/arch/pmax/test/tdisk.sh | 6 - sys/arch/pmax/ultrix/ultrix_sysent.c | 429 - sys/arch/sparc/conf/std.sparc | 10 - sys/arch/sparc/conf/std.sun4 | 20 - sys/arch/sparc/conf/std.sun4c | 35 - sys/arch/sparc/sbus/cgsixreg.h | 206 - sys/arch/sparc/sbus/cgthree.c | 363 - sys/arch/sparc/sbus/cgthreereg.h | 65 - sys/arch/sparc/sbus/dmareg.h | 135 - sys/arch/sparc/sbus/esp.c | 1327 -- sys/arch/sparc/sbus/espreg.h | 300 - sys/arch/sparc/sbus/if_le.c | 976 -- sys/arch/sparc/sbus/if_lereg.h | 167 - sys/arch/sparc/sbus/sbus.c | 179 - sys/arch/sparc/sbus/sbusreg.h | 62 - sys/arch/sparc/sbus/sbusvar.h | 74 - sys/arch/sparc/scsi/scsi_subr.c | 507 - sys/arch/sparc/scsi/scsivar.h | 191 - sys/arch/sparc/scsi/sd.c | 884 -- sys/arch/sparc/scsi/sdtrace.h | 67 - sys/arch/sparc/scsi/sun_disklabel.c | 143 - sys/arch/sparc/scsi/sun_disklabel.h | 114 - sys/arch/sparc/scsi/tape.h | 125 - sys/arch/sparc/sunos/sun_syscall.h | 158 - sys/arch/sparc/sunos/sun_syscalls.c | 211 - sys/arch/sparc/sunos/sun_sysent.c | 391 - sys/arch/sparc/sunos/syscalls.master | 224 - sys/boot/bootparam.c | 35 - sys/boot/exec.c | 206 - sys/boot/exec_var.h | 50 - sys/boot/in_cksum.c | 81 - sys/boot/net.c | 290 - sys/boot/netboot.h | 111 - sys/boot/netif.c | 127 - sys/boot/netif.h | 32 - sys/boot/nfsboot.c | 201 - sys/boot/rpc.c | 617 - sys/boot/util.c | 116 - sys/compat/sunos/sun_syscall.h | 165 - sys/compat/sunos/sun_syscalls.c | 220 - sys/compat/sunos/sun_sysent.c | 419 - sys/isofs/isofs_node.h | 106 - sys/isofs/isofs_rrip.c | 680 - sys/isofs/isofs_rrip.h | 140 - sys/isofs/isofs_util.c | 203 - sys/isofs/isofs_vfsops.c | 590 - sys/isofs/isofs_vnops.c | 842 -- sys/lib/libkern/arch/i386/bcmp.s | 71 - sys/lib/libkern/arch/i386/bzero.s | 87 - sys/lib/libkern/arch/i386/ffs.s | 59 - sys/lib/libkern/arch/i386/htonl.s | 54 - sys/lib/libkern/arch/i386/htons.s | 52 - sys/lib/libkern/arch/i386/ntohl.s | 54 - sys/lib/libkern/arch/i386/ntohs.s | 52 - sys/lib/libkern/arch/i386/setjmp.s | 26 - sys/lib/libkern/arch/i386/strcat.s | 106 - sys/lib/libkern/arch/i386/strcmp.s | 125 - sys/lib/libkern/arch/i386/strcpy.s | 95 - sys/lib/libkern/arch/i386/strlen.s | 59 - sys/lib/libkern/arch/m68k/locc.s | 60 - sys/lib/libkern/arch/m68k/scanc.s | 66 - sys/lib/libkern/arch/m68k/skpc.s | 60 - sys/lib/libkern/i386/locc.S | 47 - sys/lib/libkern/i386/ntohl.S | 54 - sys/lib/libkern/i386/ntohs.S | 52 - sys/lib/libkern/i386/scanc.S | 56 - sys/lib/libkern/i386/setjmp.S | 91 - sys/lib/libkern/i386/skpc.S | 47 - sys/lib/libkern/i386/strcat.S | 106 - sys/lib/libkern/i386/strcat.s | 106 - sys/lib/libkern/i386/strcmp.S | 125 - sys/lib/libkern/i386/strcmp.s | 125 - sys/lib/libkern/i386/strcpy.S | 95 - sys/lib/libkern/i386/strcpy.s | 95 - sys/lib/libkern/i386/strlen.S | 59 - sys/lib/libkern/i386/strlen.s | 59 - sys/lib/libkern/m68k/locc.S | 60 - sys/lib/libkern/m68k/ntohl.S | 50 - sys/lib/libkern/m68k/ntohs.S | 51 - sys/lib/libkern/m68k/scanc.S | 66 - sys/lib/libkern/m68k/skpc.S | 60 - sys/lib/libkern/m68k/strcmp.S | 66 - sys/lib/libkern/m68k/strcpy.S | 53 - sys/lib/libkern/m68k/strlen.S | 53 - sys/lib/libkern/m68k/strncmp.S | 71 - sys/lib/libkern/m68k/strncpy.S | 63 - sys/lib/libkern/ns32k/setjmp.S | 70 - sys/libkern/scanc.c | 50 - sys/libkern/skpc.c | 50 - sys/libkern/ulmax.c | 42 - sys/libkern/ulmin.c | 42 - sys/pcfs/pcfs_denode.c | 619 - sys/pcfs/pcfs_fat.c | 727 - sys/pcfs/pcfs_lookup.c | 731 - sys/pcfs/pcfs_vfsops.c | 620 - sys/pcfs/pcfs_vnops.c | 1607 --- sys/pcfs/pcfsmount.h | 142 - sys/ufs/mfsnode.h | 204 - sys/ufs/quota.h | 200 - sys/ufs/ufs_alloc.c | 1101 -- sys/ufs/ufs_lookup.c | 927 -- sys/ufs/ufs_quota.c | 935 -- sys/ufs/ufs_subr.c | 162 - sys/ufs/ufs_tables.c | 137 - sys/ufs/ufs_vfsops.c | 698 - sys/ufs/ufs_vtab.c | 47 - sys/ufs/ufsmount.h | 83 - usr.bin/elvis/ctype.h | 42 - usr.bin/elvis/curses.c | 1051 -- usr.bin/elvis/curses.h | 321 - usr.bin/elvis/cut.c | 705 - usr.bin/elvis/doc/elvis.man | 149 - usr.bin/elvis/doc/elvprsv.man | 54 - usr.bin/elvis/doc/elvrec.man | 47 - usr.bin/elvis/doc/environ.ms | 60 - usr.bin/elvis/doc/ex.ms | 524 - usr.bin/elvis/doc/fmt.man | 26 - usr.bin/elvis/doc/index.ms | 78 - usr.bin/elvis/doc/internal.ms | 232 - usr.bin/elvis/doc/intro.ms | 53 - usr.bin/elvis/doc/makefile.ms | 255 - usr.bin/elvis/doc/options.ms | 561 - usr.bin/elvis/doc/question.ms | 172 - usr.bin/elvis/doc/ref.man | 88 - usr.bin/elvis/doc/regexp.ms | 181 - usr.bin/elvis/doc/termcap.ms | 146 - usr.bin/elvis/doc/title.ms | 35 - usr.bin/elvis/doc/ver.ms | 14 - usr.bin/elvis/doc/versions.ms | 405 - usr.bin/elvis/doc/visual.ms | 297 - usr.bin/elvis/elvis.1 | 150 - usr.bin/elvis/ex.c | 775 -- usr.bin/elvis/input.c | 876 -- usr.bin/elvis/main.c | 515 - usr.bin/elvis/misc.c | 108 - usr.bin/elvis/modify.c | 479 - usr.bin/elvis/move1.c | 623 - usr.bin/elvis/move2.c | 361 - usr.bin/elvis/move3.c | 150 - usr.bin/elvis/move4.c | 225 - usr.bin/elvis/move5.c | 261 - usr.bin/elvis/opts.c | 818 -- usr.bin/elvis/prsvunix.c | 110 - usr.bin/elvis/recycle.c | 215 - usr.bin/elvis/redraw.c | 1311 -- usr.bin/elvis/regexp.c | 1036 -- usr.bin/elvis/regexp.h | 23 - usr.bin/elvis/regsub.c | 283 - usr.bin/elvis/system.c | 425 - usr.bin/elvis/tio.c | 1075 -- usr.bin/elvis/tmp.c | 795 -- usr.bin/elvis/unix.c | 227 - usr.bin/elvis/vars.c | 121 - usr.bin/elvis/vcmd.c | 991 -- usr.bin/elvis/vi.c | 847 -- usr.bin/elvis/vi.h | 653 - usr.bin/file/magdir/vax.byteswap | 17 - usr.bin/lex/lex.1 | 833 -- usr.bin/lex/lex.skel | 836 -- usr.bin/lex/lib/ln.order | 1 - usr.bin/lex/lib/shlib_version | 2 - usr.bin/rcs/man/Makefile | 32 - usr.bin/rcs/man/ci.1 | 231 - usr.bin/rcs/man/co.1 | 305 - usr.bin/rcs/man/ident.1 | 68 - usr.bin/rcs/man/merge.1 | 45 - usr.bin/rcs/man/rcs.1 | 170 - usr.bin/rcs/man/rcsclean.1 | 64 - usr.bin/rcs/man/rcsdiff.1 | 72 - usr.bin/rcs/man/rcsfile.5 | 156 - usr.bin/rcs/man/rcsfreeze.1 | 50 - usr.bin/rcs/man/rcsintro.1 | 241 - usr.bin/rcs/man/rcsmerge.1 | 75 - usr.bin/rcs/man/rlog.1 | 133 - usr.bin/rcs/man/sccstorcs.1 | 51 - usr.bin/rcs/src/maketime.c | 212 - usr.bin/rcs/src/merge.sh | 53 - usr.bin/rcs/src/partime.c | 505 - usr.bin/rcs/src/rcs.c | 1562 --- usr.bin/rcs/src/rcsbase.h | 393 - usr.bin/rcs/src/rcsclean.c | 211 - usr.bin/rcs/src/rcsclean.sh | 40 - usr.bin/rcs/src/rcsdiff.c | 298 - usr.bin/rcs/src/rcsedit.c | 524 - usr.bin/rcs/src/rcsfcmp.c | 229 - usr.bin/rcs/src/rcsfnms.c | 790 -- usr.bin/rcs/src/rcsfreeze.sh | 94 - usr.bin/rcs/src/rcsgen.c | 335 - usr.bin/rcs/src/rcskeep.c | 312 - usr.bin/rcs/src/rcskeys.c | 100 - usr.bin/rcs/src/rcslex.c | 810 -- usr.bin/rcs/src/rcsmerge.c | 216 - usr.bin/rcs/src/rcsrev.c | 719 - usr.bin/rcs/src/rcssyn.c | 572 - usr.bin/rcs/src/rcsutil.c | 516 - usr.bin/rcs/src/rlog.c | 1212 -- usr.bin/rcs/src/sccstorcs.c | 450 - usr.bin/rcs/src/snoop.c | 132 - usr.bin/rcs/src/time.h | 55 - usr.bin/sed/Makefile.bsd | 10 - usr.bin/sed/getopt.h | 102 - usr.bin/sed/getopt1.c | 158 - usr.bin/sed/regex.c | 2781 ---- usr.bin/sed/regex.h | 253 - usr.bin/sed/sed.c | 1554 --- usr.bin/sed/utils.c | 359 - usr.bin/vi/docs/structures | 61 - usr.bin/vi/docs/vi.ref.ps | 1108 -- usr.bin/vi/docs/vi.ref.txt | 634 - usr.bin/vi/line.c | 476 - usr.bin/vi/log.c | 689 - usr.bin/vi/log.h | 53 - usr.bin/vi/main.c | 795 -- usr.bin/vi/mark.c | 272 - usr.bin/vi/mark.h | 73 - usr.bin/vi/mem.h | 173 - usr.bin/vi/msg.h | 70 - usr.bin/vi/options.c | 857 -- usr.bin/vi/options.h.stub | 110 - usr.bin/vi/options_f.c | 555 - usr.bin/vi/pathnames.h | 45 - usr.bin/vi/put.c | 249 - usr.bin/vi/recover.c | 623 - usr.bin/vi/screen.c | 304 - usr.bin/vi/screen.h | 327 - usr.bin/vi/search.c | 839 -- usr.bin/vi/search.h | 54 - usr.bin/vi/seq.c | 340 - usr.bin/vi/seq.h | 78 - usr.bin/vi/term.c | 758 -- usr.bin/vi/term.h | 201 - usr.bin/vi/timer.c | 237 - usr.bin/vi/trace.c | 84 - usr.bin/vi/util.c | 625 - usr.bin/vi/vi.h | 127 - usr.bin/vi/vi/v_tag.c | 87 - usr.sbin/amd/doc/amdref.vrs | 0 usr.sbin/cron/CHANGES | 155 - usr.sbin/cron/CONVERSION | 85 - usr.sbin/cron/FEATURES | 84 - usr.sbin/cron/INSTALL | 87 - usr.sbin/cron/MAIL | 475 - usr.sbin/cron/MANIFEST | 33 - usr.sbin/cron/README | 72 - usr.sbin/cron/THANKS | 29 - usr.sbin/cron/bitstring.3 | 168 - usr.sbin/cron/bitstring.h | 122 - usr.sbin/cron/putman.sh | 23 - usr.sbin/sendmail/cf/cf/cchem.cf | 547 - usr.sbin/sendmail/cf/cf/cchem.mc | 15 - usr.sbin/sendmail/cf/cf/cogsci.cf | 610 - usr.sbin/sendmail/cf/cf/hpux-cs-exposed.mc | 41 - usr.sbin/sendmail/cf/cf/hpux-cs-hidden.mc | 41 - usr.sbin/sendmail/cf/cf/ic.cf | 603 - usr.sbin/sendmail/cf/cf/ic.mc | 18 - usr.sbin/sendmail/cf/cf/id.cf | 615 - usr.sbin/sendmail/cf/cf/id.mc | 17 - usr.sbin/sendmail/cf/cf/kappa.cf | 649 - usr.sbin/sendmail/cf/cf/knecht.mc | 44 - usr.sbin/sendmail/cf/cf/lamprey.cf | 311 - usr.sbin/sendmail/cf/cf/mail.cs.mc | 55 - usr.sbin/sendmail/cf/cf/mail.eecs.mc | 54 - usr.sbin/sendmail/cf/cf/okeeffe.cf | 606 - usr.sbin/sendmail/cf/cf/okeeffe.mc | 17 - usr.sbin/sendmail/cf/cf/osf1-cs-exposed.mc | 41 - usr.sbin/sendmail/cf/cf/osf1-cs-hidden.mc | 41 - usr.sbin/sendmail/cf/cf/proto.mc | 113 - usr.sbin/sendmail/cf/cf/riscos-cs-exposed.mc | 41 - usr.sbin/sendmail/cf/cf/s2k.mc | 42 - .../sendmail/cf/cf/sunos3.5-cs-exposed.mc | 41 - usr.sbin/sendmail/cf/cf/sunos3.5-cs-hidden.mc | 41 - .../sendmail/cf/cf/sunos4.1-cs-exposed.mc | 41 - usr.sbin/sendmail/cf/cf/sunos4.1-cs-hidden.mc | 41 - usr.sbin/sendmail/cf/cf/tcpproto.cf | 517 - usr.sbin/sendmail/cf/cf/tcpuucpproto.cf | 572 - usr.sbin/sendmail/cf/cf/tcpuucpproto.mc | 15 - usr.sbin/sendmail/cf/cf/telemuse.cf | 649 - usr.sbin/sendmail/cf/cf/ucbarpa.cf | 607 - usr.sbin/sendmail/cf/cf/ucbtcp.cf | 547 - usr.sbin/sendmail/cf/cf/ucbtcp.mc | 15 - usr.sbin/sendmail/cf/cf/ucbvax.cf | 837 -- usr.sbin/sendmail/cf/cf/udb.mc | 41 - usr.sbin/sendmail/cf/cf/uid.cf | 480 - usr.sbin/sendmail/cf/cf/uid.mc | 14 - .../sendmail/cf/cf/ultrix4.1-cs-exposed.mc | 41 - .../sendmail/cf/cf/ultrix4.1-cs-hidden.mc | 41 - usr.sbin/sendmail/cf/cf/uucpproto.cf | 484 - usr.sbin/sendmail/cf/m4/nsmacros.m4 | 45 - usr.sbin/sendmail/cf/m4/nstcpldm.m4 | 94 - usr.sbin/sendmail/cf/m4/nstcpm.m4 | 89 - usr.sbin/sendmail/cf/m4/postwriterule.m4 | 33 - usr.sbin/sendmail/cf/m4/prewriterule.m4 | 25 - usr.sbin/sendmail/cf/m4/rule0.m4 | 49 - usr.sbin/sendmail/cf/m4/rule3.m4 | 68 - usr.sbin/sendmail/cf/m4/rule5.m4 | 28 - usr.sbin/sendmail/cf/m4/smtpuucpm.m4 | 34 - usr.sbin/sendmail/cf/m4/suucpm.m4 | 43 - usr.sbin/sendmail/cf/m4/uucpm.m4 | 42 - usr.sbin/sendmail/cf/ostype/hpux.m4 | 44 - usr.sbin/sendmail/cf/ostype/irix.m4 | 41 - usr.sbin/sendmail/cf/ostype/linux.m4 | 38 - usr.sbin/sendmail/cf/ostype/nextstep.m4 | 44 - usr.sbin/sendmail/cf/ostype/osf1.m4 | 41 - usr.sbin/sendmail/cf/ostype/riscos4.5.m4 | 42 - usr.sbin/sendmail/cf/ostype/solaris2.m4 | 43 - usr.sbin/sendmail/cf/ostype/sunos3.5.m4 | 37 - usr.sbin/sendmail/cf/ostype/sunos4.1.m4 | 37 - usr.sbin/sendmail/cf/ostype/svr4.m4 | 45 - usr.sbin/sendmail/cf/ostype/ultrix4.1.m4 | 38 - usr.sbin/sendmail/cf/sitedep/uucp.cad.m4 | 36 - usr.sbin/sendmail/cf/sitedep/uucp.cogsci.m4 | 14 - usr.sbin/sendmail/cf/sitedep/uucp.ic.m4 | 8 - usr.sbin/sendmail/cf/sitedep/uucp.id.m4 | 6 - usr.sbin/sendmail/cf/sitedep/uucp.okeeffe.m4 | 12 - usr.sbin/sendmail/cf/sitedep/uucp.proto.m4 | 8 - usr.sbin/sendmail/cf/sitedep/uucp.ucbarpa.m4 | 12 - usr.sbin/sendmail/cf/sitedep/uucp.ucbvax.m4 | 86 - usr.sbin/sendmail/doc/usenix.me | 1076 -- usr.sbin/sendmail/src/Makefile.BSDI | 97 - usr.sbin/sendmail/src/Makefile.ConvexOS | 98 - usr.sbin/sendmail/src/Makefile.Dell | 106 - usr.sbin/sendmail/src/Makefile.HP-UX | 98 - usr.sbin/sendmail/src/Makefile.IRIX | 98 - usr.sbin/sendmail/src/Makefile.Linux | 112 - usr.sbin/sendmail/src/Makefile.NeXT | 107 - usr.sbin/sendmail/src/Makefile.OSF1 | 102 - usr.sbin/sendmail/src/Makefile.Solaris | 102 - usr.sbin/sendmail/src/Makefile.SunOS | 104 - usr.sbin/sendmail/src/Makefile.ULTRIX | 100 - usr.sbin/sendmail/src/Makefile.UMAX | 107 - usr.sbin/sendmail/src/Makefile.Utah | 39 - usr.sbin/sendmail/src/Makefile.dist | 102 - usr.sbin/sup/source/local_server.tar.UU | 2552 ---- usr.sbin/sup/source/sup.doc | 764 -- 2170 files changed, 746428 deletions(-) delete mode 100644 bin/ed/test/e3.ed delete mode 100644 bin/ed/test/e3.o delete mode 100644 bin/ed/test/g1.ed delete mode 100644 bin/ed/test/g1.o delete mode 100644 bin/ed/test/g2.ed delete mode 100644 bin/ed/test/g2.o delete mode 100644 bin/ed/test/i.ed delete mode 100644 bin/ed/test/i.o delete mode 100644 bin/ed/test/j.ed delete mode 100644 bin/ed/test/j.o delete mode 100644 bin/ed/test/l.ed delete mode 100644 bin/ed/test/l.o delete mode 100644 bin/ed/test/m.ed delete mode 100644 bin/ed/test/m.o delete mode 100644 bin/ed/test/n.ed delete mode 100644 bin/ed/test/n.o delete mode 100644 bin/ed/test/nl.r delete mode 100644 bin/ed/test/nl.t delete mode 100644 bin/ed/test/p.ed delete mode 100644 bin/ed/test/p.o delete mode 100644 bin/ed/test/r1.ed delete mode 100644 bin/ed/test/r1.o delete mode 100644 bin/ed/test/r2.ed delete mode 100644 bin/ed/test/r2.o delete mode 100644 bin/ed/test/r3.ed delete mode 100644 bin/ed/test/r3.o delete mode 100644 bin/ed/test/s1.ed delete mode 100644 bin/ed/test/s1.o delete mode 100644 bin/ed/test/s2.ed delete mode 100644 bin/ed/test/s2.o delete mode 100644 bin/ed/test/t.ed delete mode 100644 bin/ed/test/t.o delete mode 100644 bin/ed/test/t.t delete mode 100644 bin/ed/test/u.ed delete mode 100644 bin/ed/test/u.o delete mode 100644 bin/ed/test/v.ed delete mode 100644 bin/ed/test/v.o delete mode 100644 bin/ed/test/w.ed delete mode 100644 bin/ed/test/w.o delete mode 100644 bin/expr/TODO delete mode 100644 gnu/games/chess/Xchess/bishop_mask.bitmap delete mode 100644 gnu/games/chess/Xchess/bishop_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/bishop_small.bitmap delete mode 100644 gnu/games/chess/Xchess/bishop_small_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/board.c delete mode 100644 gnu/games/chess/Xchess/button.c delete mode 100644 gnu/games/chess/Xchess/clock.c delete mode 100644 gnu/games/chess/Xchess/control.c delete mode 100644 gnu/games/chess/Xchess/jail.c delete mode 100644 gnu/games/chess/Xchess/king.bitmap delete mode 100644 gnu/games/chess/Xchess/king_mask.bitmap delete mode 100644 gnu/games/chess/Xchess/king_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/king_small.bitmap delete mode 100644 gnu/games/chess/Xchess/king_small_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/knight.bitmap delete mode 100644 gnu/games/chess/Xchess/knight_mask.bitmap delete mode 100644 gnu/games/chess/Xchess/knight_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/knight_small.bitmap delete mode 100644 gnu/games/chess/Xchess/knight_small_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/message.c delete mode 100644 gnu/games/chess/Xchess/parse.c delete mode 100644 gnu/games/chess/Xchess/pawn.bitmap delete mode 100644 gnu/games/chess/Xchess/pawn_mask.bitmap delete mode 100644 gnu/games/chess/Xchess/pawn_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/pawn_small.bitmap delete mode 100644 gnu/games/chess/Xchess/pawn_small_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/popup.c delete mode 100644 gnu/games/chess/Xchess/program.c delete mode 100644 gnu/games/chess/Xchess/queen.bitmap delete mode 100644 gnu/games/chess/Xchess/queen_mask.bitmap delete mode 100644 gnu/games/chess/Xchess/queen_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/queen_small.bitmap delete mode 100644 gnu/games/chess/Xchess/queen_small_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/record.c delete mode 100644 gnu/games/chess/Xchess/rook.bitmap delete mode 100644 gnu/games/chess/Xchess/rook_mask.bitmap delete mode 100644 gnu/games/chess/Xchess/rook_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/rook_small.bitmap delete mode 100644 gnu/games/chess/Xchess/rook_small_outline.bitmap delete mode 100644 gnu/games/chess/Xchess/scrollText.c delete mode 100644 gnu/games/chess/Xchess/scrollText.h delete mode 100644 gnu/games/chess/Xchess/shade.bitmap delete mode 100644 gnu/games/chess/Xchess/std.c delete mode 100644 gnu/games/chess/Xchess/std.h delete mode 100644 gnu/games/chess/Xchess/valid.c delete mode 100644 gnu/games/chess/Xchess/window.c delete mode 100644 gnu/games/chess/Xchess/window.c.bm delete mode 100644 gnu/games/chess/Xchess/xchess.1 delete mode 100644 gnu/games/chess/Xchess/xchess.c delete mode 100644 gnu/games/chess/Xchess/xchess.c.150 delete mode 100644 gnu/games/chess/Xchess/xchess.cur delete mode 100644 gnu/games/chess/Xchess/xchess.game delete mode 100644 gnu/games/chess/Xchess/xchess.h delete mode 100644 gnu/games/chess/Xchess/xchess.icon delete mode 100644 gnu/games/chess/Xchess/xchess_mask.cur delete mode 100644 gnu/lib/libg++/g++-include/CursesW.h delete mode 100644 gnu/lib/libg++/g++-include/DiscUnif.h delete mode 100644 gnu/lib/libg++/g++-include/Erlang.h delete mode 100644 gnu/lib/libg++/g++-include/File.h delete mode 100644 gnu/lib/libg++/g++-include/Filebuf.h delete mode 100644 gnu/lib/libg++/g++-include/Fix.h delete mode 100644 gnu/lib/libg++/g++-include/Fix16.h delete mode 100644 gnu/lib/libg++/g++-include/Fix24.h delete mode 100644 gnu/lib/libg++/g++-include/Fmodes.h delete mode 100644 gnu/lib/libg++/g++-include/Geom.h delete mode 100644 gnu/lib/libg++/g++-include/GetOpt.h delete mode 100644 gnu/lib/libg++/g++-include/HypGeom.h delete mode 100644 gnu/lib/libg++/g++-include/Incremental.h delete mode 100644 gnu/lib/libg++/g++-include/Integer.h delete mode 100644 gnu/lib/libg++/g++-include/LogNorm.h delete mode 100644 gnu/lib/libg++/g++-include/MLCG.h delete mode 100644 gnu/lib/libg++/g++-include/Makefile delete mode 100644 gnu/lib/libg++/g++-include/NegExp.h delete mode 100644 gnu/lib/libg++/g++-include/Normal.h delete mode 100644 gnu/lib/libg++/g++-include/Obstack.h delete mode 100644 gnu/lib/libg++/g++-include/Pix.h delete mode 100644 gnu/lib/libg++/g++-include/PlotFile.h delete mode 100644 gnu/lib/libg++/g++-include/Poisson.h delete mode 100644 gnu/lib/libg++/g++-include/RNG.h delete mode 100644 gnu/lib/libg++/g++-include/Random.h delete mode 100644 gnu/lib/libg++/g++-include/Rational.h delete mode 100644 gnu/lib/libg++/g++-include/Regex.h delete mode 100644 gnu/lib/libg++/g++-include/RndInt.h delete mode 100644 gnu/lib/libg++/g++-include/SFile.h delete mode 100644 gnu/lib/libg++/g++-include/SmplHist.h delete mode 100644 gnu/lib/libg++/g++-include/SmplStat.h delete mode 100644 gnu/lib/libg++/g++-include/String.h delete mode 100644 gnu/lib/libg++/g++-include/Uniform.h delete mode 100644 gnu/lib/libg++/g++-include/Weibull.h delete mode 100644 gnu/lib/libg++/g++-include/abs.h delete mode 100644 gnu/lib/libg++/g++-include/bool.h delete mode 100644 gnu/lib/libg++/g++-include/builtin.h delete mode 100644 gnu/lib/libg++/g++-include/compare.h delete mode 100644 gnu/lib/libg++/g++-include/complex.h delete mode 100644 gnu/lib/libg++/g++-include/fcntl.h delete mode 100644 gnu/lib/libg++/g++-include/file.h delete mode 100644 gnu/lib/libg++/g++-include/filebuf.h delete mode 100644 gnu/lib/libg++/g++-include/generic.h delete mode 100644 gnu/lib/libg++/g++-include/grp.h delete mode 100644 gnu/lib/libg++/g++-include/istream.h delete mode 100644 gnu/lib/libg++/g++-include/malloc.h delete mode 100644 gnu/lib/libg++/g++-include/math-68881.h delete mode 100644 gnu/lib/libg++/g++-include/math.h delete mode 100644 gnu/lib/libg++/g++-include/max.h delete mode 100644 gnu/lib/libg++/g++-include/memory.h delete mode 100644 gnu/lib/libg++/g++-include/min.h delete mode 100644 gnu/lib/libg++/g++-include/minmax.h delete mode 100644 gnu/lib/libg++/g++-include/netdb.h delete mode 100644 gnu/lib/libg++/g++-include/new.h delete mode 100644 gnu/lib/libg++/g++-include/open.h delete mode 100644 gnu/lib/libg++/g++-include/osfcn.h delete mode 100644 gnu/lib/libg++/g++-include/ostream.h delete mode 100644 gnu/lib/libg++/g++-include/pwd.h delete mode 100644 gnu/lib/libg++/g++-include/regex.h delete mode 100644 gnu/lib/libg++/g++-include/setjmp.h delete mode 100644 gnu/lib/libg++/g++-include/signal.h delete mode 100644 gnu/lib/libg++/g++-include/std.h delete mode 100644 gnu/lib/libg++/g++-include/stdarg.h delete mode 100644 gnu/lib/libg++/g++-include/stddef.h delete mode 100644 gnu/lib/libg++/g++-include/stdio.h delete mode 100644 gnu/lib/libg++/g++-include/stdlib.h delete mode 100644 gnu/lib/libg++/g++-include/strclass.h delete mode 100644 gnu/lib/libg++/g++-include/stream.h delete mode 100644 gnu/lib/libg++/g++-include/streambuf.h delete mode 100644 gnu/lib/libg++/g++-include/string.h delete mode 100644 gnu/lib/libg++/g++-include/strings.h delete mode 100644 gnu/lib/libg++/g++-include/swap.h delete mode 100644 gnu/lib/libg++/g++-include/sys/signal.h delete mode 100644 gnu/lib/libg++/g++-include/sys/socket.h delete mode 100644 gnu/lib/libg++/g++-include/sys/stat.h delete mode 100644 gnu/lib/libg++/g++-include/sys/time.h delete mode 100644 gnu/lib/libg++/g++-include/sys/times.h delete mode 100644 gnu/lib/libg++/g++-include/sys/types.h delete mode 100644 gnu/lib/libg++/g++-include/sys/wait.h delete mode 100644 gnu/lib/libg++/g++-include/time.h delete mode 100644 gnu/lib/libg++/g++-include/unistd.h delete mode 100644 gnu/lib/libg++/libg++/SFile.cc delete mode 100644 gnu/lib/libg++/libg++/Sample.cc delete mode 100644 gnu/lib/libg++/libg++/ctype.cc delete mode 100644 gnu/lib/libg++/libg++/curses.cc delete mode 100644 gnu/lib/libg++/libg++/delete.cc delete mode 100644 gnu/lib/libg++/libg++/filebuf.cc delete mode 100644 gnu/lib/libg++/libg++/form.cc delete mode 100644 gnu/lib/libg++/libg++/g++.order delete mode 100644 gnu/lib/libg++/libg++/gnulib3.c delete mode 100644 gnu/lib/libg++/libg++/istream.cc delete mode 100644 gnu/lib/libg++/libg++/itoa.cc delete mode 100644 gnu/lib/libg++/libg++/malloc.c delete mode 100644 gnu/lib/libg++/libg++/max.cc delete mode 100644 gnu/lib/libg++/libg++/min.cc delete mode 100644 gnu/lib/libg++/libg++/open.cc delete mode 100644 gnu/lib/libg++/libg++/ostream.cc delete mode 100644 gnu/lib/libg++/libg++/std.cc delete mode 100644 gnu/lib/libg++/libg++/streambuf.cc delete mode 100644 gnu/lib/libg++/libg++/xyzzy.cc delete mode 100644 gnu/lib/libregex/Makefile.in delete mode 100644 gnu/lib/libregex/NEWS delete mode 100644 gnu/lib/libregex/README delete mode 100644 gnu/lib/libregex/VERSION delete mode 100644 gnu/lib/libregex/config.status delete mode 100644 gnu/lib/libregex/configure delete mode 100644 gnu/lib/libregex/configure.in delete mode 100644 gnu/lib/libregex/doc/regex.info delete mode 100644 gnu/lib/libregex/doc/regex.texi delete mode 100644 gnu/lib/libregex/doc/texinfo.tex delete mode 100644 gnu/lib/libregex/doc/xregex.texi delete mode 100644 gnu/lib/libregex/regex.c delete mode 100644 gnu/lib/libregex/regex.h delete mode 100644 gnu/lib/libregex/shlib_version delete mode 100644 gnu/lib/libregex/test/debugmalloc.c delete mode 100644 gnu/lib/libregex/test/emacsmalloc.c delete mode 100644 gnu/lib/libregex/test/fileregex.c delete mode 100644 gnu/lib/libregex/test/g++malloc.c delete mode 100644 gnu/lib/libregex/test/getpagesize.h delete mode 100644 gnu/lib/libregex/test/iregex.c delete mode 100644 gnu/lib/libregex/test/main.c delete mode 100644 gnu/lib/libregex/test/malloc-test.c delete mode 100644 gnu/lib/libregex/test/other.c delete mode 100644 gnu/lib/libregex/test/printchar.c delete mode 100644 gnu/lib/libregex/test/psx-basic.c delete mode 100644 gnu/lib/libregex/test/psx-extend.c delete mode 100644 gnu/lib/libregex/test/psx-generic.c delete mode 100644 gnu/lib/libregex/test/psx-group.c delete mode 100644 gnu/lib/libregex/test/psx-interf.c delete mode 100644 gnu/lib/libregex/test/psx-interv.c delete mode 100644 gnu/lib/libregex/test/regexcpp.sed delete mode 100644 gnu/lib/libregex/test/syntax.skel delete mode 100644 gnu/lib/libregex/test/test.c delete mode 100644 gnu/lib/libregex/test/test.h delete mode 100644 gnu/lib/libregex/test/tregress.c delete mode 100644 gnu/lib/libregex/test/upcase.c delete mode 100644 gnu/lib/libregex/test/xmalloc.c delete mode 100644 gnu/lib/regex-0.12/Makefile.in delete mode 100644 gnu/lib/regex-0.12/NEWS delete mode 100644 gnu/lib/regex-0.12/README delete mode 100644 gnu/lib/regex-0.12/config.status delete mode 100644 gnu/lib/regex-0.12/configure delete mode 100644 gnu/lib/regex-0.12/configure.in delete mode 100644 gnu/lib/regex-0.12/doc/regex.info delete mode 100644 gnu/lib/regex-0.12/doc/regex.texi delete mode 100644 gnu/lib/regex-0.12/doc/texinfo.tex delete mode 100644 gnu/lib/regex-0.12/doc/xregex.texi delete mode 100644 gnu/lib/regex-0.12/regex.c delete mode 100644 gnu/lib/regex-0.12/regex.h delete mode 100644 gnu/lib/regex-0.12/test/debugmalloc.c delete mode 100644 gnu/lib/regex-0.12/test/emacsmalloc.c delete mode 100644 gnu/lib/regex-0.12/test/fileregex.c delete mode 100644 gnu/lib/regex-0.12/test/g++malloc.c delete mode 100644 gnu/lib/regex-0.12/test/getpagesize.h delete mode 100644 gnu/lib/regex-0.12/test/iregex.c delete mode 100644 gnu/lib/regex-0.12/test/main.c delete mode 100644 gnu/lib/regex-0.12/test/malloc-test.c delete mode 100644 gnu/lib/regex-0.12/test/other.c delete mode 100644 gnu/lib/regex-0.12/test/printchar.c delete mode 100644 gnu/lib/regex-0.12/test/psx-basic.c delete mode 100644 gnu/lib/regex-0.12/test/psx-extend.c delete mode 100644 gnu/lib/regex-0.12/test/psx-generic.c delete mode 100644 gnu/lib/regex-0.12/test/psx-group.c delete mode 100644 gnu/lib/regex-0.12/test/psx-interf.c delete mode 100644 gnu/lib/regex-0.12/test/psx-interv.c delete mode 100644 gnu/lib/regex-0.12/test/regexcpp.sed delete mode 100644 gnu/lib/regex-0.12/test/syntax.skel delete mode 100644 gnu/lib/regex-0.12/test/test.c delete mode 100644 gnu/lib/regex-0.12/test/test.h delete mode 100644 gnu/lib/regex-0.12/test/tregress.c delete mode 100644 gnu/lib/regex-0.12/test/upcase.c delete mode 100644 gnu/lib/regex-0.12/test/xmalloc.c delete mode 100644 gnu/libexec/uucp/config.c delete mode 100644 gnu/libexec/uucp/config.status delete mode 100644 gnu/libexec/uucp/configure delete mode 100644 gnu/libexec/uucp/configure.in delete mode 100644 gnu/libexec/uucp/copy.c delete mode 100644 gnu/libexec/uucp/file.c delete mode 100644 gnu/libexec/uucp/getopt.c delete mode 100644 gnu/libexec/uucp/getopt.h delete mode 100644 gnu/libexec/uucp/log.c delete mode 100644 gnu/libexec/uucp/parse.c delete mode 100644 gnu/libexec/uucp/policy.h delete mode 100644 gnu/libexec/uucp/port.c delete mode 100644 gnu/libexec/uucp/port.h delete mode 100644 gnu/libexec/uucp/prot.c delete mode 100644 gnu/libexec/uucp/prot.h delete mode 100644 gnu/libexec/uucp/prote.c delete mode 100644 gnu/libexec/uucp/protf.c delete mode 100644 gnu/libexec/uucp/protg.c delete mode 100644 gnu/libexec/uucp/prott.c delete mode 100644 gnu/libexec/uucp/prtinf.c delete mode 100644 gnu/libexec/uucp/sys1.unx delete mode 100644 gnu/libexec/uucp/sys2.unx delete mode 100644 gnu/libexec/uucp/sys3.unx delete mode 100644 gnu/libexec/uucp/sys4.unx delete mode 100644 gnu/libexec/uucp/sys5.unx delete mode 100644 gnu/libexec/uucp/sys6.unx delete mode 100644 gnu/libexec/uucp/sys7.unx delete mode 100644 gnu/libexec/uucp/sysh.unx delete mode 100644 gnu/libexec/uucp/sysinf.c delete mode 100644 gnu/libexec/uucp/system.h delete mode 100644 gnu/libexec/uucp/tcp.c delete mode 100644 gnu/libexec/uucp/time.c delete mode 100644 gnu/libexec/uucp/util.c delete mode 100644 gnu/libexec/uucp/uuchk.c delete mode 100644 gnu/libexec/uucp/uucico.8 delete mode 100644 gnu/libexec/uucp/uucico.c delete mode 100644 gnu/libexec/uucp/uucp.1 delete mode 100644 gnu/libexec/uucp/uucp.c delete mode 100644 gnu/libexec/uucp/uucp.h delete mode 100644 gnu/libexec/uucp/uucp.info delete mode 100644 gnu/libexec/uucp/uucp.info-1 delete mode 100644 gnu/libexec/uucp/uucp.info-2 delete mode 100644 gnu/libexec/uucp/uucp.info-3 delete mode 100644 gnu/libexec/uucp/uucp.info-4 delete mode 100644 gnu/libexec/uucp/uucp.texi delete mode 100644 gnu/libexec/uucp/uudir.c delete mode 100644 gnu/libexec/uucp/uulog.c delete mode 100644 gnu/libexec/uucp/uuname.c delete mode 100644 gnu/libexec/uucp/uustat.1 delete mode 100644 gnu/libexec/uucp/uustat.c delete mode 100644 gnu/libexec/uucp/uutime.h delete mode 100644 gnu/libexec/uucp/uux.1 delete mode 100644 gnu/libexec/uucp/uux.c delete mode 100644 gnu/libexec/uucp/uuxqt.8 delete mode 100644 gnu/libexec/uucp/uuxqt.c delete mode 100644 gnu/libexec/uucp/v2.c delete mode 100644 gnu/libexec/uucp/version.c delete mode 100644 gnu/usr.bin/awk/bi_funct.c delete mode 100644 gnu/usr.bin/awk/bi_funct.h delete mode 100644 gnu/usr.bin/awk/bi_vars.c delete mode 100644 gnu/usr.bin/awk/bi_vars.h delete mode 100644 gnu/usr.bin/awk/cast.c delete mode 100644 gnu/usr.bin/awk/code.c delete mode 100644 gnu/usr.bin/awk/code.h delete mode 100644 gnu/usr.bin/awk/config.h delete mode 100644 gnu/usr.bin/awk/config/msc_dos.h delete mode 100644 gnu/usr.bin/awk/config/next.h delete mode 100644 gnu/usr.bin/awk/config/sgi.h delete mode 100644 gnu/usr.bin/awk/config/sun_os40.h delete mode 100644 gnu/usr.bin/awk/config/sun_os41.h delete mode 100644 gnu/usr.bin/awk/config/sysV.h delete mode 100644 gnu/usr.bin/awk/config/sysV_ieeefp.h delete mode 100644 gnu/usr.bin/awk/config/tcc_dos.h delete mode 100644 gnu/usr.bin/awk/config/template.h delete mode 100644 gnu/usr.bin/awk/config/think_c.h delete mode 100644 gnu/usr.bin/awk/config/ultrix42mips.h delete mode 100644 gnu/usr.bin/awk/config/ultrix_vax.h delete mode 100644 gnu/usr.bin/awk/config/xenix_r2.h delete mode 100644 gnu/usr.bin/awk/da.c delete mode 100644 gnu/usr.bin/awk/error.c delete mode 100644 gnu/usr.bin/awk/execute.c delete mode 100644 gnu/usr.bin/awk/fcall.c delete mode 100644 gnu/usr.bin/awk/field.c delete mode 100644 gnu/usr.bin/awk/field.h delete mode 100644 gnu/usr.bin/awk/files.c delete mode 100644 gnu/usr.bin/awk/files.h delete mode 100644 gnu/usr.bin/awk/fin.c delete mode 100644 gnu/usr.bin/awk/fin.h delete mode 100644 gnu/usr.bin/awk/hash.c delete mode 100644 gnu/usr.bin/awk/init.c delete mode 100644 gnu/usr.bin/awk/init.h delete mode 100644 gnu/usr.bin/awk/jmp.c delete mode 100644 gnu/usr.bin/awk/jmp.h delete mode 100644 gnu/usr.bin/awk/kw.c delete mode 100644 gnu/usr.bin/awk/main.c delete mode 100644 gnu/usr.bin/awk/makescan.c delete mode 100644 gnu/usr.bin/awk/matherr.c delete mode 100644 gnu/usr.bin/awk/mawk.h delete mode 100644 gnu/usr.bin/awk/memory.c delete mode 100644 gnu/usr.bin/awk/memory.h delete mode 100644 gnu/usr.bin/awk/parse.y delete mode 100644 gnu/usr.bin/awk/parse2.xc delete mode 100644 gnu/usr.bin/awk/patchlev.h delete mode 100644 gnu/usr.bin/awk/print.c delete mode 100644 gnu/usr.bin/awk/re_cmpl.c delete mode 100644 gnu/usr.bin/awk/regexp.h delete mode 100644 gnu/usr.bin/awk/repl.h delete mode 100644 gnu/usr.bin/awk/scan.c delete mode 100644 gnu/usr.bin/awk/scan.h delete mode 100644 gnu/usr.bin/awk/scancode.c delete mode 100644 gnu/usr.bin/awk/sizes.h delete mode 100644 gnu/usr.bin/awk/split.c delete mode 100644 gnu/usr.bin/awk/symtype.h delete mode 100644 gnu/usr.bin/awk/types.h delete mode 100644 gnu/usr.bin/awk/vargs.h delete mode 100644 gnu/usr.bin/awk/version.c delete mode 100644 gnu/usr.bin/awk/zmalloc.c delete mode 100644 gnu/usr.bin/awk/zmalloc.h delete mode 100644 gnu/usr.bin/bc-1.02/Test/ln.b delete mode 100644 gnu/usr.bin/bc-1.02/Test/mul.b delete mode 100644 gnu/usr.bin/bc-1.02/Test/raise.b delete mode 100644 gnu/usr.bin/bc-1.02/Test/sine.b delete mode 100644 gnu/usr.bin/bc-1.02/Test/sqrt.b delete mode 100644 gnu/usr.bin/bc-1.02/Test/testfn.b delete mode 100644 gnu/usr.bin/bc-1.02/Test/timetest delete mode 100644 gnu/usr.bin/bc-1.02/bc.c.dist delete mode 100644 gnu/usr.bin/bc-1.02/bc.y delete mode 100644 gnu/usr.bin/bc-1.02/bcdefs.h delete mode 100644 gnu/usr.bin/bc-1.02/config.h delete mode 100644 gnu/usr.bin/bc-1.02/configure delete mode 100644 gnu/usr.bin/bc-1.02/const.h delete mode 100644 gnu/usr.bin/bc-1.02/execute.c delete mode 100644 gnu/usr.bin/bc-1.02/fix_math.h delete mode 100644 gnu/usr.bin/bc-1.02/global.c delete mode 100644 gnu/usr.bin/bc-1.02/global.h delete mode 100644 gnu/usr.bin/bc-1.02/libmath.b delete mode 100644 gnu/usr.bin/bc-1.02/load.c delete mode 100644 gnu/usr.bin/bc-1.02/main.c delete mode 100644 gnu/usr.bin/bc-1.02/math.h delete mode 100644 gnu/usr.bin/bc-1.02/number.c delete mode 100644 gnu/usr.bin/bc-1.02/number.h delete mode 100644 gnu/usr.bin/bc-1.02/proto.h delete mode 100644 gnu/usr.bin/bc-1.02/sbc.y delete mode 100644 gnu/usr.bin/bc-1.02/scan.c.dist delete mode 100644 gnu/usr.bin/bc-1.02/scan.l delete mode 100644 gnu/usr.bin/bc-1.02/storage.c delete mode 100644 gnu/usr.bin/bc-1.02/util.c delete mode 100644 gnu/usr.bin/bc-1.02/version.h delete mode 100644 gnu/usr.bin/bc-1.02/vfprintf.c delete mode 100644 gnu/usr.bin/bc-1.02/y.tab.h.dist delete mode 100644 gnu/usr.bin/fgrep/fgrep delete mode 100644 gnu/usr.bin/fgrep/obstack.c delete mode 100644 gnu/usr.bin/fgrep/obstack.h delete mode 100644 gnu/usr.bin/fgrep/std.c delete mode 100644 gnu/usr.bin/fgrep/std.h delete mode 100644 gnu/usr.bin/fgrep/unix.h delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-class.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-cvt.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-decl.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-decl.h delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-decl2.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-except.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-expr.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-field.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-init.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-lex.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-method.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-parse.h delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-parse.y delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-ptree.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-search.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-tree.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-tree.def delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-tree.h delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-type2.c delete mode 100644 gnu/usr.bin/g++/cc1plus/cplus-typeck.c delete mode 100644 gnu/usr.bin/g++/cc1plus/dbxout.c delete mode 100644 gnu/usr.bin/g++/cc1plus/expr.c delete mode 100644 gnu/usr.bin/g++/cc1plus/expr.h delete mode 100644 gnu/usr.bin/g++/cc1plus/flags.h delete mode 100644 gnu/usr.bin/g++/cc1plus/gplus.gperf delete mode 100644 gnu/usr.bin/g++/cc1plus/input.h delete mode 100644 gnu/usr.bin/g++/cc1plus/integrate.c delete mode 100644 gnu/usr.bin/g++/cc1plus/print-tree.c delete mode 100644 gnu/usr.bin/g++/cc1plus/stab.def delete mode 100644 gnu/usr.bin/g++/cc1plus/stab.h delete mode 100644 gnu/usr.bin/g++/cc1plus/stack.h delete mode 100644 gnu/usr.bin/g++/cc1plus/stmt.c delete mode 100644 gnu/usr.bin/g++/cc1plus/stor-layout.c delete mode 100644 gnu/usr.bin/g++/cc1plus/symout.c delete mode 100644 gnu/usr.bin/g++/cc1plus/toplev.c delete mode 100644 gnu/usr.bin/g++/cc1plus/tree.c delete mode 100644 gnu/usr.bin/g++/cc1plus/tree.def delete mode 100644 gnu/usr.bin/g++/cc1plus/tree.h delete mode 100644 gnu/usr.bin/g++/cc1plus/varasm.c delete mode 100644 gnu/usr.bin/g++/cc1plus/version.c delete mode 100644 gnu/usr.bin/g++/cc1plus/y.tab.h delete mode 100644 gnu/usr.bin/gas/config/i860.h delete mode 100644 gnu/usr.bin/gas/config/m-hpux.h delete mode 100644 gnu/usr.bin/gas/config/m-sun3.h delete mode 100644 gnu/usr.bin/gas/config/m68k-opcode.h delete mode 100644 gnu/usr.bin/gas/config/m68k.c delete mode 100644 gnu/usr.bin/gas/config/m68k.h delete mode 100644 gnu/usr.bin/gas/config/ns32k-opcode.h delete mode 100644 gnu/usr.bin/gas/config/ns32k.c delete mode 100644 gnu/usr.bin/gas/config/sparc-opcode.h delete mode 100644 gnu/usr.bin/gas/config/sparc.c delete mode 100644 gnu/usr.bin/gas/config/sparc.h delete mode 100644 gnu/usr.bin/gas/config/vax-opcode.h delete mode 100644 gnu/usr.bin/gas/config/vax.c delete mode 100644 gnu/usr.bin/gas/md.h delete mode 100644 gnu/usr.bin/gas/objrecdef.h delete mode 100644 gnu/usr.bin/gawk-2.15.2/POSIX delete mode 100644 gnu/usr.bin/gawk-2.15.2/PROBLEMS delete mode 100644 gnu/usr.bin/gawk-2.15.2/README delete mode 100644 gnu/usr.bin/gawk-2.15.2/array.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/awk.1 delete mode 100644 gnu/usr.bin/gawk-2.15.2/awk.h delete mode 100644 gnu/usr.bin/gawk-2.15.2/awk.y delete mode 100644 gnu/usr.bin/gawk-2.15.2/builtin.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/config.h delete mode 100644 gnu/usr.bin/gawk-2.15.2/dfa.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/dfa.h delete mode 100644 gnu/usr.bin/gawk-2.15.2/eval.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/field.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/gawk.texi delete mode 100644 gnu/usr.bin/gawk-2.15.2/getopt.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/getopt.h delete mode 100644 gnu/usr.bin/gawk-2.15.2/getopt1.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/io.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/iop.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/main.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/msg.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/node.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/patchlevel.h delete mode 100644 gnu/usr.bin/gawk-2.15.2/protos.h delete mode 100644 gnu/usr.bin/gawk-2.15.2/re.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/regex.c delete mode 100644 gnu/usr.bin/gawk-2.15.2/regex.h delete mode 100644 gnu/usr.bin/gawk-2.15.2/version.c delete mode 100644 gnu/usr.bin/gcc2/arch/da30/insn-attrtab.c delete mode 100644 gnu/usr.bin/gcc2/arch/da30/insn-codes.h delete mode 100644 gnu/usr.bin/gcc2/arch/da30/insn-config.h delete mode 100644 gnu/usr.bin/gcc2/arch/da30/insn-emit.c delete mode 100644 gnu/usr.bin/gcc2/arch/da30/insn-extract.c delete mode 100644 gnu/usr.bin/gcc2/arch/da30/insn-flags.h delete mode 100644 gnu/usr.bin/gcc2/arch/da30/insn-opinit.c delete mode 100644 gnu/usr.bin/gcc2/arch/da30/insn-output.c delete mode 100644 gnu/usr.bin/gcc2/arch/da30/insn-peep.c delete mode 100644 gnu/usr.bin/gcc2/arch/da30/insn-recog.c delete mode 100644 gnu/usr.bin/gcc2/arch/da30/m68k.h delete mode 100644 gnu/usr.bin/gcc2/arch/da30/md delete mode 100644 gnu/usr.bin/gcc2/arch/da30/tconfig.h delete mode 100644 gnu/usr.bin/gcc2/arch/da30/tm.h delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/insn-codes.h delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/insn-config.h delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/insn-emit.c delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/insn-extract.c delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/insn-flags.h delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/insn-opinit.c delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/insn-output.c delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/insn-peep.c delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/insn-recog.c delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/m68k.h delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/md delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/tconfig.h delete mode 100644 gnu/usr.bin/gcc2/arch/hp300/tm.h delete mode 100644 gnu/usr.bin/gcc2/common/insn-config.h delete mode 100644 gnu/usr.bin/gcc2/common/insn-emit.c delete mode 100644 gnu/usr.bin/gcc2/common/insn-extract.c delete mode 100644 gnu/usr.bin/gcc2/common/insn-flags.h delete mode 100644 gnu/usr.bin/gcc2/common/insn-opinit.c delete mode 100644 gnu/usr.bin/gcc2/common/insn-output.c delete mode 100644 gnu/usr.bin/gcc2/common/insn-peep.c delete mode 100644 gnu/usr.bin/gcc2/common/insn-recog.c delete mode 100644 gnu/usr.bin/gcc2/common/tconfig.h delete mode 100644 gnu/usr.bin/gcc2/common/tm.h delete mode 100644 gnu/usr.bin/gcc2/i386/insn-attr.h delete mode 100644 gnu/usr.bin/gcc2/i386/insn-attrtab.c delete mode 100644 gnu/usr.bin/gcc2/i386/insn-codes.h delete mode 100644 gnu/usr.bin/gcc2/i386/insn-config.h delete mode 100644 gnu/usr.bin/gcc2/i386/insn-emit.c delete mode 100644 gnu/usr.bin/gcc2/i386/insn-extract.c delete mode 100644 gnu/usr.bin/gcc2/i386/insn-flags.h delete mode 100644 gnu/usr.bin/gcc2/i386/insn-opinit.c delete mode 100644 gnu/usr.bin/gcc2/i386/insn-output.c delete mode 100644 gnu/usr.bin/gcc2/i386/insn-peep.c delete mode 100644 gnu/usr.bin/gcc2/i386/insn-recog.c delete mode 100644 gnu/usr.bin/gcc2/i386/perform.h delete mode 100644 gnu/usr.bin/gcc2/i386/tconfig.h delete mode 100644 gnu/usr.bin/gcc2/i386/tm.h delete mode 100644 gnu/usr.bin/gcc2/i386/unix.h delete mode 100644 gnu/usr.bin/gcc2/libgcc/_ashlsi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_ashrdi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_ashrsi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_bb.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_clear_cache.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_cmpdi2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_ctors.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_divdf3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_divdi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_divsf3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_divsi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_eprintf.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_eqdf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_eqsf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_exit.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_extendsfdf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_ffsdi2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixdfdi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixdfsi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixsfdi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixsfsi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixunsdfdi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixunsdfsi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixunssfdi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixunssfsi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixunsxfdi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixunsxfsi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_fixxfdi.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_floatdidf.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_floatdisf.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_floatdixf.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_floatsidf.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_floatsisf.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_gedf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_gesf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_gtdf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_gtsf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_ledf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_lesf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_lshldi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_lshlsi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_lshrdi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_lshrsi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_ltdf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_ltsf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_moddi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_modsi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_muldf3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_muldi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_mulsf3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_mulsi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_nedf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_negdf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_negdi2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_negsf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_nesf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_new_handler.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_op_delete.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_op_new.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_shtab.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_subdf3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_subsf3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_trampoline.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_truncdfsf2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_ucmpdi2.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_udiv_w_sdiv.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_udivdi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_udivmoddi4.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_udivsi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_umoddi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_umodsi3.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/_varargs.c delete mode 100644 gnu/usr.bin/gcc2/libgcc/clean.sed delete mode 100644 gnu/usr.bin/gdb/Xgdb.ad delete mode 100644 gnu/usr.bin/gdb/blockframe.c delete mode 100644 gnu/usr.bin/gdb/breakpoint.c delete mode 100644 gnu/usr.bin/gdb/command.c delete mode 100644 gnu/usr.bin/gdb/command.h delete mode 100644 gnu/usr.bin/gdb/config/altos-dep.c delete mode 100644 gnu/usr.bin/gdb/config/convex-dep.c delete mode 100644 gnu/usr.bin/gdb/config/convex-opcode.h delete mode 100644 gnu/usr.bin/gdb/config/convex-pinsn.c delete mode 100644 gnu/usr.bin/gdb/config/default-dep.c delete mode 100644 gnu/usr.bin/gdb/config/gld-pinsn.c delete mode 100644 gnu/usr.bin/gdb/config/gould-dep.c delete mode 100644 gnu/usr.bin/gdb/config/hp300bsd-dep.c delete mode 100644 gnu/usr.bin/gdb/config/hp9k320-dep.c delete mode 100644 gnu/usr.bin/gdb/config/i386-dep.c delete mode 100644 gnu/usr.bin/gdb/config/i386-pinsn.c delete mode 100644 gnu/usr.bin/gdb/config/i386bsd-dep.c delete mode 100644 gnu/usr.bin/gdb/config/isi-dep.c delete mode 100644 gnu/usr.bin/gdb/config/m-altos.h delete mode 100644 gnu/usr.bin/gdb/config/m-convex.h delete mode 100644 gnu/usr.bin/gdb/config/m-hp9k320.h delete mode 100644 gnu/usr.bin/gdb/config/m-i386-sv32.h delete mode 100644 gnu/usr.bin/gdb/config/m-i386.h delete mode 100644 gnu/usr.bin/gdb/config/m-i386bsd.h delete mode 100644 gnu/usr.bin/gdb/config/m-i386g-sv32.h delete mode 100644 gnu/usr.bin/gdb/config/m-i386gas.h delete mode 100644 gnu/usr.bin/gdb/config/m-isi.h delete mode 100644 gnu/usr.bin/gdb/config/m-m68kbsd.h delete mode 100644 gnu/usr.bin/gdb/config/m-merlin.h delete mode 100644 gnu/usr.bin/gdb/config/m-news.h delete mode 100644 gnu/usr.bin/gdb/config/m-newsos3.h delete mode 100644 gnu/usr.bin/gdb/config/m-npl.h delete mode 100644 gnu/usr.bin/gdb/config/m-pn.h delete mode 100644 gnu/usr.bin/gdb/config/m-pyr.h delete mode 100644 gnu/usr.bin/gdb/config/m-sparc.h delete mode 100644 gnu/usr.bin/gdb/config/m-sun2.h delete mode 100644 gnu/usr.bin/gdb/config/m-sun2os4.h delete mode 100644 gnu/usr.bin/gdb/config/m-sun3.h delete mode 100644 gnu/usr.bin/gdb/config/m-sun3os4.h delete mode 100644 gnu/usr.bin/gdb/config/m-sun4os4.h delete mode 100644 gnu/usr.bin/gdb/config/m-symmetry.h delete mode 100644 gnu/usr.bin/gdb/config/m-tahoe.h delete mode 100644 gnu/usr.bin/gdb/config/m-umax.h delete mode 100644 gnu/usr.bin/gdb/config/m-vax.h delete mode 100644 gnu/usr.bin/gdb/config/m68k-opcode.h delete mode 100644 gnu/usr.bin/gdb/config/m68k-pinsn.c delete mode 100644 gnu/usr.bin/gdb/config/m68kbsd-dep.c delete mode 100644 gnu/usr.bin/gdb/config/news-dep.c delete mode 100644 gnu/usr.bin/gdb/config/npl-opcode.h delete mode 100644 gnu/usr.bin/gdb/config/ns32k-opcode.h delete mode 100644 gnu/usr.bin/gdb/config/ns32k-pinsn.c delete mode 100644 gnu/usr.bin/gdb/config/pn-opcode.h delete mode 100644 gnu/usr.bin/gdb/config/pyr-dep.c delete mode 100644 gnu/usr.bin/gdb/config/pyr-opcode.h delete mode 100644 gnu/usr.bin/gdb/config/pyr-pinsn.c delete mode 100644 gnu/usr.bin/gdb/config/sparc-dep.c delete mode 100644 gnu/usr.bin/gdb/config/sparc-opcode.h delete mode 100644 gnu/usr.bin/gdb/config/sparc-pinsn.c delete mode 100644 gnu/usr.bin/gdb/config/sun3-dep.c delete mode 100644 gnu/usr.bin/gdb/config/symmetry-dep.c delete mode 100644 gnu/usr.bin/gdb/config/tahoe-opcode.h delete mode 100644 gnu/usr.bin/gdb/config/tahoe-pinsn.c delete mode 100644 gnu/usr.bin/gdb/config/umax-dep.c delete mode 100644 gnu/usr.bin/gdb/config/vax-opcode.h delete mode 100644 gnu/usr.bin/gdb/config/vax-pinsn.c delete mode 100644 gnu/usr.bin/gdb/copying.c delete mode 100644 gnu/usr.bin/gdb/core.c delete mode 100644 gnu/usr.bin/gdb/cplus-dem.c delete mode 100644 gnu/usr.bin/gdb/dbxread.c delete mode 100644 gnu/usr.bin/gdb/defs.h delete mode 100644 gnu/usr.bin/gdb/environ.c delete mode 100644 gnu/usr.bin/gdb/environ.h delete mode 100644 gnu/usr.bin/gdb/eval.c delete mode 100644 gnu/usr.bin/gdb/expprint.c delete mode 100644 gnu/usr.bin/gdb/expread.y delete mode 100644 gnu/usr.bin/gdb/expression.h delete mode 100644 gnu/usr.bin/gdb/findvar.c delete mode 100644 gnu/usr.bin/gdb/frame.h delete mode 100644 gnu/usr.bin/gdb/gdb.1 delete mode 100644 gnu/usr.bin/gdb/getpagesize.h delete mode 100644 gnu/usr.bin/gdb/infcmd.c delete mode 100644 gnu/usr.bin/gdb/inferior.h delete mode 100644 gnu/usr.bin/gdb/inflow.c delete mode 100644 gnu/usr.bin/gdb/infrun.c delete mode 100644 gnu/usr.bin/gdb/kgdb_proto.h delete mode 100644 gnu/usr.bin/gdb/main.c delete mode 100644 gnu/usr.bin/gdb/obstack.c delete mode 100644 gnu/usr.bin/gdb/obstack.h delete mode 100644 gnu/usr.bin/gdb/printcmd.c delete mode 100644 gnu/usr.bin/gdb/regex.c delete mode 100644 gnu/usr.bin/gdb/regex.h delete mode 100644 gnu/usr.bin/gdb/remote-sl.c delete mode 100644 gnu/usr.bin/gdb/remote.c delete mode 100644 gnu/usr.bin/gdb/source.c delete mode 100644 gnu/usr.bin/gdb/stab.def delete mode 100644 gnu/usr.bin/gdb/stack.c delete mode 100644 gnu/usr.bin/gdb/symmisc.c delete mode 100644 gnu/usr.bin/gdb/symseg.h delete mode 100644 gnu/usr.bin/gdb/symtab.c delete mode 100644 gnu/usr.bin/gdb/symtab.h delete mode 100644 gnu/usr.bin/gdb/utils.c delete mode 100644 gnu/usr.bin/gdb/valarith.c delete mode 100644 gnu/usr.bin/gdb/valops.c delete mode 100644 gnu/usr.bin/gdb/valprint.c delete mode 100644 gnu/usr.bin/gdb/value.h delete mode 100644 gnu/usr.bin/gdb/values.c delete mode 100644 gnu/usr.bin/gdb/wait.h delete mode 100644 gnu/usr.bin/groff/Makefile.gnu delete mode 100644 gnu/usr.bin/groff/devices/devdvi/texex.map delete mode 100644 gnu/usr.bin/groff/devices/devdvi/texi.map delete mode 100644 gnu/usr.bin/groff/devices/devdvi/texmi.map delete mode 100644 gnu/usr.bin/groff/devices/devdvi/texr.map delete mode 100644 gnu/usr.bin/groff/devices/devdvi/texsy.map delete mode 100644 gnu/usr.bin/groff/devices/devdvi/textt.map delete mode 100644 gnu/usr.bin/groff/devices/devps/symbol.diff delete mode 100644 gnu/usr.bin/groff/devices/devps/symbolchars delete mode 100644 gnu/usr.bin/groff/devices/devps/symbolsl.afm delete mode 100644 gnu/usr.bin/groff/devices/devps/symbolsl.ps delete mode 100644 gnu/usr.bin/groff/devices/devps/textmap delete mode 100644 gnu/usr.bin/groff/devices/devps/zapfdr.ps delete mode 100644 gnu/usr.bin/groff/grops/Makefile.dep delete mode 100644 gnu/usr.bin/groff/libXdvi/Makefile.gnu delete mode 100644 gnu/usr.bin/groff/libXdvi/Menu.h delete mode 100644 gnu/usr.bin/groff/libXdvi/XFontName.c delete mode 100644 gnu/usr.bin/groff/libXdvi/XFontName.h delete mode 100644 gnu/usr.bin/groff/libXdvi/draw.c delete mode 100644 gnu/usr.bin/groff/libXdvi/font.c delete mode 100644 gnu/usr.bin/groff/libXdvi/lex.c delete mode 100644 gnu/usr.bin/groff/libXdvi/page.c delete mode 100644 gnu/usr.bin/groff/libXdvi/parse.c delete mode 100644 gnu/usr.bin/groff/libgroff/getpagesize.h delete mode 100644 gnu/usr.bin/groff/libgroff/groff.order delete mode 100644 gnu/usr.bin/groff/libgroff/iftoa.cc delete mode 100644 gnu/usr.bin/groff/libgroff/itoa.cc delete mode 100644 gnu/usr.bin/groff/libgroff/lib.h delete mode 100644 gnu/usr.bin/groff/libgroff/ptable.h delete mode 100644 gnu/usr.bin/groff/libgroff/stringclass.h delete mode 100644 gnu/usr.bin/groff/libgroff/version.cc delete mode 100644 gnu/usr.bin/groff/macros/tmac.pic delete mode 100644 gnu/usr.bin/groff/macros/tmac.ps delete mode 100644 gnu/usr.bin/groff/macros/tmac.psfig delete mode 100644 gnu/usr.bin/groff/macros/tmac.s delete mode 100644 gnu/usr.bin/groff/macros/tmac.tty delete mode 100644 gnu/usr.bin/groff/man/groff_me.man delete mode 100644 gnu/usr.bin/groff/man/groff_ms.man delete mode 100644 gnu/usr.bin/groff/man/groff_out.man delete mode 100644 gnu/usr.bin/groff/man/grog.man delete mode 100644 gnu/usr.bin/groff/man/gsoelim.man delete mode 100644 gnu/usr.bin/groff/man/tfmtodit.man delete mode 100644 gnu/usr.bin/gzip-1.0.7/THANKS delete mode 100644 gnu/usr.bin/gzip-1.0.7/TODO delete mode 100644 gnu/usr.bin/gzip-1.0.7/algorithm.doc delete mode 100644 gnu/usr.bin/gzip-1.0.7/alloca.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/bits.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/configure delete mode 100644 gnu/usr.bin/gzip-1.0.7/configure.in delete mode 100644 gnu/usr.bin/gzip-1.0.7/crypt.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/crypt.h delete mode 100644 gnu/usr.bin/gzip-1.0.7/deflate.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/getopt.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/getopt.h delete mode 100644 gnu/usr.bin/gzip-1.0.7/gpl.texinfo delete mode 100644 gnu/usr.bin/gzip-1.0.7/gzexe.1 delete mode 100644 gnu/usr.bin/gzip-1.0.7/gzexe.in delete mode 100644 gnu/usr.bin/gzip-1.0.7/gzip-tar.patch delete mode 100644 gnu/usr.bin/gzip-1.0.7/gzip.1 delete mode 100644 gnu/usr.bin/gzip-1.0.7/gzip.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/gzip.doc delete mode 100644 gnu/usr.bin/gzip-1.0.7/gzip.h delete mode 100644 gnu/usr.bin/gzip-1.0.7/gzip.info delete mode 100644 gnu/usr.bin/gzip-1.0.7/gzip.texi delete mode 100644 gnu/usr.bin/gzip-1.0.7/inflate.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/lzw.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/lzw.h delete mode 100644 gnu/usr.bin/gzip-1.0.7/makecrc.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/match.S delete mode 100644 gnu/usr.bin/gzip-1.0.7/msdos/match.asm delete mode 100644 gnu/usr.bin/gzip-1.0.7/msdos/tailor.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/revision.h delete mode 100644 gnu/usr.bin/gzip-1.0.7/tailor.h delete mode 100644 gnu/usr.bin/gzip-1.0.7/texinfo.tex delete mode 100644 gnu/usr.bin/gzip-1.0.7/trees.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/unlzw.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/unpack.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/unzip.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/util.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/zdiff.1 delete mode 100644 gnu/usr.bin/gzip-1.0.7/zdiff.in delete mode 100644 gnu/usr.bin/gzip-1.0.7/zforce.1 delete mode 100644 gnu/usr.bin/gzip-1.0.7/zforce.in delete mode 100644 gnu/usr.bin/gzip-1.0.7/zip.c delete mode 100644 gnu/usr.bin/gzip-1.0.7/zmore.1 delete mode 100644 gnu/usr.bin/gzip-1.0.7/zmore.in delete mode 100644 gnu/usr.bin/gzip-1.0.7/znew.1 delete mode 100644 gnu/usr.bin/gzip-1.0.7/znew.in delete mode 100644 gnu/usr.bin/gzip-1.0.7/zread.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/algorithm.doc delete mode 100644 gnu/usr.bin/gzip-1.1.1/bits.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/crypt.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/crypt.h delete mode 100644 gnu/usr.bin/gzip-1.1.1/deflate.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/getopt.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/getopt.h delete mode 100644 gnu/usr.bin/gzip-1.1.1/gzexe delete mode 100644 gnu/usr.bin/gzip-1.1.1/gzexe.1 delete mode 100644 gnu/usr.bin/gzip-1.1.1/gzexe.in delete mode 100644 gnu/usr.bin/gzip-1.1.1/gzip.1 delete mode 100644 gnu/usr.bin/gzip-1.1.1/gzip.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/gzip.h delete mode 100644 gnu/usr.bin/gzip-1.1.1/inflate.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/lzw.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/lzw.h delete mode 100644 gnu/usr.bin/gzip-1.1.1/match.S delete mode 100644 gnu/usr.bin/gzip-1.1.1/revision.h delete mode 100644 gnu/usr.bin/gzip-1.1.1/tailor.h delete mode 100644 gnu/usr.bin/gzip-1.1.1/trees.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/unlzw.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/unpack.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/unzip.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/util.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/zcmp delete mode 100644 gnu/usr.bin/gzip-1.1.1/zdiff delete mode 100644 gnu/usr.bin/gzip-1.1.1/zdiff.1 delete mode 100644 gnu/usr.bin/gzip-1.1.1/zforce delete mode 100644 gnu/usr.bin/gzip-1.1.1/zforce.1 delete mode 100644 gnu/usr.bin/gzip-1.1.1/zip.c delete mode 100644 gnu/usr.bin/gzip-1.1.1/zmore delete mode 100644 gnu/usr.bin/gzip-1.1.1/zmore.1 delete mode 100644 gnu/usr.bin/gzip-1.1.1/znew delete mode 100644 gnu/usr.bin/gzip-1.1.1/znew.1 delete mode 100644 gnu/usr.bin/lex/flex.skl delete mode 100644 gnu/usr.bin/lex/flexdef.h delete mode 100644 gnu/usr.bin/lex/flexdoc.1 delete mode 100644 gnu/usr.bin/lex/gen.c delete mode 100644 gnu/usr.bin/lex/initscan.c delete mode 100644 gnu/usr.bin/lex/main.c delete mode 100644 gnu/usr.bin/lex/misc.c delete mode 100644 gnu/usr.bin/lex/mkskel.sh delete mode 100644 gnu/usr.bin/lex/nfa.c delete mode 100644 gnu/usr.bin/lex/parse.y delete mode 100644 gnu/usr.bin/lex/pathnames.h delete mode 100644 gnu/usr.bin/lex/scan.l delete mode 100644 gnu/usr.bin/lex/sym.c delete mode 100644 gnu/usr.bin/lex/tblcmp.c delete mode 100644 gnu/usr.bin/lex/version.h delete mode 100644 gnu/usr.bin/lex/yylex.c delete mode 100644 gnu/usr.bin/tar-1.11.2/create.c delete mode 100644 gnu/usr.bin/tar-1.11.2/diffarch.c delete mode 100644 gnu/usr.bin/tar-1.11.2/extract.c delete mode 100644 gnu/usr.bin/tar-1.11.2/fnmatch.c delete mode 100644 gnu/usr.bin/tar-1.11.2/fnmatch.h delete mode 100644 gnu/usr.bin/tar-1.11.2/getdate.y delete mode 100644 gnu/usr.bin/tar-1.11.2/getoldopt.c delete mode 100644 gnu/usr.bin/tar-1.11.2/getopt.c delete mode 100644 gnu/usr.bin/tar-1.11.2/getopt.h delete mode 100644 gnu/usr.bin/tar-1.11.2/getopt1.c delete mode 100644 gnu/usr.bin/tar-1.11.2/getpagesize.h delete mode 100644 gnu/usr.bin/tar-1.11.2/gnu.c delete mode 100644 gnu/usr.bin/tar-1.11.2/list.c delete mode 100644 gnu/usr.bin/tar-1.11.2/mangle.c delete mode 100644 gnu/usr.bin/tar-1.11.2/msd_dir.h delete mode 100644 gnu/usr.bin/tar-1.11.2/names.c delete mode 100644 gnu/usr.bin/tar-1.11.2/open3.h delete mode 100644 gnu/usr.bin/tar-1.11.2/pathmax.h delete mode 100644 gnu/usr.bin/tar-1.11.2/port.c delete mode 100644 gnu/usr.bin/tar-1.11.2/port.h delete mode 100644 gnu/usr.bin/tar-1.11.2/regex.c delete mode 100644 gnu/usr.bin/tar-1.11.2/regex.h delete mode 100644 gnu/usr.bin/tar-1.11.2/rmt.h delete mode 100644 gnu/usr.bin/tar-1.11.2/rtapelib.c delete mode 100644 gnu/usr.bin/tar-1.11.2/tar.c delete mode 100644 gnu/usr.bin/tar-1.11.2/tar.h delete mode 100644 gnu/usr.bin/tar-1.11.2/update.c delete mode 100644 gnu/usr.bin/tar-1.11.2/version.c delete mode 100644 include/rpcsvc/nlm_prot.x delete mode 100644 include/rpcsvc/rex.x delete mode 100644 include/rpcsvc/rnusers.x delete mode 100644 include/rpcsvc/rquota.x delete mode 100644 include/rpcsvc/rstat.x delete mode 100644 include/rpcsvc/rwall.x delete mode 100644 include/rpcsvc/sm_inter.x delete mode 100644 include/rpcsvc/spray.x delete mode 100644 include/rpcsvc/yp.x delete mode 100644 include/rpcsvc/yppasswd.x delete mode 100644 lib/csu/mips/crt0.s delete mode 100644 lib/libc/DB/btree/bt_get.c delete mode 100644 lib/libc/DB/btree/bt_open.c delete mode 100644 lib/libc/DB/btree/bt_overflow.c delete mode 100644 lib/libc/DB/btree/bt_page.c delete mode 100644 lib/libc/DB/btree/bt_put.c delete mode 100644 lib/libc/DB/btree/bt_search.c delete mode 100644 lib/libc/DB/btree/bt_seq.c delete mode 100644 lib/libc/DB/btree/bt_split.c delete mode 100644 lib/libc/DB/btree/bt_stack.c delete mode 100644 lib/libc/DB/btree/bt_utils.c delete mode 100644 lib/libc/DB/btree/btree.h delete mode 100644 lib/libc/DB/btree/extern.h delete mode 100644 lib/libc/DB/hash/hash_buf.c delete mode 100644 lib/libc/DB/hash/hash_func.c delete mode 100644 lib/libc/DB/hash/hash_log2.c delete mode 100644 lib/libc/DB/hash/hash_page.c delete mode 100644 lib/libc/DB/hash/hsearch.c delete mode 100644 lib/libc/DB/hash/ndbm.c delete mode 100644 lib/libc/DB/hash/page.h delete mode 100644 lib/libc/DB/hash/search.h delete mode 100644 lib/libc/DB/hash/tests/tseq.c delete mode 100644 lib/libc/DB/hash/tests/tverify.c delete mode 100644 lib/libc/DB/recno/rec_open.c delete mode 100644 lib/libc/DB/recno/rec_put.c delete mode 100644 lib/libc/DB/recno/rec_search.c delete mode 100644 lib/libc/DB/recno/rec_seq.c delete mode 100644 lib/libc/DB/recno/rec_utils.c delete mode 100644 lib/libc/DB/recno/recno.h delete mode 100644 lib/libc/arch/hp300/gen/cmpdf2.S delete mode 100644 lib/libc/arch/hp300/gen/cmpdf2.s delete mode 100644 lib/libc/arch/hp300/gen/cmpsf2.S delete mode 100644 lib/libc/arch/hp300/gen/cmpsf2.s delete mode 100644 lib/libc/arch/hp300/gen/divdf3.S delete mode 100644 lib/libc/arch/hp300/gen/divdf3.s delete mode 100644 lib/libc/arch/hp300/gen/divsf3.S delete mode 100644 lib/libc/arch/hp300/gen/divsf3.s delete mode 100644 lib/libc/arch/hp300/gen/divsi3.S delete mode 100644 lib/libc/arch/hp300/gen/divsi3.s delete mode 100644 lib/libc/arch/hp300/gen/extendsfdf2.S delete mode 100644 lib/libc/arch/hp300/gen/extendsfdf2.s delete mode 100644 lib/libc/arch/hp300/gen/fabs.S delete mode 100644 lib/libc/arch/hp300/gen/fabs.s delete mode 100644 lib/libc/arch/hp300/gen/fixdfsi.S delete mode 100644 lib/libc/arch/hp300/gen/fixdfsi.s delete mode 100644 lib/libc/arch/hp300/gen/fixunsdfsi.S delete mode 100644 lib/libc/arch/hp300/gen/fixunsdfsi.s delete mode 100644 lib/libc/arch/hp300/gen/floatsidf.S delete mode 100644 lib/libc/arch/hp300/gen/floatsidf.s delete mode 100644 lib/libc/arch/hp300/gen/frexp.c delete mode 100644 lib/libc/arch/hp300/gen/infinity.c delete mode 100644 lib/libc/arch/hp300/gen/isinf.c delete mode 100644 lib/libc/arch/hp300/gen/ldexp.S delete mode 100644 lib/libc/arch/hp300/gen/ldexp.s delete mode 100644 lib/libc/arch/hp300/gen/lshlsi3.S delete mode 100644 lib/libc/arch/hp300/gen/lshlsi3.s delete mode 100644 lib/libc/arch/hp300/gen/lshrsi3.S delete mode 100644 lib/libc/arch/hp300/gen/lshrsi3.s delete mode 100644 lib/libc/arch/hp300/gen/modf.S delete mode 100644 lib/libc/arch/hp300/gen/modf.s delete mode 100644 lib/libc/arch/hp300/gen/modsi3.S delete mode 100644 lib/libc/arch/hp300/gen/modsi3.s delete mode 100644 lib/libc/arch/hp300/gen/muldf3.S delete mode 100644 lib/libc/arch/hp300/gen/muldf3.s delete mode 100644 lib/libc/arch/hp300/gen/mulsf3.S delete mode 100644 lib/libc/arch/hp300/gen/mulsf3.s delete mode 100644 lib/libc/arch/hp300/gen/mulsi3.S delete mode 100644 lib/libc/arch/hp300/gen/mulsi3.s delete mode 100644 lib/libc/arch/hp300/gen/negdf2.S delete mode 100644 lib/libc/arch/hp300/gen/negdf2.s delete mode 100644 lib/libc/arch/hp300/gen/negsf2.S delete mode 100644 lib/libc/arch/hp300/gen/negsf2.s delete mode 100644 lib/libc/arch/hp300/gen/saveregs.c delete mode 100644 lib/libc/arch/hp300/gen/setjmp.S delete mode 100644 lib/libc/arch/hp300/gen/setjmp.s delete mode 100644 lib/libc/arch/hp300/gen/subdf3.S delete mode 100644 lib/libc/arch/hp300/gen/subdf3.s delete mode 100644 lib/libc/arch/hp300/gen/subsf3.S delete mode 100644 lib/libc/arch/hp300/gen/subsf3.s delete mode 100644 lib/libc/arch/hp300/gen/truncdfsf2.S delete mode 100644 lib/libc/arch/hp300/gen/truncdfsf2.s delete mode 100644 lib/libc/arch/hp300/gen/udivsi3.S delete mode 100644 lib/libc/arch/hp300/gen/udivsi3.s delete mode 100644 lib/libc/arch/hp300/gen/umodsi3.S delete mode 100644 lib/libc/arch/hp300/gen/umodsi3.s delete mode 100644 lib/libc/arch/hp300/gen/umulsi3.S delete mode 100644 lib/libc/arch/hp300/gen/umulsi3.s delete mode 100644 lib/libc/arch/hp300/string/strcpy.S delete mode 100644 lib/libc/arch/hp300/string/strcpy.s delete mode 100644 lib/libc/arch/hp300/string/strlen.S delete mode 100644 lib/libc/arch/hp300/string/strlen.s delete mode 100644 lib/libc/arch/hp300/string/strncmp.S delete mode 100644 lib/libc/arch/hp300/string/strncmp.s delete mode 100644 lib/libc/arch/hp300/string/strncpy.S delete mode 100644 lib/libc/arch/hp300/string/strncpy.s delete mode 100644 lib/libc/arch/hp300/sys/reboot.S delete mode 100644 lib/libc/arch/hp300/sys/reboot.s delete mode 100644 lib/libc/arch/hp300/sys/sbrk.S delete mode 100644 lib/libc/arch/hp300/sys/sbrk.s delete mode 100644 lib/libc/arch/hp300/sys/setlogin.S delete mode 100644 lib/libc/arch/hp300/sys/setlogin.s delete mode 100644 lib/libc/arch/hp300/sys/sigpending.S delete mode 100644 lib/libc/arch/hp300/sys/sigpending.s delete mode 100644 lib/libc/arch/hp300/sys/sigprocmask.S delete mode 100644 lib/libc/arch/hp300/sys/sigprocmask.s delete mode 100644 lib/libc/arch/hp300/sys/sigreturn.S delete mode 100644 lib/libc/arch/hp300/sys/sigreturn.s delete mode 100644 lib/libc/arch/hp300/sys/sigsuspend.S delete mode 100644 lib/libc/arch/hp300/sys/sigsuspend.s delete mode 100644 lib/libc/arch/hp300/sys/syscall.S delete mode 100644 lib/libc/arch/hp300/sys/syscall.s delete mode 100644 lib/libc/arch/i386/gen/modf.s delete mode 100644 lib/libc/arch/i386/gen/setjmp.s delete mode 100644 lib/libc/arch/i386/gen/sigsetjmp.s delete mode 100644 lib/libc/arch/i386/gen/udivsi3.s delete mode 100644 lib/libc/arch/i386/string/memmove.s delete mode 100644 lib/libc/arch/i386/string/memset.s delete mode 100644 lib/libc/arch/i386/string/rindex.s delete mode 100644 lib/libc/arch/i386/string/strcat.s delete mode 100644 lib/libc/arch/i386/string/strchr.s delete mode 100644 lib/libc/arch/i386/string/strcmp.s delete mode 100644 lib/libc/arch/i386/string/strcpy.s delete mode 100644 lib/libc/arch/i386/string/strlen.s delete mode 100644 lib/libc/arch/i386/string/strncmp.s delete mode 100644 lib/libc/arch/i386/string/strrchr.s delete mode 100644 lib/libc/arch/i386/string/swab.s delete mode 100644 lib/libc/arch/i386/sys/reboot.s delete mode 100644 lib/libc/arch/i386/sys/sbrk.s delete mode 100644 lib/libc/arch/i386/sys/setlogin.s delete mode 100644 lib/libc/arch/i386/sys/sigpending.s delete mode 100644 lib/libc/arch/i386/sys/sigprocmask.s delete mode 100644 lib/libc/arch/i386/sys/sigreturn.s delete mode 100644 lib/libc/arch/i386/sys/sigsuspend.s delete mode 100644 lib/libc/arch/i386/sys/syscall.s delete mode 100644 lib/libc/arch/m68k/gen/cmpdf2.s delete mode 100644 lib/libc/arch/m68k/gen/cmpsf2.s delete mode 100644 lib/libc/arch/m68k/gen/divdf3.s delete mode 100644 lib/libc/arch/m68k/gen/divsf3.s delete mode 100644 lib/libc/arch/m68k/gen/divsi3.s delete mode 100644 lib/libc/arch/m68k/gen/extendsfdf2.s delete mode 100644 lib/libc/arch/m68k/gen/fabs.s delete mode 100644 lib/libc/arch/m68k/gen/fixdfsi.s delete mode 100644 lib/libc/arch/m68k/gen/fixunsdfsi.s delete mode 100644 lib/libc/arch/m68k/gen/floatsidf.s delete mode 100644 lib/libc/arch/m68k/gen/ldexp.s delete mode 100644 lib/libc/arch/m68k/gen/lshlsi3.s delete mode 100644 lib/libc/arch/m68k/gen/lshrsi3.s delete mode 100644 lib/libc/arch/m68k/gen/modf.s delete mode 100644 lib/libc/arch/m68k/gen/modsi3.s delete mode 100644 lib/libc/arch/m68k/gen/muldf3.s delete mode 100644 lib/libc/arch/m68k/gen/mulsf3.s delete mode 100644 lib/libc/arch/m68k/gen/mulsi3.s delete mode 100644 lib/libc/arch/m68k/gen/negdf2.s delete mode 100644 lib/libc/arch/m68k/gen/negsf2.s delete mode 100644 lib/libc/arch/m68k/gen/setjmp.s delete mode 100644 lib/libc/arch/m68k/gen/subdf3.s delete mode 100644 lib/libc/arch/m68k/gen/subsf3.s delete mode 100644 lib/libc/arch/m68k/gen/truncdfsf2.s delete mode 100644 lib/libc/arch/m68k/gen/udivsi3.s delete mode 100644 lib/libc/arch/m68k/gen/umodsi3.s delete mode 100644 lib/libc/arch/m68k/gen/umulsi3.s delete mode 100644 lib/libc/arch/m68k/string/strcpy.s delete mode 100644 lib/libc/arch/m68k/string/strlen.s delete mode 100644 lib/libc/arch/m68k/string/strncmp.s delete mode 100644 lib/libc/arch/m68k/string/strncpy.s delete mode 100644 lib/libc/arch/m68k/sys/reboot.s delete mode 100644 lib/libc/arch/m68k/sys/sbrk.s delete mode 100644 lib/libc/arch/m68k/sys/setlogin.s delete mode 100644 lib/libc/arch/m68k/sys/sigpending.s delete mode 100644 lib/libc/arch/m68k/sys/sigprocmask.s delete mode 100644 lib/libc/arch/m68k/sys/sigreturn.s delete mode 100644 lib/libc/arch/m68k/sys/sigsuspend.s delete mode 100644 lib/libc/arch/m68k/sys/syscall.s delete mode 100644 lib/libc/arch/mips/gen/_setjmp.s delete mode 100644 lib/libc/arch/mips/gen/fabs.s delete mode 100644 lib/libc/arch/mips/gen/isinf.s delete mode 100644 lib/libc/arch/mips/gen/ldexp.s delete mode 100644 lib/libc/arch/mips/gen/modf.s delete mode 100644 lib/libc/arch/mips/gen/setjmp.s delete mode 100644 lib/libc/arch/mips/net/htonl.s delete mode 100644 lib/libc/arch/mips/net/htons.s delete mode 100644 lib/libc/arch/mips/string/bcmp.s delete mode 100644 lib/libc/arch/mips/string/bcopy.s delete mode 100644 lib/libc/arch/mips/string/bzero.s delete mode 100644 lib/libc/arch/mips/string/ffs.s delete mode 100644 lib/libc/arch/mips/string/index.s delete mode 100644 lib/libc/arch/mips/string/rindex.s delete mode 100644 lib/libc/arch/mips/string/strcmp.s delete mode 100644 lib/libc/arch/mips/string/strlen.s delete mode 100644 lib/libc/arch/mips/sys/Ovfork.s delete mode 100644 lib/libc/arch/mips/sys/brk.s delete mode 100644 lib/libc/arch/mips/sys/cerror.s delete mode 100644 lib/libc/arch/mips/sys/exect.s delete mode 100644 lib/libc/arch/mips/sys/fork.s delete mode 100644 lib/libc/arch/mips/sys/pipe.s delete mode 100644 lib/libc/arch/mips/sys/ptrace.s delete mode 100644 lib/libc/arch/mips/sys/reboot.s delete mode 100644 lib/libc/arch/mips/sys/sbrk.s delete mode 100644 lib/libc/arch/mips/sys/setlogin.s delete mode 100644 lib/libc/arch/mips/sys/sigpending.s delete mode 100644 lib/libc/arch/mips/sys/sigprocmask.s delete mode 100644 lib/libc/arch/mips/sys/sigreturn.s delete mode 100644 lib/libc/arch/mips/sys/sigsuspend.s delete mode 100644 lib/libc/arch/mips/sys/syscall.s delete mode 100644 lib/libc/arch/ns32k/gen/_setjmp.s delete mode 100644 lib/libc/arch/ns32k/gen/alloca.s delete mode 100644 lib/libc/arch/ns32k/gen/fabs.s delete mode 100644 lib/libc/arch/ns32k/gen/frexp.s delete mode 100644 lib/libc/arch/ns32k/gen/ldexp.s delete mode 100644 lib/libc/arch/ns32k/gen/modf.s delete mode 100644 lib/libc/arch/ns32k/gen/setjmp.s delete mode 100644 lib/libc/arch/ns32k/net/ntoh.S delete mode 100644 lib/libc/arch/ns32k/net/ntoh.s delete mode 100644 lib/libc/arch/ns32k/stdlib/abs.s delete mode 100644 lib/libc/arch/ns32k/sys/Ovfork.s delete mode 100644 lib/libc/arch/ns32k/sys/brk.s delete mode 100644 lib/libc/arch/ns32k/sys/cerror.s delete mode 100644 lib/libc/arch/ns32k/sys/exect.s delete mode 100644 lib/libc/arch/ns32k/sys/fork.s delete mode 100644 lib/libc/arch/ns32k/sys/mount.s delete mode 100644 lib/libc/arch/ns32k/sys/pipe.s delete mode 100644 lib/libc/arch/ns32k/sys/ptrace.s delete mode 100644 lib/libc/arch/ns32k/sys/reboot.s delete mode 100644 lib/libc/arch/ns32k/sys/sbrk.s delete mode 100644 lib/libc/arch/ns32k/sys/setlogin.s delete mode 100644 lib/libc/arch/ns32k/sys/sigpending.s delete mode 100644 lib/libc/arch/ns32k/sys/sigprocmask.s delete mode 100644 lib/libc/arch/ns32k/sys/sigreturn.s delete mode 100644 lib/libc/arch/ns32k/sys/sigsuspend.s delete mode 100644 lib/libc/arch/ns32k/sys/syscall.s delete mode 100644 lib/libc/arch/pc532/gen/ldexp.S delete mode 100644 lib/libc/arch/pc532/gen/modf.S delete mode 100644 lib/libc/arch/pc532/gen/setjmp.S delete mode 100644 lib/libc/arch/pc532/sys/reboot.S delete mode 100644 lib/libc/arch/pc532/sys/reboot.s delete mode 100644 lib/libc/arch/pc532/sys/sbrk.S delete mode 100644 lib/libc/arch/pc532/sys/sbrk.s delete mode 100644 lib/libc/arch/pc532/sys/setlogin.S delete mode 100644 lib/libc/arch/pc532/sys/setlogin.s delete mode 100644 lib/libc/arch/pc532/sys/sigpending.S delete mode 100644 lib/libc/arch/pc532/sys/sigpending.s delete mode 100644 lib/libc/arch/pc532/sys/sigprocmask.S delete mode 100644 lib/libc/arch/pc532/sys/sigprocmask.s delete mode 100644 lib/libc/arch/pc532/sys/sigreturn.S delete mode 100644 lib/libc/arch/pc532/sys/sigreturn.s delete mode 100644 lib/libc/arch/pc532/sys/sigsuspend.S delete mode 100644 lib/libc/arch/pc532/sys/sigsuspend.s delete mode 100644 lib/libc/arch/pc532/sys/syscall.S delete mode 100644 lib/libc/arch/pc532/sys/syscall.s delete mode 100644 lib/libc/arch/sparc/gen/umul.s delete mode 100644 lib/libc/arch/sparc/sys/reboot.s delete mode 100644 lib/libc/arch/sparc/sys/sbrk.s delete mode 100644 lib/libc/arch/sparc/sys/setlogin.s delete mode 100644 lib/libc/arch/sparc/sys/sigpending.s delete mode 100644 lib/libc/arch/sparc/sys/sigprocmask.s delete mode 100644 lib/libc/arch/sparc/sys/sigreturn.s delete mode 100644 lib/libc/arch/sparc/sys/sigsuspend.s delete mode 100644 lib/libc/arch/sparc/sys/syscall.s delete mode 100644 lib/libc/compat-43/creat.2 delete mode 100644 lib/libc/compat-43/killpg.2 delete mode 100644 lib/libc/compat-43/setregid.2 delete mode 100644 lib/libc/compat-43/setreuid.2 delete mode 100644 lib/libc/compat-43/sigblock.2 delete mode 100644 lib/libc/compat-43/sigpause.2 delete mode 100644 lib/libc/compat-43/sigsetmask.2 delete mode 100644 lib/libc/compat-43/sigvec.2 delete mode 100644 lib/libc/db/btree/lrucache.c delete mode 100644 lib/libc/db/btree/lrucache.h delete mode 100644 lib/libc/db/btree/lruhash.c delete mode 100644 lib/libc/db/btree/lrutils.c delete mode 100644 lib/libc/db/btree/search.c delete mode 100644 lib/libc/db/btree/seq.c delete mode 100644 lib/libc/db/btree/split.c delete mode 100644 lib/libc/db/btree/storage.c delete mode 100644 lib/libc/db/btree/updutils.c delete mode 100644 lib/libc/db/btree/utils.c delete mode 100644 lib/libc/db/hash/hfunc.c delete mode 100644 lib/libc/db/hash/log2.c delete mode 100644 lib/libc/db/hash/page.c delete mode 100644 lib/libc/gen/regexp/regmagic.h delete mode 100644 lib/libc/gen/regexp/regsub.c delete mode 100644 lib/libc/gen/semget.c delete mode 100644 lib/libc/gen/semop.c delete mode 100644 lib/libc/gen/shmat.c delete mode 100644 lib/libc/gen/shmctl.c delete mode 100644 lib/libc/gen/shmdt.c delete mode 100644 lib/libc/gen/shmget.c delete mode 100644 lib/libc/hp300/gen/cmpdf2.s delete mode 100644 lib/libc/hp300/gen/cmpsf2.s delete mode 100644 lib/libc/hp300/gen/divdf3.s delete mode 100644 lib/libc/hp300/gen/divsf3.s delete mode 100644 lib/libc/hp300/gen/divsi3.s delete mode 100644 lib/libc/hp300/gen/extendsfdf2.s delete mode 100644 lib/libc/hp300/gen/fabs.s delete mode 100644 lib/libc/hp300/gen/fixdfsi.s delete mode 100644 lib/libc/hp300/gen/fixunsdfsi.s delete mode 100644 lib/libc/hp300/gen/floatsidf.s delete mode 100644 lib/libc/hp300/gen/frexp.c delete mode 100644 lib/libc/hp300/gen/infinity.c delete mode 100644 lib/libc/hp300/gen/isinf.c delete mode 100644 lib/libc/hp300/gen/ldexp.s delete mode 100644 lib/libc/hp300/gen/lshlsi3.s delete mode 100644 lib/libc/hp300/gen/lshrsi3.s delete mode 100644 lib/libc/hp300/gen/modf.s delete mode 100644 lib/libc/hp300/gen/modsi3.s delete mode 100644 lib/libc/hp300/gen/muldf3.s delete mode 100644 lib/libc/hp300/gen/mulsf3.s delete mode 100644 lib/libc/hp300/gen/mulsi3.s delete mode 100644 lib/libc/hp300/gen/negdf2.s delete mode 100644 lib/libc/hp300/gen/negsf2.s delete mode 100644 lib/libc/hp300/gen/saveregs.c delete mode 100644 lib/libc/hp300/gen/setjmp.s delete mode 100644 lib/libc/hp300/gen/subdf3.s delete mode 100644 lib/libc/hp300/gen/subsf3.s delete mode 100644 lib/libc/hp300/gen/truncdfsf2.s delete mode 100644 lib/libc/hp300/gen/udivsi3.s delete mode 100644 lib/libc/hp300/gen/umodsi3.s delete mode 100644 lib/libc/hp300/gen/umulsi3.s delete mode 100644 lib/libc/hp300/string/strcpy.s delete mode 100644 lib/libc/hp300/string/strlen.s delete mode 100644 lib/libc/hp300/string/strncmp.s delete mode 100644 lib/libc/hp300/string/strncpy.s delete mode 100644 lib/libc/i386/gen/frexp.c delete mode 100644 lib/libc/i386/gen/infinity.c delete mode 100644 lib/libc/i386/gen/isinf.c delete mode 100644 lib/libc/i386/gen/ldexp.c delete mode 100644 lib/libc/i386/gen/modf.s delete mode 100644 lib/libc/i386/gen/setjmp.s delete mode 100644 lib/libc/i386/gen/udivsi3.s delete mode 100644 lib/libc/i386/string/memmove.s delete mode 100644 lib/libc/i386/string/memset.s delete mode 100644 lib/libc/i386/string/rindex.s delete mode 100644 lib/libc/i386/string/strcat.s delete mode 100644 lib/libc/i386/string/strchr.s delete mode 100644 lib/libc/i386/string/strcmp.s delete mode 100644 lib/libc/i386/string/strcpy.s delete mode 100644 lib/libc/i386/string/strlen.s delete mode 100644 lib/libc/i386/string/strncmp.s delete mode 100644 lib/libc/i386/string/strrchr.s delete mode 100644 lib/libc/i386/string/swab.s delete mode 100644 lib/libc/i386/sys/reboot.s delete mode 100644 lib/libc/i386/sys/sbrk.s delete mode 100644 lib/libc/i386/sys/setlogin.s delete mode 100644 lib/libc/i386/sys/sigpending.s delete mode 100644 lib/libc/i386/sys/sigprocmask.s delete mode 100644 lib/libc/i386/sys/sigreturn.s delete mode 100644 lib/libc/i386/sys/sigsuspend.s delete mode 100644 lib/libc/i386/sys/syscall.s delete mode 100644 lib/libc/pc532/gen/ldexp.s delete mode 100644 lib/libc/pc532/gen/modf.s delete mode 100644 lib/libc/pc532/gen/setjmp.s delete mode 100644 lib/libc/pc532/sys/reboot.s delete mode 100644 lib/libc/pc532/sys/sbrk.s delete mode 100644 lib/libc/pc532/sys/setlogin.s delete mode 100644 lib/libc/pc532/sys/sigpending.s delete mode 100644 lib/libc/pc532/sys/sigprocmask.s delete mode 100644 lib/libc/pc532/sys/sigreturn.s delete mode 100644 lib/libc/pc532/sys/sigsuspend.s delete mode 100644 lib/libc/pc532/sys/syscall.s delete mode 100644 lib/libc/regex/regcomp.ih delete mode 100644 lib/libc/regex/regerror.ih delete mode 100644 lib/libc/regex/regex.h delete mode 100644 lib/libc/regex/split.c delete mode 100644 lib/libc/regex/tests delete mode 100644 lib/libc/sparc/gen/isnan.c delete mode 100644 lib/libc/sparc/gen/ldexp.c delete mode 100644 lib/libc/sparc/gen/modf.s delete mode 100644 lib/libc/sparc/gen/mul.s delete mode 100644 lib/libc/sparc/gen/saveregs.s delete mode 100644 lib/libc/sparc/gen/setjmp.s delete mode 100644 lib/libc/sparc/gen/umul.s delete mode 100644 lib/libc/sparc/sys/reboot.s delete mode 100644 lib/libc/sparc/sys/sbrk.s delete mode 100644 lib/libc/sparc/sys/setlogin.s delete mode 100644 lib/libc/sparc/sys/sigpending.s delete mode 100644 lib/libc/sparc/sys/sigprocmask.s delete mode 100644 lib/libc/sparc/sys/sigreturn.s delete mode 100644 lib/libc/sparc/sys/sigsuspend.s delete mode 100644 lib/libc/sparc/sys/syscall.s delete mode 100644 lib/libc/sys/uname.2 delete mode 100644 lib/libcompat/4.3/m68k/insque.s delete mode 100644 lib/libcompat/4.3/m68k/remque.s delete mode 100644 lib/libm/common_source/atan.c delete mode 100644 lib/libm/common_source/atan2.3 delete mode 100644 lib/libm/common_source/atanh.3 delete mode 100644 lib/libm/common_source/atanh.c delete mode 100644 lib/libm/common_source/ceil.3 delete mode 100644 lib/libm/common_source/cos.3 delete mode 100644 lib/libm/common_source/cosh.3 delete mode 100644 lib/libm/common_source/cosh.c delete mode 100644 lib/libm/common_source/erf.3 delete mode 100644 lib/libm/common_source/erf.c delete mode 100644 lib/libm/common_source/exp.3 delete mode 100644 lib/libm/common_source/exp.c delete mode 100644 lib/libm/common_source/exp__D.c delete mode 100644 lib/libm/common_source/exp__E.c delete mode 100644 lib/libm/common_source/expm1.c delete mode 100644 lib/libm/common_source/fabs.3 delete mode 100644 lib/libm/common_source/floor.3 delete mode 100644 lib/libm/common_source/floor.c delete mode 100644 lib/libm/common_source/fmod.3 delete mode 100644 lib/libm/common_source/fmod.c delete mode 100644 lib/libm/common_source/gamma.c delete mode 100644 lib/libm/common_source/hypot.3 delete mode 100644 lib/libm/common_source/ieee.3 delete mode 100644 lib/libm/common_source/infnan.3 delete mode 100644 lib/libm/common_source/j0.3 delete mode 100644 lib/libm/common_source/j0.c delete mode 100644 lib/libm/common_source/j1.c delete mode 100644 lib/libm/common_source/jn.c delete mode 100644 lib/libm/common_source/lgamma.3 delete mode 100644 lib/libm/common_source/lgamma.c delete mode 100644 lib/libm/common_source/log.c delete mode 100644 lib/libm/common_source/log.h delete mode 100644 lib/libm/common_source/log10.c delete mode 100644 lib/libm/common_source/log1p.c delete mode 100644 lib/libm/common_source/log__D.c delete mode 100644 lib/libm/common_source/log__L.c delete mode 100644 lib/libm/common_source/logtab.c delete mode 100644 lib/libm/common_source/math.3 delete mode 100644 lib/libm/common_source/mathimpl.h delete mode 100644 lib/libm/common_source/pow.c delete mode 100644 lib/libm/common_source/rint.3 delete mode 100644 lib/libm/common_source/sin.3 delete mode 100644 lib/libm/common_source/sinh.3 delete mode 100644 lib/libm/common_source/sinh.c delete mode 100644 lib/libm/common_source/sqrt.3 delete mode 100644 lib/libm/common_source/tan.3 delete mode 100644 lib/libm/common_source/tanh.3 delete mode 100644 lib/libm/common_source/tanh.c delete mode 100644 lib/libm/i387/exp.S delete mode 100644 lib/libm/i387/exp10.S delete mode 100644 lib/libm/i387/exp10.s delete mode 100644 lib/libm/i387/exp2.S delete mode 100644 lib/libm/i387/exp2.s delete mode 100644 lib/libm/i387/finite.S delete mode 100644 lib/libm/i387/finite.s delete mode 100644 lib/libm/i387/floor.S delete mode 100644 lib/libm/i387/floor.s delete mode 100644 lib/libm/i387/log.S delete mode 100644 lib/libm/i387/log.s delete mode 100644 lib/libm/i387/log10.S delete mode 100644 lib/libm/i387/log10.s delete mode 100644 lib/libm/i387/log1p.S delete mode 100644 lib/libm/i387/log1p.s delete mode 100644 lib/libm/i387/log2.S delete mode 100644 lib/libm/i387/log2.s delete mode 100644 lib/libm/i387/logb.S delete mode 100644 lib/libm/i387/logb.s delete mode 100644 lib/libm/i387/rint.S delete mode 100644 lib/libm/i387/rint.s delete mode 100644 lib/libm/i387/scalb.S delete mode 100644 lib/libm/i387/scalb.s delete mode 100644 lib/libm/i387/sin.S delete mode 100644 lib/libm/i387/sin.s delete mode 100644 lib/libm/i387/sqrt.S delete mode 100644 lib/libm/i387/sqrt.s delete mode 100644 lib/libm/i387/tan.S delete mode 100644 lib/libm/i387/tan.s delete mode 100644 lib/libm/mc68881/floor.S delete mode 100644 lib/libm/mc68881/log.S delete mode 100644 lib/libm/mc68881/log10.S delete mode 100644 lib/libm/mc68881/log10.s delete mode 100644 lib/libm/mc68881/log1p.S delete mode 100644 lib/libm/mc68881/log1p.s delete mode 100644 lib/libm/mc68881/mcount.sed delete mode 100644 lib/libm/mc68881/sincos.S delete mode 100644 lib/libm/mc68881/sincos.s delete mode 100644 lib/libm/mc68881/sinh.S delete mode 100644 lib/libm/mc68881/sinh.s delete mode 100644 lib/libm/mc68881/sqrt.S delete mode 100644 lib/libm/mc68881/sqrt.s delete mode 100644 lib/libm/mc68881/support.S delete mode 100644 lib/libm/mc68881/support.s delete mode 100644 lib/libm/mc68881/tan.S delete mode 100644 lib/libm/mc68881/tan.s delete mode 100644 lib/libm/mc68881/tanh.S delete mode 100644 lib/libm/mc68881/tanh.s delete mode 100644 lib/libm/vax/sqrt.S delete mode 100644 lib/libm/vax/support.S delete mode 100644 lib/libm/vax/support.s delete mode 100644 lib/libm/vax/tan.S delete mode 100644 lib/libm/vax/tan.s delete mode 100644 lib/librpc/rpc/bindresvport.c delete mode 100644 lib/librpc/rpc/clnt_generic.c delete mode 100644 lib/librpc/rpc/clnt_perror.c delete mode 100644 lib/librpc/rpc/clnt_raw.c delete mode 100644 lib/librpc/rpc/clnt_simple.c delete mode 100644 lib/librpc/rpc/clnt_tcp.c delete mode 100644 lib/librpc/rpc/clnt_udp.c delete mode 100644 lib/librpc/rpc/get_myaddress.c delete mode 100644 lib/librpc/rpc/getrpcent.c delete mode 100644 lib/librpc/rpc/getrpcport.c delete mode 100644 lib/librpc/rpc/pmap_clnt.c delete mode 100644 lib/librpc/rpc/pmap_getmaps.c delete mode 100644 lib/librpc/rpc/pmap_getport.c delete mode 100644 lib/librpc/rpc/pmap_prot.c delete mode 100644 lib/librpc/rpc/pmap_prot2.c delete mode 100644 lib/librpc/rpc/pmap_rmt.c delete mode 100644 lib/librpc/rpc/rpc.h delete mode 100644 lib/librpc/rpc/rpc_callmsg.c delete mode 100644 lib/librpc/rpc/rpc_commondata.c delete mode 100644 lib/librpc/rpc/rpc_dtablesize.c delete mode 100644 lib/librpc/rpc/rpc_msg.h delete mode 100644 lib/librpc/rpc/rpc_prot.c delete mode 100644 lib/librpc/rpc/svc.c delete mode 100644 lib/librpc/rpc/svc.h delete mode 100644 lib/librpc/rpc/svc_auth.c delete mode 100644 lib/librpc/rpc/svc_auth.h delete mode 100644 lib/librpc/rpc/svc_auth_unix.c delete mode 100644 lib/librpc/rpc/svc_raw.c delete mode 100644 lib/librpc/rpc/svc_run.c delete mode 100644 lib/librpc/rpc/svc_simple.c delete mode 100644 lib/librpc/rpc/svc_tcp.c delete mode 100644 lib/librpc/rpc/svc_udp.c delete mode 100644 lib/librpc/rpc/types.h delete mode 100644 lib/librpc/rpc/xdr.c delete mode 100644 lib/librpc/rpc/xdr.h delete mode 100644 lib/librpc/rpc/xdr_array.c delete mode 100644 lib/librpc/rpc/xdr_float.c delete mode 100644 lib/librpc/rpc/xdr_mem.c delete mode 100644 lib/librpc/rpc/xdr_rec.c delete mode 100644 lib/librpc/rpc/xdr_reference.c delete mode 100644 lib/librpc/rpc/xdr_stdio.c delete mode 100644 lib/librpcsvc/src/rex.x delete mode 100644 lib/librpcsvc/src/rnusers.x delete mode 100644 lib/librpcsvc/src/rquota.x delete mode 100644 lib/librpcsvc/src/rstat.x delete mode 100644 lib/librpcsvc/src/rusers.x delete mode 100644 lib/librpcsvc/src/rwall.x delete mode 100644 lib/librpcsvc/src/sm_inter.x delete mode 100644 lib/librpcsvc/src/spray.x delete mode 100644 lib/librpcsvc/src/yp.x delete mode 100644 lib/librpcsvc/src/yppasswd.x delete mode 100644 lib/libtelnet/krb_des.c delete mode 100644 lib/libutil/pwcache.c delete mode 100644 libexec/bootpd/Installation delete mode 100644 libexec/bootpd/Makefile delete mode 100644 libexec/bootpd/NewMake delete mode 100644 libexec/bootpd/Problems delete mode 100644 libexec/bootpd/README delete mode 100644 libexec/bootpd/bootp.h delete mode 100644 libexec/bootpd/bootpd.8 delete mode 100644 libexec/bootpd/bootpd.c delete mode 100644 libexec/bootpd/bootpd.h delete mode 100644 libexec/bootpd/bootpef.8 delete mode 100644 libexec/bootpd/bootpef.c delete mode 100644 libexec/bootpd/bootpgw.c delete mode 100644 libexec/bootpd/bootptab.5 delete mode 100644 libexec/bootpd/bootptab.cmu delete mode 100644 libexec/bootpd/bootptab.mcs delete mode 100644 libexec/bootpd/bootptest.8 delete mode 100644 libexec/bootpd/bootptest.c delete mode 100644 libexec/bootpd/bootptest.h delete mode 100644 libexec/bootpd/bptypes.h delete mode 100644 libexec/bootpd/dovend.c delete mode 100644 libexec/bootpd/dovend.h delete mode 100644 libexec/bootpd/dumptab.c delete mode 100644 libexec/bootpd/getether.c delete mode 100644 libexec/bootpd/getif.c delete mode 100644 libexec/bootpd/getif.h delete mode 100644 libexec/bootpd/hash.c delete mode 100644 libexec/bootpd/hash.h delete mode 100644 libexec/bootpd/hwaddr.c delete mode 100644 libexec/bootpd/hwaddr.h delete mode 100644 libexec/bootpd/lookup.c delete mode 100644 libexec/bootpd/lookup.h delete mode 100644 libexec/bootpd/patchlevel.h delete mode 100644 libexec/bootpd/print-bootp.c delete mode 100644 libexec/bootpd/readfile.c delete mode 100644 libexec/bootpd/readfile.h delete mode 100644 libexec/bootpd/report.c delete mode 100644 libexec/bootpd/report.h delete mode 100644 libexec/bootpd/syslog.conf delete mode 100644 libexec/bootpd/syslog.h delete mode 100644 libexec/bootpd/trygetea.c delete mode 100644 libexec/bootpd/trygetif.c delete mode 100644 libexec/bootpd/trylook.c delete mode 100644 libexec/bootpd/tzone.c delete mode 100644 libexec/bootpd/tzone.h delete mode 100644 libexec/bugfiler/gethead.c delete mode 100644 libexec/bugfiler/pathnames.h delete mode 100644 libexec/bugfiler/process.c delete mode 100644 libexec/bugfiler/redist.c delete mode 100644 libexec/bugfiler/reply.c delete mode 100644 libexec/bugfiler/sendbug.1 delete mode 100644 libexec/bugfiler/sendbug.sh delete mode 100644 libexec/cron/THANKS delete mode 100644 libexec/cron/crontab.1 delete mode 100644 libexec/cron/crontab.5 delete mode 100644 libexec/cron/crontab.c delete mode 100644 libexec/cron/database.c delete mode 100644 libexec/cron/do_command.c delete mode 100644 libexec/cron/entry.c delete mode 100644 libexec/cron/env.c delete mode 100644 libexec/cron/externs.h delete mode 100644 libexec/cron/job.c delete mode 100644 libexec/cron/misc.c delete mode 100644 libexec/cron/pathnames.h delete mode 100644 libexec/cron/popen.c delete mode 100644 libexec/cron/user.c delete mode 100644 libexec/crond/Makefile.vixie delete mode 100644 libexec/crond/README delete mode 100644 libexec/crond/THANKS delete mode 100644 libexec/crond/arpadate.c delete mode 100644 libexec/crond/config.h delete mode 100644 libexec/crond/cron.h delete mode 100644 libexec/crond/crond.8 delete mode 100644 libexec/crond/crond.c delete mode 100644 libexec/crond/database.c delete mode 100644 libexec/crond/do_command.c delete mode 100644 libexec/crond/entry.c delete mode 100644 libexec/crond/env.c delete mode 100644 libexec/crond/job.c delete mode 100644 libexec/crond/misc.c delete mode 100644 libexec/crond/user.c delete mode 100644 regress/lib/libc/db/hash.tests/tseq.c delete mode 100644 regress/lib/libc/db/hash.tests/tverify.c delete mode 100644 sbin/dump/rdump.8 delete mode 100644 sbin/mount_miscfs/Makefile delete mode 100644 sbin/mount_miscfs/mount_fdesc.8 delete mode 100644 sbin/mount_miscfs/mount_kernfs.8 delete mode 100644 sbin/mount_miscfs/mount_miscfs.c delete mode 100644 share/doc/ps1/04.pascal/comments.p delete mode 100644 share/doc/ps1/04.pascal/copydata.p delete mode 100644 share/doc/ps1/04.pascal/csfix.c delete mode 100644 share/doc/ps1/04.pascal/data delete mode 100644 share/doc/ps1/04.pascal/digits.p delete mode 100644 share/doc/ps1/04.pascal/expr.p delete mode 100644 share/doc/ps1/04.pascal/first.p delete mode 100644 share/doc/ps1/04.pascal/fixcomments delete mode 100644 share/doc/ps1/04.pascal/fixkatscript delete mode 100644 share/doc/ps1/04.pascal/kat.p delete mode 100644 share/doc/ps1/04.pascal/kat2.p delete mode 100644 share/doc/ps1/04.pascal/kat3.p delete mode 100644 share/doc/ps1/04.pascal/katin delete mode 100644 share/doc/ps1/04.pascal/mism.p delete mode 100644 share/doc/ps1/04.pascal/primes.p delete mode 100644 share/doc/ps1/04.pascal/primes2.p delete mode 100644 share/doc/ps1/04.pascal/puman0.n delete mode 100644 share/doc/ps1/04.pascal/puman1.n delete mode 100644 share/doc/ps1/04.pascal/puman2.n delete mode 100644 share/doc/ps1/04.pascal/puman3.n delete mode 100644 share/doc/ps1/04.pascal/puman4.n delete mode 100644 share/doc/ps1/04.pascal/puman5.n delete mode 100644 share/doc/ps1/04.pascal/pumanA.n delete mode 100644 share/doc/ps1/04.pascal/sin1.p delete mode 100644 share/doc/ps1/04.pascal/sin2.p delete mode 100644 share/doc/ps1/04.pascal/synerr.p delete mode 100644 share/doc/ps1/04.pascal/synerr2.p delete mode 100644 share/doc/ps1/04.pascal/tmac.p delete mode 100644 share/doc/ps1/04.pascal/typequ.p delete mode 100644 share/doc/ps1/06.sysman/2.1.t delete mode 100644 share/doc/ps1/06.sysman/2.2.t delete mode 100644 share/doc/ps1/06.sysman/2.3.t delete mode 100644 share/doc/ps1/06.sysman/2.4.t delete mode 100644 share/doc/ps1/06.sysman/2.5.t delete mode 100644 share/doc/ps1/06.sysman/Makefile delete mode 100644 share/doc/ps1/06.sysman/a.t delete mode 100644 share/doc/ps1/06.sysman/spell.ok delete mode 100644 share/doc/ps1/07.ipctut/pipe.grn delete mode 100644 share/doc/ps1/07.ipctut/socketpair.c delete mode 100644 share/doc/ps1/07.ipctut/socketpair.grn delete mode 100644 share/doc/ps1/07.ipctut/strchkread.c delete mode 100644 share/doc/ps1/07.ipctut/streamread.c delete mode 100644 share/doc/ps1/07.ipctut/streamwrite.c delete mode 100644 share/doc/ps1/07.ipctut/tutor.me delete mode 100644 share/doc/ps1/07.ipctut/udgramread.c delete mode 100644 share/doc/ps1/07.ipctut/udgramsend.c delete mode 100644 share/doc/ps1/07.ipctut/ustreamread.c delete mode 100644 share/doc/ps1/07.ipctut/ustreamwrite.c delete mode 100644 share/doc/ps1/13.rcs/man/rcsintro.1 delete mode 100644 share/doc/ps1/13.rcs/man/rcsmerge.1 delete mode 100644 share/doc/ps1/13.rcs/man/rlog.1 delete mode 100644 share/doc/ps1/13.rcs/man/sccstorcs.1 delete mode 100644 share/doc/ps1/18.curses/doc.III delete mode 100644 share/doc/ps1/18.curses/doc.IV delete mode 100644 share/doc/ps1/18.curses/intro.0 delete mode 100644 share/doc/ps1/18.curses/intro.1 delete mode 100644 share/doc/ps1/18.curses/intro.2 delete mode 100644 share/doc/ps1/18.curses/intro.3 delete mode 100644 share/doc/ps1/18.curses/intro.4 delete mode 100644 share/doc/ps1/18.curses/intro.5 delete mode 100644 share/doc/ps1/18.curses/life.c delete mode 100644 share/doc/ps1/18.curses/macros delete mode 100644 share/doc/ps1/18.curses/twinkle1.c delete mode 100644 share/doc/ps1/18.curses/twinkle2.c delete mode 100644 share/doc/ps1/18.curses/win_st.c delete mode 100644 share/doc/smm/02.config/spell.ok delete mode 100644 share/doc/smm/11.named/manage.me delete mode 100644 share/doc/smm/11.named/named.boot.cache delete mode 100644 share/doc/smm/11.named/named.boot.primary delete mode 100644 share/doc/smm/11.named/named.boot.secondary delete mode 100644 share/doc/smm/11.named/named.local delete mode 100644 share/doc/smm/11.named/resolv.conf delete mode 100644 share/doc/smm/11.named/root.cache delete mode 100644 share/doc/smm/11.named/setup.me delete mode 100644 share/doc/smm/11.named/spell.ok delete mode 100644 share/doc/smm/11.named/types.me delete mode 100644 share/doc/smm/11.named/ucbhosts delete mode 100644 share/doc/smm/11.named/ucbhosts.rev delete mode 100644 share/doc/smm/15.net/d.t delete mode 100644 share/doc/smm/15.net/e.t delete mode 100644 share/doc/smm/15.net/f.t delete mode 100644 share/doc/smm/15.net/spell.ok delete mode 100644 share/doc/usd/07.Mail/mail6.nr delete mode 100644 share/doc/usd/07.Mail/mail7.nr delete mode 100644 share/doc/usd/07.Mail/mail8.nr delete mode 100644 share/doc/usd/07.Mail/mail9.nr delete mode 100644 share/doc/usd/07.Mail/maila.nr delete mode 100644 share/doc/usd/11.notes/4.7 delete mode 100644 share/doc/usd/11.notes/5 delete mode 100644 share/doc/usd/11.notes/Makefile delete mode 100644 share/doc/usd/11.notes/a.checklist delete mode 100644 share/doc/usd/11.notes/acks delete mode 100644 share/doc/usd/11.notes/b.interface delete mode 100644 share/doc/usd/11.notes/c.changes delete mode 100644 share/doc/usd/11.notes/macros delete mode 100644 share/doc/usd/11.notes/vtoc delete mode 100644 sys/arch/amiga/README.CHOPPS-CONSOLE2 delete mode 100644 sys/arch/amiga/README.scsi delete mode 100644 sys/arch/amiga/README.st delete mode 100644 sys/arch/amiga/amiga/cc_blitter.h delete mode 100644 sys/arch/amiga/amiga/cc_chipmem.c delete mode 100644 sys/arch/amiga/amiga/cc_chipmem.h delete mode 100644 sys/arch/amiga/amiga/cc_copper.c delete mode 100644 sys/arch/amiga/amiga/cc_copper.h delete mode 100644 sys/arch/amiga/amiga/cc_types.h delete mode 100644 sys/arch/amiga/amiga/cc_vbl.c delete mode 100644 sys/arch/amiga/amiga/cc_vbl.h delete mode 100644 sys/arch/amiga/amiga/pte.h delete mode 100644 sys/arch/amiga/compile/AMIGA/ioconf.c delete mode 100644 sys/arch/amiga/compile/AMIGA/ite.X delete mode 100644 sys/arch/amiga/compile/AMIGA/ite.h delete mode 100644 sys/arch/amiga/compile/AMIGA/loop.h delete mode 100644 sys/arch/amiga/compile/AMIGA/param.c delete mode 100644 sys/arch/amiga/compile/AMIGA/ppp.h delete mode 100644 sys/arch/amiga/compile/AMIGA/pty.h delete mode 100644 sys/arch/amiga/compile/AMIGA/scsi.h delete mode 100644 sys/arch/amiga/compile/AMIGA/sd.h delete mode 100644 sys/arch/amiga/compile/AMIGA/ser.h delete mode 100644 sys/arch/amiga/compile/AMIGA/sl.h delete mode 100644 sys/arch/amiga/compile/AMIGA/st.h delete mode 100644 sys/arch/amiga/compile/AMIGA/swappager.h delete mode 100644 sys/arch/amiga/compile/AMIGA/swapvmunix.c delete mode 100644 sys/arch/amiga/compile/AMIGA/tb.h delete mode 100644 sys/arch/amiga/compile/AMIGA/tun.h delete mode 100644 sys/arch/amiga/compile/AMIGA/vers.c delete mode 100644 sys/arch/amiga/compile/AMIGA/version delete mode 100644 sys/arch/amiga/compile/AMIGA/vn.h delete mode 100644 sys/arch/amiga/compile/AMIGA/vnodepager.h delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_cc_h_mode.c delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_cc_hdl_mode.c delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_cc_hl_mode.c delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_cc_mode.c delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_cc_pal_a2024_mode.c delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_cc_ph_mode.c delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_cc_phdl_mode.c delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_cc_phl_mode.c delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_cc_priv.h delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_cc_view.c delete mode 100644 sys/arch/amiga/dev/grf/grf_cc/grf_ccc.c delete mode 100644 sys/arch/amiga/dev/grf/grf_monitor.c delete mode 100644 sys/arch/amiga/dev/grf/grf_monitor.h delete mode 100644 sys/arch/amiga/dev/grf/grf_types.h delete mode 100644 sys/arch/amiga/dev/grf/grf_view.c delete mode 100644 sys/arch/amiga/dev/grf/grf_view.h delete mode 100644 sys/arch/amiga/dev/grf/grfcc.c delete mode 100644 sys/arch/amiga/dev/grf_tg.c delete mode 100644 sys/arch/amiga/dev/gvp11dma.c delete mode 100644 sys/arch/amiga/dev/gvp11dmareg.h delete mode 100644 sys/arch/amiga/dev/ite_tg.c delete mode 100644 sys/arch/amiga/dev/ivsdma.c delete mode 100644 sys/arch/amiga/dev/magnumdma.c delete mode 100644 sys/arch/amiga/dev/mlhdma.c delete mode 100644 sys/arch/amiga/dev/retina-mondefs.c delete mode 100644 sys/arch/amiga/dev/retina-monitors delete mode 100644 sys/arch/amiga/dev/rtclocka.c delete mode 100644 sys/arch/amiga/dev/rtclocka_var.h delete mode 100644 sys/arch/amiga/dev/rtclockb.c delete mode 100644 sys/arch/amiga/dev/rtclockb_var.h delete mode 100644 sys/arch/amiga/dev/scsi.c delete mode 100644 sys/arch/amiga/dev/scsireg.h delete mode 100644 sys/arch/amiga/dev/scsivar.h delete mode 100644 sys/arch/amiga/dev/supradma.c delete mode 100644 sys/arch/amiga/dev/zeusdma.c delete mode 100644 sys/arch/amiga/fpsp/README delete mode 100644 sys/arch/amiga/fpsp/README.source delete mode 100644 sys/arch/amiga/fpsp/README_FIRST delete mode 100644 sys/arch/amiga/fpsp/fpsp.o.uu delete mode 100644 sys/arch/amiga/fpsp/fpspnull.s delete mode 100644 sys/arch/amiga/sunos/sun_exec_aout.c delete mode 100644 sys/arch/amiga/sunos/sun_ioctl.c delete mode 100644 sys/arch/amiga/sunos/sun_misc.c delete mode 100644 sys/arch/amiga/sunos/sun_syscall.h delete mode 100644 sys/arch/amiga/sunos/sun_syscalls.c delete mode 100644 sys/arch/amiga/sunos/sun_sysent.c delete mode 100644 sys/arch/amiga/sunos/syscalls.master delete mode 100644 sys/arch/hp300/hpux/hpux_sig.c delete mode 100644 sys/arch/hp300/hpux/hpux_syscall.h delete mode 100644 sys/arch/hp300/hpux/hpux_syscalls.c delete mode 100644 sys/arch/hp300/hpux/hpux_sysent.c delete mode 100644 sys/arch/hp300/hpux/hpux_termio.h delete mode 100644 sys/arch/hp300/hpux/hpux_tty.c delete mode 100644 sys/arch/hp300/hpux/makesyscalls.sh delete mode 100644 sys/arch/hp300/hpux/syscalls.master delete mode 100644 sys/arch/i386/conf/GENERICAHB delete mode 100644 sys/arch/i386/conf/GENERICISA delete mode 100644 sys/arch/i386/conf/SMALL delete mode 100644 sys/arch/i386/conf/SUMNER delete mode 100644 sys/arch/i386/isa/comreg.h delete mode 100644 sys/arch/i386/isa/cy.c delete mode 100644 sys/arch/i386/isa/elink.c delete mode 100644 sys/arch/i386/isa/elink.h delete mode 100644 sys/arch/i386/isa/ic/ns16550.h delete mode 100644 sys/arch/i386/isa/if_ed.c delete mode 100644 sys/arch/i386/isa/if_edreg.h delete mode 100644 sys/arch/i386/isa/if_eg.c delete mode 100644 sys/arch/i386/isa/if_egreg.h delete mode 100644 sys/arch/i386/isa/if_el.c delete mode 100644 sys/arch/i386/isa/if_elreg.h delete mode 100644 sys/arch/i386/isa/if_ep.c delete mode 100644 sys/arch/i386/isa/if_epreg.h delete mode 100644 sys/arch/i386/isa/if_hp.c delete mode 100644 sys/arch/i386/isa/if_ie.c delete mode 100644 sys/arch/i386/isa/if_ie507.h delete mode 100644 sys/arch/i386/isa/if_ieatt.h delete mode 100644 sys/arch/i386/isa/if_le.c delete mode 100644 sys/arch/i386/isa/if_lereg.h delete mode 100644 sys/arch/i386/isa/lpt.c delete mode 100644 sys/arch/i386/isa/lptreg.h delete mode 100644 sys/arch/i386/isa/mcd.c delete mode 100644 sys/arch/i386/isa/mcdreg.h delete mode 100644 sys/arch/i386/isa/rtfps.c delete mode 100644 sys/arch/i386/isa/seagate.c delete mode 100644 sys/arch/i386/isa/ultra14f.c delete mode 100644 sys/arch/i386/isa/wd.c delete mode 100644 sys/arch/i386/isa/wd7000.c delete mode 100644 sys/arch/i386/isa/wdreg.h delete mode 100644 sys/arch/i386/isa/wt.c delete mode 100644 sys/arch/i386/isa/wtreg.h delete mode 100644 sys/arch/i386/stand/wdboot.x delete mode 100644 sys/arch/mac68k/conf/AAAA delete mode 100644 sys/arch/mac68k/conf/ALBASIC delete mode 100644 sys/arch/mac68k/conf/BASIC delete mode 100644 sys/arch/mac68k/conf/GENERIC.mac delete mode 100644 sys/arch/mac68k/conf/LINT.mac delete mode 100644 sys/arch/mac68k/conf/devices.mac delete mode 100644 sys/arch/mac68k/conf/files.mac delete mode 100644 sys/arch/mac68k/dev/scc_8530.h delete mode 100644 sys/arch/mac68k/dev/scc_8530_hdw.c delete mode 100644 sys/arch/mac68k/include/nubus.h delete mode 100644 sys/arch/mac68k/mac68k/symbols.raw delete mode 100644 sys/arch/mac68k/scsi/README delete mode 100644 sys/arch/mac68k/scsi/README.AHA1742 delete mode 100644 sys/arch/mac68k/scsi/scsi_debug.h delete mode 100644 sys/arch/mac68k/scsi/scsi_disk.h delete mode 100644 sys/arch/mac68k/scsi/scsi_generic.h delete mode 100644 sys/arch/mac68k/scsi/scsi_ioctl.c delete mode 100644 sys/arch/mac68k/scsi/scsi_tape.h delete mode 100644 sys/arch/mac68k/scsi/scsiconf.c delete mode 100644 sys/arch/mac68k/scsi/scsiconf.h delete mode 100644 sys/arch/mac68k/scsi/sd.c delete mode 100644 sys/arch/mac68k/scsi/sg.c delete mode 100644 sys/arch/mac68k/scsi/st.c delete mode 100644 sys/arch/mac68k/scsi/su.c delete mode 100644 sys/arch/mac68k/scsi/uk.c delete mode 100644 sys/arch/pc532/scsi/scsi_debug.h delete mode 100644 sys/arch/pc532/scsi/scsi_disk.h delete mode 100644 sys/arch/pc532/scsi/scsi_tape.h delete mode 100644 sys/arch/pc532/scsi/scsiconf.c delete mode 100644 sys/arch/pc532/scsi/scsiconf.h delete mode 100644 sys/arch/pc532/scsi/sd.c delete mode 100644 sys/arch/pc532/scsi/sddefs.h delete mode 100644 sys/arch/pc532/scsi/st.c delete mode 100644 sys/arch/pc532/scsi/stdefs.h delete mode 100644 sys/arch/pmax/conf/AMSTEL delete mode 100644 sys/arch/pmax/conf/ECSTASY delete mode 100644 sys/arch/pmax/conf/GENERIC.3100 delete mode 100644 sys/arch/pmax/conf/GENERIC.5000 delete mode 100644 sys/arch/pmax/conf/MAXINE delete mode 100644 sys/arch/pmax/conf/MAXP delete mode 100644 sys/arch/pmax/dist/get1 delete mode 100644 sys/arch/pmax/pmax/Locore.c delete mode 100644 sys/arch/pmax/pmax/locore.s.sav delete mode 100644 sys/arch/pmax/pmax/trap.c.sav delete mode 100644 sys/arch/pmax/pmax/trap.c.sav2 delete mode 100644 sys/arch/pmax/test/Makefile delete mode 100644 sys/arch/pmax/test/coff.c delete mode 100644 sys/arch/pmax/test/fp.c delete mode 100644 sys/arch/pmax/test/fp1.c delete mode 100644 sys/arch/pmax/test/fp2.c delete mode 100644 sys/arch/pmax/test/fp2_out delete mode 100644 sys/arch/pmax/test/fp2_t delete mode 100644 sys/arch/pmax/test/fp3.c delete mode 100644 sys/arch/pmax/test/fp3_out delete mode 100644 sys/arch/pmax/test/fp3_t delete mode 100644 sys/arch/pmax/test/fp4.c delete mode 100644 sys/arch/pmax/test/fp4_out delete mode 100644 sys/arch/pmax/test/fp4_t delete mode 100644 sys/arch/pmax/test/fp5.c delete mode 100644 sys/arch/pmax/test/fp6.c delete mode 100644 sys/arch/pmax/test/fp6_out delete mode 100644 sys/arch/pmax/test/fp6_t delete mode 100644 sys/arch/pmax/test/fp7.c delete mode 100644 sys/arch/pmax/test/fp7_t delete mode 100644 sys/arch/pmax/test/fp8.c delete mode 100644 sys/arch/pmax/test/fp8_t delete mode 100644 sys/arch/pmax/test/fp_t delete mode 100644 sys/arch/pmax/test/fptest.c delete mode 100644 sys/arch/pmax/test/fptest1.s delete mode 100644 sys/arch/pmax/test/sum.c delete mode 100644 sys/arch/pmax/test/t01.c delete mode 100644 sys/arch/pmax/test/t02.c delete mode 100644 sys/arch/pmax/test/t03.c delete mode 100644 sys/arch/pmax/test/t04.c delete mode 100644 sys/arch/pmax/test/t05.c delete mode 100644 sys/arch/pmax/test/t05.s delete mode 100644 sys/arch/pmax/test/t06.c delete mode 100644 sys/arch/pmax/test/t07.c delete mode 100644 sys/arch/pmax/test/tdisk.sh delete mode 100644 sys/arch/pmax/ultrix/ultrix_sysent.c delete mode 100644 sys/arch/sparc/conf/std.sparc delete mode 100644 sys/arch/sparc/conf/std.sun4 delete mode 100644 sys/arch/sparc/conf/std.sun4c delete mode 100644 sys/arch/sparc/sbus/cgsixreg.h delete mode 100644 sys/arch/sparc/sbus/cgthree.c delete mode 100644 sys/arch/sparc/sbus/cgthreereg.h delete mode 100644 sys/arch/sparc/sbus/dmareg.h delete mode 100644 sys/arch/sparc/sbus/esp.c delete mode 100644 sys/arch/sparc/sbus/espreg.h delete mode 100644 sys/arch/sparc/sbus/if_le.c delete mode 100644 sys/arch/sparc/sbus/if_lereg.h delete mode 100644 sys/arch/sparc/sbus/sbus.c delete mode 100644 sys/arch/sparc/sbus/sbusreg.h delete mode 100644 sys/arch/sparc/sbus/sbusvar.h delete mode 100644 sys/arch/sparc/scsi/scsi_subr.c delete mode 100644 sys/arch/sparc/scsi/scsivar.h delete mode 100644 sys/arch/sparc/scsi/sd.c delete mode 100644 sys/arch/sparc/scsi/sdtrace.h delete mode 100644 sys/arch/sparc/scsi/sun_disklabel.c delete mode 100644 sys/arch/sparc/scsi/sun_disklabel.h delete mode 100644 sys/arch/sparc/scsi/tape.h delete mode 100644 sys/arch/sparc/sunos/sun_syscall.h delete mode 100644 sys/arch/sparc/sunos/sun_syscalls.c delete mode 100644 sys/arch/sparc/sunos/sun_sysent.c delete mode 100644 sys/arch/sparc/sunos/syscalls.master delete mode 100644 sys/boot/bootparam.c delete mode 100644 sys/boot/exec.c delete mode 100644 sys/boot/exec_var.h delete mode 100644 sys/boot/in_cksum.c delete mode 100644 sys/boot/net.c delete mode 100644 sys/boot/netboot.h delete mode 100644 sys/boot/netif.c delete mode 100644 sys/boot/netif.h delete mode 100644 sys/boot/nfsboot.c delete mode 100644 sys/boot/rpc.c delete mode 100644 sys/boot/util.c delete mode 100644 sys/compat/sunos/sun_syscall.h delete mode 100644 sys/compat/sunos/sun_syscalls.c delete mode 100644 sys/compat/sunos/sun_sysent.c delete mode 100644 sys/isofs/isofs_node.h delete mode 100644 sys/isofs/isofs_rrip.c delete mode 100644 sys/isofs/isofs_rrip.h delete mode 100644 sys/isofs/isofs_util.c delete mode 100644 sys/isofs/isofs_vfsops.c delete mode 100644 sys/isofs/isofs_vnops.c delete mode 100644 sys/lib/libkern/arch/i386/bcmp.s delete mode 100644 sys/lib/libkern/arch/i386/bzero.s delete mode 100644 sys/lib/libkern/arch/i386/ffs.s delete mode 100644 sys/lib/libkern/arch/i386/htonl.s delete mode 100644 sys/lib/libkern/arch/i386/htons.s delete mode 100644 sys/lib/libkern/arch/i386/ntohl.s delete mode 100644 sys/lib/libkern/arch/i386/ntohs.s delete mode 100644 sys/lib/libkern/arch/i386/setjmp.s delete mode 100644 sys/lib/libkern/arch/i386/strcat.s delete mode 100644 sys/lib/libkern/arch/i386/strcmp.s delete mode 100644 sys/lib/libkern/arch/i386/strcpy.s delete mode 100644 sys/lib/libkern/arch/i386/strlen.s delete mode 100644 sys/lib/libkern/arch/m68k/locc.s delete mode 100644 sys/lib/libkern/arch/m68k/scanc.s delete mode 100644 sys/lib/libkern/arch/m68k/skpc.s delete mode 100644 sys/lib/libkern/i386/locc.S delete mode 100644 sys/lib/libkern/i386/ntohl.S delete mode 100644 sys/lib/libkern/i386/ntohs.S delete mode 100644 sys/lib/libkern/i386/scanc.S delete mode 100644 sys/lib/libkern/i386/setjmp.S delete mode 100644 sys/lib/libkern/i386/skpc.S delete mode 100644 sys/lib/libkern/i386/strcat.S delete mode 100644 sys/lib/libkern/i386/strcat.s delete mode 100644 sys/lib/libkern/i386/strcmp.S delete mode 100644 sys/lib/libkern/i386/strcmp.s delete mode 100644 sys/lib/libkern/i386/strcpy.S delete mode 100644 sys/lib/libkern/i386/strcpy.s delete mode 100644 sys/lib/libkern/i386/strlen.S delete mode 100644 sys/lib/libkern/i386/strlen.s delete mode 100644 sys/lib/libkern/m68k/locc.S delete mode 100644 sys/lib/libkern/m68k/ntohl.S delete mode 100644 sys/lib/libkern/m68k/ntohs.S delete mode 100644 sys/lib/libkern/m68k/scanc.S delete mode 100644 sys/lib/libkern/m68k/skpc.S delete mode 100644 sys/lib/libkern/m68k/strcmp.S delete mode 100644 sys/lib/libkern/m68k/strcpy.S delete mode 100644 sys/lib/libkern/m68k/strlen.S delete mode 100644 sys/lib/libkern/m68k/strncmp.S delete mode 100644 sys/lib/libkern/m68k/strncpy.S delete mode 100644 sys/lib/libkern/ns32k/setjmp.S delete mode 100644 sys/libkern/scanc.c delete mode 100644 sys/libkern/skpc.c delete mode 100644 sys/libkern/ulmax.c delete mode 100644 sys/libkern/ulmin.c delete mode 100644 sys/pcfs/pcfs_denode.c delete mode 100644 sys/pcfs/pcfs_fat.c delete mode 100644 sys/pcfs/pcfs_lookup.c delete mode 100644 sys/pcfs/pcfs_vfsops.c delete mode 100644 sys/pcfs/pcfs_vnops.c delete mode 100644 sys/pcfs/pcfsmount.h delete mode 100644 sys/ufs/mfsnode.h delete mode 100644 sys/ufs/quota.h delete mode 100644 sys/ufs/ufs_alloc.c delete mode 100644 sys/ufs/ufs_lookup.c delete mode 100644 sys/ufs/ufs_quota.c delete mode 100644 sys/ufs/ufs_subr.c delete mode 100644 sys/ufs/ufs_tables.c delete mode 100644 sys/ufs/ufs_vfsops.c delete mode 100644 sys/ufs/ufs_vtab.c delete mode 100644 sys/ufs/ufsmount.h delete mode 100644 usr.bin/elvis/ctype.h delete mode 100644 usr.bin/elvis/curses.c delete mode 100644 usr.bin/elvis/curses.h delete mode 100644 usr.bin/elvis/cut.c delete mode 100644 usr.bin/elvis/doc/elvis.man delete mode 100644 usr.bin/elvis/doc/elvprsv.man delete mode 100644 usr.bin/elvis/doc/elvrec.man delete mode 100644 usr.bin/elvis/doc/environ.ms delete mode 100644 usr.bin/elvis/doc/ex.ms delete mode 100644 usr.bin/elvis/doc/fmt.man delete mode 100644 usr.bin/elvis/doc/index.ms delete mode 100644 usr.bin/elvis/doc/internal.ms delete mode 100644 usr.bin/elvis/doc/intro.ms delete mode 100644 usr.bin/elvis/doc/makefile.ms delete mode 100644 usr.bin/elvis/doc/options.ms delete mode 100644 usr.bin/elvis/doc/question.ms delete mode 100644 usr.bin/elvis/doc/ref.man delete mode 100644 usr.bin/elvis/doc/regexp.ms delete mode 100644 usr.bin/elvis/doc/termcap.ms delete mode 100644 usr.bin/elvis/doc/title.ms delete mode 100644 usr.bin/elvis/doc/ver.ms delete mode 100644 usr.bin/elvis/doc/versions.ms delete mode 100644 usr.bin/elvis/doc/visual.ms delete mode 100644 usr.bin/elvis/elvis.1 delete mode 100644 usr.bin/elvis/ex.c delete mode 100644 usr.bin/elvis/input.c delete mode 100644 usr.bin/elvis/main.c delete mode 100644 usr.bin/elvis/misc.c delete mode 100644 usr.bin/elvis/modify.c delete mode 100644 usr.bin/elvis/move1.c delete mode 100644 usr.bin/elvis/move2.c delete mode 100644 usr.bin/elvis/move3.c delete mode 100644 usr.bin/elvis/move4.c delete mode 100644 usr.bin/elvis/move5.c delete mode 100644 usr.bin/elvis/opts.c delete mode 100644 usr.bin/elvis/prsvunix.c delete mode 100644 usr.bin/elvis/recycle.c delete mode 100644 usr.bin/elvis/redraw.c delete mode 100644 usr.bin/elvis/regexp.c delete mode 100644 usr.bin/elvis/regexp.h delete mode 100644 usr.bin/elvis/regsub.c delete mode 100644 usr.bin/elvis/system.c delete mode 100644 usr.bin/elvis/tio.c delete mode 100644 usr.bin/elvis/tmp.c delete mode 100644 usr.bin/elvis/unix.c delete mode 100644 usr.bin/elvis/vars.c delete mode 100644 usr.bin/elvis/vcmd.c delete mode 100644 usr.bin/elvis/vi.c delete mode 100644 usr.bin/elvis/vi.h delete mode 100644 usr.bin/file/magdir/vax.byteswap delete mode 100644 usr.bin/lex/lex.1 delete mode 100644 usr.bin/lex/lex.skel delete mode 100644 usr.bin/lex/lib/ln.order delete mode 100644 usr.bin/lex/lib/shlib_version delete mode 100644 usr.bin/rcs/man/Makefile delete mode 100644 usr.bin/rcs/man/ci.1 delete mode 100644 usr.bin/rcs/man/co.1 delete mode 100644 usr.bin/rcs/man/ident.1 delete mode 100644 usr.bin/rcs/man/merge.1 delete mode 100644 usr.bin/rcs/man/rcs.1 delete mode 100644 usr.bin/rcs/man/rcsclean.1 delete mode 100644 usr.bin/rcs/man/rcsdiff.1 delete mode 100644 usr.bin/rcs/man/rcsfile.5 delete mode 100644 usr.bin/rcs/man/rcsfreeze.1 delete mode 100644 usr.bin/rcs/man/rcsintro.1 delete mode 100644 usr.bin/rcs/man/rcsmerge.1 delete mode 100644 usr.bin/rcs/man/rlog.1 delete mode 100644 usr.bin/rcs/man/sccstorcs.1 delete mode 100644 usr.bin/rcs/src/maketime.c delete mode 100644 usr.bin/rcs/src/merge.sh delete mode 100644 usr.bin/rcs/src/partime.c delete mode 100644 usr.bin/rcs/src/rcs.c delete mode 100644 usr.bin/rcs/src/rcsbase.h delete mode 100644 usr.bin/rcs/src/rcsclean.c delete mode 100644 usr.bin/rcs/src/rcsclean.sh delete mode 100644 usr.bin/rcs/src/rcsdiff.c delete mode 100644 usr.bin/rcs/src/rcsedit.c delete mode 100644 usr.bin/rcs/src/rcsfcmp.c delete mode 100644 usr.bin/rcs/src/rcsfnms.c delete mode 100644 usr.bin/rcs/src/rcsfreeze.sh delete mode 100644 usr.bin/rcs/src/rcsgen.c delete mode 100644 usr.bin/rcs/src/rcskeep.c delete mode 100644 usr.bin/rcs/src/rcskeys.c delete mode 100644 usr.bin/rcs/src/rcslex.c delete mode 100644 usr.bin/rcs/src/rcsmerge.c delete mode 100644 usr.bin/rcs/src/rcsrev.c delete mode 100644 usr.bin/rcs/src/rcssyn.c delete mode 100644 usr.bin/rcs/src/rcsutil.c delete mode 100644 usr.bin/rcs/src/rlog.c delete mode 100644 usr.bin/rcs/src/sccstorcs.c delete mode 100644 usr.bin/rcs/src/snoop.c delete mode 100644 usr.bin/rcs/src/time.h delete mode 100644 usr.bin/sed/Makefile.bsd delete mode 100644 usr.bin/sed/getopt.h delete mode 100644 usr.bin/sed/getopt1.c delete mode 100644 usr.bin/sed/regex.c delete mode 100644 usr.bin/sed/regex.h delete mode 100644 usr.bin/sed/sed.c delete mode 100644 usr.bin/sed/utils.c delete mode 100644 usr.bin/vi/docs/structures delete mode 100644 usr.bin/vi/docs/vi.ref.ps delete mode 100644 usr.bin/vi/docs/vi.ref.txt delete mode 100644 usr.bin/vi/line.c delete mode 100644 usr.bin/vi/log.c delete mode 100644 usr.bin/vi/log.h delete mode 100644 usr.bin/vi/main.c delete mode 100644 usr.bin/vi/mark.c delete mode 100644 usr.bin/vi/mark.h delete mode 100644 usr.bin/vi/mem.h delete mode 100644 usr.bin/vi/msg.h delete mode 100644 usr.bin/vi/options.c delete mode 100644 usr.bin/vi/options.h.stub delete mode 100644 usr.bin/vi/options_f.c delete mode 100644 usr.bin/vi/pathnames.h delete mode 100644 usr.bin/vi/put.c delete mode 100644 usr.bin/vi/recover.c delete mode 100644 usr.bin/vi/screen.c delete mode 100644 usr.bin/vi/screen.h delete mode 100644 usr.bin/vi/search.c delete mode 100644 usr.bin/vi/search.h delete mode 100644 usr.bin/vi/seq.c delete mode 100644 usr.bin/vi/seq.h delete mode 100644 usr.bin/vi/term.c delete mode 100644 usr.bin/vi/term.h delete mode 100644 usr.bin/vi/timer.c delete mode 100644 usr.bin/vi/trace.c delete mode 100644 usr.bin/vi/util.c delete mode 100644 usr.bin/vi/vi.h delete mode 100644 usr.bin/vi/vi/v_tag.c delete mode 100644 usr.sbin/amd/doc/amdref.vrs delete mode 100644 usr.sbin/cron/CHANGES delete mode 100644 usr.sbin/cron/CONVERSION delete mode 100644 usr.sbin/cron/FEATURES delete mode 100644 usr.sbin/cron/INSTALL delete mode 100644 usr.sbin/cron/MAIL delete mode 100644 usr.sbin/cron/MANIFEST delete mode 100644 usr.sbin/cron/README delete mode 100644 usr.sbin/cron/THANKS delete mode 100644 usr.sbin/cron/bitstring.3 delete mode 100644 usr.sbin/cron/bitstring.h delete mode 100644 usr.sbin/cron/putman.sh delete mode 100644 usr.sbin/sendmail/cf/cf/cchem.cf delete mode 100644 usr.sbin/sendmail/cf/cf/cchem.mc delete mode 100644 usr.sbin/sendmail/cf/cf/cogsci.cf delete mode 100644 usr.sbin/sendmail/cf/cf/hpux-cs-exposed.mc delete mode 100644 usr.sbin/sendmail/cf/cf/hpux-cs-hidden.mc delete mode 100644 usr.sbin/sendmail/cf/cf/ic.cf delete mode 100644 usr.sbin/sendmail/cf/cf/ic.mc delete mode 100644 usr.sbin/sendmail/cf/cf/id.cf delete mode 100644 usr.sbin/sendmail/cf/cf/id.mc delete mode 100644 usr.sbin/sendmail/cf/cf/kappa.cf delete mode 100644 usr.sbin/sendmail/cf/cf/knecht.mc delete mode 100644 usr.sbin/sendmail/cf/cf/lamprey.cf delete mode 100644 usr.sbin/sendmail/cf/cf/mail.cs.mc delete mode 100644 usr.sbin/sendmail/cf/cf/mail.eecs.mc delete mode 100644 usr.sbin/sendmail/cf/cf/okeeffe.cf delete mode 100644 usr.sbin/sendmail/cf/cf/okeeffe.mc delete mode 100644 usr.sbin/sendmail/cf/cf/osf1-cs-exposed.mc delete mode 100644 usr.sbin/sendmail/cf/cf/osf1-cs-hidden.mc delete mode 100644 usr.sbin/sendmail/cf/cf/proto.mc delete mode 100644 usr.sbin/sendmail/cf/cf/riscos-cs-exposed.mc delete mode 100644 usr.sbin/sendmail/cf/cf/s2k.mc delete mode 100644 usr.sbin/sendmail/cf/cf/sunos3.5-cs-exposed.mc delete mode 100644 usr.sbin/sendmail/cf/cf/sunos3.5-cs-hidden.mc delete mode 100644 usr.sbin/sendmail/cf/cf/sunos4.1-cs-exposed.mc delete mode 100644 usr.sbin/sendmail/cf/cf/sunos4.1-cs-hidden.mc delete mode 100644 usr.sbin/sendmail/cf/cf/tcpproto.cf delete mode 100644 usr.sbin/sendmail/cf/cf/tcpuucpproto.cf delete mode 100644 usr.sbin/sendmail/cf/cf/tcpuucpproto.mc delete mode 100644 usr.sbin/sendmail/cf/cf/telemuse.cf delete mode 100644 usr.sbin/sendmail/cf/cf/ucbarpa.cf delete mode 100644 usr.sbin/sendmail/cf/cf/ucbtcp.cf delete mode 100644 usr.sbin/sendmail/cf/cf/ucbtcp.mc delete mode 100644 usr.sbin/sendmail/cf/cf/ucbvax.cf delete mode 100644 usr.sbin/sendmail/cf/cf/udb.mc delete mode 100644 usr.sbin/sendmail/cf/cf/uid.cf delete mode 100644 usr.sbin/sendmail/cf/cf/uid.mc delete mode 100644 usr.sbin/sendmail/cf/cf/ultrix4.1-cs-exposed.mc delete mode 100644 usr.sbin/sendmail/cf/cf/ultrix4.1-cs-hidden.mc delete mode 100644 usr.sbin/sendmail/cf/cf/uucpproto.cf delete mode 100644 usr.sbin/sendmail/cf/m4/nsmacros.m4 delete mode 100644 usr.sbin/sendmail/cf/m4/nstcpldm.m4 delete mode 100644 usr.sbin/sendmail/cf/m4/nstcpm.m4 delete mode 100644 usr.sbin/sendmail/cf/m4/postwriterule.m4 delete mode 100644 usr.sbin/sendmail/cf/m4/prewriterule.m4 delete mode 100644 usr.sbin/sendmail/cf/m4/rule0.m4 delete mode 100644 usr.sbin/sendmail/cf/m4/rule3.m4 delete mode 100644 usr.sbin/sendmail/cf/m4/rule5.m4 delete mode 100644 usr.sbin/sendmail/cf/m4/smtpuucpm.m4 delete mode 100644 usr.sbin/sendmail/cf/m4/suucpm.m4 delete mode 100644 usr.sbin/sendmail/cf/m4/uucpm.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/hpux.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/irix.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/linux.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/nextstep.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/osf1.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/riscos4.5.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/solaris2.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/sunos3.5.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/sunos4.1.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/svr4.m4 delete mode 100644 usr.sbin/sendmail/cf/ostype/ultrix4.1.m4 delete mode 100644 usr.sbin/sendmail/cf/sitedep/uucp.cad.m4 delete mode 100644 usr.sbin/sendmail/cf/sitedep/uucp.cogsci.m4 delete mode 100644 usr.sbin/sendmail/cf/sitedep/uucp.ic.m4 delete mode 100644 usr.sbin/sendmail/cf/sitedep/uucp.id.m4 delete mode 100644 usr.sbin/sendmail/cf/sitedep/uucp.okeeffe.m4 delete mode 100644 usr.sbin/sendmail/cf/sitedep/uucp.proto.m4 delete mode 100644 usr.sbin/sendmail/cf/sitedep/uucp.ucbarpa.m4 delete mode 100644 usr.sbin/sendmail/cf/sitedep/uucp.ucbvax.m4 delete mode 100644 usr.sbin/sendmail/doc/usenix.me delete mode 100644 usr.sbin/sendmail/src/Makefile.BSDI delete mode 100644 usr.sbin/sendmail/src/Makefile.ConvexOS delete mode 100644 usr.sbin/sendmail/src/Makefile.Dell delete mode 100644 usr.sbin/sendmail/src/Makefile.HP-UX delete mode 100644 usr.sbin/sendmail/src/Makefile.IRIX delete mode 100644 usr.sbin/sendmail/src/Makefile.Linux delete mode 100644 usr.sbin/sendmail/src/Makefile.NeXT delete mode 100644 usr.sbin/sendmail/src/Makefile.OSF1 delete mode 100644 usr.sbin/sendmail/src/Makefile.Solaris delete mode 100644 usr.sbin/sendmail/src/Makefile.SunOS delete mode 100644 usr.sbin/sendmail/src/Makefile.ULTRIX delete mode 100644 usr.sbin/sendmail/src/Makefile.UMAX delete mode 100644 usr.sbin/sendmail/src/Makefile.Utah delete mode 100644 usr.sbin/sendmail/src/Makefile.dist delete mode 100644 usr.sbin/sup/source/local_server.tar.UU delete mode 100644 usr.sbin/sup/source/sup.doc diff --git a/bin/ed/test/e3.ed b/bin/ed/test/e3.ed deleted file mode 100644 index 204f386c6b51..000000000000 --- a/bin/ed/test/e3.ed +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \e3.d -E -w \e3.o -EOT diff --git a/bin/ed/test/e3.o b/bin/ed/test/e3.o deleted file mode 100644 index aa44630d22a6..000000000000 --- a/bin/ed/test/e3.o +++ /dev/null @@ -1 +0,0 @@ -E !echo hello world- diff --git a/bin/ed/test/g1.ed b/bin/ed/test/g1.ed deleted file mode 100644 index 47287f5f1bf8..000000000000 --- a/bin/ed/test/g1.ed +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \g1.d -g/./m0 -g/./s/$/\ -hello world -g/hello /s/lo/p!/\ -a\ -order -w \g1.o -EOT diff --git a/bin/ed/test/g1.o b/bin/ed/test/g1.o deleted file mode 100644 index 578a44b6b21c..000000000000 --- a/bin/ed/test/g1.o +++ /dev/null @@ -1,15 +0,0 @@ -line5 -help! world -order -line 4 -help! world -order -line 3 -help! world -order -line 2 -help! world -order -line 1 -help! world -order diff --git a/bin/ed/test/g2.ed b/bin/ed/test/g2.ed deleted file mode 100644 index 8041f8e0d9b7..000000000000 --- a/bin/ed/test/g2.ed +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \g2.d -g/[2-4]/-1,+1c\ -hello world -w \g2.o -EOT diff --git a/bin/ed/test/g2.o b/bin/ed/test/g2.o deleted file mode 100644 index 3b18e512dba7..000000000000 --- a/bin/ed/test/g2.o +++ /dev/null @@ -1 +0,0 @@ -hello world diff --git a/bin/ed/test/i.ed b/bin/ed/test/i.ed deleted file mode 100644 index 36720a794892..000000000000 --- a/bin/ed/test/i.ed +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \i.d -1i -hello world -. -2i -hello world! -. -$i -hello world!! -. -w \i.o -EOT diff --git a/bin/ed/test/i.o b/bin/ed/test/i.o deleted file mode 100644 index 5f27af09c03d..000000000000 --- a/bin/ed/test/i.o +++ /dev/null @@ -1,8 +0,0 @@ -hello world -hello world! -line 1 -line 2 -line 3 -line 4 -hello world!! -line5 diff --git a/bin/ed/test/j.ed b/bin/ed/test/j.ed deleted file mode 100644 index 6b7448d7e233..000000000000 --- a/bin/ed/test/j.ed +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \j.d -1,1j -2,3j -w \j.o -EOT diff --git a/bin/ed/test/j.o b/bin/ed/test/j.o deleted file mode 100644 index 66f36a8f8ab5..000000000000 --- a/bin/ed/test/j.o +++ /dev/null @@ -1,4 +0,0 @@ -line 1 -line 2line 3 -line 4 -line5 diff --git a/bin/ed/test/l.ed b/bin/ed/test/l.ed deleted file mode 100644 index d18e135739ae..000000000000 --- a/bin/ed/test/l.ed +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \l.d -w \l.o -EOT diff --git a/bin/ed/test/l.o b/bin/ed/test/l.o deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/bin/ed/test/m.ed b/bin/ed/test/m.ed deleted file mode 100644 index d93aa5238421..000000000000 --- a/bin/ed/test/m.ed +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \m.d -1,2m$ -1,2m$ -1,2m$ -$m0 -$m0 -2,3m1 -2,3m3 -w \m.o -EOT diff --git a/bin/ed/test/m.o b/bin/ed/test/m.o deleted file mode 100644 index 186cf5403b9f..000000000000 --- a/bin/ed/test/m.o +++ /dev/null @@ -1,5 +0,0 @@ -line5 -line 1 -line 2 -line 3 -line 4 diff --git a/bin/ed/test/n.ed b/bin/ed/test/n.ed deleted file mode 100644 index b7377afa273a..000000000000 --- a/bin/ed/test/n.ed +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \n.d -w \n.o -EOT diff --git a/bin/ed/test/n.o b/bin/ed/test/n.o deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/bin/ed/test/nl.r b/bin/ed/test/nl.r deleted file mode 100644 index c90847633217..000000000000 --- a/bin/ed/test/nl.r +++ /dev/null @@ -1,8 +0,0 @@ -line 1 -line 2 -line 3 - - -hello world -line 4 -line5 diff --git a/bin/ed/test/nl.t b/bin/ed/test/nl.t deleted file mode 100644 index e0398ad61029..000000000000 --- a/bin/ed/test/nl.t +++ /dev/null @@ -1,8 +0,0 @@ -1 - - -a - - -hello world -. diff --git a/bin/ed/test/p.ed b/bin/ed/test/p.ed deleted file mode 100644 index e4e0ac5240f3..000000000000 --- a/bin/ed/test/p.ed +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \p.d -w \p.o -EOT diff --git a/bin/ed/test/p.o b/bin/ed/test/p.o deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/bin/ed/test/r1.ed b/bin/ed/test/r1.ed deleted file mode 100644 index ba8b4e1ed628..000000000000 --- a/bin/ed/test/r1.ed +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \r1.d -1;r !echo hello world -1 -r !echo hello world -w \r1.o -EOT diff --git a/bin/ed/test/r1.o b/bin/ed/test/r1.o deleted file mode 100644 index a3ff506ec7c2..000000000000 --- a/bin/ed/test/r1.o +++ /dev/null @@ -1,7 +0,0 @@ -line 1 -hello world -line 2 -line 3 -line 4 -line5 -hello world diff --git a/bin/ed/test/r2.ed b/bin/ed/test/r2.ed deleted file mode 100644 index d024867de454..000000000000 --- a/bin/ed/test/r2.ed +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \r2.d -r -w \r2.o -EOT diff --git a/bin/ed/test/r2.o b/bin/ed/test/r2.o deleted file mode 100644 index ac152ba9d0a2..000000000000 --- a/bin/ed/test/r2.o +++ /dev/null @@ -1,10 +0,0 @@ -line 1 -line 2 -line 3 -line 4 -line5 -line 1 -line 2 -line 3 -line 4 -line5 diff --git a/bin/ed/test/r3.ed b/bin/ed/test/r3.ed deleted file mode 100644 index 2e087305abaf..000000000000 --- a/bin/ed/test/r3.ed +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \r3.d -r r3.t -w \r3.o -EOT diff --git a/bin/ed/test/r3.o b/bin/ed/test/r3.o deleted file mode 100644 index 86d5f904fc11..000000000000 --- a/bin/ed/test/r3.o +++ /dev/null @@ -1,2 +0,0 @@ -r r3.t -r r3.t diff --git a/bin/ed/test/s1.ed b/bin/ed/test/s1.ed deleted file mode 100644 index 64fc1a7d58fd..000000000000 --- a/bin/ed/test/s1.ed +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \s1.d -s/\([^ ][^ ]*\)/(\1)/g -2s -/3/s -/\(4\)/sr -/\(.\)/srg -%s/i/&e/ -w \s1.o -EOT diff --git a/bin/ed/test/s1.o b/bin/ed/test/s1.o deleted file mode 100644 index 4eb0980cfe79..000000000000 --- a/bin/ed/test/s1.o +++ /dev/null @@ -1,5 +0,0 @@ -liene 1 -(liene) (2) -(liene) (3) -liene (4) -(()liene5) diff --git a/bin/ed/test/s2.ed b/bin/ed/test/s2.ed deleted file mode 100644 index ce40958b97b1..000000000000 --- a/bin/ed/test/s2.ed +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \s2.d -,s/./(&)/3 -s/$/00 -2s//%/g -s/^l -w \s2.o -EOT diff --git a/bin/ed/test/s2.o b/bin/ed/test/s2.o deleted file mode 100644 index ca305c8d506a..000000000000 --- a/bin/ed/test/s2.o +++ /dev/null @@ -1,5 +0,0 @@ -li(n)e 1 -i(n)e 200 -li(n)e 3 -li(n)e 4 -li(n)e500 diff --git a/bin/ed/test/t.ed b/bin/ed/test/t.ed deleted file mode 100644 index 00c410063f5e..000000000000 --- a/bin/ed/test/t.ed +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \t.d -1t1 -2,3t2 -,t$ -w \t.o -EOT diff --git a/bin/ed/test/t.o b/bin/ed/test/t.o deleted file mode 100644 index 2b2854758d5d..000000000000 --- a/bin/ed/test/t.o +++ /dev/null @@ -1,16 +0,0 @@ -line 1 -line 1 -line 1 -line 2 -line 2 -line 3 -line 4 -line5 -line 1 -line 1 -line 1 -line 2 -line 2 -line 3 -line 4 -line5 diff --git a/bin/ed/test/t.t b/bin/ed/test/t.t deleted file mode 100644 index fcb1368bc293..000000000000 --- a/bin/ed/test/t.t +++ /dev/null @@ -1,3 +0,0 @@ -1t1 -2,3t2 -,t$ diff --git a/bin/ed/test/u.ed b/bin/ed/test/u.ed deleted file mode 100644 index 0a1dabb59202..000000000000 --- a/bin/ed/test/u.ed +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \u.d -1;r u.t -u -a -hello -world -. -g/./s//x/\ -a\ -hello\ -world -u -u -u -a -hello world! -. -u -1,$d -u -2,3d -u -c -hello world!! -. -u -u --1;.,+1j -u -u -u -.,+1t$ -w \u.o -EOT diff --git a/bin/ed/test/u.o b/bin/ed/test/u.o deleted file mode 100644 index ad558d82d02d..000000000000 --- a/bin/ed/test/u.o +++ /dev/null @@ -1,9 +0,0 @@ -line 1 -hello -hello world!! -line 2 -line 3 -line 4 -line5 -hello -hello world!! diff --git a/bin/ed/test/v.ed b/bin/ed/test/v.ed deleted file mode 100644 index fc1217d0808a..000000000000 --- a/bin/ed/test/v.ed +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \v.d -v/[ ]/m0 -v/[ ]/s/$/\ -hello world -v/hello /s/lo/p!/\ -a\ -order -w \v.o -EOT diff --git a/bin/ed/test/v.o b/bin/ed/test/v.o deleted file mode 100644 index 714db63e357b..000000000000 --- a/bin/ed/test/v.o +++ /dev/null @@ -1,11 +0,0 @@ -line5 -order -hello world -line 1 -order -line 2 -order -line 3 -order -line 4 -order diff --git a/bin/ed/test/w.ed b/bin/ed/test/w.ed deleted file mode 100644 index 9361d2d392a3..000000000000 --- a/bin/ed/test/w.ed +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -../ed - <<\EOT -r \w.d -w !cat >\!.z -r \!.z -w \w.o -EOT diff --git a/bin/ed/test/w.o b/bin/ed/test/w.o deleted file mode 100644 index ac152ba9d0a2..000000000000 --- a/bin/ed/test/w.o +++ /dev/null @@ -1,10 +0,0 @@ -line 1 -line 2 -line 3 -line 4 -line5 -line 1 -line 2 -line 3 -line 4 -line5 diff --git a/bin/expr/TODO b/bin/expr/TODO deleted file mode 100644 index 23fc96d477d9..000000000000 --- a/bin/expr/TODO +++ /dev/null @@ -1,2 +0,0 @@ -parenthesis are broken -not well tested, may have other obscure flaws diff --git a/gnu/games/chess/Xchess/bishop_mask.bitmap b/gnu/games/chess/Xchess/bishop_mask.bitmap deleted file mode 100644 index ca17bb3dae0d..000000000000 --- a/gnu/games/chess/Xchess/bishop_mask.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define bishop_mask_width 80 -#define bishop_mask_height 80 -static char bishop_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0xdf, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, - 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, 0x1f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, 0x1f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, - 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x3f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfe, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, - 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, - 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, - 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, - 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, - 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, - 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, - 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, - 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, - 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xfc, 0x3f, 0xfc, 0xff, 0xe3, 0xff, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x01, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0x01, - 0x00, 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0x01, 0x00, 0xe0, - 0xff, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0x1f, 0xf8, - 0x1f, 0xe0, 0xff, 0x80, 0xff, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/bishop_outline.bitmap b/gnu/games/chess/Xchess/bishop_outline.bitmap deleted file mode 100644 index 9772328c2984..000000000000 --- a/gnu/games/chess/Xchess/bishop_outline.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define bishop_outline_width 80 -#define bishop_outline_height 80 -static char bishop_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8d, - 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x88, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8d, 0x0d, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x0f, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x98, - 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x70, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x40, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0xc0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x22, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x66, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x05, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x01, 0x05, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0xe0, 0x3d, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x20, - 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xe0, 0x3d, 0x50, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x05, 0x70, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x20, 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x20, 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, - 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, - 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x05, 0x40, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xc0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x30, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x07, - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x8d, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x8d, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0x02, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, - 0x0c, 0x85, 0xc1, 0xff, 0x01, 0x00, 0x00, 0x00, 0x0e, 0xf0, 0x87, 0x0d, - 0x7f, 0x00, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x08, 0x00, 0x00, - 0x3c, 0x00, 0x00, 0x70, 0x00, 0x00, 0xe0, 0x18, 0x00, 0x00, 0xe0, 0x00, - 0x00, 0xc0, 0xf8, 0x1f, 0x38, 0x70, 0xc0, 0xff, 0x31, 0x00, 0x00, 0x80, - 0x0f, 0xf0, 0x0f, 0xc0, 0x7f, 0x00, 0x1f, 0x00, 0x00, 0xc0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/bishop_small.bitmap b/gnu/games/chess/Xchess/bishop_small.bitmap deleted file mode 100644 index 5525ecd03c2d..000000000000 --- a/gnu/games/chess/Xchess/bishop_small.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define bishop_small_width 32 -#define bishop_small_height 32 -static char bishop_small_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x70, 0x1c, 0x00, - 0x00, 0x70, 0x1c, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x60, 0x16, 0x00, - 0x00, 0x60, 0x22, 0x00, 0x00, 0xf0, 0x23, 0x00, 0x00, 0xf0, 0x21, 0x00, - 0x00, 0xf8, 0x21, 0x00, 0x00, 0xf8, 0x23, 0x00, 0x00, 0xf8, 0x23, 0x00, - 0x00, 0xf8, 0x27, 0x00, 0x00, 0x38, 0x27, 0x00, 0x00, 0x3c, 0x2f, 0x00, - 0x00, 0x0c, 0x2c, 0x00, 0x00, 0x0e, 0x3c, 0x00, 0x00, 0x3e, 0x3f, 0x00, - 0x00, 0x3e, 0x3f, 0x00, 0x00, 0x3e, 0x3f, 0x00, 0x00, 0x3e, 0x3f, 0x00, - 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, - 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, - 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0xe0, 0xff, 0xff, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/bishop_small_outline.bitmap b/gnu/games/chess/Xchess/bishop_small_outline.bitmap deleted file mode 100644 index 8d29a812e29e..000000000000 --- a/gnu/games/chess/Xchess/bishop_small_outline.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define bishop_small_outline_width 32 -#define bishop_small_outline_height 32 -static char bishop_small_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x50, 0x14, 0x00, - 0x00, 0x70, 0x1c, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x60, 0x16, 0x00, - 0x00, 0x60, 0x22, 0x00, 0x00, 0xf0, 0x23, 0x00, 0x00, 0x10, 0x21, 0x00, - 0x00, 0x18, 0x21, 0x00, 0x00, 0x08, 0x23, 0x00, 0x00, 0x08, 0x22, 0x00, - 0x00, 0x08, 0x26, 0x00, 0x00, 0x08, 0x24, 0x00, 0x00, 0xcc, 0x2c, 0x00, - 0x00, 0xc4, 0x28, 0x00, 0x00, 0xf6, 0x3b, 0x00, 0x00, 0xf2, 0x23, 0x00, - 0x00, 0xc2, 0x20, 0x00, 0x00, 0xc2, 0x20, 0x00, 0x00, 0xc2, 0x20, 0x00, - 0x00, 0xc2, 0x60, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, - 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, - 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0xe0, 0xff, 0xff, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/board.c b/gnu/games/chess/Xchess/board.c deleted file mode 100644 index e35430c3041c..000000000000 --- a/gnu/games/chess/Xchess/board.c +++ /dev/null @@ -1,180 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: board.c,v 1.2 1993/08/02 17:20:46 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Stuff to deal with the board. - */ - -#include "xchess.h" - -board *chessboard; - -void -board_setup() -{ - chessboard = alloc(board); - board_init(chessboard); - return; -} - -void -board_init(b) - board *b; -{ - int i, j; - - for (i = 0; i < 2; i++) - for (j = 0; j < SIZE; j++) - b->square[i][j].color = BLACK; - for (i = 2; i < 6; i++) - for (j = 0; j < SIZE; j++) - b->square[i][j].color = NONE; - for (i = 6; i < 8; i++) - for (j = 0; j < SIZE; j++) - b->square[i][j].color = WHITE; - for (i = 0; i < SIZE; i++) - b->square[1][i].type = b->square[6][i].type = - PAWN; - b->square[0][0].type = b->square[7][0].type = ROOK; - b->square[0][1].type = b->square[7][1].type = KNIGHT; - b->square[0][2].type = b->square[7][2].type = BISHOP; - b->square[0][3].type = b->square[7][3].type = QUEEN; - b->square[0][4].type = b->square[7][4].type = KING; - b->square[0][5].type = b->square[7][5].type = BISHOP; - b->square[0][6].type = b->square[7][6].type = KNIGHT; - b->square[0][7].type = b->square[7][7].type = ROOK; - b->black_cant_castle_k = false; - b->black_cant_castle_q = false; - b->white_cant_castle_k = false; - b->white_cant_castle_q = false; - - return; -} - -void -board_drawall() -{ - int i, j; - - for (i = 0; i < SIZE; i++) - for (j = 0; j < SIZE; j++) - if (chessboard->square[i][j].color != NONE) { - win_drawpiece(&chessboard->square[i][j], i, - j, WHITE); - if (!oneboard) - win_drawpiece(&chessboard->square[i][j], - i, j, BLACK); - } - return; -} - -void -board_move(b, m) - board *b; - move *m; -{ - switch (m->type) { - - case MOVE: - case CAPTURE: - b->square[m->fromy][m->fromx].color = NONE; - b->square[m->toy][m->tox].color = m->piece.color; - b->square[m->toy][m->tox].type = m->piece.type; - if ((m->piece.type == PAWN) && (((m->piece.color == BLACK) && - (m->toy == 7)) || ((m->piece.color == WHITE) && - (m->toy == 0)))) - b->square[m->toy][m->tox].type = QUEEN; - if (m->enpassant) - b->square[m->toy + ((m->piece.color == WHITE) ? 1 : - -1)][m->tox].color = NONE; - break; - - case KCASTLE: - if (m->piece.color == WHITE) { - b->square[7][5].color = m->piece.color; - b->square[7][5].type = ROOK; - b->square[7][6].color = m->piece.color; - b->square[7][6].type = KING; - b->square[7][4].color = NONE; - b->square[7][7].color = NONE; - } else { - b->square[0][5].color = m->piece.color; - b->square[0][5].type = ROOK; - b->square[0][6].color = m->piece.color; - b->square[0][6].type = KING; - b->square[0][4].color = NONE; - b->square[0][7].color = NONE; - } - break; - - case QCASTLE: - if (m->piece.color == WHITE) { - b->square[7][3].color = m->piece.color; - b->square[7][3].type = ROOK; - b->square[7][2].color = m->piece.color; - b->square[7][2].type = KING; - b->square[7][4].color = NONE; - b->square[7][0].color = NONE; - } else { - b->square[0][3].color = m->piece.color; - b->square[0][3].type = ROOK; - b->square[0][2].color = m->piece.color; - b->square[0][2].type = KING; - b->square[0][4].color = NONE; - b->square[0][0].color = NONE; - } - break; - - default: - fprintf(stderr, "Bad move type %d\n", m->type); - } - - if (m->piece.type == KING) { - if (m->piece.color == WHITE) - b->white_cant_castle_q = - b->white_cant_castle_k= true; - else - b->black_cant_castle_q = - b->black_cant_castle_k= true; - } else if (m->piece.type == ROOK) { - if (m->piece.color == WHITE) { - if (m->fromx == 0) - b->white_cant_castle_q = true; - else if (m->fromx == 7) - b->white_cant_castle_k = true; - } else { - if (m->fromx == 0) - b->black_cant_castle_q = true; - else if (m->fromx == 7) - b->black_cant_castle_k = true; - } - } - - return; -} - diff --git a/gnu/games/chess/Xchess/button.c b/gnu/games/chess/Xchess/button.c deleted file mode 100644 index 4e45ab20d149..000000000000 --- a/gnu/games/chess/Xchess/button.c +++ /dev/null @@ -1,338 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: button.c,v 1.2 1993/08/02 17:20:47 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Do stuff with the buttons. - * The configuration we're using is: Draw Back Pause - * Resign Fwd Flip - * Reset Save Easy (Switch) - */ - -#include "xchess.h" - -typedef enum choice { NOCHOICE, DRAW, RESIGN, REPLAY, SWITCH, FORE, SAVE, - STOP, FLIP, RESTART, EASY } choice; - -static struct but { - char *label; - int x, y; - int width, height; - choice which; -} buts[] = { - { "Draw", 0, 20, 108, 29, DRAW } , - { "Back", 109, 20, 108, 29, REPLAY } , - { "Pause", 219, 20, 108, 29, STOP } , - { "Resign", 0, 50, 108, 29, RESIGN } , - { "Fwd", 109, 50, 108, 29, FORE } , - { "Flip", 219, 50, 108, 29, FLIP } , - { "Reset", 0, 80, 108, 29, RESTART } , - { "Save", 109, 80, 108, 29, SAVE } , -#define EASY_OFFSET 8 - { "Switch", 219, 80, 108, 29, SWITCH } -/* { "NoEasy", 219, 80, 108, 29, EASY }*/ -} ; -static int easy = 1; - -void -button_draw(win) - windata *win; -{ - int i, x, numbuts = sizeof (buts) / sizeof (struct but); - - XSetState(win->display, DefaultGC(win->display, 0), - win->border.pixel, WhitePixel(win->display, 0), - GXcopy, AllPlanes); - XSetLineAttributes(win->display, DefaultGC(win->display, 0), - BORDER_WIDTH, LineSolid, CapButt, - JoinMiter); - - XDrawLine(win->display, win->buttonwin, - DefaultGC(win->display, 0), - 0, 29, BUTTON_WIDTH, 29); - XDrawLine(win->display, win->buttonwin, - DefaultGC(win->display, 0), - 0, 60, BUTTON_WIDTH, 60); - XDrawLine(win->display, win->buttonwin, - DefaultGC(win->display, 0), - 108, 0, 108, BUTTON_HEIGHT); - XDrawLine(win->display, win->buttonwin, - DefaultGC(win->display, 0), - 219, 0, 219, BUTTON_HEIGHT); - - XSetFont(win->display, DefaultGC(win->display, 0), win->large->fid); - XSetForeground(win->display, DefaultGC(win->display, 0), - win->textcolor.pixel); - XSetBackground(win->display, DefaultGC(win->display, 0), - win->textback.pixel); - - for (i = 0; i < numbuts; i++) { - x = (buts[i].width - - XTextWidth(win->large, buts[i].label, - strlen(buts[i].label))) / 2; - - XDrawImageString(win->display, win->buttonwin, - DefaultGC(win->display, 0), - buts[i].x + x, buts[i].y, buts[i].label, - strlen(buts[i].label)); - } - return; -} - -void -button_service(win, event) - windata *win; - XEvent *event; -{ - XKeyEvent *ev = &event->xkey; - choice c; - int i, numbuts = sizeof (buts) / sizeof (struct but); - char *s; - - ev->y += 15; - for (i = 0; i < numbuts; i++) - if ((ev->x >= buts[i].x) && (ev->x <= buts[i].x + - buts[i].width) && (ev->y >= buts[i].y) && - (ev->y <= buts[i].y + buts[i].height)) { - c = buts[i].which; - break; - } - if ((i == numbuts) || (c == NOCHOICE)) { - message_add(win, "Bad choice.\n", true); - return; - } - - if (loading_flag && (c != STOP)) { - message_add(win, "You can only use PAUSE now\n", true); - return; - } - - switch (c) { - case DRAW: - if (!oneboard) { - message_add(win, "Just a sec...\n", false); - if (!pop_question(((win == win1) ? win2 : win1), -"The other player wants\nto call the game a draw.\nDo you agree?\n")) { - message_add(win, - "The other player declines the draw\n", false); - return; - } - } - message_add(win1, "Draw agreed.\n", false); - if (!oneboard) - message_add(win2, "Draw agreed.\n", false); - cleanup("Draw agreed."); - break; - - case RESIGN: - if (!pop_question(win, "Are you sure\nyou want to resign?")) - return; - if ((oneboard && !progflag) || (nexttomove == win->color)) { - if (nexttomove == WHITE) - s = "White resigns."; - else - s = "Black resigns."; - if (oneboard) { - message_add(win, s, false); - message_add(win, "\n", false); - } else { - message_add(win1, s, false); - message_add(win, "\n", false); - message_add(win2, s, false); - message_add(win, "\n", false); - } - sleep(5); - cleanup(s); - } else { - message_add(win, "It's not your turn.\n", true); - } - break; - - case REPLAY: - if (!oneboard) { - message_add(win, "Just a sec...\n", false); - if (!pop_question(((win == win1) ? win2 : win1), -"The other player wants\nto take back his last move.\nDo you let him?\n")) { - message_add(win, - "The other player refuses...\n", false); - return; - } - } - if (!moves) { - message_add(win, "Can't back up...\n", true); - break; - } - message_add(win1, "Replaying...\n", false); - if (!oneboard) - message_add(win2, "Replaying...\n", false); - replay(); - if (progflag) - replay(); - break; - - case FORE: - if (!oneboard) { - message_add(win, "Just a sec...\n", false); - if (!pop_question(((win == win1) ? win2 : win1), -"The other player wants\nto do a 'fore'.\nIs that ok with you?\n")) { - message_add(win, - "The other player refuses...\n", false); - return; - } - } - if (!foremoves) { - message_add(win, "Can't go forward...\n", true); - break; - } - message_add(win1, "Moving forward...\n", false); - if (!oneboard) - message_add(win2, "Moving forward...\n", false); - forward(); - break; - - case SWITCH: - message_add(win, "You can't switch yet.\n", false); - break; - - case SAVE: - if (saveflag) { - message_add(win, - "Game is already being logged in file '", true); - message_add(win, record_file, true); - message_add(win, "'.\n", true); - } else { - message_add(win, "Saving game to file '", false); - message_add(win, record_file, false); - message_add(win, "'.\n", false); - record_save(); - } - break; - - case STOP: - if (loading_flag) { - loading_paused = (loading_paused ? false : true); - message_add(win, loading_paused ? - "Stopped.\nHit 'Pause' again to restart.\n" : - "Restarted.\n", false); - } else if (clock_started) { - if (!oneboard) { - message_add(win, "Just a sec...\n", false); - if (!pop_question(((win == win1) ? win2 : win1), -"The other player wants\nto stop the clock.\nDo you let him?\n")) { - message_add(win, - "The other player refuses to pause.\n", - false); - return; - } - } - message_add(win1, - "Clock stopped.\nHit 'Pause' again to restart.\n", - false); - if (!oneboard) - message_add(win2, - "Clock stopped.\nHit 'Pause' again to restart.\n", - false); - clock_started = false; - } else { - if (!oneboard) { - message_add(win, "Just a sec...\n", false); - if (!pop_question(((win == win1) ? win2 : win1), -"The other player wants\nto start the clock again.\nIs that ok?\n")) { - message_add(win, - "The other player refuses to resume.\n", - false); - return; - } - } - message_add(win1, "Clock restarted.\n", false); - if (!oneboard) - message_add(win2, "Clock restarted.\n", false); - clock_started = true; - } - break; - - case FLIP: - message_add(win, "Flipping window...\n", false); - win->flipped = win->flipped ? false : true; - win_redraw(win, (XEvent *) NULL); - break; - - case RESTART: - if (!oneboard) { - message_add(win, "Just a sec...\n", false); - if (!pop_question(((win == win1) ? win2 : win1), -"The other player wants\nto restart the game.\nDo you agree?\n")) { - message_add(win, - "The other player refuses to reset\n", false); - return; - } - } - message_add(win, "Restarting game.\n", false); - restart(); - break; - case EASY: - if (oneboard) { - int x; - if (easy) - easy = 0; - else - easy = 1; - - if (easy) - buts[EASY_OFFSET].label = " Easy "; - else - buts[EASY_OFFSET].label = "NoEasy"; - - program_easy(easy); - - x = (buts[EASY_OFFSET].width - - XTextWidth(win->large, - buts[EASY_OFFSET].label, - strlen(buts[EASY_OFFSET].label))) / 2; - - XSetFont(win->display, DefaultGC(win->display, - 0), win->large->fid); - XSetForeground(win->display, - DefaultGC(win->display, 0), - win->textcolor.pixel); - XSetBackground(win->display, - DefaultGC(win->display, 0), - win->textback.pixel); - - XDrawImageString(win->display, - win->buttonwin, - DefaultGC(win->display, 0), - buts[EASY_OFFSET].x + x, - buts[EASY_OFFSET].y, - buts[EASY_OFFSET].label, - strlen(buts[EASY_OFFSET].label)); - } - break; - } - return; -} - diff --git a/gnu/games/chess/Xchess/clock.c b/gnu/games/chess/Xchess/clock.c deleted file mode 100644 index 3bc0e7b84b20..000000000000 --- a/gnu/games/chess/Xchess/clock.c +++ /dev/null @@ -1,292 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: clock.c,v 1.2 1993/08/02 17:20:48 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Do stuff with the clocks. The way things work is as follows. We call - * clock_init to draw the clocks initially, but they don't actually start - * running until we call clock_switch for the first time. - */ - -#include "xchess.h" - -int movesperunit = 0; -int timeunit = 0; -bool clock_started = false; -int whiteseconds, blackseconds; - -static bool white_running = true; -static long lastwhite, lastblack; -static bool firstmove = true; - -extern void dohands(), hilight(); - -#define PI 3.1415926535897932384 - -void -clock_draw(win, col) - windata *win; - color col; -{ - int i; - char buf[BSIZE]; - int x = CLOCK_WIDTH / 2, y = CLOCK_WIDTH / 2; - int xp, yp; - int rad = CLOCK_WIDTH / 2 - 10; - Window w = ((col == WHITE) ? win->wclockwin : win->bclockwin); - - /* Draw a clock face and the hands. */ - XCircle(w, x, y, rad, 0.0, 0.0, 1, 1, win->textcolor.pixel, GXcopy, - AllPlanes); - rad -= 8; - - XSetFont(win->display, DefaultGC(win->display, 0), - win->small->fid); - XSetForeground(win->display, DefaultGC(win->display, 0), - win->textcolor.pixel); - XSetBackground(win->display, DefaultGC(win->display, 0), - win->textback.pixel); - for (i = 1; i <= 12; i++) { - xp = x + rad * cos(PI * 3 / 2 + i * PI / 6) - 4; - yp = y + rad * sin(PI * 3 / 2 + i * PI / 6) - 5; - sprintf(buf, "%d", i); - XDrawString(win->display, w, DefaultGC(win->display, 0), - xp, yp, buf, strlen(buf)); - } - - dohands(win, col); - - if (white_running) { - hilight(win, WHITE, true); - hilight(win, BLACK, false); - } else { - hilight(win, WHITE, false); - hilight(win, BLACK, true); - } - return; -} - -void -clock_init(win, col) - windata *win; - color col; -{ - whiteseconds = blackseconds = 0; - clock_started = false; - firstmove = true; - clock_draw(win, col); - - return; -} - -void -clock_update() -{ - int now = time((long *) NULL); - int i; - - if (!clock_started) { - lastwhite = lastblack = now; - return; - } - - if (white_running) { - whiteseconds += now - lastwhite; - lastwhite = now; - dohands(win1, WHITE); - if (!oneboard) - dohands(win2, WHITE); - if (timeunit) { - i = whiteseconds / timeunit; - if ((i > 0) && (whiteseconds > i * timeunit) && - (whiteseconds < i * timeunit + 10) && - (movesperunit * i > movenum)) { - message_add(win1, - "White has exceeded his time limit\n", - true); - if (!oneboard) { - message_add(win2, - "White has exceeded his time limit\n", - true); - } - timeunit = 0; - } - } - } else { - blackseconds += now - lastblack; - lastblack = now; - dohands(win1, BLACK); - if (!oneboard) - dohands(win2, BLACK); - if (timeunit) { - i = blackseconds / timeunit; - if ((i > 0) && (blackseconds > i * timeunit) && - (blackseconds < i * timeunit + 10) && - (movesperunit * i > movenum)) { - message_add(win1, - "Black has exceeded his time limit\n", - true); - if (!oneboard) { - message_add(win2, - "Black has exceeded his time limit\n", - true); - } - timeunit = 0; - } - } - } - return; -} - -void -clock_switch() -{ - if (firstmove) { - clock_started = true; - firstmove = false; - lastwhite = lastblack = time((long *) NULL); - } - if (white_running) { - white_running = false; - lastblack = time((long *) NULL); - hilight(win1, WHITE, false); - hilight(win1, BLACK, true); - if (!oneboard) { - hilight(win2, WHITE, false); - hilight(win2, BLACK, true); - } - } else { - white_running = true; - lastwhite = time((long *) NULL); - hilight(win1, WHITE, true); - hilight(win1, BLACK, false); - if (!oneboard) { - hilight(win2, WHITE, true); - hilight(win2, BLACK, false); - } - } - return; -} - -static void -dohands(win, col) - windata *win; - color col; -{ - int cx = CLOCK_WIDTH / 2, cy = CLOCK_WIDTH / 2; - double *h = (col == WHITE) ? win->whitehands : win->blackhands; - Window w = (col == WHITE) ? win->wclockwin : win->bclockwin; - long secs = (col == WHITE) ? whiteseconds : blackseconds; - int rad, x, y, i; - - /* First erase the old hands. */ - XSetState(win->display, DefaultGC(win->display, 0), - win->textback.pixel, win->textback.pixel, - GXcopy, AllPlanes); - - rad = CLOCK_WIDTH / 2 - 30; - for (i = 0; i < 3; i++) { - x = cx + rad * sin(PI - h[i]); - y = cy + rad * cos(PI - h[i]); - XSetLineAttributes(win->display, - DefaultGC(win->display, 0), - i, LineSolid, 0, 0); - XDrawLine(win->display, w, DefaultGC(win->display, 0), - cx, cy, x, y); - rad -= 8; - } - - h[0] = (secs % 60) * 2 * PI / 60; - h[1] = ((secs / 60) % 60) * 2 * PI / 60; - h[2] = ((secs / 3600) % 12) * 2 * PI / 12; - - /* Now draw the new ones. */ - - XSetState(win->display, DefaultGC(win->display, 0), - win->textcolor.pixel, win->textback.pixel, - GXcopy, AllPlanes); - - rad = CLOCK_WIDTH / 2 - 30; - for (i = 0; i < 3; i++) { - x = cx + rad * sin(PI - h[i]); - y = cy + rad * cos(PI - h[i]); - XSetLineAttributes(win->display, - DefaultGC(win->display, 0), - i, LineSolid, 0, 0); - XDrawLine(win->display, w, DefaultGC(win->display, 0), - cx, cy, x, y); - rad -= 8; - } - XFlush(win->display); - return; -} - -static void -hilight(win, col, on) - windata *win; - color col; - bool on; -{ - Window w = (col == WHITE) ? win->wclockwin : win->bclockwin; - char *s = (col == WHITE) ? " WHITE " : " BLACK "; - int x; - - - x = XTextWidth(win->large, s, strlen(s)); - if (on) - XSetState(win->display, DefaultGC(win->display, 0), - win->textback.pixel, - win->textcolor.pixel, - GXcopy, - AllPlanes); - else - XSetState(win->display, DefaultGC(win->display, 0), - win->textcolor.pixel, - win->textback.pixel, - GXcopy, AllPlanes); - - XSetLineAttributes(win->display, DefaultGC(win->display, 0), - BORDER_WIDTH, LineSolid, CapButt, JoinMiter); - XSetFont(win->display, DefaultGC(win->display, 0), - win->large->fid); - - XDrawLine(win->display, w, DefaultGC(win->display, 0), - 0, CLOCK_HEIGHT - 26, - CLOCK_WIDTH, CLOCK_HEIGHT - 26); - - XDrawImageString(win->display, w, DefaultGC(win->display, 0), - (CLOCK_WIDTH - x) / 2, CLOCK_HEIGHT, - s, strlen(s)); - - if (on) - XSetState(win->display, DefaultGC(win->display, 0), - win->textcolor.pixel, - win->textback.pixel, - GXcopy, AllPlanes); - return; -} - diff --git a/gnu/games/chess/Xchess/control.c b/gnu/games/chess/Xchess/control.c deleted file mode 100644 index b46a0299d0b4..000000000000 --- a/gnu/games/chess/Xchess/control.c +++ /dev/null @@ -1,517 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: control.c,v 1.2 1993/08/02 17:20:50 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Deal with input from the user. - */ - -#include "xchess.h" - -move *moves; -move *foremoves; -color nexttomove = WHITE; -bool noisyflag = false; - -move *lastmove; -static move *thismove; - -static void screen_move(); - -void -button_pressed(event, win) - XEvent *event; - windata *win; -{ - int x, y; - XKeyEvent *ev = (XKeyEvent *) event; - - if (!oneboard && (win->color != nexttomove)) { - message_add(win, "Wrong player!\n", true); - return; - } - if (progflag && (nexttomove == (blackflag ? WHITE : BLACK))) { - message_add(win, "Wait for the computer...\n", true); - return; - } - if (loading_flag) { - message_add(win, "You'd better not do that now...\n", true); - return; - } - - /* Figure out what piece he is pointing at. */ - x = ev->x / (SQUARE_WIDTH + BORDER_WIDTH); - y = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH); - - if (win->flipped) { - y = SIZE - y - 1; - x = SIZE - x - 1; - } - - if ((x < 0) || (x >= SIZE) || (y < 0) || (y >= SIZE)) { - fprintf(stderr, "Bad coords (%d, %d)\n", x, y); - return; - } - - if (oneboard && (chessboard->square[y][x].color != nexttomove)) { - message_add(win, "Wrong player!\n", true); - return; - } else if (!oneboard && (chessboard->square[y][x].color != - win->color)) { - message_add(win, "Can't move that\n", true); - return; - } - - thismove = alloc(move); - thismove->fromx = x; - thismove->fromy = y; - thismove->piece.color = chessboard->square[y][x].color; - thismove->piece.type = chessboard->square[y][x].type; - - if (debug) - fprintf(stderr, "%s selected his %s at (%d, %d)...\n", - colornames[(int) thismove->piece.color], - piecenames[(int) thismove->piece.type], - thismove->fromy, thismove->fromx); - return; -} - -void -button_released(event, win) - XEvent *event; - windata *win; -{ - int x, y; - XKeyEvent *ev = (XKeyEvent *) event; - - if (!thismove) { - /* fprintf(stderr, "Error: button hasn't been pressed\n"); */ - return; - } - if (loading_flag) - return; - - /* Figure out what piece he is pointing at. */ - x = ev->x / (SQUARE_WIDTH + BORDER_WIDTH); - y = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH); - - if (win->flipped) { - y = SIZE - y - 1; - x = SIZE - x - 1; - } - - if ((x < 0) || (x >= SIZE) || (y < 0) || (y >= SIZE)) { - fprintf(stderr, "Bad coords (%d, %d)\n", x, y); - return; - } - - if ((thismove->fromx == x) && (thismove->fromy == y)) { - message_add(win, "Hey, you touch it, you move it, buddy.\n", - true); - return; - } - if (chessboard->square[y][x].color == thismove->piece.color) { - message_add(win, "Can't put one piece on top of another\n", - true); - return; - } - - thismove->tox = x; - thismove->toy = y; - thismove->taken.color = chessboard->square[y][x].color; - thismove->taken.type = chessboard->square[y][x].type; - if (thismove->taken.color != NONE) - thismove->type = CAPTURE; - else if ((thismove->piece.type == KING) && (thismove->fromx == 4) && - (thismove->tox == 6) && - (thismove->toy == thismove->fromy)) - thismove->type = KCASTLE; - else if ((thismove->piece.type == KING) && (thismove->tox == 2) && - (thismove->fromx == 4) && - (thismove->toy == thismove->fromy)) - thismove->type = QCASTLE; - else - thismove->type = MOVE; - - /* Now check the en-passant case... */ - if ((thismove->type == MOVE) && ((thismove->tox == thismove->fromx + 1) - || (thismove->tox == thismove->fromx - 1)) && - (thismove->piece.type == PAWN) && lastmove && - (lastmove->tox == lastmove->fromx) && (lastmove->fromx - == thismove->tox) && ((lastmove->fromy + lastmove->toy) - / 2 == thismove->toy)) { - thismove->type = CAPTURE; - thismove->enpassant = true; - thismove->taken = lastmove->piece; - } - - if (!valid_move(thismove, chessboard)) { - message_add(win, "Invalid move.\n", true); - return; - } - - if (debug) - fprintf(stderr, "\t... and moved it to (%d, %d), type %s\n", - thismove->toy, thismove->tox, - movetypenames[(int) thismove->type]); - move_piece(thismove); - - if (thismove->check) { - message_add(win1, "Check.\n", true); - if (!oneboard) { - message_add(win2, "Check.\n", true); - } - } - - if (!moves) - moves = lastmove = thismove; - else - lastmove = lastmove->next = thismove; - - if (progflag) - program_send(thismove); - - thismove = NULL; - nexttomove = ((nexttomove == WHITE) ? BLACK : WHITE); - clock_switch(); - - return; -} - -void -prog_move(m) - move *m; -{ - if (debug) - fprintf(stderr, "program moves from (%d, %d) to (%d, %d)\n", - m->fromy, m->fromx, m->toy, m->tox); - move_piece(m); - - if (!moves) - moves = lastmove = m; - else - lastmove = lastmove->next = m; - - nexttomove = ((nexttomove == WHITE) ? BLACK : WHITE); - clock_switch(); - - return; -} - -void -move_piece(m) - move *m; -{ - /* Update the screen... */ - screen_move(m); - - /* Move the piece on the board... */ - board_move(chessboard, m); - - /* And record it... */ - record_move(m); - - if (noisyflag) { - XBell(win1->display, 50); - XBell(win2->display, 50); - } - return; -} - -static void -screen_move(m) - move *m; -{ - piece pp; - - switch (m->type) { - case CAPTURE: - jail_add(&m->taken); - /* FALLTHRU */ - - case MOVE: - win_erasepiece(m->fromy, m->fromx, WHITE); - if (win_flashmove) - win_flash(m, WHITE); - win_drawpiece(&m->piece, m->toy, m->tox, WHITE); - if (m->enpassant) - win_erasepiece(m->toy + ((m->piece.color == WHITE) ? - 1 : -1), m->tox, WHITE); - if (!oneboard) { - win_erasepiece(m->fromy, m->fromx, BLACK); - if (win_flashmove) - win_flash(m, BLACK); - win_drawpiece(&m->piece, m->toy, m->tox, BLACK); - if (m->enpassant) - win_erasepiece(m->toy + ((m->piece.color == - WHITE) ? 1 : -1), m->tox, WHITE); - } - if ((m->piece.type == PAWN) && (((m->piece.color == BLACK) && - (m->toy == 7)) || ((m->piece.color == WHITE) && - (m->toy == 0)))) { - pp.color = m->piece.color; - pp.type = QUEEN; - win_drawpiece(&pp, m->toy, m->tox, WHITE); - if (!oneboard) - win_drawpiece(&m->piece, m->toy, m->tox, BLACK); - } - break; - - case KCASTLE: - if (m->piece.color == WHITE) { - win_erasepiece(7, 4, WHITE); - win_erasepiece(7, 7, WHITE); - if (win_flashmove) - win_flash(m, WHITE); - win_drawpiece(&m->piece, 7, 6, WHITE); - win_drawpiece(&chessboard->square[7][7], 7, 5, WHITE); - if (!oneboard) { - win_erasepiece(7, 4, BLACK); - win_erasepiece(7, 7, BLACK); - if (win_flashmove) - win_flash(m, BLACK); - win_drawpiece(&m->piece, 7, 6, BLACK); - win_drawpiece(&chessboard->square[7][7], 7, 5, - BLACK); - } - } else { - win_erasepiece(0, 4, WHITE); - win_erasepiece(0, 7, WHITE); - if (win_flashmove) - win_flash(m, WHITE); - win_drawpiece(&m->piece, 0, 6, WHITE); - win_drawpiece(&chessboard->square[0][7], 0, 5, WHITE); - if (!oneboard) { - win_erasepiece(0, 4, BLACK); - win_erasepiece(0, 7, BLACK); - if (win_flashmove) - win_flash(m, BLACK); - win_drawpiece(&m->piece, 0, 6, BLACK); - win_drawpiece(&chessboard->square[0][7], 0, 5, - BLACK); - } - } - break; - - case QCASTLE: - if (m->piece.color == WHITE) { - win_erasepiece(7, 4, WHITE); - win_erasepiece(7, 0, WHITE); - if (win_flashmove) - win_flash(m, WHITE); - win_drawpiece(&m->piece, 7, 2, WHITE); - win_drawpiece(&chessboard->square[7][0], 7, 3, WHITE); - if (!oneboard) { - win_erasepiece(7, 4, BLACK); - win_erasepiece(7, 0, BLACK); - if (win_flashmove) - win_flash(m, BLACK); - win_drawpiece(&m->piece, 7, 2, BLACK); - win_drawpiece(&chessboard->square[7][7], 7, 3, - BLACK); - } - } else { - win_erasepiece(0, 4, WHITE); - win_erasepiece(0, 0, WHITE); - if (win_flashmove) - win_flash(m, WHITE); - win_drawpiece(&m->piece, 0, 2, WHITE); - win_drawpiece(&chessboard->square[0][0], 0, 3, WHITE); - if (!oneboard) { - win_erasepiece(0, 4, BLACK); - win_erasepiece(0, 0, BLACK); - if (win_flashmove) - win_flash(m, BLACK); - win_drawpiece(&m->piece, 0, 2, BLACK); - win_drawpiece(&chessboard->square[0][7], 0, 3, - BLACK); - } - } - break; - - default: - fprintf(stderr, "Bad move type %d\n", m->type); - } - return; -} - -/* Retract the last move made... */ - -void -replay() -{ - move *m = lastmove, bm; - - memset(&bm, 0, sizeof(bm)); - switch (m->type) { - case MOVE: - bm.type = MOVE; - bm.piece = m->piece; - bm.fromx = m->tox; - bm.fromy = m->toy; - bm.tox = m->fromx; - bm.toy = m->fromy; - board_move(chessboard, &bm); - screen_move(&bm); - break; - - case CAPTURE: - bm.type = MOVE; - bm.piece = m->piece; - bm.fromx = m->tox; - bm.fromy = m->toy; - bm.tox = m->fromx; - bm.toy = m->fromy; - board_move(chessboard, &bm); - screen_move(&bm); - chessboard->square[m->toy][m->tox] = m->taken; - bm.piece = m->taken; - bm.fromx = bm.tox = m->tox; - bm.fromy = bm.toy = m->toy; - screen_move(&bm); - jail_remove(&m->taken); - break; - - case KCASTLE: - bm.type = MOVE; - bm.piece.type = KING; - bm.piece.color = m->piece.color; - bm.fromx = 6; - bm.tox = 4; - bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0; - board_move(chessboard, &bm); - screen_move(&bm); - bm.type = MOVE; - bm.piece.type = ROOK; - bm.piece.color = m->piece.color; - bm.fromx = 5; - bm.tox = 7; - bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0; - board_move(chessboard, &bm); - screen_move(&bm); - if (m->piece.color == WHITE) - chessboard->white_cant_castle_k = false; - else - chessboard->black_cant_castle_k = false; - break; - - case QCASTLE: - bm.type = MOVE; - bm.piece.type = KING; - bm.piece.color = m->piece.color; - bm.fromx = 2; - bm.tox = 4; - bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0; - board_move(chessboard, &bm); - screen_move(&bm); - bm.type = MOVE; - bm.piece.type = ROOK; - bm.piece.color = m->piece.color; - bm.fromx = 3; - bm.tox = 0; - bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0; - board_move(chessboard, &bm); - screen_move(&bm); - if (m->piece.color == WHITE) - chessboard->white_cant_castle_q = false; - else - chessboard->black_cant_castle_q = false; - break; - } - record_back(); - - nexttomove = ((nexttomove == WHITE) ? BLACK : WHITE); - clock_switch(); - - if (!moves->next) { - moves->next = foremoves; - foremoves = moves; - moves = lastmove = NULL; - } else { - for (m = moves; m->next; m = m->next) - lastmove = m; - lastmove->next->next = foremoves; - foremoves = lastmove->next; - lastmove->next = NULL; - } - - if (progflag) - program_undo(); - - return; -} - -/* Put back the last move undone. */ - -void -forward() -{ - prog_move(foremoves); - foremoves = foremoves->next; - return; -} - -/* End the game. */ - -void -cleanup(s) - char *s; -{ - if (progflag) - program_end(); - record_end(s); - XSync(win1->display, 0); - if (!oneboard) { - XSync(win2->display, 0); - } - exit(0); -} - -void -restart() -{ - moves = lastmove = thismove = NULL; - nexttomove = WHITE; - - clock_init(win1, WHITE); - clock_init(win1, BLACK); - jail_init(win1); - if (!oneboard) { - clock_init(win2, WHITE); - clock_init(win2, BLACK); - jail_init(win2); - } - board_init(chessboard); - win_restart(); - record_reset(); - if (progflag) { - program_end(); - program_init(progname); - } - return; -} - diff --git a/gnu/games/chess/Xchess/jail.c b/gnu/games/chess/Xchess/jail.c deleted file mode 100644 index 02d5d241b66f..000000000000 --- a/gnu/games/chess/Xchess/jail.c +++ /dev/null @@ -1,328 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: jail.c,v 1.2 1993/08/02 17:20:51 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - */ - -#include "xchess.h" - -#include "pawn_small.bitmap" -#include "rook_small.bitmap" -#include "knight_small.bitmap" -#include "bishop_small.bitmap" -#include "queen_small.bitmap" -#include "king_small.bitmap" - -#include "pawn_small_outline.bitmap" -#include "rook_small_outline.bitmap" -#include "knight_small_outline.bitmap" -#include "bishop_small_outline.bitmap" -#include "queen_small_outline.bitmap" -#include "king_small_outline.bitmap" - -static bool pos[32]; - -static piecetype pcs[] = { KING, QUEEN, ROOK, ROOK, BISHOP, BISHOP, KNIGHT, - KNIGHT, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN } ; - -extern int piecepos(); -extern char *bitsget(); - -void -jail_init(win) - windata *win; -{ - int i; - - for (i = 0; i < 32; i++) - pos[i] = false; - jail_draw(win); - return; -} - -#define JAIL_HEADER "Captured Pieces" - -void -jail_draw(win) - windata *win; -{ - int i; - char *bits; - Pixmap tmpPM; - piece p; - - i = XTextWidth(win->large, JAIL_HEADER, strlen(JAIL_HEADER)); - XSetFont(win->display, DefaultGC(win->display, 0), - win->large->fid); - XSetForeground(win->display, DefaultGC(win->display, 0), - win->textcolor.pixel); - XSetBackground(win->display, DefaultGC(win->display, 0), - win->textback.pixel); - - XDrawImageString(win->display, win->jailwin, - DefaultGC(win->display, 0), - (JAIL_WIDTH - i) / 2, 20, JAIL_HEADER, - strlen(JAIL_HEADER)); - - XSetForeground(win->display, DefaultGC(win->display, 0), - win->blackpiece.pixel); - XSetBackground(win->display, DefaultGC(win->display, 0), - win->textback.pixel); - XSetFillStyle(win->display, DefaultGC(win->display, 0), - FillSolid); - XSetFunction(win->display, DefaultGC(win->display, 0), - GXcopy); - - for (i = 0; i < 16; i++) - if (pos[i]) { - p.color = WHITE; - p.type = pcs[i]; - bits = bitsget(&p); - tmpPM = XCreateBitmapFromData(win->display, - win->jailwin, bits, - 32, 32); - - XCopyPlane(win->display, tmpPM, win->jailwin, - DefaultGC(win->display, 0), - 0, 0, 32, 32, - 5 + (i % 8) * 32, 25 + (i / 8) * 32, - 1); - XFreePixmap(win->display, tmpPM); - } else { - XFillRectangle(win->display, win->jailwin, - DefaultGC(win->display, 0), - 5 + (i % 8) * 32, - 25 + (i / 8) * 32, - 32, 32); - } - for (i = 0; i < 16; i++) - if (pos[i + 16]) { - p.color = BLACK; - p.type = pcs[i]; - bits = bitsget(&p); - tmpPM = XCreateBitmapFromData(win->display, - win->jailwin, bits, - 32, 32); - - XCopyPlane(win->display, tmpPM, win->jailwin, - DefaultGC(win->display, 0), - 0, 0, 32, 32, - 5 + (i % 8) * 32, 94 + (i / 8) * 32, - 1); - XFreePixmap(win->display, tmpPM); - } else { - XFillRectangle(win->display, win->jailwin, - DefaultGC(win->display, 0), - 5 + (i % 8) * 32, 94 + (i / 8) * 32, - 32, 32); - } - - return; -} - -void -jail_add(p) - piece *p; -{ - int i = piecepos(p, false); - char *bits; - Pixmap tmpPM; - - pos[i] = true; - - bits = bitsget(p); - - XSetState(win1->display, DefaultGC(win1->display, 0), - win1->blackpiece.pixel, - win1->textback.pixel, - GXcopy, - AllPlanes); - - tmpPM = XCreateBitmapFromData(win1->display, - win1->jailwin, bits, - 32, 32); - - XCopyPlane(win1->display, tmpPM, win1->jailwin, - DefaultGC(win1->display, 0), - 0, 0, 32, 32, - 5 + (i % 8) * 32, ((i >= 16) ? 30 : 25) + (i / 8) * 32, - 1); - XFreePixmap(win1->display, tmpPM); - - if (!oneboard) { - XSetState(win2->display, DefaultGC(win2->display, 0), - win2->blackpiece.pixel, - win2->textback.pixel, - GXcopy, - AllPlanes); - - - tmpPM = XCreateBitmapFromData(win2->display, - win2->jailwin, bits, - 32, 32); - - XCopyPlane(win2->display, tmpPM, win2->jailwin, - DefaultGC(win2->display, 0), - 0, 0, 32, 32, - 5 + (i % 8) * 32, ((i >= 16) ? 30 : 25) + (i / 8) * 32, - 1); - XFreePixmap(win2->display, tmpPM); - } - - return; -} - -void -jail_remove(p) - piece *p; -{ - int i = piecepos(p, true); - - pos[i] = false; - - - XSetForeground(win1->display, - DefaultGC(win1->display, 0), - win1->blackpiece.pixel); - XSetBackground(win1->display, - DefaultGC(win1->display, 0), - win1->textback.pixel); - XSetFillStyle(win1->display, - DefaultGC(win1->display, 0), - FillSolid); - - XFillRectangle(win1->display, win1->jailwin, - DefaultGC(win1->display, 0), - 5 + (i % 8) * 32, - ((i >= 16) ? 30 : 25) + (i / 8) * 32, - 32, 32); - - if (!oneboard) { - XSetForeground(win2->display, - DefaultGC(win2->display, 0), - win2->blackpiece.pixel); - XSetBackground(win2->display, - DefaultGC(win2->display, 0), - win2->textback.pixel); - XSetFillStyle(win2->display, - DefaultGC(win2->display, 0), - FillSolid); - - XFillRectangle(win2->display, win2->jailwin, - DefaultGC(win2->display, 0), - 5 + (i % 8) * 32, - ((i >= 16) ? 30 : 25) + (i / 8) * 32, - 32, 32); - } - - return; -} - -static char *bitsget(p) - piece *p; -{ - char *bits; - - switch (p->type) { - case PAWN: - bits = (p->color == WHITE) ? pawn_small_outline_bits : - pawn_small_bits; - break; - - case ROOK: - bits = (p->color == WHITE) ? rook_small_outline_bits : - rook_small_bits; - break; - - case KNIGHT: - bits = (p->color == WHITE) ? knight_small_outline_bits : - knight_small_bits; - break; - - case BISHOP: - bits = (p->color == WHITE) ? bishop_small_outline_bits : - bishop_small_bits; - break; - - case QUEEN: - bits = (p->color == WHITE) ? queen_small_outline_bits : - queen_small_bits; - break; - - case KING: - bits = (p->color == WHITE) ? king_small_outline_bits : - king_small_bits; - break; - } - return (bits); -} - -static int -piecepos(p, there) - piece *p; - bool there; -{ - int i, base = (p->color == WHITE) ? 0 : 16; - - switch (p->type) { - case PAWN: - for (i = base + 8; (i < base + 15) && pos[i]; i++) - ; - if (there && !pos[i]) - i--; - break; - - case KING: - /* Hmm... */ - i = base; - break; - - case QUEEN: - i = base + 1; - break; - - case ROOK: - i = base + 2; - if ((there && pos[i + 1]) || (!there && pos[i])) - i++; - break; - - case BISHOP: - i = base + 4; - if ((there && pos[i + 1]) || (!there && pos[i])) - i++; - break; - - case KNIGHT: - i = base + 6; - if ((there && pos[i + 1]) || (!there && pos[i])) - i++; - break; - } - return (i); -} diff --git a/gnu/games/chess/Xchess/king.bitmap b/gnu/games/chess/Xchess/king.bitmap deleted file mode 100644 index dd9178a2ed9e..000000000000 --- a/gnu/games/chess/Xchess/king.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define king_width 80 -#define king_height 80 -static char king_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x30, 0x18, 0x00, 0xfc, 0x1f, 0x00, - 0x00, 0xfe, 0x7f, 0x00, 0xb8, 0x3b, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, - 0xff, 0x00, 0xb8, 0x3b, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x03, - 0xb8, 0x3b, 0xe0, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x0f, 0xb8, 0x3b, - 0xf0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x1f, 0xb8, 0x3b, 0xf8, 0xff, - 0xf8, 0x07, 0xe0, 0x1f, 0xc0, 0x3f, 0xb8, 0x3b, 0xfc, 0x07, 0xe2, 0x07, - 0xf0, 0xcf, 0x9f, 0x7f, 0x30, 0x18, 0xfe, 0xf3, 0xcf, 0x0f, 0xf0, 0xe7, - 0x3f, 0xfe, 0xf0, 0x1f, 0x7e, 0xfc, 0xdf, 0x0f, 0xf0, 0xf3, 0xff, 0xfc, - 0xf1, 0x1f, 0x3f, 0xff, 0x9f, 0x0f, 0xf8, 0xfb, 0xff, 0xfd, 0xf3, 0x9f, - 0xbf, 0xff, 0xbf, 0x1f, 0xf8, 0xf9, 0xff, 0xf9, 0xe3, 0x8f, 0xdf, 0xff, - 0x3f, 0x1f, 0xf8, 0xfd, 0xff, 0xf3, 0xef, 0xcf, 0xcf, 0xff, 0x7f, 0x1f, - 0xf8, 0xfd, 0xff, 0xe7, 0xef, 0xef, 0xef, 0xff, 0x7f, 0x1f, 0xfc, 0xfd, - 0xff, 0xcf, 0xff, 0xff, 0xe7, 0x3f, 0x7c, 0x3f, 0xfc, 0x3c, 0xfc, 0xdf, - 0xff, 0xfe, 0xf3, 0x3d, 0x7c, 0x3f, 0xfc, 0x3e, 0xfc, 0x9e, 0x7f, 0xfc, - 0xf9, 0x39, 0x7c, 0x3f, 0xfc, 0x3e, 0x7c, 0xbe, 0x3f, 0xf8, 0xf9, 0x3b, - 0x7c, 0x3f, 0xfc, 0x3e, 0x78, 0x3f, 0x7f, 0xfc, 0xfc, 0x3b, 0x7f, 0x3f, - 0xfc, 0xfe, 0x7b, 0x7f, 0xff, 0xfe, 0xfe, 0x9b, 0x7f, 0x3f, 0xf8, 0xfe, - 0xbb, 0x7f, 0xfe, 0x7f, 0xfe, 0xdb, 0x79, 0x1f, 0xf8, 0xfe, 0xb3, 0xff, - 0xfe, 0x7f, 0xff, 0xcb, 0x7c, 0x1f, 0xf8, 0x9e, 0xb7, 0xff, 0xfe, 0x7f, - 0xff, 0x2b, 0x3e, 0x1f, 0xf8, 0x3e, 0xa6, 0xff, 0xfc, 0x7f, 0xff, 0xa3, - 0xbf, 0x1f, 0xf8, 0xfe, 0xa8, 0xff, 0xfd, 0x3e, 0xff, 0xd3, 0xbf, 0x1f, - 0xf8, 0xfd, 0x83, 0xff, 0x7d, 0xbc, 0xff, 0xc3, 0xbf, 0x1f, 0xf0, 0xfd, - 0x8f, 0xff, 0x39, 0xb8, 0xff, 0xe3, 0xbf, 0x1f, 0xf0, 0xfd, 0x9f, 0xff, - 0x7b, 0xbc, 0xff, 0xf1, 0x9f, 0x0f, 0xf0, 0xf9, 0xbf, 0xff, 0xfb, 0xbe, - 0xff, 0xfd, 0xdf, 0x0f, 0xf0, 0xfb, 0x3f, 0xff, 0xf3, 0x9f, 0xff, 0xfd, - 0xdf, 0x0f, 0xf0, 0xf3, 0x7f, 0xff, 0xf7, 0xdf, 0xff, 0xfc, 0xdf, 0x0f, - 0xe0, 0xf7, 0x7f, 0xfe, 0xf7, 0xdf, 0xff, 0xfe, 0xdf, 0x07, 0xe0, 0xf7, - 0xff, 0xfe, 0xf7, 0xdf, 0x7f, 0xfe, 0xcf, 0x07, 0xe0, 0xe7, 0xff, 0xfe, - 0xf7, 0xdf, 0x7f, 0xff, 0xef, 0x07, 0xc0, 0xef, 0xff, 0xfc, 0xef, 0xee, - 0x7f, 0xff, 0xe7, 0x03, 0xc0, 0xcf, 0xff, 0xfd, 0x6f, 0xec, 0x3f, 0xff, - 0xf7, 0x03, 0x80, 0xdf, 0xff, 0xf9, 0xef, 0xee, 0xbf, 0xff, 0xf3, 0x01, - 0x80, 0x9f, 0xff, 0xfb, 0xef, 0xef, 0x9f, 0xff, 0xfb, 0x01, 0x00, 0xbf, - 0xff, 0xfb, 0xef, 0xef, 0xdf, 0xff, 0xf9, 0x00, 0x00, 0x7e, 0xff, 0xf3, - 0xef, 0xef, 0xdf, 0xff, 0x7e, 0x00, 0x00, 0x7e, 0xfe, 0xff, 0xef, 0xef, - 0xff, 0x7f, 0x7e, 0x00, 0x00, 0xfc, 0xfc, 0xff, 0xef, 0xef, 0xff, 0x7f, - 0x3f, 0x00, 0x00, 0xfc, 0xf9, 0xff, 0xef, 0xef, 0xff, 0x3f, 0x1f, 0x00, - 0x00, 0xf8, 0xfb, 0x03, 0xe0, 0x0f, 0x00, 0x9f, 0x1f, 0x00, 0x00, 0xf0, - 0x03, 0xf8, 0xff, 0xff, 0x7f, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xbf, - 0xf7, 0xde, 0xfb, 0xff, 0x07, 0x00, 0x00, 0xc0, 0xff, 0x1d, 0x63, 0x8c, - 0x71, 0xff, 0x03, 0x00, 0x00, 0x80, 0xef, 0xb8, 0xf7, 0xde, 0x3b, 0xee, - 0x01, 0x00, 0x00, 0x00, 0xc7, 0xfd, 0xff, 0xff, 0x7f, 0xc7, 0x00, 0x00, - 0x00, 0x00, 0xee, 0xff, 0x00, 0x00, 0xfc, 0x6f, 0x00, 0x00, 0x00, 0x00, - 0xfe, 0x03, 0xfe, 0xff, 0x01, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf8, - 0x7f, 0xfc, 0x7f, 0x60, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x1f, 0xf0, - 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xff, 0x07, 0xc0, 0xff, 0x63, - 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x1f, 0xf0, 0xff, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x06, 0xfc, 0x7f, 0xfc, 0x3f, 0x60, 0x00, 0x00, 0x00, 0x00, - 0x06, 0xff, 0xff, 0xff, 0xff, 0x60, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xff, - 0x00, 0x00, 0xfc, 0x63, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x03, 0xfe, 0xff, - 0x01, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf8, 0xff, 0xff, 0x7f, 0x60, - 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, - 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/king_mask.bitmap b/gnu/games/chess/Xchess/king_mask.bitmap deleted file mode 100644 index e1bb523cad10..000000000000 --- a/gnu/games/chess/Xchess/king_mask.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define king_mask_width 80 -#define king_mask_height 80 -static char king_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0xf8, 0x3f, 0x00, 0xfe, - 0x3f, 0x00, 0x00, 0xff, 0xff, 0x00, 0xfc, 0x3f, 0x80, 0xff, 0x7f, 0x00, - 0x80, 0xff, 0xff, 0x01, 0xfc, 0x7f, 0xc0, 0xff, 0xff, 0x00, 0xc0, 0xff, - 0xff, 0x07, 0xfc, 0x7f, 0xe0, 0xff, 0xff, 0x01, 0xe0, 0xff, 0xff, 0x1f, - 0xfc, 0x7f, 0xf8, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x3f, 0xfc, 0x7f, - 0xfc, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0x7f, 0xfc, 0x7f, 0xfe, 0xff, - 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xff, 0x1f, - 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, - 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, - 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, - 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, - 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x07, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, - 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, - 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf8, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, - 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/king_outline.bitmap b/gnu/games/chess/Xchess/king_outline.bitmap deleted file mode 100644 index 173651c28efa..000000000000 --- a/gnu/games/chess/Xchess/king_outline.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define king_outline_width 80 -#define king_outline_height 80 -static char king_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x3c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x0c, 0x60, 0x00, 0xfc, 0x1f, 0x00, - 0x00, 0x0e, 0x70, 0x00, 0x84, 0x43, 0x00, 0x07, 0x70, 0x00, 0x00, 0x03, - 0xc0, 0x00, 0xc4, 0x46, 0x80, 0x01, 0xc0, 0x00, 0x80, 0x01, 0x80, 0x03, - 0x44, 0x44, 0xe0, 0x00, 0x80, 0x01, 0xc0, 0x00, 0x00, 0x0e, 0x44, 0x44, - 0x30, 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x18, 0x44, 0x44, 0x18, 0x00, - 0x07, 0x06, 0x20, 0xe0, 0x3f, 0x30, 0xc4, 0x46, 0x0c, 0xf8, 0x1d, 0x04, - 0x30, 0x30, 0x60, 0x60, 0x8c, 0x63, 0x06, 0x0c, 0x30, 0x0c, 0x10, 0x18, - 0xc0, 0xc1, 0x08, 0x20, 0x82, 0x03, 0x20, 0x0c, 0x10, 0x0c, 0x00, 0x83, - 0x09, 0x20, 0xc3, 0x00, 0x60, 0x08, 0x18, 0x04, 0x00, 0x02, 0x8b, 0xa3, - 0x41, 0x00, 0x40, 0x18, 0x08, 0x06, 0x00, 0x06, 0x7a, 0xb6, 0x20, 0x00, - 0xc0, 0x10, 0x08, 0x02, 0x00, 0x0c, 0x3e, 0x7c, 0x30, 0x00, 0x80, 0x10, - 0x08, 0x02, 0x00, 0x18, 0x18, 0x18, 0x10, 0x00, 0x80, 0x10, 0x0c, 0x02, - 0x00, 0x30, 0x00, 0x00, 0x18, 0xc0, 0x83, 0x30, 0x04, 0xc3, 0x03, 0x20, - 0x00, 0x01, 0x0c, 0xc2, 0x83, 0x20, 0x04, 0xc1, 0x03, 0x61, 0x80, 0x03, - 0x06, 0xc6, 0x83, 0x20, 0x04, 0xc1, 0x83, 0x41, 0xc0, 0x07, 0x06, 0xc4, - 0x83, 0x20, 0x04, 0xc1, 0x87, 0xc0, 0x80, 0x03, 0x03, 0xc4, 0x80, 0x20, - 0x0c, 0x01, 0x84, 0x80, 0x00, 0x01, 0x01, 0x64, 0x80, 0x30, 0x08, 0x01, - 0x44, 0x80, 0x01, 0x80, 0x01, 0x24, 0x86, 0x10, 0x08, 0x01, 0x4c, 0x00, - 0x01, 0x80, 0x00, 0x34, 0x83, 0x10, 0x08, 0x61, 0x48, 0x00, 0x01, 0x80, - 0x00, 0xd4, 0xc1, 0x10, 0x08, 0xc1, 0x59, 0x00, 0x03, 0x80, 0x00, 0x5c, - 0x40, 0x10, 0x08, 0x01, 0x57, 0x00, 0x02, 0xc1, 0x00, 0x2c, 0x40, 0x10, - 0x18, 0x02, 0x7c, 0x00, 0x82, 0x43, 0x00, 0x3c, 0x40, 0x18, 0x10, 0x02, - 0x70, 0x00, 0xc6, 0x47, 0x00, 0x1c, 0x40, 0x18, 0x10, 0x02, 0x60, 0x00, - 0x84, 0x43, 0x00, 0x0e, 0x60, 0x08, 0x10, 0x06, 0x40, 0x00, 0x04, 0x41, - 0x00, 0x02, 0x20, 0x08, 0x10, 0x04, 0xc0, 0x00, 0x0c, 0x60, 0x00, 0x02, - 0x20, 0x0c, 0x30, 0x0c, 0x80, 0x00, 0x08, 0x20, 0x00, 0x03, 0x20, 0x0c, - 0x20, 0x08, 0x80, 0x01, 0x08, 0x20, 0x00, 0x01, 0x20, 0x04, 0x20, 0x08, - 0x00, 0x01, 0x08, 0x20, 0x80, 0x01, 0x30, 0x04, 0x60, 0x18, 0x00, 0x01, - 0x08, 0x20, 0x80, 0x00, 0x10, 0x06, 0x40, 0x10, 0x00, 0x03, 0x10, 0x11, - 0x80, 0x00, 0x18, 0x02, 0xc0, 0x30, 0x00, 0x02, 0x90, 0x13, 0xc0, 0x00, - 0x08, 0x03, 0x80, 0x20, 0x00, 0x06, 0x10, 0x11, 0x40, 0x00, 0x04, 0x01, - 0x80, 0x61, 0x00, 0x04, 0x10, 0x10, 0x60, 0x00, 0x84, 0x01, 0x00, 0x41, - 0x00, 0x04, 0x10, 0x10, 0x20, 0x00, 0xc6, 0x00, 0x00, 0x83, 0x00, 0x0c, - 0x10, 0x10, 0x20, 0x00, 0x41, 0x00, 0x00, 0x82, 0x01, 0x00, 0x10, 0x10, - 0x00, 0x80, 0x61, 0x00, 0x00, 0x06, 0x01, 0x00, 0x10, 0x10, 0x00, 0x80, - 0x30, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x10, 0x10, 0x00, 0xc0, 0x10, 0x00, - 0x00, 0x18, 0x02, 0xff, 0x1f, 0xf0, 0xff, 0x60, 0x18, 0x00, 0x00, 0x30, - 0xfe, 0x01, 0x00, 0x00, 0x80, 0x3f, 0x0c, 0x00, 0x00, 0x20, 0x00, 0x40, - 0x08, 0x21, 0x04, 0x00, 0x06, 0x00, 0x00, 0xc0, 0x00, 0xe2, 0x9c, 0x73, - 0x8e, 0x00, 0x03, 0x00, 0x00, 0x80, 0x11, 0x47, 0x08, 0x21, 0xc4, 0x11, - 0x01, 0x00, 0x00, 0x00, 0x3b, 0x02, 0x00, 0x00, 0x80, 0xb8, 0x00, 0x00, - 0x00, 0x00, 0x12, 0x00, 0xff, 0xff, 0x03, 0x90, 0x00, 0x00, 0x00, 0x00, - 0x02, 0xfc, 0x01, 0x00, 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x07, - 0x80, 0x03, 0x80, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xe0, 0x0f, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0xf8, 0x3f, 0x00, 0x5c, - 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0xe0, 0x0f, 0x00, 0x5f, 0x00, 0x00, - 0x00, 0x00, 0xfa, 0x03, 0x80, 0x03, 0xc0, 0x5f, 0x00, 0x00, 0x00, 0x00, - 0xfa, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, - 0xff, 0xff, 0x03, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfc, 0x01, 0x00, - 0xfe, 0x40, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x07, 0x00, 0x00, 0x80, 0x5f, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, - 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/king_small.bitmap b/gnu/games/chess/Xchess/king_small.bitmap deleted file mode 100644 index 38bb2b7e88b8..000000000000 --- a/gnu/games/chess/Xchess/king_small.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define king_small_width 32 -#define king_small_height 32 -static char king_small_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0x00, 0x00, 0x80, 0x9f, 0x00, 0x00, 0x70, 0x20, 0x00, - 0x00, 0x0c, 0x40, 0x00, 0x00, 0x02, 0x80, 0x01, 0x80, 0x01, 0x00, 0x03, - 0x40, 0x00, 0x00, 0x06, 0x40, 0x60, 0x30, 0x08, 0x20, 0x60, 0x30, 0x10, - 0x20, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x80, - 0x10, 0x00, 0x02, 0x80, 0x10, 0x00, 0x01, 0x80, 0x10, 0x01, 0x01, 0x80, - 0x10, 0x03, 0x1f, 0x84, 0x10, 0x02, 0x00, 0x84, 0x10, 0x06, 0x00, 0x86, - 0x20, 0x1c, 0x00, 0x42, 0x20, 0xf0, 0xff, 0x43, 0x20, 0x00, 0x00, 0x40, - 0x40, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x20, 0x80, 0x01, 0x00, 0x18, - 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/king_small_outline.bitmap b/gnu/games/chess/Xchess/king_small_outline.bitmap deleted file mode 100644 index 18d569e9d7b9..000000000000 --- a/gnu/games/chess/Xchess/king_small_outline.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define king_small_outline_width 32 -#define king_small_outline_height 32 -static char king_small_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x90, 0x00, 0x06, 0x10, 0xb1, 0x00, - 0x22, 0x12, 0xe1, 0x00, 0x24, 0x92, 0x9f, 0x00, 0x40, 0x72, 0xa0, 0x50, - 0x04, 0x0e, 0x40, 0x50, 0x40, 0x02, 0x80, 0x71, 0xc8, 0x01, 0x00, 0x73, - 0xd8, 0x00, 0x00, 0x46, 0xd8, 0x60, 0x30, 0x08, 0xa0, 0x60, 0x30, 0x10, - 0x20, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x80, - 0x10, 0x00, 0x02, 0x80, 0x10, 0x00, 0x01, 0x80, 0x10, 0x01, 0x01, 0x80, - 0x10, 0x03, 0x1f, 0x84, 0x10, 0x02, 0x00, 0x84, 0x10, 0x06, 0x00, 0x86, - 0x20, 0x1c, 0x00, 0x42, 0x20, 0xf0, 0xff, 0x43, 0x20, 0x00, 0x00, 0x40, - 0x40, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x20, 0x80, 0x01, 0x00, 0x18, - 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/knight.bitmap b/gnu/games/chess/Xchess/knight.bitmap deleted file mode 100644 index c5b1de1997f4..000000000000 --- a/gnu/games/chess/Xchess/knight.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define knight_width 80 -#define knight_height 80 -static char knight_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x18, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x38, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, - 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xe0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xbf, 0xff, - 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0xfe, 0x0f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xf8, 0xff, 0x01, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0x0f, 0xfc, 0xe3, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xf0, 0xe1, 0xf3, 0xcf, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfd, - 0xff, 0x1f, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0xfe, 0x7f, - 0xfe, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xff, 0x1f, 0xfe, 0xff, 0xfc, 0x07, - 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x7f, 0x00, 0x00, - 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xe7, 0x1f, 0x00, 0x00, 0x00, 0xe0, - 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0x03, 0x00, 0x00, 0xf0, 0xff, 0xff, - 0xff, 0xff, 0x9f, 0x3f, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, - 0x3f, 0xff, 0x07, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, - 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0x07, 0x00, - 0x00, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xfd, 0x01, 0x00, 0x00, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0xff, 0xfb, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xff, - 0xff, 0xbf, 0xff, 0xf3, 0x03, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x9f, - 0xff, 0xf7, 0x3f, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xef, - 0x07, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x7f, 0xf3, 0xff, 0xcf, 0x7f, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0x1f, 0xfd, 0xff, 0xdf, 0x07, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0x83, 0xff, 0xf3, 0x9f, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x7f, - 0x80, 0xff, 0xf9, 0xbf, 0x0f, 0x00, 0xf0, 0xff, 0xff, 0x00, 0x80, 0x7f, - 0xfc, 0x7f, 0xff, 0x01, 0xf8, 0x3f, 0x7f, 0x00, 0x80, 0x81, 0xff, 0x7f, - 0x1e, 0x00, 0x18, 0x9f, 0x3f, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0xfe, 0x07, - 0x98, 0x8f, 0x1f, 0x00, 0xc0, 0xff, 0xcf, 0x7f, 0x3e, 0x00, 0xf8, 0x87, - 0x0f, 0x00, 0xe0, 0xff, 0xe3, 0xff, 0xfe, 0x07, 0xf0, 0xc3, 0x07, 0x00, - 0xf0, 0x1f, 0xfc, 0xff, 0x3c, 0x00, 0xf0, 0xe1, 0x03, 0x00, 0xf0, 0xc0, - 0xff, 0xff, 0xfc, 0x0f, 0x60, 0xe0, 0x01, 0x00, 0xf8, 0xff, 0xff, 0xff, - 0x7c, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0x0f, - 0x00, 0x70, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x7c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xf9, 0x0f, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, - 0xff, 0xff, 0xf9, 0x0f, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, - 0xf9, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xf9, 0x1f, - 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x01, 0x00, 0x00, - 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x3f, 0x00, 0x00, 0x00, 0xf0, - 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, - 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, - 0xf3, 0x01, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, - 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf3, 0x01, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, - 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf3, 0x01, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, - 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, - 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xfc, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf3, 0x01, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/knight_mask.bitmap b/gnu/games/chess/Xchess/knight_mask.bitmap deleted file mode 100644 index 97d288c60554..000000000000 --- a/gnu/games/chess/Xchess/knight_mask.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define knight_mask_width 80 -#define knight_mask_height 80 -static char knight_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x0f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, - 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x7f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, - 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03, - 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, - 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, - 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xf8, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xfc, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x0f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, - 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xc0, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x7f, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x7f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xf8, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xf8, 0xff, 0xff, 0xff, - 0xc7, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfc, 0xff, 0xff, 0xff, 0xc1, 0xff, - 0xff, 0xff, 0xff, 0x03, 0xfc, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0xfc, 0xff, 0xff, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0xfc, 0xff, 0x7f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xdf, - 0x3f, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xef, 0x1f, 0x00, - 0xf8, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xf7, 0x0f, 0x00, 0xfc, 0xff, - 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xfb, 0x07, 0x00, 0xfc, 0xff, 0xff, 0xff, - 0xff, 0x1f, 0xf0, 0xf9, 0x03, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x1f, - 0x00, 0xf8, 0x01, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xf8, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x80, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x1f, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, - 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, - 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xfc, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, - 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, - 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, - 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, - 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf8, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, - 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/knight_outline.bitmap b/gnu/games/chess/Xchess/knight_outline.bitmap deleted file mode 100644 index a1ab938b773f..000000000000 --- a/gnu/games/chess/Xchess/knight_outline.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define knight_outline_width 80 -#define knight_outline_height 80 -static char knight_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x18, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x38, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, - 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf9, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x20, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x20, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x80, - 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0xf0, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x30, 0x58, 0x07, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x18, 0x4c, - 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x78, 0x07, 0x00, - 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x23, 0xe0, 0x01, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, - 0x00, 0xc0, 0x08, 0x00, 0x00, 0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x60, - 0x04, 0x00, 0x00, 0x40, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x30, 0x02, 0x00, - 0x00, 0x60, 0x00, 0x20, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x20, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x80, - 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x20, 0x00, 0x80, 0x07, 0x00, - 0x00, 0x26, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x13, - 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x1f, 0x00, 0x00, 0x09, 0x40, 0x00, - 0x00, 0x18, 0x08, 0x00, 0x02, 0x00, 0x80, 0x05, 0xc0, 0x00, 0x00, 0x0c, - 0x0c, 0x00, 0x3e, 0x00, 0x80, 0x00, 0x80, 0x00, 0xc0, 0x03, 0x06, 0x00, - 0x04, 0x00, 0xc0, 0x00, 0x80, 0x01, 0x70, 0x01, 0xc3, 0x00, 0x7c, 0x00, - 0x60, 0x00, 0x00, 0x03, 0x1e, 0x81, 0x41, 0x00, 0x04, 0x00, 0x20, 0x00, - 0x00, 0xce, 0x83, 0x61, 0x60, 0x00, 0xfc, 0x00, 0x30, 0x00, 0x80, 0x7f, - 0x80, 0x1c, 0x30, 0x00, 0x08, 0x00, 0x10, 0xe0, 0xc1, 0x00, 0x80, 0x07, - 0x10, 0x00, 0xf8, 0x01, 0x18, 0x30, 0x61, 0x00, 0x80, 0x00, 0x08, 0x00, - 0x10, 0x00, 0x08, 0x98, 0x31, 0x00, 0xc0, 0x00, 0x0c, 0x00, 0xf0, 0x07, - 0x08, 0x8c, 0x18, 0x00, 0x40, 0x00, 0x03, 0x00, 0x20, 0x00, 0x18, 0x86, - 0x0c, 0x00, 0x60, 0xc0, 0x01, 0x00, 0xe0, 0x07, 0x10, 0xc3, 0x06, 0x00, - 0x30, 0x30, 0x00, 0x00, 0x20, 0x00, 0xf0, 0x61, 0x02, 0x00, 0x10, 0x1e, - 0x00, 0x00, 0xe0, 0x0f, 0x60, 0x30, 0x02, 0x00, 0x98, 0x03, 0x00, 0x00, - 0x40, 0x00, 0x00, 0x10, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0x0f, - 0x00, 0xb0, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xc0, - 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, - 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f, - 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, - 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, - 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x20, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, - 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/knight_small.bitmap b/gnu/games/chess/Xchess/knight_small.bitmap deleted file mode 100644 index 77c74517f0f6..000000000000 --- a/gnu/games/chess/Xchess/knight_small.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define knight_small_width 32 -#define knight_small_height 32 -static char knight_small_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0x00, 0x00, 0xee, 0x7f, 0x02, - 0x00, 0xfe, 0x7f, 0x01, 0x00, 0xff, 0xff, 0x04, 0x00, 0xff, 0xff, 0x02, - 0x80, 0xff, 0xff, 0x09, 0xc0, 0xfc, 0xff, 0x07, 0xe0, 0xfc, 0xff, 0x11, - 0xe0, 0xff, 0xff, 0x0d, 0xe0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x3f, - 0xf0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x07, - 0xfc, 0xc7, 0xff, 0x7f, 0xfe, 0xc1, 0xff, 0x07, 0xfa, 0xc1, 0xff, 0x7f, - 0xce, 0xc0, 0xff, 0x07, 0x6c, 0xc0, 0xff, 0x7f, 0x28, 0xe0, 0xff, 0x07, - 0x00, 0xe0, 0xff, 0x7f, 0x00, 0xe0, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x7f, - 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x7f, 0x00, 0xf8, 0xff, 0x0f, - 0x00, 0xf8, 0xff, 0x7f, 0x00, 0xfc, 0xff, 0x0f, 0x00, 0xff, 0xff, 0x7f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/knight_small_outline.bitmap b/gnu/games/chess/Xchess/knight_small_outline.bitmap deleted file mode 100644 index c0e738c6db4c..000000000000 --- a/gnu/games/chess/Xchess/knight_small_outline.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define knight_small_outline_width 32 -#define knight_small_outline_height 32 -static char knight_small_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0x00, 0x00, 0xee, 0x7f, 0x02, - 0x00, 0x3a, 0x40, 0x01, 0x00, 0x03, 0xc0, 0x04, 0x00, 0x01, 0x80, 0x02, - 0x80, 0x01, 0x80, 0x09, 0xc0, 0x0c, 0x00, 0x07, 0x60, 0x0c, 0x00, 0x11, - 0x20, 0x00, 0x00, 0x0d, 0x20, 0x00, 0x00, 0x03, 0x30, 0x00, 0x00, 0x3e, - 0x10, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x7e, 0x18, 0x7c, 0x00, 0x04, - 0x0c, 0x47, 0x00, 0x7c, 0x06, 0x41, 0x00, 0x04, 0xf2, 0x41, 0x00, 0x7c, - 0xde, 0x40, 0x00, 0x04, 0x6c, 0x40, 0x00, 0x7c, 0x28, 0x60, 0x00, 0x04, - 0x00, 0x20, 0x00, 0x7c, 0x00, 0x20, 0x00, 0x08, 0x00, 0x30, 0x00, 0x78, - 0x00, 0x10, 0x00, 0x08, 0x00, 0x10, 0x00, 0x78, 0x00, 0x18, 0x00, 0x08, - 0x00, 0x08, 0x00, 0x78, 0x00, 0x0c, 0x00, 0x08, 0x00, 0xff, 0xff, 0x7f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/message.c b/gnu/games/chess/Xchess/message.c deleted file mode 100644 index f645f2d7251b..000000000000 --- a/gnu/games/chess/Xchess/message.c +++ /dev/null @@ -1,102 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: message.c,v 1.2 1993/08/02 17:20:52 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Do stuff with the message window. Font 0 is the normal font, font 1 - * is large, and font 2 is normal red. - */ - -#include "xchess.h" - -#define MESSAGE_HEADER "\n1 XChess Messages0\n" - -void -message_init(win) - windata *win; -{ - TxtGrab(win->display, win->messagewin, "xchess", win->medium, - win->textback.pixel, win->textcolor.pixel, - win->cursorcolor.pixel); - TxtAddFont(win->display, win->messagewin, 1, win->large, win->textcolor.pixel); - TxtAddFont(win->display, win->messagewin, 2, win->medium, win->errortext.pixel); - TxtAddFont(win->display, win->messagewin, 3, win->medium, win->playertext.pixel); - - TxtWriteStr(win->display, win->messagewin, MESSAGE_HEADER); - return; -} - -void -message_add(win, string, err) - windata *win; - char *string; - bool err; -{ - if (err) { - TxtWriteStr(win->display, win->messagewin, "2"); - TxtWriteStr(win->display, win->messagewin, string); - TxtWriteStr(win->display, win->messagewin, "0"); - XBell(win->display, 50); - } else - TxtWriteStr(win->display, win->messagewin, string); - - XSync(win->display, 0); - return; -} - -void -message_send(win, event) - windata *win; - XEvent *event; -{ - XKeyEvent *ev = &event->xkey; - KeySym keysym; - windata *ow = (win == win1) ? win2 : win1; - char buf[BSIZE], *s; - int i; - - i = XLookupString(ev, buf, sizeof(buf) - 1, &keysym, &s); - buf[i] = '\0'; - for (s = buf; *s; s++) - if (*s == '\r') - *s = '\n'; - else if (*s == '\177') - *s = ''; - - TxtWriteStr(win->display, win->messagewin, "3"); - TxtWriteStr(win->display, win->messagewin, buf); - TxtWriteStr(win->display, win->messagewin, "0"); - XSync(win->display, 0); - if (ow) { - TxtWriteStr(ow->display, ow->messagewin, "3"); - TxtWriteStr(ow->display, ow->messagewin, buf); - TxtWriteStr(ow->display, ow->messagewin, "0"); - XSync(ow->display, 0); - } - return; -} - diff --git a/gnu/games/chess/Xchess/parse.c b/gnu/games/chess/Xchess/parse.c deleted file mode 100644 index fc8a436c0835..000000000000 --- a/gnu/games/chess/Xchess/parse.c +++ /dev/null @@ -1,388 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: parse.c,v 1.2 1993/08/02 17:20:53 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Parse a sequence of chess moves... - */ - -#include "xchess.h" - -bool loading_flag = false; -bool loading_paused = false; - -static char *line; - -/* Load a record file in. This returns a number of things -- the board, the - * list of moves, and whose turn it is. - */ - -void -load_game(file) - char *file; -{ - FILE *fp; - char buf[BSIZE]; - bool eflag; - move *m; - board *tmpboard = alloc(board); - - if (eq(file, "xchess.game") && saveflag) { - message_add(win1, - "Oops, I just overwrote the\nfile xchess.game...\n", - true); - message_add(win1, "I hope you had another copy.\n", true); - return; - } - if (!(fp = fopen(file, "r"))) { - perror(file); - return; - } - - /* Get a few lines... */ - fgets(buf, BSIZE, fp); - message_add(win1, buf, false); - if (!oneboard) - message_add(win2, buf, false); - - fgets(buf, BSIZE, fp); - message_add(win1, buf, false); - if (!oneboard) - message_add(win2, buf, false); - - fgets(buf, BSIZE, fp); - if (eq(buf, "\tenglish\n")) - eflag = true; - else if (eq(buf, "\talgebraic\n")) - eflag = false; - else { - fprintf(stderr, "Can't decide whether this is english...\n"); - return; - } - - board_init(tmpboard); - line = NULL; - m = parse_file(fp, tmpboard, eflag); - tfree(tmpboard); - - /* Now apply these moves to the board we were given... */ - loading_flag = true; - while (m) { - if (!quickflag) - XSync(win1->display, 0); - win_process(true); - if (!quickflag) - sleep(1); - if (!loading_paused) { - prog_move(m); - m = m->next; - } - } - loading_flag = false; - if (line) - message_add(win1, line, false); - - while (fgets(buf, BSIZE, fp)) - message_add(win1, buf, false); - - fclose(fp); - - return; -} - -/* Given a starting position (usually the beginning board configuration), - * read in a file of moves. - */ - -move * -parse_file(fp, b, english) - FILE *fp; - board *b; - bool english; -{ - move *mvs = NULL, *end = NULL; - char buf[BSIZE], *s, *t; - - while (fgets(buf, BSIZE, fp)) { - if (*buf == '#') - continue; - s = buf; - - /* The move number... */ - if (!(t = gettok(&s))) - break; - if (!isdigit(*t)) { - line = copy(buf); - break; - } - - if (!(t = gettok(&s))) - break; - if (end) - end = end->next = (english ? parse_move(b, t, WHITE) : - parse_imove(b, t, WHITE)); - else - mvs = end = (english ? parse_move(b, t, WHITE) : - parse_imove(b, t, WHITE)); - if (!end) { - fprintf(stderr, "Can't parse %s\n", buf); - return (NULL); - } - board_move(b, end); - - if (!(t = gettok(&s))) - break; - if (end) - end = end->next = (english ? parse_move(b, t, BLACK) : - parse_imove(b, t, BLACK)); - else - mvs = end = (english ? parse_move(b, t, BLACK) : - parse_imove(b, t, BLACK)); - if (!end) { - fprintf(stderr, "Can't parse %s\n", buf); - return (NULL); - } - board_move(b, end); - } - - return (mvs); -} - -/* Parse a move. The move format accepted is as follows - - * move: spec-spec - * capture: specxspec - * kcastle: 2 o's - * qcastle: 3 o's - * A spec is either piece/pos, piece, or just pos. A pos consists of a column - * name followed by a row number. If the column name is kr, kn, kb, k, q, - * qb, qn, or qr, then the row number is according to the english system, - * or if it is a-h then it is according to the international system. - * - *** As of now the spec must include the position. - */ - -move * -parse_move(b, str, w) - board *b; - char *str; - color w; -{ - move *m = alloc(move); - char *s; - char spec1[16], spec2[16]; - int i, j; - -if (debug) fprintf(stderr, "parsing %s\n", str); - - /* Check for castles. */ - for (s = str, i = 0; *s; s++) - if ((*s == 'o') || (*s == 'O')) - i++; - if (i == 2) { - m->type = KCASTLE; - m->piece.type = KING; - m->piece.color = w; - return (m); - } else if (i == 3) { - m->type = QCASTLE; - m->piece.type = KING; - m->piece.color = w; - return (m); - } - if (index(str, '-')) - m->type = MOVE; - else if (index(str, 'x')) - m->type = CAPTURE; - else - return (NULL); - for (i = 0; str[i]; i++) - if ((str[i] == 'x') || (str[i] == '-')) - break; - else - spec1[i] = str[i]; - spec1[i] = '\0'; - for (i++, j = 0; str[i]; i++, j++) - if ((str[i] == 'x') || (str[i] == '-')) - break; - else - spec2[j] = str[i]; - spec2[j] = '\0'; - - /* Now decode the specifications. */ - s = spec1; - switch (*s) { - case 'p': case 'P': - m->piece.type = PAWN; break; - case 'r': case 'R': - m->piece.type = ROOK; break; - case 'n': case 'N': - m->piece.type = KNIGHT; break; - case 'b': case 'B': - m->piece.type = BISHOP; break; - case 'q': case 'Q': - m->piece.type = QUEEN; break; - case 'k': case 'K': - m->piece.type = KING; break; - default: - return (NULL); - } - m->piece.color = w; - s += 2; - - /* Now get the {q,k}{,b,n,r}n string... */ - if ((s[0] == 'q') && (s[1] == 'r')) - m->fromx = 0, s += 2; - else if ((s[0] == 'q') && (s[1] == 'n')) - m->fromx = 1, s += 2; - else if ((s[0] == 'q') && (s[1] == 'b')) - m->fromx = 2, s += 2; - else if ((s[0] == 'q') && isdigit(s[1])) - m->fromx = 3, s += 1; - else if ((s[0] == 'k') && isdigit(s[1])) - m->fromx = 4, s += 1; - else if ((s[0] == 'k') && (s[1] == 'b')) - m->fromx = 5, s += 2; - else if ((s[0] == 'k') && (s[1] == 'n')) - m->fromx = 6, s += 2; - else if ((s[0] == 'k') && (s[1] == 'r')) - m->fromx = 7, s += 2; - m->fromy = ((w == WHITE) ? (SIZE - atoi(s)) : (atoi(s) - 1)); - - if ((b->square[m->fromy][m->fromx].color != w) || - (b->square[m->fromy][m->fromx].type != m->piece.type)) { - fprintf(stderr, "Error: bad stuff\n"); - return (NULL); - } - - s = spec2; - if (m->type == CAPTURE) { - switch (*s) { - case 'p': case 'P': - m->taken.type = PAWN; break; - case 'r': case 'R': - m->taken.type = ROOK; break; - case 'n': case 'N': - m->taken.type = KNIGHT; break; - case 'b': case 'B': - m->taken.type = BISHOP; break; - case 'q': case 'Q': - m->taken.type = QUEEN; break; - case 'k': case 'K': - m->taken.type = KING; break; - default: - return (NULL); - } - m->taken.color = ((w == WHITE) ? BLACK : WHITE); - s += 2; - } - - /* Now get the {q,k}{,b,n,r}n string... */ - if ((s[0] == 'q') && (s[1] == 'r')) - m->tox = 0, s += 2; - else if ((s[0] == 'q') && (s[1] == 'n')) - m->tox = 1, s += 2; - else if ((s[0] == 'q') && (s[1] == 'b')) - m->tox = 2, s += 2; - else if ((s[0] == 'q') && isdigit(s[1])) - m->tox = 3, s += 1; - else if ((s[0] == 'k') && isdigit(s[1])) - m->tox = 4, s += 1; - else if ((s[0] == 'k') && (s[1] == 'b')) - m->tox = 5, s += 2; - else if ((s[0] == 'k') && (s[1] == 'n')) - m->tox = 6, s += 2; - else if ((s[0] == 'k') && (s[1] == 'r')) - m->tox = 7, s += 2; - m->toy = ((w == WHITE) ? (SIZE - atoi(s)) : (atoi(s) - 1)); - - if ((m->type == CAPTURE) && ((b->square[m->toy][m->tox].color != - m->taken.color) || (b->square[m->toy][m->tox].type != - m->taken.type))) { - fprintf(stderr, "Error: bad stuff\n"); - return (NULL); - } - - return (m); -} - -/* Parse an algebraic notation move. This is a lot easier... */ - -move * -parse_imove(b, buf, w) - board *b; - char *buf; - color w; -{ - char *s; - move *m = alloc(move); - int n; - -if (debug) fprintf(stderr, "(alg) parsing %s\n", buf); - - for (s = buf, n = 0; *s; s++) - if ((*s == 'o') || (*s == 'O')) - n++; - s = buf; - - if (n == 2) - m->type = KCASTLE; - else if (n == 3) - m->type = QCASTLE; - else { - m->fromx = *s++ - 'a'; - m->fromy = SIZE - (*s++ - '0'); - m->tox = *s++ - 'a'; - m->toy = SIZE - (*s++ - '0'); - m->piece = b->square[m->fromy][m->fromx]; - m->taken = b->square[m->toy][m->tox]; - if (m->taken.color == NONE) - m->type = MOVE; - else - m->type = CAPTURE; - /* for pawns we must account for en passant */ - if (m->piece.type == PAWN) { - if (m->type == MOVE && m->fromx != m->tox) { - m->enpassant = 1; - m->type = CAPTURE; - } - } - } - - if (m->piece.color != w) { - fprintf(stderr, "Error: parse_imove: piece of wrong color!\n"); - return (NULL); - } - if ((m->piece.type == KING) && (m->fromy == m->toy) && (m->fromx == 4) - && (m->tox == 6)) - m->type = KCASTLE; - else if ((m->piece.type == KING) && (m->fromy == m->toy) && - (m->fromx == 4) && (m->tox == 2)) - m->type = QCASTLE; - - return (m); -} - diff --git a/gnu/games/chess/Xchess/pawn.bitmap b/gnu/games/chess/Xchess/pawn.bitmap deleted file mode 100644 index 5c3ff76dbf68..000000000000 --- a/gnu/games/chess/Xchess/pawn.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define pawn_width 80 -#define pawn_height 80 -static char pawn_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, - 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, - 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, - 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, - 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, - 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, - 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, - 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, - 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, - 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, - 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0x80, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x03, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, - 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, - 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xfe, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x1f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/pawn_mask.bitmap b/gnu/games/chess/Xchess/pawn_mask.bitmap deleted file mode 100644 index 724875c59972..000000000000 --- a/gnu/games/chess/Xchess/pawn_mask.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define pawn_mask_width 80 -#define pawn_mask_height 80 -static char pawn_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, - 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x07, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, - 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, - 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, - 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, - 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, - 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, - 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, - 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, - 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, - 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, - 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, - 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, - 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, - 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x0f, - 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf0, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x0f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x3f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x3f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, - 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/pawn_outline.bitmap b/gnu/games/chess/Xchess/pawn_outline.bitmap deleted file mode 100644 index 0c4a3a13229a..000000000000 --- a/gnu/games/chess/Xchess/pawn_outline.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define pawn_outline_width 80 -#define pawn_outline_height 80 -static char pawn_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x70, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x80, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, - 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x20, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x20, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x40, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, - 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x30, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x78, 0xc0, 0x81, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0xc0, 0x7f, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, - 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, - 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/pawn_small.bitmap b/gnu/games/chess/Xchess/pawn_small.bitmap deleted file mode 100644 index 88ff7bbcd16f..000000000000 --- a/gnu/games/chess/Xchess/pawn_small.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define pawn_small_width 32 -#define pawn_small_height 32 -static char pawn_small_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xf0, 0x0f, 0x00, - 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, - 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf0, 0x0f, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x80, 0xff, 0xff, 0x01, - 0x80, 0xff, 0xff, 0x01, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, - 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xfc, 0x3f, 0x00, - 0x00, 0xff, 0xff, 0x00, 0xe0, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x0f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/pawn_small_outline.bitmap b/gnu/games/chess/Xchess/pawn_small_outline.bitmap deleted file mode 100644 index e860f43f3d50..000000000000 --- a/gnu/games/chess/Xchess/pawn_small_outline.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define pawn_small_outline_width 32 -#define pawn_small_outline_height 32 -static char pawn_small_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x30, 0x0c, 0x00, - 0x00, 0x18, 0x18, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00, - 0x00, 0x08, 0x10, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x30, 0x0c, 0x00, - 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x80, 0x3f, 0xfc, 0x01, - 0x80, 0x3f, 0xfc, 0x01, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, - 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, - 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, - 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, - 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x0c, 0x30, 0x00, - 0x00, 0x07, 0xe0, 0x00, 0xe0, 0x01, 0x80, 0x07, 0xf0, 0xff, 0xff, 0x0f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/popup.c b/gnu/games/chess/Xchess/popup.c deleted file mode 100644 index 2ff368ef9fb4..000000000000 --- a/gnu/games/chess/Xchess/popup.c +++ /dev/null @@ -1,113 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: popup.c,v 1.2 1993/08/02 17:20:55 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * faustus@cad.berkeley.edu, ucbvax!faustus - * Permission is granted to modify and re-distribute this code in any manner - * as long as this notice is preserved. All standard disclaimers apply. - * - * A simple pop-up menu system. - */ - -#include "xchess.h" - -/* Open a small window with some text in it and two buttons -- yes and no. - * Use black and white pixel, and the medium font. - */ - -bool -pop_question(win, text) - windata *win; - char *text; -{ - char *s, *t; - int nlines = 1, ncols = 0, i = 0, j; - int x, y; - Window w; - bool ch; - XEvent ev; - - for (s = text; *s; s++) { - if ((*s == '\n') && s[1]) - nlines++; - if ((*s == '\n') || !s[1]) { - if (i > ncols) - ncols = i; - i = 0; - } else - i++; - } - - if (ncols < 12) - ncols = 12; - nlines += 4; - ncols += 4; - - x = (BASE_WIDTH - ncols * win->medium->max_bounds.width) / 2; - y = (BASE_HEIGHT - nlines * win->medium->max_bounds.ascent) / 2; - - w = XCreateSimpleWindow(win->display, win->basewin, - x, y, ncols * win->medium->max_bounds.width, - nlines * win->medium->ascent, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - XMapRaised(win->display, w); - XSetFont(win->display, DefaultGC(win->display, 0), - win->medium->fid); - - for (i = 0, s = text; i < nlines - 4; i++) { - for (t = s, j = 0; *t && (*t != '\n'); t++, j++) - ; - XDrawString(win->display, w, DefaultGC(win->display, 0), - (ncols - j) / 2 * win->medium->max_bounds.width, - (i + 1) * win->medium->ascent, - s, j); - s = t + 1; - } - XDrawString(win->display, w, DefaultGC(win->display, 0), - (ncols - 8) * win->medium->max_bounds.width / 4, - (nlines - 2) * win->medium->ascent, - "YES", 3); - XDrawString(win->display, w, DefaultGC(win->display, 0), - (ncols - 4) * win->medium->max_bounds.width * 3 / 4, - (nlines - 2) * win->medium->ascent, - "NO", 2); - - XSync(win->display, 0); - XSelectInput(win->display, w, ButtonPressMask); - XWindowEvent(win->display, w, ButtonPressMask, &ev); - x = ev.xkey.x; - y = ev.xkey.y; - - if (x > ncols * win->medium->max_bounds.width / 2) - ch = false; - else - ch = true; - - XDestroyWindow(win->display, w); - XSync(win->display, 0); - return (ch); -} - diff --git a/gnu/games/chess/Xchess/program.c b/gnu/games/chess/Xchess/program.c deleted file mode 100644 index 00e3dd6c7eb7..000000000000 --- a/gnu/games/chess/Xchess/program.c +++ /dev/null @@ -1,201 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: program.c,v 1.2 1993/08/02 17:20:56 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * The interface to whichever chess playing program we are using... - */ - -#include "xchess.h" -#include -#include - -static int pid; -static FILE *from; -static FILE *to; -static bool easy = 1; - -bool -program_init(name) - char *name; -{ - int toprog[2], fromprog[2]; - char buf[BSIZE]; - char time[10]; - char moves[10]; - - pipe(toprog); - pipe(fromprog); - - if (!(pid = fork())) { - /* Start up the program. */ - dup2(toprog[0], 0); - dup2(fromprog[1], 1); - close(toprog[0]); - close(toprog[1]); - close(fromprog[0]); - close(fromprog[1]); - sprintf (time, "%d", timeunit/60); - sprintf (moves, "%d", movesperunit); - if (proghost) - execl("/usr/ucb/rsh", "rsh", proghost, name, - moves, time, - (char *) NULL); - else - execl(name, name, moves, time, (char *) NULL); - perror(name); - exit(1); - } - - close(toprog[0]); - close(fromprog[1]); - - from = fdopen(fromprog[0], "r"); - setbuf(from, NULL); - to = fdopen(toprog[1], "w"); - setbuf(to, NULL); - - /* Get the first line... */ - fgets(buf, BSIZE, from); - if (debug) - fprintf(stderr, "program says %s", buf); - if (blackflag) { - fputs("switch\n", to); - fflush(to); - fgets(buf, BSIZE, from); - if (debug) - fprintf(stderr, "program says %s", buf); - message_add(win1, "GNU Chess playing white\n", false); - } else - message_add(win1, "GNU Chess playing black\n", false); - - return (true); -} - -void -program_end() -{ - fclose(from); - fclose(to); - kill(pid, SIGTERM); - return; -} - -void -program_send(m) - move *m; -{ - char buf[BSIZE]; - - if ((m->type == MOVE) || (m->type == CAPTURE)) - sprintf(buf, "%c%d%c%d\n", 'a' + m->fromx, SIZE - m->fromy, - 'a' + m->tox, SIZE - m->toy); - else if (m->type == KCASTLE) - strcpy(buf, (m->piece.color == WHITE) ? "e1g1\n" : "e8g8\n"); - else if (m->type == QCASTLE) - strcpy(buf, (m->piece.color == WHITE) ? "e1c1\n" : "e8c8\n"); - - if (debug) - fprintf(stderr, "sending program %s", buf); - if (!easy) - kill (pid, SIGINT); - - fputs(buf, to); - fflush(to); - - /* One junk line... */ - fgets(buf, BSIZE, from); - if (debug) - fprintf(stderr, "program says %s", buf); - return; -} - -move * -program_get() -{ - int rfd = (1 << fileno(from)), wfd = 0, xfd = 0; - static struct timeval notime = { 0, 0 }; - char buf[BSIZE], *s; - move *m; - int i; - - /* Do a poll... */ - - if (!(i = select(32, &rfd, &wfd, &xfd, ¬ime)) && - !from->_cnt) { /* Bad stuff... */ - if (debug) - fprintf(stderr, "poll: nothing\n"); - return (NULL); - } - if (i == -1) { - perror("select"); - return (NULL); - } - - fgets(buf, BSIZE, from); - if (*buf == '\n' || *buf == '\0') { - message_add(win1, "program died", false); - return (NULL); - } - - if (debug) - fprintf(stderr, "got from program %s", buf); - - for (s = buf; !isalpha(*s); s++) - ; - m = parse_imove(chessboard, s, nexttomove); - if (m == NULL) - return (NULL); - - if (!valid_move(m, chessboard)) { - fprintf(stderr, "Error: move %s is invalid!!\n", buf); - return (NULL); - } - - /* - fgets(buf, BSIZE, from); - if (debug) - fprintf(stderr, "program says %s", buf); - */ - message_add(win1, buf, false); - return (m); -} - -void -program_undo() -{ - fputs("undo\n", to); - return; -} -void -program_easy (mode) - bool mode; - -{ - fputs("easy\n", to); - easy = mode; -} diff --git a/gnu/games/chess/Xchess/queen.bitmap b/gnu/games/chess/Xchess/queen.bitmap deleted file mode 100644 index ab3817a123a9..000000000000 --- a/gnu/games/chess/Xchess/queen.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define queen_width 80 -#define queen_height 80 -static char queen_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x80, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x80, 0x01, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x80, 0x01, 0x80, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0xf0, 0x01, 0xc0, 0x03, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0x00, 0xc0, 0x03, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, - 0xc0, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03, - 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x01, 0xc0, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, - 0xe0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xe0, 0x07, - 0xc0, 0x03, 0x00, 0x00, 0x1c, 0x00, 0xc0, 0x03, 0xe0, 0x07, 0xc0, 0x03, - 0x00, 0x00, 0x3e, 0x00, 0xc0, 0x03, 0xe0, 0x07, 0xc0, 0x03, 0x00, 0x0e, - 0x3e, 0x00, 0xc0, 0x07, 0xe0, 0x07, 0xe0, 0x03, 0x00, 0x1f, 0x3e, 0x00, - 0xc0, 0x07, 0xe0, 0x07, 0xe0, 0x03, 0x00, 0x1f, 0x3c, 0x00, 0xc0, 0x07, - 0xe0, 0x07, 0xe0, 0x03, 0x00, 0x1f, 0x70, 0x00, 0xc0, 0x0f, 0xe0, 0x07, - 0xf0, 0x03, 0x00, 0x0e, 0x60, 0x00, 0xc0, 0x0f, 0xe0, 0x07, 0xf0, 0x03, - 0x00, 0x03, 0xe0, 0x00, 0xc0, 0x0f, 0xf0, 0x0f, 0xf0, 0x03, 0x80, 0x03, - 0xc0, 0x01, 0xc0, 0x1f, 0xf0, 0x0f, 0xf8, 0x03, 0x80, 0x01, 0xc0, 0x01, - 0xc0, 0x1f, 0xf0, 0x0f, 0xf8, 0x03, 0xc0, 0x01, 0xc0, 0x03, 0xc0, 0x1f, - 0xf0, 0x0f, 0xf8, 0x03, 0xe0, 0x01, 0xc0, 0x07, 0xc0, 0x1f, 0xf0, 0x0f, - 0xf8, 0x03, 0xe0, 0x01, 0xc0, 0x07, 0xc0, 0x3f, 0xf0, 0x0f, 0xfc, 0x03, - 0xf0, 0x01, 0xc0, 0x0f, 0xc0, 0x3f, 0xf0, 0x0f, 0xfc, 0x03, 0xf8, 0x01, - 0x80, 0x1f, 0xc0, 0x3f, 0xf0, 0x0f, 0xfc, 0x03, 0xf8, 0x01, 0x80, 0x1f, - 0xc0, 0x7f, 0xf0, 0x0f, 0xfe, 0x03, 0xfc, 0x01, 0x80, 0x3f, 0xc0, 0x7f, - 0xf8, 0x1f, 0xfe, 0x03, 0xfc, 0x00, 0x80, 0x3f, 0xc0, 0x7f, 0xf8, 0x1f, - 0xfe, 0x03, 0xfe, 0x00, 0x80, 0x7f, 0xc0, 0xff, 0xf8, 0x1f, 0xff, 0x03, - 0xff, 0x00, 0x80, 0xff, 0xc0, 0xff, 0xf8, 0x1f, 0xff, 0x03, 0xff, 0x00, - 0x00, 0xff, 0xc0, 0xff, 0xf8, 0x1f, 0xff, 0x83, 0xff, 0x00, 0x00, 0xff, - 0xc1, 0xff, 0xf9, 0x9f, 0xff, 0x83, 0xff, 0x00, 0x00, 0xff, 0xc3, 0xff, - 0xf9, 0x9f, 0xff, 0xc3, 0xff, 0x00, 0x00, 0xff, 0xc3, 0xff, 0xf9, 0x9f, - 0xff, 0xe3, 0x7f, 0x00, 0x00, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xe3, - 0x7f, 0x00, 0x00, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x7f, 0x00, - 0x00, 0xfe, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x7f, 0x00, 0x00, 0xfe, - 0xdf, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x7f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, - 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x01, 0x80, - 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf8, 0xff, 0x03, 0xfc, 0x3f, 0xc0, 0xff, - 0x1f, 0x00, 0x00, 0xf0, 0x01, 0xf8, 0x7f, 0xfe, 0x1f, 0x80, 0x1f, 0x00, - 0x00, 0x30, 0xfc, 0xff, 0x1f, 0xf8, 0xff, 0x3f, 0x0c, 0x00, 0x00, 0xe0, - 0xe7, 0xff, 0x07, 0xe0, 0xff, 0xe7, 0x07, 0x00, 0x00, 0xc0, 0x81, 0xff, - 0x1f, 0xf8, 0xff, 0x81, 0x03, 0x00, 0x00, 0x80, 0x00, 0xfe, 0x7f, 0xfe, - 0x7f, 0x00, 0x03, 0x00, 0x00, 0x80, 0x81, 0xff, 0xff, 0xff, 0xff, 0x81, - 0x01, 0x00, 0x00, 0x00, 0xe7, 0xff, 0x01, 0x80, 0xff, 0xe7, 0x00, 0x00, - 0x00, 0x00, 0xff, 0x03, 0xfc, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x80, - 0x01, 0xf8, 0xff, 0xff, 0x1f, 0x80, 0x01, 0x00, 0x00, 0x80, 0xfc, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0x01, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, - 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xe0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/queen_mask.bitmap b/gnu/games/chess/Xchess/queen_mask.bitmap deleted file mode 100644 index 76a5904e8340..000000000000 --- a/gnu/games/chess/Xchess/queen_mask.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define queen_mask_width 80 -#define queen_mask_height 80 -static char queen_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x60, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, - 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x03, - 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x03, 0xc0, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xf8, 0x03, 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0xf8, 0x01, 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, - 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xe0, 0x07, - 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xe0, 0x07, 0x80, 0x07, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0xe0, 0x07, 0x80, 0x07, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0x03, 0xf0, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0x07, 0xf0, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, - 0xf0, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x7e, 0x00, 0xe0, 0x07, 0xf0, 0x0f, - 0xe0, 0x07, 0x00, 0x00, 0x7f, 0x00, 0xe0, 0x0f, 0xf0, 0x0f, 0xe0, 0x07, - 0x00, 0x1f, 0x7f, 0x00, 0xe0, 0x0f, 0xf0, 0x0f, 0xe0, 0x07, 0x80, 0x3f, - 0x7f, 0x00, 0xe0, 0x0f, 0xf0, 0x0f, 0xf0, 0x07, 0x80, 0x3f, 0x7f, 0x00, - 0xe0, 0x0f, 0xf0, 0x0f, 0xf0, 0x07, 0x80, 0x3f, 0xff, 0x00, 0xe0, 0x1f, - 0xf0, 0x0f, 0xf0, 0x07, 0x80, 0x3f, 0xfe, 0x00, 0xe0, 0x1f, 0xf0, 0x0f, - 0xf8, 0x07, 0x80, 0x1f, 0xfc, 0x01, 0xe0, 0x1f, 0xf8, 0x1f, 0xf8, 0x07, - 0x80, 0x1f, 0xf0, 0x03, 0xe0, 0x3f, 0xf8, 0x1f, 0xf8, 0x07, 0xc0, 0x0f, - 0xf0, 0x07, 0xe0, 0x3f, 0xf8, 0x1f, 0xfc, 0x07, 0xe0, 0x03, 0xe0, 0x07, - 0xe0, 0x3f, 0xf8, 0x1f, 0xfc, 0x07, 0xf0, 0x03, 0xe0, 0x0f, 0xe0, 0x7f, - 0xf8, 0x1f, 0xfc, 0x07, 0xf0, 0x03, 0xe0, 0x1f, 0xe0, 0x7f, 0xf8, 0x1f, - 0xfc, 0x07, 0xf8, 0x03, 0xe0, 0x1f, 0xe0, 0x7f, 0xf8, 0x1f, 0xfe, 0x07, - 0xf8, 0x03, 0xe0, 0x3f, 0xe0, 0x7f, 0xf8, 0x1f, 0xfe, 0x07, 0xfc, 0x03, - 0xe0, 0x3f, 0xe0, 0xff, 0xf8, 0x1f, 0xfe, 0x07, 0xfe, 0x03, 0xc0, 0x7f, - 0xe0, 0xff, 0xfc, 0x3f, 0xff, 0x07, 0xfe, 0x03, 0xc0, 0xff, 0xe0, 0xff, - 0xfd, 0x3f, 0xff, 0x07, 0xff, 0x03, 0xc0, 0xff, 0xe1, 0xff, 0xfd, 0xff, - 0xff, 0x87, 0xff, 0x03, 0xc0, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0x87, - 0xff, 0x01, 0xc0, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0x01, - 0xc0, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0x01, 0x80, 0xff, - 0xef, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xe7, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf7, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, - 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x7f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, - 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf8, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x07, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, - 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x03, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/queen_outline.bitmap b/gnu/games/chess/Xchess/queen_outline.bitmap deleted file mode 100644 index 2527216b3966..000000000000 --- a/gnu/games/chess/Xchess/queen_outline.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define queen_outline_width 80 -#define queen_outline_height 80 -static char queen_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x80, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x01, 0x80, 0x01, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x80, 0x01, 0x80, 0x0d, 0x00, 0x00, - 0x00, 0x00, 0xb0, 0x01, 0xc0, 0x03, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0x00, 0x40, 0x02, 0x80, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, - 0x40, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x02, - 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x02, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x02, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0x01, 0x40, 0x02, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x40, 0x02, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, - 0x60, 0x06, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40, 0x03, 0x20, 0x04, - 0xc0, 0x02, 0x00, 0x00, 0x1c, 0x00, 0x40, 0x02, 0x20, 0x04, 0x40, 0x02, - 0x00, 0x00, 0x36, 0x00, 0x40, 0x02, 0x20, 0x04, 0x40, 0x02, 0x00, 0x0e, - 0x22, 0x00, 0x40, 0x06, 0x20, 0x04, 0x60, 0x02, 0x00, 0x1b, 0x36, 0x00, - 0x40, 0x04, 0x20, 0x04, 0x20, 0x02, 0x00, 0x11, 0x3c, 0x00, 0x40, 0x04, - 0x20, 0x04, 0x20, 0x02, 0x00, 0x1b, 0x70, 0x00, 0x40, 0x0c, 0x20, 0x04, - 0x30, 0x02, 0x00, 0x0e, 0x60, 0x00, 0x40, 0x08, 0x20, 0x04, 0x10, 0x02, - 0x00, 0x03, 0xe0, 0x00, 0x40, 0x08, 0x30, 0x0c, 0x10, 0x02, 0x80, 0x03, - 0xc0, 0x01, 0x40, 0x18, 0x10, 0x08, 0x18, 0x02, 0x80, 0x01, 0x40, 0x01, - 0x40, 0x10, 0x10, 0x08, 0x08, 0x02, 0xc0, 0x01, 0x40, 0x03, 0x40, 0x10, - 0x10, 0x08, 0x08, 0x02, 0x60, 0x01, 0x40, 0x06, 0x40, 0x10, 0x10, 0x08, - 0x08, 0x02, 0x20, 0x01, 0x40, 0x04, 0x40, 0x30, 0x10, 0x08, 0x0c, 0x02, - 0x30, 0x01, 0xc0, 0x0c, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x18, 0x01, - 0x80, 0x18, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x08, 0x01, 0x80, 0x10, - 0x40, 0x60, 0x10, 0x08, 0x06, 0x02, 0x8c, 0x01, 0x80, 0x30, 0x40, 0x40, - 0x18, 0x18, 0x02, 0x02, 0x84, 0x00, 0x80, 0x20, 0x40, 0x40, 0x08, 0x10, - 0x02, 0x02, 0x86, 0x00, 0x80, 0x60, 0x40, 0xc0, 0x08, 0x10, 0x03, 0x02, - 0x83, 0x00, 0x80, 0xc1, 0x40, 0x80, 0x08, 0x10, 0x01, 0x02, 0x81, 0x00, - 0x00, 0x81, 0x40, 0x80, 0x08, 0x10, 0x01, 0x82, 0x81, 0x00, 0x00, 0x81, - 0x41, 0x80, 0x09, 0x90, 0x01, 0x82, 0x80, 0x00, 0x00, 0x01, 0x43, 0x00, - 0x09, 0x90, 0x00, 0xc2, 0xc0, 0x00, 0x00, 0x01, 0x42, 0x00, 0x09, 0x90, - 0x00, 0x62, 0x40, 0x00, 0x00, 0x01, 0x46, 0x00, 0x0f, 0xf0, 0x00, 0x22, - 0x40, 0x00, 0x00, 0x03, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x32, 0x40, 0x00, - 0x00, 0x02, 0x48, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x40, 0x00, 0x00, 0x02, - 0x58, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x40, 0x00, 0x00, 0x02, 0x70, 0x00, - 0x00, 0x00, 0x00, 0x0e, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, - 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0xfe, 0x7f, - 0x00, 0x00, 0x30, 0x00, 0x00, 0x18, 0x00, 0xfc, 0x03, 0xc0, 0x3f, 0x00, - 0x10, 0x00, 0x00, 0x10, 0xfe, 0x07, 0x80, 0x01, 0xe0, 0x7f, 0x18, 0x00, - 0x00, 0x30, 0x03, 0x00, 0xe0, 0x07, 0x00, 0xc0, 0x0c, 0x00, 0x00, 0x60, - 0x18, 0x00, 0xf8, 0x1f, 0x00, 0x18, 0x06, 0x00, 0x00, 0x40, 0x7e, 0x00, - 0xe0, 0x07, 0x00, 0x7e, 0x02, 0x00, 0x00, 0x40, 0xff, 0x01, 0x80, 0x01, - 0x80, 0xff, 0x02, 0x00, 0x00, 0x40, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e, - 0x02, 0x00, 0x00, 0xc0, 0x18, 0x00, 0xfe, 0x7f, 0x00, 0x18, 0x03, 0x00, - 0x00, 0x80, 0x00, 0xfc, 0x03, 0xc0, 0x3f, 0x00, 0x01, 0x00, 0x00, 0x80, - 0xfe, 0x07, 0x00, 0x00, 0xe0, 0x7f, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x60, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0xe0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/queen_small.bitmap b/gnu/games/chess/Xchess/queen_small.bitmap deleted file mode 100644 index d7ee50e9b820..000000000000 --- a/gnu/games/chess/Xchess/queen_small.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define queen_small_width 32 -#define queen_small_height 32 -static char queen_small_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, - 0x80, 0x81, 0xc0, 0x00, 0x80, 0x81, 0xc0, 0x00, 0x00, 0xc1, 0x41, 0x00, - 0x00, 0xc1, 0x41, 0x00, 0x02, 0xc3, 0x61, 0x20, 0x06, 0xc3, 0x61, 0x30, - 0x04, 0xc3, 0x61, 0x10, 0x0c, 0xc3, 0x61, 0x18, 0x08, 0xc7, 0x71, 0x08, - 0x18, 0xc6, 0x31, 0x0c, 0x38, 0xc6, 0x31, 0x0e, 0x30, 0xce, 0x39, 0x06, - 0x70, 0xce, 0x39, 0x07, 0x60, 0xee, 0x3b, 0x03, 0xe0, 0xee, 0xbb, 0x03, - 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x01, - 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0xff, 0x7f, 0x00, - 0x80, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/queen_small_outline.bitmap b/gnu/games/chess/Xchess/queen_small_outline.bitmap deleted file mode 100644 index 0b624b9587bc..000000000000 --- a/gnu/games/chess/Xchess/queen_small_outline.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define queen_small_outline_width 32 -#define queen_small_outline_height 32 -static char queen_small_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, - 0x80, 0x81, 0xc0, 0x00, 0x80, 0x81, 0xc0, 0x00, 0x00, 0xc1, 0x41, 0x00, - 0x00, 0x41, 0x41, 0x00, 0x02, 0x43, 0x61, 0x20, 0x06, 0x43, 0x61, 0x30, - 0x04, 0x43, 0x61, 0x10, 0x0c, 0x43, 0x61, 0x18, 0x08, 0x47, 0x71, 0x08, - 0x18, 0x46, 0x31, 0x0c, 0x38, 0x46, 0x31, 0x0e, 0x30, 0x4e, 0x39, 0x06, - 0x70, 0x4e, 0x29, 0x07, 0x60, 0x6a, 0x2b, 0x03, 0xe0, 0x2a, 0xab, 0x03, - 0xe0, 0x3b, 0xee, 0x03, 0x40, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x80, 0x01, - 0x80, 0xfc, 0x9f, 0x00, 0x80, 0x01, 0xc0, 0x00, 0x00, 0x01, 0x40, 0x00, - 0x80, 0xfd, 0xdf, 0x00, 0xf0, 0x00, 0x80, 0x07, 0xf0, 0xff, 0xff, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/record.c b/gnu/games/chess/Xchess/record.c deleted file mode 100644 index 3cd29b7d5219..000000000000 --- a/gnu/games/chess/Xchess/record.c +++ /dev/null @@ -1,316 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: record.c,v 1.2 1993/08/02 17:20:57 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Deal with recording moves. - */ - -#include "xchess.h" - -#undef smartass - -bool record_english = true; -char *record_file = DEF_RECORD_FILE; -int movenum = 0; -bool saveflag = false; - -static char *colnames[] = { "qr", "qn", "qb", "q", "k", "kb", "kn", "kr" } ; -static char *pcnames[] = { "P", "R", "N", "B", "Q", "K" } ; - -static char *movestring(); -static char *tstring(); -static FILE *backup; - -#define RECORD_HEADER "\n1 XChess Game Record0\n" - -void -record_init(win) - windata *win; -{ - int i; - - i = XTextWidth(win->medium, RECORD_HEADER, - sizeof(RECORD_HEADER) - 1); - i = (40 * win->small->max_bounds.width - i * - win->medium->max_bounds.width) / - win->medium->max_bounds.width / 2; - TxtGrab(win->display, win->recwin, "xchess", win->small, win->textback.pixel, - win->textcolor.pixel, win->cursorcolor.pixel); - TxtAddFont(win->display, win->recwin, 1, win->medium, win->textcolor.pixel); - for (; i > 0; i++) - TxtWriteStr(win->display, win->recwin, " "); - TxtWriteStr(win->display, win->recwin, RECORD_HEADER); - - if (saveflag) { - if (!(backup = fopen(record_file, "w"))) { - perror(record_file); - saveflag = false; - } else { - fprintf(backup, "X Chess -- %s\n", datestring()); - if (dispname2) - fprintf(backup, "\tWhite on %s, black on %s\n", - dispname1, dispname2); - else - fprintf(backup, "\tGame played on %s\n", - dispname1); - fprintf(backup, "\t%s\n", record_english ? "english" : - "algebraic"); - fflush(backup); - } - } - - movenum = 0; - return; -} - -void -record_reset() -{ - TxtWriteStr(win1->display, win1->recwin, "\n\n1 New Game0\n\n"); - if (!oneboard) { - TxtWriteStr(win2->display, win2->recwin, "\n\n1 New Game0\n\n"); - } - movenum = 0; - if (saveflag) { - fprintf(backup, "\n\nNew Game\n\n"); - fflush(backup); - } - return; -} - -void -record_end(s) - char *s; -{ - char buf[BSIZE]; - - sprintf(buf, "\n%s\n", s); - TxtWriteStr(win1->display, win1->recwin, s); - if (!oneboard) { - TxtWriteStr(win2->display, win2->recwin, s); - } - if (saveflag) { - fprintf(backup, "\n%s\n", s); - fprintf(backup, "Time: white: %s, ", tstring(whiteseconds)); - fprintf(backup, "black: %s\n", tstring(blackseconds)); - fclose(backup); - } - return; -} - -void -record_save() -{ - move *m; - FILE *fp; - int i; - char *s; - - if (!(fp = fopen(record_file, "w"))) { - perror(record_file); - return; - } - fprintf(fp, "X Chess -- %s\n", datestring()); - if (dispname2) - fprintf(fp, "\tWhite on %s, black on %s\n", - dispname1, dispname2); - else - fprintf(fp, "\tGame played on %s\n", dispname1); - fprintf(fp, "\t%s\n", record_english ? "english" : "algebraic"); - - for (m = moves, i = 1; m; i++) { - s = movestring(m); - fprintf(fp, "%2d. %-16s ", i, s); - m = m->next; - if (m) - s = movestring(m); - else - s = ""; - fprintf(fp, "%s\n", s); - if (m) - m = m->next; - } - fclose(fp); - return; -} - -void -record_move(m) - move *m; -{ - char *s, buf[BSIZE]; - - s = movestring(m); - - if (m->piece.color == WHITE) { - movenum++; - sprintf(buf, "%2d. %-16s ", movenum, s); - } else { - sprintf(buf, "%s\n", s); - } - TxtWriteStr(win1->display, win1->recwin, buf); - if (!oneboard) { - TxtWriteStr(win2->display, win2->recwin, buf); - } - if (saveflag) { - fprintf(backup, "%s", buf); - fflush(backup); - } - - return; -} - -void -record_back() -{ - extern move *lastmove; - move *m = lastmove; - char *s = movestring(m); - char buf[BSIZE]; - long i; - - if (m->piece.color == WHITE) { - sprintf(buf, "%2d. %-16s ", movenum, s); - } else { - sprintf(buf, "%s\n", s); - } - s = buf; - for (i = 0; *s != '\0'; i++) - *s++ = ''; /* control H, backspace */ - - TxtWriteStr(win1->display, win1->recwin, buf); - if (!oneboard) { - TxtWriteStr(win2->display, win2->recwin, buf); - } - - if (nexttomove == BLACK) - movenum--; - if (saveflag) { - fseek(backup, -i, 1); - fflush(backup); - } - - return; -} - -static char * -movestring(m) - move *m; -{ - int fy, ty; - static char buf[BSIZE]; - - if (!record_english || (m->piece.color == WHITE)) { - fy = SIZE - m->fromy; - ty = SIZE - m->toy; - } else { - fy = m->fromy + 1; - ty = m->toy + 1; - } - - switch (m->type) { - case MOVE: - if (record_english) - sprintf(buf, "%s/%s%d-%s%d%s", pcnames[(int) m->piece. - type], colnames[m->fromx], fy, - colnames[m->tox], ty, m->check ? "+" : - ""); - else - sprintf(buf, "%c%d%c%d", 'a' + m->fromx, fy, 'a' + - m->tox, ty); - break; - case CAPTURE: - if (record_english) - sprintf(buf, "%s/%s%dx%s/%s%d%s%s", - pcnames[(int) m->piece.type], - colnames[m->fromx], fy, - pcnames[(int) m->taken.type], - colnames[m->tox], ty, - m->enpassant ? "e.p." : "", - m->check ? "+" : ""); - else - sprintf(buf, "%c%d%c%d", 'a' + m->fromx, fy, 'a' + - m->tox, ty); - break; - - case KCASTLE: - if (record_english) - sprintf(buf, "O-O%s", m->check ? "ch" : ""); - else if (m->piece.color == WHITE) - strcpy(buf, "e1g1"); - else - strcpy(buf, "e8g8"); - break; - - case QCASTLE: - if (record_english) - sprintf(buf, "O-O-O%s", m->check ? "ch" : ""); - else if (m->piece.color == WHITE) - strcpy(buf, "e1c1"); - else - strcpy(buf, "e8c8"); - break; - - default: - sprintf(buf, "something strange"); - break; - } - if ((m->piece.type == PAWN) && (((m->piece.color == BLACK) && - (m->toy == 7)) || ((m->piece.color == WHITE) && - (m->toy == 0)))) - strcat(buf, "(Q)"); - -#ifdef smartass - if (!(random() % 50)) - strcat(buf, "?"); - else if (!(random() % 50)) - strcat(buf, "!"); - else if (!(random() % 500)) - strcat(buf, "???"); - else if (!(random() % 500)) - strcat(buf, "!!!"); -#endif smartass - - return (buf); -} - -static char * -tstring(s) - int s; -{ - static char buf[64]; - - if (s > 3600) - sprintf(buf, "%dh %dm %ds", s / 3600, (s % 3600) / 60, s % 60); - else if (s > 60) - sprintf(buf, "%dm %ds", (s % 3600) / 60, s % 60); - else - sprintf(buf, "%ds", s); - return (buf); -} - diff --git a/gnu/games/chess/Xchess/rook.bitmap b/gnu/games/chess/Xchess/rook.bitmap deleted file mode 100644 index f274614eb9cb..000000000000 --- a/gnu/games/chess/Xchess/rook.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define rook_width 80 -#define rook_height 80 -static char rook_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xf8, 0xff, 0x00, 0x3c, - 0x00, 0x00, 0x00, 0x80, 0xff, 0x01, 0xf8, 0xff, 0x00, 0xfc, 0x0f, 0x00, - 0x00, 0xc0, 0xff, 0x01, 0xf8, 0xff, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xc0, - 0xff, 0x01, 0xf8, 0xff, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0x01, - 0xf8, 0xff, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0x01, 0xff, 0xff, - 0x07, 0xfc, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0x01, 0x00, 0xfc, 0xfd, - 0x1f, 0x00, 0x00, 0xc0, 0xff, 0x07, 0xfc, 0xff, 0x01, 0xff, 0x1f, 0x00, - 0x00, 0xc0, 0x1f, 0xf0, 0xff, 0xff, 0x7f, 0xc0, 0x1f, 0x00, 0x00, 0x40, - 0xc0, 0xff, 0x07, 0x00, 0xff, 0x1f, 0x10, 0x00, 0x00, 0xc0, 0xff, 0x1f, - 0xf0, 0x7f, 0xc0, 0xff, 0x1f, 0x00, 0x00, 0xc0, 0x7f, 0xc0, 0xfd, 0xff, - 0x1d, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, - 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, - 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x7f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, - 0xff, 0xfe, 0x07, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, - 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, - 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, - 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, - 0x0f, 0x80, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xe0, 0x3f, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, - 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, - 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, - 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, - 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, - 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, - 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, - 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, - 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x07, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/rook_mask.bitmap b/gnu/games/chess/Xchess/rook_mask.bitmap deleted file mode 100644 index c04441655879..000000000000 --- a/gnu/games/chess/Xchess/rook_mask.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define rook_mask_width 80 -#define rook_mask_height 80 -static char rook_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xfc, 0xff, - 0x01, 0x7e, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x03, 0xfc, 0xff, 0x01, 0xfe, - 0x1f, 0x00, 0x00, 0xe0, 0xff, 0x03, 0xfc, 0xff, 0x01, 0xfe, 0x3f, 0x00, - 0x00, 0xe0, 0xff, 0x03, 0xfc, 0xff, 0x01, 0xfe, 0x3f, 0x00, 0x00, 0xe0, - 0xff, 0x03, 0xfc, 0xff, 0x1f, 0xfe, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0x83, - 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, - 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x3f, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, - 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, - 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, - 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x0f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x1f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/rook_outline.bitmap b/gnu/games/chess/Xchess/rook_outline.bitmap deleted file mode 100644 index f30107a3f277..000000000000 --- a/gnu/games/chess/Xchess/rook_outline.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define rook_outline_width 80 -#define rook_outline_height 80 -static char rook_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x08, 0x80, 0x00, 0x3c, - 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x08, 0x80, 0x00, 0xe4, 0x0f, 0x00, - 0x00, 0xc0, 0x00, 0x01, 0x08, 0x80, 0x00, 0x04, 0x18, 0x00, 0x00, 0x40, - 0x00, 0x01, 0x08, 0x80, 0x00, 0x04, 0x10, 0x00, 0x00, 0x40, 0x00, 0x01, - 0x08, 0x80, 0x00, 0x04, 0x10, 0x00, 0x00, 0x40, 0x00, 0x01, 0x0f, 0x80, - 0x07, 0x04, 0x10, 0x00, 0x00, 0x40, 0x00, 0xfd, 0x01, 0x00, 0xfc, 0x05, - 0x10, 0x00, 0x00, 0x40, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x10, 0x00, - 0x00, 0x40, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x10, 0x00, 0x00, 0x40, - 0x00, 0xf0, 0x07, 0x00, 0x7f, 0x00, 0x10, 0x00, 0x00, 0x40, 0xc0, 0x1f, - 0x00, 0x00, 0xc0, 0x1f, 0x10, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x02, 0x00, - 0x02, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, - 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, - 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x80, 0xff, 0xff, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, - 0x00, 0x01, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, - 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, - 0xf0, 0x7f, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x1f, 0xc0, - 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, - 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, - 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, - 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, - 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, - 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, - 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, - 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x07, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/rook_small.bitmap b/gnu/games/chess/Xchess/rook_small.bitmap deleted file mode 100644 index ddee75660d4b..000000000000 --- a/gnu/games/chess/Xchess/rook_small.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define rook_small_width 32 -#define rook_small_height 32 -static char rook_small_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x73, 0xce, 0x03, 0xc0, 0x73, 0xce, 0x03, 0xc0, 0x73, 0xce, 0x03, - 0xc0, 0x73, 0xce, 0x03, 0xc0, 0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x00, - 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, - 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, - 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, - 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, - 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, - 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, - 0xe0, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/rook_small_outline.bitmap b/gnu/games/chess/Xchess/rook_small_outline.bitmap deleted file mode 100644 index 523521b963b7..000000000000 --- a/gnu/games/chess/Xchess/rook_small_outline.bitmap +++ /dev/null @@ -1,15 +0,0 @@ - -#define rook_small_outline_width 32 -#define rook_small_outline_height 32 -static char rook_small_outline_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x73, 0xce, 0x03, 0x40, 0x52, 0x4a, 0x02, 0x40, 0x52, 0x4a, 0x02, - 0x40, 0x52, 0x4a, 0x02, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x01, 0x80, 0x00, - 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, - 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, - 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, - 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, - 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, - 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, - 0xe0, 0xff, 0xff, 0x07, 0x20, 0x00, 0x00, 0x04, 0xe0, 0xff, 0xff, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/scrollText.c b/gnu/games/chess/Xchess/scrollText.c deleted file mode 100644 index 06fc4f184379..000000000000 --- a/gnu/games/chess/Xchess/scrollText.c +++ /dev/null @@ -1,1862 +0,0 @@ -/* - * A Scrollable Text Output Window - * - * David Harrison - * University of California, Berkeley - * 1986 - * - * The following is an implementation for a scrollable text output - * system. It handles exposure events only (other interactions are - * under user control). For scrolling, a always present scroll bar - * is implemented. It detects size changes and compensates accordingly. - */ - -#ifndef lint -static char rcsid[] = "$Id: scrollText.c,v 1.2 1993/08/02 17:20:58 mycroft Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include -#include "scrollText.h" - -extern char *malloc(); -extern char *realloc(); -#define alloc(type) (type *) malloc(sizeof(type)) -#define numalloc(type, num) (type *) malloc((unsigned) (num * sizeof(type))) -#define MAXINT 2147483647 - -extern XAssocTable *XCreateAssocTable(); -extern caddr_t XLookUpAssoc(); - -static XAssocTable *textWindows = (XAssocTable *) 0; - -#define NOOPTION -1 /* Option hasn't been set yet */ -#define NORMSCROLL 0 /* Smooth scroll on LineToTop and TopToHere */ -#define JUMPSCROLL 1 /* Jump scrolling on LineToTop and TopToHere */ - -static int ScrollOption = NOOPTION; - -typedef char *Generic; - -#define DEFAULT_GC textInfo->fontGC[textInfo->curFont] - -#define BARSIZE 15 -#define BARBORDER 1 -#define MAXFONTS 8 -#define INITBUFSIZE 1024 -#define INITLINES 50 -#define INITEXPARY 50 -#define XPADDING 2 -#define YPADDING 2 -#define INTERLINE 5 -#define INTERSPACE 1 -#define CURSORWIDTH 2 -#define EXPANDPERCENT 40 -#define BUFSIZE 1024 -#define CUROFFSET 1 -#define MAXFOREIGN 250 -#define NOINDEX -1 - -/* The wrap line indicator */ -#define WRAPINDSIZE 7 -#define STEMOFFSET 5 -#define arrow_width 7 -#define arrow_height 5 -static char arrow_bits[] = { - 0x24, 0x26, 0x3f, 0x06, 0x04}; - -#define NEWLINE '\n' -#define BACKSPACE '\010' -#define NEWFONT '\006' -#define LOWCHAR '\040' -#define HIGHCHAR '\176' - -#define CHARMASK 0x00ff /* Character mask */ -#define FONTMASK 0x0700 /* Character font */ -#define FONTSHIFT 8 /* Shift amount */ - -#define WRAPFLAG 0x01 /* Line wrap flag */ - -/* - * Lines are represented by a pointer into the overall array of - * 16-bit characters. The lower eight bits is used to indicate the character - * (in ASCII), and the next two bits are used to indicate the font - * the character should be drawn in. - */ - -typedef struct txtLine { - int lineLength; /* Current line length */ - int lineHeight; /* Full height of line in pixels */ - int lineBaseLine; /* Current baseline of the line */ - int lineWidth; /* Drawing position at end of line */ - int lineText; /* Offset into master buffer */ - int lineFlags; /* Line wrap flag is here */ -}; - - -/* - * For ExposeCopy events, we queue up the redraw requests collapsing - * them into line redraw requests until the CopyExpose event arrives. - * The queue is represented as a dynamic array of the following - * structure: - */ - -typedef struct expEvent { - int lineIndex; /* Index of line to redraw */ - int ypos; /* Drawing position of line */ -}; - - -/* - * The text buffer is represented using a dynamic counted array - * of 16-bit quantities. This array expands as needed. - * For the screen representation, a dynamic counted array - * of line structures is used. This array points into the - * text buffer to denote the start of each line and its parameters. - * The windows are configured as one overall window which contains - * the scroll bar as a sub-window along its right edge. Thus, - * the text drawing space is actually w-BARSIZE. - */ - -#define NOTATBOTTOM 0x01 /* Need to scroll to bottom before appending */ -#define FONTNUMWAIT 0x02 /* Waiting for font number */ -#define COPYEXPOSE 0x04 /* Need to process a copy expose event */ -#define SCREENWRONG 0x08 /* TxtJamStr has invalidated screen contents */ - -typedef struct txtWin { - /* Basic text buffer */ - int bufAlloc; /* Allocated size of buffer */ - int bufSpot; /* Current writing position in buffer */ - short *mainBuffer; /* Main buffer of text */ - - /* Line information */ - int numLines; /* Number of display lines in buffer */ - int allocLines; /* Number of lines allocated */ - struct txtLine **txtBuffer; /* Dynamic array of lines */ - - /* Current Window display information */ - Window mainWindow; /* Text display window */ - Window scrollBar; /* Subwindow for scroll bar */ - Pixmap arrowMap; /* line wrap indicator */ - int bgPix, fgPix; /* Background and cursor */ - GC CursorGC; /* gc for the cursor */ - GC bgGC; /* gc for erasing things */ - GC fontGC[MAXFONTS]; /* gc for doing fonts */ - XFontStruct theFonts[MAXFONTS];/* Display fonts */ - int theColors[MAXFONTS]; /* foregrounds of the fonts */ - int curFont; /* current font for tracking */ - int w, h; /* Current size */ - int startLine; /* Top line in display */ - int endLine; /* Bottom line in display */ - int bottomSpace; /* Space at bottom of screen */ - int flagWord; /* If non-zero, not at end */ - - /* For handling ExposeCopy events */ - int exposeSize; /* Current size of array */ - int exposeAlloc; /* Allocated size */ - struct expEvent **exposeAry;/* Array of line indices */ - - /* Drawing position information */ - int curLine; /* Current line in buffer */ - int curX; /* Current horizontal positi */ - int curY; /* Current vertical drawing */ -}; - -/* Flags for the various basic character handling functions */ - -#define DODISP 0x01 /* Update the display */ -#define NONEWLINE 0x02 /* Dont append newline */ - - - -static int InitLine(newLine) -struct txtLine *newLine; /* Newly created line structure */ -/* - * This routine initializes a newly created line structure. - */ -{ - newLine->lineLength = 0; - newLine->lineHeight = 0; - newLine->lineBaseLine = 0; - newLine->lineWidth = XPADDING; - newLine->lineText = NOINDEX; - newLine->lineFlags = 0; - return 1; -} - - - - -int TxtGrab(display, txtWin, program, mainFont, bg, fg, cur) -Display *display; /* display window is on */ -Window txtWin; /* Window to take over as scrollable text */ -char *program; /* Program name for Xdefaults */ -XFontStruct *mainFont; /* Primary text font */ -int bg, fg, cur; /* Background, foreground, and cursor colors */ -/* - * This routine takes control of 'txtWin' and makes it into a scrollable - * text output window. It will create a sub-window for the scroll bar - * with a background of 'bg' and an bar with color 'fg'. Both fixed width - * and variable width fonts are supported. Additional fonts can be loaded - * using 'TxtAddFont'. Returns 0 if there were problems, non-zero if - * everything went ok. - */ -{ - struct txtWin *newWin; /* Text package specific information */ - XWindowAttributes winInfo; /* Window information */ - int index; - XGCValues gc_val; - - if (textWindows == (XAssocTable *) 0) { - textWindows = XCreateAssocTable(32); - if (textWindows == (XAssocTable *) 0) return(0); - } - if (XGetWindowAttributes(display, txtWin, &winInfo) == 0) return 0; - - if (ScrollOption == NOOPTION) { - /* Read to see if the user wants jump scrolling or not */ - if (XGetDefault(display, program, "JumpScroll")) { - ScrollOption = JUMPSCROLL; - } else { - ScrollOption = NORMSCROLL; - } - } - - /* Initialize local structure */ - newWin = alloc(struct txtWin); - - /* Initialize arrow pixmap */ - newWin->arrowMap = XCreatePixmapFromBitmapData(display, txtWin, - arrow_bits, - arrow_width, arrow_height, - cur, bg, - DisplayPlanes(display, 0)); - - newWin->bufAlloc = INITBUFSIZE; - newWin->bufSpot = 0; - newWin->mainBuffer = numalloc(short, INITBUFSIZE); - - newWin->numLines = 1; - newWin->allocLines = INITLINES; - newWin->txtBuffer = numalloc(struct txtLine *, INITLINES); - for (index = 0; index < INITLINES; index++) { - newWin->txtBuffer[index] = alloc(struct txtLine); - InitLine(newWin->txtBuffer[index]); - } - - /* Window display information */ - newWin->mainWindow = txtWin; - newWin->w = winInfo.width; - newWin->h = winInfo.height; - newWin->startLine = 0; - newWin->endLine = 0; - newWin->bottomSpace = winInfo.height - - YPADDING - mainFont->ascent - mainFont->descent - INTERLINE; - newWin->flagWord = 0; - newWin->bgPix = bg; - newWin->fgPix = fg; - - /* Scroll Bar Creation */ - newWin->scrollBar = XCreateSimpleWindow(display, txtWin, - winInfo.width - BARSIZE, - 0, BARSIZE - (2*BARBORDER), - winInfo.height - (2*BARBORDER), - BARBORDER, - fg, bg); - XSelectInput(display, newWin->scrollBar, ExposureMask|ButtonReleaseMask); - XMapRaised(display, newWin->scrollBar); - - /* Font and Color Initialization */ - newWin->theFonts[0] = *mainFont; - newWin->theColors[0] = fg; - gc_val.function = GXcopy; - gc_val.plane_mask = AllPlanes; - gc_val.foreground = fg; - gc_val.background = bg; - gc_val.graphics_exposures = 1; - gc_val.font = mainFont->fid; - gc_val.line_width = 1; - gc_val.line_style = LineSolid; - - newWin->fontGC[0] = XCreateGC(display, txtWin, - GCFunction | GCPlaneMask | - GCForeground | GCBackground | - GCGraphicsExposures | GCFont, - &gc_val); - - gc_val.foreground = cur; - newWin->CursorGC = XCreateGC(display, txtWin, - GCFunction | GCPlaneMask | - GCForeground | GCBackground | - GCLineStyle | GCLineWidth, - &gc_val); - - gc_val.foreground = bg; - newWin->bgGC = XCreateGC(display, txtWin, - GCFunction | GCPlaneMask | - GCForeground | GCBackground | - GCGraphicsExposures | GCFont, - &gc_val); - - - for (index = 1; index < MAXFONTS; index++) { - newWin->theFonts[index].fid = 0; - newWin->fontGC[index] = 0; - } - - - /* Initialize size of first line */ - newWin->txtBuffer[0]->lineHeight = newWin->theFonts[0].ascent + - newWin->theFonts[0].descent; - newWin->txtBuffer[0]->lineText = 0; - - /* ExposeCopy array initialization */ - newWin->exposeSize = 0; - newWin->exposeAlloc = INITEXPARY; - newWin->exposeAry = numalloc(struct expEvent *, INITEXPARY); - for (index = 0; index < newWin->exposeAlloc; index++) - newWin->exposeAry[index] = alloc(struct expEvent); - /* Put plus infinity in last slot for sorting purposes */ - newWin->exposeAry[0]->lineIndex = MAXINT; - - /* Drawing Position Information */ - newWin->curLine = 0; - newWin->curX = 0; - newWin->curY = YPADDING + mainFont->ascent + mainFont->descent; - - /* Attach it to both windows */ - XMakeAssoc(display, textWindows, (XID) txtWin, (caddr_t) newWin); - XMakeAssoc(display, textWindows, (XID) newWin->scrollBar, (caddr_t) newWin); - return 1; -} - - -int TxtRelease(display, w) -Display *display; -Window w; /* Window to release */ -/* - * This routine releases all resources associated with the - * specified window which are consumed by the text - * window package. This includes the entire text buffer, line start - * array, and the scroll bar window. However, the window - * itself is NOT destroyed. The routine will return zero if - * the window is not owned by the text window package. - */ -{ - struct txtWin *textInfo; - int index; - - if ((textInfo = (struct txtWin *) XLookUpAssoc(display, - textWindows, (XID) w)) == 0) - return 0; - - for (index = 0; index < MAXFONTS; index++) - if (textInfo->fontGC[index] != 0) - XFreeGC(display, textInfo->fontGC[index]); - - free((Generic) textInfo->mainBuffer); - for (index = 0; index < textInfo->numLines; index++) { - free((Generic) textInfo->txtBuffer[index]); - } - free((Generic) textInfo->txtBuffer); - XDestroyWindow(display, textInfo->scrollBar); - for (index = 0; index < textInfo->exposeSize; index++) { - free((Generic) textInfo->exposeAry[index]); - } - free((Generic) textInfo->exposeAry); - XDeleteAssoc(display, textWindows, (XID) w); - free((Generic) textInfo); - return 1; -} - - - -static int RecompBuffer(textInfo) -struct txtWin *textInfo; /* Text window information */ -/* - * This routine recomputes all line breaks in a buffer after - * a change in window size or font. This is done by throwing - * away the old line start array and recomputing it. Although - * a lot of this work is also done elsewhere, it has been included - * inline here for efficiency. - */ -{ - int startPos, endSize, linenum; - register int index, chsize, curfont; - register short *bufptr; - register XFontStruct *fontptr; - register struct txtLine *lineptr; - char theChar; - - /* Record the old position so we can come back to it */ - for (startPos = textInfo->txtBuffer[textInfo->startLine]->lineText; - (startPos > 0) && (textInfo->mainBuffer[startPos] != '\n'); - startPos--) - /* null loop body */; - - /* Clear out the old line start array */ - for (index = 0; index < textInfo->numLines; index++) { - InitLine(textInfo->txtBuffer[index]); - } - - /* Initialize first line */ - textInfo->txtBuffer[0]->lineHeight = - textInfo->theFonts[0].ascent + textInfo->theFonts[0].descent; - textInfo->txtBuffer[0]->lineText = 0; - - /* Process the text back into lines */ - endSize = textInfo->w - BARSIZE - WRAPINDSIZE; - bufptr = textInfo->mainBuffer; - lineptr = textInfo->txtBuffer[0]; - linenum = 0; - fontptr = &(textInfo->theFonts[0]); - curfont = 0; - for (index = 0; index < textInfo->bufSpot; index++) { - theChar = bufptr[index] & CHARMASK; - - if ((bufptr[index] & FONTMASK) != curfont) { - int newFontNum, heightDiff; - - /* Switch fonts */ - newFontNum = (bufptr[index] & FONTMASK) >> FONTSHIFT; - if (textInfo->theFonts[newFontNum].fid != 0) { - /* Valid font */ - curfont = bufptr[index] & FONTMASK; - fontptr = &(textInfo->theFonts[newFontNum]); - heightDiff = (fontptr->ascent + fontptr->descent) - - lineptr->lineHeight; - if (heightDiff < 0) heightDiff = 0; - lineptr->lineHeight += heightDiff; - } - } - if (theChar == '\n') { - /* Handle new line */ - if (linenum >= textInfo->allocLines-1) - /* Expand number of lines */ - ExpandLines(textInfo); - linenum++; - lineptr = textInfo->txtBuffer[linenum]; - /* Initialize next line */ - lineptr->lineHeight = fontptr->ascent + fontptr->descent; - lineptr->lineText = index+1; - /* Check to see if its the starting line */ - if (index == startPos) textInfo->startLine = linenum; - } else { - /* Handle normal character */ - chsize = CharSize(textInfo, linenum, index); - if (lineptr->lineWidth + chsize > endSize) { - /* Handle line wrap */ - lineptr->lineFlags |= WRAPFLAG; - if (linenum >= textInfo->allocLines-1) - /* Expand number of lines */ - ExpandLines(textInfo); - linenum++; - lineptr = textInfo->txtBuffer[linenum]; - /* Initialize next line */ - lineptr->lineHeight = fontptr->ascent + fontptr->descent; - lineptr->lineText = index; - lineptr->lineLength = 1; - lineptr->lineWidth += chsize; - } else { - /* Handle normal addition of character */ - lineptr->lineLength += 1; - lineptr->lineWidth += chsize; - } - } - } - /* We now have a valid line array. Let's clean up some other fields. */ - textInfo->numLines = linenum+1; - if (startPos == 0) { - textInfo->startLine = 0; - } - textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace)); - textInfo->curLine = linenum; - /* Check to see if we are at the bottom */ - if (textInfo->endLine >= textInfo->numLines-1) { - textInfo->curY = textInfo->h - textInfo->bottomSpace - - lineptr->lineHeight; - textInfo->flagWord &= (~NOTATBOTTOM); - } else { - textInfo->flagWord |= NOTATBOTTOM; - } - return 1; -} - - - - -int TxtAddFont(display, textWin, fontNumber, newFont, newColor) -Display *display; -Window textWin; /* Scrollable text window */ -int fontNumber; /* Place to add font (0-7) */ -XFontStruct *newFont; /* Font to add */ -int newColor; /* Color of font */ -/* - * This routine loads a new font so that it can be used in a previously - * created text window. There are eight font slots numbered 0 through 7. - * If there is already a font in the specified slot, it will be replaced - * and an automatic redraw of the window will take place. See TxtWriteStr - * for details on using alternate fonts. The color specifies the foreground - * color of the text. The default foreground color is used if this - * parameter is TXT_NO_COLOR. Returns a non-zero value if - * everything went well. - */ -{ - struct txtWin *textInfo; - int redrawFlag; - XGCValues gc_val; - - if ((fontNumber < 0) || (fontNumber >= MAXFONTS)) return 0; - if ((textInfo = (struct txtWin *) - XLookUpAssoc(display, textWindows, (XID) textWin)) == 0) - return 0; - if (newColor == TXT_NO_COLOR) { - newColor = textInfo->fgPix; - } - - gc_val.font = newFont->fid; - gc_val.foreground = newColor; - gc_val.background = textInfo->bgPix; - gc_val.plane_mask = AllPlanes; - gc_val.graphics_exposures = 1; - gc_val.function = GXcopy; - - if (textInfo->fontGC[fontNumber] != 0) - { - XChangeGC(display, textInfo->fontGC[fontNumber], - GCFont | GCForeground, &gc_val); - } - else - textInfo->fontGC[fontNumber] = XCreateGC(display, textWin, - GCFont | - GCForeground | - GCBackground | - GCFunction | - GCPlaneMask | - GCGraphicsExposures, - &gc_val); - - - redrawFlag = (textInfo->theFonts[fontNumber].fid != 0) && - (((newFont) && (newFont->fid != textInfo->theFonts[fontNumber].fid)) || - (newColor != textInfo->theColors[fontNumber])); - if (newFont) { - textInfo->theFonts[fontNumber] = *newFont; - } - textInfo->theColors[fontNumber] = newColor; - - if (redrawFlag) { - RecompBuffer(textInfo); - XClearWindow(display, textWin); - TxtRepaint(display, textWin); - } - return 1; -} - - - -int TxtWinP(display, w) -Display *display; -Window w; -/* - * Returns a non-zero value if the window has been previously grabbed - * using TxtGrab and 0 if it has not. - */ -{ - if (XLookUpAssoc(display, textWindows, (XID) w)) - return(1); - else return(0); -} - - - -static int FindEndLine(textInfo, botSpace) -struct txtWin *textInfo; -int *botSpace; -/* - * Given the starting line in 'textInfo->startLine', this routine - * determines the index of the last line that can be drawn given the - * current size of the screen. If there are not enough lines to - * fill the screen, the index of the last line will be returned. - * The amount of empty bottom space is returned in 'botSpace'. - */ -{ - int index, height, lineHeight; - - height = YPADDING; - index = textInfo->startLine; - while (index < textInfo->numLines) { - lineHeight = textInfo->txtBuffer[index]->lineHeight + INTERLINE; - if (height + lineHeight > textInfo->h) break; - height += lineHeight; - index++; - } - if (botSpace) { - *botSpace = textInfo->h - height; - } - return index - 1; -} - - - -static int UpdateScroll(display, textInfo) -Display *display; -struct txtWin *textInfo; /* Text window information */ -/* - * This routine computes the current extent of the scroll bar - * indicator and repaints the bar with the correct information. - */ -{ - int top, bottom; - - if (textInfo->numLines > 1) { - top = textInfo->startLine * (textInfo->h - 2*BARBORDER) / - (textInfo->numLines - 1); - bottom = textInfo->endLine * (textInfo->h - 2*BARBORDER) / - (textInfo->numLines - 1); - } else { - top = 0; - bottom = textInfo->h - (2*BARBORDER); - } - - /* Draw it - make sure there is a little padding */ - if (top == 0) top++; - if (bottom == textInfo->h-(2*BARBORDER)) bottom--; - - XFillRectangle(display, textInfo->scrollBar, - textInfo->bgGC, - 0, 0, BARSIZE, top-1); - XFillRectangle(display, textInfo->scrollBar, - DEFAULT_GC, top, BARSIZE - (2*BARBORDER) - 2, - bottom - top); - XFillRectangle(display, textInfo->scrollBar, DEFAULT_GC, - 0, bottom+1, BARSIZE, - textInfo->h - (2 * BARBORDER) - bottom); - - return 1; -} - - - - -int TxtClear(display, w) -Display *display; -Window w; -/* - * This routine clears a scrollable text window. It resets the current - * writing position to the upper left hand corner of the screen. - * NOTE: THIS ALSO CLEARS THE CONTENTS OF THE TEXT WINDOW BUFFER AND - * RESETS THE SCROLL BAR. Returns 0 if the window is not a text window. - * This should be used *instead* of XClear. - */ -{ - struct txtWin *textInfo; - int index; - - if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)) == 0) - return 0; - - /* Zero out the arrays */ - textInfo->bufSpot = 0; - for (index = 0; index < textInfo->numLines; index++) { - InitLine(textInfo->txtBuffer[index]); - } - textInfo->txtBuffer[0]->lineHeight = - textInfo->theFonts[textInfo->curFont].ascent + - textInfo->theFonts[textInfo->curFont].descent; - - textInfo->numLines = 1; - textInfo->startLine = 0; - textInfo->endLine = 0; - textInfo->curLine = 0; - textInfo->curX = 0; - textInfo->curY = YPADDING + textInfo->theFonts[textInfo->curFont].ascent - + textInfo->theFonts[textInfo->curFont].descent; - - textInfo->bottomSpace = textInfo->h - YPADDING - - textInfo->theFonts[textInfo->curFont].ascent - INTERLINE - - textInfo->theFonts[textInfo->curFont].descent; - /* Actually clear the window */ - XClearWindow(display, w); - - /* Draw the current cursor */ - XFillRectangle(display, w, textInfo->CursorGC, - XPADDING + CUROFFSET, textInfo->curY, - CURSORWIDTH, - textInfo->theFonts[textInfo->curFont].ascent + - textInfo->theFonts[textInfo->curFont].descent); - - /* Update the scroll bar */ - UpdateScroll(display, textInfo); - return 1; -} - - -static int WarpToBottom(display, textInfo) -Display *display; -struct txtWin *textInfo; /* Text Information */ -/* - * This routine causes the specified text window to display its - * last screen of information. It updates the scroll bar - * to the appropriate spot. The implementation scans backward - * through the buffer to find an appropriate starting spot for - * the window. - */ -{ - int index, height, lineHeight; - - index = textInfo->numLines-1; - height = 0; - while (index >= 0) { - lineHeight = textInfo->txtBuffer[index]->lineHeight + INTERLINE; - if (height + lineHeight > textInfo->h) break; - height += lineHeight; - index--; - } - textInfo->startLine = index + 1; - textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace)); - textInfo->curY = textInfo->h - textInfo->bottomSpace - - textInfo->txtBuffer[textInfo->endLine]->lineHeight; - XClearWindow(display, textInfo->mainWindow); - TxtRepaint(display, textInfo->mainWindow); - return 1; -} - - - -static int UpdateExposures(display, textInfo) -Display *display; -struct txtWin *textInfo; /* Text window information */ -/* - * Before a new scrolling action occurs, the text window package - * must handle all COPYEXPOSE events generated by the last scrolling - * action. This routine is called to do this. Foreign events (those - * not handled by TxtFilter) are queued up and replaced on the queue - * after the processing of the exposure events is complete. - */ -{ -#if 0 - XEvent foreignQueue[MAXFOREIGN]; - int index, lastItem = 0; - - while (textInfo->flagWord & COPYEXPOSE) { - XNextEvent(display, &(foreignQueue[lastItem])); - if (!TxtFilter(display, &(foreignQueue[lastItem]))) - lastItem++; - if (lastItem >= MAXFOREIGN) { - printf("Too many foreign events to queue!\n"); - textInfo->flagWord &= (~COPYEXPOSE); - } - } - for (index = 0; index < lastItem; index++) { - XPutBackEvent(display, &(foreignQueue[index])); - } -#endif - return 1; -} - - -static int ScrollDown(display,textInfo) -Display *display; -struct txtWin *textInfo; /* Text window information */ -/* - * This routine scrolls the indicated text window down by one - * line. The line below the current line must exist. The window - * is scrolled so that the line below the last line is fully - * displayed. This may cause many lines to scroll off the top. - * Scrolling is done using XCopyArea. The exposure events should - * be caught using ExposeCopy. - */ -{ - int lineSum, index, targetSpace, freeSpace, updateFlag; - - lineSum = 0; - if (textInfo->endLine + 1 >= textInfo->numLines) return 0; - targetSpace = textInfo->txtBuffer[textInfo->endLine+1]->lineHeight + - INTERLINE; - if (textInfo->bottomSpace < targetSpace) { - index = textInfo->startLine; - while (index < textInfo->endLine) { - lineSum += (textInfo->txtBuffer[index]->lineHeight + INTERLINE); - if (textInfo->bottomSpace + lineSum >= targetSpace) break; - index++; - } - - /* Must move upward by 'lineSum' pixels */ - XCopyArea(display, textInfo->mainWindow, textInfo->mainWindow, - DEFAULT_GC, 0, lineSum, - textInfo->w - BARSIZE, textInfo->h, - 0, 0); - - textInfo->flagWord |= COPYEXPOSE; - /* Repair the damage to the structures */ - textInfo->startLine = index + 1; - updateFlag = 1; - } else { - updateFlag = 0; - } - /* More lines might be able to fit. Let's check. */ - freeSpace = textInfo->bottomSpace + lineSum - targetSpace; - index = textInfo->endLine + 1; - while (index < textInfo->numLines-1) { - if (freeSpace - textInfo->txtBuffer[index+1]->lineHeight - INTERLINE < 0) - break; - freeSpace -= (textInfo->txtBuffer[index+1]->lineHeight + INTERLINE); - index++; - } - textInfo->endLine = index; - textInfo->bottomSpace = freeSpace; - if (updateFlag) { - UpdateExposures(display, textInfo); - } - UpdateScroll(display, textInfo); - return 1; -} - - - - -static int ExpandLines(textInfo) -struct txtWin *textInfo; /* Text Information */ -/* - * This routine allocates and initializes additional space in - * the line start array (txtBuffer). The new space - * is allocated using realloc. The expansion factor is a percentage - * given by EXPANDPERCENT. - */ -{ - int newSize, index; - - newSize = textInfo->allocLines; - newSize += (newSize * EXPANDPERCENT) / 100; - - textInfo->txtBuffer = (struct txtLine **) - realloc((char *) textInfo->txtBuffer, - (unsigned) (newSize * sizeof(struct txtLine *))); - for (index = textInfo->allocLines; index < newSize; index++) { - textInfo->txtBuffer[index] = alloc(struct txtLine); - InitLine(textInfo->txtBuffer[index]); - } - textInfo->allocLines = newSize; - return 1; -} - -static int ExpandBuffer(textInfo) -struct txtWin *textInfo; /* Text information */ -/* - * Expands the basic character buffer using realloc. The expansion - * factor is a percentage given by EXPANDPERCENT. - */ -{ - int newSize; - - newSize = textInfo->bufAlloc + (textInfo->bufAlloc * EXPANDPERCENT) / 100; - textInfo->mainBuffer = (short *) - realloc((char *) textInfo->mainBuffer, (unsigned) newSize * sizeof(short)); - textInfo->bufAlloc = newSize; - return 1; -} - - - -static int HandleNewLine(display, textInfo, flagWord) -Display *display; -struct txtWin *textInfo; /* Text Information */ -int flagWord; /* DODISP or NONEWLINE or both */ -/* - * This routine initializes the next line for drawing by setting - * its height to the current font height, scrolls the screen down - * one line, and updates the current drawing position to the - * left edge of the newly cleared line. If DODISP is specified, - * the screen will be updated (otherwise not). If NONEWLINE is - * specified, no newline character will be added to the text buffer - * (this is for line wrap). - */ -{ - struct txtLine *curLine, *nextLine; - - /* Check to see if a new line must be allocated */ - if (textInfo->curLine >= textInfo->allocLines-1) - /* Expand the number of lines */ - ExpandLines(textInfo); - textInfo->numLines += 1; - - /* Then we initialize the next line */ - nextLine = textInfo->txtBuffer[textInfo->numLines-1]; - nextLine->lineHeight = - textInfo->theFonts[textInfo->curFont].ascent + - textInfo->theFonts[textInfo->curFont].descent; - - curLine = textInfo->txtBuffer[textInfo->curLine]; - if (flagWord & DODISP) { - /* Scroll down a line if required */ - if ((textInfo->curY + curLine->lineHeight + - nextLine->lineHeight + (INTERLINE * 2)) > textInfo->h) - { - ScrollDown(display, textInfo); - } - else - { - /* Update the bottom space appropriately */ - textInfo->bottomSpace -= (nextLine->lineHeight + INTERLINE); - textInfo->endLine += 1; - } - /* Update drawing position */ - textInfo->curY = textInfo->h - - (textInfo->bottomSpace + nextLine->lineHeight); - } - - /* Move down a line */ - textInfo->curLine += 1; - if (!(flagWord & NONEWLINE)) { - /* Append end-of-line to text buffer */ - if (textInfo->bufSpot >= textInfo->bufAlloc) { - /* Allocate more space in main text buffer */ - ExpandBuffer(textInfo); - } - textInfo->mainBuffer[(textInfo->bufSpot)++] = - (textInfo->curFont << FONTSHIFT) | '\n'; - } - nextLine->lineText = textInfo->bufSpot; - textInfo->curX = 0; - return 1; -} - - - -static int CharSize(textInfo, lineNum, charNum) -struct txtWin *textInfo; /* Current Text Information */ -int lineNum; /* Line in buffer */ -int charNum; /* Character in line */ -/* - * This routine determines the size of the specified character. - * It takes in account the font of the character and whether its - * fixed or variable. The size includes INTERSPACE spacing between - * the characters. - */ -{ - register XFontStruct *charFont; - register short *theLine; - register short theChar; - - theLine = &(textInfo->mainBuffer[textInfo->txtBuffer[lineNum]->lineText]); - theChar = theLine[charNum] & CHARMASK; - charFont = &(textInfo->theFonts[(theChar & FONTMASK) >> FONTSHIFT]); - if (theChar <= charFont->min_char_or_byte2 || - theChar >= charFont->max_char_or_byte2 || - charFont->per_char == 0) - return charFont->max_bounds.width + 1; - else - return charFont->per_char[theChar].width + 1; -} - - - - - -static int HandleBackspace(display, textInfo, flagWord) -Display *display; -struct txtWin *textInfo; /* Text Information */ -int flagWord; /* DODISP or nothing */ -/* - * This routine handles a backspace found in the input stream. The - * character before the current writing position will be erased and - * the drawing position will move back one character. If the writing - * position is at the left margin, the drawing position will move - * up to the previous line. If it is a line that has been wrapped, - * the character at the end of the previous line will be erased. - */ -{ - struct txtLine *thisLine, *prevLine; - int chSize; - - thisLine = textInfo->txtBuffer[textInfo->curLine]; - /* First, determine whether we need to go back a line */ - if (thisLine->lineLength == 0) { - /* Bleep if at top of buffer */ - if (textInfo->curLine == 0) { - XBell(display, 50); - return 0; - } - - /* See if we have to scroll in the other direction */ - if ((flagWord & DODISP) && (textInfo->curY <= YPADDING)) { - /* This will display the last lines of the buffer */ - WarpToBottom(display, textInfo); - } - - /* Set drawing position at end of previous line */ - textInfo->curLine -= 1; - prevLine = textInfo->txtBuffer[textInfo->curLine]; - textInfo->numLines -= 1; - if (flagWord & DODISP) { - textInfo->curY -= (prevLine->lineHeight + INTERLINE); - textInfo->bottomSpace += (thisLine->lineHeight + INTERLINE); - textInfo->endLine -= 1; - } - - /* We are unlinewrapping if the previous line has flag set */ - if (prevLine->lineFlags & WRAPFLAG) { - /* Get rid of line wrap indicator */ - if (flagWord & DODISP) { - XFillRectangle(display, textInfo->mainWindow, - textInfo->bgGC, - textInfo->w - BARSIZE - WRAPINDSIZE, - textInfo->curY, WRAPINDSIZE, - prevLine->lineHeight); - } - prevLine->lineFlags &= (~WRAPFLAG); - /* Call recursively to wipe out the ending character */ - HandleBackspace(display, textInfo, flagWord); - } else { - /* Delete the end-of-line in the primary buffer */ - textInfo->bufSpot -= 1; - } - } else { - /* Normal deletion of character */ - chSize = - CharSize(textInfo, textInfo->curLine, - textInfo->txtBuffer[textInfo->curLine]->lineLength - 1); - /* Move back appropriate amount and wipe it out */ - thisLine->lineWidth -= chSize; - if (flagWord & DODISP) { - XFillRectangle(display, textInfo->mainWindow, - textInfo->bgGC, - thisLine->lineWidth, textInfo->curY, - chSize, thisLine->lineHeight); - } - /* Delete from buffer */ - textInfo->txtBuffer[textInfo->curLine]->lineLength -= 1; - textInfo->bufSpot -= 1; - } - return 1; -} - - - -static int DrawLineWrap(display, win, x, y, h, col) -Display *display; -Window win; /* What window to draw it in */ -int x, y; /* Position of upper left corner */ -int h; /* Height of indicator */ -int col; /* Color of indicator */ -/* - * This routine draws a line wrap indicator at the end of a line. - * Visually, it is an arrow of the specified height directly against - * the scroll bar border. The bitmap used for the arrow is stored - * in 'arrowMap' with size 'arrow_width' and 'arrow_height'. - */ -{ - struct txtWin *textInfo; - - textInfo = (struct txtWin *)XLookUpAssoc(display, textWindows, - (XID) win); - - /* First, draw the arrow */ - XCopyArea(display, textInfo->arrowMap, textInfo->mainWindow, - textInfo->CursorGC, - 0, 0, arrow_width, arrow_height, - x, y + h - arrow_height, 1); - - /* Then draw the stem */ - XDrawLine(display, textInfo->mainWindow, textInfo->CursorGC, - x + STEMOFFSET, y, - x + STEMOFFSET, y + h - arrow_height); - return 1; -} - - - - -static int DrawLine(display, textInfo, lineIndex, ypos) -Display *display; -struct txtWin *textInfo; /* Text window information */ -int lineIndex; /* Index of line to draw */ -int ypos; /* Y position for line */ -/* - * This routine destructively draws the indicated line in the - * indicated window at the indicated position. It does not - * clear to end of line however. It draws a line wrap indicator - * if needed but does not draw a cursor. - */ -{ - int index, startPos, curFont, theColor, curX, saveX, fontIndex; - struct txtLine *someLine; - char lineBuffer[BUFSIZE], *glyph; - short *linePointer; - XFontStruct *theFont; - XGCValues gc; - - /* First, we draw the text */ - index = 0; - curX = XPADDING; - someLine = textInfo->txtBuffer[lineIndex]; - linePointer = &(textInfo->mainBuffer[someLine->lineText]); - while (index < someLine->lineLength) { - startPos = index; - saveX = curX; - curFont = linePointer[index] & FONTMASK; - fontIndex = curFont >> FONTSHIFT; - theFont = &(textInfo->theFonts[fontIndex]); - theColor = textInfo->theColors[fontIndex]; - glyph = &(lineBuffer[0]); - while ((index < someLine->lineLength) && - ((linePointer[index] & FONTMASK) == curFont)) - { - *glyph = linePointer[index] & CHARMASK; - index++; - curX += CharSize(textInfo, lineIndex, index); - glyph++; - } - - /* Flush out the glyphs */ - XFillRectangle(display, textInfo->mainWindow, - textInfo->bgGC, - saveX, ypos, - textInfo->w - BARSIZE, - someLine->lineHeight + YPADDING + INTERLINE); - - XDrawString(display, textInfo->mainWindow, - textInfo->fontGC[fontIndex], - saveX, ypos, - lineBuffer, someLine->lineLength); - } - /* Then the line wrap indicator (if needed) */ - if (someLine->lineFlags & WRAPFLAG) { - DrawLineWrap(display, textInfo->mainWindow, - textInfo->w - BARSIZE - WRAPINDSIZE, - ypos, someLine->lineHeight, - textInfo->fgPix); - } - return 1; -} - - - - -static int HandleNewFont(display, fontNum, textInfo, flagWord) -Display *display; -int fontNum; /* Font number */ -struct txtWin *textInfo; /* Text information */ -int flagWord; /* DODISP or nothing */ -/* - * This routine handles a new font request. These requests take - * the form "^F". The parsing is done in TxtWriteStr. - * This routine is called only if the form is valid. It may return - * a failure (0 status) if the requested font is not loaded. - * If the new font is larger than any of the current - * fonts on the line, it will change the line height and redisplay - * the line. - */ -{ - struct txtLine *thisLine; - int heightDiff, baseDiff, redrawFlag; - - if (textInfo->theFonts[fontNum].fid == 0) { - return 0; - } else { - thisLine = textInfo->txtBuffer[textInfo->curLine]; - textInfo->curFont = fontNum; - redrawFlag = 0; - heightDiff = textInfo->theFonts[fontNum].ascent + - textInfo->theFonts[fontNum].descent - - thisLine->lineHeight; - - if (heightDiff > 0) { - redrawFlag = 1; - } else { - heightDiff = 0; - } - - if (redrawFlag) { - if (flagWord & DODISP) { - /* Clear current line */ - XFillRectangle(display, textInfo->mainWindow, - textInfo->bgGC, - 0, textInfo->curY, textInfo->w, - thisLine->lineHeight); - - /* Check to see if it requires scrolling */ - if ((textInfo->curY + thisLine->lineHeight + heightDiff + - INTERLINE) > textInfo->h) - { - /* - * General approach: "unscroll" the last line up - * and then call ScrollDown to do the right thing. - */ - textInfo->endLine -= 1; - textInfo->bottomSpace += thisLine->lineHeight + - INTERLINE; - - XFillRectangle(display, textInfo->mainWindow, - textInfo->bgGC, - 0, textInfo->h - textInfo->bottomSpace, - textInfo->w, textInfo->bottomSpace); - - thisLine->lineHeight += heightDiff; - ScrollDown(display, textInfo); - textInfo->curY = textInfo->h - - (textInfo->bottomSpace + INTERLINE + - thisLine->lineHeight); - } - else - { - /* Just update bottom space */ - textInfo->bottomSpace -= heightDiff; - thisLine->lineHeight += heightDiff; - } - /* Redraw the current line */ - DrawLine(display, textInfo, textInfo->curLine, textInfo->curY); - } else { - /* Just update line height */ - thisLine->lineHeight += heightDiff; - } - } - return 1; - } -} - - - -int TxtWriteStr(display, w, str) -Display *display; -Window w; /* Text window */ -register char *str; /* 0 terminated string */ -/* - * This routine writes a string to the specified text window. - * The following notes apply: - * - Text is always appended to the end of the text buffer. - * - If the scroll bar is positioned such that the end of the - * text is not visible, an automatic scroll to the bottom - * will be done before the appending of text. - * - Non-printable ASCII characters are not displayed. - * - The '\n' character causes the current text position to - * advance one line and start at the left. - * - Tabs are not supported. - * - Lines too long for the screen will be wrapped and a line wrap - * indication will be drawn. - * - Backspace clears the previous character. It will do the right - * thing if asked to backspace past a wrapped line. - * - A new font can be chosen using the sequence '^F' where - * is 0-7. The directive will be ignored if - * there is no font in the specified slot. - * Returns 0 if something went wrong. - */ -{ - register int fontIndex; - register struct txtWin *textInfo; - register struct txtLine *thisLine; - - if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)) == 0) - return 0; - - /* See if screen needs to be updated */ - if (textInfo->flagWord & SCREENWRONG) { - TxtRepaint(display, textInfo->mainWindow); - } - - /* See if we have to scroll down to the bottom */ - if (textInfo->flagWord & NOTATBOTTOM) { - WarpToBottom(display, textInfo); - textInfo->flagWord &= (~NOTATBOTTOM); - } - - /* Undraw the current cursor */ - thisLine = textInfo->txtBuffer[textInfo->curLine]; - - XFillRectangle(display, w, textInfo->bgGC, - thisLine->lineWidth + CUROFFSET, - textInfo->curY, - CURSORWIDTH, - thisLine->lineHeight); - - for ( /* str is ok */ ; (*str != 0) ; str++) { - /* Check to see if we are waiting on a font */ - if (textInfo->flagWord & FONTNUMWAIT) { - textInfo->flagWord &= (~FONTNUMWAIT); - fontIndex = *str - '0'; - if ((fontIndex >= 0) && (fontIndex < MAXFONTS)) { - /* Handle font -- go get next character */ - if (HandleNewFont(display, fontIndex, textInfo, DODISP)) - continue; - } - } - - /* Inline code for handling normal character case */ - if ((*str >= LOWCHAR) && (*str <= HIGHCHAR)) { - register XFontStruct *thisFont; - register struct txtLine *thisLine; - register int charWidth; - int thisColor; - - /* Determine size of character */ - thisFont = &(textInfo->theFonts[textInfo->curFont]); - thisColor = textInfo->theColors[textInfo->curFont]; - if (*str <= thisFont->min_char_or_byte2 || - *str >= thisFont->max_char_or_byte2 || - thisFont->per_char == 0) - charWidth = thisFont->max_bounds.width + 1; - else - charWidth = thisFont->per_char[*str].width + 1; - - /* Check to see if line wrap is required */ - thisLine = textInfo->txtBuffer[textInfo->curLine]; - if (thisLine->lineWidth + charWidth > - (textInfo->w-BARSIZE-WRAPINDSIZE)) - { - DrawLineWrap(display, textInfo->mainWindow, - textInfo->w-BARSIZE-WRAPINDSIZE, - textInfo->curY, thisLine->lineHeight, - textInfo->fgPix); - thisLine->lineFlags |= WRAPFLAG; - /* Handle the spacing problem the same way as a newline */ - HandleNewLine(display, textInfo, DODISP | NONEWLINE); - thisLine = textInfo->txtBuffer[textInfo->curLine]; - } - - /* Ready to draw character */ - XDrawString(display, textInfo->mainWindow, - DEFAULT_GC, - textInfo->curX += charWidth, - textInfo->curY + thisLine->lineHeight, - str, 1); - - /* Append character onto main buffer */ - if (textInfo->bufSpot >= textInfo->bufAlloc) - /* Make room for more characters */ - ExpandBuffer(textInfo); - textInfo->mainBuffer[(textInfo->bufSpot)++] = - (textInfo->curFont << FONTSHIFT) | (*str); - - /* Update the line start array */ - thisLine->lineLength += 1; - thisLine->lineWidth += charWidth; - } else if (*str == NEWLINE) { - HandleNewLine(display, textInfo, DODISP); - } else if (*str == NEWFONT) { - /* Go into waiting for font number mode */ - textInfo->flagWord |= FONTNUMWAIT; - } else if (*str == BACKSPACE) { - HandleBackspace(display, textInfo, DODISP); - } else { - /* Ignore all others */ - } - } - /* Draw the cursor in its new position */ - thisLine = textInfo->txtBuffer[textInfo->curLine]; - - XFillRectangle(display, w, textInfo->CursorGC, - thisLine->lineWidth + CUROFFSET, - textInfo->curY /* + thisLine->lineHeight */, - CURSORWIDTH, thisLine->lineHeight); - - return 1; -} - - - -int TxtJamStr(display, w, str) -Display *display; -Window w; /* Text window */ -register char *str; /* NULL terminated string */ -/* - * This is the same as TxtWriteStr except the screen is NOT updated. - * After a call to this routine, TxtRepaint should be called to - * update the screen. This routine is meant to be used to load - * a text buffer with information and then allow the user to - * scroll through it at will. - */ -{ - register int fontIndex; - register struct txtWin *textInfo; - - if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w) - ) == 0) - return 0; - - for ( /* str is ok */ ; (*str != 0) ; str++) { - /* Check to see if we are waiting on a font */ - if (textInfo->flagWord & FONTNUMWAIT) { - textInfo->flagWord &= (~FONTNUMWAIT); - fontIndex = *str - '0'; - if ((fontIndex >= 0) && (fontIndex < MAXFONTS)) { - if (HandleNewFont(display, fontIndex, textInfo, 0)) { - /* Handled font -- go get next character */ - continue; - } - } - } - /* Inline code for handling normal character case */ - if ((*str >= LOWCHAR) && (*str <= HIGHCHAR)) { - register XFontStruct *thisFont; - register struct txtLine *thisLine; - register int charWidth; - - /* Determine size of character */ - thisFont = &(textInfo->theFonts[textInfo->curFont]); - - if (*str <= thisFont->min_char_or_byte2 || - *str >= thisFont->max_char_or_byte2 || - thisFont->per_char == 0) - charWidth = thisFont->max_bounds.width + 1; - else - charWidth = thisFont->per_char[*str].width + 1; - - /* Check to see if line wrap is required */ - thisLine = textInfo->txtBuffer[textInfo->curLine]; - if (thisLine->lineWidth + charWidth > - (textInfo->w-BARSIZE-WRAPINDSIZE)) - { - thisLine->lineFlags |= WRAPFLAG; - /* Handle the spacing problem the same way as a newline */ - HandleNewLine(display, textInfo, NONEWLINE); - thisLine = textInfo->txtBuffer[textInfo->curLine]; - } - /* Append character onto main buffer */ - if (textInfo->bufSpot >= textInfo->bufAlloc) - /* Make room for more characters */ - ExpandBuffer(textInfo); - textInfo->mainBuffer[(textInfo->bufSpot)++] = - (textInfo->curFont << FONTSHIFT) | (*str); - - /* Update the line start array */ - thisLine->lineLength += 1; - thisLine->lineWidth += charWidth; - } else if (*str == NEWLINE) { - HandleNewLine(display, textInfo, 0); - } else if (*str == NEWFONT) { - /* Go into waiting for font number mode */ - textInfo->flagWord |= FONTNUMWAIT; - } else if (*str == BACKSPACE) { - HandleBackspace(display, textInfo, 0); - } else { - /* Ignore all others */ - } - } - textInfo->flagWord |= SCREENWRONG; - return 1; -} - - - -int TxtRepaint(display,w) -Display *display; -Window w; -/* - * Repaints the given scrollable text window. The routine repaints - * the entire window. For handling exposure events, the TxtFilter - * routine should be used. - */ -{ - struct txtWin *textInfo; - int index, ypos; - - if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w) - ) == 0) - return 0; - - /* Check to see if the screen is up to date */ - if (textInfo->flagWord & SCREENWRONG) { - textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace)); - textInfo->flagWord &= (~SCREENWRONG); - } - - ypos = YPADDING; - index = textInfo->startLine; - for (;;) { - DrawLine(display, textInfo, index, ypos); - if (index >= textInfo->endLine) break; - ypos += (textInfo->txtBuffer[index]->lineHeight + INTERLINE); - index++; - } - /* Draw the cursor (if on screen) */ - if (textInfo->endLine == textInfo->curLine) { - XFillRectangle(display, w, textInfo->CursorGC, - textInfo->txtBuffer[index]->lineWidth + CUROFFSET, - ypos /* + textInfo->txtBuffer[index]->lineHeight */, - CURSORWIDTH, textInfo->txtBuffer[index]->lineHeight); - - } - /* Update the scroll bar */ - UpdateScroll(display, textInfo); - return 1; -} - - - -static int InsertIndex(textInfo, thisIndex, ypos) -struct txtWin *textInfo; /* Text Window Information */ -int thisIndex; /* Line index of exposed line */ -int ypos; /* Drawing position of line */ -/* - * This routine inserts the supplied line index into the copy - * exposure array for 'textInfo'. The array is kept sorted - * from lowest to highest using insertion sort. The array - * is dynamically expanded if needed. - */ -{ - struct expEvent *newItem; - int newSize, index, downIndex; - - /* Check to see if we need to expand it */ - if ((textInfo->exposeSize + 3) >= textInfo->exposeAlloc) { - newSize = textInfo->exposeAlloc + - (textInfo->exposeAlloc * EXPANDPERCENT / 100); - textInfo->exposeAry = (struct expEvent **) - realloc((char *) textInfo->exposeAry, - (unsigned) (newSize * sizeof(struct expEvent *))); - for (index = textInfo->exposeAlloc; index < newSize; index++) - textInfo->exposeAry[index] = alloc(struct expEvent); - textInfo->exposeAlloc = newSize; - } - /* Find spot for insertion. NOTE: last spot has big number */ - for (index = 0; index <= textInfo->exposeSize; index++) { - if (textInfo->exposeAry[index]->lineIndex >= thisIndex) { - if (textInfo->exposeAry[index]->lineIndex > thisIndex) { - /* Insert before this entry */ - newItem = textInfo->exposeAry[textInfo->exposeSize+1]; - for (downIndex = textInfo->exposeSize; - downIndex >= index; - downIndex--) - { - textInfo->exposeAry[downIndex+1] = - textInfo->exposeAry[downIndex]; - } - /* Put a free structure at this spot */ - textInfo->exposeAry[index] = newItem; - /* Fill it in */ - textInfo->exposeAry[index]->lineIndex = thisIndex; - textInfo->exposeAry[index]->ypos = ypos; - /* Break out of loop */ - textInfo->exposeSize += 1; - } - break; - } - } - return 1; -} - - - -static int ScrollUp(display, textInfo) -Display *display; -struct txtWin *textInfo; /* Text window information */ -/* - * This routine scrolls the indicated text window up by one - * line. The line above the current line must exist. The - * window is scrolled so that the line above the start line - * is displayed at the top of the screen. This may cause - * many lines to scroll off the bottom. The scrolling is - * done using XCopyArea. The exposure events should be caught - * by ExposeCopy. - */ -{ - int targetSpace; - - /* Make sure all exposures have been handled by now */ - if (textInfo->startLine == 0) return 0; - targetSpace = textInfo->txtBuffer[textInfo->startLine-1]->lineHeight + - INTERLINE; - /* Move the area downward by the target amount */ - XCopyArea(display, textInfo->mainWindow, textInfo->mainWindow, - DEFAULT_GC, - 0, YPADDING, textInfo->w - BARSIZE, - textInfo->h, 0, targetSpace); - - textInfo->flagWord |= COPYEXPOSE; - /* Update the text window parameters */ - textInfo->startLine -= 1; - textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace)); - - /* Clear out bottom space region */ - XClearArea(display, textInfo->mainWindow, - 0, textInfo->h - textInfo->bottomSpace, - textInfo->w, textInfo->bottomSpace); - - UpdateExposures(display, textInfo); - UpdateScroll(display, textInfo); - - return 1; -} - - -static int ScrollToSpot(display, textInfo, ySpot) -Display *display; -struct txtWin *textInfo; /* Text window information */ -int ySpot; /* Button position in scroll window */ -/* - * This routine scrolls the specified text window relative to the - * position of the mouse in the scroll bar. The center of the screen - * will be positioned to correspond to the mouse position. - */ -{ - int targetLine, aboveLines; - - targetLine = textInfo->numLines * ySpot / textInfo->h; - textInfo->startLine = targetLine; - textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace)); - aboveLines = 0; - /* Make the target line the *center* of the window */ - while ((textInfo->startLine > 0) && - (aboveLines < textInfo->endLine - targetLine)) - { - textInfo->startLine -= 1; - textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace)); - aboveLines++; - } - if (textInfo->endLine == textInfo->numLines-1) { - WarpToBottom(display, textInfo); - } else { - XClearWindow(display, textInfo->mainWindow); - TxtRepaint(display, textInfo->mainWindow); - } - return 1; -} - - - -static int LineToTop(display, textInfo, pos) -Display *display; -struct txtWin *textInfo; /* Text window information */ -int pos; /* Y position of mouse */ -/* - * This routine scrolls the screen down until the line at the - * mouse position is at the top of the screen. It stops - * if it can't scroll the buffer down that far. If the - * global 'ScrollOption' is NORMSCROLL, a smooth scroll - * is used. Otherwise, it jumps to the right position - * and repaints the screen. - */ -{ - int index, sum; - - /* First, we find the current line */ - sum = 0; - for (index = textInfo->startLine; index <= textInfo->endLine; index++) { - if (sum + textInfo->txtBuffer[index]->lineHeight + INTERLINE> pos) break; - sum += textInfo->txtBuffer[index]->lineHeight + INTERLINE; - } - /* We always want to scroll down at least one line */ - if (index == textInfo->startLine) index++; - if (ScrollOption == NORMSCROLL) { - /* Scroll down until 'index' is the starting line */ - while ((textInfo->startLine < index) && ScrollDown(display, textInfo)) - { - /* Empty Loop Body */ - } - } else { - /* Immediately jump to correct spot */ - textInfo->startLine = index; - textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace)); - if (textInfo->endLine == textInfo->numLines-1) { - WarpToBottom(display, textInfo); - } else { - XClearWindow(display, textInfo->mainWindow); - TxtRepaint(display, textInfo->mainWindow); - } - } - /* Check to see if at end of buffer */ - if (textInfo->endLine >= textInfo->numLines-1) { - textInfo->flagWord &= (~NOTATBOTTOM); - } - return 1; -} - - - -static int TopToHere(display, textInfo, pos) -Display *display; -struct txtWin *textInfo; /* Text window information */ -int pos; /* Y position of mouse */ -/* - * This routine scrolls the screen up until the top line of - * the screen is at the current Y position of the mouse. Again, - * it will stop if it can't scroll that far. If the global - * 'ScrollOption' is NORMSCROLL, a smooth scroll is used. - * If it's not, it will simply redraw the screen at the - * correct spot. - */ -{ - int sum, target, linesup, index; - - target = pos - textInfo->txtBuffer[textInfo->startLine]->lineHeight; - /* We always want to scroll up at least one line */ - if (target <= 0) target = 1; - sum = 0; - linesup = 0; - /* Check to see if we are at the top anyway */ - if (textInfo->startLine == 0) return 0; - if (ScrollOption == NORMSCROLL) { - /* Scroll up until sum of new top lines greater than target */ - while ((sum < target) && ScrollUp(display, textInfo)) { - sum += textInfo->txtBuffer[textInfo->startLine]->lineHeight; - linesup++; - } - } else { - /* Search backward to find index */ - index = textInfo->startLine - 1; - while ((index > 0) && (sum < target)) { - sum += textInfo->txtBuffer[index]->lineHeight; - linesup++; - index--; - } - /* Go directly to the index */ - textInfo->startLine = index; - textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace)); - XClearWindow(display, textInfo->mainWindow); - TxtRepaint(display, textInfo->mainWindow); - } - /* If we scrolled, assert we are not at bottom of buffer */ - if (linesup > 0) { - textInfo->flagWord |= NOTATBOTTOM; - } - return 1; -} - - - -int TxtFilter(display, evt) -Display *display; -XEvent *evt; -/* - * This routine handles events associated with scrollable text windows. - * It will handle all exposure events and any button released events - * in the scroll bar of a text window. It does NOT handle any other - * events. If it cannot handle the event, it will return 0. - */ -{ - XExposeEvent *expose = &evt->xexpose; - XButtonEvent *btEvt = &evt->xbutton; - XGraphicsExposeEvent *gexpose = &evt->xgraphicsexpose; - XNoExposeEvent *noexpose = &evt->xnoexpose; - struct txtWin *textInfo; - int index, ypos; - Window w, sw; - - if (textWindows == (XAssocTable *) 0) { - textWindows = XCreateAssocTable(32); - if (textWindows == (XAssocTable *) 0) return(0); - } - if (evt->type == Expose) { - w = expose->window; - sw = 0; - } - else if (evt->type == GraphicsExpose) { - w = gexpose->drawable; - sw = 0; - } - else if (evt->type == NoExpose) { - w = noexpose->drawable; - sw = 0; - } - else if (evt->type == ButtonRelease) { - w = btEvt->window; - sw = btEvt->subwindow; - } - else - return 0; - - if ((textInfo = (struct txtWin *) - XLookUpAssoc(display, textWindows, (XID) w)) == 0) - return 0; - - /* Determine whether it's main window or not */ - if ((w == textInfo->mainWindow) && (sw == 0)) { - /* Main Window - handle exposures */ - switch (evt->type) { - case Expose: - ypos = 0 /*YPADDING*/; - for (index = textInfo->startLine; - index <= textInfo->endLine; - index++) - { - int lh = textInfo->txtBuffer[index]->lineHeight; - - if (((ypos + lh) >= expose->y) && - (ypos <= (expose->y + expose->height))) - { - /* Intersection region */ - /* Draw line immediately */ - DrawLine(display, textInfo, index, ypos); - /* And possibly draw cursor */ - if (textInfo->curLine == index) { - XFillRectangle(display, w, textInfo->CursorGC, - textInfo->txtBuffer[index]->lineWidth + - CUROFFSET, - ypos, - CURSORWIDTH, - lh); - } - } - ypos += lh + INTERLINE; - } - break; - case GraphicsExpose: - ypos = 0 /*YPADDING*/; - for (index = textInfo->startLine; - index <= textInfo->endLine; - index++) - { - int lh = textInfo->txtBuffer[index]->lineHeight; - - if (((ypos + lh) >= gexpose->y) && - (ypos <= (gexpose->y + gexpose->height))) - { - /* Intersection region */ - /* Draw line immediately */ - DrawLine(display, textInfo, index, ypos); - /* And possibly draw cursor */ - if (textInfo->curLine == index) { - XFillRectangle(display, w, textInfo->CursorGC, - textInfo->txtBuffer[index]->lineWidth + - CUROFFSET, - ypos, - CURSORWIDTH, - lh); - } - } - ypos += lh + INTERLINE; - } - break; - case NoExpose: - break; - default: - /* Not one of our events */ - return 0; - } - } else { - switch (evt->type) { - case Expose: - UpdateScroll(display, textInfo); - break; - case ButtonRelease: - /* Find out which button */ - switch (btEvt->button) { - case Button1: - /* Scroll up until top line is at mouse position */ - TopToHere(display, textInfo, btEvt->y); - break; - case Button2: - /* Scroll to spot relative to position */ - ScrollToSpot(display, textInfo, btEvt->y); - if (textInfo->endLine >= textInfo->numLines-1) { - textInfo->flagWord &= (~NOTATBOTTOM); - } else { - textInfo->flagWord |= NOTATBOTTOM; - } - break; - case Button3: - /* Scroll down until pointed line is at top */ - LineToTop(display, textInfo, btEvt->y); - break; - } - break; - default: - /* Not one of our events */ - return 0; - } - } - return 1; -} diff --git a/gnu/games/chess/Xchess/scrollText.h b/gnu/games/chess/Xchess/scrollText.h deleted file mode 100644 index 4346e09b1a7f..000000000000 --- a/gnu/games/chess/Xchess/scrollText.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Scrollable Text Window Header File - * - * David Harrison - * University of California, Berkeley - * 1986 - * - * This file contains definitions for a scrollable text window - * with scroll bar support. - * - * $Id: scrollText.h,v 1.2 1993/08/02 17:21:00 mycroft Exp $ - */ - -int TxtGrab(); - /* Take hold of a previously created window */ - -#define TXT_NO_COLOR -1 - -int TxtAddFont(); - /* Loads a new font for use later */ -int TxtWinP(); - /* Returns non-zero value if the window is text window */ -int TxtClear(); - /* Clears text window and resets text buffer */ - -int TxtWriteStr(); - /* Writes a string to window with immediate update */ -int TxtJamStr(); - /* Write a string without causing update to screen */ - -int TxtRepaint(); - /* Repaints entire scrollable text window */ -int TxtFilter(); - /* Handles events related to text window */ diff --git a/gnu/games/chess/Xchess/shade.bitmap b/gnu/games/chess/Xchess/shade.bitmap deleted file mode 100644 index a32ac80611ce..000000000000 --- a/gnu/games/chess/Xchess/shade.bitmap +++ /dev/null @@ -1,71 +0,0 @@ - -#define shade_width 80 -#define shade_height 80 -static char shade_bits[] = { - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88}; diff --git a/gnu/games/chess/Xchess/std.c b/gnu/games/chess/Xchess/std.c deleted file mode 100644 index 7e6d26ee5195..000000000000 --- a/gnu/games/chess/Xchess/std.c +++ /dev/null @@ -1,426 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: std.c,v 1.2 1993/08/02 17:21:01 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group - * - * Utility routines. - */ - -#include "std.h" - -#ifndef IBMPC -#include -#endif not IBMPC -#ifdef UNIX -#include -#include -#endif UNIX -#ifdef BSD -#include -#include -#endif BSD - -extern char **environ; - -bool -prefix(p, s) - register char *p, *s; -{ - while (*p && (*p == *s)) - p++, s++; - if (!*p) - return (true); - else - return (false); -} - -/* Create a copy of a string. */ - -char * -copy(str) - char *str; -{ - char *p, *tmalloc(); - - p = tmalloc(strlen(str) + 1); - strcpy(p, str); - return(p); -} - -/* Determine whether sub is a substring of str. */ - -bool -substring(sub, str) - register char *str, *sub; -{ - register char *s; - - while(*str) { - if(*str == *sub) { - for(s = sub; *s; s++) - if(*s != *str++) - break; - if(*s == '\0') - return (true); - } - str++; - } - return (false); -} - -/* Malloc num bytes and initialize to zero. Fatal error if the space can't - * be malloc'd. - */ - -char * -tmalloc(num) - register int num; -{ - register char *s; - char *malloc(); - - s = malloc((unsigned) num); - if (!s) { - fatal("malloc: can't allocate %d bytes", num); - } - bzero(s, num); - return(s); -} - -char * -trealloc(ptr, num) - char *ptr; - int num; -{ - register char *s; - char *realloc(); - - s = realloc(ptr, (unsigned) num); - if (!s) { - fatal("realloc: can't allocate %d bytes", num); - } - /* Well, this won't be zeroed... Too bad... */ - return(s); -} - -/* Append one character to a string. Don't check for overflow. */ - -void -appendc(s, c) - char *s, c; -{ - while (*s) - s++; - *s++ = c; - *s = '\0'; - return; -} - -int -scannum(str) - char *str; -{ - int i = 0; - - while(isdigit(*str)) - i = i * 10 + *(str++) - '0'; - return(i); -} - -/* Case insensitive prefix. */ - -bool -ciprefix(p, s) - register char *p, *s; -{ - while (*p) { - if ((isupper(*p) ? tolower(*p) : *p) != - (isupper(*s) ? tolower(*s) : *s)) - return(false); - p++; - s++; - } - return (true); -} - -/* Case insensitive strcmp... */ - -bool -cieq(p, s) - register char *p, *s; -{ - while (*p) { - if ((isupper(*p) ? tolower(*p) : *p) != - (isupper(*s) ? tolower(*s) : *s)) - return(false); - p++; - s++; - } - return (!*s); -} - -#ifdef BSD - -/* Return the date. Return value is static data. */ - -char * -datestring() -{ - register char *tzn; - struct tm *tp; - static char tbuf[40]; - char *ap; - struct timeval tv; - struct timezone tz; - char *timezone(), *asctime(); - int i; - struct tm *localtime(); - - (void) gettimeofday(&tv, &tz); - tp = localtime((time_t *) &tv.tv_sec); - ap = asctime(tp); - tzn = timezone(tz.tz_minuteswest, tp->tm_isdst); - sprintf(tbuf, "%.20s", ap); - if (tzn) - strcat(tbuf, tzn); - strcat(tbuf, ap + 19); - i = strlen(tbuf); - tbuf[i - 1] = '\0'; - return (tbuf); -} - -#else BSD - -/* Give it a try... */ - -char * -datestring() -{ - long i; - static char buf[64]; - - i = time(0); - strcpy(buf, ctime(&i)); - buf[strlen(buf) - 1] = '\0'; /* Kill the nl. */ - return (buf); -} - -#endif - -/* How many seconds have elapsed in running time. */ - -int -seconds() -{ -#ifdef BSD - struct rusage ruse; - - getrusage(RUSAGE_SELF, &ruse); - return (ruse.ru_utime.tv_sec); -#else BSD -#endif BSD -} - -/* A few things that may not exist on non-unix systems. */ - -#ifndef BSD - -#ifndef index - -char * -index(s, c) - register char *s; - register char c; -{ - while ((*s != c) && (*s != '\0')) - s++; - if (*s == '\0') - return ((char *) 0); - else - return (s); -} - -#endif not index - -#ifndef rindex - -char * -rindex(s, c) - register char *s; - register char c; -{ - register char *t; - - for (t = s; *t != '\0'; t++); - while ((*t != c) && (t != s)) - t--; - if (t == s) - return ((char *) 0); - else - return (t); -} - -#endif not rindex - -#ifndef bcopy - -void -bcopy(from, to, num) - register char *from, *to; - register int num; -{ - while (num-- > 0) - *to++ = *from++; - return; -} - -#endif not bcopy - -#ifndef bzero - -void -bzero(ptr, num) - register char *ptr; - register int num; -{ - while (num-- > 0) - *ptr++ = '\0'; - return; -} - -#endif not bzero - -/* This might not be around... If not then forget about sorting... */ - -void qsort() {} - -#endif BSD - -char * -gettok(s) - char **s; -{ - char buf[BSIZE]; - int i = 0; - - while (isspace(**s)) - (*s)++; - if (!**s) - return (NULL); - while (**s && !isspace(**s)) - buf[i++] = *(*s)++; - buf[i] = '\0'; - while (isspace(**s)) - (*s)++; - return (copy(buf)); -} - -/* Die horribly. */ - -/* VARARGS1 */ -void -fatal(s, args) - char *s; -{ - fputs("Internal Error: ", stderr); - _doprnt(s, &args, stderr); - putc('\n', stderr); - - kill(getpid(), SIGIOT); - /* NOTREACHED */ -} - -void -setenv(name, value) - char *name, *value; -{ - int i; - char **xx, *s; - - s = tmalloc(strlen(name) + 2); - sprintf(s, "%s=", name); - - /* Copy the old environment... */ - for (i = 0; environ[i]; i++) - if (prefix(s, environ[i])) - break; - if (!environ[i]) { - xx = (char **) tmalloc((i + 2) * sizeof (char *)); - for (i = 0; environ[i]; i++) - xx[i] = environ[i]; - xx[i + 1] = NULL; - environ = xx; - } else - xx = environ; - - xx[i] = tmalloc(strlen(name) + strlen(value) + 2); - sprintf(xx[i], "%s=%s", name, value); - return; -} - -char * -getusername() -{ - int i = getuid(); - struct passwd *pw = getpwuid(i); - - return (pw ? pw->pw_name : NULL); -} - -char * -gethome() -{ - int i = getuid(); - struct passwd *pw = getpwuid(i); - - return (pw ? pw->pw_dir : "/strange"); -} - -char * -tildexpand(s) - char *s; -{ - struct passwd *pw; - char *n, buf[64]; - int i; - - if (*s != '~') - return (copy(s)); - - for (s++, i = 0; *s != '/'; s++, i++) - buf[i] = *s; - buf[i] = '\0'; - if (!i) - pw = getpwuid(getuid()); - else - pw = getpwnam(buf); - if (!pw) - return (s); - n = tmalloc(strlen(s) + strlen(pw->pw_dir) + 1); - strcpy(n, pw->pw_dir); - strcat(n, s); - return (n); -} - diff --git a/gnu/games/chess/Xchess/std.h b/gnu/games/chess/Xchess/std.h deleted file mode 100644 index bf93a9192b56..000000000000 --- a/gnu/games/chess/Xchess/std.h +++ /dev/null @@ -1,106 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. - - $Id: std.h,v 1.2 1993/08/02 17:21:02 mycroft Exp $ -*/ - - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * - * Standard definitions. - */ - -#define UNIX -#define BSD - -#ifndef FILE -#include -#endif -#ifndef isalpha -#include -#endif -#ifndef HUGE -#include -#endif -#include - -typedef int bool; - -#define false 0 -#define true 1 - -/* Externs defined in std.c */ - -extern char *tmalloc(); -extern char *trealloc(); -extern char *copy(); -extern char *datestring(); -extern char *getusername(); -extern char *gethome(); -extern char *gettok(); -extern char *tildexpand(); -extern void fatal(); -extern void setenv(); -extern void appendc(); -extern int scannum(); -extern int seconds(); -extern bool prefix(); -extern bool ciprefix(); -extern bool cieq(); -extern bool substring(); - -/* Externs from libc */ - -extern char *getenv(); -extern int errno; -extern char *sys_errlist[]; - -/* Should use BSIZE instead of BUFSIZ... */ - -#define BSIZE 512 - -/* Some standard macros. */ - -#define eq(a,b) (!strcmp((a), (b))) -#define isalphanum(c) (isalpha(c) || isdigit(c)) -#define alloc(strname) ((struct strname *) tmalloc(sizeof(struct strname))) -#define tfree(ptr) { if (ptr) free((char *) ptr); ptr = 0; } -#define hexnum(c) ((((c) >= '0') && ((c) <= '9')) ? ((c) - '0') : ((((c) >= \ - 'a') && ((c) <= 'f')) ? ((c) - 'a' + 10) : ((((c) >= 'A') && \ - ((c) <= 'F')) ? ((c) - 'A' + 10) : 0))) - -#ifndef BSD -#define random rand -#define srandom srand -#endif BSD - -#ifdef VMS - -#define EXIT_NORMAL 1 -#define EXIT_BAD 0 - -#else VMS - -#define EXIT_NORMAL 0 -#define EXIT_BAD 1 - -#endif VMS - diff --git a/gnu/games/chess/Xchess/valid.c b/gnu/games/chess/Xchess/valid.c deleted file mode 100644 index 23d652a0b65d..000000000000 --- a/gnu/games/chess/Xchess/valid.c +++ /dev/null @@ -1,265 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: valid.c,v 1.2 1993/08/02 17:21:03 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Validate a move. - */ - -#include "xchess.h" - -extern bool ischeck(), couldmove(); - -bool -valid_move(m, b) - move *m; - board *b; -{ - board tb; - - /* First check that the piece can make the move at all... */ - if (!couldmove(m, b)) - return (false); - - /* Now see if the king is in check now. */ - bcopy((char *) b, (char *) &tb, sizeof (board)); - board_move(&tb, m); - if (ischeck(&tb, m->piece.color)) - return (false); - - if (ischeck(&tb, ((m->piece.color == WHITE) ? BLACK : WHITE))) - m->check = true; - - return (true); -} - -static bool -couldmove(m, b) - move *m; - board *b; -{ - int x, y; - - switch (m->type) { - case KCASTLE: - if ((m->piece.color == WHITE) && (b->white_cant_castle_k) || - (m->piece.color == BLACK) && - (b->black_cant_castle_k)) - return (false); - if ((b->square[m->fromy][5].color != NONE) || - (b->square[m->fromy][6].color != NONE)) - return (false); - if (ischeck(b, m->piece.color)) - return (false); - break; - - case QCASTLE: - if ((m->piece.color == WHITE) && (b->white_cant_castle_q) || - (m->piece.color == BLACK) && - (b->black_cant_castle_q)) - return (false); - if ((b->square[m->fromy][1].color != NONE) || - (b->square[m->fromy][2].color != NONE) || - (b->square[m->fromy][3].color != NONE)) - return (false); - if (ischeck(b, m->piece.color)) - return (false); - break; - - case MOVE: - case CAPTURE: - /* There is one special case here, that of taking a pawn - * en passant. In this case we change the move field to - * CAPTURE if it's ok. - */ - switch (m->piece.type) { - case PAWN: - if ((m->type == MOVE) && (m->fromx == m->tox)) { - /* A normal move. */ - if ((m->piece.color == WHITE) && (m->fromy == - m->toy + 1)) - break; - if ((m->piece.color == WHITE) && (m->fromy == - 6) && (m->toy == 4) && - (b->square[5][m->fromx].color - == NONE)) - break; - if ((m->piece.color == BLACK) && (m->fromy == - m->toy - 1)) - break; - if ((m->piece.color == BLACK) && (m->fromy == - 1) && (m->toy == 3) && - (b->square[2][m->fromx].color - == NONE)) - break; - return (false); - } else if (m->type == CAPTURE) { - if ((((m->piece.color == WHITE) && (m->fromy == - m->toy + 1)) || ((m->piece.color == - BLACK) && (m->fromy == m->toy - - 1))) && ((m->fromx == m->tox + 1) || - (m->fromx == m->tox - 1))) - break; - /* Now maybe it's enpassant... We've already - * checked for some of these things in the - * calling routine. - */ - if (m->enpassant) { - if (b->square[(m->piece.color == WHITE) - ? 3 : 4][m->tox].color == - ((m->piece.color == WHITE) ? - BLACK : WHITE)) - break; - } - return (false); - } - return (false); - - case ROOK: - if (m->fromx == m->tox) { - for (y = m->fromy + ((m->fromy > m->toy) ? -1 : - 1); y != m->toy; y += ((m->fromy - > m->toy) ? -1 : 1)) - if (b->square[y][m->tox].color != NONE) - return (false); - break; - } - if (m->fromy == m->toy) { - for (x = m->fromx + ((m->fromx > m->tox) ? -1 : - 1); x != m->tox; x += ((m->fromx - > m->tox) ? -1 : 1)) - if (b->square[m->toy][x].color != NONE) - return (false); - break; - } - return (false); - - case KNIGHT: - x = m->fromx - m->tox; - y = m->fromy - m->toy; - if ((((x == 2) || (x == -2)) && - ((y == 1) || (y == -1))) || - (((x == 1) || (x == -1)) && - ((y == 2) || (y == -2)))) - break; - return (false); - - case BISHOP: - x = m->fromx - m->tox; - y = m->fromy - m->toy; - if ((x != y) && (x != - y)) - return (false); - for (x = m->fromx + ((m->fromx > m->tox) ? -1 : 1), y = - m->fromy + ((m->fromy > m->toy) ? -1 : - 1); x != m->tox; - x += ((m->fromx > m->tox) ? -1 : 1), - y += ((m->fromy > m->toy) ? -1 : 1)) - if (b->square[y][x].color != NONE) - return (false); - break; - - case QUEEN: - if (m->fromx == m->tox) { - for (y = m->fromy + ((m->fromy > m->toy) ? -1 : - 1); y != m->toy; y += ((m->fromy - > m->toy) ? -1 : 1)) - if (b->square[y][m->tox].color != NONE) - return (false); - break; - } - if (m->fromy == m->toy) { - for (x = m->fromx + ((m->fromx > m->tox) ? -1 : - 1); x != m->tox; x += ((m->fromx - > m->tox) ? -1 : 1)) - if (b->square[m->toy][x].color != NONE) - return (false); - break; - } - x = m->fromx - m->tox; - y = m->fromy - m->toy; - if ((x != y) && (x != - y)) - return (false); - for (x = m->fromx + ((m->fromx > m->tox) ? -1 : 1), y = - m->fromy + ((m->fromy > m->toy) ? -1 : - 1); x != m->tox; - x += ((m->fromx > m->tox) ? -1 : 1), - y += ((m->fromy > m->toy) ? -1 : 1)) - if (b->square[y][x].color != NONE) - return (false); - break; - - case KING: - x = m->fromx - m->tox; - y = m->fromy - m->toy; - if ((x >= -1) && (x <= 1) && (y >= -1) && (y <= 1)) - break; - return (false); - } - break; - } - return (true); -} - -/* Say whether either king is in check... If move is non-NULL, say whether he - * in in check after the move takes place. We do this in a rather stupid way. - */ - -static bool -ischeck(b, col) - board *b; - color col; -{ - int x, y, kx, ky; - move ch; - - for (x = 0; x < SIZE; x++) - for (y = 0; y < SIZE; y++) - if ((b->square[y][x].color == col) && - (b->square[y][x].type == KING)) { - kx = x; - ky = y; - } - - for (x = 0; x < SIZE; x++) - for (y = 0; y < SIZE; y++) - if (b->square[y][x].color == ((col == WHITE) ? - BLACK : WHITE)) { - ch.type = CAPTURE; - ch.piece.color = b->square[y][x].color; - ch.piece.type = b->square[y][x].type; - ch.fromx = x; - ch.fromy = y; - ch.tox = kx; - ch.toy = ky; - ch.enpassant = false; - if (couldmove(&ch, b)) - return (true); - } - - return (false); -} - diff --git a/gnu/games/chess/Xchess/window.c b/gnu/games/chess/Xchess/window.c deleted file mode 100644 index 3ecb6a442aca..000000000000 --- a/gnu/games/chess/Xchess/window.c +++ /dev/null @@ -1,954 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: window.c,v 1.2 1993/08/02 17:21:05 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Deal with the two (or one) windows. - */ - -#include "xchess.h" -#include -#include - -#include "pawn.bitmap" -#include "rook.bitmap" -#include "knight.bitmap" -#include "bishop.bitmap" -#include "queen.bitmap" -#include "king.bitmap" - -#include "pawn_outline.bitmap" -#include "rook_outline.bitmap" -#include "knight_outline.bitmap" -#include "bishop_outline.bitmap" -#include "queen_outline.bitmap" -#include "king_outline.bitmap" - -#include "pawn_mask.bitmap" -#include "rook_mask.bitmap" -#include "knight_mask.bitmap" -#include "bishop_mask.bitmap" -#include "queen_mask.bitmap" -#include "king_mask.bitmap" - -#include "shade.bitmap" - -#include "xchess.cur" -#include "xchess_mask.cur" - -#include "xchess.icon" - -windata *win1, *win2; -bool win_flashmove = false; - -extern bool setup(); -extern void service(), drawgrid(), icon_refresh(); - -bool -win_setup(disp1, disp2) - char *disp1, *disp2; -{ - win1 = alloc(windata); - if (!oneboard) - win2 = alloc(windata); - - if (!setup(disp1, win1) || (!oneboard && !setup(disp2, win2))) - return (false); - - if (blackflag) { - win1->color = BLACK; - win1->flipped = true; - } else - win1->color = WHITE; - win_drawboard(win1); - - if (!oneboard) { - win2->color = BLACK; - win2->flipped = true; - win_drawboard(win2); - } - - return(true); -} - -/* Draw the chess board... */ - -void -win_drawboard(win) - windata *win; -{ - int i, j; - - drawgrid(win); - - /* Now toss on the squares... */ - for (i = 0; i < SIZE; i++) - for (j = 0; j < SIZE; j++) - win_erasepiece(j, i, win->color); - - return; -} - -/* Draw one piece. */ - -void -win_drawpiece(p, y, x, wnum) - piece *p; - int y, x; - color wnum; -{ - char *bits, *maskbits, *outline; - windata *win; - char buf[BSIZE]; - XImage *tmpImage; - Pixmap tmpPM, maskPM; - XGCValues gc; - - if (oneboard || (wnum == win1->color)) - win = win1; - else - win = win2; - - if (win->flipped) { - y = SIZE - y - 1; - x = SIZE - x - 1; - } - - /* - if (debug) - fprintf(stderr, "draw a %s at (%d, %d) on board %d\n", - piecenames[(int) p->type], y, x, wnum); - */ - - if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1); - - switch (p->type) { - case PAWN: - bits = pawn_bits; - maskbits = pawn_mask_bits; - outline = pawn_outline_bits; - break; - - case ROOK: - bits = rook_bits; - maskbits = rook_mask_bits; - outline = rook_outline_bits; - break; - - case KNIGHT: - bits = knight_bits; - maskbits = knight_mask_bits; - outline = knight_outline_bits; - break; - - case BISHOP: - bits = bishop_bits; - maskbits = bishop_mask_bits; - outline = bishop_outline_bits; - break; - - case QUEEN: - bits = queen_bits; - maskbits = queen_mask_bits; - outline = queen_outline_bits; - break; - - case KING: - bits = king_bits; - maskbits = king_mask_bits; - outline = king_outline_bits; - break; - - default: - fprintf(stderr, - "Internal Error: win_drawpiece: bad piece type %d\n", - p->type); - } - - /* There are two things we can do... If this is a black and white - * display, we have to shade the square and use an outline if the piece - * is white. We also have to use a mask... Since we don't want - * to use up too many bitmaps, create the mask bitmap, put the bits, - * and then destroy it. - */ - if (win->bnw && (p->color == WHITE)) - bits = outline; - if (win->bnw && !iswhite(win, x, y)) { - XSetState(win->display, DefaultGC(win->display, 0), - BlackPixel(win->display, 0), - WhitePixel(win->display, 0), GXcopy, AllPlanes); - - tmpPM = XCreateBitmapFromData(win->display, win->boardwin, - shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT); - - XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - - XFreePixmap(win->display, tmpPM); - - XSetFunction(win->display, DefaultGC(win->display, 0), - GXandInverted); - maskPM = XCreateBitmapFromData(win->display, win->boardwin, - maskbits, SQUARE_WIDTH, SQUARE_HEIGHT); - XCopyPlane(win->display, maskPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - XFreePixmap(win->display, maskPM); - - XSetFunction(win->display, DefaultGC(win->display, 0), - GXor); - tmpPM = XCreateBitmapFromData(win->display, win->boardwin, - bits, SQUARE_WIDTH, SQUARE_HEIGHT); - XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - XFreePixmap(win->display, tmpPM); - - XSetFunction(win->display, DefaultGC(win->display, 0), GXcopy); - - } else if (win->bnw){ - XSetState(win->display, DefaultGC(win->display, 0), - BlackPixel(win->display, 0), - WhitePixel(win->display, 0), GXcopy, AllPlanes); - - tmpPM = XCreateBitmapFromData(win->display, win->boardwin, - bits, SQUARE_WIDTH, SQUARE_HEIGHT); - XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - XFreePixmap(win->display, tmpPM); - } else { - XSetState(win->display, DefaultGC(win->display, 0), - ((p->color == WHITE) ? win->whitepiece.pixel : - win->blackpiece.pixel), - (iswhite(win, x, y) ? win->whitesquare.pixel : - win->blacksquare.pixel), - GXcopy, AllPlanes); - tmpPM = XCreateBitmapFromData(win->display, win->boardwin, - bits, SQUARE_WIDTH, SQUARE_HEIGHT); - XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - XFreePixmap(win->display, tmpPM); - } - - if (!record_english) { - gc.foreground = win->textcolor.pixel; - if (iswhite(win, x, y) || win->bnw) - gc.background = win->whitesquare.pixel; - else - gc.background = win->blacksquare.pixel; - - gc.font = win->small->fid; - - XChangeGC(win->display, DefaultGC(win->display, 0), - GCForeground | GCBackground | GCFont, &gc); - - if (!x) { - sprintf(buf, " %d", SIZE - y); - XDrawImageString(win->display, win->boardwin, - DefaultGC(win->display, 0), - 1, (y + 1) * (SQUARE_HEIGHT + - BORDER_WIDTH) - BORDER_WIDTH + - win->small->max_bounds.ascent - 1, buf, 2); - } - if (y == SIZE - 1) { - sprintf(buf, "%c", 'A' + x); - XDrawImageString(win->display, win->boardwin, - DefaultGC(win->display, 0), - x * (SQUARE_WIDTH + BORDER_WIDTH) + 1, - SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH + - win->small->max_bounds.ascent - 1, buf, 1); - } - } - return; -} - -void -win_erasepiece(y, x, wnum) - int y, x; - color wnum; -{ - windata *win; - char buf[BSIZE]; - XGCValues gc; - Pixmap tmpPM; - - if (oneboard || (wnum == win1->color)) - win = win1; - else - win = win2; - - if (win->flipped) { - y = SIZE - y - 1; - x = SIZE - x - 1; - } - - /* - if (debug) - fprintf(stderr, "erase square (%d, %d) on board %d\n", y, x, - wnum); - */ - - if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1); - - if (win->bnw && !iswhite(win, x, y)) { - XSetState(win->display, DefaultGC(win->display, 0), - BlackPixel(win->display, 0), - WhitePixel(win->display, 0), GXcopy, AllPlanes); - tmpPM = XCreateBitmapFromData(win->display, win->boardwin, - shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT); - - XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - - XFreePixmap(win->display, tmpPM); - } else { - XSetFillStyle(win->display, DefaultGC(win->display, 0), - FillSolid); - XSetForeground(win->display, DefaultGC(win->display, 0), - iswhite(win, x, y) ? win->whitesquare.pixel : - win->blacksquare.pixel); - XFillRectangle(win->display, win->boardwin, - DefaultGC(win->display, 0), - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), - SQUARE_WIDTH, SQUARE_HEIGHT); - } - - if (!record_english) { - gc.foreground = win->textcolor.pixel; - if (iswhite(win, x, y) || win->bnw) - gc.background = win->whitesquare.pixel; - else - gc.background = win->blacksquare.pixel; - - gc.font = win->small->fid; - - XChangeGC(win->display, DefaultGC(win->display, 0), - GCForeground | GCBackground | GCFont, &gc); - - if (!x) { - sprintf(buf, " %d", SIZE - y); - XDrawImageString(win->display, win->boardwin, - DefaultGC(win->display, 0), - 1, (y + 1) * (SQUARE_HEIGHT + - BORDER_WIDTH) - BORDER_WIDTH + - win->small->max_bounds.ascent - 1, buf, 2); - } - if (y == SIZE - 1) { - sprintf(buf, "%c", 'A' + x); - XDrawImageString(win->display, win->boardwin, - DefaultGC(win->display, 0), - x * (SQUARE_WIDTH + BORDER_WIDTH) + 1, - SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH + - win->small->max_bounds.ascent - 1, buf, 1); - } - } - - - return; -} - -void -win_flash(m, wnum) - move *m; - color wnum; -{ - windata *win; - int sx, sy, ex, ey, i; - - if (oneboard || (wnum == win1->color)) - win = win1; - else - win = win2; - - if (win->flipped) { - sx = SIZE - m->fromx - 1; - sy = SIZE - m->fromy - 1; - ex = SIZE - m->tox - 1; - ey = SIZE - m->toy - 1; - } else { - sx = m->fromx; - sy = m->fromy; - ex = m->tox; - ey = m->toy; - } - sx = sx * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2; - sy = sy * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2; - ex = ex * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2; - ey = ey * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2; - - XSetFunction(win->display, DefaultGC(win->display, 0), GXinvert); - XSetLineAttributes(win->display, DefaultGC(win->display, 0), - 0, LineSolid, 0, 0); - for (i = 0; i < num_flashes * 2; i++) { - XDrawLine(win->display,win->boardwin, - DefaultGC(win->display, 0), - sx, sy, ex, ey); - } - - XSetFunction(win->display, DefaultGC(win->display, 0), GXcopy); - return; -} - -/* Handle input from the players. */ - -void -win_process(quick) - bool quick; -{ - int i, rfd = 0, wfd = 0, xfd = 0; - struct timeval timeout; - - timeout.tv_sec = 0; - timeout.tv_usec = (quick ? 0 : 500000); - - if (XPending(win1->display)) - service(win1); - if (!oneboard) { - if (XPending(win1->display)) - service(win2); - } - - if (oneboard) - rfd = 1 << win1->display->fd; - else - rfd = (1 << win1->display->fd) | (1 << win2->display->fd); - if (!(i = select(32, &rfd, &wfd, &xfd, &timeout))) - return; - if (i == -1) { - perror("select"); - exit(1); - } - if (rfd & (1 << win1->display->fd)) - service(win1); - if (!oneboard && (rfd & (1 << win2->display->fd))) - service(win2); - - return; -} - -static void -service(win) - windata *win; -{ - XEvent ev; - - while(XPending(win->display)) { - XNextEvent(win->display, &ev); - if (TxtFilter(win->display, &ev)) - continue; - - if (ev.xany.window == win->boardwin) { - switch (ev.type) { - case ButtonPress: - button_pressed(&ev, win); - break; - - case ButtonRelease: - button_released(&ev, win); - break; - - case Expose: - /* Redraw... */ - win_redraw(win, &ev); - break; - - case 0: - case NoExpose: - break; - default: - fprintf(stderr, "Bad event type %d\n", ev.type); - exit(1); - } - } else if (ev.xany.window == win->wclockwin) { - switch (ev.type) { - case Expose: - clock_draw(win, WHITE); - break; - - case 0: - case NoExpose: - break; - default: - fprintf(stderr, "Bad event type %d\n", ev.type); - exit(1); - } - } else if (ev.xany.window == win->bclockwin) { - switch (ev.type) { - case Expose: - clock_draw(win, BLACK); - break; - - case 0: - case NoExpose: - break; - default: - fprintf(stderr, "Bad event type %d\n", ev.type); - exit(1); - } - } else if (ev.xany.window == win->jailwin) { - switch (ev.type) { - case Expose: - jail_draw(win); - break; - - case 0: - case NoExpose: - break; - default: - fprintf(stderr, "Bad event type %d\n", ev.type); - exit(1); - } - } else if (ev.xany.window == win->buttonwin) { - switch (ev.type) { - case ButtonPress: - button_service(win, &ev); - break; - - case Expose: - button_draw(win); - break; - - case 0: - case NoExpose: - break; - default: - fprintf(stderr, "Bad event type %d\n", ev.type); - exit(1); - } - } else if (ev.xany.window == win->icon) { - icon_refresh(win); - } else if (ev.xany.window == win->basewin) { - message_send(win, &ev); - } else { - fprintf(stderr, "Internal Error: service: bad win\n"); - fprintf(stderr, "window = %d, event = %d\n", ev.xany.window, - ev.type); - } - } - return; -} - -void -win_redraw(win, event) - windata *win; - XEvent *event; -{ - XExposeEvent *ev = &event->xexpose; - int x1, y1, x2, y2, i, j; - - drawgrid(win); - if (ev) { - x1 = ev->x / (SQUARE_WIDTH + BORDER_WIDTH); - y1 = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH); - x2 = (ev->x + ev->width) / (SQUARE_WIDTH + BORDER_WIDTH); - y2 = (ev->y + ev->height) / (SQUARE_HEIGHT + BORDER_WIDTH); - } else { - x1 = 0; - y1 = 0; - x2 = SIZE - 1; - y2 = SIZE - 1; - } - - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 < 0) x2 = 0; - if (y2 < 0) y2 = 0; - if (x1 > SIZE - 1) x1 = SIZE - 1; - if (y1 > SIZE - 1) y1 = SIZE - 1; - if (x2 > SIZE - 1) x2 = SIZE - 1; - if (y2 > SIZE - 1) y2 = SIZE - 1; - - if (win->flipped) { - y1 = SIZE - y2 - 1; - y2 = SIZE - y1 - 1; - x1 = SIZE - x2 - 1; - x2 = SIZE - x1 - 1; - } - - for (i = x1; i <= x2; i++) - for (j = y1; j <= y2; j++) { - if (chessboard->square[j][i].color == NONE) - win_erasepiece(j, i, WHITE); - else - win_drawpiece(&chessboard->square[j][i], j, i, - WHITE); - if (!oneboard) { - if (chessboard->square[j][i].color == NONE) - win_erasepiece(j, i, BLACK); - else - win_drawpiece(&chessboard->square[j][i], - j, i, BLACK); - } - } - - return; -} - -static bool -setup(dispname, win) - char *dispname; - windata *win; -{ - char buf[BSIZE], *s; - Pixmap bm, bmask; - Cursor cur; - extern char *program, *recfile; - XSizeHints xsizes; - - - if (!(win->display = XOpenDisplay(dispname))) - return (false); - - - /* Now get boolean defaults... */ - if ((s = XGetDefault(win->display, program, "noisy")) && eq(s, "on")) - noisyflag = true; - if ((s = XGetDefault(win->display, program, "savemoves")) && eq(s, "on")) - saveflag = true; - if ((s = XGetDefault(win->display, program, "algebraic")) && eq(s, "on")) - record_english = false; - if ((s = XGetDefault(win->display, program, "blackandwhite")) && eq(s, "on")) - bnwflag = true; - if ((s = XGetDefault(win->display, program, "quickrestore")) && eq(s, "on")) - quickflag = true; - if ((s = XGetDefault(win->display, program, "flash")) && eq(s, "on")) - win_flashmove = true; - - /* ... numeric variables ... */ - if (s = XGetDefault(win->display, program, "numflashes")) - num_flashes = atoi(s); - if (s = XGetDefault(win->display, program, "flashsize")) - flash_size = atoi(s); - - /* ... and strings. */ - if (s = XGetDefault(win->display, program, "progname")) - progname = s; - if (s = XGetDefault(win->display, program, "proghost")) - proghost = s; - if (s = XGetDefault(win->display, program, "recordfile")) - recfile = s; - if (s = XGetDefault(win->display, program, "blackpiece")) - black_piece_color = s; - if (s = XGetDefault(win->display, program, "whitepiece")) - white_piece_color = s; - if (s = XGetDefault(win->display, program, "blacksquare")) - black_square_color = s; - if (s = XGetDefault(win->display, program, "whitesquare")) - white_square_color = s; - if (s = XGetDefault(win->display, program, "bordercolor")) - border_color = s; - if (s = XGetDefault(win->display, program, "textcolor")) - text_color = s; - if (s = XGetDefault(win->display, program, "textback")) - text_back = s; - if (s = XGetDefault(win->display, program, "errortext")) - error_text = s; - if (s = XGetDefault(win->display, program, "playertext")) - player_text = s; - if (s = XGetDefault(win->display, program, "cursorcolor")) - cursor_color = s; - - if ((DisplayPlanes(win->display, 0) == 1) || bnwflag) - win->bnw = true; - - /* Allocate colors... */ - if (win->bnw) { - win->blackpiece.pixel = BlackPixel (win->display, 0); - win->whitepiece.pixel = WhitePixel (win->display, 0); - win->blacksquare.pixel = BlackPixel (win->display, 0); - win->whitesquare.pixel = WhitePixel (win->display, 0); - win->border.pixel = BlackPixel (win->display, 0); - win->textcolor.pixel = BlackPixel (win->display, 0); - win->textback.pixel = WhitePixel (win->display, 0); - win->playertext.pixel = BlackPixel (win->display, 0); - win->errortext.pixel = BlackPixel (win->display, 0); - win->cursorcolor.pixel = BlackPixel (win->display, 0) ; - } else { - if (!XParseColor(win->display, - DefaultColormap(win->display, 0), - black_piece_color, &win->blackpiece) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - white_piece_color, &win->whitepiece) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - black_square_color, &win->blacksquare) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - white_square_color, &win->whitesquare) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - border_color, &win->border) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - text_color, &win->textcolor) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - text_back, &win->textback) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - error_text, &win->errortext) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - player_text, &win->playertext) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - cursor_color, &win->cursorcolor) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->blackpiece) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->whitepiece) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->blacksquare) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->whitesquare) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->border) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->textcolor) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->textback) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->errortext) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->playertext) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->cursorcolor)) - fprintf(stderr, "Can't get colors...\n"); - } - - /* Get fonts... */ - if ((win->small = XLoadQueryFont(win->display,SMALL_FONT)) == - NULL) - fprintf(stderr, "Can't get small font...\n"); - - if ((win->medium = XLoadQueryFont(win->display,MEDIUM_FONT)) - == NULL) - fprintf(stderr, "Can't get medium font...\n"); - - if ((win->large = XLoadQueryFont(win->display,LARGE_FONT)) == - NULL) - fprintf(stderr, "Can't get large font...\n"); - - - /* Create the windows... */ - - win->basewin = - XCreateSimpleWindow(win->display,DefaultRootWindow(win->display), - BASE_XPOS, BASE_YPOS, - BASE_WIDTH, BASE_HEIGHT, 0, - BlackPixel(win->display, 0), - WhitePixel(win->display, 0)); - win->boardwin = XCreateSimpleWindow(win->display,win->basewin, - BOARD_XPOS, BOARD_YPOS, - BOARD_WIDTH, BOARD_HEIGHT, - BORDER_WIDTH, - win->border.pixel, - WhitePixel(win->display, 0)); - win->recwin = XCreateSimpleWindow(win->display,win->basewin, - RECORD_XPOS, RECORD_YPOS, - RECORD_WIDTH, RECORD_HEIGHT, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - win->jailwin = XCreateSimpleWindow(win->display,win->basewin, - JAIL_XPOS, JAIL_YPOS, - JAIL_WIDTH, JAIL_HEIGHT, - BORDER_WIDTH, - win->border.pixel, - win->textback.pixel); - win->wclockwin = XCreateSimpleWindow(win->display,win->basewin, - WCLOCK_XPOS, WCLOCK_YPOS, - CLOCK_WIDTH, CLOCK_HEIGHT, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - win->bclockwin = XCreateSimpleWindow(win->display,win->basewin, - BCLOCK_XPOS, BCLOCK_YPOS, - CLOCK_WIDTH, CLOCK_HEIGHT, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - win->messagewin = XCreateSimpleWindow(win->display,win->basewin, - MESS_XPOS, MESS_YPOS, - MESS_WIDTH, MESS_HEIGHT, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - win->buttonwin = XCreateSimpleWindow(win->display,win->basewin, - BUTTON_XPOS, BUTTON_YPOS, - BUTTON_WIDTH, BUTTON_HEIGHT, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - - /* Let's define an icon... */ - win->iconpixmap = XCreatePixmapFromBitmapData(win->display, - win->basewin, icon_bits, - icon_width, icon_height, - win->blacksquare.pixel, - win->whitesquare.pixel, - 1); - xsizes.flags = PSize | PMinSize | PPosition; - xsizes.min_width = BASE_WIDTH; - xsizes.min_height = BASE_HEIGHT; - xsizes.x = BASE_XPOS; - xsizes.y = BASE_YPOS; - XSetStandardProperties(win->display, win->basewin, - program, program, win->iconpixmap, - 0, NULL, &xsizes); - - bm = XCreateBitmapFromData(win->display, - win->basewin, xchess_bits, - xchess_width, xchess_height); - bmask = XCreateBitmapFromData(win->display, - win->basewin, xchess_mask_bits, - xchess_width, xchess_height); - cur = XCreatePixmapCursor(win->display, bm, bmask, - &win->cursorcolor, - &WhitePixel(win->display, 0), - xchess_x_hot, xchess_y_hot); - XFreePixmap(win->display, bm); - XFreePixmap(win->display, bmask); - - XDefineCursor(win->display,win->basewin, cur); - - XMapSubwindows(win->display,win->basewin); - XMapRaised(win->display,win->basewin); - - XSelectInput(win->display,win->basewin, KeyPressMask); - XSelectInput(win->display,win->boardwin, - ButtonPressMask | ButtonReleaseMask | ExposureMask); - XSelectInput(win->display,win->recwin, - ButtonReleaseMask | ExposureMask); - XSelectInput(win->display,win->jailwin, ExposureMask); - XSelectInput(win->display,win->wclockwin, ExposureMask); - XSelectInput(win->display,win->bclockwin, ExposureMask); - XSelectInput(win->display,win->messagewin, - ButtonReleaseMask | ExposureMask); - XSelectInput(win->display,win->buttonwin, - ButtonPressMask | ExposureMask); - - message_init(win); - record_init(win); - button_draw(win); - jail_init(win); - clock_init(win, WHITE); - clock_init(win, BLACK); - if (timeunit) { - if (timeunit > 1800) - sprintf(buf, "%d moves every %.2lg hours.\n", - movesperunit, ((double) timeunit) / 3600); - else if (timeunit > 30) - sprintf(buf, "%d moves every %.2lg minutes.\n", - movesperunit, ((double) timeunit) / 60); - else - sprintf(buf, "%d moves every %d seconds.\n", - movesperunit, timeunit); - message_add(win, buf, false); - } - return (true); -} - -static void -drawgrid(win) - windata *win; -{ - int i; - XGCValues gc; - - gc.function = GXcopy; - gc.plane_mask = AllPlanes; - gc.foreground = win->border.pixel; - gc.line_width = 0; - gc.line_style = LineSolid; - - XChangeGC(win->display, - DefaultGC(win->display, 0), - GCFunction | GCPlaneMask | GCForeground | - GCLineWidth | GCLineStyle, &gc); - - /* Draw the lines... horizontal, */ - for (i = 1; i < SIZE; i++) - XDrawLine(win->display, win->boardwin, - DefaultGC(win->display, 0), 0, - i * (SQUARE_WIDTH + BORDER_WIDTH) - - BORDER_WIDTH / 2, - SIZE * (SQUARE_WIDTH + BORDER_WIDTH), - i * (SQUARE_WIDTH + BORDER_WIDTH) - - BORDER_WIDTH / 2); - - /* and vertical... */ - for (i = 1; i < SIZE; i++) - XDrawLine(win->display, win->boardwin, - DefaultGC(win->display, 0), - i * (SQUARE_WIDTH + BORDER_WIDTH) - - BORDER_WIDTH / 2, 0, - i * (SQUARE_WIDTH + BORDER_WIDTH) - - BORDER_WIDTH / 2, - SIZE * (SQUARE_WIDTH + BORDER_WIDTH)); - return; -} - -void -win_restart() -{ - win1->flipped = false; - win_redraw(win1, (XEvent *) NULL); - if (!oneboard) { - win2->flipped = true; - win_redraw(win2, (XEvent *) NULL); - } - return; -} - -static void -icon_refresh(win) - windata *win; -{ - XCopyArea(win->display, win->iconpixmap, win->icon, - DefaultGC(win->display, 0), - 0, 0, icon_width, icon_height, 0, 0); - return; -} - diff --git a/gnu/games/chess/Xchess/window.c.bm b/gnu/games/chess/Xchess/window.c.bm deleted file mode 100644 index 13c511bc182f..000000000000 --- a/gnu/games/chess/Xchess/window.c.bm +++ /dev/null @@ -1,928 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - - -/* RCS Info: $Revision: 1.1.1.1 $ on $Date: 1993/03/21 09:45:37 $ - * $Source: /cvsroot/src/gnu/games/chess/Xchess/Attic/window.c.bm,v $ - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Deal with the two (or one) windows. - */ - -#include "xchess.h" -#include - -#include "pawn.bitmap" -#include "rook.bitmap" -#include "knight.bitmap" -#include "bishop.bitmap" -#include "queen.bitmap" -#include "king.bitmap" - -#include "pawn_outline.bitmap" -#include "rook_outline.bitmap" -#include "knight_outline.bitmap" -#include "bishop_outline.bitmap" -#include "queen_outline.bitmap" -#include "king_outline.bitmap" - -#include "pawn_mask.bitmap" -#include "rook_mask.bitmap" -#include "knight_mask.bitmap" -#include "bishop_mask.bitmap" -#include "queen_mask.bitmap" -#include "king_mask.bitmap" - -#include "shade.bitmap" - -#include "xchess.cur" -#include "xchess_mask.cur" - -#include "xchess.icon" - -windata *win1, *win2; -bool win_flashmove = false; - -extern bool setup(); -extern void service(), drawgrid(), icon_refresh(); - -bool -win_setup(disp1, disp2) - char *disp1, *disp2; -{ - win1 = alloc(windata); - if (!oneboard) - win2 = alloc(windata); - - if (!setup(disp1, win1) || (!oneboard && !setup(disp2, win2))) - return (false); - - if (blackflag) { - win1->color = BLACK; - win1->flipped = true; - } else - win1->color = WHITE; - win_drawboard(win1); - - if (!oneboard) { - win2->color = BLACK; - win2->flipped = true; - win_drawboard(win2); - } - - return(true); -} - -/* Draw the chess board... */ - -void -win_drawboard(win) - windata *win; -{ - int i, j; - - drawgrid(win); - - /* Now toss on the squares... */ - for (i = 0; i < SIZE; i++) - for (j = 0; j < SIZE; j++) - win_erasepiece(j, i, win->color); - - return; -} - -/* Draw one piece. */ - -void -win_drawpiece(p, y, x, wnum) - piece *p; - int y, x; - color wnum; -{ - char *bits, *maskbits, *outline; - windata *win; - char buf[BSIZE]; - XImage *tmpImage; - Pixmap tmpPM, maskPM; - XGCValues gc; - - if (oneboard || (wnum == win1->color)) - win = win1; - else - win = win2; - - if (win->flipped) { - y = SIZE - y - 1; - x = SIZE - x - 1; - } - - /* - if (debug) - fprintf(stderr, "draw a %s at (%d, %d) on board %d\n", - piecenames[(int) p->type], y, x, wnum); - */ - - if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1); - - switch (p->type) { - case PAWN: - bits = pawn_bits; - maskbits = pawn_mask_bits; - outline = pawn_outline_bits; - break; - - case ROOK: - bits = rook_bits; - maskbits = rook_mask_bits; - outline = rook_outline_bits; - break; - - case KNIGHT: - bits = knight_bits; - maskbits = knight_mask_bits; - outline = knight_outline_bits; - break; - - case BISHOP: - bits = bishop_bits; - maskbits = bishop_mask_bits; - outline = bishop_outline_bits; - break; - - case QUEEN: - bits = queen_bits; - maskbits = queen_mask_bits; - outline = queen_outline_bits; - break; - - case KING: - bits = king_bits; - maskbits = king_mask_bits; - outline = king_outline_bits; - break; - - default: - fprintf(stderr, - "Internal Error: win_drawpiece: bad piece type %d\n", - p->type); - } - - /* There are two things we can do... If this is a black and white - * display, we have to shade the square and use an outline if the piece - * is white. We also have to use a mask... Since we don't want - * to use up too many bitmaps, create the mask bitmap, put the bits, - * and then destroy it. - */ - if (win->bnw && (p->color == WHITE)) - bits = outline; - if (win->bnw && !iswhite(win, x, y)) { - XSetState(win->display, DefaultGC(win->display, 0), - BlackPixel(win->display, 0), - WhitePixel(win->display, 0), GXcopy, AllPlanes); - - tmpPM = XCreateBitmapFromData(win->display, win->boardwin, - shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT); - - XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - - XFreePixmap(win->display, tmpPM); - - XSetFunction(win->display, DefaultGC(win->display, 0), - GXandInverted); - maskPM = XCreateBitmapFromData(win->display, win->boardwin, - maskbits, SQUARE_WIDTH, SQUARE_HEIGHT); - XCopyPlane(win->display, maskPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - XFreePixmap(win->display, maskPM); - - XSetFunction(win->display, DefaultGC(win->display, 0), - GXor); - tmpPM = XCreateBitmapFromData(win->display, win->boardwin, - bits, SQUARE_WIDTH, SQUARE_HEIGHT); - XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - XFreePixmap(win->display, tmpPM); - - XSetFunction(win->display, DefaultGC(win->display, 0), GXcopy); - - } else if (win->bnw){ - XSetState(win->display, DefaultGC(win->display, 0), - BlackPixel(win->display, 0), - WhitePixel(win->display, 0), GXcopy, AllPlanes); - - tmpPM = XCreateBitmapFromData(win->display, win->boardwin, - bits, SQUARE_WIDTH, SQUARE_HEIGHT); - XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - XFreePixmap(win->display, tmpPM); - } else { - XSetState(win->display, DefaultGC(win->display, 0), - ((p->color == WHITE) ? win->whitepiece.pixel : - win->blackpiece.pixel), - (iswhite(win, x, y) ? win->whitesquare.pixel : - win->blacksquare.pixel), - GXcopy, AllPlanes); - tmpPM = XCreateBitmapFromData(win->display, win->boardwin, - bits, SQUARE_WIDTH, SQUARE_HEIGHT); - XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - XFreePixmap(win->display, tmpPM); - } - - if (!record_english) { - gc.foreground = win->textcolor.pixel; - if (iswhite(win, x, y) || win->bnw) - gc.background = win->whitesquare.pixel; - else - gc.background = win->blacksquare.pixel; - - gc.font = win->small->fid; - - XChangeGC(win->display, DefaultGC(win->display, 0), - GCForeground | GCBackground | GCFont, &gc); - - if (!x) { - sprintf(buf, " %d", SIZE - y); - XDrawImageString(win->display, win->boardwin, - DefaultGC(win->display, 0), - 1, (y + 1) * (SQUARE_HEIGHT + - BORDER_WIDTH) - BORDER_WIDTH + - win->small->max_bounds.ascent - 1, buf, 2); - } - if (y == SIZE - 1) { - sprintf(buf, "%c", 'A' + x); - XDrawImageString(win->display, win->boardwin, - DefaultGC(win->display, 0), - x * (SQUARE_WIDTH + BORDER_WIDTH) + 1, - SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH + - win->small->max_bounds.ascent - 1, buf, 1); - } - } - return; -} - -void -win_erasepiece(y, x, wnum) - int y, x; - color wnum; -{ - windata *win; - char buf[BSIZE]; - XGCValues gc; - Pixmap tmpPM; - - if (oneboard || (wnum == win1->color)) - win = win1; - else - win = win2; - - if (win->flipped) { - y = SIZE - y - 1; - x = SIZE - x - 1; - } - - /* - if (debug) - fprintf(stderr, "erase square (%d, %d) on board %d\n", y, x, - wnum); - */ - - if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1); - - if (win->bnw && !iswhite(win, x, y)) { - XSetState(win->display, DefaultGC(win->display, 0), - BlackPixel(win->display, 0), - WhitePixel(win->display, 0), GXcopy, AllPlanes); - tmpPM = XCreateBitmapFromData(win->display, win->boardwin, - shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT); - - XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0), - 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT, - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), 1); - - XFreePixmap(win->display, tmpPM); - } else { - XSetFillStyle(win->display, DefaultGC(win->display, 0), - FillSolid); - XSetForeground(win->display, DefaultGC(win->display, 0), - iswhite(win, x, y) ? win->whitesquare.pixel : - win->blacksquare.pixel); - XFillRectangle(win->display, win->boardwin, - DefaultGC(win->display, 0), - x * (SQUARE_WIDTH + BORDER_WIDTH), - y * (SQUARE_HEIGHT + BORDER_WIDTH), - SQUARE_WIDTH, SQUARE_HEIGHT); - } - - if (!record_english) { - gc.foreground = win->textcolor.pixel; - if (iswhite(win, x, y) || win->bnw) - gc.background = win->whitesquare.pixel; - else - gc.background = win->blacksquare.pixel; - - gc.font = win->small->fid; - - XChangeGC(win->display, DefaultGC(win->display, 0), - GCForeground | GCBackground | GCFont, &gc); - - if (!x) { - sprintf(buf, " %d", SIZE - y); - XDrawImageString(win->display, win->boardwin, - DefaultGC(win->display, 0), - 1, (y + 1) * (SQUARE_HEIGHT + - BORDER_WIDTH) - BORDER_WIDTH + - win->small->max_bounds.ascent - 1, buf, 2); - } - if (y == SIZE - 1) { - sprintf(buf, "%c", 'A' + x); - XDrawImageString(win->display, win->boardwin, - DefaultGC(win->display, 0), - x * (SQUARE_WIDTH + BORDER_WIDTH) + 1, - SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH + - win->small->max_bounds.ascent - 1, buf, 1); - } - } - - - return; -} - -void -win_flash(m, wnum) - move *m; - color wnum; -{ - windata *win; - int sx, sy, ex, ey, i; - - if (oneboard || (wnum == win1->color)) - win = win1; - else - win = win2; - - if (win->flipped) { - sx = SIZE - m->fromx - 1; - sy = SIZE - m->fromy - 1; - ex = SIZE - m->tox - 1; - ey = SIZE - m->toy - 1; - } else { - sx = m->fromx; - sy = m->fromy; - ex = m->tox; - ey = m->toy; - } - sx = sx * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2; - sy = sy * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2; - ex = ex * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2; - ey = ey * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2; - - for (i = 0; i < num_flashes * 2; i++) - XDrawLine(win->display,win->boardwin, - DefaultGC(win->display, 0), - sx, sy, ex, ey); - return; -} - -/* Handle input from the players. */ - -void -win_process(quick) - bool quick; -{ - int i, rfd = 0, wfd = 0, xfd = 0; - struct timeval timeout; - - timeout.tv_sec = 0; - timeout.tv_usec = (quick ? 0 : 500000); - - if (XPending(win1->display)) - service(win1); - if (!oneboard) { - if (XPending(win1->display)) - service(win2); - } - - if (oneboard) - rfd = 1 << win1->display->fd; - else - rfd = (1 << win1->display->fd) | (1 << win2->display->fd); - if (!(i = select(32, &rfd, &wfd, &xfd, &timeout))) - return; - if (i == -1) { - perror("select"); - exit(1); - } - if (rfd & (1 << win1->display->fd)) - service(win1); - if (!oneboard && (rfd & (1 << win2->display->fd))) - service(win2); - - return; -} - -static void -service(win) - windata *win; -{ - XEvent ev; - - while(XPending(win->display)) { - XNextEvent(win->display, &ev); - if (TxtFilter(win->display, &ev)) - continue; - - if (ev.xany.window == win->boardwin) { - switch (ev.type) { - case ButtonPress: - button_pressed(&ev, win); - break; - - case ButtonRelease: - button_released(&ev, win); - break; - - case Expose: - /* Redraw... */ - win_redraw(win, &ev); - break; - - case 0: - case NoExpose: - break; - default: - fprintf(stderr, "Bad event type %d\n", ev.type); - exit(1); - } - } else if (ev.xany.window == win->wclockwin) { - switch (ev.type) { - case Expose: - clock_draw(win, WHITE); - break; - - case 0: - case NoExpose: - break; - default: - fprintf(stderr, "Bad event type %d\n", ev.type); - exit(1); - } - } else if (ev.xany.window == win->bclockwin) { - switch (ev.type) { - case Expose: - clock_draw(win, BLACK); - break; - - case 0: - case NoExpose: - break; - default: - fprintf(stderr, "Bad event type %d\n", ev.type); - exit(1); - } - } else if (ev.xany.window == win->jailwin) { - switch (ev.type) { - case Expose: - jail_draw(win); - break; - - case 0: - case NoExpose: - break; - default: - fprintf(stderr, "Bad event type %d\n", ev.type); - exit(1); - } - } else if (ev.xany.window == win->buttonwin) { - switch (ev.type) { - case ButtonPress: - button_service(win, &ev); - break; - - case Expose: - button_draw(win); - break; - - case 0: - case NoExpose: - break; - default: - fprintf(stderr, "Bad event type %d\n", ev.type); - exit(1); - } - } else if (ev.xany.window == win->icon) { - icon_refresh(win); - } else if (ev.xany.window == win->basewin) { - message_send(win, &ev); - } else { - fprintf(stderr, "Internal Error: service: bad win\n"); - fprintf(stderr, "window = %d, event = %d\n", ev.xany.window, - ev.type); - } - } - return; -} - -void -win_redraw(win, event) - windata *win; - XEvent *event; -{ - XExposeEvent *ev = &event->xexpose; - int x1, y1, x2, y2, i, j; - - drawgrid(win); - if (ev) { - x1 = ev->x / (SQUARE_WIDTH + BORDER_WIDTH); - y1 = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH); - x2 = (ev->x + ev->width) / (SQUARE_WIDTH + BORDER_WIDTH); - y2 = (ev->y + ev->height) / (SQUARE_HEIGHT + BORDER_WIDTH); - } else { - x1 = 0; - y1 = 0; - x2 = SIZE - 1; - y2 = SIZE - 1; - } - - if (x1 < 0) x1 = 0; - if (y1 < 0) y1 = 0; - if (x2 < 0) x2 = 0; - if (y2 < 0) y2 = 0; - if (x1 > SIZE - 1) x1 = SIZE - 1; - if (y1 > SIZE - 1) y1 = SIZE - 1; - if (x2 > SIZE - 1) x2 = SIZE - 1; - if (y2 > SIZE - 1) y2 = SIZE - 1; - - if (win->flipped) { - y1 = SIZE - y2 - 1; - y2 = SIZE - y1 - 1; - x1 = SIZE - x2 - 1; - x2 = SIZE - x1 - 1; - } - - for (i = x1; i <= x2; i++) - for (j = y1; j <= y2; j++) { - if (chessboard->square[j][i].color == NONE) - win_erasepiece(j, i, WHITE); - else - win_drawpiece(&chessboard->square[j][i], j, i, - WHITE); - if (!oneboard) { - if (chessboard->square[j][i].color == NONE) - win_erasepiece(j, i, BLACK); - else - win_drawpiece(&chessboard->square[j][i], - j, i, BLACK); - } - } - - return; -} - -static bool -setup(dispname, win) - char *dispname; - windata *win; -{ - char buf[BSIZE], *s; - Pixmap bm, bmask; - Cursor cur; - extern char *program, *recfile; - - - if (!(win->display = XOpenDisplay(dispname))) - return (false); - - - /* Now get boolean defaults... */ - if ((s = XGetDefault(win->display, program, "noisy")) && eq(s, "on")) - noisyflag = true; - if ((s = XGetDefault(win->display, program, "savemoves")) && eq(s, "on")) - saveflag = true; - if ((s = XGetDefault(win->display, program, "algebraic")) && eq(s, "on")) - record_english = false; - if ((s = XGetDefault(win->display, program, "blackandwhite")) && eq(s, "on")) - bnwflag = true; - if ((s = XGetDefault(win->display, program, "quickrestore")) && eq(s, "on")) - quickflag = true; - if ((s = XGetDefault(win->display, program, "flash")) && eq(s, "on")) - win_flashmove = true; - - /* ... numeric variables ... */ - if (s = XGetDefault(win->display, program, "numflashes")) - num_flashes = atoi(s); - if (s = XGetDefault(win->display, program, "flashsize")) - flash_size = atoi(s); - - /* ... and strings. */ - if (s = XGetDefault(win->display, program, "progname")) - progname = s; - if (s = XGetDefault(win->display, program, "proghost")) - proghost = s; - if (s = XGetDefault(win->display, program, "recordfile")) - recfile = s; - if (s = XGetDefault(win->display, program, "blackpiece")) - black_piece_color = s; - if (s = XGetDefault(win->display, program, "whitepiece")) - white_piece_color = s; - if (s = XGetDefault(win->display, program, "blacksquare")) - black_square_color = s; - if (s = XGetDefault(win->display, program, "whitesquare")) - white_square_color = s; - if (s = XGetDefault(win->display, program, "bordercolor")) - border_color = s; - if (s = XGetDefault(win->display, program, "textcolor")) - text_color = s; - if (s = XGetDefault(win->display, program, "textback")) - text_back = s; - if (s = XGetDefault(win->display, program, "errortext")) - error_text = s; - if (s = XGetDefault(win->display, program, "playertext")) - player_text = s; - if (s = XGetDefault(win->display, program, "cursorcolor")) - cursor_color = s; - - if ((DisplayPlanes(win->display, 0) == 1) || bnwflag) - win->bnw = true; - - /* Allocate colors... */ - if (win->bnw) { - win->blackpiece.pixel = BlackPixel (win->display, 0); - win->whitepiece.pixel = WhitePixel (win->display, 0); - win->blacksquare.pixel = BlackPixel (win->display, 0); - win->whitesquare.pixel = WhitePixel (win->display, 0); - win->border.pixel = BlackPixel (win->display, 0); - win->textcolor.pixel = BlackPixel (win->display, 0); - win->textback.pixel = WhitePixel (win->display, 0); - win->playertext.pixel = BlackPixel (win->display, 0); - win->errortext.pixel = BlackPixel (win->display, 0); - win->cursorcolor.pixel = BlackPixel (win->display, 0) ; - } else { - if (!XParseColor(win->display, - DefaultColormap(win->display, 0), - black_piece_color, &win->blackpiece) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - white_piece_color, &win->whitepiece) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - black_square_color, &win->blacksquare) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - white_square_color, &win->whitesquare) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - border_color, &win->border) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - text_color, &win->textcolor) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - text_back, &win->textback) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - error_text, &win->errortext) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - player_text, &win->playertext) || - !XParseColor(win->display, - DefaultColormap(win->display, 0), - cursor_color, &win->cursorcolor) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->blackpiece) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->whitepiece) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->blacksquare) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->whitesquare) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->border) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->textcolor) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->textback) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->errortext) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->playertext) || - !XAllocColor(win->display, - DefaultColormap(win->display, 0), - &win->cursorcolor)) - fprintf(stderr, "Can't get color...\n"); - } - - /* Get fonts... */ - win->small = XLoadQueryFont(win->display,SMALL_FONT); - win->medium = XLoadQueryFont(win->display,MEDIUM_FONT); - win->large = XLoadQueryFont(win->display,LARGE_FONT); - - /* Create the windows... */ - - win->basewin = - XCreateSimpleWindow(win->display,DefaultRootWindow(win->display), - BASE_XPOS, BASE_YPOS, - BASE_WIDTH, BASE_HEIGHT, 0, - BlackPixel(win->display, 0), - WhitePixel(win->display, 0)); - win->boardwin = XCreateSimpleWindow(win->display,win->basewin, - BOARD_XPOS, BOARD_YPOS, - BOARD_WIDTH, BOARD_HEIGHT, - BORDER_WIDTH, - win->border.pixel, - WhitePixel(win->display, 0)); - win->recwin = XCreateSimpleWindow(win->display,win->basewin, - RECORD_XPOS, RECORD_YPOS, - RECORD_WIDTH, RECORD_HEIGHT, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - win->jailwin = XCreateSimpleWindow(win->display,win->basewin, - JAIL_XPOS, JAIL_YPOS, - JAIL_WIDTH, JAIL_HEIGHT, - BORDER_WIDTH, - win->border.pixel, - win->textback.pixel); - win->wclockwin = XCreateSimpleWindow(win->display,win->basewin, - WCLOCK_XPOS, WCLOCK_YPOS, - CLOCK_WIDTH, CLOCK_HEIGHT, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - win->bclockwin = XCreateSimpleWindow(win->display,win->basewin, - BCLOCK_XPOS, BCLOCK_YPOS, - CLOCK_WIDTH, CLOCK_HEIGHT, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - win->messagewin = XCreateSimpleWindow(win->display,win->basewin, - MESS_XPOS, MESS_YPOS, - MESS_WIDTH, MESS_HEIGHT, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - win->buttonwin = XCreateSimpleWindow(win->display,win->basewin, - BUTTON_XPOS, BUTTON_YPOS, - BUTTON_WIDTH, BUTTON_HEIGHT, - BORDER_WIDTH, win->border.pixel, - win->textback.pixel); - - /* Let's define an icon... */ - win->iconpixmap = XCreatePixmapFromBitmapData(win->display, - win->basewin, icon_bits, - icon_width, icon_height, - win->blacksquare.pixel, - win->whitesquare.pixel, - 1); - - bm = XCreateBitmapFromData(win->display, - win->basewin, xchess_bits, - xchess_width, xchess_height); - bmask = XCreateBitmapFromData(win->display, - win->basewin, xchess_mask_bits, - xchess_width, xchess_height); - cur = XCreatePixmapCursor(win->display, bm, bmask, - &win->cursorcolor, - &WhitePixel(win->display, 0), - xchess_x_hot, xchess_y_hot); - XFreePixmap(win->display, bm); - XFreePixmap(win->display, bmask); - - XDefineCursor(win->display,win->basewin, cur); - - XMapSubwindows(win->display,win->basewin); - XMapRaised(win->display,win->basewin); - - XSelectInput(win->display,win->basewin, KeyPressMask); - XSelectInput(win->display,win->boardwin, - ButtonPressMask | ButtonReleaseMask | ExposureMask); - XSelectInput(win->display,win->recwin, - ButtonReleaseMask | ExposureMask); - XSelectInput(win->display,win->jailwin, ExposureMask); - XSelectInput(win->display,win->wclockwin, ExposureMask); - XSelectInput(win->display,win->bclockwin, ExposureMask); - XSelectInput(win->display,win->messagewin, - ButtonReleaseMask | ExposureMask); - XSelectInput(win->display,win->buttonwin, - ButtonPressMask | ExposureMask); - - message_init(win); - record_init(win); - button_draw(win); - jail_init(win); - clock_init(win, WHITE); - clock_init(win, BLACK); - if (timeunit) { - if (timeunit > 1800) - sprintf(buf, "%d moves every %.2lg hours.\n", - movesperunit, ((double) timeunit) / 3600); - else if (timeunit > 30) - sprintf(buf, "%d moves every %.2lg minutes.\n", - movesperunit, ((double) timeunit) / 60); - else - sprintf(buf, "%d moves every %d seconds.\n", - movesperunit, timeunit); - message_add(win, buf, false); - } - - return (true); -} - -static void -drawgrid(win) - windata *win; -{ - int i; - XGCValues gc; - - gc.function = GXcopy; - gc.plane_mask = AllPlanes; - gc.foreground = win->border.pixel; - gc.line_width = 0; - gc.line_style = LineSolid; - - XChangeGC(win->display, - DefaultGC(win->display, 0), - GCFunction | GCPlaneMask | GCForeground | - GCLineWidth | GCLineStyle, &gc); - - /* Draw the lines... horizontal, */ - for (i = 1; i < SIZE; i++) - XDrawLine(win->display, win->boardwin, - DefaultGC(win->display, 0), 0, - i * (SQUARE_WIDTH + BORDER_WIDTH) - - BORDER_WIDTH / 2, - SIZE * (SQUARE_WIDTH + BORDER_WIDTH), - i * (SQUARE_WIDTH + BORDER_WIDTH) - - BORDER_WIDTH / 2); - - /* and vertical... */ - for (i = 1; i < SIZE; i++) - XDrawLine(win->display, win->boardwin, - DefaultGC(win->display, 0), - i * (SQUARE_WIDTH + BORDER_WIDTH) - - BORDER_WIDTH / 2, 0, - i * (SQUARE_WIDTH + BORDER_WIDTH) - - BORDER_WIDTH / 2, - SIZE * (SQUARE_WIDTH + BORDER_WIDTH)); - return; -} - -void -win_restart() -{ - win1->flipped = false; - win_redraw(win1, (XEvent *) NULL); - if (!oneboard) { - win2->flipped = true; - win_redraw(win2, (XEvent *) NULL); - } - return; -} - -static void -icon_refresh(win) - windata *win; -{ - XCopyArea(win->display, win->iconpixmap, win->icon, - DefaultGC(win->display, 0), - 0, 0, icon_width, icon_height, 0, 0); - return; -} - diff --git a/gnu/games/chess/Xchess/xchess.1 b/gnu/games/chess/Xchess/xchess.1 deleted file mode 100644 index 18b67783c131..000000000000 --- a/gnu/games/chess/Xchess/xchess.1 +++ /dev/null @@ -1,217 +0,0 @@ -.\" $Id: xchess.1,v 1.2 1993/08/02 17:21:06 mycroft Exp $ -*- nroff -*- -.TH XCHESS 1 "14 Nov 1986" "X Version 10" -.SH NAME -xchess \- X chess display -.SH SYNOPSIS -.B xchess -[ option ... ] [ white-display ] [ black-display ] -.SH DESCRIPTION -.PP -.B xchess -is a chess display program which allows players to play a game on either -one or two displays, or play a chess-playing program. It uses the -.B X -window system. If one or no display names are given, it will open up one -window and both black and white at the same board. If two displays are -given, -.B xchess -will accept moves from each player in his turn. Black's board will be drawn -with his pieces at the bottom. -.PP -.B xchess -will not allow a player to make an illegal move. It accepts all legal moves, -including castling and pawn capture \fIen passant\fR. -.SH OPTIONS -.TP 8 -.B -d -Turn on debugging. -.TP 8 -.B -f record-file -Use \fBrecord-file\fR for saving the game when the \fBSave\fR button is -selected, or if the \fB-s\fR flag is given. The default is "xchess.game". -.TP 8 -.B -r saved-game -Start with the position at the end of the saved game in the named file. -This file may be the result of the \fBSave\fR command, and may be in -either English or International format. When reading moves, one move -it made per second. -.TP 8 -.B -q -Don't pause for a second every time a move is made when a game is being -restored. -.TP 8 -.B -v -Whenever a piece is moved, outline the path with a "lightning bolt". -This option and the \fB-n\fR option are useful if you don't want to miss -an opponent's move when he makes it. -.TP 8 -.B -i -Use International format for recording moves (squares numbered 1-8, a-h) -as opposed to English (e.g, \fIp/k4xp/q5\fR). -.TP 8 -.B -t moves/timeunit -Allows \fBtimeunit\fR seconds for every \fBmoves\fR moves. If either player -exceeds this allowance both recieve a message saying informing them of -this fact. -.TP 8 -.B -c -Play the computer. -.B xchess -will start up a chess-playing program (currently the only one it knows -how to talk to is \fBGNU Chess\fR). -.TP 8 -.B -p program -The name of the program to use if the \fB-c\fR option is given. The -default is "/usr/public/gnuchess". Note that \fBgnuchess\fR must be -compiled with the \fIcompat\fR flag (in the file "main.c") set to 1. -.TP 8 -.B -b -If the \fB-c\fR flag was given, have the computer play white. -.TP 8 -.B -bnw -If the display has more than one display plane (i.e, is color), pretend -it's black and white. -.TP 8 -.B -s -Save the moves in the record file as they are made. This is useful if -you don't want your game to be lost when \fBxchess\fR core dumps. -.TP 8 -.B -n -Be noisy \- beep after every move is made. -.TP 8 -.B -h host -Run GNU Chess on the specified \fBhost\fR. -.TP 8 -.B -R -Randomly chose who plays white and who plays black, if two displays are -given. -.SH CONTROLS -.PP -The window is divided up into several sub-windows. The pieces are moved by -pushing down any mouse button on top of the piece, moving to the destination -square, and releasing it. Castling is done by moving the king to the -right square. If you push down on a piece and then let the button -up without moving it, you must move that piece. ("Touch it, move it.") -.PP -The progress of the game is listed in the "Game Record" window. Error -messages and such things are printed in the "Message" window. Both these -windows have scroll bars that you can use to move around. -There are also windows for clocks and for a record of the pieces captured. -.PP -If you type any keys in the window, the text will go into the message -window of both players. This provides a simple communication facility. -.PP -There are 9 buttons in the control window. They are as follows: -.TP 8 -.B Draw -Both players must push this button to agree on a draw (just one is ok -if only one display is being used). -.TP 8 -.B Resign -The player whose turn it is to move resigns. -.TP 8 -.B Reset -Start over from the beginning. -.TP 8 -.B Back -Retract a move. If two displays are being used the other player will be -asked to confirm this. -.TP 8 -.B Fwd -This will re-play the most recently retracted move. This button in conjunction -with \fBBack\fR is useful for "scrolling around" in a saved game. -.TP 8 -.B Save -Save the game in the record file. -.TP 8 -.B Flip -Rotate the board so that Black will have his pieces at the bottom. -.TP 8 -.B Switch -Change the mapping of boards to players. -.TP 8 -.B Pause -This button has two functions. When a game is being restored, pieces will -be moved once a second. Hitting \fBPause\fR will stop this process, and -hitting it again will restart it. During the time that it is stopped no -other action can be made except restarting it. While a game is being played, -\fBPause\fR will stop the clock and restart it. -.SH DEFAULTS -.PP -\fBxchess\fR uses the following \fI.Xdefaults\fR: -.TP 8 -.B Noisy -The -n flag. -.TP 8 -.B SaveMoves -The -s flag. -.TP 8 -.B Algebraic -The -i flag. -.TP 8 -.B BlackAndWhite -The -bnw flag. -.TP 8 -.B QuickRestore -The -q flag. -.TP 8 -.B Flash -The -v flag. -.TP 8 -.B NumFlashes -How many times to flash the move. The default is 5. -.TP 8 -.B FlashWidth -How big to make the lightning bolt. The default is 10 pixels. -.TP 8 -.B ProgName -The -p option. This may also be changed in the Makefile (-DDEF_PROG_NAME). -.TP 8 -.B ProgHost -The -h option. -.TP 8 -.B RecordFile -The -f option. -.TP 8 -.B BlackPiece -The color of the black pieces. -.TP 8 -.B WhitePiece -The color of the white pieces. -.TP 8 -.B BorderColor -The color of the borders. -.TP 8 -.B BlackSquare -The color of the black squares. -.TP 8 -.B WhiteSquare -The color of the white squares. -.TP 8 -.B TextColor -The color of routine messages and the move record text. -.TP 8 -.B ErrorText -The color of error messages. -.TP 8 -.B PlayerText -The color of player-entered text. -.TP 8 -.B TextBack -The background color for the two text windows. -.TP 8 -.B CursorColor -The color of the mouse and the text cursors. -.SH "SEE ALSO" -X(8), gnuchess(1), chess(5) -.SH AUTHOR -Wayne A. Christopher (faustus@ic.berkeley.edu) -.SH BUGS -.PP -Checkmate and stalemate are not detected, so the appropriate player must resign -or agree to a draw respectively. -.PP -\fBSwitch\fR doesn't work. -.PP -If you are playing \fBgnuchess\fR, and you select Undo a few times so that it -is \fBgnuchess\fR's turn to move, it won't do anything. diff --git a/gnu/games/chess/Xchess/xchess.c b/gnu/games/chess/Xchess/xchess.c deleted file mode 100644 index 89061cc131fe..000000000000 --- a/gnu/games/chess/Xchess/xchess.c +++ /dev/null @@ -1,206 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -#ifndef lint -static char rcsid[] = "$Id: xchess.c,v 1.2 1993/08/02 17:21:08 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - */ - -#define USAGE "xchess [ -d ] [ -f recordfile ] [ -r savedfile ] [ -i ]\n\ -\t[ -t moves/timeunit ] [ -c ] [ -p program ] [ -b ] [ -bnw ] [ -s ]\n\ -\t[ -n ] [ -h host ] [ -v ] [ -R ] [ whitedisplay ] [ blackdisplay ]" - -#include -#include "xchess.h" - -bool debug = false; -bool oneboard = false; -bool bnwflag = false; -bool progflag = false; -bool blackflag = false; -bool quickflag = false; - -char *progname = DEF_PROGRAM; -char *proghost = NULL; -char *piecenames[] = { "pawn", "rook", "knight", "bishop", "queen", "king" } ; -char *colornames[] = { "white", "black", "none" } ; -char *movetypenames[] = { "move", "qcastle", "kcastle", "capture" } ; -char *dispname1 = NULL, *dispname2 = NULL; - -char *black_piece_color = BLACK_PIECE_COLOR; -char *white_piece_color = WHITE_PIECE_COLOR; -char *black_square_color = BLACK_SQUARE_COLOR; -char *white_square_color = WHITE_SQUARE_COLOR; -char *border_color = BORDER_COLOR; -char *text_color = TEXT_COLOR; -char *text_back = TEXT_BACK; -char *error_text = ERROR_TEXT; -char *player_text = PLAYER_TEXT; -char *cursor_color = CURSOR_COLOR; - -int num_flashes = NUM_FLASHES; -int flash_size = FLASH_SIZE; -char *program; -char *recfile = NULL; - -#ifdef notdef -/* - * Serves no purpose. - */ -die () { -fprintf(stderr, "child proc changed status?!\n"); -} -#endif - -void -main(ac, av) - char **av; -{ - bool randflag = false; - move *m; - char *s; - - program = av[0]; - -#ifdef notdef - signal(SIGCHLD, die); -#endif - - /* Process args. */ - av++; ac--; - while (ac > 0 && **av == '-') { - if (eq(*av, "-d")) { - debug = true; - } else if (eq(*av, "-f")) { - av++; ac--; - if (*av) - record_file = *av; - else - goto usage; - } else if (eq(*av, "-r")) { - av++; ac--; - if (*av) - recfile = *av; - else - goto usage; - } else if (eq(*av, "-i")) { - record_english = false; - } else if (eq(*av, "-R")) { - randflag = true; - } else if (eq(*av, "-v")) { - win_flashmove = true; - } else if (eq(*av, "-q")) { - quickflag = true; - } else if (eq(*av, "-t")) { - av++; ac--; - if (*av) { - movesperunit = atoi(*av); - if (s = index(*av, '/')) - timeunit = atoi(s + 1) * 60; - else - timeunit = 60; - } else - goto usage; - } else if (eq(*av, "-p")) { - av++; ac--; - if (*av) - progname = *av; - else - goto usage; - } else if (eq(*av, "-h")) { - av++; ac--; - if (*av) - proghost = *av; - else - goto usage; - } else if (eq(*av, "-b")) { - blackflag = true; - } else if (eq(*av, "-c")) { - progflag = true; - } else if (eq(*av, "-bnw")) { - bnwflag = true; - } else if (eq(*av, "-s")) { - saveflag = true; - } else if (eq(*av, "-n")) { - noisyflag = true; - } else - goto usage; - av++; ac--; - } - if (ac > 0) - dispname1 = av[0]; - if (ac > 1) - dispname2 = av[1]; - if (ac > 2) - goto usage; - - if (!dispname2) - oneboard = true; - - srandom(getpid()); - - if (!oneboard && randflag && (random() % 2)) { - s = dispname1; - dispname1 = dispname2; - dispname2 = s; - } - - if (!dispname1) - dispname1 = getenv("DISPLAY"); - - /* Set up the board. */ - board_setup(); - - /* Create the windows. */ - win_setup(dispname1, dispname2); - - board_drawall(); - - /* Start the program if necessary. */ - if (progflag) - if (!program_init(progname)) - exit(1); - - if (recfile) - load_game(recfile); - - /* Go into a loop of prompting players alternately for moves, checking - * them, and updating things. - */ - for (;;) { - win_process(false); - clock_update(); - if (progflag && ((!blackflag && (nexttomove == BLACK)) || - (blackflag && (nexttomove == WHITE)))) { - m = program_get(); - if (m) - prog_move(m); - } - } - -usage: fprintf(stderr, "Usage: %s\n", USAGE); - exit(1); -} - diff --git a/gnu/games/chess/Xchess/xchess.c.150 b/gnu/games/chess/Xchess/xchess.c.150 deleted file mode 100644 index a5367f6fdae9..000000000000 --- a/gnu/games/chess/Xchess/xchess.c.150 +++ /dev/null @@ -1,197 +0,0 @@ - -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - - -/* RCS Info: $Revision: 1.1.1.1 $ on $Date: 1993/03/21 09:45:37 $ - * $Source: /cvsroot/src/gnu/games/chess/Xchess/Attic/xchess.c.150,v $ - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - */ - -#define USAGE "xchess [ -d ] [ -f recordfile ] [ -r savedfile ] [ -i ]\n\ -\t[ -t moves/timeunit ] [ -c ] [ -p program ] [ -b ] [ -bnw ] [ -s ]\n\ -\t[ -n ] [ -h host ] [ -v ] [ -R ] [ whitedisplay ] [ blackdisplay ]" - -#include -#include "xchess.h" - -bool debug = false; -bool oneboard = false; -bool bnwflag = false; -bool progflag = false; -bool blackflag = false; -bool quickflag = false; - -char *progname = DEF_PROGRAM; -char *proghost = NULL; -char *piecenames[] = { "pawn", "rook", "knight", "bishop", "queen", "king" } ; -char *colornames[] = { "white", "black", "none" } ; -char *movetypenames[] = { "move", "qcastle", "kcastle", "capture" } ; -char *dispname1 = NULL, *dispname2 = NULL; - -char *black_piece_color = BLACK_PIECE_COLOR; -char *white_piece_color = WHITE_PIECE_COLOR; -char *black_square_color = BLACK_SQUARE_COLOR; -char *white_square_color = WHITE_SQUARE_COLOR; -char *border_color = BORDER_COLOR; -char *text_color = TEXT_COLOR; -char *text_back = TEXT_BACK; -char *error_text = ERROR_TEXT; -char *player_text = PLAYER_TEXT; -char *cursor_color = CURSOR_COLOR; - -int num_flashes = NUM_FLASHES; -int flash_size = FLASH_SIZE; -char *program; -char *recfile = NULL; - -die () { -fprintf(stderr, "child proc changed status?!\n"); -} - -void -main(ac, av) - char **av; -{ - bool randflag = false; - move *m; - char *s; - - program = av[0]; - - signal(SIGCHLD, die); - /* Process args. */ - av++; ac--; - while (ac > 0 && **av == '-') { - if (eq(*av, "-d")) { - debug = true; - } else if (eq(*av, "-f")) { - av++; ac--; - if (*av) - record_file = *av; - else - goto usage; - } else if (eq(*av, "-r")) { - av++; ac--; - if (*av) - recfile = *av; - else - goto usage; - } else if (eq(*av, "-i")) { - record_english = false; - } else if (eq(*av, "-R")) { - randflag = true; - } else if (eq(*av, "-v")) { - win_flashmove = true; - } else if (eq(*av, "-q")) { - quickflag = true; - } else if (eq(*av, "-t")) { - av++; ac--; - if (*av) { - movesperunit = atoi(*av); - if (s = index(*av, '/')) - timeunit = atoi(s + 1) * 60; - else - timeunit = 60; - } else - goto usage; - } else if (eq(*av, "-p")) { - av++; ac--; - if (*av) - progname = *av; - else - goto usage; - } else if (eq(*av, "-h")) { - av++; ac--; - if (*av) - proghost = *av; - else - goto usage; - } else if (eq(*av, "-b")) { - blackflag = true; - } else if (eq(*av, "-c")) { - progflag = true; - } else if (eq(*av, "-bnw")) { - bnwflag = true; - } else if (eq(*av, "-s")) { - saveflag = true; - } else if (eq(*av, "-n")) { - noisyflag = true; - } else - goto usage; - av++; ac--; - } - if (ac > 0) - dispname1 = av[0]; - if (ac > 1) - dispname2 = av[1]; - if (ac > 2) - goto usage; - - if (!dispname2) - oneboard = true; - - srandom(getpid()); - - if (!oneboard && randflag && (random() % 2)) { - s = dispname1; - dispname1 = dispname2; - dispname2 = s; - } - - if (!dispname1) - dispname1 = getenv("DISPLAY"); - - /* Set up the board. */ - board_setup(); - - /* Create the windows. */ - win_setup(dispname1, dispname2); - - board_drawall(); - - /* Start the program if necessary. */ - if (progflag) - if (!program_init(progname)) - exit(1); - - if (recfile) - load_game(recfile); - - /* Go into a loop of prompting players alternately for moves, checking - * them, and updating things. - */ - for (;;) { - win_process(false); - clock_update(); - if (progflag && ((!blackflag && (nexttomove == BLACK)) || - (blackflag && (nexttomove == WHITE)))) { - m = program_get(); - if (m) - prog_move(m); - } - } - -usage: fprintf(stderr, "Usage: %s\n", USAGE); - exit(1); -} - diff --git a/gnu/games/chess/Xchess/xchess.cur b/gnu/games/chess/Xchess/xchess.cur deleted file mode 100644 index ef3750dbdd7f..000000000000 --- a/gnu/games/chess/Xchess/xchess.cur +++ /dev/null @@ -1,9 +0,0 @@ - -#define xchess_width 16 -#define xchess_height 16 -#define xchess_x_hot 9 -#define xchess_y_hot 8 -static char xchess_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xfe, 0x80, 0xff, - 0xc0, 0xff, 0x60, 0xff, 0xb0, 0xfd, 0xd8, 0x66, 0x6c, 0x3b, 0x76, 0x1d, - 0x98, 0x1d, 0xcc, 0x0c, 0x60, 0x00, 0x00, 0x00}; diff --git a/gnu/games/chess/Xchess/xchess.game b/gnu/games/chess/Xchess/xchess.game deleted file mode 100644 index 2302334080c7..000000000000 --- a/gnu/games/chess/Xchess/xchess.game +++ /dev/null @@ -1,8 +0,0 @@ - -X Chess -- Sun Sep 18 18:01:17 EDT 1988 - Game played on pitcairn:0 - english - 1. P/kb2-kb4 P/k2-k3 - 2. P/k2-k4 -Draw agreed. -Time: white: 6s, black: 43s diff --git a/gnu/games/chess/Xchess/xchess.h b/gnu/games/chess/Xchess/xchess.h deleted file mode 100644 index 343175940f1c..000000000000 --- a/gnu/games/chess/Xchess/xchess.h +++ /dev/null @@ -1,302 +0,0 @@ -/* This file contains code for X-CHESS. - Copyright (C) 1986 Free Software Foundation, Inc. - -This file is part of X-CHESS. - -X-CHESS is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the X-CHESS General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -X-CHESS, but only under the conditions described in the -X-CHESS General Public License. A copy of this license is -supposed to have been given to you along with X-CHESS so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. - - $Id: xchess.h,v 1.2 1993/08/02 17:21:10 mycroft Exp $ -*/ - - -/* - * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group - * Permission is granted to do anything with this code except sell it - * or remove this message. - * - * Definitions for the X chess program. - */ - -#include "std.h" -#include -#include "scrollText/scrollText.h" - -#define SIZE 8 - -typedef enum piecetype { PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING } piecetype; -typedef enum movetype { MOVE, QCASTLE, KCASTLE, CAPTURE } movetype; -typedef enum color { WHITE, BLACK, NONE } color; - -typedef struct piece { - enum piecetype type; - enum color color; -} piece; - -/* The board has y=0 and black at the top... This probably isn't the best - * place to keep track of who can castle, but it's part of the game state... - */ - -typedef struct board { - piece square[SIZE][SIZE]; - bool white_cant_castle_k; - bool white_cant_castle_q; - bool black_cant_castle_k; - bool black_cant_castle_q; -} board; - -typedef struct move { - movetype type; - piece piece; - piece taken; - int fromx, fromy; - int tox, toy; - struct move *next; - bool enpassant; - bool check; -} move; - -#define iswhite(win, i, j) (!(((i) + (j)) % 2)) - -/* Stuff for the display. */ - -typedef struct windata { - Display *display; - Window basewin; - Window boardwin; - Window recwin; - Window wclockwin; - Window bclockwin; - Window messagewin; - Window buttonwin; - Window jailwin; - Window icon; - Pixmap iconpixmap; - XColor blackpiece; - XColor whitepiece; - XColor blacksquare; - XColor whitesquare; - XColor border; - XColor textcolor; - XColor textback; - XColor errortext; - XColor playertext; - XColor cursorcolor; - XFontStruct *small; - XFontStruct *medium; - XFontStruct *large; - bool bnw; - color color; - bool flipped; - double whitehands[3]; - double blackhands[3]; - char *txtassoc; -} windata; - -#define SMALL_FONT "6x10" -#define MEDIUM_FONT "8x13" -#define LARGE_FONT "9x15" -#define JAIL_FONT "6x10" - -#define SQUARE_WIDTH 80 -#define SQUARE_HEIGHT 80 - -#define BORDER_WIDTH 3 - -#define BOARD_WIDTH 8 * SQUARE_WIDTH + 7 * BORDER_WIDTH -#define BOARD_HEIGHT 8 * SQUARE_HEIGHT + 7 * BORDER_WIDTH -#define BOARD_XPOS 0 -#define BOARD_YPOS 0 - -#define RECORD_WIDTH 265 /* 40 chars * 6 pixels / character. */ -#define RECORD_HEIGHT 433 -#define RECORD_XPOS BOARD_WIDTH + BORDER_WIDTH -#define RECORD_YPOS 0 - -#define JAIL_WIDTH RECORD_WIDTH -#define JAIL_HEIGHT 163 -#define JAIL_XPOS RECORD_XPOS -#define JAIL_YPOS RECORD_YPOS + RECORD_HEIGHT + BORDER_WIDTH - -#define CLOCK_WIDTH 131 -#define CLOCK_HEIGHT 131 + BORDER_WIDTH + 20 -#define WCLOCK_XPOS RECORD_XPOS -#define WCLOCK_YPOS RECORD_HEIGHT + JAIL_HEIGHT + BORDER_WIDTH * 2 -#define BCLOCK_XPOS WCLOCK_XPOS + CLOCK_WIDTH + BORDER_WIDTH -#define BCLOCK_YPOS WCLOCK_YPOS - -#define MESS_WIDTH 329 -#define MESS_HEIGHT 92 -#define MESS_XPOS 0 -#define MESS_YPOS BOARD_HEIGHT + BORDER_WIDTH - -#define BUTTON_WIDTH MESS_WIDTH -#define BUTTON_HEIGHT MESS_HEIGHT -#define BUTTON_XPOS MESS_WIDTH + BORDER_WIDTH -#define BUTTON_YPOS MESS_YPOS - -#define BASE_WIDTH BOARD_WIDTH + RECORD_WIDTH + BORDER_WIDTH * 3 -#define BASE_HEIGHT BOARD_HEIGHT + MESS_HEIGHT + BORDER_WIDTH * 3 - -#define BASE_XPOS 50 -#define BASE_YPOS 50 - -#define BLACK_PIECE_COLOR "#202020" -#define WHITE_PIECE_COLOR "#FFFFCC" -#define BLACK_SQUARE_COLOR "#77A26D" -#define WHITE_SQUARE_COLOR "#C8C365" -#define BORDER_COLOR "#902E39" -#define TEXT_COLOR "#006D6D" -#define TEXT_BACK "#FFFFDD" -#define ERROR_TEXT "Red" -#define PLAYER_TEXT "Blue" -#define CURSOR_COLOR "#FF606F" - -#define DEF_RECORD_FILE "xchess.game" - -#define NUM_FLASHES 5 -#define FLASH_SIZE 10 - -/* xchess.c */ - -extern void main(); -extern bool debug; -extern char *progname; -extern char *proghost; -extern char *piecenames[]; -extern char *colornames[]; -extern char *movetypenames[]; -extern char *dispname1, *dispname2; -extern bool oneboard; -extern bool bnwflag; -extern bool progflag; -extern bool blackflag; -extern bool quickflag; -extern int num_flashes; -extern int flash_size; -extern char *black_piece_color; -extern char *white_piece_color; -extern char *black_square_color; -extern char *white_square_color; -extern char *border_color; -extern char *text_color; -extern char *text_back; -extern char *error_text; -extern char *player_text; -extern char *cursor_color; - -/* board.c */ - -extern void board_setup(); -extern void board_drawall(); -extern void board_move(); -extern board *chessboard; -extern void board_init(); - -/* window.c */ - -extern bool win_setup(); -extern void win_redraw(); -extern void win_restart(); -extern void win_drawboard(); -extern void win_drawpiece(); -extern void win_erasepiece(); -extern void win_process(); -extern void win_flash(); -extern windata *win1, *win2; -extern bool win_flashmove; - -/* control.c */ - -extern void button_pressed(); -extern void button_released(); -extern void move_piece(); -extern void prog_move(); -extern move *moves; -extern move *foremoves; -extern color nexttomove; -extern void replay(); -extern void forward(); -extern void cleanup(); -extern void restart(); -extern bool noisyflag; - -/* valid.c */ - -extern bool valid_move(); - -/* record.c */ - -extern void record_move(); -extern void record_reset(); -extern void record_save(); -extern void record_back(); -extern void record_init(); -extern void record_end(); -extern bool record_english; -extern char *record_file; -extern int movenum; -extern bool saveflag; - -/* message.c */ - -extern void message_init(); -extern void message_add(); -extern void message_send(); - -/* clock.c */ - -extern void clock_init(); -extern void clock_draw(); -extern void clock_update(); -extern void clock_switch(); -extern bool clock_started; -extern int movesperunit; -extern int timeunit; -extern int whiteseconds; -extern int blackseconds; - -/* button.c */ - -extern void button_draw(); -extern void button_service(); - -/* jail.c */ - -extern void jail_init(); -extern void jail_draw(); -extern void jail_add(); -extern void jail_remove(); - -/* program.c */ -extern bool program_init(); -extern void program_end(); -extern void program_send(); -extern void program_undo(); -extern move *program_get(); - -/* parse.c */ - -extern void load_game(); -extern move *parse_file(); -extern move *parse_move(); -extern move *parse_imove(); -extern bool loading_flag; -extern bool loading_paused; - -/* popup.c */ - -extern bool pop_question(); - diff --git a/gnu/games/chess/Xchess/xchess.icon b/gnu/games/chess/Xchess/xchess.icon deleted file mode 100644 index 78c68f1ba46b..000000000000 --- a/gnu/games/chess/Xchess/xchess.icon +++ /dev/null @@ -1,28 +0,0 @@ - -#define icon_width 48 -#define icon_height 48 -static char icon_bits[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, - 0xc1, 0xff, 0xff, 0xff, 0xff, 0x83, 0x41, 0x00, 0x00, 0x00, 0x00, 0x82, - 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, - 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, - 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, - 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, - 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, - 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, - 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, - 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, - 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, - 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, - 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, - 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, - 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, - 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, - 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, - 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, - 0x41, 0x00, 0x00, 0x00, 0x00, 0x82, 0xc1, 0xff, 0xff, 0xff, 0xff, 0x83, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x41, 0xc4, 0x89, 0x3c, 0xcf, 0x83, - 0x41, 0x24, 0x88, 0x04, 0x41, 0x80, 0x81, 0x22, 0x88, 0x04, 0x41, 0x80, - 0x01, 0x21, 0xf8, 0x1c, 0xcf, 0x83, 0x81, 0x22, 0x88, 0x04, 0x08, 0x82, - 0x41, 0x24, 0x88, 0x04, 0x08, 0x82, 0x41, 0xc4, 0x89, 0x3c, 0xcf, 0x83, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; diff --git a/gnu/games/chess/Xchess/xchess_mask.cur b/gnu/games/chess/Xchess/xchess_mask.cur deleted file mode 100644 index 6408b7e0b915..000000000000 --- a/gnu/games/chess/Xchess/xchess_mask.cur +++ /dev/null @@ -1,7 +0,0 @@ - -#define xchess_mask_width 16 -#define xchess_mask_height 16 -static char xchess_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xfe, 0x80, 0xff, - 0xc0, 0xff, 0x60, 0xff, 0xb0, 0xfd, 0xd8, 0x66, 0x6c, 0x3b, 0x76, 0x1d, - 0x98, 0x1d, 0xcc, 0x0c, 0x60, 0x00, 0x00, 0x00}; diff --git a/gnu/lib/libg++/g++-include/CursesW.h b/gnu/lib/libg++/g++-include/CursesW.h deleted file mode 100644 index 7056db5dc562..000000000000 --- a/gnu/lib/libg++/g++-include/CursesW.h +++ /dev/null @@ -1,397 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1989 Free Software Foundation - written by Eric Newton (newton@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _CursesWindow_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _CursesWindow_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif - -#include - -/* - * - * C++ class for windows. - * - * - */ - -class CursesWindow -{ -protected: - static int count; // count of all active windows: - // We rely on the c++ promise that - // all otherwise uninitialized - // static class vars are set to 0 - - WINDOW * w; // the curses WINDOW - - int alloced; // true if we own the WINDOW - - CursesWindow* par; // parent, if subwindow - CursesWindow* subwins; // head of subwindows list - CursesWindow* sib; // next subwindow of parent - - void kill_subwindows(); // disable all subwindows - -public: - CursesWindow(WINDOW* &window); // useful only for stdscr - - CursesWindow(int lines, // number of lines - int cols, // number of columns - int begin_y, // line origin - int begin_x); // col origin - - CursesWindow(CursesWindow& par, // parent window - int lines, // number of lines - int cols, // number of columns - int by, // absolute or relative - int bx, // origins: - char absrel = 'a'); // if `a', by & bx are - // absolute screen pos, - // else if `r', they are - // relative to par origin - ~CursesWindow(); - -// terminal status - int lines(); // number of lines on terminal, *not* window - int cols(); // number of cols on terminal, *not* window - -// window status - int height(); // number of lines in this window - int width(); // number of cols in this window - int begx(); // smallest x coord in window - int begy(); // smallest y coord in window - int maxx(); // largest x coord in window - int maxy(); // largest x coord in window - -// window positioning - int move(int y, int x); - -// coordinate positioning - void getyx(int& y, int& x); - int mvcur(int sy, int ey, int sx, int ex); - -// input - int getch(); - int getstr(char * str); - int scanw(const char *, ...); - -// input + positioning - int mvgetch(int y, int x); - int mvgetstr(int y, int x, char * str); - int mvscanw(int, int, const char*, ...); - -// output - int addch(const char ch); - int addstr(const char * str); - int printw(const char * fmt, ...); - int inch(); - int insch(char c); - int insertln(); - -// output + positioning - int mvaddch(int y, int x, char ch); - int mvaddstr(int y, int x, char * str); - int mvprintw(int y, int x, const char * fmt, ...); - int mvinch(int y, int x); - int mvinsch(int y, int x, char ch); - -// borders - int box(char vert, char hor); - -// erasure - int erase(); - int clear(); - int clearok(cbool bf); - int clrtobot(); - int clrtoeol(); - int delch(); - int mvdelch(int y, int x); - int deleteln(); - -// screen control - int scroll(); - int scrollok(cbool bf); - int touchwin(); - int refresh(); - int leaveok(cbool bf); - int flushok(cbool bf); - int standout(); - int standend(); - -// multiple window control - int overlay(CursesWindow &win); - int overwrite(CursesWindow &win); - - -// traversal support - CursesWindow* child(); - CursesWindow* sibling(); - CursesWindow* parent(); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - -inline int CursesWindow::begx() -{ - return w->_begx; -} - -inline int CursesWindow::begy() -{ - return w->_begy; -} - -inline int CursesWindow::maxx() -{ - return w->_maxx; -} - -inline int CursesWindow::maxy() -{ - return w->_maxy; -} - -inline int CursesWindow::height() -{ - return maxy() - begy() + 1; -} - -inline int CursesWindow::width() -{ - return maxx() - begx() + 1; -} - -inline int CursesWindow::box(char vert, char hor) -{ - return ::box(w, vert, hor); -} - -inline int CursesWindow::overlay(CursesWindow &win) -{ - return ::overlay(w, win.w); -} - -inline int CursesWindow::overwrite(CursesWindow &win) -{ - return ::overwrite(w, win.w); -} - -inline int CursesWindow::scroll() -{ - return ::scroll(w); -} - - -inline int CursesWindow::touchwin() -{ - return ::touchwin(w); -} - -inline int CursesWindow::addch(const char ch) -{ - return ::waddch(w, ch); -} - -inline int CursesWindow::addstr(const char * str) -{ - return ::waddstr(w, str); -} - -inline int CursesWindow::clear() -{ - return ::wclear(w); -} - -inline int CursesWindow::clrtobot() -{ - return ::wclrtobot(w); -} - -inline int CursesWindow::clrtoeol() -{ - return ::wclrtoeol(w); -} - -inline int CursesWindow::delch() -{ - return ::wdelch(w); -} - -inline int CursesWindow::deleteln() -{ - return ::wdeleteln(w); -} - -inline int CursesWindow::erase() -{ - return ::werase(w); -} - -inline int CursesWindow::getch() -{ - return ::wgetch(w); -} - -inline int CursesWindow::getstr(char * str) -{ - return ::wgetstr(w, str); -} - -inline int CursesWindow::inch() -{ - return winch(w); -} - -inline int CursesWindow::insch(char c) -{ - return ::winsch(w, c); -} - -inline int CursesWindow::insertln() -{ - return ::winsertln(w); -} - -inline int CursesWindow::move(int y, int x) -{ - return ::wmove(w, y, x); -} - - -inline int CursesWindow::mvcur(int sy, int ey, int sx, int ex) -{ - return ::mvcur(sy, ey, sx,ex); -} - -inline int CursesWindow::mvaddch(int y, int x, char ch) -{ - return (::wmove(w, y, x)==0) ? 0 : ::waddch(w, ch); -} - -inline int CursesWindow::mvgetch(int y, int x) -{ - return (::wmove(w, y, x)==0) ? 0 : ::wgetch(w); -} - -inline int CursesWindow::mvaddstr(int y, int x, char * str) -{ - return (::wmove(w, y, x)==0) ? 0 : ::waddstr(w, str); -} - -inline int CursesWindow::mvgetstr(int y, int x, char * str) -{ - return (::wmove(w, y, x)==0) ? 0 : ::wgetstr(w, str); -} - -inline int CursesWindow::mvinch(int y, int x) -{ - return (::wmove(w, y, x)==0) ? 0 : ::winch(w); -} - -inline int CursesWindow::mvdelch(int y, int x) -{ - return (::wmove(w, y, x)==0) ? 0 : ::wdelch(w); -} - -inline int CursesWindow::mvinsch(int y, int x, char ch) -{ - return (::wmove(w, y, x)==0) ? 0 : ::winsch(w, ch); -} - -inline int CursesWindow::refresh() -{ - return ::wrefresh(w); -} - -inline int CursesWindow::clearok(cbool bf) -{ - return ::clearok(w,bf); -} - -inline int CursesWindow::leaveok(cbool bf) -{ - return ::leaveok(w,bf); -} - -inline int CursesWindow::scrollok(cbool bf) -{ - return ::scrollok(w,bf); -} - -inline int CursesWindow::flushok(cbool bf) -{ - return ::flushok(w, bf); -} - -inline void CursesWindow::getyx(int& y, int& x) -{ - ::getyx(w, y, x); -} - -inline int CursesWindow::standout() -{ - return ::wstandout(w); -} - -inline int CursesWindow::standend() -{ - return ::wstandend(w); -} - -inline int CursesWindow::lines() -{ - return LINES; -} - -inline int CursesWindow::cols() -{ - return COLS; -} - -inline CursesWindow* CursesWindow::child() -{ - return subwins; -} - -inline CursesWindow* CursesWindow::parent() -{ - return par; -} - -inline CursesWindow* CursesWindow::sibling() -{ - return sib; -} - - -# endif -#endif diff --git a/gnu/lib/libg++/g++-include/DiscUnif.h b/gnu/lib/libg++/g++-include/DiscUnif.h deleted file mode 100644 index d99a7d47f974..000000000000 --- a/gnu/lib/libg++/g++-include/DiscUnif.h +++ /dev/null @@ -1,79 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _DiscreteUniform_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _DiscreteUniform_h 1 - -#include - -// -// The interval [lo..hi) -// - -class DiscreteUniform: public Random { - long pLow; - long pHigh; - double delta; -public: - DiscreteUniform(long low, long high, RNG *gen); - - long low(); - long low(long x); - long high(); - long high(long x); - - virtual double operator()(); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline DiscreteUniform::DiscreteUniform(long low, long high, RNG *gen) : (gen) -{ - pLow = (low < high) ? low : high; - pHigh = (low < high) ? high : low; - delta = (pHigh - pLow) + 1; -} - -inline long DiscreteUniform::low() { return pLow; } - -inline long DiscreteUniform::low(long x) { - long tmp = pLow; - pLow = x; - delta = (pHigh - pLow) + 1; - return tmp; -} - -inline long DiscreteUniform::high() { return pHigh; } - -inline long DiscreteUniform::high(long x) { - long tmp = pHigh; - pHigh = x; - delta = (pHigh - pLow) + 1; - return tmp; -} - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/Erlang.h b/gnu/lib/libg++/g++-include/Erlang.h deleted file mode 100644 index e770e5a5924e..000000000000 --- a/gnu/lib/libg++/g++-include/Erlang.h +++ /dev/null @@ -1,77 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _Erlang_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Erlang_h 1 - -#include - -class Erlang: public Random { -protected: - double pMean; - double pVariance; - int k; - double a; - void setState(); -public: - Erlang(double mean, double variance, RNG *gen); - - double mean(); - double mean(double x); - double variance(); - double variance(double x); - - virtual double operator()(); - -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline void Erlang::setState() { - k = int( (pMean * pMean ) / pVariance + 0.5 ); - k = (k > 0) ? k : 1; - a = k / pMean; -} - -inline Erlang::Erlang(double mean, double variance, RNG *gen) : (gen) -{ - pMean = mean; pVariance = variance; - setState(); -} - -inline double Erlang::mean() { return pMean; } -inline double Erlang::mean(double x) { - double tmp = pMean; pMean = x; setState(); return tmp; -}; - -inline double Erlang::variance() { return pVariance; } -inline double Erlang::variance(double x) { - double tmp = pVariance; pVariance = x; setState(); return tmp; -} - - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/File.h b/gnu/lib/libg++/g++-include/File.h deleted file mode 100644 index ce9dbef8bf02..000000000000 --- a/gnu/lib/libg++/g++-include/File.h +++ /dev/null @@ -1,302 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _File_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _File_h 1 - -#include -#include -#include - -#include - -class Filebuf; - -class File -{ - friend class Filebuf; -protected: - FILE* fp; // _iobuf file pointer - char* nm; // file name (dynamically allocated) - char rw; // 1 = read; 2 = write; 3 = readwrite - // bit 2 (4) means read/write into string - state_value state; // _good/_eof/_fail/_bad - long stat; // last read/write/... return value - - void initialize(); - void reinitialize(const char*); - char *readline (int chunk_number, char terminator); - -public: - File(); - File(const char* filename, io_mode m, access_mode a); - File(const char* filename, const char* m); - File(int filedesc, io_mode m); - File(FILE* fileptr); - File(int sz, char* buf, io_mode m); - - ~File(); - -// binding, rebinding, unbinding to physical files - - File& open(const char* filename, io_mode m, access_mode a); - File& open(const char* filename, const char* m); - File& open(int filedesc, io_mode m); - File& open(FILE* fileptr); - - File& close(); - File& remove(); - -// class variable access - - int filedesc(); - const char* name(); - void setname(const char* newname); - int iocount(); - - int rdstate(); - int eof(); - int fail(); - int bad(); - int good(); - -// other status queries - - int readable(); - int writable(); - int is_open(); - - operator void*(); - -// error handling - - void error(); - void clear(state_value f = _good); // poorly named - void set(state_value f); // set corresponding but - void unset(state_value f); // clear corresponding bit - File& failif(int cond); - void check_state(); - -// character IO - - File& get(char& c); - File& put(char c); - File& unget(char c); - File& putback(char c); // a synonym for unget - -// char* IO - - File& put(const char* s); - File& get (char* s, int n, char terminator = '\n'); - File& getline(char* s, int n, char terminator = '\n'); - File& gets (char **s, char terminator = '\n'); - -// binary IO - - File& read(void* x, int sz, int n); - File& write(void* x, int sz, int n); - -// formatted IO - - File& form(const char* ...); - File& scan(const char* ...); - -// buffer IO - - File& flush(); - -// position control - - File& seek(long pos, int seek_mode=0); // default seek mode=absolute - long tell(); - -// buffer control - - File& setbuf(int buffer_kind); // legal vals: _IONBF, _IOFBF, _IOLBF - File& setbuf(int size, char* buf); - File& raw(); -}; - - -// error handlers - -extern void verbose_File_error_handler(const char*); -extern void quiet_File_error_handler(const char*); -extern void fatal_File_error_handler(const char*); -extern one_arg_error_handler_t File_error_handler; -extern one_arg_error_handler_t set_File_error_handler(one_arg_error_handler_t); - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - - -inline int File::filedesc() -{ - return fileno(fp); -} - -inline const char* File::name() -{ - return nm; -} - -inline int File::iocount() -{ - return stat; -} - -inline void File::clear(state_value flag) -{ - state = flag; -} - -inline void File::set(state_value flag) -{ - state = state_value(int(state) | int(flag)); -} - -inline void File::unset(state_value flag) -{ - state = state_value(int(state) & ~int(flag)); -} - -inline int File::readable() -{ - if (fp != 0) { if (feof(fp)) set(_eof); if (ferror(fp)) set(_bad);} - return (state == _good && (rw & 01)); -} - -inline int File::writable() -{ - if (fp != 0 && ferror(fp)) set(_bad); - return ((int(state) & (int(_fail)|int(_bad))) == 0 && (rw & 02)); -} - -inline int File::is_open() -{ - return (fp != 0); -} - - -inline File& File::raw() -{ - return this->File::setbuf(_IONBF); -} - - -inline File& File::failif(int cond) -{ - if (cond) set(_fail); return *this; -} - -inline File& File::get(char& c) -{ - if (readable()) - { - int ch = getc(fp); - c = ch; - failif (ch == EOF); - } - return *this; -} - -inline File& File::put(char c) -{ - return failif (!writable() || putc(c, fp) == EOF); -} - -inline File& File::unget(char c) -{ - return failif(!is_open() || !(rw & 01) || ungetc(c, fp) == EOF); -} - -inline File& File::putback(char c) -{ - return failif (!is_open() || !(rw & 01) || ungetc(c, fp) == EOF); -} - -inline File& File::read(void* x, int sz, int n) -{ - return failif (!readable() || (stat = fread(x, sz, n, fp)) != n); -} - -inline File& File::write(void* x, int sz, int n) -{ - return failif (!writable() || (stat = fwrite(x, sz, n, fp)) != n); -} - -inline File& File::flush() -{ - return failif(!is_open() || fflush(fp) == EOF); -} - - -inline File& File::seek(long pos, int seek_mode) -{ - return failif (!is_open() || fseek(fp, pos, seek_mode) < 0); -} - -inline long File::tell() -{ - failif (!is_open() || ((stat = ftell(fp)) < 0)); - return stat; -} - -inline int File::rdstate() -{ - check_state(); return state; // check_state is necessary in rare but -} // possible circumstances - -inline File::operator void*() -{ - check_state(); return (int(state) & (int(_bad)|int(_fail)))? 0 : this ; -} - -inline int File::eof() -{ - check_state(); return state & _eof; -} - -inline int File::fail() -{ - check_state(); return state & _fail; -} - -inline int File::bad() -{ - check_state(); return state & _bad; -} - -inline int File::good() -{ - check_state(); return rdstate() == _good; -} - - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/Filebuf.h b/gnu/lib/libg++/g++-include/Filebuf.h deleted file mode 100644 index 2124e21c13d7..000000000000 --- a/gnu/lib/libg++/g++-include/Filebuf.h +++ /dev/null @@ -1,32 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _Filebuf_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Filebuf_h 1 - - -#endif diff --git a/gnu/lib/libg++/g++-include/Fix.h b/gnu/lib/libg++/g++-include/Fix.h deleted file mode 100644 index d325228ce51f..000000000000 --- a/gnu/lib/libg++/g++-include/Fix.h +++ /dev/null @@ -1,468 +0,0 @@ -// -// Fix.h : variable length fixed point data type -// - -#ifndef _Fix_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Fix_h 1 - -#include -#include -#include -#include - -typedef unsigned short uint16; -typedef short int16; -typedef unsigned long uint32; -typedef long int32; - -#define _Fix_min_length 1 -#define _Fix_max_length 65535 - -#define _Fix_min_value -1.0 -#define _Fix_max_value 1.0 - -extern uint16 Fix_default_length; -extern int Fix_default_print_width; - -struct _Frep // internal Fix representation -{ - uint16 len; // length in bits - uint16 siz; // allocated storage - int16 ref; // reference count - uint16 s[1]; // start of ushort array represention -}; - -typedef struct _Frep* _Fix; - -extern _Frep _Frep_0; -extern _Frep _Frep_m1; -extern _Frep _Frep_quotient_bump; - -class Fix -{ - _Fix rep; - - Fix(_Fix); - - void unique(); - -public: - Fix(); - Fix(Fix&); - Fix(double&); - Fix(int); - Fix(int, Fix&); - Fix(int, double&); - Fix(int, _Frep*); - - ~Fix(); - - Fix operator = (Fix&); - Fix operator = (double&); - - friend int operator == (Fix&, Fix& ); - friend int operator != (Fix&, Fix&); - - friend int operator < (Fix&, Fix&); - friend int operator <= (Fix&, Fix&); - friend int operator > (Fix&, Fix&); - friend int operator >= (Fix&, Fix&); - - Fix& operator + (); - Fix operator - (); - - friend Fix operator + (Fix&, Fix&); - friend Fix operator - (Fix&, Fix&); - friend Fix operator * (Fix&, Fix&); - friend Fix operator / (Fix&, Fix&); - - friend Fix operator * (Fix&, int); - friend Fix operator * (int, Fix&); - friend Fix operator % (Fix&, int); - friend Fix operator << (Fix&, int); - friend Fix operator >> (Fix&, int); - -#ifdef __GNUG__ - friend Fix operator ? (Fix&, Fix&); // max -#endif - - Fix operator += (Fix&); - Fix operator -= (Fix&); - Fix operator *= (Fix&); - Fix operator /= (Fix&); - - Fix operator *= (int); - Fix operator %= (int); - Fix operator <<=(int); - Fix operator >>=(int); - - friend char* Ftoa(Fix&, int width = Fix_default_print_width); - friend Fix atoF(const char*, int len = Fix_default_length); - - friend istream& operator >> (istream&, Fix&); - friend ostream& operator << (ostream&, Fix&); - - // built-in functions - friend Fix abs(Fix); // absolute value - friend int sgn(Fix&); // -1, 0, +1 - friend Integer mantissa(Fix&); // integer representation - friend double value(Fix&); // double value - friend int length(Fix&); // field length - friend void show(Fix&); // show contents - - // error handlers - void error(const char* msg); // error handler - void range_error(const char* msg); // range error handler - - // internal class functions - friend void mask(_Fix); - friend int compare(_Fix, _Fix = &_Frep_0); - - friend _Fix new_Fix(uint16); - friend _Fix new_Fix(uint16, _Fix); - friend _Fix new_Fix(uint16, double); - - friend _Fix copy(_Fix, _Fix); - friend _Fix negate(_Fix, _Fix = NULL); - friend _Fix add(_Fix, _Fix, _Fix = NULL); - friend _Fix subtract(_Fix, _Fix, _Fix = NULL); - friend _Fix multiply(_Fix, _Fix, _Fix = NULL); - friend _Fix multiply(_Fix, int, _Fix = NULL); - friend _Fix divide(_Fix, _Fix, _Fix = NULL, _Fix = NULL); - friend _Fix shift(_Fix, int, _Fix = NULL); - - // non-operator versions for user - friend void negate(Fix& x, Fix& r); - friend void add(Fix& x, Fix& y, Fix& r); - friend void subtract(Fix& x, Fix& y, Fix& r); - friend void multiply(Fix& x, Fix& y, Fix& r); - friend void divide(Fix& x, Fix& y, Fix& q, Fix& r); - friend void shift(Fix& x, int y, Fix& r); -}; - -// error handlers - -extern void - default_Fix_error_handler(const char*), - default_Fix_range_error_handler(const char*); - -extern one_arg_error_handler_t - Fix_error_handler, - Fix_range_error_handler; - -extern one_arg_error_handler_t - set_Fix_error_handler(one_arg_error_handler_t f), - set_Fix_range_error_handler(one_arg_error_handler_t f); - -typedef void (*Fix_peh)(_Fix&); -extern Fix_peh Fix_overflow_handler; - -extern void - Fix_overflow_saturate(_Fix&), - Fix_overflow_wrap(_Fix&), - Fix_overflow_warning_saturate(_Fix&), - Fix_overflow_warning(_Fix&), - Fix_overflow_error(_Fix&); - -extern Fix_peh set_overflow_handler(Fix_peh); - -extern int Fix_set_default_length(int); - -// function definitions - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline void Fix::unique() -{ - if ( rep->ref > 1 ) - { - rep->ref--; - rep = new_Fix(rep->len,rep); - } -} - -inline void mask (_Fix x) -{ - int n = x->len & 0x0f; - if ( n ) - x->s[x->siz - 1] &= 0xffff0000 >> n; -} - -inline _Fix copy(_Fix from, _Fix to) -{ - uint16 *ts = to->s, *fs = from->s; - int ilim = to->siz < from->siz ? to->siz : from->siz; - for ( int i=0; i < ilim; i++ ) - *ts++ = *fs++; - for ( ; i < to->siz; i++ ) - *ts++ = 0; - mask(to); - return to; -} - -inline Fix::Fix(_Fix f) -{ - rep = f; -} - -inline Fix::Fix() -{ - rep = new_Fix(Fix_default_length); -} - -inline Fix::Fix(int len) -{ - if ( len < _Fix_min_length || len > _Fix_max_length ) - error("illegal length in declaration"); - rep = new_Fix((uint16 )len); -} - -inline Fix::Fix(double& d) -{ - rep = new_Fix(Fix_default_length,d); -} - -inline Fix::Fix(Fix& y) -{ - rep = y.rep; rep->ref++; -} - -inline Fix::Fix(int len, Fix& y) -{ - if ( len < _Fix_min_length || len > _Fix_max_length ) - error("illegal length in declaration"); - rep = new_Fix((uint16 )len,y.rep); -} - -inline Fix::Fix(int len, _Frep* fr) -{ - if ( len < 1 || len > 65535 ) - error("illegal length in declaration"); - rep = new_Fix((uint16 )len,fr); -} - -inline Fix::Fix(int len, double& d) -{ - if ( len < _Fix_min_length || len > _Fix_max_length ) - error("illegal length in declaration"); - rep = new_Fix((uint16 )len,d); -} - -inline Fix::~Fix() -{ - if ( --rep->ref <= 0 ) delete rep; -} - -inline Fix Fix::operator = (Fix& y) -{ - if ( rep->len == y.rep->len ) { - ++y.rep->ref; - if ( --rep->ref <= 0 ) delete rep; - rep = y.rep; - } - else { - unique(); - copy(y.rep,rep); - } - return *this; -} - -inline Fix Fix::operator = (double& d) -{ - int oldlen = rep->len; - if ( --rep->ref <= 0 ) delete rep; - rep = new_Fix(oldlen,d); - return *this; -} - -inline int operator == (Fix& x, Fix& y) -{ - return compare(x.rep, y.rep) == 0; -} - -inline int operator != (Fix& x, Fix& y) -{ - return compare(x.rep, y.rep) != 0; -} - -inline int operator < (Fix& x, Fix& y) -{ - return compare(x.rep, y.rep) < 0; -} - -inline int operator <= (Fix& x, Fix& y) -{ - return compare(x.rep, y.rep) <= 0; -} - -inline int operator > (Fix& x, Fix& y) -{ - return compare(x.rep, y.rep) > 0; -} - -inline int operator >= (Fix& x, Fix& y) -{ - return compare(x.rep, y.rep) >= 0; -} - -inline Fix& Fix::operator + () -{ - return *this; -} - -inline Fix Fix::operator - () -{ - _Fix r = negate(rep); return r; -} - -inline Fix operator + (Fix& x, Fix& y) -{ - _Fix r = add(x.rep, y.rep); return r; -} - -inline Fix operator - (Fix& x, Fix& y) -{ - _Fix r = subtract(x.rep, y.rep); return r; -} - -inline Fix operator * (Fix& x, Fix& y) -{ - _Fix r = multiply(x.rep, y.rep); return r; -} - -inline Fix operator * (Fix& x, int y) -{ - _Fix r = multiply(x.rep, y); return r; -} - -inline Fix operator * (int y, Fix& x) -{ - _Fix r = multiply(x.rep, y); return r; -} - -inline Fix operator / (Fix& x, Fix& y) -{ - _Fix r = divide(x.rep, y.rep); return r; -} - -inline Fix Fix::operator += (Fix& y) -{ - unique(); add(rep, y.rep, rep); return *this; -} - -inline Fix Fix::operator -= (Fix& y) -{ - unique(); subtract(rep, y.rep, rep); return *this; -} - -inline Fix Fix::operator *= (Fix& y) -{ - unique(); multiply(rep, y.rep, rep); return *this; -} - -inline Fix Fix::operator *= (int y) -{ - unique(); multiply(rep, y, rep); return *this; -} - -inline Fix Fix::operator /= (Fix& y) -{ - unique(); divide(rep, y.rep, rep); return *this; -} - -inline Fix operator % (Fix& x, int y) -{ - Fix r((int )x.rep->len + y, x); return r; -} - -inline Fix operator << (Fix& x, int y) -{ - _Fix rep = shift(x.rep, y); return rep; -} - -inline Fix operator >> (Fix& x, int y) -{ - _Fix rep = shift(x.rep, -y); return rep; -} - -inline Fix Fix::operator <<= (int y) -{ - unique(); shift(rep, y, rep); return *this; -} - -inline Fix Fix::operator >>= (int y) -{ - unique(); shift(rep, -y, rep); return *this; -} - -#ifdef __GNUG__ -inline Fix operator ? (Fix& x, Fix& y) -{ - if ( compare(x.rep, y.rep) >= 0 ) return x; else return y; -} -#endif - -inline Fix abs(Fix x) -{ - _Fix r = (compare(x.rep) >= 0 ? new_Fix(x.rep->len,x.rep) : negate(x.rep)); - return r; -} - -inline int sgn(Fix& x) -{ - int a = compare(x.rep); - return a == 0 ? 0 : (a > 0 ? 1 : -1); -} - -inline int length(Fix& x) -{ - return x.rep->len; -} - -inline ostream& operator << (ostream& s, Fix& y) -{ - return s << Ftoa(y); -} - -inline void negate (Fix& x, Fix& r) -{ - negate(x.rep, r.rep); -} - -inline void add (Fix& x, Fix& y, Fix& r) -{ - add(x.rep, y.rep, r.rep); -} - -inline void subtract (Fix& x, Fix& y, Fix& r) -{ - subtract(x.rep, y.rep, r.rep); -} - -inline void multiply (Fix& x, Fix& y, Fix& r) -{ - multiply(x.rep, y.rep, r.rep); -} - -inline void divide (Fix& x, Fix& y, Fix& q, Fix& r) -{ - divide(x.rep, y.rep, q.rep, r.rep); -} - -inline void shift (Fix& x, int y, Fix& r) -{ - shift(x.rep, y, r.rep); -} - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/Fix16.h b/gnu/lib/libg++/g++-include/Fix16.h deleted file mode 100644 index 0024c9da1108..000000000000 --- a/gnu/lib/libg++/g++-include/Fix16.h +++ /dev/null @@ -1,647 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu) - adapted for libg++ by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _Fix16_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Fix16_h 1 - -#include -#include - -// constant definitions - -#define Fix16_fs ((double)((unsigned)(1 << 15))) - -#define Fix16_msb (1 << 15) -#define Fix16_m_max ((1 << 15) - 1) -#define Fix16_m_min ((short)(1 << 15)) - -#define Fix16_mult Fix16_fs -#define Fix16_div (1./Fix16_fs) -#define Fix16_max (1. - .5/Fix16_fs) -#define Fix16_min (-1.) - - -#define Fix32_fs ((double)((unsigned long)(1 << 31))) - -#define Fix32_msb ((unsigned long)(1 << 31)) -#define Fix32_m_max ((1 << 31) - 1) -#define Fix32_m_min ((long)(1 << 31)) - -#define Fix32_mult Fix32_fs -#define Fix32_div (1./Fix32_fs) -#define Fix32_max (1. - .5/Fix32_fs) -#define Fix32_min (-1.) - - -// -// Fix16 class: 16-bit Fixed point data type -// -// consists of a 16-bit mantissa (sign bit & 15 data bits). -// - -class Fix16 -{ - friend class Fix32; - - short m; - - short round(double d); - short assign(double d); - Fix16(short i); - Fix16(int i); - - operator double(); - - -public: - Fix16(); - Fix16(Fix16& f); - Fix16(double d); - Fix16(Fix32& f); - - ~Fix16(); - - Fix16& operator=(Fix16& f); - Fix16& operator=(double d); - Fix16& operator=(Fix32& f); - - friend short& mantissa(Fix16& f); - friend double value(Fix16& f); - - Fix16 operator + (); - Fix16 operator - (); - - friend Fix16 operator + (Fix16& f, Fix16& g); - friend Fix16 operator - (Fix16& f, Fix16& g); - friend Fix32 operator * (Fix16& f, Fix16& g); - friend Fix16 operator / (Fix16& f, Fix16& g); - friend Fix16 operator << (Fix16& f, int b); - friend Fix16 operator >> (Fix16& f, int b); - - Fix16& operator += (Fix16& f); - Fix16& operator -= (Fix16& f); - Fix16& operator *= (Fix16& ); - Fix16& operator /= (Fix16& f); - - Fix16& operator <<=(int b); - Fix16& operator >>=(int b); - - friend int operator == (Fix16& f, Fix16& g); - friend int operator != (Fix16& f, Fix16& g); - friend int operator >= (Fix16& f, Fix16& g); - friend int operator <= (Fix16& f, Fix16& g); - friend int operator > (Fix16& f, Fix16& g); - friend int operator < (Fix16& f, Fix16& g); - - friend istream& operator >> (istream& s, Fix16& f); - friend ostream& operator << (ostream& s, Fix16& f); - - void overflow(short&); - void range_error(short&); - - friend Fix16 operator * (Fix16& f, int g); - friend Fix16 operator * (int g, Fix16& f); - Fix16& operator *= (int g); -}; - - -// -// Fix32 class: 32-bit Fixed point data type -// -// consists of a 32-bit mantissa (sign bit & 31 data bits). -// - -class Fix32 -{ - friend class Fix16; - - long m; - - long round(double d); - long assign(double d); - - Fix32(long i); - operator double(); - - -public: - Fix32(); - Fix32(Fix32& f); - Fix32(Fix16& f); - Fix32(double d); - ~Fix32(); - - Fix32& operator = (Fix32& f); - Fix32& operator = (Fix16& f); - Fix32& operator = (double d); - - friend long& mantissa(Fix32& f); - friend double value(Fix32& f); - - Fix32 operator + (); - Fix32 operator - (); - - friend Fix32 operator + (Fix32& f, Fix32& g); - friend Fix32 operator - (Fix32& f, Fix32& g); - friend Fix32 operator * (Fix32& f, Fix32& g); - friend Fix32 operator / (Fix32& f, Fix32& g); - friend Fix32 operator << (Fix32& f, int b); - friend Fix32 operator >> (Fix32& f, int b); - - friend Fix32 operator * (Fix16& f, Fix16& g); - - Fix32& operator += (Fix32& f); - Fix32& operator -= (Fix32& f); - Fix32& operator *= (Fix32& f); - Fix32& operator /= (Fix32& f); - Fix32& operator <<=(int b); - Fix32& operator >>=(int b); - - friend int operator == (Fix32& f, Fix32& g); - friend int operator != (Fix32& f, Fix32& g); - friend int operator >= (Fix32& f, Fix32& g); - friend int operator <= (Fix32& f, Fix32& g); - friend int operator > (Fix32& f, Fix32& g); - friend int operator < (Fix32& f, Fix32& g); - - friend istream& operator >> (istream& s, Fix32& f); - friend ostream& operator << (ostream& s, Fix32& f); - - void overflow(long& i); - void range_error(long& i); - - friend Fix32 operator * (Fix32& f, int g); - friend Fix32 operator * (int g, Fix32& f); - Fix32& operator *= (int g); -}; - -// active error handler declarations - -typedef void (*Fix16_peh)(short&); -typedef void (*Fix32_peh)(long&); - -extern Fix16_peh Fix16_overflow_handler; -extern Fix32_peh Fix32_overflow_handler; - -extern Fix16_peh Fix16_range_error_handler; -extern Fix32_peh Fix32_range_error_handler; - -#if defined(SHORT_NAMES) || defined(VMS) -#define set_overflow_handler sohndl -#define set_range_error_handler srnghdl -#endif - - -// error handler declarations - -extern Fix16_peh set_Fix16_overflow_handler(Fix16_peh); -extern Fix32_peh set_Fix32_overflow_handler(Fix32_peh); -extern void set_overflow_handler(Fix16_peh, Fix32_peh); - -extern Fix16_peh set_Fix16_range_error_handler(Fix16_peh); -extern Fix32_peh set_Fix32_range_error_handler(Fix32_peh); -extern void set_range_error_handler(Fix16_peh, Fix32_peh); - -extern void - Fix16_ignore(short&), - Fix16_overflow_saturate(short&), - Fix16_overflow_warning_saturate(short&), - Fix16_warning(short&), - Fix16_abort(short&); - -extern void - Fix32_ignore(long&), - Fix32_overflow_saturate(long&), - Fix32_overflow_warning_saturate(long&), - Fix32_warning(long&), - Fix32_abort(long&); - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline Fix16::~Fix16() {} - -inline short Fix16::round(double d) -{ - return short( (d >= 0)? d + 0.5 : d - 0.5); -} - -inline Fix16::Fix16(short i) -{ - m = i; -} - -inline Fix16::Fix16(int i) -{ - m = i; -} - -inline Fix16::operator double() -{ - return Fix16_div * m; -} - -inline Fix16::Fix16() -{ - m = 0; -} - -inline Fix16::Fix16(Fix16& f) -{ - m = f.m; -} - -inline Fix16::Fix16(double d) -{ - m = assign(d); -} - - -inline Fix16& Fix16::operator=(Fix16& f) -{ - m = f.m; - return *this; -} - -inline Fix16& Fix16::operator=(double d) -{ - m = assign(d); - return *this; -} - - -inline Fix32::Fix32() -{ - m = 0; -} - -inline Fix32::Fix32(long i) -{ - m = i; -} - -inline Fix32:: operator double() -{ - return Fix32_div * m; -} - - -inline Fix32::Fix32(Fix32& f) -{ - m = f.m; -} - -inline Fix32::Fix32(Fix16& f) -{ - m = long(f.m) << 16; -} - -inline Fix32::Fix32(double d) -{ - m = assign(d); -} - -inline Fix16::Fix16(Fix32& f) -{ - m = f.m >> 16; -} - - -inline Fix16& Fix16::operator=(Fix32& f) -{ - m = f.m >> 16; - return *this; -} - -inline Fix32& Fix32::operator=(Fix32& f) -{ - m = f.m; - return *this; -} - -inline Fix32& Fix32::operator=(Fix16& f) -{ - m = long(f.m) << 16; - return *this; -} - -inline Fix32& Fix32::operator=(double d) -{ - m = assign(d); - return *this; -} - -inline short& mantissa(Fix16& f) -{ - return f.m; -} - -inline double value(Fix16& f) -{ - return double(f); -} - -inline Fix16 Fix16::operator+() -{ - return m; -} - -inline Fix16 Fix16::operator-() -{ - return -m; -} - -inline Fix16 operator+(Fix16& f, Fix16& g) -{ - short sum = f.m + g.m; - if ( (f.m ^ sum) & (g.m ^ sum) & Fix16_msb ) - f.overflow(sum); - return sum; -} - -inline Fix16 operator-(Fix16& f, Fix16& g) -{ - short sum = f.m - g.m; - if ( (f.m ^ sum) & (-g.m ^ sum) & Fix16_msb ) - f.overflow(sum); - return sum; -} - -inline Fix32 operator*(Fix16& f, Fix16& g) -{ - return Fix32( long( long(f.m) * long(g.m) << 1)); -} - -inline Fix16 operator<<(Fix16& a, int b) -{ - return a.m << b; -} - -inline Fix16 operator>>(Fix16& a, int b) -{ - return a.m >> b; -} - -inline Fix16& Fix16:: operator+=(Fix16& f) -{ - return *this = *this + f; -} - -inline Fix16& Fix16:: operator-=(Fix16& f) -{ - return *this = *this - f; -} - -inline Fix16& Fix16::operator*=(Fix16& f) -{ - return *this = *this * f; -} - -inline Fix16& Fix16:: operator/=(Fix16& f) -{ - return *this = *this / f; -} - -inline Fix16& Fix16:: operator<<=(int b) -{ - return *this = *this << b; -} - -inline Fix16& Fix16:: operator>>=(int b) -{ - return *this = *this >> b; -} - -inline int operator==(Fix16& f, Fix16& g) -{ - return f.m == g.m; -} - -inline int operator!=(Fix16& f, Fix16& g) -{ - return f.m != g.m; -} - -inline int operator>=(Fix16& f, Fix16& g) -{ - return f.m >= g.m; -} - -inline int operator<=(Fix16& f, Fix16& g) -{ - return f.m <= g.m; -} - -inline int operator>(Fix16& f, Fix16& g) -{ - return f.m > g.m; -} - -inline int operator<(Fix16& f, Fix16& g) -{ - return f.m < g.m; -} - -inline istream& operator>>(istream& s, Fix16& f) -{ - double d; - s >> d; - f = d; - return s; -} - -inline ostream& operator<<(ostream& s, Fix16& f) -{ - return s << double(f); -} - - -inline Fix16 operator*(Fix16& f, int g) -{ - return Fix16(short(f.m * g)); -} - -inline Fix16 operator*(int g, Fix16& f) -{ - return f * g; -} - - -inline Fix16& Fix16::operator*=(int g) -{ - return *this = *this * g; -} - -inline Fix32::~Fix32() {} - -inline long Fix32::round(double d) -{ - return long( (d >= 0)? d + 0.5 : d - 0.5); -} - - -inline long& mantissa(Fix32& f) -{ - return f.m; -} - -inline double value(Fix32& f) -{ - return double(f); -} - -inline Fix32 Fix32::operator+() -{ - return m; -} - -inline Fix32 Fix32::operator-() -{ - return -m; -} - -inline Fix32 operator+(Fix32& f, Fix32& g) -{ - long sum = f.m + g.m; - if ( (f.m ^ sum) & (g.m ^ sum) & Fix32_msb ) - f.overflow(sum); - return sum; -} - -inline Fix32 operator-(Fix32& f, Fix32& g) -{ - long sum = f.m - g.m; - if ( (f.m ^ sum) & (-g.m ^ sum) & Fix32_msb ) - f.overflow(sum); - return sum; -} - -inline Fix32 operator<<(Fix32& a, int b) -{ - return a.m << b; -} - -inline Fix32 operator>>(Fix32& a, int b) -{ - return a.m >> b; -} - -inline Fix32& Fix32::operator+=(Fix32& f) -{ - return *this = *this + f; -} - -inline Fix32& Fix32::operator-=(Fix32& f) -{ - return *this = *this - f; -} - -inline Fix32& Fix32::operator*=(Fix32& f) -{ - return *this = *this * f; -} - -inline Fix32& Fix32::operator/=(Fix32& f) -{ - return *this = *this / f; -} - - -inline Fix32& Fix32::operator<<=(int b) -{ - return *this = *this << b; -} - -inline Fix32& Fix32::operator>>=(int b) -{ - return *this = *this >> b; -} - -inline int operator==(Fix32& f, Fix32& g) -{ - return f.m == g.m; -} - -inline int operator!=(Fix32& f, Fix32& g) -{ - return f.m != g.m; -} - -inline int operator>=(Fix32& f, Fix32& g) -{ - return f.m >= g.m; -} - -inline int operator<=(Fix32& f, Fix32& g) -{ - return f.m <= g.m; -} - -inline int operator>(Fix32& f, Fix32& g) -{ - return f.m > g.m; -} - -inline int operator<(Fix32& f, Fix32& g) -{ - return f.m < g.m; -} - -inline istream& operator>>(istream& s, Fix32& f) -{ - double d; - s >> d; - f = d; - return s; -} - -inline ostream& operator<<(ostream& s, Fix32& f) -{ - return s << double(f); -} - -inline Fix32 operator*(Fix32& f, int g) -{ - return Fix32(long(f.m * g)); -} - -inline Fix32 operator*(int g, Fix32& f) -{ - return f * g; -} - - - -inline Fix32& Fix32::operator*=(int g) -{ - return *this = *this * g; -} - - -#endif -#endif - diff --git a/gnu/lib/libg++/g++-include/Fix24.h b/gnu/lib/libg++/g++-include/Fix24.h deleted file mode 100644 index ec48afcae6e1..000000000000 --- a/gnu/lib/libg++/g++-include/Fix24.h +++ /dev/null @@ -1,595 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu) - adapted for libg++ by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _Fix24_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Fix24_h 1 - -#include -#include - -// extra type definitions - -typedef struct { - long u; - unsigned long l; -} twolongs; - -// constant definitions - -static const int - Fix24_shift = 31; - -static const double - Fix24_fs = 2147483648., // 2^Fix24_shift - Fix24_mult = Fix24_fs, - Fix24_div = 1./Fix24_fs, - Fix24_max = 1. - .5/Fix24_fs, - Fix24_min = -1.; - -static const unsigned long - Fix24_msb = 0x80000000L, - Fix24_lsb = 0x00000100L, - Fix24_m_max = 0x7fffff00L, - Fix24_m_min = 0x80000000L; - -static const double - Fix48_fs = 36028797018963968., // 2^(24+Fix24_shift) - Fix48_max = 1. - .5/Fix48_fs, - Fix48_min = -1., - Fix48_div_u = 1./Fix24_fs, - Fix48_div_l = 1./Fix48_fs; - -static const twolongs - Fix48_msb = { 0x80000000L, 0L }, - Fix48_lsb = { 0L, 0x00000100L }, - Fix48_m_max = { 0x7fffff00L, 0xffffff00L }, - Fix48_m_min = { 0x80000000L, 0L }; - -// -// Fix24 class: 24-bit Fixed point data type -// -// consists of a 24-bit mantissa (sign bit & 23 data bits). -// - -class Fix24 -{ - friend class Fix48; - - long m; - - long assign(double d); - operator double(); - Fix24(long i); - Fix24(int i); - - -public: - Fix24(); - Fix24(Fix24& f); - Fix24(double d); - Fix24(Fix48& f); - - ~Fix24(); - - Fix24& operator=(Fix24& f); - Fix24& operator=(double d); - Fix24& operator=(Fix48& f); - - friend long& mantissa(Fix24& f); - friend double value(Fix24& f); - - Fix24 operator + (); - Fix24 operator - (); - - friend Fix24 operator + (Fix24& f, Fix24& g); - friend Fix24 operator - (Fix24& f, Fix24& g); - friend Fix48 operator * (Fix24& f, Fix24& g); - friend Fix24 operator * (Fix24& f, int g); - friend Fix24 operator * (int g, Fix24& f); - friend Fix24 operator / (Fix24& f, Fix24& g); - friend Fix24 operator << (Fix24& f, int b); - friend Fix24 operator >> (Fix24& f, int b); - - Fix24& operator += (Fix24& f); - Fix24& operator -= (Fix24& f); - Fix24& operator *= (Fix24& f); - Fix24& operator *= (int b); - Fix24& operator /= (Fix24& f); - - Fix24& operator <<=(int b); - Fix24& operator >>=(int b); - - friend int operator == (Fix24& f, Fix24& g); - friend int operator != (Fix24& f, Fix24& g); - friend int operator >= (Fix24& f, Fix24& g); - friend int operator <= (Fix24& f, Fix24& g); - friend int operator > (Fix24& f, Fix24& g); - friend int operator < (Fix24& f, Fix24& g); - - friend istream& operator >> (istream& s, Fix24& f); - friend ostream& operator << (ostream& s, Fix24& f); - - void overflow(long&); - void range_error(long&); -}; - - -// -// Fix48 class: 48-bit Fixed point data type -// -// consists of a 48-bit mantissa (sign bit & 47 data bits). -// - -class Fix48 -{ - friend class Fix24; - - twolongs m; - - twolongs assign(double d); - operator double(); - Fix48(twolongs i); - -public: - Fix48(); - Fix48(Fix48& f); - Fix48(Fix24& f); - Fix48(double d); - ~Fix48(); - - Fix48& operator = (Fix48& f); - Fix48& operator = (Fix24& f); - Fix48& operator = (double d); - - friend twolongs& mantissa(Fix48& f); - friend double value(Fix48& f); - - Fix48 operator + (); - Fix48 operator - (); - - friend Fix48 operator + (Fix48& f, Fix48& g); - friend Fix48 operator - (Fix48& f, Fix48& g); - friend Fix48 operator * (Fix48& f, int g); - friend Fix48 operator * (int g, Fix48& f); - friend Fix48 operator << (Fix48& f, int b); - friend Fix48 operator >> (Fix48& f, int b); - - friend Fix48 operator * (Fix24& f, Fix24& g); - - Fix48& operator += (Fix48& f); - Fix48& operator -= (Fix48& f); - Fix48& operator *= (int b); - Fix48& operator <<=(int b); - Fix48& operator >>=(int b); - - friend int operator == (Fix48& f, Fix48& g); - friend int operator != (Fix48& f, Fix48& g); - friend int operator >= (Fix48& f, Fix48& g); - friend int operator <= (Fix48& f, Fix48& g); - friend int operator > (Fix48& f, Fix48& g); - friend int operator < (Fix48& f, Fix48& g); - - friend istream& operator >> (istream& s, Fix48& f); - friend ostream& operator << (ostream& s, Fix48& f); - - void overflow(twolongs& i); - void range_error(twolongs& i); -}; - - -// active error handler declarations - -typedef void (*Fix24_peh)(long&); -typedef void (*Fix48_peh)(twolongs&); - -extern Fix24_peh Fix24_overflow_handler; -extern Fix48_peh Fix48_overflow_handler; - -extern Fix24_peh Fix24_range_error_handler; -extern Fix48_peh Fix48_range_error_handler; - - -// error handler declarations - -#if defined(SHORT_NAMES) || defined(VMS) -#define set_overflow_handler sohndl -#define set_range_error_handler srnghdl -#endif - -extern Fix24_peh set_Fix24_overflow_handler(Fix24_peh); -extern Fix48_peh set_Fix48_overflow_handler(Fix48_peh); -extern void set_overflow_handler(Fix24_peh, Fix48_peh); - -extern Fix24_peh set_Fix24_range_error_handler(Fix24_peh); -extern Fix48_peh set_Fix48_range_error_handler(Fix48_peh); -extern void set_range_error_handler(Fix24_peh, Fix48_peh); - -extern void - Fix24_ignore(long&), - Fix24_overflow_saturate(long&), - Fix24_overflow_warning_saturate(long&), - Fix24_warning(long&), - Fix24_abort(long&); - -extern void - Fix48_ignore(twolongs&), - Fix48_overflow_saturate(twolongs&), - Fix48_overflow_warning_saturate(twolongs&), - Fix48_warning(twolongs&), - Fix48_abort(twolongs&); - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline Fix24::~Fix24() {} - -inline Fix24::Fix24(long i) -{ - m = i; -} - -inline Fix24::Fix24(int i) -{ - m = i; -} - -inline Fix24::operator double() -{ - return Fix24_div * m; -} - -inline Fix24::Fix24() -{ - m = 0; -} - -inline Fix24::Fix24(Fix24& f) -{ - m = f.m; -} - -inline Fix24::Fix24(double d) -{ - m = assign(d); -} - -inline Fix24::Fix24(Fix48& f) -{ - m = f.m.u; -} - -inline Fix24& Fix24::operator=(Fix24& f) -{ - m = f.m; - return *this; -} - -inline Fix24& Fix24::operator=(double d) -{ - m = assign(d); - return *this; -} - -inline Fix24& Fix24::operator=(Fix48& f) -{ - m = f.m.u; - return *this; -} - -inline long& mantissa(Fix24& f) -{ - return f.m; -} - -inline double value(Fix24& f) -{ - return double(f); -} - -inline Fix24 Fix24::operator+() -{ - return m; -} - -inline Fix24 Fix24::operator-() -{ - return -m; -} - -inline Fix24 operator+(Fix24& f, Fix24& g) -{ - long sum = f.m + g.m; - if ( (f.m ^ sum) & (g.m ^ sum) & Fix24_msb ) - f.overflow(sum); - return sum; -} - -inline Fix24 operator-(Fix24& f, Fix24& g) -{ - long sum = f.m - g.m; - if ( (f.m ^ sum) & (-g.m ^ sum) & Fix24_msb ) - f.overflow(sum); - return sum; -} - -inline Fix24 operator*(Fix24& a, int b) -{ - return a.m * b; -} - -inline Fix24 operator*(int b, Fix24& a) -{ - return a * b; -} - -inline Fix24 operator<<(Fix24& a, int b) -{ - return a.m << b; -} - -inline Fix24 operator>>(Fix24& a, int b) -{ - return (a.m >> b) & 0xffffff00L; -} - -inline Fix24& Fix24:: operator+=(Fix24& f) -{ - return *this = *this + f; -} - -inline Fix24& Fix24:: operator-=(Fix24& f) -{ - return *this = *this - f; -} - -inline Fix24& Fix24::operator*=(Fix24& f) -{ - return *this = *this * f; -} - -inline Fix24& Fix24:: operator/=(Fix24& f) -{ - return *this = *this / f; -} - -inline Fix24& Fix24:: operator<<=(int b) -{ - return *this = *this << b; -} - -inline Fix24& Fix24:: operator>>=(int b) -{ - return *this = *this >> b; -} - -inline Fix24& Fix24::operator*=(int b) -{ - return *this = *this * b; -} - -inline int operator==(Fix24& f, Fix24& g) -{ - return f.m == g.m; -} - -inline int operator!=(Fix24& f, Fix24& g) -{ - return f.m != g.m; -} - -inline int operator>=(Fix24& f, Fix24& g) -{ - return f.m >= g.m; -} - -inline int operator<=(Fix24& f, Fix24& g) -{ - return f.m <= g.m; -} - -inline int operator>(Fix24& f, Fix24& g) -{ - return f.m > g.m; -} - -inline int operator<(Fix24& f, Fix24& g) -{ - return f.m < g.m; -} - -inline istream& operator>>(istream& s, Fix24& f) -{ - double d; - s >> d; - f = d; - return s; -} - -inline ostream& operator<<(ostream& s, Fix24& f) -{ - return s << double(f); -} - -inline Fix48::~Fix48() {} - -inline Fix48::Fix48(twolongs i) -{ - m = i; -} - -inline Fix48:: operator double() -{ -/* - * Note: can't simply do Fix48_div_u * m.u + Fix48_div_l * m.l, because - * m.u is signed and m.l is unsigned. - */ - return (m.u >= 0)? Fix48_div_u * m.u + Fix48_div_l * m.l : - (Fix48_div_u * ((unsigned long)(m.u & 0xffffff00)) - + Fix48_div_l * m.l) - 2; -} - -inline Fix48::Fix48() -{ - m.u = 0; - m.l = 0; -} - -inline Fix48::Fix48(Fix48& f) -{ - m = f.m; -} - -inline Fix48::Fix48(Fix24& f) -{ - m.u = f.m; - m.l = 0; -} - -inline Fix48::Fix48(double d) -{ - m = assign(d); -} - -inline Fix48& Fix48::operator=(Fix48& f) -{ - m = f.m; - return *this; -} - -inline Fix48& Fix48::operator=(Fix24& f) -{ - m.u = f.m; - m.l = 0; - return *this; -} - -inline Fix48& Fix48::operator=(double d) -{ - m = assign(d); - return *this; -} - -inline twolongs& mantissa(Fix48& f) -{ - return f.m; -} - -inline double value(Fix48& f) -{ - return double(f); -} - -inline Fix48 Fix48::operator+() -{ - return m; -} - -inline Fix48 Fix48::operator-() -{ - twolongs n; - n.l = -m.l; - n.u = ~m.u + ((n.l ^ m.l) & Fix24_msb ? 0 : Fix24_lsb); - return Fix48(n); -} - -inline Fix48 operator*(int b, Fix48& a) -{ - return a * b; -} - -inline Fix48& Fix48::operator+=(Fix48& f) -{ - return *this = *this + f; -} - -inline Fix48& Fix48::operator-=(Fix48& f) -{ - return *this = *this - f; -} - -inline Fix48& Fix48::operator*=(int b) -{ - return *this = *this * b; -} - -inline Fix48& Fix48::operator<<=(int b) -{ - return *this = *this << b; -} - -inline Fix48& Fix48::operator>>=(int b) -{ - return *this = *this >> b; -} - -inline int operator==(Fix48& f, Fix48& g) -{ - return f.m.u == g.m.u && f.m.l == g.m.l; -} - -inline int operator!=(Fix48& f, Fix48& g) -{ - return f.m.u != g.m.u || f.m.l != g.m.l; -} - -inline int operator>=(Fix48& f, Fix48& g) -{ - return f.m.u >= g.m.u || (f.m.u == g.m.u && f.m.l >= g.m.l); -} - -inline int operator<=(Fix48& f, Fix48& g) -{ - return f.m.u <= g.m.u || (f.m.u == g.m.u && f.m.l <= g.m.l); -} - -inline int operator>(Fix48& f, Fix48& g) -{ - return f.m.u > g.m.u || (f.m.u == g.m.u && f.m.l > g.m.l); -} - -inline int operator<(Fix48& f, Fix48& g) -{ - return f.m.u < g.m.u || (f.m.u == g.m.u && f.m.l < g.m.l); -} - -inline istream& operator>>(istream& s, Fix48& f) -{ - double d; - s >> d; - f = d; - return s; -} - -inline ostream& operator<<(ostream& s, Fix48& f) -{ - return s << double(f); -} - - -#endif -#endif - diff --git a/gnu/lib/libg++/g++-include/Fmodes.h b/gnu/lib/libg++/g++-include/Fmodes.h deleted file mode 100644 index 524c2bdc4b57..000000000000 --- a/gnu/lib/libg++/g++-include/Fmodes.h +++ /dev/null @@ -1,34 +0,0 @@ - -#ifndef _Fmodes_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Fmodes_h 1 - -enum io_mode // known unix file IO modes -{ - io_readonly = 0, - io_writeonly = 1, - io_readwrite = 2, - io_appendonly = 3, - io_append = 4, // append, plus allow reads -}; - -enum access_mode // ways to open a file -{ - a_createonly = 0, // create, fail if file exists - a_create = 1, // create if doesn't exist, else truncate - a_useonly = 2, // use (no truncate) fail if doesn't exist - a_use = 3, // use (no truncate), create if doesn't exist -}; - -enum state_value // File states -{ - _good = 0, // all is well - _eof = 1, // at eof - _fail = 2, // logical or physical IO error - _bad = 4 // unopened/corrupted -}; - -#endif diff --git a/gnu/lib/libg++/g++-include/Geom.h b/gnu/lib/libg++/g++-include/Geom.h deleted file mode 100644 index d70b96a668f9..000000000000 --- a/gnu/lib/libg++/g++-include/Geom.h +++ /dev/null @@ -1,59 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _Geometric_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Geometric_h - -#include - -class Geometric: public Random { -protected: - double pMean; -public: - Geometric(double mean, RNG *gen); - - double mean(); - double mean(double x); - - virtual double operator()(); - -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline Geometric::Geometric(double mean, RNG *gen) : (gen) -{ - pMean = mean; -} - - -inline double Geometric::mean() { return pMean; } -inline double Geometric::mean(double x) { - double tmp = pMean; pMean = x; return tmp; -} - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/GetOpt.h b/gnu/lib/libg++/g++-include/GetOpt.h deleted file mode 100644 index 413c52d64c12..000000000000 --- a/gnu/lib/libg++/g++-include/GetOpt.h +++ /dev/null @@ -1,131 +0,0 @@ -/* Getopt for GNU. - Copyright (C) 1987, 1989 Free Software Foundation, Inc. - (Modified by Douglas C. Schmidt for use with GNU G++.) - - 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. */ - - - -/* 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. */ - -#ifndef GetOpt_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define GetOpt_h 1 - -#include -#include - -class GetOpt -{ -private: - /* 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; - - - /* 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 - _OPTIONS_FIRST 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 EOF 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; - - void exchange (char **argv); -public: - /* 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; - - /* 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; - - /* Callers store zero here to inhibit the error message - for unrecognized options. */ - - int opterr; - - int nargc; - char **nargv; - char *noptstring; - - GetOpt (int argc, char **argv, char *optstring); - int operator () (void); -}; - -#endif diff --git a/gnu/lib/libg++/g++-include/HypGeom.h b/gnu/lib/libg++/g++-include/HypGeom.h deleted file mode 100644 index b120f104e9f0..000000000000 --- a/gnu/lib/libg++/g++-include/HypGeom.h +++ /dev/null @@ -1,78 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _HyperGeometric_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _HyperGeometric_h - -#include - -class HyperGeometric: public Random { -protected: - double pMean; - double pVariance; - double pP; - void setState(); - -public: - HyperGeometric(double mean, double variance, RNG *gen); - - double mean(); - double mean(double x); - double variance(); - double variance(double x); - - virtual double operator()(); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline void HyperGeometric::setState() { - double z = pVariance / (pMean * pMean); - pP = 0.5 * (1.0 - sqrt((z - 1.0) / ( z + 1.0 ))); -} - -inline HyperGeometric::HyperGeometric(double mean, double variance, RNG *gen) -: (gen) { - pMean = mean; pVariance = variance; - setState(); -} - -inline double HyperGeometric::mean() { return pMean; }; - -inline double HyperGeometric::mean(double x) { - double t = pMean; pMean = x; - setState(); return t; -} - -inline double HyperGeometric::variance() { return pVariance; } - -inline double HyperGeometric::variance(double x) { - double t = pVariance; pVariance = x; - setState(); return t; -} - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/Incremental.h b/gnu/lib/libg++/g++-include/Incremental.h deleted file mode 100644 index 9b6bb3f8947b..000000000000 --- a/gnu/lib/libg++/g++-include/Incremental.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef Incremental_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define Incremental_h -#define DECLARE_INIT_FUNCTION(USER_INIT_FUNCTION) \ -static void USER_INIT_FUNCTION (); extern void (*_initfn)(); \ -static struct xyzzy { xyzzy () {_initfn = USER_INIT_FUNCTION;}; \ -~xyzzy () {};} __2xyzzy; -#else -#error Incremental.h was not the first file included in this module -#endif diff --git a/gnu/lib/libg++/g++-include/Integer.h b/gnu/lib/libg++/g++-include/Integer.h deleted file mode 100644 index a241e65a29ef..000000000000 --- a/gnu/lib/libg++/g++-include/Integer.h +++ /dev/null @@ -1,1114 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _Integer_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Integer_h 1 - -#include - -struct IntRep // internal Integer representations -{ - unsigned short len; // current length - unsigned short sz; // allocated space - short sgn; // 1 means >= 0; 0 means < 0 - unsigned short s[1]; // represented as ushort array starting here -}; - -extern IntRep* Ialloc(IntRep*, const unsigned short *, int, int, int); -extern IntRep* Icalloc(IntRep*, int); -extern IntRep* Icopy_long(IntRep*, long); -extern IntRep* Icopy(IntRep*, const IntRep*); -extern IntRep* Iresize(IntRep*, int); -extern IntRep* add(const IntRep*, int, const IntRep*, int, IntRep*); -extern IntRep* add(const IntRep*, int, long, IntRep*); -extern IntRep* multiply(const IntRep*, const IntRep*, IntRep*); -extern IntRep* multiply(const IntRep*, long, IntRep*); -extern IntRep* lshift(const IntRep*, long, IntRep*); -extern IntRep* lshift(const IntRep*, const IntRep*, int, IntRep*); -extern IntRep* bitop(const IntRep*, const IntRep*, IntRep*, char); -extern IntRep* bitop(const IntRep*, long, IntRep*, char); -extern IntRep* power(const IntRep*, long, IntRep*); -extern IntRep* div(const IntRep*, const IntRep*, IntRep*); -extern IntRep* mod(const IntRep*, const IntRep*, IntRep*); -extern IntRep* div(const IntRep*, long, IntRep*); -extern IntRep* mod(const IntRep*, long, IntRep*); -extern IntRep* compl(const IntRep*, IntRep*); -extern IntRep* abs(const IntRep*, IntRep*); -extern IntRep* negate(const IntRep*, IntRep*); -extern IntRep* pow(const IntRep*, long); -extern IntRep* gcd(const IntRep*, const IntRep* y); -extern int compare(const IntRep*, const IntRep*); -extern int compare(const IntRep*, long); -extern int ucompare(const IntRep*, const IntRep*); -extern int ucompare(const IntRep*, long); -extern char* Itoa(const IntRep* x, int base = 10, int width = 0); -extern IntRep* atoIntRep(const char* s, int base = 10); -extern long Itolong(const IntRep*); -extern double Itodouble(const IntRep*); -extern int Iislong(const IntRep*); -extern int Iisdouble(const IntRep*); -extern long lg(const IntRep*); - - -class Integer -{ -protected: - IntRep* rep; -public: - Integer(); - Integer(long); - Integer(const Integer&); - - ~Integer(); - - void operator = (const Integer&); - void operator = (long); - -// unary operations to self - - void operator ++ (); - void operator -- (); - void negate(); // negate in-place - void abs(); // absolute-value in-place - void complement(); // bitwise complement in-place - -// assignment-based operations - - void operator += (const Integer&); - void operator -= (const Integer&); - void operator *= (const Integer&); - void operator /= (const Integer&); - void operator %= (const Integer&); - void operator <<=(const Integer&); - void operator >>=(const Integer&); - void operator &= (const Integer&); - void operator |= (const Integer&); - void operator ^= (const Integer&); - - void operator += (long); - void operator -= (long); - void operator *= (long); - void operator /= (long); - void operator %= (long); - void operator <<=(long); - void operator >>=(long); - void operator &= (long); - void operator |= (long); - void operator ^= (long); - -// (constructive binary operations are inlined below) - -#ifdef __GNUG__ - friend Integer operator ? (const Integer& x, const Integer& y); // max -#endif - -// builtin Integer functions that must be friends - - friend long lg (const Integer&); // floor log base 2 of abs(x) - friend double ratio(const Integer& x, const Integer& y); - // return x/y as a double - - friend Integer gcd(const Integer&, const Integer&); - friend int even(const Integer&); // true if even - friend int odd(const Integer&); // true if odd - friend int sign(const Integer&); // returns -1, 0, +1 - - friend void setbit(Integer& x, long b); // set b'th bit of x - friend void clearbit(Integer& x, long b); // clear b'th bit - friend int testbit(const Integer& x, long b); // return b'th bit - -// procedural versions of operators - - friend void abs(const Integer& x, Integer& dest); - friend void negate(const Integer& x, Integer& dest); - friend void complement(const Integer& x, Integer& dest); - - friend int compare(const Integer&, const Integer&); - friend int ucompare(const Integer&, const Integer&); - friend void add(const Integer& x, const Integer& y, Integer& dest); - friend void sub(const Integer& x, const Integer& y, Integer& dest); - friend void mul(const Integer& x, const Integer& y, Integer& dest); - friend void div(const Integer& x, const Integer& y, Integer& dest); - friend void mod(const Integer& x, const Integer& y, Integer& dest); - friend void divide(const Integer& x, const Integer& y, - Integer& q, Integer& r); - friend void and(const Integer& x, const Integer& y, Integer& dest); - friend void or(const Integer& x, const Integer& y, Integer& dest); - friend void xor(const Integer& x, const Integer& y, Integer& dest); - friend void lshift(const Integer& x, const Integer& y, Integer& dest); - friend void rshift(const Integer& x, const Integer& y, Integer& dest); - friend void pow(const Integer& x, const Integer& y, Integer& dest); - - friend int compare(const Integer&, long); - friend int ucompare(const Integer&, long); - friend void add(const Integer& x, long y, Integer& dest); - friend void sub(const Integer& x, long y, Integer& dest); - friend void mul(const Integer& x, long y, Integer& dest); - friend void div(const Integer& x, long y, Integer& dest); - friend void mod(const Integer& x, long y, Integer& dest); - friend void divide(const Integer& x, long y, Integer& q, long& r); - friend void and(const Integer& x, long y, Integer& dest); - friend void or(const Integer& x, long y, Integer& dest); - friend void xor(const Integer& x, long y, Integer& dest); - friend void lshift(const Integer& x, long y, Integer& dest); - friend void rshift(const Integer& x, long y, Integer& dest); - friend void pow(const Integer& x, long y, Integer& dest); - - friend int compare(long, const Integer&); - friend int ucompare(long, const Integer&); - friend void add(long x, const Integer& y, Integer& dest); - friend void sub(long x, const Integer& y, Integer& dest); - friend void mul(long x, const Integer& y, Integer& dest); - friend void and(long x, const Integer& y, Integer& dest); - friend void or(long x, const Integer& y, Integer& dest); - friend void xor(long x, const Integer& y, Integer& dest); - -// coercion & conversion - - int fits_in_long() const; - int fits_in_double() const; - - operator long() const; - operator double() const; - - friend char* Itoa(const Integer& x, int base = 10, int width = 0); - friend Integer atoI(const char* s, int base = 10); - - friend istream& operator >> (istream& s, Integer& y); - friend ostream& operator << (ostream& s, const Integer& y); - -// error detection - - int initialized() const; - volatile void error(const char* msg) const; - int OK() const; -}; - - -// (These are declared inline) - - int operator == (const Integer&, const Integer&); - int operator == (const Integer&, long); - int operator != (const Integer&, const Integer&); - int operator != (const Integer&, long); - int operator < (const Integer&, const Integer&); - int operator < (const Integer&, long); - int operator <= (const Integer&, const Integer&); - int operator <= (const Integer&, long); - int operator > (const Integer&, const Integer&); - int operator > (const Integer&, long); - int operator >= (const Integer&, const Integer&); - int operator >= (const Integer&, long); - Integer operator - (const Integer&); - Integer operator ~ (const Integer&); - Integer operator + (const Integer&, const Integer&); - Integer operator + (const Integer&, long); - Integer operator + (long, const Integer&); - Integer operator - (const Integer&, const Integer&); - Integer operator - (const Integer&, long); - Integer operator - (long, const Integer&); - Integer operator * (const Integer&, const Integer&); - Integer operator * (const Integer&, long); - Integer operator * (long, const Integer&); - Integer operator / (const Integer&, const Integer&); - Integer operator / (const Integer&, long); - Integer operator % (const Integer&, const Integer&); - Integer operator % (const Integer&, long); - Integer operator << (const Integer&, const Integer&); - Integer operator << (const Integer&, long); - Integer operator >> (const Integer&, const Integer&); - Integer operator >> (const Integer&, long); - Integer operator & (const Integer&, const Integer&); - Integer operator & (const Integer&, long); - Integer operator & (long, const Integer&); - Integer operator | (const Integer&, const Integer&); - Integer operator | (const Integer&, long); - Integer operator | (long, const Integer&); - Integer operator ^ (const Integer&, const Integer&); - Integer operator ^ (const Integer&, long); - Integer operator ^ (long, const Integer&); - - Integer abs(const Integer&); // absolute value - Integer sqr(const Integer&); // square - - Integer pow(const Integer& x, const Integer& y); - Integer pow(const Integer& x, long y); - Integer Ipow(long x, long y); // x to the y as Integer - - -extern char* dec(const Integer& x, int width = 0); -extern char* oct(const Integer& x, int width = 0); -extern char* hex(const Integer& x, int width = 0); -extern Integer sqrt(const Integer&); // floor of square root -extern Integer lcm(const Integer& x, const Integer& y); // least common mult - - -typedef Integer IntTmp; // for backward compatibility - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - -inline Integer::Integer() :rep(0) {} - -inline Integer::Integer(long y) :rep(Icopy_long(0, y)) {} - -inline Integer::Integer(const Integer& y) :rep(Icopy(0, y.rep)) {} - -inline Integer::~Integer() { delete rep; } - -inline void Integer::operator = (const Integer& y) -{ - rep = Icopy(rep, y.rep); -} - -inline void Integer::operator = (long y) -{ - rep = Icopy_long(rep, y); -} - -inline Integer::operator long() const -{ - return Itolong(rep); -} - -inline int Integer::initialized() const -{ - return rep != 0; -} - -inline int Integer::fits_in_long() const -{ - return Iislong(rep); -} - -inline Integer::operator double() const -{ - return Itodouble(rep); -} - -inline int Integer::fits_in_double() const -{ - return Iisdouble(rep); -} - -// procedural versions - -inline int compare(const Integer& x, const Integer& y) -{ - return compare(x.rep, y.rep); -} - -inline int ucompare(const Integer& x, const Integer& y) -{ - return ucompare(x.rep, y.rep); -} - -inline int compare(const Integer& x, long y) -{ - return compare(x.rep, y); -} - -inline int ucompare(const Integer& x, long y) -{ - return ucompare(x.rep, y); -} - -inline int compare(long x, const Integer& y) -{ - return -compare(y.rep, x); -} - -inline int ucompare(long x, const Integer& y) -{ - return -ucompare(y.rep, x); -} - -inline void add(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = add(x.rep, 0, y.rep, 0, dest.rep); -} - -inline void sub(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = add(x.rep, 0, y.rep, 1, dest.rep); -} - -inline void mul(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = multiply(x.rep, y.rep, dest.rep); -} - -inline void div(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = div(x.rep, y.rep, dest.rep); -} - -inline void mod(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = mod(x.rep, y.rep, dest.rep); -} - -inline void and(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(x.rep, y.rep, dest.rep, '&'); -} - -inline void or(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(x.rep, y.rep, dest.rep, '|'); -} - -inline void xor(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(x.rep, y.rep, dest.rep, '^'); -} - -inline void lshift(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = lshift(x.rep, y.rep, 0, dest.rep); -} - -inline void rshift(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = lshift(x.rep, y.rep, 1, dest.rep); -} - -inline void pow(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = power(x.rep, long(y), dest.rep); // not incorrect -} - -inline void add(const Integer& x, long y, Integer& dest) -{ - dest.rep = add(x.rep, 0, y, dest.rep); -} - -inline void sub(const Integer& x, long y, Integer& dest) -{ - dest.rep = add(x.rep, 0, -y, dest.rep); -} - -inline void mul(const Integer& x, long y, Integer& dest) -{ - dest.rep = multiply(x.rep, y, dest.rep); -} - -inline void div(const Integer& x, long y, Integer& dest) -{ - dest.rep = div(x.rep, y, dest.rep); -} - -inline void mod(const Integer& x, long y, Integer& dest) -{ - dest.rep = mod(x.rep, y, dest.rep); -} - -inline void and(const Integer& x, long y, Integer& dest) -{ - dest.rep = bitop(x.rep, y, dest.rep, '&'); -} - -inline void or(const Integer& x, long y, Integer& dest) -{ - dest.rep = bitop(x.rep, y, dest.rep, '|'); -} - -inline void xor(const Integer& x, long y, Integer& dest) -{ - dest.rep = bitop(x.rep, y, dest.rep, '^'); -} - -inline void lshift(const Integer& x, long y, Integer& dest) -{ - dest.rep = lshift(x.rep, y, dest.rep); -} - -inline void rshift(const Integer& x, long y, Integer& dest) -{ - dest.rep = lshift(x.rep, -y, dest.rep); -} - -inline void pow(const Integer& x, long y, Integer& dest) -{ - dest.rep = power(x.rep, y, dest.rep); -} - -inline void abs(const Integer& x, Integer& dest) -{ - dest.rep = abs(x.rep, dest.rep); -} - -inline void negate(const Integer& x, Integer& dest) -{ - dest.rep = negate(x.rep, dest.rep); -} - -inline void complement(const Integer& x, Integer& dest) -{ - dest.rep = compl(x.rep, dest.rep); -} - -inline void add(long x, const Integer& y, Integer& dest) -{ - dest.rep = add(y.rep, 0, x, dest.rep); -} - -inline void sub(long x, const Integer& y, Integer& dest) -{ - dest.rep = add(y.rep, 1, x, dest.rep); -} - -inline void mul(long x, const Integer& y, Integer& dest) -{ - dest.rep = multiply(y.rep, x, dest.rep); -} - -inline void and(long x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(y.rep, x, dest.rep, '&'); -} - -inline void or(long x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(y.rep, x, dest.rep, '|'); -} - -inline void xor(long x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(y.rep, x, dest.rep, '^'); -} - - -// operator versions - -inline int operator == (const Integer& x, const Integer& y) -{ - return compare(x, y) == 0; -} - -inline int operator == (const Integer& x, long y) -{ - return compare(x, y) == 0; -} - -inline int operator != (const Integer& x, const Integer& y) -{ - return compare(x, y) != 0; -} - -inline int operator != (const Integer& x, long y) -{ - return compare(x, y) != 0; -} - -inline int operator < (const Integer& x, const Integer& y) -{ - return compare(x, y) < 0; -} - -inline int operator < (const Integer& x, long y) -{ - return compare(x, y) < 0; -} - -inline int operator <= (const Integer& x, const Integer& y) -{ - return compare(x, y) <= 0; -} - -inline int operator <= (const Integer& x, long y) -{ - return compare(x, y) <= 0; -} - -inline int operator > (const Integer& x, const Integer& y) -{ - return compare(x, y) > 0; -} - -inline int operator > (const Integer& x, long y) -{ - return compare(x, y) > 0; -} - -inline int operator >= (const Integer& x, const Integer& y) -{ - return compare(x, y) >= 0; -} - -inline int operator >= (const Integer& x, long y) -{ - return compare(x, y) >= 0; -} - - -inline void Integer::operator += (const Integer& y) -{ - add(*this, y, *this); -} - -inline void Integer::operator += (long y) -{ - add(*this, y, *this); -} - -inline void Integer::operator ++ () -{ - add(*this, 1, *this); -} - - -inline void Integer::operator -= (const Integer& y) -{ - sub(*this, y, *this); -} - -inline void Integer::operator -= (long y) -{ - sub(*this, y, *this); -} - -inline void Integer::operator -- () -{ - add(*this, -1, *this); -} - - - -inline void Integer::operator *= (const Integer& y) -{ - mul(*this, y, *this); -} - -inline void Integer::operator *= (long y) -{ - mul(*this, y, *this); -} - - -inline void Integer::operator &= (const Integer& y) -{ - and(*this, y, *this); -} - -inline void Integer::operator &= (long y) -{ - and(*this, y, *this); -} - -inline void Integer::operator |= (const Integer& y) -{ - or(*this, y, *this); -} - -inline void Integer::operator |= (long y) -{ - or(*this, y, *this); -} - - -inline void Integer::operator ^= (const Integer& y) -{ - xor(*this, y, *this); -} - -inline void Integer::operator ^= (long y) -{ - xor(*this, y, *this); -} - - - -inline void Integer::operator /= (const Integer& y) -{ - div(*this, y, *this); -} - -inline void Integer::operator /= (long y) -{ - div(*this, y, *this); -} - - -inline void Integer::operator %= (const Integer& y) -{ - mod(*this, y, *this); -} - -inline void Integer::operator %= (long y) -{ - mod(*this, y, *this); -} - - -inline void Integer::operator <<= (const Integer& y) -{ - lshift(*this, y, *this); -} - -inline void Integer::operator <<= (long y) -{ - lshift(*this, y, *this); -} - - -inline void Integer::operator >>= (const Integer& y) -{ - rshift(*this, y, *this); -} - -inline void Integer::operator >>= (long y) -{ - rshift(*this, y, *this); -} - -#ifdef __GNUG__ -inline Integer operator ? (const Integer& x, const Integer& y) -{ - return (compare(x.rep, y.rep) >= 0)? x : y; -} -#endif - - -inline void Integer::abs() -{ - ::abs(*this, *this); -} - -inline void Integer::negate() -{ - ::negate(*this, *this); -} - - -inline void Integer::complement() -{ - ::complement(*this, *this); -} - - -inline int sign(const Integer& x) -{ - return (x.rep->len == 0) ? 0 : ( (x.rep->sgn == 1) ? 1 : -1 ); -} - -inline int even(const Integer& y) -{ - return y.rep->len == 0 || !(y.rep->s[0] & 1); -} - -inline int odd(const Integer& y) -{ - return y.rep->len > 0 && (y.rep->s[0] & 1); -} - -inline char* Itoa(const Integer& y, int base, int width) -{ - return Itoa(y.rep, base, width); -} - - -inline ostream& operator << (ostream& s, const Integer& y) -{ - return s << Itoa(y.rep); -} - -inline long lg(const Integer& x) -{ - return lg(x.rep); -} - -// constructive operations - -#if defined(__GNUG__) && !defined(NO_NRV) - -inline Integer operator + (const Integer& x, const Integer& y) return r -{ - add(x, y, r); -} - -inline Integer operator + (const Integer& x, long y) return r -{ - add(x, y, r); -} - -inline Integer operator + (long x, const Integer& y) return r -{ - add(x, y, r); -} - -inline Integer operator - (const Integer& x, const Integer& y) return r -{ - sub(x, y, r); -} - -inline Integer operator - (const Integer& x, long y) return r -{ - sub(x, y, r); -} - -inline Integer operator - (long x, const Integer& y) return r -{ - sub(x, y, r); -} - -inline Integer operator * (const Integer& x, const Integer& y) return r -{ - mul(x, y, r); -} - -inline Integer operator * (const Integer& x, long y) return r -{ - mul(x, y, r); -} - -inline Integer operator * (long x, const Integer& y) return r -{ - mul(x, y, r); -} - -inline Integer sqr(const Integer& x) return r -{ - mul(x, x, r); -} - -inline Integer operator & (const Integer& x, const Integer& y) return r -{ - and(x, y, r); -} - -inline Integer operator & (const Integer& x, long y) return r -{ - and(x, y, r); -} - -inline Integer operator & (long x, const Integer& y) return r -{ - and(x, y, r); -} - -inline Integer operator | (const Integer& x, const Integer& y) return r -{ - or(x, y, r); -} - -inline Integer operator | (const Integer& x, long y) return r -{ - or(x, y, r); -} - -inline Integer operator | (long x, const Integer& y) return r -{ - or(x, y, r); -} - -inline Integer operator ^ (const Integer& x, const Integer& y) return r -{ - xor(x, y, r); -} - -inline Integer operator ^ (const Integer& x, long y) return r -{ - xor(x, y, r); -} - -inline Integer operator ^ (long x, const Integer& y) return r -{ - xor(x, y, r); -} - -inline Integer operator / (const Integer& x, const Integer& y) return r -{ - div(x, y, r); -} - -inline Integer operator / (const Integer& x, long y) return r -{ - div(x, y, r); -} - -inline Integer operator % (const Integer& x, const Integer& y) return r -{ - mod(x, y, r); -} - -inline Integer operator % (const Integer& x, long y) return r -{ - mod(x, y, r); -} - -inline Integer operator << (const Integer& x, const Integer& y) return r -{ - lshift(x, y, r); -} - -inline Integer operator << (const Integer& x, long y) return r -{ - lshift(x, y, r); -} - -inline Integer operator >> (const Integer& x, const Integer& y) return r; -{ - rshift(x, y, r); -} - -inline Integer operator >> (const Integer& x, long y) return r -{ - rshift(x, y, r); -} - -inline Integer pow(const Integer& x, long y) return r -{ - pow(x, y, r); -} - -inline Integer Ipow(long x, long y) return r(x) -{ - pow(r, y, r); -} - -inline Integer pow(const Integer& x, const Integer& y) return r -{ - pow(x, y, r); -} - - - -inline Integer abs(const Integer& x) return r -{ - abs(x, r); -} - -inline Integer operator - (const Integer& x) return r -{ - negate(x, r); -} - -inline Integer operator ~ (const Integer& x) return r -{ - complement(x, r); -} - -inline Integer atoI(const char* s, int base) return r -{ - r.rep = atoIntRep(s, base); -} - -inline Integer gcd(const Integer& x, const Integer& y) return r -{ - r.rep = gcd(x.rep, y.rep); -} - -#else /* NO_NRV */ - -inline Integer operator + (const Integer& x, const Integer& y) -{ - Integer r; add(x, y, r); return r; -} - -inline Integer operator + (const Integer& x, long y) -{ - Integer r; add(x, y, r); return r; -} - -inline Integer operator + (long x, const Integer& y) -{ - Integer r; add(x, y, r); return r; -} - -inline Integer operator - (const Integer& x, const Integer& y) -{ - Integer r; sub(x, y, r); return r; -} - -inline Integer operator - (const Integer& x, long y) -{ - Integer r; sub(x, y, r); return r; -} - -inline Integer operator - (long x, const Integer& y) -{ - Integer r; sub(x, y, r); return r; -} - -inline Integer operator * (const Integer& x, const Integer& y) -{ - Integer r; mul(x, y, r); return r; -} - -inline Integer operator * (const Integer& x, long y) -{ - Integer r; mul(x, y, r); return r; -} - -inline Integer operator * (long x, const Integer& y) -{ - Integer r; mul(x, y, r); return r; -} - -inline Integer sqr(const Integer& x) -{ - Integer r; mul(x, x, r); return r; -} - -inline Integer operator & (const Integer& x, const Integer& y) -{ - Integer r; and(x, y, r); return r; -} - -inline Integer operator & (const Integer& x, long y) -{ - Integer r; and(x, y, r); return r; -} - -inline Integer operator & (long x, const Integer& y) -{ - Integer r; and(x, y, r); return r; -} - -inline Integer operator | (const Integer& x, const Integer& y) -{ - Integer r; or(x, y, r); return r; -} - -inline Integer operator | (const Integer& x, long y) -{ - Integer r; or(x, y, r); return r; -} - -inline Integer operator | (long x, const Integer& y) -{ - Integer r; or(x, y, r); return r; -} - -inline Integer operator ^ (const Integer& x, const Integer& y) -{ - Integer r; xor(x, y, r); return r; -} - -inline Integer operator ^ (const Integer& x, long y) -{ - Integer r; xor(x, y, r); return r; -} - -inline Integer operator ^ (long x, const Integer& y) -{ - Integer r; xor(x, y, r); return r; -} - -inline Integer operator / (const Integer& x, const Integer& y) -{ - Integer r; div(x, y, r); return r; -} - -inline Integer operator / (const Integer& x, long y) -{ - Integer r; div(x, y, r); return r; -} - -inline Integer operator % (const Integer& x, const Integer& y) -{ - Integer r; mod(x, y, r); return r; -} - -inline Integer operator % (const Integer& x, long y) -{ - Integer r; mod(x, y, r); return r; -} - -inline Integer operator << (const Integer& x, const Integer& y) -{ - Integer r; lshift(x, y, r); return r; -} - -inline Integer operator << (const Integer& x, long y) -{ - Integer r; lshift(x, y, r); return r; -} - -inline Integer operator >> (const Integer& x, const Integer& y) -{ - Integer r; rshift(x, y, r); return r; -} - -inline Integer operator >> (const Integer& x, long y) -{ - Integer r; rshift(x, y, r); return r; -} - -inline Integer pow(const Integer& x, long y) -{ - Integer r; pow(x, y, r); return r; -} - -inline Integer Ipow(long x, long y) -{ - Integer r(x); pow(r, y, r); return r; -} - -inline Integer pow(const Integer& x, const Integer& y) -{ - Integer r; pow(x, y, r); return r; -} - - - -inline Integer abs(const Integer& x) -{ - Integer r; abs(x, r); return r; -} - -inline Integer operator - (const Integer& x) -{ - Integer r; negate(x, r); return r; -} - -inline Integer operator ~ (const Integer& x) -{ - Integer r; complement(x, r); return r; -} - -inline Integer atoI(const char* s, int base) -{ - Integer r; r.rep = atoIntRep(s, base); return r; -} - -inline Integer gcd(const Integer& x, const Integer& y) -{ - Integer r; r.rep = gcd(x.rep, y.rep); return r; -} - -#endif -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/LogNorm.h b/gnu/lib/libg++/g++-include/LogNorm.h deleted file mode 100644 index 6c7c74cdef18..000000000000 --- a/gnu/lib/libg++/g++-include/LogNorm.h +++ /dev/null @@ -1,84 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _LogNormal_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _LogNormal_h - -#include "Normal.h" - -class LogNormal: public Normal { -protected: - double logMean; - double logVariance; - void setState(); -public: - LogNormal(double mean, double variance, RNG *gen); - double mean(); - double mean(double x); - double variance(); - double variance(double x); - virtual double operator()(); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline void LogNormal::setState() -{ - double m2 = logMean * logMean; - pMean = log(m2 / sqrt(logVariance + m2) ); - pVariance = log((sqrt(logVariance + m2)/m2 )); -} - -inline LogNormal::LogNormal(double mean, double variance, RNG *gen) - : (mean, variance, gen) -{ - logMean = mean; - logVariance = variance; - setState(); -} - -inline double LogNormal::mean() { - return logMean; -} - -inline double LogNormal::mean(double x) -{ - double t=logMean; logMean = x; setState(); - return t; -} - -inline double LogNormal::variance() { - return logVariance; -} - -inline double LogNormal::variance(double x) -{ - double t=logVariance; logVariance = x; setState(); - return t; -} - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/MLCG.h b/gnu/lib/libg++/g++-include/MLCG.h deleted file mode 100644 index 73791f055ce1..000000000000 --- a/gnu/lib/libg++/g++-include/MLCG.h +++ /dev/null @@ -1,97 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _MLCG_h -#define _MLCG_h 1 -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif - -#include -#include - -// -// Multiplicative Linear Conguential Generator -// - -class MLCG : public RNG { - long initialSeedOne; - long initialSeedTwo; - long seedOne; - long seedTwo; - -protected: - -public: - MLCG(long seed1 = 0, long seed2 = 1); - // - // Return a long-words word of random bits - // - virtual unsigned long asLong(); - virtual void reset(); - long seed1(); - void seed1(long); - long seed2(); - void seed2(long); - void reseed(long, long); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline long -MLCG::seed1() -{ - return(seedOne); -} - -inline void -MLCG::seed1(long s) -{ - initialSeedOne = s; - reset(); -} - -inline long -MLCG::seed2() -{ - return(seedTwo); -} - -inline void -MLCG::seed2(long s) -{ - initialSeedTwo = s; - reset(); -} - -inline void -MLCG::reseed(long s1, long s2) -{ - initialSeedOne = s1; - initialSeedTwo = s2; - reset(); -} - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/Makefile b/gnu/lib/libg++/g++-include/Makefile deleted file mode 100644 index cf914535d3af..000000000000 --- a/gnu/lib/libg++/g++-include/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -# %W% (Berkeley) %G% -# -# Cloned from /usr/src/include/Makefile -# Doing a make install builds /usr/include/g++ -# - -all clean cleandir depend lint tags: - -FILES= ACG.h AllocRing.h Binomial.h BitSet.h BitString.h \ - Complex.h CursesW.h DiscUnif.h Erlang.h File.h \ - Filebuf.h Fix.h Fix16.h Fix24.h Fmodes.h Geom.h \ - GetOpt.h HypGeom.h Incremental.h Integer.h LogNorm.h \ - MLCG.h NegExp.h Normal.h Obstack.h Pix.h PlotFile.h \ - Poisson.h RNG.h Random.h Rational.h Regex.h RndInt.h \ - SFile.h SmplHist.h SmplStat.h String.h Uniform.h \ - Weibull.h abs.h assert.h bool.h builtin.h compare.h \ - complex.h curses.h file.h filebuf.h generic.h \ - istream.h malloc.h max.h min.h minmax.h new.h open.h \ - osfcn.h ostream.h regex.h std.h strclass.h stream.h \ - streambuf.h swap.h values.h - -DIRS= gen - -NOOBJ= noobj - -INCDIR= /usr/include/g++ - -install: - @if [ ! -d ${DESTDIR}${INCDIR} ]; then \ - /bin/rm -f ${DESTDIR}${INCDIR} ; \ - mkdir -p ${DESTDIR}${INCDIR} ; \ - chown root.wheel ${DESTDIR}${INCDIR} ; \ - chmod 755 ${DESTDIR}${INCDIR} ; \ - else \ - true ; \ - fi - @echo installing ${FILES} - @-for i in ${FILES}; do \ - cmp -s $$i ${DESTDIR}${INCDIR}/$$i || \ - install -c -o ${BINOWN} -g ${BINGRP} -m 444 $$i \ - ${DESTDIR}${INCDIR}/$$i; \ - done - @echo installing ${DIRS} - @-for i in ${DIRS}; do \ - if [ ! -d ${DESTDIR}${INCDIR}/$$i ]; \ - then \ - mkdir ${DESTDIR}${INCDIR}/$$i; \ - fi; \ - chown ${BINOWN}.${BINGRP} ${DESTDIR}${INCDIR}/$$i; \ - chmod 755 ${DESTDIR}${INCDIR}/$$i; \ - (cd $$i; for j in *.*P; do \ - cmp -s $$j ${DESTDIR}${INCDIR}/$$i/$$j || \ - install -c -o ${BINOWN} -g ${BINGRP} -m 444 $$j \ - ${DESTDIR}${INCDIR}/$$i/$$j; \ - done); \ - done - -.include diff --git a/gnu/lib/libg++/g++-include/NegExp.h b/gnu/lib/libg++/g++-include/NegExp.h deleted file mode 100644 index 21a1a18f233d..000000000000 --- a/gnu/lib/libg++/g++-include/NegExp.h +++ /dev/null @@ -1,63 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _NegativeExpntl_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _NegativeExpntl_h 1 - - -// -// Negative Exponential Random Numbers -// -// - -#include - -class NegativeExpntl: public Random { -protected: - double pMean; -public: - NegativeExpntl(double xmean, RNG *gen); - double mean(); - double mean(double x); - - virtual double operator()(); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline NegativeExpntl::NegativeExpntl(double xmean, RNG *gen) -: (gen) { - pMean = xmean; -} - -inline double NegativeExpntl::mean() { return pMean; } -inline double NegativeExpntl::mean(double x) { - double t = pMean; pMean = x; - return t; -} - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/Normal.h b/gnu/lib/libg++/g++-include/Normal.h deleted file mode 100644 index b8a209eba74c..000000000000 --- a/gnu/lib/libg++/g++-include/Normal.h +++ /dev/null @@ -1,74 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _Normal_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Normal_h - -#include - -class Normal: public Random { - char haveCachedNormal; - double cachedNormal; - -protected: - double pMean; - double pVariance; - double pStdDev; - -public: - Normal(double xmean, double xvariance, RNG *gen); - double mean(); - double mean(double x); - double variance(); - double variance(double x); - virtual double operator()(); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline Normal::Normal(double xmean, double xvariance, RNG *gen) -: (gen) { - pMean = xmean; - pVariance = xvariance; - pStdDev = sqrt(pVariance); - haveCachedNormal = 0; -} - -inline double Normal::mean() { return pMean; }; -inline double Normal::mean(double x) { - double t=pMean; pMean = x; - return t; -} - -inline double Normal::variance() { return pVariance; } -inline double Normal::variance(double x) { - double t=pVariance; pVariance = x; - pStdDev = sqrt(pVariance); - return t; -}; - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/Obstack.h b/gnu/lib/libg++/g++-include/Obstack.h deleted file mode 100644 index 0cc2e9bb3788..000000000000 --- a/gnu/lib/libg++/g++-include/Obstack.h +++ /dev/null @@ -1,226 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - - -#ifndef _Obstack_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Obstack_h 1 - -#include - -class Obstack -{ - struct _obstack_chunk - { - char* limit; - _obstack_chunk* prev; - char contents[4]; - }; - -protected: - long chunksize; - _obstack_chunk* chunk; - char* objectbase; - char* nextfree; - char* chunklimit; - int alignmentmask; - - void _free(void* obj); - void newchunk(int size); - -public: - Obstack(int size = 4080, int alignment = 4); // 4080=4096-mallocslop - - ~Obstack(); - - void* base(); - void* next_free(); - int alignment_mask(); - int chunk_size(); - int size(); - int room(); - int contains(void* p); // does Obstack hold pointer p? - - void grow(const void* data, int size); - void grow(const void* data, int size, char terminator); - void grow(const char* s); - void grow(char c); - void grow_fast(char c); - void blank(int size); - void blank_fast(int size); - - void* finish(); - void* finish(char terminator); - - void* copy(const void* data, int size); - void* copy(const void* data, int size, char terminator); - void* copy(const char* s); - void* copy(char c); - void* alloc(int size); - - void free(void* obj); - void shrink(int size = 1); // suggested by ken@cs.rochester.edu - - int OK(); // rep invariant -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - -inline Obstack::~Obstack() -{ - _free(0); -} - -inline void* Obstack::base() -{ - return objectbase; -} - -inline void* Obstack::next_free() -{ - return nextfree; -} - -inline int Obstack::alignment_mask() -{ - return alignmentmask; -} - -inline int Obstack::chunk_size() -{ - return chunksize; -} - -inline int Obstack::size() -{ - return nextfree - objectbase; -} - -inline int Obstack::room() -{ - return chunklimit - nextfree; -} - -inline void Obstack:: grow(const void* data, int size) -{ - if (nextfree+size > chunklimit) - newchunk(size); - bcopy(data, nextfree, size); - nextfree += size; -} - -inline void Obstack:: grow(const void* data, int size, char terminator) -{ - if (nextfree+size+1 > chunklimit) - newchunk(size+1); - bcopy(data, nextfree, size); - nextfree += size; - *(nextfree)++ = terminator; -} - -inline void Obstack:: grow(const char* s) -{ - grow((void*)s, strlen(s), 0); -} - -inline void Obstack:: grow(char c) -{ - if (nextfree+1 > chunklimit) - newchunk(1); - *(nextfree)++ = c; -} - -inline void Obstack:: blank(int size) -{ - if (nextfree+size > chunklimit) - newchunk(size); - nextfree += size; -} - -inline void* Obstack::finish(char terminator) -{ - grow(terminator); - return finish(); -} - -inline void* Obstack::copy(const void* data, int size) -{ - grow (data, size); - return finish(); -} - -inline void* Obstack::copy(const void* data, int size, char terminator) -{ - grow(data, size, terminator); - return finish(); -} - -inline void* Obstack::copy(const char* s) -{ - grow((void*)s, strlen(s), 0); - return finish(); -} - -inline void* Obstack::copy(char c) -{ - grow(c); - return finish(); -} - -inline void* Obstack::alloc(int size) -{ - blank(size); - return finish(); -} - -inline void Obstack:: free(void* obj) -{ - if (obj >= (void*)chunk && obj<(void*)chunklimit) - nextfree = objectbase = (char *) obj; - else - _free(obj); -} - -inline void Obstack:: grow_fast(char c) -{ - *(nextfree)++ = c; -} - -inline void Obstack:: blank_fast(int size) -{ - nextfree += size; -} - -inline void Obstack:: shrink(int size) // from ken@cs.rochester.edu -{ - if (nextfree >= objectbase + size) - nextfree -= size; -} - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/Pix.h b/gnu/lib/libg++/g++-include/Pix.h deleted file mode 100644 index 0e087967e055..000000000000 --- a/gnu/lib/libg++/g++-include/Pix.h +++ /dev/null @@ -1,9 +0,0 @@ - -#ifndef _Pix_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Pix_h 1 -typedef void* Pix; -#endif diff --git a/gnu/lib/libg++/g++-include/PlotFile.h b/gnu/lib/libg++/g++-include/PlotFile.h deleted file mode 100644 index 1a6939641eb8..000000000000 --- a/gnu/lib/libg++/g++-include/PlotFile.h +++ /dev/null @@ -1,154 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -/* - a very simple implementation of a class to output unix "plot" - format plotter files. See corresponding unix man pages for - more details. -*/ - -#ifndef _PlotFile_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _PlotFile_h - -#include - -/* - Some plot libraries have the `box' command to draw boxes. Some don't. - `box' is included here via moves & lines to allow both possiblilties. -*/ - - -class PlotFile : private File -{ -protected: - PlotFile& cmd(char c); - PlotFile& operator << (const int x); - PlotFile& operator << (const char *s); - -public: - - PlotFile(); - PlotFile(const char* filename, io_mode m, access_mode a); - PlotFile(const char* filename, const char* m); - PlotFile(int filedesc, const io_mode m = io_writeonly); - PlotFile(FILE* fileptr); - - ~PlotFile(); - - operator void*(); - - PlotFile& close() { File::close(); return *this; } - PlotFile& remove() { File::remove(); return *this; } - - int filedesc() { return File::filedesc(); } - const char* name() { return File::name(); } - void setname(const char* newname) { File::setname(newname); } - int iocount() { return File::iocount(); } - - int rdstate() { return File::rdstate(); } - int eof() { return File::eof(); } - int fail() { return File::fail(); } - int bad() { return File::bad(); } - int good() { return File::good(); } - - // other status queries - - int readable() { return File::readable(); } - int writable() { return File::writable(); } - int is_open() { return File::is_open(); } - - void error() { File::error(); } - void clear(state_value f = _good) { File::clear(f); } - void set(state_value f) { File::set(f); } - void unset(state_value f) { File::unset(f); } - PlotFile& failif(int cond) { File::failif(cond); return *this; } - void check_state() { File::check_state(); } - - PlotFile& raw() { File::raw(); return *this; } - - PlotFile& open(const char* filename, io_mode m, access_mode a); - PlotFile& open(const char* filename, const char* m); - PlotFile& open(int filedesc, io_mode m); - PlotFile& open(FILE* fileptr); - PlotFile& setbuf(const int buffer_kind); // vals: _IONBF, _IOFBF, _IOLBF - PlotFile& setbuf(const int size, char* buf); - - PlotFile& arc(const int xi, const int yi, - const int x0, const int y0, - const int x1, const int y1); - PlotFile& box(const int x0, const int y0, - const int x1, const int y1); - PlotFile& circle(const int x, const int y, const int r); - PlotFile& cont(const int xi, const int yi); - PlotFile& dot(const int xi, const int yi, const int dx, - int n, const int* pat); - PlotFile& erase(); - PlotFile& label(const char* s); - PlotFile& line(const int x0, const int y0, - const int x1, const int y1); - PlotFile& linemod(const char* s); - PlotFile& move(const int xi, const int yi); - PlotFile& point(const int xi, const int yi); - PlotFile& space(const int x0, const int y0, - const int x1, const int y1); -}; - - -#endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnu/lib/libg++/g++-include/Poisson.h b/gnu/lib/libg++/g++-include/Poisson.h deleted file mode 100644 index aaac6e75ae45..000000000000 --- a/gnu/lib/libg++/g++-include/Poisson.h +++ /dev/null @@ -1,60 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _Poisson_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Poisson_h - -#include - -class Poisson: public Random { -protected: - double pMean; -public: - Poisson(double mean, RNG *gen); - - double mean(); - double mean(double x); - - virtual double operator()(); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline Poisson::Poisson(double mean, RNG *gen) -: (gen) { - pMean = mean; -} - -inline double Poisson::mean() { return pMean; } -inline double Poisson::mean(double x) { - double t = pMean; - pMean = x; - return t; -} - - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/RNG.h b/gnu/lib/libg++/g++-include/RNG.h deleted file mode 100644 index 414b57f3afe0..000000000000 --- a/gnu/lib/libg++/g++-include/RNG.h +++ /dev/null @@ -1,88 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _RNG_h -#define _RNG_h 1 -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif - -#include -#include - -union PrivateRNGSingleType { // used to access floats as unsigneds - float s; - unsigned long u; -}; - -union PrivateRNGDoubleType { // used to access doubles as unsigneds - double d; - unsigned long u[2]; -}; - -// -// Base class for Random Number Generators. See ACG and MLCG for instances. -// -class RNG { - static PrivateRNGSingleType singleMantissa; // mantissa bit vector - static PrivateRNGDoubleType doubleMantissa; // mantissa bit vector -public: - RNG(); - // - // Return a long-words word of random bits - // - virtual unsigned long asLong() = 0; - virtual void reset() = 0; - // - // Return random bits converted to either a float or a double - // - float asFloat(); - double asDouble(); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - -inline float RNG::asFloat() -{ - PrivateRNGSingleType result; - result.s = 1.0; - result.u |= (asLong() & singleMantissa.u); - result.s -= 1.0; - assert( result.s < 1.0 && result.s >= 0); - return( result.s ); -} - -inline double RNG::asDouble() -{ - PrivateRNGDoubleType result; - result.d = 1.0; - result.u[0] |= (asLong() & doubleMantissa.u[0]); - result.u[1] |= (asLong() & doubleMantissa.u[1]); - result.d -= 1.0; - assert( result.d < 1.0 && result.d >= 0); - return( result.d ); -} - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/Random.h b/gnu/lib/libg++/g++-include/Random.h deleted file mode 100644 index 94efa09fc0ea..000000000000 --- a/gnu/lib/libg++/g++-include/Random.h +++ /dev/null @@ -1,67 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _Random_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Random_h 1 -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif - -#include -#include "RNG.h" - -class Random { -protected: - RNG *pGenerator; -public: - Random(RNG *generator); - virtual double operator()() = 0; - - RNG *generator(); - void generator(RNG *p); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline Random::Random(RNG *gen) -{ - pGenerator = gen; -} - -inline RNG *Random::generator() -{ - return(pGenerator); -} - -inline void Random::generator(RNG *p) -{ - pGenerator = p; -} - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/Rational.h b/gnu/lib/libg++/g++-include/Rational.h deleted file mode 100644 index 3e7e35f1b735..000000000000 --- a/gnu/lib/libg++/g++-include/Rational.h +++ /dev/null @@ -1,270 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _Rational_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Rational_h 1 - -#include -#include - -class Rational -{ -protected: - Integer num; - Integer den; - - void normalize(); - -public: - Rational(); - Rational(double); - Rational(long n, long d = 1); - Rational(const Integer& n); - Rational(const Integer& n, const Integer& d); - Rational(const Rational&); - - ~Rational(); - - void operator = (const Rational& y); - - friend int operator == (const Rational& x, const Rational& y); - friend int operator != (const Rational& x, const Rational& y); - friend int operator < (const Rational& x, const Rational& y); - friend int operator <= (const Rational& x, const Rational& y); - friend int operator > (const Rational& x, const Rational& y); - friend int operator >= (const Rational& x, const Rational& y); - - friend Rational operator + (const Rational& x, const Rational& y); - friend Rational operator - (const Rational& x, const Rational& y); - friend Rational operator * (const Rational& x, const Rational& y); - friend Rational operator / (const Rational& x, const Rational& y); - - void operator += (const Rational& y); - void operator -= (const Rational& y); - void operator *= (const Rational& y); - void operator /= (const Rational& y); - -#ifdef __GNUG__ - friend Rational operator ? (const Rational& x, const Rational& y); // max -#endif - - friend Rational operator - (const Rational& x); - - -// builtin Rational functions - - - void negate(); // x = -x - void invert(); // x = 1/x - - friend int sign(const Rational& x); // -1, 0, or +1 - friend Rational abs(const Rational& x); // absolute value - friend Rational sqr(const Rational& x); // square - friend Rational pow(const Rational& x, long y); - friend Rational pow(const Rational& x, Integer& y); - const Integer& numerator() const; - const Integer& denominator() const; - -// coercion & conversion - - operator double() const; - friend Integer floor(const Rational& x); - friend Integer ceil(const Rational& x); - friend Integer trunc(const Rational& x); - friend Integer round(const Rational& x); - - friend istream& operator >> (istream& s, Rational& y); - friend ostream& operator << (ostream& s, const Rational& y); - - -// procedural versions of operators - - friend int compare(const Rational& x, const Rational& y); - friend void add(const Rational& x, const Rational& y, Rational& dest); - friend void sub(const Rational& x, const Rational& y, Rational& dest); - friend void mul(const Rational& x, const Rational& y, Rational& dest); - friend void div(const Rational& x, const Rational& y, Rational& dest); - -// error detection - - volatile void error(const char* msg) const; - int OK() const; - -}; - -typedef Rational RatTmp; // backwards compatibility - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline Rational::Rational() {} -inline Rational::~Rational() {} - -inline Rational::Rational(const Rational& y) :num(y.num), den(y.den) {} - -inline Rational::Rational(const Integer& n) :num(n), den(1) {} - -inline Rational::Rational(const Integer& n, const Integer& d) :num(n),den(d) -{ - normalize(); -} - -inline Rational::Rational(long n, long d) :num(n), den(d) -{ - normalize(); -} - -inline void Rational::operator = (const Rational& y) -{ - num = y.num; den = y.den; -} - -inline int operator == (const Rational& x, const Rational& y) -{ - return compare(x.num, y.num) == 0 && compare(x.den, y.den) == 0; -} - -inline int operator != (const Rational& x, const Rational& y) -{ - return compare(x.num, y.num) != 0 || compare(x.den, y.den) != 0; -} - -inline int operator < (const Rational& x, const Rational& y) -{ - return compare(x, y) < 0; -} - -inline int operator <= (const Rational& x, const Rational& y) -{ - return compare(x, y) <= 0; -} - -inline int operator > (const Rational& x, const Rational& y) -{ - return compare(x, y) > 0; -} - -inline int operator >= (const Rational& x, const Rational& y) -{ - return compare(x, y) >= 0; -} - -inline int sign(const Rational& x) -{ - return sign(x.num); -} - -inline void Rational::negate() -{ - num.negate(); -} - - -inline void Rational::operator += (const Rational& y) -{ - add(*this, y, *this); -} - -inline void Rational::operator -= (const Rational& y) -{ - sub(*this, y, *this); -} - -inline void Rational::operator *= (const Rational& y) -{ - mul(*this, y, *this); -} - -inline void Rational::operator /= (const Rational& y) -{ - div(*this, y, *this); -} - -inline const Integer& Rational::numerator() const { return num; } -inline const Integer& Rational::denominator() const { return den; } -inline Rational::operator double() const { return ratio(num, den); } - -#ifdef __GNUG__ -inline Rational operator ? (const Rational& x, const Rational& y) -{ - if (compare(x, y) >= 0) return x; else return y; -} -#endif - -#if defined(__GNUG__) && !defined(NO_NRV) - -inline Rational operator + (const Rational& x, const Rational& y) return r -{ - add(x, y, r); -} - -inline Rational operator - (const Rational& x, const Rational& y) return r -{ - sub(x, y, r); -} - -inline Rational operator * (const Rational& x, const Rational& y) return r -{ - mul(x, y, r); -} - -inline Rational operator / (const Rational& x, const Rational& y) return r -{ - div(x, y, r); -} - -#else /* NO_NRV */ - -inline Rational operator + (const Rational& x, const Rational& y) -{ - Rational r; add(x, y, r); return r; -} - -inline Rational operator - (const Rational& x, const Rational& y) -{ - Rational r; sub(x, y, r); return r; -} - -inline Rational operator * (const Rational& x, const Rational& y) -{ - Rational r; mul(x, y, r); return r; -} - -inline Rational operator / (const Rational& x, const Rational& y) -{ - Rational r; div(x, y, r); return r; -} -#endif -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/Regex.h b/gnu/lib/libg++/g++-include/Regex.h deleted file mode 100644 index d0cff263f20a..000000000000 --- a/gnu/lib/libg++/g++-include/Regex.h +++ /dev/null @@ -1,76 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - - -#ifndef _Regex_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Regex_h 1 - -struct re_pattern_buffer; // defined elsewhere -struct re_registers; - -class Regex -{ -private: - - Regex(const Regex&) {} // no X(X&) - void operator = (const Regex&) {} // no assignment - -protected: - re_pattern_buffer* buf; - re_registers* reg; - -public: - Regex(const char* t, - int fast = 0, - int bufsize = 40, - const char* transtable = 0); - - ~Regex(); - - int match(const char* s, int len, int pos = 0) const; - int search(const char* s, int len, - int& matchlen, int startpos = 0) const; - int match_info(int& start, int& length, int nth = 0) const; - - int OK() const; // representation invariant -}; - -// some built in regular expressions - -extern const Regex RXwhite; // = "[ \n\t\r\v\f]+" -extern const Regex RXint; // = "-?[0-9]+" -extern const Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\| - // \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\) - // \\([eE][---+]?[0-9]+\\)?" -extern const Regex RXalpha; // = "[A-Za-z]+" -extern const Regex RXlowercase; // = "[a-z]+" -extern const Regex RXuppercase; // = "[A-Z]+" -extern const Regex RXalphanum; // = "[0-9A-Za-z]+" -extern const Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*" - - -#endif diff --git a/gnu/lib/libg++/g++-include/RndInt.h b/gnu/lib/libg++/g++-include/RndInt.h deleted file mode 100644 index f674796f0584..000000000000 --- a/gnu/lib/libg++/g++-include/RndInt.h +++ /dev/null @@ -1,169 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1990 Free Software Foundation - adapted from a submission from John Reidl - - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _RandomInteger_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _RandomInteger_h 1 - -// RandomInteger uses a random number generator to generate an integer -// in a specified range. By default the range is 0..1. Since in my -// experience random numbers are often needed for a wide variety of -// ranges in the same program, this generator accepts a new low or high value -// as an argument to the asLong and operator() methods to temporarily -// override stored values - -#include -#include "RNG.h" - -class RandomInteger -{ - protected: - RNG *pGenerator; - long pLow; - long pHigh; - - long _asLong(long, long); - - public: - - RandomInteger(long low, long high, RNG *gen); - RandomInteger(long high, RNG *gen); - RandomInteger(RNG *gen); - -// read params - - long low() const; - long high() const; - RNG* generator() const; - -// change params - - long low(long x); - long high(long x); - RNG* generator(RNG *gen); - -// get a random number - - long asLong(); - long operator()(); // synonym for asLong - int asInt(); // (possibly) truncate as int - -// override params for one shot - - long asLong(long high); - long asLong(long low, long high); - - long operator () (long high); // synonyms - long operator () (long low, long high); - -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline RandomInteger::RandomInteger(long low, long high, RNG *gen) - : pLow((low < high) ? low : high), - pHigh((low < high) ? high : low), - pGenerator(gen) -{} - -inline RandomInteger::RandomInteger(long high, RNG *gen) - : pLow((0 < high) ? 0 : high), - pHigh((0 < high) ? high : 0), - pGenerator(gen) -{} - - -inline RandomInteger::RandomInteger(RNG *gen) - : pLow(0), - pHigh(1), - pGenerator(gen) -{} - -inline RNG* RandomInteger::generator() const { return pGenerator;} -inline long RandomInteger::low() const { return pLow; } -inline long RandomInteger::high() const { return pHigh; } - -inline RNG* RandomInteger::generator(RNG *gen) -{ - RNG *tmp = pGenerator; pGenerator = gen; return tmp; -} - -inline long RandomInteger::low(long x) -{ - long tmp = pLow; pLow = x; return tmp; -} - -inline long RandomInteger:: high(long x) -{ - long tmp = pHigh; pHigh = x; return tmp; -} - -inline long RandomInteger:: _asLong(long low, long high) -{ - return (pGenerator->asLong() % (high-low+1)) + low; -} - - -inline long RandomInteger:: asLong() -{ - return _asLong(pLow, pHigh); -} - -inline long RandomInteger:: asLong(long high) -{ - return _asLong(pLow, high); -} - -inline long RandomInteger:: asLong(long low, long high) -{ - return _asLong(low, high); -} - -inline long RandomInteger:: operator () () -{ - return _asLong(pLow, pHigh); -} - -inline long RandomInteger:: operator () (long high) -{ - return _asLong(pLow, high); -} - -inline long RandomInteger:: operator () (long low, long high) -{ - return _asLong(low, high); -} - - - - -inline int RandomInteger:: asInt() -{ - return int(asLong()); -} - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/SFile.h b/gnu/lib/libg++/g++-include/SFile.h deleted file mode 100644 index 598078ed8fe4..000000000000 --- a/gnu/lib/libg++/g++-include/SFile.h +++ /dev/null @@ -1,88 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _SFile_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _SFile_h 1 - -#include - -class SFile: public File -{ -protected: - int sz; // unit size for structured binary IO - -public: - SFile(); - SFile(const char* filename, int size, io_mode m, access_mode a); - SFile(const char* filename, int size, const char* m); - SFile(int filedesc, int size, io_mode m); - SFile(FILE* fileptr, int size); - - ~SFile(); - - int size(); - int setsize(int s); - - SFile& get(void* x); - SFile& put(void* x); - SFile& operator[](long i); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - -inline int SFile::size() -{ - return sz; -} - -inline int SFile::setsize(int s) -{ - int old = sz; - sz = s; - return old; -} - -inline SFile& SFile::get(void* x) -{ - read(x, sz, 1); return *this; -} - -inline SFile& SFile::put(void* x) -{ - write(x, sz, 1); return *this; -} - -inline SFile& SFile::operator[](long i) -{ - seek(i * sz, 0); return *this; -} - - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/SmplHist.h b/gnu/lib/libg++/g++-include/SmplHist.h deleted file mode 100644 index ed1fb5d1364b..000000000000 --- a/gnu/lib/libg++/g++-include/SmplHist.h +++ /dev/null @@ -1,82 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef SampleHistogram_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define SampleHistogram_h 1 - -#include -#include - -extern const int SampleHistogramMinimum; -extern const int SampleHistogramMaximum; - -class SampleHistogram : public SampleStatistic -{ -protected: - short howManyBuckets; - int *bucketCount; - double *bucketLimit; - -public: - - SampleHistogram(double low, double hi, double bucketWidth = -1.0); - - ~SampleHistogram(); - - virtual void reset(); - virtual void operator+=(double); - - int similarSamples(double); - - int buckets(); - - double bucketThreshold(int i); - int inBucket(int i); - void printBuckets(ostream&); - -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - inline int SampleHistogram:: buckets() { return(howManyBuckets); }; - - inline double SampleHistogram:: bucketThreshold(int i) { - if (i < 0 || i >= howManyBuckets) - error("invalid bucket access"); - return(bucketLimit[i]); - } - - inline int SampleHistogram:: inBucket(int i) { - if (i < 0 || i >= howManyBuckets) - error("invalid bucket access"); - return(bucketCount[i]); - } - - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/SmplStat.h b/gnu/lib/libg++/g++-include/SmplStat.h deleted file mode 100644 index 6aea14aef083..000000000000 --- a/gnu/lib/libg++/g++-include/SmplStat.h +++ /dev/null @@ -1,73 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef SampleStatistic_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define SampleStatistic_h 1 - -#include - -class SampleStatistic { -protected: - int n; - double x; - double x2; - double minValue, maxValue; - - public : - - SampleStatistic(); - virtual void reset(); - - virtual void operator+=(double); - int samples(); - double mean(); - double stdDev(); - double var(); - double min(); - double max(); - double confidence(int p_percentage); - double confidence(double p_value); - - void error(const char* msg); -}; - -// error handlers - -extern void default_SampleStatistic_error_handler(const char*); -extern one_arg_error_handler_t SampleStatistic_error_handler; - -extern one_arg_error_handler_t - set_SampleStatistic_error_handler(one_arg_error_handler_t f); - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - inline SampleStatistic:: SampleStatistic(){ reset();} - inline int SampleStatistic:: samples() {return(n);} - inline double SampleStatistic:: min() {return(minValue);} - inline double SampleStatistic:: max() {return(maxValue);} - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/String.h b/gnu/lib/libg++/g++-include/String.h deleted file mode 100644 index 871b9a2d54da..000000000000 --- a/gnu/lib/libg++/g++-include/String.h +++ /dev/null @@ -1,1341 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#if defined(SHORT_NAMES) || defined(VMS) -#define re_compile_pattern recmppat -#define re_pattern_buffer repatbuf -#define re_registers reregs -#endif - -#ifndef _String_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _String_h 1 - -#include -#include - -struct StrRep // internal String representations -{ - unsigned short len; // string length - unsigned short sz; // allocated space - char s[1]; // the string starts here - // (at least 1 char for trailing null) - // allocated & expanded via non-public fcts -}; - -// primitive ops on StrReps -- nearly all String fns go through these. - -StrRep* Salloc(StrRep*, const char*, int, int); -StrRep* Scopy(StrRep*, StrRep*); -StrRep* Sresize(StrRep*, int); -StrRep* Scat(StrRep*, const char*, int, const char*, int); -StrRep* Scat(StrRep*, const char*, int,const char*,int, const char*,int); -StrRep* Sprepend(StrRep*, const char*, int); -StrRep* Sreverse(StrRep*, StrRep*); -StrRep* Supcase(StrRep*, StrRep*); -StrRep* Sdowncase(StrRep*, StrRep*); -StrRep* Scapitalize(StrRep*, StrRep*); - -// These classes need to be defined in the order given - -class String; -class SubString; - -class SubString -{ - friend class String; -protected: - - String& S; // The String I'm a substring of - unsigned short pos; // starting position in S's rep - unsigned short len; // length of substring - - void assign(StrRep*, const char*, int = -1); - SubString(String& x, int p, int l); - SubString(const SubString& x); - -public: - -// Note there are no public constructors. SubStrings are always -// created via String operations - - ~SubString(); - - void operator = (const String& y); - void operator = (const SubString& y); - void operator = (const char* t); - void operator = (char c); - -// return 1 if target appears anywhere in SubString; else 0 - - int contains(char c) const; - int contains(const String& y) const; - int contains(const SubString& y) const; - int contains(const char* t) const; - int contains(const Regex& r) const; - -// return 1 if target matches entire SubString - - int matches(const Regex& r) const; - -// IO - - friend ostream& operator<<(ostream& s, const SubString& x); - -// status - - int length() const; - int empty() const; - const char* chars() const; - - int OK() const; - -}; - - -class String -{ - friend class SubString; - -protected: - StrRep* rep; // Strings are pointers to their representations - -// some helper functions - - int search(int, int, const char*, int = -1) const; - int search(int, int, char) const; - int match(int, int, int, const char*, int = -1) const; - int _gsub(const char*, int, const char* ,int); - int _gsub(const Regex&, const char*, int); - SubString _substr(int, int); - -public: - -// constructors & assignment - - String(); - String(const String& x); - String(const SubString& x); - String(const char* t); - String(const char* t, int len); - String(char c); - - ~String(); - - void operator = (const String& y); - void operator = (const char* y); - void operator = (char c); - void operator = (const SubString& y); - -// concatenation - - void operator += (const String& y); - void operator += (const SubString& y); - void operator += (const char* t); - void operator += (char c); - - void prepend(const String& y); - void prepend(const SubString& y); - void prepend(const char* t); - void prepend(char c); - - -// procedural versions: -// concatenate first 2 args, store result in last arg - - friend void cat(const String&, const String&, String&); - friend void cat(const String&, const SubString&, String&); - friend void cat(const String&, const char*, String&); - friend void cat(const String&, char, String&); - - friend void cat(const SubString&, const String&, String&); - friend void cat(const SubString&, const SubString&, String&); - friend void cat(const SubString&, const char*, String&); - friend void cat(const SubString&, char, String&); - - friend void cat(const char*, const String&, String&); - friend void cat(const char*, const SubString&, String&); - friend void cat(const char*, const char*, String&); - friend void cat(const char*, char, String&); - -// double concatenation, by request. (yes, there are too many versions, -// but if one is supported, then the others should be too...) -// Concatenate first 3 args, store in last arg - - friend void cat(const String&,const String&, const String&,String&); - friend void cat(const String&,const String&,const SubString&,String&); - friend void cat(const String&,const String&, const char*, String&); - friend void cat(const String&,const String&, char, String&); - friend void cat(const String&,const SubString&,const String&,String&); - friend void cat(const String&,const SubString&,const SubString&,String&); - friend void cat(const String&,const SubString&, const char*, String&); - friend void cat(const String&,const SubString&, char, String&); - friend void cat(const String&,const char*, const String&, String&); - friend void cat(const String&,const char*, const SubString&, String&); - friend void cat(const String&,const char*, const char*, String&); - friend void cat(const String&,const char*, char, String&); - - friend void cat(const char*, const String&, const String&,String&); - friend void cat(const char*,const String&,const SubString&,String&); - friend void cat(const char*,const String&, const char*, String&); - friend void cat(const char*,const String&, char, String&); - friend void cat(const char*,const SubString&,const String&,String&); - friend void cat(const char*,const SubString&,const SubString&,String&); - friend void cat(const char*,const SubString&, const char*, String&); - friend void cat(const char*,const SubString&, char, String&); - friend void cat(const char*,const char*, const String&, String&); - friend void cat(const char*,const char*, const SubString&, String&); - friend void cat(const char*,const char*, const char*, String&); - friend void cat(const char*,const char*, char, String&); - - -// searching & matching - -// return position of target in string or -1 for failure - - int index(char c, int startpos = 0) const; - int index(const String& y, int startpos = 0) const; - int index(const SubString& y, int startpos = 0) const; - int index(const char* t, int startpos = 0) const; - int index(const Regex& r, int startpos = 0) const; - -// return 1 if target appears anyhere in String; else 0 - - int contains(char c) const; - int contains(const String& y) const; - int contains(const SubString& y) const; - int contains(const char* t) const; - int contains(const Regex& r) const; - -// return 1 if target appears anywhere after position pos -// (or before, if pos is negative) in String; else 0 - - int contains(char c, int pos) const; - int contains(const String& y, int pos) const; - int contains(const SubString& y, int pos) const; - int contains(const char* t, int pos) const; - int contains(const Regex& r, int pos) const; - -// return 1 if target appears at position pos in String; else 0 - - int matches(char c, int pos = 0) const; - int matches(const String& y, int pos = 0) const; - int matches(const SubString& y, int pos = 0) const; - int matches(const char* t, int pos = 0) const; - int matches(const Regex& r, int pos = 0) const; - -// return number of occurences of target in String - - int freq(char c) const; - int freq(const String& y) const; - int freq(const SubString& y) const; - int freq(const char* t) const; - -// SubString extraction - -// Note that you can't take a substring of a const String, since -// this leaves open the possiblility of indirectly modifying the -// String through the SubString - - SubString at(int pos, int len); - SubString operator () (int pos, int len); // synonym for at - - SubString at(const String& x, int startpos = 0); - SubString at(const SubString& x, int startpos = 0); - SubString at(const char* t, int startpos = 0); - SubString at(char c, int startpos = 0); - SubString at(const Regex& r, int startpos = 0); - - SubString before(int pos); - SubString before(const String& x, int startpos = 0); - SubString before(const SubString& x, int startpos = 0); - SubString before(const char* t, int startpos = 0); - SubString before(char c, int startpos = 0); - SubString before(const Regex& r, int startpos = 0); - - SubString through(int pos); - SubString through(const String& x, int startpos = 0); - SubString through(const SubString& x, int startpos = 0); - SubString through(const char* t, int startpos = 0); - SubString through(char c, int startpos = 0); - SubString through(const Regex& r, int startpos = 0); - - SubString from(int pos); - SubString from(const String& x, int startpos = 0); - SubString from(const SubString& x, int startpos = 0); - SubString from(const char* t, int startpos = 0); - SubString from(char c, int startpos = 0); - SubString from(const Regex& r, int startpos = 0); - - SubString after(int pos); - SubString after(const String& x, int startpos = 0); - SubString after(const SubString& x, int startpos = 0); - SubString after(const char* t, int startpos = 0); - SubString after(char c, int startpos = 0); - SubString after(const Regex& r, int startpos = 0); - - -// deletion - -// delete len chars starting at pos - void del(int pos, int len); - -// delete the first occurrence of target after startpos - - void del(const String& y, int startpos = 0); - void del(const SubString& y, int startpos = 0); - void del(const char* t, int startpos = 0); - void del(char c, int startpos = 0); - void del(const Regex& r, int startpos = 0); - -// global substitution: substitute all occurrences of pat with repl - - int gsub(const String& pat, const String& repl); - int gsub(const SubString& pat, const String& repl); - int gsub(const char* pat, const String& repl); - int gsub(const char* pat, const char* repl); - int gsub(const Regex& pat, const String& repl); - -// friends & utilities - -// split string into array res at separators; return number of elements - - friend int split(const String& x, String res[], int maxn, - const String& sep); - friend int split(const String& x, String res[], int maxn, - const Regex& sep); - - friend String common_prefix(const String& x, const String& y, - int startpos = 0); - friend String common_suffix(const String& x, const String& y, - int startpos = -1); - friend String replicate(char c, int n); - friend String replicate(const String& y, int n); - friend String join(String src[], int n, const String& sep); - -// simple builtin transformations - - friend String reverse(const String& x); - friend String upcase(const String& x); - friend String downcase(const String& x); - friend String capitalize(const String& x); - -// in-place versions of above - - void reverse(); - void upcase(); - void downcase(); - void capitalize(); - -// element extraction - - char& operator [] (int i); - char elem(int i) const; - char firstchar() const; - char lastchar() const; - -// conversion - - operator const char*() const; - const char* chars() const; - - -// IO - - friend ostream& operator<<(ostream& s, const String& x); - friend ostream& operator<<(ostream& s, const SubString& x); - friend istream& operator>>(istream& s, String& x); - - friend int readline(istream& s, String& x, - char terminator = '\n', - int discard_terminator = 1); - -// status - - int length() const; - int empty() const; - -// preallocate some space for String - void alloc(int newsize); - -// report current allocation (not length!) - - int allocation() const; - - - volatile void error(const char* msg) const; - - int OK() const; -}; - -typedef String StrTmp; // for backward compatibility - -// other externs - -int compare(const String& x, const String& y); -int compare(const String& x, const SubString& y); -int compare(const String& x, const char* y); -int compare(const SubString& x, const String& y); -int compare(const SubString& x, const SubString& y); -int compare(const SubString& x, const char* y); -int fcompare(const String& x, const String& y); // ignore case - -extern StrRep _nilStrRep; -extern String _nilString; - -// other inlines - -String operator + (const String& x, const String& y); -String operator + (const String& x, const SubString& y); -String operator + (const String& x, const char* y); -String operator + (const String& x, char y); -String operator + (const SubString& x, const String& y); -String operator + (const SubString& x, const SubString& y); -String operator + (const SubString& x, const char* y); -String operator + (const SubString& x, char y); -String operator + (const char* x, const String& y); -String operator + (const char* x, const SubString& y); - -int operator==(const String& x, const String& y); -int operator!=(const String& x, const String& y); -int operator> (const String& x, const String& y); -int operator>=(const String& x, const String& y); -int operator< (const String& x, const String& y); -int operator<=(const String& x, const String& y); -int operator==(const String& x, const SubString& y); -int operator!=(const String& x, const SubString& y); -int operator> (const String& x, const SubString& y); -int operator>=(const String& x, const SubString& y); -int operator< (const String& x, const SubString& y); -int operator<=(const String& x, const SubString& y); -int operator==(const String& x, const char* t); -int operator!=(const String& x, const char* t); -int operator> (const String& x, const char* t); -int operator>=(const String& x, const char* t); -int operator< (const String& x, const char* t); -int operator<=(const String& x, const char* t); -int operator==(const SubString& x, const String& y); -int operator!=(const SubString& x, const String& y); -int operator> (const SubString& x, const String& y); -int operator>=(const SubString& x, const String& y); -int operator< (const SubString& x, const String& y); -int operator<=(const SubString& x, const String& y); -int operator==(const SubString& x, const SubString& y); -int operator!=(const SubString& x, const SubString& y); -int operator> (const SubString& x, const SubString& y); -int operator>=(const SubString& x, const SubString& y); -int operator< (const SubString& x, const SubString& y); -int operator<=(const SubString& x, const SubString& y); -int operator==(const SubString& x, const char* t); -int operator!=(const SubString& x, const char* t); -int operator> (const SubString& x, const char* t); -int operator>=(const SubString& x, const char* t); -int operator< (const SubString& x, const char* t); -int operator<=(const SubString& x, const char* t); - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - -// status reports, needed before defining other things - -inline int String::length() const { return rep->len; } -inline int String::empty() const { return rep->len == 0; } -inline const char* String::chars() const { return &(rep->s[0]); } -inline int String::allocation() const { return rep->sz; } -inline void String::alloc(int newsize) { rep = Sresize(rep, newsize); } - -inline int SubString::length() const { return len; } -inline int SubString::empty() const { return len == 0; } -inline const char* SubString::chars() const { return &(S.rep->s[pos]); } - - -// constructors - -inline String::String() - : rep(&_nilStrRep) {} -inline String::String(const String& x) - : rep(Scopy(0, x.rep)) {} -inline String::String(const char* t) - : rep(Salloc(0, t, -1, -1)) {} -inline String::String(const char* t, int tlen) - : rep(Salloc(0, t, tlen, tlen)) {} -inline String::String(const SubString& y) - : rep(Salloc(0, y.chars(), y.length(), y.length())) {} -inline String::String(char c) - : rep(Salloc(0, &c, 1, 1)) {} - -inline String::~String() { if (rep != &_nilStrRep) delete rep; } - -inline SubString::SubString(const SubString& x) - :S(x.S), pos(x.pos), len(x.len) {} -inline SubString::SubString(String& x, int first, int l) - :S(x), pos(first), len(l) {} - -inline SubString::~SubString() {} - -// assignment - -inline void String::operator = (const String& y) -{ - rep = Scopy(rep, y.rep); -} - -inline void String::operator=(const char* t) -{ - rep = Salloc(rep, t, -1, -1); -} - -inline void String::operator=(const SubString& y) -{ - rep = Salloc(rep, y.chars(), y.length(), y.length()); -} - -inline void String::operator=(char c) -{ - rep = Salloc(rep, &c, 1, 1); -} - - -inline void SubString::operator = (const char* ys) -{ - assign(0, ys); -} - -inline void SubString::operator = (char ch) -{ - assign(0, &ch, 1); -} - -inline void SubString::operator = (const String& y) -{ - assign(y.rep, y.chars(), y.length()); -} - -inline void SubString::operator = (const SubString& y) -{ - assign(y.S.rep, y.chars(), y.length()); -} - -// Zillions of cats... - -inline void cat(const String& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); -} - -inline void cat(const String& x, char y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); -} - -inline void cat(const SubString& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const SubString& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const SubString& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); -} - -inline void cat(const SubString& x, char y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); -} - -inline void cat(const char* x, const String& y, String& r) -{ - r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); -} - -inline void cat(const char* x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); -} - -inline void cat(const char* x, const char* y, String& r) -{ - r.rep = Scat(r.rep, x, -1, y, -1); -} - -inline void cat(const char* x, char y, String& r) -{ - r.rep = Scat(r.rep, x, -1, &y, 1); -} - -inline void cat(const String& a, const String& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& a, const String& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& a, const String& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); -} - -inline void cat(const String& a, const String& x, char y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); -} - -inline void cat(const String& a, const SubString& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& a, const SubString& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& a, const SubString& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); -} - -inline void cat(const String& a, const SubString& x, char y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); -} - -inline void cat(const String& a, const char* x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); -} - -inline void cat(const String& a, const char* x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); -} - -inline void cat(const String& a, const char* x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1); -} - -inline void cat(const String& a, const char* x, char y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1); -} - - -inline void cat(const char* a, const String& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const char* a, const String& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const char* a, const String& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); -} - -inline void cat(const char* a, const String& x, char y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); -} - -inline void cat(const char* a, const SubString& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const char* a, const SubString& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const char* a, const SubString& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); -} - -inline void cat(const char* a, const SubString& x, char y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); -} - -inline void cat(const char* a, const char* x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); -} - -inline void cat(const char* a, const char* x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); -} - -inline void cat(const char* a, const char* x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x, -1, y, -1); -} - -inline void cat(const char* a, const char* x, char y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x, -1, &y, 1); -} - - -// operator versions - -inline void String::operator +=(const String& y) -{ - cat(*this, y, *this); -} - -inline void String::operator +=(const SubString& y) -{ - cat(*this, y, *this); -} - -inline void String::operator += (const char* y) -{ - cat(*this, y, *this); -} - -inline void String:: operator +=(char y) -{ - cat(*this, y, *this); -} - -// constructive concatenation - -#if defined(__GNUG__) && !defined(NO_NRV) - -inline String operator + (const String& x, const String& y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const String& x, const SubString& y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const String& x, const char* y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const String& x, char y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const SubString& x, const String& y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const SubString& x, const SubString& y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const SubString& x, const char* y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const SubString& x, char y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const char* x, const String& y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const char* x, const SubString& y) return r; -{ - cat(x, y, r); -} - -inline String reverse(const String& x) return r; -{ - r.rep = Sreverse(x.rep, r.rep); -} - -inline String upcase(const String& x) return r; -{ - r.rep = Supcase(x.rep, r.rep); -} - -inline String downcase(const String& x) return r; -{ - r.rep = Sdowncase(x.rep, r.rep); -} - -inline String capitalize(const String& x) return r; -{ - r.rep = Scapitalize(x.rep, r.rep); -} - -#else /* NO_NRV */ - -inline String operator + (const String& x, const String& y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const String& x, const SubString& y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const String& x, const char* y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const String& x, char y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const SubString& x, const String& y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const SubString& x, const SubString& y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const SubString& x, const char* y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const SubString& x, char y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const char* x, const String& y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const char* x, const SubString& y) -{ - String r; cat(x, y, r); return r; -} - -inline String reverse(const String& x) -{ - String r; r.rep = Sreverse(x.rep, r.rep); return r; -} - -inline String upcase(const String& x) -{ - String r; r.rep = Supcase(x.rep, r.rep); return r; -} - -inline String downcase(const String& x) -{ - String r; r.rep = Sdowncase(x.rep, r.rep); return r; -} - -inline String capitalize(const String& x) -{ - String r; r.rep = Scapitalize(x.rep, r.rep); return r; -} - -#endif - -// prepend - -inline void String::prepend(const String& y) -{ - rep = Sprepend(rep, y.chars(), y.length()); -} - -inline void String::prepend(const char* y) -{ - rep = Sprepend(rep, y, -1); -} - -inline void String::prepend(char y) -{ - rep = Sprepend(rep, &y, 1); -} - -inline void String::prepend(const SubString& y) -{ - rep = Sprepend(rep, y.chars(), y.length()); -} - -// misc transformations - - -inline void String::reverse() -{ - rep = Sreverse(rep, rep); -} - - -inline void String::upcase() -{ - rep = Supcase(rep, rep); -} - - -inline void String::downcase() -{ - rep = Sdowncase(rep, rep); -} - - -inline void String::capitalize() -{ - rep = Scapitalize(rep, rep); -} - -// element extraction - -inline char& String::operator [] (int i) -{ - if (((unsigned)i) >= length()) error("invalid index"); - return rep->s[i]; -} - -inline char String::elem (int i) const -{ - if (((unsigned)i) >= length()) error("invalid index"); - return rep->s[i]; -} - -inline char String::firstchar() const -{ - return elem(0); -} - -inline char String::lastchar() const -{ - return elem(length() - 1); -} - -// searching - -inline int String::index(char c, int startpos) const -{ - return search(startpos, length(), c); -} - -inline int String::index(const char* t, int startpos) const -{ - return search(startpos, length(), t); -} - -inline int String::index(const String& y, int startpos) const -{ - return search(startpos, length(), y.chars(), y.length()); -} - -inline int String::index(const SubString& y, int startpos) const -{ - return search(startpos, length(), y.chars(), y.length()); -} - -inline int String::index(const Regex& r, int startpos) const -{ - int unused; return r.search(chars(), length(), unused, startpos); -} - -inline int String::contains(char c) const -{ - return search(0, length(), c) >= 0; -} - -inline int String::contains(const char* t) const -{ - return search(0, length(), t) >= 0; -} - -inline int String::contains(const String& y) const -{ - return search(0, length(), y.chars(), y.length()) >= 0; -} - -inline int String::contains(const SubString& y) const -{ - return search(0, length(), y.chars(), y.length()) >= 0; -} - -inline int String::contains(char c, int p) const -{ - return match(p, length(), 0, &c, 1) >= 0; -} - -inline int String::contains(const char* t, int p) const -{ - return match(p, length(), 0, t) >= 0; -} - -inline int String::contains(const String& y, int p) const -{ - return match(p, length(), 0, y.chars(), y.length()) >= 0; -} - -inline int String::contains(const SubString& y, int p) const -{ - return match(p, length(), 0, y.chars(), y.length()) >= 0; -} - -inline int String::contains(const Regex& r) const -{ - int unused; return r.search(chars(), length(), unused, 0) >= 0; -} - -inline int String::contains(const Regex& r, int p) const -{ - return r.match(chars(), length(), p) >= 0; -} - - -inline int String::matches(const SubString& y, int p) const -{ - return match(p, length(), 1, y.chars(), y.length()) >= 0; -} - -inline int String::matches(const String& y, int p) const -{ - return match(p, length(), 1, y.chars(), y.length()) >= 0; -} - -inline int String::matches(const char* t, int p) const -{ - return match(p, length(), 1, t) >= 0; -} - -inline int String::matches(char c, int p) const -{ - return match(p, length(), 1, &c, 1) >= 0; -} - -inline int String::matches(const Regex& r, int p) const -{ - int l = (p < 0)? -p : length() - p; - return r.match(chars(), length(), p) == l; -} - - -inline int SubString::contains(const char* t) const -{ - return S.search(pos, pos+len, t) >= 0; -} - -inline int SubString::contains(const String& y) const -{ - return S.search(pos, pos+len, y.chars(), y.length()) >= 0; -} - -inline int SubString::contains(const SubString& y) const -{ - return S.search(pos, pos+len, y.chars(), y.length()) >= 0; -} - -inline int SubString::contains(char c) const -{ - return S.search(pos, pos+len, 0, c) >= 0; -} - -inline int SubString::contains(const Regex& r) const -{ - int unused; return r.search(chars(), len, unused, 0) >= 0; -} - -inline int SubString::matches(const Regex& r) const -{ - return r.match(chars(), len, 0) == len; -} - - -inline int String::gsub(const String& pat, const String& r) -{ - return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); -} - -inline int String::gsub(const SubString& pat, const String& r) -{ - return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); -} - -inline int String::gsub(const Regex& pat, const String& r) -{ - return _gsub(pat, r.chars(), r.length()); -} - -inline int String::gsub(const char* pat, const String& r) -{ - return _gsub(pat, -1, r.chars(), r.length()); -} - -inline int String::gsub(const char* pat, const char* r) -{ - return _gsub(pat, -1, r, -1); -} - - -inline String::operator const char*() const -{ - return str(chars()); -} - -inline ostream& operator<<(ostream& s, const String& x) -{ -#ifdef VMS - s << x.chars(); return s; -#else - s.put(x.chars()); return s; -#endif - -} - -// a zillion comparison operators - -inline int operator==(const String& x, const String& y) -{ - return compare(x, y) == 0; -} - -inline int operator!=(const String& x, const String& y) -{ - return compare(x, y) != 0; -} - -inline int operator>(const String& x, const String& y) -{ - return compare(x, y) > 0; -} - -inline int operator>=(const String& x, const String& y) -{ - return compare(x, y) >= 0; -} - -inline int operator<(const String& x, const String& y) -{ - return compare(x, y) < 0; -} - -inline int operator<=(const String& x, const String& y) -{ - return compare(x, y) <= 0; -} - -inline int operator==(const String& x, const SubString& y) -{ - return compare(x, y) == 0; -} - -inline int operator!=(const String& x, const SubString& y) -{ - return compare(x, y) != 0; -} - -inline int operator>(const String& x, const SubString& y) -{ - return compare(x, y) > 0; -} - -inline int operator>=(const String& x, const SubString& y) -{ - return compare(x, y) >= 0; -} - -inline int operator<(const String& x, const SubString& y) -{ - return compare(x, y) < 0; -} - -inline int operator<=(const String& x, const SubString& y) -{ - return compare(x, y) <= 0; -} - -inline int operator==(const String& x, const char* t) -{ - return compare(x, t) == 0; -} - -inline int operator!=(const String& x, const char* t) -{ - return compare(x, t) != 0; -} - -inline int operator>(const String& x, const char* t) -{ - return compare(x, t) > 0; -} - -inline int operator>=(const String& x, const char* t) -{ - return compare(x, t) >= 0; -} - -inline int operator<(const String& x, const char* t) -{ - return compare(x, t) < 0; -} - -inline int operator<=(const String& x, const char* t) -{ - return compare(x, t) <= 0; -} - -inline int operator==(const SubString& x, const String& y) -{ - return compare(y, x) == 0; -} - -inline int operator!=(const SubString& x, const String& y) -{ - return compare(y, x) != 0; -} - -inline int operator>(const SubString& x, const String& y) -{ - return compare(y, x) < 0; -} - -inline int operator>=(const SubString& x, const String& y) -{ - return compare(y, x) <= 0; -} - -inline int operator<(const SubString& x, const String& y) -{ - return compare(y, x) > 0; -} - -inline int operator<=(const SubString& x, const String& y) -{ - return compare(y, x) >= 0; -} - -inline int operator==(const SubString& x, const SubString& y) -{ - return compare(x, y) == 0; -} - -inline int operator!=(const SubString& x, const SubString& y) -{ - return compare(x, y) != 0; -} - -inline int operator>(const SubString& x, const SubString& y) -{ - return compare(x, y) > 0; -} - -inline int operator>=(const SubString& x, const SubString& y) -{ - return compare(x, y) >= 0; -} - -inline int operator<(const SubString& x, const SubString& y) -{ - return compare(x, y) < 0; -} - -inline int operator<=(const SubString& x, const SubString& y) -{ - return compare(x, y) <= 0; -} - -inline int operator==(const SubString& x, const char* t) -{ - return compare(x, t) == 0; -} - -inline int operator!=(const SubString& x, const char* t) -{ - return compare(x, t) != 0; -} - -inline int operator>(const SubString& x, const char* t) -{ - return compare(x, t) > 0; -} - -inline int operator>=(const SubString& x, const char* t) -{ - return compare(x, t) >= 0; -} - -inline int operator<(const SubString& x, const char* t) -{ - return compare(x, t) < 0; -} - -inline int operator<=(const SubString& x, const char* t) -{ - return compare(x, t) <= 0; -} - - -// a helper needed by at, before, etc. - -inline SubString String::_substr(int first, int l) -{ - if (first < 0 || (unsigned)(first + l) > length()) - return SubString(_nilString, 0, 0) ; - else - return SubString(*this, first, l); -} - - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/Uniform.h b/gnu/lib/libg++/g++-include/Uniform.h deleted file mode 100644 index 5d896e8f0cfd..000000000000 --- a/gnu/lib/libg++/g++-include/Uniform.h +++ /dev/null @@ -1,81 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _Uniform_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Uniform_h 1 - -#include - -// -// The interval [lo..hi] -// - -class Uniform: public Random { - double pLow; - double pHigh; - double delta; -public: - Uniform(double low, double high, RNG *gen); - - double low(); - double low(double x); - double high(); - double high(double x); - - virtual double operator()(); -}; - - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline Uniform::Uniform(double low, double high, RNG *gen):(gen) -{ - pLow = (low < high) ? low : high; - pHigh = (low < high) ? high : low; - delta = pHigh - pLow; -} - -inline double Uniform::low() { return pLow; } - -inline double Uniform::low(double x) { - double tmp = pLow; - pLow = x; - delta = pHigh - pLow; - return tmp; -} - -inline double Uniform::high() { return pHigh; } - -inline double Uniform::high(double x) { - double tmp = pHigh; - pHigh = x; - delta = pHigh - pLow; - return tmp; -} - - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/Weibull.h b/gnu/lib/libg++/g++-include/Weibull.h deleted file mode 100644 index 6ce8eabf8bc8..000000000000 --- a/gnu/lib/libg++/g++-include/Weibull.h +++ /dev/null @@ -1,83 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifndef _Weibull_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _Weibull_h - -#include - -class Weibull: public Random { -protected: - double pAlpha; - double pInvAlpha; - double pBeta; - - void setState(); - -public: - Weibull(double alpha, double beta, RNG *gen); - - double alpha(); - double alpha(double x); - - double beta(); - double beta(double x); - - virtual double operator()(); -}; - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline void Weibull::setState() { - pInvAlpha = 1.0 / pAlpha; -} - -inline Weibull::Weibull(double alpha, double beta, RNG *gen) : (gen) -{ - pAlpha = alpha; - pBeta = beta; - setState(); -} - -inline double Weibull::alpha() { return pAlpha; } - -inline double Weibull::alpha(double x) { - double tmp = pAlpha; - pAlpha = x; - setState(); - return tmp; -} - -inline double Weibull::beta() { return pBeta; }; -inline double Weibull::beta(double x) { - double tmp = pBeta; - pBeta = x; - return tmp; -}; - - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/abs.h b/gnu/lib/libg++/g++-include/abs.h deleted file mode 100644 index 8c2c8f98ced4..000000000000 --- a/gnu/lib/libg++/g++-include/abs.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/gnu/lib/libg++/g++-include/bool.h b/gnu/lib/libg++/g++-include/bool.h deleted file mode 100644 index e843aa9c471e..000000000000 --- a/gnu/lib/libg++/g++-include/bool.h +++ /dev/null @@ -1,10 +0,0 @@ - -#ifndef _bool_h -#ifdef __GNUG__ -#pragma once -#endif -#define _bool_h 1 - -enum bool { FALSE = 0, TRUE = 1 }; - -#endif diff --git a/gnu/lib/libg++/g++-include/builtin.h b/gnu/lib/libg++/g++-include/builtin.h deleted file mode 100644 index 904059b8af89..000000000000 --- a/gnu/lib/libg++/g++-include/builtin.h +++ /dev/null @@ -1,276 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -/* - arithmetic, etc. functions on built in types -*/ - - -#ifndef _builtin_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _builtin_h 1 - - -typedef void (*one_arg_error_handler_t)(const char*); -typedef void (*two_arg_error_handler_t)(const char*, const char*); - - - -#include -#include -#include - -long gcd(long, long); -long lg(unsigned long); -double pow(double, long); -long pow(long, long); - -double start_timer(); -double return_elapsed_time(double last_time = 0.0); - -char* itoa(long x, int base = 10, int width = 0); -char* itoa(unsigned long x, int base = 10, int width = 0); -#ifdef __GNUG__ -char* itoa(long long x, int base = 10, int width = 0); -char* itoa(unsigned long long x, int base = 10, int width = 0); -#endif -char* dtoa(double x, char cvt = 'g', int width = 0, int prec = 6); - -char* hex(long x, int width = 0); -char* hex(unsigned long x, int width = 0); -char* hex(int x, int width = 0); -char* hex(short x, int width = 0); -char* hex(unsigned int x, int width = 0); -char* hex(unsigned short x, int width = 0); - -char* oct(long x, int width = 0); -char* oct(unsigned long x, int width = 0); -char* oct(int x, int width = 0); -char* oct(short x, int width = 0); -char* oct(unsigned int x, int width = 0) ; -char* oct(unsigned short x, int width = 0); - -char* dec(long x, int width = 0); -char* dec(unsigned long x, int width = 0); -char* dec(int x, int width = 0); -char* dec(short x, int width = 0); -char* dec(unsigned int x, int width = 0) ; -char* dec(unsigned short x, int width = 0); - -char* form(const char* fmt ...); -char* chr(char ch, int width = 0); -char* str(const char* s, int width = 0); - -unsigned int hashpjw(const char*); -unsigned int multiplicativehash(int); -unsigned int foldhash(double); - -extern void default_one_arg_error_handler(const char*); -extern void default_two_arg_error_handler(const char*, const char*); - -extern two_arg_error_handler_t lib_error_handler; - -extern two_arg_error_handler_t - set_lib_error_handler(two_arg_error_handler_t f); - - -double abs(double arg); -float abs(float arg); -short abs(short arg); -long abs(long arg); -int sign(long arg); -int sign(double arg); -long sqr(long arg); -double sqr(double arg); -int even(long arg); -int odd(long arg); -long lcm(long x, long y); -void setbit(long& x, long b); -void clearbit(long& x, long b); -int testbit(long x, long b); - -signed char min(signed char a, signed char b); -unsigned char min(unsigned char a, unsigned char b); - -signed short min(signed short a, signed short b); -unsigned short min(unsigned short a, unsigned short b); - -signed int min(signed int a, signed int b); -unsigned int min(unsigned int a, unsigned int b); - -signed long min(signed long a, signed long b); -unsigned long min(unsigned long a, unsigned long b); - -float min(float a, float b); - -double min(double a, double b); - -signed char max(signed char a, signed char b); -unsigned char max(unsigned char a, unsigned char b); - -signed short max(signed short a, signed short b); -unsigned short max(unsigned short a, unsigned short b); - -signed int max(signed int a, signed int b); -unsigned int max(unsigned int a, unsigned int b); - -signed long max(signed long a, signed long b); -unsigned long max(unsigned long a, unsigned long b); - -float max(float a, float b); - -double max(double a, double b); - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - -inline double abs(double arg) -{ - return (arg < 0.0)? -arg : arg; -} - -inline float abs(float arg) -{ - return (arg < 0.0)? -arg : arg; -} - -inline short abs(short arg) -{ - return (arg < 0)? -arg : arg; -} - -inline long abs(long arg) -{ - return (arg < 0)? -arg : arg; -} - -inline int sign(long arg) -{ - return (arg == 0) ? 0 : ( (arg > 0) ? 1 : -1 ); -} - -inline int sign(double arg) -{ - return (arg == 0.0) ? 0 : ( (arg > 0.0) ? 1 : -1 ); -} - -inline long sqr(long arg) -{ - return arg * arg; -} - -inline double sqr(double arg) -{ - return arg * arg; -} - -inline int even(long arg) -{ - return !(arg & 1); -} - -inline int odd(long arg) -{ - return (arg & 1); -} - -inline long lcm(long x, long y) -{ - return x / gcd(x, y) * y; -} - -inline void setbit(long& x, long b) -{ - x |= (1 << b); -} - -inline void clearbit(long& x, long b) -{ - x &= ~(1 << b); -} - -inline int testbit(long x, long b) -{ - return ((x & (1 << b)) != 0); -} - -inline char* hex(int x, int width = 0) { return hex(long(x), width); } -inline char* hex(short x, int width = 0) { return hex(long(x), width); } -inline char* hex(unsigned int x, int width = 0) -{ return hex((unsigned long)(x), width); } -inline char* hex(unsigned short x, int width = 0) -{ return hex((unsigned long)(x), width); } - -inline char* oct(int x, int width = 0) { return oct(long(x), width); } -inline char* oct(short x, int width = 0) { return oct(long(x), width); } -inline char* oct(unsigned int x, int width = 0) -{ return oct((unsigned long)(x), width); } -inline char* oct(unsigned short x, int width = 0) -{ return oct((unsigned long)(x), width); } - -inline char* dec(int x, int width = 0) { return dec(long(x), width); } -inline char* dec(short x, int width = 0) { return dec(long(x), width); } -inline char* dec(unsigned int x, int width = 0) -{ return dec((unsigned long)(x), width); } -inline char* dec(unsigned short x, int width = 0) -{ return dec((unsigned long)(x), width); } - -inline signed char min(signed char a, signed char b) { return (a < b)?a:b;} -inline unsigned char min(unsigned char a, unsigned char b) {return (a < b)?a:b;} - -inline signed short min(signed short a, signed short b) {return (a < b) ?a:b;} -inline unsigned short min(unsigned short a, unsigned short b) {return (a < b)?a:b;} - -inline signed int min(signed int a, signed int b) {return (a < b)?a:b;} -inline unsigned int min(unsigned int a, unsigned int b) {return (a < b)?a:b;} - -inline signed long min(signed long a, signed long b) {return (a < b)?a:b;} -inline unsigned long min(unsigned long a, unsigned long b) {return (a < b)?a:b;} - -inline float min(float a, float b) {return (a < b)?a:b;} - -inline double min(double a, double b) {return (a < b)?a:b;} - -inline signed char max(signed char a, signed char b) { return (a > b)?a:b;} -inline unsigned char max(unsigned char a, unsigned char b) {return (a > b)?a:b;} - -inline signed short max(signed short a, signed short b) {return (a > b) ?a:b;} -inline unsigned short max(unsigned short a, unsigned short b) {return (a > b)?a:b;} - -inline signed int max(signed int a, signed int b) {return (a > b)?a:b;} -inline unsigned int max(unsigned int a, unsigned int b) {return (a > b)?a:b;} - -inline signed long max(signed long a, signed long b) {return (a > b)?a:b;} -inline unsigned long max(unsigned long a, unsigned long b) {return (a > b)?a:b;} - -inline float max(float a, float b) {return (a > b)?a:b;} - -inline double max(double a, double b) {return (a > b)?a:b;} - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/compare.h b/gnu/lib/libg++/g++-include/compare.h deleted file mode 100644 index e298e2f1957d..000000000000 --- a/gnu/lib/libg++/g++-include/compare.h +++ /dev/null @@ -1,98 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _compare_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _compare_h 1 - -#include - -int compare(int a, int b); -int compare(short a, short b); -int compare(char a, char b); -int compare(unsigned long a, unsigned long b); -int compare(unsigned int a, unsigned int b); -int compare(unsigned short a, unsigned short b); -int compare(unsigned char a, unsigned char b); -int compare(float a, float b); -int compare(double a, double b); -int compare(const char* a, const char* b); - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - -inline int compare(int a, int b) -{ - return a - b; -} - -inline int compare(short a, short b) -{ - return a - b; -} - -inline int compare(char a, char b) -{ - return a - b; -} - -inline int compare(unsigned long a, unsigned long b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(unsigned int a, unsigned int b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(unsigned short a, unsigned short b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(unsigned char a, unsigned char b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(float a, float b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(double a, double b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(const char* a, const char* b) -{ - return strcmp(a,b); -} - -#endif -#endif diff --git a/gnu/lib/libg++/g++-include/complex.h b/gnu/lib/libg++/g++-include/complex.h deleted file mode 100644 index 1411c22f0c0d..000000000000 --- a/gnu/lib/libg++/g++-include/complex.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _complex_h -#ifdef __GNUG__ -#pragma once -#endif -#define _complex_h -#define __ATT_complex__ -#include -typedef class Complex complex; -#endif diff --git a/gnu/lib/libg++/g++-include/fcntl.h b/gnu/lib/libg++/g++-include/fcntl.h deleted file mode 100644 index 8fab80af867c..000000000000 --- a/gnu/lib/libg++/g++-include/fcntl.h +++ /dev/null @@ -1,31 +0,0 @@ -// $Id: fcntl.h,v 1.2 1993/08/02 17:22:07 mycroft Exp $ - -#ifndef fcntl_h - -extern "C" { - -#ifdef __fcntl_h_recursive -#include_next -#else -#define fcntl __hide_fcntl -#define open __hide_open -#define creat __hide_creat - -#define __fcntl_h_recursive -#include <_G_config.h> -#include_next - -#undef fcntl -#undef open -#undef creat - -#define fcntl_h 1 - -int fcntl(int, int, ...); -int creat _G_ARGS((const char*, unsigned short int)); - -int open _G_ARGS((const char*, int, ...)); - -#endif -} -#endif diff --git a/gnu/lib/libg++/g++-include/file.h b/gnu/lib/libg++/g++-include/file.h deleted file mode 100644 index ca112456ea19..000000000000 --- a/gnu/lib/libg++/g++-include/file.h +++ /dev/null @@ -1,8 +0,0 @@ - -#ifndef file_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#include -#endif diff --git a/gnu/lib/libg++/g++-include/filebuf.h b/gnu/lib/libg++/g++-include/filebuf.h deleted file mode 100644 index 9cf35ccadb0f..000000000000 --- a/gnu/lib/libg++/g++-include/filebuf.h +++ /dev/null @@ -1,63 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _filebuf_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _filebuf_h 1 - -#include -#include - -class filebuf: public streambuf -{ -public: - int fd; - char opened; - - int overflow(int c = EOF); - int underflow(); - - filebuf(); - filebuf(int newfd); - filebuf(int newfd, char* buf, int buflen); - filebuf(const char* filename, io_mode m, access_mode a); - filebuf(const char* filename, const char* m); - filebuf(int filedesc, io_mode m); - filebuf(FILE* fileptr); - - ~filebuf(); - - streambuf* open(const char* name, open_mode m); - streambuf* open(const char* filename, io_mode m, access_mode a); - streambuf* open(const char* filename, const char* m); - streambuf* open(int filedesc, io_mode m); - streambuf* open(FILE* fileptr); - int is_open(); - int close(); -}; - - -#endif diff --git a/gnu/lib/libg++/g++-include/generic.h b/gnu/lib/libg++/g++-include/generic.h deleted file mode 100644 index 743a26dcbcb9..000000000000 --- a/gnu/lib/libg++/g++-include/generic.h +++ /dev/null @@ -1,63 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef generic_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define generic_h 1 - -/* - * See the CPP manual, argument prescan section for explanation - */ - -#define name2(a,b) gEnErIc2(a,b) -#define gEnErIc2(a,b) a ## b - -#define name3(a,b,c) gEnErIc3(a,b,c) -#define gEnErIc3(a,b,c) a ## b ## c - -#define name4(a,b,c,d) gEnErIc4(a,b,c,d) -#define gEnErIc4(a,b,c,d) a ## b ## c ## d - -#define GENERIC_STRING(a) gEnErIcStRiNg(a) -#define gEnErIcStRiNg(a) #a - -#define declare(clas,t) name2(clas,declare)(t) -#define declare2(clas,t1,t2) name2(clas,declare2)(t1,t2) - -#define implement(clas,t) name2(clas,implement)(t) -#define implement2(clas,t1,t2) name2(clas,implement2)(t1,t2) - -extern genericerror(int,char*); -typedef int (*GPT)(int,char*); - -#define set_handler(gen,type,x) name4(set_,type,gen,_handler)(x) - -#define errorhandler(gen,type) name3(type,gen,handler) - -#define callerror(gen,type,a,b) (*errorhandler(gen,type))(a,b) - - -#endif generic_h diff --git a/gnu/lib/libg++/g++-include/grp.h b/gnu/lib/libg++/g++-include/grp.h deleted file mode 100644 index d5ccbb7aa3d8..000000000000 --- a/gnu/lib/libg++/g++-include/grp.h +++ /dev/null @@ -1,43 +0,0 @@ -// $Id: grp.h,v 1.3 1993/08/14 22:07:30 mycroft Exp $ - -#ifndef grp_h - -extern "C" { - -#ifdef __grp_h_recursive -#include_next -#else -#define __grp_h_recursive - -#include - -#define getgrent c_proto_getgrent -#define getgrgid c_proto_getgrgid -#define getgrnam c_proto_getgrnam -#define setgrent c_proto_setgrent -#define endgrent c_proto_endgrent -#define fgetgrent c_proto_fgetgrent - -#include_next - -#define grp_h 1 - -#undef getgrent -#undef getgrgid -#undef getgrnam - -extern struct group* getgrent(); -extern struct group* fgetgrent(FILE*); -extern struct group* getgrgid(int); -extern struct group* getgrnam(const char*); -#if defined(__OSF1__) || defined (__NetBSD__) -extern int setgrent(); -#else -extern void setgrent(); -#endif -extern void endgrent(); - -#endif -} - -#endif diff --git a/gnu/lib/libg++/g++-include/istream.h b/gnu/lib/libg++/g++-include/istream.h deleted file mode 100644 index 1fa10fe594ae..000000000000 --- a/gnu/lib/libg++/g++-include/istream.h +++ /dev/null @@ -1,259 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -/* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */ - -/* istream.h now separately includable */ - -#ifndef _istream_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _istream_h 1 - - -#include -#include -#include -#include - -class whitespace // a class used only to input and -{ // discard white space characters - char filler; -}; - -class ostream; - -class istream -{ - friend void eatwhite(istream& s); -protected: - streambuf* bp; - state_value state; // _good/_eof/_fail/_bad - ostream* tied_to; - char skipws; - char ownbuf; - void _flush(); - char* readline (int chunk_number, char terminator); - -public: - istream(const char* filename, io_mode m, access_mode a, - int sk=1, ostream* t = 0); - istream(const char* filename, const char* m, - int sk=1, ostream* t = 0); - istream(int filedesc, io_mode m, int sk=1, ostream* t = 0); - istream(FILE* fileptr, int sk=1, ostream* t = 0); - istream(int sz, char* buf, int sk=1, ostream* t = 0); - istream(int filedesc, int sk=1, ostream* t = 0); - istream(int filedesc, char* buf, int buflen, - int sk, ostream* t = 0); - istream(streambuf* s, int sk=1, ostream* t = 0); - - ~istream(); - - istream& open(const char* filename, io_mode m, access_mode a); - istream& open(const char* filename, const char* m); - istream& open(int filedesc, io_mode m); - istream& open(FILE* fileptr); - istream& open(const char* filenam, open_mode m); - - istream& close(); - - ostream* tie(ostream* s); - int skip(int); - -// stream status - - int rdstate(); - int eof(); - int fail(); - int bad(); - int good(); - -// other status queries - - int readable(); - int writable(); - int is_open(); - - operator void*(); - int operator !(); - - const char* name(); - - char* bufptr(); - -// error handling - - void error(); - void clear(state_value f = _good); // poorly named - void set(state_value f); // set corresponding bit - void unset(state_value f); // clear corresponding bit - istream& failif(int cond); - -// unformatted IO - - istream& get(char& c); - istream& unget(char c); - istream& putback(char c); // a synonym for unget - - istream& get (char* s, int n, char terminator = '\n'); - istream& getline(char* s, int n, char terminator = '\n'); - istream& gets (char **s, char terminator = '\n'); - - - istream& operator >> (char& c); - istream& operator >> (short& n); - istream& operator >> (unsigned short& n); - istream& operator >> (int& n); - istream& operator >> (unsigned int& n); - istream& operator >> (long& n); - istream& operator >> (unsigned long& n); -#ifdef __GNUG__ - istream& operator >> (long long& n); - istream& operator >> (unsigned long long& n); -#endif - istream& operator >> (float& n); - istream& operator >> (double& n); - istream& operator >> (char* s); - istream& operator >> (whitespace& w); -}; - -// pre-declared streams - -extern istream cin; // stdin - -extern whitespace WS; // for convenience - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - -inline void istream::clear(state_value flag) -{ - state = flag; -} - -inline void istream::set(state_value flag) -{ - state = state_value(int(state) | int(flag)); -} - -inline void istream::unset(state_value flag) -{ - state = state_value(int(state) & ~int(flag)); -} - -inline int istream::rdstate() -{ - return int(state); -} - -inline int istream::good() -{ - return state == _good; -} - -inline int istream::eof() -{ - return int(state) & int(_eof); -} - -inline int istream::fail() -{ - return int(state) & int(_fail); -} - -inline int istream::bad() -{ - return int(state) & int(_bad); -} - -inline istream::operator void*() -{ - return (state == _good)? this : 0; -} - -inline int istream::operator !() -{ - return (state != _good); -} - -inline istream& istream::failif(int cond) -{ - if (cond) set(_fail); return *this; -} - -inline int istream::is_open() -{ - return bp->is_open(); -} - -inline int istream::readable() -{ - return (bp != 0) && (bp->is_open()) && (state == _good); -} - -inline int istream::writable() -{ - return 0; -} - - -inline char* istream::bufptr() -{ - return bp->base; -} - - -inline istream& istream::close() -{ - bp->close(); return *this; -} - - -inline int istream::skip(int sk) -{ - int was = skipws; skipws = sk; return was; -} - - -inline istream& istream::unget(char c) -{ - if (bp->sputbackc(c) == EOF) set(_fail); return *this; -} - -inline istream& istream::putback(char c) -{ - if (bp->sputbackc(c) == EOF) set(_fail); return *this; -} - -inline void eatwhite(istream& s) -{ - s >> WS; -} - -#endif - - -#endif diff --git a/gnu/lib/libg++/g++-include/malloc.h b/gnu/lib/libg++/g++-include/malloc.h deleted file mode 100644 index dff79ed6b0ec..000000000000 --- a/gnu/lib/libg++/g++-include/malloc.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/gnu/lib/libg++/g++-include/math-68881.h b/gnu/lib/libg++/g++-include/math-68881.h deleted file mode 100644 index f57494d46419..000000000000 --- a/gnu/lib/libg++/g++-include/math-68881.h +++ /dev/null @@ -1,518 +0,0 @@ -/******************************************************************\ -* * -* last modified: 23 May 1992. * -* * -* Copyright (C) 1989 by Matthew Self. * -* You may freely distribute verbatim copies of this software * -* provided that this copyright notice is retained in all copies. * -* You may distribute modifications to this software under the * -* conditions above if you also clearly note such modifications * -* with their author and date. * -* * -* Note: errno is not set to EDOM when domain errors occur for * -* most of these functions. Rather, it is assumed that the * -* 68881's OPERR exception will be enabled and handled * -* appropriately by the operating system. Similarly, overflow * -* and underflow do not set errno to ERANGE. * -* * -* Send bugs to Matthew Self (self@bayes.arc.nasa.gov). * -* * -* $Id: math-68881.h,v 1.1 1993/08/14 22:38:25 mycroft Exp $ * -* * -\******************************************************************/ - -/* If you find this in GCC, - please send bug reports to bug-gcc@prep.ai.mit.edu. */ - -/* Changed by Richard Stallman: % inserted before a #. - New function `hypot' added. - Nans written in hex to avoid 0rnan. - May 1992, use %! for fpcr register. Break lines before function names. - December 1989, add parens around `&' in pow. - November 1990, added alternate definition of HUGE_VAL for Sun. */ - -#include - -#ifndef HUGE_VAL -#ifdef __sun__ -/* The Sun assembler fails to handle the hex constant in the usual defn. */ -#define HUGE_VAL \ -({ \ - static union { int i[2]; double d; } u = { {0x7ff00000, 0} }; \ - u.d; \ -}) -#else -#define HUGE_VAL \ -({ \ - double huge_val; \ - \ - __asm ("fmove%.d %#0x7ff0000000000000,%0" /* Infinity */ \ - : "=f" (huge_val) \ - : /* no inputs */); \ - huge_val; \ -}) -#endif -#endif - -__inline static const double -sin (double x) -{ - double value; - - __asm ("fsin%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -cos (double x) -{ - double value; - - __asm ("fcos%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -tan (double x) -{ - double value; - - __asm ("ftan%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -asin (double x) -{ - double value; - - __asm ("fasin%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -acos (double x) -{ - double value; - - __asm ("facos%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -atan (double x) -{ - double value; - - __asm ("fatan%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -atan2 (double y, double x) -{ - double pi, pi_over_2; - - __asm ("fmovecr%.x %#0,%0" /* extended precision pi */ - : "=f" (pi) - : /* no inputs */ ); - __asm ("fscale%.b %#-1,%0" /* no loss of accuracy */ - : "=f" (pi_over_2) - : "0" (pi)); - if (x > 0) - { - if (y > 0) - { - if (x > y) - return atan (y / x); - else - return pi_over_2 - atan (x / y); - } - else - { - if (x > -y) - return atan (y / x); - else - return - pi_over_2 - atan (x / y); - } - } - else - { - if (y > 0) - { - if (-x > y) - return pi + atan (y / x); - else - return pi_over_2 - atan (x / y); - } - else - { - if (-x > -y) - return - pi + atan (y / x); - else if (y < 0) - return - pi_over_2 - atan (x / y); - else - { - double value; - - errno = EDOM; - __asm ("fmove%.d %#0x7fffffffffffffff,%0" /* quiet NaN */ - : "=f" (value) - : /* no inputs */); - return value; - } - } - } -} - -__inline static const double -sinh (double x) -{ - double value; - - __asm ("fsinh%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -cosh (double x) -{ - double value; - - __asm ("fcosh%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -tanh (double x) -{ - double value; - - __asm ("ftanh%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -atanh (double x) -{ - double value; - - __asm ("fatanh%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -exp (double x) -{ - double value; - - __asm ("fetox%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -expm1 (double x) -{ - double value; - - __asm ("fetoxm1%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -log (double x) -{ - double value; - - __asm ("flogn%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -log1p (double x) -{ - double value; - - __asm ("flognp1%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -log10 (double x) -{ - double value; - - __asm ("flog10%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -sqrt (double x) -{ - double value; - - __asm ("fsqrt%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -hypot (const double x, const double y) -{ - return sqrt (x*x + y*y); -} - -__inline static const double -pow (const double x, const double y) -{ - if (x > 0) - return exp (y * log (x)); - else if (x == 0) - { - if (y > 0) - return 0.0; - else - { - double value; - - errno = EDOM; - __asm ("fmove%.d %#0x7fffffffffffffff,%0" /* quiet NaN */ - : "=f" (value) - : /* no inputs */); - return value; - } - } - else - { - double temp; - - __asm ("fintrz%.x %1,%0" - : "=f" (temp) /* integer-valued float */ - : "f" (y)); - if (y == temp) - { - int i = (int) y; - - if ((i & 1) == 0) /* even */ - return exp (y * log (-x)); - else - return - exp (y * log (-x)); - } - else - { - double value; - - errno = EDOM; - __asm ("fmove%.d %#0x7fffffffffffffff,%0" /* quiet NaN */ - : "=f" (value) - : /* no inputs */); - return value; - } - } -} - -__inline static const double -fabs (double x) -{ - double value; - - __asm ("fabs%.x %1,%0" - : "=f" (value) - : "f" (x)); - return value; -} - -__inline static const double -ceil (double x) -{ - int rounding_mode, round_up; - double value; - - __asm volatile ("fmove%.l %!,%0" - : "=dm" (rounding_mode) - : /* no inputs */ ); - round_up = rounding_mode | 0x30; - __asm volatile ("fmove%.l %0,%!" - : /* no outputs */ - : "dmi" (round_up)); - __asm volatile ("fint%.x %1,%0" - : "=f" (value) - : "f" (x)); - __asm volatile ("fmove%.l %0,%!" - : /* no outputs */ - : "dmi" (rounding_mode)); - return value; -} - -__inline static const double -floor (double x) -{ - int rounding_mode, round_down; - double value; - - __asm volatile ("fmove%.l %!,%0" - : "=dm" (rounding_mode) - : /* no inputs */ ); - round_down = (rounding_mode & ~0x10) - | 0x20; - __asm volatile ("fmove%.l %0,%!" - : /* no outputs */ - : "dmi" (round_down)); - __asm volatile ("fint%.x %1,%0" - : "=f" (value) - : "f" (x)); - __asm volatile ("fmove%.l %0,%!" - : /* no outputs */ - : "dmi" (rounding_mode)); - return value; -} - -__inline static const double -rint (double x) -{ - int rounding_mode, round_nearest; - double value; - - __asm volatile ("fmove%.l %!,%0" - : "=dm" (rounding_mode) - : /* no inputs */ ); - round_nearest = rounding_mode & ~0x30; - __asm volatile ("fmove%.l %0,%!" - : /* no outputs */ - : "dmi" (round_nearest)); - __asm volatile ("fint%.x %1,%0" - : "=f" (value) - : "f" (x)); - __asm volatile ("fmove%.l %0,%!" - : /* no outputs */ - : "dmi" (rounding_mode)); - return value; -} - -__inline static const double -fmod (double x, double y) -{ - double value; - - __asm ("fmod%.x %2,%0" - : "=f" (value) - : "0" (x), - "f" (y)); - return value; -} - -__inline static const double -drem (double x, double y) -{ - double value; - - __asm ("frem%.x %2,%0" - : "=f" (value) - : "0" (x), - "f" (y)); - return value; -} - -__inline static const double -scalb (double x, int n) -{ - double value; - - __asm ("fscale%.l %2,%0" - : "=f" (value) - : "0" (x), - "dmi" (n)); - return value; -} - -__inline static double -logb (double x) -{ - double exponent; - - __asm ("fgetexp%.x %1,%0" - : "=f" (exponent) - : "f" (x)); - return exponent; -} - -__inline static const double -ldexp (double x, int n) -{ - double value; - - __asm ("fscale%.l %2,%0" - : "=f" (value) - : "0" (x), - "dmi" (n)); - return value; -} - -__inline static double -frexp (double x, int *exp) -{ - double float_exponent; - int int_exponent; - double mantissa; - - __asm ("fgetexp%.x %1,%0" - : "=f" (float_exponent) /* integer-valued float */ - : "f" (x)); - int_exponent = (int) float_exponent; - __asm ("fgetman%.x %1,%0" - : "=f" (mantissa) /* 1.0 <= mantissa < 2.0 */ - : "f" (x)); - if (mantissa != 0) - { - __asm ("fscale%.b %#-1,%0" - : "=f" (mantissa) /* mantissa /= 2.0 */ - : "0" (mantissa)); - int_exponent += 1; - } - *exp = int_exponent; - return mantissa; -} - -__inline static double -modf (double x, double *ip) -{ - double temp; - - __asm ("fintrz%.x %1,%0" - : "=f" (temp) /* integer-valued float */ - : "f" (x)); - *ip = temp; - return x - temp; -} - diff --git a/gnu/lib/libg++/g++-include/math.h b/gnu/lib/libg++/g++-include/math.h deleted file mode 100644 index db39f3e00b4d..000000000000 --- a/gnu/lib/libg++/g++-include/math.h +++ /dev/null @@ -1,223 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. 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, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: math.h,v 1.2 1993/08/02 17:22:08 mycroft Exp $ -*/ - - -#ifndef _math_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _math_h 1 - -#if defined(hp300) && defined(__HAVE_FPU__) -#define __HAVE_68881__ 1 -#endif - -#if defined(masscomp) -#define __HAVE_68881__ 1 -#endif - -#ifdef __HAVE_68881__ /* MC68881/2 Floating-Point Coprocessor */ -extern "C" { /* fill in what we've left out */ -#include - -double acosh(double); -double asinh(double); -double cbrt(double); -double copysign(double,double); -double erf(double); -double erfc(double); -double finite(double); -double gamma(double); -double hypot(double,double); -double infnan(int); -int isinf(double); -int isnan(double); -double j0(double); -double j1(double); -double jn(int, double); -double lgamma(double); -double y0(double); -double y1(double); -double yn(int, double); - -double aint(double); -double anint(double); -int irint(double); -int nint(double); -} -/* Please add inline asm code for other machines here! */ -#else -extern "C" { - -#include <_G_config.h> - -double acos(double); -double acosh(double); -double asin(double); -double asinh(double); -double atan(double); -double atan2(double, double); -double atanh(double); -double cbrt(double); -double ceil(double); -double copysign(double,double); -double cos(double); -double cosh(double); -double drem(double,double); -double erf(double); -double erfc(double); -double exp(double); -double expm1(double); -double fabs(double); -int finite(double); -double floor(double); -double fmod(double, double); -double frexp(double, int*); -double gamma(double); -double hypot(double,double); -double infnan(int); -#if !defined(sequent) && !defined(DGUX) &&!defined(sony) && !defined(masscomp) && !defined(hpux) -/* see below */ -int isinf(double); -int isnan(double); -#endif -double j0(double); -double j1(double); -double jn(int, double); -double ldexp(double, int); -double lgamma(double); -double log(double); -double log10(double); -double log1p(double); -double logb(double); -double modf(double, double*); -double pow(double, double); -double rint(double); -double scalb _G_ARGS((double, int)); -double sin(double); -double sinh(double); -double sqrt(double); -double tan(double); -double tanh(double); -double y0(double); -double y1(double); -double yn(int, double); - -double aint(double); -double anint(double); -int irint(double); -int nint(double); -} - -#endif - -/* libg++ doesn't use this since it is not available on some systems */ - -/* the following ifdef is just for compiling OOPS */ - -#ifndef DONT_DECLARE_EXCEPTION -struct libm_exception -{ - int type; - char* name; - double arg1, arg2, retval; -}; - -#define DOMAIN 1 -#define SING 2 -#define OVERFLOW 3 -#define UNDERFLOW 4 -#define TLOSS 5 -#define PLOSS 6 - -extern "C" int matherr(libm_exception*); - -#endif - -#include - -/* On some systems, HUGE ought to be MAXFLOAT or IEEE infinity */ - -#ifndef HUGE -#define HUGE DBL_MAX -#endif -#ifndef HUGE_VAL -#define HUGE_VAL DBL_MAX -#endif - - -/* sequents don't supply these. The following should suffice */ -#if defined(sequent) || defined(DGUX) || defined(sony) || defined(masscomp) \ -|| defined(hpux) -#include -static inline int isnan(double x) { return x != x; } -static inline int isinf(double x) { return x > DBL_MAX || x < -DBL_MAX; } -#endif - -/* These seem to be sun & sysV names of these constants */ - -#ifndef M_E -#define M_E 2.7182818284590452354 -#endif -#ifndef M_LOG2E -#define M_LOG2E 1.4426950408889634074 -#endif -#ifndef M_LOG10E -#define M_LOG10E 0.43429448190325182765 -#endif -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 -#endif -#ifndef M_LN10 -#define M_LN10 2.30258509299404568402 -#endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -#ifndef M_PI_2 -#define M_PI_2 1.57079632679489661923 -#endif -#ifndef M_1_PI -#define M_1_PI 0.31830988618379067154 -#endif -#ifndef M_PI_4 -#define M_PI_4 0.78539816339744830962 -#endif -#ifndef M_2_PI -#define M_2_PI 0.63661977236758134308 -#endif -#ifndef M_2_SQRTPI -#define M_2_SQRTPI 1.12837916709551257390 -#endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 -#endif -#ifndef M_SQRT1_2 -#define M_SQRT1_2 0.70710678118654752440 -#endif - -#ifndef PI // as in stroustrup -#define PI M_PI -#endif -#ifndef PI2 -#define PI2 M_PI_2 -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/max.h b/gnu/lib/libg++/g++-include/max.h deleted file mode 100644 index 8c2c8f98ced4..000000000000 --- a/gnu/lib/libg++/g++-include/max.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/gnu/lib/libg++/g++-include/memory.h b/gnu/lib/libg++/g++-include/memory.h deleted file mode 100644 index b54cecb9f478..000000000000 --- a/gnu/lib/libg++/g++-include/memory.h +++ /dev/null @@ -1,43 +0,0 @@ -// $Id: memory.h,v 1.3 1993/08/14 22:07:31 mycroft Exp $ - -#ifndef _memory_h -#define _memory_h 1 - -#include "_G_config.h" -#include - -extern "C" { - -void* memalign _G_ARGS((_G_size_t, _G_size_t)); -void* memccpy _G_ARGS((void*, const void*, int, _G_size_t)); -void* memchr _G_ARGS((const void*, int, _G_size_t)); -int memcmp _G_ARGS((const void*, const void*, _G_size_t)); -void* memcpy _G_ARGS((void*, const void*, _G_size_t)); -void* memmove _G_ARGS((void*, const void*, _G_size_t)); -void* memset _G_ARGS((void*, int, _G_size_t)); -int ffs _G_ARGS((int)); -#if defined(__OSF1__) || defined(__NetBSD__) -int getpagesize _G_ARGS((void)); -#else -_G_size_t getpagesize _G_ARGS((void)); -#endif -void* valloc _G_ARGS((_G_size_t)); - -void bcopy _G_ARGS((const void*, void*, _G_size_t)); -int bcmp _G_ARGS((const void*, const void*, int)); -void bzero _G_ARGS((void*, int)); -} - -#ifdef __GNUG__ -#ifndef alloca -#define alloca(x) __builtin_alloca(x) -#endif -#else -#ifndef IV -extern "C" void* alloca(_G_size_t); -#else -extern "C" void* alloca(unsigned long); -#endif /* IV */ -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/min.h b/gnu/lib/libg++/g++-include/min.h deleted file mode 100644 index 8c2c8f98ced4..000000000000 --- a/gnu/lib/libg++/g++-include/min.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/gnu/lib/libg++/g++-include/minmax.h b/gnu/lib/libg++/g++-include/minmax.h deleted file mode 100644 index 8c2c8f98ced4..000000000000 --- a/gnu/lib/libg++/g++-include/minmax.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/gnu/lib/libg++/g++-include/netdb.h b/gnu/lib/libg++/g++-include/netdb.h deleted file mode 100644 index 4c47550ba2d9..000000000000 --- a/gnu/lib/libg++/g++-include/netdb.h +++ /dev/null @@ -1,6 +0,0 @@ -// $Id: netdb.h,v 1.2 1993/08/02 17:22:11 mycroft Exp $ - -extern "C" -{ -#include_next -} diff --git a/gnu/lib/libg++/g++-include/new.h b/gnu/lib/libg++/g++-include/new.h deleted file mode 100644 index 95d86e021834..000000000000 --- a/gnu/lib/libg++/g++-include/new.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _new_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _new_h 1 - -#include -#include - -#ifndef NO_LIBGXX_MALLOC -#define MALLOC_ALIGN_MASK 7 /* ptrs aligned at 8 byte boundaries */ -#define MALLOC_MIN_OVERHEAD 8 /* 8 bytes of overhead per pointer */ -#endif - -typedef void (*new_handler_t)(); -extern "C" void default_new_handler(); -extern "C" new_handler_t set_new_handler(new_handler_t); - -#ifdef __GNUG__ -#define NEW(where) new { where } -#endif - -// default placement version of operator new -static inline void *operator new(size_t, void *place) { return place; } - -// provide a C++ interface to vector-resize via realloc -static inline void *operator new(size_t size, void *ptr, size_t new_len) -{ - return realloc(ptr, new_len * size); -} - -#endif diff --git a/gnu/lib/libg++/g++-include/open.h b/gnu/lib/libg++/g++-include/open.h deleted file mode 100644 index ffe81a15ac17..000000000000 --- a/gnu/lib/libg++/g++-include/open.h +++ /dev/null @@ -1,39 +0,0 @@ - -#ifndef _open_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _open_h 1 - -#include -#include // needed to determine values of O_RDONLY... - -/* - - translation stuff for opening files. - -*/ - - -enum sys_open_cmd_io_mode // These should be correct for most systems -{ - sio_read = O_RDONLY, - sio_write = O_WRONLY, - sio_readwrite = O_RDWR, - sio_append = O_APPEND -}; - -enum sys_open_cmd_access_mode -{ - sa_create = O_CREAT, - sa_truncate = O_TRUNC, - sa_createonly = O_EXCL | O_CREAT -}; - - -int open_cmd_arg(io_mode i, access_mode a); // decode modes -char* fopen_cmd_arg(io_mode i); -int open_cmd_arg(const char* m); - -#endif diff --git a/gnu/lib/libg++/g++-include/osfcn.h b/gnu/lib/libg++/g++-include/osfcn.h deleted file mode 100644 index 52b3063586f2..000000000000 --- a/gnu/lib/libg++/g++-include/osfcn.h +++ /dev/null @@ -1,4 +0,0 @@ -#include -#include -#include -#include diff --git a/gnu/lib/libg++/g++-include/ostream.h b/gnu/lib/libg++/g++-include/ostream.h deleted file mode 100644 index 3bf30d735d6a..000000000000 --- a/gnu/lib/libg++/g++-include/ostream.h +++ /dev/null @@ -1,256 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -/* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */ - -/* ostream.h now separately includable */ - -#ifndef _ostream_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _ostream_h 1 - -/* uncomment the next line to disable ostream << char */ -//#define NO_OUTPUT_CHAR - - -#include -#include -#include -#include - -class istream; - -class ostream -{ - friend class istream; -protected: - streambuf* bp; - state_value state; // _good/_eof/_fail/_bad - char ownbuf; // true if we own *bp - -public: - ostream(const char* filename, io_mode m, access_mode a); - ostream(const char* filename, const char* m); - ostream(int filedesc, io_mode m); - ostream(FILE* fileptr); - ostream(int sz, char* buf); - ostream(int filedesc, char* buf, int buflen); - ostream(int filedesc); - ostream(streambuf* s); - - ~ostream(); - - ostream& open(const char* filename, io_mode m, access_mode a); - ostream& open(const char* filename, const char* m); - ostream& open(int filedesc, io_mode m); - ostream& open(FILE* fileptr); - ostream& open(const char* filenam, open_mode m); - - ostream& close(); - ostream& flush(); - -// stream status - - int rdstate(); - int eof(); - int fail(); - int bad(); - int good(); - -// other status queries - - int readable(); - int writable(); - int is_open(); - - operator void*(); - int operator !(); - - const char* name(); - - char* bufptr(); - -// error handling - - void error(); - void clear(state_value f = _good); // poorly named - void set(state_value f); // set corresponding bit - void unset(state_value); // clear corresponding bit - ostream& failif(int cond); - -// unformatted IO - - ostream& put(char c); - ostream& put(const char* s); - ostream& put(const char* s, int slen); - -// formatted IO - - ostream& form(const char* fmt, ...); - - ostream& operator << (short n); - ostream& operator << (unsigned short n); - ostream& operator << (int n); - ostream& operator << (unsigned int n); - ostream& operator << (long n); - ostream& operator << (unsigned long n); -#ifdef __GNUG__ - ostream& operator << (long long n); - ostream& operator << (unsigned long long n); -#endif __GNUG__ - ostream& operator << (float n); - ostream& operator << (double n); - ostream& operator << (const char* s); - ostream& operator << (const void* ptr); - -#ifndef NO_OUTPUT_CHAR - ostream& operator << (char c); -#endif - -}; - -extern ostream cout; // stdout -extern ostream cerr; // stderr - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - -inline void ostream::clear(state_value flag) -{ - state = flag; -} - -inline void ostream::set(state_value flag) -{ - state = state_value(int(state) | int(flag)); -} - -inline void ostream::unset(state_value flag) -{ - state = state_value(int(state) & ~int(flag)); -} - -inline int ostream::rdstate() -{ - return int(state); -} - -inline int ostream::good() -{ - return state == _good; -} - -inline int ostream::eof() -{ - return int(state) & int(_eof); -} - -inline int ostream::fail() -{ - return int(state) & int(_fail); -} - -inline int ostream::bad() -{ - return int(state) & int(_bad); -} - -inline ostream::operator void*() -{ - return (state == _good)? this : 0; -} - -inline int ostream::operator !() -{ - return (state != _good); -} - -inline ostream& ostream::failif(int cond) -{ - if (cond) set(_fail); return *this; -} - -inline int ostream::is_open() -{ - return bp->is_open(); -} - -inline int ostream::readable() -{ - return 0; -} - -inline int ostream::writable() -{ - return (bp != 0) && (state == _good); -} - - -inline char* ostream::bufptr() -{ - return bp->base; -} - -inline ostream& ostream::flush() -{ - bp->overflow(); return *this; -} - -inline ostream& ostream::close() -{ - bp->overflow(); bp->close(); return *this; -} - -inline ostream& ostream::put(char ch) -{ - return failif((state != _good) || bp->sputc((int)ch &0xff) == EOF); -} - -#ifndef NO_OUTPUT_CHAR -inline ostream& ostream::operator << (char ch) -{ - return failif((state != _good) || bp->sputc((int)ch &0xff) == EOF); -} -#endif - -inline ostream& ostream::put(const char* s) -{ - return failif((state != _good) || bp->sputs(s) == EOF); -} - -inline ostream& ostream::put(const char* s, int len) -{ - return failif((state != _good) || bp->sputsn(s, len) == EOF); -} - -inline ostream& ostream::operator << (const char* s) -{ - return failif((state != _good) || bp->sputs(s) == EOF); -} - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/pwd.h b/gnu/lib/libg++/g++-include/pwd.h deleted file mode 100644 index f39267f2bf18..000000000000 --- a/gnu/lib/libg++/g++-include/pwd.h +++ /dev/null @@ -1,38 +0,0 @@ -// $Id: pwd.h,v 1.2 1993/08/02 17:22:12 mycroft Exp $ - -#ifndef _pwd_h - -// the Interviews-based standard kludge again - -extern "C" { - -#ifdef __pwd_h_recursive -#include_next -#else -#define getpwent c_proto_getpwent -#define getpwuid c_proto_getpwuid -#define getpwnam c_proto_getpwnam -#define setpwent c_proto_setpwent -#define endpwent c_proto_endpwent - -#define __pwd_h_recursive -#include_next - -#define _pwd_h 1 - -#undef getpwent -#undef getpwuid -#undef getpwnam -#undef setpwent -#undef endpwent - -extern struct passwd* getpwent(); -extern struct passwd* getpwuid(int); -extern struct passwd* getpwnam(const char*); -extern int setpwent(); -extern int endpwent(); - -#endif -} - -#endif diff --git a/gnu/lib/libg++/g++-include/regex.h b/gnu/lib/libg++/g++-include/regex.h deleted file mode 100644 index e0252cb72d36..000000000000 --- a/gnu/lib/libg++/g++-include/regex.h +++ /dev/null @@ -1,280 +0,0 @@ -/* Definitions for data structures callers pass the regex library. - Copyright (C) 1985 Free Software Foundation, Inc. - - NO WARRANTY - - BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY -NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT -WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, -RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS 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. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. -STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY -WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE -LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR -OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR -DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR -A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS -PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. - - GENERAL PUBLIC LICENSE TO COPY - - 1. You may copy and distribute verbatim copies of this source file -as you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy a valid copyright notice "Copyright -(C) 1985 Free Software Foundation, Inc."; and include following the -copyright notice a verbatim copy of the above disclaimer of warranty -and of this License. You may charge a distribution fee for the -physical act of transferring a copy. - - 2. You may modify your copy or copies of this source file or -any portion of it, and copy and distribute such modifications under -the terms of Paragraph 1 above, provided that you also do the following: - - a) cause the modified files to carry prominent notices stating - that you changed the files and the date of any change; and - - b) cause the whole of any work that you distribute or publish, - that in whole or in part contains or is a derivative of this - program or any part thereof, to be licensed at no charge to all - third parties on terms identical to those contained in this - License Agreement (except that you may choose to grant more extensive - warranty protection to some or all third parties, at your option). - - c) You may charge a distribution fee for the physical act of - transferring a copy, and you may at your option offer warranty - protection in exchange for a fee. - -Mere aggregation of another unrelated program with this program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other program under the scope of these terms. - - 3. You may copy and distribute this program (or a portion or derivative -of it, under Paragraph 2) in object code or executable form under the terms -of Paragraphs 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 - Paragraphs 1 and 2 above; or, - - b) accompany it with a written offer, valid for at least three - years, to give any third party free (except for a nominal - shipping charge) a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of - Paragraphs 1 and 2 above; or, - - c) accompany it with the information you received as to where the - corresponding source code may be obtained. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form alone.) - -For an executable file, complete source code means all the source code for -all modules it contains; but, as a special exception, it need not include -source code for modules which are standard libraries that accompany the -operating system on which the executable file runs. - - 4. You may not copy, sublicense, distribute or transfer this program -except as expressly provided under this License Agreement. Any attempt -otherwise to copy, sublicense, distribute or transfer this program is void and -your rights to use the program under this License agreement shall be -automatically terminated. However, parties who have received computer -software programs from you with this License Agreement will not have -their licenses terminated so long as such parties remain in full compliance. - - 5. If you wish to incorporate parts of this program into other free -programs whose distribution conditions are different, write to the Free -Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet -worked out a simple rule that can be stated here, but we will often permit -this. We 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. - - -In other words, you are welcome to use, share and improve this program. -You are forbidden to forbid anyone else to use, share and improve -what you give them. Help stamp out software-hoarding! */ - -#if defined(SHORT_NAMES) || defined(VMS) -#define re_compile_pattern recmppat -#define re_pattern_buffer repatbuf -#define re_registers reregs -#endif - -/* 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 - -/* These bits are used in the obscure_syntax variable to choose among - alternative regexp syntaxes. */ - -/* 1 means plain parentheses serve as grouping, and backslash - parentheses are needed for literal searching. - 0 means backslash-parentheses are grouping, and plain parentheses - are for literal searching. */ -#define RE_NO_BK_PARENS 1 - -/* 1 means plain | serves as the "or"-operator, and \| is a literal. - 0 means \| serves as the "or"-operator, and | is a literal. */ -#define RE_NO_BK_VBAR 2 - -/* 0 means plain + or ? serves as an operator, and \+, \? are literals. - 1 means \+, \? are operators and plain +, ? are literals. */ -#define RE_BK_PLUS_QM 4 - -/* 1 means | binds tighter than ^ or $. - 0 means the contrary. */ -#define RE_TIGHT_VBAR 8 - -/* 1 means treat \n as an _OR operator - 0 means treat it as a normal character */ -#define RE_NEWLINE_OR 16 - -/* 0 means that a special characters (such as *, ^, and $) always have - their special meaning regardless of the surrounding context. - 1 means that 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 | */ -#define RE_CONTEXT_INDEP_OPS 32 - -/* Now define combinations of bits for the standard possibilities. */ -#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS) -#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR) -#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR) -#define RE_SYNTAX_EMACS 0 - -/* This data structure is used to represent a compiled pattern. */ - -struct re_pattern_buffer - { - char *buffer; /* Space holding the compiled pattern commands. */ - int allocated; /* Size of space that buffer points to */ - int 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 quickly 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. */ - }; - -/* 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. - - start[i] and end[i] record the string matched by \( ... \) grouping i, - for i from 1 to RE_NREGS - 1. - start[0] and end[0] record the entire string matched. */ - -struct re_registers - { - int start[RE_NREGS]; - int end[RE_NREGS]; - }; - -/* These are the command codes that appear in compiled regular expressions, one per byte. - Some command codes are followed by argument bytes. - A command code can specify any interpretation whatever for its arguments. - Zero-bytes may appear in the compiled regular expression. */ - -enum regexpcode - { - unused, - exactn, /* followed by one byte giving n, and then by n literal bytes */ - begline, /* fails unless at beginning of line */ - endline, /* fails unless at end of line */ - jump, /* followed by two bytes giving relative address to jump to */ - on_failure_jump, /* followed by two bytes giving relative address of place - to resume at in case of failure. */ - finalize_jump, /* Throw away latest failure point and then jump to address. */ - maybe_finalize_jump, /* Like jump but finalize if safe to do so. - This is used to jump back to the beginning - of a repeat. If the command that follows - this jump is clearly incompatible with the - one at the beginning of the repeat, such that - we can be sure that there is no use backtracking - out of repetitions already completed, - then we finalize. */ - dummy_failure_jump, /* jump, and push a dummy failure point. - This failure point will be thrown away - if an attempt is made to use it for a failure. - A + construct makes this before the first repeat. */ - anychar, /* matches any one character */ - charset, /* matches any one char belonging to specified set. - First following byte is # bitmap bytes. - Then come bytes for a bit-map saying which chars are in. - Bits in each byte are ordered low-bit-first. - A character is in the set if its bit is 1. - A character too large to have a bit in the map - is automatically not in the set */ - charset_not, /* similar but match any character that is NOT one of those specified */ - start_memory, /* starts remembering the text that is matched - and stores it in a memory register. - followed by one byte containing the register number. - Register numbers must be in the range 0 through NREGS. */ - stop_memory, /* stops remembering the text that is matched - and stores it in a memory register. - followed by one byte containing the register number. - Register numbers must be in the range 0 through NREGS. */ - duplicate, /* match a duplicate of something remembered. - Followed by one byte containing the index of the memory register. */ - before_dot, /* Succeeds if before dot */ - at_dot, /* Succeeds if at dot */ - after_dot, /* Succeeds if after dot */ - begbuf, /* Succeeds if at beginning of buffer */ - endbuf, /* Succeeds if at end of buffer */ - wordchar, /* Matches any word-constituent character */ - notwordchar, /* Matches any char that is not a word-constituent */ - wordbeg, /* Succeeds if at word beginning */ - wordend, /* Succeeds if at word end */ - wordbound, /* Succeeds if at a word boundary */ - notwordbound, /* Succeeds if not at a word boundary */ - syntaxspec, /* Matches any character whose syntax is specified. - followed by a byte which contains a syntax code, Sword or such like */ - notsyntaxspec /* Matches any character whose syntax differs from the specified. */ - }; - - -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*, unsigned char*, int, - unsigned char*, int, int, struct re_registers*, int); - -/* 4.2 bsd compatibility (yuck) */ -extern char *re_comp (char*); -extern int re_exec (char*); - -#ifdef SYNTAX_TABLE -extern char *re_syntax_table; -#endif - diff --git a/gnu/lib/libg++/g++-include/setjmp.h b/gnu/lib/libg++/g++-include/setjmp.h deleted file mode 100644 index 12bb1daac614..000000000000 --- a/gnu/lib/libg++/g++-include/setjmp.h +++ /dev/null @@ -1,31 +0,0 @@ -// $Id: setjmp.h,v 1.2 1993/08/02 17:22:13 mycroft Exp $ - -#ifndef _setjmp_h - -extern "C" { - -#ifdef __setjmp_h_recursive -#include_next -#else -#define __setjmp_h_recursive -#define setjmp C_header_setjmp -#define longjmp C_header_longjmp - -#ifdef VMS -#include "gnu_cc_include:[000000]setjmp.h" -#else -#include_next -#endif - -#undef setjmp -#undef longjmp - -#define _setjmp_h 1 - -extern int setjmp(jmp_buf); -extern void longjmp(jmp_buf, int); - -#endif -} - -#endif diff --git a/gnu/lib/libg++/g++-include/signal.h b/gnu/lib/libg++/g++-include/signal.h deleted file mode 100644 index 6ba7b5a0171d..000000000000 --- a/gnu/lib/libg++/g++-include/signal.h +++ /dev/null @@ -1,82 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. 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, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: signal.h,v 1.3 1993/08/14 22:07:32 mycroft Exp $ -*/ - -#ifndef _signal_h - -#include <_G_config.h> - -extern "C" { - -#ifdef __signal_h_recursive -#include_next -#else - -#define __signal_h_recursive - -#define signal __hide_signal -#define psignal __hide_psignal -#include_next -#undef signal -#undef psignal - -#define _signal_h 1 - -// The Interviews folks call this SignalHandler. Might as well conform. -typedef _G_signal_return_type (*SignalHandler) (...); -typedef int (*SSignalHandler) (...); - -extern SignalHandler signal _G_ARGS((int sig, SignalHandler action)); -//extern SignalHandler sigset _G_ARGS((int sig, SignalHandler action)); -extern SSignalHandler ssignal _G_ARGS((int sig, SSignalHandler action)); -extern int gsignal _G_ARGS((int sig)); -extern int kill _G_ARGS((_G_pid_t pid, int sig)); -#ifndef __NetBSD__ -extern int killpg _G_ARGS((short int, int)); -#else -extern int killpg _G_ARGS((_G_pid_t, int)); -#endif -extern int siginterrupt _G_ARGS((int, int)); -extern void psignal _G_ARGS((unsigned, const char*)); - -#ifndef hpux // Interviews folks claim that hpux doesn't like these -extern int sigsetmask _G_ARGS((int mask)); -extern int sigblock _G_ARGS((int mask)); -extern int sigpause _G_ARGS((int mask)); -extern int sigvec _G_ARGS((int, struct sigvec*, struct sigvec*)); -#endif - -// The Interviews version also has these ... - -#define SignalBad ((SignalHandler)-1) -#define SignalDefault ((SignalHandler)0) -#define SignalIgnore ((SignalHandler)1) - -#undef BADSIG -#undef SIG_DFL -#undef SIG_IGN -#define BAD_SIG SignalBad -#define SIG_DFL SignalDefault -#define SIG_IGN SignalIgnore - -#endif -} - -#endif - diff --git a/gnu/lib/libg++/g++-include/std.h b/gnu/lib/libg++/g++-include/std.h deleted file mode 100644 index 52b3063586f2..000000000000 --- a/gnu/lib/libg++/g++-include/std.h +++ /dev/null @@ -1,4 +0,0 @@ -#include -#include -#include -#include diff --git a/gnu/lib/libg++/g++-include/stdarg.h b/gnu/lib/libg++/g++-include/stdarg.h deleted file mode 100644 index 98c42e9f520d..000000000000 --- a/gnu/lib/libg++/g++-include/stdarg.h +++ /dev/null @@ -1,5 +0,0 @@ -// $Id: stdarg.h,v 1.2 1993/08/02 17:22:15 mycroft Exp $ - -extern "C" { -#include_next -} diff --git a/gnu/lib/libg++/g++-include/stddef.h b/gnu/lib/libg++/g++-include/stddef.h deleted file mode 100644 index 9a4dc6b357ce..000000000000 --- a/gnu/lib/libg++/g++-include/stddef.h +++ /dev/null @@ -1,14 +0,0 @@ -// $Id: stddef.h,v 1.2 1993/08/02 17:22:16 mycroft Exp $ - -#ifndef __libgxx_stddef_h - -extern "C" { -#ifdef __stddef_h_recursive -#include_next -#else -#include_next - -#define __libgxx_stddef_h 1 -#endif -} -#endif diff --git a/gnu/lib/libg++/g++-include/stdio.h b/gnu/lib/libg++/g++-include/stdio.h deleted file mode 100644 index 05bb2e2e29ef..000000000000 --- a/gnu/lib/libg++/g++-include/stdio.h +++ /dev/null @@ -1,182 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. 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, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: stdio.h,v 1.3 1993/08/14 22:07:32 mycroft Exp $ -*/ - -#ifndef _stdio_h -#ifdef __GNUG__ -#pragma interface -#endif - -#ifdef __stdio_h_recursive -#include_next -#else -#define __stdio_h_recursive - -// Note: The #define _stdio_h is at the end of this file, -// in case #include_next finds an installed version of this -// same file -- we want it to continue until it finds the C version. - -#include <_G_config.h> - -extern "C" { - -#undef NULL - -#define fdopen __hide_fdopen -#define fopen __hide_fopen -#define fprintf __hide_fprintf -#define fputs __hide_fputs -#define fread __hide_fread -#define freopen __hide_freopen -#define fscanf __hide_fscanf -#define ftell __hide_ftell -#define fwrite __hide_fwrite -#define new __hide_new /* In case 'new' is used as a parameter name. */ -#define perror __hide_perror -#define popen __hide_popen -#define printf __hide_printf -#define puts __hide_puts -#define putw __hide_putw -#define rewind __hide_rewind -#define tempnam __hide_tempnam -#define scanf __hide_scanf -#define setbuf __hide_setbuf -#define setbuffer __hide_setbuffer -#define setlinebuf __hide_setlinebuf -#define setvbuf __hide_setvbuf -#define sprintf __hide_sprintf -#define sscanf __hide_sscanf -#define tempnam __hide_tempnam -#define vfprintf __hide_vfprintf -#define vprintf __hide_vprintf -#define vsprintf __hide_vsprintf -#define _flsbuf __hide__flsbuf - -#include_next - -#undef fdopen -#undef fopen -#undef fprintf -#undef fputs -#undef fread -#undef freopen -#undef fscanf -#undef ftell -#undef fwrite -#undef new -#undef perror -#undef popen -#undef printf -#undef puts -#undef putw -/* SCO defines remove to call unlink; that's very dangerous for us. */ -#undef remove -#undef rewind -#undef tempnam -#undef scanf -#undef setbuf -#undef setbuffer -#undef setlinebuf -#undef setvbuf -#undef sprintf -#undef sscanf -#undef tempnam -#undef vprintf -#undef vfprintf -#undef vsprintf -#undef _flsbuf - -#ifndef NULL -#define NULL _G_NULL -#endif - -#ifndef size_t -#define size_t _G_size_t -#endif -} - -extern "C" { - -int fclose(FILE*); -FILE* fdopen(int, const char*); -int fflush(FILE*); -int fgetc(FILE*); -#ifndef __NetBSD__ -char* fgets _G_ARGS((char*, int, FILE *)); -#else -char* fgets _G_ARGS((char*, _G_size_t, FILE *)); -#endif -FILE* fopen(const char*, const char*); -int fprintf(FILE*, const char* ...); -int fputc(int, FILE*); -int fputs(const char*, FILE*); -size_t fread(void*, size_t, size_t, FILE*); -#ifdef VMS -FILE* freopen(const char*, const char*, FILE* ...); -#else -FILE* freopen(const char*, const char*, FILE*); -#endif -int fscanf(FILE*, const char* ...); -int fseek(FILE*, long, int); -long ftell(FILE *); -size_t fwrite(const void*, size_t, size_t, FILE*); -char* gets(char*); -int getw(FILE*); -int pclose(FILE*); -void perror(const char*); -FILE* popen(const char*, const char*); -int printf(const char* ...); -int puts(const char*); -int putw(int, FILE*); -int rewind(FILE*); -int scanf(const char* ...); -void setbuf(FILE*, char*); -void setbuffer(FILE*, char*, int); -int setlinebuf(FILE*); -int setvbuf(FILE*, char*, int, size_t); -int sscanf(char*, const char* ...); -FILE* tmpfile(); -int ungetc(int, FILE*); -int vfprintf _G_ARGS((FILE*, const char*, _G_va_list)); -int vprintf _G_ARGS((const char*, _G_va_list)); -_G_sprintf_return_type sprintf _G_ARGS((char*, const char* ...)); -_G_sprintf_return_type vsprintf _G_ARGS((char*, const char*, _G_va_list)); - -extern int _filbuf _G_ARGS((FILE*)); -extern int _flsbuf _G_ARGS((unsigned, FILE*)); - -} - -#ifndef L_ctermid -#define L_ctermid 9 -#endif -#ifndef L_cuserid -#define L_cuserid 9 -#endif -#ifndef P_tmpdir -#define P_tmpdir "/tmp/" -#endif -#ifndef L_tmpnam -#define L_tmpnam (sizeof(P_tmpdir) + 15) -#endif - -#define _stdio_h 1 - -#endif -#endif // _stdio_h diff --git a/gnu/lib/libg++/g++-include/stdlib.h b/gnu/lib/libg++/g++-include/stdlib.h deleted file mode 100644 index 3b7e14efcb0b..000000000000 --- a/gnu/lib/libg++/g++-include/stdlib.h +++ /dev/null @@ -1,81 +0,0 @@ -// $Id: stdlib.h,v 1.2 1993/08/02 17:22:17 mycroft Exp $ - -#ifndef _stdlib_h -#define _stdlib_h 1 - -#include <_G_config.h> -#include - -extern "C" { - -int abs(int); - -#ifdef __GNUG__ -void volatile abort(void); -#else -void abort(void); -#endif - -double atof(const char*); -int atoi(const char*); -long atol(const char*); - -int atexit(auto void (*p) (void)); -void* bsearch (const void *, const void *, size_t, - size_t, auto int (*ptf)(const void*, const void*)); -void* calloc(size_t, size_t); -void cfree(void*); - -#ifdef __GNUG__ -void volatile exit(int); -#else -void exit(int); -#endif - -char* fcvt(double, int, int*, int*); -void free(void*); -char* getenv(const char*); -int getopt _G_ARGS((int, char * const *, const char*)); -int getpw(int, char*); -char* gcvt(double, int, char*); -char* ecvt(double, int, int*, int*); -extern char** environ; - -long labs(long); -void* malloc(size_t); -size_t malloc_usable_size(void*); -int putenv(const char*); -extern char* optarg; -extern int opterr; -extern int optind; -void qsort(void*, size_t, size_t, auto int (*ptf)(void*,void*)); -int rand(void); -void* realloc(void*, size_t); -int setkey(const char*); -int srand(unsigned int); -double strtod(const char*, char**); -long strtol(const char*, char**, int); -unsigned long strtoul(const char*, char **, int); -int system(const char*); - -long random(void); -void srandom(int); -char* setstate(char*); -char* initstate(unsigned, char*, int); - -double drand48(void); -void lcong48(short*); -long jrand48(short*); -long lrand48(void); -long mrand48(void); -long nrand48(short*); -short* seed48(short*); -void srand48(long); - -char* ctermid(char*); -char* cuserid(char*); -char* tempnam(const char*, const char*); -char* tmpnam(char*); - -} -#endif diff --git a/gnu/lib/libg++/g++-include/strclass.h b/gnu/lib/libg++/g++-include/strclass.h deleted file mode 100644 index e1799f1ac4e8..000000000000 --- a/gnu/lib/libg++/g++-include/strclass.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _strclass_h -#ifdef __GNUG__ -#pragma once -#endif -#define _strclass_h -#include -typedef class String string; -#endif diff --git a/gnu/lib/libg++/g++-include/stream.h b/gnu/lib/libg++/g++-include/stream.h deleted file mode 100644 index f55e978734bc..000000000000 --- a/gnu/lib/libg++/g++-include/stream.h +++ /dev/null @@ -1,13 +0,0 @@ -/* ostream.h and istream.h now separately includable */ - -#ifndef _stream_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _stream_h 1 - -#include -#include - -#endif diff --git a/gnu/lib/libg++/g++-include/streambuf.h b/gnu/lib/libg++/g++-include/streambuf.h deleted file mode 100644 index 61a3de5e9c7f..000000000000 --- a/gnu/lib/libg++/g++-include/streambuf.h +++ /dev/null @@ -1,165 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef _streambuf_h -#ifdef __GNUG__ -#pragma once -#pragma interface -#endif -#define _streambuf_h 1 - -/* streambufs. - basic streambufs and filebufs are as in Stroustrup, ch 8, - but the base class contains virtual extensions that allow - most capabilities of libg++ Files to be used as streambufs - via `Filebufs'. -*/ - -#include -#include -#include - -// see below for NO_LINE_BUFFER_STREAMBUFS - -#ifndef BUFSIZE -#ifdef BUFSIZ -#define BUFSIZE BUFSIZ -#else -#define BUFSIZE 1024 -#endif -#endif - -enum open_mode // filebuf open modes -{ - input=0, - output=1, - append=2 -}; - -class streambuf -{ -public: - char* base; // start of buffer - char* pptr; // put-pointer (and gptr fence) - char* gptr; // get-pointer - char* eptr; // last valid addr in buffer - - char alloc; // true if we own freestore alloced buffer - - streambuf(); - streambuf(char* buf, int buflen); - - virtual ~streambuf(); - - int doallocate(); - int allocate(); - - - int must_overflow(int ch); // true if should call overflow - - virtual int overflow(int c = EOF); // flush -- return EOF if fail - virtual int underflow(); // fill -- return EOF if fail - - int sgetc(); // get one char (as int) or EOF - int snextc(); // get and advance - void stossc(); // advance only - - int sputbackc(char); // unget - - int sputc(int c = EOF); // write one char - - virtual streambuf* setbuf(char* buf, int buflen, int preloaded_count = 0); - // (not virtual in AT&T) - -// the following aren't in AT&T version: - - int sputs(const char* s); // write null-terminated str - int sputsn(const char* s, int len); // write len bytes - - virtual const char* name(); - - - virtual streambuf* open(const char* name, open_mode m); - virtual streambuf* open(const char* filename, io_mode m, access_mode a); - virtual streambuf* open(const char* filename, const char* m); - virtual streambuf* open(int filedesc, io_mode m); - virtual streambuf* open(FILE* fileptr); - - virtual int is_open(); - virtual int close(); - - virtual void error(); -}; - - -#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) - - -inline int streambuf::must_overflow(int ch) -{ -#ifndef NO_LINE_BUFFER_STREAMBUF - return pptr >= eptr || ch == '\n'; -#else - return pptr >= eptr; -#endif -} - - -inline int streambuf::allocate() -{ - return (base == 0)? doallocate() : 0; -} - -inline int streambuf::sgetc() -{ - return (gptr >= pptr)? underflow() : int((unsigned char)(*gptr)); -} - - -inline int streambuf::snextc() -{ - ++gptr; - return (gptr >= pptr)? underflow() : int((unsigned char)(*gptr)); -} - - -inline void streambuf::stossc() -{ - if (gptr >= pptr) underflow(); else gptr++; -} - - -inline int streambuf::sputbackc(char ch) -{ - return (gptr > base)? int((unsigned char)(*--gptr = ch)) : EOF; -} - -inline int streambuf::sputc(int ch) -{ - return must_overflow(ch)? overflow(ch) : - int((unsigned char)(*pptr++ = char(ch))); -} - -#endif - -#endif diff --git a/gnu/lib/libg++/g++-include/string.h b/gnu/lib/libg++/g++-include/string.h deleted file mode 100644 index e03adb7d3c08..000000000000 --- a/gnu/lib/libg++/g++-include/string.h +++ /dev/null @@ -1,47 +0,0 @@ -// $Id: string.h,v 1.3 1993/09/27 18:25:49 jtc Exp $ - -#ifndef _string_h -#define _string_h 1 - -#include <_G_config.h> - -#ifndef size_t -#define size_t _G_size_t -#endif - -#ifndef NULL -#define NULL _G_NULL -#endif - -extern "C" { - -char* strcat(char*, const char*); -char* strchr(const char*, int); -int strcmp(const char*, const char*); -int strcoll(const char*, const char*); -char* strcpy(char*, const char*); -size_t strcspn(const char*, const char*); -char* strdup(const char*); -char* strerror(int); -// NOTE: If you get a error message from g++ that this declaration -// conflicts with a declaration of strlen(), that usually -// indicates that __SIZE_TYPE__ is incorrectly defined by gcc. -// Fix or add SIZE_TYPE in the appropriate file in gcc/config/*.h. -size_t strlen(const char*); -char* strncat(char*, const char*, size_t); -int strncmp(const char*, const char*, size_t); -char* strncpy(char*, const char*, size_t); -char* strpbrk(const char*, const char*); -char* strrchr(const char*, int); -size_t strspn(const char*, const char*); -char* strstr(const char*, const char *); -char* strtok(char*, const char*); -size_t strxfrm(char*, const char*, size_t); - -char* index(const char*, int); -char* rindex(const char*, int); -} - -#include - -#endif diff --git a/gnu/lib/libg++/g++-include/strings.h b/gnu/lib/libg++/g++-include/strings.h deleted file mode 100644 index ccc06eb163f1..000000000000 --- a/gnu/lib/libg++/g++-include/strings.h +++ /dev/null @@ -1,3 +0,0 @@ -// $Id: strings.h,v 1.2 1993/08/02 17:22:19 mycroft Exp $ - -#include diff --git a/gnu/lib/libg++/g++-include/swap.h b/gnu/lib/libg++/g++-include/swap.h deleted file mode 100644 index 005cb0e46482..000000000000 --- a/gnu/lib/libg++/g++-include/swap.h +++ /dev/null @@ -1,3 +0,0 @@ -/* From Ron Guillmette; apparently needed for Hansen's code */ - -#define swap(a,b) ({ typeof(a) temp = (a); (a) = (b); (b) = temp; }) diff --git a/gnu/lib/libg++/g++-include/sys/signal.h b/gnu/lib/libg++/g++-include/sys/signal.h deleted file mode 100644 index 6ff8bad7ec72..000000000000 --- a/gnu/lib/libg++/g++-include/sys/signal.h +++ /dev/null @@ -1,39 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. 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, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: signal.h,v 1.2 1993/08/02 17:21:44 mycroft Exp $ -*/ - -/* Partly for systems that think signal.h is is sys/ */ -/* But note that some systems that use sys/signal.h to define signal.h. */ - -#ifndef __libgxx_sys_signal_h -#if defined(__sys_signal_h_recursive) || defined(__signal_h_recursive) -#include_next -#else -#define __sys_signal_h_recursive - -extern "C" { -#define signal __hide_signal -#include_next -#undef signal -} - -#define __libgxx_sys_signal_h 1 -#endif -#endif - diff --git a/gnu/lib/libg++/g++-include/sys/socket.h b/gnu/lib/libg++/g++-include/sys/socket.h deleted file mode 100644 index 78b5e872296b..000000000000 --- a/gnu/lib/libg++/g++-include/sys/socket.h +++ /dev/null @@ -1,65 +0,0 @@ -// $Id: socket.h,v 1.3 1993/08/15 16:47:00 mycroft Exp $ - -#ifndef __libgxx_sys_socket_h - -#include <_G_config.h> - -extern "C" -{ -#ifdef __sys_socket_h_recursive -#include_next -#else -#define __sys_socket_h_recursive -#include - -#ifdef VMS -#include "GNU_CC_INCLUDE:[sys]socket.h" -#else -#include_next -#endif - -#define __libgxx_sys_socket_h 1 - -// void* in select, since different systems use int* or fd_set* -int accept _G_ARGS((int, struct sockaddr*, int*)); -#ifndef __NetBSD__ -int select _G_ARGS((int, void*, void*, void*, struct timeval*)); - -int bind _G_ARGS((int, const void*, int)); -int connect _G_ARGS((int, struct sockaddr*, int)); -#else -int select _G_ARGS((int, struct fd_set*, struct fd_set*, struct fd_set*, struct timeval*)); - -int bind _G_ARGS((int, const struct sockaddr *, int)); -int connect _G_ARGS((int, const struct sockaddr*, int)); -#endif -int getsockname _G_ARGS((int, struct sockaddr*, int*)); -int getpeername _G_ARGS((int, struct sockaddr*, int*)); -int getsockopt(int, int, int, void*, int*); -int listen(int, int); -#ifndef hpux -int rcmd _G_ARGS((char**, int, const char*, const char*, const char*, int*)); -#endif -int recv(int, void*, int, int); -int recvmsg(int, struct msghdr*, int); -int rexec(char**, int, const char*, const char*, const char*, int*); -int rresvport(int*); -int send _G_ARGS((int, const void*, int, int)); -int sendmsg _G_ARGS((int, const struct msghdr*, int)); -int shutdown(int, int); -int socket(int, int, int); -int socketpair(int, int, int, int sv[2]); - -#ifndef __NetBSD__ -int recvfrom _G_ARGS((int, void*, int, int, void*, int *)); -int sendto _G_ARGS((int, const void*, int, int, void*, int)); -int setsockopt _G_ARGS((int, int, int, const char*, int)); -#else -int recvfrom _G_ARGS((int, void*, int, int, struct sockaddr*, int *)); -int sendto _G_ARGS((int, const void*, int, int, const struct sockaddr*, int)); -int setsockopt _G_ARGS((int, int, int, const void*, int)); -#endif -#endif -} - -#endif diff --git a/gnu/lib/libg++/g++-include/sys/stat.h b/gnu/lib/libg++/g++-include/sys/stat.h deleted file mode 100644 index 1c5ef3c9fb90..000000000000 --- a/gnu/lib/libg++/g++-include/sys/stat.h +++ /dev/null @@ -1,49 +0,0 @@ -// $Id: stat.h,v 1.2 1993/08/02 17:21:47 mycroft Exp $ - -#ifndef __libgxx_sys_stat_h - -extern "C" -{ -#ifdef __sys_stat_h_recursive -#include_next -#else -#define __sys_stat_h_recursive -#include <_G_config.h> -#define chmod __hide_chmod -#ifdef VMS -#include "GNU_CC_INCLUDE:[sys]stat.h" -#else -#include_next -#endif -#undef chmod - -#define __libgxx_sys_stat_h 1 - -extern int chmod _G_ARGS((const char*, _G_mode_t)); -extern int stat _G_ARGS((const char *path, struct stat *buf)); -extern int lstat _G_ARGS((const char *path, struct stat *buf)); -extern int fstat _G_ARGS((int fd, struct stat *buf)); - -#ifndef S_ISDIR -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) -#endif -#ifndef S_ISBLK -#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) -#endif -#ifndef S_ISCHR -#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) -#endif -#ifndef S_ISFIFO -#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO) -#endif -#ifndef S_ISREG -#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) -#endif -#if !defined(S_ISLNK) && defined(S_IFLNK) -#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) -#endif - -#endif -} - -#endif diff --git a/gnu/lib/libg++/g++-include/sys/time.h b/gnu/lib/libg++/g++-include/sys/time.h deleted file mode 100644 index b08404702a34..000000000000 --- a/gnu/lib/libg++/g++-include/sys/time.h +++ /dev/null @@ -1,43 +0,0 @@ -// $Id: time.h,v 1.2 1993/08/02 17:21:48 mycroft Exp $ - -#ifndef __libgxx_sys_time_h - -extern "C" -{ -#ifdef __sys_time_h_recursive -#include_next -#else -#define __sys_time_h_recursive - -// Some system (e.g Ultrix) define these in sys/time.h. - -#ifndef __time_h_recursive -#define time __hide_time -#define clock __hide_clock -#define gmtime __hide_gmtime -#define localtime __hide_localtime -#define ctime __hide_ctime -#define asctime __hide_asctime -#define strftime __hide_strftime -#endif - -#ifdef VMS -#include "GNU_CC_INCLUDE:[sys]resourcetime.h" -#else -#include_next -#endif -#undef __sys_time_h_recursive - -#define __libgxx_sys_time_h 1 - -#undef clock -#undef ctime -#undef gmtime -#undef localtime -#undef time -#undef asctime -#undef strftime -#endif -} - -#endif diff --git a/gnu/lib/libg++/g++-include/sys/times.h b/gnu/lib/libg++/g++-include/sys/times.h deleted file mode 100644 index 047a984c564a..000000000000 --- a/gnu/lib/libg++/g++-include/sys/times.h +++ /dev/null @@ -1,22 +0,0 @@ -// $Id: times.h,v 1.2 1993/08/02 17:21:50 mycroft Exp $ - -#ifndef __libgxx_sys_times_h - -extern "C" -{ -#ifdef __sys_times_h_recursive -#include_next -#else -#define __sys_times_h_recursive -#include_next -#define __libgxx_sys_times_h 1 - -#include <_G_config.h> - -extern _G_clock_t times _G_ARGS((struct tms*)); - -#endif -} - - -#endif diff --git a/gnu/lib/libg++/g++-include/sys/types.h b/gnu/lib/libg++/g++-include/sys/types.h deleted file mode 100644 index 4c87cdb5641a..000000000000 --- a/gnu/lib/libg++/g++-include/sys/types.h +++ /dev/null @@ -1,27 +0,0 @@ -// $Id: types.h,v 1.2 1993/08/02 17:21:51 mycroft Exp $ - -#ifndef __libgxx_sys_types_h - -extern "C" -{ -#ifdef __sys_types_h_recursive -#include_next -#else - -#define __sys_types_h_recursive -#include - -#ifdef VMS -#include "GNU_CC_INCLUDE:[sys]types.h" -#else -#include_next -#endif - -#define __libgxx_sys_types_h 1 - -#endif -} - - -#endif - diff --git a/gnu/lib/libg++/g++-include/sys/wait.h b/gnu/lib/libg++/g++-include/sys/wait.h deleted file mode 100644 index babdc3ca413e..000000000000 --- a/gnu/lib/libg++/g++-include/sys/wait.h +++ /dev/null @@ -1,44 +0,0 @@ -// $Id: wait.h,v 1.3 1993/08/15 16:47:01 mycroft Exp $ - -#ifndef __libgxx_sys_wait_h - -#include <_G_config.h> - -extern "C" { -#ifdef __sys_wait_h_recursive -#include_next -#else -#define __sys_wait_h_recursive - - -#if _G_HAVE_SYS_WAIT -#ifdef VMS -#include "GNU_CC_INCLUDE:[sys]wait.h" -#else -#include_next -#endif -#else /* !_G_HAVE_SYS_WAIT */ -/* Traditional definitions. */ -#define WEXITSTATUS(status) (((x) >> 8) & 0xFF) -#define WIFSTOPPED(x) (((x) & 0xFF) == 0177) -#define WIFEXITED(x) (! WIFSTOPPED(x) && WTERMSIG(x) == 0) -#define WIFSIGNALED(x) (! WIFSTOPPED(x) && WTERMSIG(x) != 0) -#define WTERMSIG(status) ((x) & 0x7F) -#define WSTOPSIG(status) (((x) >> 8) & 0xFF) -#endif /* !_G_HAVE_SYS_WAIT */ - -#define __libgxx_sys_wait_h 1 - -struct rusage; -extern _G_pid_t wait _G_ARGS((int*)); -extern _G_pid_t waitpid _G_ARGS((_G_pid_t, int*, int)); -extern _G_pid_t wait3 _G_ARGS((int*, int options, struct rusage*)); -#ifndef __NetBSD__ -extern _G_pid_t wait4 _G_ARGS((int, int*, int, struct rusage*)); -#else -extern _G_pid_t wait4 _G_ARGS((_G_pid_t, int*, int, struct rusage*)); -#endif -#endif -} - -#endif diff --git a/gnu/lib/libg++/g++-include/time.h b/gnu/lib/libg++/g++-include/time.h deleted file mode 100644 index 801585991911..000000000000 --- a/gnu/lib/libg++/g++-include/time.h +++ /dev/null @@ -1,110 +0,0 @@ -// $Id: time.h,v 1.3 1993/08/14 22:07:33 mycroft Exp $ - -#ifndef _G_time_h -#define _G_time_h - -extern "C" { - -#ifdef __time_h_recursive -#include_next -#else -#define __time_h_recursive - -#include <_G_config.h> - -// A clean way to use and/or define time_t might allow removal of this crud. -#ifndef __sys_time_h_recursive -#define time __hide_time -#define clock __hide_clock -#define difftime __hide_difftime -#define gmtime __hide_gmtime -#define localtime __hide_localtime -#define ctime __hide_ctime -#define asctime __hide_asctime -#define strftime __hide_strftime -#endif -#define mktime __hide_mktime -#define tzset __hide_tzset -#define tzsetwall __hide_tzsetwall -#define getitimer __hide_getitimer -#define setitimer __hide_setitimer -#define gettimeofday __hide_gettimeofday -#define settimeofday __hide_settimeofday - -#ifdef VMS - struct unix_time - { - long int tv_sec; - long int tv_usec; - }; - - struct rusage - { - struct unix_time ru_utime; - }; - -#define RUSAGE_SELF 0 //define it, it will be unused -#else -#ifdef hpux -#define _INCLUDE_POSIX_SOURCE -#endif - -#include_next -#endif -#undef __time_h_recursive - -#define time_h 1 - -#undef time -#undef clock -#undef difftime -#undef gmtime -#undef localtime -#undef asctime -#undef ctime -#undef mktime -#undef strftime -#undef tzset -#undef tzsetwall -#undef getitimer -#undef setitimer -#undef gettimeofday -#undef settimeofday - -extern char* asctime _G_ARGS((const struct tm*)); -extern char* ctime _G_ARGS((const _G_time_t*)); -double difftime _G_ARGS((_G_time_t, _G_time_t)); -extern struct tm* gmtime _G_ARGS((const _G_time_t*)); -extern struct tm* localtime _G_ARGS((const _G_time_t*)); -extern _G_time_t mktime(struct tm*); -extern _G_size_t strftime _G_ARGS((char*,_G_size_t,const char*,const struct tm*)); -extern void tzset(); -extern void tzsetwall(); - -extern int getitimer(int, struct itimerval*); -extern int setitimer _G_ARGS((int, const struct itimerval*,struct itimerval*)); -extern int gettimeofday(struct timeval*, struct timezone*); -extern int settimeofday _G_ARGS((const struct timeval*,const struct timezone*)); -extern int stime _G_ARGS((const _G_time_t*)); -extern int dysize(int); - -#if defined(___AIX__) -int clock (void); -#elif defined(hpux) -unsigned long clock(void); -#else -long clock(void); -#endif -_G_time_t time(_G_time_t*); -unsigned ualarm(unsigned, unsigned); -#ifndef __NetBSD__ -unsigned usleep(unsigned); -void profil _G_ARGS((unsigned short*, _G_size_t, unsigned int, unsigned)); -#else -void usleep(unsigned); -int profil _G_ARGS((char*, int, int, int)); -#endif - -#endif -} -#endif diff --git a/gnu/lib/libg++/g++-include/unistd.h b/gnu/lib/libg++/g++-include/unistd.h deleted file mode 100644 index e3cd0685fb8f..000000000000 --- a/gnu/lib/libg++/g++-include/unistd.h +++ /dev/null @@ -1,189 +0,0 @@ -// $Id: unistd.h,v 1.3 1993/08/14 22:07:34 mycroft Exp $ - -#ifndef _G_unistd_h -#define _G_unistd_h 1 - -#include <_G_config.h> - -extern "C" { - -#if _G_HAVE_UNISTD -#ifndef _G_USE_PROTOS -#define chmod __hide_chmod -#define chown __hide_chown -#define execl __hide_execl -#define execlp __hide_execlp -#define execle __hide_execle -#define fchown __hide_fchown -#define ioctl __hide_ioctl -#define setgid __hide_setgid -#define setuid __hide_setuid -#endif -#ifdef _AIX -// AIX's unistd.h defines int rename (const char *old, const char *new). -// This is not legal ANSI. It causes a C++ syntax error (because of 'new'). -#define new __new -#endif -#include_next -#ifdef _AIX -#undef new -#endif -#ifndef _G_USE_PROTOS -#undef chmod -#undef chown -#undef execl -#undef execle -#undef execlp -#undef fchown -#undef ioctl -#undef setgid -#undef setuid -#endif -#else -#ifndef SEEK_SET -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef F_OK -#define F_OK 0 -#endif -#ifndef X_OK -#define X_OK 1 -#endif -#ifndef W_OK -#define W_OK 2 -#endif -#ifndef R_OK -#define R_OK 4 -#endif -#endif - -#ifdef __GNUG__ -extern void volatile _exit(int); -#else -void _exit(int); -#endif - -extern unsigned alarm _G_ARGS((unsigned)); -#ifndef __NetBSD__ -extern int brk _G_ARGS((void*)); -#else -extern char* brk _G_ARGS((const char*)); -#endif -extern int chdir _G_ARGS((const char*)); -extern int chmod _G_ARGS((const char*, _G_mode_t)); -extern int chown (const char*, _G_uid_t, _G_gid_t); -extern int close _G_ARGS((int)); -extern char* crypt _G_ARGS((const char*, const char*)); -extern int dup _G_ARGS((int)); -extern int dup2 _G_ARGS((int, int)); -#ifndef __NetBSD__ -extern void encrypt _G_ARGS((char*, int)); -#else -extern int encrypt _G_ARGS((char*, int)); -#endif -extern int execl (const char*, const char *, ...); -extern int execle (const char*, const char *, ...); -extern int execlp (const char*, const char*, ...); -#ifndef __NetBSD__ -extern int exect _G_ARGS((const char*, const char**, char**)); -extern int execv _G_ARGS((const char*, const char * const *)); -extern int execve _G_ARGS((const char*, const char * const *, const char * const *)); -extern int execvp _G_ARGS((const char*, const char * const *)); -extern int fchown (int, _G_uid_t, _G_gid_t); -#else -extern int exect _G_ARGS((const char*, char * const*, char * const *)); -extern int execv _G_ARGS((const char*, char * const *)); -extern int execve _G_ARGS((const char*, char * const *, char * const *)); -extern int execvp _G_ARGS((const char*, char * const *)); -extern int fchown (int, int, int); -#endif -extern _G_pid_t fork _G_ARGS((void)); -extern int fsync _G_ARGS((int)); -extern int ftruncate _G_ARGS((int, _G_off_t)); -extern char* getcwd _G_ARGS((char*, _G_size_t)); -extern int getdomainname _G_ARGS((char*, int)); -extern int getdtablesize _G_ARGS((void)); -#ifndef __NetBSD__ -extern int getgroups _G_ARGS((int, _G_gid_t*)); -#else -extern int getgroups _G_ARGS((int, int*)); -#endif -extern _G_uid_t geteuid _G_ARGS((void)); -extern _G_gid_t getegid _G_ARGS((void)); -extern _G_gid_t getgid _G_ARGS((void)); -extern long gethostid _G_ARGS((void)); -extern int gethostname _G_ARGS((char*, int)); -extern _G_pid_t getpgrp _G_ARGS((...)); -extern _G_pid_t getpid _G_ARGS((void)); -extern _G_pid_t getppid _G_ARGS((void)); -extern char* getlogin _G_ARGS((void)); -extern char* getpass _G_ARGS((const char*)); -extern _G_uid_t getuid _G_ARGS((void)); -#ifndef __NetBSD__ -extern int ioctl (int, int, ... ); -#else -extern int ioctl (int, unsigned long, ... ); -#endif -extern int isatty _G_ARGS((int)); -extern int link _G_ARGS((const char*, const char*)); -extern int lockf _G_ARGS((int, int, long)); -extern int mkstemp _G_ARGS((char*)); -extern char* mktemp _G_ARGS((char*)); -extern int nice _G_ARGS((int)); -extern int pause _G_ARGS((void)); -extern int pipe _G_ARGS((int*)); -extern int readlink _G_ARGS((const char*, char*, int)); -extern int rename _G_ARGS((const char*, const char*)); -extern int rmdir _G_ARGS((const char*)); -#if defined( __OSF1__ ) || defined (__NetBSD__) -extern char* sbrk _G_ARGS((int)); -#else -extern void* sbrk _G_ARGS((int)); -#endif -extern int syscall _G_ARGS((int, ...)); -extern int setgid (_G_gid_t); -extern int sethostname _G_ARGS((const char*, int)); -#ifdef _G_SYSV -extern _G_pid_t setpgrp _G_ARGS((void)); -extern _G_pid_t setsid _G_ARGS((void)); -#else -#ifndef __NetBSD__ -extern _G_pid_t setpgrp _G_ARGS((_G_pid_t, _G_pid_t)); -#else -extern _G_pid_t setsid _G_ARGS((void)); -extern int setpgrp _G_ARGS((_G_pid_t, _G_pid_t)); -#endif -#endif -extern int setregid _G_ARGS((int, int)); -extern int setreuid _G_ARGS((int, int)); -extern int setuid (_G_uid_t); -extern unsigned sleep _G_ARGS((unsigned)); -extern void swab _G_ARGS((void*, void*, int)); -extern int symlink _G_ARGS((const char*, const char*)); -extern long sysconf _G_ARGS((int)); -extern int truncate _G_ARGS((const char*, _G_off_t)); -extern char* ttyname _G_ARGS((int)); -extern int ttyslot _G_ARGS((void)); -//extern int umask _G_ARGS((int)); /* commented out for now; wrong for SunOs4.1 */ -extern int unlink _G_ARGS((const char*)); -#ifndef __NetBSD__ -extern _G_pid_t vfork _G_ARGS((void)); -#else -extern int vfork _G_ARGS((void)); -#endif -extern int vadvise _G_ARGS((int)); -extern int vhangup _G_ARGS((void)); -extern _G_off_t lseek _G_ARGS((int, long, int)); -extern _G_ssize_t read _G_ARGS((int, void*, _G_size_t)); -extern _G_ssize_t write _G_ARGS((int, const void*, _G_size_t)); -extern int access _G_ARGS((const char*, int)); -#ifndef hpux -extern int flock _G_ARGS((int, int)); -#endif - -} - -#endif diff --git a/gnu/lib/libg++/libg++/SFile.cc b/gnu/lib/libg++/libg++/SFile.cc deleted file mode 100644 index 951196f3f8e3..000000000000 --- a/gnu/lib/libg++/libg++/SFile.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifdef __GNUG__ -#pragma implementation -#endif -#include - -SFile::SFile() {} -SFile::~SFile() {} - -SFile::SFile(const char* filename, int size, io_mode m, access_mode a) -: (filename, m, a) -{ - sz = size; -} - -SFile::SFile(const char* filename, int size, const char* m) -: (filename, m) -{ - sz = size; -} - -SFile::SFile(int filedesc, int size, io_mode m) -: (filedesc, m) -{ - sz = size; -} - -SFile::SFile(FILE* fileptr, int size) -: (fileptr) -{ - sz = size; -} diff --git a/gnu/lib/libg++/libg++/Sample.cc b/gnu/lib/libg++/libg++/Sample.cc deleted file mode 100644 index c5edf108b18f..000000000000 --- a/gnu/lib/libg++/libg++/Sample.cc +++ /dev/null @@ -1,241 +0,0 @@ -// @(#)Sample.cc 6.2 (Berkeley) 2/25/91 - -// Modified for Berkeley Unix by Donn Seeley, donn@okeeffe.berkeley.edu - -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ -#ifdef __GNUG__ -#pragma implementation -#endif -#include -#include -#include - -// error handling - -void default_SampleStatistic_error_handler(const char* msg) -{ - cerr << "Fatal SampleStatistic error. " << msg << "\n"; - exit(1); -} - -one_arg_error_handler_t SampleStatistic_error_handler = default_SampleStatistic_error_handler; - -one_arg_error_handler_t set_SampleStatistic_error_handler(one_arg_error_handler_t f) -{ - one_arg_error_handler_t old = SampleStatistic_error_handler; - SampleStatistic_error_handler = f; - return old; -} - -void SampleStatistic::error(const char* msg) -{ - (*SampleStatistic_error_handler)(msg); -} - -// t-distribution: given p-value and degrees of freedom, return t-value -// adapted from Peizer & Pratt JASA, vol63, p1416 - -double tval(double p, int df) -{ - double t; - int positive = p >= 0.5; - p = (positive)? 1.0 - p : p; - if (p <= 0.0 || df <= 0) - t = HUGE; - else if (p == 0.5) - t = 0.0; - else if (df == 1) - t = 1.0 / tan((p + p) * 1.57079633); - else if (df == 2) - t = sqrt(1.0 / ((p + p) * (1.0 - p)) - 2.0); - else - { - double ddf = df; - double a = sqrt(log(1.0 / (p * p))); - double aa = a * a; - a = a - ((2.515517 + (0.802853 * a) + (0.010328 * aa)) / - (1.0 + (1.432788 * a) + (0.189269 * aa) + - (0.001308 * aa * a))); - t = ddf - 0.666666667 + 1.0 / (10.0 * ddf); - t = sqrt(ddf * (exp(a * a * (ddf - 0.833333333) / (t * t)) - 1.0)); - } - return (positive)? t : -t; -} - -void -SampleStatistic::reset() -{ - n = 0; x = x2 = 0.0; - maxValue = -HUGE; - minValue = HUGE; -} - -void -SampleStatistic::operator+=(double value) -{ - n += 1; - x += value; - x2 += (value * value); - if ( minValue > value) minValue = value; - if ( maxValue < value) maxValue = value; -} - -double -SampleStatistic::mean() -{ - if ( n > 0) { - return (x / n); - } - else { - return ( 0.0 ); - } -} - -double -SampleStatistic::var() -{ - if ( n > 1) { - return(( x2 - ((x * x) / n)) / ( n - 1)); - } - else { - return ( 0.0 ); - } -} - -double -SampleStatistic::stdDev() -{ - if ( n <= 0 || this -> var() <= 0) { - return(0); - } else { - return( (double) sqrt( var() ) ); - } -} - -double -SampleStatistic::confidence(int interval) -{ - int df = n - 1; - if (df <= 0) return HUGE; - double t = tval(double(100 + interval) * 0.005, df); - if (t == HUGE) - return t; - else - return (t * stdDev()) / sqrt(double(n)); -} - -double -SampleStatistic::confidence(double p_value) -{ - int df = n - 1; - if (df <= 0) return HUGE; - double t = tval((1.0 + p_value) * 0.5, df); - if (t == HUGE) - return t; - else - return (t * stdDev()) / sqrt(double(n)); -} - - -#include - -const int SampleHistogramMinimum = -2; -const int SampleHistogramMaximum = -1; - -SampleHistogram::SampleHistogram(double low, double high, double width) -{ - if (high < low) { - double t = high; - high = low; - low = t; - } - - if (width == -1) { - width = (high - low) / 10; - } - - howManyBuckets = int((high - low) / width) + 2; - bucketCount = new int[howManyBuckets]; - bucketLimit = new double[howManyBuckets]; - double lim = low; - for (int i = 0; i < howManyBuckets; i++) { - bucketCount[i] = 0; - bucketLimit[i] = lim; - lim += width; - } - bucketLimit[howManyBuckets-1] = HUGE; /* from math.h */ -} - -SampleHistogram::~SampleHistogram() -{ - if (howManyBuckets > 0) { - delete bucketCount; - delete bucketLimit; - } -} - -void -SampleHistogram::operator+=(double value) -{ - int i; - for (i = 0; i < howManyBuckets; i++) { - if (value < bucketLimit[i]) break; - } - bucketCount[i]++; - this->SampleStatistic::operator+=(value); -} - -int -SampleHistogram::similarSamples(double d) -{ - int i; - for (i = 0; i < howManyBuckets; i++) { - if (d < bucketLimit[i]) return(bucketCount[i]); - } - return(0); -} - -void -SampleHistogram::printBuckets(ostream& s) -{ - for(int i = 0; i < howManyBuckets; i++) { - if (bucketLimit[i] >= HUGE) { - s << "< max : " << bucketCount[i] << "\n"; - } else { - s << "< " << bucketLimit[i] << " : " << bucketCount[i] << "\n"; - } - } -} - -void -SampleHistogram::reset() -{ - this->SampleStatistic::reset(); - if (howManyBuckets > 0) { - for (register int i = 0; i < howManyBuckets; i++) { - bucketCount[i] = 0; - } - } -} - diff --git a/gnu/lib/libg++/libg++/ctype.cc b/gnu/lib/libg++/libg++/ctype.cc deleted file mode 100644 index 3401290f5890..000000000000 --- a/gnu/lib/libg++/libg++/ctype.cc +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef __GNUG__ -#pragma implementation -#endif -#include diff --git a/gnu/lib/libg++/libg++/curses.cc b/gnu/lib/libg++/libg++/curses.cc deleted file mode 100644 index 943fb380f8e3..000000000000 --- a/gnu/lib/libg++/libg++/curses.cc +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef __GNUG__ -#pragma implementation -#endif -#include diff --git a/gnu/lib/libg++/libg++/delete.cc b/gnu/lib/libg++/libg++/delete.cc deleted file mode 100644 index 7633587a0189..000000000000 --- a/gnu/lib/libg++/libg++/delete.cc +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef NO_LIBGXX_MALLOC - -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifdef __GNUG__ -#pragma implementation -#endif -#include -#include - -void operator delete(void* ptr) -{ - free (ptr); -} - -#endif diff --git a/gnu/lib/libg++/libg++/filebuf.cc b/gnu/lib/libg++/libg++/filebuf.cc deleted file mode 100644 index 8c751ca9dc53..000000000000 --- a/gnu/lib/libg++/libg++/filebuf.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* -Copyright (C) 1990 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#if 1 -#ifdef __GNUG__ -#pragma implementation -#endif -#endif - -#include -#include // needed to determine values of O_RDONLY... -#include -#include - -filebuf::filebuf() - :streambuf(), fd(-1), opened(0) {} - -filebuf::filebuf(int newfd) - : streambuf(), fd(newfd), opened(1) {} - -filebuf::filebuf(int newfd, char* buf, int buflen) - : streambuf(buf, buflen), fd(newfd), opened(1) {} - -filebuf::filebuf(const char* filename, io_mode m, access_mode a) - : streambuf() -{ - open(filename, m, a); -} - -filebuf::filebuf(const char* filename, const char* m) - : streambuf() -{ - open(filename, m); -} - -filebuf::filebuf(int filedesc, io_mode m) - : streambuf() -{ - open(filedesc, m); -} - -filebuf::filebuf(FILE* fileptr) - : streambuf() -{ - open(fileptr); -} - -int filebuf::is_open() -{ - return opened; -} - -int filebuf::close() -{ - int was = opened; - if (was) ::close(fd); - opened = 0; - return was; -} - -streambuf* filebuf::open(const char* filename, open_mode m) -{ - if (opened) return 0; - int mode = -1; // any illegal value - switch (m) - { - case input: mode = O_RDONLY; - break; - case output: mode = O_WRONLY | O_CREAT | O_TRUNC; - break; - case append: mode = O_APPEND | O_CREAT | O_WRONLY; - break; - } - fd = ::open(filename, mode, 0666); - if (opened = (fd >= 0)) - { - allocate(); - return this; - } - else - return 0; -} - - -streambuf* filebuf::open(const char* filename, io_mode m, access_mode a) -{ - int open_arg = open_cmd_arg(m, a); - if (open_arg == -1) return 0; - fd = ::open(filename, open_arg, 0666); - if (opened = (fd >= 0)) - { - allocate(); - return this; - } - else - return 0; - -} - -streambuf* filebuf::open(const char* filename, const char* m) -{ - int open_arg = open_cmd_arg(m); - if (open_arg == -1) return 0; - fd = ::open(filename, open_arg, 0666); - if (opened = (fd >= 0)) - { - allocate(); - return this; - } - else - return 0; -} - -streambuf* filebuf::open(int filedesc, io_mode m) -{ - int open_arg = open_cmd_arg(m, a_use); - if (open_arg == -1) return 0; - fd = ::open(name(), open_arg, 0666); - if (opened = (fd >= 0)) - { - allocate(); - return this; - } - else - return 0; -} - -streambuf* filebuf::open(FILE* fileptr) -{ - opened = fileptr != 0; - fd = fileno(fileptr); - return this; -} - -int filebuf::underflow() -{ - if (!opened) return EOF; - if (base == 0) allocate(); - int nwanted = eptr - base + 1; - int nread = ::read(fd, base, nwanted); - if (nread >= 0) - { - gptr = base; - pptr = base + nread; - } - return (nread <= 0)? EOF : int(*gptr); -} - -int filebuf::overflow(int ch) -{ - if (!opened) return EOF; - if (base == 0) allocate(); - if (ch != EOF) // overflow *must* be called before really full - *pptr++ = (char)(ch); - - // loop, in case write can't handle full request - // From: Rene' Seindal - - int w, n, t; - for (w = t = 0, n = pptr - base; n > 0; n -= w, t += w) - { - if ((w = ::write(fd, base + t, n)) < 0) - break; - } - - pptr = base; - return (n == 0 && w >= 0)? 0 : EOF; -} - -filebuf::~filebuf() -{ - close(); -} diff --git a/gnu/lib/libg++/libg++/form.cc b/gnu/lib/libg++/libg++/form.cc deleted file mode 100644 index ae373ed13d46..000000000000 --- a/gnu/lib/libg++/libg++/form.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (C) 1990 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifdef __GNUG__ -#pragma implementation -#endif -#include -#include -#include -#include - -extern AllocRing _libgxx_fmtq; - -char* form(const char* fmt ...) -{ - va_list args; - va_start(args, fmt); - char* fmtbase = (char *) _libgxx_fmtq.alloc(BUFSIZ); -#ifndef HAVE_VPRINTF - FILE b; -#ifdef VMS - b->_flag = _IOWRT|_IOSTRG; - b->_ptr = fmtbase; - b->_cnt = BUFSIZ-1; -#else - b._flag = _IOWRT|_IOSTRG; - b._ptr = fmtbase; - b._cnt = BUFSIZ-1; -#endif - _doprnt(fmt, args, &b); - putc('\0', &b); -#else - vsprintf(fmtbase, fmt, args); -#endif - va_end(args); - return fmtbase; -} diff --git a/gnu/lib/libg++/libg++/g++.order b/gnu/lib/libg++/libg++/g++.order deleted file mode 100644 index 3639cd50972e..000000000000 --- a/gnu/lib/libg++/libg++/g++.order +++ /dev/null @@ -1,70 +0,0 @@ -std.o -math.o -curses.o -ctype.o -compare.o -timer.o -str.o -sqrt.o -pow.o -ioob.o -fmtq.o -lg.o -itoa.o -hash.o -gcd.o -form.o -error.o -dtoa.o -chr.o -delete.o -new.o -gnulib3.o -xyzzy.o -EH2.o -EH.o -GetOpt.o -CursesW.o -Fix24.o -Fix16.o -Fix.o -RndInt.o -MLCG.o -ACG.o -RNG.o -min.o -max.o -Binomial.o -Geom.o -HypGeom.o -Poisson.o -Uniform.o -DiscUnif.o -Erlang.o -Weibull.o -NegExp.o -Normal.o -SmplStat.o -SmplHist.o -LogNorm.o -BitString.o -BitSet.o -Random.o -Complex.o -Rational.o -Integer.o -String.o -Regex.o -regex.o -builtin.o -SFile.o -PlotFile.o -open.o -Filebuf.o -istream.o -ostream.o -File.o -Obstack.o -AllocRing.o -filebuf.o -streambuf.o diff --git a/gnu/lib/libg++/libg++/gnulib3.c b/gnu/lib/libg++/libg++/gnulib3.c deleted file mode 100644 index d8d212e40fcb..000000000000 --- a/gnu/lib/libg++/libg++/gnulib3.c +++ /dev/null @@ -1,109 +0,0 @@ - -#ifndef NO_GNULIB3 /* skip entire file if NO_GNULIB3 */ - -typedef struct set_vector -{ - int length; - int vector[1]; - /* struct set_vector *next; */ -} set_vector; - -set_vector __CTOR_LIST__; -set_vector __DTOR_LIST__; -set_vector *__dlp; -int __dli; - -extern void exit (int); -extern void __do_global_init (); -extern void __do_global_cleanup (); -extern void on_exit(void*, void*); -extern void _cleanup(); -extern void _exit(int); - - -#if defined(i386) && !defined(sequent) -#define COFF -#endif - -#ifdef COFF_ENCAPSULATE -#undef COFF -#endif - -/* - ON_EXIT macro commented out - dl - Sun on_exit doesn't get linked in right!!! -*/ - -#if 0 -#if defined(sun) -#define ON_EXIT(PROCP, ARG) \ - do { extern void PROCP (); on_exit (PROCP, ARG); } while (0) -#endif -#endif - -int -__main () -{ - /* Gross hack for GNU ld. This is defined in `builtin.cc' - from libg++. */ -#ifndef COFF - extern int __1xyzzy__; -#endif - -#ifdef ON_EXIT - -#ifdef sun - ON_EXIT (_cleanup, 0); -#endif - - ON_EXIT (__do_global_cleanup, 0); - -#endif - __dli = __DTOR_LIST__.length; - __dlp = &__DTOR_LIST__; -#ifndef COFF - __do_global_init (&__1xyzzy__); -#else - __do_global_init (); -#endif -} - -#ifndef ON_EXIT - -void -exit (status) - int status; -{ - __do_global_cleanup (); - _cleanup (); - _exit (status); -} -#endif - -void -__do_global_init () -{ - register int i, len; - register void (**ppf)() = (void (**)())__CTOR_LIST__.vector; - - len = __CTOR_LIST__.length; - for (i = 0; i < len; i++) - (*ppf[i])(); -} - -void -__do_global_cleanup () -{ - while (__dlp) - { - while (--__dli >= 0) - { - void (*pf)() = (void (*)())__dlp->vector[__dli]; - (*pf)(); - } - __dlp = (struct set_vector *)__dlp->vector[__dlp->length]; - if (__dlp) __dli = __dlp->length; - } -} - -#endif diff --git a/gnu/lib/libg++/libg++/istream.cc b/gnu/lib/libg++/libg++/istream.cc deleted file mode 100644 index 4898ab6d6287..000000000000 --- a/gnu/lib/libg++/libg++/istream.cc +++ /dev/null @@ -1,507 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -/* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */ - -#ifdef __GNUG__ -#pragma implementation -#endif -#include -#include -#include -#include -#include - - -istream::istream(streambuf* s, int sk, ostream* t) - : bp(s), state(_good), skipws(sk), tied_to(t), ownbuf(0) {} - -istream::istream(int sz, char* buf, int sk, ostream* t) - : state(_good), skipws(sk), tied_to(t), ownbuf(1) -{ - bp = new streambuf; - if (buf == 0) - { - bp->alloc = 1; - buf = new char[sz]; - } - else - bp->alloc = 0; - - bp->setbuf(buf, sz, sz); -} - -istream::~istream() -{ - if (ownbuf) delete bp; -} - -istream::istream(const char* filename, io_mode m, access_mode a, int sk, ostream* t) - : state(_good), skipws(sk), tied_to(t), ownbuf(1) -{ - bp = new filebuf(filename, m, a); -} - -istream::istream(const char* filename, const char* m, int sk, ostream* t) - : state(_good), skipws(sk), tied_to(t), ownbuf(1) -{ - bp = new filebuf(filename, m); -} - -istream::istream(int filedesc, io_mode m, int sk, ostream* t) - : state(_good), skipws(sk), tied_to(t), ownbuf(1) -{ - bp = new filebuf(filedesc, m); -} - -istream::istream(FILE* fileptr, int sk, ostream* t) - : state(_good), skipws(sk), tied_to(t), ownbuf(1) -{ - bp = new filebuf(fileptr); - -} - -istream::istream(int filedesc, int sk, ostream* t) - : state(_good), skipws(sk), tied_to(t), ownbuf(1) -{ - bp = new filebuf(filedesc); -} - -istream::istream(int filedesc, char* buf, int buflen, int sk, ostream* t) - : state(_good), skipws(sk), tied_to(t), ownbuf(1) -{ - bp = new filebuf(filedesc, buf, buflen); -} - -istream& istream::open(const char* filename, io_mode m, access_mode a) -{ - return failif(bp->open(filename, m, a) == 0); -} - -istream& istream::open(const char* filename, const char* m) -{ - return failif(bp->open(filename, m) == 0); -} - -istream& istream::open(int filedesc, io_mode m) -{ - return failif(bp->open(filedesc, m) == 0); -} - -istream& istream::open(FILE* fileptr) -{ - return failif(bp->open(fileptr) == 0); -} - -istream& istream::open(const char* filenam, open_mode m) -{ - return failif(bp->open(filenam, m) == 0); -} - -istream& istream::get(char& c) -{ - if (good()) - { - if(tied_to != 0) tied_to->flush(); - int ch = bp->sgetc(); - if (ch == EOF) - set(_eof); - else - { - c = ch; - bp->stossc(); - } - } - return *this; -} - - -istream& istream::operator >> (whitespace&) -{ - if (good()) - { - int ch; - if(tied_to != 0) tied_to->flush(); - while (((ch = bp->sgetc()) != EOF) && isspace(ch)) bp->stossc(); - if (ch == EOF) set(_eof); - } - return *this; -} - - -istream& istream::operator >> (char& c) -{ - if (skipws) (*this >> WS); - return get(c); -} - -istream& istream::get(char* s, int n, char terminator) -{ - if (!readable()) - { - set(_fail); - return *this; - } - - char ch = 0; - char* start = s; - if (--n > 0 && get(ch)) - { - if (ch == terminator) - unget(ch); - else - { - *s++ = ch; --n; - while (n-- > 0 && get(ch)) - { - if (ch == terminator) - { - unget(ch); - break; - } - else - *s++ = ch; - } - } - } - - *s = 0; - if (s != start) clear(); - return *this; -} - - -istream& istream::operator >> (char* s) -{ - if (!readable() || s == 0) - { - set(_fail); - return *this; - } - - if (skipws && !(*this >> WS)) return *this; - - char ch; - char* start = s; - if (get(ch)) - { - *s++ = ch; - while (get(ch)) - { - if (isspace(ch)) - { - unget(ch); - break; - } - else - *s++ = ch; - } - } - - *s = 0; - if (s != start) clear(); - return *this; -} - - -istream& istream::getline(char* s, int n, char terminator) -{ - if (!readable()) - { - set(_fail); - return *this; - } - char* start = s; - char ch; - while (--n > 0 && get(ch) && ((*s++ = ch) != terminator)); - - *s = 0; - if (s != start) clear(); - return *this; -} - -// from Doug Schmidt - -// This should probably be a page size.... -#define CHUNK_SIZE 512 - -/* Reads an arbitrarily long input line terminated by a user-specified - TERMINATOR. Super-nifty trick using recursion avoids unnecessary calls - to NEW! */ - -char *istream::readline (int chunk_number, char terminator) -{ - char buf[CHUNK_SIZE]; - register char *bufptr = buf; - register char *ptr; - char ch; - int continu; - - while ((continu = !!get(ch)) && ch != terminator) /* fill the current buffer */ - { - *bufptr++ = ch; - if (bufptr - buf >= CHUNK_SIZE) /* prepend remainder to ptr buffer */ - { - if (ptr = readline (chunk_number + 1, terminator)) - - for (; bufptr != buf; *--ptr = *--bufptr); - - return ptr; - } - } - if (!continu && bufptr == buf) - return NULL; - - int size = (chunk_number * CHUNK_SIZE + bufptr - buf) + 1; - - if (ptr = new char[size]) - { - - for (*(ptr += (size - 1)) = '\0'; bufptr != buf; *--ptr = *--bufptr) - ; - - return ptr; - } - else - return NULL; -} - -/* Reads an arbitrarily long input line terminated by TERMINATOR. - This routine allocates its own memory, so the user should - only supply the address of a (char *). */ - -istream& istream::gets(char **s, char terminator) -{ - return failif(!readable() || !(*s = readline (0, terminator))); -} - -istream& istream::operator >> (long& y) -{ - if (!readable()) - { - set(_bad); - return *this; - } - - int got_one = 0; - char sgn = 0; - char ch; - y = 0; - if (skipws) *this >> WS; - if (!good()) - { - set(_bad); - return *this; - } - while (get(ch)) - { - if (ch == '-') - { - if (sgn == 0 && got_one == 0) - sgn = '-'; - else - break; - } - else if (ch >= '0' && ch <= '9') - y = y * 10 + ((got_one = ch) - '0'); - else - break; - } - if (good()) - unget(ch); - if (!got_one) - set(_bad); - else - clear(); - - if (sgn == '-') - y = -y; - - return *this; -} - -istream& istream::operator >> (unsigned long& y) -{ - if (!readable()) - { - set(_bad); - return *this; - } - - int got_one = 0; - char ch; - y = 0; - if (skipws) *this >> WS; - if (!good()) - while (get(ch)) - { - if (ch >= '0' && ch <= '9') - y = y * 10 + ((got_one = ch) - '0'); - else - break; - } - if (good()) - unget(ch); - if (!got_one) - set(_bad); - else - clear(); - return *this; -} - - -/* for input to a double, we must trust atof (cannot even use -the better strtod since it is not universally supported). So -guaranteed legal chars are gathered up into an obstack. The -only possible, undiagnosable error is that the input number -might give a floating overflow or underflow inside atof. -I know of no way to avoid this */ - -extern Obstack _libgxx_io_ob; - -istream& istream::operator >> (double & y) -{ - if (!readable()) - { - set(_bad); - return *this; - } - - - char seenint = 0; - char seendec = 0; - char seenexp = 0; - char seensgn = 0; - char seene = 0; - char seenexpsgn = 0; - char seendot = 0; - char ch; - - if (skipws) *this >> WS; - if (!good()) - { - set(_bad); - return *this; - } - while (get(ch)) - { - if (ch == '-' || ch == '+') - { - if (seene && !seenexpsgn) - _libgxx_io_ob.grow(seenexpsgn = ch); - else if (!seensgn && !seenint) - _libgxx_io_ob.grow(seensgn = ch); - else - break; - } - else if (ch == '.' && !seendot) - { - _libgxx_io_ob.grow(seendot = ch); - } - else if ((ch == 'e' || ch == 'E') && !seene) - { - _libgxx_io_ob.grow(seene = ch); - } - else if (ch >= '0' && ch <= '9') - { - _libgxx_io_ob.grow(ch); - if (seene) seenexp = ch; - else if (seendot) seendec = ch; - else seenint = ch; - } - else - break; - } - char* str = (char *) _libgxx_io_ob.finish(0); - if (good()) - unget(ch); - if ((seenint || seendec) && (!seene || seenexp)) - y = atof(str); - else - set(_bad); - _libgxx_io_ob.free(str); - return *this; -} - -istream& istream::operator >> (int& y) -{ - long l; (*this >> l); y = int(l); return *this; -} - -istream& istream:: operator >> (unsigned int& y) -{ - long l; (*this >> l); y = (unsigned int)(l); return *this; -} - -istream& istream:: operator >> (short& y) -{ - long l; (*this >> l); y = short(l); return *this; -} - -istream& istream:: operator >> (unsigned short& y) -{ - long l; (*this >> l); y = (unsigned short)(l); return *this; -} - -istream& istream:: operator >> (float& y) -{ - double d; (*this >> d); y = float(d); return *this; -} - -const char* istream::name() -{ - return bp->name(); -} - -void istream::error() -{ - bp->error(); -} - -ostream* istream::tie(ostream* s) -{ - ostream* was = tied_to; tied_to = s; return was; -} - -void istream::_flush() -{ - if(tied_to != 0) tied_to->flush(); -} - - -//-------------------------------------------------------------- - -extern ostream cout; - -#if 0 /* BSD 4.4 */ - -istream cin(stdin, 1, &cout); - -#else - -static char cinbuf[BUFSIZE]; -istream cin (0, cinbuf, BUFSIZE, 1, &cout); - -#endif - -whitespace WS; diff --git a/gnu/lib/libg++/libg++/itoa.cc b/gnu/lib/libg++/libg++/itoa.cc deleted file mode 100644 index 489f252e29df..000000000000 --- a/gnu/lib/libg++/libg++/itoa.cc +++ /dev/null @@ -1,226 +0,0 @@ -/* -Copyright (C) 1990 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifdef __GNUG__ -#pragma implementation -#endif -#include -#include -#include - -extern AllocRing _libgxx_fmtq; - -char* itoa(long x, int base, int width) -{ - int wrksiz; - if (base == 10) - wrksiz = width + 13; - else - wrksiz = (BITS(long) + 1) / lg(base) + 1 + width + 1; - - char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); - char* e = fmtbase + wrksiz - 1; - char* s = e; - *--s = 0; - char sgn = 0; - - if (x == 0) - *--s = '0'; - else - { - unsigned int z; - if (x < 0) - { - sgn = '-'; - z = -x; - } - else - z = x; - while (z != 0) - { - char ch = char(z % base); - z = z / base; - if (ch >= 10) - ch += 'a' - 10; - else - ch += '0'; - *--s = ch; - } - } - - if (sgn) *--s = sgn; - int w = e - s - 1; - while (w++ < width) - *--s = ' '; - return s; -} - -char* itoa(unsigned long x, int base, int width) -{ - int wrksiz; - if (base == 10) - wrksiz = width + 13; - else - wrksiz = (BITS(long) + 1) / lg(base) + 1 + width + 1; - - char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); - char* e = fmtbase + wrksiz - 1; - char* s = e; - *--s = 0; - - if (x == 0) - *--s = '0'; - else - { - unsigned int b = base; - while (x != 0) - { - char ch = char(x % b); - x = x / b; - if (ch >= 10) - ch += 'a' - 10; - else - ch += '0'; - *--s = ch; - } - } - - int w = e - s - 1; - while (w++ < width) - *--s = ' '; - return s; -} - -#ifdef __GNUG__ -#ifndef VMS -char* itoa(long long x, int base, int width) -{ - int wrksiz; - if (base == 10) - wrksiz = width + 23; - else - wrksiz = (BITS(long long) + 1) / lg(base) + 1 + width + 1; - - char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); - char* e = fmtbase + wrksiz - 1; - char* s = e; - *--s = 0; - char sgn = 0; - - if (x == 0) - *--s = '0'; - else - { - long long z; - if (x < 0) - { - sgn = '-'; - z = -x; - } - else - z = x; - while (z != 0) - { - char ch = char(z % base); - z = z / base; - if (ch >= 10) - ch += 'a' - 10; - else - ch += '0'; - *--s = ch; - } - } - - if (sgn) *--s = sgn; - int w = e - s - 1; - while (w++ < width) - *--s = ' '; - return s; -} - -char* itoa(unsigned long long x, int base, int width) -{ - int wrksiz; - if (base == 10) - wrksiz = width + 23; - else - wrksiz = (BITS(long long) + 1) / lg(base) + 1 + width + 1; - - char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz); - char* e = fmtbase + wrksiz - 1; - char* s = e; - *--s = 0; - - if (x == 0) - *--s = '0'; - else - { - unsigned int b = base; - while (x != 0) - { - char ch = char(x % b); - x = x / b; - if (ch >= 10) - ch += 'a' - 10; - else - ch += '0'; - *--s = ch; - } - } - - int w = e - s - 1; - while (w++ < width) - *--s = ' '; - return s; -} -#endif -#endif - -char* hex(long i, int width) -{ - return itoa(i, 16, width); -} - -char* oct(long i, int width) -{ - return itoa(i, 8, width); -} - -char* dec(long i, int width) -{ - return itoa(i, 10, width); -} - -char* hex(unsigned long i, int width) -{ - return itoa(i, 16, width); -} - -char* oct(unsigned long i, int width) -{ - return itoa(i, 8, width); -} - -char* dec(unsigned long i, int width) -{ - return itoa(i, 10, width); -} diff --git a/gnu/lib/libg++/libg++/malloc.c b/gnu/lib/libg++/libg++/malloc.c deleted file mode 100644 index 071ee94a594e..000000000000 --- a/gnu/lib/libg++/libg++/malloc.c +++ /dev/null @@ -1,1261 +0,0 @@ -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - - - -#ifndef NO_LIBGXX_MALLOC /* ignore whole file otherwise */ - -/* compile with -DMALLOC_STATS to collect statistics */ -/* collecting statistics slows down malloc by at least 15% */ - -#ifdef MALLOC_STATS -#define UPDATE_STATS(ARGS) {ARGS;} -#else -#define UPDATE_STATS(ARGS) -#endif - -/* History - - - Tue Jan 16 04:54:27 1990 Doug Lea (dl at g.oswego.edu) - - version 1 released in libg++ - - Sun Jan 21 05:52:47 1990 Doug Lea (dl at g.oswego.edu) - - bins are now own struct for, sanity. - - new victim search strategy: scan up and consolidate. - Both faster and less fragmentation. - - refined when to scan bins for consolidation, via consollink, etc. - - realloc: always try to expand chunk, avoiding some fragmentation. - - changed a few inlines into macros - - hardwired SBRK_UNIT to 4096 for uniformity across systems - - Tue Mar 20 14:18:23 1990 Doug Lea (dl at g.oswego.edu) - - calloc and cfree now correctly parameterized. - - Sun Apr 1 10:00:48 1990 Doug Lea (dl at g.oswego.edu) - - added memalign and valloc. - - Sun Jun 24 05:46:48 1990 Doug Lea (dl at g.oswego.edu) - - #include gepagesize.h only ifndef sun - cache pagesize after first call - - Wed Jul 25 08:35:19 1990 Doug Lea (dl at g.oswego.edu) - - No longer rely on a `designated victim': - - 1. It sometimes caused splits of large chunks - when smaller ones would do, leading to - bad worst-case fragmentation. - - 2. Scanning through the av array fast anyway, - so the overhead isn't worth it. - - To compensate, several other minor changes: - - 1. Unusable chunks are checked for consolidation during - searches inside bins, better distributing chunks - across bins. - - 2. Chunks are returned when found in malloc_find_space, - rather than finishing cleaning everything up, to - avoid wasted iterations due to (1). -*/ - -/* - A version of malloc/free/realloc tuned for C++ applications. - - Here's what you probably want to know first: - - In various tests, this appears to be about as fast as, - and usually substantially less memory-wasteful than BSD/GNUemacs malloc. - - Generally, it is slower (by perhaps 20%) than bsd-style malloc - only when bsd malloc would waste a great deal of space in - fragmented blocks, which this malloc recovers; or when, by - chance or design, nearly all requests are near the bsd malloc - power-of-2 allocation bin boundaries, and as many chunks are - used as are allocated. - - It uses more space than bsd malloc only when, again by chance - or design, only bsdmalloc bin-sized requests are malloced, or when - little dynamic space is malloced, since this malloc may grab larger - chunks from the system at a time than bsd. - - In other words, this malloc seems generally superior to bsd - except perhaps for programs that are specially tuned to - deal with bsdmalloc's characteristics. But even here, the - performance differences are slight. - - - This malloc, like any other, is a compromised design. - - - Chunks of memory are maintained using a `boundary tag' method as - described in e.g., Knuth or Standish. This means that the size of - the chunk is stored both in the front of the chunk and at the end. - This makes consolidating fragmented chunks into bigger chunks very fast. - The size field is also used to hold bits representing whether a - chunk is free or in use. - - Malloced chunks have space overhead of 8 bytes: The preceding - and trailing size fields. When they are freed, the list pointer - fields are also needed. - - Available chunks are kept in doubly linked lists. The lists are - maintained in an array of bins using a power-of-two method, except - that instead of 32 bins (one for each 1 << i), there are 128: each - power of two is split in quarters. The use of very fine bin sizes - closely approximates the use of one bin per actually used size, - without necessitating the overhead of locating such bins. It is - especially desirable in common C++ applications where large numbers - of identically-sized blocks are malloced/freed in some dynamic - manner, and then later are all freed. The finer bin sizes make - finding blocks fast, with little wasted overallocation. The - consolidation methods ensure that once the collection of blocks is - no longer useful, fragments are gathered into bigger chunks awaiting new - roles. - - The bins av[i] serve as heads of the lists. Bins contain a dummy - header for the chunk lists, and a `dirty' field used to indicate - whether the list may need to be scanned for consolidation. - - On allocation, the bin corresponding to the request size is - scanned, and if there is a chunk with size >= requested, it - is split, if too big, and used. Chunks on the list which are - too small are examined for consolidation during this traversal. - - If no chunk exists in the list bigger bins are scanned in search of - a victim. - - If no victim can be found, then smaller bins are examined for - consolidation in order to construct a victim. - - Finally, if consolidation fails to come up with a usable chunk, - more space is obtained from the system. - - After a split, the remainder is placed on - the back of the appropriate bin list. (All freed chunks are placed - on fronts of lists. All remaindered or consolidated chunks are - placed on the rear. Correspondingly, searching within a bin - starts at the front, but finding victims is from the back. All - of this approximates the effect of having 2 kinds of lists per - bin: returned chunks vs unallocated chunks, but without the overhead - of maintaining 2 lists.) - - Deallocation (free) consists only of placing the chunk on - a list. - - Reallocation proceeds in the usual way. If a chunk can be extended, - it is, else a malloc-copy-free sequence is taken. - - memalign requests more than enough space from malloc, finds a - spot within that chunk that meets the alignment request, and - then possibly frees the leading and trailing space. Overreliance - on memalign is a sure way to fragment space. - - - Some other implementation matters: - - 8 byte alignment is currently hardwired into the design. Calling - memalign will return a chunk that is both 8-byte aligned, and - meets the requested alignment. - - The basic overhead of a used chunk is 8 bytes: 4 at the front and - 4 at the end. - - When a chunk is free, 8 additional bytes are needed for free list - pointers. Thus, the minimum allocatable size is 16 bytes. - - The existence of front and back overhead permits some reasonably - effective fence-bashing checks: The front and back fields must - be identical. This is checked only within free() and realloc(). - The checks are fast enough to be made non-optional. - - The overwriting of parts of freed memory with the freelist pointers - can also be very effective (albeit in an annoying way) in helping - users track down dangling pointers. - - User overwriting of freed space will often result in crashes - within malloc or free. - - These routines are also tuned to C++ in that free(0) is a noop and - a failed malloc automatically calls (*new_handler)(). - - malloc(0) returns a pointer to something of the minimum allocatable size. - - Additional memory is gathered from the system (via sbrk) in a - way that allows chunks obtained across different sbrk calls to - be consolidated, but does not require contiguous memory: Thus, - it should be safe to intersperse mallocs with other sbrk calls. - - This malloc is NOT designed to work in multiprocessing applications. - No semaphores or other concurrency control are provided to ensure - that multiple malloc or free calls don't run at the same time, - which could be disasterous. - - VERY heavy use of inlines is made, for clarity. If this malloc - is ported via a compiler without inlining capabilities, all - inlines should be transformed into macros -- making them non-inline - makes malloc at least twice as slow. - - -*/ - - -/* preliminaries */ - -#ifdef __cplusplus -#include -#else -#include "//usr/include/stdio.h" /* needed for error reporting */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef USG -extern void* memset(void*, int, int); -extern void* memcpy(void*, const void*, int); -inline void bzero(void* s, int l) { memset(s, 0, l); } -#else -extern void bzero(void*, unsigned int); -#endif - -extern void bcopy(void*, void*, unsigned int); - -extern void* sbrk(unsigned int); - - -#ifdef __GNUC__ -extern volatile void abort(); -#else -extern void abort(); -#endif - -#ifdef __cplusplus -}; /* end of extern "C" */ -#endif - - -/* A good multiple to call sbrk with */ - -#define SBRK_UNIT 4096 - - - -/* how to die on detected error */ - -#ifdef __GNUC__ -static volatile void malloc_user_error() -#else -static void malloc_user_error() -#endif -{ - fputs("malloc/free/realloc: clobbered space detected\n", stderr); abort(); -} - - - -/* Basic overhead for each malloc'ed chunk */ - - -struct malloc_chunk -{ - unsigned int size; /* Size in bytes, including overhead. */ - /* Or'ed with INUSE if in use. */ - - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; - -}; - -typedef struct malloc_chunk* mchunkptr; - -struct malloc_bin -{ - struct malloc_chunk hd; /* dummy list header */ - unsigned int dirty; /* True if maybe consolidatable */ - /* Wasting a word here makes */ - /* sizeof(bin) a power of 2, */ - /* which makes size2bin() faster */ -}; - -typedef struct malloc_bin* mbinptr; - - -/* sizes, alignments */ - - -#define SIZE_SZ (sizeof(unsigned int)) -#define MALLOC_MIN_OVERHEAD (SIZE_SZ + SIZE_SZ) -#define MALLOC_ALIGN_MASK (MALLOC_MIN_OVERHEAD - 1) - -#define MINSIZE (sizeof(struct malloc_chunk) + SIZE_SZ) /* MUST == 16! */ - - -/* pad request bytes into a usable size */ - -static inline unsigned int request2size(unsigned int request) -{ - return (request == 0) ? MINSIZE : - ((request + MALLOC_MIN_OVERHEAD + MALLOC_ALIGN_MASK) - & ~(MALLOC_ALIGN_MASK)); -} - - -static inline int aligned_OK(void* m) -{ - return ((unsigned int)(m) & (MALLOC_ALIGN_MASK)) == 0; -} - - -/* size field or'd with INUSE when in use */ -#define INUSE 0x1 - - - -/* the bins, initialized to have null double linked lists */ - -#define MAXBIN 120 /* 1 more than needed for 32 bit addresses */ - -#define FIRSTBIN (&(av[0])) - -static struct malloc_bin av[MAXBIN] = -{ - { { 0, &(av[0].hd), &(av[0].hd) }, 0 }, - { { 0, &(av[1].hd), &(av[1].hd) }, 0 }, - { { 0, &(av[2].hd), &(av[2].hd) }, 0 }, - { { 0, &(av[3].hd), &(av[3].hd) }, 0 }, - { { 0, &(av[4].hd), &(av[4].hd) }, 0 }, - { { 0, &(av[5].hd), &(av[5].hd) }, 0 }, - { { 0, &(av[6].hd), &(av[6].hd) }, 0 }, - { { 0, &(av[7].hd), &(av[7].hd) }, 0 }, - { { 0, &(av[8].hd), &(av[8].hd) }, 0 }, - { { 0, &(av[9].hd), &(av[9].hd) }, 0 }, - - { { 0, &(av[10].hd), &(av[10].hd) }, 0 }, - { { 0, &(av[11].hd), &(av[11].hd) }, 0 }, - { { 0, &(av[12].hd), &(av[12].hd) }, 0 }, - { { 0, &(av[13].hd), &(av[13].hd) }, 0 }, - { { 0, &(av[14].hd), &(av[14].hd) }, 0 }, - { { 0, &(av[15].hd), &(av[15].hd) }, 0 }, - { { 0, &(av[16].hd), &(av[16].hd) }, 0 }, - { { 0, &(av[17].hd), &(av[17].hd) }, 0 }, - { { 0, &(av[18].hd), &(av[18].hd) }, 0 }, - { { 0, &(av[19].hd), &(av[19].hd) }, 0 }, - - { { 0, &(av[20].hd), &(av[20].hd) }, 0 }, - { { 0, &(av[21].hd), &(av[21].hd) }, 0 }, - { { 0, &(av[22].hd), &(av[22].hd) }, 0 }, - { { 0, &(av[23].hd), &(av[23].hd) }, 0 }, - { { 0, &(av[24].hd), &(av[24].hd) }, 0 }, - { { 0, &(av[25].hd), &(av[25].hd) }, 0 }, - { { 0, &(av[26].hd), &(av[26].hd) }, 0 }, - { { 0, &(av[27].hd), &(av[27].hd) }, 0 }, - { { 0, &(av[28].hd), &(av[28].hd) }, 0 }, - { { 0, &(av[29].hd), &(av[29].hd) }, 0 }, - - { { 0, &(av[30].hd), &(av[30].hd) }, 0 }, - { { 0, &(av[31].hd), &(av[31].hd) }, 0 }, - { { 0, &(av[32].hd), &(av[32].hd) }, 0 }, - { { 0, &(av[33].hd), &(av[33].hd) }, 0 }, - { { 0, &(av[34].hd), &(av[34].hd) }, 0 }, - { { 0, &(av[35].hd), &(av[35].hd) }, 0 }, - { { 0, &(av[36].hd), &(av[36].hd) }, 0 }, - { { 0, &(av[37].hd), &(av[37].hd) }, 0 }, - { { 0, &(av[38].hd), &(av[38].hd) }, 0 }, - { { 0, &(av[39].hd), &(av[39].hd) }, 0 }, - - { { 0, &(av[40].hd), &(av[40].hd) }, 0 }, - { { 0, &(av[41].hd), &(av[41].hd) }, 0 }, - { { 0, &(av[42].hd), &(av[42].hd) }, 0 }, - { { 0, &(av[43].hd), &(av[43].hd) }, 0 }, - { { 0, &(av[44].hd), &(av[44].hd) }, 0 }, - { { 0, &(av[45].hd), &(av[45].hd) }, 0 }, - { { 0, &(av[46].hd), &(av[46].hd) }, 0 }, - { { 0, &(av[47].hd), &(av[47].hd) }, 0 }, - { { 0, &(av[48].hd), &(av[48].hd) }, 0 }, - { { 0, &(av[49].hd), &(av[49].hd) }, 0 }, - - { { 0, &(av[50].hd), &(av[50].hd) }, 0 }, - { { 0, &(av[51].hd), &(av[51].hd) }, 0 }, - { { 0, &(av[52].hd), &(av[52].hd) }, 0 }, - { { 0, &(av[53].hd), &(av[53].hd) }, 0 }, - { { 0, &(av[54].hd), &(av[54].hd) }, 0 }, - { { 0, &(av[55].hd), &(av[55].hd) }, 0 }, - { { 0, &(av[56].hd), &(av[56].hd) }, 0 }, - { { 0, &(av[57].hd), &(av[57].hd) }, 0 }, - { { 0, &(av[58].hd), &(av[58].hd) }, 0 }, - { { 0, &(av[59].hd), &(av[59].hd) }, 0 }, - - { { 0, &(av[60].hd), &(av[60].hd) }, 0 }, - { { 0, &(av[61].hd), &(av[61].hd) }, 0 }, - { { 0, &(av[62].hd), &(av[62].hd) }, 0 }, - { { 0, &(av[63].hd), &(av[63].hd) }, 0 }, - { { 0, &(av[64].hd), &(av[64].hd) }, 0 }, - { { 0, &(av[65].hd), &(av[65].hd) }, 0 }, - { { 0, &(av[66].hd), &(av[66].hd) }, 0 }, - { { 0, &(av[67].hd), &(av[67].hd) }, 0 }, - { { 0, &(av[68].hd), &(av[68].hd) }, 0 }, - { { 0, &(av[69].hd), &(av[69].hd) }, 0 }, - - { { 0, &(av[70].hd), &(av[70].hd) }, 0 }, - { { 0, &(av[71].hd), &(av[71].hd) }, 0 }, - { { 0, &(av[72].hd), &(av[72].hd) }, 0 }, - { { 0, &(av[73].hd), &(av[73].hd) }, 0 }, - { { 0, &(av[74].hd), &(av[74].hd) }, 0 }, - { { 0, &(av[75].hd), &(av[75].hd) }, 0 }, - { { 0, &(av[76].hd), &(av[76].hd) }, 0 }, - { { 0, &(av[77].hd), &(av[77].hd) }, 0 }, - { { 0, &(av[78].hd), &(av[78].hd) }, 0 }, - { { 0, &(av[79].hd), &(av[79].hd) }, 0 }, - - { { 0, &(av[80].hd), &(av[80].hd) }, 0 }, - { { 0, &(av[81].hd), &(av[81].hd) }, 0 }, - { { 0, &(av[82].hd), &(av[82].hd) }, 0 }, - { { 0, &(av[83].hd), &(av[83].hd) }, 0 }, - { { 0, &(av[84].hd), &(av[84].hd) }, 0 }, - { { 0, &(av[85].hd), &(av[85].hd) }, 0 }, - { { 0, &(av[86].hd), &(av[86].hd) }, 0 }, - { { 0, &(av[87].hd), &(av[87].hd) }, 0 }, - { { 0, &(av[88].hd), &(av[88].hd) }, 0 }, - { { 0, &(av[89].hd), &(av[89].hd) }, 0 }, - - { { 0, &(av[90].hd), &(av[90].hd) }, 0 }, - { { 0, &(av[91].hd), &(av[91].hd) }, 0 }, - { { 0, &(av[92].hd), &(av[92].hd) }, 0 }, - { { 0, &(av[93].hd), &(av[93].hd) }, 0 }, - { { 0, &(av[94].hd), &(av[94].hd) }, 0 }, - { { 0, &(av[95].hd), &(av[95].hd) }, 0 }, - { { 0, &(av[96].hd), &(av[96].hd) }, 0 }, - { { 0, &(av[97].hd), &(av[97].hd) }, 0 }, - { { 0, &(av[98].hd), &(av[98].hd) }, 0 }, - { { 0, &(av[99].hd), &(av[99].hd) }, 0 }, - - { { 0, &(av[100].hd), &(av[100].hd) }, 0 }, - { { 0, &(av[101].hd), &(av[101].hd) }, 0 }, - { { 0, &(av[102].hd), &(av[102].hd) }, 0 }, - { { 0, &(av[103].hd), &(av[103].hd) }, 0 }, - { { 0, &(av[104].hd), &(av[104].hd) }, 0 }, - { { 0, &(av[105].hd), &(av[105].hd) }, 0 }, - { { 0, &(av[106].hd), &(av[106].hd) }, 0 }, - { { 0, &(av[107].hd), &(av[107].hd) }, 0 }, - { { 0, &(av[108].hd), &(av[108].hd) }, 0 }, - { { 0, &(av[109].hd), &(av[109].hd) }, 0 }, - - { { 0, &(av[110].hd), &(av[110].hd) }, 0 }, - { { 0, &(av[111].hd), &(av[111].hd) }, 0 }, - { { 0, &(av[112].hd), &(av[112].hd) }, 0 }, - { { 0, &(av[113].hd), &(av[113].hd) }, 0 }, - { { 0, &(av[114].hd), &(av[114].hd) }, 0 }, - { { 0, &(av[115].hd), &(av[115].hd) }, 0 }, - { { 0, &(av[116].hd), &(av[116].hd) }, 0 }, - { { 0, &(av[117].hd), &(av[117].hd) }, 0 }, - { { 0, &(av[118].hd), &(av[118].hd) }, 0 }, - { { 0, &(av[119].hd), &(av[119].hd) }, 0 } -}; - -/* - indexing into bins -*/ - -static inline mbinptr size2bin(unsigned int sz) -{ - mbinptr b = av; - while (sz >= (MINSIZE * 2)) { b += 4; sz >>= 1; } /* find power of 2 */ - b += (sz - MINSIZE) >> 2; /* find quadrant */ - return b; -} - - - -/* counts maintained if MALLOC_STATS defined */ - -#ifdef MALLOC_STATS - -static unsigned int sbrked_mem; -static unsigned int requested_mem; -static unsigned int malloced_mem; -static unsigned int freed_mem; -static unsigned int max_used_mem; - -static unsigned int n_sbrks; -static unsigned int n_mallocs; -static unsigned int n_frees; -static unsigned int n_reallocs; -static unsigned int n_reallocs_with_copy; -static unsigned int n_avail; -static unsigned int max_inuse; - -static unsigned int n_malloc_chunks; -static unsigned int n_malloc_bins; - -static unsigned int n_split; -static unsigned int n_consol; - - -static void do_malloc_stats(const mchunkptr p) -{ - ++n_mallocs; - if ((n_mallocs-n_frees) > max_inuse) - max_inuse = n_mallocs - n_frees; - malloced_mem += (p->size & ~(INUSE)); - if (malloced_mem - freed_mem > max_used_mem) - max_used_mem = malloced_mem - freed_mem; -} - -static void do_free_stats(const mchunkptr p) -{ - ++n_frees; - freed_mem += (p->size & ~(INUSE)); -} - -#endif - - - -/* Utilities needed below for memalign */ -/* This is redundant with libg++ support, but not if used stand-alone */ - -static unsigned int gcd(unsigned int a, unsigned int b) -{ - unsigned int tmp; - - if (b > a) - { - tmp = a; a = b; b = tmp; - } - for(;;) - { - if (b == 0) - return a; - else if (b == 1) - return b; - else - { - tmp = b; - b = a % b; - a = tmp; - } - } -} - -static inline unsigned int lcm(unsigned int x, unsigned int y) -{ - return x / gcd(x, y) * y; -} - - - -/* maintaining INUSE via size field */ - - -#define inuse(p) ((p)->size & INUSE) -#define set_inuse(p) ((p)->size |= INUSE) -#define clear_inuse(b) ((p)->size &= ~INUSE) - - -/* operations on malloc_chunk addresses */ - - -/* return ptr to next physical malloc_chunk */ - -#define next_chunk(p) ((mchunkptr)((char*)(p) + (p)->size)) - -/* return ptr to previous physical malloc_chunk */ - -#define prev_chunk(p) ((mchunkptr)((char*)(p)-((((int*)(p))[-1]) & ~(INUSE)))) - -/* place size at front and back of chunk */ - - -static inline void set_size(mchunkptr p, unsigned int sz) -{ - p->size = *((int*)((char*)(p) + sz - SIZE_SZ)) = sz; -} - - - - -/* conversion from malloc headers to user pointers, and back */ - -static inline void* chunk2mem(mchunkptr p) -{ - set_inuse(p); - return (void*)((char*)(p) + SIZE_SZ); -} - -static inline mchunkptr mem2chunk(void* mem) -{ - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); - - /* a quick sanity check */ - unsigned int sz = p->size & ~(INUSE); - if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ))) - malloc_user_error(); - - p->size = sz; /* clears INUSE */ - return p; -} - - - -/* maintaining bins & pointers */ - - -/* maximum bin actually used */ - -static mbinptr malloc_maxbin = FIRSTBIN; - - -/* operations on lists inside bins */ - - -/* take a chunk off a list */ - -static inline void unlink(mchunkptr p) -{ - mchunkptr b = p->bk; - mchunkptr f = p->fd; - - f->bk = b; b->fd = f; - - UPDATE_STATS (--n_avail); -} - - - -/* split a chunk and place on the back of a list */ - -static inline void split(mchunkptr p, unsigned int offset) -{ - unsigned int room = p->size - offset; - if (room >= MINSIZE) - { - mbinptr bn = size2bin(room); /* new bin */ - mchunkptr h = &(bn->hd); /* its head */ - mchunkptr b = h->bk; /* old back element */ - mchunkptr t = (mchunkptr)((char*)(p) + offset); /* remaindered chunk */ - - /* set size */ - t->size = *((int*)((char*)(t) + room - SIZE_SZ)) = room; - - /* link up */ - t->bk = b; t->fd = h; h->bk = b->fd = t; - - /* adjust maxbin (h == b means was empty) */ - if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; - - /* adjust size of chunk to be returned */ - p->size = *((int*)((char*)(p) + offset - SIZE_SZ)) = offset; - - UPDATE_STATS ((++n_split, ++n_avail)); - } -} - - - -/* place a consolidated chunk on the back of a list */ -/* like above, except no split */ - -static inline void consollink(mchunkptr p) -{ - mbinptr bn = size2bin(p->size); - mchunkptr h = &(bn->hd); - mchunkptr b = h->bk; - - p->bk = b; p->fd = h; h->bk = b->fd = p; - - if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; - - UPDATE_STATS(++n_avail); -} - - -/* place a freed chunk on the front of a list */ - -static inline void frontlink(mchunkptr p) -{ - mbinptr bn = size2bin(p->size); - mchunkptr h = &(bn->hd); - mchunkptr f = h->fd; - - p->bk = h; p->fd = f; f->bk = h->fd = p; - - if (h == f && bn > malloc_maxbin) malloc_maxbin = bn; - - bn->dirty = 1; - - UPDATE_STATS(++n_avail); -} - - - -/* Dealing with sbrk */ - - -/* To link consecutive sbrk regions when possible */ - -static int* last_sbrk_end; - - -/* who to call when sbrk returns failure */ - -#ifndef NO_NEW_HANDLER -typedef volatile void (*vfp)(); -#ifdef __cplusplus -extern "C" vfp __new_handler; -#else -extern vfp __new_handler; -#endif -#endif - -static mchunkptr malloc_from_sys(unsigned nb) -{ - mchunkptr p; - unsigned int sbrk_size; - int* ip; - - /* Minimally, we need to pad with enough space */ - /* to place dummy size/use fields to ends if needed */ - - sbrk_size = ((nb + SBRK_UNIT - 1 + SIZE_SZ + SIZE_SZ) - / SBRK_UNIT) * SBRK_UNIT; - - ip = (int*)(sbrk(sbrk_size)); - if ((char*)ip == (char*)(-1)) /* sbrk returns -1 on failure */ - { -#ifndef NO_NEW_HANDLER - (*__new_handler) (); -#endif - return 0; - } - - UPDATE_STATS ((++n_sbrks, sbrked_mem += sbrk_size)); - - - if (last_sbrk_end != &ip[-1]) - { - /* It's either first time through or someone else called sbrk. */ - /* Arrange end-markers at front & back */ - - /* Shouldn't be necessary, but better to be safe */ - while (!aligned_OK(ip)) { ++ip; sbrk_size -= SIZE_SZ; } - - - /* Mark the front as in use to prevent merging. */ - /* Note we can get away with only 1 word, not MINSIZE overhead here */ - - *ip++ = SIZE_SZ | INUSE; - - p = (mchunkptr)ip; - set_size(p,sbrk_size - (SIZE_SZ + SIZE_SZ)); - - } - else - { - mchunkptr l; - - /* We can safely make the header start at end of prev sbrked chunk. */ - /* We will still have space left at the end from a previous call */ - /* to place the end marker, below */ - - p = (mchunkptr)(last_sbrk_end); - set_size(p, sbrk_size); - - - /* Even better, maybe we can merge with last fragment: */ - - l = prev_chunk(p); - if (!inuse(l)) - { - unlink(l); - set_size(l, p->size + l->size); - p = l; - } - - } - - /* mark the end of sbrked space as in use to prevent merging */ - - last_sbrk_end = (int*)((char*)p + p->size); - *last_sbrk_end = SIZE_SZ | INUSE; - - UPDATE_STATS((++n_avail, ++n_malloc_chunks)); - - /* make it safe to unlink in malloc */ - UPDATE_STATS(++n_avail); - p->fd = p->bk = p; - - return p; -} - - - -/* Consolidate dirty bins. */ -/* Stop if found a chunk big enough to satisfy current malloc request */ - -/* (It requires much less bookkeeping to consolidate entire bins */ -/* at once than to keep records of which chunks might be */ -/* consolidatable. So long as the lists are short, which we */ -/* try to ensure via small bin ranges, there is little wasted effort.) */ - -static mchunkptr malloc_find_space(unsigned int nb) -{ - mbinptr b; - - /* first, re-adjust max used bin */ - - while (malloc_maxbin >= FIRSTBIN && - malloc_maxbin->hd.bk == &(malloc_maxbin->hd)) - { - malloc_maxbin->dirty = 0; - --malloc_maxbin; - } - - for (b = malloc_maxbin; b >= FIRSTBIN; --b) - { - UPDATE_STATS(++n_malloc_bins); - - if (b->dirty) - { - mchunkptr h = &(b->hd); /* head of list */ - mchunkptr p = h->fd; /* chunk traverser */ - - while (p != h) - { - mchunkptr nextp = p->fd; /* save, in case of relinks */ - int consolidated = 0; /* only unlink/relink if consolidated */ - - mchunkptr t; - - UPDATE_STATS(++n_malloc_chunks); - - while (!inuse(t = prev_chunk(p))) /* consolidate backward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(t, t->size + p->size); - p = t; - UPDATE_STATS (++n_consol); - } - - while (!inuse(t = next_chunk(p))) /* consolidate forward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(p, p->size + t->size); - UPDATE_STATS (++n_consol); - } - - if (consolidated) - { - if (p->size >= nb) - { - /* make it safe to unlink in malloc */ - UPDATE_STATS(++n_avail); - p->fd = p->bk = p; - return p; - } - else - consollink(p); - } - - p = nextp; - - } - - b->dirty = 0; - - } - } - - /* nothing available - sbrk some more */ - - return malloc_from_sys(nb); -} - - - -/* Finally, the user-level functions */ - -void* malloc(unsigned int bytes) -{ - unsigned int nb = request2size(bytes); /* padded request size */ - mbinptr b = size2bin(nb); /* corresponding bin */ - mchunkptr hd = &(b->hd); /* head of its list */ - mchunkptr p = hd->fd; /* chunk traverser */ - - UPDATE_STATS((requested_mem+=bytes, ++n_malloc_bins)); - - /* Try a (near) exact match in own bin */ - /* clean out unusable but consolidatable chunks in bin while traversing */ - - while (p != hd) - { - UPDATE_STATS(++n_malloc_chunks); - if (p->size >= nb) - goto found; - else /* try to consolidate; same code as malloc_find_space */ - { - mchunkptr nextp = p->fd; /* save, in case of relinks */ - int consolidated = 0; /* only unlink/relink if consolidated */ - - mchunkptr t; - - while (!inuse(t = prev_chunk(p))) /* consolidate backward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(t, t->size + p->size); - p = t; - UPDATE_STATS (++n_consol); - } - - while (!inuse(t = next_chunk(p))) /* consolidate forward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(p, p->size + t->size); - UPDATE_STATS (++n_consol); - } - - if (consolidated) - { - if (p->size >= nb) - { - /* make it safe to unlink again below */ - UPDATE_STATS(++n_avail); - p->fd = p->bk = p; - goto found; - } - else - consollink(p); - } - - p = nextp; - - } - } - - b->dirty = 0; /* true if got here */ - - /* Scan bigger bins for a victim */ - - while (++b <= malloc_maxbin) - { - UPDATE_STATS(++n_malloc_bins); - if ((p = b->hd.bk) != &(b->hd)) /* no need to check size */ - goto found; - } - - /* Consolidate or sbrk */ - - p = malloc_find_space(nb); - - if (p == 0) return 0; /* allocation failure */ - - found: /* Use what we found */ - - unlink(p); - split(p, nb); - UPDATE_STATS(do_malloc_stats(p)); - return chunk2mem(p); -} - - - - -void free(void* mem) -{ - if (mem != 0) - { - mchunkptr p = mem2chunk(mem); - UPDATE_STATS(do_free_stats(p)); - frontlink(p); - } -} - - -void* calloc(unsigned int n, unsigned int elem_size) -{ - unsigned int sz = n * elem_size; - void* p = malloc(sz); - bzero(p, sz); - return p; -}; - -/* This is here for compatibility with older systems */ -void cfree(void *mem) -{ - free(mem); -} - - -unsigned int malloc_usable_size(void* mem) -{ - if (mem == 0) - return 0; - else - { - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); - unsigned int sz = p->size & ~(INUSE); - if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ))) - return 0; - else - return sz - MALLOC_MIN_OVERHEAD; - } -} - - - -void* realloc(void* mem, unsigned int bytes) -{ - if (mem == 0) - return malloc(bytes); - else - { - unsigned int nb = request2size(bytes); - mchunkptr p = mem2chunk(mem); - unsigned int oldsize = p->size; - int room; - mchunkptr nxt; - - UPDATE_STATS((++n_reallocs, requested_mem += bytes-oldsize)); - - /* try to expand (even if already big enough), to clean up chunk */ - - while (!inuse(nxt = next_chunk(p))) - { - UPDATE_STATS ((malloced_mem += nxt->size, ++n_consol)); - unlink(nxt); - set_size(p, p->size + nxt->size); - } - - room = p->size - nb; - if (room >= 0) - { - split(p, nb); - UPDATE_STATS(malloced_mem -= room); - return chunk2mem(p); - } - else /* do the obvious */ - { - void* newmem; - set_inuse(p); /* don't let malloc consolidate us yet! */ - newmem = malloc(nb); - bcopy(mem, newmem, oldsize - SIZE_SZ); - free(mem); - UPDATE_STATS(++n_reallocs_with_copy); - return newmem; - } - } -} - - - -/* return a pointer to space with at least the alignment requested */ - -void* memalign(unsigned int alignment, unsigned int bytes) -{ - mchunkptr p; - unsigned int nb = request2size(bytes); - - /* find an alignment that both we and the user can live with: */ - /* least common multiple guarantees mutual happiness */ - unsigned int align = lcm(alignment, MALLOC_MIN_OVERHEAD); - unsigned int mask = align - 1; - - /* call malloc with worst case padding to hit alignment; */ - /* we will give back extra */ - - unsigned int req = nb + align + MINSIZE; - void* m = malloc(req); - - if (m == 0) return m; - - p = mem2chunk(m); - - /* keep statistics on track */ - - UPDATE_STATS(--n_mallocs); - UPDATE_STATS(malloced_mem -= p->size); - UPDATE_STATS(requested_mem -= req); - UPDATE_STATS(requested_mem += bytes); - - if (((int)(m) & (mask)) != 0) /* misaligned */ - { - - /* find an aligned spot inside chunk */ - - mchunkptr ap = (mchunkptr)(( ((int)(m) + mask) & -align) - SIZE_SZ); - - unsigned int gap = (unsigned int)(ap) - (unsigned int)(p); - unsigned int room; - - /* we need to give back leading space in a chunk of at least MINSIZE */ - - if (gap < MINSIZE) - { - /* This works since align >= MINSIZE */ - /* and we've malloc'd enough total room */ - - ap = (mchunkptr)( (int)(ap) + align ); - gap += align; - } - - if (gap + nb > p->size) /* can't happen unless chunk sizes corrupted */ - malloc_user_error(); - - room = p->size - gap; - - /* give back leader */ - set_size(p, gap); - consollink(p); - - /* use the rest */ - p = ap; - set_size(p, room); - } - - /* also give back spare room at the end */ - - split(p, nb); - UPDATE_STATS(do_malloc_stats(p)); - return chunk2mem(p); - -} - -#ifndef sun -#include -#endif - -static unsigned int malloc_pagesize = 0; - -void* valloc(unsigned int bytes) -{ - if (malloc_pagesize == 0) malloc_pagesize = getpagesize(); - return memalign (malloc_pagesize, bytes); -} - - -void malloc_stats() -{ -#ifndef MALLOC_STATS -} -#else - int i; - mchunkptr p; - double nm = (double)(n_mallocs + n_reallocs); - - fprintf(stderr, "\nmalloc statistics\n\n"); - - if (n_mallocs != 0) - fprintf(stderr, "requests = %10u total size = %10u\tave = %10u\n", - n_mallocs, requested_mem, requested_mem/n_mallocs); - - if (n_mallocs != 0) - fprintf(stderr, "mallocs = %10u total size = %10u\tave = %10u\n", - n_mallocs, malloced_mem, malloced_mem/n_mallocs); - - if (n_frees != 0) - fprintf(stderr, "frees = %10u total size = %10u\tave = %10u\n", - n_frees, freed_mem, freed_mem/n_frees); - - if (n_mallocs-n_frees != 0) - fprintf(stderr, "in use = %10u total size = %10u\tave = %10u\n", - n_mallocs-n_frees, malloced_mem-freed_mem, - (malloced_mem-freed_mem) / (n_mallocs-n_frees)); - - if (max_inuse != 0) - fprintf(stderr, "max in use= %10u total size = %10u\tave = %10u\n", - max_inuse, max_used_mem, max_used_mem / max_inuse); - - if (n_avail != 0) - fprintf(stderr, "available = %10u total size = %10u\tave = %10u\n", - n_avail, sbrked_mem - (malloced_mem-freed_mem), - (sbrked_mem - (malloced_mem-freed_mem)) / n_avail); - - if (n_sbrks != 0) - fprintf(stderr, "sbrks = %10u total size = %10u\tave = %10u\n\n", - n_sbrks, sbrked_mem, sbrked_mem/ n_sbrks); - - if (n_reallocs != 0) - fprintf(stderr, "reallocs = %10u with copy = %10u\n\n", - n_reallocs, n_reallocs_with_copy); - - - if (nm != 0) - { - fprintf(stderr, "chunks scanned per malloc = %6.3f\n", - n_malloc_chunks / nm); - fprintf(stderr, "bins scanned per malloc = %6.3f\n", - n_malloc_bins / nm); - fprintf(stderr, "splits per malloc = %6.3f\n", - n_split / nm); - fprintf(stderr, "consolidations per malloc = %6.3f\n", - n_consol / nm); - } - - fprintf(stderr, "\nfree chunks:\n"); - for (i = 0; i < MAXBIN; ++i) - { - p = av[i].hd.fd; - if (p != &(av[i].hd)) - { - unsigned int count = 1; - unsigned int sz = p->size; - for (p = p->fd; p != &(av[i].hd); p = p->fd) - { - if (p->size == sz) - ++count; - else - { - fprintf(stderr, "\tsize = %10u count = %5u\n", sz, count); - count = 1; - sz = p->size; - } - } - - fprintf(stderr, "\tsize = %10u count = %5u\n", sz, count); - - } - } -} -#endif /* MALLOC_STATS */ - -#endif /* NO_LIBGXX_MALLOC */ diff --git a/gnu/lib/libg++/libg++/max.cc b/gnu/lib/libg++/libg++/max.cc deleted file mode 100644 index cb42168a4382..000000000000 --- a/gnu/lib/libg++/libg++/max.cc +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef __GNUG__ -#pragma implementation -#endif -#include diff --git a/gnu/lib/libg++/libg++/min.cc b/gnu/lib/libg++/libg++/min.cc deleted file mode 100644 index 7f0c9b5d0b4f..000000000000 --- a/gnu/lib/libg++/libg++/min.cc +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef __GNUG__ -#pragma implementation -#endif -#include diff --git a/gnu/lib/libg++/libg++/open.cc b/gnu/lib/libg++/libg++/open.cc deleted file mode 100644 index 7c13ee9ed150..000000000000 --- a/gnu/lib/libg++/libg++/open.cc +++ /dev/null @@ -1,46 +0,0 @@ -#include -#pragma implementation - -int open_cmd_arg(io_mode i, access_mode a) // decode modes -{ - int arg; - switch(i) - { - case io_readonly: arg = sio_read; break; - case io_writeonly: arg = sio_write; break; - case io_readwrite: arg = sio_readwrite; break; - case io_appendonly: arg = sio_append | sio_write; break; - case io_append: arg = sio_append | sio_readwrite; break; - default: return -1; - }; - switch(a) - { - case a_createonly: return arg | sa_createonly; - case a_create: return arg | sa_create | sa_truncate; - case a_useonly: return arg; - case a_use: return arg | sa_create; - default: return -1; - } -} - -char* fopen_cmd_arg(io_mode i) -{ - switch(i) - { - case io_readonly: return "r"; - case io_writeonly: return "w"; - case io_readwrite: return "r+"; - case io_appendonly:return "a"; - case io_append: return "a+"; - default: return 0; - } -} - -int open_cmd_arg(const char* m) -{ - if (m == 0) return -1; - else if (m[0] == 'r') return (m[1] == '+')? io_readwrite : io_readonly; - else if (m[0] == 'w') return (m[1] == '+')? io_readwrite : io_writeonly; - else if (m[0] == 'a') return (m[1] == '+')? io_append : io_appendonly; - else return -1; -} diff --git a/gnu/lib/libg++/libg++/ostream.cc b/gnu/lib/libg++/libg++/ostream.cc deleted file mode 100644 index adee1bd26748..000000000000 --- a/gnu/lib/libg++/libg++/ostream.cc +++ /dev/null @@ -1,224 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -/* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */ - -#ifdef __GNUG__ -#pragma implementation -#endif -#include -#include -#include -#include -#include - -ostream::ostream(streambuf* s) - : bp(s), state(_good), ownbuf(0) {} - -ostream::ostream(int sz, char* buf) - : state(_good), ownbuf(1) -{ - if (buf == 0) - { - buf = new char[sz]; - bp = new streambuf(buf, sz); - bp->setbuf(buf, sz); - bp->alloc = 1; - } - else - { - bp = new streambuf(buf, sz); - bp->alloc = 0; - } -} - - -ostream::ostream(const char* filename, io_mode m, access_mode a) - : state(_good), ownbuf(1) -{ - bp = new filebuf(filename, m, a); -} - -ostream::ostream(const char* filename, const char* m) - : state(_good), ownbuf(1) -{ - bp = new filebuf(filename, m); -} - -ostream::ostream(int filedesc, io_mode m) - : state(_good), ownbuf(1) -{ - bp = new filebuf(filedesc, m); -} - -ostream::ostream(FILE* fileptr) - : state(_good), ownbuf(1) -{ - bp = new filebuf(fileptr); -} - -ostream::ostream(int filedesc) - : state(_good), ownbuf(1) -{ - bp = new filebuf(filedesc); -} - -ostream::ostream(int filedesc, char* buf, int buflen) - : state(_good), ownbuf(1) -{ - bp = new filebuf(filedesc, buf, buflen); -} - -ostream::~ostream() -{ - if (ownbuf) delete bp; -} - -ostream& ostream::open(const char* filename, io_mode m, access_mode a) -{ - return failif(bp->open(filename, m, a) == 0); -} - -ostream& ostream::open(const char* filename, const char* m) -{ - return failif(bp->open(filename, m) == 0); -} - -ostream& ostream::open(int filedesc, io_mode m) -{ - return failif(bp->open(filedesc, m) == 0); -} - -ostream& ostream::open(FILE* fileptr) -{ - return failif(bp->open(fileptr) == 0); -} - -ostream& ostream::open(const char* filenam, open_mode m) -{ - return failif(bp->open(filenam, m) == 0); -} - -ostream& ostream::form(const char* fmt...) -{ - va_list args; - va_start(args, fmt); - char buf[BUFSIZ]; -#ifndef HAVE_VPRINTF - FILE b; - b._flag = _IOWRT|_IOSTRG; - b._ptr = buf; - b._cnt = BUFSIZ; - _doprnt(fmt, args, &b); - putc('\0', &b); -#else - vsprintf(buf, fmt, args); -#endif - va_end(args); - return put(buf); -} - -ostream& ostream::operator<<(short n) -{ - return put(itoa(long(n))); -} - -ostream& ostream::operator<<(unsigned short n) -{ - return put(itoa((unsigned long)(n))); -} - -ostream& ostream::operator<<(int n) -{ - return put(itoa(long(n))); -} - -ostream& ostream::operator<<(unsigned int n) -{ - return put(itoa((unsigned long)(n))); -} - -ostream& ostream::operator<<(long n) -{ - return put(itoa(n)); -} - -ostream& ostream::operator<<(unsigned long n) -{ - return put(itoa(n)); -} - -#ifdef __GNUG__ -#ifndef VMS -ostream& ostream::operator<<(long long n) -{ - return put(itoa(n)); -} - -ostream& ostream::operator<<(unsigned long long n) -{ - return put(itoa(n)); -} -#endif -#endif -ostream& ostream::operator<<(float n) -{ - return put(dtoa(double(n))); -} - -ostream& ostream::operator<<(double n) -{ - return put(dtoa(n)); -} - -ostream& ostream::operator<<(const void* p) -{ - put("0x"); - return put(itoa((unsigned long)(p), 16)); -} - - -const char* ostream::name() -{ - return bp->name(); -} - -void ostream::error() -{ - bp->error(); -} - -#if 0 /* BSD 4.4 */ - -ostream cerr(stderr); -ostream cout(stdout); - -#else - -static char cerrbuf[1]; -static char coutbuf[BUFSIZE]; - -ostream cerr(2, cerrbuf, 1); -ostream cout(1, coutbuf, BUFSIZE); - -#endif diff --git a/gnu/lib/libg++/libg++/std.cc b/gnu/lib/libg++/libg++/std.cc deleted file mode 100644 index d2bb1140a954..000000000000 --- a/gnu/lib/libg++/libg++/std.cc +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef __GNUG__ -#pragma implementation -#endif -#include diff --git a/gnu/lib/libg++/libg++/streambuf.cc b/gnu/lib/libg++/libg++/streambuf.cc deleted file mode 100644 index 4552433d88c5..000000000000 --- a/gnu/lib/libg++/libg++/streambuf.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* -Copyright (C) 1990 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - - -streambuf::streambuf() - :base(0), gptr(0), pptr(0), eptr(0), alloc(0) -{} - -streambuf::streambuf(char* buf, int buflen) - : base(buf), gptr(buf), pptr(buf), eptr(buf+buflen-1), alloc(0) -{} - -streambuf::~streambuf() -{ - if (alloc && (base != 0)) delete base; -} - -int streambuf::doallocate() -{ - if (alloc && base != 0) delete base; - base = new char[BUFSIZ]; - gptr = pptr = base; - eptr = base + BUFSIZ - 1; - alloc = 1; - return BUFSIZ; -} - -streambuf* streambuf::setbuf(char* buf, int buflen, int preloaded_count) -{ - if (alloc && (base != 0)) delete base; - alloc = 0; - base = gptr = buf; - pptr = base + preloaded_count; - eptr = base + buflen - 1; - return this; -} - -const char* streambuf::name() -{ - return 0; -} - -int streambuf::overflow(int c) -{ - if (base == 0) allocate(); - return (c == EOF)? c : ((pptr <= eptr)? (*pptr++ = (char)(c)) : EOF); -} - -int streambuf::underflow() -{ - return EOF; -} - -int streambuf::sputs(const char* s) -{ - if (s != 0) - { - for(; *s != 0; ++s) - { - if (must_overflow(*s)) { if (overflow(*s) == EOF) return EOF; } - else *pptr++ = *s; - } - } - return 0; -} - -int streambuf::sputsn(const char* s, int len) -{ - for(; --len >= 0; ++s) - { - if (must_overflow(*s)) { if (overflow(*s) == EOF) return EOF; } - else *pptr++ = *s; - } - return 0; -} - - -int streambuf::is_open() -{ - return 1; -} - -int streambuf::close() -{ - return 1; -} - -void streambuf::error() -{ - abort(); -} - -streambuf* streambuf::open(const char*, open_mode) -{ - return 0; -} - -streambuf* streambuf::open(const char*, io_mode, access_mode) -{ - return 0; -} -streambuf* streambuf::open(const char*, const char*) -{ - return 0; -} -streambuf* streambuf::open(int, io_mode) -{ - return 0; -} -streambuf* streambuf::open(FILE*) -{ - return 0; -} diff --git a/gnu/lib/libg++/libg++/xyzzy.cc b/gnu/lib/libg++/libg++/xyzzy.cc deleted file mode 100644 index 8008e05ea5f7..000000000000 --- a/gnu/lib/libg++/libg++/xyzzy.cc +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef NO_GNULIB3 -// from tiemann - -/* Needed, in case there are no other objects which - need static initialization and cleanup. */ -struct __xyzzy__ -{ - __xyzzy__ () {} - ~__xyzzy__ () {} -} __1xyzzy__; - -#endif diff --git a/gnu/lib/libregex/Makefile.in b/gnu/lib/libregex/Makefile.in deleted file mode 100644 index 7a5e3f9938be..000000000000 --- a/gnu/lib/libregex/Makefile.in +++ /dev/null @@ -1,100 +0,0 @@ -# Makefile for regex. -# -# Copyright (C) 1992, 1993 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. -# -# $Id: Makefile.in,v 1.2 1993/08/02 17:24:45 mycroft Exp $ - -version = 0.12 - -# You can define CPPFLAGS on the command line. Aside from system-specific -# flags, you can define: -# -DREGEX_MALLOC to use malloc/realloc/free instead of alloca. -# -DDEBUG to enable the compiled pattern disassembler and execution -# tracing; code runs substantially slower. -# -DEXTRACT_MACROS to use the macros EXTRACT_* (as opposed to -# the corresponding C procedures). If not -DDEBUG, the macros -# are used. -CPPFLAGS = - -# Likewise, you can override CFLAGS to optimize, use -Wall, etc. -CFLAGS = -g - -# Ditto for LDFLAGS and LOADLIBES. -LDFLAGS = -LOADLIBES = - -srcdir = @srcdir@ -VPATH = @srcdir@ - -CC = @CC@ -DEFS = @DEFS@ - -SHELL = /bin/sh - -subdirs = doc test - -default all:: regex.o -.PHONY: default all - -regex.o: regex.c regex.h - $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) -c $< - -clean mostlyclean:: - rm -f *.o - -distclean:: clean - rm -f Makefile config.status - -extraclean:: distclean - rm -f patch* *~* *\#* *.orig *.rej *.bak core a.out - -configure: configure.in - autoconf - -config.status: configure - sh configure --no-create - -Makefile: Makefile.in config.status - sh config.status - -makeargs = $(MFLAGS) CPPFLAGS='$(CPPFLAGS)' CFLAGS='$(CFLAGS)' CC='$(CC)' \ -DEFS='$(DEFS)' LDFLAGS='$(LDFLAGS)' LOADLIBES='$(LOADLIBES)' - -default all install \ -mostlyclean clean distclean extraclean realclean \ -TAGS check:: - for d in $(subdirs); do (cd $$d; $(MAKE) $(makeargs) $@); done -.PHONY: install mostlyclean clean distclean extraclean realclean TAGS check - -# Prevent GNU make 3 from overflowing arg limit on system V. -.NOEXPORT: - -distfiles = AUTHORS ChangeLog COPYING INSTALL NEWS README \ - *.in configure regex.c regex.h -distdir = regex-$(version) -distargs = version=$(version) distdir=../$(distdir)/$$d -dist: TAGS configure - @echo "Version numbers in: Makefile.in, ChangeLog, NEWS," - @echo " regex.c, regex.h," - @echo " and doc/xregex.texi (if modified)." - rm -rf $(distdir) - mkdir $(distdir) - ln $(distfiles) $(distdir) - for d in $(subdirs); do (cd $$d; $(MAKE) $(distargs) dist); done - tar czhf $(distdir).tar.Z $(distdir) - rm -rf $(distdir) -.PHONY: dist diff --git a/gnu/lib/libregex/NEWS b/gnu/lib/libregex/NEWS deleted file mode 100644 index b3a899b4568c..000000000000 --- a/gnu/lib/libregex/NEWS +++ /dev/null @@ -1,62 +0,0 @@ -Version 0.12 - -* regex.c does not #define bcmp/bcopy/bzero if they already are. - -* regex.h does not redefine `const' if it is already defined, even if - __STDC__ is not defined. - -* RE_SYNTAX_ED added (same as POSIX BRE's). - -* The following bugs have been fixed, among others: - * The pattern \w+ doesn't infinite loop. - * The pattern ".+\n" is compiled correctly. - * Expressions with more than MAX_REGNUM groups are compiled correctly. - -* Patterns that end in a repetition operator (e.g., `*') match - slightly faster if no looping is actually necessary. - -Version 0.11 (17 Sep 92) - -* Back-references to nonexistent subexpressions, as in the r.e. `abc\1', - are always invalid. Previously, they could match the literal digit, - e.g., the stated r.e. might have matched `abc1'. - -* Empty subexpressions are always valid (POSIX leaves this undefined). - -* Simplified rules for ^ and $ being anchors. - -* One minor speedup (rewriting the C procedure `pop_failure_point' as a - macro again). - -* Bug fixes involving: - - Declarations in regex.h and non-ANSI compilers. - - Bracket expressions with characters between 0x80-0xff. - - Memory leak in re_match_2 on systems requiring `alloca (0)' to - free alloca'd storage. - -* Test and documentation files moved into subdirectories. - -Version 0.10 (9 Sep 92) - -* `obscure_syntax' is now called `re_default_syntax'. - -* `re_comp's return type is no longer `const', for compatibility with BSD. - -* POSIX syntaxes now include as much functionality as possible - (consistent with the standard). - -* Compilation conditionals normalized to what the rest of GNU is - migrating towards these days. - -* Bug fixes involving: - - Ranges with characters between 0x80 and 0xff, e.g., [\001-\377]. - - `re_compile_fastmap' and the sequence `.*\n'. - - Intervals with exact counts, e.g., a{5}. - -* Changed distribution to use a standard Makefile, install the info - files, use a configure script, etc. - -Version 0.9 - -* The longest match was not always chosen: `a*|ab' didn't match `aab'. - diff --git a/gnu/lib/libregex/README b/gnu/lib/libregex/README deleted file mode 100644 index 918e1a03b821..000000000000 --- a/gnu/lib/libregex/README +++ /dev/null @@ -1,60 +0,0 @@ -This directory contains the GNU regex library. It is compliant with -POSIX.2, except for internationalization features. - -See the file NEWS for a list of major changes in the current release. - -See the file INSTALL for compilation instructions. (The only thing -installed is the documentation; regex.c is compiled into regex.o, but -not installed anywhere.) - -The subdirectory `doc' contains a (programmers') manual for the library. -It's probably out-of-date. Improvements are welcome. - -The subdirectory `test' contains the various tests we've written. - -We know this code is not as fast as it might be. If you have specific -suggestions, profiling results, or other such useful information to -report, please do. - -Emacs 18 is not going use this revised regex (but Emacs 19 will). If -you want to try it with Emacs 18, apply the patch at the end of this -file first. - -Mail bug reports to bug-gnu-utils@prep.ai.mit.edu. - -Please include an actual regular expression that fails (and the syntax -used to compile it); without that, there's no way to reproduce the bug, -so there's no way we can fix it. Even if you include a patch, also -include the regular expression in error; otherwise, we can't know for -sure what you're trying to fix. - -Here is the patch to make this version of regex work with Emacs 18. - -*** ORIG/search.c Tue Jan 8 13:04:55 1991 ---- search.c Sun Jan 5 10:57:00 1992 -*************** -*** 25,26 **** ---- 25,28 ---- - #include "commands.h" -+ -+ #include - #include "regex.h" -*************** -*** 477,479 **** - /* really needed. */ -! && *(searchbuf.buffer) == (char) exactn /* first item is "exact match" */ - && searchbuf.buffer[1] + 2 == searchbuf.used) /*first is ONLY item */ ---- 479,482 ---- - /* really needed. */ -! /* first item is "exact match" */ -! && *(searchbuf.buffer) == (char) RE_EXACTN_VALUE - && searchbuf.buffer[1] + 2 == searchbuf.used) /*first is ONLY item */ -*************** -*** 1273,1275 **** - searchbuf.allocated = 100; -! searchbuf.buffer = (char *) malloc (searchbuf.allocated); - searchbuf.fastmap = search_fastmap; ---- 1276,1278 ---- - searchbuf.allocated = 100; -! searchbuf.buffer = (unsigned char *) malloc (searchbuf.allocated); - searchbuf.fastmap = search_fastmap; diff --git a/gnu/lib/libregex/VERSION b/gnu/lib/libregex/VERSION deleted file mode 100644 index 7182be23ebdd..000000000000 --- a/gnu/lib/libregex/VERSION +++ /dev/null @@ -1,3 +0,0 @@ -GNU regex version 0.12 - -complete, unmodified regex sources are available from prep.ai.mit.edu. diff --git a/gnu/lib/libregex/config.status b/gnu/lib/libregex/config.status deleted file mode 100644 index 1b276aacf34c..000000000000 --- a/gnu/lib/libregex/config.status +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# Generated automatically by configure. -# Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host sun-lamp.cs.berkeley.edu: -# -# configure - -for arg -do - case "$arg" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - exec /bin/sh configure ;; - *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;; - esac -done - -trap 'rm -f Makefile doc/Makefile test/Makefile; exit 1' 1 3 15 -CC='gcc' -INSTALL='/usr/bin/install -c' -INSTALL_PROGRAM='$(INSTALL)' -INSTALL_DATA='$(INSTALL) -m 644' -CPP='${CC-cc} -E' -ALLOCA='' -LIBS='' -srcdir='.' -DEFS=' -DHAVE_STRING_H=1' -prefix='/usr' -exec_prefix='${prefix}' -prsub='s%^prefix\([ ]*\)=\([ ]*\).*$%prefix\1=\2/usr% -s%^exec_prefix\([ ]*\)=\([ ]*\).*$%exec_prefix\1=\2${prefix}%' - -top_srcdir=$srcdir -for file in .. Makefile doc/Makefile test/Makefile; do if [ "x$file" != "x.." ]; then - srcdir=$top_srcdir - # Remove last slash and all that follows it. Not all systems have dirname. - dir=`echo $file|sed 's%/[^/][^/]*$%%'` - if test "$dir" != "$file"; then - test "$top_srcdir" != . && srcdir=$top_srcdir/$dir - test ! -d $dir && mkdir $dir - fi - echo creating $file - rm -f $file - echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file - sed -e " -$prsub -s%@CC@%$CC%g -s%@INSTALL@%$INSTALL%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@CPP@%$CPP%g -s%@ALLOCA@%$ALLOCA%g -s%@LIBS@%$LIBS%g -s%@srcdir@%$srcdir%g -s%@DEFS@%$DEFS% -" $top_srcdir/${file}.in >> $file -fi; done - -exit 0 diff --git a/gnu/lib/libregex/configure b/gnu/lib/libregex/configure deleted file mode 100644 index 29c5b803c329..000000000000 --- a/gnu/lib/libregex/configure +++ /dev/null @@ -1,462 +0,0 @@ -#!/bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf. -# Copyright (C) 1991, 1992, 1993 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: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [--no-create] -# [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE] [TARGET] -# Ignores all args except --srcdir, --prefix, --exec-prefix, --no-create, and -# --with-PACKAGE unless this script has special code to handle it. - - -for arg -do - # Handle --exec-prefix with a space before the argument. - if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix= - # Handle --host with a space before the argument. - elif test x$next_host = xyes; then next_host= - # Handle --prefix with a space before the argument. - elif test x$next_prefix = xyes; then prefix=$arg; next_prefix= - # Handle --srcdir with a space before the argument. - elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir= - else - case $arg in - # For backward compatibility, also recognize exact --exec_prefix. - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*) - exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;; - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e) - next_exec_prefix=yes ;; - - -gas | --gas | --ga | --g) ;; - - -host=* | --host=* | --hos=* | --ho=* | --h=*) ;; - -host | --host | --hos | --ho | --h) - next_host=yes ;; - - -nfp | --nfp | --nf) ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no) - no_create=1 ;; - - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;; - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - next_prefix=yes ;; - - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*) - srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;; - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s) - next_srcdir=yes ;; - - -with-* | --with-*) - package=`echo $arg|sed 's/-*with-//'` - # Delete all the valid chars; see if any are left. - if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then - echo "configure: $package: invalid package name" >&2; exit 1 - fi - eval "with_`echo $package|sed s/-/_/g`=1" ;; - - *) ;; - esac - fi -done - -trap 'rm -f conftest* core; exit 1' 1 3 15 - -rm -f conftest* -compile='${CC-cc} $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1' - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -unique_file=regex.c - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - srcdirdefaulted=yes - # Try the directory containing this script, then `..'. - prog=$0 - confdir=`echo $prog|sed 's%/[^/][^/]*$%%'` - test "X$confdir" = "X$prog" && confdir=. - srcdir=$confdir - if test ! -r $srcdir/$unique_file; then - srcdir=.. - fi -fi -if test ! -r $srcdir/$unique_file; then - if test x$srcdirdefaulted = xyes; then - echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2 - else - echo "configure: Can not find sources in \`${srcdir}'." 1>&2 - fi - exit 1 -fi -# Preserve a srcdir of `.' to avoid automounter screwups with pwd. -# But we can't avoid them for `..', to make subdirectories work. -case $srcdir in - .|/*|~*) ;; - *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute. -esac - - -if test -z "$CC"; then - echo checking for gcc - saveifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - test -z "$dir" && dir=. - if test -f $dir/gcc; then - CC="gcc" - break - fi - done - IFS="$saveifs" -fi -test -z "$CC" && CC="cc" - -# Find out if we are using GNU C, under whatever name. -cat > conftest.c < conftest.out 2>&1 -if egrep yes conftest.out >/dev/null 2>&1; then - GCC=1 # For later tests. -fi -rm -f conftest* - -# Make sure to not get the incompatible SysV /etc/install and -# /usr/sbin/install, which might be in PATH before a BSD-like install, -# or the SunOS /usr/etc/install directory, or the AIX /bin/install, -# or the AFS install, which mishandles nonexistent args. (Sigh.) -if test -z "$INSTALL"; then - echo checking for install - saveifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - test -z "$dir" && dir=. - case $dir in - /etc|/usr/sbin|/usr/etc|/usr/afsws/bin) ;; - *) - if test -f $dir/install; then - if grep dspmsg $dir/install >/dev/null 2>&1; then - : # AIX - else - INSTALL="$dir/install -c" - INSTALL_PROGRAM='$(INSTALL)' - INSTALL_DATA='$(INSTALL) -m 644' - break - fi - fi - ;; - esac - done - IFS="$saveifs" -fi -INSTALL=${INSTALL-cp} -INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'} -INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'} - - -echo checking for AIX -echo checking how to run the C preprocessor -if test -z "$CPP"; then - CPP='${CC-cc} -E' - cat > conftest.c < -EOF -err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` -if test -z "$err"; then - : -else - CPP=/lib/cpp -fi -rm -f conftest* -fi - -cat > conftest.c < conftest.out 2>&1" -if egrep "yes" conftest.out >/dev/null 2>&1; then - DEFS="$DEFS -D_ALL_SOURCE=1" -fi -rm -f conftest* - - -echo checking for DYNIX/ptx libseq -cat > conftest.c < conftest.out 2>&1" -if egrep "yes" conftest.out >/dev/null 2>&1; then - SEQUENT=1 -fi -rm -f conftest* - -test -n "$SEQUENT" && test -f /usr/lib/libseq.a && - LIBS="$LIBS -lseq" - -echo checking for POSIXized ISC -if test -d /etc/conf/kconfig.d && - grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 -then - ISC=1 # If later tests want to check for ISC. - DEFS="$DEFS -D_POSIX_SOURCE=1" - if test -n "$GCC"; then - CC="$CC -posix" - else - CC="$CC -Xp" - fi -fi - -echo checking for minix/config.h -cat > conftest.c < -EOF -err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` -if test -z "$err"; then - MINIX=1 -fi -rm -f conftest* - -# The Minix shell can't assign to the same variable on the same line! -if test -n "$MINIX"; then - DEFS="$DEFS -D_POSIX_SOURCE=1" - DEFS="$DEFS -D_POSIX_1_SOURCE=2" - DEFS="$DEFS -D_MINIX=1" -fi - - -echo checking for ANSI C header files -cat > conftest.c < -#include -#include -#include -EOF -err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` -if test -z "$err"; then - # SunOS string.h does not declare mem*, contrary to ANSI. -echo '#include ' > conftest.c -eval "$CPP $DEFS conftest.c > conftest.out 2>&1" -if egrep "memchr" conftest.out >/dev/null 2>&1; then - # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -cat > conftest.c < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e,f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -eval $compile -if test -s conftest && (./conftest; exit) 2>/dev/null; then - DEFS="$DEFS -DSTDC_HEADERS=1" -fi -rm -f conftest* -fi -rm -f conftest* - -fi -rm -f conftest* - -for hdr in string.h -do -trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'` -echo checking for ${hdr} -cat > conftest.c < -EOF -err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` -if test -z "$err"; then - DEFS="$DEFS -D${trhdr}=1" -fi -rm -f conftest* -done - - -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -echo checking for working alloca.h -cat > conftest.c < -main() { exit(0); } -t() { char *p = alloca(2 * sizeof(int)); } -EOF -if eval $compile; then - DEFS="$DEFS -DHAVE_ALLOCA_H=1" -fi -rm -f conftest* - -decl="#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#if HAVE_ALLOCA_H -#include -#else -#ifdef _AIX - #pragma alloca -#else -char *alloca (); -#endif -#endif -#endif -" -echo checking for alloca -cat > conftest.c < conftest.c < config.status </dev/null`: -# -# $0 $* - -for arg -do - case "\$arg" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - exec /bin/sh $0 $* ;; - *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;; - esac -done - -trap 'rm -f Makefile doc/Makefile test/Makefile; exit 1' 1 3 15 -CC='$CC' -INSTALL='$INSTALL' -INSTALL_PROGRAM='$INSTALL_PROGRAM' -INSTALL_DATA='$INSTALL_DATA' -CPP='$CPP' -ALLOCA='$ALLOCA' -LIBS='$LIBS' -srcdir='$srcdir' -DEFS='$DEFS' -prefix='$prefix' -exec_prefix='$exec_prefix' -prsub='$prsub' -EOF -cat >> config.status <<\EOF - -top_srcdir=$srcdir -for file in .. Makefile doc/Makefile test/Makefile; do if [ "x$file" != "x.." ]; then - srcdir=$top_srcdir - # Remove last slash and all that follows it. Not all systems have dirname. - dir=`echo $file|sed 's%/[^/][^/]*$%%'` - if test "$dir" != "$file"; then - test "$top_srcdir" != . && srcdir=$top_srcdir/$dir - test ! -d $dir && mkdir $dir - fi - echo creating $file - rm -f $file - echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file - sed -e " -$prsub -s%@CC@%$CC%g -s%@INSTALL@%$INSTALL%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@CPP@%$CPP%g -s%@ALLOCA@%$ALLOCA%g -s%@LIBS@%$LIBS%g -s%@srcdir@%$srcdir%g -s%@DEFS@%$DEFS% -" $top_srcdir/${file}.in >> $file -fi; done - -exit 0 -EOF -chmod +x config.status -test -n "$no_create" || ./config.status - diff --git a/gnu/lib/libregex/configure.in b/gnu/lib/libregex/configure.in deleted file mode 100644 index f0fc78025095..000000000000 --- a/gnu/lib/libregex/configure.in +++ /dev/null @@ -1,23 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -AC_INIT(regex.c) - -AC_PROG_CC -AC_PROG_INSTALL - -dnl I'm not sure if AC_AIX and AC_DYNIX_SEQ are really necessary. The -dnl Autoconf documentation isn't specific about which BSD functions they -dnl provide. -AC_AIX -AC_DYNIX_SEQ -AC_ISC_POSIX -AC_MINIX - -AC_STDC_HEADERS -AC_HAVE_HEADERS(string.h) - -AC_ALLOCA -AC_CONST - -AC_PREFIX(gcc) - -AC_OUTPUT(Makefile doc/Makefile test/Makefile) diff --git a/gnu/lib/libregex/doc/regex.info b/gnu/lib/libregex/doc/regex.info deleted file mode 100644 index 90deedeaf44f..000000000000 --- a/gnu/lib/libregex/doc/regex.info +++ /dev/null @@ -1,2836 +0,0 @@ -This is Info file regex.info, produced by Makeinfo-1.52 from the input -file .././doc/regex.texi. - - This file documents the GNU regular expression library. - - Copyright (C) 1992, 1993 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 also that the -section entitled "GNU General Public License" is included exactly as in -the original, and 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 the section entitled "GNU General Public License" -may be included in a translation approved by the Free Software -Foundation instead of in the original English. - - -File: regex.info, Node: Top, Next: Overview, Prev: (dir), Up: (dir) - -Regular Expression Library -************************** - - This manual documents how to program with the GNU regular expression -library. This is edition 0.12a of the manual, 19 September 1992. - - The first part of this master menu lists the major nodes in this Info -document, including the index. The rest of the menu lists all the -lower level nodes in the document. - -* Menu: - -* Overview:: -* Regular Expression Syntax:: -* Common Operators:: -* GNU Operators:: -* GNU Emacs Operators:: -* What Gets Matched?:: -* Programming with Regex:: -* Copying:: Copying and sharing Regex. -* Index:: General index. - -- The Detailed Node Listing -- - -Regular Expression Syntax - -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: - -Common Operators - -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? {} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ - -Repetition Operators - -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: {} - -List Operators (`[' ... `]' and `[^' ... `]') - -* Character Class Operators:: [:class:] -* Range Operator:: start-end - -Anchoring Operators - -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ - -GNU Operators - -* Word Operators:: -* Buffer Operators:: - -Word Operators - -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W - -Buffer Operators - -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' - -GNU Emacs Operators - -* Syntactic Class Operators:: - -Syntactic Class Operators - -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS - -Programming with Regex - -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: - -GNU Regex Functions - -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () - -POSIX Regex Functions - -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () - -BSD Regex Functions - -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () - - -File: regex.info, Node: Overview, Next: Regular Expression Syntax, Prev: Top, Up: Top - -Overview -******** - - A "regular expression" (or "regexp", or "pattern") is a text string -that describes some (mathematical) set of strings. A regexp R -"matches" a string S if S is in the set of strings described by R. - - Using the Regex library, you can: - - * see if a string matches a specified pattern as a whole, and - - * search within a string for a substring matching a specified - pattern. - - Some regular expressions match only one string, i.e., the set they -describe has only one member. For example, the regular expression -`foo' matches the string `foo' and no others. Other regular -expressions match more than one string, i.e., the set they describe has -more than one member. For example, the regular expression `f*' matches -the set of strings made up of any number (including zero) of `f's. As -you can see, some characters in regular expressions match themselves -(such as `f') and some don't (such as `*'); the ones that don't match -themselves instead let you specify patterns that describe many -different strings. - - To either match or search for a regular expression with the Regex -library functions, you must first compile it with a Regex pattern -compiling function. A "compiled pattern" is a regular expression -converted to the internal format used by the library functions. Once -you've compiled a pattern, you can use it for matching or searching any -number of times. - - The Regex library consists of two source files: `regex.h' and -`regex.c'. Regex provides three groups of functions with which you can -operate on regular expressions. One group--the GNU group--is more -powerful but not completely compatible with the other two, namely the -POSIX and Berkeley UNIX groups; its interface was designed specifically -for GNU. The other groups have the same interfaces as do the regular -expression functions in POSIX and Berkeley UNIX. - - We wrote this chapter with programmers in mind, not users of -programs--such as Emacs--that use Regex. We describe the Regex library -in its entirety, not how to write regular expressions that a particular -program understands. - - -File: regex.info, Node: Regular Expression Syntax, Next: Common Operators, Prev: Overview, Up: Top - -Regular Expression Syntax -************************* - - "Characters" are things you can type. "Operators" are things in a -regular expression that match one or more characters. You compose -regular expressions from operators, which in turn you specify using one -or more characters. - - Most characters represent what we call the match-self operator, i.e., -they match themselves; we call these characters "ordinary". Other -characters represent either all or parts of fancier operators; e.g., -`.' represents what we call the match-any-character operator (which, no -surprise, matches (almost) any character); we call these characters -"special". Two different things determine what characters represent -what operators: - - 1. the regular expression syntax your program has told the Regex - library to recognize, and - - 2. the context of the character in the regular expression. - - In the following sections, we describe these things in more detail. - -* Menu: - -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: - - -File: regex.info, Node: Syntax Bits, Next: Predefined Syntaxes, Up: Regular Expression Syntax - -Syntax Bits -=========== - - In any particular syntax for regular expressions, some characters are -always special, others are sometimes special, and others are never -special. The particular syntax that Regex recognizes for a given -regular expression depends on the value in the `syntax' field of the -pattern buffer of that regular expression. - - You get a pattern buffer by compiling a regular expression. *Note -GNU Pattern Buffers::, and *Note POSIX Pattern Buffers::, for more -information on pattern buffers. *Note GNU Regular Expression -Compiling::, *Note POSIX Regular Expression Compiling::, and *Note BSD -Regular Expression Compiling::, for more information on compiling. - - Regex considers the value of the `syntax' field to be a collection of -bits; we refer to these bits as "syntax bits". In most cases, they -affect what characters represent what operators. We describe the -meanings of the operators to which we refer in *Note Common Operators::, -*Note GNU Operators::, and *Note GNU Emacs Operators::. - - For reference, here is the complete list of syntax bits, in -alphabetical order: - -`RE_BACKSLASH_ESCAPE_IN_LISTS' - If this bit is set, then `\' inside a list (*note List Operators::. - quotes (makes ordinary, if it's special) the following character; - if this bit isn't set, then `\' is an ordinary character inside - lists. (*Note The Backslash Character::, for what `\' does - outside of lists.) - -`RE_BK_PLUS_QM' - If this bit is set, then `\+' represents the match-one-or-more - operator and `\?' represents the match-zero-or-more operator; if - this bit isn't set, then `+' represents the match-one-or-more - operator and `?' represents the match-zero-or-one operator. This - bit is irrelevant if `RE_LIMITED_OPS' is set. - -`RE_CHAR_CLASSES' - If this bit is set, then you can use character classes in lists; - if this bit isn't set, then you can't. - -`RE_CONTEXT_INDEP_ANCHORS' - If this bit is set, then `^' and `$' are special anywhere outside - a list; if this bit isn't set, then these characters are special - only in certain contexts. *Note Match-beginning-of-line - Operator::, and *Note Match-end-of-line Operator::. - -`RE_CONTEXT_INDEP_OPS' - If this bit is set, then certain characters are special anywhere - outside a list; if this bit isn't set, then those characters are - special only in some contexts and are ordinary elsewhere. - Specifically, if this bit isn't set then `*', and (if the syntax - bit `RE_LIMITED_OPS' isn't set) `+' and `?' (or `\+' and `\?', - depending on the syntax bit `RE_BK_PLUS_QM') represent repetition - operators only if they're not first in a regular expression or - just after an open-group or alternation operator. The same holds - for `{' (or `\{', depending on the syntax bit `RE_NO_BK_BRACES') if - it is the beginning of a valid interval and the syntax bit - `RE_INTERVALS' is set. - -`RE_CONTEXT_INVALID_OPS' - If this bit is set, then repetition and alternation operators - can't be in certain positions within a regular expression. - Specifically, the regular expression is invalid if it has: - - * a repetition operator first in the regular expression or just - after a match-beginning-of-line, open-group, or alternation - operator; or - - * an alternation operator first or last in the regular - expression, just before a match-end-of-line operator, or just - after an alternation or open-group operator. - - If this bit isn't set, then you can put the characters - representing the repetition and alternation characters anywhere in - a regular expression. Whether or not they will in fact be - operators in certain positions depends on other syntax bits. - -`RE_DOT_NEWLINE' - If this bit is set, then the match-any-character operator matches - a newline; if this bit isn't set, then it doesn't. - -`RE_DOT_NOT_NULL' - If this bit is set, then the match-any-character operator doesn't - match a null character; if this bit isn't set, then it does. - -`RE_INTERVALS' - If this bit is set, then Regex recognizes interval operators; if - this bit isn't set, then it doesn't. - -`RE_LIMITED_OPS' - If this bit is set, then Regex doesn't recognize the - match-one-or-more, match-zero-or-one or alternation operators; if - this bit isn't set, then it does. - -`RE_NEWLINE_ALT' - If this bit is set, then newline represents the alternation - operator; if this bit isn't set, then newline is ordinary. - -`RE_NO_BK_BRACES' - If this bit is set, then `{' represents the open-interval operator - and `}' represents the close-interval operator; if this bit isn't - set, then `\{' represents the open-interval operator and `\}' - represents the close-interval operator. This bit is relevant only - if `RE_INTERVALS' is set. - -`RE_NO_BK_PARENS' - If this bit is set, then `(' represents the open-group operator and - `)' represents the close-group operator; if this bit isn't set, - then `\(' represents the open-group operator and `\)' represents - the close-group operator. - -`RE_NO_BK_REFS' - If this bit is set, then Regex doesn't recognize `\'DIGIT as the - back reference operator; if this bit isn't set, then it does. - -`RE_NO_BK_VBAR' - If this bit is set, then `|' represents the alternation operator; - if this bit isn't set, then `\|' represents the alternation - operator. This bit is irrelevant if `RE_LIMITED_OPS' is set. - -`RE_NO_EMPTY_RANGES' - If this bit is set, then a regular expression with a range whose - ending point collates lower than its starting point is invalid; if - this bit isn't set, then Regex considers such a range to be empty. - -`RE_UNMATCHED_RIGHT_PAREN_ORD' - If this bit is set and the regular expression has no matching - open-group operator, then Regex considers what would otherwise be - a close-group operator (based on how `RE_NO_BK_PARENS' is set) to - match `)'. - - -File: regex.info, Node: Predefined Syntaxes, Next: Collating Elements vs. Characters, Prev: Syntax Bits, Up: Regular Expression Syntax - -Predefined Syntaxes -=================== - - If you're programming with Regex, you can set a pattern buffer's -(*note GNU Pattern Buffers::., and *Note POSIX Pattern Buffers::) -`syntax' field either to an arbitrary combination of syntax bits (*note -Syntax Bits::.) or else to the configurations defined by Regex. These -configurations define the syntaxes used by certain programs--GNU Emacs, -POSIX Awk, traditional Awk, Grep, Egrep--in addition to syntaxes for -POSIX basic and extended regular expressions. - - The predefined syntaxes-taken directly from `regex.h'--are: - - #define RE_SYNTAX_EMACS 0 - - #define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - - #define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) - - #define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - - #define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - - #define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) - - /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ - #define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - - #define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - - /* Syntax bits common to both basic and extended POSIX regex syntax. */ - #define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - - #define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) - - /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ - #define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - - #define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - - /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS - replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ - #define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) - - -File: regex.info, Node: Collating Elements vs. Characters, Next: The Backslash Character, Prev: Predefined Syntaxes, Up: Regular Expression Syntax - -Collating Elements vs. Characters -================================= - - POSIX generalizes the notion of a character to that of a collating -element. It defines a "collating element" to be "a sequence of one or -more bytes defined in the current collating sequence as a unit of -collation." - - This generalizes the notion of a character in two ways. First, a -single character can map into two or more collating elements. For -example, the German "es-zet" collates as the collating element `s' -followed by another collating element `s'. Second, two or more -characters can map into one collating element. For example, the -Spanish `ll' collates after `l' and before `m'. - - Since POSIX's "collating element" preserves the essential idea of a -"character," we use the latter, more familiar, term in this document. - - -File: regex.info, Node: The Backslash Character, Prev: Collating Elements vs. Characters, Up: Regular Expression Syntax - -The Backslash Character -======================= - - The `\' character has one of four different meanings, depending on -the context in which you use it and what syntax bits are set (*note -Syntax Bits::.). It can: 1) stand for itself, 2) quote the next -character, 3) introduce an operator, or 4) do nothing. - - 1. It stands for itself inside a list (*note List Operators::.) if - the syntax bit `RE_BACKSLASH_ESCAPE_IN_LISTS' is not set. For - example, `[\]' would match `\'. - - 2. It quotes (makes ordinary, if it's special) the next character - when you use it either: - - * outside a list,(1) or - - * inside a list and the syntax bit - `RE_BACKSLASH_ESCAPE_IN_LISTS' is set. - - 3. It introduces an operator when followed by certain ordinary - characters--sometimes only when certain syntax bits are set. See - the cases `RE_BK_PLUS_QM', `RE_NO_BK_BRACES', `RE_NO_BK_VAR', - `RE_NO_BK_PARENS', `RE_NO_BK_REF' in *Note Syntax Bits::. Also: - - * `\b' represents the match-word-boundary operator (*note - Match-word-boundary Operator::.). - - * `\B' represents the match-within-word operator (*note - Match-within-word Operator::.). - - * `\<' represents the match-beginning-of-word operator - (*note Match-beginning-of-word Operator::.). - - * `\>' represents the match-end-of-word operator (*note - Match-end-of-word Operator::.). - - * `\w' represents the match-word-constituent operator (*note - Match-word-constituent Operator::.). - - * `\W' represents the match-non-word-constituent operator - (*note Match-non-word-constituent Operator::.). - - * `\`' represents the match-beginning-of-buffer operator and - `\'' represents the match-end-of-buffer operator (*note - Buffer Operators::.). - - * If Regex was compiled with the C preprocessor symbol `emacs' - defined, then `\sCLASS' represents the match-syntactic-class - operator and `\SCLASS' represents the - match-not-syntactic-class operator (*note Syntactic Class - Operators::.). - - 4. In all other cases, Regex ignores `\'. For example, `\n' matches - `n'. - - - ---------- Footnotes ---------- - - (1) Sometimes you don't have to explicitly quote special characters -to make them ordinary. For instance, most characters lose any special -meaning inside a list (*note List Operators::.). In addition, if the -syntax bits `RE_CONTEXT_INVALID_OPS' and `RE_CONTEXT_INDEP_OPS' aren't -set, then (for historical reasons) the matcher considers special -characters ordinary if they are in contexts where the operations they -represent make no sense; for example, then the match-zero-or-more -operator (represented by `*') matches itself in the regular expression -`*foo' because there is no preceding expression on which it can -operate. It is poor practice, however, to depend on this behavior; if -you want a special character to be ordinary outside a list, it's better -to always quote it, regardless. - - -File: regex.info, Node: Common Operators, Next: GNU Operators, Prev: Regular Expression Syntax, Up: Top - -Common Operators -**************** - - You compose regular expressions from operators. In the following -sections, we describe the regular expression operators specified by -POSIX; GNU also uses these. Most operators have more than one -representation as characters. *Note Regular Expression Syntax::, for -what characters represent what operators under what circumstances. - - For most operators that can be represented in two ways, one -representation is a single character and the other is that character -preceded by `\'. For example, either `(' or `\(' represents the -open-group operator. Which one does depends on the setting of a syntax -bit, in this case `RE_NO_BK_PARENS'. Why is this so? Historical -reasons dictate some of the varying representations, while POSIX -dictates others. - - Finally, almost all characters lose any special meaning inside a list -(*note List Operators::.). - -* Menu: - -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? {} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ - - -File: regex.info, Node: Match-self Operator, Next: Match-any-character Operator, Up: Common Operators - -The Match-self Operator (ORDINARY CHARACTER) -============================================ - - This operator matches the character itself. All ordinary characters -(*note Regular Expression Syntax::.) represent this operator. For -example, `f' is always an ordinary character, so the regular expression -`f' matches only the string `f'. In particular, it does *not* match -the string `ff'. - - -File: regex.info, Node: Match-any-character Operator, Next: Concatenation Operator, Prev: Match-self Operator, Up: Common Operators - -The Match-any-character Operator (`.') -====================================== - - This operator matches any single printing or nonprinting character -except it won't match a: - -newline - if the syntax bit `RE_DOT_NEWLINE' isn't set. - -null - if the syntax bit `RE_DOT_NOT_NULL' is set. - - The `.' (period) character represents this operator. For example, -`a.b' matches any three-character string beginning with `a' and ending -with `b'. - - -File: regex.info, Node: Concatenation Operator, Next: Repetition Operators, Prev: Match-any-character Operator, Up: Common Operators - -The Concatenation Operator -========================== - - This operator concatenates two regular expressions A and B. No -character represents this operator; you simply put B after A. The -result is a regular expression that will match a string if A matches -its first part and B matches the rest. For example, `xy' (two -match-self operators) matches `xy'. - - -File: regex.info, Node: Repetition Operators, Next: Alternation Operator, Prev: Concatenation Operator, Up: Common Operators - -Repetition Operators -==================== - - Repetition operators repeat the preceding regular expression a -specified number of times. - -* Menu: - -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: {} - - -File: regex.info, Node: Match-zero-or-more Operator, Next: Match-one-or-more Operator, Up: Repetition Operators - -The Match-zero-or-more Operator (`*') -------------------------------------- - - This operator repeats the smallest possible preceding regular -expression as many times as necessary (including zero) to match the -pattern. `*' represents this operator. For example, `o*' matches any -string made up of zero or more `o's. Since this operator operates on -the smallest preceding regular expression, `fo*' has a repeating `o', -not a repeating `fo'. So, `fo*' matches `f', `fo', `foo', and so on. - - Since the match-zero-or-more operator is a suffix operator, it may be -useless as such when no regular expression precedes it. This is the -case when it: - - * is first in a regular expression, or - - * follows a match-beginning-of-line, open-group, or alternation - operator. - -Three different things can happen in these cases: - - 1. If the syntax bit `RE_CONTEXT_INVALID_OPS' is set, then the - regular expression is invalid. - - 2. If `RE_CONTEXT_INVALID_OPS' isn't set, but `RE_CONTEXT_INDEP_OPS' - is, then `*' represents the match-zero-or-more operator (which - then operates on the empty string). - - 3. Otherwise, `*' is ordinary. - - - The matcher processes a match-zero-or-more operator by first matching -as many repetitions of the smallest preceding regular expression as it -can. Then it continues to match the rest of the pattern. - - If it can't match the rest of the pattern, it backtracks (as many -times as necessary), each time discarding one of the matches until it -can either match the entire pattern or be certain that it cannot get a -match. For example, when matching `ca*ar' against `caaar', the matcher -first matches all three `a's of the string with the `a*' of the regular -expression. However, it cannot then match the final `ar' of the -regular expression against the final `r' of the string. So it -backtracks, discarding the match of the last `a' in the string. It can -then match the remaining `ar'. - - -File: regex.info, Node: Match-one-or-more Operator, Next: Match-zero-or-one Operator, Prev: Match-zero-or-more Operator, Up: Repetition Operators - -The Match-one-or-more Operator (`+' or `\+') --------------------------------------------- - - If the syntax bit `RE_LIMITED_OPS' is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit `RE_BK_PLUS_QM' -isn't set, then `+' represents this operator; if it is, then `\+' does. - - This operator is similar to the match-zero-or-more operator except -that it repeats the preceding regular expression at least once; *note -Match-zero-or-more Operator::., for what it operates on, how some -syntax bits affect it, and how Regex backtracks to match it. - - For example, supposing that `+' represents the match-one-or-more -operator; then `ca+r' matches, e.g., `car' and `caaaar', but not `cr'. - - -File: regex.info, Node: Match-zero-or-one Operator, Next: Interval Operators, Prev: Match-one-or-more Operator, Up: Repetition Operators - -The Match-zero-or-one Operator (`?' or `\?') --------------------------------------------- - - If the syntax bit `RE_LIMITED_OPS' is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit `RE_BK_PLUS_QM' -isn't set, then `?' represents this operator; if it is, then `\?' does. - - This operator is similar to the match-zero-or-more operator except -that it repeats the preceding regular expression once or not at all; -*note Match-zero-or-more Operator::., to see what it operates on, how -some syntax bits affect it, and how Regex backtracks to match it. - - For example, supposing that `?' represents the match-zero-or-one -operator; then `ca?r' matches both `car' and `cr', but nothing else. - - -File: regex.info, Node: Interval Operators, Prev: Match-zero-or-one Operator, Up: Repetition Operators - -Interval Operators (`{' ... `}' or `\{' ... `\}') -------------------------------------------------- - - If the syntax bit `RE_INTERVALS' is set, then Regex recognizes -"interval expressions". They repeat the smallest possible preceding -regular expression a specified number of times. - - If the syntax bit `RE_NO_BK_BRACES' is set, `{' represents the -"open-interval operator" and `}' represents the "close-interval -operator" ; otherwise, `\{' and `\}' do. - - Specifically, supposing that `{' and `}' represent the open-interval -and close-interval operators; then: - -`{COUNT}' - matches exactly COUNT occurrences of the preceding regular - expression. - -`{MIN,}' - matches MIN or more occurrences of the preceding regular - expression. - -`{MIN, MAX}' - matches at least MIN but no more than MAX occurrences of the - preceding regular expression. - - The interval expression (but not necessarily the regular expression -that contains it) is invalid if: - - * MIN is greater than MAX, or - - * any of COUNT, MIN, or MAX are outside the range zero to - `RE_DUP_MAX' (which symbol `regex.h' defines). - - If the interval expression is invalid and the syntax bit -`RE_NO_BK_BRACES' is set, then Regex considers all the characters in -the would-be interval to be ordinary. If that bit isn't set, then the -regular expression is invalid. - - If the interval expression is valid but there is no preceding regular -expression on which to operate, then if the syntax bit -`RE_CONTEXT_INVALID_OPS' is set, the regular expression is invalid. If -that bit isn't set, then Regex considers all the characters--other than -backslashes, which it ignores--in the would-be interval to be ordinary. - - -File: regex.info, Node: Alternation Operator, Next: List Operators, Prev: Repetition Operators, Up: Common Operators - -The Alternation Operator (`|' or `\|') -====================================== - - If the syntax bit `RE_LIMITED_OPS' is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit `RE_NO_BK_VBAR' -is set, then `|' represents this operator; otherwise, `\|' does. - - Alternatives match one of a choice of regular expressions: if you put -the character(s) representing the alternation operator between any two -regular expressions A and B, the result matches the union of the -strings that A and B match. For example, supposing that `|' is the -alternation operator, then `foo|bar|quux' would match any of `foo', -`bar' or `quux'. - - The alternation operator operates on the *largest* possible -surrounding regular expressions. (Put another way, it has the lowest -precedence of any regular expression operator.) Thus, the only way you -can delimit its arguments is to use grouping. For example, if `(' and -`)' are the open and close-group operators, then `fo(o|b)ar' would -match either `fooar' or `fobar'. (`foo|bar' would match `foo' or -`bar'.) - - The matcher usually tries all combinations of alternatives so as to -match the longest possible string. For example, when matching -`(fooq|foo)*(qbarquux|bar)' against `fooqbarquux', it cannot take, say, -the first ("depth-first") combination it could match, since then it -would be content to match just `fooqbar'. - - -File: regex.info, Node: List Operators, Next: Grouping Operators, Prev: Alternation Operator, Up: Common Operators - -List Operators (`[' ... `]' and `[^' ... `]') -============================================= - - "Lists", also called "bracket expressions", are a set of one or more -items. An "item" is a character, a character class expression, or a -range expression. The syntax bits affect which kinds of items you can -put in a list. We explain the last two items in subsections below. -Empty lists are invalid. - - A "matching list" matches a single character represented by one of -the list items. You form a matching list by enclosing one or more items -within an "open-matching-list operator" (represented by `[') and a -"close-list operator" (represented by `]'). - - For example, `[ab]' matches either `a' or `b'. `[ad]*' matches the -empty string and any string composed of just `a's and `d's in any -order. Regex considers invalid a regular expression with a `[' but no -matching `]'. - - "Nonmatching lists" are similar to matching lists except that they -match a single character *not* represented by one of the list items. -You use an "open-nonmatching-list operator" (represented by `[^'(1)) -instead of an open-matching-list operator to start a nonmatching list. - - For example, `[^ab]' matches any character except `a' or `b'. - - If the `posix_newline' field in the pattern buffer (*note GNU Pattern -Buffers::. is set, then nonmatching lists do not match a newline. - - Most characters lose any special meaning inside a list. The special -characters inside a list follow. - -`]' - ends the list if it's not the first list item. So, if you want to - make the `]' character a list item, you must put it first. - -`\' - quotes the next character if the syntax bit - `RE_BACKSLASH_ESCAPE_IN_LISTS' is set. - -`[:' - represents the open-character-class operator (*note Character - Class Operators::.) if the syntax bit `RE_CHAR_CLASSES' is set and - what follows is a valid character class expression. - -`:]' - represents the close-character-class operator if the syntax bit - `RE_CHAR_CLASSES' is set and what precedes it is an - open-character-class operator followed by a valid character class - name. - -`-' - represents the range operator (*note Range Operator::.) if it's - not first or last in a list or the ending point of a range. - -All other characters are ordinary. For example, `[.*]' matches `.' and -`*'. - -* Menu: - -* Character Class Operators:: [:class:] -* Range Operator:: start-end - - ---------- Footnotes ---------- - - (1) Regex therefore doesn't consider the `^' to be the first -character in the list. If you put a `^' character first in (what you -think is) a matching list, you'll turn it into a nonmatching list. - - -File: regex.info, Node: Character Class Operators, Next: Range Operator, Up: List Operators - -Character Class Operators (`[:' ... `:]') ------------------------------------------ - - If the syntax bit `RE_CHARACTER_CLASSES' is set, then Regex -recognizes character class expressions inside lists. A "character -class expression" matches one character from a given class. You form a -character class expression by putting a character class name between an -"open-character-class operator" (represented by `[:') and a -"close-character-class operator" (represented by `:]'). The character -class names and their meanings are: - -`alnum' - letters and digits - -`alpha' - letters - -`blank' - system-dependent; for GNU, a space or tab - -`cntrl' - control characters (in the ASCII encoding, code 0177 and codes - less than 040) - -`digit' - digits - -`graph' - same as `print' except omits space - -`lower' - lowercase letters - -`print' - printable characters (in the ASCII encoding, space tilde--codes - 040 through 0176) - -`punct' - neither control nor alphanumeric characters - -`space' - space, carriage return, newline, vertical tab, and form feed - -`upper' - uppercase letters - -`xdigit' - hexadecimal digits: `0'-`9', `a'-`f', `A'-`F' - -These correspond to the definitions in the C library's `' -facility. For example, `[:alpha:]' corresponds to the standard -facility `isalpha'. Regex recognizes character class expressions only -inside of lists; so `[[:alpha:]]' matches any letter, but `[:alpha:]' -outside of a bracket expression and not followed by a repetition -operator matches just itself. - - -File: regex.info, Node: Range Operator, Prev: Character Class Operators, Up: List Operators - -The Range Operator (`-') ------------------------- - - Regex recognizes "range expressions" inside a list. They represent -those characters that fall between two elements in the current -collating sequence. You form a range expression by putting a "range -operator" between two characters.(1) `-' represents the range operator. -For example, `a-f' within a list represents all the characters from `a' -through `f' inclusively. - - If the syntax bit `RE_NO_EMPTY_RANGES' is set, then if the range's -ending point collates less than its starting point, the range (and the -regular expression containing it) is invalid. For example, the regular -expression `[z-a]' would be invalid. If this bit isn't set, then Regex -considers such a range to be empty. - - Since `-' represents the range operator, if you want to make a `-' -character itself a list item, you must do one of the following: - - * Put the `-' either first or last in the list. - - * Include a range whose starting point collates strictly lower than - `-' and whose ending point collates equal or higher. Unless a - range is the first item in a list, a `-' can't be its starting - point, but *can* be its ending point. That is because Regex - considers `-' to be the range operator unless it is preceded by - another `-'. For example, in the ASCII encoding, `)', `*', `+', - `,', `-', `.', and `/' are contiguous characters in the collating - sequence. You might think that `[)-+--/]' has two ranges: `)-+' - and `--/'. Rather, it has the ranges `)-+' and `+--', plus the - character `/', so it matches, e.g., `,', not `.'. - - * Put a range whose starting point is `-' first in the list. - - For example, `[-a-z]' matches a lowercase letter or a hyphen (in -English, in ASCII). - - ---------- Footnotes ---------- - - (1) You can't use a character class for the starting or ending point -of a range, since a character class is not a single character. - - -File: regex.info, Node: Grouping Operators, Next: Back-reference Operator, Prev: List Operators, Up: Common Operators - -Grouping Operators (`(' ... `)' or `\(' ... `\)') -================================================= - - A "group", also known as a "subexpression", consists of an -"open-group operator", any number of other operators, and a -"close-group operator". Regex treats this sequence as a unit, just as -mathematics and programming languages treat a parenthesized expression -as a unit. - - Therefore, using "groups", you can: - - * delimit the argument(s) to an alternation operator (*note - Alternation Operator::.) or a repetition operator (*note - Repetition Operators::.). - - * keep track of the indices of the substring that matched a given - group. *Note Using Registers::, for a precise explanation. This - lets you: - - * use the back-reference operator (*note Back-reference - Operator::.). - - * use registers (*note Using Registers::.). - - If the syntax bit `RE_NO_BK_PARENS' is set, then `(' represents the -open-group operator and `)' represents the close-group operator; -otherwise, `\(' and `\)' do. - - If the syntax bit `RE_UNMATCHED_RIGHT_PAREN_ORD' is set and a -close-group operator has no matching open-group operator, then Regex -considers it to match `)'. - - -File: regex.info, Node: Back-reference Operator, Next: Anchoring Operators, Prev: Grouping Operators, Up: Common Operators - -The Back-reference Operator ("\"DIGIT) -====================================== - - If the syntax bit `RE_NO_BK_REF' isn't set, then Regex recognizes -back references. A back reference matches a specified preceding group. -The back reference operator is represented by `\DIGIT' anywhere after -the end of a regular expression's DIGIT-th group (*note Grouping -Operators::.). - - DIGIT must be between `1' and `9'. The matcher assigns numbers 1 -through 9 to the first nine groups it encounters. By using one of `\1' -through `\9' after the corresponding group's close-group operator, you -can match a substring identical to the one that the group does. - - Back references match according to the following (in all examples -below, `(' represents the open-group, `)' the close-group, `{' the -open-interval and `}' the close-interval operator): - - * If the group matches a substring, the back reference matches an - identical substring. For example, `(a)\1' matches `aa' and - `(bana)na\1bo\1' matches `bananabanabobana'. Likewise, `(.*)\1' - matches any (newline-free if the syntax bit `RE_DOT_NEWLINE' isn't - set) string that is composed of two identical halves; the `(.*)' - matches the first half and the `\1' matches the second half. - - * If the group matches more than once (as it might if followed by, - e.g., a repetition operator), then the back reference matches the - substring the group *last* matched. For example, `((a*)b)*\1\2' - matches `aabababa'; first group 1 (the outer one) matches `aab' - and group 2 (the inner one) matches `aa'. Then group 1 matches - `ab' and group 2 matches `a'. So, `\1' matches `ab' and `\2' - matches `a'. - - * If the group doesn't participate in a match, i.e., it is part of an - alternative not taken or a repetition operator allows zero - repetitions of it, then the back reference makes the whole match - fail. For example, `(one()|two())-and-(three\2|four\3)' matches - `one-and-three' and `two-and-four', but not `one-and-four' or - `two-and-three'. For example, if the pattern matches `one-and-', - then its group 2 matches the empty string and its group 3 doesn't - participate in the match. So, if it then matches `four', then - when it tries to back reference group 3--which it will attempt to - do because `\3' follows the `four'--the match will fail because - group 3 didn't participate in the match. - - You can use a back reference as an argument to a repetition operator. -For example, `(a(b))\2*' matches `a' followed by two or more `b's. -Similarly, `(a(b))\2{3}' matches `abbbb'. - - If there is no preceding DIGIT-th subexpression, the regular -expression is invalid. - - -File: regex.info, Node: Anchoring Operators, Prev: Back-reference Operator, Up: Common Operators - -Anchoring Operators -=================== - - These operators can constrain a pattern to match only at the -beginning or end of the entire string or at the beginning or end of a -line. - -* Menu: - -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ - - -File: regex.info, Node: Match-beginning-of-line Operator, Next: Match-end-of-line Operator, Up: Anchoring Operators - -The Match-beginning-of-line Operator (`^') ------------------------------------------- - - This operator can match the empty string either at the beginning of -the string or after a newline character. Thus, it is said to "anchor" -the pattern to the beginning of a line. - - In the cases following, `^' represents this operator. (Otherwise, -`^' is ordinary.) - - * It (the `^') is first in the pattern, as in `^foo'. - - * The syntax bit `RE_CONTEXT_INDEP_ANCHORS' is set, and it is outside - a bracket expression. - - * It follows an open-group or alternation operator, as in `a\(^b\)' - and `a\|^b'. *Note Grouping Operators::, and *Note Alternation - Operator::. - - These rules imply that some valid patterns containing `^' cannot be -matched; for example, `foo^bar' if `RE_CONTEXT_INDEP_ANCHORS' is set. - - If the `not_bol' field is set in the pattern buffer (*note GNU -Pattern Buffers::.), then `^' fails to match at the beginning of the -string. *Note POSIX Matching::, for when you might find this useful. - - If the `newline_anchor' field is set in the pattern buffer, then `^' -fails to match after a newline. This is useful when you do not regard -the string to be matched as broken into lines. - - -File: regex.info, Node: Match-end-of-line Operator, Prev: Match-beginning-of-line Operator, Up: Anchoring Operators - -The Match-end-of-line Operator (`$') ------------------------------------- - - This operator can match the empty string either at the end of the -string or before a newline character in the string. Thus, it is said -to "anchor" the pattern to the end of a line. - - It is always represented by `$'. For example, `foo$' usually -matches, e.g., `foo' and, e.g., the first three characters of -`foo\nbar'. - - Its interaction with the syntax bits and pattern buffer fields is -exactly the dual of `^''s; see the previous section. (That is, -"beginning" becomes "end", "next" becomes "previous", and "after" -becomes "before".) - - -File: regex.info, Node: GNU Operators, Next: GNU Emacs Operators, Prev: Common Operators, Up: Top - -GNU Operators -************* - - Following are operators that GNU defines (and POSIX doesn't). - -* Menu: - -* Word Operators:: -* Buffer Operators:: - - -File: regex.info, Node: Word Operators, Next: Buffer Operators, Up: GNU Operators - -Word Operators -============== - - The operators in this section require Regex to recognize parts of -words. Regex uses a syntax table to determine whether or not a -character is part of a word, i.e., whether or not it is -"word-constituent". - -* Menu: - -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W - - -File: regex.info, Node: Non-Emacs Syntax Tables, Next: Match-word-boundary Operator, Up: Word Operators - -Non-Emacs Syntax Tables ------------------------ - - A "syntax table" is an array indexed by the characters in your -character set. In the ASCII encoding, therefore, a syntax table has -256 elements. Regex always uses a `char *' variable `re_syntax_table' -as its syntax table. In some cases, it initializes this variable and -in others it expects you to initialize it. - - * If Regex is compiled with the preprocessor symbols `emacs' and - `SYNTAX_TABLE' both undefined, then Regex allocates - `re_syntax_table' and initializes an element I either to `Sword' - (which it defines) if I is a letter, number, or `_', or to zero if - it's not. - - * If Regex is compiled with `emacs' undefined but `SYNTAX_TABLE' - defined, then Regex expects you to define a `char *' variable - `re_syntax_table' to be a valid syntax table. - - * *Note Emacs Syntax Tables::, for what happens when Regex is - compiled with the preprocessor symbol `emacs' defined. - - -File: regex.info, Node: Match-word-boundary Operator, Next: Match-within-word Operator, Prev: Non-Emacs Syntax Tables, Up: Word Operators - -The Match-word-boundary Operator (`\b') ---------------------------------------- - - This operator (represented by `\b') matches the empty string at -either the beginning or the end of a word. For example, `\brat\b' -matches the separate word `rat'. - - -File: regex.info, Node: Match-within-word Operator, Next: Match-beginning-of-word Operator, Prev: Match-word-boundary Operator, Up: Word Operators - -The Match-within-word Operator (`\B') -------------------------------------- - - This operator (represented by `\B') matches the empty string within a -word. For example, `c\Brat\Be' matches `crate', but `dirty \Brat' -doesn't match `dirty rat'. - - -File: regex.info, Node: Match-beginning-of-word Operator, Next: Match-end-of-word Operator, Prev: Match-within-word Operator, Up: Word Operators - -The Match-beginning-of-word Operator (`\<') -------------------------------------------- - - This operator (represented by `\<') matches the empty string at the -beginning of a word. - - -File: regex.info, Node: Match-end-of-word Operator, Next: Match-word-constituent Operator, Prev: Match-beginning-of-word Operator, Up: Word Operators - -The Match-end-of-word Operator (`\>') -------------------------------------- - - This operator (represented by `\>') matches the empty string at the -end of a word. - - -File: regex.info, Node: Match-word-constituent Operator, Next: Match-non-word-constituent Operator, Prev: Match-end-of-word Operator, Up: Word Operators - -The Match-word-constituent Operator (`\w') ------------------------------------------- - - This operator (represented by `\w') matches any word-constituent -character. - - -File: regex.info, Node: Match-non-word-constituent Operator, Prev: Match-word-constituent Operator, Up: Word Operators - -The Match-non-word-constituent Operator (`\W') ----------------------------------------------- - - This operator (represented by `\W') matches any character that is not -word-constituent. - - -File: regex.info, Node: Buffer Operators, Prev: Word Operators, Up: GNU Operators - -Buffer Operators -================ - - Following are operators which work on buffers. In Emacs, a "buffer" -is, naturally, an Emacs buffer. For other programs, Regex considers the -entire string to be matched as the buffer. - -* Menu: - -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' - - -File: regex.info, Node: Match-beginning-of-buffer Operator, Next: Match-end-of-buffer Operator, Up: Buffer Operators - -The Match-beginning-of-buffer Operator (`\`') ---------------------------------------------- - - This operator (represented by `\`') matches the empty string at the -beginning of the buffer. - - -File: regex.info, Node: Match-end-of-buffer Operator, Prev: Match-beginning-of-buffer Operator, Up: Buffer Operators - -The Match-end-of-buffer Operator (`\'') ---------------------------------------- - - This operator (represented by `\'') matches the empty string at the -end of the buffer. - - -File: regex.info, Node: GNU Emacs Operators, Next: What Gets Matched?, Prev: GNU Operators, Up: Top - -GNU Emacs Operators -******************* - - Following are operators that GNU defines (and POSIX doesn't) that you -can use only when Regex is compiled with the preprocessor symbol -`emacs' defined. - -* Menu: - -* Syntactic Class Operators:: - - -File: regex.info, Node: Syntactic Class Operators, Up: GNU Emacs Operators - -Syntactic Class Operators -========================= - - The operators in this section require Regex to recognize the syntactic -classes of characters. Regex uses a syntax table to determine this. - -* Menu: - -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS - - -File: regex.info, Node: Emacs Syntax Tables, Next: Match-syntactic-class Operator, Up: Syntactic Class Operators - -Emacs Syntax Tables -------------------- - - A "syntax table" is an array indexed by the characters in your -character set. In the ASCII encoding, therefore, a syntax table has -256 elements. - - If Regex is compiled with the preprocessor symbol `emacs' defined, -then Regex expects you to define and initialize the variable -`re_syntax_table' to be an Emacs syntax table. Emacs' syntax tables -are more complicated than Regex's own (*note Non-Emacs Syntax -Tables::.). *Note Syntax: (emacs)Syntax, for a description of Emacs' -syntax tables. - - -File: regex.info, Node: Match-syntactic-class Operator, Next: Match-not-syntactic-class Operator, Prev: Emacs Syntax Tables, Up: Syntactic Class Operators - -The Match-syntactic-class Operator (`\s'CLASS) ----------------------------------------------- - - This operator matches any character whose syntactic class is -represented by a specified character. `\sCLASS' represents this -operator where CLASS is the character representing the syntactic class -you want. For example, `w' represents the syntactic class of -word-constituent characters, so `\sw' matches any word-constituent -character. - - -File: regex.info, Node: Match-not-syntactic-class Operator, Prev: Match-syntactic-class Operator, Up: Syntactic Class Operators - -The Match-not-syntactic-class Operator (`\S'CLASS) --------------------------------------------------- - - This operator is similar to the match-syntactic-class operator except -that it matches any character whose syntactic class is *not* -represented by the specified character. `\SCLASS' represents this -operator. For example, `w' represents the syntactic class of -word-constituent characters, so `\Sw' matches any character that is not -word-constituent. - - -File: regex.info, Node: What Gets Matched?, Next: Programming with Regex, Prev: GNU Emacs Operators, Up: Top - -What Gets Matched? -****************** - - Regex usually matches strings according to the "leftmost longest" -rule; that is, it chooses the longest of the leftmost matches. This -does not mean that for a regular expression containing subexpressions -that it simply chooses the longest match for each subexpression, left to -right; the overall match must also be the longest possible one. - - For example, `(ac*)(c*d[ac]*)\1' matches `acdacaaa', not `acdac', as -it would if it were to choose the longest match for the first -subexpression. - - -File: regex.info, Node: Programming with Regex, Next: Copying, Prev: What Gets Matched?, Up: Top - -Programming with Regex -********************** - - Here we describe how you use the Regex data structures and functions -in C programs. Regex has three interfaces: one designed for GNU, one -compatible with POSIX and one compatible with Berkeley UNIX. - -* Menu: - -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: - - -File: regex.info, Node: GNU Regex Functions, Next: POSIX Regex Functions, Up: Programming with Regex - -GNU Regex Functions -=================== - - If you're writing code that doesn't need to be compatible with either -POSIX or Berkeley UNIX, you can use these functions. They provide more -options than the other interfaces. - -* Menu: - -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () - - -File: regex.info, Node: GNU Pattern Buffers, Next: GNU Regular Expression Compiling, Up: GNU Regex Functions - -GNU Pattern Buffers -------------------- - - To compile, match, or search for a given regular expression, you must -supply a pattern buffer. A "pattern buffer" holds one compiled regular -expression.(1) - - You can have several different pattern buffers simultaneously, each -holding a compiled pattern for a different regular expression. - - `regex.h' defines the pattern buffer `struct' as follows: - - /* Space that holds the compiled pattern. It is declared as - `unsigned char *' because its elements are - sometimes used as array indexes. */ - unsigned char *buffer; - - /* Number of bytes to which `buffer' points. */ - unsigned long allocated; - - /* Number of bytes actually used in `buffer'. */ - unsigned long used; - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t syntax; - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses - the fastmap, if there is one, to skip over impossible - starting points for matches. */ - char *fastmap; - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation - is applied to a pattern when it is compiled and to a string - when it is matched. */ - char *translate; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in `re_search_2', to see - whether or not we should use the fastmap, so we don't set - this absolutely perfectly; see `re_compile_fastmap' (the - `duplicate' case). */ - unsigned can_be_null : 1; - - /* If REGS_UNALLOCATED, allocate space in the `regs' structure - for `max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ - #define REGS_UNALLOCATED 0 - #define REGS_REALLOCATE 1 - #define REGS_FIXED 2 - unsigned regs_allocated : 2; - - /* Set to zero when `regex_compile' compiles a pattern; set to one - by `re_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; - - /* If set, `re_match_2' does not return information about - subexpressions. */ - unsigned no_sub : 1; - - /* If set, a beginning-of-line anchor doesn't match at the - beginning of the string. */ - unsigned not_bol : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned not_eol : 1; - - /* If true, an anchor at a newline matches. */ - unsigned newline_anchor : 1; - - ---------- Footnotes ---------- - - (1) Regular expressions are also referred to as "patterns," hence -the name "pattern buffer." - - -File: regex.info, Node: GNU Regular Expression Compiling, Next: GNU Matching, Prev: GNU Pattern Buffers, Up: GNU Regex Functions - -GNU Regular Expression Compiling --------------------------------- - - In GNU, you can both match and search for a given regular expression. -To do either, you must first compile it in a pattern buffer (*note GNU -Pattern Buffers::.). - - Regular expressions match according to the syntax with which they were -compiled; with GNU, you indicate what syntax you want by setting the -variable `re_syntax_options' (declared in `regex.h' and defined in -`regex.c') before calling the compiling function, `re_compile_pattern' -(see below). *Note Syntax Bits::, and *Note Predefined Syntaxes::. - - You can change the value of `re_syntax_options' at any time. -Usually, however, you set its value once and then never change it. - - `re_compile_pattern' takes a pattern buffer as an argument. You must -initialize the following fields: - -`translate initialization' -`translate' - Initialize this to point to a translate table if you want one, or - to zero if you don't. We explain translate tables in *Note GNU - Translate Tables::. - -`fastmap' - Initialize this to nonzero if you want a fastmap, or to zero if you - don't. - -`buffer' -`allocated' - If you want `re_compile_pattern' to allocate memory for the - compiled pattern, set both of these to zero. If you have an - existing block of memory (allocated with `malloc') you want Regex - to use, set `buffer' to its address and `allocated' to its size (in - bytes). - - `re_compile_pattern' uses `realloc' to extend the space for the - compiled pattern as necessary. - - To compile a pattern buffer, use: - - char * - re_compile_pattern (const char *REGEX, const int REGEX_SIZE, - struct re_pattern_buffer *PATTERN_BUFFER) - -REGEX is the regular expression's address, REGEX_SIZE is its length, -and PATTERN_BUFFER is the pattern buffer's address. - - If `re_compile_pattern' successfully compiles the regular expression, -it returns zero and sets `*PATTERN_BUFFER' to the compiled pattern. It -sets the pattern buffer's fields as follows: - -`buffer' - to the compiled pattern. - -`used' - to the number of bytes the compiled pattern in `buffer' occupies. - -`syntax' - to the current value of `re_syntax_options'. - -`re_nsub' - to the number of subexpressions in REGEX. - -`fastmap_accurate' - to zero on the theory that the pattern you're compiling is - different than the one previously compiled into `buffer'; in that - case (since you can't make a fastmap without a compiled pattern), - `fastmap' would either contain an incompatible fastmap, or nothing - at all. - - If `re_compile_pattern' can't compile REGEX, it returns an error -string corresponding to one of the errors listed in *Note POSIX Regular -Expression Compiling::. - - -File: regex.info, Node: GNU Matching, Next: GNU Searching, Prev: GNU Regular Expression Compiling, Up: GNU Regex Functions - -GNU Matching ------------- - - Matching the GNU way means trying to match as much of a string as -possible starting at a position within it you specify. Once you've -compiled a pattern into a pattern buffer (*note GNU Regular Expression -Compiling::.), you can ask the matcher to match that pattern against a -string using: - - int - re_match (struct re_pattern_buffer *PATTERN_BUFFER, - const char *STRING, const int SIZE, - const int START, struct re_registers *REGS) - -PATTERN_BUFFER is the address of a pattern buffer containing a compiled -pattern. STRING is the string you want to match; it can contain -newline and null characters. SIZE is the length of that string. START -is the string index at which you want to begin matching; the first -character of STRING is at index zero. *Note Using Registers::, for a -explanation of REGS; you can safely pass zero. - - `re_match' matches the regular expression in PATTERN_BUFFER against -the string STRING according to the syntax in PATTERN_BUFFERS's `syntax' -field. (*Note GNU Regular Expression Compiling::, for how to set it.) -The function returns -1 if the compiled pattern does not match any part -of STRING and -2 if an internal error happens; otherwise, it returns -how many (possibly zero) characters of STRING the pattern matched. - - An example: suppose PATTERN_BUFFER points to a pattern buffer -containing the compiled pattern for `a*', and STRING points to `aaaaab' -(whereupon SIZE should be 6). Then if START is 2, `re_match' returns 3, -i.e., `a*' would have matched the last three `a's in STRING. If START -is 0, `re_match' returns 5, i.e., `a*' would have matched all the `a's -in STRING. If START is either 5 or 6, it returns zero. - - If START is not between zero and SIZE, then `re_match' returns -1. - - -File: regex.info, Node: GNU Searching, Next: Matching/Searching with Split Data, Prev: GNU Matching, Up: GNU Regex Functions - -GNU Searching -------------- - - "Searching" means trying to match starting at successive positions -within a string. The function `re_search' does this. - - Before calling `re_search', you must compile your regular expression. -*Note GNU Regular Expression Compiling::. - - Here is the function declaration: - - int - re_search (struct re_pattern_buffer *PATTERN_BUFFER, - const char *STRING, const int SIZE, - const int START, const int RANGE, - struct re_registers *REGS) - -whose arguments are the same as those to `re_match' (*note GNU -Matching::.) except that the two arguments START and RANGE replace -`re_match''s argument START. - - If RANGE is positive, then `re_search' attempts a match starting -first at index START, then at START + 1 if that fails, and so on, up to -START + RANGE; if RANGE is negative, then it attempts a match starting -first at index START, then at START -1 if that fails, and so on. - - If START is not between zero and SIZE, then `re_search' returns -1. -When RANGE is positive, `re_search' adjusts RANGE so that START + RANGE -- 1 is between zero and SIZE, if necessary; that way it won't search -outside of STRING. Similarly, when RANGE is negative, `re_search' -adjusts RANGE so that START + RANGE + 1 is between zero and SIZE, if -necessary. - - If the `fastmap' field of PATTERN_BUFFER is zero, `re_search' matches -starting at consecutive positions; otherwise, it uses `fastmap' to make -the search more efficient. *Note Searching with Fastmaps::. - - If no match is found, `re_search' returns -1. If a match is found, -it returns the index where the match began. If an internal error -happens, it returns -2. - - -File: regex.info, Node: Matching/Searching with Split Data, Next: Searching with Fastmaps, Prev: GNU Searching, Up: GNU Regex Functions - -Matching and Searching with Split Data --------------------------------------- - - Using the functions `re_match_2' and `re_search_2', you can match or -search in data that is divided into two strings. - - The function: - - int - re_match_2 (struct re_pattern_buffer *BUFFER, - const char *STRING1, const int SIZE1, - const char *STRING2, const int SIZE2, - const int START, - struct re_registers *REGS, - const int STOP) - -is similar to `re_match' (*note GNU Matching::.) except that you pass -*two* data strings and sizes, and an index STOP beyond which you don't -want the matcher to try matching. As with `re_match', if it succeeds, -`re_match_2' returns how many characters of STRING it matched. Regard -STRING1 and STRING2 as concatenated when you set the arguments START and -STOP and use the contents of REGS; `re_match_2' never returns a value -larger than SIZE1 + SIZE2. - - The function: - - int - re_search_2 (struct re_pattern_buffer *BUFFER, - const char *STRING1, const int SIZE1, - const char *STRING2, const int SIZE2, - const int START, const int RANGE, - struct re_registers *REGS, - const int STOP) - -is similarly related to `re_search'. - - -File: regex.info, Node: Searching with Fastmaps, Next: GNU Translate Tables, Prev: Matching/Searching with Split Data, Up: GNU Regex Functions - -Searching with Fastmaps ------------------------ - - If you're searching through a long string, you should use a fastmap. -Without one, the searcher tries to match at consecutive positions in the -string. Generally, most of the characters in the string could not start -a match. It takes much longer to try matching at a given position in -the string than it does to check in a table whether or not the -character at that position could start a match. A "fastmap" is such a -table. - - More specifically, a fastmap is an array indexed by the characters in -your character set. Under the ASCII encoding, therefore, a fastmap has -256 elements. If you want the searcher to use a fastmap with a given -pattern buffer, you must allocate the array and assign the array's -address to the pattern buffer's `fastmap' field. You either can -compile the fastmap yourself or have `re_search' do it for you; when -`fastmap' is nonzero, it automatically compiles a fastmap the first -time you search using a particular compiled pattern. - - To compile a fastmap yourself, use: - - int - re_compile_fastmap (struct re_pattern_buffer *PATTERN_BUFFER) - -PATTERN_BUFFER is the address of a pattern buffer. If the character C -could start a match for the pattern, `re_compile_fastmap' makes -`PATTERN_BUFFER->fastmap[C]' nonzero. It returns 0 if it can compile a -fastmap and -2 if there is an internal error. For example, if `|' is -the alternation operator and PATTERN_BUFFER holds the compiled pattern -for `a|b', then `re_compile_fastmap' sets `fastmap['a']' and -`fastmap['b']' (and no others). - - `re_search' uses a fastmap as it moves along in the string: it checks -the string's characters until it finds one that's in the fastmap. Then -it tries matching at that character. If the match fails, it repeats -the process. So, by using a fastmap, `re_search' doesn't waste time -trying to match at positions in the string that couldn't start a match. - - If you don't want `re_search' to use a fastmap, store zero in the -`fastmap' field of the pattern buffer before calling `re_search'. - - Once you've initialized a pattern buffer's `fastmap' field, you need -never do so again--even if you compile a new pattern in it--provided -the way the field is set still reflects whether or not you want a -fastmap. `re_search' will still either do nothing if `fastmap' is null -or, if it isn't, compile a new fastmap for the new pattern. - - -File: regex.info, Node: GNU Translate Tables, Next: Using Registers, Prev: Searching with Fastmaps, Up: GNU Regex Functions - -GNU Translate Tables --------------------- - - If you set the `translate' field of a pattern buffer to a translate -table, then the GNU Regex functions to which you've passed that pattern -buffer use it to apply a simple transformation to all the regular -expression and string characters at which they look. - - A "translate table" is an array indexed by the characters in your -character set. Under the ASCII encoding, therefore, a translate table -has 256 elements. The array's elements are also characters in your -character set. When the Regex functions see a character C, they use -`translate[C]' in its place, with one exception: the character after a -`\' is not translated. (This ensures that, the operators, e.g., `\B' -and `\b', are always distinguishable.) - - For example, a table that maps all lowercase letters to the -corresponding uppercase ones would cause the matcher to ignore -differences in case.(1) Such a table would map all characters except -lowercase letters to themselves, and lowercase letters to the -corresponding uppercase ones. Under the ASCII encoding, here's how you -could initialize such a table (we'll call it `case_fold'): - - for (i = 0; i < 256; i++) - case_fold[i] = i; - for (i = 'a'; i <= 'z'; i++) - case_fold[i] = i - ('a' - 'A'); - - You tell Regex to use a translate table on a given pattern buffer by -assigning that table's address to the `translate' field of that buffer. -If you don't want Regex to do any translation, put zero into this -field. You'll get weird results if you change the table's contents -anytime between compiling the pattern buffer, compiling its fastmap, and -matching or searching with the pattern buffer. - - ---------- Footnotes ---------- - - (1) A table that maps all uppercase letters to the corresponding -lowercase ones would work just as well for this purpose. - - -File: regex.info, Node: Using Registers, Next: Freeing GNU Pattern Buffers, Prev: GNU Translate Tables, Up: GNU Regex Functions - -Using Registers ---------------- - - A group in a regular expression can match a (posssibly empty) -substring of the string that regular expression as a whole matched. -The matcher remembers the beginning and end of the substring matched by -each group. - - To find out what they matched, pass a nonzero REGS argument to a GNU -matching or searching function (*note GNU Matching::. and *Note GNU -Searching::), i.e., the address of a structure of this type, as defined -in `regex.h': - - struct re_registers - { - unsigned num_regs; - regoff_t *start; - regoff_t *end; - }; - - Except for (possibly) the NUM_REGS'th element (see below), the Ith -element of the `start' and `end' arrays records information about the -Ith group in the pattern. (They're declared as C pointers, but this is -only because not all C compilers accept zero-length arrays; -conceptually, it is simplest to think of them as arrays.) - - The `start' and `end' arrays are allocated in various ways, depending -on the value of the `regs_allocated' field in the pattern buffer passed -to the matcher. - - The simplest and perhaps most useful is to let the matcher -(re)allocate enough space to record information for all the groups in -the regular expression. If `regs_allocated' is `REGS_UNALLOCATED', the -matcher allocates 1 + RE_NSUB (another field in the pattern buffer; -*note GNU Pattern Buffers::.). The extra element is set to -1, and -sets `regs_allocated' to `REGS_REALLOCATE'. Then on subsequent calls -with the same pattern buffer and REGS arguments, the matcher -reallocates more space if necessary. - - It would perhaps be more logical to make the `regs_allocated' field -part of the `re_registers' structure, instead of part of the pattern -buffer. But in that case the caller would be forced to initialize the -structure before passing it. Much existing code doesn't do this -initialization, and it's arguably better to avoid it anyway. - - `re_compile_pattern' sets `regs_allocated' to `REGS_UNALLOCATED', so -if you use the GNU regular expression functions, you get this behavior -by default. - - xx document re_set_registers - - POSIX, on the other hand, requires a different interface: the caller -is supposed to pass in a fixed-length array which the matcher fills. -Therefore, if `regs_allocated' is `REGS_FIXED' the matcher simply fills -that array. - - The following examples illustrate the information recorded in the -`re_registers' structure. (In all of them, `(' represents the -open-group and `)' the close-group operator. The first character in -the string STRING is at index 0.) - - * If the regular expression has an I-th group not contained within - another group that matches a substring of STRING, then the - function sets `REGS->start[I]' to the index in STRING where the - substring matched by the I-th group begins, and `REGS->end[I]' to - the index just beyond that substring's end. The function sets - `REGS->start[0]' and `REGS->end[0]' to analogous information about - the entire pattern. - - For example, when you match `((a)(b))' against `ab', you get: - - * 0 in `REGS->start[0]' and 2 in `REGS->end[0]' - - * 0 in `REGS->start[1]' and 2 in `REGS->end[1]' - - * 0 in `REGS->start[2]' and 1 in `REGS->end[2]' - - * 1 in `REGS->start[3]' and 2 in `REGS->end[3]' - - * If a group matches more than once (as it might if followed by, - e.g., a repetition operator), then the function reports the - information about what the group *last* matched. - - For example, when you match the pattern `(a)*' against the string - `aa', you get: - - * 0 in `REGS->start[0]' and 2 in `REGS->end[0]' - - * 1 in `REGS->start[1]' and 2 in `REGS->end[1]' - - * If the I-th group does not participate in a successful match, - e.g., it is an alternative not taken or a repetition operator - allows zero repetitions of it, then the function sets - `REGS->start[I]' and `REGS->end[I]' to -1. - - For example, when you match the pattern `(a)*b' against the string - `b', you get: - - * 0 in `REGS->start[0]' and 1 in `REGS->end[0]' - - * -1 in `REGS->start[1]' and -1 in `REGS->end[1]' - - * If the I-th group matches a zero-length string, then the function - sets `REGS->start[I]' and `REGS->end[I]' to the index just beyond - that zero-length string. - - For example, when you match the pattern `(a*)b' against the string - `b', you get: - - * 0 in `REGS->start[0]' and 1 in `REGS->end[0]' - - * 0 in `REGS->start[1]' and 0 in `REGS->end[1]' - - * If an I-th group contains a J-th group in turn not contained - within any other group within group I and the function reports a - match of the I-th group, then it records in `REGS->start[J]' and - `REGS->end[J]' the last match (if it matched) of the J-th group. - - For example, when you match the pattern `((a*)b)*' against the - string `abb', group 2 last matches the empty string, so you get - what it previously matched: - - * 0 in `REGS->start[0]' and 3 in `REGS->end[0]' - - * 2 in `REGS->start[1]' and 3 in `REGS->end[1]' - - * 2 in `REGS->start[2]' and 2 in `REGS->end[2]' - - When you match the pattern `((a)*b)*' against the string `abb', - group 2 doesn't participate in the last match, so you get: - - * 0 in `REGS->start[0]' and 3 in `REGS->end[0]' - - * 2 in `REGS->start[1]' and 3 in `REGS->end[1]' - - * 0 in `REGS->start[2]' and 1 in `REGS->end[2]' - - * If an I-th group contains a J-th group in turn not contained - within any other group within group I and the function sets - `REGS->start[I]' and `REGS->end[I]' to -1, then it also sets - `REGS->start[J]' and `REGS->end[J]' to -1. - - For example, when you match the pattern `((a)*b)*c' against the - string `c', you get: - - * 0 in `REGS->start[0]' and 1 in `REGS->end[0]' - - * -1 in `REGS->start[1]' and -1 in `REGS->end[1]' - - * -1 in `REGS->start[2]' and -1 in `REGS->end[2]' - - -File: regex.info, Node: Freeing GNU Pattern Buffers, Prev: Using Registers, Up: GNU Regex Functions - -Freeing GNU Pattern Buffers ---------------------------- - - To free any allocated fields of a pattern buffer, you can use the -POSIX function described in *Note Freeing POSIX Pattern Buffers::, -since the type `regex_t'--the type for POSIX pattern buffers--is -equivalent to the type `re_pattern_buffer'. After freeing a pattern -buffer, you need to again compile a regular expression in it (*note GNU -Regular Expression Compiling::.) before passing it to a matching or -searching function. - - -File: regex.info, Node: POSIX Regex Functions, Next: BSD Regex Functions, Prev: GNU Regex Functions, Up: Programming with Regex - -POSIX Regex Functions -===================== - - If you're writing code that has to be POSIX compatible, you'll need -to use these functions. Their interfaces are as specified by POSIX, -draft 1003.2/D11.2. - -* Menu: - -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () - - -File: regex.info, Node: POSIX Pattern Buffers, Next: POSIX Regular Expression Compiling, Up: POSIX Regex Functions - -POSIX Pattern Buffers ---------------------- - - To compile or match a given regular expression the POSIX way, you -must supply a pattern buffer exactly the way you do for GNU (*note GNU -Pattern Buffers::.). POSIX pattern buffers have type `regex_t', which -is equivalent to the GNU pattern buffer type `re_pattern_buffer'. - - -File: regex.info, Node: POSIX Regular Expression Compiling, Next: POSIX Matching, Prev: POSIX Pattern Buffers, Up: POSIX Regex Functions - -POSIX Regular Expression Compiling ----------------------------------- - - With POSIX, you can only search for a given regular expression; you -can't match it. To do this, you must first compile it in a pattern -buffer, using `regcomp'. - - To compile a pattern buffer, use: - - int - regcomp (regex_t *PREG, const char *REGEX, int CFLAGS) - -PREG is the initialized pattern buffer's address, REGEX is the regular -expression's address, and CFLAGS is the compilation flags, which Regex -considers as a collection of bits. Here are the valid bits, as defined -in `regex.h': - -`REG_EXTENDED' - says to use POSIX Extended Regular Expression syntax; if this isn't - set, then says to use POSIX Basic Regular Expression syntax. - `regcomp' sets PREG's `syntax' field accordingly. - -`REG_ICASE' - says to ignore case; `regcomp' sets PREG's `translate' field to a - translate table which ignores case, replacing anything you've put - there before. - -`REG_NOSUB' - says to set PREG's `no_sub' field; *note POSIX Matching::., for - what this means. - -`REG_NEWLINE' - says that a: - - * match-any-character operator (*note Match-any-character - Operator::.) doesn't match a newline. - - * nonmatching list not containing a newline (*note List - Operators::.) matches a newline. - - * match-beginning-of-line operator (*note - Match-beginning-of-line Operator::.) matches the empty string - immediately after a newline, regardless of how `REG_NOTBOL' - is set (*note POSIX Matching::., for an explanation of - `REG_NOTBOL'). - - * match-end-of-line operator (*note Match-beginning-of-line - Operator::.) matches the empty string immediately before a - newline, regardless of how `REG_NOTEOL' is set (*note POSIX - Matching::., for an explanation of `REG_NOTEOL'). - - If `regcomp' successfully compiles the regular expression, it returns -zero and sets `*PATTERN_BUFFER' to the compiled pattern. Except for -`syntax' (which it sets as explained above), it also sets the same -fields the same way as does the GNU compiling function (*note GNU -Regular Expression Compiling::.). - - If `regcomp' can't compile the regular expression, it returns one of -the error codes listed here. (Except when noted differently, the -syntax of in all examples below is basic regular expression syntax.) - -`REG_BADRPT' - For example, the consecutive repetition operators `**' in `a**' - are invalid. As another example, if the syntax is extended - regular expression syntax, then the repetition operator `*' with - nothing on which to operate in `*' is invalid. - -`REG_BADBR' - For example, the COUNT `-1' in `a\{-1' is invalid. - -`REG_EBRACE' - For example, `a\{1' is missing a close-interval operator. - -`REG_EBRACK' - For example, `[a' is missing a close-list operator. - -`REG_ERANGE' - For example, the range ending point `z' that collates lower than - does its starting point `a' in `[z-a]' is invalid. Also, the - range with the character class `[:alpha:]' as its starting point in - `[[:alpha:]-|]'. - -`REG_ECTYPE' - For example, the character class name `foo' in `[[:foo:]' is - invalid. - -`REG_EPAREN' - For example, `a\)' is missing an open-group operator and `\(a' is - missing a close-group operator. - -`REG_ESUBREG' - For example, the back reference `\2' that refers to a nonexistent - subexpression in `\(a\)\2' is invalid. - -`REG_EEND' - Returned when a regular expression causes no other more specific - error. - -`REG_EESCAPE' - For example, the trailing backslash `\' in `a\' is invalid, as is - the one in `\'. - -`REG_BADPAT' - For example, in the extended regular expression syntax, the empty - group `()' in `a()b' is invalid. - -`REG_ESIZE' - Returned when a regular expression needs a pattern buffer larger - than 65536 bytes. - -`REG_ESPACE' - Returned when a regular expression makes Regex to run out of - memory. - - -File: regex.info, Node: POSIX Matching, Next: Reporting Errors, Prev: POSIX Regular Expression Compiling, Up: POSIX Regex Functions - -POSIX Matching --------------- - - Matching the POSIX way means trying to match a null-terminated string -starting at its first character. Once you've compiled a pattern into a -pattern buffer (*note POSIX Regular Expression Compiling::.), you can -ask the matcher to match that pattern against a string using: - - int - regexec (const regex_t *PREG, const char *STRING, - size_t NMATCH, regmatch_t PMATCH[], int EFLAGS) - -PREG is the address of a pattern buffer for a compiled pattern. STRING -is the string you want to match. - - *Note Using Byte Offsets::, for an explanation of PMATCH. If you -pass zero for NMATCH or you compiled PREG with the compilation flag -`REG_NOSUB' set, then `regexec' will ignore PMATCH; otherwise, you must -allocate it to have at least NMATCH elements. `regexec' will record -NMATCH byte offsets in PMATCH, and set to -1 any unused elements up to -PMATCH`[NMATCH]' - 1. - - EFLAGS specifies "execution flags"--namely, the two bits `REG_NOTBOL' -and `REG_NOTEOL' (defined in `regex.h'). If you set `REG_NOTBOL', then -the match-beginning-of-line operator (*note Match-beginning-of-line -Operator::.) always fails to match. This lets you match against pieces -of a line, as you would need to if, say, searching for repeated -instances of a given pattern in a line; it would work correctly for -patterns both with and without match-beginning-of-line operators. -`REG_NOTEOL' works analogously for the match-end-of-line operator -(*note Match-end-of-line Operator::.); it exists for symmetry. - - `regexec' tries to find a match for PREG in STRING according to the -syntax in PREG's `syntax' field. (*Note POSIX Regular Expression -Compiling::, for how to set it.) The function returns zero if the -compiled pattern matches STRING and `REG_NOMATCH' (defined in -`regex.h') if it doesn't. - - -File: regex.info, Node: Reporting Errors, Next: Using Byte Offsets, Prev: POSIX Matching, Up: POSIX Regex Functions - -Reporting Errors ----------------- - - If either `regcomp' or `regexec' fail, they return a nonzero error -code, the possibilities for which are defined in `regex.h'. *Note -POSIX Regular Expression Compiling::, and *Note POSIX Matching::, for -what these codes mean. To get an error string corresponding to these -codes, you can use: - - size_t - regerror (int ERRCODE, - const regex_t *PREG, - char *ERRBUF, - size_t ERRBUF_SIZE) - -ERRCODE is an error code, PREG is the address of the pattern buffer -which provoked the error, ERRBUF is the error buffer, and ERRBUF_SIZE -is ERRBUF's size. - - `regerror' returns the size in bytes of the error string -corresponding to ERRCODE (including its terminating null). If ERRBUF -and ERRBUF_SIZE are nonzero, it also returns in ERRBUF the first -ERRBUF_SIZE - 1 characters of the error string, followed by a null. -eRRBUF_SIZE must be a nonnegative number less than or equal to the size -in bytes of ERRBUF. - - You can call `regerror' with a null ERRBUF and a zero ERRBUF_SIZE to -determine how large ERRBUF need be to accommodate `regerror''s error -string. - - -File: regex.info, Node: Using Byte Offsets, Next: Freeing POSIX Pattern Buffers, Prev: Reporting Errors, Up: POSIX Regex Functions - -Using Byte Offsets ------------------- - - In POSIX, variables of type `regmatch_t' hold analogous information, -but are not identical to, GNU's registers (*note Using Registers::.). -To get information about registers in POSIX, pass to `regexec' a -nonzero PMATCH of type `regmatch_t', i.e., the address of a structure -of this type, defined in `regex.h': - - typedef struct - { - regoff_t rm_so; - regoff_t rm_eo; - } regmatch_t; - - When reading in *Note Using Registers::, about how the matching -function stores the information into the registers, substitute PMATCH -for REGS, `PMATCH[I]->rm_so' for `REGS->start[I]' and -`PMATCH[I]->rm_eo' for `REGS->end[I]'. - - -File: regex.info, Node: Freeing POSIX Pattern Buffers, Prev: Using Byte Offsets, Up: POSIX Regex Functions - -Freeing POSIX Pattern Buffers ------------------------------ - - To free any allocated fields of a pattern buffer, use: - - void - regfree (regex_t *PREG) - -PREG is the pattern buffer whose allocated fields you want freed. -`regfree' also sets PREG's `allocated' and `used' fields to zero. -After freeing a pattern buffer, you need to again compile a regular -expression in it (*note POSIX Regular Expression Compiling::.) before -passing it to the matching function (*note POSIX Matching::.). - - -File: regex.info, Node: BSD Regex Functions, Prev: POSIX Regex Functions, Up: Programming with Regex - -BSD Regex Functions -=================== - - If you're writing code that has to be Berkeley UNIX compatible, -you'll need to use these functions whose interfaces are the same as -those in Berkeley UNIX. - -* Menu: - -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () - - -File: regex.info, Node: BSD Regular Expression Compiling, Next: BSD Searching, Up: BSD Regex Functions - -BSD Regular Expression Compiling --------------------------------- - - With Berkeley UNIX, you can only search for a given regular -expression; you can't match one. To search for it, you must first -compile it. Before you compile it, you must indicate the regular -expression syntax you want it compiled according to by setting the -variable `re_syntax_options' (declared in `regex.h' to some syntax -(*note Regular Expression Syntax::.). - - To compile a regular expression use: - - char * - re_comp (char *REGEX) - -REGEX is the address of a null-terminated regular expression. -`re_comp' uses an internal pattern buffer, so you can use only the most -recently compiled pattern buffer. This means that if you want to use a -given regular expression that you've already compiled--but it isn't the -latest one you've compiled--you'll have to recompile it. If you call -`re_comp' with the null string (*not* the empty string) as the -argument, it doesn't change the contents of the pattern buffer. - - If `re_comp' successfully compiles the regular expression, it returns -zero. If it can't compile the regular expression, it returns an error -string. `re_comp''s error messages are identical to those of -`re_compile_pattern' (*note GNU Regular Expression Compiling::.). - - -File: regex.info, Node: BSD Searching, Prev: BSD Regular Expression Compiling, Up: BSD Regex Functions - -BSD Searching -------------- - - Searching the Berkeley UNIX way means searching in a string starting -at its first character and trying successive positions within it to -find a match. Once you've compiled a pattern using `re_comp' (*note -BSD Regular Expression Compiling::.), you can ask Regex to search for -that pattern in a string using: - - int - re_exec (char *STRING) - -STRING is the address of the null-terminated string in which you want -to search. - - `re_exec' returns either 1 for success or 0 for failure. It -automatically uses a GNU fastmap (*note Searching with Fastmaps::.). - - -File: regex.info, Node: Copying, Next: Index, Prev: Programming with Regex, Up: Top - -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. - - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 1. 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. - - 2. 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. - - 3. 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. - - 4. 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. - - 5. 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. - - 6. 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. - - 7. 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. - - 8. 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. - - 9. 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. - - 10. 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. - - 11. 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 - - 12. 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. - - 13. 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. - - ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. - Copyright (C) 19YY NAME OF AUTHOR - - 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. - - SIGNATURE OF TY COON, 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. - - -File: regex.info, Node: Index, Prev: Copying, Up: Top - -Index -***** - -* Menu: - -* $: Match-end-of-line Operator. -* (: Grouping Operators. -* ): Grouping Operators. -* *: Match-zero-or-more Operator. -* +: Match-one-or-more Operator. -* -: List Operators. -* .: Match-any-character Operator. -* :] in regex: Character Class Operators. -* ?: Match-zero-or-one Operator. -* {: Interval Operators. -* }: Interval Operators. -* [: in regex: Character Class Operators. -* [^: List Operators. -* [: List Operators. -* \': Match-end-of-buffer Operator. -* \<: Match-beginning-of-word Operator. -* \>: Match-end-of-word Operator. -* \{: Interval Operators. -* \}: Interval Operators. -* \b: Match-word-boundary Operator. -* \B: Match-within-word Operator. -* \s: Match-syntactic-class Operator. -* \S: Match-not-syntactic-class Operator. -* \w: Match-word-constituent Operator. -* \W: Match-non-word-constituent Operator. -* \`: Match-beginning-of-buffer Operator. -* \: List Operators. -* ]: List Operators. -* ^: List Operators. -* allocated initialization: GNU Regular Expression Compiling. -* alternation operator: Alternation Operator. -* alternation operator and ^: Match-beginning-of-line Operator. -* anchoring: Anchoring Operators. -* anchors: Match-end-of-line Operator. -* anchors: Match-beginning-of-line Operator. -* Awk: Predefined Syntaxes. -* back references: Back-reference Operator. -* backtracking: Match-zero-or-more Operator. -* backtracking: Alternation Operator. -* beginning-of-line operator: Match-beginning-of-line Operator. -* bracket expression: List Operators. -* buffer field, set by re_compile_pattern: GNU Regular Expression Compiling. -* buffer initialization: GNU Regular Expression Compiling. -* character classes: Character Class Operators. -* Egrep: Predefined Syntaxes. -* Emacs: Predefined Syntaxes. -* end in struct re_registers: Using Registers. -* end-of-line operator: Match-end-of-line Operator. -* fastmap initialization: GNU Regular Expression Compiling. -* fastmaps: Searching with Fastmaps. -* fastmap_accurate field, set by re_compile_pattern: GNU Regular Expression Compiling. -* Grep: Predefined Syntaxes. -* grouping: Grouping Operators. -* ignoring case: POSIX Regular Expression Compiling. -* interval expression: Interval Operators. -* matching list: List Operators. -* matching newline: List Operators. -* matching with GNU functions: GNU Matching. -* newline_anchor field in pattern buffer: Match-beginning-of-line Operator. -* nonmatching list: List Operators. -* not_bol field in pattern buffer: Match-beginning-of-line Operator. -* num_regs in struct re_registers: Using Registers. -* open-group operator and ^: Match-beginning-of-line Operator. -* or operator: Alternation Operator. -* parenthesizing: Grouping Operators. -* pattern buffer initialization: GNU Regular Expression Compiling. -* pattern buffer, definition of: GNU Pattern Buffers. -* POSIX Awk: Predefined Syntaxes. -* range argument to re_search: GNU Searching. -* regex.c: Overview. -* regex.h: Overview. -* regexp anchoring: Anchoring Operators. -* regmatch_t: Using Byte Offsets. -* regs_allocated: Using Registers. -* REGS_FIXED: Using Registers. -* REGS_REALLOCATE: Using Registers. -* REGS_UNALLOCATED: Using Registers. -* regular expressions, syntax of: Regular Expression Syntax. -* REG_EXTENDED: POSIX Regular Expression Compiling. -* REG_ICASE: POSIX Regular Expression Compiling. -* REG_NEWLINE: POSIX Regular Expression Compiling. -* REG_NOSUB: POSIX Regular Expression Compiling. -* RE_BACKSLASH_ESCAPE_IN_LIST: Syntax Bits. -* RE_BK_PLUS_QM: Syntax Bits. -* RE_CHAR_CLASSES: Syntax Bits. -* RE_CONTEXT_INDEP_ANCHORS: Syntax Bits. -* RE_CONTEXT_INDEP_ANCHORS (and ^): Match-beginning-of-line Operator. -* RE_CONTEXT_INDEP_OPS: Syntax Bits. -* RE_CONTEXT_INVALID_OPS: Syntax Bits. -* RE_DOT_NEWLINE: Syntax Bits. -* RE_DOT_NOT_NULL: Syntax Bits. -* RE_INTERVALS: Syntax Bits. -* RE_LIMITED_OPS: Syntax Bits. -* RE_NEWLINE_ALT: Syntax Bits. -* RE_NO_BK_BRACES: Syntax Bits. -* RE_NO_BK_PARENS: Syntax Bits. -* RE_NO_BK_REFS: Syntax Bits. -* RE_NO_BK_VBAR: Syntax Bits. -* RE_NO_EMPTY_RANGES: Syntax Bits. -* re_nsub field, set by re_compile_pattern: GNU Regular Expression Compiling. -* re_pattern_buffer definition: GNU Pattern Buffers. -* re_registers: Using Registers. -* re_syntax_options initialization: GNU Regular Expression Compiling. -* RE_UNMATCHED_RIGHT_PAREN_ORD: Syntax Bits. -* searching with GNU functions: GNU Searching. -* start argument to re_search: GNU Searching. -* start in struct re_registers: Using Registers. -* struct re_pattern_buffer definition: GNU Pattern Buffers. -* subexpressions: Grouping Operators. -* syntax field, set by re_compile_pattern: GNU Regular Expression Compiling. -* syntax bits: Syntax Bits. -* syntax initialization: GNU Regular Expression Compiling. -* syntax of regular expressions: Regular Expression Syntax. -* translate initialization: GNU Regular Expression Compiling. -* used field, set by re_compile_pattern: GNU Regular Expression Compiling. -* word boundaries, matching: Match-word-boundary Operator. -* \: The Backslash Character. -* \(: Grouping Operators. -* \): Grouping Operators. -* \|: Alternation Operator. -* ^: Match-beginning-of-line Operator. -* |: Alternation Operator. - - - -Tag Table: -Node: Top1064 -Node: Overview4562 -Node: Regular Expression Syntax6746 -Node: Syntax Bits7916 -Node: Predefined Syntaxes14018 -Node: Collating Elements vs. Characters17872 -Node: The Backslash Character18835 -Node: Common Operators21992 -Node: Match-self Operator23445 -Node: Match-any-character Operator23941 -Node: Concatenation Operator24520 -Node: Repetition Operators25017 -Node: Match-zero-or-more Operator25436 -Node: Match-one-or-more Operator27483 -Node: Match-zero-or-one Operator28341 -Node: Interval Operators29196 -Node: Alternation Operator30991 -Node: List Operators32489 -Node: Character Class Operators35272 -Node: Range Operator36901 -Node: Grouping Operators38930 -Node: Back-reference Operator40251 -Node: Anchoring Operators43073 -Node: Match-beginning-of-line Operator43447 -Node: Match-end-of-line Operator44779 -Node: GNU Operators45518 -Node: Word Operators45767 -Node: Non-Emacs Syntax Tables46391 -Node: Match-word-boundary Operator47465 -Node: Match-within-word Operator47858 -Node: Match-beginning-of-word Operator48255 -Node: Match-end-of-word Operator48588 -Node: Match-word-constituent Operator48908 -Node: Match-non-word-constituent Operator49234 -Node: Buffer Operators49545 -Node: Match-beginning-of-buffer Operator49952 -Node: Match-end-of-buffer Operator50264 -Node: GNU Emacs Operators50558 -Node: Syntactic Class Operators50901 -Node: Emacs Syntax Tables51307 -Node: Match-syntactic-class Operator51963 -Node: Match-not-syntactic-class Operator52560 -Node: What Gets Matched?53150 -Node: Programming with Regex53799 -Node: GNU Regex Functions54237 -Node: GNU Pattern Buffers55078 -Node: GNU Regular Expression Compiling58303 -Node: GNU Matching61181 -Node: GNU Searching63101 -Node: Matching/Searching with Split Data64913 -Node: Searching with Fastmaps66369 -Node: GNU Translate Tables68921 -Node: Using Registers70892 -Node: Freeing GNU Pattern Buffers77000 -Node: POSIX Regex Functions77593 -Node: POSIX Pattern Buffers78266 -Node: POSIX Regular Expression Compiling78709 -Node: POSIX Matching82836 -Node: Reporting Errors84791 -Node: Using Byte Offsets86048 -Node: Freeing POSIX Pattern Buffers86861 -Node: BSD Regex Functions87467 -Node: BSD Regular Expression Compiling87886 -Node: BSD Searching89258 -Node: Copying89960 -Node: Index109122 - -End Tag Table diff --git a/gnu/lib/libregex/doc/regex.texi b/gnu/lib/libregex/doc/regex.texi deleted file mode 100644 index d93953ece20c..000000000000 --- a/gnu/lib/libregex/doc/regex.texi +++ /dev/null @@ -1,3138 +0,0 @@ -\input texinfo -@c %**start of header -@setfilename regex.info -@settitle Regex -@c %**end of header - -@c \\{fill-paragraph} works better (for me, anyway) if the text in the -@c source file isn't indented. -@paragraphindent 2 - -@c Define a new index for our magic constants. -@defcodeindex cn - -@c Put everything in one index (arbitrarily chosen to be the concept index). -@syncodeindex cn cp -@syncodeindex ky cp -@syncodeindex pg cp -@syncodeindex tp cp -@syncodeindex vr cp - -@c Here is what we use in the Info `dir' file: -@c * Regex: (regex). Regular expression library. - - -@ifinfo -This file documents the GNU regular expression library. - -Copyright (C) 1992, 1993 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 a 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 also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and 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 the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end ifinfo - - -@titlepage - -@title Regex -@subtitle edition 0.12a -@subtitle 19 September 1992 -@author Kathryn A. Hargreaves -@author Karl Berry - -@page - -@vskip 0pt plus 1filll -Copyright @copyright{} 1992 Free Software Foundation. - -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 also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and 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 the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. - -@end titlepage - - -@ifinfo -@node Top, Overview, (dir), (dir) -@top Regular Expression Library - -This manual documents how to program with the GNU regular expression -library. This is edition 0.12a of the manual, 19 September 1992. - -The first part of this master menu lists the major nodes in this Info -document, including the index. The rest of the menu lists all the -lower level nodes in the document. - -@menu -* Overview:: -* Regular Expression Syntax:: -* Common Operators:: -* GNU Operators:: -* GNU Emacs Operators:: -* What Gets Matched?:: -* Programming with Regex:: -* Copying:: Copying and sharing Regex. -* Index:: General index. - --- The Detailed Node Listing --- - -Regular Expression Syntax - -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: - -Common Operators - -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? @{@} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ - -Repetition Operators - -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: @{@} - -List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]}) - -* Character Class Operators:: [:class:] -* Range Operator:: start-end - -Anchoring Operators - -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ - -GNU Operators - -* Word Operators:: -* Buffer Operators:: - -Word Operators - -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W - -Buffer Operators - -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' - -GNU Emacs Operators - -* Syntactic Class Operators:: - -Syntactic Class Operators - -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS - -Programming with Regex - -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: - -GNU Regex Functions - -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () - -POSIX Regex Functions - -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () - -BSD Regex Functions - -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () -@end menu -@end ifinfo -@node Overview, Regular Expression Syntax, Top, Top -@chapter Overview - -A @dfn{regular expression} (or @dfn{regexp}, or @dfn{pattern}) is a text -string that describes some (mathematical) set of strings. A regexp -@var{r} @dfn{matches} a string @var{s} if @var{s} is in the set of -strings described by @var{r}. - -Using the Regex library, you can: - -@itemize @bullet - -@item -see if a string matches a specified pattern as a whole, and - -@item -search within a string for a substring matching a specified pattern. - -@end itemize - -Some regular expressions match only one string, i.e., the set they -describe has only one member. For example, the regular expression -@samp{foo} matches the string @samp{foo} and no others. Other regular -expressions match more than one string, i.e., the set they describe has -more than one member. For example, the regular expression @samp{f*} -matches the set of strings made up of any number (including zero) of -@samp{f}s. As you can see, some characters in regular expressions match -themselves (such as @samp{f}) and some don't (such as @samp{*}); the -ones that don't match themselves instead let you specify patterns that -describe many different strings. - -To either match or search for a regular expression with the Regex -library functions, you must first compile it with a Regex pattern -compiling function. A @dfn{compiled pattern} is a regular expression -converted to the internal format used by the library functions. Once -you've compiled a pattern, you can use it for matching or searching any -number of times. - -The Regex library consists of two source files: @file{regex.h} and -@file{regex.c}. -@pindex regex.h -@pindex regex.c -Regex provides three groups of functions with which you can operate on -regular expressions. One group---the @sc{gnu} group---is more powerful -but not completely compatible with the other two, namely the @sc{posix} -and Berkeley @sc{unix} groups; its interface was designed specifically -for @sc{gnu}. The other groups have the same interfaces as do the -regular expression functions in @sc{posix} and Berkeley -@sc{unix}. - -We wrote this chapter with programmers in mind, not users of -programs---such as Emacs---that use Regex. We describe the Regex -library in its entirety, not how to write regular expressions that a -particular program understands. - - -@node Regular Expression Syntax, Common Operators, Overview, Top -@chapter Regular Expression Syntax - -@cindex regular expressions, syntax of -@cindex syntax of regular expressions - -@dfn{Characters} are things you can type. @dfn{Operators} are things in -a regular expression that match one or more characters. You compose -regular expressions from operators, which in turn you specify using one -or more characters. - -Most characters represent what we call the match-self operator, i.e., -they match themselves; we call these characters @dfn{ordinary}. Other -characters represent either all or parts of fancier operators; e.g., -@samp{.} represents what we call the match-any-character operator -(which, no surprise, matches (almost) any character); we call these -characters @dfn{special}. Two different things determine what -characters represent what operators: - -@enumerate -@item -the regular expression syntax your program has told the Regex library to -recognize, and - -@item -the context of the character in the regular expression. -@end enumerate - -In the following sections, we describe these things in more detail. - -@menu -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: -@end menu - - -@node Syntax Bits, Predefined Syntaxes, , Regular Expression Syntax -@section Syntax Bits - -@cindex syntax bits - -In any particular syntax for regular expressions, some characters are -always special, others are sometimes special, and others are never -special. The particular syntax that Regex recognizes for a given -regular expression depends on the value in the @code{syntax} field of -the pattern buffer of that regular expression. - -You get a pattern buffer by compiling a regular expression. @xref{GNU -Pattern Buffers}, and @ref{POSIX Pattern Buffers}, for more information -on pattern buffers. @xref{GNU Regular Expression Compiling}, @ref{POSIX -Regular Expression Compiling}, and @ref{BSD Regular Expression -Compiling}, for more information on compiling. - -Regex considers the value of the @code{syntax} field to be a collection -of bits; we refer to these bits as @dfn{syntax bits}. In most cases, -they affect what characters represent what operators. We describe the -meanings of the operators to which we refer in @ref{Common Operators}, -@ref{GNU Operators}, and @ref{GNU Emacs Operators}. - -For reference, here is the complete list of syntax bits, in alphabetical -order: - -@table @code - -@cnindex RE_BACKSLASH_ESCAPE_IN_LIST -@item RE_BACKSLASH_ESCAPE_IN_LISTS -If this bit is set, then @samp{\} inside a list (@pxref{List Operators} -quotes (makes ordinary, if it's special) the following character; if -this bit isn't set, then @samp{\} is an ordinary character inside lists. -(@xref{The Backslash Character}, for what `\' does outside of lists.) - -@cnindex RE_BK_PLUS_QM -@item RE_BK_PLUS_QM -If this bit is set, then @samp{\+} represents the match-one-or-more -operator and @samp{\?} represents the match-zero-or-more operator; if -this bit isn't set, then @samp{+} represents the match-one-or-more -operator and @samp{?} represents the match-zero-or-one operator. This -bit is irrelevant if @code{RE_LIMITED_OPS} is set. - -@cnindex RE_CHAR_CLASSES -@item RE_CHAR_CLASSES -If this bit is set, then you can use character classes in lists; if this -bit isn't set, then you can't. - -@cnindex RE_CONTEXT_INDEP_ANCHORS -@item RE_CONTEXT_INDEP_ANCHORS -If this bit is set, then @samp{^} and @samp{$} are special anywhere outside -a list; if this bit isn't set, then these characters are special only in -certain contexts. @xref{Match-beginning-of-line Operator}, and -@ref{Match-end-of-line Operator}. - -@cnindex RE_CONTEXT_INDEP_OPS -@item RE_CONTEXT_INDEP_OPS -If this bit is set, then certain characters are special anywhere outside -a list; if this bit isn't set, then those characters are special only in -some contexts and are ordinary elsewhere. Specifically, if this bit -isn't set then @samp{*}, and (if the syntax bit @code{RE_LIMITED_OPS} -isn't set) @samp{+} and @samp{?} (or @samp{\+} and @samp{\?}, depending -on the syntax bit @code{RE_BK_PLUS_QM}) represent repetition operators -only if they're not first in a regular expression or just after an -open-group or alternation operator. The same holds for @samp{@{} (or -@samp{\@{}, depending on the syntax bit @code{RE_NO_BK_BRACES}) if -it is the beginning of a valid interval and the syntax bit -@code{RE_INTERVALS} is set. - -@cnindex RE_CONTEXT_INVALID_OPS -@item RE_CONTEXT_INVALID_OPS -If this bit is set, then repetition and alternation operators can't be -in certain positions within a regular expression. Specifically, the -regular expression is invalid if it has: - -@itemize @bullet - -@item -a repetition operator first in the regular expression or just after a -match-beginning-of-line, open-group, or alternation operator; or - -@item -an alternation operator first or last in the regular expression, just -before a match-end-of-line operator, or just after an alternation or -open-group operator. - -@end itemize - -If this bit isn't set, then you can put the characters representing the -repetition and alternation characters anywhere in a regular expression. -Whether or not they will in fact be operators in certain positions -depends on other syntax bits. - -@cnindex RE_DOT_NEWLINE -@item RE_DOT_NEWLINE -If this bit is set, then the match-any-character operator matches -a newline; if this bit isn't set, then it doesn't. - -@cnindex RE_DOT_NOT_NULL -@item RE_DOT_NOT_NULL -If this bit is set, then the match-any-character operator doesn't match -a null character; if this bit isn't set, then it does. - -@cnindex RE_INTERVALS -@item RE_INTERVALS -If this bit is set, then Regex recognizes interval operators; if this bit -isn't set, then it doesn't. - -@cnindex RE_LIMITED_OPS -@item RE_LIMITED_OPS -If this bit is set, then Regex doesn't recognize the match-one-or-more, -match-zero-or-one or alternation operators; if this bit isn't set, then -it does. - -@cnindex RE_NEWLINE_ALT -@item RE_NEWLINE_ALT -If this bit is set, then newline represents the alternation operator; if -this bit isn't set, then newline is ordinary. - -@cnindex RE_NO_BK_BRACES -@item RE_NO_BK_BRACES -If this bit is set, then @samp{@{} represents the open-interval operator -and @samp{@}} represents the close-interval operator; if this bit isn't -set, then @samp{\@{} represents the open-interval operator and -@samp{\@}} represents the close-interval operator. This bit is relevant -only if @code{RE_INTERVALS} is set. - -@cnindex RE_NO_BK_PARENS -@item RE_NO_BK_PARENS -If this bit is set, then @samp{(} represents the open-group operator and -@samp{)} represents the close-group operator; if this bit isn't set, then -@samp{\(} represents the open-group operator and @samp{\)} represents -the close-group operator. - -@cnindex RE_NO_BK_REFS -@item RE_NO_BK_REFS -If this bit is set, then Regex doesn't recognize @samp{\}@var{digit} as -the back reference operator; if this bit isn't set, then it does. - -@cnindex RE_NO_BK_VBAR -@item RE_NO_BK_VBAR -If this bit is set, then @samp{|} represents the alternation operator; -if this bit isn't set, then @samp{\|} represents the alternation -operator. This bit is irrelevant if @code{RE_LIMITED_OPS} is set. - -@cnindex RE_NO_EMPTY_RANGES -@item RE_NO_EMPTY_RANGES -If this bit is set, then a regular expression with a range whose ending -point collates lower than its starting point is invalid; if this bit -isn't set, then Regex considers such a range to be empty. - -@cnindex RE_UNMATCHED_RIGHT_PAREN_ORD -@item RE_UNMATCHED_RIGHT_PAREN_ORD -If this bit is set and the regular expression has no matching open-group -operator, then Regex considers what would otherwise be a close-group -operator (based on how @code{RE_NO_BK_PARENS} is set) to match @samp{)}. - -@end table - - -@node Predefined Syntaxes, Collating Elements vs. Characters, Syntax Bits, Regular Expression Syntax -@section Predefined Syntaxes - -If you're programming with Regex, you can set a pattern buffer's -(@pxref{GNU Pattern Buffers}, and @ref{POSIX Pattern Buffers}) -@code{syntax} field either to an arbitrary combination of syntax bits -(@pxref{Syntax Bits}) or else to the configurations defined by Regex. -These configurations define the syntaxes used by certain -programs---@sc{gnu} Emacs, -@cindex Emacs -@sc{posix} Awk, -@cindex POSIX Awk -traditional Awk, -@cindex Awk -Grep, -@cindex Grep -@cindex Egrep -Egrep---in addition to syntaxes for @sc{posix} basic and extended -regular expressions. - -The predefined syntaxes--taken directly from @file{regex.h}---are: - -@example -#define RE_SYNTAX_EMACS 0 - -#define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -#define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) - -#define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - -#define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - -#define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) - -/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ -#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - -#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - -/* Syntax bits common to both basic and extended POSIX regex syntax. */ -#define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - -#define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) - -/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ -#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - -#define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS - replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ -#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) -@end example - -@node Collating Elements vs. Characters, The Backslash Character, Predefined Syntaxes, Regular Expression Syntax -@section Collating Elements vs.@: Characters - -@sc{posix} generalizes the notion of a character to that of a -collating element. It defines a @dfn{collating element} to be ``a -sequence of one or more bytes defined in the current collating sequence -as a unit of collation.'' - -This generalizes the notion of a character in -two ways. First, a single character can map into two or more collating -elements. For example, the German -@tex -`\ss' -@end tex -@ifinfo -``es-zet'' -@end ifinfo -collates as the collating element @samp{s} followed by another collating -element @samp{s}. Second, two or more characters can map into one -collating element. For example, the Spanish @samp{ll} collates after -@samp{l} and before @samp{m}. - -Since @sc{posix}'s ``collating element'' preserves the essential idea of -a ``character,'' we use the latter, more familiar, term in this document. - -@node The Backslash Character, , Collating Elements vs. Characters, Regular Expression Syntax -@section The Backslash Character - -@cindex \ -The @samp{\} character has one of four different meanings, depending on -the context in which you use it and what syntax bits are set -(@pxref{Syntax Bits}). It can: 1) stand for itself, 2) quote the next -character, 3) introduce an operator, or 4) do nothing. - -@enumerate -@item -It stands for itself inside a list -(@pxref{List Operators}) if the syntax bit -@code{RE_BACKSLASH_ESCAPE_IN_LISTS} is not set. For example, @samp{[\]} -would match @samp{\}. - -@item -It quotes (makes ordinary, if it's special) the next character when you -use it either: - -@itemize @bullet -@item -outside a list,@footnote{Sometimes -you don't have to explicitly quote special characters to make -them ordinary. For instance, most characters lose any special meaning -inside a list (@pxref{List Operators}). In addition, if the syntax bits -@code{RE_CONTEXT_INVALID_OPS} and @code{RE_CONTEXT_INDEP_OPS} -aren't set, then (for historical reasons) the matcher considers special -characters ordinary if they are in contexts where the operations they -represent make no sense; for example, then the match-zero-or-more -operator (represented by @samp{*}) matches itself in the regular -expression @samp{*foo} because there is no preceding expression on which -it can operate. It is poor practice, however, to depend on this -behavior; if you want a special character to be ordinary outside a list, -it's better to always quote it, regardless.} or - -@item -inside a list and the syntax bit @code{RE_BACKSLASH_ESCAPE_IN_LISTS} is set. - -@end itemize - -@item -It introduces an operator when followed by certain ordinary -characters---sometimes only when certain syntax bits are set. See the -cases @code{RE_BK_PLUS_QM}, @code{RE_NO_BK_BRACES}, @code{RE_NO_BK_VAR}, -@code{RE_NO_BK_PARENS}, @code{RE_NO_BK_REF} in @ref{Syntax Bits}. Also: - -@itemize @bullet -@item -@samp{\b} represents the match-word-boundary operator -(@pxref{Match-word-boundary Operator}). - -@item -@samp{\B} represents the match-within-word operator -(@pxref{Match-within-word Operator}). - -@item -@samp{\<} represents the match-beginning-of-word operator @* -(@pxref{Match-beginning-of-word Operator}). - -@item -@samp{\>} represents the match-end-of-word operator -(@pxref{Match-end-of-word Operator}). - -@item -@samp{\w} represents the match-word-constituent operator -(@pxref{Match-word-constituent Operator}). - -@item -@samp{\W} represents the match-non-word-constituent operator -(@pxref{Match-non-word-constituent Operator}). - -@item -@samp{\`} represents the match-beginning-of-buffer -operator and @samp{\'} represents the match-end-of-buffer operator -(@pxref{Buffer Operators}). - -@item -If Regex was compiled with the C preprocessor symbol @code{emacs} -defined, then @samp{\s@var{class}} represents the match-syntactic-class -operator and @samp{\S@var{class}} represents the -match-not-syntactic-class operator (@pxref{Syntactic Class Operators}). - -@end itemize - -@item -In all other cases, Regex ignores @samp{\}. For example, -@samp{\n} matches @samp{n}. - -@end enumerate - -@node Common Operators, GNU Operators, Regular Expression Syntax, Top -@chapter Common Operators - -You compose regular expressions from operators. In the following -sections, we describe the regular expression operators specified by -@sc{posix}; @sc{gnu} also uses these. Most operators have more than one -representation as characters. @xref{Regular Expression Syntax}, for -what characters represent what operators under what circumstances. - -For most operators that can be represented in two ways, one -representation is a single character and the other is that character -preceded by @samp{\}. For example, either @samp{(} or @samp{\(} -represents the open-group operator. Which one does depends on the -setting of a syntax bit, in this case @code{RE_NO_BK_PARENS}. Why is -this so? Historical reasons dictate some of the varying -representations, while @sc{posix} dictates others. - -Finally, almost all characters lose any special meaning inside a list -(@pxref{List Operators}). - -@menu -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? @{@} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ -@end menu - -@node Match-self Operator, Match-any-character Operator, , Common Operators -@section The Match-self Operator (@var{ordinary character}) - -This operator matches the character itself. All ordinary characters -(@pxref{Regular Expression Syntax}) represent this operator. For -example, @samp{f} is always an ordinary character, so the regular -expression @samp{f} matches only the string @samp{f}. In -particular, it does @emph{not} match the string @samp{ff}. - -@node Match-any-character Operator, Concatenation Operator, Match-self Operator, Common Operators -@section The Match-any-character Operator (@code{.}) - -@cindex @samp{.} - -This operator matches any single printing or nonprinting character -except it won't match a: - -@table @asis -@item newline -if the syntax bit @code{RE_DOT_NEWLINE} isn't set. - -@item null -if the syntax bit @code{RE_DOT_NOT_NULL} is set. - -@end table - -The @samp{.} (period) character represents this operator. For example, -@samp{a.b} matches any three-character string beginning with @samp{a} -and ending with @samp{b}. - -@node Concatenation Operator, Repetition Operators, Match-any-character Operator, Common Operators -@section The Concatenation Operator - -This operator concatenates two regular expressions @var{a} and @var{b}. -No character represents this operator; you simply put @var{b} after -@var{a}. The result is a regular expression that will match a string if -@var{a} matches its first part and @var{b} matches the rest. For -example, @samp{xy} (two match-self operators) matches @samp{xy}. - -@node Repetition Operators, Alternation Operator, Concatenation Operator, Common Operators -@section Repetition Operators - -Repetition operators repeat the preceding regular expression a specified -number of times. - -@menu -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: @{@} -@end menu - -@node Match-zero-or-more Operator, Match-one-or-more Operator, , Repetition Operators -@subsection The Match-zero-or-more Operator (@code{*}) - -@cindex @samp{*} - -This operator repeats the smallest possible preceding regular expression -as many times as necessary (including zero) to match the pattern. -@samp{*} represents this operator. For example, @samp{o*} -matches any string made up of zero or more @samp{o}s. Since this -operator operates on the smallest preceding regular expression, -@samp{fo*} has a repeating @samp{o}, not a repeating @samp{fo}. So, -@samp{fo*} matches @samp{f}, @samp{fo}, @samp{foo}, and so on. - -Since the match-zero-or-more operator is a suffix operator, it may be -useless as such when no regular expression precedes it. This is the -case when it: - -@itemize @bullet -@item -is first in a regular expression, or - -@item -follows a match-beginning-of-line, open-group, or alternation -operator. - -@end itemize - -@noindent -Three different things can happen in these cases: - -@enumerate -@item -If the syntax bit @code{RE_CONTEXT_INVALID_OPS} is set, then the -regular expression is invalid. - -@item -If @code{RE_CONTEXT_INVALID_OPS} isn't set, but -@code{RE_CONTEXT_INDEP_OPS} is, then @samp{*} represents the -match-zero-or-more operator (which then operates on the empty string). - -@item -Otherwise, @samp{*} is ordinary. - -@end enumerate - -@cindex backtracking -The matcher processes a match-zero-or-more operator by first matching as -many repetitions of the smallest preceding regular expression as it can. -Then it continues to match the rest of the pattern. - -If it can't match the rest of the pattern, it backtracks (as many times -as necessary), each time discarding one of the matches until it can -either match the entire pattern or be certain that it cannot get a -match. For example, when matching @samp{ca*ar} against @samp{caaar}, -the matcher first matches all three @samp{a}s of the string with the -@samp{a*} of the regular expression. However, it cannot then match the -final @samp{ar} of the regular expression against the final @samp{r} of -the string. So it backtracks, discarding the match of the last @samp{a} -in the string. It can then match the remaining @samp{ar}. - - -@node Match-one-or-more Operator, Match-zero-or-one Operator, Match-zero-or-more Operator, Repetition Operators -@subsection The Match-one-or-more Operator (@code{+} or @code{\+}) - -@cindex @samp{+} - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't recognize -this operator. Otherwise, if the syntax bit @code{RE_BK_PLUS_QM} isn't -set, then @samp{+} represents this operator; if it is, then @samp{\+} -does. - -This operator is similar to the match-zero-or-more operator except that -it repeats the preceding regular expression at least once; -@pxref{Match-zero-or-more Operator}, for what it operates on, how some -syntax bits affect it, and how Regex backtracks to match it. - -For example, supposing that @samp{+} represents the match-one-or-more -operator; then @samp{ca+r} matches, e.g., @samp{car} and -@samp{caaaar}, but not @samp{cr}. - -@node Match-zero-or-one Operator, Interval Operators, Match-one-or-more Operator, Repetition Operators -@subsection The Match-zero-or-one Operator (@code{?} or @code{\?}) -@cindex @samp{?} - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit -@code{RE_BK_PLUS_QM} isn't set, then @samp{?} represents this operator; -if it is, then @samp{\?} does. - -This operator is similar to the match-zero-or-more operator except that -it repeats the preceding regular expression once or not at all; -@pxref{Match-zero-or-more Operator}, to see what it operates on, how -some syntax bits affect it, and how Regex backtracks to match it. - -For example, supposing that @samp{?} represents the match-zero-or-one -operator; then @samp{ca?r} matches both @samp{car} and @samp{cr}, but -nothing else. - -@node Interval Operators, , Match-zero-or-one Operator, Repetition Operators -@subsection Interval Operators (@code{@{} @dots{} @code{@}} or @code{\@{} @dots{} @code{\@}}) - -@cindex interval expression -@cindex @samp{@{} -@cindex @samp{@}} -@cindex @samp{\@{} -@cindex @samp{\@}} - -If the syntax bit @code{RE_INTERVALS} is set, then Regex recognizes -@dfn{interval expressions}. They repeat the smallest possible preceding -regular expression a specified number of times. - -If the syntax bit @code{RE_NO_BK_BRACES} is set, @samp{@{} represents -the @dfn{open-interval operator} and @samp{@}} represents the -@dfn{close-interval operator} ; otherwise, @samp{\@{} and @samp{\@}} do. - -Specifically, supposing that @samp{@{} and @samp{@}} represent the -open-interval and close-interval operators; then: - -@table @code -@item @{@var{count}@} -matches exactly @var{count} occurrences of the preceding regular -expression. - -@item @{@var{min,}@} -matches @var{min} or more occurrences of the preceding regular -expression. - -@item @{@var{min, max}@} -matches at least @var{min} but no more than @var{max} occurrences of -the preceding regular expression. - -@end table - -The interval expression (but not necessarily the regular expression that -contains it) is invalid if: - -@itemize @bullet -@item -@var{min} is greater than @var{max}, or - -@item -any of @var{count}, @var{min}, or @var{max} are outside the range -zero to @code{RE_DUP_MAX} (which symbol @file{regex.h} -defines). - -@end itemize - -If the interval expression is invalid and the syntax bit -@code{RE_NO_BK_BRACES} is set, then Regex considers all the -characters in the would-be interval to be ordinary. If that bit -isn't set, then the regular expression is invalid. - -If the interval expression is valid but there is no preceding regular -expression on which to operate, then if the syntax bit -@code{RE_CONTEXT_INVALID_OPS} is set, the regular expression is invalid. -If that bit isn't set, then Regex considers all the characters---other -than backslashes, which it ignores---in the would-be interval to be -ordinary. - - -@node Alternation Operator, List Operators, Repetition Operators, Common Operators -@section The Alternation Operator (@code{|} or @code{\|}) - -@kindex | -@kindex \| -@cindex alternation operator -@cindex or operator - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit -@code{RE_NO_BK_VBAR} is set, then @samp{|} represents this operator; -otherwise, @samp{\|} does. - -Alternatives match one of a choice of regular expressions: -if you put the character(s) representing the alternation operator between -any two regular expressions @var{a} and @var{b}, the result matches -the union of the strings that @var{a} and @var{b} match. For -example, supposing that @samp{|} is the alternation operator, then -@samp{foo|bar|quux} would match any of @samp{foo}, @samp{bar} or -@samp{quux}. - -@ignore -@c Nobody needs to disallow empty alternatives any more. -If the syntax bit @code{RE_NO_EMPTY_ALTS} is set, then if either of the regular -expressions @var{a} or @var{b} is empty, the -regular expression is invalid. More precisely, if this syntax bit is -set, then the alternation operator can't: - -@itemize @bullet -@item -be first or last in a regular expression; - -@item -follow either another alternation operator or an open-group operator -(@pxref{Grouping Operators}); or - -@item -precede a close-group operator. - -@end itemize - -@noindent -For example, supposing @samp{(} and @samp{)} represent the open and -close-group operators, then @samp{|foo}, @samp{foo|}, @samp{foo||bar}, -@samp{foo(|bar)}, and @samp{(foo|)bar} would all be invalid. -@end ignore - -The alternation operator operates on the @emph{largest} possible -surrounding regular expressions. (Put another way, it has the lowest -precedence of any regular expression operator.) -Thus, the only way you can -delimit its arguments is to use grouping. For example, if @samp{(} and -@samp{)} are the open and close-group operators, then @samp{fo(o|b)ar} -would match either @samp{fooar} or @samp{fobar}. (@samp{foo|bar} would -match @samp{foo} or @samp{bar}.) - -@cindex backtracking -The matcher usually tries all combinations of alternatives so as to -match the longest possible string. For example, when matching -@samp{(fooq|foo)*(qbarquux|bar)} against @samp{fooqbarquux}, it cannot -take, say, the first (``depth-first'') combination it could match, since -then it would be content to match just @samp{fooqbar}. - -@comment xx something about leftmost-longest - - -@node List Operators, Grouping Operators, Alternation Operator, Common Operators -@section List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]}) - -@cindex matching list -@cindex @samp{[} -@cindex @samp{]} -@cindex @samp{^} -@cindex @samp{-} -@cindex @samp{\} -@cindex @samp{[^} -@cindex nonmatching list -@cindex matching newline -@cindex bracket expression - -@dfn{Lists}, also called @dfn{bracket expressions}, are a set of one or -more items. An @dfn{item} is a character, -@ignore -(These get added when they get implemented.) -a collating symbol, an equivalence class expression, -@end ignore -a character class expression, or a range expression. The syntax bits -affect which kinds of items you can put in a list. We explain the last -two items in subsections below. Empty lists are invalid. - -A @dfn{matching list} matches a single character represented by one of -the list items. You form a matching list by enclosing one or more items -within an @dfn{open-matching-list operator} (represented by @samp{[}) -and a @dfn{close-list operator} (represented by @samp{]}). - -For example, @samp{[ab]} matches either @samp{a} or @samp{b}. -@samp{[ad]*} matches the empty string and any string composed of just -@samp{a}s and @samp{d}s in any order. Regex considers invalid a regular -expression with a @samp{[} but no matching -@samp{]}. - -@dfn{Nonmatching lists} are similar to matching lists except that they -match a single character @emph{not} represented by one of the list -items. You use an @dfn{open-nonmatching-list operator} (represented by -@samp{[^}@footnote{Regex therefore doesn't consider the @samp{^} to be -the first character in the list. If you put a @samp{^} character first -in (what you think is) a matching list, you'll turn it into a -nonmatching list.}) instead of an open-matching-list operator to start a -nonmatching list. - -For example, @samp{[^ab]} matches any character except @samp{a} or -@samp{b}. - -If the @code{posix_newline} field in the pattern buffer (@pxref{GNU -Pattern Buffers} is set, then nonmatching lists do not match a newline. - -Most characters lose any special meaning inside a list. The special -characters inside a list follow. - -@table @samp -@item ] -ends the list if it's not the first list item. So, if you want to make -the @samp{]} character a list item, you must put it first. - -@item \ -quotes the next character if the syntax bit @code{RE_BACKSLASH_ESCAPE_IN_LISTS} is -set. - -@ignore -Put these in if they get implemented. - -@item [. -represents the open-collating-symbol operator (@pxref{Collating Symbol -Operators}). - -@item .] -represents the close-collating-symbol operator. - -@item [= -represents the open-equivalence-class operator (@pxref{Equivalence Class -Operators}). - -@item =] -represents the close-equivalence-class operator. - -@end ignore - -@item [: -represents the open-character-class operator (@pxref{Character Class -Operators}) if the syntax bit @code{RE_CHAR_CLASSES} is set and what -follows is a valid character class expression. - -@item :] -represents the close-character-class operator if the syntax bit -@code{RE_CHAR_CLASSES} is set and what precedes it is an -open-character-class operator followed by a valid character class name. - -@item - -represents the range operator (@pxref{Range Operator}) if it's -not first or last in a list or the ending point of a range. - -@end table - -@noindent -All other characters are ordinary. For example, @samp{[.*]} matches -@samp{.} and @samp{*}. - -@menu -* Character Class Operators:: [:class:] -* Range Operator:: start-end -@end menu - -@ignore -(If collating symbols and equivalence class expressions get implemented, -then add this.) - -node Collating Symbol Operators -subsubsection Collating Symbol Operators (@code{[.} @dots{} @code{.]}) - -If the syntax bit @code{XX} is set, then you can represent -collating symbols inside lists. You form a @dfn{collating symbol} by -putting a collating element between an @dfn{open-collating-symbol -operator} and an @dfn{close-collating-symbol operator}. @samp{[.} -represents the open-collating-symbol operator and @samp{.]} represents -the close-collating-symbol operator. For example, if @samp{ll} is a -collating element, then @samp{[[.ll.]]} would match @samp{ll}. - -node Equivalence Class Operators -subsubsection Equivalence Class Operators (@code{[=} @dots{} @code{=]}) -@cindex equivalence class expression in regex -@cindex @samp{[=} in regex -@cindex @samp{=]} in regex - -If the syntax bit @code{XX} is set, then Regex recognizes equivalence class -expressions inside lists. A @dfn{equivalence class expression} is a set -of collating elements which all belong to the same equivalence class. -You form an equivalence class expression by putting a collating -element between an @dfn{open-equivalence-class operator} and a -@dfn{close-equivalence-class operator}. @samp{[=} represents the -open-equivalence-class operator and @samp{=]} represents the -close-equivalence-class operator. For example, if @samp{a} and @samp{A} -were an equivalence class, then both @samp{[[=a=]]} and @samp{[[=A=]]} -would match both @samp{a} and @samp{A}. If the collating element in an -equivalence class expression isn't part of an equivalence class, then -the matcher considers the equivalence class expression to be a collating -symbol. - -@end ignore - -@node Character Class Operators, Range Operator, , List Operators -@subsection Character Class Operators (@code{[:} @dots{} @code{:]}) - -@cindex character classes -@cindex @samp{[:} in regex -@cindex @samp{:]} in regex - -If the syntax bit @code{RE_CHARACTER_CLASSES} is set, then Regex -recognizes character class expressions inside lists. A @dfn{character -class expression} matches one character from a given class. You form a -character class expression by putting a character class name between an -@dfn{open-character-class operator} (represented by @samp{[:}) and a -@dfn{close-character-class operator} (represented by @samp{:]}). The -character class names and their meanings are: - -@table @code - -@item alnum -letters and digits - -@item alpha -letters - -@item blank -system-dependent; for @sc{gnu}, a space or tab - -@item cntrl -control characters (in the @sc{ascii} encoding, code 0177 and codes -less than 040) - -@item digit -digits - -@item graph -same as @code{print} except omits space - -@item lower -lowercase letters - -@item print -printable characters (in the @sc{ascii} encoding, space -tilde---codes 040 through 0176) - -@item punct -neither control nor alphanumeric characters - -@item space -space, carriage return, newline, vertical tab, and form feed - -@item upper -uppercase letters - -@item xdigit -hexadecimal digits: @code{0}--@code{9}, @code{a}--@code{f}, @code{A}--@code{F} - -@end table - -@noindent -These correspond to the definitions in the C library's @file{} -facility. For example, @samp{[:alpha:]} corresponds to the standard -facility @code{isalpha}. Regex recognizes character class expressions -only inside of lists; so @samp{[[:alpha:]]} matches any letter, but -@samp{[:alpha:]} outside of a bracket expression and not followed by a -repetition operator matches just itself. - -@node Range Operator, , Character Class Operators, List Operators -@subsection The Range Operator (@code{-}) - -Regex recognizes @dfn{range expressions} inside a list. They represent -those characters -that fall between two elements in the current collating sequence. You -form a range expression by putting a @dfn{range operator} between two -@ignore -(If these get implemented, then substitute this for ``characters.'') -of any of the following: characters, collating elements, collating symbols, -and equivalence class expressions. The starting point of the range and -the ending point of the range don't have to be the same kind of item, -e.g., the starting point could be a collating element and the ending -point could be an equivalence class expression. If a range's ending -point is an equivalence class, then all the collating elements in that -class will be in the range. -@end ignore -characters.@footnote{You can't use a character class for the starting -or ending point of a range, since a character class is not a single -character.} @samp{-} represents the range operator. For example, -@samp{a-f} within a list represents all the characters from @samp{a} -through @samp{f} -inclusively. - -If the syntax bit @code{RE_NO_EMPTY_RANGES} is set, then if the range's -ending point collates less than its starting point, the range (and the -regular expression containing it) is invalid. For example, the regular -expression @samp{[z-a]} would be invalid. If this bit isn't set, then -Regex considers such a range to be empty. - -Since @samp{-} represents the range operator, if you want to make a -@samp{-} character itself -a list item, you must do one of the following: - -@itemize @bullet -@item -Put the @samp{-} either first or last in the list. - -@item -Include a range whose starting point collates strictly lower than -@samp{-} and whose ending point collates equal or higher. Unless a -range is the first item in a list, a @samp{-} can't be its starting -point, but @emph{can} be its ending point. That is because Regex -considers @samp{-} to be the range operator unless it is preceded by -another @samp{-}. For example, in the @sc{ascii} encoding, @samp{)}, -@samp{*}, @samp{+}, @samp{,}, @samp{-}, @samp{.}, and @samp{/} are -contiguous characters in the collating sequence. You might think that -@samp{[)-+--/]} has two ranges: @samp{)-+} and @samp{--/}. Rather, it -has the ranges @samp{)-+} and @samp{+--}, plus the character @samp{/}, so -it matches, e.g., @samp{,}, not @samp{.}. - -@item -Put a range whose starting point is @samp{-} first in the list. - -@end itemize - -For example, @samp{[-a-z]} matches a lowercase letter or a hyphen (in -English, in @sc{ascii}). - - -@node Grouping Operators, Back-reference Operator, List Operators, Common Operators -@section Grouping Operators (@code{(} @dots{} @code{)} or @code{\(} @dots{} @code{\)}) - -@kindex ( -@kindex ) -@kindex \( -@kindex \) -@cindex grouping -@cindex subexpressions -@cindex parenthesizing - -A @dfn{group}, also known as a @dfn{subexpression}, consists of an -@dfn{open-group operator}, any number of other operators, and a -@dfn{close-group operator}. Regex treats this sequence as a unit, just -as mathematics and programming languages treat a parenthesized -expression as a unit. - -Therefore, using @dfn{groups}, you can: - -@itemize @bullet -@item -delimit the argument(s) to an alternation operator (@pxref{Alternation -Operator}) or a repetition operator (@pxref{Repetition -Operators}). - -@item -keep track of the indices of the substring that matched a given group. -@xref{Using Registers}, for a precise explanation. -This lets you: - -@itemize @bullet -@item -use the back-reference operator (@pxref{Back-reference Operator}). - -@item -use registers (@pxref{Using Registers}). - -@end itemize - -@end itemize - -If the syntax bit @code{RE_NO_BK_PARENS} is set, then @samp{(} represents -the open-group operator and @samp{)} represents the -close-group operator; otherwise, @samp{\(} and @samp{\)} do. - -If the syntax bit @code{RE_UNMATCHED_RIGHT_PAREN_ORD} is set and a -close-group operator has no matching open-group operator, then Regex -considers it to match @samp{)}. - - -@node Back-reference Operator, Anchoring Operators, Grouping Operators, Common Operators -@section The Back-reference Operator (@dfn{\}@var{digit}) - -@cindex back references - -If the syntax bit @code{RE_NO_BK_REF} isn't set, then Regex recognizes -back references. A back reference matches a specified preceding group. -The back reference operator is represented by @samp{\@var{digit}} -anywhere after the end of a regular expression's @w{@var{digit}-th} -group (@pxref{Grouping Operators}). - -@var{digit} must be between @samp{1} and @samp{9}. The matcher assigns -numbers 1 through 9 to the first nine groups it encounters. By using -one of @samp{\1} through @samp{\9} after the corresponding group's -close-group operator, you can match a substring identical to the -one that the group does. - -Back references match according to the following (in all examples below, -@samp{(} represents the open-group, @samp{)} the close-group, @samp{@{} -the open-interval and @samp{@}} the close-interval operator): - -@itemize @bullet -@item -If the group matches a substring, the back reference matches an -identical substring. For example, @samp{(a)\1} matches @samp{aa} and -@samp{(bana)na\1bo\1} matches @samp{bananabanabobana}. Likewise, -@samp{(.*)\1} matches any (newline-free if the syntax bit -@code{RE_DOT_NEWLINE} isn't set) string that is composed of two -identical halves; the @samp{(.*)} matches the first half and the -@samp{\1} matches the second half. - -@item -If the group matches more than once (as it might if followed -by, e.g., a repetition operator), then the back reference matches the -substring the group @emph{last} matched. For example, -@samp{((a*)b)*\1\2} matches @samp{aabababa}; first @w{group 1} (the -outer one) matches @samp{aab} and @w{group 2} (the inner one) matches -@samp{aa}. Then @w{group 1} matches @samp{ab} and @w{group 2} matches -@samp{a}. So, @samp{\1} matches @samp{ab} and @samp{\2} matches -@samp{a}. - -@item -If the group doesn't participate in a match, i.e., it is part of an -alternative not taken or a repetition operator allows zero repetitions -of it, then the back reference makes the whole match fail. For example, -@samp{(one()|two())-and-(three\2|four\3)} matches @samp{one-and-three} -and @samp{two-and-four}, but not @samp{one-and-four} or -@samp{two-and-three}. For example, if the pattern matches -@samp{one-and-}, then its @w{group 2} matches the empty string and its -@w{group 3} doesn't participate in the match. So, if it then matches -@samp{four}, then when it tries to back reference @w{group 3}---which it -will attempt to do because @samp{\3} follows the @samp{four}---the match -will fail because @w{group 3} didn't participate in the match. - -@end itemize - -You can use a back reference as an argument to a repetition operator. For -example, @samp{(a(b))\2*} matches @samp{a} followed by two or more -@samp{b}s. Similarly, @samp{(a(b))\2@{3@}} matches @samp{abbbb}. - -If there is no preceding @w{@var{digit}-th} subexpression, the regular -expression is invalid. - - -@node Anchoring Operators, , Back-reference Operator, Common Operators -@section Anchoring Operators - -@cindex anchoring -@cindex regexp anchoring - -These operators can constrain a pattern to match only at the beginning or -end of the entire string or at the beginning or end of a line. - -@menu -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ -@end menu - - -@node Match-beginning-of-line Operator, Match-end-of-line Operator, , Anchoring Operators -@subsection The Match-beginning-of-line Operator (@code{^}) - -@kindex ^ -@cindex beginning-of-line operator -@cindex anchors - -This operator can match the empty string either at the beginning of the -string or after a newline character. Thus, it is said to @dfn{anchor} -the pattern to the beginning of a line. - -In the cases following, @samp{^} represents this operator. (Otherwise, -@samp{^} is ordinary.) - -@itemize @bullet - -@item -It (the @samp{^}) is first in the pattern, as in @samp{^foo}. - -@cnindex RE_CONTEXT_INDEP_ANCHORS @r{(and @samp{^})} -@item -The syntax bit @code{RE_CONTEXT_INDEP_ANCHORS} is set, and it is outside -a bracket expression. - -@cindex open-group operator and @samp{^} -@cindex alternation operator and @samp{^} -@item -It follows an open-group or alternation operator, as in @samp{a\(^b\)} -and @samp{a\|^b}. @xref{Grouping Operators}, and @ref{Alternation -Operator}. - -@end itemize - -These rules imply that some valid patterns containing @samp{^} cannot be -matched; for example, @samp{foo^bar} if @code{RE_CONTEXT_INDEP_ANCHORS} -is set. - -@vindex not_bol @r{field in pattern buffer} -If the @code{not_bol} field is set in the pattern buffer (@pxref{GNU -Pattern Buffers}), then @samp{^} fails to match at the beginning of the -string. @xref{POSIX Matching}, for when you might find this useful. - -@vindex newline_anchor @r{field in pattern buffer} -If the @code{newline_anchor} field is set in the pattern buffer, then -@samp{^} fails to match after a newline. This is useful when you do not -regard the string to be matched as broken into lines. - - -@node Match-end-of-line Operator, , Match-beginning-of-line Operator, Anchoring Operators -@subsection The Match-end-of-line Operator (@code{$}) - -@kindex $ -@cindex end-of-line operator -@cindex anchors - -This operator can match the empty string either at the end of -the string or before a newline character in the string. Thus, it is -said to @dfn{anchor} the pattern to the end of a line. - -It is always represented by @samp{$}. For example, @samp{foo$} usually -matches, e.g., @samp{foo} and, e.g., the first three characters of -@samp{foo\nbar}. - -Its interaction with the syntax bits and pattern buffer fields is -exactly the dual of @samp{^}'s; see the previous section. (That is, -``beginning'' becomes ``end'', ``next'' becomes ``previous'', and -``after'' becomes ``before''.) - - -@node GNU Operators, GNU Emacs Operators, Common Operators, Top -@chapter GNU Operators - -Following are operators that @sc{gnu} defines (and @sc{posix} doesn't). - -@menu -* Word Operators:: -* Buffer Operators:: -@end menu - -@node Word Operators, Buffer Operators, , GNU Operators -@section Word Operators - -The operators in this section require Regex to recognize parts of words. -Regex uses a syntax table to determine whether or not a character is -part of a word, i.e., whether or not it is @dfn{word-constituent}. - -@menu -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W -@end menu - -@node Non-Emacs Syntax Tables, Match-word-boundary Operator, , Word Operators -@subsection Non-Emacs Syntax Tables - -A @dfn{syntax table} is an array indexed by the characters in your -character set. In the @sc{ascii} encoding, therefore, a syntax table -has 256 elements. Regex always uses a @code{char *} variable -@code{re_syntax_table} as its syntax table. In some cases, it -initializes this variable and in others it expects you to initialize it. - -@itemize @bullet -@item -If Regex is compiled with the preprocessor symbols @code{emacs} and -@code{SYNTAX_TABLE} both undefined, then Regex allocates -@code{re_syntax_table} and initializes an element @var{i} either to -@code{Sword} (which it defines) if @var{i} is a letter, number, or -@samp{_}, or to zero if it's not. - -@item -If Regex is compiled with @code{emacs} undefined but @code{SYNTAX_TABLE} -defined, then Regex expects you to define a @code{char *} variable -@code{re_syntax_table} to be a valid syntax table. - -@item -@xref{Emacs Syntax Tables}, for what happens when Regex is compiled with -the preprocessor symbol @code{emacs} defined. - -@end itemize - -@node Match-word-boundary Operator, Match-within-word Operator, Non-Emacs Syntax Tables, Word Operators -@subsection The Match-word-boundary Operator (@code{\b}) - -@cindex @samp{\b} -@cindex word boundaries, matching - -This operator (represented by @samp{\b}) matches the empty string at -either the beginning or the end of a word. For example, @samp{\brat\b} -matches the separate word @samp{rat}. - -@node Match-within-word Operator, Match-beginning-of-word Operator, Match-word-boundary Operator, Word Operators -@subsection The Match-within-word Operator (@code{\B}) - -@cindex @samp{\B} - -This operator (represented by @samp{\B}) matches the empty string within -a word. For example, @samp{c\Brat\Be} matches @samp{crate}, but -@samp{dirty \Brat} doesn't match @samp{dirty rat}. - -@node Match-beginning-of-word Operator, Match-end-of-word Operator, Match-within-word Operator, Word Operators -@subsection The Match-beginning-of-word Operator (@code{\<}) - -@cindex @samp{\<} - -This operator (represented by @samp{\<}) matches the empty string at the -beginning of a word. - -@node Match-end-of-word Operator, Match-word-constituent Operator, Match-beginning-of-word Operator, Word Operators -@subsection The Match-end-of-word Operator (@code{\>}) - -@cindex @samp{\>} - -This operator (represented by @samp{\>}) matches the empty string at the -end of a word. - -@node Match-word-constituent Operator, Match-non-word-constituent Operator, Match-end-of-word Operator, Word Operators -@subsection The Match-word-constituent Operator (@code{\w}) - -@cindex @samp{\w} - -This operator (represented by @samp{\w}) matches any word-constituent -character. - -@node Match-non-word-constituent Operator, , Match-word-constituent Operator, Word Operators -@subsection The Match-non-word-constituent Operator (@code{\W}) - -@cindex @samp{\W} - -This operator (represented by @samp{\W}) matches any character that is -not word-constituent. - - -@node Buffer Operators, , Word Operators, GNU Operators -@section Buffer Operators - -Following are operators which work on buffers. In Emacs, a @dfn{buffer} -is, naturally, an Emacs buffer. For other programs, Regex considers the -entire string to be matched as the buffer. - -@menu -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' -@end menu - - -@node Match-beginning-of-buffer Operator, Match-end-of-buffer Operator, , Buffer Operators -@subsection The Match-beginning-of-buffer Operator (@code{\`}) - -@cindex @samp{\`} - -This operator (represented by @samp{\`}) matches the empty string at the -beginning of the buffer. - -@node Match-end-of-buffer Operator, , Match-beginning-of-buffer Operator, Buffer Operators -@subsection The Match-end-of-buffer Operator (@code{\'}) - -@cindex @samp{\'} - -This operator (represented by @samp{\'}) matches the empty string at the -end of the buffer. - - -@node GNU Emacs Operators, What Gets Matched?, GNU Operators, Top -@chapter GNU Emacs Operators - -Following are operators that @sc{gnu} defines (and @sc{posix} doesn't) -that you can use only when Regex is compiled with the preprocessor -symbol @code{emacs} defined. - -@menu -* Syntactic Class Operators:: -@end menu - - -@node Syntactic Class Operators, , , GNU Emacs Operators -@section Syntactic Class Operators - -The operators in this section require Regex to recognize the syntactic -classes of characters. Regex uses a syntax table to determine this. - -@menu -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS -@end menu - -@node Emacs Syntax Tables, Match-syntactic-class Operator, , Syntactic Class Operators -@subsection Emacs Syntax Tables - -A @dfn{syntax table} is an array indexed by the characters in your -character set. In the @sc{ascii} encoding, therefore, a syntax table -has 256 elements. - -If Regex is compiled with the preprocessor symbol @code{emacs} defined, -then Regex expects you to define and initialize the variable -@code{re_syntax_table} to be an Emacs syntax table. Emacs' syntax -tables are more complicated than Regex's own (@pxref{Non-Emacs Syntax -Tables}). @xref{Syntax, , Syntax, emacs, The GNU Emacs User's Manual}, -for a description of Emacs' syntax tables. - -@node Match-syntactic-class Operator, Match-not-syntactic-class Operator, Emacs Syntax Tables, Syntactic Class Operators -@subsection The Match-syntactic-class Operator (@code{\s}@var{class}) - -@cindex @samp{\s} - -This operator matches any character whose syntactic class is represented -by a specified character. @samp{\s@var{class}} represents this operator -where @var{class} is the character representing the syntactic class you -want. For example, @samp{w} represents the syntactic -class of word-constituent characters, so @samp{\sw} matches any -word-constituent character. - -@node Match-not-syntactic-class Operator, , Match-syntactic-class Operator, Syntactic Class Operators -@subsection The Match-not-syntactic-class Operator (@code{\S}@var{class}) - -@cindex @samp{\S} - -This operator is similar to the match-syntactic-class operator except -that it matches any character whose syntactic class is @emph{not} -represented by the specified character. @samp{\S@var{class}} represents -this operator. For example, @samp{w} represents the syntactic class of -word-constituent characters, so @samp{\Sw} matches any character that is -not word-constituent. - - -@node What Gets Matched?, Programming with Regex, GNU Emacs Operators, Top -@chapter What Gets Matched? - -Regex usually matches strings according to the ``leftmost longest'' -rule; that is, it chooses the longest of the leftmost matches. This -does not mean that for a regular expression containing subexpressions -that it simply chooses the longest match for each subexpression, left to -right; the overall match must also be the longest possible one. - -For example, @samp{(ac*)(c*d[ac]*)\1} matches @samp{acdacaaa}, not -@samp{acdac}, as it would if it were to choose the longest match for the -first subexpression. - - -@node Programming with Regex, Copying, What Gets Matched?, Top -@chapter Programming with Regex - -Here we describe how you use the Regex data structures and functions in -C programs. Regex has three interfaces: one designed for @sc{gnu}, one -compatible with @sc{posix} and one compatible with Berkeley @sc{unix}. - -@menu -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: -@end menu - - -@node GNU Regex Functions, POSIX Regex Functions, , Programming with Regex -@section GNU Regex Functions - -If you're writing code that doesn't need to be compatible with either -@sc{posix} or Berkeley @sc{unix}, you can use these functions. They -provide more options than the other interfaces. - -@menu -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () -@end menu - - -@node GNU Pattern Buffers, GNU Regular Expression Compiling, , GNU Regex Functions -@subsection GNU Pattern Buffers - -@cindex pattern buffer, definition of -@tindex re_pattern_buffer @r{definition} -@tindex struct re_pattern_buffer @r{definition} - -To compile, match, or search for a given regular expression, you must -supply a pattern buffer. A @dfn{pattern buffer} holds one compiled -regular expression.@footnote{Regular expressions are also referred to as -``patterns,'' hence the name ``pattern buffer.''} - -You can have several different pattern buffers simultaneously, each -holding a compiled pattern for a different regular expression. - -@file{regex.h} defines the pattern buffer @code{struct} as follows: - -@example - /* Space that holds the compiled pattern. It is declared as - `unsigned char *' because its elements are - sometimes used as array indexes. */ - unsigned char *buffer; - - /* Number of bytes to which `buffer' points. */ - unsigned long allocated; - - /* Number of bytes actually used in `buffer'. */ - unsigned long used; - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t syntax; - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses - the fastmap, if there is one, to skip over impossible - starting points for matches. */ - char *fastmap; - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation - is applied to a pattern when it is compiled and to a string - when it is matched. */ - char *translate; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in `re_search_2', to see - whether or not we should use the fastmap, so we don't set - this absolutely perfectly; see `re_compile_fastmap' (the - `duplicate' case). */ - unsigned can_be_null : 1; - - /* If REGS_UNALLOCATED, allocate space in the `regs' structure - for `max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ -#define REGS_UNALLOCATED 0 -#define REGS_REALLOCATE 1 -#define REGS_FIXED 2 - unsigned regs_allocated : 2; - - /* Set to zero when `regex_compile' compiles a pattern; set to one - by `re_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; - - /* If set, `re_match_2' does not return information about - subexpressions. */ - unsigned no_sub : 1; - - /* If set, a beginning-of-line anchor doesn't match at the - beginning of the string. */ - unsigned not_bol : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned not_eol : 1; - - /* If true, an anchor at a newline matches. */ - unsigned newline_anchor : 1; - -@end example - - -@node GNU Regular Expression Compiling, GNU Matching, GNU Pattern Buffers, GNU Regex Functions -@subsection GNU Regular Expression Compiling - -In @sc{gnu}, you can both match and search for a given regular -expression. To do either, you must first compile it in a pattern buffer -(@pxref{GNU Pattern Buffers}). - -@cindex syntax initialization -@vindex re_syntax_options @r{initialization} -Regular expressions match according to the syntax with which they were -compiled; with @sc{gnu}, you indicate what syntax you want by setting -the variable @code{re_syntax_options} (declared in @file{regex.h} and -defined in @file{regex.c}) before calling the compiling function, -@code{re_compile_pattern} (see below). @xref{Syntax Bits}, and -@ref{Predefined Syntaxes}. - -You can change the value of @code{re_syntax_options} at any time. -Usually, however, you set its value once and then never change it. - -@cindex pattern buffer initialization -@code{re_compile_pattern} takes a pattern buffer as an argument. You -must initialize the following fields: - -@table @code - -@item translate @r{initialization} - -@item translate -@vindex translate @r{initialization} -Initialize this to point to a translate table if you want one, or to -zero if you don't. We explain translate tables in @ref{GNU Translate -Tables}. - -@item fastmap -@vindex fastmap @r{initialization} -Initialize this to nonzero if you want a fastmap, or to zero if you -don't. - -@item buffer -@itemx allocated -@vindex buffer @r{initialization} -@vindex allocated @r{initialization} -@findex malloc -If you want @code{re_compile_pattern} to allocate memory for the -compiled pattern, set both of these to zero. If you have an existing -block of memory (allocated with @code{malloc}) you want Regex to use, -set @code{buffer} to its address and @code{allocated} to its size (in -bytes). - -@code{re_compile_pattern} uses @code{realloc} to extend the space for -the compiled pattern as necessary. - -@end table - -To compile a pattern buffer, use: - -@findex re_compile_pattern -@example -char * -re_compile_pattern (const char *@var{regex}, const int @var{regex_size}, - struct re_pattern_buffer *@var{pattern_buffer}) -@end example - -@noindent -@var{regex} is the regular expression's address, @var{regex_size} is its -length, and @var{pattern_buffer} is the pattern buffer's address. - -If @code{re_compile_pattern} successfully compiles the regular -expression, it returns zero and sets @code{*@var{pattern_buffer}} to the -compiled pattern. It sets the pattern buffer's fields as follows: - -@table @code -@item buffer -@vindex buffer @r{field, set by @code{re_compile_pattern}} -to the compiled pattern. - -@item used -@vindex used @r{field, set by @code{re_compile_pattern}} -to the number of bytes the compiled pattern in @code{buffer} occupies. - -@item syntax -@vindex syntax @r{field, set by @code{re_compile_pattern}} -to the current value of @code{re_syntax_options}. - -@item re_nsub -@vindex re_nsub @r{field, set by @code{re_compile_pattern}} -to the number of subexpressions in @var{regex}. - -@item fastmap_accurate -@vindex fastmap_accurate @r{field, set by @code{re_compile_pattern}} -to zero on the theory that the pattern you're compiling is different -than the one previously compiled into @code{buffer}; in that case (since -you can't make a fastmap without a compiled pattern), -@code{fastmap} would either contain an incompatible fastmap, or nothing -at all. - -@c xx what else? -@end table - -If @code{re_compile_pattern} can't compile @var{regex}, it returns an -error string corresponding to one of the errors listed in @ref{POSIX -Regular Expression Compiling}. - - -@node GNU Matching, GNU Searching, GNU Regular Expression Compiling, GNU Regex Functions -@subsection GNU Matching - -@cindex matching with GNU functions - -Matching the @sc{gnu} way means trying to match as much of a string as -possible starting at a position within it you specify. Once you've compiled -a pattern into a pattern buffer (@pxref{GNU Regular Expression -Compiling}), you can ask the matcher to match that pattern against a -string using: - -@findex re_match -@example -int -re_match (struct re_pattern_buffer *@var{pattern_buffer}, - const char *@var{string}, const int @var{size}, - const int @var{start}, struct re_registers *@var{regs}) -@end example - -@noindent -@var{pattern_buffer} is the address of a pattern buffer containing a -compiled pattern. @var{string} is the string you want to match; it can -contain newline and null characters. @var{size} is the length of that -string. @var{start} is the string index at which you want to -begin matching; the first character of @var{string} is at index zero. -@xref{Using Registers}, for a explanation of @var{regs}; you can safely -pass zero. - -@code{re_match} matches the regular expression in @var{pattern_buffer} -against the string @var{string} according to the syntax in -@var{pattern_buffers}'s @code{syntax} field. (@xref{GNU Regular -Expression Compiling}, for how to set it.) The function returns -@math{-1} if the compiled pattern does not match any part of -@var{string} and @math{-2} if an internal error happens; otherwise, it -returns how many (possibly zero) characters of @var{string} the pattern -matched. - -An example: suppose @var{pattern_buffer} points to a pattern buffer -containing the compiled pattern for @samp{a*}, and @var{string} points -to @samp{aaaaab} (whereupon @var{size} should be 6). Then if @var{start} -is 2, @code{re_match} returns 3, i.e., @samp{a*} would have matched the -last three @samp{a}s in @var{string}. If @var{start} is 0, -@code{re_match} returns 5, i.e., @samp{a*} would have matched all the -@samp{a}s in @var{string}. If @var{start} is either 5 or 6, it returns -zero. - -If @var{start} is not between zero and @var{size}, then -@code{re_match} returns @math{-1}. - - -@node GNU Searching, Matching/Searching with Split Data, GNU Matching, GNU Regex Functions -@subsection GNU Searching - -@cindex searching with GNU functions - -@dfn{Searching} means trying to match starting at successive positions -within a string. The function @code{re_search} does this. - -Before calling @code{re_search}, you must compile your regular -expression. @xref{GNU Regular Expression Compiling}. - -Here is the function declaration: - -@findex re_search -@example -int -re_search (struct re_pattern_buffer *@var{pattern_buffer}, - const char *@var{string}, const int @var{size}, - const int @var{start}, const int @var{range}, - struct re_registers *@var{regs}) -@end example - -@noindent -@vindex start @r{argument to @code{re_search}} -@vindex range @r{argument to @code{re_search}} -whose arguments are the same as those to @code{re_match} (@pxref{GNU -Matching}) except that the two arguments @var{start} and @var{range} -replace @code{re_match}'s argument @var{start}. - -If @var{range} is positive, then @code{re_search} attempts a match -starting first at index @var{start}, then at @math{@var{start} + 1} if -that fails, and so on, up to @math{@var{start} + @var{range}}; if -@var{range} is negative, then it attempts a match starting first at -index @var{start}, then at @math{@var{start} -1} if that fails, and so -on. - -If @var{start} is not between zero and @var{size}, then @code{re_search} -returns @math{-1}. When @var{range} is positive, @code{re_search} -adjusts @var{range} so that @math{@var{start} + @var{range} - 1} is -between zero and @var{size}, if necessary; that way it won't search -outside of @var{string}. Similarly, when @var{range} is negative, -@code{re_search} adjusts @var{range} so that @math{@var{start} + -@var{range} + 1} is between zero and @var{size}, if necessary. - -If the @code{fastmap} field of @var{pattern_buffer} is zero, -@code{re_search} matches starting at consecutive positions; otherwise, -it uses @code{fastmap} to make the search more efficient. -@xref{Searching with Fastmaps}. - -If no match is found, @code{re_search} returns @math{-1}. If -a match is found, it returns the index where the match began. If an -internal error happens, it returns @math{-2}. - - -@node Matching/Searching with Split Data, Searching with Fastmaps, GNU Searching, GNU Regex Functions -@subsection Matching and Searching with Split Data - -Using the functions @code{re_match_2} and @code{re_search_2}, you can -match or search in data that is divided into two strings. - -The function: - -@findex re_match_2 -@example -int -re_match_2 (struct re_pattern_buffer *@var{buffer}, - const char *@var{string1}, const int @var{size1}, - const char *@var{string2}, const int @var{size2}, - const int @var{start}, - struct re_registers *@var{regs}, - const int @var{stop}) -@end example - -@noindent -is similar to @code{re_match} (@pxref{GNU Matching}) except that you -pass @emph{two} data strings and sizes, and an index @var{stop} beyond -which you don't want the matcher to try matching. As with -@code{re_match}, if it succeeds, @code{re_match_2} returns how many -characters of @var{string} it matched. Regard @var{string1} and -@var{string2} as concatenated when you set the arguments @var{start} and -@var{stop} and use the contents of @var{regs}; @code{re_match_2} never -returns a value larger than @math{@var{size1} + @var{size2}}. - -The function: - -@findex re_search_2 -@example -int -re_search_2 (struct re_pattern_buffer *@var{buffer}, - const char *@var{string1}, const int @var{size1}, - const char *@var{string2}, const int @var{size2}, - const int @var{start}, const int @var{range}, - struct re_registers *@var{regs}, - const int @var{stop}) -@end example - -@noindent -is similarly related to @code{re_search}. - - -@node Searching with Fastmaps, GNU Translate Tables, Matching/Searching with Split Data, GNU Regex Functions -@subsection Searching with Fastmaps - -@cindex fastmaps -If you're searching through a long string, you should use a fastmap. -Without one, the searcher tries to match at consecutive positions in the -string. Generally, most of the characters in the string could not start -a match. It takes much longer to try matching at a given position in the -string than it does to check in a table whether or not the character at -that position could start a match. A @dfn{fastmap} is such a table. - -More specifically, a fastmap is an array indexed by the characters in -your character set. Under the @sc{ascii} encoding, therefore, a fastmap -has 256 elements. If you want the searcher to use a fastmap with a -given pattern buffer, you must allocate the array and assign the array's -address to the pattern buffer's @code{fastmap} field. You either can -compile the fastmap yourself or have @code{re_search} do it for you; -when @code{fastmap} is nonzero, it automatically compiles a fastmap the -first time you search using a particular compiled pattern. - -To compile a fastmap yourself, use: - -@findex re_compile_fastmap -@example -int -re_compile_fastmap (struct re_pattern_buffer *@var{pattern_buffer}) -@end example - -@noindent -@var{pattern_buffer} is the address of a pattern buffer. If the -character @var{c} could start a match for the pattern, -@code{re_compile_fastmap} makes -@code{@var{pattern_buffer}->fastmap[@var{c}]} nonzero. It returns -@math{0} if it can compile a fastmap and @math{-2} if there is an -internal error. For example, if @samp{|} is the alternation operator -and @var{pattern_buffer} holds the compiled pattern for @samp{a|b}, then -@code{re_compile_fastmap} sets @code{fastmap['a']} and -@code{fastmap['b']} (and no others). - -@code{re_search} uses a fastmap as it moves along in the string: it -checks the string's characters until it finds one that's in the fastmap. -Then it tries matching at that character. If the match fails, it -repeats the process. So, by using a fastmap, @code{re_search} doesn't -waste time trying to match at positions in the string that couldn't -start a match. - -If you don't want @code{re_search} to use a fastmap, -store zero in the @code{fastmap} field of the pattern buffer before -calling @code{re_search}. - -Once you've initialized a pattern buffer's @code{fastmap} field, you -need never do so again---even if you compile a new pattern in -it---provided the way the field is set still reflects whether or not you -want a fastmap. @code{re_search} will still either do nothing if -@code{fastmap} is null or, if it isn't, compile a new fastmap for the -new pattern. - -@node GNU Translate Tables, Using Registers, Searching with Fastmaps, GNU Regex Functions -@subsection GNU Translate Tables - -If you set the @code{translate} field of a pattern buffer to a translate -table, then the @sc{gnu} Regex functions to which you've passed that -pattern buffer use it to apply a simple transformation -to all the regular expression and string characters at which they look. - -A @dfn{translate table} is an array indexed by the characters in your -character set. Under the @sc{ascii} encoding, therefore, a translate -table has 256 elements. The array's elements are also characters in -your character set. When the Regex functions see a character @var{c}, -they use @code{translate[@var{c}]} in its place, with one exception: the -character after a @samp{\} is not translated. (This ensures that, the -operators, e.g., @samp{\B} and @samp{\b}, are always distinguishable.) - -For example, a table that maps all lowercase letters to the -corresponding uppercase ones would cause the matcher to ignore -differences in case.@footnote{A table that maps all uppercase letters to -the corresponding lowercase ones would work just as well for this -purpose.} Such a table would map all characters except lowercase letters -to themselves, and lowercase letters to the corresponding uppercase -ones. Under the @sc{ascii} encoding, here's how you could initialize -such a table (we'll call it @code{case_fold}): - -@example -for (i = 0; i < 256; i++) - case_fold[i] = i; -for (i = 'a'; i <= 'z'; i++) - case_fold[i] = i - ('a' - 'A'); -@end example - -You tell Regex to use a translate table on a given pattern buffer by -assigning that table's address to the @code{translate} field of that -buffer. If you don't want Regex to do any translation, put zero into -this field. You'll get weird results if you change the table's contents -anytime between compiling the pattern buffer, compiling its fastmap, and -matching or searching with the pattern buffer. - -@node Using Registers, Freeing GNU Pattern Buffers, GNU Translate Tables, GNU Regex Functions -@subsection Using Registers - -A group in a regular expression can match a (posssibly empty) substring -of the string that regular expression as a whole matched. The matcher -remembers the beginning and end of the substring matched by -each group. - -To find out what they matched, pass a nonzero @var{regs} argument to a -@sc{gnu} matching or searching function (@pxref{GNU Matching} and -@ref{GNU Searching}), i.e., the address of a structure of this type, as -defined in @file{regex.h}: - -@c We don't bother to include this directly from regex.h, -@c since it changes so rarely. -@example -@tindex re_registers -@vindex num_regs @r{in @code{struct re_registers}} -@vindex start @r{in @code{struct re_registers}} -@vindex end @r{in @code{struct re_registers}} -struct re_registers -@{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -@}; -@end example - -Except for (possibly) the @var{num_regs}'th element (see below), the -@var{i}th element of the @code{start} and @code{end} arrays records -information about the @var{i}th group in the pattern. (They're declared -as C pointers, but this is only because not all C compilers accept -zero-length arrays; conceptually, it is simplest to think of them as -arrays.) - -The @code{start} and @code{end} arrays are allocated in various ways, -depending on the value of the @code{regs_allocated} -@vindex regs_allocated -field in the pattern buffer passed to the matcher. - -The simplest and perhaps most useful is to let the matcher (re)allocate -enough space to record information for all the groups in the regular -expression. If @code{regs_allocated} is @code{REGS_UNALLOCATED}, -@vindex REGS_UNALLOCATED -the matcher allocates @math{1 + @var{re_nsub}} (another field in the -pattern buffer; @pxref{GNU Pattern Buffers}). The extra element is set -to @math{-1}, and sets @code{regs_allocated} to @code{REGS_REALLOCATE}. -@vindex REGS_REALLOCATE -Then on subsequent calls with the same pattern buffer and @var{regs} -arguments, the matcher reallocates more space if necessary. - -It would perhaps be more logical to make the @code{regs_allocated} field -part of the @code{re_registers} structure, instead of part of the -pattern buffer. But in that case the caller would be forced to -initialize the structure before passing it. Much existing code doesn't -do this initialization, and it's arguably better to avoid it anyway. - -@code{re_compile_pattern} sets @code{regs_allocated} to -@code{REGS_UNALLOCATED}, -so if you use the GNU regular expression -functions, you get this behavior by default. - -xx document re_set_registers - -@sc{posix}, on the other hand, requires a different interface: the -caller is supposed to pass in a fixed-length array which the matcher -fills. Therefore, if @code{regs_allocated} is @code{REGS_FIXED} -@vindex REGS_FIXED -the matcher simply fills that array. - -The following examples illustrate the information recorded in the -@code{re_registers} structure. (In all of them, @samp{(} represents the -open-group and @samp{)} the close-group operator. The first character -in the string @var{string} is at index 0.) - -@c xx i'm not sure this is all true anymore. - -@itemize @bullet - -@item -If the regular expression has an @w{@var{i}-th} -group not contained within another group that matches a -substring of @var{string}, then the function sets -@code{@w{@var{regs}->}start[@var{i}]} to the index in @var{string} where -the substring matched by the @w{@var{i}-th} group begins, and -@code{@w{@var{regs}->}end[@var{i}]} to the index just beyond that -substring's end. The function sets @code{@w{@var{regs}->}start[0]} and -@code{@w{@var{regs}->}end[0]} to analogous information about the entire -pattern. - -For example, when you match @samp{((a)(b))} against @samp{ab}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 2 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 2 in @code{@w{@var{regs}->}end[1]} - -@item -0 in @code{@w{@var{regs}->}start[2]} and 1 in @code{@w{@var{regs}->}end[2]} - -@item -1 in @code{@w{@var{regs}->}start[3]} and 2 in @code{@w{@var{regs}->}end[3]} -@end itemize - -@item -If a group matches more than once (as it might if followed by, -e.g., a repetition operator), then the function reports the information -about what the group @emph{last} matched. - -For example, when you match the pattern @samp{(a)*} against the string -@samp{aa}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 2 in @code{@w{@var{regs}->}end[0]} - -@item -1 in @code{@w{@var{regs}->}start[1]} and 2 in @code{@w{@var{regs}->}end[1]} -@end itemize - -@item -If the @w{@var{i}-th} group does not participate in a -successful match, e.g., it is an alternative not taken or a -repetition operator allows zero repetitions of it, then the function -sets @code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to @math{-1}. - -For example, when you match the pattern @samp{(a)*b} against -the string @samp{b}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[1]} and @math{-1} in @code{@w{@var{regs}->}end[1]} -@end itemize - -@item -If the @w{@var{i}-th} group matches a zero-length string, then the -function sets @code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to the index just beyond that -zero-length string. - -For example, when you match the pattern @samp{(a*)b} against the string -@samp{b}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 0 in @code{@w{@var{regs}->}end[1]} -@end itemize - -@ignore -The function sets @code{@w{@var{regs}->}start[0]} and -@code{@w{@var{regs}->}end[0]} to analogous information about the entire -pattern. - -For example, when you match the pattern @samp{(a*)} against the empty -string, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 0 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 0 in @code{@w{@var{regs}->}end[1]} -@end itemize -@end ignore - -@item -If an @w{@var{i}-th} group contains a @w{@var{j}-th} group -in turn not contained within any other group within group @var{i} and -the function reports a match of the @w{@var{i}-th} group, then it -records in @code{@w{@var{regs}->}start[@var{j}]} and -@code{@w{@var{regs}->}end[@var{j}]} the last match (if it matched) of -the @w{@var{j}-th} group. - -For example, when you match the pattern @samp{((a*)b)*} against the -string @samp{abb}, @w{group 2} last matches the empty string, so you -get what it previously matched: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 3 in @code{@w{@var{regs}->}end[0]} - -@item -2 in @code{@w{@var{regs}->}start[1]} and 3 in @code{@w{@var{regs}->}end[1]} - -@item -2 in @code{@w{@var{regs}->}start[2]} and 2 in @code{@w{@var{regs}->}end[2]} -@end itemize - -When you match the pattern @samp{((a)*b)*} against the string -@samp{abb}, @w{group 2} doesn't participate in the last match, so you -get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 3 in @code{@w{@var{regs}->}end[0]} - -@item -2 in @code{@w{@var{regs}->}start[1]} and 3 in @code{@w{@var{regs}->}end[1]} - -@item -0 in @code{@w{@var{regs}->}start[2]} and 1 in @code{@w{@var{regs}->}end[2]} -@end itemize - -@item -If an @w{@var{i}-th} group contains a @w{@var{j}-th} group -in turn not contained within any other group within group @var{i} -and the function sets -@code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to @math{-1}, then it also sets -@code{@w{@var{regs}->}start[@var{j}]} and -@code{@w{@var{regs}->}end[@var{j}]} to @math{-1}. - -For example, when you match the pattern @samp{((a)*b)*c} against the -string @samp{c}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[1]} and @math{-1} in @code{@w{@var{regs}->}end[1]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[2]} and @math{-1} in @code{@w{@var{regs}->}end[2]} -@end itemize - -@end itemize - -@node Freeing GNU Pattern Buffers, , Using Registers, GNU Regex Functions -@subsection Freeing GNU Pattern Buffers - -To free any allocated fields of a pattern buffer, you can use the -@sc{posix} function described in @ref{Freeing POSIX Pattern Buffers}, -since the type @code{regex_t}---the type for @sc{posix} pattern -buffers---is equivalent to the type @code{re_pattern_buffer}. After -freeing a pattern buffer, you need to again compile a regular expression -in it (@pxref{GNU Regular Expression Compiling}) before passing it to -a matching or searching function. - - -@node POSIX Regex Functions, BSD Regex Functions, GNU Regex Functions, Programming with Regex -@section POSIX Regex Functions - -If you're writing code that has to be @sc{posix} compatible, you'll need -to use these functions. Their interfaces are as specified by @sc{posix}, -draft 1003.2/D11.2. - -@menu -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () -@end menu - - -@node POSIX Pattern Buffers, POSIX Regular Expression Compiling, , POSIX Regex Functions -@subsection POSIX Pattern Buffers - -To compile or match a given regular expression the @sc{posix} way, you -must supply a pattern buffer exactly the way you do for @sc{gnu} -(@pxref{GNU Pattern Buffers}). @sc{posix} pattern buffers have type -@code{regex_t}, which is equivalent to the @sc{gnu} pattern buffer -type @code{re_pattern_buffer}. - - -@node POSIX Regular Expression Compiling, POSIX Matching, POSIX Pattern Buffers, POSIX Regex Functions -@subsection POSIX Regular Expression Compiling - -With @sc{posix}, you can only search for a given regular expression; you -can't match it. To do this, you must first compile it in a -pattern buffer, using @code{regcomp}. - -@ignore -Before calling @code{regcomp}, you must initialize this pattern buffer -as you do for @sc{gnu} (@pxref{GNU Regular Expression Compiling}). See -below, however, for how to choose a syntax with which to compile. -@end ignore - -To compile a pattern buffer, use: - -@findex regcomp -@example -int -regcomp (regex_t *@var{preg}, const char *@var{regex}, int @var{cflags}) -@end example - -@noindent -@var{preg} is the initialized pattern buffer's address, @var{regex} is -the regular expression's address, and @var{cflags} is the compilation -flags, which Regex considers as a collection of bits. Here are the -valid bits, as defined in @file{regex.h}: - -@table @code - -@item REG_EXTENDED -@vindex REG_EXTENDED -says to use @sc{posix} Extended Regular Expression syntax; if this isn't -set, then says to use @sc{posix} Basic Regular Expression syntax. -@code{regcomp} sets @var{preg}'s @code{syntax} field accordingly. - -@item REG_ICASE -@vindex REG_ICASE -@cindex ignoring case -says to ignore case; @code{regcomp} sets @var{preg}'s @code{translate} -field to a translate table which ignores case, replacing anything you've -put there before. - -@item REG_NOSUB -@vindex REG_NOSUB -says to set @var{preg}'s @code{no_sub} field; @pxref{POSIX Matching}, -for what this means. - -@item REG_NEWLINE -@vindex REG_NEWLINE -says that a: - -@itemize @bullet - -@item -match-any-character operator (@pxref{Match-any-character -Operator}) doesn't match a newline. - -@item -nonmatching list not containing a newline (@pxref{List -Operators}) matches a newline. - -@item -match-beginning-of-line operator (@pxref{Match-beginning-of-line -Operator}) matches the empty string immediately after a newline, -regardless of how @code{REG_NOTBOL} is set (@pxref{POSIX Matching}, for -an explanation of @code{REG_NOTBOL}). - -@item -match-end-of-line operator (@pxref{Match-beginning-of-line -Operator}) matches the empty string immediately before a newline, -regardless of how @code{REG_NOTEOL} is set (@pxref{POSIX Matching}, -for an explanation of @code{REG_NOTEOL}). - -@end itemize - -@end table - -If @code{regcomp} successfully compiles the regular expression, it -returns zero and sets @code{*@var{pattern_buffer}} to the compiled -pattern. Except for @code{syntax} (which it sets as explained above), it -also sets the same fields the same way as does the @sc{gnu} compiling -function (@pxref{GNU Regular Expression Compiling}). - -If @code{regcomp} can't compile the regular expression, it returns one -of the error codes listed here. (Except when noted differently, the -syntax of in all examples below is basic regular expression syntax.) - -@table @code - -@comment repetitions -@item REG_BADRPT -For example, the consecutive repetition operators @samp{**} in -@samp{a**} are invalid. As another example, if the syntax is extended -regular expression syntax, then the repetition operator @samp{*} with -nothing on which to operate in @samp{*} is invalid. - -@item REG_BADBR -For example, the @var{count} @samp{-1} in @samp{a\@{-1} is invalid. - -@item REG_EBRACE -For example, @samp{a\@{1} is missing a close-interval operator. - -@comment lists -@item REG_EBRACK -For example, @samp{[a} is missing a close-list operator. - -@item REG_ERANGE -For example, the range ending point @samp{z} that collates lower than -does its starting point @samp{a} in @samp{[z-a]} is invalid. Also, the -range with the character class @samp{[:alpha:]} as its starting point in -@samp{[[:alpha:]-|]}. - -@item REG_ECTYPE -For example, the character class name @samp{foo} in @samp{[[:foo:]} is -invalid. - -@comment groups -@item REG_EPAREN -For example, @samp{a\)} is missing an open-group operator and @samp{\(a} -is missing a close-group operator. - -@item REG_ESUBREG -For example, the back reference @samp{\2} that refers to a nonexistent -subexpression in @samp{\(a\)\2} is invalid. - -@comment unfinished business - -@item REG_EEND -Returned when a regular expression causes no other more specific error. - -@item REG_EESCAPE -For example, the trailing backslash @samp{\} in @samp{a\} is invalid, as is the -one in @samp{\}. - -@comment kitchen sink -@item REG_BADPAT -For example, in the extended regular expression syntax, the empty group -@samp{()} in @samp{a()b} is invalid. - -@comment internal -@item REG_ESIZE -Returned when a regular expression needs a pattern buffer larger than -65536 bytes. - -@item REG_ESPACE -Returned when a regular expression makes Regex to run out of memory. - -@end table - - -@node POSIX Matching, Reporting Errors, POSIX Regular Expression Compiling, POSIX Regex Functions -@subsection POSIX Matching - -Matching the @sc{posix} way means trying to match a null-terminated -string starting at its first character. Once you've compiled a pattern -into a pattern buffer (@pxref{POSIX Regular Expression Compiling}), you -can ask the matcher to match that pattern against a string using: - -@findex regexec -@example -int -regexec (const regex_t *@var{preg}, const char *@var{string}, - size_t @var{nmatch}, regmatch_t @var{pmatch}[], int @var{eflags}) -@end example - -@noindent -@var{preg} is the address of a pattern buffer for a compiled pattern. -@var{string} is the string you want to match. - -@xref{Using Byte Offsets}, for an explanation of @var{pmatch}. If you -pass zero for @var{nmatch} or you compiled @var{preg} with the -compilation flag @code{REG_NOSUB} set, then @code{regexec} will ignore -@var{pmatch}; otherwise, you must allocate it to have at least -@var{nmatch} elements. @code{regexec} will record @var{nmatch} byte -offsets in @var{pmatch}, and set to @math{-1} any unused elements up to -@math{@var{pmatch}@code{[@var{nmatch}]} - 1}. - -@var{eflags} specifies @dfn{execution flags}---namely, the two bits -@code{REG_NOTBOL} and @code{REG_NOTEOL} (defined in @file{regex.h}). If -you set @code{REG_NOTBOL}, then the match-beginning-of-line operator -(@pxref{Match-beginning-of-line Operator}) always fails to match. -This lets you match against pieces of a line, as you would need to if, -say, searching for repeated instances of a given pattern in a line; it -would work correctly for patterns both with and without -match-beginning-of-line operators. @code{REG_NOTEOL} works analogously -for the match-end-of-line operator (@pxref{Match-end-of-line -Operator}); it exists for symmetry. - -@code{regexec} tries to find a match for @var{preg} in @var{string} -according to the syntax in @var{preg}'s @code{syntax} field. -(@xref{POSIX Regular Expression Compiling}, for how to set it.) The -function returns zero if the compiled pattern matches @var{string} and -@code{REG_NOMATCH} (defined in @file{regex.h}) if it doesn't. - -@node Reporting Errors, Using Byte Offsets, POSIX Matching, POSIX Regex Functions -@subsection Reporting Errors - -If either @code{regcomp} or @code{regexec} fail, they return a nonzero -error code, the possibilities for which are defined in @file{regex.h}. -@xref{POSIX Regular Expression Compiling}, and @ref{POSIX Matching}, for -what these codes mean. To get an error string corresponding to these -codes, you can use: - -@findex regerror -@example -size_t -regerror (int @var{errcode}, - const regex_t *@var{preg}, - char *@var{errbuf}, - size_t @var{errbuf_size}) -@end example - -@noindent -@var{errcode} is an error code, @var{preg} is the address of the pattern -buffer which provoked the error, @var{errbuf} is the error buffer, and -@var{errbuf_size} is @var{errbuf}'s size. - -@code{regerror} returns the size in bytes of the error string -corresponding to @var{errcode} (including its terminating null). If -@var{errbuf} and @var{errbuf_size} are nonzero, it also returns in -@var{errbuf} the first @math{@var{errbuf_size} - 1} characters of the -error string, followed by a null. -@var{errbuf_size} must be a nonnegative number less than or equal to the -size in bytes of @var{errbuf}. - -You can call @code{regerror} with a null @var{errbuf} and a zero -@var{errbuf_size} to determine how large @var{errbuf} need be to -accommodate @code{regerror}'s error string. - -@node Using Byte Offsets, Freeing POSIX Pattern Buffers, Reporting Errors, POSIX Regex Functions -@subsection Using Byte Offsets - -In @sc{posix}, variables of type @code{regmatch_t} hold analogous -information, but are not identical to, @sc{gnu}'s registers (@pxref{Using -Registers}). To get information about registers in @sc{posix}, pass to -@code{regexec} a nonzero @var{pmatch} of type @code{regmatch_t}, i.e., -the address of a structure of this type, defined in -@file{regex.h}: - -@tindex regmatch_t -@example -typedef struct -@{ - regoff_t rm_so; - regoff_t rm_eo; -@} regmatch_t; -@end example - -When reading in @ref{Using Registers}, about how the matching function -stores the information into the registers, substitute @var{pmatch} for -@var{regs}, @code{@w{@var{pmatch}[@var{i}]->}rm_so} for -@code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{pmatch}[@var{i}]->}rm_eo} for -@code{@w{@var{regs}->}end[@var{i}]}. - -@node Freeing POSIX Pattern Buffers, , Using Byte Offsets, POSIX Regex Functions -@subsection Freeing POSIX Pattern Buffers - -To free any allocated fields of a pattern buffer, use: - -@findex regfree -@example -void -regfree (regex_t *@var{preg}) -@end example - -@noindent -@var{preg} is the pattern buffer whose allocated fields you want freed. -@code{regfree} also sets @var{preg}'s @code{allocated} and @code{used} -fields to zero. After freeing a pattern buffer, you need to again -compile a regular expression in it (@pxref{POSIX Regular Expression -Compiling}) before passing it to the matching function (@pxref{POSIX -Matching}). - - -@node BSD Regex Functions, , POSIX Regex Functions, Programming with Regex -@section BSD Regex Functions - -If you're writing code that has to be Berkeley @sc{unix} compatible, -you'll need to use these functions whose interfaces are the same as those -in Berkeley @sc{unix}. - -@menu -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () -@end menu - -@node BSD Regular Expression Compiling, BSD Searching, , BSD Regex Functions -@subsection BSD Regular Expression Compiling - -With Berkeley @sc{unix}, you can only search for a given regular -expression; you can't match one. To search for it, you must first -compile it. Before you compile it, you must indicate the regular -expression syntax you want it compiled according to by setting the -variable @code{re_syntax_options} (declared in @file{regex.h} to some -syntax (@pxref{Regular Expression Syntax}). - -To compile a regular expression use: - -@findex re_comp -@example -char * -re_comp (char *@var{regex}) -@end example - -@noindent -@var{regex} is the address of a null-terminated regular expression. -@code{re_comp} uses an internal pattern buffer, so you can use only the -most recently compiled pattern buffer. This means that if you want to -use a given regular expression that you've already compiled---but it -isn't the latest one you've compiled---you'll have to recompile it. If -you call @code{re_comp} with the null string (@emph{not} the empty -string) as the argument, it doesn't change the contents of the pattern -buffer. - -If @code{re_comp} successfully compiles the regular expression, it -returns zero. If it can't compile the regular expression, it returns -an error string. @code{re_comp}'s error messages are identical to those -of @code{re_compile_pattern} (@pxref{GNU Regular Expression -Compiling}). - -@node BSD Searching, , BSD Regular Expression Compiling, BSD Regex Functions -@subsection BSD Searching - -Searching the Berkeley @sc{unix} way means searching in a string -starting at its first character and trying successive positions within -it to find a match. Once you've compiled a pattern using @code{re_comp} -(@pxref{BSD Regular Expression Compiling}), you can ask Regex -to search for that pattern in a string using: - -@findex re_exec -@example -int -re_exec (char *@var{string}) -@end example - -@noindent -@var{string} is the address of the null-terminated string in which you -want to search. - -@code{re_exec} returns either 1 for success or 0 for failure. It -automatically uses a @sc{gnu} fastmap (@pxref{Searching with Fastmaps}). - - -@node Copying, Index, Programming with Regex, Top -@appendix GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 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. -@end display - -@unnumberedsec 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. - -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -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. - -@item -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. - -@item -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: - -@enumerate a -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -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. - -@item -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.) -@end enumerate - -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. - -@item -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: - -@enumerate a -@item -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, - -@item -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, - -@item -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.) -@end enumerate - -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -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. - -@item -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 enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec 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. - -@smallexample -@var{one line to give the program's name and a brief idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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. -@end smallexample - -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: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{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. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{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: - -@example -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end example - -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. - - -@node Index, , Copying, Top -@unnumbered Index - -@printindex cp - -@contents - -@bye diff --git a/gnu/lib/libregex/doc/texinfo.tex b/gnu/lib/libregex/doc/texinfo.tex deleted file mode 100644 index d10917e237db..000000000000 --- a/gnu/lib/libregex/doc/texinfo.tex +++ /dev/null @@ -1,3941 +0,0 @@ -%% TeX macros to handle texinfo files - -% Copyright (C) 1985, 86, 88, 90, 91, 92, 1993 Free Software Foundation, Inc. - -%This texinfo.tex file 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 texinfo.tex file 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 texinfo.tex file; see the file COPYING. If not, write -%to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, -%USA. - - -%In other words, you are welcome to use, share and improve this program. -%You are forbidden to forbid anyone else to use, share and improve -%what you give them. Help stamp out software-hoarding! - -\def\texinfoversion{2.104} -\message{Loading texinfo package [Version \texinfoversion]:} -\message{} - -% Print the version number if in a .fmt file. -\everyjob{\message{[Texinfo version \texinfoversion]}\message{}} - -% Save some parts of plain tex whose names we will redefine. - -\let\ptexlbrace=\{ -\let\ptexrbrace=\} -\let\ptexdots=\dots -\let\ptexdot=\. -\let\ptexstar=\* -\let\ptexend=\end -\let\ptexbullet=\bullet -\let\ptexb=\b -\let\ptexc=\c -\let\ptexi=\i -\let\ptext=\t -\let\ptexl=\l -\let\ptexL=\L - -\def\tie{\penalty 10000\ } % Save plain tex definition of ~. - -\message{Basics,} -\chardef\other=12 - -% If this character appears in an error message or help string, it -% starts a new line in the output. -\newlinechar = `^^J - -% Ignore a token. -% -\def\gobble#1{} - -\hyphenation{ap-pen-dix} -\hyphenation{mini-buf-fer mini-buf-fers} -\hyphenation{eshell} - -% Margin to add to right of even pages, to left of odd pages. -\newdimen \bindingoffset \bindingoffset=0pt -\newdimen \normaloffset \normaloffset=\hoffset -\newdimen\pagewidth \newdimen\pageheight -\pagewidth=\hsize \pageheight=\vsize - -% Sometimes it is convenient to have everything in the transcript file -% and nothing on the terminal. We don't just call \tracingall here, -% since that produces some useless output on the terminal. -% -\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% -\def\loggingall{\tracingcommands2 \tracingstats2 - \tracingpages1 \tracingoutput1 \tracinglostchars1 - \tracingmacros2 \tracingparagraphs1 \tracingrestores1 - \showboxbreadth\maxdimen\showboxdepth\maxdimen -}% - -%---------------------Begin change----------------------- -% -%%%% For @cropmarks command. -% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986 -% -\newdimen\cornerlong \newdimen\cornerthick -\newdimen \topandbottommargin -\newdimen \outerhsize \newdimen \outervsize -\cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks -\outerhsize=7in -%\outervsize=9.5in -% Alternative @smallbook page size is 9.25in -\outervsize=9.25in -\topandbottommargin=.75in -% -%---------------------End change----------------------- - -% \onepageout takes a vbox as an argument. Note that \pagecontents -% does insertions itself, but you have to call it yourself. -\chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}} -\def\onepageout#1{\hoffset=\normaloffset -\ifodd\pageno \advance\hoffset by \bindingoffset -\else \advance\hoffset by -\bindingoffset\fi -{\escapechar=`\\\relax % makes sure backslash is used in output files. -\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}% -{\let\hsize=\pagewidth \makefootline}}}% -\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} - -%%%% For @cropmarks command %%%% - -% Here is a modification of the main output routine for Near East Publications -% This provides right-angle cropmarks at all four corners. -% The contents of the page are centerlined into the cropmarks, -% and any desired binding offset is added as an \hskip on either -% site of the centerlined box. (P. A. MacKay, 12 November, 1986) -% -\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up -{\escapechar=`\\\relax % makes sure backslash is used in output files. - \shipout - \vbox to \outervsize{\hsize=\outerhsize - \vbox{\line{\ewtop\hfill\ewtop}} - \nointerlineskip - \line{\vbox{\moveleft\cornerthick\nstop} - \hfill - \vbox{\moveright\cornerthick\nstop}} - \vskip \topandbottommargin - \centerline{\ifodd\pageno\hskip\bindingoffset\fi - \vbox{ - {\let\hsize=\pagewidth \makeheadline} - \pagebody{#1} - {\let\hsize=\pagewidth \makefootline}} - \ifodd\pageno\else\hskip\bindingoffset\fi} - \vskip \topandbottommargin plus1fill minus1fill - \boxmaxdepth\cornerthick - \line{\vbox{\moveleft\cornerthick\nsbot} - \hfill - \vbox{\moveright\cornerthick\nsbot}} - \nointerlineskip - \vbox{\line{\ewbot\hfill\ewbot}} - }} - \advancepageno - \ifnum\outputpenalty>-20000 \else\dosupereject\fi} -% -% Do @cropmarks to get crop marks -\def\cropmarks{\let\onepageout=\croppageout } - -\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} -{\catcode`\@ =11 -\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi -\dimen@=\dp#1 \unvbox#1 -\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi -\ifr@ggedbottom \kern-\dimen@ \vfil \fi} -} - -% -% Here are the rules for the cropmarks. Note that they are -% offset so that the space between them is truly \outerhsize or \outervsize -% (P. A. MacKay, 12 November, 1986) -% -\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} -\def\nstop{\vbox - {\hrule height\cornerthick depth\cornerlong width\cornerthick}} -\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} -\def\nsbot{\vbox - {\hrule height\cornerlong depth\cornerthick width\cornerthick}} - -% Parse an argument, then pass it to #1. The argument is the rest of -% the input line (except we remove a trailing comment). #1 should be a -% macro which expects an ordinary undelimited TeX argument. -% -\def\parsearg#1{% - \let\next = #1% - \begingroup - \obeylines - \futurelet\temp\parseargx -} - -% If the next token is an obeyed space (from an @example environment or -% the like), remove it and recurse. Otherwise, we're done. -\def\parseargx{% - % \obeyedspace is defined far below, after the definition of \sepspaces. - \ifx\obeyedspace\temp - \expandafter\parseargdiscardspace - \else - \expandafter\parseargline - \fi -} - -% Remove a single space (as the delimiter token to the macro call). -{\obeyspaces % - \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} - -{\obeylines % - \gdef\parseargline#1^^M{% - \endgroup % End of the group started in \parsearg. - % - % First remove any @c comment, then any @comment. - % Result of each macro is put in \toks0. - \argremovec #1\c\relax % - \expandafter\argremovecomment \the\toks0 \comment\relax % - % - % Call the caller's macro, saved as \next in \parsearg. - \expandafter\next\expandafter{\the\toks0}% - }% -} - -% Since all \c{,omment} does is throw away the argument, we can let TeX -% do that for us. The \relax here is matched by the \relax in the call -% in \parseargline; it could be more or less anything, its purpose is -% just to delimit the argument to the \c. -\def\argremovec#1\c#2\relax{\toks0 = {#1}} -\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} - -% \argremovec{,omment} might leave us with trailing spaces, though; e.g., -% @end itemize @c foo -% will have two active spaces as part of the argument with the -% `itemize'. Here we remove all active spaces from #1, and assign the -% result to \toks0. -% -% This loses if there are any *other* active characters besides spaces -% in the argument -- _ ^ +, for example -- since they get expanded. -% Fortunately, Texinfo does not define any such commands. (If it ever -% does, the catcode of the characters in questionwill have to be changed -% here.) But this means we cannot call \removeactivespaces as part of -% \argremovec{,omment}, since @c uses \parsearg, and thus the argument -% that \parsearg gets might well have any character at all in it. -% -\def\removeactivespaces#1{% - \begingroup - \ignoreactivespaces - \edef\temp{#1}% - \global\toks0 = \expandafter{\temp}% - \endgroup -} - -% Change the active space to expand to nothing. -% -\begingroup - \obeyspaces - \gdef\ignoreactivespaces{\obeyspaces\let =\empty} -\endgroup - - -\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} - -%% These are used to keep @begin/@end levels from running away -%% Call \inENV within environments (after a \begingroup) -\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} -\def\ENVcheck{% -\ifENV\errmessage{Still within an environment. Type Return to continue.} -\endgroup\fi} % This is not perfect, but it should reduce lossage - -% @begin foo is the same as @foo, for now. -\newhelp\EMsimple{Type to continue.} - -\outer\def\begin{\parsearg\beginxxx} - -\def\beginxxx #1{% -\expandafter\ifx\csname #1\endcsname\relax -{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else -\csname #1\endcsname\fi} - -% @end foo executes the definition of \Efoo. -% -\def\end{\parsearg\endxxx} -\def\endxxx #1{% - \removeactivespaces{#1}% - \edef\endthing{\the\toks0}% - % - \expandafter\ifx\csname E\endthing\endcsname\relax - \expandafter\ifx\csname \endthing\endcsname\relax - % There's no \foo, i.e., no ``environment'' foo. - \errhelp = \EMsimple - \errmessage{Undefined command `@end \endthing'}% - \else - \unmatchedenderror\endthing - \fi - \else - % Everything's ok; the right environment has been started. - \csname E\endthing\endcsname - \fi -} - -% There is an environment #1, but it hasn't been started. Give an error. -% -\def\unmatchedenderror#1{% - \errhelp = \EMsimple - \errmessage{This `@end #1' doesn't have a matching `@#1'}% -} - -% Define the control sequence \E#1 to give an unmatched @end error. -% -\def\defineunmatchedend#1{% - \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% -} - - -% Single-spacing is done by various environments. - -\newskip\singlespaceskip \singlespaceskip = \baselineskip -\def\singlespace{% -{\advance \baselineskip by -\singlespaceskip -\kern \baselineskip}% -\baselineskip=\singlespaceskip -} - -%% Simple single-character @ commands - -% @@ prints an @ -% Kludge this until the fonts are right (grr). -\def\@{{\tt \char '100}} - -% This is turned off because it was never documented -% and you can use @w{...} around a quote to suppress ligatures. -%% Define @` and @' to be the same as ` and ' -%% but suppressing ligatures. -%\def\`{{`}} -%\def\'{{'}} - -% Used to generate quoted braces. - -\def\mylbrace {{\tt \char '173}} -\def\myrbrace {{\tt \char '175}} -\let\{=\mylbrace -\let\}=\myrbrace - -% @: forces normal size whitespace following. -\def\:{\spacefactor=1000 } - -% @* forces a line break. -\def\*{\hfil\break\hbox{}\ignorespaces} - -% @. is an end-of-sentence period. -\def\.{.\spacefactor=3000 } - -% @w prevents a word break. Without the \leavevmode, @w at the -% beginning of a paragraph, when TeX is still in vertical mode, would -% produce a whole line of output instead of starting the paragraph. -\def\w#1{\leavevmode\hbox{#1}} - -% @group ... @end group forces ... to be all on one page, by enclosing -% it in a TeX vbox. We use \vtop instead of \vbox to construct the box -% to keep its height that of a normal line. According to the rules for -% \topskip (p.114 of the TeXbook), the glue inserted is -% max (\topskip - \ht (first item), 0). If that height is large, -% therefore, no glue is inserted, and the space between the headline and -% the text is small, which looks bad. -% -\def\group{\begingroup - \ifnum\catcode13=\active \else - \errhelp = \groupinvalidhelp - \errmessage{@group invalid in context where filling is enabled}% - \fi - % - % The \vtop we start below produces a box with normal height and large - % depth; thus, TeX puts \baselineskip glue before it, and (when the - % next line of text is done) \lineskip glue after it. (See p.82 of - % the TeXbook.) But the next line of text also gets us \parskip glue. - % Final result: space below is slightly more than space above. - \def\Egroup{% - \egroup % End the \vtop. - \endgroup % End the \group. - }% - % - \vtop\bgroup - % We have to put a strut on the last line in case the @group is in - % the midst of an example, rather than completely enclosing it. - % Otherwise, the interline space between the last line of the group - % and the first line afterwards is too small. But we can't put the - % strut in \Egroup, since there it would be on a line by itself. - % Hence this just inserts a strut at the beginning of each line. - \everypar = {\strut}% - % - % We do @comment here in case we are called inside an environment, - % such as @example, where each end-of-line in the input causes an - % end-of-line in the output. We don't want the end-of-line after - % the `@group' to put extra space in the output. Since @group - % should appear on a line by itself (according to the Texinfo - % manual), we don't worry about eating any user text. - \comment -} -% -% TeX puts in an \escapechar (i.e., `@') at the beginning of the help -% message, so this ends up printing `@group can only ...'. -% -\newhelp\groupinvalidhelp{% -group can only be used in environments such as @example,^^J% -where each line of input produces a line of output.} - -% @need space-in-mils -% forces a page break if there is not space-in-mils remaining. - -\newdimen\mil \mil=0.001in - -\def\need{\parsearg\needx} - -% Old definition--didn't work. -%\def\needx #1{\par % -%% This method tries to make TeX break the page naturally -%% if the depth of the box does not fit. -%{\baselineskip=0pt% -%\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000 -%\prevdepth=-1000pt -%}} - -\def\needx#1{% - % Go into vertical mode, so we don't make a big box in the middle of a - % paragraph. - \par - % - % Don't add any leading before our big empty box, but allow a page - % break, since the best break might be right here. - \allowbreak - \nointerlineskip - \vtop to #1\mil{\vfil}% - % - % TeX does not even consider page breaks if a penalty added to the - % main vertical list is 10000 or more. But in order to see if the - % empty box we just added fits on the page, we must make it consider - % page breaks. On the other hand, we don't want to actually break the - % page after the empty box. So we use a penalty of 9999. - % - % There is an extremely small chance that TeX will actually break the - % page at this \penalty, if there are no other feasible breakpoints in - % sight. (If the user is using lots of big @group commands, which - % almost-but-not-quite fill up a page, TeX will have a hard time doing - % good page breaking, for example.) However, I could not construct an - % example where a page broke at this \penalty; if it happens in a real - % document, then we can reconsider our strategy. - \penalty9999 - % - % Back up by the size of the box, whether we did a page break or not. - \kern -#1\mil - % - % Do not allow a page break right after this kern. - \nobreak -} - -% @br forces paragraph break - -\let\br = \par - -% @dots{} output some dots - -\def\dots{$\ldots$} - -% @page forces the start of a new page - -\def\page{\par\vfill\supereject} - -% @exdent text.... -% outputs text on separate line in roman font, starting at standard page margin - -% This records the amount of indent in the innermost environment. -% That's how much \exdent should take out. -\newskip\exdentamount - -% This defn is used inside fill environments such as @defun. -\def\exdent{\parsearg\exdentyyy} -\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} - -% This defn is used inside nofill environments such as @example. -\def\nofillexdent{\parsearg\nofillexdentyyy} -\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount -\leftline{\hskip\leftskip{\rm#1}}}} - -%\hbox{{\rm#1}}\hfil\break}} - -% @include file insert text of that file as input. - -\def\include{\parsearg\includezzz} -%Use \input\thisfile to avoid blank after \input, which may be an active -%char (in which case the blank would become the \input argument). -%The grouping keeps the value of \thisfile correct even when @include -%is nested. -\def\includezzz #1{\begingroup -\def\thisfile{#1}\input\thisfile -\endgroup} - -\def\thisfile{} - -% @center line outputs that line, centered - -\def\center{\parsearg\centerzzz} -\def\centerzzz #1{{\advance\hsize by -\leftskip -\advance\hsize by -\rightskip -\centerline{#1}}} - -% @sp n outputs n lines of vertical space - -\def\sp{\parsearg\spxxx} -\def\spxxx #1{\par \vskip #1\baselineskip} - -% @comment ...line which is ignored... -% @c is the same as @comment -% @ignore ... @end ignore is another way to write a comment - -\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other% -\parsearg \commentxxx} - -\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 } - -\let\c=\comment - -% Prevent errors for section commands. -% Used in @ignore and in failing conditionals. -\def\ignoresections{% -\let\chapter=\relax -\let\unnumbered=\relax -\let\top=\relax -\let\unnumberedsec=\relax -\let\unnumberedsection=\relax -\let\unnumberedsubsec=\relax -\let\unnumberedsubsection=\relax -\let\unnumberedsubsubsec=\relax -\let\unnumberedsubsubsection=\relax -\let\section=\relax -\let\subsec=\relax -\let\subsubsec=\relax -\let\subsection=\relax -\let\subsubsection=\relax -\let\appendix=\relax -\let\appendixsec=\relax -\let\appendixsection=\relax -\let\appendixsubsec=\relax -\let\appendixsubsection=\relax -\let\appendixsubsubsec=\relax -\let\appendixsubsubsection=\relax -\let\contents=\relax -\let\smallbook=\relax -\let\titlepage=\relax -} - -% Used in nested conditionals, where we have to parse the Texinfo source -% and so want to turn off most commands, in case they are used -% incorrectly. -% -\def\ignoremorecommands{% - \let\defcv = \relax - \let\deffn = \relax - \let\deffnx = \relax - \let\defindex = \relax - \let\defivar = \relax - \let\defmac = \relax - \let\defmethod = \relax - \let\defop = \relax - \let\defopt = \relax - \let\defspec = \relax - \let\deftp = \relax - \let\deftypefn = \relax - \let\deftypefun = \relax - \let\deftypevar = \relax - \let\deftypevr = \relax - \let\defun = \relax - \let\defvar = \relax - \let\defvr = \relax - \let\ref = \relax - \let\xref = \relax - \let\printindex = \relax - \let\pxref = \relax - \let\settitle = \relax - \let\include = \relax -} - -% Ignore @ignore ... @end ignore. -% -\def\ignore{\doignore{ignore}} - -% Also ignore @ifinfo, @menu, and @direntry text. -% -\def\ifinfo{\doignore{ifinfo}} -\def\menu{\doignore{menu}} -\def\direntry{\doignore{direntry}} - -% Ignore text until a line `@end #1'. -% -\def\doignore#1{\begingroup - % Don't complain about control sequences we have declared \outer. - \ignoresections - % - % Define a command to swallow text until we reach `@end #1'. - \long\def\doignoretext##1\end #1{\enddoignore}% - % - % Make sure that spaces turn into tokens that match what \doignoretext wants. - \catcode32 = 10 - % - % And now expand that command. - \doignoretext -} - -% What we do to finish off ignored text. -% -\def\enddoignore{\endgroup\ignorespaces}% - -\newif\ifwarnedobs\warnedobsfalse -\def\obstexwarn{% - \ifwarnedobs\relax\else - % We need to warn folks that they may have trouble with TeX 3.0. - % This uses \immediate\write16 rather than \message to get newlines. - \immediate\write16{} - \immediate\write16{***WARNING*** for users of Unix TeX 3.0!} - \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} - \immediate\write16{If you are running another version of TeX, relax.} - \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} - \immediate\write16{ Then upgrade your TeX installation if you can.} - \immediate\write16{If you are stuck with version 3.0, run the} - \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} - \immediate\write16{ to use a workaround.} - \immediate\write16{} - \warnedobstrue - \fi -} - -% **In TeX 3.0, setting text in \nullfont hangs tex. For a -% workaround (which requires the file ``dummy.tfm'' to be installed), -% uncomment the following line: -%%%%%\font\nullfont=dummy\let\obstexwarn=\relax - -% Ignore text, except that we keep track of conditional commands for -% purposes of nesting, up to an `@end #1' command. -% -\def\nestedignore#1{% - \obstexwarn - % We must actually expand the ignored text to look for the @end - % command, so that nested ignore constructs work. Thus, we put the - % text into a \vbox and then do nothing with the result. To minimize - % the change of memory overflow, we follow the approach outlined on - % page 401 of the TeXbook: make the current font be a dummy font. - % - \setbox0 = \vbox\bgroup - % Don't complain about control sequences we have declared \outer. - \ignoresections - % - % Define `@end #1' to end the box, which will in turn undefine the - % @end command again. - \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% - % - % We are going to be parsing Texinfo commands. Most cause no - % trouble when they are used incorrectly, but some commands do - % complicated argument parsing or otherwise get confused, so we - % undefine them. - % - % We can't do anything about stray @-signs, unfortunately; - % they'll produce `undefined control sequence' errors. - \ignoremorecommands - % - % Set the current font to be \nullfont, a TeX primitive, and define - % all the font commands to also use \nullfont. We don't use - % dummy.tfm, as suggested in the TeXbook, because not all sites - % might have that installed. Therefore, math mode will still - % produce output, but that should be an extremely small amount of - % stuff compared to the main input. - % - \nullfont - \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont - \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont - \let\tensf = \nullfont - % - % Don't complain when characters are missing from the fonts. - \tracinglostchars = 0 - % - % Don't bother to do space factor calculations. - \frenchspacing - % - % Don't report underfull hboxes. - \hbadness = 10000 - % - % Do minimal line-breaking. - \pretolerance = 10000 - % - % Do not execute instructions in @tex - \def\tex{\doignore{tex}} -} - -% @set VAR sets the variable VAR to an empty value. -% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. -% -% Since we want to separate VAR from REST-OF-LINE (which might be -% empty), we can't just use \parsearg; we have to insert a space of our -% own to delimit the rest of the line, and then take it out again if we -% didn't need it. -% -\def\set{\parsearg\setxxx} -\def\setxxx#1{\setyyy#1 \endsetyyy} -\def\setyyy#1 #2\endsetyyy{% - \def\temp{#2}% - \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty - \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. - \fi -} -\def\setzzz#1#2 \endsetzzz{\expandafter\xdef\csname SET#1\endcsname{#2}} - -% @clear VAR clears (i.e., unsets) the variable VAR. -% -\def\clear{\parsearg\clearxxx} -\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} - -% @value{foo} gets the text saved in variable foo. -% -\def\value#1{\expandafter - \ifx\csname SET#1\endcsname\relax - {\{No value for ``#1''\}} - \else \csname SET#1\endcsname \fi} - -% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined -% with @set. -% -\def\ifset{\parsearg\ifsetxxx} -\def\ifsetxxx #1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \expandafter\ifsetfail - \else - \expandafter\ifsetsucceed - \fi -} -\def\ifsetsucceed{\conditionalsucceed{ifset}} -\def\ifsetfail{\nestedignore{ifset}} -\defineunmatchedend{ifset} - -% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been -% defined with @set, or has been undefined with @clear. -% -\def\ifclear{\parsearg\ifclearxxx} -\def\ifclearxxx #1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \expandafter\ifclearsucceed - \else - \expandafter\ifclearfail - \fi -} -\def\ifclearsucceed{\conditionalsucceed{ifclear}} -\def\ifclearfail{\nestedignore{ifclear}} -\defineunmatchedend{ifclear} - -% @iftex always succeeds; we read the text following, through @end -% iftex). But `@end iftex' should be valid only after an @iftex. -% -\def\iftex{\conditionalsucceed{iftex}} -\defineunmatchedend{iftex} - -% We can't just want to start a group at @iftex (for example) and end it -% at @end iftex, since then @set commands inside the conditional have no -% effect (they'd get reverted at the end of the group). So we must -% define \Eiftex to redefine itself to be its previous value. (We can't -% just define it to fail again with an ``unmatched end'' error, since -% the @ifset might be nested.) -% -\def\conditionalsucceed#1{% - \edef\temp{% - % Remember the current value of \E#1. - \let\nece{prevE#1} = \nece{E#1}% - % - % At the `@end #1', redefine \E#1 to be its previous value. - \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% - }% - \temp -} - -% We need to expand lots of \csname's, but we don't want to expand the -% control sequences after we've constructed them. -% -\def\nece#1{\expandafter\noexpand\csname#1\endcsname} - -% @asis just yields its argument. Used with @table, for example. -% -\def\asis#1{#1} - -% @math means output in math mode. -% We don't use $'s directly in the definition of \math because control -% sequences like \math are expanded when the toc file is written. Then, -% we read the toc file back, the $'s will be normal characters (as they -% should be, according to the definition of Texinfo). So we must use a -% control sequence to switch into and out of math mode. -% -% This isn't quite enough for @math to work properly in indices, but it -% seems unlikely it will ever be needed there. -% -\let\implicitmath = $ -\def\math#1{\implicitmath #1\implicitmath} - -% @bullet and @minus need the same treatment as @math, just above. -\def\bullet{\implicitmath\ptexbullet\implicitmath} -\def\minus{\implicitmath-\implicitmath} - -\def\node{\ENVcheck\parsearg\nodezzz} -\def\nodezzz#1{\nodexxx [#1,]} -\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} -\let\nwnode=\node -\let\lastnode=\relax - -\def\donoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\setref{\lastnode}\fi -\let\lastnode=\relax} - -\def\unnumbnoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi -\let\lastnode=\relax} - -\def\appendixnoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi -\let\lastnode=\relax} - -\let\refill=\relax - -% @setfilename is done at the beginning of every texinfo file. -% So open here the files we need to have open while reading the input. -% This makes it possible to make a .fmt file for texinfo. -\def\setfilename{% - \readauxfile - \opencontents - \openindices - \fixbackslash % Turn off hack to swallow `\input texinfo'. - \global\let\setfilename=\comment % Ignore extra @setfilename cmds. - \comment % Ignore the actual filename. -} - -\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} - -\def\inforef #1{\inforefzzz #1,,,,**} -\def\inforefzzz #1,#2,#3,#4**{See Info file \file{\ignorespaces #3{}}, - node \samp{\ignorespaces#1{}}} - -\message{fonts,} - -% Font-change commands. - -% Texinfo supports the sans serif font style, which plain TeX does not. -% So we set up a \sf analogous to plain's \rm, etc. -\newfam\sffam -\def\sf{\fam=\sffam \tensf} -\let\li = \sf % Sometimes we call it \li, not \sf. - -%% Try out Computer Modern fonts at \magstephalf -\let\mainmagstep=\magstephalf - -\ifx\bigger\relax -\let\mainmagstep=\magstep1 -\font\textrm=cmr12 -\font\texttt=cmtt12 -\else -\font\textrm=cmr10 scaled \mainmagstep -\font\texttt=cmtt10 scaled \mainmagstep -\fi -% Instead of cmb10, you many want to use cmbx10. -% cmbx10 is a prettier font on its own, but cmb10 -% looks better when embedded in a line with cmr10. -\font\textbf=cmb10 scaled \mainmagstep -\font\textit=cmti10 scaled \mainmagstep -\font\textsl=cmsl10 scaled \mainmagstep -\font\textsf=cmss10 scaled \mainmagstep -\font\textsc=cmcsc10 scaled \mainmagstep -\font\texti=cmmi10 scaled \mainmagstep -\font\textsy=cmsy10 scaled \mainmagstep - -% A few fonts for @defun, etc. -\font\defbf=cmbx10 scaled \magstep1 %was 1314 -\font\deftt=cmtt10 scaled \magstep1 -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} - -% Fonts for indices and small examples. -% We actually use the slanted font rather than the italic, -% because texinfo normally uses the slanted fonts for that. -% Do not make many font distinctions in general in the index, since they -% aren't very useful. -\font\ninett=cmtt9 -\font\indrm=cmr9 -\font\indit=cmsl9 -\let\indsl=\indit -\let\indtt=\ninett -\let\indsf=\indrm -\let\indbf=\indrm -\let\indsc=\indrm -\font\indi=cmmi9 -\font\indsy=cmsy9 - -% Fonts for headings -\font\chaprm=cmbx12 scaled \magstep2 -\font\chapit=cmti12 scaled \magstep2 -\font\chapsl=cmsl12 scaled \magstep2 -\font\chaptt=cmtt12 scaled \magstep2 -\font\chapsf=cmss12 scaled \magstep2 -\let\chapbf=\chaprm -\font\chapsc=cmcsc10 scaled\magstep3 -\font\chapi=cmmi12 scaled \magstep2 -\font\chapsy=cmsy10 scaled \magstep3 - -\font\secrm=cmbx12 scaled \magstep1 -\font\secit=cmti12 scaled \magstep1 -\font\secsl=cmsl12 scaled \magstep1 -\font\sectt=cmtt12 scaled \magstep1 -\font\secsf=cmss12 scaled \magstep1 -\font\secbf=cmbx12 scaled \magstep1 -\font\secsc=cmcsc10 scaled\magstep2 -\font\seci=cmmi12 scaled \magstep1 -\font\secsy=cmsy10 scaled \magstep2 - -% \font\ssecrm=cmbx10 scaled \magstep1 % This size an font looked bad. -% \font\ssecit=cmti10 scaled \magstep1 % The letters were too crowded. -% \font\ssecsl=cmsl10 scaled \magstep1 -% \font\ssectt=cmtt10 scaled \magstep1 -% \font\ssecsf=cmss10 scaled \magstep1 - -%\font\ssecrm=cmb10 scaled 1315 % Note the use of cmb rather than cmbx. -%\font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than -%\font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1. -%\font\ssectt=cmtt10 scaled 1315 -%\font\ssecsf=cmss10 scaled 1315 - -%\let\ssecbf=\ssecrm - -\font\ssecrm=cmbx12 scaled \magstephalf -\font\ssecit=cmti12 scaled \magstephalf -\font\ssecsl=cmsl12 scaled \magstephalf -\font\ssectt=cmtt12 scaled \magstephalf -\font\ssecsf=cmss12 scaled \magstephalf -\font\ssecbf=cmbx12 scaled \magstephalf -\font\ssecsc=cmcsc10 scaled \magstep1 -\font\sseci=cmmi12 scaled \magstephalf -\font\ssecsy=cmsy10 scaled \magstep1 -% The smallcaps and symbol fonts should actually be scaled \magstep1.5, -% but that is not a standard magnification. - -% Fonts for title page: -\font\titlerm = cmbx12 scaled \magstep3 -\let\authorrm = \secrm - -% In order for the font changes to affect most math symbols and letters, -% we have to define the \textfont of the standard families. Since -% texinfo doesn't allow for producing subscripts and superscripts, we -% don't bother to reset \scriptfont and \scriptscriptfont (which would -% also require loading a lot more fonts). -% -\def\resetmathfonts{% - \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy - \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf - \textfont\ttfam = \tentt \textfont\sffam = \tensf -} - - -% The font-changing commands redefine the meanings of \tenSTYLE, instead -% of just \STYLE. We do this so that font changes will continue to work -% in math mode, where it is the current \fam that is relevant in most -% cases, not the current. Plain TeX does, for example, -% \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need -% to redefine \bf itself. -\def\textfonts{% - \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl - \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc - \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy - \resetmathfonts} -\def\chapfonts{% - \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl - \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc - \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy - \resetmathfonts} -\def\secfonts{% - \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl - \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc - \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy - \resetmathfonts} -\def\subsecfonts{% - \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl - \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc - \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy - \resetmathfonts} -\def\indexfonts{% - \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl - \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc - \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy - \resetmathfonts} - -% Set up the default fonts, so we can use them for creating boxes. -% -\textfonts - -% Count depth in font-changes, for error checks -\newcount\fontdepth \fontdepth=0 - -% Fonts for short table of contents. -\font\shortcontrm=cmr12 -\font\shortcontbf=cmbx12 -\font\shortcontsl=cmsl12 - -%% Add scribe-like font environments, plus @l for inline lisp (usually sans -%% serif) and @ii for TeX italic - -% \smartitalic{ARG} outputs arg in italics, followed by an italic correction -% unless the following character is such as not to need one. -\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} -\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx} - -\let\i=\smartitalic -\let\var=\smartitalic -\let\dfn=\smartitalic -\let\emph=\smartitalic -\let\cite=\smartitalic - -\def\b#1{{\bf #1}} -\let\strong=\b - -% We can't just use \exhyphenpenalty, because that only has effect at -% the end of a paragraph. Restore normal hyphenation at the end of the -% group within which \nohyphenation is presumably called. -% -\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} -\def\restorehyphenation{\hyphenchar\font = `- } - -\def\t#1{% - {\tt \nohyphenation \rawbackslash \frenchspacing #1}% - \null -} -\let\ttfont = \t -%\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null} -\def\samp #1{`\tclose{#1}'\null} -\def\key #1{{\tt \nohyphenation \uppercase{#1}}\null} -\def\ctrl #1{{\tt \rawbackslash \hat}#1} - -\let\file=\samp - -% @code is a modification of @t, -% which makes spaces the same size as normal in the surrounding text. -\def\tclose#1{% - {% - % Change normal interword space to be same as for the current font. - \spaceskip = \fontdimen2\font - % - % Switch to typewriter. - \tt - % - % But `\ ' produces the large typewriter interword space. - \def\ {{\spaceskip = 0pt{} }}% - % - % Turn off hyphenation. - \nohyphenation - % - \rawbackslash - \frenchspacing - #1% - }% - \null -} -\let\code=\tclose -%\let\exp=\tclose %Was temporary - -% @kbd is like @code, except that if the argument is just one @key command, -% then @kbd has no effect. - -\def\xkey{\key} -\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% -\ifx\one\xkey\ifx\threex\three \key{#2}% -\else\tclose{\look}\fi -\else\tclose{\look}\fi} - -% Typeset a dimension, e.g., `in' or `pt'. The only reason for the -% argument is to make the input look right: @dmn{pt} instead of -% @dmn{}pt. -% -\def\dmn#1{\thinspace #1} - -\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} - -\def\l#1{{\li #1}\null} % - -\def\r#1{{\rm #1}} % roman font -% Use of \lowercase was suggested. -\def\sc#1{{\smallcaps#1}} % smallcaps font -\def\ii#1{{\it #1}} % italic font - -\message{page headings,} - -\newskip\titlepagetopglue \titlepagetopglue = 1.5in -\newskip\titlepagebottomglue \titlepagebottomglue = 2pc - -% First the title page. Must do @settitle before @titlepage. -\def\titlefont#1{{\titlerm #1}} - -\newif\ifseenauthor -\newif\iffinishedtitlepage - -\def\shorttitlepage{\parsearg\shorttitlepagezzz} -\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% - \endgroup\page\hbox{}\page} - -\def\titlepage{\begingroup \parindent=0pt \textfonts - \let\subtitlerm=\tenrm -% I deinstalled the following change because \cmr12 is undefined. -% This change was not in the ChangeLog anyway. --rms. -% \let\subtitlerm=\cmr12 - \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% - % - \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% - % - % Leave some space at the very top of the page. - \vglue\titlepagetopglue - % - % Now you can print the title using @title. - \def\title{\parsearg\titlezzz}% - \def\titlezzz##1{\leftline{\titlefont{##1}} - % print a rule at the page bottom also. - \finishedtitlepagefalse - \vskip4pt \hrule height 4pt \vskip4pt}% - % No rule at page bottom unless we print one at the top with @title. - \finishedtitlepagetrue - % - % Now you can put text using @subtitle. - \def\subtitle{\parsearg\subtitlezzz}% - \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% - % - % @author should come last, but may come many times. - \def\author{\parsearg\authorzzz}% - \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi - {\authorfont \leftline{##1}}}% - % - % Most title ``pages'' are actually two pages long, with space - % at the top of the second. We don't want the ragged left on the second. - \let\oldpage = \page - \def\page{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - \oldpage - \let\page = \oldpage - \hbox{}}% -% \def\page{\oldpage \hbox{}} -} - -\def\Etitlepage{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - % It is important to do the page break before ending the group, - % because the headline and footline are only empty inside the group. - % If we use the new definition of \page, we always get a blank page - % after the title page, which we certainly don't want. - \oldpage - \endgroup - \HEADINGSon -} - -\def\finishtitlepage{% - \vskip4pt \hrule height 2pt - \vskip\titlepagebottomglue - \finishedtitlepagetrue -} - -%%% Set up page headings and footings. - -\let\thispage=\folio - -\newtoks \evenheadline % Token sequence for heading line of even pages -\newtoks \oddheadline % Token sequence for heading line of odd pages -\newtoks \evenfootline % Token sequence for footing line of even pages -\newtoks \oddfootline % Token sequence for footing line of odd pages - -% Now make Tex use those variables -\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline - \else \the\evenheadline \fi}} -\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline - \else \the\evenfootline \fi}\HEADINGShook} -\let\HEADINGShook=\relax - -% Commands to set those variables. -% For example, this is what @headings on does -% @evenheading @thistitle|@thispage|@thischapter -% @oddheading @thischapter|@thispage|@thistitle -% @evenfooting @thisfile|| -% @oddfooting ||@thisfile - -\def\evenheading{\parsearg\evenheadingxxx} -\def\oddheading{\parsearg\oddheadingxxx} -\def\everyheading{\parsearg\everyheadingxxx} - -\def\evenfooting{\parsearg\evenfootingxxx} -\def\oddfooting{\parsearg\oddfootingxxx} -\def\everyfooting{\parsearg\everyfootingxxx} - -{\catcode`\@=0 % - -\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} -\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} -\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish} -\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} -\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} -\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% -\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish} -\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}} -\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} -% -}% unbind the catcode of @. - -% @headings double turns headings on for double-sided printing. -% @headings single turns headings on for single-sided printing. -% @headings off turns them off. -% @headings on same as @headings double, retained for compatibility. -% @headings after turns on double-sided headings after this page. -% @headings doubleafter turns on double-sided headings after this page. -% @headings singleafter turns on single-sided headings after this page. -% By default, they are off. - -\def\headings #1 {\csname HEADINGS#1\endcsname} - -\def\HEADINGSoff{ -\global\evenheadline={\hfil} \global\evenfootline={\hfil} -\global\oddheadline={\hfil} \global\oddfootline={\hfil}} -\HEADINGSoff -% When we turn headings on, set the page number to 1. -% For double-sided printing, put current file name in lower left corner, -% chapter name on inside top of right hand pages, document -% title on inside top of left hand pages, and page numbers on outside top -% edge of all pages. -\def\HEADINGSdouble{ -%\pagealignmacro -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} -% For single-sided printing, chapter title goes across top left of page, -% page number on top right. -\def\HEADINGSsingle{ -%\pagealignmacro -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} -\def\HEADINGSon{\HEADINGSdouble} - -\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} -\let\HEADINGSdoubleafter=\HEADINGSafter -\def\HEADINGSdoublex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} - -\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} -\def\HEADINGSsinglex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} - -% Subroutines used in generating headings -% Produces Day Month Year style of output. -\def\today{\number\day\space -\ifcase\month\or -January\or February\or March\or April\or May\or June\or -July\or August\or September\or October\or November\or December\fi -\space\number\year} - -% Use this if you want the Month Day, Year style of output. -%\def\today{\ifcase\month\or -%January\or February\or March\or April\or May\or June\or -%July\or August\or September\or October\or November\or December\fi -%\space\number\day, \number\year} - -% @settitle line... specifies the title of the document, for headings -% It generates no output of its own - -\def\thistitle{No Title} -\def\settitle{\parsearg\settitlezzz} -\def\settitlezzz #1{\gdef\thistitle{#1}} - -\message{tables,} - -% @tabs -- simple alignment - -% These don't work. For one thing, \+ is defined as outer. -% So these macros cannot even be defined. - -%\def\tabs{\parsearg\tabszzz} -%\def\tabszzz #1{\settabs\+#1\cr} -%\def\tabline{\parsearg\tablinezzz} -%\def\tablinezzz #1{\+#1\cr} -%\def\&{&} - -% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). - -% default indentation of table text -\newdimen\tableindent \tableindent=.8in -% default indentation of @itemize and @enumerate text -\newdimen\itemindent \itemindent=.3in -% margin between end of table item and start of table text. -\newdimen\itemmargin \itemmargin=.1in - -% used internally for \itemindent minus \itemmargin -\newdimen\itemmax - -% Note @table, @vtable, and @vtable define @item, @itemx, etc., with -% these defs. -% They also define \itemindex -% to index the item name in whatever manner is desired (perhaps none). - -\def\internalBitem{\smallbreak \parsearg\itemzzz} -\def\internalBitemx{\par \parsearg\itemzzz} - -\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} -\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz} - -\def\internalBkitem{\smallbreak \parsearg\kitemzzz} -\def\internalBkitemx{\par \parsearg\kitemzzz} - -\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% - \itemzzz {#1}} - -\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% - \itemzzz {#1}} - -\def\itemzzz #1{\begingroup % - \advance\hsize by -\rightskip - \advance\hsize by -\tableindent - \setbox0=\hbox{\itemfont{#1}}% - \itemindex{#1}% - \nobreak % This prevents a break before @itemx. - % - % Be sure we are not still in the middle of a paragraph. - \parskip=0in - \par - % - % If the item text does not fit in the space we have, put it on a line - % by itself, and do not allow a page break either before or after that - % line. We do not start a paragraph here because then if the next - % command is, e.g., @kindex, the whatsit would get put into the - % horizontal list on a line by itself, resulting in extra blank space. - \ifdim \wd0>\itemmax - \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0 - \nobreak - \else - % The item text fits into the space. Start a paragraph, so that the - % following text (if any) will end up on the same line. Since that - % text will be indented by \tableindent, we make the item text be in - % a zero-width box. - \noindent - \rlap{\hskip -\tableindent\box0}% - \fi - \endgroup -} - -\def\item{\errmessage{@item while not in a table}} -\def\itemx{\errmessage{@itemx while not in a table}} -\def\kitem{\errmessage{@kitem while not in a table}} -\def\kitemx{\errmessage{@kitemx while not in a table}} -\def\xitem{\errmessage{@xitem while not in a table}} -\def\xitemx{\errmessage{@xitemx while not in a table}} - -%% Contains a kludge to get @end[description] to work -\def\description{\tablez{\dontindex}{1}{}{}{}{}} - -\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} -{\obeylines\obeyspaces% -\gdef\tablex #1^^M{% -\tabley\dontindex#1 \endtabley}} - -\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} -{\obeylines\obeyspaces% -\gdef\ftablex #1^^M{% -\tabley\fnitemindex#1 \endtabley -\def\Eftable{\endgraf\endgroup\afterenvbreak}% -\let\Etable=\relax}} - -\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} -{\obeylines\obeyspaces% -\gdef\vtablex #1^^M{% -\tabley\vritemindex#1 \endtabley -\def\Evtable{\endgraf\endgroup\afterenvbreak}% -\let\Etable=\relax}} - -\def\dontindex #1{} -\def\fnitemindex #1{\doind {fn}{\code{#1}}}% -\def\vritemindex #1{\doind {vr}{\code{#1}}}% - -{\obeyspaces % -\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% -\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} - -\def\tablez #1#2#3#4#5#6{% -\aboveenvbreak % -\begingroup % -\def\Edescription{\Etable}% Neccessary kludge. -\let\itemindex=#1% -\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % -\ifnum 0#4>0 \tableindent=#4\mil \fi % -\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % -\def\itemfont{#2}% -\itemmax=\tableindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \tableindent % -\exdentamount=\tableindent -\parindent = 0pt -\parskip = \smallskipamount -\ifdim \parskip=0pt \parskip=2pt \fi% -\def\Etable{\endgraf\endgroup\afterenvbreak}% -\let\item = \internalBitem % -\let\itemx = \internalBitemx % -\let\kitem = \internalBkitem % -\let\kitemx = \internalBkitemx % -\let\xitem = \internalBxitem % -\let\xitemx = \internalBxitemx % -} - -% This is the counter used by @enumerate, which is really @itemize - -\newcount \itemno - -\def\itemize{\parsearg\itemizezzz} - -\def\itemizezzz #1{% - \begingroup % ended by the @end itemsize - \itemizey {#1}{\Eitemize} -} - -\def\itemizey #1#2{% -\aboveenvbreak % -\itemmax=\itemindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \itemindent % -\exdentamount=\itemindent -\parindent = 0pt % -\parskip = \smallskipamount % -\ifdim \parskip=0pt \parskip=2pt \fi% -\def#2{\endgraf\endgroup\afterenvbreak}% -\def\itemcontents{#1}% -\let\item=\itemizeitem} - -% Set sfcode to normal for the chars that usually have another value. -% These are `.?!:;,' -\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 - \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } - -% \splitoff TOKENS\endmark defines \first to be the first token in -% TOKENS, and \rest to be the remainder. -% -\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% - -% Allow an optional argument of an uppercase letter, lowercase letter, -% or number, to specify the first label in the enumerated list. No -% argument is the same as `1'. -% -\def\enumerate{\parsearg\enumeratezzz} -\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} -\def\enumeratey #1 #2\endenumeratey{% - \begingroup % ended by the @end enumerate - % - % If we were given no argument, pretend we were given `1'. - \def\thearg{#1}% - \ifx\thearg\empty \def\thearg{1}\fi - % - % Detect if the argument is a single token. If so, it might be a - % letter. Otherwise, the only valid thing it can be is a number. - % (We will always have one token, because of the test we just made. - % This is a good thing, since \splitoff doesn't work given nothing at - % all -- the first parameter is undelimited.) - \expandafter\splitoff\thearg\endmark - \ifx\rest\empty - % Only one token in the argument. It could still be anything. - % A ``lowercase letter'' is one whose \lccode is nonzero. - % An ``uppercase letter'' is one whose \lccode is both nonzero, and - % not equal to itself. - % Otherwise, we assume it's a number. - % - % We need the \relax at the end of the \ifnum lines to stop TeX from - % continuing to look for a . - % - \ifnum\lccode\expandafter`\thearg=0\relax - \numericenumerate % a number (we hope) - \else - % It's a letter. - \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax - \lowercaseenumerate % lowercase letter - \else - \uppercaseenumerate % uppercase letter - \fi - \fi - \else - % Multiple tokens in the argument. We hope it's a number. - \numericenumerate - \fi -} - -% An @enumerate whose labels are integers. The starting integer is -% given in \thearg. -% -\def\numericenumerate{% - \itemno = \thearg - \startenumeration{\the\itemno}% -} - -% The starting (lowercase) letter is in \thearg. -\def\lowercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more lowercase letters in @enumerate; get a bigger - alphabet}% - \fi - \char\lccode\itemno - }% -} - -% The starting (uppercase) letter is in \thearg. -\def\uppercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more uppercase letters in @enumerate; get a bigger - alphabet} - \fi - \char\uccode\itemno - }% -} - -% Call itemizey, adding a period to the first argument and supplying the -% common last two arguments. Also subtract one from the initial value in -% \itemno, since @item increments \itemno. -% -\def\startenumeration#1{% - \advance\itemno by -1 - \itemizey{#1.}\Eenumerate\flushcr -} - -% @alphaenumerate and @capsenumerate are abbreviations for giving an arg -% to @enumerate. -% -\def\alphaenumerate{\enumerate{a}} -\def\capsenumerate{\enumerate{A}} -\def\Ealphaenumerate{\Eenumerate} -\def\Ecapsenumerate{\Eenumerate} - -% Definition of @item while inside @itemize. - -\def\itemizeitem{% -\advance\itemno by 1 -{\let\par=\endgraf \smallbreak}% -\ifhmode \errmessage{\in hmode at itemizeitem}\fi -{\parskip=0in \hskip 0pt -\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% -\vadjust{\penalty 1200}}% -\flushcr} - -\message{indexing,} -% Index generation facilities - -% Define \newwrite to be identical to plain tex's \newwrite -% except not \outer, so it can be used within \newindex. -{\catcode`\@=11 -\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} - -% \newindex {foo} defines an index named foo. -% It automatically defines \fooindex such that -% \fooindex ...rest of line... puts an entry in the index foo. -% It also defines \fooindfile to be the number of the output channel for -% the file that accumulates this index. The file's extension is foo. -% The name of an index should be no more than 2 characters long -% for the sake of vms. - -\def\newindex #1{ -\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file -\openout \csname#1indfile\endcsname \jobname.#1 % Open the file -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\doindex {#1}} -} - -% @defindex foo == \newindex{foo} - -\def\defindex{\parsearg\newindex} - -% Define @defcodeindex, like @defindex except put all entries in @code. - -\def\newcodeindex #1{ -\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file -\openout \csname#1indfile\endcsname \jobname.#1 % Open the file -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\docodeindex {#1}} -} - -\def\defcodeindex{\parsearg\newcodeindex} - -% @synindex foo bar makes index foo feed into index bar. -% Do this instead of @defindex foo if you don't want it as a separate index. -\def\synindex #1 #2 {% -\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname -\expandafter\let\csname#1indfile\endcsname=\synindexfoo -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\doindex {#2}}% -} - -% @syncodeindex foo bar similar, but put all entries made for index foo -% inside @code. -\def\syncodeindex #1 #2 {% -\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname -\expandafter\let\csname#1indfile\endcsname=\synindexfoo -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\docodeindex {#2}}% -} - -% Define \doindex, the driver for all \fooindex macros. -% Argument #1 is generated by the calling \fooindex macro, -% and it is "foo", the name of the index. - -% \doindex just uses \parsearg; it calls \doind for the actual work. -% This is because \doind is more useful to call from other macros. - -% There is also \dosubind {index}{topic}{subtopic} -% which makes an entry in a two-level index such as the operation index. - -\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} -\def\singleindexer #1{\doind{\indexname}{#1}} - -% like the previous two, but they put @code around the argument. -\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} -\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} - -\def\indexdummies{% -\def\_{{\realbackslash _}}% -\def\w{\realbackslash w }% -\def\bf{\realbackslash bf }% -\def\rm{\realbackslash rm }% -\def\sl{\realbackslash sl }% -\def\sf{\realbackslash sf}% -\def\tt{\realbackslash tt}% -\def\gtr{\realbackslash gtr}% -\def\less{\realbackslash less}% -\def\hat{\realbackslash hat}% -\def\char{\realbackslash char}% -\def\TeX{\realbackslash TeX}% -\def\dots{\realbackslash dots }% -\def\copyright{\realbackslash copyright }% -\def\tclose##1{\realbackslash tclose {##1}}% -\def\code##1{\realbackslash code {##1}}% -\def\samp##1{\realbackslash samp {##1}}% -\def\t##1{\realbackslash r {##1}}% -\def\r##1{\realbackslash r {##1}}% -\def\i##1{\realbackslash i {##1}}% -\def\b##1{\realbackslash b {##1}}% -\def\cite##1{\realbackslash cite {##1}}% -\def\key##1{\realbackslash key {##1}}% -\def\file##1{\realbackslash file {##1}}% -\def\var##1{\realbackslash var {##1}}% -\def\kbd##1{\realbackslash kbd {##1}}% -\def\dfn##1{\realbackslash dfn {##1}}% -\def\emph##1{\realbackslash emph {##1}}% -} - -% \indexnofonts no-ops all font-change commands. -% This is used when outputting the strings to sort the index by. -\def\indexdummyfont#1{#1} -\def\indexdummytex{TeX} -\def\indexdummydots{...} - -\def\indexnofonts{% -\let\w=\indexdummyfont -\let\t=\indexdummyfont -\let\r=\indexdummyfont -\let\i=\indexdummyfont -\let\b=\indexdummyfont -\let\emph=\indexdummyfont -\let\strong=\indexdummyfont -\let\cite=\indexdummyfont -\let\sc=\indexdummyfont -%Don't no-op \tt, since it isn't a user-level command -% and is used in the definitions of the active chars like <, >, |... -%\let\tt=\indexdummyfont -\let\tclose=\indexdummyfont -\let\code=\indexdummyfont -\let\file=\indexdummyfont -\let\samp=\indexdummyfont -\let\kbd=\indexdummyfont -\let\key=\indexdummyfont -\let\var=\indexdummyfont -\let\TeX=\indexdummytex -\let\dots=\indexdummydots -} - -% To define \realbackslash, we must make \ not be an escape. -% We must first make another character (@) an escape -% so we do not become unable to do a definition. - -{\catcode`\@=0 \catcode`\\=\other -@gdef@realbackslash{\}} - -\let\indexbackslash=0 %overridden during \printindex. - -\def\doind #1#2{% -{\count10=\lastpenalty % -{\indexdummies % Must do this here, since \bf, etc expand at this stage -\escapechar=`\\% -{\let\folio=0% Expand all macros now EXCEPT \folio -\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now -% so it will be output as is; and it will print as backslash in the indx. -% -% Now process the index-string once, with all font commands turned off, -% to get the string to sort the index by. -{\indexnofonts -\xdef\temp1{#2}% -}% -% Now produce the complete index entry. We process the index-string again, -% this time with font commands expanded, to get what to print in the index. -\edef\temp{% -\write \csname#1indfile\endcsname{% -\realbackslash entry {\temp1}{\folio}{#2}}}% -\temp }% -}\penalty\count10}} - -\def\dosubind #1#2#3{% -{\count10=\lastpenalty % -{\indexdummies % Must do this here, since \bf, etc expand at this stage -\escapechar=`\\% -{\let\folio=0% -\def\rawbackslashxx{\indexbackslash}% -% -% Now process the index-string once, with all font commands turned off, -% to get the string to sort the index by. -{\indexnofonts -\xdef\temp1{#2 #3}% -}% -% Now produce the complete index entry. We process the index-string again, -% this time with font commands expanded, to get what to print in the index. -\edef\temp{% -\write \csname#1indfile\endcsname{% -\realbackslash entry {\temp1}{\folio}{#2}{#3}}}% -\temp }% -}\penalty\count10}} - -% The index entry written in the file actually looks like -% \entry {sortstring}{page}{topic} -% or -% \entry {sortstring}{page}{topic}{subtopic} -% The texindex program reads in these files and writes files -% containing these kinds of lines: -% \initial {c} -% before the first topic whose initial is c -% \entry {topic}{pagelist} -% for a topic that is used without subtopics -% \primary {topic} -% for the beginning of a topic that is used with subtopics -% \secondary {subtopic}{pagelist} -% for each subtopic. - -% Define the user-accessible indexing commands -% @findex, @vindex, @kindex, @cindex. - -\def\findex {\fnindex} -\def\kindex {\kyindex} -\def\cindex {\cpindex} -\def\vindex {\vrindex} -\def\tindex {\tpindex} -\def\pindex {\pgindex} - -\def\cindexsub {\begingroup\obeylines\cindexsub} -{\obeylines % -\gdef\cindexsub "#1" #2^^M{\endgroup % -\dosubind{cp}{#2}{#1}}} - -% Define the macros used in formatting output of the sorted index material. - -% This is what you call to cause a particular index to get printed. -% Write -% @unnumbered Function Index -% @printindex fn - -\def\printindex{\parsearg\doprintindex} - -\def\doprintindex#1{% - \tex - \dobreak \chapheadingskip {10000} - \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other - \catcode`\$=\other\catcode`\_=\other - \catcode`\~=\other - % - % The following don't help, since the chars were translated - % when the raw index was written, and their fonts were discarded - % due to \indexnofonts. - %\catcode`\"=\active - %\catcode`\^=\active - %\catcode`\_=\active - %\catcode`\|=\active - %\catcode`\<=\active - %\catcode`\>=\active - % % - \def\indexbackslash{\rawbackslashxx} - \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt - \begindoublecolumns - % - % See if the index file exists and is nonempty. - \openin 1 \jobname.#1s - \ifeof 1 - % \enddoublecolumns gets confused if there is no text in the index, - % and it loses the chapter title and the aux file entries for the - % index. The easiest way to prevent this problem is to make sure - % there is some text. - (Index is nonexistent) - \else - % - % If the index file exists but is empty, then \openin leaves \ifeof - % false. We have to make TeX try to read something from the file, so - % it can discover if there is anything in it. - \read 1 to \temp - \ifeof 1 - (Index is empty) - \else - \input \jobname.#1s - \fi - \fi - \closein 1 - \enddoublecolumns - \Etex -} - -% These macros are used by the sorted index file itself. -% Change them to control the appearance of the index. - -% Same as \bigskipamount except no shrink. -% \balancecolumns gets confused if there is any shrink. -\newskip\initialskipamount \initialskipamount 12pt plus4pt - -\def\initial #1{% -{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt -\ifdim\lastskip<\initialskipamount -\removelastskip \penalty-200 \vskip \initialskipamount\fi -\line{\secbf#1\hfill}\kern 2pt\penalty10000}} - -% This typesets a paragraph consisting of #1, dot leaders, and then #2 -% flush to the right margin. It is used for index and table of contents -% entries. The paragraph is indented by \leftskip. -% -\def\entry #1#2{\begingroup - % - % Start a new paragraph if necessary, so our assignments below can't - % affect previous text. - \par - % - % Do not fill out the last line with white space. - \parfillskip = 0in - % - % No extra space above this paragraph. - \parskip = 0in - % - % Do not prefer a separate line ending with a hyphen to fewer lines. - \finalhyphendemerits = 0 - % - % \hangindent is only relevant when the entry text and page number - % don't both fit on one line. In that case, bob suggests starting the - % dots pretty far over on the line. Unfortunately, a large - % indentation looks wrong when the entry text itself is broken across - % lines. So we use a small indentation and put up with long leaders. - % - % \hangafter is reset to 1 (which is the value we want) at the start - % of each paragraph, so we need not do anything with that. - \hangindent=2em - % - % When the entry text needs to be broken, just fill out the first line - % with blank space. - \rightskip = 0pt plus1fil - % - % Start a ``paragraph'' for the index entry so the line breaking - % parameters we've set above will have an effect. - \noindent - % - % Insert the text of the index entry. TeX will do line-breaking on it. - #1% - % - % If we must, put the page number on a line of its own, and fill out - % this line with blank space. (The \hfil is overwhelmed with the - % fill leaders glue in \indexdotfill if the page number does fit.) - \hfil\penalty50 - \null\nobreak\indexdotfill % Have leaders before the page number. - % - % The `\ ' here is removed by the implicit \unskip that TeX does as - % part of (the primitive) \par. Without it, a spurious underfull - % \hbox ensues. - \ #2% The page number ends the paragraph. - \par -\endgroup} - -% Like \dotfill except takes at least 1 em. -\def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill} - -\def\primary #1{\line{#1\hfil}} - -\newskip\secondaryindent \secondaryindent=0.5cm - -\def\secondary #1#2{ -{\parfillskip=0in \parskip=0in -\hangindent =1in \hangafter=1 -\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par -}} - -%% Define two-column mode, which is used in indexes. -%% Adapted from the TeXbook, page 416. -\catcode `\@=11 - -\newbox\partialpage - -\newdimen\doublecolumnhsize - -\def\begindoublecolumns{\begingroup - % Grab any single-column material above us. - \output = {\global\setbox\partialpage - =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}% - \eject - % - % Now switch to the double-column output routine. - \output={\doublecolumnout}% - % - % Change the page size parameters. We could do this once outside this - % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 - % format, but then we repeat the same computation. Repeating a couple - % of assignments once per index is clearly meaningless for the - % execution time, so we may as well do it once. - % - % First we halve the line length, less a little for the gutter between - % the columns. We compute the gutter based on the line length, so it - % changes automatically with the paper format. The magic constant - % below is chosen so that the gutter has the same value (well, +- < - % 1pt) as it did when we hard-coded it. - % - % We put the result in a separate register, \doublecolumhsize, so we - % can restore it in \pagesofar, after \hsize itself has (potentially) - % been clobbered. - % - \doublecolumnhsize = \hsize - \advance\doublecolumnhsize by -.04154\hsize - \divide\doublecolumnhsize by 2 - \hsize = \doublecolumnhsize - % - % Double the \vsize as well. (We don't need a separate register here, - % since nobody clobbers \vsize.) - \vsize = 2\vsize - \doublecolumnpagegoal -} - -\def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage} - -\def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth - \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage - \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1} - \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3} - \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi - \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi -} -\def\doublecolumnpagegoal{% - \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@ -} -\def\pagesofar{\unvbox\partialpage % - \hsize=\doublecolumnhsize % have to restore this since output routine - \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}} -\def\doublecolumnout{% - \setbox5=\copy255 - {\vbadness=10000 \doublecolumnsplit} - \ifvbox255 - \setbox0=\vtop to\dimen@{\unvbox0} - \setbox2=\vtop to\dimen@{\unvbox2} - \onepageout\pagesofar \unvbox255 \penalty\outputpenalty - \else - \setbox0=\vbox{\unvbox5} - \ifvbox0 - \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip - \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth - {\vbadness=10000 - \loop \global\setbox5=\copy0 - \setbox1=\vsplit5 to\dimen@ - \setbox3=\vsplit5 to\dimen@ - \ifvbox5 \global\advance\dimen@ by1pt \repeat - \setbox0=\vbox to\dimen@{\unvbox1} - \setbox2=\vbox to\dimen@{\unvbox3} - \global\setbox\partialpage=\vbox{\pagesofar} - \doublecolumnpagegoal - } - \fi - \fi -} - -\catcode `\@=\other -\message{sectioning,} -% Define chapters, sections, etc. - -\newcount \chapno -\newcount \secno \secno=0 -\newcount \subsecno \subsecno=0 -\newcount \subsubsecno \subsubsecno=0 - -% This counter is funny since it counts through charcodes of letters A, B, ... -\newcount \appendixno \appendixno = `\@ -\def\appendixletter{\char\the\appendixno} - -\newwrite \contentsfile -% This is called from \setfilename. -\def\opencontents{\openout \contentsfile = \jobname.toc} - -% Each @chapter defines this as the name of the chapter. -% page headings and footings can use it. @section does likewise - -\def\thischapter{} \def\thissection{} -\def\seccheck#1{\if \pageno<0 % -\errmessage{@#1 not allowed after generating table of contents}\fi -% -} - -\def\chapternofonts{% -\let\rawbackslash=\relax% -\let\frenchspacing=\relax% -\def\result{\realbackslash result} -\def\equiv{\realbackslash equiv} -\def\expansion{\realbackslash expansion} -\def\print{\realbackslash print} -\def\TeX{\realbackslash TeX} -\def\dots{\realbackslash dots} -\def\copyright{\realbackslash copyright} -\def\tt{\realbackslash tt} -\def\bf{\realbackslash bf } -\def\w{\realbackslash w} -\def\less{\realbackslash less} -\def\gtr{\realbackslash gtr} -\def\hat{\realbackslash hat} -\def\char{\realbackslash char} -\def\tclose##1{\realbackslash tclose {##1}} -\def\code##1{\realbackslash code {##1}} -\def\samp##1{\realbackslash samp {##1}} -\def\r##1{\realbackslash r {##1}} -\def\b##1{\realbackslash b {##1}} -\def\key##1{\realbackslash key {##1}} -\def\file##1{\realbackslash file {##1}} -\def\kbd##1{\realbackslash kbd {##1}} -% These are redefined because @smartitalic wouldn't work inside xdef. -\def\i##1{\realbackslash i {##1}} -\def\cite##1{\realbackslash cite {##1}} -\def\var##1{\realbackslash var {##1}} -\def\emph##1{\realbackslash emph {##1}} -\def\dfn##1{\realbackslash dfn {##1}} -} - -\newcount\absseclevel % used to calculate proper heading level -\newcount\secbase\secbase=0 % @raise/lowersections modify this count - -% @raisesections: treat @section as chapter, @subsection as section, etc. -\def\raisesections{\global\advance\secbase by -1} -\let\up=\raisesections % original BFox name - -% @lowersections: treat @chapter as section, @section as subsection, etc. -\def\lowersections{\global\advance\secbase by 1} -\let\down=\lowersections % original BFox name - -% Choose a numbered-heading macro -% #1 is heading level if unmodified by @raisesections or @lowersections -% #2 is text for heading -\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \chapterzzz{#2} -\or - \seczzz{#2} -\or - \numberedsubseczzz{#2} -\or - \numberedsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \chapterzzz{#2} - \else - \numberedsubsubseczzz{#2} - \fi -\fi -} - -% like \numhead, but chooses appendix heading levels -\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \appendixzzz{#2} -\or - \appendixsectionzzz{#2} -\or - \appendixsubseczzz{#2} -\or - \appendixsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \appendixzzz{#2} - \else - \appendixsubsubseczzz{#2} - \fi -\fi -} - -% like \numhead, but chooses numberless heading levels -\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \unnumberedzzz{#2} -\or - \unnumberedseczzz{#2} -\or - \unnumberedsubseczzz{#2} -\or - \unnumberedsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \unnumberedzzz{#2} - \else - \unnumberedsubsubseczzz{#2} - \fi -\fi -} - - -\def\thischaptername{No Chapter Title} -\outer\def\chapter{\parsearg\chapteryyy} -\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz -\def\chapterzzz #1{\seccheck{chapter}% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \chapno by 1 \message{Chapter \the\chapno}% -\chapmacro {#1}{\the\chapno}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -% We don't substitute the actual chapter name into \thischapter -% because we don't want its macros evaluated now. -\xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}% -{\chapternofonts% -\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec -}} - -\outer\def\appendix{\parsearg\appendixyyy} -\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz -\def\appendixzzz #1{\seccheck{appendix}% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \appendixno by 1 \message{Appendix \appendixletter}% -\chapmacro {#1}{Appendix \appendixletter}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -\xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}% -{\chapternofonts% -\edef\temp{{\realbackslash chapentry - {#1}{Appendix \appendixletter}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\global\let\section = \appendixsec -\global\let\subsection = \appendixsubsec -\global\let\subsubsection = \appendixsubsubsec -}} - -\outer\def\top{\parsearg\unnumberedyyy} -\outer\def\unnumbered{\parsearg\unnumberedyyy} -\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz -\def\unnumberedzzz #1{\seccheck{unnumbered}% -\secno=0 \subsecno=0 \subsubsecno=0 -% -% This used to be simply \message{#1}, but TeX fully expands the -% argument to \message. Therefore, if #1 contained @-commands, TeX -% expanded them. For example, in `@unnumbered The @cite{Book}', TeX -% expanded @cite (which turns out to cause errors because \cite is meant -% to be executed, not expanded). -% -% Anyway, we don't want the fully-expanded definition of @cite to appear -% as a result of the \message, we just want `@cite' itself. We use -% \the to achieve this: TeX expands \the only once, -% simply yielding the contents of the . -\toks0 = {#1}\message{(\the\toks0)}% -% -\unnumbchapmacro {#1}% -\gdef\thischapter{#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\global\let\section = \unnumberedsec -\global\let\subsection = \unnumberedsubsec -\global\let\subsubsection = \unnumberedsubsubsec -}} - -\outer\def\numberedsec{\parsearg\secyyy} -\def\secyyy #1{\numhead1{#1}} % normally calls seczzz -\def\seczzz #1{\seccheck{section}% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% -{\chapternofonts% -\edef\temp{{\realbackslash secentry % -{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appenixsection{\parsearg\appendixsecyyy} -\outer\def\appendixsec{\parsearg\appendixsecyyy} -\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz -\def\appendixsectionzzz #1{\seccheck{appendixsection}% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% -{\chapternofonts% -\edef\temp{{\realbackslash secentry % -{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} -\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz -\def\unnumberedseczzz #1{\seccheck{unnumberedsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} -\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz -\def\numberedsubseczzz #1{\seccheck{subsection}% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsecentry % -{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} -\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz -\def\appendixsubseczzz #1{\seccheck{appendixsubsec}% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsecentry % -{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} -\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz -\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} -\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz -\def\numberedsubsubseczzz #1{\seccheck{subsubsection}% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsubsecentry % - {#1} - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno} - {\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} -\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz -\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsubsecentry{#1}% - {\appendixletter} - {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} -\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz -\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -% These are variants which are not "outer", so they can appear in @ifinfo. -% Actually, they should now be obsolete; ordinary section commands should work. -\def\infotop{\parsearg\unnumberedzzz} -\def\infounnumbered{\parsearg\unnumberedzzz} -\def\infounnumberedsec{\parsearg\unnumberedseczzz} -\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} -\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} - -\def\infoappendix{\parsearg\appendixzzz} -\def\infoappendixsec{\parsearg\appendixseczzz} -\def\infoappendixsubsec{\parsearg\appendixsubseczzz} -\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} - -\def\infochapter{\parsearg\chapterzzz} -\def\infosection{\parsearg\sectionzzz} -\def\infosubsection{\parsearg\subsectionzzz} -\def\infosubsubsection{\parsearg\subsubsectionzzz} - -% These macros control what the section commands do, according -% to what kind of chapter we are in (ordinary, appendix, or unnumbered). -% Define them by default for a numbered chapter. -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec - -% Define @majorheading, @heading and @subheading - -% NOTE on use of \vbox for chapter headings, section headings, and -% such: -% 1) We use \vbox rather than the earlier \line to permit -% overlong headings to fold. -% 2) \hyphenpenalty is set to 10000 because hyphenation in a -% heading is obnoxious; this forbids it. -% 3) Likewise, headings look best if no \parindent is used, and -% if justification is not attempted. Hence \raggedright. - - -\def\majorheading{\parsearg\majorheadingzzz} -\def\majorheadingzzz #1{% -{\advance\chapheadingskip by 10pt \chapbreak }% -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} - -\def\chapheading{\parsearg\chapheadingzzz} -\def\chapheadingzzz #1{\chapbreak % -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} - -\def\heading{\parsearg\secheadingi} - -\def\subheading{\parsearg\subsecheadingi} - -\def\subsubheading{\parsearg\subsubsecheadingi} - -% These macros generate a chapter, section, etc. heading only -% (including whitespace, linebreaking, etc. around it), -% given all the information in convenient, parsed form. - -%%% Args are the skip and penalty (usually negative) -\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} - -\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} - -%%% Define plain chapter starts, and page on/off switching for it -% Parameter controlling skip before chapter headings (if needed) - -\newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt - -\def\chapbreak{\dobreak \chapheadingskip {-4000}} -\def\chappager{\par\vfill\supereject} -\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} - -\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} - -\def\CHAPPAGoff{ -\global\let\pchapsepmacro=\chapbreak -\global\let\pagealignmacro=\chappager} - -\def\CHAPPAGon{ -\global\let\pchapsepmacro=\chappager -\global\let\pagealignmacro=\chappager -\global\def\HEADINGSon{\HEADINGSsingle}} - -\def\CHAPPAGodd{ -\global\let\pchapsepmacro=\chapoddpage -\global\let\pagealignmacro=\chapoddpage -\global\def\HEADINGSon{\HEADINGSdouble}} - -\CHAPPAGon - -\def\CHAPFplain{ -\global\let\chapmacro=\chfplain -\global\let\unnumbchapmacro=\unnchfplain} - -\def\chfplain #1#2{% - \pchapsepmacro - {% - \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #2\enspace #1}% - }% - \bigskip - \penalty5000 -} - -\def\unnchfplain #1{% -\pchapsepmacro % -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 10000 % -} -\CHAPFplain % The default - -\def\unnchfopen #1{% -\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 10000 % -} - -\def\chfopen #1#2{\chapoddpage {\chapfonts -\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% -\par\penalty 5000 % -} - -\def\CHAPFopen{ -\global\let\chapmacro=\chfopen -\global\let\unnumbchapmacro=\unnchfopen} - -% Parameter controlling skip before section headings. - -\newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt -\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} - -\newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt -\def\secheadingbreak{\dobreak \secheadingskip {-1000}} - -% @paragraphindent is defined for the Info formatting commands only. -\let\paragraphindent=\comment - -% Section fonts are the base font at magstep2, which produces -% a size a bit more than 14 points in the default situation. - -\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}} -\def\plainsecheading #1{\secheadingi {#1}} -\def\secheadingi #1{{\advance \secheadingskip by \parskip % -\secheadingbreak}% -{\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } - - -% Subsection fonts are the base font at magstep1, -% which produces a size of 12 points. - -\def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}} -\def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip % -\subsecheadingbreak}% -{\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } - -\def\subsubsecfonts{\subsecfonts} % Maybe this should change: - % Perhaps make sssec fonts scaled - % magstep half -\def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}} -\def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip % -\subsecheadingbreak}% -{\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000} - - -\message{toc printing,} - -% Finish up the main text and prepare to read what we've written -% to \contentsfile. - -\newskip\contentsrightmargin \contentsrightmargin=1in -\def\startcontents#1{% - \pagealignmacro - \immediate\closeout \contentsfile - \ifnum \pageno>0 - \pageno = -1 % Request roman numbered pages. - \fi - % Don't need to put `Contents' or `Short Contents' in the headline. - % It is abundantly clear what they are. - \unnumbchapmacro{#1}\def\thischapter{}% - \begingroup % Set up to handle contents files properly. - \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 - \raggedbottom % Worry more about breakpoints than the bottom. - \advance\hsize by -\contentsrightmargin % Don't use the full line length. -} - - -% Normal (long) toc. -\outer\def\contents{% - \startcontents{Table of Contents}% - \input \jobname.toc - \endgroup - \vfill \eject -} - -% And just the chapters. -\outer\def\summarycontents{% - \startcontents{Short Contents}% - % - \let\chapentry = \shortchapentry - \let\unnumbchapentry = \shortunnumberedentry - % We want a true roman here for the page numbers. - \secfonts - \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl - \rm - \advance\baselineskip by 1pt % Open it up a little. - \def\secentry ##1##2##3##4{} - \def\unnumbsecentry ##1##2{} - \def\subsecentry ##1##2##3##4##5{} - \def\unnumbsubsecentry ##1##2{} - \def\subsubsecentry ##1##2##3##4##5##6{} - \def\unnumbsubsubsecentry ##1##2{} - \input \jobname.toc - \endgroup - \vfill \eject -} -\let\shortcontents = \summarycontents - -% These macros generate individual entries in the table of contents. -% The first argument is the chapter or section name. -% The last argument is the page number. -% The arguments in between are the chapter number, section number, ... - -% Chapter-level things, for both the long and short contents. -\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} - -% See comments in \dochapentry re vbox and related settings -\def\shortchapentry#1#2#3{% - \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% -} - -% Typeset the label for a chapter or appendix for the short contents. -% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. -% We could simplify the code here by writing out an \appendixentry -% command in the toc file for appendices, instead of using \chapentry -% for both, but it doesn't seem worth it. -\setbox0 = \hbox{\shortcontrm Appendix } -\newdimen\shortappendixwidth \shortappendixwidth = \wd0 - -\def\shortchaplabel#1{% - % We typeset #1 in a box of constant width, regardless of the text of - % #1, so the chapter titles will come out aligned. - \setbox0 = \hbox{#1}% - \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi - % - % This space should be plenty, since a single number is .5em, and the - % widest letter (M) is 1em, at least in the Computer Modern fonts. - % (This space doesn't include the extra space that gets added after - % the label; that gets put in in \shortchapentry above.) - \advance\dimen0 by 1.1em - \hbox to \dimen0{#1\hfil}% -} - -\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} -\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} - -% Sections. -\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} -\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} - -% Subsections. -\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} -\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} - -% And subsubsections. -\def\subsubsecentry#1#2#3#4#5#6{% - \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} -\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} - - -% This parameter controls the indentation of the various levels. -\newdimen\tocindent \tocindent = 3pc - -% Now for the actual typesetting. In all these, #1 is the text and #2 is the -% page number. -% -% If the toc has to be broken over pages, we would want to be at chapters -% if at all possible; hence the \penalty. -\def\dochapentry#1#2{% - \penalty-300 \vskip\baselineskip - \begingroup - \chapentryfonts - \tocentry{#1}{\dopageno{#2}}% - \endgroup - \nobreak\vskip .25\baselineskip -} - -\def\dosecentry#1#2{\begingroup - \secentryfonts \leftskip=\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -\def\dosubsecentry#1#2{\begingroup - \subsecentryfonts \leftskip=2\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -\def\dosubsubsecentry#1#2{\begingroup - \subsubsecentryfonts \leftskip=3\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -% Final typesetting of a toc entry; we use the same \entry macro as for -% the index entries, but we want to suppress hyphenation here. (We -% can't do that in the \entry macro, since index entries might consist -% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) -% -\def\tocentry#1#2{\begingroup - \hyphenpenalty = 10000 - \entry{#1}{#2}% -\endgroup} - -% Space between chapter (or whatever) number and the title. -\def\labelspace{\hskip1em \relax} - -\def\dopageno#1{{\rm #1}} -\def\doshortpageno#1{{\rm #1}} - -\def\chapentryfonts{\secfonts \rm} -\def\secentryfonts{\textfonts} -\let\subsecentryfonts = \textfonts -\let\subsubsecentryfonts = \textfonts - - -\message{environments,} - -% Since these characters are used in examples, it should be an even number of -% \tt widths. Each \tt character is 1en, so two makes it 1em. -% Furthermore, these definitions must come after we define our fonts. -\newbox\dblarrowbox \newbox\longdblarrowbox -\newbox\pushcharbox \newbox\bullbox -\newbox\equivbox \newbox\errorbox - -\let\ptexequiv = \equiv - -%{\tentt -%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} -%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} -%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} -%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} -% Adapted from the manmac format (p.420 of TeXbook) -%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex -% depth .1ex\hfil} -%} - -\def\point{$\star$} - -\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} -\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} -\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} - -\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} - -% Adapted from the TeXbook's \boxit. -{\tentt \global\dimen0 = 3em}% Width of the box. -\dimen2 = .55pt % Thickness of rules -% The text. (`r' is open on the right, `e' somewhat less so on the left.) -\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} - -\global\setbox\errorbox=\hbox to \dimen0{\hfil - \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. - \advance\hsize by -2\dimen2 % Rules. - \vbox{ - \hrule height\dimen2 - \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. - \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. - \kern3pt\vrule width\dimen2}% Space to right. - \hrule height\dimen2} - \hfil} - -% The @error{} command. -\def\error{\leavevmode\lower.7ex\copy\errorbox} - -% @tex ... @end tex escapes into raw Tex temporarily. -% One exception: @ is still an escape character, so that @end tex works. -% But \@ or @@ will get a plain tex @ character. - -\def\tex{\begingroup -\catcode `\\=0 \catcode `\{=1 \catcode `\}=2 -\catcode `\$=3 \catcode `\&=4 \catcode `\#=6 -\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie -\catcode `\%=14 -\catcode 43=12 -\catcode`\"=12 -\catcode`\==12 -\catcode`\|=12 -\catcode`\<=12 -\catcode`\>=12 -\escapechar=`\\ -% -\let\{=\ptexlbrace -\let\}=\ptexrbrace -\let\.=\ptexdot -\let\*=\ptexstar -\let\dots=\ptexdots -\def\@{@}% -\let\bullet=\ptexbullet -\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl -\let\L=\ptexL -% -\let\Etex=\endgroup} - -% Define @lisp ... @endlisp. -% @lisp does a \begingroup so it can rebind things, -% including the definition of @endlisp (which normally is erroneous). - -% Amount to narrow the margins by for @lisp. -\newskip\lispnarrowing \lispnarrowing=0.4in - -% This is the definition that ^M gets inside @lisp -% phr: changed space to \null, to avoid overfull hbox problems. -{\obeyspaces% -\gdef\lisppar{\null\endgraf}} - -% Make each space character in the input produce a normal interword -% space in the output. Don't allow a line break at this space, as this -% is used only in environments like @example, where each line of input -% should produce a line of output anyway. -% -{\obeyspaces % -\gdef\sepspaces{\obeyspaces\let =\tie}} - -% Define \obeyedspace to be our active space, whatever it is. This is -% for use in \parsearg. -{\sepspaces % -\global\let\obeyedspace= } - -% This space is always present above and below environments. -\newskip\envskipamount \envskipamount = 0pt - -% Make spacing and below environment symmetrical. -\def\aboveenvbreak{{\advance\envskipamount by \parskip -\endgraf \ifdim\lastskip<\envskipamount -\removelastskip \penalty-50 \vskip\envskipamount \fi}} - -\let\afterenvbreak = \aboveenvbreak - -% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. -\let\nonarrowing=\relax - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \cartouche: draw rectangle w/rounded corners around argument -\font\circle=lcircle10 -\newdimen\circthick -\newdimen\cartouter\newdimen\cartinner -\newskip\normbskip\newskip\normpskip\newskip\normlskip -\circthick=\fontdimen8\circle -% -\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth -\def\ctr{{\hskip 6pt\circle\char'010}} -\def\cbl{{\circle\char'012\hskip -6pt}} -\def\cbr{{\hskip 6pt\circle\char'011}} -\def\carttop{\hbox to \cartouter{\hskip\lskip - \ctl\leaders\hrule height\circthick\hfil\ctr - \hskip\rskip}} -\def\cartbot{\hbox to \cartouter{\hskip\lskip - \cbl\leaders\hrule height\circthick\hfil\cbr - \hskip\rskip}} -% -\newskip\lskip\newskip\rskip - -\long\def\cartouche{% -\begingroup - \lskip=\leftskip \rskip=\rightskip - \leftskip=0pt\rightskip=0pt %we want these *outside*. - \cartinner=\hsize \advance\cartinner by-\lskip - \advance\cartinner by-\rskip - \cartouter=\hsize - \advance\cartouter by 18pt % allow for 3pt kerns on either -% side, and for 6pt waste from -% each corner char - \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip - % Flag to tell @lisp, etc., not to narrow margin. - \let\nonarrowing=\comment - \vbox\bgroup - \baselineskip=0pt\parskip=0pt\lineskip=0pt - \carttop - \hbox\bgroup - \hskip\lskip - \vrule\kern3pt - \vbox\bgroup - \hsize=\cartinner - \kern3pt - \begingroup - \baselineskip=\normbskip - \lineskip=\normlskip - \parskip=\normpskip - \vskip -\parskip -\def\Ecartouche{% - \endgroup - \kern3pt - \egroup - \kern3pt\vrule - \hskip\rskip - \egroup - \cartbot - \egroup -\endgroup -}} - - -% This macro is called at the beginning of all the @example variants, -% inside a group. -\def\nonfillstart{% - \aboveenvbreak - \inENV % This group ends at the end of the body - \hfuzz = 12pt % Don't be fussy - \sepspaces % Make spaces be word-separators rather than space tokens. - \singlespace % single space lines - \let\par = \lisppar % don't ignore blank lines - \obeylines % each line of input is a line of output - \parskip = 0pt - \parindent = 0pt - \emergencystretch = 0pt % don't try to avoid overfull boxes - % @cartouche defines \nonarrowing to inhibit narrowing - % at next level down. - \ifx\nonarrowing\relax - \advance \leftskip by \lispnarrowing - \exdentamount=\lispnarrowing - \let\exdent=\nofillexdent - \let\nonarrowing=\relax - \fi -} - -\def\Elisp{\endgroup\afterenvbreak}% - -\def\lisp{\begingroup - \nonfillstart - \def\Elisp{\endgroup\afterenvbreak}% - \tt - \rawbackslash % output the \ character from the current font - \gobble -} - -% Define the \E... control sequence only if we are inside the -% environment, so the error checking in \end will work. -% -% We must call \lisp last in the definition, since it reads the -% return following the @example (or whatever) command. -% -\def\example{\begingroup \def\Eexample{\Elisp\endgroup}\lisp} -\def\smallexample{\begingroup \def\Esmallexample{\Elisp\endgroup}\lisp} - -% Macro for 9 pt. examples, necessary to print with 5" lines. From -% Pavel@xerox. This is not used for @smallexamples unless the -% @smallbook command is given. -% -\def\smalllispx{\begingroup - \nonfillstart - \def\Esmalllisp{\endgroup\afterenvbreak}% - % - % Smaller interline space and fonts for small examples. - \baselineskip 10pt - \indexfonts \tt - \rawbackslash % output the \ character from the current font - \gobble -} - -% This is @display; same as @lisp except use roman font. -% -\def\display{\begingroup - \nonfillstart - \def\Edisplay{\endgroup\afterenvbreak}% - \gobble -} - -% This is @format; same as @display except don't narrow margins. -% -\def\format{\begingroup - \let\nonarrowing = t - \nonfillstart - \def\Eformat{\endgroup\afterenvbreak} - \gobble -} - -% @flushleft (same as @format) and @flushright. -% -\def\flushleft{\begingroup - \let\nonarrowing = t - \nonfillstart - \def\Eflushleft{\endgroup\afterenvbreak}% - \gobble -} -\def\flushright{\begingroup - \let\nonarrowing = t - \nonfillstart - \def\Eflushright{\endgroup\afterenvbreak}% - \advance\leftskip by 0pt plus 1fill - \gobble} - -% @quotation does normal linebreaking and narrows the margins. -% -\def\quotation{% -\begingroup\inENV %This group ends at the end of the @quotation body -{\parskip=0pt % because we will skip by \parskip too, later -\aboveenvbreak}% -\singlespace -\parindent=0pt -\def\Equotation{\par\endgroup\afterenvbreak}% -% @cartouche defines \nonarrowing to inhibit narrowing -% at next level down. -\ifx\nonarrowing\relax -\advance \leftskip by \lispnarrowing -\advance \rightskip by \lispnarrowing -\exdentamount=\lispnarrowing -\let\nonarrowing=\relax -\fi} - -\message{defuns,} -% Define formatter for defuns -% First, allow user to change definition object font (\df) internally -\def\setdeffont #1 {\csname DEF#1\endcsname} - -\newskip\defbodyindent \defbodyindent=.4in -\newskip\defargsindent \defargsindent=50pt -\newskip\deftypemargin \deftypemargin=12pt -\newskip\deflastargmargin \deflastargmargin=18pt - -\newcount\parencount -% define \functionparens, which makes ( and ) and & do special things. -% \functionparens affects the group it is contained in. -\def\activeparens{% -\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active -\catcode`\[=\active \catcode`\]=\active} - -% Make control sequences which act like normal parenthesis chars. -\let\lparen = ( \let\rparen = ) - -{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) - -% Be sure that we always have a definition for `(', etc. For example, -% if the fn name has parens in it, \boldbrax will not be in effect yet, -% so TeX would otherwise complain about undefined control sequence. -\global\let(=\lparen \global\let)=\rparen -\global\let[=\lbrack \global\let]=\rbrack - -\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } -\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} - -% Definitions of (, ) and & used in args for functions. -% This is the definition of ( outside of all parentheses. -\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested % -\global\advance\parencount by 1 } -% -% This is the definition of ( when already inside a level of parens. -\gdef\opnested{\char`\(\global\advance\parencount by 1 } -% -\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. -% also in that case restore the outer-level definition of (. -\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi -\global\advance \parencount by -1 } -% If we encounter &foo, then turn on ()-hacking afterwards -\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } -% -\gdef\normalparens{\boldbrax\let&=\ampnr} -} % End of definition inside \activeparens -%% These parens (in \boldbrax) actually are a little bolder than the -%% contained text. This is especially needed for [ and ] -\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&} -\def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} - -% First, defname, which formats the header line itself. -% #1 should be the function name. -% #2 should be the type of definition, such as "Function". - -\def\defname #1#2{% -% Get the values of \leftskip and \rightskip as they were -% outside the @def... -\dimen2=\leftskip -\advance\dimen2 by -\defbodyindent -\dimen3=\rightskip -\advance\dimen3 by -\defbodyindent -\noindent % -\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% -\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line -\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations -\parshape 2 0in \dimen0 \defargsindent \dimen1 % -% Now output arg 2 ("Function" or some such) -% ending at \deftypemargin from the right margin, -% but stuck inside a box of width 0 so it does not interfere with linebreaking -{% Adjust \hsize to exclude the ambient margins, -% so that \rightline will obey them. -\advance \hsize by -\dimen2 \advance \hsize by -\dimen3 -\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% -% Make all lines underfull and no complaints: -\tolerance=10000 \hbadness=10000 -\advance\leftskip by -\defbodyindent -\exdentamount=\defbodyindent -{\df #1}\enskip % Generate function name -} - -% Actually process the body of a definition -% #1 should be the terminating control sequence, such as \Edefun. -% #2 should be the "another name" control sequence, such as \defunx. -% #3 should be the control sequence that actually processes the header, -% such as \defunheader. - -\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % -\obeylines\activeparens\spacesplit#3} - -\def\defmethparsebody #1#2#3#4 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} - -\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} - -% These parsing functions are similar to the preceding ones -% except that they do not make parens into active characters. -% These are used for "variables" since they have no arguments. - -\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % -\obeylines\spacesplit#3} - -\def\defvrparsebody #1#2#3#4 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\spacesplit{#3{#4}}} - -% This seems to work right in all cases. -\let\deftpparsebody=\defvrparsebody -% This fails to work. When given `@deftp {Data Type} foo_t', -% it thinks the type name is just `f'. -%%% This is the same as all the others except for the last line. We need -%%% to parse the arguments differently for @deftp, since the ``attributes'' -%%% there are optional. -%%% -%%\def\deftpparsebody #1#2#3#4 {\begingroup\inENV % -%%\medbreak % -%%% Define the end token that this defining construct specifies -%%% so that it will exit this group. -%%\def#1{\endgraf\endgroup\medbreak}% -%%\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% -%%\parindent=0in -%%\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -%%\exdentamount=\defbodyindent -%%\begingroup\obeylines\parsetpheaderline{#3{#4}}} - -%%{\obeylines % -%% % Parse the type name and any attributes (field names, etc.). -%% % #1 is the beginning of the macro call that will produce the output, -%% % i.e., \deftpheader{CLASS}; this is passed from \deftpparsebody. -%% % #2 is the type name, e.g., `struct termios'. -%% % #3 is the (possibly empty) attribute list. -%% % -%% \gdef\parsetpheaderline#1#2#3^^M{% -%% \endgroup % Started in \deftpparsebody. -%% % -%% % If the attribute list is in fact empty, there will be no space after -%% % #2; so we can't put a space in our TeX parameter list. But if it -%% % isn't empty, then #3 will begin with an unwanted space. -%% \def\theargs{\ignorespaces #3}% -%% % -%% % Call the macro to produce the output. -%% #1{#2}\theargs % -%% }% -%%} - -\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\spacesplit{#3{#5}}} - -% Split up #2 at the first space token. -% call #1 with two arguments: -% the first is all of #2 before the space token, -% the second is all of #2 after that space token. -% If #2 contains no space token, all of it is passed as the first arg -% and the second is passed as empty. - -{\obeylines -\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% -\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% -\ifx\relax #3% -#1{#2}{}\else #1{#2}{#3#4}\fi}} - -% So much for the things common to all kinds of definitions. - -% Define @defun. - -% First, define the processing that is wanted for arguments of \defun -% Use this to expand the args and terminate the paragraph they make up - -\def\defunargs #1{\functionparens \sl -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -\hyphenchar\tensl=0 -#1% -\hyphenchar\tensl=45 -\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi% -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\penalty 10000\vskip -\parskip\penalty 10000% -} - -\def\deftypefunargs #1{% -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -\functionparens -\code{#1}% -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\penalty 10000\vskip -\parskip\penalty 10000% -} - -% Do complete processing of one @defun or @defunx line already parsed. - -% @deffn Command forward-char nchars - -\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} - -\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% -\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defun == @deffn Function - -\def\defun{\defparsebody\Edefun\defunx\defunheader} - -\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Function}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefun int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} - -% #1 is the data type. #2 is the name and args. -\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} -% #1 is the data type, #2 the name, #3 the args. -\def\deftypefunheaderx #1#2 #3\relax{% -\doind {fn}{\code{#2}}% Make entry in function index -\begingroup\defname {\code{#1} #2}{Function}% -\deftypefunargs {#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} - -% #1 is the classification. #2 is the data type. #3 is the name and args. -\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} -% #1 is the classification, #2 the data type, #3 the name, #4 the args. -\def\deftypefnheaderx #1#2#3 #4\relax{% -\doind {fn}{\code{#3}}% Make entry in function index -\begingroup\defname {\code{#2} #3}{#1}% -\deftypefunargs {#4}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defmac == @deffn Macro - -\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} - -\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Macro}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defspec == @deffn Special Form - -\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} - -\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Special Form}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% This definition is run if you use @defunx -% anywhere other than immediately after a @defun or @defunx. - -\def\deffnx #1 {\errmessage{@deffnx in invalid context}} -\def\defunx #1 {\errmessage{@defunx in invalid context}} -\def\defmacx #1 {\errmessage{@defmacx in invalid context}} -\def\defspecx #1 {\errmessage{@defspecx in invalid context}} -\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} -\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}} - -% @defmethod, and so on - -% @defop {Funny Method} foo-class frobnicate argument - -\def\defop #1 {\def\defoptype{#1}% -\defopparsebody\Edefop\defopx\defopheader\defoptype} - -\def\defopheader #1#2#3{% -\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index -\begingroup\defname {#2}{\defoptype{} on #1}% -\defunargs {#3}\endgroup % -} - -% @defmethod == @defop Method - -\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} - -\def\defmethodheader #1#2#3{% -\dosubind {fn}{\code{#2}}{on #1}% entry in function index -\begingroup\defname {#2}{Method on #1}% -\defunargs {#3}\endgroup % -} - -% @defcv {Class Option} foo-class foo-flag - -\def\defcv #1 {\def\defcvtype{#1}% -\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} - -\def\defcvarheader #1#2#3{% -\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index -\begingroup\defname {#2}{\defcvtype{} of #1}% -\defvarargs {#3}\endgroup % -} - -% @defivar == @defcv {Instance Variable} - -\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} - -\def\defivarheader #1#2#3{% -\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index -\begingroup\defname {#2}{Instance Variable of #1}% -\defvarargs {#3}\endgroup % -} - -% These definitions are run if you use @defmethodx, etc., -% anywhere other than immediately after a @defmethod, etc. - -\def\defopx #1 {\errmessage{@defopx in invalid context}} -\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} -\def\defcvx #1 {\errmessage{@defcvx in invalid context}} -\def\defivarx #1 {\errmessage{@defivarx in invalid context}} - -% Now @defvar - -% First, define the processing that is wanted for arguments of @defvar. -% This is actually simple: just print them in roman. -% This must expand the args and terminate the paragraph they make up -\def\defvarargs #1{\normalparens #1% -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000} - -% @defvr Counter foo-count - -\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} - -\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% -\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} - -% @defvar == @defvr Variable - -\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} - -\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{Variable}% -\defvarargs {#2}\endgroup % -} - -% @defopt == @defvr {User Option} - -\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} - -\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{User Option}% -\defvarargs {#2}\endgroup % -} - -% @deftypevar int foobar - -\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} - -% #1 is the data type. #2 is the name. -\def\deftypevarheader #1#2{% -\doind {vr}{\code{#2}}% Make entry in variables index -\begingroup\defname {\code{#1} #2}{Variable}% -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000 -\endgroup} - -% @deftypevr {Global Flag} int enable - -\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} - -\def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% -\begingroup\defname {\code{#2} #3}{#1} -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000 -\endgroup} - -% This definition is run if you use @defvarx -% anywhere other than immediately after a @defvar or @defvarx. - -\def\defvrx #1 {\errmessage{@defvrx in invalid context}} -\def\defvarx #1 {\errmessage{@defvarx in invalid context}} -\def\defoptx #1 {\errmessage{@defoptx in invalid context}} -\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} -\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} - -% Now define @deftp -% Args are printed in bold, a slight difference from @defvar. - -\def\deftpargs #1{\bf \defvarargs{#1}} - -% @deftp Class window height width ... - -\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} - -\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% -\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} - -% This definition is run if you use @deftpx, etc -% anywhere other than immediately after a @deftp, etc. - -\def\deftpx #1 {\errmessage{@deftpx in invalid context}} - -\message{cross reference,} -% Define cross-reference macros -\newwrite \auxfile - -\newif\ifhavexrefs % True if xref values are known. -\newif\ifwarnedxrefs % True if we warned once that they aren't known. - -% \setref{foo} defines a cross-reference point named foo. - -\def\setref#1{% -%\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Ysectionnumberandtype}} - -\def\unnumbsetref#1{% -%\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Ynothing}} - -\def\appendixsetref#1{% -%\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Yappendixletterandtype}} - -% \xref, \pxref, and \ref generate cross-references to specified points. -% For \xrefX, #1 is the node name, #2 the name of the Info -% cross-reference, #3 the printed node name, #4 the name of the Info -% file, #5 the name of the printed manual. All but the node name can be -% omitted. -% -\def\pxref#1{see \xrefX[#1,,,,,,,]} -\def\xref#1{See \xrefX[#1,,,,,,,]} -\def\ref#1{\xrefX[#1,,,,,,,]} -\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup% -\def\printedmanual{\ignorespaces #5}% -\def\printednodename{\ignorespaces #3}% -% -\setbox1=\hbox{\printedmanual}% -\setbox0=\hbox{\printednodename}% -\ifdim \wd0=0pt% -\def\printednodename{\ignorespaces #1}% -%%% Uncommment the following line to make the actual chapter or section title -%%% appear inside the square brackets. -%\def\printednodename{#1-title}% -\fi% -% -% -% If we use \unhbox0 and \unhbox1 to print the node names, TeX does -% not insert empty discretionaries after hyphens, which means that it -% will not find a line break at a hyphen in a node names. Since some -% manuals are best written with fairly long node names, containing -% hyphens, this is a loss. Therefore, we simply give the text of -% the node name again, so it is as if TeX is seeing it for the first -% time. -\ifdim \wd1>0pt -section ``\printednodename'' in \cite{\printedmanual}% -\else% -\turnoffactive% -\refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}% -\fi -\endgroup} - -% \dosetq is the interface for calls from other macros - -% Use \turnoffactive so that punctuation chars such as underscore -% work in node names. -\def\dosetq #1#2{{\let\folio=0 \turnoffactive% -\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}% -\next}} - -% \internalsetq {foo}{page} expands into -% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} -% When the aux file is read, ' is the escape character - -\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} - -% Things to be expanded by \internalsetq - -\def\Ypagenumber{\folio} - -\def\Ytitle{\thischapter} - -\def\Ynothing{} - -\def\Ysectionnumberandtype{% -\ifnum\secno=0 Chapter\xreftie\the\chapno % -\else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno % -\else \ifnum \subsubsecno=0 % -Section\xreftie\the\chapno.\the\secno.\the\subsecno % -\else % -Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\def\Yappendixletterandtype{% -\ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}% -\else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno % -\else \ifnum \subsubsecno=0 % -Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno % -\else % -Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\gdef\xreftie{'tie} - -% Use TeX 3.0's \inputlineno to get the line number, for better error -% messages, but if we're using an old version of TeX, don't do anything. -% -\ifx\inputlineno\thisisundefined - \let\linenumber = \empty % Non-3.0. -\else - \def\linenumber{\the\inputlineno:\space} -\fi - -% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. -% If its value is nonempty, SUFFIX is output afterward. - -\def\refx#1#2{% - \expandafter\ifx\csname X#1\endcsname\relax - % If not defined, say something at least. - $\langle$un\-de\-fined$\rangle$% - \ifhavexrefs - \message{\linenumber Undefined cross reference `#1'.}% - \else - \ifwarnedxrefs\else - \global\warnedxrefstrue - \message{Cross reference values unknown; you must run TeX again.}% - \fi - \fi - \else - % It's defined, so just use it. - \csname X#1\endcsname - \fi - #2% Output the suffix in any case. -} - -% Read the last existing aux file, if any. No error if none exists. - -% This is the macro invoked by entries in the aux file. -\def\xrdef #1#2{ -{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}} - -\def\readauxfile{% -\begingroup -\catcode `\^^@=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\^^C=\other -\catcode `\^^D=\other -\catcode `\^^E=\other -\catcode `\^^F=\other -\catcode `\^^G=\other -\catcode `\^^H=\other -\catcode `\ =\other -\catcode `\^^L=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode 26=\other -\catcode `\^^[=\other -\catcode `\^^\=\other -\catcode `\^^]=\other -\catcode `\^^^=\other -\catcode `\^^_=\other -\catcode `\@=\other -\catcode `\^=\other -\catcode `\~=\other -\catcode `\[=\other -\catcode `\]=\other -\catcode`\"=\other -\catcode`\_=\other -\catcode`\|=\other -\catcode`\<=\other -\catcode`\>=\other -\catcode `\$=\other -\catcode `\#=\other -\catcode `\&=\other -% `\+ does not work, so use 43. -\catcode 43=\other -% the aux file uses ' as the escape. -% Turn off \ as an escape so we do not lose on -% entries which were dumped with control sequences in their names. -% For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ -% Reference to such entries still does not work the way one would wish, -% but at least they do not bomb out when the aux file is read in. -\catcode `\{=1 \catcode `\}=2 -\catcode `\%=\other -\catcode `\'=0 -\catcode `\\=\other -\openin 1 \jobname.aux -\ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue -\global\warnedobstrue -\fi -% Open the new aux file. Tex will close it automatically at exit. -\openout \auxfile=\jobname.aux -\endgroup} - - -% Footnotes. - -\newcount \footnoteno - -% The trailing space in the following definition for supereject is -% vital for proper filling; pages come out unaligned when you do a -% pagealignmacro call if that space before the closing brace is -% removed. -\def\supereject{\par\penalty -20000\footnoteno =0 } - -% @footnotestyle is meaningful for info output only.. -\let\footnotestyle=\comment - -\let\ptexfootnote=\footnote - -{\catcode `\@=11 -% -% Auto-number footnotes. Otherwise like plain. -\gdef\footnote{% - \global\advance\footnoteno by \@ne - \edef\thisfootno{$^{\the\footnoteno}$}% - % - % In case the footnote comes at the end of a sentence, preserve the - % extra spacing after we do the footnote number. - \let\@sf\empty - \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi - % - % Remove inadvertent blank space before typesetting the footnote number. - \unskip - \thisfootno\@sf - \footnotezzz -}% - -% Don't bother with the trickery in plain.tex to not require the -% footnote text as a parameter. Our footnotes don't need to be so general. -% -\long\gdef\footnotezzz#1{\insert\footins{% - % We want to typeset this text as a normal paragraph, even if the - % footnote reference occurs in (for example) a display environment. - % So reset some parameters. - \interlinepenalty\interfootnotelinepenalty - \splittopskip\ht\strutbox % top baseline for broken footnotes - \splitmaxdepth\dp\strutbox - \floatingpenalty\@MM - \leftskip\z@skip - \rightskip\z@skip - \spaceskip\z@skip - \xspaceskip\z@skip - \parindent\defaultparindent - % - % Hang the footnote text off the number. - \hang - \textindent{\thisfootno}% - % - % Don't crash into the line above the footnote text. Since this - % expands into a box, it must come within the paragraph, lest it - % provide a place where TeX can split the footnote. - \footstrut - #1\strut}% -} - -}%end \catcode `\@=11 - -% Set the baselineskip to #1, and the lineskip and strut size -% correspondingly. There is no deep meaning behind these magic numbers -% used as factors; they just match (closely enough) what Knuth defined. -% -\def\lineskipfactor{.1} -\def\strutheightpercent{.71} -\def\strutdepthpercent{.29} -% -\def\setleading#1{% - \baselineskip = #1\relax - \normalbaselineskip = \baselineskip - \lineskip = \lineskipfactor\baselineskip - \setbox\strutbox =\hbox{% - \vrule width0pt height\strutheightpercent\baselineskip - depth \strutdepthpercent \baselineskip - }% -} - -% @| inserts a changebar to the left of the current line. It should -% surround any changed text. This approach does *not* work if the -% change spans more than two lines of output. To handle that, we would -% have adopt a much more difficult approach (putting marks into the main -% vertical list for the beginning and end of each change). -% -\def\|{% - % \vadjust can only be used in horizontal mode. - \leavevmode - % - % Append this vertical mode material after the current line in the output. - \vadjust{% - % We want to insert a rule with the height and depth of the current - % leading; that is exactly what \strutbox is supposed to record. - \vskip-\baselineskip - % - % \vadjust-items are inserted at the left edge of the type. So - % the \llap here moves out into the left-hand margin. - \llap{% - % - % For a thicker or thinner bar, change the `1pt'. - \vrule height\baselineskip width1pt - % - % This is the space between the bar and the text. - \hskip 12pt - }% - }% -} - -% For a final copy, take out the rectangles -% that mark overfull boxes (in case you have decided -% that the text looks ok even though it passes the margin). -% -\def\finalout{\overfullrule=0pt} - - -% End of control word definitions. - -\message{and turning on texinfo input format.} - -\def\openindices{% - \newindex{cp}% - \newcodeindex{fn}% - \newcodeindex{vr}% - \newcodeindex{tp}% - \newcodeindex{ky}% - \newcodeindex{pg}% -} - -% Set some numeric style parameters, for 8.5 x 11 format. - -%\hsize = 6.5in -\newdimen\defaultparindent \defaultparindent = 15pt -\parindent = \defaultparindent -\parskip 18pt plus 1pt -\setleading{15pt} -\advance\topskip by 1.2cm - -% Prevent underfull vbox error messages. -\vbadness=10000 - -% Following George Bush, just get rid of widows and orphans. -\widowpenalty=10000 -\clubpenalty=10000 - -% Use TeX 3.0's \emergencystretch to help line breaking, but if we're -% using an old version of TeX, don't do anything. We want the amount of -% stretch added to depend on the line length, hence the dependence on -% \hsize. This makes it come to about 9pt for the 8.5x11 format. -% -\ifx\emergencystretch\thisisundefined - % Allow us to assign to \emergencystretch anyway. - \def\emergencystretch{\dimen0}% -\else - \emergencystretch = \hsize - \divide\emergencystretch by 45 -\fi - -% Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25) -\def\smallbook{ - -% These values for secheadingskip and subsecheadingskip are -% experiments. RJC 7 Aug 1992 -\global\secheadingskip = 17pt plus 6pt minus 3pt -\global\subsecheadingskip = 14pt plus 6pt minus 3pt - -\global\lispnarrowing = 0.3in -\setleading{12pt} -\advance\topskip by -1cm -\global\parskip 3pt plus 1pt -\global\hsize = 5in -\global\vsize=7.5in -\global\tolerance=700 -\global\hfuzz=1pt -\global\contentsrightmargin=0pt - -\global\pagewidth=\hsize -\global\pageheight=\vsize - -\global\let\smalllisp=\smalllispx -\global\let\smallexample=\smalllispx -\global\def\Esmallexample{\Esmalllisp} -} - -% Use @afourpaper to print on European A4 paper. -\def\afourpaper{ -\global\tolerance=700 -\global\hfuzz=1pt -\setleading{12pt} -\global\parskip 15pt plus 1pt - -\global\vsize= 53\baselineskip -\advance\vsize by \topskip -%\global\hsize= 5.85in % A4 wide 10pt -\global\hsize= 6.5in -\global\outerhsize=\hsize -\global\advance\outerhsize by 0.5in -\global\outervsize=\vsize -\global\advance\outervsize by 0.6in - -\global\pagewidth=\hsize -\global\pageheight=\vsize -} - -% Define macros to output various characters with catcode for normal text. -\catcode`\"=\other -\catcode`\~=\other -\catcode`\^=\other -\catcode`\_=\other -\catcode`\|=\other -\catcode`\<=\other -\catcode`\>=\other -\catcode`\+=\other -\def\normaldoublequote{"} -\def\normaltilde{~} -\def\normalcaret{^} -\def\normalunderscore{_} -\def\normalverticalbar{|} -\def\normalless{<} -\def\normalgreater{>} -\def\normalplus{+} - -% This macro is used to make a character print one way in ttfont -% where it can probably just be output, and another way in other fonts, -% where something hairier probably needs to be done. -% -% #1 is what to print if we are indeed using \tt; #2 is what to print -% otherwise. Since all the Computer Modern typewriter fonts have zero -% interword stretch (and shrink), and it is reasonable to expect all -% typewriter fonts to have this, we can check that font parameter. -% -\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} - -% Turn off all special characters except @ -% (and those which the user can use as if they were ordinary). -% Most of these we simply print from the \tt font, but for some, we can -% use math or other variants that look better in normal text. - -\catcode`\"=\active -\def\activedoublequote{{\tt \char '042}} -\let"=\activedoublequote -\catcode`\~=\active -\def~{{\tt \char '176}} -\chardef\hat=`\^ -\catcode`\^=\active -\def^{{\tt \hat}} - -\catcode`\_=\active -\def_{\ifusingtt\normalunderscore\_} -% Subroutine for the previous macro. -\def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}} - -% \lvvmode is equivalent in function to \leavevmode. -% Using \leavevmode runs into trouble when written out to -% an index file due to the expansion of \leavevmode into ``\unhbox -% \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our -% magic tricks with @. -\def\lvvmode{\vbox to 0pt{}} - -\catcode`\|=\active -\def|{{\tt \char '174}} -\chardef \less=`\< -\catcode`\<=\active -\def<{{\tt \less}} -\chardef \gtr=`\> -\catcode`\>=\active -\def>{{\tt \gtr}} -\catcode`\+=\active -\def+{{\tt \char 43}} -%\catcode 27=\active -%\def^^[{$\diamondsuit$} - -% Used sometimes to turn off (effectively) the active characters -% even after parsing them. -\def\turnoffactive{\let"=\normaldoublequote -\let~=\normaltilde -\let^=\normalcaret -\let_=\normalunderscore -\let|=\normalverticalbar -\let<=\normalless -\let>=\normalgreater -\let+=\normalplus} - -% Set up an active definition for =, but don't enable it most of the time. -{\catcode`\==\active -\global\def={{\tt \char 61}}} - -\catcode`\@=0 - -% \rawbackslashxx output one backslash character in current font -\global\chardef\rawbackslashxx=`\\ -%{\catcode`\\=\other -%@gdef@rawbackslashxx{\}} - -% \rawbackslash redefines \ as input to do \rawbackslashxx. -{\catcode`\\=\active -@gdef@rawbackslash{@let\=@rawbackslashxx }} - -% \normalbackslash outputs one backslash in fixed width font. -\def\normalbackslash{{\tt\rawbackslashxx}} - -% Say @foo, not \foo, in error messages. -\escapechar=`\@ - -% \catcode 17=0 % Define control-q -\catcode`\\=\active - -% If a .fmt file is being used, we don't want the `\input texinfo' to show up. -% That is what \eatinput is for; after that, the `\' should revert to printing -% a backslash. -% -@gdef@eatinput input texinfo{@fixbackslash} -@global@let\ = @eatinput - -% On the other hand, perhaps the file did not have a `\input texinfo'. Then -% the first `\{ in the file would cause an error. This macro tries to fix -% that, assuming it is called before the first `\' could plausibly occur. -% -@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi} - -%% These look ok in all fonts, so just make them not special. The @rm below -%% makes sure that the current font starts out as the newly loaded cmr10 -@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other - -@textfonts -@rm - -@c Local variables: -@c page-delimiter: "^\\\\message" -@c End: diff --git a/gnu/lib/libregex/doc/xregex.texi b/gnu/lib/libregex/doc/xregex.texi deleted file mode 100644 index 9292b356ef75..000000000000 --- a/gnu/lib/libregex/doc/xregex.texi +++ /dev/null @@ -1,3021 +0,0 @@ -\input texinfo -@c %**start of header -@setfilename regex.info -@settitle Regex -@c %**end of header - -@c \\{fill-paragraph} works better (for me, anyway) if the text in the -@c source file isn't indented. -@paragraphindent 2 - -@c Define a new index for our magic constants. -@defcodeindex cn - -@c Put everything in one index (arbitrarily chosen to be the concept index). -@syncodeindex cn cp -@syncodeindex ky cp -@syncodeindex pg cp -@syncodeindex tp cp -@syncodeindex vr cp - -@c Here is what we use in the Info `dir' file: -@c * Regex: (regex). Regular expression library. - - -@ifinfo -This file documents the GNU regular expression library. - -Copyright (C) 1992, 1993 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 a 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 also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and 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 the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end ifinfo - - -@titlepage - -@title Regex -@subtitle edition 0.12a -@subtitle 19 September 1992 -@author Kathryn A. Hargreaves -@author Karl Berry - -@page - -@vskip 0pt plus 1filll -Copyright @copyright{} 1992 Free Software Foundation. - -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 also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and 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 the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. - -@end titlepage - - -@ifinfo -@node Top, Overview, (dir), (dir) -@top Regular Expression Library - -This manual documents how to program with the GNU regular expression -library. This is edition 0.12a of the manual, 19 September 1992. - -The first part of this master menu lists the major nodes in this Info -document, including the index. The rest of the menu lists all the -lower level nodes in the document. - -@menu -* Overview:: -* Regular Expression Syntax:: -* Common Operators:: -* GNU Operators:: -* GNU Emacs Operators:: -* What Gets Matched?:: -* Programming with Regex:: -* Copying:: Copying and sharing Regex. -* Index:: General index. - --- The Detailed Node Listing --- - -Regular Expression Syntax - -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: - -Common Operators - -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? @{@} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ - -Repetition Operators - -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: @{@} - -List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]}) - -* Character Class Operators:: [:class:] -* Range Operator:: start-end - -Anchoring Operators - -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ - -GNU Operators - -* Word Operators:: -* Buffer Operators:: - -Word Operators - -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W - -Buffer Operators - -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' - -GNU Emacs Operators - -* Syntactic Class Operators:: - -Syntactic Class Operators - -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS - -Programming with Regex - -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: - -GNU Regex Functions - -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () - -POSIX Regex Functions - -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () - -BSD Regex Functions - -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () -@end menu -@end ifinfo -@node Overview, Regular Expression Syntax, Top, Top -@chapter Overview - -A @dfn{regular expression} (or @dfn{regexp}, or @dfn{pattern}) is a text -string that describes some (mathematical) set of strings. A regexp -@var{r} @dfn{matches} a string @var{s} if @var{s} is in the set of -strings described by @var{r}. - -Using the Regex library, you can: - -@itemize @bullet - -@item -see if a string matches a specified pattern as a whole, and - -@item -search within a string for a substring matching a specified pattern. - -@end itemize - -Some regular expressions match only one string, i.e., the set they -describe has only one member. For example, the regular expression -@samp{foo} matches the string @samp{foo} and no others. Other regular -expressions match more than one string, i.e., the set they describe has -more than one member. For example, the regular expression @samp{f*} -matches the set of strings made up of any number (including zero) of -@samp{f}s. As you can see, some characters in regular expressions match -themselves (such as @samp{f}) and some don't (such as @samp{*}); the -ones that don't match themselves instead let you specify patterns that -describe many different strings. - -To either match or search for a regular expression with the Regex -library functions, you must first compile it with a Regex pattern -compiling function. A @dfn{compiled pattern} is a regular expression -converted to the internal format used by the library functions. Once -you've compiled a pattern, you can use it for matching or searching any -number of times. - -The Regex library consists of two source files: @file{regex.h} and -@file{regex.c}. -@pindex regex.h -@pindex regex.c -Regex provides three groups of functions with which you can operate on -regular expressions. One group---the @sc{gnu} group---is more powerful -but not completely compatible with the other two, namely the @sc{posix} -and Berkeley @sc{unix} groups; its interface was designed specifically -for @sc{gnu}. The other groups have the same interfaces as do the -regular expression functions in @sc{posix} and Berkeley -@sc{unix}. - -We wrote this chapter with programmers in mind, not users of -programs---such as Emacs---that use Regex. We describe the Regex -library in its entirety, not how to write regular expressions that a -particular program understands. - - -@node Regular Expression Syntax, Common Operators, Overview, Top -@chapter Regular Expression Syntax - -@cindex regular expressions, syntax of -@cindex syntax of regular expressions - -@dfn{Characters} are things you can type. @dfn{Operators} are things in -a regular expression that match one or more characters. You compose -regular expressions from operators, which in turn you specify using one -or more characters. - -Most characters represent what we call the match-self operator, i.e., -they match themselves; we call these characters @dfn{ordinary}. Other -characters represent either all or parts of fancier operators; e.g., -@samp{.} represents what we call the match-any-character operator -(which, no surprise, matches (almost) any character); we call these -characters @dfn{special}. Two different things determine what -characters represent what operators: - -@enumerate -@item -the regular expression syntax your program has told the Regex library to -recognize, and - -@item -the context of the character in the regular expression. -@end enumerate - -In the following sections, we describe these things in more detail. - -@menu -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: -@end menu - - -@node Syntax Bits, Predefined Syntaxes, , Regular Expression Syntax -@section Syntax Bits - -@cindex syntax bits - -In any particular syntax for regular expressions, some characters are -always special, others are sometimes special, and others are never -special. The particular syntax that Regex recognizes for a given -regular expression depends on the value in the @code{syntax} field of -the pattern buffer of that regular expression. - -You get a pattern buffer by compiling a regular expression. @xref{GNU -Pattern Buffers}, and @ref{POSIX Pattern Buffers}, for more information -on pattern buffers. @xref{GNU Regular Expression Compiling}, @ref{POSIX -Regular Expression Compiling}, and @ref{BSD Regular Expression -Compiling}, for more information on compiling. - -Regex considers the value of the @code{syntax} field to be a collection -of bits; we refer to these bits as @dfn{syntax bits}. In most cases, -they affect what characters represent what operators. We describe the -meanings of the operators to which we refer in @ref{Common Operators}, -@ref{GNU Operators}, and @ref{GNU Emacs Operators}. - -For reference, here is the complete list of syntax bits, in alphabetical -order: - -@table @code - -@cnindex RE_BACKSLASH_ESCAPE_IN_LIST -@item RE_BACKSLASH_ESCAPE_IN_LISTS -If this bit is set, then @samp{\} inside a list (@pxref{List Operators} -quotes (makes ordinary, if it's special) the following character; if -this bit isn't set, then @samp{\} is an ordinary character inside lists. -(@xref{The Backslash Character}, for what `\' does outside of lists.) - -@cnindex RE_BK_PLUS_QM -@item RE_BK_PLUS_QM -If this bit is set, then @samp{\+} represents the match-one-or-more -operator and @samp{\?} represents the match-zero-or-more operator; if -this bit isn't set, then @samp{+} represents the match-one-or-more -operator and @samp{?} represents the match-zero-or-one operator. This -bit is irrelevant if @code{RE_LIMITED_OPS} is set. - -@cnindex RE_CHAR_CLASSES -@item RE_CHAR_CLASSES -If this bit is set, then you can use character classes in lists; if this -bit isn't set, then you can't. - -@cnindex RE_CONTEXT_INDEP_ANCHORS -@item RE_CONTEXT_INDEP_ANCHORS -If this bit is set, then @samp{^} and @samp{$} are special anywhere outside -a list; if this bit isn't set, then these characters are special only in -certain contexts. @xref{Match-beginning-of-line Operator}, and -@ref{Match-end-of-line Operator}. - -@cnindex RE_CONTEXT_INDEP_OPS -@item RE_CONTEXT_INDEP_OPS -If this bit is set, then certain characters are special anywhere outside -a list; if this bit isn't set, then those characters are special only in -some contexts and are ordinary elsewhere. Specifically, if this bit -isn't set then @samp{*}, and (if the syntax bit @code{RE_LIMITED_OPS} -isn't set) @samp{+} and @samp{?} (or @samp{\+} and @samp{\?}, depending -on the syntax bit @code{RE_BK_PLUS_QM}) represent repetition operators -only if they're not first in a regular expression or just after an -open-group or alternation operator. The same holds for @samp{@{} (or -@samp{\@{}, depending on the syntax bit @code{RE_NO_BK_BRACES}) if -it is the beginning of a valid interval and the syntax bit -@code{RE_INTERVALS} is set. - -@cnindex RE_CONTEXT_INVALID_OPS -@item RE_CONTEXT_INVALID_OPS -If this bit is set, then repetition and alternation operators can't be -in certain positions within a regular expression. Specifically, the -regular expression is invalid if it has: - -@itemize @bullet - -@item -a repetition operator first in the regular expression or just after a -match-beginning-of-line, open-group, or alternation operator; or - -@item -an alternation operator first or last in the regular expression, just -before a match-end-of-line operator, or just after an alternation or -open-group operator. - -@end itemize - -If this bit isn't set, then you can put the characters representing the -repetition and alternation characters anywhere in a regular expression. -Whether or not they will in fact be operators in certain positions -depends on other syntax bits. - -@cnindex RE_DOT_NEWLINE -@item RE_DOT_NEWLINE -If this bit is set, then the match-any-character operator matches -a newline; if this bit isn't set, then it doesn't. - -@cnindex RE_DOT_NOT_NULL -@item RE_DOT_NOT_NULL -If this bit is set, then the match-any-character operator doesn't match -a null character; if this bit isn't set, then it does. - -@cnindex RE_INTERVALS -@item RE_INTERVALS -If this bit is set, then Regex recognizes interval operators; if this bit -isn't set, then it doesn't. - -@cnindex RE_LIMITED_OPS -@item RE_LIMITED_OPS -If this bit is set, then Regex doesn't recognize the match-one-or-more, -match-zero-or-one or alternation operators; if this bit isn't set, then -it does. - -@cnindex RE_NEWLINE_ALT -@item RE_NEWLINE_ALT -If this bit is set, then newline represents the alternation operator; if -this bit isn't set, then newline is ordinary. - -@cnindex RE_NO_BK_BRACES -@item RE_NO_BK_BRACES -If this bit is set, then @samp{@{} represents the open-interval operator -and @samp{@}} represents the close-interval operator; if this bit isn't -set, then @samp{\@{} represents the open-interval operator and -@samp{\@}} represents the close-interval operator. This bit is relevant -only if @code{RE_INTERVALS} is set. - -@cnindex RE_NO_BK_PARENS -@item RE_NO_BK_PARENS -If this bit is set, then @samp{(} represents the open-group operator and -@samp{)} represents the close-group operator; if this bit isn't set, then -@samp{\(} represents the open-group operator and @samp{\)} represents -the close-group operator. - -@cnindex RE_NO_BK_REFS -@item RE_NO_BK_REFS -If this bit is set, then Regex doesn't recognize @samp{\}@var{digit} as -the back reference operator; if this bit isn't set, then it does. - -@cnindex RE_NO_BK_VBAR -@item RE_NO_BK_VBAR -If this bit is set, then @samp{|} represents the alternation operator; -if this bit isn't set, then @samp{\|} represents the alternation -operator. This bit is irrelevant if @code{RE_LIMITED_OPS} is set. - -@cnindex RE_NO_EMPTY_RANGES -@item RE_NO_EMPTY_RANGES -If this bit is set, then a regular expression with a range whose ending -point collates lower than its starting point is invalid; if this bit -isn't set, then Regex considers such a range to be empty. - -@cnindex RE_UNMATCHED_RIGHT_PAREN_ORD -@item RE_UNMATCHED_RIGHT_PAREN_ORD -If this bit is set and the regular expression has no matching open-group -operator, then Regex considers what would otherwise be a close-group -operator (based on how @code{RE_NO_BK_PARENS} is set) to match @samp{)}. - -@end table - - -@node Predefined Syntaxes, Collating Elements vs. Characters, Syntax Bits, Regular Expression Syntax -@section Predefined Syntaxes - -If you're programming with Regex, you can set a pattern buffer's -(@pxref{GNU Pattern Buffers}, and @ref{POSIX Pattern Buffers}) -@code{syntax} field either to an arbitrary combination of syntax bits -(@pxref{Syntax Bits}) or else to the configurations defined by Regex. -These configurations define the syntaxes used by certain -programs---@sc{gnu} Emacs, -@cindex Emacs -@sc{posix} Awk, -@cindex POSIX Awk -traditional Awk, -@cindex Awk -Grep, -@cindex Grep -@cindex Egrep -Egrep---in addition to syntaxes for @sc{posix} basic and extended -regular expressions. - -The predefined syntaxes--taken directly from @file{regex.h}---are: - -@example -[[[ syntaxes ]]] -@end example - -@node Collating Elements vs. Characters, The Backslash Character, Predefined Syntaxes, Regular Expression Syntax -@section Collating Elements vs.@: Characters - -@sc{posix} generalizes the notion of a character to that of a -collating element. It defines a @dfn{collating element} to be ``a -sequence of one or more bytes defined in the current collating sequence -as a unit of collation.'' - -This generalizes the notion of a character in -two ways. First, a single character can map into two or more collating -elements. For example, the German -@tex -`\ss' -@end tex -@ifinfo -``es-zet'' -@end ifinfo -collates as the collating element @samp{s} followed by another collating -element @samp{s}. Second, two or more characters can map into one -collating element. For example, the Spanish @samp{ll} collates after -@samp{l} and before @samp{m}. - -Since @sc{posix}'s ``collating element'' preserves the essential idea of -a ``character,'' we use the latter, more familiar, term in this document. - -@node The Backslash Character, , Collating Elements vs. Characters, Regular Expression Syntax -@section The Backslash Character - -@cindex \ -The @samp{\} character has one of four different meanings, depending on -the context in which you use it and what syntax bits are set -(@pxref{Syntax Bits}). It can: 1) stand for itself, 2) quote the next -character, 3) introduce an operator, or 4) do nothing. - -@enumerate -@item -It stands for itself inside a list -(@pxref{List Operators}) if the syntax bit -@code{RE_BACKSLASH_ESCAPE_IN_LISTS} is not set. For example, @samp{[\]} -would match @samp{\}. - -@item -It quotes (makes ordinary, if it's special) the next character when you -use it either: - -@itemize @bullet -@item -outside a list,@footnote{Sometimes -you don't have to explicitly quote special characters to make -them ordinary. For instance, most characters lose any special meaning -inside a list (@pxref{List Operators}). In addition, if the syntax bits -@code{RE_CONTEXT_INVALID_OPS} and @code{RE_CONTEXT_INDEP_OPS} -aren't set, then (for historical reasons) the matcher considers special -characters ordinary if they are in contexts where the operations they -represent make no sense; for example, then the match-zero-or-more -operator (represented by @samp{*}) matches itself in the regular -expression @samp{*foo} because there is no preceding expression on which -it can operate. It is poor practice, however, to depend on this -behavior; if you want a special character to be ordinary outside a list, -it's better to always quote it, regardless.} or - -@item -inside a list and the syntax bit @code{RE_BACKSLASH_ESCAPE_IN_LISTS} is set. - -@end itemize - -@item -It introduces an operator when followed by certain ordinary -characters---sometimes only when certain syntax bits are set. See the -cases @code{RE_BK_PLUS_QM}, @code{RE_NO_BK_BRACES}, @code{RE_NO_BK_VAR}, -@code{RE_NO_BK_PARENS}, @code{RE_NO_BK_REF} in @ref{Syntax Bits}. Also: - -@itemize @bullet -@item -@samp{\b} represents the match-word-boundary operator -(@pxref{Match-word-boundary Operator}). - -@item -@samp{\B} represents the match-within-word operator -(@pxref{Match-within-word Operator}). - -@item -@samp{\<} represents the match-beginning-of-word operator @* -(@pxref{Match-beginning-of-word Operator}). - -@item -@samp{\>} represents the match-end-of-word operator -(@pxref{Match-end-of-word Operator}). - -@item -@samp{\w} represents the match-word-constituent operator -(@pxref{Match-word-constituent Operator}). - -@item -@samp{\W} represents the match-non-word-constituent operator -(@pxref{Match-non-word-constituent Operator}). - -@item -@samp{\`} represents the match-beginning-of-buffer -operator and @samp{\'} represents the match-end-of-buffer operator -(@pxref{Buffer Operators}). - -@item -If Regex was compiled with the C preprocessor symbol @code{emacs} -defined, then @samp{\s@var{class}} represents the match-syntactic-class -operator and @samp{\S@var{class}} represents the -match-not-syntactic-class operator (@pxref{Syntactic Class Operators}). - -@end itemize - -@item -In all other cases, Regex ignores @samp{\}. For example, -@samp{\n} matches @samp{n}. - -@end enumerate - -@node Common Operators, GNU Operators, Regular Expression Syntax, Top -@chapter Common Operators - -You compose regular expressions from operators. In the following -sections, we describe the regular expression operators specified by -@sc{posix}; @sc{gnu} also uses these. Most operators have more than one -representation as characters. @xref{Regular Expression Syntax}, for -what characters represent what operators under what circumstances. - -For most operators that can be represented in two ways, one -representation is a single character and the other is that character -preceded by @samp{\}. For example, either @samp{(} or @samp{\(} -represents the open-group operator. Which one does depends on the -setting of a syntax bit, in this case @code{RE_NO_BK_PARENS}. Why is -this so? Historical reasons dictate some of the varying -representations, while @sc{posix} dictates others. - -Finally, almost all characters lose any special meaning inside a list -(@pxref{List Operators}). - -@menu -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? @{@} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ -@end menu - -@node Match-self Operator, Match-any-character Operator, , Common Operators -@section The Match-self Operator (@var{ordinary character}) - -This operator matches the character itself. All ordinary characters -(@pxref{Regular Expression Syntax}) represent this operator. For -example, @samp{f} is always an ordinary character, so the regular -expression @samp{f} matches only the string @samp{f}. In -particular, it does @emph{not} match the string @samp{ff}. - -@node Match-any-character Operator, Concatenation Operator, Match-self Operator, Common Operators -@section The Match-any-character Operator (@code{.}) - -@cindex @samp{.} - -This operator matches any single printing or nonprinting character -except it won't match a: - -@table @asis -@item newline -if the syntax bit @code{RE_DOT_NEWLINE} isn't set. - -@item null -if the syntax bit @code{RE_DOT_NOT_NULL} is set. - -@end table - -The @samp{.} (period) character represents this operator. For example, -@samp{a.b} matches any three-character string beginning with @samp{a} -and ending with @samp{b}. - -@node Concatenation Operator, Repetition Operators, Match-any-character Operator, Common Operators -@section The Concatenation Operator - -This operator concatenates two regular expressions @var{a} and @var{b}. -No character represents this operator; you simply put @var{b} after -@var{a}. The result is a regular expression that will match a string if -@var{a} matches its first part and @var{b} matches the rest. For -example, @samp{xy} (two match-self operators) matches @samp{xy}. - -@node Repetition Operators, Alternation Operator, Concatenation Operator, Common Operators -@section Repetition Operators - -Repetition operators repeat the preceding regular expression a specified -number of times. - -@menu -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: @{@} -@end menu - -@node Match-zero-or-more Operator, Match-one-or-more Operator, , Repetition Operators -@subsection The Match-zero-or-more Operator (@code{*}) - -@cindex @samp{*} - -This operator repeats the smallest possible preceding regular expression -as many times as necessary (including zero) to match the pattern. -@samp{*} represents this operator. For example, @samp{o*} -matches any string made up of zero or more @samp{o}s. Since this -operator operates on the smallest preceding regular expression, -@samp{fo*} has a repeating @samp{o}, not a repeating @samp{fo}. So, -@samp{fo*} matches @samp{f}, @samp{fo}, @samp{foo}, and so on. - -Since the match-zero-or-more operator is a suffix operator, it may be -useless as such when no regular expression precedes it. This is the -case when it: - -@itemize @bullet -@item -is first in a regular expression, or - -@item -follows a match-beginning-of-line, open-group, or alternation -operator. - -@end itemize - -@noindent -Three different things can happen in these cases: - -@enumerate -@item -If the syntax bit @code{RE_CONTEXT_INVALID_OPS} is set, then the -regular expression is invalid. - -@item -If @code{RE_CONTEXT_INVALID_OPS} isn't set, but -@code{RE_CONTEXT_INDEP_OPS} is, then @samp{*} represents the -match-zero-or-more operator (which then operates on the empty string). - -@item -Otherwise, @samp{*} is ordinary. - -@end enumerate - -@cindex backtracking -The matcher processes a match-zero-or-more operator by first matching as -many repetitions of the smallest preceding regular expression as it can. -Then it continues to match the rest of the pattern. - -If it can't match the rest of the pattern, it backtracks (as many times -as necessary), each time discarding one of the matches until it can -either match the entire pattern or be certain that it cannot get a -match. For example, when matching @samp{ca*ar} against @samp{caaar}, -the matcher first matches all three @samp{a}s of the string with the -@samp{a*} of the regular expression. However, it cannot then match the -final @samp{ar} of the regular expression against the final @samp{r} of -the string. So it backtracks, discarding the match of the last @samp{a} -in the string. It can then match the remaining @samp{ar}. - - -@node Match-one-or-more Operator, Match-zero-or-one Operator, Match-zero-or-more Operator, Repetition Operators -@subsection The Match-one-or-more Operator (@code{+} or @code{\+}) - -@cindex @samp{+} - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't recognize -this operator. Otherwise, if the syntax bit @code{RE_BK_PLUS_QM} isn't -set, then @samp{+} represents this operator; if it is, then @samp{\+} -does. - -This operator is similar to the match-zero-or-more operator except that -it repeats the preceding regular expression at least once; -@pxref{Match-zero-or-more Operator}, for what it operates on, how some -syntax bits affect it, and how Regex backtracks to match it. - -For example, supposing that @samp{+} represents the match-one-or-more -operator; then @samp{ca+r} matches, e.g., @samp{car} and -@samp{caaaar}, but not @samp{cr}. - -@node Match-zero-or-one Operator, Interval Operators, Match-one-or-more Operator, Repetition Operators -@subsection The Match-zero-or-one Operator (@code{?} or @code{\?}) -@cindex @samp{?} - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit -@code{RE_BK_PLUS_QM} isn't set, then @samp{?} represents this operator; -if it is, then @samp{\?} does. - -This operator is similar to the match-zero-or-more operator except that -it repeats the preceding regular expression once or not at all; -@pxref{Match-zero-or-more Operator}, to see what it operates on, how -some syntax bits affect it, and how Regex backtracks to match it. - -For example, supposing that @samp{?} represents the match-zero-or-one -operator; then @samp{ca?r} matches both @samp{car} and @samp{cr}, but -nothing else. - -@node Interval Operators, , Match-zero-or-one Operator, Repetition Operators -@subsection Interval Operators (@code{@{} @dots{} @code{@}} or @code{\@{} @dots{} @code{\@}}) - -@cindex interval expression -@cindex @samp{@{} -@cindex @samp{@}} -@cindex @samp{\@{} -@cindex @samp{\@}} - -If the syntax bit @code{RE_INTERVALS} is set, then Regex recognizes -@dfn{interval expressions}. They repeat the smallest possible preceding -regular expression a specified number of times. - -If the syntax bit @code{RE_NO_BK_BRACES} is set, @samp{@{} represents -the @dfn{open-interval operator} and @samp{@}} represents the -@dfn{close-interval operator} ; otherwise, @samp{\@{} and @samp{\@}} do. - -Specifically, supposing that @samp{@{} and @samp{@}} represent the -open-interval and close-interval operators; then: - -@table @code -@item @{@var{count}@} -matches exactly @var{count} occurrences of the preceding regular -expression. - -@item @{@var{min,}@} -matches @var{min} or more occurrences of the preceding regular -expression. - -@item @{@var{min, max}@} -matches at least @var{min} but no more than @var{max} occurrences of -the preceding regular expression. - -@end table - -The interval expression (but not necessarily the regular expression that -contains it) is invalid if: - -@itemize @bullet -@item -@var{min} is greater than @var{max}, or - -@item -any of @var{count}, @var{min}, or @var{max} are outside the range -zero to @code{RE_DUP_MAX} (which symbol @file{regex.h} -defines). - -@end itemize - -If the interval expression is invalid and the syntax bit -@code{RE_NO_BK_BRACES} is set, then Regex considers all the -characters in the would-be interval to be ordinary. If that bit -isn't set, then the regular expression is invalid. - -If the interval expression is valid but there is no preceding regular -expression on which to operate, then if the syntax bit -@code{RE_CONTEXT_INVALID_OPS} is set, the regular expression is invalid. -If that bit isn't set, then Regex considers all the characters---other -than backslashes, which it ignores---in the would-be interval to be -ordinary. - - -@node Alternation Operator, List Operators, Repetition Operators, Common Operators -@section The Alternation Operator (@code{|} or @code{\|}) - -@kindex | -@kindex \| -@cindex alternation operator -@cindex or operator - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit -@code{RE_NO_BK_VBAR} is set, then @samp{|} represents this operator; -otherwise, @samp{\|} does. - -Alternatives match one of a choice of regular expressions: -if you put the character(s) representing the alternation operator between -any two regular expressions @var{a} and @var{b}, the result matches -the union of the strings that @var{a} and @var{b} match. For -example, supposing that @samp{|} is the alternation operator, then -@samp{foo|bar|quux} would match any of @samp{foo}, @samp{bar} or -@samp{quux}. - -@ignore -@c Nobody needs to disallow empty alternatives any more. -If the syntax bit @code{RE_NO_EMPTY_ALTS} is set, then if either of the regular -expressions @var{a} or @var{b} is empty, the -regular expression is invalid. More precisely, if this syntax bit is -set, then the alternation operator can't: - -@itemize @bullet -@item -be first or last in a regular expression; - -@item -follow either another alternation operator or an open-group operator -(@pxref{Grouping Operators}); or - -@item -precede a close-group operator. - -@end itemize - -@noindent -For example, supposing @samp{(} and @samp{)} represent the open and -close-group operators, then @samp{|foo}, @samp{foo|}, @samp{foo||bar}, -@samp{foo(|bar)}, and @samp{(foo|)bar} would all be invalid. -@end ignore - -The alternation operator operates on the @emph{largest} possible -surrounding regular expressions. (Put another way, it has the lowest -precedence of any regular expression operator.) -Thus, the only way you can -delimit its arguments is to use grouping. For example, if @samp{(} and -@samp{)} are the open and close-group operators, then @samp{fo(o|b)ar} -would match either @samp{fooar} or @samp{fobar}. (@samp{foo|bar} would -match @samp{foo} or @samp{bar}.) - -@cindex backtracking -The matcher usually tries all combinations of alternatives so as to -match the longest possible string. For example, when matching -@samp{(fooq|foo)*(qbarquux|bar)} against @samp{fooqbarquux}, it cannot -take, say, the first (``depth-first'') combination it could match, since -then it would be content to match just @samp{fooqbar}. - -@comment xx something about leftmost-longest - - -@node List Operators, Grouping Operators, Alternation Operator, Common Operators -@section List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]}) - -@cindex matching list -@cindex @samp{[} -@cindex @samp{]} -@cindex @samp{^} -@cindex @samp{-} -@cindex @samp{\} -@cindex @samp{[^} -@cindex nonmatching list -@cindex matching newline -@cindex bracket expression - -@dfn{Lists}, also called @dfn{bracket expressions}, are a set of one or -more items. An @dfn{item} is a character, -@ignore -(These get added when they get implemented.) -a collating symbol, an equivalence class expression, -@end ignore -a character class expression, or a range expression. The syntax bits -affect which kinds of items you can put in a list. We explain the last -two items in subsections below. Empty lists are invalid. - -A @dfn{matching list} matches a single character represented by one of -the list items. You form a matching list by enclosing one or more items -within an @dfn{open-matching-list operator} (represented by @samp{[}) -and a @dfn{close-list operator} (represented by @samp{]}). - -For example, @samp{[ab]} matches either @samp{a} or @samp{b}. -@samp{[ad]*} matches the empty string and any string composed of just -@samp{a}s and @samp{d}s in any order. Regex considers invalid a regular -expression with a @samp{[} but no matching -@samp{]}. - -@dfn{Nonmatching lists} are similar to matching lists except that they -match a single character @emph{not} represented by one of the list -items. You use an @dfn{open-nonmatching-list operator} (represented by -@samp{[^}@footnote{Regex therefore doesn't consider the @samp{^} to be -the first character in the list. If you put a @samp{^} character first -in (what you think is) a matching list, you'll turn it into a -nonmatching list.}) instead of an open-matching-list operator to start a -nonmatching list. - -For example, @samp{[^ab]} matches any character except @samp{a} or -@samp{b}. - -If the @code{posix_newline} field in the pattern buffer (@pxref{GNU -Pattern Buffers} is set, then nonmatching lists do not match a newline. - -Most characters lose any special meaning inside a list. The special -characters inside a list follow. - -@table @samp -@item ] -ends the list if it's not the first list item. So, if you want to make -the @samp{]} character a list item, you must put it first. - -@item \ -quotes the next character if the syntax bit @code{RE_BACKSLASH_ESCAPE_IN_LISTS} is -set. - -@ignore -Put these in if they get implemented. - -@item [. -represents the open-collating-symbol operator (@pxref{Collating Symbol -Operators}). - -@item .] -represents the close-collating-symbol operator. - -@item [= -represents the open-equivalence-class operator (@pxref{Equivalence Class -Operators}). - -@item =] -represents the close-equivalence-class operator. - -@end ignore - -@item [: -represents the open-character-class operator (@pxref{Character Class -Operators}) if the syntax bit @code{RE_CHAR_CLASSES} is set and what -follows is a valid character class expression. - -@item :] -represents the close-character-class operator if the syntax bit -@code{RE_CHAR_CLASSES} is set and what precedes it is an -open-character-class operator followed by a valid character class name. - -@item - -represents the range operator (@pxref{Range Operator}) if it's -not first or last in a list or the ending point of a range. - -@end table - -@noindent -All other characters are ordinary. For example, @samp{[.*]} matches -@samp{.} and @samp{*}. - -@menu -* Character Class Operators:: [:class:] -* Range Operator:: start-end -@end menu - -@ignore -(If collating symbols and equivalence class expressions get implemented, -then add this.) - -node Collating Symbol Operators -subsubsection Collating Symbol Operators (@code{[.} @dots{} @code{.]}) - -If the syntax bit @code{XX} is set, then you can represent -collating symbols inside lists. You form a @dfn{collating symbol} by -putting a collating element between an @dfn{open-collating-symbol -operator} and an @dfn{close-collating-symbol operator}. @samp{[.} -represents the open-collating-symbol operator and @samp{.]} represents -the close-collating-symbol operator. For example, if @samp{ll} is a -collating element, then @samp{[[.ll.]]} would match @samp{ll}. - -node Equivalence Class Operators -subsubsection Equivalence Class Operators (@code{[=} @dots{} @code{=]}) -@cindex equivalence class expression in regex -@cindex @samp{[=} in regex -@cindex @samp{=]} in regex - -If the syntax bit @code{XX} is set, then Regex recognizes equivalence class -expressions inside lists. A @dfn{equivalence class expression} is a set -of collating elements which all belong to the same equivalence class. -You form an equivalence class expression by putting a collating -element between an @dfn{open-equivalence-class operator} and a -@dfn{close-equivalence-class operator}. @samp{[=} represents the -open-equivalence-class operator and @samp{=]} represents the -close-equivalence-class operator. For example, if @samp{a} and @samp{A} -were an equivalence class, then both @samp{[[=a=]]} and @samp{[[=A=]]} -would match both @samp{a} and @samp{A}. If the collating element in an -equivalence class expression isn't part of an equivalence class, then -the matcher considers the equivalence class expression to be a collating -symbol. - -@end ignore - -@node Character Class Operators, Range Operator, , List Operators -@subsection Character Class Operators (@code{[:} @dots{} @code{:]}) - -@cindex character classes -@cindex @samp{[:} in regex -@cindex @samp{:]} in regex - -If the syntax bit @code{RE_CHARACTER_CLASSES} is set, then Regex -recognizes character class expressions inside lists. A @dfn{character -class expression} matches one character from a given class. You form a -character class expression by putting a character class name between an -@dfn{open-character-class operator} (represented by @samp{[:}) and a -@dfn{close-character-class operator} (represented by @samp{:]}). The -character class names and their meanings are: - -@table @code - -@item alnum -letters and digits - -@item alpha -letters - -@item blank -system-dependent; for @sc{gnu}, a space or tab - -@item cntrl -control characters (in the @sc{ascii} encoding, code 0177 and codes -less than 040) - -@item digit -digits - -@item graph -same as @code{print} except omits space - -@item lower -lowercase letters - -@item print -printable characters (in the @sc{ascii} encoding, space -tilde---codes 040 through 0176) - -@item punct -neither control nor alphanumeric characters - -@item space -space, carriage return, newline, vertical tab, and form feed - -@item upper -uppercase letters - -@item xdigit -hexadecimal digits: @code{0}--@code{9}, @code{a}--@code{f}, @code{A}--@code{F} - -@end table - -@noindent -These correspond to the definitions in the C library's @file{} -facility. For example, @samp{[:alpha:]} corresponds to the standard -facility @code{isalpha}. Regex recognizes character class expressions -only inside of lists; so @samp{[[:alpha:]]} matches any letter, but -@samp{[:alpha:]} outside of a bracket expression and not followed by a -repetition operator matches just itself. - -@node Range Operator, , Character Class Operators, List Operators -@subsection The Range Operator (@code{-}) - -Regex recognizes @dfn{range expressions} inside a list. They represent -those characters -that fall between two elements in the current collating sequence. You -form a range expression by putting a @dfn{range operator} between two -@ignore -(If these get implemented, then substitute this for ``characters.'') -of any of the following: characters, collating elements, collating symbols, -and equivalence class expressions. The starting point of the range and -the ending point of the range don't have to be the same kind of item, -e.g., the starting point could be a collating element and the ending -point could be an equivalence class expression. If a range's ending -point is an equivalence class, then all the collating elements in that -class will be in the range. -@end ignore -characters.@footnote{You can't use a character class for the starting -or ending point of a range, since a character class is not a single -character.} @samp{-} represents the range operator. For example, -@samp{a-f} within a list represents all the characters from @samp{a} -through @samp{f} -inclusively. - -If the syntax bit @code{RE_NO_EMPTY_RANGES} is set, then if the range's -ending point collates less than its starting point, the range (and the -regular expression containing it) is invalid. For example, the regular -expression @samp{[z-a]} would be invalid. If this bit isn't set, then -Regex considers such a range to be empty. - -Since @samp{-} represents the range operator, if you want to make a -@samp{-} character itself -a list item, you must do one of the following: - -@itemize @bullet -@item -Put the @samp{-} either first or last in the list. - -@item -Include a range whose starting point collates strictly lower than -@samp{-} and whose ending point collates equal or higher. Unless a -range is the first item in a list, a @samp{-} can't be its starting -point, but @emph{can} be its ending point. That is because Regex -considers @samp{-} to be the range operator unless it is preceded by -another @samp{-}. For example, in the @sc{ascii} encoding, @samp{)}, -@samp{*}, @samp{+}, @samp{,}, @samp{-}, @samp{.}, and @samp{/} are -contiguous characters in the collating sequence. You might think that -@samp{[)-+--/]} has two ranges: @samp{)-+} and @samp{--/}. Rather, it -has the ranges @samp{)-+} and @samp{+--}, plus the character @samp{/}, so -it matches, e.g., @samp{,}, not @samp{.}. - -@item -Put a range whose starting point is @samp{-} first in the list. - -@end itemize - -For example, @samp{[-a-z]} matches a lowercase letter or a hyphen (in -English, in @sc{ascii}). - - -@node Grouping Operators, Back-reference Operator, List Operators, Common Operators -@section Grouping Operators (@code{(} @dots{} @code{)} or @code{\(} @dots{} @code{\)}) - -@kindex ( -@kindex ) -@kindex \( -@kindex \) -@cindex grouping -@cindex subexpressions -@cindex parenthesizing - -A @dfn{group}, also known as a @dfn{subexpression}, consists of an -@dfn{open-group operator}, any number of other operators, and a -@dfn{close-group operator}. Regex treats this sequence as a unit, just -as mathematics and programming languages treat a parenthesized -expression as a unit. - -Therefore, using @dfn{groups}, you can: - -@itemize @bullet -@item -delimit the argument(s) to an alternation operator (@pxref{Alternation -Operator}) or a repetition operator (@pxref{Repetition -Operators}). - -@item -keep track of the indices of the substring that matched a given group. -@xref{Using Registers}, for a precise explanation. -This lets you: - -@itemize @bullet -@item -use the back-reference operator (@pxref{Back-reference Operator}). - -@item -use registers (@pxref{Using Registers}). - -@end itemize - -@end itemize - -If the syntax bit @code{RE_NO_BK_PARENS} is set, then @samp{(} represents -the open-group operator and @samp{)} represents the -close-group operator; otherwise, @samp{\(} and @samp{\)} do. - -If the syntax bit @code{RE_UNMATCHED_RIGHT_PAREN_ORD} is set and a -close-group operator has no matching open-group operator, then Regex -considers it to match @samp{)}. - - -@node Back-reference Operator, Anchoring Operators, Grouping Operators, Common Operators -@section The Back-reference Operator (@dfn{\}@var{digit}) - -@cindex back references - -If the syntax bit @code{RE_NO_BK_REF} isn't set, then Regex recognizes -back references. A back reference matches a specified preceding group. -The back reference operator is represented by @samp{\@var{digit}} -anywhere after the end of a regular expression's @w{@var{digit}-th} -group (@pxref{Grouping Operators}). - -@var{digit} must be between @samp{1} and @samp{9}. The matcher assigns -numbers 1 through 9 to the first nine groups it encounters. By using -one of @samp{\1} through @samp{\9} after the corresponding group's -close-group operator, you can match a substring identical to the -one that the group does. - -Back references match according to the following (in all examples below, -@samp{(} represents the open-group, @samp{)} the close-group, @samp{@{} -the open-interval and @samp{@}} the close-interval operator): - -@itemize @bullet -@item -If the group matches a substring, the back reference matches an -identical substring. For example, @samp{(a)\1} matches @samp{aa} and -@samp{(bana)na\1bo\1} matches @samp{bananabanabobana}. Likewise, -@samp{(.*)\1} matches any (newline-free if the syntax bit -@code{RE_DOT_NEWLINE} isn't set) string that is composed of two -identical halves; the @samp{(.*)} matches the first half and the -@samp{\1} matches the second half. - -@item -If the group matches more than once (as it might if followed -by, e.g., a repetition operator), then the back reference matches the -substring the group @emph{last} matched. For example, -@samp{((a*)b)*\1\2} matches @samp{aabababa}; first @w{group 1} (the -outer one) matches @samp{aab} and @w{group 2} (the inner one) matches -@samp{aa}. Then @w{group 1} matches @samp{ab} and @w{group 2} matches -@samp{a}. So, @samp{\1} matches @samp{ab} and @samp{\2} matches -@samp{a}. - -@item -If the group doesn't participate in a match, i.e., it is part of an -alternative not taken or a repetition operator allows zero repetitions -of it, then the back reference makes the whole match fail. For example, -@samp{(one()|two())-and-(three\2|four\3)} matches @samp{one-and-three} -and @samp{two-and-four}, but not @samp{one-and-four} or -@samp{two-and-three}. For example, if the pattern matches -@samp{one-and-}, then its @w{group 2} matches the empty string and its -@w{group 3} doesn't participate in the match. So, if it then matches -@samp{four}, then when it tries to back reference @w{group 3}---which it -will attempt to do because @samp{\3} follows the @samp{four}---the match -will fail because @w{group 3} didn't participate in the match. - -@end itemize - -You can use a back reference as an argument to a repetition operator. For -example, @samp{(a(b))\2*} matches @samp{a} followed by two or more -@samp{b}s. Similarly, @samp{(a(b))\2@{3@}} matches @samp{abbbb}. - -If there is no preceding @w{@var{digit}-th} subexpression, the regular -expression is invalid. - - -@node Anchoring Operators, , Back-reference Operator, Common Operators -@section Anchoring Operators - -@cindex anchoring -@cindex regexp anchoring - -These operators can constrain a pattern to match only at the beginning or -end of the entire string or at the beginning or end of a line. - -@menu -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ -@end menu - - -@node Match-beginning-of-line Operator, Match-end-of-line Operator, , Anchoring Operators -@subsection The Match-beginning-of-line Operator (@code{^}) - -@kindex ^ -@cindex beginning-of-line operator -@cindex anchors - -This operator can match the empty string either at the beginning of the -string or after a newline character. Thus, it is said to @dfn{anchor} -the pattern to the beginning of a line. - -In the cases following, @samp{^} represents this operator. (Otherwise, -@samp{^} is ordinary.) - -@itemize @bullet - -@item -It (the @samp{^}) is first in the pattern, as in @samp{^foo}. - -@cnindex RE_CONTEXT_INDEP_ANCHORS @r{(and @samp{^})} -@item -The syntax bit @code{RE_CONTEXT_INDEP_ANCHORS} is set, and it is outside -a bracket expression. - -@cindex open-group operator and @samp{^} -@cindex alternation operator and @samp{^} -@item -It follows an open-group or alternation operator, as in @samp{a\(^b\)} -and @samp{a\|^b}. @xref{Grouping Operators}, and @ref{Alternation -Operator}. - -@end itemize - -These rules imply that some valid patterns containing @samp{^} cannot be -matched; for example, @samp{foo^bar} if @code{RE_CONTEXT_INDEP_ANCHORS} -is set. - -@vindex not_bol @r{field in pattern buffer} -If the @code{not_bol} field is set in the pattern buffer (@pxref{GNU -Pattern Buffers}), then @samp{^} fails to match at the beginning of the -string. @xref{POSIX Matching}, for when you might find this useful. - -@vindex newline_anchor @r{field in pattern buffer} -If the @code{newline_anchor} field is set in the pattern buffer, then -@samp{^} fails to match after a newline. This is useful when you do not -regard the string to be matched as broken into lines. - - -@node Match-end-of-line Operator, , Match-beginning-of-line Operator, Anchoring Operators -@subsection The Match-end-of-line Operator (@code{$}) - -@kindex $ -@cindex end-of-line operator -@cindex anchors - -This operator can match the empty string either at the end of -the string or before a newline character in the string. Thus, it is -said to @dfn{anchor} the pattern to the end of a line. - -It is always represented by @samp{$}. For example, @samp{foo$} usually -matches, e.g., @samp{foo} and, e.g., the first three characters of -@samp{foo\nbar}. - -Its interaction with the syntax bits and pattern buffer fields is -exactly the dual of @samp{^}'s; see the previous section. (That is, -``beginning'' becomes ``end'', ``next'' becomes ``previous'', and -``after'' becomes ``before''.) - - -@node GNU Operators, GNU Emacs Operators, Common Operators, Top -@chapter GNU Operators - -Following are operators that @sc{gnu} defines (and @sc{posix} doesn't). - -@menu -* Word Operators:: -* Buffer Operators:: -@end menu - -@node Word Operators, Buffer Operators, , GNU Operators -@section Word Operators - -The operators in this section require Regex to recognize parts of words. -Regex uses a syntax table to determine whether or not a character is -part of a word, i.e., whether or not it is @dfn{word-constituent}. - -@menu -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W -@end menu - -@node Non-Emacs Syntax Tables, Match-word-boundary Operator, , Word Operators -@subsection Non-Emacs Syntax Tables - -A @dfn{syntax table} is an array indexed by the characters in your -character set. In the @sc{ascii} encoding, therefore, a syntax table -has 256 elements. Regex always uses a @code{char *} variable -@code{re_syntax_table} as its syntax table. In some cases, it -initializes this variable and in others it expects you to initialize it. - -@itemize @bullet -@item -If Regex is compiled with the preprocessor symbols @code{emacs} and -@code{SYNTAX_TABLE} both undefined, then Regex allocates -@code{re_syntax_table} and initializes an element @var{i} either to -@code{Sword} (which it defines) if @var{i} is a letter, number, or -@samp{_}, or to zero if it's not. - -@item -If Regex is compiled with @code{emacs} undefined but @code{SYNTAX_TABLE} -defined, then Regex expects you to define a @code{char *} variable -@code{re_syntax_table} to be a valid syntax table. - -@item -@xref{Emacs Syntax Tables}, for what happens when Regex is compiled with -the preprocessor symbol @code{emacs} defined. - -@end itemize - -@node Match-word-boundary Operator, Match-within-word Operator, Non-Emacs Syntax Tables, Word Operators -@subsection The Match-word-boundary Operator (@code{\b}) - -@cindex @samp{\b} -@cindex word boundaries, matching - -This operator (represented by @samp{\b}) matches the empty string at -either the beginning or the end of a word. For example, @samp{\brat\b} -matches the separate word @samp{rat}. - -@node Match-within-word Operator, Match-beginning-of-word Operator, Match-word-boundary Operator, Word Operators -@subsection The Match-within-word Operator (@code{\B}) - -@cindex @samp{\B} - -This operator (represented by @samp{\B}) matches the empty string within -a word. For example, @samp{c\Brat\Be} matches @samp{crate}, but -@samp{dirty \Brat} doesn't match @samp{dirty rat}. - -@node Match-beginning-of-word Operator, Match-end-of-word Operator, Match-within-word Operator, Word Operators -@subsection The Match-beginning-of-word Operator (@code{\<}) - -@cindex @samp{\<} - -This operator (represented by @samp{\<}) matches the empty string at the -beginning of a word. - -@node Match-end-of-word Operator, Match-word-constituent Operator, Match-beginning-of-word Operator, Word Operators -@subsection The Match-end-of-word Operator (@code{\>}) - -@cindex @samp{\>} - -This operator (represented by @samp{\>}) matches the empty string at the -end of a word. - -@node Match-word-constituent Operator, Match-non-word-constituent Operator, Match-end-of-word Operator, Word Operators -@subsection The Match-word-constituent Operator (@code{\w}) - -@cindex @samp{\w} - -This operator (represented by @samp{\w}) matches any word-constituent -character. - -@node Match-non-word-constituent Operator, , Match-word-constituent Operator, Word Operators -@subsection The Match-non-word-constituent Operator (@code{\W}) - -@cindex @samp{\W} - -This operator (represented by @samp{\W}) matches any character that is -not word-constituent. - - -@node Buffer Operators, , Word Operators, GNU Operators -@section Buffer Operators - -Following are operators which work on buffers. In Emacs, a @dfn{buffer} -is, naturally, an Emacs buffer. For other programs, Regex considers the -entire string to be matched as the buffer. - -@menu -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' -@end menu - - -@node Match-beginning-of-buffer Operator, Match-end-of-buffer Operator, , Buffer Operators -@subsection The Match-beginning-of-buffer Operator (@code{\`}) - -@cindex @samp{\`} - -This operator (represented by @samp{\`}) matches the empty string at the -beginning of the buffer. - -@node Match-end-of-buffer Operator, , Match-beginning-of-buffer Operator, Buffer Operators -@subsection The Match-end-of-buffer Operator (@code{\'}) - -@cindex @samp{\'} - -This operator (represented by @samp{\'}) matches the empty string at the -end of the buffer. - - -@node GNU Emacs Operators, What Gets Matched?, GNU Operators, Top -@chapter GNU Emacs Operators - -Following are operators that @sc{gnu} defines (and @sc{posix} doesn't) -that you can use only when Regex is compiled with the preprocessor -symbol @code{emacs} defined. - -@menu -* Syntactic Class Operators:: -@end menu - - -@node Syntactic Class Operators, , , GNU Emacs Operators -@section Syntactic Class Operators - -The operators in this section require Regex to recognize the syntactic -classes of characters. Regex uses a syntax table to determine this. - -@menu -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS -@end menu - -@node Emacs Syntax Tables, Match-syntactic-class Operator, , Syntactic Class Operators -@subsection Emacs Syntax Tables - -A @dfn{syntax table} is an array indexed by the characters in your -character set. In the @sc{ascii} encoding, therefore, a syntax table -has 256 elements. - -If Regex is compiled with the preprocessor symbol @code{emacs} defined, -then Regex expects you to define and initialize the variable -@code{re_syntax_table} to be an Emacs syntax table. Emacs' syntax -tables are more complicated than Regex's own (@pxref{Non-Emacs Syntax -Tables}). @xref{Syntax, , Syntax, emacs, The GNU Emacs User's Manual}, -for a description of Emacs' syntax tables. - -@node Match-syntactic-class Operator, Match-not-syntactic-class Operator, Emacs Syntax Tables, Syntactic Class Operators -@subsection The Match-syntactic-class Operator (@code{\s}@var{class}) - -@cindex @samp{\s} - -This operator matches any character whose syntactic class is represented -by a specified character. @samp{\s@var{class}} represents this operator -where @var{class} is the character representing the syntactic class you -want. For example, @samp{w} represents the syntactic -class of word-constituent characters, so @samp{\sw} matches any -word-constituent character. - -@node Match-not-syntactic-class Operator, , Match-syntactic-class Operator, Syntactic Class Operators -@subsection The Match-not-syntactic-class Operator (@code{\S}@var{class}) - -@cindex @samp{\S} - -This operator is similar to the match-syntactic-class operator except -that it matches any character whose syntactic class is @emph{not} -represented by the specified character. @samp{\S@var{class}} represents -this operator. For example, @samp{w} represents the syntactic class of -word-constituent characters, so @samp{\Sw} matches any character that is -not word-constituent. - - -@node What Gets Matched?, Programming with Regex, GNU Emacs Operators, Top -@chapter What Gets Matched? - -Regex usually matches strings according to the ``leftmost longest'' -rule; that is, it chooses the longest of the leftmost matches. This -does not mean that for a regular expression containing subexpressions -that it simply chooses the longest match for each subexpression, left to -right; the overall match must also be the longest possible one. - -For example, @samp{(ac*)(c*d[ac]*)\1} matches @samp{acdacaaa}, not -@samp{acdac}, as it would if it were to choose the longest match for the -first subexpression. - - -@node Programming with Regex, Copying, What Gets Matched?, Top -@chapter Programming with Regex - -Here we describe how you use the Regex data structures and functions in -C programs. Regex has three interfaces: one designed for @sc{gnu}, one -compatible with @sc{posix} and one compatible with Berkeley @sc{unix}. - -@menu -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: -@end menu - - -@node GNU Regex Functions, POSIX Regex Functions, , Programming with Regex -@section GNU Regex Functions - -If you're writing code that doesn't need to be compatible with either -@sc{posix} or Berkeley @sc{unix}, you can use these functions. They -provide more options than the other interfaces. - -@menu -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () -@end menu - - -@node GNU Pattern Buffers, GNU Regular Expression Compiling, , GNU Regex Functions -@subsection GNU Pattern Buffers - -@cindex pattern buffer, definition of -@tindex re_pattern_buffer @r{definition} -@tindex struct re_pattern_buffer @r{definition} - -To compile, match, or search for a given regular expression, you must -supply a pattern buffer. A @dfn{pattern buffer} holds one compiled -regular expression.@footnote{Regular expressions are also referred to as -``patterns,'' hence the name ``pattern buffer.''} - -You can have several different pattern buffers simultaneously, each -holding a compiled pattern for a different regular expression. - -@file{regex.h} defines the pattern buffer @code{struct} as follows: - -@example -[[[ pattern_buffer ]]] -@end example - - -@node GNU Regular Expression Compiling, GNU Matching, GNU Pattern Buffers, GNU Regex Functions -@subsection GNU Regular Expression Compiling - -In @sc{gnu}, you can both match and search for a given regular -expression. To do either, you must first compile it in a pattern buffer -(@pxref{GNU Pattern Buffers}). - -@cindex syntax initialization -@vindex re_syntax_options @r{initialization} -Regular expressions match according to the syntax with which they were -compiled; with @sc{gnu}, you indicate what syntax you want by setting -the variable @code{re_syntax_options} (declared in @file{regex.h} and -defined in @file{regex.c}) before calling the compiling function, -@code{re_compile_pattern} (see below). @xref{Syntax Bits}, and -@ref{Predefined Syntaxes}. - -You can change the value of @code{re_syntax_options} at any time. -Usually, however, you set its value once and then never change it. - -@cindex pattern buffer initialization -@code{re_compile_pattern} takes a pattern buffer as an argument. You -must initialize the following fields: - -@table @code - -@item translate @r{initialization} - -@item translate -@vindex translate @r{initialization} -Initialize this to point to a translate table if you want one, or to -zero if you don't. We explain translate tables in @ref{GNU Translate -Tables}. - -@item fastmap -@vindex fastmap @r{initialization} -Initialize this to nonzero if you want a fastmap, or to zero if you -don't. - -@item buffer -@itemx allocated -@vindex buffer @r{initialization} -@vindex allocated @r{initialization} -@findex malloc -If you want @code{re_compile_pattern} to allocate memory for the -compiled pattern, set both of these to zero. If you have an existing -block of memory (allocated with @code{malloc}) you want Regex to use, -set @code{buffer} to its address and @code{allocated} to its size (in -bytes). - -@code{re_compile_pattern} uses @code{realloc} to extend the space for -the compiled pattern as necessary. - -@end table - -To compile a pattern buffer, use: - -@findex re_compile_pattern -@example -char * -re_compile_pattern (const char *@var{regex}, const int @var{regex_size}, - struct re_pattern_buffer *@var{pattern_buffer}) -@end example - -@noindent -@var{regex} is the regular expression's address, @var{regex_size} is its -length, and @var{pattern_buffer} is the pattern buffer's address. - -If @code{re_compile_pattern} successfully compiles the regular -expression, it returns zero and sets @code{*@var{pattern_buffer}} to the -compiled pattern. It sets the pattern buffer's fields as follows: - -@table @code -@item buffer -@vindex buffer @r{field, set by @code{re_compile_pattern}} -to the compiled pattern. - -@item used -@vindex used @r{field, set by @code{re_compile_pattern}} -to the number of bytes the compiled pattern in @code{buffer} occupies. - -@item syntax -@vindex syntax @r{field, set by @code{re_compile_pattern}} -to the current value of @code{re_syntax_options}. - -@item re_nsub -@vindex re_nsub @r{field, set by @code{re_compile_pattern}} -to the number of subexpressions in @var{regex}. - -@item fastmap_accurate -@vindex fastmap_accurate @r{field, set by @code{re_compile_pattern}} -to zero on the theory that the pattern you're compiling is different -than the one previously compiled into @code{buffer}; in that case (since -you can't make a fastmap without a compiled pattern), -@code{fastmap} would either contain an incompatible fastmap, or nothing -at all. - -@c xx what else? -@end table - -If @code{re_compile_pattern} can't compile @var{regex}, it returns an -error string corresponding to one of the errors listed in @ref{POSIX -Regular Expression Compiling}. - - -@node GNU Matching, GNU Searching, GNU Regular Expression Compiling, GNU Regex Functions -@subsection GNU Matching - -@cindex matching with GNU functions - -Matching the @sc{gnu} way means trying to match as much of a string as -possible starting at a position within it you specify. Once you've compiled -a pattern into a pattern buffer (@pxref{GNU Regular Expression -Compiling}), you can ask the matcher to match that pattern against a -string using: - -@findex re_match -@example -int -re_match (struct re_pattern_buffer *@var{pattern_buffer}, - const char *@var{string}, const int @var{size}, - const int @var{start}, struct re_registers *@var{regs}) -@end example - -@noindent -@var{pattern_buffer} is the address of a pattern buffer containing a -compiled pattern. @var{string} is the string you want to match; it can -contain newline and null characters. @var{size} is the length of that -string. @var{start} is the string index at which you want to -begin matching; the first character of @var{string} is at index zero. -@xref{Using Registers}, for a explanation of @var{regs}; you can safely -pass zero. - -@code{re_match} matches the regular expression in @var{pattern_buffer} -against the string @var{string} according to the syntax in -@var{pattern_buffers}'s @code{syntax} field. (@xref{GNU Regular -Expression Compiling}, for how to set it.) The function returns -@math{-1} if the compiled pattern does not match any part of -@var{string} and @math{-2} if an internal error happens; otherwise, it -returns how many (possibly zero) characters of @var{string} the pattern -matched. - -An example: suppose @var{pattern_buffer} points to a pattern buffer -containing the compiled pattern for @samp{a*}, and @var{string} points -to @samp{aaaaab} (whereupon @var{size} should be 6). Then if @var{start} -is 2, @code{re_match} returns 3, i.e., @samp{a*} would have matched the -last three @samp{a}s in @var{string}. If @var{start} is 0, -@code{re_match} returns 5, i.e., @samp{a*} would have matched all the -@samp{a}s in @var{string}. If @var{start} is either 5 or 6, it returns -zero. - -If @var{start} is not between zero and @var{size}, then -@code{re_match} returns @math{-1}. - - -@node GNU Searching, Matching/Searching with Split Data, GNU Matching, GNU Regex Functions -@subsection GNU Searching - -@cindex searching with GNU functions - -@dfn{Searching} means trying to match starting at successive positions -within a string. The function @code{re_search} does this. - -Before calling @code{re_search}, you must compile your regular -expression. @xref{GNU Regular Expression Compiling}. - -Here is the function declaration: - -@findex re_search -@example -int -re_search (struct re_pattern_buffer *@var{pattern_buffer}, - const char *@var{string}, const int @var{size}, - const int @var{start}, const int @var{range}, - struct re_registers *@var{regs}) -@end example - -@noindent -@vindex start @r{argument to @code{re_search}} -@vindex range @r{argument to @code{re_search}} -whose arguments are the same as those to @code{re_match} (@pxref{GNU -Matching}) except that the two arguments @var{start} and @var{range} -replace @code{re_match}'s argument @var{start}. - -If @var{range} is positive, then @code{re_search} attempts a match -starting first at index @var{start}, then at @math{@var{start} + 1} if -that fails, and so on, up to @math{@var{start} + @var{range}}; if -@var{range} is negative, then it attempts a match starting first at -index @var{start}, then at @math{@var{start} -1} if that fails, and so -on. - -If @var{start} is not between zero and @var{size}, then @code{re_search} -returns @math{-1}. When @var{range} is positive, @code{re_search} -adjusts @var{range} so that @math{@var{start} + @var{range} - 1} is -between zero and @var{size}, if necessary; that way it won't search -outside of @var{string}. Similarly, when @var{range} is negative, -@code{re_search} adjusts @var{range} so that @math{@var{start} + -@var{range} + 1} is between zero and @var{size}, if necessary. - -If the @code{fastmap} field of @var{pattern_buffer} is zero, -@code{re_search} matches starting at consecutive positions; otherwise, -it uses @code{fastmap} to make the search more efficient. -@xref{Searching with Fastmaps}. - -If no match is found, @code{re_search} returns @math{-1}. If -a match is found, it returns the index where the match began. If an -internal error happens, it returns @math{-2}. - - -@node Matching/Searching with Split Data, Searching with Fastmaps, GNU Searching, GNU Regex Functions -@subsection Matching and Searching with Split Data - -Using the functions @code{re_match_2} and @code{re_search_2}, you can -match or search in data that is divided into two strings. - -The function: - -@findex re_match_2 -@example -int -re_match_2 (struct re_pattern_buffer *@var{buffer}, - const char *@var{string1}, const int @var{size1}, - const char *@var{string2}, const int @var{size2}, - const int @var{start}, - struct re_registers *@var{regs}, - const int @var{stop}) -@end example - -@noindent -is similar to @code{re_match} (@pxref{GNU Matching}) except that you -pass @emph{two} data strings and sizes, and an index @var{stop} beyond -which you don't want the matcher to try matching. As with -@code{re_match}, if it succeeds, @code{re_match_2} returns how many -characters of @var{string} it matched. Regard @var{string1} and -@var{string2} as concatenated when you set the arguments @var{start} and -@var{stop} and use the contents of @var{regs}; @code{re_match_2} never -returns a value larger than @math{@var{size1} + @var{size2}}. - -The function: - -@findex re_search_2 -@example -int -re_search_2 (struct re_pattern_buffer *@var{buffer}, - const char *@var{string1}, const int @var{size1}, - const char *@var{string2}, const int @var{size2}, - const int @var{start}, const int @var{range}, - struct re_registers *@var{regs}, - const int @var{stop}) -@end example - -@noindent -is similarly related to @code{re_search}. - - -@node Searching with Fastmaps, GNU Translate Tables, Matching/Searching with Split Data, GNU Regex Functions -@subsection Searching with Fastmaps - -@cindex fastmaps -If you're searching through a long string, you should use a fastmap. -Without one, the searcher tries to match at consecutive positions in the -string. Generally, most of the characters in the string could not start -a match. It takes much longer to try matching at a given position in the -string than it does to check in a table whether or not the character at -that position could start a match. A @dfn{fastmap} is such a table. - -More specifically, a fastmap is an array indexed by the characters in -your character set. Under the @sc{ascii} encoding, therefore, a fastmap -has 256 elements. If you want the searcher to use a fastmap with a -given pattern buffer, you must allocate the array and assign the array's -address to the pattern buffer's @code{fastmap} field. You either can -compile the fastmap yourself or have @code{re_search} do it for you; -when @code{fastmap} is nonzero, it automatically compiles a fastmap the -first time you search using a particular compiled pattern. - -To compile a fastmap yourself, use: - -@findex re_compile_fastmap -@example -int -re_compile_fastmap (struct re_pattern_buffer *@var{pattern_buffer}) -@end example - -@noindent -@var{pattern_buffer} is the address of a pattern buffer. If the -character @var{c} could start a match for the pattern, -@code{re_compile_fastmap} makes -@code{@var{pattern_buffer}->fastmap[@var{c}]} nonzero. It returns -@math{0} if it can compile a fastmap and @math{-2} if there is an -internal error. For example, if @samp{|} is the alternation operator -and @var{pattern_buffer} holds the compiled pattern for @samp{a|b}, then -@code{re_compile_fastmap} sets @code{fastmap['a']} and -@code{fastmap['b']} (and no others). - -@code{re_search} uses a fastmap as it moves along in the string: it -checks the string's characters until it finds one that's in the fastmap. -Then it tries matching at that character. If the match fails, it -repeats the process. So, by using a fastmap, @code{re_search} doesn't -waste time trying to match at positions in the string that couldn't -start a match. - -If you don't want @code{re_search} to use a fastmap, -store zero in the @code{fastmap} field of the pattern buffer before -calling @code{re_search}. - -Once you've initialized a pattern buffer's @code{fastmap} field, you -need never do so again---even if you compile a new pattern in -it---provided the way the field is set still reflects whether or not you -want a fastmap. @code{re_search} will still either do nothing if -@code{fastmap} is null or, if it isn't, compile a new fastmap for the -new pattern. - -@node GNU Translate Tables, Using Registers, Searching with Fastmaps, GNU Regex Functions -@subsection GNU Translate Tables - -If you set the @code{translate} field of a pattern buffer to a translate -table, then the @sc{gnu} Regex functions to which you've passed that -pattern buffer use it to apply a simple transformation -to all the regular expression and string characters at which they look. - -A @dfn{translate table} is an array indexed by the characters in your -character set. Under the @sc{ascii} encoding, therefore, a translate -table has 256 elements. The array's elements are also characters in -your character set. When the Regex functions see a character @var{c}, -they use @code{translate[@var{c}]} in its place, with one exception: the -character after a @samp{\} is not translated. (This ensures that, the -operators, e.g., @samp{\B} and @samp{\b}, are always distinguishable.) - -For example, a table that maps all lowercase letters to the -corresponding uppercase ones would cause the matcher to ignore -differences in case.@footnote{A table that maps all uppercase letters to -the corresponding lowercase ones would work just as well for this -purpose.} Such a table would map all characters except lowercase letters -to themselves, and lowercase letters to the corresponding uppercase -ones. Under the @sc{ascii} encoding, here's how you could initialize -such a table (we'll call it @code{case_fold}): - -@example -for (i = 0; i < 256; i++) - case_fold[i] = i; -for (i = 'a'; i <= 'z'; i++) - case_fold[i] = i - ('a' - 'A'); -@end example - -You tell Regex to use a translate table on a given pattern buffer by -assigning that table's address to the @code{translate} field of that -buffer. If you don't want Regex to do any translation, put zero into -this field. You'll get weird results if you change the table's contents -anytime between compiling the pattern buffer, compiling its fastmap, and -matching or searching with the pattern buffer. - -@node Using Registers, Freeing GNU Pattern Buffers, GNU Translate Tables, GNU Regex Functions -@subsection Using Registers - -A group in a regular expression can match a (posssibly empty) substring -of the string that regular expression as a whole matched. The matcher -remembers the beginning and end of the substring matched by -each group. - -To find out what they matched, pass a nonzero @var{regs} argument to a -@sc{gnu} matching or searching function (@pxref{GNU Matching} and -@ref{GNU Searching}), i.e., the address of a structure of this type, as -defined in @file{regex.h}: - -@c We don't bother to include this directly from regex.h, -@c since it changes so rarely. -@example -@tindex re_registers -@vindex num_regs @r{in @code{struct re_registers}} -@vindex start @r{in @code{struct re_registers}} -@vindex end @r{in @code{struct re_registers}} -struct re_registers -@{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -@}; -@end example - -Except for (possibly) the @var{num_regs}'th element (see below), the -@var{i}th element of the @code{start} and @code{end} arrays records -information about the @var{i}th group in the pattern. (They're declared -as C pointers, but this is only because not all C compilers accept -zero-length arrays; conceptually, it is simplest to think of them as -arrays.) - -The @code{start} and @code{end} arrays are allocated in various ways, -depending on the value of the @code{regs_allocated} -@vindex regs_allocated -field in the pattern buffer passed to the matcher. - -The simplest and perhaps most useful is to let the matcher (re)allocate -enough space to record information for all the groups in the regular -expression. If @code{regs_allocated} is @code{REGS_UNALLOCATED}, -@vindex REGS_UNALLOCATED -the matcher allocates @math{1 + @var{re_nsub}} (another field in the -pattern buffer; @pxref{GNU Pattern Buffers}). The extra element is set -to @math{-1}, and sets @code{regs_allocated} to @code{REGS_REALLOCATE}. -@vindex REGS_REALLOCATE -Then on subsequent calls with the same pattern buffer and @var{regs} -arguments, the matcher reallocates more space if necessary. - -It would perhaps be more logical to make the @code{regs_allocated} field -part of the @code{re_registers} structure, instead of part of the -pattern buffer. But in that case the caller would be forced to -initialize the structure before passing it. Much existing code doesn't -do this initialization, and it's arguably better to avoid it anyway. - -@code{re_compile_pattern} sets @code{regs_allocated} to -@code{REGS_UNALLOCATED}, -so if you use the GNU regular expression -functions, you get this behavior by default. - -xx document re_set_registers - -@sc{posix}, on the other hand, requires a different interface: the -caller is supposed to pass in a fixed-length array which the matcher -fills. Therefore, if @code{regs_allocated} is @code{REGS_FIXED} -@vindex REGS_FIXED -the matcher simply fills that array. - -The following examples illustrate the information recorded in the -@code{re_registers} structure. (In all of them, @samp{(} represents the -open-group and @samp{)} the close-group operator. The first character -in the string @var{string} is at index 0.) - -@c xx i'm not sure this is all true anymore. - -@itemize @bullet - -@item -If the regular expression has an @w{@var{i}-th} -group not contained within another group that matches a -substring of @var{string}, then the function sets -@code{@w{@var{regs}->}start[@var{i}]} to the index in @var{string} where -the substring matched by the @w{@var{i}-th} group begins, and -@code{@w{@var{regs}->}end[@var{i}]} to the index just beyond that -substring's end. The function sets @code{@w{@var{regs}->}start[0]} and -@code{@w{@var{regs}->}end[0]} to analogous information about the entire -pattern. - -For example, when you match @samp{((a)(b))} against @samp{ab}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 2 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 2 in @code{@w{@var{regs}->}end[1]} - -@item -0 in @code{@w{@var{regs}->}start[2]} and 1 in @code{@w{@var{regs}->}end[2]} - -@item -1 in @code{@w{@var{regs}->}start[3]} and 2 in @code{@w{@var{regs}->}end[3]} -@end itemize - -@item -If a group matches more than once (as it might if followed by, -e.g., a repetition operator), then the function reports the information -about what the group @emph{last} matched. - -For example, when you match the pattern @samp{(a)*} against the string -@samp{aa}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 2 in @code{@w{@var{regs}->}end[0]} - -@item -1 in @code{@w{@var{regs}->}start[1]} and 2 in @code{@w{@var{regs}->}end[1]} -@end itemize - -@item -If the @w{@var{i}-th} group does not participate in a -successful match, e.g., it is an alternative not taken or a -repetition operator allows zero repetitions of it, then the function -sets @code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to @math{-1}. - -For example, when you match the pattern @samp{(a)*b} against -the string @samp{b}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[1]} and @math{-1} in @code{@w{@var{regs}->}end[1]} -@end itemize - -@item -If the @w{@var{i}-th} group matches a zero-length string, then the -function sets @code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to the index just beyond that -zero-length string. - -For example, when you match the pattern @samp{(a*)b} against the string -@samp{b}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 0 in @code{@w{@var{regs}->}end[1]} -@end itemize - -@ignore -The function sets @code{@w{@var{regs}->}start[0]} and -@code{@w{@var{regs}->}end[0]} to analogous information about the entire -pattern. - -For example, when you match the pattern @samp{(a*)} against the empty -string, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 0 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 0 in @code{@w{@var{regs}->}end[1]} -@end itemize -@end ignore - -@item -If an @w{@var{i}-th} group contains a @w{@var{j}-th} group -in turn not contained within any other group within group @var{i} and -the function reports a match of the @w{@var{i}-th} group, then it -records in @code{@w{@var{regs}->}start[@var{j}]} and -@code{@w{@var{regs}->}end[@var{j}]} the last match (if it matched) of -the @w{@var{j}-th} group. - -For example, when you match the pattern @samp{((a*)b)*} against the -string @samp{abb}, @w{group 2} last matches the empty string, so you -get what it previously matched: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 3 in @code{@w{@var{regs}->}end[0]} - -@item -2 in @code{@w{@var{regs}->}start[1]} and 3 in @code{@w{@var{regs}->}end[1]} - -@item -2 in @code{@w{@var{regs}->}start[2]} and 2 in @code{@w{@var{regs}->}end[2]} -@end itemize - -When you match the pattern @samp{((a)*b)*} against the string -@samp{abb}, @w{group 2} doesn't participate in the last match, so you -get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 3 in @code{@w{@var{regs}->}end[0]} - -@item -2 in @code{@w{@var{regs}->}start[1]} and 3 in @code{@w{@var{regs}->}end[1]} - -@item -0 in @code{@w{@var{regs}->}start[2]} and 1 in @code{@w{@var{regs}->}end[2]} -@end itemize - -@item -If an @w{@var{i}-th} group contains a @w{@var{j}-th} group -in turn not contained within any other group within group @var{i} -and the function sets -@code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to @math{-1}, then it also sets -@code{@w{@var{regs}->}start[@var{j}]} and -@code{@w{@var{regs}->}end[@var{j}]} to @math{-1}. - -For example, when you match the pattern @samp{((a)*b)*c} against the -string @samp{c}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[1]} and @math{-1} in @code{@w{@var{regs}->}end[1]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[2]} and @math{-1} in @code{@w{@var{regs}->}end[2]} -@end itemize - -@end itemize - -@node Freeing GNU Pattern Buffers, , Using Registers, GNU Regex Functions -@subsection Freeing GNU Pattern Buffers - -To free any allocated fields of a pattern buffer, you can use the -@sc{posix} function described in @ref{Freeing POSIX Pattern Buffers}, -since the type @code{regex_t}---the type for @sc{posix} pattern -buffers---is equivalent to the type @code{re_pattern_buffer}. After -freeing a pattern buffer, you need to again compile a regular expression -in it (@pxref{GNU Regular Expression Compiling}) before passing it to -a matching or searching function. - - -@node POSIX Regex Functions, BSD Regex Functions, GNU Regex Functions, Programming with Regex -@section POSIX Regex Functions - -If you're writing code that has to be @sc{posix} compatible, you'll need -to use these functions. Their interfaces are as specified by @sc{posix}, -draft 1003.2/D11.2. - -@menu -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () -@end menu - - -@node POSIX Pattern Buffers, POSIX Regular Expression Compiling, , POSIX Regex Functions -@subsection POSIX Pattern Buffers - -To compile or match a given regular expression the @sc{posix} way, you -must supply a pattern buffer exactly the way you do for @sc{gnu} -(@pxref{GNU Pattern Buffers}). @sc{posix} pattern buffers have type -@code{regex_t}, which is equivalent to the @sc{gnu} pattern buffer -type @code{re_pattern_buffer}. - - -@node POSIX Regular Expression Compiling, POSIX Matching, POSIX Pattern Buffers, POSIX Regex Functions -@subsection POSIX Regular Expression Compiling - -With @sc{posix}, you can only search for a given regular expression; you -can't match it. To do this, you must first compile it in a -pattern buffer, using @code{regcomp}. - -@ignore -Before calling @code{regcomp}, you must initialize this pattern buffer -as you do for @sc{gnu} (@pxref{GNU Regular Expression Compiling}). See -below, however, for how to choose a syntax with which to compile. -@end ignore - -To compile a pattern buffer, use: - -@findex regcomp -@example -int -regcomp (regex_t *@var{preg}, const char *@var{regex}, int @var{cflags}) -@end example - -@noindent -@var{preg} is the initialized pattern buffer's address, @var{regex} is -the regular expression's address, and @var{cflags} is the compilation -flags, which Regex considers as a collection of bits. Here are the -valid bits, as defined in @file{regex.h}: - -@table @code - -@item REG_EXTENDED -@vindex REG_EXTENDED -says to use @sc{posix} Extended Regular Expression syntax; if this isn't -set, then says to use @sc{posix} Basic Regular Expression syntax. -@code{regcomp} sets @var{preg}'s @code{syntax} field accordingly. - -@item REG_ICASE -@vindex REG_ICASE -@cindex ignoring case -says to ignore case; @code{regcomp} sets @var{preg}'s @code{translate} -field to a translate table which ignores case, replacing anything you've -put there before. - -@item REG_NOSUB -@vindex REG_NOSUB -says to set @var{preg}'s @code{no_sub} field; @pxref{POSIX Matching}, -for what this means. - -@item REG_NEWLINE -@vindex REG_NEWLINE -says that a: - -@itemize @bullet - -@item -match-any-character operator (@pxref{Match-any-character -Operator}) doesn't match a newline. - -@item -nonmatching list not containing a newline (@pxref{List -Operators}) matches a newline. - -@item -match-beginning-of-line operator (@pxref{Match-beginning-of-line -Operator}) matches the empty string immediately after a newline, -regardless of how @code{REG_NOTBOL} is set (@pxref{POSIX Matching}, for -an explanation of @code{REG_NOTBOL}). - -@item -match-end-of-line operator (@pxref{Match-beginning-of-line -Operator}) matches the empty string immediately before a newline, -regardless of how @code{REG_NOTEOL} is set (@pxref{POSIX Matching}, -for an explanation of @code{REG_NOTEOL}). - -@end itemize - -@end table - -If @code{regcomp} successfully compiles the regular expression, it -returns zero and sets @code{*@var{pattern_buffer}} to the compiled -pattern. Except for @code{syntax} (which it sets as explained above), it -also sets the same fields the same way as does the @sc{gnu} compiling -function (@pxref{GNU Regular Expression Compiling}). - -If @code{regcomp} can't compile the regular expression, it returns one -of the error codes listed here. (Except when noted differently, the -syntax of in all examples below is basic regular expression syntax.) - -@table @code - -@comment repetitions -@item REG_BADRPT -For example, the consecutive repetition operators @samp{**} in -@samp{a**} are invalid. As another example, if the syntax is extended -regular expression syntax, then the repetition operator @samp{*} with -nothing on which to operate in @samp{*} is invalid. - -@item REG_BADBR -For example, the @var{count} @samp{-1} in @samp{a\@{-1} is invalid. - -@item REG_EBRACE -For example, @samp{a\@{1} is missing a close-interval operator. - -@comment lists -@item REG_EBRACK -For example, @samp{[a} is missing a close-list operator. - -@item REG_ERANGE -For example, the range ending point @samp{z} that collates lower than -does its starting point @samp{a} in @samp{[z-a]} is invalid. Also, the -range with the character class @samp{[:alpha:]} as its starting point in -@samp{[[:alpha:]-|]}. - -@item REG_ECTYPE -For example, the character class name @samp{foo} in @samp{[[:foo:]} is -invalid. - -@comment groups -@item REG_EPAREN -For example, @samp{a\)} is missing an open-group operator and @samp{\(a} -is missing a close-group operator. - -@item REG_ESUBREG -For example, the back reference @samp{\2} that refers to a nonexistent -subexpression in @samp{\(a\)\2} is invalid. - -@comment unfinished business - -@item REG_EEND -Returned when a regular expression causes no other more specific error. - -@item REG_EESCAPE -For example, the trailing backslash @samp{\} in @samp{a\} is invalid, as is the -one in @samp{\}. - -@comment kitchen sink -@item REG_BADPAT -For example, in the extended regular expression syntax, the empty group -@samp{()} in @samp{a()b} is invalid. - -@comment internal -@item REG_ESIZE -Returned when a regular expression needs a pattern buffer larger than -65536 bytes. - -@item REG_ESPACE -Returned when a regular expression makes Regex to run out of memory. - -@end table - - -@node POSIX Matching, Reporting Errors, POSIX Regular Expression Compiling, POSIX Regex Functions -@subsection POSIX Matching - -Matching the @sc{posix} way means trying to match a null-terminated -string starting at its first character. Once you've compiled a pattern -into a pattern buffer (@pxref{POSIX Regular Expression Compiling}), you -can ask the matcher to match that pattern against a string using: - -@findex regexec -@example -int -regexec (const regex_t *@var{preg}, const char *@var{string}, - size_t @var{nmatch}, regmatch_t @var{pmatch}[], int @var{eflags}) -@end example - -@noindent -@var{preg} is the address of a pattern buffer for a compiled pattern. -@var{string} is the string you want to match. - -@xref{Using Byte Offsets}, for an explanation of @var{pmatch}. If you -pass zero for @var{nmatch} or you compiled @var{preg} with the -compilation flag @code{REG_NOSUB} set, then @code{regexec} will ignore -@var{pmatch}; otherwise, you must allocate it to have at least -@var{nmatch} elements. @code{regexec} will record @var{nmatch} byte -offsets in @var{pmatch}, and set to @math{-1} any unused elements up to -@math{@var{pmatch}@code{[@var{nmatch}]} - 1}. - -@var{eflags} specifies @dfn{execution flags}---namely, the two bits -@code{REG_NOTBOL} and @code{REG_NOTEOL} (defined in @file{regex.h}). If -you set @code{REG_NOTBOL}, then the match-beginning-of-line operator -(@pxref{Match-beginning-of-line Operator}) always fails to match. -This lets you match against pieces of a line, as you would need to if, -say, searching for repeated instances of a given pattern in a line; it -would work correctly for patterns both with and without -match-beginning-of-line operators. @code{REG_NOTEOL} works analogously -for the match-end-of-line operator (@pxref{Match-end-of-line -Operator}); it exists for symmetry. - -@code{regexec} tries to find a match for @var{preg} in @var{string} -according to the syntax in @var{preg}'s @code{syntax} field. -(@xref{POSIX Regular Expression Compiling}, for how to set it.) The -function returns zero if the compiled pattern matches @var{string} and -@code{REG_NOMATCH} (defined in @file{regex.h}) if it doesn't. - -@node Reporting Errors, Using Byte Offsets, POSIX Matching, POSIX Regex Functions -@subsection Reporting Errors - -If either @code{regcomp} or @code{regexec} fail, they return a nonzero -error code, the possibilities for which are defined in @file{regex.h}. -@xref{POSIX Regular Expression Compiling}, and @ref{POSIX Matching}, for -what these codes mean. To get an error string corresponding to these -codes, you can use: - -@findex regerror -@example -size_t -regerror (int @var{errcode}, - const regex_t *@var{preg}, - char *@var{errbuf}, - size_t @var{errbuf_size}) -@end example - -@noindent -@var{errcode} is an error code, @var{preg} is the address of the pattern -buffer which provoked the error, @var{errbuf} is the error buffer, and -@var{errbuf_size} is @var{errbuf}'s size. - -@code{regerror} returns the size in bytes of the error string -corresponding to @var{errcode} (including its terminating null). If -@var{errbuf} and @var{errbuf_size} are nonzero, it also returns in -@var{errbuf} the first @math{@var{errbuf_size} - 1} characters of the -error string, followed by a null. -@var{errbuf_size} must be a nonnegative number less than or equal to the -size in bytes of @var{errbuf}. - -You can call @code{regerror} with a null @var{errbuf} and a zero -@var{errbuf_size} to determine how large @var{errbuf} need be to -accommodate @code{regerror}'s error string. - -@node Using Byte Offsets, Freeing POSIX Pattern Buffers, Reporting Errors, POSIX Regex Functions -@subsection Using Byte Offsets - -In @sc{posix}, variables of type @code{regmatch_t} hold analogous -information, but are not identical to, @sc{gnu}'s registers (@pxref{Using -Registers}). To get information about registers in @sc{posix}, pass to -@code{regexec} a nonzero @var{pmatch} of type @code{regmatch_t}, i.e., -the address of a structure of this type, defined in -@file{regex.h}: - -@tindex regmatch_t -@example -typedef struct -@{ - regoff_t rm_so; - regoff_t rm_eo; -@} regmatch_t; -@end example - -When reading in @ref{Using Registers}, about how the matching function -stores the information into the registers, substitute @var{pmatch} for -@var{regs}, @code{@w{@var{pmatch}[@var{i}]->}rm_so} for -@code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{pmatch}[@var{i}]->}rm_eo} for -@code{@w{@var{regs}->}end[@var{i}]}. - -@node Freeing POSIX Pattern Buffers, , Using Byte Offsets, POSIX Regex Functions -@subsection Freeing POSIX Pattern Buffers - -To free any allocated fields of a pattern buffer, use: - -@findex regfree -@example -void -regfree (regex_t *@var{preg}) -@end example - -@noindent -@var{preg} is the pattern buffer whose allocated fields you want freed. -@code{regfree} also sets @var{preg}'s @code{allocated} and @code{used} -fields to zero. After freeing a pattern buffer, you need to again -compile a regular expression in it (@pxref{POSIX Regular Expression -Compiling}) before passing it to the matching function (@pxref{POSIX -Matching}). - - -@node BSD Regex Functions, , POSIX Regex Functions, Programming with Regex -@section BSD Regex Functions - -If you're writing code that has to be Berkeley @sc{unix} compatible, -you'll need to use these functions whose interfaces are the same as those -in Berkeley @sc{unix}. - -@menu -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () -@end menu - -@node BSD Regular Expression Compiling, BSD Searching, , BSD Regex Functions -@subsection BSD Regular Expression Compiling - -With Berkeley @sc{unix}, you can only search for a given regular -expression; you can't match one. To search for it, you must first -compile it. Before you compile it, you must indicate the regular -expression syntax you want it compiled according to by setting the -variable @code{re_syntax_options} (declared in @file{regex.h} to some -syntax (@pxref{Regular Expression Syntax}). - -To compile a regular expression use: - -@findex re_comp -@example -char * -re_comp (char *@var{regex}) -@end example - -@noindent -@var{regex} is the address of a null-terminated regular expression. -@code{re_comp} uses an internal pattern buffer, so you can use only the -most recently compiled pattern buffer. This means that if you want to -use a given regular expression that you've already compiled---but it -isn't the latest one you've compiled---you'll have to recompile it. If -you call @code{re_comp} with the null string (@emph{not} the empty -string) as the argument, it doesn't change the contents of the pattern -buffer. - -If @code{re_comp} successfully compiles the regular expression, it -returns zero. If it can't compile the regular expression, it returns -an error string. @code{re_comp}'s error messages are identical to those -of @code{re_compile_pattern} (@pxref{GNU Regular Expression -Compiling}). - -@node BSD Searching, , BSD Regular Expression Compiling, BSD Regex Functions -@subsection BSD Searching - -Searching the Berkeley @sc{unix} way means searching in a string -starting at its first character and trying successive positions within -it to find a match. Once you've compiled a pattern using @code{re_comp} -(@pxref{BSD Regular Expression Compiling}), you can ask Regex -to search for that pattern in a string using: - -@findex re_exec -@example -int -re_exec (char *@var{string}) -@end example - -@noindent -@var{string} is the address of the null-terminated string in which you -want to search. - -@code{re_exec} returns either 1 for success or 0 for failure. It -automatically uses a @sc{gnu} fastmap (@pxref{Searching with Fastmaps}). - - -@node Copying, Index, Programming with Regex, Top -@appendix GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 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. -@end display - -@unnumberedsec 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. - -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -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. - -@item -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. - -@item -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: - -@enumerate a -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -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. - -@item -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.) -@end enumerate - -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. - -@item -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: - -@enumerate a -@item -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, - -@item -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, - -@item -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.) -@end enumerate - -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -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. - -@item -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 enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec 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. - -@smallexample -@var{one line to give the program's name and a brief idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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. -@end smallexample - -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: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{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. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{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: - -@example -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end example - -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. - - -@node Index, , Copying, Top -@unnumbered Index - -@printindex cp - -@contents - -@bye diff --git a/gnu/lib/libregex/regex.c b/gnu/lib/libregex/regex.c deleted file mode 100644 index 0013e8f84ab8..000000000000 --- a/gnu/lib/libregex/regex.c +++ /dev/null @@ -1,4952 +0,0 @@ -/* Extended regular expression matching and search library, - version 0.12. - (Implements POSIX draft P10003.2/D11.2, except for - internationalization features.) - - Copyright (C) 1993 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. */ - -#ifndef lint -static char rcsid[] = "$Id: regex.c,v 1.2 1993/08/02 17:24:48 mycroft Exp $"; -#endif /* not lint */ - -/* AIX requires this to be the first thing in the file. */ -#if defined (_AIX) && !defined (REGEX_MALLOC) - #pragma alloca -#endif - -#define _GNU_SOURCE - -/* We need this for `regex.h', and perhaps for the Emacs include files. */ -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* The `emacs' switch turns on certain matching commands - that make sense only in Emacs. */ -#ifdef emacs - -#include "lisp.h" -#include "buffer.h" -#include "syntax.h" - -/* Emacs uses `NULL' as a predicate. */ -#undef NULL - -#else /* not emacs */ - -/* We used to test for `BSTRING' here, but only GCC and Emacs define - `BSTRING', as far as I know, and neither of them use this code. */ -#if HAVE_STRING_H || STDC_HEADERS -#include -#ifndef bcmp -#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) -#endif -#ifndef bcopy -#define bcopy(s, d, n) memcpy ((d), (s), (n)) -#endif -#ifndef bzero -#define bzero(s, n) memset ((s), 0, (n)) -#endif -#else -#include -#endif - -#ifdef STDC_HEADERS -#include -#else -char *malloc (); -char *realloc (); -#endif - - -/* Define the syntax stuff for \<, \>, etc. */ - -/* This must be nonzero for the wordchar and notwordchar pattern - commands in re_match_2. */ -#ifndef Sword -#define Sword 1 -#endif - -#ifdef SYNTAX_TABLE - -extern char *re_syntax_table; - -#else /* not SYNTAX_TABLE */ - -/* How many characters in the character set. */ -#define CHAR_SET_SIZE 256 - -static char re_syntax_table[CHAR_SET_SIZE]; - -static void -init_syntax_once () -{ - register int c; - static int done = 0; - - if (done) - return; - - bzero (re_syntax_table, sizeof re_syntax_table); - - for (c = 'a'; c <= 'z'; c++) - re_syntax_table[c] = Sword; - - for (c = 'A'; c <= 'Z'; c++) - re_syntax_table[c] = Sword; - - for (c = '0'; c <= '9'; c++) - re_syntax_table[c] = Sword; - - re_syntax_table['_'] = Sword; - - done = 1; -} - -#endif /* not SYNTAX_TABLE */ - -#define SYNTAX(c) re_syntax_table[c] - -#endif /* not emacs */ - -/* Get the interface, including the syntax bits. */ -#include "regex.h" - -/* isalpha etc. are used for the character classes. */ -#include - -#ifndef isascii -#define isascii(c) 1 -#endif - -#ifdef isblank -#define ISBLANK(c) (isascii (c) && isblank (c)) -#else -#define ISBLANK(c) ((c) == ' ' || (c) == '\t') -#endif -#ifdef isgraph -#define ISGRAPH(c) (isascii (c) && isgraph (c)) -#else -#define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c)) -#endif - -#define ISPRINT(c) (isascii (c) && isprint (c)) -#define ISDIGIT(c) (isascii (c) && isdigit (c)) -#define ISALNUM(c) (isascii (c) && isalnum (c)) -#define ISALPHA(c) (isascii (c) && isalpha (c)) -#define ISCNTRL(c) (isascii (c) && iscntrl (c)) -#define ISLOWER(c) (isascii (c) && islower (c)) -#define ISPUNCT(c) (isascii (c) && ispunct (c)) -#define ISSPACE(c) (isascii (c) && isspace (c)) -#define ISUPPER(c) (isascii (c) && isupper (c)) -#define ISXDIGIT(c) (isascii (c) && isxdigit (c)) - -#ifndef NULL -#define NULL 0 -#endif - -/* We remove any previous definition of `SIGN_EXTEND_CHAR', - since ours (we hope) works properly with all combinations of - machines, compilers, `char' and `unsigned char' argument types. - (Per Bothner suggested the basic approach.) */ -#undef SIGN_EXTEND_CHAR -#if __STDC__ -#define SIGN_EXTEND_CHAR(c) ((signed char) (c)) -#else /* not __STDC__ */ -/* As in Harbison and Steele. */ -#define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) -#endif - -/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we - use `alloca' instead of `malloc'. This is because using malloc in - re_search* or re_match* could cause memory leaks when C-g is used in - Emacs; also, malloc is slower and causes storage fragmentation. On - the other hand, malloc is more portable, and easier to debug. - - Because we sometimes use alloca, some routines have to be macros, - not functions -- `alloca'-allocated space disappears at the end of the - function it is called in. */ - -#ifdef REGEX_MALLOC - -#define REGEX_ALLOCATE malloc -#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) - -#else /* not REGEX_MALLOC */ - -/* Emacs already defines alloca, sometimes. */ -#ifndef alloca - -/* Make alloca work the best possible way. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if HAVE_ALLOCA_H -#include -#else /* not __GNUC__ or HAVE_ALLOCA_H */ -#ifndef _AIX /* Already did AIX, up at the top. */ -char *alloca (); -#endif /* not _AIX */ -#endif /* not HAVE_ALLOCA_H */ -#endif /* not __GNUC__ */ - -#endif /* not alloca */ - -#define REGEX_ALLOCATE alloca - -/* Assumes a `char *destination' variable. */ -#define REGEX_REALLOCATE(source, osize, nsize) \ - (destination = (char *) alloca (nsize), \ - bcopy (source, destination, osize), \ - destination) - -#endif /* not REGEX_MALLOC */ - - -/* True if `size1' is non-NULL and PTR is pointing anywhere inside - `string1' or just past its end. This works if PTR is NULL, which is - a good thing. */ -#define FIRST_STRING_P(ptr) \ - (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) - -/* (Re)Allocate N items of type T using malloc, or fail. */ -#define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) -#define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) -#define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) - -#define BYTEWIDTH 8 /* In bits. */ - -#define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) - -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -typedef char boolean; -#define false 0 -#define true 1 - -/* These are the command codes that appear in compiled regular - expressions. Some opcodes are followed by argument bytes. A - command code can specify any interpretation whatsoever for its - arguments. Zero bytes may appear in the compiled regular expression. - - The value of `exactn' is needed in search.c (search_buffer) in Emacs. - So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of - `exactn' we use here must also be 1. */ - -typedef enum -{ - no_op = 0, - - /* Followed by one byte giving n, then by n literal bytes. */ - exactn = 1, - - /* Matches any (more or less) character. */ - anychar, - - /* Matches any one char belonging to specified set. First - following byte is number of bitmap bytes. Then come bytes - for a bitmap saying which chars are in. Bits in each byte - are ordered low-bit-first. A character is in the set if its - bit is 1. A character too large to have a bit in the map is - automatically not in the set. */ - charset, - - /* Same parameters as charset, but match any character that is - not one of those specified. */ - charset_not, - - /* Start remembering the text that is matched, for storing in a - register. Followed by one byte with the register number, in - the range 0 to one less than the pattern buffer's re_nsub - field. Then followed by one byte with the number of groups - inner to this one. (This last has to be part of the - start_memory only because we need it in the on_failure_jump - of re_match_2.) */ - start_memory, - - /* Stop remembering the text that is matched and store it in a - memory register. Followed by one byte with the register - number, in the range 0 to one less than `re_nsub' in the - pattern buffer, and one byte with the number of inner groups, - just like `start_memory'. (We need the number of inner - groups here because we don't have any easy way of finding the - corresponding start_memory when we're at a stop_memory.) */ - stop_memory, - - /* Match a duplicate of something remembered. Followed by one - byte containing the register number. */ - duplicate, - - /* Fail unless at beginning of line. */ - begline, - - /* Fail unless at end of line. */ - endline, - - /* Succeeds if at beginning of buffer (if emacs) or at beginning - of string to be matched (if not). */ - begbuf, - - /* Analogously, for end of buffer/string. */ - endbuf, - - /* Followed by two byte relative address to which to jump. */ - jump, - - /* Same as jump, but marks the end of an alternative. */ - jump_past_alt, - - /* Followed by two-byte relative address of place to resume at - in case of failure. */ - on_failure_jump, - - /* Like on_failure_jump, but pushes a placeholder instead of the - current string position when executed. */ - on_failure_keep_string_jump, - - /* Throw away latest failure point and then jump to following - two-byte relative address. */ - pop_failure_jump, - - /* Change to pop_failure_jump if know won't have to backtrack to - match; otherwise change to jump. This is used to jump - back to the beginning of a repeat. If what follows this jump - clearly won't match what the repeat does, such that we can be - sure that there is no use backtracking out of repetitions - already matched, then we change it to a pop_failure_jump. - Followed by two-byte address. */ - maybe_pop_jump, - - /* Jump to following two-byte address, and push a dummy failure - point. This failure point will be thrown away if an attempt - is made to use it for a failure. A `+' construct makes this - before the first repeat. Also used as an intermediary kind - of jump when compiling an alternative. */ - dummy_failure_jump, - - /* Push a dummy failure point and continue. Used at the end of - alternatives. */ - push_dummy_failure, - - /* Followed by two-byte relative address and two-byte number n. - After matching N times, jump to the address upon failure. */ - succeed_n, - - /* Followed by two-byte relative address, and two-byte number n. - Jump to the address N times, then fail. */ - jump_n, - - /* Set the following two-byte relative address to the - subsequent two-byte number. The address *includes* the two - bytes of number. */ - set_number_at, - - wordchar, /* Matches any word-constituent character. */ - notwordchar, /* Matches any char that is not a word-constituent. */ - - wordbeg, /* Succeeds if at word beginning. */ - wordend, /* Succeeds if at word end. */ - - wordbound, /* Succeeds if at a word boundary. */ - notwordbound /* Succeeds if not at a word boundary. */ - -#ifdef emacs - ,before_dot, /* Succeeds if before point. */ - at_dot, /* Succeeds if at point. */ - after_dot, /* Succeeds if after point. */ - - /* Matches any character whose syntax is specified. Followed by - a byte which contains a syntax code, e.g., Sword. */ - syntaxspec, - - /* Matches any character whose syntax is not that specified. */ - notsyntaxspec -#endif /* emacs */ -} re_opcode_t; - -/* Common operations on the compiled pattern. */ - -/* Store NUMBER in two contiguous bytes starting at DESTINATION. */ - -#define STORE_NUMBER(destination, number) \ - do { \ - (destination)[0] = (number) & 0377; \ - (destination)[1] = (number) >> 8; \ - } while (0) - -/* Same as STORE_NUMBER, except increment DESTINATION to - the byte after where the number is stored. Therefore, DESTINATION - must be an lvalue. */ - -#define STORE_NUMBER_AND_INCR(destination, number) \ - do { \ - STORE_NUMBER (destination, number); \ - (destination) += 2; \ - } while (0) - -/* Put into DESTINATION a number stored in two contiguous bytes starting - at SOURCE. */ - -#define EXTRACT_NUMBER(destination, source) \ - do { \ - (destination) = *(source) & 0377; \ - (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \ - } while (0) - -#ifdef DEBUG -static void -extract_number (dest, source) - int *dest; - unsigned char *source; -{ - int temp = SIGN_EXTEND_CHAR (*(source + 1)); - *dest = *source & 0377; - *dest += temp << 8; -} - -#ifndef EXTRACT_MACROS /* To debug the macros. */ -#undef EXTRACT_NUMBER -#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) -#endif /* not EXTRACT_MACROS */ - -#endif /* DEBUG */ - -/* Same as EXTRACT_NUMBER, except increment SOURCE to after the number. - SOURCE must be an lvalue. */ - -#define EXTRACT_NUMBER_AND_INCR(destination, source) \ - do { \ - EXTRACT_NUMBER (destination, source); \ - (source) += 2; \ - } while (0) - -#ifdef DEBUG -static void -extract_number_and_incr (destination, source) - int *destination; - unsigned char **source; -{ - extract_number (destination, *source); - *source += 2; -} - -#ifndef EXTRACT_MACROS -#undef EXTRACT_NUMBER_AND_INCR -#define EXTRACT_NUMBER_AND_INCR(dest, src) \ - extract_number_and_incr (&dest, &src) -#endif /* not EXTRACT_MACROS */ - -#endif /* DEBUG */ - -/* If DEBUG is defined, Regex prints many voluminous messages about what - it is doing (if the variable `debug' is nonzero). If linked with the - main program in `iregex.c', you can enter patterns and strings - interactively. And if linked with the main program in `main.c' and - the other test files, you can run the already-written tests. */ - -#ifdef DEBUG - -/* We use standard I/O for debugging. */ -#include - -/* It is useful to test things that ``must'' be true when debugging. */ -#include - -static int debug = 0; - -#define DEBUG_STATEMENT(e) e -#define DEBUG_PRINT1(x) if (debug) printf (x) -#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) -#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) -#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ - if (debug) print_partial_compiled_pattern (s, e) -#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ - if (debug) print_double_string (w, s1, sz1, s2, sz2) - - -extern void printchar (); - -/* Print the fastmap in human-readable form. */ - -void -print_fastmap (fastmap) - char *fastmap; -{ - unsigned was_a_range = 0; - unsigned i = 0; - - while (i < (1 << BYTEWIDTH)) - { - if (fastmap[i++]) - { - was_a_range = 0; - printchar (i - 1); - while (i < (1 << BYTEWIDTH) && fastmap[i]) - { - was_a_range = 1; - i++; - } - if (was_a_range) - { - printf ("-"); - printchar (i - 1); - } - } - } - putchar ('\n'); -} - - -/* Print a compiled pattern string in human-readable form, starting at - the START pointer into it and ending just before the pointer END. */ - -void -print_partial_compiled_pattern (start, end) - unsigned char *start; - unsigned char *end; -{ - int mcnt, mcnt2; - unsigned char *p = start; - unsigned char *pend = end; - - if (start == NULL) - { - printf ("(null)\n"); - return; - } - - /* Loop over pattern commands. */ - while (p < pend) - { - switch ((re_opcode_t) *p++) - { - case no_op: - printf ("/no_op"); - break; - - case exactn: - mcnt = *p++; - printf ("/exactn/%d", mcnt); - do - { - putchar ('/'); - printchar (*p++); - } - while (--mcnt); - break; - - case start_memory: - mcnt = *p++; - printf ("/start_memory/%d/%d", mcnt, *p++); - break; - - case stop_memory: - mcnt = *p++; - printf ("/stop_memory/%d/%d", mcnt, *p++); - break; - - case duplicate: - printf ("/duplicate/%d", *p++); - break; - - case anychar: - printf ("/anychar"); - break; - - case charset: - case charset_not: - { - register int c; - - printf ("/charset%s", - (re_opcode_t) *(p - 1) == charset_not ? "_not" : ""); - - assert (p + *p < pend); - - for (c = 0; c < *p; c++) - { - unsigned bit; - unsigned char map_byte = p[1 + c]; - - putchar ('/'); - - for (bit = 0; bit < BYTEWIDTH; bit++) - if (map_byte & (1 << bit)) - printchar (c * BYTEWIDTH + bit); - } - p += 1 + *p; - break; - } - - case begline: - printf ("/begline"); - break; - - case endline: - printf ("/endline"); - break; - - case on_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/on_failure_jump/0/%d", mcnt); - break; - - case on_failure_keep_string_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/on_failure_keep_string_jump/0/%d", mcnt); - break; - - case dummy_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/dummy_failure_jump/0/%d", mcnt); - break; - - case push_dummy_failure: - printf ("/push_dummy_failure"); - break; - - case maybe_pop_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/maybe_pop_jump/0/%d", mcnt); - break; - - case pop_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/pop_failure_jump/0/%d", mcnt); - break; - - case jump_past_alt: - extract_number_and_incr (&mcnt, &p); - printf ("/jump_past_alt/0/%d", mcnt); - break; - - case jump: - extract_number_and_incr (&mcnt, &p); - printf ("/jump/0/%d", mcnt); - break; - - case succeed_n: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/succeed_n/0/%d/0/%d", mcnt, mcnt2); - break; - - case jump_n: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/jump_n/0/%d/0/%d", mcnt, mcnt2); - break; - - case set_number_at: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/set_number_at/0/%d/0/%d", mcnt, mcnt2); - break; - - case wordbound: - printf ("/wordbound"); - break; - - case notwordbound: - printf ("/notwordbound"); - break; - - case wordbeg: - printf ("/wordbeg"); - break; - - case wordend: - printf ("/wordend"); - -#ifdef emacs - case before_dot: - printf ("/before_dot"); - break; - - case at_dot: - printf ("/at_dot"); - break; - - case after_dot: - printf ("/after_dot"); - break; - - case syntaxspec: - printf ("/syntaxspec"); - mcnt = *p++; - printf ("/%d", mcnt); - break; - - case notsyntaxspec: - printf ("/notsyntaxspec"); - mcnt = *p++; - printf ("/%d", mcnt); - break; -#endif /* emacs */ - - case wordchar: - printf ("/wordchar"); - break; - - case notwordchar: - printf ("/notwordchar"); - break; - - case begbuf: - printf ("/begbuf"); - break; - - case endbuf: - printf ("/endbuf"); - break; - - default: - printf ("?%d", *(p-1)); - } - } - printf ("/\n"); -} - - -void -print_compiled_pattern (bufp) - struct re_pattern_buffer *bufp; -{ - unsigned char *buffer = bufp->buffer; - - print_partial_compiled_pattern (buffer, buffer + bufp->used); - printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated); - - if (bufp->fastmap_accurate && bufp->fastmap) - { - printf ("fastmap: "); - print_fastmap (bufp->fastmap); - } - - printf ("re_nsub: %d\t", bufp->re_nsub); - printf ("regs_alloc: %d\t", bufp->regs_allocated); - printf ("can_be_null: %d\t", bufp->can_be_null); - printf ("newline_anchor: %d\n", bufp->newline_anchor); - printf ("no_sub: %d\t", bufp->no_sub); - printf ("not_bol: %d\t", bufp->not_bol); - printf ("not_eol: %d\t", bufp->not_eol); - printf ("syntax: %d\n", bufp->syntax); - /* Perhaps we should print the translate table? */ -} - - -void -print_double_string (where, string1, size1, string2, size2) - const char *where; - const char *string1; - const char *string2; - int size1; - int size2; -{ - unsigned this_char; - - if (where == NULL) - printf ("(null)"); - else - { - if (FIRST_STRING_P (where)) - { - for (this_char = where - string1; this_char < size1; this_char++) - printchar (string1[this_char]); - - where = string2; - } - - for (this_char = where - string2; this_char < size2; this_char++) - printchar (string2[this_char]); - } -} - -#else /* not DEBUG */ - -#undef assert -#define assert(e) - -#define DEBUG_STATEMENT(e) -#define DEBUG_PRINT1(x) -#define DEBUG_PRINT2(x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) -#define DEBUG_PRINT4(x1, x2, x3, x4) -#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) -#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) - -#endif /* not DEBUG */ - -/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can - also be assigned to arbitrarily: each pattern buffer stores its own - syntax, so it can be changed between regex compilations. */ -reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; - - -/* Specify the precise syntax of regexps for compilation. This provides - for compatibility for various utilities which historically have - different, incompatible syntaxes. - - The argument SYNTAX is a bit mask comprised of the various bits - defined in regex.h. We return the old syntax. */ - -reg_syntax_t -re_set_syntax (syntax) - reg_syntax_t syntax; -{ - reg_syntax_t ret = re_syntax_options; - - re_syntax_options = syntax; - return ret; -} - -/* This table gives an error message for each of the error codes listed - in regex.h. Obviously the order here has to be same as there. */ - -static const char *re_error_msg[] = - { NULL, /* REG_NOERROR */ - "No match", /* REG_NOMATCH */ - "Invalid regular expression", /* REG_BADPAT */ - "Invalid collation character", /* REG_ECOLLATE */ - "Invalid character class name", /* REG_ECTYPE */ - "Trailing backslash", /* REG_EESCAPE */ - "Invalid back reference", /* REG_ESUBREG */ - "Unmatched [ or [^", /* REG_EBRACK */ - "Unmatched ( or \\(", /* REG_EPAREN */ - "Unmatched \\{", /* REG_EBRACE */ - "Invalid content of \\{\\}", /* REG_BADBR */ - "Invalid range end", /* REG_ERANGE */ - "Memory exhausted", /* REG_ESPACE */ - "Invalid preceding regular expression", /* REG_BADRPT */ - "Premature end of regular expression", /* REG_EEND */ - "Regular expression too big", /* REG_ESIZE */ - "Unmatched ) or \\)", /* REG_ERPAREN */ - }; - -/* Subroutine declarations and macros for regex_compile. */ - -static void store_op1 (), store_op2 (); -static void insert_op1 (), insert_op2 (); -static boolean at_begline_loc_p (), at_endline_loc_p (); -static boolean group_in_compile_stack (); -static reg_errcode_t compile_range (); - -/* Fetch the next character in the uncompiled pattern---translating it - if necessary. Also cast from a signed character in the constant - string passed to us by the user to an unsigned char that we can use - as an array index (in, e.g., `translate'). */ -#define PATFETCH(c) \ - do {if (p == pend) return REG_EEND; \ - c = (unsigned char) *p++; \ - if (translate) c = translate[c]; \ - } while (0) - -/* Fetch the next character in the uncompiled pattern, with no - translation. */ -#define PATFETCH_RAW(c) \ - do {if (p == pend) return REG_EEND; \ - c = (unsigned char) *p++; \ - } while (0) - -/* Go backwards one character in the pattern. */ -#define PATUNFETCH p-- - - -/* If `translate' is non-null, return translate[D], else just D. We - cast the subscript to translate because some data is declared as - `char *', to avoid warnings when a string constant is passed. But - when we use a character as a subscript we must make it unsigned. */ -#define TRANSLATE(d) (translate ? translate[(unsigned char) (d)] : (d)) - - -/* Macros for outputting the compiled pattern into `buffer'. */ - -/* If the buffer isn't allocated when it comes in, use this. */ -#define INIT_BUF_SIZE 32 - -/* Make sure we have at least N more bytes of space in buffer. */ -#define GET_BUFFER_SPACE(n) \ - while (b - bufp->buffer + (n) > bufp->allocated) \ - EXTEND_BUFFER () - -/* Make sure we have one more byte of buffer space and then add C to it. */ -#define BUF_PUSH(c) \ - do { \ - GET_BUFFER_SPACE (1); \ - *b++ = (unsigned char) (c); \ - } while (0) - - -/* Ensure we have two more bytes of buffer space and then append C1 and C2. */ -#define BUF_PUSH_2(c1, c2) \ - do { \ - GET_BUFFER_SPACE (2); \ - *b++ = (unsigned char) (c1); \ - *b++ = (unsigned char) (c2); \ - } while (0) - - -/* As with BUF_PUSH_2, except for three bytes. */ -#define BUF_PUSH_3(c1, c2, c3) \ - do { \ - GET_BUFFER_SPACE (3); \ - *b++ = (unsigned char) (c1); \ - *b++ = (unsigned char) (c2); \ - *b++ = (unsigned char) (c3); \ - } while (0) - - -/* Store a jump with opcode OP at LOC to location TO. We store a - relative address offset by the three bytes the jump itself occupies. */ -#define STORE_JUMP(op, loc, to) \ - store_op1 (op, loc, (to) - (loc) - 3) - -/* Likewise, for a two-argument jump. */ -#define STORE_JUMP2(op, loc, to, arg) \ - store_op2 (op, loc, (to) - (loc) - 3, arg) - -/* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */ -#define INSERT_JUMP(op, loc, to) \ - insert_op1 (op, loc, (to) - (loc) - 3, b) - -/* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */ -#define INSERT_JUMP2(op, loc, to, arg) \ - insert_op2 (op, loc, (to) - (loc) - 3, arg, b) - - -/* This is not an arbitrary limit: the arguments which represent offsets - into the pattern are two bytes long. So if 2^16 bytes turns out to - be too small, many things would have to change. */ -#define MAX_BUF_SIZE (1L << 16) - - -/* Extend the buffer by twice its current size via realloc and - reset the pointers that pointed into the old block to point to the - correct places in the new one. If extending the buffer results in it - being larger than MAX_BUF_SIZE, then flag memory exhausted. */ -#define EXTEND_BUFFER() \ - do { \ - unsigned char *old_buffer = bufp->buffer; \ - if (bufp->allocated == MAX_BUF_SIZE) \ - return REG_ESIZE; \ - bufp->allocated <<= 1; \ - if (bufp->allocated > MAX_BUF_SIZE) \ - bufp->allocated = MAX_BUF_SIZE; \ - bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\ - if (bufp->buffer == NULL) \ - return REG_ESPACE; \ - /* If the buffer moved, move all the pointers into it. */ \ - if (old_buffer != bufp->buffer) \ - { \ - b = (b - old_buffer) + bufp->buffer; \ - begalt = (begalt - old_buffer) + bufp->buffer; \ - if (fixup_alt_jump) \ - fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\ - if (laststart) \ - laststart = (laststart - old_buffer) + bufp->buffer; \ - if (pending_exact) \ - pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ - } \ - } while (0) - - -/* Since we have one byte reserved for the register number argument to - {start,stop}_memory, the maximum number of groups we can report - things about is what fits in that byte. */ -#define MAX_REGNUM 255 - -/* But patterns can have more than `MAX_REGNUM' registers. We just - ignore the excess. */ -typedef unsigned regnum_t; - - -/* Macros for the compile stack. */ - -/* Since offsets can go either forwards or backwards, this type needs to - be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ -typedef int pattern_offset_t; - -typedef struct -{ - pattern_offset_t begalt_offset; - pattern_offset_t fixup_alt_jump; - pattern_offset_t inner_group_offset; - pattern_offset_t laststart_offset; - regnum_t regnum; -} compile_stack_elt_t; - - -typedef struct -{ - compile_stack_elt_t *stack; - unsigned size; - unsigned avail; /* Offset of next open position. */ -} compile_stack_type; - - -#define INIT_COMPILE_STACK_SIZE 32 - -#define COMPILE_STACK_EMPTY (compile_stack.avail == 0) -#define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) - -/* The next available element. */ -#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) - - -/* Set the bit for character C in a list. */ -#define SET_LIST_BIT(c) \ - (b[((unsigned char) (c)) / BYTEWIDTH] \ - |= 1 << (((unsigned char) c) % BYTEWIDTH)) - - -/* Get the next unsigned number in the uncompiled pattern. */ -#define GET_UNSIGNED_NUMBER(num) \ - { if (p != pend) \ - { \ - PATFETCH (c); \ - while (ISDIGIT (c)) \ - { \ - if (num < 0) \ - num = 0; \ - num = num * 10 + c - '0'; \ - if (p == pend) \ - break; \ - PATFETCH (c); \ - } \ - } \ - } - -#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ - -#define IS_CHAR_CLASS(string) \ - (STREQ (string, "alpha") || STREQ (string, "upper") \ - || STREQ (string, "lower") || STREQ (string, "digit") \ - || STREQ (string, "alnum") || STREQ (string, "xdigit") \ - || STREQ (string, "space") || STREQ (string, "print") \ - || STREQ (string, "punct") || STREQ (string, "graph") \ - || STREQ (string, "cntrl") || STREQ (string, "blank")) - -/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. - Returns one of error codes defined in `regex.h', or zero for success. - - Assumes the `allocated' (and perhaps `buffer') and `translate' - fields are set in BUFP on entry. - - If it succeeds, results are put in BUFP (if it returns an error, the - contents of BUFP are undefined): - `buffer' is the compiled pattern; - `syntax' is set to SYNTAX; - `used' is set to the length of the compiled pattern; - `fastmap_accurate' is zero; - `re_nsub' is the number of subexpressions in PATTERN; - `not_bol' and `not_eol' are zero; - - The `fastmap' and `newline_anchor' fields are neither - examined nor set. */ - -static reg_errcode_t -regex_compile (pattern, size, syntax, bufp) - const char *pattern; - int size; - reg_syntax_t syntax; - struct re_pattern_buffer *bufp; -{ - /* We fetch characters from PATTERN here. Even though PATTERN is - `char *' (i.e., signed), we declare these variables as unsigned, so - they can be reliably used as array indices. */ - register unsigned char c, c1; - - /* A random tempory spot in PATTERN. */ - const char *p1; - - /* Points to the end of the buffer, where we should append. */ - register unsigned char *b; - - /* Keeps track of unclosed groups. */ - compile_stack_type compile_stack; - - /* Points to the current (ending) position in the pattern. */ - const char *p = pattern; - const char *pend = pattern + size; - - /* How to translate the characters in the pattern. */ - char *translate = bufp->translate; - - /* Address of the count-byte of the most recently inserted `exactn' - command. This makes it possible to tell if a new exact-match - character can be added to that command or if the character requires - a new `exactn' command. */ - unsigned char *pending_exact = 0; - - /* Address of start of the most recently finished expression. - This tells, e.g., postfix * where to find the start of its - operand. Reset at the beginning of groups and alternatives. */ - unsigned char *laststart = 0; - - /* Address of beginning of regexp, or inside of last group. */ - unsigned char *begalt; - - /* Place in the uncompiled pattern (i.e., the {) to - which to go back if the interval is invalid. */ - const char *beg_interval; - - /* Address of the place where a forward jump should go to the end of - the containing expression. Each alternative of an `or' -- except the - last -- ends with a forward jump of this sort. */ - unsigned char *fixup_alt_jump = 0; - - /* Counts open-groups as they are encountered. Remembered for the - matching close-group on the compile stack, so the same register - number is put in the stop_memory as the start_memory. */ - regnum_t regnum = 0; - -#ifdef DEBUG - DEBUG_PRINT1 ("\nCompiling pattern: "); - if (debug) - { - unsigned debug_count; - - for (debug_count = 0; debug_count < size; debug_count++) - printchar (pattern[debug_count]); - putchar ('\n'); - } -#endif /* DEBUG */ - - /* Initialize the compile stack. */ - compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); - if (compile_stack.stack == NULL) - return REG_ESPACE; - - compile_stack.size = INIT_COMPILE_STACK_SIZE; - compile_stack.avail = 0; - - /* Initialize the pattern buffer. */ - bufp->syntax = syntax; - bufp->fastmap_accurate = 0; - bufp->not_bol = bufp->not_eol = 0; - - /* Set `used' to zero, so that if we return an error, the pattern - printer (for debugging) will think there's no pattern. We reset it - at the end. */ - bufp->used = 0; - - /* Always count groups, whether or not bufp->no_sub is set. */ - bufp->re_nsub = 0; - -#if !defined (emacs) && !defined (SYNTAX_TABLE) - /* Initialize the syntax table. */ - init_syntax_once (); -#endif - - if (bufp->allocated == 0) - { - if (bufp->buffer) - { /* If zero allocated, but buffer is non-null, try to realloc - enough space. This loses if buffer's address is bogus, but - that is the user's responsibility. */ - RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); - } - else - { /* Caller did not allocate a buffer. Do it for them. */ - bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); - } - if (!bufp->buffer) return REG_ESPACE; - - bufp->allocated = INIT_BUF_SIZE; - } - - begalt = b = bufp->buffer; - - /* Loop through the uncompiled pattern until we're at the end. */ - while (p != pend) - { - PATFETCH (c); - - switch (c) - { - case '^': - { - if ( /* If at start of pattern, it's an operator. */ - p == pattern + 1 - /* If context independent, it's an operator. */ - || syntax & RE_CONTEXT_INDEP_ANCHORS - /* Otherwise, depends on what's come before. */ - || at_begline_loc_p (pattern, p, syntax)) - BUF_PUSH (begline); - else - goto normal_char; - } - break; - - - case '$': - { - if ( /* If at end of pattern, it's an operator. */ - p == pend - /* If context independent, it's an operator. */ - || syntax & RE_CONTEXT_INDEP_ANCHORS - /* Otherwise, depends on what's next. */ - || at_endline_loc_p (p, pend, syntax)) - BUF_PUSH (endline); - else - goto normal_char; - } - break; - - - case '+': - case '?': - if ((syntax & RE_BK_PLUS_QM) - || (syntax & RE_LIMITED_OPS)) - goto normal_char; - handle_plus: - case '*': - /* If there is no previous pattern... */ - if (!laststart) - { - if (syntax & RE_CONTEXT_INVALID_OPS) - return REG_BADRPT; - else if (!(syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - } - - { - /* Are we optimizing this jump? */ - boolean keep_string_p = false; - - /* 1 means zero (many) matches is allowed. */ - char zero_times_ok = 0, many_times_ok = 0; - - /* If there is a sequence of repetition chars, collapse it - down to just one (the right one). We can't combine - interval operators with these because of, e.g., `a{2}*', - which should only match an even number of `a's. */ - - for (;;) - { - zero_times_ok |= c != '+'; - many_times_ok |= c != '?'; - - if (p == pend) - break; - - PATFETCH (c); - - if (c == '*' - || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?'))) - ; - - else if (syntax & RE_BK_PLUS_QM && c == '\\') - { - if (p == pend) return REG_EESCAPE; - - PATFETCH (c1); - if (!(c1 == '+' || c1 == '?')) - { - PATUNFETCH; - PATUNFETCH; - break; - } - - c = c1; - } - else - { - PATUNFETCH; - break; - } - - /* If we get here, we found another repeat character. */ - } - - /* Star, etc. applied to an empty pattern is equivalent - to an empty pattern. */ - if (!laststart) - break; - - /* Now we know whether or not zero matches is allowed - and also whether or not two or more matches is allowed. */ - if (many_times_ok) - { /* More than one repetition is allowed, so put in at the - end a backward relative jump from `b' to before the next - jump we're going to put in below (which jumps from - laststart to after this jump). - - But if we are at the `*' in the exact sequence `.*\n', - insert an unconditional jump backwards to the ., - instead of the beginning of the loop. This way we only - push a failure point once, instead of every time - through the loop. */ - assert (p - 1 > pattern); - - /* Allocate the space for the jump. */ - GET_BUFFER_SPACE (3); - - /* We know we are not at the first character of the pattern, - because laststart was nonzero. And we've already - incremented `p', by the way, to be the character after - the `*'. Do we have to do something analogous here - for null bytes, because of RE_DOT_NOT_NULL? */ - if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') - && zero_times_ok - && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') - && !(syntax & RE_DOT_NEWLINE)) - { /* We have .*\n. */ - STORE_JUMP (jump, b, laststart); - keep_string_p = true; - } - else - /* Anything else. */ - STORE_JUMP (maybe_pop_jump, b, laststart - 3); - - /* We've added more stuff to the buffer. */ - b += 3; - } - - /* On failure, jump from laststart to b + 3, which will be the - end of the buffer after this jump is inserted. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump - : on_failure_jump, - laststart, b + 3); - pending_exact = 0; - b += 3; - - if (!zero_times_ok) - { - /* At least one repetition is required, so insert a - `dummy_failure_jump' before the initial - `on_failure_jump' instruction of the loop. This - effects a skip over that instruction the first time - we hit that loop. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); - b += 3; - } - } - break; - - - case '.': - laststart = b; - BUF_PUSH (anychar); - break; - - - case '[': - { - boolean had_char_class = false; - - if (p == pend) return REG_EBRACK; - - /* Ensure that we have enough space to push a charset: the - opcode, the length count, and the bitset; 34 bytes in all. */ - GET_BUFFER_SPACE (34); - - laststart = b; - - /* We test `*p == '^' twice, instead of using an if - statement, so we only need one BUF_PUSH. */ - BUF_PUSH (*p == '^' ? charset_not : charset); - if (*p == '^') - p++; - - /* Remember the first position in the bracket expression. */ - p1 = p; - - /* Push the number of bytes in the bitmap. */ - BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); - - /* Clear the whole map. */ - bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); - - /* charset_not matches newline according to a syntax bit. */ - if ((re_opcode_t) b[-2] == charset_not - && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) - SET_LIST_BIT ('\n'); - - /* Read in characters and ranges, setting map bits. */ - for (;;) - { - if (p == pend) return REG_EBRACK; - - PATFETCH (c); - - /* \ might escape characters inside [...] and [^...]. */ - if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') - { - if (p == pend) return REG_EESCAPE; - - PATFETCH (c1); - SET_LIST_BIT (c1); - continue; - } - - /* Could be the end of the bracket expression. If it's - not (i.e., when the bracket expression is `[]' so - far), the ']' character bit gets set way below. */ - if (c == ']' && p != p1 + 1) - break; - - /* Look ahead to see if it's a range when the last thing - was a character class. */ - if (had_char_class && c == '-' && *p != ']') - return REG_ERANGE; - - /* Look ahead to see if it's a range when the last thing - was a character: if this is a hyphen not at the - beginning or the end of a list, then it's the range - operator. */ - if (c == '-' - && !(p - 2 >= pattern && p[-2] == '[') - && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') - && *p != ']') - { - reg_errcode_t ret - = compile_range (&p, pend, translate, syntax, b); - if (ret != REG_NOERROR) return ret; - } - - else if (p[0] == '-' && p[1] != ']') - { /* This handles ranges made up of characters only. */ - reg_errcode_t ret; - - /* Move past the `-'. */ - PATFETCH (c1); - - ret = compile_range (&p, pend, translate, syntax, b); - if (ret != REG_NOERROR) return ret; - } - - /* See if we're at the beginning of a possible character - class. */ - - else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') - { /* Leave room for the null. */ - char str[CHAR_CLASS_MAX_LENGTH + 1]; - - PATFETCH (c); - c1 = 0; - - /* If pattern is `[[:'. */ - if (p == pend) return REG_EBRACK; - - for (;;) - { - PATFETCH (c); - if (c == ':' || c == ']' || p == pend - || c1 == CHAR_CLASS_MAX_LENGTH) - break; - str[c1++] = c; - } - str[c1] = '\0'; - - /* If isn't a word bracketed by `[:' and:`]': - undo the ending character, the letters, and leave - the leading `:' and `[' (but set bits for them). */ - if (c == ':' && *p == ']') - { - int ch; - boolean is_alnum = STREQ (str, "alnum"); - boolean is_alpha = STREQ (str, "alpha"); - boolean is_blank = STREQ (str, "blank"); - boolean is_cntrl = STREQ (str, "cntrl"); - boolean is_digit = STREQ (str, "digit"); - boolean is_graph = STREQ (str, "graph"); - boolean is_lower = STREQ (str, "lower"); - boolean is_print = STREQ (str, "print"); - boolean is_punct = STREQ (str, "punct"); - boolean is_space = STREQ (str, "space"); - boolean is_upper = STREQ (str, "upper"); - boolean is_xdigit = STREQ (str, "xdigit"); - - if (!IS_CHAR_CLASS (str)) return REG_ECTYPE; - - /* Throw away the ] at the end of the character - class. */ - PATFETCH (c); - - if (p == pend) return REG_EBRACK; - - for (ch = 0; ch < 1 << BYTEWIDTH; ch++) - { - if ( (is_alnum && ISALNUM (ch)) - || (is_alpha && ISALPHA (ch)) - || (is_blank && ISBLANK (ch)) - || (is_cntrl && ISCNTRL (ch)) - || (is_digit && ISDIGIT (ch)) - || (is_graph && ISGRAPH (ch)) - || (is_lower && ISLOWER (ch)) - || (is_print && ISPRINT (ch)) - || (is_punct && ISPUNCT (ch)) - || (is_space && ISSPACE (ch)) - || (is_upper && ISUPPER (ch)) - || (is_xdigit && ISXDIGIT (ch))) - SET_LIST_BIT (ch); - } - had_char_class = true; - } - else - { - c1++; - while (c1--) - PATUNFETCH; - SET_LIST_BIT ('['); - SET_LIST_BIT (':'); - had_char_class = false; - } - } - else - { - had_char_class = false; - SET_LIST_BIT (c); - } - } - - /* Discard any (non)matching list bytes that are all 0 at the - end of the map. Decrease the map-length byte too. */ - while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) - b[-1]--; - b += b[-1]; - } - break; - - - case '(': - if (syntax & RE_NO_BK_PARENS) - goto handle_open; - else - goto normal_char; - - - case ')': - if (syntax & RE_NO_BK_PARENS) - goto handle_close; - else - goto normal_char; - - - case '\n': - if (syntax & RE_NEWLINE_ALT) - goto handle_alt; - else - goto normal_char; - - - case '|': - if (syntax & RE_NO_BK_VBAR) - goto handle_alt; - else - goto normal_char; - - - case '{': - if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) - goto handle_interval; - else - goto normal_char; - - - case '\\': - if (p == pend) return REG_EESCAPE; - - /* Do not translate the character after the \, so that we can - distinguish, e.g., \B from \b, even if we normally would - translate, e.g., B to b. */ - PATFETCH_RAW (c); - - switch (c) - { - case '(': - if (syntax & RE_NO_BK_PARENS) - goto normal_backslash; - - handle_open: - bufp->re_nsub++; - regnum++; - - if (COMPILE_STACK_FULL) - { - RETALLOC (compile_stack.stack, compile_stack.size << 1, - compile_stack_elt_t); - if (compile_stack.stack == NULL) return REG_ESPACE; - - compile_stack.size <<= 1; - } - - /* These are the values to restore when we hit end of this - group. They are all relative offsets, so that if the - whole pattern moves because of realloc, they will still - be valid. */ - COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; - COMPILE_STACK_TOP.fixup_alt_jump - = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; - COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer; - COMPILE_STACK_TOP.regnum = regnum; - - /* We will eventually replace the 0 with the number of - groups inner to this one. But do not push a - start_memory for groups beyond the last one we can - represent in the compiled pattern. */ - if (regnum <= MAX_REGNUM) - { - COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2; - BUF_PUSH_3 (start_memory, regnum, 0); - } - - compile_stack.avail++; - - fixup_alt_jump = 0; - laststart = 0; - begalt = b; - /* If we've reached MAX_REGNUM groups, then this open - won't actually generate any code, so we'll have to - clear pending_exact explicitly. */ - pending_exact = 0; - break; - - - case ')': - if (syntax & RE_NO_BK_PARENS) goto normal_backslash; - - if (COMPILE_STACK_EMPTY) - if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) - goto normal_backslash; - else - return REG_ERPAREN; - - handle_close: - if (fixup_alt_jump) - { /* Push a dummy failure point at the end of the - alternative for a possible future - `pop_failure_jump' to pop. See comments at - `push_dummy_failure' in `re_match_2'. */ - BUF_PUSH (push_dummy_failure); - - /* We allocated space for this jump when we assigned - to `fixup_alt_jump', in the `handle_alt' case below. */ - STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1); - } - - /* See similar code for backslashed left paren above. */ - if (COMPILE_STACK_EMPTY) - if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) - goto normal_char; - else - return REG_ERPAREN; - - /* Since we just checked for an empty stack above, this - ``can't happen''. */ - assert (compile_stack.avail != 0); - { - /* We don't just want to restore into `regnum', because - later groups should continue to be numbered higher, - as in `(ab)c(de)' -- the second group is #2. */ - regnum_t this_group_regnum; - - compile_stack.avail--; - begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; - fixup_alt_jump - = COMPILE_STACK_TOP.fixup_alt_jump - ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 - : 0; - laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; - this_group_regnum = COMPILE_STACK_TOP.regnum; - /* If we've reached MAX_REGNUM groups, then this open - won't actually generate any code, so we'll have to - clear pending_exact explicitly. */ - pending_exact = 0; - - /* We're at the end of the group, so now we know how many - groups were inside this one. */ - if (this_group_regnum <= MAX_REGNUM) - { - unsigned char *inner_group_loc - = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; - - *inner_group_loc = regnum - this_group_regnum; - BUF_PUSH_3 (stop_memory, this_group_regnum, - regnum - this_group_regnum); - } - } - break; - - - case '|': /* `\|'. */ - if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) - goto normal_backslash; - handle_alt: - if (syntax & RE_LIMITED_OPS) - goto normal_char; - - /* Insert before the previous alternative a jump which - jumps to this alternative if the former fails. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (on_failure_jump, begalt, b + 6); - pending_exact = 0; - b += 3; - - /* The alternative before this one has a jump after it - which gets executed if it gets matched. Adjust that - jump so it will jump to this alternative's analogous - jump (put in below, which in turn will jump to the next - (if any) alternative's such jump, etc.). The last such - jump jumps to the correct final destination. A picture: - _____ _____ - | | | | - | v | v - a | b | c - - If we are at `b', then fixup_alt_jump right now points to a - three-byte space after `a'. We'll put in the jump, set - fixup_alt_jump to right after `b', and leave behind three - bytes which we'll fill in when we get to after `c'. */ - - if (fixup_alt_jump) - STORE_JUMP (jump_past_alt, fixup_alt_jump, b); - - /* Mark and leave space for a jump after this alternative, - to be filled in later either by next alternative or - when know we're at the end of a series of alternatives. */ - fixup_alt_jump = b; - GET_BUFFER_SPACE (3); - b += 3; - - laststart = 0; - begalt = b; - break; - - - case '{': - /* If \{ is a literal. */ - if (!(syntax & RE_INTERVALS) - /* If we're at `\{' and it's not the open-interval - operator. */ - || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) - || (p - 2 == pattern && p == pend)) - goto normal_backslash; - - handle_interval: - { - /* If got here, then the syntax allows intervals. */ - - /* At least (most) this many matches must be made. */ - int lower_bound = -1, upper_bound = -1; - - beg_interval = p - 1; - - if (p == pend) - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_EBRACE; - } - - GET_UNSIGNED_NUMBER (lower_bound); - - if (c == ',') - { - GET_UNSIGNED_NUMBER (upper_bound); - if (upper_bound < 0) upper_bound = RE_DUP_MAX; - } - else - /* Interval such as `{1}' => match exactly once. */ - upper_bound = lower_bound; - - if (lower_bound < 0 || upper_bound > RE_DUP_MAX - || lower_bound > upper_bound) - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_BADBR; - } - - if (!(syntax & RE_NO_BK_BRACES)) - { - if (c != '\\') return REG_EBRACE; - - PATFETCH (c); - } - - if (c != '}') - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_BADBR; - } - - /* We just parsed a valid interval. */ - - /* If it's invalid to have no preceding re. */ - if (!laststart) - { - if (syntax & RE_CONTEXT_INVALID_OPS) - return REG_BADRPT; - else if (syntax & RE_CONTEXT_INDEP_OPS) - laststart = b; - else - goto unfetch_interval; - } - - /* If the upper bound is zero, don't want to succeed at - all; jump from `laststart' to `b + 3', which will be - the end of the buffer after we insert the jump. */ - if (upper_bound == 0) - { - GET_BUFFER_SPACE (3); - INSERT_JUMP (jump, laststart, b + 3); - b += 3; - } - - /* Otherwise, we have a nontrivial interval. When - we're all done, the pattern will look like: - set_number_at - set_number_at - succeed_n - - jump_n - (The upper bound and `jump_n' are omitted if - `upper_bound' is 1, though.) */ - else - { /* If the upper bound is > 1, we need to insert - more at the end of the loop. */ - unsigned nbytes = 10 + (upper_bound > 1) * 10; - - GET_BUFFER_SPACE (nbytes); - - /* Initialize lower bound of the `succeed_n', even - though it will be set during matching by its - attendant `set_number_at' (inserted next), - because `re_compile_fastmap' needs to know. - Jump to the `jump_n' we might insert below. */ - INSERT_JUMP2 (succeed_n, laststart, - b + 5 + (upper_bound > 1) * 5, - lower_bound); - b += 5; - - /* Code to initialize the lower bound. Insert - before the `succeed_n'. The `5' is the last two - bytes of this `set_number_at', plus 3 bytes of - the following `succeed_n'. */ - insert_op2 (set_number_at, laststart, 5, lower_bound, b); - b += 5; - - if (upper_bound > 1) - { /* More than one repetition is allowed, so - append a backward jump to the `succeed_n' - that starts this interval. - - When we've reached this during matching, - we'll have matched the interval once, so - jump back only `upper_bound - 1' times. */ - STORE_JUMP2 (jump_n, b, laststart + 5, - upper_bound - 1); - b += 5; - - /* The location we want to set is the second - parameter of the `jump_n'; that is `b-2' as - an absolute address. `laststart' will be - the `set_number_at' we're about to insert; - `laststart+3' the number to set, the source - for the relative address. But we are - inserting into the middle of the pattern -- - so everything is getting moved up by 5. - Conclusion: (b - 2) - (laststart + 3) + 5, - i.e., b - laststart. - - We insert this at the beginning of the loop - so that if we fail during matching, we'll - reinitialize the bounds. */ - insert_op2 (set_number_at, laststart, b - laststart, - upper_bound - 1, b); - b += 5; - } - } - pending_exact = 0; - beg_interval = NULL; - } - break; - - unfetch_interval: - /* If an invalid interval, match the characters as literals. */ - assert (beg_interval); - p = beg_interval; - beg_interval = NULL; - - /* normal_char and normal_backslash need `c'. */ - PATFETCH (c); - - if (!(syntax & RE_NO_BK_BRACES)) - { - if (p > pattern && p[-1] == '\\') - goto normal_backslash; - } - goto normal_char; - -#ifdef emacs - /* There is no way to specify the before_dot and after_dot - operators. rms says this is ok. --karl */ - case '=': - BUF_PUSH (at_dot); - break; - - case 's': - laststart = b; - PATFETCH (c); - BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); - break; - - case 'S': - laststart = b; - PATFETCH (c); - BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); - break; -#endif /* emacs */ - - - case 'w': - laststart = b; - BUF_PUSH (wordchar); - break; - - - case 'W': - laststart = b; - BUF_PUSH (notwordchar); - break; - - - case '<': - BUF_PUSH (wordbeg); - break; - - case '>': - BUF_PUSH (wordend); - break; - - case 'b': - BUF_PUSH (wordbound); - break; - - case 'B': - BUF_PUSH (notwordbound); - break; - - case '`': - BUF_PUSH (begbuf); - break; - - case '\'': - BUF_PUSH (endbuf); - break; - - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - if (syntax & RE_NO_BK_REFS) - goto normal_char; - - c1 = c - '0'; - - if (c1 > regnum) - return REG_ESUBREG; - - /* Can't back reference to a subexpression if inside of it. */ - if (group_in_compile_stack (compile_stack, c1)) - goto normal_char; - - laststart = b; - BUF_PUSH_2 (duplicate, c1); - break; - - - case '+': - case '?': - if (syntax & RE_BK_PLUS_QM) - goto handle_plus; - else - goto normal_backslash; - - default: - normal_backslash: - /* You might think it would be useful for \ to mean - not to translate; but if we don't translate it - it will never match anything. */ - c = TRANSLATE (c); - goto normal_char; - } - break; - - - default: - /* Expects the character in `c'. */ - normal_char: - /* If no exactn currently being built. */ - if (!pending_exact - - /* If last exactn not at current position. */ - || pending_exact + *pending_exact + 1 != b - - /* We have only one byte following the exactn for the count. */ - || *pending_exact == (1 << BYTEWIDTH) - 1 - - /* If followed by a repetition operator. */ - || *p == '*' || *p == '^' - || ((syntax & RE_BK_PLUS_QM) - ? *p == '\\' && (p[1] == '+' || p[1] == '?') - : (*p == '+' || *p == '?')) - || ((syntax & RE_INTERVALS) - && ((syntax & RE_NO_BK_BRACES) - ? *p == '{' - : (p[0] == '\\' && p[1] == '{')))) - { - /* Start building a new exactn. */ - - laststart = b; - - BUF_PUSH_2 (exactn, 0); - pending_exact = b - 1; - } - - BUF_PUSH (c); - (*pending_exact)++; - break; - } /* switch (c) */ - } /* while p != pend */ - - - /* Through the pattern now. */ - - if (fixup_alt_jump) - STORE_JUMP (jump_past_alt, fixup_alt_jump, b); - - if (!COMPILE_STACK_EMPTY) - return REG_EPAREN; - - free (compile_stack.stack); - - /* We have succeeded; set the length of the buffer. */ - bufp->used = b - bufp->buffer; - -#ifdef DEBUG - if (debug) - { - DEBUG_PRINT1 ("\nCompiled pattern: "); - print_compiled_pattern (bufp); - } -#endif /* DEBUG */ - - return REG_NOERROR; -} /* regex_compile */ - -/* Subroutines for `regex_compile'. */ - -/* Store OP at LOC followed by two-byte integer parameter ARG. */ - -static void -store_op1 (op, loc, arg) - re_opcode_t op; - unsigned char *loc; - int arg; -{ - *loc = (unsigned char) op; - STORE_NUMBER (loc + 1, arg); -} - - -/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ - -static void -store_op2 (op, loc, arg1, arg2) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; -{ - *loc = (unsigned char) op; - STORE_NUMBER (loc + 1, arg1); - STORE_NUMBER (loc + 3, arg2); -} - - -/* Copy the bytes from LOC to END to open up three bytes of space at LOC - for OP followed by two-byte integer parameter ARG. */ - -static void -insert_op1 (op, loc, arg, end) - re_opcode_t op; - unsigned char *loc; - int arg; - unsigned char *end; -{ - register unsigned char *pfrom = end; - register unsigned char *pto = end + 3; - - while (pfrom != loc) - *--pto = *--pfrom; - - store_op1 (op, loc, arg); -} - - -/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ - -static void -insert_op2 (op, loc, arg1, arg2, end) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; - unsigned char *end; -{ - register unsigned char *pfrom = end; - register unsigned char *pto = end + 5; - - while (pfrom != loc) - *--pto = *--pfrom; - - store_op2 (op, loc, arg1, arg2); -} - - -/* P points to just after a ^ in PATTERN. Return true if that ^ comes - after an alternative or a begin-subexpression. We assume there is at - least one character before the ^. */ - -static boolean -at_begline_loc_p (pattern, p, syntax) - const char *pattern, *p; - reg_syntax_t syntax; -{ - const char *prev = p - 2; - boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; - - return - /* After a subexpression? */ - (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) - /* After an alternative? */ - || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); -} - - -/* The dual of at_begline_loc_p. This one is for $. We assume there is - at least one character after the $, i.e., `P < PEND'. */ - -static boolean -at_endline_loc_p (p, pend, syntax) - const char *p, *pend; - int syntax; -{ - const char *next = p; - boolean next_backslash = *next == '\\'; - const char *next_next = p + 1 < pend ? p + 1 : NULL; - - return - /* Before a subexpression? */ - (syntax & RE_NO_BK_PARENS ? *next == ')' - : next_backslash && next_next && *next_next == ')') - /* Before an alternative? */ - || (syntax & RE_NO_BK_VBAR ? *next == '|' - : next_backslash && next_next && *next_next == '|'); -} - - -/* Returns true if REGNUM is in one of COMPILE_STACK's elements and - false if it's not. */ - -static boolean -group_in_compile_stack (compile_stack, regnum) - compile_stack_type compile_stack; - regnum_t regnum; -{ - int this_element; - - for (this_element = compile_stack.avail - 1; - this_element >= 0; - this_element--) - if (compile_stack.stack[this_element].regnum == regnum) - return true; - - return false; -} - - -/* Read the ending character of a range (in a bracket expression) from the - uncompiled pattern *P_PTR (which ends at PEND). We assume the - starting character is in `P[-2]'. (`P[-1]' is the character `-'.) - Then we set the translation of all bits between the starting and - ending characters (inclusive) in the compiled pattern B. - - Return an error code. - - We use these short variable names so we can use the same macros as - `regex_compile' itself. */ - -static reg_errcode_t -compile_range (p_ptr, pend, translate, syntax, b) - const char **p_ptr, *pend; - char *translate; - reg_syntax_t syntax; - unsigned char *b; -{ - unsigned this_char; - - const char *p = *p_ptr; - int range_start, range_end; - - if (p == pend) - return REG_ERANGE; - - /* Even though the pattern is a signed `char *', we need to fetch - with unsigned char *'s; if the high bit of the pattern character - is set, the range endpoints will be negative if we fetch using a - signed char *. - - We also want to fetch the endpoints without translating them; the - appropriate translation is done in the bit-setting loop below. */ - range_start = ((unsigned char *) p)[-2]; - range_end = ((unsigned char *) p)[0]; - - /* Have to increment the pointer into the pattern string, so the - caller isn't still at the ending character. */ - (*p_ptr)++; - - /* If the start is after the end, the range is empty. */ - if (range_start > range_end) - return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; - - /* Here we see why `this_char' has to be larger than an `unsigned - char' -- the range is inclusive, so if `range_end' == 0xff - (assuming 8-bit characters), we would otherwise go into an infinite - loop, since all characters <= 0xff. */ - for (this_char = range_start; this_char <= range_end; this_char++) - { - SET_LIST_BIT (TRANSLATE (this_char)); - } - - return REG_NOERROR; -} - -/* Failure stack declarations and macros; both re_compile_fastmap and - re_match_2 use a failure stack. These have to be macros because of - REGEX_ALLOCATE. */ - - -/* Number of failure points for which to initially allocate space - when matching. If this number is exceeded, we allocate more - space, so it is not a hard limit. */ -#ifndef INIT_FAILURE_ALLOC -#define INIT_FAILURE_ALLOC 5 -#endif - -/* Roughly the maximum number of failure points on the stack. Would be - exactly that if always used MAX_FAILURE_SPACE each time we failed. - This is a variable only so users of regex can assign to it; we never - change it ourselves. */ -int re_max_failures = 2000; - -typedef const unsigned char *fail_stack_elt_t; - -typedef struct -{ - fail_stack_elt_t *stack; - unsigned size; - unsigned avail; /* Offset of next open position. */ -} fail_stack_type; - -#define FAIL_STACK_EMPTY() (fail_stack.avail == 0) -#define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) -#define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) -#define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail]) - - -/* Initialize `fail_stack'. Do `return -2' if the alloc fails. */ - -#define INIT_FAIL_STACK() \ - do { \ - fail_stack.stack = (fail_stack_elt_t *) \ - REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \ - \ - if (fail_stack.stack == NULL) \ - return -2; \ - \ - fail_stack.size = INIT_FAILURE_ALLOC; \ - fail_stack.avail = 0; \ - } while (0) - - -/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items. - - Return 1 if succeeds, and 0 if either ran out of memory - allocating space for it or it was already too large. - - REGEX_REALLOCATE requires `destination' be declared. */ - -#define DOUBLE_FAIL_STACK(fail_stack) \ - ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \ - ? 0 \ - : ((fail_stack).stack = (fail_stack_elt_t *) \ - REGEX_REALLOCATE ((fail_stack).stack, \ - (fail_stack).size * sizeof (fail_stack_elt_t), \ - ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \ - \ - (fail_stack).stack == NULL \ - ? 0 \ - : ((fail_stack).size <<= 1, \ - 1))) - - -/* Push PATTERN_OP on FAIL_STACK. - - Return 1 if was able to do so and 0 if ran out of memory allocating - space to do so. */ -#define PUSH_PATTERN_OP(pattern_op, fail_stack) \ - ((FAIL_STACK_FULL () \ - && !DOUBLE_FAIL_STACK (fail_stack)) \ - ? 0 \ - : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \ - 1)) - -/* This pushes an item onto the failure stack. Must be a four-byte - value. Assumes the variable `fail_stack'. Probably should only - be called from within `PUSH_FAILURE_POINT'. */ -#define PUSH_FAILURE_ITEM(item) \ - fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item - -/* The complement operation. Assumes `fail_stack' is nonempty. */ -#define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail] - -/* Used to omit pushing failure point id's when we're not debugging. */ -#ifdef DEBUG -#define DEBUG_PUSH PUSH_FAILURE_ITEM -#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_ITEM () -#else -#define DEBUG_PUSH(item) -#define DEBUG_POP(item_addr) -#endif - - -/* Push the information about the state we will need - if we ever fail back to it. - - Requires variables fail_stack, regstart, regend, reg_info, and - num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be - declared. - - Does `return FAILURE_CODE' if runs out of memory. */ - -#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \ - do { \ - char *destination; \ - /* Must be int, so when we don't save any registers, the arithmetic \ - of 0 + -1 isn't done as unsigned. */ \ - int this_reg; \ - \ - DEBUG_STATEMENT (failure_id++); \ - DEBUG_STATEMENT (nfailure_points_pushed++); \ - DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \ - DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\ - DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\ - \ - DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ - DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \ - \ - /* Ensure we have enough space allocated for what we will push. */ \ - while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ - { \ - if (!DOUBLE_FAIL_STACK (fail_stack)) \ - return failure_code; \ - \ - DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \ - (fail_stack).size); \ - DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\ - } \ - \ - /* Push the info, starting with the registers. */ \ - DEBUG_PRINT1 ("\n"); \ - \ - for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ - this_reg++) \ - { \ - DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ - DEBUG_STATEMENT (num_regs_pushed++); \ - \ - DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ - PUSH_FAILURE_ITEM (regstart[this_reg]); \ - \ - DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ - PUSH_FAILURE_ITEM (regend[this_reg]); \ - \ - DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ - DEBUG_PRINT2 (" match_null=%d", \ - REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ - DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ - DEBUG_PRINT2 (" matched_something=%d", \ - MATCHED_SOMETHING (reg_info[this_reg])); \ - DEBUG_PRINT2 (" ever_matched=%d", \ - EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ - DEBUG_PRINT1 ("\n"); \ - PUSH_FAILURE_ITEM (reg_info[this_reg].word); \ - } \ - \ - DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ - PUSH_FAILURE_ITEM (lowest_active_reg); \ - \ - DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ - PUSH_FAILURE_ITEM (highest_active_reg); \ - \ - DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \ - DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ - PUSH_FAILURE_ITEM (pattern_place); \ - \ - DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \ - DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ - size2); \ - DEBUG_PRINT1 ("'\n"); \ - PUSH_FAILURE_ITEM (string_place); \ - \ - DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \ - DEBUG_PUSH (failure_id); \ - } while (0) - -/* This is the number of items that are pushed and popped on the stack - for each register. */ -#define NUM_REG_ITEMS 3 - -/* Individual items aside from the registers. */ -#ifdef DEBUG -#define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ -#else -#define NUM_NONREG_ITEMS 4 -#endif - -/* We push at most this many items on the stack. */ -#define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) - -/* We actually push this many items. */ -#define NUM_FAILURE_ITEMS \ - ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ - + NUM_NONREG_ITEMS) - -/* How many items can still be added to the stack without overflowing it. */ -#define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) - - -/* Pops what PUSH_FAIL_STACK pushes. - - We restore into the parameters, all of which should be lvalues: - STR -- the saved data position. - PAT -- the saved pattern position. - LOW_REG, HIGH_REG -- the highest and lowest active registers. - REGSTART, REGEND -- arrays of string positions. - REG_INFO -- array of information about each subexpression. - - Also assumes the variables `fail_stack' and (if debugging), `bufp', - `pend', `string1', `size1', `string2', and `size2'. */ - -#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\ -{ \ - DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \ - int this_reg; \ - const unsigned char *string_temp; \ - \ - assert (!FAIL_STACK_EMPTY ()); \ - \ - /* Remove failure points and point to how many regs pushed. */ \ - DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ - DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \ - DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \ - \ - assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ - \ - DEBUG_POP (&failure_id); \ - DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \ - \ - /* If the saved string location is NULL, it came from an \ - on_failure_keep_string_jump opcode, and we want to throw away the \ - saved NULL, thus retaining our current position in the string. */ \ - string_temp = POP_FAILURE_ITEM (); \ - if (string_temp != NULL) \ - str = (const char *) string_temp; \ - \ - DEBUG_PRINT2 (" Popping string 0x%x: `", str); \ - DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ - DEBUG_PRINT1 ("'\n"); \ - \ - pat = (unsigned char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \ - DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ - \ - /* Restore register info. */ \ - high_reg = (unsigned) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ - \ - low_reg = (unsigned) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ - \ - for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ - { \ - DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ - \ - reg_info[this_reg].word = POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ - \ - regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ - \ - regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ - } \ - \ - DEBUG_STATEMENT (nfailure_points_popped++); \ -} /* POP_FAILURE_POINT */ - -/* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in - BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible - characters can start a string that matches the pattern. This fastmap - is used by re_search to skip quickly over impossible starting points. - - The caller must supply the address of a (1 << BYTEWIDTH)-byte data - area as BUFP->fastmap. - - We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in - the pattern buffer. - - Returns 0 if we succeed, -2 if an internal error. */ - -int -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; -{ - int j, k; - fail_stack_type fail_stack; -#ifndef REGEX_MALLOC - char *destination; -#endif - /* We don't push any register information onto the failure stack. */ - unsigned num_regs = 0; - - register char *fastmap = bufp->fastmap; - unsigned char *pattern = bufp->buffer; - unsigned long size = bufp->used; - const unsigned char *p = pattern; - register unsigned char *pend = pattern + size; - - /* Assume that each path through the pattern can be null until - proven otherwise. We set this false at the bottom of switch - statement, to which we get only if a particular path doesn't - match the empty string. */ - boolean path_can_be_null = true; - - /* We aren't doing a `succeed_n' to begin with. */ - boolean succeed_n_p = false; - - assert (fastmap != NULL && p != NULL); - - INIT_FAIL_STACK (); - bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ - bufp->fastmap_accurate = 1; /* It will be when we're done. */ - bufp->can_be_null = 0; - - while (p != pend || !FAIL_STACK_EMPTY ()) - { - if (p == pend) - { - bufp->can_be_null |= path_can_be_null; - - /* Reset for next path. */ - path_can_be_null = true; - - p = fail_stack.stack[--fail_stack.avail]; - } - - /* We should never be about to go beyond the end of the pattern. */ - assert (p < pend); - -#ifdef SWITCH_ENUM_BUG - switch ((int) ((re_opcode_t) *p++)) -#else - switch ((re_opcode_t) *p++) -#endif - { - - /* I guess the idea here is to simply not bother with a fastmap - if a backreference is used, since it's too hard to figure out - the fastmap for the corresponding group. Setting - `can_be_null' stops `re_search_2' from using the fastmap, so - that is all we do. */ - case duplicate: - bufp->can_be_null = 1; - return 0; - - - /* Following are the cases which match a character. These end - with `break'. */ - - case exactn: - fastmap[p[1]] = 1; - break; - - - case charset: - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) - fastmap[j] = 1; - break; - - - case charset_not: - /* Chars beyond end of map must be allowed. */ - for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) - fastmap[j] = 1; - - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) - fastmap[j] = 1; - break; - - - case wordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == Sword) - fastmap[j] = 1; - break; - - - case notwordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != Sword) - fastmap[j] = 1; - break; - - - case anychar: - /* `.' matches anything ... */ - for (j = 0; j < (1 << BYTEWIDTH); j++) - fastmap[j] = 1; - - /* ... except perhaps newline. */ - if (!(bufp->syntax & RE_DOT_NEWLINE)) - fastmap['\n'] = 0; - - /* Return if we have already set `can_be_null'; if we have, - then the fastmap is irrelevant. Something's wrong here. */ - else if (bufp->can_be_null) - return 0; - - /* Otherwise, have to check alternative paths. */ - break; - - -#ifdef emacs - case syntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == (enum syntaxcode) k) - fastmap[j] = 1; - break; - - - case notsyntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != (enum syntaxcode) k) - fastmap[j] = 1; - break; - - - /* All cases after this match the empty string. These end with - `continue'. */ - - - case before_dot: - case at_dot: - case after_dot: - continue; -#endif /* not emacs */ - - - case no_op: - case begline: - case endline: - case begbuf: - case endbuf: - case wordbound: - case notwordbound: - case wordbeg: - case wordend: - case push_dummy_failure: - continue; - - - case jump_n: - case pop_failure_jump: - case maybe_pop_jump: - case jump: - case jump_past_alt: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - if (j > 0) - continue; - - /* Jump backward implies we just went through the body of a - loop and matched nothing. Opcode jumped to should be - `on_failure_jump' or `succeed_n'. Just treat it like an - ordinary jump. For a * loop, it has pushed its failure - point already; if so, discard that as redundant. */ - if ((re_opcode_t) *p != on_failure_jump - && (re_opcode_t) *p != succeed_n) - continue; - - p++; - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - - /* If what's on the stack is where we are now, pop it. */ - if (!FAIL_STACK_EMPTY () - && fail_stack.stack[fail_stack.avail - 1] == p) - fail_stack.avail--; - - continue; - - - case on_failure_jump: - case on_failure_keep_string_jump: - handle_on_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - - /* For some patterns, e.g., `(a?)?', `p+j' here points to the - end of the pattern. We don't want to push such a point, - since when we restore it above, entering the switch will - increment `p' past the end of the pattern. We don't need - to push such a point since we obviously won't find any more - fastmap entries beyond `pend'. Such a pattern can match - the null string, though. */ - if (p + j < pend) - { - if (!PUSH_PATTERN_OP (p + j, fail_stack)) - return -2; - } - else - bufp->can_be_null = 1; - - if (succeed_n_p) - { - EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ - succeed_n_p = false; - } - - continue; - - - case succeed_n: - /* Get to the number of times to succeed. */ - p += 2; - - /* Increment p past the n for when k != 0. */ - EXTRACT_NUMBER_AND_INCR (k, p); - if (k == 0) - { - p -= 4; - succeed_n_p = true; /* Spaghetti code alert. */ - goto handle_on_failure_jump; - } - continue; - - - case set_number_at: - p += 4; - continue; - - - case start_memory: - case stop_memory: - p += 2; - continue; - - - default: - abort (); /* We have listed all the cases. */ - } /* switch *p++ */ - - /* Getting here means we have found the possible starting - characters for one path of the pattern -- and that the empty - string does not match. We need not follow this path further. - Instead, look at the next alternative (remembered on the - stack), or quit if no more. The test at the top of the loop - does these things. */ - path_can_be_null = false; - p = pend; - } /* while p */ - - /* Set `can_be_null' for the last path (also the first path, if the - pattern is empty). */ - bufp->can_be_null |= path_can_be_null; - return 0; -} /* re_compile_fastmap */ - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use - this memory for recording register information. STARTS and ENDS - must be allocated using the malloc library routine, and must each - be at least NUM_REGS * sizeof (regoff_t) bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ - -void -re_set_registers (bufp, regs, num_regs, starts, ends) - struct re_pattern_buffer *bufp; - struct re_registers *regs; - unsigned num_regs; - regoff_t *starts, *ends; -{ - if (num_regs) - { - bufp->regs_allocated = REGS_REALLOCATE; - regs->num_regs = num_regs; - regs->start = starts; - regs->end = ends; - } - else - { - bufp->regs_allocated = REGS_UNALLOCATED; - regs->num_regs = 0; - regs->start = regs->end = (regoff_t) 0; - } -} - -/* Searching routines. */ - -/* Like re_search_2, below, but only one string is specified, and - doesn't let you say where to stop matching. */ - -int -re_search (bufp, string, size, startpos, range, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, startpos, range; - struct re_registers *regs; -{ - return re_search_2 (bufp, NULL, 0, string, size, startpos, range, - regs, size); -} - - -/* Using the compiled pattern in BUFP->buffer, first tries to match the - virtual concatenation of STRING1 and STRING2, starting first at index - STARTPOS, then at STARTPOS + 1, and so on. - - STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. - - RANGE is how far to scan while trying to match. RANGE = 0 means try - only at STARTPOS; in general, the last start tried is STARTPOS + - RANGE. - - In REGS, return the indices of the virtual concatenation of STRING1 - and STRING2 that matched the entire BUFP->buffer and its contained - subexpressions. - - Do not consider matching one past the index STOP in the virtual - concatenation of STRING1 and STRING2. - - We return either the position in the strings at which the match was - found, -1 if no match, or -2 if error (such as failure - stack overflow). */ - -int -re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int size1, size2; - int startpos; - int range; - struct re_registers *regs; - int stop; -{ - int val; - register char *fastmap = bufp->fastmap; - register char *translate = bufp->translate; - int total_size = size1 + size2; - int endpos = startpos + range; - - /* Check for out-of-range STARTPOS. */ - if (startpos < 0 || startpos > total_size) - return -1; - - /* Fix up RANGE if it might eventually take us outside - the virtual concatenation of STRING1 and STRING2. */ - if (endpos < -1) - range = -1 - startpos; - else if (endpos > total_size) - range = total_size - startpos; - - /* If the search isn't to be a backwards one, don't waste time in a - search for a pattern that must be anchored. */ - if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) - { - if (startpos > 0) - return -1; - else - range = 1; - } - - /* Update the fastmap now if not correct already. */ - if (fastmap && !bufp->fastmap_accurate) - if (re_compile_fastmap (bufp) == -2) - return -2; - - /* Loop through the string, looking for a place to start matching. */ - for (;;) - { - /* If a fastmap is supplied, skip quickly over characters that - cannot be the start of a match. If the pattern can match the - null string, however, we don't need to skip characters; we want - the first null string. */ - if (fastmap && startpos < total_size && !bufp->can_be_null) - { - if (range > 0) /* Searching forwards. */ - { - register const char *d; - register int lim = 0; - int irange = range; - - if (startpos < size1 && startpos + range >= size1) - lim = range - (size1 - startpos); - - d = (startpos >= size1 ? string2 - size1 : string1) + startpos; - - /* Written out as an if-else to avoid testing `translate' - inside the loop. */ - if (translate) - while (range > lim - && !fastmap[(unsigned char) - translate[(unsigned char) *d++]]) - range--; - else - while (range > lim && !fastmap[(unsigned char) *d++]) - range--; - - startpos += irange - range; - } - else /* Searching backwards. */ - { - register char c = (size1 == 0 || startpos >= size1 - ? string2[startpos - size1] - : string1[startpos]); - - if (!fastmap[(unsigned char) TRANSLATE (c)]) - goto advance; - } - } - - /* If can't match the null string, and that's all we have left, fail. */ - if (range >= 0 && startpos == total_size && fastmap - && !bufp->can_be_null) - return -1; - - val = re_match_2 (bufp, string1, size1, string2, size2, - startpos, regs, stop); - if (val >= 0) - return startpos; - - if (val == -2) - return -2; - - advance: - if (!range) - break; - else if (range > 0) - { - range--; - startpos++; - } - else - { - range++; - startpos--; - } - } - return -1; -} /* re_search_2 */ - -/* Declarations and macros for re_match_2. */ - -static int bcmp_translate (); -static boolean alt_match_null_string_p (), - common_op_match_null_string_p (), - group_match_null_string_p (); - -/* Structure for per-register (a.k.a. per-group) information. - This must not be longer than one word, because we push this value - onto the failure stack. Other register information, such as the - starting and ending positions (which are addresses), and the list of - inner groups (which is a bits list) are maintained in separate - variables. - - We are making a (strictly speaking) nonportable assumption here: that - the compiler will pack our bit fields into something that fits into - the type of `word', i.e., is something that fits into one item on the - failure stack. */ -typedef union -{ - fail_stack_elt_t word; - struct - { - /* This field is one if this group can match the empty string, - zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ -#define MATCH_NULL_UNSET_VALUE 3 - unsigned match_null_string_p : 2; - unsigned is_active : 1; - unsigned matched_something : 1; - unsigned ever_matched_something : 1; - } bits; -} register_info_type; - -#define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) -#define IS_ACTIVE(R) ((R).bits.is_active) -#define MATCHED_SOMETHING(R) ((R).bits.matched_something) -#define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) - - -/* Call this when have matched a real character; it sets `matched' flags - for the subexpressions which we are currently inside. Also records - that those subexprs have matched. */ -#define SET_REGS_MATCHED() \ - do \ - { \ - unsigned r; \ - for (r = lowest_active_reg; r <= highest_active_reg; r++) \ - { \ - MATCHED_SOMETHING (reg_info[r]) \ - = EVER_MATCHED_SOMETHING (reg_info[r]) \ - = 1; \ - } \ - } \ - while (0) - - -/* This converts PTR, a pointer into one of the search strings `string1' - and `string2' into an offset from the beginning of that string. */ -#define POINTER_TO_OFFSET(ptr) \ - (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1) - -/* Registers are set to a sentinel when they haven't yet matched. */ -#define REG_UNSET_VALUE ((char *) -1) -#define REG_UNSET(e) ((e) == REG_UNSET_VALUE) - - -/* Macros for dealing with the split strings in re_match_2. */ - -#define MATCHING_IN_FIRST_STRING (dend == end_match_1) - -/* Call before fetching a character with *d. This switches over to - string2 if necessary. */ -#define PREFETCH() \ - while (d == dend) \ - { \ - /* End of string2 => fail. */ \ - if (dend == end_match_2) \ - goto fail; \ - /* End of string1 => advance to string2. */ \ - d = string2; \ - dend = end_match_2; \ - } - - -/* Test if at very beginning or at very end of the virtual concatenation - of `string1' and `string2'. If only one string, it's `string2'. */ -#define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) -#define AT_STRINGS_END(d) ((d) == end2) - - -/* Test if D points to a character which is word-constituent. We have - two special cases to check for: if past the end of string1, look at - the first character in string2; and if before the beginning of - string2, look at the last character in string1. */ -#define WORDCHAR_P(d) \ - (SYNTAX ((d) == end1 ? *string2 \ - : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ - == Sword) - -/* Test if the character before D and the one at D differ with respect - to being word-constituent. */ -#define AT_WORD_BOUNDARY(d) \ - (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \ - || WORDCHAR_P (d - 1) != WORDCHAR_P (d)) - - -/* Free everything we malloc. */ -#ifdef REGEX_MALLOC -#define FREE_VAR(var) if (var) free (var); var = NULL -#define FREE_VARIABLES() \ - do { \ - FREE_VAR (fail_stack.stack); \ - FREE_VAR (regstart); \ - FREE_VAR (regend); \ - FREE_VAR (old_regstart); \ - FREE_VAR (old_regend); \ - FREE_VAR (best_regstart); \ - FREE_VAR (best_regend); \ - FREE_VAR (reg_info); \ - FREE_VAR (reg_dummy); \ - FREE_VAR (reg_info_dummy); \ - } while (0) -#else /* not REGEX_MALLOC */ -/* Some MIPS systems (at least) want this to free alloca'd storage. */ -#define FREE_VARIABLES() alloca (0) -#endif /* not REGEX_MALLOC */ - - -/* These values must meet several constraints. They must not be valid - register values; since we have a limit of 255 registers (because - we use only one byte in the pattern for the register number), we can - use numbers larger than 255. They must differ by 1, because of - NUM_FAILURE_ITEMS above. And the value for the lowest register must - be larger than the value for the highest register, so we do not try - to actually save any registers when none are active. */ -#define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH) -#define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) - -/* Matching routines. */ - -#ifndef emacs /* Emacs never uses this. */ -/* re_match is like re_match_2 except it takes only a single string. */ - -int -re_match (bufp, string, size, pos, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, pos; - struct re_registers *regs; - { - return re_match_2 (bufp, NULL, 0, string, size, pos, regs, size); -} -#endif /* not emacs */ - - -/* re_match_2 matches the compiled pattern in BUFP against the - the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 - and SIZE2, respectively). We start matching at POS, and stop - matching at STOP. - - If REGS is non-null and the `no_sub' field of BUFP is nonzero, we - store offsets for the substring each group matched in REGS. See the - documentation for exactly how many groups we fill. - - We return -1 if no match, -2 if an internal error (such as the - failure stack overflowing). Otherwise, we return the length of the - matched substring. */ - -int -re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int size1, size2; - int pos; - struct re_registers *regs; - int stop; -{ - /* General temporaries. */ - int mcnt; - unsigned char *p1; - - /* Just past the end of the corresponding string. */ - const char *end1, *end2; - - /* Pointers into string1 and string2, just past the last characters in - each to consider matching. */ - const char *end_match_1, *end_match_2; - - /* Where we are in the data, and the end of the current string. */ - const char *d, *dend; - - /* Where we are in the pattern, and the end of the pattern. */ - unsigned char *p = bufp->buffer; - register unsigned char *pend = p + bufp->used; - - /* We use this to map every character in the string. */ - char *translate = bufp->translate; - - /* Failure point stack. Each place that can handle a failure further - down the line pushes a failure point on this stack. It consists of - restart, regend, and reg_info for all registers corresponding to - the subexpressions we're currently inside, plus the number of such - registers, and, finally, two char *'s. The first char * is where - to resume scanning the pattern; the second one is where to resume - scanning the strings. If the latter is zero, the failure point is - a ``dummy''; if a failure happens and the failure point is a dummy, - it gets discarded and the next next one is tried. */ - fail_stack_type fail_stack; -#ifdef DEBUG - static unsigned failure_id = 0; - unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; -#endif - - /* We fill all the registers internally, independent of what we - return, for use in backreferences. The number here includes - an element for register zero. */ - unsigned num_regs = bufp->re_nsub + 1; - - /* The currently active registers. */ - unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG; - unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG; - - /* Information on the contents of registers. These are pointers into - the input strings; they record just what was matched (on this - attempt) by a subexpression part of the pattern, that is, the - regnum-th regstart pointer points to where in the pattern we began - matching and the regnum-th regend points to right after where we - stopped matching the regnum-th subexpression. (The zeroth register - keeps track of what the whole pattern matches.) */ - const char **regstart, **regend; - - /* If a group that's operated upon by a repetition operator fails to - match anything, then the register for its start will need to be - restored because it will have been set to wherever in the string we - are when we last see its open-group operator. Similarly for a - register's end. */ - const char **old_regstart, **old_regend; - - /* The is_active field of reg_info helps us keep track of which (possibly - nested) subexpressions we are currently in. The matched_something - field of reg_info[reg_num] helps us tell whether or not we have - matched any of the pattern so far this time through the reg_num-th - subexpression. These two fields get reset each time through any - loop their register is in. */ - register_info_type *reg_info; - - /* The following record the register info as found in the above - variables when we find a match better than any we've seen before. - This happens as we backtrack through the failure points, which in - turn happens only if we have not yet matched the entire string. */ - unsigned best_regs_set = false; - const char **best_regstart, **best_regend; - - /* Logically, this is `best_regend[0]'. But we don't want to have to - allocate space for that if we're not allocating space for anything - else (see below). Also, we never need info about register 0 for - any of the other register vectors, and it seems rather a kludge to - treat `best_regend' differently than the rest. So we keep track of - the end of the best match so far in a separate variable. We - initialize this to NULL so that when we backtrack the first time - and need to test it, it's not garbage. */ - const char *match_end = NULL; - - /* Used when we pop values we don't care about. */ - const char **reg_dummy; - register_info_type *reg_info_dummy; - -#ifdef DEBUG - /* Counts the total number of registers pushed. */ - unsigned num_regs_pushed = 0; -#endif - - DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); - - INIT_FAIL_STACK (); - - /* Do not bother to initialize all the register variables if there are - no groups in the pattern, as it takes a fair amount of time. If - there are groups, we include space for register 0 (the whole - pattern), even though we never use it, since it simplifies the - array indexing. We should fix this. */ - if (bufp->re_nsub) - { - regstart = REGEX_TALLOC (num_regs, const char *); - regend = REGEX_TALLOC (num_regs, const char *); - old_regstart = REGEX_TALLOC (num_regs, const char *); - old_regend = REGEX_TALLOC (num_regs, const char *); - best_regstart = REGEX_TALLOC (num_regs, const char *); - best_regend = REGEX_TALLOC (num_regs, const char *); - reg_info = REGEX_TALLOC (num_regs, register_info_type); - reg_dummy = REGEX_TALLOC (num_regs, const char *); - reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); - - if (!(regstart && regend && old_regstart && old_regend && reg_info - && best_regstart && best_regend && reg_dummy && reg_info_dummy)) - { - FREE_VARIABLES (); - return -2; - } - } -#ifdef REGEX_MALLOC - else - { - /* We must initialize all our variables to NULL, so that - `FREE_VARIABLES' doesn't try to free them. */ - regstart = regend = old_regstart = old_regend = best_regstart - = best_regend = reg_dummy = NULL; - reg_info = reg_info_dummy = (register_info_type *) NULL; - } -#endif /* REGEX_MALLOC */ - - /* The starting position is bogus. */ - if (pos < 0 || pos > size1 + size2) - { - FREE_VARIABLES (); - return -1; - } - - /* Initialize subexpression text positions to -1 to mark ones that no - start_memory/stop_memory has been seen for. Also initialize the - register information struct. */ - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - regstart[mcnt] = regend[mcnt] - = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE; - - REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; - IS_ACTIVE (reg_info[mcnt]) = 0; - MATCHED_SOMETHING (reg_info[mcnt]) = 0; - EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; - } - - /* We move `string1' into `string2' if the latter's empty -- but not if - `string1' is null. */ - if (size2 == 0 && string1 != NULL) - { - string2 = string1; - size2 = size1; - string1 = 0; - size1 = 0; - } - end1 = string1 + size1; - end2 = string2 + size2; - - /* Compute where to stop matching, within the two strings. */ - if (stop <= size1) - { - end_match_1 = string1 + stop; - end_match_2 = string2; - } - else - { - end_match_1 = end1; - end_match_2 = string2 + stop - size1; - } - - /* `p' scans through the pattern as `d' scans through the data. - `dend' is the end of the input string that `d' points within. `d' - is advanced into the following input string whenever necessary, but - this happens before fetching; therefore, at the beginning of the - loop, `d' can be pointing at the end of a string, but it cannot - equal `string2'. */ - if (size1 > 0 && pos <= size1) - { - d = string1 + pos; - dend = end_match_1; - } - else - { - d = string2 + pos - size1; - dend = end_match_2; - } - - DEBUG_PRINT1 ("The compiled pattern is: "); - DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend); - DEBUG_PRINT1 ("The string to match is: `"); - DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); - DEBUG_PRINT1 ("'\n"); - - /* This loops over pattern commands. It exits by returning from the - function if the match is complete, or it drops through if the match - fails at this starting point in the input data. */ - for (;;) - { - DEBUG_PRINT2 ("\n0x%x: ", p); - - if (p == pend) - { /* End of pattern means we might have succeeded. */ - DEBUG_PRINT1 ("end of pattern ... "); - - /* If we haven't matched the entire string, and we want the - longest match, try backtracking. */ - if (d != end_match_2) - { - DEBUG_PRINT1 ("backtracking.\n"); - - if (!FAIL_STACK_EMPTY ()) - { /* More failure points to try. */ - boolean same_str_p = (FIRST_STRING_P (match_end) - == MATCHING_IN_FIRST_STRING); - - /* If exceeds best match so far, save it. */ - if (!best_regs_set - || (same_str_p && d > match_end) - || (!same_str_p && !MATCHING_IN_FIRST_STRING)) - { - best_regs_set = true; - match_end = d; - - DEBUG_PRINT1 ("\nSAVING match as best so far.\n"); - - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - best_regstart[mcnt] = regstart[mcnt]; - best_regend[mcnt] = regend[mcnt]; - } - } - goto fail; - } - - /* If no failure points, don't restore garbage. */ - else if (best_regs_set) - { - restore_best_regs: - /* Restore best match. It may happen that `dend == - end_match_1' while the restored d is in string2. - For example, the pattern `x.*y.*z' against the - strings `x-' and `y-z-', if the two strings are - not consecutive in memory. */ - DEBUG_PRINT1 ("Restoring best registers.\n"); - - d = match_end; - dend = ((d >= string1 && d <= end1) - ? end_match_1 : end_match_2); - - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - regstart[mcnt] = best_regstart[mcnt]; - regend[mcnt] = best_regend[mcnt]; - } - } - } /* d != end_match_2 */ - - DEBUG_PRINT1 ("Accepting match.\n"); - - /* If caller wants register contents data back, do it. */ - if (regs && !bufp->no_sub) - { - /* Have the register data arrays been allocated? */ - if (bufp->regs_allocated == REGS_UNALLOCATED) - { /* No. So allocate them with malloc. We need one - extra element beyond `num_regs' for the `-1' marker - GNU code uses. */ - regs->num_regs = MAX (RE_NREGS, num_regs + 1); - regs->start = TALLOC (regs->num_regs, regoff_t); - regs->end = TALLOC (regs->num_regs, regoff_t); - if (regs->start == NULL || regs->end == NULL) - return -2; - bufp->regs_allocated = REGS_REALLOCATE; - } - else if (bufp->regs_allocated == REGS_REALLOCATE) - { /* Yes. If we need more elements than were already - allocated, reallocate them. If we need fewer, just - leave it alone. */ - if (regs->num_regs < num_regs + 1) - { - regs->num_regs = num_regs + 1; - RETALLOC (regs->start, regs->num_regs, regoff_t); - RETALLOC (regs->end, regs->num_regs, regoff_t); - if (regs->start == NULL || regs->end == NULL) - return -2; - } - } - else - assert (bufp->regs_allocated == REGS_FIXED); - - /* Convert the pointer data in `regstart' and `regend' to - indices. Register zero has to be set differently, - since we haven't kept track of any info for it. */ - if (regs->num_regs > 0) - { - regs->start[0] = pos; - regs->end[0] = (MATCHING_IN_FIRST_STRING ? d - string1 - : d - string2 + size1); - } - - /* Go through the first `min (num_regs, regs->num_regs)' - registers, since that is all we initialized. */ - for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++) - { - if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt])) - regs->start[mcnt] = regs->end[mcnt] = -1; - else - { - regs->start[mcnt] = POINTER_TO_OFFSET (regstart[mcnt]); - regs->end[mcnt] = POINTER_TO_OFFSET (regend[mcnt]); - } - } - - /* If the regs structure we return has more elements than - were in the pattern, set the extra elements to -1. If - we (re)allocated the registers, this is the case, - because we always allocate enough to have at least one - -1 at the end. */ - for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++) - regs->start[mcnt] = regs->end[mcnt] = -1; - } /* regs && !bufp->no_sub */ - - FREE_VARIABLES (); - DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", - nfailure_points_pushed, nfailure_points_popped, - nfailure_points_pushed - nfailure_points_popped); - DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); - - mcnt = d - pos - (MATCHING_IN_FIRST_STRING - ? string1 - : string2 - size1); - - DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); - - return mcnt; - } - - /* Otherwise match next pattern command. */ -#ifdef SWITCH_ENUM_BUG - switch ((int) ((re_opcode_t) *p++)) -#else - switch ((re_opcode_t) *p++) -#endif - { - /* Ignore these. Used to ignore the n of succeed_n's which - currently have n == 0. */ - case no_op: - DEBUG_PRINT1 ("EXECUTING no_op.\n"); - break; - - - /* Match the next n pattern characters exactly. The following - byte in the pattern defines n, and the n bytes after that - are the characters to match. */ - case exactn: - mcnt = *p++; - DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt); - - /* This is written out as an if-else so we don't waste time - testing `translate' inside the loop. */ - if (translate) - { - do - { - PREFETCH (); - if (translate[(unsigned char) *d++] != (char) *p++) - goto fail; - } - while (--mcnt); - } - else - { - do - { - PREFETCH (); - if (*d++ != (char) *p++) goto fail; - } - while (--mcnt); - } - SET_REGS_MATCHED (); - break; - - - /* Match any character except possibly a newline or a null. */ - case anychar: - DEBUG_PRINT1 ("EXECUTING anychar.\n"); - - PREFETCH (); - - if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n') - || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000')) - goto fail; - - SET_REGS_MATCHED (); - DEBUG_PRINT2 (" Matched `%d'.\n", *d); - d++; - break; - - - case charset: - case charset_not: - { - register unsigned char c; - boolean not = (re_opcode_t) *(p - 1) == charset_not; - - DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); - - PREFETCH (); - c = TRANSLATE (*d); /* The character to match. */ - - /* Cast to `unsigned' instead of `unsigned char' in case the - bit list is a full 32 bytes long. */ - if (c < (unsigned) (*p * BYTEWIDTH) - && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - p += 1 + *p; - - if (!not) goto fail; - - SET_REGS_MATCHED (); - d++; - break; - } - - - /* The beginning of a group is represented by start_memory. - The arguments are the register number in the next byte, and the - number of groups inner to this one in the next. The text - matched within the group is recorded (in the internal - registers data structure) under the register number. */ - case start_memory: - DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]); - - /* Find out if this group can match the empty string. */ - p1 = p; /* To send to group_match_null_string_p. */ - - if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) - REG_MATCH_NULL_STRING_P (reg_info[*p]) - = group_match_null_string_p (&p1, pend, reg_info); - - /* Save the position in the string where we were the last time - we were at this open-group operator in case the group is - operated upon by a repetition operator, e.g., with `(a*)*b' - against `ab'; then we want to ignore where we are now in - the string in case this attempt to match fails. */ - old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) - ? REG_UNSET (regstart[*p]) ? d : regstart[*p] - : regstart[*p]; - DEBUG_PRINT2 (" old_regstart: %d\n", - POINTER_TO_OFFSET (old_regstart[*p])); - - regstart[*p] = d; - DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p])); - - IS_ACTIVE (reg_info[*p]) = 1; - MATCHED_SOMETHING (reg_info[*p]) = 0; - - /* This is the new highest active register. */ - highest_active_reg = *p; - - /* If nothing was active before, this is the new lowest active - register. */ - if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) - lowest_active_reg = *p; - - /* Move past the register number and inner group count. */ - p += 2; - break; - - - /* The stop_memory opcode represents the end of a group. Its - arguments are the same as start_memory's: the register - number, and the number of inner groups. */ - case stop_memory: - DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]); - - /* We need to save the string position the last time we were at - this close-group operator in case the group is operated - upon by a repetition operator, e.g., with `((a*)*(b*)*)*' - against `aba'; then we want to ignore where we are now in - the string in case this attempt to match fails. */ - old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) - ? REG_UNSET (regend[*p]) ? d : regend[*p] - : regend[*p]; - DEBUG_PRINT2 (" old_regend: %d\n", - POINTER_TO_OFFSET (old_regend[*p])); - - regend[*p] = d; - DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p])); - - /* This register isn't active anymore. */ - IS_ACTIVE (reg_info[*p]) = 0; - - /* If this was the only register active, nothing is active - anymore. */ - if (lowest_active_reg == highest_active_reg) - { - lowest_active_reg = NO_LOWEST_ACTIVE_REG; - highest_active_reg = NO_HIGHEST_ACTIVE_REG; - } - else - { /* We must scan for the new highest active register, since - it isn't necessarily one less than now: consider - (a(b)c(d(e)f)g). When group 3 ends, after the f), the - new highest active register is 1. */ - unsigned char r = *p - 1; - while (r > 0 && !IS_ACTIVE (reg_info[r])) - r--; - - /* If we end up at register zero, that means that we saved - the registers as the result of an `on_failure_jump', not - a `start_memory', and we jumped to past the innermost - `stop_memory'. For example, in ((.)*) we save - registers 1 and 2 as a result of the *, but when we pop - back to the second ), we are at the stop_memory 1. - Thus, nothing is active. */ - if (r == 0) - { - lowest_active_reg = NO_LOWEST_ACTIVE_REG; - highest_active_reg = NO_HIGHEST_ACTIVE_REG; - } - else - highest_active_reg = r; - } - - /* If just failed to match something this time around with a - group that's operated on by a repetition operator, try to - force exit from the ``loop'', and restore the register - information for this group that we had before trying this - last match. */ - if ((!MATCHED_SOMETHING (reg_info[*p]) - || (re_opcode_t) p[-3] == start_memory) - && (p + 2) < pend) - { - boolean is_a_jump_n = false; - - p1 = p + 2; - mcnt = 0; - switch ((re_opcode_t) *p1++) - { - case jump_n: - is_a_jump_n = true; - case pop_failure_jump: - case maybe_pop_jump: - case jump: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if (is_a_jump_n) - p1 += 2; - break; - - default: - /* do nothing */ ; - } - p1 += mcnt; - - /* If the next operation is a jump backwards in the pattern - to an on_failure_jump right before the start_memory - corresponding to this stop_memory, exit from the loop - by forcing a failure after pushing on the stack the - on_failure_jump's jump in the pattern, and d. */ - if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump - && (re_opcode_t) p1[3] == start_memory && p1[4] == *p) - { - /* If this group ever matched anything, then restore - what its registers were before trying this last - failed match, e.g., with `(a*)*b' against `ab' for - regstart[1], and, e.g., with `((a*)*(b*)*)*' - against `aba' for regend[3]. - - Also restore the registers for inner groups for, - e.g., `((a*)(b*))*' against `aba' (register 3 would - otherwise get trashed). */ - - if (EVER_MATCHED_SOMETHING (reg_info[*p])) - { - unsigned r; - - EVER_MATCHED_SOMETHING (reg_info[*p]) = 0; - - /* Restore this and inner groups' (if any) registers. */ - for (r = *p; r < *p + *(p + 1); r++) - { - regstart[r] = old_regstart[r]; - - /* xx why this test? */ - if ((int) old_regend[r] >= (int) regstart[r]) - regend[r] = old_regend[r]; - } - } - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - PUSH_FAILURE_POINT (p1 + mcnt, d, -2); - - goto fail; - } - } - - /* Move past the register number and the inner group count. */ - p += 2; - break; - - - /* \ has been turned into a `duplicate' command which is - followed by the numeric value of as the register number. */ - case duplicate: - { - register const char *d2, *dend2; - int regno = *p++; /* Get which register to match against. */ - DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno); - - /* Can't back reference a group which we've never matched. */ - if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) - goto fail; - - /* Where in input to try to start matching. */ - d2 = regstart[regno]; - - /* Where to stop matching; if both the place to start and - the place to stop matching are in the same string, then - set to the place to stop, otherwise, for now have to use - the end of the first string. */ - - dend2 = ((FIRST_STRING_P (regstart[regno]) - == FIRST_STRING_P (regend[regno])) - ? regend[regno] : end_match_1); - for (;;) - { - /* If necessary, advance to next segment in register - contents. */ - while (d2 == dend2) - { - if (dend2 == end_match_2) break; - if (dend2 == regend[regno]) break; - - /* End of string1 => advance to string2. */ - d2 = string2; - dend2 = regend[regno]; - } - /* At end of register contents => success */ - if (d2 == dend2) break; - - /* If necessary, advance to next segment in data. */ - PREFETCH (); - - /* How many characters left in this segment to match. */ - mcnt = dend - d; - - /* Want how many consecutive characters we can match in - one shot, so, if necessary, adjust the count. */ - if (mcnt > dend2 - d2) - mcnt = dend2 - d2; - - /* Compare that many; failure if mismatch, else move - past them. */ - if (translate - ? bcmp_translate (d, d2, mcnt, translate) - : bcmp (d, d2, mcnt)) - goto fail; - d += mcnt, d2 += mcnt; - } - } - break; - - - /* begline matches the empty string at the beginning of the string - (unless `not_bol' is set in `bufp'), and, if - `newline_anchor' is set, after newlines. */ - case begline: - DEBUG_PRINT1 ("EXECUTING begline.\n"); - - if (AT_STRINGS_BEG (d)) - { - if (!bufp->not_bol) break; - } - else if (d[-1] == '\n' && bufp->newline_anchor) - { - break; - } - /* In all other cases, we fail. */ - goto fail; - - - /* endline is the dual of begline. */ - case endline: - DEBUG_PRINT1 ("EXECUTING endline.\n"); - - if (AT_STRINGS_END (d)) - { - if (!bufp->not_eol) break; - } - - /* We have to ``prefetch'' the next character. */ - else if ((d == end1 ? *string2 : *d) == '\n' - && bufp->newline_anchor) - { - break; - } - goto fail; - - - /* Match at the very beginning of the data. */ - case begbuf: - DEBUG_PRINT1 ("EXECUTING begbuf.\n"); - if (AT_STRINGS_BEG (d)) - break; - goto fail; - - - /* Match at the very end of the data. */ - case endbuf: - DEBUG_PRINT1 ("EXECUTING endbuf.\n"); - if (AT_STRINGS_END (d)) - break; - goto fail; - - - /* on_failure_keep_string_jump is used to optimize `.*\n'. It - pushes NULL as the value for the string on the stack. Then - `pop_failure_point' will keep the current value for the - string, instead of restoring it. To see why, consider - matching `foo\nbar' against `.*\n'. The .* matches the foo; - then the . fails against the \n. But the next thing we want - to do is match the \n against the \n; if we restored the - string value, we would be back at the foo. - - Because this is used only in specific cases, we don't need to - check all the things that `on_failure_jump' does, to make - sure the right things get saved on the stack. Hence we don't - share its code. The only reason to push anything on the - stack at all is that otherwise we would have to change - `anychar's code to do something besides goto fail in this - case; that seems worse than this. */ - case on_failure_keep_string_jump: - DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt); - - PUSH_FAILURE_POINT (p + mcnt, NULL, -2); - break; - - - /* Uses of on_failure_jump: - - Each alternative starts with an on_failure_jump that points - to the beginning of the next alternative. Each alternative - except the last ends with a jump that in effect jumps past - the rest of the alternatives. (They really jump to the - ending jump of the following alternative, because tensioning - these jumps is a hassle.) - - Repeats start with an on_failure_jump that points past both - the repetition text and either the following jump or - pop_failure_jump back to this on_failure_jump. */ - case on_failure_jump: - on_failure: - DEBUG_PRINT1 ("EXECUTING on_failure_jump"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt); - - /* If this on_failure_jump comes right before a group (i.e., - the original * applied to a group), save the information - for that group and all inner ones, so that if we fail back - to this point, the group's information will be correct. - For example, in \(a*\)*\1, we need the preceding group, - and in \(\(a*\)b*\)\2, we need the inner group. */ - - /* We can't use `p' to check ahead because we push - a failure point to `p + mcnt' after we do this. */ - p1 = p; - - /* We need to skip no_op's before we look for the - start_memory in case this on_failure_jump is happening as - the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 - against aba. */ - while (p1 < pend && (re_opcode_t) *p1 == no_op) - p1++; - - if (p1 < pend && (re_opcode_t) *p1 == start_memory) - { - /* We have a new highest active register now. This will - get reset at the start_memory we are about to get to, - but we will have saved all the registers relevant to - this repetition op, as described above. */ - highest_active_reg = *(p1 + 1) + *(p1 + 2); - if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) - lowest_active_reg = *(p1 + 1); - } - - DEBUG_PRINT1 (":\n"); - PUSH_FAILURE_POINT (p + mcnt, d, -2); - break; - - - /* A smart repeat ends with `maybe_pop_jump'. - We change it to either `pop_failure_jump' or `jump'. */ - case maybe_pop_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); - { - register unsigned char *p2 = p; - - /* Compare the beginning of the repeat with what in the - pattern follows its end. If we can establish that there - is nothing that they would both match, i.e., that we - would have to backtrack because of (as in, e.g., `a*a') - then we can change to pop_failure_jump, because we'll - never have to backtrack. - - This is not true in the case of alternatives: in - `(a|ab)*' we do need to backtrack to the `ab' alternative - (e.g., if the string was `ab'). But instead of trying to - detect that here, the alternative has put on a dummy - failure point which is what we will end up popping. */ - - /* Skip over open/close-group commands. */ - while (p2 + 2 < pend - && ((re_opcode_t) *p2 == stop_memory - || (re_opcode_t) *p2 == start_memory)) - p2 += 3; /* Skip over args, too. */ - - /* If we're at the end of the pattern, we can change. */ - if (p2 == pend) - { - /* Consider what happens when matching ":\(.*\)" - against ":/". I don't really understand this code - yet. */ - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT1 - (" End of pattern: change to `pop_failure_jump'.\n"); - } - - else if ((re_opcode_t) *p2 == exactn - || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) - { - register unsigned char c - = *p2 == (unsigned char) endline ? '\n' : p2[2]; - p1 = p + mcnt; - - /* p1[0] ... p1[2] are the `on_failure_jump' corresponding - to the `maybe_finalize_jump' of this case. Examine what - follows. */ - if ((re_opcode_t) p1[3] == exactn && p1[5] != c) - { - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", - c, p1[5]); - } - - else if ((re_opcode_t) p1[3] == charset - || (re_opcode_t) p1[3] == charset_not) - { - int not = (re_opcode_t) p1[3] == charset_not; - - if (c < (unsigned char) (p1[4] * BYTEWIDTH) - && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - /* `not' is equal to 1 if c would match, which means - that we can't change to pop_failure_jump. */ - if (!not) - { - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); - } - } - } - } - p -= 2; /* Point at relative address again. */ - if ((re_opcode_t) p[-1] != pop_failure_jump) - { - p[-1] = (unsigned char) jump; - DEBUG_PRINT1 (" Match => jump.\n"); - goto unconditional_jump; - } - /* Note fall through. */ - - - /* The end of a simple repeat has a pop_failure_jump back to - its matching on_failure_jump, where the latter will push a - failure point. The pop_failure_jump takes off failure - points put on by this pop_failure_jump's matching - on_failure_jump; we got through the pattern to here from the - matching on_failure_jump, so didn't fail. */ - case pop_failure_jump: - { - /* We need to pass separate storage for the lowest and - highest registers, even though we don't care about the - actual values. Otherwise, we will restore only one - register from the stack, since lowest will == highest in - `pop_failure_point'. */ - unsigned dummy_low_reg, dummy_high_reg; - unsigned char *pdummy; - const char *sdummy; - - DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n"); - POP_FAILURE_POINT (sdummy, pdummy, - dummy_low_reg, dummy_high_reg, - reg_dummy, reg_dummy, reg_info_dummy); - } - /* Note fall through. */ - - - /* Unconditionally jump (without popping any failure points). */ - case jump: - unconditional_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ - DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); - p += mcnt; /* Do the jump. */ - DEBUG_PRINT2 ("(to 0x%x).\n", p); - break; - - - /* We need this opcode so we can detect where alternatives end - in `group_match_null_string_p' et al. */ - case jump_past_alt: - DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n"); - goto unconditional_jump; - - - /* Normally, the on_failure_jump pushes a failure point, which - then gets popped at pop_failure_jump. We will end up at - pop_failure_jump, also, and with a pattern of, say, `a+', we - are skipping over the on_failure_jump, so we have to push - something meaningless for pop_failure_jump to pop. */ - case dummy_failure_jump: - DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n"); - /* It doesn't matter what we push for the string here. What - the code at `fail' tests is the value for the pattern. */ - PUSH_FAILURE_POINT (0, 0, -2); - goto unconditional_jump; - - - /* At the end of an alternative, we need to push a dummy failure - point in case we are followed by a `pop_failure_jump', because - we don't want the failure point for the alternative to be - popped. For example, matching `(a|ab)*' against `aab' - requires that we match the `ab' alternative. */ - case push_dummy_failure: - DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); - /* See comments just above at `dummy_failure_jump' about the - two zeroes. */ - PUSH_FAILURE_POINT (0, 0, -2); - break; - - /* Have to succeed matching what follows at least n times. - After that, handle like `on_failure_jump'. */ - case succeed_n: - EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); - - assert (mcnt >= 0); - /* Originally, this is how many times we HAVE to succeed. */ - if (mcnt > 0) - { - mcnt--; - p += 2; - STORE_NUMBER_AND_INCR (p, mcnt); - DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p, mcnt); - } - else if (mcnt == 0) - { - DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2); - p[2] = (unsigned char) no_op; - p[3] = (unsigned char) no_op; - goto on_failure; - } - break; - - case jump_n: - EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); - - /* Originally, this is how many times we CAN jump. */ - if (mcnt) - { - mcnt--; - STORE_NUMBER (p + 2, mcnt); - goto unconditional_jump; - } - /* If don't have to jump any more, skip over the rest of command. */ - else - p += 4; - break; - - case set_number_at: - { - DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - p1 = p + mcnt; - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt); - STORE_NUMBER (p1, mcnt); - break; - } - - case wordbound: - DEBUG_PRINT1 ("EXECUTING wordbound.\n"); - if (AT_WORD_BOUNDARY (d)) - break; - goto fail; - - case notwordbound: - DEBUG_PRINT1 ("EXECUTING notwordbound.\n"); - if (AT_WORD_BOUNDARY (d)) - goto fail; - break; - - case wordbeg: - DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); - if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) - break; - goto fail; - - case wordend: - DEBUG_PRINT1 ("EXECUTING wordend.\n"); - if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) - && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) - break; - goto fail; - -#ifdef emacs -#ifdef emacs19 - case before_dot: - DEBUG_PRINT1 ("EXECUTING before_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) >= point) - goto fail; - break; - - case at_dot: - DEBUG_PRINT1 ("EXECUTING at_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) != point) - goto fail; - break; - - case after_dot: - DEBUG_PRINT1 ("EXECUTING after_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) <= point) - goto fail; - break; -#else /* not emacs19 */ - case at_dot: - DEBUG_PRINT1 ("EXECUTING at_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point) - goto fail; - break; -#endif /* not emacs19 */ - - case syntaxspec: - DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); - mcnt = *p++; - goto matchsyntax; - - case wordchar: - DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n"); - mcnt = (int) Sword; - matchsyntax: - PREFETCH (); - if (SYNTAX (*d++) != (enum syntaxcode) mcnt) - goto fail; - SET_REGS_MATCHED (); - break; - - case notsyntaxspec: - DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); - mcnt = *p++; - goto matchnotsyntax; - - case notwordchar: - DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n"); - mcnt = (int) Sword; - matchnotsyntax: - PREFETCH (); - if (SYNTAX (*d++) == (enum syntaxcode) mcnt) - goto fail; - SET_REGS_MATCHED (); - break; - -#else /* not emacs */ - case wordchar: - DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); - PREFETCH (); - if (!WORDCHAR_P (d)) - goto fail; - SET_REGS_MATCHED (); - d++; - break; - - case notwordchar: - DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); - PREFETCH (); - if (WORDCHAR_P (d)) - goto fail; - SET_REGS_MATCHED (); - d++; - break; -#endif /* not emacs */ - - default: - abort (); - } - continue; /* Successfully executed one pattern command; keep going. */ - - - /* We goto here if a matching operation fails. */ - fail: - if (!FAIL_STACK_EMPTY ()) - { /* A restart point is known. Restore to that state. */ - DEBUG_PRINT1 ("\nFAIL:\n"); - POP_FAILURE_POINT (d, p, - lowest_active_reg, highest_active_reg, - regstart, regend, reg_info); - - /* If this failure point is a dummy, try the next one. */ - if (!p) - goto fail; - - /* If we failed to the end of the pattern, don't examine *p. */ - assert (p <= pend); - if (p < pend) - { - boolean is_a_jump_n = false; - - /* If failed to a backwards jump that's part of a repetition - loop, need to pop this failure point and use the next one. */ - switch ((re_opcode_t) *p) - { - case jump_n: - is_a_jump_n = true; - case maybe_pop_jump: - case pop_failure_jump: - case jump: - p1 = p + 1; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - - if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n) - || (!is_a_jump_n - && (re_opcode_t) *p1 == on_failure_jump)) - goto fail; - break; - default: - /* do nothing */ ; - } - } - - if (d >= string1 && d <= end1) - dend = end_match_1; - } - else - break; /* Matching at this starting point really fails. */ - } /* for (;;) */ - - if (best_regs_set) - goto restore_best_regs; - - FREE_VARIABLES (); - - return -1; /* Failure to match. */ -} /* re_match_2 */ - -/* Subroutine definitions for re_match_2. */ - - -/* We are passed P pointing to a register number after a start_memory. - - Return true if the pattern up to the corresponding stop_memory can - match the empty string, and false otherwise. - - If we find the matching stop_memory, sets P to point to one past its number. - Otherwise, sets P to an undefined byte less than or equal to END. - - We don't handle duplicates properly (yet). */ - -static boolean -group_match_null_string_p (p, end, reg_info) - unsigned char **p, *end; - register_info_type *reg_info; -{ - int mcnt; - /* Point to after the args to the start_memory. */ - unsigned char *p1 = *p + 2; - - while (p1 < end) - { - /* Skip over opcodes that can match nothing, and return true or - false, as appropriate, when we get to one that can't, or to the - matching stop_memory. */ - - switch ((re_opcode_t) *p1) - { - /* Could be either a loop or a series of alternatives. */ - case on_failure_jump: - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - - /* If the next operation is not a jump backwards in the - pattern. */ - - if (mcnt >= 0) - { - /* Go through the on_failure_jumps of the alternatives, - seeing if any of the alternatives cannot match nothing. - The last alternative starts with only a jump, - whereas the rest start with on_failure_jump and end - with a jump, e.g., here is the pattern for `a|b|c': - - /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6 - /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3 - /exactn/1/c - - So, we have to first go through the first (n-1) - alternatives and then deal with the last one separately. */ - - - /* Deal with the first (n-1) alternatives, which start - with an on_failure_jump (see above) that jumps to right - past a jump_past_alt. */ - - while ((re_opcode_t) p1[mcnt-3] == jump_past_alt) - { - /* `mcnt' holds how many bytes long the alternative - is, including the ending `jump_past_alt' and - its number. */ - - if (!alt_match_null_string_p (p1, p1 + mcnt - 3, - reg_info)) - return false; - - /* Move to right after this alternative, including the - jump_past_alt. */ - p1 += mcnt; - - /* Break if it's the beginning of an n-th alternative - that doesn't begin with an on_failure_jump. */ - if ((re_opcode_t) *p1 != on_failure_jump) - break; - - /* Still have to check that it's not an n-th - alternative that starts with an on_failure_jump. */ - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if ((re_opcode_t) p1[mcnt-3] != jump_past_alt) - { - /* Get to the beginning of the n-th alternative. */ - p1 -= 3; - break; - } - } - - /* Deal with the last alternative: go back and get number - of the `jump_past_alt' just before it. `mcnt' contains - the length of the alternative. */ - EXTRACT_NUMBER (mcnt, p1 - 2); - - if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info)) - return false; - - p1 += mcnt; /* Get past the n-th alternative. */ - } /* if mcnt > 0 */ - break; - - - case stop_memory: - assert (p1[1] == **p); - *p = p1 + 2; - return true; - - - default: - if (!common_op_match_null_string_p (&p1, end, reg_info)) - return false; - } - } /* while p1 < end */ - - return false; -} /* group_match_null_string_p */ - - -/* Similar to group_match_null_string_p, but doesn't deal with alternatives: - It expects P to be the first byte of a single alternative and END one - byte past the last. The alternative can contain groups. */ - -static boolean -alt_match_null_string_p (p, end, reg_info) - unsigned char *p, *end; - register_info_type *reg_info; -{ - int mcnt; - unsigned char *p1 = p; - - while (p1 < end) - { - /* Skip over opcodes that can match nothing, and break when we get - to one that can't. */ - - switch ((re_opcode_t) *p1) - { - /* It's a loop. */ - case on_failure_jump: - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - break; - - default: - if (!common_op_match_null_string_p (&p1, end, reg_info)) - return false; - } - } /* while p1 < end */ - - return true; -} /* alt_match_null_string_p */ - - -/* Deals with the ops common to group_match_null_string_p and - alt_match_null_string_p. - - Sets P to one after the op and its arguments, if any. */ - -static boolean -common_op_match_null_string_p (p, end, reg_info) - unsigned char **p, *end; - register_info_type *reg_info; -{ - int mcnt; - boolean ret; - int reg_no; - unsigned char *p1 = *p; - - switch ((re_opcode_t) *p1++) - { - case no_op: - case begline: - case endline: - case begbuf: - case endbuf: - case wordbeg: - case wordend: - case wordbound: - case notwordbound: -#ifdef emacs - case before_dot: - case at_dot: - case after_dot: -#endif - break; - - case start_memory: - reg_no = *p1; - assert (reg_no > 0 && reg_no <= MAX_REGNUM); - ret = group_match_null_string_p (&p1, end, reg_info); - - /* Have to set this here in case we're checking a group which - contains a group and a back reference to it. */ - - if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE) - REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret; - - if (!ret) - return false; - break; - - /* If this is an optimized succeed_n for zero times, make the jump. */ - case jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if (mcnt >= 0) - p1 += mcnt; - else - return false; - break; - - case succeed_n: - /* Get to the number of times to succeed. */ - p1 += 2; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - - if (mcnt == 0) - { - p1 -= 4; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - } - else - return false; - break; - - case duplicate: - if (!REG_MATCH_NULL_STRING_P (reg_info[*p1])) - return false; - break; - - case set_number_at: - p1 += 4; - - default: - /* All other opcodes mean we cannot match the empty string. */ - return false; - } - - *p = p1; - return true; -} /* common_op_match_null_string_p */ - - -/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN - bytes; nonzero otherwise. */ - -static int -bcmp_translate (s1, s2, len, translate) - unsigned char *s1, *s2; - register int len; - char *translate; -{ - register unsigned char *p1 = s1, *p2 = s2; - while (len) - { - if (translate[*p1++] != translate[*p2++]) return 1; - len--; - } - return 0; -} - -/* Entry points for GNU code. */ - -/* re_compile_pattern is the GNU regular expression compiler: it - compiles PATTERN (of length SIZE) and puts the result in BUFP. - Returns 0 if the pattern was valid, otherwise an error string. - - Assumes the `allocated' (and perhaps `buffer') and `translate' fields - are set in BUFP on entry. - - We call regex_compile to do the actual compilation. */ - -const char * -re_compile_pattern (pattern, length, bufp) - const char *pattern; - int length; - struct re_pattern_buffer *bufp; -{ - reg_errcode_t ret; - - /* GNU code is written to assume at least RE_NREGS registers will be set - (and at least one extra will be -1). */ - bufp->regs_allocated = REGS_UNALLOCATED; - - /* And GNU code determines whether or not to get register information - by passing null for the REGS argument to re_match, etc., not by - setting no_sub. */ - bufp->no_sub = 0; - - /* Match anchors at newline. */ - bufp->newline_anchor = 1; - - ret = regex_compile (pattern, length, re_syntax_options, bufp); - - return re_error_msg[(int) ret]; -} - -/* Entry points compatible with 4.2 BSD regex library. We don't define - them if this is an Emacs or POSIX compilation. */ - -#if !defined (emacs) && !defined (_POSIX_SOURCE) - -/* BSD has one and only one pattern buffer. */ -static struct re_pattern_buffer re_comp_buf; - -char * -re_comp (s) - const char *s; -{ - reg_errcode_t ret; - - if (!s) - { - if (!re_comp_buf.buffer) - return "No previous regular expression"; - return 0; - } - - if (!re_comp_buf.buffer) - { - re_comp_buf.buffer = (unsigned char *) malloc (200); - if (re_comp_buf.buffer == NULL) - return "Memory exhausted"; - re_comp_buf.allocated = 200; - - re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); - if (re_comp_buf.fastmap == NULL) - return "Memory exhausted"; - } - - /* Since `re_exec' always passes NULL for the `regs' argument, we - don't need to initialize the pattern buffer fields which affect it. */ - - /* Match anchors at newlines. */ - re_comp_buf.newline_anchor = 1; - - ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); - - /* Yes, we're discarding `const' here. */ - return (char *) re_error_msg[(int) ret]; -} - - -int -re_exec (s) - const char *s; -{ - const int len = strlen (s); - return - 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); -} -#endif /* not emacs and not _POSIX_SOURCE */ - -/* POSIX.2 functions. Don't define these for Emacs. */ - -#ifndef emacs - -/* regcomp takes a regular expression as a string and compiles it. - - PREG is a regex_t *. We do not expect any fields to be initialized, - since POSIX says we shouldn't. Thus, we set - - `buffer' to the compiled pattern; - `used' to the length of the compiled pattern; - `syntax' to RE_SYNTAX_POSIX_EXTENDED if the - REG_EXTENDED bit in CFLAGS is set; otherwise, to - RE_SYNTAX_POSIX_BASIC; - `newline_anchor' to REG_NEWLINE being set in CFLAGS; - `fastmap' and `fastmap_accurate' to zero; - `re_nsub' to the number of subexpressions in PATTERN. - - PATTERN is the address of the pattern string. - - CFLAGS is a series of bits which affect compilation. - - If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we - use POSIX basic syntax. - - If REG_NEWLINE is set, then . and [^...] don't match newline. - Also, regexec will try a match beginning after every newline. - - If REG_ICASE is set, then we considers upper- and lowercase - versions of letters to be equivalent when matching. - - If REG_NOSUB is set, then when PREG is passed to regexec, that - routine will report only success or failure, and nothing about the - registers. - - It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for - the return codes and their meanings.) */ - -int -regcomp (preg, pattern, cflags) - regex_t *preg; - const char *pattern; - int cflags; -{ - reg_errcode_t ret; - unsigned syntax - = (cflags & REG_EXTENDED) ? - RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; - - /* regex_compile will allocate the space for the compiled pattern. */ - preg->buffer = 0; - preg->allocated = 0; - - /* Don't bother to use a fastmap when searching. This simplifies the - REG_NEWLINE case: if we used a fastmap, we'd have to put all the - characters after newlines into the fastmap. This way, we just try - every character. */ - preg->fastmap = 0; - - if (cflags & REG_ICASE) - { - unsigned i; - - preg->translate = (char *) malloc (CHAR_SET_SIZE); - if (preg->translate == NULL) - return (int) REG_ESPACE; - - /* Map uppercase characters to corresponding lowercase ones. */ - for (i = 0; i < CHAR_SET_SIZE; i++) - preg->translate[i] = ISUPPER (i) ? tolower (i) : i; - } - else - preg->translate = NULL; - - /* If REG_NEWLINE is set, newlines are treated differently. */ - if (cflags & REG_NEWLINE) - { /* REG_NEWLINE implies neither . nor [^...] match newline. */ - syntax &= ~RE_DOT_NEWLINE; - syntax |= RE_HAT_LISTS_NOT_NEWLINE; - /* It also changes the matching behavior. */ - preg->newline_anchor = 1; - } - else - preg->newline_anchor = 0; - - preg->no_sub = !!(cflags & REG_NOSUB); - - /* POSIX says a null character in the pattern terminates it, so we - can use strlen here in compiling the pattern. */ - ret = regex_compile (pattern, strlen (pattern), syntax, preg); - - /* POSIX doesn't distinguish between an unmatched open-group and an - unmatched close-group: both are REG_EPAREN. */ - if (ret == REG_ERPAREN) ret = REG_EPAREN; - - return (int) ret; -} - - -/* regexec searches for a given pattern, specified by PREG, in the - string STRING. - - If NMATCH is zero or REG_NOSUB was set in the cflags argument to - `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at - least NMATCH elements, and we set them to the offsets of the - corresponding matched substrings. - - EFLAGS specifies `execution flags' which affect matching: if - REG_NOTBOL is set, then ^ does not match at the beginning of the - string; if REG_NOTEOL is set, then $ does not match at the end. - - We return 0 if we find a match and REG_NOMATCH if not. */ - -int -regexec (preg, string, nmatch, pmatch, eflags) - const regex_t *preg; - const char *string; - size_t nmatch; - regmatch_t pmatch[]; - int eflags; -{ - int ret; - struct re_registers regs; - regex_t private_preg; - int len = strlen (string); - boolean want_reg_info = !preg->no_sub && nmatch > 0; - - private_preg = *preg; - - private_preg.not_bol = !!(eflags & REG_NOTBOL); - private_preg.not_eol = !!(eflags & REG_NOTEOL); - - /* The user has told us exactly how many registers to return - information about, via `nmatch'. We have to pass that on to the - matching routines. */ - private_preg.regs_allocated = REGS_FIXED; - - if (want_reg_info) - { - regs.num_regs = nmatch; - regs.start = TALLOC (nmatch, regoff_t); - regs.end = TALLOC (nmatch, regoff_t); - if (regs.start == NULL || regs.end == NULL) - return (int) REG_NOMATCH; - } - - /* Perform the searching operation. */ - ret = re_search (&private_preg, string, len, - /* start: */ 0, /* range: */ len, - want_reg_info ? ®s : (struct re_registers *) 0); - - /* Copy the register information to the POSIX structure. */ - if (want_reg_info) - { - if (ret >= 0) - { - unsigned r; - - for (r = 0; r < nmatch; r++) - { - pmatch[r].rm_so = regs.start[r]; - pmatch[r].rm_eo = regs.end[r]; - } - } - - /* If we needed the temporary register info, free the space now. */ - free (regs.start); - free (regs.end); - } - - /* We want zero return to mean success, unlike `re_search'. */ - return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH; -} - - -/* Returns a message corresponding to an error code, ERRCODE, returned - from either regcomp or regexec. We don't use PREG here. */ - -size_t -regerror (errcode, preg, errbuf, errbuf_size) - int errcode; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; -{ - const char *msg; - size_t msg_size; - - if (errcode < 0 - || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0]))) - /* Only error codes returned by the rest of the code should be passed - to this routine. If we are given anything else, or if other regex - code generates an invalid error code, then the program has a bug. - Dump core so we can fix it. */ - abort (); - - msg = re_error_msg[errcode]; - - /* POSIX doesn't require that we do anything in this case, but why - not be nice. */ - if (! msg) - msg = "Success"; - - msg_size = strlen (msg) + 1; /* Includes the null. */ - - if (errbuf_size != 0) - { - if (msg_size > errbuf_size) - { - strncpy (errbuf, msg, errbuf_size - 1); - errbuf[errbuf_size - 1] = 0; - } - else - strcpy (errbuf, msg); - } - - return msg_size; -} - - -/* Free dynamically allocated space used by PREG. */ - -void -regfree (preg) - regex_t *preg; -{ - if (preg->buffer != NULL) - free (preg->buffer); - preg->buffer = NULL; - - preg->allocated = 0; - preg->used = 0; - - if (preg->fastmap != NULL) - free (preg->fastmap); - preg->fastmap = NULL; - preg->fastmap_accurate = 0; - - if (preg->translate != NULL) - free (preg->translate); - preg->translate = NULL; -} - -#endif /* not emacs */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/libregex/regex.h b/gnu/lib/libregex/regex.h deleted file mode 100644 index f920fbeabc79..000000000000 --- a/gnu/lib/libregex/regex.h +++ /dev/null @@ -1,493 +0,0 @@ -/* Definitions for data structures and routines for the regular - expression library, version 0.12. - - Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 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. - - $Id: regex.h,v 1.2 1993/08/02 17:24:51 mycroft Exp $ -*/ - -#ifndef __REGEXP_LIBRARY_H__ -#define __REGEXP_LIBRARY_H__ - -/* POSIX says that must be included (by the caller) before - . */ - -#ifdef VMS -/* VMS doesn't have `size_t' in , even though POSIX says it - should be there. */ -#include -#endif - - -/* The following bits are used to determine the regexp syntax we - recognize. The set/not-set meanings are chosen so that Emacs syntax - remains the value 0. The bits are given in alphabetical order, and - the definitions shifted by one from the previous bit; thus, when we - add or remove a bit, only one other definition need change. */ -typedef unsigned reg_syntax_t; - -/* If this bit is not set, then \ inside a bracket expression is literal. - If set, then such a \ quotes the following character. */ -#define RE_BACKSLASH_ESCAPE_IN_LISTS (1) - -/* If this bit is not set, then + and ? are operators, and \+ and \? are - literals. - If set, then \+ and \? are operators and + and ? are literals. */ -#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) - -/* 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 (RE_BK_PLUS_QM << 1) - -/* If this bit is set, then ^ and $ are always anchors (outside bracket - expressions, of course). - If this bit is not set, then it depends: - ^ is an anchor if it is at the beginning of a regular - expression or after an open-group or an alternation operator; - $ is an anchor if it is at the end of a regular expression, or - before a close-group or an alternation operator. - - This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because - POSIX draft 11.2 says that * etc. in leading positions is undefined. - We already implemented a previous draft which made those constructs - invalid, though, so we haven't changed the code back. */ -#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) - -/* If this bit is set, then special characters are always special - regardless of where they are in the pattern. - If this bit is not set, then special characters are special only in - some contexts; otherwise they are ordinary. Specifically, - * + ? and intervals are only special when not after the beginning, - open-group, or alternation operator. */ -#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) - -/* If this bit is set, then *, +, ?, and { cannot be first in an re or - immediately after an alternation or begin-group operator. */ -#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) - -/* If this bit is set, then . matches newline. - If not set, then it doesn't. */ -#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) - -/* If this bit is set, then . doesn't match NUL. - If not set, then it does. */ -#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) - -/* If this bit is set, nonmatching lists [^...] do not match newline. - If not set, they do. */ -#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) - -/* If this bit is set, either \{...\} or {...} defines an - interval, depending on RE_NO_BK_BRACES. - If not set, \{, \}, {, and } are literals. */ -#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) - -/* If this bit is set, +, ? and | aren't recognized as operators. - If not set, they are. */ -#define RE_LIMITED_OPS (RE_INTERVALS << 1) - -/* If this bit is set, newline is an alternation operator. - If not set, newline is literal. */ -#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) - -/* If this bit is set, then `{...}' defines an interval, and \{ and \} - are literals. - If not set, then `\{...\}' defines an interval. */ -#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) - -/* If this bit is set, (...) defines a group, and \( and \) are literals. - If not set, \(...\) defines a group, and ( and ) are literals. */ -#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) - -/* If this bit is set, then \ matches . - If not set, then \ is a back-reference. */ -#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) - -/* If this bit is set, then | is an alternation operator, and \| is literal. - If not set, then \| is an alternation operator, and | is literal. */ -#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) - -/* If this bit is set, then an ending range point collating higher - than the starting range point, as in [z-a], is invalid. - If not set, then when ending range point collates higher than the - starting range point, the range is ignored. */ -#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) - -/* If this bit is set, then an unmatched ) is ordinary. - If not set, then an unmatched ) is invalid. */ -#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) - -/* This global variable defines the particular regexp syntax to use (for - some interfaces). When a regexp is compiled, the syntax used is - stored in the pattern buffer, so changing this does not affect - already-compiled regexps. */ -extern reg_syntax_t re_syntax_options; - -/* Define combinations of the above bits for the standard possibilities. - (The [[[ comments delimit what gets put into the Texinfo file, so - don't delete them!) */ -/* [[[begin syntaxes]]] */ -#define RE_SYNTAX_EMACS 0 - -#define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -#define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) - -#define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - -#define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - -#define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) - -/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ -#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - -#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - -/* Syntax bits common to both basic and extended POSIX regex syntax. */ -#define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - -#define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) - -/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ -#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - -#define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS - replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ -#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) -/* [[[end syntaxes]]] */ - -/* Maximum number of duplicates an interval can allow. Some systems - (erroneously) define this in other header files, but we want our - value, so remove any previous define. */ -#ifdef RE_DUP_MAX -#undef RE_DUP_MAX -#endif -#define RE_DUP_MAX ((1 << 15) - 1) - - -/* POSIX `cflags' bits (i.e., information for `regcomp'). */ - -/* If this bit is set, then use extended regular expression syntax. - If not set, then use basic regular expression syntax. */ -#define REG_EXTENDED 1 - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -#define REG_ICASE (REG_EXTENDED << 1) - -/* If this bit is set, then anchors do not match at newline - characters in the string. - If not set, then anchors do match at newlines. */ -#define REG_NEWLINE (REG_ICASE << 1) - -/* If this bit is set, then report only success or fail in regexec. - If not set, then returns differ between not matching and errors. */ -#define REG_NOSUB (REG_NEWLINE << 1) - - -/* POSIX `eflags' bits (i.e., information for regexec). */ - -/* If this bit is set, then the beginning-of-line operator doesn't match - the beginning of the string (presumably because it's not the - beginning of a line). - If not set, then the beginning-of-line operator does match the - beginning of the string. */ -#define REG_NOTBOL 1 - -/* Like REG_NOTBOL, except for the end-of-line. */ -#define REG_NOTEOL (1 << 1) - - -/* If any error codes are removed, changed, or added, update the - `re_error_msg' table in regex.c. */ -typedef enum -{ - REG_NOERROR = 0, /* Success. */ - REG_NOMATCH, /* Didn't find a match (for regexec). */ - - /* POSIX regcomp return error codes. (In the order listed in the - standard.) */ - REG_BADPAT, /* Invalid pattern. */ - REG_ECOLLATE, /* Not implemented. */ - REG_ECTYPE, /* Invalid character class name. */ - REG_EESCAPE, /* Trailing backslash. */ - REG_ESUBREG, /* Invalid back reference. */ - REG_EBRACK, /* Unmatched left bracket. */ - REG_EPAREN, /* Parenthesis imbalance. */ - REG_EBRACE, /* Unmatched \{. */ - REG_BADBR, /* Invalid contents of \{\}. */ - REG_ERANGE, /* Invalid range end. */ - REG_ESPACE, /* Ran out of memory. */ - REG_BADRPT, /* No preceding re for repetition op. */ - - /* Error codes we've added. */ - REG_EEND, /* Premature end. */ - REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ - REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ -} reg_errcode_t; - -/* This data structure represents a compiled pattern. Before calling - the pattern compiler, the fields `buffer', `allocated', `fastmap', - `translate', and `no_sub' can be set. After the pattern has been - compiled, the `re_nsub' field is available. All other fields are - private to the regex routines. */ - -struct re_pattern_buffer -{ -/* [[[begin pattern_buffer]]] */ - /* Space that holds the compiled pattern. It is declared as - `unsigned char *' because its elements are - sometimes used as array indexes. */ - unsigned char *buffer; - - /* Number of bytes to which `buffer' points. */ - unsigned long allocated; - - /* Number of bytes actually used in `buffer'. */ - unsigned long used; - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t syntax; - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses - the fastmap, if there is one, to skip over impossible - starting points for matches. */ - char *fastmap; - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation - is applied to a pattern when it is compiled and to a string - when it is matched. */ - char *translate; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in `re_search_2', to see - whether or not we should use the fastmap, so we don't set - this absolutely perfectly; see `re_compile_fastmap' (the - `duplicate' case). */ - unsigned can_be_null : 1; - - /* If REGS_UNALLOCATED, allocate space in the `regs' structure - for `max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ -#define REGS_UNALLOCATED 0 -#define REGS_REALLOCATE 1 -#define REGS_FIXED 2 - unsigned regs_allocated : 2; - - /* Set to zero when `regex_compile' compiles a pattern; set to one - by `re_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; - - /* If set, `re_match_2' does not return information about - subexpressions. */ - unsigned no_sub : 1; - - /* If set, a beginning-of-line anchor doesn't match at the - beginning of the string. */ - unsigned not_bol : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned not_eol : 1; - - /* If true, an anchor at a newline matches. */ - unsigned newline_anchor : 1; - -/* [[[end pattern_buffer]]] */ -}; - -typedef struct re_pattern_buffer regex_t; - - -/* search.c (search_buffer) in Emacs needs this one opcode value. It is - defined both in `regex.c' and here. */ -#define RE_EXACTN_VALUE 1 - -/* Type for byte offsets within the string. POSIX mandates this. */ -typedef int regoff_t; - - -/* This is the structure we store register match data in. See - regex.texinfo for a full description of what registers match. */ -struct re_registers -{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -}; - - -/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, - `re_match_2' returns information about at least this many registers - the first time a `regs' structure is passed. */ -#ifndef RE_NREGS -#define RE_NREGS 30 -#endif - - -/* POSIX specification for registers. Aside from the different names than - `re_registers', POSIX uses an array of structures, instead of a - structure of arrays. */ -typedef struct -{ - regoff_t rm_so; /* Byte offset from string's start to substring's start. */ - regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ -} regmatch_t; - -/* Declarations for routines. */ - -/* To avoid duplicating every routine declaration -- once with a - prototype (if we are ANSI), and once without (if we aren't) -- we - use the following macro to declare argument types. This - unfortunately clutters up the declarations a bit, but I think it's - worth it. */ - -#if __STDC__ - -#define _RE_ARGS(args) args - -#else /* not __STDC__ */ - -#define _RE_ARGS(args) () - -#endif /* not __STDC__ */ - -/* Sets the current default syntax to SYNTAX, and return the old syntax. - You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); - -/* Compile the regular expression PATTERN, with length LENGTH - and syntax given by the global `re_syntax_options', into the buffer - BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern - _RE_ARGS ((const char *pattern, int length, - struct re_pattern_buffer *buffer)); - - -/* Compile a fastmap for the compiled pattern in BUFFER; used to - accelerate searches. Return 0 if successful and -2 if was an - internal error. */ -extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); - - -/* Search in the string STRING (with length LENGTH) for the pattern - compiled into BUFFER. Start searching at position START, for RANGE - characters. Return the starting position of the match, -1 for no - match, or -2 for an internal error. Also return register - information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, int range, struct re_registers *regs)); - - -/* Like `re_search', but search in the concatenation of STRING1 and - STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, int range, struct re_registers *regs, int stop)); - - -/* Like `re_search', but return how many characters in STRING the regexp - in BUFFER matched, starting at position START. */ -extern int re_match - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, struct re_registers *regs)); - - -/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int re_match_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, struct re_registers *regs, int stop)); - - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using BUFFER and REGS will use this memory - for recording register information. STARTS and ENDS must be - allocated with malloc, and must each be at least `NUM_REGS * sizeof - (regoff_t)' bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ -extern void re_set_registers - _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, regoff_t *starts, regoff_t *ends)); - -/* 4.2 bsd compatibility. */ -extern char *re_comp _RE_ARGS ((const char *)); -extern int re_exec _RE_ARGS ((const char *)); - -/* POSIX compatibility. */ -extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags)); -extern int regexec - _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch, - regmatch_t pmatch[], int eflags)); -extern size_t regerror - _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf, - size_t errbuf_size)); -extern void regfree _RE_ARGS ((regex_t *preg)); - -#endif /* not __REGEXP_LIBRARY_H__ */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/libregex/shlib_version b/gnu/lib/libregex/shlib_version deleted file mode 100644 index 97c9f92d6b8f..000000000000 --- a/gnu/lib/libregex/shlib_version +++ /dev/null @@ -1,2 +0,0 @@ -major=0 -minor=0 diff --git a/gnu/lib/libregex/test/debugmalloc.c b/gnu/lib/libregex/test/debugmalloc.c deleted file mode 100644 index 2c71aa9ec4a7..000000000000 --- a/gnu/lib/libregex/test/debugmalloc.c +++ /dev/null @@ -1,277 +0,0 @@ -/* debugmalloc.c: a malloc for debugging purposes. */ - -#ifndef lint -static char rcsid[] = "$Id: debugmalloc.c,v 1.2 1993/08/02 17:24:15 mycroft Exp $"; -#endif /* not lint */ - -#include -#include -#include - -static unsigned trace = 0; -#define TRACE(s) if (trace) fprintf (stderr, "%s", s) -#define TRACE1(s, e1) if (trace) fprintf (stderr, s, e1) -#define TRACE2(s, e1, e2) if (trace) fprintf (stderr, s, e1, e2) -#define TRACE3(s, e1, e2, e3) if (trace) fprintf (stderr, s, e1, e2, e3) -#define TRACE4(s, e1, e2, e3, e4) \ - if (trace) fprintf (stderr, s, e1, e2, e3, e4) - -typedef char *address; - - -/* Wrap our calls to sbrk. */ - -address -xsbrk (incr) - int incr; -{ - extern char *sbrk (); - address ret = sbrk (incr); - - if (ret == (address) -1) - { - perror ("sbrk"); /* Actually, we should return NULL, not quit. */ - abort (); - } - - return ret; -} - - - -typedef struct chunk_struct -{ - /* This is the size (in bytes) that has actually been actually - allocated, not the size that the user requested. */ - unsigned alloc_size; - - /* This is the size the user requested. */ - unsigned user_size; - - /* Points to the next block in one of the lists. */ - struct chunk_struct *next; - - /* Now comes the user's memory. */ - address user_mem; - - /* After the user's memory is a constant. */ -} *chunk; - -#define MALLOC_OVERHEAD 16 - -/* We might play around with the `user_size' field, but the amount of - memory that is actually available in the chunk is always the size - allocated minus the overhead. */ -#define USER_ALLOC(c) ((c)->alloc_size - MALLOC_OVERHEAD) - -/* Given a pointer to a malloc-allocated block, the beginning of the - chunk should always be MALLOC_OVERHEAD - 4 bytes back, since the only - overhead after the user memory is the constant. */ - -chunk -mem_to_chunk (mem) - address mem; -{ - return (chunk) (mem - (MALLOC_OVERHEAD - 4)); -} - - -/* The other direction is even easier, since the user's memory starts at - the `user_mem' member in the chunk. */ - -address -chunk_to_mem (c) - chunk c; -{ - return (address) &(c->user_mem); -} - - - -/* We keep both all the allocated chunks and all the free chunks on - lists. Since we put the next pointers in the chunk structure, we - don't need a separate chunk_list structure. */ -chunk alloc_list = NULL, free_list = NULL; - - -/* We always append the new chunk at the beginning of the list. */ - -void -chunk_insert (chunk_list, new_c) - chunk *chunk_list; - chunk new_c; -{ - chunk c = *chunk_list; /* old beginning of list */ - - TRACE3 (" Inserting 0x%x at the beginning of 0x%x, before 0x%x.\n", - new_c, chunk_list, c); - - *chunk_list = new_c; - new_c->next = c; -} - - -/* Thus, removing an element means we have to search until we find it. - Have to delete before we insert, since insertion changes the next - pointer, which we need to put it on the other list. */ - -void -chunk_delete (chunk_list, dead_c) - chunk *chunk_list; - chunk dead_c; -{ - chunk c = *chunk_list; - chunk prev_c = NULL; - - TRACE2 (" Deleting 0x%x from 0x%x:", dead_c, chunk_list); - - while (c != dead_c && c != NULL) - { - TRACE1 (" 0x%x", c); - prev_c = c; - c = c->next; - } - - if (c == NULL) - { - fprintf (stderr, "Chunk at 0x%x not found on list.\n", dead_c); - abort (); - } - - if (prev_c == NULL) - { - TRACE1 (".\n Setting head to 0x%x.\n", c->next); - *chunk_list = c->next; - } - else - { - TRACE2 (".\n Linking next(0x%x) to 0x%x.\n", prev_c, c->next); - prev_c->next = c->next; - } -} - - -/* See if a list is hunky-dory. */ - -void -validate_list (chunk_list) - chunk *chunk_list; -{ - chunk c; - - TRACE1 (" Validating list at 0x%x:", chunk_list); - - for (c = *chunk_list; c != NULL; c = c->next) - { - assert (c->user_size < c->alloc_size); - assert (memcmp (chunk_to_mem (c) + c->user_size, "Karl", 4)); - TRACE2 (" 0x%x/%d", c, c->user_size); - } - - TRACE (".\n"); -} - - -/* See if we have a free chunk of a given size. We'll take the first - one that is big enough. */ - -chunk -free_list_available (needed) - unsigned needed; -{ - chunk c; - - TRACE1 (" Checking free list for %d bytes:", needed); - - if (free_list == NULL) - { - return NULL; - } - - c = free_list; - - while (c != NULL && USER_ALLOC (c) < needed) - { - TRACE2 (" 0x%x/%d", c, USER_ALLOC (c)); - c = c->next; - } - - TRACE1 ("\n Returning 0x%x.\n", c); - return c; -} - - - - -address -malloc (n) - unsigned n; -{ - address new_mem; - chunk c; - - TRACE1 ("Mallocing %d bytes.\n", n); - - validate_list (&free_list); - validate_list (&alloc_list); - - c = free_list_available (n); - - if (c == NULL) - { /* Nothing suitable on free list. Allocate a new chunk. */ - TRACE (" not on free list.\n"); - c = (chunk) xsbrk (n + MALLOC_OVERHEAD); - c->alloc_size = n + MALLOC_OVERHEAD; - } - else - { /* Found something on free list. Don't split it, just use as is. */ - TRACE (" found on free list.\n"); - chunk_delete (&free_list, c); - } - - /* If we took this from the free list, then the user size might be - different now, and consequently the constant at the end might be in - the wrong place. */ - c->user_size = n; - new_mem = chunk_to_mem (c); - memcpy (new_mem + n, "Karl", 4); - chunk_insert (&alloc_list, c); - - TRACE2 ("Malloc returning 0x%x (chunk 0x%x).\n", new_mem, c); - return new_mem; -} - - -address -realloc (mem, n) - address mem; - unsigned n; -{ - void free (); - chunk c = mem_to_chunk (mem); - address new_mem; - - TRACE3 ("Reallocing %d bytes at 0x%x (chunk 0x%x).\n", n, mem, c); - - new_mem = malloc (n); - memcpy (new_mem, mem, c->user_size); - free (mem); - - return new_mem; -} - - -void -free (mem) - address mem; -{ - chunk c = mem_to_chunk (mem); - - TRACE2 ("Freeing memory at 0x%x (chunk at 0x%x).\n", mem, c); - - validate_list (&free_list); - validate_list (&alloc_list); - - chunk_delete (&alloc_list, c); - chunk_insert (&free_list, c); -} diff --git a/gnu/lib/libregex/test/emacsmalloc.c b/gnu/lib/libregex/test/emacsmalloc.c deleted file mode 100644 index 88d96e5a841c..000000000000 --- a/gnu/lib/libregex/test/emacsmalloc.c +++ /dev/null @@ -1,846 +0,0 @@ -/* dynamic memory allocation for GNU. - Copyright (C) 1985, 1987 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 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. - -In other words, you are welcome to use, share and improve this program. -You are forbidden to forbid anyone else to use, share and improve -what you give them. Help stamp out software-hoarding! */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)nmalloc.c 1 (Caltech) 2/21/82";*/ -static char rcsid[] = "$Id: emacsmalloc.c,v 1.2 1993/08/01 18:49:07 mycroft Exp $"; -#endif - -/* - * U of M Modified: 20 Jun 1983 ACT: strange hacks for Emacs - * - * Nov 1983, Mike@BRL, Added support for 4.1C/4.2 BSD. - * - * This is a very fast storage allocator. It allocates blocks of a small - * number of different sizes, and keeps free lists of each size. Blocks - * that don't exactly fit are passed up to the next larger size. In this - * implementation, the available sizes are (2^n)-4 (or -16) bytes long. - * This is designed for use in a program that uses vast quantities of - * memory, but bombs when it runs out. To make it a little better, it - * warns the user when he starts to get near the end. - * - * June 84, ACT: modified rcheck code to check the range given to malloc, - * rather than the range determined by the 2-power used. - * - * Jan 85, RMS: calls malloc_warning to issue warning on nearly full. - * No longer Emacs-specific; can serve as all-purpose malloc for GNU. - * You should call malloc_init to reinitialize after loading dumped Emacs. - * Call malloc_stats to get info on memory stats if MSTATS turned on. - * realloc knows how to return same block given, just changing its size, - * if the power of 2 is correct. - */ - -/* - * nextf[i] is the pointer to the next free block of size 2^(i+3). The - * smallest allocatable block is 8 bytes. The overhead information will - * go in the first int of the block, and the returned pointer will point - * to the second. - * -#ifdef MSTATS - * nmalloc[i] is the difference between the number of mallocs and frees - * for a given block size. -#endif MSTATS - */ - -#ifdef emacs -/* config.h specifies which kind of system this is. */ -#include "config.h" -#include -#else - -/* Determine which kind of system this is. */ -#include -#include - -#include -#define bcopy(s,d,n) memcpy ((d), (s), (n)) -#define bcmp(s1,s2,n) memcmp ((s1), (s2), (n)) -#define bzero(s,n) memset ((s), 0, (n)) - -#ifndef SIGTSTP -#ifndef VMS -#ifndef USG -#define USG -#endif -#endif /* not VMS */ -#else /* SIGTSTP */ -#ifdef SIGIO -#define BSD4_2 -#endif /* SIGIO */ -#endif /* SIGTSTP */ - -#endif /* not emacs */ - -/* Define getpagesize () if the system does not. */ -#include "getpagesize.h" - -#ifdef BSD -#ifdef BSD4_1 -#include /* warn the user when near the end */ -#else /* if 4.2 or newer */ -#include -#include -#endif /* if 4.2 or newer */ -#endif - -#ifdef VMS -#include "vlimit.h" -#endif - -extern char *start_of_data (); - -#ifdef BSD -#ifndef DATA_SEG_BITS -#define start_of_data() &etext -#endif -#endif - -#ifndef emacs -#define start_of_data() &etext -#endif - -#define ISALLOC ((char) 0xf7) /* magic byte that implies allocation */ -#define ISFREE ((char) 0x54) /* magic byte that implies free block */ - /* this is for error checking only */ -#define ISMEMALIGN ((char) 0xd6) /* Stored before the value returned by - memalign, with the rest of the word - being the distance to the true - beginning of the block. */ - -extern char etext; - -/* These two are for user programs to look at, when they are interested. */ - -unsigned int malloc_sbrk_used; /* amount of data space used now */ -unsigned int malloc_sbrk_unused; /* amount more we can have */ - -/* start of data space; can be changed by calling init_malloc */ -static char *data_space_start; - -#ifdef MSTATS -static int nmalloc[30]; -static int nmal, nfre; -#endif /* MSTATS */ - -/* If range checking is not turned on, all we have is a flag indicating - whether memory is allocated, an index in nextf[], and a size field; to - realloc() memory we copy either size bytes or 1<<(index+3) bytes depending - on whether the former can hold the exact size (given the value of - 'index'). If range checking is on, we always need to know how much space - is allocated, so the 'size' field is never used. */ - -struct mhead { - char mh_alloc; /* ISALLOC or ISFREE */ - char mh_index; /* index in nextf[] */ -/* Remainder are valid only when block is allocated */ - unsigned short mh_size; /* size, if < 0x10000 */ -#ifdef rcheck - unsigned mh_nbytes; /* number of bytes allocated */ - int mh_magic4; /* should be == MAGIC4 */ -#endif /* rcheck */ -}; - -/* Access free-list pointer of a block. - It is stored at block + 4. - This is not a field in the mhead structure - because we want sizeof (struct mhead) - to describe the overhead for when the block is in use, - and we do not want the free-list pointer to count in that. */ - -#define CHAIN(a) \ - (*(struct mhead **) (sizeof (char *) + (char *) (a))) - -#ifdef rcheck - -/* To implement range checking, we write magic values in at the beginning and - end of each allocated block, and make sure they are undisturbed whenever a - free or a realloc occurs. */ -/* Written in each of the 4 bytes following the block's real space */ -#define MAGIC1 0x55 -/* Written in the 4 bytes before the block's real space */ -#define MAGIC4 0x55555555 -#define ASSERT(p) if (!(p)) botch("p"); else -#define EXTRA 4 /* 4 bytes extra for MAGIC1s */ -#else -#define ASSERT(p) if (!(p)) abort (); else -#define EXTRA 0 -#endif /* rcheck */ - - -/* nextf[i] is free list of blocks of size 2**(i + 3) */ - -static struct mhead *nextf[30]; - -/* busy[i] is nonzero while allocation of block size i is in progress. */ - -static char busy[30]; - -/* Number of bytes of writable memory we can expect to be able to get */ -static unsigned int lim_data; - -/* Level number of warnings already issued. - 0 -- no warnings issued. - 1 -- 75% warning already issued. - 2 -- 85% warning already issued. -*/ -static int warnlevel; - -/* Function to call to issue a warning; - 0 means don't issue them. */ -static void (*warnfunction) (); - -/* nonzero once initial bunch of free blocks made */ -static int gotpool; - -char *_malloc_base; - -static void getpool (); - -/* Cause reinitialization based on job parameters; - also declare where the end of pure storage is. */ -void -malloc_init (start, warnfun) - char *start; - void (*warnfun) (); -{ - if (start) - data_space_start = start; - lim_data = 0; - warnlevel = 0; - warnfunction = warnfun; -} - -/* Return the maximum size to which MEM can be realloc'd - without actually requiring copying. */ - -int -malloc_usable_size (mem) - char *mem; -{ - struct mhead *p - = (struct mhead *) (mem - ((sizeof (struct mhead) + 7) & ~7)); - int blocksize = 8 << p->mh_index; - - return blocksize - sizeof (struct mhead) - EXTRA; -} - -static void -morecore (nu) /* ask system for more memory */ - register int nu; /* size index to get more of */ -{ - char *sbrk (); - register char *cp; - register int nblks; - register unsigned int siz; - int oldmask; - -#ifdef BSD -#ifndef BSD4_1 - int newmask = -1; - /* Blocking these signals interferes with debugging, at least on BSD on - the HP 9000/300. */ -#ifdef SIGTRAP - newmask &= ~(1 << SIGTRAP); -#endif -#ifdef SIGILL - newmask &= ~(1 << SIGILL); -#endif -#ifdef SIGTSTP - newmask &= ~(1 << SIGTSTP); -#endif -#ifdef SIGSTOP - newmask &= ~(1 << SIGSTOP); -#endif - oldmask = sigsetmask (newmask); -#endif -#endif - - if (!data_space_start) - { - data_space_start = start_of_data (); - } - - if (lim_data == 0) - get_lim_data (); - - /* On initial startup, get two blocks of each size up to 1k bytes */ - if (!gotpool) - { getpool (); getpool (); gotpool = 1; } - - /* Find current end of memory and issue warning if getting near max */ - -#ifndef VMS - /* Maximum virtual memory on VMS is difficult to calculate since it - * depends on several dynmacially changing things. Also, alignment - * isn't that important. That is why much of the code here is ifdef'ed - * out for VMS systems. - */ - cp = sbrk (0); - siz = cp - data_space_start; - - if (warnfunction) - switch (warnlevel) - { - case 0: - if (siz > (lim_data / 4) * 3) - { - warnlevel++; - (*warnfunction) ("Warning: past 75% of memory limit"); - } - break; - case 1: - if (siz > (lim_data / 20) * 17) - { - warnlevel++; - (*warnfunction) ("Warning: past 85% of memory limit"); - } - break; - case 2: - if (siz > (lim_data / 20) * 19) - { - warnlevel++; - (*warnfunction) ("Warning: past 95% of memory limit"); - } - break; - } - - if ((int) cp & 0x3ff) /* land on 1K boundaries */ - sbrk (1024 - ((int) cp & 0x3ff)); -#endif /* not VMS */ - - /* Take at least 2k, and figure out how many blocks of the desired size - we're about to get */ - nblks = 1; - if ((siz = nu) < 8) - nblks = 1 << ((siz = 8) - nu); - - if ((cp = sbrk (1 << (siz + 3))) == (char *) -1) - { -#ifdef BSD -#ifndef BSD4_1 - sigsetmask (oldmask); -#endif -#endif - return; /* no more room! */ - } - malloc_sbrk_used = siz; - malloc_sbrk_unused = lim_data - siz; - -#ifndef VMS - if ((int) cp & 7) - { /* shouldn't happen, but just in case */ - cp = (char *) (((int) cp + 8) & ~7); - nblks--; - } -#endif /* not VMS */ - - /* save new header and link the nblks blocks together */ - nextf[nu] = (struct mhead *) cp; - siz = 1 << (nu + 3); - while (1) - { - ((struct mhead *) cp) -> mh_alloc = ISFREE; - ((struct mhead *) cp) -> mh_index = nu; - if (--nblks <= 0) break; - CHAIN ((struct mhead *) cp) = (struct mhead *) (cp + siz); - cp += siz; - } - CHAIN ((struct mhead *) cp) = 0; - -#ifdef BSD -#ifndef BSD4_1 - sigsetmask (oldmask); -#endif -#endif -} - -static void -getpool () -{ - register int nu; - char * sbrk (); - register char *cp = sbrk (0); - - if ((int) cp & 0x3ff) /* land on 1K boundaries */ - sbrk (1024 - ((int) cp & 0x3ff)); - - /* Record address of start of space allocated by malloc. */ - if (_malloc_base == 0) - _malloc_base = cp; - - /* Get 2k of storage */ - - cp = sbrk (04000); - if (cp == (char *) -1) - return; - - /* Divide it into an initial 8-word block - plus one block of size 2**nu for nu = 3 ... 10. */ - - CHAIN (cp) = nextf[0]; - nextf[0] = (struct mhead *) cp; - ((struct mhead *) cp) -> mh_alloc = ISFREE; - ((struct mhead *) cp) -> mh_index = 0; - cp += 8; - - for (nu = 0; nu < 7; nu++) - { - CHAIN (cp) = nextf[nu]; - nextf[nu] = (struct mhead *) cp; - ((struct mhead *) cp) -> mh_alloc = ISFREE; - ((struct mhead *) cp) -> mh_index = nu; - cp += 8 << nu; - } -} - -char * -malloc (n) /* get a block */ - unsigned n; -{ - register struct mhead *p; - register unsigned int nbytes; - register int nunits = 0; - - /* Figure out how many bytes are required, rounding up to the nearest - multiple of 8, then figure out which nestf[] area to use. - Both the beginning of the header and the beginning of the - block should be on an eight byte boundary. */ - nbytes = (n + ((sizeof *p + 7) & ~7) + EXTRA + 7) & ~7; - { - register unsigned int shiftr = (nbytes - 1) >> 2; - - while (shiftr >>= 1) - nunits++; - } - - /* In case this is reentrant use of malloc from signal handler, - pick a block size that no other malloc level is currently - trying to allocate. That's the easiest harmless way not to - interfere with the other level of execution. */ - while (busy[nunits]) nunits++; - busy[nunits] = 1; - - /* If there are no blocks of the appropriate size, go get some */ - /* COULD SPLIT UP A LARGER BLOCK HERE ... ACT */ - if (nextf[nunits] == 0) - morecore (nunits); - - /* Get one block off the list, and set the new list head */ - if ((p = nextf[nunits]) == 0) - { - busy[nunits] = 0; - return 0; - } - nextf[nunits] = CHAIN (p); - busy[nunits] = 0; - - /* Check for free block clobbered */ - /* If not for this check, we would gobble a clobbered free chain ptr */ - /* and bomb out on the NEXT allocate of this size block */ - if (p -> mh_alloc != ISFREE || p -> mh_index != nunits) -#ifdef rcheck - botch ("block on free list clobbered"); -#else /* not rcheck */ - abort (); -#endif /* not rcheck */ - - /* Fill in the info, and if range checking, set up the magic numbers */ - p -> mh_alloc = ISALLOC; -#ifdef rcheck - p -> mh_nbytes = n; - p -> mh_magic4 = MAGIC4; - { - /* Get the location n after the beginning of the user's space. */ - register char *m = (char *) p + ((sizeof *p + 7) & ~7) + n; - - *m++ = MAGIC1, *m++ = MAGIC1, *m++ = MAGIC1, *m = MAGIC1; - } -#else /* not rcheck */ - p -> mh_size = n; -#endif /* not rcheck */ -#ifdef MSTATS - nmalloc[nunits]++; - nmal++; -#endif /* MSTATS */ - return (char *) p + ((sizeof *p + 7) & ~7); -} - -free (mem) - char *mem; -{ - register struct mhead *p; - { - register char *ap = mem; - - if (ap == 0) - return; - - p = (struct mhead *) (ap - ((sizeof *p + 7) & ~7)); - if (p -> mh_alloc == ISMEMALIGN) - { - ap -= p->mh_size; - p = (struct mhead *) (ap - ((sizeof *p + 7) & ~7)); - } - -#ifndef rcheck - if (p -> mh_alloc != ISALLOC) - abort (); - -#else rcheck - if (p -> mh_alloc != ISALLOC) - { - if (p -> mh_alloc == ISFREE) - botch ("free: Called with already freed block argument\n"); - else - botch ("free: Called with bad argument\n"); - } - - ASSERT (p -> mh_magic4 == MAGIC4); - ap += p -> mh_nbytes; - ASSERT (*ap++ == MAGIC1); ASSERT (*ap++ == MAGIC1); - ASSERT (*ap++ == MAGIC1); ASSERT (*ap == MAGIC1); -#endif /* rcheck */ - } - { - register int nunits = p -> mh_index; - - ASSERT (nunits <= 29); - p -> mh_alloc = ISFREE; - - /* Protect against signal handlers calling malloc. */ - busy[nunits] = 1; - /* Put this block on the free list. */ - CHAIN (p) = nextf[nunits]; - nextf[nunits] = p; - busy[nunits] = 0; - -#ifdef MSTATS - nmalloc[nunits]--; - nfre++; -#endif /* MSTATS */ - } -} - -char * -realloc (mem, n) - char *mem; - register unsigned n; -{ - register struct mhead *p; - register unsigned int tocopy; - register unsigned int nbytes; - register int nunits; - - if (mem == 0) - return malloc (n); - p = (struct mhead *) (mem - ((sizeof *p + 7) & ~7)); - nunits = p -> mh_index; - ASSERT (p -> mh_alloc == ISALLOC); -#ifdef rcheck - ASSERT (p -> mh_magic4 == MAGIC4); - { - register char *m = mem + (tocopy = p -> mh_nbytes); - ASSERT (*m++ == MAGIC1); ASSERT (*m++ == MAGIC1); - ASSERT (*m++ == MAGIC1); ASSERT (*m == MAGIC1); - } -#else /* not rcheck */ - if (p -> mh_index >= 13) - tocopy = (1 << (p -> mh_index + 3)) - ((sizeof *p + 7) & ~7); - else - tocopy = p -> mh_size; -#endif /* not rcheck */ - - /* See if desired size rounds to same power of 2 as actual size. */ - nbytes = (n + ((sizeof *p + 7) & ~7) + EXTRA + 7) & ~7; - - /* If ok, use the same block, just marking its size as changed. */ - if (nbytes > (4 << nunits) && nbytes <= (8 << nunits)) - { -#ifdef rcheck - register char *m = mem + tocopy; - *m++ = 0; *m++ = 0; *m++ = 0; *m++ = 0; - p-> mh_nbytes = n; - m = mem + n; - *m++ = MAGIC1; *m++ = MAGIC1; *m++ = MAGIC1; *m++ = MAGIC1; -#else /* not rcheck */ - p -> mh_size = n; -#endif /* not rcheck */ - return mem; - } - - if (n < tocopy) - tocopy = n; - { - register char *new; - - if ((new = malloc (n)) == 0) - return 0; - bcopy (mem, new, tocopy); - free (mem); - return new; - } -} - -/* This is in case something linked with Emacs calls calloc. */ - -char * -calloc (num, size) - unsigned num, size; -{ - register char *mem; - - num *= size; - mem = malloc (num); - if (mem != 0) - bzero (mem, num); - return mem; -} - -#ifndef VMS - -char * -memalign (alignment, size) - unsigned alignment, size; -{ - register char *ptr = malloc (size + alignment); - register char *aligned; - register struct mhead *p; - - if (ptr == 0) - return 0; - /* If entire block has the desired alignment, just accept it. */ - if (((int) ptr & (alignment - 1)) == 0) - return ptr; - /* Otherwise, get address of byte in the block that has that alignment. */ - aligned = (char *) (((int) ptr + alignment - 1) & -alignment); - - /* Store a suitable indication of how to free the block, - so that free can find the true beginning of it. */ - p = (struct mhead *) (aligned - ((7 + sizeof (struct mhead)) & ~7)); - p -> mh_size = aligned - ptr; - p -> mh_alloc = ISMEMALIGN; - return aligned; -} - -#ifndef HPUX -/* This runs into trouble with getpagesize on HPUX. - Patching out seems cleaner than the ugly fix needed. */ -char * -valloc (size) -{ - return memalign (getpagesize (), size); -} -#endif /* not HPUX */ -#endif /* not VMS */ - -#ifdef MSTATS -/* Return statistics describing allocation of blocks of size 2**n. */ - -struct mstats_value - { - int blocksize; - int nfree; - int nused; - }; - -struct mstats_value -malloc_stats (size) - int size; -{ - struct mstats_value v; - register int i; - register struct mhead *p; - - v.nfree = 0; - - if (size < 0 || size >= 30) - { - v.blocksize = 0; - v.nused = 0; - return v; - } - - v.blocksize = 1 << (size + 3); - v.nused = nmalloc[size]; - - for (p = nextf[size]; p; p = CHAIN (p)) - v.nfree++; - - return v; -} -int -malloc_mem_used () -{ - int i; - int size_used; - - size_used = 0; - - for (i = 0; i < 30; i++) - { - int allocation_size = 1 << (i + 3); - struct mhead *p; - - size_used += nmalloc[i] * allocation_size; - } - - return size_used; -} - -int -malloc_mem_free () -{ - int i; - int size_unused; - - size_unused = 0; - - for (i = 0; i < 30; i++) - { - int allocation_size = 1 << (i + 3); - struct mhead *p; - - for (p = nextf[i]; p ; p = CHAIN (p)) - size_unused += allocation_size; - } - - return size_unused; -} -#endif /* MSTATS */ - -/* - * This function returns the total number of bytes that the process - * will be allowed to allocate via the sbrk(2) system call. On - * BSD systems this is the total space allocatable to stack and - * data. On USG systems this is the data space only. - */ - -#ifdef USG - -get_lim_data () -{ - extern long ulimit (); - -#ifdef ULIMIT_BREAK_VALUE - lim_data = ULIMIT_BREAK_VALUE; -#else - lim_data = ulimit (3, 0); -#endif - - lim_data -= (long) data_space_start; -} - -#else /* not USG */ -#if defined (BSD4_1) || defined (VMS) - -get_lim_data () -{ - lim_data = vlimit (LIM_DATA, -1); -} - -#else /* not BSD4_1 and not VMS */ - -get_lim_data () -{ - struct rlimit XXrlimit; - - getrlimit (RLIMIT_DATA, &XXrlimit); -#ifdef RLIM_INFINITY - lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */ -#else - lim_data = XXrlimit.rlim_cur; /* soft limit */ -#endif -} - -#endif /* not BSD4_1 and not VMS */ -#endif /* not USG */ - -#ifdef VMS -/* There is a problem when dumping and restoring things on VMS. Calls - * to SBRK don't necessarily result in contiguous allocation. Dumping - * doesn't work when it isn't. Therefore, we make the initial - * allocation contiguous by allocating a big chunk, and do SBRKs from - * there. Once Emacs has dumped there is no reason to continue - * contiguous allocation, malloc doesn't depend on it. - * - * There is a further problem of using brk and sbrk while using VMS C - * run time library routines malloc, calloc, etc. The documentation - * says that this is a no-no, although I'm not sure why this would be - * a problem. In any case, we remove the necessity to call brk and - * sbrk, by calling calloc (to assure zero filled data) rather than - * sbrk. - * - * VMS_ALLOCATION_SIZE is the size of the allocation array. This - * should be larger than the malloc size before dumping. Making this - * too large will result in the startup procedure slowing down since - * it will require more space and time to map it in. - * - * The value for VMS_ALLOCATION_SIZE in the following define was determined - * by running emacs linked (and a large allocation) with the debugger and - * looking to see how much storage was used. The allocation was 201 pages, - * so I rounded it up to a power of two. - */ -#ifndef VMS_ALLOCATION_SIZE -#define VMS_ALLOCATION_SIZE (512*256) -#endif - -/* Use VMS RTL definitions */ -#undef sbrk -#undef brk -#undef malloc -int vms_out_initial = 0; -char vms_initial_buffer[VMS_ALLOCATION_SIZE]; -static char *vms_current_brk = &vms_initial_buffer; -static char *vms_end_brk = &vms_initial_buffer[VMS_ALLOCATION_SIZE-1]; - -#include - -char * -sys_sbrk (incr) - int incr; -{ - char *sbrk(), *temp, *ptr; - - if (vms_out_initial) - { - /* out of initial allocation... */ - if (!(temp = malloc (incr))) - temp = (char *) -1; - } - else - { - /* otherwise, go out of our area */ - ptr = vms_current_brk + incr; /* new current_brk */ - if (ptr <= vms_end_brk) - { - temp = vms_current_brk; - vms_current_brk = ptr; - } - else - { - vms_out_initial = 1; /* mark as out of initial allocation */ - if (!(temp = malloc (incr))) - temp = (char *) -1; - } - } - return temp; -} -#endif /* VMS */ diff --git a/gnu/lib/libregex/test/fileregex.c b/gnu/lib/libregex/test/fileregex.c deleted file mode 100644 index 08882e1ffd4a..000000000000 --- a/gnu/lib/libregex/test/fileregex.c +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef lint -static char rcsid[] = "$Id: fileregex.c,v 1.2 1993/08/02 17:24:16 mycroft Exp $"; -#endif /* not lint */ - -#include -#include -#include "regex.h" - -#define BYTEWIDTH 8 - -/* Sorry, but this is just a test program. */ -#define LINE_MAX 500 - -int -main (argc, argv) - int argc; - char *argv[]; -{ - FILE *f; - char *filename; - char pat[500]; /* Sorry for that maximum size, too. */ - char line[LINE_MAX]; - struct re_pattern_buffer buf; - char fastmap[(1 << BYTEWIDTH)]; - const char *compile_ret; - unsigned lineno = 1; - unsigned nfound = 0; - - /* Actually, it might be useful to allow the data file to be standard - input, and to specify the pattern on the command line. */ - if (argc != 2) - { - fprintf (stderr, "Usage: %s .\n", argv[0]); - exit (1); - } - - filename = argv[1]; - f = fopen (filename, "r"); - if (f == NULL) - perror (filename); - - buf.allocated = 0; - buf.buffer = NULL; - buf.fastmap = fastmap; - - printf ("Pattern = ", pat); - gets (pat); - - if (feof (stdin)) - { - putchar ('\n'); - exit (0); - } - - compile_ret = re_compile_pattern (pat, strlen (pat), &buf); - if (compile_ret != NULL) - { - fprintf (stderr, "%s: %s\n", pat, compile_ret); - exit (1); - } - - while (fgets (line, LINE_MAX, f) != NULL) - { - size_t len = strlen (line); - struct re_registers regs; - int search_ret - = re_search_2 (&buf, NULL, 0, line, len, 0, len, ®s, len); - - if (search_ret == -2) - { - fprintf (stderr, "%s:%d: re_search failed.\n", filename, lineno); - exit (1); - } - - nfound += search_ret != -1; - lineno++; - } - - printf ("Matches found: %u (out of %u lines).\n", nfound, lineno - 1); - return 0; -} diff --git a/gnu/lib/libregex/test/g++malloc.c b/gnu/lib/libregex/test/g++malloc.c deleted file mode 100644 index b75684778cb6..000000000000 --- a/gnu/lib/libregex/test/g++malloc.c +++ /dev/null @@ -1,1290 +0,0 @@ -#define inline - -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - -#ifndef lint -static char rcsid[] = "$Id: g++malloc.c,v 1.2 1993/08/02 17:24:17 mycroft Exp $"; -#endif /* not lint */ - -#ifndef NO_LIBGXX_MALLOC /* ignore whole file otherwise */ - -/* compile with -DMALLOC_STATS to collect statistics */ -/* collecting statistics slows down malloc by at least 15% */ - -#ifdef MALLOC_STATS -#define UPDATE_STATS(ARGS) {ARGS;} -#else -#define UPDATE_STATS(ARGS) -#endif - -/* History - - - Tue Jan 16 04:54:27 1990 Doug Lea (dl at g.oswego.edu) - - version 1 released in libg++ - - Sun Jan 21 05:52:47 1990 Doug Lea (dl at g.oswego.edu) - - bins are now own struct for, sanity. - - new victim search strategy: scan up and consolidate. - Both faster and less fragmentation. - - refined when to scan bins for consolidation, via consollink, etc. - - realloc: always try to expand chunk, avoiding some fragmentation. - - changed a few inlines into macros - - hardwired SBRK_UNIT to 4096 for uniformity across systems - - Tue Mar 20 14:18:23 1990 Doug Lea (dl at g.oswego.edu) - - calloc and cfree now correctly parameterized. - - Sun Apr 1 10:00:48 1990 Doug Lea (dl at g.oswego.edu) - - added memalign and valloc. - - Sun Jun 24 05:46:48 1990 Doug Lea (dl at g.oswego.edu) - - #include gepagesize.h only ifndef sun - cache pagesize after first call - - Wed Jul 25 08:35:19 1990 Doug Lea (dl at g.oswego.edu) - - No longer rely on a `designated victim': - - 1. It sometimes caused splits of large chunks - when smaller ones would do, leading to - bad worst-case fragmentation. - - 2. Scanning through the av array fast anyway, - so the overhead isn't worth it. - - To compensate, several other minor changes: - - 1. Unusable chunks are checked for consolidation during - searches inside bins, better distributing chunks - across bins. - - 2. Chunks are returned when found in malloc_find_space, - rather than finishing cleaning everything up, to - avoid wasted iterations due to (1). -*/ - -/* - A version of malloc/free/realloc tuned for C++ applications. - - Here's what you probably want to know first: - - In various tests, this appears to be about as fast as, - and usually substantially less memory-wasteful than BSD/GNUemacs malloc. - - Generally, it is slower (by perhaps 20%) than bsd-style malloc - only when bsd malloc would waste a great deal of space in - fragmented blocks, which this malloc recovers; or when, by - chance or design, nearly all requests are near the bsd malloc - power-of-2 allocation bin boundaries, and as many chunks are - used as are allocated. - - It uses more space than bsd malloc only when, again by chance - or design, only bsdmalloc bin-sized requests are malloced, or when - little dynamic space is malloced, since this malloc may grab larger - chunks from the system at a time than bsd. - - In other words, this malloc seems generally superior to bsd - except perhaps for programs that are specially tuned to - deal with bsdmalloc's characteristics. But even here, the - performance differences are slight. - - - This malloc, like any other, is a compromised design. - - - Chunks of memory are maintained using a `boundary tag' method as - described in e.g., Knuth or Standish. This means that the size of - the chunk is stored both in the front of the chunk and at the end. - This makes consolidating fragmented chunks into bigger chunks very fast. - The size field is also used to hold bits representing whether a - chunk is free or in use. - - Malloced chunks have space overhead of 8 bytes: The preceding - and trailing size fields. When they are freed, the list pointer - fields are also needed. - - Available chunks are kept in doubly linked lists. The lists are - maintained in an array of bins using a power-of-two method, except - that instead of 32 bins (one for each 1 << i), there are 128: each - power of two is split in quarters. The use of very fine bin sizes - closely approximates the use of one bin per actually used size, - without necessitating the overhead of locating such bins. It is - especially desirable in common C++ applications where large numbers - of identically-sized blocks are malloced/freed in some dynamic - manner, and then later are all freed. The finer bin sizes make - finding blocks fast, with little wasted overallocation. The - consolidation methods ensure that once the collection of blocks is - no longer useful, fragments are gathered into bigger chunks awaiting new - roles. - - The bins av[i] serve as heads of the lists. Bins contain a dummy - header for the chunk lists, and a `dirty' field used to indicate - whether the list may need to be scanned for consolidation. - - On allocation, the bin corresponding to the request size is - scanned, and if there is a chunk with size >= requested, it - is split, if too big, and used. Chunks on the list which are - too small are examined for consolidation during this traversal. - - If no chunk exists in the list bigger bins are scanned in search of - a victim. - - If no victim can be found, then smaller bins are examined for - consolidation in order to construct a victim. - - Finally, if consolidation fails to come up with a usable chunk, - more space is obtained from the system. - - After a split, the remainder is placed on - the back of the appropriate bin list. (All freed chunks are placed - on fronts of lists. All remaindered or consolidated chunks are - placed on the rear. Correspondingly, searching within a bin - starts at the front, but finding victims is from the back. All - of this approximates the effect of having 2 kinds of lists per - bin: returned chunks vs unallocated chunks, but without the overhead - of maintaining 2 lists.) - - Deallocation (free) consists only of placing the chunk on - a list. - - Reallocation proceeds in the usual way. If a chunk can be extended, - it is, else a malloc-copy-free sequence is taken. - - memalign requests more than enough space from malloc, finds a - spot within that chunk that meets the alignment request, and - then possibly frees the leading and trailing space. Overreliance - on memalign is a sure way to fragment space. - - - Some other implementation matters: - - 8 byte alignment is currently hardwired into the design. Calling - memalign will return a chunk that is both 8-byte aligned, and - meets the requested alignment. - - The basic overhead of a used chunk is 8 bytes: 4 at the front and - 4 at the end. - - When a chunk is free, 8 additional bytes are needed for free list - pointers. Thus, the minimum allocatable size is 16 bytes. - - The existence of front and back overhead permits some reasonably - effective fence-bashing checks: The front and back fields must - be identical. This is checked only within free() and realloc(). - The checks are fast enough to be made non-optional. - - The overwriting of parts of freed memory with the freelist pointers - can also be very effective (albeit in an annoying way) in helping - users track down dangling pointers. - - User overwriting of freed space will often result in crashes - within malloc or free. - - These routines are also tuned to C++ in that free(0) is a noop and - a failed malloc automatically calls (*new_handler)(). - - malloc(0) returns a pointer to something of the minimum allocatable size. - - Additional memory is gathered from the system (via sbrk) in a - way that allows chunks obtained across different sbrk calls to - be consolidated, but does not require contiguous memory: Thus, - it should be safe to intersperse mallocs with other sbrk calls. - - This malloc is NOT designed to work in multiprocessing applications. - No semaphores or other concurrency control are provided to ensure - that multiple malloc or free calls don't run at the same time, - which could be disasterous. - - VERY heavy use of inlines is made, for clarity. If this malloc - is ported via a compiler without inlining capabilities, all - inlines should be transformed into macros -- making them non-inline - makes malloc at least twice as slow. - - -*/ - - -/* preliminaries */ - -#ifdef __cplusplus -#include -#else -#include "//usr/include/stdio.h" /* needed for error reporting */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef USG -extern void* memset(void*, int, int); -extern void* memcpy(void*, const void*, int); -/*inline void bzero(void* s, int l) { memset(s, 0, l); }*/ -#else -/*extern void bzero(void*, unsigned int);*/ -#endif - -/*extern void bcopy(void*, void*, unsigned int);*/ - -extern void* sbrk(unsigned int); - -/* Put this in instead of commmented out stuff above. */ -#define bcopy(s,d,n) memcpy((d),(s),(n)) -#define bcmp(s1,s2,n) memcmp((s1),(s2),(n)) -#define bzero(s,n) memset((s),0,(n)) - - -#ifdef __GNUC__ -extern volatile void abort(); -#else -extern void abort(); -#endif - -#ifdef __cplusplus -}; /* end of extern "C" */ -#endif - - -/* A good multiple to call sbrk with */ - -#define SBRK_UNIT 4096 - - - -/* how to die on detected error */ - -#ifdef __GNUC__ -static volatile void malloc_user_error() -#else -static void malloc_user_error() -#endif -{ - fputs("malloc/free/realloc: clobbered space detected\n", stderr); abort(); -} - - - -/* Basic overhead for each malloc'ed chunk */ - - -struct malloc_chunk -{ - unsigned int size; /* Size in bytes, including overhead. */ - /* Or'ed with INUSE if in use. */ - - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; - -}; - -typedef struct malloc_chunk* mchunkptr; - -struct malloc_bin -{ - struct malloc_chunk hd; /* dummy list header */ - unsigned int dirty; /* True if maybe consolidatable */ - /* Wasting a word here makes */ - /* sizeof(bin) a power of 2, */ - /* which makes size2bin() faster */ -}; - -typedef struct malloc_bin* mbinptr; - - -/* sizes, alignments */ - - -#define SIZE_SZ (sizeof(unsigned int)) -#define MALLOC_MIN_OVERHEAD (SIZE_SZ + SIZE_SZ) -#define MALLOC_ALIGN_MASK (MALLOC_MIN_OVERHEAD - 1) - -#define MINSIZE (sizeof(struct malloc_chunk) + SIZE_SZ) /* MUST == 16! */ - - -/* pad request bytes into a usable size */ - -static inline unsigned int request2size(unsigned int request) -{ - return (request == 0) ? MINSIZE : - ((request + MALLOC_MIN_OVERHEAD + MALLOC_ALIGN_MASK) - & ~(MALLOC_ALIGN_MASK)); -} - - -static inline int aligned_OK(void* m) -{ - return ((unsigned int)(m) & (MALLOC_ALIGN_MASK)) == 0; -} - - -/* size field or'd with INUSE when in use */ -#define INUSE 0x1 - - - -/* the bins, initialized to have null double linked lists */ - -#define MAXBIN 120 /* 1 more than needed for 32 bit addresses */ - -#define FIRSTBIN (&(av[0])) - -static struct malloc_bin av[MAXBIN] = -{ - { { 0, &(av[0].hd), &(av[0].hd) }, 0 }, - { { 0, &(av[1].hd), &(av[1].hd) }, 0 }, - { { 0, &(av[2].hd), &(av[2].hd) }, 0 }, - { { 0, &(av[3].hd), &(av[3].hd) }, 0 }, - { { 0, &(av[4].hd), &(av[4].hd) }, 0 }, - { { 0, &(av[5].hd), &(av[5].hd) }, 0 }, - { { 0, &(av[6].hd), &(av[6].hd) }, 0 }, - { { 0, &(av[7].hd), &(av[7].hd) }, 0 }, - { { 0, &(av[8].hd), &(av[8].hd) }, 0 }, - { { 0, &(av[9].hd), &(av[9].hd) }, 0 }, - - { { 0, &(av[10].hd), &(av[10].hd) }, 0 }, - { { 0, &(av[11].hd), &(av[11].hd) }, 0 }, - { { 0, &(av[12].hd), &(av[12].hd) }, 0 }, - { { 0, &(av[13].hd), &(av[13].hd) }, 0 }, - { { 0, &(av[14].hd), &(av[14].hd) }, 0 }, - { { 0, &(av[15].hd), &(av[15].hd) }, 0 }, - { { 0, &(av[16].hd), &(av[16].hd) }, 0 }, - { { 0, &(av[17].hd), &(av[17].hd) }, 0 }, - { { 0, &(av[18].hd), &(av[18].hd) }, 0 }, - { { 0, &(av[19].hd), &(av[19].hd) }, 0 }, - - { { 0, &(av[20].hd), &(av[20].hd) }, 0 }, - { { 0, &(av[21].hd), &(av[21].hd) }, 0 }, - { { 0, &(av[22].hd), &(av[22].hd) }, 0 }, - { { 0, &(av[23].hd), &(av[23].hd) }, 0 }, - { { 0, &(av[24].hd), &(av[24].hd) }, 0 }, - { { 0, &(av[25].hd), &(av[25].hd) }, 0 }, - { { 0, &(av[26].hd), &(av[26].hd) }, 0 }, - { { 0, &(av[27].hd), &(av[27].hd) }, 0 }, - { { 0, &(av[28].hd), &(av[28].hd) }, 0 }, - { { 0, &(av[29].hd), &(av[29].hd) }, 0 }, - - { { 0, &(av[30].hd), &(av[30].hd) }, 0 }, - { { 0, &(av[31].hd), &(av[31].hd) }, 0 }, - { { 0, &(av[32].hd), &(av[32].hd) }, 0 }, - { { 0, &(av[33].hd), &(av[33].hd) }, 0 }, - { { 0, &(av[34].hd), &(av[34].hd) }, 0 }, - { { 0, &(av[35].hd), &(av[35].hd) }, 0 }, - { { 0, &(av[36].hd), &(av[36].hd) }, 0 }, - { { 0, &(av[37].hd), &(av[37].hd) }, 0 }, - { { 0, &(av[38].hd), &(av[38].hd) }, 0 }, - { { 0, &(av[39].hd), &(av[39].hd) }, 0 }, - - { { 0, &(av[40].hd), &(av[40].hd) }, 0 }, - { { 0, &(av[41].hd), &(av[41].hd) }, 0 }, - { { 0, &(av[42].hd), &(av[42].hd) }, 0 }, - { { 0, &(av[43].hd), &(av[43].hd) }, 0 }, - { { 0, &(av[44].hd), &(av[44].hd) }, 0 }, - { { 0, &(av[45].hd), &(av[45].hd) }, 0 }, - { { 0, &(av[46].hd), &(av[46].hd) }, 0 }, - { { 0, &(av[47].hd), &(av[47].hd) }, 0 }, - { { 0, &(av[48].hd), &(av[48].hd) }, 0 }, - { { 0, &(av[49].hd), &(av[49].hd) }, 0 }, - - { { 0, &(av[50].hd), &(av[50].hd) }, 0 }, - { { 0, &(av[51].hd), &(av[51].hd) }, 0 }, - { { 0, &(av[52].hd), &(av[52].hd) }, 0 }, - { { 0, &(av[53].hd), &(av[53].hd) }, 0 }, - { { 0, &(av[54].hd), &(av[54].hd) }, 0 }, - { { 0, &(av[55].hd), &(av[55].hd) }, 0 }, - { { 0, &(av[56].hd), &(av[56].hd) }, 0 }, - { { 0, &(av[57].hd), &(av[57].hd) }, 0 }, - { { 0, &(av[58].hd), &(av[58].hd) }, 0 }, - { { 0, &(av[59].hd), &(av[59].hd) }, 0 }, - - { { 0, &(av[60].hd), &(av[60].hd) }, 0 }, - { { 0, &(av[61].hd), &(av[61].hd) }, 0 }, - { { 0, &(av[62].hd), &(av[62].hd) }, 0 }, - { { 0, &(av[63].hd), &(av[63].hd) }, 0 }, - { { 0, &(av[64].hd), &(av[64].hd) }, 0 }, - { { 0, &(av[65].hd), &(av[65].hd) }, 0 }, - { { 0, &(av[66].hd), &(av[66].hd) }, 0 }, - { { 0, &(av[67].hd), &(av[67].hd) }, 0 }, - { { 0, &(av[68].hd), &(av[68].hd) }, 0 }, - { { 0, &(av[69].hd), &(av[69].hd) }, 0 }, - - { { 0, &(av[70].hd), &(av[70].hd) }, 0 }, - { { 0, &(av[71].hd), &(av[71].hd) }, 0 }, - { { 0, &(av[72].hd), &(av[72].hd) }, 0 }, - { { 0, &(av[73].hd), &(av[73].hd) }, 0 }, - { { 0, &(av[74].hd), &(av[74].hd) }, 0 }, - { { 0, &(av[75].hd), &(av[75].hd) }, 0 }, - { { 0, &(av[76].hd), &(av[76].hd) }, 0 }, - { { 0, &(av[77].hd), &(av[77].hd) }, 0 }, - { { 0, &(av[78].hd), &(av[78].hd) }, 0 }, - { { 0, &(av[79].hd), &(av[79].hd) }, 0 }, - - { { 0, &(av[80].hd), &(av[80].hd) }, 0 }, - { { 0, &(av[81].hd), &(av[81].hd) }, 0 }, - { { 0, &(av[82].hd), &(av[82].hd) }, 0 }, - { { 0, &(av[83].hd), &(av[83].hd) }, 0 }, - { { 0, &(av[84].hd), &(av[84].hd) }, 0 }, - { { 0, &(av[85].hd), &(av[85].hd) }, 0 }, - { { 0, &(av[86].hd), &(av[86].hd) }, 0 }, - { { 0, &(av[87].hd), &(av[87].hd) }, 0 }, - { { 0, &(av[88].hd), &(av[88].hd) }, 0 }, - { { 0, &(av[89].hd), &(av[89].hd) }, 0 }, - - { { 0, &(av[90].hd), &(av[90].hd) }, 0 }, - { { 0, &(av[91].hd), &(av[91].hd) }, 0 }, - { { 0, &(av[92].hd), &(av[92].hd) }, 0 }, - { { 0, &(av[93].hd), &(av[93].hd) }, 0 }, - { { 0, &(av[94].hd), &(av[94].hd) }, 0 }, - { { 0, &(av[95].hd), &(av[95].hd) }, 0 }, - { { 0, &(av[96].hd), &(av[96].hd) }, 0 }, - { { 0, &(av[97].hd), &(av[97].hd) }, 0 }, - { { 0, &(av[98].hd), &(av[98].hd) }, 0 }, - { { 0, &(av[99].hd), &(av[99].hd) }, 0 }, - - { { 0, &(av[100].hd), &(av[100].hd) }, 0 }, - { { 0, &(av[101].hd), &(av[101].hd) }, 0 }, - { { 0, &(av[102].hd), &(av[102].hd) }, 0 }, - { { 0, &(av[103].hd), &(av[103].hd) }, 0 }, - { { 0, &(av[104].hd), &(av[104].hd) }, 0 }, - { { 0, &(av[105].hd), &(av[105].hd) }, 0 }, - { { 0, &(av[106].hd), &(av[106].hd) }, 0 }, - { { 0, &(av[107].hd), &(av[107].hd) }, 0 }, - { { 0, &(av[108].hd), &(av[108].hd) }, 0 }, - { { 0, &(av[109].hd), &(av[109].hd) }, 0 }, - - { { 0, &(av[110].hd), &(av[110].hd) }, 0 }, - { { 0, &(av[111].hd), &(av[111].hd) }, 0 }, - { { 0, &(av[112].hd), &(av[112].hd) }, 0 }, - { { 0, &(av[113].hd), &(av[113].hd) }, 0 }, - { { 0, &(av[114].hd), &(av[114].hd) }, 0 }, - { { 0, &(av[115].hd), &(av[115].hd) }, 0 }, - { { 0, &(av[116].hd), &(av[116].hd) }, 0 }, - { { 0, &(av[117].hd), &(av[117].hd) }, 0 }, - { { 0, &(av[118].hd), &(av[118].hd) }, 0 }, - { { 0, &(av[119].hd), &(av[119].hd) }, 0 } -}; - -/* - indexing into bins -*/ - -static inline mbinptr size2bin(unsigned int sz) -{ - mbinptr b = av; - while (sz >= (MINSIZE * 2)) { b += 4; sz >>= 1; } /* find power of 2 */ - b += (sz - MINSIZE) >> 2; /* find quadrant */ - return b; -} - - - -/* counts maintained if MALLOC_STATS defined */ - -#ifdef MALLOC_STATS - -static unsigned int sbrked_mem; -static unsigned int requested_mem; -static unsigned int malloced_mem; -static unsigned int freed_mem; -static unsigned int max_used_mem; - -static unsigned int n_sbrks; -static unsigned int n_mallocs; -static unsigned int n_frees; -static unsigned int n_reallocs; -static unsigned int n_reallocs_with_copy; -static unsigned int n_avail; -static unsigned int max_inuse; - -static unsigned int n_malloc_chunks; -static unsigned int n_malloc_bins; - -static unsigned int n_split; -static unsigned int n_consol; - - -static void do_malloc_stats(const mchunkptr p) -{ - ++n_mallocs; - if ((n_mallocs-n_frees) > max_inuse) - max_inuse = n_mallocs - n_frees; - malloced_mem += (p->size & ~(INUSE)); - if (malloced_mem - freed_mem > max_used_mem) - max_used_mem = malloced_mem - freed_mem; -} - -static void do_free_stats(const mchunkptr p) -{ - ++n_frees; - freed_mem += (p->size & ~(INUSE)); -} - -#endif - - - -/* Utilities needed below for memalign */ -/* This is redundant with libg++ support, but not if used stand-alone */ - -static unsigned int gcd(unsigned int a, unsigned int b) -{ - unsigned int tmp; - - if (b > a) - { - tmp = a; a = b; b = tmp; - } - for(;;) - { - if (b == 0) - return a; - else if (b == 1) - return b; - else - { - tmp = b; - b = a % b; - a = tmp; - } - } -} - -static inline unsigned int lcm(unsigned int x, unsigned int y) -{ - return x / gcd(x, y) * y; -} - - - -/* maintaining INUSE via size field */ - - -#define inuse(p) ((p)->size & INUSE) -#define set_inuse(p) ((p)->size |= INUSE) -#define clear_inuse(b) ((p)->size &= ~INUSE) - - -/* operations on malloc_chunk addresses */ - - -/* return ptr to next physical malloc_chunk */ - -#define next_chunk(p) ((mchunkptr)((char*)(p) + (p)->size)) - -/* return ptr to previous physical malloc_chunk */ - -#define prev_chunk(p) ((mchunkptr)((char*)(p)-((((int*)(p))[-1]) & ~(INUSE)))) - -/* place size at front and back of chunk */ - - -static inline void set_size(mchunkptr p, unsigned int sz) -{ - p->size = *((int*)((char*)(p) + sz - SIZE_SZ)) = sz; -} - - - - -/* conversion from malloc headers to user pointers, and back */ - -static inline void* chunk2mem(mchunkptr p) -{ - void *mem; - set_inuse(p); -mem = (void*)((char*)(p) + SIZE_SZ); - return mem; -} - -/* xxxx my own */ -mchunkptr sanity_check(void* mem) -{ - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); - - /* a quick sanity check */ - unsigned int sz = p->size & ~(INUSE); - if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ))) - malloc_user_error(); - - return p; -} - - - - -static inline mchunkptr mem2chunk(void* mem) -{ - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); - - /* a quick sanity check */ - unsigned int sz = p->size & ~(INUSE); - if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ))) - malloc_user_error(); - - p->size = sz; /* clears INUSE */ - return p; -} - - - -/* maintaining bins & pointers */ - - -/* maximum bin actually used */ - -static mbinptr malloc_maxbin = FIRSTBIN; - - -/* operations on lists inside bins */ - - -/* take a chunk off a list */ - -static inline void unlink(mchunkptr p) -{ - mchunkptr b = p->bk; - mchunkptr f = p->fd; - - f->bk = b; b->fd = f; - - UPDATE_STATS (--n_avail); -} - - - -/* split a chunk and place on the back of a list */ - -static inline void split(mchunkptr p, unsigned int offset) -{ - unsigned int room = p->size - offset; - if (room >= MINSIZE) - { - mbinptr bn = size2bin(room); /* new bin */ - mchunkptr h = &(bn->hd); /* its head */ - mchunkptr b = h->bk; /* old back element */ - mchunkptr t = (mchunkptr)((char*)(p) + offset); /* remaindered chunk */ - - /* set size */ - t->size = *((int*)((char*)(t) + room - SIZE_SZ)) = room; - - /* link up */ - t->bk = b; t->fd = h; h->bk = b->fd = t; - - /* adjust maxbin (h == b means was empty) */ - if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; - - /* adjust size of chunk to be returned */ - p->size = *((int*)((char*)(p) + offset - SIZE_SZ)) = offset; - - UPDATE_STATS ((++n_split, ++n_avail)); - } -} - - - -/* place a consolidated chunk on the back of a list */ -/* like above, except no split */ - -static inline void consollink(mchunkptr p) -{ - mbinptr bn = size2bin(p->size); - mchunkptr h = &(bn->hd); - mchunkptr b = h->bk; - - p->bk = b; p->fd = h; h->bk = b->fd = p; - - if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; - - UPDATE_STATS(++n_avail); -} - - -/* place a freed chunk on the front of a list */ - -static inline void frontlink(mchunkptr p) -{ - mbinptr bn = size2bin(p->size); - mchunkptr h = &(bn->hd); - mchunkptr f = h->fd; - - p->bk = h; p->fd = f; f->bk = h->fd = p; - - if (h == f && bn > malloc_maxbin) malloc_maxbin = bn; - - bn->dirty = 1; - - UPDATE_STATS(++n_avail); -} - - - -/* Dealing with sbrk */ - - -/* To link consecutive sbrk regions when possible */ - -static int* last_sbrk_end; - - -/* who to call when sbrk returns failure */ - -#ifndef NO_NEW_HANDLER -typedef volatile void (*vfp)(); -#ifdef __cplusplus -extern "C" vfp __new_handler; -#else -extern vfp __new_handler; -#endif -#endif - -static mchunkptr malloc_from_sys(unsigned nb) -{ - mchunkptr p; - unsigned int sbrk_size; - int* ip; - - /* Minimally, we need to pad with enough space */ - /* to place dummy size/use fields to ends if needed */ - - sbrk_size = ((nb + SBRK_UNIT - 1 + SIZE_SZ + SIZE_SZ) - / SBRK_UNIT) * SBRK_UNIT; - - ip = (int*)(sbrk(sbrk_size)); - if ((char*)ip == (char*)(-1)) /* sbrk returns -1 on failure */ - { -#ifndef NO_NEW_HANDLER - (*__new_handler) (); -#endif - return 0; - } - - UPDATE_STATS ((++n_sbrks, sbrked_mem += sbrk_size)); - - - if (last_sbrk_end != &ip[-1]) - { - /* It's either first time through or someone else called sbrk. */ - /* Arrange end-markers at front & back */ - - /* Shouldn't be necessary, but better to be safe */ - while (!aligned_OK(ip)) { ++ip; sbrk_size -= SIZE_SZ; } - - - /* Mark the front as in use to prevent merging. */ - /* Note we can get away with only 1 word, not MINSIZE overhead here */ - - *ip++ = SIZE_SZ | INUSE; - - p = (mchunkptr)ip; - set_size(p,sbrk_size - (SIZE_SZ + SIZE_SZ)); - - } - else - { - mchunkptr l; - - /* We can safely make the header start at end of prev sbrked chunk. */ - /* We will still have space left at the end from a previous call */ - /* to place the end marker, below */ - - p = (mchunkptr)(last_sbrk_end); - set_size(p, sbrk_size); - - - /* Even better, maybe we can merge with last fragment: */ - - l = prev_chunk(p); - if (!inuse(l)) - { - unlink(l); - set_size(l, p->size + l->size); - p = l; - } - - } - - /* mark the end of sbrked space as in use to prevent merging */ - - last_sbrk_end = (int*)((char*)p + p->size); - *last_sbrk_end = SIZE_SZ | INUSE; - - UPDATE_STATS((++n_avail, ++n_malloc_chunks)); - - /* make it safe to unlink in malloc */ - UPDATE_STATS(++n_avail); - p->fd = p->bk = p; - - return p; -} - - - -/* Consolidate dirty bins. */ -/* Stop if found a chunk big enough to satisfy current malloc request */ - -/* (It requires much less bookkeeping to consolidate entire bins */ -/* at once than to keep records of which chunks might be */ -/* consolidatable. So long as the lists are short, which we */ -/* try to ensure via small bin ranges, there is little wasted effort.) */ - -static mchunkptr malloc_find_space(unsigned int nb) -{ - mbinptr b; - - /* first, re-adjust max used bin */ - - while (malloc_maxbin >= FIRSTBIN && - malloc_maxbin->hd.bk == &(malloc_maxbin->hd)) - { - malloc_maxbin->dirty = 0; - --malloc_maxbin; - } - - for (b = malloc_maxbin; b >= FIRSTBIN; --b) - { - UPDATE_STATS(++n_malloc_bins); - - if (b->dirty) - { - mchunkptr h = &(b->hd); /* head of list */ - mchunkptr p = h->fd; /* chunk traverser */ - - while (p != h) - { - mchunkptr nextp = p->fd; /* save, in case of relinks */ - int consolidated = 0; /* only unlink/relink if consolidated */ - - mchunkptr t; - - UPDATE_STATS(++n_malloc_chunks); - - while (!inuse(t = prev_chunk(p))) /* consolidate backward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(t, t->size + p->size); - p = t; - UPDATE_STATS (++n_consol); - } - - while (!inuse(t = next_chunk(p))) /* consolidate forward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(p, p->size + t->size); - UPDATE_STATS (++n_consol); - } - - if (consolidated) - { - if (p->size >= nb) - { - /* make it safe to unlink in malloc */ - UPDATE_STATS(++n_avail); - p->fd = p->bk = p; - return p; - } - else - consollink(p); - } - - p = nextp; - - } - - b->dirty = 0; - - } - } - - /* nothing available - sbrk some more */ - - return malloc_from_sys(nb); -} - - - -/* Finally, the user-level functions */ - -void* malloc(unsigned int bytes) -{ - unsigned int nb = request2size(bytes); /* padded request size */ - mbinptr b = size2bin(nb); /* corresponding bin */ - mchunkptr hd = &(b->hd); /* head of its list */ - mchunkptr p = hd->fd; /* chunk traverser */ - - UPDATE_STATS((requested_mem+=bytes, ++n_malloc_bins)); - - /* Try a (near) exact match in own bin */ - /* clean out unusable but consolidatable chunks in bin while traversing */ - - while (p != hd) - { - UPDATE_STATS(++n_malloc_chunks); - if (p->size >= nb) - goto found; - else /* try to consolidate; same code as malloc_find_space */ - { - mchunkptr nextp = p->fd; /* save, in case of relinks */ - int consolidated = 0; /* only unlink/relink if consolidated */ - - mchunkptr t; - - while (!inuse(t = prev_chunk(p))) /* consolidate backward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(t, t->size + p->size); - p = t; - UPDATE_STATS (++n_consol); - } - - while (!inuse(t = next_chunk(p))) /* consolidate forward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(p, p->size + t->size); - UPDATE_STATS (++n_consol); - } - - if (consolidated) - { - if (p->size >= nb) - { - /* make it safe to unlink again below */ - UPDATE_STATS(++n_avail); - p->fd = p->bk = p; - goto found; - } - else - consollink(p); - } - - p = nextp; - - } - } - - b->dirty = 0; /* true if got here */ - - /* Scan bigger bins for a victim */ - - while (++b <= malloc_maxbin) - { - UPDATE_STATS(++n_malloc_bins); - if ((p = b->hd.bk) != &(b->hd)) /* no need to check size */ - goto found; - } - - /* Consolidate or sbrk */ - - p = malloc_find_space(nb); - - if (p == 0) return 0; /* allocation failure */ - - found: /* Use what we found */ - - unlink(p); - split(p, nb); - UPDATE_STATS(do_malloc_stats(p)); - return chunk2mem(p); -} - - - - -void free(void* mem) -{ - if (mem != 0) - { - mchunkptr p = mem2chunk(mem); - UPDATE_STATS(do_free_stats(p)); - frontlink(p); - } -} - - -void* calloc(unsigned int n, unsigned int elem_size) -{ - unsigned int sz = n * elem_size; - void* p = malloc(sz); - bzero(p, sz); - return p; -}; - -/* This is here for compatibility with older systems */ -void cfree(void *mem) -{ - free(mem); -} - - -unsigned int malloc_usable_size(void* mem) -{ - if (mem == 0) - return 0; - else - { - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); - unsigned int sz = p->size & ~(INUSE); - if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ))) - return 0; - else - return sz - MALLOC_MIN_OVERHEAD; - } -} - - - -void* realloc(void* mem, unsigned int bytes) -{ - if (mem == 0) - return malloc(bytes); - else - { - unsigned int nb = request2size(bytes); - mchunkptr p = mem2chunk(mem); - unsigned int oldsize = p->size; - int room; - mchunkptr nxt; - - UPDATE_STATS((++n_reallocs, requested_mem += bytes-oldsize)); - - /* try to expand (even if already big enough), to clean up chunk */ - - while (!inuse(nxt = next_chunk(p))) - { - UPDATE_STATS ((malloced_mem += nxt->size, ++n_consol)); - unlink(nxt); - set_size(p, p->size + nxt->size); - } - - room = p->size - nb; - if (room >= 0) - { - split(p, nb); - UPDATE_STATS(malloced_mem -= room); - return chunk2mem(p); - } - else /* do the obvious */ - { - void* newmem; - set_inuse(p); /* don't let malloc consolidate us yet! */ - newmem = malloc(nb); - bcopy(mem, newmem, oldsize - SIZE_SZ); - free(mem); - UPDATE_STATS(++n_reallocs_with_copy); - return newmem; - } - } -} - - - -/* return a pointer to space with at least the alignment requested */ - -void* memalign(unsigned int alignment, unsigned int bytes) -{ - mchunkptr p; - unsigned int nb = request2size(bytes); - - /* find an alignment that both we and the user can live with: */ - /* least common multiple guarantees mutual happiness */ - unsigned int align = lcm(alignment, MALLOC_MIN_OVERHEAD); - unsigned int mask = align - 1; - - /* call malloc with worst case padding to hit alignment; */ - /* we will give back extra */ - - unsigned int req = nb + align + MINSIZE; - void* m = malloc(req); - - if (m == 0) return m; - - p = mem2chunk(m); - - /* keep statistics on track */ - - UPDATE_STATS(--n_mallocs); - UPDATE_STATS(malloced_mem -= p->size); - UPDATE_STATS(requested_mem -= req); - UPDATE_STATS(requested_mem += bytes); - - if (((int)(m) & (mask)) != 0) /* misaligned */ - { - - /* find an aligned spot inside chunk */ - - mchunkptr ap = (mchunkptr)(( ((int)(m) + mask) & -align) - SIZE_SZ); - - unsigned int gap = (unsigned int)(ap) - (unsigned int)(p); - unsigned int room; - - /* we need to give back leading space in a chunk of at least MINSIZE */ - - if (gap < MINSIZE) - { - /* This works since align >= MINSIZE */ - /* and we've malloc'd enough total room */ - - ap = (mchunkptr)( (int)(ap) + align ); - gap += align; - } - - if (gap + nb > p->size) /* can't happen unless chunk sizes corrupted */ - malloc_user_error(); - - room = p->size - gap; - - /* give back leader */ - set_size(p, gap); - consollink(p); - - /* use the rest */ - p = ap; - set_size(p, room); - } - - /* also give back spare room at the end */ - - split(p, nb); - UPDATE_STATS(do_malloc_stats(p)); - return chunk2mem(p); - -} - -#ifndef sun -#include "getpagesize.h" -#endif - -static unsigned int malloc_pagesize = 0; - -void* valloc(unsigned int bytes) -{ - if (malloc_pagesize == 0) malloc_pagesize = getpagesize(); - return memalign (malloc_pagesize, bytes); -} - - -void malloc_stats() -{ -#ifndef MALLOC_STATS -} -#else - int i; - mchunkptr p; - double nm = (double)(n_mallocs + n_reallocs); - - fprintf(stderr, "\nmalloc statistics\n\n"); - - if (n_mallocs != 0) - fprintf(stderr, "requests = %10u total size = %10u\tave = %10u\n", - n_mallocs, requested_mem, requested_mem/n_mallocs); - - if (n_mallocs != 0) - fprintf(stderr, "mallocs = %10u total size = %10u\tave = %10u\n", - n_mallocs, malloced_mem, malloced_mem/n_mallocs); - - if (n_frees != 0) - fprintf(stderr, "frees = %10u total size = %10u\tave = %10u\n", - n_frees, freed_mem, freed_mem/n_frees); - - if (n_mallocs-n_frees != 0) - fprintf(stderr, "in use = %10u total size = %10u\tave = %10u\n", - n_mallocs-n_frees, malloced_mem-freed_mem, - (malloced_mem-freed_mem) / (n_mallocs-n_frees)); - - if (max_inuse != 0) - fprintf(stderr, "max in use= %10u total size = %10u\tave = %10u\n", - max_inuse, max_used_mem, max_used_mem / max_inuse); - - if (n_avail != 0) - fprintf(stderr, "available = %10u total size = %10u\tave = %10u\n", - n_avail, sbrked_mem - (malloced_mem-freed_mem), - (sbrked_mem - (malloced_mem-freed_mem)) / n_avail); - - if (n_sbrks != 0) - fprintf(stderr, "sbrks = %10u total size = %10u\tave = %10u\n\n", - n_sbrks, sbrked_mem, sbrked_mem/ n_sbrks); - - if (n_reallocs != 0) - fprintf(stderr, "reallocs = %10u with copy = %10u\n\n", - n_reallocs, n_reallocs_with_copy); - - - if (nm != 0) - { - fprintf(stderr, "chunks scanned per malloc = %6.3f\n", - n_malloc_chunks / nm); - fprintf(stderr, "bins scanned per malloc = %6.3f\n", - n_malloc_bins / nm); - fprintf(stderr, "splits per malloc = %6.3f\n", - n_split / nm); - fprintf(stderr, "consolidations per malloc = %6.3f\n", - n_consol / nm); - } - - fprintf(stderr, "\nfree chunks:\n"); - for (i = 0; i < MAXBIN; ++i) - { - p = av[i].hd.fd; - if (p != &(av[i].hd)) - { - unsigned int count = 1; - unsigned int sz = p->size; - for (p = p->fd; p != &(av[i].hd); p = p->fd) - { - if (p->size == sz) - ++count; - else - { - fprintf(stderr, "\tsize = %10u count = %5u\n", sz, count); - count = 1; - sz = p->size; - } - } - - fprintf(stderr, "\tsize = %10u count = %5u\n", sz, count); - - } - } -} -#endif /* MALLOC_STATS */ - -#endif /* NO_LIBGXX_MALLOC */ - - diff --git a/gnu/lib/libregex/test/getpagesize.h b/gnu/lib/libregex/test/getpagesize.h deleted file mode 100644 index 962e7ccefa76..000000000000 --- a/gnu/lib/libregex/test/getpagesize.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $Id: getpagesize.h,v 1.2 1993/08/02 17:24:19 mycroft Exp $ */ - -#ifdef BSD -#ifndef BSD4_1 -#define HAVE_GETPAGESIZE -#endif -#endif - -#ifndef HAVE_GETPAGESIZE - -#include - -#ifdef EXEC_PAGESIZE -#define getpagesize() EXEC_PAGESIZE -#else -#ifdef NBPG -#define getpagesize() NBPG * CLSIZE -#ifndef CLSIZE -#define CLSIZE 1 -#endif /* no CLSIZE */ -#else /* no NBPG */ -#define getpagesize() NBPC -#endif /* no NBPG */ -#endif /* no EXEC_PAGESIZE */ - -#endif /* not HAVE_GETPAGESIZE */ - diff --git a/gnu/lib/libregex/test/iregex.c b/gnu/lib/libregex/test/iregex.c deleted file mode 100644 index ca4c733239f4..000000000000 --- a/gnu/lib/libregex/test/iregex.c +++ /dev/null @@ -1,168 +0,0 @@ -/* Main program for interactive testing. For maximum output, compile - this and regex.c with -DDEBUG. */ - -#ifndef lint -static char rcsid[] = "$Id: iregex.c,v 1.2 1993/08/02 17:24:19 mycroft Exp $"; -#endif /* not lint */ - -#include -#include -#include "regex.h" - -/* Don't bother to guess about vs , etc. */ -extern int strlen (); - -#define BYTEWIDTH 8 - -extern void printchar (); -extern char upcase[]; - -static void scanstring (); -static void print_regs (); - -int -main (argc, argv) - int argc; - char **argv; -{ - int i; - struct re_pattern_buffer buf; - char fastmap[(1 << BYTEWIDTH)]; - - /* Allow a command argument to specify the style of syntax. You can - use the `syntax' program to decode integer syntax values. */ - if (argc > 1) - re_set_syntax (atoi (argv[1])); - - buf.allocated = 0; - buf.buffer = NULL; - buf.fastmap = fastmap; - buf.translate = upcase; - - for (;;) - { - char pat[500], str[500]; - struct re_registers regs; - - /* Some C compilers don't like `char pat[500] = ""'. */ - pat[0] = 0; - - printf ("Pattern (%s) = ", pat); - gets (pat); - scanstring (pat); - - if (feof (stdin)) - { - putchar ('\n'); - exit (0); - } - - if (*pat) - { - re_compile_pattern (pat, strlen (pat), &buf); - re_compile_fastmap (&buf); -#ifdef DEBUG - print_compiled_pattern (&buf); -#endif - } - - printf ("String = "); - gets (str); /* Now read the string to match against */ - scanstring (str); - - i = re_match (&buf, str, strlen (str), 0, ®s); - printf ("Match value %d.\t", i); - if (i >= 0) - print_regs (regs); - putchar ('\n'); - - i = re_search (&buf, str, strlen (str), 0, strlen (str), ®s); - printf ("Search value %d.\t", i); - if (i >= 0) - print_regs (regs); - putchar ('\n'); - } - - /* We never get here, but what the heck. */ - return 0; -} - -void -scanstring (s) - char *s; -{ - char *write = s; - - while (*s != '\0') - { - if (*s == '\\') - { - s++; - - switch (*s) - { - case '\0': - break; - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - *write = *s++ - '0'; - - if ('0' <= *s && *s <= '9') - { - *write = (*write << 3) + (*s++ - '0'); - if ('0' <= *s && *s <= '9') - *write = (*write << 3) + (*s++ - '0'); - } - write++; - break; - - case 'n': - *write++ = '\n'; - s++; - break; - - case 't': - *write++ = '\t'; - s++; - break; - - default: - *write++ = *s++; - break; - } - } - else - *write++ = *s++; - } - - *write++ = '\0'; -} - -/* Print REGS in human-readable form. */ - -void -print_regs (regs) - struct re_registers regs; -{ - int i, end; - - printf ("Registers: "); - - if (regs.num_regs == 0 || regs.start[0] == -1) - { - printf ("(none)"); - } - else - { - /* Find the last register pair that matched. */ - for (end = regs.num_regs - 1; end >= 0; end--) - if (regs.start[end] != -1) - break; - - printf ("[%d ", regs.start[0]); - for (i = 1; i <= end; i++) - printf ("(%d %d) ", regs.start[i], regs.end[i]); - printf ("%d]", regs.end[0]); - } -} diff --git a/gnu/lib/libregex/test/main.c b/gnu/lib/libregex/test/main.c deleted file mode 100644 index 7f8bb024e7c0..000000000000 --- a/gnu/lib/libregex/test/main.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Main routine for running various tests. Meant only to be linked with - all the auxiliary test source files, with `test' undefined. */ - -#ifndef lint -static char rcsid[] = "$Id: main.c,v 1.2 1993/08/02 17:24:20 mycroft Exp $"; -#endif /* not lint */ - -#include "test.h" - -test_type t = all_test; - - -/* Use this to run the tests we've thought of. */ - -int -main () -{ - switch (t) - { - case all_test: - test_regress (); - test_others (); - test_posix_basic (); - test_posix_extended (); - test_posix_interface (); - break; - - case other_test: - test_others (); - break; - - case posix_basic_test: - test_posix_basic (); - break; - - case posix_extended_test: - test_posix_extended (); - break; - - case posix_interface_test: - test_posix_interface (); - break; - - case regress_test: - test_regress (); - break; - - default: - fprintf (stderr, "Unknown test %d.\n", t); - } - - return 0; -} diff --git a/gnu/lib/libregex/test/malloc-test.c b/gnu/lib/libregex/test/malloc-test.c deleted file mode 100644 index f4b6ddcad537..000000000000 --- a/gnu/lib/libregex/test/malloc-test.c +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef lint -static char rcsid[] = "$Id: malloc-test.c,v 1.2 1993/08/02 17:24:21 mycroft Exp $"; -#endif /* not lint */ - -typedef struct { - unsigned *bits; - unsigned size; -} bits_list_type; - -#define BYTEWIDTH 8 -#define NULL 0 - -#define BITS_BLOCK_SIZE (sizeof (unsigned) * BYTEWIDTH) -#define BITS_BLOCK(position) ((position) / BITS_BLOCK_SIZE) -#define BITS_MASK(position) (1 << ((position) % BITS_BLOCK_SIZE)) - -static unsigned -init_bits_list (bits_list_ptr) - bits_list_type *bits_list_ptr; -{ - bits_list_ptr->bits = NULL; - bits_list_ptr->bits = (unsigned *) malloc (sizeof (unsigned)); - - if (bits_list_ptr->bits == NULL) - return 0; - - bits_list_ptr->bits[0] = (unsigned)0; - bits_list_ptr->size = BITS_BLOCK_SIZE; - - return 1; -} - - -main() -{ - bits_list_type dummy; - bits_list_type dummy_1; - bits_list_type dummy_2; - bits_list_type dummy_3; - - init_bits_list (&dummy); -printf("init 1\n"); - init_bits_list (&dummy_1); -printf("init 2\n"); - init_bits_list (&dummy_2); -printf("init 3\n"); - init_bits_list (&dummy_3); -printf("init 4\n"); -} diff --git a/gnu/lib/libregex/test/other.c b/gnu/lib/libregex/test/other.c deleted file mode 100644 index c5d847155e1c..000000000000 --- a/gnu/lib/libregex/test/other.c +++ /dev/null @@ -1,507 +0,0 @@ -/* other.c: test (not exhaustively) non-POSIX regular expressions. */ - -#ifndef lint -static char rcsid[] = "$Id: other.c,v 1.2 1993/08/02 17:24:22 mycroft Exp $"; -#endif /* not lint */ - -#include "test.h" - -void -test_others () -{ - struct re_registers regs; - - printf ("\nStarting non-POSIX tests.\n"); - t = other_test; - - test_should_match = true; - - /* The big question: does the group participate in the match, or match - the empty string? */ - re_set_syntax (RE_NO_BK_PARENS); - test_match ("(a*)*ab", "ab"); - TEST_REGISTERS ("(a*)*ab", "ab", 0, 2, 0, 0, -1, -1); - test_match ("(a*)*", ""); - TEST_REGISTERS ("(a*)*ab", "ab", 0, 0, 0, 0, -1, -1); - - /* This tests finding the highest and lowest active registers. */ - test_match ("(a(b)c(d(e)f)g)h(i(j)k(l(m)n)o)\\1\\2\\3\\4\\5\\6\\7\\8", - "abcdefghijklmnoabcdefgbdefeijklmnojlmnm"); - - /* Test that \< and \> match at the beginning and end of the string. */ - test_match ("\\", "abc"); - - /* May as well test \` and \' while we're at it. */ - test_match ("\\`abc\\'", "abc"); - -#if 0 - /* Test backreferencing and the fastmap -- which doesn't work. */ - test_fastmap ("(a)*\\1", "a", 0, 0); -#endif - - /* But at least we shouldn't search improperly. */ - test_search_return (-1, "(a)\\1", ""); - - re_set_syntax (RE_SYNTAX_EMACS); - - MATCH_SELF("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - MATCH_SELF ("a^"); - MATCH_SELF ("a^b"); - MATCH_SELF ("$a"); - MATCH_SELF ("a$b"); - - re_set_syntax (RE_BACKSLASH_ESCAPE_IN_LISTS); - test_match ("[\\^a]", "a"); - test_match ("[\\^a]", "^"); - - /* These op characters should be ordinary if RE_CONTEXT_INVALID_OPS - isn't set. */ - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_BRACES | RE_INTERVALS - | RE_NO_BK_PARENS); - MATCH_SELF ("*"); - test_match ("a|*", "*"); - test_match ("(*)", "*"); - - MATCH_SELF ("+"); - test_match ("a|+", "+"); - test_match ("(+)", "+"); - - MATCH_SELF ("?"); - test_match ("a|?", "?"); - test_match ("(?)", "?"); - - MATCH_SELF ("{1}"); - test_match ("a|{1}", "a"); - test_match ("a|{1}", "{1}"); - test_match ("({1})", "{1}"); - - test_match ("\\{", "{"); - - - re_set_syntax (RE_LIMITED_OPS); - MATCH_SELF ("|"); - MATCH_SELF ("a|"); - MATCH_SELF ("a|"); - MATCH_SELF ("a||"); - MATCH_SELF ("a||"); - MATCH_SELF ("(|)"); - - re_set_syntax (RE_SYNTAX_EMACS); - TEST_SEARCH ("^a", "b\na", 0, 3); - TEST_SEARCH ("b$", "b\na", 0, 3); - -#if 0 - /* Newline is no longer special for anchors (16 Sep 92). --karl */ - test_match_2 ("a\n^b", "a", "\nb"); - test_match_2 ("a$\nb", "a\n", "b"); -#endif - - /* Test grouping. */ - re_set_syntax (RE_NO_BK_PARENS); - - test_match ("()", ""); - test_fastmap ("()", "", 0, 0); - TEST_REGISTERS ("()", "", 0, 0, 0, 0, -1, -1); - - test_match ("((((((((()))))))))", ""); - test_fastmap ("((((((((()))))))))", "", 0, 0); - test_match ("a()b", "ab"); - TEST_REGISTERS ("a()b", "ab", 0, 2, 1, 1, -1, -1); - - test_match ("(((((((((())))))))))", ""); - test_fastmap ("(((((((((())))))))))", "", 0, 0); - - test_match ("()*", ""); - TEST_REGISTERS ("()*", "", 0, 0, 0, 0, -1, -1); /* empty string */ - test_match ("(())*", ""); - - re_set_syntax (RE_CONTEXT_INDEP_OPS); - test_match ("*", ""); - - re_set_syntax (RE_INTERVALS | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES); - test_match ("{1}", ""); /* Should remain an interval. */ - MATCH_SELF ("{1"); /* Not a valid interval. */ - - re_set_syntax (RE_NEWLINE_ALT); - test_match ("a\nb", "a"); - test_match ("a\nb", "b"); - - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); - test_match ("^a", "a"); - test_match ("(^a)", "a"); - test_match ("(a|^b)", "b"); - test_match ("a$", "a"); - test_match ("(a$)", "a"); - test_match ("a$|b", "a"); - - /* You should be able to have empty alternatives if RE_NO_EMPTY_ALTS - isn't set. */ - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); - - test_match ("|", ""); - test_match ("^|a", ""); - test_match ("^|a", "a"); - test_match ("a|", ""); - test_match ("a|", "a"); - test_match ("a|$", ""); - test_match ("a|$", "a"); - test_match ("a||b", "a"); - test_match ("a||b", ""); - test_match ("a||b", "b"); - test_match ("(|a)", ""); - test_match ("(|a)", "a"); - test_match ("(a|)", ""); - test_match ("(a|)", "a"); - - TEST_SEARCH ("a|$", "xa", 0, 2); - TEST_SEARCH ("a|$", "x", 0, 1); - TEST_SEARCH ("$|b", "x", 0, 1); - TEST_SEARCH ("$|b", "xb", 0, 2); - TEST_SEARCH ("c(a|$)", "xca", 0, 3); - TEST_SEARCH ("c(a|$)", "xc", 0, 2); - TEST_SEARCH ("c($|b)", "xcb", 0, 3); - TEST_SEARCH ("c($|b)", "xc", 0, 2); - TEST_SEARCH ("c($|b$)", "xcb", 0, 3); - TEST_SEARCH ("c($|b$)", "xc", 0, 2); - TEST_SEARCH ("c(a$|$)", "xca", 0, 3); - TEST_SEARCH ("c(a$|$)", "xc", 0, 2); - TEST_SEARCH ("(a$|b$)|$", "x", 0, 1); - TEST_SEARCH ("(a$|b$)|$", "xa", 0, 2); - TEST_SEARCH ("(a$|b$)|$", "xb", 0, 2); - TEST_SEARCH ("(a$|$)|c$", "x", 0, 1); - TEST_SEARCH ("(a$|$)|c$", "xa", 0, 2); - TEST_SEARCH ("(a$|$)|c$", "xc", 0, 2); - TEST_SEARCH ("($|b$)|c$", "x", 0, 1); - TEST_SEARCH ("($|b$)|c$", "xb", 0, 2); - TEST_SEARCH ("($|b$)|c$", "xc", 0, 2); - TEST_SEARCH ("c$|(a$|$)", "x", 0, 1); - TEST_SEARCH ("c$|(a$|$)", "xa", 0, 2); - TEST_SEARCH ("c$|(a$|$)", "xc", 0, 2); - TEST_SEARCH ("c$|($|b$)", "x", 0, 1); - TEST_SEARCH ("c$|($|b$)", "xb", 0, 2); - TEST_SEARCH ("c$|($|b$)", "xc", 0, 2); - TEST_SEARCH ("$|(a$|b$)", "x", 0, 1); - TEST_SEARCH ("$|(a$|b$)", "xa", 0, 2); - TEST_SEARCH ("$|(a$|b$)", "xb", 0, 2); - TEST_SEARCH ("c(a$|b$)|$", "x", 0, 1); - TEST_SEARCH ("c(a$|b$)|$", "xca", 0, 3); - TEST_SEARCH ("c(a$|b$)|$", "xcb", 0, 3); - TEST_SEARCH ("c(a$|$)|d$", "xc", 0, 2); - TEST_SEARCH ("c(a$|$)|d$", "xca", 0, 3); - TEST_SEARCH ("c(a$|$)|d$", "xd", 0, 2); - TEST_SEARCH ("c($|b$)|d$", "xc", 0, 2); - TEST_SEARCH ("c($|b$)|d$", "xcb", 0, 3); - TEST_SEARCH ("c($|b$)|d$", "xd", 0, 2); - TEST_SEARCH ("d(c$|e((a$|$)))", "xdc", 0, 3); - TEST_SEARCH ("d(c$|e((a$|$)))", "xde", 0, 3); - TEST_SEARCH ("d(c$|e((a$|$)))", "xdea", 0, 4); - TEST_SEARCH ("d(c$|e(($|b$)))", "xdc", 0, 3); - TEST_SEARCH ("d(c$|e(($|b$)))", "xde", 0, 3); - TEST_SEARCH ("d(c$|e(($|b$)))", "xdeb", 0, 4); - TEST_SEARCH ("d($|e((a$|b$)))", "xd", 0, 2); - TEST_SEARCH ("d($|e((a$|b$)))", "xdea", 0, 4); - TEST_SEARCH ("d($|e((a$|b$)))", "xdeb", 0, 4); - TEST_SEARCH ("a(b$|c$)|$", "x", 0, 1); - TEST_SEARCH ("a(b$|c$)|$", "xab", 0, 3); - TEST_SEARCH ("a(b$|c$)|$", "xac", 0, 3); - TEST_SEARCH ("a(b$|$)|d$", "xa", 0, 2); - TEST_SEARCH ("a(b$|$)|d$", "xab", 0, 3); - TEST_SEARCH ("a(b$|$)|d$", "xd", 0, 2); - TEST_SEARCH ("a($|c$)|d$", "xa", 0, 2); - TEST_SEARCH ("a($|c$)|d$", "xac", 0, 3); - TEST_SEARCH ("a($|c$)|d$", "xd", 0, 2); - TEST_SEARCH ("d$|a(b$|$)", "xd", 0, 2); - TEST_SEARCH ("d$|a(b$|$)", "xa", 0, 2); - TEST_SEARCH ("d$|a(b$|$)", "xab", 0, 3); - TEST_SEARCH ("d$|a($|c$)", "xd", 0, 2); - TEST_SEARCH ("d$|a($|c$)", "xa", 0, 2); - TEST_SEARCH ("d$|a($|c$)", "xac", 0, 3); - TEST_SEARCH ("$|a(b$|c$)", "x", 0, 1); - TEST_SEARCH ("$|a(b$|c$)", "xab", 0, 3); - TEST_SEARCH ("$|a(b$|c$)", "xac", 0, 3); - TEST_SEARCH ("(a)(b$|c$)|d$", "xab", 0, 3); - TEST_SEARCH ("(a)(b$|c$)|d$", "xac", 0, 3); - TEST_SEARCH ("(a)(b$|c$)|d$", "xd", 0, 2); - TEST_SEARCH ("(a)(b$|$)|d$", "xa", 0, 2); - TEST_SEARCH ("(a)(b$|$)|d$", "xab", 0, 3); - TEST_SEARCH ("(a)(b$|$)|d$", "xd", 0, 2); - TEST_SEARCH ("(a)($|c$)|d$", "xa", 0, 2); - TEST_SEARCH ("(a)($|c$)|d$", "xac", 0, 3); - TEST_SEARCH ("(a)($|c$)|d$", "xd", 0, 2); - TEST_SEARCH ("d$|(a)(b$|$)", "xd", 0, 2); - TEST_SEARCH ("d$|(a)(b$|$)", "xa", 0, 2); - TEST_SEARCH ("d$|(a)(b$|$)", "xab", 0, 3); - TEST_SEARCH ("d$|(a)($|c$)", "xd", 0, 2); - TEST_SEARCH ("d$|(a)($|c$)", "xa", 0, 2); - TEST_SEARCH ("d$|(a)($|c$)", "xac", 0, 3); - TEST_SEARCH ("$|(a)(b$|c$)", "x", 0, 1); - TEST_SEARCH ("$|(a)(b$|c$)", "xab", 0, 3); - TEST_SEARCH ("$|(a)(b$|c$)", "xac", 0, 3); - TEST_SEARCH ("d$|(c$|(a$|$))", "x", 0, 1); - TEST_SEARCH ("d$|(c$|(a$|$))", "xd", 0, 2); - TEST_SEARCH ("d$|(c$|(a$|$))", "xc", 0, 2); - TEST_SEARCH ("d$|(c$|(a$|$))", "xa", 0, 2); - TEST_SEARCH ("d$|(c$|($|b$))", "x", 0, 1); - TEST_SEARCH ("d$|(c$|($|b$))", "xd", 0, 2); - TEST_SEARCH ("d$|(c$|($|b$))", "xc", 0, 2); - TEST_SEARCH ("d$|(c$|($|b$))", "xb", 0, 2); - TEST_SEARCH ("d$|($|(a$|b$))", "x", 0, 1); - TEST_SEARCH ("d$|($|(a$|b$))", "xd", 0, 2); - TEST_SEARCH ("d$|($|(a$|b$))", "xa", 0, 2); - TEST_SEARCH ("d$|($|(a$|b$))", "xb", 0, 2); - TEST_SEARCH ("$|(c$|(a$|b$))", "x", 0, 1); - TEST_SEARCH ("$|(c$|(a$|b$))", "xc", 0, 2); - TEST_SEARCH ("$|(c$|(a$|b$))", "xa", 0, 2); - TEST_SEARCH ("$|(c$|(a$|b$))", "xb", 0, 2); - TEST_SEARCH ("d$|c(a$|$)", "xd", 0, 2); - TEST_SEARCH ("d$|c(a$|$)", "xc", 0, 2); - TEST_SEARCH ("d$|c(a$|$)", "xca", 0, 3); - TEST_SEARCH ("d$|c($|b$)", "xd", 0, 2); - TEST_SEARCH ("d$|c($|b$)", "xc", 0, 2); - TEST_SEARCH ("d$|c($|b$)", "xcb", 0, 3); - TEST_SEARCH ("$|c(a$|b$)", "x", 0, 1); - TEST_SEARCH ("$|c(a$|b$)", "xca", 0, 3); - TEST_SEARCH ("$|c(a$|b$)", "xcb", 0, 3); - TEST_SEARCH ("e(d$|c((a$|$)))", "xed", 0, 3); - TEST_SEARCH ("e(d$|c((a$|$)))", "xec", 0, 3); - TEST_SEARCH ("e(d$|c((a$|$)))", "xeca", 0, 3); - TEST_SEARCH ("e(d$|c(($|b$)))", "xed", 0, 3); - TEST_SEARCH ("e(d$|c(($|b$)))", "xec", 0, 3); - TEST_SEARCH ("e(d$|c(($|b$)))", "xecb", 0, 4); - TEST_SEARCH ("e($|c((a$|b$)))", "xe", 0, 2); - TEST_SEARCH ("e($|c((a$|b$)))", "xeca", 0, 4); - TEST_SEARCH ("e($|c((a$|b$)))", "xecb", 0, 4); - TEST_SEARCH ("ed$|(c((a$|$)))", "xed", 0, 3); - TEST_SEARCH ("ed$|(c((a$|$)))", "xc", 0, 2); - TEST_SEARCH ("ed$|(c((a$|$)))", "xca", 0, 3); - TEST_SEARCH ("ed$|(c(($|b$)))", "xed", 0, 3); - TEST_SEARCH ("ed$|(c(($|b$)))", "xc", 0, 2); - TEST_SEARCH ("ed$|(c(($|b$)))", "xcb", 0, 3); - TEST_SEARCH ("$|(c((a$|b$)))", "x", 0, 1); - TEST_SEARCH ("$|(c((a$|b$)))", "xca", 0, 3); - TEST_SEARCH ("$|(c((a$|b$)))", "xcb", 0, 3); - TEST_SEARCH ("d$|($|(a|b)$)", "x", 0, 1); - TEST_SEARCH ("d$|($|(a|b)$)", "xa", 0, 2); - TEST_SEARCH ("d$|($|(a|b)$)", "xb", 0, 2); - TEST_SEARCH ("$|(c$|(a|b)$)", "x", 0, 1); - TEST_SEARCH ("$|(c$|(a|b)$)", "xc", 0, 2); - TEST_SEARCH ("$|(c$|(a|b)$)", "xa", 0, 2); - TEST_SEARCH ("$|(c$|(a|b)$)", "xb", 0, 2); - - re_set_syntax (0); - test_match ("[^\n]", "a"); - test_match ("[^a]", "\n"); - - TEST_SEARCH ("^a", "b\na", 0, 3); - TEST_SEARCH ("b$", "b\na", 0, 3); - - test_case_fold ("[!-`]", "A"); - test_case_fold ("[!-`]", "a"); - - re_set_syntax (RE_CONTEXT_INDEP_OPS | RE_NO_BK_VBAR | RE_NO_BK_PARENS - | RE_NO_BK_BRACES | RE_INTERVALS); - valid_nonposix_pattern ("()^a"); - valid_nonposix_pattern ("()\\1^a"); - - /* Per Cederqvist (cedar@lysator.liu.se) bug. */ - - re_set_syntax (RE_SYNTAX_EMACS); - - /* One `a' before the \n and 638 a's after it. */ - test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "a\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - - /* No a's before the \n and 639 a's after it. */ - test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - - /* One `a' before the \n and 639 a's after it. */ - test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "a\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - - /* No a's before the \n and 640 a's after it. */ - test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); - TEST_SEARCH ("^(^a)", "ab", 0, 2); - TEST_SEARCH ("(a$)$", "ba", 0, 2); - test_match ("a|$b", "$b"); - - /* Mike's curiosity item. */ - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); - test_all_registers ("(foo|foobar)(foo|bar)*\\1(foo|bar)*", - "foobarfoobar", "", - 0, 12, 0, 3, 3, 6, 9, 12, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1); - - /* Another one from Mike. */ - test_match ("(foo|foobarfoo)(bar)*", "foobarfoo"); - - /* And another. */ - test_match("(foo|foobar)(bar|barfoo)?\\1", "foobarfoobar"); - - re_set_syntax (RE_NO_BK_PARENS | RE_INTERVALS | RE_NO_BK_VBAR - | RE_NO_BK_BRACES); /* xx get new ones from ext.*/ - test_match ("((a{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)*", "bb"); - test_all_registers ("((a{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)*", "", "bb", - 0, 2, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1); - - test_match ("((a+?*{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)", "b"); - test_all_registers ("((a+?*{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)", "", "b", - 0, 1, 0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1); - - /* Valid anchoring. */ - /* See generic_test.c and extended_test.c for more search - tests. xx Not sure all these tests are represented in the - search tests. */ - - re_set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR); - valid_nonposix_pattern - ("(((((((((((((((((((((((((((((((((^a)))))))))))))))))))))))))))))))))"); - valid_nonposix_pattern - ("(((((((((((((((((((((((((((((((((a$)))))))))))))))))))))))))))))))))"); - valid_nonposix_pattern ("\\b\\B\\<\\>\\`\\'^a"); - valid_nonposix_pattern ("a$\\b\\B\\<\\>\\`\\'"); - valid_nonposix_pattern ("(^a)"); - valid_nonposix_pattern ("(a$)"); - valid_nonposix_pattern ("(^a)b"); - valid_nonposix_pattern ("b(a$)"); - valid_nonposix_pattern ("(^a|^b)c"); - valid_nonposix_pattern ("c(a$|b$)"); - valid_nonposix_pattern ("(^a|^b)|^c"); - valid_nonposix_pattern ("(a$|b$)|c$"); - valid_nonposix_pattern ("^c|(^a|^b)"); - valid_nonposix_pattern ("c$|(a$|b$)"); - valid_nonposix_pattern ("(^a|^b)c|^d"); - valid_nonposix_pattern ("c(a$|b$)|d$"); - valid_nonposix_pattern ("(((^a|^b))c|^d)e"); - valid_nonposix_pattern ("(c((a|b))|d)e$"); - valid_nonposix_pattern ("^d(c|e((a|b)))"); - valid_nonposix_pattern ("d(c$|e((a$|b$)))"); - valid_nonposix_pattern ("(((^a|^b))c)|^de"); - valid_nonposix_pattern ("(((a|b))c$)|de$"); - - valid_nonposix_pattern ("((a$)$)$"); - valid_nonposix_pattern ("^(^(^a))"); - - valid_nonposix_pattern ("^de|^(c((a|b)))"); - valid_nonposix_pattern ("^de|(^c((a|b)))"); - valid_nonposix_pattern ("de$|(c((a|b)$))"); - valid_nonposix_pattern ("de$|(c((a|b))$)"); - valid_nonposix_pattern ("de$|(c((a|b)))$"); - - valid_nonposix_pattern ("^a(b|c)|^d"); - valid_nonposix_pattern ("a(b$|c$)|d$"); - valid_nonposix_pattern ("^d|^a(b|c)"); - valid_nonposix_pattern ("d$|a(b$|c$)"); - valid_nonposix_pattern ("^d|^(b|c)a"); - valid_nonposix_pattern ("d$|(b|c)a$"); - valid_nonposix_pattern ("^(a)(b|c)|^d"); - valid_nonposix_pattern ("(a)(b|c)$|d$"); - valid_nonposix_pattern ("(^a)(b|c)|^d"); - valid_nonposix_pattern ("(a)(b$|c$)|d$"); - valid_nonposix_pattern ("^d|^(b|c)(a)"); - valid_nonposix_pattern ("d$|(b|c)(a)$"); - valid_nonposix_pattern ("^d|(^b|^c)(a)"); - valid_nonposix_pattern ("d$|(b|c)(a$)"); - valid_nonposix_pattern ("^d|^(a)(b|c)"); - valid_nonposix_pattern ("^d|(^a)(b|c)"); - valid_nonposix_pattern ("d$|(a)(b$|c$)"); - valid_nonposix_pattern ("((^a|^b)|^c)|^d"); - valid_nonposix_pattern ("d$|(c$|(a$|b$))"); - - - /* Tests shouldn't match. */ - test_should_match = false; - - /* Test that RE_CONTEXT_INVALID_OPS has precedence over - RE_CONTEXT_INDEP_OPS. */ - - re_set_syntax (RE_CONTEXT_INDEP_OPS | RE_CONTEXT_INVALID_OPS - | RE_NO_BK_VBAR | RE_NO_BK_PARENS - | RE_NO_BK_BRACES | RE_INTERVALS); - INVALID_PATTERN ("*"); - INVALID_PATTERN ("^*"); - INVALID_PATTERN ("a|*"); - INVALID_PATTERN ("(*)"); - - INVALID_PATTERN ("^+"); - INVALID_PATTERN ("+"); - INVALID_PATTERN ("a|+"); - INVALID_PATTERN ("(+)"); - - INVALID_PATTERN ("^?"); - INVALID_PATTERN ("?"); - INVALID_PATTERN ("a|?"); - INVALID_PATTERN ("(?)"); - - INVALID_PATTERN ("^{1}"); - INVALID_PATTERN ("{1}"); - INVALID_PATTERN ("a|{1}"); - INVALID_PATTERN ("({1})"); - -#if 0 - /* No longer have this syntax option -- POSIX says empty alternatives - are undefined as of draft 11.2. */ - - /* You can't have empty alternatives if RE_NO_EMPTY_ALTS is set. */ - - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_ALTS); - - INVALID_PATTERN ("|"); - INVALID_PATTERN ("^|a"); - INVALID_PATTERN ("a|"); - INVALID_PATTERN ("a||"); - INVALID_PATTERN ("a||b"); - INVALID_PATTERN ("(|a)"); - INVALID_PATTERN ("(a|)"); - INVALID_PATTERN ("(a|)"); - - - /* Test above with `\(' and `\)'. */ - re_set_syntax (RE_NO_BK_VBAR | RE_NO_EMPTY_ALTS); - INVALID_PATTERN ("\\(|a\\)"); - INVALID_PATTERN ("\\(a|\\)"); - - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_ALTS); - INVALID_PATTERN ("(|)()$|d$"); -#endif - - /* Test grouping. */ - test_match ("()", "a"); - - /* Test backslashed intervals that are CONTEXTly invalid if have - nothing on which to operate. */ - - re_set_syntax (RE_INTERVALS | RE_CONTEXT_INVALID_OPS); - INVALID_PATTERN ("\\{1\\}"); - - re_set_syntax (0); - test_match ("z-a", "a"); - - re_set_syntax (RE_BK_PLUS_QM); - INVALID_PATTERN ("a*\\"); - - re_set_syntax (0); - INVALID_PATTERN ("a*\\"); - - re_set_syntax (RE_BACKSLASH_ESCAPE_IN_LISTS); - INVALID_PATTERN ("[\\"); - -#if 0 - /* Empty groups are always ok now. (13 Sep 92) */ - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_GROUPS); - INVALID_PATTERN ("(|)()$|d$"); -#endif - - printf ("\nFinished non-POSIX tests.\n"); -} - - - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/libregex/test/printchar.c b/gnu/lib/libregex/test/printchar.c deleted file mode 100644 index 4e21ea03e8d7..000000000000 --- a/gnu/lib/libregex/test/printchar.c +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef lint -static char rcsid[] = "$Id: printchar.c,v 1.2 1993/08/02 17:24:23 mycroft Exp $"; -#endif /* not lint */ - -void -printchar (c) - char c; -{ - if (c < 040 || c >= 0177) - { - putchar ('\\'); - putchar (((c >> 6) & 3) + '0'); - putchar (((c >> 3) & 7) + '0'); - putchar ((c & 7) + '0'); - } - else - putchar (c); -} diff --git a/gnu/lib/libregex/test/psx-basic.c b/gnu/lib/libregex/test/psx-basic.c deleted file mode 100644 index d79e2e24d967..000000000000 --- a/gnu/lib/libregex/test/psx-basic.c +++ /dev/null @@ -1,257 +0,0 @@ -/* psx-basic.c: Test POSIX basic regular expressions. */ - -#ifndef lint -static char rcsid[] = "$Id: psx-basic.c,v 1.2 1993/08/02 17:24:24 mycroft Exp $"; -#endif /* not lint */ - -#include "test.h" - - -void -test_posix_basic () -{ - /* Intervals can only match up to RE_DUP_MAX occurences of anything. */ - char dup_max_plus_one[6]; - sprintf (dup_max_plus_one, "%d", RE_DUP_MAX + 1); - - printf ("\nStarting POSIX basic tests.\n"); - t = posix_basic_test; - - re_set_syntax (RE_SYNTAX_POSIX_MINIMAL_BASIC); - - test_posix_generic (); - - printf ("\nContinuing POSIX basic tests.\n"); - -/* Grouping tests that are not the same. */ - - test_should_match = false; - invalid_pattern (REG_EPAREN, PARENS_TO_OPS ("a)")); - - test_should_match = true; - /* Special characters. */ - MATCH_SELF ("*"); - test_match ("\\(*\\)", "*"); - test_match ("\\(^*\\)", "*"); - test_match ("**", "***"); - test_match ("***", "****"); - - MATCH_SELF ("{"); /* of extended... */ - MATCH_SELF ("()"); /* also non-Posix. */ - MATCH_SELF ("a+"); - MATCH_SELF ("a?"); - MATCH_SELF ("a|b"); - MATCH_SELF ("a|"); /* No alternations, */ - MATCH_SELF ("|a"); /* so OK if empty. */ - MATCH_SELF ("a||"); - test_match ("\\(|a\\)", "|a"); - test_match ("\\(a|\\)", "a|"); - test_match ("a\\+", "a+"); - test_match ("a\\?", "a?"); - test_match ("a\\|b", "a|b"); - test_match ("^*", "*"); - test_match ("^+", "+"); - test_match ("^?", "?"); - test_match ("^{", "{"); - /* Valid subexpressions - (empty) in basic only. */ - test_match ("\\(\\)", ""); - - test_match ("a\\(\\)", "a"); - test_match ("\\(\\)b", "b"); - test_match ("a\\(\\)b", "ab"); - TEST_REGISTERS ("a\\(\\)b", "ab", 0, 2, 1, 1, -1, -1); - - test_match ("\\(\\)*", ""); - test_match ("\\(\\(\\)\\)*", ""); - /* Valid back references. */ - - /* N.B.: back references to subexpressions that include a * are - undefined in the spec. The tests are in here to see if we handle - the situation consistently, but if it fails any of them, it doesn't - matter. */ - - test_match ("\\(\\)\\1", ""); - TEST_REGISTERS ("\\(\\)\\1", "", 0, 0, 0, 0, -1, -1); - - test_match ("\\(\\(\\)\\)\\(\\)\\2", ""); - - test_match ("\\(a\\)\\1", "aa"); - TEST_REGISTERS ("\\(a\\)\\1", "aa", 0, 2, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a\\)\\1", "xaax", 1, 3, 1, 2, -1, -1); - - test_match ("\\(\\(a\\)\\)\\1", "aa"); - test_match ("\\(a\\)\\(b\\)\\2\\1", "abba"); - - test_match ("\\(a\\)*\\1", "aa"); - TEST_REGISTERS ("\\(a\\)*\\1", "aa", 0, 2, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a\\)*\\1", "xaax", 0, 0, -1, -1, -1, -1); - - test_match ("\\(\\(a\\)\\2b\\)*", "aab"); - TEST_REGISTERS ("\\(\\(a\\)\\2b\\)*", "aab", 0, 3, 0, 3, 0, 1); - TEST_REGISTERS ("\\(\\(a\\)\\2b\\)*", "xaabx", 0, 0, -1, -1, -1, -1); - - test_match ("\\(a*\\)*\\1", ""); - test_match ("\\(a*\\)*\\1", "aa"); - TEST_REGISTERS ("\\(a*\\)*\\1", "aa", 0, 2, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a*\\)*\\1", "xaax", 0, 0, 0, 0, -1, -1); - - test_match ("\\(a*\\)*\\1", ""); - test_match ("\\(a*\\)*\\1", "aa"); - test_match ("\\(\\(a*\\)*\\)*\\1", "aa"); - test_match ("\\(ab*\\)*\\1", "abab"); - TEST_REGISTERS ("\\(ab*\\)*\\1", "abab", 0, 4, 0, 2, -1, -1); - TEST_REGISTERS ("\\(ab*\\)*\\1", "xababx", 0, 0, -1, -1, -1, -1); - - test_match ("\\(a*\\)ab\\1", "aaba"); - TEST_REGISTERS ("\\(a*\\)ab\\1", "aaba", 0, 4, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a*\\)ab\\1", "xaabax", 1, 5, 1, 2, -1, -1); - - test_match ("\\(a*\\)*ab\\1", "aaba"); - TEST_REGISTERS ("\\(a*\\)*ab\\1", "aaba", 0, 4, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a*\\)*ab\\1", "xaabax", 1, 5, 1, 2, -1, -1); - - test_match ("\\(\\(a*\\)b\\)*\\2", "abb"); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "abb", 0, 3, 2, 3, 2, 2); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "xabbx", 0, 0, -1, -1, -1, -1); - - /* Different from above. */ - test_match ("\\(\\(a*\\)b*\\)*\\2", "aa"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aa", 0, 2, 0, 1, 0, 1); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaax", 0, 0, 0, 0, 0, 0); - - test_match ("\\(\\(a*\\)b*\\)*\\2", "aba"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aba", 0, 3, 0, 2, 0, 1); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xabax", 0, 0, 0, 0, 0, 0); - - test_match ("\\(\\(a*\\)b\\)*\\2", "aababa"); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "aababa", 0, 6, 3, 5, 3, 4); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "xaababax", 0, 0, -1, -1, -1, -1); - - test_match ("\\(\\(a*\\)b*\\)*\\2", "aabaa"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aabaa", 0, 5, 0, 3, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaabaax", 0, 0, 0, 0, 0, 0); - - test_match ("\\(\\(a*\\)b*\\)*\\2", "aabbaa"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aabbaa", 0, 6, 0, 4, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaabbaax", 0, 0, 0, 0, 0, 0); - - test_match ("\\(\\(a*\\)b*\\)*\\2", "abaabaa"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "abaabaa", 0, 7, 2, 5, 2, 4); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaababaax", 0, 0, 0, 0, 0, 0); - - test_match ("\\(\\(a*\\)b*\\)*a\\2", "aabaaa"); - TEST_REGISTERS ("\\(\\(a*\\)b*a\\)*\\2", "aabaaa", 0, 6, 0, 3, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*a\\)*\\2", "xaabaax", 0, 0, -1, -1, -1, -1); - - test_match ("\\(\\(a*\\)b*\\)*\\2a", "aabaaa"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2a", "aabaaa", 0, 6, 0, 3, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2a", "xaabaaax", 1, 7, 1, 4, 1, 3); - - test_match ("\\(\\(a*\\)b\\)*\\2\\1", "abaabaaaab"); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2\\1", "abaabaaaab", 0, 10, 2, 5, 2, 4); - /* We are matching the empty string here. */ - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2\\1", "xabaabaaaabx", 0, 0, -1, -1, -1, -1); - - test_match ("\\(a*b\\)\\1", "abab"); - test_match ("\\(a\\)\\1\\1", "aaa"); - test_match ("\\(a\\(c\\)d\\)\\1\\2", "acdacdc"); - - test_match ("\\(a\\)\\1*", "aaa"); - TEST_REGISTERS ("\\(a\\)\\1*", "aaa", 0, 3, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a\\)\\1*", "xaaax", 1, 4, 1, 2, -1, -1); - - test_match ("\\(a\\)\\{1,3\\}b\\1", "aba"); - TEST_REGISTERS ("\\(a\\)\\{1,3\\}b\\1", "aba", 0, 3, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a\\)\\{1,3\\}b\\1", "xabax", 1, 4, 1, 2, -1, -1); - - test_match ("\\(\\(a\\)\\2\\)*", "aaaa"); /* rms? */ - TEST_REGISTERS ("\\(\\(a*b\\)\\2\\)*", "bbabab", 0, 6, 2, 6, 2, 4); /* rms? */ - - test_match ("\\(\\(a\\)\\1\\)*", "a1a1"); - - test_match ("\\(\\(a\\)\\2\\)\\1", "aaaa"); - - test_match ("\\(\\(a*\\)\\2\\)\\1", "aaaa"); - TEST_REGISTERS ("\\(\\(a*\\)\\2\\)\\1", "aaaa", 0, 4, 0, 2, 0, 1); - TEST_REGISTERS ("\\(\\(a*\\)\\2\\)\\1", "xaaaax", 0, 0, 0, 0, 0, 0); - - test_match ("\\{1\\}", "{1}"); - test_match ("^\\{1\\}", "{1}"); - - test_match ("\\(a\\)\\1\\{1,2\\}", "aaa"); - TEST_REGISTERS ("\\(a\\)\\1\\{1,2\\}", "aaa", 0, 3, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a\\)\\1\\{1,2\\}", "xaaax", 1, 4, 1, 2, -1, -1); - - - /* Per POSIX D11.1 p. 109, leftmost longest match. */ - - test_match (PARENS_TO_OPS ("(.*).*\\1"), "abcabc"); - - - /* Per POSIX D11.1, p. 125, leftmost longest match. */ - - test_match (PARENS_TO_OPS ("(ac*)c*d[ac]*\\1"), "acdacaaa"); - TEST_REGISTERS (PARENS_TO_OPS ("(ac*)c*d[ac]*\\1"), "acdacaaa", - 0, 8, 0, 1, -1, -1); - - /* Anchors become ordinary, sometimes. */ - MATCH_SELF ("a^"); - MATCH_SELF ("$a"); - MATCH_SELF ("$^"); - test_fastmap ("$a^", "$", 0, 0); - test_match ("$^*", "$^^"); - test_match ("\\($^\\)", "$^"); - test_match ("$*", "$$"); - /* xx -- known bug, solution pending test_match ("^^$", "^"); */ - test_match ("$\\{0,\\}", "$$"); - TEST_SEARCH ("^$*", "$$", 0, 2); - TEST_SEARCH ("^$\\{0,\\}", "$$", 0, 2); - MATCH_SELF ("2^10"); - MATCH_SELF ("$HOME"); - MATCH_SELF ("$1.35"); - - - /* Basic regular expressions, continued; these don't match their strings. */ - test_should_match = false; - - invalid_pattern (REG_EESCAPE, "\\(a\\"); - /* Invalid back references. */ - test_match ("\\(a\\)\\1", "ab"); - test_match ("\\(a\\)\\1\\1", "aab"); - test_match ("\\(a\\)\\(b\\)\\2\\1", "abab"); - test_match ("\\(a\\(c\\)d\\)\\1\\2", "acdc"); - test_match ("\\(a*b\\)\\1", "abaab"); - test_match ("\\(a\\)\\1*", "aaaaaaaaaab"); - test_match ("\\(\\(a\\)\\1\\)*", "aaa"); - invalid_pattern (REG_ESUBREG, "\\1"); - invalid_pattern (REG_ESUBREG, "\\(a\\)\\2"); - test_match ("\\(\\(a\\)\\2\\)*", "abaa"); - test_match ("\\(\\(a\\)\\1\\)*", "a"); - test_match ("\\(\\(a\\)\\2\\)\\1", "abaa"); - test_match ("\\(\\(a*\\)\\2\\)\\1", "abaa"); - /* Invalid intervals. */ - invalid_pattern (REG_EBRACE, "a\\{"); - - invalid_pattern (REG_BADBR, "a\\{-1"); - invalid_pattern (REG_BADBR, concat ("a\\{", (char *)dup_max_plus_one)); - invalid_pattern (REG_BADBR, concat (concat ("a\\{", (char *)dup_max_plus_one), ",")); - invalid_pattern (REG_BADBR, "a\\{1,0"); - - invalid_pattern (REG_EBRACE, "a\\{1"); - invalid_pattern (REG_EBRACE, "a\\{0,"); - invalid_pattern (REG_EBRACE, "a\\{0,1"); - invalid_pattern (REG_EBRACE, "a\\{0,1}"); - - printf ("\nFinished POSIX basic tests.\n"); -} - - - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/libregex/test/psx-extend.c b/gnu/lib/libregex/test/psx-extend.c deleted file mode 100644 index 44112cb3df27..000000000000 --- a/gnu/lib/libregex/test/psx-extend.c +++ /dev/null @@ -1,1248 +0,0 @@ -/* psx-extend.c: Test POSIX extended regular expressions. */ - -#ifndef lint -static char rcsid[] = "$Id: psx-extend.c,v 1.2 1993/08/02 17:24:26 mycroft Exp $"; -#endif /* not lint */ - -#include "test.h" - - -void -test_posix_extended () -{ - /* Intervals can only match up to RE_DUP_MAX occurences of anything. */ - char dup_max_plus_one[6]; - sprintf (dup_max_plus_one, "%d", RE_DUP_MAX + 1); - - - printf ("\nStarting POSIX extended tests.\n"); - t = posix_extended_test; - - re_set_syntax (RE_SYNTAX_POSIX_MINIMAL_EXTENDED); - - test_posix_generic (); - - printf ("\nContinuing POSIX extended tests.\n"); - - /* Grouping tests that differ from basic's. */ - - test_should_match = true; - MATCH_SELF ("a)"); - - /* Valid use of special characters. */ - test_match ("\\(a", "(a"); - test_match ("a\\+", "a+"); - test_match ("a\\?", "a?"); - test_match ("\\{a", "{a"); - test_match ("\\|a", "|a"); - test_match ("a\\|b", "a|b"); - test_match ("a\\|?", "a"); - test_match ("a\\|?", "a|"); - test_match ("a\\|*", "a"); - test_match ("a\\|*", "a||"); - test_match ("\\(*\\)", ")"); - test_match ("\\(*\\)", "(()"); - test_match ("a\\|+", "a|"); - test_match ("a\\|+", "a||"); - test_match ("\\(+\\)", "()"); - test_match ("\\(+\\)", "(()"); - test_match ("a\\||b", "a|"); - test_match ("\\(?\\)", ")"); - test_match ("\\(?\\)", "()"); - - test_match ("a+", "a"); - test_match ("a+", "aa"); - test_match ("a?", ""); - test_match ("a?", "a"); - - /* Bracket expressions. */ - test_match ("[(]", "("); - test_match ("[+]", "+"); - test_match ("[?]", "?"); - test_match ("[{]", "{"); - test_match ("[|]", "|"); - /* Subexpressions. */ - test_match ("(a+)*", ""); - test_match ("(a+)*", "aa"); - test_match ("(a?)*", ""); - test_match ("(a?)*", "aa"); - /* (No) back references. */ - test_match ("(a)\\1", "a1"); - /* Invalid as intervals, - but are valid patterns. */ - MATCH_SELF ("{"); - test_match ("^{", "{"); - test_match ("a|{", "{"); - test_match ("({)", "{"); - MATCH_SELF ("a{"); - MATCH_SELF ("a{}"); - MATCH_SELF ("a{-1"); - MATCH_SELF ("a{-1}"); - MATCH_SELF ("a{0"); - MATCH_SELF ("a{0,"); - MATCH_SELF (concat ("a{", dup_max_plus_one)); - MATCH_SELF (concat (concat ("a{", dup_max_plus_one), ",")); - MATCH_SELF ("a{1,0"); - MATCH_SELF ("a{1,0}"); - MATCH_SELF ("a{0,1"); - test_match ("[a{0,1}]", "}"); - test_match ("a{1,3}{-1}", "aaa{-1}"); - test_match (concat ("a{1,3}{", dup_max_plus_one), - concat ("aaa{", dup_max_plus_one)); - test_match ("a{1,3}{2,1}", "aaa{2,1}"); - test_match ("a{1,3}{1,2", "aaa{1,2"); - /* Valid consecutive repetitions. */ - test_match ("a*+", "a"); - test_match ("a*?", "a"); - test_match ("a++", "a"); - test_match ("a+*", "a"); - test_match ("a+?", "a"); - test_match ("a??", "a"); - test_match ("a?*", "a"); - test_match ("a?+", "a"); - - test_match ("a{2}?", ""); - test_match ("a{2}?", "aa"); - test_match ("a{2}+", "aa"); - test_match ("a{2}{2}", "aaaa"); - - test_match ("a{1}?*", ""); - test_match ("a{1}?*", "aa"); - - test_match ("(a?){0,3}b", "aaab"); - test_fastmap ("(a?){0,3}b", "ab", 0, 0); - test_match ("(a+){0,3}b", "b"); - test_fastmap ("(a+){0,3}b", "ab", 0, 0); - test_match ("(a+){0,3}b", "ab"); - test_fastmap ("(a+){0,3}b", "ab", 0, 0); - test_match ("(a+){1,3}b", "aaab"); - test_match ("(a?){1,3}b", "aaab"); - - test_match ("\\\\{1}", "\\"); /* Extended only. */ - - test_match ("(a?)?", "a"); - test_match ("(a?b)?c", "abc"); - test_match ("(a+)*b", "b"); - /* Alternatives. */ - test_match ("a|b", "a"); - test_match ("a|b", "b"); - test_fastmap ("a|b", "ab", 0, 0); - - TEST_SEARCH ("a|b", "cb", 0, 2); - TEST_SEARCH ("a|b", "cb", 0, 2); - - test_match ("(a|b|c)", "a"); - test_match ("(a|b|c)", "b"); - test_match ("(a|b|c)", "c"); - - test_match ("(a|b|c)*", "abccba"); - - test_match ("(a(b*))|c", "a"); /* xx do registers. */ - test_match ("(a(b*))|c", "ab"); - test_match ("(a(b*))|c", "c"); - - test_fastmap ("(a+?*|b)", "ab", 0, 0); - test_match ("(a+?*|b)", "b"); - TEST_REGISTERS ("(a+?*|b)", "b", 0, 1, 0, 1, -1, -1); - - test_fastmap ("(a+?*|b)*", "ab", 0, 0); - test_match ("(a+?*|b)*", "bb"); - TEST_REGISTERS ("(a+?*|b)*", "bb", 0, 2, 1, 2, -1, -1); - - test_fastmap ("(a*|b)*", "ab", 0, 0); - test_match ("(a*|b)*", "bb"); - TEST_REGISTERS ("(a*|b)*", "bb", 0, 2, 1, 2, -1, -1); - - test_fastmap ("((a*)|b)*", "ab", 0, 0); - test_match ("((a*)|b)*", "bb"); - TEST_REGISTERS ("((a*)|b)*", "bb", 0, 2, 1, 2, 1, 1); - - test_fastmap ("(a{0,}|b)*", "ab", 0, 0); - test_match ("(a{0,}|b)*", "bb"); - TEST_REGISTERS ("(a{0,}|b)*", "bb", 0, 2, 1, 2, -1, -1); - - test_fastmap ("((a{0,})|b)*", "ab", 0, 0); - test_match ("((a{0,})|b)*", "bb"); - TEST_REGISTERS ("((a{0,})|b)*", "bb", 0, 2, 1, 2, 1, 1); - - /* With c's */ - test_fastmap ("(a+?*|b)c", "abc", 0, 0); - test_match ("(a+?*|b)c", "bc"); - TEST_REGISTERS ("(a+?*|b)c", "bc", 0, 2, 0, 1, -1, -1); - - test_fastmap ("(a+?*|b)*c", "abc", 0, 0); - test_match ("(a+?*|b)*c", "bbc"); - TEST_REGISTERS ("(a+?*|b)*c", "bbc", 0, 3, 1, 2, -1, -1); - - test_fastmap ("(a*|b)*c", "abc", 0, 0); - test_match ("(a*|b)*c", "bbc"); - TEST_REGISTERS ("(a*|b)*c", "bbc", 0, 3, 1, 2, -1, -1); - - test_fastmap ("((a*)|b)*c", "abc", 0, 0); - test_match ("((a*)|b)*c", "bbc"); - TEST_REGISTERS ("((a*)|b)*c", "bbc", 0, 3, 1, 2, 1, 1); - - test_fastmap ("(a{0,}|b)*c", "abc", 0, 0); - test_match ("(a{0,}|b)*c", "bbc"); - TEST_REGISTERS ("(a{0,}|b)*c", "bbc", 0, 3, 1, 2, -1, -1); - - test_fastmap ("((a{0,})|b)*c", "abc", 0, 0); - test_match ("((a{0,})|b)*c", "bbc"); - TEST_REGISTERS ("((a{0,})|b)*c", "bbc", 0, 3, 1, 2, 1, 1); - - - test_fastmap ("((a{0,}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a{0,}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a{0,}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a{0,}\\b\\<)|b)*", "ab", 0, 0); - test_match ("((a{0,}\\b\\<)|b)*", "b"); - TEST_REGISTERS ("((a{0,}\\b\\<)|b)*", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,1}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,1}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,1}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,2}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,2}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,2}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - - test_fastmap ("((a+?*{0,4095}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,4095}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,4095}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,5119}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,5119}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,5119}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,6143}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,6143}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,6143}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,8191}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,8191}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,8191}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,16383}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,16383}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,16383}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - - test_fastmap ("((a+?*{0,}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,}\\b\\<)|b)*", "ab", 0, 0); - test_match ("((a+?*{0,}\\b\\<)|b)*", "b"); - TEST_REGISTERS ("((a+?*{0,}\\b\\<)|b)*", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,}\\b\\<)|b)*", "ab", 0, 0); - test_match ("((a+?*{0,}\\b\\<)|b)*", "bb"); - TEST_REGISTERS ("((a+?*{0,}\\b\\<)|b)*", "bb", - 0, 2, 1, 2, 0, 0); - - - /* `*' after group. */ - test_match ("(a*|b*)*c", "c"); - TEST_REGISTERS ("(a*|b*)*c", "c", 0, 1, 0, 0, -1, -1); - - test_match ("(a*|b*)*c", "ac"); - TEST_REGISTERS ("(a*|b*)*c", "ac", 0, 2, 0, 1, -1, -1); - - test_match ("(a*|b*)*c", "aac"); - TEST_REGISTERS ("(a*|b*)*c", "aac", 0, 3, 0, 2, -1, -1); - - test_match ("(a*|b*)*c", "bbc"); - TEST_REGISTERS ("(a*|b*)*c", "bbc", 0, 3, 0, 2, -1, -1); - - test_match ("(a*|b*)*c", "abc"); - TEST_REGISTERS ("(a*|b*)*c", "abc", 0, 3, 1, 2, -1, -1); - - /* No `*' after group. */ - test_match ("(a*|b*)c", "c"); - TEST_REGISTERS ("(a*|b*)c", "c", 0, 1, 0, 0, -1, -1); - - test_match ("(a*|b*)c", "ac"); - TEST_REGISTERS ("(a*|b*)c", "ac", 0, 2, 0, 1, -1, -1); - - test_match ("(a*|b*)c", "bc"); - TEST_REGISTERS ("(a*|b*)c", "bc", 0, 2, 0, 1, -1, -1); - - test_match ("(a*|b*)c", "aac"); - TEST_REGISTERS ("(a*|b*)c", "aac", 0, 3, 0, 2, -1, -1); - - /* Same as above, but with no `*'s in alternatives. - - test_match ("(a|b)*c", "c"); /* `*' after group. */ - TEST_REGISTERS ("(a|b)*c", "c", 0, 1, -1, -1, -1, -1); - - test_match ("(a|b)*c", "ac"); - TEST_REGISTERS ("(a|b)*c", "ac", 0, 2, 0, 1, -1, -1); - - test_match ("(a|b)*c", "bc"); - TEST_REGISTERS ("(a|b)*c", "bc", 0, 2, 0, 1, -1, -1); - - test_match ("(a|b)*c", "abc"); - TEST_REGISTERS ("(a|b)*c", "abc", 0, 3, 1, 2, -1, -1); - - - test_match ("(a*|b*)c", "bbc"); - TEST_REGISTERS ("(a*|b*)c", "bbc", 0, 3, 0, 2, -1, -1); - - /* Complicated second alternative. */ - - test_match ("(a*|(b*)*)*c", "bc"); - TEST_REGISTERS ("(a*|(b*)*)*c", "bc", 0, 2, 0, 1, 0, 1); - - test_match ("(a*|(b*|c*)*)*d", "bd"); - TEST_REGISTERS ("(a*|(b*|c*)*)*d", "bd", 0, 2, 0, 1, 0, 1); - - test_match ("(a*|(b*|c*)*)*d", "bbd"); - TEST_REGISTERS ("(a*|(b*|c*)*)*d", "bbd", 0, 3, 0, 2, 0, 2); - - test_match ("(a*|(b*|c*)*)*d", "cd"); - TEST_REGISTERS ("(a*|(b*|c*)*)*d", "cd", 0, 2, 0, 1, 0, 1); - - test_match ("(a*|(b*|c*)*)*d", "ccd"); - TEST_REGISTERS ("(a*|(b*|c*)*)*d", "ccd", 0, 3, 0, 2, 0, 2); - - test_match ("(a*|b*|c*)*d", "aad"); - TEST_REGISTERS ("(a*|b*|c*)*d", "aad", 0, 3, 0, 2, 0, 2); - - test_match ("(a*|b*|c*)*d", "bbd"); - TEST_REGISTERS ("(a*|b*|c*)*d", "bbd", 0, 3, 0, 2, 0, 2); - - test_match ("(a*|b*|c*)*d", "ccd"); - TEST_REGISTERS ("(a*|b*|c*)*d", "ccd", 0, 3, 0, 2, 0, 2); - - /* Valid anchoring. */ - valid_pattern ("a^"); - valid_pattern ("a^b"); - valid_pattern ("$a"); - valid_pattern ("a$b"); - valid_pattern ("foo^bar"); - valid_pattern ("foo$bar"); - valid_pattern ("(^)"); - valid_pattern ("($)"); - valid_pattern ("(^$)"); - - /* These are the same (but valid) as those (invalid) in other_test.c. */ - valid_pattern - ("(((((((((((((((((((((((((((((((((a^)))))))))))))))))))))))))))))))))"); - valid_pattern - ("((((((((((((((((((((((((((((((((($a)))))))))))))))))))))))))))))))))"); - valid_pattern ("\\(^a\\)"); - valid_pattern ("a\\|^b"); - valid_pattern ("\\w^a"); - valid_pattern ("\\W^a"); - valid_pattern ("(a^)"); - valid_pattern ("($a)"); - valid_pattern ("a(^b)"); - valid_pattern ("a$(b)"); - valid_pattern ("(a)^b"); - valid_pattern ("(a)$b"); - valid_pattern ("(a)(^b)"); - valid_pattern ("(a$)(b)"); - valid_pattern ("(a|b)^c"); - valid_pattern ("(a|b)$c"); - valid_pattern ("(a$|b)c"); - valid_pattern ("(a|b$)c"); - valid_pattern ("a(b|^c)"); - valid_pattern ("a(^b|c)"); - valid_pattern ("a$(b|c)"); - valid_pattern ("(a)(^b|c)"); - valid_pattern ("(a)(b|^c)"); - valid_pattern ("(b$|c)(a)"); - valid_pattern ("(b|c$)(a)"); - valid_pattern ("(a(^b|c))"); - valid_pattern ("(a(b|^c))"); - valid_pattern ("((b$|c)a)"); - valid_pattern ("((b|c$)a)"); - valid_pattern ("((^a|^b)^c)"); - valid_pattern ("(c$(a$|b$))"); - valid_pattern ("((^a|^b)^c)"); - valid_pattern ("((a$|b$)c)"); - valid_pattern ("(c$(a$|b$))"); - valid_pattern ("((^a|^b)|^c)^d"); - valid_pattern ("((a$|b$)|c$)d$"); - valid_pattern ("d$(c$|(a$|b$))"); - valid_pattern ("((^a|^b)|^c)(^d)"); - valid_pattern ("((a$|b$)|c$)(d$)"); - valid_pattern ("(d$)((a$|b$)|c$)"); - valid_pattern ("((^a|^b)|^c)((^d))"); - valid_pattern ("((a$|b$)|c$)((d$))"); - valid_pattern ("((d$))((a$|b$)|c$)"); - valid_pattern ("(((^a|^b))c|^d)^e"); - valid_pattern ("(((a$|b$))c|d$)$e$"); - valid_pattern ("e$(d$|c((a$|b$)))"); - valid_pattern ("(^a)((^b))"); - valid_pattern ("(a$)((b$))"); - valid_pattern ("((^a))(^b)"); - valid_pattern ("((a$))(b$)"); - valid_pattern ("((^a))((^b))"); - valid_pattern ("((a$))((b$))"); - valid_pattern ("((^a)^b)"); - valid_pattern ("((a$)b$)"); - valid_pattern ("(b$(a$))"); - valid_pattern ("(((^a)b)^c)"); - valid_pattern ("(((a$)b)c$)"); - valid_pattern ("(c$(b(a$)))"); - valid_pattern ("(((^a)b)c)^d"); - valid_pattern ("(((a$)b)c)d$"); - valid_pattern ("d$(c(b(a$)))"); - valid_pattern (".^a"); - valid_pattern ("a$."); - valid_pattern ("[a]^b"); - valid_pattern ("b$[a]"); - valid_pattern ("\\(a$\\)"); - valid_pattern ("a$\\|b"); - valid_pattern ("(^a|^b)^c"); - valid_pattern ("c$(a$|b$)"); - valid_pattern ("(^a|^b)^|^c"); - valid_pattern ("(a$|b$)$|$c$"); - valid_pattern ("(a$|$b$)$|c$"); - valid_pattern ("($a$|b$)$|c$"); - valid_pattern ("$(a$|b$)$|c$"); - valid_pattern ("^c|d(^a|^b)"); - valid_pattern ("(^a|^b)|d^c"); - valid_pattern ("c$|(a$|b$)d"); - valid_pattern ("c$d|(a$|b$)"); - valid_pattern ("c(^a|^b)|^d"); - valid_pattern ("(a$|b$)c|d$"); - valid_pattern ("c(((^a|^b))|^d)e"); - valid_pattern ("(c((^a|^b))|^d)e"); - valid_pattern ("((c(^a|^b))|^d)e"); - valid_pattern ("(((^a|^b))|c^d)e"); - valid_pattern ("(((^a|^b))|^d)^e"); - valid_pattern ("(c$((a|b))|d)e$"); - valid_pattern ("(c((a$|b$))|d)e$"); - valid_pattern ("(c((a|b)$)|d)e$"); - valid_pattern ("(c((a|b))|d$)e$"); - valid_pattern ("^d(^c|e((a|b)))"); - valid_pattern ("^d(c|^e((a|b)))"); - valid_pattern ("^d(c|e(^(a|b)))"); - valid_pattern ("^d(c|e((^a|b)))"); - valid_pattern ("^d(c|e((a|^b)))"); - valid_pattern ("^d(c|e((a|b^)))"); - valid_pattern ("^d(c|e((a|b)^))"); - valid_pattern ("^d(c|e((a|b))^)"); - valid_pattern ("^d(c|e((a|b)))^"); - valid_pattern ("d$(c$|e((a$|b$)))"); - valid_pattern ("d(c$|e$((a$|b$)))"); - valid_pattern ("(((^a|^b))^c)|^de"); - valid_pattern ("(((^a|^b))c)|^d^e"); - valid_pattern ("(((a$|b))c$)|de$"); - valid_pattern ("(((a|b$))c$)|de$"); - valid_pattern ("(((a|b))c$)|d$e$"); - valid_pattern ("^d^e|^(c((a|b)))"); - valid_pattern ("^de|^(c^((a|b)))"); - valid_pattern ("^de|^(c(^(a|b)))"); - valid_pattern ("^de|^(c((^a|b)))"); - valid_pattern ("^de|^(c((a|^b)))"); - valid_pattern ("^de|(^c(^(a|b)))"); - valid_pattern ("^de|(^c((^a|b)))"); - valid_pattern ("^de|(^c((a|^b)))"); - valid_pattern ("de$|(c($(a|b)$))"); - valid_pattern ("de$|(c$((a|b)$))"); - valid_pattern ("de$|($c((a|b)$))"); - valid_pattern ("de$|$(c((a|b)$))"); - valid_pattern ("de$|(c($(a|b))$)"); - valid_pattern ("de$|(c$((a|b))$)"); - valid_pattern ("de$|$(c((a|b))$)"); - valid_pattern ("de$|(c($(a|b)))$"); - valid_pattern ("de$|(c$((a|b)))$"); - valid_pattern ("de$|($c((a|b)))$"); - valid_pattern ("de$|$(c((a|b)))$"); - valid_pattern ("^a(^b|c)|^d"); - valid_pattern ("^a(b|^c)|^d"); - valid_pattern ("^a(b|c^)|^d"); - valid_pattern ("^a(b|c)^|^d"); - valid_pattern ("a$(b$|c$)|d$"); - valid_pattern ("^d|^a(^b|c)"); - valid_pattern ("^d|^a(b|^c)"); - valid_pattern ("d$|a$(b$|c$)"); - valid_pattern ("^d|^(b|c)^a"); - valid_pattern ("d$|(b|c$)a$"); - valid_pattern ("d$|(b$|c)a$"); - valid_pattern ("^(a)^(b|c)|^d"); - valid_pattern ("^(a)(^b|c)|^d"); - valid_pattern ("^(a)(b|^c)|^d"); - valid_pattern ("(a)$(b|c)$|d$"); - valid_pattern ("(a$)(b|c)$|d$"); - valid_pattern ("(^a)(^b|c)|^d"); - valid_pattern ("(^a)(b|^c)|^d"); - valid_pattern ("(a)$(b$|c$)|d$"); - valid_pattern ("(a$)(b$|c$)|d$"); - valid_pattern ("^d|^(b|c)^(a)"); - valid_pattern ("^d|^(b|c)(^a)"); - valid_pattern ("d$|(b|c$)(a)$"); - valid_pattern ("d$|(b$|c)(a)$"); - valid_pattern ("^d|(^b|^c)^(a)"); - valid_pattern ("^d|(^b|^c)(^a)"); - valid_pattern ("d$|(b|c)$(a$)"); - valid_pattern ("d$|(b|c$)(a$)"); - valid_pattern ("d$|(b$|c)(a$)"); - valid_pattern ("^d|^(a)^(b|c)"); - valid_pattern ("^d|^(a)(^b|c)"); - valid_pattern ("^d|^(a)(b|^c)"); - valid_pattern ("^d|(^a)^(b|c)"); - valid_pattern ("^d|(^a)(^b|c)"); - valid_pattern ("^d|(^a)(b|^c)"); - valid_pattern ("d$|(a)$(b$|c$)"); - valid_pattern ("d$|(a$)(b$|c$)"); - valid_pattern ("((e^a|^b)|^c)|^d"); - valid_pattern ("((^a|e^b)|^c)|^d"); - valid_pattern ("((^a|^b)|e^c)|^d"); - valid_pattern ("((^a|^b)|^c)|e^d"); - valid_pattern ("d$e|(c$|(a$|b$))"); - valid_pattern ("d$|(c$e|(a$|b$))"); - valid_pattern ("d$|(c$|(a$e|b$))"); - valid_pattern ("d$|(c$|(a$|b$e))"); - valid_pattern ("d$|(c$|(a$|b$)e)"); - valid_pattern ("d$|(c$|(a$|b$))e"); - valid_pattern ("(a|b)^|c"); - valid_pattern ("(a|b)|c^"); - valid_pattern ("$(a|b)|c"); - valid_pattern ("(a|b)|$c"); - valid_pattern ("(a^|^b)|^c"); - valid_pattern ("(^a|b^)|^c"); - valid_pattern ("(^a|^b)|c^"); - valid_pattern ("($a|b$)|c$"); - valid_pattern ("(a$|$b)|c$"); - valid_pattern ("(a$|b$)|$c"); - valid_pattern ("c^|(^a|^b)"); - valid_pattern ("^c|(a^|^b)"); - valid_pattern ("^c|(^a|b^)"); - valid_pattern ("$c|(a$|b$)"); - valid_pattern ("c$|($a|b$)"); - valid_pattern ("c$|(a$|$b)"); - valid_pattern ("c^|^(a|b)"); - valid_pattern ("^c|(a|b)^"); - valid_pattern ("$c|(a|b)$"); - valid_pattern ("c$|$(a|b)"); - valid_pattern ("(a^|^b)c|^d"); - valid_pattern ("(^a|b^)c|^d"); - valid_pattern ("(^a|^b)c|d^"); - valid_pattern ("(^a|^b)^c|^d"); - valid_pattern ("(a|b)c$|$d"); - valid_pattern ("(a|b)$c$|d$"); - valid_pattern ("(a|b)$c$|d$"); - valid_pattern ("(a|b$)c$|d$"); - valid_pattern ("(a$|b)c$|d$"); - valid_pattern ("($a|b)c$|d$"); - valid_pattern ("$(a|b)c$|d$"); - valid_pattern ("^d|^c^(a|b)"); - valid_pattern ("^d|^c(^a|b)"); - valid_pattern ("^d|^c(a|^b)"); - valid_pattern ("^d|^c(a|b^)"); - valid_pattern ("^d|^c(a|b)^"); - valid_pattern ("$d|c(a$|b$)"); - valid_pattern ("d$|c($a$|b$)"); - valid_pattern ("d$|c$(a$|b$)"); - valid_pattern ("d$|$c(a$|b$)"); - - valid_pattern ("(((a^|^b))c|^d)e"); - valid_pattern ("(((^a|b^))c|^d)e"); - valid_pattern ("(((^a|^b))^c|^d)e"); - valid_pattern ("((^(a|b))c|d^)e"); - valid_pattern ("(^((a|b))c|^d)^e"); - valid_pattern ("(^((a|b)^)c|^d)e"); - valid_pattern ("(^((a^|b))c|^d)e"); - valid_pattern ("(^((a|b^))c|^d)e"); - valid_pattern ("(^((a|b)^)c|^d)e"); - valid_pattern ("(^((a|b))^c|^d)e"); - valid_pattern ("(^((a|b))c^|^d)e"); - valid_pattern ("(^((a|b))c|^d^)e"); - valid_pattern ("(^((a|b))c|^d)^e"); - valid_pattern ("(((a|b))c|d)$e$"); - valid_pattern ("(((a|b))c|d$)e$"); - valid_pattern ("(((a|b))c|$d)e$"); - valid_pattern ("(((a|b))c$|d)e$"); - valid_pattern ("(((a|b))$c|d)e$"); - valid_pattern ("(((a|b)$)c|d)e$"); - valid_pattern ("(((a|b$))c|d)e$"); - valid_pattern ("(((a$|b))c|d)e$"); - valid_pattern ("((($a|b))c|d)e$"); - valid_pattern ("(($(a|b))c|d)e$"); - valid_pattern ("($((a|b))c|d)e$"); - valid_pattern ("$(((a|b))c|d)e$"); - valid_pattern ("(^((a|b)^)c|^d)e"); - valid_pattern ("(^((a|b))^c|^d)e"); - valid_pattern ("(^((a|b))c|^d^)e"); - valid_pattern ("(^((a|b))c|^d)^e"); - - valid_pattern ("^e(^d|c((a|b)))"); - valid_pattern ("^e(d|^c((a|b)))"); - valid_pattern ("^e(d|c^((a|b)))"); - valid_pattern ("^e(d|c(^(a|b)))"); - valid_pattern ("^e(d|c((^a|b)))"); - valid_pattern ("^e(d|c((a|^b)))"); - valid_pattern ("^e(d|c((a|b^)))"); - valid_pattern ("^e(d|c((a|b)^))"); - valid_pattern ("^e(d|c((a|b))^)"); - valid_pattern ("^e(d|c((a|b)))^"); - valid_pattern ("e$(d$|c((a$|b$)))"); - valid_pattern ("e(d$|c$((a$|b$)))"); - valid_pattern ("e(d$|c($(a$|b$)))"); - valid_pattern ("e(d$|c(($a$|b$)))"); - valid_pattern ("e$(d$|c((a|b)$))"); - valid_pattern ("e($d$|c((a|b)$))"); - valid_pattern ("e(d$|$c((a|b)$))"); - valid_pattern ("e(d$|c$((a|b)$))"); - valid_pattern ("e(d$|c($(a|b)$))"); - valid_pattern ("e(d$|c(($a|b)$))"); - valid_pattern ("e(d$|c((a|$b)$))"); - valid_pattern ("e(d$|c((a$|$b$)))"); - - valid_pattern ("e$(d$|c((a|b))$)"); - valid_pattern ("e($d$|c((a|b))$)"); - valid_pattern ("e(d$|$c((a|b))$)"); - valid_pattern ("e(d$|c$((a|b))$)"); - valid_pattern ("e(d$|c($(a|b))$)"); - valid_pattern ("e(d$|c(($a|b))$)"); - valid_pattern ("e(d$|c((a|$b))$)"); - valid_pattern ("e$(d$|c((a|b)))$"); - valid_pattern ("e($d$|c((a|b)))$"); - valid_pattern ("e(d$|$c((a|b)))$"); - valid_pattern ("e(d$|c$((a|b)))$"); - valid_pattern ("e(d$|c($(a|b)))$"); - valid_pattern ("e(d$|c(($a|b)))$"); - valid_pattern ("e(d$|c((a|$b)))$"); - valid_pattern ("(((^a|^b)^)c)|^de"); - valid_pattern ("(((^a|^b))^c)|^de"); - valid_pattern ("(((^a|^b))c)^|^de"); - valid_pattern ("$(((a|b))c$)|de$"); - valid_pattern ("($((a|b))c$)|de$"); - valid_pattern ("(($(a|b))c$)|de$"); - valid_pattern ("((($a|b))c$)|de$"); - valid_pattern ("(((a|$b))c$)|de$"); - valid_pattern ("(((a|b)$)c$)|de$"); - valid_pattern ("(((a|b))$c$)|de$"); - valid_pattern ("$(((a|b))c)$|de$"); - valid_pattern ("($((a|b))c)$|de$"); - valid_pattern ("(($(a|b))c)$|de$"); - valid_pattern ("((($a|b))c)$|de$"); - valid_pattern ("(((a|$b))c)$|de$"); - valid_pattern ("(((a|b)$)c)$|de$"); - valid_pattern ("(((a|b))$c)$|de$"); - valid_pattern ("^ed|^(c((a|b)))^"); - valid_pattern ("^ed|^(c((a|b))^)"); - valid_pattern ("^ed|^(c((a|b)^))"); - valid_pattern ("^ed|^(c((a|b^)))"); - valid_pattern ("^ed|^(c((a^|b)))"); - valid_pattern ("^ed|^(c((^a|b)))"); - valid_pattern ("^ed|^(c(^(a|b)))"); - valid_pattern ("^ed|^(c^((a|b)))"); - valid_pattern ("^ed|(^c((a|b)))^"); - valid_pattern ("^ed|(^c((a|b))^)"); - valid_pattern ("^ed|(^c((a|b)^))"); - valid_pattern ("^ed|(^c((a|b^)))"); - valid_pattern ("^ed|(^c((a|^b)))"); - valid_pattern ("^ed|(^c((a^|b)))"); - valid_pattern ("^ed|(^c((^a|b)))"); - valid_pattern ("^ed|(^c(^(a|b)))"); - valid_pattern ("^ed|(^c(^(a|b)))"); - valid_pattern ("^ed|(^c^((a|b)))"); - valid_pattern ("ed$|$(c((a|b)))$"); - valid_pattern ("ed$|($c((a|b)))$"); - valid_pattern ("ed$|(c$((a|b)))$"); - valid_pattern ("ed$|(c($(a|b)))$"); - valid_pattern ("ed$|(c(($a|b)))$"); - valid_pattern ("ed$|(c((a|$b)))$"); - valid_pattern ("ed$|$(c((a|b))$)"); - valid_pattern ("ed$|($c((a|b))$)"); - valid_pattern ("ed$|(c$((a|b))$)"); - valid_pattern ("ed$|(c($(a|b))$)"); - valid_pattern ("ed$|(c(($a|b))$)"); - valid_pattern ("ed$|(c((a|$b))$)"); - valid_pattern ("ed$|$(c((a|b)$))"); - valid_pattern ("ed$|($c((a|b)$))"); - valid_pattern ("ed$|(c$((a|b)$))"); - valid_pattern ("ed$|(c($(a|b)$))"); - valid_pattern ("ed$|(c(($a|b)$))"); - valid_pattern ("ed$|(c((a|$b)$))"); - valid_pattern ("ed$|$(c((a|b)$))"); - valid_pattern ("ed$|($c((a|b)$))"); - valid_pattern ("ed$|(c$((a|b)$))"); - valid_pattern ("ed$|(c($(a|b)$))"); - valid_pattern ("ed$|(c(($a|b)$))"); - valid_pattern ("ed$|(c((a|$b)$))"); - valid_pattern ("ed$|$(c((a|b)$))"); - valid_pattern ("ed$|($c((a|b)$))"); - valid_pattern ("ed$|(c$((a|b)$))"); - valid_pattern ("ed$|(c($(a|b)$))"); - valid_pattern ("ed$|(c(($a|b)$))"); - valid_pattern ("ed$|(c((a|$b)$))"); - valid_pattern ("ed$|$(c((a|b)$))"); - valid_pattern ("ed$|($c((a|b)$))"); - valid_pattern ("ed$|(c$((a|b)$))"); - valid_pattern ("ed$|(c($(a|b)$))"); - valid_pattern ("ed$|(c(($a|b)$))"); - valid_pattern ("ed$|(c((a|$b)$))"); - valid_pattern ("ed$|$(c((a|b)$))"); - valid_pattern ("ed$|($c((a|b)$))"); - valid_pattern ("ed$|(c$((a|b)$))"); - valid_pattern ("ed$|(c($(a|b)$))"); - valid_pattern ("ed$|(c(($a|b)$))"); - valid_pattern ("ed$|(c((a|$b)$))"); - valid_pattern ("ed$|$(c((a$|b$)))"); - valid_pattern ("ed$|($c((a$|b$)))"); - valid_pattern ("ed$|(c$((a$|b$)))"); - valid_pattern ("ed$|(c($(a$|b$)))"); - valid_pattern ("ed$|(c(($a$|b$)))"); - valid_pattern ("ed$|(c((a$|$b$)))"); - valid_pattern ("^a(b|c)^|^d"); - valid_pattern ("^a(b|c^)|^d"); - valid_pattern ("^a(b|^c)|^d"); - valid_pattern ("^a(b^|c)|^d"); - valid_pattern ("^a(^b|c)|^d"); - valid_pattern ("^a^(b|c)|^d"); - valid_pattern ("$a(b$|c$)|d$"); - valid_pattern ("a$(b$|c$)|d$"); - valid_pattern ("a($b$|c$)|d$"); - valid_pattern ("a(b$|$c$)|d$"); - valid_pattern ("a(b$|c$)|$d$"); - valid_pattern ("^(a^)(b|c)|^d"); - valid_pattern ("^(a)^(b|c)|^d"); - valid_pattern ("^(a)(^b|c)|^d"); - valid_pattern ("^(a)(b^|c)|^d"); - valid_pattern ("^(a)(b|^c)|^d"); - valid_pattern ("^(a)(b|c^)|^d"); - valid_pattern ("^(a)(b|c)^|^d"); - valid_pattern ("(^a^)(b|c)|^d"); - valid_pattern ("(^a)^(b|c)|^d"); - valid_pattern ("(^a)(^b|c)|^d"); - valid_pattern ("(^a)(b^|c)|^d"); - valid_pattern ("(^a)(b|^c)|^d"); - valid_pattern ("(^a)(b|c^)|^d"); - valid_pattern ("(^a)(b|c)^|^d"); - - valid_pattern ("(a)(b$|c$)d$"); - valid_pattern ("(a)(b|$c)$|d$"); - valid_pattern ("(a)($b|c)$|d$"); - valid_pattern ("(a)$(b|c)$|d$"); - valid_pattern ("(a$)(b|c)$|d$"); - valid_pattern ("($a)(b|c)$|d$"); - valid_pattern ("$(a)(b|c)$|d$"); - valid_pattern ("(b|c)($a)$|d$"); - valid_pattern ("(b|c)$(a)$|d$"); - valid_pattern ("(b|c$)(a)$|d$"); - valid_pattern ("(b|$c)(a)$|d$"); - valid_pattern ("(b$|c)(a)$|d$"); - valid_pattern ("($b|c)(a)$|d$"); - valid_pattern ("$(b|c)(a)$|d$"); - valid_pattern ("(b|c)($a$)|d$"); - valid_pattern ("(b|c)$(a$)|d$"); - valid_pattern ("(b|c$)(a$)|d$"); - valid_pattern ("(b|$c)(a$)|d$"); - valid_pattern ("(b$|c)(a$)|d$"); - valid_pattern ("($b|c)(a$)|d$"); - valid_pattern ("$(b|c)(a$)|d$"); - valid_pattern ("(a)$(b$|c$)|d$"); - valid_pattern ("(a$)(b$|c$)|d$"); - valid_pattern ("($a)(b$|c$)|d$"); - valid_pattern ("$(a)(b$|c$)|d$"); - valid_pattern ("^d|^(b^|c)(a)"); - valid_pattern ("^d|^(b|c^)(a)"); - valid_pattern ("^d|^(b|c)^(a)"); - valid_pattern ("^d|^(b|c)(^a)"); - valid_pattern ("^d|^(b|c)(a^)"); - valid_pattern ("^d|^(b|c)(a)^"); - valid_pattern ("^d|(^b|^c^)(a)"); - valid_pattern ("^d|(^b|^c)^(a)"); - valid_pattern ("^d|(^b|^c)(^a)"); - valid_pattern ("^d|(^b|^c)(a^)"); - valid_pattern ("^d|(^b|^c)(a)^"); - valid_pattern ("d$|(b|c)($a$)"); - valid_pattern ("d$|(b|c)$(a$)"); - valid_pattern ("d$|(b|c$)(a$)"); - valid_pattern ("d$|(b$|c)(a$)"); - valid_pattern ("d$|($b|c)(a$)"); - valid_pattern ("d$|$(b|c)(a$)"); - valid_pattern ("d$|(b|c)($a)$"); - valid_pattern ("d$|(b|c)$(a)$"); - valid_pattern ("d$|(b|c$)(a)$"); - valid_pattern ("d$|(b$|c)(a)$"); - valid_pattern ("d$|($b|c)(a)$"); - valid_pattern ("d$|$(b|c)(a)$"); - valid_pattern ("^d|^(a^)(b|c)"); - valid_pattern ("^d|^(a)^(b|c)"); - valid_pattern ("^d|^(a)(^b|c)"); - valid_pattern ("^d|^(a)(b^|c)"); - valid_pattern ("^d|^(a)(b|^c)"); - valid_pattern ("^d|^(a)(b|c^)"); - valid_pattern ("^d|^(a)(b|c)^"); - valid_pattern ("^d|(^a^)(b|c)"); - valid_pattern ("^d|(^a)^(b|c)"); - valid_pattern ("^d|(^a)(^b|c)"); - valid_pattern ("^d|(^a)(b^|c)"); - valid_pattern ("^d|(^a)(b|^c)"); - valid_pattern ("^d|(^a)(b|c^)"); - valid_pattern ("^d|(^a)(b|c)^"); - valid_pattern ("d$|(a)$(b$|c$)"); - valid_pattern ("d$|(a$)(b$|c$)"); - valid_pattern ("d$|($a)(b$|c$)"); - valid_pattern ("d$|$(a)(b$|c$)"); - valid_pattern ("d$|(a)(b|$c)$"); - valid_pattern ("d$|(a)($b|c)$"); - valid_pattern ("d$|(a)$(b|c)$"); - valid_pattern ("d$|(a$)(b|c)$"); - valid_pattern ("d$|($a)(b|c)$"); - valid_pattern ("d$|$(a)(b|c)$"); - valid_pattern ("((^a|^b)|^c)|^d^"); - valid_pattern ("((^a|^b)|^c)^|^d"); - valid_pattern ("((^a|^b)|^c^)|^d"); - valid_pattern ("((^a|^b)^|^c)|^d"); - valid_pattern ("((^a|^b^)|^c)|^d"); - valid_pattern ("((^a^|^b)|^c)|^d"); - valid_pattern ("((a|b)|c)|$d$"); - valid_pattern ("((a|b)|$c)|d$"); - valid_pattern ("((a|$b)|c)|d$"); - valid_pattern ("(($a|b)|c)|d$"); - valid_pattern ("($(a|b)|c)|d$"); - valid_pattern ("$((a|b)|c)|d$"); - valid_pattern ("^d^|(c|(a|b))"); - valid_pattern ("^d|(c^|(a|b))"); - valid_pattern ("^d|(c|(a^|b))"); - valid_pattern ("^d|(c|(a|b^))"); - valid_pattern ("^d|(c|(a|b)^)"); - valid_pattern ("^d|(c|(a|b))^"); - valid_pattern ("d$|(c$|(a$|$b$))"); - valid_pattern ("d$|(c$|($a$|b$))"); - valid_pattern ("d$|($c$|(a$|b$))"); - valid_pattern ("d$|$(c$|(a$|b$))"); - valid_pattern ("$d$|(c$|(a$|b$))"); - valid_pattern ("d$|(c$|(a|$b)$)"); - valid_pattern ("d$|(c$|($a|b)$)"); - valid_pattern ("d$|($c$|(a|b)$)"); - valid_pattern ("d$|$(c$|(a|b)$)"); - valid_pattern ("$d$|(c$|(a|b)$)"); - valid_pattern ("d$|(c$|(a|$b))$"); - valid_pattern ("d$|(c$|($a|b))$"); - valid_pattern ("d$|($c$|(a|b))$"); - valid_pattern ("d$|$(c$|(a|b))$"); - valid_pattern ("$d$|(c$|(a|b))$"); - valid_pattern ("^c^|(^a|^b)"); - valid_pattern ("^c|(^a^|^b)"); - valid_pattern ("^c|(^a|^b^)"); - valid_pattern ("^c|(^a|^b)^"); - valid_pattern ("c$|(a$|$b$)"); - valid_pattern ("c$|($a$|b$)"); - valid_pattern ("c$|$(a$|b$)"); - valid_pattern ("$c$|(a$|b$)"); - valid_pattern ("^d^(c|e((a|b)))"); - valid_pattern ("^d(^c|e((a|b)))"); - valid_pattern ("^d(c^|e((a|b)))"); - valid_pattern ("^d(c|^e((a|b)))"); - valid_pattern ("^d(c|e^((a|b)))"); - valid_pattern ("^d(c|e(^(a|b)))"); - valid_pattern ("^d(c|e((^a|b)))"); - valid_pattern ("^d(c|e((a|^b)))"); - valid_pattern ("^d(c|e((a|b^)))"); - valid_pattern ("^d(c|e((a|b)^))"); - valid_pattern ("^d(c|e((a|b))^)"); - valid_pattern ("^d(c|e((a|b)))^"); - valid_pattern ("d(c$|e($(a$|b$)))"); - valid_pattern ("d(c$|e$((a$|b$)))"); - valid_pattern ("d(c$|$e((a$|b$)))"); - valid_pattern ("d($c$|e((a$|b$)))"); - valid_pattern ("d$(c$|e((a$|b$)))"); - valid_pattern ("$d(c$|e((a$|b$)))"); - valid_pattern ("^d|^a^(b|c)"); - valid_pattern ("^d|^a(^b|c)"); - valid_pattern ("^d|^a(b^|c)"); - valid_pattern ("^d|^a(b|^c)"); - valid_pattern ("^d|^a(b|c^)"); - valid_pattern ("^d|^a(b|c)^"); - valid_pattern ("d$|a($b$|c$)"); - valid_pattern ("d$|a$(b$|c$)"); - valid_pattern ("d$|$a(b$|c$)"); - valid_pattern ("$d$|a(b$|c$)"); - valid_pattern ("^d|^(b^|c)a"); - valid_pattern ("^d|^(b|c^)a"); - valid_pattern ("^d|^(b|c)^a"); - valid_pattern ("^d|^(b|c)a^"); - valid_pattern ("d$|(b|c)$a$"); - valid_pattern ("d$|(b|c$)a$"); - valid_pattern ("d$|(b|$c)a$"); - valid_pattern ("d$|(b$|c)a$"); - valid_pattern ("d$|($b|c)a$"); - valid_pattern ("d$|$(b|c)a$"); - valid_pattern ("$d$|(b|c)a$"); - - /* xx Do these use all the valid_nonposix_pattern ones in other_test.c? */ - - TEST_SEARCH ("(^a|^b)c", "ac", 0, 2); - TEST_SEARCH ("(^a|^b)c", "bc", 0, 2); - TEST_SEARCH ("c(a$|b$)", "ca", 0, 2); - TEST_SEARCH ("c(a$|b$)", "cb", 0, 2); - TEST_SEARCH ("^(a|b)|^c", "ad", 0, 2); - TEST_SEARCH ("^(a|b)|^c", "bd", 0, 2); - TEST_SEARCH ("(a|b)$|c$", "da", 0, 2); - TEST_SEARCH ("(a|b)$|c$", "db", 0, 2); - TEST_SEARCH ("(a|b)$|c$", "dc", 0, 2); - TEST_SEARCH ("(^a|^b)|^c", "ad", 0, 2); - TEST_SEARCH ("(^a|^b)|^c", "bd", 0, 2); - TEST_SEARCH ("(^a|^b)|^c", "cd", 0, 2); - TEST_SEARCH ("(a$|b$)|c$", "da", 0, 2); - TEST_SEARCH ("(a$|b$)|c$", "db", 0, 2); - TEST_SEARCH ("(a$|b$)|c$", "dc", 0, 2); - TEST_SEARCH ("^c|(^a|^b)", "ad", 0, 2); - TEST_SEARCH ("^c|(^a|^b)", "bd", 0, 2); - TEST_SEARCH ("^c|(^a|^b)", "cd", 0, 2); - TEST_SEARCH ("c$|(a$|b$)", "da", 0, 2); - TEST_SEARCH ("c$|(a$|b$)", "db", 0, 2); - TEST_SEARCH ("c$|(a$|b$)", "dc", 0, 2); - TEST_SEARCH ("^c|^(a|b)", "ad", 0, 2); - TEST_SEARCH ("^c|^(a|b)", "bd", 0, 2); - TEST_SEARCH ("^c|^(a|b)", "cd", 0, 2); - TEST_SEARCH ("c$|(a|b)$", "da", 0, 2); - TEST_SEARCH ("c$|(a|b)$", "db", 0, 2); - TEST_SEARCH ("c$|(a|b)$", "dc", 0, 2); - TEST_SEARCH ("(^a|^b)c|^d", "ace", 0, 3); - TEST_SEARCH ("(^a|^b)c|^d", "bce", 0, 3); - TEST_SEARCH ("(^a|^b)c|^d", "de", 0, 2); - TEST_SEARCH ("(a|b)c$|d$", "eac", 0, 3); - TEST_SEARCH ("(a|b)c$|d$", "ebc", 0, 3); - TEST_SEARCH ("(a|b)c$|d$", "ed", 0, 3); - TEST_SEARCH ("^d|^c(a|b)", "cae", 0, 3); - TEST_SEARCH ("^d|^c(a|b)", "cbe", 0, 3); - TEST_SEARCH ("^d|^c(a|b)", "de", 0, 3); - TEST_SEARCH ("d$|c(a$|b$)", "eca", 0, 3); - TEST_SEARCH ("d$|c(a$|b$)", "ecb", 0, 3); - TEST_SEARCH ("d$|c(a$|b$)", "ed", 0, 3); - - TEST_SEARCH ("(((^a|^b))c|^d)e", "acef", 0, 4); - TEST_SEARCH ("(((^a|^b))c|^d)e", "bcef", 0, 4); - TEST_SEARCH ("(((^a|^b))c|^d)e", "def", 0, 3); - - TEST_SEARCH ("((^(a|b))c|^d)e", "acef", 0, 4); - TEST_SEARCH ("((^(a|b))c|^d)e", "bcef", 0, 4); - TEST_SEARCH ("((^(a|b))c|^d)e", "def", 0, 3); - - TEST_SEARCH ("(^((a|b))c|^d)e", "acef", 0, 4); - TEST_SEARCH ("(^((a|b))c|^d)e", "bcef", 0, 4); - TEST_SEARCH ("(^((a|b))c|^d)e", "def", 0, 3); - - TEST_SEARCH ("(((a|b))c|d)e$", "face", 0, 4); - TEST_SEARCH ("(((a|b))c|d)e$", "fbce", 0, 4); - TEST_SEARCH ("(((a|b))c|d)e$", "fde", 0, 3); - - TEST_SEARCH ("^e(d|c((a|b)))", "edf", 0, 3); - TEST_SEARCH ("^e(d|c((a|b)))", "ecaf", 0, 4); - TEST_SEARCH ("^e(d|c((a|b)))", "ecbf", 0, 4); - - TEST_SEARCH ("e(d$|c((a$|b$)))", "fed", 0, 3); - TEST_SEARCH ("e(d$|c((a$|b$)))", "feca", 0, 4); - TEST_SEARCH ("e(d$|c((a$|b$)))", "fecb", 0, 4); - - TEST_SEARCH ("e(d$|c((a|b)$))", "fed", 0, 3); - TEST_SEARCH ("e(d$|c((a|b)$))", "feca", 0, 4); - TEST_SEARCH ("e(d$|c((a|b)$))", "fecb", 0, 4); - - TEST_SEARCH ("e(d$|c((a|b))$)", "fed", 0, 3); - TEST_SEARCH ("e(d$|c((a|b))$)", "feca", 0, 3); - TEST_SEARCH ("e(d$|c((a|b))$)", "fecb", 0, 3); - - TEST_SEARCH ("e(d$|c((a|b)))$", "fed", 0, 3); - TEST_SEARCH ("e(d$|c((a|b)))$", "feca", 0, 3); - TEST_SEARCH ("e(d$|c((a|b)))$", "fecb", 0, 3); - - TEST_SEARCH ("(((^a|^b))c)|^de", "acf", 0, 3); - TEST_SEARCH ("(((^a|^b))c)|^de", "bcf", 0, 3); - TEST_SEARCH ("(((^a|^b))c)|^de", "def", 0, 3); - - TEST_SEARCH ("(((a|b))c$)|de$", "fac", 0, 3); - TEST_SEARCH ("(((a|b))c$)|de$", "fbc", 0, 3); - TEST_SEARCH ("(((a|b))c$)|de$", "fde", 0, 3); - - TEST_SEARCH ("(((a|b))c)$|de$", "fac", 0, 3); - TEST_SEARCH ("(((a|b))c)$|de$", "fbc", 0, 3); - TEST_SEARCH ("(((a|b))c)$|de$", "fde", 0, 3); - - TEST_SEARCH ("^ed|^(c((a|b)))", "edf", 0, 3); - TEST_SEARCH ("^ed|^(c((a|b)))", "caf", 0, 3); - TEST_SEARCH ("^ed|^(c((a|b)))", "cbf", 0, 3); - - TEST_SEARCH ("^ed|(^c((a|b)))", "edf", 0, 3); - TEST_SEARCH ("^ed|(^c((a|b)))", "caf", 0, 3); - TEST_SEARCH ("^ed|(^c((a|b)))", "cbf", 0, 3); - - TEST_SEARCH ("ed$|(c((a|b)))$", "fed", 0, 3); - TEST_SEARCH ("ed$|(c((a|b)))$", "fca", 0, 3); - TEST_SEARCH ("ed$|(c((a|b)))$", "fcb", 0, 3); - - TEST_SEARCH ("ed$|(c((a|b))$)", "fed", 0, 3); - TEST_SEARCH ("ed$|(c((a|b))$)", "fca", 0, 3); - TEST_SEARCH ("ed$|(c((a|b))$)", "fcb", 0, 3); - - TEST_SEARCH ("ed$|(c((a|b)$))", "fed", 0, 3); - TEST_SEARCH ("ed$|(c((a|b)$))", "fca", 0, 3); - TEST_SEARCH ("ed$|(c((a|b)$))", "fcb", 0, 3); - - TEST_SEARCH ("ed$|(c((a$|b$)))", "fed", 0, 3); - TEST_SEARCH ("ed$|(c((a$|b$)))", "fca", 0, 3); - TEST_SEARCH ("ed$|(c((a$|b$)))", "fcb", 0, 3); - - TEST_SEARCH ("^a(b|c)|^d", "abe", 0, 3); - TEST_SEARCH ("^a(b|c)|^d", "ace", 0, 3); - TEST_SEARCH ("^a(b|c)|^d", "df", 0, 2); - - TEST_SEARCH ("a(b$|c$)|d$", "fab", 0, 3); - TEST_SEARCH ("a(b$|c$)|d$", "fac", 0, 3); - TEST_SEARCH ("a(b$|c$)|d$", "fd", 0, 2); - - TEST_SEARCH ("^(a)(b|c)|^d", "abe", 0, 3); - TEST_SEARCH ("^(a)(b|c)|^d", "ace", 0, 3); - TEST_SEARCH ("^(a)(b|c)|^d", "df", 0, 2); - - TEST_SEARCH ("(^a)(b|c)|^d", "abe", 0, 3); - TEST_SEARCH ("(^a)(b|c)|^d", "ace", 0, 3); - TEST_SEARCH ("(^a)(b|c)|^d", "df", 0, 2); - - TEST_SEARCH ("(a)(b|c)$|d$", "fab", 0, 3); - TEST_SEARCH ("(a)(b|c)$|d$", "fac", 0, 3); - TEST_SEARCH ("(a)(b|c)$|d$", "fd", 0, 2); - - TEST_SEARCH ("(b|c)(a)$|d$", "fba", 0, 3); - TEST_SEARCH ("(b|c)(a)$|d$", "fca", 0, 3); - TEST_SEARCH ("(b|c)(a)$|d$", "fd", 0, 2); - - TEST_SEARCH ("(b|c)(a$)|d$", "fba", 0, 3); - TEST_SEARCH ("(b|c)(a$)|d$", "fca", 0, 3); - TEST_SEARCH ("(b|c)(a$)|d$", "fd", 0, 2); - - TEST_SEARCH ("(a)(b$|c$)|d$", "fab", 0, 3); - TEST_SEARCH ("(a)(b$|c$)|d$", "fac", 0, 3); - TEST_SEARCH ("(a)(b$|c$)|d$", "fd", 0, 2); - - TEST_SEARCH ("^d|^(b|c)(a)", "df", 0, 2); - TEST_SEARCH ("^d|^(b|c)(a)", "baf", 0, 3); - TEST_SEARCH ("^d|^(b|c)(a)", "caf", 0, 3); - - TEST_SEARCH ("^d|(^b|^c)(a)", "df", 0, 2); - TEST_SEARCH ("^d|(^b|^c)(a)", "baf", 0, 3); - TEST_SEARCH ("^d|(^b|^c)(a)", "caf", 0, 3); - - TEST_SEARCH ("d$|(b|c)(a$)", "fd", 0, 2); - TEST_SEARCH ("d$|(b|c)(a$)", "fba", 0, 3); - TEST_SEARCH ("d$|(b|c)(a$)", "fca", 0, 3); - - TEST_SEARCH ("d$|(b|c)(a)$", "fd", 0, 2); - TEST_SEARCH ("d$|(b|c)(a)$", "fba", 0, 3); - TEST_SEARCH ("d$|(b|c)(a)$", "fca", 0, 3); - - TEST_SEARCH ("d$|(b|c)(a$)", "fd", 0, 2); - TEST_SEARCH ("d$|(b|c)(a$)", "fba", 0, 3); - TEST_SEARCH ("d$|(b|c)(a$)", "fca", 0, 3); - - TEST_SEARCH ("^d|^(a)(b|c)", "df", 0, 2); - TEST_SEARCH ("^d|^(a)(b|c)", "abf", 0, 3); - TEST_SEARCH ("^d|^(a)(b|c)", "acf", 0, 3); - - TEST_SEARCH ("^d|(^a)(b|c)", "df", 0, 2); - TEST_SEARCH ("^d|(^a)(b|c)", "abf", 0, 3); - TEST_SEARCH ("^d|(^a)(b|c)", "acf", 0, 3); - - TEST_SEARCH ("d$|(a)(b$|c$)", "fd", 0, 2); - TEST_SEARCH ("d$|(a)(b$|c$)", "fab", 0, 3); - TEST_SEARCH ("d$|(a)(b$|c$)", "fac", 0, 3); - - TEST_SEARCH ("d$|(a)(b|c)$", "fd", 0, 2); - TEST_SEARCH ("d$|(a)(b|c)$", "fab", 0, 3); - TEST_SEARCH ("d$|(a)(b|c)$", "fac", 0, 3); - - TEST_SEARCH ("((^a|^b)|^c)|^d", "ae", 0, 2); - TEST_SEARCH ("((^a|^b)|^c)|^d", "be", 0, 2); - TEST_SEARCH ("((^a|^b)|^c)|^d", "ce", 0, 2); - TEST_SEARCH ("((^a|^b)|^c)|^d", "de", 0, 2); - - TEST_SEARCH ("((a|b)|c)|d$", "ed", 0, 2); - TEST_SEARCH ("((a|b)|c)|d$", "ea", 0, 2); - TEST_SEARCH ("((a|b)|c)|d$", "eb", 0, 2); - TEST_SEARCH ("((a|b)|c)|d$", "ec", 0, 2); - - TEST_SEARCH ("^d|(c|(a|b))", "de", 0, 2); - - TEST_SEARCH ("d$|(c$|(a$|b$))", "ed", 0, 2); - TEST_SEARCH ("d$|(c$|(a$|b$))", "ec", 0, 2); - TEST_SEARCH ("d$|(c$|(a$|b$))", "ea", 0, 2); - TEST_SEARCH ("d$|(c$|(a$|b$))", "eb", 0, 2); - - TEST_SEARCH ("d$|(c$|(a|b)$)", "ed", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b)$)", "ec", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b)$)", "ea", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b)$)", "eb", 0, 2); - - TEST_SEARCH ("d$|(c$|(a|b))$", "ed", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b))$", "ec", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b))$", "ea", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b))$", "eb", 0, 2); - - test_match ("a|^b", "b"); - test_match ("a|b$", "b"); - test_match ("^b|a", "b"); - test_match ("b$|a", "b"); - test_match ("(^a)", "a"); - test_match ("(a$)", "a"); - TEST_SEARCH ("c|^ab", "aba", 0, 3); - TEST_SEARCH ("c|ba$", "aba", 0, 3); - TEST_SEARCH ("^ab|c", "aba", 0, 3); - TEST_SEARCH ("ba$|c", "aba", 0, 3); - TEST_SEARCH ("(^a)", "ab", 0, 2); - TEST_SEARCH ("(a$)", "ba", 0, 2); - - TEST_SEARCH ("(^a$)", "a", 0, 1); - TEST_SEARCH ("(^a)", "ab", 0, 2); - TEST_SEARCH ("(b$)", "ab", 0, 2); - - /* Backtracking. */ - /* Per POSIX D11.1 p. 108, leftmost longest match. */ - test_match ("(wee|week)(knights|night)", "weeknights"); - - test_match ("(fooq|foo)qbar", "fooqbar"); - test_match ("(fooq|foo)(qbarx|bar)", "fooqbarx"); - - /* Take first alternative that does the longest match. */ - test_all_registers ("(fooq|(foo)|(fo))((qbarx)|(oqbarx)|bar)", "fooqbarx", - "", 0, 8, 0, 3, 0, 3, -1, -1, 3, 8, 3, 8, -1, -1, -1, -1, -1, -1, - -1, -1); - - test_match ("(fooq|foo)*qbar", "fooqbar"); - test_match ("(fooq|foo)*(qbar)", "fooqbar"); - test_match ("(fooq|foo)*(qbar)*", "fooqbar"); - - test_match ("(fooq|fo|o)*qbar", "fooqbar"); - test_match ("(fooq|fo|o)*(qbar)", "fooqbar"); - test_match ("(fooq|fo|o)*(qbar)*", "fooqbar"); - - test_match ("(fooq|fo|o)*(qbar|q)*", "fooqbar"); - test_match ("(fooq|foo)*(qbarx|bar)", "fooqbarx"); - test_match ("(fooq|foo)*(qbarx|bar)*", "fooqbarx"); - - test_match ("(fooq|fo|o)+(qbar|q)+", "fooqbar"); - test_match ("(fooq|foo)+(qbarx|bar)", "fooqbarx"); - test_match ("(fooq|foo)+(qbarx|bar)+", "fooqbarx"); - - /* Per Mike Haertel. */ - test_match ("(foo|foobarfoo)(bar)*", "foobarfoo"); - - /* Combination. */ - test_match ("[ab]?c", "ac"); - test_match ("[ab]*c", "ac"); - test_match ("[ab]+c", "ac"); - test_match ("(a|b)?c", "ac"); - test_match ("(a|b)*c", "ac"); - test_match ("(a|b)+c", "ac"); - test_match ("(a*c)?b", "b"); - test_match ("(a*c)+b", "aacb"); - /* Registers. */ - /* Per David A. Willcox. */ - test_match ("a((b)|(c))d", "acd"); - test_all_registers ("a((b)|(c))d", "acd", "", 0, 3, 1, 2, -1, -1, 1, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - - /* Extended regular expressions, continued; these don't match their strings. */ - test_should_match = false; - -#if 0 - /* Invalid use of special characters. */ - /* These are not invalid anymore, since POSIX says the behavior is - undefined, and we prefer context-independent to context-invalid. */ - invalid_pattern (REG_BADRPT, "*"); - invalid_pattern (REG_BADRPT, "a|*"); - invalid_pattern (REG_BADRPT, "(*)"); - invalid_pattern (REG_BADRPT, "^*"); - invalid_pattern (REG_BADRPT, "+"); - invalid_pattern (REG_BADRPT, "a|+"); - invalid_pattern (REG_BADRPT, "(+)"); - invalid_pattern (REG_BADRPT, "^+"); - - invalid_pattern (REG_BADRPT, "?"); - invalid_pattern (REG_BADRPT, "a|?"); - invalid_pattern (REG_BADRPT, "(?)"); - invalid_pattern (REG_BADRPT, "^?"); - - invalid_pattern (REG_BADPAT, "|"); - invalid_pattern (REG_BADPAT, "a|"); - invalid_pattern (REG_BADPAT, "a||"); - invalid_pattern (REG_BADPAT, "(|a)"); - invalid_pattern (REG_BADPAT, "(a|)"); - - invalid_pattern (REG_BADPAT, PARENS_TO_OPS ("(|)")); - - invalid_pattern (REG_BADRPT, "{1}"); - invalid_pattern (REG_BADRPT, "a|{1}"); - invalid_pattern (REG_BADRPT, "^{1}"); - invalid_pattern (REG_BADRPT, "({1})"); - - invalid_pattern (REG_BADPAT, "|b"); - - invalid_pattern (REG_BADRPT, "^{0,}*"); - invalid_pattern (REG_BADRPT, "$*"); - invalid_pattern (REG_BADRPT, "${0,}*"); -#endif /* 0 */ - - invalid_pattern (REG_EESCAPE, "\\"); - - test_match ("a?b", "a"); - - - test_match ("a+", ""); - test_match ("a+b", "a"); - test_match ("a?", "b"); - -#if 0 - /* We make empty groups valid now, since they are undefined in POSIX. - (13 Sep 92) */ - /* Subexpressions. */ - invalid_pattern (REG_BADPAT, "()"); - invalid_pattern (REG_BADPAT, "a()"); - invalid_pattern (REG_BADPAT, "()b"); - invalid_pattern (REG_BADPAT, "a()b"); - invalid_pattern (REG_BADPAT, "()*"); - invalid_pattern (REG_BADPAT, "(()*"); -#endif - /* Invalid intervals. */ - test_match ("a{2}*", "aaa"); - test_match ("a{2}?", "aaa"); - test_match ("a{2}+", "aaa"); - test_match ("a{2}{2}", "aaa"); - test_match ("a{1}{1}{2}", "aaa"); - test_match ("a{1}{1}{2}", "a"); - /* Invalid alternation. */ - test_match ("a|b", "c"); - - TEST_SEARCH ("c|^ba", "aba", 0, 3); - TEST_SEARCH ("c|ab$", "aba", 0, 3); - TEST_SEARCH ("^ba|c", "aba", 0, 3); - TEST_SEARCH ("ab$|c", "aba", 0, 3); - /* Invalid anchoring. */ - TEST_SEARCH ("(^a)", "ba", 0, 2); - TEST_SEARCH ("(b$)", "ba", 0, 2); - - printf ("\nFinished POSIX extended tests.\n"); -} - - - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/libregex/test/psx-generic.c b/gnu/lib/libregex/test/psx-generic.c deleted file mode 100644 index 912aa70140ab..000000000000 --- a/gnu/lib/libregex/test/psx-generic.c +++ /dev/null @@ -1,340 +0,0 @@ -/* psx-generic.c: test POSIX re's independent of us using basic or - extended syntax. */ - -#ifndef lint -static char rcsid[] = "$Id: psx-generic.c,v 1.2 1993/08/02 17:24:27 mycroft Exp $"; -#endif /* not lint */ - -#include "test.h" - - -void -test_posix_generic () -{ - int omit_generic_tests = 0; /* reset in debugger to skip */ - - if (omit_generic_tests) - return; - /* Tests somewhat in the order of P1003.2. */ - - /* Both posix basic and extended; should match. */ - - printf ("\nStarting generic POSIX tests.\n"); - test_grouping (); - test_intervals (); - - test_should_match = true; - /* Ordinary characters. */ - printf ("\nContinuing generic POSIX tests.\n"); - - MATCH_SELF (""); - test_fastmap ("", "", 0, 0); - test_fastmap_search ("", "", "", 0, 0, 2, 0, 0); - TEST_REGISTERS ("", "", 0, 0, -1, -1, -1, -1); - TEST_SEARCH ("", "", 0, 0); - TEST_SEARCH_2 ("", "", "", 0, 1, 0); - - MATCH_SELF ("abc"); - test_fastmap ("abc", "a", 0, 0); - TEST_REGISTERS ("abc", "abc", 0, 3, -1, -1, -1, -1); - TEST_REGISTERS ("abc", "xabcx", 1, 4, -1, -1, -1, -1); - - test_match ("\\a","a"); - test_match ("\\0", "0"); - - TEST_SEARCH ("a", "ab", 0, 2); - TEST_SEARCH ("b", "ab", 0, 2); - TEST_SEARCH ("a", "ab", 1, -2); - TEST_SEARCH_2 ("a", "a", "b", 0, 2, 2); - TEST_SEARCH_2 ("b", "a", "b", 0, 2, 2); - TEST_SEARCH_2 ("a", "a", "b", 1, -2, 2); - - test_match ("\n", "\n"); - test_match ("a\n", "a\n"); - test_match ("\nb", "\nb"); - test_match ("a\nb", "a\nb"); - - TEST_SEARCH ("b", "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 236, -237); - /* Valid use of special characters. */ - test_match ("a*", "aa"); - test_fastmap ("a*", "a", 0, 0); - TEST_REGISTERS ("a*", "aa", 0, 2, -1, -1, -1, -1); - - test_match ("a*b", "aab"); - test_fastmap ("a*b", "ab", 0, 0); - - test_match ("a*ab", "aab"); - TEST_REGISTERS ("a*a", "aa", 0, 2, -1, -1, -1, -1); - TEST_REGISTERS ("a*a", "xaax", 1, 3, -1, -1, -1, -1); - - test_match ("\\{", "{"); - test_match ("\\^", "^"); - test_match ("\\.", "."); - test_match ("\\*", "*"); - test_match ("\\[", "["); - test_match ("\\$", "$"); - test_match ("\\\\", "\\"); - - test_match ("ab*", "a"); - test_match ("ab*", "abb"); - - /* Valid consecutive repetitions. */ - test_match ("a**", "a"); - /* Valid period. */ - test_match (".", "a"); - TEST_REGISTERS (".", "a", 0, 1, -1, -1, -1, -1); - test_match (".", "\004"); - test_match (".", "\n"); - /* Valid bracket expressions. */ - test_match ("[ab]", "a"); - test_match ("[ab]", "b"); - test_fastmap ("[ab]", "ab", 0, 0); - TEST_REGISTERS ("[ab]", "a", 0, 1, -1, -1, -1, -1); - TEST_REGISTERS ("[ab]", "xax", 1, 2, -1, -1, -1, -1); - - test_fastmap ("[^ab]", "ab", 1, 1); - test_match ("[^ab]", "c"); - test_match ("[^a]", "\n"); - - test_match ("[a]*a", "aa"); - - test_match ("[[]", "["); - test_match ("[]]", "]"); - test_match ("[.]", "."); - test_match ("[*]", "*"); - test_match ("[\\]", "\\"); - test_match ("[\\(]", "("); - test_match ("[\\)]", ")"); - test_match ("[^]]", "a"); - test_match ("[a^]", "^"); - test_match ("[a$]", "$"); - test_match ("[]a]", "]"); - test_match ("[a][]]", "a]"); - test_match ("[\n]", "\n"); - test_match ("[^a]", "\n"); - test_match ("[a-]", "a"); - - TEST_REGISTERS ("\\`[ \t\n]*", " karl (Karl Berry)", 0, 1, -1, -1, -1, -1); - TEST_REGISTERS ("[ \t\n]*\\'", " karl (Karl Berry)", 18, 18, -1, -1, -1, -1); - - /* Collating, noncollating, - equivalence classes aren't - implemented yet. */ - - - /* Character classes. */ - test_match ("[:alpha:]", "p"); - test_match ("[[:alpha:]]", "a"); - test_match ("[[:alpha:]]", "z"); - test_match ("[[:alpha:]]", "A"); - test_match ("[[:alpha:]]", "Z"); - test_match ("[[:upper:]]", "A"); - test_match ("[[:upper:]]", "Z"); - test_match ("[[:lower:]]", "a"); - test_match ("[[:lower:]]", "z"); - - test_match ("[[:digit:]]", "0"); - test_match ("[[:digit:]]", "9"); - test_fastmap ("[[:digit:]]", "0123456789", 0, 0); - - test_match ("[[:alnum:]]", "0"); - test_match ("[[:alnum:]]", "9"); - test_match ("[[:alnum:]]", "a"); - test_match ("[[:alnum:]]", "z"); - test_match ("[[:alnum:]]", "A"); - test_match ("[[:alnum:]]", "Z"); - test_match ("[[:xdigit:]]", "0"); - test_match ("[[:xdigit:]]", "9"); - test_match ("[[:xdigit:]]", "A"); - test_match ("[[:xdigit:]]", "F"); - test_match ("[[:xdigit:]]", "a"); - test_match ("[[:xdigit:]]", "f"); - test_match ("[[:space:]]", " "); - test_match ("[[:print:]]", " "); - test_match ("[[:print:]]", "~"); - test_match ("[[:punct:]]", ","); - test_match ("[[:graph:]]", "!"); - test_match ("[[:graph:]]", "~"); - test_match ("[[:cntrl:]]", "\177"); - test_match ("[[:digit:]a]", "a"); - test_match ("[[:digit:]a]", "2"); - test_match ("[a[:digit:]]", "a"); - test_match ("[a[:digit:]]", "2"); - test_match ("[[:]", "["); - test_match ("[:]", ":"); - test_match ("[[:a]", "["); - test_match ("[[:alpha:a]", "["); - /* Valid ranges. */ - test_match ("[a-a]", "a"); - test_fastmap ("[a-a]", "a", 0, 0); - TEST_REGISTERS ("[a-a]", "xax", 1, 2, -1, -1, -1, -1); - - test_match ("[a-z]", "z"); - test_fastmap ("[a-z]", "abcdefghijklmnopqrstuvwxyz", 0, 0); - test_match ("[-a]", "-"); /* First */ - test_match ("[-a]", "a"); - test_match ("[a-]", "-"); /* Last */ - test_match ("[a-]", "a"); - test_match ("[--@]", "@"); /* First and starting point. */ - - test_match ("[%--a]", "%"); /* Ending point. */ - test_match ("[%--a]", "-"); /* Ditto. */ - - test_match ("[a%--]", "%"); /* Both ending point and last. */ - test_match ("[a%--]", "-"); - test_match ("[%--a]", "a"); /* Ending point only. */ - test_match ("[a-c-f]", "e"); /* Piggyback. */ - - test_match ("[)-+--/]", "*"); - test_match ("[)-+--/]", ","); - test_match ("[)-+--/]", "/"); - test_match ("[[:digit:]-]", "-"); - /* Concatenation ????*/ - test_match ("[ab][cd]", "ac"); - test_fastmap ("[ab][cd]", "ab", 0, 0); - TEST_REGISTERS ("[ab][cd]", "ad", 0, 2, -1, -1, -1, -1); - TEST_REGISTERS ("[ab][cd]", "xadx", 1, 3, -1, -1, -1, -1); - - /* Valid expression anchoring. */ - test_match ("^a", "a"); - test_fastmap ("^a", "a", 0, 0); - TEST_REGISTERS ("^a", "ax", 0, 1, -1, -1, -1, -1); - - test_match ("^", ""); - TEST_REGISTERS ("^", "", 0, 0, -1, -1, -1, -1); - test_match ("$", ""); - TEST_REGISTERS ("$", "", 0, 0, -1, -1, -1, -1); - - test_match ("a$", "a"); - test_fastmap ("a$", "a", 0, 0); - TEST_REGISTERS ("a$", "xa", 1, 2, -1, -1, -1, -1); - - test_match ("^ab$", "ab"); - test_fastmap ("^ab$", "a", 0, 0); - TEST_REGISTERS ("^a$", "a", 0, 1, -1, -1, -1, -1); - - test_fastmap ("^$", "", 0, 0); - test_match ("^$", ""); - TEST_REGISTERS ("^$", "", 0, 0, -1, -1, -1, -1); - - TEST_SEARCH (PARENS_TO_OPS ("(^a)"), "ab", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("(a$)"), "ba", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("^(^a)"), "ab", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("(a$)$"), "ba", 0, 2); - - /* Two strings. */ - test_match_2 ("ab", "a", "b"); - TEST_REGISTERS_2 ("ab", "a", "b", 0, 2, -1, -1, -1, -1); - - test_match_2 ("a", "", "a"); - test_match_2 ("a", "a", ""); - test_match_2 ("ab", "a", "b"); - /* (start)pos. */ - TEST_POSITIONED_MATCH ("b", "ab", 1); - /* mstop. */ - TEST_TRUNCATED_MATCH ("a", "ab", 1); - - - /* Both basic and extended, continued; should not match. */ - - test_should_match = false; - /* Ordinary characters. */ - test_match ("abc", "ab"); - - TEST_SEARCH ("c", "ab", 0, 2); - TEST_SEARCH ("c", "ab", 0, 2); - TEST_SEARCH ("c", "ab", 1, -2); - TEST_SEARCH ("c", "ab", 0, 10); - TEST_SEARCH ("c", "ab", 1, -10); - TEST_SEARCH_2 ("c", "a", "b", 0, 2, 2); - TEST_SEARCH_2 ("c", "a", "b", 0, 2, 2); - TEST_SEARCH_2 ("c", "a", "b", 0, 2, 2); - TEST_SEARCH_2 ("c", "a", "b", 1, -2, 2); - TEST_SEARCH_2 ("c", "a", "b", 1, -2, 2); - - TEST_SEARCH ("c", "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 236, -237); - - /* Invalid use of special characters. */ - invalid_pattern (REG_EESCAPE, "\\"); - invalid_pattern (REG_EESCAPE, "a\\"); - invalid_pattern (REG_EESCAPE, "a*\\"); - /* Invalid period. */ - test_match (".", ""); - /* Invalid bracket expressions. */ - test_match ("[ab]", "c"); - test_match ("[^b]", "b"); - test_match ("[^]]", "]"); - - invalid_pattern (REG_EBRACK, "["); - invalid_pattern (REG_EBRACK, "[^"); - invalid_pattern (REG_EBRACK, "[a"); - invalid_pattern (REG_EBRACK, "[]"); - invalid_pattern (REG_EBRACK, "[]a"); - invalid_pattern (REG_EBRACK, "a[]a"); - - - test_match ("[:alpha:]", "q"); /* Character classes. */ - test_match ("[[:alpha:]]", "2"); - test_match ("[[:upper:]]", "a"); - test_match ("[[:lower:]]", "A"); - test_match ("[[:digit:]]", "a"); - test_match ("[[:alnum:]]", ":"); - test_match ("[[:xdigit:]]", "g"); - test_match ("[[:space:]]", "a"); - test_match ("[[:print:]]", "\177"); - test_match ("[[:punct:]]", "a"); - test_match ("[[:graph:]]", " "); - test_match ("[[:cntrl:]]", "a"); - invalid_pattern (REG_EBRACK, "[[:"); - invalid_pattern (REG_EBRACK, "[[:alpha:"); - invalid_pattern (REG_EBRACK, "[[:alpha:]"); - invalid_pattern (REG_ECTYPE, "[[::]]"); - invalid_pattern (REG_ECTYPE, "[[:a:]]"); - invalid_pattern (REG_ECTYPE, "[[:alpo:]]"); - invalid_pattern (REG_ECTYPE, "[[:a:]"); - - test_match ("[a-z]", "2"); /* Invalid ranges. */ - test_match ("[^-a]", "-"); - test_match ("[^a-]", "-"); - test_match ("[)-+--/]", "."); - invalid_pattern (REG_ERANGE, "[z-a]"); /* Empty */ - invalid_pattern (REG_ERANGE, "[a--]"); /* Empty */ - invalid_pattern (REG_ERANGE, "[[:digit:]-9]"); - invalid_pattern (REG_ERANGE, "[a-[:alpha:]]"); - invalid_pattern (REG_ERANGE, "[a-"); - invalid_pattern (REG_EBRACK, "[a-z"); - - test_match ("[ab][cd]", "ae"); /* Concatenation. */ - test_match ("b*c", "b"); /* Star. */ - - /* Invalid anchoring. */ - test_match ("^", "a"); - test_match ("^a", "ba"); - test_match ("$", "b"); - test_match ("a$", "ab"); - test_match ("^$", "a"); - test_match ("^ab$", "a"); - - TEST_SEARCH ("^a", "b\na", 0, 3); - TEST_SEARCH ("b$", "b\na", 0, 3); - - test_match_2 ("^a", "\n", "a"); - test_match_2 ("a$", "a", "\n"); - - TEST_SEARCH (PARENS_TO_OPS ("(^a)"), "ba", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("(a$)"), "ab", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("^(^a)"), "ba", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("(a$)$"), "ab", 0, 2); - - printf ("\nFinished generic POSIX tests.\n"); -} - - - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/libregex/test/psx-group.c b/gnu/lib/libregex/test/psx-group.c deleted file mode 100644 index 4ccebe0546e8..000000000000 --- a/gnu/lib/libregex/test/psx-group.c +++ /dev/null @@ -1,444 +0,0 @@ -/* psx-group.c: test POSIX grouping, both basic and extended. */ - -#ifndef lint -static char rcsid[] = "$Id: psx-group.c,v 1.2 1993/08/02 17:24:28 mycroft Exp $"; -#endif /* not lint */ - -#include "test.h" - - -void -test_grouping () -{ - printf ("\nStarting POSIX grouping tests.\n"); - - test_should_match = true; - - test_fastmap (PARENS_TO_OPS ("(a)"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a)"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)"), "a", 0, 1, 0, 1, -1, -1); - TEST_REGISTERS (PARENS_TO_OPS ("(a)"), "xax", 1, 2, 1, 2, -1, -1); - - test_match (PARENS_TO_OPS ("((a))"), "a"); - test_fastmap (PARENS_TO_OPS ("((a))"), "a", 0, 0); - TEST_REGISTERS (PARENS_TO_OPS ("((a))"), "a", 0, 1, 0, 1, 0, 1); - TEST_REGISTERS (PARENS_TO_OPS ("((a))"), "xax", 1, 2, 1, 2, 1, 2); - - test_fastmap (PARENS_TO_OPS ("(a)(b)"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a)(b)"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)(b)"), "ab", 0, 2, 0, 1, 1, 2); - - TEST_REGISTERS (PARENS_TO_OPS ("(a)(b)"), "xabx", 1, 3, 1, 2, 2, 3); - - test_all_registers (PARENS_TO_OPS ("((a)(b))"), "ab", "", 0, 2, 0, 2, 0, 1, - 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - - /* Test that we simply ignore groups past the 255th. */ - test_match (PARENS_TO_OPS ("((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((a))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))"), "a"); - - - /* Per POSIX D11.1, p. 125. */ - - test_fastmap (PARENS_TO_OPS ("(a)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*"), "", 0, 0, -1, -1, -1, -1); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*"), "aa", 0, 2, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a*)"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)"), "", 0, 0, 0, 0, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a*)"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)"), "a", 0, 1, 0, 1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)b"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a*)b"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)b"), "b", 0, 1, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)b"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)b"), "ab", 0, 2, 0, 1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a*)b)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a*)b)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("((a*)b)*"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "ab", 0, 2, 0, 2, 0, 1); - - test_match (PARENS_TO_OPS ("((a*)b)*"), "abb"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "abb", 0, 3, 2, 3, 2, 2); - - test_match (PARENS_TO_OPS ("((a*)b)*"), "aabab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "aabab", 0, 5, 3, 5, 3, 4); - - test_match (PARENS_TO_OPS ("((a*)b)*"), "abbab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "abbab", 0, 5, 3, 5, 3, 4); - - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "xabbabx", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("((a*)b)*"), "abaabaaaab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "abaabaaab", 0, 9, 5, 9, 5, 8); - - test_fastmap (PARENS_TO_OPS ("(ab)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(ab)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(ab)*"), "", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(ab)*"), "abab"); - TEST_REGISTERS (PARENS_TO_OPS ("(ab)*"), "abab", 0, 4, 2, 4, -1, -1); - - /* We match the empty string here. */ - TEST_REGISTERS (PARENS_TO_OPS ("(ab)*"), "xababx", 0, 0, -1, -1, -1, -1); - - /* Per David A. Willcox. */ - TEST_REGISTERS (PARENS_TO_OPS ("a(b*)c"), "ac", 0, 2, 1, 1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a)*b"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a)*b"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*b"), "b", 0, 1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(a)*b"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*b"), "ab", 0, 2, 0, 1, -1, -1); - - test_match_2 (PARENS_TO_OPS ("(a)*b"), "a", "ab"); - TEST_REGISTERS_2 (PARENS_TO_OPS ("(a)*b"), "a", "ab", 0, 3, 1, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a)*b"), "aab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*b"), "aab", 0, 3, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a)*a"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a)*a"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*a"), "a", 0, 1, -1, -1, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*"), "", 0, 0, 0, 0, 0, 0); - - test_match (PARENS_TO_OPS ("((a*))*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a*))*"), "", 0, 0, 0, 0, 0, 0); - test_match (PARENS_TO_OPS ("((a*))*"), "aa"); - - test_fastmap (PARENS_TO_OPS ("(a*)*b"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a*)*b"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "b", 0, 1, 0, 0, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "xbx", 1, 2, 1, 1, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)*b"), "ab"); /* Per rms. */ - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "ab", 0, 2, 0, 1, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "xabx", 1, 3, 1, 2, -1, -1); - - /* Test register restores. */ - test_match (PARENS_TO_OPS ("(a*)*b"), "aab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "aab", 0, 3, 0, 2, -1, -1); - - TEST_REGISTERS_2 (PARENS_TO_OPS ("(a*)*b"), "a", "ab", 0, 3, 0, 2, -1, -1); - - /* We are matching the empty string, with backtracking. */ - test_fastmap (PARENS_TO_OPS ("(a*)a"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a*)a"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)a"), "a", 0, 1, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)a"), "aa"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)a"), "aa", 0, 2, 0, 1, -1, -1); - - /* We are matching the empty string, with backtracking. */ -/*fails test_match (PARENS_TO_OPS ("(a*)*a"), "a"); */ - test_match (PARENS_TO_OPS ("(a*)*a"), "aa"); - /* Match the empty string. */ - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "a", 0, 1, 0, 0, -1, -1); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "xax", 1, 2, 1, 1, -1, -1); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "aa", 0, 2, 0, 1, -1, -1); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "xaax", 1, 3, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a)*ab"), "a", 0 , 0); - test_match (PARENS_TO_OPS ("(a)*ab"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*ab"), "ab", 0, 2, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(a)*ab"), "aab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*ab"), "aab", 0, 3, 0, 1, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS("(a)*ab"), "xaabx", 1, 4, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)ab"), "a", 0 , 0); - test_match (PARENS_TO_OPS ("(a*)ab"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)ab"), "ab", 0, 2, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)ab"), "aab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)ab"), "aab", 0, 3, 0, 1, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS ("(a*)ab"), "xaabx", 1, 4, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)*ab"), "a", 0 , 0); - test_match (PARENS_TO_OPS ("(a*)*ab"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*ab"), "ab", 0, 2, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)*ab"), "aab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*ab"), "aab", 0, 3, 0, 1, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS("(a*)*ab"), "xaabx", 1, 4, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)*b*c"), "abc", 0, 0); - test_match (PARENS_TO_OPS ("(a*)*b*c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b*c"), "c", 0, 1, 0, 0, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a)*(ab)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a)*(ab)*"), "ab"); - /* Register 1 doesn't match at all (vs. matching the empty string) - because of backtracking, hence -1's. */ - TEST_REGISTERS (PARENS_TO_OPS ("(a)*(ab)*"), "ab", 0, 2, -1, -1, 0, 2); - - test_match (PARENS_TO_OPS ("(a*)*(ab)*"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*(ab)*"), "ab", 0, 2, 0, 0, 0, 2); - - test_fastmap (PARENS_TO_OPS ("(a*b)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a*b)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*"), "", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b)*"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*"), "b", 0, 1, 0, 1, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b)*"), "baab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*"), "baab", 0, 4, 1, 4, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*b*)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a*b*)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "", 0, 0, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "a", 0, 1, 0, 1, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "ba"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "ba", 0, 2, 1, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "ab", 0, 2, 0, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "aa"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "aa", 0, 2, 0, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "bb"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "bb", 0, 2, 0, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "aba"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "aba", 0, 3, 2, 3, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)b"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)b"), "b", 0, 1, 0, 0, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a*)*(b*)*)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a*)*(b*)*)*"), ""); - test_all_registers (PARENS_TO_OPS ("((a*)*(b*)*)*"), "", "", 0, 0, 0, 0, - 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("((a*)*(b*)*)*"), "aba"); - /* Perhaps register 3 should be 3/3 here? Not sure if standard - specifies this. xx*/ - test_all_registers (PARENS_TO_OPS ("((a*)*(b*)*)*"), "aba", "", 0, 3, 2, 3, - 2, 3, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a*)(b*))*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a*)(b*))*"), ""); - - test_all_registers (PARENS_TO_OPS ("((a*)(b*))*"), "", "", 0, 0, 0, 0, - 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), ""); - - test_match (PARENS_TO_OPS ("((a*)(b*))*"), "aba"); - test_all_registers (PARENS_TO_OPS ("((a*)(b*))*"), "aba", "", 0, 3, 2, 3, - 2, 3, 3, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a)*(b)*)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a)*(b)*)*"), ""); - test_all_registers (PARENS_TO_OPS ("((a)*(b)*)*"), "", "", 0, 0, 0, 0, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("((a)*(b)*)*"), "aba"); - - test_all_registers (PARENS_TO_OPS ("((a)*(b)*)*"), "aba", "", 0, 3, 2, 3, - 2, 3, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(c(a)*(b)*)*"), "c", 0, 0); - test_match (PARENS_TO_OPS ("(c(a)*(b)*)*"), ""); - test_all_registers (PARENS_TO_OPS ("(c(a)*(b)*)*"), "", "", 0, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(c(a)*(b)*)*"), "c"); - test_all_registers (PARENS_TO_OPS ("(c(a)*(b)*)*"), "c", "", 0, 1, 0, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("c((a)*(b)*)*"), "c", 0, 0); - test_match (PARENS_TO_OPS ("c((a)*(b)*)*"), "c"); - test_all_registers (PARENS_TO_OPS ("c((a)*(b)*)*"), "c", "", 0, 1, 1, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(((a)*(b)*)*)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(((a)*(b)*)*)*"), ""); - test_all_registers (PARENS_TO_OPS ("(((a)*(b)*)*)*"), "", "", 0, 0, 0, 0, - 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), ""); - test_fastmap (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), "c", 0, 0); - - test_all_registers (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), "", "", 0, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a)*b)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a)*b)*"), ""); - - test_match (PARENS_TO_OPS ("((a)*b)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("((a)*b)*"), "abb"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "abb", 0, 3, 2, 3, 0, 1); /*zz*/ - - test_match (PARENS_TO_OPS ("((a)*b)*"), "abbab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "abbab", 0, 5, 3, 5, 3, 4); - - /* We match the empty string here. */ - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "xabbabx", 0, 0, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a*)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*"), "", 0, 0, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)*"), "aa"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*"), "aa", 0, 2, 0, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a*)*)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("((a*)*)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)*)*"), "", 0, 0, 0, 0, 0, 0); - - test_match (PARENS_TO_OPS ("((a*)*)*"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)*)*"), "a", 0, 1, 0, 1, 0, 1); - - test_fastmap (PARENS_TO_OPS ("(ab*)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(ab*)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*"), "", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(ab*)*"), "aa"); - TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*"), "aa", 0, 2, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(ab*)*c"), "ac", 0, 0); - test_match (PARENS_TO_OPS ("(ab*)*c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*c"), "c", 0, 1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(ab*)*c"), "abbac"); - TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*c"), "abbac", 0, 5, 3, 4, -1, -1); - - test_match (PARENS_TO_OPS ("(ab*)*c"), "abac"); - TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*c"), "abac", 0, 4, 2, 3, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*b)*c"), "abc", 0, 0); - test_match (PARENS_TO_OPS ("(a*b)*c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "c", 0, 1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b)*c"), "bbc"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "bbc", 0, 3, 1, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b)*c"), "aababc"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "aababc", 0, 6, 3, 5, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b)*c"), "aabaabc"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "aabaabc", 0, 7, 3, 6, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a*)b*)"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a*)b*)"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)"), "", 0, 0, 0, 0, 0, 0); - - test_match (PARENS_TO_OPS ("((a*)b*)"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)"), "a", 0, 1, 0, 1, 0, 1); - - test_match (PARENS_TO_OPS ("((a*)b*)"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)"), "b", 0, 1, 0, 1, 0, 0); - - test_fastmap (PARENS_TO_OPS ("((a)*b*)"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a)*b*)"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "", 0, 0, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("((a)*b*)"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "a", 0, 1, 0, 1, 0, 1); - - test_match (PARENS_TO_OPS ("((a)*b*)"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "b", 0, 1, 0, 1, -1, -1); - - test_match (PARENS_TO_OPS ("((a)*b*)"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "ab", 0, 2, 0, 2, 0, 1); - - test_fastmap (PARENS_TO_OPS ("((a*)b*)c"), "abc", 0, 0); - test_match (PARENS_TO_OPS ("((a*)b*)c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)c"), "c", 0, 1, 0, 0, 0, 0); - - test_fastmap (PARENS_TO_OPS ("((a)*b*)c"), "abc", 0, 0); - test_match (PARENS_TO_OPS ("((a)*b*)c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)c"), "c", 0, 1, 0, 0, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*b*)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a*b*)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "", 0, 0, 0, 0, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(((a*))((b*)))*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(((a*))((b*)))*"), ""); - test_all_registers (PARENS_TO_OPS ("(((a*))((b*)))*"), "", "", 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(c*((a*))d*((b*))e*)*"), "abcde", 0, 0); - test_match (PARENS_TO_OPS ("(c*((a*))d*((b*))e*)*"), ""); - test_all_registers (PARENS_TO_OPS ("(c*((a*))d*((b*))e*)*"), "", "", 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a)*b)*c"), "abc", 0, 0); - test_match (PARENS_TO_OPS ("((a)*b)*c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*c"), "c", 0, 1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(ab)*"), ""); - test_match (PARENS_TO_OPS ("((ab)*)"), ""); - test_match (PARENS_TO_OPS ("(((ab)*))"), ""); - test_match (PARENS_TO_OPS ("((((ab)*)))"), ""); - test_match (PARENS_TO_OPS ("(((((ab)*))))"), ""); - test_match (PARENS_TO_OPS ("((((((ab)*)))))"), ""); - test_match (PARENS_TO_OPS ("(((((((ab)*))))))"), ""); - test_match (PARENS_TO_OPS ("((((((((ab)*)))))))"), ""); - test_match (PARENS_TO_OPS ("(((((((((ab)*))))))))"), ""); - - - test_fastmap (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "a", 0, 0); - test_match (PARENS_TO_OPS ("((((((((((ab)*)))))))))"), ""); - test_match (PARENS_TO_OPS ("(((((((((ab)*))))))))"), ""); - test_all_registers (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "", NULL, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "abab"); - test_all_registers (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "abab", NULL, - 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 2, 4); - - - test_should_match = false; - - invalid_pattern (REG_EPAREN, PARENS_TO_OPS ("(a")); - - test_match (PARENS_TO_OPS ("(a)"), ""); - test_match (PARENS_TO_OPS ("((a))"), "b"); - test_match (PARENS_TO_OPS ("(a)(b)"), "ac"); - test_match (PARENS_TO_OPS ("(ab)*"), "acab"); - test_match (PARENS_TO_OPS ("(a*)*b"), "c"); - test_match (PARENS_TO_OPS ("(a*b)*"), "baa"); - test_match (PARENS_TO_OPS ("(a*b)*"), "baabc"); - test_match (PARENS_TO_OPS ("(a*b*)*"), "c"); - test_match (PARENS_TO_OPS ("((a*)*(b*)*)*"), "c"); - test_match (PARENS_TO_OPS ("(a*)*"), "ab"); - test_match (PARENS_TO_OPS ("((a*)*)*"), "ab"); - test_match (PARENS_TO_OPS ("((a*)*)*"), "b"); - test_match (PARENS_TO_OPS ("(ab*)*"), "abc"); - test_match (PARENS_TO_OPS ("(ab*)*c"), "abbad"); - test_match (PARENS_TO_OPS ("(a*c)*b"), "aacaacd"); - test_match (PARENS_TO_OPS ("(a*)"), "b"); - test_match (PARENS_TO_OPS ("((a*)b*)"), "c"); - - /* Expression anchoring. */ - TEST_SEARCH (PARENS_TO_OPS ("(^b)"), "ab", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("(a$)"), "ab", 0, 2); - - printf ("\nFinished POSIX grouping tests.\n"); -} diff --git a/gnu/lib/libregex/test/psx-interf.c b/gnu/lib/libregex/test/psx-interf.c deleted file mode 100644 index 4217cb20b432..000000000000 --- a/gnu/lib/libregex/test/psx-interf.c +++ /dev/null @@ -1,628 +0,0 @@ -/* psx-interf.c: test POSIX interface. */ - -#ifndef lint -static char rcsid[] = "$Id: psx-interf.c,v 1.2 1993/08/02 17:24:29 mycroft Exp $"; -#endif /* not lint */ - -#include -#include - -#include "test.h" - -#define ERROR_CODE_LENGTH 20 -#define TEST_ERRBUF_SIZE 15 - - -void test_compile (); - - -/* ANSWER should be at least ERROR_CODE_LENGTH long. */ - -static char * -get_error_string (error_code, answer) - int error_code; - char answer[]; -{ - switch (error_code) - { - case 0: strcpy (answer, "No error"); break; - case REG_NOMATCH: strcpy (answer, "REG_NOMATCH"); break; - case REG_BADPAT: strcpy (answer, "REG_BADPAT"); break; - case REG_EPAREN: strcpy (answer, "REG_EPAREN"); break; - case REG_ESPACE: strcpy (answer, "REG_ESPACE"); break; - case REG_ECOLLATE: strcpy (answer, "REG_ECOLLATE"); break; - case REG_ECTYPE: strcpy (answer, "REG_ECTYPE"); break; - case REG_EESCAPE: strcpy (answer, "REG_EESCAPE"); break; - case REG_ESUBREG: strcpy (answer, "REG_ESUBREG"); break; - case REG_EBRACK: strcpy (answer, "REG_EBRACK"); break; - case REG_EBRACE: strcpy (answer, "REG_EBRACE"); break; - case REG_BADBR: strcpy (answer, "REG_BADBR"); break; - case REG_ERANGE: strcpy (answer, "REG_ERANGE"); break; - case REG_BADRPT: strcpy (answer, "REG_BADRPT"); break; - case REG_EEND: strcpy (answer, "REG_EEND"); break; - default: strcpy (answer, "Bad error code"); - } - return answer; -} - - -/* I don't think we actually need to initialize all these things. - --karl */ - -void -init_pattern_buffer (pattern_buffer_ptr) - regex_t *pattern_buffer_ptr; -{ - pattern_buffer_ptr->buffer = NULL; - pattern_buffer_ptr->allocated = 0; - pattern_buffer_ptr->used = 0; - pattern_buffer_ptr->fastmap = NULL; - pattern_buffer_ptr->fastmap_accurate = 0; - pattern_buffer_ptr->translate = NULL; - pattern_buffer_ptr->can_be_null = 0; - pattern_buffer_ptr->re_nsub = 0; - pattern_buffer_ptr->no_sub = 0; - pattern_buffer_ptr->not_bol = 0; - pattern_buffer_ptr->not_eol = 0; -} - - -void -test_compile (valid_pattern, error_code_expected, pattern, - pattern_buffer_ptr, cflags) - unsigned valid_pattern; - int error_code_expected; - const char *pattern; - regex_t *pattern_buffer_ptr; - int cflags; -{ - int error_code_returned; - boolean error = false; - char errbuf[TEST_ERRBUF_SIZE]; - - init_pattern_buffer (pattern_buffer_ptr); - error_code_returned = regcomp (pattern_buffer_ptr, pattern, cflags); - - if (valid_pattern && error_code_returned) - { - printf ("\nShould have been a valid pattern but wasn't.\n"); - regerror (error_code_returned, pattern_buffer_ptr, errbuf, - TEST_ERRBUF_SIZE); - printf ("%s", errbuf); - error = true; - } - - if (!valid_pattern && !error_code_returned) - { - printf ("\n\nInvalid pattern compiled as valid:\n"); - error = true; - } - - if (error_code_returned != error_code_expected) - { - char expected_error_string[ERROR_CODE_LENGTH]; - char returned_error_string[ERROR_CODE_LENGTH]; - - get_error_string (error_code_expected, expected_error_string), - get_error_string (error_code_returned, returned_error_string); - - printf (" Expected error code %s but got `%s'.\n", - expected_error_string, returned_error_string); - - error = true; - } - - if (error) - print_pattern_info (pattern, pattern_buffer_ptr); -} - - -static void -test_nsub (sub_count, pattern, cflags) - unsigned sub_count; - char *pattern; - int cflags; - -{ - regex_t pattern_buffer; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - - if (pattern_buffer.re_nsub != sub_count) - { - printf ("\nShould have counted %d subexpressions but counted %d \ -instead.\n", sub_count, pattern_buffer.re_nsub); - } - - regfree (&pattern_buffer); -} - - -static void -test_regcomp () -{ - regex_t pattern_buffer; - int cflags = 0; - - - printf ("\nStarting regcomp tests.\n"); - - cflags = 0; - test_compile (0, REG_ESUBREG, "\\(a\\)\\2", &pattern_buffer, cflags); - test_compile (0, REG_EBRACE, "a\\{", &pattern_buffer, cflags); - test_compile (0, REG_BADBR, "a\\{-1\\}", &pattern_buffer, cflags); - test_compile (0, REG_EBRACE, "a\\{", &pattern_buffer, cflags); - test_compile (0, REG_EBRACE, "a\\{1", &pattern_buffer, cflags); - - cflags = REG_EXTENDED; - test_compile (0, REG_ECTYPE, "[[:alpo:]]", &pattern_buffer, cflags); - test_compile (0, REG_EESCAPE, "\\", &pattern_buffer, cflags); - test_compile (0, REG_EBRACK, "[a", &pattern_buffer, cflags); - test_compile (0, REG_EPAREN, "(", &pattern_buffer, cflags); - test_compile (0, REG_ERANGE, "[z-a]", &pattern_buffer, cflags); - - test_nsub (1, "(a)", cflags); - test_nsub (2, "((a))", cflags); - test_nsub (2, "(a)(b)", cflags); - - cflags = REG_EXTENDED | REG_NOSUB; - test_nsub (1, "(a)", cflags); - - regfree (&pattern_buffer); - - printf ("\nFinished regcomp tests.\n"); -} - - -static void -fill_pmatch (pmatch, start0, end0, start1, end1, start2, end2) - regmatch_t pmatch[]; - regoff_t start0, end0, start1, end1, start2, end2; -{ - pmatch[0].rm_so = start0; - pmatch[0].rm_eo = end0; - pmatch[1].rm_so = start1; - pmatch[1].rm_eo = end1; - pmatch[2].rm_so = start2; - pmatch[2].rm_eo = end2; -} - - -static void -test_pmatch (pattern, string, nmatch, pmatch, correct_pmatch, cflags) - char *pattern; - char *string; - unsigned nmatch; - regmatch_t pmatch[]; - regmatch_t correct_pmatch[]; - int cflags; -{ - regex_t pattern_buffer; - unsigned this_match; - int error_code_returned; - boolean found_nonmatch = false; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - error_code_returned = regexec (&pattern_buffer, string, nmatch, pmatch, 0); - - if (error_code_returned == REG_NOMATCH) - printf ("Matching failed in test_pmatch.\n"); - else - { - for (this_match = 0; this_match < nmatch; this_match++) - { - if (pmatch[this_match].rm_so != correct_pmatch[this_match].rm_so) - { - if (found_nonmatch == false) - printf ("\n"); - - printf ("Pmatch start %d wrong: was %d when should have \ -been %d.\n", this_match, pmatch[this_match].rm_so, - correct_pmatch[this_match].rm_so); - found_nonmatch = true; - } - if (pmatch[this_match].rm_eo != correct_pmatch[this_match].rm_eo) - { - if (found_nonmatch == false) - printf ("\n"); - - printf ("Pmatch end %d wrong: was %d when should have been \ -%d.\n", this_match, pmatch[this_match].rm_eo, - correct_pmatch[this_match].rm_eo); - found_nonmatch = true; - } - } - - if (found_nonmatch) - { - printf (" The number of pmatches requested was: %d.\n", nmatch); - printf (" The string to match was: `%s'.\n", string); - print_pattern_info (pattern, &pattern_buffer); - } - } /* error_code_returned == REG_NOMATCH */ - - regfree (&pattern_buffer); -} - - -static void -test_eflags (must_match_bol, must_match_eol, pattern, string, cflags, eflags) - boolean must_match_bol; - boolean must_match_eol; - char *pattern; - char *string; - int cflags; - int eflags; -{ - regex_t pattern_buffer; - int error_code_returned; - boolean was_error = false; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - error_code_returned = regexec (&pattern_buffer, string, 0, 0, eflags); - - if (error_code_returned == REG_NOMATCH) - { - /* If wasn't true that both 1) the anchored part of the pattern - had to match this string and 2) this string was a proper - substring... */ - - if (!( (must_match_bol && (eflags & REG_NOTBOL)) - || (must_match_eol && (eflags & REG_NOTEOL)) )) - { - printf ("\nEflags test failed: didn't match when should have.\n"); - was_error = true; - } - } - else /* We got a match. */ - { - /* If wasn't true that either 1) the anchored part of the pattern - didn't have to match this string or 2) this string wasn't a - proper substring... */ - - if ((must_match_bol == (eflags & REG_NOTBOL)) - || (must_match_eol == (eflags & REG_NOTEOL))) - { - printf ("\nEflags test failed: matched when shouldn't have.\n"); - was_error = true; - } - } - - if (was_error) - { - printf (" The string to match was: `%s'.\n", string); - print_pattern_info (pattern, &pattern_buffer); - - if (eflags & REG_NOTBOL) - printf (" The eflag REG_BOL was set.\n"); - if (eflags & REG_NOTEOL) - printf (" The eflag REG_EOL was set.\n"); - } - - regfree (&pattern_buffer); -} - - -static void -test_ignore_case (should_match, pattern, string, cflags) - boolean should_match; - char *pattern; - char *string; - int cflags; -{ - regex_t pattern_buffer; - int error_code_returned; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0); - - if (should_match && error_code_returned == REG_NOMATCH) - { - printf ("\nIgnore-case test failed:\n"); - printf (" The string to match was: `%s'.\n", string); - print_pattern_info (pattern, &pattern_buffer); - - if (cflags & REG_ICASE) - printf (" The cflag REG_ICASE was set.\n"); - } - - regfree (&pattern_buffer); -} - - -static void -test_newline (should_match, pattern, string, cflags) - boolean should_match; - char *pattern; - char *string; - int cflags; -{ - regex_t pattern_buffer; - int error_code_returned; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0); - - if (should_match && error_code_returned == REG_NOMATCH) - { - printf ("\nNewline test failed:\n"); - printf (" The string to match was: `%s'.\n", string); - print_pattern_info (pattern, &pattern_buffer); - - if (cflags & REG_NEWLINE) - printf (" The cflag REG_NEWLINE was set.\n"); - else - printf (" The cflag REG_NEWLINE wasn't set.\n"); - } - - regfree (&pattern_buffer); -} - - -static void -test_posix_match (should_match, pattern, string, cflags) - boolean should_match; - char *pattern; - char *string; - int cflags; -{ - regex_t pattern_buffer; - int error_code_returned; - boolean was_error = false; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0); - - if (should_match && error_code_returned == REG_NOMATCH) - { - printf ("\nShould have matched but didn't:\n"); - was_error = true; - } - else if (!should_match && error_code_returned != REG_NOMATCH) - { - printf ("\nShould not have matched but did:\n"); - was_error = true; - } - - if (was_error) - { - printf (" The string to match was: `%s'.\n", string); - print_pattern_info (pattern, &pattern_buffer); - } - - regfree (&pattern_buffer); -} - - -static void -test_regexec () -{ - regmatch_t pmatch[3]; - regmatch_t correct_pmatch[3]; - int cflags = 0; - int eflags = 0; - - printf ("\nStarting regexec tests.\n"); - - cflags = REG_NOSUB; /* shouldn't look at any of pmatch. */ - test_pmatch ("a", "a", 0, pmatch, correct_pmatch, cflags); - - /* Ask for less `pmatch'es than there are pattern subexpressions. - (Shouldn't look at pmatch[2]. */ - cflags = REG_EXTENDED; - fill_pmatch (correct_pmatch, 0, 1, 0, 1, 100, 101); - test_pmatch ("((a))", "a", 2, pmatch, correct_pmatch, cflags); - - /* Ask for same number of `pmatch'es as there are pattern subexpressions. */ - cflags = REG_EXTENDED; - fill_pmatch(correct_pmatch, 0, 1, 0, 1, -1, -1); - test_pmatch ("(a)", "a", 2, pmatch, correct_pmatch, cflags); - - /* Ask for more `pmatch'es than there are pattern subexpressions. */ - cflags = REG_EXTENDED; - fill_pmatch (correct_pmatch, 0, 1, -1, -1, -1, -1); - test_pmatch ("a", "a", 2, pmatch, correct_pmatch, cflags); - - eflags = REG_NOTBOL; - test_eflags (true, false, "^a", "a", cflags, eflags); - test_eflags (true, false, "(^a)", "a", cflags, eflags); - test_eflags (true, false, "a|^b", "b", cflags, eflags); - test_eflags (true, false, "^b|a", "b", cflags, eflags); - - eflags = REG_NOTEOL; - test_eflags (false, true, "a$", "a", cflags, eflags); - test_eflags (false, true, "(a$)", "a", cflags, eflags); - test_eflags (false, true, "a|b$", "b", cflags, eflags); - test_eflags (false, true, "b$|a", "b", cflags, eflags); - - eflags = REG_NOTBOL | REG_NOTEOL; - test_eflags (true, true, "^a$", "a", cflags, eflags); - test_eflags (true, true, "(^a$)", "a", cflags, eflags); - test_eflags (true, true, "a|(^b$)", "b", cflags, eflags); - test_eflags (true, true, "(^b$)|a", "b", cflags, eflags); - - cflags = REG_ICASE; - test_ignore_case (true, "a", "a", cflags); - test_ignore_case (true, "A", "A", cflags); - test_ignore_case (true, "A", "a", cflags); - test_ignore_case (true, "a", "A", cflags); - - test_ignore_case (true, "@", "@", cflags); - test_ignore_case (true, "\\[", "[", cflags); - test_ignore_case (true, "`", "`", cflags); - test_ignore_case (true, "{", "{", cflags); - - test_ignore_case (true, "[!-`]", "A", cflags); - test_ignore_case (true, "[!-`]", "a", cflags); - - cflags = 0; - test_ignore_case (false, "a", "a", cflags); - test_ignore_case (false, "A", "A", cflags); - test_ignore_case (false, "A", "a", cflags); - test_ignore_case (false, "a", "A", cflags); - - test_ignore_case (true, "@", "@", cflags); - test_ignore_case (true, "\\[", "[", cflags); - test_ignore_case (true, "`", "`", cflags); - test_ignore_case (true, "{", "{", cflags); - - test_ignore_case (true, "[!-`]", "A", cflags); - test_ignore_case (false, "[!-`]", "a", cflags); - - - /* Test newline stuff. */ - cflags = REG_EXTENDED | REG_NEWLINE; - test_newline (true, "\n", "\n", cflags); - test_newline (true, "a\n", "a\n", cflags); - test_newline (true, "\nb", "\nb", cflags); - test_newline (true, "a\nb", "a\nb", cflags); - - test_newline (false, ".", "\n", cflags); - test_newline (false, "[^a]", "\n", cflags); - - test_newline (true, "\n^a", "\na", cflags); - test_newline (true, "\n(^a|b)", "\na", cflags); - test_newline (true, "a$\n", "a\n", cflags); - test_newline (true, "(a$|b)\n", "a\n", cflags); - test_newline (true, "(a$|b|c)\n", "a\n", cflags); - test_newline (true, "((a$|b|c)$)\n", "a\n", cflags); - test_newline (true, "((a$|b|c)$)\n", "b\n", cflags); - test_newline (true, "(a$|b)\n|a\n", "a\n", cflags); - - test_newline (true, "^a", "\na", cflags); - test_newline (true, "a$", "a\n", cflags); - - /* Now test normal behavior. */ - cflags = REG_EXTENDED; - test_newline (true, "\n", "\n", cflags); - test_newline (true, "a\n", "a\n", cflags); - test_newline (true, "\nb", "\nb", cflags); - test_newline (true, "a\nb", "a\nb", cflags); - - test_newline (true, ".", "\n", cflags); - test_newline (true, "[^a]", "\n", cflags); - - test_newline (false, "\n^a", "\na", cflags); - test_newline (false, "a$\n", "a\n", cflags); - - test_newline (false, "^a", "\na", cflags); - test_newline (false, "a$", "a\n", cflags); - - - /* Test that matches whole string only. */ - cflags = 0; - test_posix_match (true, "a", "a", cflags); - - /* Tests that match substrings. */ - test_posix_match (true, "a", "ab", cflags); - test_posix_match (true, "b", "ab", cflags); - - /* Test that doesn't match. */ - test_posix_match (false, "a", "b", cflags); - - printf ("\nFinished regexec tests.\n"); -} - - -static void -test_error_code_message (error_code, expected_error_message) - int error_code; - char *expected_error_message; -{ - char returned_error_message[TEST_ERRBUF_SIZE]; - char error_code_string[ERROR_CODE_LENGTH]; - size_t expected_error_message_length = strlen (expected_error_message) + 1; - size_t returned_error_message_length = regerror (error_code, 0, - returned_error_message, - TEST_ERRBUF_SIZE); - - if (returned_error_message_length != expected_error_message_length) - { - printf ("\n\n Testing returned error codes, with expected error \ -message `%s':\n", expected_error_message); - - printf ("\n\n and returned error message `%s':\n", - returned_error_message); - printf (" should have returned a length of %d but returned %d.\n", - expected_error_message_length, returned_error_message_length); - } - - if (strncmp (expected_error_message, returned_error_message, - TEST_ERRBUF_SIZE - 1) != 0) - { - - get_error_string (error_code, error_code_string), - printf ("\n\n With error code %s (%d), expected error message:\n", - error_code_string, error_code); - - printf (" `%s'\n", expected_error_message); - printf (" but got:\n"); - printf (" `%s'\n", returned_error_message); - } -} - - -static void -test_error_code_allocation (error_code, expected_error_message) - int error_code; - char *expected_error_message; -{ - char *returned_error_message = NULL; - char error_code_string[ERROR_CODE_LENGTH]; - size_t returned_error_message_length = regerror (error_code, 0, - returned_error_message, - (size_t)0); - - returned_error_message = xmalloc (returned_error_message_length + 1); - - regerror (error_code, 0, returned_error_message, - returned_error_message_length); - - if (strcmp (expected_error_message, returned_error_message) != 0) - { - get_error_string (error_code, error_code_string), - - printf ("\n\n Testing error code allocation,\n"); - printf ("with error code %s (%d), expected error message:\n", - error_code_string, error_code); - printf (" `%s'\n", expected_error_message); - printf (" but got:\n"); - printf (" `%s'\n", returned_error_message); - } -} - - -static void -test_regerror () -{ - test_error_code_message (REG_NOMATCH, "No match"); - test_error_code_message (REG_BADPAT, "Invalid regular expression"); - test_error_code_message (REG_ECOLLATE, "Invalid collation character"); - test_error_code_message (REG_ECTYPE, "Invalid character class name"); - test_error_code_message (REG_EESCAPE, "Trailing backslash"); - test_error_code_message (REG_ESUBREG, "Invalid back reference"); - test_error_code_message (REG_EBRACK, "Unmatched [ or [^"); - test_error_code_message (REG_EPAREN, "Unmatched ( or \\("); - test_error_code_message (REG_EBRACE, "Unmatched \\{"); - test_error_code_message (REG_BADBR, "Invalid content of \\{\\}"); - test_error_code_message (REG_ERANGE, "Invalid range end"); - test_error_code_message (REG_ESPACE, "Memory exhausted"); - test_error_code_message (REG_BADRPT, "Invalid preceding regular expression"); - test_error_code_message (REG_EEND, "Premature end of regular expression"); - test_error_code_message (REG_ESIZE, "Regular expression too big"); - test_error_code_allocation (REG_ERPAREN, "Unmatched ) or \\)"); -} - - -void -test_posix_interface () -{ - printf ("\nStarting POSIX interface tests.\n"); - t = posix_interface_test; - - test_regcomp (); - test_regexec (); - test_regerror (); - - printf ("\nFinished POSIX interface tests.\n"); -} diff --git a/gnu/lib/libregex/test/psx-interv.c b/gnu/lib/libregex/test/psx-interv.c deleted file mode 100644 index f35ca16d58f7..000000000000 --- a/gnu/lib/libregex/test/psx-interv.c +++ /dev/null @@ -1,144 +0,0 @@ -/* psx-interv.c: test POSIX intervals, both basic and extended. */ - -#ifndef lint -static char rcsid[] = "$Id: psx-interv.c,v 1.2 1993/08/02 17:24:31 mycroft Exp $"; -#endif /* not lint */ - -#include "test.h" - -void -test_intervals () -{ - printf ("\nStarting POSIX interval tests.\n"); - - test_should_match = true; - /* Valid intervals. */ - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,2}b)*")), "abaab"); - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,2}b)*")), "a", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,2}b)*")), - "abaab", 0, 5, 2, 5, -1, -1); - - test_match (BRACES_TO_OPS ("a{0}"), ""); - test_fastmap (BRACES_TO_OPS ("a{0}"), "", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS ("a{0}"), "", 0, 0, -1, -1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS ("a{0}"), "x", 0, 0, -1, -1, -1, -1); - - test_match (BRACES_TO_OPS ("a{0,}"), ""); - test_match (BRACES_TO_OPS ("a{0,}"), "a"); - test_fastmap (BRACES_TO_OPS ("a{0,}"), "a", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS ("a{0,}"), "a", 0, 1, -1, -1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS ("a{0,}"), "xax", 0, 0, -1, -1, -1, -1); - - test_match (BRACES_TO_OPS ("a{1}"), "a"); - test_match (BRACES_TO_OPS ("a{1,}"), "a"); - test_match (BRACES_TO_OPS ("a{1,}"), "aa"); - test_match (BRACES_TO_OPS ("a{0,0}"), ""); - test_match (BRACES_TO_OPS ("a{0,1}"), ""); - test_match (BRACES_TO_OPS ("a{0,1}"), "a"); - test_match (BRACES_TO_OPS ("a{1,3}"), "a"); - test_match (BRACES_TO_OPS ("a{1,3}"), "aa"); - test_match (BRACES_TO_OPS ("a{1,3}"), "aaa"); - TEST_REGISTERS (BRACES_TO_OPS ("a{1,3}"), "aaa", 0, 3, -1, -1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS ("a{1,3}"), "xaaax", 1, 4, -1, -1, -1, -1); - - test_match (BRACES_TO_OPS ("a{0,3}b"), "b"); - test_match (BRACES_TO_OPS ("a{0,3}b"), "aaab"); - test_fastmap (BRACES_TO_OPS ("a{0,3}b"), "ab", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS ("a{0,3}b"), "b", 0, 1, -1, -1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS ("a{0,3}b"), "xbx", 1, 2, -1, -1, -1, -1); - - test_match (BRACES_TO_OPS ("a{1,3}b"), "ab"); - test_match (BRACES_TO_OPS ("a{1,3}b"), "aaab"); - test_match (BRACES_TO_OPS ("ab{1,3}c"), "abbbc"); - - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "b"); - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "ab", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "b", 0, 1, -1, -1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "ab", 0, 2, 0, 1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "xabx", 1, 3, 1, 2, -1, -1); - - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "ab"); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "aaab"); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "aaab", 0, 4, 2, 3, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "xaaabx", 1, 5, 3, 4, -1, -1); - - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){0,3}b")), "aaaab"); - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){0,3}b")), "ab", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){0,3}b")), "aaaab", 0, 5, 4, 4, -1, -1); - - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "b"); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "aaab"); - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "ab", 0, 0); - - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,1}ab")), "aaaab"); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,1}ab")), "aaaab", 0, 5, 0, 3, -1, -1); - - test_match (BRACES_TO_OPS (".{0,3}b"), "b"); - test_match (BRACES_TO_OPS (".{0,3}b"), "ab"); - - test_match (BRACES_TO_OPS ("[a]{0,3}b"), "b"); - test_match (BRACES_TO_OPS ("[a]{0,3}b"), "aaab"); - test_fastmap (BRACES_TO_OPS ("[a]{0,3}b"), "ab", 0, 0); - test_match (BRACES_TO_OPS ("[^a]{0,3}b"), "bcdb"); - test_match (BRACES_TO_OPS ("ab{0,3}c"), "abbbc"); - test_match (BRACES_TO_OPS ("[[:digit:]]{0,3}d"), "123d"); - test_fastmap (BRACES_TO_OPS ("[[:digit:]]{0,3}d"), "0123456789d", 0, 0); - - test_match (BRACES_TO_OPS ("\\*{0,3}a"), "***a"); - test_match (BRACES_TO_OPS (".{0,3}b"), "aaab"); - test_match (BRACES_TO_OPS ("a{0,3}a"), "aaa"); - /* Backtracking. */ - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,})*a")), "a", 0, 0); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,})*a")), "a"); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,})*a")), "a", 0, 1, -1, -1, -1, -1); - - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a{2,})*aa")), "aa", 0, 0); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a{2,})*aa")), "aa"); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a{2,})*aa")), "aa", 0, 2, -1, -1, -1, -1); - - test_match (BRACES_TO_OPS ("a{2}*"), ""); - test_match (BRACES_TO_OPS ("a{2}*"), "aa"); - - test_match (BRACES_TO_OPS ("a{1}*"), ""); - test_match (BRACES_TO_OPS ("a{1}*"), "a"); - test_match (BRACES_TO_OPS ("a{1}*"), "aa"); - - test_match (BRACES_TO_OPS ("a{1}{1}"), "a"); - - test_match (BRACES_TO_OPS ("a{1}{1}{1}"), "a"); - test_match (BRACES_TO_OPS ("a{1}{1}{2}"), "aa"); - - test_match (BRACES_TO_OPS ("a{1}{1}*"), ""); - test_match (BRACES_TO_OPS ("a{1}{1}*"), "a"); - test_match (BRACES_TO_OPS ("a{1}{1}*"), "aa"); - test_match (BRACES_TO_OPS ("a{1}{1}*"), "aaa"); - - test_match (BRACES_TO_OPS ("a{1}{2}"), "aa"); - test_match (BRACES_TO_OPS ("a{2}{1}"), "aa"); - - - test_should_match = false; - - test_match (BRACES_TO_OPS ("a{0}"), "a"); - test_match (BRACES_TO_OPS ("a{0,}"), "b"); - test_match (BRACES_TO_OPS ("a{1}"), ""); - test_match (BRACES_TO_OPS ("a{1}"), "aa"); - test_match (BRACES_TO_OPS ("a{1,}"), ""); - test_match (BRACES_TO_OPS ("a{1,}"), "b"); - test_match (BRACES_TO_OPS ("a{0,0}"), "a"); - test_match (BRACES_TO_OPS ("a{0,1}"), "aa"); - test_match (BRACES_TO_OPS ("a{0,1}"), "b"); - test_match (BRACES_TO_OPS ("a{1,3}"), ""); - test_match (BRACES_TO_OPS ("a{1,3}"), "aaaa"); - test_match (BRACES_TO_OPS ("a{1,3}"), "b"); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "aaaab"); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "bb"); - test_match (BRACES_TO_OPS ("[a]{0,3}"), "aaaa"); - test_match (BRACES_TO_OPS ("[^a]{0,3}b"), "ab"); - test_match (BRACES_TO_OPS ("ab{0,3}c"), "abababc"); - test_match (BRACES_TO_OPS ("[:alpha:]{0,3}d"), "123d"); - test_match (BRACES_TO_OPS ("\\^{1,3}a"), "a"); - test_match (BRACES_TO_OPS (".{0,3}b"), "aaaab"); - - printf ("\nFinished POSIX interval tests.\n"); -} diff --git a/gnu/lib/libregex/test/regexcpp.sed b/gnu/lib/libregex/test/regexcpp.sed deleted file mode 100644 index 082c1360814f..000000000000 --- a/gnu/lib/libregex/test/regexcpp.sed +++ /dev/null @@ -1,8 +0,0 @@ -/;..*$/s/;/;\ -/g -/{ .*$/s/{/{\ -/g -/ \?[^'] /s/?/?\ -/g -/ : /s/:/:\ -/g diff --git a/gnu/lib/libregex/test/syntax.skel b/gnu/lib/libregex/test/syntax.skel deleted file mode 100644 index a3fbf64c5983..000000000000 --- a/gnu/lib/libregex/test/syntax.skel +++ /dev/null @@ -1,74 +0,0 @@ -/* Print which syntax bits are set. */ - -#include -#include -#include "regex.h" - -/* It's coincidental that these two are currently the same. */ -#define LONGEST_BIT_NAME "RE_UNMATCHED_RIGHT_PAREN_ORD" -#define LAST_BIT RE_UNMATCHED_RIGHT_PAREN_ORD - -/* Sum of above, when printed. Assigned in main. */ -static unsigned longest; - - -static void -test_bit (syntax, bit, name) - reg_syntax_t syntax; - unsigned bit; - char *name; -{ - char padding[100], test_str[100]; - int padding_count; - - sprintf (test_str, "%s (%d=0x%x)", name, bit, bit); - padding_count = longest - strlen (test_str); - - padding[padding_count] = 0; - while (padding_count--) - { - padding[padding_count] = ' '; - } - - printf ("%s%s (%d=0x%x): %c\n", - name, padding, bit, bit, syntax & bit ? 'y' : 'n'); -} - - -/* Macro to abbreviate the constant arguments. */ -#define TEST_BIT(bit) test_bit (syntax, bit, #bit) - -int -main (argc, argv) - int argc; - char *argv[]; -{ - reg_syntax_t syntax; - char syntax_str[1000], test_str[100]; - - switch (argc) - { - case 1: - printf ("Syntax? "); - scanf ("%s", syntax_str); - break; - - case 2: - strcpy (syntax_str, argv[1]); - break; - - default: - fprintf (stderr, "Usage: syntax [syntax].\n"); - exit (1); - } - - sscanf (syntax_str, "%i", &syntax); - - /* Figure out the longest name, so we can align the output nicely. */ - sprintf (test_str, "%s (%d=0x%x)", LONGEST_BIT_NAME, LAST_BIT, LAST_BIT); - longest = strlen (test_str); - - /* [[[replace with bit tests]]] */ - - return 0; -} diff --git a/gnu/lib/libregex/test/test.c b/gnu/lib/libregex/test/test.c deleted file mode 100644 index 26926b0f6e48..000000000000 --- a/gnu/lib/libregex/test/test.c +++ /dev/null @@ -1,786 +0,0 @@ -/* test.c: testing routines for regex.c. */ - -#ifndef lint -static char rcsid[] = "$Id: test.c,v 1.2 1993/08/02 17:24:32 mycroft Exp $"; -#endif /* not lint */ - -#include - -#ifdef STDC_HEADERS -#include -#else -char *malloc (); -char *realloc (); -#endif - -/* Just to be complete, we make both the system V/ANSI and the BSD - versions of the string functions available. */ -#if USG || STDC_HEADERS -#include -#define index strchr -#define rindex strrchr -#define bcmp(s1, s2, len) memcmp ((s1), (s2), (len)) -#define bcopy(from, to, len) memcpy ((to), (from), (len)) -#define bzero(s, len) memset ((s), 0, (len)) -#else -#include -#define strchr index -#define strrchr rindex -#ifndef NEED_MEMORY_H -#define memcmp(s1, s2, n) bcmp ((s1), (s2), (n)) -#define memcpy(to, from, len) bcopy ((from), (to), (len)) -#endif -extern char *strtok (); -extern char *strstr (); -#endif /* not USG or STDC_HEADERS */ - -/* SunOS 4.1 declares memchr in , not . I don't - understand why. */ -#if NEED_MEMORY_H -#include -#endif - -#include "test.h" - -#define BYTEWIDTH 8 - -extern void print_partial_compiled_pattern (); -extern void print_compiled_pattern (); -extern void print_double_string (); - -/* If nonzero, the results of every test are displayed. */ -boolean verbose = false; - -/* If nonzero, don't do register testing. */ -boolean omit_register_tests = true; - -/* Says whether the current test should match or fail to match. */ -boolean test_should_match; - - -static void -set_all_registers (start0, end0, start1, end1, - start2, end2, start3, end3, - start4, end4, start5, end5, - start6, end6, start7, end7, - start8, end8, start9, end9, regs) - - int start0; int end0; int start1; int end1; - int start2; int end2; int start3; int end3; - int start4; int end4; int start5; int end5; - int start6; int end6; int start7; int end7; - int start8; int end8; int start9; int end9; - struct re_registers *regs; - - { - unsigned r; - - regs->start[0] = start0; regs->end[0] = end0; - regs->start[1] = start1; regs->end[1] = end1; - regs->start[2] = start2; regs->end[2] = end2; - regs->start[3] = start3; regs->end[3] = end3; - regs->start[4] = start4; regs->end[4] = end4; - regs->start[5] = start5; regs->end[5] = end5; - regs->start[6] = start6; regs->end[6] = end6; - regs->start[7] = start7; regs->end[7] = end7; - regs->start[8] = start8; regs->end[8] = end8; - regs->start[9] = start9; regs->end[9] = end9; - for (r = 10; r < regs->num_regs; r++) - { - regs->start[r] = -1; - regs->end[r] = -1; - } - } - - - -/* Return the concatenation of S1 and S2. This would be a prime place - to use varargs. */ - -char * -concat (s1, s2) - char *s1; - char *s2; -{ - char *answer = xmalloc (strlen (s1) + strlen (s2) + 1); - - strcpy (answer, s1); - strcat (answer, s2); - - return answer; -} - - -#define OK_TO_SEARCH (nonconst_buf.fastmap_accurate && (str1 || str2)) - -/* We ignore the `can_be_null' argument. Should just be removed. */ - -void -general_test (pattern_should_be_valid, match_whole_string, - pat, str1, str2, start, range, end, correct_fastmap, - correct_regs, can_be_null) - unsigned pattern_should_be_valid; - unsigned match_whole_string; - const char *pat; - char *str1, *str2; - int start, range, end; - char *correct_fastmap; - struct re_registers *correct_regs; - int can_be_null; -{ - struct re_pattern_buffer nonconst_buf; - struct re_pattern_buffer old_buf; - struct re_registers regs; - const char *r; - char fastmap[1 << BYTEWIDTH]; - unsigned *regs_correct = NULL; - unsigned all_regs_correct = 1; - boolean fastmap_internal_error = false; - unsigned match = 0; - unsigned match_1 = 0; - unsigned match_2 = 0; - unsigned invalid_pattern = 0; - boolean internal_error_1 = false; - boolean internal_error_2 = false; - - - nonconst_buf.allocated = 8; - nonconst_buf.buffer = xmalloc (nonconst_buf.allocated); - nonconst_buf.fastmap = fastmap; - nonconst_buf.translate = 0; - - assert (pat != NULL); - r = re_compile_pattern (pat, strlen (pat), &nonconst_buf); - - /* Kludge: if we are doing POSIX testing, we really should have - called regcomp, not re_compile_pattern. As it happens, the only - way in which it matters is that re_compile_pattern sets the - newline/anchor field for matching (part of what happens when - REG_NEWLINE is given to regcomp). We have to undo that for POSIX - matching. */ - if (t == posix_basic_test || t == posix_extended_test) - nonconst_buf.newline_anchor = 0; - - invalid_pattern = r != NULL; - - if (!r) - { - int r; - - if (!pattern_should_be_valid) - printf ("\nShould have been an invalid pattern but wasn't:\n"); - else - { - fastmap_internal_error = (re_compile_fastmap (&nonconst_buf) == -2); - - if (correct_fastmap) - nonconst_buf.fastmap_accurate = - memcmp (nonconst_buf.fastmap, correct_fastmap, 1 << BYTEWIDTH) - == 0; - - if (OK_TO_SEARCH) - { - old_buf = nonconst_buf; - old_buf.buffer = (unsigned char *) xmalloc (nonconst_buf.used); - memcpy (old_buf.buffer, nonconst_buf.buffer, nonconst_buf.used); - - /* If only one string is null, call re_match or re_search, - which is what the user would probably do. */ - if (str1 == NULL && str2 != NULL - || str2 == NULL && str1 != NULL) - { - char *the_str = str1 == NULL ? str2 : str1; - - match_1 - = match_whole_string - ? (r = re_match (&nonconst_buf, the_str, - strlen (the_str), start, ®s)) - == strlen (the_str) - : (r = re_search (&nonconst_buf, - the_str, strlen (the_str), - start, range, ®s)) - >= 0; - - if (r == -2) - internal_error_1 = true; - } - else - match_1 = 1; - - /* Also call with re_match_2 or re_search_2, as they might - do this. (Also can check calling with either string1 - or string2 or both null.) */ - if (match_whole_string) - { - r = re_match_2 (&nonconst_buf, - str1, SAFE_STRLEN (str1), - str2, SAFE_STRLEN (str2), - start, ®s, end); - match_2 = r == SAFE_STRLEN (str1) + SAFE_STRLEN (str2); - } - else - { - r = re_search_2 (&nonconst_buf, - str1, SAFE_STRLEN (str1), - str2, SAFE_STRLEN (str2), - start, range, ®s, end); - match_2 = r >= 0; - } - - if (r == -2) - internal_error_2 = true; - - match = match_1 & match_2; - - if (correct_regs) - { - unsigned reg; - if (regs_correct != NULL) - free (regs_correct); - - regs_correct - = (unsigned *) xmalloc (regs.num_regs * sizeof (unsigned)); - - for (reg = 0; - reg < regs.num_regs && reg < correct_regs->num_regs; - reg++) - { - regs_correct[reg] - = (regs.start[reg] == correct_regs->start[reg] - && regs.end[reg] == correct_regs->end[reg]) -#ifdef EMPTY_REGS_CONFUSED - /* There is confusion in the standard about - the registers in some patterns which can - match either the empty string or not match. - For example, in `((a*))*' against the empty - string, the two registers can either match - the empty string (be 0/0), or not match - (because of the outer *) (be -1/-1). (Or - one can do one and one can do the other.) */ - || (regs.start[reg] == -1 && regs.end[reg] == -1 - && correct_regs->start[reg] - == correct_regs->end[reg]) -#endif - ; - - all_regs_correct &= regs_correct[reg]; - } - } - } /* OK_TO_SEARCH */ - } - } - - if (fastmap_internal_error) - printf ("\n\nInternal error in re_compile_fastmap:"); - - if (internal_error_1) - { - if (!fastmap_internal_error) - printf ("\n"); - - printf ("\nInternal error in re_match or re_search:"); - } - - if (internal_error_2) - { - if (!internal_error_1) - printf ("\n"); - - printf ("\nInternal error in re_match_2 or re_search_2:"); - } - - if ((OK_TO_SEARCH && ((match && !test_should_match) - || (!match && test_should_match)) - || (correct_regs && !all_regs_correct)) - || !nonconst_buf.fastmap_accurate - || invalid_pattern - || !pattern_should_be_valid - || internal_error_1 || internal_error_2 - || verbose) - { - if (OK_TO_SEARCH && match && !test_should_match) - { - printf ("\n\nMatched but shouldn't have:\n"); - if (match_1) - printf ("The single match/search succeeded.\n"); - - if (match_2) - printf ("The double match/search succeeded.\n"); - } - else if (OK_TO_SEARCH && !match && test_should_match) - { - printf ("\n\nDidn't match but should have:\n"); - if (!match_1) - printf ("The single match/search failed.\n"); - - if (!match_2) - printf ("The double match/search failed.\n"); - } - else if (invalid_pattern && pattern_should_be_valid) - printf ("\n\nInvalid pattern (%s):\n", r); - else if (!nonconst_buf.fastmap_accurate && pattern_should_be_valid) - printf ("\n\nIncorrect fastmap:\n"); - else if (OK_TO_SEARCH && correct_regs && !all_regs_correct) - printf ("\n\nNot all registers were correct:\n"); - else if (verbose) - printf ("\n\nTest was OK:\n"); - - - if ((!(invalid_pattern && !pattern_should_be_valid)) || verbose) - printf (" Pattern: `%s'.\n", pat); - - if (pattern_should_be_valid || verbose - || internal_error_1 || internal_error_2) - { - printf(" Strings: "); - printf ("`%s' and ", str1 == NULL ? "NULL" : str1); - printf ("`%s'.\n", str2 == NULL ? "NULL" : str2); - - if ((OK_TO_SEARCH || verbose || internal_error_1 || internal_error_2) - && !invalid_pattern) - { - if (memcmp (old_buf.buffer, nonconst_buf.buffer, - nonconst_buf.used) != 0 - && !invalid_pattern) - { - printf(" (%s)\n", r ? r : "Valid regular expression"); - printf ("\n Compiled pattern before matching: "); - print_compiled_pattern (&old_buf); - printf ("\n Compiled pattern after matching: "); - } - else - printf ("\n Compiled pattern: "); - - print_compiled_pattern (&nonconst_buf); - } - - if (correct_fastmap && (!nonconst_buf.fastmap_accurate || verbose)) - { - printf ("\n The fastmap should have been: "); - print_fastmap (correct_fastmap); - - printf ("\n Fastmap: "); - print_fastmap (fastmap); - - printf ("\n Compiled pattern before matching: "); - print_compiled_pattern (&nonconst_buf); - } - - if ((!all_regs_correct || verbose) && correct_regs) - { - unsigned this_reg; - printf ("\n Incorrect registers:"); - - for (this_reg = 0; this_reg < regs.num_regs; this_reg++) - { - if (!regs_correct[this_reg]) - { - printf ("\n Register %d's start was %2d. ", this_reg, - regs.start[this_reg]); - printf ("\tIt should have been %d.\n", - correct_regs->start[this_reg]); - printf (" Register %d's end was %2d. ", this_reg, - regs.end[this_reg]); - printf ("\tIt should have been %d.\n", - correct_regs->end[this_reg]); - } - } - } - } - } - - if (nonconst_buf.buffer != NULL) - free (nonconst_buf.buffer); - - if (OK_TO_SEARCH) - { - free (old_buf.buffer); - - if (correct_regs) - free (regs_correct); - - } - - nonconst_buf.buffer = old_buf.buffer = NULL; - regs_correct = NULL; - regs.start = regs.end = NULL; - -} /* general_test */ - - -void -test_search_return (match_start_wanted, pattern, string) - int match_start_wanted; - const char *pattern; - char *string; -{ - struct re_pattern_buffer buf; - char fastmap[1 << BYTEWIDTH]; - const char *compile_return; - int match_start; - static num_times_called = 0; - - num_times_called++; - buf.allocated = 1; - buf.buffer = xmalloc (buf.allocated); - - assert (pattern != NULL); - buf.translate = 0; - compile_return = re_compile_pattern (pattern, strlen (pattern), &buf); - - if (compile_return) - { - printf ("\n\nInvalid pattern in test_match_start:\n"); - printf ("%s\n", compile_return); - } - else - { - buf.fastmap = fastmap; - match_start = re_search (&buf, string, strlen (string), - 0, strlen (string), 0); - - if (match_start != match_start_wanted) - printf ("\nWanted search to start at %d but started at %d.\n", - match_start, match_start_wanted); - } - free (buf.buffer); - buf.buffer = NULL; -} - - -#define SET_FASTMAP() \ - { \ - unsigned this_char; \ - \ - memset (correct_fastmap, invert, (1 << BYTEWIDTH)); \ - \ - for (this_char = 0; this_char < strlen (fastmap_string); this_char++)\ - correct_fastmap[fastmap_string[this_char]] = !invert; \ - correct_fastmap['\n'] = match_newline; \ - } - - -void -test_fastmap (pat, fastmap_string, invert, match_newline) - const char *pat; - char *fastmap_string; - unsigned invert; - unsigned match_newline; -{ - char correct_fastmap[(1 << BYTEWIDTH)]; - - SET_FASTMAP (); - general_test (1, 0, pat, NULL, NULL, -1, 0, -1, correct_fastmap, 0, -1); -} - - -void -test_fastmap_search (pat, str, fastmap_string, invert, match_newline, - can_be_null, start0, end0) - const char *pat; - char *str; - char *fastmap_string; - unsigned invert; - unsigned match_newline; - int can_be_null; - int start0; - int end0; -{ - char correct_fastmap[(1 << BYTEWIDTH)]; - struct re_registers correct_regs; - - correct_regs.num_regs = RE_NREGS; - correct_regs.start = (int *) xmalloc (RE_NREGS * sizeof (int)); - correct_regs.end = (int *) xmalloc (RE_NREGS * sizeof (int)); - - set_all_registers (start0, end0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, &correct_regs); - SET_FASTMAP (); - general_test (1, 0, pat, str, NULL, 0, SAFE_STRLEN (str), SAFE_STRLEN (str), - correct_fastmap, &correct_regs, can_be_null); - - free (correct_regs.start); - free (correct_regs.end); -} - - - - -void -test_all_registers (pat, str1, str2, - start0, end0, start1, end1, - start2, end2, start3, end3, - start4, end4, start5, end5, - start6, end6, start7, end7, - start8, end8, start9, end9) - char *pat; char *str1; char *str2; - int start0; int end0; int start1; int end1; - int start2; int end2; int start3; int end3; - int start4; int end4; int start5; int end5; - int start6; int end6; int start7; int end7; - int start8; int end8; int start9; int end9; -{ - struct re_registers correct_regs; - - if (omit_register_tests) return; - - correct_regs.num_regs = RE_NREGS; - correct_regs.start = (int *) xmalloc (RE_NREGS * sizeof (int)); - correct_regs.end = (int *) xmalloc (RE_NREGS * sizeof (int)); - - set_all_registers (start0, end0, start1, end1, start2, end2, start3, end3, - start4, end4, start5, end5, start6, end6, start7, end7, - start8, end8, start9, end9, &correct_regs); - - general_test (1, 0, pat, str1, str2, 0, - SAFE_STRLEN (str1) + SAFE_STRLEN (str2), - SAFE_STRLEN (str1) + SAFE_STRLEN (str2), - NULL, &correct_regs, -1); - - free (correct_regs.start); - free (correct_regs.end); -} - - -void -invalid_pattern (error_code_expected, pattern) - int error_code_expected; - char *pattern; -{ - regex_t pattern_buffer; - int cflags - = re_syntax_options == RE_SYNTAX_POSIX_EXTENDED - || re_syntax_options == RE_SYNTAX_POSIX_MINIMAL_EXTENDED - ? REG_EXTENDED : 0; - - test_compile (0, error_code_expected, pattern, &pattern_buffer, cflags); -} - - -void -valid_pattern (pattern) - char *pattern; -{ - regex_t pattern_buffer; - int cflags - = re_syntax_options == RE_SYNTAX_POSIX_EXTENDED - || re_syntax_options == RE_SYNTAX_POSIX_MINIMAL_EXTENDED - ? REG_EXTENDED : 0; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); -} - - -char * -delimiters_to_ops (source, left_delimiter, right_delimiter) - char *source; - char left_delimiter; - char right_delimiter; -{ - static char *answer = NULL; - char *tmp = NULL; - boolean double_size = false; - unsigned source_char; - unsigned answer_char = 0; - - assert (source != NULL); - - switch (left_delimiter) - { - case '(': if (!(re_syntax_options & RE_NO_BK_PARENS)) - double_size = true; - break; - case '{': if (!(re_syntax_options & RE_NO_BK_BRACES)) - double_size = true; - break; - default: printf ("Found strange delimiter %c in delimiter_to_ops.\n", - left_delimiter); - printf ("The source was `%s'\n", source); - exit (0); - } - - if (answer == source) - { - tmp = (char *) xmalloc (strlen (source) + 1); - strcpy (tmp, source); - source = tmp; - } - - if (answer) - { - free (answer); - answer = NULL; - } - - answer = (char *) xmalloc ((double_size - ? strlen (source) << 1 - : strlen (source)) - + 1); - if (!double_size) - strcpy (answer, source); - else - { - for (source_char = 0; source_char < strlen (source); source_char++) - { - if (source[source_char] == left_delimiter - || source[source_char] == right_delimiter) - answer[answer_char++] = '\\'; - - answer[answer_char++] = source[source_char]; - } - answer[answer_char] = 0; - } - - return answer; -} - - -void -print_pattern_info (pattern, pattern_buffer_ptr) - const char *pattern; - regex_t *pattern_buffer_ptr; -{ - printf (" Pattern: `%s'.\n", pattern); - printf (" Compiled pattern: "); - print_compiled_pattern (pattern_buffer_ptr); -} - - -void -valid_nonposix_pattern (pattern) - char *pattern; -{ - struct re_pattern_buffer nonconst_buf; - - nonconst_buf.allocated = 0; - nonconst_buf.buffer = NULL; - nonconst_buf.translate = NULL; - - assert (pattern != NULL); - - if (re_compile_pattern (pattern, strlen (pattern), &nonconst_buf)) - { - printf ("Couldn't compile the pattern.\n"); - print_pattern_info (pattern, &nonconst_buf); - } -} - - -void -compile_and_print_pattern (pattern) - char *pattern; -{ - struct re_pattern_buffer nonconst_buf; - - nonconst_buf.allocated = 0; - nonconst_buf.buffer = NULL; - - if (re_compile_pattern (pattern, strlen (pattern), &nonconst_buf)) - printf ("Couldn't compile the pattern.\n"); - - print_pattern_info (pattern, &nonconst_buf); -} - - -void -test_case_fold (pattern, string) - const char *pattern; - char* string; -{ - struct re_pattern_buffer nonconst_buf; - const char *ret; - - init_pattern_buffer (&nonconst_buf); - nonconst_buf.translate = upcase; - - assert (pattern != NULL); - ret = re_compile_pattern (pattern, strlen (pattern), &nonconst_buf); - - if (ret) - { - printf ("\nShould have been a valid pattern but wasn't.\n"); - print_pattern_info (pattern, &nonconst_buf); - } - else - { - if (test_should_match - && re_match (&nonconst_buf, string, strlen (string), 0, 0) - != strlen (string)) - { - printf ("Match failed for case fold.\n"); - printf (" Pattern: `%s'.\n", pattern); - printf (" String: `%s'.\n", string == NULL ? "NULL" : string); - } - } -} - - -void -test_match_n_times (n, pattern, string) - unsigned n; - char* pattern; - char* string; -{ - struct re_pattern_buffer buf; - const char *r; - unsigned match = 0; - unsigned this_match; - - buf.allocated = 0; - buf.buffer = NULL; - buf.translate = 0; - - assert (pattern != NULL); - - r = re_compile_pattern (pattern, strlen (pattern), &buf); - if (r) - { - printf ("Didn't compile.\n"); - printf (" Pattern: %s.\n", pattern); - } - else - { - for (this_match = 1; this_match <= n; this_match++) - match = (re_match (&buf, string, strlen (string), - 0, 0) - == strlen (string)); - - if (match && !test_should_match) - printf ("\n\nMatched but shouldn't have:\n"); - else if (!match && test_should_match) - printf ("\n\nDidn't match but should have:\n"); - - if ((match && !test_should_match) || (!match && test_should_match)) - { - printf(" The string to match was: "); - if (string) - printf ("`%s' and ", string); - else - printf ("`'"); - - printf (" Pattern: %s.\n", pattern); - printf (" Compiled pattern: %s.\n", pattern); - print_compiled_pattern (&buf); - } - } -} - - -void -test_match_2 (pat, str1, str2) - const char *pat; - char *str1; - char *str2; -{ - general_test (1, 1, pat, str1, str2, 0, 1, - SAFE_STRLEN (str1) + SAFE_STRLEN (str2), NULL, 0, -1); -} - -void -test_match (pat, str) - const char *pat; - char *str; -{ - test_match_2 (pat, str, NULL); - test_match_2 (pat, NULL, str); -} diff --git a/gnu/lib/libregex/test/test.h b/gnu/lib/libregex/test/test.h deleted file mode 100644 index e2ab1e93516b..000000000000 --- a/gnu/lib/libregex/test/test.h +++ /dev/null @@ -1,141 +0,0 @@ -/* $Id: test.h,v 1.2 1993/08/02 17:24:33 mycroft Exp $ */ - -#ifndef TEST_H -#define TEST_H - -#include -#include - -#include -#include "regex.h" - - -/* A strlen that works even on a null pointer. */ -#define SAFE_STRLEN(s) (s == NULL ? 0 : strlen (s)) - -typedef enum { false = 0, true = 1 } boolean; - -extern boolean test_should_match; -extern boolean omit_register_tests; -extern void *xmalloc (); - -/* Defined in upcase.c. */ -extern char upcase[]; - -typedef enum -{ - all_test, - other_test, - posix_basic_test, - posix_extended_test, - posix_interface_test, - regress_test -} test_type; - -extern test_type t; - - -#if __STDC__ - -extern char *concat (char *, char *); - -extern void general_test (unsigned pattern_should_be_valid, - unsigned match_whole_string, - const char *pat, char *str1, char *str2, - int start, int range, int end, - char *correct_fastmap, - struct re_registers *correct_regs, int can_be_null); - - -extern void init_pattern_buffer (regex_t *pattern_buffer_ptr); - -extern void test_compile (unsigned valid_pattern, int error_code_expected, - const char *pattern, regex_t *pattern_buffer_ptr, - int cflags); - -extern char *delimiter_to_ops (char *source, char left_delimiter, - char right_delimiter); - - -extern void test_search_return (int, const char *, char *); - -extern void test_berk_search (const char *pattern, char *string); - -extern void test_fastmap (const char *pat, char *fastmap_string, unsigned invert, - unsigned match_newline); - -extern void test_fastmap_search (const char *pat, char *str, char *fastmap_string, - unsigned invert, unsigned match_newline, - int can_be_null, int start0, int end0); - -extern void test_all_registers (char *pat, char *str1, char *str2, - int start0, int end0, int start1, int end1, - int start2, int end2, int start3, int end3, - int start4, int end4, int start5, int end5, - int start6, int end6, int start7, int end7, - int start8, int end8, int start9, int end9); - -extern void print_pattern_info (const char *pattern, regex_t *pattern_buffer_ptr); -extern void compile_and_print_pattern (char *pattern); - -extern void test_case_fold (const char *pattern, char* string); - -extern void test_posix_generic (); - -extern void test_grouping (); - -extern void invalid_pattern (int error_code_expected, char *pattern); -extern void valid_nonposix_pattern (char *pattern); -extern void valid_pattern (char *pattern); - -extern void test_match_2 (const char *pat, char *str1, char *str2); -extern void test_match (const char *pat, char *str); - -#endif /* __STDC__ */ - - -#define TEST_REGISTERS_2(pat, str1, str2, start0, end0, start1, end1, start2, end2)\ - if (!omit_register_tests) \ - test_all_registers (pat, str1, str2, start0, end0, start1, end1, \ - start2, end2, -1, -1, -1, -1, -1, -1, -1, -1,\ - -1, -1, -1, -1, -1, -1) \ - - -#define TEST_REGISTERS(pat, str, start0, end0, start1, end1, start2, end2) \ - TEST_REGISTERS_2 (pat, str, NULL, start0, end0, start1, end1, start2, end2)\ - -#define BRACES_TO_OPS(string) ((char *) delimiters_to_ops (string, '{', '}')) -#define PARENS_TO_OPS(string) ((char *) delimiters_to_ops (string, '(', ')')) - -#define INVALID_PATTERN(pat) \ - general_test (0, 0, pat, NULL, NULL, -1, 0, -1, NULL, 0, -1) - - -#define MATCH_SELF(p) test_match (p, p) - -#define TEST_POSITIONED_MATCH(pat, str, start) \ - general_test (1, 0, pat, str, NULL, start, 1, SAFE_STRLEN (str), \ - NULL, 0, -1) - -#define TEST_TRUNCATED_MATCH(pat, str, end) \ - general_test (1, 0, pat, str, NULL, 0, 1, end, NULL, 0, -1) - -#define TEST_SEARCH_2(pat, str1, str2, start, range, one_past_end) \ - general_test (1, 0, pat, str1, str2, start, range, one_past_end, \ - NULL, 0, -1) - -#define TEST_SEARCH(pat, str, start, range) \ - { \ - TEST_SEARCH_2 (pat, str, NULL, start, range, SAFE_STRLEN (str)); \ - TEST_SEARCH_2 (pat, NULL, str, start, range, SAFE_STRLEN (str)); \ - } - -#endif /* TEST_H */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/libregex/test/tregress.c b/gnu/lib/libregex/test/tregress.c deleted file mode 100644 index 68bac4bda0bd..000000000000 --- a/gnu/lib/libregex/test/tregress.c +++ /dev/null @@ -1,468 +0,0 @@ -/* tregress.c: reported bugs. The `t' just makes the filename not have - a common prefix with `regex.c', so completion works better. */ - -#ifndef lint -static char rcsid[] = "$Id: tregress.c,v 1.2 1993/08/02 17:24:34 mycroft Exp $"; -#endif /* not lint */ - -#include "test.h" - - -boolean pause_at_error = true; - -char * -itoa (i) - int i; -{ - char *a = xmalloc (21); /* sign + 19 digits (enough for 64 bits) + null */ - - sprintf (a, "%d", i); - return a; -} - - -static void -simple_fail (routine, pat, buf, str, ret) - const char *routine; - const char *pat; - struct re_pattern_buffer *buf; - const char *str; - char *ret; -{ - fprintf (stderr, "Failed %s (return = %s).\n", routine, ret); - if (str && *str) fprintf (stderr, " String = %s\n", str); - fprintf (stderr, " Pattern = %s\n", pat); - print_compiled_pattern (buf); - - if (pause_at_error) - { - fprintf (stderr, "RET to continue: "); - (void) getchar (); - } -} - - -/* Abbreviate the most common calls. */ - -static void -simple_compile (pat, buf) - const char *pat; - struct re_pattern_buffer *buf; -{ - const char *ret = re_compile_pattern (pat, strlen (pat), buf); - - if (ret != NULL) simple_fail ("compile", pat, buf, NULL, ret); -} - - -static void -simple_fastmap (pat) - const char *pat; -{ - struct re_pattern_buffer buf; - char fastmap[256]; - int ret; - - buf.allocated = 0; - buf.buffer = buf.translate = NULL; - buf.fastmap = fastmap; - - simple_compile (pat, &buf); - - ret = re_compile_fastmap (&buf); - - if (ret != 0) simple_fail ("fastmap compile", pat, &buf, NULL, itoa (ret)); -} - - -#define SIMPLE_MATCH(pat, str) do_match (pat, str, strlen (str)) -#define SIMPLE_NONMATCH(pat, str) do_match (pat, str, -1) - -static void -do_match (pat, str, expected) - const char *pat, *str; - int expected; -{ - int ret; - unsigned len; - struct re_pattern_buffer buf; - - buf.allocated = 0; - buf.buffer = buf.translate = buf.fastmap = NULL; - - simple_compile (pat, &buf); - - len = strlen (str); - - ret = re_match_2 (&buf, NULL, 0, str, len, 0, NULL, len); - - if (ret != expected) simple_fail ("match", pat, &buf, str, itoa (ret)); -} - - -static void -simple_search (pat, str, correct_startpos) - const char *pat, *str; - int correct_startpos; -{ - int ret; - unsigned len; - struct re_pattern_buffer buf; - - buf.allocated = 0; - buf.buffer = buf.translate = buf.fastmap = NULL; - - simple_compile (pat, &buf); - - len = strlen (str); - - ret = re_search_2 (&buf, NULL, 0, str, len, 0, len, NULL, len); - - if (ret != correct_startpos) - simple_fail ("match", pat, &buf, str, itoa (ret)); -} - -/* Past bugs people have reported. */ - -void -test_regress () -{ - extern char upcase[]; - struct re_pattern_buffer buf; - unsigned len; - struct re_registers regs; - int ret; - char *fastmap = xmalloc (256); - - buf.translate = NULL; - buf.fastmap = NULL; - buf.allocated = 0; - buf.buffer = NULL; - - printf ("\nStarting regression tests.\n"); - t = regress_test; - - test_should_match = true; - re_set_syntax (RE_SYNTAX_EMACS); - - /* enami@sys.ptg.sony.co.jp 10 Nov 92 15:19:02 JST */ - buf.translate = upcase; - SIMPLE_MATCH ("[A-[]", "A"); - buf.translate = NULL; - - /* meyering@cs.utexas.edu Nov 6 22:34:41 1992 */ - simple_search ("\\w+", "a", 0); - - /* jimb@occs.cs.oberlin.edu 10 Sep 92 00:42:33 */ - buf.translate = upcase; - SIMPLE_MATCH ("[\001-\377]", "\001"); - SIMPLE_MATCH ("[\001-\377]", "a"); - SIMPLE_MATCH ("[\001-\377]", "\377"); - buf.translate = NULL; - - /* mike@skinner.cs.uoregon.edu 1 Sep 92 01:45:22 */ - SIMPLE_MATCH ("^^$", "^"); - - /* pclink@qld.tne.oz.au Sep 7 22:42:36 1992 */ - re_set_syntax (RE_INTERVALS); - SIMPLE_MATCH ("^a\\{3\\}$", "aaa"); - SIMPLE_NONMATCH ("^a\\{3\\}$", "aa"); - re_set_syntax (RE_SYNTAX_EMACS); - - /* pclink@qld.tne.oz.au, 31 Aug 92. (conjecture) */ - re_set_syntax (RE_INTERVALS); - simple_search ("a\\{1,3\\}b", "aaab", 0); - simple_search ("a\\{1,3\\}b", "aaaab", 1); - re_set_syntax (RE_SYNTAX_EMACS); - - /* trq@dionysos.thphys.ox.ac.uk, 31 Aug 92. (simplified) */ - simple_fastmap ("^.*\n[ ]*"); - - /* wind!greg@plains.NoDak.edu, 25 Aug 92. (simplified) */ - re_set_syntax (RE_INTERVALS); - SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}", "xN0000"); - SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}$", "systemxN0000"); - SIMPLE_MATCH ("\\([a-zA-Z]*\\).\\{5\\}$", "systemxN0000"); - re_set_syntax (RE_SYNTAX_EMACS); - - /* jimb, 18 Aug 92. Don't use \000, so `strlen' (in our testing - routines) will work. (This still tickles the bug jimb reported.) */ - SIMPLE_MATCH ("[\001-\377]", "\001"); - SIMPLE_MATCH ("[\001-\377]", "a"); - SIMPLE_MATCH ("[\001-\377]", "\377"); - - /* jimb, 13 Aug 92. */ - SIMPLE_MATCH ("[\001-\177]", "\177"); - - /* Tests based on bwoelfel's below. */ - SIMPLE_MATCH ("\\(a\\|ab\\)*", "aab"); - SIMPLE_MATCH ("\\(a\\|ab\\)+", "aab"); - SIMPLE_MATCH ("\\(a*\\|ab\\)+", "aab"); - SIMPLE_MATCH ("\\(a+\\|ab\\)+", "aab"); - SIMPLE_MATCH ("\\(a?\\|ab\\)+", "aab"); - - /* bwoelfel@widget.seas.upenn.edu, 25 Jul 92. */ - SIMPLE_MATCH ("^\\([ab]+\\|bc\\)+", "abc"); - - /* jla, 3 Jul 92. Core dump in re_search_2. */ - buf.fastmap = fastmap; - buf.translate = upcase; -#define DATEDUMP_PATTERN " *[0-9]*:" - if (re_compile_pattern (DATEDUMP_PATTERN, strlen (DATEDUMP_PATTERN), &buf) - != NULL) - printf ("date dump compile failed.\n"); - regs.num_regs = 0; - regs.start = regs.end = NULL; - if (re_search_2 (&buf, NULL, 0, "Thu Jul 2 18:34:18 1992", - 24, 3, 21, ®s, 24) != 10) - printf ("date dump search failed.\n"); - buf.fastmap = 0; - buf.translate = 0; - - - /* rms, 4 Jul 1992. Pattern is much slower in Emacs 19. Fastmap - should be only a backslash. */ -#define BEGINEND_PATTERN "\\(\\\\begin\\s *{\\)\\|\\(\\\\end\\s *{\\)" - test_fastmap (BEGINEND_PATTERN, "\\", false, 0); - - - /* kaoru@is.s.u-tokyo.ac.jp, 27 Jun 1992. Code for [a-z] (in regex.c) - should translate the whole set. */ - buf.translate = upcase; -#define CASE_SET_PATTERN "[ -`]" - if (re_compile_pattern (CASE_SET_PATTERN, strlen (CASE_SET_PATTERN), &buf) - != NULL) - printf ("case set compile failed.\n"); - if (re_match_2 (&buf, "K", 1, "", 0, 0, NULL, 1) != 1) - printf ("case set match failed.\n"); - -#define CASE_SET_PATTERN2 "[`-|]" - if (re_compile_pattern (CASE_SET_PATTERN2, strlen (CASE_SET_PATTERN2), &buf) - != NULL) - printf ("case set2 compile failed.\n"); - if (re_match_2 (&buf, "K", 1, "", 0, 0, NULL, 1) != 1) - printf ("case set2 match failed.\n"); - - buf.translate = NULL; - - - /* jimb, 27 Jun 92. Problems with gaps in the string. */ -#define GAP_PATTERN "x.*y.*z" - if (re_compile_pattern (GAP_PATTERN, strlen (GAP_PATTERN), &buf) != NULL) - printf ("gap didn't compile.\n"); - if (re_match_2 (&buf, "x-", 2, "y-z-", 4, 0, NULL, 6) != 5) - printf ("gap match failed.\n"); - - - /* jimb, 19 Jun 92. Since `beginning of word' matches at the - beginning of the string, then searching ought to find it there. - If `re_compile_fastmap' is not called, then it works ok. */ - buf.fastmap = fastmap; -#define BOW_BEG_PATTERN "\\<" - if (re_compile_pattern (BOW_BEG_PATTERN, strlen (BOW_BEG_PATTERN), &buf) - != NULL) - printf ("begword-begstring didn't compile.\n"); - if (re_search (&buf, "foo", 3, 0, 3, NULL) != 0) - printf ("begword-begstring search failed.\n"); - - /* Same bug report, different null-matching pattern. */ -#define EMPTY_ANCHOR_PATTERN "^$" - if (re_compile_pattern (EMPTY_ANCHOR_PATTERN, strlen (EMPTY_ANCHOR_PATTERN), - &buf) != NULL) - printf ("empty anchor didn't compile.\n"); - if (re_search (&buf, "foo\n\nbar", 8, 0, 8, NULL) != 4) - printf ("empty anchor search failed.\n"); - - /* jimb@occs.cs.oberlin.edu, 21 Apr 92. After we first allocate - registers for a particular re_pattern_buffer, we might have to - reallocate more registers on subsequent calls -- and we should be - reusing the same memory. */ -#define ALLOC_REG_PATTERN "\\(abc\\)" - free (buf.fastmap); - buf.fastmap = 0; - if (re_compile_pattern (ALLOC_REG_PATTERN, strlen (ALLOC_REG_PATTERN), &buf) - != NULL) - printf ("register allocation didn't compile.\n"); - if (re_match (&buf, "abc", 3, 0, ®s) != 3) - printf ("register allocation didn't match.\n"); - if (regs.start[1] != 0 || regs.end[1] != 3) - printf ("register allocation reg #1 wrong.\n"); - - { - int *old_regstart = regs.start; - int *old_regend = regs.end; - - if (re_match (&buf, "abc", 3, 0, ®s) != 3) - printf ("register reallocation didn't match.\n"); - if (regs.start[1] != 0 || regs.end[1] != 3 - || old_regstart[1] != 0 || old_regend[1] != 3 - || regs.start != old_regstart || regs.end != old_regend) - printf ("register reallocation registers wrong.\n"); - } - - /* jskudlarek@std.MENTORG.COM, 21 Apr 92 (string-match). */ -#define JSKUD_PATTERN "[^/]+\\(/[^/.]+\\)?/[0-9]+$" - if (re_compile_pattern (JSKUD_PATTERN, strlen (JSKUD_PATTERN), &buf) != NULL) - printf ("jskud test didn't compile.\n"); - if (re_search (&buf, "a/1", 3, 0, 3, ®s) != 0) - printf ("jskud test didn't match.\n"); - if (regs.start[1] != -1 || regs.end[1] != -1) - printf ("jskud test, reg #1 wrong.\n"); - - /* jla's bug (with string-match), 5 Feb 92. */ - TEST_SEARCH ("\\`[ \t\n]*", "jla@challenger (Joseph Arceneaux)", 0, 100); - - /* jwz@lucid.com, 8 March 1992 (re-search-forward). (His is the - second.) These are not supposed to match. */ -#if 0 - /* This one fails quickly, because we can change the maybe_pop_jump - from the + to a pop_failure_pop, because of the c's. */ - TEST_SEARCH ("^\\(To\\|CC\\):\\([^c]*\\)+co", -"To: hbs%titanic@lucid.com (Harlan Sexton)\n\ -Cc: eb@thalidomide, jlm@thalidomide\n\ -Subject: Re: so is this really as horrible an idea as it seems to me?\n\ -In-Reply-To: Harlan Sexton's message of Sun 8-Mar-92 11:00:06 PST <9203081900.AA24794@titanic.lucid>\n\ -References: <9203080736.AA05869@thalidomide.lucid>\n\ - <9203081900.AA24794@titanic.lucid>", 0, 5000); - - /* This one takes a long, long time to complete, because we have to - keep the failure points around because we might backtrack. */ - TEST_SEARCH ("^\\(To\\|CC\\):\\(.*\n.*\\)+co", - /* "X-Windows: The joke that kills.\n\ -FCC: /u/jwz/VM/inbox\n\ -From: Jamie Zawinski \n\ */ -"To: hbs%titanic@lucid.com (Harlan Sexton)\n\ -Cc: eb@thalidomide, jlm@thalidomide\n\ -Subject: Re: so is this really as horrible an idea as it seems to me?\n\ -In-Reply-To: Harlan Sexton's message of Sun 8-Mar-92 11:00:06 PST <9203081900.AA24794@titanic.lucid>\n\ -References: <9203080736.AA05869@thalidomide.lucid>\n\ - <9203081900.AA24794@titanic.lucid>", 0, 5000); -#endif /* 0 [failed searches] */ - - - /* macrakis' bugs. */ - buf.translate = upcase; /* message of 24 Jan 91 */ - if (re_compile_pattern ("[!-`]", 5, &buf) != NULL) - printf ("Range test didn't compile.\n"); - if (re_match (&buf, "A", 1, 0, NULL) != 1) - printf ("Range test #1 didn't match.\n"); - if (re_match (&buf, "a", 1, 0, NULL) != 1) - printf ("Range test #2 didn't match.\n"); - - buf.translate = 0; -#define FAO_PATTERN "\\(f\\(.\\)o\\)+" - if (re_compile_pattern (FAO_PATTERN, strlen (FAO_PATTERN), &buf) != NULL) - printf ("faofdx test didn't compile.\n"); - if (re_search (&buf, "faofdx", 6, 0, 6, ®s) != 0) - printf ("faofdx test didn't match.\n"); - if (regs.start[1] != 0 || regs.end[1] != 3) - printf ("faofdx test, reg #1 wrong.\n"); - if (regs.start[2] != 1 || regs.end[2] != 2) - printf ("faofdx test, reg #2 wrong.\n"); - - TEST_REGISTERS ("\\(a\\)*a", "aaa", 0, 3, 1, 2, -1, -1); - test_fastmap ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)", " \n", 1, 0); - - /* 40 lines, 48 a's in each line. */ - test_match ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)", - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:"); - - /* 640 a's followed by one b, twice. */ - test_match ("\\(.*\\)\\1", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"); - - /* 640 a's followed by two b's, twice. */ - test_match ("\\(.*\\)\\1", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabb"); - - - /* Dave G. bug: Reference to a subexpression which didn't match. - Should fail. */ - re_set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR); - test_match ("(ooooooooooone())-annnnnnnnnnnd-(twooooooooooo\\2)", - "ooooooooooone-annnnnnnnnnnd-twooooooooooo"); - test_match ("(o|t)", "o"); - test_match ("(o()|t)", "o"); - test_match ("(o|t)", "o"); - test_match ("(ooooooooooooooo|tttttttttttttttt())", "ooooooooooooooo"); - test_match ("(o|t())", "o"); - test_match ("(o()|t())", "o"); - test_match ("(ooooooooooooooooooooooooone()|twooooooooooooooooooooooooo())", "ooooooooooooooooooooooooone"); - test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-t"); - test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-f"); - - test_should_match = 0; - test_match ("(foo(bar)|second)\\2", "second"); - test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-t"); - test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-f"); - - re_set_syntax (RE_SYNTAX_EMACS); - test_match ("\\(foo\\(bar\\)\\|second\\)\\2", "secondbar"); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", - "one-and-four"); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", - "two-and-three"); - - test_should_match = 1; - re_set_syntax (RE_SYNTAX_EMACS); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", - "one-and-three"); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", - "two-and-four"); - - TEST_REGISTERS (":\\(.*\\)", ":/", 0, 2, 1, 2, -1, -1); - - /* Bug with `upcase' translation table, from Nico Josuttis - */ - test_should_match = 1; - test_case_fold ("[a-a]", "a"); - - printf ("\nFinished regression tests.\n"); -} - - - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/libregex/test/upcase.c b/gnu/lib/libregex/test/upcase.c deleted file mode 100644 index 40af4fcfb717..000000000000 --- a/gnu/lib/libregex/test/upcase.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Indexed by a character, gives the upper case equivalent of the - character. */ - -#ifndef lint -static char rcsid[] = "$Id: upcase.c,v 1.2 1993/08/02 17:24:35 mycroft Exp $"; -#endif /* not lint */ - -char upcase[0400] = - { 000, 001, 002, 003, 004, 005, 006, 007, - 010, 011, 012, 013, 014, 015, 016, 017, - 020, 021, 022, 023, 024, 025, 026, 027, - 030, 031, 032, 033, 034, 035, 036, 037, - 040, 041, 042, 043, 044, 045, 046, 047, - 050, 051, 052, 053, 054, 055, 056, 057, - 060, 061, 062, 063, 064, 065, 066, 067, - 070, 071, 072, 073, 074, 075, 076, 077, - 0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137, - 0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177, - 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, - 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, - 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, - 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, - 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, - 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, - 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, - 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, - 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, - 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, - 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, - 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, - 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, - 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, - 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, - 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377 - }; - - diff --git a/gnu/lib/libregex/test/xmalloc.c b/gnu/lib/libregex/test/xmalloc.c deleted file mode 100644 index 694a1af69968..000000000000 --- a/gnu/lib/libregex/test/xmalloc.c +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef lint -static char rcsid[] = "$Id: xmalloc.c,v 1.2 1993/08/02 17:24:36 mycroft Exp $"; -#endif /* not lint */ - -#include -extern char *malloc (); - -#ifndef NULL -#define NULL 0 -#endif - -void * -xmalloc (size) - unsigned size; -{ - char *new_mem = malloc (size); - - if (new_mem == NULL) - { - fprintf (stderr, "xmalloc: request for %u bytes failed.\n", size); - abort (); - } - - return new_mem; -} diff --git a/gnu/lib/regex-0.12/Makefile.in b/gnu/lib/regex-0.12/Makefile.in deleted file mode 100644 index 836e6de0ba5a..000000000000 --- a/gnu/lib/regex-0.12/Makefile.in +++ /dev/null @@ -1,98 +0,0 @@ -# Makefile for regex. -# -# Copyright (C) 1992, 1993 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. - -version = 0.12 - -# You can define CPPFLAGS on the command line. Aside from system-specific -# flags, you can define: -# -DREGEX_MALLOC to use malloc/realloc/free instead of alloca. -# -DDEBUG to enable the compiled pattern disassembler and execution -# tracing; code runs substantially slower. -# -DEXTRACT_MACROS to use the macros EXTRACT_* (as opposed to -# the corresponding C procedures). If not -DDEBUG, the macros -# are used. -CPPFLAGS = - -# Likewise, you can override CFLAGS to optimize, use -Wall, etc. -CFLAGS = -g - -# Ditto for LDFLAGS and LOADLIBES. -LDFLAGS = -LOADLIBES = - -srcdir = @srcdir@ -VPATH = @srcdir@ - -CC = @CC@ -DEFS = @DEFS@ - -SHELL = /bin/sh - -subdirs = doc test - -default all:: regex.o -.PHONY: default all - -regex.o: regex.c regex.h - $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) -c $< - -clean mostlyclean:: - rm -f *.o - -distclean:: clean - rm -f Makefile config.status - -extraclean:: distclean - rm -f patch* *~* *\#* *.orig *.rej *.bak core a.out - -configure: configure.in - autoconf - -config.status: configure - sh configure --no-create - -Makefile: Makefile.in config.status - sh config.status - -makeargs = $(MFLAGS) CPPFLAGS='$(CPPFLAGS)' CFLAGS='$(CFLAGS)' CC='$(CC)' \ -DEFS='$(DEFS)' LDFLAGS='$(LDFLAGS)' LOADLIBES='$(LOADLIBES)' - -default all install \ -mostlyclean clean distclean extraclean realclean \ -TAGS check:: - for d in $(subdirs); do (cd $$d; $(MAKE) $(makeargs) $@); done -.PHONY: install mostlyclean clean distclean extraclean realclean TAGS check - -# Prevent GNU make 3 from overflowing arg limit on system V. -.NOEXPORT: - -distfiles = AUTHORS ChangeLog COPYING INSTALL NEWS README \ - *.in configure regex.c regex.h -distdir = regex-$(version) -distargs = version=$(version) distdir=../$(distdir)/$$d -dist: TAGS configure - @echo "Version numbers in: Makefile.in, ChangeLog, NEWS," - @echo " regex.c, regex.h," - @echo " and doc/xregex.texi (if modified)." - rm -rf $(distdir) - mkdir $(distdir) - ln $(distfiles) $(distdir) - for d in $(subdirs); do (cd $$d; $(MAKE) $(distargs) dist); done - tar czhf $(distdir).tar.Z $(distdir) - rm -rf $(distdir) -.PHONY: dist diff --git a/gnu/lib/regex-0.12/NEWS b/gnu/lib/regex-0.12/NEWS deleted file mode 100644 index b3a899b4568c..000000000000 --- a/gnu/lib/regex-0.12/NEWS +++ /dev/null @@ -1,62 +0,0 @@ -Version 0.12 - -* regex.c does not #define bcmp/bcopy/bzero if they already are. - -* regex.h does not redefine `const' if it is already defined, even if - __STDC__ is not defined. - -* RE_SYNTAX_ED added (same as POSIX BRE's). - -* The following bugs have been fixed, among others: - * The pattern \w+ doesn't infinite loop. - * The pattern ".+\n" is compiled correctly. - * Expressions with more than MAX_REGNUM groups are compiled correctly. - -* Patterns that end in a repetition operator (e.g., `*') match - slightly faster if no looping is actually necessary. - -Version 0.11 (17 Sep 92) - -* Back-references to nonexistent subexpressions, as in the r.e. `abc\1', - are always invalid. Previously, they could match the literal digit, - e.g., the stated r.e. might have matched `abc1'. - -* Empty subexpressions are always valid (POSIX leaves this undefined). - -* Simplified rules for ^ and $ being anchors. - -* One minor speedup (rewriting the C procedure `pop_failure_point' as a - macro again). - -* Bug fixes involving: - - Declarations in regex.h and non-ANSI compilers. - - Bracket expressions with characters between 0x80-0xff. - - Memory leak in re_match_2 on systems requiring `alloca (0)' to - free alloca'd storage. - -* Test and documentation files moved into subdirectories. - -Version 0.10 (9 Sep 92) - -* `obscure_syntax' is now called `re_default_syntax'. - -* `re_comp's return type is no longer `const', for compatibility with BSD. - -* POSIX syntaxes now include as much functionality as possible - (consistent with the standard). - -* Compilation conditionals normalized to what the rest of GNU is - migrating towards these days. - -* Bug fixes involving: - - Ranges with characters between 0x80 and 0xff, e.g., [\001-\377]. - - `re_compile_fastmap' and the sequence `.*\n'. - - Intervals with exact counts, e.g., a{5}. - -* Changed distribution to use a standard Makefile, install the info - files, use a configure script, etc. - -Version 0.9 - -* The longest match was not always chosen: `a*|ab' didn't match `aab'. - diff --git a/gnu/lib/regex-0.12/README b/gnu/lib/regex-0.12/README deleted file mode 100644 index 918e1a03b821..000000000000 --- a/gnu/lib/regex-0.12/README +++ /dev/null @@ -1,60 +0,0 @@ -This directory contains the GNU regex library. It is compliant with -POSIX.2, except for internationalization features. - -See the file NEWS for a list of major changes in the current release. - -See the file INSTALL for compilation instructions. (The only thing -installed is the documentation; regex.c is compiled into regex.o, but -not installed anywhere.) - -The subdirectory `doc' contains a (programmers') manual for the library. -It's probably out-of-date. Improvements are welcome. - -The subdirectory `test' contains the various tests we've written. - -We know this code is not as fast as it might be. If you have specific -suggestions, profiling results, or other such useful information to -report, please do. - -Emacs 18 is not going use this revised regex (but Emacs 19 will). If -you want to try it with Emacs 18, apply the patch at the end of this -file first. - -Mail bug reports to bug-gnu-utils@prep.ai.mit.edu. - -Please include an actual regular expression that fails (and the syntax -used to compile it); without that, there's no way to reproduce the bug, -so there's no way we can fix it. Even if you include a patch, also -include the regular expression in error; otherwise, we can't know for -sure what you're trying to fix. - -Here is the patch to make this version of regex work with Emacs 18. - -*** ORIG/search.c Tue Jan 8 13:04:55 1991 ---- search.c Sun Jan 5 10:57:00 1992 -*************** -*** 25,26 **** ---- 25,28 ---- - #include "commands.h" -+ -+ #include - #include "regex.h" -*************** -*** 477,479 **** - /* really needed. */ -! && *(searchbuf.buffer) == (char) exactn /* first item is "exact match" */ - && searchbuf.buffer[1] + 2 == searchbuf.used) /*first is ONLY item */ ---- 479,482 ---- - /* really needed. */ -! /* first item is "exact match" */ -! && *(searchbuf.buffer) == (char) RE_EXACTN_VALUE - && searchbuf.buffer[1] + 2 == searchbuf.used) /*first is ONLY item */ -*************** -*** 1273,1275 **** - searchbuf.allocated = 100; -! searchbuf.buffer = (char *) malloc (searchbuf.allocated); - searchbuf.fastmap = search_fastmap; ---- 1276,1278 ---- - searchbuf.allocated = 100; -! searchbuf.buffer = (unsigned char *) malloc (searchbuf.allocated); - searchbuf.fastmap = search_fastmap; diff --git a/gnu/lib/regex-0.12/config.status b/gnu/lib/regex-0.12/config.status deleted file mode 100644 index 1b276aacf34c..000000000000 --- a/gnu/lib/regex-0.12/config.status +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# Generated automatically by configure. -# Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host sun-lamp.cs.berkeley.edu: -# -# configure - -for arg -do - case "$arg" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - exec /bin/sh configure ;; - *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;; - esac -done - -trap 'rm -f Makefile doc/Makefile test/Makefile; exit 1' 1 3 15 -CC='gcc' -INSTALL='/usr/bin/install -c' -INSTALL_PROGRAM='$(INSTALL)' -INSTALL_DATA='$(INSTALL) -m 644' -CPP='${CC-cc} -E' -ALLOCA='' -LIBS='' -srcdir='.' -DEFS=' -DHAVE_STRING_H=1' -prefix='/usr' -exec_prefix='${prefix}' -prsub='s%^prefix\([ ]*\)=\([ ]*\).*$%prefix\1=\2/usr% -s%^exec_prefix\([ ]*\)=\([ ]*\).*$%exec_prefix\1=\2${prefix}%' - -top_srcdir=$srcdir -for file in .. Makefile doc/Makefile test/Makefile; do if [ "x$file" != "x.." ]; then - srcdir=$top_srcdir - # Remove last slash and all that follows it. Not all systems have dirname. - dir=`echo $file|sed 's%/[^/][^/]*$%%'` - if test "$dir" != "$file"; then - test "$top_srcdir" != . && srcdir=$top_srcdir/$dir - test ! -d $dir && mkdir $dir - fi - echo creating $file - rm -f $file - echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file - sed -e " -$prsub -s%@CC@%$CC%g -s%@INSTALL@%$INSTALL%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@CPP@%$CPP%g -s%@ALLOCA@%$ALLOCA%g -s%@LIBS@%$LIBS%g -s%@srcdir@%$srcdir%g -s%@DEFS@%$DEFS% -" $top_srcdir/${file}.in >> $file -fi; done - -exit 0 diff --git a/gnu/lib/regex-0.12/configure b/gnu/lib/regex-0.12/configure deleted file mode 100644 index 29c5b803c329..000000000000 --- a/gnu/lib/regex-0.12/configure +++ /dev/null @@ -1,462 +0,0 @@ -#!/bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf. -# Copyright (C) 1991, 1992, 1993 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: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [--no-create] -# [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE] [TARGET] -# Ignores all args except --srcdir, --prefix, --exec-prefix, --no-create, and -# --with-PACKAGE unless this script has special code to handle it. - - -for arg -do - # Handle --exec-prefix with a space before the argument. - if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix= - # Handle --host with a space before the argument. - elif test x$next_host = xyes; then next_host= - # Handle --prefix with a space before the argument. - elif test x$next_prefix = xyes; then prefix=$arg; next_prefix= - # Handle --srcdir with a space before the argument. - elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir= - else - case $arg in - # For backward compatibility, also recognize exact --exec_prefix. - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*) - exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;; - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e) - next_exec_prefix=yes ;; - - -gas | --gas | --ga | --g) ;; - - -host=* | --host=* | --hos=* | --ho=* | --h=*) ;; - -host | --host | --hos | --ho | --h) - next_host=yes ;; - - -nfp | --nfp | --nf) ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no) - no_create=1 ;; - - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;; - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - next_prefix=yes ;; - - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*) - srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;; - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s) - next_srcdir=yes ;; - - -with-* | --with-*) - package=`echo $arg|sed 's/-*with-//'` - # Delete all the valid chars; see if any are left. - if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then - echo "configure: $package: invalid package name" >&2; exit 1 - fi - eval "with_`echo $package|sed s/-/_/g`=1" ;; - - *) ;; - esac - fi -done - -trap 'rm -f conftest* core; exit 1' 1 3 15 - -rm -f conftest* -compile='${CC-cc} $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1' - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -unique_file=regex.c - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - srcdirdefaulted=yes - # Try the directory containing this script, then `..'. - prog=$0 - confdir=`echo $prog|sed 's%/[^/][^/]*$%%'` - test "X$confdir" = "X$prog" && confdir=. - srcdir=$confdir - if test ! -r $srcdir/$unique_file; then - srcdir=.. - fi -fi -if test ! -r $srcdir/$unique_file; then - if test x$srcdirdefaulted = xyes; then - echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2 - else - echo "configure: Can not find sources in \`${srcdir}'." 1>&2 - fi - exit 1 -fi -# Preserve a srcdir of `.' to avoid automounter screwups with pwd. -# But we can't avoid them for `..', to make subdirectories work. -case $srcdir in - .|/*|~*) ;; - *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute. -esac - - -if test -z "$CC"; then - echo checking for gcc - saveifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - test -z "$dir" && dir=. - if test -f $dir/gcc; then - CC="gcc" - break - fi - done - IFS="$saveifs" -fi -test -z "$CC" && CC="cc" - -# Find out if we are using GNU C, under whatever name. -cat > conftest.c < conftest.out 2>&1 -if egrep yes conftest.out >/dev/null 2>&1; then - GCC=1 # For later tests. -fi -rm -f conftest* - -# Make sure to not get the incompatible SysV /etc/install and -# /usr/sbin/install, which might be in PATH before a BSD-like install, -# or the SunOS /usr/etc/install directory, or the AIX /bin/install, -# or the AFS install, which mishandles nonexistent args. (Sigh.) -if test -z "$INSTALL"; then - echo checking for install - saveifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - test -z "$dir" && dir=. - case $dir in - /etc|/usr/sbin|/usr/etc|/usr/afsws/bin) ;; - *) - if test -f $dir/install; then - if grep dspmsg $dir/install >/dev/null 2>&1; then - : # AIX - else - INSTALL="$dir/install -c" - INSTALL_PROGRAM='$(INSTALL)' - INSTALL_DATA='$(INSTALL) -m 644' - break - fi - fi - ;; - esac - done - IFS="$saveifs" -fi -INSTALL=${INSTALL-cp} -INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'} -INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'} - - -echo checking for AIX -echo checking how to run the C preprocessor -if test -z "$CPP"; then - CPP='${CC-cc} -E' - cat > conftest.c < -EOF -err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` -if test -z "$err"; then - : -else - CPP=/lib/cpp -fi -rm -f conftest* -fi - -cat > conftest.c < conftest.out 2>&1" -if egrep "yes" conftest.out >/dev/null 2>&1; then - DEFS="$DEFS -D_ALL_SOURCE=1" -fi -rm -f conftest* - - -echo checking for DYNIX/ptx libseq -cat > conftest.c < conftest.out 2>&1" -if egrep "yes" conftest.out >/dev/null 2>&1; then - SEQUENT=1 -fi -rm -f conftest* - -test -n "$SEQUENT" && test -f /usr/lib/libseq.a && - LIBS="$LIBS -lseq" - -echo checking for POSIXized ISC -if test -d /etc/conf/kconfig.d && - grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 -then - ISC=1 # If later tests want to check for ISC. - DEFS="$DEFS -D_POSIX_SOURCE=1" - if test -n "$GCC"; then - CC="$CC -posix" - else - CC="$CC -Xp" - fi -fi - -echo checking for minix/config.h -cat > conftest.c < -EOF -err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` -if test -z "$err"; then - MINIX=1 -fi -rm -f conftest* - -# The Minix shell can't assign to the same variable on the same line! -if test -n "$MINIX"; then - DEFS="$DEFS -D_POSIX_SOURCE=1" - DEFS="$DEFS -D_POSIX_1_SOURCE=2" - DEFS="$DEFS -D_MINIX=1" -fi - - -echo checking for ANSI C header files -cat > conftest.c < -#include -#include -#include -EOF -err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` -if test -z "$err"; then - # SunOS string.h does not declare mem*, contrary to ANSI. -echo '#include ' > conftest.c -eval "$CPP $DEFS conftest.c > conftest.out 2>&1" -if egrep "memchr" conftest.out >/dev/null 2>&1; then - # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -cat > conftest.c < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e,f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -eval $compile -if test -s conftest && (./conftest; exit) 2>/dev/null; then - DEFS="$DEFS -DSTDC_HEADERS=1" -fi -rm -f conftest* -fi -rm -f conftest* - -fi -rm -f conftest* - -for hdr in string.h -do -trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'` -echo checking for ${hdr} -cat > conftest.c < -EOF -err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` -if test -z "$err"; then - DEFS="$DEFS -D${trhdr}=1" -fi -rm -f conftest* -done - - -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -echo checking for working alloca.h -cat > conftest.c < -main() { exit(0); } -t() { char *p = alloca(2 * sizeof(int)); } -EOF -if eval $compile; then - DEFS="$DEFS -DHAVE_ALLOCA_H=1" -fi -rm -f conftest* - -decl="#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#if HAVE_ALLOCA_H -#include -#else -#ifdef _AIX - #pragma alloca -#else -char *alloca (); -#endif -#endif -#endif -" -echo checking for alloca -cat > conftest.c < conftest.c < config.status </dev/null`: -# -# $0 $* - -for arg -do - case "\$arg" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - exec /bin/sh $0 $* ;; - *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;; - esac -done - -trap 'rm -f Makefile doc/Makefile test/Makefile; exit 1' 1 3 15 -CC='$CC' -INSTALL='$INSTALL' -INSTALL_PROGRAM='$INSTALL_PROGRAM' -INSTALL_DATA='$INSTALL_DATA' -CPP='$CPP' -ALLOCA='$ALLOCA' -LIBS='$LIBS' -srcdir='$srcdir' -DEFS='$DEFS' -prefix='$prefix' -exec_prefix='$exec_prefix' -prsub='$prsub' -EOF -cat >> config.status <<\EOF - -top_srcdir=$srcdir -for file in .. Makefile doc/Makefile test/Makefile; do if [ "x$file" != "x.." ]; then - srcdir=$top_srcdir - # Remove last slash and all that follows it. Not all systems have dirname. - dir=`echo $file|sed 's%/[^/][^/]*$%%'` - if test "$dir" != "$file"; then - test "$top_srcdir" != . && srcdir=$top_srcdir/$dir - test ! -d $dir && mkdir $dir - fi - echo creating $file - rm -f $file - echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file - sed -e " -$prsub -s%@CC@%$CC%g -s%@INSTALL@%$INSTALL%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@CPP@%$CPP%g -s%@ALLOCA@%$ALLOCA%g -s%@LIBS@%$LIBS%g -s%@srcdir@%$srcdir%g -s%@DEFS@%$DEFS% -" $top_srcdir/${file}.in >> $file -fi; done - -exit 0 -EOF -chmod +x config.status -test -n "$no_create" || ./config.status - diff --git a/gnu/lib/regex-0.12/configure.in b/gnu/lib/regex-0.12/configure.in deleted file mode 100644 index f0fc78025095..000000000000 --- a/gnu/lib/regex-0.12/configure.in +++ /dev/null @@ -1,23 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -AC_INIT(regex.c) - -AC_PROG_CC -AC_PROG_INSTALL - -dnl I'm not sure if AC_AIX and AC_DYNIX_SEQ are really necessary. The -dnl Autoconf documentation isn't specific about which BSD functions they -dnl provide. -AC_AIX -AC_DYNIX_SEQ -AC_ISC_POSIX -AC_MINIX - -AC_STDC_HEADERS -AC_HAVE_HEADERS(string.h) - -AC_ALLOCA -AC_CONST - -AC_PREFIX(gcc) - -AC_OUTPUT(Makefile doc/Makefile test/Makefile) diff --git a/gnu/lib/regex-0.12/doc/regex.info b/gnu/lib/regex-0.12/doc/regex.info deleted file mode 100644 index 90deedeaf44f..000000000000 --- a/gnu/lib/regex-0.12/doc/regex.info +++ /dev/null @@ -1,2836 +0,0 @@ -This is Info file regex.info, produced by Makeinfo-1.52 from the input -file .././doc/regex.texi. - - This file documents the GNU regular expression library. - - Copyright (C) 1992, 1993 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 also that the -section entitled "GNU General Public License" is included exactly as in -the original, and 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 the section entitled "GNU General Public License" -may be included in a translation approved by the Free Software -Foundation instead of in the original English. - - -File: regex.info, Node: Top, Next: Overview, Prev: (dir), Up: (dir) - -Regular Expression Library -************************** - - This manual documents how to program with the GNU regular expression -library. This is edition 0.12a of the manual, 19 September 1992. - - The first part of this master menu lists the major nodes in this Info -document, including the index. The rest of the menu lists all the -lower level nodes in the document. - -* Menu: - -* Overview:: -* Regular Expression Syntax:: -* Common Operators:: -* GNU Operators:: -* GNU Emacs Operators:: -* What Gets Matched?:: -* Programming with Regex:: -* Copying:: Copying and sharing Regex. -* Index:: General index. - -- The Detailed Node Listing -- - -Regular Expression Syntax - -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: - -Common Operators - -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? {} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ - -Repetition Operators - -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: {} - -List Operators (`[' ... `]' and `[^' ... `]') - -* Character Class Operators:: [:class:] -* Range Operator:: start-end - -Anchoring Operators - -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ - -GNU Operators - -* Word Operators:: -* Buffer Operators:: - -Word Operators - -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W - -Buffer Operators - -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' - -GNU Emacs Operators - -* Syntactic Class Operators:: - -Syntactic Class Operators - -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS - -Programming with Regex - -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: - -GNU Regex Functions - -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () - -POSIX Regex Functions - -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () - -BSD Regex Functions - -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () - - -File: regex.info, Node: Overview, Next: Regular Expression Syntax, Prev: Top, Up: Top - -Overview -******** - - A "regular expression" (or "regexp", or "pattern") is a text string -that describes some (mathematical) set of strings. A regexp R -"matches" a string S if S is in the set of strings described by R. - - Using the Regex library, you can: - - * see if a string matches a specified pattern as a whole, and - - * search within a string for a substring matching a specified - pattern. - - Some regular expressions match only one string, i.e., the set they -describe has only one member. For example, the regular expression -`foo' matches the string `foo' and no others. Other regular -expressions match more than one string, i.e., the set they describe has -more than one member. For example, the regular expression `f*' matches -the set of strings made up of any number (including zero) of `f's. As -you can see, some characters in regular expressions match themselves -(such as `f') and some don't (such as `*'); the ones that don't match -themselves instead let you specify patterns that describe many -different strings. - - To either match or search for a regular expression with the Regex -library functions, you must first compile it with a Regex pattern -compiling function. A "compiled pattern" is a regular expression -converted to the internal format used by the library functions. Once -you've compiled a pattern, you can use it for matching or searching any -number of times. - - The Regex library consists of two source files: `regex.h' and -`regex.c'. Regex provides three groups of functions with which you can -operate on regular expressions. One group--the GNU group--is more -powerful but not completely compatible with the other two, namely the -POSIX and Berkeley UNIX groups; its interface was designed specifically -for GNU. The other groups have the same interfaces as do the regular -expression functions in POSIX and Berkeley UNIX. - - We wrote this chapter with programmers in mind, not users of -programs--such as Emacs--that use Regex. We describe the Regex library -in its entirety, not how to write regular expressions that a particular -program understands. - - -File: regex.info, Node: Regular Expression Syntax, Next: Common Operators, Prev: Overview, Up: Top - -Regular Expression Syntax -************************* - - "Characters" are things you can type. "Operators" are things in a -regular expression that match one or more characters. You compose -regular expressions from operators, which in turn you specify using one -or more characters. - - Most characters represent what we call the match-self operator, i.e., -they match themselves; we call these characters "ordinary". Other -characters represent either all or parts of fancier operators; e.g., -`.' represents what we call the match-any-character operator (which, no -surprise, matches (almost) any character); we call these characters -"special". Two different things determine what characters represent -what operators: - - 1. the regular expression syntax your program has told the Regex - library to recognize, and - - 2. the context of the character in the regular expression. - - In the following sections, we describe these things in more detail. - -* Menu: - -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: - - -File: regex.info, Node: Syntax Bits, Next: Predefined Syntaxes, Up: Regular Expression Syntax - -Syntax Bits -=========== - - In any particular syntax for regular expressions, some characters are -always special, others are sometimes special, and others are never -special. The particular syntax that Regex recognizes for a given -regular expression depends on the value in the `syntax' field of the -pattern buffer of that regular expression. - - You get a pattern buffer by compiling a regular expression. *Note -GNU Pattern Buffers::, and *Note POSIX Pattern Buffers::, for more -information on pattern buffers. *Note GNU Regular Expression -Compiling::, *Note POSIX Regular Expression Compiling::, and *Note BSD -Regular Expression Compiling::, for more information on compiling. - - Regex considers the value of the `syntax' field to be a collection of -bits; we refer to these bits as "syntax bits". In most cases, they -affect what characters represent what operators. We describe the -meanings of the operators to which we refer in *Note Common Operators::, -*Note GNU Operators::, and *Note GNU Emacs Operators::. - - For reference, here is the complete list of syntax bits, in -alphabetical order: - -`RE_BACKSLASH_ESCAPE_IN_LISTS' - If this bit is set, then `\' inside a list (*note List Operators::. - quotes (makes ordinary, if it's special) the following character; - if this bit isn't set, then `\' is an ordinary character inside - lists. (*Note The Backslash Character::, for what `\' does - outside of lists.) - -`RE_BK_PLUS_QM' - If this bit is set, then `\+' represents the match-one-or-more - operator and `\?' represents the match-zero-or-more operator; if - this bit isn't set, then `+' represents the match-one-or-more - operator and `?' represents the match-zero-or-one operator. This - bit is irrelevant if `RE_LIMITED_OPS' is set. - -`RE_CHAR_CLASSES' - If this bit is set, then you can use character classes in lists; - if this bit isn't set, then you can't. - -`RE_CONTEXT_INDEP_ANCHORS' - If this bit is set, then `^' and `$' are special anywhere outside - a list; if this bit isn't set, then these characters are special - only in certain contexts. *Note Match-beginning-of-line - Operator::, and *Note Match-end-of-line Operator::. - -`RE_CONTEXT_INDEP_OPS' - If this bit is set, then certain characters are special anywhere - outside a list; if this bit isn't set, then those characters are - special only in some contexts and are ordinary elsewhere. - Specifically, if this bit isn't set then `*', and (if the syntax - bit `RE_LIMITED_OPS' isn't set) `+' and `?' (or `\+' and `\?', - depending on the syntax bit `RE_BK_PLUS_QM') represent repetition - operators only if they're not first in a regular expression or - just after an open-group or alternation operator. The same holds - for `{' (or `\{', depending on the syntax bit `RE_NO_BK_BRACES') if - it is the beginning of a valid interval and the syntax bit - `RE_INTERVALS' is set. - -`RE_CONTEXT_INVALID_OPS' - If this bit is set, then repetition and alternation operators - can't be in certain positions within a regular expression. - Specifically, the regular expression is invalid if it has: - - * a repetition operator first in the regular expression or just - after a match-beginning-of-line, open-group, or alternation - operator; or - - * an alternation operator first or last in the regular - expression, just before a match-end-of-line operator, or just - after an alternation or open-group operator. - - If this bit isn't set, then you can put the characters - representing the repetition and alternation characters anywhere in - a regular expression. Whether or not they will in fact be - operators in certain positions depends on other syntax bits. - -`RE_DOT_NEWLINE' - If this bit is set, then the match-any-character operator matches - a newline; if this bit isn't set, then it doesn't. - -`RE_DOT_NOT_NULL' - If this bit is set, then the match-any-character operator doesn't - match a null character; if this bit isn't set, then it does. - -`RE_INTERVALS' - If this bit is set, then Regex recognizes interval operators; if - this bit isn't set, then it doesn't. - -`RE_LIMITED_OPS' - If this bit is set, then Regex doesn't recognize the - match-one-or-more, match-zero-or-one or alternation operators; if - this bit isn't set, then it does. - -`RE_NEWLINE_ALT' - If this bit is set, then newline represents the alternation - operator; if this bit isn't set, then newline is ordinary. - -`RE_NO_BK_BRACES' - If this bit is set, then `{' represents the open-interval operator - and `}' represents the close-interval operator; if this bit isn't - set, then `\{' represents the open-interval operator and `\}' - represents the close-interval operator. This bit is relevant only - if `RE_INTERVALS' is set. - -`RE_NO_BK_PARENS' - If this bit is set, then `(' represents the open-group operator and - `)' represents the close-group operator; if this bit isn't set, - then `\(' represents the open-group operator and `\)' represents - the close-group operator. - -`RE_NO_BK_REFS' - If this bit is set, then Regex doesn't recognize `\'DIGIT as the - back reference operator; if this bit isn't set, then it does. - -`RE_NO_BK_VBAR' - If this bit is set, then `|' represents the alternation operator; - if this bit isn't set, then `\|' represents the alternation - operator. This bit is irrelevant if `RE_LIMITED_OPS' is set. - -`RE_NO_EMPTY_RANGES' - If this bit is set, then a regular expression with a range whose - ending point collates lower than its starting point is invalid; if - this bit isn't set, then Regex considers such a range to be empty. - -`RE_UNMATCHED_RIGHT_PAREN_ORD' - If this bit is set and the regular expression has no matching - open-group operator, then Regex considers what would otherwise be - a close-group operator (based on how `RE_NO_BK_PARENS' is set) to - match `)'. - - -File: regex.info, Node: Predefined Syntaxes, Next: Collating Elements vs. Characters, Prev: Syntax Bits, Up: Regular Expression Syntax - -Predefined Syntaxes -=================== - - If you're programming with Regex, you can set a pattern buffer's -(*note GNU Pattern Buffers::., and *Note POSIX Pattern Buffers::) -`syntax' field either to an arbitrary combination of syntax bits (*note -Syntax Bits::.) or else to the configurations defined by Regex. These -configurations define the syntaxes used by certain programs--GNU Emacs, -POSIX Awk, traditional Awk, Grep, Egrep--in addition to syntaxes for -POSIX basic and extended regular expressions. - - The predefined syntaxes-taken directly from `regex.h'--are: - - #define RE_SYNTAX_EMACS 0 - - #define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - - #define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) - - #define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - - #define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - - #define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) - - /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ - #define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - - #define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - - /* Syntax bits common to both basic and extended POSIX regex syntax. */ - #define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - - #define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) - - /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ - #define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - - #define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - - /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS - replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ - #define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) - - -File: regex.info, Node: Collating Elements vs. Characters, Next: The Backslash Character, Prev: Predefined Syntaxes, Up: Regular Expression Syntax - -Collating Elements vs. Characters -================================= - - POSIX generalizes the notion of a character to that of a collating -element. It defines a "collating element" to be "a sequence of one or -more bytes defined in the current collating sequence as a unit of -collation." - - This generalizes the notion of a character in two ways. First, a -single character can map into two or more collating elements. For -example, the German "es-zet" collates as the collating element `s' -followed by another collating element `s'. Second, two or more -characters can map into one collating element. For example, the -Spanish `ll' collates after `l' and before `m'. - - Since POSIX's "collating element" preserves the essential idea of a -"character," we use the latter, more familiar, term in this document. - - -File: regex.info, Node: The Backslash Character, Prev: Collating Elements vs. Characters, Up: Regular Expression Syntax - -The Backslash Character -======================= - - The `\' character has one of four different meanings, depending on -the context in which you use it and what syntax bits are set (*note -Syntax Bits::.). It can: 1) stand for itself, 2) quote the next -character, 3) introduce an operator, or 4) do nothing. - - 1. It stands for itself inside a list (*note List Operators::.) if - the syntax bit `RE_BACKSLASH_ESCAPE_IN_LISTS' is not set. For - example, `[\]' would match `\'. - - 2. It quotes (makes ordinary, if it's special) the next character - when you use it either: - - * outside a list,(1) or - - * inside a list and the syntax bit - `RE_BACKSLASH_ESCAPE_IN_LISTS' is set. - - 3. It introduces an operator when followed by certain ordinary - characters--sometimes only when certain syntax bits are set. See - the cases `RE_BK_PLUS_QM', `RE_NO_BK_BRACES', `RE_NO_BK_VAR', - `RE_NO_BK_PARENS', `RE_NO_BK_REF' in *Note Syntax Bits::. Also: - - * `\b' represents the match-word-boundary operator (*note - Match-word-boundary Operator::.). - - * `\B' represents the match-within-word operator (*note - Match-within-word Operator::.). - - * `\<' represents the match-beginning-of-word operator - (*note Match-beginning-of-word Operator::.). - - * `\>' represents the match-end-of-word operator (*note - Match-end-of-word Operator::.). - - * `\w' represents the match-word-constituent operator (*note - Match-word-constituent Operator::.). - - * `\W' represents the match-non-word-constituent operator - (*note Match-non-word-constituent Operator::.). - - * `\`' represents the match-beginning-of-buffer operator and - `\'' represents the match-end-of-buffer operator (*note - Buffer Operators::.). - - * If Regex was compiled with the C preprocessor symbol `emacs' - defined, then `\sCLASS' represents the match-syntactic-class - operator and `\SCLASS' represents the - match-not-syntactic-class operator (*note Syntactic Class - Operators::.). - - 4. In all other cases, Regex ignores `\'. For example, `\n' matches - `n'. - - - ---------- Footnotes ---------- - - (1) Sometimes you don't have to explicitly quote special characters -to make them ordinary. For instance, most characters lose any special -meaning inside a list (*note List Operators::.). In addition, if the -syntax bits `RE_CONTEXT_INVALID_OPS' and `RE_CONTEXT_INDEP_OPS' aren't -set, then (for historical reasons) the matcher considers special -characters ordinary if they are in contexts where the operations they -represent make no sense; for example, then the match-zero-or-more -operator (represented by `*') matches itself in the regular expression -`*foo' because there is no preceding expression on which it can -operate. It is poor practice, however, to depend on this behavior; if -you want a special character to be ordinary outside a list, it's better -to always quote it, regardless. - - -File: regex.info, Node: Common Operators, Next: GNU Operators, Prev: Regular Expression Syntax, Up: Top - -Common Operators -**************** - - You compose regular expressions from operators. In the following -sections, we describe the regular expression operators specified by -POSIX; GNU also uses these. Most operators have more than one -representation as characters. *Note Regular Expression Syntax::, for -what characters represent what operators under what circumstances. - - For most operators that can be represented in two ways, one -representation is a single character and the other is that character -preceded by `\'. For example, either `(' or `\(' represents the -open-group operator. Which one does depends on the setting of a syntax -bit, in this case `RE_NO_BK_PARENS'. Why is this so? Historical -reasons dictate some of the varying representations, while POSIX -dictates others. - - Finally, almost all characters lose any special meaning inside a list -(*note List Operators::.). - -* Menu: - -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? {} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ - - -File: regex.info, Node: Match-self Operator, Next: Match-any-character Operator, Up: Common Operators - -The Match-self Operator (ORDINARY CHARACTER) -============================================ - - This operator matches the character itself. All ordinary characters -(*note Regular Expression Syntax::.) represent this operator. For -example, `f' is always an ordinary character, so the regular expression -`f' matches only the string `f'. In particular, it does *not* match -the string `ff'. - - -File: regex.info, Node: Match-any-character Operator, Next: Concatenation Operator, Prev: Match-self Operator, Up: Common Operators - -The Match-any-character Operator (`.') -====================================== - - This operator matches any single printing or nonprinting character -except it won't match a: - -newline - if the syntax bit `RE_DOT_NEWLINE' isn't set. - -null - if the syntax bit `RE_DOT_NOT_NULL' is set. - - The `.' (period) character represents this operator. For example, -`a.b' matches any three-character string beginning with `a' and ending -with `b'. - - -File: regex.info, Node: Concatenation Operator, Next: Repetition Operators, Prev: Match-any-character Operator, Up: Common Operators - -The Concatenation Operator -========================== - - This operator concatenates two regular expressions A and B. No -character represents this operator; you simply put B after A. The -result is a regular expression that will match a string if A matches -its first part and B matches the rest. For example, `xy' (two -match-self operators) matches `xy'. - - -File: regex.info, Node: Repetition Operators, Next: Alternation Operator, Prev: Concatenation Operator, Up: Common Operators - -Repetition Operators -==================== - - Repetition operators repeat the preceding regular expression a -specified number of times. - -* Menu: - -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: {} - - -File: regex.info, Node: Match-zero-or-more Operator, Next: Match-one-or-more Operator, Up: Repetition Operators - -The Match-zero-or-more Operator (`*') -------------------------------------- - - This operator repeats the smallest possible preceding regular -expression as many times as necessary (including zero) to match the -pattern. `*' represents this operator. For example, `o*' matches any -string made up of zero or more `o's. Since this operator operates on -the smallest preceding regular expression, `fo*' has a repeating `o', -not a repeating `fo'. So, `fo*' matches `f', `fo', `foo', and so on. - - Since the match-zero-or-more operator is a suffix operator, it may be -useless as such when no regular expression precedes it. This is the -case when it: - - * is first in a regular expression, or - - * follows a match-beginning-of-line, open-group, or alternation - operator. - -Three different things can happen in these cases: - - 1. If the syntax bit `RE_CONTEXT_INVALID_OPS' is set, then the - regular expression is invalid. - - 2. If `RE_CONTEXT_INVALID_OPS' isn't set, but `RE_CONTEXT_INDEP_OPS' - is, then `*' represents the match-zero-or-more operator (which - then operates on the empty string). - - 3. Otherwise, `*' is ordinary. - - - The matcher processes a match-zero-or-more operator by first matching -as many repetitions of the smallest preceding regular expression as it -can. Then it continues to match the rest of the pattern. - - If it can't match the rest of the pattern, it backtracks (as many -times as necessary), each time discarding one of the matches until it -can either match the entire pattern or be certain that it cannot get a -match. For example, when matching `ca*ar' against `caaar', the matcher -first matches all three `a's of the string with the `a*' of the regular -expression. However, it cannot then match the final `ar' of the -regular expression against the final `r' of the string. So it -backtracks, discarding the match of the last `a' in the string. It can -then match the remaining `ar'. - - -File: regex.info, Node: Match-one-or-more Operator, Next: Match-zero-or-one Operator, Prev: Match-zero-or-more Operator, Up: Repetition Operators - -The Match-one-or-more Operator (`+' or `\+') --------------------------------------------- - - If the syntax bit `RE_LIMITED_OPS' is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit `RE_BK_PLUS_QM' -isn't set, then `+' represents this operator; if it is, then `\+' does. - - This operator is similar to the match-zero-or-more operator except -that it repeats the preceding regular expression at least once; *note -Match-zero-or-more Operator::., for what it operates on, how some -syntax bits affect it, and how Regex backtracks to match it. - - For example, supposing that `+' represents the match-one-or-more -operator; then `ca+r' matches, e.g., `car' and `caaaar', but not `cr'. - - -File: regex.info, Node: Match-zero-or-one Operator, Next: Interval Operators, Prev: Match-one-or-more Operator, Up: Repetition Operators - -The Match-zero-or-one Operator (`?' or `\?') --------------------------------------------- - - If the syntax bit `RE_LIMITED_OPS' is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit `RE_BK_PLUS_QM' -isn't set, then `?' represents this operator; if it is, then `\?' does. - - This operator is similar to the match-zero-or-more operator except -that it repeats the preceding regular expression once or not at all; -*note Match-zero-or-more Operator::., to see what it operates on, how -some syntax bits affect it, and how Regex backtracks to match it. - - For example, supposing that `?' represents the match-zero-or-one -operator; then `ca?r' matches both `car' and `cr', but nothing else. - - -File: regex.info, Node: Interval Operators, Prev: Match-zero-or-one Operator, Up: Repetition Operators - -Interval Operators (`{' ... `}' or `\{' ... `\}') -------------------------------------------------- - - If the syntax bit `RE_INTERVALS' is set, then Regex recognizes -"interval expressions". They repeat the smallest possible preceding -regular expression a specified number of times. - - If the syntax bit `RE_NO_BK_BRACES' is set, `{' represents the -"open-interval operator" and `}' represents the "close-interval -operator" ; otherwise, `\{' and `\}' do. - - Specifically, supposing that `{' and `}' represent the open-interval -and close-interval operators; then: - -`{COUNT}' - matches exactly COUNT occurrences of the preceding regular - expression. - -`{MIN,}' - matches MIN or more occurrences of the preceding regular - expression. - -`{MIN, MAX}' - matches at least MIN but no more than MAX occurrences of the - preceding regular expression. - - The interval expression (but not necessarily the regular expression -that contains it) is invalid if: - - * MIN is greater than MAX, or - - * any of COUNT, MIN, or MAX are outside the range zero to - `RE_DUP_MAX' (which symbol `regex.h' defines). - - If the interval expression is invalid and the syntax bit -`RE_NO_BK_BRACES' is set, then Regex considers all the characters in -the would-be interval to be ordinary. If that bit isn't set, then the -regular expression is invalid. - - If the interval expression is valid but there is no preceding regular -expression on which to operate, then if the syntax bit -`RE_CONTEXT_INVALID_OPS' is set, the regular expression is invalid. If -that bit isn't set, then Regex considers all the characters--other than -backslashes, which it ignores--in the would-be interval to be ordinary. - - -File: regex.info, Node: Alternation Operator, Next: List Operators, Prev: Repetition Operators, Up: Common Operators - -The Alternation Operator (`|' or `\|') -====================================== - - If the syntax bit `RE_LIMITED_OPS' is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit `RE_NO_BK_VBAR' -is set, then `|' represents this operator; otherwise, `\|' does. - - Alternatives match one of a choice of regular expressions: if you put -the character(s) representing the alternation operator between any two -regular expressions A and B, the result matches the union of the -strings that A and B match. For example, supposing that `|' is the -alternation operator, then `foo|bar|quux' would match any of `foo', -`bar' or `quux'. - - The alternation operator operates on the *largest* possible -surrounding regular expressions. (Put another way, it has the lowest -precedence of any regular expression operator.) Thus, the only way you -can delimit its arguments is to use grouping. For example, if `(' and -`)' are the open and close-group operators, then `fo(o|b)ar' would -match either `fooar' or `fobar'. (`foo|bar' would match `foo' or -`bar'.) - - The matcher usually tries all combinations of alternatives so as to -match the longest possible string. For example, when matching -`(fooq|foo)*(qbarquux|bar)' against `fooqbarquux', it cannot take, say, -the first ("depth-first") combination it could match, since then it -would be content to match just `fooqbar'. - - -File: regex.info, Node: List Operators, Next: Grouping Operators, Prev: Alternation Operator, Up: Common Operators - -List Operators (`[' ... `]' and `[^' ... `]') -============================================= - - "Lists", also called "bracket expressions", are a set of one or more -items. An "item" is a character, a character class expression, or a -range expression. The syntax bits affect which kinds of items you can -put in a list. We explain the last two items in subsections below. -Empty lists are invalid. - - A "matching list" matches a single character represented by one of -the list items. You form a matching list by enclosing one or more items -within an "open-matching-list operator" (represented by `[') and a -"close-list operator" (represented by `]'). - - For example, `[ab]' matches either `a' or `b'. `[ad]*' matches the -empty string and any string composed of just `a's and `d's in any -order. Regex considers invalid a regular expression with a `[' but no -matching `]'. - - "Nonmatching lists" are similar to matching lists except that they -match a single character *not* represented by one of the list items. -You use an "open-nonmatching-list operator" (represented by `[^'(1)) -instead of an open-matching-list operator to start a nonmatching list. - - For example, `[^ab]' matches any character except `a' or `b'. - - If the `posix_newline' field in the pattern buffer (*note GNU Pattern -Buffers::. is set, then nonmatching lists do not match a newline. - - Most characters lose any special meaning inside a list. The special -characters inside a list follow. - -`]' - ends the list if it's not the first list item. So, if you want to - make the `]' character a list item, you must put it first. - -`\' - quotes the next character if the syntax bit - `RE_BACKSLASH_ESCAPE_IN_LISTS' is set. - -`[:' - represents the open-character-class operator (*note Character - Class Operators::.) if the syntax bit `RE_CHAR_CLASSES' is set and - what follows is a valid character class expression. - -`:]' - represents the close-character-class operator if the syntax bit - `RE_CHAR_CLASSES' is set and what precedes it is an - open-character-class operator followed by a valid character class - name. - -`-' - represents the range operator (*note Range Operator::.) if it's - not first or last in a list or the ending point of a range. - -All other characters are ordinary. For example, `[.*]' matches `.' and -`*'. - -* Menu: - -* Character Class Operators:: [:class:] -* Range Operator:: start-end - - ---------- Footnotes ---------- - - (1) Regex therefore doesn't consider the `^' to be the first -character in the list. If you put a `^' character first in (what you -think is) a matching list, you'll turn it into a nonmatching list. - - -File: regex.info, Node: Character Class Operators, Next: Range Operator, Up: List Operators - -Character Class Operators (`[:' ... `:]') ------------------------------------------ - - If the syntax bit `RE_CHARACTER_CLASSES' is set, then Regex -recognizes character class expressions inside lists. A "character -class expression" matches one character from a given class. You form a -character class expression by putting a character class name between an -"open-character-class operator" (represented by `[:') and a -"close-character-class operator" (represented by `:]'). The character -class names and their meanings are: - -`alnum' - letters and digits - -`alpha' - letters - -`blank' - system-dependent; for GNU, a space or tab - -`cntrl' - control characters (in the ASCII encoding, code 0177 and codes - less than 040) - -`digit' - digits - -`graph' - same as `print' except omits space - -`lower' - lowercase letters - -`print' - printable characters (in the ASCII encoding, space tilde--codes - 040 through 0176) - -`punct' - neither control nor alphanumeric characters - -`space' - space, carriage return, newline, vertical tab, and form feed - -`upper' - uppercase letters - -`xdigit' - hexadecimal digits: `0'-`9', `a'-`f', `A'-`F' - -These correspond to the definitions in the C library's `' -facility. For example, `[:alpha:]' corresponds to the standard -facility `isalpha'. Regex recognizes character class expressions only -inside of lists; so `[[:alpha:]]' matches any letter, but `[:alpha:]' -outside of a bracket expression and not followed by a repetition -operator matches just itself. - - -File: regex.info, Node: Range Operator, Prev: Character Class Operators, Up: List Operators - -The Range Operator (`-') ------------------------- - - Regex recognizes "range expressions" inside a list. They represent -those characters that fall between two elements in the current -collating sequence. You form a range expression by putting a "range -operator" between two characters.(1) `-' represents the range operator. -For example, `a-f' within a list represents all the characters from `a' -through `f' inclusively. - - If the syntax bit `RE_NO_EMPTY_RANGES' is set, then if the range's -ending point collates less than its starting point, the range (and the -regular expression containing it) is invalid. For example, the regular -expression `[z-a]' would be invalid. If this bit isn't set, then Regex -considers such a range to be empty. - - Since `-' represents the range operator, if you want to make a `-' -character itself a list item, you must do one of the following: - - * Put the `-' either first or last in the list. - - * Include a range whose starting point collates strictly lower than - `-' and whose ending point collates equal or higher. Unless a - range is the first item in a list, a `-' can't be its starting - point, but *can* be its ending point. That is because Regex - considers `-' to be the range operator unless it is preceded by - another `-'. For example, in the ASCII encoding, `)', `*', `+', - `,', `-', `.', and `/' are contiguous characters in the collating - sequence. You might think that `[)-+--/]' has two ranges: `)-+' - and `--/'. Rather, it has the ranges `)-+' and `+--', plus the - character `/', so it matches, e.g., `,', not `.'. - - * Put a range whose starting point is `-' first in the list. - - For example, `[-a-z]' matches a lowercase letter or a hyphen (in -English, in ASCII). - - ---------- Footnotes ---------- - - (1) You can't use a character class for the starting or ending point -of a range, since a character class is not a single character. - - -File: regex.info, Node: Grouping Operators, Next: Back-reference Operator, Prev: List Operators, Up: Common Operators - -Grouping Operators (`(' ... `)' or `\(' ... `\)') -================================================= - - A "group", also known as a "subexpression", consists of an -"open-group operator", any number of other operators, and a -"close-group operator". Regex treats this sequence as a unit, just as -mathematics and programming languages treat a parenthesized expression -as a unit. - - Therefore, using "groups", you can: - - * delimit the argument(s) to an alternation operator (*note - Alternation Operator::.) or a repetition operator (*note - Repetition Operators::.). - - * keep track of the indices of the substring that matched a given - group. *Note Using Registers::, for a precise explanation. This - lets you: - - * use the back-reference operator (*note Back-reference - Operator::.). - - * use registers (*note Using Registers::.). - - If the syntax bit `RE_NO_BK_PARENS' is set, then `(' represents the -open-group operator and `)' represents the close-group operator; -otherwise, `\(' and `\)' do. - - If the syntax bit `RE_UNMATCHED_RIGHT_PAREN_ORD' is set and a -close-group operator has no matching open-group operator, then Regex -considers it to match `)'. - - -File: regex.info, Node: Back-reference Operator, Next: Anchoring Operators, Prev: Grouping Operators, Up: Common Operators - -The Back-reference Operator ("\"DIGIT) -====================================== - - If the syntax bit `RE_NO_BK_REF' isn't set, then Regex recognizes -back references. A back reference matches a specified preceding group. -The back reference operator is represented by `\DIGIT' anywhere after -the end of a regular expression's DIGIT-th group (*note Grouping -Operators::.). - - DIGIT must be between `1' and `9'. The matcher assigns numbers 1 -through 9 to the first nine groups it encounters. By using one of `\1' -through `\9' after the corresponding group's close-group operator, you -can match a substring identical to the one that the group does. - - Back references match according to the following (in all examples -below, `(' represents the open-group, `)' the close-group, `{' the -open-interval and `}' the close-interval operator): - - * If the group matches a substring, the back reference matches an - identical substring. For example, `(a)\1' matches `aa' and - `(bana)na\1bo\1' matches `bananabanabobana'. Likewise, `(.*)\1' - matches any (newline-free if the syntax bit `RE_DOT_NEWLINE' isn't - set) string that is composed of two identical halves; the `(.*)' - matches the first half and the `\1' matches the second half. - - * If the group matches more than once (as it might if followed by, - e.g., a repetition operator), then the back reference matches the - substring the group *last* matched. For example, `((a*)b)*\1\2' - matches `aabababa'; first group 1 (the outer one) matches `aab' - and group 2 (the inner one) matches `aa'. Then group 1 matches - `ab' and group 2 matches `a'. So, `\1' matches `ab' and `\2' - matches `a'. - - * If the group doesn't participate in a match, i.e., it is part of an - alternative not taken or a repetition operator allows zero - repetitions of it, then the back reference makes the whole match - fail. For example, `(one()|two())-and-(three\2|four\3)' matches - `one-and-three' and `two-and-four', but not `one-and-four' or - `two-and-three'. For example, if the pattern matches `one-and-', - then its group 2 matches the empty string and its group 3 doesn't - participate in the match. So, if it then matches `four', then - when it tries to back reference group 3--which it will attempt to - do because `\3' follows the `four'--the match will fail because - group 3 didn't participate in the match. - - You can use a back reference as an argument to a repetition operator. -For example, `(a(b))\2*' matches `a' followed by two or more `b's. -Similarly, `(a(b))\2{3}' matches `abbbb'. - - If there is no preceding DIGIT-th subexpression, the regular -expression is invalid. - - -File: regex.info, Node: Anchoring Operators, Prev: Back-reference Operator, Up: Common Operators - -Anchoring Operators -=================== - - These operators can constrain a pattern to match only at the -beginning or end of the entire string or at the beginning or end of a -line. - -* Menu: - -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ - - -File: regex.info, Node: Match-beginning-of-line Operator, Next: Match-end-of-line Operator, Up: Anchoring Operators - -The Match-beginning-of-line Operator (`^') ------------------------------------------- - - This operator can match the empty string either at the beginning of -the string or after a newline character. Thus, it is said to "anchor" -the pattern to the beginning of a line. - - In the cases following, `^' represents this operator. (Otherwise, -`^' is ordinary.) - - * It (the `^') is first in the pattern, as in `^foo'. - - * The syntax bit `RE_CONTEXT_INDEP_ANCHORS' is set, and it is outside - a bracket expression. - - * It follows an open-group or alternation operator, as in `a\(^b\)' - and `a\|^b'. *Note Grouping Operators::, and *Note Alternation - Operator::. - - These rules imply that some valid patterns containing `^' cannot be -matched; for example, `foo^bar' if `RE_CONTEXT_INDEP_ANCHORS' is set. - - If the `not_bol' field is set in the pattern buffer (*note GNU -Pattern Buffers::.), then `^' fails to match at the beginning of the -string. *Note POSIX Matching::, for when you might find this useful. - - If the `newline_anchor' field is set in the pattern buffer, then `^' -fails to match after a newline. This is useful when you do not regard -the string to be matched as broken into lines. - - -File: regex.info, Node: Match-end-of-line Operator, Prev: Match-beginning-of-line Operator, Up: Anchoring Operators - -The Match-end-of-line Operator (`$') ------------------------------------- - - This operator can match the empty string either at the end of the -string or before a newline character in the string. Thus, it is said -to "anchor" the pattern to the end of a line. - - It is always represented by `$'. For example, `foo$' usually -matches, e.g., `foo' and, e.g., the first three characters of -`foo\nbar'. - - Its interaction with the syntax bits and pattern buffer fields is -exactly the dual of `^''s; see the previous section. (That is, -"beginning" becomes "end", "next" becomes "previous", and "after" -becomes "before".) - - -File: regex.info, Node: GNU Operators, Next: GNU Emacs Operators, Prev: Common Operators, Up: Top - -GNU Operators -************* - - Following are operators that GNU defines (and POSIX doesn't). - -* Menu: - -* Word Operators:: -* Buffer Operators:: - - -File: regex.info, Node: Word Operators, Next: Buffer Operators, Up: GNU Operators - -Word Operators -============== - - The operators in this section require Regex to recognize parts of -words. Regex uses a syntax table to determine whether or not a -character is part of a word, i.e., whether or not it is -"word-constituent". - -* Menu: - -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W - - -File: regex.info, Node: Non-Emacs Syntax Tables, Next: Match-word-boundary Operator, Up: Word Operators - -Non-Emacs Syntax Tables ------------------------ - - A "syntax table" is an array indexed by the characters in your -character set. In the ASCII encoding, therefore, a syntax table has -256 elements. Regex always uses a `char *' variable `re_syntax_table' -as its syntax table. In some cases, it initializes this variable and -in others it expects you to initialize it. - - * If Regex is compiled with the preprocessor symbols `emacs' and - `SYNTAX_TABLE' both undefined, then Regex allocates - `re_syntax_table' and initializes an element I either to `Sword' - (which it defines) if I is a letter, number, or `_', or to zero if - it's not. - - * If Regex is compiled with `emacs' undefined but `SYNTAX_TABLE' - defined, then Regex expects you to define a `char *' variable - `re_syntax_table' to be a valid syntax table. - - * *Note Emacs Syntax Tables::, for what happens when Regex is - compiled with the preprocessor symbol `emacs' defined. - - -File: regex.info, Node: Match-word-boundary Operator, Next: Match-within-word Operator, Prev: Non-Emacs Syntax Tables, Up: Word Operators - -The Match-word-boundary Operator (`\b') ---------------------------------------- - - This operator (represented by `\b') matches the empty string at -either the beginning or the end of a word. For example, `\brat\b' -matches the separate word `rat'. - - -File: regex.info, Node: Match-within-word Operator, Next: Match-beginning-of-word Operator, Prev: Match-word-boundary Operator, Up: Word Operators - -The Match-within-word Operator (`\B') -------------------------------------- - - This operator (represented by `\B') matches the empty string within a -word. For example, `c\Brat\Be' matches `crate', but `dirty \Brat' -doesn't match `dirty rat'. - - -File: regex.info, Node: Match-beginning-of-word Operator, Next: Match-end-of-word Operator, Prev: Match-within-word Operator, Up: Word Operators - -The Match-beginning-of-word Operator (`\<') -------------------------------------------- - - This operator (represented by `\<') matches the empty string at the -beginning of a word. - - -File: regex.info, Node: Match-end-of-word Operator, Next: Match-word-constituent Operator, Prev: Match-beginning-of-word Operator, Up: Word Operators - -The Match-end-of-word Operator (`\>') -------------------------------------- - - This operator (represented by `\>') matches the empty string at the -end of a word. - - -File: regex.info, Node: Match-word-constituent Operator, Next: Match-non-word-constituent Operator, Prev: Match-end-of-word Operator, Up: Word Operators - -The Match-word-constituent Operator (`\w') ------------------------------------------- - - This operator (represented by `\w') matches any word-constituent -character. - - -File: regex.info, Node: Match-non-word-constituent Operator, Prev: Match-word-constituent Operator, Up: Word Operators - -The Match-non-word-constituent Operator (`\W') ----------------------------------------------- - - This operator (represented by `\W') matches any character that is not -word-constituent. - - -File: regex.info, Node: Buffer Operators, Prev: Word Operators, Up: GNU Operators - -Buffer Operators -================ - - Following are operators which work on buffers. In Emacs, a "buffer" -is, naturally, an Emacs buffer. For other programs, Regex considers the -entire string to be matched as the buffer. - -* Menu: - -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' - - -File: regex.info, Node: Match-beginning-of-buffer Operator, Next: Match-end-of-buffer Operator, Up: Buffer Operators - -The Match-beginning-of-buffer Operator (`\`') ---------------------------------------------- - - This operator (represented by `\`') matches the empty string at the -beginning of the buffer. - - -File: regex.info, Node: Match-end-of-buffer Operator, Prev: Match-beginning-of-buffer Operator, Up: Buffer Operators - -The Match-end-of-buffer Operator (`\'') ---------------------------------------- - - This operator (represented by `\'') matches the empty string at the -end of the buffer. - - -File: regex.info, Node: GNU Emacs Operators, Next: What Gets Matched?, Prev: GNU Operators, Up: Top - -GNU Emacs Operators -******************* - - Following are operators that GNU defines (and POSIX doesn't) that you -can use only when Regex is compiled with the preprocessor symbol -`emacs' defined. - -* Menu: - -* Syntactic Class Operators:: - - -File: regex.info, Node: Syntactic Class Operators, Up: GNU Emacs Operators - -Syntactic Class Operators -========================= - - The operators in this section require Regex to recognize the syntactic -classes of characters. Regex uses a syntax table to determine this. - -* Menu: - -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS - - -File: regex.info, Node: Emacs Syntax Tables, Next: Match-syntactic-class Operator, Up: Syntactic Class Operators - -Emacs Syntax Tables -------------------- - - A "syntax table" is an array indexed by the characters in your -character set. In the ASCII encoding, therefore, a syntax table has -256 elements. - - If Regex is compiled with the preprocessor symbol `emacs' defined, -then Regex expects you to define and initialize the variable -`re_syntax_table' to be an Emacs syntax table. Emacs' syntax tables -are more complicated than Regex's own (*note Non-Emacs Syntax -Tables::.). *Note Syntax: (emacs)Syntax, for a description of Emacs' -syntax tables. - - -File: regex.info, Node: Match-syntactic-class Operator, Next: Match-not-syntactic-class Operator, Prev: Emacs Syntax Tables, Up: Syntactic Class Operators - -The Match-syntactic-class Operator (`\s'CLASS) ----------------------------------------------- - - This operator matches any character whose syntactic class is -represented by a specified character. `\sCLASS' represents this -operator where CLASS is the character representing the syntactic class -you want. For example, `w' represents the syntactic class of -word-constituent characters, so `\sw' matches any word-constituent -character. - - -File: regex.info, Node: Match-not-syntactic-class Operator, Prev: Match-syntactic-class Operator, Up: Syntactic Class Operators - -The Match-not-syntactic-class Operator (`\S'CLASS) --------------------------------------------------- - - This operator is similar to the match-syntactic-class operator except -that it matches any character whose syntactic class is *not* -represented by the specified character. `\SCLASS' represents this -operator. For example, `w' represents the syntactic class of -word-constituent characters, so `\Sw' matches any character that is not -word-constituent. - - -File: regex.info, Node: What Gets Matched?, Next: Programming with Regex, Prev: GNU Emacs Operators, Up: Top - -What Gets Matched? -****************** - - Regex usually matches strings according to the "leftmost longest" -rule; that is, it chooses the longest of the leftmost matches. This -does not mean that for a regular expression containing subexpressions -that it simply chooses the longest match for each subexpression, left to -right; the overall match must also be the longest possible one. - - For example, `(ac*)(c*d[ac]*)\1' matches `acdacaaa', not `acdac', as -it would if it were to choose the longest match for the first -subexpression. - - -File: regex.info, Node: Programming with Regex, Next: Copying, Prev: What Gets Matched?, Up: Top - -Programming with Regex -********************** - - Here we describe how you use the Regex data structures and functions -in C programs. Regex has three interfaces: one designed for GNU, one -compatible with POSIX and one compatible with Berkeley UNIX. - -* Menu: - -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: - - -File: regex.info, Node: GNU Regex Functions, Next: POSIX Regex Functions, Up: Programming with Regex - -GNU Regex Functions -=================== - - If you're writing code that doesn't need to be compatible with either -POSIX or Berkeley UNIX, you can use these functions. They provide more -options than the other interfaces. - -* Menu: - -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () - - -File: regex.info, Node: GNU Pattern Buffers, Next: GNU Regular Expression Compiling, Up: GNU Regex Functions - -GNU Pattern Buffers -------------------- - - To compile, match, or search for a given regular expression, you must -supply a pattern buffer. A "pattern buffer" holds one compiled regular -expression.(1) - - You can have several different pattern buffers simultaneously, each -holding a compiled pattern for a different regular expression. - - `regex.h' defines the pattern buffer `struct' as follows: - - /* Space that holds the compiled pattern. It is declared as - `unsigned char *' because its elements are - sometimes used as array indexes. */ - unsigned char *buffer; - - /* Number of bytes to which `buffer' points. */ - unsigned long allocated; - - /* Number of bytes actually used in `buffer'. */ - unsigned long used; - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t syntax; - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses - the fastmap, if there is one, to skip over impossible - starting points for matches. */ - char *fastmap; - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation - is applied to a pattern when it is compiled and to a string - when it is matched. */ - char *translate; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in `re_search_2', to see - whether or not we should use the fastmap, so we don't set - this absolutely perfectly; see `re_compile_fastmap' (the - `duplicate' case). */ - unsigned can_be_null : 1; - - /* If REGS_UNALLOCATED, allocate space in the `regs' structure - for `max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ - #define REGS_UNALLOCATED 0 - #define REGS_REALLOCATE 1 - #define REGS_FIXED 2 - unsigned regs_allocated : 2; - - /* Set to zero when `regex_compile' compiles a pattern; set to one - by `re_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; - - /* If set, `re_match_2' does not return information about - subexpressions. */ - unsigned no_sub : 1; - - /* If set, a beginning-of-line anchor doesn't match at the - beginning of the string. */ - unsigned not_bol : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned not_eol : 1; - - /* If true, an anchor at a newline matches. */ - unsigned newline_anchor : 1; - - ---------- Footnotes ---------- - - (1) Regular expressions are also referred to as "patterns," hence -the name "pattern buffer." - - -File: regex.info, Node: GNU Regular Expression Compiling, Next: GNU Matching, Prev: GNU Pattern Buffers, Up: GNU Regex Functions - -GNU Regular Expression Compiling --------------------------------- - - In GNU, you can both match and search for a given regular expression. -To do either, you must first compile it in a pattern buffer (*note GNU -Pattern Buffers::.). - - Regular expressions match according to the syntax with which they were -compiled; with GNU, you indicate what syntax you want by setting the -variable `re_syntax_options' (declared in `regex.h' and defined in -`regex.c') before calling the compiling function, `re_compile_pattern' -(see below). *Note Syntax Bits::, and *Note Predefined Syntaxes::. - - You can change the value of `re_syntax_options' at any time. -Usually, however, you set its value once and then never change it. - - `re_compile_pattern' takes a pattern buffer as an argument. You must -initialize the following fields: - -`translate initialization' -`translate' - Initialize this to point to a translate table if you want one, or - to zero if you don't. We explain translate tables in *Note GNU - Translate Tables::. - -`fastmap' - Initialize this to nonzero if you want a fastmap, or to zero if you - don't. - -`buffer' -`allocated' - If you want `re_compile_pattern' to allocate memory for the - compiled pattern, set both of these to zero. If you have an - existing block of memory (allocated with `malloc') you want Regex - to use, set `buffer' to its address and `allocated' to its size (in - bytes). - - `re_compile_pattern' uses `realloc' to extend the space for the - compiled pattern as necessary. - - To compile a pattern buffer, use: - - char * - re_compile_pattern (const char *REGEX, const int REGEX_SIZE, - struct re_pattern_buffer *PATTERN_BUFFER) - -REGEX is the regular expression's address, REGEX_SIZE is its length, -and PATTERN_BUFFER is the pattern buffer's address. - - If `re_compile_pattern' successfully compiles the regular expression, -it returns zero and sets `*PATTERN_BUFFER' to the compiled pattern. It -sets the pattern buffer's fields as follows: - -`buffer' - to the compiled pattern. - -`used' - to the number of bytes the compiled pattern in `buffer' occupies. - -`syntax' - to the current value of `re_syntax_options'. - -`re_nsub' - to the number of subexpressions in REGEX. - -`fastmap_accurate' - to zero on the theory that the pattern you're compiling is - different than the one previously compiled into `buffer'; in that - case (since you can't make a fastmap without a compiled pattern), - `fastmap' would either contain an incompatible fastmap, or nothing - at all. - - If `re_compile_pattern' can't compile REGEX, it returns an error -string corresponding to one of the errors listed in *Note POSIX Regular -Expression Compiling::. - - -File: regex.info, Node: GNU Matching, Next: GNU Searching, Prev: GNU Regular Expression Compiling, Up: GNU Regex Functions - -GNU Matching ------------- - - Matching the GNU way means trying to match as much of a string as -possible starting at a position within it you specify. Once you've -compiled a pattern into a pattern buffer (*note GNU Regular Expression -Compiling::.), you can ask the matcher to match that pattern against a -string using: - - int - re_match (struct re_pattern_buffer *PATTERN_BUFFER, - const char *STRING, const int SIZE, - const int START, struct re_registers *REGS) - -PATTERN_BUFFER is the address of a pattern buffer containing a compiled -pattern. STRING is the string you want to match; it can contain -newline and null characters. SIZE is the length of that string. START -is the string index at which you want to begin matching; the first -character of STRING is at index zero. *Note Using Registers::, for a -explanation of REGS; you can safely pass zero. - - `re_match' matches the regular expression in PATTERN_BUFFER against -the string STRING according to the syntax in PATTERN_BUFFERS's `syntax' -field. (*Note GNU Regular Expression Compiling::, for how to set it.) -The function returns -1 if the compiled pattern does not match any part -of STRING and -2 if an internal error happens; otherwise, it returns -how many (possibly zero) characters of STRING the pattern matched. - - An example: suppose PATTERN_BUFFER points to a pattern buffer -containing the compiled pattern for `a*', and STRING points to `aaaaab' -(whereupon SIZE should be 6). Then if START is 2, `re_match' returns 3, -i.e., `a*' would have matched the last three `a's in STRING. If START -is 0, `re_match' returns 5, i.e., `a*' would have matched all the `a's -in STRING. If START is either 5 or 6, it returns zero. - - If START is not between zero and SIZE, then `re_match' returns -1. - - -File: regex.info, Node: GNU Searching, Next: Matching/Searching with Split Data, Prev: GNU Matching, Up: GNU Regex Functions - -GNU Searching -------------- - - "Searching" means trying to match starting at successive positions -within a string. The function `re_search' does this. - - Before calling `re_search', you must compile your regular expression. -*Note GNU Regular Expression Compiling::. - - Here is the function declaration: - - int - re_search (struct re_pattern_buffer *PATTERN_BUFFER, - const char *STRING, const int SIZE, - const int START, const int RANGE, - struct re_registers *REGS) - -whose arguments are the same as those to `re_match' (*note GNU -Matching::.) except that the two arguments START and RANGE replace -`re_match''s argument START. - - If RANGE is positive, then `re_search' attempts a match starting -first at index START, then at START + 1 if that fails, and so on, up to -START + RANGE; if RANGE is negative, then it attempts a match starting -first at index START, then at START -1 if that fails, and so on. - - If START is not between zero and SIZE, then `re_search' returns -1. -When RANGE is positive, `re_search' adjusts RANGE so that START + RANGE -- 1 is between zero and SIZE, if necessary; that way it won't search -outside of STRING. Similarly, when RANGE is negative, `re_search' -adjusts RANGE so that START + RANGE + 1 is between zero and SIZE, if -necessary. - - If the `fastmap' field of PATTERN_BUFFER is zero, `re_search' matches -starting at consecutive positions; otherwise, it uses `fastmap' to make -the search more efficient. *Note Searching with Fastmaps::. - - If no match is found, `re_search' returns -1. If a match is found, -it returns the index where the match began. If an internal error -happens, it returns -2. - - -File: regex.info, Node: Matching/Searching with Split Data, Next: Searching with Fastmaps, Prev: GNU Searching, Up: GNU Regex Functions - -Matching and Searching with Split Data --------------------------------------- - - Using the functions `re_match_2' and `re_search_2', you can match or -search in data that is divided into two strings. - - The function: - - int - re_match_2 (struct re_pattern_buffer *BUFFER, - const char *STRING1, const int SIZE1, - const char *STRING2, const int SIZE2, - const int START, - struct re_registers *REGS, - const int STOP) - -is similar to `re_match' (*note GNU Matching::.) except that you pass -*two* data strings and sizes, and an index STOP beyond which you don't -want the matcher to try matching. As with `re_match', if it succeeds, -`re_match_2' returns how many characters of STRING it matched. Regard -STRING1 and STRING2 as concatenated when you set the arguments START and -STOP and use the contents of REGS; `re_match_2' never returns a value -larger than SIZE1 + SIZE2. - - The function: - - int - re_search_2 (struct re_pattern_buffer *BUFFER, - const char *STRING1, const int SIZE1, - const char *STRING2, const int SIZE2, - const int START, const int RANGE, - struct re_registers *REGS, - const int STOP) - -is similarly related to `re_search'. - - -File: regex.info, Node: Searching with Fastmaps, Next: GNU Translate Tables, Prev: Matching/Searching with Split Data, Up: GNU Regex Functions - -Searching with Fastmaps ------------------------ - - If you're searching through a long string, you should use a fastmap. -Without one, the searcher tries to match at consecutive positions in the -string. Generally, most of the characters in the string could not start -a match. It takes much longer to try matching at a given position in -the string than it does to check in a table whether or not the -character at that position could start a match. A "fastmap" is such a -table. - - More specifically, a fastmap is an array indexed by the characters in -your character set. Under the ASCII encoding, therefore, a fastmap has -256 elements. If you want the searcher to use a fastmap with a given -pattern buffer, you must allocate the array and assign the array's -address to the pattern buffer's `fastmap' field. You either can -compile the fastmap yourself or have `re_search' do it for you; when -`fastmap' is nonzero, it automatically compiles a fastmap the first -time you search using a particular compiled pattern. - - To compile a fastmap yourself, use: - - int - re_compile_fastmap (struct re_pattern_buffer *PATTERN_BUFFER) - -PATTERN_BUFFER is the address of a pattern buffer. If the character C -could start a match for the pattern, `re_compile_fastmap' makes -`PATTERN_BUFFER->fastmap[C]' nonzero. It returns 0 if it can compile a -fastmap and -2 if there is an internal error. For example, if `|' is -the alternation operator and PATTERN_BUFFER holds the compiled pattern -for `a|b', then `re_compile_fastmap' sets `fastmap['a']' and -`fastmap['b']' (and no others). - - `re_search' uses a fastmap as it moves along in the string: it checks -the string's characters until it finds one that's in the fastmap. Then -it tries matching at that character. If the match fails, it repeats -the process. So, by using a fastmap, `re_search' doesn't waste time -trying to match at positions in the string that couldn't start a match. - - If you don't want `re_search' to use a fastmap, store zero in the -`fastmap' field of the pattern buffer before calling `re_search'. - - Once you've initialized a pattern buffer's `fastmap' field, you need -never do so again--even if you compile a new pattern in it--provided -the way the field is set still reflects whether or not you want a -fastmap. `re_search' will still either do nothing if `fastmap' is null -or, if it isn't, compile a new fastmap for the new pattern. - - -File: regex.info, Node: GNU Translate Tables, Next: Using Registers, Prev: Searching with Fastmaps, Up: GNU Regex Functions - -GNU Translate Tables --------------------- - - If you set the `translate' field of a pattern buffer to a translate -table, then the GNU Regex functions to which you've passed that pattern -buffer use it to apply a simple transformation to all the regular -expression and string characters at which they look. - - A "translate table" is an array indexed by the characters in your -character set. Under the ASCII encoding, therefore, a translate table -has 256 elements. The array's elements are also characters in your -character set. When the Regex functions see a character C, they use -`translate[C]' in its place, with one exception: the character after a -`\' is not translated. (This ensures that, the operators, e.g., `\B' -and `\b', are always distinguishable.) - - For example, a table that maps all lowercase letters to the -corresponding uppercase ones would cause the matcher to ignore -differences in case.(1) Such a table would map all characters except -lowercase letters to themselves, and lowercase letters to the -corresponding uppercase ones. Under the ASCII encoding, here's how you -could initialize such a table (we'll call it `case_fold'): - - for (i = 0; i < 256; i++) - case_fold[i] = i; - for (i = 'a'; i <= 'z'; i++) - case_fold[i] = i - ('a' - 'A'); - - You tell Regex to use a translate table on a given pattern buffer by -assigning that table's address to the `translate' field of that buffer. -If you don't want Regex to do any translation, put zero into this -field. You'll get weird results if you change the table's contents -anytime between compiling the pattern buffer, compiling its fastmap, and -matching or searching with the pattern buffer. - - ---------- Footnotes ---------- - - (1) A table that maps all uppercase letters to the corresponding -lowercase ones would work just as well for this purpose. - - -File: regex.info, Node: Using Registers, Next: Freeing GNU Pattern Buffers, Prev: GNU Translate Tables, Up: GNU Regex Functions - -Using Registers ---------------- - - A group in a regular expression can match a (posssibly empty) -substring of the string that regular expression as a whole matched. -The matcher remembers the beginning and end of the substring matched by -each group. - - To find out what they matched, pass a nonzero REGS argument to a GNU -matching or searching function (*note GNU Matching::. and *Note GNU -Searching::), i.e., the address of a structure of this type, as defined -in `regex.h': - - struct re_registers - { - unsigned num_regs; - regoff_t *start; - regoff_t *end; - }; - - Except for (possibly) the NUM_REGS'th element (see below), the Ith -element of the `start' and `end' arrays records information about the -Ith group in the pattern. (They're declared as C pointers, but this is -only because not all C compilers accept zero-length arrays; -conceptually, it is simplest to think of them as arrays.) - - The `start' and `end' arrays are allocated in various ways, depending -on the value of the `regs_allocated' field in the pattern buffer passed -to the matcher. - - The simplest and perhaps most useful is to let the matcher -(re)allocate enough space to record information for all the groups in -the regular expression. If `regs_allocated' is `REGS_UNALLOCATED', the -matcher allocates 1 + RE_NSUB (another field in the pattern buffer; -*note GNU Pattern Buffers::.). The extra element is set to -1, and -sets `regs_allocated' to `REGS_REALLOCATE'. Then on subsequent calls -with the same pattern buffer and REGS arguments, the matcher -reallocates more space if necessary. - - It would perhaps be more logical to make the `regs_allocated' field -part of the `re_registers' structure, instead of part of the pattern -buffer. But in that case the caller would be forced to initialize the -structure before passing it. Much existing code doesn't do this -initialization, and it's arguably better to avoid it anyway. - - `re_compile_pattern' sets `regs_allocated' to `REGS_UNALLOCATED', so -if you use the GNU regular expression functions, you get this behavior -by default. - - xx document re_set_registers - - POSIX, on the other hand, requires a different interface: the caller -is supposed to pass in a fixed-length array which the matcher fills. -Therefore, if `regs_allocated' is `REGS_FIXED' the matcher simply fills -that array. - - The following examples illustrate the information recorded in the -`re_registers' structure. (In all of them, `(' represents the -open-group and `)' the close-group operator. The first character in -the string STRING is at index 0.) - - * If the regular expression has an I-th group not contained within - another group that matches a substring of STRING, then the - function sets `REGS->start[I]' to the index in STRING where the - substring matched by the I-th group begins, and `REGS->end[I]' to - the index just beyond that substring's end. The function sets - `REGS->start[0]' and `REGS->end[0]' to analogous information about - the entire pattern. - - For example, when you match `((a)(b))' against `ab', you get: - - * 0 in `REGS->start[0]' and 2 in `REGS->end[0]' - - * 0 in `REGS->start[1]' and 2 in `REGS->end[1]' - - * 0 in `REGS->start[2]' and 1 in `REGS->end[2]' - - * 1 in `REGS->start[3]' and 2 in `REGS->end[3]' - - * If a group matches more than once (as it might if followed by, - e.g., a repetition operator), then the function reports the - information about what the group *last* matched. - - For example, when you match the pattern `(a)*' against the string - `aa', you get: - - * 0 in `REGS->start[0]' and 2 in `REGS->end[0]' - - * 1 in `REGS->start[1]' and 2 in `REGS->end[1]' - - * If the I-th group does not participate in a successful match, - e.g., it is an alternative not taken or a repetition operator - allows zero repetitions of it, then the function sets - `REGS->start[I]' and `REGS->end[I]' to -1. - - For example, when you match the pattern `(a)*b' against the string - `b', you get: - - * 0 in `REGS->start[0]' and 1 in `REGS->end[0]' - - * -1 in `REGS->start[1]' and -1 in `REGS->end[1]' - - * If the I-th group matches a zero-length string, then the function - sets `REGS->start[I]' and `REGS->end[I]' to the index just beyond - that zero-length string. - - For example, when you match the pattern `(a*)b' against the string - `b', you get: - - * 0 in `REGS->start[0]' and 1 in `REGS->end[0]' - - * 0 in `REGS->start[1]' and 0 in `REGS->end[1]' - - * If an I-th group contains a J-th group in turn not contained - within any other group within group I and the function reports a - match of the I-th group, then it records in `REGS->start[J]' and - `REGS->end[J]' the last match (if it matched) of the J-th group. - - For example, when you match the pattern `((a*)b)*' against the - string `abb', group 2 last matches the empty string, so you get - what it previously matched: - - * 0 in `REGS->start[0]' and 3 in `REGS->end[0]' - - * 2 in `REGS->start[1]' and 3 in `REGS->end[1]' - - * 2 in `REGS->start[2]' and 2 in `REGS->end[2]' - - When you match the pattern `((a)*b)*' against the string `abb', - group 2 doesn't participate in the last match, so you get: - - * 0 in `REGS->start[0]' and 3 in `REGS->end[0]' - - * 2 in `REGS->start[1]' and 3 in `REGS->end[1]' - - * 0 in `REGS->start[2]' and 1 in `REGS->end[2]' - - * If an I-th group contains a J-th group in turn not contained - within any other group within group I and the function sets - `REGS->start[I]' and `REGS->end[I]' to -1, then it also sets - `REGS->start[J]' and `REGS->end[J]' to -1. - - For example, when you match the pattern `((a)*b)*c' against the - string `c', you get: - - * 0 in `REGS->start[0]' and 1 in `REGS->end[0]' - - * -1 in `REGS->start[1]' and -1 in `REGS->end[1]' - - * -1 in `REGS->start[2]' and -1 in `REGS->end[2]' - - -File: regex.info, Node: Freeing GNU Pattern Buffers, Prev: Using Registers, Up: GNU Regex Functions - -Freeing GNU Pattern Buffers ---------------------------- - - To free any allocated fields of a pattern buffer, you can use the -POSIX function described in *Note Freeing POSIX Pattern Buffers::, -since the type `regex_t'--the type for POSIX pattern buffers--is -equivalent to the type `re_pattern_buffer'. After freeing a pattern -buffer, you need to again compile a regular expression in it (*note GNU -Regular Expression Compiling::.) before passing it to a matching or -searching function. - - -File: regex.info, Node: POSIX Regex Functions, Next: BSD Regex Functions, Prev: GNU Regex Functions, Up: Programming with Regex - -POSIX Regex Functions -===================== - - If you're writing code that has to be POSIX compatible, you'll need -to use these functions. Their interfaces are as specified by POSIX, -draft 1003.2/D11.2. - -* Menu: - -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () - - -File: regex.info, Node: POSIX Pattern Buffers, Next: POSIX Regular Expression Compiling, Up: POSIX Regex Functions - -POSIX Pattern Buffers ---------------------- - - To compile or match a given regular expression the POSIX way, you -must supply a pattern buffer exactly the way you do for GNU (*note GNU -Pattern Buffers::.). POSIX pattern buffers have type `regex_t', which -is equivalent to the GNU pattern buffer type `re_pattern_buffer'. - - -File: regex.info, Node: POSIX Regular Expression Compiling, Next: POSIX Matching, Prev: POSIX Pattern Buffers, Up: POSIX Regex Functions - -POSIX Regular Expression Compiling ----------------------------------- - - With POSIX, you can only search for a given regular expression; you -can't match it. To do this, you must first compile it in a pattern -buffer, using `regcomp'. - - To compile a pattern buffer, use: - - int - regcomp (regex_t *PREG, const char *REGEX, int CFLAGS) - -PREG is the initialized pattern buffer's address, REGEX is the regular -expression's address, and CFLAGS is the compilation flags, which Regex -considers as a collection of bits. Here are the valid bits, as defined -in `regex.h': - -`REG_EXTENDED' - says to use POSIX Extended Regular Expression syntax; if this isn't - set, then says to use POSIX Basic Regular Expression syntax. - `regcomp' sets PREG's `syntax' field accordingly. - -`REG_ICASE' - says to ignore case; `regcomp' sets PREG's `translate' field to a - translate table which ignores case, replacing anything you've put - there before. - -`REG_NOSUB' - says to set PREG's `no_sub' field; *note POSIX Matching::., for - what this means. - -`REG_NEWLINE' - says that a: - - * match-any-character operator (*note Match-any-character - Operator::.) doesn't match a newline. - - * nonmatching list not containing a newline (*note List - Operators::.) matches a newline. - - * match-beginning-of-line operator (*note - Match-beginning-of-line Operator::.) matches the empty string - immediately after a newline, regardless of how `REG_NOTBOL' - is set (*note POSIX Matching::., for an explanation of - `REG_NOTBOL'). - - * match-end-of-line operator (*note Match-beginning-of-line - Operator::.) matches the empty string immediately before a - newline, regardless of how `REG_NOTEOL' is set (*note POSIX - Matching::., for an explanation of `REG_NOTEOL'). - - If `regcomp' successfully compiles the regular expression, it returns -zero and sets `*PATTERN_BUFFER' to the compiled pattern. Except for -`syntax' (which it sets as explained above), it also sets the same -fields the same way as does the GNU compiling function (*note GNU -Regular Expression Compiling::.). - - If `regcomp' can't compile the regular expression, it returns one of -the error codes listed here. (Except when noted differently, the -syntax of in all examples below is basic regular expression syntax.) - -`REG_BADRPT' - For example, the consecutive repetition operators `**' in `a**' - are invalid. As another example, if the syntax is extended - regular expression syntax, then the repetition operator `*' with - nothing on which to operate in `*' is invalid. - -`REG_BADBR' - For example, the COUNT `-1' in `a\{-1' is invalid. - -`REG_EBRACE' - For example, `a\{1' is missing a close-interval operator. - -`REG_EBRACK' - For example, `[a' is missing a close-list operator. - -`REG_ERANGE' - For example, the range ending point `z' that collates lower than - does its starting point `a' in `[z-a]' is invalid. Also, the - range with the character class `[:alpha:]' as its starting point in - `[[:alpha:]-|]'. - -`REG_ECTYPE' - For example, the character class name `foo' in `[[:foo:]' is - invalid. - -`REG_EPAREN' - For example, `a\)' is missing an open-group operator and `\(a' is - missing a close-group operator. - -`REG_ESUBREG' - For example, the back reference `\2' that refers to a nonexistent - subexpression in `\(a\)\2' is invalid. - -`REG_EEND' - Returned when a regular expression causes no other more specific - error. - -`REG_EESCAPE' - For example, the trailing backslash `\' in `a\' is invalid, as is - the one in `\'. - -`REG_BADPAT' - For example, in the extended regular expression syntax, the empty - group `()' in `a()b' is invalid. - -`REG_ESIZE' - Returned when a regular expression needs a pattern buffer larger - than 65536 bytes. - -`REG_ESPACE' - Returned when a regular expression makes Regex to run out of - memory. - - -File: regex.info, Node: POSIX Matching, Next: Reporting Errors, Prev: POSIX Regular Expression Compiling, Up: POSIX Regex Functions - -POSIX Matching --------------- - - Matching the POSIX way means trying to match a null-terminated string -starting at its first character. Once you've compiled a pattern into a -pattern buffer (*note POSIX Regular Expression Compiling::.), you can -ask the matcher to match that pattern against a string using: - - int - regexec (const regex_t *PREG, const char *STRING, - size_t NMATCH, regmatch_t PMATCH[], int EFLAGS) - -PREG is the address of a pattern buffer for a compiled pattern. STRING -is the string you want to match. - - *Note Using Byte Offsets::, for an explanation of PMATCH. If you -pass zero for NMATCH or you compiled PREG with the compilation flag -`REG_NOSUB' set, then `regexec' will ignore PMATCH; otherwise, you must -allocate it to have at least NMATCH elements. `regexec' will record -NMATCH byte offsets in PMATCH, and set to -1 any unused elements up to -PMATCH`[NMATCH]' - 1. - - EFLAGS specifies "execution flags"--namely, the two bits `REG_NOTBOL' -and `REG_NOTEOL' (defined in `regex.h'). If you set `REG_NOTBOL', then -the match-beginning-of-line operator (*note Match-beginning-of-line -Operator::.) always fails to match. This lets you match against pieces -of a line, as you would need to if, say, searching for repeated -instances of a given pattern in a line; it would work correctly for -patterns both with and without match-beginning-of-line operators. -`REG_NOTEOL' works analogously for the match-end-of-line operator -(*note Match-end-of-line Operator::.); it exists for symmetry. - - `regexec' tries to find a match for PREG in STRING according to the -syntax in PREG's `syntax' field. (*Note POSIX Regular Expression -Compiling::, for how to set it.) The function returns zero if the -compiled pattern matches STRING and `REG_NOMATCH' (defined in -`regex.h') if it doesn't. - - -File: regex.info, Node: Reporting Errors, Next: Using Byte Offsets, Prev: POSIX Matching, Up: POSIX Regex Functions - -Reporting Errors ----------------- - - If either `regcomp' or `regexec' fail, they return a nonzero error -code, the possibilities for which are defined in `regex.h'. *Note -POSIX Regular Expression Compiling::, and *Note POSIX Matching::, for -what these codes mean. To get an error string corresponding to these -codes, you can use: - - size_t - regerror (int ERRCODE, - const regex_t *PREG, - char *ERRBUF, - size_t ERRBUF_SIZE) - -ERRCODE is an error code, PREG is the address of the pattern buffer -which provoked the error, ERRBUF is the error buffer, and ERRBUF_SIZE -is ERRBUF's size. - - `regerror' returns the size in bytes of the error string -corresponding to ERRCODE (including its terminating null). If ERRBUF -and ERRBUF_SIZE are nonzero, it also returns in ERRBUF the first -ERRBUF_SIZE - 1 characters of the error string, followed by a null. -eRRBUF_SIZE must be a nonnegative number less than or equal to the size -in bytes of ERRBUF. - - You can call `regerror' with a null ERRBUF and a zero ERRBUF_SIZE to -determine how large ERRBUF need be to accommodate `regerror''s error -string. - - -File: regex.info, Node: Using Byte Offsets, Next: Freeing POSIX Pattern Buffers, Prev: Reporting Errors, Up: POSIX Regex Functions - -Using Byte Offsets ------------------- - - In POSIX, variables of type `regmatch_t' hold analogous information, -but are not identical to, GNU's registers (*note Using Registers::.). -To get information about registers in POSIX, pass to `regexec' a -nonzero PMATCH of type `regmatch_t', i.e., the address of a structure -of this type, defined in `regex.h': - - typedef struct - { - regoff_t rm_so; - regoff_t rm_eo; - } regmatch_t; - - When reading in *Note Using Registers::, about how the matching -function stores the information into the registers, substitute PMATCH -for REGS, `PMATCH[I]->rm_so' for `REGS->start[I]' and -`PMATCH[I]->rm_eo' for `REGS->end[I]'. - - -File: regex.info, Node: Freeing POSIX Pattern Buffers, Prev: Using Byte Offsets, Up: POSIX Regex Functions - -Freeing POSIX Pattern Buffers ------------------------------ - - To free any allocated fields of a pattern buffer, use: - - void - regfree (regex_t *PREG) - -PREG is the pattern buffer whose allocated fields you want freed. -`regfree' also sets PREG's `allocated' and `used' fields to zero. -After freeing a pattern buffer, you need to again compile a regular -expression in it (*note POSIX Regular Expression Compiling::.) before -passing it to the matching function (*note POSIX Matching::.). - - -File: regex.info, Node: BSD Regex Functions, Prev: POSIX Regex Functions, Up: Programming with Regex - -BSD Regex Functions -=================== - - If you're writing code that has to be Berkeley UNIX compatible, -you'll need to use these functions whose interfaces are the same as -those in Berkeley UNIX. - -* Menu: - -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () - - -File: regex.info, Node: BSD Regular Expression Compiling, Next: BSD Searching, Up: BSD Regex Functions - -BSD Regular Expression Compiling --------------------------------- - - With Berkeley UNIX, you can only search for a given regular -expression; you can't match one. To search for it, you must first -compile it. Before you compile it, you must indicate the regular -expression syntax you want it compiled according to by setting the -variable `re_syntax_options' (declared in `regex.h' to some syntax -(*note Regular Expression Syntax::.). - - To compile a regular expression use: - - char * - re_comp (char *REGEX) - -REGEX is the address of a null-terminated regular expression. -`re_comp' uses an internal pattern buffer, so you can use only the most -recently compiled pattern buffer. This means that if you want to use a -given regular expression that you've already compiled--but it isn't the -latest one you've compiled--you'll have to recompile it. If you call -`re_comp' with the null string (*not* the empty string) as the -argument, it doesn't change the contents of the pattern buffer. - - If `re_comp' successfully compiles the regular expression, it returns -zero. If it can't compile the regular expression, it returns an error -string. `re_comp''s error messages are identical to those of -`re_compile_pattern' (*note GNU Regular Expression Compiling::.). - - -File: regex.info, Node: BSD Searching, Prev: BSD Regular Expression Compiling, Up: BSD Regex Functions - -BSD Searching -------------- - - Searching the Berkeley UNIX way means searching in a string starting -at its first character and trying successive positions within it to -find a match. Once you've compiled a pattern using `re_comp' (*note -BSD Regular Expression Compiling::.), you can ask Regex to search for -that pattern in a string using: - - int - re_exec (char *STRING) - -STRING is the address of the null-terminated string in which you want -to search. - - `re_exec' returns either 1 for success or 0 for failure. It -automatically uses a GNU fastmap (*note Searching with Fastmaps::.). - - -File: regex.info, Node: Copying, Next: Index, Prev: Programming with Regex, Up: Top - -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. - - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 1. 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. - - 2. 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. - - 3. 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. - - 4. 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. - - 5. 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. - - 6. 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. - - 7. 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. - - 8. 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. - - 9. 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. - - 10. 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. - - 11. 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 - - 12. 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. - - 13. 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. - - ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. - Copyright (C) 19YY NAME OF AUTHOR - - 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. - - SIGNATURE OF TY COON, 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. - - -File: regex.info, Node: Index, Prev: Copying, Up: Top - -Index -***** - -* Menu: - -* $: Match-end-of-line Operator. -* (: Grouping Operators. -* ): Grouping Operators. -* *: Match-zero-or-more Operator. -* +: Match-one-or-more Operator. -* -: List Operators. -* .: Match-any-character Operator. -* :] in regex: Character Class Operators. -* ?: Match-zero-or-one Operator. -* {: Interval Operators. -* }: Interval Operators. -* [: in regex: Character Class Operators. -* [^: List Operators. -* [: List Operators. -* \': Match-end-of-buffer Operator. -* \<: Match-beginning-of-word Operator. -* \>: Match-end-of-word Operator. -* \{: Interval Operators. -* \}: Interval Operators. -* \b: Match-word-boundary Operator. -* \B: Match-within-word Operator. -* \s: Match-syntactic-class Operator. -* \S: Match-not-syntactic-class Operator. -* \w: Match-word-constituent Operator. -* \W: Match-non-word-constituent Operator. -* \`: Match-beginning-of-buffer Operator. -* \: List Operators. -* ]: List Operators. -* ^: List Operators. -* allocated initialization: GNU Regular Expression Compiling. -* alternation operator: Alternation Operator. -* alternation operator and ^: Match-beginning-of-line Operator. -* anchoring: Anchoring Operators. -* anchors: Match-end-of-line Operator. -* anchors: Match-beginning-of-line Operator. -* Awk: Predefined Syntaxes. -* back references: Back-reference Operator. -* backtracking: Match-zero-or-more Operator. -* backtracking: Alternation Operator. -* beginning-of-line operator: Match-beginning-of-line Operator. -* bracket expression: List Operators. -* buffer field, set by re_compile_pattern: GNU Regular Expression Compiling. -* buffer initialization: GNU Regular Expression Compiling. -* character classes: Character Class Operators. -* Egrep: Predefined Syntaxes. -* Emacs: Predefined Syntaxes. -* end in struct re_registers: Using Registers. -* end-of-line operator: Match-end-of-line Operator. -* fastmap initialization: GNU Regular Expression Compiling. -* fastmaps: Searching with Fastmaps. -* fastmap_accurate field, set by re_compile_pattern: GNU Regular Expression Compiling. -* Grep: Predefined Syntaxes. -* grouping: Grouping Operators. -* ignoring case: POSIX Regular Expression Compiling. -* interval expression: Interval Operators. -* matching list: List Operators. -* matching newline: List Operators. -* matching with GNU functions: GNU Matching. -* newline_anchor field in pattern buffer: Match-beginning-of-line Operator. -* nonmatching list: List Operators. -* not_bol field in pattern buffer: Match-beginning-of-line Operator. -* num_regs in struct re_registers: Using Registers. -* open-group operator and ^: Match-beginning-of-line Operator. -* or operator: Alternation Operator. -* parenthesizing: Grouping Operators. -* pattern buffer initialization: GNU Regular Expression Compiling. -* pattern buffer, definition of: GNU Pattern Buffers. -* POSIX Awk: Predefined Syntaxes. -* range argument to re_search: GNU Searching. -* regex.c: Overview. -* regex.h: Overview. -* regexp anchoring: Anchoring Operators. -* regmatch_t: Using Byte Offsets. -* regs_allocated: Using Registers. -* REGS_FIXED: Using Registers. -* REGS_REALLOCATE: Using Registers. -* REGS_UNALLOCATED: Using Registers. -* regular expressions, syntax of: Regular Expression Syntax. -* REG_EXTENDED: POSIX Regular Expression Compiling. -* REG_ICASE: POSIX Regular Expression Compiling. -* REG_NEWLINE: POSIX Regular Expression Compiling. -* REG_NOSUB: POSIX Regular Expression Compiling. -* RE_BACKSLASH_ESCAPE_IN_LIST: Syntax Bits. -* RE_BK_PLUS_QM: Syntax Bits. -* RE_CHAR_CLASSES: Syntax Bits. -* RE_CONTEXT_INDEP_ANCHORS: Syntax Bits. -* RE_CONTEXT_INDEP_ANCHORS (and ^): Match-beginning-of-line Operator. -* RE_CONTEXT_INDEP_OPS: Syntax Bits. -* RE_CONTEXT_INVALID_OPS: Syntax Bits. -* RE_DOT_NEWLINE: Syntax Bits. -* RE_DOT_NOT_NULL: Syntax Bits. -* RE_INTERVALS: Syntax Bits. -* RE_LIMITED_OPS: Syntax Bits. -* RE_NEWLINE_ALT: Syntax Bits. -* RE_NO_BK_BRACES: Syntax Bits. -* RE_NO_BK_PARENS: Syntax Bits. -* RE_NO_BK_REFS: Syntax Bits. -* RE_NO_BK_VBAR: Syntax Bits. -* RE_NO_EMPTY_RANGES: Syntax Bits. -* re_nsub field, set by re_compile_pattern: GNU Regular Expression Compiling. -* re_pattern_buffer definition: GNU Pattern Buffers. -* re_registers: Using Registers. -* re_syntax_options initialization: GNU Regular Expression Compiling. -* RE_UNMATCHED_RIGHT_PAREN_ORD: Syntax Bits. -* searching with GNU functions: GNU Searching. -* start argument to re_search: GNU Searching. -* start in struct re_registers: Using Registers. -* struct re_pattern_buffer definition: GNU Pattern Buffers. -* subexpressions: Grouping Operators. -* syntax field, set by re_compile_pattern: GNU Regular Expression Compiling. -* syntax bits: Syntax Bits. -* syntax initialization: GNU Regular Expression Compiling. -* syntax of regular expressions: Regular Expression Syntax. -* translate initialization: GNU Regular Expression Compiling. -* used field, set by re_compile_pattern: GNU Regular Expression Compiling. -* word boundaries, matching: Match-word-boundary Operator. -* \: The Backslash Character. -* \(: Grouping Operators. -* \): Grouping Operators. -* \|: Alternation Operator. -* ^: Match-beginning-of-line Operator. -* |: Alternation Operator. - - - -Tag Table: -Node: Top1064 -Node: Overview4562 -Node: Regular Expression Syntax6746 -Node: Syntax Bits7916 -Node: Predefined Syntaxes14018 -Node: Collating Elements vs. Characters17872 -Node: The Backslash Character18835 -Node: Common Operators21992 -Node: Match-self Operator23445 -Node: Match-any-character Operator23941 -Node: Concatenation Operator24520 -Node: Repetition Operators25017 -Node: Match-zero-or-more Operator25436 -Node: Match-one-or-more Operator27483 -Node: Match-zero-or-one Operator28341 -Node: Interval Operators29196 -Node: Alternation Operator30991 -Node: List Operators32489 -Node: Character Class Operators35272 -Node: Range Operator36901 -Node: Grouping Operators38930 -Node: Back-reference Operator40251 -Node: Anchoring Operators43073 -Node: Match-beginning-of-line Operator43447 -Node: Match-end-of-line Operator44779 -Node: GNU Operators45518 -Node: Word Operators45767 -Node: Non-Emacs Syntax Tables46391 -Node: Match-word-boundary Operator47465 -Node: Match-within-word Operator47858 -Node: Match-beginning-of-word Operator48255 -Node: Match-end-of-word Operator48588 -Node: Match-word-constituent Operator48908 -Node: Match-non-word-constituent Operator49234 -Node: Buffer Operators49545 -Node: Match-beginning-of-buffer Operator49952 -Node: Match-end-of-buffer Operator50264 -Node: GNU Emacs Operators50558 -Node: Syntactic Class Operators50901 -Node: Emacs Syntax Tables51307 -Node: Match-syntactic-class Operator51963 -Node: Match-not-syntactic-class Operator52560 -Node: What Gets Matched?53150 -Node: Programming with Regex53799 -Node: GNU Regex Functions54237 -Node: GNU Pattern Buffers55078 -Node: GNU Regular Expression Compiling58303 -Node: GNU Matching61181 -Node: GNU Searching63101 -Node: Matching/Searching with Split Data64913 -Node: Searching with Fastmaps66369 -Node: GNU Translate Tables68921 -Node: Using Registers70892 -Node: Freeing GNU Pattern Buffers77000 -Node: POSIX Regex Functions77593 -Node: POSIX Pattern Buffers78266 -Node: POSIX Regular Expression Compiling78709 -Node: POSIX Matching82836 -Node: Reporting Errors84791 -Node: Using Byte Offsets86048 -Node: Freeing POSIX Pattern Buffers86861 -Node: BSD Regex Functions87467 -Node: BSD Regular Expression Compiling87886 -Node: BSD Searching89258 -Node: Copying89960 -Node: Index109122 - -End Tag Table diff --git a/gnu/lib/regex-0.12/doc/regex.texi b/gnu/lib/regex-0.12/doc/regex.texi deleted file mode 100644 index d93953ece20c..000000000000 --- a/gnu/lib/regex-0.12/doc/regex.texi +++ /dev/null @@ -1,3138 +0,0 @@ -\input texinfo -@c %**start of header -@setfilename regex.info -@settitle Regex -@c %**end of header - -@c \\{fill-paragraph} works better (for me, anyway) if the text in the -@c source file isn't indented. -@paragraphindent 2 - -@c Define a new index for our magic constants. -@defcodeindex cn - -@c Put everything in one index (arbitrarily chosen to be the concept index). -@syncodeindex cn cp -@syncodeindex ky cp -@syncodeindex pg cp -@syncodeindex tp cp -@syncodeindex vr cp - -@c Here is what we use in the Info `dir' file: -@c * Regex: (regex). Regular expression library. - - -@ifinfo -This file documents the GNU regular expression library. - -Copyright (C) 1992, 1993 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 a 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 also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and 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 the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end ifinfo - - -@titlepage - -@title Regex -@subtitle edition 0.12a -@subtitle 19 September 1992 -@author Kathryn A. Hargreaves -@author Karl Berry - -@page - -@vskip 0pt plus 1filll -Copyright @copyright{} 1992 Free Software Foundation. - -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 also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and 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 the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. - -@end titlepage - - -@ifinfo -@node Top, Overview, (dir), (dir) -@top Regular Expression Library - -This manual documents how to program with the GNU regular expression -library. This is edition 0.12a of the manual, 19 September 1992. - -The first part of this master menu lists the major nodes in this Info -document, including the index. The rest of the menu lists all the -lower level nodes in the document. - -@menu -* Overview:: -* Regular Expression Syntax:: -* Common Operators:: -* GNU Operators:: -* GNU Emacs Operators:: -* What Gets Matched?:: -* Programming with Regex:: -* Copying:: Copying and sharing Regex. -* Index:: General index. - --- The Detailed Node Listing --- - -Regular Expression Syntax - -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: - -Common Operators - -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? @{@} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ - -Repetition Operators - -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: @{@} - -List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]}) - -* Character Class Operators:: [:class:] -* Range Operator:: start-end - -Anchoring Operators - -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ - -GNU Operators - -* Word Operators:: -* Buffer Operators:: - -Word Operators - -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W - -Buffer Operators - -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' - -GNU Emacs Operators - -* Syntactic Class Operators:: - -Syntactic Class Operators - -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS - -Programming with Regex - -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: - -GNU Regex Functions - -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () - -POSIX Regex Functions - -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () - -BSD Regex Functions - -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () -@end menu -@end ifinfo -@node Overview, Regular Expression Syntax, Top, Top -@chapter Overview - -A @dfn{regular expression} (or @dfn{regexp}, or @dfn{pattern}) is a text -string that describes some (mathematical) set of strings. A regexp -@var{r} @dfn{matches} a string @var{s} if @var{s} is in the set of -strings described by @var{r}. - -Using the Regex library, you can: - -@itemize @bullet - -@item -see if a string matches a specified pattern as a whole, and - -@item -search within a string for a substring matching a specified pattern. - -@end itemize - -Some regular expressions match only one string, i.e., the set they -describe has only one member. For example, the regular expression -@samp{foo} matches the string @samp{foo} and no others. Other regular -expressions match more than one string, i.e., the set they describe has -more than one member. For example, the regular expression @samp{f*} -matches the set of strings made up of any number (including zero) of -@samp{f}s. As you can see, some characters in regular expressions match -themselves (such as @samp{f}) and some don't (such as @samp{*}); the -ones that don't match themselves instead let you specify patterns that -describe many different strings. - -To either match or search for a regular expression with the Regex -library functions, you must first compile it with a Regex pattern -compiling function. A @dfn{compiled pattern} is a regular expression -converted to the internal format used by the library functions. Once -you've compiled a pattern, you can use it for matching or searching any -number of times. - -The Regex library consists of two source files: @file{regex.h} and -@file{regex.c}. -@pindex regex.h -@pindex regex.c -Regex provides three groups of functions with which you can operate on -regular expressions. One group---the @sc{gnu} group---is more powerful -but not completely compatible with the other two, namely the @sc{posix} -and Berkeley @sc{unix} groups; its interface was designed specifically -for @sc{gnu}. The other groups have the same interfaces as do the -regular expression functions in @sc{posix} and Berkeley -@sc{unix}. - -We wrote this chapter with programmers in mind, not users of -programs---such as Emacs---that use Regex. We describe the Regex -library in its entirety, not how to write regular expressions that a -particular program understands. - - -@node Regular Expression Syntax, Common Operators, Overview, Top -@chapter Regular Expression Syntax - -@cindex regular expressions, syntax of -@cindex syntax of regular expressions - -@dfn{Characters} are things you can type. @dfn{Operators} are things in -a regular expression that match one or more characters. You compose -regular expressions from operators, which in turn you specify using one -or more characters. - -Most characters represent what we call the match-self operator, i.e., -they match themselves; we call these characters @dfn{ordinary}. Other -characters represent either all or parts of fancier operators; e.g., -@samp{.} represents what we call the match-any-character operator -(which, no surprise, matches (almost) any character); we call these -characters @dfn{special}. Two different things determine what -characters represent what operators: - -@enumerate -@item -the regular expression syntax your program has told the Regex library to -recognize, and - -@item -the context of the character in the regular expression. -@end enumerate - -In the following sections, we describe these things in more detail. - -@menu -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: -@end menu - - -@node Syntax Bits, Predefined Syntaxes, , Regular Expression Syntax -@section Syntax Bits - -@cindex syntax bits - -In any particular syntax for regular expressions, some characters are -always special, others are sometimes special, and others are never -special. The particular syntax that Regex recognizes for a given -regular expression depends on the value in the @code{syntax} field of -the pattern buffer of that regular expression. - -You get a pattern buffer by compiling a regular expression. @xref{GNU -Pattern Buffers}, and @ref{POSIX Pattern Buffers}, for more information -on pattern buffers. @xref{GNU Regular Expression Compiling}, @ref{POSIX -Regular Expression Compiling}, and @ref{BSD Regular Expression -Compiling}, for more information on compiling. - -Regex considers the value of the @code{syntax} field to be a collection -of bits; we refer to these bits as @dfn{syntax bits}. In most cases, -they affect what characters represent what operators. We describe the -meanings of the operators to which we refer in @ref{Common Operators}, -@ref{GNU Operators}, and @ref{GNU Emacs Operators}. - -For reference, here is the complete list of syntax bits, in alphabetical -order: - -@table @code - -@cnindex RE_BACKSLASH_ESCAPE_IN_LIST -@item RE_BACKSLASH_ESCAPE_IN_LISTS -If this bit is set, then @samp{\} inside a list (@pxref{List Operators} -quotes (makes ordinary, if it's special) the following character; if -this bit isn't set, then @samp{\} is an ordinary character inside lists. -(@xref{The Backslash Character}, for what `\' does outside of lists.) - -@cnindex RE_BK_PLUS_QM -@item RE_BK_PLUS_QM -If this bit is set, then @samp{\+} represents the match-one-or-more -operator and @samp{\?} represents the match-zero-or-more operator; if -this bit isn't set, then @samp{+} represents the match-one-or-more -operator and @samp{?} represents the match-zero-or-one operator. This -bit is irrelevant if @code{RE_LIMITED_OPS} is set. - -@cnindex RE_CHAR_CLASSES -@item RE_CHAR_CLASSES -If this bit is set, then you can use character classes in lists; if this -bit isn't set, then you can't. - -@cnindex RE_CONTEXT_INDEP_ANCHORS -@item RE_CONTEXT_INDEP_ANCHORS -If this bit is set, then @samp{^} and @samp{$} are special anywhere outside -a list; if this bit isn't set, then these characters are special only in -certain contexts. @xref{Match-beginning-of-line Operator}, and -@ref{Match-end-of-line Operator}. - -@cnindex RE_CONTEXT_INDEP_OPS -@item RE_CONTEXT_INDEP_OPS -If this bit is set, then certain characters are special anywhere outside -a list; if this bit isn't set, then those characters are special only in -some contexts and are ordinary elsewhere. Specifically, if this bit -isn't set then @samp{*}, and (if the syntax bit @code{RE_LIMITED_OPS} -isn't set) @samp{+} and @samp{?} (or @samp{\+} and @samp{\?}, depending -on the syntax bit @code{RE_BK_PLUS_QM}) represent repetition operators -only if they're not first in a regular expression or just after an -open-group or alternation operator. The same holds for @samp{@{} (or -@samp{\@{}, depending on the syntax bit @code{RE_NO_BK_BRACES}) if -it is the beginning of a valid interval and the syntax bit -@code{RE_INTERVALS} is set. - -@cnindex RE_CONTEXT_INVALID_OPS -@item RE_CONTEXT_INVALID_OPS -If this bit is set, then repetition and alternation operators can't be -in certain positions within a regular expression. Specifically, the -regular expression is invalid if it has: - -@itemize @bullet - -@item -a repetition operator first in the regular expression or just after a -match-beginning-of-line, open-group, or alternation operator; or - -@item -an alternation operator first or last in the regular expression, just -before a match-end-of-line operator, or just after an alternation or -open-group operator. - -@end itemize - -If this bit isn't set, then you can put the characters representing the -repetition and alternation characters anywhere in a regular expression. -Whether or not they will in fact be operators in certain positions -depends on other syntax bits. - -@cnindex RE_DOT_NEWLINE -@item RE_DOT_NEWLINE -If this bit is set, then the match-any-character operator matches -a newline; if this bit isn't set, then it doesn't. - -@cnindex RE_DOT_NOT_NULL -@item RE_DOT_NOT_NULL -If this bit is set, then the match-any-character operator doesn't match -a null character; if this bit isn't set, then it does. - -@cnindex RE_INTERVALS -@item RE_INTERVALS -If this bit is set, then Regex recognizes interval operators; if this bit -isn't set, then it doesn't. - -@cnindex RE_LIMITED_OPS -@item RE_LIMITED_OPS -If this bit is set, then Regex doesn't recognize the match-one-or-more, -match-zero-or-one or alternation operators; if this bit isn't set, then -it does. - -@cnindex RE_NEWLINE_ALT -@item RE_NEWLINE_ALT -If this bit is set, then newline represents the alternation operator; if -this bit isn't set, then newline is ordinary. - -@cnindex RE_NO_BK_BRACES -@item RE_NO_BK_BRACES -If this bit is set, then @samp{@{} represents the open-interval operator -and @samp{@}} represents the close-interval operator; if this bit isn't -set, then @samp{\@{} represents the open-interval operator and -@samp{\@}} represents the close-interval operator. This bit is relevant -only if @code{RE_INTERVALS} is set. - -@cnindex RE_NO_BK_PARENS -@item RE_NO_BK_PARENS -If this bit is set, then @samp{(} represents the open-group operator and -@samp{)} represents the close-group operator; if this bit isn't set, then -@samp{\(} represents the open-group operator and @samp{\)} represents -the close-group operator. - -@cnindex RE_NO_BK_REFS -@item RE_NO_BK_REFS -If this bit is set, then Regex doesn't recognize @samp{\}@var{digit} as -the back reference operator; if this bit isn't set, then it does. - -@cnindex RE_NO_BK_VBAR -@item RE_NO_BK_VBAR -If this bit is set, then @samp{|} represents the alternation operator; -if this bit isn't set, then @samp{\|} represents the alternation -operator. This bit is irrelevant if @code{RE_LIMITED_OPS} is set. - -@cnindex RE_NO_EMPTY_RANGES -@item RE_NO_EMPTY_RANGES -If this bit is set, then a regular expression with a range whose ending -point collates lower than its starting point is invalid; if this bit -isn't set, then Regex considers such a range to be empty. - -@cnindex RE_UNMATCHED_RIGHT_PAREN_ORD -@item RE_UNMATCHED_RIGHT_PAREN_ORD -If this bit is set and the regular expression has no matching open-group -operator, then Regex considers what would otherwise be a close-group -operator (based on how @code{RE_NO_BK_PARENS} is set) to match @samp{)}. - -@end table - - -@node Predefined Syntaxes, Collating Elements vs. Characters, Syntax Bits, Regular Expression Syntax -@section Predefined Syntaxes - -If you're programming with Regex, you can set a pattern buffer's -(@pxref{GNU Pattern Buffers}, and @ref{POSIX Pattern Buffers}) -@code{syntax} field either to an arbitrary combination of syntax bits -(@pxref{Syntax Bits}) or else to the configurations defined by Regex. -These configurations define the syntaxes used by certain -programs---@sc{gnu} Emacs, -@cindex Emacs -@sc{posix} Awk, -@cindex POSIX Awk -traditional Awk, -@cindex Awk -Grep, -@cindex Grep -@cindex Egrep -Egrep---in addition to syntaxes for @sc{posix} basic and extended -regular expressions. - -The predefined syntaxes--taken directly from @file{regex.h}---are: - -@example -#define RE_SYNTAX_EMACS 0 - -#define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -#define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) - -#define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - -#define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - -#define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) - -/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ -#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - -#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - -/* Syntax bits common to both basic and extended POSIX regex syntax. */ -#define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - -#define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) - -/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ -#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - -#define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS - replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ -#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) -@end example - -@node Collating Elements vs. Characters, The Backslash Character, Predefined Syntaxes, Regular Expression Syntax -@section Collating Elements vs.@: Characters - -@sc{posix} generalizes the notion of a character to that of a -collating element. It defines a @dfn{collating element} to be ``a -sequence of one or more bytes defined in the current collating sequence -as a unit of collation.'' - -This generalizes the notion of a character in -two ways. First, a single character can map into two or more collating -elements. For example, the German -@tex -`\ss' -@end tex -@ifinfo -``es-zet'' -@end ifinfo -collates as the collating element @samp{s} followed by another collating -element @samp{s}. Second, two or more characters can map into one -collating element. For example, the Spanish @samp{ll} collates after -@samp{l} and before @samp{m}. - -Since @sc{posix}'s ``collating element'' preserves the essential idea of -a ``character,'' we use the latter, more familiar, term in this document. - -@node The Backslash Character, , Collating Elements vs. Characters, Regular Expression Syntax -@section The Backslash Character - -@cindex \ -The @samp{\} character has one of four different meanings, depending on -the context in which you use it and what syntax bits are set -(@pxref{Syntax Bits}). It can: 1) stand for itself, 2) quote the next -character, 3) introduce an operator, or 4) do nothing. - -@enumerate -@item -It stands for itself inside a list -(@pxref{List Operators}) if the syntax bit -@code{RE_BACKSLASH_ESCAPE_IN_LISTS} is not set. For example, @samp{[\]} -would match @samp{\}. - -@item -It quotes (makes ordinary, if it's special) the next character when you -use it either: - -@itemize @bullet -@item -outside a list,@footnote{Sometimes -you don't have to explicitly quote special characters to make -them ordinary. For instance, most characters lose any special meaning -inside a list (@pxref{List Operators}). In addition, if the syntax bits -@code{RE_CONTEXT_INVALID_OPS} and @code{RE_CONTEXT_INDEP_OPS} -aren't set, then (for historical reasons) the matcher considers special -characters ordinary if they are in contexts where the operations they -represent make no sense; for example, then the match-zero-or-more -operator (represented by @samp{*}) matches itself in the regular -expression @samp{*foo} because there is no preceding expression on which -it can operate. It is poor practice, however, to depend on this -behavior; if you want a special character to be ordinary outside a list, -it's better to always quote it, regardless.} or - -@item -inside a list and the syntax bit @code{RE_BACKSLASH_ESCAPE_IN_LISTS} is set. - -@end itemize - -@item -It introduces an operator when followed by certain ordinary -characters---sometimes only when certain syntax bits are set. See the -cases @code{RE_BK_PLUS_QM}, @code{RE_NO_BK_BRACES}, @code{RE_NO_BK_VAR}, -@code{RE_NO_BK_PARENS}, @code{RE_NO_BK_REF} in @ref{Syntax Bits}. Also: - -@itemize @bullet -@item -@samp{\b} represents the match-word-boundary operator -(@pxref{Match-word-boundary Operator}). - -@item -@samp{\B} represents the match-within-word operator -(@pxref{Match-within-word Operator}). - -@item -@samp{\<} represents the match-beginning-of-word operator @* -(@pxref{Match-beginning-of-word Operator}). - -@item -@samp{\>} represents the match-end-of-word operator -(@pxref{Match-end-of-word Operator}). - -@item -@samp{\w} represents the match-word-constituent operator -(@pxref{Match-word-constituent Operator}). - -@item -@samp{\W} represents the match-non-word-constituent operator -(@pxref{Match-non-word-constituent Operator}). - -@item -@samp{\`} represents the match-beginning-of-buffer -operator and @samp{\'} represents the match-end-of-buffer operator -(@pxref{Buffer Operators}). - -@item -If Regex was compiled with the C preprocessor symbol @code{emacs} -defined, then @samp{\s@var{class}} represents the match-syntactic-class -operator and @samp{\S@var{class}} represents the -match-not-syntactic-class operator (@pxref{Syntactic Class Operators}). - -@end itemize - -@item -In all other cases, Regex ignores @samp{\}. For example, -@samp{\n} matches @samp{n}. - -@end enumerate - -@node Common Operators, GNU Operators, Regular Expression Syntax, Top -@chapter Common Operators - -You compose regular expressions from operators. In the following -sections, we describe the regular expression operators specified by -@sc{posix}; @sc{gnu} also uses these. Most operators have more than one -representation as characters. @xref{Regular Expression Syntax}, for -what characters represent what operators under what circumstances. - -For most operators that can be represented in two ways, one -representation is a single character and the other is that character -preceded by @samp{\}. For example, either @samp{(} or @samp{\(} -represents the open-group operator. Which one does depends on the -setting of a syntax bit, in this case @code{RE_NO_BK_PARENS}. Why is -this so? Historical reasons dictate some of the varying -representations, while @sc{posix} dictates others. - -Finally, almost all characters lose any special meaning inside a list -(@pxref{List Operators}). - -@menu -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? @{@} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ -@end menu - -@node Match-self Operator, Match-any-character Operator, , Common Operators -@section The Match-self Operator (@var{ordinary character}) - -This operator matches the character itself. All ordinary characters -(@pxref{Regular Expression Syntax}) represent this operator. For -example, @samp{f} is always an ordinary character, so the regular -expression @samp{f} matches only the string @samp{f}. In -particular, it does @emph{not} match the string @samp{ff}. - -@node Match-any-character Operator, Concatenation Operator, Match-self Operator, Common Operators -@section The Match-any-character Operator (@code{.}) - -@cindex @samp{.} - -This operator matches any single printing or nonprinting character -except it won't match a: - -@table @asis -@item newline -if the syntax bit @code{RE_DOT_NEWLINE} isn't set. - -@item null -if the syntax bit @code{RE_DOT_NOT_NULL} is set. - -@end table - -The @samp{.} (period) character represents this operator. For example, -@samp{a.b} matches any three-character string beginning with @samp{a} -and ending with @samp{b}. - -@node Concatenation Operator, Repetition Operators, Match-any-character Operator, Common Operators -@section The Concatenation Operator - -This operator concatenates two regular expressions @var{a} and @var{b}. -No character represents this operator; you simply put @var{b} after -@var{a}. The result is a regular expression that will match a string if -@var{a} matches its first part and @var{b} matches the rest. For -example, @samp{xy} (two match-self operators) matches @samp{xy}. - -@node Repetition Operators, Alternation Operator, Concatenation Operator, Common Operators -@section Repetition Operators - -Repetition operators repeat the preceding regular expression a specified -number of times. - -@menu -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: @{@} -@end menu - -@node Match-zero-or-more Operator, Match-one-or-more Operator, , Repetition Operators -@subsection The Match-zero-or-more Operator (@code{*}) - -@cindex @samp{*} - -This operator repeats the smallest possible preceding regular expression -as many times as necessary (including zero) to match the pattern. -@samp{*} represents this operator. For example, @samp{o*} -matches any string made up of zero or more @samp{o}s. Since this -operator operates on the smallest preceding regular expression, -@samp{fo*} has a repeating @samp{o}, not a repeating @samp{fo}. So, -@samp{fo*} matches @samp{f}, @samp{fo}, @samp{foo}, and so on. - -Since the match-zero-or-more operator is a suffix operator, it may be -useless as such when no regular expression precedes it. This is the -case when it: - -@itemize @bullet -@item -is first in a regular expression, or - -@item -follows a match-beginning-of-line, open-group, or alternation -operator. - -@end itemize - -@noindent -Three different things can happen in these cases: - -@enumerate -@item -If the syntax bit @code{RE_CONTEXT_INVALID_OPS} is set, then the -regular expression is invalid. - -@item -If @code{RE_CONTEXT_INVALID_OPS} isn't set, but -@code{RE_CONTEXT_INDEP_OPS} is, then @samp{*} represents the -match-zero-or-more operator (which then operates on the empty string). - -@item -Otherwise, @samp{*} is ordinary. - -@end enumerate - -@cindex backtracking -The matcher processes a match-zero-or-more operator by first matching as -many repetitions of the smallest preceding regular expression as it can. -Then it continues to match the rest of the pattern. - -If it can't match the rest of the pattern, it backtracks (as many times -as necessary), each time discarding one of the matches until it can -either match the entire pattern or be certain that it cannot get a -match. For example, when matching @samp{ca*ar} against @samp{caaar}, -the matcher first matches all three @samp{a}s of the string with the -@samp{a*} of the regular expression. However, it cannot then match the -final @samp{ar} of the regular expression against the final @samp{r} of -the string. So it backtracks, discarding the match of the last @samp{a} -in the string. It can then match the remaining @samp{ar}. - - -@node Match-one-or-more Operator, Match-zero-or-one Operator, Match-zero-or-more Operator, Repetition Operators -@subsection The Match-one-or-more Operator (@code{+} or @code{\+}) - -@cindex @samp{+} - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't recognize -this operator. Otherwise, if the syntax bit @code{RE_BK_PLUS_QM} isn't -set, then @samp{+} represents this operator; if it is, then @samp{\+} -does. - -This operator is similar to the match-zero-or-more operator except that -it repeats the preceding regular expression at least once; -@pxref{Match-zero-or-more Operator}, for what it operates on, how some -syntax bits affect it, and how Regex backtracks to match it. - -For example, supposing that @samp{+} represents the match-one-or-more -operator; then @samp{ca+r} matches, e.g., @samp{car} and -@samp{caaaar}, but not @samp{cr}. - -@node Match-zero-or-one Operator, Interval Operators, Match-one-or-more Operator, Repetition Operators -@subsection The Match-zero-or-one Operator (@code{?} or @code{\?}) -@cindex @samp{?} - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit -@code{RE_BK_PLUS_QM} isn't set, then @samp{?} represents this operator; -if it is, then @samp{\?} does. - -This operator is similar to the match-zero-or-more operator except that -it repeats the preceding regular expression once or not at all; -@pxref{Match-zero-or-more Operator}, to see what it operates on, how -some syntax bits affect it, and how Regex backtracks to match it. - -For example, supposing that @samp{?} represents the match-zero-or-one -operator; then @samp{ca?r} matches both @samp{car} and @samp{cr}, but -nothing else. - -@node Interval Operators, , Match-zero-or-one Operator, Repetition Operators -@subsection Interval Operators (@code{@{} @dots{} @code{@}} or @code{\@{} @dots{} @code{\@}}) - -@cindex interval expression -@cindex @samp{@{} -@cindex @samp{@}} -@cindex @samp{\@{} -@cindex @samp{\@}} - -If the syntax bit @code{RE_INTERVALS} is set, then Regex recognizes -@dfn{interval expressions}. They repeat the smallest possible preceding -regular expression a specified number of times. - -If the syntax bit @code{RE_NO_BK_BRACES} is set, @samp{@{} represents -the @dfn{open-interval operator} and @samp{@}} represents the -@dfn{close-interval operator} ; otherwise, @samp{\@{} and @samp{\@}} do. - -Specifically, supposing that @samp{@{} and @samp{@}} represent the -open-interval and close-interval operators; then: - -@table @code -@item @{@var{count}@} -matches exactly @var{count} occurrences of the preceding regular -expression. - -@item @{@var{min,}@} -matches @var{min} or more occurrences of the preceding regular -expression. - -@item @{@var{min, max}@} -matches at least @var{min} but no more than @var{max} occurrences of -the preceding regular expression. - -@end table - -The interval expression (but not necessarily the regular expression that -contains it) is invalid if: - -@itemize @bullet -@item -@var{min} is greater than @var{max}, or - -@item -any of @var{count}, @var{min}, or @var{max} are outside the range -zero to @code{RE_DUP_MAX} (which symbol @file{regex.h} -defines). - -@end itemize - -If the interval expression is invalid and the syntax bit -@code{RE_NO_BK_BRACES} is set, then Regex considers all the -characters in the would-be interval to be ordinary. If that bit -isn't set, then the regular expression is invalid. - -If the interval expression is valid but there is no preceding regular -expression on which to operate, then if the syntax bit -@code{RE_CONTEXT_INVALID_OPS} is set, the regular expression is invalid. -If that bit isn't set, then Regex considers all the characters---other -than backslashes, which it ignores---in the would-be interval to be -ordinary. - - -@node Alternation Operator, List Operators, Repetition Operators, Common Operators -@section The Alternation Operator (@code{|} or @code{\|}) - -@kindex | -@kindex \| -@cindex alternation operator -@cindex or operator - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit -@code{RE_NO_BK_VBAR} is set, then @samp{|} represents this operator; -otherwise, @samp{\|} does. - -Alternatives match one of a choice of regular expressions: -if you put the character(s) representing the alternation operator between -any two regular expressions @var{a} and @var{b}, the result matches -the union of the strings that @var{a} and @var{b} match. For -example, supposing that @samp{|} is the alternation operator, then -@samp{foo|bar|quux} would match any of @samp{foo}, @samp{bar} or -@samp{quux}. - -@ignore -@c Nobody needs to disallow empty alternatives any more. -If the syntax bit @code{RE_NO_EMPTY_ALTS} is set, then if either of the regular -expressions @var{a} or @var{b} is empty, the -regular expression is invalid. More precisely, if this syntax bit is -set, then the alternation operator can't: - -@itemize @bullet -@item -be first or last in a regular expression; - -@item -follow either another alternation operator or an open-group operator -(@pxref{Grouping Operators}); or - -@item -precede a close-group operator. - -@end itemize - -@noindent -For example, supposing @samp{(} and @samp{)} represent the open and -close-group operators, then @samp{|foo}, @samp{foo|}, @samp{foo||bar}, -@samp{foo(|bar)}, and @samp{(foo|)bar} would all be invalid. -@end ignore - -The alternation operator operates on the @emph{largest} possible -surrounding regular expressions. (Put another way, it has the lowest -precedence of any regular expression operator.) -Thus, the only way you can -delimit its arguments is to use grouping. For example, if @samp{(} and -@samp{)} are the open and close-group operators, then @samp{fo(o|b)ar} -would match either @samp{fooar} or @samp{fobar}. (@samp{foo|bar} would -match @samp{foo} or @samp{bar}.) - -@cindex backtracking -The matcher usually tries all combinations of alternatives so as to -match the longest possible string. For example, when matching -@samp{(fooq|foo)*(qbarquux|bar)} against @samp{fooqbarquux}, it cannot -take, say, the first (``depth-first'') combination it could match, since -then it would be content to match just @samp{fooqbar}. - -@comment xx something about leftmost-longest - - -@node List Operators, Grouping Operators, Alternation Operator, Common Operators -@section List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]}) - -@cindex matching list -@cindex @samp{[} -@cindex @samp{]} -@cindex @samp{^} -@cindex @samp{-} -@cindex @samp{\} -@cindex @samp{[^} -@cindex nonmatching list -@cindex matching newline -@cindex bracket expression - -@dfn{Lists}, also called @dfn{bracket expressions}, are a set of one or -more items. An @dfn{item} is a character, -@ignore -(These get added when they get implemented.) -a collating symbol, an equivalence class expression, -@end ignore -a character class expression, or a range expression. The syntax bits -affect which kinds of items you can put in a list. We explain the last -two items in subsections below. Empty lists are invalid. - -A @dfn{matching list} matches a single character represented by one of -the list items. You form a matching list by enclosing one or more items -within an @dfn{open-matching-list operator} (represented by @samp{[}) -and a @dfn{close-list operator} (represented by @samp{]}). - -For example, @samp{[ab]} matches either @samp{a} or @samp{b}. -@samp{[ad]*} matches the empty string and any string composed of just -@samp{a}s and @samp{d}s in any order. Regex considers invalid a regular -expression with a @samp{[} but no matching -@samp{]}. - -@dfn{Nonmatching lists} are similar to matching lists except that they -match a single character @emph{not} represented by one of the list -items. You use an @dfn{open-nonmatching-list operator} (represented by -@samp{[^}@footnote{Regex therefore doesn't consider the @samp{^} to be -the first character in the list. If you put a @samp{^} character first -in (what you think is) a matching list, you'll turn it into a -nonmatching list.}) instead of an open-matching-list operator to start a -nonmatching list. - -For example, @samp{[^ab]} matches any character except @samp{a} or -@samp{b}. - -If the @code{posix_newline} field in the pattern buffer (@pxref{GNU -Pattern Buffers} is set, then nonmatching lists do not match a newline. - -Most characters lose any special meaning inside a list. The special -characters inside a list follow. - -@table @samp -@item ] -ends the list if it's not the first list item. So, if you want to make -the @samp{]} character a list item, you must put it first. - -@item \ -quotes the next character if the syntax bit @code{RE_BACKSLASH_ESCAPE_IN_LISTS} is -set. - -@ignore -Put these in if they get implemented. - -@item [. -represents the open-collating-symbol operator (@pxref{Collating Symbol -Operators}). - -@item .] -represents the close-collating-symbol operator. - -@item [= -represents the open-equivalence-class operator (@pxref{Equivalence Class -Operators}). - -@item =] -represents the close-equivalence-class operator. - -@end ignore - -@item [: -represents the open-character-class operator (@pxref{Character Class -Operators}) if the syntax bit @code{RE_CHAR_CLASSES} is set and what -follows is a valid character class expression. - -@item :] -represents the close-character-class operator if the syntax bit -@code{RE_CHAR_CLASSES} is set and what precedes it is an -open-character-class operator followed by a valid character class name. - -@item - -represents the range operator (@pxref{Range Operator}) if it's -not first or last in a list or the ending point of a range. - -@end table - -@noindent -All other characters are ordinary. For example, @samp{[.*]} matches -@samp{.} and @samp{*}. - -@menu -* Character Class Operators:: [:class:] -* Range Operator:: start-end -@end menu - -@ignore -(If collating symbols and equivalence class expressions get implemented, -then add this.) - -node Collating Symbol Operators -subsubsection Collating Symbol Operators (@code{[.} @dots{} @code{.]}) - -If the syntax bit @code{XX} is set, then you can represent -collating symbols inside lists. You form a @dfn{collating symbol} by -putting a collating element between an @dfn{open-collating-symbol -operator} and an @dfn{close-collating-symbol operator}. @samp{[.} -represents the open-collating-symbol operator and @samp{.]} represents -the close-collating-symbol operator. For example, if @samp{ll} is a -collating element, then @samp{[[.ll.]]} would match @samp{ll}. - -node Equivalence Class Operators -subsubsection Equivalence Class Operators (@code{[=} @dots{} @code{=]}) -@cindex equivalence class expression in regex -@cindex @samp{[=} in regex -@cindex @samp{=]} in regex - -If the syntax bit @code{XX} is set, then Regex recognizes equivalence class -expressions inside lists. A @dfn{equivalence class expression} is a set -of collating elements which all belong to the same equivalence class. -You form an equivalence class expression by putting a collating -element between an @dfn{open-equivalence-class operator} and a -@dfn{close-equivalence-class operator}. @samp{[=} represents the -open-equivalence-class operator and @samp{=]} represents the -close-equivalence-class operator. For example, if @samp{a} and @samp{A} -were an equivalence class, then both @samp{[[=a=]]} and @samp{[[=A=]]} -would match both @samp{a} and @samp{A}. If the collating element in an -equivalence class expression isn't part of an equivalence class, then -the matcher considers the equivalence class expression to be a collating -symbol. - -@end ignore - -@node Character Class Operators, Range Operator, , List Operators -@subsection Character Class Operators (@code{[:} @dots{} @code{:]}) - -@cindex character classes -@cindex @samp{[:} in regex -@cindex @samp{:]} in regex - -If the syntax bit @code{RE_CHARACTER_CLASSES} is set, then Regex -recognizes character class expressions inside lists. A @dfn{character -class expression} matches one character from a given class. You form a -character class expression by putting a character class name between an -@dfn{open-character-class operator} (represented by @samp{[:}) and a -@dfn{close-character-class operator} (represented by @samp{:]}). The -character class names and their meanings are: - -@table @code - -@item alnum -letters and digits - -@item alpha -letters - -@item blank -system-dependent; for @sc{gnu}, a space or tab - -@item cntrl -control characters (in the @sc{ascii} encoding, code 0177 and codes -less than 040) - -@item digit -digits - -@item graph -same as @code{print} except omits space - -@item lower -lowercase letters - -@item print -printable characters (in the @sc{ascii} encoding, space -tilde---codes 040 through 0176) - -@item punct -neither control nor alphanumeric characters - -@item space -space, carriage return, newline, vertical tab, and form feed - -@item upper -uppercase letters - -@item xdigit -hexadecimal digits: @code{0}--@code{9}, @code{a}--@code{f}, @code{A}--@code{F} - -@end table - -@noindent -These correspond to the definitions in the C library's @file{} -facility. For example, @samp{[:alpha:]} corresponds to the standard -facility @code{isalpha}. Regex recognizes character class expressions -only inside of lists; so @samp{[[:alpha:]]} matches any letter, but -@samp{[:alpha:]} outside of a bracket expression and not followed by a -repetition operator matches just itself. - -@node Range Operator, , Character Class Operators, List Operators -@subsection The Range Operator (@code{-}) - -Regex recognizes @dfn{range expressions} inside a list. They represent -those characters -that fall between two elements in the current collating sequence. You -form a range expression by putting a @dfn{range operator} between two -@ignore -(If these get implemented, then substitute this for ``characters.'') -of any of the following: characters, collating elements, collating symbols, -and equivalence class expressions. The starting point of the range and -the ending point of the range don't have to be the same kind of item, -e.g., the starting point could be a collating element and the ending -point could be an equivalence class expression. If a range's ending -point is an equivalence class, then all the collating elements in that -class will be in the range. -@end ignore -characters.@footnote{You can't use a character class for the starting -or ending point of a range, since a character class is not a single -character.} @samp{-} represents the range operator. For example, -@samp{a-f} within a list represents all the characters from @samp{a} -through @samp{f} -inclusively. - -If the syntax bit @code{RE_NO_EMPTY_RANGES} is set, then if the range's -ending point collates less than its starting point, the range (and the -regular expression containing it) is invalid. For example, the regular -expression @samp{[z-a]} would be invalid. If this bit isn't set, then -Regex considers such a range to be empty. - -Since @samp{-} represents the range operator, if you want to make a -@samp{-} character itself -a list item, you must do one of the following: - -@itemize @bullet -@item -Put the @samp{-} either first or last in the list. - -@item -Include a range whose starting point collates strictly lower than -@samp{-} and whose ending point collates equal or higher. Unless a -range is the first item in a list, a @samp{-} can't be its starting -point, but @emph{can} be its ending point. That is because Regex -considers @samp{-} to be the range operator unless it is preceded by -another @samp{-}. For example, in the @sc{ascii} encoding, @samp{)}, -@samp{*}, @samp{+}, @samp{,}, @samp{-}, @samp{.}, and @samp{/} are -contiguous characters in the collating sequence. You might think that -@samp{[)-+--/]} has two ranges: @samp{)-+} and @samp{--/}. Rather, it -has the ranges @samp{)-+} and @samp{+--}, plus the character @samp{/}, so -it matches, e.g., @samp{,}, not @samp{.}. - -@item -Put a range whose starting point is @samp{-} first in the list. - -@end itemize - -For example, @samp{[-a-z]} matches a lowercase letter or a hyphen (in -English, in @sc{ascii}). - - -@node Grouping Operators, Back-reference Operator, List Operators, Common Operators -@section Grouping Operators (@code{(} @dots{} @code{)} or @code{\(} @dots{} @code{\)}) - -@kindex ( -@kindex ) -@kindex \( -@kindex \) -@cindex grouping -@cindex subexpressions -@cindex parenthesizing - -A @dfn{group}, also known as a @dfn{subexpression}, consists of an -@dfn{open-group operator}, any number of other operators, and a -@dfn{close-group operator}. Regex treats this sequence as a unit, just -as mathematics and programming languages treat a parenthesized -expression as a unit. - -Therefore, using @dfn{groups}, you can: - -@itemize @bullet -@item -delimit the argument(s) to an alternation operator (@pxref{Alternation -Operator}) or a repetition operator (@pxref{Repetition -Operators}). - -@item -keep track of the indices of the substring that matched a given group. -@xref{Using Registers}, for a precise explanation. -This lets you: - -@itemize @bullet -@item -use the back-reference operator (@pxref{Back-reference Operator}). - -@item -use registers (@pxref{Using Registers}). - -@end itemize - -@end itemize - -If the syntax bit @code{RE_NO_BK_PARENS} is set, then @samp{(} represents -the open-group operator and @samp{)} represents the -close-group operator; otherwise, @samp{\(} and @samp{\)} do. - -If the syntax bit @code{RE_UNMATCHED_RIGHT_PAREN_ORD} is set and a -close-group operator has no matching open-group operator, then Regex -considers it to match @samp{)}. - - -@node Back-reference Operator, Anchoring Operators, Grouping Operators, Common Operators -@section The Back-reference Operator (@dfn{\}@var{digit}) - -@cindex back references - -If the syntax bit @code{RE_NO_BK_REF} isn't set, then Regex recognizes -back references. A back reference matches a specified preceding group. -The back reference operator is represented by @samp{\@var{digit}} -anywhere after the end of a regular expression's @w{@var{digit}-th} -group (@pxref{Grouping Operators}). - -@var{digit} must be between @samp{1} and @samp{9}. The matcher assigns -numbers 1 through 9 to the first nine groups it encounters. By using -one of @samp{\1} through @samp{\9} after the corresponding group's -close-group operator, you can match a substring identical to the -one that the group does. - -Back references match according to the following (in all examples below, -@samp{(} represents the open-group, @samp{)} the close-group, @samp{@{} -the open-interval and @samp{@}} the close-interval operator): - -@itemize @bullet -@item -If the group matches a substring, the back reference matches an -identical substring. For example, @samp{(a)\1} matches @samp{aa} and -@samp{(bana)na\1bo\1} matches @samp{bananabanabobana}. Likewise, -@samp{(.*)\1} matches any (newline-free if the syntax bit -@code{RE_DOT_NEWLINE} isn't set) string that is composed of two -identical halves; the @samp{(.*)} matches the first half and the -@samp{\1} matches the second half. - -@item -If the group matches more than once (as it might if followed -by, e.g., a repetition operator), then the back reference matches the -substring the group @emph{last} matched. For example, -@samp{((a*)b)*\1\2} matches @samp{aabababa}; first @w{group 1} (the -outer one) matches @samp{aab} and @w{group 2} (the inner one) matches -@samp{aa}. Then @w{group 1} matches @samp{ab} and @w{group 2} matches -@samp{a}. So, @samp{\1} matches @samp{ab} and @samp{\2} matches -@samp{a}. - -@item -If the group doesn't participate in a match, i.e., it is part of an -alternative not taken or a repetition operator allows zero repetitions -of it, then the back reference makes the whole match fail. For example, -@samp{(one()|two())-and-(three\2|four\3)} matches @samp{one-and-three} -and @samp{two-and-four}, but not @samp{one-and-four} or -@samp{two-and-three}. For example, if the pattern matches -@samp{one-and-}, then its @w{group 2} matches the empty string and its -@w{group 3} doesn't participate in the match. So, if it then matches -@samp{four}, then when it tries to back reference @w{group 3}---which it -will attempt to do because @samp{\3} follows the @samp{four}---the match -will fail because @w{group 3} didn't participate in the match. - -@end itemize - -You can use a back reference as an argument to a repetition operator. For -example, @samp{(a(b))\2*} matches @samp{a} followed by two or more -@samp{b}s. Similarly, @samp{(a(b))\2@{3@}} matches @samp{abbbb}. - -If there is no preceding @w{@var{digit}-th} subexpression, the regular -expression is invalid. - - -@node Anchoring Operators, , Back-reference Operator, Common Operators -@section Anchoring Operators - -@cindex anchoring -@cindex regexp anchoring - -These operators can constrain a pattern to match only at the beginning or -end of the entire string or at the beginning or end of a line. - -@menu -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ -@end menu - - -@node Match-beginning-of-line Operator, Match-end-of-line Operator, , Anchoring Operators -@subsection The Match-beginning-of-line Operator (@code{^}) - -@kindex ^ -@cindex beginning-of-line operator -@cindex anchors - -This operator can match the empty string either at the beginning of the -string or after a newline character. Thus, it is said to @dfn{anchor} -the pattern to the beginning of a line. - -In the cases following, @samp{^} represents this operator. (Otherwise, -@samp{^} is ordinary.) - -@itemize @bullet - -@item -It (the @samp{^}) is first in the pattern, as in @samp{^foo}. - -@cnindex RE_CONTEXT_INDEP_ANCHORS @r{(and @samp{^})} -@item -The syntax bit @code{RE_CONTEXT_INDEP_ANCHORS} is set, and it is outside -a bracket expression. - -@cindex open-group operator and @samp{^} -@cindex alternation operator and @samp{^} -@item -It follows an open-group or alternation operator, as in @samp{a\(^b\)} -and @samp{a\|^b}. @xref{Grouping Operators}, and @ref{Alternation -Operator}. - -@end itemize - -These rules imply that some valid patterns containing @samp{^} cannot be -matched; for example, @samp{foo^bar} if @code{RE_CONTEXT_INDEP_ANCHORS} -is set. - -@vindex not_bol @r{field in pattern buffer} -If the @code{not_bol} field is set in the pattern buffer (@pxref{GNU -Pattern Buffers}), then @samp{^} fails to match at the beginning of the -string. @xref{POSIX Matching}, for when you might find this useful. - -@vindex newline_anchor @r{field in pattern buffer} -If the @code{newline_anchor} field is set in the pattern buffer, then -@samp{^} fails to match after a newline. This is useful when you do not -regard the string to be matched as broken into lines. - - -@node Match-end-of-line Operator, , Match-beginning-of-line Operator, Anchoring Operators -@subsection The Match-end-of-line Operator (@code{$}) - -@kindex $ -@cindex end-of-line operator -@cindex anchors - -This operator can match the empty string either at the end of -the string or before a newline character in the string. Thus, it is -said to @dfn{anchor} the pattern to the end of a line. - -It is always represented by @samp{$}. For example, @samp{foo$} usually -matches, e.g., @samp{foo} and, e.g., the first three characters of -@samp{foo\nbar}. - -Its interaction with the syntax bits and pattern buffer fields is -exactly the dual of @samp{^}'s; see the previous section. (That is, -``beginning'' becomes ``end'', ``next'' becomes ``previous'', and -``after'' becomes ``before''.) - - -@node GNU Operators, GNU Emacs Operators, Common Operators, Top -@chapter GNU Operators - -Following are operators that @sc{gnu} defines (and @sc{posix} doesn't). - -@menu -* Word Operators:: -* Buffer Operators:: -@end menu - -@node Word Operators, Buffer Operators, , GNU Operators -@section Word Operators - -The operators in this section require Regex to recognize parts of words. -Regex uses a syntax table to determine whether or not a character is -part of a word, i.e., whether or not it is @dfn{word-constituent}. - -@menu -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W -@end menu - -@node Non-Emacs Syntax Tables, Match-word-boundary Operator, , Word Operators -@subsection Non-Emacs Syntax Tables - -A @dfn{syntax table} is an array indexed by the characters in your -character set. In the @sc{ascii} encoding, therefore, a syntax table -has 256 elements. Regex always uses a @code{char *} variable -@code{re_syntax_table} as its syntax table. In some cases, it -initializes this variable and in others it expects you to initialize it. - -@itemize @bullet -@item -If Regex is compiled with the preprocessor symbols @code{emacs} and -@code{SYNTAX_TABLE} both undefined, then Regex allocates -@code{re_syntax_table} and initializes an element @var{i} either to -@code{Sword} (which it defines) if @var{i} is a letter, number, or -@samp{_}, or to zero if it's not. - -@item -If Regex is compiled with @code{emacs} undefined but @code{SYNTAX_TABLE} -defined, then Regex expects you to define a @code{char *} variable -@code{re_syntax_table} to be a valid syntax table. - -@item -@xref{Emacs Syntax Tables}, for what happens when Regex is compiled with -the preprocessor symbol @code{emacs} defined. - -@end itemize - -@node Match-word-boundary Operator, Match-within-word Operator, Non-Emacs Syntax Tables, Word Operators -@subsection The Match-word-boundary Operator (@code{\b}) - -@cindex @samp{\b} -@cindex word boundaries, matching - -This operator (represented by @samp{\b}) matches the empty string at -either the beginning or the end of a word. For example, @samp{\brat\b} -matches the separate word @samp{rat}. - -@node Match-within-word Operator, Match-beginning-of-word Operator, Match-word-boundary Operator, Word Operators -@subsection The Match-within-word Operator (@code{\B}) - -@cindex @samp{\B} - -This operator (represented by @samp{\B}) matches the empty string within -a word. For example, @samp{c\Brat\Be} matches @samp{crate}, but -@samp{dirty \Brat} doesn't match @samp{dirty rat}. - -@node Match-beginning-of-word Operator, Match-end-of-word Operator, Match-within-word Operator, Word Operators -@subsection The Match-beginning-of-word Operator (@code{\<}) - -@cindex @samp{\<} - -This operator (represented by @samp{\<}) matches the empty string at the -beginning of a word. - -@node Match-end-of-word Operator, Match-word-constituent Operator, Match-beginning-of-word Operator, Word Operators -@subsection The Match-end-of-word Operator (@code{\>}) - -@cindex @samp{\>} - -This operator (represented by @samp{\>}) matches the empty string at the -end of a word. - -@node Match-word-constituent Operator, Match-non-word-constituent Operator, Match-end-of-word Operator, Word Operators -@subsection The Match-word-constituent Operator (@code{\w}) - -@cindex @samp{\w} - -This operator (represented by @samp{\w}) matches any word-constituent -character. - -@node Match-non-word-constituent Operator, , Match-word-constituent Operator, Word Operators -@subsection The Match-non-word-constituent Operator (@code{\W}) - -@cindex @samp{\W} - -This operator (represented by @samp{\W}) matches any character that is -not word-constituent. - - -@node Buffer Operators, , Word Operators, GNU Operators -@section Buffer Operators - -Following are operators which work on buffers. In Emacs, a @dfn{buffer} -is, naturally, an Emacs buffer. For other programs, Regex considers the -entire string to be matched as the buffer. - -@menu -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' -@end menu - - -@node Match-beginning-of-buffer Operator, Match-end-of-buffer Operator, , Buffer Operators -@subsection The Match-beginning-of-buffer Operator (@code{\`}) - -@cindex @samp{\`} - -This operator (represented by @samp{\`}) matches the empty string at the -beginning of the buffer. - -@node Match-end-of-buffer Operator, , Match-beginning-of-buffer Operator, Buffer Operators -@subsection The Match-end-of-buffer Operator (@code{\'}) - -@cindex @samp{\'} - -This operator (represented by @samp{\'}) matches the empty string at the -end of the buffer. - - -@node GNU Emacs Operators, What Gets Matched?, GNU Operators, Top -@chapter GNU Emacs Operators - -Following are operators that @sc{gnu} defines (and @sc{posix} doesn't) -that you can use only when Regex is compiled with the preprocessor -symbol @code{emacs} defined. - -@menu -* Syntactic Class Operators:: -@end menu - - -@node Syntactic Class Operators, , , GNU Emacs Operators -@section Syntactic Class Operators - -The operators in this section require Regex to recognize the syntactic -classes of characters. Regex uses a syntax table to determine this. - -@menu -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS -@end menu - -@node Emacs Syntax Tables, Match-syntactic-class Operator, , Syntactic Class Operators -@subsection Emacs Syntax Tables - -A @dfn{syntax table} is an array indexed by the characters in your -character set. In the @sc{ascii} encoding, therefore, a syntax table -has 256 elements. - -If Regex is compiled with the preprocessor symbol @code{emacs} defined, -then Regex expects you to define and initialize the variable -@code{re_syntax_table} to be an Emacs syntax table. Emacs' syntax -tables are more complicated than Regex's own (@pxref{Non-Emacs Syntax -Tables}). @xref{Syntax, , Syntax, emacs, The GNU Emacs User's Manual}, -for a description of Emacs' syntax tables. - -@node Match-syntactic-class Operator, Match-not-syntactic-class Operator, Emacs Syntax Tables, Syntactic Class Operators -@subsection The Match-syntactic-class Operator (@code{\s}@var{class}) - -@cindex @samp{\s} - -This operator matches any character whose syntactic class is represented -by a specified character. @samp{\s@var{class}} represents this operator -where @var{class} is the character representing the syntactic class you -want. For example, @samp{w} represents the syntactic -class of word-constituent characters, so @samp{\sw} matches any -word-constituent character. - -@node Match-not-syntactic-class Operator, , Match-syntactic-class Operator, Syntactic Class Operators -@subsection The Match-not-syntactic-class Operator (@code{\S}@var{class}) - -@cindex @samp{\S} - -This operator is similar to the match-syntactic-class operator except -that it matches any character whose syntactic class is @emph{not} -represented by the specified character. @samp{\S@var{class}} represents -this operator. For example, @samp{w} represents the syntactic class of -word-constituent characters, so @samp{\Sw} matches any character that is -not word-constituent. - - -@node What Gets Matched?, Programming with Regex, GNU Emacs Operators, Top -@chapter What Gets Matched? - -Regex usually matches strings according to the ``leftmost longest'' -rule; that is, it chooses the longest of the leftmost matches. This -does not mean that for a regular expression containing subexpressions -that it simply chooses the longest match for each subexpression, left to -right; the overall match must also be the longest possible one. - -For example, @samp{(ac*)(c*d[ac]*)\1} matches @samp{acdacaaa}, not -@samp{acdac}, as it would if it were to choose the longest match for the -first subexpression. - - -@node Programming with Regex, Copying, What Gets Matched?, Top -@chapter Programming with Regex - -Here we describe how you use the Regex data structures and functions in -C programs. Regex has three interfaces: one designed for @sc{gnu}, one -compatible with @sc{posix} and one compatible with Berkeley @sc{unix}. - -@menu -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: -@end menu - - -@node GNU Regex Functions, POSIX Regex Functions, , Programming with Regex -@section GNU Regex Functions - -If you're writing code that doesn't need to be compatible with either -@sc{posix} or Berkeley @sc{unix}, you can use these functions. They -provide more options than the other interfaces. - -@menu -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () -@end menu - - -@node GNU Pattern Buffers, GNU Regular Expression Compiling, , GNU Regex Functions -@subsection GNU Pattern Buffers - -@cindex pattern buffer, definition of -@tindex re_pattern_buffer @r{definition} -@tindex struct re_pattern_buffer @r{definition} - -To compile, match, or search for a given regular expression, you must -supply a pattern buffer. A @dfn{pattern buffer} holds one compiled -regular expression.@footnote{Regular expressions are also referred to as -``patterns,'' hence the name ``pattern buffer.''} - -You can have several different pattern buffers simultaneously, each -holding a compiled pattern for a different regular expression. - -@file{regex.h} defines the pattern buffer @code{struct} as follows: - -@example - /* Space that holds the compiled pattern. It is declared as - `unsigned char *' because its elements are - sometimes used as array indexes. */ - unsigned char *buffer; - - /* Number of bytes to which `buffer' points. */ - unsigned long allocated; - - /* Number of bytes actually used in `buffer'. */ - unsigned long used; - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t syntax; - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses - the fastmap, if there is one, to skip over impossible - starting points for matches. */ - char *fastmap; - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation - is applied to a pattern when it is compiled and to a string - when it is matched. */ - char *translate; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in `re_search_2', to see - whether or not we should use the fastmap, so we don't set - this absolutely perfectly; see `re_compile_fastmap' (the - `duplicate' case). */ - unsigned can_be_null : 1; - - /* If REGS_UNALLOCATED, allocate space in the `regs' structure - for `max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ -#define REGS_UNALLOCATED 0 -#define REGS_REALLOCATE 1 -#define REGS_FIXED 2 - unsigned regs_allocated : 2; - - /* Set to zero when `regex_compile' compiles a pattern; set to one - by `re_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; - - /* If set, `re_match_2' does not return information about - subexpressions. */ - unsigned no_sub : 1; - - /* If set, a beginning-of-line anchor doesn't match at the - beginning of the string. */ - unsigned not_bol : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned not_eol : 1; - - /* If true, an anchor at a newline matches. */ - unsigned newline_anchor : 1; - -@end example - - -@node GNU Regular Expression Compiling, GNU Matching, GNU Pattern Buffers, GNU Regex Functions -@subsection GNU Regular Expression Compiling - -In @sc{gnu}, you can both match and search for a given regular -expression. To do either, you must first compile it in a pattern buffer -(@pxref{GNU Pattern Buffers}). - -@cindex syntax initialization -@vindex re_syntax_options @r{initialization} -Regular expressions match according to the syntax with which they were -compiled; with @sc{gnu}, you indicate what syntax you want by setting -the variable @code{re_syntax_options} (declared in @file{regex.h} and -defined in @file{regex.c}) before calling the compiling function, -@code{re_compile_pattern} (see below). @xref{Syntax Bits}, and -@ref{Predefined Syntaxes}. - -You can change the value of @code{re_syntax_options} at any time. -Usually, however, you set its value once and then never change it. - -@cindex pattern buffer initialization -@code{re_compile_pattern} takes a pattern buffer as an argument. You -must initialize the following fields: - -@table @code - -@item translate @r{initialization} - -@item translate -@vindex translate @r{initialization} -Initialize this to point to a translate table if you want one, or to -zero if you don't. We explain translate tables in @ref{GNU Translate -Tables}. - -@item fastmap -@vindex fastmap @r{initialization} -Initialize this to nonzero if you want a fastmap, or to zero if you -don't. - -@item buffer -@itemx allocated -@vindex buffer @r{initialization} -@vindex allocated @r{initialization} -@findex malloc -If you want @code{re_compile_pattern} to allocate memory for the -compiled pattern, set both of these to zero. If you have an existing -block of memory (allocated with @code{malloc}) you want Regex to use, -set @code{buffer} to its address and @code{allocated} to its size (in -bytes). - -@code{re_compile_pattern} uses @code{realloc} to extend the space for -the compiled pattern as necessary. - -@end table - -To compile a pattern buffer, use: - -@findex re_compile_pattern -@example -char * -re_compile_pattern (const char *@var{regex}, const int @var{regex_size}, - struct re_pattern_buffer *@var{pattern_buffer}) -@end example - -@noindent -@var{regex} is the regular expression's address, @var{regex_size} is its -length, and @var{pattern_buffer} is the pattern buffer's address. - -If @code{re_compile_pattern} successfully compiles the regular -expression, it returns zero and sets @code{*@var{pattern_buffer}} to the -compiled pattern. It sets the pattern buffer's fields as follows: - -@table @code -@item buffer -@vindex buffer @r{field, set by @code{re_compile_pattern}} -to the compiled pattern. - -@item used -@vindex used @r{field, set by @code{re_compile_pattern}} -to the number of bytes the compiled pattern in @code{buffer} occupies. - -@item syntax -@vindex syntax @r{field, set by @code{re_compile_pattern}} -to the current value of @code{re_syntax_options}. - -@item re_nsub -@vindex re_nsub @r{field, set by @code{re_compile_pattern}} -to the number of subexpressions in @var{regex}. - -@item fastmap_accurate -@vindex fastmap_accurate @r{field, set by @code{re_compile_pattern}} -to zero on the theory that the pattern you're compiling is different -than the one previously compiled into @code{buffer}; in that case (since -you can't make a fastmap without a compiled pattern), -@code{fastmap} would either contain an incompatible fastmap, or nothing -at all. - -@c xx what else? -@end table - -If @code{re_compile_pattern} can't compile @var{regex}, it returns an -error string corresponding to one of the errors listed in @ref{POSIX -Regular Expression Compiling}. - - -@node GNU Matching, GNU Searching, GNU Regular Expression Compiling, GNU Regex Functions -@subsection GNU Matching - -@cindex matching with GNU functions - -Matching the @sc{gnu} way means trying to match as much of a string as -possible starting at a position within it you specify. Once you've compiled -a pattern into a pattern buffer (@pxref{GNU Regular Expression -Compiling}), you can ask the matcher to match that pattern against a -string using: - -@findex re_match -@example -int -re_match (struct re_pattern_buffer *@var{pattern_buffer}, - const char *@var{string}, const int @var{size}, - const int @var{start}, struct re_registers *@var{regs}) -@end example - -@noindent -@var{pattern_buffer} is the address of a pattern buffer containing a -compiled pattern. @var{string} is the string you want to match; it can -contain newline and null characters. @var{size} is the length of that -string. @var{start} is the string index at which you want to -begin matching; the first character of @var{string} is at index zero. -@xref{Using Registers}, for a explanation of @var{regs}; you can safely -pass zero. - -@code{re_match} matches the regular expression in @var{pattern_buffer} -against the string @var{string} according to the syntax in -@var{pattern_buffers}'s @code{syntax} field. (@xref{GNU Regular -Expression Compiling}, for how to set it.) The function returns -@math{-1} if the compiled pattern does not match any part of -@var{string} and @math{-2} if an internal error happens; otherwise, it -returns how many (possibly zero) characters of @var{string} the pattern -matched. - -An example: suppose @var{pattern_buffer} points to a pattern buffer -containing the compiled pattern for @samp{a*}, and @var{string} points -to @samp{aaaaab} (whereupon @var{size} should be 6). Then if @var{start} -is 2, @code{re_match} returns 3, i.e., @samp{a*} would have matched the -last three @samp{a}s in @var{string}. If @var{start} is 0, -@code{re_match} returns 5, i.e., @samp{a*} would have matched all the -@samp{a}s in @var{string}. If @var{start} is either 5 or 6, it returns -zero. - -If @var{start} is not between zero and @var{size}, then -@code{re_match} returns @math{-1}. - - -@node GNU Searching, Matching/Searching with Split Data, GNU Matching, GNU Regex Functions -@subsection GNU Searching - -@cindex searching with GNU functions - -@dfn{Searching} means trying to match starting at successive positions -within a string. The function @code{re_search} does this. - -Before calling @code{re_search}, you must compile your regular -expression. @xref{GNU Regular Expression Compiling}. - -Here is the function declaration: - -@findex re_search -@example -int -re_search (struct re_pattern_buffer *@var{pattern_buffer}, - const char *@var{string}, const int @var{size}, - const int @var{start}, const int @var{range}, - struct re_registers *@var{regs}) -@end example - -@noindent -@vindex start @r{argument to @code{re_search}} -@vindex range @r{argument to @code{re_search}} -whose arguments are the same as those to @code{re_match} (@pxref{GNU -Matching}) except that the two arguments @var{start} and @var{range} -replace @code{re_match}'s argument @var{start}. - -If @var{range} is positive, then @code{re_search} attempts a match -starting first at index @var{start}, then at @math{@var{start} + 1} if -that fails, and so on, up to @math{@var{start} + @var{range}}; if -@var{range} is negative, then it attempts a match starting first at -index @var{start}, then at @math{@var{start} -1} if that fails, and so -on. - -If @var{start} is not between zero and @var{size}, then @code{re_search} -returns @math{-1}. When @var{range} is positive, @code{re_search} -adjusts @var{range} so that @math{@var{start} + @var{range} - 1} is -between zero and @var{size}, if necessary; that way it won't search -outside of @var{string}. Similarly, when @var{range} is negative, -@code{re_search} adjusts @var{range} so that @math{@var{start} + -@var{range} + 1} is between zero and @var{size}, if necessary. - -If the @code{fastmap} field of @var{pattern_buffer} is zero, -@code{re_search} matches starting at consecutive positions; otherwise, -it uses @code{fastmap} to make the search more efficient. -@xref{Searching with Fastmaps}. - -If no match is found, @code{re_search} returns @math{-1}. If -a match is found, it returns the index where the match began. If an -internal error happens, it returns @math{-2}. - - -@node Matching/Searching with Split Data, Searching with Fastmaps, GNU Searching, GNU Regex Functions -@subsection Matching and Searching with Split Data - -Using the functions @code{re_match_2} and @code{re_search_2}, you can -match or search in data that is divided into two strings. - -The function: - -@findex re_match_2 -@example -int -re_match_2 (struct re_pattern_buffer *@var{buffer}, - const char *@var{string1}, const int @var{size1}, - const char *@var{string2}, const int @var{size2}, - const int @var{start}, - struct re_registers *@var{regs}, - const int @var{stop}) -@end example - -@noindent -is similar to @code{re_match} (@pxref{GNU Matching}) except that you -pass @emph{two} data strings and sizes, and an index @var{stop} beyond -which you don't want the matcher to try matching. As with -@code{re_match}, if it succeeds, @code{re_match_2} returns how many -characters of @var{string} it matched. Regard @var{string1} and -@var{string2} as concatenated when you set the arguments @var{start} and -@var{stop} and use the contents of @var{regs}; @code{re_match_2} never -returns a value larger than @math{@var{size1} + @var{size2}}. - -The function: - -@findex re_search_2 -@example -int -re_search_2 (struct re_pattern_buffer *@var{buffer}, - const char *@var{string1}, const int @var{size1}, - const char *@var{string2}, const int @var{size2}, - const int @var{start}, const int @var{range}, - struct re_registers *@var{regs}, - const int @var{stop}) -@end example - -@noindent -is similarly related to @code{re_search}. - - -@node Searching with Fastmaps, GNU Translate Tables, Matching/Searching with Split Data, GNU Regex Functions -@subsection Searching with Fastmaps - -@cindex fastmaps -If you're searching through a long string, you should use a fastmap. -Without one, the searcher tries to match at consecutive positions in the -string. Generally, most of the characters in the string could not start -a match. It takes much longer to try matching at a given position in the -string than it does to check in a table whether or not the character at -that position could start a match. A @dfn{fastmap} is such a table. - -More specifically, a fastmap is an array indexed by the characters in -your character set. Under the @sc{ascii} encoding, therefore, a fastmap -has 256 elements. If you want the searcher to use a fastmap with a -given pattern buffer, you must allocate the array and assign the array's -address to the pattern buffer's @code{fastmap} field. You either can -compile the fastmap yourself or have @code{re_search} do it for you; -when @code{fastmap} is nonzero, it automatically compiles a fastmap the -first time you search using a particular compiled pattern. - -To compile a fastmap yourself, use: - -@findex re_compile_fastmap -@example -int -re_compile_fastmap (struct re_pattern_buffer *@var{pattern_buffer}) -@end example - -@noindent -@var{pattern_buffer} is the address of a pattern buffer. If the -character @var{c} could start a match for the pattern, -@code{re_compile_fastmap} makes -@code{@var{pattern_buffer}->fastmap[@var{c}]} nonzero. It returns -@math{0} if it can compile a fastmap and @math{-2} if there is an -internal error. For example, if @samp{|} is the alternation operator -and @var{pattern_buffer} holds the compiled pattern for @samp{a|b}, then -@code{re_compile_fastmap} sets @code{fastmap['a']} and -@code{fastmap['b']} (and no others). - -@code{re_search} uses a fastmap as it moves along in the string: it -checks the string's characters until it finds one that's in the fastmap. -Then it tries matching at that character. If the match fails, it -repeats the process. So, by using a fastmap, @code{re_search} doesn't -waste time trying to match at positions in the string that couldn't -start a match. - -If you don't want @code{re_search} to use a fastmap, -store zero in the @code{fastmap} field of the pattern buffer before -calling @code{re_search}. - -Once you've initialized a pattern buffer's @code{fastmap} field, you -need never do so again---even if you compile a new pattern in -it---provided the way the field is set still reflects whether or not you -want a fastmap. @code{re_search} will still either do nothing if -@code{fastmap} is null or, if it isn't, compile a new fastmap for the -new pattern. - -@node GNU Translate Tables, Using Registers, Searching with Fastmaps, GNU Regex Functions -@subsection GNU Translate Tables - -If you set the @code{translate} field of a pattern buffer to a translate -table, then the @sc{gnu} Regex functions to which you've passed that -pattern buffer use it to apply a simple transformation -to all the regular expression and string characters at which they look. - -A @dfn{translate table} is an array indexed by the characters in your -character set. Under the @sc{ascii} encoding, therefore, a translate -table has 256 elements. The array's elements are also characters in -your character set. When the Regex functions see a character @var{c}, -they use @code{translate[@var{c}]} in its place, with one exception: the -character after a @samp{\} is not translated. (This ensures that, the -operators, e.g., @samp{\B} and @samp{\b}, are always distinguishable.) - -For example, a table that maps all lowercase letters to the -corresponding uppercase ones would cause the matcher to ignore -differences in case.@footnote{A table that maps all uppercase letters to -the corresponding lowercase ones would work just as well for this -purpose.} Such a table would map all characters except lowercase letters -to themselves, and lowercase letters to the corresponding uppercase -ones. Under the @sc{ascii} encoding, here's how you could initialize -such a table (we'll call it @code{case_fold}): - -@example -for (i = 0; i < 256; i++) - case_fold[i] = i; -for (i = 'a'; i <= 'z'; i++) - case_fold[i] = i - ('a' - 'A'); -@end example - -You tell Regex to use a translate table on a given pattern buffer by -assigning that table's address to the @code{translate} field of that -buffer. If you don't want Regex to do any translation, put zero into -this field. You'll get weird results if you change the table's contents -anytime between compiling the pattern buffer, compiling its fastmap, and -matching or searching with the pattern buffer. - -@node Using Registers, Freeing GNU Pattern Buffers, GNU Translate Tables, GNU Regex Functions -@subsection Using Registers - -A group in a regular expression can match a (posssibly empty) substring -of the string that regular expression as a whole matched. The matcher -remembers the beginning and end of the substring matched by -each group. - -To find out what they matched, pass a nonzero @var{regs} argument to a -@sc{gnu} matching or searching function (@pxref{GNU Matching} and -@ref{GNU Searching}), i.e., the address of a structure of this type, as -defined in @file{regex.h}: - -@c We don't bother to include this directly from regex.h, -@c since it changes so rarely. -@example -@tindex re_registers -@vindex num_regs @r{in @code{struct re_registers}} -@vindex start @r{in @code{struct re_registers}} -@vindex end @r{in @code{struct re_registers}} -struct re_registers -@{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -@}; -@end example - -Except for (possibly) the @var{num_regs}'th element (see below), the -@var{i}th element of the @code{start} and @code{end} arrays records -information about the @var{i}th group in the pattern. (They're declared -as C pointers, but this is only because not all C compilers accept -zero-length arrays; conceptually, it is simplest to think of them as -arrays.) - -The @code{start} and @code{end} arrays are allocated in various ways, -depending on the value of the @code{regs_allocated} -@vindex regs_allocated -field in the pattern buffer passed to the matcher. - -The simplest and perhaps most useful is to let the matcher (re)allocate -enough space to record information for all the groups in the regular -expression. If @code{regs_allocated} is @code{REGS_UNALLOCATED}, -@vindex REGS_UNALLOCATED -the matcher allocates @math{1 + @var{re_nsub}} (another field in the -pattern buffer; @pxref{GNU Pattern Buffers}). The extra element is set -to @math{-1}, and sets @code{regs_allocated} to @code{REGS_REALLOCATE}. -@vindex REGS_REALLOCATE -Then on subsequent calls with the same pattern buffer and @var{regs} -arguments, the matcher reallocates more space if necessary. - -It would perhaps be more logical to make the @code{regs_allocated} field -part of the @code{re_registers} structure, instead of part of the -pattern buffer. But in that case the caller would be forced to -initialize the structure before passing it. Much existing code doesn't -do this initialization, and it's arguably better to avoid it anyway. - -@code{re_compile_pattern} sets @code{regs_allocated} to -@code{REGS_UNALLOCATED}, -so if you use the GNU regular expression -functions, you get this behavior by default. - -xx document re_set_registers - -@sc{posix}, on the other hand, requires a different interface: the -caller is supposed to pass in a fixed-length array which the matcher -fills. Therefore, if @code{regs_allocated} is @code{REGS_FIXED} -@vindex REGS_FIXED -the matcher simply fills that array. - -The following examples illustrate the information recorded in the -@code{re_registers} structure. (In all of them, @samp{(} represents the -open-group and @samp{)} the close-group operator. The first character -in the string @var{string} is at index 0.) - -@c xx i'm not sure this is all true anymore. - -@itemize @bullet - -@item -If the regular expression has an @w{@var{i}-th} -group not contained within another group that matches a -substring of @var{string}, then the function sets -@code{@w{@var{regs}->}start[@var{i}]} to the index in @var{string} where -the substring matched by the @w{@var{i}-th} group begins, and -@code{@w{@var{regs}->}end[@var{i}]} to the index just beyond that -substring's end. The function sets @code{@w{@var{regs}->}start[0]} and -@code{@w{@var{regs}->}end[0]} to analogous information about the entire -pattern. - -For example, when you match @samp{((a)(b))} against @samp{ab}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 2 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 2 in @code{@w{@var{regs}->}end[1]} - -@item -0 in @code{@w{@var{regs}->}start[2]} and 1 in @code{@w{@var{regs}->}end[2]} - -@item -1 in @code{@w{@var{regs}->}start[3]} and 2 in @code{@w{@var{regs}->}end[3]} -@end itemize - -@item -If a group matches more than once (as it might if followed by, -e.g., a repetition operator), then the function reports the information -about what the group @emph{last} matched. - -For example, when you match the pattern @samp{(a)*} against the string -@samp{aa}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 2 in @code{@w{@var{regs}->}end[0]} - -@item -1 in @code{@w{@var{regs}->}start[1]} and 2 in @code{@w{@var{regs}->}end[1]} -@end itemize - -@item -If the @w{@var{i}-th} group does not participate in a -successful match, e.g., it is an alternative not taken or a -repetition operator allows zero repetitions of it, then the function -sets @code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to @math{-1}. - -For example, when you match the pattern @samp{(a)*b} against -the string @samp{b}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[1]} and @math{-1} in @code{@w{@var{regs}->}end[1]} -@end itemize - -@item -If the @w{@var{i}-th} group matches a zero-length string, then the -function sets @code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to the index just beyond that -zero-length string. - -For example, when you match the pattern @samp{(a*)b} against the string -@samp{b}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 0 in @code{@w{@var{regs}->}end[1]} -@end itemize - -@ignore -The function sets @code{@w{@var{regs}->}start[0]} and -@code{@w{@var{regs}->}end[0]} to analogous information about the entire -pattern. - -For example, when you match the pattern @samp{(a*)} against the empty -string, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 0 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 0 in @code{@w{@var{regs}->}end[1]} -@end itemize -@end ignore - -@item -If an @w{@var{i}-th} group contains a @w{@var{j}-th} group -in turn not contained within any other group within group @var{i} and -the function reports a match of the @w{@var{i}-th} group, then it -records in @code{@w{@var{regs}->}start[@var{j}]} and -@code{@w{@var{regs}->}end[@var{j}]} the last match (if it matched) of -the @w{@var{j}-th} group. - -For example, when you match the pattern @samp{((a*)b)*} against the -string @samp{abb}, @w{group 2} last matches the empty string, so you -get what it previously matched: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 3 in @code{@w{@var{regs}->}end[0]} - -@item -2 in @code{@w{@var{regs}->}start[1]} and 3 in @code{@w{@var{regs}->}end[1]} - -@item -2 in @code{@w{@var{regs}->}start[2]} and 2 in @code{@w{@var{regs}->}end[2]} -@end itemize - -When you match the pattern @samp{((a)*b)*} against the string -@samp{abb}, @w{group 2} doesn't participate in the last match, so you -get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 3 in @code{@w{@var{regs}->}end[0]} - -@item -2 in @code{@w{@var{regs}->}start[1]} and 3 in @code{@w{@var{regs}->}end[1]} - -@item -0 in @code{@w{@var{regs}->}start[2]} and 1 in @code{@w{@var{regs}->}end[2]} -@end itemize - -@item -If an @w{@var{i}-th} group contains a @w{@var{j}-th} group -in turn not contained within any other group within group @var{i} -and the function sets -@code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to @math{-1}, then it also sets -@code{@w{@var{regs}->}start[@var{j}]} and -@code{@w{@var{regs}->}end[@var{j}]} to @math{-1}. - -For example, when you match the pattern @samp{((a)*b)*c} against the -string @samp{c}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[1]} and @math{-1} in @code{@w{@var{regs}->}end[1]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[2]} and @math{-1} in @code{@w{@var{regs}->}end[2]} -@end itemize - -@end itemize - -@node Freeing GNU Pattern Buffers, , Using Registers, GNU Regex Functions -@subsection Freeing GNU Pattern Buffers - -To free any allocated fields of a pattern buffer, you can use the -@sc{posix} function described in @ref{Freeing POSIX Pattern Buffers}, -since the type @code{regex_t}---the type for @sc{posix} pattern -buffers---is equivalent to the type @code{re_pattern_buffer}. After -freeing a pattern buffer, you need to again compile a regular expression -in it (@pxref{GNU Regular Expression Compiling}) before passing it to -a matching or searching function. - - -@node POSIX Regex Functions, BSD Regex Functions, GNU Regex Functions, Programming with Regex -@section POSIX Regex Functions - -If you're writing code that has to be @sc{posix} compatible, you'll need -to use these functions. Their interfaces are as specified by @sc{posix}, -draft 1003.2/D11.2. - -@menu -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () -@end menu - - -@node POSIX Pattern Buffers, POSIX Regular Expression Compiling, , POSIX Regex Functions -@subsection POSIX Pattern Buffers - -To compile or match a given regular expression the @sc{posix} way, you -must supply a pattern buffer exactly the way you do for @sc{gnu} -(@pxref{GNU Pattern Buffers}). @sc{posix} pattern buffers have type -@code{regex_t}, which is equivalent to the @sc{gnu} pattern buffer -type @code{re_pattern_buffer}. - - -@node POSIX Regular Expression Compiling, POSIX Matching, POSIX Pattern Buffers, POSIX Regex Functions -@subsection POSIX Regular Expression Compiling - -With @sc{posix}, you can only search for a given regular expression; you -can't match it. To do this, you must first compile it in a -pattern buffer, using @code{regcomp}. - -@ignore -Before calling @code{regcomp}, you must initialize this pattern buffer -as you do for @sc{gnu} (@pxref{GNU Regular Expression Compiling}). See -below, however, for how to choose a syntax with which to compile. -@end ignore - -To compile a pattern buffer, use: - -@findex regcomp -@example -int -regcomp (regex_t *@var{preg}, const char *@var{regex}, int @var{cflags}) -@end example - -@noindent -@var{preg} is the initialized pattern buffer's address, @var{regex} is -the regular expression's address, and @var{cflags} is the compilation -flags, which Regex considers as a collection of bits. Here are the -valid bits, as defined in @file{regex.h}: - -@table @code - -@item REG_EXTENDED -@vindex REG_EXTENDED -says to use @sc{posix} Extended Regular Expression syntax; if this isn't -set, then says to use @sc{posix} Basic Regular Expression syntax. -@code{regcomp} sets @var{preg}'s @code{syntax} field accordingly. - -@item REG_ICASE -@vindex REG_ICASE -@cindex ignoring case -says to ignore case; @code{regcomp} sets @var{preg}'s @code{translate} -field to a translate table which ignores case, replacing anything you've -put there before. - -@item REG_NOSUB -@vindex REG_NOSUB -says to set @var{preg}'s @code{no_sub} field; @pxref{POSIX Matching}, -for what this means. - -@item REG_NEWLINE -@vindex REG_NEWLINE -says that a: - -@itemize @bullet - -@item -match-any-character operator (@pxref{Match-any-character -Operator}) doesn't match a newline. - -@item -nonmatching list not containing a newline (@pxref{List -Operators}) matches a newline. - -@item -match-beginning-of-line operator (@pxref{Match-beginning-of-line -Operator}) matches the empty string immediately after a newline, -regardless of how @code{REG_NOTBOL} is set (@pxref{POSIX Matching}, for -an explanation of @code{REG_NOTBOL}). - -@item -match-end-of-line operator (@pxref{Match-beginning-of-line -Operator}) matches the empty string immediately before a newline, -regardless of how @code{REG_NOTEOL} is set (@pxref{POSIX Matching}, -for an explanation of @code{REG_NOTEOL}). - -@end itemize - -@end table - -If @code{regcomp} successfully compiles the regular expression, it -returns zero and sets @code{*@var{pattern_buffer}} to the compiled -pattern. Except for @code{syntax} (which it sets as explained above), it -also sets the same fields the same way as does the @sc{gnu} compiling -function (@pxref{GNU Regular Expression Compiling}). - -If @code{regcomp} can't compile the regular expression, it returns one -of the error codes listed here. (Except when noted differently, the -syntax of in all examples below is basic regular expression syntax.) - -@table @code - -@comment repetitions -@item REG_BADRPT -For example, the consecutive repetition operators @samp{**} in -@samp{a**} are invalid. As another example, if the syntax is extended -regular expression syntax, then the repetition operator @samp{*} with -nothing on which to operate in @samp{*} is invalid. - -@item REG_BADBR -For example, the @var{count} @samp{-1} in @samp{a\@{-1} is invalid. - -@item REG_EBRACE -For example, @samp{a\@{1} is missing a close-interval operator. - -@comment lists -@item REG_EBRACK -For example, @samp{[a} is missing a close-list operator. - -@item REG_ERANGE -For example, the range ending point @samp{z} that collates lower than -does its starting point @samp{a} in @samp{[z-a]} is invalid. Also, the -range with the character class @samp{[:alpha:]} as its starting point in -@samp{[[:alpha:]-|]}. - -@item REG_ECTYPE -For example, the character class name @samp{foo} in @samp{[[:foo:]} is -invalid. - -@comment groups -@item REG_EPAREN -For example, @samp{a\)} is missing an open-group operator and @samp{\(a} -is missing a close-group operator. - -@item REG_ESUBREG -For example, the back reference @samp{\2} that refers to a nonexistent -subexpression in @samp{\(a\)\2} is invalid. - -@comment unfinished business - -@item REG_EEND -Returned when a regular expression causes no other more specific error. - -@item REG_EESCAPE -For example, the trailing backslash @samp{\} in @samp{a\} is invalid, as is the -one in @samp{\}. - -@comment kitchen sink -@item REG_BADPAT -For example, in the extended regular expression syntax, the empty group -@samp{()} in @samp{a()b} is invalid. - -@comment internal -@item REG_ESIZE -Returned when a regular expression needs a pattern buffer larger than -65536 bytes. - -@item REG_ESPACE -Returned when a regular expression makes Regex to run out of memory. - -@end table - - -@node POSIX Matching, Reporting Errors, POSIX Regular Expression Compiling, POSIX Regex Functions -@subsection POSIX Matching - -Matching the @sc{posix} way means trying to match a null-terminated -string starting at its first character. Once you've compiled a pattern -into a pattern buffer (@pxref{POSIX Regular Expression Compiling}), you -can ask the matcher to match that pattern against a string using: - -@findex regexec -@example -int -regexec (const regex_t *@var{preg}, const char *@var{string}, - size_t @var{nmatch}, regmatch_t @var{pmatch}[], int @var{eflags}) -@end example - -@noindent -@var{preg} is the address of a pattern buffer for a compiled pattern. -@var{string} is the string you want to match. - -@xref{Using Byte Offsets}, for an explanation of @var{pmatch}. If you -pass zero for @var{nmatch} or you compiled @var{preg} with the -compilation flag @code{REG_NOSUB} set, then @code{regexec} will ignore -@var{pmatch}; otherwise, you must allocate it to have at least -@var{nmatch} elements. @code{regexec} will record @var{nmatch} byte -offsets in @var{pmatch}, and set to @math{-1} any unused elements up to -@math{@var{pmatch}@code{[@var{nmatch}]} - 1}. - -@var{eflags} specifies @dfn{execution flags}---namely, the two bits -@code{REG_NOTBOL} and @code{REG_NOTEOL} (defined in @file{regex.h}). If -you set @code{REG_NOTBOL}, then the match-beginning-of-line operator -(@pxref{Match-beginning-of-line Operator}) always fails to match. -This lets you match against pieces of a line, as you would need to if, -say, searching for repeated instances of a given pattern in a line; it -would work correctly for patterns both with and without -match-beginning-of-line operators. @code{REG_NOTEOL} works analogously -for the match-end-of-line operator (@pxref{Match-end-of-line -Operator}); it exists for symmetry. - -@code{regexec} tries to find a match for @var{preg} in @var{string} -according to the syntax in @var{preg}'s @code{syntax} field. -(@xref{POSIX Regular Expression Compiling}, for how to set it.) The -function returns zero if the compiled pattern matches @var{string} and -@code{REG_NOMATCH} (defined in @file{regex.h}) if it doesn't. - -@node Reporting Errors, Using Byte Offsets, POSIX Matching, POSIX Regex Functions -@subsection Reporting Errors - -If either @code{regcomp} or @code{regexec} fail, they return a nonzero -error code, the possibilities for which are defined in @file{regex.h}. -@xref{POSIX Regular Expression Compiling}, and @ref{POSIX Matching}, for -what these codes mean. To get an error string corresponding to these -codes, you can use: - -@findex regerror -@example -size_t -regerror (int @var{errcode}, - const regex_t *@var{preg}, - char *@var{errbuf}, - size_t @var{errbuf_size}) -@end example - -@noindent -@var{errcode} is an error code, @var{preg} is the address of the pattern -buffer which provoked the error, @var{errbuf} is the error buffer, and -@var{errbuf_size} is @var{errbuf}'s size. - -@code{regerror} returns the size in bytes of the error string -corresponding to @var{errcode} (including its terminating null). If -@var{errbuf} and @var{errbuf_size} are nonzero, it also returns in -@var{errbuf} the first @math{@var{errbuf_size} - 1} characters of the -error string, followed by a null. -@var{errbuf_size} must be a nonnegative number less than or equal to the -size in bytes of @var{errbuf}. - -You can call @code{regerror} with a null @var{errbuf} and a zero -@var{errbuf_size} to determine how large @var{errbuf} need be to -accommodate @code{regerror}'s error string. - -@node Using Byte Offsets, Freeing POSIX Pattern Buffers, Reporting Errors, POSIX Regex Functions -@subsection Using Byte Offsets - -In @sc{posix}, variables of type @code{regmatch_t} hold analogous -information, but are not identical to, @sc{gnu}'s registers (@pxref{Using -Registers}). To get information about registers in @sc{posix}, pass to -@code{regexec} a nonzero @var{pmatch} of type @code{regmatch_t}, i.e., -the address of a structure of this type, defined in -@file{regex.h}: - -@tindex regmatch_t -@example -typedef struct -@{ - regoff_t rm_so; - regoff_t rm_eo; -@} regmatch_t; -@end example - -When reading in @ref{Using Registers}, about how the matching function -stores the information into the registers, substitute @var{pmatch} for -@var{regs}, @code{@w{@var{pmatch}[@var{i}]->}rm_so} for -@code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{pmatch}[@var{i}]->}rm_eo} for -@code{@w{@var{regs}->}end[@var{i}]}. - -@node Freeing POSIX Pattern Buffers, , Using Byte Offsets, POSIX Regex Functions -@subsection Freeing POSIX Pattern Buffers - -To free any allocated fields of a pattern buffer, use: - -@findex regfree -@example -void -regfree (regex_t *@var{preg}) -@end example - -@noindent -@var{preg} is the pattern buffer whose allocated fields you want freed. -@code{regfree} also sets @var{preg}'s @code{allocated} and @code{used} -fields to zero. After freeing a pattern buffer, you need to again -compile a regular expression in it (@pxref{POSIX Regular Expression -Compiling}) before passing it to the matching function (@pxref{POSIX -Matching}). - - -@node BSD Regex Functions, , POSIX Regex Functions, Programming with Regex -@section BSD Regex Functions - -If you're writing code that has to be Berkeley @sc{unix} compatible, -you'll need to use these functions whose interfaces are the same as those -in Berkeley @sc{unix}. - -@menu -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () -@end menu - -@node BSD Regular Expression Compiling, BSD Searching, , BSD Regex Functions -@subsection BSD Regular Expression Compiling - -With Berkeley @sc{unix}, you can only search for a given regular -expression; you can't match one. To search for it, you must first -compile it. Before you compile it, you must indicate the regular -expression syntax you want it compiled according to by setting the -variable @code{re_syntax_options} (declared in @file{regex.h} to some -syntax (@pxref{Regular Expression Syntax}). - -To compile a regular expression use: - -@findex re_comp -@example -char * -re_comp (char *@var{regex}) -@end example - -@noindent -@var{regex} is the address of a null-terminated regular expression. -@code{re_comp} uses an internal pattern buffer, so you can use only the -most recently compiled pattern buffer. This means that if you want to -use a given regular expression that you've already compiled---but it -isn't the latest one you've compiled---you'll have to recompile it. If -you call @code{re_comp} with the null string (@emph{not} the empty -string) as the argument, it doesn't change the contents of the pattern -buffer. - -If @code{re_comp} successfully compiles the regular expression, it -returns zero. If it can't compile the regular expression, it returns -an error string. @code{re_comp}'s error messages are identical to those -of @code{re_compile_pattern} (@pxref{GNU Regular Expression -Compiling}). - -@node BSD Searching, , BSD Regular Expression Compiling, BSD Regex Functions -@subsection BSD Searching - -Searching the Berkeley @sc{unix} way means searching in a string -starting at its first character and trying successive positions within -it to find a match. Once you've compiled a pattern using @code{re_comp} -(@pxref{BSD Regular Expression Compiling}), you can ask Regex -to search for that pattern in a string using: - -@findex re_exec -@example -int -re_exec (char *@var{string}) -@end example - -@noindent -@var{string} is the address of the null-terminated string in which you -want to search. - -@code{re_exec} returns either 1 for success or 0 for failure. It -automatically uses a @sc{gnu} fastmap (@pxref{Searching with Fastmaps}). - - -@node Copying, Index, Programming with Regex, Top -@appendix GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 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. -@end display - -@unnumberedsec 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. - -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -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. - -@item -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. - -@item -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: - -@enumerate a -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -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. - -@item -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.) -@end enumerate - -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. - -@item -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: - -@enumerate a -@item -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, - -@item -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, - -@item -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.) -@end enumerate - -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -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. - -@item -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 enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec 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. - -@smallexample -@var{one line to give the program's name and a brief idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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. -@end smallexample - -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: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{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. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{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: - -@example -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end example - -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. - - -@node Index, , Copying, Top -@unnumbered Index - -@printindex cp - -@contents - -@bye diff --git a/gnu/lib/regex-0.12/doc/texinfo.tex b/gnu/lib/regex-0.12/doc/texinfo.tex deleted file mode 100644 index d10917e237db..000000000000 --- a/gnu/lib/regex-0.12/doc/texinfo.tex +++ /dev/null @@ -1,3941 +0,0 @@ -%% TeX macros to handle texinfo files - -% Copyright (C) 1985, 86, 88, 90, 91, 92, 1993 Free Software Foundation, Inc. - -%This texinfo.tex file 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 texinfo.tex file 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 texinfo.tex file; see the file COPYING. If not, write -%to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, -%USA. - - -%In other words, you are welcome to use, share and improve this program. -%You are forbidden to forbid anyone else to use, share and improve -%what you give them. Help stamp out software-hoarding! - -\def\texinfoversion{2.104} -\message{Loading texinfo package [Version \texinfoversion]:} -\message{} - -% Print the version number if in a .fmt file. -\everyjob{\message{[Texinfo version \texinfoversion]}\message{}} - -% Save some parts of plain tex whose names we will redefine. - -\let\ptexlbrace=\{ -\let\ptexrbrace=\} -\let\ptexdots=\dots -\let\ptexdot=\. -\let\ptexstar=\* -\let\ptexend=\end -\let\ptexbullet=\bullet -\let\ptexb=\b -\let\ptexc=\c -\let\ptexi=\i -\let\ptext=\t -\let\ptexl=\l -\let\ptexL=\L - -\def\tie{\penalty 10000\ } % Save plain tex definition of ~. - -\message{Basics,} -\chardef\other=12 - -% If this character appears in an error message or help string, it -% starts a new line in the output. -\newlinechar = `^^J - -% Ignore a token. -% -\def\gobble#1{} - -\hyphenation{ap-pen-dix} -\hyphenation{mini-buf-fer mini-buf-fers} -\hyphenation{eshell} - -% Margin to add to right of even pages, to left of odd pages. -\newdimen \bindingoffset \bindingoffset=0pt -\newdimen \normaloffset \normaloffset=\hoffset -\newdimen\pagewidth \newdimen\pageheight -\pagewidth=\hsize \pageheight=\vsize - -% Sometimes it is convenient to have everything in the transcript file -% and nothing on the terminal. We don't just call \tracingall here, -% since that produces some useless output on the terminal. -% -\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% -\def\loggingall{\tracingcommands2 \tracingstats2 - \tracingpages1 \tracingoutput1 \tracinglostchars1 - \tracingmacros2 \tracingparagraphs1 \tracingrestores1 - \showboxbreadth\maxdimen\showboxdepth\maxdimen -}% - -%---------------------Begin change----------------------- -% -%%%% For @cropmarks command. -% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986 -% -\newdimen\cornerlong \newdimen\cornerthick -\newdimen \topandbottommargin -\newdimen \outerhsize \newdimen \outervsize -\cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks -\outerhsize=7in -%\outervsize=9.5in -% Alternative @smallbook page size is 9.25in -\outervsize=9.25in -\topandbottommargin=.75in -% -%---------------------End change----------------------- - -% \onepageout takes a vbox as an argument. Note that \pagecontents -% does insertions itself, but you have to call it yourself. -\chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}} -\def\onepageout#1{\hoffset=\normaloffset -\ifodd\pageno \advance\hoffset by \bindingoffset -\else \advance\hoffset by -\bindingoffset\fi -{\escapechar=`\\\relax % makes sure backslash is used in output files. -\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}% -{\let\hsize=\pagewidth \makefootline}}}% -\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} - -%%%% For @cropmarks command %%%% - -% Here is a modification of the main output routine for Near East Publications -% This provides right-angle cropmarks at all four corners. -% The contents of the page are centerlined into the cropmarks, -% and any desired binding offset is added as an \hskip on either -% site of the centerlined box. (P. A. MacKay, 12 November, 1986) -% -\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up -{\escapechar=`\\\relax % makes sure backslash is used in output files. - \shipout - \vbox to \outervsize{\hsize=\outerhsize - \vbox{\line{\ewtop\hfill\ewtop}} - \nointerlineskip - \line{\vbox{\moveleft\cornerthick\nstop} - \hfill - \vbox{\moveright\cornerthick\nstop}} - \vskip \topandbottommargin - \centerline{\ifodd\pageno\hskip\bindingoffset\fi - \vbox{ - {\let\hsize=\pagewidth \makeheadline} - \pagebody{#1} - {\let\hsize=\pagewidth \makefootline}} - \ifodd\pageno\else\hskip\bindingoffset\fi} - \vskip \topandbottommargin plus1fill minus1fill - \boxmaxdepth\cornerthick - \line{\vbox{\moveleft\cornerthick\nsbot} - \hfill - \vbox{\moveright\cornerthick\nsbot}} - \nointerlineskip - \vbox{\line{\ewbot\hfill\ewbot}} - }} - \advancepageno - \ifnum\outputpenalty>-20000 \else\dosupereject\fi} -% -% Do @cropmarks to get crop marks -\def\cropmarks{\let\onepageout=\croppageout } - -\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} -{\catcode`\@ =11 -\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi -\dimen@=\dp#1 \unvbox#1 -\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi -\ifr@ggedbottom \kern-\dimen@ \vfil \fi} -} - -% -% Here are the rules for the cropmarks. Note that they are -% offset so that the space between them is truly \outerhsize or \outervsize -% (P. A. MacKay, 12 November, 1986) -% -\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} -\def\nstop{\vbox - {\hrule height\cornerthick depth\cornerlong width\cornerthick}} -\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} -\def\nsbot{\vbox - {\hrule height\cornerlong depth\cornerthick width\cornerthick}} - -% Parse an argument, then pass it to #1. The argument is the rest of -% the input line (except we remove a trailing comment). #1 should be a -% macro which expects an ordinary undelimited TeX argument. -% -\def\parsearg#1{% - \let\next = #1% - \begingroup - \obeylines - \futurelet\temp\parseargx -} - -% If the next token is an obeyed space (from an @example environment or -% the like), remove it and recurse. Otherwise, we're done. -\def\parseargx{% - % \obeyedspace is defined far below, after the definition of \sepspaces. - \ifx\obeyedspace\temp - \expandafter\parseargdiscardspace - \else - \expandafter\parseargline - \fi -} - -% Remove a single space (as the delimiter token to the macro call). -{\obeyspaces % - \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} - -{\obeylines % - \gdef\parseargline#1^^M{% - \endgroup % End of the group started in \parsearg. - % - % First remove any @c comment, then any @comment. - % Result of each macro is put in \toks0. - \argremovec #1\c\relax % - \expandafter\argremovecomment \the\toks0 \comment\relax % - % - % Call the caller's macro, saved as \next in \parsearg. - \expandafter\next\expandafter{\the\toks0}% - }% -} - -% Since all \c{,omment} does is throw away the argument, we can let TeX -% do that for us. The \relax here is matched by the \relax in the call -% in \parseargline; it could be more or less anything, its purpose is -% just to delimit the argument to the \c. -\def\argremovec#1\c#2\relax{\toks0 = {#1}} -\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} - -% \argremovec{,omment} might leave us with trailing spaces, though; e.g., -% @end itemize @c foo -% will have two active spaces as part of the argument with the -% `itemize'. Here we remove all active spaces from #1, and assign the -% result to \toks0. -% -% This loses if there are any *other* active characters besides spaces -% in the argument -- _ ^ +, for example -- since they get expanded. -% Fortunately, Texinfo does not define any such commands. (If it ever -% does, the catcode of the characters in questionwill have to be changed -% here.) But this means we cannot call \removeactivespaces as part of -% \argremovec{,omment}, since @c uses \parsearg, and thus the argument -% that \parsearg gets might well have any character at all in it. -% -\def\removeactivespaces#1{% - \begingroup - \ignoreactivespaces - \edef\temp{#1}% - \global\toks0 = \expandafter{\temp}% - \endgroup -} - -% Change the active space to expand to nothing. -% -\begingroup - \obeyspaces - \gdef\ignoreactivespaces{\obeyspaces\let =\empty} -\endgroup - - -\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} - -%% These are used to keep @begin/@end levels from running away -%% Call \inENV within environments (after a \begingroup) -\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} -\def\ENVcheck{% -\ifENV\errmessage{Still within an environment. Type Return to continue.} -\endgroup\fi} % This is not perfect, but it should reduce lossage - -% @begin foo is the same as @foo, for now. -\newhelp\EMsimple{Type to continue.} - -\outer\def\begin{\parsearg\beginxxx} - -\def\beginxxx #1{% -\expandafter\ifx\csname #1\endcsname\relax -{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else -\csname #1\endcsname\fi} - -% @end foo executes the definition of \Efoo. -% -\def\end{\parsearg\endxxx} -\def\endxxx #1{% - \removeactivespaces{#1}% - \edef\endthing{\the\toks0}% - % - \expandafter\ifx\csname E\endthing\endcsname\relax - \expandafter\ifx\csname \endthing\endcsname\relax - % There's no \foo, i.e., no ``environment'' foo. - \errhelp = \EMsimple - \errmessage{Undefined command `@end \endthing'}% - \else - \unmatchedenderror\endthing - \fi - \else - % Everything's ok; the right environment has been started. - \csname E\endthing\endcsname - \fi -} - -% There is an environment #1, but it hasn't been started. Give an error. -% -\def\unmatchedenderror#1{% - \errhelp = \EMsimple - \errmessage{This `@end #1' doesn't have a matching `@#1'}% -} - -% Define the control sequence \E#1 to give an unmatched @end error. -% -\def\defineunmatchedend#1{% - \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% -} - - -% Single-spacing is done by various environments. - -\newskip\singlespaceskip \singlespaceskip = \baselineskip -\def\singlespace{% -{\advance \baselineskip by -\singlespaceskip -\kern \baselineskip}% -\baselineskip=\singlespaceskip -} - -%% Simple single-character @ commands - -% @@ prints an @ -% Kludge this until the fonts are right (grr). -\def\@{{\tt \char '100}} - -% This is turned off because it was never documented -% and you can use @w{...} around a quote to suppress ligatures. -%% Define @` and @' to be the same as ` and ' -%% but suppressing ligatures. -%\def\`{{`}} -%\def\'{{'}} - -% Used to generate quoted braces. - -\def\mylbrace {{\tt \char '173}} -\def\myrbrace {{\tt \char '175}} -\let\{=\mylbrace -\let\}=\myrbrace - -% @: forces normal size whitespace following. -\def\:{\spacefactor=1000 } - -% @* forces a line break. -\def\*{\hfil\break\hbox{}\ignorespaces} - -% @. is an end-of-sentence period. -\def\.{.\spacefactor=3000 } - -% @w prevents a word break. Without the \leavevmode, @w at the -% beginning of a paragraph, when TeX is still in vertical mode, would -% produce a whole line of output instead of starting the paragraph. -\def\w#1{\leavevmode\hbox{#1}} - -% @group ... @end group forces ... to be all on one page, by enclosing -% it in a TeX vbox. We use \vtop instead of \vbox to construct the box -% to keep its height that of a normal line. According to the rules for -% \topskip (p.114 of the TeXbook), the glue inserted is -% max (\topskip - \ht (first item), 0). If that height is large, -% therefore, no glue is inserted, and the space between the headline and -% the text is small, which looks bad. -% -\def\group{\begingroup - \ifnum\catcode13=\active \else - \errhelp = \groupinvalidhelp - \errmessage{@group invalid in context where filling is enabled}% - \fi - % - % The \vtop we start below produces a box with normal height and large - % depth; thus, TeX puts \baselineskip glue before it, and (when the - % next line of text is done) \lineskip glue after it. (See p.82 of - % the TeXbook.) But the next line of text also gets us \parskip glue. - % Final result: space below is slightly more than space above. - \def\Egroup{% - \egroup % End the \vtop. - \endgroup % End the \group. - }% - % - \vtop\bgroup - % We have to put a strut on the last line in case the @group is in - % the midst of an example, rather than completely enclosing it. - % Otherwise, the interline space between the last line of the group - % and the first line afterwards is too small. But we can't put the - % strut in \Egroup, since there it would be on a line by itself. - % Hence this just inserts a strut at the beginning of each line. - \everypar = {\strut}% - % - % We do @comment here in case we are called inside an environment, - % such as @example, where each end-of-line in the input causes an - % end-of-line in the output. We don't want the end-of-line after - % the `@group' to put extra space in the output. Since @group - % should appear on a line by itself (according to the Texinfo - % manual), we don't worry about eating any user text. - \comment -} -% -% TeX puts in an \escapechar (i.e., `@') at the beginning of the help -% message, so this ends up printing `@group can only ...'. -% -\newhelp\groupinvalidhelp{% -group can only be used in environments such as @example,^^J% -where each line of input produces a line of output.} - -% @need space-in-mils -% forces a page break if there is not space-in-mils remaining. - -\newdimen\mil \mil=0.001in - -\def\need{\parsearg\needx} - -% Old definition--didn't work. -%\def\needx #1{\par % -%% This method tries to make TeX break the page naturally -%% if the depth of the box does not fit. -%{\baselineskip=0pt% -%\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000 -%\prevdepth=-1000pt -%}} - -\def\needx#1{% - % Go into vertical mode, so we don't make a big box in the middle of a - % paragraph. - \par - % - % Don't add any leading before our big empty box, but allow a page - % break, since the best break might be right here. - \allowbreak - \nointerlineskip - \vtop to #1\mil{\vfil}% - % - % TeX does not even consider page breaks if a penalty added to the - % main vertical list is 10000 or more. But in order to see if the - % empty box we just added fits on the page, we must make it consider - % page breaks. On the other hand, we don't want to actually break the - % page after the empty box. So we use a penalty of 9999. - % - % There is an extremely small chance that TeX will actually break the - % page at this \penalty, if there are no other feasible breakpoints in - % sight. (If the user is using lots of big @group commands, which - % almost-but-not-quite fill up a page, TeX will have a hard time doing - % good page breaking, for example.) However, I could not construct an - % example where a page broke at this \penalty; if it happens in a real - % document, then we can reconsider our strategy. - \penalty9999 - % - % Back up by the size of the box, whether we did a page break or not. - \kern -#1\mil - % - % Do not allow a page break right after this kern. - \nobreak -} - -% @br forces paragraph break - -\let\br = \par - -% @dots{} output some dots - -\def\dots{$\ldots$} - -% @page forces the start of a new page - -\def\page{\par\vfill\supereject} - -% @exdent text.... -% outputs text on separate line in roman font, starting at standard page margin - -% This records the amount of indent in the innermost environment. -% That's how much \exdent should take out. -\newskip\exdentamount - -% This defn is used inside fill environments such as @defun. -\def\exdent{\parsearg\exdentyyy} -\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} - -% This defn is used inside nofill environments such as @example. -\def\nofillexdent{\parsearg\nofillexdentyyy} -\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount -\leftline{\hskip\leftskip{\rm#1}}}} - -%\hbox{{\rm#1}}\hfil\break}} - -% @include file insert text of that file as input. - -\def\include{\parsearg\includezzz} -%Use \input\thisfile to avoid blank after \input, which may be an active -%char (in which case the blank would become the \input argument). -%The grouping keeps the value of \thisfile correct even when @include -%is nested. -\def\includezzz #1{\begingroup -\def\thisfile{#1}\input\thisfile -\endgroup} - -\def\thisfile{} - -% @center line outputs that line, centered - -\def\center{\parsearg\centerzzz} -\def\centerzzz #1{{\advance\hsize by -\leftskip -\advance\hsize by -\rightskip -\centerline{#1}}} - -% @sp n outputs n lines of vertical space - -\def\sp{\parsearg\spxxx} -\def\spxxx #1{\par \vskip #1\baselineskip} - -% @comment ...line which is ignored... -% @c is the same as @comment -% @ignore ... @end ignore is another way to write a comment - -\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other% -\parsearg \commentxxx} - -\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 } - -\let\c=\comment - -% Prevent errors for section commands. -% Used in @ignore and in failing conditionals. -\def\ignoresections{% -\let\chapter=\relax -\let\unnumbered=\relax -\let\top=\relax -\let\unnumberedsec=\relax -\let\unnumberedsection=\relax -\let\unnumberedsubsec=\relax -\let\unnumberedsubsection=\relax -\let\unnumberedsubsubsec=\relax -\let\unnumberedsubsubsection=\relax -\let\section=\relax -\let\subsec=\relax -\let\subsubsec=\relax -\let\subsection=\relax -\let\subsubsection=\relax -\let\appendix=\relax -\let\appendixsec=\relax -\let\appendixsection=\relax -\let\appendixsubsec=\relax -\let\appendixsubsection=\relax -\let\appendixsubsubsec=\relax -\let\appendixsubsubsection=\relax -\let\contents=\relax -\let\smallbook=\relax -\let\titlepage=\relax -} - -% Used in nested conditionals, where we have to parse the Texinfo source -% and so want to turn off most commands, in case they are used -% incorrectly. -% -\def\ignoremorecommands{% - \let\defcv = \relax - \let\deffn = \relax - \let\deffnx = \relax - \let\defindex = \relax - \let\defivar = \relax - \let\defmac = \relax - \let\defmethod = \relax - \let\defop = \relax - \let\defopt = \relax - \let\defspec = \relax - \let\deftp = \relax - \let\deftypefn = \relax - \let\deftypefun = \relax - \let\deftypevar = \relax - \let\deftypevr = \relax - \let\defun = \relax - \let\defvar = \relax - \let\defvr = \relax - \let\ref = \relax - \let\xref = \relax - \let\printindex = \relax - \let\pxref = \relax - \let\settitle = \relax - \let\include = \relax -} - -% Ignore @ignore ... @end ignore. -% -\def\ignore{\doignore{ignore}} - -% Also ignore @ifinfo, @menu, and @direntry text. -% -\def\ifinfo{\doignore{ifinfo}} -\def\menu{\doignore{menu}} -\def\direntry{\doignore{direntry}} - -% Ignore text until a line `@end #1'. -% -\def\doignore#1{\begingroup - % Don't complain about control sequences we have declared \outer. - \ignoresections - % - % Define a command to swallow text until we reach `@end #1'. - \long\def\doignoretext##1\end #1{\enddoignore}% - % - % Make sure that spaces turn into tokens that match what \doignoretext wants. - \catcode32 = 10 - % - % And now expand that command. - \doignoretext -} - -% What we do to finish off ignored text. -% -\def\enddoignore{\endgroup\ignorespaces}% - -\newif\ifwarnedobs\warnedobsfalse -\def\obstexwarn{% - \ifwarnedobs\relax\else - % We need to warn folks that they may have trouble with TeX 3.0. - % This uses \immediate\write16 rather than \message to get newlines. - \immediate\write16{} - \immediate\write16{***WARNING*** for users of Unix TeX 3.0!} - \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} - \immediate\write16{If you are running another version of TeX, relax.} - \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} - \immediate\write16{ Then upgrade your TeX installation if you can.} - \immediate\write16{If you are stuck with version 3.0, run the} - \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} - \immediate\write16{ to use a workaround.} - \immediate\write16{} - \warnedobstrue - \fi -} - -% **In TeX 3.0, setting text in \nullfont hangs tex. For a -% workaround (which requires the file ``dummy.tfm'' to be installed), -% uncomment the following line: -%%%%%\font\nullfont=dummy\let\obstexwarn=\relax - -% Ignore text, except that we keep track of conditional commands for -% purposes of nesting, up to an `@end #1' command. -% -\def\nestedignore#1{% - \obstexwarn - % We must actually expand the ignored text to look for the @end - % command, so that nested ignore constructs work. Thus, we put the - % text into a \vbox and then do nothing with the result. To minimize - % the change of memory overflow, we follow the approach outlined on - % page 401 of the TeXbook: make the current font be a dummy font. - % - \setbox0 = \vbox\bgroup - % Don't complain about control sequences we have declared \outer. - \ignoresections - % - % Define `@end #1' to end the box, which will in turn undefine the - % @end command again. - \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% - % - % We are going to be parsing Texinfo commands. Most cause no - % trouble when they are used incorrectly, but some commands do - % complicated argument parsing or otherwise get confused, so we - % undefine them. - % - % We can't do anything about stray @-signs, unfortunately; - % they'll produce `undefined control sequence' errors. - \ignoremorecommands - % - % Set the current font to be \nullfont, a TeX primitive, and define - % all the font commands to also use \nullfont. We don't use - % dummy.tfm, as suggested in the TeXbook, because not all sites - % might have that installed. Therefore, math mode will still - % produce output, but that should be an extremely small amount of - % stuff compared to the main input. - % - \nullfont - \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont - \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont - \let\tensf = \nullfont - % - % Don't complain when characters are missing from the fonts. - \tracinglostchars = 0 - % - % Don't bother to do space factor calculations. - \frenchspacing - % - % Don't report underfull hboxes. - \hbadness = 10000 - % - % Do minimal line-breaking. - \pretolerance = 10000 - % - % Do not execute instructions in @tex - \def\tex{\doignore{tex}} -} - -% @set VAR sets the variable VAR to an empty value. -% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. -% -% Since we want to separate VAR from REST-OF-LINE (which might be -% empty), we can't just use \parsearg; we have to insert a space of our -% own to delimit the rest of the line, and then take it out again if we -% didn't need it. -% -\def\set{\parsearg\setxxx} -\def\setxxx#1{\setyyy#1 \endsetyyy} -\def\setyyy#1 #2\endsetyyy{% - \def\temp{#2}% - \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty - \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. - \fi -} -\def\setzzz#1#2 \endsetzzz{\expandafter\xdef\csname SET#1\endcsname{#2}} - -% @clear VAR clears (i.e., unsets) the variable VAR. -% -\def\clear{\parsearg\clearxxx} -\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} - -% @value{foo} gets the text saved in variable foo. -% -\def\value#1{\expandafter - \ifx\csname SET#1\endcsname\relax - {\{No value for ``#1''\}} - \else \csname SET#1\endcsname \fi} - -% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined -% with @set. -% -\def\ifset{\parsearg\ifsetxxx} -\def\ifsetxxx #1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \expandafter\ifsetfail - \else - \expandafter\ifsetsucceed - \fi -} -\def\ifsetsucceed{\conditionalsucceed{ifset}} -\def\ifsetfail{\nestedignore{ifset}} -\defineunmatchedend{ifset} - -% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been -% defined with @set, or has been undefined with @clear. -% -\def\ifclear{\parsearg\ifclearxxx} -\def\ifclearxxx #1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \expandafter\ifclearsucceed - \else - \expandafter\ifclearfail - \fi -} -\def\ifclearsucceed{\conditionalsucceed{ifclear}} -\def\ifclearfail{\nestedignore{ifclear}} -\defineunmatchedend{ifclear} - -% @iftex always succeeds; we read the text following, through @end -% iftex). But `@end iftex' should be valid only after an @iftex. -% -\def\iftex{\conditionalsucceed{iftex}} -\defineunmatchedend{iftex} - -% We can't just want to start a group at @iftex (for example) and end it -% at @end iftex, since then @set commands inside the conditional have no -% effect (they'd get reverted at the end of the group). So we must -% define \Eiftex to redefine itself to be its previous value. (We can't -% just define it to fail again with an ``unmatched end'' error, since -% the @ifset might be nested.) -% -\def\conditionalsucceed#1{% - \edef\temp{% - % Remember the current value of \E#1. - \let\nece{prevE#1} = \nece{E#1}% - % - % At the `@end #1', redefine \E#1 to be its previous value. - \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% - }% - \temp -} - -% We need to expand lots of \csname's, but we don't want to expand the -% control sequences after we've constructed them. -% -\def\nece#1{\expandafter\noexpand\csname#1\endcsname} - -% @asis just yields its argument. Used with @table, for example. -% -\def\asis#1{#1} - -% @math means output in math mode. -% We don't use $'s directly in the definition of \math because control -% sequences like \math are expanded when the toc file is written. Then, -% we read the toc file back, the $'s will be normal characters (as they -% should be, according to the definition of Texinfo). So we must use a -% control sequence to switch into and out of math mode. -% -% This isn't quite enough for @math to work properly in indices, but it -% seems unlikely it will ever be needed there. -% -\let\implicitmath = $ -\def\math#1{\implicitmath #1\implicitmath} - -% @bullet and @minus need the same treatment as @math, just above. -\def\bullet{\implicitmath\ptexbullet\implicitmath} -\def\minus{\implicitmath-\implicitmath} - -\def\node{\ENVcheck\parsearg\nodezzz} -\def\nodezzz#1{\nodexxx [#1,]} -\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} -\let\nwnode=\node -\let\lastnode=\relax - -\def\donoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\setref{\lastnode}\fi -\let\lastnode=\relax} - -\def\unnumbnoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi -\let\lastnode=\relax} - -\def\appendixnoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi -\let\lastnode=\relax} - -\let\refill=\relax - -% @setfilename is done at the beginning of every texinfo file. -% So open here the files we need to have open while reading the input. -% This makes it possible to make a .fmt file for texinfo. -\def\setfilename{% - \readauxfile - \opencontents - \openindices - \fixbackslash % Turn off hack to swallow `\input texinfo'. - \global\let\setfilename=\comment % Ignore extra @setfilename cmds. - \comment % Ignore the actual filename. -} - -\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} - -\def\inforef #1{\inforefzzz #1,,,,**} -\def\inforefzzz #1,#2,#3,#4**{See Info file \file{\ignorespaces #3{}}, - node \samp{\ignorespaces#1{}}} - -\message{fonts,} - -% Font-change commands. - -% Texinfo supports the sans serif font style, which plain TeX does not. -% So we set up a \sf analogous to plain's \rm, etc. -\newfam\sffam -\def\sf{\fam=\sffam \tensf} -\let\li = \sf % Sometimes we call it \li, not \sf. - -%% Try out Computer Modern fonts at \magstephalf -\let\mainmagstep=\magstephalf - -\ifx\bigger\relax -\let\mainmagstep=\magstep1 -\font\textrm=cmr12 -\font\texttt=cmtt12 -\else -\font\textrm=cmr10 scaled \mainmagstep -\font\texttt=cmtt10 scaled \mainmagstep -\fi -% Instead of cmb10, you many want to use cmbx10. -% cmbx10 is a prettier font on its own, but cmb10 -% looks better when embedded in a line with cmr10. -\font\textbf=cmb10 scaled \mainmagstep -\font\textit=cmti10 scaled \mainmagstep -\font\textsl=cmsl10 scaled \mainmagstep -\font\textsf=cmss10 scaled \mainmagstep -\font\textsc=cmcsc10 scaled \mainmagstep -\font\texti=cmmi10 scaled \mainmagstep -\font\textsy=cmsy10 scaled \mainmagstep - -% A few fonts for @defun, etc. -\font\defbf=cmbx10 scaled \magstep1 %was 1314 -\font\deftt=cmtt10 scaled \magstep1 -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} - -% Fonts for indices and small examples. -% We actually use the slanted font rather than the italic, -% because texinfo normally uses the slanted fonts for that. -% Do not make many font distinctions in general in the index, since they -% aren't very useful. -\font\ninett=cmtt9 -\font\indrm=cmr9 -\font\indit=cmsl9 -\let\indsl=\indit -\let\indtt=\ninett -\let\indsf=\indrm -\let\indbf=\indrm -\let\indsc=\indrm -\font\indi=cmmi9 -\font\indsy=cmsy9 - -% Fonts for headings -\font\chaprm=cmbx12 scaled \magstep2 -\font\chapit=cmti12 scaled \magstep2 -\font\chapsl=cmsl12 scaled \magstep2 -\font\chaptt=cmtt12 scaled \magstep2 -\font\chapsf=cmss12 scaled \magstep2 -\let\chapbf=\chaprm -\font\chapsc=cmcsc10 scaled\magstep3 -\font\chapi=cmmi12 scaled \magstep2 -\font\chapsy=cmsy10 scaled \magstep3 - -\font\secrm=cmbx12 scaled \magstep1 -\font\secit=cmti12 scaled \magstep1 -\font\secsl=cmsl12 scaled \magstep1 -\font\sectt=cmtt12 scaled \magstep1 -\font\secsf=cmss12 scaled \magstep1 -\font\secbf=cmbx12 scaled \magstep1 -\font\secsc=cmcsc10 scaled\magstep2 -\font\seci=cmmi12 scaled \magstep1 -\font\secsy=cmsy10 scaled \magstep2 - -% \font\ssecrm=cmbx10 scaled \magstep1 % This size an font looked bad. -% \font\ssecit=cmti10 scaled \magstep1 % The letters were too crowded. -% \font\ssecsl=cmsl10 scaled \magstep1 -% \font\ssectt=cmtt10 scaled \magstep1 -% \font\ssecsf=cmss10 scaled \magstep1 - -%\font\ssecrm=cmb10 scaled 1315 % Note the use of cmb rather than cmbx. -%\font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than -%\font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1. -%\font\ssectt=cmtt10 scaled 1315 -%\font\ssecsf=cmss10 scaled 1315 - -%\let\ssecbf=\ssecrm - -\font\ssecrm=cmbx12 scaled \magstephalf -\font\ssecit=cmti12 scaled \magstephalf -\font\ssecsl=cmsl12 scaled \magstephalf -\font\ssectt=cmtt12 scaled \magstephalf -\font\ssecsf=cmss12 scaled \magstephalf -\font\ssecbf=cmbx12 scaled \magstephalf -\font\ssecsc=cmcsc10 scaled \magstep1 -\font\sseci=cmmi12 scaled \magstephalf -\font\ssecsy=cmsy10 scaled \magstep1 -% The smallcaps and symbol fonts should actually be scaled \magstep1.5, -% but that is not a standard magnification. - -% Fonts for title page: -\font\titlerm = cmbx12 scaled \magstep3 -\let\authorrm = \secrm - -% In order for the font changes to affect most math symbols and letters, -% we have to define the \textfont of the standard families. Since -% texinfo doesn't allow for producing subscripts and superscripts, we -% don't bother to reset \scriptfont and \scriptscriptfont (which would -% also require loading a lot more fonts). -% -\def\resetmathfonts{% - \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy - \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf - \textfont\ttfam = \tentt \textfont\sffam = \tensf -} - - -% The font-changing commands redefine the meanings of \tenSTYLE, instead -% of just \STYLE. We do this so that font changes will continue to work -% in math mode, where it is the current \fam that is relevant in most -% cases, not the current. Plain TeX does, for example, -% \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need -% to redefine \bf itself. -\def\textfonts{% - \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl - \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc - \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy - \resetmathfonts} -\def\chapfonts{% - \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl - \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc - \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy - \resetmathfonts} -\def\secfonts{% - \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl - \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc - \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy - \resetmathfonts} -\def\subsecfonts{% - \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl - \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc - \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy - \resetmathfonts} -\def\indexfonts{% - \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl - \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc - \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy - \resetmathfonts} - -% Set up the default fonts, so we can use them for creating boxes. -% -\textfonts - -% Count depth in font-changes, for error checks -\newcount\fontdepth \fontdepth=0 - -% Fonts for short table of contents. -\font\shortcontrm=cmr12 -\font\shortcontbf=cmbx12 -\font\shortcontsl=cmsl12 - -%% Add scribe-like font environments, plus @l for inline lisp (usually sans -%% serif) and @ii for TeX italic - -% \smartitalic{ARG} outputs arg in italics, followed by an italic correction -% unless the following character is such as not to need one. -\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} -\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx} - -\let\i=\smartitalic -\let\var=\smartitalic -\let\dfn=\smartitalic -\let\emph=\smartitalic -\let\cite=\smartitalic - -\def\b#1{{\bf #1}} -\let\strong=\b - -% We can't just use \exhyphenpenalty, because that only has effect at -% the end of a paragraph. Restore normal hyphenation at the end of the -% group within which \nohyphenation is presumably called. -% -\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} -\def\restorehyphenation{\hyphenchar\font = `- } - -\def\t#1{% - {\tt \nohyphenation \rawbackslash \frenchspacing #1}% - \null -} -\let\ttfont = \t -%\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null} -\def\samp #1{`\tclose{#1}'\null} -\def\key #1{{\tt \nohyphenation \uppercase{#1}}\null} -\def\ctrl #1{{\tt \rawbackslash \hat}#1} - -\let\file=\samp - -% @code is a modification of @t, -% which makes spaces the same size as normal in the surrounding text. -\def\tclose#1{% - {% - % Change normal interword space to be same as for the current font. - \spaceskip = \fontdimen2\font - % - % Switch to typewriter. - \tt - % - % But `\ ' produces the large typewriter interword space. - \def\ {{\spaceskip = 0pt{} }}% - % - % Turn off hyphenation. - \nohyphenation - % - \rawbackslash - \frenchspacing - #1% - }% - \null -} -\let\code=\tclose -%\let\exp=\tclose %Was temporary - -% @kbd is like @code, except that if the argument is just one @key command, -% then @kbd has no effect. - -\def\xkey{\key} -\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% -\ifx\one\xkey\ifx\threex\three \key{#2}% -\else\tclose{\look}\fi -\else\tclose{\look}\fi} - -% Typeset a dimension, e.g., `in' or `pt'. The only reason for the -% argument is to make the input look right: @dmn{pt} instead of -% @dmn{}pt. -% -\def\dmn#1{\thinspace #1} - -\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} - -\def\l#1{{\li #1}\null} % - -\def\r#1{{\rm #1}} % roman font -% Use of \lowercase was suggested. -\def\sc#1{{\smallcaps#1}} % smallcaps font -\def\ii#1{{\it #1}} % italic font - -\message{page headings,} - -\newskip\titlepagetopglue \titlepagetopglue = 1.5in -\newskip\titlepagebottomglue \titlepagebottomglue = 2pc - -% First the title page. Must do @settitle before @titlepage. -\def\titlefont#1{{\titlerm #1}} - -\newif\ifseenauthor -\newif\iffinishedtitlepage - -\def\shorttitlepage{\parsearg\shorttitlepagezzz} -\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% - \endgroup\page\hbox{}\page} - -\def\titlepage{\begingroup \parindent=0pt \textfonts - \let\subtitlerm=\tenrm -% I deinstalled the following change because \cmr12 is undefined. -% This change was not in the ChangeLog anyway. --rms. -% \let\subtitlerm=\cmr12 - \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% - % - \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% - % - % Leave some space at the very top of the page. - \vglue\titlepagetopglue - % - % Now you can print the title using @title. - \def\title{\parsearg\titlezzz}% - \def\titlezzz##1{\leftline{\titlefont{##1}} - % print a rule at the page bottom also. - \finishedtitlepagefalse - \vskip4pt \hrule height 4pt \vskip4pt}% - % No rule at page bottom unless we print one at the top with @title. - \finishedtitlepagetrue - % - % Now you can put text using @subtitle. - \def\subtitle{\parsearg\subtitlezzz}% - \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% - % - % @author should come last, but may come many times. - \def\author{\parsearg\authorzzz}% - \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi - {\authorfont \leftline{##1}}}% - % - % Most title ``pages'' are actually two pages long, with space - % at the top of the second. We don't want the ragged left on the second. - \let\oldpage = \page - \def\page{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - \oldpage - \let\page = \oldpage - \hbox{}}% -% \def\page{\oldpage \hbox{}} -} - -\def\Etitlepage{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - % It is important to do the page break before ending the group, - % because the headline and footline are only empty inside the group. - % If we use the new definition of \page, we always get a blank page - % after the title page, which we certainly don't want. - \oldpage - \endgroup - \HEADINGSon -} - -\def\finishtitlepage{% - \vskip4pt \hrule height 2pt - \vskip\titlepagebottomglue - \finishedtitlepagetrue -} - -%%% Set up page headings and footings. - -\let\thispage=\folio - -\newtoks \evenheadline % Token sequence for heading line of even pages -\newtoks \oddheadline % Token sequence for heading line of odd pages -\newtoks \evenfootline % Token sequence for footing line of even pages -\newtoks \oddfootline % Token sequence for footing line of odd pages - -% Now make Tex use those variables -\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline - \else \the\evenheadline \fi}} -\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline - \else \the\evenfootline \fi}\HEADINGShook} -\let\HEADINGShook=\relax - -% Commands to set those variables. -% For example, this is what @headings on does -% @evenheading @thistitle|@thispage|@thischapter -% @oddheading @thischapter|@thispage|@thistitle -% @evenfooting @thisfile|| -% @oddfooting ||@thisfile - -\def\evenheading{\parsearg\evenheadingxxx} -\def\oddheading{\parsearg\oddheadingxxx} -\def\everyheading{\parsearg\everyheadingxxx} - -\def\evenfooting{\parsearg\evenfootingxxx} -\def\oddfooting{\parsearg\oddfootingxxx} -\def\everyfooting{\parsearg\everyfootingxxx} - -{\catcode`\@=0 % - -\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} -\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} -\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish} -\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} -\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} -\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% -\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish} -\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}} -\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} -% -}% unbind the catcode of @. - -% @headings double turns headings on for double-sided printing. -% @headings single turns headings on for single-sided printing. -% @headings off turns them off. -% @headings on same as @headings double, retained for compatibility. -% @headings after turns on double-sided headings after this page. -% @headings doubleafter turns on double-sided headings after this page. -% @headings singleafter turns on single-sided headings after this page. -% By default, they are off. - -\def\headings #1 {\csname HEADINGS#1\endcsname} - -\def\HEADINGSoff{ -\global\evenheadline={\hfil} \global\evenfootline={\hfil} -\global\oddheadline={\hfil} \global\oddfootline={\hfil}} -\HEADINGSoff -% When we turn headings on, set the page number to 1. -% For double-sided printing, put current file name in lower left corner, -% chapter name on inside top of right hand pages, document -% title on inside top of left hand pages, and page numbers on outside top -% edge of all pages. -\def\HEADINGSdouble{ -%\pagealignmacro -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} -% For single-sided printing, chapter title goes across top left of page, -% page number on top right. -\def\HEADINGSsingle{ -%\pagealignmacro -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} -\def\HEADINGSon{\HEADINGSdouble} - -\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} -\let\HEADINGSdoubleafter=\HEADINGSafter -\def\HEADINGSdoublex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} - -\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} -\def\HEADINGSsinglex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} - -% Subroutines used in generating headings -% Produces Day Month Year style of output. -\def\today{\number\day\space -\ifcase\month\or -January\or February\or March\or April\or May\or June\or -July\or August\or September\or October\or November\or December\fi -\space\number\year} - -% Use this if you want the Month Day, Year style of output. -%\def\today{\ifcase\month\or -%January\or February\or March\or April\or May\or June\or -%July\or August\or September\or October\or November\or December\fi -%\space\number\day, \number\year} - -% @settitle line... specifies the title of the document, for headings -% It generates no output of its own - -\def\thistitle{No Title} -\def\settitle{\parsearg\settitlezzz} -\def\settitlezzz #1{\gdef\thistitle{#1}} - -\message{tables,} - -% @tabs -- simple alignment - -% These don't work. For one thing, \+ is defined as outer. -% So these macros cannot even be defined. - -%\def\tabs{\parsearg\tabszzz} -%\def\tabszzz #1{\settabs\+#1\cr} -%\def\tabline{\parsearg\tablinezzz} -%\def\tablinezzz #1{\+#1\cr} -%\def\&{&} - -% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). - -% default indentation of table text -\newdimen\tableindent \tableindent=.8in -% default indentation of @itemize and @enumerate text -\newdimen\itemindent \itemindent=.3in -% margin between end of table item and start of table text. -\newdimen\itemmargin \itemmargin=.1in - -% used internally for \itemindent minus \itemmargin -\newdimen\itemmax - -% Note @table, @vtable, and @vtable define @item, @itemx, etc., with -% these defs. -% They also define \itemindex -% to index the item name in whatever manner is desired (perhaps none). - -\def\internalBitem{\smallbreak \parsearg\itemzzz} -\def\internalBitemx{\par \parsearg\itemzzz} - -\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} -\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz} - -\def\internalBkitem{\smallbreak \parsearg\kitemzzz} -\def\internalBkitemx{\par \parsearg\kitemzzz} - -\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% - \itemzzz {#1}} - -\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% - \itemzzz {#1}} - -\def\itemzzz #1{\begingroup % - \advance\hsize by -\rightskip - \advance\hsize by -\tableindent - \setbox0=\hbox{\itemfont{#1}}% - \itemindex{#1}% - \nobreak % This prevents a break before @itemx. - % - % Be sure we are not still in the middle of a paragraph. - \parskip=0in - \par - % - % If the item text does not fit in the space we have, put it on a line - % by itself, and do not allow a page break either before or after that - % line. We do not start a paragraph here because then if the next - % command is, e.g., @kindex, the whatsit would get put into the - % horizontal list on a line by itself, resulting in extra blank space. - \ifdim \wd0>\itemmax - \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0 - \nobreak - \else - % The item text fits into the space. Start a paragraph, so that the - % following text (if any) will end up on the same line. Since that - % text will be indented by \tableindent, we make the item text be in - % a zero-width box. - \noindent - \rlap{\hskip -\tableindent\box0}% - \fi - \endgroup -} - -\def\item{\errmessage{@item while not in a table}} -\def\itemx{\errmessage{@itemx while not in a table}} -\def\kitem{\errmessage{@kitem while not in a table}} -\def\kitemx{\errmessage{@kitemx while not in a table}} -\def\xitem{\errmessage{@xitem while not in a table}} -\def\xitemx{\errmessage{@xitemx while not in a table}} - -%% Contains a kludge to get @end[description] to work -\def\description{\tablez{\dontindex}{1}{}{}{}{}} - -\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} -{\obeylines\obeyspaces% -\gdef\tablex #1^^M{% -\tabley\dontindex#1 \endtabley}} - -\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} -{\obeylines\obeyspaces% -\gdef\ftablex #1^^M{% -\tabley\fnitemindex#1 \endtabley -\def\Eftable{\endgraf\endgroup\afterenvbreak}% -\let\Etable=\relax}} - -\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} -{\obeylines\obeyspaces% -\gdef\vtablex #1^^M{% -\tabley\vritemindex#1 \endtabley -\def\Evtable{\endgraf\endgroup\afterenvbreak}% -\let\Etable=\relax}} - -\def\dontindex #1{} -\def\fnitemindex #1{\doind {fn}{\code{#1}}}% -\def\vritemindex #1{\doind {vr}{\code{#1}}}% - -{\obeyspaces % -\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% -\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} - -\def\tablez #1#2#3#4#5#6{% -\aboveenvbreak % -\begingroup % -\def\Edescription{\Etable}% Neccessary kludge. -\let\itemindex=#1% -\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % -\ifnum 0#4>0 \tableindent=#4\mil \fi % -\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % -\def\itemfont{#2}% -\itemmax=\tableindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \tableindent % -\exdentamount=\tableindent -\parindent = 0pt -\parskip = \smallskipamount -\ifdim \parskip=0pt \parskip=2pt \fi% -\def\Etable{\endgraf\endgroup\afterenvbreak}% -\let\item = \internalBitem % -\let\itemx = \internalBitemx % -\let\kitem = \internalBkitem % -\let\kitemx = \internalBkitemx % -\let\xitem = \internalBxitem % -\let\xitemx = \internalBxitemx % -} - -% This is the counter used by @enumerate, which is really @itemize - -\newcount \itemno - -\def\itemize{\parsearg\itemizezzz} - -\def\itemizezzz #1{% - \begingroup % ended by the @end itemsize - \itemizey {#1}{\Eitemize} -} - -\def\itemizey #1#2{% -\aboveenvbreak % -\itemmax=\itemindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \itemindent % -\exdentamount=\itemindent -\parindent = 0pt % -\parskip = \smallskipamount % -\ifdim \parskip=0pt \parskip=2pt \fi% -\def#2{\endgraf\endgroup\afterenvbreak}% -\def\itemcontents{#1}% -\let\item=\itemizeitem} - -% Set sfcode to normal for the chars that usually have another value. -% These are `.?!:;,' -\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 - \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } - -% \splitoff TOKENS\endmark defines \first to be the first token in -% TOKENS, and \rest to be the remainder. -% -\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% - -% Allow an optional argument of an uppercase letter, lowercase letter, -% or number, to specify the first label in the enumerated list. No -% argument is the same as `1'. -% -\def\enumerate{\parsearg\enumeratezzz} -\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} -\def\enumeratey #1 #2\endenumeratey{% - \begingroup % ended by the @end enumerate - % - % If we were given no argument, pretend we were given `1'. - \def\thearg{#1}% - \ifx\thearg\empty \def\thearg{1}\fi - % - % Detect if the argument is a single token. If so, it might be a - % letter. Otherwise, the only valid thing it can be is a number. - % (We will always have one token, because of the test we just made. - % This is a good thing, since \splitoff doesn't work given nothing at - % all -- the first parameter is undelimited.) - \expandafter\splitoff\thearg\endmark - \ifx\rest\empty - % Only one token in the argument. It could still be anything. - % A ``lowercase letter'' is one whose \lccode is nonzero. - % An ``uppercase letter'' is one whose \lccode is both nonzero, and - % not equal to itself. - % Otherwise, we assume it's a number. - % - % We need the \relax at the end of the \ifnum lines to stop TeX from - % continuing to look for a . - % - \ifnum\lccode\expandafter`\thearg=0\relax - \numericenumerate % a number (we hope) - \else - % It's a letter. - \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax - \lowercaseenumerate % lowercase letter - \else - \uppercaseenumerate % uppercase letter - \fi - \fi - \else - % Multiple tokens in the argument. We hope it's a number. - \numericenumerate - \fi -} - -% An @enumerate whose labels are integers. The starting integer is -% given in \thearg. -% -\def\numericenumerate{% - \itemno = \thearg - \startenumeration{\the\itemno}% -} - -% The starting (lowercase) letter is in \thearg. -\def\lowercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more lowercase letters in @enumerate; get a bigger - alphabet}% - \fi - \char\lccode\itemno - }% -} - -% The starting (uppercase) letter is in \thearg. -\def\uppercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more uppercase letters in @enumerate; get a bigger - alphabet} - \fi - \char\uccode\itemno - }% -} - -% Call itemizey, adding a period to the first argument and supplying the -% common last two arguments. Also subtract one from the initial value in -% \itemno, since @item increments \itemno. -% -\def\startenumeration#1{% - \advance\itemno by -1 - \itemizey{#1.}\Eenumerate\flushcr -} - -% @alphaenumerate and @capsenumerate are abbreviations for giving an arg -% to @enumerate. -% -\def\alphaenumerate{\enumerate{a}} -\def\capsenumerate{\enumerate{A}} -\def\Ealphaenumerate{\Eenumerate} -\def\Ecapsenumerate{\Eenumerate} - -% Definition of @item while inside @itemize. - -\def\itemizeitem{% -\advance\itemno by 1 -{\let\par=\endgraf \smallbreak}% -\ifhmode \errmessage{\in hmode at itemizeitem}\fi -{\parskip=0in \hskip 0pt -\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% -\vadjust{\penalty 1200}}% -\flushcr} - -\message{indexing,} -% Index generation facilities - -% Define \newwrite to be identical to plain tex's \newwrite -% except not \outer, so it can be used within \newindex. -{\catcode`\@=11 -\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} - -% \newindex {foo} defines an index named foo. -% It automatically defines \fooindex such that -% \fooindex ...rest of line... puts an entry in the index foo. -% It also defines \fooindfile to be the number of the output channel for -% the file that accumulates this index. The file's extension is foo. -% The name of an index should be no more than 2 characters long -% for the sake of vms. - -\def\newindex #1{ -\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file -\openout \csname#1indfile\endcsname \jobname.#1 % Open the file -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\doindex {#1}} -} - -% @defindex foo == \newindex{foo} - -\def\defindex{\parsearg\newindex} - -% Define @defcodeindex, like @defindex except put all entries in @code. - -\def\newcodeindex #1{ -\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file -\openout \csname#1indfile\endcsname \jobname.#1 % Open the file -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\docodeindex {#1}} -} - -\def\defcodeindex{\parsearg\newcodeindex} - -% @synindex foo bar makes index foo feed into index bar. -% Do this instead of @defindex foo if you don't want it as a separate index. -\def\synindex #1 #2 {% -\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname -\expandafter\let\csname#1indfile\endcsname=\synindexfoo -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\doindex {#2}}% -} - -% @syncodeindex foo bar similar, but put all entries made for index foo -% inside @code. -\def\syncodeindex #1 #2 {% -\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname -\expandafter\let\csname#1indfile\endcsname=\synindexfoo -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\docodeindex {#2}}% -} - -% Define \doindex, the driver for all \fooindex macros. -% Argument #1 is generated by the calling \fooindex macro, -% and it is "foo", the name of the index. - -% \doindex just uses \parsearg; it calls \doind for the actual work. -% This is because \doind is more useful to call from other macros. - -% There is also \dosubind {index}{topic}{subtopic} -% which makes an entry in a two-level index such as the operation index. - -\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} -\def\singleindexer #1{\doind{\indexname}{#1}} - -% like the previous two, but they put @code around the argument. -\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} -\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} - -\def\indexdummies{% -\def\_{{\realbackslash _}}% -\def\w{\realbackslash w }% -\def\bf{\realbackslash bf }% -\def\rm{\realbackslash rm }% -\def\sl{\realbackslash sl }% -\def\sf{\realbackslash sf}% -\def\tt{\realbackslash tt}% -\def\gtr{\realbackslash gtr}% -\def\less{\realbackslash less}% -\def\hat{\realbackslash hat}% -\def\char{\realbackslash char}% -\def\TeX{\realbackslash TeX}% -\def\dots{\realbackslash dots }% -\def\copyright{\realbackslash copyright }% -\def\tclose##1{\realbackslash tclose {##1}}% -\def\code##1{\realbackslash code {##1}}% -\def\samp##1{\realbackslash samp {##1}}% -\def\t##1{\realbackslash r {##1}}% -\def\r##1{\realbackslash r {##1}}% -\def\i##1{\realbackslash i {##1}}% -\def\b##1{\realbackslash b {##1}}% -\def\cite##1{\realbackslash cite {##1}}% -\def\key##1{\realbackslash key {##1}}% -\def\file##1{\realbackslash file {##1}}% -\def\var##1{\realbackslash var {##1}}% -\def\kbd##1{\realbackslash kbd {##1}}% -\def\dfn##1{\realbackslash dfn {##1}}% -\def\emph##1{\realbackslash emph {##1}}% -} - -% \indexnofonts no-ops all font-change commands. -% This is used when outputting the strings to sort the index by. -\def\indexdummyfont#1{#1} -\def\indexdummytex{TeX} -\def\indexdummydots{...} - -\def\indexnofonts{% -\let\w=\indexdummyfont -\let\t=\indexdummyfont -\let\r=\indexdummyfont -\let\i=\indexdummyfont -\let\b=\indexdummyfont -\let\emph=\indexdummyfont -\let\strong=\indexdummyfont -\let\cite=\indexdummyfont -\let\sc=\indexdummyfont -%Don't no-op \tt, since it isn't a user-level command -% and is used in the definitions of the active chars like <, >, |... -%\let\tt=\indexdummyfont -\let\tclose=\indexdummyfont -\let\code=\indexdummyfont -\let\file=\indexdummyfont -\let\samp=\indexdummyfont -\let\kbd=\indexdummyfont -\let\key=\indexdummyfont -\let\var=\indexdummyfont -\let\TeX=\indexdummytex -\let\dots=\indexdummydots -} - -% To define \realbackslash, we must make \ not be an escape. -% We must first make another character (@) an escape -% so we do not become unable to do a definition. - -{\catcode`\@=0 \catcode`\\=\other -@gdef@realbackslash{\}} - -\let\indexbackslash=0 %overridden during \printindex. - -\def\doind #1#2{% -{\count10=\lastpenalty % -{\indexdummies % Must do this here, since \bf, etc expand at this stage -\escapechar=`\\% -{\let\folio=0% Expand all macros now EXCEPT \folio -\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now -% so it will be output as is; and it will print as backslash in the indx. -% -% Now process the index-string once, with all font commands turned off, -% to get the string to sort the index by. -{\indexnofonts -\xdef\temp1{#2}% -}% -% Now produce the complete index entry. We process the index-string again, -% this time with font commands expanded, to get what to print in the index. -\edef\temp{% -\write \csname#1indfile\endcsname{% -\realbackslash entry {\temp1}{\folio}{#2}}}% -\temp }% -}\penalty\count10}} - -\def\dosubind #1#2#3{% -{\count10=\lastpenalty % -{\indexdummies % Must do this here, since \bf, etc expand at this stage -\escapechar=`\\% -{\let\folio=0% -\def\rawbackslashxx{\indexbackslash}% -% -% Now process the index-string once, with all font commands turned off, -% to get the string to sort the index by. -{\indexnofonts -\xdef\temp1{#2 #3}% -}% -% Now produce the complete index entry. We process the index-string again, -% this time with font commands expanded, to get what to print in the index. -\edef\temp{% -\write \csname#1indfile\endcsname{% -\realbackslash entry {\temp1}{\folio}{#2}{#3}}}% -\temp }% -}\penalty\count10}} - -% The index entry written in the file actually looks like -% \entry {sortstring}{page}{topic} -% or -% \entry {sortstring}{page}{topic}{subtopic} -% The texindex program reads in these files and writes files -% containing these kinds of lines: -% \initial {c} -% before the first topic whose initial is c -% \entry {topic}{pagelist} -% for a topic that is used without subtopics -% \primary {topic} -% for the beginning of a topic that is used with subtopics -% \secondary {subtopic}{pagelist} -% for each subtopic. - -% Define the user-accessible indexing commands -% @findex, @vindex, @kindex, @cindex. - -\def\findex {\fnindex} -\def\kindex {\kyindex} -\def\cindex {\cpindex} -\def\vindex {\vrindex} -\def\tindex {\tpindex} -\def\pindex {\pgindex} - -\def\cindexsub {\begingroup\obeylines\cindexsub} -{\obeylines % -\gdef\cindexsub "#1" #2^^M{\endgroup % -\dosubind{cp}{#2}{#1}}} - -% Define the macros used in formatting output of the sorted index material. - -% This is what you call to cause a particular index to get printed. -% Write -% @unnumbered Function Index -% @printindex fn - -\def\printindex{\parsearg\doprintindex} - -\def\doprintindex#1{% - \tex - \dobreak \chapheadingskip {10000} - \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other - \catcode`\$=\other\catcode`\_=\other - \catcode`\~=\other - % - % The following don't help, since the chars were translated - % when the raw index was written, and their fonts were discarded - % due to \indexnofonts. - %\catcode`\"=\active - %\catcode`\^=\active - %\catcode`\_=\active - %\catcode`\|=\active - %\catcode`\<=\active - %\catcode`\>=\active - % % - \def\indexbackslash{\rawbackslashxx} - \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt - \begindoublecolumns - % - % See if the index file exists and is nonempty. - \openin 1 \jobname.#1s - \ifeof 1 - % \enddoublecolumns gets confused if there is no text in the index, - % and it loses the chapter title and the aux file entries for the - % index. The easiest way to prevent this problem is to make sure - % there is some text. - (Index is nonexistent) - \else - % - % If the index file exists but is empty, then \openin leaves \ifeof - % false. We have to make TeX try to read something from the file, so - % it can discover if there is anything in it. - \read 1 to \temp - \ifeof 1 - (Index is empty) - \else - \input \jobname.#1s - \fi - \fi - \closein 1 - \enddoublecolumns - \Etex -} - -% These macros are used by the sorted index file itself. -% Change them to control the appearance of the index. - -% Same as \bigskipamount except no shrink. -% \balancecolumns gets confused if there is any shrink. -\newskip\initialskipamount \initialskipamount 12pt plus4pt - -\def\initial #1{% -{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt -\ifdim\lastskip<\initialskipamount -\removelastskip \penalty-200 \vskip \initialskipamount\fi -\line{\secbf#1\hfill}\kern 2pt\penalty10000}} - -% This typesets a paragraph consisting of #1, dot leaders, and then #2 -% flush to the right margin. It is used for index and table of contents -% entries. The paragraph is indented by \leftskip. -% -\def\entry #1#2{\begingroup - % - % Start a new paragraph if necessary, so our assignments below can't - % affect previous text. - \par - % - % Do not fill out the last line with white space. - \parfillskip = 0in - % - % No extra space above this paragraph. - \parskip = 0in - % - % Do not prefer a separate line ending with a hyphen to fewer lines. - \finalhyphendemerits = 0 - % - % \hangindent is only relevant when the entry text and page number - % don't both fit on one line. In that case, bob suggests starting the - % dots pretty far over on the line. Unfortunately, a large - % indentation looks wrong when the entry text itself is broken across - % lines. So we use a small indentation and put up with long leaders. - % - % \hangafter is reset to 1 (which is the value we want) at the start - % of each paragraph, so we need not do anything with that. - \hangindent=2em - % - % When the entry text needs to be broken, just fill out the first line - % with blank space. - \rightskip = 0pt plus1fil - % - % Start a ``paragraph'' for the index entry so the line breaking - % parameters we've set above will have an effect. - \noindent - % - % Insert the text of the index entry. TeX will do line-breaking on it. - #1% - % - % If we must, put the page number on a line of its own, and fill out - % this line with blank space. (The \hfil is overwhelmed with the - % fill leaders glue in \indexdotfill if the page number does fit.) - \hfil\penalty50 - \null\nobreak\indexdotfill % Have leaders before the page number. - % - % The `\ ' here is removed by the implicit \unskip that TeX does as - % part of (the primitive) \par. Without it, a spurious underfull - % \hbox ensues. - \ #2% The page number ends the paragraph. - \par -\endgroup} - -% Like \dotfill except takes at least 1 em. -\def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill} - -\def\primary #1{\line{#1\hfil}} - -\newskip\secondaryindent \secondaryindent=0.5cm - -\def\secondary #1#2{ -{\parfillskip=0in \parskip=0in -\hangindent =1in \hangafter=1 -\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par -}} - -%% Define two-column mode, which is used in indexes. -%% Adapted from the TeXbook, page 416. -\catcode `\@=11 - -\newbox\partialpage - -\newdimen\doublecolumnhsize - -\def\begindoublecolumns{\begingroup - % Grab any single-column material above us. - \output = {\global\setbox\partialpage - =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}% - \eject - % - % Now switch to the double-column output routine. - \output={\doublecolumnout}% - % - % Change the page size parameters. We could do this once outside this - % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 - % format, but then we repeat the same computation. Repeating a couple - % of assignments once per index is clearly meaningless for the - % execution time, so we may as well do it once. - % - % First we halve the line length, less a little for the gutter between - % the columns. We compute the gutter based on the line length, so it - % changes automatically with the paper format. The magic constant - % below is chosen so that the gutter has the same value (well, +- < - % 1pt) as it did when we hard-coded it. - % - % We put the result in a separate register, \doublecolumhsize, so we - % can restore it in \pagesofar, after \hsize itself has (potentially) - % been clobbered. - % - \doublecolumnhsize = \hsize - \advance\doublecolumnhsize by -.04154\hsize - \divide\doublecolumnhsize by 2 - \hsize = \doublecolumnhsize - % - % Double the \vsize as well. (We don't need a separate register here, - % since nobody clobbers \vsize.) - \vsize = 2\vsize - \doublecolumnpagegoal -} - -\def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage} - -\def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth - \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage - \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1} - \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3} - \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi - \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi -} -\def\doublecolumnpagegoal{% - \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@ -} -\def\pagesofar{\unvbox\partialpage % - \hsize=\doublecolumnhsize % have to restore this since output routine - \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}} -\def\doublecolumnout{% - \setbox5=\copy255 - {\vbadness=10000 \doublecolumnsplit} - \ifvbox255 - \setbox0=\vtop to\dimen@{\unvbox0} - \setbox2=\vtop to\dimen@{\unvbox2} - \onepageout\pagesofar \unvbox255 \penalty\outputpenalty - \else - \setbox0=\vbox{\unvbox5} - \ifvbox0 - \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip - \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth - {\vbadness=10000 - \loop \global\setbox5=\copy0 - \setbox1=\vsplit5 to\dimen@ - \setbox3=\vsplit5 to\dimen@ - \ifvbox5 \global\advance\dimen@ by1pt \repeat - \setbox0=\vbox to\dimen@{\unvbox1} - \setbox2=\vbox to\dimen@{\unvbox3} - \global\setbox\partialpage=\vbox{\pagesofar} - \doublecolumnpagegoal - } - \fi - \fi -} - -\catcode `\@=\other -\message{sectioning,} -% Define chapters, sections, etc. - -\newcount \chapno -\newcount \secno \secno=0 -\newcount \subsecno \subsecno=0 -\newcount \subsubsecno \subsubsecno=0 - -% This counter is funny since it counts through charcodes of letters A, B, ... -\newcount \appendixno \appendixno = `\@ -\def\appendixletter{\char\the\appendixno} - -\newwrite \contentsfile -% This is called from \setfilename. -\def\opencontents{\openout \contentsfile = \jobname.toc} - -% Each @chapter defines this as the name of the chapter. -% page headings and footings can use it. @section does likewise - -\def\thischapter{} \def\thissection{} -\def\seccheck#1{\if \pageno<0 % -\errmessage{@#1 not allowed after generating table of contents}\fi -% -} - -\def\chapternofonts{% -\let\rawbackslash=\relax% -\let\frenchspacing=\relax% -\def\result{\realbackslash result} -\def\equiv{\realbackslash equiv} -\def\expansion{\realbackslash expansion} -\def\print{\realbackslash print} -\def\TeX{\realbackslash TeX} -\def\dots{\realbackslash dots} -\def\copyright{\realbackslash copyright} -\def\tt{\realbackslash tt} -\def\bf{\realbackslash bf } -\def\w{\realbackslash w} -\def\less{\realbackslash less} -\def\gtr{\realbackslash gtr} -\def\hat{\realbackslash hat} -\def\char{\realbackslash char} -\def\tclose##1{\realbackslash tclose {##1}} -\def\code##1{\realbackslash code {##1}} -\def\samp##1{\realbackslash samp {##1}} -\def\r##1{\realbackslash r {##1}} -\def\b##1{\realbackslash b {##1}} -\def\key##1{\realbackslash key {##1}} -\def\file##1{\realbackslash file {##1}} -\def\kbd##1{\realbackslash kbd {##1}} -% These are redefined because @smartitalic wouldn't work inside xdef. -\def\i##1{\realbackslash i {##1}} -\def\cite##1{\realbackslash cite {##1}} -\def\var##1{\realbackslash var {##1}} -\def\emph##1{\realbackslash emph {##1}} -\def\dfn##1{\realbackslash dfn {##1}} -} - -\newcount\absseclevel % used to calculate proper heading level -\newcount\secbase\secbase=0 % @raise/lowersections modify this count - -% @raisesections: treat @section as chapter, @subsection as section, etc. -\def\raisesections{\global\advance\secbase by -1} -\let\up=\raisesections % original BFox name - -% @lowersections: treat @chapter as section, @section as subsection, etc. -\def\lowersections{\global\advance\secbase by 1} -\let\down=\lowersections % original BFox name - -% Choose a numbered-heading macro -% #1 is heading level if unmodified by @raisesections or @lowersections -% #2 is text for heading -\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \chapterzzz{#2} -\or - \seczzz{#2} -\or - \numberedsubseczzz{#2} -\or - \numberedsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \chapterzzz{#2} - \else - \numberedsubsubseczzz{#2} - \fi -\fi -} - -% like \numhead, but chooses appendix heading levels -\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \appendixzzz{#2} -\or - \appendixsectionzzz{#2} -\or - \appendixsubseczzz{#2} -\or - \appendixsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \appendixzzz{#2} - \else - \appendixsubsubseczzz{#2} - \fi -\fi -} - -% like \numhead, but chooses numberless heading levels -\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \unnumberedzzz{#2} -\or - \unnumberedseczzz{#2} -\or - \unnumberedsubseczzz{#2} -\or - \unnumberedsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \unnumberedzzz{#2} - \else - \unnumberedsubsubseczzz{#2} - \fi -\fi -} - - -\def\thischaptername{No Chapter Title} -\outer\def\chapter{\parsearg\chapteryyy} -\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz -\def\chapterzzz #1{\seccheck{chapter}% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \chapno by 1 \message{Chapter \the\chapno}% -\chapmacro {#1}{\the\chapno}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -% We don't substitute the actual chapter name into \thischapter -% because we don't want its macros evaluated now. -\xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}% -{\chapternofonts% -\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec -}} - -\outer\def\appendix{\parsearg\appendixyyy} -\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz -\def\appendixzzz #1{\seccheck{appendix}% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \appendixno by 1 \message{Appendix \appendixletter}% -\chapmacro {#1}{Appendix \appendixletter}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -\xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}% -{\chapternofonts% -\edef\temp{{\realbackslash chapentry - {#1}{Appendix \appendixletter}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\global\let\section = \appendixsec -\global\let\subsection = \appendixsubsec -\global\let\subsubsection = \appendixsubsubsec -}} - -\outer\def\top{\parsearg\unnumberedyyy} -\outer\def\unnumbered{\parsearg\unnumberedyyy} -\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz -\def\unnumberedzzz #1{\seccheck{unnumbered}% -\secno=0 \subsecno=0 \subsubsecno=0 -% -% This used to be simply \message{#1}, but TeX fully expands the -% argument to \message. Therefore, if #1 contained @-commands, TeX -% expanded them. For example, in `@unnumbered The @cite{Book}', TeX -% expanded @cite (which turns out to cause errors because \cite is meant -% to be executed, not expanded). -% -% Anyway, we don't want the fully-expanded definition of @cite to appear -% as a result of the \message, we just want `@cite' itself. We use -% \the to achieve this: TeX expands \the only once, -% simply yielding the contents of the . -\toks0 = {#1}\message{(\the\toks0)}% -% -\unnumbchapmacro {#1}% -\gdef\thischapter{#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\global\let\section = \unnumberedsec -\global\let\subsection = \unnumberedsubsec -\global\let\subsubsection = \unnumberedsubsubsec -}} - -\outer\def\numberedsec{\parsearg\secyyy} -\def\secyyy #1{\numhead1{#1}} % normally calls seczzz -\def\seczzz #1{\seccheck{section}% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% -{\chapternofonts% -\edef\temp{{\realbackslash secentry % -{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appenixsection{\parsearg\appendixsecyyy} -\outer\def\appendixsec{\parsearg\appendixsecyyy} -\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz -\def\appendixsectionzzz #1{\seccheck{appendixsection}% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% -{\chapternofonts% -\edef\temp{{\realbackslash secentry % -{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} -\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz -\def\unnumberedseczzz #1{\seccheck{unnumberedsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} -\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz -\def\numberedsubseczzz #1{\seccheck{subsection}% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsecentry % -{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} -\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz -\def\appendixsubseczzz #1{\seccheck{appendixsubsec}% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsecentry % -{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} -\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz -\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} -\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz -\def\numberedsubsubseczzz #1{\seccheck{subsubsection}% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsubsecentry % - {#1} - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno} - {\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} -\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz -\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsubsecentry{#1}% - {\appendixletter} - {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} -\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz -\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -% These are variants which are not "outer", so they can appear in @ifinfo. -% Actually, they should now be obsolete; ordinary section commands should work. -\def\infotop{\parsearg\unnumberedzzz} -\def\infounnumbered{\parsearg\unnumberedzzz} -\def\infounnumberedsec{\parsearg\unnumberedseczzz} -\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} -\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} - -\def\infoappendix{\parsearg\appendixzzz} -\def\infoappendixsec{\parsearg\appendixseczzz} -\def\infoappendixsubsec{\parsearg\appendixsubseczzz} -\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} - -\def\infochapter{\parsearg\chapterzzz} -\def\infosection{\parsearg\sectionzzz} -\def\infosubsection{\parsearg\subsectionzzz} -\def\infosubsubsection{\parsearg\subsubsectionzzz} - -% These macros control what the section commands do, according -% to what kind of chapter we are in (ordinary, appendix, or unnumbered). -% Define them by default for a numbered chapter. -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec - -% Define @majorheading, @heading and @subheading - -% NOTE on use of \vbox for chapter headings, section headings, and -% such: -% 1) We use \vbox rather than the earlier \line to permit -% overlong headings to fold. -% 2) \hyphenpenalty is set to 10000 because hyphenation in a -% heading is obnoxious; this forbids it. -% 3) Likewise, headings look best if no \parindent is used, and -% if justification is not attempted. Hence \raggedright. - - -\def\majorheading{\parsearg\majorheadingzzz} -\def\majorheadingzzz #1{% -{\advance\chapheadingskip by 10pt \chapbreak }% -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} - -\def\chapheading{\parsearg\chapheadingzzz} -\def\chapheadingzzz #1{\chapbreak % -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} - -\def\heading{\parsearg\secheadingi} - -\def\subheading{\parsearg\subsecheadingi} - -\def\subsubheading{\parsearg\subsubsecheadingi} - -% These macros generate a chapter, section, etc. heading only -% (including whitespace, linebreaking, etc. around it), -% given all the information in convenient, parsed form. - -%%% Args are the skip and penalty (usually negative) -\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} - -\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} - -%%% Define plain chapter starts, and page on/off switching for it -% Parameter controlling skip before chapter headings (if needed) - -\newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt - -\def\chapbreak{\dobreak \chapheadingskip {-4000}} -\def\chappager{\par\vfill\supereject} -\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} - -\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} - -\def\CHAPPAGoff{ -\global\let\pchapsepmacro=\chapbreak -\global\let\pagealignmacro=\chappager} - -\def\CHAPPAGon{ -\global\let\pchapsepmacro=\chappager -\global\let\pagealignmacro=\chappager -\global\def\HEADINGSon{\HEADINGSsingle}} - -\def\CHAPPAGodd{ -\global\let\pchapsepmacro=\chapoddpage -\global\let\pagealignmacro=\chapoddpage -\global\def\HEADINGSon{\HEADINGSdouble}} - -\CHAPPAGon - -\def\CHAPFplain{ -\global\let\chapmacro=\chfplain -\global\let\unnumbchapmacro=\unnchfplain} - -\def\chfplain #1#2{% - \pchapsepmacro - {% - \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #2\enspace #1}% - }% - \bigskip - \penalty5000 -} - -\def\unnchfplain #1{% -\pchapsepmacro % -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 10000 % -} -\CHAPFplain % The default - -\def\unnchfopen #1{% -\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 10000 % -} - -\def\chfopen #1#2{\chapoddpage {\chapfonts -\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% -\par\penalty 5000 % -} - -\def\CHAPFopen{ -\global\let\chapmacro=\chfopen -\global\let\unnumbchapmacro=\unnchfopen} - -% Parameter controlling skip before section headings. - -\newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt -\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} - -\newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt -\def\secheadingbreak{\dobreak \secheadingskip {-1000}} - -% @paragraphindent is defined for the Info formatting commands only. -\let\paragraphindent=\comment - -% Section fonts are the base font at magstep2, which produces -% a size a bit more than 14 points in the default situation. - -\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}} -\def\plainsecheading #1{\secheadingi {#1}} -\def\secheadingi #1{{\advance \secheadingskip by \parskip % -\secheadingbreak}% -{\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } - - -% Subsection fonts are the base font at magstep1, -% which produces a size of 12 points. - -\def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}} -\def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip % -\subsecheadingbreak}% -{\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } - -\def\subsubsecfonts{\subsecfonts} % Maybe this should change: - % Perhaps make sssec fonts scaled - % magstep half -\def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}} -\def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip % -\subsecheadingbreak}% -{\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000} - - -\message{toc printing,} - -% Finish up the main text and prepare to read what we've written -% to \contentsfile. - -\newskip\contentsrightmargin \contentsrightmargin=1in -\def\startcontents#1{% - \pagealignmacro - \immediate\closeout \contentsfile - \ifnum \pageno>0 - \pageno = -1 % Request roman numbered pages. - \fi - % Don't need to put `Contents' or `Short Contents' in the headline. - % It is abundantly clear what they are. - \unnumbchapmacro{#1}\def\thischapter{}% - \begingroup % Set up to handle contents files properly. - \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 - \raggedbottom % Worry more about breakpoints than the bottom. - \advance\hsize by -\contentsrightmargin % Don't use the full line length. -} - - -% Normal (long) toc. -\outer\def\contents{% - \startcontents{Table of Contents}% - \input \jobname.toc - \endgroup - \vfill \eject -} - -% And just the chapters. -\outer\def\summarycontents{% - \startcontents{Short Contents}% - % - \let\chapentry = \shortchapentry - \let\unnumbchapentry = \shortunnumberedentry - % We want a true roman here for the page numbers. - \secfonts - \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl - \rm - \advance\baselineskip by 1pt % Open it up a little. - \def\secentry ##1##2##3##4{} - \def\unnumbsecentry ##1##2{} - \def\subsecentry ##1##2##3##4##5{} - \def\unnumbsubsecentry ##1##2{} - \def\subsubsecentry ##1##2##3##4##5##6{} - \def\unnumbsubsubsecentry ##1##2{} - \input \jobname.toc - \endgroup - \vfill \eject -} -\let\shortcontents = \summarycontents - -% These macros generate individual entries in the table of contents. -% The first argument is the chapter or section name. -% The last argument is the page number. -% The arguments in between are the chapter number, section number, ... - -% Chapter-level things, for both the long and short contents. -\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} - -% See comments in \dochapentry re vbox and related settings -\def\shortchapentry#1#2#3{% - \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% -} - -% Typeset the label for a chapter or appendix for the short contents. -% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. -% We could simplify the code here by writing out an \appendixentry -% command in the toc file for appendices, instead of using \chapentry -% for both, but it doesn't seem worth it. -\setbox0 = \hbox{\shortcontrm Appendix } -\newdimen\shortappendixwidth \shortappendixwidth = \wd0 - -\def\shortchaplabel#1{% - % We typeset #1 in a box of constant width, regardless of the text of - % #1, so the chapter titles will come out aligned. - \setbox0 = \hbox{#1}% - \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi - % - % This space should be plenty, since a single number is .5em, and the - % widest letter (M) is 1em, at least in the Computer Modern fonts. - % (This space doesn't include the extra space that gets added after - % the label; that gets put in in \shortchapentry above.) - \advance\dimen0 by 1.1em - \hbox to \dimen0{#1\hfil}% -} - -\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} -\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} - -% Sections. -\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} -\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} - -% Subsections. -\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} -\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} - -% And subsubsections. -\def\subsubsecentry#1#2#3#4#5#6{% - \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} -\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} - - -% This parameter controls the indentation of the various levels. -\newdimen\tocindent \tocindent = 3pc - -% Now for the actual typesetting. In all these, #1 is the text and #2 is the -% page number. -% -% If the toc has to be broken over pages, we would want to be at chapters -% if at all possible; hence the \penalty. -\def\dochapentry#1#2{% - \penalty-300 \vskip\baselineskip - \begingroup - \chapentryfonts - \tocentry{#1}{\dopageno{#2}}% - \endgroup - \nobreak\vskip .25\baselineskip -} - -\def\dosecentry#1#2{\begingroup - \secentryfonts \leftskip=\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -\def\dosubsecentry#1#2{\begingroup - \subsecentryfonts \leftskip=2\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -\def\dosubsubsecentry#1#2{\begingroup - \subsubsecentryfonts \leftskip=3\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -% Final typesetting of a toc entry; we use the same \entry macro as for -% the index entries, but we want to suppress hyphenation here. (We -% can't do that in the \entry macro, since index entries might consist -% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) -% -\def\tocentry#1#2{\begingroup - \hyphenpenalty = 10000 - \entry{#1}{#2}% -\endgroup} - -% Space between chapter (or whatever) number and the title. -\def\labelspace{\hskip1em \relax} - -\def\dopageno#1{{\rm #1}} -\def\doshortpageno#1{{\rm #1}} - -\def\chapentryfonts{\secfonts \rm} -\def\secentryfonts{\textfonts} -\let\subsecentryfonts = \textfonts -\let\subsubsecentryfonts = \textfonts - - -\message{environments,} - -% Since these characters are used in examples, it should be an even number of -% \tt widths. Each \tt character is 1en, so two makes it 1em. -% Furthermore, these definitions must come after we define our fonts. -\newbox\dblarrowbox \newbox\longdblarrowbox -\newbox\pushcharbox \newbox\bullbox -\newbox\equivbox \newbox\errorbox - -\let\ptexequiv = \equiv - -%{\tentt -%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} -%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} -%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} -%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} -% Adapted from the manmac format (p.420 of TeXbook) -%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex -% depth .1ex\hfil} -%} - -\def\point{$\star$} - -\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} -\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} -\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} - -\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} - -% Adapted from the TeXbook's \boxit. -{\tentt \global\dimen0 = 3em}% Width of the box. -\dimen2 = .55pt % Thickness of rules -% The text. (`r' is open on the right, `e' somewhat less so on the left.) -\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} - -\global\setbox\errorbox=\hbox to \dimen0{\hfil - \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. - \advance\hsize by -2\dimen2 % Rules. - \vbox{ - \hrule height\dimen2 - \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. - \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. - \kern3pt\vrule width\dimen2}% Space to right. - \hrule height\dimen2} - \hfil} - -% The @error{} command. -\def\error{\leavevmode\lower.7ex\copy\errorbox} - -% @tex ... @end tex escapes into raw Tex temporarily. -% One exception: @ is still an escape character, so that @end tex works. -% But \@ or @@ will get a plain tex @ character. - -\def\tex{\begingroup -\catcode `\\=0 \catcode `\{=1 \catcode `\}=2 -\catcode `\$=3 \catcode `\&=4 \catcode `\#=6 -\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie -\catcode `\%=14 -\catcode 43=12 -\catcode`\"=12 -\catcode`\==12 -\catcode`\|=12 -\catcode`\<=12 -\catcode`\>=12 -\escapechar=`\\ -% -\let\{=\ptexlbrace -\let\}=\ptexrbrace -\let\.=\ptexdot -\let\*=\ptexstar -\let\dots=\ptexdots -\def\@{@}% -\let\bullet=\ptexbullet -\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl -\let\L=\ptexL -% -\let\Etex=\endgroup} - -% Define @lisp ... @endlisp. -% @lisp does a \begingroup so it can rebind things, -% including the definition of @endlisp (which normally is erroneous). - -% Amount to narrow the margins by for @lisp. -\newskip\lispnarrowing \lispnarrowing=0.4in - -% This is the definition that ^M gets inside @lisp -% phr: changed space to \null, to avoid overfull hbox problems. -{\obeyspaces% -\gdef\lisppar{\null\endgraf}} - -% Make each space character in the input produce a normal interword -% space in the output. Don't allow a line break at this space, as this -% is used only in environments like @example, where each line of input -% should produce a line of output anyway. -% -{\obeyspaces % -\gdef\sepspaces{\obeyspaces\let =\tie}} - -% Define \obeyedspace to be our active space, whatever it is. This is -% for use in \parsearg. -{\sepspaces % -\global\let\obeyedspace= } - -% This space is always present above and below environments. -\newskip\envskipamount \envskipamount = 0pt - -% Make spacing and below environment symmetrical. -\def\aboveenvbreak{{\advance\envskipamount by \parskip -\endgraf \ifdim\lastskip<\envskipamount -\removelastskip \penalty-50 \vskip\envskipamount \fi}} - -\let\afterenvbreak = \aboveenvbreak - -% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. -\let\nonarrowing=\relax - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \cartouche: draw rectangle w/rounded corners around argument -\font\circle=lcircle10 -\newdimen\circthick -\newdimen\cartouter\newdimen\cartinner -\newskip\normbskip\newskip\normpskip\newskip\normlskip -\circthick=\fontdimen8\circle -% -\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth -\def\ctr{{\hskip 6pt\circle\char'010}} -\def\cbl{{\circle\char'012\hskip -6pt}} -\def\cbr{{\hskip 6pt\circle\char'011}} -\def\carttop{\hbox to \cartouter{\hskip\lskip - \ctl\leaders\hrule height\circthick\hfil\ctr - \hskip\rskip}} -\def\cartbot{\hbox to \cartouter{\hskip\lskip - \cbl\leaders\hrule height\circthick\hfil\cbr - \hskip\rskip}} -% -\newskip\lskip\newskip\rskip - -\long\def\cartouche{% -\begingroup - \lskip=\leftskip \rskip=\rightskip - \leftskip=0pt\rightskip=0pt %we want these *outside*. - \cartinner=\hsize \advance\cartinner by-\lskip - \advance\cartinner by-\rskip - \cartouter=\hsize - \advance\cartouter by 18pt % allow for 3pt kerns on either -% side, and for 6pt waste from -% each corner char - \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip - % Flag to tell @lisp, etc., not to narrow margin. - \let\nonarrowing=\comment - \vbox\bgroup - \baselineskip=0pt\parskip=0pt\lineskip=0pt - \carttop - \hbox\bgroup - \hskip\lskip - \vrule\kern3pt - \vbox\bgroup - \hsize=\cartinner - \kern3pt - \begingroup - \baselineskip=\normbskip - \lineskip=\normlskip - \parskip=\normpskip - \vskip -\parskip -\def\Ecartouche{% - \endgroup - \kern3pt - \egroup - \kern3pt\vrule - \hskip\rskip - \egroup - \cartbot - \egroup -\endgroup -}} - - -% This macro is called at the beginning of all the @example variants, -% inside a group. -\def\nonfillstart{% - \aboveenvbreak - \inENV % This group ends at the end of the body - \hfuzz = 12pt % Don't be fussy - \sepspaces % Make spaces be word-separators rather than space tokens. - \singlespace % single space lines - \let\par = \lisppar % don't ignore blank lines - \obeylines % each line of input is a line of output - \parskip = 0pt - \parindent = 0pt - \emergencystretch = 0pt % don't try to avoid overfull boxes - % @cartouche defines \nonarrowing to inhibit narrowing - % at next level down. - \ifx\nonarrowing\relax - \advance \leftskip by \lispnarrowing - \exdentamount=\lispnarrowing - \let\exdent=\nofillexdent - \let\nonarrowing=\relax - \fi -} - -\def\Elisp{\endgroup\afterenvbreak}% - -\def\lisp{\begingroup - \nonfillstart - \def\Elisp{\endgroup\afterenvbreak}% - \tt - \rawbackslash % output the \ character from the current font - \gobble -} - -% Define the \E... control sequence only if we are inside the -% environment, so the error checking in \end will work. -% -% We must call \lisp last in the definition, since it reads the -% return following the @example (or whatever) command. -% -\def\example{\begingroup \def\Eexample{\Elisp\endgroup}\lisp} -\def\smallexample{\begingroup \def\Esmallexample{\Elisp\endgroup}\lisp} - -% Macro for 9 pt. examples, necessary to print with 5" lines. From -% Pavel@xerox. This is not used for @smallexamples unless the -% @smallbook command is given. -% -\def\smalllispx{\begingroup - \nonfillstart - \def\Esmalllisp{\endgroup\afterenvbreak}% - % - % Smaller interline space and fonts for small examples. - \baselineskip 10pt - \indexfonts \tt - \rawbackslash % output the \ character from the current font - \gobble -} - -% This is @display; same as @lisp except use roman font. -% -\def\display{\begingroup - \nonfillstart - \def\Edisplay{\endgroup\afterenvbreak}% - \gobble -} - -% This is @format; same as @display except don't narrow margins. -% -\def\format{\begingroup - \let\nonarrowing = t - \nonfillstart - \def\Eformat{\endgroup\afterenvbreak} - \gobble -} - -% @flushleft (same as @format) and @flushright. -% -\def\flushleft{\begingroup - \let\nonarrowing = t - \nonfillstart - \def\Eflushleft{\endgroup\afterenvbreak}% - \gobble -} -\def\flushright{\begingroup - \let\nonarrowing = t - \nonfillstart - \def\Eflushright{\endgroup\afterenvbreak}% - \advance\leftskip by 0pt plus 1fill - \gobble} - -% @quotation does normal linebreaking and narrows the margins. -% -\def\quotation{% -\begingroup\inENV %This group ends at the end of the @quotation body -{\parskip=0pt % because we will skip by \parskip too, later -\aboveenvbreak}% -\singlespace -\parindent=0pt -\def\Equotation{\par\endgroup\afterenvbreak}% -% @cartouche defines \nonarrowing to inhibit narrowing -% at next level down. -\ifx\nonarrowing\relax -\advance \leftskip by \lispnarrowing -\advance \rightskip by \lispnarrowing -\exdentamount=\lispnarrowing -\let\nonarrowing=\relax -\fi} - -\message{defuns,} -% Define formatter for defuns -% First, allow user to change definition object font (\df) internally -\def\setdeffont #1 {\csname DEF#1\endcsname} - -\newskip\defbodyindent \defbodyindent=.4in -\newskip\defargsindent \defargsindent=50pt -\newskip\deftypemargin \deftypemargin=12pt -\newskip\deflastargmargin \deflastargmargin=18pt - -\newcount\parencount -% define \functionparens, which makes ( and ) and & do special things. -% \functionparens affects the group it is contained in. -\def\activeparens{% -\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active -\catcode`\[=\active \catcode`\]=\active} - -% Make control sequences which act like normal parenthesis chars. -\let\lparen = ( \let\rparen = ) - -{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) - -% Be sure that we always have a definition for `(', etc. For example, -% if the fn name has parens in it, \boldbrax will not be in effect yet, -% so TeX would otherwise complain about undefined control sequence. -\global\let(=\lparen \global\let)=\rparen -\global\let[=\lbrack \global\let]=\rbrack - -\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } -\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} - -% Definitions of (, ) and & used in args for functions. -% This is the definition of ( outside of all parentheses. -\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested % -\global\advance\parencount by 1 } -% -% This is the definition of ( when already inside a level of parens. -\gdef\opnested{\char`\(\global\advance\parencount by 1 } -% -\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. -% also in that case restore the outer-level definition of (. -\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi -\global\advance \parencount by -1 } -% If we encounter &foo, then turn on ()-hacking afterwards -\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } -% -\gdef\normalparens{\boldbrax\let&=\ampnr} -} % End of definition inside \activeparens -%% These parens (in \boldbrax) actually are a little bolder than the -%% contained text. This is especially needed for [ and ] -\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&} -\def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} - -% First, defname, which formats the header line itself. -% #1 should be the function name. -% #2 should be the type of definition, such as "Function". - -\def\defname #1#2{% -% Get the values of \leftskip and \rightskip as they were -% outside the @def... -\dimen2=\leftskip -\advance\dimen2 by -\defbodyindent -\dimen3=\rightskip -\advance\dimen3 by -\defbodyindent -\noindent % -\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% -\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line -\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations -\parshape 2 0in \dimen0 \defargsindent \dimen1 % -% Now output arg 2 ("Function" or some such) -% ending at \deftypemargin from the right margin, -% but stuck inside a box of width 0 so it does not interfere with linebreaking -{% Adjust \hsize to exclude the ambient margins, -% so that \rightline will obey them. -\advance \hsize by -\dimen2 \advance \hsize by -\dimen3 -\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% -% Make all lines underfull and no complaints: -\tolerance=10000 \hbadness=10000 -\advance\leftskip by -\defbodyindent -\exdentamount=\defbodyindent -{\df #1}\enskip % Generate function name -} - -% Actually process the body of a definition -% #1 should be the terminating control sequence, such as \Edefun. -% #2 should be the "another name" control sequence, such as \defunx. -% #3 should be the control sequence that actually processes the header, -% such as \defunheader. - -\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % -\obeylines\activeparens\spacesplit#3} - -\def\defmethparsebody #1#2#3#4 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} - -\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} - -% These parsing functions are similar to the preceding ones -% except that they do not make parens into active characters. -% These are used for "variables" since they have no arguments. - -\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % -\obeylines\spacesplit#3} - -\def\defvrparsebody #1#2#3#4 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\spacesplit{#3{#4}}} - -% This seems to work right in all cases. -\let\deftpparsebody=\defvrparsebody -% This fails to work. When given `@deftp {Data Type} foo_t', -% it thinks the type name is just `f'. -%%% This is the same as all the others except for the last line. We need -%%% to parse the arguments differently for @deftp, since the ``attributes'' -%%% there are optional. -%%% -%%\def\deftpparsebody #1#2#3#4 {\begingroup\inENV % -%%\medbreak % -%%% Define the end token that this defining construct specifies -%%% so that it will exit this group. -%%\def#1{\endgraf\endgroup\medbreak}% -%%\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% -%%\parindent=0in -%%\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -%%\exdentamount=\defbodyindent -%%\begingroup\obeylines\parsetpheaderline{#3{#4}}} - -%%{\obeylines % -%% % Parse the type name and any attributes (field names, etc.). -%% % #1 is the beginning of the macro call that will produce the output, -%% % i.e., \deftpheader{CLASS}; this is passed from \deftpparsebody. -%% % #2 is the type name, e.g., `struct termios'. -%% % #3 is the (possibly empty) attribute list. -%% % -%% \gdef\parsetpheaderline#1#2#3^^M{% -%% \endgroup % Started in \deftpparsebody. -%% % -%% % If the attribute list is in fact empty, there will be no space after -%% % #2; so we can't put a space in our TeX parameter list. But if it -%% % isn't empty, then #3 will begin with an unwanted space. -%% \def\theargs{\ignorespaces #3}% -%% % -%% % Call the macro to produce the output. -%% #1{#2}\theargs % -%% }% -%%} - -\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\spacesplit{#3{#5}}} - -% Split up #2 at the first space token. -% call #1 with two arguments: -% the first is all of #2 before the space token, -% the second is all of #2 after that space token. -% If #2 contains no space token, all of it is passed as the first arg -% and the second is passed as empty. - -{\obeylines -\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% -\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% -\ifx\relax #3% -#1{#2}{}\else #1{#2}{#3#4}\fi}} - -% So much for the things common to all kinds of definitions. - -% Define @defun. - -% First, define the processing that is wanted for arguments of \defun -% Use this to expand the args and terminate the paragraph they make up - -\def\defunargs #1{\functionparens \sl -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -\hyphenchar\tensl=0 -#1% -\hyphenchar\tensl=45 -\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi% -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\penalty 10000\vskip -\parskip\penalty 10000% -} - -\def\deftypefunargs #1{% -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -\functionparens -\code{#1}% -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\penalty 10000\vskip -\parskip\penalty 10000% -} - -% Do complete processing of one @defun or @defunx line already parsed. - -% @deffn Command forward-char nchars - -\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} - -\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% -\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defun == @deffn Function - -\def\defun{\defparsebody\Edefun\defunx\defunheader} - -\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Function}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefun int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} - -% #1 is the data type. #2 is the name and args. -\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} -% #1 is the data type, #2 the name, #3 the args. -\def\deftypefunheaderx #1#2 #3\relax{% -\doind {fn}{\code{#2}}% Make entry in function index -\begingroup\defname {\code{#1} #2}{Function}% -\deftypefunargs {#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} - -% #1 is the classification. #2 is the data type. #3 is the name and args. -\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} -% #1 is the classification, #2 the data type, #3 the name, #4 the args. -\def\deftypefnheaderx #1#2#3 #4\relax{% -\doind {fn}{\code{#3}}% Make entry in function index -\begingroup\defname {\code{#2} #3}{#1}% -\deftypefunargs {#4}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defmac == @deffn Macro - -\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} - -\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Macro}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defspec == @deffn Special Form - -\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} - -\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Special Form}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% This definition is run if you use @defunx -% anywhere other than immediately after a @defun or @defunx. - -\def\deffnx #1 {\errmessage{@deffnx in invalid context}} -\def\defunx #1 {\errmessage{@defunx in invalid context}} -\def\defmacx #1 {\errmessage{@defmacx in invalid context}} -\def\defspecx #1 {\errmessage{@defspecx in invalid context}} -\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} -\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}} - -% @defmethod, and so on - -% @defop {Funny Method} foo-class frobnicate argument - -\def\defop #1 {\def\defoptype{#1}% -\defopparsebody\Edefop\defopx\defopheader\defoptype} - -\def\defopheader #1#2#3{% -\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index -\begingroup\defname {#2}{\defoptype{} on #1}% -\defunargs {#3}\endgroup % -} - -% @defmethod == @defop Method - -\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} - -\def\defmethodheader #1#2#3{% -\dosubind {fn}{\code{#2}}{on #1}% entry in function index -\begingroup\defname {#2}{Method on #1}% -\defunargs {#3}\endgroup % -} - -% @defcv {Class Option} foo-class foo-flag - -\def\defcv #1 {\def\defcvtype{#1}% -\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} - -\def\defcvarheader #1#2#3{% -\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index -\begingroup\defname {#2}{\defcvtype{} of #1}% -\defvarargs {#3}\endgroup % -} - -% @defivar == @defcv {Instance Variable} - -\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} - -\def\defivarheader #1#2#3{% -\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index -\begingroup\defname {#2}{Instance Variable of #1}% -\defvarargs {#3}\endgroup % -} - -% These definitions are run if you use @defmethodx, etc., -% anywhere other than immediately after a @defmethod, etc. - -\def\defopx #1 {\errmessage{@defopx in invalid context}} -\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} -\def\defcvx #1 {\errmessage{@defcvx in invalid context}} -\def\defivarx #1 {\errmessage{@defivarx in invalid context}} - -% Now @defvar - -% First, define the processing that is wanted for arguments of @defvar. -% This is actually simple: just print them in roman. -% This must expand the args and terminate the paragraph they make up -\def\defvarargs #1{\normalparens #1% -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000} - -% @defvr Counter foo-count - -\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} - -\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% -\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} - -% @defvar == @defvr Variable - -\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} - -\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{Variable}% -\defvarargs {#2}\endgroup % -} - -% @defopt == @defvr {User Option} - -\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} - -\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{User Option}% -\defvarargs {#2}\endgroup % -} - -% @deftypevar int foobar - -\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} - -% #1 is the data type. #2 is the name. -\def\deftypevarheader #1#2{% -\doind {vr}{\code{#2}}% Make entry in variables index -\begingroup\defname {\code{#1} #2}{Variable}% -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000 -\endgroup} - -% @deftypevr {Global Flag} int enable - -\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} - -\def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% -\begingroup\defname {\code{#2} #3}{#1} -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000 -\endgroup} - -% This definition is run if you use @defvarx -% anywhere other than immediately after a @defvar or @defvarx. - -\def\defvrx #1 {\errmessage{@defvrx in invalid context}} -\def\defvarx #1 {\errmessage{@defvarx in invalid context}} -\def\defoptx #1 {\errmessage{@defoptx in invalid context}} -\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} -\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} - -% Now define @deftp -% Args are printed in bold, a slight difference from @defvar. - -\def\deftpargs #1{\bf \defvarargs{#1}} - -% @deftp Class window height width ... - -\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} - -\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% -\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} - -% This definition is run if you use @deftpx, etc -% anywhere other than immediately after a @deftp, etc. - -\def\deftpx #1 {\errmessage{@deftpx in invalid context}} - -\message{cross reference,} -% Define cross-reference macros -\newwrite \auxfile - -\newif\ifhavexrefs % True if xref values are known. -\newif\ifwarnedxrefs % True if we warned once that they aren't known. - -% \setref{foo} defines a cross-reference point named foo. - -\def\setref#1{% -%\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Ysectionnumberandtype}} - -\def\unnumbsetref#1{% -%\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Ynothing}} - -\def\appendixsetref#1{% -%\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Yappendixletterandtype}} - -% \xref, \pxref, and \ref generate cross-references to specified points. -% For \xrefX, #1 is the node name, #2 the name of the Info -% cross-reference, #3 the printed node name, #4 the name of the Info -% file, #5 the name of the printed manual. All but the node name can be -% omitted. -% -\def\pxref#1{see \xrefX[#1,,,,,,,]} -\def\xref#1{See \xrefX[#1,,,,,,,]} -\def\ref#1{\xrefX[#1,,,,,,,]} -\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup% -\def\printedmanual{\ignorespaces #5}% -\def\printednodename{\ignorespaces #3}% -% -\setbox1=\hbox{\printedmanual}% -\setbox0=\hbox{\printednodename}% -\ifdim \wd0=0pt% -\def\printednodename{\ignorespaces #1}% -%%% Uncommment the following line to make the actual chapter or section title -%%% appear inside the square brackets. -%\def\printednodename{#1-title}% -\fi% -% -% -% If we use \unhbox0 and \unhbox1 to print the node names, TeX does -% not insert empty discretionaries after hyphens, which means that it -% will not find a line break at a hyphen in a node names. Since some -% manuals are best written with fairly long node names, containing -% hyphens, this is a loss. Therefore, we simply give the text of -% the node name again, so it is as if TeX is seeing it for the first -% time. -\ifdim \wd1>0pt -section ``\printednodename'' in \cite{\printedmanual}% -\else% -\turnoffactive% -\refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}% -\fi -\endgroup} - -% \dosetq is the interface for calls from other macros - -% Use \turnoffactive so that punctuation chars such as underscore -% work in node names. -\def\dosetq #1#2{{\let\folio=0 \turnoffactive% -\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}% -\next}} - -% \internalsetq {foo}{page} expands into -% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} -% When the aux file is read, ' is the escape character - -\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} - -% Things to be expanded by \internalsetq - -\def\Ypagenumber{\folio} - -\def\Ytitle{\thischapter} - -\def\Ynothing{} - -\def\Ysectionnumberandtype{% -\ifnum\secno=0 Chapter\xreftie\the\chapno % -\else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno % -\else \ifnum \subsubsecno=0 % -Section\xreftie\the\chapno.\the\secno.\the\subsecno % -\else % -Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\def\Yappendixletterandtype{% -\ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}% -\else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno % -\else \ifnum \subsubsecno=0 % -Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno % -\else % -Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\gdef\xreftie{'tie} - -% Use TeX 3.0's \inputlineno to get the line number, for better error -% messages, but if we're using an old version of TeX, don't do anything. -% -\ifx\inputlineno\thisisundefined - \let\linenumber = \empty % Non-3.0. -\else - \def\linenumber{\the\inputlineno:\space} -\fi - -% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. -% If its value is nonempty, SUFFIX is output afterward. - -\def\refx#1#2{% - \expandafter\ifx\csname X#1\endcsname\relax - % If not defined, say something at least. - $\langle$un\-de\-fined$\rangle$% - \ifhavexrefs - \message{\linenumber Undefined cross reference `#1'.}% - \else - \ifwarnedxrefs\else - \global\warnedxrefstrue - \message{Cross reference values unknown; you must run TeX again.}% - \fi - \fi - \else - % It's defined, so just use it. - \csname X#1\endcsname - \fi - #2% Output the suffix in any case. -} - -% Read the last existing aux file, if any. No error if none exists. - -% This is the macro invoked by entries in the aux file. -\def\xrdef #1#2{ -{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}} - -\def\readauxfile{% -\begingroup -\catcode `\^^@=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\^^C=\other -\catcode `\^^D=\other -\catcode `\^^E=\other -\catcode `\^^F=\other -\catcode `\^^G=\other -\catcode `\^^H=\other -\catcode `\ =\other -\catcode `\^^L=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode 26=\other -\catcode `\^^[=\other -\catcode `\^^\=\other -\catcode `\^^]=\other -\catcode `\^^^=\other -\catcode `\^^_=\other -\catcode `\@=\other -\catcode `\^=\other -\catcode `\~=\other -\catcode `\[=\other -\catcode `\]=\other -\catcode`\"=\other -\catcode`\_=\other -\catcode`\|=\other -\catcode`\<=\other -\catcode`\>=\other -\catcode `\$=\other -\catcode `\#=\other -\catcode `\&=\other -% `\+ does not work, so use 43. -\catcode 43=\other -% the aux file uses ' as the escape. -% Turn off \ as an escape so we do not lose on -% entries which were dumped with control sequences in their names. -% For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ -% Reference to such entries still does not work the way one would wish, -% but at least they do not bomb out when the aux file is read in. -\catcode `\{=1 \catcode `\}=2 -\catcode `\%=\other -\catcode `\'=0 -\catcode `\\=\other -\openin 1 \jobname.aux -\ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue -\global\warnedobstrue -\fi -% Open the new aux file. Tex will close it automatically at exit. -\openout \auxfile=\jobname.aux -\endgroup} - - -% Footnotes. - -\newcount \footnoteno - -% The trailing space in the following definition for supereject is -% vital for proper filling; pages come out unaligned when you do a -% pagealignmacro call if that space before the closing brace is -% removed. -\def\supereject{\par\penalty -20000\footnoteno =0 } - -% @footnotestyle is meaningful for info output only.. -\let\footnotestyle=\comment - -\let\ptexfootnote=\footnote - -{\catcode `\@=11 -% -% Auto-number footnotes. Otherwise like plain. -\gdef\footnote{% - \global\advance\footnoteno by \@ne - \edef\thisfootno{$^{\the\footnoteno}$}% - % - % In case the footnote comes at the end of a sentence, preserve the - % extra spacing after we do the footnote number. - \let\@sf\empty - \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi - % - % Remove inadvertent blank space before typesetting the footnote number. - \unskip - \thisfootno\@sf - \footnotezzz -}% - -% Don't bother with the trickery in plain.tex to not require the -% footnote text as a parameter. Our footnotes don't need to be so general. -% -\long\gdef\footnotezzz#1{\insert\footins{% - % We want to typeset this text as a normal paragraph, even if the - % footnote reference occurs in (for example) a display environment. - % So reset some parameters. - \interlinepenalty\interfootnotelinepenalty - \splittopskip\ht\strutbox % top baseline for broken footnotes - \splitmaxdepth\dp\strutbox - \floatingpenalty\@MM - \leftskip\z@skip - \rightskip\z@skip - \spaceskip\z@skip - \xspaceskip\z@skip - \parindent\defaultparindent - % - % Hang the footnote text off the number. - \hang - \textindent{\thisfootno}% - % - % Don't crash into the line above the footnote text. Since this - % expands into a box, it must come within the paragraph, lest it - % provide a place where TeX can split the footnote. - \footstrut - #1\strut}% -} - -}%end \catcode `\@=11 - -% Set the baselineskip to #1, and the lineskip and strut size -% correspondingly. There is no deep meaning behind these magic numbers -% used as factors; they just match (closely enough) what Knuth defined. -% -\def\lineskipfactor{.1} -\def\strutheightpercent{.71} -\def\strutdepthpercent{.29} -% -\def\setleading#1{% - \baselineskip = #1\relax - \normalbaselineskip = \baselineskip - \lineskip = \lineskipfactor\baselineskip - \setbox\strutbox =\hbox{% - \vrule width0pt height\strutheightpercent\baselineskip - depth \strutdepthpercent \baselineskip - }% -} - -% @| inserts a changebar to the left of the current line. It should -% surround any changed text. This approach does *not* work if the -% change spans more than two lines of output. To handle that, we would -% have adopt a much more difficult approach (putting marks into the main -% vertical list for the beginning and end of each change). -% -\def\|{% - % \vadjust can only be used in horizontal mode. - \leavevmode - % - % Append this vertical mode material after the current line in the output. - \vadjust{% - % We want to insert a rule with the height and depth of the current - % leading; that is exactly what \strutbox is supposed to record. - \vskip-\baselineskip - % - % \vadjust-items are inserted at the left edge of the type. So - % the \llap here moves out into the left-hand margin. - \llap{% - % - % For a thicker or thinner bar, change the `1pt'. - \vrule height\baselineskip width1pt - % - % This is the space between the bar and the text. - \hskip 12pt - }% - }% -} - -% For a final copy, take out the rectangles -% that mark overfull boxes (in case you have decided -% that the text looks ok even though it passes the margin). -% -\def\finalout{\overfullrule=0pt} - - -% End of control word definitions. - -\message{and turning on texinfo input format.} - -\def\openindices{% - \newindex{cp}% - \newcodeindex{fn}% - \newcodeindex{vr}% - \newcodeindex{tp}% - \newcodeindex{ky}% - \newcodeindex{pg}% -} - -% Set some numeric style parameters, for 8.5 x 11 format. - -%\hsize = 6.5in -\newdimen\defaultparindent \defaultparindent = 15pt -\parindent = \defaultparindent -\parskip 18pt plus 1pt -\setleading{15pt} -\advance\topskip by 1.2cm - -% Prevent underfull vbox error messages. -\vbadness=10000 - -% Following George Bush, just get rid of widows and orphans. -\widowpenalty=10000 -\clubpenalty=10000 - -% Use TeX 3.0's \emergencystretch to help line breaking, but if we're -% using an old version of TeX, don't do anything. We want the amount of -% stretch added to depend on the line length, hence the dependence on -% \hsize. This makes it come to about 9pt for the 8.5x11 format. -% -\ifx\emergencystretch\thisisundefined - % Allow us to assign to \emergencystretch anyway. - \def\emergencystretch{\dimen0}% -\else - \emergencystretch = \hsize - \divide\emergencystretch by 45 -\fi - -% Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25) -\def\smallbook{ - -% These values for secheadingskip and subsecheadingskip are -% experiments. RJC 7 Aug 1992 -\global\secheadingskip = 17pt plus 6pt minus 3pt -\global\subsecheadingskip = 14pt plus 6pt minus 3pt - -\global\lispnarrowing = 0.3in -\setleading{12pt} -\advance\topskip by -1cm -\global\parskip 3pt plus 1pt -\global\hsize = 5in -\global\vsize=7.5in -\global\tolerance=700 -\global\hfuzz=1pt -\global\contentsrightmargin=0pt - -\global\pagewidth=\hsize -\global\pageheight=\vsize - -\global\let\smalllisp=\smalllispx -\global\let\smallexample=\smalllispx -\global\def\Esmallexample{\Esmalllisp} -} - -% Use @afourpaper to print on European A4 paper. -\def\afourpaper{ -\global\tolerance=700 -\global\hfuzz=1pt -\setleading{12pt} -\global\parskip 15pt plus 1pt - -\global\vsize= 53\baselineskip -\advance\vsize by \topskip -%\global\hsize= 5.85in % A4 wide 10pt -\global\hsize= 6.5in -\global\outerhsize=\hsize -\global\advance\outerhsize by 0.5in -\global\outervsize=\vsize -\global\advance\outervsize by 0.6in - -\global\pagewidth=\hsize -\global\pageheight=\vsize -} - -% Define macros to output various characters with catcode for normal text. -\catcode`\"=\other -\catcode`\~=\other -\catcode`\^=\other -\catcode`\_=\other -\catcode`\|=\other -\catcode`\<=\other -\catcode`\>=\other -\catcode`\+=\other -\def\normaldoublequote{"} -\def\normaltilde{~} -\def\normalcaret{^} -\def\normalunderscore{_} -\def\normalverticalbar{|} -\def\normalless{<} -\def\normalgreater{>} -\def\normalplus{+} - -% This macro is used to make a character print one way in ttfont -% where it can probably just be output, and another way in other fonts, -% where something hairier probably needs to be done. -% -% #1 is what to print if we are indeed using \tt; #2 is what to print -% otherwise. Since all the Computer Modern typewriter fonts have zero -% interword stretch (and shrink), and it is reasonable to expect all -% typewriter fonts to have this, we can check that font parameter. -% -\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} - -% Turn off all special characters except @ -% (and those which the user can use as if they were ordinary). -% Most of these we simply print from the \tt font, but for some, we can -% use math or other variants that look better in normal text. - -\catcode`\"=\active -\def\activedoublequote{{\tt \char '042}} -\let"=\activedoublequote -\catcode`\~=\active -\def~{{\tt \char '176}} -\chardef\hat=`\^ -\catcode`\^=\active -\def^{{\tt \hat}} - -\catcode`\_=\active -\def_{\ifusingtt\normalunderscore\_} -% Subroutine for the previous macro. -\def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}} - -% \lvvmode is equivalent in function to \leavevmode. -% Using \leavevmode runs into trouble when written out to -% an index file due to the expansion of \leavevmode into ``\unhbox -% \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our -% magic tricks with @. -\def\lvvmode{\vbox to 0pt{}} - -\catcode`\|=\active -\def|{{\tt \char '174}} -\chardef \less=`\< -\catcode`\<=\active -\def<{{\tt \less}} -\chardef \gtr=`\> -\catcode`\>=\active -\def>{{\tt \gtr}} -\catcode`\+=\active -\def+{{\tt \char 43}} -%\catcode 27=\active -%\def^^[{$\diamondsuit$} - -% Used sometimes to turn off (effectively) the active characters -% even after parsing them. -\def\turnoffactive{\let"=\normaldoublequote -\let~=\normaltilde -\let^=\normalcaret -\let_=\normalunderscore -\let|=\normalverticalbar -\let<=\normalless -\let>=\normalgreater -\let+=\normalplus} - -% Set up an active definition for =, but don't enable it most of the time. -{\catcode`\==\active -\global\def={{\tt \char 61}}} - -\catcode`\@=0 - -% \rawbackslashxx output one backslash character in current font -\global\chardef\rawbackslashxx=`\\ -%{\catcode`\\=\other -%@gdef@rawbackslashxx{\}} - -% \rawbackslash redefines \ as input to do \rawbackslashxx. -{\catcode`\\=\active -@gdef@rawbackslash{@let\=@rawbackslashxx }} - -% \normalbackslash outputs one backslash in fixed width font. -\def\normalbackslash{{\tt\rawbackslashxx}} - -% Say @foo, not \foo, in error messages. -\escapechar=`\@ - -% \catcode 17=0 % Define control-q -\catcode`\\=\active - -% If a .fmt file is being used, we don't want the `\input texinfo' to show up. -% That is what \eatinput is for; after that, the `\' should revert to printing -% a backslash. -% -@gdef@eatinput input texinfo{@fixbackslash} -@global@let\ = @eatinput - -% On the other hand, perhaps the file did not have a `\input texinfo'. Then -% the first `\{ in the file would cause an error. This macro tries to fix -% that, assuming it is called before the first `\' could plausibly occur. -% -@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi} - -%% These look ok in all fonts, so just make them not special. The @rm below -%% makes sure that the current font starts out as the newly loaded cmr10 -@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other - -@textfonts -@rm - -@c Local variables: -@c page-delimiter: "^\\\\message" -@c End: diff --git a/gnu/lib/regex-0.12/doc/xregex.texi b/gnu/lib/regex-0.12/doc/xregex.texi deleted file mode 100644 index 9292b356ef75..000000000000 --- a/gnu/lib/regex-0.12/doc/xregex.texi +++ /dev/null @@ -1,3021 +0,0 @@ -\input texinfo -@c %**start of header -@setfilename regex.info -@settitle Regex -@c %**end of header - -@c \\{fill-paragraph} works better (for me, anyway) if the text in the -@c source file isn't indented. -@paragraphindent 2 - -@c Define a new index for our magic constants. -@defcodeindex cn - -@c Put everything in one index (arbitrarily chosen to be the concept index). -@syncodeindex cn cp -@syncodeindex ky cp -@syncodeindex pg cp -@syncodeindex tp cp -@syncodeindex vr cp - -@c Here is what we use in the Info `dir' file: -@c * Regex: (regex). Regular expression library. - - -@ifinfo -This file documents the GNU regular expression library. - -Copyright (C) 1992, 1993 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 a 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 also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and 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 the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end ifinfo - - -@titlepage - -@title Regex -@subtitle edition 0.12a -@subtitle 19 September 1992 -@author Kathryn A. Hargreaves -@author Karl Berry - -@page - -@vskip 0pt plus 1filll -Copyright @copyright{} 1992 Free Software Foundation. - -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 also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and 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 the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. - -@end titlepage - - -@ifinfo -@node Top, Overview, (dir), (dir) -@top Regular Expression Library - -This manual documents how to program with the GNU regular expression -library. This is edition 0.12a of the manual, 19 September 1992. - -The first part of this master menu lists the major nodes in this Info -document, including the index. The rest of the menu lists all the -lower level nodes in the document. - -@menu -* Overview:: -* Regular Expression Syntax:: -* Common Operators:: -* GNU Operators:: -* GNU Emacs Operators:: -* What Gets Matched?:: -* Programming with Regex:: -* Copying:: Copying and sharing Regex. -* Index:: General index. - --- The Detailed Node Listing --- - -Regular Expression Syntax - -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: - -Common Operators - -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? @{@} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ - -Repetition Operators - -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: @{@} - -List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]}) - -* Character Class Operators:: [:class:] -* Range Operator:: start-end - -Anchoring Operators - -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ - -GNU Operators - -* Word Operators:: -* Buffer Operators:: - -Word Operators - -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W - -Buffer Operators - -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' - -GNU Emacs Operators - -* Syntactic Class Operators:: - -Syntactic Class Operators - -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS - -Programming with Regex - -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: - -GNU Regex Functions - -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () - -POSIX Regex Functions - -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () - -BSD Regex Functions - -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () -@end menu -@end ifinfo -@node Overview, Regular Expression Syntax, Top, Top -@chapter Overview - -A @dfn{regular expression} (or @dfn{regexp}, or @dfn{pattern}) is a text -string that describes some (mathematical) set of strings. A regexp -@var{r} @dfn{matches} a string @var{s} if @var{s} is in the set of -strings described by @var{r}. - -Using the Regex library, you can: - -@itemize @bullet - -@item -see if a string matches a specified pattern as a whole, and - -@item -search within a string for a substring matching a specified pattern. - -@end itemize - -Some regular expressions match only one string, i.e., the set they -describe has only one member. For example, the regular expression -@samp{foo} matches the string @samp{foo} and no others. Other regular -expressions match more than one string, i.e., the set they describe has -more than one member. For example, the regular expression @samp{f*} -matches the set of strings made up of any number (including zero) of -@samp{f}s. As you can see, some characters in regular expressions match -themselves (such as @samp{f}) and some don't (such as @samp{*}); the -ones that don't match themselves instead let you specify patterns that -describe many different strings. - -To either match or search for a regular expression with the Regex -library functions, you must first compile it with a Regex pattern -compiling function. A @dfn{compiled pattern} is a regular expression -converted to the internal format used by the library functions. Once -you've compiled a pattern, you can use it for matching or searching any -number of times. - -The Regex library consists of two source files: @file{regex.h} and -@file{regex.c}. -@pindex regex.h -@pindex regex.c -Regex provides three groups of functions with which you can operate on -regular expressions. One group---the @sc{gnu} group---is more powerful -but not completely compatible with the other two, namely the @sc{posix} -and Berkeley @sc{unix} groups; its interface was designed specifically -for @sc{gnu}. The other groups have the same interfaces as do the -regular expression functions in @sc{posix} and Berkeley -@sc{unix}. - -We wrote this chapter with programmers in mind, not users of -programs---such as Emacs---that use Regex. We describe the Regex -library in its entirety, not how to write regular expressions that a -particular program understands. - - -@node Regular Expression Syntax, Common Operators, Overview, Top -@chapter Regular Expression Syntax - -@cindex regular expressions, syntax of -@cindex syntax of regular expressions - -@dfn{Characters} are things you can type. @dfn{Operators} are things in -a regular expression that match one or more characters. You compose -regular expressions from operators, which in turn you specify using one -or more characters. - -Most characters represent what we call the match-self operator, i.e., -they match themselves; we call these characters @dfn{ordinary}. Other -characters represent either all or parts of fancier operators; e.g., -@samp{.} represents what we call the match-any-character operator -(which, no surprise, matches (almost) any character); we call these -characters @dfn{special}. Two different things determine what -characters represent what operators: - -@enumerate -@item -the regular expression syntax your program has told the Regex library to -recognize, and - -@item -the context of the character in the regular expression. -@end enumerate - -In the following sections, we describe these things in more detail. - -@menu -* Syntax Bits:: -* Predefined Syntaxes:: -* Collating Elements vs. Characters:: -* The Backslash Character:: -@end menu - - -@node Syntax Bits, Predefined Syntaxes, , Regular Expression Syntax -@section Syntax Bits - -@cindex syntax bits - -In any particular syntax for regular expressions, some characters are -always special, others are sometimes special, and others are never -special. The particular syntax that Regex recognizes for a given -regular expression depends on the value in the @code{syntax} field of -the pattern buffer of that regular expression. - -You get a pattern buffer by compiling a regular expression. @xref{GNU -Pattern Buffers}, and @ref{POSIX Pattern Buffers}, for more information -on pattern buffers. @xref{GNU Regular Expression Compiling}, @ref{POSIX -Regular Expression Compiling}, and @ref{BSD Regular Expression -Compiling}, for more information on compiling. - -Regex considers the value of the @code{syntax} field to be a collection -of bits; we refer to these bits as @dfn{syntax bits}. In most cases, -they affect what characters represent what operators. We describe the -meanings of the operators to which we refer in @ref{Common Operators}, -@ref{GNU Operators}, and @ref{GNU Emacs Operators}. - -For reference, here is the complete list of syntax bits, in alphabetical -order: - -@table @code - -@cnindex RE_BACKSLASH_ESCAPE_IN_LIST -@item RE_BACKSLASH_ESCAPE_IN_LISTS -If this bit is set, then @samp{\} inside a list (@pxref{List Operators} -quotes (makes ordinary, if it's special) the following character; if -this bit isn't set, then @samp{\} is an ordinary character inside lists. -(@xref{The Backslash Character}, for what `\' does outside of lists.) - -@cnindex RE_BK_PLUS_QM -@item RE_BK_PLUS_QM -If this bit is set, then @samp{\+} represents the match-one-or-more -operator and @samp{\?} represents the match-zero-or-more operator; if -this bit isn't set, then @samp{+} represents the match-one-or-more -operator and @samp{?} represents the match-zero-or-one operator. This -bit is irrelevant if @code{RE_LIMITED_OPS} is set. - -@cnindex RE_CHAR_CLASSES -@item RE_CHAR_CLASSES -If this bit is set, then you can use character classes in lists; if this -bit isn't set, then you can't. - -@cnindex RE_CONTEXT_INDEP_ANCHORS -@item RE_CONTEXT_INDEP_ANCHORS -If this bit is set, then @samp{^} and @samp{$} are special anywhere outside -a list; if this bit isn't set, then these characters are special only in -certain contexts. @xref{Match-beginning-of-line Operator}, and -@ref{Match-end-of-line Operator}. - -@cnindex RE_CONTEXT_INDEP_OPS -@item RE_CONTEXT_INDEP_OPS -If this bit is set, then certain characters are special anywhere outside -a list; if this bit isn't set, then those characters are special only in -some contexts and are ordinary elsewhere. Specifically, if this bit -isn't set then @samp{*}, and (if the syntax bit @code{RE_LIMITED_OPS} -isn't set) @samp{+} and @samp{?} (or @samp{\+} and @samp{\?}, depending -on the syntax bit @code{RE_BK_PLUS_QM}) represent repetition operators -only if they're not first in a regular expression or just after an -open-group or alternation operator. The same holds for @samp{@{} (or -@samp{\@{}, depending on the syntax bit @code{RE_NO_BK_BRACES}) if -it is the beginning of a valid interval and the syntax bit -@code{RE_INTERVALS} is set. - -@cnindex RE_CONTEXT_INVALID_OPS -@item RE_CONTEXT_INVALID_OPS -If this bit is set, then repetition and alternation operators can't be -in certain positions within a regular expression. Specifically, the -regular expression is invalid if it has: - -@itemize @bullet - -@item -a repetition operator first in the regular expression or just after a -match-beginning-of-line, open-group, or alternation operator; or - -@item -an alternation operator first or last in the regular expression, just -before a match-end-of-line operator, or just after an alternation or -open-group operator. - -@end itemize - -If this bit isn't set, then you can put the characters representing the -repetition and alternation characters anywhere in a regular expression. -Whether or not they will in fact be operators in certain positions -depends on other syntax bits. - -@cnindex RE_DOT_NEWLINE -@item RE_DOT_NEWLINE -If this bit is set, then the match-any-character operator matches -a newline; if this bit isn't set, then it doesn't. - -@cnindex RE_DOT_NOT_NULL -@item RE_DOT_NOT_NULL -If this bit is set, then the match-any-character operator doesn't match -a null character; if this bit isn't set, then it does. - -@cnindex RE_INTERVALS -@item RE_INTERVALS -If this bit is set, then Regex recognizes interval operators; if this bit -isn't set, then it doesn't. - -@cnindex RE_LIMITED_OPS -@item RE_LIMITED_OPS -If this bit is set, then Regex doesn't recognize the match-one-or-more, -match-zero-or-one or alternation operators; if this bit isn't set, then -it does. - -@cnindex RE_NEWLINE_ALT -@item RE_NEWLINE_ALT -If this bit is set, then newline represents the alternation operator; if -this bit isn't set, then newline is ordinary. - -@cnindex RE_NO_BK_BRACES -@item RE_NO_BK_BRACES -If this bit is set, then @samp{@{} represents the open-interval operator -and @samp{@}} represents the close-interval operator; if this bit isn't -set, then @samp{\@{} represents the open-interval operator and -@samp{\@}} represents the close-interval operator. This bit is relevant -only if @code{RE_INTERVALS} is set. - -@cnindex RE_NO_BK_PARENS -@item RE_NO_BK_PARENS -If this bit is set, then @samp{(} represents the open-group operator and -@samp{)} represents the close-group operator; if this bit isn't set, then -@samp{\(} represents the open-group operator and @samp{\)} represents -the close-group operator. - -@cnindex RE_NO_BK_REFS -@item RE_NO_BK_REFS -If this bit is set, then Regex doesn't recognize @samp{\}@var{digit} as -the back reference operator; if this bit isn't set, then it does. - -@cnindex RE_NO_BK_VBAR -@item RE_NO_BK_VBAR -If this bit is set, then @samp{|} represents the alternation operator; -if this bit isn't set, then @samp{\|} represents the alternation -operator. This bit is irrelevant if @code{RE_LIMITED_OPS} is set. - -@cnindex RE_NO_EMPTY_RANGES -@item RE_NO_EMPTY_RANGES -If this bit is set, then a regular expression with a range whose ending -point collates lower than its starting point is invalid; if this bit -isn't set, then Regex considers such a range to be empty. - -@cnindex RE_UNMATCHED_RIGHT_PAREN_ORD -@item RE_UNMATCHED_RIGHT_PAREN_ORD -If this bit is set and the regular expression has no matching open-group -operator, then Regex considers what would otherwise be a close-group -operator (based on how @code{RE_NO_BK_PARENS} is set) to match @samp{)}. - -@end table - - -@node Predefined Syntaxes, Collating Elements vs. Characters, Syntax Bits, Regular Expression Syntax -@section Predefined Syntaxes - -If you're programming with Regex, you can set a pattern buffer's -(@pxref{GNU Pattern Buffers}, and @ref{POSIX Pattern Buffers}) -@code{syntax} field either to an arbitrary combination of syntax bits -(@pxref{Syntax Bits}) or else to the configurations defined by Regex. -These configurations define the syntaxes used by certain -programs---@sc{gnu} Emacs, -@cindex Emacs -@sc{posix} Awk, -@cindex POSIX Awk -traditional Awk, -@cindex Awk -Grep, -@cindex Grep -@cindex Egrep -Egrep---in addition to syntaxes for @sc{posix} basic and extended -regular expressions. - -The predefined syntaxes--taken directly from @file{regex.h}---are: - -@example -[[[ syntaxes ]]] -@end example - -@node Collating Elements vs. Characters, The Backslash Character, Predefined Syntaxes, Regular Expression Syntax -@section Collating Elements vs.@: Characters - -@sc{posix} generalizes the notion of a character to that of a -collating element. It defines a @dfn{collating element} to be ``a -sequence of one or more bytes defined in the current collating sequence -as a unit of collation.'' - -This generalizes the notion of a character in -two ways. First, a single character can map into two or more collating -elements. For example, the German -@tex -`\ss' -@end tex -@ifinfo -``es-zet'' -@end ifinfo -collates as the collating element @samp{s} followed by another collating -element @samp{s}. Second, two or more characters can map into one -collating element. For example, the Spanish @samp{ll} collates after -@samp{l} and before @samp{m}. - -Since @sc{posix}'s ``collating element'' preserves the essential idea of -a ``character,'' we use the latter, more familiar, term in this document. - -@node The Backslash Character, , Collating Elements vs. Characters, Regular Expression Syntax -@section The Backslash Character - -@cindex \ -The @samp{\} character has one of four different meanings, depending on -the context in which you use it and what syntax bits are set -(@pxref{Syntax Bits}). It can: 1) stand for itself, 2) quote the next -character, 3) introduce an operator, or 4) do nothing. - -@enumerate -@item -It stands for itself inside a list -(@pxref{List Operators}) if the syntax bit -@code{RE_BACKSLASH_ESCAPE_IN_LISTS} is not set. For example, @samp{[\]} -would match @samp{\}. - -@item -It quotes (makes ordinary, if it's special) the next character when you -use it either: - -@itemize @bullet -@item -outside a list,@footnote{Sometimes -you don't have to explicitly quote special characters to make -them ordinary. For instance, most characters lose any special meaning -inside a list (@pxref{List Operators}). In addition, if the syntax bits -@code{RE_CONTEXT_INVALID_OPS} and @code{RE_CONTEXT_INDEP_OPS} -aren't set, then (for historical reasons) the matcher considers special -characters ordinary if they are in contexts where the operations they -represent make no sense; for example, then the match-zero-or-more -operator (represented by @samp{*}) matches itself in the regular -expression @samp{*foo} because there is no preceding expression on which -it can operate. It is poor practice, however, to depend on this -behavior; if you want a special character to be ordinary outside a list, -it's better to always quote it, regardless.} or - -@item -inside a list and the syntax bit @code{RE_BACKSLASH_ESCAPE_IN_LISTS} is set. - -@end itemize - -@item -It introduces an operator when followed by certain ordinary -characters---sometimes only when certain syntax bits are set. See the -cases @code{RE_BK_PLUS_QM}, @code{RE_NO_BK_BRACES}, @code{RE_NO_BK_VAR}, -@code{RE_NO_BK_PARENS}, @code{RE_NO_BK_REF} in @ref{Syntax Bits}. Also: - -@itemize @bullet -@item -@samp{\b} represents the match-word-boundary operator -(@pxref{Match-word-boundary Operator}). - -@item -@samp{\B} represents the match-within-word operator -(@pxref{Match-within-word Operator}). - -@item -@samp{\<} represents the match-beginning-of-word operator @* -(@pxref{Match-beginning-of-word Operator}). - -@item -@samp{\>} represents the match-end-of-word operator -(@pxref{Match-end-of-word Operator}). - -@item -@samp{\w} represents the match-word-constituent operator -(@pxref{Match-word-constituent Operator}). - -@item -@samp{\W} represents the match-non-word-constituent operator -(@pxref{Match-non-word-constituent Operator}). - -@item -@samp{\`} represents the match-beginning-of-buffer -operator and @samp{\'} represents the match-end-of-buffer operator -(@pxref{Buffer Operators}). - -@item -If Regex was compiled with the C preprocessor symbol @code{emacs} -defined, then @samp{\s@var{class}} represents the match-syntactic-class -operator and @samp{\S@var{class}} represents the -match-not-syntactic-class operator (@pxref{Syntactic Class Operators}). - -@end itemize - -@item -In all other cases, Regex ignores @samp{\}. For example, -@samp{\n} matches @samp{n}. - -@end enumerate - -@node Common Operators, GNU Operators, Regular Expression Syntax, Top -@chapter Common Operators - -You compose regular expressions from operators. In the following -sections, we describe the regular expression operators specified by -@sc{posix}; @sc{gnu} also uses these. Most operators have more than one -representation as characters. @xref{Regular Expression Syntax}, for -what characters represent what operators under what circumstances. - -For most operators that can be represented in two ways, one -representation is a single character and the other is that character -preceded by @samp{\}. For example, either @samp{(} or @samp{\(} -represents the open-group operator. Which one does depends on the -setting of a syntax bit, in this case @code{RE_NO_BK_PARENS}. Why is -this so? Historical reasons dictate some of the varying -representations, while @sc{posix} dictates others. - -Finally, almost all characters lose any special meaning inside a list -(@pxref{List Operators}). - -@menu -* Match-self Operator:: Ordinary characters. -* Match-any-character Operator:: . -* Concatenation Operator:: Juxtaposition. -* Repetition Operators:: * + ? @{@} -* Alternation Operator:: | -* List Operators:: [...] [^...] -* Grouping Operators:: (...) -* Back-reference Operator:: \digit -* Anchoring Operators:: ^ $ -@end menu - -@node Match-self Operator, Match-any-character Operator, , Common Operators -@section The Match-self Operator (@var{ordinary character}) - -This operator matches the character itself. All ordinary characters -(@pxref{Regular Expression Syntax}) represent this operator. For -example, @samp{f} is always an ordinary character, so the regular -expression @samp{f} matches only the string @samp{f}. In -particular, it does @emph{not} match the string @samp{ff}. - -@node Match-any-character Operator, Concatenation Operator, Match-self Operator, Common Operators -@section The Match-any-character Operator (@code{.}) - -@cindex @samp{.} - -This operator matches any single printing or nonprinting character -except it won't match a: - -@table @asis -@item newline -if the syntax bit @code{RE_DOT_NEWLINE} isn't set. - -@item null -if the syntax bit @code{RE_DOT_NOT_NULL} is set. - -@end table - -The @samp{.} (period) character represents this operator. For example, -@samp{a.b} matches any three-character string beginning with @samp{a} -and ending with @samp{b}. - -@node Concatenation Operator, Repetition Operators, Match-any-character Operator, Common Operators -@section The Concatenation Operator - -This operator concatenates two regular expressions @var{a} and @var{b}. -No character represents this operator; you simply put @var{b} after -@var{a}. The result is a regular expression that will match a string if -@var{a} matches its first part and @var{b} matches the rest. For -example, @samp{xy} (two match-self operators) matches @samp{xy}. - -@node Repetition Operators, Alternation Operator, Concatenation Operator, Common Operators -@section Repetition Operators - -Repetition operators repeat the preceding regular expression a specified -number of times. - -@menu -* Match-zero-or-more Operator:: * -* Match-one-or-more Operator:: + -* Match-zero-or-one Operator:: ? -* Interval Operators:: @{@} -@end menu - -@node Match-zero-or-more Operator, Match-one-or-more Operator, , Repetition Operators -@subsection The Match-zero-or-more Operator (@code{*}) - -@cindex @samp{*} - -This operator repeats the smallest possible preceding regular expression -as many times as necessary (including zero) to match the pattern. -@samp{*} represents this operator. For example, @samp{o*} -matches any string made up of zero or more @samp{o}s. Since this -operator operates on the smallest preceding regular expression, -@samp{fo*} has a repeating @samp{o}, not a repeating @samp{fo}. So, -@samp{fo*} matches @samp{f}, @samp{fo}, @samp{foo}, and so on. - -Since the match-zero-or-more operator is a suffix operator, it may be -useless as such when no regular expression precedes it. This is the -case when it: - -@itemize @bullet -@item -is first in a regular expression, or - -@item -follows a match-beginning-of-line, open-group, or alternation -operator. - -@end itemize - -@noindent -Three different things can happen in these cases: - -@enumerate -@item -If the syntax bit @code{RE_CONTEXT_INVALID_OPS} is set, then the -regular expression is invalid. - -@item -If @code{RE_CONTEXT_INVALID_OPS} isn't set, but -@code{RE_CONTEXT_INDEP_OPS} is, then @samp{*} represents the -match-zero-or-more operator (which then operates on the empty string). - -@item -Otherwise, @samp{*} is ordinary. - -@end enumerate - -@cindex backtracking -The matcher processes a match-zero-or-more operator by first matching as -many repetitions of the smallest preceding regular expression as it can. -Then it continues to match the rest of the pattern. - -If it can't match the rest of the pattern, it backtracks (as many times -as necessary), each time discarding one of the matches until it can -either match the entire pattern or be certain that it cannot get a -match. For example, when matching @samp{ca*ar} against @samp{caaar}, -the matcher first matches all three @samp{a}s of the string with the -@samp{a*} of the regular expression. However, it cannot then match the -final @samp{ar} of the regular expression against the final @samp{r} of -the string. So it backtracks, discarding the match of the last @samp{a} -in the string. It can then match the remaining @samp{ar}. - - -@node Match-one-or-more Operator, Match-zero-or-one Operator, Match-zero-or-more Operator, Repetition Operators -@subsection The Match-one-or-more Operator (@code{+} or @code{\+}) - -@cindex @samp{+} - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't recognize -this operator. Otherwise, if the syntax bit @code{RE_BK_PLUS_QM} isn't -set, then @samp{+} represents this operator; if it is, then @samp{\+} -does. - -This operator is similar to the match-zero-or-more operator except that -it repeats the preceding regular expression at least once; -@pxref{Match-zero-or-more Operator}, for what it operates on, how some -syntax bits affect it, and how Regex backtracks to match it. - -For example, supposing that @samp{+} represents the match-one-or-more -operator; then @samp{ca+r} matches, e.g., @samp{car} and -@samp{caaaar}, but not @samp{cr}. - -@node Match-zero-or-one Operator, Interval Operators, Match-one-or-more Operator, Repetition Operators -@subsection The Match-zero-or-one Operator (@code{?} or @code{\?}) -@cindex @samp{?} - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit -@code{RE_BK_PLUS_QM} isn't set, then @samp{?} represents this operator; -if it is, then @samp{\?} does. - -This operator is similar to the match-zero-or-more operator except that -it repeats the preceding regular expression once or not at all; -@pxref{Match-zero-or-more Operator}, to see what it operates on, how -some syntax bits affect it, and how Regex backtracks to match it. - -For example, supposing that @samp{?} represents the match-zero-or-one -operator; then @samp{ca?r} matches both @samp{car} and @samp{cr}, but -nothing else. - -@node Interval Operators, , Match-zero-or-one Operator, Repetition Operators -@subsection Interval Operators (@code{@{} @dots{} @code{@}} or @code{\@{} @dots{} @code{\@}}) - -@cindex interval expression -@cindex @samp{@{} -@cindex @samp{@}} -@cindex @samp{\@{} -@cindex @samp{\@}} - -If the syntax bit @code{RE_INTERVALS} is set, then Regex recognizes -@dfn{interval expressions}. They repeat the smallest possible preceding -regular expression a specified number of times. - -If the syntax bit @code{RE_NO_BK_BRACES} is set, @samp{@{} represents -the @dfn{open-interval operator} and @samp{@}} represents the -@dfn{close-interval operator} ; otherwise, @samp{\@{} and @samp{\@}} do. - -Specifically, supposing that @samp{@{} and @samp{@}} represent the -open-interval and close-interval operators; then: - -@table @code -@item @{@var{count}@} -matches exactly @var{count} occurrences of the preceding regular -expression. - -@item @{@var{min,}@} -matches @var{min} or more occurrences of the preceding regular -expression. - -@item @{@var{min, max}@} -matches at least @var{min} but no more than @var{max} occurrences of -the preceding regular expression. - -@end table - -The interval expression (but not necessarily the regular expression that -contains it) is invalid if: - -@itemize @bullet -@item -@var{min} is greater than @var{max}, or - -@item -any of @var{count}, @var{min}, or @var{max} are outside the range -zero to @code{RE_DUP_MAX} (which symbol @file{regex.h} -defines). - -@end itemize - -If the interval expression is invalid and the syntax bit -@code{RE_NO_BK_BRACES} is set, then Regex considers all the -characters in the would-be interval to be ordinary. If that bit -isn't set, then the regular expression is invalid. - -If the interval expression is valid but there is no preceding regular -expression on which to operate, then if the syntax bit -@code{RE_CONTEXT_INVALID_OPS} is set, the regular expression is invalid. -If that bit isn't set, then Regex considers all the characters---other -than backslashes, which it ignores---in the would-be interval to be -ordinary. - - -@node Alternation Operator, List Operators, Repetition Operators, Common Operators -@section The Alternation Operator (@code{|} or @code{\|}) - -@kindex | -@kindex \| -@cindex alternation operator -@cindex or operator - -If the syntax bit @code{RE_LIMITED_OPS} is set, then Regex doesn't -recognize this operator. Otherwise, if the syntax bit -@code{RE_NO_BK_VBAR} is set, then @samp{|} represents this operator; -otherwise, @samp{\|} does. - -Alternatives match one of a choice of regular expressions: -if you put the character(s) representing the alternation operator between -any two regular expressions @var{a} and @var{b}, the result matches -the union of the strings that @var{a} and @var{b} match. For -example, supposing that @samp{|} is the alternation operator, then -@samp{foo|bar|quux} would match any of @samp{foo}, @samp{bar} or -@samp{quux}. - -@ignore -@c Nobody needs to disallow empty alternatives any more. -If the syntax bit @code{RE_NO_EMPTY_ALTS} is set, then if either of the regular -expressions @var{a} or @var{b} is empty, the -regular expression is invalid. More precisely, if this syntax bit is -set, then the alternation operator can't: - -@itemize @bullet -@item -be first or last in a regular expression; - -@item -follow either another alternation operator or an open-group operator -(@pxref{Grouping Operators}); or - -@item -precede a close-group operator. - -@end itemize - -@noindent -For example, supposing @samp{(} and @samp{)} represent the open and -close-group operators, then @samp{|foo}, @samp{foo|}, @samp{foo||bar}, -@samp{foo(|bar)}, and @samp{(foo|)bar} would all be invalid. -@end ignore - -The alternation operator operates on the @emph{largest} possible -surrounding regular expressions. (Put another way, it has the lowest -precedence of any regular expression operator.) -Thus, the only way you can -delimit its arguments is to use grouping. For example, if @samp{(} and -@samp{)} are the open and close-group operators, then @samp{fo(o|b)ar} -would match either @samp{fooar} or @samp{fobar}. (@samp{foo|bar} would -match @samp{foo} or @samp{bar}.) - -@cindex backtracking -The matcher usually tries all combinations of alternatives so as to -match the longest possible string. For example, when matching -@samp{(fooq|foo)*(qbarquux|bar)} against @samp{fooqbarquux}, it cannot -take, say, the first (``depth-first'') combination it could match, since -then it would be content to match just @samp{fooqbar}. - -@comment xx something about leftmost-longest - - -@node List Operators, Grouping Operators, Alternation Operator, Common Operators -@section List Operators (@code{[} @dots{} @code{]} and @code{[^} @dots{} @code{]}) - -@cindex matching list -@cindex @samp{[} -@cindex @samp{]} -@cindex @samp{^} -@cindex @samp{-} -@cindex @samp{\} -@cindex @samp{[^} -@cindex nonmatching list -@cindex matching newline -@cindex bracket expression - -@dfn{Lists}, also called @dfn{bracket expressions}, are a set of one or -more items. An @dfn{item} is a character, -@ignore -(These get added when they get implemented.) -a collating symbol, an equivalence class expression, -@end ignore -a character class expression, or a range expression. The syntax bits -affect which kinds of items you can put in a list. We explain the last -two items in subsections below. Empty lists are invalid. - -A @dfn{matching list} matches a single character represented by one of -the list items. You form a matching list by enclosing one or more items -within an @dfn{open-matching-list operator} (represented by @samp{[}) -and a @dfn{close-list operator} (represented by @samp{]}). - -For example, @samp{[ab]} matches either @samp{a} or @samp{b}. -@samp{[ad]*} matches the empty string and any string composed of just -@samp{a}s and @samp{d}s in any order. Regex considers invalid a regular -expression with a @samp{[} but no matching -@samp{]}. - -@dfn{Nonmatching lists} are similar to matching lists except that they -match a single character @emph{not} represented by one of the list -items. You use an @dfn{open-nonmatching-list operator} (represented by -@samp{[^}@footnote{Regex therefore doesn't consider the @samp{^} to be -the first character in the list. If you put a @samp{^} character first -in (what you think is) a matching list, you'll turn it into a -nonmatching list.}) instead of an open-matching-list operator to start a -nonmatching list. - -For example, @samp{[^ab]} matches any character except @samp{a} or -@samp{b}. - -If the @code{posix_newline} field in the pattern buffer (@pxref{GNU -Pattern Buffers} is set, then nonmatching lists do not match a newline. - -Most characters lose any special meaning inside a list. The special -characters inside a list follow. - -@table @samp -@item ] -ends the list if it's not the first list item. So, if you want to make -the @samp{]} character a list item, you must put it first. - -@item \ -quotes the next character if the syntax bit @code{RE_BACKSLASH_ESCAPE_IN_LISTS} is -set. - -@ignore -Put these in if they get implemented. - -@item [. -represents the open-collating-symbol operator (@pxref{Collating Symbol -Operators}). - -@item .] -represents the close-collating-symbol operator. - -@item [= -represents the open-equivalence-class operator (@pxref{Equivalence Class -Operators}). - -@item =] -represents the close-equivalence-class operator. - -@end ignore - -@item [: -represents the open-character-class operator (@pxref{Character Class -Operators}) if the syntax bit @code{RE_CHAR_CLASSES} is set and what -follows is a valid character class expression. - -@item :] -represents the close-character-class operator if the syntax bit -@code{RE_CHAR_CLASSES} is set and what precedes it is an -open-character-class operator followed by a valid character class name. - -@item - -represents the range operator (@pxref{Range Operator}) if it's -not first or last in a list or the ending point of a range. - -@end table - -@noindent -All other characters are ordinary. For example, @samp{[.*]} matches -@samp{.} and @samp{*}. - -@menu -* Character Class Operators:: [:class:] -* Range Operator:: start-end -@end menu - -@ignore -(If collating symbols and equivalence class expressions get implemented, -then add this.) - -node Collating Symbol Operators -subsubsection Collating Symbol Operators (@code{[.} @dots{} @code{.]}) - -If the syntax bit @code{XX} is set, then you can represent -collating symbols inside lists. You form a @dfn{collating symbol} by -putting a collating element between an @dfn{open-collating-symbol -operator} and an @dfn{close-collating-symbol operator}. @samp{[.} -represents the open-collating-symbol operator and @samp{.]} represents -the close-collating-symbol operator. For example, if @samp{ll} is a -collating element, then @samp{[[.ll.]]} would match @samp{ll}. - -node Equivalence Class Operators -subsubsection Equivalence Class Operators (@code{[=} @dots{} @code{=]}) -@cindex equivalence class expression in regex -@cindex @samp{[=} in regex -@cindex @samp{=]} in regex - -If the syntax bit @code{XX} is set, then Regex recognizes equivalence class -expressions inside lists. A @dfn{equivalence class expression} is a set -of collating elements which all belong to the same equivalence class. -You form an equivalence class expression by putting a collating -element between an @dfn{open-equivalence-class operator} and a -@dfn{close-equivalence-class operator}. @samp{[=} represents the -open-equivalence-class operator and @samp{=]} represents the -close-equivalence-class operator. For example, if @samp{a} and @samp{A} -were an equivalence class, then both @samp{[[=a=]]} and @samp{[[=A=]]} -would match both @samp{a} and @samp{A}. If the collating element in an -equivalence class expression isn't part of an equivalence class, then -the matcher considers the equivalence class expression to be a collating -symbol. - -@end ignore - -@node Character Class Operators, Range Operator, , List Operators -@subsection Character Class Operators (@code{[:} @dots{} @code{:]}) - -@cindex character classes -@cindex @samp{[:} in regex -@cindex @samp{:]} in regex - -If the syntax bit @code{RE_CHARACTER_CLASSES} is set, then Regex -recognizes character class expressions inside lists. A @dfn{character -class expression} matches one character from a given class. You form a -character class expression by putting a character class name between an -@dfn{open-character-class operator} (represented by @samp{[:}) and a -@dfn{close-character-class operator} (represented by @samp{:]}). The -character class names and their meanings are: - -@table @code - -@item alnum -letters and digits - -@item alpha -letters - -@item blank -system-dependent; for @sc{gnu}, a space or tab - -@item cntrl -control characters (in the @sc{ascii} encoding, code 0177 and codes -less than 040) - -@item digit -digits - -@item graph -same as @code{print} except omits space - -@item lower -lowercase letters - -@item print -printable characters (in the @sc{ascii} encoding, space -tilde---codes 040 through 0176) - -@item punct -neither control nor alphanumeric characters - -@item space -space, carriage return, newline, vertical tab, and form feed - -@item upper -uppercase letters - -@item xdigit -hexadecimal digits: @code{0}--@code{9}, @code{a}--@code{f}, @code{A}--@code{F} - -@end table - -@noindent -These correspond to the definitions in the C library's @file{} -facility. For example, @samp{[:alpha:]} corresponds to the standard -facility @code{isalpha}. Regex recognizes character class expressions -only inside of lists; so @samp{[[:alpha:]]} matches any letter, but -@samp{[:alpha:]} outside of a bracket expression and not followed by a -repetition operator matches just itself. - -@node Range Operator, , Character Class Operators, List Operators -@subsection The Range Operator (@code{-}) - -Regex recognizes @dfn{range expressions} inside a list. They represent -those characters -that fall between two elements in the current collating sequence. You -form a range expression by putting a @dfn{range operator} between two -@ignore -(If these get implemented, then substitute this for ``characters.'') -of any of the following: characters, collating elements, collating symbols, -and equivalence class expressions. The starting point of the range and -the ending point of the range don't have to be the same kind of item, -e.g., the starting point could be a collating element and the ending -point could be an equivalence class expression. If a range's ending -point is an equivalence class, then all the collating elements in that -class will be in the range. -@end ignore -characters.@footnote{You can't use a character class for the starting -or ending point of a range, since a character class is not a single -character.} @samp{-} represents the range operator. For example, -@samp{a-f} within a list represents all the characters from @samp{a} -through @samp{f} -inclusively. - -If the syntax bit @code{RE_NO_EMPTY_RANGES} is set, then if the range's -ending point collates less than its starting point, the range (and the -regular expression containing it) is invalid. For example, the regular -expression @samp{[z-a]} would be invalid. If this bit isn't set, then -Regex considers such a range to be empty. - -Since @samp{-} represents the range operator, if you want to make a -@samp{-} character itself -a list item, you must do one of the following: - -@itemize @bullet -@item -Put the @samp{-} either first or last in the list. - -@item -Include a range whose starting point collates strictly lower than -@samp{-} and whose ending point collates equal or higher. Unless a -range is the first item in a list, a @samp{-} can't be its starting -point, but @emph{can} be its ending point. That is because Regex -considers @samp{-} to be the range operator unless it is preceded by -another @samp{-}. For example, in the @sc{ascii} encoding, @samp{)}, -@samp{*}, @samp{+}, @samp{,}, @samp{-}, @samp{.}, and @samp{/} are -contiguous characters in the collating sequence. You might think that -@samp{[)-+--/]} has two ranges: @samp{)-+} and @samp{--/}. Rather, it -has the ranges @samp{)-+} and @samp{+--}, plus the character @samp{/}, so -it matches, e.g., @samp{,}, not @samp{.}. - -@item -Put a range whose starting point is @samp{-} first in the list. - -@end itemize - -For example, @samp{[-a-z]} matches a lowercase letter or a hyphen (in -English, in @sc{ascii}). - - -@node Grouping Operators, Back-reference Operator, List Operators, Common Operators -@section Grouping Operators (@code{(} @dots{} @code{)} or @code{\(} @dots{} @code{\)}) - -@kindex ( -@kindex ) -@kindex \( -@kindex \) -@cindex grouping -@cindex subexpressions -@cindex parenthesizing - -A @dfn{group}, also known as a @dfn{subexpression}, consists of an -@dfn{open-group operator}, any number of other operators, and a -@dfn{close-group operator}. Regex treats this sequence as a unit, just -as mathematics and programming languages treat a parenthesized -expression as a unit. - -Therefore, using @dfn{groups}, you can: - -@itemize @bullet -@item -delimit the argument(s) to an alternation operator (@pxref{Alternation -Operator}) or a repetition operator (@pxref{Repetition -Operators}). - -@item -keep track of the indices of the substring that matched a given group. -@xref{Using Registers}, for a precise explanation. -This lets you: - -@itemize @bullet -@item -use the back-reference operator (@pxref{Back-reference Operator}). - -@item -use registers (@pxref{Using Registers}). - -@end itemize - -@end itemize - -If the syntax bit @code{RE_NO_BK_PARENS} is set, then @samp{(} represents -the open-group operator and @samp{)} represents the -close-group operator; otherwise, @samp{\(} and @samp{\)} do. - -If the syntax bit @code{RE_UNMATCHED_RIGHT_PAREN_ORD} is set and a -close-group operator has no matching open-group operator, then Regex -considers it to match @samp{)}. - - -@node Back-reference Operator, Anchoring Operators, Grouping Operators, Common Operators -@section The Back-reference Operator (@dfn{\}@var{digit}) - -@cindex back references - -If the syntax bit @code{RE_NO_BK_REF} isn't set, then Regex recognizes -back references. A back reference matches a specified preceding group. -The back reference operator is represented by @samp{\@var{digit}} -anywhere after the end of a regular expression's @w{@var{digit}-th} -group (@pxref{Grouping Operators}). - -@var{digit} must be between @samp{1} and @samp{9}. The matcher assigns -numbers 1 through 9 to the first nine groups it encounters. By using -one of @samp{\1} through @samp{\9} after the corresponding group's -close-group operator, you can match a substring identical to the -one that the group does. - -Back references match according to the following (in all examples below, -@samp{(} represents the open-group, @samp{)} the close-group, @samp{@{} -the open-interval and @samp{@}} the close-interval operator): - -@itemize @bullet -@item -If the group matches a substring, the back reference matches an -identical substring. For example, @samp{(a)\1} matches @samp{aa} and -@samp{(bana)na\1bo\1} matches @samp{bananabanabobana}. Likewise, -@samp{(.*)\1} matches any (newline-free if the syntax bit -@code{RE_DOT_NEWLINE} isn't set) string that is composed of two -identical halves; the @samp{(.*)} matches the first half and the -@samp{\1} matches the second half. - -@item -If the group matches more than once (as it might if followed -by, e.g., a repetition operator), then the back reference matches the -substring the group @emph{last} matched. For example, -@samp{((a*)b)*\1\2} matches @samp{aabababa}; first @w{group 1} (the -outer one) matches @samp{aab} and @w{group 2} (the inner one) matches -@samp{aa}. Then @w{group 1} matches @samp{ab} and @w{group 2} matches -@samp{a}. So, @samp{\1} matches @samp{ab} and @samp{\2} matches -@samp{a}. - -@item -If the group doesn't participate in a match, i.e., it is part of an -alternative not taken or a repetition operator allows zero repetitions -of it, then the back reference makes the whole match fail. For example, -@samp{(one()|two())-and-(three\2|four\3)} matches @samp{one-and-three} -and @samp{two-and-four}, but not @samp{one-and-four} or -@samp{two-and-three}. For example, if the pattern matches -@samp{one-and-}, then its @w{group 2} matches the empty string and its -@w{group 3} doesn't participate in the match. So, if it then matches -@samp{four}, then when it tries to back reference @w{group 3}---which it -will attempt to do because @samp{\3} follows the @samp{four}---the match -will fail because @w{group 3} didn't participate in the match. - -@end itemize - -You can use a back reference as an argument to a repetition operator. For -example, @samp{(a(b))\2*} matches @samp{a} followed by two or more -@samp{b}s. Similarly, @samp{(a(b))\2@{3@}} matches @samp{abbbb}. - -If there is no preceding @w{@var{digit}-th} subexpression, the regular -expression is invalid. - - -@node Anchoring Operators, , Back-reference Operator, Common Operators -@section Anchoring Operators - -@cindex anchoring -@cindex regexp anchoring - -These operators can constrain a pattern to match only at the beginning or -end of the entire string or at the beginning or end of a line. - -@menu -* Match-beginning-of-line Operator:: ^ -* Match-end-of-line Operator:: $ -@end menu - - -@node Match-beginning-of-line Operator, Match-end-of-line Operator, , Anchoring Operators -@subsection The Match-beginning-of-line Operator (@code{^}) - -@kindex ^ -@cindex beginning-of-line operator -@cindex anchors - -This operator can match the empty string either at the beginning of the -string or after a newline character. Thus, it is said to @dfn{anchor} -the pattern to the beginning of a line. - -In the cases following, @samp{^} represents this operator. (Otherwise, -@samp{^} is ordinary.) - -@itemize @bullet - -@item -It (the @samp{^}) is first in the pattern, as in @samp{^foo}. - -@cnindex RE_CONTEXT_INDEP_ANCHORS @r{(and @samp{^})} -@item -The syntax bit @code{RE_CONTEXT_INDEP_ANCHORS} is set, and it is outside -a bracket expression. - -@cindex open-group operator and @samp{^} -@cindex alternation operator and @samp{^} -@item -It follows an open-group or alternation operator, as in @samp{a\(^b\)} -and @samp{a\|^b}. @xref{Grouping Operators}, and @ref{Alternation -Operator}. - -@end itemize - -These rules imply that some valid patterns containing @samp{^} cannot be -matched; for example, @samp{foo^bar} if @code{RE_CONTEXT_INDEP_ANCHORS} -is set. - -@vindex not_bol @r{field in pattern buffer} -If the @code{not_bol} field is set in the pattern buffer (@pxref{GNU -Pattern Buffers}), then @samp{^} fails to match at the beginning of the -string. @xref{POSIX Matching}, for when you might find this useful. - -@vindex newline_anchor @r{field in pattern buffer} -If the @code{newline_anchor} field is set in the pattern buffer, then -@samp{^} fails to match after a newline. This is useful when you do not -regard the string to be matched as broken into lines. - - -@node Match-end-of-line Operator, , Match-beginning-of-line Operator, Anchoring Operators -@subsection The Match-end-of-line Operator (@code{$}) - -@kindex $ -@cindex end-of-line operator -@cindex anchors - -This operator can match the empty string either at the end of -the string or before a newline character in the string. Thus, it is -said to @dfn{anchor} the pattern to the end of a line. - -It is always represented by @samp{$}. For example, @samp{foo$} usually -matches, e.g., @samp{foo} and, e.g., the first three characters of -@samp{foo\nbar}. - -Its interaction with the syntax bits and pattern buffer fields is -exactly the dual of @samp{^}'s; see the previous section. (That is, -``beginning'' becomes ``end'', ``next'' becomes ``previous'', and -``after'' becomes ``before''.) - - -@node GNU Operators, GNU Emacs Operators, Common Operators, Top -@chapter GNU Operators - -Following are operators that @sc{gnu} defines (and @sc{posix} doesn't). - -@menu -* Word Operators:: -* Buffer Operators:: -@end menu - -@node Word Operators, Buffer Operators, , GNU Operators -@section Word Operators - -The operators in this section require Regex to recognize parts of words. -Regex uses a syntax table to determine whether or not a character is -part of a word, i.e., whether or not it is @dfn{word-constituent}. - -@menu -* Non-Emacs Syntax Tables:: -* Match-word-boundary Operator:: \b -* Match-within-word Operator:: \B -* Match-beginning-of-word Operator:: \< -* Match-end-of-word Operator:: \> -* Match-word-constituent Operator:: \w -* Match-non-word-constituent Operator:: \W -@end menu - -@node Non-Emacs Syntax Tables, Match-word-boundary Operator, , Word Operators -@subsection Non-Emacs Syntax Tables - -A @dfn{syntax table} is an array indexed by the characters in your -character set. In the @sc{ascii} encoding, therefore, a syntax table -has 256 elements. Regex always uses a @code{char *} variable -@code{re_syntax_table} as its syntax table. In some cases, it -initializes this variable and in others it expects you to initialize it. - -@itemize @bullet -@item -If Regex is compiled with the preprocessor symbols @code{emacs} and -@code{SYNTAX_TABLE} both undefined, then Regex allocates -@code{re_syntax_table} and initializes an element @var{i} either to -@code{Sword} (which it defines) if @var{i} is a letter, number, or -@samp{_}, or to zero if it's not. - -@item -If Regex is compiled with @code{emacs} undefined but @code{SYNTAX_TABLE} -defined, then Regex expects you to define a @code{char *} variable -@code{re_syntax_table} to be a valid syntax table. - -@item -@xref{Emacs Syntax Tables}, for what happens when Regex is compiled with -the preprocessor symbol @code{emacs} defined. - -@end itemize - -@node Match-word-boundary Operator, Match-within-word Operator, Non-Emacs Syntax Tables, Word Operators -@subsection The Match-word-boundary Operator (@code{\b}) - -@cindex @samp{\b} -@cindex word boundaries, matching - -This operator (represented by @samp{\b}) matches the empty string at -either the beginning or the end of a word. For example, @samp{\brat\b} -matches the separate word @samp{rat}. - -@node Match-within-word Operator, Match-beginning-of-word Operator, Match-word-boundary Operator, Word Operators -@subsection The Match-within-word Operator (@code{\B}) - -@cindex @samp{\B} - -This operator (represented by @samp{\B}) matches the empty string within -a word. For example, @samp{c\Brat\Be} matches @samp{crate}, but -@samp{dirty \Brat} doesn't match @samp{dirty rat}. - -@node Match-beginning-of-word Operator, Match-end-of-word Operator, Match-within-word Operator, Word Operators -@subsection The Match-beginning-of-word Operator (@code{\<}) - -@cindex @samp{\<} - -This operator (represented by @samp{\<}) matches the empty string at the -beginning of a word. - -@node Match-end-of-word Operator, Match-word-constituent Operator, Match-beginning-of-word Operator, Word Operators -@subsection The Match-end-of-word Operator (@code{\>}) - -@cindex @samp{\>} - -This operator (represented by @samp{\>}) matches the empty string at the -end of a word. - -@node Match-word-constituent Operator, Match-non-word-constituent Operator, Match-end-of-word Operator, Word Operators -@subsection The Match-word-constituent Operator (@code{\w}) - -@cindex @samp{\w} - -This operator (represented by @samp{\w}) matches any word-constituent -character. - -@node Match-non-word-constituent Operator, , Match-word-constituent Operator, Word Operators -@subsection The Match-non-word-constituent Operator (@code{\W}) - -@cindex @samp{\W} - -This operator (represented by @samp{\W}) matches any character that is -not word-constituent. - - -@node Buffer Operators, , Word Operators, GNU Operators -@section Buffer Operators - -Following are operators which work on buffers. In Emacs, a @dfn{buffer} -is, naturally, an Emacs buffer. For other programs, Regex considers the -entire string to be matched as the buffer. - -@menu -* Match-beginning-of-buffer Operator:: \` -* Match-end-of-buffer Operator:: \' -@end menu - - -@node Match-beginning-of-buffer Operator, Match-end-of-buffer Operator, , Buffer Operators -@subsection The Match-beginning-of-buffer Operator (@code{\`}) - -@cindex @samp{\`} - -This operator (represented by @samp{\`}) matches the empty string at the -beginning of the buffer. - -@node Match-end-of-buffer Operator, , Match-beginning-of-buffer Operator, Buffer Operators -@subsection The Match-end-of-buffer Operator (@code{\'}) - -@cindex @samp{\'} - -This operator (represented by @samp{\'}) matches the empty string at the -end of the buffer. - - -@node GNU Emacs Operators, What Gets Matched?, GNU Operators, Top -@chapter GNU Emacs Operators - -Following are operators that @sc{gnu} defines (and @sc{posix} doesn't) -that you can use only when Regex is compiled with the preprocessor -symbol @code{emacs} defined. - -@menu -* Syntactic Class Operators:: -@end menu - - -@node Syntactic Class Operators, , , GNU Emacs Operators -@section Syntactic Class Operators - -The operators in this section require Regex to recognize the syntactic -classes of characters. Regex uses a syntax table to determine this. - -@menu -* Emacs Syntax Tables:: -* Match-syntactic-class Operator:: \sCLASS -* Match-not-syntactic-class Operator:: \SCLASS -@end menu - -@node Emacs Syntax Tables, Match-syntactic-class Operator, , Syntactic Class Operators -@subsection Emacs Syntax Tables - -A @dfn{syntax table} is an array indexed by the characters in your -character set. In the @sc{ascii} encoding, therefore, a syntax table -has 256 elements. - -If Regex is compiled with the preprocessor symbol @code{emacs} defined, -then Regex expects you to define and initialize the variable -@code{re_syntax_table} to be an Emacs syntax table. Emacs' syntax -tables are more complicated than Regex's own (@pxref{Non-Emacs Syntax -Tables}). @xref{Syntax, , Syntax, emacs, The GNU Emacs User's Manual}, -for a description of Emacs' syntax tables. - -@node Match-syntactic-class Operator, Match-not-syntactic-class Operator, Emacs Syntax Tables, Syntactic Class Operators -@subsection The Match-syntactic-class Operator (@code{\s}@var{class}) - -@cindex @samp{\s} - -This operator matches any character whose syntactic class is represented -by a specified character. @samp{\s@var{class}} represents this operator -where @var{class} is the character representing the syntactic class you -want. For example, @samp{w} represents the syntactic -class of word-constituent characters, so @samp{\sw} matches any -word-constituent character. - -@node Match-not-syntactic-class Operator, , Match-syntactic-class Operator, Syntactic Class Operators -@subsection The Match-not-syntactic-class Operator (@code{\S}@var{class}) - -@cindex @samp{\S} - -This operator is similar to the match-syntactic-class operator except -that it matches any character whose syntactic class is @emph{not} -represented by the specified character. @samp{\S@var{class}} represents -this operator. For example, @samp{w} represents the syntactic class of -word-constituent characters, so @samp{\Sw} matches any character that is -not word-constituent. - - -@node What Gets Matched?, Programming with Regex, GNU Emacs Operators, Top -@chapter What Gets Matched? - -Regex usually matches strings according to the ``leftmost longest'' -rule; that is, it chooses the longest of the leftmost matches. This -does not mean that for a regular expression containing subexpressions -that it simply chooses the longest match for each subexpression, left to -right; the overall match must also be the longest possible one. - -For example, @samp{(ac*)(c*d[ac]*)\1} matches @samp{acdacaaa}, not -@samp{acdac}, as it would if it were to choose the longest match for the -first subexpression. - - -@node Programming with Regex, Copying, What Gets Matched?, Top -@chapter Programming with Regex - -Here we describe how you use the Regex data structures and functions in -C programs. Regex has three interfaces: one designed for @sc{gnu}, one -compatible with @sc{posix} and one compatible with Berkeley @sc{unix}. - -@menu -* GNU Regex Functions:: -* POSIX Regex Functions:: -* BSD Regex Functions:: -@end menu - - -@node GNU Regex Functions, POSIX Regex Functions, , Programming with Regex -@section GNU Regex Functions - -If you're writing code that doesn't need to be compatible with either -@sc{posix} or Berkeley @sc{unix}, you can use these functions. They -provide more options than the other interfaces. - -@menu -* GNU Pattern Buffers:: The re_pattern_buffer type. -* GNU Regular Expression Compiling:: re_compile_pattern () -* GNU Matching:: re_match () -* GNU Searching:: re_search () -* Matching/Searching with Split Data:: re_match_2 (), re_search_2 () -* Searching with Fastmaps:: re_compile_fastmap () -* GNU Translate Tables:: The `translate' field. -* Using Registers:: The re_registers type and related fns. -* Freeing GNU Pattern Buffers:: regfree () -@end menu - - -@node GNU Pattern Buffers, GNU Regular Expression Compiling, , GNU Regex Functions -@subsection GNU Pattern Buffers - -@cindex pattern buffer, definition of -@tindex re_pattern_buffer @r{definition} -@tindex struct re_pattern_buffer @r{definition} - -To compile, match, or search for a given regular expression, you must -supply a pattern buffer. A @dfn{pattern buffer} holds one compiled -regular expression.@footnote{Regular expressions are also referred to as -``patterns,'' hence the name ``pattern buffer.''} - -You can have several different pattern buffers simultaneously, each -holding a compiled pattern for a different regular expression. - -@file{regex.h} defines the pattern buffer @code{struct} as follows: - -@example -[[[ pattern_buffer ]]] -@end example - - -@node GNU Regular Expression Compiling, GNU Matching, GNU Pattern Buffers, GNU Regex Functions -@subsection GNU Regular Expression Compiling - -In @sc{gnu}, you can both match and search for a given regular -expression. To do either, you must first compile it in a pattern buffer -(@pxref{GNU Pattern Buffers}). - -@cindex syntax initialization -@vindex re_syntax_options @r{initialization} -Regular expressions match according to the syntax with which they were -compiled; with @sc{gnu}, you indicate what syntax you want by setting -the variable @code{re_syntax_options} (declared in @file{regex.h} and -defined in @file{regex.c}) before calling the compiling function, -@code{re_compile_pattern} (see below). @xref{Syntax Bits}, and -@ref{Predefined Syntaxes}. - -You can change the value of @code{re_syntax_options} at any time. -Usually, however, you set its value once and then never change it. - -@cindex pattern buffer initialization -@code{re_compile_pattern} takes a pattern buffer as an argument. You -must initialize the following fields: - -@table @code - -@item translate @r{initialization} - -@item translate -@vindex translate @r{initialization} -Initialize this to point to a translate table if you want one, or to -zero if you don't. We explain translate tables in @ref{GNU Translate -Tables}. - -@item fastmap -@vindex fastmap @r{initialization} -Initialize this to nonzero if you want a fastmap, or to zero if you -don't. - -@item buffer -@itemx allocated -@vindex buffer @r{initialization} -@vindex allocated @r{initialization} -@findex malloc -If you want @code{re_compile_pattern} to allocate memory for the -compiled pattern, set both of these to zero. If you have an existing -block of memory (allocated with @code{malloc}) you want Regex to use, -set @code{buffer} to its address and @code{allocated} to its size (in -bytes). - -@code{re_compile_pattern} uses @code{realloc} to extend the space for -the compiled pattern as necessary. - -@end table - -To compile a pattern buffer, use: - -@findex re_compile_pattern -@example -char * -re_compile_pattern (const char *@var{regex}, const int @var{regex_size}, - struct re_pattern_buffer *@var{pattern_buffer}) -@end example - -@noindent -@var{regex} is the regular expression's address, @var{regex_size} is its -length, and @var{pattern_buffer} is the pattern buffer's address. - -If @code{re_compile_pattern} successfully compiles the regular -expression, it returns zero and sets @code{*@var{pattern_buffer}} to the -compiled pattern. It sets the pattern buffer's fields as follows: - -@table @code -@item buffer -@vindex buffer @r{field, set by @code{re_compile_pattern}} -to the compiled pattern. - -@item used -@vindex used @r{field, set by @code{re_compile_pattern}} -to the number of bytes the compiled pattern in @code{buffer} occupies. - -@item syntax -@vindex syntax @r{field, set by @code{re_compile_pattern}} -to the current value of @code{re_syntax_options}. - -@item re_nsub -@vindex re_nsub @r{field, set by @code{re_compile_pattern}} -to the number of subexpressions in @var{regex}. - -@item fastmap_accurate -@vindex fastmap_accurate @r{field, set by @code{re_compile_pattern}} -to zero on the theory that the pattern you're compiling is different -than the one previously compiled into @code{buffer}; in that case (since -you can't make a fastmap without a compiled pattern), -@code{fastmap} would either contain an incompatible fastmap, or nothing -at all. - -@c xx what else? -@end table - -If @code{re_compile_pattern} can't compile @var{regex}, it returns an -error string corresponding to one of the errors listed in @ref{POSIX -Regular Expression Compiling}. - - -@node GNU Matching, GNU Searching, GNU Regular Expression Compiling, GNU Regex Functions -@subsection GNU Matching - -@cindex matching with GNU functions - -Matching the @sc{gnu} way means trying to match as much of a string as -possible starting at a position within it you specify. Once you've compiled -a pattern into a pattern buffer (@pxref{GNU Regular Expression -Compiling}), you can ask the matcher to match that pattern against a -string using: - -@findex re_match -@example -int -re_match (struct re_pattern_buffer *@var{pattern_buffer}, - const char *@var{string}, const int @var{size}, - const int @var{start}, struct re_registers *@var{regs}) -@end example - -@noindent -@var{pattern_buffer} is the address of a pattern buffer containing a -compiled pattern. @var{string} is the string you want to match; it can -contain newline and null characters. @var{size} is the length of that -string. @var{start} is the string index at which you want to -begin matching; the first character of @var{string} is at index zero. -@xref{Using Registers}, for a explanation of @var{regs}; you can safely -pass zero. - -@code{re_match} matches the regular expression in @var{pattern_buffer} -against the string @var{string} according to the syntax in -@var{pattern_buffers}'s @code{syntax} field. (@xref{GNU Regular -Expression Compiling}, for how to set it.) The function returns -@math{-1} if the compiled pattern does not match any part of -@var{string} and @math{-2} if an internal error happens; otherwise, it -returns how many (possibly zero) characters of @var{string} the pattern -matched. - -An example: suppose @var{pattern_buffer} points to a pattern buffer -containing the compiled pattern for @samp{a*}, and @var{string} points -to @samp{aaaaab} (whereupon @var{size} should be 6). Then if @var{start} -is 2, @code{re_match} returns 3, i.e., @samp{a*} would have matched the -last three @samp{a}s in @var{string}. If @var{start} is 0, -@code{re_match} returns 5, i.e., @samp{a*} would have matched all the -@samp{a}s in @var{string}. If @var{start} is either 5 or 6, it returns -zero. - -If @var{start} is not between zero and @var{size}, then -@code{re_match} returns @math{-1}. - - -@node GNU Searching, Matching/Searching with Split Data, GNU Matching, GNU Regex Functions -@subsection GNU Searching - -@cindex searching with GNU functions - -@dfn{Searching} means trying to match starting at successive positions -within a string. The function @code{re_search} does this. - -Before calling @code{re_search}, you must compile your regular -expression. @xref{GNU Regular Expression Compiling}. - -Here is the function declaration: - -@findex re_search -@example -int -re_search (struct re_pattern_buffer *@var{pattern_buffer}, - const char *@var{string}, const int @var{size}, - const int @var{start}, const int @var{range}, - struct re_registers *@var{regs}) -@end example - -@noindent -@vindex start @r{argument to @code{re_search}} -@vindex range @r{argument to @code{re_search}} -whose arguments are the same as those to @code{re_match} (@pxref{GNU -Matching}) except that the two arguments @var{start} and @var{range} -replace @code{re_match}'s argument @var{start}. - -If @var{range} is positive, then @code{re_search} attempts a match -starting first at index @var{start}, then at @math{@var{start} + 1} if -that fails, and so on, up to @math{@var{start} + @var{range}}; if -@var{range} is negative, then it attempts a match starting first at -index @var{start}, then at @math{@var{start} -1} if that fails, and so -on. - -If @var{start} is not between zero and @var{size}, then @code{re_search} -returns @math{-1}. When @var{range} is positive, @code{re_search} -adjusts @var{range} so that @math{@var{start} + @var{range} - 1} is -between zero and @var{size}, if necessary; that way it won't search -outside of @var{string}. Similarly, when @var{range} is negative, -@code{re_search} adjusts @var{range} so that @math{@var{start} + -@var{range} + 1} is between zero and @var{size}, if necessary. - -If the @code{fastmap} field of @var{pattern_buffer} is zero, -@code{re_search} matches starting at consecutive positions; otherwise, -it uses @code{fastmap} to make the search more efficient. -@xref{Searching with Fastmaps}. - -If no match is found, @code{re_search} returns @math{-1}. If -a match is found, it returns the index where the match began. If an -internal error happens, it returns @math{-2}. - - -@node Matching/Searching with Split Data, Searching with Fastmaps, GNU Searching, GNU Regex Functions -@subsection Matching and Searching with Split Data - -Using the functions @code{re_match_2} and @code{re_search_2}, you can -match or search in data that is divided into two strings. - -The function: - -@findex re_match_2 -@example -int -re_match_2 (struct re_pattern_buffer *@var{buffer}, - const char *@var{string1}, const int @var{size1}, - const char *@var{string2}, const int @var{size2}, - const int @var{start}, - struct re_registers *@var{regs}, - const int @var{stop}) -@end example - -@noindent -is similar to @code{re_match} (@pxref{GNU Matching}) except that you -pass @emph{two} data strings and sizes, and an index @var{stop} beyond -which you don't want the matcher to try matching. As with -@code{re_match}, if it succeeds, @code{re_match_2} returns how many -characters of @var{string} it matched. Regard @var{string1} and -@var{string2} as concatenated when you set the arguments @var{start} and -@var{stop} and use the contents of @var{regs}; @code{re_match_2} never -returns a value larger than @math{@var{size1} + @var{size2}}. - -The function: - -@findex re_search_2 -@example -int -re_search_2 (struct re_pattern_buffer *@var{buffer}, - const char *@var{string1}, const int @var{size1}, - const char *@var{string2}, const int @var{size2}, - const int @var{start}, const int @var{range}, - struct re_registers *@var{regs}, - const int @var{stop}) -@end example - -@noindent -is similarly related to @code{re_search}. - - -@node Searching with Fastmaps, GNU Translate Tables, Matching/Searching with Split Data, GNU Regex Functions -@subsection Searching with Fastmaps - -@cindex fastmaps -If you're searching through a long string, you should use a fastmap. -Without one, the searcher tries to match at consecutive positions in the -string. Generally, most of the characters in the string could not start -a match. It takes much longer to try matching at a given position in the -string than it does to check in a table whether or not the character at -that position could start a match. A @dfn{fastmap} is such a table. - -More specifically, a fastmap is an array indexed by the characters in -your character set. Under the @sc{ascii} encoding, therefore, a fastmap -has 256 elements. If you want the searcher to use a fastmap with a -given pattern buffer, you must allocate the array and assign the array's -address to the pattern buffer's @code{fastmap} field. You either can -compile the fastmap yourself or have @code{re_search} do it for you; -when @code{fastmap} is nonzero, it automatically compiles a fastmap the -first time you search using a particular compiled pattern. - -To compile a fastmap yourself, use: - -@findex re_compile_fastmap -@example -int -re_compile_fastmap (struct re_pattern_buffer *@var{pattern_buffer}) -@end example - -@noindent -@var{pattern_buffer} is the address of a pattern buffer. If the -character @var{c} could start a match for the pattern, -@code{re_compile_fastmap} makes -@code{@var{pattern_buffer}->fastmap[@var{c}]} nonzero. It returns -@math{0} if it can compile a fastmap and @math{-2} if there is an -internal error. For example, if @samp{|} is the alternation operator -and @var{pattern_buffer} holds the compiled pattern for @samp{a|b}, then -@code{re_compile_fastmap} sets @code{fastmap['a']} and -@code{fastmap['b']} (and no others). - -@code{re_search} uses a fastmap as it moves along in the string: it -checks the string's characters until it finds one that's in the fastmap. -Then it tries matching at that character. If the match fails, it -repeats the process. So, by using a fastmap, @code{re_search} doesn't -waste time trying to match at positions in the string that couldn't -start a match. - -If you don't want @code{re_search} to use a fastmap, -store zero in the @code{fastmap} field of the pattern buffer before -calling @code{re_search}. - -Once you've initialized a pattern buffer's @code{fastmap} field, you -need never do so again---even if you compile a new pattern in -it---provided the way the field is set still reflects whether or not you -want a fastmap. @code{re_search} will still either do nothing if -@code{fastmap} is null or, if it isn't, compile a new fastmap for the -new pattern. - -@node GNU Translate Tables, Using Registers, Searching with Fastmaps, GNU Regex Functions -@subsection GNU Translate Tables - -If you set the @code{translate} field of a pattern buffer to a translate -table, then the @sc{gnu} Regex functions to which you've passed that -pattern buffer use it to apply a simple transformation -to all the regular expression and string characters at which they look. - -A @dfn{translate table} is an array indexed by the characters in your -character set. Under the @sc{ascii} encoding, therefore, a translate -table has 256 elements. The array's elements are also characters in -your character set. When the Regex functions see a character @var{c}, -they use @code{translate[@var{c}]} in its place, with one exception: the -character after a @samp{\} is not translated. (This ensures that, the -operators, e.g., @samp{\B} and @samp{\b}, are always distinguishable.) - -For example, a table that maps all lowercase letters to the -corresponding uppercase ones would cause the matcher to ignore -differences in case.@footnote{A table that maps all uppercase letters to -the corresponding lowercase ones would work just as well for this -purpose.} Such a table would map all characters except lowercase letters -to themselves, and lowercase letters to the corresponding uppercase -ones. Under the @sc{ascii} encoding, here's how you could initialize -such a table (we'll call it @code{case_fold}): - -@example -for (i = 0; i < 256; i++) - case_fold[i] = i; -for (i = 'a'; i <= 'z'; i++) - case_fold[i] = i - ('a' - 'A'); -@end example - -You tell Regex to use a translate table on a given pattern buffer by -assigning that table's address to the @code{translate} field of that -buffer. If you don't want Regex to do any translation, put zero into -this field. You'll get weird results if you change the table's contents -anytime between compiling the pattern buffer, compiling its fastmap, and -matching or searching with the pattern buffer. - -@node Using Registers, Freeing GNU Pattern Buffers, GNU Translate Tables, GNU Regex Functions -@subsection Using Registers - -A group in a regular expression can match a (posssibly empty) substring -of the string that regular expression as a whole matched. The matcher -remembers the beginning and end of the substring matched by -each group. - -To find out what they matched, pass a nonzero @var{regs} argument to a -@sc{gnu} matching or searching function (@pxref{GNU Matching} and -@ref{GNU Searching}), i.e., the address of a structure of this type, as -defined in @file{regex.h}: - -@c We don't bother to include this directly from regex.h, -@c since it changes so rarely. -@example -@tindex re_registers -@vindex num_regs @r{in @code{struct re_registers}} -@vindex start @r{in @code{struct re_registers}} -@vindex end @r{in @code{struct re_registers}} -struct re_registers -@{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -@}; -@end example - -Except for (possibly) the @var{num_regs}'th element (see below), the -@var{i}th element of the @code{start} and @code{end} arrays records -information about the @var{i}th group in the pattern. (They're declared -as C pointers, but this is only because not all C compilers accept -zero-length arrays; conceptually, it is simplest to think of them as -arrays.) - -The @code{start} and @code{end} arrays are allocated in various ways, -depending on the value of the @code{regs_allocated} -@vindex regs_allocated -field in the pattern buffer passed to the matcher. - -The simplest and perhaps most useful is to let the matcher (re)allocate -enough space to record information for all the groups in the regular -expression. If @code{regs_allocated} is @code{REGS_UNALLOCATED}, -@vindex REGS_UNALLOCATED -the matcher allocates @math{1 + @var{re_nsub}} (another field in the -pattern buffer; @pxref{GNU Pattern Buffers}). The extra element is set -to @math{-1}, and sets @code{regs_allocated} to @code{REGS_REALLOCATE}. -@vindex REGS_REALLOCATE -Then on subsequent calls with the same pattern buffer and @var{regs} -arguments, the matcher reallocates more space if necessary. - -It would perhaps be more logical to make the @code{regs_allocated} field -part of the @code{re_registers} structure, instead of part of the -pattern buffer. But in that case the caller would be forced to -initialize the structure before passing it. Much existing code doesn't -do this initialization, and it's arguably better to avoid it anyway. - -@code{re_compile_pattern} sets @code{regs_allocated} to -@code{REGS_UNALLOCATED}, -so if you use the GNU regular expression -functions, you get this behavior by default. - -xx document re_set_registers - -@sc{posix}, on the other hand, requires a different interface: the -caller is supposed to pass in a fixed-length array which the matcher -fills. Therefore, if @code{regs_allocated} is @code{REGS_FIXED} -@vindex REGS_FIXED -the matcher simply fills that array. - -The following examples illustrate the information recorded in the -@code{re_registers} structure. (In all of them, @samp{(} represents the -open-group and @samp{)} the close-group operator. The first character -in the string @var{string} is at index 0.) - -@c xx i'm not sure this is all true anymore. - -@itemize @bullet - -@item -If the regular expression has an @w{@var{i}-th} -group not contained within another group that matches a -substring of @var{string}, then the function sets -@code{@w{@var{regs}->}start[@var{i}]} to the index in @var{string} where -the substring matched by the @w{@var{i}-th} group begins, and -@code{@w{@var{regs}->}end[@var{i}]} to the index just beyond that -substring's end. The function sets @code{@w{@var{regs}->}start[0]} and -@code{@w{@var{regs}->}end[0]} to analogous information about the entire -pattern. - -For example, when you match @samp{((a)(b))} against @samp{ab}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 2 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 2 in @code{@w{@var{regs}->}end[1]} - -@item -0 in @code{@w{@var{regs}->}start[2]} and 1 in @code{@w{@var{regs}->}end[2]} - -@item -1 in @code{@w{@var{regs}->}start[3]} and 2 in @code{@w{@var{regs}->}end[3]} -@end itemize - -@item -If a group matches more than once (as it might if followed by, -e.g., a repetition operator), then the function reports the information -about what the group @emph{last} matched. - -For example, when you match the pattern @samp{(a)*} against the string -@samp{aa}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 2 in @code{@w{@var{regs}->}end[0]} - -@item -1 in @code{@w{@var{regs}->}start[1]} and 2 in @code{@w{@var{regs}->}end[1]} -@end itemize - -@item -If the @w{@var{i}-th} group does not participate in a -successful match, e.g., it is an alternative not taken or a -repetition operator allows zero repetitions of it, then the function -sets @code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to @math{-1}. - -For example, when you match the pattern @samp{(a)*b} against -the string @samp{b}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[1]} and @math{-1} in @code{@w{@var{regs}->}end[1]} -@end itemize - -@item -If the @w{@var{i}-th} group matches a zero-length string, then the -function sets @code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to the index just beyond that -zero-length string. - -For example, when you match the pattern @samp{(a*)b} against the string -@samp{b}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 0 in @code{@w{@var{regs}->}end[1]} -@end itemize - -@ignore -The function sets @code{@w{@var{regs}->}start[0]} and -@code{@w{@var{regs}->}end[0]} to analogous information about the entire -pattern. - -For example, when you match the pattern @samp{(a*)} against the empty -string, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 0 in @code{@w{@var{regs}->}end[0]} - -@item -0 in @code{@w{@var{regs}->}start[1]} and 0 in @code{@w{@var{regs}->}end[1]} -@end itemize -@end ignore - -@item -If an @w{@var{i}-th} group contains a @w{@var{j}-th} group -in turn not contained within any other group within group @var{i} and -the function reports a match of the @w{@var{i}-th} group, then it -records in @code{@w{@var{regs}->}start[@var{j}]} and -@code{@w{@var{regs}->}end[@var{j}]} the last match (if it matched) of -the @w{@var{j}-th} group. - -For example, when you match the pattern @samp{((a*)b)*} against the -string @samp{abb}, @w{group 2} last matches the empty string, so you -get what it previously matched: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 3 in @code{@w{@var{regs}->}end[0]} - -@item -2 in @code{@w{@var{regs}->}start[1]} and 3 in @code{@w{@var{regs}->}end[1]} - -@item -2 in @code{@w{@var{regs}->}start[2]} and 2 in @code{@w{@var{regs}->}end[2]} -@end itemize - -When you match the pattern @samp{((a)*b)*} against the string -@samp{abb}, @w{group 2} doesn't participate in the last match, so you -get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 3 in @code{@w{@var{regs}->}end[0]} - -@item -2 in @code{@w{@var{regs}->}start[1]} and 3 in @code{@w{@var{regs}->}end[1]} - -@item -0 in @code{@w{@var{regs}->}start[2]} and 1 in @code{@w{@var{regs}->}end[2]} -@end itemize - -@item -If an @w{@var{i}-th} group contains a @w{@var{j}-th} group -in turn not contained within any other group within group @var{i} -and the function sets -@code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{regs}->}end[@var{i}]} to @math{-1}, then it also sets -@code{@w{@var{regs}->}start[@var{j}]} and -@code{@w{@var{regs}->}end[@var{j}]} to @math{-1}. - -For example, when you match the pattern @samp{((a)*b)*c} against the -string @samp{c}, you get: - -@itemize -@item -0 in @code{@w{@var{regs}->}start[0]} and 1 in @code{@w{@var{regs}->}end[0]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[1]} and @math{-1} in @code{@w{@var{regs}->}end[1]} - -@item -@math{-1} in @code{@w{@var{regs}->}start[2]} and @math{-1} in @code{@w{@var{regs}->}end[2]} -@end itemize - -@end itemize - -@node Freeing GNU Pattern Buffers, , Using Registers, GNU Regex Functions -@subsection Freeing GNU Pattern Buffers - -To free any allocated fields of a pattern buffer, you can use the -@sc{posix} function described in @ref{Freeing POSIX Pattern Buffers}, -since the type @code{regex_t}---the type for @sc{posix} pattern -buffers---is equivalent to the type @code{re_pattern_buffer}. After -freeing a pattern buffer, you need to again compile a regular expression -in it (@pxref{GNU Regular Expression Compiling}) before passing it to -a matching or searching function. - - -@node POSIX Regex Functions, BSD Regex Functions, GNU Regex Functions, Programming with Regex -@section POSIX Regex Functions - -If you're writing code that has to be @sc{posix} compatible, you'll need -to use these functions. Their interfaces are as specified by @sc{posix}, -draft 1003.2/D11.2. - -@menu -* POSIX Pattern Buffers:: The regex_t type. -* POSIX Regular Expression Compiling:: regcomp () -* POSIX Matching:: regexec () -* Reporting Errors:: regerror () -* Using Byte Offsets:: The regmatch_t type. -* Freeing POSIX Pattern Buffers:: regfree () -@end menu - - -@node POSIX Pattern Buffers, POSIX Regular Expression Compiling, , POSIX Regex Functions -@subsection POSIX Pattern Buffers - -To compile or match a given regular expression the @sc{posix} way, you -must supply a pattern buffer exactly the way you do for @sc{gnu} -(@pxref{GNU Pattern Buffers}). @sc{posix} pattern buffers have type -@code{regex_t}, which is equivalent to the @sc{gnu} pattern buffer -type @code{re_pattern_buffer}. - - -@node POSIX Regular Expression Compiling, POSIX Matching, POSIX Pattern Buffers, POSIX Regex Functions -@subsection POSIX Regular Expression Compiling - -With @sc{posix}, you can only search for a given regular expression; you -can't match it. To do this, you must first compile it in a -pattern buffer, using @code{regcomp}. - -@ignore -Before calling @code{regcomp}, you must initialize this pattern buffer -as you do for @sc{gnu} (@pxref{GNU Regular Expression Compiling}). See -below, however, for how to choose a syntax with which to compile. -@end ignore - -To compile a pattern buffer, use: - -@findex regcomp -@example -int -regcomp (regex_t *@var{preg}, const char *@var{regex}, int @var{cflags}) -@end example - -@noindent -@var{preg} is the initialized pattern buffer's address, @var{regex} is -the regular expression's address, and @var{cflags} is the compilation -flags, which Regex considers as a collection of bits. Here are the -valid bits, as defined in @file{regex.h}: - -@table @code - -@item REG_EXTENDED -@vindex REG_EXTENDED -says to use @sc{posix} Extended Regular Expression syntax; if this isn't -set, then says to use @sc{posix} Basic Regular Expression syntax. -@code{regcomp} sets @var{preg}'s @code{syntax} field accordingly. - -@item REG_ICASE -@vindex REG_ICASE -@cindex ignoring case -says to ignore case; @code{regcomp} sets @var{preg}'s @code{translate} -field to a translate table which ignores case, replacing anything you've -put there before. - -@item REG_NOSUB -@vindex REG_NOSUB -says to set @var{preg}'s @code{no_sub} field; @pxref{POSIX Matching}, -for what this means. - -@item REG_NEWLINE -@vindex REG_NEWLINE -says that a: - -@itemize @bullet - -@item -match-any-character operator (@pxref{Match-any-character -Operator}) doesn't match a newline. - -@item -nonmatching list not containing a newline (@pxref{List -Operators}) matches a newline. - -@item -match-beginning-of-line operator (@pxref{Match-beginning-of-line -Operator}) matches the empty string immediately after a newline, -regardless of how @code{REG_NOTBOL} is set (@pxref{POSIX Matching}, for -an explanation of @code{REG_NOTBOL}). - -@item -match-end-of-line operator (@pxref{Match-beginning-of-line -Operator}) matches the empty string immediately before a newline, -regardless of how @code{REG_NOTEOL} is set (@pxref{POSIX Matching}, -for an explanation of @code{REG_NOTEOL}). - -@end itemize - -@end table - -If @code{regcomp} successfully compiles the regular expression, it -returns zero and sets @code{*@var{pattern_buffer}} to the compiled -pattern. Except for @code{syntax} (which it sets as explained above), it -also sets the same fields the same way as does the @sc{gnu} compiling -function (@pxref{GNU Regular Expression Compiling}). - -If @code{regcomp} can't compile the regular expression, it returns one -of the error codes listed here. (Except when noted differently, the -syntax of in all examples below is basic regular expression syntax.) - -@table @code - -@comment repetitions -@item REG_BADRPT -For example, the consecutive repetition operators @samp{**} in -@samp{a**} are invalid. As another example, if the syntax is extended -regular expression syntax, then the repetition operator @samp{*} with -nothing on which to operate in @samp{*} is invalid. - -@item REG_BADBR -For example, the @var{count} @samp{-1} in @samp{a\@{-1} is invalid. - -@item REG_EBRACE -For example, @samp{a\@{1} is missing a close-interval operator. - -@comment lists -@item REG_EBRACK -For example, @samp{[a} is missing a close-list operator. - -@item REG_ERANGE -For example, the range ending point @samp{z} that collates lower than -does its starting point @samp{a} in @samp{[z-a]} is invalid. Also, the -range with the character class @samp{[:alpha:]} as its starting point in -@samp{[[:alpha:]-|]}. - -@item REG_ECTYPE -For example, the character class name @samp{foo} in @samp{[[:foo:]} is -invalid. - -@comment groups -@item REG_EPAREN -For example, @samp{a\)} is missing an open-group operator and @samp{\(a} -is missing a close-group operator. - -@item REG_ESUBREG -For example, the back reference @samp{\2} that refers to a nonexistent -subexpression in @samp{\(a\)\2} is invalid. - -@comment unfinished business - -@item REG_EEND -Returned when a regular expression causes no other more specific error. - -@item REG_EESCAPE -For example, the trailing backslash @samp{\} in @samp{a\} is invalid, as is the -one in @samp{\}. - -@comment kitchen sink -@item REG_BADPAT -For example, in the extended regular expression syntax, the empty group -@samp{()} in @samp{a()b} is invalid. - -@comment internal -@item REG_ESIZE -Returned when a regular expression needs a pattern buffer larger than -65536 bytes. - -@item REG_ESPACE -Returned when a regular expression makes Regex to run out of memory. - -@end table - - -@node POSIX Matching, Reporting Errors, POSIX Regular Expression Compiling, POSIX Regex Functions -@subsection POSIX Matching - -Matching the @sc{posix} way means trying to match a null-terminated -string starting at its first character. Once you've compiled a pattern -into a pattern buffer (@pxref{POSIX Regular Expression Compiling}), you -can ask the matcher to match that pattern against a string using: - -@findex regexec -@example -int -regexec (const regex_t *@var{preg}, const char *@var{string}, - size_t @var{nmatch}, regmatch_t @var{pmatch}[], int @var{eflags}) -@end example - -@noindent -@var{preg} is the address of a pattern buffer for a compiled pattern. -@var{string} is the string you want to match. - -@xref{Using Byte Offsets}, for an explanation of @var{pmatch}. If you -pass zero for @var{nmatch} or you compiled @var{preg} with the -compilation flag @code{REG_NOSUB} set, then @code{regexec} will ignore -@var{pmatch}; otherwise, you must allocate it to have at least -@var{nmatch} elements. @code{regexec} will record @var{nmatch} byte -offsets in @var{pmatch}, and set to @math{-1} any unused elements up to -@math{@var{pmatch}@code{[@var{nmatch}]} - 1}. - -@var{eflags} specifies @dfn{execution flags}---namely, the two bits -@code{REG_NOTBOL} and @code{REG_NOTEOL} (defined in @file{regex.h}). If -you set @code{REG_NOTBOL}, then the match-beginning-of-line operator -(@pxref{Match-beginning-of-line Operator}) always fails to match. -This lets you match against pieces of a line, as you would need to if, -say, searching for repeated instances of a given pattern in a line; it -would work correctly for patterns both with and without -match-beginning-of-line operators. @code{REG_NOTEOL} works analogously -for the match-end-of-line operator (@pxref{Match-end-of-line -Operator}); it exists for symmetry. - -@code{regexec} tries to find a match for @var{preg} in @var{string} -according to the syntax in @var{preg}'s @code{syntax} field. -(@xref{POSIX Regular Expression Compiling}, for how to set it.) The -function returns zero if the compiled pattern matches @var{string} and -@code{REG_NOMATCH} (defined in @file{regex.h}) if it doesn't. - -@node Reporting Errors, Using Byte Offsets, POSIX Matching, POSIX Regex Functions -@subsection Reporting Errors - -If either @code{regcomp} or @code{regexec} fail, they return a nonzero -error code, the possibilities for which are defined in @file{regex.h}. -@xref{POSIX Regular Expression Compiling}, and @ref{POSIX Matching}, for -what these codes mean. To get an error string corresponding to these -codes, you can use: - -@findex regerror -@example -size_t -regerror (int @var{errcode}, - const regex_t *@var{preg}, - char *@var{errbuf}, - size_t @var{errbuf_size}) -@end example - -@noindent -@var{errcode} is an error code, @var{preg} is the address of the pattern -buffer which provoked the error, @var{errbuf} is the error buffer, and -@var{errbuf_size} is @var{errbuf}'s size. - -@code{regerror} returns the size in bytes of the error string -corresponding to @var{errcode} (including its terminating null). If -@var{errbuf} and @var{errbuf_size} are nonzero, it also returns in -@var{errbuf} the first @math{@var{errbuf_size} - 1} characters of the -error string, followed by a null. -@var{errbuf_size} must be a nonnegative number less than or equal to the -size in bytes of @var{errbuf}. - -You can call @code{regerror} with a null @var{errbuf} and a zero -@var{errbuf_size} to determine how large @var{errbuf} need be to -accommodate @code{regerror}'s error string. - -@node Using Byte Offsets, Freeing POSIX Pattern Buffers, Reporting Errors, POSIX Regex Functions -@subsection Using Byte Offsets - -In @sc{posix}, variables of type @code{regmatch_t} hold analogous -information, but are not identical to, @sc{gnu}'s registers (@pxref{Using -Registers}). To get information about registers in @sc{posix}, pass to -@code{regexec} a nonzero @var{pmatch} of type @code{regmatch_t}, i.e., -the address of a structure of this type, defined in -@file{regex.h}: - -@tindex regmatch_t -@example -typedef struct -@{ - regoff_t rm_so; - regoff_t rm_eo; -@} regmatch_t; -@end example - -When reading in @ref{Using Registers}, about how the matching function -stores the information into the registers, substitute @var{pmatch} for -@var{regs}, @code{@w{@var{pmatch}[@var{i}]->}rm_so} for -@code{@w{@var{regs}->}start[@var{i}]} and -@code{@w{@var{pmatch}[@var{i}]->}rm_eo} for -@code{@w{@var{regs}->}end[@var{i}]}. - -@node Freeing POSIX Pattern Buffers, , Using Byte Offsets, POSIX Regex Functions -@subsection Freeing POSIX Pattern Buffers - -To free any allocated fields of a pattern buffer, use: - -@findex regfree -@example -void -regfree (regex_t *@var{preg}) -@end example - -@noindent -@var{preg} is the pattern buffer whose allocated fields you want freed. -@code{regfree} also sets @var{preg}'s @code{allocated} and @code{used} -fields to zero. After freeing a pattern buffer, you need to again -compile a regular expression in it (@pxref{POSIX Regular Expression -Compiling}) before passing it to the matching function (@pxref{POSIX -Matching}). - - -@node BSD Regex Functions, , POSIX Regex Functions, Programming with Regex -@section BSD Regex Functions - -If you're writing code that has to be Berkeley @sc{unix} compatible, -you'll need to use these functions whose interfaces are the same as those -in Berkeley @sc{unix}. - -@menu -* BSD Regular Expression Compiling:: re_comp () -* BSD Searching:: re_exec () -@end menu - -@node BSD Regular Expression Compiling, BSD Searching, , BSD Regex Functions -@subsection BSD Regular Expression Compiling - -With Berkeley @sc{unix}, you can only search for a given regular -expression; you can't match one. To search for it, you must first -compile it. Before you compile it, you must indicate the regular -expression syntax you want it compiled according to by setting the -variable @code{re_syntax_options} (declared in @file{regex.h} to some -syntax (@pxref{Regular Expression Syntax}). - -To compile a regular expression use: - -@findex re_comp -@example -char * -re_comp (char *@var{regex}) -@end example - -@noindent -@var{regex} is the address of a null-terminated regular expression. -@code{re_comp} uses an internal pattern buffer, so you can use only the -most recently compiled pattern buffer. This means that if you want to -use a given regular expression that you've already compiled---but it -isn't the latest one you've compiled---you'll have to recompile it. If -you call @code{re_comp} with the null string (@emph{not} the empty -string) as the argument, it doesn't change the contents of the pattern -buffer. - -If @code{re_comp} successfully compiles the regular expression, it -returns zero. If it can't compile the regular expression, it returns -an error string. @code{re_comp}'s error messages are identical to those -of @code{re_compile_pattern} (@pxref{GNU Regular Expression -Compiling}). - -@node BSD Searching, , BSD Regular Expression Compiling, BSD Regex Functions -@subsection BSD Searching - -Searching the Berkeley @sc{unix} way means searching in a string -starting at its first character and trying successive positions within -it to find a match. Once you've compiled a pattern using @code{re_comp} -(@pxref{BSD Regular Expression Compiling}), you can ask Regex -to search for that pattern in a string using: - -@findex re_exec -@example -int -re_exec (char *@var{string}) -@end example - -@noindent -@var{string} is the address of the null-terminated string in which you -want to search. - -@code{re_exec} returns either 1 for success or 0 for failure. It -automatically uses a @sc{gnu} fastmap (@pxref{Searching with Fastmaps}). - - -@node Copying, Index, Programming with Regex, Top -@appendix GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 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. -@end display - -@unnumberedsec 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. - -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -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. - -@item -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. - -@item -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: - -@enumerate a -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -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. - -@item -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.) -@end enumerate - -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. - -@item -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: - -@enumerate a -@item -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, - -@item -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, - -@item -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.) -@end enumerate - -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -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. - -@item -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 enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec 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. - -@smallexample -@var{one line to give the program's name and a brief idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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. -@end smallexample - -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: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{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. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{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: - -@example -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end example - -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. - - -@node Index, , Copying, Top -@unnumbered Index - -@printindex cp - -@contents - -@bye diff --git a/gnu/lib/regex-0.12/regex.c b/gnu/lib/regex-0.12/regex.c deleted file mode 100644 index 8169880d7e4f..000000000000 --- a/gnu/lib/regex-0.12/regex.c +++ /dev/null @@ -1,4948 +0,0 @@ -/* Extended regular expression matching and search library, - version 0.12. - (Implements POSIX draft P10003.2/D11.2, except for - internationalization features.) - - Copyright (C) 1993 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. */ - -/* AIX requires this to be the first thing in the file. */ -#if defined (_AIX) && !defined (REGEX_MALLOC) - #pragma alloca -#endif - -#define _GNU_SOURCE - -/* We need this for `regex.h', and perhaps for the Emacs include files. */ -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* The `emacs' switch turns on certain matching commands - that make sense only in Emacs. */ -#ifdef emacs - -#include "lisp.h" -#include "buffer.h" -#include "syntax.h" - -/* Emacs uses `NULL' as a predicate. */ -#undef NULL - -#else /* not emacs */ - -/* We used to test for `BSTRING' here, but only GCC and Emacs define - `BSTRING', as far as I know, and neither of them use this code. */ -#if HAVE_STRING_H || STDC_HEADERS -#include -#ifndef bcmp -#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) -#endif -#ifndef bcopy -#define bcopy(s, d, n) memcpy ((d), (s), (n)) -#endif -#ifndef bzero -#define bzero(s, n) memset ((s), 0, (n)) -#endif -#else -#include -#endif - -#ifdef STDC_HEADERS -#include -#else -char *malloc (); -char *realloc (); -#endif - - -/* Define the syntax stuff for \<, \>, etc. */ - -/* This must be nonzero for the wordchar and notwordchar pattern - commands in re_match_2. */ -#ifndef Sword -#define Sword 1 -#endif - -#ifdef SYNTAX_TABLE - -extern char *re_syntax_table; - -#else /* not SYNTAX_TABLE */ - -/* How many characters in the character set. */ -#define CHAR_SET_SIZE 256 - -static char re_syntax_table[CHAR_SET_SIZE]; - -static void -init_syntax_once () -{ - register int c; - static int done = 0; - - if (done) - return; - - bzero (re_syntax_table, sizeof re_syntax_table); - - for (c = 'a'; c <= 'z'; c++) - re_syntax_table[c] = Sword; - - for (c = 'A'; c <= 'Z'; c++) - re_syntax_table[c] = Sword; - - for (c = '0'; c <= '9'; c++) - re_syntax_table[c] = Sword; - - re_syntax_table['_'] = Sword; - - done = 1; -} - -#endif /* not SYNTAX_TABLE */ - -#define SYNTAX(c) re_syntax_table[c] - -#endif /* not emacs */ - -/* Get the interface, including the syntax bits. */ -#include "regex.h" - -/* isalpha etc. are used for the character classes. */ -#include - -#ifndef isascii -#define isascii(c) 1 -#endif - -#ifdef isblank -#define ISBLANK(c) (isascii (c) && isblank (c)) -#else -#define ISBLANK(c) ((c) == ' ' || (c) == '\t') -#endif -#ifdef isgraph -#define ISGRAPH(c) (isascii (c) && isgraph (c)) -#else -#define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c)) -#endif - -#define ISPRINT(c) (isascii (c) && isprint (c)) -#define ISDIGIT(c) (isascii (c) && isdigit (c)) -#define ISALNUM(c) (isascii (c) && isalnum (c)) -#define ISALPHA(c) (isascii (c) && isalpha (c)) -#define ISCNTRL(c) (isascii (c) && iscntrl (c)) -#define ISLOWER(c) (isascii (c) && islower (c)) -#define ISPUNCT(c) (isascii (c) && ispunct (c)) -#define ISSPACE(c) (isascii (c) && isspace (c)) -#define ISUPPER(c) (isascii (c) && isupper (c)) -#define ISXDIGIT(c) (isascii (c) && isxdigit (c)) - -#ifndef NULL -#define NULL 0 -#endif - -/* We remove any previous definition of `SIGN_EXTEND_CHAR', - since ours (we hope) works properly with all combinations of - machines, compilers, `char' and `unsigned char' argument types. - (Per Bothner suggested the basic approach.) */ -#undef SIGN_EXTEND_CHAR -#if __STDC__ -#define SIGN_EXTEND_CHAR(c) ((signed char) (c)) -#else /* not __STDC__ */ -/* As in Harbison and Steele. */ -#define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) -#endif - -/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we - use `alloca' instead of `malloc'. This is because using malloc in - re_search* or re_match* could cause memory leaks when C-g is used in - Emacs; also, malloc is slower and causes storage fragmentation. On - the other hand, malloc is more portable, and easier to debug. - - Because we sometimes use alloca, some routines have to be macros, - not functions -- `alloca'-allocated space disappears at the end of the - function it is called in. */ - -#ifdef REGEX_MALLOC - -#define REGEX_ALLOCATE malloc -#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) - -#else /* not REGEX_MALLOC */ - -/* Emacs already defines alloca, sometimes. */ -#ifndef alloca - -/* Make alloca work the best possible way. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if HAVE_ALLOCA_H -#include -#else /* not __GNUC__ or HAVE_ALLOCA_H */ -#ifndef _AIX /* Already did AIX, up at the top. */ -char *alloca (); -#endif /* not _AIX */ -#endif /* not HAVE_ALLOCA_H */ -#endif /* not __GNUC__ */ - -#endif /* not alloca */ - -#define REGEX_ALLOCATE alloca - -/* Assumes a `char *destination' variable. */ -#define REGEX_REALLOCATE(source, osize, nsize) \ - (destination = (char *) alloca (nsize), \ - bcopy (source, destination, osize), \ - destination) - -#endif /* not REGEX_MALLOC */ - - -/* True if `size1' is non-NULL and PTR is pointing anywhere inside - `string1' or just past its end. This works if PTR is NULL, which is - a good thing. */ -#define FIRST_STRING_P(ptr) \ - (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) - -/* (Re)Allocate N items of type T using malloc, or fail. */ -#define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) -#define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) -#define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) - -#define BYTEWIDTH 8 /* In bits. */ - -#define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) - -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -typedef char boolean; -#define false 0 -#define true 1 - -/* These are the command codes that appear in compiled regular - expressions. Some opcodes are followed by argument bytes. A - command code can specify any interpretation whatsoever for its - arguments. Zero bytes may appear in the compiled regular expression. - - The value of `exactn' is needed in search.c (search_buffer) in Emacs. - So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of - `exactn' we use here must also be 1. */ - -typedef enum -{ - no_op = 0, - - /* Followed by one byte giving n, then by n literal bytes. */ - exactn = 1, - - /* Matches any (more or less) character. */ - anychar, - - /* Matches any one char belonging to specified set. First - following byte is number of bitmap bytes. Then come bytes - for a bitmap saying which chars are in. Bits in each byte - are ordered low-bit-first. A character is in the set if its - bit is 1. A character too large to have a bit in the map is - automatically not in the set. */ - charset, - - /* Same parameters as charset, but match any character that is - not one of those specified. */ - charset_not, - - /* Start remembering the text that is matched, for storing in a - register. Followed by one byte with the register number, in - the range 0 to one less than the pattern buffer's re_nsub - field. Then followed by one byte with the number of groups - inner to this one. (This last has to be part of the - start_memory only because we need it in the on_failure_jump - of re_match_2.) */ - start_memory, - - /* Stop remembering the text that is matched and store it in a - memory register. Followed by one byte with the register - number, in the range 0 to one less than `re_nsub' in the - pattern buffer, and one byte with the number of inner groups, - just like `start_memory'. (We need the number of inner - groups here because we don't have any easy way of finding the - corresponding start_memory when we're at a stop_memory.) */ - stop_memory, - - /* Match a duplicate of something remembered. Followed by one - byte containing the register number. */ - duplicate, - - /* Fail unless at beginning of line. */ - begline, - - /* Fail unless at end of line. */ - endline, - - /* Succeeds if at beginning of buffer (if emacs) or at beginning - of string to be matched (if not). */ - begbuf, - - /* Analogously, for end of buffer/string. */ - endbuf, - - /* Followed by two byte relative address to which to jump. */ - jump, - - /* Same as jump, but marks the end of an alternative. */ - jump_past_alt, - - /* Followed by two-byte relative address of place to resume at - in case of failure. */ - on_failure_jump, - - /* Like on_failure_jump, but pushes a placeholder instead of the - current string position when executed. */ - on_failure_keep_string_jump, - - /* Throw away latest failure point and then jump to following - two-byte relative address. */ - pop_failure_jump, - - /* Change to pop_failure_jump if know won't have to backtrack to - match; otherwise change to jump. This is used to jump - back to the beginning of a repeat. If what follows this jump - clearly won't match what the repeat does, such that we can be - sure that there is no use backtracking out of repetitions - already matched, then we change it to a pop_failure_jump. - Followed by two-byte address. */ - maybe_pop_jump, - - /* Jump to following two-byte address, and push a dummy failure - point. This failure point will be thrown away if an attempt - is made to use it for a failure. A `+' construct makes this - before the first repeat. Also used as an intermediary kind - of jump when compiling an alternative. */ - dummy_failure_jump, - - /* Push a dummy failure point and continue. Used at the end of - alternatives. */ - push_dummy_failure, - - /* Followed by two-byte relative address and two-byte number n. - After matching N times, jump to the address upon failure. */ - succeed_n, - - /* Followed by two-byte relative address, and two-byte number n. - Jump to the address N times, then fail. */ - jump_n, - - /* Set the following two-byte relative address to the - subsequent two-byte number. The address *includes* the two - bytes of number. */ - set_number_at, - - wordchar, /* Matches any word-constituent character. */ - notwordchar, /* Matches any char that is not a word-constituent. */ - - wordbeg, /* Succeeds if at word beginning. */ - wordend, /* Succeeds if at word end. */ - - wordbound, /* Succeeds if at a word boundary. */ - notwordbound /* Succeeds if not at a word boundary. */ - -#ifdef emacs - ,before_dot, /* Succeeds if before point. */ - at_dot, /* Succeeds if at point. */ - after_dot, /* Succeeds if after point. */ - - /* Matches any character whose syntax is specified. Followed by - a byte which contains a syntax code, e.g., Sword. */ - syntaxspec, - - /* Matches any character whose syntax is not that specified. */ - notsyntaxspec -#endif /* emacs */ -} re_opcode_t; - -/* Common operations on the compiled pattern. */ - -/* Store NUMBER in two contiguous bytes starting at DESTINATION. */ - -#define STORE_NUMBER(destination, number) \ - do { \ - (destination)[0] = (number) & 0377; \ - (destination)[1] = (number) >> 8; \ - } while (0) - -/* Same as STORE_NUMBER, except increment DESTINATION to - the byte after where the number is stored. Therefore, DESTINATION - must be an lvalue. */ - -#define STORE_NUMBER_AND_INCR(destination, number) \ - do { \ - STORE_NUMBER (destination, number); \ - (destination) += 2; \ - } while (0) - -/* Put into DESTINATION a number stored in two contiguous bytes starting - at SOURCE. */ - -#define EXTRACT_NUMBER(destination, source) \ - do { \ - (destination) = *(source) & 0377; \ - (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \ - } while (0) - -#ifdef DEBUG -static void -extract_number (dest, source) - int *dest; - unsigned char *source; -{ - int temp = SIGN_EXTEND_CHAR (*(source + 1)); - *dest = *source & 0377; - *dest += temp << 8; -} - -#ifndef EXTRACT_MACROS /* To debug the macros. */ -#undef EXTRACT_NUMBER -#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) -#endif /* not EXTRACT_MACROS */ - -#endif /* DEBUG */ - -/* Same as EXTRACT_NUMBER, except increment SOURCE to after the number. - SOURCE must be an lvalue. */ - -#define EXTRACT_NUMBER_AND_INCR(destination, source) \ - do { \ - EXTRACT_NUMBER (destination, source); \ - (source) += 2; \ - } while (0) - -#ifdef DEBUG -static void -extract_number_and_incr (destination, source) - int *destination; - unsigned char **source; -{ - extract_number (destination, *source); - *source += 2; -} - -#ifndef EXTRACT_MACROS -#undef EXTRACT_NUMBER_AND_INCR -#define EXTRACT_NUMBER_AND_INCR(dest, src) \ - extract_number_and_incr (&dest, &src) -#endif /* not EXTRACT_MACROS */ - -#endif /* DEBUG */ - -/* If DEBUG is defined, Regex prints many voluminous messages about what - it is doing (if the variable `debug' is nonzero). If linked with the - main program in `iregex.c', you can enter patterns and strings - interactively. And if linked with the main program in `main.c' and - the other test files, you can run the already-written tests. */ - -#ifdef DEBUG - -/* We use standard I/O for debugging. */ -#include - -/* It is useful to test things that ``must'' be true when debugging. */ -#include - -static int debug = 0; - -#define DEBUG_STATEMENT(e) e -#define DEBUG_PRINT1(x) if (debug) printf (x) -#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) -#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) -#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ - if (debug) print_partial_compiled_pattern (s, e) -#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ - if (debug) print_double_string (w, s1, sz1, s2, sz2) - - -extern void printchar (); - -/* Print the fastmap in human-readable form. */ - -void -print_fastmap (fastmap) - char *fastmap; -{ - unsigned was_a_range = 0; - unsigned i = 0; - - while (i < (1 << BYTEWIDTH)) - { - if (fastmap[i++]) - { - was_a_range = 0; - printchar (i - 1); - while (i < (1 << BYTEWIDTH) && fastmap[i]) - { - was_a_range = 1; - i++; - } - if (was_a_range) - { - printf ("-"); - printchar (i - 1); - } - } - } - putchar ('\n'); -} - - -/* Print a compiled pattern string in human-readable form, starting at - the START pointer into it and ending just before the pointer END. */ - -void -print_partial_compiled_pattern (start, end) - unsigned char *start; - unsigned char *end; -{ - int mcnt, mcnt2; - unsigned char *p = start; - unsigned char *pend = end; - - if (start == NULL) - { - printf ("(null)\n"); - return; - } - - /* Loop over pattern commands. */ - while (p < pend) - { - switch ((re_opcode_t) *p++) - { - case no_op: - printf ("/no_op"); - break; - - case exactn: - mcnt = *p++; - printf ("/exactn/%d", mcnt); - do - { - putchar ('/'); - printchar (*p++); - } - while (--mcnt); - break; - - case start_memory: - mcnt = *p++; - printf ("/start_memory/%d/%d", mcnt, *p++); - break; - - case stop_memory: - mcnt = *p++; - printf ("/stop_memory/%d/%d", mcnt, *p++); - break; - - case duplicate: - printf ("/duplicate/%d", *p++); - break; - - case anychar: - printf ("/anychar"); - break; - - case charset: - case charset_not: - { - register int c; - - printf ("/charset%s", - (re_opcode_t) *(p - 1) == charset_not ? "_not" : ""); - - assert (p + *p < pend); - - for (c = 0; c < *p; c++) - { - unsigned bit; - unsigned char map_byte = p[1 + c]; - - putchar ('/'); - - for (bit = 0; bit < BYTEWIDTH; bit++) - if (map_byte & (1 << bit)) - printchar (c * BYTEWIDTH + bit); - } - p += 1 + *p; - break; - } - - case begline: - printf ("/begline"); - break; - - case endline: - printf ("/endline"); - break; - - case on_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/on_failure_jump/0/%d", mcnt); - break; - - case on_failure_keep_string_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/on_failure_keep_string_jump/0/%d", mcnt); - break; - - case dummy_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/dummy_failure_jump/0/%d", mcnt); - break; - - case push_dummy_failure: - printf ("/push_dummy_failure"); - break; - - case maybe_pop_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/maybe_pop_jump/0/%d", mcnt); - break; - - case pop_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/pop_failure_jump/0/%d", mcnt); - break; - - case jump_past_alt: - extract_number_and_incr (&mcnt, &p); - printf ("/jump_past_alt/0/%d", mcnt); - break; - - case jump: - extract_number_and_incr (&mcnt, &p); - printf ("/jump/0/%d", mcnt); - break; - - case succeed_n: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/succeed_n/0/%d/0/%d", mcnt, mcnt2); - break; - - case jump_n: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/jump_n/0/%d/0/%d", mcnt, mcnt2); - break; - - case set_number_at: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/set_number_at/0/%d/0/%d", mcnt, mcnt2); - break; - - case wordbound: - printf ("/wordbound"); - break; - - case notwordbound: - printf ("/notwordbound"); - break; - - case wordbeg: - printf ("/wordbeg"); - break; - - case wordend: - printf ("/wordend"); - -#ifdef emacs - case before_dot: - printf ("/before_dot"); - break; - - case at_dot: - printf ("/at_dot"); - break; - - case after_dot: - printf ("/after_dot"); - break; - - case syntaxspec: - printf ("/syntaxspec"); - mcnt = *p++; - printf ("/%d", mcnt); - break; - - case notsyntaxspec: - printf ("/notsyntaxspec"); - mcnt = *p++; - printf ("/%d", mcnt); - break; -#endif /* emacs */ - - case wordchar: - printf ("/wordchar"); - break; - - case notwordchar: - printf ("/notwordchar"); - break; - - case begbuf: - printf ("/begbuf"); - break; - - case endbuf: - printf ("/endbuf"); - break; - - default: - printf ("?%d", *(p-1)); - } - } - printf ("/\n"); -} - - -void -print_compiled_pattern (bufp) - struct re_pattern_buffer *bufp; -{ - unsigned char *buffer = bufp->buffer; - - print_partial_compiled_pattern (buffer, buffer + bufp->used); - printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated); - - if (bufp->fastmap_accurate && bufp->fastmap) - { - printf ("fastmap: "); - print_fastmap (bufp->fastmap); - } - - printf ("re_nsub: %d\t", bufp->re_nsub); - printf ("regs_alloc: %d\t", bufp->regs_allocated); - printf ("can_be_null: %d\t", bufp->can_be_null); - printf ("newline_anchor: %d\n", bufp->newline_anchor); - printf ("no_sub: %d\t", bufp->no_sub); - printf ("not_bol: %d\t", bufp->not_bol); - printf ("not_eol: %d\t", bufp->not_eol); - printf ("syntax: %d\n", bufp->syntax); - /* Perhaps we should print the translate table? */ -} - - -void -print_double_string (where, string1, size1, string2, size2) - const char *where; - const char *string1; - const char *string2; - int size1; - int size2; -{ - unsigned this_char; - - if (where == NULL) - printf ("(null)"); - else - { - if (FIRST_STRING_P (where)) - { - for (this_char = where - string1; this_char < size1; this_char++) - printchar (string1[this_char]); - - where = string2; - } - - for (this_char = where - string2; this_char < size2; this_char++) - printchar (string2[this_char]); - } -} - -#else /* not DEBUG */ - -#undef assert -#define assert(e) - -#define DEBUG_STATEMENT(e) -#define DEBUG_PRINT1(x) -#define DEBUG_PRINT2(x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) -#define DEBUG_PRINT4(x1, x2, x3, x4) -#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) -#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) - -#endif /* not DEBUG */ - -/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can - also be assigned to arbitrarily: each pattern buffer stores its own - syntax, so it can be changed between regex compilations. */ -reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; - - -/* Specify the precise syntax of regexps for compilation. This provides - for compatibility for various utilities which historically have - different, incompatible syntaxes. - - The argument SYNTAX is a bit mask comprised of the various bits - defined in regex.h. We return the old syntax. */ - -reg_syntax_t -re_set_syntax (syntax) - reg_syntax_t syntax; -{ - reg_syntax_t ret = re_syntax_options; - - re_syntax_options = syntax; - return ret; -} - -/* This table gives an error message for each of the error codes listed - in regex.h. Obviously the order here has to be same as there. */ - -static const char *re_error_msg[] = - { NULL, /* REG_NOERROR */ - "No match", /* REG_NOMATCH */ - "Invalid regular expression", /* REG_BADPAT */ - "Invalid collation character", /* REG_ECOLLATE */ - "Invalid character class name", /* REG_ECTYPE */ - "Trailing backslash", /* REG_EESCAPE */ - "Invalid back reference", /* REG_ESUBREG */ - "Unmatched [ or [^", /* REG_EBRACK */ - "Unmatched ( or \\(", /* REG_EPAREN */ - "Unmatched \\{", /* REG_EBRACE */ - "Invalid content of \\{\\}", /* REG_BADBR */ - "Invalid range end", /* REG_ERANGE */ - "Memory exhausted", /* REG_ESPACE */ - "Invalid preceding regular expression", /* REG_BADRPT */ - "Premature end of regular expression", /* REG_EEND */ - "Regular expression too big", /* REG_ESIZE */ - "Unmatched ) or \\)", /* REG_ERPAREN */ - }; - -/* Subroutine declarations and macros for regex_compile. */ - -static void store_op1 (), store_op2 (); -static void insert_op1 (), insert_op2 (); -static boolean at_begline_loc_p (), at_endline_loc_p (); -static boolean group_in_compile_stack (); -static reg_errcode_t compile_range (); - -/* Fetch the next character in the uncompiled pattern---translating it - if necessary. Also cast from a signed character in the constant - string passed to us by the user to an unsigned char that we can use - as an array index (in, e.g., `translate'). */ -#define PATFETCH(c) \ - do {if (p == pend) return REG_EEND; \ - c = (unsigned char) *p++; \ - if (translate) c = translate[c]; \ - } while (0) - -/* Fetch the next character in the uncompiled pattern, with no - translation. */ -#define PATFETCH_RAW(c) \ - do {if (p == pend) return REG_EEND; \ - c = (unsigned char) *p++; \ - } while (0) - -/* Go backwards one character in the pattern. */ -#define PATUNFETCH p-- - - -/* If `translate' is non-null, return translate[D], else just D. We - cast the subscript to translate because some data is declared as - `char *', to avoid warnings when a string constant is passed. But - when we use a character as a subscript we must make it unsigned. */ -#define TRANSLATE(d) (translate ? translate[(unsigned char) (d)] : (d)) - - -/* Macros for outputting the compiled pattern into `buffer'. */ - -/* If the buffer isn't allocated when it comes in, use this. */ -#define INIT_BUF_SIZE 32 - -/* Make sure we have at least N more bytes of space in buffer. */ -#define GET_BUFFER_SPACE(n) \ - while (b - bufp->buffer + (n) > bufp->allocated) \ - EXTEND_BUFFER () - -/* Make sure we have one more byte of buffer space and then add C to it. */ -#define BUF_PUSH(c) \ - do { \ - GET_BUFFER_SPACE (1); \ - *b++ = (unsigned char) (c); \ - } while (0) - - -/* Ensure we have two more bytes of buffer space and then append C1 and C2. */ -#define BUF_PUSH_2(c1, c2) \ - do { \ - GET_BUFFER_SPACE (2); \ - *b++ = (unsigned char) (c1); \ - *b++ = (unsigned char) (c2); \ - } while (0) - - -/* As with BUF_PUSH_2, except for three bytes. */ -#define BUF_PUSH_3(c1, c2, c3) \ - do { \ - GET_BUFFER_SPACE (3); \ - *b++ = (unsigned char) (c1); \ - *b++ = (unsigned char) (c2); \ - *b++ = (unsigned char) (c3); \ - } while (0) - - -/* Store a jump with opcode OP at LOC to location TO. We store a - relative address offset by the three bytes the jump itself occupies. */ -#define STORE_JUMP(op, loc, to) \ - store_op1 (op, loc, (to) - (loc) - 3) - -/* Likewise, for a two-argument jump. */ -#define STORE_JUMP2(op, loc, to, arg) \ - store_op2 (op, loc, (to) - (loc) - 3, arg) - -/* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */ -#define INSERT_JUMP(op, loc, to) \ - insert_op1 (op, loc, (to) - (loc) - 3, b) - -/* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */ -#define INSERT_JUMP2(op, loc, to, arg) \ - insert_op2 (op, loc, (to) - (loc) - 3, arg, b) - - -/* This is not an arbitrary limit: the arguments which represent offsets - into the pattern are two bytes long. So if 2^16 bytes turns out to - be too small, many things would have to change. */ -#define MAX_BUF_SIZE (1L << 16) - - -/* Extend the buffer by twice its current size via realloc and - reset the pointers that pointed into the old block to point to the - correct places in the new one. If extending the buffer results in it - being larger than MAX_BUF_SIZE, then flag memory exhausted. */ -#define EXTEND_BUFFER() \ - do { \ - unsigned char *old_buffer = bufp->buffer; \ - if (bufp->allocated == MAX_BUF_SIZE) \ - return REG_ESIZE; \ - bufp->allocated <<= 1; \ - if (bufp->allocated > MAX_BUF_SIZE) \ - bufp->allocated = MAX_BUF_SIZE; \ - bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\ - if (bufp->buffer == NULL) \ - return REG_ESPACE; \ - /* If the buffer moved, move all the pointers into it. */ \ - if (old_buffer != bufp->buffer) \ - { \ - b = (b - old_buffer) + bufp->buffer; \ - begalt = (begalt - old_buffer) + bufp->buffer; \ - if (fixup_alt_jump) \ - fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\ - if (laststart) \ - laststart = (laststart - old_buffer) + bufp->buffer; \ - if (pending_exact) \ - pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ - } \ - } while (0) - - -/* Since we have one byte reserved for the register number argument to - {start,stop}_memory, the maximum number of groups we can report - things about is what fits in that byte. */ -#define MAX_REGNUM 255 - -/* But patterns can have more than `MAX_REGNUM' registers. We just - ignore the excess. */ -typedef unsigned regnum_t; - - -/* Macros for the compile stack. */ - -/* Since offsets can go either forwards or backwards, this type needs to - be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ -typedef int pattern_offset_t; - -typedef struct -{ - pattern_offset_t begalt_offset; - pattern_offset_t fixup_alt_jump; - pattern_offset_t inner_group_offset; - pattern_offset_t laststart_offset; - regnum_t regnum; -} compile_stack_elt_t; - - -typedef struct -{ - compile_stack_elt_t *stack; - unsigned size; - unsigned avail; /* Offset of next open position. */ -} compile_stack_type; - - -#define INIT_COMPILE_STACK_SIZE 32 - -#define COMPILE_STACK_EMPTY (compile_stack.avail == 0) -#define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) - -/* The next available element. */ -#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) - - -/* Set the bit for character C in a list. */ -#define SET_LIST_BIT(c) \ - (b[((unsigned char) (c)) / BYTEWIDTH] \ - |= 1 << (((unsigned char) c) % BYTEWIDTH)) - - -/* Get the next unsigned number in the uncompiled pattern. */ -#define GET_UNSIGNED_NUMBER(num) \ - { if (p != pend) \ - { \ - PATFETCH (c); \ - while (ISDIGIT (c)) \ - { \ - if (num < 0) \ - num = 0; \ - num = num * 10 + c - '0'; \ - if (p == pend) \ - break; \ - PATFETCH (c); \ - } \ - } \ - } - -#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ - -#define IS_CHAR_CLASS(string) \ - (STREQ (string, "alpha") || STREQ (string, "upper") \ - || STREQ (string, "lower") || STREQ (string, "digit") \ - || STREQ (string, "alnum") || STREQ (string, "xdigit") \ - || STREQ (string, "space") || STREQ (string, "print") \ - || STREQ (string, "punct") || STREQ (string, "graph") \ - || STREQ (string, "cntrl") || STREQ (string, "blank")) - -/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. - Returns one of error codes defined in `regex.h', or zero for success. - - Assumes the `allocated' (and perhaps `buffer') and `translate' - fields are set in BUFP on entry. - - If it succeeds, results are put in BUFP (if it returns an error, the - contents of BUFP are undefined): - `buffer' is the compiled pattern; - `syntax' is set to SYNTAX; - `used' is set to the length of the compiled pattern; - `fastmap_accurate' is zero; - `re_nsub' is the number of subexpressions in PATTERN; - `not_bol' and `not_eol' are zero; - - The `fastmap' and `newline_anchor' fields are neither - examined nor set. */ - -static reg_errcode_t -regex_compile (pattern, size, syntax, bufp) - const char *pattern; - int size; - reg_syntax_t syntax; - struct re_pattern_buffer *bufp; -{ - /* We fetch characters from PATTERN here. Even though PATTERN is - `char *' (i.e., signed), we declare these variables as unsigned, so - they can be reliably used as array indices. */ - register unsigned char c, c1; - - /* A random tempory spot in PATTERN. */ - const char *p1; - - /* Points to the end of the buffer, where we should append. */ - register unsigned char *b; - - /* Keeps track of unclosed groups. */ - compile_stack_type compile_stack; - - /* Points to the current (ending) position in the pattern. */ - const char *p = pattern; - const char *pend = pattern + size; - - /* How to translate the characters in the pattern. */ - char *translate = bufp->translate; - - /* Address of the count-byte of the most recently inserted `exactn' - command. This makes it possible to tell if a new exact-match - character can be added to that command or if the character requires - a new `exactn' command. */ - unsigned char *pending_exact = 0; - - /* Address of start of the most recently finished expression. - This tells, e.g., postfix * where to find the start of its - operand. Reset at the beginning of groups and alternatives. */ - unsigned char *laststart = 0; - - /* Address of beginning of regexp, or inside of last group. */ - unsigned char *begalt; - - /* Place in the uncompiled pattern (i.e., the {) to - which to go back if the interval is invalid. */ - const char *beg_interval; - - /* Address of the place where a forward jump should go to the end of - the containing expression. Each alternative of an `or' -- except the - last -- ends with a forward jump of this sort. */ - unsigned char *fixup_alt_jump = 0; - - /* Counts open-groups as they are encountered. Remembered for the - matching close-group on the compile stack, so the same register - number is put in the stop_memory as the start_memory. */ - regnum_t regnum = 0; - -#ifdef DEBUG - DEBUG_PRINT1 ("\nCompiling pattern: "); - if (debug) - { - unsigned debug_count; - - for (debug_count = 0; debug_count < size; debug_count++) - printchar (pattern[debug_count]); - putchar ('\n'); - } -#endif /* DEBUG */ - - /* Initialize the compile stack. */ - compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); - if (compile_stack.stack == NULL) - return REG_ESPACE; - - compile_stack.size = INIT_COMPILE_STACK_SIZE; - compile_stack.avail = 0; - - /* Initialize the pattern buffer. */ - bufp->syntax = syntax; - bufp->fastmap_accurate = 0; - bufp->not_bol = bufp->not_eol = 0; - - /* Set `used' to zero, so that if we return an error, the pattern - printer (for debugging) will think there's no pattern. We reset it - at the end. */ - bufp->used = 0; - - /* Always count groups, whether or not bufp->no_sub is set. */ - bufp->re_nsub = 0; - -#if !defined (emacs) && !defined (SYNTAX_TABLE) - /* Initialize the syntax table. */ - init_syntax_once (); -#endif - - if (bufp->allocated == 0) - { - if (bufp->buffer) - { /* If zero allocated, but buffer is non-null, try to realloc - enough space. This loses if buffer's address is bogus, but - that is the user's responsibility. */ - RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); - } - else - { /* Caller did not allocate a buffer. Do it for them. */ - bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); - } - if (!bufp->buffer) return REG_ESPACE; - - bufp->allocated = INIT_BUF_SIZE; - } - - begalt = b = bufp->buffer; - - /* Loop through the uncompiled pattern until we're at the end. */ - while (p != pend) - { - PATFETCH (c); - - switch (c) - { - case '^': - { - if ( /* If at start of pattern, it's an operator. */ - p == pattern + 1 - /* If context independent, it's an operator. */ - || syntax & RE_CONTEXT_INDEP_ANCHORS - /* Otherwise, depends on what's come before. */ - || at_begline_loc_p (pattern, p, syntax)) - BUF_PUSH (begline); - else - goto normal_char; - } - break; - - - case '$': - { - if ( /* If at end of pattern, it's an operator. */ - p == pend - /* If context independent, it's an operator. */ - || syntax & RE_CONTEXT_INDEP_ANCHORS - /* Otherwise, depends on what's next. */ - || at_endline_loc_p (p, pend, syntax)) - BUF_PUSH (endline); - else - goto normal_char; - } - break; - - - case '+': - case '?': - if ((syntax & RE_BK_PLUS_QM) - || (syntax & RE_LIMITED_OPS)) - goto normal_char; - handle_plus: - case '*': - /* If there is no previous pattern... */ - if (!laststart) - { - if (syntax & RE_CONTEXT_INVALID_OPS) - return REG_BADRPT; - else if (!(syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - } - - { - /* Are we optimizing this jump? */ - boolean keep_string_p = false; - - /* 1 means zero (many) matches is allowed. */ - char zero_times_ok = 0, many_times_ok = 0; - - /* If there is a sequence of repetition chars, collapse it - down to just one (the right one). We can't combine - interval operators with these because of, e.g., `a{2}*', - which should only match an even number of `a's. */ - - for (;;) - { - zero_times_ok |= c != '+'; - many_times_ok |= c != '?'; - - if (p == pend) - break; - - PATFETCH (c); - - if (c == '*' - || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?'))) - ; - - else if (syntax & RE_BK_PLUS_QM && c == '\\') - { - if (p == pend) return REG_EESCAPE; - - PATFETCH (c1); - if (!(c1 == '+' || c1 == '?')) - { - PATUNFETCH; - PATUNFETCH; - break; - } - - c = c1; - } - else - { - PATUNFETCH; - break; - } - - /* If we get here, we found another repeat character. */ - } - - /* Star, etc. applied to an empty pattern is equivalent - to an empty pattern. */ - if (!laststart) - break; - - /* Now we know whether or not zero matches is allowed - and also whether or not two or more matches is allowed. */ - if (many_times_ok) - { /* More than one repetition is allowed, so put in at the - end a backward relative jump from `b' to before the next - jump we're going to put in below (which jumps from - laststart to after this jump). - - But if we are at the `*' in the exact sequence `.*\n', - insert an unconditional jump backwards to the ., - instead of the beginning of the loop. This way we only - push a failure point once, instead of every time - through the loop. */ - assert (p - 1 > pattern); - - /* Allocate the space for the jump. */ - GET_BUFFER_SPACE (3); - - /* We know we are not at the first character of the pattern, - because laststart was nonzero. And we've already - incremented `p', by the way, to be the character after - the `*'. Do we have to do something analogous here - for null bytes, because of RE_DOT_NOT_NULL? */ - if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') - && zero_times_ok - && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') - && !(syntax & RE_DOT_NEWLINE)) - { /* We have .*\n. */ - STORE_JUMP (jump, b, laststart); - keep_string_p = true; - } - else - /* Anything else. */ - STORE_JUMP (maybe_pop_jump, b, laststart - 3); - - /* We've added more stuff to the buffer. */ - b += 3; - } - - /* On failure, jump from laststart to b + 3, which will be the - end of the buffer after this jump is inserted. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump - : on_failure_jump, - laststart, b + 3); - pending_exact = 0; - b += 3; - - if (!zero_times_ok) - { - /* At least one repetition is required, so insert a - `dummy_failure_jump' before the initial - `on_failure_jump' instruction of the loop. This - effects a skip over that instruction the first time - we hit that loop. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); - b += 3; - } - } - break; - - - case '.': - laststart = b; - BUF_PUSH (anychar); - break; - - - case '[': - { - boolean had_char_class = false; - - if (p == pend) return REG_EBRACK; - - /* Ensure that we have enough space to push a charset: the - opcode, the length count, and the bitset; 34 bytes in all. */ - GET_BUFFER_SPACE (34); - - laststart = b; - - /* We test `*p == '^' twice, instead of using an if - statement, so we only need one BUF_PUSH. */ - BUF_PUSH (*p == '^' ? charset_not : charset); - if (*p == '^') - p++; - - /* Remember the first position in the bracket expression. */ - p1 = p; - - /* Push the number of bytes in the bitmap. */ - BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); - - /* Clear the whole map. */ - bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); - - /* charset_not matches newline according to a syntax bit. */ - if ((re_opcode_t) b[-2] == charset_not - && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) - SET_LIST_BIT ('\n'); - - /* Read in characters and ranges, setting map bits. */ - for (;;) - { - if (p == pend) return REG_EBRACK; - - PATFETCH (c); - - /* \ might escape characters inside [...] and [^...]. */ - if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') - { - if (p == pend) return REG_EESCAPE; - - PATFETCH (c1); - SET_LIST_BIT (c1); - continue; - } - - /* Could be the end of the bracket expression. If it's - not (i.e., when the bracket expression is `[]' so - far), the ']' character bit gets set way below. */ - if (c == ']' && p != p1 + 1) - break; - - /* Look ahead to see if it's a range when the last thing - was a character class. */ - if (had_char_class && c == '-' && *p != ']') - return REG_ERANGE; - - /* Look ahead to see if it's a range when the last thing - was a character: if this is a hyphen not at the - beginning or the end of a list, then it's the range - operator. */ - if (c == '-' - && !(p - 2 >= pattern && p[-2] == '[') - && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') - && *p != ']') - { - reg_errcode_t ret - = compile_range (&p, pend, translate, syntax, b); - if (ret != REG_NOERROR) return ret; - } - - else if (p[0] == '-' && p[1] != ']') - { /* This handles ranges made up of characters only. */ - reg_errcode_t ret; - - /* Move past the `-'. */ - PATFETCH (c1); - - ret = compile_range (&p, pend, translate, syntax, b); - if (ret != REG_NOERROR) return ret; - } - - /* See if we're at the beginning of a possible character - class. */ - - else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') - { /* Leave room for the null. */ - char str[CHAR_CLASS_MAX_LENGTH + 1]; - - PATFETCH (c); - c1 = 0; - - /* If pattern is `[[:'. */ - if (p == pend) return REG_EBRACK; - - for (;;) - { - PATFETCH (c); - if (c == ':' || c == ']' || p == pend - || c1 == CHAR_CLASS_MAX_LENGTH) - break; - str[c1++] = c; - } - str[c1] = '\0'; - - /* If isn't a word bracketed by `[:' and:`]': - undo the ending character, the letters, and leave - the leading `:' and `[' (but set bits for them). */ - if (c == ':' && *p == ']') - { - int ch; - boolean is_alnum = STREQ (str, "alnum"); - boolean is_alpha = STREQ (str, "alpha"); - boolean is_blank = STREQ (str, "blank"); - boolean is_cntrl = STREQ (str, "cntrl"); - boolean is_digit = STREQ (str, "digit"); - boolean is_graph = STREQ (str, "graph"); - boolean is_lower = STREQ (str, "lower"); - boolean is_print = STREQ (str, "print"); - boolean is_punct = STREQ (str, "punct"); - boolean is_space = STREQ (str, "space"); - boolean is_upper = STREQ (str, "upper"); - boolean is_xdigit = STREQ (str, "xdigit"); - - if (!IS_CHAR_CLASS (str)) return REG_ECTYPE; - - /* Throw away the ] at the end of the character - class. */ - PATFETCH (c); - - if (p == pend) return REG_EBRACK; - - for (ch = 0; ch < 1 << BYTEWIDTH; ch++) - { - if ( (is_alnum && ISALNUM (ch)) - || (is_alpha && ISALPHA (ch)) - || (is_blank && ISBLANK (ch)) - || (is_cntrl && ISCNTRL (ch)) - || (is_digit && ISDIGIT (ch)) - || (is_graph && ISGRAPH (ch)) - || (is_lower && ISLOWER (ch)) - || (is_print && ISPRINT (ch)) - || (is_punct && ISPUNCT (ch)) - || (is_space && ISSPACE (ch)) - || (is_upper && ISUPPER (ch)) - || (is_xdigit && ISXDIGIT (ch))) - SET_LIST_BIT (ch); - } - had_char_class = true; - } - else - { - c1++; - while (c1--) - PATUNFETCH; - SET_LIST_BIT ('['); - SET_LIST_BIT (':'); - had_char_class = false; - } - } - else - { - had_char_class = false; - SET_LIST_BIT (c); - } - } - - /* Discard any (non)matching list bytes that are all 0 at the - end of the map. Decrease the map-length byte too. */ - while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) - b[-1]--; - b += b[-1]; - } - break; - - - case '(': - if (syntax & RE_NO_BK_PARENS) - goto handle_open; - else - goto normal_char; - - - case ')': - if (syntax & RE_NO_BK_PARENS) - goto handle_close; - else - goto normal_char; - - - case '\n': - if (syntax & RE_NEWLINE_ALT) - goto handle_alt; - else - goto normal_char; - - - case '|': - if (syntax & RE_NO_BK_VBAR) - goto handle_alt; - else - goto normal_char; - - - case '{': - if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) - goto handle_interval; - else - goto normal_char; - - - case '\\': - if (p == pend) return REG_EESCAPE; - - /* Do not translate the character after the \, so that we can - distinguish, e.g., \B from \b, even if we normally would - translate, e.g., B to b. */ - PATFETCH_RAW (c); - - switch (c) - { - case '(': - if (syntax & RE_NO_BK_PARENS) - goto normal_backslash; - - handle_open: - bufp->re_nsub++; - regnum++; - - if (COMPILE_STACK_FULL) - { - RETALLOC (compile_stack.stack, compile_stack.size << 1, - compile_stack_elt_t); - if (compile_stack.stack == NULL) return REG_ESPACE; - - compile_stack.size <<= 1; - } - - /* These are the values to restore when we hit end of this - group. They are all relative offsets, so that if the - whole pattern moves because of realloc, they will still - be valid. */ - COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; - COMPILE_STACK_TOP.fixup_alt_jump - = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; - COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer; - COMPILE_STACK_TOP.regnum = regnum; - - /* We will eventually replace the 0 with the number of - groups inner to this one. But do not push a - start_memory for groups beyond the last one we can - represent in the compiled pattern. */ - if (regnum <= MAX_REGNUM) - { - COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2; - BUF_PUSH_3 (start_memory, regnum, 0); - } - - compile_stack.avail++; - - fixup_alt_jump = 0; - laststart = 0; - begalt = b; - /* If we've reached MAX_REGNUM groups, then this open - won't actually generate any code, so we'll have to - clear pending_exact explicitly. */ - pending_exact = 0; - break; - - - case ')': - if (syntax & RE_NO_BK_PARENS) goto normal_backslash; - - if (COMPILE_STACK_EMPTY) - if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) - goto normal_backslash; - else - return REG_ERPAREN; - - handle_close: - if (fixup_alt_jump) - { /* Push a dummy failure point at the end of the - alternative for a possible future - `pop_failure_jump' to pop. See comments at - `push_dummy_failure' in `re_match_2'. */ - BUF_PUSH (push_dummy_failure); - - /* We allocated space for this jump when we assigned - to `fixup_alt_jump', in the `handle_alt' case below. */ - STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1); - } - - /* See similar code for backslashed left paren above. */ - if (COMPILE_STACK_EMPTY) - if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) - goto normal_char; - else - return REG_ERPAREN; - - /* Since we just checked for an empty stack above, this - ``can't happen''. */ - assert (compile_stack.avail != 0); - { - /* We don't just want to restore into `regnum', because - later groups should continue to be numbered higher, - as in `(ab)c(de)' -- the second group is #2. */ - regnum_t this_group_regnum; - - compile_stack.avail--; - begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; - fixup_alt_jump - = COMPILE_STACK_TOP.fixup_alt_jump - ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 - : 0; - laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; - this_group_regnum = COMPILE_STACK_TOP.regnum; - /* If we've reached MAX_REGNUM groups, then this open - won't actually generate any code, so we'll have to - clear pending_exact explicitly. */ - pending_exact = 0; - - /* We're at the end of the group, so now we know how many - groups were inside this one. */ - if (this_group_regnum <= MAX_REGNUM) - { - unsigned char *inner_group_loc - = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; - - *inner_group_loc = regnum - this_group_regnum; - BUF_PUSH_3 (stop_memory, this_group_regnum, - regnum - this_group_regnum); - } - } - break; - - - case '|': /* `\|'. */ - if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) - goto normal_backslash; - handle_alt: - if (syntax & RE_LIMITED_OPS) - goto normal_char; - - /* Insert before the previous alternative a jump which - jumps to this alternative if the former fails. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (on_failure_jump, begalt, b + 6); - pending_exact = 0; - b += 3; - - /* The alternative before this one has a jump after it - which gets executed if it gets matched. Adjust that - jump so it will jump to this alternative's analogous - jump (put in below, which in turn will jump to the next - (if any) alternative's such jump, etc.). The last such - jump jumps to the correct final destination. A picture: - _____ _____ - | | | | - | v | v - a | b | c - - If we are at `b', then fixup_alt_jump right now points to a - three-byte space after `a'. We'll put in the jump, set - fixup_alt_jump to right after `b', and leave behind three - bytes which we'll fill in when we get to after `c'. */ - - if (fixup_alt_jump) - STORE_JUMP (jump_past_alt, fixup_alt_jump, b); - - /* Mark and leave space for a jump after this alternative, - to be filled in later either by next alternative or - when know we're at the end of a series of alternatives. */ - fixup_alt_jump = b; - GET_BUFFER_SPACE (3); - b += 3; - - laststart = 0; - begalt = b; - break; - - - case '{': - /* If \{ is a literal. */ - if (!(syntax & RE_INTERVALS) - /* If we're at `\{' and it's not the open-interval - operator. */ - || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) - || (p - 2 == pattern && p == pend)) - goto normal_backslash; - - handle_interval: - { - /* If got here, then the syntax allows intervals. */ - - /* At least (most) this many matches must be made. */ - int lower_bound = -1, upper_bound = -1; - - beg_interval = p - 1; - - if (p == pend) - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_EBRACE; - } - - GET_UNSIGNED_NUMBER (lower_bound); - - if (c == ',') - { - GET_UNSIGNED_NUMBER (upper_bound); - if (upper_bound < 0) upper_bound = RE_DUP_MAX; - } - else - /* Interval such as `{1}' => match exactly once. */ - upper_bound = lower_bound; - - if (lower_bound < 0 || upper_bound > RE_DUP_MAX - || lower_bound > upper_bound) - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_BADBR; - } - - if (!(syntax & RE_NO_BK_BRACES)) - { - if (c != '\\') return REG_EBRACE; - - PATFETCH (c); - } - - if (c != '}') - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_BADBR; - } - - /* We just parsed a valid interval. */ - - /* If it's invalid to have no preceding re. */ - if (!laststart) - { - if (syntax & RE_CONTEXT_INVALID_OPS) - return REG_BADRPT; - else if (syntax & RE_CONTEXT_INDEP_OPS) - laststart = b; - else - goto unfetch_interval; - } - - /* If the upper bound is zero, don't want to succeed at - all; jump from `laststart' to `b + 3', which will be - the end of the buffer after we insert the jump. */ - if (upper_bound == 0) - { - GET_BUFFER_SPACE (3); - INSERT_JUMP (jump, laststart, b + 3); - b += 3; - } - - /* Otherwise, we have a nontrivial interval. When - we're all done, the pattern will look like: - set_number_at - set_number_at - succeed_n - - jump_n - (The upper bound and `jump_n' are omitted if - `upper_bound' is 1, though.) */ - else - { /* If the upper bound is > 1, we need to insert - more at the end of the loop. */ - unsigned nbytes = 10 + (upper_bound > 1) * 10; - - GET_BUFFER_SPACE (nbytes); - - /* Initialize lower bound of the `succeed_n', even - though it will be set during matching by its - attendant `set_number_at' (inserted next), - because `re_compile_fastmap' needs to know. - Jump to the `jump_n' we might insert below. */ - INSERT_JUMP2 (succeed_n, laststart, - b + 5 + (upper_bound > 1) * 5, - lower_bound); - b += 5; - - /* Code to initialize the lower bound. Insert - before the `succeed_n'. The `5' is the last two - bytes of this `set_number_at', plus 3 bytes of - the following `succeed_n'. */ - insert_op2 (set_number_at, laststart, 5, lower_bound, b); - b += 5; - - if (upper_bound > 1) - { /* More than one repetition is allowed, so - append a backward jump to the `succeed_n' - that starts this interval. - - When we've reached this during matching, - we'll have matched the interval once, so - jump back only `upper_bound - 1' times. */ - STORE_JUMP2 (jump_n, b, laststart + 5, - upper_bound - 1); - b += 5; - - /* The location we want to set is the second - parameter of the `jump_n'; that is `b-2' as - an absolute address. `laststart' will be - the `set_number_at' we're about to insert; - `laststart+3' the number to set, the source - for the relative address. But we are - inserting into the middle of the pattern -- - so everything is getting moved up by 5. - Conclusion: (b - 2) - (laststart + 3) + 5, - i.e., b - laststart. - - We insert this at the beginning of the loop - so that if we fail during matching, we'll - reinitialize the bounds. */ - insert_op2 (set_number_at, laststart, b - laststart, - upper_bound - 1, b); - b += 5; - } - } - pending_exact = 0; - beg_interval = NULL; - } - break; - - unfetch_interval: - /* If an invalid interval, match the characters as literals. */ - assert (beg_interval); - p = beg_interval; - beg_interval = NULL; - - /* normal_char and normal_backslash need `c'. */ - PATFETCH (c); - - if (!(syntax & RE_NO_BK_BRACES)) - { - if (p > pattern && p[-1] == '\\') - goto normal_backslash; - } - goto normal_char; - -#ifdef emacs - /* There is no way to specify the before_dot and after_dot - operators. rms says this is ok. --karl */ - case '=': - BUF_PUSH (at_dot); - break; - - case 's': - laststart = b; - PATFETCH (c); - BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); - break; - - case 'S': - laststart = b; - PATFETCH (c); - BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); - break; -#endif /* emacs */ - - - case 'w': - laststart = b; - BUF_PUSH (wordchar); - break; - - - case 'W': - laststart = b; - BUF_PUSH (notwordchar); - break; - - - case '<': - BUF_PUSH (wordbeg); - break; - - case '>': - BUF_PUSH (wordend); - break; - - case 'b': - BUF_PUSH (wordbound); - break; - - case 'B': - BUF_PUSH (notwordbound); - break; - - case '`': - BUF_PUSH (begbuf); - break; - - case '\'': - BUF_PUSH (endbuf); - break; - - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - if (syntax & RE_NO_BK_REFS) - goto normal_char; - - c1 = c - '0'; - - if (c1 > regnum) - return REG_ESUBREG; - - /* Can't back reference to a subexpression if inside of it. */ - if (group_in_compile_stack (compile_stack, c1)) - goto normal_char; - - laststart = b; - BUF_PUSH_2 (duplicate, c1); - break; - - - case '+': - case '?': - if (syntax & RE_BK_PLUS_QM) - goto handle_plus; - else - goto normal_backslash; - - default: - normal_backslash: - /* You might think it would be useful for \ to mean - not to translate; but if we don't translate it - it will never match anything. */ - c = TRANSLATE (c); - goto normal_char; - } - break; - - - default: - /* Expects the character in `c'. */ - normal_char: - /* If no exactn currently being built. */ - if (!pending_exact - - /* If last exactn not at current position. */ - || pending_exact + *pending_exact + 1 != b - - /* We have only one byte following the exactn for the count. */ - || *pending_exact == (1 << BYTEWIDTH) - 1 - - /* If followed by a repetition operator. */ - || *p == '*' || *p == '^' - || ((syntax & RE_BK_PLUS_QM) - ? *p == '\\' && (p[1] == '+' || p[1] == '?') - : (*p == '+' || *p == '?')) - || ((syntax & RE_INTERVALS) - && ((syntax & RE_NO_BK_BRACES) - ? *p == '{' - : (p[0] == '\\' && p[1] == '{')))) - { - /* Start building a new exactn. */ - - laststart = b; - - BUF_PUSH_2 (exactn, 0); - pending_exact = b - 1; - } - - BUF_PUSH (c); - (*pending_exact)++; - break; - } /* switch (c) */ - } /* while p != pend */ - - - /* Through the pattern now. */ - - if (fixup_alt_jump) - STORE_JUMP (jump_past_alt, fixup_alt_jump, b); - - if (!COMPILE_STACK_EMPTY) - return REG_EPAREN; - - free (compile_stack.stack); - - /* We have succeeded; set the length of the buffer. */ - bufp->used = b - bufp->buffer; - -#ifdef DEBUG - if (debug) - { - DEBUG_PRINT1 ("\nCompiled pattern: "); - print_compiled_pattern (bufp); - } -#endif /* DEBUG */ - - return REG_NOERROR; -} /* regex_compile */ - -/* Subroutines for `regex_compile'. */ - -/* Store OP at LOC followed by two-byte integer parameter ARG. */ - -static void -store_op1 (op, loc, arg) - re_opcode_t op; - unsigned char *loc; - int arg; -{ - *loc = (unsigned char) op; - STORE_NUMBER (loc + 1, arg); -} - - -/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ - -static void -store_op2 (op, loc, arg1, arg2) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; -{ - *loc = (unsigned char) op; - STORE_NUMBER (loc + 1, arg1); - STORE_NUMBER (loc + 3, arg2); -} - - -/* Copy the bytes from LOC to END to open up three bytes of space at LOC - for OP followed by two-byte integer parameter ARG. */ - -static void -insert_op1 (op, loc, arg, end) - re_opcode_t op; - unsigned char *loc; - int arg; - unsigned char *end; -{ - register unsigned char *pfrom = end; - register unsigned char *pto = end + 3; - - while (pfrom != loc) - *--pto = *--pfrom; - - store_op1 (op, loc, arg); -} - - -/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ - -static void -insert_op2 (op, loc, arg1, arg2, end) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; - unsigned char *end; -{ - register unsigned char *pfrom = end; - register unsigned char *pto = end + 5; - - while (pfrom != loc) - *--pto = *--pfrom; - - store_op2 (op, loc, arg1, arg2); -} - - -/* P points to just after a ^ in PATTERN. Return true if that ^ comes - after an alternative or a begin-subexpression. We assume there is at - least one character before the ^. */ - -static boolean -at_begline_loc_p (pattern, p, syntax) - const char *pattern, *p; - reg_syntax_t syntax; -{ - const char *prev = p - 2; - boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; - - return - /* After a subexpression? */ - (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) - /* After an alternative? */ - || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); -} - - -/* The dual of at_begline_loc_p. This one is for $. We assume there is - at least one character after the $, i.e., `P < PEND'. */ - -static boolean -at_endline_loc_p (p, pend, syntax) - const char *p, *pend; - int syntax; -{ - const char *next = p; - boolean next_backslash = *next == '\\'; - const char *next_next = p + 1 < pend ? p + 1 : NULL; - - return - /* Before a subexpression? */ - (syntax & RE_NO_BK_PARENS ? *next == ')' - : next_backslash && next_next && *next_next == ')') - /* Before an alternative? */ - || (syntax & RE_NO_BK_VBAR ? *next == '|' - : next_backslash && next_next && *next_next == '|'); -} - - -/* Returns true if REGNUM is in one of COMPILE_STACK's elements and - false if it's not. */ - -static boolean -group_in_compile_stack (compile_stack, regnum) - compile_stack_type compile_stack; - regnum_t regnum; -{ - int this_element; - - for (this_element = compile_stack.avail - 1; - this_element >= 0; - this_element--) - if (compile_stack.stack[this_element].regnum == regnum) - return true; - - return false; -} - - -/* Read the ending character of a range (in a bracket expression) from the - uncompiled pattern *P_PTR (which ends at PEND). We assume the - starting character is in `P[-2]'. (`P[-1]' is the character `-'.) - Then we set the translation of all bits between the starting and - ending characters (inclusive) in the compiled pattern B. - - Return an error code. - - We use these short variable names so we can use the same macros as - `regex_compile' itself. */ - -static reg_errcode_t -compile_range (p_ptr, pend, translate, syntax, b) - const char **p_ptr, *pend; - char *translate; - reg_syntax_t syntax; - unsigned char *b; -{ - unsigned this_char; - - const char *p = *p_ptr; - int range_start, range_end; - - if (p == pend) - return REG_ERANGE; - - /* Even though the pattern is a signed `char *', we need to fetch - with unsigned char *'s; if the high bit of the pattern character - is set, the range endpoints will be negative if we fetch using a - signed char *. - - We also want to fetch the endpoints without translating them; the - appropriate translation is done in the bit-setting loop below. */ - range_start = ((unsigned char *) p)[-2]; - range_end = ((unsigned char *) p)[0]; - - /* Have to increment the pointer into the pattern string, so the - caller isn't still at the ending character. */ - (*p_ptr)++; - - /* If the start is after the end, the range is empty. */ - if (range_start > range_end) - return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; - - /* Here we see why `this_char' has to be larger than an `unsigned - char' -- the range is inclusive, so if `range_end' == 0xff - (assuming 8-bit characters), we would otherwise go into an infinite - loop, since all characters <= 0xff. */ - for (this_char = range_start; this_char <= range_end; this_char++) - { - SET_LIST_BIT (TRANSLATE (this_char)); - } - - return REG_NOERROR; -} - -/* Failure stack declarations and macros; both re_compile_fastmap and - re_match_2 use a failure stack. These have to be macros because of - REGEX_ALLOCATE. */ - - -/* Number of failure points for which to initially allocate space - when matching. If this number is exceeded, we allocate more - space, so it is not a hard limit. */ -#ifndef INIT_FAILURE_ALLOC -#define INIT_FAILURE_ALLOC 5 -#endif - -/* Roughly the maximum number of failure points on the stack. Would be - exactly that if always used MAX_FAILURE_SPACE each time we failed. - This is a variable only so users of regex can assign to it; we never - change it ourselves. */ -int re_max_failures = 2000; - -typedef const unsigned char *fail_stack_elt_t; - -typedef struct -{ - fail_stack_elt_t *stack; - unsigned size; - unsigned avail; /* Offset of next open position. */ -} fail_stack_type; - -#define FAIL_STACK_EMPTY() (fail_stack.avail == 0) -#define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) -#define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) -#define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail]) - - -/* Initialize `fail_stack'. Do `return -2' if the alloc fails. */ - -#define INIT_FAIL_STACK() \ - do { \ - fail_stack.stack = (fail_stack_elt_t *) \ - REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \ - \ - if (fail_stack.stack == NULL) \ - return -2; \ - \ - fail_stack.size = INIT_FAILURE_ALLOC; \ - fail_stack.avail = 0; \ - } while (0) - - -/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items. - - Return 1 if succeeds, and 0 if either ran out of memory - allocating space for it or it was already too large. - - REGEX_REALLOCATE requires `destination' be declared. */ - -#define DOUBLE_FAIL_STACK(fail_stack) \ - ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \ - ? 0 \ - : ((fail_stack).stack = (fail_stack_elt_t *) \ - REGEX_REALLOCATE ((fail_stack).stack, \ - (fail_stack).size * sizeof (fail_stack_elt_t), \ - ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \ - \ - (fail_stack).stack == NULL \ - ? 0 \ - : ((fail_stack).size <<= 1, \ - 1))) - - -/* Push PATTERN_OP on FAIL_STACK. - - Return 1 if was able to do so and 0 if ran out of memory allocating - space to do so. */ -#define PUSH_PATTERN_OP(pattern_op, fail_stack) \ - ((FAIL_STACK_FULL () \ - && !DOUBLE_FAIL_STACK (fail_stack)) \ - ? 0 \ - : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \ - 1)) - -/* This pushes an item onto the failure stack. Must be a four-byte - value. Assumes the variable `fail_stack'. Probably should only - be called from within `PUSH_FAILURE_POINT'. */ -#define PUSH_FAILURE_ITEM(item) \ - fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item - -/* The complement operation. Assumes `fail_stack' is nonempty. */ -#define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail] - -/* Used to omit pushing failure point id's when we're not debugging. */ -#ifdef DEBUG -#define DEBUG_PUSH PUSH_FAILURE_ITEM -#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_ITEM () -#else -#define DEBUG_PUSH(item) -#define DEBUG_POP(item_addr) -#endif - - -/* Push the information about the state we will need - if we ever fail back to it. - - Requires variables fail_stack, regstart, regend, reg_info, and - num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be - declared. - - Does `return FAILURE_CODE' if runs out of memory. */ - -#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \ - do { \ - char *destination; \ - /* Must be int, so when we don't save any registers, the arithmetic \ - of 0 + -1 isn't done as unsigned. */ \ - int this_reg; \ - \ - DEBUG_STATEMENT (failure_id++); \ - DEBUG_STATEMENT (nfailure_points_pushed++); \ - DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \ - DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\ - DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\ - \ - DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ - DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \ - \ - /* Ensure we have enough space allocated for what we will push. */ \ - while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ - { \ - if (!DOUBLE_FAIL_STACK (fail_stack)) \ - return failure_code; \ - \ - DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \ - (fail_stack).size); \ - DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\ - } \ - \ - /* Push the info, starting with the registers. */ \ - DEBUG_PRINT1 ("\n"); \ - \ - for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ - this_reg++) \ - { \ - DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ - DEBUG_STATEMENT (num_regs_pushed++); \ - \ - DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ - PUSH_FAILURE_ITEM (regstart[this_reg]); \ - \ - DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ - PUSH_FAILURE_ITEM (regend[this_reg]); \ - \ - DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ - DEBUG_PRINT2 (" match_null=%d", \ - REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ - DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ - DEBUG_PRINT2 (" matched_something=%d", \ - MATCHED_SOMETHING (reg_info[this_reg])); \ - DEBUG_PRINT2 (" ever_matched=%d", \ - EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ - DEBUG_PRINT1 ("\n"); \ - PUSH_FAILURE_ITEM (reg_info[this_reg].word); \ - } \ - \ - DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ - PUSH_FAILURE_ITEM (lowest_active_reg); \ - \ - DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ - PUSH_FAILURE_ITEM (highest_active_reg); \ - \ - DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \ - DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ - PUSH_FAILURE_ITEM (pattern_place); \ - \ - DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \ - DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ - size2); \ - DEBUG_PRINT1 ("'\n"); \ - PUSH_FAILURE_ITEM (string_place); \ - \ - DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \ - DEBUG_PUSH (failure_id); \ - } while (0) - -/* This is the number of items that are pushed and popped on the stack - for each register. */ -#define NUM_REG_ITEMS 3 - -/* Individual items aside from the registers. */ -#ifdef DEBUG -#define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ -#else -#define NUM_NONREG_ITEMS 4 -#endif - -/* We push at most this many items on the stack. */ -#define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) - -/* We actually push this many items. */ -#define NUM_FAILURE_ITEMS \ - ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ - + NUM_NONREG_ITEMS) - -/* How many items can still be added to the stack without overflowing it. */ -#define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) - - -/* Pops what PUSH_FAIL_STACK pushes. - - We restore into the parameters, all of which should be lvalues: - STR -- the saved data position. - PAT -- the saved pattern position. - LOW_REG, HIGH_REG -- the highest and lowest active registers. - REGSTART, REGEND -- arrays of string positions. - REG_INFO -- array of information about each subexpression. - - Also assumes the variables `fail_stack' and (if debugging), `bufp', - `pend', `string1', `size1', `string2', and `size2'. */ - -#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\ -{ \ - DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \ - int this_reg; \ - const unsigned char *string_temp; \ - \ - assert (!FAIL_STACK_EMPTY ()); \ - \ - /* Remove failure points and point to how many regs pushed. */ \ - DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ - DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \ - DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \ - \ - assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ - \ - DEBUG_POP (&failure_id); \ - DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \ - \ - /* If the saved string location is NULL, it came from an \ - on_failure_keep_string_jump opcode, and we want to throw away the \ - saved NULL, thus retaining our current position in the string. */ \ - string_temp = POP_FAILURE_ITEM (); \ - if (string_temp != NULL) \ - str = (const char *) string_temp; \ - \ - DEBUG_PRINT2 (" Popping string 0x%x: `", str); \ - DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ - DEBUG_PRINT1 ("'\n"); \ - \ - pat = (unsigned char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \ - DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ - \ - /* Restore register info. */ \ - high_reg = (unsigned) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ - \ - low_reg = (unsigned) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ - \ - for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ - { \ - DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ - \ - reg_info[this_reg].word = POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ - \ - regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ - \ - regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ - } \ - \ - DEBUG_STATEMENT (nfailure_points_popped++); \ -} /* POP_FAILURE_POINT */ - -/* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in - BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible - characters can start a string that matches the pattern. This fastmap - is used by re_search to skip quickly over impossible starting points. - - The caller must supply the address of a (1 << BYTEWIDTH)-byte data - area as BUFP->fastmap. - - We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in - the pattern buffer. - - Returns 0 if we succeed, -2 if an internal error. */ - -int -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; -{ - int j, k; - fail_stack_type fail_stack; -#ifndef REGEX_MALLOC - char *destination; -#endif - /* We don't push any register information onto the failure stack. */ - unsigned num_regs = 0; - - register char *fastmap = bufp->fastmap; - unsigned char *pattern = bufp->buffer; - unsigned long size = bufp->used; - const unsigned char *p = pattern; - register unsigned char *pend = pattern + size; - - /* Assume that each path through the pattern can be null until - proven otherwise. We set this false at the bottom of switch - statement, to which we get only if a particular path doesn't - match the empty string. */ - boolean path_can_be_null = true; - - /* We aren't doing a `succeed_n' to begin with. */ - boolean succeed_n_p = false; - - assert (fastmap != NULL && p != NULL); - - INIT_FAIL_STACK (); - bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ - bufp->fastmap_accurate = 1; /* It will be when we're done. */ - bufp->can_be_null = 0; - - while (p != pend || !FAIL_STACK_EMPTY ()) - { - if (p == pend) - { - bufp->can_be_null |= path_can_be_null; - - /* Reset for next path. */ - path_can_be_null = true; - - p = fail_stack.stack[--fail_stack.avail]; - } - - /* We should never be about to go beyond the end of the pattern. */ - assert (p < pend); - -#ifdef SWITCH_ENUM_BUG - switch ((int) ((re_opcode_t) *p++)) -#else - switch ((re_opcode_t) *p++) -#endif - { - - /* I guess the idea here is to simply not bother with a fastmap - if a backreference is used, since it's too hard to figure out - the fastmap for the corresponding group. Setting - `can_be_null' stops `re_search_2' from using the fastmap, so - that is all we do. */ - case duplicate: - bufp->can_be_null = 1; - return 0; - - - /* Following are the cases which match a character. These end - with `break'. */ - - case exactn: - fastmap[p[1]] = 1; - break; - - - case charset: - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) - fastmap[j] = 1; - break; - - - case charset_not: - /* Chars beyond end of map must be allowed. */ - for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) - fastmap[j] = 1; - - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) - fastmap[j] = 1; - break; - - - case wordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == Sword) - fastmap[j] = 1; - break; - - - case notwordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != Sword) - fastmap[j] = 1; - break; - - - case anychar: - /* `.' matches anything ... */ - for (j = 0; j < (1 << BYTEWIDTH); j++) - fastmap[j] = 1; - - /* ... except perhaps newline. */ - if (!(bufp->syntax & RE_DOT_NEWLINE)) - fastmap['\n'] = 0; - - /* Return if we have already set `can_be_null'; if we have, - then the fastmap is irrelevant. Something's wrong here. */ - else if (bufp->can_be_null) - return 0; - - /* Otherwise, have to check alternative paths. */ - break; - - -#ifdef emacs - case syntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == (enum syntaxcode) k) - fastmap[j] = 1; - break; - - - case notsyntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != (enum syntaxcode) k) - fastmap[j] = 1; - break; - - - /* All cases after this match the empty string. These end with - `continue'. */ - - - case before_dot: - case at_dot: - case after_dot: - continue; -#endif /* not emacs */ - - - case no_op: - case begline: - case endline: - case begbuf: - case endbuf: - case wordbound: - case notwordbound: - case wordbeg: - case wordend: - case push_dummy_failure: - continue; - - - case jump_n: - case pop_failure_jump: - case maybe_pop_jump: - case jump: - case jump_past_alt: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - if (j > 0) - continue; - - /* Jump backward implies we just went through the body of a - loop and matched nothing. Opcode jumped to should be - `on_failure_jump' or `succeed_n'. Just treat it like an - ordinary jump. For a * loop, it has pushed its failure - point already; if so, discard that as redundant. */ - if ((re_opcode_t) *p != on_failure_jump - && (re_opcode_t) *p != succeed_n) - continue; - - p++; - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - - /* If what's on the stack is where we are now, pop it. */ - if (!FAIL_STACK_EMPTY () - && fail_stack.stack[fail_stack.avail - 1] == p) - fail_stack.avail--; - - continue; - - - case on_failure_jump: - case on_failure_keep_string_jump: - handle_on_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - - /* For some patterns, e.g., `(a?)?', `p+j' here points to the - end of the pattern. We don't want to push such a point, - since when we restore it above, entering the switch will - increment `p' past the end of the pattern. We don't need - to push such a point since we obviously won't find any more - fastmap entries beyond `pend'. Such a pattern can match - the null string, though. */ - if (p + j < pend) - { - if (!PUSH_PATTERN_OP (p + j, fail_stack)) - return -2; - } - else - bufp->can_be_null = 1; - - if (succeed_n_p) - { - EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ - succeed_n_p = false; - } - - continue; - - - case succeed_n: - /* Get to the number of times to succeed. */ - p += 2; - - /* Increment p past the n for when k != 0. */ - EXTRACT_NUMBER_AND_INCR (k, p); - if (k == 0) - { - p -= 4; - succeed_n_p = true; /* Spaghetti code alert. */ - goto handle_on_failure_jump; - } - continue; - - - case set_number_at: - p += 4; - continue; - - - case start_memory: - case stop_memory: - p += 2; - continue; - - - default: - abort (); /* We have listed all the cases. */ - } /* switch *p++ */ - - /* Getting here means we have found the possible starting - characters for one path of the pattern -- and that the empty - string does not match. We need not follow this path further. - Instead, look at the next alternative (remembered on the - stack), or quit if no more. The test at the top of the loop - does these things. */ - path_can_be_null = false; - p = pend; - } /* while p */ - - /* Set `can_be_null' for the last path (also the first path, if the - pattern is empty). */ - bufp->can_be_null |= path_can_be_null; - return 0; -} /* re_compile_fastmap */ - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use - this memory for recording register information. STARTS and ENDS - must be allocated using the malloc library routine, and must each - be at least NUM_REGS * sizeof (regoff_t) bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ - -void -re_set_registers (bufp, regs, num_regs, starts, ends) - struct re_pattern_buffer *bufp; - struct re_registers *regs; - unsigned num_regs; - regoff_t *starts, *ends; -{ - if (num_regs) - { - bufp->regs_allocated = REGS_REALLOCATE; - regs->num_regs = num_regs; - regs->start = starts; - regs->end = ends; - } - else - { - bufp->regs_allocated = REGS_UNALLOCATED; - regs->num_regs = 0; - regs->start = regs->end = (regoff_t) 0; - } -} - -/* Searching routines. */ - -/* Like re_search_2, below, but only one string is specified, and - doesn't let you say where to stop matching. */ - -int -re_search (bufp, string, size, startpos, range, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, startpos, range; - struct re_registers *regs; -{ - return re_search_2 (bufp, NULL, 0, string, size, startpos, range, - regs, size); -} - - -/* Using the compiled pattern in BUFP->buffer, first tries to match the - virtual concatenation of STRING1 and STRING2, starting first at index - STARTPOS, then at STARTPOS + 1, and so on. - - STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. - - RANGE is how far to scan while trying to match. RANGE = 0 means try - only at STARTPOS; in general, the last start tried is STARTPOS + - RANGE. - - In REGS, return the indices of the virtual concatenation of STRING1 - and STRING2 that matched the entire BUFP->buffer and its contained - subexpressions. - - Do not consider matching one past the index STOP in the virtual - concatenation of STRING1 and STRING2. - - We return either the position in the strings at which the match was - found, -1 if no match, or -2 if error (such as failure - stack overflow). */ - -int -re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int size1, size2; - int startpos; - int range; - struct re_registers *regs; - int stop; -{ - int val; - register char *fastmap = bufp->fastmap; - register char *translate = bufp->translate; - int total_size = size1 + size2; - int endpos = startpos + range; - - /* Check for out-of-range STARTPOS. */ - if (startpos < 0 || startpos > total_size) - return -1; - - /* Fix up RANGE if it might eventually take us outside - the virtual concatenation of STRING1 and STRING2. */ - if (endpos < -1) - range = -1 - startpos; - else if (endpos > total_size) - range = total_size - startpos; - - /* If the search isn't to be a backwards one, don't waste time in a - search for a pattern that must be anchored. */ - if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) - { - if (startpos > 0) - return -1; - else - range = 1; - } - - /* Update the fastmap now if not correct already. */ - if (fastmap && !bufp->fastmap_accurate) - if (re_compile_fastmap (bufp) == -2) - return -2; - - /* Loop through the string, looking for a place to start matching. */ - for (;;) - { - /* If a fastmap is supplied, skip quickly over characters that - cannot be the start of a match. If the pattern can match the - null string, however, we don't need to skip characters; we want - the first null string. */ - if (fastmap && startpos < total_size && !bufp->can_be_null) - { - if (range > 0) /* Searching forwards. */ - { - register const char *d; - register int lim = 0; - int irange = range; - - if (startpos < size1 && startpos + range >= size1) - lim = range - (size1 - startpos); - - d = (startpos >= size1 ? string2 - size1 : string1) + startpos; - - /* Written out as an if-else to avoid testing `translate' - inside the loop. */ - if (translate) - while (range > lim - && !fastmap[(unsigned char) - translate[(unsigned char) *d++]]) - range--; - else - while (range > lim && !fastmap[(unsigned char) *d++]) - range--; - - startpos += irange - range; - } - else /* Searching backwards. */ - { - register char c = (size1 == 0 || startpos >= size1 - ? string2[startpos - size1] - : string1[startpos]); - - if (!fastmap[(unsigned char) TRANSLATE (c)]) - goto advance; - } - } - - /* If can't match the null string, and that's all we have left, fail. */ - if (range >= 0 && startpos == total_size && fastmap - && !bufp->can_be_null) - return -1; - - val = re_match_2 (bufp, string1, size1, string2, size2, - startpos, regs, stop); - if (val >= 0) - return startpos; - - if (val == -2) - return -2; - - advance: - if (!range) - break; - else if (range > 0) - { - range--; - startpos++; - } - else - { - range++; - startpos--; - } - } - return -1; -} /* re_search_2 */ - -/* Declarations and macros for re_match_2. */ - -static int bcmp_translate (); -static boolean alt_match_null_string_p (), - common_op_match_null_string_p (), - group_match_null_string_p (); - -/* Structure for per-register (a.k.a. per-group) information. - This must not be longer than one word, because we push this value - onto the failure stack. Other register information, such as the - starting and ending positions (which are addresses), and the list of - inner groups (which is a bits list) are maintained in separate - variables. - - We are making a (strictly speaking) nonportable assumption here: that - the compiler will pack our bit fields into something that fits into - the type of `word', i.e., is something that fits into one item on the - failure stack. */ -typedef union -{ - fail_stack_elt_t word; - struct - { - /* This field is one if this group can match the empty string, - zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ -#define MATCH_NULL_UNSET_VALUE 3 - unsigned match_null_string_p : 2; - unsigned is_active : 1; - unsigned matched_something : 1; - unsigned ever_matched_something : 1; - } bits; -} register_info_type; - -#define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) -#define IS_ACTIVE(R) ((R).bits.is_active) -#define MATCHED_SOMETHING(R) ((R).bits.matched_something) -#define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) - - -/* Call this when have matched a real character; it sets `matched' flags - for the subexpressions which we are currently inside. Also records - that those subexprs have matched. */ -#define SET_REGS_MATCHED() \ - do \ - { \ - unsigned r; \ - for (r = lowest_active_reg; r <= highest_active_reg; r++) \ - { \ - MATCHED_SOMETHING (reg_info[r]) \ - = EVER_MATCHED_SOMETHING (reg_info[r]) \ - = 1; \ - } \ - } \ - while (0) - - -/* This converts PTR, a pointer into one of the search strings `string1' - and `string2' into an offset from the beginning of that string. */ -#define POINTER_TO_OFFSET(ptr) \ - (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1) - -/* Registers are set to a sentinel when they haven't yet matched. */ -#define REG_UNSET_VALUE ((char *) -1) -#define REG_UNSET(e) ((e) == REG_UNSET_VALUE) - - -/* Macros for dealing with the split strings in re_match_2. */ - -#define MATCHING_IN_FIRST_STRING (dend == end_match_1) - -/* Call before fetching a character with *d. This switches over to - string2 if necessary. */ -#define PREFETCH() \ - while (d == dend) \ - { \ - /* End of string2 => fail. */ \ - if (dend == end_match_2) \ - goto fail; \ - /* End of string1 => advance to string2. */ \ - d = string2; \ - dend = end_match_2; \ - } - - -/* Test if at very beginning or at very end of the virtual concatenation - of `string1' and `string2'. If only one string, it's `string2'. */ -#define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) -#define AT_STRINGS_END(d) ((d) == end2) - - -/* Test if D points to a character which is word-constituent. We have - two special cases to check for: if past the end of string1, look at - the first character in string2; and if before the beginning of - string2, look at the last character in string1. */ -#define WORDCHAR_P(d) \ - (SYNTAX ((d) == end1 ? *string2 \ - : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ - == Sword) - -/* Test if the character before D and the one at D differ with respect - to being word-constituent. */ -#define AT_WORD_BOUNDARY(d) \ - (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \ - || WORDCHAR_P (d - 1) != WORDCHAR_P (d)) - - -/* Free everything we malloc. */ -#ifdef REGEX_MALLOC -#define FREE_VAR(var) if (var) free (var); var = NULL -#define FREE_VARIABLES() \ - do { \ - FREE_VAR (fail_stack.stack); \ - FREE_VAR (regstart); \ - FREE_VAR (regend); \ - FREE_VAR (old_regstart); \ - FREE_VAR (old_regend); \ - FREE_VAR (best_regstart); \ - FREE_VAR (best_regend); \ - FREE_VAR (reg_info); \ - FREE_VAR (reg_dummy); \ - FREE_VAR (reg_info_dummy); \ - } while (0) -#else /* not REGEX_MALLOC */ -/* Some MIPS systems (at least) want this to free alloca'd storage. */ -#define FREE_VARIABLES() alloca (0) -#endif /* not REGEX_MALLOC */ - - -/* These values must meet several constraints. They must not be valid - register values; since we have a limit of 255 registers (because - we use only one byte in the pattern for the register number), we can - use numbers larger than 255. They must differ by 1, because of - NUM_FAILURE_ITEMS above. And the value for the lowest register must - be larger than the value for the highest register, so we do not try - to actually save any registers when none are active. */ -#define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH) -#define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) - -/* Matching routines. */ - -#ifndef emacs /* Emacs never uses this. */ -/* re_match is like re_match_2 except it takes only a single string. */ - -int -re_match (bufp, string, size, pos, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, pos; - struct re_registers *regs; - { - return re_match_2 (bufp, NULL, 0, string, size, pos, regs, size); -} -#endif /* not emacs */ - - -/* re_match_2 matches the compiled pattern in BUFP against the - the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 - and SIZE2, respectively). We start matching at POS, and stop - matching at STOP. - - If REGS is non-null and the `no_sub' field of BUFP is nonzero, we - store offsets for the substring each group matched in REGS. See the - documentation for exactly how many groups we fill. - - We return -1 if no match, -2 if an internal error (such as the - failure stack overflowing). Otherwise, we return the length of the - matched substring. */ - -int -re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int size1, size2; - int pos; - struct re_registers *regs; - int stop; -{ - /* General temporaries. */ - int mcnt; - unsigned char *p1; - - /* Just past the end of the corresponding string. */ - const char *end1, *end2; - - /* Pointers into string1 and string2, just past the last characters in - each to consider matching. */ - const char *end_match_1, *end_match_2; - - /* Where we are in the data, and the end of the current string. */ - const char *d, *dend; - - /* Where we are in the pattern, and the end of the pattern. */ - unsigned char *p = bufp->buffer; - register unsigned char *pend = p + bufp->used; - - /* We use this to map every character in the string. */ - char *translate = bufp->translate; - - /* Failure point stack. Each place that can handle a failure further - down the line pushes a failure point on this stack. It consists of - restart, regend, and reg_info for all registers corresponding to - the subexpressions we're currently inside, plus the number of such - registers, and, finally, two char *'s. The first char * is where - to resume scanning the pattern; the second one is where to resume - scanning the strings. If the latter is zero, the failure point is - a ``dummy''; if a failure happens and the failure point is a dummy, - it gets discarded and the next next one is tried. */ - fail_stack_type fail_stack; -#ifdef DEBUG - static unsigned failure_id = 0; - unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; -#endif - - /* We fill all the registers internally, independent of what we - return, for use in backreferences. The number here includes - an element for register zero. */ - unsigned num_regs = bufp->re_nsub + 1; - - /* The currently active registers. */ - unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG; - unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG; - - /* Information on the contents of registers. These are pointers into - the input strings; they record just what was matched (on this - attempt) by a subexpression part of the pattern, that is, the - regnum-th regstart pointer points to where in the pattern we began - matching and the regnum-th regend points to right after where we - stopped matching the regnum-th subexpression. (The zeroth register - keeps track of what the whole pattern matches.) */ - const char **regstart, **regend; - - /* If a group that's operated upon by a repetition operator fails to - match anything, then the register for its start will need to be - restored because it will have been set to wherever in the string we - are when we last see its open-group operator. Similarly for a - register's end. */ - const char **old_regstart, **old_regend; - - /* The is_active field of reg_info helps us keep track of which (possibly - nested) subexpressions we are currently in. The matched_something - field of reg_info[reg_num] helps us tell whether or not we have - matched any of the pattern so far this time through the reg_num-th - subexpression. These two fields get reset each time through any - loop their register is in. */ - register_info_type *reg_info; - - /* The following record the register info as found in the above - variables when we find a match better than any we've seen before. - This happens as we backtrack through the failure points, which in - turn happens only if we have not yet matched the entire string. */ - unsigned best_regs_set = false; - const char **best_regstart, **best_regend; - - /* Logically, this is `best_regend[0]'. But we don't want to have to - allocate space for that if we're not allocating space for anything - else (see below). Also, we never need info about register 0 for - any of the other register vectors, and it seems rather a kludge to - treat `best_regend' differently than the rest. So we keep track of - the end of the best match so far in a separate variable. We - initialize this to NULL so that when we backtrack the first time - and need to test it, it's not garbage. */ - const char *match_end = NULL; - - /* Used when we pop values we don't care about. */ - const char **reg_dummy; - register_info_type *reg_info_dummy; - -#ifdef DEBUG - /* Counts the total number of registers pushed. */ - unsigned num_regs_pushed = 0; -#endif - - DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); - - INIT_FAIL_STACK (); - - /* Do not bother to initialize all the register variables if there are - no groups in the pattern, as it takes a fair amount of time. If - there are groups, we include space for register 0 (the whole - pattern), even though we never use it, since it simplifies the - array indexing. We should fix this. */ - if (bufp->re_nsub) - { - regstart = REGEX_TALLOC (num_regs, const char *); - regend = REGEX_TALLOC (num_regs, const char *); - old_regstart = REGEX_TALLOC (num_regs, const char *); - old_regend = REGEX_TALLOC (num_regs, const char *); - best_regstart = REGEX_TALLOC (num_regs, const char *); - best_regend = REGEX_TALLOC (num_regs, const char *); - reg_info = REGEX_TALLOC (num_regs, register_info_type); - reg_dummy = REGEX_TALLOC (num_regs, const char *); - reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); - - if (!(regstart && regend && old_regstart && old_regend && reg_info - && best_regstart && best_regend && reg_dummy && reg_info_dummy)) - { - FREE_VARIABLES (); - return -2; - } - } -#ifdef REGEX_MALLOC - else - { - /* We must initialize all our variables to NULL, so that - `FREE_VARIABLES' doesn't try to free them. */ - regstart = regend = old_regstart = old_regend = best_regstart - = best_regend = reg_dummy = NULL; - reg_info = reg_info_dummy = (register_info_type *) NULL; - } -#endif /* REGEX_MALLOC */ - - /* The starting position is bogus. */ - if (pos < 0 || pos > size1 + size2) - { - FREE_VARIABLES (); - return -1; - } - - /* Initialize subexpression text positions to -1 to mark ones that no - start_memory/stop_memory has been seen for. Also initialize the - register information struct. */ - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - regstart[mcnt] = regend[mcnt] - = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE; - - REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; - IS_ACTIVE (reg_info[mcnt]) = 0; - MATCHED_SOMETHING (reg_info[mcnt]) = 0; - EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; - } - - /* We move `string1' into `string2' if the latter's empty -- but not if - `string1' is null. */ - if (size2 == 0 && string1 != NULL) - { - string2 = string1; - size2 = size1; - string1 = 0; - size1 = 0; - } - end1 = string1 + size1; - end2 = string2 + size2; - - /* Compute where to stop matching, within the two strings. */ - if (stop <= size1) - { - end_match_1 = string1 + stop; - end_match_2 = string2; - } - else - { - end_match_1 = end1; - end_match_2 = string2 + stop - size1; - } - - /* `p' scans through the pattern as `d' scans through the data. - `dend' is the end of the input string that `d' points within. `d' - is advanced into the following input string whenever necessary, but - this happens before fetching; therefore, at the beginning of the - loop, `d' can be pointing at the end of a string, but it cannot - equal `string2'. */ - if (size1 > 0 && pos <= size1) - { - d = string1 + pos; - dend = end_match_1; - } - else - { - d = string2 + pos - size1; - dend = end_match_2; - } - - DEBUG_PRINT1 ("The compiled pattern is: "); - DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend); - DEBUG_PRINT1 ("The string to match is: `"); - DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); - DEBUG_PRINT1 ("'\n"); - - /* This loops over pattern commands. It exits by returning from the - function if the match is complete, or it drops through if the match - fails at this starting point in the input data. */ - for (;;) - { - DEBUG_PRINT2 ("\n0x%x: ", p); - - if (p == pend) - { /* End of pattern means we might have succeeded. */ - DEBUG_PRINT1 ("end of pattern ... "); - - /* If we haven't matched the entire string, and we want the - longest match, try backtracking. */ - if (d != end_match_2) - { - DEBUG_PRINT1 ("backtracking.\n"); - - if (!FAIL_STACK_EMPTY ()) - { /* More failure points to try. */ - boolean same_str_p = (FIRST_STRING_P (match_end) - == MATCHING_IN_FIRST_STRING); - - /* If exceeds best match so far, save it. */ - if (!best_regs_set - || (same_str_p && d > match_end) - || (!same_str_p && !MATCHING_IN_FIRST_STRING)) - { - best_regs_set = true; - match_end = d; - - DEBUG_PRINT1 ("\nSAVING match as best so far.\n"); - - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - best_regstart[mcnt] = regstart[mcnt]; - best_regend[mcnt] = regend[mcnt]; - } - } - goto fail; - } - - /* If no failure points, don't restore garbage. */ - else if (best_regs_set) - { - restore_best_regs: - /* Restore best match. It may happen that `dend == - end_match_1' while the restored d is in string2. - For example, the pattern `x.*y.*z' against the - strings `x-' and `y-z-', if the two strings are - not consecutive in memory. */ - DEBUG_PRINT1 ("Restoring best registers.\n"); - - d = match_end; - dend = ((d >= string1 && d <= end1) - ? end_match_1 : end_match_2); - - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - regstart[mcnt] = best_regstart[mcnt]; - regend[mcnt] = best_regend[mcnt]; - } - } - } /* d != end_match_2 */ - - DEBUG_PRINT1 ("Accepting match.\n"); - - /* If caller wants register contents data back, do it. */ - if (regs && !bufp->no_sub) - { - /* Have the register data arrays been allocated? */ - if (bufp->regs_allocated == REGS_UNALLOCATED) - { /* No. So allocate them with malloc. We need one - extra element beyond `num_regs' for the `-1' marker - GNU code uses. */ - regs->num_regs = MAX (RE_NREGS, num_regs + 1); - regs->start = TALLOC (regs->num_regs, regoff_t); - regs->end = TALLOC (regs->num_regs, regoff_t); - if (regs->start == NULL || regs->end == NULL) - return -2; - bufp->regs_allocated = REGS_REALLOCATE; - } - else if (bufp->regs_allocated == REGS_REALLOCATE) - { /* Yes. If we need more elements than were already - allocated, reallocate them. If we need fewer, just - leave it alone. */ - if (regs->num_regs < num_regs + 1) - { - regs->num_regs = num_regs + 1; - RETALLOC (regs->start, regs->num_regs, regoff_t); - RETALLOC (regs->end, regs->num_regs, regoff_t); - if (regs->start == NULL || regs->end == NULL) - return -2; - } - } - else - assert (bufp->regs_allocated == REGS_FIXED); - - /* Convert the pointer data in `regstart' and `regend' to - indices. Register zero has to be set differently, - since we haven't kept track of any info for it. */ - if (regs->num_regs > 0) - { - regs->start[0] = pos; - regs->end[0] = (MATCHING_IN_FIRST_STRING ? d - string1 - : d - string2 + size1); - } - - /* Go through the first `min (num_regs, regs->num_regs)' - registers, since that is all we initialized. */ - for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++) - { - if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt])) - regs->start[mcnt] = regs->end[mcnt] = -1; - else - { - regs->start[mcnt] = POINTER_TO_OFFSET (regstart[mcnt]); - regs->end[mcnt] = POINTER_TO_OFFSET (regend[mcnt]); - } - } - - /* If the regs structure we return has more elements than - were in the pattern, set the extra elements to -1. If - we (re)allocated the registers, this is the case, - because we always allocate enough to have at least one - -1 at the end. */ - for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++) - regs->start[mcnt] = regs->end[mcnt] = -1; - } /* regs && !bufp->no_sub */ - - FREE_VARIABLES (); - DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", - nfailure_points_pushed, nfailure_points_popped, - nfailure_points_pushed - nfailure_points_popped); - DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); - - mcnt = d - pos - (MATCHING_IN_FIRST_STRING - ? string1 - : string2 - size1); - - DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); - - return mcnt; - } - - /* Otherwise match next pattern command. */ -#ifdef SWITCH_ENUM_BUG - switch ((int) ((re_opcode_t) *p++)) -#else - switch ((re_opcode_t) *p++) -#endif - { - /* Ignore these. Used to ignore the n of succeed_n's which - currently have n == 0. */ - case no_op: - DEBUG_PRINT1 ("EXECUTING no_op.\n"); - break; - - - /* Match the next n pattern characters exactly. The following - byte in the pattern defines n, and the n bytes after that - are the characters to match. */ - case exactn: - mcnt = *p++; - DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt); - - /* This is written out as an if-else so we don't waste time - testing `translate' inside the loop. */ - if (translate) - { - do - { - PREFETCH (); - if (translate[(unsigned char) *d++] != (char) *p++) - goto fail; - } - while (--mcnt); - } - else - { - do - { - PREFETCH (); - if (*d++ != (char) *p++) goto fail; - } - while (--mcnt); - } - SET_REGS_MATCHED (); - break; - - - /* Match any character except possibly a newline or a null. */ - case anychar: - DEBUG_PRINT1 ("EXECUTING anychar.\n"); - - PREFETCH (); - - if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n') - || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000')) - goto fail; - - SET_REGS_MATCHED (); - DEBUG_PRINT2 (" Matched `%d'.\n", *d); - d++; - break; - - - case charset: - case charset_not: - { - register unsigned char c; - boolean not = (re_opcode_t) *(p - 1) == charset_not; - - DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); - - PREFETCH (); - c = TRANSLATE (*d); /* The character to match. */ - - /* Cast to `unsigned' instead of `unsigned char' in case the - bit list is a full 32 bytes long. */ - if (c < (unsigned) (*p * BYTEWIDTH) - && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - p += 1 + *p; - - if (!not) goto fail; - - SET_REGS_MATCHED (); - d++; - break; - } - - - /* The beginning of a group is represented by start_memory. - The arguments are the register number in the next byte, and the - number of groups inner to this one in the next. The text - matched within the group is recorded (in the internal - registers data structure) under the register number. */ - case start_memory: - DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]); - - /* Find out if this group can match the empty string. */ - p1 = p; /* To send to group_match_null_string_p. */ - - if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) - REG_MATCH_NULL_STRING_P (reg_info[*p]) - = group_match_null_string_p (&p1, pend, reg_info); - - /* Save the position in the string where we were the last time - we were at this open-group operator in case the group is - operated upon by a repetition operator, e.g., with `(a*)*b' - against `ab'; then we want to ignore where we are now in - the string in case this attempt to match fails. */ - old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) - ? REG_UNSET (regstart[*p]) ? d : regstart[*p] - : regstart[*p]; - DEBUG_PRINT2 (" old_regstart: %d\n", - POINTER_TO_OFFSET (old_regstart[*p])); - - regstart[*p] = d; - DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p])); - - IS_ACTIVE (reg_info[*p]) = 1; - MATCHED_SOMETHING (reg_info[*p]) = 0; - - /* This is the new highest active register. */ - highest_active_reg = *p; - - /* If nothing was active before, this is the new lowest active - register. */ - if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) - lowest_active_reg = *p; - - /* Move past the register number and inner group count. */ - p += 2; - break; - - - /* The stop_memory opcode represents the end of a group. Its - arguments are the same as start_memory's: the register - number, and the number of inner groups. */ - case stop_memory: - DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]); - - /* We need to save the string position the last time we were at - this close-group operator in case the group is operated - upon by a repetition operator, e.g., with `((a*)*(b*)*)*' - against `aba'; then we want to ignore where we are now in - the string in case this attempt to match fails. */ - old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) - ? REG_UNSET (regend[*p]) ? d : regend[*p] - : regend[*p]; - DEBUG_PRINT2 (" old_regend: %d\n", - POINTER_TO_OFFSET (old_regend[*p])); - - regend[*p] = d; - DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p])); - - /* This register isn't active anymore. */ - IS_ACTIVE (reg_info[*p]) = 0; - - /* If this was the only register active, nothing is active - anymore. */ - if (lowest_active_reg == highest_active_reg) - { - lowest_active_reg = NO_LOWEST_ACTIVE_REG; - highest_active_reg = NO_HIGHEST_ACTIVE_REG; - } - else - { /* We must scan for the new highest active register, since - it isn't necessarily one less than now: consider - (a(b)c(d(e)f)g). When group 3 ends, after the f), the - new highest active register is 1. */ - unsigned char r = *p - 1; - while (r > 0 && !IS_ACTIVE (reg_info[r])) - r--; - - /* If we end up at register zero, that means that we saved - the registers as the result of an `on_failure_jump', not - a `start_memory', and we jumped to past the innermost - `stop_memory'. For example, in ((.)*) we save - registers 1 and 2 as a result of the *, but when we pop - back to the second ), we are at the stop_memory 1. - Thus, nothing is active. */ - if (r == 0) - { - lowest_active_reg = NO_LOWEST_ACTIVE_REG; - highest_active_reg = NO_HIGHEST_ACTIVE_REG; - } - else - highest_active_reg = r; - } - - /* If just failed to match something this time around with a - group that's operated on by a repetition operator, try to - force exit from the ``loop'', and restore the register - information for this group that we had before trying this - last match. */ - if ((!MATCHED_SOMETHING (reg_info[*p]) - || (re_opcode_t) p[-3] == start_memory) - && (p + 2) < pend) - { - boolean is_a_jump_n = false; - - p1 = p + 2; - mcnt = 0; - switch ((re_opcode_t) *p1++) - { - case jump_n: - is_a_jump_n = true; - case pop_failure_jump: - case maybe_pop_jump: - case jump: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if (is_a_jump_n) - p1 += 2; - break; - - default: - /* do nothing */ ; - } - p1 += mcnt; - - /* If the next operation is a jump backwards in the pattern - to an on_failure_jump right before the start_memory - corresponding to this stop_memory, exit from the loop - by forcing a failure after pushing on the stack the - on_failure_jump's jump in the pattern, and d. */ - if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump - && (re_opcode_t) p1[3] == start_memory && p1[4] == *p) - { - /* If this group ever matched anything, then restore - what its registers were before trying this last - failed match, e.g., with `(a*)*b' against `ab' for - regstart[1], and, e.g., with `((a*)*(b*)*)*' - against `aba' for regend[3]. - - Also restore the registers for inner groups for, - e.g., `((a*)(b*))*' against `aba' (register 3 would - otherwise get trashed). */ - - if (EVER_MATCHED_SOMETHING (reg_info[*p])) - { - unsigned r; - - EVER_MATCHED_SOMETHING (reg_info[*p]) = 0; - - /* Restore this and inner groups' (if any) registers. */ - for (r = *p; r < *p + *(p + 1); r++) - { - regstart[r] = old_regstart[r]; - - /* xx why this test? */ - if ((int) old_regend[r] >= (int) regstart[r]) - regend[r] = old_regend[r]; - } - } - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - PUSH_FAILURE_POINT (p1 + mcnt, d, -2); - - goto fail; - } - } - - /* Move past the register number and the inner group count. */ - p += 2; - break; - - - /* \ has been turned into a `duplicate' command which is - followed by the numeric value of as the register number. */ - case duplicate: - { - register const char *d2, *dend2; - int regno = *p++; /* Get which register to match against. */ - DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno); - - /* Can't back reference a group which we've never matched. */ - if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) - goto fail; - - /* Where in input to try to start matching. */ - d2 = regstart[regno]; - - /* Where to stop matching; if both the place to start and - the place to stop matching are in the same string, then - set to the place to stop, otherwise, for now have to use - the end of the first string. */ - - dend2 = ((FIRST_STRING_P (regstart[regno]) - == FIRST_STRING_P (regend[regno])) - ? regend[regno] : end_match_1); - for (;;) - { - /* If necessary, advance to next segment in register - contents. */ - while (d2 == dend2) - { - if (dend2 == end_match_2) break; - if (dend2 == regend[regno]) break; - - /* End of string1 => advance to string2. */ - d2 = string2; - dend2 = regend[regno]; - } - /* At end of register contents => success */ - if (d2 == dend2) break; - - /* If necessary, advance to next segment in data. */ - PREFETCH (); - - /* How many characters left in this segment to match. */ - mcnt = dend - d; - - /* Want how many consecutive characters we can match in - one shot, so, if necessary, adjust the count. */ - if (mcnt > dend2 - d2) - mcnt = dend2 - d2; - - /* Compare that many; failure if mismatch, else move - past them. */ - if (translate - ? bcmp_translate (d, d2, mcnt, translate) - : bcmp (d, d2, mcnt)) - goto fail; - d += mcnt, d2 += mcnt; - } - } - break; - - - /* begline matches the empty string at the beginning of the string - (unless `not_bol' is set in `bufp'), and, if - `newline_anchor' is set, after newlines. */ - case begline: - DEBUG_PRINT1 ("EXECUTING begline.\n"); - - if (AT_STRINGS_BEG (d)) - { - if (!bufp->not_bol) break; - } - else if (d[-1] == '\n' && bufp->newline_anchor) - { - break; - } - /* In all other cases, we fail. */ - goto fail; - - - /* endline is the dual of begline. */ - case endline: - DEBUG_PRINT1 ("EXECUTING endline.\n"); - - if (AT_STRINGS_END (d)) - { - if (!bufp->not_eol) break; - } - - /* We have to ``prefetch'' the next character. */ - else if ((d == end1 ? *string2 : *d) == '\n' - && bufp->newline_anchor) - { - break; - } - goto fail; - - - /* Match at the very beginning of the data. */ - case begbuf: - DEBUG_PRINT1 ("EXECUTING begbuf.\n"); - if (AT_STRINGS_BEG (d)) - break; - goto fail; - - - /* Match at the very end of the data. */ - case endbuf: - DEBUG_PRINT1 ("EXECUTING endbuf.\n"); - if (AT_STRINGS_END (d)) - break; - goto fail; - - - /* on_failure_keep_string_jump is used to optimize `.*\n'. It - pushes NULL as the value for the string on the stack. Then - `pop_failure_point' will keep the current value for the - string, instead of restoring it. To see why, consider - matching `foo\nbar' against `.*\n'. The .* matches the foo; - then the . fails against the \n. But the next thing we want - to do is match the \n against the \n; if we restored the - string value, we would be back at the foo. - - Because this is used only in specific cases, we don't need to - check all the things that `on_failure_jump' does, to make - sure the right things get saved on the stack. Hence we don't - share its code. The only reason to push anything on the - stack at all is that otherwise we would have to change - `anychar's code to do something besides goto fail in this - case; that seems worse than this. */ - case on_failure_keep_string_jump: - DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt); - - PUSH_FAILURE_POINT (p + mcnt, NULL, -2); - break; - - - /* Uses of on_failure_jump: - - Each alternative starts with an on_failure_jump that points - to the beginning of the next alternative. Each alternative - except the last ends with a jump that in effect jumps past - the rest of the alternatives. (They really jump to the - ending jump of the following alternative, because tensioning - these jumps is a hassle.) - - Repeats start with an on_failure_jump that points past both - the repetition text and either the following jump or - pop_failure_jump back to this on_failure_jump. */ - case on_failure_jump: - on_failure: - DEBUG_PRINT1 ("EXECUTING on_failure_jump"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt); - - /* If this on_failure_jump comes right before a group (i.e., - the original * applied to a group), save the information - for that group and all inner ones, so that if we fail back - to this point, the group's information will be correct. - For example, in \(a*\)*\1, we need the preceding group, - and in \(\(a*\)b*\)\2, we need the inner group. */ - - /* We can't use `p' to check ahead because we push - a failure point to `p + mcnt' after we do this. */ - p1 = p; - - /* We need to skip no_op's before we look for the - start_memory in case this on_failure_jump is happening as - the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 - against aba. */ - while (p1 < pend && (re_opcode_t) *p1 == no_op) - p1++; - - if (p1 < pend && (re_opcode_t) *p1 == start_memory) - { - /* We have a new highest active register now. This will - get reset at the start_memory we are about to get to, - but we will have saved all the registers relevant to - this repetition op, as described above. */ - highest_active_reg = *(p1 + 1) + *(p1 + 2); - if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) - lowest_active_reg = *(p1 + 1); - } - - DEBUG_PRINT1 (":\n"); - PUSH_FAILURE_POINT (p + mcnt, d, -2); - break; - - - /* A smart repeat ends with `maybe_pop_jump'. - We change it to either `pop_failure_jump' or `jump'. */ - case maybe_pop_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); - { - register unsigned char *p2 = p; - - /* Compare the beginning of the repeat with what in the - pattern follows its end. If we can establish that there - is nothing that they would both match, i.e., that we - would have to backtrack because of (as in, e.g., `a*a') - then we can change to pop_failure_jump, because we'll - never have to backtrack. - - This is not true in the case of alternatives: in - `(a|ab)*' we do need to backtrack to the `ab' alternative - (e.g., if the string was `ab'). But instead of trying to - detect that here, the alternative has put on a dummy - failure point which is what we will end up popping. */ - - /* Skip over open/close-group commands. */ - while (p2 + 2 < pend - && ((re_opcode_t) *p2 == stop_memory - || (re_opcode_t) *p2 == start_memory)) - p2 += 3; /* Skip over args, too. */ - - /* If we're at the end of the pattern, we can change. */ - if (p2 == pend) - { - /* Consider what happens when matching ":\(.*\)" - against ":/". I don't really understand this code - yet. */ - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT1 - (" End of pattern: change to `pop_failure_jump'.\n"); - } - - else if ((re_opcode_t) *p2 == exactn - || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) - { - register unsigned char c - = *p2 == (unsigned char) endline ? '\n' : p2[2]; - p1 = p + mcnt; - - /* p1[0] ... p1[2] are the `on_failure_jump' corresponding - to the `maybe_finalize_jump' of this case. Examine what - follows. */ - if ((re_opcode_t) p1[3] == exactn && p1[5] != c) - { - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", - c, p1[5]); - } - - else if ((re_opcode_t) p1[3] == charset - || (re_opcode_t) p1[3] == charset_not) - { - int not = (re_opcode_t) p1[3] == charset_not; - - if (c < (unsigned char) (p1[4] * BYTEWIDTH) - && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - /* `not' is equal to 1 if c would match, which means - that we can't change to pop_failure_jump. */ - if (!not) - { - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); - } - } - } - } - p -= 2; /* Point at relative address again. */ - if ((re_opcode_t) p[-1] != pop_failure_jump) - { - p[-1] = (unsigned char) jump; - DEBUG_PRINT1 (" Match => jump.\n"); - goto unconditional_jump; - } - /* Note fall through. */ - - - /* The end of a simple repeat has a pop_failure_jump back to - its matching on_failure_jump, where the latter will push a - failure point. The pop_failure_jump takes off failure - points put on by this pop_failure_jump's matching - on_failure_jump; we got through the pattern to here from the - matching on_failure_jump, so didn't fail. */ - case pop_failure_jump: - { - /* We need to pass separate storage for the lowest and - highest registers, even though we don't care about the - actual values. Otherwise, we will restore only one - register from the stack, since lowest will == highest in - `pop_failure_point'. */ - unsigned dummy_low_reg, dummy_high_reg; - unsigned char *pdummy; - const char *sdummy; - - DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n"); - POP_FAILURE_POINT (sdummy, pdummy, - dummy_low_reg, dummy_high_reg, - reg_dummy, reg_dummy, reg_info_dummy); - } - /* Note fall through. */ - - - /* Unconditionally jump (without popping any failure points). */ - case jump: - unconditional_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ - DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); - p += mcnt; /* Do the jump. */ - DEBUG_PRINT2 ("(to 0x%x).\n", p); - break; - - - /* We need this opcode so we can detect where alternatives end - in `group_match_null_string_p' et al. */ - case jump_past_alt: - DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n"); - goto unconditional_jump; - - - /* Normally, the on_failure_jump pushes a failure point, which - then gets popped at pop_failure_jump. We will end up at - pop_failure_jump, also, and with a pattern of, say, `a+', we - are skipping over the on_failure_jump, so we have to push - something meaningless for pop_failure_jump to pop. */ - case dummy_failure_jump: - DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n"); - /* It doesn't matter what we push for the string here. What - the code at `fail' tests is the value for the pattern. */ - PUSH_FAILURE_POINT (0, 0, -2); - goto unconditional_jump; - - - /* At the end of an alternative, we need to push a dummy failure - point in case we are followed by a `pop_failure_jump', because - we don't want the failure point for the alternative to be - popped. For example, matching `(a|ab)*' against `aab' - requires that we match the `ab' alternative. */ - case push_dummy_failure: - DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); - /* See comments just above at `dummy_failure_jump' about the - two zeroes. */ - PUSH_FAILURE_POINT (0, 0, -2); - break; - - /* Have to succeed matching what follows at least n times. - After that, handle like `on_failure_jump'. */ - case succeed_n: - EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); - - assert (mcnt >= 0); - /* Originally, this is how many times we HAVE to succeed. */ - if (mcnt > 0) - { - mcnt--; - p += 2; - STORE_NUMBER_AND_INCR (p, mcnt); - DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p, mcnt); - } - else if (mcnt == 0) - { - DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2); - p[2] = (unsigned char) no_op; - p[3] = (unsigned char) no_op; - goto on_failure; - } - break; - - case jump_n: - EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); - - /* Originally, this is how many times we CAN jump. */ - if (mcnt) - { - mcnt--; - STORE_NUMBER (p + 2, mcnt); - goto unconditional_jump; - } - /* If don't have to jump any more, skip over the rest of command. */ - else - p += 4; - break; - - case set_number_at: - { - DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - p1 = p + mcnt; - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt); - STORE_NUMBER (p1, mcnt); - break; - } - - case wordbound: - DEBUG_PRINT1 ("EXECUTING wordbound.\n"); - if (AT_WORD_BOUNDARY (d)) - break; - goto fail; - - case notwordbound: - DEBUG_PRINT1 ("EXECUTING notwordbound.\n"); - if (AT_WORD_BOUNDARY (d)) - goto fail; - break; - - case wordbeg: - DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); - if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) - break; - goto fail; - - case wordend: - DEBUG_PRINT1 ("EXECUTING wordend.\n"); - if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) - && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) - break; - goto fail; - -#ifdef emacs -#ifdef emacs19 - case before_dot: - DEBUG_PRINT1 ("EXECUTING before_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) >= point) - goto fail; - break; - - case at_dot: - DEBUG_PRINT1 ("EXECUTING at_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) != point) - goto fail; - break; - - case after_dot: - DEBUG_PRINT1 ("EXECUTING after_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) <= point) - goto fail; - break; -#else /* not emacs19 */ - case at_dot: - DEBUG_PRINT1 ("EXECUTING at_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point) - goto fail; - break; -#endif /* not emacs19 */ - - case syntaxspec: - DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); - mcnt = *p++; - goto matchsyntax; - - case wordchar: - DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n"); - mcnt = (int) Sword; - matchsyntax: - PREFETCH (); - if (SYNTAX (*d++) != (enum syntaxcode) mcnt) - goto fail; - SET_REGS_MATCHED (); - break; - - case notsyntaxspec: - DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); - mcnt = *p++; - goto matchnotsyntax; - - case notwordchar: - DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n"); - mcnt = (int) Sword; - matchnotsyntax: - PREFETCH (); - if (SYNTAX (*d++) == (enum syntaxcode) mcnt) - goto fail; - SET_REGS_MATCHED (); - break; - -#else /* not emacs */ - case wordchar: - DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); - PREFETCH (); - if (!WORDCHAR_P (d)) - goto fail; - SET_REGS_MATCHED (); - d++; - break; - - case notwordchar: - DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); - PREFETCH (); - if (WORDCHAR_P (d)) - goto fail; - SET_REGS_MATCHED (); - d++; - break; -#endif /* not emacs */ - - default: - abort (); - } - continue; /* Successfully executed one pattern command; keep going. */ - - - /* We goto here if a matching operation fails. */ - fail: - if (!FAIL_STACK_EMPTY ()) - { /* A restart point is known. Restore to that state. */ - DEBUG_PRINT1 ("\nFAIL:\n"); - POP_FAILURE_POINT (d, p, - lowest_active_reg, highest_active_reg, - regstart, regend, reg_info); - - /* If this failure point is a dummy, try the next one. */ - if (!p) - goto fail; - - /* If we failed to the end of the pattern, don't examine *p. */ - assert (p <= pend); - if (p < pend) - { - boolean is_a_jump_n = false; - - /* If failed to a backwards jump that's part of a repetition - loop, need to pop this failure point and use the next one. */ - switch ((re_opcode_t) *p) - { - case jump_n: - is_a_jump_n = true; - case maybe_pop_jump: - case pop_failure_jump: - case jump: - p1 = p + 1; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - - if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n) - || (!is_a_jump_n - && (re_opcode_t) *p1 == on_failure_jump)) - goto fail; - break; - default: - /* do nothing */ ; - } - } - - if (d >= string1 && d <= end1) - dend = end_match_1; - } - else - break; /* Matching at this starting point really fails. */ - } /* for (;;) */ - - if (best_regs_set) - goto restore_best_regs; - - FREE_VARIABLES (); - - return -1; /* Failure to match. */ -} /* re_match_2 */ - -/* Subroutine definitions for re_match_2. */ - - -/* We are passed P pointing to a register number after a start_memory. - - Return true if the pattern up to the corresponding stop_memory can - match the empty string, and false otherwise. - - If we find the matching stop_memory, sets P to point to one past its number. - Otherwise, sets P to an undefined byte less than or equal to END. - - We don't handle duplicates properly (yet). */ - -static boolean -group_match_null_string_p (p, end, reg_info) - unsigned char **p, *end; - register_info_type *reg_info; -{ - int mcnt; - /* Point to after the args to the start_memory. */ - unsigned char *p1 = *p + 2; - - while (p1 < end) - { - /* Skip over opcodes that can match nothing, and return true or - false, as appropriate, when we get to one that can't, or to the - matching stop_memory. */ - - switch ((re_opcode_t) *p1) - { - /* Could be either a loop or a series of alternatives. */ - case on_failure_jump: - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - - /* If the next operation is not a jump backwards in the - pattern. */ - - if (mcnt >= 0) - { - /* Go through the on_failure_jumps of the alternatives, - seeing if any of the alternatives cannot match nothing. - The last alternative starts with only a jump, - whereas the rest start with on_failure_jump and end - with a jump, e.g., here is the pattern for `a|b|c': - - /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6 - /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3 - /exactn/1/c - - So, we have to first go through the first (n-1) - alternatives and then deal with the last one separately. */ - - - /* Deal with the first (n-1) alternatives, which start - with an on_failure_jump (see above) that jumps to right - past a jump_past_alt. */ - - while ((re_opcode_t) p1[mcnt-3] == jump_past_alt) - { - /* `mcnt' holds how many bytes long the alternative - is, including the ending `jump_past_alt' and - its number. */ - - if (!alt_match_null_string_p (p1, p1 + mcnt - 3, - reg_info)) - return false; - - /* Move to right after this alternative, including the - jump_past_alt. */ - p1 += mcnt; - - /* Break if it's the beginning of an n-th alternative - that doesn't begin with an on_failure_jump. */ - if ((re_opcode_t) *p1 != on_failure_jump) - break; - - /* Still have to check that it's not an n-th - alternative that starts with an on_failure_jump. */ - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if ((re_opcode_t) p1[mcnt-3] != jump_past_alt) - { - /* Get to the beginning of the n-th alternative. */ - p1 -= 3; - break; - } - } - - /* Deal with the last alternative: go back and get number - of the `jump_past_alt' just before it. `mcnt' contains - the length of the alternative. */ - EXTRACT_NUMBER (mcnt, p1 - 2); - - if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info)) - return false; - - p1 += mcnt; /* Get past the n-th alternative. */ - } /* if mcnt > 0 */ - break; - - - case stop_memory: - assert (p1[1] == **p); - *p = p1 + 2; - return true; - - - default: - if (!common_op_match_null_string_p (&p1, end, reg_info)) - return false; - } - } /* while p1 < end */ - - return false; -} /* group_match_null_string_p */ - - -/* Similar to group_match_null_string_p, but doesn't deal with alternatives: - It expects P to be the first byte of a single alternative and END one - byte past the last. The alternative can contain groups. */ - -static boolean -alt_match_null_string_p (p, end, reg_info) - unsigned char *p, *end; - register_info_type *reg_info; -{ - int mcnt; - unsigned char *p1 = p; - - while (p1 < end) - { - /* Skip over opcodes that can match nothing, and break when we get - to one that can't. */ - - switch ((re_opcode_t) *p1) - { - /* It's a loop. */ - case on_failure_jump: - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - break; - - default: - if (!common_op_match_null_string_p (&p1, end, reg_info)) - return false; - } - } /* while p1 < end */ - - return true; -} /* alt_match_null_string_p */ - - -/* Deals with the ops common to group_match_null_string_p and - alt_match_null_string_p. - - Sets P to one after the op and its arguments, if any. */ - -static boolean -common_op_match_null_string_p (p, end, reg_info) - unsigned char **p, *end; - register_info_type *reg_info; -{ - int mcnt; - boolean ret; - int reg_no; - unsigned char *p1 = *p; - - switch ((re_opcode_t) *p1++) - { - case no_op: - case begline: - case endline: - case begbuf: - case endbuf: - case wordbeg: - case wordend: - case wordbound: - case notwordbound: -#ifdef emacs - case before_dot: - case at_dot: - case after_dot: -#endif - break; - - case start_memory: - reg_no = *p1; - assert (reg_no > 0 && reg_no <= MAX_REGNUM); - ret = group_match_null_string_p (&p1, end, reg_info); - - /* Have to set this here in case we're checking a group which - contains a group and a back reference to it. */ - - if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE) - REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret; - - if (!ret) - return false; - break; - - /* If this is an optimized succeed_n for zero times, make the jump. */ - case jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if (mcnt >= 0) - p1 += mcnt; - else - return false; - break; - - case succeed_n: - /* Get to the number of times to succeed. */ - p1 += 2; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - - if (mcnt == 0) - { - p1 -= 4; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - } - else - return false; - break; - - case duplicate: - if (!REG_MATCH_NULL_STRING_P (reg_info[*p1])) - return false; - break; - - case set_number_at: - p1 += 4; - - default: - /* All other opcodes mean we cannot match the empty string. */ - return false; - } - - *p = p1; - return true; -} /* common_op_match_null_string_p */ - - -/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN - bytes; nonzero otherwise. */ - -static int -bcmp_translate (s1, s2, len, translate) - unsigned char *s1, *s2; - register int len; - char *translate; -{ - register unsigned char *p1 = s1, *p2 = s2; - while (len) - { - if (translate[*p1++] != translate[*p2++]) return 1; - len--; - } - return 0; -} - -/* Entry points for GNU code. */ - -/* re_compile_pattern is the GNU regular expression compiler: it - compiles PATTERN (of length SIZE) and puts the result in BUFP. - Returns 0 if the pattern was valid, otherwise an error string. - - Assumes the `allocated' (and perhaps `buffer') and `translate' fields - are set in BUFP on entry. - - We call regex_compile to do the actual compilation. */ - -const char * -re_compile_pattern (pattern, length, bufp) - const char *pattern; - int length; - struct re_pattern_buffer *bufp; -{ - reg_errcode_t ret; - - /* GNU code is written to assume at least RE_NREGS registers will be set - (and at least one extra will be -1). */ - bufp->regs_allocated = REGS_UNALLOCATED; - - /* And GNU code determines whether or not to get register information - by passing null for the REGS argument to re_match, etc., not by - setting no_sub. */ - bufp->no_sub = 0; - - /* Match anchors at newline. */ - bufp->newline_anchor = 1; - - ret = regex_compile (pattern, length, re_syntax_options, bufp); - - return re_error_msg[(int) ret]; -} - -/* Entry points compatible with 4.2 BSD regex library. We don't define - them if this is an Emacs or POSIX compilation. */ - -#if !defined (emacs) && !defined (_POSIX_SOURCE) - -/* BSD has one and only one pattern buffer. */ -static struct re_pattern_buffer re_comp_buf; - -char * -re_comp (s) - const char *s; -{ - reg_errcode_t ret; - - if (!s) - { - if (!re_comp_buf.buffer) - return "No previous regular expression"; - return 0; - } - - if (!re_comp_buf.buffer) - { - re_comp_buf.buffer = (unsigned char *) malloc (200); - if (re_comp_buf.buffer == NULL) - return "Memory exhausted"; - re_comp_buf.allocated = 200; - - re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); - if (re_comp_buf.fastmap == NULL) - return "Memory exhausted"; - } - - /* Since `re_exec' always passes NULL for the `regs' argument, we - don't need to initialize the pattern buffer fields which affect it. */ - - /* Match anchors at newlines. */ - re_comp_buf.newline_anchor = 1; - - ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); - - /* Yes, we're discarding `const' here. */ - return (char *) re_error_msg[(int) ret]; -} - - -int -re_exec (s) - const char *s; -{ - const int len = strlen (s); - return - 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); -} -#endif /* not emacs and not _POSIX_SOURCE */ - -/* POSIX.2 functions. Don't define these for Emacs. */ - -#ifndef emacs - -/* regcomp takes a regular expression as a string and compiles it. - - PREG is a regex_t *. We do not expect any fields to be initialized, - since POSIX says we shouldn't. Thus, we set - - `buffer' to the compiled pattern; - `used' to the length of the compiled pattern; - `syntax' to RE_SYNTAX_POSIX_EXTENDED if the - REG_EXTENDED bit in CFLAGS is set; otherwise, to - RE_SYNTAX_POSIX_BASIC; - `newline_anchor' to REG_NEWLINE being set in CFLAGS; - `fastmap' and `fastmap_accurate' to zero; - `re_nsub' to the number of subexpressions in PATTERN. - - PATTERN is the address of the pattern string. - - CFLAGS is a series of bits which affect compilation. - - If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we - use POSIX basic syntax. - - If REG_NEWLINE is set, then . and [^...] don't match newline. - Also, regexec will try a match beginning after every newline. - - If REG_ICASE is set, then we considers upper- and lowercase - versions of letters to be equivalent when matching. - - If REG_NOSUB is set, then when PREG is passed to regexec, that - routine will report only success or failure, and nothing about the - registers. - - It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for - the return codes and their meanings.) */ - -int -regcomp (preg, pattern, cflags) - regex_t *preg; - const char *pattern; - int cflags; -{ - reg_errcode_t ret; - unsigned syntax - = (cflags & REG_EXTENDED) ? - RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; - - /* regex_compile will allocate the space for the compiled pattern. */ - preg->buffer = 0; - preg->allocated = 0; - - /* Don't bother to use a fastmap when searching. This simplifies the - REG_NEWLINE case: if we used a fastmap, we'd have to put all the - characters after newlines into the fastmap. This way, we just try - every character. */ - preg->fastmap = 0; - - if (cflags & REG_ICASE) - { - unsigned i; - - preg->translate = (char *) malloc (CHAR_SET_SIZE); - if (preg->translate == NULL) - return (int) REG_ESPACE; - - /* Map uppercase characters to corresponding lowercase ones. */ - for (i = 0; i < CHAR_SET_SIZE; i++) - preg->translate[i] = ISUPPER (i) ? tolower (i) : i; - } - else - preg->translate = NULL; - - /* If REG_NEWLINE is set, newlines are treated differently. */ - if (cflags & REG_NEWLINE) - { /* REG_NEWLINE implies neither . nor [^...] match newline. */ - syntax &= ~RE_DOT_NEWLINE; - syntax |= RE_HAT_LISTS_NOT_NEWLINE; - /* It also changes the matching behavior. */ - preg->newline_anchor = 1; - } - else - preg->newline_anchor = 0; - - preg->no_sub = !!(cflags & REG_NOSUB); - - /* POSIX says a null character in the pattern terminates it, so we - can use strlen here in compiling the pattern. */ - ret = regex_compile (pattern, strlen (pattern), syntax, preg); - - /* POSIX doesn't distinguish between an unmatched open-group and an - unmatched close-group: both are REG_EPAREN. */ - if (ret == REG_ERPAREN) ret = REG_EPAREN; - - return (int) ret; -} - - -/* regexec searches for a given pattern, specified by PREG, in the - string STRING. - - If NMATCH is zero or REG_NOSUB was set in the cflags argument to - `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at - least NMATCH elements, and we set them to the offsets of the - corresponding matched substrings. - - EFLAGS specifies `execution flags' which affect matching: if - REG_NOTBOL is set, then ^ does not match at the beginning of the - string; if REG_NOTEOL is set, then $ does not match at the end. - - We return 0 if we find a match and REG_NOMATCH if not. */ - -int -regexec (preg, string, nmatch, pmatch, eflags) - const regex_t *preg; - const char *string; - size_t nmatch; - regmatch_t pmatch[]; - int eflags; -{ - int ret; - struct re_registers regs; - regex_t private_preg; - int len = strlen (string); - boolean want_reg_info = !preg->no_sub && nmatch > 0; - - private_preg = *preg; - - private_preg.not_bol = !!(eflags & REG_NOTBOL); - private_preg.not_eol = !!(eflags & REG_NOTEOL); - - /* The user has told us exactly how many registers to return - information about, via `nmatch'. We have to pass that on to the - matching routines. */ - private_preg.regs_allocated = REGS_FIXED; - - if (want_reg_info) - { - regs.num_regs = nmatch; - regs.start = TALLOC (nmatch, regoff_t); - regs.end = TALLOC (nmatch, regoff_t); - if (regs.start == NULL || regs.end == NULL) - return (int) REG_NOMATCH; - } - - /* Perform the searching operation. */ - ret = re_search (&private_preg, string, len, - /* start: */ 0, /* range: */ len, - want_reg_info ? ®s : (struct re_registers *) 0); - - /* Copy the register information to the POSIX structure. */ - if (want_reg_info) - { - if (ret >= 0) - { - unsigned r; - - for (r = 0; r < nmatch; r++) - { - pmatch[r].rm_so = regs.start[r]; - pmatch[r].rm_eo = regs.end[r]; - } - } - - /* If we needed the temporary register info, free the space now. */ - free (regs.start); - free (regs.end); - } - - /* We want zero return to mean success, unlike `re_search'. */ - return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH; -} - - -/* Returns a message corresponding to an error code, ERRCODE, returned - from either regcomp or regexec. We don't use PREG here. */ - -size_t -regerror (errcode, preg, errbuf, errbuf_size) - int errcode; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; -{ - const char *msg; - size_t msg_size; - - if (errcode < 0 - || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0]))) - /* Only error codes returned by the rest of the code should be passed - to this routine. If we are given anything else, or if other regex - code generates an invalid error code, then the program has a bug. - Dump core so we can fix it. */ - abort (); - - msg = re_error_msg[errcode]; - - /* POSIX doesn't require that we do anything in this case, but why - not be nice. */ - if (! msg) - msg = "Success"; - - msg_size = strlen (msg) + 1; /* Includes the null. */ - - if (errbuf_size != 0) - { - if (msg_size > errbuf_size) - { - strncpy (errbuf, msg, errbuf_size - 1); - errbuf[errbuf_size - 1] = 0; - } - else - strcpy (errbuf, msg); - } - - return msg_size; -} - - -/* Free dynamically allocated space used by PREG. */ - -void -regfree (preg) - regex_t *preg; -{ - if (preg->buffer != NULL) - free (preg->buffer); - preg->buffer = NULL; - - preg->allocated = 0; - preg->used = 0; - - if (preg->fastmap != NULL) - free (preg->fastmap); - preg->fastmap = NULL; - preg->fastmap_accurate = 0; - - if (preg->translate != NULL) - free (preg->translate); - preg->translate = NULL; -} - -#endif /* not emacs */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/regex-0.12/regex.h b/gnu/lib/regex-0.12/regex.h deleted file mode 100644 index 408dd210348f..000000000000 --- a/gnu/lib/regex-0.12/regex.h +++ /dev/null @@ -1,490 +0,0 @@ -/* Definitions for data structures and routines for the regular - expression library, version 0.12. - - Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 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. */ - -#ifndef __REGEXP_LIBRARY_H__ -#define __REGEXP_LIBRARY_H__ - -/* POSIX says that must be included (by the caller) before - . */ - -#ifdef VMS -/* VMS doesn't have `size_t' in , even though POSIX says it - should be there. */ -#include -#endif - - -/* The following bits are used to determine the regexp syntax we - recognize. The set/not-set meanings are chosen so that Emacs syntax - remains the value 0. The bits are given in alphabetical order, and - the definitions shifted by one from the previous bit; thus, when we - add or remove a bit, only one other definition need change. */ -typedef unsigned reg_syntax_t; - -/* If this bit is not set, then \ inside a bracket expression is literal. - If set, then such a \ quotes the following character. */ -#define RE_BACKSLASH_ESCAPE_IN_LISTS (1) - -/* If this bit is not set, then + and ? are operators, and \+ and \? are - literals. - If set, then \+ and \? are operators and + and ? are literals. */ -#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) - -/* 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 (RE_BK_PLUS_QM << 1) - -/* If this bit is set, then ^ and $ are always anchors (outside bracket - expressions, of course). - If this bit is not set, then it depends: - ^ is an anchor if it is at the beginning of a regular - expression or after an open-group or an alternation operator; - $ is an anchor if it is at the end of a regular expression, or - before a close-group or an alternation operator. - - This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because - POSIX draft 11.2 says that * etc. in leading positions is undefined. - We already implemented a previous draft which made those constructs - invalid, though, so we haven't changed the code back. */ -#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) - -/* If this bit is set, then special characters are always special - regardless of where they are in the pattern. - If this bit is not set, then special characters are special only in - some contexts; otherwise they are ordinary. Specifically, - * + ? and intervals are only special when not after the beginning, - open-group, or alternation operator. */ -#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) - -/* If this bit is set, then *, +, ?, and { cannot be first in an re or - immediately after an alternation or begin-group operator. */ -#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) - -/* If this bit is set, then . matches newline. - If not set, then it doesn't. */ -#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) - -/* If this bit is set, then . doesn't match NUL. - If not set, then it does. */ -#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) - -/* If this bit is set, nonmatching lists [^...] do not match newline. - If not set, they do. */ -#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) - -/* If this bit is set, either \{...\} or {...} defines an - interval, depending on RE_NO_BK_BRACES. - If not set, \{, \}, {, and } are literals. */ -#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) - -/* If this bit is set, +, ? and | aren't recognized as operators. - If not set, they are. */ -#define RE_LIMITED_OPS (RE_INTERVALS << 1) - -/* If this bit is set, newline is an alternation operator. - If not set, newline is literal. */ -#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) - -/* If this bit is set, then `{...}' defines an interval, and \{ and \} - are literals. - If not set, then `\{...\}' defines an interval. */ -#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) - -/* If this bit is set, (...) defines a group, and \( and \) are literals. - If not set, \(...\) defines a group, and ( and ) are literals. */ -#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) - -/* If this bit is set, then \ matches . - If not set, then \ is a back-reference. */ -#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) - -/* If this bit is set, then | is an alternation operator, and \| is literal. - If not set, then \| is an alternation operator, and | is literal. */ -#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) - -/* If this bit is set, then an ending range point collating higher - than the starting range point, as in [z-a], is invalid. - If not set, then when ending range point collates higher than the - starting range point, the range is ignored. */ -#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) - -/* If this bit is set, then an unmatched ) is ordinary. - If not set, then an unmatched ) is invalid. */ -#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) - -/* This global variable defines the particular regexp syntax to use (for - some interfaces). When a regexp is compiled, the syntax used is - stored in the pattern buffer, so changing this does not affect - already-compiled regexps. */ -extern reg_syntax_t re_syntax_options; - -/* Define combinations of the above bits for the standard possibilities. - (The [[[ comments delimit what gets put into the Texinfo file, so - don't delete them!) */ -/* [[[begin syntaxes]]] */ -#define RE_SYNTAX_EMACS 0 - -#define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -#define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) - -#define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - -#define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - -#define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) - -/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ -#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - -#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - -/* Syntax bits common to both basic and extended POSIX regex syntax. */ -#define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - -#define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) - -/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ -#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - -#define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS - replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ -#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) -/* [[[end syntaxes]]] */ - -/* Maximum number of duplicates an interval can allow. Some systems - (erroneously) define this in other header files, but we want our - value, so remove any previous define. */ -#ifdef RE_DUP_MAX -#undef RE_DUP_MAX -#endif -#define RE_DUP_MAX ((1 << 15) - 1) - - -/* POSIX `cflags' bits (i.e., information for `regcomp'). */ - -/* If this bit is set, then use extended regular expression syntax. - If not set, then use basic regular expression syntax. */ -#define REG_EXTENDED 1 - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -#define REG_ICASE (REG_EXTENDED << 1) - -/* If this bit is set, then anchors do not match at newline - characters in the string. - If not set, then anchors do match at newlines. */ -#define REG_NEWLINE (REG_ICASE << 1) - -/* If this bit is set, then report only success or fail in regexec. - If not set, then returns differ between not matching and errors. */ -#define REG_NOSUB (REG_NEWLINE << 1) - - -/* POSIX `eflags' bits (i.e., information for regexec). */ - -/* If this bit is set, then the beginning-of-line operator doesn't match - the beginning of the string (presumably because it's not the - beginning of a line). - If not set, then the beginning-of-line operator does match the - beginning of the string. */ -#define REG_NOTBOL 1 - -/* Like REG_NOTBOL, except for the end-of-line. */ -#define REG_NOTEOL (1 << 1) - - -/* If any error codes are removed, changed, or added, update the - `re_error_msg' table in regex.c. */ -typedef enum -{ - REG_NOERROR = 0, /* Success. */ - REG_NOMATCH, /* Didn't find a match (for regexec). */ - - /* POSIX regcomp return error codes. (In the order listed in the - standard.) */ - REG_BADPAT, /* Invalid pattern. */ - REG_ECOLLATE, /* Not implemented. */ - REG_ECTYPE, /* Invalid character class name. */ - REG_EESCAPE, /* Trailing backslash. */ - REG_ESUBREG, /* Invalid back reference. */ - REG_EBRACK, /* Unmatched left bracket. */ - REG_EPAREN, /* Parenthesis imbalance. */ - REG_EBRACE, /* Unmatched \{. */ - REG_BADBR, /* Invalid contents of \{\}. */ - REG_ERANGE, /* Invalid range end. */ - REG_ESPACE, /* Ran out of memory. */ - REG_BADRPT, /* No preceding re for repetition op. */ - - /* Error codes we've added. */ - REG_EEND, /* Premature end. */ - REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ - REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ -} reg_errcode_t; - -/* This data structure represents a compiled pattern. Before calling - the pattern compiler, the fields `buffer', `allocated', `fastmap', - `translate', and `no_sub' can be set. After the pattern has been - compiled, the `re_nsub' field is available. All other fields are - private to the regex routines. */ - -struct re_pattern_buffer -{ -/* [[[begin pattern_buffer]]] */ - /* Space that holds the compiled pattern. It is declared as - `unsigned char *' because its elements are - sometimes used as array indexes. */ - unsigned char *buffer; - - /* Number of bytes to which `buffer' points. */ - unsigned long allocated; - - /* Number of bytes actually used in `buffer'. */ - unsigned long used; - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t syntax; - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses - the fastmap, if there is one, to skip over impossible - starting points for matches. */ - char *fastmap; - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation - is applied to a pattern when it is compiled and to a string - when it is matched. */ - char *translate; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in `re_search_2', to see - whether or not we should use the fastmap, so we don't set - this absolutely perfectly; see `re_compile_fastmap' (the - `duplicate' case). */ - unsigned can_be_null : 1; - - /* If REGS_UNALLOCATED, allocate space in the `regs' structure - for `max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ -#define REGS_UNALLOCATED 0 -#define REGS_REALLOCATE 1 -#define REGS_FIXED 2 - unsigned regs_allocated : 2; - - /* Set to zero when `regex_compile' compiles a pattern; set to one - by `re_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; - - /* If set, `re_match_2' does not return information about - subexpressions. */ - unsigned no_sub : 1; - - /* If set, a beginning-of-line anchor doesn't match at the - beginning of the string. */ - unsigned not_bol : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned not_eol : 1; - - /* If true, an anchor at a newline matches. */ - unsigned newline_anchor : 1; - -/* [[[end pattern_buffer]]] */ -}; - -typedef struct re_pattern_buffer regex_t; - - -/* search.c (search_buffer) in Emacs needs this one opcode value. It is - defined both in `regex.c' and here. */ -#define RE_EXACTN_VALUE 1 - -/* Type for byte offsets within the string. POSIX mandates this. */ -typedef int regoff_t; - - -/* This is the structure we store register match data in. See - regex.texinfo for a full description of what registers match. */ -struct re_registers -{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -}; - - -/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, - `re_match_2' returns information about at least this many registers - the first time a `regs' structure is passed. */ -#ifndef RE_NREGS -#define RE_NREGS 30 -#endif - - -/* POSIX specification for registers. Aside from the different names than - `re_registers', POSIX uses an array of structures, instead of a - structure of arrays. */ -typedef struct -{ - regoff_t rm_so; /* Byte offset from string's start to substring's start. */ - regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ -} regmatch_t; - -/* Declarations for routines. */ - -/* To avoid duplicating every routine declaration -- once with a - prototype (if we are ANSI), and once without (if we aren't) -- we - use the following macro to declare argument types. This - unfortunately clutters up the declarations a bit, but I think it's - worth it. */ - -#if __STDC__ - -#define _RE_ARGS(args) args - -#else /* not __STDC__ */ - -#define _RE_ARGS(args) () - -#endif /* not __STDC__ */ - -/* Sets the current default syntax to SYNTAX, and return the old syntax. - You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); - -/* Compile the regular expression PATTERN, with length LENGTH - and syntax given by the global `re_syntax_options', into the buffer - BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern - _RE_ARGS ((const char *pattern, int length, - struct re_pattern_buffer *buffer)); - - -/* Compile a fastmap for the compiled pattern in BUFFER; used to - accelerate searches. Return 0 if successful and -2 if was an - internal error. */ -extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); - - -/* Search in the string STRING (with length LENGTH) for the pattern - compiled into BUFFER. Start searching at position START, for RANGE - characters. Return the starting position of the match, -1 for no - match, or -2 for an internal error. Also return register - information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, int range, struct re_registers *regs)); - - -/* Like `re_search', but search in the concatenation of STRING1 and - STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, int range, struct re_registers *regs, int stop)); - - -/* Like `re_search', but return how many characters in STRING the regexp - in BUFFER matched, starting at position START. */ -extern int re_match - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, struct re_registers *regs)); - - -/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int re_match_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, struct re_registers *regs, int stop)); - - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using BUFFER and REGS will use this memory - for recording register information. STARTS and ENDS must be - allocated with malloc, and must each be at least `NUM_REGS * sizeof - (regoff_t)' bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ -extern void re_set_registers - _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, regoff_t *starts, regoff_t *ends)); - -/* 4.2 bsd compatibility. */ -extern char *re_comp _RE_ARGS ((const char *)); -extern int re_exec _RE_ARGS ((const char *)); - -/* POSIX compatibility. */ -extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags)); -extern int regexec - _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch, - regmatch_t pmatch[], int eflags)); -extern size_t regerror - _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf, - size_t errbuf_size)); -extern void regfree _RE_ARGS ((regex_t *preg)); - -#endif /* not __REGEXP_LIBRARY_H__ */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/regex-0.12/test/debugmalloc.c b/gnu/lib/regex-0.12/test/debugmalloc.c deleted file mode 100644 index 5c468e212439..000000000000 --- a/gnu/lib/regex-0.12/test/debugmalloc.c +++ /dev/null @@ -1,273 +0,0 @@ -/* debugmalloc.c: a malloc for debugging purposes. */ - -#include -#include -#include - -static unsigned trace = 0; -#define TRACE(s) if (trace) fprintf (stderr, "%s", s) -#define TRACE1(s, e1) if (trace) fprintf (stderr, s, e1) -#define TRACE2(s, e1, e2) if (trace) fprintf (stderr, s, e1, e2) -#define TRACE3(s, e1, e2, e3) if (trace) fprintf (stderr, s, e1, e2, e3) -#define TRACE4(s, e1, e2, e3, e4) \ - if (trace) fprintf (stderr, s, e1, e2, e3, e4) - -typedef char *address; - - -/* Wrap our calls to sbrk. */ - -address -xsbrk (incr) - int incr; -{ - extern char *sbrk (); - address ret = sbrk (incr); - - if (ret == (address) -1) - { - perror ("sbrk"); /* Actually, we should return NULL, not quit. */ - abort (); - } - - return ret; -} - - - -typedef struct chunk_struct -{ - /* This is the size (in bytes) that has actually been actually - allocated, not the size that the user requested. */ - unsigned alloc_size; - - /* This is the size the user requested. */ - unsigned user_size; - - /* Points to the next block in one of the lists. */ - struct chunk_struct *next; - - /* Now comes the user's memory. */ - address user_mem; - - /* After the user's memory is a constant. */ -} *chunk; - -#define MALLOC_OVERHEAD 16 - -/* We might play around with the `user_size' field, but the amount of - memory that is actually available in the chunk is always the size - allocated minus the overhead. */ -#define USER_ALLOC(c) ((c)->alloc_size - MALLOC_OVERHEAD) - -/* Given a pointer to a malloc-allocated block, the beginning of the - chunk should always be MALLOC_OVERHEAD - 4 bytes back, since the only - overhead after the user memory is the constant. */ - -chunk -mem_to_chunk (mem) - address mem; -{ - return (chunk) (mem - (MALLOC_OVERHEAD - 4)); -} - - -/* The other direction is even easier, since the user's memory starts at - the `user_mem' member in the chunk. */ - -address -chunk_to_mem (c) - chunk c; -{ - return (address) &(c->user_mem); -} - - - -/* We keep both all the allocated chunks and all the free chunks on - lists. Since we put the next pointers in the chunk structure, we - don't need a separate chunk_list structure. */ -chunk alloc_list = NULL, free_list = NULL; - - -/* We always append the new chunk at the beginning of the list. */ - -void -chunk_insert (chunk_list, new_c) - chunk *chunk_list; - chunk new_c; -{ - chunk c = *chunk_list; /* old beginning of list */ - - TRACE3 (" Inserting 0x%x at the beginning of 0x%x, before 0x%x.\n", - new_c, chunk_list, c); - - *chunk_list = new_c; - new_c->next = c; -} - - -/* Thus, removing an element means we have to search until we find it. - Have to delete before we insert, since insertion changes the next - pointer, which we need to put it on the other list. */ - -void -chunk_delete (chunk_list, dead_c) - chunk *chunk_list; - chunk dead_c; -{ - chunk c = *chunk_list; - chunk prev_c = NULL; - - TRACE2 (" Deleting 0x%x from 0x%x:", dead_c, chunk_list); - - while (c != dead_c && c != NULL) - { - TRACE1 (" 0x%x", c); - prev_c = c; - c = c->next; - } - - if (c == NULL) - { - fprintf (stderr, "Chunk at 0x%x not found on list.\n", dead_c); - abort (); - } - - if (prev_c == NULL) - { - TRACE1 (".\n Setting head to 0x%x.\n", c->next); - *chunk_list = c->next; - } - else - { - TRACE2 (".\n Linking next(0x%x) to 0x%x.\n", prev_c, c->next); - prev_c->next = c->next; - } -} - - -/* See if a list is hunky-dory. */ - -void -validate_list (chunk_list) - chunk *chunk_list; -{ - chunk c; - - TRACE1 (" Validating list at 0x%x:", chunk_list); - - for (c = *chunk_list; c != NULL; c = c->next) - { - assert (c->user_size < c->alloc_size); - assert (memcmp (chunk_to_mem (c) + c->user_size, "Karl", 4)); - TRACE2 (" 0x%x/%d", c, c->user_size); - } - - TRACE (".\n"); -} - - -/* See if we have a free chunk of a given size. We'll take the first - one that is big enough. */ - -chunk -free_list_available (needed) - unsigned needed; -{ - chunk c; - - TRACE1 (" Checking free list for %d bytes:", needed); - - if (free_list == NULL) - { - return NULL; - } - - c = free_list; - - while (c != NULL && USER_ALLOC (c) < needed) - { - TRACE2 (" 0x%x/%d", c, USER_ALLOC (c)); - c = c->next; - } - - TRACE1 ("\n Returning 0x%x.\n", c); - return c; -} - - - - -address -malloc (n) - unsigned n; -{ - address new_mem; - chunk c; - - TRACE1 ("Mallocing %d bytes.\n", n); - - validate_list (&free_list); - validate_list (&alloc_list); - - c = free_list_available (n); - - if (c == NULL) - { /* Nothing suitable on free list. Allocate a new chunk. */ - TRACE (" not on free list.\n"); - c = (chunk) xsbrk (n + MALLOC_OVERHEAD); - c->alloc_size = n + MALLOC_OVERHEAD; - } - else - { /* Found something on free list. Don't split it, just use as is. */ - TRACE (" found on free list.\n"); - chunk_delete (&free_list, c); - } - - /* If we took this from the free list, then the user size might be - different now, and consequently the constant at the end might be in - the wrong place. */ - c->user_size = n; - new_mem = chunk_to_mem (c); - memcpy (new_mem + n, "Karl", 4); - chunk_insert (&alloc_list, c); - - TRACE2 ("Malloc returning 0x%x (chunk 0x%x).\n", new_mem, c); - return new_mem; -} - - -address -realloc (mem, n) - address mem; - unsigned n; -{ - void free (); - chunk c = mem_to_chunk (mem); - address new_mem; - - TRACE3 ("Reallocing %d bytes at 0x%x (chunk 0x%x).\n", n, mem, c); - - new_mem = malloc (n); - memcpy (new_mem, mem, c->user_size); - free (mem); - - return new_mem; -} - - -void -free (mem) - address mem; -{ - chunk c = mem_to_chunk (mem); - - TRACE2 ("Freeing memory at 0x%x (chunk at 0x%x).\n", mem, c); - - validate_list (&free_list); - validate_list (&alloc_list); - - chunk_delete (&alloc_list, c); - chunk_insert (&free_list, c); -} diff --git a/gnu/lib/regex-0.12/test/emacsmalloc.c b/gnu/lib/regex-0.12/test/emacsmalloc.c deleted file mode 100644 index 6eee1fae1acb..000000000000 --- a/gnu/lib/regex-0.12/test/emacsmalloc.c +++ /dev/null @@ -1,844 +0,0 @@ -/* dynamic memory allocation for GNU. - Copyright (C) 1985, 1987 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 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. - -In other words, you are welcome to use, share and improve this program. -You are forbidden to forbid anyone else to use, share and improve -what you give them. Help stamp out software-hoarding! */ - - -/* - * @(#)nmalloc.c 1 (Caltech) 2/21/82 - * - * U of M Modified: 20 Jun 1983 ACT: strange hacks for Emacs - * - * Nov 1983, Mike@BRL, Added support for 4.1C/4.2 BSD. - * - * This is a very fast storage allocator. It allocates blocks of a small - * number of different sizes, and keeps free lists of each size. Blocks - * that don't exactly fit are passed up to the next larger size. In this - * implementation, the available sizes are (2^n)-4 (or -16) bytes long. - * This is designed for use in a program that uses vast quantities of - * memory, but bombs when it runs out. To make it a little better, it - * warns the user when he starts to get near the end. - * - * June 84, ACT: modified rcheck code to check the range given to malloc, - * rather than the range determined by the 2-power used. - * - * Jan 85, RMS: calls malloc_warning to issue warning on nearly full. - * No longer Emacs-specific; can serve as all-purpose malloc for GNU. - * You should call malloc_init to reinitialize after loading dumped Emacs. - * Call malloc_stats to get info on memory stats if MSTATS turned on. - * realloc knows how to return same block given, just changing its size, - * if the power of 2 is correct. - */ - -/* - * nextf[i] is the pointer to the next free block of size 2^(i+3). The - * smallest allocatable block is 8 bytes. The overhead information will - * go in the first int of the block, and the returned pointer will point - * to the second. - * -#ifdef MSTATS - * nmalloc[i] is the difference between the number of mallocs and frees - * for a given block size. -#endif MSTATS - */ - -#ifdef emacs -/* config.h specifies which kind of system this is. */ -#include "config.h" -#include -#else - -/* Determine which kind of system this is. */ -#include -#include - -#include -#define bcopy(s,d,n) memcpy ((d), (s), (n)) -#define bcmp(s1,s2,n) memcmp ((s1), (s2), (n)) -#define bzero(s,n) memset ((s), 0, (n)) - -#ifndef SIGTSTP -#ifndef VMS -#ifndef USG -#define USG -#endif -#endif /* not VMS */ -#else /* SIGTSTP */ -#ifdef SIGIO -#define BSD4_2 -#endif /* SIGIO */ -#endif /* SIGTSTP */ - -#endif /* not emacs */ - -/* Define getpagesize () if the system does not. */ -#include "getpagesize.h" - -#ifdef BSD -#ifdef BSD4_1 -#include /* warn the user when near the end */ -#else /* if 4.2 or newer */ -#include -#include -#endif /* if 4.2 or newer */ -#endif - -#ifdef VMS -#include "vlimit.h" -#endif - -extern char *start_of_data (); - -#ifdef BSD -#ifndef DATA_SEG_BITS -#define start_of_data() &etext -#endif -#endif - -#ifndef emacs -#define start_of_data() &etext -#endif - -#define ISALLOC ((char) 0xf7) /* magic byte that implies allocation */ -#define ISFREE ((char) 0x54) /* magic byte that implies free block */ - /* this is for error checking only */ -#define ISMEMALIGN ((char) 0xd6) /* Stored before the value returned by - memalign, with the rest of the word - being the distance to the true - beginning of the block. */ - -extern char etext; - -/* These two are for user programs to look at, when they are interested. */ - -unsigned int malloc_sbrk_used; /* amount of data space used now */ -unsigned int malloc_sbrk_unused; /* amount more we can have */ - -/* start of data space; can be changed by calling init_malloc */ -static char *data_space_start; - -#ifdef MSTATS -static int nmalloc[30]; -static int nmal, nfre; -#endif /* MSTATS */ - -/* If range checking is not turned on, all we have is a flag indicating - whether memory is allocated, an index in nextf[], and a size field; to - realloc() memory we copy either size bytes or 1<<(index+3) bytes depending - on whether the former can hold the exact size (given the value of - 'index'). If range checking is on, we always need to know how much space - is allocated, so the 'size' field is never used. */ - -struct mhead { - char mh_alloc; /* ISALLOC or ISFREE */ - char mh_index; /* index in nextf[] */ -/* Remainder are valid only when block is allocated */ - unsigned short mh_size; /* size, if < 0x10000 */ -#ifdef rcheck - unsigned mh_nbytes; /* number of bytes allocated */ - int mh_magic4; /* should be == MAGIC4 */ -#endif /* rcheck */ -}; - -/* Access free-list pointer of a block. - It is stored at block + 4. - This is not a field in the mhead structure - because we want sizeof (struct mhead) - to describe the overhead for when the block is in use, - and we do not want the free-list pointer to count in that. */ - -#define CHAIN(a) \ - (*(struct mhead **) (sizeof (char *) + (char *) (a))) - -#ifdef rcheck - -/* To implement range checking, we write magic values in at the beginning and - end of each allocated block, and make sure they are undisturbed whenever a - free or a realloc occurs. */ -/* Written in each of the 4 bytes following the block's real space */ -#define MAGIC1 0x55 -/* Written in the 4 bytes before the block's real space */ -#define MAGIC4 0x55555555 -#define ASSERT(p) if (!(p)) botch("p"); else -#define EXTRA 4 /* 4 bytes extra for MAGIC1s */ -#else -#define ASSERT(p) if (!(p)) abort (); else -#define EXTRA 0 -#endif /* rcheck */ - - -/* nextf[i] is free list of blocks of size 2**(i + 3) */ - -static struct mhead *nextf[30]; - -/* busy[i] is nonzero while allocation of block size i is in progress. */ - -static char busy[30]; - -/* Number of bytes of writable memory we can expect to be able to get */ -static unsigned int lim_data; - -/* Level number of warnings already issued. - 0 -- no warnings issued. - 1 -- 75% warning already issued. - 2 -- 85% warning already issued. -*/ -static int warnlevel; - -/* Function to call to issue a warning; - 0 means don't issue them. */ -static void (*warnfunction) (); - -/* nonzero once initial bunch of free blocks made */ -static int gotpool; - -char *_malloc_base; - -static void getpool (); - -/* Cause reinitialization based on job parameters; - also declare where the end of pure storage is. */ -void -malloc_init (start, warnfun) - char *start; - void (*warnfun) (); -{ - if (start) - data_space_start = start; - lim_data = 0; - warnlevel = 0; - warnfunction = warnfun; -} - -/* Return the maximum size to which MEM can be realloc'd - without actually requiring copying. */ - -int -malloc_usable_size (mem) - char *mem; -{ - struct mhead *p - = (struct mhead *) (mem - ((sizeof (struct mhead) + 7) & ~7)); - int blocksize = 8 << p->mh_index; - - return blocksize - sizeof (struct mhead) - EXTRA; -} - -static void -morecore (nu) /* ask system for more memory */ - register int nu; /* size index to get more of */ -{ - char *sbrk (); - register char *cp; - register int nblks; - register unsigned int siz; - int oldmask; - -#ifdef BSD -#ifndef BSD4_1 - int newmask = -1; - /* Blocking these signals interferes with debugging, at least on BSD on - the HP 9000/300. */ -#ifdef SIGTRAP - newmask &= ~(1 << SIGTRAP); -#endif -#ifdef SIGILL - newmask &= ~(1 << SIGILL); -#endif -#ifdef SIGTSTP - newmask &= ~(1 << SIGTSTP); -#endif -#ifdef SIGSTOP - newmask &= ~(1 << SIGSTOP); -#endif - oldmask = sigsetmask (newmask); -#endif -#endif - - if (!data_space_start) - { - data_space_start = start_of_data (); - } - - if (lim_data == 0) - get_lim_data (); - - /* On initial startup, get two blocks of each size up to 1k bytes */ - if (!gotpool) - { getpool (); getpool (); gotpool = 1; } - - /* Find current end of memory and issue warning if getting near max */ - -#ifndef VMS - /* Maximum virtual memory on VMS is difficult to calculate since it - * depends on several dynmacially changing things. Also, alignment - * isn't that important. That is why much of the code here is ifdef'ed - * out for VMS systems. - */ - cp = sbrk (0); - siz = cp - data_space_start; - - if (warnfunction) - switch (warnlevel) - { - case 0: - if (siz > (lim_data / 4) * 3) - { - warnlevel++; - (*warnfunction) ("Warning: past 75% of memory limit"); - } - break; - case 1: - if (siz > (lim_data / 20) * 17) - { - warnlevel++; - (*warnfunction) ("Warning: past 85% of memory limit"); - } - break; - case 2: - if (siz > (lim_data / 20) * 19) - { - warnlevel++; - (*warnfunction) ("Warning: past 95% of memory limit"); - } - break; - } - - if ((int) cp & 0x3ff) /* land on 1K boundaries */ - sbrk (1024 - ((int) cp & 0x3ff)); -#endif /* not VMS */ - - /* Take at least 2k, and figure out how many blocks of the desired size - we're about to get */ - nblks = 1; - if ((siz = nu) < 8) - nblks = 1 << ((siz = 8) - nu); - - if ((cp = sbrk (1 << (siz + 3))) == (char *) -1) - { -#ifdef BSD -#ifndef BSD4_1 - sigsetmask (oldmask); -#endif -#endif - return; /* no more room! */ - } - malloc_sbrk_used = siz; - malloc_sbrk_unused = lim_data - siz; - -#ifndef VMS - if ((int) cp & 7) - { /* shouldn't happen, but just in case */ - cp = (char *) (((int) cp + 8) & ~7); - nblks--; - } -#endif /* not VMS */ - - /* save new header and link the nblks blocks together */ - nextf[nu] = (struct mhead *) cp; - siz = 1 << (nu + 3); - while (1) - { - ((struct mhead *) cp) -> mh_alloc = ISFREE; - ((struct mhead *) cp) -> mh_index = nu; - if (--nblks <= 0) break; - CHAIN ((struct mhead *) cp) = (struct mhead *) (cp + siz); - cp += siz; - } - CHAIN ((struct mhead *) cp) = 0; - -#ifdef BSD -#ifndef BSD4_1 - sigsetmask (oldmask); -#endif -#endif -} - -static void -getpool () -{ - register int nu; - char * sbrk (); - register char *cp = sbrk (0); - - if ((int) cp & 0x3ff) /* land on 1K boundaries */ - sbrk (1024 - ((int) cp & 0x3ff)); - - /* Record address of start of space allocated by malloc. */ - if (_malloc_base == 0) - _malloc_base = cp; - - /* Get 2k of storage */ - - cp = sbrk (04000); - if (cp == (char *) -1) - return; - - /* Divide it into an initial 8-word block - plus one block of size 2**nu for nu = 3 ... 10. */ - - CHAIN (cp) = nextf[0]; - nextf[0] = (struct mhead *) cp; - ((struct mhead *) cp) -> mh_alloc = ISFREE; - ((struct mhead *) cp) -> mh_index = 0; - cp += 8; - - for (nu = 0; nu < 7; nu++) - { - CHAIN (cp) = nextf[nu]; - nextf[nu] = (struct mhead *) cp; - ((struct mhead *) cp) -> mh_alloc = ISFREE; - ((struct mhead *) cp) -> mh_index = nu; - cp += 8 << nu; - } -} - -char * -malloc (n) /* get a block */ - unsigned n; -{ - register struct mhead *p; - register unsigned int nbytes; - register int nunits = 0; - - /* Figure out how many bytes are required, rounding up to the nearest - multiple of 8, then figure out which nestf[] area to use. - Both the beginning of the header and the beginning of the - block should be on an eight byte boundary. */ - nbytes = (n + ((sizeof *p + 7) & ~7) + EXTRA + 7) & ~7; - { - register unsigned int shiftr = (nbytes - 1) >> 2; - - while (shiftr >>= 1) - nunits++; - } - - /* In case this is reentrant use of malloc from signal handler, - pick a block size that no other malloc level is currently - trying to allocate. That's the easiest harmless way not to - interfere with the other level of execution. */ - while (busy[nunits]) nunits++; - busy[nunits] = 1; - - /* If there are no blocks of the appropriate size, go get some */ - /* COULD SPLIT UP A LARGER BLOCK HERE ... ACT */ - if (nextf[nunits] == 0) - morecore (nunits); - - /* Get one block off the list, and set the new list head */ - if ((p = nextf[nunits]) == 0) - { - busy[nunits] = 0; - return 0; - } - nextf[nunits] = CHAIN (p); - busy[nunits] = 0; - - /* Check for free block clobbered */ - /* If not for this check, we would gobble a clobbered free chain ptr */ - /* and bomb out on the NEXT allocate of this size block */ - if (p -> mh_alloc != ISFREE || p -> mh_index != nunits) -#ifdef rcheck - botch ("block on free list clobbered"); -#else /* not rcheck */ - abort (); -#endif /* not rcheck */ - - /* Fill in the info, and if range checking, set up the magic numbers */ - p -> mh_alloc = ISALLOC; -#ifdef rcheck - p -> mh_nbytes = n; - p -> mh_magic4 = MAGIC4; - { - /* Get the location n after the beginning of the user's space. */ - register char *m = (char *) p + ((sizeof *p + 7) & ~7) + n; - - *m++ = MAGIC1, *m++ = MAGIC1, *m++ = MAGIC1, *m = MAGIC1; - } -#else /* not rcheck */ - p -> mh_size = n; -#endif /* not rcheck */ -#ifdef MSTATS - nmalloc[nunits]++; - nmal++; -#endif /* MSTATS */ - return (char *) p + ((sizeof *p + 7) & ~7); -} - -free (mem) - char *mem; -{ - register struct mhead *p; - { - register char *ap = mem; - - if (ap == 0) - return; - - p = (struct mhead *) (ap - ((sizeof *p + 7) & ~7)); - if (p -> mh_alloc == ISMEMALIGN) - { - ap -= p->mh_size; - p = (struct mhead *) (ap - ((sizeof *p + 7) & ~7)); - } - -#ifndef rcheck - if (p -> mh_alloc != ISALLOC) - abort (); - -#else rcheck - if (p -> mh_alloc != ISALLOC) - { - if (p -> mh_alloc == ISFREE) - botch ("free: Called with already freed block argument\n"); - else - botch ("free: Called with bad argument\n"); - } - - ASSERT (p -> mh_magic4 == MAGIC4); - ap += p -> mh_nbytes; - ASSERT (*ap++ == MAGIC1); ASSERT (*ap++ == MAGIC1); - ASSERT (*ap++ == MAGIC1); ASSERT (*ap == MAGIC1); -#endif /* rcheck */ - } - { - register int nunits = p -> mh_index; - - ASSERT (nunits <= 29); - p -> mh_alloc = ISFREE; - - /* Protect against signal handlers calling malloc. */ - busy[nunits] = 1; - /* Put this block on the free list. */ - CHAIN (p) = nextf[nunits]; - nextf[nunits] = p; - busy[nunits] = 0; - -#ifdef MSTATS - nmalloc[nunits]--; - nfre++; -#endif /* MSTATS */ - } -} - -char * -realloc (mem, n) - char *mem; - register unsigned n; -{ - register struct mhead *p; - register unsigned int tocopy; - register unsigned int nbytes; - register int nunits; - - if (mem == 0) - return malloc (n); - p = (struct mhead *) (mem - ((sizeof *p + 7) & ~7)); - nunits = p -> mh_index; - ASSERT (p -> mh_alloc == ISALLOC); -#ifdef rcheck - ASSERT (p -> mh_magic4 == MAGIC4); - { - register char *m = mem + (tocopy = p -> mh_nbytes); - ASSERT (*m++ == MAGIC1); ASSERT (*m++ == MAGIC1); - ASSERT (*m++ == MAGIC1); ASSERT (*m == MAGIC1); - } -#else /* not rcheck */ - if (p -> mh_index >= 13) - tocopy = (1 << (p -> mh_index + 3)) - ((sizeof *p + 7) & ~7); - else - tocopy = p -> mh_size; -#endif /* not rcheck */ - - /* See if desired size rounds to same power of 2 as actual size. */ - nbytes = (n + ((sizeof *p + 7) & ~7) + EXTRA + 7) & ~7; - - /* If ok, use the same block, just marking its size as changed. */ - if (nbytes > (4 << nunits) && nbytes <= (8 << nunits)) - { -#ifdef rcheck - register char *m = mem + tocopy; - *m++ = 0; *m++ = 0; *m++ = 0; *m++ = 0; - p-> mh_nbytes = n; - m = mem + n; - *m++ = MAGIC1; *m++ = MAGIC1; *m++ = MAGIC1; *m++ = MAGIC1; -#else /* not rcheck */ - p -> mh_size = n; -#endif /* not rcheck */ - return mem; - } - - if (n < tocopy) - tocopy = n; - { - register char *new; - - if ((new = malloc (n)) == 0) - return 0; - bcopy (mem, new, tocopy); - free (mem); - return new; - } -} - -/* This is in case something linked with Emacs calls calloc. */ - -char * -calloc (num, size) - unsigned num, size; -{ - register char *mem; - - num *= size; - mem = malloc (num); - if (mem != 0) - bzero (mem, num); - return mem; -} - -#ifndef VMS - -char * -memalign (alignment, size) - unsigned alignment, size; -{ - register char *ptr = malloc (size + alignment); - register char *aligned; - register struct mhead *p; - - if (ptr == 0) - return 0; - /* If entire block has the desired alignment, just accept it. */ - if (((int) ptr & (alignment - 1)) == 0) - return ptr; - /* Otherwise, get address of byte in the block that has that alignment. */ - aligned = (char *) (((int) ptr + alignment - 1) & -alignment); - - /* Store a suitable indication of how to free the block, - so that free can find the true beginning of it. */ - p = (struct mhead *) (aligned - ((7 + sizeof (struct mhead)) & ~7)); - p -> mh_size = aligned - ptr; - p -> mh_alloc = ISMEMALIGN; - return aligned; -} - -#ifndef HPUX -/* This runs into trouble with getpagesize on HPUX. - Patching out seems cleaner than the ugly fix needed. */ -char * -valloc (size) -{ - return memalign (getpagesize (), size); -} -#endif /* not HPUX */ -#endif /* not VMS */ - -#ifdef MSTATS -/* Return statistics describing allocation of blocks of size 2**n. */ - -struct mstats_value - { - int blocksize; - int nfree; - int nused; - }; - -struct mstats_value -malloc_stats (size) - int size; -{ - struct mstats_value v; - register int i; - register struct mhead *p; - - v.nfree = 0; - - if (size < 0 || size >= 30) - { - v.blocksize = 0; - v.nused = 0; - return v; - } - - v.blocksize = 1 << (size + 3); - v.nused = nmalloc[size]; - - for (p = nextf[size]; p; p = CHAIN (p)) - v.nfree++; - - return v; -} -int -malloc_mem_used () -{ - int i; - int size_used; - - size_used = 0; - - for (i = 0; i < 30; i++) - { - int allocation_size = 1 << (i + 3); - struct mhead *p; - - size_used += nmalloc[i] * allocation_size; - } - - return size_used; -} - -int -malloc_mem_free () -{ - int i; - int size_unused; - - size_unused = 0; - - for (i = 0; i < 30; i++) - { - int allocation_size = 1 << (i + 3); - struct mhead *p; - - for (p = nextf[i]; p ; p = CHAIN (p)) - size_unused += allocation_size; - } - - return size_unused; -} -#endif /* MSTATS */ - -/* - * This function returns the total number of bytes that the process - * will be allowed to allocate via the sbrk(2) system call. On - * BSD systems this is the total space allocatable to stack and - * data. On USG systems this is the data space only. - */ - -#ifdef USG - -get_lim_data () -{ - extern long ulimit (); - -#ifdef ULIMIT_BREAK_VALUE - lim_data = ULIMIT_BREAK_VALUE; -#else - lim_data = ulimit (3, 0); -#endif - - lim_data -= (long) data_space_start; -} - -#else /* not USG */ -#if defined (BSD4_1) || defined (VMS) - -get_lim_data () -{ - lim_data = vlimit (LIM_DATA, -1); -} - -#else /* not BSD4_1 and not VMS */ - -get_lim_data () -{ - struct rlimit XXrlimit; - - getrlimit (RLIMIT_DATA, &XXrlimit); -#ifdef RLIM_INFINITY - lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */ -#else - lim_data = XXrlimit.rlim_cur; /* soft limit */ -#endif -} - -#endif /* not BSD4_1 and not VMS */ -#endif /* not USG */ - -#ifdef VMS -/* There is a problem when dumping and restoring things on VMS. Calls - * to SBRK don't necessarily result in contiguous allocation. Dumping - * doesn't work when it isn't. Therefore, we make the initial - * allocation contiguous by allocating a big chunk, and do SBRKs from - * there. Once Emacs has dumped there is no reason to continue - * contiguous allocation, malloc doesn't depend on it. - * - * There is a further problem of using brk and sbrk while using VMS C - * run time library routines malloc, calloc, etc. The documentation - * says that this is a no-no, although I'm not sure why this would be - * a problem. In any case, we remove the necessity to call brk and - * sbrk, by calling calloc (to assure zero filled data) rather than - * sbrk. - * - * VMS_ALLOCATION_SIZE is the size of the allocation array. This - * should be larger than the malloc size before dumping. Making this - * too large will result in the startup procedure slowing down since - * it will require more space and time to map it in. - * - * The value for VMS_ALLOCATION_SIZE in the following define was determined - * by running emacs linked (and a large allocation) with the debugger and - * looking to see how much storage was used. The allocation was 201 pages, - * so I rounded it up to a power of two. - */ -#ifndef VMS_ALLOCATION_SIZE -#define VMS_ALLOCATION_SIZE (512*256) -#endif - -/* Use VMS RTL definitions */ -#undef sbrk -#undef brk -#undef malloc -int vms_out_initial = 0; -char vms_initial_buffer[VMS_ALLOCATION_SIZE]; -static char *vms_current_brk = &vms_initial_buffer; -static char *vms_end_brk = &vms_initial_buffer[VMS_ALLOCATION_SIZE-1]; - -#include - -char * -sys_sbrk (incr) - int incr; -{ - char *sbrk(), *temp, *ptr; - - if (vms_out_initial) - { - /* out of initial allocation... */ - if (!(temp = malloc (incr))) - temp = (char *) -1; - } - else - { - /* otherwise, go out of our area */ - ptr = vms_current_brk + incr; /* new current_brk */ - if (ptr <= vms_end_brk) - { - temp = vms_current_brk; - vms_current_brk = ptr; - } - else - { - vms_out_initial = 1; /* mark as out of initial allocation */ - if (!(temp = malloc (incr))) - temp = (char *) -1; - } - } - return temp; -} -#endif /* VMS */ diff --git a/gnu/lib/regex-0.12/test/fileregex.c b/gnu/lib/regex-0.12/test/fileregex.c deleted file mode 100644 index 2c27a0f5ddcd..000000000000 --- a/gnu/lib/regex-0.12/test/fileregex.c +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#include "regex.h" - -#define BYTEWIDTH 8 - -/* Sorry, but this is just a test program. */ -#define LINE_MAX 500 - -int -main (argc, argv) - int argc; - char *argv[]; -{ - FILE *f; - char *filename; - char pat[500]; /* Sorry for that maximum size, too. */ - char line[LINE_MAX]; - struct re_pattern_buffer buf; - char fastmap[(1 << BYTEWIDTH)]; - const char *compile_ret; - unsigned lineno = 1; - unsigned nfound = 0; - - /* Actually, it might be useful to allow the data file to be standard - input, and to specify the pattern on the command line. */ - if (argc != 2) - { - fprintf (stderr, "Usage: %s .\n", argv[0]); - exit (1); - } - - filename = argv[1]; - f = fopen (filename, "r"); - if (f == NULL) - perror (filename); - - buf.allocated = 0; - buf.buffer = NULL; - buf.fastmap = fastmap; - - printf ("Pattern = ", pat); - gets (pat); - - if (feof (stdin)) - { - putchar ('\n'); - exit (0); - } - - compile_ret = re_compile_pattern (pat, strlen (pat), &buf); - if (compile_ret != NULL) - { - fprintf (stderr, "%s: %s\n", pat, compile_ret); - exit (1); - } - - while (fgets (line, LINE_MAX, f) != NULL) - { - size_t len = strlen (line); - struct re_registers regs; - int search_ret - = re_search_2 (&buf, NULL, 0, line, len, 0, len, ®s, len); - - if (search_ret == -2) - { - fprintf (stderr, "%s:%d: re_search failed.\n", filename, lineno); - exit (1); - } - - nfound += search_ret != -1; - lineno++; - } - - printf ("Matches found: %u (out of %u lines).\n", nfound, lineno - 1); - return 0; -} diff --git a/gnu/lib/regex-0.12/test/g++malloc.c b/gnu/lib/regex-0.12/test/g++malloc.c deleted file mode 100644 index d55ce45643d3..000000000000 --- a/gnu/lib/regex-0.12/test/g++malloc.c +++ /dev/null @@ -1,1288 +0,0 @@ -#define inline - -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@oswego.edu) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. -*/ - - - -#ifndef NO_LIBGXX_MALLOC /* ignore whole file otherwise */ - -/* compile with -DMALLOC_STATS to collect statistics */ -/* collecting statistics slows down malloc by at least 15% */ - -#ifdef MALLOC_STATS -#define UPDATE_STATS(ARGS) {ARGS;} -#else -#define UPDATE_STATS(ARGS) -#endif - -/* History - - - Tue Jan 16 04:54:27 1990 Doug Lea (dl at g.oswego.edu) - - version 1 released in libg++ - - Sun Jan 21 05:52:47 1990 Doug Lea (dl at g.oswego.edu) - - bins are now own struct for, sanity. - - new victim search strategy: scan up and consolidate. - Both faster and less fragmentation. - - refined when to scan bins for consolidation, via consollink, etc. - - realloc: always try to expand chunk, avoiding some fragmentation. - - changed a few inlines into macros - - hardwired SBRK_UNIT to 4096 for uniformity across systems - - Tue Mar 20 14:18:23 1990 Doug Lea (dl at g.oswego.edu) - - calloc and cfree now correctly parameterized. - - Sun Apr 1 10:00:48 1990 Doug Lea (dl at g.oswego.edu) - - added memalign and valloc. - - Sun Jun 24 05:46:48 1990 Doug Lea (dl at g.oswego.edu) - - #include gepagesize.h only ifndef sun - cache pagesize after first call - - Wed Jul 25 08:35:19 1990 Doug Lea (dl at g.oswego.edu) - - No longer rely on a `designated victim': - - 1. It sometimes caused splits of large chunks - when smaller ones would do, leading to - bad worst-case fragmentation. - - 2. Scanning through the av array fast anyway, - so the overhead isn't worth it. - - To compensate, several other minor changes: - - 1. Unusable chunks are checked for consolidation during - searches inside bins, better distributing chunks - across bins. - - 2. Chunks are returned when found in malloc_find_space, - rather than finishing cleaning everything up, to - avoid wasted iterations due to (1). -*/ - -/* - A version of malloc/free/realloc tuned for C++ applications. - - Here's what you probably want to know first: - - In various tests, this appears to be about as fast as, - and usually substantially less memory-wasteful than BSD/GNUemacs malloc. - - Generally, it is slower (by perhaps 20%) than bsd-style malloc - only when bsd malloc would waste a great deal of space in - fragmented blocks, which this malloc recovers; or when, by - chance or design, nearly all requests are near the bsd malloc - power-of-2 allocation bin boundaries, and as many chunks are - used as are allocated. - - It uses more space than bsd malloc only when, again by chance - or design, only bsdmalloc bin-sized requests are malloced, or when - little dynamic space is malloced, since this malloc may grab larger - chunks from the system at a time than bsd. - - In other words, this malloc seems generally superior to bsd - except perhaps for programs that are specially tuned to - deal with bsdmalloc's characteristics. But even here, the - performance differences are slight. - - - This malloc, like any other, is a compromised design. - - - Chunks of memory are maintained using a `boundary tag' method as - described in e.g., Knuth or Standish. This means that the size of - the chunk is stored both in the front of the chunk and at the end. - This makes consolidating fragmented chunks into bigger chunks very fast. - The size field is also used to hold bits representing whether a - chunk is free or in use. - - Malloced chunks have space overhead of 8 bytes: The preceding - and trailing size fields. When they are freed, the list pointer - fields are also needed. - - Available chunks are kept in doubly linked lists. The lists are - maintained in an array of bins using a power-of-two method, except - that instead of 32 bins (one for each 1 << i), there are 128: each - power of two is split in quarters. The use of very fine bin sizes - closely approximates the use of one bin per actually used size, - without necessitating the overhead of locating such bins. It is - especially desirable in common C++ applications where large numbers - of identically-sized blocks are malloced/freed in some dynamic - manner, and then later are all freed. The finer bin sizes make - finding blocks fast, with little wasted overallocation. The - consolidation methods ensure that once the collection of blocks is - no longer useful, fragments are gathered into bigger chunks awaiting new - roles. - - The bins av[i] serve as heads of the lists. Bins contain a dummy - header for the chunk lists, and a `dirty' field used to indicate - whether the list may need to be scanned for consolidation. - - On allocation, the bin corresponding to the request size is - scanned, and if there is a chunk with size >= requested, it - is split, if too big, and used. Chunks on the list which are - too small are examined for consolidation during this traversal. - - If no chunk exists in the list bigger bins are scanned in search of - a victim. - - If no victim can be found, then smaller bins are examined for - consolidation in order to construct a victim. - - Finally, if consolidation fails to come up with a usable chunk, - more space is obtained from the system. - - After a split, the remainder is placed on - the back of the appropriate bin list. (All freed chunks are placed - on fronts of lists. All remaindered or consolidated chunks are - placed on the rear. Correspondingly, searching within a bin - starts at the front, but finding victims is from the back. All - of this approximates the effect of having 2 kinds of lists per - bin: returned chunks vs unallocated chunks, but without the overhead - of maintaining 2 lists.) - - Deallocation (free) consists only of placing the chunk on - a list. - - Reallocation proceeds in the usual way. If a chunk can be extended, - it is, else a malloc-copy-free sequence is taken. - - memalign requests more than enough space from malloc, finds a - spot within that chunk that meets the alignment request, and - then possibly frees the leading and trailing space. Overreliance - on memalign is a sure way to fragment space. - - - Some other implementation matters: - - 8 byte alignment is currently hardwired into the design. Calling - memalign will return a chunk that is both 8-byte aligned, and - meets the requested alignment. - - The basic overhead of a used chunk is 8 bytes: 4 at the front and - 4 at the end. - - When a chunk is free, 8 additional bytes are needed for free list - pointers. Thus, the minimum allocatable size is 16 bytes. - - The existence of front and back overhead permits some reasonably - effective fence-bashing checks: The front and back fields must - be identical. This is checked only within free() and realloc(). - The checks are fast enough to be made non-optional. - - The overwriting of parts of freed memory with the freelist pointers - can also be very effective (albeit in an annoying way) in helping - users track down dangling pointers. - - User overwriting of freed space will often result in crashes - within malloc or free. - - These routines are also tuned to C++ in that free(0) is a noop and - a failed malloc automatically calls (*new_handler)(). - - malloc(0) returns a pointer to something of the minimum allocatable size. - - Additional memory is gathered from the system (via sbrk) in a - way that allows chunks obtained across different sbrk calls to - be consolidated, but does not require contiguous memory: Thus, - it should be safe to intersperse mallocs with other sbrk calls. - - This malloc is NOT designed to work in multiprocessing applications. - No semaphores or other concurrency control are provided to ensure - that multiple malloc or free calls don't run at the same time, - which could be disasterous. - - VERY heavy use of inlines is made, for clarity. If this malloc - is ported via a compiler without inlining capabilities, all - inlines should be transformed into macros -- making them non-inline - makes malloc at least twice as slow. - - -*/ - - -/* preliminaries */ - -#ifdef __cplusplus -#include -#else -#include "//usr/include/stdio.h" /* needed for error reporting */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef USG -extern void* memset(void*, int, int); -extern void* memcpy(void*, const void*, int); -/*inline void bzero(void* s, int l) { memset(s, 0, l); }*/ -#else -/*extern void bzero(void*, unsigned int);*/ -#endif - -/*extern void bcopy(void*, void*, unsigned int);*/ - -extern void* sbrk(unsigned int); - -/* Put this in instead of commmented out stuff above. */ -#define bcopy(s,d,n) memcpy((d),(s),(n)) -#define bcmp(s1,s2,n) memcmp((s1),(s2),(n)) -#define bzero(s,n) memset((s),0,(n)) - - -#ifdef __GNUC__ -extern volatile void abort(); -#else -extern void abort(); -#endif - -#ifdef __cplusplus -}; /* end of extern "C" */ -#endif - - -/* A good multiple to call sbrk with */ - -#define SBRK_UNIT 4096 - - - -/* how to die on detected error */ - -#ifdef __GNUC__ -static volatile void malloc_user_error() -#else -static void malloc_user_error() -#endif -{ - fputs("malloc/free/realloc: clobbered space detected\n", stderr); abort(); -} - - - -/* Basic overhead for each malloc'ed chunk */ - - -struct malloc_chunk -{ - unsigned int size; /* Size in bytes, including overhead. */ - /* Or'ed with INUSE if in use. */ - - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; - -}; - -typedef struct malloc_chunk* mchunkptr; - -struct malloc_bin -{ - struct malloc_chunk hd; /* dummy list header */ - unsigned int dirty; /* True if maybe consolidatable */ - /* Wasting a word here makes */ - /* sizeof(bin) a power of 2, */ - /* which makes size2bin() faster */ -}; - -typedef struct malloc_bin* mbinptr; - - -/* sizes, alignments */ - - -#define SIZE_SZ (sizeof(unsigned int)) -#define MALLOC_MIN_OVERHEAD (SIZE_SZ + SIZE_SZ) -#define MALLOC_ALIGN_MASK (MALLOC_MIN_OVERHEAD - 1) - -#define MINSIZE (sizeof(struct malloc_chunk) + SIZE_SZ) /* MUST == 16! */ - - -/* pad request bytes into a usable size */ - -static inline unsigned int request2size(unsigned int request) -{ - return (request == 0) ? MINSIZE : - ((request + MALLOC_MIN_OVERHEAD + MALLOC_ALIGN_MASK) - & ~(MALLOC_ALIGN_MASK)); -} - - -static inline int aligned_OK(void* m) -{ - return ((unsigned int)(m) & (MALLOC_ALIGN_MASK)) == 0; -} - - -/* size field or'd with INUSE when in use */ -#define INUSE 0x1 - - - -/* the bins, initialized to have null double linked lists */ - -#define MAXBIN 120 /* 1 more than needed for 32 bit addresses */ - -#define FIRSTBIN (&(av[0])) - -static struct malloc_bin av[MAXBIN] = -{ - { { 0, &(av[0].hd), &(av[0].hd) }, 0 }, - { { 0, &(av[1].hd), &(av[1].hd) }, 0 }, - { { 0, &(av[2].hd), &(av[2].hd) }, 0 }, - { { 0, &(av[3].hd), &(av[3].hd) }, 0 }, - { { 0, &(av[4].hd), &(av[4].hd) }, 0 }, - { { 0, &(av[5].hd), &(av[5].hd) }, 0 }, - { { 0, &(av[6].hd), &(av[6].hd) }, 0 }, - { { 0, &(av[7].hd), &(av[7].hd) }, 0 }, - { { 0, &(av[8].hd), &(av[8].hd) }, 0 }, - { { 0, &(av[9].hd), &(av[9].hd) }, 0 }, - - { { 0, &(av[10].hd), &(av[10].hd) }, 0 }, - { { 0, &(av[11].hd), &(av[11].hd) }, 0 }, - { { 0, &(av[12].hd), &(av[12].hd) }, 0 }, - { { 0, &(av[13].hd), &(av[13].hd) }, 0 }, - { { 0, &(av[14].hd), &(av[14].hd) }, 0 }, - { { 0, &(av[15].hd), &(av[15].hd) }, 0 }, - { { 0, &(av[16].hd), &(av[16].hd) }, 0 }, - { { 0, &(av[17].hd), &(av[17].hd) }, 0 }, - { { 0, &(av[18].hd), &(av[18].hd) }, 0 }, - { { 0, &(av[19].hd), &(av[19].hd) }, 0 }, - - { { 0, &(av[20].hd), &(av[20].hd) }, 0 }, - { { 0, &(av[21].hd), &(av[21].hd) }, 0 }, - { { 0, &(av[22].hd), &(av[22].hd) }, 0 }, - { { 0, &(av[23].hd), &(av[23].hd) }, 0 }, - { { 0, &(av[24].hd), &(av[24].hd) }, 0 }, - { { 0, &(av[25].hd), &(av[25].hd) }, 0 }, - { { 0, &(av[26].hd), &(av[26].hd) }, 0 }, - { { 0, &(av[27].hd), &(av[27].hd) }, 0 }, - { { 0, &(av[28].hd), &(av[28].hd) }, 0 }, - { { 0, &(av[29].hd), &(av[29].hd) }, 0 }, - - { { 0, &(av[30].hd), &(av[30].hd) }, 0 }, - { { 0, &(av[31].hd), &(av[31].hd) }, 0 }, - { { 0, &(av[32].hd), &(av[32].hd) }, 0 }, - { { 0, &(av[33].hd), &(av[33].hd) }, 0 }, - { { 0, &(av[34].hd), &(av[34].hd) }, 0 }, - { { 0, &(av[35].hd), &(av[35].hd) }, 0 }, - { { 0, &(av[36].hd), &(av[36].hd) }, 0 }, - { { 0, &(av[37].hd), &(av[37].hd) }, 0 }, - { { 0, &(av[38].hd), &(av[38].hd) }, 0 }, - { { 0, &(av[39].hd), &(av[39].hd) }, 0 }, - - { { 0, &(av[40].hd), &(av[40].hd) }, 0 }, - { { 0, &(av[41].hd), &(av[41].hd) }, 0 }, - { { 0, &(av[42].hd), &(av[42].hd) }, 0 }, - { { 0, &(av[43].hd), &(av[43].hd) }, 0 }, - { { 0, &(av[44].hd), &(av[44].hd) }, 0 }, - { { 0, &(av[45].hd), &(av[45].hd) }, 0 }, - { { 0, &(av[46].hd), &(av[46].hd) }, 0 }, - { { 0, &(av[47].hd), &(av[47].hd) }, 0 }, - { { 0, &(av[48].hd), &(av[48].hd) }, 0 }, - { { 0, &(av[49].hd), &(av[49].hd) }, 0 }, - - { { 0, &(av[50].hd), &(av[50].hd) }, 0 }, - { { 0, &(av[51].hd), &(av[51].hd) }, 0 }, - { { 0, &(av[52].hd), &(av[52].hd) }, 0 }, - { { 0, &(av[53].hd), &(av[53].hd) }, 0 }, - { { 0, &(av[54].hd), &(av[54].hd) }, 0 }, - { { 0, &(av[55].hd), &(av[55].hd) }, 0 }, - { { 0, &(av[56].hd), &(av[56].hd) }, 0 }, - { { 0, &(av[57].hd), &(av[57].hd) }, 0 }, - { { 0, &(av[58].hd), &(av[58].hd) }, 0 }, - { { 0, &(av[59].hd), &(av[59].hd) }, 0 }, - - { { 0, &(av[60].hd), &(av[60].hd) }, 0 }, - { { 0, &(av[61].hd), &(av[61].hd) }, 0 }, - { { 0, &(av[62].hd), &(av[62].hd) }, 0 }, - { { 0, &(av[63].hd), &(av[63].hd) }, 0 }, - { { 0, &(av[64].hd), &(av[64].hd) }, 0 }, - { { 0, &(av[65].hd), &(av[65].hd) }, 0 }, - { { 0, &(av[66].hd), &(av[66].hd) }, 0 }, - { { 0, &(av[67].hd), &(av[67].hd) }, 0 }, - { { 0, &(av[68].hd), &(av[68].hd) }, 0 }, - { { 0, &(av[69].hd), &(av[69].hd) }, 0 }, - - { { 0, &(av[70].hd), &(av[70].hd) }, 0 }, - { { 0, &(av[71].hd), &(av[71].hd) }, 0 }, - { { 0, &(av[72].hd), &(av[72].hd) }, 0 }, - { { 0, &(av[73].hd), &(av[73].hd) }, 0 }, - { { 0, &(av[74].hd), &(av[74].hd) }, 0 }, - { { 0, &(av[75].hd), &(av[75].hd) }, 0 }, - { { 0, &(av[76].hd), &(av[76].hd) }, 0 }, - { { 0, &(av[77].hd), &(av[77].hd) }, 0 }, - { { 0, &(av[78].hd), &(av[78].hd) }, 0 }, - { { 0, &(av[79].hd), &(av[79].hd) }, 0 }, - - { { 0, &(av[80].hd), &(av[80].hd) }, 0 }, - { { 0, &(av[81].hd), &(av[81].hd) }, 0 }, - { { 0, &(av[82].hd), &(av[82].hd) }, 0 }, - { { 0, &(av[83].hd), &(av[83].hd) }, 0 }, - { { 0, &(av[84].hd), &(av[84].hd) }, 0 }, - { { 0, &(av[85].hd), &(av[85].hd) }, 0 }, - { { 0, &(av[86].hd), &(av[86].hd) }, 0 }, - { { 0, &(av[87].hd), &(av[87].hd) }, 0 }, - { { 0, &(av[88].hd), &(av[88].hd) }, 0 }, - { { 0, &(av[89].hd), &(av[89].hd) }, 0 }, - - { { 0, &(av[90].hd), &(av[90].hd) }, 0 }, - { { 0, &(av[91].hd), &(av[91].hd) }, 0 }, - { { 0, &(av[92].hd), &(av[92].hd) }, 0 }, - { { 0, &(av[93].hd), &(av[93].hd) }, 0 }, - { { 0, &(av[94].hd), &(av[94].hd) }, 0 }, - { { 0, &(av[95].hd), &(av[95].hd) }, 0 }, - { { 0, &(av[96].hd), &(av[96].hd) }, 0 }, - { { 0, &(av[97].hd), &(av[97].hd) }, 0 }, - { { 0, &(av[98].hd), &(av[98].hd) }, 0 }, - { { 0, &(av[99].hd), &(av[99].hd) }, 0 }, - - { { 0, &(av[100].hd), &(av[100].hd) }, 0 }, - { { 0, &(av[101].hd), &(av[101].hd) }, 0 }, - { { 0, &(av[102].hd), &(av[102].hd) }, 0 }, - { { 0, &(av[103].hd), &(av[103].hd) }, 0 }, - { { 0, &(av[104].hd), &(av[104].hd) }, 0 }, - { { 0, &(av[105].hd), &(av[105].hd) }, 0 }, - { { 0, &(av[106].hd), &(av[106].hd) }, 0 }, - { { 0, &(av[107].hd), &(av[107].hd) }, 0 }, - { { 0, &(av[108].hd), &(av[108].hd) }, 0 }, - { { 0, &(av[109].hd), &(av[109].hd) }, 0 }, - - { { 0, &(av[110].hd), &(av[110].hd) }, 0 }, - { { 0, &(av[111].hd), &(av[111].hd) }, 0 }, - { { 0, &(av[112].hd), &(av[112].hd) }, 0 }, - { { 0, &(av[113].hd), &(av[113].hd) }, 0 }, - { { 0, &(av[114].hd), &(av[114].hd) }, 0 }, - { { 0, &(av[115].hd), &(av[115].hd) }, 0 }, - { { 0, &(av[116].hd), &(av[116].hd) }, 0 }, - { { 0, &(av[117].hd), &(av[117].hd) }, 0 }, - { { 0, &(av[118].hd), &(av[118].hd) }, 0 }, - { { 0, &(av[119].hd), &(av[119].hd) }, 0 } -}; - -/* - indexing into bins -*/ - -static inline mbinptr size2bin(unsigned int sz) -{ - mbinptr b = av; - while (sz >= (MINSIZE * 2)) { b += 4; sz >>= 1; } /* find power of 2 */ - b += (sz - MINSIZE) >> 2; /* find quadrant */ - return b; -} - - - -/* counts maintained if MALLOC_STATS defined */ - -#ifdef MALLOC_STATS - -static unsigned int sbrked_mem; -static unsigned int requested_mem; -static unsigned int malloced_mem; -static unsigned int freed_mem; -static unsigned int max_used_mem; - -static unsigned int n_sbrks; -static unsigned int n_mallocs; -static unsigned int n_frees; -static unsigned int n_reallocs; -static unsigned int n_reallocs_with_copy; -static unsigned int n_avail; -static unsigned int max_inuse; - -static unsigned int n_malloc_chunks; -static unsigned int n_malloc_bins; - -static unsigned int n_split; -static unsigned int n_consol; - - -static void do_malloc_stats(const mchunkptr p) -{ - ++n_mallocs; - if ((n_mallocs-n_frees) > max_inuse) - max_inuse = n_mallocs - n_frees; - malloced_mem += (p->size & ~(INUSE)); - if (malloced_mem - freed_mem > max_used_mem) - max_used_mem = malloced_mem - freed_mem; -} - -static void do_free_stats(const mchunkptr p) -{ - ++n_frees; - freed_mem += (p->size & ~(INUSE)); -} - -#endif - - - -/* Utilities needed below for memalign */ -/* This is redundant with libg++ support, but not if used stand-alone */ - -static unsigned int gcd(unsigned int a, unsigned int b) -{ - unsigned int tmp; - - if (b > a) - { - tmp = a; a = b; b = tmp; - } - for(;;) - { - if (b == 0) - return a; - else if (b == 1) - return b; - else - { - tmp = b; - b = a % b; - a = tmp; - } - } -} - -static inline unsigned int lcm(unsigned int x, unsigned int y) -{ - return x / gcd(x, y) * y; -} - - - -/* maintaining INUSE via size field */ - - -#define inuse(p) ((p)->size & INUSE) -#define set_inuse(p) ((p)->size |= INUSE) -#define clear_inuse(b) ((p)->size &= ~INUSE) - - -/* operations on malloc_chunk addresses */ - - -/* return ptr to next physical malloc_chunk */ - -#define next_chunk(p) ((mchunkptr)((char*)(p) + (p)->size)) - -/* return ptr to previous physical malloc_chunk */ - -#define prev_chunk(p) ((mchunkptr)((char*)(p)-((((int*)(p))[-1]) & ~(INUSE)))) - -/* place size at front and back of chunk */ - - -static inline void set_size(mchunkptr p, unsigned int sz) -{ - p->size = *((int*)((char*)(p) + sz - SIZE_SZ)) = sz; -} - - - - -/* conversion from malloc headers to user pointers, and back */ - -static inline void* chunk2mem(mchunkptr p) -{ - void *mem; - set_inuse(p); -mem = (void*)((char*)(p) + SIZE_SZ); - return mem; -} - -/* xxxx my own */ -mchunkptr sanity_check(void* mem) -{ - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); - - /* a quick sanity check */ - unsigned int sz = p->size & ~(INUSE); - if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ))) - malloc_user_error(); - - return p; -} - - - - -static inline mchunkptr mem2chunk(void* mem) -{ - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); - - /* a quick sanity check */ - unsigned int sz = p->size & ~(INUSE); - if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ))) - malloc_user_error(); - - p->size = sz; /* clears INUSE */ - return p; -} - - - -/* maintaining bins & pointers */ - - -/* maximum bin actually used */ - -static mbinptr malloc_maxbin = FIRSTBIN; - - -/* operations on lists inside bins */ - - -/* take a chunk off a list */ - -static inline void unlink(mchunkptr p) -{ - mchunkptr b = p->bk; - mchunkptr f = p->fd; - - f->bk = b; b->fd = f; - - UPDATE_STATS (--n_avail); -} - - - -/* split a chunk and place on the back of a list */ - -static inline void split(mchunkptr p, unsigned int offset) -{ - unsigned int room = p->size - offset; - if (room >= MINSIZE) - { - mbinptr bn = size2bin(room); /* new bin */ - mchunkptr h = &(bn->hd); /* its head */ - mchunkptr b = h->bk; /* old back element */ - mchunkptr t = (mchunkptr)((char*)(p) + offset); /* remaindered chunk */ - - /* set size */ - t->size = *((int*)((char*)(t) + room - SIZE_SZ)) = room; - - /* link up */ - t->bk = b; t->fd = h; h->bk = b->fd = t; - - /* adjust maxbin (h == b means was empty) */ - if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; - - /* adjust size of chunk to be returned */ - p->size = *((int*)((char*)(p) + offset - SIZE_SZ)) = offset; - - UPDATE_STATS ((++n_split, ++n_avail)); - } -} - - - -/* place a consolidated chunk on the back of a list */ -/* like above, except no split */ - -static inline void consollink(mchunkptr p) -{ - mbinptr bn = size2bin(p->size); - mchunkptr h = &(bn->hd); - mchunkptr b = h->bk; - - p->bk = b; p->fd = h; h->bk = b->fd = p; - - if (h == b && bn > malloc_maxbin) malloc_maxbin = bn; - - UPDATE_STATS(++n_avail); -} - - -/* place a freed chunk on the front of a list */ - -static inline void frontlink(mchunkptr p) -{ - mbinptr bn = size2bin(p->size); - mchunkptr h = &(bn->hd); - mchunkptr f = h->fd; - - p->bk = h; p->fd = f; f->bk = h->fd = p; - - if (h == f && bn > malloc_maxbin) malloc_maxbin = bn; - - bn->dirty = 1; - - UPDATE_STATS(++n_avail); -} - - - -/* Dealing with sbrk */ - - -/* To link consecutive sbrk regions when possible */ - -static int* last_sbrk_end; - - -/* who to call when sbrk returns failure */ - -#ifndef NO_NEW_HANDLER -typedef volatile void (*vfp)(); -#ifdef __cplusplus -extern "C" vfp __new_handler; -#else -extern vfp __new_handler; -#endif -#endif - -static mchunkptr malloc_from_sys(unsigned nb) -{ - mchunkptr p; - unsigned int sbrk_size; - int* ip; - - /* Minimally, we need to pad with enough space */ - /* to place dummy size/use fields to ends if needed */ - - sbrk_size = ((nb + SBRK_UNIT - 1 + SIZE_SZ + SIZE_SZ) - / SBRK_UNIT) * SBRK_UNIT; - - ip = (int*)(sbrk(sbrk_size)); - if ((char*)ip == (char*)(-1)) /* sbrk returns -1 on failure */ - { -#ifndef NO_NEW_HANDLER - (*__new_handler) (); -#endif - return 0; - } - - UPDATE_STATS ((++n_sbrks, sbrked_mem += sbrk_size)); - - - if (last_sbrk_end != &ip[-1]) - { - /* It's either first time through or someone else called sbrk. */ - /* Arrange end-markers at front & back */ - - /* Shouldn't be necessary, but better to be safe */ - while (!aligned_OK(ip)) { ++ip; sbrk_size -= SIZE_SZ; } - - - /* Mark the front as in use to prevent merging. */ - /* Note we can get away with only 1 word, not MINSIZE overhead here */ - - *ip++ = SIZE_SZ | INUSE; - - p = (mchunkptr)ip; - set_size(p,sbrk_size - (SIZE_SZ + SIZE_SZ)); - - } - else - { - mchunkptr l; - - /* We can safely make the header start at end of prev sbrked chunk. */ - /* We will still have space left at the end from a previous call */ - /* to place the end marker, below */ - - p = (mchunkptr)(last_sbrk_end); - set_size(p, sbrk_size); - - - /* Even better, maybe we can merge with last fragment: */ - - l = prev_chunk(p); - if (!inuse(l)) - { - unlink(l); - set_size(l, p->size + l->size); - p = l; - } - - } - - /* mark the end of sbrked space as in use to prevent merging */ - - last_sbrk_end = (int*)((char*)p + p->size); - *last_sbrk_end = SIZE_SZ | INUSE; - - UPDATE_STATS((++n_avail, ++n_malloc_chunks)); - - /* make it safe to unlink in malloc */ - UPDATE_STATS(++n_avail); - p->fd = p->bk = p; - - return p; -} - - - -/* Consolidate dirty bins. */ -/* Stop if found a chunk big enough to satisfy current malloc request */ - -/* (It requires much less bookkeeping to consolidate entire bins */ -/* at once than to keep records of which chunks might be */ -/* consolidatable. So long as the lists are short, which we */ -/* try to ensure via small bin ranges, there is little wasted effort.) */ - -static mchunkptr malloc_find_space(unsigned int nb) -{ - mbinptr b; - - /* first, re-adjust max used bin */ - - while (malloc_maxbin >= FIRSTBIN && - malloc_maxbin->hd.bk == &(malloc_maxbin->hd)) - { - malloc_maxbin->dirty = 0; - --malloc_maxbin; - } - - for (b = malloc_maxbin; b >= FIRSTBIN; --b) - { - UPDATE_STATS(++n_malloc_bins); - - if (b->dirty) - { - mchunkptr h = &(b->hd); /* head of list */ - mchunkptr p = h->fd; /* chunk traverser */ - - while (p != h) - { - mchunkptr nextp = p->fd; /* save, in case of relinks */ - int consolidated = 0; /* only unlink/relink if consolidated */ - - mchunkptr t; - - UPDATE_STATS(++n_malloc_chunks); - - while (!inuse(t = prev_chunk(p))) /* consolidate backward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(t, t->size + p->size); - p = t; - UPDATE_STATS (++n_consol); - } - - while (!inuse(t = next_chunk(p))) /* consolidate forward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(p, p->size + t->size); - UPDATE_STATS (++n_consol); - } - - if (consolidated) - { - if (p->size >= nb) - { - /* make it safe to unlink in malloc */ - UPDATE_STATS(++n_avail); - p->fd = p->bk = p; - return p; - } - else - consollink(p); - } - - p = nextp; - - } - - b->dirty = 0; - - } - } - - /* nothing available - sbrk some more */ - - return malloc_from_sys(nb); -} - - - -/* Finally, the user-level functions */ - -void* malloc(unsigned int bytes) -{ - unsigned int nb = request2size(bytes); /* padded request size */ - mbinptr b = size2bin(nb); /* corresponding bin */ - mchunkptr hd = &(b->hd); /* head of its list */ - mchunkptr p = hd->fd; /* chunk traverser */ - - UPDATE_STATS((requested_mem+=bytes, ++n_malloc_bins)); - - /* Try a (near) exact match in own bin */ - /* clean out unusable but consolidatable chunks in bin while traversing */ - - while (p != hd) - { - UPDATE_STATS(++n_malloc_chunks); - if (p->size >= nb) - goto found; - else /* try to consolidate; same code as malloc_find_space */ - { - mchunkptr nextp = p->fd; /* save, in case of relinks */ - int consolidated = 0; /* only unlink/relink if consolidated */ - - mchunkptr t; - - while (!inuse(t = prev_chunk(p))) /* consolidate backward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(t, t->size + p->size); - p = t; - UPDATE_STATS (++n_consol); - } - - while (!inuse(t = next_chunk(p))) /* consolidate forward */ - { - if (!consolidated) { consolidated = 1; unlink(p); } - if (t == nextp) nextp = t->fd; - unlink(t); - set_size(p, p->size + t->size); - UPDATE_STATS (++n_consol); - } - - if (consolidated) - { - if (p->size >= nb) - { - /* make it safe to unlink again below */ - UPDATE_STATS(++n_avail); - p->fd = p->bk = p; - goto found; - } - else - consollink(p); - } - - p = nextp; - - } - } - - b->dirty = 0; /* true if got here */ - - /* Scan bigger bins for a victim */ - - while (++b <= malloc_maxbin) - { - UPDATE_STATS(++n_malloc_bins); - if ((p = b->hd.bk) != &(b->hd)) /* no need to check size */ - goto found; - } - - /* Consolidate or sbrk */ - - p = malloc_find_space(nb); - - if (p == 0) return 0; /* allocation failure */ - - found: /* Use what we found */ - - unlink(p); - split(p, nb); - UPDATE_STATS(do_malloc_stats(p)); - return chunk2mem(p); -} - - - - -void free(void* mem) -{ - if (mem != 0) - { - mchunkptr p = mem2chunk(mem); - UPDATE_STATS(do_free_stats(p)); - frontlink(p); - } -} - - -void* calloc(unsigned int n, unsigned int elem_size) -{ - unsigned int sz = n * elem_size; - void* p = malloc(sz); - bzero(p, sz); - return p; -}; - -/* This is here for compatibility with older systems */ -void cfree(void *mem) -{ - free(mem); -} - - -unsigned int malloc_usable_size(void* mem) -{ - if (mem == 0) - return 0; - else - { - mchunkptr p = (mchunkptr)((char*)(mem) - SIZE_SZ); - unsigned int sz = p->size & ~(INUSE); - if (p->size == sz || sz != *((int*)((char*)(p) + sz - SIZE_SZ))) - return 0; - else - return sz - MALLOC_MIN_OVERHEAD; - } -} - - - -void* realloc(void* mem, unsigned int bytes) -{ - if (mem == 0) - return malloc(bytes); - else - { - unsigned int nb = request2size(bytes); - mchunkptr p = mem2chunk(mem); - unsigned int oldsize = p->size; - int room; - mchunkptr nxt; - - UPDATE_STATS((++n_reallocs, requested_mem += bytes-oldsize)); - - /* try to expand (even if already big enough), to clean up chunk */ - - while (!inuse(nxt = next_chunk(p))) - { - UPDATE_STATS ((malloced_mem += nxt->size, ++n_consol)); - unlink(nxt); - set_size(p, p->size + nxt->size); - } - - room = p->size - nb; - if (room >= 0) - { - split(p, nb); - UPDATE_STATS(malloced_mem -= room); - return chunk2mem(p); - } - else /* do the obvious */ - { - void* newmem; - set_inuse(p); /* don't let malloc consolidate us yet! */ - newmem = malloc(nb); - bcopy(mem, newmem, oldsize - SIZE_SZ); - free(mem); - UPDATE_STATS(++n_reallocs_with_copy); - return newmem; - } - } -} - - - -/* return a pointer to space with at least the alignment requested */ - -void* memalign(unsigned int alignment, unsigned int bytes) -{ - mchunkptr p; - unsigned int nb = request2size(bytes); - - /* find an alignment that both we and the user can live with: */ - /* least common multiple guarantees mutual happiness */ - unsigned int align = lcm(alignment, MALLOC_MIN_OVERHEAD); - unsigned int mask = align - 1; - - /* call malloc with worst case padding to hit alignment; */ - /* we will give back extra */ - - unsigned int req = nb + align + MINSIZE; - void* m = malloc(req); - - if (m == 0) return m; - - p = mem2chunk(m); - - /* keep statistics on track */ - - UPDATE_STATS(--n_mallocs); - UPDATE_STATS(malloced_mem -= p->size); - UPDATE_STATS(requested_mem -= req); - UPDATE_STATS(requested_mem += bytes); - - if (((int)(m) & (mask)) != 0) /* misaligned */ - { - - /* find an aligned spot inside chunk */ - - mchunkptr ap = (mchunkptr)(( ((int)(m) + mask) & -align) - SIZE_SZ); - - unsigned int gap = (unsigned int)(ap) - (unsigned int)(p); - unsigned int room; - - /* we need to give back leading space in a chunk of at least MINSIZE */ - - if (gap < MINSIZE) - { - /* This works since align >= MINSIZE */ - /* and we've malloc'd enough total room */ - - ap = (mchunkptr)( (int)(ap) + align ); - gap += align; - } - - if (gap + nb > p->size) /* can't happen unless chunk sizes corrupted */ - malloc_user_error(); - - room = p->size - gap; - - /* give back leader */ - set_size(p, gap); - consollink(p); - - /* use the rest */ - p = ap; - set_size(p, room); - } - - /* also give back spare room at the end */ - - split(p, nb); - UPDATE_STATS(do_malloc_stats(p)); - return chunk2mem(p); - -} - -#ifndef sun -#include "getpagesize.h" -#endif - -static unsigned int malloc_pagesize = 0; - -void* valloc(unsigned int bytes) -{ - if (malloc_pagesize == 0) malloc_pagesize = getpagesize(); - return memalign (malloc_pagesize, bytes); -} - - -void malloc_stats() -{ -#ifndef MALLOC_STATS -} -#else - int i; - mchunkptr p; - double nm = (double)(n_mallocs + n_reallocs); - - fprintf(stderr, "\nmalloc statistics\n\n"); - - if (n_mallocs != 0) - fprintf(stderr, "requests = %10u total size = %10u\tave = %10u\n", - n_mallocs, requested_mem, requested_mem/n_mallocs); - - if (n_mallocs != 0) - fprintf(stderr, "mallocs = %10u total size = %10u\tave = %10u\n", - n_mallocs, malloced_mem, malloced_mem/n_mallocs); - - if (n_frees != 0) - fprintf(stderr, "frees = %10u total size = %10u\tave = %10u\n", - n_frees, freed_mem, freed_mem/n_frees); - - if (n_mallocs-n_frees != 0) - fprintf(stderr, "in use = %10u total size = %10u\tave = %10u\n", - n_mallocs-n_frees, malloced_mem-freed_mem, - (malloced_mem-freed_mem) / (n_mallocs-n_frees)); - - if (max_inuse != 0) - fprintf(stderr, "max in use= %10u total size = %10u\tave = %10u\n", - max_inuse, max_used_mem, max_used_mem / max_inuse); - - if (n_avail != 0) - fprintf(stderr, "available = %10u total size = %10u\tave = %10u\n", - n_avail, sbrked_mem - (malloced_mem-freed_mem), - (sbrked_mem - (malloced_mem-freed_mem)) / n_avail); - - if (n_sbrks != 0) - fprintf(stderr, "sbrks = %10u total size = %10u\tave = %10u\n\n", - n_sbrks, sbrked_mem, sbrked_mem/ n_sbrks); - - if (n_reallocs != 0) - fprintf(stderr, "reallocs = %10u with copy = %10u\n\n", - n_reallocs, n_reallocs_with_copy); - - - if (nm != 0) - { - fprintf(stderr, "chunks scanned per malloc = %6.3f\n", - n_malloc_chunks / nm); - fprintf(stderr, "bins scanned per malloc = %6.3f\n", - n_malloc_bins / nm); - fprintf(stderr, "splits per malloc = %6.3f\n", - n_split / nm); - fprintf(stderr, "consolidations per malloc = %6.3f\n", - n_consol / nm); - } - - fprintf(stderr, "\nfree chunks:\n"); - for (i = 0; i < MAXBIN; ++i) - { - p = av[i].hd.fd; - if (p != &(av[i].hd)) - { - unsigned int count = 1; - unsigned int sz = p->size; - for (p = p->fd; p != &(av[i].hd); p = p->fd) - { - if (p->size == sz) - ++count; - else - { - fprintf(stderr, "\tsize = %10u count = %5u\n", sz, count); - count = 1; - sz = p->size; - } - } - - fprintf(stderr, "\tsize = %10u count = %5u\n", sz, count); - - } - } -} -#endif /* MALLOC_STATS */ - -#endif /* NO_LIBGXX_MALLOC */ - - diff --git a/gnu/lib/regex-0.12/test/getpagesize.h b/gnu/lib/regex-0.12/test/getpagesize.h deleted file mode 100644 index 32adae61efa2..000000000000 --- a/gnu/lib/regex-0.12/test/getpagesize.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifdef BSD -#ifndef BSD4_1 -#define HAVE_GETPAGESIZE -#endif -#endif - -#ifndef HAVE_GETPAGESIZE - -#include - -#ifdef EXEC_PAGESIZE -#define getpagesize() EXEC_PAGESIZE -#else -#ifdef NBPG -#define getpagesize() NBPG * CLSIZE -#ifndef CLSIZE -#define CLSIZE 1 -#endif /* no CLSIZE */ -#else /* no NBPG */ -#define getpagesize() NBPC -#endif /* no NBPG */ -#endif /* no EXEC_PAGESIZE */ - -#endif /* not HAVE_GETPAGESIZE */ - diff --git a/gnu/lib/regex-0.12/test/iregex.c b/gnu/lib/regex-0.12/test/iregex.c deleted file mode 100644 index 2346d441fcdb..000000000000 --- a/gnu/lib/regex-0.12/test/iregex.c +++ /dev/null @@ -1,164 +0,0 @@ -/* Main program for interactive testing. For maximum output, compile - this and regex.c with -DDEBUG. */ - -#include -#include -#include "regex.h" - -/* Don't bother to guess about vs , etc. */ -extern int strlen (); - -#define BYTEWIDTH 8 - -extern void printchar (); -extern char upcase[]; - -static void scanstring (); -static void print_regs (); - -int -main (argc, argv) - int argc; - char **argv; -{ - int i; - struct re_pattern_buffer buf; - char fastmap[(1 << BYTEWIDTH)]; - - /* Allow a command argument to specify the style of syntax. You can - use the `syntax' program to decode integer syntax values. */ - if (argc > 1) - re_set_syntax (atoi (argv[1])); - - buf.allocated = 0; - buf.buffer = NULL; - buf.fastmap = fastmap; - buf.translate = upcase; - - for (;;) - { - char pat[500], str[500]; - struct re_registers regs; - - /* Some C compilers don't like `char pat[500] = ""'. */ - pat[0] = 0; - - printf ("Pattern (%s) = ", pat); - gets (pat); - scanstring (pat); - - if (feof (stdin)) - { - putchar ('\n'); - exit (0); - } - - if (*pat) - { - re_compile_pattern (pat, strlen (pat), &buf); - re_compile_fastmap (&buf); -#ifdef DEBUG - print_compiled_pattern (&buf); -#endif - } - - printf ("String = "); - gets (str); /* Now read the string to match against */ - scanstring (str); - - i = re_match (&buf, str, strlen (str), 0, ®s); - printf ("Match value %d.\t", i); - if (i >= 0) - print_regs (regs); - putchar ('\n'); - - i = re_search (&buf, str, strlen (str), 0, strlen (str), ®s); - printf ("Search value %d.\t", i); - if (i >= 0) - print_regs (regs); - putchar ('\n'); - } - - /* We never get here, but what the heck. */ - return 0; -} - -void -scanstring (s) - char *s; -{ - char *write = s; - - while (*s != '\0') - { - if (*s == '\\') - { - s++; - - switch (*s) - { - case '\0': - break; - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - *write = *s++ - '0'; - - if ('0' <= *s && *s <= '9') - { - *write = (*write << 3) + (*s++ - '0'); - if ('0' <= *s && *s <= '9') - *write = (*write << 3) + (*s++ - '0'); - } - write++; - break; - - case 'n': - *write++ = '\n'; - s++; - break; - - case 't': - *write++ = '\t'; - s++; - break; - - default: - *write++ = *s++; - break; - } - } - else - *write++ = *s++; - } - - *write++ = '\0'; -} - -/* Print REGS in human-readable form. */ - -void -print_regs (regs) - struct re_registers regs; -{ - int i, end; - - printf ("Registers: "); - - if (regs.num_regs == 0 || regs.start[0] == -1) - { - printf ("(none)"); - } - else - { - /* Find the last register pair that matched. */ - for (end = regs.num_regs - 1; end >= 0; end--) - if (regs.start[end] != -1) - break; - - printf ("[%d ", regs.start[0]); - for (i = 1; i <= end; i++) - printf ("(%d %d) ", regs.start[i], regs.end[i]); - printf ("%d]", regs.end[0]); - } -} diff --git a/gnu/lib/regex-0.12/test/main.c b/gnu/lib/regex-0.12/test/main.c deleted file mode 100644 index 28ae31528579..000000000000 --- a/gnu/lib/regex-0.12/test/main.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Main routine for running various tests. Meant only to be linked with - all the auxiliary test source files, with `test' undefined. */ - -#include "test.h" - -test_type t = all_test; - - -/* Use this to run the tests we've thought of. */ - -int -main () -{ - switch (t) - { - case all_test: - test_regress (); - test_others (); - test_posix_basic (); - test_posix_extended (); - test_posix_interface (); - break; - - case other_test: - test_others (); - break; - - case posix_basic_test: - test_posix_basic (); - break; - - case posix_extended_test: - test_posix_extended (); - break; - - case posix_interface_test: - test_posix_interface (); - break; - - case regress_test: - test_regress (); - break; - - default: - fprintf (stderr, "Unknown test %d.\n", t); - } - - return 0; -} diff --git a/gnu/lib/regex-0.12/test/malloc-test.c b/gnu/lib/regex-0.12/test/malloc-test.c deleted file mode 100644 index 7e27a15a8905..000000000000 --- a/gnu/lib/regex-0.12/test/malloc-test.c +++ /dev/null @@ -1,47 +0,0 @@ - - -typedef struct { - unsigned *bits; - unsigned size; -} bits_list_type; - -#define BYTEWIDTH 8 -#define NULL 0 - -#define BITS_BLOCK_SIZE (sizeof (unsigned) * BYTEWIDTH) -#define BITS_BLOCK(position) ((position) / BITS_BLOCK_SIZE) -#define BITS_MASK(position) (1 << ((position) % BITS_BLOCK_SIZE)) - -static unsigned -init_bits_list (bits_list_ptr) - bits_list_type *bits_list_ptr; -{ - bits_list_ptr->bits = NULL; - bits_list_ptr->bits = (unsigned *) malloc (sizeof (unsigned)); - - if (bits_list_ptr->bits == NULL) - return 0; - - bits_list_ptr->bits[0] = (unsigned)0; - bits_list_ptr->size = BITS_BLOCK_SIZE; - - return 1; -} - - -main() -{ - bits_list_type dummy; - bits_list_type dummy_1; - bits_list_type dummy_2; - bits_list_type dummy_3; - - init_bits_list (&dummy); -printf("init 1\n"); - init_bits_list (&dummy_1); -printf("init 2\n"); - init_bits_list (&dummy_2); -printf("init 3\n"); - init_bits_list (&dummy_3); -printf("init 4\n"); -} diff --git a/gnu/lib/regex-0.12/test/other.c b/gnu/lib/regex-0.12/test/other.c deleted file mode 100644 index d2ceb3844883..000000000000 --- a/gnu/lib/regex-0.12/test/other.c +++ /dev/null @@ -1,503 +0,0 @@ -/* other.c: test (not exhaustively) non-POSIX regular expressions. */ - -#include "test.h" - -void -test_others () -{ - struct re_registers regs; - - printf ("\nStarting non-POSIX tests.\n"); - t = other_test; - - test_should_match = true; - - /* The big question: does the group participate in the match, or match - the empty string? */ - re_set_syntax (RE_NO_BK_PARENS); - test_match ("(a*)*ab", "ab"); - TEST_REGISTERS ("(a*)*ab", "ab", 0, 2, 0, 0, -1, -1); - test_match ("(a*)*", ""); - TEST_REGISTERS ("(a*)*ab", "ab", 0, 0, 0, 0, -1, -1); - - /* This tests finding the highest and lowest active registers. */ - test_match ("(a(b)c(d(e)f)g)h(i(j)k(l(m)n)o)\\1\\2\\3\\4\\5\\6\\7\\8", - "abcdefghijklmnoabcdefgbdefeijklmnojlmnm"); - - /* Test that \< and \> match at the beginning and end of the string. */ - test_match ("\\", "abc"); - - /* May as well test \` and \' while we're at it. */ - test_match ("\\`abc\\'", "abc"); - -#if 0 - /* Test backreferencing and the fastmap -- which doesn't work. */ - test_fastmap ("(a)*\\1", "a", 0, 0); -#endif - - /* But at least we shouldn't search improperly. */ - test_search_return (-1, "(a)\\1", ""); - - re_set_syntax (RE_SYNTAX_EMACS); - - MATCH_SELF("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - MATCH_SELF ("a^"); - MATCH_SELF ("a^b"); - MATCH_SELF ("$a"); - MATCH_SELF ("a$b"); - - re_set_syntax (RE_BACKSLASH_ESCAPE_IN_LISTS); - test_match ("[\\^a]", "a"); - test_match ("[\\^a]", "^"); - - /* These op characters should be ordinary if RE_CONTEXT_INVALID_OPS - isn't set. */ - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_BRACES | RE_INTERVALS - | RE_NO_BK_PARENS); - MATCH_SELF ("*"); - test_match ("a|*", "*"); - test_match ("(*)", "*"); - - MATCH_SELF ("+"); - test_match ("a|+", "+"); - test_match ("(+)", "+"); - - MATCH_SELF ("?"); - test_match ("a|?", "?"); - test_match ("(?)", "?"); - - MATCH_SELF ("{1}"); - test_match ("a|{1}", "a"); - test_match ("a|{1}", "{1}"); - test_match ("({1})", "{1}"); - - test_match ("\\{", "{"); - - - re_set_syntax (RE_LIMITED_OPS); - MATCH_SELF ("|"); - MATCH_SELF ("a|"); - MATCH_SELF ("a|"); - MATCH_SELF ("a||"); - MATCH_SELF ("a||"); - MATCH_SELF ("(|)"); - - re_set_syntax (RE_SYNTAX_EMACS); - TEST_SEARCH ("^a", "b\na", 0, 3); - TEST_SEARCH ("b$", "b\na", 0, 3); - -#if 0 - /* Newline is no longer special for anchors (16 Sep 92). --karl */ - test_match_2 ("a\n^b", "a", "\nb"); - test_match_2 ("a$\nb", "a\n", "b"); -#endif - - /* Test grouping. */ - re_set_syntax (RE_NO_BK_PARENS); - - test_match ("()", ""); - test_fastmap ("()", "", 0, 0); - TEST_REGISTERS ("()", "", 0, 0, 0, 0, -1, -1); - - test_match ("((((((((()))))))))", ""); - test_fastmap ("((((((((()))))))))", "", 0, 0); - test_match ("a()b", "ab"); - TEST_REGISTERS ("a()b", "ab", 0, 2, 1, 1, -1, -1); - - test_match ("(((((((((())))))))))", ""); - test_fastmap ("(((((((((())))))))))", "", 0, 0); - - test_match ("()*", ""); - TEST_REGISTERS ("()*", "", 0, 0, 0, 0, -1, -1); /* empty string */ - test_match ("(())*", ""); - - re_set_syntax (RE_CONTEXT_INDEP_OPS); - test_match ("*", ""); - - re_set_syntax (RE_INTERVALS | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES); - test_match ("{1}", ""); /* Should remain an interval. */ - MATCH_SELF ("{1"); /* Not a valid interval. */ - - re_set_syntax (RE_NEWLINE_ALT); - test_match ("a\nb", "a"); - test_match ("a\nb", "b"); - - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); - test_match ("^a", "a"); - test_match ("(^a)", "a"); - test_match ("(a|^b)", "b"); - test_match ("a$", "a"); - test_match ("(a$)", "a"); - test_match ("a$|b", "a"); - - /* You should be able to have empty alternatives if RE_NO_EMPTY_ALTS - isn't set. */ - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); - - test_match ("|", ""); - test_match ("^|a", ""); - test_match ("^|a", "a"); - test_match ("a|", ""); - test_match ("a|", "a"); - test_match ("a|$", ""); - test_match ("a|$", "a"); - test_match ("a||b", "a"); - test_match ("a||b", ""); - test_match ("a||b", "b"); - test_match ("(|a)", ""); - test_match ("(|a)", "a"); - test_match ("(a|)", ""); - test_match ("(a|)", "a"); - - TEST_SEARCH ("a|$", "xa", 0, 2); - TEST_SEARCH ("a|$", "x", 0, 1); - TEST_SEARCH ("$|b", "x", 0, 1); - TEST_SEARCH ("$|b", "xb", 0, 2); - TEST_SEARCH ("c(a|$)", "xca", 0, 3); - TEST_SEARCH ("c(a|$)", "xc", 0, 2); - TEST_SEARCH ("c($|b)", "xcb", 0, 3); - TEST_SEARCH ("c($|b)", "xc", 0, 2); - TEST_SEARCH ("c($|b$)", "xcb", 0, 3); - TEST_SEARCH ("c($|b$)", "xc", 0, 2); - TEST_SEARCH ("c(a$|$)", "xca", 0, 3); - TEST_SEARCH ("c(a$|$)", "xc", 0, 2); - TEST_SEARCH ("(a$|b$)|$", "x", 0, 1); - TEST_SEARCH ("(a$|b$)|$", "xa", 0, 2); - TEST_SEARCH ("(a$|b$)|$", "xb", 0, 2); - TEST_SEARCH ("(a$|$)|c$", "x", 0, 1); - TEST_SEARCH ("(a$|$)|c$", "xa", 0, 2); - TEST_SEARCH ("(a$|$)|c$", "xc", 0, 2); - TEST_SEARCH ("($|b$)|c$", "x", 0, 1); - TEST_SEARCH ("($|b$)|c$", "xb", 0, 2); - TEST_SEARCH ("($|b$)|c$", "xc", 0, 2); - TEST_SEARCH ("c$|(a$|$)", "x", 0, 1); - TEST_SEARCH ("c$|(a$|$)", "xa", 0, 2); - TEST_SEARCH ("c$|(a$|$)", "xc", 0, 2); - TEST_SEARCH ("c$|($|b$)", "x", 0, 1); - TEST_SEARCH ("c$|($|b$)", "xb", 0, 2); - TEST_SEARCH ("c$|($|b$)", "xc", 0, 2); - TEST_SEARCH ("$|(a$|b$)", "x", 0, 1); - TEST_SEARCH ("$|(a$|b$)", "xa", 0, 2); - TEST_SEARCH ("$|(a$|b$)", "xb", 0, 2); - TEST_SEARCH ("c(a$|b$)|$", "x", 0, 1); - TEST_SEARCH ("c(a$|b$)|$", "xca", 0, 3); - TEST_SEARCH ("c(a$|b$)|$", "xcb", 0, 3); - TEST_SEARCH ("c(a$|$)|d$", "xc", 0, 2); - TEST_SEARCH ("c(a$|$)|d$", "xca", 0, 3); - TEST_SEARCH ("c(a$|$)|d$", "xd", 0, 2); - TEST_SEARCH ("c($|b$)|d$", "xc", 0, 2); - TEST_SEARCH ("c($|b$)|d$", "xcb", 0, 3); - TEST_SEARCH ("c($|b$)|d$", "xd", 0, 2); - TEST_SEARCH ("d(c$|e((a$|$)))", "xdc", 0, 3); - TEST_SEARCH ("d(c$|e((a$|$)))", "xde", 0, 3); - TEST_SEARCH ("d(c$|e((a$|$)))", "xdea", 0, 4); - TEST_SEARCH ("d(c$|e(($|b$)))", "xdc", 0, 3); - TEST_SEARCH ("d(c$|e(($|b$)))", "xde", 0, 3); - TEST_SEARCH ("d(c$|e(($|b$)))", "xdeb", 0, 4); - TEST_SEARCH ("d($|e((a$|b$)))", "xd", 0, 2); - TEST_SEARCH ("d($|e((a$|b$)))", "xdea", 0, 4); - TEST_SEARCH ("d($|e((a$|b$)))", "xdeb", 0, 4); - TEST_SEARCH ("a(b$|c$)|$", "x", 0, 1); - TEST_SEARCH ("a(b$|c$)|$", "xab", 0, 3); - TEST_SEARCH ("a(b$|c$)|$", "xac", 0, 3); - TEST_SEARCH ("a(b$|$)|d$", "xa", 0, 2); - TEST_SEARCH ("a(b$|$)|d$", "xab", 0, 3); - TEST_SEARCH ("a(b$|$)|d$", "xd", 0, 2); - TEST_SEARCH ("a($|c$)|d$", "xa", 0, 2); - TEST_SEARCH ("a($|c$)|d$", "xac", 0, 3); - TEST_SEARCH ("a($|c$)|d$", "xd", 0, 2); - TEST_SEARCH ("d$|a(b$|$)", "xd", 0, 2); - TEST_SEARCH ("d$|a(b$|$)", "xa", 0, 2); - TEST_SEARCH ("d$|a(b$|$)", "xab", 0, 3); - TEST_SEARCH ("d$|a($|c$)", "xd", 0, 2); - TEST_SEARCH ("d$|a($|c$)", "xa", 0, 2); - TEST_SEARCH ("d$|a($|c$)", "xac", 0, 3); - TEST_SEARCH ("$|a(b$|c$)", "x", 0, 1); - TEST_SEARCH ("$|a(b$|c$)", "xab", 0, 3); - TEST_SEARCH ("$|a(b$|c$)", "xac", 0, 3); - TEST_SEARCH ("(a)(b$|c$)|d$", "xab", 0, 3); - TEST_SEARCH ("(a)(b$|c$)|d$", "xac", 0, 3); - TEST_SEARCH ("(a)(b$|c$)|d$", "xd", 0, 2); - TEST_SEARCH ("(a)(b$|$)|d$", "xa", 0, 2); - TEST_SEARCH ("(a)(b$|$)|d$", "xab", 0, 3); - TEST_SEARCH ("(a)(b$|$)|d$", "xd", 0, 2); - TEST_SEARCH ("(a)($|c$)|d$", "xa", 0, 2); - TEST_SEARCH ("(a)($|c$)|d$", "xac", 0, 3); - TEST_SEARCH ("(a)($|c$)|d$", "xd", 0, 2); - TEST_SEARCH ("d$|(a)(b$|$)", "xd", 0, 2); - TEST_SEARCH ("d$|(a)(b$|$)", "xa", 0, 2); - TEST_SEARCH ("d$|(a)(b$|$)", "xab", 0, 3); - TEST_SEARCH ("d$|(a)($|c$)", "xd", 0, 2); - TEST_SEARCH ("d$|(a)($|c$)", "xa", 0, 2); - TEST_SEARCH ("d$|(a)($|c$)", "xac", 0, 3); - TEST_SEARCH ("$|(a)(b$|c$)", "x", 0, 1); - TEST_SEARCH ("$|(a)(b$|c$)", "xab", 0, 3); - TEST_SEARCH ("$|(a)(b$|c$)", "xac", 0, 3); - TEST_SEARCH ("d$|(c$|(a$|$))", "x", 0, 1); - TEST_SEARCH ("d$|(c$|(a$|$))", "xd", 0, 2); - TEST_SEARCH ("d$|(c$|(a$|$))", "xc", 0, 2); - TEST_SEARCH ("d$|(c$|(a$|$))", "xa", 0, 2); - TEST_SEARCH ("d$|(c$|($|b$))", "x", 0, 1); - TEST_SEARCH ("d$|(c$|($|b$))", "xd", 0, 2); - TEST_SEARCH ("d$|(c$|($|b$))", "xc", 0, 2); - TEST_SEARCH ("d$|(c$|($|b$))", "xb", 0, 2); - TEST_SEARCH ("d$|($|(a$|b$))", "x", 0, 1); - TEST_SEARCH ("d$|($|(a$|b$))", "xd", 0, 2); - TEST_SEARCH ("d$|($|(a$|b$))", "xa", 0, 2); - TEST_SEARCH ("d$|($|(a$|b$))", "xb", 0, 2); - TEST_SEARCH ("$|(c$|(a$|b$))", "x", 0, 1); - TEST_SEARCH ("$|(c$|(a$|b$))", "xc", 0, 2); - TEST_SEARCH ("$|(c$|(a$|b$))", "xa", 0, 2); - TEST_SEARCH ("$|(c$|(a$|b$))", "xb", 0, 2); - TEST_SEARCH ("d$|c(a$|$)", "xd", 0, 2); - TEST_SEARCH ("d$|c(a$|$)", "xc", 0, 2); - TEST_SEARCH ("d$|c(a$|$)", "xca", 0, 3); - TEST_SEARCH ("d$|c($|b$)", "xd", 0, 2); - TEST_SEARCH ("d$|c($|b$)", "xc", 0, 2); - TEST_SEARCH ("d$|c($|b$)", "xcb", 0, 3); - TEST_SEARCH ("$|c(a$|b$)", "x", 0, 1); - TEST_SEARCH ("$|c(a$|b$)", "xca", 0, 3); - TEST_SEARCH ("$|c(a$|b$)", "xcb", 0, 3); - TEST_SEARCH ("e(d$|c((a$|$)))", "xed", 0, 3); - TEST_SEARCH ("e(d$|c((a$|$)))", "xec", 0, 3); - TEST_SEARCH ("e(d$|c((a$|$)))", "xeca", 0, 3); - TEST_SEARCH ("e(d$|c(($|b$)))", "xed", 0, 3); - TEST_SEARCH ("e(d$|c(($|b$)))", "xec", 0, 3); - TEST_SEARCH ("e(d$|c(($|b$)))", "xecb", 0, 4); - TEST_SEARCH ("e($|c((a$|b$)))", "xe", 0, 2); - TEST_SEARCH ("e($|c((a$|b$)))", "xeca", 0, 4); - TEST_SEARCH ("e($|c((a$|b$)))", "xecb", 0, 4); - TEST_SEARCH ("ed$|(c((a$|$)))", "xed", 0, 3); - TEST_SEARCH ("ed$|(c((a$|$)))", "xc", 0, 2); - TEST_SEARCH ("ed$|(c((a$|$)))", "xca", 0, 3); - TEST_SEARCH ("ed$|(c(($|b$)))", "xed", 0, 3); - TEST_SEARCH ("ed$|(c(($|b$)))", "xc", 0, 2); - TEST_SEARCH ("ed$|(c(($|b$)))", "xcb", 0, 3); - TEST_SEARCH ("$|(c((a$|b$)))", "x", 0, 1); - TEST_SEARCH ("$|(c((a$|b$)))", "xca", 0, 3); - TEST_SEARCH ("$|(c((a$|b$)))", "xcb", 0, 3); - TEST_SEARCH ("d$|($|(a|b)$)", "x", 0, 1); - TEST_SEARCH ("d$|($|(a|b)$)", "xa", 0, 2); - TEST_SEARCH ("d$|($|(a|b)$)", "xb", 0, 2); - TEST_SEARCH ("$|(c$|(a|b)$)", "x", 0, 1); - TEST_SEARCH ("$|(c$|(a|b)$)", "xc", 0, 2); - TEST_SEARCH ("$|(c$|(a|b)$)", "xa", 0, 2); - TEST_SEARCH ("$|(c$|(a|b)$)", "xb", 0, 2); - - re_set_syntax (0); - test_match ("[^\n]", "a"); - test_match ("[^a]", "\n"); - - TEST_SEARCH ("^a", "b\na", 0, 3); - TEST_SEARCH ("b$", "b\na", 0, 3); - - test_case_fold ("[!-`]", "A"); - test_case_fold ("[!-`]", "a"); - - re_set_syntax (RE_CONTEXT_INDEP_OPS | RE_NO_BK_VBAR | RE_NO_BK_PARENS - | RE_NO_BK_BRACES | RE_INTERVALS); - valid_nonposix_pattern ("()^a"); - valid_nonposix_pattern ("()\\1^a"); - - /* Per Cederqvist (cedar@lysator.liu.se) bug. */ - - re_set_syntax (RE_SYNTAX_EMACS); - - /* One `a' before the \n and 638 a's after it. */ - test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "a\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - - /* No a's before the \n and 639 a's after it. */ - test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - - /* One `a' before the \n and 639 a's after it. */ - test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "a\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - - /* No a's before the \n and 640 a's after it. */ - test_search_return (0, "\\(.*\\)\n\\(\\(.\\|\n\\)*\\)$", "\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); - TEST_SEARCH ("^(^a)", "ab", 0, 2); - TEST_SEARCH ("(a$)$", "ba", 0, 2); - test_match ("a|$b", "$b"); - - /* Mike's curiosity item. */ - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS); - test_all_registers ("(foo|foobar)(foo|bar)*\\1(foo|bar)*", - "foobarfoobar", "", - 0, 12, 0, 3, 3, 6, 9, 12, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1); - - /* Another one from Mike. */ - test_match ("(foo|foobarfoo)(bar)*", "foobarfoo"); - - /* And another. */ - test_match("(foo|foobar)(bar|barfoo)?\\1", "foobarfoobar"); - - re_set_syntax (RE_NO_BK_PARENS | RE_INTERVALS | RE_NO_BK_VBAR - | RE_NO_BK_BRACES); /* xx get new ones from ext.*/ - test_match ("((a{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)*", "bb"); - test_all_registers ("((a{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)*", "", "bb", - 0, 2, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1); - - test_match ("((a+?*{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)", "b"); - test_all_registers ("((a+?*{0,}{0,0}()\\3\\b\\B\\<\\>\\`\\')|b)", "", "b", - 0, 1, 0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1); - - /* Valid anchoring. */ - /* See generic_test.c and extended_test.c for more search - tests. xx Not sure all these tests are represented in the - search tests. */ - - re_set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR); - valid_nonposix_pattern - ("(((((((((((((((((((((((((((((((((^a)))))))))))))))))))))))))))))))))"); - valid_nonposix_pattern - ("(((((((((((((((((((((((((((((((((a$)))))))))))))))))))))))))))))))))"); - valid_nonposix_pattern ("\\b\\B\\<\\>\\`\\'^a"); - valid_nonposix_pattern ("a$\\b\\B\\<\\>\\`\\'"); - valid_nonposix_pattern ("(^a)"); - valid_nonposix_pattern ("(a$)"); - valid_nonposix_pattern ("(^a)b"); - valid_nonposix_pattern ("b(a$)"); - valid_nonposix_pattern ("(^a|^b)c"); - valid_nonposix_pattern ("c(a$|b$)"); - valid_nonposix_pattern ("(^a|^b)|^c"); - valid_nonposix_pattern ("(a$|b$)|c$"); - valid_nonposix_pattern ("^c|(^a|^b)"); - valid_nonposix_pattern ("c$|(a$|b$)"); - valid_nonposix_pattern ("(^a|^b)c|^d"); - valid_nonposix_pattern ("c(a$|b$)|d$"); - valid_nonposix_pattern ("(((^a|^b))c|^d)e"); - valid_nonposix_pattern ("(c((a|b))|d)e$"); - valid_nonposix_pattern ("^d(c|e((a|b)))"); - valid_nonposix_pattern ("d(c$|e((a$|b$)))"); - valid_nonposix_pattern ("(((^a|^b))c)|^de"); - valid_nonposix_pattern ("(((a|b))c$)|de$"); - - valid_nonposix_pattern ("((a$)$)$"); - valid_nonposix_pattern ("^(^(^a))"); - - valid_nonposix_pattern ("^de|^(c((a|b)))"); - valid_nonposix_pattern ("^de|(^c((a|b)))"); - valid_nonposix_pattern ("de$|(c((a|b)$))"); - valid_nonposix_pattern ("de$|(c((a|b))$)"); - valid_nonposix_pattern ("de$|(c((a|b)))$"); - - valid_nonposix_pattern ("^a(b|c)|^d"); - valid_nonposix_pattern ("a(b$|c$)|d$"); - valid_nonposix_pattern ("^d|^a(b|c)"); - valid_nonposix_pattern ("d$|a(b$|c$)"); - valid_nonposix_pattern ("^d|^(b|c)a"); - valid_nonposix_pattern ("d$|(b|c)a$"); - valid_nonposix_pattern ("^(a)(b|c)|^d"); - valid_nonposix_pattern ("(a)(b|c)$|d$"); - valid_nonposix_pattern ("(^a)(b|c)|^d"); - valid_nonposix_pattern ("(a)(b$|c$)|d$"); - valid_nonposix_pattern ("^d|^(b|c)(a)"); - valid_nonposix_pattern ("d$|(b|c)(a)$"); - valid_nonposix_pattern ("^d|(^b|^c)(a)"); - valid_nonposix_pattern ("d$|(b|c)(a$)"); - valid_nonposix_pattern ("^d|^(a)(b|c)"); - valid_nonposix_pattern ("^d|(^a)(b|c)"); - valid_nonposix_pattern ("d$|(a)(b$|c$)"); - valid_nonposix_pattern ("((^a|^b)|^c)|^d"); - valid_nonposix_pattern ("d$|(c$|(a$|b$))"); - - - /* Tests shouldn't match. */ - test_should_match = false; - - /* Test that RE_CONTEXT_INVALID_OPS has precedence over - RE_CONTEXT_INDEP_OPS. */ - - re_set_syntax (RE_CONTEXT_INDEP_OPS | RE_CONTEXT_INVALID_OPS - | RE_NO_BK_VBAR | RE_NO_BK_PARENS - | RE_NO_BK_BRACES | RE_INTERVALS); - INVALID_PATTERN ("*"); - INVALID_PATTERN ("^*"); - INVALID_PATTERN ("a|*"); - INVALID_PATTERN ("(*)"); - - INVALID_PATTERN ("^+"); - INVALID_PATTERN ("+"); - INVALID_PATTERN ("a|+"); - INVALID_PATTERN ("(+)"); - - INVALID_PATTERN ("^?"); - INVALID_PATTERN ("?"); - INVALID_PATTERN ("a|?"); - INVALID_PATTERN ("(?)"); - - INVALID_PATTERN ("^{1}"); - INVALID_PATTERN ("{1}"); - INVALID_PATTERN ("a|{1}"); - INVALID_PATTERN ("({1})"); - -#if 0 - /* No longer have this syntax option -- POSIX says empty alternatives - are undefined as of draft 11.2. */ - - /* You can't have empty alternatives if RE_NO_EMPTY_ALTS is set. */ - - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_ALTS); - - INVALID_PATTERN ("|"); - INVALID_PATTERN ("^|a"); - INVALID_PATTERN ("a|"); - INVALID_PATTERN ("a||"); - INVALID_PATTERN ("a||b"); - INVALID_PATTERN ("(|a)"); - INVALID_PATTERN ("(a|)"); - INVALID_PATTERN ("(a|)"); - - - /* Test above with `\(' and `\)'. */ - re_set_syntax (RE_NO_BK_VBAR | RE_NO_EMPTY_ALTS); - INVALID_PATTERN ("\\(|a\\)"); - INVALID_PATTERN ("\\(a|\\)"); - - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_ALTS); - INVALID_PATTERN ("(|)()$|d$"); -#endif - - /* Test grouping. */ - test_match ("()", "a"); - - /* Test backslashed intervals that are CONTEXTly invalid if have - nothing on which to operate. */ - - re_set_syntax (RE_INTERVALS | RE_CONTEXT_INVALID_OPS); - INVALID_PATTERN ("\\{1\\}"); - - re_set_syntax (0); - test_match ("z-a", "a"); - - re_set_syntax (RE_BK_PLUS_QM); - INVALID_PATTERN ("a*\\"); - - re_set_syntax (0); - INVALID_PATTERN ("a*\\"); - - re_set_syntax (RE_BACKSLASH_ESCAPE_IN_LISTS); - INVALID_PATTERN ("[\\"); - -#if 0 - /* Empty groups are always ok now. (13 Sep 92) */ - re_set_syntax (RE_NO_BK_VBAR | RE_NO_BK_PARENS | RE_NO_EMPTY_GROUPS); - INVALID_PATTERN ("(|)()$|d$"); -#endif - - printf ("\nFinished non-POSIX tests.\n"); -} - - - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/regex-0.12/test/printchar.c b/gnu/lib/regex-0.12/test/printchar.c deleted file mode 100644 index 1b756f441be3..000000000000 --- a/gnu/lib/regex-0.12/test/printchar.c +++ /dev/null @@ -1,14 +0,0 @@ -void -printchar (c) - char c; -{ - if (c < 040 || c >= 0177) - { - putchar ('\\'); - putchar (((c >> 6) & 3) + '0'); - putchar (((c >> 3) & 7) + '0'); - putchar ((c & 7) + '0'); - } - else - putchar (c); -} diff --git a/gnu/lib/regex-0.12/test/psx-basic.c b/gnu/lib/regex-0.12/test/psx-basic.c deleted file mode 100644 index 52535b6b3076..000000000000 --- a/gnu/lib/regex-0.12/test/psx-basic.c +++ /dev/null @@ -1,253 +0,0 @@ -/* psx-basic.c: Test POSIX basic regular expressions. */ - -#include "test.h" - - -void -test_posix_basic () -{ - /* Intervals can only match up to RE_DUP_MAX occurences of anything. */ - char dup_max_plus_one[6]; - sprintf (dup_max_plus_one, "%d", RE_DUP_MAX + 1); - - printf ("\nStarting POSIX basic tests.\n"); - t = posix_basic_test; - - re_set_syntax (RE_SYNTAX_POSIX_MINIMAL_BASIC); - - test_posix_generic (); - - printf ("\nContinuing POSIX basic tests.\n"); - -/* Grouping tests that are not the same. */ - - test_should_match = false; - invalid_pattern (REG_EPAREN, PARENS_TO_OPS ("a)")); - - test_should_match = true; - /* Special characters. */ - MATCH_SELF ("*"); - test_match ("\\(*\\)", "*"); - test_match ("\\(^*\\)", "*"); - test_match ("**", "***"); - test_match ("***", "****"); - - MATCH_SELF ("{"); /* of extended... */ - MATCH_SELF ("()"); /* also non-Posix. */ - MATCH_SELF ("a+"); - MATCH_SELF ("a?"); - MATCH_SELF ("a|b"); - MATCH_SELF ("a|"); /* No alternations, */ - MATCH_SELF ("|a"); /* so OK if empty. */ - MATCH_SELF ("a||"); - test_match ("\\(|a\\)", "|a"); - test_match ("\\(a|\\)", "a|"); - test_match ("a\\+", "a+"); - test_match ("a\\?", "a?"); - test_match ("a\\|b", "a|b"); - test_match ("^*", "*"); - test_match ("^+", "+"); - test_match ("^?", "?"); - test_match ("^{", "{"); - /* Valid subexpressions - (empty) in basic only. */ - test_match ("\\(\\)", ""); - - test_match ("a\\(\\)", "a"); - test_match ("\\(\\)b", "b"); - test_match ("a\\(\\)b", "ab"); - TEST_REGISTERS ("a\\(\\)b", "ab", 0, 2, 1, 1, -1, -1); - - test_match ("\\(\\)*", ""); - test_match ("\\(\\(\\)\\)*", ""); - /* Valid back references. */ - - /* N.B.: back references to subexpressions that include a * are - undefined in the spec. The tests are in here to see if we handle - the situation consistently, but if it fails any of them, it doesn't - matter. */ - - test_match ("\\(\\)\\1", ""); - TEST_REGISTERS ("\\(\\)\\1", "", 0, 0, 0, 0, -1, -1); - - test_match ("\\(\\(\\)\\)\\(\\)\\2", ""); - - test_match ("\\(a\\)\\1", "aa"); - TEST_REGISTERS ("\\(a\\)\\1", "aa", 0, 2, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a\\)\\1", "xaax", 1, 3, 1, 2, -1, -1); - - test_match ("\\(\\(a\\)\\)\\1", "aa"); - test_match ("\\(a\\)\\(b\\)\\2\\1", "abba"); - - test_match ("\\(a\\)*\\1", "aa"); - TEST_REGISTERS ("\\(a\\)*\\1", "aa", 0, 2, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a\\)*\\1", "xaax", 0, 0, -1, -1, -1, -1); - - test_match ("\\(\\(a\\)\\2b\\)*", "aab"); - TEST_REGISTERS ("\\(\\(a\\)\\2b\\)*", "aab", 0, 3, 0, 3, 0, 1); - TEST_REGISTERS ("\\(\\(a\\)\\2b\\)*", "xaabx", 0, 0, -1, -1, -1, -1); - - test_match ("\\(a*\\)*\\1", ""); - test_match ("\\(a*\\)*\\1", "aa"); - TEST_REGISTERS ("\\(a*\\)*\\1", "aa", 0, 2, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a*\\)*\\1", "xaax", 0, 0, 0, 0, -1, -1); - - test_match ("\\(a*\\)*\\1", ""); - test_match ("\\(a*\\)*\\1", "aa"); - test_match ("\\(\\(a*\\)*\\)*\\1", "aa"); - test_match ("\\(ab*\\)*\\1", "abab"); - TEST_REGISTERS ("\\(ab*\\)*\\1", "abab", 0, 4, 0, 2, -1, -1); - TEST_REGISTERS ("\\(ab*\\)*\\1", "xababx", 0, 0, -1, -1, -1, -1); - - test_match ("\\(a*\\)ab\\1", "aaba"); - TEST_REGISTERS ("\\(a*\\)ab\\1", "aaba", 0, 4, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a*\\)ab\\1", "xaabax", 1, 5, 1, 2, -1, -1); - - test_match ("\\(a*\\)*ab\\1", "aaba"); - TEST_REGISTERS ("\\(a*\\)*ab\\1", "aaba", 0, 4, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a*\\)*ab\\1", "xaabax", 1, 5, 1, 2, -1, -1); - - test_match ("\\(\\(a*\\)b\\)*\\2", "abb"); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "abb", 0, 3, 2, 3, 2, 2); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "xabbx", 0, 0, -1, -1, -1, -1); - - /* Different from above. */ - test_match ("\\(\\(a*\\)b*\\)*\\2", "aa"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aa", 0, 2, 0, 1, 0, 1); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaax", 0, 0, 0, 0, 0, 0); - - test_match ("\\(\\(a*\\)b*\\)*\\2", "aba"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aba", 0, 3, 0, 2, 0, 1); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xabax", 0, 0, 0, 0, 0, 0); - - test_match ("\\(\\(a*\\)b\\)*\\2", "aababa"); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "aababa", 0, 6, 3, 5, 3, 4); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2", "xaababax", 0, 0, -1, -1, -1, -1); - - test_match ("\\(\\(a*\\)b*\\)*\\2", "aabaa"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aabaa", 0, 5, 0, 3, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaabaax", 0, 0, 0, 0, 0, 0); - - test_match ("\\(\\(a*\\)b*\\)*\\2", "aabbaa"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "aabbaa", 0, 6, 0, 4, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaabbaax", 0, 0, 0, 0, 0, 0); - - test_match ("\\(\\(a*\\)b*\\)*\\2", "abaabaa"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "abaabaa", 0, 7, 2, 5, 2, 4); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2", "xaababaax", 0, 0, 0, 0, 0, 0); - - test_match ("\\(\\(a*\\)b*\\)*a\\2", "aabaaa"); - TEST_REGISTERS ("\\(\\(a*\\)b*a\\)*\\2", "aabaaa", 0, 6, 0, 3, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*a\\)*\\2", "xaabaax", 0, 0, -1, -1, -1, -1); - - test_match ("\\(\\(a*\\)b*\\)*\\2a", "aabaaa"); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2a", "aabaaa", 0, 6, 0, 3, 0, 2); - TEST_REGISTERS ("\\(\\(a*\\)b*\\)*\\2a", "xaabaaax", 1, 7, 1, 4, 1, 3); - - test_match ("\\(\\(a*\\)b\\)*\\2\\1", "abaabaaaab"); - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2\\1", "abaabaaaab", 0, 10, 2, 5, 2, 4); - /* We are matching the empty string here. */ - TEST_REGISTERS ("\\(\\(a*\\)b\\)*\\2\\1", "xabaabaaaabx", 0, 0, -1, -1, -1, -1); - - test_match ("\\(a*b\\)\\1", "abab"); - test_match ("\\(a\\)\\1\\1", "aaa"); - test_match ("\\(a\\(c\\)d\\)\\1\\2", "acdacdc"); - - test_match ("\\(a\\)\\1*", "aaa"); - TEST_REGISTERS ("\\(a\\)\\1*", "aaa", 0, 3, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a\\)\\1*", "xaaax", 1, 4, 1, 2, -1, -1); - - test_match ("\\(a\\)\\{1,3\\}b\\1", "aba"); - TEST_REGISTERS ("\\(a\\)\\{1,3\\}b\\1", "aba", 0, 3, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a\\)\\{1,3\\}b\\1", "xabax", 1, 4, 1, 2, -1, -1); - - test_match ("\\(\\(a\\)\\2\\)*", "aaaa"); /* rms? */ - TEST_REGISTERS ("\\(\\(a*b\\)\\2\\)*", "bbabab", 0, 6, 2, 6, 2, 4); /* rms? */ - - test_match ("\\(\\(a\\)\\1\\)*", "a1a1"); - - test_match ("\\(\\(a\\)\\2\\)\\1", "aaaa"); - - test_match ("\\(\\(a*\\)\\2\\)\\1", "aaaa"); - TEST_REGISTERS ("\\(\\(a*\\)\\2\\)\\1", "aaaa", 0, 4, 0, 2, 0, 1); - TEST_REGISTERS ("\\(\\(a*\\)\\2\\)\\1", "xaaaax", 0, 0, 0, 0, 0, 0); - - test_match ("\\{1\\}", "{1}"); - test_match ("^\\{1\\}", "{1}"); - - test_match ("\\(a\\)\\1\\{1,2\\}", "aaa"); - TEST_REGISTERS ("\\(a\\)\\1\\{1,2\\}", "aaa", 0, 3, 0, 1, -1, -1); - TEST_REGISTERS ("\\(a\\)\\1\\{1,2\\}", "xaaax", 1, 4, 1, 2, -1, -1); - - - /* Per POSIX D11.1 p. 109, leftmost longest match. */ - - test_match (PARENS_TO_OPS ("(.*).*\\1"), "abcabc"); - - - /* Per POSIX D11.1, p. 125, leftmost longest match. */ - - test_match (PARENS_TO_OPS ("(ac*)c*d[ac]*\\1"), "acdacaaa"); - TEST_REGISTERS (PARENS_TO_OPS ("(ac*)c*d[ac]*\\1"), "acdacaaa", - 0, 8, 0, 1, -1, -1); - - /* Anchors become ordinary, sometimes. */ - MATCH_SELF ("a^"); - MATCH_SELF ("$a"); - MATCH_SELF ("$^"); - test_fastmap ("$a^", "$", 0, 0); - test_match ("$^*", "$^^"); - test_match ("\\($^\\)", "$^"); - test_match ("$*", "$$"); - /* xx -- known bug, solution pending test_match ("^^$", "^"); */ - test_match ("$\\{0,\\}", "$$"); - TEST_SEARCH ("^$*", "$$", 0, 2); - TEST_SEARCH ("^$\\{0,\\}", "$$", 0, 2); - MATCH_SELF ("2^10"); - MATCH_SELF ("$HOME"); - MATCH_SELF ("$1.35"); - - - /* Basic regular expressions, continued; these don't match their strings. */ - test_should_match = false; - - invalid_pattern (REG_EESCAPE, "\\(a\\"); - /* Invalid back references. */ - test_match ("\\(a\\)\\1", "ab"); - test_match ("\\(a\\)\\1\\1", "aab"); - test_match ("\\(a\\)\\(b\\)\\2\\1", "abab"); - test_match ("\\(a\\(c\\)d\\)\\1\\2", "acdc"); - test_match ("\\(a*b\\)\\1", "abaab"); - test_match ("\\(a\\)\\1*", "aaaaaaaaaab"); - test_match ("\\(\\(a\\)\\1\\)*", "aaa"); - invalid_pattern (REG_ESUBREG, "\\1"); - invalid_pattern (REG_ESUBREG, "\\(a\\)\\2"); - test_match ("\\(\\(a\\)\\2\\)*", "abaa"); - test_match ("\\(\\(a\\)\\1\\)*", "a"); - test_match ("\\(\\(a\\)\\2\\)\\1", "abaa"); - test_match ("\\(\\(a*\\)\\2\\)\\1", "abaa"); - /* Invalid intervals. */ - invalid_pattern (REG_EBRACE, "a\\{"); - - invalid_pattern (REG_BADBR, "a\\{-1"); - invalid_pattern (REG_BADBR, concat ("a\\{", (char *)dup_max_plus_one)); - invalid_pattern (REG_BADBR, concat (concat ("a\\{", (char *)dup_max_plus_one), ",")); - invalid_pattern (REG_BADBR, "a\\{1,0"); - - invalid_pattern (REG_EBRACE, "a\\{1"); - invalid_pattern (REG_EBRACE, "a\\{0,"); - invalid_pattern (REG_EBRACE, "a\\{0,1"); - invalid_pattern (REG_EBRACE, "a\\{0,1}"); - - printf ("\nFinished POSIX basic tests.\n"); -} - - - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/regex-0.12/test/psx-extend.c b/gnu/lib/regex-0.12/test/psx-extend.c deleted file mode 100644 index 6f02d67b8219..000000000000 --- a/gnu/lib/regex-0.12/test/psx-extend.c +++ /dev/null @@ -1,1244 +0,0 @@ -/* psx-extend.c: Test POSIX extended regular expressions. */ - -#include "test.h" - - -void -test_posix_extended () -{ - /* Intervals can only match up to RE_DUP_MAX occurences of anything. */ - char dup_max_plus_one[6]; - sprintf (dup_max_plus_one, "%d", RE_DUP_MAX + 1); - - - printf ("\nStarting POSIX extended tests.\n"); - t = posix_extended_test; - - re_set_syntax (RE_SYNTAX_POSIX_MINIMAL_EXTENDED); - - test_posix_generic (); - - printf ("\nContinuing POSIX extended tests.\n"); - - /* Grouping tests that differ from basic's. */ - - test_should_match = true; - MATCH_SELF ("a)"); - - /* Valid use of special characters. */ - test_match ("\\(a", "(a"); - test_match ("a\\+", "a+"); - test_match ("a\\?", "a?"); - test_match ("\\{a", "{a"); - test_match ("\\|a", "|a"); - test_match ("a\\|b", "a|b"); - test_match ("a\\|?", "a"); - test_match ("a\\|?", "a|"); - test_match ("a\\|*", "a"); - test_match ("a\\|*", "a||"); - test_match ("\\(*\\)", ")"); - test_match ("\\(*\\)", "(()"); - test_match ("a\\|+", "a|"); - test_match ("a\\|+", "a||"); - test_match ("\\(+\\)", "()"); - test_match ("\\(+\\)", "(()"); - test_match ("a\\||b", "a|"); - test_match ("\\(?\\)", ")"); - test_match ("\\(?\\)", "()"); - - test_match ("a+", "a"); - test_match ("a+", "aa"); - test_match ("a?", ""); - test_match ("a?", "a"); - - /* Bracket expressions. */ - test_match ("[(]", "("); - test_match ("[+]", "+"); - test_match ("[?]", "?"); - test_match ("[{]", "{"); - test_match ("[|]", "|"); - /* Subexpressions. */ - test_match ("(a+)*", ""); - test_match ("(a+)*", "aa"); - test_match ("(a?)*", ""); - test_match ("(a?)*", "aa"); - /* (No) back references. */ - test_match ("(a)\\1", "a1"); - /* Invalid as intervals, - but are valid patterns. */ - MATCH_SELF ("{"); - test_match ("^{", "{"); - test_match ("a|{", "{"); - test_match ("({)", "{"); - MATCH_SELF ("a{"); - MATCH_SELF ("a{}"); - MATCH_SELF ("a{-1"); - MATCH_SELF ("a{-1}"); - MATCH_SELF ("a{0"); - MATCH_SELF ("a{0,"); - MATCH_SELF (concat ("a{", dup_max_plus_one)); - MATCH_SELF (concat (concat ("a{", dup_max_plus_one), ",")); - MATCH_SELF ("a{1,0"); - MATCH_SELF ("a{1,0}"); - MATCH_SELF ("a{0,1"); - test_match ("[a{0,1}]", "}"); - test_match ("a{1,3}{-1}", "aaa{-1}"); - test_match (concat ("a{1,3}{", dup_max_plus_one), - concat ("aaa{", dup_max_plus_one)); - test_match ("a{1,3}{2,1}", "aaa{2,1}"); - test_match ("a{1,3}{1,2", "aaa{1,2"); - /* Valid consecutive repetitions. */ - test_match ("a*+", "a"); - test_match ("a*?", "a"); - test_match ("a++", "a"); - test_match ("a+*", "a"); - test_match ("a+?", "a"); - test_match ("a??", "a"); - test_match ("a?*", "a"); - test_match ("a?+", "a"); - - test_match ("a{2}?", ""); - test_match ("a{2}?", "aa"); - test_match ("a{2}+", "aa"); - test_match ("a{2}{2}", "aaaa"); - - test_match ("a{1}?*", ""); - test_match ("a{1}?*", "aa"); - - test_match ("(a?){0,3}b", "aaab"); - test_fastmap ("(a?){0,3}b", "ab", 0, 0); - test_match ("(a+){0,3}b", "b"); - test_fastmap ("(a+){0,3}b", "ab", 0, 0); - test_match ("(a+){0,3}b", "ab"); - test_fastmap ("(a+){0,3}b", "ab", 0, 0); - test_match ("(a+){1,3}b", "aaab"); - test_match ("(a?){1,3}b", "aaab"); - - test_match ("\\\\{1}", "\\"); /* Extended only. */ - - test_match ("(a?)?", "a"); - test_match ("(a?b)?c", "abc"); - test_match ("(a+)*b", "b"); - /* Alternatives. */ - test_match ("a|b", "a"); - test_match ("a|b", "b"); - test_fastmap ("a|b", "ab", 0, 0); - - TEST_SEARCH ("a|b", "cb", 0, 2); - TEST_SEARCH ("a|b", "cb", 0, 2); - - test_match ("(a|b|c)", "a"); - test_match ("(a|b|c)", "b"); - test_match ("(a|b|c)", "c"); - - test_match ("(a|b|c)*", "abccba"); - - test_match ("(a(b*))|c", "a"); /* xx do registers. */ - test_match ("(a(b*))|c", "ab"); - test_match ("(a(b*))|c", "c"); - - test_fastmap ("(a+?*|b)", "ab", 0, 0); - test_match ("(a+?*|b)", "b"); - TEST_REGISTERS ("(a+?*|b)", "b", 0, 1, 0, 1, -1, -1); - - test_fastmap ("(a+?*|b)*", "ab", 0, 0); - test_match ("(a+?*|b)*", "bb"); - TEST_REGISTERS ("(a+?*|b)*", "bb", 0, 2, 1, 2, -1, -1); - - test_fastmap ("(a*|b)*", "ab", 0, 0); - test_match ("(a*|b)*", "bb"); - TEST_REGISTERS ("(a*|b)*", "bb", 0, 2, 1, 2, -1, -1); - - test_fastmap ("((a*)|b)*", "ab", 0, 0); - test_match ("((a*)|b)*", "bb"); - TEST_REGISTERS ("((a*)|b)*", "bb", 0, 2, 1, 2, 1, 1); - - test_fastmap ("(a{0,}|b)*", "ab", 0, 0); - test_match ("(a{0,}|b)*", "bb"); - TEST_REGISTERS ("(a{0,}|b)*", "bb", 0, 2, 1, 2, -1, -1); - - test_fastmap ("((a{0,})|b)*", "ab", 0, 0); - test_match ("((a{0,})|b)*", "bb"); - TEST_REGISTERS ("((a{0,})|b)*", "bb", 0, 2, 1, 2, 1, 1); - - /* With c's */ - test_fastmap ("(a+?*|b)c", "abc", 0, 0); - test_match ("(a+?*|b)c", "bc"); - TEST_REGISTERS ("(a+?*|b)c", "bc", 0, 2, 0, 1, -1, -1); - - test_fastmap ("(a+?*|b)*c", "abc", 0, 0); - test_match ("(a+?*|b)*c", "bbc"); - TEST_REGISTERS ("(a+?*|b)*c", "bbc", 0, 3, 1, 2, -1, -1); - - test_fastmap ("(a*|b)*c", "abc", 0, 0); - test_match ("(a*|b)*c", "bbc"); - TEST_REGISTERS ("(a*|b)*c", "bbc", 0, 3, 1, 2, -1, -1); - - test_fastmap ("((a*)|b)*c", "abc", 0, 0); - test_match ("((a*)|b)*c", "bbc"); - TEST_REGISTERS ("((a*)|b)*c", "bbc", 0, 3, 1, 2, 1, 1); - - test_fastmap ("(a{0,}|b)*c", "abc", 0, 0); - test_match ("(a{0,}|b)*c", "bbc"); - TEST_REGISTERS ("(a{0,}|b)*c", "bbc", 0, 3, 1, 2, -1, -1); - - test_fastmap ("((a{0,})|b)*c", "abc", 0, 0); - test_match ("((a{0,})|b)*c", "bbc"); - TEST_REGISTERS ("((a{0,})|b)*c", "bbc", 0, 3, 1, 2, 1, 1); - - - test_fastmap ("((a{0,}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a{0,}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a{0,}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a{0,}\\b\\<)|b)*", "ab", 0, 0); - test_match ("((a{0,}\\b\\<)|b)*", "b"); - TEST_REGISTERS ("((a{0,}\\b\\<)|b)*", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,1}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,1}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,1}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,2}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,2}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,2}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - - test_fastmap ("((a+?*{0,4095}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,4095}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,4095}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,5119}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,5119}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,5119}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,6143}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,6143}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,6143}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,8191}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,8191}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,8191}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,16383}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,16383}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,16383}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - - test_fastmap ("((a+?*{0,}\\b\\<)|b)", "ab", 0, 0); - test_match ("((a+?*{0,}\\b\\<)|b)", "b"); - TEST_REGISTERS ("((a+?*{0,}\\b\\<)|b)", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,}\\b\\<)|b)*", "ab", 0, 0); - test_match ("((a+?*{0,}\\b\\<)|b)*", "b"); - TEST_REGISTERS ("((a+?*{0,}\\b\\<)|b)*", "b", - 0, 1, 0, 1, 0, 0); - - test_fastmap ("((a+?*{0,}\\b\\<)|b)*", "ab", 0, 0); - test_match ("((a+?*{0,}\\b\\<)|b)*", "bb"); - TEST_REGISTERS ("((a+?*{0,}\\b\\<)|b)*", "bb", - 0, 2, 1, 2, 0, 0); - - - /* `*' after group. */ - test_match ("(a*|b*)*c", "c"); - TEST_REGISTERS ("(a*|b*)*c", "c", 0, 1, 0, 0, -1, -1); - - test_match ("(a*|b*)*c", "ac"); - TEST_REGISTERS ("(a*|b*)*c", "ac", 0, 2, 0, 1, -1, -1); - - test_match ("(a*|b*)*c", "aac"); - TEST_REGISTERS ("(a*|b*)*c", "aac", 0, 3, 0, 2, -1, -1); - - test_match ("(a*|b*)*c", "bbc"); - TEST_REGISTERS ("(a*|b*)*c", "bbc", 0, 3, 0, 2, -1, -1); - - test_match ("(a*|b*)*c", "abc"); - TEST_REGISTERS ("(a*|b*)*c", "abc", 0, 3, 1, 2, -1, -1); - - /* No `*' after group. */ - test_match ("(a*|b*)c", "c"); - TEST_REGISTERS ("(a*|b*)c", "c", 0, 1, 0, 0, -1, -1); - - test_match ("(a*|b*)c", "ac"); - TEST_REGISTERS ("(a*|b*)c", "ac", 0, 2, 0, 1, -1, -1); - - test_match ("(a*|b*)c", "bc"); - TEST_REGISTERS ("(a*|b*)c", "bc", 0, 2, 0, 1, -1, -1); - - test_match ("(a*|b*)c", "aac"); - TEST_REGISTERS ("(a*|b*)c", "aac", 0, 3, 0, 2, -1, -1); - - /* Same as above, but with no `*'s in alternatives. - - test_match ("(a|b)*c", "c"); /* `*' after group. */ - TEST_REGISTERS ("(a|b)*c", "c", 0, 1, -1, -1, -1, -1); - - test_match ("(a|b)*c", "ac"); - TEST_REGISTERS ("(a|b)*c", "ac", 0, 2, 0, 1, -1, -1); - - test_match ("(a|b)*c", "bc"); - TEST_REGISTERS ("(a|b)*c", "bc", 0, 2, 0, 1, -1, -1); - - test_match ("(a|b)*c", "abc"); - TEST_REGISTERS ("(a|b)*c", "abc", 0, 3, 1, 2, -1, -1); - - - test_match ("(a*|b*)c", "bbc"); - TEST_REGISTERS ("(a*|b*)c", "bbc", 0, 3, 0, 2, -1, -1); - - /* Complicated second alternative. */ - - test_match ("(a*|(b*)*)*c", "bc"); - TEST_REGISTERS ("(a*|(b*)*)*c", "bc", 0, 2, 0, 1, 0, 1); - - test_match ("(a*|(b*|c*)*)*d", "bd"); - TEST_REGISTERS ("(a*|(b*|c*)*)*d", "bd", 0, 2, 0, 1, 0, 1); - - test_match ("(a*|(b*|c*)*)*d", "bbd"); - TEST_REGISTERS ("(a*|(b*|c*)*)*d", "bbd", 0, 3, 0, 2, 0, 2); - - test_match ("(a*|(b*|c*)*)*d", "cd"); - TEST_REGISTERS ("(a*|(b*|c*)*)*d", "cd", 0, 2, 0, 1, 0, 1); - - test_match ("(a*|(b*|c*)*)*d", "ccd"); - TEST_REGISTERS ("(a*|(b*|c*)*)*d", "ccd", 0, 3, 0, 2, 0, 2); - - test_match ("(a*|b*|c*)*d", "aad"); - TEST_REGISTERS ("(a*|b*|c*)*d", "aad", 0, 3, 0, 2, 0, 2); - - test_match ("(a*|b*|c*)*d", "bbd"); - TEST_REGISTERS ("(a*|b*|c*)*d", "bbd", 0, 3, 0, 2, 0, 2); - - test_match ("(a*|b*|c*)*d", "ccd"); - TEST_REGISTERS ("(a*|b*|c*)*d", "ccd", 0, 3, 0, 2, 0, 2); - - /* Valid anchoring. */ - valid_pattern ("a^"); - valid_pattern ("a^b"); - valid_pattern ("$a"); - valid_pattern ("a$b"); - valid_pattern ("foo^bar"); - valid_pattern ("foo$bar"); - valid_pattern ("(^)"); - valid_pattern ("($)"); - valid_pattern ("(^$)"); - - /* These are the same (but valid) as those (invalid) in other_test.c. */ - valid_pattern - ("(((((((((((((((((((((((((((((((((a^)))))))))))))))))))))))))))))))))"); - valid_pattern - ("((((((((((((((((((((((((((((((((($a)))))))))))))))))))))))))))))))))"); - valid_pattern ("\\(^a\\)"); - valid_pattern ("a\\|^b"); - valid_pattern ("\\w^a"); - valid_pattern ("\\W^a"); - valid_pattern ("(a^)"); - valid_pattern ("($a)"); - valid_pattern ("a(^b)"); - valid_pattern ("a$(b)"); - valid_pattern ("(a)^b"); - valid_pattern ("(a)$b"); - valid_pattern ("(a)(^b)"); - valid_pattern ("(a$)(b)"); - valid_pattern ("(a|b)^c"); - valid_pattern ("(a|b)$c"); - valid_pattern ("(a$|b)c"); - valid_pattern ("(a|b$)c"); - valid_pattern ("a(b|^c)"); - valid_pattern ("a(^b|c)"); - valid_pattern ("a$(b|c)"); - valid_pattern ("(a)(^b|c)"); - valid_pattern ("(a)(b|^c)"); - valid_pattern ("(b$|c)(a)"); - valid_pattern ("(b|c$)(a)"); - valid_pattern ("(a(^b|c))"); - valid_pattern ("(a(b|^c))"); - valid_pattern ("((b$|c)a)"); - valid_pattern ("((b|c$)a)"); - valid_pattern ("((^a|^b)^c)"); - valid_pattern ("(c$(a$|b$))"); - valid_pattern ("((^a|^b)^c)"); - valid_pattern ("((a$|b$)c)"); - valid_pattern ("(c$(a$|b$))"); - valid_pattern ("((^a|^b)|^c)^d"); - valid_pattern ("((a$|b$)|c$)d$"); - valid_pattern ("d$(c$|(a$|b$))"); - valid_pattern ("((^a|^b)|^c)(^d)"); - valid_pattern ("((a$|b$)|c$)(d$)"); - valid_pattern ("(d$)((a$|b$)|c$)"); - valid_pattern ("((^a|^b)|^c)((^d))"); - valid_pattern ("((a$|b$)|c$)((d$))"); - valid_pattern ("((d$))((a$|b$)|c$)"); - valid_pattern ("(((^a|^b))c|^d)^e"); - valid_pattern ("(((a$|b$))c|d$)$e$"); - valid_pattern ("e$(d$|c((a$|b$)))"); - valid_pattern ("(^a)((^b))"); - valid_pattern ("(a$)((b$))"); - valid_pattern ("((^a))(^b)"); - valid_pattern ("((a$))(b$)"); - valid_pattern ("((^a))((^b))"); - valid_pattern ("((a$))((b$))"); - valid_pattern ("((^a)^b)"); - valid_pattern ("((a$)b$)"); - valid_pattern ("(b$(a$))"); - valid_pattern ("(((^a)b)^c)"); - valid_pattern ("(((a$)b)c$)"); - valid_pattern ("(c$(b(a$)))"); - valid_pattern ("(((^a)b)c)^d"); - valid_pattern ("(((a$)b)c)d$"); - valid_pattern ("d$(c(b(a$)))"); - valid_pattern (".^a"); - valid_pattern ("a$."); - valid_pattern ("[a]^b"); - valid_pattern ("b$[a]"); - valid_pattern ("\\(a$\\)"); - valid_pattern ("a$\\|b"); - valid_pattern ("(^a|^b)^c"); - valid_pattern ("c$(a$|b$)"); - valid_pattern ("(^a|^b)^|^c"); - valid_pattern ("(a$|b$)$|$c$"); - valid_pattern ("(a$|$b$)$|c$"); - valid_pattern ("($a$|b$)$|c$"); - valid_pattern ("$(a$|b$)$|c$"); - valid_pattern ("^c|d(^a|^b)"); - valid_pattern ("(^a|^b)|d^c"); - valid_pattern ("c$|(a$|b$)d"); - valid_pattern ("c$d|(a$|b$)"); - valid_pattern ("c(^a|^b)|^d"); - valid_pattern ("(a$|b$)c|d$"); - valid_pattern ("c(((^a|^b))|^d)e"); - valid_pattern ("(c((^a|^b))|^d)e"); - valid_pattern ("((c(^a|^b))|^d)e"); - valid_pattern ("(((^a|^b))|c^d)e"); - valid_pattern ("(((^a|^b))|^d)^e"); - valid_pattern ("(c$((a|b))|d)e$"); - valid_pattern ("(c((a$|b$))|d)e$"); - valid_pattern ("(c((a|b)$)|d)e$"); - valid_pattern ("(c((a|b))|d$)e$"); - valid_pattern ("^d(^c|e((a|b)))"); - valid_pattern ("^d(c|^e((a|b)))"); - valid_pattern ("^d(c|e(^(a|b)))"); - valid_pattern ("^d(c|e((^a|b)))"); - valid_pattern ("^d(c|e((a|^b)))"); - valid_pattern ("^d(c|e((a|b^)))"); - valid_pattern ("^d(c|e((a|b)^))"); - valid_pattern ("^d(c|e((a|b))^)"); - valid_pattern ("^d(c|e((a|b)))^"); - valid_pattern ("d$(c$|e((a$|b$)))"); - valid_pattern ("d(c$|e$((a$|b$)))"); - valid_pattern ("(((^a|^b))^c)|^de"); - valid_pattern ("(((^a|^b))c)|^d^e"); - valid_pattern ("(((a$|b))c$)|de$"); - valid_pattern ("(((a|b$))c$)|de$"); - valid_pattern ("(((a|b))c$)|d$e$"); - valid_pattern ("^d^e|^(c((a|b)))"); - valid_pattern ("^de|^(c^((a|b)))"); - valid_pattern ("^de|^(c(^(a|b)))"); - valid_pattern ("^de|^(c((^a|b)))"); - valid_pattern ("^de|^(c((a|^b)))"); - valid_pattern ("^de|(^c(^(a|b)))"); - valid_pattern ("^de|(^c((^a|b)))"); - valid_pattern ("^de|(^c((a|^b)))"); - valid_pattern ("de$|(c($(a|b)$))"); - valid_pattern ("de$|(c$((a|b)$))"); - valid_pattern ("de$|($c((a|b)$))"); - valid_pattern ("de$|$(c((a|b)$))"); - valid_pattern ("de$|(c($(a|b))$)"); - valid_pattern ("de$|(c$((a|b))$)"); - valid_pattern ("de$|$(c((a|b))$)"); - valid_pattern ("de$|(c($(a|b)))$"); - valid_pattern ("de$|(c$((a|b)))$"); - valid_pattern ("de$|($c((a|b)))$"); - valid_pattern ("de$|$(c((a|b)))$"); - valid_pattern ("^a(^b|c)|^d"); - valid_pattern ("^a(b|^c)|^d"); - valid_pattern ("^a(b|c^)|^d"); - valid_pattern ("^a(b|c)^|^d"); - valid_pattern ("a$(b$|c$)|d$"); - valid_pattern ("^d|^a(^b|c)"); - valid_pattern ("^d|^a(b|^c)"); - valid_pattern ("d$|a$(b$|c$)"); - valid_pattern ("^d|^(b|c)^a"); - valid_pattern ("d$|(b|c$)a$"); - valid_pattern ("d$|(b$|c)a$"); - valid_pattern ("^(a)^(b|c)|^d"); - valid_pattern ("^(a)(^b|c)|^d"); - valid_pattern ("^(a)(b|^c)|^d"); - valid_pattern ("(a)$(b|c)$|d$"); - valid_pattern ("(a$)(b|c)$|d$"); - valid_pattern ("(^a)(^b|c)|^d"); - valid_pattern ("(^a)(b|^c)|^d"); - valid_pattern ("(a)$(b$|c$)|d$"); - valid_pattern ("(a$)(b$|c$)|d$"); - valid_pattern ("^d|^(b|c)^(a)"); - valid_pattern ("^d|^(b|c)(^a)"); - valid_pattern ("d$|(b|c$)(a)$"); - valid_pattern ("d$|(b$|c)(a)$"); - valid_pattern ("^d|(^b|^c)^(a)"); - valid_pattern ("^d|(^b|^c)(^a)"); - valid_pattern ("d$|(b|c)$(a$)"); - valid_pattern ("d$|(b|c$)(a$)"); - valid_pattern ("d$|(b$|c)(a$)"); - valid_pattern ("^d|^(a)^(b|c)"); - valid_pattern ("^d|^(a)(^b|c)"); - valid_pattern ("^d|^(a)(b|^c)"); - valid_pattern ("^d|(^a)^(b|c)"); - valid_pattern ("^d|(^a)(^b|c)"); - valid_pattern ("^d|(^a)(b|^c)"); - valid_pattern ("d$|(a)$(b$|c$)"); - valid_pattern ("d$|(a$)(b$|c$)"); - valid_pattern ("((e^a|^b)|^c)|^d"); - valid_pattern ("((^a|e^b)|^c)|^d"); - valid_pattern ("((^a|^b)|e^c)|^d"); - valid_pattern ("((^a|^b)|^c)|e^d"); - valid_pattern ("d$e|(c$|(a$|b$))"); - valid_pattern ("d$|(c$e|(a$|b$))"); - valid_pattern ("d$|(c$|(a$e|b$))"); - valid_pattern ("d$|(c$|(a$|b$e))"); - valid_pattern ("d$|(c$|(a$|b$)e)"); - valid_pattern ("d$|(c$|(a$|b$))e"); - valid_pattern ("(a|b)^|c"); - valid_pattern ("(a|b)|c^"); - valid_pattern ("$(a|b)|c"); - valid_pattern ("(a|b)|$c"); - valid_pattern ("(a^|^b)|^c"); - valid_pattern ("(^a|b^)|^c"); - valid_pattern ("(^a|^b)|c^"); - valid_pattern ("($a|b$)|c$"); - valid_pattern ("(a$|$b)|c$"); - valid_pattern ("(a$|b$)|$c"); - valid_pattern ("c^|(^a|^b)"); - valid_pattern ("^c|(a^|^b)"); - valid_pattern ("^c|(^a|b^)"); - valid_pattern ("$c|(a$|b$)"); - valid_pattern ("c$|($a|b$)"); - valid_pattern ("c$|(a$|$b)"); - valid_pattern ("c^|^(a|b)"); - valid_pattern ("^c|(a|b)^"); - valid_pattern ("$c|(a|b)$"); - valid_pattern ("c$|$(a|b)"); - valid_pattern ("(a^|^b)c|^d"); - valid_pattern ("(^a|b^)c|^d"); - valid_pattern ("(^a|^b)c|d^"); - valid_pattern ("(^a|^b)^c|^d"); - valid_pattern ("(a|b)c$|$d"); - valid_pattern ("(a|b)$c$|d$"); - valid_pattern ("(a|b)$c$|d$"); - valid_pattern ("(a|b$)c$|d$"); - valid_pattern ("(a$|b)c$|d$"); - valid_pattern ("($a|b)c$|d$"); - valid_pattern ("$(a|b)c$|d$"); - valid_pattern ("^d|^c^(a|b)"); - valid_pattern ("^d|^c(^a|b)"); - valid_pattern ("^d|^c(a|^b)"); - valid_pattern ("^d|^c(a|b^)"); - valid_pattern ("^d|^c(a|b)^"); - valid_pattern ("$d|c(a$|b$)"); - valid_pattern ("d$|c($a$|b$)"); - valid_pattern ("d$|c$(a$|b$)"); - valid_pattern ("d$|$c(a$|b$)"); - - valid_pattern ("(((a^|^b))c|^d)e"); - valid_pattern ("(((^a|b^))c|^d)e"); - valid_pattern ("(((^a|^b))^c|^d)e"); - valid_pattern ("((^(a|b))c|d^)e"); - valid_pattern ("(^((a|b))c|^d)^e"); - valid_pattern ("(^((a|b)^)c|^d)e"); - valid_pattern ("(^((a^|b))c|^d)e"); - valid_pattern ("(^((a|b^))c|^d)e"); - valid_pattern ("(^((a|b)^)c|^d)e"); - valid_pattern ("(^((a|b))^c|^d)e"); - valid_pattern ("(^((a|b))c^|^d)e"); - valid_pattern ("(^((a|b))c|^d^)e"); - valid_pattern ("(^((a|b))c|^d)^e"); - valid_pattern ("(((a|b))c|d)$e$"); - valid_pattern ("(((a|b))c|d$)e$"); - valid_pattern ("(((a|b))c|$d)e$"); - valid_pattern ("(((a|b))c$|d)e$"); - valid_pattern ("(((a|b))$c|d)e$"); - valid_pattern ("(((a|b)$)c|d)e$"); - valid_pattern ("(((a|b$))c|d)e$"); - valid_pattern ("(((a$|b))c|d)e$"); - valid_pattern ("((($a|b))c|d)e$"); - valid_pattern ("(($(a|b))c|d)e$"); - valid_pattern ("($((a|b))c|d)e$"); - valid_pattern ("$(((a|b))c|d)e$"); - valid_pattern ("(^((a|b)^)c|^d)e"); - valid_pattern ("(^((a|b))^c|^d)e"); - valid_pattern ("(^((a|b))c|^d^)e"); - valid_pattern ("(^((a|b))c|^d)^e"); - - valid_pattern ("^e(^d|c((a|b)))"); - valid_pattern ("^e(d|^c((a|b)))"); - valid_pattern ("^e(d|c^((a|b)))"); - valid_pattern ("^e(d|c(^(a|b)))"); - valid_pattern ("^e(d|c((^a|b)))"); - valid_pattern ("^e(d|c((a|^b)))"); - valid_pattern ("^e(d|c((a|b^)))"); - valid_pattern ("^e(d|c((a|b)^))"); - valid_pattern ("^e(d|c((a|b))^)"); - valid_pattern ("^e(d|c((a|b)))^"); - valid_pattern ("e$(d$|c((a$|b$)))"); - valid_pattern ("e(d$|c$((a$|b$)))"); - valid_pattern ("e(d$|c($(a$|b$)))"); - valid_pattern ("e(d$|c(($a$|b$)))"); - valid_pattern ("e$(d$|c((a|b)$))"); - valid_pattern ("e($d$|c((a|b)$))"); - valid_pattern ("e(d$|$c((a|b)$))"); - valid_pattern ("e(d$|c$((a|b)$))"); - valid_pattern ("e(d$|c($(a|b)$))"); - valid_pattern ("e(d$|c(($a|b)$))"); - valid_pattern ("e(d$|c((a|$b)$))"); - valid_pattern ("e(d$|c((a$|$b$)))"); - - valid_pattern ("e$(d$|c((a|b))$)"); - valid_pattern ("e($d$|c((a|b))$)"); - valid_pattern ("e(d$|$c((a|b))$)"); - valid_pattern ("e(d$|c$((a|b))$)"); - valid_pattern ("e(d$|c($(a|b))$)"); - valid_pattern ("e(d$|c(($a|b))$)"); - valid_pattern ("e(d$|c((a|$b))$)"); - valid_pattern ("e$(d$|c((a|b)))$"); - valid_pattern ("e($d$|c((a|b)))$"); - valid_pattern ("e(d$|$c((a|b)))$"); - valid_pattern ("e(d$|c$((a|b)))$"); - valid_pattern ("e(d$|c($(a|b)))$"); - valid_pattern ("e(d$|c(($a|b)))$"); - valid_pattern ("e(d$|c((a|$b)))$"); - valid_pattern ("(((^a|^b)^)c)|^de"); - valid_pattern ("(((^a|^b))^c)|^de"); - valid_pattern ("(((^a|^b))c)^|^de"); - valid_pattern ("$(((a|b))c$)|de$"); - valid_pattern ("($((a|b))c$)|de$"); - valid_pattern ("(($(a|b))c$)|de$"); - valid_pattern ("((($a|b))c$)|de$"); - valid_pattern ("(((a|$b))c$)|de$"); - valid_pattern ("(((a|b)$)c$)|de$"); - valid_pattern ("(((a|b))$c$)|de$"); - valid_pattern ("$(((a|b))c)$|de$"); - valid_pattern ("($((a|b))c)$|de$"); - valid_pattern ("(($(a|b))c)$|de$"); - valid_pattern ("((($a|b))c)$|de$"); - valid_pattern ("(((a|$b))c)$|de$"); - valid_pattern ("(((a|b)$)c)$|de$"); - valid_pattern ("(((a|b))$c)$|de$"); - valid_pattern ("^ed|^(c((a|b)))^"); - valid_pattern ("^ed|^(c((a|b))^)"); - valid_pattern ("^ed|^(c((a|b)^))"); - valid_pattern ("^ed|^(c((a|b^)))"); - valid_pattern ("^ed|^(c((a^|b)))"); - valid_pattern ("^ed|^(c((^a|b)))"); - valid_pattern ("^ed|^(c(^(a|b)))"); - valid_pattern ("^ed|^(c^((a|b)))"); - valid_pattern ("^ed|(^c((a|b)))^"); - valid_pattern ("^ed|(^c((a|b))^)"); - valid_pattern ("^ed|(^c((a|b)^))"); - valid_pattern ("^ed|(^c((a|b^)))"); - valid_pattern ("^ed|(^c((a|^b)))"); - valid_pattern ("^ed|(^c((a^|b)))"); - valid_pattern ("^ed|(^c((^a|b)))"); - valid_pattern ("^ed|(^c(^(a|b)))"); - valid_pattern ("^ed|(^c(^(a|b)))"); - valid_pattern ("^ed|(^c^((a|b)))"); - valid_pattern ("ed$|$(c((a|b)))$"); - valid_pattern ("ed$|($c((a|b)))$"); - valid_pattern ("ed$|(c$((a|b)))$"); - valid_pattern ("ed$|(c($(a|b)))$"); - valid_pattern ("ed$|(c(($a|b)))$"); - valid_pattern ("ed$|(c((a|$b)))$"); - valid_pattern ("ed$|$(c((a|b))$)"); - valid_pattern ("ed$|($c((a|b))$)"); - valid_pattern ("ed$|(c$((a|b))$)"); - valid_pattern ("ed$|(c($(a|b))$)"); - valid_pattern ("ed$|(c(($a|b))$)"); - valid_pattern ("ed$|(c((a|$b))$)"); - valid_pattern ("ed$|$(c((a|b)$))"); - valid_pattern ("ed$|($c((a|b)$))"); - valid_pattern ("ed$|(c$((a|b)$))"); - valid_pattern ("ed$|(c($(a|b)$))"); - valid_pattern ("ed$|(c(($a|b)$))"); - valid_pattern ("ed$|(c((a|$b)$))"); - valid_pattern ("ed$|$(c((a|b)$))"); - valid_pattern ("ed$|($c((a|b)$))"); - valid_pattern ("ed$|(c$((a|b)$))"); - valid_pattern ("ed$|(c($(a|b)$))"); - valid_pattern ("ed$|(c(($a|b)$))"); - valid_pattern ("ed$|(c((a|$b)$))"); - valid_pattern ("ed$|$(c((a|b)$))"); - valid_pattern ("ed$|($c((a|b)$))"); - valid_pattern ("ed$|(c$((a|b)$))"); - valid_pattern ("ed$|(c($(a|b)$))"); - valid_pattern ("ed$|(c(($a|b)$))"); - valid_pattern ("ed$|(c((a|$b)$))"); - valid_pattern ("ed$|$(c((a|b)$))"); - valid_pattern ("ed$|($c((a|b)$))"); - valid_pattern ("ed$|(c$((a|b)$))"); - valid_pattern ("ed$|(c($(a|b)$))"); - valid_pattern ("ed$|(c(($a|b)$))"); - valid_pattern ("ed$|(c((a|$b)$))"); - valid_pattern ("ed$|$(c((a|b)$))"); - valid_pattern ("ed$|($c((a|b)$))"); - valid_pattern ("ed$|(c$((a|b)$))"); - valid_pattern ("ed$|(c($(a|b)$))"); - valid_pattern ("ed$|(c(($a|b)$))"); - valid_pattern ("ed$|(c((a|$b)$))"); - valid_pattern ("ed$|$(c((a$|b$)))"); - valid_pattern ("ed$|($c((a$|b$)))"); - valid_pattern ("ed$|(c$((a$|b$)))"); - valid_pattern ("ed$|(c($(a$|b$)))"); - valid_pattern ("ed$|(c(($a$|b$)))"); - valid_pattern ("ed$|(c((a$|$b$)))"); - valid_pattern ("^a(b|c)^|^d"); - valid_pattern ("^a(b|c^)|^d"); - valid_pattern ("^a(b|^c)|^d"); - valid_pattern ("^a(b^|c)|^d"); - valid_pattern ("^a(^b|c)|^d"); - valid_pattern ("^a^(b|c)|^d"); - valid_pattern ("$a(b$|c$)|d$"); - valid_pattern ("a$(b$|c$)|d$"); - valid_pattern ("a($b$|c$)|d$"); - valid_pattern ("a(b$|$c$)|d$"); - valid_pattern ("a(b$|c$)|$d$"); - valid_pattern ("^(a^)(b|c)|^d"); - valid_pattern ("^(a)^(b|c)|^d"); - valid_pattern ("^(a)(^b|c)|^d"); - valid_pattern ("^(a)(b^|c)|^d"); - valid_pattern ("^(a)(b|^c)|^d"); - valid_pattern ("^(a)(b|c^)|^d"); - valid_pattern ("^(a)(b|c)^|^d"); - valid_pattern ("(^a^)(b|c)|^d"); - valid_pattern ("(^a)^(b|c)|^d"); - valid_pattern ("(^a)(^b|c)|^d"); - valid_pattern ("(^a)(b^|c)|^d"); - valid_pattern ("(^a)(b|^c)|^d"); - valid_pattern ("(^a)(b|c^)|^d"); - valid_pattern ("(^a)(b|c)^|^d"); - - valid_pattern ("(a)(b$|c$)d$"); - valid_pattern ("(a)(b|$c)$|d$"); - valid_pattern ("(a)($b|c)$|d$"); - valid_pattern ("(a)$(b|c)$|d$"); - valid_pattern ("(a$)(b|c)$|d$"); - valid_pattern ("($a)(b|c)$|d$"); - valid_pattern ("$(a)(b|c)$|d$"); - valid_pattern ("(b|c)($a)$|d$"); - valid_pattern ("(b|c)$(a)$|d$"); - valid_pattern ("(b|c$)(a)$|d$"); - valid_pattern ("(b|$c)(a)$|d$"); - valid_pattern ("(b$|c)(a)$|d$"); - valid_pattern ("($b|c)(a)$|d$"); - valid_pattern ("$(b|c)(a)$|d$"); - valid_pattern ("(b|c)($a$)|d$"); - valid_pattern ("(b|c)$(a$)|d$"); - valid_pattern ("(b|c$)(a$)|d$"); - valid_pattern ("(b|$c)(a$)|d$"); - valid_pattern ("(b$|c)(a$)|d$"); - valid_pattern ("($b|c)(a$)|d$"); - valid_pattern ("$(b|c)(a$)|d$"); - valid_pattern ("(a)$(b$|c$)|d$"); - valid_pattern ("(a$)(b$|c$)|d$"); - valid_pattern ("($a)(b$|c$)|d$"); - valid_pattern ("$(a)(b$|c$)|d$"); - valid_pattern ("^d|^(b^|c)(a)"); - valid_pattern ("^d|^(b|c^)(a)"); - valid_pattern ("^d|^(b|c)^(a)"); - valid_pattern ("^d|^(b|c)(^a)"); - valid_pattern ("^d|^(b|c)(a^)"); - valid_pattern ("^d|^(b|c)(a)^"); - valid_pattern ("^d|(^b|^c^)(a)"); - valid_pattern ("^d|(^b|^c)^(a)"); - valid_pattern ("^d|(^b|^c)(^a)"); - valid_pattern ("^d|(^b|^c)(a^)"); - valid_pattern ("^d|(^b|^c)(a)^"); - valid_pattern ("d$|(b|c)($a$)"); - valid_pattern ("d$|(b|c)$(a$)"); - valid_pattern ("d$|(b|c$)(a$)"); - valid_pattern ("d$|(b$|c)(a$)"); - valid_pattern ("d$|($b|c)(a$)"); - valid_pattern ("d$|$(b|c)(a$)"); - valid_pattern ("d$|(b|c)($a)$"); - valid_pattern ("d$|(b|c)$(a)$"); - valid_pattern ("d$|(b|c$)(a)$"); - valid_pattern ("d$|(b$|c)(a)$"); - valid_pattern ("d$|($b|c)(a)$"); - valid_pattern ("d$|$(b|c)(a)$"); - valid_pattern ("^d|^(a^)(b|c)"); - valid_pattern ("^d|^(a)^(b|c)"); - valid_pattern ("^d|^(a)(^b|c)"); - valid_pattern ("^d|^(a)(b^|c)"); - valid_pattern ("^d|^(a)(b|^c)"); - valid_pattern ("^d|^(a)(b|c^)"); - valid_pattern ("^d|^(a)(b|c)^"); - valid_pattern ("^d|(^a^)(b|c)"); - valid_pattern ("^d|(^a)^(b|c)"); - valid_pattern ("^d|(^a)(^b|c)"); - valid_pattern ("^d|(^a)(b^|c)"); - valid_pattern ("^d|(^a)(b|^c)"); - valid_pattern ("^d|(^a)(b|c^)"); - valid_pattern ("^d|(^a)(b|c)^"); - valid_pattern ("d$|(a)$(b$|c$)"); - valid_pattern ("d$|(a$)(b$|c$)"); - valid_pattern ("d$|($a)(b$|c$)"); - valid_pattern ("d$|$(a)(b$|c$)"); - valid_pattern ("d$|(a)(b|$c)$"); - valid_pattern ("d$|(a)($b|c)$"); - valid_pattern ("d$|(a)$(b|c)$"); - valid_pattern ("d$|(a$)(b|c)$"); - valid_pattern ("d$|($a)(b|c)$"); - valid_pattern ("d$|$(a)(b|c)$"); - valid_pattern ("((^a|^b)|^c)|^d^"); - valid_pattern ("((^a|^b)|^c)^|^d"); - valid_pattern ("((^a|^b)|^c^)|^d"); - valid_pattern ("((^a|^b)^|^c)|^d"); - valid_pattern ("((^a|^b^)|^c)|^d"); - valid_pattern ("((^a^|^b)|^c)|^d"); - valid_pattern ("((a|b)|c)|$d$"); - valid_pattern ("((a|b)|$c)|d$"); - valid_pattern ("((a|$b)|c)|d$"); - valid_pattern ("(($a|b)|c)|d$"); - valid_pattern ("($(a|b)|c)|d$"); - valid_pattern ("$((a|b)|c)|d$"); - valid_pattern ("^d^|(c|(a|b))"); - valid_pattern ("^d|(c^|(a|b))"); - valid_pattern ("^d|(c|(a^|b))"); - valid_pattern ("^d|(c|(a|b^))"); - valid_pattern ("^d|(c|(a|b)^)"); - valid_pattern ("^d|(c|(a|b))^"); - valid_pattern ("d$|(c$|(a$|$b$))"); - valid_pattern ("d$|(c$|($a$|b$))"); - valid_pattern ("d$|($c$|(a$|b$))"); - valid_pattern ("d$|$(c$|(a$|b$))"); - valid_pattern ("$d$|(c$|(a$|b$))"); - valid_pattern ("d$|(c$|(a|$b)$)"); - valid_pattern ("d$|(c$|($a|b)$)"); - valid_pattern ("d$|($c$|(a|b)$)"); - valid_pattern ("d$|$(c$|(a|b)$)"); - valid_pattern ("$d$|(c$|(a|b)$)"); - valid_pattern ("d$|(c$|(a|$b))$"); - valid_pattern ("d$|(c$|($a|b))$"); - valid_pattern ("d$|($c$|(a|b))$"); - valid_pattern ("d$|$(c$|(a|b))$"); - valid_pattern ("$d$|(c$|(a|b))$"); - valid_pattern ("^c^|(^a|^b)"); - valid_pattern ("^c|(^a^|^b)"); - valid_pattern ("^c|(^a|^b^)"); - valid_pattern ("^c|(^a|^b)^"); - valid_pattern ("c$|(a$|$b$)"); - valid_pattern ("c$|($a$|b$)"); - valid_pattern ("c$|$(a$|b$)"); - valid_pattern ("$c$|(a$|b$)"); - valid_pattern ("^d^(c|e((a|b)))"); - valid_pattern ("^d(^c|e((a|b)))"); - valid_pattern ("^d(c^|e((a|b)))"); - valid_pattern ("^d(c|^e((a|b)))"); - valid_pattern ("^d(c|e^((a|b)))"); - valid_pattern ("^d(c|e(^(a|b)))"); - valid_pattern ("^d(c|e((^a|b)))"); - valid_pattern ("^d(c|e((a|^b)))"); - valid_pattern ("^d(c|e((a|b^)))"); - valid_pattern ("^d(c|e((a|b)^))"); - valid_pattern ("^d(c|e((a|b))^)"); - valid_pattern ("^d(c|e((a|b)))^"); - valid_pattern ("d(c$|e($(a$|b$)))"); - valid_pattern ("d(c$|e$((a$|b$)))"); - valid_pattern ("d(c$|$e((a$|b$)))"); - valid_pattern ("d($c$|e((a$|b$)))"); - valid_pattern ("d$(c$|e((a$|b$)))"); - valid_pattern ("$d(c$|e((a$|b$)))"); - valid_pattern ("^d|^a^(b|c)"); - valid_pattern ("^d|^a(^b|c)"); - valid_pattern ("^d|^a(b^|c)"); - valid_pattern ("^d|^a(b|^c)"); - valid_pattern ("^d|^a(b|c^)"); - valid_pattern ("^d|^a(b|c)^"); - valid_pattern ("d$|a($b$|c$)"); - valid_pattern ("d$|a$(b$|c$)"); - valid_pattern ("d$|$a(b$|c$)"); - valid_pattern ("$d$|a(b$|c$)"); - valid_pattern ("^d|^(b^|c)a"); - valid_pattern ("^d|^(b|c^)a"); - valid_pattern ("^d|^(b|c)^a"); - valid_pattern ("^d|^(b|c)a^"); - valid_pattern ("d$|(b|c)$a$"); - valid_pattern ("d$|(b|c$)a$"); - valid_pattern ("d$|(b|$c)a$"); - valid_pattern ("d$|(b$|c)a$"); - valid_pattern ("d$|($b|c)a$"); - valid_pattern ("d$|$(b|c)a$"); - valid_pattern ("$d$|(b|c)a$"); - - /* xx Do these use all the valid_nonposix_pattern ones in other_test.c? */ - - TEST_SEARCH ("(^a|^b)c", "ac", 0, 2); - TEST_SEARCH ("(^a|^b)c", "bc", 0, 2); - TEST_SEARCH ("c(a$|b$)", "ca", 0, 2); - TEST_SEARCH ("c(a$|b$)", "cb", 0, 2); - TEST_SEARCH ("^(a|b)|^c", "ad", 0, 2); - TEST_SEARCH ("^(a|b)|^c", "bd", 0, 2); - TEST_SEARCH ("(a|b)$|c$", "da", 0, 2); - TEST_SEARCH ("(a|b)$|c$", "db", 0, 2); - TEST_SEARCH ("(a|b)$|c$", "dc", 0, 2); - TEST_SEARCH ("(^a|^b)|^c", "ad", 0, 2); - TEST_SEARCH ("(^a|^b)|^c", "bd", 0, 2); - TEST_SEARCH ("(^a|^b)|^c", "cd", 0, 2); - TEST_SEARCH ("(a$|b$)|c$", "da", 0, 2); - TEST_SEARCH ("(a$|b$)|c$", "db", 0, 2); - TEST_SEARCH ("(a$|b$)|c$", "dc", 0, 2); - TEST_SEARCH ("^c|(^a|^b)", "ad", 0, 2); - TEST_SEARCH ("^c|(^a|^b)", "bd", 0, 2); - TEST_SEARCH ("^c|(^a|^b)", "cd", 0, 2); - TEST_SEARCH ("c$|(a$|b$)", "da", 0, 2); - TEST_SEARCH ("c$|(a$|b$)", "db", 0, 2); - TEST_SEARCH ("c$|(a$|b$)", "dc", 0, 2); - TEST_SEARCH ("^c|^(a|b)", "ad", 0, 2); - TEST_SEARCH ("^c|^(a|b)", "bd", 0, 2); - TEST_SEARCH ("^c|^(a|b)", "cd", 0, 2); - TEST_SEARCH ("c$|(a|b)$", "da", 0, 2); - TEST_SEARCH ("c$|(a|b)$", "db", 0, 2); - TEST_SEARCH ("c$|(a|b)$", "dc", 0, 2); - TEST_SEARCH ("(^a|^b)c|^d", "ace", 0, 3); - TEST_SEARCH ("(^a|^b)c|^d", "bce", 0, 3); - TEST_SEARCH ("(^a|^b)c|^d", "de", 0, 2); - TEST_SEARCH ("(a|b)c$|d$", "eac", 0, 3); - TEST_SEARCH ("(a|b)c$|d$", "ebc", 0, 3); - TEST_SEARCH ("(a|b)c$|d$", "ed", 0, 3); - TEST_SEARCH ("^d|^c(a|b)", "cae", 0, 3); - TEST_SEARCH ("^d|^c(a|b)", "cbe", 0, 3); - TEST_SEARCH ("^d|^c(a|b)", "de", 0, 3); - TEST_SEARCH ("d$|c(a$|b$)", "eca", 0, 3); - TEST_SEARCH ("d$|c(a$|b$)", "ecb", 0, 3); - TEST_SEARCH ("d$|c(a$|b$)", "ed", 0, 3); - - TEST_SEARCH ("(((^a|^b))c|^d)e", "acef", 0, 4); - TEST_SEARCH ("(((^a|^b))c|^d)e", "bcef", 0, 4); - TEST_SEARCH ("(((^a|^b))c|^d)e", "def", 0, 3); - - TEST_SEARCH ("((^(a|b))c|^d)e", "acef", 0, 4); - TEST_SEARCH ("((^(a|b))c|^d)e", "bcef", 0, 4); - TEST_SEARCH ("((^(a|b))c|^d)e", "def", 0, 3); - - TEST_SEARCH ("(^((a|b))c|^d)e", "acef", 0, 4); - TEST_SEARCH ("(^((a|b))c|^d)e", "bcef", 0, 4); - TEST_SEARCH ("(^((a|b))c|^d)e", "def", 0, 3); - - TEST_SEARCH ("(((a|b))c|d)e$", "face", 0, 4); - TEST_SEARCH ("(((a|b))c|d)e$", "fbce", 0, 4); - TEST_SEARCH ("(((a|b))c|d)e$", "fde", 0, 3); - - TEST_SEARCH ("^e(d|c((a|b)))", "edf", 0, 3); - TEST_SEARCH ("^e(d|c((a|b)))", "ecaf", 0, 4); - TEST_SEARCH ("^e(d|c((a|b)))", "ecbf", 0, 4); - - TEST_SEARCH ("e(d$|c((a$|b$)))", "fed", 0, 3); - TEST_SEARCH ("e(d$|c((a$|b$)))", "feca", 0, 4); - TEST_SEARCH ("e(d$|c((a$|b$)))", "fecb", 0, 4); - - TEST_SEARCH ("e(d$|c((a|b)$))", "fed", 0, 3); - TEST_SEARCH ("e(d$|c((a|b)$))", "feca", 0, 4); - TEST_SEARCH ("e(d$|c((a|b)$))", "fecb", 0, 4); - - TEST_SEARCH ("e(d$|c((a|b))$)", "fed", 0, 3); - TEST_SEARCH ("e(d$|c((a|b))$)", "feca", 0, 3); - TEST_SEARCH ("e(d$|c((a|b))$)", "fecb", 0, 3); - - TEST_SEARCH ("e(d$|c((a|b)))$", "fed", 0, 3); - TEST_SEARCH ("e(d$|c((a|b)))$", "feca", 0, 3); - TEST_SEARCH ("e(d$|c((a|b)))$", "fecb", 0, 3); - - TEST_SEARCH ("(((^a|^b))c)|^de", "acf", 0, 3); - TEST_SEARCH ("(((^a|^b))c)|^de", "bcf", 0, 3); - TEST_SEARCH ("(((^a|^b))c)|^de", "def", 0, 3); - - TEST_SEARCH ("(((a|b))c$)|de$", "fac", 0, 3); - TEST_SEARCH ("(((a|b))c$)|de$", "fbc", 0, 3); - TEST_SEARCH ("(((a|b))c$)|de$", "fde", 0, 3); - - TEST_SEARCH ("(((a|b))c)$|de$", "fac", 0, 3); - TEST_SEARCH ("(((a|b))c)$|de$", "fbc", 0, 3); - TEST_SEARCH ("(((a|b))c)$|de$", "fde", 0, 3); - - TEST_SEARCH ("^ed|^(c((a|b)))", "edf", 0, 3); - TEST_SEARCH ("^ed|^(c((a|b)))", "caf", 0, 3); - TEST_SEARCH ("^ed|^(c((a|b)))", "cbf", 0, 3); - - TEST_SEARCH ("^ed|(^c((a|b)))", "edf", 0, 3); - TEST_SEARCH ("^ed|(^c((a|b)))", "caf", 0, 3); - TEST_SEARCH ("^ed|(^c((a|b)))", "cbf", 0, 3); - - TEST_SEARCH ("ed$|(c((a|b)))$", "fed", 0, 3); - TEST_SEARCH ("ed$|(c((a|b)))$", "fca", 0, 3); - TEST_SEARCH ("ed$|(c((a|b)))$", "fcb", 0, 3); - - TEST_SEARCH ("ed$|(c((a|b))$)", "fed", 0, 3); - TEST_SEARCH ("ed$|(c((a|b))$)", "fca", 0, 3); - TEST_SEARCH ("ed$|(c((a|b))$)", "fcb", 0, 3); - - TEST_SEARCH ("ed$|(c((a|b)$))", "fed", 0, 3); - TEST_SEARCH ("ed$|(c((a|b)$))", "fca", 0, 3); - TEST_SEARCH ("ed$|(c((a|b)$))", "fcb", 0, 3); - - TEST_SEARCH ("ed$|(c((a$|b$)))", "fed", 0, 3); - TEST_SEARCH ("ed$|(c((a$|b$)))", "fca", 0, 3); - TEST_SEARCH ("ed$|(c((a$|b$)))", "fcb", 0, 3); - - TEST_SEARCH ("^a(b|c)|^d", "abe", 0, 3); - TEST_SEARCH ("^a(b|c)|^d", "ace", 0, 3); - TEST_SEARCH ("^a(b|c)|^d", "df", 0, 2); - - TEST_SEARCH ("a(b$|c$)|d$", "fab", 0, 3); - TEST_SEARCH ("a(b$|c$)|d$", "fac", 0, 3); - TEST_SEARCH ("a(b$|c$)|d$", "fd", 0, 2); - - TEST_SEARCH ("^(a)(b|c)|^d", "abe", 0, 3); - TEST_SEARCH ("^(a)(b|c)|^d", "ace", 0, 3); - TEST_SEARCH ("^(a)(b|c)|^d", "df", 0, 2); - - TEST_SEARCH ("(^a)(b|c)|^d", "abe", 0, 3); - TEST_SEARCH ("(^a)(b|c)|^d", "ace", 0, 3); - TEST_SEARCH ("(^a)(b|c)|^d", "df", 0, 2); - - TEST_SEARCH ("(a)(b|c)$|d$", "fab", 0, 3); - TEST_SEARCH ("(a)(b|c)$|d$", "fac", 0, 3); - TEST_SEARCH ("(a)(b|c)$|d$", "fd", 0, 2); - - TEST_SEARCH ("(b|c)(a)$|d$", "fba", 0, 3); - TEST_SEARCH ("(b|c)(a)$|d$", "fca", 0, 3); - TEST_SEARCH ("(b|c)(a)$|d$", "fd", 0, 2); - - TEST_SEARCH ("(b|c)(a$)|d$", "fba", 0, 3); - TEST_SEARCH ("(b|c)(a$)|d$", "fca", 0, 3); - TEST_SEARCH ("(b|c)(a$)|d$", "fd", 0, 2); - - TEST_SEARCH ("(a)(b$|c$)|d$", "fab", 0, 3); - TEST_SEARCH ("(a)(b$|c$)|d$", "fac", 0, 3); - TEST_SEARCH ("(a)(b$|c$)|d$", "fd", 0, 2); - - TEST_SEARCH ("^d|^(b|c)(a)", "df", 0, 2); - TEST_SEARCH ("^d|^(b|c)(a)", "baf", 0, 3); - TEST_SEARCH ("^d|^(b|c)(a)", "caf", 0, 3); - - TEST_SEARCH ("^d|(^b|^c)(a)", "df", 0, 2); - TEST_SEARCH ("^d|(^b|^c)(a)", "baf", 0, 3); - TEST_SEARCH ("^d|(^b|^c)(a)", "caf", 0, 3); - - TEST_SEARCH ("d$|(b|c)(a$)", "fd", 0, 2); - TEST_SEARCH ("d$|(b|c)(a$)", "fba", 0, 3); - TEST_SEARCH ("d$|(b|c)(a$)", "fca", 0, 3); - - TEST_SEARCH ("d$|(b|c)(a)$", "fd", 0, 2); - TEST_SEARCH ("d$|(b|c)(a)$", "fba", 0, 3); - TEST_SEARCH ("d$|(b|c)(a)$", "fca", 0, 3); - - TEST_SEARCH ("d$|(b|c)(a$)", "fd", 0, 2); - TEST_SEARCH ("d$|(b|c)(a$)", "fba", 0, 3); - TEST_SEARCH ("d$|(b|c)(a$)", "fca", 0, 3); - - TEST_SEARCH ("^d|^(a)(b|c)", "df", 0, 2); - TEST_SEARCH ("^d|^(a)(b|c)", "abf", 0, 3); - TEST_SEARCH ("^d|^(a)(b|c)", "acf", 0, 3); - - TEST_SEARCH ("^d|(^a)(b|c)", "df", 0, 2); - TEST_SEARCH ("^d|(^a)(b|c)", "abf", 0, 3); - TEST_SEARCH ("^d|(^a)(b|c)", "acf", 0, 3); - - TEST_SEARCH ("d$|(a)(b$|c$)", "fd", 0, 2); - TEST_SEARCH ("d$|(a)(b$|c$)", "fab", 0, 3); - TEST_SEARCH ("d$|(a)(b$|c$)", "fac", 0, 3); - - TEST_SEARCH ("d$|(a)(b|c)$", "fd", 0, 2); - TEST_SEARCH ("d$|(a)(b|c)$", "fab", 0, 3); - TEST_SEARCH ("d$|(a)(b|c)$", "fac", 0, 3); - - TEST_SEARCH ("((^a|^b)|^c)|^d", "ae", 0, 2); - TEST_SEARCH ("((^a|^b)|^c)|^d", "be", 0, 2); - TEST_SEARCH ("((^a|^b)|^c)|^d", "ce", 0, 2); - TEST_SEARCH ("((^a|^b)|^c)|^d", "de", 0, 2); - - TEST_SEARCH ("((a|b)|c)|d$", "ed", 0, 2); - TEST_SEARCH ("((a|b)|c)|d$", "ea", 0, 2); - TEST_SEARCH ("((a|b)|c)|d$", "eb", 0, 2); - TEST_SEARCH ("((a|b)|c)|d$", "ec", 0, 2); - - TEST_SEARCH ("^d|(c|(a|b))", "de", 0, 2); - - TEST_SEARCH ("d$|(c$|(a$|b$))", "ed", 0, 2); - TEST_SEARCH ("d$|(c$|(a$|b$))", "ec", 0, 2); - TEST_SEARCH ("d$|(c$|(a$|b$))", "ea", 0, 2); - TEST_SEARCH ("d$|(c$|(a$|b$))", "eb", 0, 2); - - TEST_SEARCH ("d$|(c$|(a|b)$)", "ed", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b)$)", "ec", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b)$)", "ea", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b)$)", "eb", 0, 2); - - TEST_SEARCH ("d$|(c$|(a|b))$", "ed", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b))$", "ec", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b))$", "ea", 0, 2); - TEST_SEARCH ("d$|(c$|(a|b))$", "eb", 0, 2); - - test_match ("a|^b", "b"); - test_match ("a|b$", "b"); - test_match ("^b|a", "b"); - test_match ("b$|a", "b"); - test_match ("(^a)", "a"); - test_match ("(a$)", "a"); - TEST_SEARCH ("c|^ab", "aba", 0, 3); - TEST_SEARCH ("c|ba$", "aba", 0, 3); - TEST_SEARCH ("^ab|c", "aba", 0, 3); - TEST_SEARCH ("ba$|c", "aba", 0, 3); - TEST_SEARCH ("(^a)", "ab", 0, 2); - TEST_SEARCH ("(a$)", "ba", 0, 2); - - TEST_SEARCH ("(^a$)", "a", 0, 1); - TEST_SEARCH ("(^a)", "ab", 0, 2); - TEST_SEARCH ("(b$)", "ab", 0, 2); - - /* Backtracking. */ - /* Per POSIX D11.1 p. 108, leftmost longest match. */ - test_match ("(wee|week)(knights|night)", "weeknights"); - - test_match ("(fooq|foo)qbar", "fooqbar"); - test_match ("(fooq|foo)(qbarx|bar)", "fooqbarx"); - - /* Take first alternative that does the longest match. */ - test_all_registers ("(fooq|(foo)|(fo))((qbarx)|(oqbarx)|bar)", "fooqbarx", - "", 0, 8, 0, 3, 0, 3, -1, -1, 3, 8, 3, 8, -1, -1, -1, -1, -1, -1, - -1, -1); - - test_match ("(fooq|foo)*qbar", "fooqbar"); - test_match ("(fooq|foo)*(qbar)", "fooqbar"); - test_match ("(fooq|foo)*(qbar)*", "fooqbar"); - - test_match ("(fooq|fo|o)*qbar", "fooqbar"); - test_match ("(fooq|fo|o)*(qbar)", "fooqbar"); - test_match ("(fooq|fo|o)*(qbar)*", "fooqbar"); - - test_match ("(fooq|fo|o)*(qbar|q)*", "fooqbar"); - test_match ("(fooq|foo)*(qbarx|bar)", "fooqbarx"); - test_match ("(fooq|foo)*(qbarx|bar)*", "fooqbarx"); - - test_match ("(fooq|fo|o)+(qbar|q)+", "fooqbar"); - test_match ("(fooq|foo)+(qbarx|bar)", "fooqbarx"); - test_match ("(fooq|foo)+(qbarx|bar)+", "fooqbarx"); - - /* Per Mike Haertel. */ - test_match ("(foo|foobarfoo)(bar)*", "foobarfoo"); - - /* Combination. */ - test_match ("[ab]?c", "ac"); - test_match ("[ab]*c", "ac"); - test_match ("[ab]+c", "ac"); - test_match ("(a|b)?c", "ac"); - test_match ("(a|b)*c", "ac"); - test_match ("(a|b)+c", "ac"); - test_match ("(a*c)?b", "b"); - test_match ("(a*c)+b", "aacb"); - /* Registers. */ - /* Per David A. Willcox. */ - test_match ("a((b)|(c))d", "acd"); - test_all_registers ("a((b)|(c))d", "acd", "", 0, 3, 1, 2, -1, -1, 1, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - - /* Extended regular expressions, continued; these don't match their strings. */ - test_should_match = false; - -#if 0 - /* Invalid use of special characters. */ - /* These are not invalid anymore, since POSIX says the behavior is - undefined, and we prefer context-independent to context-invalid. */ - invalid_pattern (REG_BADRPT, "*"); - invalid_pattern (REG_BADRPT, "a|*"); - invalid_pattern (REG_BADRPT, "(*)"); - invalid_pattern (REG_BADRPT, "^*"); - invalid_pattern (REG_BADRPT, "+"); - invalid_pattern (REG_BADRPT, "a|+"); - invalid_pattern (REG_BADRPT, "(+)"); - invalid_pattern (REG_BADRPT, "^+"); - - invalid_pattern (REG_BADRPT, "?"); - invalid_pattern (REG_BADRPT, "a|?"); - invalid_pattern (REG_BADRPT, "(?)"); - invalid_pattern (REG_BADRPT, "^?"); - - invalid_pattern (REG_BADPAT, "|"); - invalid_pattern (REG_BADPAT, "a|"); - invalid_pattern (REG_BADPAT, "a||"); - invalid_pattern (REG_BADPAT, "(|a)"); - invalid_pattern (REG_BADPAT, "(a|)"); - - invalid_pattern (REG_BADPAT, PARENS_TO_OPS ("(|)")); - - invalid_pattern (REG_BADRPT, "{1}"); - invalid_pattern (REG_BADRPT, "a|{1}"); - invalid_pattern (REG_BADRPT, "^{1}"); - invalid_pattern (REG_BADRPT, "({1})"); - - invalid_pattern (REG_BADPAT, "|b"); - - invalid_pattern (REG_BADRPT, "^{0,}*"); - invalid_pattern (REG_BADRPT, "$*"); - invalid_pattern (REG_BADRPT, "${0,}*"); -#endif /* 0 */ - - invalid_pattern (REG_EESCAPE, "\\"); - - test_match ("a?b", "a"); - - - test_match ("a+", ""); - test_match ("a+b", "a"); - test_match ("a?", "b"); - -#if 0 - /* We make empty groups valid now, since they are undefined in POSIX. - (13 Sep 92) */ - /* Subexpressions. */ - invalid_pattern (REG_BADPAT, "()"); - invalid_pattern (REG_BADPAT, "a()"); - invalid_pattern (REG_BADPAT, "()b"); - invalid_pattern (REG_BADPAT, "a()b"); - invalid_pattern (REG_BADPAT, "()*"); - invalid_pattern (REG_BADPAT, "(()*"); -#endif - /* Invalid intervals. */ - test_match ("a{2}*", "aaa"); - test_match ("a{2}?", "aaa"); - test_match ("a{2}+", "aaa"); - test_match ("a{2}{2}", "aaa"); - test_match ("a{1}{1}{2}", "aaa"); - test_match ("a{1}{1}{2}", "a"); - /* Invalid alternation. */ - test_match ("a|b", "c"); - - TEST_SEARCH ("c|^ba", "aba", 0, 3); - TEST_SEARCH ("c|ab$", "aba", 0, 3); - TEST_SEARCH ("^ba|c", "aba", 0, 3); - TEST_SEARCH ("ab$|c", "aba", 0, 3); - /* Invalid anchoring. */ - TEST_SEARCH ("(^a)", "ba", 0, 2); - TEST_SEARCH ("(b$)", "ba", 0, 2); - - printf ("\nFinished POSIX extended tests.\n"); -} - - - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/regex-0.12/test/psx-generic.c b/gnu/lib/regex-0.12/test/psx-generic.c deleted file mode 100644 index 340e93875515..000000000000 --- a/gnu/lib/regex-0.12/test/psx-generic.c +++ /dev/null @@ -1,336 +0,0 @@ -/* psx-generic.c: test POSIX re's independent of us using basic or - extended syntax. */ - -#include "test.h" - - -void -test_posix_generic () -{ - int omit_generic_tests = 0; /* reset in debugger to skip */ - - if (omit_generic_tests) - return; - /* Tests somewhat in the order of P1003.2. */ - - /* Both posix basic and extended; should match. */ - - printf ("\nStarting generic POSIX tests.\n"); - test_grouping (); - test_intervals (); - - test_should_match = true; - /* Ordinary characters. */ - printf ("\nContinuing generic POSIX tests.\n"); - - MATCH_SELF (""); - test_fastmap ("", "", 0, 0); - test_fastmap_search ("", "", "", 0, 0, 2, 0, 0); - TEST_REGISTERS ("", "", 0, 0, -1, -1, -1, -1); - TEST_SEARCH ("", "", 0, 0); - TEST_SEARCH_2 ("", "", "", 0, 1, 0); - - MATCH_SELF ("abc"); - test_fastmap ("abc", "a", 0, 0); - TEST_REGISTERS ("abc", "abc", 0, 3, -1, -1, -1, -1); - TEST_REGISTERS ("abc", "xabcx", 1, 4, -1, -1, -1, -1); - - test_match ("\\a","a"); - test_match ("\\0", "0"); - - TEST_SEARCH ("a", "ab", 0, 2); - TEST_SEARCH ("b", "ab", 0, 2); - TEST_SEARCH ("a", "ab", 1, -2); - TEST_SEARCH_2 ("a", "a", "b", 0, 2, 2); - TEST_SEARCH_2 ("b", "a", "b", 0, 2, 2); - TEST_SEARCH_2 ("a", "a", "b", 1, -2, 2); - - test_match ("\n", "\n"); - test_match ("a\n", "a\n"); - test_match ("\nb", "\nb"); - test_match ("a\nb", "a\nb"); - - TEST_SEARCH ("b", "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 236, -237); - /* Valid use of special characters. */ - test_match ("a*", "aa"); - test_fastmap ("a*", "a", 0, 0); - TEST_REGISTERS ("a*", "aa", 0, 2, -1, -1, -1, -1); - - test_match ("a*b", "aab"); - test_fastmap ("a*b", "ab", 0, 0); - - test_match ("a*ab", "aab"); - TEST_REGISTERS ("a*a", "aa", 0, 2, -1, -1, -1, -1); - TEST_REGISTERS ("a*a", "xaax", 1, 3, -1, -1, -1, -1); - - test_match ("\\{", "{"); - test_match ("\\^", "^"); - test_match ("\\.", "."); - test_match ("\\*", "*"); - test_match ("\\[", "["); - test_match ("\\$", "$"); - test_match ("\\\\", "\\"); - - test_match ("ab*", "a"); - test_match ("ab*", "abb"); - - /* Valid consecutive repetitions. */ - test_match ("a**", "a"); - /* Valid period. */ - test_match (".", "a"); - TEST_REGISTERS (".", "a", 0, 1, -1, -1, -1, -1); - test_match (".", "\004"); - test_match (".", "\n"); - /* Valid bracket expressions. */ - test_match ("[ab]", "a"); - test_match ("[ab]", "b"); - test_fastmap ("[ab]", "ab", 0, 0); - TEST_REGISTERS ("[ab]", "a", 0, 1, -1, -1, -1, -1); - TEST_REGISTERS ("[ab]", "xax", 1, 2, -1, -1, -1, -1); - - test_fastmap ("[^ab]", "ab", 1, 1); - test_match ("[^ab]", "c"); - test_match ("[^a]", "\n"); - - test_match ("[a]*a", "aa"); - - test_match ("[[]", "["); - test_match ("[]]", "]"); - test_match ("[.]", "."); - test_match ("[*]", "*"); - test_match ("[\\]", "\\"); - test_match ("[\\(]", "("); - test_match ("[\\)]", ")"); - test_match ("[^]]", "a"); - test_match ("[a^]", "^"); - test_match ("[a$]", "$"); - test_match ("[]a]", "]"); - test_match ("[a][]]", "a]"); - test_match ("[\n]", "\n"); - test_match ("[^a]", "\n"); - test_match ("[a-]", "a"); - - TEST_REGISTERS ("\\`[ \t\n]*", " karl (Karl Berry)", 0, 1, -1, -1, -1, -1); - TEST_REGISTERS ("[ \t\n]*\\'", " karl (Karl Berry)", 18, 18, -1, -1, -1, -1); - - /* Collating, noncollating, - equivalence classes aren't - implemented yet. */ - - - /* Character classes. */ - test_match ("[:alpha:]", "p"); - test_match ("[[:alpha:]]", "a"); - test_match ("[[:alpha:]]", "z"); - test_match ("[[:alpha:]]", "A"); - test_match ("[[:alpha:]]", "Z"); - test_match ("[[:upper:]]", "A"); - test_match ("[[:upper:]]", "Z"); - test_match ("[[:lower:]]", "a"); - test_match ("[[:lower:]]", "z"); - - test_match ("[[:digit:]]", "0"); - test_match ("[[:digit:]]", "9"); - test_fastmap ("[[:digit:]]", "0123456789", 0, 0); - - test_match ("[[:alnum:]]", "0"); - test_match ("[[:alnum:]]", "9"); - test_match ("[[:alnum:]]", "a"); - test_match ("[[:alnum:]]", "z"); - test_match ("[[:alnum:]]", "A"); - test_match ("[[:alnum:]]", "Z"); - test_match ("[[:xdigit:]]", "0"); - test_match ("[[:xdigit:]]", "9"); - test_match ("[[:xdigit:]]", "A"); - test_match ("[[:xdigit:]]", "F"); - test_match ("[[:xdigit:]]", "a"); - test_match ("[[:xdigit:]]", "f"); - test_match ("[[:space:]]", " "); - test_match ("[[:print:]]", " "); - test_match ("[[:print:]]", "~"); - test_match ("[[:punct:]]", ","); - test_match ("[[:graph:]]", "!"); - test_match ("[[:graph:]]", "~"); - test_match ("[[:cntrl:]]", "\177"); - test_match ("[[:digit:]a]", "a"); - test_match ("[[:digit:]a]", "2"); - test_match ("[a[:digit:]]", "a"); - test_match ("[a[:digit:]]", "2"); - test_match ("[[:]", "["); - test_match ("[:]", ":"); - test_match ("[[:a]", "["); - test_match ("[[:alpha:a]", "["); - /* Valid ranges. */ - test_match ("[a-a]", "a"); - test_fastmap ("[a-a]", "a", 0, 0); - TEST_REGISTERS ("[a-a]", "xax", 1, 2, -1, -1, -1, -1); - - test_match ("[a-z]", "z"); - test_fastmap ("[a-z]", "abcdefghijklmnopqrstuvwxyz", 0, 0); - test_match ("[-a]", "-"); /* First */ - test_match ("[-a]", "a"); - test_match ("[a-]", "-"); /* Last */ - test_match ("[a-]", "a"); - test_match ("[--@]", "@"); /* First and starting point. */ - - test_match ("[%--a]", "%"); /* Ending point. */ - test_match ("[%--a]", "-"); /* Ditto. */ - - test_match ("[a%--]", "%"); /* Both ending point and last. */ - test_match ("[a%--]", "-"); - test_match ("[%--a]", "a"); /* Ending point only. */ - test_match ("[a-c-f]", "e"); /* Piggyback. */ - - test_match ("[)-+--/]", "*"); - test_match ("[)-+--/]", ","); - test_match ("[)-+--/]", "/"); - test_match ("[[:digit:]-]", "-"); - /* Concatenation ????*/ - test_match ("[ab][cd]", "ac"); - test_fastmap ("[ab][cd]", "ab", 0, 0); - TEST_REGISTERS ("[ab][cd]", "ad", 0, 2, -1, -1, -1, -1); - TEST_REGISTERS ("[ab][cd]", "xadx", 1, 3, -1, -1, -1, -1); - - /* Valid expression anchoring. */ - test_match ("^a", "a"); - test_fastmap ("^a", "a", 0, 0); - TEST_REGISTERS ("^a", "ax", 0, 1, -1, -1, -1, -1); - - test_match ("^", ""); - TEST_REGISTERS ("^", "", 0, 0, -1, -1, -1, -1); - test_match ("$", ""); - TEST_REGISTERS ("$", "", 0, 0, -1, -1, -1, -1); - - test_match ("a$", "a"); - test_fastmap ("a$", "a", 0, 0); - TEST_REGISTERS ("a$", "xa", 1, 2, -1, -1, -1, -1); - - test_match ("^ab$", "ab"); - test_fastmap ("^ab$", "a", 0, 0); - TEST_REGISTERS ("^a$", "a", 0, 1, -1, -1, -1, -1); - - test_fastmap ("^$", "", 0, 0); - test_match ("^$", ""); - TEST_REGISTERS ("^$", "", 0, 0, -1, -1, -1, -1); - - TEST_SEARCH (PARENS_TO_OPS ("(^a)"), "ab", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("(a$)"), "ba", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("^(^a)"), "ab", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("(a$)$"), "ba", 0, 2); - - /* Two strings. */ - test_match_2 ("ab", "a", "b"); - TEST_REGISTERS_2 ("ab", "a", "b", 0, 2, -1, -1, -1, -1); - - test_match_2 ("a", "", "a"); - test_match_2 ("a", "a", ""); - test_match_2 ("ab", "a", "b"); - /* (start)pos. */ - TEST_POSITIONED_MATCH ("b", "ab", 1); - /* mstop. */ - TEST_TRUNCATED_MATCH ("a", "ab", 1); - - - /* Both basic and extended, continued; should not match. */ - - test_should_match = false; - /* Ordinary characters. */ - test_match ("abc", "ab"); - - TEST_SEARCH ("c", "ab", 0, 2); - TEST_SEARCH ("c", "ab", 0, 2); - TEST_SEARCH ("c", "ab", 1, -2); - TEST_SEARCH ("c", "ab", 0, 10); - TEST_SEARCH ("c", "ab", 1, -10); - TEST_SEARCH_2 ("c", "a", "b", 0, 2, 2); - TEST_SEARCH_2 ("c", "a", "b", 0, 2, 2); - TEST_SEARCH_2 ("c", "a", "b", 0, 2, 2); - TEST_SEARCH_2 ("c", "a", "b", 1, -2, 2); - TEST_SEARCH_2 ("c", "a", "b", 1, -2, 2); - - TEST_SEARCH ("c", "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 236, -237); - - /* Invalid use of special characters. */ - invalid_pattern (REG_EESCAPE, "\\"); - invalid_pattern (REG_EESCAPE, "a\\"); - invalid_pattern (REG_EESCAPE, "a*\\"); - /* Invalid period. */ - test_match (".", ""); - /* Invalid bracket expressions. */ - test_match ("[ab]", "c"); - test_match ("[^b]", "b"); - test_match ("[^]]", "]"); - - invalid_pattern (REG_EBRACK, "["); - invalid_pattern (REG_EBRACK, "[^"); - invalid_pattern (REG_EBRACK, "[a"); - invalid_pattern (REG_EBRACK, "[]"); - invalid_pattern (REG_EBRACK, "[]a"); - invalid_pattern (REG_EBRACK, "a[]a"); - - - test_match ("[:alpha:]", "q"); /* Character classes. */ - test_match ("[[:alpha:]]", "2"); - test_match ("[[:upper:]]", "a"); - test_match ("[[:lower:]]", "A"); - test_match ("[[:digit:]]", "a"); - test_match ("[[:alnum:]]", ":"); - test_match ("[[:xdigit:]]", "g"); - test_match ("[[:space:]]", "a"); - test_match ("[[:print:]]", "\177"); - test_match ("[[:punct:]]", "a"); - test_match ("[[:graph:]]", " "); - test_match ("[[:cntrl:]]", "a"); - invalid_pattern (REG_EBRACK, "[[:"); - invalid_pattern (REG_EBRACK, "[[:alpha:"); - invalid_pattern (REG_EBRACK, "[[:alpha:]"); - invalid_pattern (REG_ECTYPE, "[[::]]"); - invalid_pattern (REG_ECTYPE, "[[:a:]]"); - invalid_pattern (REG_ECTYPE, "[[:alpo:]]"); - invalid_pattern (REG_ECTYPE, "[[:a:]"); - - test_match ("[a-z]", "2"); /* Invalid ranges. */ - test_match ("[^-a]", "-"); - test_match ("[^a-]", "-"); - test_match ("[)-+--/]", "."); - invalid_pattern (REG_ERANGE, "[z-a]"); /* Empty */ - invalid_pattern (REG_ERANGE, "[a--]"); /* Empty */ - invalid_pattern (REG_ERANGE, "[[:digit:]-9]"); - invalid_pattern (REG_ERANGE, "[a-[:alpha:]]"); - invalid_pattern (REG_ERANGE, "[a-"); - invalid_pattern (REG_EBRACK, "[a-z"); - - test_match ("[ab][cd]", "ae"); /* Concatenation. */ - test_match ("b*c", "b"); /* Star. */ - - /* Invalid anchoring. */ - test_match ("^", "a"); - test_match ("^a", "ba"); - test_match ("$", "b"); - test_match ("a$", "ab"); - test_match ("^$", "a"); - test_match ("^ab$", "a"); - - TEST_SEARCH ("^a", "b\na", 0, 3); - TEST_SEARCH ("b$", "b\na", 0, 3); - - test_match_2 ("^a", "\n", "a"); - test_match_2 ("a$", "a", "\n"); - - TEST_SEARCH (PARENS_TO_OPS ("(^a)"), "ba", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("(a$)"), "ab", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("^(^a)"), "ba", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("(a$)$"), "ab", 0, 2); - - printf ("\nFinished generic POSIX tests.\n"); -} - - - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/regex-0.12/test/psx-group.c b/gnu/lib/regex-0.12/test/psx-group.c deleted file mode 100644 index 08ae8a28d37a..000000000000 --- a/gnu/lib/regex-0.12/test/psx-group.c +++ /dev/null @@ -1,440 +0,0 @@ -/* psx-group.c: test POSIX grouping, both basic and extended. */ - -#include "test.h" - - -void -test_grouping () -{ - printf ("\nStarting POSIX grouping tests.\n"); - - test_should_match = true; - - test_fastmap (PARENS_TO_OPS ("(a)"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a)"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)"), "a", 0, 1, 0, 1, -1, -1); - TEST_REGISTERS (PARENS_TO_OPS ("(a)"), "xax", 1, 2, 1, 2, -1, -1); - - test_match (PARENS_TO_OPS ("((a))"), "a"); - test_fastmap (PARENS_TO_OPS ("((a))"), "a", 0, 0); - TEST_REGISTERS (PARENS_TO_OPS ("((a))"), "a", 0, 1, 0, 1, 0, 1); - TEST_REGISTERS (PARENS_TO_OPS ("((a))"), "xax", 1, 2, 1, 2, 1, 2); - - test_fastmap (PARENS_TO_OPS ("(a)(b)"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a)(b)"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)(b)"), "ab", 0, 2, 0, 1, 1, 2); - - TEST_REGISTERS (PARENS_TO_OPS ("(a)(b)"), "xabx", 1, 3, 1, 2, 2, 3); - - test_all_registers (PARENS_TO_OPS ("((a)(b))"), "ab", "", 0, 2, 0, 2, 0, 1, - 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - - /* Test that we simply ignore groups past the 255th. */ - test_match (PARENS_TO_OPS ("((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((a))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))"), "a"); - - - /* Per POSIX D11.1, p. 125. */ - - test_fastmap (PARENS_TO_OPS ("(a)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*"), "", 0, 0, -1, -1, -1, -1); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*"), "aa", 0, 2, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a*)"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)"), "", 0, 0, 0, 0, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a*)"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)"), "a", 0, 1, 0, 1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)b"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a*)b"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)b"), "b", 0, 1, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)b"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)b"), "ab", 0, 2, 0, 1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a*)b)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a*)b)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("((a*)b)*"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "ab", 0, 2, 0, 2, 0, 1); - - test_match (PARENS_TO_OPS ("((a*)b)*"), "abb"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "abb", 0, 3, 2, 3, 2, 2); - - test_match (PARENS_TO_OPS ("((a*)b)*"), "aabab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "aabab", 0, 5, 3, 5, 3, 4); - - test_match (PARENS_TO_OPS ("((a*)b)*"), "abbab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "abbab", 0, 5, 3, 5, 3, 4); - - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "xabbabx", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("((a*)b)*"), "abaabaaaab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b)*"), "abaabaaab", 0, 9, 5, 9, 5, 8); - - test_fastmap (PARENS_TO_OPS ("(ab)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(ab)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(ab)*"), "", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(ab)*"), "abab"); - TEST_REGISTERS (PARENS_TO_OPS ("(ab)*"), "abab", 0, 4, 2, 4, -1, -1); - - /* We match the empty string here. */ - TEST_REGISTERS (PARENS_TO_OPS ("(ab)*"), "xababx", 0, 0, -1, -1, -1, -1); - - /* Per David A. Willcox. */ - TEST_REGISTERS (PARENS_TO_OPS ("a(b*)c"), "ac", 0, 2, 1, 1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a)*b"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a)*b"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*b"), "b", 0, 1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(a)*b"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*b"), "ab", 0, 2, 0, 1, -1, -1); - - test_match_2 (PARENS_TO_OPS ("(a)*b"), "a", "ab"); - TEST_REGISTERS_2 (PARENS_TO_OPS ("(a)*b"), "a", "ab", 0, 3, 1, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a)*b"), "aab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*b"), "aab", 0, 3, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a)*a"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a)*a"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*a"), "a", 0, 1, -1, -1, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*"), "", 0, 0, 0, 0, 0, 0); - - test_match (PARENS_TO_OPS ("((a*))*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a*))*"), "", 0, 0, 0, 0, 0, 0); - test_match (PARENS_TO_OPS ("((a*))*"), "aa"); - - test_fastmap (PARENS_TO_OPS ("(a*)*b"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a*)*b"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "b", 0, 1, 0, 0, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "xbx", 1, 2, 1, 1, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)*b"), "ab"); /* Per rms. */ - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "ab", 0, 2, 0, 1, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "xabx", 1, 3, 1, 2, -1, -1); - - /* Test register restores. */ - test_match (PARENS_TO_OPS ("(a*)*b"), "aab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b"), "aab", 0, 3, 0, 2, -1, -1); - - TEST_REGISTERS_2 (PARENS_TO_OPS ("(a*)*b"), "a", "ab", 0, 3, 0, 2, -1, -1); - - /* We are matching the empty string, with backtracking. */ - test_fastmap (PARENS_TO_OPS ("(a*)a"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a*)a"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)a"), "a", 0, 1, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)a"), "aa"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)a"), "aa", 0, 2, 0, 1, -1, -1); - - /* We are matching the empty string, with backtracking. */ -/*fails test_match (PARENS_TO_OPS ("(a*)*a"), "a"); */ - test_match (PARENS_TO_OPS ("(a*)*a"), "aa"); - /* Match the empty string. */ - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "a", 0, 1, 0, 0, -1, -1); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "xax", 1, 2, 1, 1, -1, -1); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "aa", 0, 2, 0, 1, -1, -1); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*a"), "xaax", 1, 3, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a)*ab"), "a", 0 , 0); - test_match (PARENS_TO_OPS ("(a)*ab"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*ab"), "ab", 0, 2, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(a)*ab"), "aab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a)*ab"), "aab", 0, 3, 0, 1, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS("(a)*ab"), "xaabx", 1, 4, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)ab"), "a", 0 , 0); - test_match (PARENS_TO_OPS ("(a*)ab"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)ab"), "ab", 0, 2, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)ab"), "aab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)ab"), "aab", 0, 3, 0, 1, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS ("(a*)ab"), "xaabx", 1, 4, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)*ab"), "a", 0 , 0); - test_match (PARENS_TO_OPS ("(a*)*ab"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*ab"), "ab", 0, 2, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)*ab"), "aab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*ab"), "aab", 0, 3, 0, 1, -1, -1); - - TEST_REGISTERS (PARENS_TO_OPS("(a*)*ab"), "xaabx", 1, 4, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)*b*c"), "abc", 0, 0); - test_match (PARENS_TO_OPS ("(a*)*b*c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*b*c"), "c", 0, 1, 0, 0, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a)*(ab)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a)*(ab)*"), "ab"); - /* Register 1 doesn't match at all (vs. matching the empty string) - because of backtracking, hence -1's. */ - TEST_REGISTERS (PARENS_TO_OPS ("(a)*(ab)*"), "ab", 0, 2, -1, -1, 0, 2); - - test_match (PARENS_TO_OPS ("(a*)*(ab)*"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*(ab)*"), "ab", 0, 2, 0, 0, 0, 2); - - test_fastmap (PARENS_TO_OPS ("(a*b)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a*b)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*"), "", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b)*"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*"), "b", 0, 1, 0, 1, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b)*"), "baab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*"), "baab", 0, 4, 1, 4, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*b*)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a*b*)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "", 0, 0, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "a", 0, 1, 0, 1, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "ba"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "ba", 0, 2, 1, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "ab", 0, 2, 0, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "aa"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "aa", 0, 2, 0, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "bb"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "bb", 0, 2, 0, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)*"), "aba"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "aba", 0, 3, 2, 3, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b*)b"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)b"), "b", 0, 1, 0, 0, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a*)*(b*)*)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a*)*(b*)*)*"), ""); - test_all_registers (PARENS_TO_OPS ("((a*)*(b*)*)*"), "", "", 0, 0, 0, 0, - 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("((a*)*(b*)*)*"), "aba"); - /* Perhaps register 3 should be 3/3 here? Not sure if standard - specifies this. xx*/ - test_all_registers (PARENS_TO_OPS ("((a*)*(b*)*)*"), "aba", "", 0, 3, 2, 3, - 2, 3, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a*)(b*))*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a*)(b*))*"), ""); - - test_all_registers (PARENS_TO_OPS ("((a*)(b*))*"), "", "", 0, 0, 0, 0, - 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), ""); - - test_match (PARENS_TO_OPS ("((a*)(b*))*"), "aba"); - test_all_registers (PARENS_TO_OPS ("((a*)(b*))*"), "aba", "", 0, 3, 2, 3, - 2, 3, 3, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a)*(b)*)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a)*(b)*)*"), ""); - test_all_registers (PARENS_TO_OPS ("((a)*(b)*)*"), "", "", 0, 0, 0, 0, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("((a)*(b)*)*"), "aba"); - - test_all_registers (PARENS_TO_OPS ("((a)*(b)*)*"), "aba", "", 0, 3, 2, 3, - 2, 3, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(c(a)*(b)*)*"), "c", 0, 0); - test_match (PARENS_TO_OPS ("(c(a)*(b)*)*"), ""); - test_all_registers (PARENS_TO_OPS ("(c(a)*(b)*)*"), "", "", 0, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(c(a)*(b)*)*"), "c"); - test_all_registers (PARENS_TO_OPS ("(c(a)*(b)*)*"), "c", "", 0, 1, 0, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("c((a)*(b)*)*"), "c", 0, 0); - test_match (PARENS_TO_OPS ("c((a)*(b)*)*"), "c"); - test_all_registers (PARENS_TO_OPS ("c((a)*(b)*)*"), "c", "", 0, 1, 1, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(((a)*(b)*)*)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(((a)*(b)*)*)*"), ""); - test_all_registers (PARENS_TO_OPS ("(((a)*(b)*)*)*"), "", "", 0, 0, 0, 0, - 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), ""); - test_fastmap (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), "c", 0, 0); - - test_all_registers (PARENS_TO_OPS ("(c(c(a)*(b)*)*)*"), "", "", 0, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a)*b)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a)*b)*"), ""); - - test_match (PARENS_TO_OPS ("((a)*b)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("((a)*b)*"), "abb"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "abb", 0, 3, 2, 3, 0, 1); /*zz*/ - - test_match (PARENS_TO_OPS ("((a)*b)*"), "abbab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "abbab", 0, 5, 3, 5, 3, 4); - - /* We match the empty string here. */ - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*"), "xabbabx", 0, 0, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(a*)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*"), "", 0, 0, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(a*)*"), "aa"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*)*"), "aa", 0, 2, 0, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a*)*)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("((a*)*)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)*)*"), "", 0, 0, 0, 0, 0, 0); - - test_match (PARENS_TO_OPS ("((a*)*)*"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)*)*"), "a", 0, 1, 0, 1, 0, 1); - - test_fastmap (PARENS_TO_OPS ("(ab*)*"), "a", 0, 0); - test_match (PARENS_TO_OPS ("(ab*)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*"), "", 0, 0, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(ab*)*"), "aa"); - TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*"), "aa", 0, 2, 1, 2, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(ab*)*c"), "ac", 0, 0); - test_match (PARENS_TO_OPS ("(ab*)*c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*c"), "c", 0, 1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(ab*)*c"), "abbac"); - TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*c"), "abbac", 0, 5, 3, 4, -1, -1); - - test_match (PARENS_TO_OPS ("(ab*)*c"), "abac"); - TEST_REGISTERS (PARENS_TO_OPS ("(ab*)*c"), "abac", 0, 4, 2, 3, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*b)*c"), "abc", 0, 0); - test_match (PARENS_TO_OPS ("(a*b)*c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "c", 0, 1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b)*c"), "bbc"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "bbc", 0, 3, 1, 2, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b)*c"), "aababc"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "aababc", 0, 6, 3, 5, -1, -1); - - test_match (PARENS_TO_OPS ("(a*b)*c"), "aabaabc"); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b)*c"), "aabaabc", 0, 7, 3, 6, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a*)b*)"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a*)b*)"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)"), "", 0, 0, 0, 0, 0, 0); - - test_match (PARENS_TO_OPS ("((a*)b*)"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)"), "a", 0, 1, 0, 1, 0, 1); - - test_match (PARENS_TO_OPS ("((a*)b*)"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)"), "b", 0, 1, 0, 1, 0, 0); - - test_fastmap (PARENS_TO_OPS ("((a)*b*)"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("((a)*b*)"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "", 0, 0, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("((a)*b*)"), "a"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "a", 0, 1, 0, 1, 0, 1); - - test_match (PARENS_TO_OPS ("((a)*b*)"), "b"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "b", 0, 1, 0, 1, -1, -1); - - test_match (PARENS_TO_OPS ("((a)*b*)"), "ab"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)"), "ab", 0, 2, 0, 2, 0, 1); - - test_fastmap (PARENS_TO_OPS ("((a*)b*)c"), "abc", 0, 0); - test_match (PARENS_TO_OPS ("((a*)b*)c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("((a*)b*)c"), "c", 0, 1, 0, 0, 0, 0); - - test_fastmap (PARENS_TO_OPS ("((a)*b*)c"), "abc", 0, 0); - test_match (PARENS_TO_OPS ("((a)*b*)c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b*)c"), "c", 0, 1, 0, 0, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(a*b*)*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(a*b*)*"), ""); - TEST_REGISTERS (PARENS_TO_OPS ("(a*b*)*"), "", 0, 0, 0, 0, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(((a*))((b*)))*"), "ab", 0, 0); - test_match (PARENS_TO_OPS ("(((a*))((b*)))*"), ""); - test_all_registers (PARENS_TO_OPS ("(((a*))((b*)))*"), "", "", 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("(c*((a*))d*((b*))e*)*"), "abcde", 0, 0); - test_match (PARENS_TO_OPS ("(c*((a*))d*((b*))e*)*"), ""); - test_all_registers (PARENS_TO_OPS ("(c*((a*))d*((b*))e*)*"), "", "", 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1); - - test_fastmap (PARENS_TO_OPS ("((a)*b)*c"), "abc", 0, 0); - test_match (PARENS_TO_OPS ("((a)*b)*c"), "c"); - TEST_REGISTERS (PARENS_TO_OPS ("((a)*b)*c"), "c", 0, 1, -1, -1, -1, -1); - - test_match (PARENS_TO_OPS ("(ab)*"), ""); - test_match (PARENS_TO_OPS ("((ab)*)"), ""); - test_match (PARENS_TO_OPS ("(((ab)*))"), ""); - test_match (PARENS_TO_OPS ("((((ab)*)))"), ""); - test_match (PARENS_TO_OPS ("(((((ab)*))))"), ""); - test_match (PARENS_TO_OPS ("((((((ab)*)))))"), ""); - test_match (PARENS_TO_OPS ("(((((((ab)*))))))"), ""); - test_match (PARENS_TO_OPS ("((((((((ab)*)))))))"), ""); - test_match (PARENS_TO_OPS ("(((((((((ab)*))))))))"), ""); - - - test_fastmap (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "a", 0, 0); - test_match (PARENS_TO_OPS ("((((((((((ab)*)))))))))"), ""); - test_match (PARENS_TO_OPS ("(((((((((ab)*))))))))"), ""); - test_all_registers (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "", NULL, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1); - - test_match (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "abab"); - test_all_registers (PARENS_TO_OPS ("(((((((((ab)*))))))))"), "abab", NULL, - 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 2, 4); - - - test_should_match = false; - - invalid_pattern (REG_EPAREN, PARENS_TO_OPS ("(a")); - - test_match (PARENS_TO_OPS ("(a)"), ""); - test_match (PARENS_TO_OPS ("((a))"), "b"); - test_match (PARENS_TO_OPS ("(a)(b)"), "ac"); - test_match (PARENS_TO_OPS ("(ab)*"), "acab"); - test_match (PARENS_TO_OPS ("(a*)*b"), "c"); - test_match (PARENS_TO_OPS ("(a*b)*"), "baa"); - test_match (PARENS_TO_OPS ("(a*b)*"), "baabc"); - test_match (PARENS_TO_OPS ("(a*b*)*"), "c"); - test_match (PARENS_TO_OPS ("((a*)*(b*)*)*"), "c"); - test_match (PARENS_TO_OPS ("(a*)*"), "ab"); - test_match (PARENS_TO_OPS ("((a*)*)*"), "ab"); - test_match (PARENS_TO_OPS ("((a*)*)*"), "b"); - test_match (PARENS_TO_OPS ("(ab*)*"), "abc"); - test_match (PARENS_TO_OPS ("(ab*)*c"), "abbad"); - test_match (PARENS_TO_OPS ("(a*c)*b"), "aacaacd"); - test_match (PARENS_TO_OPS ("(a*)"), "b"); - test_match (PARENS_TO_OPS ("((a*)b*)"), "c"); - - /* Expression anchoring. */ - TEST_SEARCH (PARENS_TO_OPS ("(^b)"), "ab", 0, 2); - TEST_SEARCH (PARENS_TO_OPS ("(a$)"), "ab", 0, 2); - - printf ("\nFinished POSIX grouping tests.\n"); -} diff --git a/gnu/lib/regex-0.12/test/psx-interf.c b/gnu/lib/regex-0.12/test/psx-interf.c deleted file mode 100644 index 8312d5e7d74a..000000000000 --- a/gnu/lib/regex-0.12/test/psx-interf.c +++ /dev/null @@ -1,624 +0,0 @@ -/* psx-interf.c: test POSIX interface. */ - -#include -#include - -#include "test.h" - -#define ERROR_CODE_LENGTH 20 -#define TEST_ERRBUF_SIZE 15 - - -void test_compile (); - - -/* ANSWER should be at least ERROR_CODE_LENGTH long. */ - -static char * -get_error_string (error_code, answer) - int error_code; - char answer[]; -{ - switch (error_code) - { - case 0: strcpy (answer, "No error"); break; - case REG_NOMATCH: strcpy (answer, "REG_NOMATCH"); break; - case REG_BADPAT: strcpy (answer, "REG_BADPAT"); break; - case REG_EPAREN: strcpy (answer, "REG_EPAREN"); break; - case REG_ESPACE: strcpy (answer, "REG_ESPACE"); break; - case REG_ECOLLATE: strcpy (answer, "REG_ECOLLATE"); break; - case REG_ECTYPE: strcpy (answer, "REG_ECTYPE"); break; - case REG_EESCAPE: strcpy (answer, "REG_EESCAPE"); break; - case REG_ESUBREG: strcpy (answer, "REG_ESUBREG"); break; - case REG_EBRACK: strcpy (answer, "REG_EBRACK"); break; - case REG_EBRACE: strcpy (answer, "REG_EBRACE"); break; - case REG_BADBR: strcpy (answer, "REG_BADBR"); break; - case REG_ERANGE: strcpy (answer, "REG_ERANGE"); break; - case REG_BADRPT: strcpy (answer, "REG_BADRPT"); break; - case REG_EEND: strcpy (answer, "REG_EEND"); break; - default: strcpy (answer, "Bad error code"); - } - return answer; -} - - -/* I don't think we actually need to initialize all these things. - --karl */ - -void -init_pattern_buffer (pattern_buffer_ptr) - regex_t *pattern_buffer_ptr; -{ - pattern_buffer_ptr->buffer = NULL; - pattern_buffer_ptr->allocated = 0; - pattern_buffer_ptr->used = 0; - pattern_buffer_ptr->fastmap = NULL; - pattern_buffer_ptr->fastmap_accurate = 0; - pattern_buffer_ptr->translate = NULL; - pattern_buffer_ptr->can_be_null = 0; - pattern_buffer_ptr->re_nsub = 0; - pattern_buffer_ptr->no_sub = 0; - pattern_buffer_ptr->not_bol = 0; - pattern_buffer_ptr->not_eol = 0; -} - - -void -test_compile (valid_pattern, error_code_expected, pattern, - pattern_buffer_ptr, cflags) - unsigned valid_pattern; - int error_code_expected; - const char *pattern; - regex_t *pattern_buffer_ptr; - int cflags; -{ - int error_code_returned; - boolean error = false; - char errbuf[TEST_ERRBUF_SIZE]; - - init_pattern_buffer (pattern_buffer_ptr); - error_code_returned = regcomp (pattern_buffer_ptr, pattern, cflags); - - if (valid_pattern && error_code_returned) - { - printf ("\nShould have been a valid pattern but wasn't.\n"); - regerror (error_code_returned, pattern_buffer_ptr, errbuf, - TEST_ERRBUF_SIZE); - printf ("%s", errbuf); - error = true; - } - - if (!valid_pattern && !error_code_returned) - { - printf ("\n\nInvalid pattern compiled as valid:\n"); - error = true; - } - - if (error_code_returned != error_code_expected) - { - char expected_error_string[ERROR_CODE_LENGTH]; - char returned_error_string[ERROR_CODE_LENGTH]; - - get_error_string (error_code_expected, expected_error_string), - get_error_string (error_code_returned, returned_error_string); - - printf (" Expected error code %s but got `%s'.\n", - expected_error_string, returned_error_string); - - error = true; - } - - if (error) - print_pattern_info (pattern, pattern_buffer_ptr); -} - - -static void -test_nsub (sub_count, pattern, cflags) - unsigned sub_count; - char *pattern; - int cflags; - -{ - regex_t pattern_buffer; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - - if (pattern_buffer.re_nsub != sub_count) - { - printf ("\nShould have counted %d subexpressions but counted %d \ -instead.\n", sub_count, pattern_buffer.re_nsub); - } - - regfree (&pattern_buffer); -} - - -static void -test_regcomp () -{ - regex_t pattern_buffer; - int cflags = 0; - - - printf ("\nStarting regcomp tests.\n"); - - cflags = 0; - test_compile (0, REG_ESUBREG, "\\(a\\)\\2", &pattern_buffer, cflags); - test_compile (0, REG_EBRACE, "a\\{", &pattern_buffer, cflags); - test_compile (0, REG_BADBR, "a\\{-1\\}", &pattern_buffer, cflags); - test_compile (0, REG_EBRACE, "a\\{", &pattern_buffer, cflags); - test_compile (0, REG_EBRACE, "a\\{1", &pattern_buffer, cflags); - - cflags = REG_EXTENDED; - test_compile (0, REG_ECTYPE, "[[:alpo:]]", &pattern_buffer, cflags); - test_compile (0, REG_EESCAPE, "\\", &pattern_buffer, cflags); - test_compile (0, REG_EBRACK, "[a", &pattern_buffer, cflags); - test_compile (0, REG_EPAREN, "(", &pattern_buffer, cflags); - test_compile (0, REG_ERANGE, "[z-a]", &pattern_buffer, cflags); - - test_nsub (1, "(a)", cflags); - test_nsub (2, "((a))", cflags); - test_nsub (2, "(a)(b)", cflags); - - cflags = REG_EXTENDED | REG_NOSUB; - test_nsub (1, "(a)", cflags); - - regfree (&pattern_buffer); - - printf ("\nFinished regcomp tests.\n"); -} - - -static void -fill_pmatch (pmatch, start0, end0, start1, end1, start2, end2) - regmatch_t pmatch[]; - regoff_t start0, end0, start1, end1, start2, end2; -{ - pmatch[0].rm_so = start0; - pmatch[0].rm_eo = end0; - pmatch[1].rm_so = start1; - pmatch[1].rm_eo = end1; - pmatch[2].rm_so = start2; - pmatch[2].rm_eo = end2; -} - - -static void -test_pmatch (pattern, string, nmatch, pmatch, correct_pmatch, cflags) - char *pattern; - char *string; - unsigned nmatch; - regmatch_t pmatch[]; - regmatch_t correct_pmatch[]; - int cflags; -{ - regex_t pattern_buffer; - unsigned this_match; - int error_code_returned; - boolean found_nonmatch = false; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - error_code_returned = regexec (&pattern_buffer, string, nmatch, pmatch, 0); - - if (error_code_returned == REG_NOMATCH) - printf ("Matching failed in test_pmatch.\n"); - else - { - for (this_match = 0; this_match < nmatch; this_match++) - { - if (pmatch[this_match].rm_so != correct_pmatch[this_match].rm_so) - { - if (found_nonmatch == false) - printf ("\n"); - - printf ("Pmatch start %d wrong: was %d when should have \ -been %d.\n", this_match, pmatch[this_match].rm_so, - correct_pmatch[this_match].rm_so); - found_nonmatch = true; - } - if (pmatch[this_match].rm_eo != correct_pmatch[this_match].rm_eo) - { - if (found_nonmatch == false) - printf ("\n"); - - printf ("Pmatch end %d wrong: was %d when should have been \ -%d.\n", this_match, pmatch[this_match].rm_eo, - correct_pmatch[this_match].rm_eo); - found_nonmatch = true; - } - } - - if (found_nonmatch) - { - printf (" The number of pmatches requested was: %d.\n", nmatch); - printf (" The string to match was: `%s'.\n", string); - print_pattern_info (pattern, &pattern_buffer); - } - } /* error_code_returned == REG_NOMATCH */ - - regfree (&pattern_buffer); -} - - -static void -test_eflags (must_match_bol, must_match_eol, pattern, string, cflags, eflags) - boolean must_match_bol; - boolean must_match_eol; - char *pattern; - char *string; - int cflags; - int eflags; -{ - regex_t pattern_buffer; - int error_code_returned; - boolean was_error = false; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - error_code_returned = regexec (&pattern_buffer, string, 0, 0, eflags); - - if (error_code_returned == REG_NOMATCH) - { - /* If wasn't true that both 1) the anchored part of the pattern - had to match this string and 2) this string was a proper - substring... */ - - if (!( (must_match_bol && (eflags & REG_NOTBOL)) - || (must_match_eol && (eflags & REG_NOTEOL)) )) - { - printf ("\nEflags test failed: didn't match when should have.\n"); - was_error = true; - } - } - else /* We got a match. */ - { - /* If wasn't true that either 1) the anchored part of the pattern - didn't have to match this string or 2) this string wasn't a - proper substring... */ - - if ((must_match_bol == (eflags & REG_NOTBOL)) - || (must_match_eol == (eflags & REG_NOTEOL))) - { - printf ("\nEflags test failed: matched when shouldn't have.\n"); - was_error = true; - } - } - - if (was_error) - { - printf (" The string to match was: `%s'.\n", string); - print_pattern_info (pattern, &pattern_buffer); - - if (eflags & REG_NOTBOL) - printf (" The eflag REG_BOL was set.\n"); - if (eflags & REG_NOTEOL) - printf (" The eflag REG_EOL was set.\n"); - } - - regfree (&pattern_buffer); -} - - -static void -test_ignore_case (should_match, pattern, string, cflags) - boolean should_match; - char *pattern; - char *string; - int cflags; -{ - regex_t pattern_buffer; - int error_code_returned; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0); - - if (should_match && error_code_returned == REG_NOMATCH) - { - printf ("\nIgnore-case test failed:\n"); - printf (" The string to match was: `%s'.\n", string); - print_pattern_info (pattern, &pattern_buffer); - - if (cflags & REG_ICASE) - printf (" The cflag REG_ICASE was set.\n"); - } - - regfree (&pattern_buffer); -} - - -static void -test_newline (should_match, pattern, string, cflags) - boolean should_match; - char *pattern; - char *string; - int cflags; -{ - regex_t pattern_buffer; - int error_code_returned; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0); - - if (should_match && error_code_returned == REG_NOMATCH) - { - printf ("\nNewline test failed:\n"); - printf (" The string to match was: `%s'.\n", string); - print_pattern_info (pattern, &pattern_buffer); - - if (cflags & REG_NEWLINE) - printf (" The cflag REG_NEWLINE was set.\n"); - else - printf (" The cflag REG_NEWLINE wasn't set.\n"); - } - - regfree (&pattern_buffer); -} - - -static void -test_posix_match (should_match, pattern, string, cflags) - boolean should_match; - char *pattern; - char *string; - int cflags; -{ - regex_t pattern_buffer; - int error_code_returned; - boolean was_error = false; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); - error_code_returned = regexec (&pattern_buffer, string, 0, 0, 0); - - if (should_match && error_code_returned == REG_NOMATCH) - { - printf ("\nShould have matched but didn't:\n"); - was_error = true; - } - else if (!should_match && error_code_returned != REG_NOMATCH) - { - printf ("\nShould not have matched but did:\n"); - was_error = true; - } - - if (was_error) - { - printf (" The string to match was: `%s'.\n", string); - print_pattern_info (pattern, &pattern_buffer); - } - - regfree (&pattern_buffer); -} - - -static void -test_regexec () -{ - regmatch_t pmatch[3]; - regmatch_t correct_pmatch[3]; - int cflags = 0; - int eflags = 0; - - printf ("\nStarting regexec tests.\n"); - - cflags = REG_NOSUB; /* shouldn't look at any of pmatch. */ - test_pmatch ("a", "a", 0, pmatch, correct_pmatch, cflags); - - /* Ask for less `pmatch'es than there are pattern subexpressions. - (Shouldn't look at pmatch[2]. */ - cflags = REG_EXTENDED; - fill_pmatch (correct_pmatch, 0, 1, 0, 1, 100, 101); - test_pmatch ("((a))", "a", 2, pmatch, correct_pmatch, cflags); - - /* Ask for same number of `pmatch'es as there are pattern subexpressions. */ - cflags = REG_EXTENDED; - fill_pmatch(correct_pmatch, 0, 1, 0, 1, -1, -1); - test_pmatch ("(a)", "a", 2, pmatch, correct_pmatch, cflags); - - /* Ask for more `pmatch'es than there are pattern subexpressions. */ - cflags = REG_EXTENDED; - fill_pmatch (correct_pmatch, 0, 1, -1, -1, -1, -1); - test_pmatch ("a", "a", 2, pmatch, correct_pmatch, cflags); - - eflags = REG_NOTBOL; - test_eflags (true, false, "^a", "a", cflags, eflags); - test_eflags (true, false, "(^a)", "a", cflags, eflags); - test_eflags (true, false, "a|^b", "b", cflags, eflags); - test_eflags (true, false, "^b|a", "b", cflags, eflags); - - eflags = REG_NOTEOL; - test_eflags (false, true, "a$", "a", cflags, eflags); - test_eflags (false, true, "(a$)", "a", cflags, eflags); - test_eflags (false, true, "a|b$", "b", cflags, eflags); - test_eflags (false, true, "b$|a", "b", cflags, eflags); - - eflags = REG_NOTBOL | REG_NOTEOL; - test_eflags (true, true, "^a$", "a", cflags, eflags); - test_eflags (true, true, "(^a$)", "a", cflags, eflags); - test_eflags (true, true, "a|(^b$)", "b", cflags, eflags); - test_eflags (true, true, "(^b$)|a", "b", cflags, eflags); - - cflags = REG_ICASE; - test_ignore_case (true, "a", "a", cflags); - test_ignore_case (true, "A", "A", cflags); - test_ignore_case (true, "A", "a", cflags); - test_ignore_case (true, "a", "A", cflags); - - test_ignore_case (true, "@", "@", cflags); - test_ignore_case (true, "\\[", "[", cflags); - test_ignore_case (true, "`", "`", cflags); - test_ignore_case (true, "{", "{", cflags); - - test_ignore_case (true, "[!-`]", "A", cflags); - test_ignore_case (true, "[!-`]", "a", cflags); - - cflags = 0; - test_ignore_case (false, "a", "a", cflags); - test_ignore_case (false, "A", "A", cflags); - test_ignore_case (false, "A", "a", cflags); - test_ignore_case (false, "a", "A", cflags); - - test_ignore_case (true, "@", "@", cflags); - test_ignore_case (true, "\\[", "[", cflags); - test_ignore_case (true, "`", "`", cflags); - test_ignore_case (true, "{", "{", cflags); - - test_ignore_case (true, "[!-`]", "A", cflags); - test_ignore_case (false, "[!-`]", "a", cflags); - - - /* Test newline stuff. */ - cflags = REG_EXTENDED | REG_NEWLINE; - test_newline (true, "\n", "\n", cflags); - test_newline (true, "a\n", "a\n", cflags); - test_newline (true, "\nb", "\nb", cflags); - test_newline (true, "a\nb", "a\nb", cflags); - - test_newline (false, ".", "\n", cflags); - test_newline (false, "[^a]", "\n", cflags); - - test_newline (true, "\n^a", "\na", cflags); - test_newline (true, "\n(^a|b)", "\na", cflags); - test_newline (true, "a$\n", "a\n", cflags); - test_newline (true, "(a$|b)\n", "a\n", cflags); - test_newline (true, "(a$|b|c)\n", "a\n", cflags); - test_newline (true, "((a$|b|c)$)\n", "a\n", cflags); - test_newline (true, "((a$|b|c)$)\n", "b\n", cflags); - test_newline (true, "(a$|b)\n|a\n", "a\n", cflags); - - test_newline (true, "^a", "\na", cflags); - test_newline (true, "a$", "a\n", cflags); - - /* Now test normal behavior. */ - cflags = REG_EXTENDED; - test_newline (true, "\n", "\n", cflags); - test_newline (true, "a\n", "a\n", cflags); - test_newline (true, "\nb", "\nb", cflags); - test_newline (true, "a\nb", "a\nb", cflags); - - test_newline (true, ".", "\n", cflags); - test_newline (true, "[^a]", "\n", cflags); - - test_newline (false, "\n^a", "\na", cflags); - test_newline (false, "a$\n", "a\n", cflags); - - test_newline (false, "^a", "\na", cflags); - test_newline (false, "a$", "a\n", cflags); - - - /* Test that matches whole string only. */ - cflags = 0; - test_posix_match (true, "a", "a", cflags); - - /* Tests that match substrings. */ - test_posix_match (true, "a", "ab", cflags); - test_posix_match (true, "b", "ab", cflags); - - /* Test that doesn't match. */ - test_posix_match (false, "a", "b", cflags); - - printf ("\nFinished regexec tests.\n"); -} - - -static void -test_error_code_message (error_code, expected_error_message) - int error_code; - char *expected_error_message; -{ - char returned_error_message[TEST_ERRBUF_SIZE]; - char error_code_string[ERROR_CODE_LENGTH]; - size_t expected_error_message_length = strlen (expected_error_message) + 1; - size_t returned_error_message_length = regerror (error_code, 0, - returned_error_message, - TEST_ERRBUF_SIZE); - - if (returned_error_message_length != expected_error_message_length) - { - printf ("\n\n Testing returned error codes, with expected error \ -message `%s':\n", expected_error_message); - - printf ("\n\n and returned error message `%s':\n", - returned_error_message); - printf (" should have returned a length of %d but returned %d.\n", - expected_error_message_length, returned_error_message_length); - } - - if (strncmp (expected_error_message, returned_error_message, - TEST_ERRBUF_SIZE - 1) != 0) - { - - get_error_string (error_code, error_code_string), - printf ("\n\n With error code %s (%d), expected error message:\n", - error_code_string, error_code); - - printf (" `%s'\n", expected_error_message); - printf (" but got:\n"); - printf (" `%s'\n", returned_error_message); - } -} - - -static void -test_error_code_allocation (error_code, expected_error_message) - int error_code; - char *expected_error_message; -{ - char *returned_error_message = NULL; - char error_code_string[ERROR_CODE_LENGTH]; - size_t returned_error_message_length = regerror (error_code, 0, - returned_error_message, - (size_t)0); - - returned_error_message = xmalloc (returned_error_message_length + 1); - - regerror (error_code, 0, returned_error_message, - returned_error_message_length); - - if (strcmp (expected_error_message, returned_error_message) != 0) - { - get_error_string (error_code, error_code_string), - - printf ("\n\n Testing error code allocation,\n"); - printf ("with error code %s (%d), expected error message:\n", - error_code_string, error_code); - printf (" `%s'\n", expected_error_message); - printf (" but got:\n"); - printf (" `%s'\n", returned_error_message); - } -} - - -static void -test_regerror () -{ - test_error_code_message (REG_NOMATCH, "No match"); - test_error_code_message (REG_BADPAT, "Invalid regular expression"); - test_error_code_message (REG_ECOLLATE, "Invalid collation character"); - test_error_code_message (REG_ECTYPE, "Invalid character class name"); - test_error_code_message (REG_EESCAPE, "Trailing backslash"); - test_error_code_message (REG_ESUBREG, "Invalid back reference"); - test_error_code_message (REG_EBRACK, "Unmatched [ or [^"); - test_error_code_message (REG_EPAREN, "Unmatched ( or \\("); - test_error_code_message (REG_EBRACE, "Unmatched \\{"); - test_error_code_message (REG_BADBR, "Invalid content of \\{\\}"); - test_error_code_message (REG_ERANGE, "Invalid range end"); - test_error_code_message (REG_ESPACE, "Memory exhausted"); - test_error_code_message (REG_BADRPT, "Invalid preceding regular expression"); - test_error_code_message (REG_EEND, "Premature end of regular expression"); - test_error_code_message (REG_ESIZE, "Regular expression too big"); - test_error_code_allocation (REG_ERPAREN, "Unmatched ) or \\)"); -} - - -void -test_posix_interface () -{ - printf ("\nStarting POSIX interface tests.\n"); - t = posix_interface_test; - - test_regcomp (); - test_regexec (); - test_regerror (); - - printf ("\nFinished POSIX interface tests.\n"); -} diff --git a/gnu/lib/regex-0.12/test/psx-interv.c b/gnu/lib/regex-0.12/test/psx-interv.c deleted file mode 100644 index 6725c38d00b8..000000000000 --- a/gnu/lib/regex-0.12/test/psx-interv.c +++ /dev/null @@ -1,140 +0,0 @@ -/* psx-interv.c: test POSIX intervals, both basic and extended. */ - -#include "test.h" - -void -test_intervals () -{ - printf ("\nStarting POSIX interval tests.\n"); - - test_should_match = true; - /* Valid intervals. */ - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,2}b)*")), "abaab"); - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,2}b)*")), "a", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,2}b)*")), - "abaab", 0, 5, 2, 5, -1, -1); - - test_match (BRACES_TO_OPS ("a{0}"), ""); - test_fastmap (BRACES_TO_OPS ("a{0}"), "", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS ("a{0}"), "", 0, 0, -1, -1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS ("a{0}"), "x", 0, 0, -1, -1, -1, -1); - - test_match (BRACES_TO_OPS ("a{0,}"), ""); - test_match (BRACES_TO_OPS ("a{0,}"), "a"); - test_fastmap (BRACES_TO_OPS ("a{0,}"), "a", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS ("a{0,}"), "a", 0, 1, -1, -1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS ("a{0,}"), "xax", 0, 0, -1, -1, -1, -1); - - test_match (BRACES_TO_OPS ("a{1}"), "a"); - test_match (BRACES_TO_OPS ("a{1,}"), "a"); - test_match (BRACES_TO_OPS ("a{1,}"), "aa"); - test_match (BRACES_TO_OPS ("a{0,0}"), ""); - test_match (BRACES_TO_OPS ("a{0,1}"), ""); - test_match (BRACES_TO_OPS ("a{0,1}"), "a"); - test_match (BRACES_TO_OPS ("a{1,3}"), "a"); - test_match (BRACES_TO_OPS ("a{1,3}"), "aa"); - test_match (BRACES_TO_OPS ("a{1,3}"), "aaa"); - TEST_REGISTERS (BRACES_TO_OPS ("a{1,3}"), "aaa", 0, 3, -1, -1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS ("a{1,3}"), "xaaax", 1, 4, -1, -1, -1, -1); - - test_match (BRACES_TO_OPS ("a{0,3}b"), "b"); - test_match (BRACES_TO_OPS ("a{0,3}b"), "aaab"); - test_fastmap (BRACES_TO_OPS ("a{0,3}b"), "ab", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS ("a{0,3}b"), "b", 0, 1, -1, -1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS ("a{0,3}b"), "xbx", 1, 2, -1, -1, -1, -1); - - test_match (BRACES_TO_OPS ("a{1,3}b"), "ab"); - test_match (BRACES_TO_OPS ("a{1,3}b"), "aaab"); - test_match (BRACES_TO_OPS ("ab{1,3}c"), "abbbc"); - - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "b"); - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "ab", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "b", 0, 1, -1, -1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "ab", 0, 2, 0, 1, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){0,3}b")), "xabx", 1, 3, 1, 2, -1, -1); - - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "ab"); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "aaab"); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "aaab", 0, 4, 2, 3, -1, -1); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "xaaabx", 1, 5, 3, 4, -1, -1); - - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){0,3}b")), "aaaab"); - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){0,3}b")), "ab", 0, 0); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){0,3}b")), "aaaab", 0, 5, 4, 4, -1, -1); - - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "b"); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "aaab"); - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "ab", 0, 0); - - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,1}ab")), "aaaab"); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,1}ab")), "aaaab", 0, 5, 0, 3, -1, -1); - - test_match (BRACES_TO_OPS (".{0,3}b"), "b"); - test_match (BRACES_TO_OPS (".{0,3}b"), "ab"); - - test_match (BRACES_TO_OPS ("[a]{0,3}b"), "b"); - test_match (BRACES_TO_OPS ("[a]{0,3}b"), "aaab"); - test_fastmap (BRACES_TO_OPS ("[a]{0,3}b"), "ab", 0, 0); - test_match (BRACES_TO_OPS ("[^a]{0,3}b"), "bcdb"); - test_match (BRACES_TO_OPS ("ab{0,3}c"), "abbbc"); - test_match (BRACES_TO_OPS ("[[:digit:]]{0,3}d"), "123d"); - test_fastmap (BRACES_TO_OPS ("[[:digit:]]{0,3}d"), "0123456789d", 0, 0); - - test_match (BRACES_TO_OPS ("\\*{0,3}a"), "***a"); - test_match (BRACES_TO_OPS (".{0,3}b"), "aaab"); - test_match (BRACES_TO_OPS ("a{0,3}a"), "aaa"); - /* Backtracking. */ - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,})*a")), "a", 0, 0); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,})*a")), "a"); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a{1,})*a")), "a", 0, 1, -1, -1, -1, -1); - - test_fastmap (BRACES_TO_OPS (PARENS_TO_OPS ("(a{2,})*aa")), "aa", 0, 0); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a{2,})*aa")), "aa"); - TEST_REGISTERS (BRACES_TO_OPS (PARENS_TO_OPS ("(a{2,})*aa")), "aa", 0, 2, -1, -1, -1, -1); - - test_match (BRACES_TO_OPS ("a{2}*"), ""); - test_match (BRACES_TO_OPS ("a{2}*"), "aa"); - - test_match (BRACES_TO_OPS ("a{1}*"), ""); - test_match (BRACES_TO_OPS ("a{1}*"), "a"); - test_match (BRACES_TO_OPS ("a{1}*"), "aa"); - - test_match (BRACES_TO_OPS ("a{1}{1}"), "a"); - - test_match (BRACES_TO_OPS ("a{1}{1}{1}"), "a"); - test_match (BRACES_TO_OPS ("a{1}{1}{2}"), "aa"); - - test_match (BRACES_TO_OPS ("a{1}{1}*"), ""); - test_match (BRACES_TO_OPS ("a{1}{1}*"), "a"); - test_match (BRACES_TO_OPS ("a{1}{1}*"), "aa"); - test_match (BRACES_TO_OPS ("a{1}{1}*"), "aaa"); - - test_match (BRACES_TO_OPS ("a{1}{2}"), "aa"); - test_match (BRACES_TO_OPS ("a{2}{1}"), "aa"); - - - test_should_match = false; - - test_match (BRACES_TO_OPS ("a{0}"), "a"); - test_match (BRACES_TO_OPS ("a{0,}"), "b"); - test_match (BRACES_TO_OPS ("a{1}"), ""); - test_match (BRACES_TO_OPS ("a{1}"), "aa"); - test_match (BRACES_TO_OPS ("a{1,}"), ""); - test_match (BRACES_TO_OPS ("a{1,}"), "b"); - test_match (BRACES_TO_OPS ("a{0,0}"), "a"); - test_match (BRACES_TO_OPS ("a{0,1}"), "aa"); - test_match (BRACES_TO_OPS ("a{0,1}"), "b"); - test_match (BRACES_TO_OPS ("a{1,3}"), ""); - test_match (BRACES_TO_OPS ("a{1,3}"), "aaaa"); - test_match (BRACES_TO_OPS ("a{1,3}"), "b"); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a){1,3}b")), "aaaab"); - test_match (BRACES_TO_OPS (PARENS_TO_OPS ("(a*){1,3}b")), "bb"); - test_match (BRACES_TO_OPS ("[a]{0,3}"), "aaaa"); - test_match (BRACES_TO_OPS ("[^a]{0,3}b"), "ab"); - test_match (BRACES_TO_OPS ("ab{0,3}c"), "abababc"); - test_match (BRACES_TO_OPS ("[:alpha:]{0,3}d"), "123d"); - test_match (BRACES_TO_OPS ("\\^{1,3}a"), "a"); - test_match (BRACES_TO_OPS (".{0,3}b"), "aaaab"); - - printf ("\nFinished POSIX interval tests.\n"); -} diff --git a/gnu/lib/regex-0.12/test/regexcpp.sed b/gnu/lib/regex-0.12/test/regexcpp.sed deleted file mode 100644 index 082c1360814f..000000000000 --- a/gnu/lib/regex-0.12/test/regexcpp.sed +++ /dev/null @@ -1,8 +0,0 @@ -/;..*$/s/;/;\ -/g -/{ .*$/s/{/{\ -/g -/ \?[^'] /s/?/?\ -/g -/ : /s/:/:\ -/g diff --git a/gnu/lib/regex-0.12/test/syntax.skel b/gnu/lib/regex-0.12/test/syntax.skel deleted file mode 100644 index a3fbf64c5983..000000000000 --- a/gnu/lib/regex-0.12/test/syntax.skel +++ /dev/null @@ -1,74 +0,0 @@ -/* Print which syntax bits are set. */ - -#include -#include -#include "regex.h" - -/* It's coincidental that these two are currently the same. */ -#define LONGEST_BIT_NAME "RE_UNMATCHED_RIGHT_PAREN_ORD" -#define LAST_BIT RE_UNMATCHED_RIGHT_PAREN_ORD - -/* Sum of above, when printed. Assigned in main. */ -static unsigned longest; - - -static void -test_bit (syntax, bit, name) - reg_syntax_t syntax; - unsigned bit; - char *name; -{ - char padding[100], test_str[100]; - int padding_count; - - sprintf (test_str, "%s (%d=0x%x)", name, bit, bit); - padding_count = longest - strlen (test_str); - - padding[padding_count] = 0; - while (padding_count--) - { - padding[padding_count] = ' '; - } - - printf ("%s%s (%d=0x%x): %c\n", - name, padding, bit, bit, syntax & bit ? 'y' : 'n'); -} - - -/* Macro to abbreviate the constant arguments. */ -#define TEST_BIT(bit) test_bit (syntax, bit, #bit) - -int -main (argc, argv) - int argc; - char *argv[]; -{ - reg_syntax_t syntax; - char syntax_str[1000], test_str[100]; - - switch (argc) - { - case 1: - printf ("Syntax? "); - scanf ("%s", syntax_str); - break; - - case 2: - strcpy (syntax_str, argv[1]); - break; - - default: - fprintf (stderr, "Usage: syntax [syntax].\n"); - exit (1); - } - - sscanf (syntax_str, "%i", &syntax); - - /* Figure out the longest name, so we can align the output nicely. */ - sprintf (test_str, "%s (%d=0x%x)", LONGEST_BIT_NAME, LAST_BIT, LAST_BIT); - longest = strlen (test_str); - - /* [[[replace with bit tests]]] */ - - return 0; -} diff --git a/gnu/lib/regex-0.12/test/test.c b/gnu/lib/regex-0.12/test/test.c deleted file mode 100644 index a8de23ef7429..000000000000 --- a/gnu/lib/regex-0.12/test/test.c +++ /dev/null @@ -1,782 +0,0 @@ -/* test.c: testing routines for regex.c. */ - -#include - -#ifdef STDC_HEADERS -#include -#else -char *malloc (); -char *realloc (); -#endif - -/* Just to be complete, we make both the system V/ANSI and the BSD - versions of the string functions available. */ -#if USG || STDC_HEADERS -#include -#define index strchr -#define rindex strrchr -#define bcmp(s1, s2, len) memcmp ((s1), (s2), (len)) -#define bcopy(from, to, len) memcpy ((to), (from), (len)) -#define bzero(s, len) memset ((s), 0, (len)) -#else -#include -#define strchr index -#define strrchr rindex -#ifndef NEED_MEMORY_H -#define memcmp(s1, s2, n) bcmp ((s1), (s2), (n)) -#define memcpy(to, from, len) bcopy ((from), (to), (len)) -#endif -extern char *strtok (); -extern char *strstr (); -#endif /* not USG or STDC_HEADERS */ - -/* SunOS 4.1 declares memchr in , not . I don't - understand why. */ -#if NEED_MEMORY_H -#include -#endif - -#include "test.h" - -#define BYTEWIDTH 8 - -extern void print_partial_compiled_pattern (); -extern void print_compiled_pattern (); -extern void print_double_string (); - -/* If nonzero, the results of every test are displayed. */ -boolean verbose = false; - -/* If nonzero, don't do register testing. */ -boolean omit_register_tests = true; - -/* Says whether the current test should match or fail to match. */ -boolean test_should_match; - - -static void -set_all_registers (start0, end0, start1, end1, - start2, end2, start3, end3, - start4, end4, start5, end5, - start6, end6, start7, end7, - start8, end8, start9, end9, regs) - - int start0; int end0; int start1; int end1; - int start2; int end2; int start3; int end3; - int start4; int end4; int start5; int end5; - int start6; int end6; int start7; int end7; - int start8; int end8; int start9; int end9; - struct re_registers *regs; - - { - unsigned r; - - regs->start[0] = start0; regs->end[0] = end0; - regs->start[1] = start1; regs->end[1] = end1; - regs->start[2] = start2; regs->end[2] = end2; - regs->start[3] = start3; regs->end[3] = end3; - regs->start[4] = start4; regs->end[4] = end4; - regs->start[5] = start5; regs->end[5] = end5; - regs->start[6] = start6; regs->end[6] = end6; - regs->start[7] = start7; regs->end[7] = end7; - regs->start[8] = start8; regs->end[8] = end8; - regs->start[9] = start9; regs->end[9] = end9; - for (r = 10; r < regs->num_regs; r++) - { - regs->start[r] = -1; - regs->end[r] = -1; - } - } - - - -/* Return the concatenation of S1 and S2. This would be a prime place - to use varargs. */ - -char * -concat (s1, s2) - char *s1; - char *s2; -{ - char *answer = xmalloc (strlen (s1) + strlen (s2) + 1); - - strcpy (answer, s1); - strcat (answer, s2); - - return answer; -} - - -#define OK_TO_SEARCH (nonconst_buf.fastmap_accurate && (str1 || str2)) - -/* We ignore the `can_be_null' argument. Should just be removed. */ - -void -general_test (pattern_should_be_valid, match_whole_string, - pat, str1, str2, start, range, end, correct_fastmap, - correct_regs, can_be_null) - unsigned pattern_should_be_valid; - unsigned match_whole_string; - const char *pat; - char *str1, *str2; - int start, range, end; - char *correct_fastmap; - struct re_registers *correct_regs; - int can_be_null; -{ - struct re_pattern_buffer nonconst_buf; - struct re_pattern_buffer old_buf; - struct re_registers regs; - const char *r; - char fastmap[1 << BYTEWIDTH]; - unsigned *regs_correct = NULL; - unsigned all_regs_correct = 1; - boolean fastmap_internal_error = false; - unsigned match = 0; - unsigned match_1 = 0; - unsigned match_2 = 0; - unsigned invalid_pattern = 0; - boolean internal_error_1 = false; - boolean internal_error_2 = false; - - - nonconst_buf.allocated = 8; - nonconst_buf.buffer = xmalloc (nonconst_buf.allocated); - nonconst_buf.fastmap = fastmap; - nonconst_buf.translate = 0; - - assert (pat != NULL); - r = re_compile_pattern (pat, strlen (pat), &nonconst_buf); - - /* Kludge: if we are doing POSIX testing, we really should have - called regcomp, not re_compile_pattern. As it happens, the only - way in which it matters is that re_compile_pattern sets the - newline/anchor field for matching (part of what happens when - REG_NEWLINE is given to regcomp). We have to undo that for POSIX - matching. */ - if (t == posix_basic_test || t == posix_extended_test) - nonconst_buf.newline_anchor = 0; - - invalid_pattern = r != NULL; - - if (!r) - { - int r; - - if (!pattern_should_be_valid) - printf ("\nShould have been an invalid pattern but wasn't:\n"); - else - { - fastmap_internal_error = (re_compile_fastmap (&nonconst_buf) == -2); - - if (correct_fastmap) - nonconst_buf.fastmap_accurate = - memcmp (nonconst_buf.fastmap, correct_fastmap, 1 << BYTEWIDTH) - == 0; - - if (OK_TO_SEARCH) - { - old_buf = nonconst_buf; - old_buf.buffer = (unsigned char *) xmalloc (nonconst_buf.used); - memcpy (old_buf.buffer, nonconst_buf.buffer, nonconst_buf.used); - - /* If only one string is null, call re_match or re_search, - which is what the user would probably do. */ - if (str1 == NULL && str2 != NULL - || str2 == NULL && str1 != NULL) - { - char *the_str = str1 == NULL ? str2 : str1; - - match_1 - = match_whole_string - ? (r = re_match (&nonconst_buf, the_str, - strlen (the_str), start, ®s)) - == strlen (the_str) - : (r = re_search (&nonconst_buf, - the_str, strlen (the_str), - start, range, ®s)) - >= 0; - - if (r == -2) - internal_error_1 = true; - } - else - match_1 = 1; - - /* Also call with re_match_2 or re_search_2, as they might - do this. (Also can check calling with either string1 - or string2 or both null.) */ - if (match_whole_string) - { - r = re_match_2 (&nonconst_buf, - str1, SAFE_STRLEN (str1), - str2, SAFE_STRLEN (str2), - start, ®s, end); - match_2 = r == SAFE_STRLEN (str1) + SAFE_STRLEN (str2); - } - else - { - r = re_search_2 (&nonconst_buf, - str1, SAFE_STRLEN (str1), - str2, SAFE_STRLEN (str2), - start, range, ®s, end); - match_2 = r >= 0; - } - - if (r == -2) - internal_error_2 = true; - - match = match_1 & match_2; - - if (correct_regs) - { - unsigned reg; - if (regs_correct != NULL) - free (regs_correct); - - regs_correct - = (unsigned *) xmalloc (regs.num_regs * sizeof (unsigned)); - - for (reg = 0; - reg < regs.num_regs && reg < correct_regs->num_regs; - reg++) - { - regs_correct[reg] - = (regs.start[reg] == correct_regs->start[reg] - && regs.end[reg] == correct_regs->end[reg]) -#ifdef EMPTY_REGS_CONFUSED - /* There is confusion in the standard about - the registers in some patterns which can - match either the empty string or not match. - For example, in `((a*))*' against the empty - string, the two registers can either match - the empty string (be 0/0), or not match - (because of the outer *) (be -1/-1). (Or - one can do one and one can do the other.) */ - || (regs.start[reg] == -1 && regs.end[reg] == -1 - && correct_regs->start[reg] - == correct_regs->end[reg]) -#endif - ; - - all_regs_correct &= regs_correct[reg]; - } - } - } /* OK_TO_SEARCH */ - } - } - - if (fastmap_internal_error) - printf ("\n\nInternal error in re_compile_fastmap:"); - - if (internal_error_1) - { - if (!fastmap_internal_error) - printf ("\n"); - - printf ("\nInternal error in re_match or re_search:"); - } - - if (internal_error_2) - { - if (!internal_error_1) - printf ("\n"); - - printf ("\nInternal error in re_match_2 or re_search_2:"); - } - - if ((OK_TO_SEARCH && ((match && !test_should_match) - || (!match && test_should_match)) - || (correct_regs && !all_regs_correct)) - || !nonconst_buf.fastmap_accurate - || invalid_pattern - || !pattern_should_be_valid - || internal_error_1 || internal_error_2 - || verbose) - { - if (OK_TO_SEARCH && match && !test_should_match) - { - printf ("\n\nMatched but shouldn't have:\n"); - if (match_1) - printf ("The single match/search succeeded.\n"); - - if (match_2) - printf ("The double match/search succeeded.\n"); - } - else if (OK_TO_SEARCH && !match && test_should_match) - { - printf ("\n\nDidn't match but should have:\n"); - if (!match_1) - printf ("The single match/search failed.\n"); - - if (!match_2) - printf ("The double match/search failed.\n"); - } - else if (invalid_pattern && pattern_should_be_valid) - printf ("\n\nInvalid pattern (%s):\n", r); - else if (!nonconst_buf.fastmap_accurate && pattern_should_be_valid) - printf ("\n\nIncorrect fastmap:\n"); - else if (OK_TO_SEARCH && correct_regs && !all_regs_correct) - printf ("\n\nNot all registers were correct:\n"); - else if (verbose) - printf ("\n\nTest was OK:\n"); - - - if ((!(invalid_pattern && !pattern_should_be_valid)) || verbose) - printf (" Pattern: `%s'.\n", pat); - - if (pattern_should_be_valid || verbose - || internal_error_1 || internal_error_2) - { - printf(" Strings: "); - printf ("`%s' and ", str1 == NULL ? "NULL" : str1); - printf ("`%s'.\n", str2 == NULL ? "NULL" : str2); - - if ((OK_TO_SEARCH || verbose || internal_error_1 || internal_error_2) - && !invalid_pattern) - { - if (memcmp (old_buf.buffer, nonconst_buf.buffer, - nonconst_buf.used) != 0 - && !invalid_pattern) - { - printf(" (%s)\n", r ? r : "Valid regular expression"); - printf ("\n Compiled pattern before matching: "); - print_compiled_pattern (&old_buf); - printf ("\n Compiled pattern after matching: "); - } - else - printf ("\n Compiled pattern: "); - - print_compiled_pattern (&nonconst_buf); - } - - if (correct_fastmap && (!nonconst_buf.fastmap_accurate || verbose)) - { - printf ("\n The fastmap should have been: "); - print_fastmap (correct_fastmap); - - printf ("\n Fastmap: "); - print_fastmap (fastmap); - - printf ("\n Compiled pattern before matching: "); - print_compiled_pattern (&nonconst_buf); - } - - if ((!all_regs_correct || verbose) && correct_regs) - { - unsigned this_reg; - printf ("\n Incorrect registers:"); - - for (this_reg = 0; this_reg < regs.num_regs; this_reg++) - { - if (!regs_correct[this_reg]) - { - printf ("\n Register %d's start was %2d. ", this_reg, - regs.start[this_reg]); - printf ("\tIt should have been %d.\n", - correct_regs->start[this_reg]); - printf (" Register %d's end was %2d. ", this_reg, - regs.end[this_reg]); - printf ("\tIt should have been %d.\n", - correct_regs->end[this_reg]); - } - } - } - } - } - - if (nonconst_buf.buffer != NULL) - free (nonconst_buf.buffer); - - if (OK_TO_SEARCH) - { - free (old_buf.buffer); - - if (correct_regs) - free (regs_correct); - - } - - nonconst_buf.buffer = old_buf.buffer = NULL; - regs_correct = NULL; - regs.start = regs.end = NULL; - -} /* general_test */ - - -void -test_search_return (match_start_wanted, pattern, string) - int match_start_wanted; - const char *pattern; - char *string; -{ - struct re_pattern_buffer buf; - char fastmap[1 << BYTEWIDTH]; - const char *compile_return; - int match_start; - static num_times_called = 0; - - num_times_called++; - buf.allocated = 1; - buf.buffer = xmalloc (buf.allocated); - - assert (pattern != NULL); - buf.translate = 0; - compile_return = re_compile_pattern (pattern, strlen (pattern), &buf); - - if (compile_return) - { - printf ("\n\nInvalid pattern in test_match_start:\n"); - printf ("%s\n", compile_return); - } - else - { - buf.fastmap = fastmap; - match_start = re_search (&buf, string, strlen (string), - 0, strlen (string), 0); - - if (match_start != match_start_wanted) - printf ("\nWanted search to start at %d but started at %d.\n", - match_start, match_start_wanted); - } - free (buf.buffer); - buf.buffer = NULL; -} - - -#define SET_FASTMAP() \ - { \ - unsigned this_char; \ - \ - memset (correct_fastmap, invert, (1 << BYTEWIDTH)); \ - \ - for (this_char = 0; this_char < strlen (fastmap_string); this_char++)\ - correct_fastmap[fastmap_string[this_char]] = !invert; \ - correct_fastmap['\n'] = match_newline; \ - } - - -void -test_fastmap (pat, fastmap_string, invert, match_newline) - const char *pat; - char *fastmap_string; - unsigned invert; - unsigned match_newline; -{ - char correct_fastmap[(1 << BYTEWIDTH)]; - - SET_FASTMAP (); - general_test (1, 0, pat, NULL, NULL, -1, 0, -1, correct_fastmap, 0, -1); -} - - -void -test_fastmap_search (pat, str, fastmap_string, invert, match_newline, - can_be_null, start0, end0) - const char *pat; - char *str; - char *fastmap_string; - unsigned invert; - unsigned match_newline; - int can_be_null; - int start0; - int end0; -{ - char correct_fastmap[(1 << BYTEWIDTH)]; - struct re_registers correct_regs; - - correct_regs.num_regs = RE_NREGS; - correct_regs.start = (int *) xmalloc (RE_NREGS * sizeof (int)); - correct_regs.end = (int *) xmalloc (RE_NREGS * sizeof (int)); - - set_all_registers (start0, end0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, &correct_regs); - SET_FASTMAP (); - general_test (1, 0, pat, str, NULL, 0, SAFE_STRLEN (str), SAFE_STRLEN (str), - correct_fastmap, &correct_regs, can_be_null); - - free (correct_regs.start); - free (correct_regs.end); -} - - - - -void -test_all_registers (pat, str1, str2, - start0, end0, start1, end1, - start2, end2, start3, end3, - start4, end4, start5, end5, - start6, end6, start7, end7, - start8, end8, start9, end9) - char *pat; char *str1; char *str2; - int start0; int end0; int start1; int end1; - int start2; int end2; int start3; int end3; - int start4; int end4; int start5; int end5; - int start6; int end6; int start7; int end7; - int start8; int end8; int start9; int end9; -{ - struct re_registers correct_regs; - - if (omit_register_tests) return; - - correct_regs.num_regs = RE_NREGS; - correct_regs.start = (int *) xmalloc (RE_NREGS * sizeof (int)); - correct_regs.end = (int *) xmalloc (RE_NREGS * sizeof (int)); - - set_all_registers (start0, end0, start1, end1, start2, end2, start3, end3, - start4, end4, start5, end5, start6, end6, start7, end7, - start8, end8, start9, end9, &correct_regs); - - general_test (1, 0, pat, str1, str2, 0, - SAFE_STRLEN (str1) + SAFE_STRLEN (str2), - SAFE_STRLEN (str1) + SAFE_STRLEN (str2), - NULL, &correct_regs, -1); - - free (correct_regs.start); - free (correct_regs.end); -} - - -void -invalid_pattern (error_code_expected, pattern) - int error_code_expected; - char *pattern; -{ - regex_t pattern_buffer; - int cflags - = re_syntax_options == RE_SYNTAX_POSIX_EXTENDED - || re_syntax_options == RE_SYNTAX_POSIX_MINIMAL_EXTENDED - ? REG_EXTENDED : 0; - - test_compile (0, error_code_expected, pattern, &pattern_buffer, cflags); -} - - -void -valid_pattern (pattern) - char *pattern; -{ - regex_t pattern_buffer; - int cflags - = re_syntax_options == RE_SYNTAX_POSIX_EXTENDED - || re_syntax_options == RE_SYNTAX_POSIX_MINIMAL_EXTENDED - ? REG_EXTENDED : 0; - - test_compile (1, 0, pattern, &pattern_buffer, cflags); -} - - -char * -delimiters_to_ops (source, left_delimiter, right_delimiter) - char *source; - char left_delimiter; - char right_delimiter; -{ - static char *answer = NULL; - char *tmp = NULL; - boolean double_size = false; - unsigned source_char; - unsigned answer_char = 0; - - assert (source != NULL); - - switch (left_delimiter) - { - case '(': if (!(re_syntax_options & RE_NO_BK_PARENS)) - double_size = true; - break; - case '{': if (!(re_syntax_options & RE_NO_BK_BRACES)) - double_size = true; - break; - default: printf ("Found strange delimiter %c in delimiter_to_ops.\n", - left_delimiter); - printf ("The source was `%s'\n", source); - exit (0); - } - - if (answer == source) - { - tmp = (char *) xmalloc (strlen (source) + 1); - strcpy (tmp, source); - source = tmp; - } - - if (answer) - { - free (answer); - answer = NULL; - } - - answer = (char *) xmalloc ((double_size - ? strlen (source) << 1 - : strlen (source)) - + 1); - if (!double_size) - strcpy (answer, source); - else - { - for (source_char = 0; source_char < strlen (source); source_char++) - { - if (source[source_char] == left_delimiter - || source[source_char] == right_delimiter) - answer[answer_char++] = '\\'; - - answer[answer_char++] = source[source_char]; - } - answer[answer_char] = 0; - } - - return answer; -} - - -void -print_pattern_info (pattern, pattern_buffer_ptr) - const char *pattern; - regex_t *pattern_buffer_ptr; -{ - printf (" Pattern: `%s'.\n", pattern); - printf (" Compiled pattern: "); - print_compiled_pattern (pattern_buffer_ptr); -} - - -void -valid_nonposix_pattern (pattern) - char *pattern; -{ - struct re_pattern_buffer nonconst_buf; - - nonconst_buf.allocated = 0; - nonconst_buf.buffer = NULL; - nonconst_buf.translate = NULL; - - assert (pattern != NULL); - - if (re_compile_pattern (pattern, strlen (pattern), &nonconst_buf)) - { - printf ("Couldn't compile the pattern.\n"); - print_pattern_info (pattern, &nonconst_buf); - } -} - - -void -compile_and_print_pattern (pattern) - char *pattern; -{ - struct re_pattern_buffer nonconst_buf; - - nonconst_buf.allocated = 0; - nonconst_buf.buffer = NULL; - - if (re_compile_pattern (pattern, strlen (pattern), &nonconst_buf)) - printf ("Couldn't compile the pattern.\n"); - - print_pattern_info (pattern, &nonconst_buf); -} - - -void -test_case_fold (pattern, string) - const char *pattern; - char* string; -{ - struct re_pattern_buffer nonconst_buf; - const char *ret; - - init_pattern_buffer (&nonconst_buf); - nonconst_buf.translate = upcase; - - assert (pattern != NULL); - ret = re_compile_pattern (pattern, strlen (pattern), &nonconst_buf); - - if (ret) - { - printf ("\nShould have been a valid pattern but wasn't.\n"); - print_pattern_info (pattern, &nonconst_buf); - } - else - { - if (test_should_match - && re_match (&nonconst_buf, string, strlen (string), 0, 0) - != strlen (string)) - { - printf ("Match failed for case fold.\n"); - printf (" Pattern: `%s'.\n", pattern); - printf (" String: `%s'.\n", string == NULL ? "NULL" : string); - } - } -} - - -void -test_match_n_times (n, pattern, string) - unsigned n; - char* pattern; - char* string; -{ - struct re_pattern_buffer buf; - const char *r; - unsigned match = 0; - unsigned this_match; - - buf.allocated = 0; - buf.buffer = NULL; - buf.translate = 0; - - assert (pattern != NULL); - - r = re_compile_pattern (pattern, strlen (pattern), &buf); - if (r) - { - printf ("Didn't compile.\n"); - printf (" Pattern: %s.\n", pattern); - } - else - { - for (this_match = 1; this_match <= n; this_match++) - match = (re_match (&buf, string, strlen (string), - 0, 0) - == strlen (string)); - - if (match && !test_should_match) - printf ("\n\nMatched but shouldn't have:\n"); - else if (!match && test_should_match) - printf ("\n\nDidn't match but should have:\n"); - - if ((match && !test_should_match) || (!match && test_should_match)) - { - printf(" The string to match was: "); - if (string) - printf ("`%s' and ", string); - else - printf ("`'"); - - printf (" Pattern: %s.\n", pattern); - printf (" Compiled pattern: %s.\n", pattern); - print_compiled_pattern (&buf); - } - } -} - - -void -test_match_2 (pat, str1, str2) - const char *pat; - char *str1; - char *str2; -{ - general_test (1, 1, pat, str1, str2, 0, 1, - SAFE_STRLEN (str1) + SAFE_STRLEN (str2), NULL, 0, -1); -} - -void -test_match (pat, str) - const char *pat; - char *str; -{ - test_match_2 (pat, str, NULL); - test_match_2 (pat, NULL, str); -} diff --git a/gnu/lib/regex-0.12/test/test.h b/gnu/lib/regex-0.12/test/test.h deleted file mode 100644 index fb67126547cc..000000000000 --- a/gnu/lib/regex-0.12/test/test.h +++ /dev/null @@ -1,141 +0,0 @@ -/* test.h: for Regex testing. */ - -#ifndef TEST_H -#define TEST_H - -#include -#include - -#include -#include "regex.h" - - -/* A strlen that works even on a null pointer. */ -#define SAFE_STRLEN(s) (s == NULL ? 0 : strlen (s)) - -typedef enum { false = 0, true = 1 } boolean; - -extern boolean test_should_match; -extern boolean omit_register_tests; -extern void *xmalloc (); - -/* Defined in upcase.c. */ -extern char upcase[]; - -typedef enum -{ - all_test, - other_test, - posix_basic_test, - posix_extended_test, - posix_interface_test, - regress_test -} test_type; - -extern test_type t; - - -#if __STDC__ - -extern char *concat (char *, char *); - -extern void general_test (unsigned pattern_should_be_valid, - unsigned match_whole_string, - const char *pat, char *str1, char *str2, - int start, int range, int end, - char *correct_fastmap, - struct re_registers *correct_regs, int can_be_null); - - -extern void init_pattern_buffer (regex_t *pattern_buffer_ptr); - -extern void test_compile (unsigned valid_pattern, int error_code_expected, - const char *pattern, regex_t *pattern_buffer_ptr, - int cflags); - -extern char *delimiter_to_ops (char *source, char left_delimiter, - char right_delimiter); - - -extern void test_search_return (int, const char *, char *); - -extern void test_berk_search (const char *pattern, char *string); - -extern void test_fastmap (const char *pat, char *fastmap_string, unsigned invert, - unsigned match_newline); - -extern void test_fastmap_search (const char *pat, char *str, char *fastmap_string, - unsigned invert, unsigned match_newline, - int can_be_null, int start0, int end0); - -extern void test_all_registers (char *pat, char *str1, char *str2, - int start0, int end0, int start1, int end1, - int start2, int end2, int start3, int end3, - int start4, int end4, int start5, int end5, - int start6, int end6, int start7, int end7, - int start8, int end8, int start9, int end9); - -extern void print_pattern_info (const char *pattern, regex_t *pattern_buffer_ptr); -extern void compile_and_print_pattern (char *pattern); - -extern void test_case_fold (const char *pattern, char* string); - -extern void test_posix_generic (); - -extern void test_grouping (); - -extern void invalid_pattern (int error_code_expected, char *pattern); -extern void valid_nonposix_pattern (char *pattern); -extern void valid_pattern (char *pattern); - -extern void test_match_2 (const char *pat, char *str1, char *str2); -extern void test_match (const char *pat, char *str); - -#endif /* __STDC__ */ - - -#define TEST_REGISTERS_2(pat, str1, str2, start0, end0, start1, end1, start2, end2)\ - if (!omit_register_tests) \ - test_all_registers (pat, str1, str2, start0, end0, start1, end1, \ - start2, end2, -1, -1, -1, -1, -1, -1, -1, -1,\ - -1, -1, -1, -1, -1, -1) \ - - -#define TEST_REGISTERS(pat, str, start0, end0, start1, end1, start2, end2) \ - TEST_REGISTERS_2 (pat, str, NULL, start0, end0, start1, end1, start2, end2)\ - -#define BRACES_TO_OPS(string) ((char *) delimiters_to_ops (string, '{', '}')) -#define PARENS_TO_OPS(string) ((char *) delimiters_to_ops (string, '(', ')')) - -#define INVALID_PATTERN(pat) \ - general_test (0, 0, pat, NULL, NULL, -1, 0, -1, NULL, 0, -1) - - -#define MATCH_SELF(p) test_match (p, p) - -#define TEST_POSITIONED_MATCH(pat, str, start) \ - general_test (1, 0, pat, str, NULL, start, 1, SAFE_STRLEN (str), \ - NULL, 0, -1) - -#define TEST_TRUNCATED_MATCH(pat, str, end) \ - general_test (1, 0, pat, str, NULL, 0, 1, end, NULL, 0, -1) - -#define TEST_SEARCH_2(pat, str1, str2, start, range, one_past_end) \ - general_test (1, 0, pat, str1, str2, start, range, one_past_end, \ - NULL, 0, -1) - -#define TEST_SEARCH(pat, str, start, range) \ - { \ - TEST_SEARCH_2 (pat, str, NULL, start, range, SAFE_STRLEN (str)); \ - TEST_SEARCH_2 (pat, NULL, str, start, range, SAFE_STRLEN (str)); \ - } - -#endif /* TEST_H */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/regex-0.12/test/tregress.c b/gnu/lib/regex-0.12/test/tregress.c deleted file mode 100644 index 7858cac1502b..000000000000 --- a/gnu/lib/regex-0.12/test/tregress.c +++ /dev/null @@ -1,464 +0,0 @@ -/* tregress.c: reported bugs. The `t' just makes the filename not have - a common prefix with `regex.c', so completion works better. */ - -#include "test.h" - - -boolean pause_at_error = true; - -char * -itoa (i) - int i; -{ - char *a = xmalloc (21); /* sign + 19 digits (enough for 64 bits) + null */ - - sprintf (a, "%d", i); - return a; -} - - -static void -simple_fail (routine, pat, buf, str, ret) - const char *routine; - const char *pat; - struct re_pattern_buffer *buf; - const char *str; - char *ret; -{ - fprintf (stderr, "Failed %s (return = %s).\n", routine, ret); - if (str && *str) fprintf (stderr, " String = %s\n", str); - fprintf (stderr, " Pattern = %s\n", pat); - print_compiled_pattern (buf); - - if (pause_at_error) - { - fprintf (stderr, "RET to continue: "); - (void) getchar (); - } -} - - -/* Abbreviate the most common calls. */ - -static void -simple_compile (pat, buf) - const char *pat; - struct re_pattern_buffer *buf; -{ - const char *ret = re_compile_pattern (pat, strlen (pat), buf); - - if (ret != NULL) simple_fail ("compile", pat, buf, NULL, ret); -} - - -static void -simple_fastmap (pat) - const char *pat; -{ - struct re_pattern_buffer buf; - char fastmap[256]; - int ret; - - buf.allocated = 0; - buf.buffer = buf.translate = NULL; - buf.fastmap = fastmap; - - simple_compile (pat, &buf); - - ret = re_compile_fastmap (&buf); - - if (ret != 0) simple_fail ("fastmap compile", pat, &buf, NULL, itoa (ret)); -} - - -#define SIMPLE_MATCH(pat, str) do_match (pat, str, strlen (str)) -#define SIMPLE_NONMATCH(pat, str) do_match (pat, str, -1) - -static void -do_match (pat, str, expected) - const char *pat, *str; - int expected; -{ - int ret; - unsigned len; - struct re_pattern_buffer buf; - - buf.allocated = 0; - buf.buffer = buf.translate = buf.fastmap = NULL; - - simple_compile (pat, &buf); - - len = strlen (str); - - ret = re_match_2 (&buf, NULL, 0, str, len, 0, NULL, len); - - if (ret != expected) simple_fail ("match", pat, &buf, str, itoa (ret)); -} - - -static void -simple_search (pat, str, correct_startpos) - const char *pat, *str; - int correct_startpos; -{ - int ret; - unsigned len; - struct re_pattern_buffer buf; - - buf.allocated = 0; - buf.buffer = buf.translate = buf.fastmap = NULL; - - simple_compile (pat, &buf); - - len = strlen (str); - - ret = re_search_2 (&buf, NULL, 0, str, len, 0, len, NULL, len); - - if (ret != correct_startpos) - simple_fail ("match", pat, &buf, str, itoa (ret)); -} - -/* Past bugs people have reported. */ - -void -test_regress () -{ - extern char upcase[]; - struct re_pattern_buffer buf; - unsigned len; - struct re_registers regs; - int ret; - char *fastmap = xmalloc (256); - - buf.translate = NULL; - buf.fastmap = NULL; - buf.allocated = 0; - buf.buffer = NULL; - - printf ("\nStarting regression tests.\n"); - t = regress_test; - - test_should_match = true; - re_set_syntax (RE_SYNTAX_EMACS); - - /* enami@sys.ptg.sony.co.jp 10 Nov 92 15:19:02 JST */ - buf.translate = upcase; - SIMPLE_MATCH ("[A-[]", "A"); - buf.translate = NULL; - - /* meyering@cs.utexas.edu Nov 6 22:34:41 1992 */ - simple_search ("\\w+", "a", 0); - - /* jimb@occs.cs.oberlin.edu 10 Sep 92 00:42:33 */ - buf.translate = upcase; - SIMPLE_MATCH ("[\001-\377]", "\001"); - SIMPLE_MATCH ("[\001-\377]", "a"); - SIMPLE_MATCH ("[\001-\377]", "\377"); - buf.translate = NULL; - - /* mike@skinner.cs.uoregon.edu 1 Sep 92 01:45:22 */ - SIMPLE_MATCH ("^^$", "^"); - - /* pclink@qld.tne.oz.au Sep 7 22:42:36 1992 */ - re_set_syntax (RE_INTERVALS); - SIMPLE_MATCH ("^a\\{3\\}$", "aaa"); - SIMPLE_NONMATCH ("^a\\{3\\}$", "aa"); - re_set_syntax (RE_SYNTAX_EMACS); - - /* pclink@qld.tne.oz.au, 31 Aug 92. (conjecture) */ - re_set_syntax (RE_INTERVALS); - simple_search ("a\\{1,3\\}b", "aaab", 0); - simple_search ("a\\{1,3\\}b", "aaaab", 1); - re_set_syntax (RE_SYNTAX_EMACS); - - /* trq@dionysos.thphys.ox.ac.uk, 31 Aug 92. (simplified) */ - simple_fastmap ("^.*\n[ ]*"); - - /* wind!greg@plains.NoDak.edu, 25 Aug 92. (simplified) */ - re_set_syntax (RE_INTERVALS); - SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}", "xN0000"); - SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}$", "systemxN0000"); - SIMPLE_MATCH ("\\([a-zA-Z]*\\).\\{5\\}$", "systemxN0000"); - re_set_syntax (RE_SYNTAX_EMACS); - - /* jimb, 18 Aug 92. Don't use \000, so `strlen' (in our testing - routines) will work. (This still tickles the bug jimb reported.) */ - SIMPLE_MATCH ("[\001-\377]", "\001"); - SIMPLE_MATCH ("[\001-\377]", "a"); - SIMPLE_MATCH ("[\001-\377]", "\377"); - - /* jimb, 13 Aug 92. */ - SIMPLE_MATCH ("[\001-\177]", "\177"); - - /* Tests based on bwoelfel's below. */ - SIMPLE_MATCH ("\\(a\\|ab\\)*", "aab"); - SIMPLE_MATCH ("\\(a\\|ab\\)+", "aab"); - SIMPLE_MATCH ("\\(a*\\|ab\\)+", "aab"); - SIMPLE_MATCH ("\\(a+\\|ab\\)+", "aab"); - SIMPLE_MATCH ("\\(a?\\|ab\\)+", "aab"); - - /* bwoelfel@widget.seas.upenn.edu, 25 Jul 92. */ - SIMPLE_MATCH ("^\\([ab]+\\|bc\\)+", "abc"); - - /* jla, 3 Jul 92. Core dump in re_search_2. */ - buf.fastmap = fastmap; - buf.translate = upcase; -#define DATEDUMP_PATTERN " *[0-9]*:" - if (re_compile_pattern (DATEDUMP_PATTERN, strlen (DATEDUMP_PATTERN), &buf) - != NULL) - printf ("date dump compile failed.\n"); - regs.num_regs = 0; - regs.start = regs.end = NULL; - if (re_search_2 (&buf, NULL, 0, "Thu Jul 2 18:34:18 1992", - 24, 3, 21, ®s, 24) != 10) - printf ("date dump search failed.\n"); - buf.fastmap = 0; - buf.translate = 0; - - - /* rms, 4 Jul 1992. Pattern is much slower in Emacs 19. Fastmap - should be only a backslash. */ -#define BEGINEND_PATTERN "\\(\\\\begin\\s *{\\)\\|\\(\\\\end\\s *{\\)" - test_fastmap (BEGINEND_PATTERN, "\\", false, 0); - - - /* kaoru@is.s.u-tokyo.ac.jp, 27 Jun 1992. Code for [a-z] (in regex.c) - should translate the whole set. */ - buf.translate = upcase; -#define CASE_SET_PATTERN "[ -`]" - if (re_compile_pattern (CASE_SET_PATTERN, strlen (CASE_SET_PATTERN), &buf) - != NULL) - printf ("case set compile failed.\n"); - if (re_match_2 (&buf, "K", 1, "", 0, 0, NULL, 1) != 1) - printf ("case set match failed.\n"); - -#define CASE_SET_PATTERN2 "[`-|]" - if (re_compile_pattern (CASE_SET_PATTERN2, strlen (CASE_SET_PATTERN2), &buf) - != NULL) - printf ("case set2 compile failed.\n"); - if (re_match_2 (&buf, "K", 1, "", 0, 0, NULL, 1) != 1) - printf ("case set2 match failed.\n"); - - buf.translate = NULL; - - - /* jimb, 27 Jun 92. Problems with gaps in the string. */ -#define GAP_PATTERN "x.*y.*z" - if (re_compile_pattern (GAP_PATTERN, strlen (GAP_PATTERN), &buf) != NULL) - printf ("gap didn't compile.\n"); - if (re_match_2 (&buf, "x-", 2, "y-z-", 4, 0, NULL, 6) != 5) - printf ("gap match failed.\n"); - - - /* jimb, 19 Jun 92. Since `beginning of word' matches at the - beginning of the string, then searching ought to find it there. - If `re_compile_fastmap' is not called, then it works ok. */ - buf.fastmap = fastmap; -#define BOW_BEG_PATTERN "\\<" - if (re_compile_pattern (BOW_BEG_PATTERN, strlen (BOW_BEG_PATTERN), &buf) - != NULL) - printf ("begword-begstring didn't compile.\n"); - if (re_search (&buf, "foo", 3, 0, 3, NULL) != 0) - printf ("begword-begstring search failed.\n"); - - /* Same bug report, different null-matching pattern. */ -#define EMPTY_ANCHOR_PATTERN "^$" - if (re_compile_pattern (EMPTY_ANCHOR_PATTERN, strlen (EMPTY_ANCHOR_PATTERN), - &buf) != NULL) - printf ("empty anchor didn't compile.\n"); - if (re_search (&buf, "foo\n\nbar", 8, 0, 8, NULL) != 4) - printf ("empty anchor search failed.\n"); - - /* jimb@occs.cs.oberlin.edu, 21 Apr 92. After we first allocate - registers for a particular re_pattern_buffer, we might have to - reallocate more registers on subsequent calls -- and we should be - reusing the same memory. */ -#define ALLOC_REG_PATTERN "\\(abc\\)" - free (buf.fastmap); - buf.fastmap = 0; - if (re_compile_pattern (ALLOC_REG_PATTERN, strlen (ALLOC_REG_PATTERN), &buf) - != NULL) - printf ("register allocation didn't compile.\n"); - if (re_match (&buf, "abc", 3, 0, ®s) != 3) - printf ("register allocation didn't match.\n"); - if (regs.start[1] != 0 || regs.end[1] != 3) - printf ("register allocation reg #1 wrong.\n"); - - { - int *old_regstart = regs.start; - int *old_regend = regs.end; - - if (re_match (&buf, "abc", 3, 0, ®s) != 3) - printf ("register reallocation didn't match.\n"); - if (regs.start[1] != 0 || regs.end[1] != 3 - || old_regstart[1] != 0 || old_regend[1] != 3 - || regs.start != old_regstart || regs.end != old_regend) - printf ("register reallocation registers wrong.\n"); - } - - /* jskudlarek@std.MENTORG.COM, 21 Apr 92 (string-match). */ -#define JSKUD_PATTERN "[^/]+\\(/[^/.]+\\)?/[0-9]+$" - if (re_compile_pattern (JSKUD_PATTERN, strlen (JSKUD_PATTERN), &buf) != NULL) - printf ("jskud test didn't compile.\n"); - if (re_search (&buf, "a/1", 3, 0, 3, ®s) != 0) - printf ("jskud test didn't match.\n"); - if (regs.start[1] != -1 || regs.end[1] != -1) - printf ("jskud test, reg #1 wrong.\n"); - - /* jla's bug (with string-match), 5 Feb 92. */ - TEST_SEARCH ("\\`[ \t\n]*", "jla@challenger (Joseph Arceneaux)", 0, 100); - - /* jwz@lucid.com, 8 March 1992 (re-search-forward). (His is the - second.) These are not supposed to match. */ -#if 0 - /* This one fails quickly, because we can change the maybe_pop_jump - from the + to a pop_failure_pop, because of the c's. */ - TEST_SEARCH ("^\\(To\\|CC\\):\\([^c]*\\)+co", -"To: hbs%titanic@lucid.com (Harlan Sexton)\n\ -Cc: eb@thalidomide, jlm@thalidomide\n\ -Subject: Re: so is this really as horrible an idea as it seems to me?\n\ -In-Reply-To: Harlan Sexton's message of Sun 8-Mar-92 11:00:06 PST <9203081900.AA24794@titanic.lucid>\n\ -References: <9203080736.AA05869@thalidomide.lucid>\n\ - <9203081900.AA24794@titanic.lucid>", 0, 5000); - - /* This one takes a long, long time to complete, because we have to - keep the failure points around because we might backtrack. */ - TEST_SEARCH ("^\\(To\\|CC\\):\\(.*\n.*\\)+co", - /* "X-Windows: The joke that kills.\n\ -FCC: /u/jwz/VM/inbox\n\ -From: Jamie Zawinski \n\ */ -"To: hbs%titanic@lucid.com (Harlan Sexton)\n\ -Cc: eb@thalidomide, jlm@thalidomide\n\ -Subject: Re: so is this really as horrible an idea as it seems to me?\n\ -In-Reply-To: Harlan Sexton's message of Sun 8-Mar-92 11:00:06 PST <9203081900.AA24794@titanic.lucid>\n\ -References: <9203080736.AA05869@thalidomide.lucid>\n\ - <9203081900.AA24794@titanic.lucid>", 0, 5000); -#endif /* 0 [failed searches] */ - - - /* macrakis' bugs. */ - buf.translate = upcase; /* message of 24 Jan 91 */ - if (re_compile_pattern ("[!-`]", 5, &buf) != NULL) - printf ("Range test didn't compile.\n"); - if (re_match (&buf, "A", 1, 0, NULL) != 1) - printf ("Range test #1 didn't match.\n"); - if (re_match (&buf, "a", 1, 0, NULL) != 1) - printf ("Range test #2 didn't match.\n"); - - buf.translate = 0; -#define FAO_PATTERN "\\(f\\(.\\)o\\)+" - if (re_compile_pattern (FAO_PATTERN, strlen (FAO_PATTERN), &buf) != NULL) - printf ("faofdx test didn't compile.\n"); - if (re_search (&buf, "faofdx", 6, 0, 6, ®s) != 0) - printf ("faofdx test didn't match.\n"); - if (regs.start[1] != 0 || regs.end[1] != 3) - printf ("faofdx test, reg #1 wrong.\n"); - if (regs.start[2] != 1 || regs.end[2] != 2) - printf ("faofdx test, reg #2 wrong.\n"); - - TEST_REGISTERS ("\\(a\\)*a", "aaa", 0, 3, 1, 2, -1, -1); - test_fastmap ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)", " \n", 1, 0); - - /* 40 lines, 48 a's in each line. */ - test_match ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)", - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\ -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:"); - - /* 640 a's followed by one b, twice. */ - test_match ("\\(.*\\)\\1", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"); - - /* 640 a's followed by two b's, twice. */ - test_match ("\\(.*\\)\\1", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabb"); - - - /* Dave G. bug: Reference to a subexpression which didn't match. - Should fail. */ - re_set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR); - test_match ("(ooooooooooone())-annnnnnnnnnnd-(twooooooooooo\\2)", - "ooooooooooone-annnnnnnnnnnd-twooooooooooo"); - test_match ("(o|t)", "o"); - test_match ("(o()|t)", "o"); - test_match ("(o|t)", "o"); - test_match ("(ooooooooooooooo|tttttttttttttttt())", "ooooooooooooooo"); - test_match ("(o|t())", "o"); - test_match ("(o()|t())", "o"); - test_match ("(ooooooooooooooooooooooooone()|twooooooooooooooooooooooooo())", "ooooooooooooooooooooooooone"); - test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-t"); - test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-f"); - - test_should_match = 0; - test_match ("(foo(bar)|second)\\2", "second"); - test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-t"); - test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-f"); - - re_set_syntax (RE_SYNTAX_EMACS); - test_match ("\\(foo\\(bar\\)\\|second\\)\\2", "secondbar"); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", - "one-and-four"); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", - "two-and-three"); - - test_should_match = 1; - re_set_syntax (RE_SYNTAX_EMACS); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", - "one-and-three"); - test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", - "two-and-four"); - - TEST_REGISTERS (":\\(.*\\)", ":/", 0, 2, 1, 2, -1, -1); - - /* Bug with `upcase' translation table, from Nico Josuttis - */ - test_should_match = 1; - test_case_fold ("[a-a]", "a"); - - printf ("\nFinished regression tests.\n"); -} - - - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/lib/regex-0.12/test/upcase.c b/gnu/lib/regex-0.12/test/upcase.c deleted file mode 100644 index 5147b812aaae..000000000000 --- a/gnu/lib/regex-0.12/test/upcase.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Indexed by a character, gives the upper case equivalent of the - character. */ - -char upcase[0400] = - { 000, 001, 002, 003, 004, 005, 006, 007, - 010, 011, 012, 013, 014, 015, 016, 017, - 020, 021, 022, 023, 024, 025, 026, 027, - 030, 031, 032, 033, 034, 035, 036, 037, - 040, 041, 042, 043, 044, 045, 046, 047, - 050, 051, 052, 053, 054, 055, 056, 057, - 060, 061, 062, 063, 064, 065, 066, 067, - 070, 071, 072, 073, 074, 075, 076, 077, - 0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137, - 0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177, - 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, - 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, - 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, - 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, - 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, - 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, - 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, - 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, - 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, - 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, - 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, - 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, - 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, - 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, - 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, - 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377 - }; - - diff --git a/gnu/lib/regex-0.12/test/xmalloc.c b/gnu/lib/regex-0.12/test/xmalloc.c deleted file mode 100644 index 88be1a668bd3..000000000000 --- a/gnu/lib/regex-0.12/test/xmalloc.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -extern char *malloc (); - -#ifndef NULL -#define NULL 0 -#endif - -void * -xmalloc (size) - unsigned size; -{ - char *new_mem = malloc (size); - - if (new_mem == NULL) - { - fprintf (stderr, "xmalloc: request for %u bytes failed.\n", size); - abort (); - } - - return new_mem; -} diff --git a/gnu/libexec/uucp/config.c b/gnu/libexec/uucp/config.c deleted file mode 100644 index aee11f8e3cc3..000000000000 --- a/gnu/libexec/uucp/config.c +++ /dev/null @@ -1,1044 +0,0 @@ -/* config.c - Read the configuration file. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: config.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.29 1992/03/28 22:06:38 ian - Michael I Bushnell: renamed enum tstatus to avoid header file conflict - - Revision 1.28 1992/03/28 21:47:55 ian - David J. MacKenzie: allow backslash to quote newline in config files - - Revision 1.27 1992/03/28 04:26:12 ian - David J. MacKenzie: cMaxuuxqts is independent of HAVE_TAYLOR_CONFIG - - Revision 1.26 1992/03/18 23:12:37 ian - Handle CMDTABTYPE_FULLSTRING correctly if there are no arguments - - Revision 1.25 1992/03/17 01:03:03 ian - Miscellaneous cleanup - - Revision 1.24 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.23 1992/03/11 22:06:37 ian - Marty Shannon: added max-uuxqts command - - Revision 1.22 1992/03/09 05:08:16 ian - Added status for wrong time to call, not used if system can't be called - - Revision 1.21 1992/03/04 21:39:04 ian - Local variables in igradecmp have to be integers - - Revision 1.20 1992/03/03 06:06:48 ian - T. William Wells: don't complain about missing configuration files - - Revision 1.19 1992/02/29 01:06:59 ian - Chip Salzenberg: recheck file permissions before sending - - Revision 1.18 1992/02/24 04:58:47 ian - Only permit files to be received into directories that are world-writeable - - Revision 1.17 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.16 1992/01/15 07:06:29 ian - Set configuration directory in Makefile rather than sysdep.h - - Revision 1.15 1992/01/14 04:04:17 ian - Chip Salzenberg: strcmp is a macro on AIX - - Revision 1.14 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.13 1991/12/29 01:54:46 ian - Terry Gardner: allow a # character to be quoted in a configuration file - - Revision 1.12 1991/12/22 20:57:57 ian - Added externs for strcasecmp or strncasecmp - - Revision 1.11 1991/12/18 03:54:14 ian - Made error messages to terminal appear more normal - - Revision 1.10 1991/12/15 03:42:33 ian - Added tprocess_chat_cmd for all chat commands, and added CMDTABTYPE_PREFIX - - Revision 1.9 1991/12/13 22:43:06 ian - Don't continually allocate and free the list of arguments - - Revision 1.8 1991/12/09 18:39:46 ian - Richard Todd: the pushed back line is specific to a particular multi file - - Revision 1.7 1991/12/09 16:59:48 ian - Richard Todd: don't warn if special "#" command is unrecognized - - Revision 1.6 1991/12/07 18:05:20 ian - Franc,ois Pinard: no limit to number of arguments - - Revision 1.5 1991/12/03 02:38:26 ian - Don't treat numbers with leading zeroes as octal - - Revision 1.4 1991/12/01 19:35:38 ian - David Nugent: read V2 and BNU files by default even with TAYLOR_CONFIG - - Revision 1.3 1991/11/26 02:04:49 ian - Bob Denny: add explicit extern for strcmp and strcasecmp - - Revision 1.2 1991/09/19 02:38:21 ian - Chip Salzenberg: V2 and BNU dialcodes files are relative to CONFIGLIB - - Revision 1.1 1991/09/10 19:38:34 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char config_rcsid[] = "$Id: config.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#include "system.h" -#include "sysdep.h" - -/* Some systems make strcmp a macro, which screws us up since we want - to declare it since we will take its address later. */ -#undef strcmp -#undef strncmp - -/* External functions. */ -extern int strcmp (), strncmp (), strcasecmp (), strncasecmp (); -extern int fclose (); - -/* Local functions. */ - -static void umulti_pushback P((struct smulti_file *, char *)); - -/* Status strings. These must match enum tstatus_type. */ - -const char *azStatus[] = -{ - "Conversation complete", - "Port unavailable", - "Dial failed", - "Login failed", - "Handshake failed", - "Call failed", - "Talking", - "Wrong time to call" -}; - -/* Local node name. */ -const char *zLocalname; - -/* Spool directory. */ -const char *zSpooldir = SPOOLDIR; - -#if DEBUG > 1 -/* Debugging level. */ -int iDebug = 0; - -/* Debugging file name. */ -const char *zDebugfile = DEBUGFILE; -#endif - -/* Public directory. */ -const char *zPubdir = PUBDIR; - -/* Log file name. */ -const char *zLogfile = LOGFILE; - -/* Statistics file name. */ -const char *zStatfile = STATFILE; - -/* Dialcode file names. */ -char *zDialcodefile; - -/* The maximum number of uuxqt processes which may be running at one - time. If this is zero, there is no limit. */ -int cMaxuuxqts; - -#if HAVE_TAYLOR_CONFIG - -/* System file names. */ -char *zSysfile; - -/* Port file names. */ -char *zPortfile; - -/* Dialer file names. */ -char *zDialfile; - -/* Call out login and password file names. */ -char *zCallfile; - -/* Call in login and password file names. */ -char *zPwdfile; - -/* Command table used to parse the configuration file. */ - -static enum tcmdtabret tcadd P((int argc, char **argv, pointer pvar, - const char *zerr)); - -const struct scmdtab asCmds[] = -{ - /* System name. */ - { "nodename", CMDTABTYPE_STRING, (pointer) &zLocalname, NULL }, - { "hostname", CMDTABTYPE_STRING, (pointer) &zLocalname, NULL }, - { "uuname", CMDTABTYPE_STRING, (pointer) &zLocalname, NULL }, - /* Spool directory. */ - { "spool", CMDTABTYPE_STRING, (pointer) &zSpooldir, NULL }, - /* System information files. */ - { "sysfile", CMDTABTYPE_FN | 0, (pointer) &zSysfile, tcadd }, - /* Port files. */ - { "portfile", CMDTABTYPE_FN | 0, (pointer) &zPortfile, tcadd }, - /* Dial files. */ - { "dialfile", CMDTABTYPE_FN | 0, (pointer) &zDialfile, tcadd }, - /* Dialcode files. */ - { "dialcodefile", CMDTABTYPE_FN | 0, (pointer) &zDialcodefile, tcadd }, - /* Public directory. */ - { "pubdir", CMDTABTYPE_STRING, (pointer) &zPubdir, NULL }, - /* Call out login name and password files. */ - { "callfile", CMDTABTYPE_FN | 0, (pointer) &zCallfile, tcadd }, - /* Call in login name and password files. */ - { "passwdfile", CMDTABTYPE_FN | 0, (pointer) &zPwdfile, tcadd }, - /* Log file. */ - { "logfile", CMDTABTYPE_STRING, (pointer) &zLogfile, NULL }, - /* Statistics file. */ - { "statfile", CMDTABTYPE_STRING, (pointer) &zStatfile, NULL }, -#if DEBUG > 1 - /* Debugging file. */ - { "debugfile", CMDTABTYPE_STRING, (pointer) &zDebugfile, NULL }, - /* Debugging level. */ - { "debug", CMDTABTYPE_FN | 0, (pointer) &iDebug, tidebug_parse }, -#endif - /* Command for unknown system. */ - { "unknown", CMDTABTYPE_FN, NULL, tiunknown }, - /* Maximum number of uuxqt processes. */ - { "max-uuxqts", CMDTABTYPE_INT, (pointer) &cMaxuuxqts, NULL }, -#if HAVE_V2_CONFIG - { "v2-files", CMDTABTYPE_BOOLEAN, (pointer) &fV2, NULL }, -#endif -#if HAVE_BNU_CONFIG - { "bnu-files", CMDTABTYPE_BOOLEAN, (pointer) &fBnu, NULL }, -#endif - /* End marker. */ - { NULL, 0, NULL, NULL } -}; - -/* Add strings to a string variable, separating with spaces. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tcadd (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - int i; - - for (i = 1; i < argc; i++) - uadd_string ((char **) pvar, argv[i], ' '); - return CMDTABRET_FREE; -} - -#endif /* HAVE_TAYLOR_CONFIG */ - -/* Process commands from a stdio file according to a command table. - The character '#' introduces a comment. Exactly one of e and - qmulti must be NULL. If we get the first line of a multi file, we - attempt to process the command "#"; this command will not arise - from a normal command file, and lets the caller take special action - at the start of a new file. If we are reading with zmulti_gets, we - ignore the zerr argument and instead use the name of the file. */ - -void -uprocesscmds (e, qmulti, qcmds, zerr, iflags) - FILE *e; - struct smulti_file *qmulti; - const struct scmdtab *qcmds; - const char *zerr; - int iflags; -{ - while (TRUE) - { - static char **pzargs; - static int calloc_args; - char *zget, *z; - int cargs; - enum tcmdtabret t; - char **pzhold_args; - int chold_alloc_args; - - if (e != NULL) - zget = zfgets (e, (iflags & CMDFLAG_BACKSLASH) != 0); - else - { - boolean ffirst; - - zget = zmulti_gets (qmulti, &ffirst, &zerr, - (iflags & CMDFLAG_BACKSLASH) != 0); - if (zget != NULL && ffirst) - { - char *zargs; - - zargs = (char *) "#"; - t = tprocess_one_cmd (1, &zargs, qcmds, zerr, - iflags &~ CMDFLAG_WARNUNRECOG); - if (t == CMDTABRET_EXIT || t == CMDTABRET_FREE_AND_EXIT) - { - umulti_pushback (qmulti, zget); - return; - } - } - } - - if (zget == NULL) - return; - - /* Any # character not preceeded by a backslash starts a - comment. */ - z = zget; - while ((z = strchr (z, '#')) != NULL) - { - if (z == zget || *(z - 1) != '\\') - { - *z = '\0'; - break; - } - /* Remove the backslash. */ - xmemmove (z - 1, z, strlen (z) + 1); - } - - z = zget; - cargs = 0; - while (TRUE) - { - while (*z != '\0' && isspace (BUCHAR (*z))) - z++; - - if (*z == '\0') - break; - - if (cargs >= calloc_args) - { - calloc_args += 10; - pzargs = (char **) xrealloc ((pointer) pzargs, - calloc_args * sizeof (char *)); - } - - pzargs[cargs] = z; - ++cargs; - - while (*z != '\0' && ! isspace (BUCHAR (*z))) - z++; - - if (*z == '\0') - break; - - *z++ = '\0'; - } - - if (cargs <= 0) - { - xfree ((pointer) zget); - continue; - } - - /* Save off the static variables to allow this function to - be called recursively. */ - pzhold_args = pzargs; - chold_alloc_args = calloc_args; - pzargs = NULL; - calloc_args = 0; - - t = tprocess_one_cmd (cargs, pzhold_args, qcmds, zerr, iflags); - - if (pzargs != NULL) - xfree ((pointer) pzargs); - pzargs = pzhold_args; - calloc_args = chold_alloc_args; - - if (t == CMDTABRET_FREE || t == CMDTABRET_FREE_AND_EXIT) - xfree ((pointer) zget); - if (t == CMDTABRET_EXIT || t == CMDTABRET_FREE_AND_EXIT) - return; - } -} - -/* Process a single command. */ - -enum tcmdtabret -tprocess_one_cmd (cargs, azargs, qcmds, zerr, iflags) - int cargs; - char **azargs; - const struct scmdtab *qcmds; - const char *zerr; - int iflags; -{ - const struct scmdtab *q; - int (*pfcmp) P((const char *, const char *)); - - if ((iflags & CMDFLAG_CASESIGNIFICANT) != 0) - pfcmp = strcmp; - else - pfcmp = strcasecmp; - - for (q = qcmds; q->zcmd != NULL; q++) - { - int itype; - int callowed; - - itype = TTYPE_CMDTABTYPE (q->itype); - if (itype != CMDTABTYPE_PREFIX) - { - if ((*pfcmp) (q->zcmd, azargs[0]) != 0) - continue; - } - else - { - int clen; - - clen = strlen (q->zcmd); - if ((iflags & CMDFLAG_CASESIGNIFICANT) != 0) - { - if (strncmp (q->zcmd, azargs[0], clen) != 0) - continue; - } - else - { - if (strncasecmp (q->zcmd, azargs[0], clen) != 0) - continue; - } - } - - callowed = CARGS_CMDTABTYPE (q->itype); - if (callowed != 0 && callowed != cargs) - { - if (zerr != NULL) - ulog (LOG_ERROR, "%s: %s: Wrong number of arguments", - zerr, q->zcmd); - return CMDTABRET_FREE; - } - else if (itype == TTYPE_CMDTABTYPE (CMDTABTYPE_STRING)) - { - if (cargs != 1 && cargs != 2) - { - if (zerr != NULL) - ulog (LOG_ERROR, "%s: %s: Wrong number of arguments", - zerr, q->zcmd); - return CMDTABRET_FREE; - } - if (cargs == 1) - *(const char **) q->pvar = ""; - else - *(const char **) q->pvar = azargs[1]; - return CMDTABRET_CONTINUE; - } - else if (itype == TTYPE_CMDTABTYPE (CMDTABTYPE_INT) - || itype == TTYPE_CMDTABTYPE (CMDTABTYPE_LONG)) - { - long i; - char *zend; - - i = strtol (azargs[1], &zend, 10); - if (*zend != '\0') - { - if (zerr != NULL) - ulog (LOG_ERROR, "%s: %s: Bad number", zerr, - q->zcmd); - return CMDTABRET_FREE; - } - if (itype == TTYPE_CMDTABTYPE (CMDTABTYPE_INT)) - * (int *) q->pvar = (int) i; - else - * (long *) q->pvar = i; - - return CMDTABRET_FREE; - } - else if (itype == TTYPE_CMDTABTYPE (CMDTABTYPE_BOOLEAN)) - { - char b; - - b = azargs[1][0]; - if (b == 'y' || b == 'Y' || b == 't' || b == 'T') - * (boolean *) q->pvar = TRUE; - else if (b == 'n' || b == 'N' || b == 'f' || b == 'F') - * (boolean *) q->pvar = FALSE; - else if (zerr != NULL) - ulog (LOG_ERROR, "%s: %s: Bad boolean", zerr, - q->zcmd); - return CMDTABRET_FREE; - } - else if (itype == TTYPE_CMDTABTYPE (CMDTABTYPE_FULLSTRING)) - { - int i, clen; - char *zset; - - /* Use all the arguments separated by a ' ' - character. */ - - clen = 1; - for (i = 1; i < cargs; i++) - clen += strlen (azargs[i]) + 1; - - zset = (char *) xmalloc (clen); - *zset = '\0'; - for (i = 1; i < cargs - 1; i++) - { - strcat (zset, azargs[i]); - strcat (zset, " "); - } - if (i < cargs) - strcat (zset, azargs[i]); - - * (const char **) q->pvar = zset; - - return CMDTABRET_FREE; - } - else if (itype == TTYPE_CMDTABTYPE (CMDTABTYPE_FN) - || itype == TTYPE_CMDTABTYPE (CMDTABTYPE_PREFIX)) - return (*q->ptfn) (cargs, azargs, q->pvar, zerr); - else - { -#if DEBUG > 0 - ulog (LOG_FATAL, "tprocess_one_cmd: Can't happen (0x%x)", - itype); -#endif - return CMDTABRET_FREE; - } - } - - if ((iflags & CMDFLAG_WARNUNRECOG) != 0 - && zerr != NULL) - ulog (LOG_ERROR, "%s: Unrecognized command %s", zerr, azargs[0]); - - return CMDTABRET_FREE; -} - -/* Read the configuration file. If we can't open the configuration file, - and we're trying to read the default, don't report an error. This - permits people to not have a configuration file at all if they are - satisfied with the compiled in defaults. */ - -void -uread_config (zname) - const char *zname; -{ -#if HAVE_TAYLOR_CONFIG - - FILE *e; - char *zdefault; - - zdefault = (char *) alloca (sizeof NEWCONFIGLIB + sizeof CONFIGFILE); - sprintf (zdefault, "%s%s", NEWCONFIGLIB, CONFIGFILE); - - /* On UNIX we will be probably be running suid to uucp. We don't want - to let somebody run us and specify some arbitrary file as the - configuration file, since that might let them examine files they - have no access to. */ - if (zname != NULL - && strcmp (zname, zdefault) != 0 - && ! fsysdep_other_config (zname)) - { - ulog (LOG_ERROR, "Can't read %s; using %s", zname, zdefault); - zname = zdefault; - } - - if (zname == NULL) - zname = zdefault; - - e = fopen (zname, "r"); - if (e == NULL) - { - if (strcmp (zname, zdefault) != 0) - { - fprintf (stderr, "%s: %s: %s\n", abProgram, zname, - strerror (errno)); - /* We haven't yet called usysdep_initialize, so it should be - safe to just exit. */ - exit (EXIT_FAILURE); - } - /* Just use defaults. */ - } - else - { - uiunknown_start (); - uprocesscmds (e, (struct smulti_file *) NULL, asCmds, zname, - CMDFLAG_BACKSLASH); - (void) fclose (e); - uiunknown_end (); - } - -#else /* ! HAVE_TAYLOR_CONFIG */ - - uiunknown_start (); - uiunknown_end (); - -#endif /* ! HAVE_TAYLOR_CONFIG */ - - if (zLocalname == NULL) - { - zLocalname = zsysdep_local_name (); - if (zLocalname == NULL) - { - fprintf (stderr, "%s: Can't get local node name\n", abProgram); - exit (EXIT_FAILURE); - } - } - - uisetup_localsys (); - -#if HAVE_TAYLOR_CONFIG - - /* Get the defaults for the file names. */ - -#define SETDEFAULT(z, zfile) \ - if (z == NULL) \ - { \ - z = (char *) xmalloc (sizeof NEWCONFIGLIB + sizeof zfile - 1); \ - strcpy (z, NEWCONFIGLIB); \ - strcat (z, zfile); \ - if (! fsysdep_file_exists (z)) \ - { \ - xfree ((pointer) z); \ - z = NULL; \ - } \ - } - - SETDEFAULT (zSysfile, SYSFILE); - SETDEFAULT (zPortfile, PORTFILE); - SETDEFAULT (zDialfile, DIALFILE); - SETDEFAULT (zDialcodefile, DIALCODEFILE); - SETDEFAULT (zPwdfile, PASSWDFILE); - SETDEFAULT (zCallfile, CALLFILE); - -#endif /* HAVE_TAYLOR_CONFIG */ - -#if HAVE_BNU_CONFIG - /* If we are supposed to read standard BNU files, read Sysfiles to - get any nonstandard file names. */ - if (fBnu) - ubnu_read_sysfiles (); -#endif /* HAVE_BNU_CONFIG */ - - /* The format of the dialcodes file is the same for all systems, so - if additional configuration are being used we add the files in - here to save having to do it when the dialcodes file is read. */ - -#if HAVE_V2_CONFIG - if (fV2) - { - char *z; - - z = (char *) alloca (sizeof OLDCONFIGLIB + sizeof V2_DIALCODES); - sprintf (z, "%s%s", OLDCONFIGLIB, V2_DIALCODES); - uadd_string (&zDialcodefile, z, ' '); - } -#endif /* HAVE_V2_CONFIG */ - -#if HAVE_BNU_CONFIG - if (fBnu) - { - char *z; - - z = (char *) alloca (sizeof OLDCONFIGLIB + sizeof BNU_DIALCODES); - sprintf (z, "%s%s", OLDCONFIGLIB, BNU_DIALCODES); - uadd_string (&zDialcodefile, z, ' '); - } -#endif /* HAVE_BNU_CONFIG */ -} - -/* Add a string to a list of strings separated by a separator - character. */ - -void -uadd_string (pz, z, bsep) - char **pz; - const char *z; - int bsep; -{ - if (*pz == NULL) - *pz = xstrdup (z); - else - { - int clen; - - clen = strlen (*pz); - *pz = (char *) xrealloc ((pointer) *pz, clen + strlen (z) + 2); - (*pz)[clen] = (char) bsep; - strcpy (*pz + clen + 1, z); - } -} - -#if DEBUG > 1 - -/* Parse a debugging string. This may be a simple number, which sets - the given number of bits in iDebug, or it may be a series of single - letters. */ - -static const char * const azDebug_names[] = DEBUG_NAMES; - -int -idebug_parse (z) - const char *z; -{ - char *zend; - int i, iret; - char *zcopy, *ztok; - - i = (int) strtol (z, &zend, 0); - if (*zend == '\0') - { - if (i > 15) - i = 15; - else if (i < 0) - i = 0; - return (1 << i) - 1; - } - - zcopy = (char *) alloca (strlen (z) + 1); - strcpy (zcopy, z); - - iret = 0; - - for (ztok = strtok (zcopy, ","); - ztok != NULL; - ztok = strtok ((char *) NULL, ",")) - { - if (strcasecmp (ztok, "all") == 0) - { - iret = DEBUG_MAX; - break; - } - for (i = 0; azDebug_names[i] != NULL; i++) - { - if (strncasecmp (ztok, azDebug_names[i], - strlen (azDebug_names[i])) == 0) - { - iret |= 1 << i; - break; - } - } - if (azDebug_names[i] == NULL) - ulog (LOG_ERROR, "Unrecognized debugging option \"%s\"", - ztok); - } - - return iret; -} - -/* Parse a debugging string in a configuration file. The pvar - arguments points to the field to set. */ - -/*ARGSUSED*/ -enum tcmdtabret -tidebug_parse (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - int *pidebug = (int *) pvar; - int i; - - if (argc == 2 && - strncasecmp (argv[1], DEBUG_NONE, strlen (DEBUG_NONE)) == 0) - { - *pidebug = 0; - return CMDTABRET_FREE; - } - - for (i = 1; i < argc; i++) - *pidebug |= idebug_parse (argv[i]); - - return CMDTABRET_FREE; -} - -#endif /* DEBUG > 1 */ - -/* Given a file name that may actually be several file names each - separated with a single space character, we want to be able to read - lines from them as though they were catenated to form a single - file. This set of routines allows us to do that easily, although - only for one set of files at a time. One line can be pushed back, - which can be convenient for the first line of a file. */ - -struct smulti_file -{ - /* Names of next files to open. */ - char *z; - /* String to free up when done. */ - char *zfree; - /* Current file. */ - FILE *e; - /* Current file name. */ - char *zname; - /* Next line to return. */ - char *znext; -}; - -struct smulti_file * -qmulti_open (znames) - const char *znames; -{ - struct smulti_file *qret; - - qret = (struct smulti_file *) xmalloc (sizeof (struct smulti_file)); - qret->z = qret->zfree = xstrdup (znames); - qret->zname = NULL; - qret->e = NULL; - qret->znext = NULL; - - return qret; -} - -/* Read the next line from a multiply opened set of files. */ - -char * -zmulti_gets (q, pffirst, pzname, fbackslash) - struct smulti_file *q; - boolean *pffirst; - const char **pzname; - boolean fbackslash; -{ - if (pffirst != NULL) - *pffirst = FALSE; - - if (q->znext != NULL) - { - char *z; - - z = q->znext; - q->znext = NULL; - return z; - } - - while (TRUE) - { - char *z; - - if (q->e != NULL) - { - char *zret; - - zret = zfgets (q->e, fbackslash); - if (zret != NULL) - { - if (pzname != NULL) - *pzname = q->zname; - return zret; - } - - if (fclose (q->e) != 0) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - q->e = NULL; - return NULL; - } - - q->e = NULL; - } - - if (*q->z == '\0') - return NULL; - - z = q->z; - q->z += strcspn (z, " "); - if (*q->z != '\0') - *q->z++ = '\0'; - - q->e = fopen (z, "r"); - if (q->e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", z, strerror (errno)); - return NULL; - } - - if (pffirst != NULL) - *pffirst = TRUE; - q->zname = z; - } -} - -/* Push back a line so that it is read by the next call to - zmulti_gets. This is sometimes used on the first line of a file in - uprocesscmds. */ - -static void -umulti_pushback (q, z) - struct smulti_file *q; - char *z; -{ -#if DEBUG > 0 - if (q->znext != NULL) - ulog (LOG_FATAL, "umulti_pushback: Can't happen"); -#endif - q->znext = z; -} - -/* Close the multiple file, even though a read is in progress. If - zmulti_gets returns NULL, the files will have been closed. */ - -boolean -fmulti_close (q) - struct smulti_file *q; -{ - boolean fret; - - fret = TRUE; - - if (q->e != NULL) - { - if (fclose (q->e) != 0) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - fret = FALSE; - } - } - - xfree ((pointer) q->zfree); - xfree ((pointer) q); - - return fret; -} - -/* See whether a file is in a directory list, and make sure the user - has appropriate access. */ - -boolean -fin_directory_list (qsys, zfile, zdirs, fcheck, freadable, zuser) - const struct ssysteminfo *qsys; - const char *zfile; - const char *zdirs; - boolean fcheck; - boolean freadable; - const char *zuser; -{ - char *zcopy; - boolean fmatch; - - zcopy = (char *) alloca (strlen (zdirs) + 1); - strcpy (zcopy, zdirs); - - fmatch = FALSE; - - while (*zcopy != '\0') - { - char *z; - - z = zcopy + strcspn (zcopy, " "); - if (*z == '\0') - --z; - else - *z = '\0'; - - if (*zcopy == '!') - { - if (fsysdep_in_directory (qsys, zfile, zcopy + 1, FALSE, - FALSE, (const char *) NULL)) - fmatch = FALSE; - } - else - { - if (fsysdep_in_directory (qsys, zfile, zcopy, fcheck, - freadable, zuser)) - fmatch = TRUE; - } - - zcopy = z + 1; - } - - return fmatch; -} - -/* See whether a file is a spool file. Spool file names are specially - crafted to hand around to other UUCP packages. They always begin - with 'C', 'D' or 'X', and the second character is always a period. - The remaining characters are any character that could appear in a - system name. */ - -boolean -fspool_file (zfile) - const char *zfile; -{ - const char *z; - - if (*zfile != 'C' && *zfile != 'D' && *zfile != 'X') - return FALSE; - if (zfile[1] != '.') - return FALSE; - for (z = zfile + 2; *z != '\0'; z++) - if (! isalnum (BUCHAR (*z)) && *z != '_' && *z != '-' && *z != '.') - return FALSE; - return TRUE; -} - -/* Compare two grades, returning < 0 if the first should be executed - before the second, == 0 if they are the same, and > 0 if the first - should be executed after the second. This code assumes that the - upper case letters appear in sequence and the lower case letters - appear in sequence. */ - -int -igradecmp (barg1, barg2) - int barg1; - int barg2; -{ - int b1, b2; - - /* Make sure the arguments are unsigned. */ - b1 = (int) BUCHAR (barg1); - b2 = (int) BUCHAR (barg2); - - if (isdigit (b1)) - { - if (isdigit (b2)) - return b1 - b2; - else - return -1; - } - else if (isupper (b1)) - { - if (isdigit (b2)) - return 1; - else if (isupper (b2)) - return b1 - b2; - else - return -1; - } - else - { - if (! islower (b2)) - return 1; - else - return b1 - b2; - } -} diff --git a/gnu/libexec/uucp/config.status b/gnu/libexec/uucp/config.status deleted file mode 100644 index fd56c992df54..000000000000 --- a/gnu/libexec/uucp/config.status +++ /dev/null @@ -1,11 +0,0 @@ -DEFS="" -LIBS="" -INSTALL="/usr/bin/install -c" -INSTALLDATA="/usr/bin/install -c -m 644" -CC="gcc -O" -CFLAGS="-g" -LDFLAGS="" -LN_S="ln -s" -ALLOCA="" -UUDIR="# " - diff --git a/gnu/libexec/uucp/configure b/gnu/libexec/uucp/configure deleted file mode 100644 index 9dcf886067ea..000000000000 --- a/gnu/libexec/uucp/configure +++ /dev/null @@ -1,936 +0,0 @@ -: -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically by autoconf. -# 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. - -# Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [TARGET] -# All args except --srcdir=DIR are ignored. - -trap 'rm -f conftest conftest.c; exit 1' 1 3 15 - -set +u # Make sure unset variables are ok. - -for arg in $*; do - # Handle --srcdir with a space before the argument. - if test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir= - # Handle --host with a space before the argument. - elif test x$next_host = xyes; then next_host= - else - case $arg in - +srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*) - srcdir=`echo $arg | sed 's/[+-]s[a-z]*=//'` ;; - +srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s) - next_srcdir=yes ;; - +host=* | --host=* | --hos=* | --ho=* | --h=*) ;; - +host | --host | --hos | --ho | --h) - next_host=yes ;; - +gas | --gas | --ga | --g) ;; - +nfp | --nfp | --nf | --n) ;; - *) ;; - esac - fi -done - -INCLUDEDIR=${INCLUDEDIR-/usr/include} - -rm -f conftest conftest.c -compile='$CC $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1' - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -unique_file=uucico.c - -# Makefile rules whose targets are searched for in VPATH need to use $<. -# However, old makes do not support it, so we use a combination -# construction in Makefile.in: `$file<'. -# If srcdir is `.', we use sed to change that to `file' for old makes. -# Otherwise, we use sed to change it to `$<'. -# vpsub is the sed program, which changes `$file<' to one or the other. -vpsub='s,\$\([-./a-zA-Z0-9_][-./a-zA-Z0-9_]*\)<,\1,g' -# Find the source files, if location was not specified. -if test x$srcdir = x; then - srcdirdefaulted=yes; srcdir=. - if test ! -r $unique_file; then srcdir=`pwd`/..; fi -fi -if test $srcdir != .; then - VPATH='VPATH = $(srcdir)' - vpsub='s,\$\([-./a-zA-Z0-9_][-./a-zA-Z0-9_]*\)<,\$<,g' -fi - -if test ! -r $srcdir/$unique_file; then - if test x$srcdirdefaulted = xyes; then - echo "configure: Can not find sources in \`.' or \`..'." 1>&2 - else - echo "configure: Can not find sources in \`${srcdir}'." 1>&2 - fi - exit 1 -fi - -# The Bourne shell writes "command not found" to /dev/tty, so if we get -# a usage message on stderr, we have the program. -# -# ksh and zsh write "command not found" to stderr, but test -n does not -# want any output if there is no program. So we use the `type' builtin -# instead for them (and bash). -if test "$RANDOM" = "$RANDOM"; then - checkfor='test -n "`$checkprog $checkargs 2>&1`"' -else - checkfor='type $checkprog >/dev/null' -fi - - -exec 6>conf.h -trap 'rm -f conftest conftest.c conf.h; exit 1' 1 3 15 -echo 1>&6 "/* conf.h */" - -echo 1>&6 "/* Configuration header file for Taylor UUCP. - Generated on `date`. */ -" -echo checking for install -# Make sure to not get the incompatible SysV /etc/install. -if test -z "$INSTALL" || test -z "$INSTALLDATA"; then - saveifs="$IFS"; IFS="$IFS:" - for dir in $PATH; do - test -z "$dir" && dir=. - if test $dir != /etc && test -f $dir/install; then - test -z "$INSTALL" && INSTALL="$dir/install -c" - test -z "$INSTALLDATA" && INSTALLDATA="$dir/install -c -m 644" - break - fi - done - IFS="$saveifs" -fi -INSTALL=${INSTALL-cp} -INSTALLDATA=${INSTALLDATA-cp} - -echo checking for gcc -checkprog=gcc checkargs='' -test -z "$CC" && eval $checkfor && CC='gcc -O' -CC=${CC-cc} - -CFLAGS=${CFLAGS--g} -echo checking for mail program -echo 1>&6 "/* Set MAIL_PROGRAM to a program which takes a mail address as an argument - and accepts a mail message to send to that address on stdin. */ -#define MAIL_PROGRAM `if test -s /usr/ucb/mail; then echo '"/usr/ucb/mail"'; else if test -s /bin/mail; then echo '"/bin/mail"'; else echo 'undefined'; fi; fi`" -echo checking for echo program -echo 1>&6 " -/* Set ECHO_PROGRAM to a program which echoes its arguments; if echo - is a shell builtin you can just use \"echo\". */ -#define ECHO_PROGRAM `if test -s /bin/echo; then echo '"/bin/echo"'; else echo '"echo"'; fi`" -echo checking for symbolic links -if ln -s X NoSucHFile 2>/dev/null; then - LN_S='ln -s' -else - LN_S='ln' -fi -rm -f NoSucHFile - -echo 1>&6 " -/* The following macros indicate what header files you have. Set the - macro to 1 if you have the corresponding header file, or 0 if you - do not. */" -for hdr in string.h strings.h unistd.h stdlib.h limits.h time.h -do -havehdr=HAVE_`echo ${hdr} | tr "[a-z]./" "[A-Z]__"` -echo checking for ${hdr} -echo 1>&6 "#define ${havehdr} `if test -f $INCLUDEDIR/${hdr}; then echo 1; else echo 0; fi` /* <${hdr}> */" -done -for hdr in sys/wait.h sys/ioctl.h dirent.h memory.h sys/param.h -do -havehdr=HAVE_`echo ${hdr} | tr "[a-z]./" "[A-Z]__"` -echo checking for ${hdr} -echo 1>&6 "#define ${havehdr} `if test -f $INCLUDEDIR/${hdr}; then echo 1; else echo 0; fi` /* <${hdr}> */" -done -for hdr in utime.h fcntl.h sys/file.h libc.h sysexits.h -do -havehdr=HAVE_`echo ${hdr} | tr "[a-z]./" "[A-Z]__"` -echo checking for ${hdr} -echo 1>&6 "#define ${havehdr} `if test -f $INCLUDEDIR/${hdr}; then echo 1; else echo 0; fi` /* <${hdr}> */" -done -for hdr in poll.h stropts.h -do -havehdr=HAVE_`echo ${hdr} | tr "[a-z]./" "[A-Z]__"` -echo checking for ${hdr} -echo 1>&6 "#define ${havehdr} `if test -f $INCLUDEDIR/${hdr}; then echo 1; else echo 0; fi` /* <${hdr}> */" -done - -echo 1>&6 "" -echo checking for signal handler type -pattern='void[ ]*(\*signal[ ]*(' -echo 1>&6 "/* Set SIGtype to the return type of a signal handler. On newer systems - this will be void; some older systems use int. */ -#define SIGtype `if grep "$pattern" $INCLUDEDIR/signal.h >/dev/null 2>&1 || - grep "$pattern" $INCLUDEDIR/sys/signal.h >/dev/null 2>&1; then - echo void - else - echo int - fi`" - -echo checking for time_t in time.h -echo "#include -main() { exit(0); } t() { time_t i; }" > conftest.c -eval $compile -echo 1>&6 " -/* Set HAVE_TIME_T to 1 if time_t is defined in , as required by - the ANSI C standard. */ -#define HAVE_TIME_T `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - -echo checking for time_t in sys/types.h -echo "#include -main() { exit(0); } t() { time_t i; }" > conftest.c -eval $compile -echo 1>&6 " -/* Set HAVE_SYS_TIME_T to 1 if time_t is defined in ; this - is only checked if HAVE_TIME_T is 0. */ -#define HAVE_SYS_TIME_T `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - -echo 1>&6 "" -echo checking for time.h and sys/time.h being included together -echo "#include -#include -main () { exit (0); }" > conftest.c -eval $compile -echo 1>&6 "/* Set HAVE_SYS_TIME_AND_TIME_H to 1 if and can both - be included in a single source file; if you don't have either or both of - them, it doesn't matter what you set this to. */ -#define HAVE_SYS_TIME_AND_TIME_H `(if test -f $INCLUDEDIR/time.h -a -f $INCLUDEDIR/sys/time.h -a -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - -echo 1>&6 "" -echo checking for termios.h and sys/ioctl.h being included together -echo "#include -#include -main () { exit (0); }" > conftest.c -eval $compile -echo 1>&6 "/* Set HAVE_TERMIOS_AND_SYS_IOCTL_H to 1 if and - can both be included in a single source file; if you don't have either - or both of them, it doesn't matter what you set this to. */ -#define HAVE_TERMIOS_AND_SYS_IOCTL_H `(if test -f $INCLUDEDIR/termios.h -a -f $INCLUDEDIR/sys/ioctl.h -a -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - -echo 1>&6 "" -echo checking for CBREAK -echo "#include -main() { exit(0); } t() { int i = CBREAK; }" > conftest.c -eval $compile -echo 1>&6 "/* If you are configuring by hand, you should set one of the terminal - driver options in policy.h. If you are autoconfiguring, the script - will check whether your system defines CBREAK, which is a terminal - setting; if your system supports CBREAK, and you don't set a terminal - driver in policy.h, the code will assume that you have a BSD style - terminal driver. */ -#define HAVE_CBREAK `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - -echo 1>&6 " -/* The package needs several standard types. If you are using the - configure script, it will look in standard places for these types, - and give default definitions for them here if it doesn't find them. - The default definitions should work on most systems, but you may - want to check them. If you are configuring by hand, you will have - to figure out whether the types are defined on your system, and - what they should be defined to. - - Each of the types should be defined using #define. For example, - #define pid_t int - */" -echo 1>&6 " -/* The type pid_t is used to hold a process ID number. It is normally - defined in . This is the type returned by the - functions fork or getpid. Usually int will work fine. */" -echo checking for pid_t in sys/types.h -echo "#include -main() { exit(0); } t() {pid_t x; }" >conftest.c -eval $compile -if test -s conftest && ./conftest 2>/dev/null; then - echo 1>&6 "/* A definition of pid_t was found on your system. */" -else - echo 1>&6 "#define pid_t int" -fi -rm -f conftest conftest.c - -echo 1>&6 " -/* The type uid_t is used to hold a user ID number. It is normally - defined in . This is the type returned by the getuid - function. Usually int will work fine. */" -echo checking for uid_t in sys/types.h -echo "#include -main() { exit(0); } t() {uid_t x; }" >conftest.c -eval $compile -if test -s conftest && ./conftest 2>/dev/null; then - echo 1>&6 "/* A definition of uid_t was found on your system. */" -else - echo 1>&6 "#define uid_t int" -fi -rm -f conftest conftest.c - -echo 1>&6 " -/* The type gid_t is used to hold a group ID number. It is sometimes - defined in . This is the type returned by the getgid - function. Usually int will work fine. */" -echo checking for gid_t in sys/types.h -echo "#include -main() { exit(0); } t() {gid_t x; }" >conftest.c -eval $compile -if test -s conftest && ./conftest 2>/dev/null; then - echo 1>&6 "/* A definition of gid_t was found on your system. */" -else - echo 1>&6 "#define gid_t int" -fi -rm -f conftest conftest.c - -echo 1>&6 " -/* The type off_t is used to hold an offset in a file. It is sometimes - defined in . This is the type of the second argument to - the lseek function. Usually long will work fine. */" -echo checking for off_t in sys/types.h -echo "#include -main() { exit(0); } t() {off_t x; }" >conftest.c -eval $compile -if test -s conftest && ./conftest 2>/dev/null; then - echo 1>&6 "/* A definition of off_t was found on your system. */" -else - echo 1>&6 "#define off_t long" -fi -rm -f conftest conftest.c - - -echo checking for sig_atomic_t in signal.h -echo "#include -main() { exit(0); } t() { sig_atomic_t x; }" > conftest.c -eval $compile -echo 1>&6 " -/* Set HAVE_SIG_ATOMIC_T_IN_SIGNAL_H if the type sig_atomic_t is defined - in as required by ANSI C. */ -#define HAVE_SIG_ATOMIC_T_IN_SIGNAL_H `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - -echo checking for sig_atomic_t in sys/types.h -echo "#include -main() { exit(0); } t() { sig_atomic_t x; }" > conftest.c -eval $compile -echo 1>&6 " -/* Set HAVE_SIG_ATOMIC_T_IN_TYPES_H if the type sig_atomic_t is defined - in . This is ignored if HAVE_SIG_ATOMIC_T_IN_SIGNAL_H is - set to 1. */ -#define HAVE_SIG_ATOMIC_T_IN_TYPES_H `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - -echo 1>&6 " -/* The type sig_atomic_t is used to hold a value which may be - referenced in a single atomic operation. If it is not defined in - either or , you may want to give it a - definition here (if you don't, the code will use char). If your - compiler does not support sig_atomic_t, there is no type which is - really correct; fortunately, for this package it does not really - matter very much. */" - -echo checking how to get filesystem info -echo 1>&6 " -/* When Taylor UUCP is talking to another instance of itself, it will - tell the other side the size of a file before it is transferred. - If the package can determine how much disk space is available, it - will use this information to avoid filling up the disk. Define one - of the following macros to tell the code how to determine the - amount of available disk space. It is possible that none of these - are appropriate; it will do no harm to use none of them, but, of - course, nothing will then prevent the package from filling up the - disk. Note that this space check is only useful when talking to - another instance of Taylor UUCP. - - FS_STATVFS the statvfs function - FS_USG_STATFS the four argument statfs function - FS_MNTENT the two argument statfs function with the f_bsize field - FS_STATFS the two argument statfs function with the f_fsize field - FS_GETMNT the two argument statfs function with the fd_req field - FS_USTAT the ustat function with 512 byte blocks. */" -if test -f $INCLUDEDIR/sys/statvfs.h -a -f $INCLUDEDIR/sys/fstyp.h; then - echo 1>&6 "#define FS_STATVFS " -elif test -f $INCLUDEDIR/sys/statfs.h -a -f $INCLUDEDIR/sys/fstyp.h; then - echo 1>&6 "#define FS_USG_STATFS " -elif test -f $INCLUDEDIR/mntent.h; then - echo 1>&6 "#define FS_MNTENT " -elif test -f $INCLUDEDIR/sys/mount.h -a -f $INCLUDEDIR/sys/fs_types.h; then - echo 1>&6 "#define FS_GETMNT " -elif grep MOUNT_UFS $INCLUDEDIR/sys/mount.h >/dev/null 2>&1; then - echo 1>&6 "#define FS_STATFS " -else - echo checking for ustat -echo " -main() { exit(0); } t() { ustat(); }" > conftest.c -eval $compile -if test -s conftest && ./conftest 2>/dev/null; then - echo 1>&6 "#define FS_USTAT " -fi -rm -f conftest conftest.c - -fi - -echo checking for void -echo "void main() { (void) exit (0); }" > conftest.c -eval $compile -echo 1>&6 " -/* Set HAVE_VOID to 1 if the compiler supports declaring functions with - a return type of void and casting values to void. */ -#define HAVE_VOID `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest.c conftest - -echo checking for unsigned char -echo "main () { unsigned char i = (unsigned char) -1; exit (0); }" > conftest.c -eval $compile -echo 1>&6 " -/* Set HAVE_UNSIGNED_CHAR to 1 if the compiler supports the type unsigned - char. */ -#define HAVE_UNSIGNED_CHAR `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest.c conftest - -echo checking for "int.*errno" in "errno.h" -echo 1>&6 " -/* Set HAVE_ERRNO_DECLARATION to 1 if errno is declared in . */ -#define HAVE_ERRNO_DECLARATION `if grep 'int.*errno' $INCLUDEDIR/errno.h >/dev/null 2>&1; then echo 1; else echo 0; fi`" - -echo checking for combined use of O_NONBLOCK and O_NDELAY -echo "#include -#ifndef O_NDELAY -#ifdef FNDELAY -#define O_NDELAY FNDELAY -#else -#define O_NDELAY 0 -#endif -#endif -#ifndef O_NONBLOCK -#ifdef FNBLOCK -#define O_NONBLOCK FNBLOCK -#else -#define O_NONBLOCK 0 -#endif -#endif -main () { exit (fcntl (open ("'"conftest.c"'", O_RDONLY), - F_SETFL, - O_NONBLOCK | O_NDELAY)); }" > conftest.c -eval $compile -echo 1>&6 " -/* Set COMBINED_UNBLOCK to 1 if the flags O_NONBLOCK and O_NDELAY can - both be specified at once on a file descriptor. If your system - does not support both flags, it doesn't matter what you set this - to. */ -#define COMBINED_UNBLOCK `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" - -echo checking for alloca -echo "#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* ! defined(__GNUC__) */ -#ifdef sparc -#include -#else /* ! defined (sparc) */ -#ifdef _AIX - #pragma alloca -#else /* ! defined (_AIX) */ -char *alloca (); -#endif /* ! defined (_AIX) */ -#endif /* ! defined (sparc) */ -#endif /* ! defined (__GNUC__) */ -main() { exit(0); } t() { char *p = (char *) alloca(1); }" > conftest.c -eval $compile -if test -s conftest && ./conftest 2>/dev/null; then : -else - OLIBS=$LIBS - if test -f /usr/ucblib/libucb.a; then - LIBS="$LIBS -L/usr/ucblib -lucb" # SVR4 - elif test -f /lib/libPW.a; then - LIBS="$LIBS -lPW" # SVR2 and SVR3 - else - ALLOCA=alloca.o - fi - if test "$OLIBS" != "$LIBS"; then - eval $compile - if test -s conftest && ./conftest 2>/dev/null; then : - else - LIBS=$OLIBS - ALLOCA=alloca.o - fi - fi -fi - -echo 1>&6 " -/* There are now a number of functions to check for. For each of these, - the macro HAVE_FUNC should be set to 1 if your system has FUNC. For - example, HAVE_STRERROR should be set to 1 if your system has strerror, - 0 otherwise. */" - -echo 1>&6 " -/* Taylor UUCP provides its own versions of the following functions, - or knows how to work around their absence. */" - -for func in memset memcmp memchr memcpy bcopy bcmp bzero -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo checking for memmove -echo "main () { exit (0); } t() { memmove(); }" > conftest.c -eval $compile -havememmove=`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null` -rm -f conftest conftest.c -if test "${havememmove}" != "1"; then - echo 1>&6 "#define HAVE_MEMMOVE 0" -else - echo "main() - { - register int x1, x2, x3; - char s[2]; - - x1 = 1; - x2 = 2; - x3 = 3; - memmove(s, "'""'", 1); - exit((x1 != 1) || (x2 != 2) || (x3 != 3)); - }" > conftest.c - cc -o conftest conftest.c >/dev/null 2>/dev/null - if test ! -s ./conftest; then - echo 1>&6 "#define HAVE_MEMMOVE 1" - elif ./conftest 2>/dev/null; then - echo 1>&6 "#define HAVE_MEMMOVE 1" - else - echo 1>&6 "#define HAVE_MEMMOVE 0 /* Your memmove seems to be buggy. */" - fi - rm -f conftest conftest.c -fi - -for func in strchr strrchr index rindex strerror strtol strstr -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done -for func in strdup strcasecmp stricmp strlwr bsearch vfprintf -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done -for func in remove ftruncate ltrunc rename opendir dup2 waitpid wait4 -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo 1>&6 " -/* If you have either sigsetjmp or setret, it will be used instead of - setjmp. These functions will only be used if your system restarts - system calls after interrupts (see HAVE_RESTARTABLE_SYSCALLS, - below). */" -for func in sigsetjmp setret -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo 1>&6 " -/* The code needs to know what function to use to set a signal - handler. If will try to use each of the following functions in - turn. If none are available, it will use signal, which is assumed - to always exist. */" -for func in sigaction sigvec sigset -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo 1>&6 " -/* The code will try to use each of the following functions in turn - when blocking signals from delivery. If none are available, a - relatively unimportant race condition will exist. */" -for func in sigprocmask sigblock sighold -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo 1>&6 " -/* If you have either of the following functions, it will be used to - determine the number of file descriptors which may be open. - Otherwise, the code will use OPEN_MAX if defined, then NOFILE if - defined, then 20. */" -for func in getdtablesize sysconf -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo 1>&6 " -/* The code will use one of the following functions when detaching - from a terminal. One of these must exist. */" -for func in setpgrp setsid -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo 1>&6 " -/* If you do not specify the local node name in the main configuration - file, Taylor UUCP will try to use each of the following functions - in turn. If neither is available, you must specify the local node - name in the configuration file. */" -for func in gethostname uname -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo 1>&6 " -/* The code will try to use each of the following functions in turn to - determine the current time. If none are available, it will use - time, which is assume to always exist. */" -for func in gettimeofday -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo checking for ftime -echo "main () { exit (0); } t() { ftime(); }" > conftest.c -eval $compile -haveftime=`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null` -rm -f conftest conftest.c -if test "${haveftime}" != "1"; then - echo 1>&6 "#define HAVE_FTIME 0" -else - echo "#include - #include - main () - { - struct timeb s, slast; - int c = 0; - ftime (&slast); - while (c < 10) - { - ftime (&s); - if (s.time < slast.time - || (s.time == slast.time && s.millitm < slast.millitm)) - exit (1); - if (s.time != slast.time) - ++c; - slast.time = s.time; - slast.millitm = s.millitm; - } - exit (0); - }" > conftest.c - eval $compile - if test -s ./conftest && ./conftest 2>/dev/null; then - echo 1>&6 "#define HAVE_FTIME 1" - else - echo 1>&6 "#define HAVE_FTIME 0 /* Your ftime seems to be buggy. */" - fi - rm -f conftest conftest.c -fi - -echo 1>&6 " -/* If neither gettimeofday nor ftime is available, the code will use - times (if available) to measure a span of time. See also the - discussion of TIMES_TICK in policy.h. */" -for func in times -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo 1>&6 " -/* When a chat script requests a pause of less than a second with \\p, - Taylor UUCP will try to use each of the following functions in - turn. If none are available, it will sleep for a full second. - Also, the (non-portable) tstuu program requires either select or - poll. */" -for func in napms nap usleep poll select -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done -echo '#include -#include "conf.h" -main () -{ -#if ! HAVE_NAPMS -#if ! HAVE_NAP -#if ! HAVE_USLEEP -#if ! HAVE_POLL -#if ! HAVE_SELECT - fprintf (stderr, "WARNING: No way to sleep for less than one second\n"); - fprintf (stderr, " \\p in chat scripts will sleep for a full second\n"); -#endif -#endif -#endif -#endif -#endif -}' > conftest.c -eval $compile -if test -s ./conftest; then - ./conftest -fi -rm -f conftest conftest.c - -echo 1>&6 " -/* If the getgrent function is available, it will be used to determine - all the groups a user belongs to when checking file access - permissions. */" -for func in getgrent -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo 1>&6 " -/* If the socket function is available, TCP support code will be - compiled in. */" -for func in socket -do -havefunc=HAVE_`echo ${func} | tr "[a-z]" "[A-Z]"` -echo checking for ${func} -echo "main() { exit (0); } t() { ${func}(); }" > conftest.c -eval $compile -echo 1>&6 "#define ${havefunc} `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c -done - -echo 1>&6 " -/* The code needs to know to how to get the name of the current - directory. If getcwd is available it will be used, otherwise if - getwd is available it will be used. Otherwise, set PWD_PROGRAM to - the name of the program which will print the name of the current - working directory. */" -echo checking for getcwd -echo "main() { exit (0); } t() { getcwd(); }" >conftest.c -eval $compile -havegetcwd=`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null` -echo 1>&6 "#define HAVE_GETCWD ${havegetcwd}" -echo checking for getwd -echo "main() { exit (0); } t() { getwd(); }" >conftest.c -eval $compile -havegetwd=`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null` -echo 1>&6 "#define HAVE_GETWD ${havegetwd}" -if test "${havegetcwd}" != 1 -a "${havegetwd}" != 1; then - echo 1>&6 "#define PWD_PROGRAM `if test -s /bin/pwd; then echo '"/bin/pwd"'; else echo unknown; fi`" -else - echo 1>&6 "#define PWD_PROGRAM unused" -fi - -echo 1>&6 " -/* The code needs to know how to create directories. If you have the - mkdir function, set HAVE_MKDIR to 1 and replace @UUDIR@ in - Makefile.in with '# ' (the configure script will set @UUDIR@ - according to the variable UUDIR). Otherwise, set HAVE_MKDIR to 0, - remove @UUDIR@ from Makefile.in, and set MKDIR_PROGRAM to the name - of the program which will create a directory named on the command - line. */" -echo checking for mkdir -echo "main() { exit (0); } t() { mkdir(); }" > conftest.c -eval $compile -havemkdir=`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null` -echo 1>&6 "#define HAVE_MKDIR ${havemkdir}" -if test "${havemkdir}" = "1"; then - UUDIR='# ' - echo 1>&6 "#define MKDIR_PROGRAM unused" -else - UUDIR= - echo 1>&6 "#define MKDIR_PROGRAM `if test -f /bin/mkdir; then echo '"/bin/mkdir"'; else echo unknown; fi`" -fi -rm -f conftest conftest.c - -echo 1>&6 " -/* That's the end of the list of the functions. Now there are a few - last miscellaneous items. */" - -echo checking whether times can be declared as long -echo "#include -`if test -f $INCLUDEDIR/sys/times.h; then echo '#include '; fi` -main () { exit(0); } extern long times ();" > conftest.c -eval $compile -echo 1>&6 " -/* On some systems times is declared in as returning - int, so the code cannot safely declare it as returning long. On - the other hand, on some systems times will not work unless it is - declared as returning long. Set TIMES_DECLARATION_OK to 1 if times - can be safely declared as returning long. If you will not be using - times, it doesn't matter what you set this to. */ -#define TIMES_DECLARATION_OK `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - -echo checking for BSD setpgrp -echo "`if test -f $INCLUDEDIR/unistd.h; then echo '#include '; fi` -main() { exit(0); } t() { getpgrp (0); setpgrp (0, 0); }" > conftest.c -eval $compile -echo 1>&6 " -/* Set HAVE_BSD_PGRP to 1 if your getpgrp call takes 1 argument and - your setpgrp calls takes 2 argument (on System V they generally - take no arguments). You can safely set this to 1 on System V, - provided the call will compile without any errors. */ -#define HAVE_BSD_PGRP `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - - -echo checking for union wait -echo "#include -main() { exit(0); } t() { union wait u; wait (&u); }" > conftest.c -eval $compile -echo 1>&6 " -/* Set HAVE_UNION_WAIT to 1 if union wait is defined in the header - file . */ -#define HAVE_UNION_WAIT `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - - -echo 1>&6 " -/* Define UTIME_NULL_MISSING if utime with a NULL second argument does not - set the file times to the current time. */" -echo checking utime with null argument -rm -f uttest; > uttest -# Sequent interprets utime(file, 0) to mean use start of epoch. Wrong. -echo '#include -#include -main() { -struct stat s, t; -exit(!(stat ("uttest", &s) == 0 && utime("uttest", (long *)0) == 0 -&& stat("uttest", &t) == 0 && t.st_mtime >= s.st_mtime -&& t.st_mtime - s.st_mtime < 120)); -}' > conftest.c -eval $compile -./conftest 2>/dev/null || echo 1>&6 "#define UTIME_NULL_MISSING " -rm -f conftest conftest.c uttest core - - -echo checking for long file names -(echo "1" > 123456789012345) 2>/dev/null -(echo "2" > 123456789012346) 2>/dev/null -long=`cat 123456789012345 2>/dev/null` -echo 1>&6 " -/* Set HAVE_LONG_NAMES to 1 if the system supports file names longer - than 14 characters. */ -#define HAVE_LONG_NAMES `if test -f 123456789012345 -a "${long}" = "1"; then echo 1; else echo 0; fi 2>/dev/null`" -rm -f 123456789012345 123456789012346 2>/dev/null - -echo checking for restartable system calls -echo "#include -ucatch (isig) { } -main () { int i = fork (); - if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); } - signal (SIGINT, ucatch); - exit (wait (&i) == -1); }" > conftest.c -eval $compile -echo 1>&6 " -/* If slow system calls are restarted after interrupts, set - HAVE_RESTARTABLE_SYSCALLS to 1. This is ignored if HAVE_SIGACTION - is 1 or if HAVE_SIGVEC is 1 and SV_INTERRUPT is defined in - . In both of these cases system calls can be prevented - from restarting. */ -#define HAVE_RESTARTABLE_SYSCALLS `(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`" -rm -f conftest conftest.c - -trap 'for dir in .; do rm -f $dir/Makefile; done; rm -f config.status conf.h; exit 1' 1 3 15 - -for dir in .; do - test -d $dir || mkdir $dir - echo creating $dir/Makefile - echo '# Generated automatically from Makefile.in by configure.' > $dir/Makefile - sed -e " -$vpsub -s,@srcdir@,$srcdir, -s,@VPATH@,$VPATH, -s,@DEFS@,$DEFS, -s,@LIBS@,$LIBS, -s,@INSTALL@,$INSTALL, -s,@INSTALLDATA@,$INSTALLDATA, -s,@CC@,$CC, -s,@CFLAGS@,$CFLAGS, -s,@LDFLAGS@,$LDFLAGS, -s,@LN_S@,$LN_S, -s,@ALLOCA@,$ALLOCA, -s,@UUDIR@,$UUDIR, -" $srcdir/$dir/Makefile.in >> $dir/Makefile -done - -echo creating config.status -echo "\ -DEFS=\"$DEFS\" -LIBS=\"$LIBS\" -INSTALL=\"$INSTALL\" -INSTALLDATA=\"$INSTALLDATA\" -CC=\"$CC\" -CFLAGS=\"$CFLAGS\" -LDFLAGS=\"$LDFLAGS\" -LN_S=\"$LN_S\" -ALLOCA=\"$ALLOCA\" -UUDIR=\"$UUDIR\" -" > config.status - diff --git a/gnu/libexec/uucp/configure.in b/gnu/libexec/uucp/configure.in deleted file mode 100644 index c1efdce1706e..000000000000 --- a/gnu/libexec/uucp/configure.in +++ /dev/null @@ -1,589 +0,0 @@ -dnl Taylor UUCP configuration file -dnl This should be processed with autoconf to produce a configure script. -dnl Copyright (c) 1992 Ian Lance Taylor -dnl -M_INIT(uucico.c) -M_HEADER_FILE(conf.h) -ILT_HEADER_COMMENT([/* Configuration header file for Taylor UUCP. - Generated on `date`. */ -]) -dnl -M_PROG_INSTALL -M_PROG_GCC -CFLAGS=${CFLAGS--g} -M_SUBST(CFLAGS)dnl -M_SUBST(LDFLAGS)dnl -dnl -echo checking for mail program -M_DEFINE([MAIL_PROGRAM], -[`if test -s /usr/ucb/mail; then echo '"/usr/ucb/mail"'; else if test -s /bin/mail; then echo '"/bin/mail"'; else echo 'undefined'; fi; fi`], -[/* Set MAIL_PROGRAM to a program which takes a mail address as an argument - and accepts a mail message to send to that address on stdin. */]) -echo checking for echo program -M_DEFINE([ECHO_PROGRAM], -[`if test -s /bin/echo; then echo '"/bin/echo"'; else echo '"echo"'; fi`], -[ -/* Set ECHO_PROGRAM to a program which echoes its arguments; if echo - is a shell builtin you can just use \"echo\". */]) -dnl this is just used to set LN_S in the Makefile -echo checking for symbolic links -if ln -s X NoSucHFile 2>/dev/null; then - LN_S='ln -s' -else - LN_S='ln' -fi -rm -f NoSucHFile -M_SUBST(LN_S)dnl - -ILT_HEADER_COMMENT([ -/* The following macros indicate what header files you have. Set the - macro to 1 if you have the corresponding header file, or 0 if you - do not. */]) -ILT_HEADER_CHECK(string.h strings.h unistd.h stdlib.h limits.h time.h) -ILT_HEADER_CHECK(sys/wait.h sys/ioctl.h dirent.h memory.h sys/param.h) -ILT_HEADER_CHECK(utime.h fcntl.h sys/file.h libc.h sysexits.h) -ILT_HEADER_CHECK(poll.h stropts.h) - -ILT_HEADER_COMMENT() -ILT_SIGTYPE -ILT_LIBTHING_CHECK([time_t in time.h], -[#include ], [time_t i;], [HAVE_TIME_T], -[ -/* Set HAVE_TIME_T to 1 if time_t is defined in , as required by - the ANSI C standard. */]) -ILT_LIBTHING_CHECK([time_t in sys/types.h], -[#include ], [time_t i;], [HAVE_SYS_TIME_T], -[ -/* Set HAVE_SYS_TIME_T to 1 if time_t is defined in ; this - is only checked if HAVE_TIME_T is 0. */]) -ILT_HEADER_COMMENT() -echo checking for time.h and sys/time.h being included together -echo "#include -#include -main () { exit (0); }" > conftest.c -eval $compile -M_DEFINE([HAVE_SYS_TIME_AND_TIME_H], -[`(if test -f $INCLUDEDIR/time.h -a -f $INCLUDEDIR/sys/time.h -a -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`], -[/* Set HAVE_SYS_TIME_AND_TIME_H to 1 if and can both - be included in a single source file; if you don't have either or both of - them, it doesn't matter what you set this to. */]) -rm -f conftest conftest.c - -ILT_HEADER_COMMENT() -echo checking for termios.h and sys/ioctl.h being included together -echo "#include -#include -main () { exit (0); }" > conftest.c -eval $compile -M_DEFINE([HAVE_TERMIOS_AND_SYS_IOCTL_H], -[`(if test -f $INCLUDEDIR/termios.h -a -f $INCLUDEDIR/sys/ioctl.h -a -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`], -[/* Set HAVE_TERMIOS_AND_SYS_IOCTL_H to 1 if and - can both be included in a single source file; if you don't have either - or both of them, it doesn't matter what you set this to. */]) -rm -f conftest conftest.c - -ILT_HEADER_COMMENT() -ILT_LIBTHING_CHECK([CBREAK], [#include ], [int i = CBREAK;], -[HAVE_CBREAK], -[/* If you are configuring by hand, you should set one of the terminal - driver options in policy.h. If you are autoconfiguring, the script - will check whether your system defines CBREAK, which is a terminal - setting; if your system supports CBREAK, and you don't set a terminal - driver in policy.h, the code will assume that you have a BSD style - terminal driver. */]) -ILT_HEADER_COMMENT([ -/* The package needs several standard types. If you are using the - configure script, it will look in standard places for these types, - and give default definitions for them here if it doesn't find them. - The default definitions should work on most systems, but you may - want to check them. If you are configuring by hand, you will have - to figure out whether the types are defined on your system, and - what they should be defined to. - - Each of the types should be defined using #define. For example, - #define pid_t int - */]) -ILT_HEADER_COMMENT([ -/* The type pid_t is used to hold a process ID number. It is normally - defined in . This is the type returned by the - functions fork or getpid. Usually int will work fine. */]) -ILT_LIBTHING_CHOICE([pid_t in sys/types.h], -[#include ], [pid_t x;], -ILT_HEADER_COMMENT([/* A definition of pid_t was found on your system. */]), -M_DEFINE(pid_t, int)) -ILT_HEADER_COMMENT([ -/* The type uid_t is used to hold a user ID number. It is normally - defined in . This is the type returned by the getuid - function. Usually int will work fine. */]) -ILT_LIBTHING_CHOICE([uid_t in sys/types.h], -[#include ], [uid_t x;], -ILT_HEADER_COMMENT([/* A definition of uid_t was found on your system. */]), -M_DEFINE(uid_t, int)) -ILT_HEADER_COMMENT([ -/* The type gid_t is used to hold a group ID number. It is sometimes - defined in . This is the type returned by the getgid - function. Usually int will work fine. */]) -ILT_LIBTHING_CHOICE([gid_t in sys/types.h], -[#include ], [gid_t x;], -ILT_HEADER_COMMENT([/* A definition of gid_t was found on your system. */]), -M_DEFINE(gid_t, int)) -ILT_HEADER_COMMENT([ -/* The type off_t is used to hold an offset in a file. It is sometimes - defined in . This is the type of the second argument to - the lseek function. Usually long will work fine. */]) -ILT_LIBTHING_CHOICE([off_t in sys/types.h], -[#include ], [off_t x;], -ILT_HEADER_COMMENT([/* A definition of off_t was found on your system. */]), -M_DEFINE(off_t, long)) - -dnl On SCO 3.2.2 sig_atomic_t is in but not . -ILT_LIBTHING_CHECK([sig_atomic_t in signal.h], -[#include ], [sig_atomic_t x;], -[HAVE_SIG_ATOMIC_T_IN_SIGNAL_H], -[ -/* Set HAVE_SIG_ATOMIC_T_IN_SIGNAL_H if the type sig_atomic_t is defined - in as required by ANSI C. */]) -ILT_LIBTHING_CHECK([sig_atomic_t in sys/types.h], -[#include ], [sig_atomic_t x;], -[HAVE_SIG_ATOMIC_T_IN_TYPES_H], -[ -/* Set HAVE_SIG_ATOMIC_T_IN_TYPES_H if the type sig_atomic_t is defined - in . This is ignored if HAVE_SIG_ATOMIC_T_IN_SIGNAL_H is - set to 1. */]) -ILT_HEADER_COMMENT([ -/* The type sig_atomic_t is used to hold a value which may be - referenced in a single atomic operation. If it is not defined in - either or , you may want to give it a - definition here (if you don't, the code will use char). If your - compiler does not support sig_atomic_t, there is no type which is - really correct; fortunately, for this package it does not really - matter very much. */]) - -dnl The filesystem info code is from David MacKenzie's fileutils 3.1 -dnl package. -echo checking how to get filesystem info -ILT_HEADER_COMMENT([ -/* When Taylor UUCP is talking to another instance of itself, it will - tell the other side the size of a file before it is transferred. - If the package can determine how much disk space is available, it - will use this information to avoid filling up the disk. Define one - of the following macros to tell the code how to determine the - amount of available disk space. It is possible that none of these - are appropriate; it will do no harm to use none of them, but, of - course, nothing will then prevent the package from filling up the - disk. Note that this space check is only useful when talking to - another instance of Taylor UUCP. - - FS_STATVFS the statvfs function - FS_USG_STATFS the four argument statfs function - FS_MNTENT the two argument statfs function with the f_bsize field - FS_STATFS the two argument statfs function with the f_fsize field - FS_GETMNT the two argument statfs function with the fd_req field - FS_USTAT the ustat function with 512 byte blocks. */]) -if test -f $INCLUDEDIR/sys/statvfs.h -a -f $INCLUDEDIR/sys/fstyp.h; then - M_DEFINE(FS_STATVFS) -elif test -f $INCLUDEDIR/sys/statfs.h -a -f $INCLUDEDIR/sys/fstyp.h; then - M_DEFINE(FS_USG_STATFS) -elif test -f $INCLUDEDIR/mntent.h; then - M_DEFINE(FS_MNTENT) -elif test -f $INCLUDEDIR/sys/mount.h -a -f $INCLUDEDIR/sys/fs_types.h; then - M_DEFINE(FS_GETMNT) -elif grep MOUNT_UFS $INCLUDEDIR/sys/mount.h >/dev/null 2>&1; then - M_DEFINE(FS_STATFS) -else - M_LIBTHING_PRESENT([ustat], , [ustat();], M_DEFINE(FS_USTAT)) -fi - -echo checking for void -echo "void main() { (void) exit (0); }" > conftest.c -eval $compile -M_DEFINE([HAVE_VOID], -[`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`], -[ -/* Set HAVE_VOID to 1 if the compiler supports declaring functions with - a return type of void and casting values to void. */]) -rm -f conftest.c conftest - -echo checking for unsigned char -echo "main () { unsigned char i = (unsigned char) -1; exit (0); }" > conftest.c -eval $compile -M_DEFINE([HAVE_UNSIGNED_CHAR], -[`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`], -[ -/* Set HAVE_UNSIGNED_CHAR to 1 if the compiler supports the type unsigned - char. */]) -rm -f conftest.c conftest - -ILT_IDENT_CHECK([int.*errno], [errno.h], [HAVE_ERRNO_DECLARATION], -[ -/* Set HAVE_ERRNO_DECLARATION to 1 if errno is declared in . */]) - -echo checking for combined use of O_NONBLOCK and O_NDELAY -echo "#include -#ifndef O_NDELAY -#ifdef FNDELAY -#define O_NDELAY FNDELAY -#else -#define O_NDELAY 0 -#endif -#endif -#ifndef O_NONBLOCK -#ifdef FNBLOCK -#define O_NONBLOCK FNBLOCK -#else -#define O_NONBLOCK 0 -#endif -#endif -main () { exit (fcntl (open ("'"conftest.c"'", O_RDONLY), - F_SETFL, - O_NONBLOCK | O_NDELAY)); }" > conftest.c -eval $compile -M_DEFINE([COMBINED_UNBLOCK], -[`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`], -[ -/* Set COMBINED_UNBLOCK to 1 if the flags O_NONBLOCK and O_NDELAY can - both be specified at once on a file descriptor. If your system - does not support both flags, it doesn't matter what you set this - to. */]) - -dnl Do some complicated tests for alloca. If we fail to find it, we -dnl look in a couple of libraries and try again. -echo checking for alloca -echo "#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* ! defined(__GNUC__) */ -#ifdef sparc -#include -#else /* ! defined (sparc) */ -#ifdef _AIX - #pragma alloca -#else /* ! defined (_AIX) */ -char *alloca (); -#endif /* ! defined (_AIX) */ -#endif /* ! defined (sparc) */ -#endif /* ! defined (__GNUC__) */ -main() { exit(0); } t() { char *p = (char *) alloca(1); }" > conftest.c -eval $compile -if test -s conftest && ./conftest 2>/dev/null; then : -else - OLIBS=$LIBS - if test -f /usr/ucblib/libucb.a; then - LIBS="$LIBS -L/usr/ucblib -lucb" # SVR4 - elif test -f /lib/libPW.a; then - LIBS="$LIBS -lPW" # SVR2 and SVR3 - else - ALLOCA=alloca.o - fi - if test "$OLIBS" != "$LIBS"; then - eval $compile - if test -s conftest && ./conftest 2>/dev/null; then : - else - LIBS=$OLIBS - ALLOCA=alloca.o - fi - fi -fi -M_SUBST(ALLOCA)dnl - -ILT_HEADER_COMMENT([ -/* There are now a number of functions to check for. For each of these, - the macro HAVE_FUNC should be set to 1 if your system has FUNC. For - example, HAVE_STRERROR should be set to 1 if your system has strerror, - 0 otherwise. */]) - -ILT_HEADER_COMMENT([ -/* Taylor UUCP provides its own versions of the following functions, - or knows how to work around their absence. */]) -undefine([index]) -ILT_FUNC_CHECK(memset memcmp memchr memcpy bcopy bcmp bzero) - -echo checking for memmove -echo "main () { exit (0); } t() { memmove(); }" > conftest.c -eval $compile -havememmove=`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null` -rm -f conftest conftest.c -if test "${havememmove}" != "1"; then - M_DEFINE(HAVE_MEMMOVE, 0) -else - dnl now check for the SCO buggy memmove. This test case is from - dnl Chip Salzenberg - changequote(,)dnl - echo "main() - { - register int x1, x2, x3; - char s[2]; - - x1 = 1; - x2 = 2; - x3 = 3; - memmove(s, "'""'", 1); - exit((x1 != 1) || (x2 != 2) || (x3 != 3)); - }" > conftest.c - changequote([,])dnl - dnl The test case must be compiled with cc without optimization - cc -o conftest conftest.c >/dev/null 2>/dev/null - if test ! -s ./conftest; then - dnl $CC worked but cc didn't; it's probably OK - M_DEFINE(HAVE_MEMMOVE, 1) - elif ./conftest 2>/dev/null; then - M_DEFINE(HAVE_MEMMOVE, 1) - else - M_DEFINE(HAVE_MEMMOVE, [0 /* Your memmove seems to be buggy. */]) - fi - rm -f conftest conftest.c -fi - -ILT_FUNC_CHECK(strchr strrchr index rindex strerror strtol strstr) -ILT_FUNC_CHECK(strdup strcasecmp stricmp strlwr bsearch vfprintf) -ILT_FUNC_CHECK(remove ftruncate ltrunc rename opendir dup2 waitpid wait4) - -ILT_HEADER_COMMENT([ -/* If you have either sigsetjmp or setret, it will be used instead of - setjmp. These functions will only be used if your system restarts - system calls after interrupts (see HAVE_RESTARTABLE_SYSCALLS, - below). */]) -ILT_FUNC_CHECK(sigsetjmp setret) - -ILT_HEADER_COMMENT([ -/* The code needs to know what function to use to set a signal - handler. If will try to use each of the following functions in - turn. If none are available, it will use signal, which is assumed - to always exist. */]) -ILT_FUNC_CHECK(sigaction sigvec sigset) - -ILT_HEADER_COMMENT([ -/* The code will try to use each of the following functions in turn - when blocking signals from delivery. If none are available, a - relatively unimportant race condition will exist. */]) -ILT_FUNC_CHECK(sigprocmask sigblock sighold) - -ILT_HEADER_COMMENT([ -/* If you have either of the following functions, it will be used to - determine the number of file descriptors which may be open. - Otherwise, the code will use OPEN_MAX if defined, then NOFILE if - defined, then 20. */]) -ILT_FUNC_CHECK(getdtablesize sysconf) - -ILT_HEADER_COMMENT([ -/* The code will use one of the following functions when detaching - from a terminal. One of these must exist. */]) -ILT_FUNC_CHECK(setpgrp setsid) - -ILT_HEADER_COMMENT([ -/* If you do not specify the local node name in the main configuration - file, Taylor UUCP will try to use each of the following functions - in turn. If neither is available, you must specify the local node - name in the configuration file. */]) -ILT_FUNC_CHECK(gethostname uname) - -ILT_HEADER_COMMENT([ -/* The code will try to use each of the following functions in turn to - determine the current time. If none are available, it will use - time, which is assume to always exist. */]) -ILT_FUNC_CHECK(gettimeofday) - -echo checking for ftime -echo "main () { exit (0); } t() { ftime(); }" > conftest.c -eval $compile -haveftime=`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null` -rm -f conftest conftest.c -if test "${haveftime}" != "1"; then - M_DEFINE(HAVE_FTIME, 0) -else - dnl now check for the SCO buggy ftime - echo "#include - #include - main () - { - struct timeb s, slast; - int c = 0; - ftime (&slast); - while (c < 10) - { - ftime (&s); - if (s.time < slast.time - || (s.time == slast.time && s.millitm < slast.millitm)) - exit (1); - if (s.time != slast.time) - ++c; - slast.time = s.time; - slast.millitm = s.millitm; - } - exit (0); - }" > conftest.c - eval $compile - if test -s ./conftest && ./conftest 2>/dev/null; then - M_DEFINE(HAVE_FTIME, 1) - else - M_DEFINE(HAVE_FTIME, [0 /* Your ftime seems to be buggy. */]) - fi - rm -f conftest conftest.c -fi - -ILT_HEADER_COMMENT([ -/* If neither gettimeofday nor ftime is available, the code will use - times (if available) to measure a span of time. See also the - discussion of TIMES_TICK in policy.h. */]) -ILT_FUNC_CHECK(times) - -ILT_HEADER_COMMENT([ -/* When a chat script requests a pause of less than a second with \\p, - Taylor UUCP will try to use each of the following functions in - turn. If none are available, it will sleep for a full second. - Also, the (non-portable) tstuu program requires either select or - poll. */]) -ILT_FUNC_CHECK(napms nap usleep poll select) -echo '#include -#include "conf.h" -main () -{ -#if ! HAVE_NAPMS -#if ! HAVE_NAP -#if ! HAVE_USLEEP -#if ! HAVE_POLL -#if ! HAVE_SELECT - fprintf (stderr, "WARNING: No way to sleep for less than one second\n"); - fprintf (stderr, " \\p in chat scripts will sleep for a full second\n"); -#endif -#endif -#endif -#endif -#endif -}' > conftest.c -eval $compile -if test -s ./conftest; then - ./conftest -fi -rm -f conftest conftest.c - -ILT_HEADER_COMMENT([ -/* If the getgrent function is available, it will be used to determine - all the groups a user belongs to when checking file access - permissions. */]) -ILT_FUNC_CHECK(getgrent) - -ILT_HEADER_COMMENT([ -/* If the socket function is available, TCP support code will be - compiled in. */]) -ILT_FUNC_CHECK(socket) - -ILT_HEADER_COMMENT([ -/* The code needs to know to how to get the name of the current - directory. If getcwd is available it will be used, otherwise if - getwd is available it will be used. Otherwise, set PWD_PROGRAM to - the name of the program which will print the name of the current - working directory. */]) -echo checking for getcwd -echo "main() { exit (0); } t() { getcwd(); }" >conftest.c -eval $compile -havegetcwd=`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null` -M_DEFINE([HAVE_GETCWD], [${havegetcwd}]) -echo checking for getwd -echo "main() { exit (0); } t() { getwd(); }" >conftest.c -eval $compile -havegetwd=`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null` -M_DEFINE([HAVE_GETWD], [${havegetwd}]) -if test "${havegetcwd}" != 1 -a "${havegetwd}" != 1; then - M_DEFINE([PWD_PROGRAM], - [`if test -s /bin/pwd; then echo '"/bin/pwd"'; else echo unknown; fi`]) -else - M_DEFINE([PWD_PROGRAM], [unused]) -fi - -ILT_HEADER_COMMENT([ -/* The code needs to know how to create directories. If you have the - mkdir function, set HAVE_MKDIR to 1 and replace @UUDIR@ in - Makefile.in with '# ' (the configure script will set @UUDIR@ - according to the variable UUDIR). Otherwise, set HAVE_MKDIR to 0, - remove @UUDIR@ from Makefile.in, and set MKDIR_PROGRAM to the name - of the program which will create a directory named on the command - line. */]) -echo checking for mkdir -echo "main() { exit (0); } t() { mkdir(); }" > conftest.c -eval $compile -havemkdir=`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null` -M_DEFINE([HAVE_MKDIR], [${havemkdir}]) -if test "${havemkdir}" = "1"; then - UUDIR='# ' - M_DEFINE([MKDIR_PROGRAM], [unused]) -else - UUDIR= - M_DEFINE([MKDIR_PROGRAM], - [`if test -f /bin/mkdir; then echo '"/bin/mkdir"'; else echo unknown; fi`]) -fi -M_SUBST(UUDIR)dnl -rm -f conftest conftest.c - -ILT_HEADER_COMMENT([ -/* That's the end of the list of the functions. Now there are a few - last miscellaneous items. */]) - -echo checking whether times can be declared as long -echo "#include -`if test -f $INCLUDEDIR/sys/times.h; then echo '#include '; fi` -main () { exit(0); } extern long times ();" > conftest.c -eval $compile -M_DEFINE([TIMES_DECLARATION_OK], -[`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`], -[ -/* On some systems times is declared in as returning - int, so the code cannot safely declare it as returning long. On - the other hand, on some systems times will not work unless it is - declared as returning long. Set TIMES_DECLARATION_OK to 1 if times - can be safely declared as returning long. If you will not be using - times, it doesn't matter what you set this to. */]) -rm -f conftest conftest.c - -ILT_LIBTHING_CHECK([BSD setpgrp], -[`if test -f $INCLUDEDIR/unistd.h; then echo '#include '; fi`], -[getpgrp (0); setpgrp (0, 0);], [HAVE_BSD_PGRP], -[ -/* Set HAVE_BSD_PGRP to 1 if your getpgrp call takes 1 argument and - your setpgrp calls takes 2 argument (on System V they generally - take no arguments). You can safely set this to 1 on System V, - provided the call will compile without any errors. */]) - -ILT_LIBTHING_CHECK([union wait], [#include ], -[union wait u; wait (&u);], [HAVE_UNION_WAIT], -[ -/* Set HAVE_UNION_WAIT to 1 if union wait is defined in the header - file . */]) - -ILT_HEADER_COMMENT([ -/* Define UTIME_NULL_MISSING if utime with a NULL second argument does not - set the file times to the current time. */]) -M_UTIME_NULL - -echo checking for long file names -(echo "1" > 123456789012345) 2>/dev/null -(echo "2" > 123456789012346) 2>/dev/null -long=`cat 123456789012345 2>/dev/null` -M_DEFINE([HAVE_LONG_NAMES], -[`if test -f 123456789012345 -a "${long}" = "1"; then echo 1; else echo 0; fi 2>/dev/null`], -[ -/* Set HAVE_LONG_NAMES to 1 if the system supports file names longer - than 14 characters. */]) -rm -f 123456789012345 123456789012346 2>/dev/null - -echo checking for restartable system calls -dnl Remember that exit (0) is true, so this exits with true when the wait -dnl call returns something other than -1, i.e. the pid of the child, -dnl which means that the wait was restarted after the signal. -echo "#include -ucatch (isig) { } -main () { int i = fork (); - if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); } - signal (SIGINT, ucatch); - exit (wait (&i) == -1); }" > conftest.c -eval $compile -M_DEFINE([HAVE_RESTARTABLE_SYSCALLS], -[`(if test -s conftest && ./conftest 2>/dev/null; then echo 1; else echo 0; fi) 2>/dev/null`], -[ -/* If slow system calls are restarted after interrupts, set - HAVE_RESTARTABLE_SYSCALLS to 1. This is ignored if HAVE_SIGACTION - is 1 or if HAVE_SIGVEC is 1 and SV_INTERRUPT is defined in - . In both of these cases system calls can be prevented - from restarting. */]) -rm -f conftest conftest.c - -M_OUTPUT(.) diff --git a/gnu/libexec/uucp/copy.c b/gnu/libexec/uucp/copy.c deleted file mode 100644 index 3976a84fec67..000000000000 --- a/gnu/libexec/uucp/copy.c +++ /dev/null @@ -1,207 +0,0 @@ -/* copy.c - Copy one file to another for the UUCP package. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: copy.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.7 1992/02/24 20:07:43 ian - John Theus: some systems don't have - - Revision 1.6 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.5 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.4 1991/12/11 03:59:19 ian - Create directories when necessary; don't just assume they exist - - Revision 1.3 1991/12/01 02:23:12 ian - Niels Baggesen: don't multiply include - - Revision 1.2 1991/09/19 03:23:34 ian - Chip Salzenberg: append to private debugging file, don't overwrite it - - Revision 1.1 1991/09/10 19:39:38 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char copy_rcsid[] = "$Id: copy.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#include "system.h" -#include "sysdep.h" - -/* External functions. */ -extern int fclose (); - -/* Copy one file to another. */ - -#if USE_STDIO - -boolean -fcopy_file (zfrom, zto, fpublic, fmkdirs) - const char *zfrom; - const char *zto; - boolean fpublic; - boolean fmkdirs; -{ - FILE *efrom; - FILE *eto; - char ab[8192]; - int c; - - efrom = fopen (zfrom, BINREAD); - if (efrom == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", zfrom, strerror (errno)); - return FALSE; - } - eto = esysdep_fopen (zto, fpublic, FALSE, fmkdirs); - if (eto == NULL) - { - (void) fclose (efrom); - return FALSE; - } - - while ((c = fread (ab, sizeof (char), sizeof ab, efrom)) != 0) - { - if (fwrite (ab, sizeof (char), c, eto) != c) - { - ulog (LOG_ERROR, "fwrite: %s", strerror (errno)); - (void) fclose (efrom); - (void) fclose (eto); - (void) remove (zto); - return FALSE; - } - } - - (void) fclose (efrom); - - if (fclose (eto) != 0) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - (void) remove (zto); - return FALSE; - } - - return TRUE; -} - -#else /* ! USE_STDIO */ - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -boolean -fcopy_file (zfrom, zto, fpublic, fmkdirs) - const char *zfrom; - const char *zto; - boolean fpublic; - boolean fmkdirs; -{ - int ofrom; - int oto; - char ab[8192]; - int c; - - ofrom = open (zfrom, O_RDONLY, 0); - if (ofrom < 0) - { - ulog (LOG_ERROR, "open (%s): %s", zfrom, strerror (errno)); - return FALSE; - } - - /* These file mode arguments are from the UNIX version of sysdep.h; - each system dependent header file will need their own - definitions. */ - oto = creat (zto, fpublic ? IPUBLIC_FILE_MODE : IPRIVATE_FILE_MODE); - if (oto < 0) - { - if (errno == ENOENT && fmkdirs) - { - if (! fsysdep_make_dirs (zto, fpublic)) - return FALSE; - oto = creat (zto, - fpublic ? IPUBLIC_FILE_MODE : IPRIVATE_FILE_MODE); - } - if (oto < 0) - { - ulog (LOG_ERROR, "open (%s): %s", zto, strerror (errno)); - (void) close (ofrom); - return FALSE; - } - } - - while ((c = read (ofrom, ab, sizeof ab)) > 0) - { - if (write (oto, ab, c) != c) - { - ulog (LOG_ERROR, "write: %s", strerror (errno)); - (void) close (ofrom); - (void) close (oto); - (void) remove (zto); - return FALSE; - } - } - - (void) close (ofrom); - - if (close (oto) < 0) - { - ulog (LOG_ERROR, "close: %s", strerror (errno)); - (void) remove (zto); - return FALSE; - } - - if (c < 0) - { - ulog (LOG_ERROR, "read: %s", strerror (errno)); - (void) remove (zto); - return FALSE; - } - - return TRUE; -} - -#endif /* ! USE_STDIO */ diff --git a/gnu/libexec/uucp/file.c b/gnu/libexec/uucp/file.c deleted file mode 100644 index 5fc34456ac0b..000000000000 --- a/gnu/libexec/uucp/file.c +++ /dev/null @@ -1,589 +0,0 @@ -/* file.c - Generic routines to handle files. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: file.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.16 1992/03/30 04:07:13 ian - Dirk Musstopf: remove temporary file if receive fails - - Revision 1.15 1992/03/17 00:31:33 ian - Changed iRecmode to unsigned int - - Revision 1.14 1992/03/11 01:18:15 ian - Niels Baggesen: drop the connection on a write failure - - Revision 1.13 1992/03/11 00:18:50 ian - Save temporary file if file send fails - - Revision 1.12 1992/02/29 01:06:59 ian - Chip Salzenberg: recheck file permissions before sending - - Revision 1.11 1992/02/19 19:36:07 ian - Rearranged time functions - - Revision 1.10 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.9 1992/01/18 22:48:53 ian - Reworked sending of mail and general handling of failed transfers - - Revision 1.8 1991/12/21 23:10:43 ian - Terry Gardner: record failed file transfers in statistics file - - Revision 1.7 1991/12/17 07:09:58 ian - Record statistics in fractions of a second - - Revision 1.6 1991/12/10 19:29:02 ian - Move statistics file stuff from file.c to log.c - - Revision 1.5 1991/11/10 19:24:22 ian - Added pffile protocol entry point for file level control - - Revision 1.4 1991/11/08 04:30:50 ian - Hannu Strang: flush statistics file after each line - - Revision 1.3 1991/11/07 19:42:16 ian - Chip Salzenberg: declare inline functions consistently - - Revision 1.2 1991/09/19 03:23:34 ian - Chip Salzenberg: append to private debugging file, don't overwrite it - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char file_rcsid[] = "$Id: file.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#include "system.h" - -/* Current file being sent. */ -openfile_t eSendfile = EFILECLOSED; - -/* Current file being received. */ -openfile_t eRecfile = EFILECLOSED; - -/* This file has to keep several strings. I don't want to pay for the - overhead (small as it is) of calling malloc for each one, and I also - don't want to truncate the strings. So I use a structure which holds - strings up to a certain length, and call malloc for longer strings. - NULL strings are indistinguishable from empty strings, which turns - out not to matter. */ - -#define CSTRLEN (30) - -struct sstring -{ - char ab[CSTRLEN]; - char *zalloc; -}; - -/* Local functions. */ - -__inline__ static boolean ffsetstring P((struct sstring *, const char *)); -__inline__ static const char *zfgetstring P((const struct sstring *)); -__inline__ static void uffreestring P((struct sstring *)); - -__inline__ -static boolean ffsetstring (q, z) - struct sstring *q; - const char *z; -{ - if (z == NULL) - q->ab[0] = '\0'; - else if (strlen (z) < CSTRLEN) - strcpy (q->ab, z); - else - { - q->zalloc = strdup (z); - if (q->zalloc == NULL) - { - ulog (LOG_ERROR, "Not enough memory to store command"); - return FALSE; - } - } - return TRUE; -} - -__inline__ -static const char *zfgetstring (q) - const struct sstring *q; -{ - if (q->zalloc != NULL) - return q->zalloc; - else - return q->ab; -} - -__inline__ static void -uffreestring (q) - struct sstring *q; -{ - xfree ((pointer) q->zalloc); - q->zalloc = NULL; -} - -/* Information we keep for the file being sent. We have to be able to - send mail to the user when the transfer is finished, we have to be - able to report error messages sensibly, and we have to be able to - clear this send request out of the work queue if we initiated the - send. */ - -/* Work queue sequence number. */ -static pointer pSendseq; -/* File name being transferred from. */ -static struct sstring sSendfrom; -/* File name being transferred to. */ -static struct sstring sSendto; -/* System being transferred to. */ -static struct sstring sSendtosys; -/* Requesting user name. */ -static struct sstring sSenduser; -/* User to send mail to. */ -static struct sstring sSendmail; -/* Start time. */ -static long iSendstart_secs; -static long iSendstart_micros; -/* Indicate whether we had an error during the transfer. */ -static boolean fSenderror; - -/* Store information about a file being sent. */ - -boolean -fstore_sendfile (e, pseq, zfrom, zto, ztosys, zuser, zmail) - openfile_t e; - pointer pseq; - const char *zfrom; - const char *zto; - const char *ztosys; - const char *zuser; - const char *zmail; -{ -#if DEBUG > 0 - if (ffileisopen (eSendfile)) - ulog (LOG_FATAL, "fstore_sendfile: In progress"); -#endif - - if (! ffsetstring (&sSendfrom, zfrom) - || ! ffsetstring (&sSendto, zto) - || ! ffsetstring (&sSendtosys, ztosys) - || ! ffsetstring (&sSenduser, zuser) - || ! ffsetstring (&sSendmail, zmail)) - { - (void) ffileclose (e); - return FALSE; - } - - eSendfile = e; - pSendseq = pseq; - iSendstart_secs = isysdep_process_time (&iSendstart_micros); - - fSenderror = FALSE; - - return TRUE; -} - -/* Finish up after sending a file. The freceived argument indicates - whether the other file received it successfully. The cbytes - argument is the number of bytes that were sent (for the statistics - entry). The zwhy argument holds a reason for failure if freceived - is FALSE. The fnever argument is TRUE if the file was not received - correctly and, moreover, will never be received correctly. */ - -boolean -fsent_file (freceived, cbytes, zwhy, fnever) - boolean freceived; - long cbytes; - const char *zwhy; - boolean fnever; -{ - boolean f; - long isecs, imicros; - - f = TRUE; - - if (fSenderror) - freceived = FALSE; - - if (ffileisopen (eSendfile)) - (void) ffileclose (eSendfile); - - isecs = isysdep_process_time (&imicros); - imicros -= iSendstart_micros; - if (imicros < 0) - { - imicros += 1000000; - isecs--; - } - isecs -= iSendstart_secs; - - ustats (freceived, zfgetstring (&sSenduser), zfgetstring (&sSendtosys), - TRUE, cbytes, isecs, imicros); - - if (freceived) - { - const char *zmail; - - zmail = zfgetstring (&sSendmail); - if (*zmail != '\0') - { - if (! fmail_transfer (TRUE, zfgetstring (&sSenduser), - zmail, zwhy, - zfgetstring (&sSendfrom), - zLocalname, - zfgetstring (&sSendto), - zfgetstring (&sSendtosys), - (const char *) NULL)) - f = FALSE; - } - - if (pSendseq != NULL) - { - if (! fsysdep_did_work (pSendseq)) - f = FALSE; - pSendseq = NULL; - } - } - else - { - /* If the transfer failed, we only try to save the file and send - mail if it was requested locally (in which case pSendseq != - NULL) and it will never succeed. We send mail to sSendmail - if defined, otherwise to sSenduser. I hope this is - reasonable. */ - if (pSendseq != NULL && fnever) - { - if (! fmail_transfer (FALSE, - zfgetstring (&sSenduser), - zfgetstring (&sSendmail), - zwhy, - zfgetstring (&sSendfrom), - zLocalname, - zfgetstring (&sSendto), - zfgetstring (&sSendtosys), - zsysdep_save_temp_file (pSendseq))) - f = FALSE; - - if (! fsysdep_did_work (pSendseq)) - f = FALSE; - pSendseq = NULL; - } - } - - eSendfile = EFILECLOSED; - uffreestring (&sSendfrom); - uffreestring (&sSendto); - uffreestring (&sSendtosys); - uffreestring (&sSenduser); - uffreestring (&sSendmail); - - return f; -} - -/* Some error occurred while sending a file. Mark an error and let - fsent_file handle everything else. This used to differentiate - between temporary and permanent errors, but I've decided that all - transmission errors are temporary. */ - -void -usendfile_error () -{ - fSenderror = TRUE; -} - -/* Information we keep for the file being received. We have to be - able to move the file into its final location with the correct - mode, we have to be able to send mail to the user when the transfer - is finished, we have to be able to report error messages sensibly, - and we have to be able to clear this receive request out of the - work queue if we initiated the receive. */ - -/* Work queue sequence number. */ -static pointer pRecseq; -/* File name being transferred from. */ -static struct sstring sRecfrom; -/* File name being transferred to. */ -static struct sstring sRecto; -/* System being transferred from. */ -static struct sstring sRecfromsys; -/* Requesting user name. */ -static struct sstring sRecuser; -/* Final file mode. */ -static unsigned int iRecmode; -/* User to send mail to. */ -static struct sstring sRecmail; -/* Temporary file name (as returned by esysdep_open_receive). */ -static struct sstring sRectemp; -/* Start time. */ -static long iRecstart_secs; -static long iRecstart_micros; -/* Indicate whether we had an error during the transfer. */ -static boolean fRecerror; - -/* Store information about a file being received. */ - -boolean -fstore_recfile (e, pseq, zfrom, zto, zfromsys, zuser, imode, zmail, ztemp) - openfile_t e; - pointer pseq; - const char *zfrom; - const char *zto; - const char *zfromsys; - const char *zuser; - unsigned int imode; - const char *zmail; - const char *ztemp; -{ -#if DEBUG > 0 - if (ffileisopen (eRecfile)) - ulog (LOG_FATAL, "fstore_recfile: In progress"); -#endif - - if (! ffsetstring (&sRecfrom, zfrom) - || ! ffsetstring (&sRecto, zto) - || ! ffsetstring (&sRecfromsys, zfromsys) - || ! ffsetstring (&sRecuser, zuser) - || ! ffsetstring (&sRecmail, zmail) - || ! ffsetstring (&sRectemp, ztemp)) - { - (void) ffileclose (e); - (void) remove (ztemp); - return FALSE; - } - - eRecfile = e; - pRecseq = pseq; - iRecmode = imode; - iRecstart_secs = isysdep_process_time (&iRecstart_micros); - - fRecerror = FALSE; - - return TRUE; -} - -/* Finish up after receiving a file. The argument indicates whether - the data was received correctly. We do not confirm the file - reception to the other system unless this function returns TRUE. - This may be called when no file receive is in progress if a fatal - program error occurs. The zwhy and fnever arguments are valid if - fsent is FALSE; fnever is TRUE if the file receive can never - succeed. */ - -boolean -freceived_file (fsent, cbytes, zwhy, fnever) - boolean fsent; - long cbytes; - const char *zwhy; - boolean fnever; -{ - long isecs, imicros; - - if (fRecerror) - fsent = FALSE; - - if (ffileisopen (eRecfile)) - { - if (! ffileclose (eRecfile)) - { - if (fsent) - { - zwhy = strerror (errno); - fnever = FALSE; - ulog (LOG_ERROR, "close: %s", zwhy); - } - fsent = FALSE; - } - } - - if (fsent) - { - if (! fsysdep_move_file (zfgetstring (&sRectemp), - zfgetstring (&sRecto), - iRecmode, TRUE, - (pRecseq != NULL - ? zfgetstring (&sRecuser) - : (const char *) NULL))) - { - zwhy = "could not move to final location"; - fnever = TRUE; - fsent = FALSE; - } - } - else - (void) remove (zfgetstring (&sRectemp)); - - isecs = isysdep_process_time (&imicros); - imicros -= iRecstart_micros; - if (imicros < 0) - { - imicros += 1000000; - isecs--; - } - isecs -= iRecstart_secs; - - ustats (fsent, zfgetstring (&sRecuser), zfgetstring (&sRecfromsys), - FALSE, cbytes, isecs, imicros); - - if (fsent) - { - const char *zmail; - - zmail = zfgetstring (&sRecmail); - if (*zmail != '\0') - (void) fmail_transfer (TRUE, zfgetstring (&sRecuser), - zmail, zwhy, - zfgetstring (&sRecfrom), - zfgetstring (&sRecfromsys), - zfgetstring (&sRecto), - zLocalname, (const char *) NULL); - - if (pRecseq != NULL) - { - if (! fsysdep_did_work (pRecseq)) - fsent = FALSE; - pRecseq = NULL; - } - } - else - { - /* If the transfer failed, we send mail if it was requested - locally and if it can never succeed. */ - if (pRecseq != NULL && fnever) - { - (void) fmail_transfer (FALSE, - zfgetstring (&sRecuser), - zfgetstring (&sRecmail), - zwhy, - zfgetstring (&sRecfrom), - zfgetstring (&sRecfromsys), - zfgetstring (&sRecto), - zLocalname, (const char *) NULL); - if (! fsysdep_did_work (pRecseq)) - fsent = FALSE; - pRecseq = NULL; - } - } - - eRecfile = EFILECLOSED; - uffreestring (&sRecfrom); - uffreestring (&sRecto); - uffreestring (&sRecfromsys); - uffreestring (&sRecuser); - uffreestring (&sRecmail); - uffreestring (&sRectemp); - - return fsent; -} - -/* Some error occurred while receiving a file. Note that we had an - error, so that when we close up we know that something went wrong. - We leave the file open because it's easier to handle everything in - freceived_file. This used to differentiate between permanent - errors and temporary errors, but I've decided that all errors that - occur while the file is being transferred are temporary. */ - -void -urecfile_error () -{ - fRecerror = TRUE; -} - -/* There was some sort of protocol error while receiving the file, - so we want to try it again. We must truncate the file. */ - -boolean -frecfile_rewind () -{ - eRecfile = esysdep_truncate (eRecfile, zfgetstring (&sRectemp)); - if (! ffileisopen (eRecfile)) - { - urecfile_error (); - return FALSE; - } - return TRUE; -} - -/* Send mail about a file transfer. We send to the given mailing - address if there is one, otherwise to the user. */ - -boolean -fmail_transfer (fsuccess, zuser, zmail, zwhy, zfromfile, zfromsys, - ztofile, ztosys, zsaved) - boolean fsuccess; - const char *zuser; - const char *zmail; - const char *zwhy; - const char *zfromfile; - const char *zfromsys; - const char *ztofile; - const char *ztosys; - const char *zsaved; -{ - const char *zsendto; - const char *az[20]; - int i; - - if (zmail != NULL && *zmail != '\0') - zsendto = zmail; - else - zsendto = zuser; - - i = 0; - az[i++] = "The file\n\t"; - az[i++] = zfromsys; - az[i++] = "!"; - az[i++] = zfromfile; - if (fsuccess) - az[i++] = "\nwas successfully transferred to\n\t"; - else - az[i++] = "\ncould not be transferred to\n\t"; - az[i++] = ztosys; - az[i++] = "!"; - az[i++] = ztofile; - az[i++] = "\nas requested by\n\t"; - az[i++] = zuser; - if (! fsuccess) - { - az[i++] = "\nfor the following reason:\n\t"; - az[i++] = zwhy; - az[i++] = "\n"; - } - if (zsaved != NULL) - { - az[i++] = zsaved; - az[i++] = "\n"; - } - - return fsysdep_mail (zsendto, - fsuccess ? "UUCP succeeded" : "UUCP failed", - i, az); -} diff --git a/gnu/libexec/uucp/getopt.c b/gnu/libexec/uucp/getopt.c deleted file mode 100644 index 71f5cb6e86aa..000000000000 --- a/gnu/libexec/uucp/getopt.c +++ /dev/null @@ -1,682 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu - before changing it! - - Copyright (C) 1987, 88, 89, 90, 91, 1992 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. */ - -#ifndef lint -static char rcsid[] = "$Id: getopt.c,v 1.2 1993/08/02 17:25:05 mycroft Exp $"; -#endif /* not lint */ - -/* AIX requires this to be the first thing in the file. */ -#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__ */ - -#ifdef LIBC -/* For when compiled as part of the GNU C library. */ -#include -#endif - -#include - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#undef alloca -#include -#include -#else /* Not GNU C library. */ -#define __alloca alloca -#endif /* GNU C library. */ - - -#ifndef __STDC__ -#define const -#endif - -/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a - long-named option. Because this is not POSIX.2 compliant, it is - being phased out. */ -#define GETOPT_COMPAT - -/* 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 POSIXLY_CORRECT 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 "getopt.h" - -/* 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 - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the 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; - -#ifdef __GNU_LIBRARY__ -#include -#define my_index strchr -#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) -#else - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -char *getenv (); - -static char * -my_index (string, chr) - char *string; - int chr; -{ - while (*string) - { - if (*string == chr) - return string; - string++; - } - return 0; -} - -static void -my_bcopy (from, to, size) - char *from, *to; - int size; -{ - int i; - for (i = 0; i < size; i++) - to[i] = from[i]; -} -#endif /* GNU C library. */ - -/* 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. */ - - my_bcopy (&argv[first_nonopt], temp, nonopts_size); - my_bcopy (&argv[last_nonopt], &argv[first_nonopt], - (optind - last_nonopt) * sizeof (char *)); - my_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 - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - int option_index; - - 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 = NULL; - - /* 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 ("POSIXLY_CORRECT") != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - } - - 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 ((char **) 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') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - 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 ((char **) 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') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - { - 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 - + (longopts != NULL && argv[optind][1] == '-')); - } - - if (longopts != NULL - && ((argv[optind][0] == '-' - && (argv[optind][1] == '-' || long_only)) -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - )) - { - const struct option *p; - char *s = nextchar; - int exact = 0; - int ambig = 0; - const struct option *pfound = NULL; - int indfound; - - while (*s && *s != '=') - s++; - - /* Test all options for either exact match or abbreviated matches. */ - for (p = longopts, 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 == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*s) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = s + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - else - /* +option or -option */ - 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 - { - if (opterr) - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, "%s: unrecognized option `--%s'\n", - argv[0], nextchar); - else - /* +option or -option */ - 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 = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - optind++; - - if (temp == NULL || c == ':') - { - if (opterr) - { - 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 = NULL; - } - 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) - 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 = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -#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/gnu/libexec/uucp/getopt.h b/gnu/libexec/uucp/getopt.h deleted file mode 100644 index a31e4e82123d..000000000000 --- a/gnu/libexec/uucp/getopt.h +++ /dev/null @@ -1,124 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992 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. - - $Id: getopt.h,v 1.2 1993/08/02 17:25:06 mycroft Exp $ -*/ - -#ifndef _GETOPT_H_ -#define _GETOPT_H_ - -/* Ian Lance Taylor added the following defines for - Taylor UUCP. This avoids reported conflicts with system getopt - definitions. */ -#define getopt gnu_getopt -#define optarg gnu_optarg -#define optind gnu_optind -#define opterr gnu_opterr - -/* 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. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, 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 -{ -#ifdef __STDC__ - const char *name; -#else - char *name; -#endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -enum _argtype -{ - no_argument, - required_argument, - optional_argument -}; - -#ifdef __STDC__ -extern int getopt (int argc, char *const *argv, const char *shortopts); -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* not __STDC__ */ - -#endif /* _GETOPT_H_ */ diff --git a/gnu/libexec/uucp/log.c b/gnu/libexec/uucp/log.c deleted file mode 100644 index 435a49309757..000000000000 --- a/gnu/libexec/uucp/log.c +++ /dev/null @@ -1,740 +0,0 @@ -/* log.c - Routines to add entries to the log files. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: log.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.29 1992/04/01 21:58:35 ian - Added CLOSE_LOGFILES configuration parameter - - Revision 1.28 1992/03/28 19:40:26 ian - Close log and statistics file at each master/slave role switch - - Revision 1.27 1992/03/15 04:51:17 ian - Keep an array of signals we've received rather than a single variable - - Revision 1.26 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.25 1992/03/08 16:42:41 ian - Ted Lindgreen: report port and login name in log file - - Revision 1.24 1992/03/04 00:36:44 ian - Michael Richardson: better chat script debugging - - Revision 1.23 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.22 1992/02/19 19:36:07 ian - Rearranged time functions - - Revision 1.21 1992/02/18 04:33:38 ian - Don't use headers when outputting to terminal - - Revision 1.20 1992/02/14 07:51:49 ian - Michael Nolan: don't refer to eLdebug if DEBUG is 0 - - Revision 1.19 1992/02/08 20:33:57 ian - Handle all possible signals raised by abort - - Revision 1.18 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.17 1992/02/01 00:51:28 ian - Michael Nolan: call abort if SIGABRT is not defined - - Revision 1.16 1992/01/28 04:51:34 ian - Marty Shannon: don't report failed transfers with BNU logging - - Revision 1.15 1992/01/16 18:07:18 ian - Niels Baggesen: add FAILED to end of xferstats line if appropriate - - Revision 1.14 1992/01/12 19:32:29 ian - Handle HAVE_BNU_LOGGING with no %s in zLogfile - - Revision 1.13 1992/01/05 04:41:48 ian - Tweaked HAVE_V2_LOGGING output slightly - - Revision 1.12 1991/12/29 05:00:27 ian - Was not allocating enough space in zldate_and_time - - Revision 1.11 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.10 1991/12/29 02:59:50 ian - Lele Gaifax: put full year in log file - - Revision 1.9 1991/12/21 23:10:43 ian - Terry Gardner: record failed file transfers in statistics file - - Revision 1.8 1991/12/18 03:54:14 ian - Made error messages to terminal appear more normal - - Revision 1.7 1991/12/18 03:14:52 ian - Use a fixed number of fields in log messages - - Revision 1.6 1991/12/17 07:09:58 ian - Record statistics in fractions of a second - - Revision 1.5 1991/12/13 04:02:23 ian - David Nugent: move ERROR: from start of line to after date and time - - Revision 1.4 1991/12/11 04:21:37 ian - Arne Ludwig: merge in Arne Ludwig's patches for V2 and BNU style logging - - Revision 1.3 1991/11/07 20:32:04 ian - Chip Salzenberg: allow ANSI_C to be defined in conf.h - - Revision 1.2 1991/09/19 03:23:34 ian - Chip Salzenberg: append to private debugging file, don't overwrite it - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char log_rcsid[] = "$Id: log.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#if ANSI_C -#include -#endif - -#if HAVE_TIME_H -#include -#endif - -#if ! HAVE_TIME_T -#if HAVE_SYS_TIME_T -#include -#endif /* HAVE_SYS_TIME_T */ -#endif /* ! HAVE_TIME_T */ - -#include "system.h" - -/* External functions. */ -extern int fflush (), fclose (); -#if HAVE_VFPRINTF -extern int vfprintf (); -#endif - -/* Static functions. */ - -static const char *zldate_and_time P((void)); - -/* The function to call when a LOG_FATAL error occurs. */ -static void (*fLfatal) P((void)); - -/* Whether to go to a file. */ -static boolean fLfile; - -/* ID number. */ -static int iLid; - -/* The current user name. */ -static char *zLuser; - -/* The current system name. */ -static char *zLsystem; - -/* The current device name. */ -char *zLdevice; - -/* The open log file. */ -static FILE *eLlog; - -/* Whether we have tried to open the log file. We need this because - we don't want to keep trying to open the log file if we failed the - first time. It can't be static because under HAVE_BNU_LOGGING we - may have to write to various different log files. */ -static boolean fLlog_tried; - -#if DEBUG > 1 -/* The open debugging file. */ -static FILE *eLdebug; - -/* Whether we've tried to open the debugging file. */ -static boolean fLdebug_tried; - -/* Whether we've written out any debugging information. */ -static boolean fLdebugging; -#endif - -/* The open statistics file. */ -static FILE *eLstats; - -/* Whether we've tried to open the statistics file. */ -static boolean fLstats_tried; - -/* The array of signals. The elements are only set to TRUE by the - default signal handler. They are only set to FALSE if we don't - care whether we got the signal or not. */ -volatile sig_atomic_t afSignal[INDEXSIG_COUNT]; - -/* The array of signals to log. The elements are only set to TRUE by - the default signal handler. They are set to FALSE when the signal - is logged in ulog. This means that if a signal comes in at just - the right time we won't log it (or, rather, we'll log it once - instead of twice), but that is not a catatrophe. */ -volatile sig_atomic_t afLog_signal[INDEXSIG_COUNT]; - -/* Signal names to use when logging signals. */ -static const char * const azSignal_names[INDEXSIG_COUNT] = INDEXSIG_NAMES; - -/* Set the function to call on a LOG_FATAL error. */ - -void -ulog_fatal_fn (pfn) - void (*pfn) P((void)); -{ - fLfatal = pfn; -} - -/* Decide whether to send log message to the file or not. */ - -void -ulog_to_file (ffile) - boolean ffile; -{ - fLfile = ffile; -} - -/* Set the ID number. This will be called by the usysdep_initialize - if there is something sensible to set it to. */ - -void -ulog_id (i) - int i; -{ - iLid = i; -} - -/* Set the user we are making log entries for. The arguments will be - copied into memory. */ - -void -ulog_user (zuser) - const char *zuser; -{ - if (zuser == NULL - || zLuser == NULL - || strcmp (zuser, zLuser) != 0) - { - xfree ((pointer) zLuser); - if (zuser == NULL) - zLuser = NULL; - else - zLuser = xstrdup (zuser); - } -} - -/* Set the system name we are making log entries for. The name is copied - into memory. */ - -void -ulog_system (zsystem) - const char *zsystem; -{ - if (zsystem == NULL - || zLsystem == NULL - || strcmp (zsystem, zLsystem) != 0) - { - xfree ((pointer) zLsystem); - if (zsystem == NULL) - zLsystem = NULL; - else - zLsystem = xstrdup (zsystem); -#if HAVE_BNU_LOGGING - /* Under BNU logging we now must write to a different log file. */ - if (eLlog != NULL) - { - (void) fclose (eLlog); - eLlog = NULL; - fLlog_tried = FALSE; - } -#endif /* HAVE_BNU_LOGGING */ - } -} - -/* Set the device name. This is copied into memory. */ - -void -ulog_device (zdevice) - const char *zdevice; -{ - if (zdevice == NULL - || zLdevice == NULL - || strcmp (zdevice, zLdevice) != 0) - { - xfree ((pointer) zLdevice); - if (zdevice == NULL) - zLdevice = NULL; - else - zLdevice = xstrdup (zdevice); - } -} - -/* Make a log entry. We make a token concession to non ANSI_C systems, - but it clearly won't always work. */ - -#if ! ANSI_C -#undef HAVE_VFPRINTF -#endif - -/*VARARGS2*/ -#if HAVE_VFPRINTF -void -ulog (enum tlog ttype, const char *zmsg, ...) -#else -void -ulog (ttype, zmsg, a, b, c, d, f, g, h, i, j) - enum tlog ttype; - const char *zmsg; -#endif -{ -#if HAVE_VFPRINTF - va_list parg; -#endif - FILE *e, *edebug; - boolean fstart, fend; - const char *zhdr, *zstr; - - /* Log any received signal. We do it this way to avoid calling ulog - from the signal handler. A few routines call ulog to get this - message out with zmsg == NULL. */ - { - static boolean fdoing_sigs; - - if (! fdoing_sigs) - { - int isig; - - fdoing_sigs = TRUE; - for (isig = 0; isig < INDEXSIG_COUNT; isig++) - { - if (afLog_signal[isig]) - { - afLog_signal[isig] = FALSE; - ulog (LOG_ERROR, "Got %s signal", azSignal_names[isig]); - } - } - fdoing_sigs = FALSE; - } - } - - if (zmsg == NULL) - return; - -#if DEBUG > 1 - /* If we've had a debugging file open in the past, then we want to - write all log file entries to the debugging file even if it's - currently closed. */ - if (fLfile - && eLdebug == NULL - && ! fLdebug_tried - && (fLdebugging || (int) ttype >= (int) LOG_DEBUG)) - { - fLdebug_tried = TRUE; - eLdebug = esysdep_fopen (zDebugfile, FALSE, TRUE, TRUE); - fLdebugging = TRUE; - } -#endif /* DEBUG > 1 */ - - if (! fLfile) - e = stderr; -#if DEBUG > 1 - else if ((int) ttype >= (int) LOG_DEBUG) - { - e = eLdebug; - - /* If we can't open the debugging file, don't output any - debugging messages. */ - if (e == NULL) - return; - } -#endif /* DEBUG > 1 */ - else - { - if (eLlog == NULL && ! fLlog_tried) - { - fLlog_tried = TRUE; -#if ! HAVE_BNU_LOGGING - eLlog = esysdep_fopen (zLogfile, TRUE, TRUE, TRUE); -#else /* HAVE_BNU_LOGGING */ - { - const char *zsys; - char *zfile; - - /* We want to write to .Log/program/system, e.g. - .Log/uucico/uunet. The system name may not be set. */ - if (zLsystem == NULL) - zsys = "ANY"; - else - zsys = zLsystem; - - zfile = (char *) alloca (strlen (zLogfile) - + strlen (abProgram) - + strlen (zsys) - + 1); - sprintf (zfile, zLogfile, abProgram, zsys); - eLlog = esysdep_fopen (zfile, TRUE, TRUE, TRUE); - } -#endif /* HAVE_BNU_LOGGING */ - - if (eLlog == NULL) - { - /* We can't open the log file. We don't even have a - safe way to report this problem, since we may not be - able to write to stderr (it may, for example, be - attached to the incoming call). */ - if (fLfatal != NULL) - (*fLfatal) (); - usysdep_exit (FALSE); - } - } - - e = eLlog; - - /* eLlog might be NULL here because we might try to open the log - file recursively via esysdep_fopen. */ - if (e == NULL) - return; - } - - edebug = NULL; -#if DEBUG > 1 - if ((int) ttype < (int) LOG_DEBUG) - edebug = eLdebug; -#endif - - fstart = TRUE; - fend = TRUE; - - switch (ttype) - { - case LOG_NORMAL: - zhdr = ""; - break; - case LOG_ERROR: - zhdr = "ERROR: "; - break; - case LOG_FATAL: - zhdr = "FATAL: "; - break; -#if DEBUG > 1 - case LOG_DEBUG: - zhdr = "DEBUG: "; - break; - case LOG_DEBUG_START: - zhdr = "DEBUG: "; - fend = FALSE; - break; - case LOG_DEBUG_CONTINUE: - zhdr = NULL; - fstart = FALSE; - fend = FALSE; - break; - case LOG_DEBUG_END: - zhdr = NULL; - fstart = FALSE; - break; -#endif - default: - zhdr = "???: "; - break; - } - - if (fstart) - { - if (! fLfile) - { - fprintf (e, "%s: ", abProgram); - if (edebug != NULL) - fprintf (edebug, "%s: ", abProgram); - } - else - { -#if HAVE_TAYLOR_LOGGING - fprintf (e, "%s ", abProgram); - if (edebug != NULL) - fprintf (edebug, "%s ", abProgram); -#else /* ! HAVE_TAYLOR_LOGGING */ - fprintf (e, "%s ", zLuser == NULL ? "uucp" : zLuser); - if (edebug != NULL) - fprintf (edebug, "%s ", zLuser == NULL ? "uucp" : zLuser); -#endif /* HAVE_TAYLOR_LOGGING */ - - fprintf (e, "%s ", zLsystem == NULL ? "-" : zLsystem); - if (edebug != NULL) - fprintf (edebug, "%s ", zLsystem == NULL ? "-" : zLsystem); - -#if HAVE_TAYLOR_LOGGING - fprintf (e, "%s ", zLuser == NULL ? "-" : zLuser); - if (edebug != NULL) - fprintf (edebug, "%s ", zLuser == NULL ? "-" : zLuser); -#endif /* HAVE_TAYLOR_LOGGING */ - - zstr = zldate_and_time (); - fprintf (e, "(%s", zstr); - if (edebug != NULL) - fprintf (edebug, "(%s", zstr); - - if (iLid != 0) - { -#if ! HAVE_BNU_LOGGING -#if HAVE_TAYLOR_LOGGING - fprintf (e, " %d", iLid); - if (edebug != NULL) - fprintf (edebug, " %d", iLid); -#else /* ! HAVE_TAYLOR_LOGGING */ - fprintf (e, "-%d", iLid); - if (edebug != NULL) - fprintf (edebug, "-%d", iLid); -#endif /* ! HAVE_TAYLOR_LOGGING */ -#else /* HAVE_BNU_LOGGING */ - - /* I assume that the second number here is meant to be - some sort of file sequence number, and that it should - correspond to the sequence number in the statistics - file. I don't have any really convenient way to do - this, so I won't unless somebody thinks it's very - important. */ - fprintf (e, ",%d,%d", iLid, 0); - if (edebug != NULL) - fprintf (edebug, ",%d,%d", iLid, 0); -#endif /* HAVE_BNU_LOGGING */ - } - - fprintf (e, ") "); - if (edebug != NULL) - fprintf (edebug, ") "); - - fprintf (e, "%s", zhdr); - if (edebug != NULL) - fprintf (edebug, "%s", zhdr); - } - } - -#if HAVE_VFPRINTF - va_start (parg, zmsg); - vfprintf (e, zmsg, parg); - va_end (parg); - if (edebug != NULL) - { - va_start (parg, zmsg); - vfprintf (edebug, zmsg, parg); - va_end (parg); - } -#else /* ! HAVE_VFPRINTF */ - fprintf (e, zmsg, a, b, c, d, f, g, h, i, j); - if (edebug != NULL) - fprintf (edebug, zmsg, a, b, c, d, f, g, h, i, j); -#endif /* ! HAVE_VFPRINTF */ - - if (fend) - { - fprintf (e, "\n"); - if (edebug != NULL) - fprintf (edebug, "\n"); - } - - (void) fflush (e); - if (edebug != NULL) - (void) fflush (edebug); - - if (ttype == LOG_FATAL) - { - if (fLfatal != NULL) - (*fLfatal) (); - usysdep_exit (FALSE); - } - -#if CLOSE_LOGFILES - ulog_close (); -#endif -} - -/* Close the log file. There's nothing useful we can do with errors, - so we don't check for them. */ - -void -ulog_close () -{ - /* Make sure we logged any signal we received. */ - ulog (LOG_ERROR, (const char *) NULL); - - if (eLlog != NULL) - { - (void) fclose (eLlog); - eLlog = NULL; - fLlog_tried = FALSE; - } - -#if DEBUG > 1 - if (eLdebug != NULL) - { - (void) fclose (eLdebug); - eLdebug = NULL; - fLdebug_tried = FALSE; - } -#endif -} - -/* Add an entry to the statistics file. We may eventually want to put - failed file transfers in here, but we currently do not. */ - -void -ustats (fsucceeded, zuser, zsystem, fsent, cbytes, csecs, cmicros) - boolean fsucceeded; - const char *zuser; - const char *zsystem; - boolean fsent; - long cbytes; - long csecs; - long cmicros; -{ - long cbps; - - /* On a system which can determine microseconds we might very well - have both csecs == 0 and cmicros == 0. */ - if (csecs == 0 && cmicros == 0) - cbps = 0; - else - cbps = (1000 * cbytes) / (csecs * 1000 + cmicros / 1000); - - if (eLstats == NULL) - { - if (fLstats_tried) - return; - fLstats_tried = TRUE; - eLstats = esysdep_fopen (zStatfile, TRUE, TRUE, TRUE); - if (eLstats == NULL) - return; - } - -#if HAVE_TAYLOR_LOGGING - fprintf (eLstats, - "%s %s (%s) %s%s %ld bytes in %ld.%03ld seconds (%ld bytes/sec)\n", - zuser, zsystem, zldate_and_time (), - fsucceeded ? "" : "failed after ", - fsent ? "sent" : "received", - cbytes, csecs, cmicros / 1000, cbps); -#endif /* HAVE_TAYLOR_LOGGING */ -#if HAVE_V2_LOGGING - fprintf (eLstats, - "%s %s (%s) (%ld) %s %s %ld bytes %ld seconds\n", - zuser, zsystem, zldate_and_time (), - (long) time ((time_t *) NULL), - fsent ? "sent" : "received", - fsucceeded ? "data" : "failed after", - cbytes, csecs + cmicros / 500000); -#endif /* HAVE_V2_LOGGING */ -#if HAVE_BNU_LOGGING - { - static int iseq; - - /* I don't know what the 'M' or the 'C' mean. This format expects - us to get the time in fractions of a second; on Unix we could - use times to do this, and we probably should. The sequence - number should probably correspond to the sequence number in the - log file, but that is currently always 0; using this fake - sequence number will still at least reveal which transfers are - from different calls. We don't report a failed data transfer - with this format. */ - if (! fsucceeded) - return; - ++iseq; - fprintf (eLstats, - "%s!%s M (%s) (C,%d,%d) [%s] %s %ld / %ld.%03ld secs, %ld %s\n", - zsystem, zuser, zldate_and_time (), iLid, iseq, - zLdevice == NULL ? "unknown" : zLdevice, - fsent ? "->" : "<-", - cbytes, csecs, cmicros / 1000, cbps, - "bytes/sec"); - } -#endif /* HAVE_BNU_LOGGING */ - - (void) fflush (eLstats); - -#if CLOSE_LOGFILES - ustats_close (); -#endif -} - -/* Close the statistics file. */ - -void -ustats_close () -{ - if (eLstats != NULL) - { - if (fclose (eLstats) != 0) - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - eLstats = NULL; - fLstats_tried = FALSE; - } -} - -/* Return the date and time in a form used for a log entry. */ - -static const char * -zldate_and_time () -{ - long isecs, imicros; - struct tm s; -#if HAVE_TAYLOR_LOGGING - static char ab[sizeof "1991-12-31 12:00:00.00"]; -#endif -#if HAVE_V2_LOGGING - static char ab[sizeof "12/31-12:00"]; -#endif -#if HAVE_BNU_LOGGING - static char ab[sizeof "12/31-12:00:00"]; -#endif - - isecs = isysdep_time (&imicros); - usysdep_localtime (isecs, &s); - -#if HAVE_TAYLOR_LOGGING - sprintf (ab, "%04d-%02d-%02d %02d:%02d:%02d.%02d", - s.tm_year + 1900, s.tm_mon + 1, s.tm_mday, s.tm_hour, - s.tm_min, s.tm_sec, (int) (imicros / 10000)); -#endif -#if HAVE_V2_LOGGING - sprintf (ab, "%d/%d-%02d:%02d", s.tm_mon + 1, s.tm_mday, - s.tm_hour, s.tm_min); -#endif -#if HAVE_BNU_LOGGING - sprintf (ab, "%d/%d-%02d:%02d:%02d", s.tm_mon + 1, s.tm_mday, - s.tm_hour, s.tm_min, s.tm_sec); -#endif - - return ab; -} diff --git a/gnu/libexec/uucp/parse.c b/gnu/libexec/uucp/parse.c deleted file mode 100644 index 632947edcfd5..000000000000 --- a/gnu/libexec/uucp/parse.c +++ /dev/null @@ -1,162 +0,0 @@ -/* parse.c - Parse a UUCP command string. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: parse.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.3 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.2 1991/11/11 02:10:39 ian - Forget to set pseq field to NULL - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char parse_rcsid[] = "$Id: parse.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -/* Parse a UUCP command string into an scmd structure. This is called - by the 'g' protocol and the UNIX command file reading routines. It - destroys the string it is passed, and the scmd string pointers are - left pointing into it. It returns TRUE if the string is - successfully parsed, FALSE otherwise. */ - -boolean -fparse_cmd (zcmd, qcmd) - char *zcmd; - struct scmd *qcmd; -{ - char *z; - - z = strtok (zcmd, " \t\n"); - if (z == NULL) - return FALSE; - - qcmd->bcmd = *z; - if (qcmd->bcmd != 'S' - && qcmd->bcmd != 'R' - && qcmd->bcmd != 'X' - && qcmd->bcmd != 'H') - return FALSE; - - qcmd->pseq = NULL; - - /* Handle hangup commands specially. If it's just "H", return - the command 'H' to indicate a hangup request. If it's "HY" - return 'Y' and if it's "HN" return 'N'. */ - - if (qcmd->bcmd == 'H') - { - if (z[1] == '\0') - return TRUE; - else if (z[1] == 'Y') - { - qcmd->bcmd = 'Y'; - return TRUE; - } - else if (z[1] == 'N') - { - qcmd->bcmd = 'N'; - return TRUE; - } - else - return FALSE; - } - - if (z[1] != '\0') - return FALSE; - - z = strtok ((char *) NULL, " \t\n"); - if (z == NULL) - return FALSE; - qcmd->zfrom = z; - - z = strtok ((char *) NULL, " \t\n"); - if (z == NULL) - return FALSE; - qcmd->zto = z; - - z = strtok ((char *) NULL, " \t\n"); - if (z == NULL) - return FALSE; - qcmd->zuser = z; - - z = strtok ((char *) NULL, " \t\n"); - if (z == NULL || *z != '-') - return FALSE; - qcmd->zoptions = z + 1; - - z = strtok ((char *) NULL, " \t\n"); - if (z != NULL) - qcmd->ztemp = z; - else if (qcmd->bcmd == 'S') - return FALSE; - else - qcmd->ztemp = ""; - - z = strtok ((char *) NULL, " \t\n"); - if (z != NULL) - { - char *zend; - - qcmd->imode = (int) strtol (z, &zend, 8); - if (*zend != '\0') - return FALSE; - } - else if (qcmd->bcmd == 'S') - return FALSE; - else - qcmd->imode = 0666; - - z = strtok ((char *) NULL, " \t\n"); - if (z != NULL) - qcmd->znotify = z; - else - qcmd->znotify = ""; - - /* If the notify string is "", there may be a number of bytes. */ - qcmd->cbytes = -1; - if (strcmp (qcmd->znotify, "\"\"") == 0) - { - z = strtok ((char *) NULL, " \t\n"); - if (z != NULL) - { - char *zend; - - qcmd->znotify = ""; - qcmd->cbytes = strtol (z, &zend, 10); - if (*zend != '\0') - return FALSE; - } - } - - return TRUE; -} diff --git a/gnu/libexec/uucp/policy.h b/gnu/libexec/uucp/policy.h deleted file mode 100644 index 74c0d085d608..000000000000 --- a/gnu/libexec/uucp/policy.h +++ /dev/null @@ -1,419 +0,0 @@ -/* policy.h - Configuration file for policy decisions. To be edited on site. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Id: policy.h,v 1.2 1993/08/02 17:25:07 mycroft Exp $ -*/ - -/* This header file contains macro definitions which must be set by - each site before compilation. The first few are system - characteristics that can not be easily discovered by the - configuration script. Most are configuration decisions that must - be made by the local administrator. */ - -/* System characteristics. */ - -/* This code tries to use several ANSI C features, including - prototypes, stdarg.h, the const qualifier and the types void - (including void * pointers) and unsigned char. By default it will - use these features if the compiler defines __STDC__. If your - compiler supports these features but does not define __STDC__, you - should set ANSI_C to 1. If your compiler does not support these - features but defines __STDC__ (no compiler should do this, in my - opinion), you should set ANSI_C to 0. In most cases (or if you're - not sure) just leave the line below commented out. */ -/* #define ANSI_C 1 */ - -/* Set USE_STDIO to 1 if data files should be read using the stdio - routines (fopen, fread, etc.) rather than the UNIX unbuffered I/O - calls (open, read, etc.). Unless you know your stdio is really - rotten, you should leave this as 1. */ -#define USE_STDIO 1 - -/* Exactly one of the following macros must be set to 1. Many modern - systems support more than one of these choices through some form of - compilation environment, in which case the setting will depend on - the compilation environment you use. If you have a reasonable - choice between options, I suspect that TERMIO or TERMIOS will be - more efficient than TTY, but I have not done any head to head - comparisons. - - If you don't set any of these macros, the code below will guess. - It will doubtless be wrong on some systems. - - HAVE_BSD_TTY -- Use the 4.2BSD tty routines - HAVE_SYSV_TERMIO -- Use the System V termio routines - HAVE_POSIX_TERMIOS -- Use the POSIX termios routines - */ -#define HAVE_BSD_TTY 1 -#define HAVE_SYSV_TERMIO 0 -#define HAVE_POSIX_TERMIOS 0 - -/* This code tries to guess which terminal driver to use if you did - not make a choice above. It is in this file to make it easy to - figure out what's happening if something goes wrong. */ - -#if HAVE_BSD_TTY + HAVE_SYSV_TERMIO + HAVE_POSIX_TERMIOS == 0 -#if HAVE_CBREAK -#undef HAVE_BSD_TTY -#define HAVE_BSD_TTY 1 -#else -#undef HAVE_SYSV_TERMIO -#define HAVE_SYSV_TERMIO 1 -#endif -#endif - -/* On some systems a write to a serial port will block even if the - file descriptor has been set to not block. File transfer can be - more efficient if the package knows that a write to the serial port - will not block; however, if the write does block unexpectedly then - data loss is possible at high speeds. - - If writes to a serial port always block even when requested not to, - you should set HAVE_UNBLOCKED_WRITES to 0; otherwise you should set - it to 1. In general on System V HAVE_UNBLOCKED_WRITES should be 0 - and on BSD it should be 1. - - If HAVE_UNBLOCKED_WRITES is set to 1 when it should be 0 you may - see an unexpectedly large number of transmission errors, or, if you - have hardware handshaking, transfer times may be lower than - expected (but then, they always are). If HAVE_UNBLOCKED_WRITES is - set to 0 when it should be 1, file transfer will use more CPU time - than necessary. If you are unsure, setting HAVE_UNBLOCKED_WRITES - to 0 should always be safe. */ -#define HAVE_UNBLOCKED_WRITES 1 - -/* When the code does do a blocking write, it wants to write the - largest amount of data which the kernel will accept as a single - unit. On BSD this is typically the value of OBUFSIZ in - , usually 100. On System V this is typically the size - of a clist, CLSIZE in , which is usually 64. Define - SINGLE_WRITE to the correct value for your system. If SINGLE_WRITE - is too large, data loss may occur. If SINGLE_WRITE is too small, - file transfer will use more CPU time than necessary. If you have - no idea, 64 should work on most modern systems. */ -#define SINGLE_WRITE 100 - -/* Set TIMES_TICK to the fraction of a second which times(2) returns - (for example, if times returns 100ths of a second TIMES_TICK should - be set to 100). On a true POSIX system TIMES_TICK may simply be - defined as CLK_TCK. On some systems the environment variable HZ is - what you want for TIMES_TICK, but on some other systems HZ has the - wrong value; check the man page. If you leave this set to 0, the - code will try to guess; it will doubtless be wrong on some systems. - If TIMES_TICK is wrong the code may report incorrect file transfer - times in the statistics file, but on many systems times(2) will - actually not be used and this value will not matter at all. */ -#define TIMES_TICK 60 - -/* Set PS_PROGRAM to the program to run to get a process status, - including the arguments to pass it. This is used by ``uustat -p''. - Set HAVE_PS_MULTIPLE to 1 if a comma separated list of process - numbers may be appended (e.g. ``ps -flp1,10,100''). Otherwise ps - will be invoked several times, with a single process number append - each time. The default definitions should work on most systems, - although some may complain about the 'p' option. The second set of - definitions are appropriate for System V. To use the second set of - definitions, change the ``#if 1'' to ``#if 0''. */ -#if 1 -#define PS_PROGRAM "/bin/ps -lp" -#define HAVE_PS_MULTIPLE 0 -#else -#define PS_PROGRAM "/bin/ps -flp" -#define HAVE_PS_MULTIPLE 1 -#endif - -/* If you use other programs that also lock devices, such as cu or - uugetty, the other programs and UUCP must agree on whether a device - is locked. This is typically done by creating a lock file in a - specific directory. The lock file is named LCK.. followed by the - name of the device (UUCP and some versions of cu also lock systems - this way). If the LOCKDIR macro is defined, these lock files will - be placed in the named directory; otherwise they will be placed in - the default spool directory. On some BNU systems the lock files - are placed in /etc/locks. On some they are placed in - /usr/spool/locks. */ -/* #define LOCKDIR "/etc/locks" */ -#define LOCKDIR "/var/spool/lock" - -/* You must also specify the format of the lock files by setting - exactly one of the following macros to 1. Check an existing lock - file to decide which of these choices is more appropriate. - - The BNU style is to write the locking process ID in ASCII, passed - to ten characters, followed by a newline. - - The V2 style is to write the locking process ID as four binary - bytes in the host byte order. - - SCO lock files are similar to BNU lock files, but always lock the - lowercase version of the tty (i.e., LCK..tty2a is created if you - are locking tty2A). They are appropriate if you are using Taylor - UUCP on an SCO Unix, SCO Xenix, or SCO Open Desktop system. - - SVR4 lock files are also similar to BNU lock files, but they use a - different naming convention. The filenames are LK.xxx.yyy.zzz, - where xxx is the major device number of the device holding the - special device file, yyy is the major device number of the port - device itself, and zzz is the minor device number of the port - device. */ -#define HAVE_V2_LOCKFILES 0 -#define HAVE_BNU_LOCKFILES 1 -#define HAVE_SCO_LOCKFILES 0 -#define HAVE_SVR4_LOCKFILES 0 - -/* If your system supports Internet mail addresses, HAVE_INTERNET_MAIL - should be set to 1. This is checked by uuxqt when sending error - (or success, if requested) notifications to the person who - submitted the job. */ -#define HAVE_INTERNET_MAIL 1 - -/* Adminstrative decisions. */ - -/* Set USE_RCS_ID to 1 if you want the RCS ID strings compiled into - the executable. Leaving them out will decrease the executable - size. Leaving them in will make it easier to determine which - version you are running. */ -#define USE_RCS_ID 1 - -/* DEBUG controls how much debugging information is compiled into the - code. If DEBUG is defined as 0, no sanity checks will be done and - no debugging messages will be compiled in. If DEBUG is defined as - 1 sanity checks will be done but there will still be no debugging - messages. If DEBUG is 2 than debugging messages will be compiled - in. When initially testing, DEBUG should be 2, and you should - probably leave it at 2 unless a small reduction in the executable - file size will be very helpful. */ -#define DEBUG 2 - -/* Set the default grade to use for a uucp command if the -g option is - not used. The grades, from highest to lowest, are 0 to 9, A to Z, - a to z. */ -#define BDEFAULT_UUCP_GRADE ('N') - -/* Set the default grade to use for a uux command if the -g option is - not used. */ -#define BDEFAULT_UUX_GRADE ('N') - -/* The maximum number of times to retry calling a system which is not - answering. If this many calls to the system have failed, the - system will not be called again until the status file has been - removed (on a Unix system the status file is in the .Status - subdirectory of the main spool directory, and has the same name as - the system name). If this is set to 0 the system may be called - regardless of how many previous calls have failed. */ -#define CMAXRETRIES 26 - -/* To compile in use of the new style of configuration files described - in the documentation, set HAVE_TAYLOR_CONFIG to 1. */ -#define HAVE_TAYLOR_CONFIG 1 - -/* To compile in use of V2 style configuration files (L.sys, L-devices - and so on), set HAVE_V2_CONFIG to 1. To compile in use of BNU - style configuration files (Systems, Devices and so on) set - HAVE_BNU_CONFIG to 1. The files will be looked up in the - oldconfigdir directory as defined in the Makefile. - - You may set any or all of HAVE_TAYLOR_CONFIG, HAVE_V2_CONFIG and - HAVE_BNU_CONFIG to 1 (you must set at least one of the macros). - When looking something up (a system, a port, etc.) the new style - configuration files will be read first, followed by the V2 - configuration files, followed by the BNU configuration files. */ -#define HAVE_V2_CONFIG 0 -#define HAVE_BNU_CONFIG 0 - -/* Exactly one of the following macros must be set to 1. The exact - format of the spool directories is explained in sys3.unx. - - SPOOLDIR_V2 -- Use a Version 2 (original UUCP) style spool directory - SPOOLDIR_BSD42 -- Use a BSD 4.2 style spool directory - SPOOLDIR_BSD43 -- Use a BSD 4.3 style spool directory - SPOOLDIR_BNU -- Use a BNU (HDB) style spool directory - SPOOLDIR_ULTRIX -- Use an Ultrix style spool directory - SPOOLDIR_TAYLOR -- Use a new style spool directory - - If you are not worried about compatibility with a currently running - UUCP, use SPOOLDIR_TAYLOR. */ -#define SPOOLDIR_V2 0 -#define SPOOLDIR_BSD42 0 -#define SPOOLDIR_BSD43 0 -#define SPOOLDIR_BNU 0 -#define SPOOLDIR_ULTRIX 0 -#define SPOOLDIR_TAYLOR 1 - -/* You must select which type of logging you want by setting exactly - one of the following to 1. These control output to the log file - and to the statistics file. - - If you define HAVE_TAYLOR_LOGGING, each line in the log file will - look something like this: - - uucico uunet uucp (1991-12-10 09:04:34.45 16390) Receiving uunet/D./D.uunetSwJ72 - - and each line in the statistics file will look something like this: - - uucp uunet (1991-12-10 09:04:40.20) received 2371 bytes in 5 seconds (474 bytes/sec) - - If you define HAVE_V2_LOGGING, each line in the log file will look - something like this: - - uucico uunet uucp (12/10-09:04 16390) Receiving uunet/D./D.uunetSwJ72 - - and each line in the statistics file will look something like this: - - uucp uunet (12/10-09:04 16390) (692373862) received data 2371 bytes 5 seconds - - If you define HAVE_BNU_LOGGING, each program will by default use a - separate log file. For uucico talking to uunet, for example, it - will be /usr/spool/uucp/.Log/uucico/uunet. Each line will look - something like this: - - uucp uunet (12/10-09:04:22,16390,1) Receiving uunet/D./D.uunetSwJ72 - - and each line in the statistics file will look something like this: - - uunet!uucp M (12/10-09:04:22) (C,16390,1) [ttyXX] <- 2371 / 5.000 secs, 474 bytes/sec - - The main reason to prefer one format over another is that you may - have shell scripts which expect the files to have a particular - format. If you have none, choose whichever format you find more - appealing. */ -#define HAVE_TAYLOR_LOGGING 1 -#define HAVE_V2_LOGGING 0 -#define HAVE_BNU_LOGGING 0 - -/* If you would like the log, debugging and statistics files to be - closed after each message, set CLOSE_LOGFILES to 1. This will - permit the log files to be easily moved. If a log file does not - exist when a new message is written out, it will be created. - Setting CLOSE_LOGFILES to 1 will obviously require slightly more - processing time. */ -#define CLOSE_LOGFILES 0 - -/* The name of the default spool directory. If HAVE_TAYLOR_CONFIG is - set to 1, this may be overridden by the ``spool'' command in the - configuration file. */ -#define SPOOLDIR "/var/spool/uucp" - -/* The name of the default public directory. If HAVE_TAYLOR_CONFIG is - set to 1, this may be overridden by the ``pubdir'' command in the - configuration file. Also, a particular system may be given a - specific public directory by using the ``pubdir'' command in the - system file. */ -#define PUBDIR "/var/spool/uucppublic" - -/* The default command path. This is a space separated list of - directories. Remote command executions requested by uux are looked - up using this path. If you are using HAVE_TAYLOR_CONFIG, the - command path may be overridden for a particular system. For most - systems, you should just make sure that the programs rmail and - rnews can be found using this path. */ -#define CMDPATH "/bin /usr/bin /usr/local/bin" - -/* The default amount of free space to require for systems that do not - specify an amount with the ``free-space'' command. This is only - used when talking to another instance of Taylor UUCP; if accepting - a file would not leave at least this many bytes free on the disk, - it will be refused. */ -#define DEFAULT_FREE_SPACE (50000) - -/* It is possible for an execute job to request to be executed using - sh(1), rather than execve(2). This is such a security risk, it is - being disabled by default; to allow such jobs, set the following - macro to 1. */ -#define ALLOW_SH_EXECUTION 0 - -/* If a command executed on behalf of a remote system takes a filename - as an argument, a security breach may be possible (note that on my - system neither of the default commands, rmail and rnews, take - filename arguments). If you set ALLOW_FILENAME_ARGUMENTS to 0, all - arguments to a command will be checked; if any argument - 1) starts with ../ - 2) contains the string /../ - 3) begins with a / but does not name a file that may be sent or - received (according to the specified ``remote-send'' and - ``remote-receive'') - the command will be rejected. By default, any argument is - permitted. */ -#define ALLOW_FILENAME_ARGUMENTS 1 - -#if HAVE_TAYLOR_LOGGING - -/* The default log file when using HAVE_TAYLOR_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``logfile'' - command in the configuration file. */ -#define LOGFILE "/var/spool/uucp/Log" - -/* The default statistics file when using HAVE_TAYLOR_LOGGING. When - using HAVE_TAYLOR_CONFIG, this may be overridden by the - ``statfile'' command in the configuration file. */ -#define STATFILE "/var/spool/uucp/Stats" - -/* The default debugging file when using HAVE_TAYLOR_LOGGING. When - using HAVE_TAYLOR_CONFIG, this may be overridden by the - ``debugfile'' command in the configuration file. */ -#define DEBUGFILE "/var/spool/uucp/Debug" - -#endif /* HAVE_TAYLOR_LOGGING */ - -#if HAVE_V2_LOGGING - -/* The default log file when using HAVE_V2_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``logfile'' - command in the configuration file. */ -#define LOGFILE "/var/spool/uucp/LOGFILE" - -/* The default statistics file when using HAVE_V2_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``statfile'' - command in the configuration file. */ -#define STATFILE "/var/spool/uucp/SYSLOG" - -/* The default debugging file when using HAVE_V2_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``debugfile'' - command in the configuration file. */ -#define DEBUGFILE "/var/spool/uucp/DEBUG" - -#endif /* HAVE_V2_LOGGING */ - -#if HAVE_BNU_LOGGING - -/* The default log file when using HAVE_BNU_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``logfile'' - command in the configuration file. The first %s in the string will - be replaced by the program name (e.g. uucico); the second %s will - be replaced by the system name (if there is no appropriate system, - "ANY" will be used). No other '%' character may appear in the - string. */ -#define LOGFILE "/var/spool/uucp/.Log/%s/%s" - -/* The default statistics file when using HAVE_BNU_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``statfile'' - command in the configuration file. */ -#define STATFILE "/var/spool/uucp/.Admin/xferstats" - -/* The default debugging file when using HAVE_BNU_LOGGING. When using - HAVE_TAYLOR_CONFIG, this may be overridden by the ``debugfile'' - command in the configuration file. */ -#define DEBUGFILE "/var/spool/uucp/.Admin/audit.local" - -#endif /* HAVE_BNU_LOGGING */ diff --git a/gnu/libexec/uucp/port.c b/gnu/libexec/uucp/port.c deleted file mode 100644 index 65ae2acb6e85..000000000000 --- a/gnu/libexec/uucp/port.c +++ /dev/null @@ -1,602 +0,0 @@ -/* port.c - Port manipulation routines for the Taylor UUCP package. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: port.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.17 1992/04/01 22:31:05 ian - Initialize stdin port - - Revision 1.16 1992/03/28 19:57:22 ian - David J. MacKenzie: send port device for /Y rather than port name - - Revision 1.15 1992/03/17 01:03:03 ian - Miscellaneous cleanup - - Revision 1.14 1992/03/15 06:58:12 ian - Show fport_read and fport_write calls under DEBUG_PORT - - Revision 1.13 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.12 1992/03/04 00:36:44 ian - Michael Richardson: better chat script debugging - - Revision 1.11 1992/02/08 19:34:07 ian - Cast result of alloca - - Revision 1.10 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.9 1991/12/28 04:20:36 ian - Cleaned up debugging code - - Revision 1.8 1991/12/20 02:18:35 ian - Complete diagnostics for fport_io - - Revision 1.7 1991/12/15 03:42:33 ian - Added tprocess_chat_cmd for all chat commands, and added CMDTABTYPE_PREFIX - - Revision 1.6 1991/12/10 19:45:05 ian - Added ulog_device to record device name for log file - - Revision 1.5 1991/11/14 03:20:13 ian - Added seven-bit and reliable commands to help when selecting protocols - - Revision 1.4 1991/11/13 20:38:00 ian - Added TCP port type for connections over TCP - - Revision 1.3 1991/11/11 23:47:24 ian - Added chat-program to run a program to do a chat script - - Revision 1.2 1991/11/11 00:39:45 ian - Open port in seven bit mode, added fport_set to change to eight bit - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char port_rcsid[] = "$Id: port.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#include "port.h" - -#if DEBUG > 1 - -/* A debugging routine used when displaying buffers. */ - -int -cdebug_char (z, ichar) - char *z; - int ichar; -{ - char b; - - if (isprint (BUCHAR (ichar)) - && ichar != '\"' - && ichar != '\\') - { - *z++ = (char) ichar; - *z = '\0'; - return 1; - } - - *z++ = '\\'; - - switch (ichar) - { - case '\n': - b = 'n'; - break; - case '\r': - b = 'r'; - break; - case '\"': - b = '\"'; - break; - case '\\': - b = '\\'; - break; - default: - sprintf (z, "%03o", (unsigned int) BUCHAR (ichar)); - return strlen (z) + 1; - } - - *z++ = b; - *z = '\0'; - return 2; -} - -/* Display a buffer when debugging. */ - -void -udebug_buffer (zhdr, zbuf, clen) - const char *zhdr; - const char *zbuf; - int clen; -{ - char *z, *zalc; - int i; - - z = zalc = (char *) xmalloc (clen * 4 + 1); - for (i = 0; i < clen && i < 80; i++) - z += cdebug_char (z, zbuf[i]); - if (i < clen) - { - *z++ = '.'; - *z++ = '.'; - *z++ = '.'; - } - *z = '\0'; - - ulog (LOG_DEBUG, "%s %d \"%s\"", zhdr, clen, zalc); - xfree ((pointer) zalc); -} - -#endif /* DEBUG > 1 */ - -/* The open port. */ - -struct sport *qPort; - -/* The port dispatch table. The order of entries in this table must - be the same as the tporttype enumeration. */ - -const struct sportcmds asPortcmds[] = -{ - { fsysdep_stdin_lock, fsysdep_stdin_open, fsysdep_stdin_close, - fsysdep_stdin_reset, NULL, fsysdep_stdin_read, - fsysdep_stdin_write, fsysdep_stdin_io, fsysdep_stdin_break, - fsysdep_stdin_set, fsysdep_stdin_chat, isysdep_stdin_baud }, - { fsysdep_modem_lock, fsysdep_modem_open, fsysdep_modem_close, - fsysdep_modem_reset, fmodem_dial, fsysdep_modem_read, - fsysdep_modem_write, fsysdep_modem_io, fsysdep_modem_break, - fsysdep_modem_set, fsysdep_modem_chat, isysdep_modem_baud }, - { fsysdep_direct_lock, fsysdep_direct_open, fsysdep_direct_close, - fsysdep_direct_reset, NULL, fsysdep_direct_read, - fsysdep_direct_write, fsysdep_direct_io, fsysdep_direct_break, - fsysdep_direct_set, fsysdep_direct_chat, isysdep_direct_baud }, -#if HAVE_TCP - { ftcp_lock, ftcp_open, ftcp_close, - ftcp_reset, ftcp_dial, fsysdep_tcp_read, - fsysdep_tcp_write, fsysdep_tcp_io, NULL, - NULL, fsysdep_tcp_chat, itcp_baud }, -#endif /* HAVE_TCP */ -}; - -/* Port dispatch routines. These could probably become macros, - although the port argument would have to be evaluated twice. */ - -/* Lock a port. */ - -boolean -fport_lock (qport, fin) - struct sport *qport; - boolean fin; -{ - return (*asPortcmds[(int) qport->ttype].pflock) (qport, fin); -} - -/* The port structure we use when opening standard input as a port. */ - -static struct sport sPstdin = -{ - "stdin", - PORTTYPE_STDIN, - NULL, - 0, - NULL, - 0, - NULL -}; - -/* Open a port. */ - -boolean -fport_open (qport, ibaud, ihighbaud, fwait) - struct sport *qport; - long ibaud; - long ihighbaud; - boolean fwait; -{ - boolean fret; - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_PORT)) - { - char abspeed[20]; - - if (ibaud == (long) 0) - strcpy (abspeed, "default speed"); - else - sprintf (abspeed, "speed %ld", ibaud); - - if (qport == NULL) - ulog (LOG_DEBUG, "fport_open: Opening stdin port (%s)", - abspeed); - else if (qport->zname == NULL) - ulog (LOG_DEBUG, "fport_open: Opening unnamed port (%s)", - abspeed); - else - ulog (LOG_DEBUG, "fport_open: Opening port %s (%s)", - qport->zname, abspeed); - } -#endif - - if (qport == NULL) - { - qport = &sPstdin; - SYSDEP_STDIN_INIT (&qport->u.sstdin.s); - } - qPort = NULL; - - /* If the system provides a range of baud rates, we select the - highest baud rate supported by the port. */ - if (ihighbaud != 0) - { - ibaud = ihighbaud; - if (qport->ttype == PORTTYPE_MODEM) - { - if (qport->u.smodem.ihighbaud != 0) - { - if (qport->u.smodem.ihighbaud < ihighbaud) - ibaud = qport->u.smodem.ihighbaud; - } - else if (qport->u.smodem.ibaud != 0) - ibaud = qport->u.smodem.ibaud; - } - else if (qport->ttype == PORTTYPE_DIRECT) - { - if (qport->u.sdirect.ibaud != 0) - ibaud = qport->u.sdirect.ibaud; - } - } - - /* This will normally be overridden by the port specific open - routine. */ - ulog_device (qport->zname); - - fret = (*asPortcmds[(int) qport->ttype].pfopen) (qport, ibaud, fwait); - if (fret) - qPort = qport; - else - ulog_device ((const char *) NULL); - return fret; -} - -/* Close and unlock the port. */ - -boolean -fport_close (fsuccess) - boolean fsuccess; -{ - boolean fret; - - if (qPort == NULL) - return TRUE; - - DEBUG_MESSAGE0 (DEBUG_PORT, "fport_close: Closing port"); - - fret = (*asPortcmds[(int) qPort->ttype].pfclose) (qPort, fsuccess); - qPort = NULL; - ulog_device ((const char *) NULL); - return fret; -} - -/* Reset the port. */ - -boolean -fport_reset () -{ - DEBUG_MESSAGE0 (DEBUG_PORT, "fport_reset: Resetting port"); - - return (*asPortcmds[(int) qPort->ttype].pfreset) (qPort); -} - -/* Dial out on the port. */ - -boolean -fport_dial (qsys, pcproto_params, pqproto_params, pireliable) - const struct ssysteminfo *qsys; - int *pcproto_params; - struct sproto_param **pqproto_params; - int *pireliable; -{ - boolean (*pfdial) P((struct sport *, const struct ssysteminfo *, - int *, struct sproto_param **, int *)); - - pfdial = asPortcmds[(int) qPort->ttype].pfdial; - if (pfdial == NULL) - { - *pcproto_params = 0; - *pqproto_params = NULL; - *pireliable = 0; - return TRUE; - } - return (*pfdial) (qPort, qsys, pcproto_params, pqproto_params, - pireliable); -} - -/* Read data from the port. */ - -boolean -fport_read (zbuf, pclen, cmin, ctimeout, freport) - char *zbuf; - int *pclen; - int cmin; - int ctimeout; - boolean freport; -{ - boolean fret; - - fret = (*asPortcmds[(int) qPort->ttype].pfread) (qPort, zbuf, pclen, - cmin, ctimeout, - freport); -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_INCOMING)) - udebug_buffer ("fport_read: Read", zbuf, *pclen); - else if (FDEBUGGING (DEBUG_PORT)) - ulog (LOG_DEBUG, "fport_read: Read %d", *pclen); -#endif - - return fret; -} - -/* Write data to the port. */ - -boolean -fport_write (zbuf, clen) - const char *zbuf; - int clen; -{ -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_OUTGOING)) - udebug_buffer ("fport_write: Writing", zbuf, clen); - else if (FDEBUGGING (DEBUG_PORT)) - ulog (LOG_DEBUG, "fport_write: Writing %d", clen); -#endif - - return (*asPortcmds[(int) qPort->ttype].pfwrite) (qPort, zbuf, clen); -} - -/* Read and write data. */ - -boolean -fport_io (zwrite, pcwrite, zread, pcread) - const char *zwrite; - int *pcwrite; - char *zread; - int *pcread; -{ - boolean fret; -#if DEBUG > 1 - int cwrite = *pcwrite; - int cread = *pcread; - - if (cread <= 0 || cwrite <= 0) - ulog (LOG_FATAL, "fport_io: cread %d; cwrite %d", cread, cwrite); -#endif - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_OUTGOING)) - udebug_buffer ("fport_io: Writing", zwrite, cwrite); -#endif - - fret = (*asPortcmds[(int) qPort->ttype].pfio) (qPort, zwrite, pcwrite, - zread, pcread); - - DEBUG_MESSAGE4 (DEBUG_PORT, - "fport_io: Wrote %d of %d, read %d of %d", - *pcwrite, cwrite, *pcread, cread); - -#if DEBUG > 1 - if (*pcread > 0 && FDEBUGGING (DEBUG_INCOMING)) - udebug_buffer ("fport_io: Read", zread, *pcread); -#endif - - return fret; -} - -/* Send a break character to a port. Some port types may not support - break characters, in which case we just return TRUE. */ - -boolean -fport_break () -{ - boolean (*pfbreak) P((struct sport *)); - - DEBUG_MESSAGE0 (DEBUG_PORT, "fport_break: Sending break character"); - - pfbreak = asPortcmds[(int) qPort->ttype].pfbreak; - if (pfbreak == NULL) - return TRUE; - return (*pfbreak) (qPort); -} - -/* Change the setting of a port. Some port types may not support - this, in which case we just return TRUE. */ - -boolean -fport_set (tset) - enum tportsetting tset; -{ - boolean (*pfset) P((struct sport *, enum tportsetting)); - - DEBUG_MESSAGE1 (DEBUG_PORT, - "fport_set: Changing setting to %d", (int) tset); - - pfset = asPortcmds[(int) qPort->ttype].pfset; - if (pfset == NULL) - return TRUE; - return (*pfset) (qPort, tset); -} - -/* Run a chat program on a port. */ - -boolean -fport_run_chat (zprog) - const char *zprog; -{ - return (*asPortcmds[(int) qPort->ttype].pfchat) (qPort, zprog); -} - -/* Get the baud rate of a port. */ - -long -iport_baud () -{ - return (*asPortcmds[(int) qPort->ttype].pibaud) (qPort); -} - -/* Modem dialing routines. */ - -static boolean fpdo_dial P((struct sdialer *qdial, const char *zphone, - boolean ftranslate)); - -boolean -fmodem_dial (qport, qsys, pcproto_params, pqproto_params, pireliable) - struct sport *qport; - const struct ssysteminfo *qsys; - int *pcproto_params; - struct sproto_param **pqproto_params; - int *pireliable; -{ - if (qport->u.smodem.zdialer != NULL) - { - char *zcopy, *zdialer; - boolean ffirst; - - /* The zdialer string is a sequence of dialer/token pairs. The - dialer portion names a dialer to use. The token portion is - what \D and \T in the chat script expand to. If there is no - token for the last dialer, the phone number for the system is - used. */ - - ffirst = TRUE; - *pcproto_params = 0; - *pqproto_params = NULL; - *pireliable = 0; - - zcopy = (char *) alloca (strlen (qport->u.smodem.zdialer) + 1); - strcpy (zcopy, qport->u.smodem.zdialer); - - zdialer = strtok (zcopy, " \t"); - while (zdialer != NULL) - { - struct sdialer s; - char *ztoken; - boolean ftranslate, ftoken; - - if (! fread_dialer_info (zdialer, &s)) - return FALSE; - - ztoken = strtok ((char *) NULL, " \t"); - ftoken = ztoken != NULL; - - ftranslate = FALSE; - if (ztoken == NULL - || strcmp (ztoken, "\\D") == 0) - ztoken = qsys->zphone; - else if (strcmp (ztoken, "\\T") == 0) - { - ztoken = qsys->zphone; - ftranslate = TRUE; - } - - /* Perhaps we should accumulate the protocol parameters. */ - if (ffirst) - { - *pcproto_params = s.cproto_params; - *pqproto_params = s.qproto_params; - *pireliable = s.ireliable; - ffirst = FALSE; - } - - if (! fpdo_dial (&s, ztoken, ftranslate)) - return FALSE; - - if (! ftoken) - zdialer = NULL; - else - zdialer = strtok ((char *) NULL, " \t"); - } - - return TRUE; - } - else if (qport->u.smodem.qdialer != NULL) - { - *pcproto_params = qport->u.smodem.qdialer->cproto_params; - *pqproto_params = qport->u.smodem.qdialer->qproto_params; - *pireliable = qport->u.smodem.qdialer->ireliable; - return fpdo_dial (qport->u.smodem.qdialer, qsys->zphone, FALSE); - } - else - { - ulog (LOG_ERROR, "No dialer information"); - return FALSE; - } -} - -/* Actually use a dialer. We set up the modem (which may include - opening the dialer device), run the chat script, and finish dealing - with the modem. */ - -static boolean -fpdo_dial (qdial, zphone, ftranslate) - struct sdialer *qdial; - const char *zphone; - boolean ftranslate; -{ - if (! fsysdep_modem_begin_dial (qPort, qdial)) - return FALSE; - - if (! fchat (&qdial->schat, (const struct ssysteminfo *) NULL, qdial, - zphone, ftranslate, qPort->zname, iport_baud ())) - return FALSE; - - return fsysdep_modem_end_dial (qPort, qdial); -} - -/* Permit no carrier from a port. */ - -boolean -fport_no_carrier () -{ - return fsysdep_modem_no_carrier (qPort); -} - -/* Require carrier from a port. */ - -boolean -fport_need_carrier () -{ - return fsysdep_modem_need_carrier (qPort); -} diff --git a/gnu/libexec/uucp/port.h b/gnu/libexec/uucp/port.h deleted file mode 100644 index 00e940116f83..000000000000 --- a/gnu/libexec/uucp/port.h +++ /dev/null @@ -1,509 +0,0 @@ -/* port.h - Header file for routines which manipulate ports. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Id: port.h,v 1.2 1993/08/02 17:25:09 mycroft Exp $ -*/ - -#ifndef PORT_H - -#define PORT_H - -#include "sysdep.h" - -/* Information kept about using stdin as a port. */ - -struct sstdin_port -{ - struct ssysdep_stdin_port s; -}; - -/* The smodem_port structure holds the information we keep about a modem - port. */ - -struct smodem_port -{ - /* The device name. If NULL, use the port name instead. */ - const char *zdevice; - /* The device name to output dialer instructions to. If NULL, use - the normal port. */ - const char *zdial_device; - /* The default baud rate. */ - long ibaud; - /* The low baud rate, if a range is used. */ - long ilowbaud; - /* The high baud rate, if a range is used. */ - long ihighbaud; - /* Whether to wait for carrier detect after dialing. */ - boolean fcarrier; - /* The name of the dialer to use. */ - const char *zdialer; - /* Specific dialer information, if zdialer is NULL. */ - struct sdialer *qdialer; - /* System dependent modem port stuff. */ - struct ssysdep_modem_port s; -}; - -/* Information kept about a direct port. */ - -struct sdirect_port -{ - /* The device to use (if NULL, use the port name). */ - const char *zdevice; - /* The baud rate to communicate at. */ - long ibaud; - /* System dependent direct port stuff. */ - struct ssysdep_direct_port s; -}; - -#if HAVE_TCP - -/* Information kept about a TCP port. */ - -struct stcp_port -{ - /* The file descriptor. */ - int o; - /* The TCP port number to use. */ - const char *zport; -}; - -#endif /* HAVE_TCP */ - -/* Types of ports. The order of this enumeration must be the same - as the initializer for asPortcmds and azPtype_names. */ - -enum tporttype -{ - PORTTYPE_STDIN, - PORTTYPE_MODEM, - PORTTYPE_DIRECT -#if HAVE_TCP - , PORTTYPE_TCP -#endif -}; - -/* Port settings. Currently we only have seven bit and eight bit - ports. The only real difference between these is that seven bit - ports can do XON/XOFF. */ - -enum tportsetting -{ - PORTSETTING_EIGHT, - PORTSETTING_SEVEN -}; - -/* Reliability bits. These bits are used to decide which protocol to - run. A given protocol will have a set of these bits, and each of - them must be turned on for the port before we will permit that - protocol to be used. Of course, this can always be overridden by - using the ``protocols'' command in the system file. Reliability - bits can be specified by both ports and dialers. */ - -/* Whether a set of reliability bits is given (0 means no - information). */ -#define RELIABLE_SPECIFIED (01) - -/* Whether the connection is eight bit transparent. */ -#define RELIABLE_EIGHT (02) - -/* Whether the connection is error-free. */ -#define RELIABLE_RELIABLE (04) - -/* Whether the connection is end-to-end reliable (e.g. TCP). */ -#define RELIABLE_ENDTOEND (010) - -/* Information kept about a port. */ - -struct sport -{ - /* The name of the port. */ - const char *zname; - /* The type of the port. */ - enum tporttype ttype; - /* The protocol string for the port. */ - const char *zprotocols; - /* The number of protocol parameter entries. */ - int cproto_params; - /* The protocol parameter string. */ - struct sproto_param *qproto_params; - /* The set of reliability bits. */ - int ireliable; - /* The lock file name to use. */ - const char *zlockname; - /* The type specific information. */ - union - { - struct sstdin_port sstdin; - struct smodem_port smodem; - struct sdirect_port sdirect; -#if HAVE_TCP - struct stcp_port stcp; -#endif - } u; -}; - -/* Information kept about a dialer. */ - -struct sdialer -{ - /* The name. */ - const char *zname; - /* Chat script. */ - struct schat_info schat; - /* The ``wait for dialtone'' string. */ - const char *zdialtone; - /* The ``pause'' string. */ - const char *zpause; - /* Whether the dialer supports carrier. */ - boolean fcarrier; - /* How many seconds to wait for carrier (if fcarrier TRUE). */ - int ccarrier_wait; - /* Whether to toggle DTR. */ - boolean fdtr_toggle; - /* Whether to wait after toggling DTR. */ - boolean fdtr_toggle_wait; - /* The chat script to use when a call is complete. */ - struct schat_info scomplete; - /* The chat script to use when a call is aborted. */ - struct schat_info sabort; - /* Number of protocol parameters. */ - int cproto_params; - /* The protocol parameters. */ - struct sproto_param *qproto_params; - /* The set of reliability bits. */ - int ireliable; -}; - -/* A command table holds the functions which implement actions for - each different kind of port. */ - -struct sportcmds -{ - /* Lock the port. The fin argument is TRUE if the port is to be - used for an incoming call, FALSE for an outgoing call. */ - boolean (*pflock) P((struct sport *qport, boolean fin)); - /* Open the port. */ - boolean (*pfopen) P((struct sport *qport, long ibaud, - boolean fwait)); - /* Close the port. */ - boolean (*pfclose) P((struct sport *qport, boolean fsuccess)); - /* Reset the port so that another call may be accepted. */ - boolean (*pfreset) P((struct sport *qport)); - /* Dial a number on a port (may be NULL). This set *pcproto_params - and *pqproto_params to the protocol parameters of the dialer, if - any, and *pireliable to the reliable code of the dialer (a hack - to avoid reading dialer information twice). */ - boolean (*pfdial) P((struct sport *qport, const struct ssysteminfo *qsys, - int *pcproto_params, - struct sproto_param **pqproto_params, - int *pireliable)); - /* Read data from the port, with a timeout in seconds. When called - *pclen is the length of the buffer; on successful return *pclen - is the number of bytes read into the buffer. The cmin argument - is the minimum number of bytes to read before returning ahead - of a timeout. */ - boolean (*pfread) P((struct sport *qport, char *zbuf, int *pclen, - int cmin, int ctimeout, boolean freport)); - /* Write data to the port. */ - boolean (*pfwrite) P((struct sport *qport, const char *zbuf, - int clen)); - /* Read and write data to the port. This reads and writes data - until either all passed in data has been written or the read - buffer has been filled. When called *pcread is the size of - the read buffer and *pcwrite is the number of bytes to write; - on successful return *pcread is the number of bytes read and - *pcwrite is the number of bytes written. */ - boolean (*pfio) P((struct sport *qport, const char *zwrite, - int *pcwrite, char *zread, int *pcread)); - /* Send a break character. This may be NULL. */ - boolean (*pfbreak) P((struct sport *qport)); - /* Change the port setting. This may be NULL. */ - boolean (*pfset) P((struct sport *qport, enum tportsetting tset)); - /* Run a chat program on a port. */ - boolean (*pfchat) P((struct sport *qport, const char *zprog)); - /* Get the baud rate of a port. */ - long (*pibaud) P((struct sport *qport)); -}; - -/* Only one port can be open during an execution of uucico, and we - keep it in this global variable. */ - -extern struct sport *qPort; - -/* The table of port functions. The order of entries in this table - must match the tporttype enumeration. */ - -extern const struct sportcmds asPortcmds[]; - -/* Port functions. */ - -/* Process a port command. The pvar argument should point to a pointer - to type struct sport. */ -extern enum tcmdtabret tprocess_port_cmd P((int cargs, char **azargs, - pointer pvar, const char *zerr)); - -/* Read dialer information. */ -extern boolean fread_dialer_info P((const char *zdialer, - struct sdialer *qdialer)); - -#if HAVE_V2_CONFIG -/* Read information from the V2 configuration files. */ - -extern boolean fv2_find_port P((const char *zname, long ibaud, - long ihighbaud, struct sport *qport, - boolean (*pflock) P((struct sport *, - boolean fin)), - boolean *pffound)); -#endif /* HAVE_V2_CONFIG */ - -#if HAVE_BNU_CONFIG -/* Read information from the BNU configuration files. */ - -extern boolean fbnu_find_port P((const char *zname, long ibaud, - long ihighbaud, struct sport *qport, - boolean (*pflock) P((struct sport *, - boolean fin)), - boolean *pffound)); -extern boolean fbnu_read_dialer_info P((const char *zdialer, - struct sdialer *qdialer)); -#endif /* HAVE_BNU_CONFIG */ - -/* Lock a port. The fin argument is TRUE if the port is to be used - for an incoming call; certains type of Unix locking need this - information because they need to open the port. */ -extern boolean fport_lock P((struct sport *qport, boolean fin)); - -/* Find and lock a port. If the port name is NULL, the matching is - done only on the baud rate. If the baud rate is 0, the matching is - done only on the port name. Otherwise the port must match both - name and baud rate. If ihighbaud is not 0, the baud rate of the - port must fall between ibaud and ihighbaud. */ -extern boolean ffind_port P((const char *zname, long ibaud, - long ihighbaud, struct sport *qport, - boolean (*pflock) P((struct sport *, - boolean fin)), - boolean freport)); - -/* Open a port. If ibaud is 0, the natural baud rate of the port is - used. If ihighbaud is not 0, fport_open figures out what baud rate - to use based on the port's baud rate. */ -extern boolean fport_open P((struct sport *qport, long ibaud, - long ihighbaud, boolean fwait)); - -/* Close and unlock a port. The fsuccess argument is TRUE if the - conversation on the port was completed normally, FALSE if it is - being aborted. */ -extern boolean fport_close P((boolean fsuccess)); - -/* Reset a port such that another call may be accepted. */ -extern boolean fport_reset P((void)); - -/* Dial out on a port. This is permitted to return a set of protocol - parameters and reliability bits for the dialer (yes, it's a hack; - this permits protocol parameters to set for particular modems). */ -extern boolean fport_dial P((const struct ssysteminfo *qsys, - int *pcproto_params, - struct sproto_param **pqproto_params, - int *pireliable)); - -/* Read from a port. - zbuf -- buffer to read bytes into - *pclen on call -- length of zbuf - *pclen on successful return -- number of bytes read - cmin -- minimum number of bytes to read before returning ahead of timeout - ctimeout -- timeout in seconds, 0 if none - freport -- whether to report errors. */ -extern boolean fport_read P((char *zbuf, int *pclen, int cmin, - int ctimeout, boolean freport)); - -/* Write to a port. */ -extern boolean fport_write P((const char *zbuf, int cbytes)); - -/* Read and write to a port. This reads and writes data until either - all passed-in data has been written or the read buffer is full. - - zwrite -- buffer to write bytes from - *pcwrite on call -- number of bytes to write - *pcwrite on successful return -- number of bytes written - zread -- buffer to read bytes into - *pcread on call -- size of read buffer - *pcread on successful return -- number of bytes read. */ -extern boolean fport_io P((const char *zwrite, int *pcwrite, - char *zread, int *pcread)); - -/* Send a break character to a port. */ -extern boolean fport_break P((void)); - -/* Change the settings of a port. */ -extern boolean fport_set P((enum tportsetting tset)); - -/* Get the baud rate of a port. */ -extern long iport_baud P((void)); - -/* Do a chat script with a system. */ -extern boolean fchat P((const struct schat_info *qchat, - const struct ssysteminfo *qsys, - const struct sdialer *qdial, - const char *zphone, boolean ftranslate, - const char *zport, long ibaud)); - -/* Allow no carrier during a chat script. */ -extern boolean fport_no_carrier P((void)); - -/* Require carrier during a chat script. */ -extern boolean fport_need_carrier P((void)); - -/* Run a chat program on a port. */ -extern boolean fport_run_chat P((const char *zprog)); - -/* Modem routines used when dialing. */ - -/* Begin dialing out. This should open the dialer device if there is - one, toggle DTR if requested and possible, and tell the port to - ignore carrier. It should return FALSE on error. */ -extern boolean fsysdep_modem_begin_dial P((struct sport *qport, - struct sdialer *qdial)); - -/* Tell the modem to ignore carrier. This is called when \M is - encountered in a dialer chat script. It should return FALSE on - error. */ -extern boolean fsysdep_modem_no_carrier P((struct sport *qport)); - -/* Tell the modem that carrier is required. This is called when \m is - encountered in a dialer chat script. It should return FALSE on - error. */ -extern boolean fsysdep_modem_need_carrier P((struct sport *qport)); - -/* Finish dialing out on a modem. This should close the dialer device - if there is one. If the dialer and the port both support carrier, - the port should be told to pay attention to carrier. If it is - possible to wait for carrier to come on, and the dialer and the - port both the port support carrier, it should wait until carrier - comes on. */ -extern boolean fsysdep_modem_end_dial P((struct sport *qport, - struct sdialer *qdial)); - -/* Port routines for stdin ports. */ - -extern boolean fsysdep_stdin_lock P((struct sport *qport, boolean fin)); -extern boolean fsysdep_stdin_open P((struct sport *qport, long ibaud, - boolean fwait)); -extern boolean fsysdep_stdin_close P((struct sport *qport, - boolean fsuccess)); -extern boolean fsysdep_stdin_reset P((struct sport *qport)); -extern boolean fsysdep_stdin_read P((struct sport *qport, char *zread, - int *pcread, int cmin, - int ctimeout, boolean freport)); -extern boolean fsysdep_stdin_write P((struct sport *qport, - const char *zwrite, int cwrite)); -extern boolean fsysdep_stdin_io P((struct sport *qport, - const char *zwrite, int *pcwrite, - char *zread, int *pcread)); -extern boolean fsysdep_stdin_break P((struct sport *qport)); -extern boolean fsysdep_stdin_set P((struct sport *qport, - enum tportsetting tset)); -extern boolean fsysdep_stdin_chat P((struct sport *qport, - const char *zprog)); -extern long isysdep_stdin_baud P((struct sport *qport)); - -/* Port routines for modem ports. */ - -extern boolean fsysdep_modem_lock P((struct sport *qport, boolean fin)); -extern boolean fsysdep_modem_open P((struct sport *qport, long ibaud, - boolean fwait)); -extern boolean fsysdep_modem_close P((struct sport *qport, - boolean fsuccess)); -extern boolean fsysdep_modem_reset P((struct sport *qport)); -extern boolean fmodem_dial P((struct sport *qport, - const struct ssysteminfo *qsys, - int *pcproto_params, - struct sproto_param **pqproto_params, - int *pireliable)); -extern boolean fsysdep_modem_read P((struct sport *qport, char *zread, - int *pcread, int cmin, - int ctimeout, boolean freport)); -extern boolean fsysdep_modem_write P((struct sport *qport, - const char *zwrite, int cwrite)); -extern boolean fsysdep_modem_io P((struct sport *qport, - const char *zwrite, int *pcwrite, - char *zread, int *pcread)); -extern boolean fsysdep_modem_break P((struct sport *qport)); -extern boolean fsysdep_modem_set P((struct sport *qport, - enum tportsetting tset)); -extern boolean fsysdep_modem_chat P((struct sport *qport, - const char *zprog)); -extern long isysdep_modem_baud P((struct sport *qport)); - -/* Port routines for direct connections. */ - -extern boolean fsysdep_direct_lock P((struct sport *qport, boolean fin)); -extern boolean fsysdep_direct_open P((struct sport *qport, long ibaud, - boolean fwait)); -extern boolean fsysdep_direct_close P((struct sport *qport, - boolean fsuccess)); -extern boolean fsysdep_direct_reset P((struct sport *qport)); -extern boolean fsysdep_direct_read P((struct sport *qport, char *zread, - int *pcread, int cmin, - int ctimeout, boolean freport)); -extern boolean fsysdep_direct_write P((struct sport *qport, - const char *zwrite, int cwrite)); -extern boolean fsysdep_direct_io P((struct sport *qport, - const char *zwrite, int *pcwrite, - char *zread, int *pcread)); -extern boolean fsysdep_direct_break P((struct sport *qport)); -extern boolean fsysdep_direct_set P((struct sport *qport, - enum tportsetting tset)); -extern boolean fsysdep_direct_chat P((struct sport *qport, - const char *zprog)); -extern long isysdep_direct_baud P((struct sport *qport)); - -#if HAVE_TCP - -/* Port routines for TCP ports. */ - -extern boolean ftcp_lock P((struct sport *qport, boolean fin)); -extern boolean ftcp_open P((struct sport *qport, long ibaud, - boolean fwait)); -extern boolean ftcp_close P((struct sport *qport, boolean fsuccess)); -extern boolean ftcp_reset P((struct sport *qport)); -extern boolean ftcp_dial P((struct sport *qport, - const struct ssysteminfo *qsys, - int *pcproto_params, - struct sproto_param **pqproto_params, - int *pireliable)); -extern boolean fsysdep_tcp_read P((struct sport *qport, char *zread, - int *pcread, int cmin, - int ctimeout, boolean freport)); -extern boolean fsysdep_tcp_write P((struct sport *qport, - const char *zwrite, int cwrite)); -extern boolean fsysdep_tcp_io P((struct sport *qport, - const char *zwrite, int *pcwrite, - char *zread, int *pcread)); -extern boolean fsysdep_tcp_chat P((struct sport *qport, - const char *zprog)); -extern long itcp_baud P((struct sport *qport)); - -#endif /* HAVE_TCP */ - -#endif diff --git a/gnu/libexec/uucp/prot.c b/gnu/libexec/uucp/prot.c deleted file mode 100644 index 155a9cb459d8..000000000000 --- a/gnu/libexec/uucp/prot.c +++ /dev/null @@ -1,1255 +0,0 @@ -/* prot.c - Protocol support routines to move commands and data around. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: prot.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.21 1992/04/02 22:51:09 ian - Add gcc 2.0 format checking to ulog, and fixed discovered problems - - Revision 1.20 1992/03/30 04:49:10 ian - Niels Baggesen: added debugging types abnormal and uucp-proto - - Revision 1.19 1992/03/30 04:07:13 ian - Dirk Musstopf: remove temporary file if receive fails - - Revision 1.18 1992/03/13 22:59:25 ian - Have breceive_char go through freceive_data - - Revision 1.17 1992/03/12 19:56:10 ian - Debugging based on types rather than number - - Revision 1.16 1992/03/11 01:18:15 ian - Niels Baggesen: drop the connection on a write failure - - Revision 1.15 1992/03/11 00:18:50 ian - Save temporary file if file send fails - - Revision 1.14 1992/02/09 05:21:55 ian - Bob Denny: call fmail_transfer before fsysdep_did_work - - Revision 1.13 1992/02/08 19:41:24 ian - Simplify pffile calls for ancient stupid compilers - - Revision 1.12 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.11 1992/01/18 22:48:53 ian - Reworked sending of mail and general handling of failed transfers - - Revision 1.10 1992/01/16 18:16:58 ian - Niels Baggesen: add some debugging messages - - Revision 1.9 1991/12/31 19:34:19 ian - Added number of bytes to pffile protocol entry point - - Revision 1.8 1991/12/30 04:28:30 ian - John Theus: check for EOF to work around bug in fread - - Revision 1.7 1991/12/21 23:10:43 ian - Terry Gardner: record failed file transfers in statistics file - - Revision 1.6 1991/12/13 04:33:38 ian - Franc,ois Pinard: don't bother to warn if the final HY doesn't come in - - Revision 1.5 1991/11/15 21:00:59 ian - Efficiency hacks for 'f' and 't' protocols - - Revision 1.4 1991/11/11 19:32:03 ian - Added breceive_char to read characters through protocol buffering - - Revision 1.3 1991/11/11 04:21:16 ian - Added 'f' protocol - - Revision 1.2 1991/11/10 19:24:22 ian - Added pffile protocol entry point for file level control - - Revision 1.1 1991/11/09 18:51:50 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char prot_rcsid[] = "$Id: prot.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#include "system.h" -#include "port.h" -#include "prot.h" - -/* This file implements the generic UUCP protocol for making and - confirming file transfer requests. This involves sending ASCII - strings back and forth between the communicating daemons. It would - be possible to use a different scheme when designing a new - protocol, but this scheme is used by all traditional UUCP - protocols. */ - -/* Local functions. */ - -static boolean fpsendfile_confirm P((void)); -static boolean fprecfile_confirm P((void)); -static boolean fploop P((void)); -static void upadd_cmd P((const char *z, int clen, boolean flast)); - -/* Variables visible to the protocol-specific routines. */ - -/* Protocol structure. */ -const struct sprotocol *qProto; - -/* Buffer to hold received data. */ -char abPrecbuf[CRECBUFLEN]; - -/* Index of start of data in abPrecbuf. */ -int iPrecstart; - -/* Index of end of data (first byte not included in data) in abPrecbuf. */ -int iPrecend; - -/* Whether an unexpected shutdown is OK now; this is used to avoid - giving a warning for systems that hang up in a hurry. */ -boolean fPerror_ok; - -/* Amount of data sent for current send file; -1 means there is no - current send file. */ -static long cPsent_bytes = -1; - -/* Amount of data received for current receive file; -1 means there is - no current receive file. */ -static long cPreceived_bytes = -1; - -/* Send a file. If we are the master, we must send a command to - transfer the file and wait for a confirmation that we can begin - sending the file. If we are the slave, the master has sent us a - command and is waiting for a reply; we must confirm that we will - send the file. Either way, we begin transferring data. - - This function returns FALSE if there is a communication failure. - It returns TRUE otherwise, even if the file transfer failed. */ - -boolean -fsend_file (fmaster, e, qcmd, zmail, ztosys, fnew) - boolean fmaster; - openfile_t e; - const struct scmd *qcmd; - const char *zmail; - const char *ztosys; - boolean fnew; -{ - if (fmaster) - { - int clen; - char *zsend; - const char *zrec; - - /* Send the string - S zfrom zto zuser zoptions ztemp imode znotify - to the remote system. We put a '-' in front of the (possibly - empty) options and a '0' in front of the mode. The remote - system will ignore ztemp, but it is supposed to be sent anyhow. - If fnew is TRUE, we also send the size; in this case if ztemp - is empty we must send it as "". */ - clen = (strlen (qcmd->zfrom) + strlen (qcmd->zto) - + strlen (qcmd->zuser) + strlen (qcmd->zoptions) - + strlen (qcmd->ztemp) + strlen (qcmd->znotify) - + 50); - zsend = (char *) alloca (clen); - if (! fnew) - sprintf (zsend, "S %s %s %s -%s %s 0%o %s", qcmd->zfrom, qcmd->zto, - qcmd->zuser, qcmd->zoptions, qcmd->ztemp, qcmd->imode, - qcmd->znotify); - else - { - const char *znotify; - - if (qcmd->znotify[0] != '\0') - znotify = qcmd->znotify; - else - znotify = "\"\""; - sprintf (zsend, "S %s %s %s -%s %s 0%o %s %ld", qcmd->zfrom, - qcmd->zto, qcmd->zuser, qcmd->zoptions, qcmd->ztemp, - qcmd->imode, znotify, qcmd->cbytes); - } - - if (! (qProto->pfsendcmd) (zsend)) - { - (void) ffileclose (e); - return FALSE; - } - - /* Now we must await a reply. */ - - zrec = zgetcmd (); - if (zrec == NULL) - { - (void) ffileclose (e); - return FALSE; - } - - if (zrec[0] != 'S' - || (zrec[1] != 'Y' && zrec[1] != 'N')) - { - ulog (LOG_ERROR, "Bad response to send request"); - (void) ffileclose (e); - return FALSE; - } - - if (zrec[1] == 'N') - { - const char *zerr; - boolean fnever; - - fnever = TRUE; - if (zrec[2] == '2') - zerr = "permission denied"; - else if (zrec[2] == '4') - { - zerr = "remote cannot create work files"; - fnever = FALSE; - } - else if (zrec[2] == '6') - { - zerr = "too large for receiver now"; - fnever = FALSE; - } - else if (zrec[2] == '7') - { - /* The file is too large to ever send. */ - zerr = "too large for receiver"; - } - else - { - char *zset; - - zset = (char *) alloca (sizeof "unknown reason: " - + strlen (zrec)); - sprintf (zset, "unknown reason: %s", zrec); - zerr = zset; - } - - ulog (LOG_ERROR, "Can't send %s: %s", qcmd->zfrom, zerr); - (void) ffileclose (e); - if (fnever) - { - (void) fmail_transfer (FALSE, qcmd->zuser, zmail, zerr, - qcmd->zfrom, zLocalname, - qcmd->zto, ztosys, - zsysdep_save_temp_file (qcmd->pseq)); - (void) fsysdep_did_work (qcmd->pseq); - } - return TRUE; - } - } - else - { - char absend[20]; - - /* We are the slave; confirm that we will send the file. We - send the file mode in the confirmation string. */ - - sprintf (absend, "RY 0%o", qcmd->imode); - - if (! (qProto->pfsendcmd) (absend)) - { - (void) ffileclose (e); - return FALSE; - } - } - - /* Record the file we are sending, and let the protocol take over. */ - - if (! fstore_sendfile (e, qcmd->pseq, qcmd->zfrom, qcmd->zto, ztosys, - qcmd->zuser, zmail)) - return FALSE; - - cPsent_bytes = 0; - - /* Tell the protocol that we are starting to send a file. */ - if (qProto->pffile != NULL) - { - boolean (*pffile) P((boolean, boolean, boolean *, long)); - - /* Simplify expression for ancient compilers. */ - pffile = qProto->pffile; - if (! pffile (TRUE, TRUE, (boolean *) NULL, qcmd->cbytes)) - return FALSE; - } - - return fploop (); -} - -/* Confirm that a file has been received correctly by the other side. - Return FALSE for a communication error. We expect the receiving - system to send back CY; if an error occurred while moving the - received file into its final location, the receiving system will - send back CN5. */ - -static boolean -fpsendfile_confirm () -{ - const char *zrec; - long cbytes; - const char *zerr; - - zrec = zgetcmd (); - if (zrec == NULL) - return FALSE; - - cbytes = cPsent_bytes; - cPsent_bytes = -1; - - if (zrec[0] != 'C' - || (zrec[1] != 'Y' && zrec[1] != 'N')) - { - zerr = "Bad confirmation for sent file"; - ulog (LOG_ERROR, zerr); - (void) fsent_file (FALSE, cbytes, zerr, FALSE); - } - else if (zrec[1] == 'N') - { - if (zrec[2] == '5') - zerr = "File could not be stored in final location"; - else - { - char *zset; - - zset = (char *) alloca (sizeof "File send failed: " + strlen (zrec)); - sprintf (zset, "File send failed: %s", zrec); - zerr = zset; - } - ulog (LOG_ERROR, zerr); - (void) fsent_file (FALSE, cbytes, zerr, TRUE); - } - else - (void) fsent_file (TRUE, cbytes, (const char *) NULL, FALSE); - - return TRUE; -} - -/* Receive a file. If we are the master, we must set up a file - request and wait for the other side to confirm it. If we are the - slave, we must confirm a request made by the other side. We then - start receiving the file. - - This function must return FALSE if there is a communication error - and TRUE otherwise. We return TRUE even if the file transfer - fails. */ - -boolean -freceive_file (fmaster, e, qcmd, zmail, zfromsys, fnew) - boolean fmaster; - openfile_t e; - const struct scmd *qcmd; - const char *zmail; - const char *zfromsys; - boolean fnew; -{ - unsigned int imode; - - if (fmaster) - { - int clen; - char *zsend; - const char *zrec; - - /* We send the string - R from to user options - We put a dash in front of options. If we are talking to a - counterpart, we also send the maximum size file we are - prepared to accept, as returned by esysdep_open_receive. */ - - clen = (strlen (qcmd->zfrom) + strlen (qcmd->zto) - + strlen (qcmd->zuser) + strlen (qcmd->zoptions) + 30); - zsend = (char *) alloca (clen); - - if (! fnew) - sprintf (zsend, "R %s %s %s -%s", qcmd->zfrom, qcmd->zto, - qcmd->zuser, qcmd->zoptions); - else - sprintf (zsend, "R %s %s %s -%s %ld", qcmd->zfrom, qcmd->zto, - qcmd->zuser, qcmd->zoptions, qcmd->cbytes); - - if (! (qProto->pfsendcmd) (zsend)) - { - (void) ffileclose (e); - (void) remove (qcmd->ztemp); - return FALSE; - } - - /* Wait for a reply. */ - - zrec = zgetcmd (); - if (zrec == NULL) - { - (void) ffileclose (e); - (void) remove (qcmd->ztemp); - return FALSE; - } - - if (zrec[0] != 'R' - || (zrec[1] != 'Y' && zrec[1] != 'N')) - { - ulog (LOG_ERROR, "Bad response to receive request"); - (void) ffileclose (e); - (void) remove (qcmd->ztemp); - return FALSE; - } - - if (zrec[1] == 'N') - { - const char *zerr; - - if (zrec[2] == '2') - zerr = "no such file"; - else if (zrec[2] == '6') - { - /* We sent over the maximum file size we were prepared - to receive, and the remote system is telling us that - the file is larger than that. Try again later. It - would be better if we could know whether there will - ever be enough room. */ - ulog (LOG_ERROR, "Can't receive %s: too large", - qcmd->zfrom); - (void) ffileclose (e); - (void) remove (qcmd->ztemp); - return TRUE; - } - else - { - char *zset; - - zset = (char *) alloca (sizeof "unknown reason: " - + strlen (zrec)); - sprintf (zset, "unknown reason: %s", zrec); - zerr = zset; - } - ulog (LOG_ERROR, "Can't receive %s: %s", qcmd->zfrom, zerr); - (void) ffileclose (e); - (void) remove (qcmd->ztemp); - (void) fmail_transfer (FALSE, qcmd->zuser, zmail, zerr, - qcmd->zfrom, zfromsys, - qcmd->zto, zLocalname, - (const char *) NULL); - (void) fsysdep_did_work (qcmd->pseq); - return TRUE; - } - - /* The mode should have been sent as "RY 0%o". If it wasn't, - we use 0666. */ - imode = (unsigned int) strtol (zrec + 2, (char **) NULL, 8); - if (imode == 0) - imode = 0666; - } - else - { - /* Tell the other system to go ahead and send. */ - - if (! (qProto->pfsendcmd) ("SY")) - { - (void) ffileclose (e); - (void) remove (qcmd->ztemp); - return FALSE; - } - imode = qcmd->imode; - } - - if (! fstore_recfile (e, qcmd->pseq, qcmd->zfrom, qcmd->zto, zfromsys, - qcmd->zuser, imode, zmail, qcmd->ztemp)) - return FALSE; - - cPreceived_bytes = 0; - - /* Tell the protocol that we are starting to receive a file. */ - if (qProto->pffile != NULL) - { - boolean (*pffile) P((boolean, boolean, boolean *, long)); - - /* Simplify expression for ancient compilers. */ - pffile = qProto->pffile; - if (! pffile (TRUE, FALSE, (boolean *) NULL, (long) -1)) - return FALSE; - } - - return fploop (); -} - -/* Confirm that a file was received correctly. */ - -static boolean -fprecfile_confirm () -{ - long cbytes; - - cbytes = cPreceived_bytes; - cPreceived_bytes = -1; - - if (freceived_file (TRUE, cbytes, (const char *) NULL, FALSE)) - return (qProto->pfsendcmd) ("CY"); - else - return (qProto->pfsendcmd) ("CN5"); -} - -/* Send a transfer request. This is only called by the master. It - ignored the pseq entry in the scmd structure. */ - -boolean -fxcmd (qcmd, pfnever) - const struct scmd *qcmd; - boolean *pfnever; -{ - int clen; - char *zsend; - const char *zrec; - - *pfnever = FALSE; - - /* We send the string - X from to user options - We put a dash in front of options. */ - - clen = (strlen (qcmd->zfrom) + strlen (qcmd->zto) - + strlen (qcmd->zuser) + strlen (qcmd->zoptions) + 7); - zsend = (char *) alloca (clen); - - sprintf (zsend, "X %s %s %s -%s", qcmd->zfrom, qcmd->zto, - qcmd->zuser, qcmd->zoptions); - - if (! (qProto->pfsendcmd) (zsend)) - return FALSE; - - /* Wait for a reply. */ - - zrec = zgetcmd (); - if (zrec == NULL) - return FALSE; - - if (zrec[0] != 'X' - || (zrec[1] != 'Y' && zrec[1] != 'N')) - { - ulog (LOG_ERROR, "Bad response to wildcard request"); - return FALSE; - } - - if (zrec[1] == 'N') - { - ulog (LOG_ERROR, "Work request denied"); - *pfnever = TRUE; - return TRUE; - } - - return TRUE; -} - -/* Confirm a transfer request. */ - -boolean -fxcmd_confirm () -{ - return (qProto->pfsendcmd) ("XY"); -} - -/* Signal a file transfer failure to the other side. This is only called - by the slave. */ - -boolean -ftransfer_fail (bcmd, twhy) - int bcmd; - enum tfailure twhy; -{ - const char *z; - - switch (bcmd) - { - case 'S': - switch (twhy) - { - case FAILURE_PERM: - z = "SN2"; - break; - case FAILURE_OPEN: - z = "SN4"; - break; - case FAILURE_SIZE: - z = "SN6"; - break; - default: - z = "SN"; - break; - } - break; - case 'R': - switch (twhy) - { - case FAILURE_PERM: - case FAILURE_OPEN: - z = "RN2"; - break; - case FAILURE_SIZE: - z = "RN6"; - break; - default: - z = "RN"; - break; - } - break; - case 'X': - z = "XN"; - break; - default: -#if DEBUG > 0 - ulog (LOG_ERROR, "ftransfer_fail: Can't happen"); -#endif - return FALSE; - } - - return (qProto->pfsendcmd) (z); -} - -/* Get and parse a command from the other system. Handle hangups - specially. */ - -boolean -fgetcmd (fmaster, qcmd) - boolean fmaster; - struct scmd *qcmd; -{ - static char *z; - static int c; - - while (TRUE) - { - const char *zcmd; - int clen; - - zcmd = zgetcmd (); - if (zcmd == NULL) - return FALSE; - - clen = strlen (zcmd); - if (clen + 1 > c) - { - c = clen + 1; - z = (char *) xrealloc ((pointer) z, c); - } - strcpy (z, zcmd); - - if (! fparse_cmd (z, qcmd)) - continue; - - /* Handle hangup commands specially. If it's just 'H', return - it. If it's 'N', the other side is denying a hangup request - which we can just ignore (since the top level code assumes - that hangup requests are denied). If it's 'Y', the other - side is confirming a hangup request. In this case we confirm - with an "HY", wait for yet another "HY" from the other side, - and then finally shut down the protocol (I don't know why it - works this way, but it does). We then return a 'Y' command - to the top level code. */ - - if (qcmd->bcmd == 'N') - { -#if DEBUG > 0 - if (fmaster) - ulog (LOG_ERROR, "Got hangup reply as master"); -#endif - continue; - } - - if (qcmd->bcmd == 'Y') - { -#if DEBUG > 0 - if (fmaster) - ulog (LOG_ERROR, "Got hangup reply as master"); -#endif - /* Don't check errors rigorously here, since the other side - might jump the gun and hang up. */ - - if (! (qProto->pfsendcmd) ("HY")) - return TRUE; - fPerror_ok = TRUE; - zcmd = zgetcmd (); - fPerror_ok = FALSE; - if (zcmd == NULL) - return TRUE; -#if DEBUG > 1 - if (strcmp (zcmd, "HY") != 0) - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO | DEBUG_ABNORMAL, - "fgetcmd: Got \"%s\" when expecting \"HY\"", - zcmd); -#endif - (void) (qProto->pfshutdown) (); - return TRUE; - } - - return TRUE; - } - - /*NOTREACHED*/ -} - -/* Hangup. */ - -boolean -fhangup_request () -{ - return (qProto->pfsendcmd) ("H"); -} - -/* Reply to a hangup request. This is only called by the slave. If - fconfirm is TRUE, we are closing down the protocol. We send an HY - message. The master responds with an HY message. We send another - HY message, and then shut down the protocol. */ - -boolean -fhangup_reply (fconfirm) - boolean fconfirm; -{ - if (! fconfirm) - return (qProto->pfsendcmd) ("HN"); - else - { - const char *z; - - if (! (qProto->pfsendcmd) ("HY")) - return FALSE; - - z = zgetcmd (); - if (z == NULL) - return FALSE; - if (strcmp (z, "HY") != 0) - ulog (LOG_ERROR, "Got \"%s\" when expecting \"HY\"", z); - else - { - if (! (qProto->pfsendcmd) ("HY")) - return FALSE; - } - - return (qProto->pfshutdown) (); - } -} - -/* Loop sending and/or receiving data. If there is a file to send, - this will send it until the entire file has been sent or a command - has been received from the remote system or a complete file has - been received from the remote system. Otherwise this will simply - call the protocol to wait until a complete file or command has been - received from the remote system. */ - -static boolean -fploop () -{ - boolean fexit; - - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "fploop: Main protocol loop"); - - if (ffileisopen (eSendfile)) - { - int iend; - - iend = iPrecend; - - while (TRUE) - { - /* We keep sending out packets until we have something - in the receive buffer. */ - while (iend == iPrecend) - { - char *zdata; - int cdata; - - /* Get a packet and fill it with data. */ - - zdata = (qProto->pzgetspace) (&cdata); - if (zdata == NULL) - return FALSE; - - if (ffileeof (eSendfile)) - cdata = 0; - else - { - cdata = cfileread (eSendfile, zdata, cdata); - if (ffilereaderror (eSendfile, cdata)) - { - /* The protocol gives us no way to report a file - sending error, so we just drop the connection. - What else can we do? */ - ulog (LOG_ERROR, "read: %s", strerror (errno)); - usendfile_error (); - return FALSE; - } - } - - if (! (qProto->pfsenddata) (zdata, cdata)) - return FALSE; - - cPsent_bytes += cdata; - - /* If we have reached the end of the file, tell the - protocol that the file is finished (the protocol - could also detect this by looking for zero passed as - the data length to the send data routine, but would - have no convenient way to tell us to redo the file - send). If we are not supposed to redo the file - transfer, wait for confirmation and return out to get - the next file. */ - - if (cdata == 0) - { - if (qProto->pffile != NULL) - { - boolean fredo; - boolean (*pffile) P((boolean, boolean, boolean *, - long)); - - /* Simplify expression for ancient compilers. */ - pffile = qProto->pffile; - if (! pffile (FALSE, TRUE, &fredo, (long) -1)) - return FALSE; - - if (fredo) - { - ulog (LOG_NORMAL, "Resending file"); - if (! ffilerewind (eSendfile)) - { - ulog (LOG_ERROR, "rewind: %s", - strerror (errno)); - usendfile_error (); - return FALSE; - } - continue; - } - } - - return fpsendfile_confirm (); - } - } - - /* Process the data in the receive buffer, and decide - whether it's time to get out. */ - if (! (qProto->pfprocess) (&fexit)) - return FALSE; - if (fexit) - return TRUE; - - iend = iPrecend; - } - } - -#if DEBUG > 0 - /* If there is no file to send, there really should be a file to - receive. */ - - if (! ffileisopen(eRecfile)) - ulog (LOG_FATAL, "fploop: No send or receive file"); -#endif - - /* We have no file to send. Wait for data to come in. */ - - return (qProto->pfwait) (); -} - -/* This function is called by the protocol routines when data has - arrived. Some protocols may know whether the data is for a command - or a file; for others, if a receive file is open it is for the file - and is otherwise for a command. This function will set *pfexit to - TRUE if it has received a complete file (assumed to be true if - cdata is zero) or a complete command (assumed to be true if the - argument data contains a null byte). It will return FALSE on - error. */ - -boolean -fgot_data (zdata, cdata, fcmd, ffile, pfexit) - const char *zdata; - int cdata; - boolean fcmd; - boolean ffile; - boolean *pfexit; -{ - *pfexit = FALSE; - - if (! fcmd && ! ffile) - { - if (ffileisopen (eRecfile)) - ffile = TRUE; - else - fcmd = TRUE; - } - -#if DEBUG > 0 - if (ffile && ! ffileisopen (eRecfile)) - ulog (LOG_FATAL, "fgot_data: No file to receive into"); -#endif - - if (ffile) - { - if (cdata == 0) - { - /* The file transfer is complete. If the protocol has a - file level routine, call it to see whether we have to - receive the file again. */ - if (qProto->pffile != NULL) - { - boolean fredo; - boolean (*pffile) P((boolean, boolean, boolean *, long)); - - /* Simplify expression for ancient compilers. */ - pffile = qProto->pffile; - if (! pffile (FALSE, FALSE, &fredo, (long) -1)) - return FALSE; - - if (fredo) - { - ulog (LOG_NORMAL, "File being resent"); - if (! frecfile_rewind ()) - return FALSE; - return TRUE; - } - } - - if (! fprecfile_confirm ()) - return FALSE; - *pfexit = TRUE; - return TRUE; - } - else - { - int cwrote; - - /* Cast zdata to avoid warnings because of erroneous - prototypes on Ultrix. */ - cwrote = cfilewrite (eRecfile, (char *) zdata, cdata); - if (cwrote != cdata) - { - const char *zerr; - - if (cwrote < 0) - zerr = strerror (errno); - else - zerr = "could not write all data"; - ulog (LOG_ERROR, "write: %s", zerr); - urecfile_error (); - - /* Any write error is almost certainly a temporary - condition, or else UUCP would not be functioning at - all. If we continue to accept the file, we will wind - up rejecting it at the end (what else could we do?) - and the remote system will throw away the request. - We're better off just dropping the connection, which - is what happens when we return FALSE, and trying - again later. */ - return FALSE; - } - - cPreceived_bytes += cdata; - - return TRUE; - } - } - else - { - const char *z; - - /* We want to add this data to the current command string. If - there is no null character in the data, this string will be - continued by the next packet. Otherwise this must be the - last string in the command, and we don't care about what - comes after the null byte. */ - - z = (const char *) memchr ((constpointer) zdata, '\0', cdata); - if (z == NULL) - upadd_cmd (zdata, cdata, FALSE); - else - { - upadd_cmd (zdata, z - zdata, TRUE); - *pfexit = TRUE; - } - - return TRUE; - } -} - -/* This function is called by fgot_data when a command string is - received. We must queue up received commands since we don't know - when we'll be able to get to them (for example, the - acknowledgements for the last few packets of a sent file may - contain the string indicating whether the file was received - correctly). */ - -struct spcmdqueue -{ - struct spcmdqueue *qnext; - int csize; - int clen; - char *z; -}; - -static struct spcmdqueue *qPcmd_queue; -static struct spcmdqueue *qPcmd_free; - -static void -upadd_cmd (z, clen, flast) - const char *z; - int clen; - boolean flast; -{ - struct spcmdqueue *q; - - q = qPcmd_free; - if (q == NULL) - { - q = (struct spcmdqueue *) xmalloc (sizeof (struct spcmdqueue)); - q->qnext = NULL; - q->csize = 0; - q->clen = 0; - q->z = NULL; - qPcmd_free = q; - } - - if (q->clen + clen + 1 > q->csize) - { - q->csize = q->clen + clen + 1; - q->z = (char *) xrealloc ((pointer) q->z, q->csize); - } - - memcpy (q->z + q->clen, z, clen); - q->clen += clen; - q->z[q->clen] = '\0'; - - /* If the last string in this command, add it to the queue of - finished commands. */ - - if (flast) - { - struct spcmdqueue **pq; - - for (pq = &qPcmd_queue; *pq != NULL; pq = &(*pq)->qnext) - ; - *pq = q; - qPcmd_free = q->qnext; - q->qnext = NULL; - } -} - -/* Get a command string. We just have to wait until the receive - packet function gives us something in qPcmd_queue. The return - value of this may be treated as a static buffer; it will last - at least until the next packet is received. */ - -const char * -zgetcmd () -{ - struct spcmdqueue *q; - - /* Wait until a command comes in. */ - while (qPcmd_queue == NULL) - { - DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "zgetcmd: Waiting for packet"); - - if (! (qProto->pfwait) ()) - return NULL; - } - - q = qPcmd_queue; - qPcmd_queue = q->qnext; - - q->clen = 0; - - /* We must not replace qPcmd_free, because it may already be - receiving a new command string. */ - if (qPcmd_free == NULL) - { - q->qnext = NULL; - qPcmd_free = q; - } - else - { - q->qnext = qPcmd_free->qnext; - qPcmd_free->qnext = q; - } - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "zgetcmd: Got command \"%s\"", q->z); - - return q->z; -} - -/* We want to output and input at the same time, if supported on this - machine. If we have something to send, we send it all while - accepting a large amount of data. Once we have sent everything we - look at whatever we have received. If data comes in faster than we - can send it, we may run out of buffer space. */ - -boolean -fsend_data (zsend, csend, fdoread) - const char *zsend; - int csend; - boolean fdoread; -{ - if (! fdoread) - return fport_write (zsend, csend); - - while (csend > 0) - { - char *zrec; - int crec, csent; - - if (iPrecend < iPrecstart) - { - zrec = abPrecbuf + iPrecend; - crec = iPrecstart - iPrecend - 1; - } - else if (iPrecend < CRECBUFLEN) - { - zrec = abPrecbuf + iPrecend; - crec = CRECBUFLEN - iPrecend; - } - else - { - zrec = abPrecbuf; - crec = iPrecstart - 1; - } - - csent = csend; - - if (! fport_io (zsend, &csent, zrec, &crec)) - return FALSE; - - csend -= csent; - zsend += csent; - - iPrecend = (iPrecend + crec) % CRECBUFLEN; - } - - return TRUE; -} - -/* Read data from the other system when we have nothing to send. The - argument cneed is the amount of data the caller wants, and ctimeout - is the timeout in seconds. The function sets *pcrec to the amount - of data which was actually received, which may be less than cneed - if there isn't enough room in the receive buffer. If no data is - received before the timeout expires, *pcrec will be returned as 0. - If an error occurs, the function returns FALSE. If the freport - argument is FALSE, no error should be reported. */ - -boolean -freceive_data (cneed, pcrec, ctimeout, freport) - int cneed; - int *pcrec; - int ctimeout; - boolean freport; -{ - /* Set *pcrec to the maximum amount of data we can read. fport_read - expects *pcrec to be the buffer size, and sets it to the amount - actually received. */ - if (iPrecend < iPrecstart) - *pcrec = iPrecstart - iPrecend - 1; - else - { - *pcrec = CRECBUFLEN - iPrecend; - if (iPrecstart == 0) - --(*pcrec); - } - -#if DEBUG > 0 - /* If we have no room in the buffer, we're in trouble. The - protocols must be written to ensure that this can't happen. */ - if (*pcrec == 0) - ulog (LOG_FATAL, "freceive_data: No room in buffer"); -#endif - - /* If we don't have room for all the data the caller wants, we - simply have to expect less. We'll get the rest later. */ - if (*pcrec < cneed) - cneed = *pcrec; - - if (! fport_read (abPrecbuf + iPrecend, pcrec, cneed, ctimeout, freport)) - return FALSE; - - iPrecend = (iPrecend + *pcrec) % CRECBUFLEN; - - return TRUE; -} - -/* Read a single character. Get it out of the receive buffer if it's - there, otherwise ask freceive_data for at least one character. - This is used because as a protocol is shutting down freceive_data - may read ahead and eat characters that should be read outside the - protocol routines. We call freceive_data rather than fport_read - with an argument of 1 so that we can get all the available data in - a single system call. The ctimeout argument is the timeout in - seconds; the freport argument is FALSE if no error should be - reported. This returns a character, or -1 on timeout or -2 on - error. */ - -int -breceive_char (ctimeout, freport) - int ctimeout; - boolean freport; -{ - char b; - - if (iPrecstart == iPrecend) - { - int crec; - - if (! freceive_data (1, &crec, ctimeout, freport)) - return -2; - if (crec == 0) - return -1; - } - - b = abPrecbuf[iPrecstart]; - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - return BUCHAR (b); -} - -/* This routine is called when an error occurred and we are crashing - out of the connection. It is only used to report statistics on - failed transfers to the statistics file. Note that the number of - bytes we report as having been sent has little or nothing to do - with the number of bytes the remote site actually received. */ - -void -ustats_failed () -{ - long cbytes; - - if (cPsent_bytes != -1) - { - cbytes = cPsent_bytes; - cPsent_bytes = -1; - (void) fsent_file (FALSE, cbytes, "connection failure", FALSE); - } - - if (cPreceived_bytes != -1) - { - cbytes = cPreceived_bytes; - cPreceived_bytes = -1; - (void) freceived_file (FALSE, cbytes, "connection failure", FALSE); - } -} diff --git a/gnu/libexec/uucp/prot.h b/gnu/libexec/uucp/prot.h deleted file mode 100644 index ffcc75103b0c..000000000000 --- a/gnu/libexec/uucp/prot.h +++ /dev/null @@ -1,266 +0,0 @@ -/* prot.h - Protocol header file. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Id: prot.h,v 1.2 1993/08/02 17:25:12 mycroft Exp $ -*/ - -/* The sprotocol structure holds information and functions for a specific - protocol (e.g. the 'g' protocol). */ - -struct sprotocol -{ - /* The name of the protocol (e.g. 'g'). */ - char bname; - /* Whether the protocol is full-duplex or not; a full-duplex protocol - can transfer files in both directions at once. */ - boolean ffullduplex; - /* Reliability requirements, an or of RELIABLE_xxx defines from - port.h. */ - int ireliable; - /* Protocol parameter commands. */ - struct scmdtab *qcmds; - /* A routine to start the protocol; the argument is whether the caller - is the master or the slave. Returns TRUE if the protocol has been - succesfully started, FALSE otherwise. */ - boolean (*pfstart) P((boolean fmaster)); - /* Shutdown the protocol. */ - boolean (*pfshutdown) P((void)); - /* Send a command to the other side. */ - boolean (*pfsendcmd) P((const char *z)); - /* Get buffer to space to fill with data. This should set *pcdata - to the amount of data desired. */ - char *(*pzgetspace) P((int *pcdata)); - /* Send data to the other side. The first argument must be a return - value of pzgetspace. */ - boolean (*pfsenddata) P((char *z, int c)); - /* Process received data in abPrecbuf, calling fgot_data as - necessary. If fgot_data sets *pfexit, it should get passed back - out. */ - boolean (*pfprocess) P((boolean *pfexit)); - /* Wait for data to come in and call fgot_data with it until - fgot_data sets *pfexit. */ - boolean (*pfwait) P((void)); - /* Handle any file level actions that need to be taken. If fstart - is TRUE, a file transfer is beginning. If fstart is FALSE a file - transfer is ending, and *pfredo should be set to TRUE if the file - transfer needs to be redone. If fstart and fsend are both TRUE, - cbytes holds the size of the file or -1 if it is unknown. */ - boolean (*pffile) P((boolean fstart, boolean fsend, boolean *pfredo, - long cbytes)); -}; - -/* Send a file. - fmaster -- whether this job is the master - e -- open file (send if fmaster, receive if ! fmaster) - qcmd -- command to execute - zmail -- user to notify on source system. - ztosys -- system the file is being sent to - fnew -- whether the system is running our code or not - - If this is called with fmaster TRUE, it is responsible for - informing the slave that it wants to send a file; the slave will - eventually call freceive_file. The file should then be - transferred. When the transfer is complete, then if fmaster is - TRUE and zmail is not NULL, mail should be sent to the user zmail; - if fmaster is FALSE and qcmd->znotify is not NULL, mail should be - sent to the user qcmd->znotify. After the file transfer is - complete, the work queue entry should be removed by calling - fsysdep_did_work (pseq). Most of the latter stuff is handled by - fsent_file. */ -extern boolean fsend_file P((boolean fmaster, openfile_t e, - const struct scmd *qcmd, const char *zmail, - const char *ztosys, boolean fnew)); - -/* Receive a file. - fmaster -- whether this job is the master - e -- open file (receive if fmaster, send if ! fmaster) - qcmd -- command to execute - zmail -- user to notify on destination system. - zfromsys -- system the file is from - fnew -- whether the system is running our code or not - - The field qcmd->znotify will not be meaningful. - - If this is called with fmaster TRUE, it is responsible for - informing the slave that it wants to receive a file; the slave will - eventually call pfsend. The file should then be transferred. When - the transfer is complete, if fmaster is TRUE and zmail is not NULL, - mail should be sent to the user zmail. After the file transfer is - complete, the work queue entry should be removed by calling - fsysdep_did_work (pseq). Most of the latter work is done by - freceived_file. */ -extern boolean freceive_file P((boolean fmaster, openfile_t e, - const struct scmd *qcmd, const char *zmail, - const char *zfromsys, boolean fnew)); - -/* Request a transfer. This is only called by the master. - qcmd -- command (only pseq, zfrom, zto, zuser, zoptions valid) - - This function should tell the slave that the master wants to - execute a transfer. The slave may queue up work to do. The return - value is FALSE if some error occurred. This always does its work - immediately, so it does not use qcmd->pseq. It sets *pfnever to - TRUE if the request was denied. */ -extern boolean fxcmd P((const struct scmd *qcmd, boolean *pfnever)); - -/* Confirm a transfer. This is only called by the slave. This is - called after a transfer request has been received to confirm that - it was successful. If it was not successful, pffail will be - called with a first argument of 'X'. */ -extern boolean fxcmd_confirm P((void)); - -/* Fail. This is called by the slave if it is unable to execute some - request by the master. The argument bcmd is the request which - failed ('S' or 'R'). The argument twhy indicates the reason. The - return value is FALSE if some error occurred. */ -extern boolean ftransfer_fail P((int bcmd, enum tfailure twhy)); - -/* Get a command from the master. The strings in the command argument - are set to point into a static buffer. If fmaster is TRUE, this - should not wait if there is no command pending; if fmaster is FALSE - it should wait until a command is received. The field qcmd->pseq - will be set to NULL. */ -extern boolean fgetcmd P((boolean fmaster, struct scmd *qcmd)); - -/* Get a command string from the other system, where the nature of a - command string is defined by the protocol. The return value is - fragile, and must be saved if any other protocol related calls are - made. */ -extern const char *zgetcmd P((void)); - -/* Hangup. This is only called by the master, and indicates that the - master is ready to relinquish control; after calling it, the master - becomes the slave. If the original slave has no work to do, it - confirms the hangup (the new slave will wind up getting a 'Y' - command from fgetcmd). If the the original slave has work to do, - it becomes the master (it also denies the hangup, but this is not - seen outside the protocol code). The return value of fhangup is - FALSE if some error occurred. */ -extern boolean fhangup_request P((void)); - -/* Hangup reply. This is only called by the slave if the master has - sent a hangup request. If fconfirm is TRUE, the slave is - confirming the hangup, in which case the protocol should be shut - down. If fconfirm is FALSE, the slave will become the master. The - return value is FALSE if some error occurred. */ -extern boolean fhangup_reply P((boolean fconfirm)); - -/* Handle data received by a protocol. This is called by the protocol - specific routines as data comes in. The protocol specific routines - may know that the data is destined for a command or a file, in - which case they should pass fcmd and ffile appropriately. - Otherwise they may both be passed as FALSE, in which case if a file - recieve is in progress the data will be sent to the file, otherwise - to a command. This will set *pfexit to TRUE if the file or command - is finished. A file is finished when a zero length buffer is - passed. A command is finished when a string containing a null byte - is passed. This will return FALSE on error. */ -extern boolean fgot_data P((const char *zdata, int cdata, - boolean fcmd, boolean ffile, - boolean *pfexit)); - -/* Send data to the other system. If the fread argument is TRUE, this - will also receive data into the receive buffer abPrecbuf; fread is - passed as TRUE if the protocol expects data to be coming back, to - make sure the input buffer does not fill up. Returns FALSE on - error. */ -extern boolean fsend_data P((const char *zsend, int csend, - boolean fdoread)); - -/* Receive data from the other system when there is no data to send. - The cneed argument is the amount of data desired and the ctimeout - argument is the timeout in seconds. This will set *pcrec to the - amount of data received. It will return FALSE on error. If a - timeout occurs, it will return TRUE with *pcrec set to zero. */ -extern boolean freceive_data P((int cneed, int *pcrec, int ctimeout, - boolean freport)); - -/* Protocol in use. */ -extern const struct sprotocol *qProto; - -/* The size of the receive buffer. */ -#define CRECBUFLEN (16384) - -/* Buffer to hold received data. */ -extern char abPrecbuf[CRECBUFLEN]; - -/* Index of start of data in abPrecbuf. */ -extern int iPrecstart; - -/* Index of end of data (first byte not included in data) in abPrecbuf. */ -extern int iPrecend; - -/* Whether an unexpected shutdown is OK now; this is used to avoid - giving a warning for systems that hang up in a hurry. */ -extern boolean fPerror_ok; - -/* Prototypes for 'g' protocol functions. */ - -extern struct scmdtab asGproto_params[]; -extern boolean fgstart P((boolean fmaster)); -extern boolean fgshutdown P((void)); -extern boolean fgsendcmd P((const char *z)); -extern char *zggetspace P((int *pcdata)); -extern boolean fgsenddata P((char *z, int c)); -extern boolean fgprocess P((boolean *pfexit)); -extern boolean fgwait P((void)); - -/* Prototypes for 'f' protocol functions. */ - -extern struct scmdtab asFproto_params[]; -extern boolean ffstart P((boolean fmaster)); -extern boolean ffshutdown P((void)); -extern boolean ffsendcmd P((const char *z)); -extern char *zfgetspace P((int *pcdata)); -extern boolean ffsenddata P((char *z, int c)); -extern boolean ffprocess P((boolean *pfexit)); -extern boolean ffwait P((void)); -extern boolean fffile P((boolean fstart, boolean fsend, boolean *pfredo, - long cbytes)); - -/* Prototypes for 't' protocol functions. */ - -extern struct scmdtab asTproto_params[]; -extern boolean ftstart P((boolean fmaster)); -extern boolean ftshutdown P((void)); -extern boolean ftsendcmd P((const char *z)); -extern char *ztgetspace P((int *pcdata)); -extern boolean ftsenddata P((char *z, int c)); -extern boolean ftprocess P((boolean *pfexit)); -extern boolean ftwait P((void)); -extern boolean ftfile P((boolean fstart, boolean fsend, boolean *pfredo, - long cbytes)); - -/* Prototypes for 'e' protocol functions. */ - -extern struct scmdtab asEproto_params[]; -extern boolean festart P((boolean fmaster)); -extern boolean feshutdown P((void)); -extern boolean fesendcmd P((const char *z)); -extern char *zegetspace P((int *pcdata)); -extern boolean fesenddata P((char *z, int c)); -extern boolean feprocess P((boolean *pfexit)); -extern boolean fewait P((void)); -extern boolean fefile P((boolean fstart, boolean fsend, boolean *pfredo, - long cbytes)); diff --git a/gnu/libexec/uucp/prote.c b/gnu/libexec/uucp/prote.c deleted file mode 100644 index 45fbdc4a1d9a..000000000000 --- a/gnu/libexec/uucp/prote.c +++ /dev/null @@ -1,401 +0,0 @@ -/* prote.c - The 'e' protocol. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: prote.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.7 1992/03/30 04:49:10 ian - Niels Baggesen: added debugging types abnormal and uucp-proto - - Revision 1.6 1992/03/17 01:03:03 ian - Miscellaneous cleanup - - Revision 1.5 1992/03/13 22:59:25 ian - Have breceive_char go through freceive_data - - Revision 1.4 1992/03/12 19:56:10 ian - Debugging based on types rather than number - - Revision 1.3 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.2 1992/01/16 18:16:58 ian - Niels Baggesen: add some debugging messages - - Revision 1.1 1991/12/31 19:43:30 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char prote_rcsid[] = "$Id: prote.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include "prot.h" -#include "port.h" -#include "system.h" - -/* This implementation is based on my implementation of the 't' - protocol, which is fairly similar. The main difference between the - protocols seems to be that 't' breaks the file into packets and - transmits the size of the packet with each packet, whereas 'e' - sends the size of the entire file and then sends all the data in a - single enormous packet. - - The 'e' protocol does no error checking whatsoever and thus - requires an end-to-end verified eight bit communication line, such - as is provided by TCP. Using it with a modem is inadvisable, since - errors can occur between the modem and the computer. */ - -/* The buffer size we use. */ -#define CEBUFSIZE (CRECBUFLEN / 2) - -/* The size of the initial file size message. */ -#define CEFRAMELEN (20) - -/* A pointer to the buffer we will use. */ -static char *zEbuf; - -/* True if we are receiving a file. */ -static boolean fEfile; - -/* The number of bytes we have left to send or receive. */ -static long cEbytes; - -/* The timeout we use. */ -static int cEtimeout = 120; - -struct scmdtab asEproto_params[] = -{ - { "timeout", CMDTABTYPE_INT, (pointer) &cEtimeout, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Local function. */ - -static boolean feprocess_data P((boolean *pfexit, int *pcneed)); - -/* Start the protocol. */ - -/*ARGSUSED*/ -boolean -festart (fmaster) - boolean fmaster; -{ - if (! fport_set (PORTSETTING_EIGHT)) - return FALSE; - zEbuf = (char *) xmalloc (CEBUFSIZE); - fEfile = FALSE; - usysdep_sleep (2); - return TRUE; -} - -/* Stop the protocol. */ - -boolean -feshutdown () -{ - xfree ((pointer) zEbuf); - zEbuf = NULL; - return TRUE; -} - -/* Send a command string. We send everything up to and including the - null byte. */ - -boolean -fesendcmd (z) - const char *z; -{ - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fesendcmd: Sending command \"%s\"", z); - - return fsend_data (z, strlen (z) + 1, TRUE); -} - -/* Get space to be filled with data. We provide a buffer which has - 20 bytes at the start available to hold the length. */ - -char * -zegetspace (pclen) - int *pclen; -{ - *pclen = CEBUFSIZE; - return zEbuf; -} - -/* Send out some data. We are allowed to modify the 20 bytes - preceding the buffer. This allows us to send the entire block with - header bytes in a single call. */ - -boolean -fesenddata (zdata, cdata) - char *zdata; - int cdata; -{ -#if DEBUG > 0 - /* Keep track of the number of bytes we send out to make sure it all - adds up. */ - cEbytes -= cdata; - if (cEbytes < 0) - { - ulog (LOG_ERROR, "Protocol 'e' internal error"); - return FALSE; - } -#endif - - /* We pass FALSE to fsend_data since we don't expect the other side - to be sending us anything just now. */ - return fsend_data (zdata, cdata, FALSE); -} - -/* Process any data in the receive buffer. */ - -boolean -feprocess (pfexit) - boolean *pfexit; -{ - return feprocess_data (pfexit, (int *) NULL); -} - -/* Process data and return the amount we need in *pfneed. */ - -static boolean -feprocess_data (pfexit, pcneed) - boolean *pfexit; - int *pcneed; -{ - int cinbuf, cfirst, clen; - - *pfexit = FALSE; - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - - if (! fEfile) - { - /* We are not receiving a file. Commands continue up to a null - byte. */ - while (cinbuf > 0) - { - char *pnull; - - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst > cinbuf) - cfirst = cinbuf; - - pnull = memchr (abPrecbuf + iPrecstart, '\0', cfirst); - if (pnull != NULL) - cfirst = pnull - (abPrecbuf + iPrecstart) + 1; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "feprocess_data: Got %d command bytes", - cfirst); - - if (! fgot_data (abPrecbuf + iPrecstart, cfirst, TRUE, FALSE, - pfexit)) - return FALSE; - - iPrecstart = (iPrecstart + cfirst) % CRECBUFLEN; - - if (*pfexit) - return TRUE; - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - } - - if (pcneed != NULL) - *pcneed = 1; - - return TRUE; - } - - /* Here we are receiving a file. We want cEbytes in total. If we - don't have cEbytes yet, we have to get it first. */ - - if (cEbytes == -1) - { - char ab[CEFRAMELEN + 1]; - - if (cinbuf < CEFRAMELEN) - { - if (pcneed != NULL) - *pcneed = CEFRAMELEN - cinbuf; - return TRUE; - } - - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst >= CEFRAMELEN) - memcpy (ab, abPrecbuf + iPrecstart, CEFRAMELEN); - else - { - memcpy (ab, abPrecbuf + iPrecstart, cfirst); - memcpy (ab + cfirst, abPrecbuf, CEFRAMELEN - cfirst); - } - - ab[CEFRAMELEN] = '\0'; - cEbytes = strtol (ab, (char **) NULL, 10); - - iPrecstart = (iPrecstart + CEFRAMELEN) % CRECBUFLEN; - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - } - - /* Here we can read real data for the file. */ - - while (cinbuf > 0) - { - clen = cinbuf; - if ((long) clen > cEbytes) - clen = (int) cEbytes; - - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst > clen) - cfirst = clen; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "feprocess_data: Got %d data bytes", - cfirst); - - if (! fgot_data (abPrecbuf + iPrecstart, cfirst, FALSE, TRUE, - pfexit)) - return FALSE; - if (cfirst < clen) - { - if (! fgot_data (abPrecbuf, clen - cfirst, FALSE, TRUE, - pfexit)) - return FALSE; - } - - iPrecstart = (iPrecstart + clen) % CRECBUFLEN; - cEbytes -= clen; - - if (cEbytes == 0) - { - if (! fgot_data (abPrecbuf, 0, FALSE, TRUE, pfexit)) - return FALSE; - if (*pfexit) - return TRUE; - } - - cinbuf -= clen; - } - - if (pcneed != NULL) - { - if (cEbytes > CRECBUFLEN / 2) - *pcneed = CRECBUFLEN / 2; - else - *pcneed = (int) cEbytes; - } - - return TRUE; -} - -/* Wait for data to come in and process it until we've reached the end - of a command or a file. */ - -boolean -fewait () -{ - while (TRUE) - { - boolean fexit; - int cneed, crec; - - if (! feprocess_data (&fexit, &cneed)) - return FALSE; - if (fexit) - return TRUE; - - if (! freceive_data (cneed, &crec, cEtimeout, TRUE)) - return FALSE; - - if (crec == 0) - { - ulog (LOG_ERROR, "Timed out waiting for data"); - return FALSE; - } - } -} - -/* File level routine, to handle transferring the amount of data and - to set fEfile correctly. */ - -boolean -fefile (fstart, fsend, pfredo, cbytes) - boolean fstart; - boolean fsend; - boolean *pfredo; - long cbytes; -{ - if (pfredo != NULL) - *pfredo = FALSE; - - if (fstart) - { - if (fsend) - { - char ab[CEFRAMELEN]; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "Protocol 'e' starting to send %ld bytes", - cbytes); - - bzero (ab, CEFRAMELEN); - sprintf (ab, "%ld", cbytes); - if (! fsend_data (ab, CEFRAMELEN, TRUE)) - return FALSE; - cEbytes = cbytes; - } - else - { - cEbytes = -1; - fEfile = TRUE; - } - } - else - { - if (! fsend) - fEfile = FALSE; -#if DEBUG > 0 - if (cEbytes != 0) - { - ulog (LOG_ERROR, - "Protocol 'e' internal error: %ld bytes left over", - cEbytes); - return FALSE; - } -#endif - } - - return TRUE; -} diff --git a/gnu/libexec/uucp/protf.c b/gnu/libexec/uucp/protf.c deleted file mode 100644 index bb234a5a7f1a..000000000000 --- a/gnu/libexec/uucp/protf.c +++ /dev/null @@ -1,673 +0,0 @@ -/* protf.c - The 'f' protocol. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: protf.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.15 1992/03/30 04:49:10 ian - Niels Baggesen: added debugging types abnormal and uucp-proto - - Revision 1.14 1992/03/17 01:03:03 ian - Miscellaneous cleanup - - Revision 1.13 1992/03/13 22:59:25 ian - Have breceive_char go through freceive_data - - Revision 1.12 1992/03/12 19:56:10 ian - Debugging based on types rather than number - - Revision 1.11 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.10 1992/01/16 18:16:58 ian - Niels Baggesen: add some debugging messages - - Revision 1.9 1992/01/14 04:35:23 ian - Chip Salzenberg: implement this patch correctly - - Revision 1.8 1992/01/14 04:21:59 ian - Chip Salzenberg: avoid use before set warning - - Revision 1.7 1991/12/31 19:34:19 ian - Added number of bytes to pffile protocol entry point - - Revision 1.6 1991/12/20 03:02:01 ian - Oleg Tabarovsky: added statistical messages to 'g' and 'f' protocols - - Revision 1.5 1991/12/20 00:01:54 ian - Franc,ois Pinard: don't crash 'f' protocol because of an illegal byte - - Revision 1.4 1991/11/16 00:31:01 ian - Increased default 't' and 'f' protocol timeouts - - Revision 1.3 1991/11/15 23:32:15 ian - Don't use 1 second timeouts--loses data on System V - - Revision 1.2 1991/11/15 21:00:59 ian - Efficiency hacks for 'f' and 't' protocols - - Revision 1.1 1991/11/11 04:21:16 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char protf_rcsid[] = "$Id: protf.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#include "prot.h" -#include "port.h" -#include "system.h" - -/* This implementation is based on code by Piet Beertema, CWI, - Amsterdam, Sep 1984. - - This code implements the 'f' protocol, which requires a - flow-controlled error-free seven-bit data path. It does check for - errors, but only at the end of each file transmission, so a noisy - line without error correcting modems will be unusable. - - The conversion to seven bit data is done as follows, where b - represents the character to convert: - - 0 <= b <= 037: 0172, b + 0100 (0100 to 0137) - 040 <= b <= 0171: b ( 040 to 0171) - 0172 <= b <= 0177: 0173, b - 0100 ( 072 to 077) - 0200 <= b <= 0237: 0174, b - 0100 (0100 to 0137) - 0240 <= b <= 0371: 0175, b - 0200 ( 040 to 0171) - 0372 <= b <= 0377: 0176, b - 0300 ( 072 to 077) - - This causes all output bytes to be in the range 040 to 0176; these - are the printable ASCII characters. */ - -/* Internal functions. */ -static boolean ffprocess_data P((boolean *pfexit, int *pcneed)); - -/* The size of the buffer we allocate to store outgoing data in. */ -#define CFBUFSIZE (256) - -/* The timeout to wait for data to arrive before giving up. */ -static int cFtimeout = 120; - -/* The maximum number of retries. */ -static int cFmaxretries = 2; - -/* The buffer we allocate for outgoing data. */ -static char *zFbuf; - -/* TRUE if we are receiving a file rather than a command. */ -static boolean fFfile; - -/* The checksum so far. */ -static unsigned int iFcheck; - -/* The last special byte (0172 to 0176) or 0 if none. */ -static char bFspecial; - -/* The number of times we have retried this file. */ -static int cFretries; - -struct scmdtab asFproto_params[] = -{ - { "timeout", CMDTABTYPE_INT, (pointer) &cFtimeout, NULL }, - { "retries", CMDTABTYPE_INT, (pointer) &cFmaxretries, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Statistics. */ - -/* The number of data bytes sent in files. */ -static long cFsent_data; - -/* The number of actual bytes sent in files. */ -static long cFsent_bytes; - -/* The number of data bytes received in files. */ -static long cFrec_data; - -/* The number of actual bytes received in files. */ -static long cFrec_bytes; - -/* The number of file retries when sending. */ -static long cFsend_retries; - -/* The number of file retries when receiving. */ -static long cFrec_retries; - -/* Start the protocol. */ - -/*ARGSUSED*/ -boolean -ffstart (fmaster) - boolean fmaster; -{ - cFsent_data = 0; - cFsent_bytes = 0; - cFrec_data = 0; - cFrec_bytes = 0; - cFsend_retries = 0; - cFrec_retries = 0; - - /* Allow XON/XOFF to work. */ - if (! fport_set (PORTSETTING_SEVEN)) - return FALSE; - - /* We sleep to allow the other side to reset the terminal; this is - what Mr. Beertema's code does. */ - usysdep_sleep (2); - - return TRUE; -} - -/* Shutdown the protocol. */ - -boolean -ffshutdown () -{ - xfree ((pointer) zFbuf); - zFbuf = NULL; - ulog (LOG_NORMAL, - "Protocol 'f': sent %ld bytes for %ld, received %ld bytes for %ld", - cFsent_bytes, cFsent_data, cFrec_bytes, cFrec_data); - if (cFsend_retries != 0 || cFrec_retries != 0) - ulog (LOG_NORMAL, "Protocol 'f' file retries: %ld sending, %ld receiving", - cFsend_retries, cFrec_retries); - return TRUE; -} - -/* Send a command string. We just send the string followed by a carriage - return. */ - -boolean -ffsendcmd (z) - const char *z; -{ - int clen; - char *zalc; - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "ffsendcmd: Sending command \"%s\"", z); - - clen = strlen (z); - zalc = (char *) alloca (clen + 2); - sprintf (zalc, "%s\r", z); - return fsend_data (zalc, clen + 1, TRUE); -} - -/* Get space to be filled with data. We allocate the space from the - heap. */ - -char * -zfgetspace (pclen) - int *pclen; -{ - *pclen = CFBUFSIZE; - if (zFbuf == NULL) - zFbuf = (char *) xmalloc (CFBUFSIZE); - return zFbuf; -} - -/* Send out a data packet. We have to encode the data into seven bits - and accumulate a checksum. */ - -boolean -ffsenddata (zdata, cdata) - char *zdata; - int cdata; -{ - char ab[CFBUFSIZE * 2]; - char *ze; - register unsigned int itmpchk; - - cFsent_data += cdata; - - ze = ab; - itmpchk = iFcheck; - while (cdata-- > 0) - { - register int b; - - /* Rotate the checksum left. */ - if ((itmpchk & 0x8000) == 0) - itmpchk <<= 1; - else - { - itmpchk <<= 1; - ++itmpchk; - } - - /* Add the next byte into the checksum. */ - b = *zdata++ & 0xff; - itmpchk += b; - - /* Encode the byte. */ - if (b <= 0177) - { - if (b <= 037) - { - *ze++ = '\172'; - *ze++ = (char) (b + 0100); - } - else if (b <= 0171) - *ze++ = (char) b; - else - { - *ze++ = '\173'; - *ze++ = (char) (b - 0100); - } - } - else - { - if (b <= 0237) - { - *ze++ = '\174'; - *ze++ = (char) (b - 0100); - } - else if (b <= 0371) - { - *ze++ = '\175'; - *ze++ = (char) (b - 0200); - } - else - { - *ze++ = '\176'; - *ze++ = (char) (b - 0300); - } - } - } - - iFcheck = itmpchk; - - cFsent_bytes += ze - ab; - - /* Passing FALSE tells fsend_data not to bother looking for incoming - information, since we really don't expect any. */ - return fsend_data (ab, ze - ab, FALSE); -} - -/* Process any data in the receive buffer. */ - -boolean -ffprocess (pfexit) - boolean *pfexit; -{ - return ffprocess_data (pfexit, (int *) NULL); -} - -/* Process data and return the amount of data we are looking for in - *pcneed. The 'f' protocol doesn't really reveal this, but when - transferring file we know that we need at least seven characters - for the checksum. */ - -static boolean -ffprocess_data (pfexit, pcneed) - boolean *pfexit; - int *pcneed; -{ - int i; - register unsigned int itmpchk; - - if (pcneed != NULL) - *pcneed = 1; - - if (! fFfile) - { - /* A command continues until a '\r' character, which we turn - into '\0' before calling fgot_data. */ - - while (iPrecstart != iPrecend) - { - for (i = iPrecstart; i < CRECBUFLEN && i != iPrecend; i++) - { - if (abPrecbuf[i] == '\r') - { - int istart; - - abPrecbuf[i] = '\0'; - istart = iPrecstart; - iPrecstart = (i + 1) % CRECBUFLEN; - return fgot_data (abPrecbuf + istart, i - istart + 1, - TRUE, FALSE, pfexit); - } - } - - if (! fgot_data (abPrecbuf + iPrecstart, i - iPrecstart, - TRUE, FALSE, pfexit)) - return FALSE; - - iPrecstart = i % CRECBUFLEN; - } - - *pfexit = FALSE; - return TRUE; - } - - /* Here the data is destined for a file, and we must decode it. */ - - itmpchk = iFcheck; - - while (iPrecstart != iPrecend) - { - char *zstart, *zto, *zfrom; - int c; - - zto = zfrom = zstart = abPrecbuf + iPrecstart; - - c = iPrecend - iPrecstart; - if (c < 0) - c = CRECBUFLEN - iPrecstart; - - while (c-- != 0) - { - int b; - - b = *zfrom++ & 0xff; - if (b < 040 || b > 0176) - { - ulog (LOG_ERROR, "Illegal byte %d", b); - continue; - } - - /* Characters >= 0172 are always special characters. The - only legal pair of consecutive special characters - are 0176 0176 which immediately precede the four - digit checksum. */ - - if (b >= 0172) - { - if (bFspecial != 0) - { - if (bFspecial != 0176 || b != 0176) - { - ulog (LOG_ERROR, "Illegal bytes %d %d", - bFspecial, b); - bFspecial = 0; - continue; - } - - /* Pass any initial data. */ - if (zto != zstart) - { - /* Don't count the checksum in the received bytes. */ - cFrec_bytes += zfrom - zstart - 2; - cFrec_data += zto - zstart; - if (! fgot_data (zstart, zto - zstart, FALSE, - TRUE, pfexit)) - return FALSE; - } - - /* The next characters we want to read are the - checksum, so skip the second 0176. */ - iPrecstart = (iPrecstart + zfrom - zstart) % CRECBUFLEN; - - iFcheck = itmpchk; - - /* Tell fgot_data that we've read the entire file by - passing 0 length data. This will set *pfexit to - TRUE and call fffile to verify the checksum. */ - return fgot_data ((char *) NULL, 0, FALSE, TRUE, pfexit); - } - - /* Here we have encountered a special character that - does not follow another special character. */ - bFspecial = (char) b; - } - else - { - int bnext; - - /* Here we have encountered a nonspecial character. */ - - switch (bFspecial) - { - default: - bnext = b; - break; - case 0172: - bnext = b - 0100; - break; - case 0173: - case 0174: - bnext = b + 0100; - break; - case 0175: - bnext = b + 0200; - break; - case 0176: - bnext = b + 0300; - break; - } - - *zto++ = (char) bnext; - bFspecial = 0; - - /* Rotate the checksum left. */ - if ((itmpchk & 0x8000) == 0) - itmpchk <<= 1; - else - { - itmpchk <<= 1; - ++itmpchk; - } - - /* Add the next byte into the checksum. */ - itmpchk += bnext; - } - } - - if (zto != zstart) - { - DEBUG_MESSAGE1 (DEBUG_PROTO, - "ffprocess: Calling fgot_data with %d bytes", - zto - zstart); - - cFrec_data += zto - zstart; - if (! fgot_data (zstart, zto - zstart, FALSE, TRUE, pfexit)) - return FALSE; - } - - cFrec_bytes += zfrom - zstart; - - iPrecstart = (iPrecstart + zfrom - zstart) % CRECBUFLEN; - } - - iFcheck = itmpchk; - - if (pcneed != NULL) - { - /* At this point we may have seen the first 0176 in the checksum - but not the second. The checksum is at least seven - characters long (0176 0176 a b c d \r). This won't help - much, but reading seven characters is a lot better than - reading two, which is what I saw in a 2400 baud log file. */ - if (bFspecial == 0176) - *pcneed = 6; - else - *pcneed = 7; - } - - *pfexit = FALSE; - return TRUE; -} - -/* Wait for data to come in and process it until we've finished a - command or a file. */ - -boolean -ffwait () -{ - while (TRUE) - { - boolean fexit; - int cneed, crec; - - if (! ffprocess_data (&fexit, &cneed)) - return FALSE; - if (fexit) - return TRUE; - - /* We only ask for one character at a time. This could wind up - being quite inefficient, since we might only get one - character back from each read. We really want to do - something like get all available characters, then sleep for - half a second and get all available characters again, and - keep this up until we don't get anything after sleeping. */ - - if (! freceive_data (cneed, &crec, cFtimeout, TRUE)) - return FALSE; - - if (crec == 0) - { - ulog (LOG_ERROR, "Timed out waiting for data"); - return FALSE; - } - } -} - -/* File level operations. Reset the checksums when starting to send - or receive a file, and output the checksum when we've finished - sending a file. */ - -/*ARGSUSED*/ -boolean -fffile (fstart, fsend, pfredo, cbytes) - boolean fstart; - boolean fsend; - boolean *pfredo; - long cbytes; -{ - if (fstart) - { - iFcheck = 0xffff; - cFretries = 0; - if (! fsend) - { - bFspecial = 0; - fFfile = TRUE; - } - return TRUE; - } - else - { - const char *z; - - *pfredo = FALSE; - - if (fsend) - { - char ab[8]; - - /* Send the final checksum. */ - - sprintf (ab, "\176\176%04x\r", iFcheck & 0xffff); - if (! fsend_data (ab, 7, TRUE)) - return FALSE; - - /* Now look for the acknowledgement. */ - z = zgetcmd (); - if (z == NULL) - return FALSE; - - /* An R means to retry sending the file. */ - if (*z == 'R') - { - ++cFretries; - if (cFretries > cFmaxretries) - { - ulog (LOG_ERROR, "Too many retries"); - return FALSE; - } - *pfredo = TRUE; - iFcheck = 0xffff; - ++cFsend_retries; - return TRUE; - } - - if (*z == 'G') - return TRUE; - - DEBUG_MESSAGE1 (DEBUG_PROTO, "fffile: Got \"%s\"", z); - - ulog (LOG_ERROR, "File send failed"); - return FALSE; - } - else - { - unsigned int icheck; - - /* We next expect to receive a command. */ - fFfile = FALSE; - - /* Get the checksum. */ - z = zgetcmd (); - if (z == NULL) - return FALSE; - - if (strlen (z) != 4 - || ! isxdigit (z[0]) - || ! isxdigit (z[1]) - || ! isxdigit (z[2]) - || ! isxdigit (z[3])) - { - ulog (LOG_ERROR, "Bad checksum format"); - return FALSE; - } - - icheck = strtol (z, (char **) NULL, 16); - - if (icheck != (iFcheck & 0xffff)) - { - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "Checksum failed; calculated 0x%x, got 0x%x", - iFcheck & 0xffff, icheck); - - ++cFretries; - if (cFretries > cFmaxretries) - { - ulog (LOG_ERROR, "Too many retries"); - (void) ffsendcmd ("Q"); - return FALSE; - } - - *pfredo = TRUE; - iFcheck = 0xffff; - bFspecial = 0; - fFfile = TRUE; - ++cFrec_retries; - - /* Send an R to tell the other side to resend the file. */ - return ffsendcmd ("R"); - } - - /* Send a G to tell the other side the file was received - correctly. */ - return ffsendcmd ("G"); - } - } -} diff --git a/gnu/libexec/uucp/protg.c b/gnu/libexec/uucp/protg.c deleted file mode 100644 index 5e8c0b794428..000000000000 --- a/gnu/libexec/uucp/protg.c +++ /dev/null @@ -1,1932 +0,0 @@ -/* protg.c - The 'g' protocol. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: protg.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.31 1992/03/31 19:39:08 ian - Niels Baggesen: packet to retransmit did not get reset correctly - - Revision 1.30 1992/03/30 04:49:10 ian - Niels Baggesen: added debugging types abnormal and uucp-proto - - Revision 1.29 1992/03/16 18:57:38 ian - Niels Baggesen: improved debugging information - - Revision 1.28 1992/03/13 22:59:25 ian - Have breceive_char go through freceive_data - - Revision 1.27 1992/03/12 19:56:10 ian - Debugging based on types rather than number - - Revision 1.26 1992/03/03 21:18:31 ian - Aleksey P. Rudnev: added remote-window and packsize 'g' protocol parameters - - Revision 1.25 1992/02/25 18:47:38 ian - Bob Denny: reset timeouts only when data is recognized - - Revision 1.24 1992/02/19 19:36:07 ian - Rearranged time functions - - Revision 1.23 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.22 1992/02/01 00:56:20 ian - Chip Salzenberg: change default window size to 7 - - Revision 1.21 1992/01/28 16:06:24 ian - Correct previous patch - - Revision 1.20 1992/01/28 03:30:14 ian - John Antypas: bad boundary condition for command in small packet - - Revision 1.19 1992/01/19 23:01:21 ian - Dave Platt: send small packets to hold a small amount of data - - Revision 1.18 1992/01/16 23:46:40 ian - Zero out unused bytes in short packets - - Revision 1.17 1992/01/16 18:16:14 ian - Corrected misspelling in debugging message - - Revision 1.16 1992/01/07 17:11:15 ian - Discount out of order packets in the error count - - Revision 1.15 1992/01/04 22:15:41 ian - Mark Mallett: wait for INITx from master before sending our INITx - - Revision 1.14 1992/01/02 05:01:28 ian - Count rejections separately from resent packets - - Revision 1.13 1991/12/31 21:17:32 ian - Franc,ois Pinard: forgot to initialize cGdelayed_packets - - Revision 1.12 1991/12/30 04:07:13 ian - Don't send RR packets when a failure occurs - - Revision 1.11 1991/12/28 03:49:23 ian - Added HAVE_MEMFNS and HAVE_BFNS; changed uses of memset to bzero - - Revision 1.10 1991/12/27 06:01:55 ian - Check for configurable maximum number of errors - - Revision 1.9 1991/12/20 03:02:01 ian - Oleg Tabarovsky: added statistical messages to 'g' and 'f' protocols - - Revision 1.8 1991/12/17 22:13:14 ian - David Nugent: zero out garbage before sending data - - Revision 1.7 1991/12/11 15:02:45 ian - Tweaked initialization sequence slightly for better packet loss response - - Revision 1.6 1991/11/15 21:33:36 ian - Remove unreached line - - Revision 1.5 1991/11/15 21:00:59 ian - Efficiency hacks for 'f' and 't' protocols - - Revision 1.4 1991/11/11 00:39:45 ian - Open port in seven bit mode, added fport_set to change to eight bit - - Revision 1.3 1991/11/09 18:53:07 ian - Reworked protocol interface - - Revision 1.2 1991/11/08 04:07:04 ian - Brian Campbell: made cGsent_bytes and cGreceived_bytes long, not int - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char protg_rcsid[] = "$Id: protg.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#include "prot.h" -#include "system.h" -#include "port.h" - -/* Each 'g' protocol packet begins with six bytes. They are: - - - - is the ASCII DLE character (^P or '\020'). - if 1 <= <= 8, the packet is followed by 2 ** (k + 4) bytes of data; - if == 9, these six bytes are a complete control packet; - other value of are illegal. - is the low byte of a checksum. - is the high byte of a checksum. - is a control byte (see below). - is ^ ^ ^ . - - The control byte is divided into three bitfields: - - t t x x x y y y - - The two bit field tt is the packet type. - The three bit field xxx is the control type for a control packet, or - the sequence number for a data packet. - The three bit field yyy is a value for a control packet, or the - sequence number of the last packet received for a data packet. - - For all successfully recieved packets, the control byte is stored - into iGpacket_control. */ - -/* Names for the bytes in the frame header. */ - -#define IFRAME_DLE (0) -#define IFRAME_K (1) -#define IFRAME_CHECKLOW (2) -#define IFRAME_CHECKHIGH (3) -#define IFRAME_CONTROL (4) -#define IFRAME_XOR (5) - -/* Length of the frame header. */ -#define CFRAMELEN (6) - -/* Macros to break apart the control bytes. */ - -#define CONTROL_TT(b) ((int)(((b) >> 6) & 03)) -#define CONTROL_XXX(b) ((int)(((b) >> 3) & 07)) -#define CONTROL_YYY(b) ((int)((b) & 07)) - -/* DLE value. */ -#define DLE ('\020') - -/* Get the length of a packet given a pointer to the header. */ -#define CPACKLEN(z) (1 << ((z)[IFRAME_K] + 4)) - -/* field value for a control message. */ -#define KCONTROL (9) - -/* Get the next sequence number given a sequence number. */ -#define INEXTSEQ(i) ((i + 1) & 07) - -/* Compute i1 - i2 modulo 8. */ -#define CSEQDIFF(i1, i2) (((i1) + 8 - (i2)) & 07) - -/* Packet types. These are from the tt field. - CONTROL -- control packet - ALTCHAN -- alternate channel; not used by UUCP - DATA -- full data segment - SHORTDATA -- less than full data segment (all the bytes specified by - the packet length are always transferred). Let be the number - of bytes in the data segment not to be used. If <= 0x7f, the first - byte of the data segment is and the data follows. If > 0x7f, - the first byte of the data segment is 0x80 | ( & 0x7f), the second - byte of the data segment is >> 7, and the data follows. The - maximum possible data segment size is 2**12, so this handles all - possible cases. */ - -#define CONTROL (0) -#define ALTCHAN (1) -#define DATA (2) -#define SHORTDATA (3) - -/* Control types. These are from the xxx field if the type (tt field) - is CONTROL. - - CLOSE -- close the connection - RJ -- reject; packet yyy last to be received correctly - SRJ -- selective reject; reject only packet yyy (not used by UUCP) - RR -- receiver ready; packet yyy received correctly - INITC -- third step of initialization; yyy holds window size - INITB -- second step of initialization; yyy holds maximum value - 1 - INITA -- first step of initialization; yyy holds window size. - - The yyy value for RR is the same as the yyy value for an ordinary - data packet. */ - -#define CLOSE (1) -#define RJ (2) -#define SRJ (3) -#define RR (4) -#define INITC (5) -#define INITB (6) -#define INITA (7) - -/* Maximum amount of data in a single packet. This is set by the - field in the header; the amount of data in a packet is - 2 ** ( + 4). ranges from 1 to 8. */ - -#define CMAXDATAINDEX (8) - -#define CMAXDATA (1 << (CMAXDATAINDEX + 4)) - -/* Maximum window size. */ - -#define CMAXWINDOW (7) - -/* Defaults for the protocol parameters. These may all be changed by - using the ``protocol-parameter g'' command, so there is no - particular reason to change the values given here. */ - -/* The desired window size. This is what we tell the other system to - use. It must be between 1 and 7, and there's no reason to use less - than 7. Protocol parameter ``window''. */ -#define IWINDOW (7) - -/* The desired packet size. Many implementations only support 64 byte - packets. Protocol parameter ``packet-size''. */ -#define IPACKSIZE (64) - -/* The number of times to retry the exchange of INIT packets when - starting the protocol. Protocol parameter ``startup-retries''. */ -#define CSTARTUP_RETRIES (8) - -/* The timeout to use when waiting for an INIT packet when starting up - the protocol. Protocol parameter ``init-timeout''. */ -#define CEXCHANGE_INIT_TIMEOUT (10) - -/* The number of times to retry sending and waiting for a single INIT - packet when starting the protocol. This controls a single INIT - packet, while CSTARTUP_RETRIES controls how many times to try the - entire INIT sequence. Protocol parameter ``init-retries''. */ -#define CEXCHANGE_INIT_RETRIES (4) - -/* The timeout to use when waiting for a packet. Protocol parameter - ``timeout''. */ -#define CTIMEOUT (10) - -/* The number of times to retry waiting for a packet. Each time the - timeout fails we send a copy of our last data packet or a reject - message for the packet we expect from the other side, depending on - whether we are waiting for an acknowledgement or a data packet. - This is the number of times we try doing that and then waiting - again. Protocol parameter ``retries''. */ -#define CRETRIES (6) - -/* If we see more than this much unrecognized data, we drop the - connection. This must be larger than a single packet size, which - means it must be larger than 4096 (the largest possible packet - size). Protocol parameter ``garbage''. */ -#define CGARBAGE (10000) - -/* If we see more than this many protocol errors, we drop the - connection. Protocol parameter ``errors''. */ -#define CERRORS (100) - -/* If this value is non-zero, it will be used as the remote window - size regardless of what the other side requested. This can be - useful for dealing with some particularly flawed packages. This - default value should always be 0, and protocol parameter - ``remote-window'' should be used for the affected systems. */ -#define IREMOTE_WINDOW (0) - -/* If this value is non-zero, it will be used as the packet size to - send to the remote system regardless of what it requested. It's - difficult to imagine any circumstances where you would want to set - this. Protocol parameter ``remote-packet-size''. */ -#define IREMOTE_PACKSIZE (0) - -/* Local variables. */ - -/* Next sequence number to send. */ -static int iGsendseq; - -/* Last sequence number that has been acked. */ -static int iGremote_ack; - -/* Last sequence number to be retransmitted. */ -static int iGretransmit_seq; - -/* Last sequence number we have received. */ -static int iGrecseq; - -/* Last sequence number we have acked. */ -static int iGlocal_ack; - -/* Window size to request (protocol parameter ``window''). */ -static int iGrequest_winsize = IWINDOW; - -/* Packet size to request (protocol parameter ``packet-size''). */ -static int iGrequest_packsize = IPACKSIZE; - -/* Remote window size (set during handshake). */ -static int iGremote_winsize; - -/* Forced remote window size (protocol parameter ``remote-window''). */ -static int iGforced_remote_winsize = IREMOTE_WINDOW; - -/* Remote segment size (set during handshake). This is one less than - the value in a packet header. */ -static int iGremote_segsize; - -/* Remote packet size (set based on iGremote_segsize). */ -static int iGremote_packsize; - -/* Forced remote packet size (protocol parameter - ``remote-packet-size''). */ -static int iGforced_remote_packsize = IREMOTE_PACKSIZE; - -/* Recieved control byte. */ -static int iGpacket_control; - -/* Number of times to retry the initial handshake. Protocol parameter - ``startup-retries''. */ -static int cGstartup_retries = CSTARTUP_RETRIES; - -/* Number of times to retry sending an initial control packet. - Protocol parameter ``init-retries''. */ -static int cGexchange_init_retries = CEXCHANGE_INIT_RETRIES; - -/* Timeout (seconds) for receiving an initial control packet. - Protocol parameter ``init-timeout''. */ -static int cGexchange_init_timeout = CEXCHANGE_INIT_TIMEOUT; - -/* Timeout (seconds) for receiving a data packet. Protocol parameter - ``timeout''. */ -static int cGtimeout = CTIMEOUT; - -/* Maximum number of timeouts when receiving a data packet or - acknowledgement. Protocol parameter ``retries''. */ -static int cGretries = CRETRIES; - -/* Amount of garbage data we are prepared to see before giving up. - Protocol parameter ``garbage''. */ -static int cGgarbage_data = CGARBAGE; - -/* Maximum number of errors we are prepared to see before giving up. - Protocol parameter ``errors''. */ -static int cGmax_errors = CERRORS; - -/* Protocol parameter commands. */ - -struct scmdtab asGproto_params[] = -{ - { "window", CMDTABTYPE_INT, (pointer) &iGrequest_winsize, NULL }, - { "packet-size", CMDTABTYPE_INT, (pointer) &iGrequest_packsize, NULL }, - { "startup-retries", CMDTABTYPE_INT, (pointer) &cGstartup_retries, NULL }, - { "init-timeout", CMDTABTYPE_INT, (pointer) &cGexchange_init_timeout, - NULL }, - { "init-retries", CMDTABTYPE_INT, (pointer) &cGexchange_init_retries, - NULL }, - { "timeout", CMDTABTYPE_INT, (pointer) &cGtimeout, NULL }, - { "retries", CMDTABTYPE_INT, (pointer) &cGretries, NULL }, - { "garbage", CMDTABTYPE_INT, (pointer) &cGgarbage_data, NULL }, - { "errors", CMDTABTYPE_INT, (pointer) &cGmax_errors, NULL }, - { "remote-window", CMDTABTYPE_INT, (pointer) &iGforced_remote_winsize, - NULL }, - { "remote-packet-size", CMDTABTYPE_INT, (pointer) &iGforced_remote_packsize, - NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Statistics. */ - -/* Number of packets we have sent. */ -static long cGsent_packets; - -/* Number of packets we have resent (these are not included in - cGsent_packets). */ -static long cGresent_packets; - -/* Number of packets we have delayed sending (these should not be - counted in cGresent_packets). */ -static long cGdelayed_packets; - -/* Number of packets we have received. */ -static long cGrec_packets; - -/* Number of packets rejected because the header was bad. */ -static long cGbad_hdr; - -/* Number of packets rejected because the checksum was bad. */ -static long cGbad_checksum; - -/* Number of packets received out of order. */ -static long cGbad_order; - -/* Number of packets rejected by receiver (number of RJ packets - received). */ -static long cGremote_rejects; - -#if DEBUG > 1 -/* Control packet names used for debugging. */ -static const char * const azGcontrol[] = -{"?0?", "CLOSE", "RJ", "SRJ", "RR", "INITC", "INITB", "INITA"}; -#endif - -/* Local functions. */ - -static boolean fgexchange_init P((boolean fmaster, int ictl, int ival, - int *piset)); -static boolean fgsend_control P((int ictl, int ival)); -static void ugadjust_ack P((int iseq)); -static boolean fgwait_for_packet P((boolean freturncontrol, int ctimeout, - int cretries)); -static boolean fgsend_acks P((void)); -static boolean fggot_ack P((int iack)); -static boolean fgprocess_data P((boolean fdoacks, boolean freturncontrol, - boolean *pfexit, int *pcneed, - boolean *pffound)); -static boolean fginit_sendbuffers P((boolean fallocate)); -static boolean fgcheck_errors P((void)); -static int igchecksum P((const char *zdata, int clen)); -static int igchecksum2 P((const char *zfirst, int cfirst, - const char *zsecond, int csecond)); - -/* Start the protocol. This requires a three way handshake. Both sides - must send and receive an INITA packet, an INITB packet, and an INITC - packet. The INITA and INITC packets contain the window size, and the - INITB packet contains the packet size. */ - -boolean -fgstart (fmaster) - boolean fmaster; -{ - int iseg; - int i; - boolean fgota, fgotb; - - /* The 'g' protocol requires a full eight bit interface. */ - if (! fport_set (PORTSETTING_EIGHT)) - return FALSE; - - iGsendseq = 1; - iGremote_ack = 0; - iGretransmit_seq = -1; - iGrecseq = 0; - iGlocal_ack = 0; - cGsent_packets = 0; - cGresent_packets = 0; - cGdelayed_packets = 0; - cGrec_packets = 0; - cGbad_hdr = 0; - cGbad_checksum = 0; - cGbad_order = 0; - cGremote_rejects = 0; - - /* We must determine the segment size based on the packet size - which may have been modified by a protocol parameter command. - A segment size of 2^n is passed as n - 5. */ - - i = iGrequest_packsize; - iseg = -1; - while (i > 0) - { - ++iseg; - i >>= 1; - } - iseg -= 5; - if (iseg < 0 || iseg > 7) - { - ulog (LOG_ERROR, "Illegal packet size %d for 'g' protocol", - iGrequest_packsize); - iseg = 1; - } - - fgota = FALSE; - fgotb = FALSE; - for (i = 0; i < cGstartup_retries; i++) - { - if (fgota) - { - if (! fgsend_control (INITA, iGrequest_winsize)) - return FALSE; - } - else - { - if (! fgexchange_init (fmaster, INITA, iGrequest_winsize, - &iGremote_winsize)) - continue; - } - fgota = TRUE; - - if (fgotb) - { - if (! fgsend_control (INITB, iseg)) - return FALSE; - } - else - { - if (! fgexchange_init (fmaster, INITB, iseg, - &iGremote_segsize)) - continue; - } - fgotb = TRUE; - - if (! fgexchange_init (fmaster, INITC, iGrequest_winsize, - &iGremote_winsize)) - continue; - - /* We have succesfully connected. Determine the remote packet - size. */ - - iGremote_packsize = 1 << (iGremote_segsize + 5); - - /* If the user requested us to force specific remote window and - packet sizes, do so now. */ - - if (iGforced_remote_winsize > 0 - && iGforced_remote_winsize <= CMAXWINDOW) - iGremote_winsize = iGforced_remote_winsize; - - if (iGforced_remote_packsize >= 32 - && iGforced_remote_packsize <= 4096) - { - /* Force the value to a power of two. */ - i = iGforced_remote_packsize; - iseg = -1; - while (i > 0) - { - ++iseg; - i >>= 1; - } - iGremote_packsize = 1 << iseg; - } - - /* Set up packet buffers to use. We don't do this until we know - the maximum packet size we are going to send. */ - if (! fginit_sendbuffers (TRUE)) - return FALSE; - - DEBUG_MESSAGE2 (DEBUG_PROTO, - "fgstart: Protocol started; packsize %d, winsize %d", - iGremote_packsize, iGremote_winsize); - - return TRUE; - } - - DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgstart: Protocol startup failed"); - - return FALSE; -} - -/* Exchange initialization messages with the other system. - - A problem: - - We send INITA; it gets received - We receive INITA - We send INITB; it gets garbled - We receive INITB - - We have seen and sent INITB, so we start to send INITC. The other - side as sent INITB but not seen it, so it times out and resends - INITB. We will continue sending INITC and the other side will - continue sending INITB until both sides give up and start again - with INITA. - - It might seem as though if we are sending INITC and receive INITB, - we should resend our INITB, but this could cause infinite echoing - of INITB on a long-latency line. Rather than risk that, I have - implemented a fast drop-back procedure. If we are sending INITB and - receive INITC, the other side has gotten ahead of us. We immediately - fail and begin again with INITA. For the other side, if we are - sending INITC and see INITA, we also immediately fail back to INITA. - - Unfortunately, this doesn't work for the other case, in which we - are sending INITB but the other side has not yet seen INITA. As - far as I can see, if this happens we just have to wait until we - time out and resend INITA. */ - -/*ARGSUSED*/ -static boolean -fgexchange_init (fmaster, ictl, ival, piset) - boolean fmaster; - int ictl; - int ival; - int *piset; -{ - int i; - - /* The three-way handshake should be independent of who initializes - it, but it seems that some versions of uucico assume that the - master sends first and the slave responds. This only matters if - we are the slave and the first packet is garbled. If we send a - packet, the other side will assume that we must have seen the - packet they sent and will never time out and send it again. - Therefore, if we are the slave we don't send a packet the first - time through the loop. This can still fail, but should usually - work, and, after all, if the initialization packets are received - correctly there will be no problem no matter what we do. */ - - for (i = 0; i < cGexchange_init_retries; i++) - { - long itime; - int ctimeout; - - if (fmaster || i > 0) - { - if (! fgsend_control (ictl, ival)) - return FALSE; - } - - itime = isysdep_time ((long *) NULL); - ctimeout = cGexchange_init_timeout; - - do - { - long inewtime; - - /* We pass 0 as the retry count to fgwait_for_packet because - we want to handle retries here and because if it retried - it would send a packet, which would be bad. */ - - if (! fgwait_for_packet (TRUE, ctimeout, 0)) - break; - - if (CONTROL_TT (iGpacket_control) == CONTROL) - { - if (CONTROL_XXX (iGpacket_control) == ictl) - { - *piset = CONTROL_YYY (iGpacket_control); - - /* If we didn't already send our initialization - packet, send it now. */ - if (! fmaster && i == 0) - { - if (! fgsend_control (ictl, ival)) - return FALSE; - } - - return TRUE; - } - - /* If the other side is farther along than we are, - we have lost a packet. Fail immediately back to - INITA (but don't fail if we are already doing INITA, - since that would count against cStart_retries more - than it should). */ - if (CONTROL_XXX (iGpacket_control) < ictl && ictl != INITA) - return FALSE; - - /* If we are sending INITC and we receive an INITA, the other - side has failed back (we know this because we have - seen an INITB from them). Fail back ourselves to - start the whole handshake over again. */ - if (CONTROL_XXX (iGpacket_control) == INITA && ictl == INITC) - return FALSE; - } - - inewtime = isysdep_time ((long *) NULL); - ctimeout -= inewtime - itime; - } - while (ctimeout > 0); - } - - return FALSE; -} - -/* Shut down the protocol. */ - -boolean -fgshutdown () -{ - (void) fgsend_control (CLOSE, 0); - (void) fgsend_control (CLOSE, 0); - (void) fginit_sendbuffers (FALSE); - - /* The count of sent packets may not be accurate, because some of - them may have not been sent yet if the connection failed in the - middle (the ones that counted for cGdelayed_packets). I don't - think it's worth being precise. */ - ulog (LOG_NORMAL, - "Protocol 'g' packets: sent %ld, resent %ld, received %ld", - cGsent_packets, cGresent_packets - cGdelayed_packets, - cGrec_packets); - if (cGbad_hdr != 0 - || cGbad_checksum != 0 - || cGbad_order != 0 - || cGremote_rejects != 0) - ulog (LOG_NORMAL, - "Errors: header %ld, checksum %ld, order %ld, remote rejects %ld", - cGbad_hdr, cGbad_checksum, cGbad_order, cGremote_rejects); - - /* Reset all the parameters to their default values, so that the - protocol parameters used for this connection do not affect the - next one. */ - iGrequest_winsize = IWINDOW; - iGrequest_packsize = IPACKSIZE; - cGstartup_retries = CSTARTUP_RETRIES; - cGexchange_init_timeout = CEXCHANGE_INIT_TIMEOUT; - cGexchange_init_retries = CEXCHANGE_INIT_RETRIES; - cGtimeout = CTIMEOUT; - cGretries = CRETRIES; - cGgarbage_data = CGARBAGE; - cGmax_errors = CERRORS; - iGforced_remote_winsize = IREMOTE_WINDOW; - iGforced_remote_packsize = IREMOTE_PACKSIZE; - - return TRUE; -} - -/* Send a command string. We send packets containing the string until - the entire string has been sent. Each packet is full. */ - -boolean -fgsendcmd (z) - const char *z; -{ - int clen; - boolean fagain; - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fgsendcmd: Sending command \"%s\"", z); - - clen = strlen (z); - - do - { - char *zpacket; - int cdummy; - - zpacket = zggetspace (&cdummy); - - if (clen < iGremote_packsize) - { - int csize; - - /* If the remote packet size is larger than 64 (the default, - which may indicate an older UUCP package), try to fit - this command into a smaller packet. We still always send - a complete packet, though. */ - - if (iGremote_packsize <= 64) - csize = iGremote_packsize; - else - { - csize = 32; - while (csize <= clen) - csize <<= 1; - } - - strcpy (zpacket, z); - bzero (zpacket + clen, csize - clen); - fagain = FALSE; - - if (! fgsenddata (zpacket, csize)) - return FALSE; - } - else - { - memcpy (zpacket, z, iGremote_packsize); - z += iGremote_packsize; - clen -= iGremote_packsize; - fagain = TRUE; - - if (! fgsenddata (zpacket, iGremote_packsize)) - return FALSE; - } - } - while (fagain); - - return TRUE; -} - -/* We keep an array of buffers to retransmit as necessary. Rather - than waste static space on large buffer sizes, we allocate the - buffers once we know how large the other system expects them to be. - The sequence numbers used in the 'g' protocol are only three bits - long, so we allocate eight buffers and maintain a correspondence - between buffer index and sequence number. This always wastes some - buffer space, but it's easy to implement. */ - -#define CSENDBUFFERS (CMAXWINDOW + 1) - -static char *azGsendbuffers[CSENDBUFFERS]; - -static boolean -fginit_sendbuffers (fallocate) - boolean fallocate; -{ - int i; - - /* Free up any remaining old buffers. */ - - for (i = 0; i < CSENDBUFFERS; i++) - { - xfree ((pointer) azGsendbuffers[i]); - if (fallocate) - { - azGsendbuffers[i] = (char *) malloc (CFRAMELEN + iGremote_packsize); - if (azGsendbuffers[i] == NULL) - return FALSE; - bzero (azGsendbuffers[i], CFRAMELEN + iGremote_packsize); - } - else - azGsendbuffers[i] = NULL; - } - return TRUE; -} - -/* Allocate a packet to send out. The return value of this function - must be filled in and passed to fgsenddata, or discarded. This - will ensure that the buffers and iGsendseq stay in synch. Set - *pclen to the amount of data to place in the buffer. */ - -char * -zggetspace (pclen) - int *pclen; -{ - *pclen = iGremote_packsize; - return azGsendbuffers[iGsendseq] + CFRAMELEN; -} - -/* Send out a data packet. This computes the checksum, sets up the - header, and sends the packet out. The argument should point to the - return value of zggetspace. */ - -boolean -fgsenddata (zdata, cdata) - char *zdata; - int cdata; -{ - char *z; - int itt, iseg, csize; - unsigned short icheck; - - /* Set the initial length bytes. See the description at the definition - of SHORTDATA, above. */ - - itt = DATA; - csize = iGremote_packsize; - iseg = iGremote_segsize + 1; - -#if DEBUG > 0 - if (cdata > iGremote_packsize) - ulog (LOG_FATAL, "fgsend_packet: Packet size too large"); -#endif - - if (cdata < iGremote_packsize) - { - /* If the remote packet size is larger than 64, the default, we - can assume they can handle a smaller packet as well, which - will be more efficient to send. */ - if (iGremote_packsize > 64) - { - /* The packet size is 1 << (iseg + 4). */ - iseg = 1; - csize = 32; - while (csize < cdata) - { - csize <<= 1; - ++iseg; - } - } - - if (csize != cdata) - { - int cshort; - - /* We have to move the data within the packet, - unfortunately. It's tough to see any way around this - without going to some sort of iovec structure. It only - happens once per file transfer. It would also be nice if - we computed the checksum as we move. We zero out the - unused bytes, since it makes people happy. */ - - itt = SHORTDATA; - cshort = csize - cdata; - if (cshort <= 127) - { - xmemmove (zdata + 1, zdata, cdata); - zdata[0] = (char) cshort; - bzero (zdata + cdata + 1, cshort - 1); - } - else - { - xmemmove (zdata + 2, zdata, cdata); - zdata[0] = (char) (0x80 | (cshort & 0x7f)); - zdata[1] = (char) (cshort >> 7); - bzero (zdata + cdata + 2, cshort - 2); - } - } - } - - z = zdata - CFRAMELEN; - - z[IFRAME_DLE] = DLE; - z[IFRAME_K] = (char) iseg; - - icheck = (unsigned short) igchecksum (zdata, csize); - - /* We're just about ready to go. Wait until there is room in the - receiver's window for us to send the packet. We do this now so - that we send the correct value for the last packet received. - Note that if iGsendseq == iGremote_ack, this means that the - sequence numbers are actually 8 apart, since the packet could not - have been acknowledged before it was sent; this can happen when - the window size is 7. */ - while (iGsendseq == iGremote_ack - || CSEQDIFF (iGsendseq, iGremote_ack) > iGremote_winsize) - { - if (! fgwait_for_packet (TRUE, cGtimeout, cGretries)) - return FALSE; - } - - /* Ack all packets up to the next one, since the UUCP protocol - requires that all packets be acked in order. */ - while (CSEQDIFF (iGrecseq, iGlocal_ack) > 1) - { - iGlocal_ack = INEXTSEQ (iGlocal_ack); - if (! fgsend_control (RR, iGlocal_ack)) - return FALSE; - } - iGlocal_ack = iGrecseq; - - z[IFRAME_CONTROL] = (char) ((itt << 6) | (iGsendseq << 3) | iGrecseq); - - iGsendseq = INEXTSEQ (iGsendseq); - - icheck = ((unsigned short) - ((0xaaaa - (icheck ^ (z[IFRAME_CONTROL] & 0xff))) & 0xffff)); - z[IFRAME_CHECKLOW] = (char) (icheck & 0xff); - z[IFRAME_CHECKHIGH] = (char) (icheck >> 8); - - z[IFRAME_XOR] = (char) (z[IFRAME_K] ^ z[IFRAME_CHECKLOW] - ^ z[IFRAME_CHECKHIGH] ^ z[IFRAME_CONTROL]); - - /* If we've retransmitted a packet, but it hasn't been acked yet, - and this isn't the next packet after the retransmitted one (note - that iGsendseq has already been incremented at this point) then - don't send this packet yet. The other side is probably not ready - for it yet. Instead, code in fgprocess_data will send the - outstanding packets when an ack is received. */ - - ++cGsent_packets; - - if (iGretransmit_seq != -1 - && INEXTSEQ (INEXTSEQ (iGretransmit_seq)) != iGsendseq) - { - ++cGdelayed_packets; - return TRUE; - } - - iGretransmit_seq = -1; - - DEBUG_MESSAGE2 (DEBUG_PROTO, - "fgsenddata: Sending packet %d (%d bytes)", - CONTROL_XXX (z[IFRAME_CONTROL]), cdata); - - return fsend_data (z, CFRAMELEN + csize, TRUE); -} - -/* Recompute the control byte and checksum of a packet so that it - includes the correct packet acknowledgement. This is called - when a packet is retransmitted to make sure the retransmission - does not confuse the other side. */ - -static void -ugadjust_ack (iseq) - int iseq; -{ - char *z; - unsigned short icheck; - - z = azGsendbuffers[iseq]; - - /* If the received packet number is the same, there is nothing - to do. */ - if (CONTROL_YYY (z[IFRAME_CONTROL]) == iGrecseq) - return; - - /* Get the old checksum. */ - icheck = (unsigned short) (((z[IFRAME_CHECKHIGH] & 0xff) << 8) - | (z[IFRAME_CHECKLOW] & 0xff)); - icheck = ((unsigned short) - (((0xaaaa - icheck) ^ (z[IFRAME_CONTROL] & 0xff)) & 0xffff)); - - /* Update the control byte. */ - z[IFRAME_CONTROL] = (char) ((z[IFRAME_CONTROL] &~ 07) | iGrecseq); - - /* Create the new checksum. */ - icheck = ((unsigned short) - ((0xaaaa - (icheck ^ (z[IFRAME_CONTROL] & 0xff))) & 0xffff)); - z[IFRAME_CHECKLOW] = (char) (icheck & 0xff); - z[IFRAME_CHECKHIGH] = (char) (icheck >> 8); - - /* Update the XOR byte. */ - z[IFRAME_XOR] = (char) (z[IFRAME_K] ^ z[IFRAME_CHECKLOW] - ^ z[IFRAME_CHECKHIGH] ^ z[IFRAME_CONTROL]); -} - -/* Send a control packet. These are fairly simple to construct. It - seems reasonable to me that we should be able to send a control - packet at any time, even if the receive window is closed. In - particular, we don't want to delay when sending a CLOSE control - message. If I'm wrong, it can be changed easily enough. */ - -static boolean -fgsend_control (ixxx, iyyy) - int ixxx; - int iyyy; -{ - char ab[CFRAMELEN]; - int ictl; - unsigned short icheck; - - DEBUG_MESSAGE2 (DEBUG_PROTO, - "fgsend_control: Sending control %s %d", - azGcontrol[ixxx], iyyy); - - ab[IFRAME_DLE] = DLE; - ab[IFRAME_K] = KCONTROL; - - ictl = (CONTROL << 6) | (ixxx << 3) | iyyy; - icheck = (unsigned short) (0xaaaa - ictl); - ab[IFRAME_CHECKLOW] = (char) (icheck & 0xff); - ab[IFRAME_CHECKHIGH] = (char) (icheck >> 8); - - ab[IFRAME_CONTROL] = (char) ictl; - - ab[IFRAME_XOR] = (char) (ab[IFRAME_K] ^ ab[IFRAME_CHECKLOW] - ^ ab[IFRAME_CHECKHIGH] ^ ab[IFRAME_CONTROL]); - - return fsend_data (ab, CFRAMELEN, TRUE); -} - -/* Process existing data. Set *pfexit to TRUE if a file or a command - has been completely received. Return FALSE on error. */ - -boolean -fgprocess (pfexit) - boolean *pfexit; -{ - /* Don't ack incoming data (since this is called when a file is - being sent and the acks can be merged onto the outgoing data), - don't return after receiving a control packet, and don't bother - to report how much more data is needed or whether any packets - were found. */ - return fgprocess_data (FALSE, FALSE, pfexit, (int *) NULL, - (boolean *) NULL); -} - -/* Wait for data to come in. This continues processing until a - complete file or command has been received. */ - -boolean -fgwait () -{ - return fgwait_for_packet (FALSE, cGtimeout, cGretries); -} - -/* Get a packet. This is called when we have nothing to send, but - want to wait for a packet to come in. If freturncontrol is TRUE, - this will return after getting any control packet. Otherwise, it - will continue to receive packets until a complete file or a - complete command has been received. The timeout and the number of - retries are specified as arguments. The function returns FALSE if - an error occurs or if cretries timeouts of ctimeout seconds were - exceeded. */ - -static boolean -fgwait_for_packet (freturncontrol, ctimeout, cretries) - boolean freturncontrol; - int ctimeout; - int cretries; -{ - int ctimeouts; - int cgarbage; - int cshort; - - ctimeouts = 0; - cgarbage = 0; - cshort = 0; - - while (TRUE) - { - boolean fexit; - int cneed; - boolean ffound; - int crec; - - if (! fgprocess_data (TRUE, freturncontrol, &fexit, &cneed, &ffound)) - return FALSE; - - if (fexit) - return TRUE; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fgwait_for_packet: Need %d bytes", cneed); - - if (ffound) - { - ctimeouts = 0; - cgarbage = 0; - } - else - { - if (cgarbage > cGgarbage_data) - { - ulog (LOG_ERROR, "Too much unrecognized data"); - return FALSE; - } - } - - if (! freceive_data (cneed, &crec, ctimeout, TRUE)) - return FALSE; - - cgarbage += crec; - - if (crec != 0) - { - /* If we don't get enough data twice in a row, we may have - dropped some data and still be looking for the end of a - large packet. Incrementing iPrecstart will force - fgprocess_data to skip that packet and look through the - rest of the data. In some situations, this will be a - mistake. */ - if (crec >= cneed) - cshort = 0; - else - { - ++cshort; - if (cshort > 1) - { - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - cshort = 0; - } - } - } - else - { - /* The read timed out. If we're looking for a control - packet, assume we're looking for an ack and send the last - unacknowledged packet again. Otherwise, send an RJ with - the last packet we received correctly. */ - - ++ctimeouts; - if (ctimeouts > cretries) - { - if (cretries > 0) - ulog (LOG_ERROR, "Timed out waiting for packet"); - return FALSE; - } - - if (freturncontrol - && INEXTSEQ (iGremote_ack) != iGsendseq) - { - int inext; - - inext = INEXTSEQ (iGremote_ack); - - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgwait_for_packet: Resending packet %d", - inext); - - ugadjust_ack (inext); - ++cGresent_packets; - if (! fsend_data (azGsendbuffers[inext], - CFRAMELEN + CPACKLEN (azGsendbuffers[inext]), - TRUE)) - return FALSE; - iGretransmit_seq = inext; - } - else - { - /* Send all pending acks first, to avoid confusing - the other side. */ - if (iGlocal_ack != iGrecseq) - { - if (! fgsend_acks ()) - return FALSE; - } - if (! fgsend_control (RJ, iGrecseq)) - return FALSE; - } - } - } -} - -/* Send acks for all packets we haven't acked yet. */ - -static boolean -fgsend_acks () -{ - while (iGlocal_ack != iGrecseq) - { - iGlocal_ack = INEXTSEQ (iGlocal_ack); - if (! fgsend_control (RR, iGlocal_ack)) - return FALSE; - } - return TRUE; -} - -/* Handle an ack of a packet. According to Hanrahan's paper, this - acknowledges all previous packets. If this is an ack for a - retransmitted packet, continue by resending up to two more packets - following the retransmitted one. This should recover quickly from - a line glitch, while avoiding the problem of continual - retransmission. */ - -static boolean -fggot_ack (iack) - int iack; -{ - int inext; - - iGremote_ack = iack; - - if (iack != iGretransmit_seq) - return TRUE; - - inext = INEXTSEQ (iGretransmit_seq); - if (inext == iGsendseq) - iGretransmit_seq = -1; - else - { - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fggot_ack: Sending packet %d", inext); - - ugadjust_ack (inext); - ++cGresent_packets; - if (! fsend_data (azGsendbuffers[inext], - CFRAMELEN + CPACKLEN (azGsendbuffers[inext]), - TRUE)) - return FALSE; - inext = INEXTSEQ (inext); - if (inext == iGsendseq) - iGretransmit_seq = -1; - else - { - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fggot_ack: Sending packet %d", inext); - - ugadjust_ack (inext); - ++cGresent_packets; - if (! fsend_data (azGsendbuffers[inext], - CFRAMELEN + CPACKLEN (azGsendbuffers[inext]), - TRUE)) - return FALSE; - iGretransmit_seq = inext; - } - } - - return TRUE; -} - -/* See if we've received more than the permitted number of errors. If - we receive a bad packet, we can expect a window full (less one) of - out of order packets to follow, so we discount cGbad_order - accordingly. */ - -static boolean -fgcheck_errors () -{ - int corder; - - if (cGmax_errors < 0) - return TRUE; - - corder = (cGbad_order - - ((cGbad_hdr + cGbad_checksum) * (iGremote_winsize - 1))); - if (corder < 0) - corder = 0; - - if ((cGbad_hdr + cGbad_checksum + corder + cGremote_rejects) - > cGmax_errors) - { - ulog (LOG_ERROR, "Too many 'g' protocol errors"); - return FALSE; - } - - return TRUE; -} - -/* Process the receive buffer into a data packet, if possible. All - control packets are handled here. When a data packet is received, - fgprocess_data calls fgot_data with the data; if that sets its - pfexit argument to TRUE fgprocess_data will set *pfexit to TRUE and - return TRUE. Otherwise if the freturncontrol argument is TRUE - fgprocess_data will set *pfexit to FALSE and return TRUE. - Otherwise fgprocess_data will continue trying to process data. If - some error occurs, fgprocess_data will return FALSE. If there is - not enough data to form a complete packet, then *pfexit will be set - to FALSE, *pcneed will be set to the number of bytes needed to form - a complete packet (unless pcneed is NULL) and fgprocess_data will - return TRUE. If this function found a data packet, and pffound is - not NULL, it will set *pffound to TRUE; this can be used to tell - valid data from an endless stream of garbage and control packets. - If fdoacks is TRUE, received packets will be acknowledged; - otherwise they must be acknowledged later. */ - -static boolean -fgprocess_data (fdoacks, freturncontrol, pfexit, pcneed, pffound) - boolean fdoacks; - boolean freturncontrol; - boolean *pfexit; - int *pcneed; - boolean *pffound; -{ - *pfexit = FALSE; - if (pffound != NULL) - *pffound = FALSE; - - while (iPrecstart != iPrecend) - { - char ab[CFRAMELEN]; - int i, iget, cwant; - unsigned short ihdrcheck, idatcheck; - const char *zfirst, *zsecond; - int cfirst, csecond; - - /* Look for the DLE which must start a packet. */ - - if (abPrecbuf[iPrecstart] != DLE) - { - char *zdle; - - cfirst = iPrecend - iPrecstart; - if (cfirst < 0) - cfirst = CRECBUFLEN - iPrecstart; - - zdle = memchr (abPrecbuf + iPrecstart, DLE, cfirst); - - if (zdle == NULL) - { - iPrecstart = (iPrecstart + cfirst) % CRECBUFLEN; - continue; - } - - /* We don't need % CRECBUFLEN here because zdle - (abPrecbuf - + iPrecstart) < cfirst <= CRECBUFLEN - iPrecstart. */ - iPrecstart += zdle - (abPrecbuf + iPrecstart); - } - - /* Get the first six bytes into ab. */ - - for (i = 0, iget = iPrecstart; - i < CFRAMELEN && iget != iPrecend; - i++, iget = (iget + 1) % CRECBUFLEN) - ab[i] = abPrecbuf[iget]; - - /* If there aren't six bytes, there is no packet. */ - - if (i < CFRAMELEN) - { - if (pcneed != NULL) - *pcneed = CFRAMELEN - i; - return TRUE; - } - - /* Make sure these six bytes start a packet. The check on - IFRAME_DLE is basically a debugging check, since the above - code should have ensured that it will never fail. If this is - not the start of a packet, bump iPrecstart and loop around to - look for another DLE. */ - - if (ab[IFRAME_DLE] != DLE - || ab[IFRAME_K] < 1 - || ab[IFRAME_K] > 9 - || ab[IFRAME_XOR] != (ab[IFRAME_K] ^ ab[IFRAME_CHECKLOW] - ^ ab[IFRAME_CHECKHIGH] ^ ab[IFRAME_CONTROL]) - || CONTROL_TT (ab[IFRAME_CONTROL]) == ALTCHAN) - { - ++cGbad_hdr; - - DEBUG_MESSAGE4 - (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Bad header: K %d TT %d XOR byte %d calc %d", - ab[IFRAME_K] & 0xff, - CONTROL_TT (ab[IFRAME_CONTROL]), - ab[IFRAME_XOR] & 0xff, - (ab[IFRAME_K] ^ ab[IFRAME_CHECKLOW] - ^ ab[IFRAME_CHECKHIGH] ^ ab[IFRAME_CONTROL]) & 0xff); - - if (! fgcheck_errors ()) - return FALSE; - - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - continue; - } - - /* The zfirst and cfirst pair point to the first set of data for - this packet; the zsecond and csecond point to the second set, - in case the packet wraps around the end of the buffer. */ - zfirst = abPrecbuf + iPrecstart + CFRAMELEN; - cfirst = 0; - zsecond = NULL; - csecond = 0; - - if (ab[IFRAME_K] == KCONTROL) - { - /* This is a control packet. It should not have any data. */ - - if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL) - { - ++cGbad_hdr; - - DEBUG_MESSAGE0 - (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Bad header: control packet with data"); - - if (! fgcheck_errors ()) - return FALSE; - - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - continue; - } - - idatcheck = (unsigned short) (0xaaaa - ab[IFRAME_CONTROL]); - cwant = 0; - } - else - { - int cinbuf; - unsigned short icheck; - - /* This is a data packet. It should not be type CONTROL. */ - - if (CONTROL_TT (ab[IFRAME_CONTROL]) == CONTROL) - { - ++cGbad_hdr; - - DEBUG_MESSAGE0 - (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Bad header: data packet is type CONTROL"); - - if (! fgcheck_errors ()) - return FALSE; - - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - continue; - } - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - cinbuf -= CFRAMELEN; - - /* Make sure we have enough data. If we don't, wait for - more. */ - - cwant = CPACKLEN (ab); - if (cinbuf < cwant) - { - if (pcneed != NULL) - *pcneed = cwant - cinbuf; - return TRUE; - } - - /* Set up the data pointers and compute the checksum. */ - - if (iPrecend >= iPrecstart) - cfirst = cwant; - else - { - cfirst = CRECBUFLEN - (iPrecstart + CFRAMELEN); - if (cfirst >= cwant) - cfirst = cwant; - else if (cfirst > 0) - { - zsecond = abPrecbuf; - csecond = cwant - cfirst; - } - else - { - /* Here cfirst is non-positive, so subtracting from - abPrecbuf will actually skip the appropriate number - of bytes at the start of abPrecbuf. */ - zfirst = abPrecbuf - cfirst; - cfirst = cwant; - } - } - - if (csecond == 0) - icheck = (unsigned short) igchecksum (zfirst, cfirst); - else - icheck = (unsigned short) igchecksum2 (zfirst, cfirst, - zsecond, csecond); - - idatcheck = ((unsigned short) - (((0xaaaa - (icheck ^ (ab[IFRAME_CONTROL] & 0xff))) - & 0xffff))); - } - - ihdrcheck = (unsigned short) (((ab[IFRAME_CHECKHIGH] & 0xff) << 8) - | (ab[IFRAME_CHECKLOW] & 0xff)); - - if (ihdrcheck != idatcheck) - { - DEBUG_MESSAGE2 - (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Bad checksum: header 0x%x, data 0x%x", - ihdrcheck, idatcheck); - - ++cGbad_checksum; - if (! fgcheck_errors ()) - return FALSE; - - /* If the checksum failed for a data packet, then if it was - the one we were expecting send an RJ, otherwise ignore - it. Previously if this code got the wrong packet number - it would send an RR, but that may confuse some Telebit - modems and it doesn't help in any case since the receiver - will probably just ignore the RR as a duplicate (that's - basically what this code does). If we totally missed the - packet we will time out and send an RJ in the function - fgwait_for_packet above. */ - - if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL) - { - /* Make sure we've acked everything up to this point. */ - if (iGrecseq != iGlocal_ack) - { - if (! fgsend_acks ()) - return FALSE; - } - - /* If this is the packet we wanted, tell the sender that - it failed. */ - if (CONTROL_XXX (ab[IFRAME_CONTROL]) == INEXTSEQ (iGrecseq)) - { - if (! fgsend_control (RJ, iGrecseq)) - return FALSE; - } - } - - /* We can't skip the packet data after this, because if we - have lost incoming bytes the next DLE will be somewhere - in what we thought was the packet data. */ - - iPrecstart = (iPrecstart + 1) % CRECBUFLEN; - continue; - } - - /* We have a packet; remove the processed bytes from the receive - buffer. */ - iPrecstart = (iPrecstart + cwant + CFRAMELEN) % CRECBUFLEN; - - /* Store the control byte for the handshake routines. */ - iGpacket_control = ab[IFRAME_CONTROL] & 0xff; - - /* Update the received sequence number from the yyy field of a - data packet or an RR control packet. If we've been delaying - sending packets until we received an ack, this may send out - some packets. */ - if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL - || CONTROL_XXX (ab[IFRAME_CONTROL]) == RR) - { - if (! fggot_ack (CONTROL_YYY (ab[IFRAME_CONTROL]))) - return FALSE; - } - - /* If this isn't a control message, make sure we have received - the expected packet sequence number, acknowledge the packet - if it's the right one, and process the data. */ - - if (CONTROL_TT (ab[IFRAME_CONTROL]) != CONTROL) - { - if (CONTROL_XXX (ab[IFRAME_CONTROL]) != INEXTSEQ (iGrecseq)) - { - /* We got the wrong packet number. */ - DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Got packet %d; expected %d", - CONTROL_XXX (ab[IFRAME_CONTROL]), - INEXTSEQ (iGrecseq)); - - ++cGbad_order; - if (! fgcheck_errors ()) - return FALSE; - - /* This code used to send an RR to encourage the other - side to get back in synch, but that may confuse some - Telebit modems and does little good in any case, - since the other side will probably just ignore it - anyhow (that's what this code does). */ - - continue; - } - - /* We got the packet we expected. */ - - ++cGrec_packets; - - iGrecseq = INEXTSEQ (iGrecseq); - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fgprocess_data: Got packet %d", iGrecseq); - - /* Tell the caller that we found something. */ - if (pffound != NULL) - *pffound = TRUE; - - /* If we are supposed to do acknowledgements here, send back - an RR packet. */ - - if (fdoacks) - { - if (! fgsend_acks ()) - return FALSE; - } - - /* If this is a short data packet, adjust the data pointers - and lengths. */ - - if (CONTROL_TT (ab[IFRAME_CONTROL]) == SHORTDATA) - { - int cshort, cmove; - - if ((zfirst[0] & 0x80) == 0) - { - cshort = zfirst[0] & 0xff; - cmove = 1; - } - else - { - int cbyte2; - - if (cfirst > 1) - cbyte2 = zfirst[1] & 0xff; - else - cbyte2 = zsecond[0] & 0xff; - cshort = (zfirst[0] & 0x7f) + (cbyte2 << 7); - cmove = 2; - } - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "fgprocess_data: Packet short by %d", - cshort); - - /* Adjust the start of the buffer for the bytes used - by the count. */ - if (cfirst > cmove) - { - zfirst += cmove; - cfirst -= cmove; - } - else - { - zfirst = zsecond + (cmove - cfirst); - cfirst = csecond - (cmove - cfirst); - csecond = 0; - } - - /* Adjust the length of the buffer for the bytes we are - not supposed to consider. */ - cshort -= cmove; - if (csecond >= cshort) - csecond -= cshort; - else - { - cfirst -= cshort - csecond; - csecond = 0; - } - -#if DEBUG > 0 - /* This should not happen, but just in case. */ - if (cfirst < 0) - cfirst = 0; -#endif - } - - /* If *pfexit gets set by the first batch of data, and there - is still more data, it must be the case that we are - accumulating a command and encountered a null byte, so we - can ignore the second batch of data. */ - - if (! fgot_data (zfirst, cfirst, FALSE, FALSE, pfexit)) - return FALSE; - if (csecond > 0 && ! *pfexit) - { - if (! fgot_data (zsecond, csecond, FALSE, FALSE, pfexit)) - return FALSE; - } - - /* If fgot_data told us that we were finished, get out. */ - if (*pfexit) - return TRUE; - - /* If we've been asked to return control packets, get out - now. */ - if (freturncontrol) - { - *pfexit = TRUE; - return TRUE; - } - - continue; - } - - /* Handle control messages here. */ - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_PROTO) - || (FDEBUGGING (DEBUG_ABNORMAL) - && CONTROL_XXX (ab[IFRAME_CONTROL]) != RR)) - ulog (LOG_DEBUG, "fgprocess_data: Got control %s %d", - azGcontrol[CONTROL_XXX (ab[IFRAME_CONTROL])], - CONTROL_YYY (ab[IFRAME_CONTROL])); -#endif - - switch (CONTROL_XXX (ab[IFRAME_CONTROL])) - { - case CLOSE: - /* The other side has closed the connection. */ - if (fPerror_ok) - (void) fgshutdown (); - else - { - ulog (LOG_ERROR, "Received unexpected CLOSE packet"); - (void) fgsend_control (CLOSE, 0); - } - return FALSE; - case RJ: - /* The other side dropped a packet. Begin retransmission with - the packet following the one acknowledged. We don't - retransmit the packets immediately, but instead wait - for the first one to be acked. This prevents us from - sending an entire window several times if we get several - RJ packets. */ - iGremote_ack = CONTROL_YYY (ab[IFRAME_CONTROL]); - iGretransmit_seq = INEXTSEQ (iGremote_ack); - if (iGretransmit_seq == iGsendseq) - iGretransmit_seq = -1; - else - { - char *zpack; - - DEBUG_MESSAGE2 - (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Remote reject: next %d resending %d", - iGsendseq, iGretransmit_seq); - - ugadjust_ack (iGretransmit_seq); - ++cGresent_packets; - ++cGremote_rejects; - if (! fgcheck_errors ()) - return FALSE; - zpack = azGsendbuffers[iGretransmit_seq]; - if (! fsend_data (zpack, CFRAMELEN + CPACKLEN (zpack), TRUE)) - return FALSE; - } - break; - case SRJ: - /* Selectively reject a particular packet. This is not used - by UUCP, but it's easy to support. */ - DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL, - "fgprocess_data: Selective reject of %d", - CONTROL_YYY (ab[IFRAME_CONTROL])); - { - char *zpack; - - ugadjust_ack (CONTROL_YYY (ab[IFRAME_CONTROL])); - ++cGresent_packets; - ++cGremote_rejects; - zpack = azGsendbuffers[CONTROL_YYY (ab[IFRAME_CONTROL])]; - if (! fsend_data (zpack, CFRAMELEN + CPACKLEN (zpack), TRUE)) - return FALSE; - } - break; - case RR: - /* Acknowledge receipt of a packet. This was already handled - above. */ - break; - case INITC: - case INITB: - case INITA: - /* Ignore attempts to reinitialize. */ - break; - } - - /* If we've been asked to return control packets, get out. */ - if (freturncontrol) - { - *pfexit = TRUE; - return TRUE; - } - - /* Loop around to look for the next packet, if any. */ - } - - /* There is no data left in the receive buffer. */ - - if (pcneed != NULL) - *pcneed = CFRAMELEN; - return TRUE; -} - -/* Compute the 'g' protocol checksum. This is unfortunately rather - awkward. This is the most time consuming code in the entire - program. It's also not a great checksum, since it can be fooled - by some single bit errors. */ - -static int -igchecksum (z, c) - register const char *z; - register int c; -{ - register unsigned int ichk1, ichk2; - - ichk1 = 0xffff; - ichk2 = 0; - - do - { - register unsigned int b; - - /* Rotate ichk1 left. */ - if ((ichk1 & 0x8000) == 0) - ichk1 <<= 1; - else - { - ichk1 <<= 1; - ++ichk1; - } - - /* Add the next character to ichk1. */ - b = *z++ & 0xff; - ichk1 += b; - - /* Add ichk1 xor the character position in the buffer counting from - the back to ichk2. */ - ichk2 += ichk1 ^ c; - - /* If the character was zero, or adding it to ichk1 caused an - overflow, xor ichk2 to ichk1. */ - if (b == 0 || (ichk1 & 0xffff) < b) - ichk1 ^= ichk2; - } - while (--c > 0); - - return ichk1 & 0xffff; -} - -/* We use a separate function compute the checksum if the block is - split around the end of the receive buffer since it occurs much - less frequently and the checksum is already high up in the - profiles. These functions are almost identical, and this one - actually only has a few more instructions in the inner loop. */ - -static int -igchecksum2 (zfirst, cfirst, zsecond, csecond) - const char *zfirst; - int cfirst; - const char *zsecond; - int csecond; -{ - register unsigned int ichk1, ichk2; - register const char *z; - register int c; - - z = zfirst; - c = cfirst + csecond; - - ichk1 = 0xffff; - ichk2 = 0; - - do - { - register unsigned int b; - - /* Rotate ichk1 left. */ - if ((ichk1 & 0x8000) == 0) - ichk1 <<= 1; - else - { - ichk1 <<= 1; - ++ichk1; - } - - /* Add the next character to ichk1. */ - b = *z++ & 0xff; - ichk1 += b; - - /* If the first buffer has been finished, switch to the second. */ - --cfirst; - if (cfirst == 0) - z = zsecond; - - /* Add ichk1 xor the character position in the buffer counting from - the back to ichk2. */ - ichk2 += ichk1 ^ c; - - /* If the character was zero, or adding it to ichk1 caused an - overflow, xor ichk2 to ichk1. */ - if (b == 0 || (ichk1 & 0xffff) < b) - ichk1 ^= ichk2; - } - while (--c > 0); - - return ichk1 & 0xffff; -} diff --git a/gnu/libexec/uucp/prott.c b/gnu/libexec/uucp/prott.c deleted file mode 100644 index 8b6a72c2eece..000000000000 --- a/gnu/libexec/uucp/prott.c +++ /dev/null @@ -1,375 +0,0 @@ -/* prott.c - The 't' protocol. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: prott.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.16 1992/03/30 04:49:10 ian - Niels Baggesen: added debugging types abnormal and uucp-proto - - Revision 1.15 1992/03/17 01:03:03 ian - Miscellaneous cleanup - - Revision 1.14 1992/03/13 22:59:25 ian - Have breceive_char go through freceive_data - - Revision 1.13 1992/03/12 19:56:10 ian - Debugging based on types rather than number - - Revision 1.12 1992/02/08 19:55:32 ian - Shifts of integers by more than 15 are not portable - - Revision 1.11 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.10 1992/01/16 18:16:58 ian - Niels Baggesen: add some debugging messages - - Revision 1.9 1991/12/31 19:34:19 ian - Added number of bytes to pffile protocol entry point - - Revision 1.8 1991/12/28 03:49:23 ian - Added HAVE_MEMFNS and HAVE_BFNS; changed uses of memset to bzero - - Revision 1.7 1991/12/17 22:13:14 ian - David Nugent: zero out garbage before sending data - - Revision 1.6 1991/11/16 00:31:01 ian - Increased default 't' and 'f' protocol timeouts - - Revision 1.5 1991/11/15 23:27:21 ian - Include system.h in prott.c and protf.c - - Revision 1.4 1991/11/15 23:20:59 ian - Changed sleep to usysdep_sleep - - Revision 1.3 1991/11/15 21:00:59 ian - Efficiency hacks for 'f' and 't' protocols - - Revision 1.2 1991/11/13 20:44:20 ian - Learned author - - Revision 1.1 1991/11/12 18:26:03 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char prott_rcsid[] = "$Id: prott.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - - -#include "prot.h" -#include "port.h" -#include "system.h" - -/* This implementation is based on code written by Rick Adams. - - This code implements the 't' protocol, which does no error checking - whatsoever and thus requires an end-to-end verified eight bit - communication line, such as is provided by TCP. Using it with a - modem is unadvisable, since errors can occur between the modem and - the computer. */ - -/* The buffer size we use. */ -#define CTBUFSIZE (1024) - -/* The offset in the buffer to the data. */ -#define CTFRAMELEN (4) - -/* Commands are sent in multiples of this size. */ -#define CTPACKSIZE (512) - -/* A pointer to the buffer we will use. */ -static char *zTbuf; - -/* True if we are receiving a file. */ -static boolean fTfile; - -/* The timeout we use. */ -static int cTtimeout = 120; - -struct scmdtab asTproto_params[] = -{ - { "timeout", CMDTABTYPE_INT, (pointer) &cTtimeout, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Local function. */ - -static boolean ftprocess_data P((boolean *pfexit, int *pcneed)); - -/* Start the protocol. */ - -/*ARGSUSED*/ -boolean -ftstart (fmaster) - boolean fmaster; -{ - if (! fport_set (PORTSETTING_EIGHT)) - return FALSE; - zTbuf = (char *) xmalloc (CTBUFSIZE + CTFRAMELEN); - /* The first two bytes of the buffer are always zero. */ - zTbuf[0] = 0; - zTbuf[1] = 0; - fTfile = FALSE; - usysdep_sleep (2); - return TRUE; -} - -/* Stop the protocol. */ - -boolean -ftshutdown () -{ - xfree ((pointer) zTbuf); - zTbuf = NULL; - return TRUE; -} - -/* Send a command string. We send everything up to and including the - null byte. The number of bytes we send must be a multiple of - TPACKSIZE. */ - -boolean -ftsendcmd (z) - const char *z; -{ - int clen; - char *zalc; - - DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "ftsendcmd: Sending command \"%s\"", z); - - clen = strlen (z); - - /* We need to send the smallest multiple of CTPACKSIZE which is - greater than clen (not equal to clen, since we need room for the - null byte). */ - clen = ((clen / CTPACKSIZE) + 1) * CTPACKSIZE; - - zalc = (char *) alloca (clen); - bzero (zalc, clen); - strcpy (zalc, z); - - return fsend_data (zalc, clen, TRUE); -} - -/* Get space to be filled with data. We provide a buffer which has - four bytes at the start available to hold the length. */ - -char * -ztgetspace (pclen) - int *pclen; -{ - *pclen = CTBUFSIZE; - return zTbuf + CTFRAMELEN; -} - -/* Send out some data. We are allowed to modify the four bytes - preceding the buffer. This allows us to send the entire block with - header bytes in a single call. */ - -boolean -ftsenddata (zdata, cdata) - char *zdata; - int cdata; -{ - /* Here we do htonl by hand, since it doesn't exist everywhere. We - know that the amount of data cannot be greater than CTBUFSIZE, so - the first two bytes of this value will always be 0. They were - set to 0 in ftstart so we don't touch them here. This is useful - because we cannot portably right shift by 24 or 16, since we - might be dealing with sixteen bit integers. */ - zdata[-2] = (char) ((cdata >> 8) & 0xff); - zdata[-1] = (char) (cdata & 0xff); - - /* We pass FALSE to fsend_data since we don't expect the other side - to be sending us anything just now. */ - return fsend_data (zdata - CTFRAMELEN, cdata + CTFRAMELEN, FALSE); -} - -/* Process any data in the receive buffer. */ - -boolean -ftprocess (pfexit) - boolean *pfexit; -{ - return ftprocess_data (pfexit, (int *) NULL); -} - -/* Process data and return the amount we need in *pfneed. */ - -static boolean -ftprocess_data (pfexit, pcneed) - boolean *pfexit; - int *pcneed; -{ - int cinbuf, cfirst, clen; - - *pfexit = FALSE; - - cinbuf = iPrecend - iPrecstart; - if (cinbuf < 0) - cinbuf += CRECBUFLEN; - - if (! fTfile) - { - /* We are not receiving a file. Commands are read in chunks of - CTPACKSIZE. */ - while (cinbuf >= CTPACKSIZE) - { - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst > CTPACKSIZE) - cfirst = CTPACKSIZE; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "ftprocess_data: Got %d command bytes", - cfirst); - - if (! fgot_data (abPrecbuf + iPrecstart, cfirst, TRUE, FALSE, - pfexit)) - return FALSE; - if (cfirst < CTPACKSIZE && ! *pfexit) - { - if (! fgot_data (abPrecbuf, CTPACKSIZE - cfirst, TRUE, FALSE, - pfexit)) - return FALSE; - } - - iPrecstart = (iPrecstart + CTPACKSIZE) % CRECBUFLEN; - - if (*pfexit) - return TRUE; - - cinbuf -= CTPACKSIZE; - } - - if (pcneed != NULL) - *pcneed = CTPACKSIZE - cinbuf; - - return TRUE; - } - - /* Here we are receiving a file. The data comes in blocks. The - first four bytes contain the length, followed by that amount of - data. */ - - while (cinbuf >= CTFRAMELEN) - { - /* The length is stored in network byte order, MSB first. */ - - clen = (((((((abPrecbuf[iPrecstart] & 0xff) << 8) - + (abPrecbuf[(iPrecstart + 1) % CRECBUFLEN] & 0xff)) << 8) - + (abPrecbuf[(iPrecstart + 2) % CRECBUFLEN] & 0xff)) << 8) - + (abPrecbuf[(iPrecstart + 3) % CRECBUFLEN] & 0xff)); - - if (cinbuf < clen + CTFRAMELEN) - { - if (pcneed != NULL) - *pcneed = clen + CTFRAMELEN - cinbuf; - return TRUE; - } - - iPrecstart = (iPrecstart + CTFRAMELEN) % CRECBUFLEN; - - cfirst = CRECBUFLEN - iPrecstart; - if (cfirst > clen) - cfirst = clen; - - DEBUG_MESSAGE1 (DEBUG_PROTO, - "ftprocess_data: Got %d data bytes", - cfirst); - - if (! fgot_data (abPrecbuf + iPrecstart, cfirst, FALSE, TRUE, - pfexit)) - return FALSE; - if (cfirst < clen) - { - if (! fgot_data (abPrecbuf, clen - cfirst, FALSE, TRUE, - pfexit)) - return FALSE; - } - - iPrecstart = (iPrecstart + clen) % CRECBUFLEN; - - if (*pfexit) - return TRUE; - - cinbuf -= clen + CTFRAMELEN; - } - - if (pcneed != NULL) - *pcneed = CTFRAMELEN - cinbuf; - - return TRUE; -} - -/* Wait for data to come in and process it until we've reached the end - of a command or a file. */ - -boolean -ftwait () -{ - while (TRUE) - { - boolean fexit; - int cneed, crec; - - if (! ftprocess_data (&fexit, &cneed)) - return FALSE; - if (fexit) - return TRUE; - - if (! freceive_data (cneed, &crec, cTtimeout, TRUE)) - return FALSE; - - if (crec == 0) - { - ulog (LOG_ERROR, "Timed out waiting for data"); - return FALSE; - } - } -} - -/* File level routine, to set fTfile correctly. */ - -/*ARGSUSED*/ -boolean -ftfile (fstart, fsend, pfredo, cbytes) - boolean fstart; - boolean fsend; - boolean *pfredo; - long cbytes; -{ - if (pfredo != NULL) - *pfredo = FALSE; - - if (! fsend) - fTfile = fstart; - - return TRUE; -} diff --git a/gnu/libexec/uucp/prtinf.c b/gnu/libexec/uucp/prtinf.c deleted file mode 100644 index f6dce5528d19..000000000000 --- a/gnu/libexec/uucp/prtinf.c +++ /dev/null @@ -1,1072 +0,0 @@ -/* prtinf.c - Routines to gather information about ports and dialers from - configuration files. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: prtinf.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.20 1992/04/02 22:51:09 ian - Add gcc 2.0 format checking to ulog, and fixed discovered problems - - Revision 1.19 1992/03/28 21:47:55 ian - David J. MacKenzie: allow backslash to quote newline in config files - - Revision 1.18 1992/03/10 21:47:39 ian - Added protocol command for ports - - Revision 1.17 1992/03/08 04:56:21 ian - Peter da Silva: added ``lockname'' command for ports - - Revision 1.16 1992/03/03 06:06:48 ian - T. William Wells: don't complain about missing configuration files - - Revision 1.15 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.14 1992/01/14 04:04:17 ian - Chip Salzenberg: strcmp is a macro on AIX - - Revision 1.13 1992/01/11 17:11:11 ian - Hannu Strang: avoid compiler bug by not using -> in address constant - - Revision 1.12 1991/12/22 20:57:57 ian - Added externs for strcasecmp or strncasecmp - - Revision 1.11 1991/12/17 23:14:08 ian - T. William Wells: allow dialer complete and abort to be chat scripts - - Revision 1.10 1991/12/17 17:08:02 ian - Marc Unangst: allow true and false for boolean strings as documented - - Revision 1.9 1991/12/15 03:42:33 ian - Added tprocess_chat_cmd for all chat commands, and added CMDTABTYPE_PREFIX - - Revision 1.8 1991/12/09 18:26:33 ian - Richard Todd: handle "#" command generated by multiple dialer files - - Revision 1.7 1991/12/02 21:25:36 ian - Niels Baggesen: protocol-parameter for ports and dialers didn't work - - Revision 1.6 1991/11/30 22:55:03 ian - Marty Shannon: blew up if more than one port in port file! - - Revision 1.5 1991/11/14 03:20:13 ian - Added seven-bit and reliable commands to help when selecting protocols - - Revision 1.4 1991/11/13 20:38:00 ian - Added TCP port type for connections over TCP - - Revision 1.3 1991/11/11 23:47:24 ian - Added chat-program to run a program to do a chat script - - Revision 1.2 1991/11/11 16:59:05 ian - Eliminate fread_port_info, allow NULL pflock arg to ffind_port - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char prtinf_rcsid[] = "$Id: prtinf.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#include "port.h" - -/* External functions. */ -extern int strcasecmp (); - -/* Ports are defined in a file. This file has to be both flexible and - easy to use. The format is described in a separate documentation - file. */ - -#if HAVE_TAYLOR_CONFIG - -/* The string names of the port types. This array corresponds to the - tporttype enumeration. */ - -static const char *azPtype_names[] = -{ - "stdin", - "modem", - "direct", -#if HAVE_TCP - "tcp", -#endif -}; - -#define CPORT_TYPES (sizeof azPtype_names / sizeof azPtype_names[0]) - -/* The port structure used by the command tables. */ - -static struct sport sPort; - -/* The generic port command table. */ - -static enum tcmdtabret tpexit P((int argc, char **argv, pointer pvar, - const char *zerr)); -static enum tcmdtabret tpdup_type P((int argc, char **argv, - pointer pvar, const char *zerr)); -static enum tcmdtabret tpproto_param P((int argc, char **argv, - pointer pvar, const char *zerr)); -static enum tcmdtabret tpseven_bit P((int argc, char **argv, - pointer pvar, const char *zerr)); -static enum tcmdtabret tpreliable P((int argc, char **argv, - pointer pvar, const char *zerr)); - -static struct scmdtab asPort_cmds[] = -{ - { "type", CMDTABTYPE_FN | 2, NULL, tpdup_type }, - { "protocol", CMDTABTYPE_STRING, (pointer) &sPort.zprotocols, NULL }, - { "protocol-parameter", CMDTABTYPE_FN | 0, NULL, tpproto_param }, - { "seven-bit", CMDTABTYPE_FN | 2, (pointer) &sPort.ireliable, - tpseven_bit }, - { "reliable", CMDTABTYPE_FN | 2, (pointer) &sPort.ireliable, - tpreliable }, - { "lockname", CMDTABTYPE_STRING, (pointer) &sPort.zlockname, NULL }, - { NULL, 0, NULL, NULL } -}; - -#define CPORT_CMDS (sizeof asPort_cmds / sizeof asPort_cmds[0]) - -/* The stdin port command table. */ - -static struct scmdtab asPstdin_cmds[] = -{ -#ifdef SYSDEP_STDIN_CMDS - SYSDEP_STDIN_CMDS (sPort.u.sstdin.s), -#endif - { NULL, 0, NULL, NULL } -}; - -#define CSTDIN_CMDS (sizeof asPstdin_cmds / sizeof asPstdin_cmds[0]) - -/* The modem port command table. */ - -static enum tcmdtabret tpdialer P((int argc, char **argv, pointer pvar, - const char *zerr)); -static enum tcmdtabret tpbaud_range P((int argc, char **argv, - pointer pvar, - const char *zerr)); - -static struct scmdtab asPmodem_cmds[] = -{ - { "device", CMDTABTYPE_STRING, (pointer) &sPort.u.smodem.zdevice, NULL }, - { "baud", CMDTABTYPE_LONG, (pointer) &sPort.u.smodem.ibaud, NULL }, - { "speed", CMDTABTYPE_LONG, (pointer) &sPort.u.smodem.ibaud, NULL }, - { "baud-range", CMDTABTYPE_FN | 3, NULL, tpbaud_range }, - { "speed-range", CMDTABTYPE_FN | 3, NULL, tpbaud_range }, - { "carrier", CMDTABTYPE_BOOLEAN, (pointer) &sPort.u.smodem.fcarrier, NULL }, - { "dial-device", CMDTABTYPE_STRING, (pointer) &sPort.u.smodem.zdial_device, - NULL }, - { "dialer", CMDTABTYPE_FN | 0, (pointer) &sPort.u.smodem.qdialer, - tpdialer }, - { "dialer-sequence", CMDTABTYPE_FULLSTRING, - (pointer) &sPort.u.smodem.zdialer, NULL }, -#ifdef SYSDEP_MODEM_CMDS - SYSDEP_MODEM_CMDS (sPort.u.smodem.s); -#endif - { NULL, 0, NULL, NULL } -}; - -#define CMODEM_CMDS (sizeof asPmodem_cmds / sizeof asPmodem_cmds[0]) - -/* The direct port command table. */ - -static struct scmdtab asPdirect_cmds[] = -{ - { "device", CMDTABTYPE_STRING, (pointer) &sPort.u.sdirect.zdevice, NULL }, - { "baud", CMDTABTYPE_LONG, (pointer) &sPort.u.sdirect.ibaud, NULL }, - { "speed", CMDTABTYPE_LONG, (pointer) &sPort.u.sdirect.ibaud, NULL }, -#ifdef SYSDEP_DIRECT_CMDS - SYSDEP_DIRECT_CMDS (sPort.u.sdirect.s); -#endif - { NULL, 0, NULL, NULL } -}; - -#define CDIRECT_CMDS (sizeof asPdirect_cmds / sizeof asPdirect_cmds[0]) - -#if HAVE_TCP - -/* The TCP port command table. */ - -static struct scmdtab asPtcp_cmds[] = -{ - { "service", CMDTABTYPE_STRING, (pointer) &sPort.u.stcp.zport, NULL }, - { NULL, 0, NULL, NULL } -}; - -#define CTCP_CMDS (sizeof asPtcp_cmds / sizeof asPtcp_cmds[0]) - -#else /* ! HAVE_TCP */ - -#define CTCP_CMDS (0) - -#endif /* ! HAVE_TCP */ - -/* A little routine to exit when another port command is seen. This - will cause confusion if somebody types ``port port foo'' in the - system file. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tpexit (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - return CMDTABRET_EXIT; -} - -/* A little routine to give a warning about duplicate type commands. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tpdup_type (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - ulog (LOG_ERROR, "%s: type: Ignoring extraneous command", zerr); - return CMDTABRET_FREE; -} - -/* Handle protocol parameter settings for ports. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tpproto_param (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - return tadd_proto_param (&sPort.cproto_params, &sPort.qproto_params, - zerr, argc - 1, argv + 1); -} - -/* Handle the ``seven-bit'' command for ports or dialers. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tpseven_bit (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - char b; - boolean fset; - int *pi = (int *) pvar; - - b = argv[1][0]; - if (b == 'y' || b == 'Y' || b == 't' || b == 'T') - fset = TRUE; - else if (b == 'n' || b == 'N' || b == 'f' || b == 'F') - fset = FALSE; - else - { - ulog (LOG_ERROR, "%s: %s: %s: Bad boolean", zerr, argv[0], argv[1]); - return CMDTABRET_FREE; - } - - *pi |= RELIABLE_SPECIFIED; - if (fset) - *pi |= RELIABLE_EIGHT; - else - *pi &=~ RELIABLE_EIGHT; - - return CMDTABRET_FREE; -} - -/* Handle the ``reliable'' command for ports or dialers. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tpreliable (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - char b; - boolean fset; - int *pi = (int *) pvar; - - b = argv[1][0]; - if (b == 'y' || b == 'Y' || b == 't' || b == 'T') - fset = TRUE; - else if (b == 'n' || b == 'N' || b == 'f' || b == 'F') - fset = FALSE; - else - { - ulog (LOG_ERROR, "%s: %s: %s: Bad boolean", zerr, argv[0], argv[1]); - return CMDTABRET_FREE; - } - - *pi |= RELIABLE_SPECIFIED; - if (fset) - *pi |= RELIABLE_RELIABLE; - else - *pi &=~ RELIABLE_RELIABLE; - - return CMDTABRET_FREE; -} - -/* Handle the ``baud-range'' command for a modem port. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tpbaud_range (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - /* This should do more error checking. */ - sPort.u.smodem.ilowbaud = atol (argv[1]); - sPort.u.smodem.ihighbaud = atol (argv[2]); - return CMDTABRET_FREE; -} - -/* Process a port command found while reading the system information - file. */ - -enum tcmdtabret -tprocess_port_cmd (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - struct sport **pqport = (struct sport **) pvar; - enum tcmdtabret tret; - const struct scmdtab *qcmds; - int i; - - if (*pqport == NULL) - { - enum tporttype ttype; - struct sport *qnew; - boolean fgottype; - - if (strcasecmp (argv[0], "type") != 0) - { - ttype = PORTTYPE_MODEM; - fgottype = FALSE; - } - else - { - if (argc != 2) - { - ulog (LOG_ERROR, "%s: port type: Wrong number of arguments", - zerr); - return CMDTABRET_FREE; - } - - for (i = 0; i < CPORT_TYPES; i++) - if (strcasecmp (argv[1], azPtype_names[i]) == 0) - break; - - if (i >= CPORT_TYPES) - { - ulog (LOG_ERROR, "%s: Unknown port type", zerr); - return CMDTABRET_FREE; - } - - ttype = (enum tporttype) i; - fgottype = TRUE; - } - - qnew = (struct sport *) xmalloc (sizeof (struct sport)); - qnew->zname = NULL; - qnew->ttype = ttype; - qnew->zprotocols = NULL; - qnew->cproto_params = 0; - qnew->qproto_params = NULL; - qnew->zlockname = NULL; - - /* Note that we do not set RELIABLE_SPECIFIED; this just sets - defaults, so that ``seven-bit true'' does not imply - ``reliable false''. */ - qnew->ireliable = RELIABLE_RELIABLE | RELIABLE_EIGHT; - - switch (ttype) - { - case PORTTYPE_STDIN: -#ifdef SYSDEP_STDIN_INIT - SYSDEP_STDIN_INIT (&qnew->u.sstdin.s); -#endif - break; - case PORTTYPE_MODEM: - qnew->u.smodem.zdevice = NULL; - qnew->u.smodem.zdial_device = NULL; - qnew->u.smodem.ibaud = 0L; - qnew->u.smodem.ilowbaud = 0L; - qnew->u.smodem.ihighbaud = 0L; - qnew->u.smodem.fcarrier = TRUE; - qnew->u.smodem.zdialer = NULL; - qnew->u.smodem.qdialer = NULL; -#ifdef SYSDEP_MODEM_INIT - SYSDEP_MODEM_INIT (&qnew->u.smodem.s); -#endif - break; - case PORTTYPE_DIRECT: - qnew->u.sdirect.zdevice = NULL; - qnew->u.sdirect.ibaud = -1; -#ifdef SYSDEP_DIRECT_INIT - SYSDEP_DIRECT_INIT (&qnew->u.sdirect.s); -#endif - break; -#if HAVE_TCP - case PORTTYPE_TCP: - qnew->u.stcp.o = -1; - qnew->u.stcp.zport = "uucp"; - break; -#endif /* HAVE_TCP */ - } - - *pqport = qnew; - - if (fgottype) - return CMDTABRET_FREE; - } - - /* See if this command is one of the generic ones. */ - for (i = 0; i < CPORT_CMDS - 1; i++) - { - if (strcasecmp (argv[0], asPort_cmds[i].zcmd) == 0) - { - sPort = **pqport; - tret = tprocess_one_cmd (argc, argv, asPort_cmds, zerr, 0); - **pqport = sPort; - return tret; - } - } - - /* Now check the port commands for specific types. */ - switch ((*pqport)->ttype) - { - case PORTTYPE_STDIN: - qcmds = asPstdin_cmds; - break; - case PORTTYPE_MODEM: - qcmds = asPmodem_cmds; - break; - case PORTTYPE_DIRECT: - qcmds = asPdirect_cmds; - break; -#if HAVE_TCP - case PORTTYPE_TCP: - qcmds = asPtcp_cmds; - break; -#endif /* HAVE_TCP */ - default: -#if DEBUG > 0 - ulog (LOG_FATAL, "tprocess_port_cmd: Can't happen"); -#endif - return CMDTABRET_FREE; - } - - sPort = **pqport; - tret = tprocess_one_cmd (argc, argv, qcmds, zerr, - CMDFLAG_WARNUNRECOG); - **pqport = sPort; - return tret; -} - -/* Fill in an scmdtab structure to pass every possible port command - to tprocess_port_cmd. The argument must be large enough. */ - -static void uport_cmdtab P((struct scmdtab *qcmds, struct sport **pqnew)); - -static void -uport_cmdtab (qcmds, pqnew) - struct scmdtab *qcmds; - struct sport **pqnew; -{ - int i; - int ibase; - - ibase = 0; - for (i = 0; i < CPORT_CMDS - 1; i++) - { - qcmds[ibase + i].zcmd = asPort_cmds[i].zcmd; - qcmds[ibase + i].itype = CMDTABTYPE_FN | 0; - qcmds[ibase + i].pvar = (pointer) pqnew; - qcmds[ibase + i].ptfn = tprocess_port_cmd; - } - ibase += CPORT_CMDS - 1; - for (i = 0; i < CSTDIN_CMDS - 1; i++) - { - qcmds[ibase + i].zcmd = asPstdin_cmds[i].zcmd; - qcmds[ibase + i].itype = CMDTABTYPE_FN | 0; - qcmds[ibase + i].pvar = (pointer) pqnew; - qcmds[ibase + i].ptfn = tprocess_port_cmd; - } - ibase += CSTDIN_CMDS - 1; - for (i = 0; i < CMODEM_CMDS - 1; i++) - { - qcmds[ibase + i].zcmd = asPmodem_cmds[i].zcmd; - qcmds[ibase + i].itype = CMDTABTYPE_FN | 0; - qcmds[ibase + i].pvar = (pointer) pqnew; - qcmds[ibase + i].ptfn = tprocess_port_cmd; - } - ibase += CMODEM_CMDS - 1; - for (i = 0; i < CDIRECT_CMDS - 1; i++) - { - qcmds[ibase + i].zcmd = asPdirect_cmds[i].zcmd; - qcmds[ibase + i].itype = CMDTABTYPE_FN | 0; - qcmds[ibase + i].pvar = (pointer) pqnew; - qcmds[ibase + i].ptfn = tprocess_port_cmd; - } - ibase += CDIRECT_CMDS - 1; -#if HAVE_TCP - for (i = 0; i < CTCP_CMDS - 1; i++) - { - qcmds[ibase + i].zcmd = asPtcp_cmds[i].zcmd; - qcmds[ibase + i].itype = CMDTABTYPE_FN | 0; - qcmds[ibase + i].pvar = (pointer) pqnew; - qcmds[ibase + i].ptfn = tprocess_port_cmd; - } - ibase += CTCP_CMDS - 1; -#endif /* HAVE_TCP */ - qcmds[ibase].zcmd = NULL; -} - -#endif /* HAVE_TAYLOR_CONFIG */ - -#if HAVE_TAYLOR_CONFIG - -/* Save a port name so that we can use it when looking for a port - with a particular baud rate. */ - -static enum tcmdtabret tpport_for_baud P((int argc, char **argv, - pointer pvar, const char *zerr)); - -static const char *zport_for_baud_name; - -/*ARGSUSED*/ -static enum tcmdtabret -tpport_for_baud (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - zport_for_baud_name = argv[1]; - return CMDTABRET_EXIT; -} - -#endif /* HAVE_TAYLOR_CONFIG */ - -/* Find and lock a port. The arguments specify a port name and a baud - rate, and the port found must match both. If the name passed in is - NULL, all ports match. If the baud rate passed in is 0, all ports - match. The lock routine is passed in so that it doesn't have to be - linked in by programs which don't need this call (yes, it's a - hack). The freport argument is actually only used for testing - purposes. */ - -boolean -ffind_port (zfind, ibaud, ihighbaud, qport, pflock, freport) - const char *zfind; - long ibaud; - long ihighbaud; - struct sport *qport; - boolean (*pflock) P((struct sport *, boolean fin)); - boolean freport; -{ - boolean ffound; - - if (ihighbaud == 0) - ihighbaud = ibaud; - - ffound = FALSE; - -#if HAVE_TAYLOR_CONFIG - if (zPortfile == NULL) - { - boolean fmore; - - /* Only warn about a missing file if we're not going to read the - V2 or BNU files. */ - fmore = FALSE; -#if HAVE_V2_CONFIG - if (fV2) - fmore = TRUE; -#endif -#if HAVE_BNU_CONFIG - if (fBnu) - fmore = TRUE; -#endif - if (! fmore) - { - ulog (LOG_ERROR, "%s%s: file not found", NEWCONFIGLIB, - PORTFILE); - return FALSE; - } - } - else - { - struct smulti_file *qmulti; - struct scmdtab ascmds[CPORT_CMDS + CSTDIN_CMDS + CMODEM_CMDS + - CDIRECT_CMDS + CTCP_CMDS + 1]; - struct sport *qnew; - const char *zname; - - qmulti = qmulti_open (zPortfile); - if (qmulti != NULL) - { - /* Set up such that each command is routed to - tprocess_port_cmd. Route "port" to tpport_for_baud, - which will record the name of the port. */ - qnew = NULL; - - ascmds[0].zcmd = "port"; - ascmds[0].itype = CMDTABTYPE_FN | 2; - ascmds[0].pvar = NULL; - ascmds[0].ptfn = tpport_for_baud; - uport_cmdtab (ascmds + 1, &qnew); - - /* Look for the first command in the file (which should be - ``port'') to get the name of the first port. */ - - zport_for_baud_name = NULL; - - uprocesscmds ((FILE *) NULL, qmulti, ascmds, - (const char *) NULL, CMDFLAG_BACKSLASH); - - if (qnew != NULL) - { - (void) fmulti_close (qmulti); - ulog (LOG_ERROR, "First command in port file is not `port'"); - return FALSE; - } - - /* Look through the files until we can't find any more. */ - - zname = zport_for_baud_name; - while (zname != NULL) - { - zport_for_baud_name = NULL; - uprocesscmds ((FILE *) NULL, qmulti, ascmds, - (const char *) NULL, CMDFLAG_BACKSLASH); - - if (qnew != NULL - && (zfind == NULL - || strcmp (zfind, zname) == 0) - && (ibaud == 0 - || (qnew->ttype == PORTTYPE_MODEM - && ((qnew->u.smodem.ibaud == 0 - && qnew->u.smodem.ilowbaud == 0 - && qnew->u.smodem.ihighbaud == 0) - || (qnew->u.smodem.ibaud >= ibaud - && qnew->u.smodem.ibaud <= ihighbaud) - || (qnew->u.smodem.ilowbaud <= ihighbaud - && qnew->u.smodem.ihighbaud >= ibaud))) - || (qnew->ttype == PORTTYPE_DIRECT - && (qnew->u.sdirect.ibaud == 0 - || qnew->u.sdirect.ibaud == ibaud)))) - { - ffound = TRUE; - qnew->zname = zname; - if (pflock == NULL - || (*pflock) (qnew, FALSE)) - { - *qport = *qnew; - xfree ((pointer) qnew); - (void) fmulti_close (qmulti); - return TRUE; - } - } - - xfree ((pointer) qnew); - qnew = NULL; - - zname = zport_for_baud_name; - } - - (void) fmulti_close (qmulti); - } - } -#endif /* HAVE_TAYLOR_CONFIG */ - -#if HAVE_V2_CONFIG - if (fV2) - { - if (fv2_find_port (zfind, ibaud, ihighbaud, qport, pflock, &ffound)) - return TRUE; - } -#endif /* HAVE_V2_CONFIG */ - -#if HAVE_BNU_CONFIG - if (fBnu) - { - if (fbnu_find_port (zfind, ibaud, ihighbaud, qport, pflock, &ffound)) - return TRUE; - } -#endif /* HAVE_BNU_CONFIG */ - - if (freport) - { - if (ffound) - ulog (LOG_ERROR, "All matching ports in use"); - else - ulog (LOG_ERROR, "No matching ports defined"); - } - - return FALSE; -} - -#if HAVE_TAYLOR_CONFIG - -/* Read dialer commands. */ - -static struct sdialer sPdialer; - -/* The dialer command table. */ - -static enum tcmdtabret tpdtr_toggle P((int argc, char **argv, pointer pvar, - const char *zerr)); -static enum tcmdtabret tpcomplete P((int argc, char **argv, pointer pvar, - const char *zerr)); -static enum tcmdtabret tpdialer_proto_param P((int argc, char **argv, - pointer pvar, - const char *zerr)); - -static struct scmdtab asPdialer_cmds[] = -{ - { "dialer", CMDTABTYPE_FN | 2, NULL, tpexit }, - { "#", CMDTABTYPE_FN | 0, NULL, tpexit }, - { "chat", CMDTABTYPE_PREFIX | 0, (pointer) &sPdialer.schat, - tprocess_chat_cmd }, - { "dialtone", CMDTABTYPE_STRING, (pointer) &sPdialer.zdialtone, NULL }, - { "pause", CMDTABTYPE_STRING, (pointer) &sPdialer.zpause, NULL }, - { "carrier", CMDTABTYPE_BOOLEAN, (pointer) &sPdialer.fcarrier, NULL }, - { "carrier-wait", CMDTABTYPE_INT, (pointer) &sPdialer.ccarrier_wait, NULL }, - { "dtr-toggle", CMDTABTYPE_FN | 0, NULL, tpdtr_toggle }, - { "complete", CMDTABTYPE_FN | 2, (pointer) &sPdialer.scomplete, - tpcomplete }, - { "complete-chat", CMDTABTYPE_PREFIX, (pointer) &sPdialer.scomplete, - tprocess_chat_cmd }, - { "abort", CMDTABTYPE_FN | 2, (pointer) &sPdialer.sabort, tpcomplete }, - { "abort-chat", CMDTABTYPE_PREFIX, (pointer) &sPdialer.sabort, - tprocess_chat_cmd }, - { "protocol-parameter", CMDTABTYPE_FN | 0, NULL, tpdialer_proto_param }, - { "seven-bit", CMDTABTYPE_FN | 2, (pointer) &sPdialer.ireliable, - tpseven_bit }, - { "reliable", CMDTABTYPE_FN | 2, (pointer) &sPdialer.ireliable, - tpreliable }, - { NULL, 0, NULL, NULL } -}; - -#define CDIALER_CMDS (sizeof asPdialer_cmds / sizeof asPdialer_cmds[0]) - -/* Handle the dtr-toggle command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tpdtr_toggle (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - char b; - - if (argc < 2 || argc > 3) - { - ulog (LOG_ERROR, "%s: %s: Wrong number of arguments", zerr, argv[0]); - return CMDTABRET_FREE; - } - - b = argv[1][0]; - if (b == 'y' || b == 'Y' || b == 't' || b == 'T') - sPdialer.fdtr_toggle = TRUE; - else if (b == 'n' || b == 'N' || b == 'f' || b == 'F') - sPdialer.fdtr_toggle = FALSE; - else - { - ulog (LOG_ERROR, "%s: %s: Bad boolean", zerr, argv[0]); - return CMDTABRET_FREE; - } - - if (argc == 3) - { - b = argv[2][0]; - if (b == 'y' || b == 'Y' || b == 't' || b == 'T') - sPdialer.fdtr_toggle_wait = TRUE; - else if (b == 'n' || b == 'N' || b == 'f' || b == 'F') - sPdialer.fdtr_toggle_wait = FALSE; - else - { - ulog (LOG_ERROR, "%s: %s: Bad boolean", zerr, argv[0]); - return CMDTABRET_FREE; - } - } - - return CMDTABRET_FREE; -} - -/* Handle the complete and abort commands. These just turn a string - into a trivial chat script. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tpcomplete (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - struct schat_info *qchat = (struct schat_info *) pvar; - - qchat->zchat = (char *) xmalloc (strlen (argv[1]) + sizeof "\"\" "); - sprintf (qchat->zchat, "\"\" %s", argv[1]); - return CMDTABRET_FREE; -} - -/* Handle protocol parameters for dialers. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tpdialer_proto_param (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - return tadd_proto_param (&sPdialer.cproto_params, &sPdialer.qproto_params, - zerr, argc - 1, argv + 1); -} - -/* Process one dialer command. */ - -static enum tcmdtabret tprocess_dialer_cmd P((int argc, char **argv, - pointer pvar, - const char *zerr)); - -static enum tcmdtabret -tprocess_dialer_cmd (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - struct sdialer **pq = (struct sdialer **) pvar; - enum tcmdtabret tret; - - if (*pq == NULL) - { - struct sdialer *qnew; - - qnew = (struct sdialer *) xmalloc (sizeof (struct sdialer)); - qnew->zname = NULL; - INIT_CHAT (&qnew->schat); - qnew->zdialtone = ","; - qnew->zpause = ","; - qnew->fcarrier = TRUE; - qnew->ccarrier_wait = 60; - qnew->fdtr_toggle = FALSE; - qnew->fdtr_toggle_wait = FALSE; - INIT_CHAT (&qnew->scomplete); - INIT_CHAT (&qnew->sabort); - qnew->cproto_params = 0; - qnew->qproto_params = NULL; - - /* Note that we do not set RELIABLE_SPECIFIED; this just sets - defaults, so that ``seven-bit true'' does not imply - ``reliable false''. */ - qnew->ireliable = RELIABLE_RELIABLE | RELIABLE_EIGHT; - - *pq = qnew; - } - - sPdialer = **pq; - tret = tprocess_one_cmd (argc, argv, asPdialer_cmds, zerr, - CMDFLAG_WARNUNRECOG); - **pq = sPdialer; - return tret; -} - -/* Handle a dialer command seen in the port file. */ - -static enum tcmdtabret -tpdialer (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - if (argc < 2) - { - ulog (LOG_ERROR, "%s: %s: Wrong number of arguments", zerr, argv[0]); - return CMDTABRET_FREE; - } - - if (argc > 2) - return tprocess_dialer_cmd (argc - 1, argv + 1, pvar, zerr); - - sPort.u.smodem.zdialer = argv[1]; - - return CMDTABRET_CONTINUE; -} - -/* Read the information for a particular item. */ - -struct splook -{ - const char *zlook; - boolean ffound; -}; - -/* Look for a particular dialer. */ - -static enum tcmdtabret tplook P((int argc, char **argv, pointer pvar, - const char *zerr)); - -/*ARGSUSED*/ -static enum tcmdtabret -tplook (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - struct splook *q = (struct splook *) pvar; - - if (strcmp (q->zlook, argv[1]) == 0) - { - q->ffound = TRUE; - return CMDTABRET_FREE_AND_EXIT; - } - return CMDTABRET_FREE; -} - -#endif /* HAVE_TAYLOR_CONFIG */ - -/* Read information about a specific dialer. */ - -boolean -fread_dialer_info (zdialer, qdialer) - const char *zdialer; - struct sdialer *qdialer; -{ -#if HAVE_TAYLOR_CONFIG - - /* If we haven't got a dialer file, then only complain if we aren't - going to try the BNU dialer file. */ - if (zDialfile == NULL) - { -#if HAVE_BNU_CONFIG - if (! fBnu) -#endif - { - ulog (LOG_ERROR, "%s%s: file not found", NEWCONFIGLIB, DIALFILE); - return FALSE; - } - } - else - { - struct smulti_file *qmulti; - struct scmdtab as[2]; - struct splook s; - struct sdialer *qnew; - struct scmdtab ascmds[CDIALER_CMDS]; - int i; - - qmulti = qmulti_open (zDialfile); - if (qmulti != NULL) - { - s.zlook = zdialer; - s.ffound = FALSE; - - as[0].zcmd = "dialer"; - as[0].itype = CMDTABTYPE_FN | 2; - as[0].pvar = (pointer) &s; - as[0].ptfn = tplook; - - as[1].zcmd = NULL; - - uprocesscmds ((FILE *) NULL, qmulti, as, (const char *) NULL, - CMDFLAG_BACKSLASH); - - if (s.ffound) - { - qnew = NULL; - - for (i = 0; i < CDIALER_CMDS; i++) - { - ascmds[i].zcmd = asPdialer_cmds[i].zcmd; - if (TTYPE_CMDTABTYPE (asPdialer_cmds[i].itype) - == CMDTABTYPE_PREFIX) - ascmds[i].itype = CMDTABTYPE_PREFIX | 0; - else - ascmds[i].itype = CMDTABTYPE_FN | 0; - ascmds[i].pvar = (pointer) &qnew; - ascmds[i].ptfn = tprocess_dialer_cmd; - } - - uprocesscmds ((FILE *) NULL, qmulti, ascmds, - (const char *) NULL, - CMDFLAG_WARNUNRECOG | CMDFLAG_BACKSLASH); - - (void) fmulti_close (qmulti); - - if (qnew == NULL) - { - ulog (LOG_ERROR, "No information for dialer %s", zdialer); - return FALSE; - } - - *qdialer = *qnew; - xfree ((pointer) qnew); - - return TRUE; - } - - (void) fmulti_close (qmulti); - } - } -#endif /* HAVE_TAYLOR_CONFIG */ - -#if HAVE_BNU_CONFIG - if (fBnu) - { - if (fbnu_read_dialer_info (zdialer, qdialer)) - return TRUE; - } -#endif /* HAVE_BNU_CONFIG */ - - ulog (LOG_ERROR, "%s: No such dialer", zdialer); - return FALSE; -} diff --git a/gnu/libexec/uucp/sys1.unx b/gnu/libexec/uucp/sys1.unx deleted file mode 100644 index 2a8fa1f862e7..000000000000 --- a/gnu/libexec/uucp/sys1.unx +++ /dev/null @@ -1,2543 +0,0 @@ -/* sys1.unx - The basic system dependent routines for UNIX. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: sys1.unx,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - -# Revision 1.2 92/05/13 05:42:07 rich -# ported to 386bsd -# -# Revision 1.1 1992/05/10 17:36:33 rich -# Initial revision -# - Revision 1.68 1992/04/03 05:37:11 ian - Minor cleanups for gcc 2.1 - - Revision 1.67 1992/03/31 23:53:34 ian - Use $PWD to get the current directory if it's defined and correct - - Revision 1.66 1992/03/31 23:42:59 ian - Brian W. Antoine: use name from getpwnam rather than getlogin - - Revision 1.65 1992/03/26 17:17:25 ian - Gerben Wierda: various cleanups - - Revision 1.64 1992/03/18 06:00:25 ian - Open the controlling terminal in non delay mode - - Revision 1.63 1992/03/17 15:35:28 ian - Log signals when they happen, even if we continue looping - - Revision 1.62 1992/03/17 01:28:18 ian - Undefine remove in uucp.h if ! HAVE_REMOVE - - Revision 1.61 1992/03/16 22:40:01 ian - Undefine remove before function definition - - Revision 1.60 1992/03/16 22:22:35 ian - Adjusted external declarations - - Revision 1.59 1992/03/16 22:01:58 ian - Don't declare sigemptyset - - Revision 1.58 1992/03/16 01:23:08 ian - Make blocking writes optional - - Revision 1.57 1992/03/15 04:51:17 ian - Keep an array of signals we've received rather than a single variable - - Revision 1.56 1992/03/15 01:54:46 ian - All execs are now done in isspawn, all waits are done in iswait - - Revision 1.55 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.54 1992/03/11 02:09:57 ian - Franc,ois Pinard: retry fork several times before giving up - - Revision 1.53 1992/03/11 00:18:50 ian - Save temporary file if file send fails - - Revision 1.52 1992/03/08 02:06:28 ian - Let setpgrp fail silently - - Revision 1.51 1992/03/04 01:40:51 ian - Thomas Fischer: tweaked a bit for the NeXT - - Revision 1.50 1992/03/03 21:01:20 ian - Use strict timeout in fsserial_read, eliminate all race conditions - - Revision 1.49 1992/02/29 01:06:59 ian - Chip Salzenberg: recheck file permissions before sending - - Revision 1.48 1992/02/28 05:06:15 ian - T. William Wells: fsysdep_catch must be a macro - - Revision 1.47 1992/02/27 19:51:09 ian - Added some new extern definitions - - Revision 1.46 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.45 1992/02/24 20:07:43 ian - John Theus: some systems don't have - - Revision 1.44 1992/02/24 04:58:47 ian - Only permit files to be received into directories that are world-writeable - - Revision 1.43 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.42 1992/02/19 19:36:07 ian - Rearranged time functions - - Revision 1.41 1992/02/09 05:10:50 ian - Added HAVE_MKDIR configuration parameter and mkdir emulation - - Revision 1.40 1992/02/09 03:14:48 ian - Added HAVE_OLD_DIRECTORIES for systems without readdir routines - - Revision 1.39 1992/02/09 02:41:58 ian - Added HAVE_DUP2 configuration parameter and dup2 emulation function - - Revision 1.38 1992/02/08 23:38:17 ian - Put utsname on stack rather than making it static - - Revision 1.37 1992/02/08 23:34:41 ian - If we have neither getcwd nor getwd, fork /bin/pwd to get the cwd - - Revision 1.36 1992/02/08 22:33:32 ian - Only get the current working directory if it's going to be needed - - Revision 1.35 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.34 1992/01/29 04:27:11 ian - Jay Vassos-Libove: removed some conflicting declarations - - Revision 1.33 1992/01/22 05:08:21 ian - Call execl with correct first argument - - Revision 1.32 1992/01/21 19:39:12 ian - Chip Salzenberg: uucp and uux start uucico for right system, not any - - Revision 1.31 1992/01/21 00:30:48 ian - Don't try to create a directory with no name - - Revision 1.30 1992/01/16 03:38:20 ian - Put \n at end of fsysdep_run error message - - Revision 1.29 1992/01/15 21:06:11 ian - Mike Park: some systems can't include and together - - Revision 1.28 1992/01/13 19:38:16 ian - Chip Salzenberg: can't declare execl, since it is varadic - - Revision 1.27 1992/01/13 06:11:39 ian - David Nugent: can't declare open or fcntl - - Revision 1.26 1992/01/11 17:30:10 ian - John Antypas: use memcpy instead of relying on structure assignment - - Revision 1.25 1992/01/04 23:23:57 ian - usysdep_localtime can't use usysdep_full_time if HAVE_TIMES - - Revision 1.24 1992/01/04 22:56:22 ian - Added extern definition - - Revision 1.23 1991/12/29 15:45:46 ian - Don't take the address of a cast value - - Revision 1.22 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.21 1991/12/29 02:59:50 ian - Lele Gaifax: put full year in log file - - Revision 1.20 1991/12/28 17:08:47 ian - John Theus: offer HAVE_GETWD as an alternative to using getcwd - - Revision 1.19 1991/12/28 07:01:15 ian - Added HAVE_FTIME configuration option - - Revision 1.18 1991/12/22 22:14:19 ian - Monty Solomon: added HAVE_UNISTD_H configuration parameter - - Revision 1.17 1991/12/21 21:34:14 ian - Moved fsysdep_file_exists from sys5.unx to sys1.unx - - Revision 1.16 1991/12/21 21:04:42 ian - Use real program name in fsysdep_run error messages - - Revision 1.15 1991/12/17 07:09:58 ian - Record statistics in fractions of a second - - Revision 1.14 1991/12/12 18:35:47 ian - Do locking with link to avoid races and to permit running as root - - Revision 1.13 1991/12/12 17:39:40 ian - Set the GID as well as the UID for extra safety - - Revision 1.12 1991/12/11 03:59:19 ian - Create directories when necessary; don't just assume they exist - - Revision 1.11 1991/12/06 22:50:01 ian - Franc,ois Pinard: getcwd may legitimately fail in usysdep_initialize - - Revision 1.10 1991/12/01 02:23:12 ian - Niels Baggesen: don't multiply include - - Revision 1.9 1991/11/21 20:59:32 ian - Brian Campbell: ttyname takes an argument - - Revision 1.8 1991/11/14 19:11:25 ian - Add extern for ttyname - - Revision 1.7 1991/11/14 03:40:10 ian - Try to figure out whether stdin is a TCP port - - Revision 1.6 1991/11/11 18:55:52 ian - Get protocol parameters from port and dialer for incoming calls - - Revision 1.5 1991/09/19 17:49:39 ian - Chip Salzenberg: the log file has been closed before calling fsysdep_run - - Revision 1.4 1991/09/19 15:46:48 ian - Chip Salzenberg: Make sure getlogin () uid matches process uid - - Revision 1.3 1991/09/19 03:23:34 ian - Chip Salzenberg: append to private debugging file, don't overwrite it - - Revision 1.2 1991/09/11 02:33:14 ian - Added ffork argument to fsysdep_run - - Revision 1.1 1991/09/10 19:45:50 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char sys1_unx_rcsid[] = "$Id: sys1.unx,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#if USE_STDIO && HAVE_UNISTD_H -#include -#endif - -#include "system.h" -#include "sysdep.h" - -#include - -#if HAVE_GETGRENT -#include -extern struct group *getgrent (); -#endif - -#if HAVE_LIMITS_H -#include -#endif - -#if HAVE_SYS_PARAM_H -#include -#endif - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#ifndef O_APPEND -#ifdef FAPPEND -#define O_APPEND FAPPEND -#endif -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - -#if ! HAVE_GETHOSTNAME && HAVE_UNAME -#include -extern int uname (); -#endif - -#if HAVE_TIME_H && (HAVE_SYS_TIME_AND_TIME_H || ! HAVE_GETTIMEOFDAY) -#include -#endif - -#if HAVE_SYS_IOCTL_H -#include -#endif - -/* If we have getcwd, forget about getwd. */ - -#if HAVE_GETCWD -#undef HAVE_GETWD -#define HAVE_GETWD 0 -#endif - -#if HAVE_GETWD -/* If we didn't get MAXPATHLEN, make it up. */ -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 -#endif -extern char *getwd (); -#endif /* HAVE_GETWD */ - -/* Prefer gettimeofday to ftime to times. */ - -#if HAVE_GETTIMEOFDAY || HAVE_FTIME -#undef HAVE_TIMES -#define HAVE_TIMES 0 -#endif - -#if HAVE_GETTIMEOFDAY -#undef HAVE_FTIME -#define HAVE_FTIME 0 -#endif - -#if HAVE_GETTIMEOFDAY -#include -extern int gettimeofday (); -#endif - -#if HAVE_FTIME -#include -extern int ftime (); -#endif - -#if HAVE_TIMES -#include -#if TIMES_DECLARATION_OK -/* We use a macro to protect this because times really returns clock_t - and on some systems, such as Ultrix 4.0, clock_t is int. We don't - leave it out entirely because on some systems, such as System III, - the declaration is necessary for correct compilation. */ -extern long times (); -#endif - -#if TIMES_TICK == 0 -/* We don't have a value for TIMES_TICK. Look for one. */ -#ifdef CLK_TCK -#undef TIMES_TICK -#define TIMES_TICK CLK_TCK -#else /* ! defined (CLK_TCK) */ -#ifdef HZ -#undef TIMES_TICK -#define TIMES_TICK HZ -#endif /* defined (HZ) */ -#endif /* ! defined (CLK_TCK) */ -#endif /* TIMES_TICK == 0 */ - -#endif /* HAVE_TIMES */ - -/* We need the access macros. */ - -#ifndef R_OK -#define R_OK 4 -#define W_OK 2 -#define X_OK 1 -#define F_OK 0 -#endif /* ! defined (R_OK) */ - -/* We need wait status information. */ - -#if HAVE_SYS_WAIT_H -#include -#endif - -/* We use a typedef wait_status for wait and related functions to put - results into. We define the POSIX examination functions we need if - they are not already defined (if they aren't defined, I assume that - we have a standard wait status). */ - -#if HAVE_UNION_WAIT -typedef union wait wait_status; -#ifndef WIFEXITED -#define WIFEXITED(u) ((u).w_termsig == 0) -#endif -#ifndef WEXITSTATUS -#define WEXITSTATUS(u) ((u).w_retcode) -#endif -#ifndef WTERMSIG -#define WTERMSIG(u) ((u).w_termsig) -#endif -#else /* ! HAVE_UNION_WAIT */ -typedef int wait_status; -#ifndef WIFEXITED -#define WIFEXITED(i) (((i) & 0xff) == 0) -#endif -#ifndef WEXITSTATUS -#define WEXITSTATUS(i) (((i) >> 8) & 0xff) -#endif -#ifndef WTERMSIG -#define WTERMSIG(i) ((i) & 0x7f) -#endif -#endif /* ! HAVE_UNION_WAIT */ - -/* External variables. */ -extern char **environ; - -/* External functions. */ -#ifndef __386BSD__ -extern int kill (); -#endif __386BSD__ -extern int chdir (), access (), stat (), unlink (), execve (); -extern int close (), pipe (), dup2 (); -extern int fputs (); -extern void _exit (); -extern time_t time (); -extern char *getlogin (), *ttyname (); -extern pid_t getpid (), getppid (), fork (), getpgrp (); -extern uid_t getuid (), geteuid (), getgid (), getegid (); -extern struct tm *localtime (); -#ifndef __386BSD__ -extern struct passwd *getpwuid (); -#endif __386BSD__ -extern struct passwd *getpwnam (); -#if HAVE_GETHOSTNAME -extern int gethostname (); -#endif -#if HAVE_GETCWD -extern char *getcwd (); -#else -#if ! HAVE_GETWD -static char *getcwd P((char *zbuf, int cbuf)); -#endif /* ! HAVE_GETWD */ -#endif /* ! HAVE_GETCWD */ -#if HAVE_GETDTABLESIZE -extern int getdtablesize (); -#endif -#if HAVE_SYSCONF -extern long sysconf (); -#endif -#if HAVE_SETPGRP -#ifndef __386BSD__ -extern int setpgrp (); -#endif __386BSD__ -#endif -#if HAVE_SETSID -#ifndef __386BSD__ -extern int setsid (); -#endif __386BSD__ -#endif -#if HAVE_SIGACTION -extern int sigaction (); -#endif -#if HAVE_SIGVEC -extern int sigvec (); -#endif -#if HAVE_TCP -extern int getsockname (); -#endif - -/* Initialize the system dependent routines. We will probably be running - suid to uucp, so we make sure that nothing is obviously wrong. We - save the login name since we will be losing the real uid. */ -static char *zSlogin; - -/* We save the current directory since we will do a chdir to the - spool directory. */ -char *zScwd; - -/* The maximum length of a system name is controlled by the type of spool - directory we use. */ - -#if SPOOLDIR_V2 | SPOOLDIR_BSD42 | SPOOLDIR_BSD43 | SPOOLDIR_ULTRIX -int cSysdep_max_name_len = 7; -#endif /* SPOOLDIR_V2 | SPOOLDIR_BSD42 | SPOOLDIR_BSD43 | SPOOLDIR_ULTRIX */ -#if SPOOLDIR_BNU -int cSysdep_max_name_len = 14; -#endif /* SPOOLDIR_BNU */ -#if SPOOLDIR_TAYLOR -#if HAVE_LONG_NAMES -int cSysdep_max_name_len = 255; -#else /* ! HAVE_LONG_NAMES */ -int cSysdep_max_name_len = 14; -#endif /* ! HAVE_LONG_NAMES */ -#endif /* SPOOLDIR_TAYLOR */ - -/* The number of available file descriptors. */ - -static int cSdescriptors; - -/* Local functions. */ - -static void xmkdir P((const char *zdir)); -static void usmake_spool_dir P((void)); - -void -usysdep_initialize (fdaemon, fgetcwd) - boolean fdaemon; - boolean fgetcwd; -{ - int o; - char *z; - struct passwd *q; - - ulog_id (getpid ()); - -#if HAVE_GETDTABLESIZE - cSdescriptors = getdtablesize (); -#else -#if HAVE_SYSCONF - cSdescriptors = sysconf (_SC_OPEN_MAX); -#else -#ifdef OPEN_MAX - cSdescriptors = OPEN_MAX; -#else -#ifdef NOFILE - cSdescriptors = NOFILE; -#else - cSdescriptors = 20; -#endif /* ! defined (NOFILE) */ -#endif /* ! defined (OPEN_MAX) */ -#endif /* ! HAVE_SYSCONF */ -#endif /* ! HAVE_GETDTABLESIZE */ - - /* Close everything but stdin, stdout and stderr. */ - - for (o = 3; o < cSdescriptors; o++) - (void) close (o); - - /* Make sure stdin, stdout and stderr are open. Otherwise, newly - opened files will appear to be them and confusion will result. */ - if (fcntl (0, F_GETFD, 0) == -1 - && open ("/dev/null", O_RDONLY, 0) != 0) - exit (EXIT_FAILURE); - if (fcntl (1, F_GETFD, 0) == -1 - && open ("/dev/null", O_WRONLY, 0) != 1) - exit (EXIT_FAILURE); - if (fcntl (2, F_GETFD, 0) == -1 - && open ("/dev/null", O_WRONLY, 0) != 2) - exit (EXIT_FAILURE); - - /* We always set our file modes to exactly what we want. */ - umask (0); - - /* Get the login name, making sure that it matches the uid. Many - systems truncate the getlogin return value to 8 characters, but - keep the full name in the password file, so we prefer the name in - the password file. */ - z = getlogin (); - if (z == NULL) - q = NULL; - else - { - q = getpwnam (z); - if (q != NULL) - z = q->pw_name; - } - if (q == NULL || q->pw_uid != getuid ()) - { - q = getpwuid (getuid ()); - if (q == NULL) - ulog (LOG_FATAL, "Can't get login name"); - z = q->pw_name; - } - zSlogin = xstrdup (z); - - if (fdaemon) - { - /* Set our uid to our effective uid. There is no point in - remembering who originally ran the program. This won't work - on System V, but there's nothing to be done about that and it - doesn't make all that much difference. */ - (void) setuid (geteuid ()); - (void) setgid (getegid ()); - } - - if (fgetcwd) - { - const char *zenv; - struct stat senv, sdot; - - /* Get the current working directory. We have to get it now, - since we're about to do a chdir. We use PWD if it's defined - and if it really names the working directory, since if it's - not the same as whatever getcwd returns it's probably more - appropriate. */ - zenv = getenv ("PWD"); - if (zenv != NULL - && stat (zenv, &senv) == 0 - && stat (".", &sdot) == 0 - && senv.st_ino == sdot.st_ino - && senv.st_dev == sdot.st_dev) - zScwd = xstrdup (zenv); - else - { - -#if HAVE_GETCWD || ! HAVE_GETWD - { - int c; - - c = 128; - while (TRUE) - { - zScwd = (char *) xmalloc (c); - if (getcwd (zScwd, c) != NULL) - break; - if (errno != ERANGE) - ulog (LOG_FATAL, "getcwd: %s", strerror (errno)); - xfree ((pointer) zScwd); - c <<= 1; - } - } -#endif /* HAVE_GETCWD */ - -#if HAVE_GETWD - zScwd = (char *) xmalloc (MAXPATHLEN); - /* The getwd function puts in an error message in the - buffer, rather than setting errno. */ - if (getwd (zScwd) == NULL) - ulog (LOG_FATAL, "getwd: %s", zScwd); -#endif /* HAVE_GETWD */ - - zScwd = (char *) xrealloc ((pointer) zScwd, strlen (zScwd) + 1); - } - } - - /* Connect to the spool directory, and create it if is doesn't - exist. */ - if (chdir (zSpooldir) < 0) - { - if (errno != ENOENT) - ulog (LOG_FATAL, "chdir (%s): %s", zSpooldir, - strerror (errno)); - usmake_spool_dir (); - } -} - -/* Exit the program. */ - -void -usysdep_exit (fsuccess) - boolean fsuccess; -{ - exit (fsuccess ? EXIT_SUCCESS : EXIT_FAILURE); -} - -/* This is called when a non-standard configuration file is used, to - make sure the program doesn't hand out privileged file access. - This means that to test non-standard configuration files, you - should be logged in as uucp. This is called before - usysdep_initialize. It ensures that someone can't simply use an - alternate configuration file to steal UUCP transfers from other - systems. This will still permit people to set up their own - configuration file and pretend to be whatever system they choose. - The only real security is to use a high level of protection on the - modem ports. */ - -/*ARGSUSED*/ -boolean fsysdep_other_config (z) - const char *z; -{ - (void) setuid (getuid ()); - (void) setgid (getgid ()); - return TRUE; -} - -/* Detach from the controlling terminal. This is called by uucico if - it is calling out to another system, so that it can receive SIGHUP - signals from the port it calls out on. It is also called by uucico - just before it starts uuxqt, so that uuxqt is completely - independent of the terminal. */ - -#ifdef TIOCNOTTY -#define HAVE_TIOCNOTTY 1 -#else -#define HAVE_TIOCNOTTY 0 -#endif - -void -usysdep_detach () -{ - int o; - -#if ! HAVE_BSD_PGRP || ! HAVE_TIOCNOTTY - - pid_t igrp; - - /* First make sure we are not a process group leader. If we have - TIOCNOTTY, this doesn't matter, since TIOCNOTTY sets our process - group to 0 anyhow. */ - -#if HAVE_BSD_PGRP - igrp = getpgrp (0); -#else - igrp = getpgrp (); -#endif - - if (igrp == getpid ()) - { - boolean fignored; - pid_t ipid; - - /* Ignore SIGHUP, since our process group leader is about to - die. */ - usset_signal (SIGHUP, SIG_IGN, FALSE, &fignored); - - ipid = isfork (); - if (ipid < 0) - ulog (LOG_FATAL, "fork: %s", strerror (errno)); - - if (ipid != 0) - _exit (EXIT_SUCCESS); - - /* We'll always wind up as a child of process number 1, right? - Right? We have to wait for our parent to die before - reenabling SIGHUP. */ - while (getppid () != 1) - sleep (1); - - /* Restore SIGHUP catcher if it wasn't being ignored. */ - if (! fignored) - usset_signal (SIGHUP, ussignal, TRUE, (boolean *) NULL); - } - -#endif /* ! HAVE_BSD_PGRP || ! HAVE_TIOCNOTTY */ - - /* Close all open files. */ - - ulog_close (); - - for (o = 0; o < cSdescriptors; o++) - (void) close (o); - - /* Reopen stdin, stdout and stderr. */ - - if (open ("/dev/null", O_RDONLY) != 0 - || open ("/dev/null", O_WRONLY) != 1 - || open ("/dev/null", O_WRONLY) != 2) - ulog (LOG_FATAL, "open (/dev/null): %s", strerror (errno)); - -#if HAVE_BSD_PGRP - -#if HAVE_TIOCNOTTY - /* Lose our controlling terminal. */ - -#ifndef O_NDELAY -#define O_NDELAY FNDELAY -#endif - - o = open ("/dev/tty", O_RDWR | O_NDELAY, 0); - if (o >= 0) - { - (void) ioctl (o, TIOCNOTTY, (char *) NULL); - (void) close (o); - } -#endif /* HAVE_TIOCNOTTY */ - - /* Make sure our process group ID is set to 0. On BSD TIOCNOTTY - should already have set it 0, so this will do no harm. On System - V we presumably did not execute the TIOCNOTTY call, but the - System V setpgrp will detach the controlling terminal anyhow. - This lets us use the same code on both BSD and System V, provided - it compiles correctly, which life easier for the configure - script. We don't output an error if we got EPERM because some - BSD variants don't permit this usage of setpgrp (which means they - don't provide any way to pick up a new controlling terminal). */ - - if (setpgrp (0, 0) < 0) - { - if (errno != EPERM) - ulog (LOG_ERROR, "setpgrp: %s", strerror (errno)); - } - -#else /* ! HAVE_BSD_PGRP */ - -#if HAVE_SETSID - - /* Under POSIX the setsid call creates a new session for which we - are the process group leader. It also detaches us from our - controlling terminal. I'm using the BSD setpgrp call first - because they should be equivalent for my purposes, but it turns - out that on Ultrix 4.0 setsid prevents us from ever acquiring - another controlling terminal (it does not change our process - group, and Ultrix 4.0 prevents us from setting our process group - to 0). */ - - if (setsid () < 0) - ulog (LOG_ERROR, "setsid: %s", strerror (errno)); - -#else /* ! HAVE_SETSID */ - -#if HAVE_SETPGRP - - /* Now we assume we have the System V setpgrp, which takes no - arguments, and we couldn't compile the HAVE_BSD_PGRP code above - because there was a prototype somewhere in scope. On System V - setpgrp makes us the leader of a new process group and also - detaches the controlling terminal. */ - - if (setpgrp () < 0) - ulog (LOG_ERROR, "setpgrp: %s", strerror (errno)); - -#else /* ! HAVE_SETPGRP */ - - #error Must detach from controlling terminal - -#endif /* HAVE_SETPGRP */ -#endif /* ! HAVE_SETSID */ -#endif /* ! HAVE_BSD_PGRP */ - - /* At this point we have completely detached from our controlling - terminal. The next terminal device we open will probably become - our controlling terminal. */ -} - -/* Get the node name to use if it was not specified in the configuration - file. */ - -const char * -zsysdep_local_name () -{ -#if HAVE_GETHOSTNAME - char ab[256]; - - if (gethostname (ab, sizeof ab) < 0) - { - ulog (LOG_ERROR, "gethostname: %s", strerror (errno)); - return NULL; - } - ab[sizeof ab - 1] = '\0'; - ab[strcspn (ab, ".")] = '\0'; - return xstrdup (ab); -#else /* ! HAVE_GETHOSTNAME */ -#if HAVE_UNAME - struct utsname s; - - if (uname (&s) < 0) - { - ulog (LOG_ERROR, "uname: %s", strerror (errno)); - return NULL; - } - return xstrdup (s.nodename); -#else /* ! HAVE_UNAME */ - return NULL; -#endif /* ! HAVE_UNAME */ -#endif /* ! HAVE_GETHOSTNAME */ -} - -/* Get the login name. We actually get the login name in - usysdep_initialize, because after that we will lost the real uid. */ - -const char * -zsysdep_login_name () -{ - return zSlogin; -} - -/* Get the port name of standard input. I assume that Unix systems - generally support ttyname. If they don't, this function can just - return NULL. It uses getsockname to see whether standard input is - a TCP connection. */ - -const char * -zsysdep_port_name (ftcp_port) - boolean *ftcp_port; -{ - const char *z; - - *ftcp_port = FALSE; - -#if HAVE_TCP - { - int clen; - - clen = 0; - if (getsockname (0, (struct sockaddr *) NULL, &clen) == 0) - *ftcp_port = TRUE; - } -#endif /* HAVE_TCP */ - - z = ttyname (0); - if (z == NULL) - return NULL; - if (strncmp (z, "/dev/", 5) == 0) - return z + 5; - else - return z; -} - -/* Signal handling routines. When we catch a signal, we want to set - the appropriate elements of afSignal and afLog_signal to TRUE. If - we are on a system which restarts system calls, we may also want to - longjmp out. On a system which does not restart system calls, - these signal handling routines are well-defined by ANSI C. */ - -#if HAVE_RESTARTABLE_SYSCALLS -volatile sig_atomic_t fSjmp; -volatile jmp_buf sSjmp_buf; -#endif /* HAVE_RESTARTABLE_SYSCALLS */ - -/* The SVR3 sigset function can be called just like signal, unless - system calls are restarted which is extremely unlikely; we prevent - this case in sysh.unx. */ -#if HAVE_SIGSET && ! HAVE_SIGACTION && ! HAVE_SIGVEC -#define signal sigset -#endif - -/* Catch a signal. Reinstall the signal handler if necessary, set the - appropriate variables, and do a longjmp if necessary. */ - -SIGtype -ussignal (isig) - int isig; -{ - int iindex; - -#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET - (void) signal (isig, ussignal); -#endif - - switch (isig) - { - default: iindex = INDEXSIG_SIGHUP; break; -#ifdef SIGINT - case SIGINT: iindex = INDEXSIG_SIGINT; break; -#endif -#ifdef SIGQUIT - case SIGQUIT: iindex = INDEXSIG_SIGQUIT; break; -#endif -#ifdef SIGTERM - case SIGTERM: iindex = INDEXSIG_SIGTERM; break; -#endif -#ifdef SIGPIPE - case SIGPIPE: iindex = INDEXSIG_SIGPIPE; break; -#endif - } - - afSignal[iindex] = TRUE; - afLog_signal[iindex] = TRUE; - -#if HAVE_RESTARTABLE_SYSCALLS - if (fSjmp) - longjmp (sSjmp_buf, 1); -#endif /* HAVE_RESTARTABLE_SYSCALLS */ -} - -/* Prepare to catch a signal. This is basically the ANSI C routine - signal, but it uses sigaction or sigvec instead if they are - available. If fforce is FALSE, we do not set the signal if it is - currently being ignored. If pfignored is not NULL and fforce is - FALSE, then *pfignored will be set to TRUE if the signal was - previously being ignored (if fforce is TRUE the value of *pfignored - is meaningless). If we can't change the signal handler we give a - fatal error. */ - -void -usset_signal (isig, pfn, fforce, pfignored) - int isig; - SIGtype (*pfn) P((int)); - boolean fforce; - boolean *pfignored; -{ -#if HAVE_SIGACTION - - struct sigaction s; - - if (! fforce) - { - sigemptyset (&s.sa_mask); - if (sigaction (isig, (struct sigaction *) NULL, &s) != 0) - ulog (LOG_FATAL, "sigaction (%d): %s", isig, strerror (errno)); - - if (s.sa_handler == SIG_IGN) - { - if (pfignored != NULL) - *pfignored = TRUE; - return; - } - - if (pfignored != NULL) - *pfignored = FALSE; - } - - s.sa_handler = pfn; - sigemptyset (&s.sa_mask); - s.sa_flags = 0; - - if (sigaction (isig, &s, (struct sigaction *) NULL) != 0) - ulog (LOG_FATAL, "sigaction (%d): %s", isig, strerror (errno)); - -#else /* ! HAVE_SIGACTION */ -#if HAVE_SIGVEC - - struct sigvec s; - - if (! fforce) - { - if (sigvec (isig, (struct sigvec *) NULL, &s) != 0) - ulog (LOG_FATAL, "sigvec (%d): %s", isig, strerror (errno)); - - if (s.sv_handler == SIG_IGN) - { - if (pfignored != NULL) - *pfignored = TRUE; - return; - } - - if (pfignored != NULL) - *pfignored = FALSE; - } - - s.sv_handler = pfn; - s.sv_mask = 0; -#ifdef SV_INTERRUPT - s.sv_flags = SV_INTERRUPT; -#else - s.sv_flags = 0; -#endif - - if (sigvec (isig, &s, (struct sigvec *) NULL) != 0) - ulog (LOG_FATAL, "sigvec (%d): %s", isig, strerror (errno)); - -#else /* ! HAVE_SIGVEC */ - - if (! fforce) - { - if (signal (isig, SIG_IGN) == SIG_IGN) - { - if (pfignored != NULL) - *pfignored = TRUE; - return; - } - - if (pfignored != NULL) - *pfignored = FALSE; - } - - (void) signal (isig, pfn); - -#endif /* ! HAVE_SIGVEC */ -#endif /* ! HAVE_SIGACTION */ -} - -/* The routine called by the system independent code, which always - uses the same signal handler. */ - -void -usysdep_signal (isig) - int isig; -{ - usset_signal (isig, ussignal, FALSE, (boolean *) NULL); -} - -/* Get the time in seconds since the epoch, with optional - microseconds. We use usysdep_process_time to get the microseconds - if it will work (it won't is it uses times, since that returns a - time based only on the process). */ - -long -isysdep_time (pimicros) - long *pimicros; -{ -#if HAVE_GETTIMEOFDAY || HAVE_FTIME - return isysdep_process_time (pimicros); -#else - if (pimicros != NULL) - *pimicros = 0; - return time ((time_t *) NULL); -#endif -} - -/* Get the time in seconds and microseconds; this need only work - within the process when called from the system independent code. - It is also called by isysdep_time, above. */ - -long -isysdep_process_time (pimicros) - long *pimicros; -{ -#if HAVE_GETTIMEOFDAY - struct timeval stime; - struct timezone stz; - - (void) gettimeofday (&stime, &stz); - if (pimicros != NULL) - *pimicros = stime.tv_usec; - return stime.tv_sec; -#endif /* HAVE_GETTIMEOFDAY */ - -#if HAVE_FTIME - struct timeb stime; - - (void) ftime (&stime); - if (pimicros != NULL) - *pimicros = stime.millitm * 1000; - return stime.time; -#endif /* HAVE_FTIME */ - -#if HAVE_TIMES - struct tms s; - long i; - static int itick; - - if (itick == 0) - { -#if TIMES_TICK != 0 - itick = TIMES_TICK; -#else /* TIMES_TICK == 0 */ - const char *z; - - z = getenv ("HZ"); - if (z != NULL) - itick = atoi (z); - - /* If we really couldn't get anything, just use 60. */ - if (itick == 0) - itick = 60; -#endif /* TIMES_TICK == 0 */ - } - - i = (long) times (&s); - if (pimicros != NULL) - *pimicros = (i % (long) itick) * ((long) 1000000 / (long) itick); - return i / (long) itick; -#endif /* HAVE_TIMES */ - -#if ! HAVE_GETTIMEOFDAY && ! HAVE_FTIME && ! HAVE_TIMES - if (pimicros != NULL) - *pimicros = 0; - return time ((time_t *) NULL); -#endif /* ! HAVE_GETTIMEOFDAY && ! HAVE_FTIME && ! HAVE_TIMES */ -} - -/* Fill in a struct tm. */ - -void -usysdep_localtime (itime, q) - long itime; - struct tm *q; -{ - time_t i; - - i = (time_t) itime; - memcpy (q, localtime (&i), sizeof (struct tm)); -} - -/* Sleep for a number of seconds. */ - -void -usysdep_sleep (c) - int c; -{ - sleep (c); -} - -/* Check whether a file exists. */ - -boolean -fsysdep_file_exists (zfile) - const char *zfile; -{ - struct stat s; - - return stat (zfile, &s) == 0; -} - -/* Open a stdio file with appropriate permissions. */ - -FILE * -esysdep_fopen (zfile, fpublic, fappend, fmkdirs) - const char *zfile; - boolean fpublic; - boolean fappend; - boolean fmkdirs; -{ - int imode; - int o; - FILE *e; - - if (fpublic) - imode = IPUBLIC_FILE_MODE; - else - imode = IPRIVATE_FILE_MODE; - - if (! fappend) - o = creat (zfile, imode); - else - { -#ifdef O_CREAT - o = open (zfile, O_WRONLY | O_APPEND | O_CREAT | O_NOCTTY, imode); -#else - o = open (zfile, O_WRONLY | O_NOCTTY); - if (o < 0 && errno == ENOENT) - o = creat (zfile, imode); -#endif /* ! defined (O_CREAT) */ - } - - if (o < 0) - { - if (errno == ENOENT && fmkdirs) - { - if (! fsysdep_make_dirs (zfile, fpublic)) - return NULL; - if (! fappend) - o = creat (zfile, imode); - else - { -#ifdef O_CREAT - o = open (zfile, O_WRONLY | O_APPEND | O_CREAT, imode); -#else - o = creat (zfile, imode); -#endif - } - } - if (o < 0) - { - ulog (LOG_ERROR, "open (%s): %s", zfile, strerror (errno)); - return NULL; - } - } - -#ifndef O_CREAT -#ifdef O_APPEND - if (fappend) - { - if (fcntl (o, F_SETFL, O_APPEND) != 0) - { - ulog (LOG_ERROR, "fcntl (%s, O_APPEND): %s", zfile, - strerror (errno)); - (void) close (o); - return NULL; - } - } -#endif /* defined (O_APPEND) */ -#endif /* ! defined (O_CREAT) */ - - if (fappend) - e = fdopen (o, (char *) "a"); - else - e = fdopen (o, (char *) "w"); - - if (e == NULL) - { - ulog (LOG_ERROR, "fdopen: %s", strerror (errno)); - (void) close (o); - } - - return e; -} - -/* See whether a directory exists. */ - -boolean -fsdirectory_exists (z) - const char *z; -{ - struct stat s; - - if (stat (z, &s) < 0) - return FALSE; - return S_ISDIR (s.st_mode); -} - -/* Create any directories needed for a file name. */ - -boolean -fsysdep_make_dirs (zfile, fpublic) - const char *zfile; - boolean fpublic; -{ - char *zcopy, *z; - int imode; - - zcopy = (char *) alloca (strlen (zfile) + 1); - strcpy (zcopy, zfile); - - if (fpublic) - imode = IPUBLIC_DIRECTORY_MODE; - else - imode = IDIRECTORY_MODE; - - for (z = zcopy; *z != '\0'; z++) - { - if (*z == '/' && z != zcopy) - { - *z = '\0'; - if (! fsdirectory_exists (zcopy)) - { - if (mkdir (zcopy, imode) != 0) - { - ulog (LOG_ERROR, "mkdir (%s): %s", zcopy, - strerror (errno)); - return FALSE; - } - } - *z = '/'; - } - } - - return TRUE; -} - -/* Tilde expand a file or directory name. */ - -/*ARGSUSED*/ -const char * -zstilde_expand (qsys, zfile) - const struct ssysteminfo *qsys; - const char *zfile; -{ - static int calc; - static char *zalc; - const char *zdir; - int clen; - - if (zfile[0] != '~') - return zfile; - else if (zfile[1] == '\0' || zfile[1] == '/') - { - const char *zpub; - - if (qsys->zpubdir == NULL) - zpub = zPubdir; - else - zpub = qsys->zpubdir; - if (zfile[1] == '\0') - return zpub; - else - { - zdir = zpub; - zfile += 2; - } - } - else - { - int cuserlen; - char *zcopy; - struct passwd *q; - - ++zfile; - cuserlen = strcspn (zfile, "/"); - zcopy = (char *) alloca (cuserlen + 1); - strncpy (zcopy, zfile, cuserlen); - zcopy[cuserlen] = '\0'; - - q = getpwnam (zcopy); - if (q == NULL) - { - ulog (LOG_ERROR, "User %s not found", zcopy); - return NULL; - } - - if (zfile[cuserlen] == '\0') - return q->pw_dir; - else - { - zdir = q->pw_dir; - zfile += cuserlen + 1; - } - } - - clen = strlen (zdir) + strlen (zfile) + 2; - if (clen > calc) - { - zalc = (char *) xrealloc ((pointer) zalc, clen); - calc = clen; - } - - sprintf (zalc, "%s/%s", zdir, zfile); - return zalc; -} - -/* Do access(2) on a stat structure, except that the user name is - provided. If the user name in zuser is NULL, require the file to - be accessible to the world. Return TRUE if access is permitted, - FALSE otherwise. This does not log an error message. */ - -boolean -fsuser_access (q, imode, zuser) - const struct stat *q; - int imode; - const char *zuser; -{ - static char *zuser_hold; - static uid_t iuid_hold; - static gid_t igid_hold; - static int cgroups_hold; - static gid_t *paigroups_hold; - int ir, iw, ix, iand; - - if (imode == F_OK) - return TRUE; - - if (zuser != NULL) - { - /* We keep static variables around for the last user we did, to - avoid looking up a user multiple times. */ - if (zuser_hold == NULL || strcmp (zuser_hold, zuser) != 0) - { - struct passwd *qpwd; - - if (zuser_hold != NULL) - { - xfree ((pointer) zuser_hold); - zuser_hold = NULL; - cgroups_hold = 0; - xfree ((pointer) paigroups_hold); - paigroups_hold = NULL; - } - - qpwd = getpwnam ((char *) zuser); - if (qpwd == NULL) - { - /* Check this as a remote request. */ - zuser = NULL; - } - else - { -#if HAVE_GETGRENT - struct group *qg; -#endif - - zuser_hold = xstrdup (zuser); - - iuid_hold = qpwd->pw_uid; - igid_hold = qpwd->pw_gid; - -#if HAVE_GETGRENT - /* Get the list of groups for this user. This is - definitely more appropriate for BSD than for System - V. It may just be a waste of time, and perhaps it - should be configurable. */ - setgrent (); - while ((qg = getgrent ()) != NULL) - { - const char **pz; - - if (qg->gr_gid == igid_hold) - continue; - for (pz = (const char **) qg->gr_mem; *pz != NULL; pz++) - { - if ((*pz)[0] == *zuser - && strcmp (*pz, zuser) == 0) - { - paigroups_hold = ((gid_t *) - (xrealloc - ((pointer) paigroups_hold, - ((cgroups_hold + 1) - * sizeof (gid_t))))); - paigroups_hold[cgroups_hold] = qg->gr_gid; - ++cgroups_hold; - break; - } - } - } - endgrent (); -#endif - } - } - } - - - /* Now do the actual access check. */ - - if (zuser != NULL) - { - /* The superuser can do anything. */ - if (iuid_hold == 0) - return TRUE; - - /* If this is the uid we're running under, there's no point to - checking access further, because when we actually try the - operation the system will do the checking for us. */ - if (iuid_hold == geteuid ()) - return TRUE; - } - - ir = S_IROTH; - iw = S_IWOTH; - ix = S_IXOTH; - - if (zuser != NULL) - { - if (iuid_hold == q->st_uid) - { - ir = S_IRUSR; - iw = S_IWUSR; - ix = S_IXUSR; - } - else - { - boolean fgroup; - - fgroup = FALSE; - if (igid_hold == q->st_gid) - fgroup = TRUE; - else - { - int i; - - for (i = 0; i < cgroups_hold; i++) - { - if (paigroups_hold[i] == q->st_gid) - { - fgroup = TRUE; - break; - } - } - } - - if (fgroup) - { - ir = S_IRGRP; - iw = S_IWGRP; - ix = S_IXGRP; - } - } - } - - iand = 0; - if ((imode & R_OK) != 0) - iand |= ir; - if ((imode & W_OK) != 0) - iand |= iw; - if ((imode & X_OK) != 0) - iand |= ix; - - return (q->st_mode & iand) == iand; -} - -/* See whether a file is in a directory, and optionally check access. */ - -boolean -fsysdep_in_directory (qsys, zfile, zdir, fcheck, freadable, zuser) - const struct ssysteminfo *qsys; - const char *zfile; - const char *zdir; - boolean fcheck; - boolean freadable; - const char *zuser; -{ - int c; - char *zcopy, *zslash; - struct stat s; - - if (*zdir == '~') - { - zdir = zstilde_expand (qsys, zdir); - if (zdir == NULL) - return FALSE; - } - c = strlen (zdir); - if (zdir[c - 1] == '/') - c--; - if (strncmp (zfile, zdir, c) != 0 - || (zfile[c] != '/' && zfile[c] != '\0')) - return FALSE; - if (strstr (zfile + c, "/../") != NULL) - return FALSE; - - /* If we're not checking access, get out now. */ - - if (! fcheck) - return TRUE; - - zcopy = (char *) alloca (strlen (zfile) + 1); - strcpy (zcopy, zfile); - - /* Start checking directories after zdir. Otherwise, we would - require that all directories down to /usr/spool/uucppublic be - publically searchable; they probably are but it should not be - requirement. */ - - zslash = zcopy + c; - do - { - char b; - struct stat shold; - - b = *zslash; - *zslash = '\0'; - - shold = s; - if (stat (zcopy, &s) != 0) - { - if (errno != ENOENT) - { - ulog (LOG_ERROR, "stat (%s): %s", zcopy, strerror (errno)); - return FALSE; - } - - /* If this is the top directory, any problems will be caught - later when we try to open it. */ - if (zslash == zcopy + c) - return TRUE; - - /* Go back and check the last directory for read or write - access. */ - s = shold; - break; - } - - /* If this is not a directory, get out of the loop. */ - if (! S_ISDIR (s.st_mode)) - break; - - /* Make sure the directory is searchable. */ - if (! fsuser_access (&s, X_OK, zuser)) - { - ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES)); - return FALSE; - } - - /* If we've reached the end of the string, get out. */ - if (b == '\0') - break; - - *zslash = b; - } - while ((zslash = strchr (zslash + 1, '/')) != NULL); - - /* At this point s holds a stat on the last component of the path. - We must check it for readability or writeability. */ - - if (! fsuser_access (&s, freadable ? R_OK : W_OK, zuser)) - { - ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES)); - return FALSE; - } - - return TRUE; -} - -/* Start up a new program and end the current one. We always go - through isspawn, and never exec directly. We don't have to worry - about SIGHUP because the current process is either not a process - group leader (uucp, uux) or it does not have a controlling terminal - (uucico). */ - -boolean -fsysdep_run (ffork, zprogram, zarg1, zarg2) - boolean ffork; - const char *zprogram; - const char *zarg1; - const char *zarg2; -{ - char *zlib; - const char *azargs[4]; - int aidescs[3]; - pid_t ipid; - - zlib = (char *) alloca (sizeof LIBDIR + sizeof "/" + strlen (zprogram)); - sprintf (zlib, "%s/%s", LIBDIR, zprogram); - - azargs[0] = zlib; - azargs[1] = zarg1; - azargs[2] = zarg2; - azargs[3] = NULL; - - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_NULL; - aidescs[2] = SPAWN_NULL; - - /* We pass fshell as TRUE, which permits uucico and uuxqt to be - replaced by shell scripts. */ - ipid = isspawn (azargs, aidescs, FALSE, FALSE, (const char *) NULL, - FALSE, TRUE, (const char *) NULL, - (const char *) NULL, (const char *) NULL); - if (ipid < 0) - { - ulog (LOG_ERROR, "isspawn: %s", strerror (errno)); - return FALSE; - } - - if (ffork) - return TRUE; - - exit (EXIT_SUCCESS); -} - -/* Mail a message to a user. */ - -boolean -fsysdep_mail (zto, zsubject, cstrs, paz) - const char *zto; - const char *zsubject; - int cstrs; - const char **paz; -{ - const char *az[3]; - FILE *e; - pid_t ipid; - time_t itime; - int i; - - az[0] = MAIL_PROGRAM; - az[1] = zto; - az[2] = NULL; - - e = espopen (az, FALSE, &ipid); - if (e == NULL) - { - ulog (LOG_ERROR, "espopen (%s): %s", MAIL_PROGRAM, - strerror (errno)); - return FALSE; - } - - fprintf (e, "Subject: %s\n", zsubject); - fprintf (e, "To: %s\n", zto); - - /* We should probably put in a Date: header as well. */ - - fprintf (e, "\n"); - - (void) time (&itime); - /* Remember that ctime includes a \n, so this skips a line. */ - fprintf (e, "Message from UUCP on %s %s\n", zLocalname, - ctime (&itime)); - - for (i = 0; i < cstrs; i++) - fputs (paz[i], e); - - (void) fclose (e); - - return iswait ((unsigned long) ipid, MAIL_PROGRAM) == 0; -} - -/* Make a directory with error checking. */ - -static void -xmkdir (zdir) - const char *zdir; -{ - if (mkdir ((char *) zdir, IDIRECTORY_MODE) < 0) - ulog (LOG_FATAL, "mkdir (%s): %s", zdir, strerror (errno)); -} - -/* Make the spool directory. */ - -static void -usmake_spool_dir () -{ - xmkdir (zSpooldir); - - if (chdir (zSpooldir) < 0) - ulog (LOG_FATAL, "chdir (%s): %s", zSpooldir, strerror (errno)); - -#if SPOOLDIR_BSD42 | SPOOLDIR_BSD43 - xmkdir ("C."); - xmkdir ("D."); -#if SPOOLDIR_BSD43 - xmkdir ("X."); -#endif /* SPOOLDIR_BSD43 */ - { - char ab[sizeof "D.1234567X"]; - - sprintf (ab, "D.%.7s", zLocalname); - xmkdir (ab); -#if SPOOLDIR_BSD43 - strcat (ab, "X"); - xmkdir (ab); -#endif /* SPOOLDIR_BSD43 */ - } -#endif /* SPOOLDIR_BSD42 | SPOOLDIR_BSD43 */ - -#if SPOOLDIR_ULTRIX - xmkdir ("sys"); - xmkdir ("sys/DEFAULT"); - xmkdir ("sys/DEFAULT/C."); - xmkdir ("sys/DEFAULT/D."); - xmkdir ("sys/DEFAULT/X."); - { - char ab[sizeof "sys/DEFAULT/D.1234567X"]; - - sprintf (ab, "sys/DEFAULT/D.%.7s", zLocalname); - xmkdir (ab); - strcat (ab, "X"); - xmkdir (ab); - } -#endif /* SPOOLDIR_ULTRIX */ - -#if SPOOLDIR_BSD43 | SPOOLDIR_ULTRIX | SPOOLDIR_TAYLOR - xmkdir (".Temp"); -#endif /* SPOOLDIR_BSD43 | SPOOLDIR_ULTRIX | SPOOLDIR_TAYLOR */ - - xmkdir (".Status"); - xmkdir (".Sequence"); - xmkdir (XQTDIR); - xmkdir (PRESERVEDIR); -} - -/* Retry fork several times before giving up. */ - -pid_t -isfork () -{ - int i; - pid_t iret; - - for (i = 0; i < 10; i++) - { - iret = fork (); - if (iret >= 0 || errno != EAGAIN) - return iret; - sleep (5); - } - - return iret; -} - -/* Spawn a child in a fairly secure fashion. This returns the process - ID of the child or -1 on error. It takes far too many arguments: - - pazargs -- arguments (element 0 is command) - aidescs -- file descriptors for stdin, stdout and stderr - fkeepuid -- TRUE if euid should be left unchanged - fkeepenv -- TRUE if environment should be left unmodified - zchdir -- directory to chdir to - fnosigs -- TRUE if child should ignore SIGHUP, SIGINT and SIGQUIT - fshell -- TRUE if should try /bin/sh if execve gets ENOEXEC - zpath -- value for environment variable PATH - zuu_machine -- value for environment variable UU_MACHINE - zuu_user -- value for environment variable UU_USER - - The aidescs array is three elements long. 0 is stdin, 1 is stdout - and 2 is stderr. The array may contain either file descriptor - numbers to dup appropriately, or one of the following: - - SPAWN_NULL -- set descriptor to /dev/null - SPAWN_READ_PIPE -- set aidescs element to pipe for parent to read - SPAWN_WRITE_PIPE -- set aidescs element to pipe for parent to write - - If fkeepenv is FALSE, a standard environment is created. The - environment arguments (zpath, zuu_machine and zuu_user) are only - used if fkeepenv is FALSE; any of them may be NULL. */ - -pid_t -isspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell, - zpath, zuu_machine, zuu_user) - const char **pazargs; - int aidescs[3]; - boolean fkeepuid; - boolean fkeepenv; - const char *zchdir; - boolean fnosigs; - boolean fshell; - const char *zpath; - const char *zuu_machine; - const char *zuu_user; -{ - char *zshcmd = NULL; - int i; - char *azenv[9]; - char **pazenv; - boolean ferr; - int ierr = 0; - int onull; - int aichild_descs[3]; - int cpar_close; - int aipar_close[4]; - int cchild_close; - int aichild_close[3]; - pid_t iret = 0; - const char *zcmd; - - /* If we might have to use the shell, allocate enough space for the - quoted command before forking. Otherwise the allocation might - modify the data segment and we could not safely use vfork. */ - if (fshell) - { - int clen; - - clen = 0; - for (i = 0; pazargs[i] != NULL; i++) - clen += strlen (pazargs[i]); - zshcmd = (char *) alloca (2 * clen + i); - } - - /* Set up a standard environment. This is again done before forking - because it might modify the data segment. */ - - if (fkeepenv) - pazenv = environ; - else - { - const char *zterm, *ztz; - char *zspace; - int ienv; - - if (zpath == NULL) - zpath = CMDPATH; - - azenv[0] = (char *) alloca (sizeof "PATH=" + strlen (zpath)); - sprintf (azenv[0], "PATH=%s", zpath); - zspace = azenv[0] + sizeof "PATH=" - 1; - while ((zspace = strchr (zspace, ' ')) != NULL) - *zspace = ':'; - - azenv[1] = (char *) alloca (sizeof "HOME=" + strlen (zSpooldir)); - sprintf (azenv[1], "HOME=%s", zSpooldir); - - zterm = getenv ("TERM"); - if (zterm == NULL) - zterm = "unknown"; - azenv[2] = (char *) alloca (sizeof "TERM=" + strlen (zterm)); - sprintf (azenv[2], "TERM=%s", zterm); - - azenv[3] = (char *) "SHELL=/bin/sh"; - - azenv[4] = (char *) alloca (sizeof "USER=" + strlen (OWNER)); - sprintf (azenv[4], "USER=%s", OWNER); - - ienv = 5; - - ztz = getenv ("TZ"); - if (ztz != NULL) - { - azenv[ienv] = (char *) alloca (sizeof "TZ=" + strlen (ztz)); - sprintf (azenv[ienv], "TZ=%s", ztz); - ++ienv; - } - - if (zuu_machine != NULL) - { - azenv[ienv] = (char *) alloca (sizeof "UU_MACHINE=" - + strlen (zuu_machine)); - sprintf (azenv[ienv], "UU_MACHINE=%s", zuu_machine); - ++ienv; - } - - if (zuu_user != NULL) - { - azenv[ienv] = (char *) alloca (sizeof "UU_USER=" - + strlen (zuu_user)); - sprintf (azenv[ienv], "UU_USER=%s", zuu_user); - ++ienv; - } - - azenv[ienv] = NULL; - pazenv = azenv; - } - - /* Set up any needed pipes. */ - - ferr = FALSE; - onull = -1; - cpar_close = 0; - cchild_close = 0; - - for (i = 0; i < 3; i++) - { - if (aidescs[i] == SPAWN_NULL) - { - if (onull < 0) - { - onull = open ("/dev/null", O_RDWR); - if (onull < 0) - { - ierr = errno; - ferr = TRUE; - break; - } - aipar_close[cpar_close] = onull; - ++cpar_close; - } - aichild_descs[i] = onull; - } - else if (aidescs[i] != SPAWN_READ_PIPE - && aidescs[i] != SPAWN_WRITE_PIPE) - aichild_descs[i] = aidescs[i]; - else - { - int aipipe[2]; - - if (pipe (aipipe) < 0) - { - ierr = errno; - ferr = TRUE; - break; - } - - if (aidescs[i] == SPAWN_READ_PIPE) - { - aidescs[i] = aipipe[0]; - aichild_close[cchild_close] = aipipe[0]; - aichild_descs[i] = aipipe[1]; - aipar_close[cpar_close] = aipipe[1]; - } - else - { - aidescs[i] = aipipe[1]; - aichild_close[cchild_close] = aipipe[1]; - aichild_descs[i] = aipipe[0]; - aipar_close[cpar_close] = aipipe[0]; - } - - ++cpar_close; - ++cchild_close; - } - } - -#if DEBUG > 1 - if (! ferr && FDEBUGGING (DEBUG_EXECUTE)) - { - ulog (LOG_DEBUG_START, "Forking %s", pazargs[0]); - for (i = 1; pazargs[i] != NULL; i++) - ulog (LOG_DEBUG_CONTINUE, " %s", pazargs[i]); - ulog (LOG_DEBUG_END, "%s", ""); - } -#endif - - if (! ferr) - { - /* This should really be vfork if available. */ - iret = isfork (); - if (iret < 0) - { - ferr = TRUE; - ierr = errno; - } - } - - if (ferr) - { - for (i = 0; i < cpar_close; i++) - (void) close (aipar_close[i]); - for (i = 0; i < cchild_close; i++) - (void) close (aichild_close[i]); - errno = ierr; - return -1; - } - - /* Here the fork has succeeded and all the pipes have been done. */ - - if (iret != 0) - { - /* The parent. Close the child's ends of the pipes and return - the process ID. */ - for (i = 0; i < cpar_close; i++) - (void) close (aipar_close[i]); - return iret; - } - - /* The child. */ - -#ifdef STDIN_FILENO -#if STDIN_FILENO != 0 || STDOUT_FILENO != 1 || STDERR_FILENO != 2 - #error The following code makes invalid assumptions -#endif -#endif - - for (i = 0; i < 3; i++) - if (aichild_descs[i] != i) - (void) dup2 (aichild_descs[i], i); - - for (i = 3; i < cSdescriptors; i++) - (void) close (i); - - zcmd = pazargs[0]; - pazargs[0] = strrchr (zcmd, '/'); - if (pazargs[0] == NULL) - pazargs[0] = zcmd; - else - ++pazargs[0]; - - if (! fkeepuid) - { - (void) setuid (getuid ()); - (void) setgid (getgid ()); - } - - if (zchdir != NULL) - (void) chdir (zchdir); - - if (fnosigs) - { -#ifdef SIGHUP - (void) signal (SIGHUP, SIG_IGN); -#endif -#ifdef SIGINT - (void) signal (SIGINT, SIG_IGN); -#endif -#ifdef SIGQUIT - (void) signal (SIGQUIT, SIG_IGN); -#endif - } - - (void) execve ((char *) zcmd, (char **) pazargs, pazenv); - - /* The exec failed. If permitted, try using /bin/sh to execute a - shell script. */ - - if (errno == ENOEXEC && fshell) - { - char *zto; - const char *azshargs[4]; - - pazargs[0] = zcmd; - zto = zshcmd; - for (i = 0; pazargs[i] != NULL; i++) - { - const char *zfrom; - - for (zfrom = pazargs[i]; *zfrom != '\0'; zfrom++) - { - /* Some versions of /bin/sh appear to have a bug such - that quoting a '/' sometimes causes an error. I - don't know exactly when this happens (I can recreate - it on Ultrix 4.0), but in any case it is harmless to - not quote a '/'. */ - if (*zfrom != '/') - *zto++ = '\\'; - *zto++ = *zfrom; - } - *zto++ = ' '; - } - *(zto - 1) = '\0'; - - azshargs[0] = "sh"; - azshargs[1] = "-c"; - azshargs[2] = zshcmd; - azshargs[3] = NULL; - - (void) execve ((char *) "/bin/sh", (char **) azshargs, pazenv); - } - - _exit (EXIT_FAILURE); - - /* Avoid compiler warning. */ - return -1; -} - -/* A version of popen that goes through isspawn. This actually takes - an array of arguments rather than a string, and takes a boolean - read/write value rather than a string. It sets *pipid to the - process ID of the child. */ - -FILE * -espopen (pazargs, frd, pipid) - const char **pazargs; - boolean frd; - pid_t *pipid; -{ - int aidescs[3]; - pid_t ipid; - FILE *eret; - - if (frd) - { - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_READ_PIPE; - } - else - { - aidescs[0] = SPAWN_WRITE_PIPE; - aidescs[1] = SPAWN_NULL; - } - aidescs[2] = SPAWN_NULL; - - ipid = isspawn (pazargs, aidescs, FALSE, FALSE, - (const char *) NULL, FALSE, TRUE, - (const char *) NULL, (const char *) NULL, - (const char *) NULL); - if (ipid < 0) - return NULL; - - if (frd) - eret = fdopen (aidescs[1], (char *) "r"); - else - eret = fdopen (aidescs[0], (char *) "w"); - - if (eret == NULL) - { - int ierr; - - ierr = errno; - (void) close (frd ? aidescs[1] : aidescs[0]); - (void) kill (ipid, SIGKILL); - (void) iswait ((unsigned long) ipid, (const char *) NULL); - errno = ierr; - return NULL; - } - - *pipid = ipid; - - return eret; -} - -/* Wait for a particular process to finish. The ipid argument should - be pid_t, but then we couldn't have a prototype. If the zreport - argument is not NULL, then a wait error will be logged, and if the - exit status is non-zero it will be logged with zreport as the - header of the log message. If the zreport argument is NULL, no - errors will be logged. This function returns the exit status if - the process exited normally, or -1 on error or if the process was - killed by a signal (I don't just always return the exit status - because then the calling code would have to prepared to handle - union wait status vs. int status, and none of the callers care - which signal killed the program anyhow). - - This functions keeps waiting until the process finished, even if it - is interrupted by a signal. I think this is right for all uses. - The controversial one would be when called from uuxqt to wait for a - requested process. Hitting uuxqt with SIGKILL will approximate the - actions taken if we return from here with an error anyhow. If we - do get a signal, we call ulog with a NULL argument to get it in the - log file at about the right time. */ - -int -iswait (ipid, zreport) - unsigned long ipid; - const char *zreport; -{ - wait_status istat; - -#if HAVE_WAITPID - while (waitpid ((pid_t) ipid, &istat, 0) < 0) - { - if (errno != EINTR) - { - if (zreport != NULL) - ulog (LOG_ERROR, "waitpid: %s", strerror (errno)); - return -1; - } - ulog (LOG_ERROR, (const char *) NULL); - } -#else /* ! HAVE_WAITPID */ -#if HAVE_WAIT4 - while (wait4 ((pid_t) ipid, &istat, 0, (struct rusage *) NULL) < 0) - { - if (errno != EINTR) - { - if (zreport != NULL) - ulog (LOG_ERROR, "wait4: %s", strerror (errno)); - return -1; - } - ulog (LOG_ERROR, (const char *) NULL); - } -#else /* ! HAVE_WAIT4 */ - pid_t igot; - - /* We could theoretically get the wrong child here if we're in some - kind of weird pipeline, so we don't give any error messages for - it. */ - while ((igot = wait (&istat)) != (pid_t) ipid) - { - if (igot < 0) - { - if (errno != EINTR) - { - if (zreport != NULL) - ulog (LOG_ERROR, "wait: %s", strerror (errno)); - return -1; - } - ulog (LOG_ERROR, (const char *) NULL); - } - } -#endif /* ! HAVE_WAIT4 */ -#endif /* ! HAVE_WAITPID */ - - DEBUG_MESSAGE2 (DEBUG_EXECUTE, "%s %d", - WIFEXITED (istat) ? "Exit status" : "Signal", - WIFEXITED (istat) ? WEXITSTATUS (istat) : WTERMSIG (istat)); - - if (WIFEXITED (istat) && WEXITSTATUS (istat) == 0) - return 0; - - if (zreport != NULL) - { - if (! WIFEXITED (istat)) - ulog (LOG_ERROR, "%s: Got signal %d", zreport, WTERMSIG (istat)); - else - ulog (LOG_ERROR, "%s: Exit status %d", zreport, - WEXITSTATUS (istat)); - } - - if (WIFEXITED (istat)) - return WEXITSTATUS (istat); - else - return -1; -} - -#if ! HAVE_REMOVE - -/* Remove a file. */ - -int -remove (z) - const char *z; -{ - return unlink (z); -} - -#endif /* ! HAVE_REMOVE */ - -#if ! HAVE_STRERROR - -/* Some systems don't have a strerror definition, so we provide one. - This function is, of course, system dependent. */ - -char * -strerror (ierr) - int ierr; -{ - extern int sys_nerr; - extern char *sys_errlist[]; - - if (ierr >= 0 && ierr < sys_nerr) - return sys_errlist[ierr]; - return (char *) "unknown error"; -} - -#endif /* ! HAVE_STRERROR */ - -#if ! HAVE_GETCWD && ! HAVE_GETWD - -/* Implement a simple getcwd that just calls /bin/pwd. I probably - should include Roland McGrath's getcwd implementation here, since - it doesn't fork, but it requires readdir support that I don't feel - like contemplating just now. */ - -static char * -getcwd (zbuf, cbuf) - char *zbuf; - int cbuf; -{ - const char *azargs[2]; - FILE *e; - pid_t ipid; - int cread; - int ierr; - - azargs[0] = PWD_PROGRAM; - azargs[1] = NULL; - e = espopen (azargs, TRUE, &ipid); - if (e == NULL) - return NULL; - - ierr = 0; - - cread = fread (zbuf, sizeof (char), cbuf, e); - if (cread == 0) - ierr = errno; - - (void) fclose (e); - - if (iswait ((unsigned long) ipid, (const char *) NULL) != 0) - { - ierr = EACCES; - cread = 0; - } - - if (cread != 0) - { - if (zbuf[cread - 1] == '\n') - zbuf[cread - 1] = '\0'; - else - { - ierr = ERANGE; - cread = 0; - } - } - - if (cread == 0) - { - errno = ierr; - return NULL; - } - - return zbuf; -} - -#endif /* ! HAVE_GETCWD && ! HAVE_GETWD */ - -#if ! HAVE_DUP2 - -/* Emulate the dup2 call. I basically took this from the emacs 18.57 - distribution, although I cleaned it up a bit and made it POSIX - compliant. */ - -int -dup2 (oold, onew) - int oold; - int onew; -{ - if (oold == onew) - return onew; - (void) close (onew); - -#ifdef F_DUPFD - return fcntl (oold, F_DUPFD, onew); -#else - { - int onext, oret, isave; - - onext = dup (oold); - if (onext == onew) - return onext; - if (onext < 0) - return -1; - oret = dup2 (oold, onew); - isave = errno; - (void) close (onext); - errno = isave; - return oret; - } -#endif -} - -#endif /* ! HAVE_DUP2 */ - -#if ! HAVE_OPENDIR - -/* Simple emulations of opendir/readdir/closedir for systems which - have the original format of Unix directories. It's probably better - to get Doug Gwyn's public domain set of emulation functions. */ - -DIR * -opendir (zdir) - const char *zdir; -{ - int o; - struct stat s; - DIR *qret; - - o = open (zdir, O_RDONLY | O_NOCTTY, 0); - if (o == -1) - return NULL; - if (fstat (o, &s) < 0) - { - (void) close (o); - return NULL; - } - if (! S_ISDIR (s.st_mode)) - { - (void) close (o); - errno = ENOTDIR; - return NULL; - } - qret = (DIR *) xmalloc (sizeof (DIR)); - qret->o = o; - return qret; -} - -struct dirent * -readdir (q) - DIR *q; -{ - struct direct sdir; - int cgot; - - do - { - cgot = read (q->o, &sdir, sizeof (struct direct)); - if (cgot <= 0) - return NULL; - if (cgot != sizeof (struct direct)) - { - errno = ENOENT; - return NULL; - } - } - while (sdir.d_ino == 0); - - strncpy (q->s.d_name, sdir.d_name, DIRSIZ); - q->s.d_name[DIRSIZ] = '\0'; - return &q->s; -} - -int -closedir (q) - DIR *q; -{ - int iret, isave; - - iret = close (q->o); - isave = errno; - xfree (q); - errno = isave; - return iret; -} - -#endif /* ! HAVE_OPENDIR */ - -#if ! HAVE_MKDIR - -/* We don't have the mkdir system call, so we invoke the suid program - uudir to create the directory with the correct owner. */ - -int -mkdir (zdir, imode) - const char *zdir; - int imode; -{ - const char *azargs[2]; - int aidescs[3]; - pid_t ipid; - - /* /bin/mkdir will create the directory with mode 777, so we set our - umask to get the mode we want. */ - (void) umask ((~ imode) & (S_IRWXU | S_IRWXG | S_IRWXO)); - - azargs[0] = UUDIR_PROGRAM; - azargs[1] = NULL; - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_NULL; - aidescs[2] = SPAWN_NULL; - - ipid = isspawn (azargs, aidescs, FALSE, FALSE, (const char *) NULL, - TRUE, FALSE, (const char *) NULL, - (const char *) NULL, (const char *) NULL); - - (void) umask (0); - - if (ipid < 0) - return -1; - - if (iswait ((unsigned long) ipid, (const char *) NULL) != 0) - { - /* Make up an errno value. */ - errno = EACCES; - return -1; - } - - return 0; -} - -#endif /* ! HAVE_MKDIR */ - -/* - Local variables: - mode:c - End: - */ diff --git a/gnu/libexec/uucp/sys2.unx b/gnu/libexec/uucp/sys2.unx deleted file mode 100644 index 95f4b60841f2..000000000000 --- a/gnu/libexec/uucp/sys2.unx +++ /dev/null @@ -1,2746 +0,0 @@ -/* sys2.unx - The system dependent communication routines for UNIX. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: sys2.unx,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.72 1992/04/03 17:43:39 ian - Petri Helenius: don't clobber undefined bits in termio or termios - - Revision 1.71 1992/04/01 21:52:04 ian - T. William Wells: handle a system without or - - Revision 1.70 1992/03/30 15:29:58 ian - Added HAVE_SVR4_LOCKFILES - - Revision 1.69 1992/03/29 22:25:27 ian - Always block and unblock read and write descriptors together - - Revision 1.68 1992/03/28 04:12:17 ian - Gerben Wierda: minor cleanups - - Revision 1.67 1992/03/28 03:06:04 ian - Don't use TIOCEXCL locking - - Revision 1.66 1992/03/28 02:47:30 ian - Rework HAVE_UNBLOCKED_WRITES to work even if writes are unblocked - - Revision 1.65 1992/03/17 15:35:28 ian - Log signals when they happen, even if we continue looping - - Revision 1.64 1992/03/17 05:01:33 ian - Don't block when opening the write descriptor - - Revision 1.63 1992/03/17 01:03:03 ian - Miscellaneous cleanup - - Revision 1.62 1992/03/16 01:23:08 ian - Make blocking writes optional - - Revision 1.61 1992/03/15 07:15:42 ian - T. William Wells: don't use unblocked writes - - Revision 1.60 1992/03/15 04:51:17 ian - Keep an array of signals we've received rather than a single variable - - Revision 1.59 1992/03/15 01:54:46 ian - All execs are now done in isspawn, all waits are done in iswait - - Revision 1.58 1992/03/12 21:50:50 ian - Moved local header includes above sleep routine determination - - Revision 1.57 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.56 1992/03/11 02:09:57 ian - Franc,ois Pinard: retry fork several times before giving up - - Revision 1.55 1992/03/09 22:11:46 ian - Franc,ois Pinard: sleep for a second after closing a serial port - - Revision 1.54 1992/03/09 22:07:36 ian - Wait for terminal output to drain at various points - - Revision 1.53 1992/03/08 16:56:51 ian - Ted Lindgreen: if CRTSCTS is defined, don't turn on IXOFF - - Revision 1.52 1992/03/08 04:56:21 ian - Peter da Silva: added ``lockname'' command for ports - - Revision 1.51 1992/03/08 01:56:01 ian - Include if we have it - - Revision 1.50 1992/03/08 01:37:45 ian - Suppurt TIOCEXCL locking - - Revision 1.49 1992/03/07 16:25:21 ian - Preserve unknown bits in c_cflag - - Revision 1.48 1992/03/04 23:43:39 ian - Petri Helenius: didn't remove lock file if open failed - - Revision 1.47 1992/03/04 01:40:51 ian - Thomas Fischer: tweaked a bit for the NeXT - - Revision 1.46 1992/03/03 21:01:20 ian - Use strict timeout in fsserial_read, eliminate all race conditions - - Revision 1.45 1992/03/03 04:25:00 ian - T. William Wells: don't arbitrarily extend read timeout - - Revision 1.44 1992/03/02 04:53:07 ian - Marc Unangst: added HAVE_SCO_LOCKFILES configuration parameter - - Revision 1.43 1992/02/28 05:06:15 ian - T. William Wells: fsysdep_catch must be a macro - - Revision 1.42 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.41 1992/02/24 21:22:47 ian - The poll function takes milliseconds, not microseconds (my error) - - Revision 1.40 1992/02/24 21:18:17 ian - Roberto Biancardi: use poll for sleeping if we haven't got anything else - - Revision 1.39 1992/02/24 20:07:43 ian - John Theus: some systems don't have - - Revision 1.38 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.37 1992/02/17 22:08:50 ian - Bob Denny: log chat script messages as LOG_NORMAL, not LOG_ERROR - - Revision 1.36 1992/02/08 20:02:36 ian - Added HAVE_SETRET configuration option for systems without setjmp - - Revision 1.35 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.34 1992/01/16 16:32:44 ian - Mike Park: ioctl is sometimes declared varadic, so we can't declare it - - Revision 1.33 1992/01/15 21:06:11 ian - Mike Park: some systems can't include and together - - Revision 1.32 1992/01/15 20:40:04 ian - Mike Park: some systems don't have - - Revision 1.31 1992/01/15 19:40:35 ian - Mike Park: handle HAVE_UNION_WAIT correctly and completely - - Revision 1.30 1992/01/14 04:18:47 ian - Chip Salzenberg: added HAVE_USLEEP configuration parameter - - Revision 1.29 1992/01/13 06:11:39 ian - David Nugent: can't declare open or fcntl - - Revision 1.28 1991/12/31 04:16:19 ian - Chip Salzenberg: don't turn on IXON and IXOFF at the start - - Revision 1.27 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.26 1991/12/29 00:55:23 ian - Monty Solomon: added HAVE_UNION_WAIT - - Revision 1.25 1991/12/22 22:14:19 ian - Monty Solomon: added HAVE_UNISTD_H configuration parameter - - Revision 1.24 1991/12/20 02:23:10 ian - Don't change port settings if we don't have to - - Revision 1.23 1991/12/19 04:25:57 ian - Terry Gardner: configuration parameter to not use both NONBLOCK and NDELAY - - Revision 1.22 1991/12/17 23:14:08 ian - T. William Wells: allow dialer complete and abort to be chat scripts - - Revision 1.21 1991/12/17 22:31:15 ian - Start in RAW mode, to avoid dropping characters when we switch to it - - Revision 1.20 1991/12/17 05:24:01 ian - David Nugent: flush pending input in fsserial_open - - Revision 1.19 1991/12/15 04:28:23 ian - Don't turn on ISTRIP initially - - Revision 1.18 1991/12/10 19:45:05 ian - Added ulog_device to record device name for log file - - Revision 1.17 1991/12/01 02:23:12 ian - Niels Baggesen: don't multiply include - - Revision 1.16 1991/11/26 01:50:30 ian - Set fread_blocking and fwrite_blocking correctly for TCP routines - - Revision 1.15 1991/11/26 01:45:42 ian - Marty Shannon: configuration option to not include - - Revision 1.14 1991/11/22 06:05:57 ian - Gregory Gulik: fix wait status macro definitions - - Revision 1.13 1991/11/21 20:58:18 ian - Brian Campbell: for HAVE_SIGSETJMP use sigjmp_buf, not jmp_buf - - Revision 1.12 1991/11/15 23:13:53 ian - Fixed termio(s) version of fsserial_set - - Revision 1.11 1991/11/13 20:38:00 ian - Added TCP port type for connections over TCP - - Revision 1.10 1991/11/12 19:07:27 ian - Be careful to only call fsetterminfo on a terminal - - Revision 1.9 1991/11/11 23:47:24 ian - Added chat-program to run a program to do a chat script - - Revision 1.8 1991/11/11 00:39:45 ian - Open port in seven bit mode, added fport_set to change to eight bit - - Revision 1.7 1991/11/08 22:52:34 ian - Brian Campbell: only include and when needed - - Revision 1.6 1991/11/08 22:11:45 ian - Brian Campbell: allow sigsetjmp as configuration option - - Revision 1.5 1991/11/07 22:52:11 ian - Chip Salzenberg: force stdin and stdout to stay open in case of spawning - - Revision 1.4 1991/11/07 21:43:59 ian - Chip Salzenberg: set terminal modes directly, don't or them in - - Revision 1.3 1991/11/07 19:42:16 ian - Chip Salzenberg: declare inline functions consistently - - Revision 1.2 1991/11/07 19:32:28 ian - Chip Salzenberg: allow LOCKDIR, and check that locking process exists - - Revision 1.1 1991/09/10 19:45:50 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char sys2_unx_rcsid[] = "$Id: sys2.unx,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#if HAVE_LIMITS_H -#include -#endif - -#if USE_STDIO && HAVE_UNISTD_H -#include -#endif - -#include "system.h" -#include "sysdep.h" -#include "port.h" - -/* Pick a timing routine to use. I somewhat arbitrarily picked usleep - above nap above napms above poll above select. */ - -#if HAVE_USLEEP || HAVE_NAP || HAVE_NAPMS || HAVE_POLL -#define USE_SELECT_TIMER 0 -#else -#define USE_SELECT_TIMER HAVE_SELECT -#endif - -#if HAVE_USLEEP || HAVE_NAP || HAVE_NAPMS -#undef HAVE_POLL -#define HAVE_POLL 0 -#endif - -#if HAVE_USLEEP || HAVE_NAP -#undef HAVE_NAPMS -#define HAVE_NAPMS 0 -#endif - -#if HAVE_USLEEP -#undef HAVE_NAP -#define HAVE_NAP 0 -#endif - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#if HAVE_SYS_IOCTL_H -#include -#endif - -#if USE_SELECT_TIMER || HAVE_BSD_TTY -#include -#endif - -#if HAVE_POLL -#if HAVE_STROPTS_H -#include -#endif -#if HAVE_POLL_H -#include -#endif -#if ! HAVE_STROPTS_H && ! HAVE_POLL_H -/* We need a definition for struct pollfd, although it doesn't matter - what it contains. It's used in usysdep_pause. */ -struct pollfd -{ - int idummy; -}; -#endif /* ! HAVE_STROPTS_H && ! HAVE_POLL_H */ -#endif /* HAVE_POLL */ - -#if HAVE_TIME_H -#if HAVE_SYS_TIME_AND_TIME_H || (! USE_SELECT_TIMER && ! HAVE_BSD_TTY) -#include -#endif -#endif - -/* Get definitions for both O_NONBLOCK and O_NDELAY. */ - -#ifndef O_NDELAY -#ifdef FNDELAY -#define O_NDELAY FNDELAY -#else /* ! defined (FNDELAY) */ -#define O_NDELAY 0 -#endif /* ! defined (FNDELAY) */ -#endif /* ! defined (O_NDELAY) */ - -#ifndef O_NONBLOCK -#ifdef FNBLOCK -#define O_NONBLOCK FNBLOCK -#else /* ! defined (FNBLOCK) */ -#define O_NONBLOCK 0 -#endif /* ! defined (FNBLOCK) */ -#endif /* ! defined (O_NONBLOCK) */ - -#if O_NDELAY == 0 && O_NONBLOCK == 0 - #error No way to do nonblocking I/O -#endif - -/* If we can define them both together, do so. This is because some - ancient drivers on some systems appear to look for one but not the - other. Otherwise just use O_NONBLOCK. */ -#if COMBINED_UNBLOCK -#define FILE_UNBLOCKED (O_NDELAY | O_NONBLOCK) -#else -#define FILE_UNBLOCKED O_NONBLOCK -#endif - -/* Get definitions for both EAGAIN and EWOULDBLOCK. */ - -#ifndef EAGAIN -#ifndef EWOULDBLOCK -#define EAGAIN (-1) -#define EWOULDBLOCK (-1) -#else /* defined (EWOULDBLOCK) */ -#define EAGAIN EWOULDBLOCK -#endif /* defined (EWOULDBLOCK) */ -#else /* defined (EAGAIN) */ -#ifndef EWOULDBLOCK -#define EWOULDBLOCK EAGAIN -#endif /* ! defined (EWOULDBLOCK) */ -#endif /* defined (EAGAIN) */ - -/* Make sure we have a definition for MAX_INPUT. */ - -#ifndef MAX_INPUT -#define MAX_INPUT (256) -#endif - -/* Make sure we have definitions for major and minor. */ - -#ifndef major -#define major(i) (((i) >> 8) & 0xff) -#endif -#ifndef minor -#define minor(i) ((i) & 0xff) -#endif - -/* If we have the TIOCSINUSE ioctl call, we use it to lock a terminal. - Otherwise, if we have the TIOCEXCL ioctl call, we have to open the - terminal before we know that it is unlocked. */ -#ifdef TIOCSINUSE -#define HAVE_TIOCSINUSE 1 -#else -#ifdef TIOCEXCL -#define HAVE_TIOCEXCL 1 -#endif -#endif - -/* Determine bits to clear for the various terminal control fields for - HAVE_SYSV_TERMIO and HAVE_POSIX_TERMIOS. */ - -#if HAVE_SYSV_TERMIO -#define ICLEAR_IFLAG (IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK \ - | ISTRIP | INLCR | IGNCR | ICRNL | IUCLC \ - | IXON | IXANY | IXOFF) -#define ICLEAR_OFLAG (OPOST | OLCUC | ONLCR | OCRNL | ONOCR | ONLRET \ - | OFILL | OFDEL | NLDLY | CRDLY | TABDLY | BSDLY \ - | VTDLY | FFDLY) -#define ICLEAR_CFLAG (CBAUD | CLOCAL | CSIZE | PARENB | PARODD) -#define ISET_CFLAG (CS8 | CREAD | HUPCL) -#define ICLEAR_LFLAG (ISIG | ICANON | XCASE | ECHO | ECHOE | ECHOK \ - | ECHONL | NOFLSH) -#endif -#if HAVE_POSIX_TERMIOS -#define ICLEAR_IFLAG (BRKINT | ICRNL | IGNBRK | IGNCR | IGNPAR \ - | INLCR | INPCK | ISTRIP | IXOFF | IXON \ - | PARMRK) -#define ICLEAR_OFLAG (OPOST) -#define ICLEAR_CFLAG (CLOCAL | CSIZE | PARENB | PARODD) -#define ISET_CFLAG (CS8 | CREAD | HUPCL) -#define ICLEAR_LFLAG (ECHO | ECHOE | ECHOK | ECHONL | ICANON | IEXTEN \ - | ISIG | NOFLSH | TOSTOP) -#endif - -/* External functions. */ -extern char *strlwr (); -extern int close (), pipe (), dup2 (), read (), write (); -extern int fclose (); -extern void _exit (); -#if USE_SELECT_TIMER || HAVE_BSD_TTY -extern int select (); -#endif -#if HAVE_NAP -extern int nap (); -#endif -#if HAVE_NAPMS -extern int napms (); -#endif -#if HAVE_POLL -extern int poll (); -#endif - -/* Local functions. */ - -static SIGtype usalarm P((int isig)); -static boolean fsserial_lockfile P((boolean flok, const struct sport *, - const char *zdevice)); -static boolean fsserial_lock P((const struct sport *qport, - struct ssysdep_serial_port *q, - boolean fin, const char *zdevice)); -static boolean fsserial_open P((const char *z, long ibaud, boolean fwait, - struct ssysdep_serial_port *q)); -__inline__ static boolean fsblock P((struct ssysdep_serial_port *q, - boolean fblock)); -static boolean fsserial_close P((struct ssysdep_serial_port *q)); -static boolean fsserial_reset P((struct ssysdep_serial_port *q)); -static boolean fsserial_read P((struct ssysdep_serial_port *q, - char *zbuf, int *pclen, int cmin, - int ctimeout, boolean freport, - boolean fpty)); -static boolean fsserial_write P((struct ssysdep_serial_port *q, - const char *zwrite, int cwrite)); -static boolean fsserial_io P((struct ssysdep_serial_port *q, - const char *zwrite, int *pcwrite, - char *zread, int *pcread)); -static boolean fsserial_break P((struct ssysdep_serial_port *q)); -static boolean fsserial_set P((struct ssysdep_serial_port *q, - enum tportsetting tset)); -static boolean fsrun_chat P((int oread, int owrite, const char *zprog)); - -/* This code handles SIGALRM. See the discussion above fsserial_read. - Normally we ignore SIGALRM, but the handler will temporarily be set - to this function, which should set fSalarm and then either longjmp - or schedule another SIGALRM. fSalarm is never referred to outside - of this file, but we don't make it static to try to fool compilers - which don't understand volatile. */ - -volatile sig_atomic_t fSalarm; - -static SIGtype -usalarm (isig) - int isig; -{ -#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && ! HAVE_SIGSET - (void) signal (isig, usalarm); -#endif - - fSalarm = TRUE; - -#if HAVE_RESTARTABLE_SYSCALLS - longjmp (sSjmp_buf, 1); -#else - alarm (1); -#endif -} - -/* We need a simple routine to block SIGINT, SIGQUIT, SIGTERM and - SIGPIPE and another to restore the original state. When these - functions are called (in fsysdep_modem_close) SIGHUP is being - ignored. The routines are isblocksigs, which returns a value of - type HELD_SIG_MASK and usunblocksigs which takes a single argument - of type HELD_SIG_MASK. */ - -#if HAVE_SIGPROCMASK - -/* Use the POSIX sigprocmask call. */ - -extern int sigprocmask (); - -#define HELD_SIG_MASK sigset_t - -static sigset_t isblocksigs P((void)); - -static sigset_t -isblocksigs () -{ - sigset_t sblock, sold; - - sigemptyset (&sblock); - sigaddset (&sblock, SIGINT); - sigaddset (&sblock, SIGQUIT); - sigaddset (&sblock, SIGTERM); - sigaddset (&sblock, SIGPIPE); - sigprocmask (SIG_BLOCK, &sblock, &sold); - return sold; -} - -#define usunblocksigs(s) \ - ((void) sigprocmask (SIG_SETMASK, &(s), (sigset_t *) NULL)) - -#else /* ! HAVE_SIGPROCMASK */ -#if HAVE_SIGBLOCK - -/* Use the BSD sigblock and sigsetmask calls. */ - -extern int sigblock (), sigsetmask (); - -#define HELD_SIG_MASK int - -#ifndef sigmask -#define sigmask(i) (1 << ((i) - 1)) -#endif - -#define isblocksigs() \ - sigblock (sigmask (SIGINT) | sigmask (SIGQUIT) \ - | sigmask (SIGTERM) | sigmask (SIGPIPE)) - -#define usunblocksigs(i) ((void) sigsetmask (i)) - -#else /* ! HAVE_SIGBLOCK */ - -#if HAVE_SIGHOLD - -/* Use the SVR3 sighold and sigrelse calls. */ - -extern int sighold (), sigrelse (); - -#define HELD_SIG_MASK int - -static int isblocksigs P((void)); - -static int -isblocksigs () -{ - sighold (SIGINT); - sighold (SIGQUIT); - sighold (SIGTERM); - sighold (SIGPIPE); - return 0; -} - -static void usunblocksigs P((int)); - -/*ARGSUSED*/ -static void -usunblocksigs (i) - int i; -{ - sigrelse (SIGINT); - sigrelse (SIGQUIT); - sigrelse (SIGTERM); - sigrelse (SIGPIPE); -} - -#else /* ! HAVE_SIGHOLD */ - -/* We have no way to block signals. This system will suffer from a - race condition in fsysdep_modem_close. */ - -#define HELD_SIG_MASK int - -#define isblocksigs() 0 - -#define usunblocksigs(i) - -#endif /* ! HAVE_SIGHOLD */ -#endif /* ! HAVE_SIGBLOCK */ -#endif /* ! HAVE_SIGPROCMASK */ - -/* Pause for half a second. This doesn't really belong in this file, - but all the timing routines are here. */ - -void -usysdep_pause () -{ -#if HAVE_NAPMS - napms (500); -#endif /* HAVE_NAPMS */ -#if HAVE_NAP - nap (500L); -#endif /* HAVE_NAP */ -#if HAVE_USLEEP - usleep (500 * (long) 1000); -#endif /* HAVE_USLEEP */ -#if HAVE_POLL - struct pollfd sdummy; - - /* We need to pass an unused pollfd structure because poll checks - the address before checking the number of elements. */ - poll (&sdummy, 0, 500); -#endif /* HAVE_POLL */ -#if USE_SELECT_TIMER - struct timeval s; - - s.tv_sec = 0; - s.tv_usec = 500 * (long) 1000; - select (0, (int *) NULL, (int *) NULL, (int *) NULL, &s); -#endif /* USE_SELECT_TIMER */ -#if ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP -#if ! USE_SELECT_TIMER && ! HAVE_POLL - sleep (1); -#endif /* ! USE_SELECT_TIMER && ! HAVE_POLL */ -#endif /* ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP */ -} - -/* This routine is used for both locking and unlocking. It is the - only routine which knows how to translate a device name into the - name of a lock file. If it can't figure out a name, it does - nothing and returns TRUE. */ - -static boolean -fsserial_lockfile (flok, qport, zdevice) - boolean flok; - const struct sport *qport; - const char *zdevice; -{ - const char *z; - - z = qport->zlockname; - if (z == NULL) - { - char *zalc; - - z = zdevice; - if (z == NULL) - { - z = qport->zname; - if (z == NULL) - return TRUE; - } - -#if ! HAVE_SVR4_LOCKFILES - if (strncmp (z, "/dev/", sizeof "/dev/" - 1) == 0) - z += sizeof "/dev/" - 1; - zalc = (char *) alloca (strlen (z) + sizeof "LCK.."); - sprintf (zalc, "LCK..%s", z); -#if HAVE_SCO_LOCKFILES - strlwr (zalc + sizeof "LCK.." - 1); -#endif -#else /* HAVE_SVR4_LOCKFILES */ - { - struct stat s; - - if (*z != '/') - { - zalc = (char *) alloca (sizeof "/dev/" + strlen (z)); - sprintf (zalc, "/dev/%s", z); - z = zalc; - } - if (stat (z, &s) != 0) - { - ulog (LOG_ERROR, "stat (%s): %s", z, strerror (errno)); - return FALSE; - } - zalc = (char *) alloca (sizeof "LK.123.123.123"); - sprintf (zalc, "LK.%03d.%03d.%03d", major (s.st_dev), - major (s.st_rdev), minor (s.st_rdev)); - } -#endif /* HAVE_SVR4_LOCKFILES */ - - z = zalc; - } - - if (flok) - return fsdo_lock (z, FALSE); - else - return fsdo_unlock (z, FALSE); -} - -/* If we can mark a modem line in use, then when we lock a port we - must open it and mark it in use. We can't wait until the actual - open because we can't fail out if it is locked then. */ - -static boolean -fsserial_lock (qport, q, fin, zdevice) - const struct sport *qport; - struct ssysdep_serial_port *q; - boolean fin; - const char *zdevice; -{ - if (! fsserial_lockfile (TRUE, qport, zdevice)) - return FALSE; - -#if HAVE_TIOCSINUSE || HAVE_TIOCEXCL - /* Open the line and, if possible, mark it in use. */ - { - const char *z; - int oread, iflag; - - z = zdevice; - if (z == NULL) - { - z = qport->zname; - if (z == NULL) - return TRUE; - } - - if (fin) - iflag = 0; - else - iflag = FILE_UNBLOCKED; - - if (*z != '/') - { - char *zcopy; - - zcopy = (char *) alloca (sizeof "/dev/" + strlen (z)); - sprintf (zcopy, "/dev/%s", z); - z = zcopy; - } - - oread = open (z, O_RDWR | iflag); - if (oread < 0) - { - if (errno != EBUSY) - ulog (LOG_ERROR, "open (%s): %s", z, strerror (errno)); - (void) fsserial_lockfile (FALSE, qport, zdevice); - return FALSE; - } - -#if HAVE_TIOCSINUSE - /* If we can't mark it in use, return FALSE to indicate that the - lock failed. */ - if (ioctl (oread, TIOCSINUSE, 0) < 0) - { - if (errno != EALREADY) - ulog (LOG_ERROR, "ioctl (TIOCSINUSE): %s", strerror (errno)); - (void) close (oread); - (void) fsserial_lockfile (FALSE, qport, zdevice); - return FALSE; - } -#endif - -#ifdef TIOCSCTTY - /* On BSD 4.4, make it our controlling terminal. */ - (void) ioctl (oread, TIOCSCTTY, 0); -#endif - - q->oread = q->owrite = oread; - } -#endif /* HAVE_TIOCSINUSE || HAVE_TIOCEXCL */ - - return TRUE; -} - -/* We don't need to lock a stdin port. */ - -/*ARGSUSED*/ -boolean -fsysdep_stdin_lock (qport, fin) - struct sport *qport; - boolean fin; -{ - return TRUE; -} - -/* Lock a modem port. */ - -boolean -fsysdep_modem_lock (qport, fin) - struct sport *qport; - boolean fin; -{ - return fsserial_lock (qport, &qport->u.smodem.s.s, fin, - qport->u.smodem.zdevice); -} - -/* Lock a direct port. */ - -boolean -fsysdep_direct_lock (qport, fin) - struct sport *qport; - boolean fin; -{ - return fsserial_lock (qport, &qport->u.sdirect.s.s, fin, - qport->u.sdirect.zdevice); -} - -/* Open a serial line. This sets the terminal settings. We begin in - seven bit mode and let the protocol change if necessary. */ - -static struct sbaud_table -{ -#if HAVE_POSIX_TERMIOS - speed_t icode; -#else - int icode; -#endif - long ibaud; -} asSbaud_table[] = -{ - { B50, 50 }, - { B75, 75 }, - { B110, 110 }, - { B134, 134 }, - { B150, 150 }, - { B200, 200 }, - { B300, 300 }, - { B600, 600 }, - { B1200, 1200 }, - { B1800, 1800 }, - { B2400, 2400 }, - { B4800, 4800 }, - { B9600, 9600 }, -#ifdef B19200 - { B19200, 19200 }, -#else /* ! defined (B19200) */ -#ifdef EXTA - { EXTA, 19200 }, -#endif /* EXTA */ -#endif /* ! defined (B19200) */ -#ifdef B38400 - { B38400, 38400 } -#else /* ! defined (B38400) */ -#ifdef EXTB - { EXTB, 38400 } -#endif /* EXTB */ -#endif /* ! defined (B38400) */ -}; - -#define CBAUD_TABLE (sizeof asSbaud_table / sizeof asSbaud_table[0]) - -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS -/* Hold the MIN value for the terminal to avoid setting it - unnecessarily. */ -static int cSmin; -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - -static boolean -fsserial_open (z, ibaud, fwait, q) - const char *z; - long ibaud; - boolean fwait; - struct ssysdep_serial_port *q; -{ -#if HAVE_POSIX_TERMIOS - speed_t ib; -#else - int ib; -#endif - - if (z == NULL) - { - const char *zport; - boolean fdummy; - - zport = zsysdep_port_name (&fdummy); - if (zport != NULL) - ulog_device (zport); - } - else - { - if (strncmp (z, "/dev/", sizeof "/dev/" - 1) == 0) - ulog_device (z + sizeof "/dev/" - 1); - else - ulog_device (z); - } - - ib = B0; - - if (ibaud != 0) - { - int i; - - for (i = 0; i < CBAUD_TABLE; i++) - if (asSbaud_table[i].ibaud == ibaud) - break; - if (i >= CBAUD_TABLE) - { - ulog (LOG_ERROR, "Unsupported baud rate %ld", ibaud); - if (q->oread != -1) - { - (void) close (q->oread); - if (q->oread != q->owrite) - (void) close (q->owrite); - } - return FALSE; - } - ib = asSbaud_table[i].icode; - } - - /* The port may have already been opened by the locking routine. */ - if (q->oread == -1) - { - int oread, owrite; - - if (z == NULL) - { - oread = 0; - owrite = 1; - } - else - { - int iflag; - - if (fwait) - iflag = 0; - else - iflag = FILE_UNBLOCKED; - - if (*z != '/') - { - char *zcopy; - - zcopy = (char *) alloca (sizeof "/dev/" + strlen (z)); - sprintf (zcopy, "/dev/%s", z); - z = zcopy; - } - - oread = open (z, O_RDWR | iflag); - if (oread < 0) - { - ulog (LOG_ERROR, "open (%s): %s", z, strerror (errno)); - return FALSE; - } - -#ifdef TIOCSCTTY - /* On BSD 4.4, make it our controlling terminal. */ - (void) ioctl (oread, TIOCSCTTY, 0); -#endif - - owrite = oread; - } - - q->oread = oread; - q->owrite = owrite; - } - - /* Make sure the ports are blocking. */ - - if (fcntl (q->oread, F_SETFL, 0) < 0 - || (q->oread != q->owrite - && fcntl (q->owrite, F_SETFL, 0) < 0)) - { - ulog (LOG_ERROR, "fcntl: %s", strerror (errno)); - (void) close (q->oread); - if (q->oread != q->owrite) - (void) close (q->owrite); - return FALSE; - } - - q->fread_blocking = TRUE; - - if (! fgetterminfo (q->oread, &q->sorig)) - { - q->fterminal = FALSE; - return TRUE; - } - - q->fterminal = TRUE; - - q->snew = q->sorig; - -#if HAVE_BSD_TTY - - q->snew.sg_flags = RAW | ANYP; - if (ibaud == 0) - ib = q->snew.sg_ospeed; - else - { - q->snew.sg_ispeed = ib; - q->snew.sg_ospeed = ib; - } - -#ifdef TIOCHPCL - /* When the file is closed, hang up the line. This is a safety - measure in case the program crashes. */ - (void) ioctl (q->oread, TIOCHPCL, 0); -#endif - -#ifdef TIOCFLUSH - { - int iparam; - - /* Flush pending input. */ -#ifdef FREAD - iparam = FREAD; -#else - iparam = 0; -#endif - (void) ioctl (q->oread, TIOCFLUSH, &iparam); - } -#endif /* TIOCFLUSH */ - -#endif /* HAVE_BSD_TTY */ - -#if HAVE_SYSV_TERMIO - - if (ibaud == 0) - ib = q->snew.c_cflag & CBAUD; - - q->snew.c_iflag &=~ ICLEAR_IFLAG; - q->snew.c_oflag &=~ ICLEAR_OFLAG; - q->snew.c_cflag &=~ ICLEAR_CFLAG; - q->snew.c_cflag |= (ib | ISET_CFLAG); - q->snew.c_lflag &=~ ICLEAR_LFLAG; - cSmin = 6; - q->snew.c_cc[VMIN] = cSmin; - q->snew.c_cc[VTIME] = 0; - -#ifdef TCFLSH - /* Flush pending input. */ - (void) ioctl (q->oread, TCFLSH, 0); -#endif - -#endif /* HAVE_SYSV_TERMIO */ - -#if HAVE_POSIX_TERMIOS - - if (ibaud == 0) - ib = cfgetospeed (&q->snew); - - q->snew.c_iflag &=~ ICLEAR_IFLAG; - q->snew.c_oflag &=~ ICLEAR_OFLAG; - q->snew.c_cflag &=~ ICLEAR_CFLAG; - q->snew.c_cflag |= ISET_CFLAG; - q->snew.c_lflag &=~ ICLEAR_LFLAG; - cSmin = 6; - q->snew.c_cc[VMIN] = cSmin; - q->snew.c_cc[VTIME] = 0; - - (void) cfsetospeed (&q->snew, ib); - (void) cfsetispeed (&q->snew, ib); - - /* Flush pending input. */ - (void) tcflush (q->oread, TCIFLUSH); - -#endif /* HAVE_POSIX_TERMIOS */ - - if (! fsetterminfo (q->oread, &q->snew)) - { - ulog (LOG_ERROR, "Can't set terminal settings: %s", strerror (errno)); - (void) close (q->oread); - if (q->oread != q->owrite) - (void) close (q->owrite); - return FALSE; - } - - if (ibaud != 0) - q->ibaud = ibaud; - else - { - int i; - - q->ibaud = 1200; - for (i = 0; i < CBAUD_TABLE; i++) - { - if (asSbaud_table[i].icode == ib) - { - q->ibaud = asSbaud_table[i].ibaud; - break; - } - } - - DEBUG_MESSAGE1 (DEBUG_PORT, - "fsserial_open: Baud rate is %ld", q->ibaud); - } - - return TRUE; -} - -/* Open a stdin port. */ - -boolean -fsysdep_stdin_open (qport, ibaud, fwait) - struct sport *qport; - long ibaud; - boolean fwait; -{ - return fsserial_open ((const char *) NULL, ibaud, fwait, - &qport->u.sstdin.s.s); -} - -/* Open a modem port. */ - -boolean -fsysdep_modem_open (qport, ibaud, fwait) - struct sport *qport; - long ibaud; - boolean fwait; -{ - const char *z; - boolean fret; - - z = qport->u.smodem.zdevice; - if (z == NULL) - { - z = qport->zname; - if (z == NULL) - { - ulog (LOG_ERROR, "Port has no name or device"); - return FALSE; - } - } - if (ibaud == 0) - ibaud = qport->u.smodem.ibaud; - fret = fsserial_open (z, ibaud, fwait, &qport->u.smodem.s.s); - if (! fret) - (void) fsserial_lockfile (FALSE, qport, qport->u.smodem.zdevice); - return fret; -} - -/* Open a direct port. */ - -boolean -fsysdep_direct_open (qport, ibaud, fwait) - struct sport *qport; - long ibaud; - boolean fwait; -{ - const char *z; - boolean fret; - - z = qport->u.sdirect.zdevice; - if (z == NULL) - { - z = qport->zname; - if (z == NULL) - { - ulog (LOG_ERROR, "Port has no name or device"); - return FALSE; - } - } - if (ibaud == 0) - ibaud = qport->u.sdirect.ibaud; - fret = fsserial_open (z, ibaud, fwait, &qport->u.sdirect.s.s); - if (! fret) - (void) fsserial_lockfile (FALSE, qport, qport->u.sdirect.zdevice); - return fret; -} - -/* Change the blocking status of the port. We keep track of the - current blocking status to avoid calling fcntl unnecessarily; fcntl - turns out to be surprisingly expensive, at least on Ultrix. We - used to keep track of the blocking status of the read port and the - write port independently. Unfortunately, this is nonportable, - because on BSD, and probably some other systems, unblocking a - terminal applies to all descriptors to that terminal. Now, if - oread != owrite, we set both. */ - -__inline__ -static boolean -fsblock (qs, fblock) - struct ssysdep_serial_port *qs; - boolean fblock; -{ - if (fblock ? ! qs->fread_blocking : qs->fread_blocking) - { - int iset; - - if (fblock) - iset = 0; - else - iset = FILE_UNBLOCKED; - if (fcntl (qs->oread, F_SETFL, iset) < 0 - || (qs->oread != qs->owrite - && fcntl (qs->owrite, F_SETFL, iset) < 0)) - { - ulog (LOG_ERROR, "fcntl: %s", strerror (errno)); - return FALSE; - } - qs->fread_blocking = fblock; - } - return TRUE; -} - -/* Close a serial port. */ - -static boolean -fsserial_close (q) - struct ssysdep_serial_port *q; -{ - if (q->oread >= 0) - { - /* Use a 30 second timeout to avoid hanging while draining - output. */ - if (q->fterminal) - { - fSalarm = FALSE; - - if (fsysdep_catch ()) - { - usysdep_start_catch (); - usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); - (void) alarm (30); - - (void) fsetterminfodrain (q->oread, &q->sorig); - } - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - (void) alarm (0); - usysdep_end_catch (); - - /* If we timed out, use the non draining call. Hopefully - this can't hang. */ - if (fSalarm) - (void) fsetterminfo (q->oread, &q->sorig); - } - - (void) close (q->oread); - if (q->oread != q->owrite) - (void) close (q->owrite); - q->oread = q->owrite = -1; - - /* Sleep for a second to give the terminal a chance to settle, - in case we are about to call out again. */ - sleep (1); - } - - return TRUE; -} - -/* Close a stdin port. */ - -/*ARGSUSED*/ -boolean -fsysdep_stdin_close (qport, fsuccess) - struct sport *qport; - boolean fsuccess; -{ - return fsserial_close (&qport->u.sstdin.s.s); -} - -/* Close a modem port. */ - -boolean -fsysdep_modem_close (qport, fsuccess) - struct sport *qport; - boolean fsuccess; -{ - boolean fret; - struct sdialer *qdial; - struct sdialer sdial; - - fret = TRUE; - qdial = NULL; - - /* We're no longer interested in carrier. */ - (void) fsysdep_modem_no_carrier (qport); - - if (qport->u.smodem.zdialer != NULL) - { - char *zcopy; - - zcopy = (char *) alloca (strlen (qport->u.smodem.zdialer) + 1); - strcpy (zcopy, qport->u.smodem.zdialer); - zcopy[strcspn (zcopy, " \t")] = '\0'; - if (! fread_dialer_info (zcopy, &sdial)) - fret = FALSE; - else - qdial = &sdial; - } - else - qdial = qport->u.smodem.qdialer; - - if (qdial != NULL) - { - boolean fsighup_ignored; - HELD_SIG_MASK smask; - int i; - sig_atomic_t afhold[INDEXSIG_COUNT]; - const struct schat_info *qchat; - - /* The port I/O routines check whether any signal has been - received, and abort if one has. While we are closing down - the modem, we don't care if we received a signal in the past, - but we do care if we receive a new signal (otherwise it would - be difficult to kill a uucico which was closing down a - modem). We never care if we get SIGHUP at this point. So we - turn off SIGHUP, remember what signals we've already seen, - and clear our notion of what signals we've seen. We have to - block the signals while we remember and clear the array, - since we might otherwise miss a signal which occurred between - the copy and the clear (old systems can't block signals; they - will just have to suffer the race). */ - - usset_signal (SIGHUP, SIG_IGN, FALSE, &fsighup_ignored); - smask = isblocksigs (); - for (i = 0; i < INDEXSIG_COUNT; i++) - { - afhold[i] = afSignal[i]; - afSignal[i] = FALSE; - } - usunblocksigs (smask); - - if (fsuccess) - qchat = &qdial->scomplete; - else - qchat = &qdial->sabort; - if (! fchat (qchat, (const struct ssysteminfo *) NULL, - (const struct sdialer *) NULL, (const char *) NULL, - FALSE, qport->zname, qport->u.smodem.s.s.ibaud)) - fret = FALSE; - - /* Restore the old signal array and the SIGHUP handler. It is - not necessary to block signals here, since all we are doing - is exactly what the signal handler itself would do if the - signal occurred. */ - for (i = 0; i < INDEXSIG_COUNT; i++) - if (afhold[i]) - afSignal[i] = TRUE; - if (! fsighup_ignored) - usset_signal (SIGHUP, ussignal, TRUE, (boolean *) NULL); - } - - if (! fsserial_close (&qport->u.smodem.s.s)) - fret = FALSE; - - if (! fsserial_lockfile (FALSE, qport, qport->u.smodem.zdevice)) - fret = FALSE; - - return fret; -} - -/* Close a direct port. */ - -/*ARGSUSED*/ -boolean -fsysdep_direct_close (qport, fsuccess) - struct sport *qport; - boolean fsuccess; -{ - boolean fret; - - fret = fsserial_close (&qport->u.sdirect.s.s); - - if (! fsserial_lockfile (FALSE, qport, qport->u.sdirect.zdevice)) - fret = FALSE; - - return fret; -} - -/* Reset a serial port by hanging up. */ - -#if ! HAVE_POSIX_TERMIOS - -static boolean -fsserial_reset (q) - struct ssysdep_serial_port *q; -{ - sterminal sbaud; - - if (! q->fterminal) - return TRUE; - - sbaud = q->snew; - -#if HAVE_BSD_TTY - sbaud.sg_ispeed = B0; - sbaud.sg_ospeed = B0; -#else /* ! HAVE_BSD_TTY */ - sbaud.c_cflag = (sbaud.c_cflag &~ CBAUD) | B0; -#endif /* ! HAVE_BSD_TTY */ - - if (! fsetterminfodrain (q->oread, &sbaud)) - ulog (LOG_FATAL, "Can't hangup terminal: %s", strerror (errno)); - - /* Give the terminal a chance to settle. */ - sleep (1); - - if (! fsetterminfo (q->oread, &q->snew)) - ulog (LOG_FATAL, "Can't reopen terminal: %s", strerror (errno)); - - return TRUE; -} - -#else /* HAVE_POSIX_TERMIOS */ - -static boolean -fsserial_reset (q) - struct ssysdep_serial_port *q; -{ - sterminal sbaud; - speed_t iin, iout; - - if (! q->fterminal) - return TRUE; - - iin = cfgetispeed (&q->snew); - iout = cfgetospeed (&q->snew); - - sbaud = q->snew; - - if (cfsetospeed (&sbaud, B0) != 0 - || ! fsetterminfodrain (q->oread, &sbaud)) - ulog (LOG_FATAL, "Can't hangup terminal: %s", strerror (errno)); - - /* Give the terminal a chance to settle. */ - sleep (1); - - if (cfsetispeed (&q->snew, iin) != 0 - || cfsetospeed (&q->snew, iout) != 0 - || ! fsetterminfo (q->oread, &q->snew)) - ulog (LOG_FATAL, "Can't reopen terminal: %s", strerror (errno)); - - return TRUE; -} - -#endif /* HAVE_POSIX_TERMIOS */ - -/* Reset a stdin port. */ - -boolean -fsysdep_stdin_reset (qport) - struct sport *qport; -{ - return fsserial_reset (&qport->u.sstdin.s.s); -} - -/* Reset a modem port. */ - -boolean -fsysdep_modem_reset (qport) - struct sport *qport; -{ - return fsserial_reset (&qport->u.smodem.s.s); -} - -/* Reset a direct port. */ - -boolean -fsysdep_direct_reset (qport) - struct sport *qport; -{ - return fsserial_reset (&qport->u.sdirect.s.s); -} - -/* Begin dialing out on a modem port. This opens the dialer device if - there is one. */ - -boolean -fsysdep_modem_begin_dial (qport, qdial) - struct sport *qport; - struct sdialer *qdial; -{ -#ifdef TIOCMODEM - /* If we can tell the modem to obey modem control, do so. */ - { - int iperm; - - iperm = 0; - (void) ioctl (qport->u.smodem.s.s.oread, TIOCMODEM, &iperm); - } -#endif /* TIOCMODEM */ - -#ifdef TIOCCDTR - /* If we supposed to toggle DTR, do so. */ - - if (qdial->fdtr_toggle) - { - (void) ioctl (qport->u.smodem.s.s.oread, TIOCCDTR, 0); - (void) ioctl (qport->u.smodem.s.s.oread, TIOCSDTR, 0); - - if (qdial->fdtr_toggle_wait) - sleep (1); - } -#endif /* TIOCCDTR */ - - if (! fsysdep_modem_no_carrier (qport)) - return FALSE; - - /* Open the dial device if there is one. */ - if (qport->u.smodem.zdial_device != NULL) - { - const char *z; - int oread; - - qport->u.smodem.s.s.oholdread = qport->u.smodem.s.s.oread; - qport->u.smodem.s.s.oholdwrite = qport->u.smodem.s.s.owrite; - - z = qport->u.smodem.zdial_device; - if (*z != '/') - { - char *zcopy; - - zcopy = (char *) alloca (sizeof "/dev/" + strlen (z)); - sprintf (zcopy, "/dev/%s", z); - z = zcopy; - } - - oread = open (z, O_RDWR); - if (oread < 0) - { - ulog (LOG_ERROR, "open (%s): %s", z, strerror (errno)); - return FALSE; - } - - qport->u.smodem.s.s.oread = qport->u.smodem.s.s.owrite = oread; - } - - return TRUE; -} - -/* Tell the port to not require carrier. I don't know how to do this - on a BSD system that doesn't support TIOCNCAR, if there are any - such systems. */ - -boolean -fsysdep_modem_no_carrier (qport) - struct sport *qport; -{ - if (! qport->u.smodem.s.s.fterminal) - return TRUE; - -#ifdef TIOCNCAR - /* Tell the modem to ignore carrier. */ - if (ioctl (qport->u.smodem.s.s.oread, TIOCNCAR, 0) < 0) - { - ulog (LOG_ERROR, "ioctl (TIOCNCAR): %s", strerror (errno)); - return FALSE; - } -#endif /* TIOCNCAR */ - -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS - /* Put the modem into local mode (ignore carrier) to start the chat - script. */ - qport->u.smodem.s.s.snew.c_cflag |= CLOCAL; - if (! fsetterminfo (qport->u.smodem.s.s.oread, - &qport->u.smodem.s.s.snew)) - { - ulog (LOG_ERROR, "Can't set CLOCAL: %s", strerror (errno)); - return FALSE; - } -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - - return TRUE; -} - -/* Tell the port to require carrier. If the port does not support - carrier, we do nothing. We do not need to worry whether the - dialer supports carrier, since this will only be called when - explicitly requested by a dialer chat script. */ - -boolean -fsysdep_modem_need_carrier (qport) - struct sport *qport; -{ - if (! qport->u.smodem.s.s.fterminal) - return TRUE; - - if (qport->u.smodem.fcarrier) - { -#ifdef TIOCCAR - /* Tell the modem to pay attention to carrier. */ - if (ioctl (qport->u.smodem.s.s.oread, TIOCCAR, 0) < 0) - { - ulog (LOG_ERROR, "ioctl (TIOCCAR): %s", strerror (errno)); - return FALSE; - } -#endif /* TIOCCAR */ - -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS - /* Put the modem into nonlocal mode. */ - qport->u.smodem.s.s.snew.c_cflag &=~ CLOCAL; - if (! fsetterminfo (qport->u.smodem.s.s.oread, - &qport->u.smodem.s.s.snew)) - { - ulog (LOG_ERROR, "Can't clear CLOCAL: %s", strerror (errno)); - return FALSE; - } -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - } - - return TRUE; -} - -/* Finish dialing out on a modem by closing any dialer device and waiting - for carrier. */ - -boolean -fsysdep_modem_end_dial (qport, qdial) - struct sport *qport; - struct sdialer *qdial; -{ - if (qport->u.smodem.zdial_device != NULL) - { - (void) close (qport->u.smodem.s.s.oread); - qport->u.smodem.s.s.oread = qport->u.smodem.s.s.oholdread; - qport->u.smodem.s.s.owrite = qport->u.smodem.s.s.oholdwrite; - } - - if (qport->u.smodem.fcarrier && qdial->fcarrier) - { - /* Tell the port that we need carrier. */ - - if (! fsysdep_modem_need_carrier (qport)) - return FALSE; - -#ifdef TIOCWONLINE - - /* We know how to wait for carrier, so do so. */ - - /* If we already got a signal, just quit now. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - - /* This bit of code handles signals just like fsserial_read - does. See that function for a longer explanation. */ - - /* Use fsysdep_catch to handle a longjmp from the signal - handler. */ - - fSalarm = FALSE; - - if (fsysdep_catch ()) - { - /* Start catching SIGALRM; normally we ignore it. */ - usysdep_start_catch (); - usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); - (void) alarm (qdial->ccarrier_wait); - - /* We really don't care if we get an error, since that will - probably just mean that TIOCWONLINE isn't supported in - which case there's nothing we can do anyhow. If we get - SIGINT we want to keep waiting for carrier, because - SIGINT just means don't start any new sessions. We don't - handle SIGINT correctly if we do a longjmp in the signal - handler; too bad. */ - while (ioctl (qport->u.smodem.s.s.oread, TIOCWONLINE, 0) < 0 - && errno == EINTR) - { - /* Log the signal. */ - ulog (LOG_ERROR, (const char *) NULL); - if (FGOT_QUIT_SIGNAL () || fSalarm) - break; - } - } - - /* Turn off the pending SIGALRM and ignore SIGALARM again. */ - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - (void) alarm (0); - usysdep_end_catch (); - - /* If we got a random signal, just return FALSE. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - - /* If we timed out, give an error. */ - if (fSalarm) - { - ulog (LOG_ERROR, "Timed out waiting for carrier"); - return FALSE; - } - -#endif /* TIOCWONLINE */ - } - - return TRUE; -} - -/* Read data from a serial port, with a timeout. - - This function should return when we have read cmin characters or - the timeout has occurred. We have to work a bit to get UNIX to do - this efficiently. The simple implementation schedules a SIGALRM - signal and then calls read; if there is a single character - available, the call to read will return immediately, so there must - be a loop which terminates when the SIGALRM is delivered or the - correct number of characters has been read. This can be very - inefficient with a fast CPU or a low baud rate (or both!), since - each call to read may return only one or two characters. - - Under POSIX or System V, we can specify a minimum number of - characters to read, so there is no serious trouble. - - Under BSD, we figure out how many characters we have left to read, - how long it will take for them to arrive at the current baud rate, - and sleep that long. - - Doing this with a timeout and avoiding all possible race conditions - get very hairy, though. Basically, we're going to schedule a - SIGALRM for when the timeout expires. I don't really want to do a - longjmp in the SIGALRM handler, though, because that may lose data. - Therefore, I have the signal handler set a variable. However, this - means that there will be a span of time between the time the code - checks the variable and the time it calls the read system call; if - the SIGALRM occurs during that time, the read might hang forever. - To avoid this, the SIGALRM handler not only sets a global variable, - it also schedules another SIGALRM for one second in the future - (POSIX specifies that a signal handler is permitted to safely call - alarm). To avoid getting a continual sequence of SIGALRM - interrupts, we change the signal handler to ignore SIGALRM when - we're about to exit the function. This means that every time we - execute fsserial_read we make at least five system calls. It's the - best I've been able to come up with, though. - - When fsserial_read finishes, there will be no SIGALRM scheduled and - SIGALRM will be ignored. */ - -static boolean -fsserial_read (q, zbuf, pclen, cmin, ctimeout, freport, fpty) - struct ssysdep_serial_port *q; - char *zbuf; - int *pclen; - int cmin; - int ctimeout; - boolean freport; - boolean fpty; -{ - CATCH_PROTECT int cwant; - boolean fret; - - cwant = *pclen; - *pclen = 0; - - /* Guard against a bad timeout. We return TRUE when a timeout - expires. It is possible to get a negative timeout here because - the calling code does not check user supplied timeouts for - plausibility. */ - if (ctimeout <= 0) - return TRUE; - - /* We want to do a blocking read. */ - if (! fsblock (q, TRUE)) - return FALSE; - - fSalarm = FALSE; - - /* We're going to set up an alarm signal to last for the entire - read. If the read system call cannot be interrupted, the signal - handler will do a longjmp causing fsysdep_catch (a macro) to - return FALSE. We handle that here. If read can be interrupted, - fsysdep_catch will be defined to TRUE. */ - - if (fsysdep_catch ()) - { - /* Prepare to catch SIGALRM and schedule the signal. */ - usysdep_start_catch (); - usset_signal (SIGALRM, usalarm, TRUE, (boolean *) NULL); - alarm (ctimeout); - } - else - { - /* We caught a signal. We don't actually have to do anything, - as all the appropriate checks are made at the start of the - following loop. */ - } - - fret = FALSE; - - while (TRUE) - { - int cgot; - -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS - /* If we can tell the terminal not to return until we have a - certain number of characters, do so. */ - if (q->fterminal) - { - int csetmin; - - /* I'm not that confident about setting MIN to values larger - than 127, although up to 255 would probably work. */ - if (cmin < 127) - csetmin = cmin; - else - csetmin = 127; - - if (csetmin != cSmin) - { - q->snew.c_cc[VMIN] = csetmin; - if (! fsetterminfo (q->oread, &q->snew)) - { - int ierr; - - /* We turn off the signal before reporting the error - to minimize any problems with interrupted system - calls. */ - ierr = errno; - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - usysdep_end_catch (); - ulog (LOG_ERROR, "Can't set MIN for terminal: %s", - strerror (ierr)); - return FALSE; - } - cSmin = csetmin; - } - } -#endif /* HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS */ - - /* If we've received a signal, get out now. */ - if (FGOT_QUIT_SIGNAL ()) - break; - - /* If we've already gotten a SIGALRM, get out with whatever - we've accumulated. */ - - if (fSalarm) - { - fret = TRUE; - break; - } - - /* Right here is the race condition which we avoid by having the - SIGALRM handler schedule another SIGALRM. */ - - cgot = read (q->oread, zbuf, cwant); - - /* If the read returned an error, check for signals. */ - if (cgot < 0) - { - if (errno == EINTR) - { - /* Log the signal. */ - ulog (LOG_ERROR, (const char *) NULL); - } - if (fSalarm) - { - fret = TRUE; - break; - } - if (FGOT_QUIT_SIGNAL ()) - break; - } - - /* If read returned an error, get out. We just ignore EINTR - here, since it must be from some signal we don't care about. - If the read returned 0 then the line must have been hung up - (normally we would have received SIGHUP, but we can't count - on that). We turn off the signals before calling ulog to - reduce problems with interrupted system calls. */ - if (cgot <= 0) - { - if (cgot < 0 && errno == EINTR) - cgot = 0; - else - { - int ierr; - - ierr = errno; - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - usysdep_end_catch (); - - if (freport) - { - if (cgot == 0) - ulog (LOG_ERROR, "Line disconnected"); - else - ulog (LOG_ERROR, "read: %s", strerror (ierr)); - } - - return FALSE; - } - } - - cwant -= cgot; - cmin -= cgot; - zbuf += cgot; - *pclen += cgot; - - /* If we have enough data, get out now. */ - - if (cmin <= 0) - { - fret = TRUE; - break; - } - -#if HAVE_BSD_TTY - /* We still want more data, so sleep long enough for the rest of - it to arrive. We don't this for System V or POSIX because - setting MIN is good enough (we can't sleep longer than it - takes to get MAX_INPUT characters anyhow). - - The baud rate is approximately 10 times the number of - characters which will arrive in one second, so the number of - milliseconds to sleep == - characters * (milliseconds / character) == - characters * (1000 * (seconds / character)) == - characters * (1000 * (1 / (baud / 10))) == - characters * (10000 / baud) - - We arbitrarily reduce the sleep amount by 10 milliseconds to - attempt to account for the amount of time it takes to set up - the sleep. This is how long it takes to get half a character - at 19200 baud. We then don't bother to sleep for less than - 10 milliseconds. We don't sleep if the read was interrupted. - - We use select to sleep. It would be easy to use poll as - well, but it's unlikely that any system with BSD ttys would - have poll but not select. Using select avoids hassles with - the pending SIGALRM; if it hits the select will be - interrupted, and otherwise the select will not affect it. */ - -#if ! HAVE_SELECT - #error This code requires select; feel free to extend it -#endif - - if (q->fterminal && ! fpty && cmin > 1 && cgot > 0) - { - int csleepchars; - int isleep; - - /* We don't try to read all the way up to MAX_INPUT, - since that might drop a character. */ - - if (cmin <= MAX_INPUT - 10) - csleepchars = cmin; - else - csleepchars = MAX_INPUT - 10; - - isleep = (int) (((long) csleepchars * 10000L) / q->ibaud); - isleep -= 10; - - if (isleep > 10) - { - struct timeval s; - - s.tv_sec = isleep / 1000; - s.tv_usec = (isleep % 1000) * 1000; - - /* Some versions of select take a pointer to an int, - while some take a pointer to an fd_set. I just cast - the arguments to a generic pointer, and assume that - any machine which distinguishes int * from fd_set * - (I would be amazed if there are any such machines) - have an appropriate prototype somewhere or other. */ - (void) select (0, (pointer) NULL, (pointer) NULL, - (pointer) NULL, &s); - - /* Here either the select finished sleeping or we got a - SIGALRM. If the latter occurred, fSalarm was set to - TRUE; it will be checked at the top of the loop. */ - } - } -#endif /* HAVE_BSD_TTY */ - } - - /* Turn off the pending SIGALRM and return. */ - - usset_signal (SIGALRM, SIG_IGN, TRUE, (boolean *) NULL); - alarm (0); - usysdep_end_catch (); - - return fret; -} - -/* Read from a stdin port. */ - -boolean -fsysdep_stdin_read (qport, zbuf, pclen, cmin, ctimeout, freport) - struct sport *qport; - char *zbuf; - int *pclen; - int cmin; - int ctimeout; - boolean freport; -{ - return fsserial_read (&qport->u.sstdin.s.s, zbuf, pclen, cmin, ctimeout, - freport, qport->u.sstdin.s.fpty); -} - -/* Read from a modem port. */ - -boolean -fsysdep_modem_read (qport, zbuf, pclen, cmin, ctimeout, freport) - struct sport *qport; - char *zbuf; - int *pclen; - int cmin; - int ctimeout; - boolean freport; -{ - return fsserial_read (&qport->u.smodem.s.s, zbuf, pclen, cmin, ctimeout, - freport, FALSE); -} - -/* Read from a direct port. */ - -boolean -fsysdep_direct_read (qport, zbuf, pclen, cmin, ctimeout, freport) - struct sport *qport; - char *zbuf; - int *pclen; - int cmin; - int ctimeout; - boolean freport; -{ - return fsserial_read (&qport->u.sdirect.s.s, zbuf, pclen, cmin, ctimeout, - freport, FALSE); -} - -/* Write data to a serial port. */ - -static boolean -fsserial_write (q, zwrite, cwrite) - struct ssysdep_serial_port *q; - const char *zwrite; - int cwrite; -{ - int czero; - - /* We want blocking writes here. */ - if (! fsblock (q, TRUE)) - return FALSE; - - czero = 0; - - while (cwrite > 0) - { - int cdid; - - /* If we've received a signal, don't continue. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - - /* Loop until we don't get an interrupt. */ - while ((cdid = write (q->owrite, zwrite, cwrite)) < 0 - && errno == EINTR) - { - /* Log the signal. */ - ulog (LOG_ERROR, (const char *) NULL); - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - } - - if (cdid < 0) - { - if (errno != EWOULDBLOCK && errno != EAGAIN) - { - ulog (LOG_ERROR, "write: %s", strerror (errno)); - return FALSE; - } - cdid = 0; - } - - if (cdid == 0) - { - /* On some systems write will return 0 if carrier is lost. - If we fail to write anything ten times in a row, we - assume that this has happened. This is hacked in like - this because there seems to be no reliable way to tell - exactly why the write returned 0. */ - ++czero; - if (czero >= 10) - { - ulog (LOG_ERROR, "Line disconnected"); - return FALSE; - } - } - else - { - czero = 0; - - cwrite -= cdid; - zwrite += cdid; - } - } - - return TRUE; -} - -/* Write to a stdin port. */ - -boolean -fsysdep_stdin_write (qport, zwrite, cwrite) - struct sport *qport; - const char *zwrite; - int cwrite; -{ - return fsserial_write (&qport->u.sstdin.s.s, zwrite, cwrite); -} - -/* Write to a modem port. */ - -boolean -fsysdep_modem_write (qport, zwrite, cwrite) - struct sport *qport; - const char *zwrite; - int cwrite; -{ - return fsserial_write (&qport->u.smodem.s.s, zwrite, cwrite); -} - -/* Write to a direct port. */ - -boolean -fsysdep_direct_write (qport, zwrite, cwrite) - struct sport *qport; - const char *zwrite; - int cwrite; -{ - return fsserial_write (&qport->u.sdirect.s.s, zwrite, cwrite); -} - -/* The fsysdep_io routine is supposed to both read and write data - until it has either filled its read buffer or written out all the - data it was given. This lets us write out large packets without - losing incoming data. */ - -static boolean -fsserial_io (q, zwrite, pcwrite, zread, pcread) - struct ssysdep_serial_port *q; - const char *zwrite; - int *pcwrite; - char *zread; - int *pcread; -{ - int cwrite, cread, czero; - - cwrite = *pcwrite; - *pcwrite = 0; - cread = *pcread; - *pcread = 0; - - czero = 0; - - while (TRUE) - { - int cgot, cdo, cdid; - - /* If we've received a signal, don't continue. */ - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - - /* This used to always use nonblocking writes, but it turns out - that some systems don't support them on terminals. - - The current algorithm is: - loop: - unblocked read - if read buffer full, return - if nothing to write, return - if HAVE_UNBLOCKED_WRITES - write all data - else - write up to SINGLE_WRITE bytes - if all data written, return - if no data written - blocked write of up to SINGLE_WRITE bytes - - This algorithm should work whether the system supports - unblocked writes on terminals or not. If the system supports - unblocked writes but HAVE_UNBLOCKED_WRITES is 0, then it will - call write more often than it needs to. If the system does - not support unblocked writes but HAVE_UNBLOCKED_WRITES is 1, - then the write may hang so long that incoming data is lost. - This is actually possible at high baud rates on any system - when a blocking write is done; there is no solution, except - hardware handshaking. */ - - /* Do an unblocked read. */ - - if (! fsblock (q, FALSE)) - return FALSE; - - /* Loop until we get something (error or data) other than an - acceptable EINTR. */ - while ((cgot = read (q->oread, zread, cread)) < 0 - && errno == EINTR) - { - /* Log the signal. */ - ulog (LOG_ERROR, (const char *) NULL); - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - } - - if (cgot < 0) - { - if (errno != EAGAIN && errno != EWOULDBLOCK) - { - ulog (LOG_ERROR, "read: %s", strerror (errno)); - return FALSE; - } - cgot = 0; - } - - cread -= cgot; - zread += cgot; - *pcread += cgot; - - /* If we've filled the read buffer, or we have nothing left to - write, return out. */ - - if (cread <= 0 || cwrite <= 0) - return TRUE; - - /* The port is currently unblocked. Do a write. */ - - cdo = cwrite; - -#if ! HAVE_UNBLOCKED_WRITES - if (cdo > SINGLE_WRITE) - cdo = SINGLE_WRITE; -#endif - - /* Loop until we get something besides EINTR. */ - while ((cdid = write (q->owrite, zwrite, cdo)) < 0 - && errno == EINTR) - { - /* Log the signal. */ - ulog (LOG_ERROR, (const char *) NULL); - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - } - - if (cdid < 0) - { - if (errno != EWOULDBLOCK && errno != EAGAIN) - { - ulog (LOG_ERROR, "write: %s", strerror (errno)); - return FALSE; - } - cdid = 0; - } - - if (cdid > 0) - { - /* We wrote some data. If we wrote everything, return out. - Otherwise loop around and do another read. */ - cwrite -= cdid; - zwrite += cdid; - *pcwrite += cdid; - - if (cwrite <= 0) - return TRUE; - - czero = 0; - } - else - { - /* We didn't write any data. Do a blocking write. */ - - if (! fsblock (q, TRUE)) - return FALSE; - - cdo = cwrite; - if (cdo > SINGLE_WRITE) - cdo = SINGLE_WRITE; - - DEBUG_MESSAGE1 (DEBUG_PORT, - "fsserial_io: Blocking write of %d", cdo); - - /* Loop until we get something besides EINTR. */ - while ((cdid = write (q->owrite, zwrite, cdo)) < 0 - && errno == EINTR) - { - /* Log the signal. */ - ulog (LOG_ERROR, (const char *) NULL); - if (FGOT_QUIT_SIGNAL ()) - return FALSE; - } - - if (cdid < 0) - { - ulog (LOG_ERROR, "write: %s", strerror (errno)); - return FALSE; - } - - if (cdid == 0) - { - /* On some systems write will return 0 if carrier is - lost. If we fail to write anything ten times in a - row, we assume that this has happened. This is - hacked in like this because there seems to be no - reliable way to tell exactly why the write returned - 0. */ - ++czero; - if (czero >= 10) - { - ulog (LOG_ERROR, "Line disconnected"); - return FALSE; - } - } - else - { - cwrite -= cdid; - zwrite += cdid; - *pcwrite += cdid; - czero = 0; - } - } - } -} - -/* I/O to a stdin port. */ - -boolean -fsysdep_stdin_io (qport, zwrite, pcwrite, zread, pcread) - struct sport *qport; - const char *zwrite; - int *pcwrite; - char *zread; - int *pcread; -{ - return fsserial_io (&qport->u.sstdin.s.s, zwrite, pcwrite, zread, pcread); -} - -/* I/O to a modem port. */ - -boolean -fsysdep_modem_io (qport, zwrite, pcwrite, zread, pcread) - struct sport *qport; - const char *zwrite; - int *pcwrite; - char *zread; - int *pcread; -{ - return fsserial_io (&qport->u.smodem.s.s, zwrite, pcwrite, zread, pcread); -} - -/* I/O to a direct port. */ - -boolean -fsysdep_direct_io (qport, zwrite, pcwrite, zread, pcread) - struct sport *qport; - const char *zwrite; - int *pcwrite; - char *zread; - int *pcread; -{ - return fsserial_io (&qport->u.sdirect.s.s, zwrite, pcwrite, zread, pcread); -} - -/* Send a break character to a serial port. */ - -static boolean -fsserial_break (q) - struct ssysdep_serial_port *q; -{ -#if HAVE_BSD_TTY - ioctl (q->owrite, TIOCSBRK, 0); - sleep (1); - ioctl (q->owrite, TIOCCBRK, 0); - return TRUE; -#endif /* HAVE_BSD_TTY */ -#if HAVE_SYSV_TERMIO - ioctl (q->owrite, TCSBRK, 0); - return TRUE; -#endif /* HAVE_SYSV_TERMIO */ -#if HAVE_POSIX_TERMIOS - return tcsendbreak (q->owrite, 0) == 0; -#endif /* HAVE_POSIX_TERMIOS */ -} - -/* Send a break character to a stdin port. */ - -boolean -fsysdep_stdin_break (qport) - struct sport *qport; -{ - return fsserial_break (&qport->u.sstdin.s.s); -} - -/* Send a break character to a modem port. */ - -boolean -fsysdep_modem_break (qport) - struct sport *qport; -{ - return fsserial_break (&qport->u.smodem.s.s); -} - -/* Send a break character to a direct port. */ - -boolean -fsysdep_direct_break (qport) - struct sport *qport; -{ - return fsserial_break (&qport->u.sdirect.s.s); -} - -/* Change the setting of a serial port. */ - -static boolean -fsserial_set (q, tset) - struct ssysdep_serial_port *q; - enum tportsetting tset; -{ - if (! q->fterminal) - return TRUE; - - switch (tset) - { - case PORTSETTING_EIGHT: -#if HAVE_BSD_TTY - if (q->snew.sg_flags == (RAW | ANYP)) - return TRUE; - q->snew.sg_flags = RAW | ANYP; -#endif -#if HAVE_SYSV_TERMIO || HAVE_POSIX_TERMIOS - if ((q->snew.c_iflag & ICLEAR_IFLAG) == 0) - return TRUE; - q->snew.c_iflag &=~ ICLEAR_IFLAG; -#endif - if (! fsetterminfodrain (q->oread, &q->snew)) - { - ulog (LOG_ERROR, "Can't go to raw mode: %s", strerror (errno)); - return FALSE; - } - return TRUE; - - case PORTSETTING_SEVEN: -#if HAVE_BSD_TTY - if (q->snew.sg_flags == (CBREAK | ANYP | TANDEM)) - return TRUE; - q->snew.sg_flags = CBREAK | ANYP | TANDEM; -#endif /* HAVE_BSD_TTY */ -#if HAVE_SYSV_TERMIO | HAVE_POSIX_TERMIOS - { - int iwant; - -#ifdef CRTSCTS - /* It would be nice to do this is in a more portable fashion, - but in any case this is apparently correct for SunOS. If - we are doing hardware flow control, we don't also send - start and stop characters; however, we do recognize - incoming start and stop characters. */ - if ((q->snew.c_cflag & CRTSCTS) != 0) - iwant = ISTRIP | IXON; - else - iwant = ISTRIP | IXON | IXOFF; -#else /* ! defined (CRTSCTS) */ - iwant = ISTRIP | IXON | IXOFF; -#endif /* ! defined (CRTSCTS) */ - - if ((q->snew.c_iflag & ICLEAR_IFLAG) == iwant) - return TRUE; - - q->snew.c_iflag &=~ ICLEAR_IFLAG; - q->snew.c_iflag |= iwant; - } -#endif /* HAVE_SYSV_TERMIO | HAVE_POSIX_TERMIOS */ - - if (! fsetterminfodrain (q->oread, &q->snew)) - { - ulog (LOG_ERROR, "Can't go to seven bit mode: %s", - strerror (errno)); - return FALSE; - } - return TRUE; - - default: -#if DEBUG > 0 - ulog (LOG_FATAL, "fsserial_set: Can't happen"); -#endif - return FALSE; - } -} - -/* Change settings of a stdin port. */ - -boolean -fsysdep_stdin_set (qport, tset) - struct sport *qport; - enum tportsetting tset; -{ - return fsserial_set (&qport->u.sstdin.s.s, tset); -} - -/* Change settings of a modem port. */ - -boolean -fsysdep_modem_set (qport, tset) - struct sport *qport; - enum tportsetting tset; -{ - return fsserial_set (&qport->u.smodem.s.s, tset); -} - -/* Change settings of a direct port. */ - -boolean -fsysdep_direct_set (qport, tset) - struct sport *qport; - enum tportsetting tset; -{ - return fsserial_set (&qport->u.sdirect.s.s, tset); -} - -/* Run a chat program. */ - -static boolean -fsrun_chat (oread, owrite, zprog) - int oread; - int owrite; - const char *zprog; -{ - int cargs; - const char **azargs; - char *zcopy, *zarg; - int aidescs[3]; - FILE *e; - pid_t ipid; - char *z; - - /* Get the arguments into an array to pass to isspawn. */ - zcopy = (char *) alloca (strlen (zprog) + 1); - strcpy (zcopy, zprog); - cargs = 0; - for (zarg = strtok (zcopy, " \t"); - zarg != NULL; - zarg = strtok ((char *) NULL, " \t")) - ++cargs; - - azargs = (const char **) alloca ((cargs + 1) * sizeof (const char *)); - - strcpy (zcopy, zprog); - cargs = 0; - for (zarg = strtok (zcopy, " \t"); - zarg != NULL; - zarg = strtok ((char *) NULL, " \t")) - { - azargs[cargs] = zarg; - ++cargs; - } - azargs[cargs] = NULL; - - aidescs[0] = oread; - aidescs[1] = owrite; - aidescs[2] = SPAWN_READ_PIPE; - - /* Pass fkeepuid, fkeepenv and fshell as TRUE. This puts the - responsibility of maintaing security on the chat program. */ - ipid = isspawn (azargs, aidescs, TRUE, TRUE, (const char *) NULL, - FALSE, TRUE, (const char *) NULL, - (const char *) NULL, (const char *) NULL); - if (ipid < 0) - { - ulog (LOG_ERROR, "isspawn (%s): %s", azargs[0], strerror (errno)); - return FALSE; - } - - e = fdopen (aidescs[2], (char *) "r"); - if (e == NULL) - { - ulog (LOG_ERROR, "fdopen: %s", strerror (errno)); - (void) close (aidescs[2]); - (void) kill (ipid, SIGKILL); - (void) iswait ((unsigned long) ipid, (const char *) NULL); - return FALSE; - } - - /* The FILE e now is attached to stderr of the program. Forward - every line the program outputs to the log file. */ - while ((z = zfgets (e, FALSE)) != NULL) - { - int clen; - - clen = strlen (z); - if (z[clen - 1] == '\n') - z[clen - 1] = '\0'; - if (*z != '\0') - ulog (LOG_NORMAL, "chat: %s", z); - xfree ((pointer) z); - } - - (void) fclose (e); - - return iswait ((unsigned long) ipid, "Chat program") == 0; -} - -/* Run a chat program on a stdin port. */ - -boolean -fsysdep_stdin_chat (qport, zprog) - struct sport *qport; - const char *zprog; -{ - return fsrun_chat (qport->u.sstdin.s.s.oread, - qport->u.sstdin.s.s.owrite, - zprog); -} - -/* Run a chat program on a modem port. */ - -boolean -fsysdep_modem_chat (qport, zprog) - struct sport *qport; - const char *zprog; -{ - return fsrun_chat (qport->u.smodem.s.s.oread, - qport->u.smodem.s.s.owrite, - zprog); -} - -/* Run a chat program on a direct port. */ - -boolean -fsysdep_direct_chat (qport, zprog) - struct sport *qport; - const char *zprog; -{ - return fsrun_chat (qport->u.sdirect.s.s.oread, - qport->u.sdirect.s.s.owrite, - zprog); -} - -#if HAVE_TCP - -/* Run a chat program on a TCP port. */ - -boolean -fsysdep_tcp_chat (qport, zprog) - struct sport *qport; - const char *zprog; -{ - return fsrun_chat (qport->u.stcp.o, qport->u.stcp.o, zprog); -} - -#endif /* HAVE_TCP */ - -/* Functions to return baud rates. */ - -/* Return baud rate of a stdin port. */ - -long -isysdep_stdin_baud (qport) - struct sport *qport; -{ - return qport->u.sstdin.s.s.ibaud; -} - -/* Return baud rate of a modem port. */ - -long -isysdep_modem_baud (qport) - struct sport *qport; -{ - return qport->u.smodem.s.s.ibaud; -} - -/* Return baud rate of a direct port. */ - -long -isysdep_direct_baud (qport) - struct sport *qport; -{ - return qport->u.sdirect.s.s.ibaud; -} - -#if HAVE_TCP - -/* Some system dependent routines for TCP ports. These work by - setting up an ssysdep_serial_port structure to fake out the serial - port routines. I'm doing it this way to avoid having to write the - complicated timeout code twice, and because the serial port code - will work fine. It does mean that if the serial port code changes - this code will have to be considered. */ - -/* Read data from a TCP port. */ - -boolean -fsysdep_tcp_read (qport, zread, pclen, cmin, ctimeout, freport) - struct sport *qport; - char *zread; - int *pclen; - int cmin; - int ctimeout; - boolean freport; -{ - struct ssysdep_serial_port s; - - s.oread = s.owrite = qport->u.stcp.o; - s.fread_blocking = TRUE; - s.fterminal = FALSE; - return fsserial_read (&s, zread, pclen, cmin, ctimeout, freport, FALSE); -} - -/* Write data to a TCP port. */ - -boolean -fsysdep_tcp_write (qport, zwrite, cwrite) - struct sport *qport; - const char *zwrite; - int cwrite; -{ - struct ssysdep_serial_port s; - - s.oread = s.owrite = qport->u.stcp.o; - s.fread_blocking = TRUE; - s.fterminal = FALSE; - return fsserial_write (&s, zwrite, cwrite); -} - -/* Read and write data to and from a TCP port. We actually don't - bother to really implement this, since the system will buffer up - plenty of TCP data (only 256 bytes are buffered for a terminal, - so losing data becomes a real possibility). */ - -boolean -fsysdep_tcp_io (qport, zwrite, pcwrite, zread, pcread) - struct sport *qport; - const char *zwrite; - int *pcwrite; - char *zread; - int *pcread; -{ - struct ssysdep_serial_port s; - - s.oread = s.owrite = qport->u.stcp.o; - s.fread_blocking = TRUE; - s.fterminal = FALSE; - *pcread = 0; - return fsserial_write (&s, zwrite, *pcwrite); -} - -#endif /* HAVE_TCP */ - -/* - Local variables: - mode:c - End: - */ diff --git a/gnu/libexec/uucp/sys3.unx b/gnu/libexec/uucp/sys3.unx deleted file mode 100644 index 9ef70d643b82..000000000000 --- a/gnu/libexec/uucp/sys3.unx +++ /dev/null @@ -1,2650 +0,0 @@ -/* sys3.unx - The system dependent spool directory subroutines for Unix. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: sys3.unx,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - -# Revision 1.2 92/05/13 05:42:07 rich -# ported to 386bsd -# -# Revision 1.1 1992/05/10 18:00:16 rich -# Initial revision -# - Revision 1.48 1992/04/01 22:36:48 ian - David J. MacKenzie: some USG_STATFS systems use 512 despite f_bsize - - Revision 1.47 1992/03/30 15:03:07 ian - Niels Baggesen: USG statfs has an f_bsize field - - Revision 1.46 1992/03/28 22:06:38 ian - Michael I Bushnell: renamed enum tstatus to avoid header file conflict - - Revision 1.45 1992/03/26 20:20:28 ian - Reduce race condition in fsdo_lock - - Revision 1.44 1992/03/15 01:54:46 ian - All execs are now done in isspawn, all waits are done in iswait - - Revision 1.43 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.42 1992/03/10 20:45:58 ian - Check size of destination file system as well as temporary system - - Revision 1.41 1992/03/09 19:42:43 ian - Ted Lindgreen: don't send mail for nonexistent file - - Revision 1.40 1992/03/04 01:40:51 ian - Thomas Fischer: tweaked a bit for the NeXT - - Revision 1.39 1992/02/29 04:07:08 ian - Added -j option to uucp and uux - - Revision 1.38 1992/02/29 01:06:59 ian - Chip Salzenberg: recheck file permissions before sending - - Revision 1.37 1992/02/28 15:57:58 ian - Give error if esysdep_open_send is given a directory - - Revision 1.36 1992/02/24 22:05:30 ian - Roberto Biancardi: support F_CHSIZE and F_FREESP in esysdep_truncate - - Revision 1.35 1992/02/24 20:07:43 ian - John Theus: some systems don't have - - Revision 1.34 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.33 1992/02/20 04:18:59 ian - Added uustat - - Revision 1.32 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.31 1992/02/02 20:42:40 ian - Niels Baggesen: case enum to int before comparison - - Revision 1.30 1992/02/01 00:54:31 ian - Michael Nolan: cast alloca return value - - Revision 1.29 1992/01/29 04:27:11 ian - Jay Vassos-Libove: removed some conflicting declarations - - Revision 1.28 1992/01/28 04:34:10 ian - Marty Shannon: handle trailing '/' to indicate directory - - Revision 1.27 1992/01/14 04:51:48 ian - David Nugent: don't declare chmod - - Revision 1.26 1992/01/14 04:25:20 ian - Chip Salzenberg: avoid use before set warning - - Revision 1.25 1992/01/14 03:46:55 ian - Chip Salzenberg: handle invalid status values in status files - - Revision 1.24 1992/01/13 06:11:39 ian - David Nugent: can't declare open or fcntl - - Revision 1.23 1992/01/05 03:18:54 ian - Avoid redefining SEEK_SET - - Revision 1.22 1992/01/04 22:56:22 ian - Added extern definition - - Revision 1.21 1992/01/03 05:44:35 ian - Remove temporary file if link fails in fsdo_lock - - Revision 1.20 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.19 1991/12/22 22:14:19 ian - Monty Solomon: added HAVE_UNISTD_H configuration parameter - - Revision 1.18 1991/12/22 20:50:47 ian - Franc,ois Pinard: fixed bug in fsysdep_get_status - - Revision 1.17 1991/12/12 18:35:47 ian - Do locking with link to avoid races and to permit running as root - - Revision 1.16 1991/12/12 17:45:34 ian - fcopy_file now creates the file with IPRIVATE_MODE - - Revision 1.15 1991/12/11 03:59:19 ian - Create directories when necessary; don't just assume they exist - - Revision 1.14 1991/12/09 19:07:07 ian - Richard Todd: add HAVE_V2_LOCKFILES--binary number in lock file - - Revision 1.13 1991/12/03 02:59:46 ian - Using LOCKDIR clobbered a byte on the stack - - Revision 1.12 1991/12/01 02:23:12 ian - Niels Baggesen: don't multiply include - - Revision 1.11 1991/12/01 01:12:40 ian - Marty Shannon: accept truncated status file; also eliminated scanf calls - - Revision 1.10 1991/11/30 23:28:26 ian - Marty Shannon: some systems need a fake version of the rename system call - - Revision 1.9 1991/11/21 21:43:42 ian - Eliminate unused MIN_FREE_BYTES - - Revision 1.8 1991/11/21 21:07:46 ian - Brian Campbell: offer ltrunc as an alternative to ftruncate - - Revision 1.7 1991/11/10 21:32:16 ian - Fixed ftruncate call - - Revision 1.6 1991/11/10 19:24:22 ian - Added pffile protocol entry point for file level control - - Revision 1.5 1991/11/07 19:32:28 ian - Chip Salzenberg: allow LOCKDIR, and check that locking process exists - - Revision 1.4 1991/09/19 17:28:01 ian - Chip Salzenberg: make sure spool directory files are not world readable - - Revision 1.3 1991/09/19 03:23:34 ian - Chip Salzenberg: append to private debugging file, don't overwrite it - - Revision 1.2 1991/09/19 03:06:04 ian - Chip Salzenberg: put BNU temporary files in system's directory - - Revision 1.1 1991/09/10 19:45:50 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char sys3_unx_rcsid[] = "$Id: sys3.unx,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#if USE_STDIO && HAVE_UNISTD_H -#include -#endif - -#include "system.h" -#include "sysdep.h" - -#include - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -/* Get the right header files for statfs and friends. This stuff is - from David MacKenzie's df program. */ - -#ifdef FS_STATVFS -#include -extern int statvfs (); -#endif - -#ifdef FS_USG_STATFS -#include -extern int statfs (); -#endif - -#ifdef FS_MNTENT -#include -extern int statfs (); -#endif - -#ifdef FS_GETMNT -#include -#include -extern int statfs (); -#endif - -#ifdef FS_STATFS -#include -extern int statfs (); -#endif - -#ifdef FS_USTAT -#include -extern int ustat (); -#endif - -/* We need a definition for SEEK_SET. */ - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -/* External functions. */ -extern int close (), link (), read (), write (); -#ifndef __386BSD__ -extern int kill (); -#endif __386BSD__ -extern int fstat (), stat (); -extern int fclose (), fseek (), pclose (); -extern pid_t getpid (); -extern off_t lseek (); -extern char *strrchr (); - -#if HAVE_FTRUNCATE -extern int ftruncate (); -#endif - -#if HAVE_RENAME -extern int rename (); -#else -static int rename P((const char *zfrom, const char *zto)); -#endif - -/* There are several types of files that go in the spool directory, - and they go into various different subdirectories. When using - SPOOLDIR_TAYLOR, there is a subdirectory for each system for which - communication occurs; these system names have been made canonical - via fread_system_info or ztranslate_name, so they will fit any - name length restrictions (namely 14 characters on System V). - Whenever the system name LOCAL appears below, it means whatever - the local system name is. - - Command files - These contain instructions for uucico indicating what files to transfer - to and from what systems. Each line of a work file is a command - beginning with S, R or X. - #if ! SPOOLDIR_TAYLOR - They are named C.ssssssgqqqq, where ssssss is the system name to - transfer to or from, g is the grade and qqqq is the sequence number. - #if SPOOLDIR_V2 - They are put in the spool directory. - #elif SPOOLDIR_BSD42 | SPOOLDIR_BSD43 - They are put in the directory C. - #elif SPOOLDIR_BNU - They are put in a directory named for the system for which they were - created. - #elif SPOOLDIR_ULTRIX - If the directory sys/ssssss exists, they are put in the directory - sys/ssssss/C; otherwise, they are put in the directory sys/DEFAULT/C. - #endif - #else SPOOLDIR_TAYLOR - They are named C.gqqqq, where g is the grade and qqqq is the sequence - number, and are placed in the directory ssssss/C. where ssssss is - the system name to transfer to or from. - #endif - - Data files - There are files to be transferred to other systems. Some files to - be transferred may not be in the spool directory, depending on how - uucp was invoked. Data files are named in work files, so it is - never necessary to look at them directly (except to remove old ones); - it is only necessary to create them. These means that the many - variations in naming are inconsequential. - #if ! SPOOLDIR_TAYLOR - They are named D.ssssssgqqqq where ssssss is a system name (which - may be LOCAL for locally initiated transfers or a remote system for - remotely initiated transfers, except that BNU appears to use the - system the file is being transferred to), g is the grade and qqqq - is the sequence number. Some systems use a trailing subjob ID - number, but we currently do not. The grade is not important, and - some systems do not use it. If the data file is to become an - execution file on another system the grade (if present) will be - 'X'. Otherwise Ultrix appears to use 'b'; the uux included with - gnuucp 1.0 appears to use 'S'; SCO does not appear to use a grade, - although it does use a subjob ID number. - #if SPOOLDIR_V2 - They are put in the spool directory. - #elif SPOOLDIR_BSD42 - If the name begins with D.LOCAL, the file is put in the directory - D.LOCAL. Otherwise the file is put in the directory D.. - #elif SPOOLDIR_BSD43 - If the name begins with D.LOCALX, the file is put in the directory - D.LOCALX. Otherwise if the name begins with D.LOCAL, the file is - put in the directory D.LOCAL Otherwise the file is put in the - directory D.. - #elif SPOOLDIR_BNU - They are put in a directory named for the system for which they - were created. - #elif SPOOLDIR_ULTRIX - Say the file is being transferred to system REMOTE. If the - directory sys/REMOTE exists, then if the file begins with D.LOCALX - it is put in sys/REMOTE/D.LOCALX, if the file begins with D.LOCAL - it is put in sys/REMOTE/D.LOCAL, and otherwise it is put in - sys/REMOTE/D.. If the directory sys/REMOTE does not exist, the - same applies except that DEFAULT is used instead of REMOTE. - #endif - #else SPOOLDIR_TAYLOR - If the file is to become an executable file on another system it is - named D.Xqqqq, otherwise it is named D.qqqq where in both cases - qqqq is a sequence number. If the corresponding C. file is in - directory ssssss/C., a D.X file is placed in ssssss/D.X and a D. - file is placed in ssssss/D.. - #endif - - Execute files - These are files that specify programs to be executed. They are - created by uux, perhaps as run on another system. These names are - important, because a file transfer done to an execute file name - causes an execution to occur. The name is X.ssssssgqqqq, where - ssssss is the requesting system, g is the grade, and qqqq is a - sequence number. - #if SPOOLDIR_V2 | SPOOLDIR_BSD42 - These files are placed in the spool directory. - #elif SPOOLDIR_BSD43 - These files are placed in the directory X.. - #elif SPOOLDIR_BNU - These files are put in a directory named for the system for which - the files were created. - #elif SPOOLDIR_ULTRIX - If there is a spool directory (sys/ssssss) for the requesting - system, the files are placed in sys/ssssss/X.; otherwise, the files - are placed in sys/DEFAULT/X.. - #elif SPOOLDIR_TAYLOR - The system name is automatically truncated to seven characters when - a file is created. The files are placed in the subdirectory X. of - a directory named for the system for which the files were created. - #endif - - Temporary receive files - These are used when receiving files from another system. They are - later renamed to the final name. The actual name is unimportant, - although it generally begins with TM.. - #if SPOOLDIR_V2 | SPOOLDIR_BSD42 - These files are placed in the spool directory. - #elif SPOOLDIR_BSD43 | SPOOLDIR_ULTRIX | SPOOLDIR_TAYLOR - These files are placed in the directory .Temp. - #elif SPOOLDIR_BNU - These files are placed in a directory named for the system for - which they were created. - #endif - - Lock files - These files are used to lock systems, devices and special files. - The file LCK..ssssss is used to lock a system, where ssssss is the - system name. The file LCK..dev is used to lock a device, where dev - is the device name. The file LCK.file is used to lock a file, - where file is LOG for the log file, SQ for the system sequence - number file, or SEQF for the work queue sequence number file. At - least under Ultrix, the file LCK.XQT is used to lock uuxqt - execution. Some systems supposedly use LCK.SEQL for something. On - some systems, the contents of the lock file is the ASCII process - id; on others, it is the process id as four data bytes. As far as - I can tell, the only lock file I really have to get right is the - one locking a device, so that cu won't use it; if somebody tries to - run old UUCP and this at the same time, they will probably have - trouble unless they make sure the locking is correct for their - system. Not that there is any easy way to make that check, - unfortunately. Supposedly all normal systems put the LCK files in - the spool directory, and this package will do that also. - - System status files - These are used to record when the last call was made to the system - and what the status is. They are used to prevent frequent recalls - to a system which is not responding. I will not attempt to - recreate the format of these exactly, since they are not all that - important. They will be put in the directory .Status, as in BNU, - and they use the system name as the name of the file. - - Log files - These are used to record what UUCP has done. I will not attempt to - recreate the format of these at all. They will be stored in the - directory .Log/uucico (or .Log/uucp, .Log/uux, .Log/uuxqt) and - named for the relevant system. This is the format used by BNU. - - Statistics files - I don't really know the format of these. They are apparently used - to keep track of what jobs have been run by UUCP, but at least on - Ultrix they don't seem to be used very consistently. - - Sequence file - This is used to generate a unique sequence number. It contains an - ASCII number. - #if SPOOLDIR_V2 | SPOOLDIR_BSD42 | SPOOLDIR_BSD43 - The file is named SEQF and is kept in the spool directory. - #elif SPOOLDIR_BNU - A separate sequence file is kept for each system in the directory - .Sequence with the name of the system. - #elif SPOOLDIR_ULTRIX - Each system with a file sys/ssssss has a sequence file in - sys/ssssss/.SEQF. Other systems use sys/DEFAULT/.SEQF. - #else SPOOLDIR_TAYLOR - A sequence file named SEQF is kept in the directory ssssss for each - system. - #endif - - Audit files - Debugging messages are stored in these when running as a slave. We - use the file AUDIT in the spool directory. */ - -/* Local functions. */ - -static char *zsstatic_size P((int c)); -#if SPOOLDIR_TAYLOR -static const char *zsappend3 P((const char *zdir1, const char *zdir2, - const char *zfile)); -#endif -#if SPOOLDIR_ULTRIX -static const char *zsappend4 P((const char *zdir1, const char *zdir2, - const char *zdir3, const char *zfile)); -#endif -static const char *zsfind_file P((const char *zsimple, - const char *zsystem)); -static boolean fscmd_seq P((const char *zsystem, char *zseq)); -static const char *zsfile_name P((int btype, const char *zsystem, - int bgrade, char *ztname, - char *zdname, char *zxname)); - -/* A few routines to manipulate strings with directories. */ - -#define CSTATICLEN (50) -static char abSstatic[CSTATICLEN]; -static char *zSstatic_alloc; -static int cSstatic_alloc; - -/* Return a pointer to a static buffer of a certain size. */ - -static char * -zsstatic_size (c) - int c; -{ - if (c <= CSTATICLEN) - return abSstatic; - if (cSstatic_alloc < c) - { - xfree ((pointer) zSstatic_alloc); - zSstatic_alloc = (char *) xmalloc (c); - cSstatic_alloc = c; - } - return zSstatic_alloc; -} - -/* Copy a string into a static buffer. */ - -const char * -zscopy (z) - const char *z; -{ - char *zret; - - zret = zsstatic_size (strlen (z) + 1); - strcpy (zret, z); - return (const char *) zret; -} - -/* Stick a directory and file name together. Return a static buffer - holding the combined name. This is called by Unix system dependent - routines outside this file. */ - -const char * -zsappend (zdir, zfile) - const char *zdir; - const char *zfile; -{ - char *zret; - - zret = zsstatic_size (strlen (zdir) + strlen (zfile) + sizeof "/"); - sprintf (zret, "%s/%s", zdir, zfile); - return (const char *) zret; -} - -#if SPOOLDIR_TAYLOR - -/* Stick two directories and a file name together. Return a static - buffer holding the combined name. */ - -static const char * -zsappend3 (zdir1, zdir2, zfile) - const char *zdir1; - const char *zdir2; - const char *zfile; -{ - char *zret; - - zret = zsstatic_size (strlen (zdir1) + strlen (zdir2) - + strlen (zfile) + sizeof "//"); - sprintf (zret, "%s/%s/%s", zdir1, zdir2, zfile); - return (const char *) zret; -} - -#endif /* SPOOLDIR_TAYLOR */ - -#if SPOOLDIR_ULTRIX - -/* Stick three directories and a file name together. Return a static - buffer holding the combined name. */ - -static const char * -zsappend4 (zdir1, zdir2, zdir3, zfile) - const char *zdir1; - const char *zdir2; - const char *zdir3; - const char *zfile; -{ - char *zret; - - zret = zsstatic_size (strlen (zdir1) + strlen (zdir2) + strlen (zdir3) - + strlen (zfile) + sizeof "///"); - sprintf (zret, "%s/%s/%s/%s", zdir1, zdir2, zdir3, zfile); - return (const char *) zret; -} - -/* See whether an ULTRIX spool directory exists for a system. For system - ssssss, the spool directory is called sys/ssssss. */ - -boolean -fsultrix_has_spool (zsystem) - const char *zsystem; -{ - char *z; - - z = (char *) alloca (sizeof "sys/" + strlen (zsystem)); - sprintf (z, "sys/%s", zsystem); - return fsdirectory_exists (z); -} - -#endif /* SPOOLDIR_ULTRIX */ - -/* Create a spool directory for a system. This is only relevant for - SPOOLDIR_BNU or SPOOLDIR_TAYLOR. The system specific directories - for Ultrix are meant to be created by hand. */ - -#if SPOOLDIR_TAYLOR | SPOOLDIR_BNU - -static boolean fsmkdir P((const char *zdir)); - -static boolean -fsmkdir (zdir) - const char *zdir; -{ - if (mkdir ((char *) zdir, IDIRECTORY_MODE) < 0) - { - ulog (LOG_ERROR, "mkdir (%s): %s", zdir, strerror (errno)); - return FALSE; - } - return TRUE; -} - -#endif /* SPOOLDIR_TAYLOR | SPOOLDIR_BNU */ - -boolean -fsysdep_make_spool_dir (qsys) - const struct ssysteminfo *qsys; -{ - const char *zsystem; - - zsystem = qsys->zname; - -#if SPOOLDIR_BNU - if (fsdirectory_exists (zsystem)) - return TRUE; - if (! fsmkdir (zsystem)) - return FALSE; -#endif /* SPOOLDIR_BNU */ - -#if SPOOLDIR_TAYLOR - if (fsdirectory_exists (zsystem)) - return TRUE; - if (! fsmkdir (zsystem) - || ! fsmkdir (zsappend (zsystem, "C.")) - || ! fsmkdir (zsappend (zsystem, "D.")) - || ! fsmkdir (zsappend (zsystem, "D.X")) - || ! fsmkdir (zsappend (zsystem, "X."))) - return FALSE; -#endif /* SPOOLDIR_TAYLOR */ - - return TRUE; -} - -/* Given the name of a file as specified in a UUCP command, and the - system for which this file has been created, return where to find - it in the spool directory. The file will begin with C. (a command - file), D. (a data file) or X. (an execution file). The return - value of this function will point to a static buffer. */ - -static const char * -zsfind_file (zsimple, zsystem) - const char *zsimple; - const char *zsystem; -{ - if (zsimple[1] != '.' - || (*zsimple != 'C' - && *zsimple != 'D' - && *zsimple != 'X')) - { - ulog (LOG_ERROR, "Unrecognized file name %s", zsimple); - return NULL; - } - - switch (*zsimple) - { - case 'C': -#if SPOOLDIR_V2 - return zscopy (zsimple); -#endif /* SPOOLDIR_V2 */ -#if SPOOLDIR_BSD42 | SPOOLDIR_BSD43 - return zsappend ("C.", zsimple); -#endif /* SPOOLDIR_BSD42 | SPOOLDIR_BSD43 */ -#if SPOOLDIR_BNU - return zsappend (zsystem, zsimple); -#endif /* SPOOLDIR_BNU */ -#if SPOOLDIR_ULTRIX - if (fsultrix_has_spool (zsystem)) - return zsappend4 ("sys", zsystem, "C.", zsimple); - else - return zsappend4 ("sys", "DEFAULT", "C.", zsimple); -#endif -#if SPOOLDIR_TAYLOR - return zsappend3 (zsystem, "C.", zsimple); -#endif - - case 'D': -#if SPOOLDIR_V2 - return zscopy (zsimple); -#endif /* SPOOLDIR_V2 */ -#if SPOOLDIR_BSD42 | SPOOLDIR_BSD43 - { - int c; - boolean ftruncated; - char *zalloc; - - /* D.LOCAL in D.LOCAL/, others in D./. If BSD43, D.LOCALX in - D.LOCALX/. */ - ftruncated = TRUE; - if (strncmp (zsimple + 2, zLocalname, strlen (zLocalname)) == 0) - { - c = strlen (zLocalname); - ftruncated = FALSE; - } - else if (strncmp (zsimple + 2, zLocalname, 7) == 0) - c = 7; - else if (strncmp (zsimple + 2, zLocalname, 6) == 0) - c = 6; - else - c = 0; -#if SPOOLDIR_BSD43 - if (c > 0 && zsimple[c + 2] == 'X') - c++; -#endif /* SPOOLDIR_BSD43 */ - if (c > 0) - { - zalloc = (char *) alloca (c + 3); - strncpy (zalloc, zsimple, c + 2); - zalloc[c + 2] = '\0'; - - /* If we truncated the system name, and there is no existing - directory with the truncated name, then just use D.. */ - if (ftruncated && ! fsdirectory_exists (zalloc)) - return zsappend ("D.", zsimple); - - return zsappend (zalloc, zsimple); - } - else - return zsappend ("D.", zsimple); - } -#endif /* SPOOLDIR_BSD42 | SPOOLDIR_BSD43 */ -#if SPOOLDIR_BNU - return zsappend (zsystem, zsimple); -#endif /* SPOOLDIR_BNU */ -#if SPOOLDIR_ULTRIX - { - int c; - boolean ftruncated; - char *zalloc; - const char *zdir; - - /* D.LOCALX in D.LOCALX/, D.LOCAL in D.LOCAL/, others in D./. */ - - ftruncated = TRUE; - if (strncmp (zsimple + 2, zLocalname, strlen (zLocalname)) == 0) - { - c = strlen (zLocalname); - ftruncated = FALSE; - } - else if (strncmp (zsimple + 2, zLocalname, 7) == 0) - c = 7; - else if (strncmp (zsimple + 2, zLocalname, 6) == 0) - c = 6; - else - c = 0; - if (c > 0 && zsimple[c + 2] == 'X') - c++; - if (c > 0) - { - zalloc = (char *) alloca (c + 3); - strncpy (zalloc, zsimple, c + 2); - zalloc[c + 2] = '\0'; - zdir = zalloc; - - /* If we truncated the name, and there is no directory for - the truncated name, then don't use it. */ - if (ftruncated) - { - char *zlook; - - zlook = (char *) alloca (c + 20 + strlen (zsystem)); - if (fsultrix_has_spool (zsystem)) - sprintf (zlook, "sys/%s/%s", zsystem, zdir); - else - sprintf (zlook, "sys/DEFAULT/%s", zdir); - if (! fsdirectory_exists (zlook)) - zdir = "D."; - } - } - else - zdir = "D."; - - if (fsultrix_has_spool (zsystem)) - return zsappend4 ("sys", zsystem, zdir, zsimple); - else - return zsappend4 ("sys", "DEFAULT", zdir, zsimple); - } -#endif /* SPOOLDIR_ULTRIX */ -#if SPOOLDIR_TAYLOR - if (zsimple[2] == 'X') - return zsappend3 (zsystem, "D.X", zsimple); - else - return zsappend3 (zsystem, "D.", zsimple); -#endif /* SPOOLDIR_TAYLOR */ - - /* Files beginning with X. are execute files. It is important - for security reasons that we know the system which created - the X. file. This is easy under SPOOLDIR_BNU or - SPOOLDIR_TAYLOR, because the file will be in a directory - named for the system. Under other schemes, we must get the - system name from the X. file name. To prevent security - violations, we set the system name directly here; this will - cause problems if the maximum file name length is too short, - but hopefully no problem will occur since any System V - systems will be using either BNU or TAYLOR. */ - - case 'X': -#if ! SPOOLDIR_BNU && ! SPOOLDIR_TAYLOR - if (strncmp (zsimple + 2, zsystem, strlen (zsimple) - 7) != 0) - { - char *zcopy; - - zcopy = (char *) alloca (strlen (zsystem) + 8); - sprintf (zcopy, "X.%s%s", zsystem, - zsimple + strlen (zsimple) - 5); - zsimple = zcopy; - } -#endif /* ! SPOOLDIR_BNU && ! SPOOLDIR_TAYLOR */ - -#if SPOOLDIR_V2 | SPOOLDIR_BSD42 - return zscopy (zsimple); -#endif -#if SPOOLDIR_BSD43 - return zsappend ("X.", zsimple); -#endif -#if SPOOLDIR_BNU - return zsappend (zsystem, zsimple); -#endif -#if SPOOLDIR_ULTRIX - if (fsultrix_has_spool (zsystem)) - return zsappend4 ("sys", zsystem, "X.", zsimple); - else - return zsappend4 ("sys", "DEFAULT", "X.", zsimple); -#endif -#if SPOOLDIR_TAYLOR - return zsappend3 (zsystem, "X.", zsimple); -#endif - - default: -#if DEBUG > 0 - ulog (LOG_FATAL, "zsfind_file: Can't happen"); -#endif /* DEBUG */ - return NULL; - } - /*NOTREACHED*/ -} - -/* Get the status of a system. */ - -/*ARGSUSED*/ -boolean -fsysdep_get_status (qsys, qret) - const struct ssysteminfo *qsys; - struct sstatus *qret; -{ - const char *zname; - FILE *e; - char *zline; - char *zend, *znext; - boolean fbad; - int istat; - - zname = zsappend (".Status", qsys->zname); - e = fopen (zname, "r"); - if (e == NULL) - { - if (errno != ENOENT) - { - ulog (LOG_ERROR, "fopen (%s): %s", zname, strerror (errno)); - return FALSE; - } - zline = NULL; - } - else - { - zline = zfgets (e, FALSE); - (void) fclose (e); - } - - if (zline == NULL) - { - /* There is either no status file for this system, or it's been - truncated, so fake a good status. */ - qret->ttype = STATUS_COMPLETE; - qret->cretries = 0; - qret->ilast = 0; - qret->cwait = 0; - return TRUE; - } - - /* It turns out that scanf is not used much in this program, so for - the benefit of small computers we avoid linking it in. This is - basically - - sscanf (zline, "%d %d %ld %d", &qret->ttype, &qret->cretries, - &qret->ilast, &qret->cwait); - - except that it's done with strtol. */ - - fbad = FALSE; - istat = (int) strtol (zline, &zend, 10); - if (zend == zline) - fbad = TRUE; - - /* On some systems it may be appropriate to map system dependent status - values on to our status values. Perhaps someday. */ - - if (istat < 0 || istat >= (int) STATUS_VALUES) - istat = (int) STATUS_COMPLETE; - qret->ttype = (enum tstatus_type) istat; - znext = zend; - qret->cretries = (int) strtol (znext, &zend, 10); - if (zend == znext) - fbad = TRUE; - znext = zend; - qret->ilast = strtol (znext, &zend, 10); - if (zend == znext) - fbad = TRUE; - znext = zend; - qret->cwait = (int) strtol (znext, &zend, 10); - if (zend == znext) - fbad = TRUE; - - xfree ((pointer) zline); - - if (fbad) - { - ulog (LOG_ERROR, "Bad format of status file for %s", qsys->zname); - return FALSE; - } - - return TRUE; -} - -/* Set the status of a remote system. We assume the system is locked - when this is called. */ - -/*ARGSUSED*/ -boolean -fsysdep_set_status (qsys, qset) - const struct ssysteminfo *qsys; - const struct sstatus *qset; -{ - const char *zname; - FILE *e; - int istat; - - zname = zsappend (".Status", qsys->zname); - - e = esysdep_fopen (zname, TRUE, FALSE, TRUE); - if (e == NULL) - return FALSE; - istat = (int) qset->ttype; - - /* On some systems it may be appropriate to map istat onto a system - dependent number. Perhaps someday. */ - - fprintf (e, "%d %d %ld %d %s %s\n", istat, qset->cretries, - qset->ilast, qset->cwait, azStatus[(int) qset->ttype], - qsys->zname); - if (fclose (e) != 0) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - return FALSE; - } - - return TRUE; -} - -/* Get the real name of a spool file. */ - -const char * -zsysdep_spool_file_name (qsys, zfile) - const struct ssysteminfo *qsys; - const char *zfile; -{ - return zsfind_file (zfile, qsys->zname); -} - -/* Expand a file name on the local system. The qsys argument is only - used to determine which public directory to use. */ - -const char * -zsysdep_real_file_name (qsys, zfile, zname) - const struct ssysteminfo *qsys; - const char *zfile; - const char *zname; -{ - const char *ztry; - char *zlook; - - if (zfile[0] == '/') - ztry = zfile; - else if (zfile[0] == '~') - { - const char *z; - char *zcopy; - - z = zstilde_expand (qsys, zfile); - zcopy = (char *) alloca (strlen (z) + 1); - strcpy (zcopy, z); - ztry = zcopy; - } - else - { - const char *zpub, *z; - char *zcopy; - - /* Put the file in the public directory. */ - if (qsys == NULL || qsys->zpubdir == NULL) - zpub = zPubdir; - else - zpub = qsys->zpubdir; - z = zsappend (zpub, zfile); - zcopy = (char *) alloca (strlen (z) + 1); - strcpy (zcopy, z); - ztry = zcopy; - } - - /* If we don't have a file name to use within a directory, or we - haven't named a directory, we use what we've got so far. If the - name ends in a '/', it is assumed to name a directory. */ - - if (zname == NULL) - return zscopy (ztry); - - if (ztry[strlen (ztry) - 1] != '/') - { - if (! fsdirectory_exists (ztry)) - return zscopy (ztry); - } - else - { - char *zcopy; - int clen; - - clen = strlen (ztry); - zcopy = (char *) alloca (clen + 1); - strcpy (zcopy, ztry); - zcopy[clen - 1] = '\0'; - ztry = zcopy; - } - - /* Get a name out of zname and tag it on. */ - - zlook = strrchr (zname, '/'); - if (zlook != NULL) - zname = zlook + 1; - - return zsappend (ztry, zname); -} - -/* Return a file name within a directory. */ - -const char * -zsysdep_in_dir (zdir, zfile) - const char *zdir; - const char *zfile; -{ - if (fsdirectory_exists (zdir)) - return zsappend (zdir, zfile); - else - return zdir; -} - -/* Open a file to send to another system, and return the mode and - the size. */ - -/*ARGSUSED*/ -openfile_t -esysdep_open_send (qsys, zfile, fcheck, zuser, pimode, pcbytes, pfgone) - const struct ssysteminfo *qsys; - const char *zfile; - boolean fcheck; - const char *zuser; - unsigned int *pimode; - long *pcbytes; - boolean *pfgone; -{ - struct stat s; - openfile_t e; - int o; - - if (pfgone != NULL) - *pfgone = FALSE; - - if (fsdirectory_exists (zfile)) - { - ulog (LOG_ERROR, "%s: is a directory", zfile); - return EFILECLOSED; - } -#if USE_STDIO - e = fopen (zfile, BINREAD); - if (e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno)); - if (pfgone != NULL && errno == ENOENT) - *pfgone = TRUE; - return NULL; - } - o = fileno (e); -#else - e = open (zfile, O_RDONLY, 0); - if (e == -1) - { - ulog (LOG_ERROR, "open (%s): %s", zfile, strerror (errno)); - if (pfgone != NULL && errno == ENOENT) - *pfgone = TRUE; - return -1; - } - o = e; -#endif - - if (fstat (o, &s) == -1) - { - ulog (LOG_ERROR, "fstat: %s", strerror (errno)); - s.st_mode = 0666; - } - - /* We have to recheck the file permission, although we probably - checked it already, because otherwise there would be a window in - which somebody could change the contents of a symbolic link to - point to some file which was only readable by uucp. */ - if (fcheck) - { - if (! fsuser_access (&s, R_OK, zuser)) - { - ulog (LOG_ERROR, "%s: %s", zfile, strerror (EACCES)); - (void) ffileclose (e); - return EFILECLOSED; - } - } - - *pimode = s.st_mode & 0777; - *pcbytes = s.st_size; - return e; -} - -/* Get a temporary file name. */ - -/*ARGSUSED*/ -const char * -zstemp_file (qsys) - const struct ssysteminfo *qsys; -{ - static int icount; - char *zret; - -#if SPOOLDIR_V2 | SPOOLDIR_BSD42 - { - static char ab[sizeof "TM.12345.123"]; - - sprintf (ab, "TM.%05d.%03d", getpid (), icount); - zret = ab; - } -#endif -#if SPOOLDIR_BSD43 | SPOOLDIR_ULTRIX | SPOOLDIR_TAYLOR - { - static char ab[sizeof ".Temp/TM.12345.123"]; - - sprintf (ab, ".Temp/TM.%05d.%03d", getpid (), icount); - zret = ab; - } -#endif -#if SPOOLDIR_BNU - { - static char *z; - static int calc; - int cneed; - - cneed = strlen (qsys->zname) + sizeof "/TM.12345.123"; - if (cneed > calc) - { - xfree ((pointer) z); - z = (char *) xmalloc (cneed); - calc = cneed; - } - sprintf (z, "%s/TM.%05d.%03d", qsys->zname, getpid (), icount); - zret = z; - } -#endif - - ++icount; - - return zret; -} - -/* Open a temporary file to receive into. This should, perhaps, check - that we have write permission on the receiving directory, but it - doesn't. It is supposed to set *pcbytes to the size of the largest - file that can be accepted. */ - -/*ARGSUSED*/ -openfile_t -esysdep_open_receive (qsys, zto, pztemp, pcbytes) - const struct ssysteminfo *qsys; - const char *zto; - const char **pztemp; - long *pcbytes; -{ - const char *z; - int o; - openfile_t e; - long c1, c2; - char *zcopy, *zslash; - - z = zstemp_file (qsys); - - o = creat (z, IPRIVATE_FILE_MODE); - - if (o == -1) - { - if (errno == ENOENT) - { - if (! fsysdep_make_dirs (z, FALSE)) - return EFILECLOSED; - o = creat (z, IPRIVATE_FILE_MODE); - } - if (o == -1) - { - ulog (LOG_ERROR, "creat (%s): %s", z, strerror (errno)); - return EFILECLOSED; - } - } - -#if USE_STDIO - e = fdopen (o, (char *) BINWRITE); - - if (e == NULL) - { - ulog (LOG_ERROR, "fdopen (%s): %s", z, strerror (errno)); - (void) close (o); - (void) remove (z); - return NULL; - } -#else - e = o; -#endif - - *pztemp = z; - - /* Try to determine the amount of free space available for the - temporary file and for the final destination. This code is - mostly from David MacKenzie's df program. */ - - c1 = (long) -1; - c2 = (long) -1; - - zcopy = (char *) alloca (strlen (zto) + 1); - strcpy (zcopy, zto); - zslash = strrchr (zcopy, '/'); - if (zslash != NULL) - *zslash = '\0'; - else - { - zcopy[0] = '.'; - zcopy[1] = '\0'; - } - - { -#ifdef FS_STATVFS - struct statvfs s; - - if (statvfs (z, &s) >= 0) - c1 = (long) s.f_bavail * (long) s.f_frsize; - if (statvfs (zcopy, &s) >= 0) - c2 = (long) s.f_bavail * (long) s.f_frsize; -#endif -#ifdef FS_USG_STATFS - struct statfs s; - - /* This structure has an f_bsize field, but on many systems - f_bfree is measured in 512 byte blocks. On some systems, - f_bfree is measured in f_bsize byte blocks. Rather than - overestimate the amount of free space, this code assumes that - f_bfree is measuring 512 byte blocks. */ - - if (statfs (z, &s, sizeof s, 0) >= 0) - c1 = (long) s.f_bfree * (long) 512; - if (statfs (zcopy, &s, sizeof s, 0) >= 0) - c2 = (long) s.f_bfree * (long) 512; -#endif -#ifdef FS_MNTENT - struct statfs s; - - if (statfs (z, &s) == 0) - c1 = (long) s.f_bavail * (long) s.f_bsize; - if (statfs (zcopy, &s) == 0) - c2 = (long) s.f_bavail * (long) s.f_bsize; -#endif -#ifdef FS_GETMNT - struct fs_data s; - - if (statfs (z, &s) == 1) - c1 = (long) s.fd_req.bfreen * (long) 1024; - if (statfs (zcopy, &s) == 1) - c2 = (long) s.fd_req.bfreen * (long) 1024; -#endif -#ifdef FS_STATFS - struct statfs s; - - if (statfs (z, &s) >= 0) - c1 = (long) s.f_bavail * (long) s.f_fsize; - if (statfs (zcopy, &s) >= 0) - c2 = (long) s.f_bavail * (long) s.f_fsize; -#endif -#ifdef FS_USTAT - struct stat sstat; - struct ustat s; - - if (fstat (o, &sstat) == 0 - && ustat (sstat.st_dev, &s) == 0) - c1 = (long) s.f_tfree * (long) 512; - if (stat (zcopy, &sstat) == 0 - && ustat (sstat.st_dev, &s) == 0) - c2 = (long) s.f_tfree * (long) 512; -#endif - } - - if (c1 == (long) -1) - *pcbytes = c2; - else if (c2 == (long) -1) - *pcbytes = c1; - else if (c1 < c2) - *pcbytes = c1; - else - *pcbytes = c2; - - return e; -} - -/* After the temporary file has been completely written out, the file - is closed and this routine is called to move it into its final - location. If we fail, we must remove the temporary file. */ - -boolean -fsysdep_move_file (zorig, zto, imode, fcheck, zuser) - const char *zorig; - const char *zto; - unsigned int imode; - boolean fcheck; - const char *zuser; -{ - DEBUG_MESSAGE2 (DEBUG_SPOOLDIR, - "fsysdep_move_file: Moving %s to %s", zorig, zto); - - /* Unless and until we add an option to change the ownership of the - file, the only information we want from the mode is whether the - file is executable or not. It would be dumb to create a file - with mode 0600, for example, since the owner will be uucp and the - recipient will not be able to read it. If we do not have an - absolute path to the file, which means that it is being moved - somewhere in the spool directory, we don't change the mode; in - general, the files in the spool directory should not be - publically readable. */ - - if (*zto != '/') - imode = 0; - - if (imode != 0) - { - if ((imode & 0111) != 0) - imode = S_IRWXU | S_IRWXG | S_IRWXO; - else - imode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - } - - /* Optionally make sure that zuser has write access on the - directory. We only check files that are not in the spool - directory. */ - if (fcheck && *zto == '/') - { - char *zcopy; - char *zslash; - struct stat s; - - zcopy = (char *) alloca (strlen (zto) + 1); - strcpy (zcopy, zto); - zslash = strrchr (zcopy, '/'); - if (zslash == zcopy) - zslash[1] = '\0'; - else - *zslash = '\0'; - - if (stat (zcopy, &s) != 0) - { - ulog (LOG_ERROR, "stat (%s): %s", zcopy, strerror (errno)); - (void) remove (zorig); - return FALSE; - } - if (! fsuser_access (&s, W_OK, zuser)) - { - ulog (LOG_ERROR, "%s: %s", zcopy, strerror (EACCES)); - (void) remove (zorig); - return FALSE; - } - - /* A malicious user now has a few milliseconds to change a - symbolic link to a directory uucp has write permission on but - the user does not (the obvious choice being /usr/lib/uucp). - The only certain method I can come up with to close this race - is to fork an suid process which takes on the users identity - and does the actual copy. This is sufficiently high overhead - that I'm not going to do it. */ - } - - /* We try to use rename to move the file. */ - - if (rename (zorig, zto) == 0) - { - /* We must set the correct file mode, but don't worry if it doesn't - work. There should be an option for setting the owner, as - well. */ - if (imode != 0) - (void) chmod (zto, imode); - return TRUE; - } - - /* If this file is in the spool directory, make sure all directories - exist. */ - if (*zto != '/' && errno == ENOENT) - { - if (! fsysdep_make_dirs (zto, FALSE)) - { - (void) remove (zorig); - return FALSE; - } - if (rename (zorig, zto) == 0) - { - if (imode != 0) - (void) chmod (zto, imode); - return TRUE; - } - } - - /* If we can't link across devices, we must copy the file by hand. */ - if (errno != EXDEV) - { - ulog (LOG_ERROR, "rename (%s, %s): %s", zorig, zto, - strerror (errno)); - (void) remove (zorig); - return FALSE; - } - - /* If the destination file is not in the spool directory, any - necessary directories should already have been made. */ - if (! fcopy_file (zorig, zto, FALSE, *zto != '/')) - { - (void) remove (zorig); - return FALSE; - } - - if (remove (zorig) < 0) - ulog (LOG_ERROR, "remove (%s): %s", zorig, strerror (errno)); - - if (imode != 0) - (void) chmod (zto, imode); - - return TRUE; -} - -/* Truncate a file to zero length. If this fails, it closes and - removes the file. We support a number of different means of - truncation, which is probably a waste of time since this function - is currently only called when the 'f' protocol resends a file. */ - -#if HAVE_FTRUNCATE -#undef HAVE_LTRUNC -#define HAVE_LTRUNC 0 -#endif - -#if ! HAVE_FTRUNCATE && ! HAVE_LTRUNC -#ifdef F_CHSIZE -#define HAVE_F_CHSIZE 1 -#else /* ! defined (F_CHSIZE) */ -#ifdef F_FREESP -#define HAVE_F_FREESP 1 -#endif /* defined (F_FREESP) */ -#endif /* ! defined (F_CHSIZE) */ -#endif /* ! HAVE_FTRUNCATE && ! HAVE_LTRUNC */ - -openfile_t -esysdep_truncate (e, zname) - openfile_t e; - const char *zname; -{ - int o; - -#if HAVE_FTRUNCATE || HAVE_LTRUNC || HAVE_F_CHSIZE || HAVE_F_FREESP - int itrunc; - - if (! ffilerewind (e)) - { - ulog (LOG_ERROR, "rewind: %s", strerror (errno)); - (void) ffileclose (e); - (void) remove (zname); - return EFILECLOSED; - } - -#if USE_STDIO - o = fileno (e); -#else - o = e; -#endif - -#if HAVE_FTRUNCATE - itrunc = ftruncate (o, 0); -#endif -#if HAVE_LTRUNC - itrunc = ltrunc (o, (long) 0, SEEK_SET); -#endif -#if HAVE_F_CHSIZE - itrunc = fcntl (o, F_CHSIZE, (off_t) 0); -#endif -#if HAVE_F_FREESP - /* This selection is based on an implementation of ftruncate by - kucharsk@Solbourne.com (William Kucharski). */ - { - struct flock fl; - - fl.l_whence = 0; - fl.l_len = 0; - fl.l_start = 0; - fl.l_type = F_WRLCK; - - itrunc = fcntl (o, F_FREESP, &fl); - } -#endif - - if (itrunc != 0) - { -#if HAVE_FTRUNCATE - ulog (LOG_ERROR, "ftruncate: %s", strerror (errno)); -#endif -#ifdef HAVE_LTRUNC - ulog (LOG_ERROR, "ltrunc: %s", strerror (errno)); -#endif -#ifdef HAVE_F_CHSIZE - ulog (LOG_ERROR, "fcntl (F_CHSIZE): %s", strerror (errno)); -#endif -#ifdef HAVE_F_FREESP - ulog (LOG_ERROR, "fcntl (F_FREESP): %s", strerror (errno)); -#endif - - (void) ffileclose (e); - (void) remove (zname); - return EFILECLOSED; - } - - return e; -#else /* ! (HAVE_FTRUNCATE || HAVE_LTRUNC) */ - (void) ffileclose (e); - (void) remove (zname); - - o = creat (zname, IPRIVATE_FILE_MODE); - - if (o == -1) - { - ulog (LOG_ERROR, "open (%s): %s", zname, strerror (errno)); - return EFILECLOSED; - } - -#if USE_STDIO - e = fdopen (o, (char *) BINWRITE); - - if (e == NULL) - { - ulog (LOG_ERROR, "fdopen (%s): %s", zname, strerror (errno)); - (void) close (o); - (void) remove (zname); - return NULL; - } -#else /* ! USE_STDIO */ - e = o; -#endif /* ! USE_STDIO */ - - return e; -#endif /* ! HAVE_FTRUNCATE */ -} - -/* Lock something. If the fspooldir argument is TRUE, the argument is - a file name relative to the spool directory; otherwise the argument - is a simple file name which should be created in the system lock - directory (under BNU this is /etc/locks). */ - -/*ARGSUSED*/ -boolean -fsdo_lock (zlock, fspooldir) - const char *zlock; - boolean fspooldir; -{ - const char *zpath, *zslash; - int cslash; - char *ztempfile; - char abtempfile[20]; - int o; - pid_t ime; -#if HAVE_V2_LOCKFILES - int i; -#else - char ab[12]; -#endif - int cwrote; - const char *zerr; - boolean fret; - -#ifdef LOCKDIR - if (fspooldir) - zpath = zlock; - else - { - char *zalc; - - zalc = (char *) alloca (sizeof LOCKDIR + strlen (zlock) + 1); - sprintf (zalc, "%s/%s", LOCKDIR, zlock); - zpath = zalc; - } -#else /* ! defined (LOCKDIR) */ - zpath = zlock; -#endif - - ime = getpid (); - - /* We do the actual lock by creating a file and then linking it to - the final file name we want. This avoids race conditions due to - one process checking the file before we have finished writing it, - and also works even if we are somehow running as root. - - First, create the file in the right directory (we must create the - file in the same directory since otherwise we might attempt a - cross-device link). */ - zslash = strrchr (zpath, '/'); - if (zslash == NULL) - cslash = 0; - else - cslash = zslash - zpath + 1; - - ztempfile = (char *) alloca (cslash + sizeof "TMP1234567890"); - strncpy (ztempfile, zpath, cslash); - sprintf (abtempfile, "TMP%010d", (int) ime); - ztempfile[cslash] = '\0'; - strcat (ztempfile, abtempfile); - - o = creat (ztempfile, IPUBLIC_FILE_MODE); - if (o < 0) - { - if (errno == ENOENT) - { - if (! fsysdep_make_dirs (ztempfile, FALSE)) - return FALSE; - o = creat (ztempfile, IPUBLIC_FILE_MODE); - } - if (o < 0) - { - ulog (LOG_ERROR, "open (%s): %s", ztempfile, strerror (errno)); - return FALSE; - } - } - -#if HAVE_V2_LOCKFILES - i = ime; - cwrote = write (o, &i, sizeof i); -#else - sprintf (ab, "%10d\n", (int) ime); - cwrote = write (o, ab, strlen (ab)); -#endif - - zerr = NULL; - if (cwrote < 0) - zerr = "write"; - if (close (o) < 0) - zerr = "close"; - if (zerr != NULL) - { - ulog (LOG_ERROR, "%s (%s): %s", zerr, ztempfile, strerror (errno)); - (void) remove (ztempfile); - return FALSE; - } - - /* Now try to link the file we just created to the lock file that we - want. If it fails, try reading the existing file to make sure - the process that created it still exists. We do this in a loop - to make it easy to retry if the old locking process no longer - exists. */ - - fret = TRUE; - o = -1; - zerr = NULL; - - while (link (ztempfile, zpath) != 0) - { - int cgot; - int ipid; - - fret = FALSE; - - if (errno != EEXIST) - { - ulog (LOG_ERROR, "link (%s, %s): %s", ztempfile, zpath, - strerror (errno)); - break; - } - - o = open (zpath, O_RDWR, 0); - if (o < 0) - { - zerr = "open"; - break; - } - - /* The race starts here. See below for a discussion. */ - -#if HAVE_V2_LOCKFILES - cgot = read (o, &i, sizeof i); -#else - cgot = read (o, ab, sizeof ab - 1); -#endif - - if (cgot < 0) - { - zerr = "read"; - break; - } - -#if HAVE_V2_LOCKFILES - ipid = i; -#else - ab[cgot] = '\0'; - ipid = atoi (ab); -#endif - - /* If the process still exists, we will get EPERM rather than - ESRCH. We then return FALSE to indicate that we cannot make - the lock. */ - if (kill (ipid, 0) == 0 || errno == EPERM) - break; - - /* On NFS, the link might have actually succeeded even though we - got a failure return. This can happen if the original - acknowledgement was lost or delayed and the operation was - retried. In this case the pid will be our own. This - introduces a rather improbable race condition: if a stale - lock was left with our process ID in it, and another process - just did the above kill but has not yet changed the lock file - to hold its own process ID, we could start up and make it all - the way to here and think we have the lock. I'm not going to - worry about this possibility. */ - if (ipid == ime) - { - fret = TRUE; - break; - } - - ulog (LOG_ERROR, "Found stale lock %s held by process %d", - zpath, ipid); - - /* This is a stale lock, created by a process that no longer - exists. - - Now we could remove the file, but that would be a race - condition. If we were interrupted any time after we did the - read until we did the remove, another process could get in, - open the file, find that it was a stale lock, remove the file - and create a new one. When we woke up we would remove the - file the other process just created. - - These files are being generated partially for the benefit of - cu, and it would be nice to avoid the race however cu avoids - it, so that the programs remain compatible. Unfortunately, - nobody seems to know how cu avoids the race, or even if it - tries to avoid it at all. - - There are a few ways to avoid the race. We could use kernel - locking primitives, but they may not be available. We could - link to a special file name, but if that file were left lying - around then no stale lock could ever be broken (Henry Spencer - would think this was a good thing). - - Instead I've implemented the following procedure: seek to the - start of the file, write our pid into it, sleep for five - seconds, and then make sure our pid is still there. Anybody - who checks the file while we're asleep will find our pid - there and fail the lock. The only race will come from - another process which has done the read by the time we do our - write. That process will then have five seconds to do its - own write. When we wake up, we'll notice that our pid is no - longer in the file, and retry the lock from the beginning. - - This relies on the atomicity of write(2). If it possible for - the writes of two processes to be interleaved, the two - processes could livelock. POSIX unfortunately leaves this - case explicitly undefined; however, given that the write is - of less than a disk block, it's difficult to imagine an - interleave occurring. - - Note that this is still a race. If it takes the second - process more than five seconds to do the kill, the lseek, and - the write, both processes will think they have the lock. - Perhaps the length of time to sleep should be configurable. - Even better, perhaps I should add a configuration option to - use a permanent lock file, which eliminates any race and - forces the installer to be aware of the existence of the - permanent lock file. - - For the benefit of cu, we stat the file after the sleep, to - make sure some cu program hasn't deleted it for us. */ - - if (lseek (o, (off_t) 0, SEEK_SET) != 0) - { - zerr = "lseek"; - break; - } - -#if HAVE_V2_LOCKFILES - i = ime; - cwrote = write (o, &i, sizeof i); -#else - sprintf (ab, "%10d\n", (int) ime); - cwrote = write (o, ab, strlen (ab)); -#endif - - if (cwrote < 0) - { - zerr = "write"; - break; - } - - (void) sleep (5); - - if (lseek (o, (off_t) 0, SEEK_SET) != 0) - { - zerr = "lseek"; - break; - } - -#if HAVE_V2_LOCKFILES - cgot = read (o, &i, sizeof i); -#else - cgot = read (o, ab, sizeof ab - 1); -#endif - - if (cgot < 0) - { - zerr = "read"; - break; - } - -#if HAVE_V2_LOCKFILES - ipid = i; -#else - ab[cgot] = '\0'; - ipid = atoi (ab); -#endif - - if (ipid == ime) - { - struct stat sfile, sdescriptor; - - /* It looks like we have the lock. Do the final stat - check. */ - - if (stat (zpath, &sfile) != 0) - { - if (errno != ENOENT) - { - zerr = "stat"; - break; - } - /* Loop around and try again. */ - } - else - { - if (fstat (o, &sdescriptor) < 0) - { - zerr = "fstat"; - break; - } - - if (sfile.st_ino == sdescriptor.st_ino - && sfile.st_dev == sdescriptor.st_dev) - { - /* Close the file before assuming we've succeeded to - pick up any trailing errors. */ - if (close (o) < 0) - { - zerr = "close"; - break; - } - - o = -1; - - /* We have the lock. */ - fret = TRUE; - break; - } - } - } - - /* Loop around and try the lock again. We keep doing this until - the lock file holds a pid that exists. */ - - (void) close (o); - o = -1; - fret = TRUE; - } - - if (zerr != NULL) - ulog (LOG_ERROR, "%s (%s): %s", zerr, zpath, strerror (errno)); - - if (o >= 0) - (void) close (o); - - /* It would be nice if we could leave the temporary file around for - future calls, but considering that we create lock files in - various different directories it's probably more trouble than - it's worth. */ - if (remove (ztempfile) != 0) - ulog (LOG_ERROR, "remove (%s): %s", ztempfile, strerror (errno)); - - return fret; -} - -/* Unlock something. The fspooldir argument is as in fsdo_lock. */ - -boolean -fsdo_unlock (zlock, fspooldir) - const char *zlock; - boolean fspooldir; -{ - const char *zpath; - -#ifdef LOCKDIR - if (fspooldir) - zpath = zlock; - else - { - char *zalc; - - zalc = (char *) alloca (sizeof LOCKDIR + strlen (zlock) + 1); - sprintf (zalc, "%s/%s", LOCKDIR, zlock); - zpath = zalc; - } -#else /* ! defined (LOCKDIR) */ - zpath = zlock; -#endif - - if (remove (zpath) == 0 - || errno == ENOENT) - return TRUE; - else - { - ulog (LOG_ERROR, "remove (%s): %s", zpath, strerror (errno)); - return FALSE; - } -} - -/* Lock a remote system. */ - -/*ARGSUSED*/ -boolean -fsysdep_lock_system (qsys) - const struct ssysteminfo *qsys; -{ - char *z; - - z = (char *) alloca (strlen (qsys->zname) + sizeof "LCK.."); - sprintf (z, "LCK..%.8s", qsys->zname); - return fsdo_lock (z, FALSE); -} - -/* Unlock a remote system. */ - -/*ARGSUSED*/ -boolean -fsysdep_unlock_system (qsys) - const struct ssysteminfo *qsys; -{ - char *z; - - z = (char *) alloca (strlen (qsys->zname) + sizeof "LCK.."); - sprintf (z, "LCK..%.8s", qsys->zname); - return fsdo_unlock (z, FALSE); -} - -/* Get a new command sequence number (this is not a sequence number to - be used for communicating with another system, but a sequence - number to be used when generating the name of a command file). - The sequence number is placed into zseq, which should be five - characters long. */ - -#define CSEQLEN (4) - -static boolean -fscmd_seq (zsystem, zseq) - const char *zsystem; - char *zseq; -{ - int ctries; - const char *zfile; - int o; - int i; - - /* Lock the sequence file. This may not be correct for all systems, - but it only matters if the system UUCP and this UUCP are running - at the same time. */ - - ctries = 0; - while (! fsdo_lock ("LCK..SEQ", TRUE)) - { - ++ctries; - if (ctries > 10) - { - ulog (LOG_ERROR, "Can't lock sequence file"); - return FALSE; - } - sleep (1); - } - -#if SPOOLDIR_V2 | SPOOLDIR_BSD42 | SPOOLDIR_BSD43 - zfile = "SEQF"; -#endif -#if SPOOLDIR_BNU - { - char *zalc; - - zalc = (char *) alloca (strlen (zsystem) + sizeof ".Sequence/"); - sprintf (zalc, ".Sequence/%s", zsystem); - zfile = zalc; - } -#endif -#if SPOOLDIR_ULTRIX - if (fsultrix_has_spool (zsystem)) - { - char *zalc; - - zalc = (char *) alloca (strlen (zsystem) + sizeof "sys//.SEQF"); - sprintf (zalc, "sys/%s/.SEQF", zsystem); - zfile = zalc; - } - else - zfile = "sys/DEFAULT/.SEQF"; -#endif /* SPOOLDIR_ULTRIX */ -#if SPOOLDIR_TAYLOR - { - char *zalc; - - zalc = (char *) alloca (strlen (zsystem) + sizeof "/SEQF"); - sprintf (zalc, "%s/SEQF", zsystem); - zfile = zalc; - } -#endif /* SPOOLDIR_TAYLOR */ - -#ifdef O_CREAT - o = open (zfile, O_RDWR | O_CREAT, IPUBLIC_FILE_MODE); -#else - o = open (zfile, O_RDWR); - if (o < 0 && errno == ENOENT) - { - o = creat (zfile, IPUBLIC_FILE_MODE); - if (o >= 0) - { - (void) close (o); - o = open (zfile, O_RDWR); - } - } -#endif - - if (o < 0) - { - if (errno == ENOENT) - { - if (! fsysdep_make_dirs (zfile, FALSE)) - { - (void) fsdo_unlock ("LCK..SEQ", TRUE); - return FALSE; - } -#ifdef O_CREAT - o = open (zfile, O_RDWR | O_CREAT, IPUBLIC_FILE_MODE); -#else - o = creat (zfile, IPUBLIC_FILE_MODE); - if (o >= 0) - { - (void) close (o); - o = open (zfile, O_RDWR); - } -#endif - } - if (o < 0) - { - ulog (LOG_ERROR, "open (%s): %s", zfile, strerror (errno)); - (void) fsdo_unlock ("LCK..SEQ", TRUE); - return FALSE; - } - } - - if (read (o, zseq, CSEQLEN) != CSEQLEN) - strcpy (zseq, "0000"); - zseq[CSEQLEN] = '\0'; - - /* We must add one to the sequence number and return the new value. - On Ultrix, arbitrary characters are allowed in the sequence number. - On other systems, the sequence number apparently must be in hex. */ - -#if SPOOLDIR_V2 | SPOOLDIR_BSD42 | SPOOLDIR_BSD43 | SPOOLDIR_BNU - i = strtol (zseq, (char **) NULL, 16); - ++i; - if (i > 0xffff) - i = 0; - /* The sprintf argument has CSEQLEN built into it. */ - sprintf (zseq, "%04x", (unsigned int) i); -#endif /* SPOOLDIR_V2 | SPOOLDIR_BSD42 | SPOOLDIR_BSD43 | SPOOLDIR_BNU */ -#if SPOOLDIR_ULTRIX | SPOOLDIR_TAYLOR - for (i = CSEQLEN - 1; i >= 0; i--) - { - if (zseq[i] == 'z') - { - zseq[i] = '0'; - continue; - } - - if (zseq[i] == '9') - zseq[i] = 'A'; - else if (zseq[i] == 'Z') - zseq[i] = 'a'; - else if ((zseq[i] >= '0' && zseq[i] < '9') - || (zseq[i] >= 'A' && zseq[i] < 'Z') - || (zseq[i] >= 'a' && zseq[i] < 'z')) - ++zseq[i]; - else - { - /* A bad character was found; reset the entire sequence - number. */ - ulog (LOG_ERROR, - "Bad sequence number %s for system %s", - zseq, zsystem); - strcpy (zseq, "0000"); - } - - break; - } -#endif /* SPOOLDIR_ULTRIX | SPOOLDIR_TAYLOR */ - - if (lseek (o, (off_t) 0, SEEK_SET) < 0 - || write (o, zseq, CSEQLEN) != CSEQLEN - || close (o) < 0) - { - ulog (LOG_ERROR, "lseek or write or close: %s", strerror (errno)); - (void) close (o); - (void) fsdo_unlock ("LCK..SEQ", TRUE); - return FALSE; - } - - (void) fsdo_unlock ("LCK..SEQ", TRUE); - - return TRUE; -} - -/* Get the name of a command or data file for a remote system. The - btype argument should be C for a command file or D for a data file. - If the grade of a data file is X, it is assumed that this is going - to become an execute file on some other system. The zsystem - argument is the system that the file will be transferred to. The - ztname argument will be set to a file name that could be passed to - zsysdep_spool_file_name. The zdname argument, if not NULL, will be - set to a data file name appropriate for the remote system. The - zxname argument, if not NULL, will be set to the name of an execute - file on the remote system. None of the names will be more than 14 - characters long. */ - -static const char * -zsfile_name (btype, zsystem, bgrade, ztname, zdname, zxname) - int btype; - const char *zsystem; - int bgrade; - char *ztname; - char *zdname; - char *zxname; -{ - char abseq[CSEQLEN + 1]; - char absimple[11 + CSEQLEN]; - const char *zname; - struct stat s; - - do - { - if (! fscmd_seq (zsystem, abseq)) - return NULL; - - if (btype == 'C') - { -#if ! SPOOLDIR_TAYLOR - sprintf (absimple, "C.%.7s%c%s", zsystem, bgrade, abseq); -#else - sprintf (absimple, "C.%c%s", bgrade, abseq); -#endif - } - else if (btype == 'D') - { -#if ! SPOOLDIR_TAYLOR - /* Note that a data file uses the local system's name. */ - sprintf (absimple, "D.%.7s%c%s", zLocalname, bgrade, abseq); -#else - if (bgrade == 'X') - sprintf (absimple, "D.X%s", abseq); - else - sprintf (absimple, "D.%s", abseq); -#endif - } -#if DEBUG > 0 - else - ulog (LOG_FATAL, "zsfile_name: Can't happen (%d)", btype); -#endif - - zname = zsfind_file (absimple, zsystem); - if (zname == NULL) - return NULL; - } - while (stat (zname, &s) == 0); - - if (ztname != NULL) - strcpy (ztname, absimple); - - if (zdname != NULL) - sprintf (zdname, "D.%.7s%c%s", zLocalname, bgrade, abseq); - - if (zxname != NULL) - sprintf (zxname, "X.%.7s%c%s", zLocalname, bgrade, abseq); - - return zname; -} - -/* Given a set of commands to execute for a remote system, create a - command file holding them. This creates a single command file - holding all the commands passed in. It returns a jobid. */ - -const char * -zsysdep_spool_commands (qsys, bgrade, ccmds, pascmds) - const struct ssysteminfo *qsys; - int bgrade; - int ccmds; - const struct scmd *pascmds; -{ - const char *z; - FILE *e; - int i; - const struct scmd *q; - const char *zjobid; - -#if DEBUG > 0 - if (! FGRADE_LEGAL (bgrade)) - ulog (LOG_FATAL, "Bad grade %d", bgrade); -#endif - - z = zsfile_name ('C', qsys->zname, bgrade, (char *) NULL, (char *) NULL, - (char *) NULL); - if (z == NULL) - return NULL; - - e = esysdep_fopen (z, FALSE, FALSE, TRUE); - if (e == NULL) - return NULL; - - for (i = 0, q = pascmds; i < ccmds; i++, q++) - { - switch (q->bcmd) - { - case 'S': - fprintf (e, "S %s %s %s -%s %s 0%o %s\n", q->zfrom, q->zto, - q->zuser, q->zoptions, q->ztemp, q->imode, - q->znotify); - break; - case 'R': - fprintf (e, "R %s %s %s -%s\n", q->zfrom, q->zto, q->zuser, - q->zoptions); - break; - case 'X': - fprintf (e, "X %s %s %s -%s\n", q->zfrom, q->zto, q->zuser, - q->zoptions); - break; - default: - ulog (LOG_ERROR, - "zsysdep_spool_commands: Unrecognized type %d", - q->bcmd); - (void) fclose (e); - (void) remove (z); - return NULL; - } - } - - if (fclose (e) != 0) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - (void) remove (z); - return NULL; - } - - zjobid = zsfile_to_jobid (qsys, z); - if (zjobid == NULL) - (void) remove (z); - return zjobid; -} - -/* Return a name to use for a data file to be copied to another - system. The name returned will be for a real file. The ztname - argument, if not NULL, will be set to a name that could be passed - to zsysdep_spool_file_name to get back the return value of this - function. The zdname argument, if not NULL, will be set to a name - that the file could be given on another system. The zxname - argument, if not NULL, will be set to a name for an execute file on - another system. */ - -const char * -zsysdep_data_file_name (qsys, bgrade, ztname, zdname, zxname) - const struct ssysteminfo *qsys; - int bgrade; - char *ztname; - char *zdname; - char *zxname; -{ - return zsfile_name ('D', qsys->zname, bgrade, ztname, zdname, zxname); -} - -/* Return a name for an execute file to be created locally. This is - used by uux to execute a command locally with remote files. */ - -const char * -zsysdep_xqt_file_name () -{ - char abseq[CSEQLEN + 1]; - char absx[11 + CSEQLEN]; - const char *zname; - struct stat s; - - while (TRUE) - { - if (! fscmd_seq (zLocalname, abseq)) - return NULL; - - sprintf (absx, "X.%.7sX%s", zLocalname, abseq); - - zname = zsfind_file (absx, zLocalname); - if (zname == NULL) - return NULL; - if (stat (zname, &s) != 0) - break; - } - - return zname; -} - -/* Start getting a wildcarded file spec. We use the shell to expand - the wildcard. */ - -static char *zSwildcard_alloc; -static char *zSwildcard; - -boolean -fsysdep_wildcard_start (qsys, zfile) - const struct ssysteminfo *qsys; - const char *zfile; -{ - char *zcmd; - const char *azargs[4]; - FILE *e; - pid_t ipid; - - zSwildcard_alloc = NULL; - zSwildcard = NULL; - - if (*zfile == '~') - { - zfile = zstilde_expand (qsys, zfile); - if (zfile == NULL) - return FALSE; - } - - if (*zfile != '/') - { - ulog (LOG_ERROR, "Relative path not permitted in wildcard"); - return FALSE; - } - - zcmd = (char *) alloca (sizeof ECHO_PROGRAM + sizeof " " + strlen (zfile)); - sprintf (zcmd, "%s %s", ECHO_PROGRAM, zfile); - - azargs[0] = "/bin/sh"; - azargs[1] = "-c"; - azargs[2] = zcmd; - azargs[3] = NULL; - - e = espopen (azargs, TRUE, &ipid); - if (e == NULL) - { - ulog (LOG_ERROR, "espopen: %s", strerror (errno)); - return FALSE; - } - - zSwildcard_alloc = zfgets (e, FALSE); - - if (iswait ((unsigned long) ipid, ECHO_PROGRAM) != 0) - { - xfree ((pointer) zSwildcard_alloc); - return FALSE; - } - - if (zSwildcard_alloc == NULL) - return FALSE; - - DEBUG_MESSAGE1 (DEBUG_EXECUTE, - "fsysdep_wildcard_start: got \"%s\"", - zSwildcard_alloc); - - zSwildcard = zSwildcard_alloc; - - return TRUE; -} - -/* Get the next wildcard spec. */ - -/*ARGSUSED*/ -const char * -zsysdep_wildcard (qsys, zfile) - const struct ssysteminfo *qsys; - const char *zfile; -{ - char *zret; - - if (zSwildcard_alloc == NULL || zSwildcard == NULL) - return NULL; - - zret = zSwildcard; - - while (*zSwildcard != '\0' && ! isspace (BUCHAR (*zSwildcard))) - ++zSwildcard; - - if (*zSwildcard == '\0') - zSwildcard = NULL; - else - { - *zSwildcard = '\0'; - ++zSwildcard; - while (*zSwildcard != '\0' && isspace (BUCHAR (*zSwildcard))) - ++zSwildcard; - if (*zSwildcard == '\0') - zSwildcard = NULL; - } - - return zret; -} - -/* Finish up getting wildcard specs. */ - -boolean -fsysdep_wildcard_end () -{ - xfree ((pointer) zSwildcard_alloc); - zSwildcard_alloc = NULL; - zSwildcard = NULL; - return TRUE; -} - -/* Get the current conversation sequence number for a remote system, - and increment it for next time. The conversation sequence number - is kept in a file named .SQ in the spool directory for that system. - This is not compatible with other versions of UUCP, but it makes - more sense to me. The sequence file is only used if specified in - the information for that system. In V2, the file - /usr/lib/uucp/SQFILE is searched for each system to get a - conversation sequence number. */ - -long -isysdep_get_sequence (qsys) - const struct ssysteminfo *qsys; -{ - FILE *e; - const char *zname; - struct stat s; - long iseq; - - /* This will only be called when the system is locked anyhow, so there - is no need to use a separate lock for the conversation sequence - file. */ - - zname = zsappend (".Sequence", qsys->zname); - - iseq = 0; - if (stat (zname, &s) == 0) - { - boolean fok; - char *zline; - - /* The file should only be readable and writable by uucp. */ - - if ((s.st_mode & (S_IRWXG | S_IRWXO)) != 0) - { - ulog (LOG_ERROR, - "Bad file protection for conversation sequence file"); - return -1; - } - - /* The file already exists, so we don't have to worry about - its protection. */ - e = fopen (zname, "r+"); - if (e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", zname, strerror (errno)); - return -1; - } - - zline = zfgets (e, FALSE); - - fok = TRUE; - if (zline == NULL) - fok = FALSE; - else - { - char *zend; - - iseq = strtol (zline, &zend, 10); - if (zend == zline) - fok = FALSE; - xfree ((pointer) zline); - } - - if (! fok) - { - ulog (LOG_ERROR, "Bad format for conversation sequence file"); - return -1; - } - - rewind (e); - } - else - { - e = esysdep_fopen (zname, FALSE, FALSE, TRUE); - if (e == NULL) - return -1; - } - - ++iseq; - - fprintf (e, "%ld", iseq); - - if (fclose (e) != 0) - { - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - return -1; - } - - return iseq; -} - -/* Get the Unix file mode of a file. */ - -unsigned int -isysdep_file_mode (zfile) - const char *zfile; -{ - struct stat s; - - if (stat (zfile, &s) != 0) - { - ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno)); - return 0; - } - -#if S_IRWXU != 0700 - #error Files modes need to be translated -#endif - - /* We can't return 0, since that indicate an error. */ - if ((s.st_mode & 0777) == 0) - return 0400; - - return s.st_mode & 0777; -} - -/* Translate a file name and an associated system into a job id. - These job ids are used by uustat. We use the system name attached - to the grade and sequence number. */ - -const char * -zsfile_to_jobid (qsys, zfile) - const struct ssysteminfo *qsys; - const char *zfile; -{ - char *zid; - - zid = (char *) alloca (strlen (qsys->zname) + CSEQLEN + 2); - sprintf (zid, "%s%s", qsys->zname, - zfile + strlen (zfile) - CSEQLEN - 1); - - return zscopy (zid); -} - -/* Turn a job id back into a file name. */ - -const char * -zsjobid_to_file (zid, pzsystem) - const char *zid; - const char **pzsystem; -{ - int clen; - char abend[CSEQLEN + 2]; - static char *zsys; - static int csyslen; - char abname[CSEQLEN + 11]; - - clen = strlen (zid); - strcpy (abend, zid + clen - CSEQLEN - 1); - - if (clen - CSEQLEN > csyslen) - { - zsys = (char *) xrealloc ((pointer) zsys, clen - CSEQLEN); - csyslen = clen - CSEQLEN; - } - - strncpy (zsys, zid, clen - CSEQLEN - 1); - zsys[clen - CSEQLEN - 1] = '\0'; - if (pzsystem != NULL) - *pzsystem = zsys; - - /* This must correspond to zsfile_name. */ -#if ! SPOOLDIR_TAYLOR - sprintf (abname, "C.%.7s%s", zsys, abend); -#else - sprintf (abname, "C.%s", abend); -#endif - - return zsfind_file (abname, zsys); -} - -#if ! HAVE_RENAME - -/* This is currently the only file which calls rename, so I've put my - fake rename function in here. */ - -static int -rename (zfrom, zto) - const char *zfrom; - const char *zto; -{ - /* Try to make the link without removing the old file first. */ - if (link (zfrom, zto) == -1) - { - if (errno != EEXIST) - return -1; - - /* Assume that this will never be called with zfrom the same as - zto. If it could be, this is wrong. */ - (void) remove (zto); - - if (link (zfrom, zto) == -1) - return -1; - } - - return remove (zfrom); -} - -#endif /* ! HAVE_RENAME */ - -/* - Local variables: - mode:c - End: - */ diff --git a/gnu/libexec/uucp/sys4.unx b/gnu/libexec/uucp/sys4.unx deleted file mode 100644 index 88820ccb4e16..000000000000 --- a/gnu/libexec/uucp/sys4.unx +++ /dev/null @@ -1,769 +0,0 @@ -/* sys4.unx - The system dependent routines to read command files for Unix. - These routines are used by uucico to get the commands it should - execute. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: sys4.unx,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.17 1992/03/12 19:56:10 ian - Debugging based on types rather than number - - Revision 1.16 1992/03/11 00:18:50 ian - Save temporary file if file send fails - - Revision 1.15 1992/03/04 21:34:12 ian - Johan Vromans: set *pbgrade correctly in fsysdep_has_work - - Revision 1.14 1992/03/04 02:13:23 ian - Bob Denny: warn if we can't open a command file - - Revision 1.13 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.12 1992/02/20 04:18:59 ian - Added uustat - - Revision 1.11 1992/02/09 03:14:48 ian - Added HAVE_OLD_DIRECTORIES for systems without readdir routines - - Revision 1.10 1992/02/08 20:11:47 ian - Work data was freed up incorrectly if a file transfer failed in the middle - - Revision 1.9 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.8 1992/01/29 18:28:34 ian - Patrick Smith: fixed casts in iswork_cmp - - Revision 1.7 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.6 1991/12/20 00:10:39 ian - Sort the earlier files so that bsearch can work correctly - - Revision 1.5 1991/12/19 01:09:38 ian - David Nugent: rescan work directory before quitting - - Revision 1.4 1991/11/16 00:45:50 ian - If fsysdep_work frees qSwork_file, it must set it to NULL - - Revision 1.3 1991/11/15 21:58:02 ian - Move ssline definition out of ssfile - - Revision 1.2 1991/11/08 04:47:19 ian - Hannu Strang: don't check system name for BNU work files - - Revision 1.1 1991/09/10 19:45:50 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char sys4_unx_rcsid[] = "$Id: sys4.unx,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#include "system.h" -#include "sysdep.h" - -#if HAVE_OPENDIR -#if HAVE_DIRENT_H -#include -#else /* ! HAVE_DIRENT_H */ -#include -#define dirent direct -#endif /* ! HAVE_DIRENT_H */ -#endif /* HAVE_OPENDIR */ - -/* External functions. */ -extern int fclose (); - -/* Local functions. */ - -static const char *zswork_directory P((const char *zsystem)); -static boolean fswork_file P((const char *zsystem, const char *zfile, - char *pbgrade)); - -/* These functions can support multiple actions going on at once. - This allows the UUCP package to send and receive multiple files at - the same time. This is a very flexible feature, but I'm not sure - it will actually be used all that much. - - The ssfile structure holds a command file name and all the lines - read in from that command file. The union within the ssline - structure initially holds a line from the file and then holds a - pointer back to the ssfile structure; a pointer to this union is - used as a sequence pointer. The ztemp entry of the ssline - structure holds the name of a temporary file to delete, if any. */ - -#define CFILELINES (10) - -struct ssline -{ - char *zline; - struct ssfile *qfile; - char *ztemp; -}; - -struct ssfile -{ - char *zfile; - int clines; - int cdid; - struct ssline aslines[CFILELINES]; -}; - -/* Static variables for the work scan. */ - -static char **azSwork_files; -static int cSwork_files; -static int iSwork_file; -static struct ssfile *qSwork_file; - -/* Given a system name, return a directory to search for work. */ - -static const char * -zswork_directory (zsystem) - const char *zsystem; -{ -#if SPOOLDIR_V2 - return "."; -#endif /* SPOOLDIR_V2 */ -#if SPOOLDIR_BSD42 | SPOOLDIR_BSD43 - return "C."; -#endif /* SPOOLDIR_BSD42 | SPOOLDIR_BSD43 */ -#if SPOOLDIR_BNU - return zsystem; -#endif /* SPOOLDIR_BNU */ -#if SPOOLDIR_ULTRIX - static int c; - static char *z; - int cwant; - - cwant = strlen (zsystem); - if (cwant < sizeof "DEFAULT" - 1) - cwant = sizeof "DEFAULT" - 1; - cwant += sizeof "sys//C."; - if (c < cwant) - { - xfree ((pointer) z); - z = (char *) xmalloc (cwant); - c = cwant; - } - - if (fsultrix_has_spool (zsystem)) - sprintf (z, "sys/%s/C.", zsystem); - else - strcpy (z, "sys/DEFAULT/C."); - return z; -#endif /* SPOOLDIR_ULTRIX */ -#if SPOOLDIR_TAYLOR - static int c; - static char *z; - int cwant; - - cwant = strlen (zsystem) + sizeof "/C."; - if (c < cwant) - { - xfree ((pointer) z); - z = (char *) xmalloc (cwant); - c = cwant; - } - sprintf (z, "%s/C.", zsystem); - return z; -#endif /* SPOOLDIR_TAYLOR */ -} - -/* See whether a file name from the directory returned by - zswork_directory is really a command for a particular system. - Return the command grade. */ - -/*ARGSUSED*/ -static boolean -fswork_file (zsystem, zfile, pbgrade) - const char *zsystem; - const char *zfile; - char *pbgrade; -{ -#if SPOOLDIR_V2 || SPOOLDIR_BSD42 || SPOOLDIR_BSD43 || SPOOLDIR_ULTRIX - int cfilesys, csys; - - /* The file name should be C.ssssssgqqqq, where g is exactly one - letter and qqqq is exactly four numbers. The system name may be - truncated to six or seven characters. The system name of the - file must match the system name we're looking for, since there - could be work files for several systems in one directory. */ - if (zfile[0] != 'C' || zfile[1] != '.') - return FALSE; - csys = strlen (zsystem); - cfilesys = strlen (zfile) - 7; - if (csys != cfilesys - && (csys < 6 || (cfilesys != 6 && cfilesys != 7))) - return FALSE; - *pbgrade = zfile[cfilesys + 2]; - return strncmp (zfile + 2, zsystem, cfilesys) == 0; -#endif /* V2 || BSD42 || BSD43 || ULTRIX */ -#if SPOOLDIR_BNU - int clen; - - /* The file name should be C.ssssssgqqqq where g is exactly one - letter and qqqq is exactly four numbers or letters. We don't - check the system name, because it is guaranteed by the directory - we are looking in and AIX uucp sets it to the local system rather - than the remote one. */ - if (zfile[0] != 'C' || zfile[1] != '.') - return FALSE; - clen = strlen (zfile); - if (clen < 7) - return FALSE; - *pbgrade = zfile[clen - 5]; - return TRUE; -#endif /* SPOOLDIR_BNU */ -#if SPOOLDIR_TAYLOR - /* We don't keep the system name in the file name, since that - forces truncation. Our file names are always C.gqqqq. */ - *pbgrade = zfile[2]; - return (zfile[0] == 'C' - && zfile[1] == '.' - && strlen (zfile) == 7); -#endif /* SPOOLDIR_TAYLOR */ -} - -/* A comparison function to look through the list of file names. */ - -static int iswork_cmp P((constpointer pkey, constpointer pdatum)); - -static int -iswork_cmp (pkey, pdatum) - constpointer pkey; - constpointer pdatum; -{ - const char * const *pzkey = (const char * const *) pkey; - const char * const *pzdatum = (const char * const *) pdatum; - - return strcmp (*pzkey, *pzdatum); -} - -/* See whether there is any work to do for a particular system. If - any work is found, *pbgrade is set to highest grade found. */ - -/*ARGSUSED*/ -boolean -fsysdep_has_work (qsys, pbgrade) - const struct ssysteminfo *qsys; - char *pbgrade; -{ - boolean fret; - const char *zdir; - DIR *qdir; - struct dirent *qentry; - - fret = FALSE; - *pbgrade = BGRADE_LOW; - - if (azSwork_files != NULL && iSwork_file < cSwork_files) - { - int i; - - fret = TRUE; - for (i = iSwork_file; i < cSwork_files; i++) - { - char bgrade; - - (void) fswork_file (qsys->zname, azSwork_files[i], &bgrade); - if (igradecmp (bgrade, *pbgrade) < 0) - *pbgrade = bgrade; - } - } - - zdir = zswork_directory (qsys->zname); - if (zdir == NULL) - return FALSE; - - qdir = opendir ((char *) zdir); - if (qdir == NULL) - return FALSE; - while ((qentry = readdir (qdir)) != NULL) - { - char bgrade; - char *zname; - - /* If this is a work file and we haven't seen it before, return - TRUE. Also, determine the grade to return. */ - zname = qentry->d_name; - if (fswork_file (qsys->zname, qentry->d_name, &bgrade) - && (azSwork_files == NULL - || bsearch ((pointer) &zname, - (pointer) azSwork_files, - cSwork_files, sizeof (char *), - iswork_cmp) == NULL)) - { - fret = TRUE; - if (igradecmp (bgrade, *pbgrade) < 0) - *pbgrade = bgrade; - } - } - closedir (qdir); - return fret; -} - -/* Initialize the work scan. We have to read all the files in the - work directory, so that we can sort them by work grade. The bgrade - argument is the minimum grade to consider. We don't want to return - files that we have already considered; usysdep_get_work_free will - clear the data out when we are done with the system. This returns - FALSE on error. */ - -#define CWORKFILES (10) - -/*ARGSUSED*/ -boolean -fsysdep_get_work_init (qsys, bgrade) - const struct ssysteminfo *qsys; - int bgrade; -{ - const char *zdir; - DIR *qdir; - struct dirent *qentry; - int chad; - int callocated; - - zdir = zswork_directory (qsys->zname); - if (zdir == NULL) - return FALSE; - - qdir = opendir ((char *) zdir); - if (qdir == NULL) - { - if (errno != ENOENT) - ulog (LOG_ERROR, "opendir (%s): %s", zdir, strerror (errno)); - return FALSE; - } - - chad = cSwork_files; - callocated = cSwork_files; - - /* Sort the files we already know about so that we can check the new - ones with bsearch. It would be faster to use a hash table, and - the code should be probably be changed. The sort done at the end - of this function does not suffice because it only includes the - files added last time, and does not sort the entire array. Some - (bad) qsort implementations are very slow when given a sorted - array, which causes particularly bad effects here. */ - if (chad > 0) - qsort ((pointer) azSwork_files, chad, sizeof (char *), iswork_cmp); - - while ((qentry = readdir (qdir)) != NULL) - { - char bfilegrade; - char *zname; - - zname = qentry->d_name; - if (fswork_file (qsys->zname, qentry->d_name, &bfilegrade) - && (azSwork_files == NULL - || bsearch ((pointer) &zname, - (pointer) azSwork_files, - chad, sizeof (char *), - iswork_cmp) == NULL)) - { - if (igradecmp (bgrade, bfilegrade) < 0) - continue; - - DEBUG_MESSAGE1 (DEBUG_SPOOLDIR, - "fsysdep_get_work_init: Found %s", - qentry->d_name); - - if (cSwork_files >= callocated) - { - callocated += CWORKFILES; - azSwork_files = - (char **) xrealloc ((pointer) azSwork_files, - callocated * sizeof (char *)); - } - - azSwork_files[cSwork_files] = xstrdup (qentry->d_name); - ++cSwork_files; - } - } - - closedir (qdir); - - /* Sorting the files alphabetically will get the grades in the - right order, since all the file prefixes are the same. */ - - if (cSwork_files > chad) - qsort ((pointer) (azSwork_files + chad), cSwork_files - chad, - sizeof (char *), iswork_cmp); - - return TRUE; -} - -/* Get the next work entry for a system. This must parse the next - line in the next work file. The type of command is set into - qcmd->bcmd; if there are no more commands we call - fsysdep_get_work_init to rescan, in case any came in since the last - call. If there are still no commands, qcmd->bcmd is set to 'H'. - Each field in the structure is set to point to a spot in an - malloced string. The only time we use the grade here is when - calling fsysdep_get_work_init to rescan. */ - -boolean -fsysdep_get_work (qsys, bgrade, qcmd) - const struct ssysteminfo *qsys; - int bgrade; - struct scmd *qcmd; -{ - const char *zdir; - - if (qSwork_file != NULL && qSwork_file->cdid >= qSwork_file->clines) - qSwork_file = NULL; - - if (azSwork_files == NULL) - { - qcmd->bcmd = 'H'; - return TRUE; - } - - zdir = NULL; - - /* This loop continues until a line is returned. */ - while (TRUE) - { - /* This loop continues until a file is opened and read in. */ - while (qSwork_file == NULL) - { - FILE *e; - struct ssfile *qfile; - int iline, callocated; - char *zline; - const char *zname; - - /* Read all the lines of a command file into memory. */ - - do - { - if (iSwork_file >= cSwork_files) - { - /* Rescan the work directory. */ - if (! fsysdep_get_work_init (qsys, bgrade)) - return FALSE; - if (iSwork_file >= cSwork_files) - { - qcmd->bcmd = 'H'; - return TRUE; - } - } - - if (zdir == NULL) - { - zdir = zswork_directory (qsys->zname); - if (zdir == NULL) - return FALSE; - } - - zname = zsappend (zdir, azSwork_files[iSwork_file]); - - ++iSwork_file; - - if (zname == NULL) - return FALSE; - - e = fopen (zname, "r"); - if (e == NULL) - ulog (LOG_ERROR, "fopen (%s): %s", zname, - strerror (errno)); - } - while (e == NULL); - - qfile = (struct ssfile *) xmalloc (sizeof (struct ssfile)); - callocated = CFILELINES; - iline = 0; - - while ((zline = zfgets (e, FALSE)) != NULL) - { - if (iline >= callocated) - { - /* The sizeof (struct ssfile) includes CFILELINES - entries already, so using callocated * sizeof - (struct ssline) will give us callocated * - CFILELINES entries. */ - qfile = - ((struct ssfile *) - xrealloc ((pointer) qfile, - (sizeof (struct ssfile) + - (callocated * sizeof (struct ssline))))); - callocated += CFILELINES; - } - qfile->aslines[iline].zline = zline; - qfile->aslines[iline].qfile = NULL; - qfile->aslines[iline].ztemp = NULL; - iline++; - } - - if (fclose (e) != 0) - ulog (LOG_ERROR, "fclose: %s", strerror (errno)); - - if (iline == 0) - { - /* There was nothing in the file; remove it and look - for the next one. */ - xfree ((pointer) qfile); - if (remove (zname) != 0) - ulog (LOG_ERROR, "remove (%s): %s", zname, - strerror (errno)); - } - else - { - qfile->zfile = xstrdup (zname); - qfile->clines = iline; - qfile->cdid = 0; - qSwork_file = qfile; - } - } - - /* This loop continues until all the lines from the current file - are used up, or a line is returned. */ - while (TRUE) - { - int iline; - - if (qSwork_file->cdid >= qSwork_file->clines) - { - /* We don't want to free qSwork_file here, since it must - remain until all the lines have been completed. It - is freed in fsysdep_did_work. */ - qSwork_file = NULL; - /* Go back to the main loop which finds another file. */ - break; - } - - iline = qSwork_file->cdid; - ++qSwork_file->cdid; - - /* Now parse the line into a command. */ - - if (! fparse_cmd (qSwork_file->aslines[iline].zline, qcmd)) - { - ulog (LOG_ERROR, "Bad line in command file %s", - qSwork_file->zfile); - xfree ((pointer) qSwork_file->aslines[iline].zline); - qSwork_file->aslines[iline].zline = NULL; - continue; - } - - if (qcmd->bcmd == 'S') - { - const char *zreal; - - zreal = zsysdep_spool_file_name (qsys, qcmd->ztemp); - if (zreal == NULL) - { - xfree ((pointer) qSwork_file->aslines[iline].zline); - qSwork_file->aslines[iline].zline = NULL; - return FALSE; - } - - qSwork_file->aslines[iline].ztemp = xstrdup (zreal); - } - - qSwork_file->aslines[iline].qfile = qSwork_file; - qcmd->pseq = (pointer)(&qSwork_file->aslines[iline]); - - return TRUE; - } - } -} - -/* When a command has been complete, fsysdep_did_work is called. The - sequence entry was set above to be the address of an aslines - structure whose pfile entry points to the ssfile corresponding to - this file. We can then check whether all the lines have been - completed (they will have been if the pfile entry is NULL) and - remove the file if they have been. This means that we only remove - a command file if we manage to complete every transfer it specifies - in a single UUCP session. I don't know if this is how regular UUCP - works. */ - -boolean -fsysdep_did_work (pseq) - pointer pseq; -{ - struct ssfile *qfile; - struct ssline *qline; - int i; - - qline = (struct ssline *) pseq; - - xfree ((pointer) qline->zline); - qline->zline = NULL; - - qfile = qline->qfile; - qline->qfile = NULL; - - /* Remove the temporary file, if there is one. It really doesn't - matter if this fails, and not checking the return value lets us - attempt to remove D.0 or whatever an unused temporary file is - called without complaining. */ - if (qline->ztemp != NULL) - (void) remove (qline->ztemp); - - /* If not all the lines have been returned from bsysdep_get_work, - we can't remove the file yet. */ - if (qfile->cdid < qfile->clines) - return TRUE; - - /* See whether all the commands have been completed. */ - for (i = 0; i < qfile->clines; i++) - if (qfile->aslines[i].qfile != NULL) - return TRUE; - - /* All commands have finished. */ - if (remove (qfile->zfile) != 0) - { - ulog (LOG_ERROR, "remove (%s): %s", qfile->zfile, - strerror (errno)); - return FALSE; - } - - xfree ((pointer) qfile->zfile); - xfree ((pointer) qfile); - - if (qfile == qSwork_file) - qSwork_file = NULL; - - return TRUE; -} - -/* Free up the results of a work scan, when we're done with this - system. */ - -/*ARGSUSED*/ -void -usysdep_get_work_free (qsys) - const struct ssysteminfo *qsys; -{ - if (azSwork_files != NULL) - { - int i; - - for (i = 0; i < cSwork_files; i++) - xfree ((pointer) azSwork_files[i]); - xfree ((pointer) azSwork_files); - azSwork_files = NULL; - cSwork_files = 0; - iSwork_file = 0; - } - if (qSwork_file != NULL) - { - int i; - - xfree ((pointer) qSwork_file->zfile); - for (i = 0; i < qSwork_file->cdid; i++) - { - xfree ((pointer) qSwork_file->aslines[i].zline); - xfree ((pointer) qSwork_file->aslines[i].ztemp); - } - for (i = qSwork_file->cdid; i < qSwork_file->clines; i++) - xfree ((pointer) qSwork_file->aslines[i].zline); - xfree ((pointer) qSwork_file); - qSwork_file = NULL; - } -} - -/* Save the temporary file used by a send command, and return an - informative message to mail to the requestor. This is called when - a file transfer failed, to make sure that the potentially valuable - file is not completely lost. */ - -const char * -zsysdep_save_temp_file (pseq) - pointer pseq; -{ - struct ssline *qline = (struct ssline *) pseq; - char *zto, *zslash; - int cwant; - static char *zbuf; - static int cbuf; - - if (! fsysdep_file_exists (qline->ztemp)) - return NULL; - - zslash = strrchr (qline->ztemp, '/'); - if (zslash == NULL) - zslash = qline->ztemp; - else - ++zslash; - - zto = (char *) alloca (sizeof PRESERVEDIR + 1 + strlen (zslash)); - sprintf (zto, "%s/%s", PRESERVEDIR, zslash); - - /* We must make sure that the PRESERVEDIR directory exists, since - fsysdep_move_file won't create it for us. */ - - if (! fsdirectory_exists (PRESERVEDIR)) - { - if (mkdir (PRESERVEDIR, IDIRECTORY_MODE) != 0) - { - ulog (LOG_ERROR, "mkdir (%s): %s", PRESERVEDIR, - strerror (errno)); - return "Could not create preservation directory"; - } - } - - if (! fsysdep_move_file (qline->ztemp, zto, 0, FALSE, - (const char *) NULL)) - return "Could not move file to preservation directory"; - - cwant = sizeof "File saved as\n\t" + strlen (zSpooldir) + 1 + strlen (zto); - if (cwant > cbuf) - { - zbuf = (char *) xrealloc ((pointer) zbuf, cwant); - cbuf = cwant; - } - - sprintf (zbuf, "File saved as\n\t%s/%s", zSpooldir, zto); - return zbuf; -} - -/* Get the jobid of a work file. This is needed by uustat. */ - -const char * -zsysdep_jobid (qsys, pseq) - const struct ssysteminfo *qsys; - pointer pseq; -{ - return zsfile_to_jobid (qsys, ((struct ssline *) pseq)->qfile->zfile); -} - -/* - Local variables: - mode:c - End: - */ diff --git a/gnu/libexec/uucp/sys5.unx b/gnu/libexec/uucp/sys5.unx deleted file mode 100644 index a3bf8453a7e6..000000000000 --- a/gnu/libexec/uucp/sys5.unx +++ /dev/null @@ -1,877 +0,0 @@ -/* sys5.unx - The system dependent routines to read execute files for Unix, - and to execute programs. These routines are used by uuxqt. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: sys5.unx,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.40 1992/03/17 03:15:40 ian - Pass command to fsysdep_execute as first element of argument array - - Revision 1.39 1992/03/16 19:44:45 ian - Cast result of alloca - - Revision 1.38 1992/03/15 01:54:46 ian - All execs are now done in isspawn, all waits are done in iswait - - Revision 1.37 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.36 1992/03/11 22:06:37 ian - Marty Shannon: added max-uuxqts command - - Revision 1.35 1992/03/11 17:04:53 ian - Jon Zeeff: retry execution later if temporary failure - - Revision 1.34 1992/03/11 02:09:57 ian - Franc,ois Pinard: retry fork several times before giving up - - Revision 1.33 1992/02/29 01:06:59 ian - Chip Salzenberg: recheck file permissions before sending - - Revision 1.32 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.31 1992/02/25 15:58:29 ian - Bob Denny: don't warn when trying to open a non-directory - - Revision 1.30 1992/02/24 20:07:43 ian - John Theus: some systems don't have - - Revision 1.29 1992/02/24 04:58:47 ian - Only permit files to be received into directories that are world-writeable - - Revision 1.28 1992/02/23 19:50:50 ian - Handle READ and WRITE in Permissions correctly - - Revision 1.27 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.26 1992/02/18 04:40:06 ian - Michael Nolan: allow full command path from remote, not just basename - - Revision 1.25 1992/02/09 03:14:48 ian - Added HAVE_OLD_DIRECTORIES for systems without readdir routines - - Revision 1.24 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.23 1992/01/15 19:42:42 ian - No longer need to define wait status macros here - - Revision 1.22 1992/01/15 19:40:35 ian - Mike Park: handle HAVE_UNION_WAIT correctly and completely - - Revision 1.21 1992/01/13 06:11:39 ian - David Nugent: can't declare open or fcntl - - Revision 1.20 1992/01/04 21:43:24 ian - Chip Salzenberg: added ALLOW_FILENAME_ARGUMENTS to permit them - - Revision 1.19 1992/01/04 04:12:54 ian - David J. Fiander: make sure execution arguments are not bad file names - - Revision 1.18 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.17 1991/12/29 00:55:23 ian - Monty Solomon: added HAVE_UNION_WAIT - - Revision 1.16 1991/12/22 22:14:19 ian - Monty Solomon: added HAVE_UNISTD_H configuration parameter - - Revision 1.15 1991/12/21 21:34:14 ian - Moved fsysdep_file_exists from sys5.unx to sys1.unx - - Revision 1.14 1991/12/15 01:58:49 ian - Oleg Tabarovsky: don't abandon processing because of an opendir error - - Revision 1.13 1991/12/11 04:17:39 ian - Call fsysdep_make_dirs correctly if chdir (XQTDIR) fails - - Revision 1.12 1991/12/11 03:59:19 ian - Create directories when necessary; don't just assume they exist - - Revision 1.11 1991/12/07 03:41:44 ian - David J. Fiander: if execve fails, fall back on /bin/sh - - Revision 1.10 1991/12/01 02:23:12 ian - Niels Baggesen: don't multiply include - - Revision 1.9 1991/11/26 01:45:42 ian - Marty Shannon: configuration option to not include - - Revision 1.8 1991/11/22 06:05:57 ian - Gregory Gulik: fix wait status macro definitions - - Revision 1.7 1991/11/16 00:35:43 ian - Case constant arguments to opendir - - Revision 1.6 1991/11/07 20:52:33 ian - Chip Salzenberg: pass command as single argument to /bin/sh - - Revision 1.5 1991/11/07 19:32:28 ian - Chip Salzenberg: allow LOCKDIR, and check that locking process exists - - Revision 1.4 1991/09/19 16:15:58 ian - Chip Salzenberg: configuration option for permitting execution via sh - - Revision 1.3 1991/09/19 15:51:01 ian - Chip Salzenberg: pass TZ environment variable to execution process - - Revision 1.2 1991/09/19 03:06:04 ian - Chip Salzenberg: put BNU temporary files in system's directory - - Revision 1.1 1991/09/10 19:45:50 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char sys5_unx_rcsid[] = "$Id: sys5.unx,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#if USE_STDIO && HAVE_UNISTD_H -#include -#endif - -#include "system.h" -#include "sysdep.h" - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#if HAVE_OPENDIR -#if HAVE_DIRENT_H -#include -#else /* ! HAVE_DIRENT_H */ -#include -#define dirent direct -#endif /* ! HAVE_DIRENT_H */ -#endif /* HAVE_OPENDIR */ - -/* We need F_OK. */ - -#ifndef F_OK -#define F_OK (0) -#endif - -/* Get a value for EX_TEMPFAIL. */ - -#if HAVE_SYSEXITS_H -#include -#endif - -#ifndef EX_TEMPFAIL -#define EX_TEMPFAIL 75 -#endif - -/* External functions. */ -extern int access (), close (), dup2 (), chdir (); -extern void _exit (); - -/* Under the V2 or BSD42 spool directory scheme, all execute files are - in the main spool directory. Under the BSD43 scheme, they are all - in the directory X.. Under the BNU scheme, they are in directories - named after systems. Under the ULTRIX scheme, they are in X. - subdirectories of subdirectories of sys. Under the TAYLOR scheme, - they are all in the subdirectory X. of a directory named after - the system. - - This means that for BNU, ULTRIX or TAYLOR, we have to search - directories of directories. */ - -#if SPOOLDIR_V2 | SPOOLDIR_BSD42 -#define ZDIR "." -#define SUBDIRS 0 -#endif -#if SPOOLDIR_BNU | SPOOLDIR_TAYLOR -#define ZDIR "." -#define SUBDIRS 1 -#endif -#if SPOOLDIR_ULTRIX -#define ZDIR "sys" -#define SUBDIRS 1 -#endif -#if SPOOLDIR_BSD43 -#define ZDIR "X." -#define SUBDIRS 0 -#endif - -/* Static variables for the execute file scan. */ - -static DIR *qSxqt_topdir; -#if ! SUBDIRS -static const char *zSdir; -#else /* SUBDIRS */ -static char *zSdir; -static DIR *qSxqt_dir; -static char *zSsystem; -#endif /* SUBDIRS */ - -/* Initialize the scan for execute files. The function - usysdep_get_xqt_free will clear the data out when we are done with - the system. This returns FALSE on error. */ - -/*ARGSUSED*/ -boolean -fsysdep_get_xqt_init () -{ - usysdep_get_xqt_free (); - - qSxqt_topdir = opendir ((char *) ZDIR); - if (qSxqt_topdir == NULL) - { - if (errno == ENOENT) - return TRUE; - ulog (LOG_ERROR, "opendir (%s): %s", ZDIR, strerror (errno)); - return FALSE; - } - - return TRUE; -} - -/* Return the name of the next execute file to read and process. If - this returns NULL, *pferr must be checked. If will be TRUE on - error, FALSE if there are no more files. On a successful return - *pzsystem will be set to the system for which the execute file was - created. */ - -const char * -zsysdep_get_xqt (pzsystem, pferr) - const char **pzsystem; - boolean *pferr; -{ - *pferr = FALSE; - - if (qSxqt_topdir == NULL) - return NULL; - - /* This loop continues until we find a file. */ - while (TRUE) - { - DIR *qdir; - struct dirent *q; - -#if ! SUBDIRS - zSdir = ZDIR; - qdir = qSxqt_topdir; -#else /* SUBDIRS */ - /* This loop continues until we find a subdirectory to read. */ - while (qSxqt_dir == NULL) - { - struct dirent *qtop; - char *zset; - - qtop = readdir (qSxqt_topdir); - if (qtop == NULL) - { - (void) closedir (qSxqt_topdir); - qSxqt_topdir = NULL; - return NULL; - } - - /* No system name may start with a dot (this is enforced by - tisystem in sysinf.c). This allows us to quickly skip - impossible directories. */ - if (qtop->d_name[0] == '.') - continue; - - DEBUG_MESSAGE1 (DEBUG_SPOOLDIR, - "zsysdep_get_xqt: Found %s in top directory", - qtop->d_name); - -#if SPOOLDIR_BNU - zset = qtop->d_name; -#endif -#if SPOOLDIR_ULTRIX - zset = (char *) alloca (strlen (qtop->d_name) + sizeof "sys//X."); - sprintf (zset, "sys/%s/X.", qtop->d_name); -#endif -#if SPOOLDIR_TAYLOR - zset = (char *) alloca (strlen (qtop->d_name) + sizeof "/X."); - sprintf (zset, "%s/X.", qtop->d_name); -#endif - - xfree ((pointer) zSdir); - zSdir = xstrdup (zset); - - xfree ((pointer) zSsystem); - zSsystem = xstrdup (qtop->d_name); - - qSxqt_dir = opendir (zSdir); - - if (qSxqt_dir == NULL - && errno != ENOTDIR - && errno != ENOENT) - ulog (LOG_ERROR, "opendir (%s): %s", zSdir, strerror (errno)); - } - - qdir = qSxqt_dir; -#endif /* SUBDIRS */ - - q = readdir (qdir); - -#if DEBUG > 1 - if (q != NULL) - DEBUG_MESSAGE2 (DEBUG_SPOOLDIR, - "zsysdep_get_xqt: Found %s in subdirectory %s", - q->d_name, zSdir); -#endif - - /* If we've found an execute file, return it. We have to get - the system name, which is easy for BNU or TAYLOR. For other - spool directory schemes, we have to pull it out of the X. - file name; this would be insecure, except that zsfind_file - clobbers the file name to include the real system name. */ - - if (q != NULL - && q->d_name[0] == 'X' - && q->d_name[1] == '.') - { - const char *zret; - -#if SPOOLDIR_BNU | SPOOLDIR_TAYLOR - *pzsystem = zSsystem; -#else - { - static char *zsys = NULL; - static int csys = 0; - int clen; - - clen = strlen (q->d_name) - 7; - if (clen + 1 > csys) - { - zsys = (char *) xrealloc ((pointer) zsys, clen + 1); - csys = clen + 1; - } - strncpy (zsys, q->d_name + 2, clen); - zsys[clen] = '\0'; - - *pzsystem = zsys; - } -#endif - - /* Set *pferr to TRUE in case zsappend returns NULL. */ - *pferr = TRUE; - - zret = zsappend (zSdir, q->d_name); - -#if DEBUG > 1 - if (zret != NULL) - DEBUG_MESSAGE2 (DEBUG_SPOOLDIR, - "zsysdep_get_xqt: Returning %s (system %s)", - zret, *pzsystem); -#endif - - return zret; - } - - /* If we've reached the end of the directory, then if we are - using subdirectories loop around to read the next one, - otherwise we are finished. */ - - if (q == NULL) - { - (void) closedir (qdir); -#if SUBDIRS - qSxqt_dir = NULL; - continue; -#else - qSxqt_topdir = NULL; - return NULL; -#endif - } - } -} - -/* Free up the results of an execute file scan, when we're done with - this system. */ - -/*ARGSUSED*/ -void -usysdep_get_xqt_free () -{ - if (qSxqt_topdir != NULL) - { - (void) closedir (qSxqt_topdir); - qSxqt_topdir = NULL; - } -#if SUBDIRS - if (qSxqt_dir != NULL) - { - (void) closedir (qSxqt_dir); - qSxqt_dir = NULL; - } - xfree ((pointer) zSdir); - zSdir = NULL; - xfree ((pointer) zSsystem); - zSsystem = NULL; -#endif -} - -/* Get the full pathname of the command to execute, given the list of - permitted commands and the allowed path. */ - -const char * -zsysdep_find_command (zcmd, zcmds, zpath, pferr) - const char *zcmd; - const char *zcmds; - const char *zpath; - boolean *pferr; -{ - char *zcopy, *ztok; - - *pferr = TRUE; - - if (strcmp (zcmds, "ALL") != 0) - { - zcopy = (char *) alloca (strlen (zcmds) + 1); - strcpy (zcopy, zcmds); - for (ztok = strtok (zcopy, " "); - ztok != NULL; - ztok = strtok ((char *) NULL, " ")) - { - char *zslash; - - zslash = strrchr (ztok, '/'); - if (zslash != NULL) - ++zslash; - else - zslash = ztok; - if (strcmp (zslash, zcmd) == 0 - || strcmp (ztok, zcmd) == 0) - { - if (*ztok == '/') - { - /* Hack to get two arguments for zsappend. */ - zslash[-1] = '\0'; - return zsappend (ztok, zslash); - } - break; - } - } - - /* If we didn't find this command, get out. */ - if (ztok == NULL) - { - *pferr = FALSE; - return NULL; - } - } - - /* We didn't find an absolute pathname, so we must look through - the path. */ - zcopy = (char *) alloca (strlen (zpath) + 1); - strcpy (zcopy, zpath); - for (ztok = strtok (zcopy, " "); - ztok != NULL; - ztok = strtok ((char *) NULL, " ")) - { - const char *zname; - - zname = zsappend (ztok, zcmd); - if (zname == NULL) - return NULL; - if (access (zname, F_OK) == 0) - return zname; - } - - *pferr = FALSE; - return NULL; -} - -#if ! ALLOW_FILENAME_ARGUMENTS - -/* Check to see whether an argument specifies a file name; if it does, - make sure that the file may legally be sent and/or received. For - Unix, we do not permit any occurrence of "/../" in the name, nor - may it start with "../". Otherwise, if it starts with "/" we check - against the list of permitted files. */ - -boolean -fsysdep_xqt_check_file (qsys, zfile) - const struct ssysteminfo *qsys; - const char *zfile; -{ - if (strncmp (zfile, "../", sizeof "../" - 1) == 0 - || strstr (zfile, "/../") != NULL - || (*zfile == '/' - && (! fin_directory_list (qsys, zfile, qsys->zremote_send, TRUE, - FALSE, (const char *) NULL) - || (qsys->zcalled_remote_send != NULL - && ! fin_directory_list (qsys, zfile, - qsys->zcalled_remote_send, - TRUE, FALSE, - (const char *) NULL)) - || ! fin_directory_list (qsys, zfile, qsys->zremote_receive, - TRUE, FALSE, (const char *) NULL) - || (qsys->zcalled_remote_receive != NULL - && ! fin_directory_list (qsys, zfile, - qsys->zcalled_remote_receive, - TRUE, FALSE, - (const char *) NULL))))) - { - ulog (LOG_ERROR, "Not permitted to refer to file \"%s\"", zfile); - return FALSE; - } - - return TRUE; -} - -#endif /* ! ALLOW_FILENAME_ARGUMENTS */ - -/* Invoke the command specified by an execute file. */ - -/*ARGSUSED*/ -boolean -fsysdep_execute (qsys, zuser, pazargs, zfullcmd, zinput, zoutput, - fshell, pzerror, pftemp) - const struct ssysteminfo *qsys; - const char *zuser; - const char **pazargs; - const char *zfullcmd; - const char *zinput; - const char *zoutput; - boolean fshell; - const char **pzerror; - boolean *pftemp; -{ - int aidescs[3]; - boolean ferr; - pid_t ipid; - int ierr; - int istat; -#if ALLOW_SH_EXECUTION - const char *azshargs[4]; -#endif - - *pzerror = NULL; - *pftemp = FALSE; - - aidescs[0] = SPAWN_NULL; - aidescs[1] = SPAWN_NULL; - aidescs[2] = SPAWN_NULL; - - ferr = FALSE; - - if (zinput != NULL) - { - aidescs[0] = open (zinput, O_RDONLY, 0); - if (aidescs[0] < 0) - { - ulog (LOG_ERROR, "open (%s): %s", zinput, strerror (errno)); - ferr = TRUE; - } - } - - if (! ferr && zoutput != NULL) - { - aidescs[1] = creat (zoutput, IPRIVATE_FILE_MODE); - if (aidescs[1] < 0) - { - ulog (LOG_ERROR, "creat (%s): %s", zoutput, strerror (errno)); - *pftemp = TRUE; - ferr = TRUE; - } - } - - if (! ferr) - { - *pzerror = zstemp_file (qsys); - aidescs[2] = creat (*pzerror, IPRIVATE_FILE_MODE); - if (aidescs[2] < 0) - { - if (errno == ENOENT) - { - if (! fsysdep_make_dirs (*pzerror, FALSE)) - { - *pftemp = TRUE; - ferr = TRUE; - } - else - aidescs[2] = creat (*pzerror, IPRIVATE_FILE_MODE); - } - if (! ferr && aidescs[2] < 0) - { - ulog (LOG_ERROR, "creat (%s): %s", *pzerror, strerror (errno)); - *pftemp = TRUE; - ferr = TRUE; - } - } - } - - if (! fsdirectory_exists (XQTDIR)) - { - char *zcopy; - - /* The fsysdep_make_dirs function needs a trailing slash, - because it only works on file names. */ - zcopy = (char *) alloca (strlen (XQTDIR) + 2); - sprintf (zcopy, "%s/", XQTDIR); - if (! fsysdep_make_dirs (zcopy, FALSE)) - ferr = TRUE; - } - - if (ferr) - { - if (aidescs[0] != SPAWN_NULL) - (void) close (aidescs[0]); - if (aidescs[1] != SPAWN_NULL) - (void) close (aidescs[1]); - if (aidescs[2] != SPAWN_NULL) - (void) close (aidescs[2]); - return FALSE; - } - -#if ALLOW_SH_EXECUTION - if (fshell) - { - azshargs[0] = "/bin/sh"; - azshargs[1] = "-c"; - azshargs[2] = zfullcmd; - azshargs[3] = NULL; - pazargs = azshargs; - } -#else - fshell = FALSE; -#endif - - /* Pass zchdir as XQTDIR, fnosigs as TRUE, fshell as TRUE if we - aren't already using the shell. */ - ipid = isspawn (pazargs, aidescs, FALSE, FALSE, XQTDIR, TRUE, - ! fshell, qsys->zpath, qsys->zname, zuser); - - ierr = errno; - - if (aidescs[0] != SPAWN_NULL) - (void) close (aidescs[0]); - if (aidescs[1] != SPAWN_NULL) - (void) close (aidescs[1]); - if (aidescs[2] != SPAWN_NULL) - (void) close (aidescs[2]); - - if (ipid < 0) - { - ulog (LOG_ERROR, "isspawn: %s", strerror (ierr)); - *pftemp = TRUE; - return FALSE; - } - - istat = iswait ((unsigned long) ipid, "Execution"); - - if (istat == EX_TEMPFAIL) - *pftemp = TRUE; - - return istat == 0; -} - -/* Lock a uuxqt process. */ - -int -isysdep_lock_uuxqt (zcmd) - const char *zcmd; -{ - char ab[14]; - int i; - - if (cMaxuuxqts <= 0) - i = 0; - else - { - int c; - - c = cMaxuuxqts; - if (c >= 10000) - c = 9999; - for (i = 0; i < c; i++) - { - sprintf (ab, "LCK.XQT.%d", i); - if (fsdo_lock (ab, TRUE)) - break; - } - if (i >= c) - return -1; - } - - if (zcmd != NULL) - { - char abcmd[14]; - - sprintf (abcmd, "LXQ.%.9s", zcmd); - abcmd[strcspn (abcmd, " \t/")] = '\0'; - if (! fsdo_lock (abcmd, TRUE)) - { - if (cMaxuuxqts > 0) - (void) fsdo_unlock (ab, TRUE); - return -1; - } - } - - return i; -} - -/* Unlock a uuxqt process. */ - -boolean -fsysdep_unlock_uuxqt (iseq, zcmd) - int iseq; - const char *zcmd; -{ - char ab[14]; - boolean fret; - - fret = TRUE; - - if (cMaxuuxqts > 0) - { - sprintf (ab, "LCK.XQT.%d", iseq); - if (! fsdo_unlock (ab, TRUE)) - fret = FALSE; - } - - if (zcmd != NULL) - { - sprintf (ab, "LXQ.%.9s", zcmd); - ab[strcspn (ab, " \t/")] = '\0'; - if (! fsdo_unlock (ab, TRUE)) - fret = FALSE; - } - - return fret; -} - -/* See whether a particular uuxqt command is locked (this depends on - the implementation of fsdo_lock). */ - -boolean -fsysdep_uuxqt_locked (zcmd) - const char *zcmd; -{ - char ab[14]; - - sprintf (ab, "LXQ.%.9s", zcmd); - return access (ab, F_OK) == 0; -} - -/* Lock a particular execute file. */ - -boolean -fsysdep_lock_uuxqt_file (zfile) - const char *zfile; -{ - char *zcopy, *z; - - zcopy = (char *) alloca (strlen (zfile) + 1); - strcpy (zcopy, zfile); - - z = strrchr (zcopy, '/'); - if (z == NULL) - *zcopy = 'L'; - else - *(z + 1) = 'L'; - - return fsdo_lock (zcopy, TRUE); -} - -/* Unlock a particular execute file. */ - -boolean -fsysdep_unlock_uuxqt_file (zfile) - const char *zfile; -{ - char *zcopy, *z; - - zcopy = (char *) alloca (strlen (zfile) + 1); - strcpy (zcopy, zfile); - - z = strrchr (zcopy, '/'); - if (z == NULL) - *zcopy = 'L'; - else - *(z + 1) = 'L'; - - return fsdo_unlock (zcopy, TRUE); -} - -/* Lock the execute directory. */ - -boolean -fsysdep_lock_uuxqt_dir () -{ - return fsdo_lock ("LCK..XQTDIR", TRUE); -} - -/* Unlock the execute directory and clear it out. */ - -boolean -fsysdep_unlock_uuxqt_dir () -{ - DIR *qdir; - - qdir = opendir ((char *) XQTDIR); - if (qdir != NULL) - { - struct dirent *qentry; - - while ((qentry = readdir (qdir)) != NULL) - { - const char *z; - - if (strcmp (qentry->d_name, ".") == 0 - || strcmp (qentry->d_name, "..") == 0) - continue; - z = zsappend (XQTDIR, qentry->d_name); - if (z != NULL) - (void) remove (z); - } - - closedir (qdir); - } - - return fsdo_unlock ("LCK..XQTDIR", TRUE); -} - -/* - Local variables: - mode:c - End: - */ diff --git a/gnu/libexec/uucp/sys6.unx b/gnu/libexec/uucp/sys6.unx deleted file mode 100644 index d4f9a20bc782..000000000000 --- a/gnu/libexec/uucp/sys6.unx +++ /dev/null @@ -1,234 +0,0 @@ -/* sys6.unx - System dependent routines to deal with local file names. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: sys6.unx,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.9 1992/02/27 19:51:55 ian - Added extern for stat - - Revision 1.8 1992/02/08 22:33:32 ian - Only get the current working directory if it's going to be needed - - Revision 1.7 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.6 1992/02/02 20:34:36 ian - Niels Baggesen: must check user permissions on access to local files - - Revision 1.5 1991/12/22 22:14:19 ian - Monty Solomon: added HAVE_UNISTD_H configuration parameter - - Revision 1.4 1991/12/14 16:09:07 ian - Added -l option to uux to link files into the spool directory - - Revision 1.3 1991/12/06 22:50:01 ian - Franc,ois Pinard: getcwd may legitimately fail in usysdep_initialize - - Revision 1.2 1991/11/13 23:08:40 ian - Expand remote pathnames in uucp and uux; fix up uux special cases - - Revision 1.1 1991/09/10 19:45:50 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char sys6_unx_rcsid[] = "$Id: sys6.unx,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#if USE_STDIO && HAVE_UNISTD_H -#include -#endif - -#include "system.h" -#include "sysdep.h" - -/* We need R_OK. */ -#ifndef R_OK -#define R_OK 4 -#endif - -/* We need some mode access macros. */ -#ifndef S_IRUSR -#define S_IRUSR (0400) -#define S_IRGRP (0040) -#define S_IROTH (0004) -#endif /* ! defined (S_IRUSR) */ - -/* External functions. */ -extern int access (), link (), stat (); -extern uid_t getuid (), getgid (), geteuid (), getegid (); - -/* See whether running this file through zsysdep_add_cwd would require - knowing the current working directory. This is used to avoid - determining the cwd if it will not be needed. */ - -boolean -fsysdep_needs_cwd (zfile) - const char *zfile; -{ - return *zfile != '/' && *zfile != '~'; -} - -/* Add the current working directory to a file name, if no directory - has been specified. We do ~ expansion here. */ - -const char * -zsysdep_add_cwd (zfile, flocal) - const char *zfile; - boolean flocal; -{ - if (*zfile == '/') - return zfile; - if (*zfile == '~') - { - if (flocal) - return zstilde_expand (&sLocalsys, zfile); - else - return zfile; - } - -#if DEBUG > 0 - if (zScwd == NULL) - ulog (LOG_FATAL, "zsysdep_add_cwd: No cwd"); -#endif - - return zsappend (zScwd, zfile); -} - -/* Get the base name of a file name. */ - -const char * -zsysdep_base_name (zfile) - const char *zfile; -{ - const char *z; - - z = strrchr (zfile, '/'); - if (z != NULL) - return z + 1; - return zfile; -} - -/* See if the user has access to a file, to prevent the setuid uucp - and uux programs handing out unauthorized access. */ - -boolean -fsysdep_access (zfile) - const char *zfile; -{ - if (access (zfile, R_OK) == 0) - return TRUE; - ulog (LOG_ERROR, "%s: %s", zfile, strerror (errno)); - return FALSE; -} - -/* See if the daemon has access to a file. This is called if a file - is not being transferred to the spool directory, since if the - daemon does not have access the later transfer will fail. We - assume that the daemon will have the same euid (or egid) as the one - we are running under. If our uid (gid) and euid (egid) are the - same, we assume that we have access. Note that is not important - for security, since the check will be (implicitly) done again when - the daemon tries to transfer the file. This routine should work - whether the UUCP programs are installed setuid or setgid. */ - -boolean -fsysdep_daemon_access (zfile) - const char *zfile; -{ - struct stat s; - uid_t ieuid, iuid, iegid, igid; - boolean fok; - - ieuid = geteuid (); - if (ieuid == 0) - return TRUE; - iuid = getuid (); - iegid = getegid (); - igid = getgid (); - - /* If our effective uid and gid are the same as our real uid and - gid, we assume the daemon will have access to the file. */ - if (ieuid == iuid && iegid == igid) - return TRUE; - - if (stat (zfile, &s) != 0) - { - ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno)); - return FALSE; - } - - /* If our euid is not our uid, but it is the file's uid, see if the - owner has read access. Otherwise, if our egid is not our gid, - but it is the file's gid, see if the group has read access. - Otherwise, see if the world has read access. We know from the - above check that at least one of our euid and egid are different, - so that is the only one we want to check. This check could fail - if the UUCP programs were both setuid and setgid, but why would - they be? */ - if (ieuid != iuid && ieuid == s.st_uid) - fok = (s.st_mode & S_IRUSR) != 0; - else if (iegid != igid && iegid == s.st_gid) - fok = (s.st_mode & S_IRGRP) != 0; - else - fok = (s.st_mode & S_IROTH) != 0; - - if (! fok) - { - ulog (LOG_ERROR, "%s: cannot be read by daemon", zfile); - return FALSE; - } - - return TRUE; -} - -/* Link two files. This in here because it's only called by uux. */ - -boolean -fsysdep_link (zfrom, zto, pfworked) - const char *zfrom; - const char *zto; - boolean *pfworked; -{ - if (link (zfrom, zto) == 0) - { - *pfworked = TRUE; - return TRUE; - } - *pfworked = FALSE; - return errno == EXDEV; -} - -/* - Local variables: - mode:c - End: - */ diff --git a/gnu/libexec/uucp/sys7.unx b/gnu/libexec/uucp/sys7.unx deleted file mode 100644 index 0a83cf1c0f2b..000000000000 --- a/gnu/libexec/uucp/sys7.unx +++ /dev/null @@ -1,606 +0,0 @@ -/* sys7.unx - System dependent routines for uustat. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: sys7.unx,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.11 1992/03/28 04:19:39 ian - Niels Baggesen, Gerben Wierda: minor patches - - Revision 1.10 1992/03/16 22:22:35 ian - Adjusted external declarations - - Revision 1.9 1992/03/15 01:54:46 ian - All execs are now done in isspawn, all waits are done in iswait - - Revision 1.8 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.7 1992/03/11 22:21:19 ian - Permit uucp user to delete jobs - - Revision 1.6 1992/02/27 19:53:26 ian - Added some extern definitions - - Revision 1.5 1992/02/24 20:07:43 ian - John Theus: some systems don't have - - Revision 1.4 1992/02/23 16:21:26 ian - Handle systems on which NULL second argument to utime fails - - Revision 1.3 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.2 1992/02/20 04:40:07 ian - Make sure only the submitter or the superuser can cancel a request - - Revision 1.1 1992/02/20 04:18:59 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char sys7_unx_rcsid[] = "$Id: sys7.unx,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#if USE_STDIO && HAVE_UNISTD_H -#include -#endif - -#include "system.h" -#include "sysdep.h" - -#if HAVE_FCNTL_H -#include -#else -#if HAVE_SYS_FILE_H -#include -#endif -#endif - -#ifndef O_RDONLY -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#endif - -#if HAVE_OPENDIR -#if HAVE_DIRENT_H -#include -#else /* ! HAVE_DIRENT_H */ -#include -#define dirent direct -#endif /* ! HAVE_DIRENT_H */ -#endif /* HAVE_OPENDIR */ - -#ifdef UTIME_NULL_MISSING -#if HAVE_TIME_H -#include -#endif -#endif - -#if HAVE_UTIME_H -#include -#endif - -/* External functions. */ -extern int fclose (), fflush (); -extern int read (), close (), utime (), stat (); -extern uid_t getuid (), geteuid (); - -/* Local functions. */ - -static boolean fskill_or_rejuv P((const char *zid, boolean fkill)); - -/* Set file access time to the present. On most systems this can be a - macro, but some apparently do not support utime correctly. */ - -#ifndef UTIME_NULL_MISSING - -#define ussettime(z) utime((z), (struct utimbuf *) NULL) - -#else /* defined (UTIME_NULL_MISSING) */ - -static int -ussettime(z) - const char *z; -{ - time_t inow; - - inow = time ((time_t *) NULL); - - { -#if HAVE_UTIME_H - struct utimbuf s; - - s.actime = inow; - s.modtime = inow; - return utime (z, &s); -#else - time_t ai[2]; - - ai[0] = inow; - ai[1] = inow; - return utime (z, ai); -#endif - } -} - -#endif /* defined (UTIME_NULL_MISSING) */ - -/* Kill a job, given the jobid. */ - -boolean -fsysdep_kill_job (zid) - const char *zid; -{ - return fskill_or_rejuv (zid, TRUE); -} - -/* Rejuvenate a job, given the jobid. */ - -boolean -fsysdep_rejuvenate_job (zid) - const char *zid; -{ - return fskill_or_rejuv (zid, FALSE); -} - -/* Kill or rejuvenate a job, given the jobid. */ - -static boolean -fskill_or_rejuv (zid, fkill) - const char *zid; - boolean fkill; -{ - const char *zfile; - const char *zsys; - char *zcopy; - struct ssysteminfo ssys; - const struct ssysteminfo *qsys; - FILE *e; - boolean fret; - char *zline; - int isys; - - zfile = zsjobid_to_file (zid, &zsys); - zcopy = (char *) alloca (strlen (zfile) + 1); - strcpy (zcopy, zfile); - zfile = zcopy; - zcopy = (char *) alloca (strlen (zsys) + 1); - strcpy (zcopy, zsys); - zsys = zcopy; - - if (fread_system_info (zsys, &ssys)) - qsys = &ssys; - else - { - if (! fUnknown_ok) - { - ulog (LOG_ERROR, "%s: Bad job id", zid); - return FALSE; - } - sUnknown.zname = zsys; - qsys = &sUnknown; - } - - e = fopen (zfile, "r"); - if (e == NULL) - { - if (errno == ENOENT) - ulog (LOG_ERROR, "%s: Job not found", zid); - else - ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno)); - return FALSE; - } - - /* Now we have to read through the file to identify any temporary - files. */ - - fret = TRUE; - while ((zline = zfgets (e, FALSE)) != NULL) - { - struct scmd s; - - if (! fparse_cmd (zline, &s)) - { - ulog (LOG_ERROR, "Bad line in command file %s", zfile); - fret = FALSE; - xfree ((pointer) zline); - continue; - } - - /* You are only permitted to delete a job if you submitted it or - if you are root or uucp. We check for uucp by seeing if the - real user ID and the effective user ID are the same; this - works because we should be suid to uucp, so our effective - user ID will always be uucp while our real user ID will be - whoever ran the program. */ - if (strcmp (s.zuser, zsysdep_login_name ()) != 0 - && getuid () != 0 - && getuid () != geteuid ()) - { - ulog (LOG_ERROR, "%s: Not submitted by you", zid); - xfree ((pointer) zline); - return FALSE; - } - - if (s.bcmd == 'S') - { - const char *ztemp; - - ztemp = zsysdep_spool_file_name (qsys, s.ztemp); - if (ztemp == NULL) - fret = FALSE; - else - { - if (fkill) - isys = remove (ztemp); - else - isys = ussettime (ztemp); - - if (isys != 0 && errno != ENOENT) - { - ulog (LOG_ERROR, "%s (%s): %s", - fkill ? "remove" : "utime", ztemp, - strerror (errno)); - fret = FALSE; - } - } - } - - xfree ((pointer) zline); - } - - (void) fclose (e); - - if (fkill) - isys = remove (zfile); - else - isys = ussettime (zfile); - - if (isys != 0 && errno != ENOENT) - { - ulog (LOG_ERROR, "%s (%s): %s", fkill ? "remove" : "utime", - zfile, strerror (errno)); - fret = FALSE; - } - - return fret; -} - -/* Get the time a work job was queued. */ - -long -isysdep_work_time (qsys, pseq) - const struct ssysteminfo *qsys; - pointer pseq; -{ - return isysdep_file_time (zsjobid_to_file (zsysdep_jobid (qsys, pseq), - (const char **) NULL)); -} - -/* Get the time a file was created (actually, the time it was last - modified). */ - -long -isysdep_file_time (zfile) - const char *zfile; -{ - struct stat s; - - if (stat (zfile, &s) < 0) - { - if (errno != ENOENT) - ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno)); - return isysdep_time ((long *) NULL); - } - - return (long) s.st_mtime; -} - -/* Get the size in bytes of a file. */ - -long -csysdep_size (zfile) - const char *zfile; -{ - struct stat s; - - if (stat (zfile, &s) < 0) - { - if (errno != ENOENT) - ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno)); - return 0; - } - - return s.st_size; -} - -/* Start getting the status files. */ - -boolean -fsysdep_all_status_init (phold) - pointer *phold; -{ - DIR *qdir; - - qdir = opendir ((char *) ".Status"); - if (qdir == NULL) - { - ulog (LOG_ERROR, "opendir (.Status): %s", strerror (errno)); - return FALSE; - } - - *phold = (pointer) qdir; - return TRUE; -} - -/* Get the next status file. */ - -const char * -zsysdep_all_status (phold, pferr, qstat) - pointer phold; - boolean *pferr; - struct sstatus *qstat; -{ - DIR *qdir = (DIR *) phold; - struct dirent *qentry; - - while (TRUE) - { - errno = 0; - qentry = readdir (qdir); - if (qentry == NULL) - { - if (errno == 0) - *pferr = FALSE; - else - { - ulog (LOG_ERROR, "readdir: %s", strerror (errno)); - *pferr = TRUE; - } - return NULL; - } - - if (qentry->d_name[0] != '.') - { - struct ssysteminfo ssys; - - /* Hack seriously; fsysdep_get_status only looks at the - zname element of the qsys argument, so if we fake that we - can read the status file. This should really be done - differently. */ - ssys.zname = qentry->d_name; - if (fsysdep_get_status (&ssys, qstat)) - return zscopy (qentry->d_name); - - /* If fsysdep_get_status fails, it will output an error - message. We just continue with the next entry, so that - most of the status files will be displayed. */ - } - } -} - -/* Finish getting the status file. */ - -void -usysdep_all_status_free (phold) - pointer phold; -{ - DIR *qdir = (DIR *) phold; - - (void) closedir (qdir); -} - -/* Get the status of all processes holding lock files. We do this by - invoking ps after we've figured out the process entries to use. */ - -boolean -fsysdep_lock_status () -{ - const char *zdir; - DIR *qdir; - struct dirent *qentry; - int calc; - int *pai; - int cgot; - int aidescs[3]; - char *zcopy, *ztok; - int cargs, iarg; - char **pazargs; - -#ifdef LOCKDIR - zdir = LOCKDIR; -#else - zdir = "."; -#endif - - qdir = opendir ((char *) zdir); - if (qdir == NULL) - { - ulog (LOG_ERROR, "opendir (%s): %s", zdir, strerror (errno)); - return FALSE; - } - - /* We look for entries that start with "LCK.." and ignore everything - else. This won't find all possible lock files, but it should - find all the locks on terminals and systems. */ - - calc = 0; - pai = NULL; - cgot = 0; - while ((qentry = readdir (qdir)) != NULL) - { - const char *zname; - int o; -#if HAVE_V2_LOCKFILES - int i; -#else - char ab[12]; -#endif - int cread; - int ierr; - int ipid; - - if (strncmp (qentry->d_name, "LCK..", sizeof "LCK.." - 1) != 0) - continue; - - zname = zsappend (zdir, qentry->d_name); - o = open (zname, O_RDONLY, 0); - if (o < 0) - { - if (errno != ENOENT) - ulog (LOG_ERROR, "open (%s): %s", zname, strerror (errno)); - continue; - } - -#if HAVE_V2_LOCKFILES - cread = read (o, &i, sizeof i); -#else - cread = read (o, ab, sizeof ab - 1); -#endif - - ierr = errno; - (void) close (o); - - if (cread < 0) - { - ulog (LOG_ERROR, "read %s: %s", zname, strerror (ierr)); - continue; - } - -#if HAVE_V2_LOCKFILES - ipid = i; -#else - ab[cread] = '\0'; - ipid = atoi (ab); -#endif - - printf ("%s: %d\n", qentry->d_name, ipid); - - if (cgot >= calc) - { - calc += 10; - pai = (int *) xrealloc ((pointer) pai, calc * sizeof (int)); - } - - pai[cgot] = ipid; - ++cgot; - } - - if (cgot == 0) - return TRUE; - - aidescs[0] = SPAWN_NULL; - aidescs[1] = 1; - aidescs[2] = 2; - - /* Parse PS_PROGRAM into an array of arguments. */ - zcopy = (char *) alloca (sizeof PS_PROGRAM); - strcpy (zcopy, PS_PROGRAM); - - cargs = 0; - for (ztok = strtok (zcopy, " \t"); - ztok != NULL; - ztok = strtok ((char *) NULL, " \t")) - ++cargs; - - pazargs = (char **) alloca ((cargs + 1) * sizeof (char *)); - - strcpy (zcopy, PS_PROGRAM); - for (ztok = strtok (zcopy, " \t"), iarg = 0; - ztok != NULL; - ztok = strtok ((char *) NULL, " \t"), ++iarg) - pazargs[iarg] = ztok; - pazargs[iarg] = NULL; - -#if ! HAVE_PS_MULTIPLE - /* We have to invoke ps multiple times. */ - { - int i; - char *zlast, *zset; - - zlast = pazargs[cargs - 1]; - zset = (char *) alloca (strlen (zlast) + 20); - for (i = 0; i < cgot; i++) - { - pid_t ipid; - - sprintf (zset, "%s%d", zlast, pai[i]); - pazargs[cargs - 1] = zset; - - ipid = isspawn ((const char **) pazargs, aidescs, FALSE, FALSE, - (const char *) NULL, FALSE, TRUE, - (const char *) NULL, (const char *) NULL, - (const char *) NULL); - if (ipid < 0) - ulog (LOG_ERROR, "isspawn: %s", strerror (errno)); - else - (void) iswait ((unsigned long) ipid, PS_PROGRAM); - } - } -#else - { - char *zlast; - int i; - pid_t ipid; - - zlast = (char *) alloca (strlen (pazargs[cargs - 1]) + cgot * 20 + 1); - strcpy (zlast, pazargs[cargs - 1]); - for (i = 0; i < cgot; i++) - { - char ab[20]; - - sprintf (ab, "%d", pai[i]); - strcat (zlast, ab); - if (i + 1 < cgot) - strcat (zlast, ","); - } - pazargs[cargs - 1] = zlast; - - ipid = isspawn ((const char **) pazargs, aidescs, FALSE, FALSE, - (const char *) NULL, FALSE, TRUE, - (const char *) NULL, (const char *) NULL, - (const char *) NULL); - if (ipid < 0) - ulog (LOG_ERROR, "isspawn: %s", strerror (errno)); - else - (void) iswait ((unsigned long) ipid, PS_PROGRAM); - } -#endif - - return TRUE; -} - -/* - Local variables: - mode:c - End: - */ diff --git a/gnu/libexec/uucp/sysh.unx b/gnu/libexec/uucp/sysh.unx deleted file mode 100644 index f7c07bb4d769..000000000000 --- a/gnu/libexec/uucp/sysh.unx +++ /dev/null @@ -1,606 +0,0 @@ -/* sysh.unx - The header file for the UNIX system dependent routines. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: sysh.unx,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.53 1992/03/30 15:29:58 ian - Added HAVE_SVR4_LOCKFILES - - Revision 1.52 1992/03/16 01:23:08 ian - Make blocking writes optional - - Revision 1.51 1992/03/15 07:15:42 ian - T. William Wells: don't use unblocked writes - - Revision 1.50 1992/03/15 04:51:17 ian - Keep an array of signals we've received rather than a single variable - - Revision 1.49 1992/03/15 01:54:46 ian - All execs are now done in isspawn, all waits are done in iswait - - Revision 1.48 1992/03/12 21:52:21 ian - Corrected readdir prototype - - Revision 1.47 1992/03/11 22:06:37 ian - Marty Shannon: added max-uuxqts command - - Revision 1.46 1992/03/11 02:09:57 ian - Franc,ois Pinard: retry fork several times before giving up - - Revision 1.45 1992/03/11 00:18:50 ian - Save temporary file if file send fails - - Revision 1.44 1992/03/10 17:39:57 ian - Some systems don't permit both and to be included - - Revision 1.43 1992/03/09 22:07:36 ian - Wait for terminal output to drain at various points - - Revision 1.42 1992/03/03 21:01:20 ian - Use strict timeout in fsserial_read, eliminate all race conditions - - Revision 1.41 1992/03/02 04:53:07 ian - Marc Unangst: added HAVE_SCO_LOCKFILES configuration parameter - - Revision 1.40 1992/02/29 01:06:59 ian - Chip Salzenberg: recheck file permissions before sending - - Revision 1.39 1992/02/28 05:06:15 ian - T. William Wells: fsysdep_catch must be a macro - - Revision 1.38 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.37 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.36 1992/02/20 04:18:59 ian - Added uustat - - Revision 1.35 1992/02/09 05:10:50 ian - Added HAVE_MKDIR configuration parameter and mkdir emulation - - Revision 1.34 1992/02/09 03:14:48 ian - Added HAVE_OLD_DIRECTORIES for systems without readdir routines - - Revision 1.33 1992/02/09 02:41:58 ian - Added HAVE_DUP2 configuration parameter and dup2 emulation function - - Revision 1.32 1992/02/08 23:34:41 ian - If we have neither getcwd nor getwd, fork /bin/pwd to get the cwd - - Revision 1.31 1992/02/08 20:02:36 ian - Added HAVE_SETRET configuration option for systems without setjmp - - Revision 1.30 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.29 1992/01/15 21:06:11 ian - Mike Park: some systems can't include and together - - Revision 1.28 1992/01/15 19:40:35 ian - Mike Park: handle HAVE_UNION_WAIT correctly and completely - - Revision 1.27 1992/01/15 07:06:29 ian - Set configuration directory in Makefile rather than sysdep.h - - Revision 1.26 1992/01/14 04:18:47 ian - Chip Salzenberg: added HAVE_USLEEP configuration parameter - - Revision 1.25 1992/01/13 19:59:29 ian - Define LIBDIR in Makefile rather than in sysh.unx - - Revision 1.24 1992/01/13 05:55:59 ian - Touched up a few comments - - Revision 1.23 1992/01/13 05:53:04 ian - Mike Park: added HAVE_WAITPID and HAVE_WAIT4 configuration parameters - - Revision 1.22 1992/01/11 17:11:11 ian - Hannu Strang: avoid compiler bug by not using -> in address constant - - Revision 1.21 1992/01/04 21:43:24 ian - Chip Salzenberg: added ALLOW_FILENAME_ARGUMENTS to permit them - - Revision 1.20 1991/12/29 00:55:23 ian - Monty Solomon: added HAVE_UNION_WAIT - - Revision 1.19 1991/12/28 17:08:47 ian - John Theus: offer HAVE_GETWD as an alternative to using getcwd - - Revision 1.18 1991/12/28 07:01:15 ian - Added HAVE_FTIME configuration option - - Revision 1.17 1991/12/22 22:14:19 ian - Monty Solomon: added HAVE_UNISTD_H configuration parameter - - Revision 1.16 1991/12/19 04:25:57 ian - Terry Gardner: configuration parameter to not use both NONBLOCK and NDELAY - - Revision 1.15 1991/12/17 07:09:58 ian - Record statistics in fractions of a second - - Revision 1.14 1991/12/11 04:21:37 ian - Arne Ludwig: merge in Arne Ludwig's patches for V2 and BNU style logging - - Revision 1.13 1991/12/09 19:07:07 ian - Richard Todd: add HAVE_V2_LOCKFILES--binary number in lock file - - Revision 1.12 1991/11/30 23:28:26 ian - Marty Shannon: some systems need a fake version of the rename system call - - Revision 1.11 1991/11/26 01:45:42 ian - Marty Shannon: configuration option to not include - - Revision 1.10 1991/11/24 04:15:13 ian - Removed extraneous comment left by last revision - - Revision 1.9 1991/11/21 21:49:38 ian - Brian Campbell: define all macros to avoid compiler warnings - - Revision 1.8 1991/11/21 21:07:46 ian - Brian Campbell: offer ltrunc as an alternative to ftruncate - - Revision 1.7 1991/11/10 19:24:22 ian - Added pffile protocol entry point for file level control - - Revision 1.6 1991/11/08 22:52:34 ian - Brian Campbell: only include and when needed - - Revision 1.5 1991/11/08 22:11:45 ian - Brian Campbell: allow sigsetjmp as configuration option - - Revision 1.4 1991/11/07 19:32:28 ian - Chip Salzenberg: allow LOCKDIR, and check that locking process exists - - Revision 1.3 1991/09/19 16:15:58 ian - Chip Salzenberg: configuration option for permitting execution via sh - - Revision 1.2 1991/09/19 03:06:04 ian - Chip Salzenberg: put BNU temporary files in system's directory - - Revision 1.1 1991/09/10 19:45:50 ian - Initial revision - - */ - -#ifndef SYSH_UNX_H - -#define SYSH_UNX_H - -/* We're might redefine fsysdep_catch, so make sure we've gotten the - prototype already. */ - -#ifndef SYSTEM_H -#include "system.h" -#endif - -/* Make sure the defines do not conflict. These are in this file - because they are Unix dependent. */ - -#if HAVE_V2_LOCKFILES + HAVE_BNU_LOCKFILES + HAVE_SCO_LOCKFILES + HAVE_SVR4_LOCKFILES != 1 - #error LOCKFILES define not set or duplicated -#endif - -/* SCO and SVR4 lockfiles are basically just like BNU lockfiles. */ -#if HAVE_SCO_LOCKFILES || HAVE_SVR4_LOCKFILES -#undef HAVE_BNU_LOCKFILES -#define HAVE_BNU_LOCKFILES 1 -#endif - -#if HAVE_BSD_TTY + HAVE_SYSV_TERMIO + HAVE_POSIX_TERMIOS != 1 - #error Terminal driver define not set or duplicated -#endif - -#if SPOOLDIR_V2 + SPOOLDIR_BSD42 + SPOOLDIR_BSD43 + SPOOLDIR_BNU + SPOOLDIR_ULTRIX + SPOOLDIR_TAYLOR != 1 - #error Spool directory define not set or duplicated -#endif - -/* On Unix, binary files are the same as text files. */ -#define BINREAD "r" -#define BINWRITE "w" - -/* If we have sigaction, we can force system calls to not be - restarted. */ -#if HAVE_SIGACTION -#undef HAVE_RESTARTABLE_SYSCALLS -#define HAVE_RESTARTABLE_SYSCALLS 0 -#endif - -/* If we have sigvec and SV_INTERRUPT is defined, we can force system - calls to not be restarted (signal.h is included by uucp.h before - this point, so SV_INTERRUPT will be defined by now if it it ever - is). */ -#if HAVE_SIGVEC -#ifdef SV_INTERRUPT -#undef HAVE_RESTARTABLE_SYSCALLS -#define HAVE_RESTARTABLE_SYSCALLS 0 -#endif -#endif - -/* We don't handle sigset in combination with restartable system - calls, so we check for it although this combination will never - happen. */ -#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && HAVE_SIGSET -#if HAVE_RESTARTABLE_SYSCALLS -#undef HAVE_SIGSET -#define HAVE_SIGSET 0 -#endif -#endif - -/* If we don't have restartable system calls, we can ignore - fsysdep_catch, usysdep_start_catch and usysdep_end_catch. - Otherwise fsysdep_catch has to do a setjmp. */ - -#if ! HAVE_RESTARTABLE_SYSCALLS - -#define fsysdep_catch() (TRUE) -#define usysdep_start_catch() -#define usysdep_end_catch() -#define CATCH_PROTECT - -#else /* HAVE_RESTARTABLE_SYSCALLS */ - -#if HAVE_SETRET && ! HAVE_SIGSETJMP -#include -#define setjmp setret -#define longjmp longret -#define jmp_buf ret_buf -#else /* ! HAVE_SETRET || HAVE_SIGSETJMP */ -#include -#if HAVE_SIGSETJMP -#undef setjmp -#undef longjmp -#undef jmp_buf -#define setjmp(s) sigsetjmp ((s), TRUE) -#define longjmp siglongjmp -#define jmp_buf sigjmp_buf -#endif /* HAVE_SIGSETJMP */ -#endif /* ! HAVE_SETRET || HAVE_SIGSETJMP */ - -extern volatile sig_atomic_t fSjmp; -extern volatile jmp_buf sSjmp_buf; - -#define fsysdep_catch() (setjmp (sSjmp_buf) == 0) - -#define usysdep_start_catch() (fSjmp = TRUE) - -#define usysdep_end_catch() (fSjmp = FALSE) - -#define CATCH_PROTECT volatile - -#endif /* HAVE_RESTARTABLE_SYSCALLS */ - -/* Get definitions for the terminal driver. */ - -#if HAVE_BSD_TTY -#include -typedef struct sgttyb sterminal; -#define fgetterminfo(o, q) (ioctl ((o), TIOCGETP, (q)) == 0) -#define fsetterminfo(o, q) (ioctl ((o), TIOCSETN, (q)) == 0) -#define fsetterminfodrain(o, q) (ioctl ((o), TIOCSETP, (q)) == 0) -#endif /* HAVE_BSD_TTY */ - -#if HAVE_SYSV_TERMIO -#include -typedef struct termio sterminal; -#define fgetterminfo(o, q) (ioctl ((o), TCGETA, (q)) == 0) -#define fsetterminfo(o, q) (ioctl ((o), TCSETA, (q)) == 0) -#define fsetterminfodrain(o, q) (ioctl ((o), TCSETAW, (q)) == 0) -#endif /* HAVE_SYSV_TERMIO */ - -#if HAVE_POSIX_TERMIOS -#include -typedef struct termios sterminal; -#define fgetterminfo(o, q) (tcgetattr ((o), (q)) == 0) -#define fsetterminfo(o, q) (tcsetattr ((o), TCSANOW, (q)) == 0) -#define fsetterminfodrain(o, q) (tcsetattr ((o), TCSADRAIN, (q)) == 0) - -/* On some systems it is not possible to include both - and in the same source files; I don't really know why. - On such systems, we pretend that we don't have . */ -#if ! HAVE_TERMIOS_AND_SYS_IOCTL_H -#undef HAVE_SYS_IOCTL_H -#define HAVE_SYS_IOCTL_H 0 -#endif - -#endif /* HAVE_POSIX_TERMIOS */ - -/* The root directory (this is needed by the system independent stuff - as the default for local-send). */ -#define ZROOTDIR "/" - -/* The name of the execution directory within the spool directory - (this is need by the system independent uuxqt.c). */ -#define XQTDIR ".Xqtdir" - -/* The name of the directory in which we preserve file transfers that - failed. */ -#define PRESERVEDIR ".Preserve" - -#if HAVE_TAYLOR_CONFIG - -/* The names of the configuration files. These are appended to - NEWCONFIGLIB which is defined in Makefile. */ -#define CONFIGFILE "/config" -#define SYSFILE "/sys" -#define PORTFILE "/port" -#define DIALFILE "/dial" -#define CALLFILE "/call" -#define PASSWDFILE "/passwd" -#define DIALCODEFILE "/dialcode" - -#endif /* HAVE_TAYLOR_CONFIG */ - -#if HAVE_V2_CONFIG - -/* The names of the various V2 configuration files. These are - appended to OLDCONFIGLIB which is defined in Makefile. */ -#define V2_SYSTEMS "/L.sys" -#define V2_DEVICES "/L-devices" -#define V2_USERFILE "/USERFILE" -#define V2_CMDS "/L.cmds" -#define V2_DIALCODES "/L-dialcodes" - -#endif /* HAVE_V2_CONFIG */ - -#if HAVE_BNU_CONFIG - -/* The names of the BNU configuration files. These are appended to - OLDCONFIGLIB which is defined in Makefile. */ -#define BNU_SYSFILES "/Sysfiles" -#define BNU_SYSTEMS "/Systems" -#define BNU_PERMISSIONS "/Permissions" -#define BNU_DIALERS "/Dialers" -#define BNU_DEVICES "/Devices" -#define BNU_PERMISSIONS "/Permissions" -#define BNU_DIALCODES "/Dialcodes" -#define BNU_MAXUUXQTS "/Maxuuxqts" - -#endif /* HAVE_BNU_CONFIG */ - -/* Get some standard definitions. */ - -#include -#include - -/* Get definitions for the file permission bits. */ - -#ifndef S_IRUSR - -#define S_IRWXU 0700 -#define S_IRUSR 0400 -#define S_IWUSR 0200 -#define S_IXUSR 0100 - -#define S_IRWXG 0070 -#define S_IRGRP 0040 -#define S_IWGRP 0020 -#define S_IXGRP 0010 - -#define S_IRWXO 0007 -#define S_IROTH 0004 -#define S_IWOTH 0002 -#define S_IXOTH 0001 - -#endif /* ! defined (S_IRUSR) */ - -#ifndef S_ISDIR -#ifdef S_IFDIR -#define S_ISDIR(i) (((i) & S_IFMT) == S_IFDIR) -#else /* ! defined (S_IFDIR) */ -#define S_ISDIR(i) (((i) & 0170000) == 040000) -#endif /* ! defined (S_IFDIR) */ -#endif /* ! defined (S_ISDIR) */ - -/* We create files with these modes (should this be configurable?). */ -#define IPRIVATE_FILE_MODE (S_IRUSR | S_IWUSR) -#define IPUBLIC_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) - -/* We create directories with this mode (should this be configurable?). */ -#define IDIRECTORY_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) -#define IPUBLIC_DIRECTORY_MODE (S_IRWXU | S_IRWXG | S_IRWXO) - -#if ! HAVE_OPENDIR - -/* Define some structures to use if we don't have opendir, etc. These - will only work if we have the old Unix filesystem, with a 2 byte - inode and a 14 byte filename. */ - -#include - -struct dirent -{ - char d_name[DIRSIZ + 1]; -}; - -typedef struct -{ - int o; - struct dirent s; -} DIR; - -extern DIR *opendir P((const char *zdir)); -extern struct dirent *readdir P((DIR *)); -extern int closedir P((DIR *)); - -#endif /* ! HAVE_OPENDIR */ - -/* Information we need for a UNIX serial port. */ - -struct ssysdep_serial_port -{ - /* File descriptor to read from. */ - int oread; - /* Whether the read descriptor is blocking. */ - boolean fread_blocking; - /* File descriptor to write to. */ - int owrite; - /* Whether the write descriptor is blocking. */ - boolean fwrite_blocking; - /* Whether setting the read descriptor to blocking affects the write - descriptor and vice-versa. */ - boolean fblock_both; - /* Hold the real read descriptor when using a dialer device. */ - int oholdread; - /* Hold the real write descriptor when using a dialer device. */ - int oholdwrite; - /* TRUE if this is a terminal and the remaining fields are valid. */ - boolean fterminal; - /* Baud rate. */ - long ibaud; - /* Original terminal settings. */ - sterminal sorig; - /* New terminal settings (raw mode, etc.). */ - sterminal snew; -}; - -/* Information we need for a UNIX stdin port. */ - -struct ssysdep_stdin_port -{ - struct ssysdep_serial_port s; - boolean fpty; -}; - -/* For debugging it is helpful to know whether we are connected - through a pty; the fsserial_read routine uses this information to - know whether to sleep or not. */ -#define SYSDEP_STDIN_CMDS(s) \ - { "pty", CMDTABTYPE_BOOLEAN, (pointer) &(s).fpty, NULL } - -#define SYSDEP_STDIN_INIT(q) ((q)->fpty = FALSE, (q)->s.oread = -1) - -/* Information we need for a UNIX modem port. */ - -struct ssysdep_modem_port -{ - struct ssysdep_serial_port s; -}; - -#define SYSDEP_MODEM_INIT(q) ((q)->s.oread = -1) - -/* Information we need for a UNIX direct port. */ - -struct ssysdep_direct_port -{ - struct ssysdep_serial_port s; -}; - -#define SYSDEP_DIRECT_INIT(q) ((q)->s.oread = -1) - -/* Set a signal handler. */ -extern void usset_signal P((int isig, SIGtype (*pfn) P((int)), - boolean fforce, boolean *pfignored)); - -/* Default signal handler. This sets the appropriate element of the - afSignal array. If system calls are automatically restarted, it - may do a longjmp to an fsysdep_catch. */ -extern SIGtype ussignal P((int isig)); - -/* Try to fork, repeating several times. */ -extern pid_t isfork P((void)); - -/* Spawn a job. Returns the process ID of the spawned job or -1 on - error. The following macros may be passed in aidescs. */ - -/* Set descriptor to /dev/null. */ -#define SPAWN_NULL (-1) -/* Set element of aidescs to a pipe for caller to read from. */ -#define SPAWN_READ_PIPE (-2) -/* Set element of aidescs to a pipe for caller to write to. */ -#define SPAWN_WRITE_PIPE (-3) - -extern pid_t isspawn P((const char **pazargs, int *aidescs, - boolean fkeepuid, boolean fkeepenv, - const char *zchdir, boolean fnosigs, - boolean fshell, const char *zpath, - const char *zuu_machine, - const char *zuu_user)); - -/* Do a form of popen using isspawn. */ -extern FILE *espopen P((const char **pazargs, boolean frd, - pid_t *pipid)); - -/* Wait for a particular process to finish, returning the exit status. - The process ID should be pid_t, but we can't put that in a - prototype. */ -extern int iswait P((unsigned long ipid, const char *zreport)); - -/* Lock a string. */ -extern boolean fsdo_lock P((const char *, boolean fspooldir)); - -/* Unlock a string. */ -extern boolean fsdo_unlock P((const char *, boolean fspooldir)); - -/* See whether a directory exists. */ -extern boolean fsdirectory_exists P((const char *)); - -/* Expand a leading tilde to the public directory or a user's home - directory. Each system may have a different public directory, so - the system information must be passed in. */ -extern const char *zstilde_expand P((const struct ssysteminfo *qsys, - const char *zfile)); - -/* Check access for a particular user name, or NULL to check access - for any user. */ -extern boolean fsuser_access P((const struct stat *, int imode, - const char *zuser)); - -/* Copy a string to the common static buffer. */ -extern const char *zscopy P((const char *z)); - -/* Prepend a directory to a file name, returning the common static - buffer. */ -extern const char *zsappend P((const char *zdir, const char *zfile)); - -/* Get a temporary file name. */ -extern const char *zstemp_file P((const struct ssysteminfo *qsys)); - -/* Get a jobid from a system and file name. */ -extern const char *zsfile_to_jobid P((const struct ssysteminfo *qsys, - const char *zfile)); - -/* Get a file name from a jobid. This also returns the associated system - in *pzsystem. */ -extern const char *zsjobid_to_file P((const char *zid, - const char **pzsystem)); - -#if SPOOLDIR_ULTRIX -/* See whether there is a spool directory for a system. */ -extern boolean fsultrix_has_spool P((const char *zsystem)); -#endif /* SPOOLDIR_ULTRIX */ - -/* The working directory from which the program was run (this is set - by usysdep_initialize if called with fgetcwd TRUE). */ -extern char *zScwd; - -/* - Local variables: - mode:c - End: - */ -#endif /* ! defined (SYSH_UNX_H) */ diff --git a/gnu/libexec/uucp/sysinf.c b/gnu/libexec/uucp/sysinf.c deleted file mode 100644 index 647d56be1476..000000000000 --- a/gnu/libexec/uucp/sysinf.c +++ /dev/null @@ -1,1797 +0,0 @@ -/* sysinf.c - Functions to read system information for the UUCP package. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: sysinf.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.24 1992/04/02 22:51:09 ian - Add gcc 2.0 format checking to ulog, and fixed discovered problems - - Revision 1.23 1992/03/30 04:49:10 ian - Niels Baggesen: added debugging types abnormal and uucp-proto - - Revision 1.22 1992/03/28 21:47:55 ian - David J. MacKenzie: allow backslash to quote newline in config files - - Revision 1.21 1992/03/28 20:31:55 ian - Franc,ois Pinard: allow a name to be given to an alternate - - Revision 1.20 1992/03/24 17:18:33 ian - Fixed handling of alternates in file-wide defaults - - Revision 1.19 1992/03/16 04:30:57 ian - Permit a retry time for the time and timegrade commands - - Revision 1.18 1992/03/13 16:17:42 ian - Chip Salzenberg: set default login chat script timeout to 10 seconds - - Revision 1.17 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.16 1992/03/09 20:14:37 ian - Ted Lindgreen: added max-remote-debug command - - Revision 1.15 1992/03/07 02:56:30 ian - Rewrote time routines - - Revision 1.14 1992/03/03 06:06:48 ian - T. William Wells: don't complain about missing configuration files - - Revision 1.13 1992/02/23 19:50:50 ian - Handle READ and WRITE in Permissions correctly - - Revision 1.12 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.11 1992/01/13 05:17:30 ian - Mike Park: wrong number of arguments to ulog call - - Revision 1.10 1992/01/07 15:23:50 ian - Niels Baggesen: allocate number of protocol parameters correctly - - Revision 1.9 1991/12/28 03:49:23 ian - Added HAVE_MEMFNS and HAVE_BFNS; changed uses of memset to bzero - - Revision 1.8 1991/12/23 05:15:54 ian - David Nugent: set debugging level for a specific system - - Revision 1.7 1991/12/17 17:08:02 ian - Marc Unangst: allow true and false for boolean strings as documented - - Revision 1.6 1991/12/15 04:17:11 ian - Added chat-seven-bit command to control parity bit stripping - - Revision 1.5 1991/12/15 03:42:33 ian - Added tprocess_chat_cmd for all chat commands, and added CMDTABTYPE_PREFIX - - Revision 1.4 1991/11/13 20:38:00 ian - Added TCP port type for connections over TCP - - Revision 1.3 1991/11/12 19:47:04 ian - Add called-chat set of commands to run a chat script on an incoming call - - Revision 1.2 1991/11/11 23:47:24 ian - Added chat-program to run a program to do a chat script - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char sysinf_rcsid[] = "$Id: sysinf.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#include "port.h" -#include "system.h" -#include "uutime.h" - -/* Whether we accept calls from unknown systems. */ -boolean fUnknown_ok = FALSE; - -/* Information we hold for an unknown system. */ -struct ssysteminfo sUnknown; - -/* Information we hold for the local system. */ -struct ssysteminfo sLocalsys; - -#if HAVE_TAYLOR_CONFIG - -/* I don't find the system file format used by either V2 or BNU UUCP - very intuitive, so I've developed my own format. This replaces the - files L.sys and USERFILE for V2, and Systems and Permissions for - BNU. The complete format is described in a separate document. */ - -/* Some local functions. */ -static void uiset_clear P((boolean falternate)); - -/* Set when we read the first line of a new file, to indicate that a - new set of defaults should be gathered. */ -static boolean fIfirst; - -/* This structure holds system information as it is gathered. */ -static struct ssysteminfo sIhold; - -/* Default information. */ -static struct ssysteminfo sIdefault; - -/* The name of the next system. */ -static char *zInext_system; - -/* The list of alternates to draw from. */ -static struct ssysteminfo *qIalternates; - -/* Whether to use default alternates. */ -static boolean fIdefault_alternates; - -/* There are several commands for which we want to take the default if - provided, but we don't want to add to the default. For example, - each system can have multiple time specifications (using different - grades), which is implemented by adding each new time specification - to the previous ones. We want to allow default time specifications. - However, if a system has time specifications, we don't want to add - its time specifications to the default ones. We handle this with a - set of boolean variables which we set to tell the adding functions - to ignore any existing entry; when an entry has been added, the - boolean variable is cleared. */ -static boolean fIclear_alias; -static boolean fIclear_alternate; -static boolean fIclear_time; -static boolean fIclear_calltimegrade; -static boolean fIclear_call_local_size; -static boolean fIclear_call_remote_size; -static boolean fIclear_called_local_size; -static boolean fIclear_called_remote_size; -static boolean fIclear_port; -static boolean fIclear_chat_fail; -static boolean fIclear_proto_param; -static boolean fIclear_called_chat_fail; - -/* Local functions needed to parse the system information file. */ - -#define CMDTABFN(z) \ - static enum tcmdtabret z P((int, char **, pointer, const char *)) - -CMDTABFN (ticlear); -CMDTABFN (tisystem); -CMDTABFN (tialias); -CMDTABFN (tialternate); -CMDTABFN (titime); -CMDTABFN (titimegrade); -CMDTABFN (ticall_local_size); -CMDTABFN (ticall_remote_size); -CMDTABFN (ticalled_local_size); -CMDTABFN (ticalled_remote_size); -CMDTABFN (titimetable); -CMDTABFN (tiport); -CMDTABFN (tichat); -CMDTABFN (ticalled_login); -CMDTABFN (tiproto_param); -CMDTABFN (tirequest); -CMDTABFN (titransfer); - -#undef CMDTABFN - -/* The commands accepted from the system information file. */ - -static const struct scmdtab asIcmds[] = -{ - { "#", CMDTABTYPE_FN | 1, NULL, ticlear }, - { "system", CMDTABTYPE_FN | 2, NULL, tisystem }, - { "alias", CMDTABTYPE_FN | 2, NULL, tialias }, - { "alternate", CMDTABTYPE_FN | 0, NULL, tialternate }, - { "default-alternates", CMDTABTYPE_BOOLEAN, - (pointer) &fIdefault_alternates, NULL }, - { "time", CMDTABTYPE_FN | 0, NULL, titime }, - { "timegrade", CMDTABTYPE_FN | 0, (pointer) &sIhold.ztime, titimegrade }, - { "call-timegrade", CMDTABTYPE_FN | 3, (pointer) &sIhold.zcalltimegrade, - titimegrade }, - { "call-local-size", CMDTABTYPE_FN | 3, NULL, ticall_local_size }, - { "call-remote-size", CMDTABTYPE_FN | 3, NULL, ticall_remote_size }, - { "called-local-size", CMDTABTYPE_FN | 3, NULL, ticalled_local_size }, - { "called-remote-size", CMDTABTYPE_FN | 3, NULL, ticalled_remote_size }, - { "timetable", CMDTABTYPE_FN | 3, NULL, titimetable }, - { "baud", CMDTABTYPE_LONG, (pointer) &sIhold.ibaud, NULL }, - { "speed", CMDTABTYPE_LONG, (pointer) &sIhold.ibaud, NULL }, - { "port", CMDTABTYPE_FN | 0, NULL, tiport }, - { "phone", CMDTABTYPE_STRING, (pointer) &sIhold.zphone, NULL }, - { "address", CMDTABTYPE_STRING, (pointer) &sIhold.zphone, NULL }, - { "chat", CMDTABTYPE_PREFIX | 0, (pointer) &sIhold.schat, tichat }, - { "call-login", CMDTABTYPE_STRING, (pointer) &sIhold.zcall_login, NULL }, - { "call-password", CMDTABTYPE_STRING, (pointer) &sIhold.zcall_password, - NULL }, - { "called-login", CMDTABTYPE_FN | 0, NULL, ticalled_login }, - { "callback", CMDTABTYPE_BOOLEAN, (pointer) &sIhold.fcallback, NULL }, - { "sequence", CMDTABTYPE_BOOLEAN, (pointer) &sIhold.fsequence, NULL }, - { "protocol", CMDTABTYPE_STRING, (pointer) &sIhold.zprotocols, NULL }, - { "protocol-parameter", CMDTABTYPE_FN | 0, NULL, tiproto_param }, - { "called-chat", CMDTABTYPE_PREFIX | 0, (pointer) &sIhold.scalled_chat, - tichat }, -#if DEBUG > 1 - { "debug", CMDTABTYPE_FN | 0, (pointer) &sIhold.idebug, tidebug_parse }, - { "max-remote-debug", CMDTABTYPE_FN | 0, - (pointer) &sIhold.imax_remote_debug, tidebug_parse }, -#endif - { "call-request", CMDTABTYPE_BOOLEAN, (pointer) &sIhold.fcall_request, - NULL }, - { "called-request", CMDTABTYPE_BOOLEAN, (pointer) &sIhold.fcalled_request, - NULL }, - { "request", CMDTABTYPE_FN | 2, NULL, tirequest }, - { "call-transfer", CMDTABTYPE_BOOLEAN, (pointer) &sIhold.fcall_transfer, - NULL }, - { "called-transfer", CMDTABTYPE_BOOLEAN, - (pointer) &sIhold.fcalled_transfer, NULL }, - { "transfer", CMDTABTYPE_FN | 2, NULL, titransfer }, - { "local-send", CMDTABTYPE_FULLSTRING, (pointer) &sIhold.zlocal_send, - NULL }, - { "remote-send", CMDTABTYPE_FULLSTRING, (pointer) &sIhold.zremote_send, - NULL }, - { "local-receive", CMDTABTYPE_FULLSTRING, - (pointer) &sIhold.zlocal_receive, NULL }, - { "remote-receive", CMDTABTYPE_FULLSTRING, - (pointer) &sIhold.zremote_receive, NULL }, - { "command-path", CMDTABTYPE_FULLSTRING, (pointer) &sIhold.zpath, NULL }, - { "commands", CMDTABTYPE_FULLSTRING, (pointer) &sIhold.zcmds, NULL }, - { "free-space", CMDTABTYPE_LONG, (pointer) &sIhold.cfree_space, NULL }, - { "forwardto", CMDTABTYPE_FULLSTRING, (pointer) &sIhold.zforwardto, NULL }, - { "forward-to", CMDTABTYPE_FULLSTRING, (pointer) &sIhold.zforwardto, NULL }, - { "pubdir", CMDTABTYPE_STRING, (pointer) &sIhold.zpubdir, NULL }, - { "myname", CMDTABTYPE_STRING, (pointer) &sIhold.zlocalname, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* This is called for the first line of each file. It clears the - defaults, so that each file has a different set. */ - -/*ARGSUSED*/ -static enum tcmdtabret -ticlear (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - fIfirst = TRUE; - return CMDTABRET_FREE_AND_EXIT; -} - -/* Process the system command. We store away the system name and exit - out of processing commands to let the main loop handle it. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tisystem (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - const char *z; - - /* System names may only contain alphanumeric characters, - underscores, dashes and dots, and they may not begin with a dot, - at least for now. */ - for (z = argv[1]; *z != '\0'; z++) - { - if (! isalnum (BUCHAR (*z)) - && *z != '_' - && *z != '-' - && (*z != '.' || z == argv[1])) - { - ulog (LOG_ERROR, "%s: %s %s: Illegal character in system name", - zerr, argv[0], argv[1]); - return CMDTABRET_FREE; - } - } - - if (strlen (argv[1]) > cSysdep_max_name_len) - { - ulog (LOG_ERROR, "System name \"%s\" too long (max %d)", argv[1], - cSysdep_max_name_len); - return CMDTABRET_FREE; - } - - zInext_system = argv[1]; - - DEBUG_MESSAGE1 (DEBUG_CONFIG, - "tisystem: Reading system %s", zInext_system); - - return CMDTABRET_EXIT; -} - -/* Process the alias command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tialias (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - if (fIclear_alias) - { - sIhold.zalias = NULL; - fIclear_alias = FALSE; - } - uadd_string (&sIhold.zalias, argv[1], ' '); - return CMDTABRET_FREE; -} - -/* Process the alternate command. The current information is in - sIhold. We link this onto a chain of alternates starting at - sIalternate. We then set up sIhold with the defaults for the next - alternate. qIalternates holds the list of alternates for the - file-wide defaults, and we use to set up sIhold. We also call - uiset_clear to set all the fIclear_* variables so that commands - like ``time'' know that they should ignore any existing entry. */ - -static struct ssysteminfo sIalternate; - -/*ARGSUSED*/ -static enum tcmdtabret -tialternate (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - if (fIclear_alternate) - { - sIalternate = sIhold; - fIclear_alternate = FALSE; - } - else - { - struct ssysteminfo *qnew; - struct ssysteminfo **pq; - - qnew = (struct ssysteminfo *) xmalloc (sizeof (struct ssysteminfo)); - *qnew = sIhold; - for (pq = &sIalternate.qalternate; *pq != NULL; pq = &(*pq)->qalternate) - ; - *pq = qnew; - sIhold = sIalternate; - sIhold.qalternate = NULL; - } - - /* Clear the name of the next alternate. */ - sIhold.zalternate = NULL; - - /* Now, if there is a default alternate to base this on, we must - override everything not changed before the first ``alternate'' - command to the default alternate. */ - if (fIdefault_alternates - && qIalternates != NULL) - { - if (qIalternates->zalternate != NULL) - sIhold.zalternate = qIalternates->zalternate; - -#define TEST(x) \ - if (sIhold.x == sIdefault.x) \ - sIhold.x = qIalternates->x; - - TEST (ztime); - TEST (zcalltimegrade); - TEST (zcall_local_size); - TEST (zcall_remote_size); - TEST (zcalled_local_size); - TEST (zcalled_remote_size); - TEST (ibaud); - TEST (zport); - TEST (qport); - TEST (zphone); - TEST (schat.zchat); - TEST (schat.zprogram); - TEST (schat.ctimeout); - TEST (schat.zfail); - TEST (zcall_login); - TEST (zcalled_login); - TEST (fcallback); - TEST (zprotocols); - TEST (cproto_params); - TEST (qproto_params); - TEST (scalled_chat.zchat); - TEST (scalled_chat.zprogram); - TEST (scalled_chat.ctimeout); - TEST (scalled_chat.zfail); -#if DEBUG > 1 - TEST (idebug); - TEST (imax_remote_debug); -#endif - TEST (fcall_request); - TEST (fcalled_request); - TEST (fcall_transfer); - TEST (fcalled_transfer); - TEST (zlocal_send); - TEST (zcalled_local_send); - TEST (zremote_send); - TEST (zcalled_remote_send); - TEST (zlocal_receive); - TEST (zcalled_local_receive); - TEST (zremote_receive); - TEST (zcalled_remote_receive); - TEST (zpath); - TEST (zcmds); - TEST (cfree_space); - TEST (zforwardto); - TEST (zpubdir); - TEST (zlocalname); - -#undef TEST - - qIalternates = qIalternates->qalternate; - } - - /* If there is a name for this alternate, put it in. */ - if (argc > 1) - sIhold.zalternate = xstrdup (argv[1]); - - uiset_clear (TRUE); - - return CMDTABRET_FREE; -} - -/* Process the time command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -titime (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - char *pznew[4]; - char ab[2]; - - pznew[0] = argv[0]; - ab[0] = 'z'; - ab[1] = '\0'; - pznew[1] = ab; - pznew[2] = argv[1]; - if (argc > 2) - pznew[3] = argv[2]; - - return titimegrade (argc + 1, pznew, (pointer) &sIhold.ztime, zerr); -} - -/* Process the timegrade and the call-timegrade commands. */ - -static enum tcmdtabret -titimegrade (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - char **pztime = (char **) pvar; - int clen; - char *z; - - if (argc < 3 || argc > 4) - { - ulog (LOG_ERROR, "%s: %s: Wrong number of arguments", zerr, argv[0]); - return CMDTABRET_FREE; - } - - if (argv[1][1] != '\0' || ! FGRADE_LEGAL (argv[1][0])) - { - ulog (LOG_ERROR, "%s: %s: Illegal grade '%s'", zerr, argv[0], - argv[1]); - return CMDTABRET_FREE; - } - - /* We should probably check whether the time string is legal. A - timegrade string is a single character grade, then a time string, - then an optional semicolon and a retry time. */ - - clen = strlen (argv[2]) + 2; - if (argc > 3) - clen += strlen (argv[3]) + 1; - z = (char *) alloca (clen); - *z = argv[1][0]; - strcpy (z + 1, argv[2]); - if (argc > 3) - { - strcat (z, ";"); - strcat (z, argv[3]); - } - - if (pztime == &sIhold.ztime) - { - if (fIclear_time) - { - *pztime = NULL; - fIclear_time = FALSE; - } - } - else - { - if (fIclear_calltimegrade) - { - *pztime = NULL; - fIclear_calltimegrade = FALSE; - } - } - - uadd_string (pztime, z, ' '); - - return CMDTABRET_FREE; -} - -/* Add a size command. */ - -static enum tcmdtabret tiadd_size P((int argc, char **argv, - const char *zerr, boolean *pf, - char **pz)); - -static enum tcmdtabret -tiadd_size (argc, argv, zerr, pf, pz) - int argc; - char **argv; - const char *zerr; - boolean *pf; - char **pz; -{ - long cbytes; - char *zend; - char *zarg; - - cbytes = strtol (argv[1], &zend, 10); - if (*zend != '\0') - { - ulog (LOG_ERROR, "%s: %s: Bad number", zerr, argv[0]); - return CMDTABRET_FREE; - } - - /* We should check the legality of the time string here. */ - - if (*pf) - { - *pz = NULL; - *pf = FALSE; - } - - zarg = (char *) alloca (strlen (argv[2]) + 20); - sprintf (zarg, "%ld %s", cbytes, argv[2]); - - uadd_string (pz, zarg, ' '); - - return CMDTABRET_FREE; -} - -/* Process the call-local-size command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -ticall_local_size (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - return tiadd_size (argc, argv, zerr, &fIclear_call_local_size, - &sIhold.zcall_local_size); -} - -/* Process the call-remote-size command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -ticall_remote_size (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - return tiadd_size (argc, argv, zerr, &fIclear_call_remote_size, - &sIhold.zcall_remote_size); -} - -/* Process the called-local-size command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -ticalled_local_size (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - return tiadd_size (argc, argv, zerr, &fIclear_called_local_size, - &sIhold.zcalled_local_size); -} - -/* Process the called-remote-size command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -ticalled_remote_size (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - return tiadd_size (argc, argv, zerr, &fIclear_called_remote_size, - &sIhold.zcalled_remote_size); -} - -/* Process the timetable command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -titimetable (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - uaddtimetable (argv[1], argv[2]); - return CMDTABRET_CONTINUE; -} - -/* Process the port command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tiport (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - if (argc < 2) - { - ulog (LOG_ERROR, "%s: %s: Wrong number of arguments", zerr, argv[0]); - return CMDTABRET_FREE; - } - - if (fIclear_port) - { - sIhold.zport = NULL; - sIhold.qport = NULL; - fIclear_port = FALSE; - } - - if (argc > 2) - { - enum tcmdtabret tret; - - if (sIhold.zport != NULL) - { - ulog (LOG_ERROR, - "%s: %s: Ignoring port specification following port name", - zerr, argv[0]); - return CMDTABRET_FREE; - } - tret = tprocess_port_cmd (argc - 1, argv + 1, (pointer) &sIhold.qport, - zerr); - if (sIhold.qport != NULL && sIhold.qport->zname == NULL) - { - char *zname; - - if (sIhold.zname == NULL) - sIhold.qport->zname = "default system file port"; - else - { - zname = (char *) alloca (strlen (sIhold.zname) - + sizeof "system port"); - sprintf (zname, "system %s port", sIhold.zname); - sIhold.qport->zname = xstrdup (zname); - } - } - -#if DEBUG > 1 - if (sIhold.qport != NULL) - DEBUG_MESSAGE2 (DEBUG_CONFIG, - "tiport: Command %s to port %s", argv[1], - sIhold.qport->zname); -#endif - - return tret; - } - else - { - if (sIhold.qport != NULL) - { - ulog (LOG_ERROR, - "%s: %s: Ignoring port name following port specification", - zerr, argv[0]); - return CMDTABRET_FREE; - } - - sIhold.zport = argv[1]; - - return CMDTABRET_CONTINUE; - } -} - -/* Process one of the chat commands. We have a special version for - systems just so that we clear out the chat failure strings. It - would be nice if there were a cleaner way to do this. */ - -static enum tcmdtabret -tichat (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - if (strcmp (argv[0], "chat-fail") == 0) - { - if (fIclear_chat_fail) - { - sIhold.schat.zfail = NULL; - fIclear_chat_fail = FALSE; - } - } - else if (strcmp (argv[0], "called-chat-fail") == 0) - { - if (fIclear_called_chat_fail) - { - sIhold.scalled_chat.zfail = NULL; - fIclear_called_chat_fail = FALSE; - } - } - - return tprocess_chat_cmd (argc, argv, pvar, zerr); -} - -/* Process the called-login command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -ticalled_login (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - if (argc < 2) - { - ulog (LOG_ERROR, "%s: %s: Wrong number of arguments", zerr, argv[0]); - return CMDTABRET_FREE; - } - - sIhold.zcalled_login = argv[1]; - - if (argc > 2) - uadd_validate (argv[1], argc - 2, (const char **) argv + 2); - - return CMDTABRET_CONTINUE; -} - -/* Process the protocol parameter command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tiproto_param (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - if (fIclear_proto_param) - { - sIhold.cproto_params = 0; - sIhold.qproto_params = NULL; - fIclear_proto_param = FALSE; - } - - return tadd_proto_param (&sIhold.cproto_params, &sIhold.qproto_params, - zerr, argc - 1, argv + 1); -} - -/* Process the request command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tirequest (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - char b; - boolean fset; - - b = argv[1][0]; - if (b == 'y' || b == 'Y' || b == 't' || b == 'T') - fset = TRUE; - else if (b == 'n' || b == 'N' || b == 'f' || b == 'F') - fset = FALSE; - else - { - ulog (LOG_ERROR, "%s: %s: %s: Bad boolean", zerr, argv[0], argv[1]); - return CMDTABRET_FREE; - } - - sIhold.fcall_request = fset; - sIhold.fcalled_request = fset; - - return CMDTABRET_FREE; -} - -/* Process the transfer command. */ - -/*ARGSUSED*/ -static enum tcmdtabret -titransfer (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - char b; - boolean fset; - - b = argv[1][0]; - if (b == 'y' || b == 'Y' || b == 't' || b == 'T') - fset = TRUE; - else if (b == 'n' || b == 'N' || b == 'f' || b == 'F') - fset = FALSE; - else - { - ulog (LOG_ERROR, "%s: %s: %s: Bad boolean", zerr, argv[0], argv[1]); - return CMDTABRET_FREE; - } - - sIhold.fcall_transfer = fset; - sIhold.fcalled_transfer = fset; - - return CMDTABRET_FREE; -} - -/* Mark all the contents of sIhold to be cleared before they are set. - If the falternate argument is TRUE, then only prepare to clear - those contents that should be cleared for an alternate. */ - -static void -uiset_clear (falternate) - boolean falternate; -{ - if (! falternate) - { - fIclear_alias = TRUE; - fIclear_alternate = TRUE; - } - fIclear_time = TRUE; - fIclear_calltimegrade = TRUE; - fIclear_call_local_size = TRUE; - fIclear_call_remote_size = TRUE; - fIclear_called_local_size = TRUE; - fIclear_called_remote_size = TRUE; - fIclear_port = TRUE; - fIclear_chat_fail = TRUE; - fIclear_proto_param = TRUE; - fIclear_called_chat_fail = TRUE; -} - -#endif /* HAVE_TAYLOR_CONFIG */ - -/* Set up the default values advertised in the documentation. */ - -void -uset_system_defaults (qsys) - struct ssysteminfo *qsys; -{ - qsys->zname = NULL; - qsys->zalias = NULL; - qsys->qalternate = NULL; - qsys->zalternate = NULL; - qsys->ztime = xmalloc (1 + sizeof "Never"); - sprintf (qsys->ztime, "%cNever", BGRADE_LOW); - qsys->zcalltimegrade = NULL; - qsys->zcall_local_size = NULL; - qsys->zcall_remote_size = NULL; - qsys->zcalled_local_size = NULL; - qsys->zcalled_remote_size = NULL; - qsys->ibaud = 0L; - qsys->ihighbaud = 0L; - qsys->zport = NULL; - qsys->zphone = NULL; - qsys->qport = NULL; - INIT_CHAT (&qsys->schat); - qsys->schat.zchat = - (char *) "\"\" \\r\\c ogin:-BREAK-ogin:-BREAK-ogin: \\L word: \\P"; - qsys->schat.ctimeout = 10; - qsys->zcall_login = NULL; - qsys->zcall_password = NULL; - qsys->zcalled_login = NULL; - qsys->fcallback = FALSE; - qsys->fsequence = FALSE; - qsys->zprotocols = NULL; - qsys->cproto_params = 0; - qsys->qproto_params = NULL; - INIT_CHAT (&qsys->scalled_chat); -#if DEBUG > 1 - qsys->idebug = 0; - qsys->imax_remote_debug = DEBUG_ABNORMAL | DEBUG_CHAT | DEBUG_HANDSHAKE; -#endif - qsys->fcall_request = TRUE; - qsys->fcalled_request = TRUE; - qsys->fcall_transfer = TRUE; - qsys->fcalled_transfer = TRUE; - qsys->zlocal_send = ZROOTDIR; - qsys->zcalled_local_send = NULL; - qsys->zremote_send = "~"; - qsys->zcalled_remote_send = NULL; - qsys->zlocal_receive = "~"; - qsys->zcalled_local_receive = NULL; - qsys->zremote_receive = "~"; - qsys->zcalled_remote_receive = NULL; - qsys->zpath = CMDPATH; - qsys->zcmds = "rnews rmail"; - qsys->cfree_space = DEFAULT_FREE_SPACE; - qsys->zforwardto = NULL; - qsys->zpubdir = NULL; - qsys->zlocalname = NULL; -} - -/* Variables to store the loaded system information. */ - -static boolean fIhave_systems; -static int cIsystems; -static struct ssysteminfo *pasIsystems; - -/* Read information about all systems. */ - -static void uiread_systems P((void)); - -static void -uiread_systems () -{ - if (fIhave_systems) - return; - - fIhave_systems = TRUE; - -#if HAVE_TAYLOR_CONFIG - if (zSysfile == NULL) - { - boolean fmore; - - /* Only warn about a missing file if we aren't going to read the - V2 or BNU files. */ - fmore = FALSE; -#if HAVE_V2_CONFIG - if (fV2) - fmore = TRUE; -#endif -#if HAVE_BNU_CONFIG - if (fBnu) - fmore = TRUE; -#endif - if (! fmore) - { - ulog (LOG_ERROR, "%s%s: file not found", NEWCONFIGLIB, - SYSFILE); - return; - } - } - else - { - struct smulti_file *qmulti; - int calc; - boolean fdefaults, fsystem; - struct ssysteminfo *qalternates; - - qmulti = qmulti_open (zSysfile); - if (qmulti != NULL) - { - calc = 0; - fdefaults = FALSE; - fsystem = FALSE; - qalternates = NULL; - - fIfirst = FALSE; - zInext_system = NULL; - - while (TRUE) - { - qIalternates = qalternates; - fIdefault_alternates = TRUE; - - /* Read commands. This will exit when it encounters the - start of a file (which it will when we first start - reading) and when it reads a ``system'' command. */ - uprocesscmds ((FILE *) NULL, qmulti, asIcmds, - (const char *) NULL, - CMDFLAG_WARNUNRECOG | CMDFLAG_BACKSLASH); - - /* The handling of alternates can get complex. Before - we start reading a system, fIclear_alternate is set - to TRUE (this is done in uiset_clear). After we have - finished reading a system, then if fIclear_alternate - is still TRUE then no ``alternate'' command was used - and the system information is in sIhold. Otherwise, - if fIclear_alternate is FALSE, an ``alternate'' - command was used and we must call tialternate one - more time; after this final call to tialternate, the - system information will be in sIalternate. - - The final call to tialternate is needed because each - occurrence of the ``alternate'' command links the - previous alternate into sIalternate and sets up - sIhold with the defaults for the next alternate. The - final call will link the last alternate into - sIalternate. */ - - if (fdefaults) - { - /* We were reading default information. Save it. */ - if (fIclear_alternate) - sIdefault = sIhold; - else - { - (void) tialternate (0, (char **) NULL, - (pointer) NULL, "alternate"); - sIdefault = sIalternate; - } - qalternates = sIdefault.qalternate; - sIdefault.qalternate = NULL; - fdefaults = FALSE; - } - else if (fsystem) - { - /* We just either finished a file or encountered a - ``system'' command after we had started reading a - system. Finish up the information for the system - we were reading. */ - if (cIsystems >= calc) - { - calc += 10; - pasIsystems = - ((struct ssysteminfo *) - xrealloc ((pointer) pasIsystems, - calc * sizeof (struct ssysteminfo))); - } - - /* We must now attach any remaining default - alternates. */ - if (fIdefault_alternates) - { - while (qIalternates != NULL) - (void) tialternate (0, (char **) NULL, - (pointer) NULL, "alternate"); - } - - if (fIclear_alternate) - pasIsystems[cIsystems] = sIhold; - else - { - (void) tialternate (0, (char **) NULL, - (pointer) NULL, "alternate"); - pasIsystems[cIsystems] = sIalternate; - } - - ++cIsystems; - - fsystem = FALSE; - } - - if (fIfirst) - { - /* We just started reading a new file. Reset the - default information. The next time around the - loop we will read the default information. */ - uset_system_defaults (&sIhold); - uiset_clear (FALSE); - qalternates = NULL; - fdefaults = TRUE; - fIfirst = FALSE; - } - else if (zInext_system != NULL) - { - /* We just encountered a ``system'' command. Save - the name, reset the system information to the - defaults, and go on to read the system - information. */ - sIhold = sIdefault; - sIhold.zname = zInext_system; - uiset_clear (FALSE); - fsystem = TRUE; - zInext_system = NULL; - } - else - { - /* We have reached the end of the files to read. */ - break; - } - } - - (void) fmulti_close (qmulti); - } - } -#endif /* HAVE_TAYLOR_CONFIG */ - -#if HAVE_V2_CONFIG - if (fV2) - { - int cv2; - struct ssysteminfo *pasv2; - - uv2_read_systems (&cv2, &pasv2); - if (cv2 > 0) - { - pasIsystems = - ((struct ssysteminfo *) - xrealloc ((pointer) pasIsystems, - (cIsystems + cv2) * sizeof (struct ssysteminfo))); - memcpy (pasIsystems + cIsystems, pasv2, - cv2 * sizeof (struct ssysteminfo)); - cIsystems += cv2; - } - } -#endif /* HAVE_V2_CONFIG */ - -#if HAVE_BNU_CONFIG - if (fBnu) - { - int cbnu; - struct ssysteminfo *pasbnu; - - ubnu_read_systems (&cbnu, &pasbnu); - if (cbnu > 0) - { - pasIsystems = - ((struct ssysteminfo *) - xrealloc ((pointer) pasIsystems, - (cIsystems + cbnu) * sizeof (struct ssysteminfo))); - memcpy (pasIsystems + cIsystems, pasbnu, - cbnu * sizeof (struct ssysteminfo)); - cIsystems += cbnu; - } - } -#endif /* HAVE_BNU_CONFIG */ -} - -/* Get information about all systems. */ - -void -uread_all_system_info (pc, ppas) - int *pc; - struct ssysteminfo **ppas; -{ - if (! fIhave_systems) - uiread_systems (); - - *pc = cIsystems; - *ppas = pasIsystems; -} - -/* Get information about a specific system. */ - -boolean -fread_system_info (zsystem, qsys) - const char *zsystem; - struct ssysteminfo *qsys; -{ - int i; - - DEBUG_MESSAGE1 (DEBUG_CONFIG, - "fread_system_info: Reading information for system %s", - zsystem); - - if (! fIhave_systems) - uiread_systems (); - - for (i = 0; i < cIsystems; i++) - { - char *z; - - if (strcmp (zsystem, pasIsystems[i].zname) == 0) - { - *qsys = pasIsystems[i]; - - DEBUG_MESSAGE1 (DEBUG_CONFIG, - "fread_system_info: Got information for system %s", - qsys->zname); - - return TRUE; - } - - z = pasIsystems[i].zalias; - if (z == NULL) - continue; - while (TRUE) - { - char *znext; - - znext = z + strcspn (z, " "); - if (strncmp (zsystem, z, znext - z) == 0) - { - *qsys = pasIsystems[i]; - - DEBUG_MESSAGE1 (DEBUG_CONFIG, - "fread_system_info: Got system %s", - qsys->zname); - - return TRUE; - } - z = znext; - if (*z == ' ') - ++z; - else - break; - } - } - - DEBUG_MESSAGE1 (DEBUG_CONFIG, - "fread_system_info: Could not find system %s", - zsystem); - - return FALSE; -} - -/* Prepare to read commands defining unknown systems. */ - -void -uiunknown_start () -{ -#if HAVE_TAYLOR_CONFIG - uset_system_defaults (&sIhold); - uiset_clear (FALSE); -#else /* ! HAVE_TAYLOR_CONFIG */ - uset_system_defaults (&sUnknown); -#endif /* ! HAVE_TAYLOR_CONFIG */ -} - -#if HAVE_TAYLOR_CONFIG - -/* Process a command defining unknown systems. This is actually - called from the main configuration file, not the system file. */ - -enum tcmdtabret -tiunknown (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - fUnknown_ok = TRUE; - return tprocess_one_cmd (argc - 1, argv + 1, asIcmds, zerr, - CMDFLAG_WARNUNRECOG); -} - -#endif /* HAVE_TAYLOR_CONFIG */ - -/* Finish up after all commands defining unknwon systems. */ - -void -uiunknown_end () -{ -#if HAVE_TAYLOR_CONFIG - if (fUnknown_ok) - { - /* Add the final alternate. */ - if (fIclear_alternate) - sUnknown = sIhold; - else - { - (void) tialternate (0, (char **) NULL, (pointer) NULL, "alternate"); - sUnknown = sIalternate; - } - } -#endif /* HAVE_TAYLOR_CONFIG */ -} - -/* Initialize the local system information. Perhaps it would be - desirable to allow the user to customize this as well. This is - called after the configuration file has been read in and the system - name has been determined. Only a few elements of this structure - are ever actually used, probably just zname and zremote_receive. */ - -void -uisetup_localsys () -{ - uset_system_defaults (&sLocalsys); - sLocalsys.zname = zLocalname; -} - -/* Translate a system name into something we can use locally. This should - be more intelligent than it is. Right now we just truncate the name; - if this matches the name of another system, we reject the call. */ - -const char * -ztranslate_system (zsystem) - const char *zsystem; -{ - char *z; - struct ssysteminfo s; - - if (strlen (zsystem) <= cSysdep_max_name_len) - return zsystem; - z = (char *) xmalloc (cSysdep_max_name_len + 1); - strncpy (z, zsystem, cSysdep_max_name_len); - z[cSysdep_max_name_len] = '\0'; - if (fread_system_info (z, &s)) - { - xfree ((pointer) z); - return NULL; - } - return z; -} - -#if HAVE_TAYLOR_CONFIG - -/* Get the login name and password for a system out of the call file. - The call file is simple a sequence of lines. The first word on - each line is the system name, the second word is the login name, - and the third word is the password. We read it using uprocesscmds, - since it's easy. */ - -struct silogpass -{ - char **pzlog; - char **pzpass; -}; - -static enum tcmdtabret tilog_pass P((int argc, char **argv, pointer pvar, - const char *zerr)); - -/*ARGSUSED*/ -static enum tcmdtabret -tilog_pass (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - struct silogpass *q = (struct silogpass *) pvar; - - *q->pzlog = xstrdup (argv[1]); - *q->pzpass = xstrdup (argv[2]); - return CMDTABRET_FREE_AND_EXIT; -} - -#endif /* HAVE_TAYLOR_CONFIG */ - -/* Get the login name and password to use for a system. */ - -boolean -fcallout_login (qsys, pzlog, pzpass) - const struct ssysteminfo *qsys; - char **pzlog; - char **pzpass; -{ - *pzlog = NULL; - *pzpass = NULL; - -#if HAVE_TAYLOR_CONFIG - { - struct smulti_file *qmulti; - struct scmdtab as[2]; - struct silogpass s; - - qmulti = qmulti_open (zCallfile); - if (qmulti == NULL) - return FALSE; - - s.pzlog = pzlog; - s.pzpass = pzpass; - - as[0].zcmd = qsys->zname; - as[0].itype = CMDTABTYPE_FN | 3; - as[0].pvar = (pointer)&s; - as[0].ptfn = tilog_pass; - - as[1].zcmd = NULL; - - uprocesscmds ((FILE *) NULL, qmulti, as, (const char *) NULL, - CMDFLAG_BACKSLASH); - - (void) fmulti_close (qmulti); - } -#endif /* HAVE_TAYLOR_CONFIG */ - - if (*pzlog == NULL) - { - ulog (LOG_ERROR, "No call out login for system %s", qsys->zname); - return FALSE; - } - - return TRUE; -} - -#if HAVE_TAYLOR_CONFIG - -/* Check whether a login name and password gathered by the UUCP program - itself are correct. */ - -static enum tcmdtabret ticheck_login P((int argc, char **argv, - pointer pvar, const char *zerr)); - -/*ARGSUSED*/ -static enum tcmdtabret -ticheck_login (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - char **pz = (char **) pvar; - - *pz = xstrdup (argv[1]); - return CMDTABRET_FREE_AND_EXIT; -} - -#endif /* HAVE_TAYLOR_CONFIG */ - -boolean -fcheck_login (zuser, zpass) - const char *zuser; - const char *zpass; -{ -#if HAVE_TAYLOR_CONFIG - struct smulti_file *qmulti; - struct scmdtab as[2]; - char *zfilepass; - boolean fok; - - if (zPwdfile == NULL) - { - ulog (LOG_ERROR, "%s%s: file not found", NEWCONFIGLIB, - PASSWDFILE); - return FALSE; - } - - qmulti = qmulti_open (zPwdfile); - if (qmulti == NULL) - return FALSE; - - zfilepass = NULL; - - as[0].zcmd = zuser; - as[0].itype = CMDTABTYPE_FN | 2; - as[0].pvar = (pointer)&zfilepass; - as[0].ptfn = ticheck_login; - - as[1].zcmd = NULL; - - uprocesscmds ((FILE *) NULL, qmulti, as, (const char *) NULL, - CMDFLAG_CASESIGNIFICANT | CMDFLAG_BACKSLASH); - - (void) fmulti_close (qmulti); - - fok = zfilepass != NULL && strcmp (zfilepass, zpass) == 0; - - if (zfilepass != NULL) - { - bzero (zfilepass, strlen (zfilepass)); - xfree ((pointer) zfilepass); - } - - if (! fok) - ulog (LOG_ERROR, "Bad login"); - - return fok; - -#else /* HAVE_TAYLOR_CONFIG */ - - ulog (LOG_ERROR, "Not compiled to accept logins"); - return FALSE; - -#endif /* HAVE_TAYLOR_CONFIG */ -} - -#if HAVE_TAYLOR_CONFIG - -/* Process a chat command. These are done as prefix commands. We set - it up such that argv[0] will contain the string "chat" and we must - look after that point to see what command to execute. */ - -static struct schat_info sChat; - -static enum tcmdtabret tcchat_fail P((int argc, char **argv, - pointer pvar, - const char *zerr)); - -static const struct scmdtab asChatcmds[] = -{ - { "chat", CMDTABTYPE_FULLSTRING, (pointer) &sChat.zchat, NULL }, - { "chat-program", CMDTABTYPE_FULLSTRING, (pointer) &sChat.zprogram, - NULL }, - { "chat-timeout", CMDTABTYPE_INT, (pointer) &sChat.ctimeout, NULL }, - { "chat-fail", CMDTABTYPE_FN | 2, NULL, tcchat_fail }, - { "chat-seven-bit", CMDTABTYPE_BOOLEAN, (pointer) &sChat.fstrip, NULL }, - { NULL, 0, NULL, NULL } -}; - -enum tcmdtabret -tprocess_chat_cmd (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - struct schat_info *qchat = (struct schat_info *) pvar; - char *zchat; - enum tcmdtabret t; - - zchat = strstr (argv[0], "chat"); - -#if DEBUG > 0 - if (zchat == NULL) - ulog (LOG_FATAL, "tprocess_chat_cmd: Can't happen"); -#endif - - argv[0] = zchat; - - sChat = *qchat; - t = tprocess_one_cmd (argc, argv, asChatcmds, zerr, - CMDFLAG_WARNUNRECOG); - *qchat = sChat; - - return t; -} - -/* Add a new chat failure string. */ - -static enum tcmdtabret -tcchat_fail (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - uadd_string (&sChat.zfail, argv[1], ' '); - return CMDTABRET_FREE; -} - -#endif /* HAVE_TAYLOR_CONFIG */ - -#if HAVE_TAYLOR_CONFIG - -/* Add a protocol parameter entry. The pc parameter points to the - number of protocol parameter entries, and the pq parameter points - to the array of protocol parameters. */ - -enum tcmdtabret -tadd_proto_param (pc, pq, zerr, cargs, azargs) - int *pc; - struct sproto_param **pq; - const char *zerr; - int cargs; - char **azargs; -{ - int i; - struct sproto_param *q; - int ientry; - int icopy; - - if (cargs < 1) - { - ulog (LOG_ERROR, "%s: protocol-parameter: Not enough arguments", zerr); - return CMDTABRET_FREE; - } - if (azargs[0][1] != '\0') - { - ulog (LOG_ERROR, - "%s: protocol-parameter: Protocol names are single characters", - zerr); - return CMDTABRET_FREE; - } - - q = NULL; - ientry = 0; - - for (i = 0; i < *pc; i++) - { - if ((*pq)[i].bproto == azargs[0][0]) - { - q = &(*pq)[i]; - ientry = q->centries; - ++q->centries; - q->qentries = - ((struct sproto_param_entry *) - xrealloc ((pointer) q->qentries, - (q->centries * sizeof (struct sproto_param_entry)))); - break; - } - } - - if (i >= *pc) - { - ++(*pc); - *pq = ((struct sproto_param *) - xrealloc ((pointer) *pq, - (*pc * sizeof (struct sproto_param)))); - q = &(*pq)[*pc - 1]; - q->bproto = azargs[0][0]; - q->centries = 1; - q->qentries = ((struct sproto_param_entry *) - xmalloc (sizeof (struct sproto_param_entry))); - ientry = 0; - } - - q->qentries[ientry].cargs = cargs - 1; - q->qentries[ientry].azargs = - (char **) xmalloc ((cargs - 1) * sizeof (char *)); - for (icopy = 0; icopy < cargs - 1; icopy++) - q->qentries[ientry].azargs[icopy] = azargs[icopy + 1]; - - return CMDTABRET_CONTINUE; -} - -#endif /* HAVE_TAYLOR_CONFIG */ - -/* Apply some protocol parameters, given the current protocol. */ - -void -uapply_proto_params (bproto, qcmds, c, pas) - int bproto; - struct scmdtab *qcmds; - int c; - struct sproto_param *pas; -{ - int i; - struct sproto_param *q; - - for (i = 0, q = pas; - i < c; - i++, q++) - { - if (q->bproto == (char) bproto) - { - char ab[sizeof "g protocol parameters"]; - struct sproto_param_entry *qentry; - int ientry; - - sprintf (ab, "%c protocol parameters", bproto); - q = &pas[i]; - for (ientry = 0, qentry = &q->qentries[0]; - ientry < q->centries; - ientry++, qentry++) - (void) tprocess_one_cmd (qentry->cargs, qentry->azargs, - qcmds, ab, CMDFLAG_WARNUNRECOG); - return; - } - } -} - -/* Maintain a list of systems which are permitted to log in using a - particular login name. This is the VALIDATE entry from the BNU - Permissions file. */ - -static struct svalidate -{ - struct svalidate *qnext; - const char *zlogname; - int cmachines; - const char *azmachines[1]; -} *qIvalidate; - -/* Add an entry to the validation list. This assumes that it does not - have to copy the login name or the machine names. It does copy the - array of machines names. */ - -void -uadd_validate (zlogname, cmachines, pazmachines) - const char *zlogname; - int cmachines; - const char **pazmachines; -{ - struct svalidate **pq, *q; - - for (pq = &qIvalidate; *pq != NULL; pq = &(*pq)->qnext) - { - if (strcmp ((*pq)->zlogname, zlogname) == 0) - { - *pq = ((struct svalidate *) - xrealloc ((pointer) *pq, - sizeof (struct svalidate) - + (((*pq)->cmachines + cmachines - 1) - * sizeof (const char *)))); - memcpy ((*pq)->azmachines + (*pq)->cmachines, pazmachines, - cmachines * sizeof (const char *)); - (*pq)->cmachines += cmachines; - return; - } - } - - q = (struct svalidate *) xmalloc (sizeof (struct svalidate) - + ((cmachines - 1) - * sizeof (const char *))); - q->qnext = qIvalidate; - q->zlogname = zlogname; - memcpy (q->azmachines, pazmachines, - cmachines * sizeof (const char *)); - q->cmachines = cmachines; - qIvalidate = q; -} - -/* Check whether a particular login name/machine name is valid. */ - -boolean -fcheck_validate (zlogname, zmachine) - const char *zlogname; - const char *zmachine; -{ - struct svalidate *q; - - for (q = qIvalidate; q != NULL; q = q->qnext) - { - if (strcmp (q->zlogname, zlogname) == 0) - { - int i; - - for (i = 0; i < q->cmachines; i++) - if (strcmp (q->azmachines[i], zmachine) == 0) - return TRUE; - - return FALSE; - } - } - - return TRUE; -} - -/* The variables which hold the array of timetables. */ - -int cTtable; -struct stimetable *pasTtable; - -/* Initialize the table of timetables as advertised in the - documentation. */ - -void -uinittimetables () -{ - pasTtable = (struct stimetable *) xmalloc (3 * sizeof (struct stimetable)); - pasTtable[0].zname = "Evening"; - pasTtable[0].ztime = "Wk1705-0755,Sa,Su"; - pasTtable[1].zname = "Night"; - pasTtable[1].ztime = "Wk2305-0755,Sa,Su2305-1655"; - pasTtable[2].zname = "NonPeak"; - pasTtable[2].ztime = "Wk1805-0655,Sa,Su"; - cTtable = 3; -} - -/* Add a new timetable entry. This assumes it can take control of the - strings it is passed, so they must not be on the stack and if they - have been allocated they must not be freed. */ - -void -uaddtimetable (zname, ztime) - const char *zname; - const char *ztime; -{ - if (pasTtable == NULL) - uinittimetables (); - - pasTtable = ((struct stimetable *) - xrealloc ((pointer) pasTtable, - (cTtable + 1) * sizeof (struct stimetable))); - pasTtable[cTtable].zname = zname; - pasTtable[cTtable].ztime = ztime; - ++cTtable; -} diff --git a/gnu/libexec/uucp/system.h b/gnu/libexec/uucp/system.h deleted file mode 100644 index ccc5ae2c014f..000000000000 --- a/gnu/libexec/uucp/system.h +++ /dev/null @@ -1,668 +0,0 @@ -/* system.h - Header file for system dependent stuff in the Taylor UUCP package. - This file is not itself system dependent. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Id: system.h,v 1.2 1993/08/02 17:25:13 mycroft Exp $ -*/ - -#ifndef SYSTEM_H - -#define SYSTEM_H - -/* Any function which returns an error should also report an error - message. - - Many of the function may share a common static buffer; this is - noted in the description of the function. */ - -/* The maximum length of a remote system name. */ -extern int cSysdep_max_name_len; - -/* Initialize. If something goes wrong, this routine should just - exit. The fdaemon argument is TRUE if called from uucico or uuxqt. - The fgetcwd argument is TRUE if the current working directory is - needed. This is used because on Unix it can be expensive to - determine the current working directory (some versions of getcwd - fork a process), but in most cases we don't need to know it. - However, we are going to chdir to the spool directory, so we have - to get the cwd now if we are ever going to get it. Both uucp and - uux use the function fsysdep_needs_cwd to determine whether they - will need the current working directory, and pass the argument to - usysdep_initialize appropriately. There's probably a cleaner way - to handle this, but this will suffice for now. */ -extern void usysdep_initialize P((boolean fdaemon, boolean fgetcwd)); - -/* Exit the program. The fsuccess argument indicates whether to - return an indication of success or failure to the outer - environment. This routine should not return. */ -extern void usysdep_exit P((boolean fsuccess)); - -/* Called when a non-standard configuration file is being used, to - avoid handing out privileged access. If it returns FALSE, the - default configuration file will be used. This is called before - the usysdep_initialize function is called. */ -extern boolean fsysdep_other_config P((const char *)); - -/* Detach from the controlling terminal. This probably only makes - sense on Unix. It is called by uucico to try to get the modem port - as a controlling terminal. It is also called by uucico before it - starts up uuxqt, so that uuxqt will be a complete daemon. */ -extern void usysdep_detach P((void)); - -/* Get the local node name if it is not specified in the configuration - file. This is called before the usysdep_initialize function is - called. It should return NULL on error. The return value should - point to a static buffer. */ -extern const char *zsysdep_local_name P((void)); - -/* Get the login name. This is used when uucico is started up with no - arguments in slave mode, which causes it to assume that somebody - has logged in. It also used by uucp and uux for recording the user - name. This may not return NULL. The return value should point to - a static buffer. */ -extern const char *zsysdep_login_name P((void)); - -/* Set a signal handler for a signal. If the signal occurs, the - appropriate element of afSignal should be set to the signal number - (see the declaration of afSignal in uucp.h). This routine might be - able to just use signal, but 4.3 BSD requires more complex - handling. This is called before usysdep_initialize. */ -extern void usysdep_signal P((int isig)); - -/* Catch a signal. This is actually defined as a macro in the system - dependent header file, and the prototype here just indicates how it - should be called. It is called before a routine which must exit if - a signal occurs, and is expected to set do a setjmp (which is why - it must be a macro). It is actually only called in one place in - the system independent code, before the call to read stdin in uux. - This is needed to handle 4.2 BSD restartable system calls, which - require a longjmp. On systems which don't need to do - setjmp/longjmp around system calls, this can be redefined in - to TRUE. It should return TRUE if the routine should - proceed, or FALSE if a signal occurred. After having this return - TRUE, usysdep_start_catch should be used to start catching the - signal; this basically tells the signal handler that it's OK to do - the longjmp, if fsysdep_catch did not already do so. */ -extern boolean fsysdep_catch P((void)); - -/* Start catching a signal. This is called after fsysdep_catch to - tell the signal handler to go ahead and do the longjmp. */ -extern void usysdep_start_catch P((void)); - -/* Stop catching a signal. This is called when it is no longer - necessary for fsysdep_catch to handle signals. */ -extern void usysdep_end_catch P((void)); - -/* Link two files. On Unix this should attempt the link. If it - succeeds it should return TRUE with *pfworked set to TRUE. If the - link fails because it must go across a device, it should return - TRUE with *pfworked set to FALSE. If the link fails for some other - reason, it should print an error message and return FALSE. On a - system which does not support links to files, this should just - return TRUE with *pfworked set to FALSE. */ -extern boolean fsysdep_link P((const char *zfrom, const char *zto, - boolean *pfworked)); - -/* Get the port name. This is used when uucico is started up in slave - mode to figure out which port was used to call in so that it can - determine any appropriate protocol parameters. This may return - NULL if the port cannot be determined, which will just mean that no - protocol parameters are applied. The name returned should be the - sort of name that would appear in the port file. This should set - *pftcp_port to TRUE if it can determine that the port is a TCP - connection rather than a normal serial port. */ -extern const char *zsysdep_port_name P((boolean *pftcp_port)); - -/* Make a spool directory for a system. This will be called each time - the system might be accessed. It should return FALSE on error. */ -extern boolean fsysdep_make_spool_dir P((const struct ssysteminfo *qsys)); - -/* Return whether a file name is in a directory, and check for read or - write access. This should check whether zfile is within zdir (or - is zdir itself). If it is not, it should return FALSE. If zfile - is in zdir, then fcheck indicates whether further checking should - be done. If fcheck is FALSE, no further checking is done. - Otherwise, if freadable is TRUE the user zuser should have search - access to all directories from zdir down to zfile and should have - read access on zfile itself (if zfile does not exist, or is not a - regular file, this function may return FALSE but does not have to). - If freadable is FALSE, the user zuser should have search access to - all directories from zdir down to zfile and should have write - access on zfile (which may be a directory, or may not actually - exist, which is acceptable). The zuser argument may be NULL, in - which case the check should be made for any user, not just zuser. - There is no way for this function to return error. The qsys - argument should be used to expand ~ into the public directory. */ -extern boolean fsysdep_in_directory P((const struct ssysteminfo *qsys, - const char *zfile, - const char *zdir, - boolean fcheck, - boolean freadable, - const char *zuser)); - -/* Return TRUE if a file exists, FALSE otherwise. There is no way to - return error. */ -extern boolean fsysdep_file_exists P((const char *zfile)); - -/* Exit the current program and start a new one. If the ffork - argument is TRUE, the new program should be started up and the - current program should continue (but in all current cases, it will - immediately exit anyhow); if the ffork argument is FALSE, the new - program should replace the current program. The three string - arguments may be catenated together to form the program to execute; - I did it this way to make it easy to call execl(2), and because I - never needed more than two arguments. The program will always be - "uucico" or "uuxqt". The return value will be passed directly to - usysdep_exit, and should be TRUE on success, FALSE on error. */ -extern boolean fsysdep_run P((boolean ffork, const char *zprogram, - const char *zarg1, const char *zarg2)); - -/* Send a mail message. This function will be passed an array of - strings. All necessary newlines are already included; the strings - should simply be concatenated together to form the mail message. - It should return FALSE on error, although the return value is often - ignored. */ -extern boolean fsysdep_mail P((const char *zto, const char *zsubject, - int cstrs, const char **paz)); - -/* Get the time in seconds since some epoch. The actual epoch is - unimportant, so long as the time values are consistent across calls - to the program, and the value is never negative. If the pimicros - argument is not NULL, it should be set to the number of - microseconds (if this is not available, *pimicros should be set to - zero). */ - extern long isysdep_time P((long *pimicros)); - -/* Get the time in seconds and microseconds (millionths of a second) - since some epoch. The actual epoch is not important, and it may - change in between program invocations; this is provided because on - Unix the times function may be used. If microseconds can not be - determined, *pimicros can just be set to zero. */ -extern long isysdep_process_time P((long *pimicros)); - -/* Parse the value returned by isysdep_time into a struct tm. I - assume that this structure is defined in . This is - basically just localtime, except that the ANSI function takes a - time_t which may not be what is returned by isysdep_time. The - typedef is a hack to avoid the problem of mentioning a structure - for the first time in a prototype while remaining compatible with - standard C. The type tm_ptr is never again referred to. */ -typedef struct tm *tm_ptr; -extern void usysdep_localtime P((long itime, tm_ptr q)); - -/* Sleep for a number of seconds. */ -extern void usysdep_sleep P((int cseconds)); - -/* Pause for half a second. */ -extern void usysdep_pause P((void)); - -/* Lock a remote system. This should return FALSE if the system is - already locked (no error should be reported). */ -extern boolean fsysdep_lock_system P((const struct ssysteminfo *qsys)); - -/* Unlock a remote system. This should return FALSE on error - (although the return value is generally ignored). */ -extern boolean fsysdep_unlock_system P((const struct ssysteminfo *qsys)); - -/* Get the conversation sequence number for a remote system, and - increment it for next time. This should return -1 on error. */ -extern long isysdep_get_sequence P((const struct ssysteminfo *qsys)); - -/* Get the status of a remote system. This should return FALSE on - error. Otherwise it should set *qret to the status. */ -extern boolean fsysdep_get_status P((const struct ssysteminfo *qsys, - struct sstatus *qret)); - -/* Set the status of a remote system. This should return FALSE on - error. The system will be locked before this call is made. */ -extern boolean fsysdep_set_status P((const struct ssysteminfo *qsys, - const struct sstatus *qset)); - -/* Check whether there is work for a remote system. This should set - *pbgrade to the highest grade of work waiting to execute. It - should return TRUE if there is work, FALSE otherwise; there is no - way to indicate an error. */ -extern boolean fsysdep_has_work P((const struct ssysteminfo *qsys, - char *pbgrade)); - -/* Initialize the work scan. This will be called before - fsysdep_get_work. The bgrade argument is the minimum grade of - execution files that should be considered (e.g. a bgrade of 'd' - will allow all grades from 'A' to 'Z' and 'a' to 'd'). It should - return FALSE on error. */ -extern boolean fsysdep_get_work_init P((const struct ssysteminfo *qsys, - int bgrade)); - -/* Get the next command to be executed for a remote system. The - bgrade argument will be the same as for fsysdep_get_work_init; - probably only one of these functions will use it, namely the - function for which it is more convenient. This should return FALSE - on error. The structure pointed to by qcmd should be filled in. - The strings may point into a static buffer; they will be copied out - if necessary. If there is no more work, this should set qcmd->bcmd - to 'H' and return TRUE. This should set qcmd->pseq to something - which can be passed to fsysdep_did_work to remove the job from the - queue when it has been completed. */ -extern boolean fsysdep_get_work P((const struct ssysteminfo *qsys, - int bgrade, struct scmd *qcmd)); - -/* Remove a job from the work queue. This must also remove the - temporary file used for a send command, if there is one. It should - return FALSE on error. */ -extern boolean fsysdep_did_work P((pointer pseq)); - -/* Save the temporary file for a send command. This function should - return a string that will be put into a mail message. On success - this string should say something like ``The file has been saved as - ...''. On failure it could say something like ``The file could not - be saved because ...''. If there is no temporary file, or for some - reason it's not appropriate to include a message, this function - should just return NULL. This function is used when a file send - fails for some reason, to make sure that we don't completely lost - the file. */ -extern const char *zsysdep_save_temp_file P((pointer pseq)); - -/* Cleanup anything left over by fsysdep_get_work_init and - fsysdep_get_work. This may be called even though - fsysdep_get_work_init has not been. */ -extern void usysdep_get_work_free P((const struct ssysteminfo *qsys)); - -/* Get the real file name for a file. The file may or may not exist - on the system. If the zname argument is not NULL, then the zfile - argument may be a directory; if it is, zname should be used for the - name of the file within the directory. The zname argument may not - be simple (it may be in the format of another OS) so care should be - taken with it. On Unix, if the zfile argument begins with ~user/ - it goes in that users home directory, and if it begins with ~/ - (~uucp/) it goes in the public directory (note that each system may - have its own public directory); similar conventions may be - desirable on other systems. The return value may point to a common - static buffer. This should return NULL on error. */ -extern const char *zsysdep_real_file_name P((const struct ssysteminfo *, - const char *zfile, - const char *zname)); - -/* Get a file name from the spool directory. This should return - NULL on error. The return value may point to a common static - buffer. */ -extern const char *zsysdep_spool_file_name P((const struct ssysteminfo *, - const char *zfile)); - -/* Make necessary directories. This should create all non-existent - directories for a file. If the fpublic argument is TRUE, anybody - should be permitted to create and remove files in the directory; - otherwise anybody can list the directory, but only the UUCP system - can create and remove files. It should return FALSE on error. */ -extern boolean fsysdep_make_dirs P((const char *zfile, boolean fpublic)); - -/* Create a stdio file, setting appropriate protection. If the - fpublic argument is TRUE, the file is made publically accessible; - otherwise it is treated as a private data file. If the fappend - argument is TRUE, the file is opened in append mode; otherwise any - previously existing file of the same name is removed, and the file - is kept private to the UUCP system. If the fmkdirs argument is - TRUE, then any necessary directories should also be created. On a - system in which file protections are unimportant (and the necessary - directories exist), this may be implemented as - - fopen (zfile, fappend ? "a" : "w"); - - */ -extern FILE *esysdep_fopen P((const char *zfile, boolean fpublic, - boolean fappend, boolean fmkdirs)); - -/* Open a file to send to another system; the qsys argument is the - system the file is being sent to. If fcheck is TRUE, it should - make sure that the file is readable by zuser (if zuser is NULL the - file must be readable by anybody). This is to eliminate a window - between fsysdep_in_directory and esysdep_open_send. The function - should set *pimode to the mode that should be sent over (this - should be a UNIX style file mode number). It should set *pcbytes - to the number of bytes contained in the file. If an error occurs, - it should return EFILECLOSED and, if pfgone is not NULL, it should - *pfgone to TRUE if the file no longer exists or FALSE if there was - some other error. */ -extern openfile_t esysdep_open_send P((const struct ssysteminfo *qsys, - const char *zname, - boolean fcheck, - const char *zuser, - unsigned int *pimode, - long *pcbytes, - boolean *pfgone)); - -/* Open a file to receive from another system. Receiving a file is - done in two steps. First esysdep_open_receive is called. This - should open a temporary file and return the file name in *pztemp. - It may ignore qsys (the system the file is coming from) and zto - (the file to be created) although they are passed in case they are - useful. The file mode is not available at this point. The *pztemp - return value may point to a common static buffer. The amount of - free space should be returned in *pcbytes; ideally it should be the - lesser of the amount of free space on the file system of the - temporary file and the amount of free space on the file system of - the final destination. If the amount of free space is not - available, *pcbytes should be set to -1. The function should - return EFILECLOSED on error. - - After the file is written, fsysdep_move_file will be called to move - the file to its final destination, and to set the correct file - mode. */ -extern openfile_t esysdep_open_receive P((const struct ssysteminfo *qsys, - const char *zto, - const char **pztemp, - long *pcbytes)); - -/* Move a file. This is used to move a received file to its final - location. It is also used by uuxqt to move files in and out of the - execute directory. The zto argument is the file to create. The - zorig argument is the name of the file to move. The imode argument - is the Unix file mode to use for the final file; if it is zero, it - should be ignored and the file should be kept private to the UUCP - system. If fcheck is TRUE, this should make sure the directory is - writeable by the user zuser (if zuser is NULL, then it must be - writeable by any user); this is to avoid a window of vulnerability - between fsysdep_in_directory and fsysdep_move_file. This function - should return FALSE on error; the zorig file should be removed even - if an error occurs. */ -extern boolean fsysdep_move_file P((const char *zorig, const char *zto, - unsigned int imode, boolean fcheck, - const char *zuser)); - -/* Truncate a file which we are receiving into. This may be done by - closing the original file, removing it and reopening it. This - should return FALSE on error. */ -extern openfile_t esysdep_truncate P((openfile_t e, const char *zname)); - -/* Start expanding a wildcarded file name. This should return FALSE - on error; otherwise subsequent calls to zsysdep_wildcard should - return file names. The argument may have leading ~ characters. */ -extern boolean fsysdep_wildcard_start P((const struct ssysteminfo *qsys, - const char *zfile)); - -/* Get the next wildcard name. This should return NULL when there are - no more names to return. The return value may point to a common - static buffer. The argument should be the same as that to - fsysdep_wildcard_start. There is no way to return error. */ -extern const char *zsysdep_wildcard P((const struct ssysteminfo *qsys, - const char *zfile)); - -/* Finish getting wildcard names. This may be called before or after - zsysdep_wildcard has returned NULL. It should return FALSE on - error. */ -extern boolean fsysdep_wildcard_end P((void)); - -/* Prepare to execute a bunch of file transfer requests. This should - make an entry in the spool directory so that the next time uucico - is started up it will transfer these files. The bgrade argument - specifies the grade of the commands. The commands themselves are - in the pascmds array, which has ccmds entries. The function should - return NULL on error, or the jobid on success. The jobid is a - string that may be printed or passed to fsysdep_kill_job and - related functions, but is otherwise uninterpreted. */ - extern const char *zsysdep_spool_commands P((const struct ssysteminfo *qsys, - int bgrade, int ccmds, - const struct scmd *pascmds)); - -/* Get a file name to use for a data file to be copied to another - system. A file which will become an execute file will use a grade - of 'X' (actually this is just convention, but it affects where the - file will be placed in the spool directory on Unix). The ztname, - zdname and zxname arguments will all either be NULL or point to an - array of CFILE_NAME_LEN characters in length. The ztname array - should be set to a temporary file name that could be passed to - zsysdep_spool_file_name to retrieve the return value of this - function; this will be appropriate for the temporary name in a send - request. The zdname array should be set to a data file name that - is appropriate for the spool directory of the other system; this - will be appropriate for the name of the destination file in a send - request of a data file for an execution of some sort. The zxname - array should be set to an execute file name that is appropriate for - the other system. This should return NULL on error. The return - value may point to a common static buffer. */ - -#define CFILE_NAME_LEN (15) - -extern const char *zsysdep_data_file_name P((const struct ssysteminfo *qsys, - int bgrade, char *ztname, - char *zdname, char *zxname)); - -/* Get a name for a local execute file. This is used by uux for a - local command with remote files. It should return NULL on error. - The return value may point to a common static buffer. */ -extern const char *zsysdep_xqt_file_name P((void)); - -/* Beginning getting execute files. To get a list of execute files, - first fsysdep_get_xqt_init is called, then zsysdep_get_xqt is - called several times until it returns NULL, then finally - usysdep_get_xqt_free is called. */ -extern boolean fsysdep_get_xqt_init P((void)); - -/* Get the next execute file. This should return NULL when finished - (with *pferr set to FALSE). On an error this should return NULL - with *pferr set to TRUE. This should set *pzsystem to the name of - the system for which the execute file was created. */ -extern const char *zsysdep_get_xqt P((const char **pzsystem, - boolean *pferr)); - -/* Clean up after getting execute files. */ -extern void usysdep_get_xqt_free P((void)); - -/* Get the absolute pathname of a command to execute. This is given - the legal list of commands (which may be the special case "ALL") - and the path. It must return an absolute pathname to the command. - If it gets an error it should set *pferr to TRUE and return NULL; - if the command is not found it should set *pferr to FALSE and - return NULL. Otherwise, the return value may point to a common - static buffer. */ -extern const char *zsysdep_find_command P((const char *zcmd, - const char *zcmds, - const char *zpath, - boolean *pferr)); - -#if ! ALLOW_FILENAME_ARGUMENTS -/* Check an argument to an execution command to make sure that it - doesn't refer to a file name that may not be accessed. This should - check the argument to see if it is a filename. If it is, it should - either reject it out of hand or it should call fin_directory_list - on the file with both qsys->zremote_receive and qsys->zremote_send. - If the file is rejected, it should log an error and return FALSE. - Otherwise it should return TRUE. */ -extern boolean fsysdep_xqt_check_file P((const struct ssysteminfo *qsys, - const char *zfile)); -#endif /* ! ALLOW_FILENAME_ARGUMENTS */ - -/* Run an execute file. The arguments are: - - qsys -- system for which execute file was created - zuser -- user who requested execution - pazargs -- list of arguments to command (element 0 is command) - zfullcmd -- command and arguments stuck together in one string - zinput -- file name for standard input (may be NULL) - zoutput -- file name for standard output (may be NULL) - fshell -- if TRUE, use /bin/sh to execute file - pzerror -- set to name of standard error file - pftemp -- set to TRUE if error is temporary, FALSE otherwise - - If fshell is TRUE, the command should be executed with /bin/sh - (obviously, this can only really be done on Unix systems). If an - error occurs this should return FALSE and set *pftemp - appropriately. */ -extern boolean fsysdep_execute P((const struct ssysteminfo *qsys, - const char *zuser, - const char **pazargs, - const char *zfullcmd, - const char *zinput, - const char *zoutput, - boolean fshell, - const char **pzerror, - boolean *pftemp)); - -/* Lock a particular uuxqt command (e.g. rmail). This should return - FALSE if the command is already locked. This is used to make sure - only one uuxqt process is handling a particular command. There is - no way to return error. */ - -/* Lock for uuxqt execution. If the global variable cMaxuuxqts is not - zero, this should make sure that no more than cMaxuuxqts uuxqt - processes are running at once. Also, only one uuxqt may execute a - particular command (specified by the -c option) at a time. If zcmd - is not NULL, it is a command that must be locked. This should - return a nonegative number which will be passed to - fsysdep_unlock_uuxqt, or -1 on error. */ -extern int isysdep_lock_uuxqt P((const char *zcmd)); - -/* Unlock a uuxqt process. This is passed the return value of - isysdep_lock_uuxqt, as well as the zcmd argument passed to - isysdep_lock_uuxqt. It may return FALSE on error, but at present - the return value is ignored. */ -extern boolean fsysdep_unlock_uuxqt P((int iseq, const char *zcmd)); - -/* See whether a particular uuxqt command is locked. This should - return TRUE if the command is locked (because isysdep_lock_uuxqt - was called with it as an argument), FALSE otherwise. There is no - way to return error. */ -extern boolean fsysdep_uuxqt_locked P((const char *zcmd)); - -/* Lock an execute file in order to execute it. This should return - FALSE if the execute file is already locked. There is no way to - return error. */ -extern boolean fsysdep_lock_uuxqt_file P((const char *zfile)); - -/* Unlock an execute file. This should return FALSE on error. */ -extern boolean fsysdep_unlock_uuxqt_file P((const char *zfile)); - -/* Lock the execution directory. This should return FALSE if the - directory is already locked. There is no way to return error. */ -extern boolean fsysdep_lock_uuxqt_dir P((void)); - -/* Remove all files in the execution directory, and unlock it. This - should return FALSE on error. */ -extern boolean fsysdep_unlock_uuxqt_dir P((void)); - -/* Add the working directory to a file name. If the file already has - a directory, it should not be changed. The return value may point - to a common static buffer. If the flocal argument is TRUE, then - this is a local file (so, for example, a leading ~ should be - expanded as appropriate); otherwise the file is on a remote system. - This should return NULL on error. */ -extern const char *zsysdep_add_cwd P((const char *zfile, - boolean flocal)); - -/* See whether a file name will need the current working directory - when zsysdep_add_cwd is called on it. This will be called before - usysdep_initialize. It should just check whether the argument is - an absolute path. See the comment above usysdep_initialize in this - file for an explanation of why things are done this way. */ -extern boolean fsysdep_needs_cwd P((const char *zfile)); - -/* Get the base name of a file. The file will be a local file name, - and this function should return the base file name, ideally in a - form which will make sense on most systems; it will be used if the - destination of a uucp is a directory. */ -extern const char *zsysdep_base_name P((const char *zfile)); - -/* Return a filename within a directory. The zdir argument may name a - file, in which case it should be returned. If it names a - directory, this function should get the filename from the zfile - argument and return that filename within the directory. */ -extern const char *zsysdep_in_dir P((const char *zdir, const char *zfile)); - -/* Get the mode of a file. This should return a Unix style file mode. - It should return 0 on error. */ -extern unsigned int isysdep_file_mode P((const char *zfile)); - -/* See whether the user has access to a file. This is called by uucp - and uux to prevent copying of a file which uucp can read but the - user cannot. If access is denied, this should log an error message - and return FALSE. */ -extern boolean fsysdep_access P((const char *zfile)); - -/* See whether the daemon has access to a file. This is called by - uucp and uux when a file is queued up for transfer without being - copied into the spool directory. It is merely an early error - check, as the daemon would of course discover the error itself when - it tried the transfer. If access would be denied, this should log - an error message and return FALSE. */ -extern boolean fsysdep_daemon_access P((const char *zfile)); - -/* Return the jobid of a work file, given the sequence value. On - error this should log an error and return NULL. The jobid is a - string which may be printed out and read in and passed to - fsysdep_kill_job, etc., but is not otherwise interpreted. The - return value may point to a common statis buffer. */ -extern const char *zsysdep_jobid P((const struct ssysteminfo *qsys, - pointer pseq)); - -/* Kill a job, given the jobid. This should remove all associated - files and in general eliminate the job completely. On error it - should log an error message and return FALSE. */ -extern boolean fsysdep_kill_job P((const char *zjobid)); - -/* Rejuvenate a job, given the jobid. If possible, this should update - the time associated with the job such that it will not be - eliminated by uuclean or similar programs that check the creation - time. This should affect the return value of isysdep_work_time. - On error it should log an error message and return FALSE. */ -extern boolean fsysdep_rejuvenate_job P((const char *zjobid)); - -/* Get the time a job was queued, given the sequence number. There is - no way to indicate error. The return value must use the same epoch - as isysdep_time. */ -extern long isysdep_work_time P((const struct ssysteminfo *qsys, - pointer pseq)); - -/* Get the time a file was created. This is called by uustat on - execution files. There is no way to indicate error. The return - value must use the same epoch as isysdep_time. */ -extern long isysdep_file_time P((const char *zfile)); - -/* Get the size in bytes of a file. There is no way to indicate - error. This is only used by uustat. */ -extern long csysdep_size P((const char *zfile)); - -/* Start getting status information for all systems with available - status information. There may be status information for unknown - systems, which is why this series of functions is used. The phold - argument is used to pass information around, to possibly avoid the - use of static variables. On error this should log an error and - return FALSE. */ -extern boolean fsysdep_all_status_init P((pointer *phold)); - -/* Get status information for the next system. This should return the - system name and fill in the qstat argument. The phold argument - will be that set by fsysdep_all_status_init. On error this should - log an error, set *pferr to TRUE, and return NULL. */ -extern const char *zsysdep_all_status P((pointer phold, boolean *pferr, - struct sstatus *qstat)); - -/* Free up anything allocated by fsysdep_all_status_init and - zsysdep_all_status. The phold argument is that set by - fsysdep_all_status_init. */ -extern void usysdep_all_status_free P((pointer phold)); - -/* Display the process status of all processes holding lock files. - This is uustat -p. The return value is passed to usysdep_exit. */ -extern boolean fsysdep_lock_status P((void)); - -#endif /* ! defined (SYSTEM_H) */ diff --git a/gnu/libexec/uucp/tcp.c b/gnu/libexec/uucp/tcp.c deleted file mode 100644 index ea1a7eb4b34d..000000000000 --- a/gnu/libexec/uucp/tcp.c +++ /dev/null @@ -1,363 +0,0 @@ -/* tcp.c - Code to handle TCP connections. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: tcp.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.16 1992/03/30 15:37:22 ian - Petri Helenius: TCP server never started uuxqt - - Revision 1.15 1992/03/17 02:44:08 ian - Declare _exit - - Revision 1.14 1992/03/17 00:34:10 ian - Cast argument to bzero - - Revision 1.13 1992/03/15 04:51:17 ian - Keep an array of signals we've received rather than a single variable - - Revision 1.12 1992/03/15 01:54:46 ian - All execs are now done in isspawn, all waits are done in iswait - - Revision 1.11 1992/03/12 19:56:10 ian - Debugging based on types rather than number - - Revision 1.10 1992/03/11 02:09:57 ian - Franc,ois Pinard: retry fork several times before giving up - - Revision 1.9 1992/03/10 22:57:03 ian - Petri Helenius: have server fork twice to avoid zombies - - Revision 1.8 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.7 1991/12/28 03:49:23 ian - Added HAVE_MEMFNS and HAVE_BFNS; changed uses of memset to bzero - - Revision 1.6 1991/12/26 22:54:32 ian - Monty Solomon: cast arguments to avoid prototype errors - - Revision 1.5 1991/12/22 22:14:19 ian - Monty Solomon: added HAVE_UNISTD_H configuration parameter - - Revision 1.4 1991/12/10 19:45:05 ian - Added ulog_device to record device name for log file - - Revision 1.3 1991/11/24 20:06:08 ian - Michael Haberler: itcp_port_number of a number wasn't calling htons - - Revision 1.2 1991/11/14 03:20:13 ian - Added seven-bit and reliable commands to help when selecting protocols - - Revision 1.1 1991/11/13 20:38:00 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char tcp_rcsid[] = "$Id: tcp.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#if HAVE_TCP - -#include - -#if USE_STDIO && HAVE_UNISTD_H -#include -#endif - -#include -#include -#include -#include - -#include "sysdep.h" -#include "port.h" -#include "system.h" - -/* External functions. */ -extern int close (); -extern int socket (), bind (), listen (), accept (), connect (); -extern void _exit (); - -/* This code handles TCP connections by providing a set of routines - that are called by the port routines. It assumes a Berkeley socket - interface. */ - -/* The normal "uucp" port number. */ -#define IUUCP_PORT (540) - -/* Local function to get the port number from a name. */ -static int itcp_port_number P((const char *zport)); - -/* Lock a port. There is no need to lock a TCP port. */ - -boolean -ftcp_lock (qport, fin) - struct sport *qport; - boolean fin; -{ - return TRUE; -} - -/* Open a port. If the fwait argument is TRUE, we are running as a - server. Otherwise we are just trying to reach another system. */ - -boolean -ftcp_open (qport, ibaud, fwait) - struct sport *qport; - long ibaud; - boolean fwait; -{ - struct sockaddr_in s; - - ulog_device ("TCP"); - - qport->u.stcp.o = socket (AF_INET, SOCK_STREAM, 0); - if (qport->u.stcp.o == -1) - { - ulog (LOG_ERROR, "socket: %s", strerror (errno)); - return FALSE; - } - - /* If we aren't waiting for a connection, we're done. */ - - if (! fwait) - return TRUE; - - /* Run as a server and wait for a new connection. The code in - uucico.c has already detached us from our controlling terminal. - From this point on if the server gets an error we exit; we only - return if we have received a connection. It would be more robust - to respawn the server if it fails; someday. */ - - bzero ((pointer) &s, sizeof s); - s.sin_family = AF_INET; - s.sin_port = itcp_port_number (qport->u.stcp.zport); - s.sin_addr.s_addr = htonl (INADDR_ANY); - - if (bind (qport->u.stcp.o, (struct sockaddr *) &s, sizeof s) == -1) - { - ulog (LOG_ERROR, "bind: %s", strerror (errno)); - usysdep_exit (FALSE); - } - if (listen (qport->u.stcp.o, 5) == -1) - { - ulog (LOG_ERROR, "listen: %s", strerror (errno)); - usysdep_exit (FALSE); - } - - while (! FGOT_SIGNAL ()) - { - int clen; - int onew; - pid_t ipid; - - DEBUG_MESSAGE0 (DEBUG_PORT, - "ftcp_open: Waiting for connections"); - - clen = sizeof s; - onew = accept (qport->u.stcp.o, (struct sockaddr *) &s, &clen); - if (onew == -1) - { - ulog (LOG_ERROR, "accept: %s", strerror (errno)); - usysdep_exit (FALSE); - } - - DEBUG_MESSAGE0 (DEBUG_PORT, - "ftcp_open: Got connection; forking"); - - ipid = isfork (); - if (ipid < 0) - { - ulog (LOG_ERROR, "fork: %s", strerror (errno)); - usysdep_exit (FALSE); - } - if (ipid == 0) - { - (void) close (qport->u.stcp.o); - qport->u.stcp.o = onew; - - /* Now we fork and let our parent die, so that we become - a child of init. This lets the main server code wait - for its child and then continue without accumulating - zombie children. */ - - ipid = isfork (); - if (ipid < 0) - { - ulog (LOG_ERROR, "fork: %s", strerror (errno)); - _exit (EXIT_FAILURE); - } - - if (ipid != 0) - _exit (EXIT_SUCCESS); - - return TRUE; - } - - (void) close (onew); - - /* Now wait for the child. */ - (void) iswait ((unsigned long) ipid, (const char *) NULL); - } - - /* We got a signal. */ - usysdep_exit (FALSE); - - /* Avoid compiler warnings. */ - return FALSE; -} - -/* Close the port. */ - -boolean -ftcp_close (qport, fsuccess) - struct sport *qport; - boolean fsuccess; -{ - if (close (qport->u.stcp.o) == -1) - { - ulog (LOG_ERROR, "close: %s", strerror (errno)); - return FALSE; - } - return TRUE; -} - -/* Reset the port. This will be called by a child which was forked - off in ftcp_open, above. We don't want uucico to continue looping - and giving login prompts, so we pretend that we received a SIGINT - signal. This should probably be handled more cleanly. */ - -boolean -ftcp_reset (qport) - struct sport *qport; -{ - afSignal[INDEXSIG_SIGINT] = TRUE; - return TRUE; -} - -/* Dial out on a TCP port, so to speak: connect to a remote computer. */ - -boolean -ftcp_dial (qport, qsys, pcproto_params, pqproto_params, pireliable) - struct sport *qport; - const struct ssysteminfo *qsys; - int *pcproto_params; - struct sproto_param **pqproto_params; - int *pireliable; -{ - const char *zhost; - struct sockaddr_in s; - struct hostent *q; - - /* There are no dialer protocol parameters, but a TCP connection is - fully reliable. */ - *pcproto_params = 0; - *pqproto_params = NULL; - *pireliable = (RELIABLE_SPECIFIED | RELIABLE_ENDTOEND - | RELIABLE_RELIABLE | RELIABLE_EIGHT); - - zhost = qsys->zphone; - if (zhost == NULL) - zhost = qsys->zname; - - /* Cast argument to avoid prototype error on NeXT. */ - q = gethostbyname ((char *) zhost); - if (q == NULL) - { - ulog (LOG_ERROR, "gethostbyname (%s): %s", zhost, strerror (errno)); - return FALSE; - } - - s.sin_family = q->h_addrtype; - s.sin_port = itcp_port_number (qport->u.stcp.zport); - memcpy (&s.sin_addr.s_addr, q->h_addr, q->h_length); - - if (connect (qport->u.stcp.o, (struct sockaddr *) &s, sizeof s) == -1) - { - ulog (LOG_ERROR, "connect: %s", strerror (errno)); - return FALSE; - } - - return TRUE; -} - -/* Return the baud rate. */ - -long -itcp_baud (qport) - struct sport *qport; -{ - return 0; -} - -/* Get the port number given a name. The argument will almost always - be "uucp" so we cache that value. The return value is always in - network byte order. This returns -1 on error. */ - -static int -itcp_port_number (zname) - const char *zname; -{ - boolean fuucp; - static int iuucp; - int i; - char *zend; - struct servent *q; - - fuucp = strcmp (zname, "uucp") == 0; - if (fuucp && iuucp != 0) - return iuucp; - - /* Try it as a number first. */ - i = strtol (zname, &zend, 10); - if (i != 0 && *zend == '\0') - return htons (i); - - /* Cast arguments to avoid prototype errors on NeXT. */ - q = getservbyname ((char *) zname, (char *) "tcp"); - if (q == NULL) - { - /* We know that the "uucp" service should be 540, even if isn't - in /etc/services. */ - if (fuucp) - { - iuucp = htons (IUUCP_PORT); - return iuucp; - } - ulog (LOG_ERROR, "getservbyname (%s): %s", zname, strerror (errno)); - return -1; - } - - if (fuucp) - iuucp = q->s_port; - - return q->s_port; -} - -#endif /* HAVE_TCP */ diff --git a/gnu/libexec/uucp/time.c b/gnu/libexec/uucp/time.c deleted file mode 100644 index 7ff051203e1e..000000000000 --- a/gnu/libexec/uucp/time.c +++ /dev/null @@ -1,705 +0,0 @@ -/* time.c - Routines to deal with UUCP time strings. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: time.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.12 1992/03/17 00:32:40 ian - Cast argument to qttime_parse - - Revision 1.11 1992/03/09 05:08:16 ian - Added status for wrong time to call, not used if system can't be called - - Revision 1.10 1992/03/08 01:52:34 ian - Removed extraneous semicolons - - Revision 1.9 1992/03/07 02:56:30 ian - Rewrote time routines - - Revision 1.8 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.7 1992/01/11 17:30:10 ian - John Antypas: use memcpy instead of relying on structure assignment - - Revision 1.6 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.5 1991/12/22 20:57:57 ian - Added externs for strcasecmp or strncasecmp - - Revision 1.4 1991/09/19 02:22:44 ian - Chip Salzenberg's patch to allow ";retrytime" at the end of a time string - - Revision 1.3 1991/09/12 05:04:44 ian - Wrong sense of comparison in btime_low_grade - - Revision 1.2 1991/09/11 16:59:00 ian - fcheck_time and btime_low_grade looped endlessly on unusual grades - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char time_rcsid[] = "$Id: time.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#if HAVE_TIME_H -#include -#endif - -#if ! HAVE_TIME_T -#if HAVE_SYS_TIME_T -#include -#endif /* HAVE_SYS_TIME_T */ -#endif /* ! HAVE_TIME_T */ - -#include "uutime.h" - -/* External functions. */ -extern int strncasecmp (); -extern time_t time (); -extern struct tm *localtime (); - -/* Local functions. */ - -static struct sspan *qtnew P((struct sspan *qnext, long ival, - int istart, int iend, int cretry)); -static struct sspan *qtadd_span P((struct sspan *qlist, long ival, - int istart, int iend, - boolean (*picmp) P((long, long)), - int cretry)); -static struct sspan *qttime_parse P((const char *ztime, - struct sspan *qlist, long ival, - boolean (*picmp) P((long, long)), - int cretry)); - -/* A helper function to create a new time span with the specified - arguments. */ - -static struct sspan * -qtnew (qnext, ival, istart, iend, cretry) - struct sspan *qnext; - long ival; - int istart; - int iend; - int cretry; -{ - struct sspan *q; - - q = (struct sspan *) xmalloc (sizeof (struct sspan)); - q->qnext = qnext; - q->ival = ival; - q->istart = istart; - q->iend = iend; - q->cretry = cretry; - return q; -} - -/* A simple function to free a list of time spans. */ - -void -utimespan_free (q) - struct sspan *q; -{ - while (q != NULL) - { - struct sspan *qnext; - - qnext = q->qnext; - xfree ((pointer) q); - q = qnext; - } -} - -/* Add a time span to an existing list of time spans. We keep the - list sorted by time to make this operation easier. This modifies - the existing list, and returns the modified version. It takes a - comparison function which should return < 0 if the first argument - should take precedence over the second argument and == 0 if they - are the same (for grades this is igradecmp; for sizes it is minus - (the binary operator)). */ - -static struct sspan * -qtadd_span (qlist, ival, istart, iend, picmp, cretry) - struct sspan *qlist; - long ival; - int istart; - int iend; - boolean (*picmp) P((long, long)); - int cretry; -{ - struct sspan **pq; - - /* istart < iend */ - for (pq = &qlist; *pq != NULL; pq = &(*pq)->qnext) - { - int icmp; - - /* Invariant: PREV (*pq) == NULL || PREV (*pq)->iend <= istart */ - /* istart < iend && (*pq)->istart < (*pq)->iend */ - - if (iend <= (*pq)->istart) - { - /* istart < iend <= (*pq)->istart < (*pq)->iend */ - /* No overlap, and we're at the right spot. See if we can - combine these spans. */ - if (iend == (*pq)->istart - && cretry == (*pq)->cretry - && (*picmp) (ival, (*pq)->ival) == 0) - { - (*pq)->istart = istart; - return qlist; - } - /* We couldn't combine them. */ - break; - } - - if ((*pq)->iend <= istart) - { - /* (*pq)->istart < (*pq)->iend <= istart < iend */ - /* No overlap. Try attaching this span. */ - if ((*pq)->iend == istart - && (*pq)->cretry == cretry - && ((*pq)->qnext == NULL - || iend <= (*pq)->qnext->istart) - && (*picmp) (ival, (*pq)->ival) == 0) - { - (*pq)->iend = iend; - return qlist; - } - /* Couldn't attach; keep looking for the right spot. We - might be able to combine part of the new span onto an - existing span, but it's probably not worth it. */ - continue; - } - - /* istart < iend - && (*pq)->istart < (*pq)->iend - && istart < (*pq)->iend - && (*pq)->istart < iend */ - /* Overlap. */ - - icmp = (*picmp) (ival, (*pq)->ival); - - if (icmp == 0) - { - /* Just expand the old span to include the new span. */ - if (istart < (*pq)->istart) - (*pq)->istart = istart; - if ((*pq)->iend < iend) - (*pq)->iend = iend; - } - else if (icmp < 0) - { - /* Replace the old span with the new span. */ - if ((*pq)->istart < istart) - { - /* Save the initial portion of the old span. */ - *pq = qtnew (*pq, (*pq)->ival, (*pq)->istart, istart, - (*pq)->cretry); - pq = &(*pq)->qnext; - } - if (iend < (*pq)->iend) - { - /* Save the final portion of the old span. */ - (*pq)->qnext = qtnew ((*pq)->qnext, (*pq)->ival, iend, - (*pq)->iend, (*pq)->cretry); - } - (*pq)->ival = ival; - (*pq)->istart = istart; - (*pq)->iend = iend; - (*pq)->cretry = cretry; - } - else - { - /* Leave the old span untouched. */ - if (istart < (*pq)->istart) - { - /* Put in the initial portion of the new span. */ - *pq = qtnew (*pq, ival, istart, (*pq)->istart, cretry); - pq = &(*pq)->qnext; - } - if ((*pq)->iend < iend) - { - /* Put in the final portion of the new span. */ - (*pq)->qnext = qtnew ((*pq)->qnext, ival, (*pq)->iend, - iend, cretry); - } - } - - return qlist; - } - - /* This is the spot for the new span, and there's no overlap. */ - - *pq = qtnew (*pq, ival, istart, iend, cretry); - - return qlist; -} - -/* An array of weekday abbreviations. The code below assumes that - each one starts with a lower case letter. */ - -static const struct -{ - const char *zname; - int imin; - int imax; -} asTdays[] = -{ - { "any", 0, 6 }, - { "wk", 1, 5 }, - { "su", 0, 0 }, - { "mo", 1, 1 }, - { "tu", 2, 2 }, - { "we", 3, 3 }, - { "th", 4, 4 }, - { "fr", 5, 5 }, - { "sa", 6, 6 }, - { "never", -1, -2 }, - { NULL, 0, 0 } -}; - -/* Parse a time string and add it to a span list. This function is - given the value and comparison function to use. The time string - continues to a null byte, a space or a semicolon. This returns the - new span list, or NULL on error. If no time matches, it will wind - up returning qlist, which may itself be NULL. */ - -static struct sspan * -qttime_parse (ztime, qlist, ival, picmp, cretry) - const char *ztime; - struct sspan *qlist; - long ival; - int (*picmp) P((long, long)); - int cretry; -{ - const char *zend; - char bfirst; - int i; - - zend = ztime + strcspn (ztime, "; "); - - if (pasTtable == NULL) - uinittimetables (); - - /* Expand the string using a timetable. */ - bfirst = tolower (BUCHAR (*ztime)); - for (i = 0; i < cTtable; i++) - { - if (bfirst == tolower (BUCHAR (pasTtable[i].zname[0])) - && strncasecmp (ztime, pasTtable[i].zname, zend - ztime) == 0) - { - ztime = pasTtable[i].ztime; - zend = ztime + strlen (ztime); - /* Now search the table for this string. */ - i = -1; - } - } - - /* Look through the portions of the time string separated by a - comma or a vertical bar. */ - - for (; ztime < zend; ztime += strcspn (ztime, ",|")) - { - int iday; - boolean afday[7]; - const char *z; - int istart, iend; - - if (*ztime == ',' || *ztime == '|') - ++ztime; - - for (iday = 0; iday < 7; iday++) - afday[iday] = FALSE; - - /* Get the days. */ - - z = ztime; - do - { - bfirst = tolower (BUCHAR (*z)); - for (iday = 0; asTdays[iday].zname != NULL; iday++) - { - int clen; - - if (bfirst != asTdays[iday].zname[0]) - continue; - - clen = strlen (asTdays[iday].zname); - if (strncasecmp (z, asTdays[iday].zname, clen) == 0) - { - int iset; - - for (iset = asTdays[iday].imin; - iset <= asTdays[iday].imax; - iset++) - afday[iset] = TRUE; - z += clen; - break; - } - } - if (asTdays[iday].zname == NULL) - { - ulog (LOG_ERROR, "%s: unparseable time string", ztime); - return NULL; - } - } - while (isalpha (BUCHAR (*z))); - - /* Get the hours. */ - - if (! isdigit (BUCHAR (*z))) - { - istart = 0; - iend = 24 * 60; - } - else - { - char *zendnum; - - istart = (int) strtol (z, &zendnum, 10); - if (*zendnum != '-' || ! isdigit (BUCHAR (zendnum[1]))) - { - ulog (LOG_ERROR, "%s: unparseable time string", ztime); - return NULL; - } - z = zendnum + 1; - iend = (int) strtol (z, &zendnum, 10); - if (*zendnum != '\0' - && *zendnum != ' ' - && *zendnum != ';' - && *zendnum != ',' - && *zendnum != '|') - { - ulog (LOG_ERROR, "%s: unparseable time string", ztime); - return NULL; - } - - istart = (istart / 100) * 60 + istart % 100; - iend = (iend / 100) * 60 + iend % 100; - } - - /* Add the times we've found onto the list. */ - - for (iday = 0; iday < 7; iday++) - { - if (afday[iday]) - { - int iminute; - - iminute = iday * 24 * 60; - if (istart < iend) - qlist = qtadd_span (qlist, ival, iminute + istart, - iminute + iend, picmp, cretry); - else - { - /* Wrap around midnight. */ - qlist = qtadd_span (qlist, ival, iminute, - iminute + iend, picmp, cretry); - qlist = qtadd_span (qlist, ival, iminute + istart, - iminute + 24 * 60, picmp, - cretry); - } - } - } - } - - return qlist; -} - -/* See if the current time matches a time span. If it does, return - TRUE, set *pival to the value for the matching span, and set - *pcretry to the retry for the matching span. Otherwise return - FALSE. */ - -boolean -ftimespan_match (qspan, pival, pcretry) - const struct sspan *qspan; - long *pival; - int *pcretry; -{ - time_t inow; - struct tm *qtm; - int itm; - const struct sspan *q; - - time (&inow); - qtm = localtime (&inow); - - /* Get the number of minutes since Sunday for the time. */ - itm = qtm->tm_wday * 24 * 60 + qtm->tm_hour * 60 + qtm->tm_min; - - for (q = qspan; q != NULL; q = q->qnext) - { - if (q->istart <= itm && itm <= q->iend) - { - if (pival != NULL) - *pival = q->ival; - if (pcretry != NULL) - *pcretry = q->cretry; - return TRUE; - } - } - - return FALSE; -} - -/* Compare two work grades. */ - -static int itgradecmp P((long, long)); - -static int -itgradecmp (i1, i2) - long i1; - long i2; -{ - return igradecmp ((int) i1, (int) i2); -} - -/* Parse a time grade string into a time span. A time grade string is - a series of single character work grades followed by time strings. - The time string may end with a semicolon and a retry time. Each - grade/time/retry tuple is separated by a single space. This - function returns a time span, or NULL if no time matches or an - error occurs. */ - -struct sspan * -qtimegrade_parse (ztimegrade) - const char *ztimegrade; -{ - struct sspan *qret; - - if (ztimegrade == NULL) - return NULL; - - qret = NULL; - - while (TRUE) - { - const char *zretry; - int cretry; - struct sspan *qnext; - - zretry = ztimegrade + strcspn (ztimegrade, "; "); - if (*zretry == ';') - cretry = atoi (zretry + 1); - else - cretry = 0; - - qnext = qttime_parse (ztimegrade + 1, qret, (long) *ztimegrade, - itgradecmp, cretry); - if (qnext != NULL) - qret = qnext; - - ztimegrade += strcspn (ztimegrade, " "); - - if (*ztimegrade == '\0') - break; - - ++ztimegrade; - } - - return qret; -} - -/* Compare sizes when putting them into a timestring. */ - -static int itsizecmp P((long, long)); - -static int -itsizecmp (i1, i2) - long i1; - long i2; -{ - /* We can't just return i1 - i2 because that would be a long. */ - if (i1 < i2) - return -1; - else if (i1 == i2) - return 0; - else - return 1; -} - -/* Parse a time size string into a span. A time size string is a - size, a space, a time string, a space, repeated. There is no retry - time associated with a time size string. */ - -struct sspan * -qtimesize_parse (ztimesize) - const char *ztimesize; -{ - struct sspan *qret; - - if (ztimesize == NULL) - return NULL; - - qret = NULL; - - while (TRUE) - { - long isize; - char *zend; - struct sspan *qnext; - - isize = strtol (ztimesize, &zend, 10); - -#if DEBUG > 0 - if (*zend != ' ') - ulog (LOG_FATAL, "qtimesize_parse: Can't happen"); -#endif - - ++zend; - - qnext = qttime_parse (zend, qret, isize, itsizecmp, 0); - if (qnext != NULL) - qret = qnext; - - ztimesize = zend + strcspn (zend, " "); - - if (*ztimesize == '\0') - break; - - ++ztimesize; - } - - return qret; -} - -/* Determine the grade of work we are permitted to do at the current - time, given a time/grade string. Return a null byte if no grades - are legal. */ - -char -btimegrade (ztimegrade) - const char *ztimegrade; -{ - struct sspan *qspan; - boolean fmatch; - long ival; - - qspan = qtimegrade_parse (ztimegrade); - if (qspan == NULL) - return '\0'; - - fmatch = ftimespan_match (qspan, &ival, (int *) NULL); - - utimespan_free (qspan); - - if (! fmatch) - return '\0'; - - return (int) ival; -} - -/* Determine the maximum size that may be transferred at the present - time, according to a time size string. This returns -1 if there - are no restrictions. */ - -long -cmax_size_now (ztimesize) - const char *ztimesize; -{ - struct sspan *qspan; - boolean fmatch; - long ival; - - qspan = qtimesize_parse (ztimesize); - if (qspan == NULL) - return -1; - - fmatch = ftimespan_match (qspan, &ival, (int *) NULL); - - utimespan_free (qspan); - - if (! fmatch) - return -1; - - return ival; -} - -/* Determine the maximum size that may ever be transferred, according - to a time size string. This returns -1 if there is no limit. */ - -long -cmax_size_ever (ztimesize) - const char *ztimesize; -{ - struct sspan *qspan; - long imax; - struct sspan *q; - - qspan = qtimesize_parse (ztimesize); - if (qspan == NULL) - return -1; - - /* Look through the list of spans. If there is any gap larger than - 1 hour, we assume there are no restrictions. Otherwise we keep - track of the largest value we see. I picked 1 hour arbitrarily, - on the theory that a 1 hour span to transfer large files might - actually occur, and is probably not an accident. */ - - if (qspan->istart >= 60) - { - utimespan_free (qspan); - return -1; - } - - imax = -1; - - for (q = qspan; q != NULL; q = q->qnext) - { - if (q->qnext == NULL) - { - if (q->iend <= 6 * 24 * 60 + 23 * 60) - { - utimespan_free (qspan); - return -1; - } - } - else - { - if (q->iend + 60 <= q->qnext->istart) - { - utimespan_free (qspan); - return -1; - } - } - - if (imax < q->ival) - imax = q->ival; - } - - utimespan_free (qspan); - - return imax; -} diff --git a/gnu/libexec/uucp/util.c b/gnu/libexec/uucp/util.c deleted file mode 100644 index b77e81bad765..000000000000 --- a/gnu/libexec/uucp/util.c +++ /dev/null @@ -1,684 +0,0 @@ -/* util.c - Utilities for the UUCP package. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: util.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.11 1992/03/12 19:56:10 ian - Debugging based on types rather than number - - Revision 1.10 1992/03/02 04:53:07 ian - Marc Unangst: added HAVE_SCO_LOCKFILES configuration parameter - - Revision 1.9 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.8 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.7 1992/01/19 18:29:05 ian - Added HAVE_BSEARCH configuration parameter - - Revision 1.6 1992/01/15 20:40:04 ian - Mike Park: some systems don't have - - Revision 1.5 1991/12/28 06:10:50 ian - Added HAVE_STRCHR and HAVE_INDEX to conf.h - - Revision 1.4 1991/12/28 03:49:23 ian - Added HAVE_MEMFNS and HAVE_BFNS; changed uses of memset to bzero - - Revision 1.3 1991/12/11 19:35:48 ian - Mark Powell: put in my own version of strtol - - Revision 1.2 1991/11/21 21:20:41 ian - Brian Campbell: offer str{n}icmp as an alternative to str{n}casecmp - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char util_rcsid[] = "$Id: util.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include -#include - -#if HAVE_LIMITS_H -#include -#endif - -/* Allocate a block of memory without fail. */ - -pointer -xmalloc (c) - int c; -{ - pointer pret; - - pret = malloc (c); - if (pret == NULL && c != 0) - ulog (LOG_FATAL, "Out of memory"); - return pret; -} - -/* Realloc a block of memory without fail. Supposedly some versions of - realloc can't handle a NULL first argument, so we check for that - here. */ - -pointer -xrealloc (p, c) - pointer p; - int c; -{ - pointer pret; - - if (p == NULL) - return xmalloc (c); - pret = realloc (p, c); - if (pret == NULL && c != 0) - ulog (LOG_FATAL, "Out of memory"); - return pret; -} - -/* Some versions of free (like the one in SCO Unix 3.2.2) don't handle - null pointers correctly, so we go through our own routine. */ - -void -xfree (p) - pointer p; -{ - if (p != NULL) - free (p); -} - -/* Read a string of arbitrary length from a stdio file, returning an - malloced memory area. */ - -#define CFGETSDEFAULT (63) - -char * -zfgets (e, fbackslash) - FILE *e; - boolean fbackslash; -{ - char *zret, *z, *zend; - int clen; - int ichar; - - clen = CFGETSDEFAULT; - - /* Allocate one extra byte for the '\0'. */ - zret = (char *) xmalloc (clen + 1); - - z = zret; - zend = zret + clen; - while ((ichar = getc (e)) != EOF) - { - if (z >= zend) - { - char *znew; - - clen += CFGETSDEFAULT; - - /* Allocate one extra byte for the '\0'. */ - znew = (char *) xrealloc ((pointer) zret, clen + 1); - z = znew + (z - zret); - zret = znew; - zend = zret + clen; - } - - *z++ = (char) ichar; - if (ichar == '\n') - { - if (! fbackslash || z - zret < 2 || z[-2] != '\\') - break; - z -= 2; - } - } - - if (z == zret) - { - xfree ((pointer) zret); - return NULL; - } - - *z = '\0'; - - return zret; -} - -#if ! HAVE_STRDUP - -/* Duplicate a string in memory. */ - -char * -strdup (z) - const char *z; -{ - char *zret; - - zret = malloc (strlen (z) + 1); - if (zret != NULL) - strcpy (zret, z); - return zret; -} - -#endif /* ! HAVE_STRDUP */ - -/* Duplicate a string in memory with no errors. */ - -char * -xstrdup (z) - const char *z; -{ - char *zret; - - zret = strdup (z); - if (zret == NULL) - ulog (LOG_FATAL, "Out of memory"); - return zret; -} - -#if ! HAVE_STRSTR - -/* Look for one string inside another. */ - -char * -strstr (zhold, zwithin) - const char *zhold; - const char *zwithin; -{ - register char b; - register char bwithin; - - if ((bwithin = *zwithin++) == '\0') - return (char *) zhold; - - while ((b = *zhold++) != '\0') - { - if (bwithin == b) - { - register const char *zout, *zin; - - zout = zhold; - zin = zwithin; - do - { - if (*zin == '\0') - return (char *) (zhold - 1); - } - while (*zout++ == *zin++); - } - } - - return (char *) NULL; -} - -#endif /* ! HAVE_STRSTR */ - -#if ! HAVE_STRCASECMP && ! HAVE_STRICMP - -/* Do a case insensitive string comparison. */ - -int -strcasecmp (z1, z2) - const char *z1; - const char *z2; -{ - char b1, b2; - - while ((b1 = *z1++) != '\0') - { - b2 = *z2++; - if (b2 == '\0') - return 1; - if (b1 != b2) - { - if (isupper (BUCHAR (b1))) - b1 = tolower (BUCHAR (b1)); - if (isupper (BUCHAR (b2))) - b2 = tolower (BUCHAR (b2)); - if (b1 != b2) - return b1 - b2; - } - } - if (*z2 == '\0') - return 0; - else - return -1; -} - -int -strncasecmp (z1, z2, c) - const char *z1; - const char *z2; - int c; -{ - char b1, b2; - - if (c <= 0) - return 0; - while ((b1 = *z1++) != '\0') - { - b2 = *z2++; - if (b2 == '\0') - return 1; - if (b1 != b2) - { - if (isupper (BUCHAR (b1))) - b1 = tolower (BUCHAR (b1)); - if (isupper (BUCHAR (b2))) - b2 = tolower (BUCHAR (b2)); - if (b1 != b2) - return b1 - b2; - } - --c; - if (c <= 0) - return 0; - } - if (*z2 == '\0') - return 0; - else - return -1; -} - -#endif /* ! HAVE_STRCASECMP && ! HAVE_STRICMP */ - -#if ! HAVE_MEMCHR - -/* Find a single byte in a memory block. */ - -pointer -memchr (parg, b, c) - constpointer parg; - int b; - int c; -{ - const char *p = (const char *) parg; - - b = BUCHAR (b); - while (c-- != 0) - if (BUCHAR (*p++) == b) - return (pointer) --p; - return NULL; -} - -#endif /* ! HAVE_MEMCHR */ - -#if ! HAVE_MEMCMP && ! HAVE_BCMP - -/* Compare two memory blocks. */ - -int -memcmp (p1arg, p2arg, c) - constpointer p1arg; - constpointer p2arg; - int c; -{ - const char *p1 = (const char *) p1arg; - const char *p2 = (const char *) p2arg; - - while (c-- != 0) - if (*p1++ != *p2++) - return BUCHAR (*--p1) - BUCHAR (*--p2); - return 0; -} - -#endif /* ! HAVE_MEMCMP && ! HAVE_BCMP */ - -#if ! HAVE_MEMCPY && ! HAVE_BCOPY - -/* Copy one memory block to another. */ - -pointer -memcpy (ptoarg, pfromarg, c) - pointer ptoarg; - constpointer pfromarg; - int c; -{ - char *pto = (char *) ptoarg; - const char *pfrom = (const char *) pfromarg; - - while (c-- != 0) - *pto++ = *pfrom++; - return ptoarg; -} - -#endif /* ! HAVE_MEMCPY && ! HAVE_BCOPY */ - -#if ! HAVE_BZERO && ! HAVE_MEMSET - -/* Zero out a block of memory. */ - -void -bzero (parg, c) - pointer parg; - int c; -{ - char *p = (char *) parg; - - while (c-- != 0) - *p++ = 0; -} - -#endif /* ! HAVE_BZERO && ! HAVE_MEMSET */ - -#if ! HAVE_MEMMOVE - -/* Move a memory block safely despite overlap. This function is - almost impossible to write in strictly conforming C, because it - wants to compare pointers to different objects, but this - implementation will suffice for all normal systems. I hope. */ - -pointer -xmemmove (pto, pfrom, c) - pointer pto; - constpointer pfrom; - int c; -{ - char *zto = (char *) pto; - const char *zfrom = (const char *) pfrom; - - if (zto <= zfrom || zto >= zfrom + c) - { - while (c-- != 0) - *zto++ = *zfrom++; - } - else - { - zto += c; - zfrom += c; - while (c-- != 0) - *--zto = *--zfrom; - } - - return pto; -} - -#endif /* ! HAVE_MEMMOVE */ - -#if ! HAVE_STRCHR && ! HAVE_INDEX - -/* I doubt there are any systems for which this is true, but who - knows? Provide my own version of strchr. */ - -/* Look for a character in a string. This is supposed to work for a - null byte, although we never actually call it with one. */ - -char * -strchr (z, b) - const char *z; - int b; -{ - b = (char) b; - while (*z != b) - if (*z++ == '\0') - return NULL; - return (char *) z; -} - -#endif /* ! HAVE_STRCHR && ! HAVE_INDEX */ - -#if ! HAVE_STRRCHR && ! HAVE_RINDEX - -/* Look for the last occurrence of a character in a string. This is - supposed to work for a null byte, although we never actually call - it with one. */ - -char * -strrchr (z, b) - const char *z; - int b; -{ - char *zret; - - b = (char) b; - zret = NULL; - do - { - if (*z == b) - zret = (char *) z; - } - while (*z++ != '\0'); - return zret; -} - -#endif /* ! HAVE_STRRCHR && ! HAVE_RINDEX */ - -#if ! HAVE_STRLWR - -/* Convert a string to lower case. */ - -char * -strlwr (zarg) - char *zarg; -{ - char *z = zarg; - - while (*z != '\0') - { - if (isupper (*z)) - *z = tolower (*z); - ++z; - } - - return zarg; -} - -#endif /* ! HAVE_STRLWR */ - -#if ! HAVE_STRTOL - -/* My own version of strtol. This assumes that the upper case - characters appear in sequence and that the lower case characters - appear in sequence. It also assumes that unsigned arithmetic is - performed correctly, but that's probably a safe assumption. This - code needs only a couple of changes to also work as strtoul. */ - -/* We need definitions for LONG_MAX and LONG_MIN; the limits that - appear here are those guaranteed by the C standard. The value for - LONG_MIN is one greater than that applicable to most computers. */ - -#ifndef LONG_MAX -#define LONG_MAX (2147483647) -#endif -#ifndef LONG_MIN -#define LONG_MIN (- 2147483647) -#endif - -long -strtol (zarg, pzend, ibase) - const char *zarg; - char **pzend; - int ibase; -{ - const char *z, *zsubj; - boolean fsign; - unsigned long ival; - boolean foverflow; - - z = zarg; - - while (isspace (BUCHAR (*z))) - ++z; - - fsign = FALSE; - if (*z == '+') - ++z; - else if (*z == '-') - { - ++z; - fsign = TRUE; - } - - if (ibase == 0) - { - if (*z == '0') - { - if (z[1] == 'x' || z[1] == 'X') - { - z += 2; - ibase = 16; - } - else - ibase = 8; - } - else - ibase = 10; - } - else - { - if (ibase == 16 - && *z == '0' - && (z[1] == 'x' || z[1] == 'X')) - z += 2; - } - - ival = 0; - foverflow = FALSE; - zsubj = z; - - while (TRUE) - { - int inext; - unsigned long itmp; - - if (isdigit (BUCHAR (*z))) - inext = *z - '0'; - else if (isupper (BUCHAR (*z))) - inext = *z - 'A' + 10; - else if (islower (BUCHAR (*z))) - inext = *z - 'a' + 10; - else - break; - - if (inext >= ibase) - break; - - itmp = ival * ibase + inext; - - /* Operations on unsigned values are performed using modulos - arithmetic. Therefore any overflow will result in a smaller - number. Note that we can't simply return out on overflow, - because we still have to determine the end of the subject - sequence. */ - if (itmp < ival) - foverflow = TRUE; - - ival = itmp; - ++z; - } - - if (z == zsubj) - { - if (pzend != NULL) - *pzend = (char *) zarg; - return 0; - } - - if (pzend != NULL) - *pzend = (char *) z; - - /* Now checked for overflow as a signed type. If this were strtoul, - we would just leave out this check. Converting LONG_MIN, a - negative number, to unsigned long means adding it to ULONG_MAX + - 1, which can not overflow since long and unsigned long are the - same size. Negating an unsigned long, say i, means performing - the operation (ULONG_MAX + 1) - i, which clearly can not - overflow. The result is thus (ULONG_MAX + 1) - ((ULONG_MAX + 1) - + LONG_MIN) == - LONG_MIN, which is the magnitude we are looking - for. */ - if (fsign - ? ival > (unsigned long) LONG_MAX - : ival > - (unsigned long) LONG_MIN) - foverflow = TRUE; - - /* If this were strtoul, we would return ULONG_MAX on overflow - regardless of the value of fsign. */ - if (foverflow) - { - errno = ERANGE; - if (fsign) - return LONG_MIN; - else - return LONG_MAX; - } - - if (fsign) - ival = - ival; - - /* If this were strtoul, we would not case the value before - returning. */ - return (long) ival; -} - -#endif /* ! HAVE_STRTOL */ - -#if ! HAVE_BSEARCH - -/* Search for a key in a sorted array. The third and fourth arguments - should be size_t, but int will suffice for my uses and spare me - from defining size_t portably. */ - -pointer -bsearch (pkey, parray, celes, cbytes, pficmp) - constpointer pkey; - constpointer parray; - int celes; - int cbytes; - int (*pficmp) P((constpointer, constpointer)); -{ - const char *zarray = (const char *) parray; - int ilow, ihigh, itrial; - - ilow = 0; - ihigh = celes; - while (ilow < ihigh) - { - const char *zcheck; - int icmp; - - itrial = (ilow + ihigh) >> 1; - /* Here ilow <= itrial < ihigh */ - zcheck = zarray + itrial * cbytes; - icmp = (*pficmp) (pkey, (constpointer) zcheck); - if (icmp < 0) - ihigh = itrial; - else if (icmp > 0) - ilow = itrial + 1; - else - return (pointer) zcheck; - } - - return NULL; -} - -#endif /* ! HAVE_BSEARCH */ diff --git a/gnu/libexec/uucp/uuchk.c b/gnu/libexec/uucp/uuchk.c deleted file mode 100644 index 3df8b4cf725c..000000000000 --- a/gnu/libexec/uucp/uuchk.c +++ /dev/null @@ -1,908 +0,0 @@ -/* uuchk.c - Display what we think the permissions of systems are. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: uuchk.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.28 1992/03/28 20:31:55 ian - Franc,ois Pinard: allow a name to be given to an alternate - - Revision 1.27 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.26 1992/03/10 21:47:39 ian - Added protocol command for ports - - Revision 1.25 1992/03/09 18:10:26 ian - Zacharias Beckman: put acceptable commands and path on different lines - - Revision 1.24 1992/03/07 02:56:30 ian - Rewrote time routines - - Revision 1.23 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.22 1992/02/23 19:50:50 ian - Handle READ and WRITE in Permissions correctly - - Revision 1.21 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.20 1992/02/08 22:33:32 ian - Only get the current working directory if it's going to be needed - - Revision 1.19 1992/02/08 20:33:57 ian - Handle all possible signals raised by abort - - Revision 1.18 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.17 1992/01/15 07:06:29 ian - Set configuration directory in Makefile rather than sysdep.h - - Revision 1.16 1992/01/14 04:04:17 ian - Chip Salzenberg: strcmp is a macro on AIX - - Revision 1.15 1992/01/05 03:09:17 ian - Changed abProgram and abVersion to non const to avoid compiler bug - - Revision 1.14 1991/12/23 05:15:54 ian - David Nugent: set debugging level for a specific system - - Revision 1.13 1991/12/22 22:14:53 ian - Added externs for strcasecmp or strncasecmp - - Revision 1.12 1991/12/18 03:54:14 ian - Made error messages to terminal appear more normal - - Revision 1.11 1991/12/17 23:14:08 ian - T. William Wells: allow dialer complete and abort to be chat scripts - - Revision 1.10 1991/12/15 04:17:11 ian - Added chat-seven-bit command to control parity bit stripping - - Revision 1.9 1991/12/15 03:42:33 ian - Added tprocess_chat_cmd for all chat commands, and added CMDTABTYPE_PREFIX - - Revision 1.8 1991/12/01 14:45:53 ian - Bob Izenberg: report dialer/token pairs correctly - - Revision 1.7 1991/11/21 22:17:06 ian - Add version string, print version when printing usage - - Revision 1.6 1991/11/13 20:38:00 ian - Added TCP port type for connections over TCP - - Revision 1.5 1991/11/12 19:47:04 ian - Add called-chat set of commands to run a chat script on an incoming call - - Revision 1.4 1991/11/11 23:47:24 ian - Added chat-program to run a program to do a chat script - - Revision 1.3 1991/11/11 16:19:21 ian - Added message for no protocol specified - - Revision 1.2 1991/09/19 02:22:44 ian - Chip Salzenberg's patch to allow ";retrytime" at the end of a time string - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char uuchk_rcsid[] = "$Id: uuchk.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include "getopt.h" - -#include "port.h" -#include "system.h" -#include "sysdep.h" -#include "uutime.h" - -/* External functions. */ -extern int strcasecmp (); - -/* Program name. */ -char abProgram[] = "uuchk"; - -/* Local functions. */ - -static void ukusage P((void)); -static void ukshow P((const struct ssysteminfo *qsys)); -static boolean fkshow_port P((struct sport *qport, boolean fin)); -static void ukshow_dialer P((struct sdialer *qdial)); -static void ukshow_chat P((const struct schat_info *qchat, - const char *zhdr)); -static void ukshow_size P((const char *z, boolean fcall, boolean flocal)); -static void ukshow_proto_params P((int c, struct sproto_param *pas, - int cindent)); -static void ukshow_time P((const struct sspan *)); -static struct sspan *qcompress_span P((struct sspan *)); - -/* Local variables. */ -static boolean fKgot_port; - -/* Long getopt options. */ - -static const struct option asKlongopts[] = { { NULL, 0, NULL, 0 } }; - -const struct option *_getopt_long_options = asKlongopts; - -int -main (argc, argv) - int argc; - char **argv; -{ - int iopt; - /* The configuration file name. */ - const char *zconfig = NULL; - int c; - struct ssysteminfo *pas; - int i; - - while ((iopt = getopt (argc, argv, "I:x:")) != EOF) - { - switch (iopt) - { - case 'I': - /* Set the configuration file name. */ - zconfig = optarg; - break; - - case 'x': -#if DEBUG > 1 - /* Set the debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 0: - /* Long option found and flag set. */ - break; - - default: - ukusage (); - break; - } - } - - if (optind != argc) - ukusage (); - - uread_config (zconfig); - - usysdep_initialize (FALSE, FALSE); - - uread_all_system_info (&c, &pas); - - for (i = 0; i < c; i++) - { - ukshow (&pas[i]); - if (i < c - 1) - printf ("\n"); - } - - ulog_close (); - - usysdep_exit (TRUE); - - /* Avoid errors about not returning a value. */ - return 0; -} - -/* Print a usage message and die. */ - -static void -ukusage () -{ - fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", - abVersion); - fprintf (stderr, - "Usage: uuchk [-I file] [-x debug]\n"); - fprintf (stderr, - " -x debug: Set debugging level (0 for none, 9 is max)\n"); -#if HAVE_TAYLOR_CONFIG - fprintf (stderr, - " -I file: Set configuration file to use (default %s%s)\n", - NEWCONFIGLIB, CONFIGFILE); -#endif /* HAVE_TAYLOR_CONFIG */ - exit (EXIT_FAILURE); -} - -/* Dump out the information for a system. */ - -static void -ukshow (qsys) - const struct ssysteminfo *qsys; -{ - int i; - const struct ssysteminfo *qlast; - - printf ("System: %s", qsys->zname); - if (qsys->zalias != NULL) - printf (" (%s)", qsys->zalias); - printf ("\n"); - - qlast = NULL; - for (i = 0; qsys != NULL; qlast = qsys, qsys = qsys->qalternate, i++) - { - boolean fcall, fcalled; - struct sspan *qtime, *qspan; - - if (i != 0 || qsys->qalternate != NULL) - { - printf ("Alternate %d", i); - if (qsys->zalternate != NULL) - printf (" (%s)", qsys->zalternate); - printf ("\n"); - } - - /* See if this alternate could be used when calling out. */ - - fcall = (i == 0 - || qsys->ztime != qlast->ztime - || qsys->zport != qlast->zport - || qsys->qport != qlast->qport - || qsys->ibaud != qlast->ibaud - || qsys->zphone != qlast->zphone - || qsys->schat.zprogram != qlast->schat.zprogram - || qsys->schat.zchat != qlast->schat.zchat); - - if (! fcall) - qtime = NULL; - else - { - qtime = qtimegrade_parse (qsys->ztime); - if (qtime == NULL) - fcall = FALSE; - } - - /* If this is the first alternate, it can be used to accept - a call. Otherwise it can be used if it specifies a different - login name than the previous alternate. */ - fcalled = (i == 0 - || (qlast != NULL - && qsys->zcalled_login != NULL - && (qlast->zcalled_login == NULL - || strcmp (qsys->zcalled_login, - qlast->zcalled_login) != 0))); - - if (! fcall && ! fcalled) - { - printf (" This alternate is never used\n"); - continue; - } - - if (fcalled) - { - if (qsys->zcalled_login != NULL - && strcmp (qsys->zcalled_login, "ANY") != 0) - { - if (i == 0 && qsys->qalternate == NULL) - printf (" Caller must log in as %s\n", qsys->zcalled_login); - else - printf (" When called using login name %s\n", - qsys->zcalled_login); - } - else - printf (" When called using any login name\n"); - - if (qsys->zlocalname != NULL) - printf (" Will use %s as name of local system\n", - qsys->zlocalname); - } - - if (fcalled && qsys->fcallback) - { - printf (" If called, will call back\n"); - fcalled = FALSE; - } - - if (fcall) - { - if (i == 0 && qsys->qalternate == NULL) - printf (" Call out"); - else - printf (" This alternate applies when calling"); - - if (qsys->zport != NULL || qsys->qport != NULL) - { - printf (" using "); - if (qsys->zport != NULL) - printf ("port %s", qsys->zport); - else - printf ("a specially defined port"); - if (qsys->ibaud != 0) - { - printf (" at speed %ld", qsys->ibaud); - if (qsys->ihighbaud != 0) - printf (" to %ld", qsys->ihighbaud); - } - printf ("\n"); - } - else if (qsys->ibaud != 0) - { - printf (" at speed %ld", qsys->ibaud); - if (qsys->ihighbaud != 0) - printf (" to %ld", qsys->ihighbaud); - printf ("\n"); - } - else - printf (" using any port\n"); - - if (qsys->qport != NULL) - { - printf (" The port is defined as:\n"); - (void) fkshow_port (qsys->qport, FALSE); - } - else - { - struct sport sdummy; - - printf (" The possible ports are:\n"); - fKgot_port = FALSE; - (void) ffind_port (qsys->zport, qsys->ibaud, - qsys->ihighbaud, &sdummy, - fkshow_port, FALSE); - if (! fKgot_port) - printf (" *** There are no matching ports\n"); - } - - if (qsys->zphone != NULL) - { -#if HAVE_TCP - if ((qsys->zport != NULL - && strcmp (qsys->zport, "TCP") == 0) - || (qsys->qport != NULL - && qsys->qport->ttype == PORTTYPE_TCP)) - printf (" Remote address %s\n", qsys->zphone); - else -#endif /* HAVE_TCP */ - printf (" Phone number %s\n", qsys->zphone); - } - - ukshow_chat (&qsys->schat, " Chat"); - - if (qsys->zcall_login != NULL) - { - if (strcmp (qsys->zcall_login, "*") != 0) - printf (" Login name %s\n", qsys->zcall_login); - else - { - char *zlogin, *zpass; - - if (! fcallout_login (qsys, &zlogin, &zpass)) - printf (" Can not determine login name\n"); - else - { - printf (" Login name %s\n", zlogin); - xfree ((pointer) zlogin); - xfree ((pointer) zpass); - } - } - } - - if (qsys->zcall_password != NULL) - { - if (strcmp (qsys->zcall_password, "*") != 0) - printf (" Password %s\n", qsys->zcall_password); - else - { - char *zlogin, *zpass; - - if (! fcallout_login (qsys, &zlogin, &zpass)) - printf (" Can not determine password\n"); - else - { - printf (" Password %s\n", zpass); - xfree ((pointer) zlogin); - xfree ((pointer) zpass); - } - } - } - - qtime = qcompress_span (qtime); - - for (qspan = qtime; qspan != NULL; qspan = qspan->qnext) - { - printf (" "); - ukshow_time (qspan); - printf (" may call if "); - if ((char) qspan->ival == BGRADE_LOW) - printf ("any work"); - else - printf ("work grade %c or higher", (char) qspan->ival); - if (qspan->cretry != 0) - printf (" (retry %d)", qspan->cretry); - printf ("\n"); - } - - utimespan_free (qtime); - - if (qsys->zcalltimegrade != NULL) - { - boolean fprint, fother; - - qtime = qtimegrade_parse (qsys->zcalltimegrade); - qtime = qcompress_span (qtime); - fprint = FALSE; - fother = FALSE; - if (qtime->istart != 0) - fother = TRUE; - for (qspan = qtime; qspan != NULL; qspan = qspan->qnext) - { - if ((char) qspan->ival == BGRADE_LOW) - { - fother = TRUE; - continue; - } - fprint = TRUE; - printf (" "); - ukshow_time (qspan); - printf (" may accept work grade %c or higher\n", - (char) qspan->ival); - if (qspan->qnext == NULL) - { - if (qspan->iend != 7 * 24 * 60) - fother = TRUE; - } - else - { - if (qspan->iend != qspan->qnext->istart) - fother = TRUE; - } - } - if (fprint && fother) - printf (" (At other times may accept any work)\n"); - - utimespan_free (qtime); - } - } - - if (qsys->fsequence) - printf (" Sequence numbers are used\n"); - - if (fcalled) - ukshow_chat (&qsys->scalled_chat, " When called, chat"); - -#if DEBUG > 1 - if (qsys->idebug != 0) - printf (" Debugging level 0%o\n", (unsigned int) qsys->idebug); - if (qsys->imax_remote_debug != 0) - printf (" Max remote debugging level 0%o\n", - (unsigned int) qsys->imax_remote_debug); -#endif - - if (fcall) - { - ukshow_size (qsys->zcall_local_size, TRUE, TRUE); - ukshow_size (qsys->zcall_remote_size, TRUE, FALSE); - } - if (fcalled) - { - ukshow_size (qsys->zcalled_local_size, FALSE, TRUE); - ukshow_size (qsys->zcalled_remote_size, FALSE, TRUE); - } - - if (fcall) - { - printf (" %sllow remote requests when calling\n", - qsys->fcall_request ? "A" : "Do not a"); - printf (" May %smake local requests when calling\n", - qsys->fcall_transfer ? "" : "not "); - } - - if (fcalled) - { - printf (" %sllow remote requests when called\n", - qsys->fcalled_request ? "A" : "Do not a"); - printf (" May %smake local requests when called\n", - qsys->fcalled_transfer ? "" : "not "); - } - - if (qsys->fcall_transfer || qsys->fcalled_transfer) - { - if (qsys->zcalled_local_send == NULL) - printf (" May send by local request: %s\n", qsys->zlocal_send); - else - { - if (fcall && qsys->fcall_transfer) - printf (" May send by local request when calling: %s\n", - qsys->zlocal_send); - if (fcalled && qsys->fcalled_transfer) - printf (" May send by local request when called: %s\n", - qsys->zcalled_local_send); - } - } - if (qsys->fcall_request || qsys->fcalled_request) - { - if (qsys->zcalled_remote_send == NULL) - printf (" May send by remote request: %s\n", qsys->zremote_send); - else - { - if (fcall && qsys->fcall_request) - printf (" May send by remote request when calling: %s\n", - qsys->zremote_send); - if (fcalled && qsys->fcalled_request) - printf (" May send by remote request when called: %s\n", - qsys->zcalled_remote_send); - } - } - if (qsys->fcall_transfer || qsys->fcalled_transfer) - { - if (qsys->zcalled_local_receive == NULL) - printf (" May accept by local request: %s\n", - qsys->zlocal_receive); - else - { - if (fcall && qsys->fcall_transfer) - printf (" May accept by local request when calling: %s\n", - qsys->zlocal_receive); - if (fcalled && qsys->fcalled_transfer) - printf (" May accept by local request when called: %s\n", - qsys->zcalled_local_receive); - } - } - if (qsys->fcall_request || qsys->fcalled_request) - { - if (qsys->zcalled_remote_receive == NULL) - printf (" May accept by remote request: %s\n", - qsys->zremote_receive); - else - { - if (fcall && qsys->fcall_request) - printf (" May accept by remote request when calling: %s\n", - qsys->zremote_receive); - if (fcalled && qsys->fcalled_request) - printf (" May accept by remote request when called: %s\n", - qsys->zcalled_remote_receive); - } - } - - printf (" May execute %s\n", qsys->zcmds); - printf (" Execution path %s\n", qsys->zpath); - - if (qsys->cfree_space != 0) - printf (" Will leave %ld bytes available\n", qsys->cfree_space); - - if (qsys->zpubdir != NULL) - printf (" Public directory is %s\n", qsys->zpubdir); - - if (qsys->zprotocols != NULL) - printf (" Will use protocols %s\n", qsys->zprotocols); - else - printf (" Will use any known protocol\n"); - - if (qsys->cproto_params != 0) - ukshow_proto_params (qsys->cproto_params, qsys->qproto_params, 1); - } -} - -/* Show information about a port. */ - -/*ARGSUSED*/ -static boolean -fkshow_port (qport, fin) - struct sport *qport; - boolean fin; -{ - fKgot_port = TRUE; - - printf (" Port name %s\n", qport->zname); - switch (qport->ttype) - { - case PORTTYPE_STDIN: - printf (" Port type stdin\n"); - break; - case PORTTYPE_DIRECT: - printf (" Port type direct\n"); - if (qport->u.sdirect.zdevice != NULL) - printf (" Device %s\n", qport->u.sdirect.zdevice); - printf (" Speed %ld\n", qport->u.sdirect.ibaud); - break; - case PORTTYPE_MODEM: - printf (" Port type modem\n"); - if (qport->u.smodem.zdevice != NULL) - printf (" Device %s\n", qport->u.smodem.zdevice); - if (qport->u.smodem.zdial_device != NULL) - printf (" Dial device %s\n", qport->u.smodem.zdial_device); - printf (" Speed %ld\n", qport->u.smodem.ibaud); - if (qport->u.smodem.ilowbaud != qport->u.smodem.ihighbaud) - printf (" Speed range %ld to %ld\n", qport->u.smodem.ilowbaud, - qport->u.smodem.ihighbaud); - printf (" Carrier %savailable\n", - qport->u.smodem.fcarrier ? "" : "not "); - if (qport->u.smodem.qdialer != NULL) - { - printf (" Specially defined dialer\n"); - ukshow_dialer (qport->u.smodem.qdialer); - } - else if (qport->u.smodem.zdialer != NULL) - { - const char *zc; - struct sdialer sdial; - - /* This might be a single dialer name, or it might be a - sequence of dialer/token pairs. */ - - zc = qport->u.smodem.zdialer; - if (zc[strcspn (zc, " \t")] == '\0') - { - if (! fread_dialer_info (qport->u.smodem.zdialer, &sdial)) - printf (" *** No dialer %s\n", qport->u.smodem.zdialer); - else - { - printf (" Dialer %s\n", qport->u.smodem.zdialer); - ukshow_dialer (&sdial); - } - } - else - { - char *z, *zdialer; - - printf (" Dialer sequence %s\n", zc); - - z = (char *) alloca (strlen (zc) + 1); - strcpy (z, zc); - - zdialer = strtok (z, " \t"); - while (zdialer != NULL) - { - char *ztoken; - - if (! fread_dialer_info (zdialer, &sdial)) - printf (" *** No dialer %s\n", zdialer); - else - { - printf (" Dialer %s\n", zdialer); - ukshow_dialer (&sdial); - } - - ztoken = strtok ((char *) NULL, " \t"); - if (ztoken == NULL) - zdialer = NULL; - else - zdialer = strtok ((char *) NULL, " \t"); - } - } - } - else - printf (" *** No dialer information\n"); - break; -#if HAVE_TCP - case PORTTYPE_TCP: - printf (" Port type tcp\n"); - printf (" TCP service %s\n", qport->u.stcp.zport); - break; -#endif /* HAVE_TCP */ - default: - printf (" CAN'T HAPPEN\n"); - break; - } - - if (qport->zprotocols != NULL) - printf (" Will use protocols %s\n", qport->zprotocols); - - if (qport->cproto_params != 0) - ukshow_proto_params (qport->cproto_params, qport->qproto_params, 3); - - /* Return FALSE to force ffind_port to continue searching. */ - return FALSE; -} - -/* Show information about a dialer. */ - -static void -ukshow_dialer (q) - struct sdialer *q; -{ - ukshow_chat (&q->schat, " Chat"); - if (q->zdialtone != NULL) - printf (" Wait for dialtone %s\n", q->zdialtone); - if (q->zpause != NULL) - printf (" Pause while dialing %s\n", q->zpause); - printf (" Carrier %savailable\n", q->fcarrier ? "" : "not "); - if (q->fcarrier) - printf (" Wait %d seconds for carrier\n", q->ccarrier_wait); - if (q->fdtr_toggle) - { - printf (" Toggle DTR"); - if (q->fdtr_toggle_wait) - printf (" and wait"); - printf ("\n"); - } - ukshow_chat (&q->scomplete, " When complete chat"); - ukshow_chat (&q->sabort, " When aborting chat"); - if (q->cproto_params != 0) - ukshow_proto_params (q->cproto_params, q->qproto_params, 4); -} - -/* Show a chat script. */ - -static void -ukshow_chat (qchat, zhdr) - const struct schat_info *qchat; - const char *zhdr; -{ - if (qchat->zprogram != NULL) - printf ("%s program %s\n", zhdr, qchat->zprogram); - - if (qchat->zchat != NULL) - { - printf ("%s script %s\n", zhdr, qchat->zchat); - printf ("%s script timeout %d\n", zhdr, qchat->ctimeout); - if (qchat->zfail != NULL) - printf ("%s failure strings %s\n", zhdr, qchat->zfail); - if (qchat->fstrip) - printf ("%s script incoming bytes stripped to seven bits\n", zhdr); - } -} - -/* Show a size/time restriction. */ - -static void -ukshow_size (zstring, fcall, flocal) - const char *zstring; - boolean fcall; - boolean flocal; -{ - struct sspan *qspan, *q; - boolean fother; - - qspan = qcompress_span (qtimesize_parse (zstring)); - if (qspan == NULL) - return; - - printf (" If call%s the following applies to a %s request:\n", - fcall ? "ing" : "ed", flocal ? "local" : "remote"); - - fother = FALSE; - if (qspan->istart >= 60) - fother = TRUE; - - for (q = qspan; q != NULL; q = q->qnext) - { - printf (" "); - ukshow_time (q); - printf (" may transfer files %ld bytes or smaller\n", q->ival); - if (q->qnext == NULL) - { - if (q->iend <= 6 * 24 * 60 + 23 * 60) - fother = TRUE; - } - else - { - if (q->iend + 60 <= q->qnext->istart) - fother = TRUE; - } - } - - if (fother) - printf (" (At other times may send files of any size)\n"); - - utimespan_free (qspan); -} - -/* Show protocol parameters. */ - -static void -ukshow_proto_params (c, pas, cindent) - int c; - struct sproto_param *pas; - int cindent; -{ - int ip; - - for (ip = 0; ip < c; ip++) - { - int ie, isp; - - for (isp = 0; isp < cindent; isp++) - printf (" "); - printf ("For protocol %c will use the following parameters\n", - pas[ip].bproto); - for (ie = 0; ie < pas[ip].centries; ie++) - { - int ia; - struct sproto_param_entry *qe; - - qe = &pas[ip].qentries[ie]; - for (isp = 0; isp < cindent; isp++) - printf (" "); - for (ia = 0; ia < qe->cargs; ia++) - printf (" %s", qe->azargs[ia]); - printf ("\n"); - } - } -} - -/* Display a time span. */ - -static void -ukshow_time (q) - const struct sspan *q; -{ - int idaystart, idayend; - int ihourstart, ihourend; - int iminutestart, iminuteend; - const char * const zdays = "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat\0Sun"; - - if (q->istart == 0 && q->iend == 7 * 24 * 60) - { - printf ("At any time"); - return; - } - - idaystart = q->istart / (24 * 60); - ihourstart = (q->istart % (24 * 60)) / 60; - iminutestart = q->istart % 60; - idayend = q->iend / (24 * 60); - ihourend = (q->iend % (24 * 60)) / 60; - iminuteend = q->iend % 60; - - if (idaystart == idayend) - printf ("%s from %02d:%02d to %02d:%02d", zdays + idaystart * 4, - ihourstart, iminutestart, ihourend, iminuteend); - else - printf ("From %s %02d:%02d to %s %02d:%02d", - zdays + idaystart * 4, ihourstart, iminutestart, - zdays + idayend * 4, ihourend, iminuteend); -} - -/* Compress a time span by merging any two adjacent spans with - identical values. This isn't necessary for uucico, but it looks - nicer when printed out. */ - -static struct sspan * -qcompress_span (qlist) - struct sspan *qlist; -{ - struct sspan **pq; - - pq = &qlist; - while (*pq != NULL) - { - if ((*pq)->qnext != NULL - && (*pq)->iend == (*pq)->qnext->istart - && (*pq)->ival == (*pq)->qnext->ival) - { - struct sspan *qfree; - - qfree = (*pq)->qnext; - (*pq)->qnext = qfree->qnext; - (*pq)->iend = qfree->iend; - xfree ((pointer) qfree); - } - else - pq = &(*pq)->qnext; - } - - return qlist; -} diff --git a/gnu/libexec/uucp/uucico.8 b/gnu/libexec/uucp/uucico.8 deleted file mode 100644 index dc4c44e44a67..000000000000 --- a/gnu/libexec/uucp/uucico.8 +++ /dev/null @@ -1,242 +0,0 @@ -''' $Id: uucico.8,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ -''' $Log: uucico.8,v $ -''' Revision 1.1.1.1 1993/03/21 09:45:37 cgd -''' initial import of 386bsd-0.1 sources -''' -''' Revision 1.7 1992/04/01 21:11:19 ian -''' Cleaned up a bit, updated -x switch -''' -''' Revision 1.6 1992/03/28 04:34:11 ian -''' David J. MacKenzie: change .TP5 to .TP 5; also updated to 1.03 -''' -''' Revision 1.5 1992/03/08 17:08:20 ian -''' Ted Lindgreen: ignore -u option -''' -''' Revision 1.4 1992/02/27 05:40:54 ian -''' T. William Wells: detach from controlling terminal, handle signals safely -''' -''' Revision 1.3 1992/01/20 23:52:23 ian -''' Change to version 1.02 -''' -''' Revision 1.2 1991/12/18 05:12:00 ian -''' Added -l option to uucico to prompt for login name once and then exit -''' -''' Revision 1.1 1991/12/14 19:05:30 ian -''' Initial revision -''' -''' -.TH uucico 8 "Taylor UUCP 1.03" -.SH NAME -uucico \- UUCP file transfer daemon -.SH SYNOPSIS -.B uucico -[ options ] -.SH DESCRIPTION -The -.I uucico -daemon processes file transfer requests queued by -.I uucp -(1) and -.I uux -(1). It is started when -.I uucp -or -.I uux -is run (unless they are given the -.B \-r -option). It is also typically started periodically using -entries in the -.I crontab -table(s). - -When invoked with the -.B \-r1 -option or the -.B \-s -or -.B \-S -option, the daemon will place a call to a remote system, running in -master mode. -Otherwise the daemon will start in slave mode, accepting a -call from a remote system. Typically a special login name will be set -up for UUCP which automatically invokes -.I uucico -when a call is made. - -When -.I uucico -terminates, it invokes the -.I uuxqt -(8) daemon, unless the -.B \-q -option is given; -.I uuxqt -(8) executes any work orders created by -.I uux -(1) on a remote system, and any work orders created locally which have -received remote files for which they were waiting. - -If a call fails, -.I uucico -will normally refuse to retry the -call until a certain (configurable) amount of time -has passed. This may be overriden by the -.B -f -or the -.B -S -option. - -The -.B \-l -or -.B \-e -option may be used to force -.I uucico -to produce its own prompts of "login: " and "Password:". When another -daemon calls in, it will see these prompts and log in as usual; the -login name and password will be checked against a separate list kept -specially for -.I uucico -rather than the -.I /etc/passwd -file. The -.B \-l -option will prompt once and then exit. The -.B \-e -option will prompt again after the first session is over; in this mode -.I uucico -will permanently control a port. - -If -.I uucico -receives a SIGQUIT, SIGTERM or SIGPIPE signal, it will cleanly abort -any current conversation with a remote system and exit. If it -receives a SIGHUP signal it will abort any current conversation, but -will continue to place calls to (if invoked with -.B \-r1) -and accept calls from (if invoked with -.B \-e) -other systems. If it receives a -SIGINT signal it will finish the current conversation, but will not -place or accept any more calls. -.SH OPTIONS -The following options may be given to -.I uucico. -.TP 5 -.B \-r1 -Start in master mode (call out to a system); implied by -.B \-s -or -.B \-S. If no system is specified, -call any system for which work is -waiting to be done. -.TP 5 -.B \-r0 -Start in slave mode. This is the default. -.TP 5 -.B \-s system -Call the named system. -.TP 5 -.B \-S system -Call the named system, ignoring any required wait. -.TP 5 -.B \-f -Ignore any required wait for any systems to be called. -.TP 5 -.B \-l -Prompt for login name and password using "login: " and "Password:". -This allows -.I uucico -to be easily run from -.I inetd -(8). The login name and password are checked against the UUCP -password file, which has no connection to the file -.I /etc/passwd. -.TP 5 -.B \-p port -Specify a port to call out on or to listen to. In slave mode, this -implies -.B \-e. -.TP 5 -.B \-e -Enter endless loop of login/password prompts and slave mode daemon -execution. The program will not stop by itself; you must use -.I kill -(1) to shut it down. -.TP 5 -.B \-w -After calling out (to a particular system when -.B \-s -or -.B \-S -is specifed, or to all systems which have work when -.B \-r1 -is specifed), begin an endless loop as with -.B \-e. -.TP 5 -.B \-q -Do not start the -.I uuxqt -(8) daemon when finished. -.TP 5 -.B \-D -Do not detach from the controlling terminal. Normally -.I uucico -detaches from the terminal before each call out to another system and -before invoking -.I uuxqt. -This option prevents this. -.TP 5 -.B \-x type, \-X type -Turn on particular debugging types. The following types are -recognized: abnormal, chat, handshake, uucp-proto, proto, port, -config, spooldir, execute, incoming, outgoing. - -Multiple types may be given, separated by commas, and the -.B \-x -option may appear multiple times. A number may also be given, which -will turn on that many types from the foregoing list; for example, -.B \-x 2 -is equivalent to -.B \-x abnormal,chat. - -The debugging output is sent to the debugging file, usually one of -/usr/spool/uucp/Debug, /usr/spool/uucp/DEBUG, or -/usr/spool/uucp/.Admin/audit.local. -.TP 5 -.B \-I file -Set configuration file to use. This option may not be available, -depending upon how -.I uucico -was compiled. -.TP 5 -.B \-u login -This option is ignored. It is only included because some versions of -uucpd invoke -.I uucico -with it. -.SH FILES -The file names may be changed at compilation time or by the -configuration file, so these are only approximations. - -.br -/usr/lib/uucp/config - Configuration file. -.br -/usr/lib/uucp/passwd - Default UUCP password file. -.br -/usr/spool/uucp - -UUCP spool directory. -.br -/usr/spool/uucp/Log - -UUCP log file. -.br -/usr/spool/uucppublic - -Default UUCP public directory. -.br -/usr/spool/uucp/Debug - -Debugging file. -.SH SEE ALSO -kill(1), uucp(1), uux(1), uuxqt(8) -.SH AUTHOR -Ian Lance Taylor -(ian@airs.com or uunet!airs!ian) diff --git a/gnu/libexec/uucp/uucico.c b/gnu/libexec/uucp/uucico.c deleted file mode 100644 index dd60ee8a7150..000000000000 --- a/gnu/libexec/uucp/uucico.c +++ /dev/null @@ -1,3496 +0,0 @@ -/* uucico.c - This is the main UUCP communication program. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: uucico.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.92 1992/04/06 21:10:14 ian - Marc Boucher: set *pqsys to NULL in faccept_call - - Revision 1.91 1992/03/30 04:07:13 ian - Dirk Musstopf: remove temporary file if receive fails - - Revision 1.90 1992/03/28 22:06:38 ian - Michael I Bushnell: renamed enum tstatus to avoid header file conflict - - Revision 1.89 1992/03/28 20:52:11 ian - Petri Helenius: must dump controlling terminal when going to next alternate - - Revision 1.88 1992/03/28 20:31:55 ian - Franc,ois Pinard: allow a name to be given to an alternate - - Revision 1.87 1992/03/28 19:40:26 ian - Close log and statistics file at each master/slave role switch - - Revision 1.86 1992/03/28 04:45:31 ian - Mark E. Mallett: minor cleanup - - Revision 1.85 1992/03/17 18:42:21 ian - T. William Wells: set current time in status file when call completes - - Revision 1.84 1992/03/17 01:03:03 ian - Miscellaneous cleanup - - Revision 1.83 1992/03/16 05:16:03 ian - Recognize SVR4 -U flag - - Revision 1.82 1992/03/16 04:38:00 ian - Turn off DEBUG_PORT for handshake debugging - - Revision 1.81 1992/03/15 04:51:17 ian - Keep an array of signals we've received rather than a single variable - - Revision 1.80 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.79 1992/03/11 19:53:55 ian - Improved chat script debugging - - Revision 1.78 1992/03/11 00:18:50 ian - Save temporary file if file send fails - - Revision 1.77 1992/03/10 23:01:20 ian - Don't run uuxqt if we got a SIGTERM - - Revision 1.76 1992/03/10 21:47:39 ian - Added protocol command for ports - - Revision 1.75 1992/03/09 20:14:37 ian - Ted Lindgreen: added max-remote-debug command - - Revision 1.74 1992/03/09 19:52:50 ian - Ted Lindgreen: strip parity from initial handshake strings - - Revision 1.73 1992/03/09 19:42:43 ian - Ted Lindgreen: don't send mail for nonexistent file - - Revision 1.72 1992/03/09 05:37:10 ian - Only look for hangup string in debugging mode - - Revision 1.71 1992/03/09 05:29:20 ian - Ted Lindgreen: report requested grade on an incoming call - - Revision 1.70 1992/03/09 05:08:16 ian - Added status for wrong time to call, not used if system can't be called - - Revision 1.69 1992/03/08 17:45:41 ian - Ted Lindgreen: start uuxqt for only one system if appropriate - - Revision 1.68 1992/03/08 17:08:20 ian - Ted Lindgreen: ignore -u option - - Revision 1.67 1992/03/08 16:42:41 ian - Ted Lindgreen: report port and login name in log file - - Revision 1.66 1992/03/07 02:56:30 ian - Rewrote time routines - - Revision 1.65 1992/03/04 15:05:51 ian - Michael Haberler: some systems send \n after Shere - - Revision 1.64 1992/03/04 00:36:44 ian - Michael Richardson: better chat script debugging - - Revision 1.63 1992/03/03 21:01:20 ian - Use strict timeout in fsserial_read, eliminate all race conditions - - Revision 1.62 1992/03/03 06:06:48 ian - T. William Wells: don't complain about missing configuration files - - Revision 1.61 1992/02/29 04:07:08 ian - Added -j option to uucp and uux - - Revision 1.60 1992/02/29 01:06:59 ian - Chip Salzenberg: recheck file permissions before sending - - Revision 1.59 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.58 1992/02/24 22:38:45 ian - Don't treat an extra argument as a port - - Revision 1.57 1992/02/24 04:58:47 ian - Only permit files to be received into directories that are world-writeable - - Revision 1.56 1992/02/23 19:50:50 ian - Handle READ and WRITE in Permissions correctly - - Revision 1.55 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.54 1992/02/20 22:57:19 ian - Chip Salzenberg: some systems truncate the Shere= machine name - - Revision 1.53 1992/02/19 19:36:07 ian - Rearranged time functions - - Revision 1.52 1992/02/14 21:32:50 ian - Niels Baggesen: under HAVE_BNU_LOGGING, don't lost system name when dieing - - Revision 1.51 1992/02/09 05:21:55 ian - Bob Denny: call fmail_transfer before fsysdep_did_work - - Revision 1.50 1992/02/08 22:33:32 ian - Only get the current working directory if it's going to be needed - - Revision 1.49 1992/02/08 20:33:57 ian - Handle all possible signals raised by abort - - Revision 1.48 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.47 1992/02/07 17:08:15 ian - Bob Denny: retry time not reached is not an error - - Revision 1.46 1992/01/29 18:37:27 ian - Patrick Smith: only wait a short time for the hangup message - - Revision 1.45 1992/01/28 04:34:10 ian - Marty Shannon: -f uucp flag not handled correctly - - Revision 1.44 1992/01/28 03:50:42 ian - Chip Salzenberg: set .Status correctly if wrong time to call - - Revision 1.43 1992/01/21 19:39:12 ian - Chip Salzenberg: uucp and uux start uucico for right system, not any - - Revision 1.42 1992/01/20 16:44:54 ian - Marty Shannon: update .Status file if it's the wrong time to call - - Revision 1.41 1992/01/19 02:27:00 ian - Marty Shannon: update .Status file on incoming calls - - Revision 1.40 1992/01/18 22:48:53 ian - Reworked sending of mail and general handling of failed transfers - - Revision 1.39 1992/01/15 07:06:29 ian - Set configuration directory in Makefile rather than sysdep.h - - Revision 1.38 1992/01/14 04:38:43 ian - Chip Salzenberg: only declare sportinfo if it will be used - - Revision 1.37 1992/01/12 19:53:05 ian - John Antypas: pass in sportinfo structure for fdo_call to use - - Revision 1.36 1992/01/05 03:09:17 ian - Changed abProgram and abVersion to non const to avoid compiler bug - - Revision 1.35 1992/01/04 21:53:36 ian - Start up uuxqt even if a call fails - - Revision 1.34 1991/12/31 19:43:13 ian - Added 'e' protocol - - Revision 1.33 1991/12/28 04:33:09 ian - Set fmasterdone correctly in slave mode - - Revision 1.32 1991/12/23 05:15:54 ian - David Nugent: set debugging level for a specific system - - Revision 1.31 1991/12/21 23:10:43 ian - Terry Gardner: record failed file transfers in statistics file - - Revision 1.30 1991/12/21 22:17:20 ian - Change protocol ordering to 't', 'g', 'f' - - Revision 1.29 1991/12/21 22:07:47 ian - John Theus: don't warn if port file does not exist - - Revision 1.28 1991/12/20 04:30:24 ian - Terry Gardner: record conversation time in log file - - Revision 1.27 1991/12/20 00:42:24 ian - Clear user name from error message given by getting next command - - Revision 1.26 1991/12/18 05:12:00 ian - Added -l option to uucico to prompt for login name once and then exit - - Revision 1.25 1991/12/18 03:54:14 ian - Made error messages to terminal appear more normal - - Revision 1.24 1991/12/17 04:55:01 ian - David Nugent: ignore SIGHUP in uucico and uuxqt - - Revision 1.23 1991/12/15 03:42:33 ian - Added tprocess_chat_cmd for all chat commands, and added CMDTABTYPE_PREFIX - - Revision 1.22 1991/12/11 03:59:19 ian - Create directories when necessary; don't just assume they exist - - Revision 1.21 1991/11/21 22:17:06 ian - Add version string, print version when printing usage - - Revision 1.20 1991/11/16 00:33:28 ian - Remove ?: operator between string literal and variable - - Revision 1.19 1991/11/14 03:40:10 ian - Try to figure out whether stdin is a TCP port - - Revision 1.18 1991/11/14 03:20:13 ian - Added seven-bit and reliable commands to help when selecting protocols - - Revision 1.17 1991/11/13 23:08:40 ian - Expand remote pathnames in uucp and uux; fix up uux special cases - - Revision 1.16 1991/11/12 19:47:04 ian - Add called-chat set of commands to run a chat script on an incoming call - - Revision 1.15 1991/11/12 18:25:33 ian - Added 't' protocol - - Revision 1.14 1991/11/11 23:47:24 ian - Added chat-program to run a program to do a chat script - - Revision 1.13 1991/11/11 19:32:03 ian - Added breceive_char to read characters through protocol buffering - - Revision 1.12 1991/11/11 18:55:52 ian - Get protocol parameters from port and dialer for incoming calls - - Revision 1.11 1991/11/11 16:59:05 ian - Eliminate fread_port_info, allow NULL pflock arg to ffind_port - - Revision 1.10 1991/11/11 04:21:16 ian - Added 'f' protocol - - Revision 1.9 1991/11/10 19:24:22 ian - Added pffile protocol entry point for file level control - - Revision 1.8 1991/11/09 18:53:07 ian - Reworked protocol interface - - Revision 1.7 1991/11/07 18:15:38 ian - Chip Salzenberg: move CMAXRETRIES to conf.h for easy configuration - - Revision 1.6 1991/09/19 03:06:04 ian - Chip Salzenberg: put BNU temporary files in system's directory - - Revision 1.5 1991/09/19 02:30:37 ian - From Chip Salzenberg: check whether signal is ignored differently - - Revision 1.4 1991/09/19 02:22:44 ian - Chip Salzenberg's patch to allow ";retrytime" at the end of a time string - - Revision 1.3 1991/09/12 05:04:26 ian - Changed sense of \0 return from btime_low_grade on calltimegrade - - Revision 1.2 1991/09/11 02:33:14 ian - Added ffork argument to fsysdep_run - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char uucico_rcsid[] = "$Id: uucico.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#include "getopt.h" - -#include "port.h" -#include "prot.h" -#include "system.h" -#include "uutime.h" - -/* The program name. */ -char abProgram[] = "uucico"; - -/* Define the known protocols. - bname, ffullduplex, qcmds, pfstart, pfshutdown, pfsendcmd, pzgetspace, - pfsenddata, pfprocess, pfwait, pffile */ - -static struct sprotocol asProtocols[] = -{ - { 't', FALSE, RELIABLE_ENDTOEND | RELIABLE_RELIABLE | RELIABLE_EIGHT, - asTproto_params, ftstart, ftshutdown, ftsendcmd, ztgetspace, - ftsenddata, ftprocess, ftwait, ftfile }, - { 'e', FALSE, RELIABLE_ENDTOEND | RELIABLE_RELIABLE | RELIABLE_EIGHT, - asEproto_params, festart, feshutdown, fesendcmd, zegetspace, - fesenddata, feprocess, fewait, fefile }, - { 'g', FALSE, RELIABLE_EIGHT, - asGproto_params, fgstart, fgshutdown, fgsendcmd, zggetspace, - fgsenddata, fgprocess, fgwait, NULL }, - { 'f', FALSE, RELIABLE_RELIABLE, - asFproto_params, ffstart, ffshutdown, ffsendcmd, zfgetspace, - ffsenddata, ffprocess, ffwait, fffile }, -}; - -#define CPROTOCOLS (sizeof asProtocols / sizeof asProtocols[0]) - -/* Locked system. */ - -static boolean fLocked_system; -static struct ssysteminfo sLocked_system; - -/* Local functions. */ - -static void uusage P((void)); -static void uabort P((void)); -static boolean fcall P((const struct ssysteminfo *qsys, - struct sport *qport, - boolean fforce, int bgrade, - boolean fnodetach)); -static boolean fdo_call P((const struct ssysteminfo *qsys, - struct sport *qport, - struct sstatus *qstat, int cretry, - boolean *pfcalled, struct sport *quse)); -static boolean fcall_failed P((const struct ssysteminfo *qsys, - enum tstatus_type twhy, - struct sstatus *qstat, int cretry)); -static boolean flogin_prompt P((struct sport *qport)); -static boolean faccept_call P((const char *zlogin, struct sport *qport, - const struct ssysteminfo **pqsys)); -static boolean fuucp P((boolean fmaster, const struct ssysteminfo *qsys, - int bgrade, boolean fnew, long cmax_receive)); -static boolean fdo_xcmd P((const struct ssysteminfo *qsys, - boolean fcaller, - const struct scmd *qcmd)); -static boolean fok_to_send P((const char *zfrom, boolean flocal, - boolean fcaller, boolean fspool, - const struct ssysteminfo *qsys, - const char *zuser)); -static boolean fok_to_receive P((const char *zto, boolean flocal, - boolean fcaller, - const struct ssysteminfo *qsys, - const char *zuser)); -static boolean frequest_ok P((boolean flocal, boolean fcaller, - const struct ssysteminfo *qsys, - const char *zuser)); -static boolean fsend_uucp_cmd P((const char *z)); -static const char *zget_uucp_cmd P((boolean frequired)); -static const char *zget_typed_line P((void)); - -/* Long getopt options. */ - -static const struct option asLongopts[] = { { NULL, 0, NULL, 0 } }; - -const struct option *_getopt_long_options = asLongopts; - -int -main (argc, argv) - int argc; - char **argv; -{ - /* getopt return value */ - int iopt; - /* Don't detach from controlling terminal. */ - boolean fnodetach = FALSE; - /* Configuration file name */ - const char *zconfig = NULL; - /* System to call */ - const char *zsystem = NULL; - /* Port to use; in master mode, call out on this port. In slave mode, - accept logins on this port. If port not specified, then in master - mode figure it out for each system, and in slave mode use stdin and - stdout. */ - const char *zport = NULL; - /* Port information for the port name in zport. */ - struct sport sportinfo; - /* Pointer to port to use, or NULL if unknown. */ - struct sport *qport; - /* Whether to start uuxqt when done. */ - boolean fuuxqt = TRUE; - /* Whether to force a call despite status of previous call */ - boolean fforce = FALSE; - /* Whether we are the master */ - boolean fmaster = FALSE; - /* Whether to give a single login prompt. */ - boolean flogin = FALSE; - /* Whether to do an endless loop of accepting calls */ - boolean floop = FALSE; - /* Whether to wait for an inbound call after doing an outbound call */ - boolean fwait = FALSE; - boolean fret = TRUE; -#if DEBUG > 1 - int iholddebug; -#endif - - while ((iopt = getopt (argc, argv, - "DefI:lp:qr:s:S:u:x:X:w")) != EOF) - { - switch (iopt) - { - case 'D': - /* Don't detach from controlling terminal. */ - fnodetach = TRUE; - break; - - case 'e': - /* Do an endless loop of accepting calls. */ - floop = TRUE; - break; - - case 'f': - /* Force a call even if it hasn't been long enough since the last - failed call. */ - fforce = TRUE; - break; - - case 'I': - /* Set configuration file name (default is in sysdep.h). */ - zconfig = optarg; - break; - - case 'l': - /* Prompt for login name and password. */ - flogin = TRUE; - break; - - case 'p': - /* Port to use */ - zport = optarg; - break; - - case 'q': - /* Don't start uuxqt. */ - fuuxqt = FALSE; - break; - - case 'r': - /* Set mode: -r1 for master, -r0 for slave (default) */ - if (optarg[0] == '1' && optarg[1] == '\0') - fmaster = TRUE; - else if (optarg[0] == '0' && optarg[1] == '\0') - fmaster = FALSE; - else - uusage (); - break; - - case 's': - /* Set system name */ - zsystem = optarg; - fmaster = TRUE; - break; - - case 'S': - /* Set system name and force call like -f */ - zsystem = optarg; - fforce = TRUE; - fmaster = TRUE; - break; - - case 'u': - /* Some versions of uucpd invoke uucico with a -u argument - specifying the login name. I'm told it is safe to ignore - this value, although perhaps we should use it rather than - zsysdep_login_name (). */ - break; - - case 'x': - case 'X': -#if DEBUG > 1 - /* Set debugging level */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'w': - /* Call out and then wait for a call in */ - fwait = TRUE; - break; - - case 0: - /* Long option found, and flag value set. */ - break; - - default: - uusage (); - break; - } - } - - if (optind != argc) - uusage (); - - if (fwait && zport == NULL) - { - fprintf (stderr, "%s: -w requires -e\n", abProgram); - uusage (); - } - - uread_config (zconfig); - -#ifdef SIGINT - usysdep_signal (SIGINT); -#endif -#ifdef SIGHUP - usysdep_signal (SIGHUP); -#endif -#ifdef SIGQUIT - usysdep_signal (SIGQUIT); -#endif -#ifdef SIGTERM - usysdep_signal (SIGTERM); -#endif -#ifdef SIGPIPE - usysdep_signal (SIGPIPE); -#endif - - usysdep_initialize (TRUE, FALSE); - - ulog_to_file (TRUE); - ulog_fatal_fn (uabort); - - /* If a port was named, get its information. */ - if (zport == NULL) - qport = NULL; - else - { - if (! ffind_port (zport, (long) 0, (long) 0, &sportinfo, - (boolean (*) P((struct sport *, boolean))) NULL, - FALSE)) - { - ulog (LOG_ERROR, "%s: No such port", zport); - ulog_close (); - usysdep_exit (FALSE); - } - qport = &sportinfo; - } - - if (fmaster) - { - /* If a system was named, call it up. Otherwise check all the - known systems, and call all the ones which have work to do. */ - if (zsystem != NULL) - { - if (! fread_system_info (zsystem, &sLocked_system)) - ulog (LOG_FATAL, "Unknown system %s", zsystem); - - /* Detach from the controlling terminal for the call. This - probably makes sense only on Unix. We want the modem - line to become the controlling terminal. */ - if (! fnodetach && - (qport == NULL || qport->ttype != PORTTYPE_STDIN)) - usysdep_detach (); - - ulog_system (sLocked_system.zname); - -#if DEBUG > 1 - iholddebug = iDebug; - iDebug |= sLocked_system.idebug; -#endif - - if (! fsysdep_lock_system (&sLocked_system)) - { - ulog (LOG_ERROR, "System already locked"); - fret = FALSE; - } - else - { - fLocked_system = TRUE; - fret = fcall (&sLocked_system, qport, fforce, BGRADE_HIGH, - fnodetach); - (void) fsysdep_unlock_system (&sLocked_system); - fLocked_system = FALSE; - } - -#if DEBUG > 1 - iDebug = iholddebug; -#endif - - ulog_system ((const char *) NULL); - } - else - { - int csystems; - struct ssysteminfo *pas; - int i; - char bgrade; - boolean fdidone; - - fret = TRUE; - fdidone = FALSE; - uread_all_system_info (&csystems, &pas); - for (i = 0; i < csystems && ! FGOT_SIGNAL (); i++) - { - if (fsysdep_has_work (&pas[i], &bgrade)) - { - fdidone = TRUE; - - /* Detach from the controlling terminal. On Unix - this means that we will wind up forking a new - process for each system we call. */ - if (! fnodetach - && (qport == NULL - || qport->ttype != PORTTYPE_STDIN)) - usysdep_detach (); - - ulog_system (pas[i].zname); - -#if DEBUG > 1 - iholddebug = iDebug; - iDebug |= pas[i].idebug; -#endif - - if (! fsysdep_lock_system (&pas[i])) - { - ulog (LOG_ERROR, "System already locked"); - fret = FALSE; - } - else - { - sLocked_system = pas[i]; - fLocked_system = TRUE; - if (! fcall (&pas[i], qport, fforce, bgrade, - fnodetach)) - fret = FALSE; - - /* Now ignore any SIGHUP that we got. */ - afSignal[INDEXSIG_SIGHUP] = FALSE; - - (void) fsysdep_unlock_system (&pas[i]); - fLocked_system = FALSE; - } - -#if DEBUG > 1 - iDebug = iholddebug; -#endif - - ulog_system ((const char *) NULL); - } - } - - if (! fdidone) - ulog (LOG_NORMAL, "No work"); - } - - /* If requested, wait for calls after dialing out. */ - if (fwait) - { - floop = TRUE; - fmaster = FALSE; - } - } - - if (! fmaster) - { - /* If a port was specified by name, we go into endless loop - mode. In this mode, we wait for calls and prompt them with - "login:" and "Password:", so that they think we are a regular - UNIX system. If we aren't in endless loop mode, we have been - called by some other system. If flogin is TRUE, we prompt - with "login:" and "Password:" a single time. */ - - fret = TRUE; - zsystem = NULL; - - if (qport != NULL) - { - /* Detach from the controlling terminal, so that the port we - are about to use becomes our controlling terminal. */ - if (! fnodetach && qport->ttype != PORTTYPE_STDIN) - usysdep_detach (); - - floop = TRUE; - if (! fport_lock (qport, TRUE)) - { - ulog (LOG_ERROR, "Port %s is locked", qport->zname); - fret = FALSE; - } - } - - if (fret) - { - if (! fport_open (qport, (long) 0, (long) 0, TRUE)) - fret = FALSE; - } - - if (fret) - { - if (floop) - { - while (! FGOT_SIGNAL () && flogin_prompt (qport)) - { - /* Now ignore any SIGHUP that we got. */ - afSignal[INDEXSIG_SIGHUP] = FALSE; - - if (fLocked_system) - { - (void) fsysdep_unlock_system (&sLocked_system); - fLocked_system = FALSE; - } - if (! fport_reset ()) - break; - } - fret = FALSE; - } - else - { - if (flogin) - fret = flogin_prompt (qport); - else - { - const struct ssysteminfo *qsys; - -#if DEBUG > 1 - iholddebug = iDebug; -#endif - fret = faccept_call (zsysdep_login_name (), qport, - &qsys); - if (qsys != NULL) - zsystem = qsys->zname; -#if DEBUG > 1 - iDebug = iholddebug; -#endif - } - } - - (void) fport_close (fret); - - if (fLocked_system) - { - (void) fsysdep_unlock_system (&sLocked_system); - fLocked_system = FALSE; - } - } - } - - ulog_close (); - ustats_close (); - - /* If we got a SIGTERM, perhaps because the system is going down, - don't run uuxqt. We go ahead and run it for any other signal, - since I think they indicate more temporary conditions. */ - if (afSignal[INDEXSIG_SIGTERM]) - fuuxqt = FALSE; - - if (fuuxqt) - { - /* Detach from the controlling terminal before starting up uuxqt, - so that it runs as a true daemon. */ - if (! fnodetach) - usysdep_detach (); - if (zsystem == NULL) - fret = fsysdep_run (FALSE, "uuxqt", (const char *) NULL, - (const char *) NULL); - else - fret = fsysdep_run (FALSE, "uuxqt", "-s", zsystem); - } - - usysdep_exit (fret); - - /* Avoid complaints about not returning. */ - return 0; -} - -/* Print out a usage message. */ - -static void -uusage () -{ - fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", - abVersion); - fprintf (stderr, - "Usage: uucico [options]\n"); - fprintf (stderr, - " -s,-S system: Call system (-S implies -f)\n"); - fprintf (stderr, - " -f: Force call despite system status\n"); - fprintf (stderr, - " -r state: 1 for master, 0 for slave (default)\n"); - fprintf (stderr, - " -p port: Specify port (implies -e)\n"); - fprintf (stderr, - " -l: prompt for login name and password\n"); - fprintf (stderr, - " -e: Endless loop of login prompts and daemon execution\n"); - fprintf (stderr, - " -w: After calling out, wait for incoming calls\n"); - fprintf (stderr, - " -q: Don't start uuxqt when done\n"); - fprintf (stderr, - " -x,-X debug: Set debugging level\n"); -#if HAVE_TAYLOR_CONFIG - fprintf (stderr, - " -I file: Set configuration file to use (default %s%s)\n", - NEWCONFIGLIB, CONFIGFILE); -#endif /* HAVE_TAYLOR_CONFIG */ - - exit (EXIT_FAILURE); -} - -/* This function is called when a LOG_FATAL error occurs. */ - -static void -uabort () -{ - ustats_failed (); - -#if ! HAVE_BNU_LOGGING - /* When using BNU logging, it's a pain to have no system name. */ - ulog_system ((const char *) NULL); -#endif - - ulog_user ((const char *) NULL); - - if (qPort != NULL) - (void) fport_close (FALSE); - - if (fLocked_system) - { - (void) fsysdep_unlock_system (&sLocked_system); - fLocked_system = FALSE; - } - - ulog_close (); - ustats_close (); - - usysdep_exit (FALSE); -} - -/* Call another system, trying all the possible sets of calling - instructions. The fprepare_call function should already have been - called. The qsys argument is the system to call. The qport - argument is the port to use, and may be NULL. If the fforce - argument is TRUE, a call is forced even if not enough time has - passed since the last failed call. The bgrade argument is the - highest grade of work to be done for the system. The qstat - argument holds the status of the system. */ - -static boolean fcall (qsys, qport, fforce, bgrade, fnodetach) - const struct ssysteminfo *qsys; - struct sport *qport; - boolean fforce; - int bgrade; - boolean fnodetach; -{ - boolean fbadtime, fnevertime; - const struct ssysteminfo *qorigsys; - struct sstatus sstat; - - qorigsys = qsys; - if (! fsysdep_get_status (qorigsys, &sstat)) - return FALSE; - - /* Make sure it's been long enough since the last failed call. */ - if (! fforce) - { -#ifdef CMAXRETRIES -#if CMAXRETRIES > 0 - if (sstat.cretries >= CMAXRETRIES) - { - ulog (LOG_ERROR, "Too many retries"); - return FALSE; - } -#endif /* CMAXRETRIES > 0 */ -#endif /* defined (CMAXRETRIES) */ - - if (sstat.ttype != STATUS_COMPLETE - && sstat.ilast + sstat.cwait > isysdep_time ((long *) NULL)) - { - ulog (LOG_NORMAL, "Retry time not reached"); - return FALSE; - } - } - - fbadtime = TRUE; - fnevertime = TRUE; - - do - { - struct sspan *qtime; - const struct ssysteminfo *qnext; - - qtime = qtimegrade_parse (qsys->ztime); - if (qtime != NULL) - { - long ival; - int cretry; - boolean fmatch; - - fnevertime = FALSE; - - /* The value returned in ival by fspan_match is the lowest - grade which may be done at this time. */ - - fmatch = (ftimespan_match (qtime, &ival, &cretry) - && igradecmp (bgrade, (int) ival) <= 0); - - utimespan_free (qtime); - - if (fmatch) - { - boolean fret, fcalled; - struct sport sportinfo; - - if (FGOT_SIGNAL ()) - return FALSE; - - fbadtime = FALSE; - - fret = fdo_call (qsys, qport, &sstat, cretry, &fcalled, - &sportinfo); - (void) fport_close (fret); - - if (fret) - return TRUE; - if (fcalled) - return FALSE; - - /* Now we have to dump that port so that we can aquire a - new one. */ - if (! fnodetach) - usysdep_detach (); - } - } - - /* Look for the next alternate with different calling - instructions. */ - qnext = qsys; - do - { - qnext = qnext->qalternate; - } - while (qnext != NULL - && qsys->ztime == qnext->ztime - && qsys->zport == qnext->zport - && qsys->qport == qnext->qport - && qsys->ibaud == qnext->ibaud - && qsys->zphone == qnext->zphone - && qsys->schat.zprogram == qnext->schat.zprogram - && qsys->schat.zchat == qnext->schat.zchat); - - qsys = qnext; - } - while (qsys != NULL); - - if (fbadtime) - { - ulog (LOG_ERROR, "Wrong time to call"); - - /* Update the status, unless the system can never be called. If - the system can never be called, there is little point to - putting in a ``wrong time to call'' message. We don't change - the number of retries, although we do set the wait until the - next retry to 0. */ - if (! fnevertime) - { - sstat.ttype = STATUS_WRONG_TIME; - sstat.ilast = isysdep_time ((long *) NULL); - sstat.cwait = 0; - (void) fsysdep_set_status (qorigsys, &sstat); - } - } - - return FALSE; -} - -/* Do the actual work of calling another system, such as dialing and - logging in. The qsys argument is the system to call, the qport - argument is the port to use, and the qstat argument holds the - current status of the ssystem. If we log in successfully, set - *pfcalled to TRUE; this is used to distinguish a failed dial from a - failure during the call. The quse argument is passed in because - this function does not call fport_close, so if it reads in a port - structure to open it must not keep it on the stack. */ - -static boolean fdo_call (qsys, qport, qstat, cretry, pfcalled, quse) - const struct ssysteminfo *qsys; - struct sport *qport; - struct sstatus *qstat; - int cretry; - boolean *pfcalled; - struct sport *quse; -{ - const char *zstr; - boolean fnew; - int cdial_proto_params; - struct sproto_param *qdial_proto_params; - int idial_reliable; - long istart_time; - - *pfcalled = FALSE; - - /* If no port was specified on the command line, use any port - defined for the system. To select the system port: 1) see if - port information was specified directly; 2) see if a port was - named; 3) get an available port given the baud rate. We don't - change the system status if a port is unavailable; i.e. we don't - force the system to wait for the retry time. */ - - if (qport == NULL) - qport = qsys->qport; - if (qport != NULL) - { - if (! fport_lock (qport, FALSE)) - { - ulog (LOG_ERROR, "Port \"%s\" already locked", qport->zname); - return FALSE; - } - } - else - { - if (! ffind_port (qsys->zport, qsys->ibaud, qsys->ihighbaud, - quse, fport_lock, TRUE)) - return FALSE; - qport = quse; - /* The port is locked by ffind_port. */ - } - - /* Now try to call the system. */ - - if (! fport_open (qport, qsys->ibaud, qsys->ihighbaud, FALSE)) - { - (void) fcall_failed (qsys, STATUS_PORT_FAILED, qstat, cretry); - return FALSE; - } - - if (qsys->zalternate == NULL) - ulog (LOG_NORMAL, "Calling system %s (port %s)", qsys->zname, - zLdevice == NULL ? "unknown" : zLdevice); - else - ulog (LOG_NORMAL, "Calling system %s (alternate %s, port %s)", - qsys->zname, qsys->zalternate, - zLdevice == NULL ? "unknown" : zLdevice); - - cdial_proto_params = 0; - qdial_proto_params = NULL; - if (! fport_dial (qsys, &cdial_proto_params, &qdial_proto_params, - &idial_reliable)) - { - (void) fcall_failed (qsys, STATUS_DIAL_FAILED, qstat, cretry); - return FALSE; - } - - if (! fchat (&qsys->schat, qsys, (const struct sdialer *) NULL, - (const char *) NULL, FALSE, qPort->zname, iport_baud ())) - { - (void) fcall_failed (qsys, STATUS_LOGIN_FAILED, qstat, cretry); - return FALSE; - } - - qstat->ttype = STATUS_TALKING; - qstat->ilast = isysdep_time ((long *) NULL); - qstat->cretries = 0; - qstat->cwait = 0; - if (! fsysdep_set_status (qsys, qstat)) - return FALSE; - - ulog (LOG_NORMAL, "Login successful"); - - *pfcalled = TRUE; - istart_time = isysdep_time ((long *) NULL); - - /* We should now see "Shere" from the other system. Apparently - some systems send "Shere=foo" where foo is the remote name. */ - - zstr = zget_uucp_cmd (TRUE); - if (zstr == NULL) - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, cretry); - return FALSE; - } - - if (strncmp (zstr, "Shere", 5) != 0) - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, cretry); - ulog (LOG_ERROR, "Bad initialization string"); - return FALSE; - } - - if (zstr[5] == '=') - { - const char *zheresys; - int icmp; - - /* Some UUCP packages only provide seven characters in the Shere - machine name. */ - zheresys = zstr + 6; - if (strlen (zheresys) == 7) - icmp = strncmp (zheresys, qsys->zname, 7); - else - icmp = strcmp (zheresys, qsys->zname); - if (icmp != 0) - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, - cretry); - ulog (LOG_ERROR, "Called wrong system (%s)", zheresys); - return FALSE; - } - } -#if DEBUG > 1 - else if (zstr[5] != '\0') - DEBUG_MESSAGE1 (DEBUG_HANDSHAKE, - "fdo_call: Strange Shere: %s", zstr); -#endif - - /* We now send "S" name switches, where name is our UUCP name. If - we are using sequence numbers with this system, we send a -Q - argument with the sequence number. If the call-timegrade command - was used, we send a -p argument and a -vgrade= argument with the - grade to send us (we send both argument to make it more likely - that one is recognized). We always send a -N (for new) switch to - indicate that we are prepared to accept file sizes. */ - { - char bgrade; - const char *zuse_local; - char *zsend; - - /* Determine the grade we should request of the other system. A - '\0' means that no restrictions have been made. */ - bgrade = btimegrade (qsys->zcalltimegrade); - - if (qsys->zlocalname != NULL) - zuse_local = qsys->zlocalname; - else - zuse_local = zLocalname; - - zsend = (char *) alloca (strlen (zuse_local) + 70); - if (! qsys->fsequence) - { - if (bgrade == '\0') - sprintf (zsend, "S%s -N", zuse_local); - else - sprintf (zsend, "S%s -p%c -vgrade=%c -N", zuse_local, bgrade, - bgrade); - } - else - { - long iseq; - - iseq = isysdep_get_sequence (qsys); - if (iseq < 0) - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, - cretry); - return FALSE; - } - if (bgrade == '\0') - sprintf (zsend, "S%s -Q%ld -N", zuse_local, iseq); - else - sprintf (zsend, "S%s -Q%ld -p%c -vgrade=%c -N", zuse_local, iseq, - bgrade, bgrade); - } - - if (! fsend_uucp_cmd (zsend)) - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, - cretry); - return FALSE; - } - } - - /* Now we should see ROK or Rreason where reason gives a cryptic - reason for failure. If we are talking to a counterpart, we will - get back ROKN. */ - zstr = zget_uucp_cmd (TRUE); - if (zstr == NULL) - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, cretry); - return FALSE; - } - - if (zstr[0] != 'R') - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, cretry); - ulog (LOG_ERROR, "Bad reponse to handshake string (%s)", - zstr); - return FALSE; - } - - if (strcmp (zstr + 1, "OKN") == 0) - fnew = TRUE; - else if (strcmp (zstr + 1, "OK") == 0) - fnew = FALSE; - else if (strcmp (zstr + 1, "CB") == 0) - { - ulog (LOG_NORMAL, "Remote system will call back"); - qstat->ttype = STATUS_COMPLETE; - (void) fsysdep_set_status (qsys, qstat); - return TRUE; - } - else - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, cretry); - ulog (LOG_ERROR, "Handshake failed (%s)", zstr + 1); - return FALSE; - } - - /* The slave should now send \020Pprotos\0 where protos is a list of - supported protocols. Each protocol is a single character. */ - - zstr = zget_uucp_cmd (TRUE); - if (zstr == NULL) - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, cretry); - return FALSE; - } - - if (zstr[0] != 'P') - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, cretry); - ulog (LOG_ERROR, "Bad protocol handshake (%s)", zstr); - return FALSE; - } - - /* Now decide which protocol to use. The system and the port may - have their own list of protocols. */ - { - int i; - char ab[5]; - - i = CPROTOCOLS; - if (qsys->zprotocols != NULL || qPort->zprotocols != NULL) - { - const char *zproto; - - if (qsys->zprotocols != NULL) - zproto = qsys->zprotocols; - else - zproto = qPort->zprotocols; - for (; *zproto != '\0'; zproto++) - { - if (strchr (zstr + 1, *zproto) != NULL) - { - for (i = 0; i < CPROTOCOLS; i++) - if (asProtocols[i].bname == *zproto) - break; - if (i < CPROTOCOLS) - break; - } - } - } - else - { - int ir; - - /* If neither the system nor the port specified a list of - protocols, we want only protocols that match the known - reliability of the dialer and the port. If we have no - reliability information, we default to a reliable eight bit - connection. */ - - ir = 0; - if ((qPort->ireliable & RELIABLE_SPECIFIED) != 0) - ir = qPort->ireliable; - if ((idial_reliable & RELIABLE_SPECIFIED) != 0) - { - if (ir != 0) - ir &= idial_reliable; - else - ir = idial_reliable; - } - if (ir == 0) - ir = RELIABLE_RELIABLE | RELIABLE_EIGHT | RELIABLE_SPECIFIED; - - for (i = 0; i < CPROTOCOLS; i++) - { - int ipr; - - ipr = asProtocols[i].ireliable; - if ((ipr & ir) != ipr) - continue; - if (strchr (zstr + 1, asProtocols[i].bname) != NULL) - break; - } - } - - if (i >= CPROTOCOLS) - { - (void) fsend_uucp_cmd ("UN"); - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, cretry); - ulog (LOG_ERROR, "No mutually supported protocols"); - return FALSE; - } - - qProto = &asProtocols[i]; - - sprintf (ab, "U%c", qProto->bname); - if (! fsend_uucp_cmd (ab)) - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, cretry); - return FALSE; - } - } - - /* Run any protocol parameter commands. */ - - if (qProto->qcmds != NULL) - { - if (qsys->cproto_params != 0) - uapply_proto_params (qProto->bname, qProto->qcmds, - qsys->cproto_params, qsys->qproto_params); - if (qPort->cproto_params != 0) - uapply_proto_params (qProto->bname, qProto->qcmds, - qPort->cproto_params, qPort->qproto_params); - if (cdial_proto_params != 0) - uapply_proto_params (qProto->bname, qProto->qcmds, - cdial_proto_params, qdial_proto_params); - } - - /* Turn on the selected protocol. */ - - if (! (*qProto->pfstart) (TRUE)) - { - (void) fcall_failed (qsys, STATUS_HANDSHAKE_FAILED, qstat, - cretry); - return FALSE; - } - - /* Now we have succesfully logged in as the master. */ - - ulog (LOG_NORMAL, "Handshake successful"); - - { - boolean fret; - long iend_time; - - fret = fuucp (TRUE, qsys, '\0', fnew, (long) -1); - ulog_user ((const char *) NULL); - usysdep_get_work_free (qsys); - - /* If we jumped out due to an error, shutdown the protocol. */ - if (! fret) - { - (void) (*qProto->pfshutdown) (); - ustats_failed (); - } - - /* Now send the hangup message. As the caller, we send six O's - and expect to receive seven O's. We send the six O's twice - to help the other side. We don't worry about errors here. */ - if (fsend_uucp_cmd ("OOOOOO") - && fsend_uucp_cmd ("OOOOOO")) - { - /* We don't even look for the hangup string from the other - side unless we're in debugging mode. */ -#if DEBUG > 1 - if (fret && FDEBUGGING (DEBUG_HANDSHAKE)) - { - zstr = zget_uucp_cmd (FALSE); - if (zstr != NULL) - { - /* The Ultrix UUCP only sends six O's, although I - think it should send seven. Because of this, we - only check for six. */ - if (strstr (zstr, "OOOOOO") == NULL) - ulog (LOG_DEBUG, "No hangup from remote"); - } - } -#endif - } - - iend_time = isysdep_time ((long *) NULL); - - ulog (LOG_NORMAL, "Call complete (%ld seconds)", - iend_time - istart_time); - - if (! fret) - { - (void) fcall_failed (qsys, STATUS_FAILED, qstat, cretry); - return FALSE; - } - else - { - qstat->ttype = STATUS_COMPLETE; - qstat->ilast = iend_time; - (void) fsysdep_set_status (qsys, qstat); - return TRUE; - } - } -} - -/* A small helper routine to write out the system status when something - goes wrong. */ - -static boolean -fcall_failed (qsys, twhy, qstat, cretry) - const struct ssysteminfo *qsys; - enum tstatus_type twhy; - struct sstatus *qstat; - int cretry; -{ - DEBUG_MESSAGE2 (DEBUG_HANDSHAKE, - "fcall_failed: Cause %d (%s)", (int) twhy, - azStatus[(int) twhy]); - - qstat->ttype = twhy; - qstat->cretries++; - qstat->ilast = isysdep_time ((long *) NULL); - if (cretry == 0) - qstat->cwait = CRETRY_WAIT (qstat->cretries); - else - qstat->cwait = cretry * 60; - return fsysdep_set_status (qsys, qstat); -} - -/* Prompt for a login name and a password, and run as the slave. */ - -static boolean flogin_prompt (qport) - struct sport *qport; -{ - const char *zuser, *zpass; - - DEBUG_MESSAGE0 (DEBUG_HANDSHAKE, "flogin_prompt: Waiting for login"); - - do - { - if (! fport_write ("login: ", sizeof "login: " - 1)) - return FALSE; - zuser = zget_typed_line (); - } - while (zuser != NULL && *zuser == '\0'); - - if (zuser != NULL) - { - char *zhold; - - zhold = (char *) alloca (strlen (zuser) + 1); - strcpy (zhold, zuser); - - if (! fport_write ("Password:", sizeof "Password:" - 1)) - return FALSE; - - zpass = zget_typed_line (); - if (zpass != NULL) - { - if (fcheck_login (zhold, zpass)) - { -#if DEBUG > 1 - int iholddebug; -#endif - - /* We ignore the return value of faccept_call because we - really don't care whether the call succeeded or not. - We are going to reset the port anyhow. */ -#if DEBUG > 1 - iholddebug = iDebug; -#endif - (void) faccept_call (zhold, qport, - (const struct ssysteminfo **) NULL); -#if DEBUG > 1 - iDebug = iholddebug; -#endif - } - } - } - - return TRUE; -} - -/* Accept a call from a remote system. If pqsys is not NULL, *pqsys - will be set to the system that called in if known. */ - -static boolean -faccept_call (zlogin, qport, pqsys) - const char *zlogin; - struct sport *qport; - const struct ssysteminfo **pqsys; -{ - long istart_time; - int cdial_proto_params; - struct sproto_param *qdial_proto_params; - int idial_reliable; - boolean ftcp_port; - const char *zport; - char *zsend, *zspace; - const char *zstr; - struct ssysteminfo ssys; - const struct ssysteminfo *qsys; - boolean fnew; - char bgrade; - const char *zuse_local; - struct sstatus sstat; - long cmax_receive; - boolean frestart; -#if HAVE_TAYLOR_CONFIG - struct sport sportinfo; -#endif - - if (pqsys != NULL) - *pqsys = NULL; - - ulog (LOG_NORMAL, "Incoming call (login %s port %s)", - zlogin == NULL ? "unknown" : zlogin, - zLdevice == NULL ? "unknown" : zLdevice); - - istart_time = isysdep_time ((long *) NULL); - - /* Figure out protocol parameters determined by the port. If no - port was specified we're reading standard input, so try to get - the port name and read information from the port file. We only - use the port information to get protocol parameters; we don't - want to start treating the port as though it were a modem, for - example. */ - - if (qport != NULL) - { - zport = qport->zname; - ftcp_port = FALSE; - } - else - { - zport = zsysdep_port_name (&ftcp_port); - - /* We want to get the protocol parameters for the port. If we - aren't using HAVE_TAYLOR_CONFIG, that information isn't - stored anyhow, so we don't bother to look it up. */ - -#if HAVE_TAYLOR_CONFIG - - if (zport != NULL && zPortfile != NULL) - { - if (ffind_port (zport, (long) 0, (long) 0, &sportinfo, - (boolean (*) P((struct sport *, boolean))) NULL, - FALSE)) - qport = &sportinfo; - } - -#endif /* HAVE_TAYLOR_CONFIG */ - - if (zport == NULL) - zport = "unknown"; - } - - /* If we've managed to figure out that this is a modem port, now try - to get protocol parameters from the dialer. */ - - cdial_proto_params = 0; - qdial_proto_params = NULL; - idial_reliable = 0; - if (qport != NULL) - { - if (qport->ttype == PORTTYPE_MODEM) - { - if (qport->u.smodem.zdialer != NULL) - { - char *zcopy; - char *zdial; - struct sdialer sdialerinfo; - - /* We use the first dialer in the sequence. */ - zcopy = (char *) alloca (strlen (qport->u.smodem.zdialer) - + 1); - strcpy (zcopy, qport->u.smodem.zdialer); - - zdial = strtok (zcopy, " \t"); - if (fread_dialer_info (zdial, &sdialerinfo)) - { - cdial_proto_params = sdialerinfo.cproto_params; - qdial_proto_params = sdialerinfo.qproto_params; - idial_reliable = sdialerinfo.ireliable; - } - } - else if (qport->u.smodem.qdialer != NULL) - { - cdial_proto_params = qport->u.smodem.qdialer->cproto_params; - qdial_proto_params = qport->u.smodem.qdialer->qproto_params; - idial_reliable = qport->u.smodem.qdialer->ireliable; - } - } -#if HAVE_TCP - else if (qport->ttype == PORTTYPE_TCP) - ftcp_port = TRUE; -#endif - } - - /* If it's a TCP port, it's fully reliable. Even if HAVE_TCP is not - supported, zsysdep_port_name may be able to figure this out (not - on Unix, though). */ - if (ftcp_port) - idial_reliable = (RELIABLE_SPECIFIED | RELIABLE_ENDTOEND - | RELIABLE_RELIABLE | RELIABLE_EIGHT); - - /* We have to check to see whether some system uses this login name - to indicate a different local name. Obviously, this means that - any system which uses this login name must expect the alternate - system name. */ - zuse_local = NULL; - if (fUnknown_ok) - { - for (qsys = &sUnknown; qsys != NULL; qsys = qsys->qalternate) - { - if (qsys->zlocalname != NULL - && qsys->zcalled_login != NULL - && strcmp (qsys->zcalled_login, zlogin) == 0) - { - zuse_local = qsys->zlocalname; - break; - } - } - } - if (zuse_local == NULL) - { - struct ssysteminfo *pas; - int isys, csystems; - - zuse_local = zLocalname; - - uread_all_system_info (&csystems, &pas); - for (isys = 0; isys < csystems; isys++) - { - for (qsys = &pas[isys]; qsys != NULL; qsys = qsys->qalternate) - { - if (qsys->zlocalname != NULL - && qsys->zcalled_login != NULL - && strcmp (qsys->zcalled_login, zlogin) == 0) - { - zuse_local = qsys->zlocalname; - break; - } - } - if (qsys != NULL) - break; - } - } - - /* Tell the remote system who we are. */ - zsend = (char *) alloca (strlen (zuse_local) + 10); - sprintf (zsend, "Shere=%s", zuse_local); - if (! fsend_uucp_cmd (zsend)) - return FALSE; - - zstr = zget_uucp_cmd (TRUE); - if (zstr == NULL) - return FALSE; - - if (zstr[0] != 'S') - { - ulog (LOG_ERROR, "Bad introduction string"); - return FALSE; - } - ++zstr; - - zspace = strchr (zstr, ' '); - if (zspace != NULL) - *zspace = '\0'; - if (fread_system_info (zstr, &ssys)) - qsys = &ssys; - else - { - /* We have no information on this system. */ - if (! fUnknown_ok) - { - (void) fsend_uucp_cmd ("RYou are unknown to me"); - ulog (LOG_ERROR, "Call from unknown system %s", zstr); - return FALSE; - } - - /* We have to translate the name to a canonical form for the - benefit of systems which only allow short system names. */ - sUnknown.zname = ztranslate_system (zstr); - if (sUnknown.zname == NULL) - { - (void) fsend_uucp_cmd ("RYou are unknown to me"); - return FALSE; - } - - qsys = &sUnknown; - } - - if (pqsys != NULL) - *pqsys = qsys; - - if (! fcheck_validate (zlogin, qsys->zname)) - { - (void) fsend_uucp_cmd ("RLOGIN"); - ulog (LOG_ERROR, "System %s used wrong login name %s", - zstr, zlogin); - return FALSE; - } - - if (qsys->zcalled_login != NULL) - { - const struct ssysteminfo *qany; - - /* Choose an alternate system definition based on the - login name. */ - qany = NULL; - for (; qsys != NULL; qsys = qsys->qalternate) - { - if (qsys->zcalled_login != NULL) - { - if (qany == NULL - && strcmp (qsys->zcalled_login, "ANY") == 0) - qany = qsys; - else if (strcmp (qsys->zcalled_login, zlogin) == 0) - break; - } - } - - if (qsys == NULL) - { - if (qany == NULL) - { - (void) fsend_uucp_cmd ("RLOGIN"); - ulog (LOG_ERROR, "System %s used wrong login name %s", - zstr, zlogin); - return FALSE; - } - qsys = qany; - } - } - - ulog_system (qsys->zname); - -#if DEBUG > 1 - iDebug |= qsys->idebug; -#endif - - /* See if we are supposed to call the system back. This will queue - up an empty command. It would be better to actually call back - directly at this point as well. */ - if (qsys->fcallback) - { - (void) fsend_uucp_cmd ("RCB"); - ulog (LOG_NORMAL, "Will call back"); - (void) zsysdep_spool_commands (qsys, BGRADE_HIGH, 0, - (const struct scmd *) NULL); - return TRUE; - } - - /* We only permit one call at a time from a remote system. Lock it. */ - if (! fsysdep_lock_system (qsys)) - { - (void) fsend_uucp_cmd ("RLCK"); - ulog (LOG_ERROR, "System already locked"); - return FALSE; - } - sLocked_system = *qsys; - fLocked_system = TRUE; - - /* Set the system status. We don't really care if we can't get the - earlier status. We also don't want to kill the conversation just - because we can't output the .Status file, so we ignore any - errors. */ - if (! fsysdep_get_status (qsys, &sstat)) - { - sstat.cretries = 0; - sstat.cwait = 0; - } - - sstat.ttype = STATUS_TALKING; - sstat.ilast = isysdep_time ((long *) NULL); - (void) fsysdep_set_status (qsys, &sstat); - - /* Check the arguments of the remote system. We accept -x# to set - our debugging level and -Q# for a sequence number. We may insist - on a sequence number. The -p and -vgrade= arguments are taken to - specify the lowest job grade that we should transfer; I think - this is the traditional meaning, but I don't know. The -N switch - means that we are talking to another instance of ourselves. The - -U switch specifies the ulimit of the remote system, which we - treat as the maximum file size that may be sent. The -R switch - means that the remote system supports file restart; we don't. */ - - fnew = FALSE; - bgrade = BGRADE_LOW; - cmax_receive = (long) -1; - frestart = FALSE; - - if (zspace == NULL) - { - if (qsys->fsequence) - { - (void) fsend_uucp_cmd ("RBADSEQ"); - ulog (LOG_ERROR, "No sequence number (call rejected)"); - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - return FALSE; - } - } - else - { - ++zspace; - while (isspace (BUCHAR (*zspace))) - ++zspace; - - while (*zspace != '\0') - { - boolean frecognized; - char *znext; - - frecognized = FALSE; - if (*zspace == '-') - { - switch (zspace[1]) - { - case 'x': - frecognized = TRUE; -#if DEBUG > 1 - { - int iwant; - - iwant = atoi (zspace + 2); - if (! fnew) - iwant = (1 << iwant) - 1; - iwant &= qsys->imax_remote_debug; - if ((iDebug | iwant) != iDebug) - { - iDebug |= iwant; - ulog (LOG_NORMAL, "Setting debugging mode to 0%o", - iDebug); - } - } -#endif - break; - case 'Q': - frecognized = TRUE; - { - long iseq; - - if (! qsys->fsequence) - break; - iseq = atol (zspace + 2); - if (iseq != isysdep_get_sequence (qsys)) - { - (void) fsend_uucp_cmd ("RBADSEQ"); - ulog (LOG_ERROR, "Out of sequence call rejected"); - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - return FALSE; - } - } - break; - case 'p': - /* We don't accept a space between the -p and the - grade, although we should. */ - frecognized = TRUE; - if (FGRADE_LEGAL (zspace[2])) - bgrade = zspace[2]; - break; - case 'v': - if (strncmp (zspace + 1, "vgrade=", - sizeof "vgrade=" - 1) == 0) - { - frecognized = TRUE; - if (FGRADE_LEGAL (zspace[sizeof "vgrade="])) - bgrade = zspace[sizeof "vgrade="]; - } - break; - case 'N': - frecognized = TRUE; - fnew = TRUE; - break; - case 'U': - frecognized = TRUE; - { - long c; - - c = strtol (zspace + 2, (char **) NULL, 0); - if (c > 0) - cmax_receive = c * (long) 512; - } - break; - case 'R': - frecognized = TRUE; - frestart = TRUE; - break; - default: - break; - } - } - - znext = zspace; - while (*znext != '\0' && ! isspace (BUCHAR (*znext))) - ++znext; - - if (! frecognized) - { - int clen; - char *zcopy; - - /* We could just use %.*s for this, but it's probably - not portable. */ - clen = znext - zspace; - zcopy = (char *) alloca (clen + 1); - strncpy (zcopy, zspace, clen); - zcopy[clen] = '\0'; - ulog (LOG_NORMAL, "Unrecognized argument %s", zcopy); - } - - zspace = znext; - while (isspace (BUCHAR (*zspace))) - ++zspace; - } - } - - /* We recognized the system, and the sequence number (if any) was - OK. Send an ROK, and send a list of protocols. If we got the -N - switch, send ROKN to confirm it. */ - - if (! fsend_uucp_cmd (fnew ? "ROKN" : "ROK")) - { - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - return FALSE; - } - - { - int i; - - if (qsys->zprotocols != NULL || - (qport != NULL && qport->zprotocols != NULL)) - { - const char *zprotos; - - if (qsys->zprotocols != NULL) - zprotos = qsys->zprotocols; - else - zprotos = qport->zprotocols; - zsend = (char *) alloca (strlen (zprotos) + 2); - sprintf (zsend, "P%s", zprotos); - } - else - { - char *zset; - int ir; - - zsend = (char *) alloca (CPROTOCOLS + 2); - zset = zsend; - *zset++ = 'P'; - - /* If the system did not specify a list of protocols, we want - only protocols that match the known reliability of the - dialer and the port. If we have no information, we default - to a reliable eight bit connection. */ - - ir = 0; - if (qport != NULL - && (qport->ireliable & RELIABLE_SPECIFIED) != 0) - ir = qport->ireliable; - if ((idial_reliable & RELIABLE_SPECIFIED) != 0) - { - if (ir != 0) - ir &= idial_reliable; - else - ir = idial_reliable; - } - if (ir == 0) - ir = RELIABLE_RELIABLE | RELIABLE_EIGHT | RELIABLE_SPECIFIED; - - for (i = 0; i < CPROTOCOLS; i++) - { - int ipr; - - ipr = asProtocols[i].ireliable; - if ((ipr & ir) != ipr) - continue; - *zset++ = asProtocols[i].bname; - } - *zset = '\0'; - } - - if (! fsend_uucp_cmd (zsend)) - { - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - return FALSE; - } - - /* The master will now send back the selected protocol. */ - zstr = zget_uucp_cmd (TRUE); - if (zstr == NULL) - { - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - return FALSE; - } - - if (zstr[0] != 'U' || zstr[2] != '\0') - { - ulog (LOG_ERROR, "Bad protocol response string"); - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - return FALSE; - } - - if (zstr[1] == 'N') - { - ulog (LOG_ERROR, "No supported protocol"); - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - return FALSE; - } - - for (i = 0; i < CPROTOCOLS; i++) - if (asProtocols[i].bname == zstr[1]) - break; - - if (i >= CPROTOCOLS) - { - ulog (LOG_ERROR, "No supported protocol"); - sstat.ttype = STATUS_FAILED; - (void) fsysdep_set_status (qsys, &sstat); - return FALSE; - } - - qProto = &asProtocols[i]; - } - - /* Run the chat script for when a call is received. */ - - if (! fchat (&qsys->scalled_chat, qsys, (const struct sdialer *) NULL, - (const char *) NULL, FALSE, zport, iport_baud ())) - { - sstat.ttype = STATUS_FAILED; - sstat.ilast = isysdep_time ((long *) NULL); - (void) fsysdep_set_status (qsys, &sstat); - return FALSE; - } - - /* Run any protocol parameter commands. There should be a way to - read the dialer information if there is any to permit modem - specific protocol parameters, but for now there isn't. */ - - if (qProto->qcmds != NULL) - { - if (qsys->cproto_params != 0) - uapply_proto_params (qProto->bname, qProto->qcmds, - qsys->cproto_params, qsys->qproto_params); - if (qport != NULL - && qport->cproto_params != 0) - uapply_proto_params (qProto->bname, qProto->qcmds, - qport->cproto_params, qport->qproto_params); - if (cdial_proto_params != 0) - uapply_proto_params (qProto->bname, qProto->qcmds, - cdial_proto_params, qdial_proto_params); - } - - /* Turn on the selected protocol. */ - - if (! (*qProto->pfstart)(FALSE)) - { - sstat.ttype = STATUS_FAILED; - sstat.ilast = isysdep_time ((long *) NULL); - (void) fsysdep_set_status (qsys, &sstat); - return FALSE; - } - - /* If we using HAVE_BNU_LOGGING, then the previous ``incoming call'' - message went to the general log, since we didn't know the system - name at that point. In that case, we repeat the port and login - names. */ -#if HAVE_BNU_LOGGING - if (bgrade == BGRADE_LOW) - ulog (LOG_NORMAL, "Handshake successful (login %s port %s)", - zlogin == NULL ? "unknown" : zlogin, - zLdevice == NULL ? "unknown" : zLdevice); - else - ulog (LOG_NORMAL, "Handshake successful (login %s port %s grade %c)", - zlogin == NULL ? "unknown" : zlogin, - zLdevice == NULL ? "unknown" : zLdevice, - bgrade); -#else /* ! HAVE_BNU_LOGGING */ - if (bgrade == BGRADE_LOW) - ulog (LOG_NORMAL, "Handshake successful"); - else - ulog (LOG_NORMAL, "Handshake successful (grade %c)", bgrade); -#endif /* ! HAVE_BNU_LOGGING */ - - { - boolean fret; - long iend_time; - - fret = fuucp (FALSE, qsys, bgrade, fnew, cmax_receive); - ulog_user ((const char *) NULL); - usysdep_get_work_free (qsys); - - /* If we bombed out due to an error, shut down the protocol. */ - if (! fret) - { - (void) (*qProto->pfshutdown) (); - ustats_failed (); - } - - /* Hangup. As the answerer, we send seven O's and expect to see - six. */ - if (fsend_uucp_cmd ("OOOOOOO") - && fsend_uucp_cmd ("OOOOOOO")) - { - /* We don't even look for the hangup string from the other - side unless we're in debugging mode. */ -#if DEBUG > 1 - if (fret && FDEBUGGING (DEBUG_HANDSHAKE)) - { - zstr = zget_uucp_cmd (FALSE); - if (zstr != NULL) - { - if (strstr (zstr, "OOOOOO") == NULL) - ulog (LOG_DEBUG, "No hangup from remote"); - } - } -#endif - } - - iend_time = isysdep_time ((long *) NULL); - - ulog (LOG_NORMAL, "Call complete (%ld seconds)", - iend_time - istart_time); - if (fret) - sstat.ttype = STATUS_COMPLETE; - else - sstat.ttype = STATUS_FAILED; - sstat.ilast = iend_time; - (void) fsysdep_set_status (qsys, &sstat); - return fret; - } -} - -/* This function runs the main UUCP protocol. It is called when the - two systems have succesfully connected. It transfers files back - and forth until neither system has any more work to do. The - traditional UUCP protocol has a master which sends files to the - slave or requests files from the slave (a single file is requested - with the R command; a wildcarded file name is requested with the X - command). The slave simply obeys the commands of the master. When - the master has done all its work, it requests a hangup. If the - slave has work to do it refuses the hangup and becomes the new - master. - - This is essentially a half-duplex connection, in that files are - only transferred in one direction at a time. This is not - unreasonable, since generally one site is receiving a lot of news - from the other site, and I believe that Telebit modems are - basically half-duplex in that it takes a comparatively long time to - turn the line around. However, it is possible to design a - full-duplex protocol which would be useful in some situtations when - using V.32 (or a network) and this function attempts to support - this possibility. - - Traditionally the work to be done is kept in a set of files whose - names begin with C.[system][grade][pid], where system is the remote - system name, grade is the grade of transfer, and pid makes the file - name unique. Each line in these files is a command, and each line - can be treated independently. We let the system dependent layer - handle all of this. This will let us use some other scheme on - systems in which the fourteen character filename length limit - restricts the name of the remote system to seven characters (the - usual restriction cited is six characters; I do not yet know where - this comes from). - - Here are the types of commands, along with the definitions of the - variables they use in the fuucp function. - - 'S' -- Send a file from master to slave. - zfrom -- master file name - zto -- slave file name - zuser -- user who requested the transfer - zoptions -- list of options - ztemp -- temporary file name on master (used unless option c) - imode -- mode to give file - znotify -- user to notify (if option n) - - The options are: - C -- file copied to spool (use ztemp rather than zfrom) - c -- file not copied to spool (use zfrom rather than ztemp) - d -- create directories if necessary - f -- do not create directories - m -- notify originator (in zuser) when complete - n -- notify recipient (in znotify) when complete - - I assume that the n option is implemented by the remote system. - - 'R' -- Retrieve a file from slave to master. - zfrom -- slave file name - zto -- master file name - zuser -- user who requested the transfer - zoptions -- list of options - - The options are the same as in case 'S', except that option n is - not supported. If zto is a directory, we must create a file in - that directory using the last component of zfrom. - - 'X' -- Execute wildcard transfer from slave to master. - zfrom -- wildcard file name - zto -- local file (hopefully a directory) - zuser -- user who requested the transfer - zoptions -- list of options - - The options are presumably the same as in case 'R'. It may be - permissible to have no zuser or zoptions. The zto name will have - local! prepended to it already (where local is the local system - name). - - This command is merely sent over to the remote system, where it - is executed. When the remote system becomes the master, it sends - the files back. - - 'H' -- Hangup - This is used by the master to indicate a transfer of control. If - slave has nothing to do, it responds with HY and the conversation - is finished. Otherwise, the slave becomes the master, and - vice-versa. */ - -static boolean -fuucp (fmaster, qsys, bgrade, fnew, cmax_receive) - boolean fmaster; - const struct ssysteminfo *qsys; - int bgrade; - boolean fnew; - long cmax_receive; -{ - boolean fcaller, fmasterdone, fnowork; - const char *zlocal_size, *zremote_size; - long clocal_size, cremote_size, cmax_ever; - - fcaller = fmaster; - - fmasterdone = FALSE; - if (! qProto->ffullduplex && ! fmaster) - fmasterdone = TRUE; - - /* Make sure we have a spool directory for this system. */ - if (! fsysdep_make_spool_dir (qsys)) - return FALSE; - - /* If we are not the caller, the grade will be passed in as an - argument. If we are the caller, we compute the grade in this - function so that we can recompute if time has passed. */ - - if (fcaller) - bgrade = btimegrade (qsys->ztime); - - if (bgrade == '\0') - fnowork = TRUE; - else - { - if (! fsysdep_get_work_init (qsys, bgrade)) - return FALSE; - fnowork = FALSE; - } - - /* Determine the maximum sizes we can send and receive. */ - - if (fcaller) - { - zlocal_size = qsys->zcall_local_size; - zremote_size = qsys->zcall_remote_size; - } - else - { - zlocal_size = qsys->zcalled_local_size; - zremote_size = qsys->zcalled_remote_size; - } - - clocal_size = cmax_size_now (zlocal_size); - cremote_size = cmax_size_now (zremote_size); - cmax_ever = (long) -2; - - /* Loop while we have local commands to execute and while we receive - remote commands. */ - - while (TRUE) - { -#if ! HAVE_ALLOCA - /* This only works if we know that no caller of this function is - holding an alloca'ed pointer. */ - (void) alloca (0); -#endif - -#if DEBUG > 1 - /* If we're doing any debugging, close the log and debugging - files regularly. This will let people copy them off and - remove them while the conversation is in progresss. */ - if (iDebug != 0) - { - ulog_close (); - ustats_close (); - } -#endif - - /* We send a command to the remote system if - we are the master or - this is full duplex protocol which is ready for a command and - we haven't finished executing commands. */ - if (fmaster || - (qProto->ffullduplex && ! fmasterdone)) - { - struct scmd s; - const char *zmail, *zuse; - boolean fspool, fnever; - openfile_t e = EFILECLOSED; - boolean fgone; - - /* Get the next work line for this system. All the arguments - are left pointing into a static buffer, so they must be - copied out before the next call. */ - ulog_user ((const char *) NULL); - if (fnowork) - s.bcmd = 'H'; - else - { - s.zuser = NULL; - if (! fsysdep_get_work (qsys, bgrade, &s)) - return FALSE; - ulog_user (s.zuser); - } - - switch (s.bcmd) - { - case 'S': - /* Send a file. */ - - fspool = fspool_file (s.zfrom); - - if (! fspool) - { - zuse = zsysdep_real_file_name (qsys, s.zfrom, - (const char *) NULL); - if (zuse == NULL) - { - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "cannot form file name", - s.zfrom, zLocalname, - s.zto, qsys->zname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - } - - /* The 'C' option means that the file has been - copied to the spool directory. */ - if (strchr (s.zoptions, 'C') != NULL) - fspool = TRUE; - - if (! fok_to_send (zuse, TRUE, fcaller, fspool, qsys, - s.zuser)) - { - ulog (LOG_ERROR, "Not permitted to send %s", zuse); - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "not permitted to send", - s.zfrom, zLocalname, - s.zto, qsys->zname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - } - - /* If we're copying the real file, use its mode - directly rather than the mode copied into the - command file. */ - if (! fspool) - e = esysdep_open_send (qsys, zuse, TRUE, s.zuser, - &s.imode, &s.cbytes, &fgone); - } - - if (fspool) - { - unsigned int idummy; - - zuse = zsysdep_spool_file_name (qsys, s.ztemp); - if (zuse == NULL) - { - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "cannot form file name", - s.zfrom, zLocalname, - s.zto, qsys->zname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - } - e = esysdep_open_send (qsys, zuse, FALSE, - (const char *) NULL, &idummy, - &s.cbytes, &fgone); - } - - if (! ffileisopen (e)) - { - /* If the file does not exist, fgone will be set to - TRUE. In this case we might have sent the file - the last time we talked to the remote system, - because we might have been interrupted in the - middle of a command file. To avoid confusion, we - don't send a mail message. */ - if (! fgone) - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "cannot open file", - s.zfrom, zLocalname, - s.zto, qsys->zname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - } - - if (s.cbytes != -1) - { - boolean fsmall; - const char *zerr; - - fsmall = FALSE; - fnever = FALSE; - zerr = NULL; - - if (cmax_receive != -1 && cmax_receive < s.cbytes) - { - fsmall = TRUE; - fnever = TRUE; - zerr = "too large for receiver"; - } - else if (clocal_size != -1 && clocal_size < s.cbytes) - { - fsmall = TRUE; - - if (cmax_ever == -2) - { - long c1, c2; - - c1 = cmax_size_ever (qsys->zcall_local_size); - c2 = cmax_size_ever (qsys->zcalled_local_size); - if (c1 > c2) - cmax_ever = c1; - else - cmax_ever = c2; - } - - if (cmax_ever == -1 || cmax_ever >= s.cbytes) - zerr = "too large to send now"; - else - { - fnever = TRUE; - zerr = "too large to send"; - } - } - - if (fsmall) - { - ulog (LOG_ERROR, "File %s is %s", s.zfrom, zerr); - - if (fnever) - { - const char *zsaved; - - zsaved = zsysdep_save_temp_file (s.pseq); - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - zerr, - s.zfrom, zLocalname, - s.zto, qsys->zname, - zsaved); - (void) fsysdep_did_work (s.pseq); - } - - (void) ffileclose (e); - break; - } - } - - ulog (LOG_NORMAL, "Sending %s", s.zfrom); - - /* The send file function is responsible for notifying - the user upon success (if option m) or failure, and - for closing the file. This allows it to not complete - immediately. */ - if (strchr (s.zoptions, 'm') == NULL) - zmail = NULL; - else - zmail = s.zuser; - - if (! fsend_file (TRUE, e, &s, zmail, qsys->zname, fnew)) - return FALSE; - - break; - - case 'R': - /* Receive a file. */ - - if (fspool_file (s.zto)) - { - /* Normal users are not allowed to receive files in - the spool directory, and to make it particularly - difficult we require a special option '9'. This - is used only by uux when a file must be requested - from one system and then sent to another. */ - if (s.zto[0] != 'D' - || strchr (s.zoptions, '9') == NULL) - { - ulog (LOG_ERROR, "Not permitted to receive %s", - s.zto); - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "not permitted to receive", - s.zfrom, qsys->zname, - s.zto, zLocalname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - } - - zuse = zsysdep_spool_file_name (qsys, s.zto); - if (zuse == NULL) - { - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "cannot form file name", - s.zfrom, qsys->zname, - s.zto, zLocalname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - } - } - else - { - zuse = zsysdep_real_file_name (qsys, s.zto, s.zfrom); - if (zuse == NULL) - { - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "cannot form file name", - s.zfrom, qsys->zname, - s.zto, zLocalname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - } - - /* Check permissions. */ - if (! fok_to_receive (zuse, TRUE, fcaller, qsys, s.zuser)) - { - ulog (LOG_ERROR, "Not permitted to receive %s", - s.zto); - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "not permitted to receive", - s.zfrom, qsys->zname, - s.zto, zLocalname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - } - - /* The 'f' option means that directories should not - be created if they do not already exist. */ - if (strchr (s.zoptions, 'f') == NULL) - { - if (! fsysdep_make_dirs (zuse, TRUE)) - { - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "cannot create directories", - s.zfrom, qsys->zname, - s.zto, zLocalname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - } - } - } - - e = esysdep_open_receive (qsys, zuse, &s.ztemp, &s.cbytes); - if (! ffileisopen (e)) - { - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "cannot open file", - s.zfrom, qsys->zname, - s.zto, zLocalname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - } - - /* Here s.cbytes represents the amount of free space we - have. We want to adjust it by the amount of free - space permitted for this system. If there is a - maximum transfer size, we may want to use that as an - amount of free space. */ - if (s.cbytes != -1) - { - s.cbytes -= qsys->cfree_space; - if (s.cbytes < 0) - s.cbytes = 0; - } - - if (clocal_size != -1 - && (s.cbytes == -1 || clocal_size < s.cbytes)) - s.cbytes = clocal_size; - - ulog (LOG_NORMAL, "Receiving %s", zuse); - s.zto = zuse; - - /* As with the send routine, this function is - responsible for mailing a message to the user on - failure or on success if the m option is set, and is - also responsible for closing the file. */ - if (strchr (s.zoptions, 'm') == NULL) - zmail = NULL; - else - zmail = s.zuser; - - /* The imode argument (passed as 0666) will be corrected - with information from the remote system. */ - s.imode = 0666; - - if (! freceive_file (TRUE, e, &s, zmail, qsys->zname, fnew)) - return FALSE; - - break; - - case 'X': - /* Request a file copy. This is used to request a file - to be sent to another machine, as well as to get a - wildcarded filespec. */ - ulog (LOG_NORMAL, "Requesting work: %s to %s", s.zfrom, - s.zto); - - if (! fxcmd (&s, &fnever)) - return FALSE; - - if (fnever) - (void) fmail_transfer (FALSE, s.zuser, - (const char *) NULL, - "wildcard request denied", - s.zfrom, qsys->zname, - s.zto, zLocalname, - (const char *) NULL); - (void) fsysdep_did_work (s.pseq); - break; - - case 'H': - /* There is nothing left to do; hang up. If we are not the - master, take no action (this allows for two-way - protocols. */ - - fmasterdone = TRUE; - if (fmaster) - { - if (! fhangup_request ()) - { - ulog (LOG_ERROR, "Hangup failed"); - return FALSE; - } - - fmaster = FALSE; - - /* Close the log file at every master/slave switch. - This will cut down on the amount of time we have - an old log file open. */ - ulog_close (); - ustats_close (); - } - break; - - default: - ulog (LOG_ERROR, "Unknown command '%c'", s.bcmd); - break; - } - } - - /* We look for a command from the other system if we are the - slave or this is a full-duplex protocol and the slave still - has work to do. */ - if (! fmaster || qProto->ffullduplex) - { - struct scmd s; - const char *zuse, *zmail; - openfile_t e; - char bhave_grade; - long cbytes; - - /* We are the slave. Get the next command from the other - system. */ - ulog_user ((const char *) NULL); - if (! fgetcmd (fmaster, &s)) - return FALSE; - - if (s.bcmd != 'H' && s.bcmd != 'Y') - ulog_user (s.zuser); - - switch (s.bcmd) - { - case 'S': - /* The master wants to send a file to us. */ - - if (fspool_file (s.zto)) - { - zuse = zsysdep_spool_file_name (qsys, s.zto); - /* We don't accept remote command files. */ - if (zuse == NULL || s.zto[0] == 'C') - { - if (! ftransfer_fail ('S', FAILURE_PERM)) - return FALSE; - break; - } - } - else - { - zuse = zsysdep_real_file_name (qsys, s.zto, s.zfrom); - if (zuse == NULL) - { - if (! ftransfer_fail ('S', FAILURE_PERM)) - return FALSE; - break; - } - - /* Check permissions. */ - if (! fok_to_receive (zuse, FALSE, fcaller, qsys, - s.zuser)) - { - ulog (LOG_ERROR, "Not permitted to receive %s", zuse); - if (! ftransfer_fail ('S', FAILURE_PERM)) - return FALSE; - break; - } - - if (strchr (s.zoptions, 'f') == NULL) - { - if (! fsysdep_make_dirs (zuse, TRUE)) - { - if (! ftransfer_fail ('S', FAILURE_PERM)) - return FALSE; - break; - } - } - } - - e = esysdep_open_receive (qsys, zuse, &s.ztemp, &cbytes); - if (! ffileisopen (e)) - { - if (! ftransfer_fail ('S', FAILURE_OPEN)) - return FALSE; - break; - } - - /* Adjust the number of bytes we are prepared to receive - according to the amount of free space we are supposed - to leave available and the maximum file size we are - permitted to transfer. */ - if (cbytes != -1) - { - cbytes -= qsys->cfree_space; - if (cbytes < 0) - cbytes = 0; - } - - if (cremote_size != -1 - && (cbytes == -1 || cremote_size < cbytes)) - cbytes = cremote_size; - - /* If the number of bytes we are prepared to receive - is less than the file size, we must fail. */ - - if (s.cbytes != -1 - && cbytes != -1 - && cbytes < s.cbytes) - { - ulog (LOG_ERROR, "%s is too big to receive", zuse); - (void) ffileclose (e); - (void) remove (s.ztemp); - if (! ftransfer_fail ('S', FAILURE_SIZE)) - return FALSE; - break; - } - - ulog (LOG_NORMAL, "Receiving %s", zuse); - s.zto = zuse; - - if (strchr (s.zoptions, 'n') == NULL) - zmail = NULL; - else - zmail = s.znotify; - s.pseq = NULL; - if (! freceive_file (FALSE, e, &s, zmail, qsys->zname, fnew)) - return FALSE; - - break; - - case 'R': - /* The master wants to get a file from us. */ - - if (fspool_file (s.zfrom)) - { - ulog (LOG_ERROR, "No permission to send %s", s.zfrom); - if (! ftransfer_fail ('R', FAILURE_PERM)) - return FALSE; - break; - } - - zuse = zsysdep_real_file_name (qsys, s.zfrom, - (const char *) NULL); - if (zuse == NULL) - { - if (! ftransfer_fail ('R', FAILURE_PERM)) - return FALSE; - break; - } - - if (! fok_to_send (zuse, FALSE, fcaller, FALSE, qsys, - s.zuser)) - { - ulog (LOG_ERROR, "No permission to send %s", zuse); - if (! ftransfer_fail ('R', FAILURE_PERM)) - return FALSE; - break; - } - - e = esysdep_open_send (qsys, zuse, TRUE, (const char *) NULL, - &s.imode, &cbytes, (boolean *) NULL); - if (! ffileisopen (e)) - { - if (! ftransfer_fail ('R', FAILURE_OPEN)) - return FALSE; - break; - } - - /* If the file is larger than the amount of space - the other side reported, we can't send it. */ - if (cbytes != -1 - && ((s.cbytes != -1 && s.cbytes < cbytes) - || (cremote_size != -1 && cremote_size < cbytes) - || (cmax_receive != -1 && cmax_receive < cbytes))) - { - ulog (LOG_ERROR, "%s is too large to send", zuse); - if (! ftransfer_fail ('R', FAILURE_SIZE)) - return FALSE; - (void) ffileclose (e); - break; - } - - ulog (LOG_NORMAL, "Sending %s", zuse); - - /* Pass in the real size of the file. */ - s.cbytes = cbytes; - - if (! fsend_file (FALSE, e, &s, (const char *) NULL, - qsys->zname, fnew)) - return FALSE; - - break; - - case 'X': - /* This is an execution request. We are being asked to - send one or more files to a destination on either the - local or a remote system. We do this by spooling up - commands for the destination system. */ - ulog (LOG_NORMAL, "Work requested: %s to %s", s.zfrom, - s.zto); - - if (fdo_xcmd (qsys, fcaller, &s)) - { - if (! fxcmd_confirm ()) - return FALSE; - } - else - { - if (! ftransfer_fail ('X', FAILURE_PERM)) - return FALSE; - } - - break; - - case 'H': - /* The master wants to hang up. If we have something to - do, become the master. Otherwise, agree to hang up. - We recheck the grades allowed at this time, since a - lot of time may have passed. */ - if (fcaller) - bgrade = btimegrade (qsys->ztime); - if (bgrade != '\0' - && fsysdep_has_work (qsys, &bhave_grade) - && igradecmp (bgrade, bhave_grade) >= 0) - { - if (fmasterdone) - { - if (! fsysdep_get_work_init (qsys, bgrade)) - return FALSE; - fnowork = FALSE; - } - - fmasterdone = FALSE; - - if (! fhangup_reply (FALSE)) - return FALSE; - fmaster = TRUE; - - /* Recalculate the maximum sizes we can send, since - the time might have changed significantly. */ - clocal_size = cmax_size_now (zlocal_size); - cremote_size = cmax_size_now (zremote_size); - - /* Close the log file at every switch of master and - slave. */ - ulog_close (); - ustats_close (); - } - else - { - /* The hangup_reply function will shut down the - protocol. */ - return fhangup_reply (TRUE); - } - break; - - case 'Y': - /* This is returned when a hangup has been confirmed and - the protocol has been shut down. */ - return TRUE; - - default: - ulog (LOG_ERROR, "Unknown command %c", s.bcmd); - break; - } - } - } -} - -/* Do an 'X' request for another system. The other system has - basically requested us to execute a uucp command for them. */ - -static boolean -fdo_xcmd (qsys, fcaller, q) - const struct ssysteminfo *qsys; - boolean fcaller; - const struct scmd *q; -{ - const char *zexclam; - const char *zdestfile; - char *zcopy; - struct ssysteminfo sdestsys; - const struct ssysteminfo *qdestsys; - char *zuser = NULL; - char aboptions[5]; - char *zoptions = NULL; - boolean fmkdirs; - const char *zfile; - - zexclam = strchr (q->zto, '!'); - if (zexclam == NULL - || zexclam == q->zto - || strncmp (zLocalname, q->zto, zexclam - q->zto) == 0) - { - /* The files are supposed to be copied to the - local system. */ - qdestsys = NULL; - if (zexclam == NULL) - zdestfile = q->zto; - else - zdestfile = zexclam + 1; - } - else - { - int clen; - - clen = zexclam - q->zto; - zcopy = (char *) alloca (clen + 1); - strncpy (zcopy, q->zto, clen); - zcopy[clen] = '\0'; - - if (! fread_system_info (zcopy, &sdestsys)) - { - if (! fUnknown_ok) - { - ulog (LOG_ERROR, "Destination system %s unknown", - zcopy); - return FALSE; - } - sdestsys = sUnknown; - sdestsys.zname = zcopy; - } - qdestsys = &sdestsys; - zdestfile = zexclam + 1; - } - - if (qdestsys != NULL) - { - zuser = (char *) alloca (strlen (qdestsys->zname) - + strlen (q->zuser) + sizeof "!"); - sprintf (zuser, "%s!%s", qdestsys->zname, - q->zuser); - zoptions = aboptions; - *zoptions++ = 'C'; - if (strchr (q->zoptions, 'd') != NULL) - *zoptions++ = 'd'; - if (strchr (q->zoptions, 'm') != NULL) - *zoptions++ = 'm'; - *zoptions = '\0'; - fmkdirs = TRUE; - } - else - fmkdirs = strchr (q->zoptions, 'f') != NULL; - - /* Now we have to process each source file. The - source specification may or may use wildcards. */ - if (! fsysdep_wildcard_start (qsys, q->zfrom)) - return FALSE; - - while ((zfile = zsysdep_wildcard (qsys, q->zfrom)) != NULL) - { - const char *zsend; - const char *zto; - char abtname[CFILE_NAME_LEN]; - - zcopy = (char *) alloca (strlen (zfile) + 1); - strcpy (zcopy, zfile); - zfile = zcopy; - - /* Make sure the remote system is permitted to read the - specified file. */ - zsend = qsys->zremote_send; - if (! fcaller && qsys->zcalled_remote_send != NULL) - zsend = qsys->zcalled_remote_send; - - if (! fin_directory_list (qsys, zfile, zsend, TRUE, TRUE, - (const char *) NULL)) - { - ulog (LOG_ERROR, "Not permitted to send %s", zfile); - (void) fsysdep_wildcard_end (); - return FALSE; - } - - if (qdestsys != NULL) - { - /* We really should get the original grade here. */ - zto = zsysdep_data_file_name (qdestsys, BDEFAULT_UUCP_GRADE, - abtname, (char *) NULL, - (char *) NULL); - } - else - { - const char *zrec; - - zto = zsysdep_real_file_name (qsys, zexclam + 1, zfile); - if (zto == NULL) - { - (void) fsysdep_wildcard_end (); - return FALSE; - } - /* We only accept a local destination if the remote system - has the right to create files there. */ - zrec = qsys->zremote_receive; - if (! fcaller && qsys->zcalled_remote_receive != NULL) - zrec = qsys->zcalled_remote_receive; - - if (! fin_directory_list (qsys, zto, zrec, TRUE, FALSE, - (const char *) NULL)) - { - ulog (LOG_ERROR, "Not permitted to receive %s", zto); - (void) fsysdep_wildcard_end (); - return FALSE; - } - } - - /* Copy the file either to the final destination or to the - spool directory. */ - if (! fcopy_file (zfile, zto, qdestsys == NULL, fmkdirs)) - { - (void) fsysdep_wildcard_end (); - return FALSE; - } - - /* If there is a destination system, queue it up. */ - if (qdestsys != NULL) - { - struct scmd ssend; - - ssend.bcmd = 'S'; - ssend.pseq = NULL; - ssend.zfrom = zfile; - ssend.zto = zdestfile; - ssend.zuser = zuser; - ssend.zoptions = aboptions; - ssend.ztemp = abtname; - ssend.imode = isysdep_file_mode (zfile); - if (ssend.imode == 0) - { - (void) fsysdep_wildcard_end (); - return FALSE; - } - ssend.znotify = ""; - ssend.cbytes = -1; - - if (zsysdep_spool_commands (qdestsys, BDEFAULT_UUCP_GRADE, - 1, &ssend) == NULL) - { - (void) fsysdep_wildcard_end (); - return FALSE; - } - } - } - - if (! fsysdep_wildcard_end ()) - return FALSE; - - return TRUE; -} - -/* See whether it's OK to send a file to another system, according to - the permissions recorded for that system. If the file is not in - the spool directory, this also makes sure that the user has - permission to access the file and all its containing directories. - - zfile -- file to send - flocal -- TRUE if the send was requested locally - fcaller -- TRUE if the local system called the other system - fspool -- TRUE if file was copied to spool directory - qsys -- remote system information - zuser -- user who requested the action */ - -static boolean -fok_to_send (zfile, flocal, fcaller, fspool, qsys, zuser) - const char *zfile; - boolean flocal; - boolean fcaller; - boolean fspool; - const struct ssysteminfo *qsys; - const char *zuser; -{ - const char *z; - - if (! frequest_ok (flocal, fcaller, qsys, zuser)) - return FALSE; - - if (flocal) - { - z = qsys->zlocal_send; - if (! fcaller && qsys->zcalled_local_send != NULL) - z = qsys->zcalled_local_send; - } - else - { - z = qsys->zremote_send; - if (! fcaller && qsys->zcalled_remote_send != NULL) - z = qsys->zcalled_remote_send; - } - - /* If fspool is TRUE, we don't want to check file accessibility. If - this was not a local request, we pass a NULL down as the user - name, since zuser has no meaning on this system. */ - return fin_directory_list (qsys, zfile, z, ! fspool, TRUE, - flocal ? zuser : (const char *) NULL); -} - -/* See whether it's OK to receive a file from another system. */ - -/*ARGSUSED*/ -static boolean -fok_to_receive (zto, flocal, fcaller, qsys, zuser) - const char *zto; - boolean flocal; - boolean fcaller; - const struct ssysteminfo *qsys; - const char *zuser; -{ - const char *z; - - if (! frequest_ok (flocal, fcaller, qsys, zuser)) - return FALSE; - - if (flocal) - { - z = qsys->zlocal_receive; - if (! fcaller && qsys->zcalled_local_receive != NULL) - z = qsys->zcalled_local_receive; - } - else - { - z = qsys->zremote_receive; - if (! fcaller && qsys->zcalled_remote_receive != NULL) - z = qsys->zcalled_remote_receive; - } - - return fin_directory_list (qsys, zto, z, TRUE, FALSE, - flocal ? zuser : (const char *) NULL); -} - -/* See whether a request is OK. This depends on which system placed - the call and which system made the request. */ - -/*ARGSUSED*/ -static boolean -frequest_ok (flocal, fcaller, qsys, zuser) - boolean flocal; - boolean fcaller; - const struct ssysteminfo *qsys; - const char *zuser; -{ - if (flocal) - { - if (fcaller) - return qsys->fcall_transfer; - else - return qsys->fcalled_transfer; - } - else - { - if (fcaller) - return qsys->fcall_request; - else - return qsys->fcalled_request; - } -} - -/* Send a string to the other system beginning with a DLE - character and terminated with a null byte. This is only - used when no protocol is in force. */ - -static boolean -fsend_uucp_cmd (z) - const char *z; -{ - char *zalc; - int cwrite; - - cwrite = strlen (z) + 2; - - zalc = (char *) alloca (cwrite); - sprintf (zalc, "\020%s", z); - - return fport_write (zalc, cwrite); -} - -/* Get a UUCP command beginning with a DLE character and ending with a - null byte. This is only used when no protocol is in force. This - implementation has the potential of being seriously slow. It also - doesn't have any real error recovery. The frequired argument is - passed as TRUE if we need the string; we don't care that much if - we're closing down the connection anyhow. */ - -#define CTIMEOUT (120) -#define CSHORTTIMEOUT (10) -#define CINCREMENT (10) - -static const char * -zget_uucp_cmd (frequired) - boolean frequired; -{ - static char *zalc; - static int calc; - int cgot; - long iendtime; - int ctimeout; -#if DEBUG > 1 - int cchars; - int iolddebug; -#endif - - iendtime = isysdep_time ((long *) NULL); - if (frequired) - iendtime += CTIMEOUT; - else - iendtime += CSHORTTIMEOUT; - -#if DEBUG > 1 - cchars = 0; - iolddebug = iDebug; - if (FDEBUGGING (DEBUG_HANDSHAKE)) - { - ulog (LOG_DEBUG_START, "zget_uucp_cmd: Got \""); - iDebug &=~ (DEBUG_INCOMING | DEBUG_PORT); - } -#endif - - cgot = -1; - while ((ctimeout = (int) (iendtime - isysdep_time ((long *) NULL))) > 0) - { - int b; - - b = breceive_char (ctimeout, frequired); - /* Now b == -1 on timeout, -2 on error. */ - if (b < 0) - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_HANDSHAKE)) - { - ulog (LOG_DEBUG_END, "\" (%s)", - b == -1 ? "timeout" : "error"); - iDebug = iolddebug; - } -#endif - if (b == -1 && frequired) - ulog (LOG_ERROR, "Timeout"); - return NULL; - } - - /* Apparently some systems use parity on these strings, so we - strip the parity bit. This may need to be configurable at - some point, although only if system names can have eight bit - characters. */ - if (! isprint (BUCHAR (b))) - b &= 0x7f; - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_HANDSHAKE)) - { - char ab[5]; - - ++cchars; - if (cchars > 60) - { - ulog (LOG_DEBUG_END, "\""); - ulog (LOG_DEBUG_START, "zget_uucp_cmd: Got \""); - cchars = 0; - } - (void) cdebug_char (ab, b); - ulog (LOG_DEBUG_CONTINUE, "%s", ab); - } -#endif - - if (cgot < 0) - { - if (b != '\020') - continue; - cgot = 0; - continue; - } - - /* If we see another DLE, something has gone wrong; continue - as though this were the first one we saw. */ - if (b == '\020') - { - cgot = 0; - continue; - } - - /* Some systems send a trailing \n on the Shere line. As far as - I can tell this line can never contain a \n, so this - modification should be safe enough. */ - if (b == '\r' || b == '\n') - b = '\0'; - - if (cgot >= calc) - { - calc += CINCREMENT; - zalc = (char *) xrealloc ((pointer) zalc, calc); - } - - zalc[cgot] = (char) b; - ++cgot; - - if (b == '\0') - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_HANDSHAKE)) - { - ulog (LOG_DEBUG_END, "\""); - iDebug = iolddebug; - } -#endif - return zalc; - } - } - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_HANDSHAKE)) - { - ulog (LOG_DEBUG_END, "\" (timeout)"); - iDebug = iolddebug; - } -#endif - - if (frequired) - ulog (LOG_ERROR, "Timeout"); - return NULL; -} - -/* Read a sequence of characters up to a newline or carriage return, and - return the line without the line terminating character. */ - -static const char * -zget_typed_line () -{ - static char *zalc; - static int calc; - int cgot; - -#if DEBUG > 1 - int cchars; - int iolddebug; - - cchars = 0; - iolddebug = iDebug; - if (FDEBUGGING (DEBUG_CHAT)) - { - ulog (LOG_DEBUG_START, "zget_typed_line: Got \""); - iDebug &=~ (DEBUG_INCOMING | DEBUG_PORT); - } -#endif - - cgot = 0; - while (TRUE) - { - int b; - - b = breceive_char (CTIMEOUT, FALSE); - - /* Now b == -1 on timeout, -2 on error. */ - - if (b == -2 || FGOT_SIGNAL ()) - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - ulog (LOG_DEBUG_END, "\" (error)"); - iDebug = iolddebug; - } -#endif - return NULL; - } - - if (b == -1) - continue; - -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - char ab[5]; - - ++cchars; - if (cchars > 60) - { - ulog (LOG_DEBUG_END, "\""); - ulog (LOG_DEBUG_START, "zget_typed_line: Got \""); - cchars = 0; - } - (void) cdebug_char (ab, b); - ulog (LOG_DEBUG_CONTINUE, "%s", ab); - } -#endif - - if (cgot >= calc) - { - calc += CINCREMENT; - zalc = (char *) xrealloc ((pointer) zalc, calc); - } - - if (b == '\r' || b == '\n') - b = '\0'; - - zalc[cgot] = (char) b; - ++cgot; - - if (b == '\0') - { -#if DEBUG > 1 - if (FDEBUGGING (DEBUG_CHAT)) - { - ulog (LOG_DEBUG_END, "\""); - iDebug = iolddebug; - } -#endif - return zalc; - } - } -} diff --git a/gnu/libexec/uucp/uucp.1 b/gnu/libexec/uucp/uucp.1 deleted file mode 100644 index 40431801af30..000000000000 --- a/gnu/libexec/uucp/uucp.1 +++ /dev/null @@ -1,183 +0,0 @@ -''' $Id: uucp.1,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ -''' $Log: uucp.1,v $ -''' Revision 1.1.1.1 1993/03/21 09:45:37 cgd -''' initial import of 386bsd-0.1 sources -''' -''' Revision 1.5 1992/04/01 21:11:19 ian -''' Cleaned up a bit, updated -x switch -''' -''' Revision 1.4 1992/03/28 04:34:11 ian -''' David J. MacKenzie: change .TP5 to .TP 5; also updated to 1.03 -''' -''' Revision 1.3 1992/02/29 04:07:08 ian -''' Added -j option to uucp and uux -''' -''' Revision 1.2 1992/01/20 23:52:23 ian -''' Change to version 1.02 -''' -''' Revision 1.1 1991/12/14 19:05:20 ian -''' Initial revision -''' -''' -.TH uucp 1 "Taylor UUCP 1.03" -.SH NAME -uucp \- Unix to Unix copy -.SH SYNOPSIS -.B uucp -[ options ] source-file destination-file -.PP -.B uucp -[ options ] source-file... destination-directory -.SH DESCRIPTION -The -.I uucp -command copies files between systems. Each -.I file -argument is either a pathname on the local machine or is of the form -.IP -system!path -.LP -which is interpreted as being on a remote system. -In the first form, the contents of the first file are copied to the -second. In the second form, each source file is copied into the -destination directory. - -Any pathname that does not begin with / or ~ will be appended to the -current directory; this resulting path may not exist on a remote -system. A pathname beginning with a simple ~ starts at the UUCP -public directory; a pathname beginning with ~name starts at the home -directory of the named user. The ~ is interpreted on the appropriate -system. Note that some shells will interpret a simple ~ to the local -home directory before -.I uucp -sees it; to avoid this the ~ must be quoted. - -Shell metacharacters ? * [ ] are interpreted on the appropriate -system, assuming they are quoted to prevent the shell from -interpreting them first. - -The copy does not take place immediately, but is queued up for the -.I uucico -(8) daemon; the daemon is started immediately unless the -.B \-r -switch is given. In any case, the next time the remote system is called the -file(s) will be copied. -.SH OPTIONS -The following options may be given to -.I uucp. -.TP 5 -.B \-c -Do not copy local source files to the spool directory. If they are -removed before being processed by the -.I uucico -(8) daemon, the copy will fail. The files must be readable by the -.I uucico -(8) daemon, and by the invoking user. -.TP 5 -.B \-C -Copy local source files to the spool directory. This is the default. -.TP 5 -.B \-d -Create all necessary directories when doing the copy. This is the -default. -.TP 5 -.B \-f -If any necessary directories do not exist for the destination path, -abort the copy. -.TP 5 -.B \-g grade -Set the grade of the file transfer command. Jobs of a higher grade -are executed first. Grades run 0 ... 9 A ... Z a ... z from high to -low. -.TP 5 -.B \-m -Report completion or failure of the file transfer by -.I mail -(1). -.TP 5 -.B \-n user -Report completion or failure of the file transfer by -.I mail -(1) to the named -user on the remote system. -.TP 5 -.B \-r -Do not start -.I uucico -(8) daemon immediately; merely queue up the file transfer for later -execution. -.TP 5 -.B \-j -Print jobid on standard output. The job may be -later cancelled by passing the jobid to the -.B \-k -switch of -.I uustat -(1). -It is possible for some complex operations to produce more than one -jobid, in which case each will be printed on a separate line. For -example -.EX -uucp sys1!~user1/file1 sys2!~user2/file2 /usr/spool/uucppublic -.EE -will generate two separate jobs, one for the system -.I sys1 -and one for the system -.I sys2. -.TP 5 -.B \-x type -Turn on particular debugging types. The following types are -recognized: abnormal, chat, handshake, uucp-proto, proto, port, -config, spooldir, execute, incoming, outgoing. Only abnormal, config, -spooldir and execute are meaningful for -.I uucp. - -Multiple types may be given, separated by commas, and the -.B \-x -option may appear multiple times. A number may also be given, which -will turn on that many types from the foregoing list; for example, -.B \-x 2 -is equivalent to -.B \-x abnormal,chat. -.TP 5 -.B \-I file -Set configuration file to use. This option may not be available, -depending upon how -.I uucp -was compiled. -.SH FILES -The file names may be changed at compilation time or by the -configuration file, so these are only approximations. - -.br -/usr/lib/uucp/config - Configuration file. -.br -/usr/spool/uucp - -UUCP spool directory. -.br -/usr/spool/uucp/Log - -UUCP log file. -.br -/usr/spool/uucppublic - -Default UUCP public directory. -.SH SEE ALSO -mail(1), uux(1), uustat(1), uucico(8) -.SH BUGS -Files can not be copied across multiple systems. - -Some of the options are dependent on the capabilities of the -.I uucico -(8) daemon on the remote system. - -The -.I \-n -and -.I \-m -switches do not work when transferring a file from one remote system -to another. - -File modes are not preserved, except for the execute bit. The -resulting file is owned by the uucp user. -.SH AUTHOR -Ian Lance Taylor -(ian@airs.com or uunet!airs!ian) diff --git a/gnu/libexec/uucp/uucp.c b/gnu/libexec/uucp/uucp.c deleted file mode 100644 index efee28de102c..000000000000 --- a/gnu/libexec/uucp/uucp.c +++ /dev/null @@ -1,809 +0,0 @@ -/* uucp.c - Prepare to copy a file to or from a remote system. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: uucp.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.25 1992/03/15 04:51:17 ian - Keep an array of signals we've received rather than a single variable - - Revision 1.24 1992/03/12 21:55:09 ian - Use fake local name when generating an execution request - - Revision 1.23 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.22 1992/02/29 04:07:08 ian - Added -j option to uucp and uux - - Revision 1.21 1992/02/29 01:06:59 ian - Chip Salzenberg: recheck file permissions before sending - - Revision 1.20 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.19 1992/02/24 04:58:47 ian - Only permit files to be received into directories that are world-writeable - - Revision 1.18 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.17 1992/02/14 05:17:09 ian - Niels Baggesen: have to copy abtname into memory - - Revision 1.16 1992/02/08 22:33:32 ian - Only get the current working directory if it's going to be needed - - Revision 1.15 1992/02/08 20:33:57 ian - Handle all possible signals raised by abort - - Revision 1.14 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.13 1992/02/02 20:56:25 ian - Do local copy to zsysdep_real_file_name, not zsysdep_in_dir - - Revision 1.12 1992/02/02 20:34:36 ian - Niels Baggesen: must check user permissions on access to local files - - Revision 1.11 1992/01/21 19:39:12 ian - Chip Salzenberg: uucp and uux start uucico for right system, not any - - Revision 1.10 1992/01/15 07:06:29 ian - Set configuration directory in Makefile rather than sysdep.h - - Revision 1.9 1992/01/05 03:09:17 ian - Changed abProgram and abVersion to non const to avoid compiler bug - - Revision 1.8 1991/12/21 21:09:01 ian - Use ulog to report illegal grade error message - - Revision 1.7 1991/12/18 03:54:14 ian - Made error messages to terminal appear more normal - - Revision 1.6 1991/12/11 03:59:19 ian - Create directories when necessary; don't just assume they exist - - Revision 1.5 1991/11/21 22:17:06 ian - Add version string, print version when printing usage - - Revision 1.4 1991/11/13 23:08:40 ian - Expand remote pathnames in uucp and uux; fix up uux special cases - - Revision 1.3 1991/09/19 02:30:37 ian - From Chip Salzenberg: check whether signal is ignored differently - - Revision 1.2 1991/09/11 02:33:14 ian - Added ffork argument to fsysdep_run - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char uucp_rcsid[] = "$Id: uucp.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#include "getopt.h" - -#include "system.h" -#include "sysdep.h" - -/* The program name. */ -char abProgram[] = "uucp"; - -/* Long getopt options. */ - -static const struct option asClongopts[] = { { NULL, 0, NULL, 0 } }; - -const struct option *_getopt_long_options = asClongopts; - -/* Local functions. */ - -static void ucusage P((void)); -static void ucadd_cmd P((const struct ssysteminfo *qsys, - const struct scmd *qcmd)); -static void ucspool_cmds P((int bgrade, boolean fjobid)); -static const char *zcone_system P((boolean *pfany)); -static void ucrecord_file P((const char *zfile)); -static void ucabort P((void)); - -int -main (argc, argv) - int argc; - char **argv; -{ - int iopt; - /* -c,-C: if true, copy to spool directory. */ - boolean fcopy = TRUE; - /* -d,-f: if true, create directories if they don't exist. */ - boolean fmkdirs = TRUE; - /* -g: job grade. */ - char bgrade = BDEFAULT_UUCP_GRADE; - /* -I: configuration file name. */ - const char *zconfig = NULL; - /* -j: output job id. */ - boolean fjobid = FALSE; - /* -m: mail to requesting user. */ - boolean fmail = FALSE; - /* -n: notify remote user. */ - const char *znotify = ""; - /* -r: don't start uucico when finished. */ - boolean fuucico = TRUE; - /* -s: report status to named file. */ - const char *zstatus_file = NULL; - /* -W: expand local file names only. */ - boolean fexpand = TRUE; - int i; - boolean fgetcwd; - char *zexclam; - char *zdestfile; - const char *zconst; - struct ssysteminfo sdestsys; - const struct ssysteminfo *qdestsys; - boolean flocaldest; - const char *zuser; - char absend_options[5]; - char abrec_options[3]; - char *zoptions; - boolean fexit; - - while ((iopt = getopt (argc, argv, "cCdfg:I:jmn:rs:Wx:")) != EOF) - { - switch (iopt) - { - case 'c': - /* Do not copy local files to spool directory. */ - fcopy = FALSE; - break; - - case 'C': - /* Copy local files to spool directory. */ - fcopy = TRUE; - break; - - case 'd': - /* Create directories if necessary. */ - fmkdirs = TRUE; - break; - - case 'f': - /* Do not create directories if they don't exist. */ - fmkdirs = FALSE; - break; - - case 'g': - /* Set job grade. */ - bgrade = optarg[0]; - break; - - case 'I': - /* Name configuration file. */ - zconfig = optarg; - break; - - case 'j': - /* Output job id. */ - fjobid = TRUE; - break; - - case 'm': - /* Mail to requesting user. */ - fmail = TRUE; - break; - - case 'n': - /* Notify remote user. */ - znotify = optarg; - break; - - case 'r': - /* Don't start uucico when finished. */ - fuucico = FALSE; - break; - - case 's': - /* Report status to named file. */ - zstatus_file = optarg; - break; - - case 'W': - /* Expand only local file names. */ - fexpand = FALSE; - break; - - case 'x': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 0: - /* Long option found and flag set. */ - break; - - default: - ucusage (); - break; - } - } - - if (! FGRADE_LEGAL (bgrade)) - { - /* We use LOG_NORMAL rather than LOG_ERROR because this is going - to stderr rather than to the log file, and we don't need the - ERROR header string. */ - ulog (LOG_NORMAL, "Ignoring illegal grade"); - bgrade = BDEFAULT_UUCP_GRADE; - } - - if (argc - optind < 2) - ucusage (); - - uread_config (zconfig); - - /* See if we are going to need to know the current directory. We - just check each argument to see whether it's an absolute - pathname. We actually aren't going to need the cwd if fexpand is - FALSE and the file is remote, but so what. */ - fgetcwd = FALSE; - for (i = optind; i < argc; i++) - { - zexclam = strrchr (argv[i], '!'); - if (zexclam == NULL) - zexclam = argv[i]; - else - ++zexclam; - if (fsysdep_needs_cwd (zexclam)) - { - fgetcwd = TRUE; - break; - } - } - -#ifdef SIGINT - usysdep_signal (SIGINT); -#endif -#ifdef SIGHUP - usysdep_signal (SIGHUP); -#endif -#ifdef SIGQUIT - usysdep_signal (SIGQUIT); -#endif -#ifdef SIGTERM - usysdep_signal (SIGTERM); -#endif -#ifdef SIGPIPE - usysdep_signal (SIGPIPE); -#endif - - usysdep_initialize (FALSE, fgetcwd); - - ulog_fatal_fn (ucabort); - - zuser = zsysdep_login_name (); - - /* Set up the options. */ - - zoptions = absend_options; - if (fcopy) - *zoptions++ = 'C'; - else - *zoptions++ = 'c'; - if (fmkdirs) - *zoptions++ = 'd'; - else - *zoptions++ = 'f'; - if (fmail) - *zoptions++ = 'm'; - if (*znotify != '\0') - *zoptions++ = 'n'; - *zoptions = '\0'; - - zoptions = abrec_options; - if (fmkdirs) - *zoptions++ = 'd'; - else - *zoptions++ = 'f'; - if (fmail) - *zoptions++ = 'm'; - *zoptions = '\0'; - - zexclam = strchr (argv[argc - 1], '!'); - if (zexclam == NULL) - { - zdestfile = argv[argc - 1]; - qdestsys = &sLocalsys; - flocaldest = TRUE; - } - else - { - int clen; - char *zcopy; - - clen = zexclam - argv[argc - 1]; - zcopy = (char *) alloca (clen + 1); - strncpy (zcopy, argv[argc - 1], clen); - zcopy[clen] = '\0'; - - zdestfile = zexclam + 1; - - if (*zcopy == '\0' || strcmp (zcopy, zLocalname) == 0) - { - qdestsys = &sLocalsys; - flocaldest = TRUE; - } - else - { - if (fread_system_info (zcopy, &sdestsys)) - qdestsys = &sdestsys; - else - { - if (! fUnknown_ok) - ulog (LOG_FATAL, "System %s unknown", zcopy); - qdestsys = &sUnknown; - sUnknown.zname = zcopy; - } - - flocaldest = FALSE; - - if (! fsysdep_make_spool_dir (qdestsys)) - { - ulog_close (); - usysdep_exit (FALSE); - } - } - } - - /* If the destination file is not an absolute path, expand it - with the current directory. */ - if (fexpand || flocaldest) - { - zconst = zsysdep_add_cwd (zdestfile, flocaldest); - if (zconst == NULL) - { - ulog_close (); - usysdep_exit (FALSE); - } - zdestfile = xstrdup (zconst); - } - - /* Check that we have permission to receive into the desired - directory. If we don't have permission, uucico will fail. */ - - if (flocaldest) - { - if (! fin_directory_list (&sLocalsys, zdestfile, - sLocalsys.zlocal_receive, - TRUE, FALSE, zuser)) - ulog (LOG_FATAL, "Not permitted to receive to %s", zdestfile); - } - - /* Process each file. */ - - for (i = optind; i < argc - 1 && ! FGOT_SIGNAL (); i++) - { - struct scmd s; - - zexclam = strchr (argv[i], '!'); - - if (zexclam == NULL) - { - char *zfrom; - - /* This is a local file. Make sure we get it out of the - original directory. We don't support local wildcards - yet (if ever). */ - zconst = zsysdep_add_cwd (argv[i], TRUE); - if (zconst == NULL) - ucabort (); - zfrom = xstrdup (zconst); - - /* Make sure the user has access to this file, since we are - running setuid. */ - if (! fsysdep_access (zfrom)) - ucabort (); - - if (flocaldest) - { - char *zto; - - /* Copy one local file to another. */ - - zconst = zsysdep_real_file_name (&sLocalsys, zdestfile, - argv[i]); - if (zconst == NULL) - ucabort (); - zto = xstrdup (zconst); - - if (! fcopy_file (zfrom, zto, FALSE, fmkdirs)) - ucabort (); - - xfree ((pointer) zto); - } - else - { - char abtname[CFILE_NAME_LEN]; - unsigned int imode; - - /* Copy a local file to a remote file. We may have to - copy the local file to the spool directory. */ - - imode = isysdep_file_mode (zfrom); - if (imode == 0) - ucabort (); - - if (! fcopy) - { - /* Make sure the daemon will be permitted to send - this file. */ - if (! fsysdep_daemon_access (zfrom)) - ucabort (); - if (! fin_directory_list (&sLocalsys, zfrom, - sLocalsys.zlocal_send, - TRUE, TRUE, zuser)) - ulog (LOG_FATAL, "Not permitted to send from %s", - zfrom); - strcpy (abtname, "D.0"); - } - else - { - char *zdata; - - zconst = zsysdep_data_file_name (qdestsys, bgrade, - abtname, (char *) NULL, - (char *) NULL); - if (zconst == NULL) - ucabort (); - zdata = xstrdup (zconst); - - ucrecord_file (zdata); - if (! fcopy_file (zfrom, zdata, FALSE, TRUE)) - ucabort (); - xfree ((pointer) zdata); - } - - s.bcmd = 'S'; - s.pseq = NULL; - s.zfrom = zfrom; - s.zto = zdestfile; - s.zuser = zuser; - s.zoptions = absend_options; - s.ztemp = xstrdup (abtname); - s.imode = imode; - s.znotify = znotify; - s.cbytes = -1; - - ucadd_cmd (qdestsys, &s); - } - } - else - { - int clen; - char *zcopy; - struct ssysteminfo *qfromsys; - - /* Add the current directory to the filename if it's not - already there. */ - if (fexpand) - { - zconst = zsysdep_add_cwd (zexclam + 1, FALSE); - if (zconst == NULL) - ucabort (); - zconst = xstrdup (zconst); - } - else - zconst = zexclam + 1; - - /* Read the system information. */ - clen = zexclam - argv[i]; - zcopy = (char *) xmalloc (clen + 1); - strncpy (zcopy, argv[i], clen); - zcopy[clen] = '\0'; - - qfromsys = ((struct ssysteminfo *) - xmalloc (sizeof (struct ssysteminfo))); - if (fread_system_info (zcopy, qfromsys)) - xfree ((pointer) zcopy); - else - { - *qfromsys = sUnknown; - qfromsys->zname = zcopy; - } - - if (! fsysdep_make_spool_dir (qfromsys)) - ucabort (); - - if (flocaldest) - { - char *zto; - - /* Fetch a file from a remote system. If the remote - filespec is wildcarded, we must generate an 'X' - request. We currently check for Unix shell - wildcards. Note that it should do no harm to mistake - a non-wildcard for a wildcard. */ - - if (strchr (zconst, '*') != NULL - || strchr (zconst, '?') != NULL - || strchr (zconst, '[') != NULL) - { - const char *zuse; - - if (qfromsys->zlocalname != NULL) - zuse = qfromsys->zlocalname; - else - zuse = zLocalname; - - s.bcmd = 'X'; - zto = (char *) alloca (strlen (zuse) - + strlen (zdestfile) - + sizeof "!"); - sprintf (zto, "%s!%s", zuse, zdestfile); - zto = xstrdup (zto); - } - else - { - s.bcmd = 'R'; - zto = zdestfile; - } - s.pseq = NULL; - s.zfrom = zconst; - s.zto = zto; - s.zuser = zuser; - s.zoptions = abrec_options; - s.ztemp = ""; - s.imode = 0; - s.znotify = ""; - s.cbytes = -1; - - ucadd_cmd (qfromsys, &s); - } - else - { - /* Move a file from one remote system to another. */ - - s.bcmd = 'X'; - s.pseq = NULL; - s.zfrom = zconst; - s.zto = argv[argc - 1]; - s.zuser = zuser; - s.zoptions = abrec_options; - s.ztemp = ""; - s.imode = 0; - s.znotify = ""; - s.cbytes = -1; - - ucadd_cmd (qfromsys, &s); - } - } - } - - /* See if we got an interrupt, presumably from the user. */ - if (FGOT_SIGNAL ()) - ucabort (); - - /* Now push out the actual commands, making log entries for them. */ - ulog_to_file (TRUE); - ulog_user (zuser); - - ucspool_cmds (bgrade, fjobid); - - ulog_close (); - - if (! fuucico) - fexit = TRUE; - else - { - const char *zsys; - boolean fany; - - zsys = zcone_system (&fany); - if (zsys != NULL) - fexit = fsysdep_run (TRUE, "uucico", "-s", zsys); - else if (fany) - fexit = fsysdep_run (TRUE, "uucico", "-r1", (const char *) NULL); - else - fexit = TRUE; - } - - usysdep_exit (fexit); - - /* Avoid error about not returning. */ - return 0; -} - -static void -ucusage () -{ - fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", - abVersion); - fprintf (stderr, - "Usage: uucp [options] file1 [file2 ...] dest\n"); - fprintf (stderr, - " -c: Do not copy local files to spool directory\n"); - fprintf (stderr, - " -C: Copy local files to spool directory (default)\n"); - fprintf (stderr, - " -d: Create necessary directories (default)\n"); - fprintf (stderr, - " -f: Do not create directories (fail if they do not exist)\n"); - fprintf (stderr, - " -g grade: Set job grade (must be alphabetic)\n"); - fprintf (stderr, - " -m: Report status of copy by mail\n"); - fprintf (stderr, - " -n user: Report status of copy by mail to remote user\n"); - fprintf (stderr, - " -r: Do not start uucico daemon\n"); - fprintf (stderr, - " -s file: Report completion status to file\n"); - fprintf (stderr, - " -j: Report job id\n"); - fprintf (stderr, - " -x debug: Set debugging level\n"); -#if HAVE_TAYLOR_CONFIG - fprintf (stderr, - " -I file: Set configuration file to use (default %s%s)\n", - NEWCONFIGLIB, CONFIGFILE); -#endif /* HAVE_TAYLOR_CONFIG */ - exit (EXIT_FAILURE); -} - -/* We keep a list of jobs for each system. */ - -struct sjob -{ - struct sjob *qnext; - const struct ssysteminfo *qsys; - int ccmds; - struct scmd *pascmds; -}; - -static struct sjob *qCjobs; - -static void -ucadd_cmd (qsys, qcmd) - const struct ssysteminfo *qsys; - const struct scmd *qcmd; -{ - struct sjob *qjob; - - for (qjob = qCjobs; qjob != NULL; qjob = qjob->qnext) - if (strcmp (qjob->qsys->zname, qsys->zname) == 0) - break; - - if (qjob == NULL) - { - qjob = (struct sjob *) xmalloc (sizeof (struct sjob)); - qjob->qnext = qCjobs; - qjob->qsys = qsys; - qjob->ccmds = 0; - qjob->pascmds = NULL; - qCjobs = qjob; - } - - qjob->pascmds = ((struct scmd *) - xrealloc ((pointer) qjob->pascmds, - (qjob->ccmds + 1) * sizeof (struct scmd))); - qjob->pascmds[qjob->ccmds] = *qcmd; - ++qjob->ccmds; -} - -static void -ucspool_cmds (bgrade, fjobid) - int bgrade; - boolean fjobid; -{ - struct sjob *qjob; - const char *zjobid; - - for (qjob = qCjobs; qjob != NULL; qjob = qjob->qnext) - { - ulog_system (qjob->qsys->zname); - zjobid = zsysdep_spool_commands (qjob->qsys, bgrade, qjob->ccmds, - qjob->pascmds); - if (zjobid != NULL) - { - int i; - struct scmd *qcmd; - - for (i = 0, qcmd = qjob->pascmds; i < qjob->ccmds; i++, qcmd++) - { - if (qcmd->bcmd == 'S') - ulog (LOG_NORMAL, "Queuing send of %s to %s", - qcmd->zfrom, qcmd->zto); - else if (qcmd->bcmd == 'R') - ulog (LOG_NORMAL, "Queuing request of %s to %s", - qcmd->zfrom, qcmd->zto); - else - ulog (LOG_NORMAL, "Queuing execution (%s to %s)", - qcmd->zfrom, qcmd->zto); - } - - if (fjobid) - printf ("%s\n", zjobid); - } - } -} - -/* Return the system name for which we have created commands, or NULL - if we've created commands for more than one system. Set *pfany to - FALSE if we didn't create work for any system. */ - -static const char * -zcone_system (pfany) - boolean *pfany; -{ - if (qCjobs == NULL) - { - *pfany = FALSE; - return NULL; - } - - *pfany = TRUE; - - if (qCjobs->qnext == NULL) - return qCjobs->qsys->zname; - else - return NULL; -} - -/* Keep track of all files we have created so that we can delete them - if we get a signal. The argument will be on the heap. */ - -static int ccfiles; -static const char **pcaz; - -static void -ucrecord_file (zfile) - const char *zfile; -{ - pcaz = (const char **) xrealloc ((pointer) pcaz, - (ccfiles + 1) * sizeof (const char *)); - pcaz[ccfiles] = zfile; - ++ccfiles; -} - -/* Delete all the files we have recorded and exit. */ - -static void -ucabort () -{ - int i; - - for (i = 0; i < ccfiles; i++) - (void) remove (pcaz[i]); - ulog_close (); - usysdep_exit (FALSE); -} diff --git a/gnu/libexec/uucp/uucp.h b/gnu/libexec/uucp/uucp.h deleted file mode 100644 index 052995591f7c..000000000000 --- a/gnu/libexec/uucp/uucp.h +++ /dev/null @@ -1,1208 +0,0 @@ -/* uucp.h - Header file for the UUCP package. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Id: uucp.h,v 1.2 1993/08/02 17:25:15 mycroft Exp $ -*/ - -/* Get the system configuration parameters. */ - -#include "conf.h" -#include "policy.h" - -/* We always want . */ - -#include - -/* We need for sig_atomic_t. */ - -#include - -/* On some systems that won't get us sig_atomic_t. */ - -#if ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H -#if HAVE_SIG_ATOMIC_T_IN_TYPES_H -#include -#else /* ! HAVE_SIG_ATOMIC_T_IN_TYPES_H */ -#ifndef sig_atomic_t -/* There is no portable definition for sig_atomic_t. */ -#define sig_atomic_t char -#endif /* ! defined (sig_atomic_t) */ -#endif /* ! HAVE_SIG_ATOMIC_T_IN_TYPES_H */ -#endif /* ! HAVE_SIG_ATOMIC_T_IN_SIGNAL_H */ - -/* Get a definition for ANSI_C if we weren't given one. */ - -#ifndef ANSI_C -#ifdef __STDC__ -#define ANSI_C 1 -#else /* ! defined (__STDC__) */ -#define ANSI_C 0 -#endif /* ! defined (__STDC__) */ -#endif /* ! defined (ANSI_C) */ - -/* Set up some definitions for both ANSI C and Classic C. - - P() is used for function prototypes (e.g. extern int foo P((int)) ). - pointer is used for a generic pointer (i.e. void *). - constpointer is used for a generic pointer to constant data. - BUCHAR is used to convert a character to unsigned. */ - -#if ANSI_C -#if ! HAVE_VOID || ! HAVE_UNSIGNED_CHAR - #error ANSI C compiler without void or unsigned char -#endif -#define P(x) x -typedef void *pointer; -typedef const void *constpointer; -#define BUCHAR(b) ((unsigned char) (b)) -#else /* ! ANSI_C */ -/* Handle uses of const, volatile and void in Classic C. */ -#define const -#define volatile -#if ! HAVE_VOID -#define void int -#endif -#define P(x) () -typedef char *pointer; -typedef const char *constpointer; -#if HAVE_UNSIGNED_CHAR -#define BUCHAR(b) ((unsigned char) (b)) -#else /* ! HAVE_UNSIGNED_CHAR */ -/* This should work on most systems, but not necessarily all. */ -#define BUCHAR(b) ((b) & 0xff) -#endif /* ! HAVE_UNSIGNED_CHAR */ -#endif /* ! ANSI_C */ - -/* Only use inline with gcc. */ - -#ifndef __GNUC__ -#define __inline__ -#endif - -/* Get the string functions, which are used throughout the code. */ - -#if HAVE_MEMORY_H -#include -#else -/* We really need a definition for memchr, and this should not - conflict with anything in . I hope. */ -extern pointer memchr (); -#endif - -#if HAVE_STRING_H -#include -#else /* ! HAVE_STRING_H */ -#if HAVE_STRINGS_H -#include -#else /* ! HAVE_STRINGS_H */ -extern int strcmp (), strncmp (); -extern char *strcpy (), *strncpy (), *strchr (), *strrchr (), *strtok (); -extern char *strcat (), *strerror (), *strstr (); -/* These should be size_t, but there's no declaration to conflict with. */ -extern int strlen (), strspn (), strcspn (); -#if ! HAVE_MEMORY_H -extern pointer memcpy (), memmove (), memchr (); -extern int memcmp (); -#endif /* ! HAVE_MEMORY_H */ -#endif /* ! HAVE_STRINGS_H */ -#endif /* ! HAVE_STRING_H */ - -/* Get what we need from . */ - -#if HAVE_STDLIB_H -#include -#else /* ! HAVE_STDLIB_H */ -extern pointer malloc (), realloc (), bsearch (); -extern void free (), exit (), perror (), abort (), qsort (); -extern long atol (), strtol (); -extern int atoi (); -extern char *getenv (); -#endif /* ! HAVE_STDLIB_H */ - -/* Define alloca as suggested by David MacKenzie. AIX requires this - to be the first thing in the file. I really hate system dependent - cruft like this (and this is the only case in which it appears), - but I guess that's the price of using alloca. */ -#define HAVE_ALLOCA 1 -#ifdef __GNUC__ -#ifndef __NeXT__ -#define alloca __builtin_alloca -#endif /* ! defined (__NeXT__) */ -#else /* ! defined(__GNUC__) */ -#ifdef sparc -#include -#else /* ! defined (sparc) */ -#ifdef _AIX - #pragma alloca -#else /* ! defined (_AIX) */ -/* We may not be using a real alloca. */ -#undef HAVE_ALLOCA -#define HAVE_ALLOCA 0 -#endif /* ! defined (_AIX) */ -#endif /* ! defined (sparc) */ -#endif /* ! defined (__GNUC__) */ - -/* NeXT uses to declare a bunch of functions. */ -#if HAVE_LIBC_H -#include -#endif - -/* Make sure we have the EXIT_ macros (some versions of SunOS have - but left them out). */ -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS (0) -#endif -#ifndef EXIT_FAILURE -#define EXIT_FAILURE (1) -#endif - -/* If we need to declare errno, do so. I don't want to always do - this, because some system might theoretically have a different - declaration for errno. On a POSIX system this is sure to work. */ -#if ! HAVE_ERRNO_DECLARATION -extern int errno; -#endif - -/* If the system has the socket call, guess that we can compile the - TCP code. */ -#define HAVE_TCP HAVE_SOCKET - -/* The boolean type holds boolean values. */ - -typedef int boolean; - -#undef TRUE -#undef FALSE -#define TRUE (1) -#define FALSE (0) - -/* The openfile_t type holds an open file. This depends on whether we - are using stdio or not. */ - -#if USE_STDIO - -typedef FILE *openfile_t; -#define EFILECLOSED ((FILE *) NULL) -#define ffileisopen(e) ((e) != NULL) -#define ffileeof(e) feof (e) -#define cfileread(e, z, c) fread ((z), 1, (c), (e)) -#define ffilereaderror(e, c) ferror (e) -#define cfilewrite(e, z, c) fwrite ((z), 1, (c), (e)) -#ifdef SEEK_SET -#define ffilerewind(e) (fseek (e, (long) 0, SEEK_SET) == 0) -#else -#define ffilerewind(e) (fseek (e, (long) 0, 0) == 0) -#endif -#define ffileclose(e) (fclose (e) == 0) - -extern int fclose (), fseek (); -/* The ferror and feof functions are often macros, so we can't safely - define them. The fread and fwrite functions may return int or may - return size_t, so we can't safely define them. */ - -#else /* ! USE_STDIO */ - -#if HAVE_UNISTD_H -#include -#endif - -/* It would be nice to provide prototypes for read, write and lseek, but - we can't because they might not return int. */ -extern int close (); - -typedef int openfile_t; -#define EFILECLOSED (-1) -#define ffileisopen(e) ((e) >= 0) -#define ffileeof(e) (FALSE) -#define cfileread(e, z, c) read ((e), (z), (c)) -#define ffilereaderror(e, c) ((c) < 0) -#define cfilewrite(e, z, c) write ((e), (z), (c)) -#ifdef SEEK_SET -#define ffilerewind(e) (lseek (e, (long) 0, SEEK_SET) >= 0) -#else -#define ffilerewind(e) (lseek (e, (long) 0, 0) >= 0) -#endif -#define ffileclose(e) (close (e) >= 0) - -extern int read (), write (), close (); -/* The lseek function should return off_t, but we don't want to - include sysdep.h here. */ - -#endif /* ! USE_STDIO */ - -/* Define the time_t type. This still won't help if they don't have - time or ctime. */ - -#if ! HAVE_TIME_T && ! HAVE_SYS_TIME_T -typedef long time_t; -#endif - -/* The types of entries allowed in a command table (struct scmdtab). - If CMDTABTYPE_FN is used, it should be or'ed with the number of - arguments permitted, or 0 if there is no single number. - CMDTABTYPE_PREFIX means that the string in the scmdtab table is a - prefix; any command which matches the prefix should be used to call - a function. The number of arguments should be or'ed in as with - CMDTABTYPE_FN. */ - -#define CMDTABTYPE_BOOLEAN (0x12) -#define CMDTABTYPE_INT (0x22) -#define CMDTABTYPE_LONG (0x32) -#define CMDTABTYPE_STRING (0x40) -#define CMDTABTYPE_FULLSTRING (0x50) -#define CMDTABTYPE_FN (0x60) -#define CMDTABTYPE_PREFIX (0x70) - -#define TTYPE_CMDTABTYPE(i) ((i) & 0x70) -#define CARGS_CMDTABTYPE(i) ((i) & 0x0f) - -/* These flags are or'red together to form an argument to - uprocesscmds. */ -#define CMDFLAG_WARNUNRECOG (0x1) -#define CMDFLAG_CASESIGNIFICANT (0x2) -#define CMDFLAG_BACKSLASH (0x4) - -/* The enumeration returned by functions called by uprocesscmds. */ - -enum tcmdtabret -{ - CMDTABRET_CONTINUE, - CMDTABRET_FREE, - CMDTABRET_EXIT, - CMDTABRET_FREE_AND_EXIT -}; - -/* This structure holds the argument to uprocesscmds. */ - -struct scmdtab -{ - /* Command name. */ - const char *zcmd; - /* Command type (one of CMDTABTYPE_...). */ - int itype; - /* This is the address of the variable if not CMDTABTYPE_FN. */ - pointer pvar; - /* This is used if CMDTABTYPE_FN. */ - enum tcmdtabret (*ptfn) P((int argc, char **argv, pointer par, - const char *zerr)); -}; - -/* This structure holds the information we need for a chat script. */ - -struct schat_info -{ - /* The script itself, if any. */ - char *zchat; - /* The program to run, if any. */ - char *zprogram; - /* The timeout for the chat script. */ - int ctimeout; - /* The list of failure strings. */ - char *zfail; - /* Whether to strip incoming characters to seven bits. */ - boolean fstrip; -}; - -/* This macro is used to initialize the entries of an schat_info - structure to the correct default values. */ - -#define INIT_CHAT(q) \ - ((q)->zchat = NULL, \ - (q)->zprogram = NULL, \ - (q)->ctimeout = 60, \ - (q)->zfail = NULL, \ - (q)->fstrip = TRUE) - -/* This structure holds a set of special commands executed for - particular protocols. */ - -struct sproto_param -{ - /* Protocol. */ - char bproto; - /* Number of entries. */ - int centries; - /* Specific entries. */ - struct sproto_param_entry - { - int cargs; - char **azargs; - } *qentries; -}; - -/* The ssysteminfo structure holds information about a remote system. */ - -struct ssysteminfo -{ - /* System name. */ - const char *zname; - /* List of aliases separated by ' '. */ - char *zalias; - /* Linked list of alternate sets of call information. */ - struct ssysteminfo *qalternate; - /* Name for this alternate (may be NULL). */ - char *zalternate; - /* Legal times to call. A grade, a time string, an optional ';' and - retry time, ' ', repeated. */ - char *ztime; - /* Grade to request of other system and associated time. A grade, a - time string, ' ', repeated. */ - char *zcalltimegrade; - /* Sizes for local requests and calls. A size, ' ', a time string, - ' ', repeated. */ - char *zcall_local_size; - /* Sizes for remote requests and local calls. */ - char *zcall_remote_size; - /* Sizes for local requests when called. */ - char *zcalled_local_size; - /* Sizes for remote requests when called. */ - char *zcalled_remote_size; - /* Baud rate (all right, so it's really bps). */ - long ibaud; - /* High baud rate, if a range is permitted (0 if no range). */ - long ihighbaud; - /* Port name, if qport is not used. */ - char *zport; - /* Specific port information, if zport is not used. */ - struct sport *qport; - /* Phone number. */ - char *zphone; - /* Chat script information. */ - struct schat_info schat; - /* Login name to use when calling the remote system. */ - const char *zcall_login; - /* Password to use when calling the remote system. */ - const char *zcall_password; - /* Login name that must be used by the other system when calling in. */ - const char *zcalled_login; - /* Whether to call back the remote system. */ - boolean fcallback; - /* Whether system uses sequencing. */ - boolean fsequence; - /* List of protocols to use for this system (may be NULL). */ - const char *zprotocols; - /* Number of entries in protocol parameters array. */ - int cproto_params; - /* Protocol parameters array. */ - struct sproto_param *qproto_params; - /* Chat to run when called. */ - struct schat_info scalled_chat; -#if DEBUG > 1 - /* Debugging level to set during a call. */ - int idebug; - /* Maximum remote debugging level. */ - int imax_remote_debug; -#endif - /* Whether the other system may request things when we call them. */ - boolean fcall_request; - /* Whether the other system may request things when they call us. */ - boolean fcalled_request; - /* Whether we may request things when we call. */ - boolean fcall_transfer; - /* Whether we may request things when they call. */ - boolean fcalled_transfer; - /* List of directories that may be sent by local request. */ - const char *zlocal_send; - /* List of directories that may be sent by local request when the - other system placed the call (if NULL, use zlocal_send). This is - actually never used currently. */ - const char *zcalled_local_send; - /* List of directories that may be sent by remote request. */ - const char *zremote_send; - /* List of directories that may be sent by remote request when the - other system placed the call (if NULL, use zremote_send). This - is currently only used by HAVE_BNU_CONFIG. */ - const char *zcalled_remote_send; - /* List of directories that may be received into by local request. */ - const char *zlocal_receive; - /* List of directories that may be received into by local request - when the other system placed the call (if NULL, use - zlocal_receive). This is currently only used under - HAVE_BNU_CONFIG. */ - const char *zcalled_local_receive; - /* List of directories that may be received into by remote request. */ - const char *zremote_receive; - /* List of directories that may be received into by remote request - when the other system placed the call (if NULL, use - zremote_receive). This is currently only used by - HAVE_BNU_CONFIG. */ - const char *zcalled_remote_receive; - /* Path to use for command execution. */ - const char *zpath; - /* List of commands that may be executed. */ - const char *zcmds; - /* Amount of free space to leave. */ - long cfree_space; - /* List of systems that may be forwarded to. */ - const char *zforwardto; - /* The public directory to use for this sytem. */ - const char *zpubdir; - /* The local name to use for this remote system. */ - const char *zlocalname; -}; - -/* The tfailure enumeration holds reasons for failure to be passed to - the pffail function of a protocol. */ - -enum tfailure -{ - /* No failure. */ - FAILURE_NONE, - /* No permission for operation. */ - FAILURE_PERM, - /* Can't open necessary file. */ - FAILURE_OPEN, - /* Not enough space to receive file. */ - FAILURE_SIZE -}; - -/* The tlog enumeration holds the different types of logging. */ - -enum tlog -{ - /* Normal log entry. */ - LOG_NORMAL, - /* Error log entry. */ - LOG_ERROR, - /* Fatal log entry. */ - LOG_FATAL -#if DEBUG > 1 - , - /* Debugging log entry. */ - LOG_DEBUG, - /* Start debugging log entry. */ - LOG_DEBUG_START, - /* Continue debugging log entry. */ - LOG_DEBUG_CONTINUE, - /* End debugging log entry. */ - LOG_DEBUG_END -#endif -}; - -/* The tstatus_type enumeration holds the kinds of status information - we put in the status file. The order of entries here corresponds - to the order of entries in the azStatus array. */ - -enum tstatus_type -{ - /* Conversation complete. */ - STATUS_COMPLETE, - /* Port unavailable. */ - STATUS_PORT_FAILED, - /* Dial failed. */ - STATUS_DIAL_FAILED, - /* Login failed. */ - STATUS_LOGIN_FAILED, - /* Handshake failed. */ - STATUS_HANDSHAKE_FAILED, - /* Failed after logging in. */ - STATUS_FAILED, - /* Talking to remote system. */ - STATUS_TALKING, - /* Wrong time to call. */ - STATUS_WRONG_TIME, - /* Number of status values. */ - STATUS_VALUES -}; - -/* An array to convert status entries to strings. If more status entries - are added, this array must be extended. */ -extern const char *azStatus[]; - -/* The sstatus structure holds the contents of a system status file. */ - -struct sstatus -{ - /* Current status of conversation. */ - enum tstatus_type ttype; - /* Number of failed retries. */ - int cretries; - /* Time of last call in seconds since epoch (determined by - isysdep_time). */ - long ilast; - /* Number of seconds until a retry is permitted. */ - int cwait; -}; - -/* How long we have to wait for the next call, given the number of retries - we have already made. This should probably be configurable. */ -#define CRETRY_WAIT(c) ((c) * 10 * 60) - -/* The scmd structure holds a complete UUCP command. */ - -struct scmd -{ - /* Command ('S' for send, 'R' for receive, 'X' for execute, 'H' for - hangup, 'Y' for hangup confirm, 'N' for hangup deny). */ - char bcmd; - /* At least one compiler needs an explicit padding byte here. */ - char bdummy; - /* Sequence handle for fsysdep_did_work. */ - pointer pseq; - /* File name to transfer from. */ - const char *zfrom; - /* File name to transfer to. */ - const char *zto; - /* User who requested transfer. */ - const char *zuser; - /* Options. */ - const char *zoptions; - /* Temporary file name ('S' and pfreceive protocol function). */ - const char *ztemp; - /* Mode to give newly created file ('S' and pfreceive protocol fn). */ - unsigned int imode; - /* User to notify on remote system (optional; 'S' only). */ - const char *znotify; - /* File size (-1 if not supplied) ('S' and pfreceive protocol fn). */ - long cbytes; -}; - -/* The highest grade. */ -#define BGRADE_HIGH ('0') - -/* The lowest grade. */ -#define BGRADE_LOW ('z') - -/* Whether a character is a legal grade. */ -#define FGRADE_LEGAL(b) (isalnum (BUCHAR (b))) - -#if DEBUG > 1 - -/* We allow independent control over several different types of - debugging output, using a bit string with individual bits dedicated - to particular debugging types. */ - -/* The bit string is stored in iDebug. */ -extern int iDebug; - -/* Debug abnormal events. */ -#define DEBUG_ABNORMAL (01) -/* Debug chat scripts. */ -#define DEBUG_CHAT (02) -/* Debug initial handshake. */ -#define DEBUG_HANDSHAKE (04) -/* Debug UUCP protocol. */ -#define DEBUG_UUCP_PROTO (010) -/* Debug protocols. */ -#define DEBUG_PROTO (020) -/* Debug port actions. */ -#define DEBUG_PORT (040) -/* Debug configuration files. */ -#define DEBUG_CONFIG (0100) -/* Debug spool directory actions. */ -#define DEBUG_SPOOLDIR (0200) -/* Debug executions. */ -#define DEBUG_EXECUTE (0400) -/* Debug incoming data. */ -#define DEBUG_INCOMING (01000) -/* Debug outgoing data. */ -#define DEBUG_OUTGOING (02000) - -/* Maximum possible value for iDebug. */ -#define DEBUG_MAX (03777) - -/* Intializer for array of debug names. The index of the name in the - array is the corresponding bit position in iDebug. We only check - for prefixes, so these names only need to be long enough to - distinguish each name from every other. The last entry must be - NULL. The string "all" is also recognized to turn on all - debugging. */ -#define DEBUG_NAMES \ - { "a", "ch", "h", "u", "pr", "po", "co", "s", "e", "i", "o", NULL } - -/* The prefix to use to turn off all debugging. */ -#define DEBUG_NONE "n" - -/* Check whether a particular type of debugging is being done. */ -#define FDEBUGGING(i) ((iDebug & (i)) != 0) - -/* These macros are used to output debugging information. I use - several different macros depending on the number of arguments - because no macro can take a variable number of arguments and I - don't want to use double parentheses. */ -#define DEBUG_MESSAGE0(i, z) \ - do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z)); } while (0) -#define DEBUG_MESSAGE1(i, z, a1) \ - do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z), (a1)); } while (0) -#define DEBUG_MESSAGE2(i, z, a1, a2) \ - do { if (FDEBUGGING (i)) ulog (LOG_DEBUG, (z), (a1), (a2)); } while (0) -#define DEBUG_MESSAGE3(i, z, a1, a2, a3) \ - do \ - { \ - if (FDEBUGGING (i)) \ - ulog (LOG_DEBUG, (z), (a1), (a2), (a3)); \ - } \ - while (0) -#define DEBUG_MESSAGE4(i, z, a1, a2, a3, a4) \ - do \ - { \ - if (FDEBUGGING (i)) \ - ulog (LOG_DEBUG, (z), (a1), (a2), (a3), (a4)); \ - } \ - while (0) - -#else /* DEBUG <= 1 */ - -/* If debugging information is not being compiled, provide versions of - the debugging macros which just disappear. */ -#define DEBUG_MESSAGE0(i, z) -#define DEBUG_MESSAGE1(i, z, a1) -#define DEBUG_MESSAGE2(i, z, a1, a2) -#define DEBUG_MESSAGE3(i, z, a1, a2, a3) -#define DEBUG_MESSAGE4(i, z, a1, a2, a3, a4) - -#endif /* DEBUG <= 1 */ - -/* Functions. */ - -/* Read the configuration file. */ -extern void uread_config P((const char *zname)); - -/* Read information about all systems. */ -extern void uread_all_system_info P((int *pc, struct ssysteminfo **ppas)); - -/* Read information about a specific system. */ -extern boolean fread_system_info P((const char *zsystem, - struct ssysteminfo *qsys)); - -/* Set the default values for an uninitialized system. */ -extern void uset_system_defaults P((struct ssysteminfo *qsys)); - -/* Start getting commands for unknown systems. */ -extern void uiunknown_start P((void)); - -/* Process a command defining unknown systems. */ -extern enum tcmdtabret tiunknown P((int argc, char **argv, - pointer pvar, const char *zerr)); - -/* Finish getting commands for unknown systems. */ -extern void uiunknown_end P((void)); - -/* Set up the sLocalsys structure. */ -extern void uisetup_localsys P((void)); - -/* Open a set of files and pretend that they were all catenated - together. */ -extern struct smulti_file *qmulti_open P((const char *znames)); - -/* Close a set of files opened by qmulti_open. */ -extern boolean fmulti_close P((struct smulti_file *q)); - -/* Process a set of commands. */ -extern void uprocesscmds P((FILE *e, struct smulti_file *qmulti, - const struct scmdtab *qcmds, - const char *zerr, int iflags)); - -/* Process a single command. */ -extern enum tcmdtabret tprocess_one_cmd P((int cargs, char **azargs, - const struct scmdtab *qcmds, - const char *zerr, - int iflags)); - -/* Translate an unknown system name into something acceptable for the - spool directory stuff. */ -extern const char *ztranslate_system P((const char *zsystem)); - -/* Check login name and password. */ -extern boolean fcheck_login P((const char *zuser, const char *zpass)); - -/* Get one character from the remote system, going through the - procotol buffering. The ctimeout argument is the timeout in - seconds, and the freport argument is TRUE if errors should be - reported (when closing a connection it is pointless to report - errors). This returns a character or -1 on a timeout or -2 on an - error. */ -extern int breceive_char P((int ctimeout, boolean freport)); - -/* See whether a file belongs in the spool directory. */ -extern boolean fspool_file P((const char *zfile)); - -/* Store information about a file being sent. */ -extern boolean fstore_sendfile P((openfile_t e, pointer pseq, - const char *zfrom, const char *zto, - const char *ztosys, const char *zuser, - const char *zmail)); - -/* Finish sending a file. The zwhy and fnever arguments are used - if the file was not received correctly. */ -extern boolean fsent_file P((boolean freceived, long cbytes, - const char *zwhy, boolean fnever)); - -/* Note an error sending a file. The function fsent_file must still - be called after this is called. */ -extern void usendfile_error P((void)); - -/* Store information about a file being received. */ -extern boolean fstore_recfile P((openfile_t e, pointer pseq, - const char *zfrom, const char *zto, - const char *zfromsys, const char *zuser, - unsigned int imode, const char *zmail, - const char *ztemp)); - -/* Finish receiving a file. The zwhy and fnever arguments are used - if the file was not received correctly. */ -extern boolean freceived_file P((boolean fsent, long cbytes, - const char *zwhy, boolean fnever)); - -/* Note an error receiving a file. The function freceived_file must - still be called after this is called. */ -extern void urecfile_error P((void)); - -/* Prepare to receive a file again by discarding the previous - contents. */ -extern boolean frecfile_rewind P((void)); - -/* Send mail about a file transfer. */ -extern boolean fmail_transfer P((boolean fok, const char *zuser, - const char *zmail, const char *zwhy, - const char *zfrom, const char *zfromsys, - const char *zto, const char *ztosys, - const char *zsaved)); - -/* See whether a file is in one of a list of directories. The qsys - argument are passed down to allow ~ expansion. If fcheck is FALSE, - this does not check accessibility. Otherwise, if freadable is - TRUE, the user zuser must have read access to the file and all - appropriate directories; if freadable is FALSE zuser must have - write access to the appropriate directories. The zuser argument - may be NULL, in which case all users must have the appropriate - access (this is used for a remote request). */ -extern boolean fin_directory_list P((const struct ssysteminfo *qsys, - const char *zfile, - const char *zdirs, - boolean fcheck, - boolean freadable, - const char *zuser)); - -/* Get the login name and password to use when calling a system out - of the call out login file. The pzlog and pzpass arguments are set - to point to malloc'ed strings which must be freed after they have - been used. */ -extern boolean fcallout_login P((const struct ssysteminfo *qsys, - char **pzlog, char **pzpass)); - -/* Add a string to the end of another. */ -extern void uadd_string P((char **pz, const char *z, int bsep)); - -/* Process a chat command. These are handled using CMDTABTYPE_PREFIX. - This function switches off on argv[0]. */ -extern enum tcmdtabret tprocess_chat_cmd P((int argc, char **argv, - pointer pvar, - const char *zerr)); - -/* Add a protocol parameter entry. */ -extern enum tcmdtabret tadd_proto_param P((int *pc, - struct sproto_param **pq, - const char *zerr, int cargs, - char **azargs)); - -/* Apply protocol parameters. */ -extern void uapply_proto_params P((int bproto, struct scmdtab *qcmds, - int c, struct sproto_param *pas)); - -/* Parse a command string. */ -extern boolean fparse_cmd P((char *zcmd, struct scmd *qcmd)); - -/* Specify which machines may be accepted for a login name. */ -extern void uadd_validate P((const char *zlogname, int cmachines, - const char **pazmachines)); - -/* Check whether a login name/machine name pair is acceptable. */ -extern boolean fcheck_validate P((const char *zlogname, - const char *zmachine)); - -/* Compare the execution times of two grades. Return < 0 if the first - argument should be executed first, 0 if they are the same, > 0 if - the second argument should be executed first. */ -extern int igradecmp P((int b1, int b2)); - -/* Make a log entry. */ -#if ANSI_C && HAVE_VFPRINTF -extern void ulog P((enum tlog ttype, const char *zfmt, ...)) -#if __GNUC__ > 1 - __attribute__ ((format (printf, 2, 3))) -#endif - ; -#else -extern void ulog (); -#endif - -/* Set the function to call if a fatal error occurs. */ -extern void ulog_fatal_fn P((void (*pfn) P((void)))); - -/* If ffile is TRUE, send log entries to the log file rather than to - stderr. */ -extern void ulog_to_file P((boolean ffile)); - -/* Set the ID number used by the logging functions. */ -extern void ulog_id P((int iid)); - -/* Set the system name used by the logging functions. */ -extern void ulog_system P((const char *zsystem)); - -/* Set the system and user name used by the logging functions. */ -extern void ulog_user P((const char *zuser)); - -/* Set the device name used by the logging functions. */ -extern void ulog_device P((const char *zdevice)); - -/* Close the log file. */ -extern void ulog_close P((void)); - -/* Make an entry in the statistics file. */ -extern void ustats P((boolean fsucceeded, const char *zuser, - const char *zsystem, boolean fsent, - long cbytes, long csecs, long cmicros)); - -/* We have lost the connection; record any in progress file transfers - in the statistics file. */ -extern void ustats_failed P((void)); - -/* Close the statistics file. */ -extern void ustats_close P((void)); - -#if DEBUG > 1 -/* A debugging routine to output a buffer. This outputs zhdr, the - buffer length clen, and the contents of the buffer in quotation - marks. */ -extern void udebug_buffer P((const char *zhdr, const char *zbuf, - int clen)); - -/* A debugging routine to make a readable version of a character. - This takes a buffer at least 5 bytes long, and returns the length - of the string it put into it (not counting the null byte). */ -extern int cdebug_char P((char *z, int ichar)); - -/* Parse a debugging option string. This can either be a number or a - comma separated list of debugging names. If the code is compiled - without debugging this is a dummy function. This returns a value - for iDebug. */ -extern int idebug_parse P((const char *)); - -/* Parse a debugging option in a configuration file. This is used for - the ``debug'' command. */ -extern enum tcmdtabret tidebug_parse P((int argc, char **argv, - pointer pvar, const char *zerr)); - -#else /* DEBUG <= 1 */ - -/* Dummy version of idebug_parse. This makes the option processing - look a little neater. */ - -#define idebug_parse(z) 0 - -#endif /* DEBUG <= 1 */ - -/* Copy one file to another. */ -extern boolean fcopy_file P((const char *zfrom, const char *zto, - boolean fpublic, boolean fmkdirs)); - -/* Read a line from a set of files opened by qmulti_open. The return - value is an malloc'ed buffer. This will return NULL when all the - files have been exhausted. If pffirst is not NULL, it will be set - to TRUE if this is the first line of a file. If pzname is not - NULL, it will be set to the file name from which the line was read. - If fbackslash is TRUE, lines may be continued by using a backslash - as the last character before the newline. */ -extern char *zmulti_gets P((struct smulti_file *q, boolean *pffirst, - const char **pzname, boolean fbackslash)); - -/* Read an arbitrary length string from a file, returning an malloc'ed - buffer. If the fbackslash argument is true, lines may be continued - by using a backslash as the last character before the newline. */ -extern char *zfgets P((FILE *e, boolean fbackslash)); - -/* Copy a string into memory without fail. */ -extern char *xstrdup P((const char *)); - -/* Allocate memory without fail. */ -extern pointer xmalloc P((int)); - -/* Realloc memory without fail. */ -extern pointer xrealloc P((pointer, int)); - -/* Free memory (accepts NULL pointers, which some libraries erroneously - do not). */ -extern void xfree P((pointer)); - -#if ! HAVE_REMOVE -/* Erase a file. */ -#undef remove -extern int remove P((const char *zfile)); -#endif - -#if ! HAVE_STRDUP -/* Copy a string into memory. */ -extern char *strdup P((const char *z)); -#endif - -#if ! HAVE_STRSTR -/* Look for one string within another. */ -extern char *strstr P((const char *zouter, const char *zinner)); -#endif - -#if ! HAVE_STRCASECMP -#if HAVE_STRICMP -/* Use macros to access stricmp and strnicmp as strcasecmp and - strncasecmp. */ -#define strcasecmp stricmp -#define strncasecmp strnicmp -#else /* ! HAVE_STRICMP */ -/* Use our own case insensitive string comparisons. */ -extern int strcasecmp P((const char *z1, const char *z2)); -extern int strncasecmp P((const char *z1, const char *z2, int clen)); -#endif /* ! HAVE_STRICMP */ -#endif /* ! HAVE_STRCASECMP */ - -#if ! HAVE_STRERROR -/* Get a string corresponding to an error message. */ -extern char *strerror P((int ierr)); -#endif - -/* Get the appropriate definitions for memcmp, memcpy, memchr and - bzero. Hopefully the declarations of bzero, bcmp and bcopy will - not cause any trouble. */ -#if ! HAVE_MEMCMP -#if HAVE_BCMP -#define memcmp(p1, p2, c) bcmp ((p1), (p2), (c)) -extern int bcmp (); -#else /* ! HAVE_BCMP */ -extern int memcmp P((constpointer p1, constpointer p2, int c)); -#endif /* ! HAVE_BCMP */ -#endif /* ! HAVE_MEMCMP */ - -#if ! HAVE_MEMCPY -#if HAVE_BCOPY -#define memcpy(pto, pfrom, c) bcopy ((pfrom), (pto), (c)) -extern void bcopy (); -#else /* ! HAVE_BCOPY */ -extern pointer memcpy P((pointer pto, constpointer pfrom, int c)); -#endif /* ! HAVE_BCOPY */ -#endif /* ! HAVE_MEMCPY */ - -#if ! HAVE_MEMCHR -extern pointer memchr P((constpointer p, int b, int c)); -#endif - -#if HAVE_BZERO -#ifndef bzero /* bzero is sometimes a macro. */ -extern void bzero (); -#endif -#else /* ! HAVE_BZERO */ -#if HAVE_MEMSET -#define bzero(p, c) memset ((p), 0, (c)) -#else /* ! HAVE_MEMSET */ -extern void bzero P((pointer p, int c)); -#endif /* ! HAVE_MEMSET */ -#endif /* ! HAVE_BZERO */ - -/* Move a memory block safely. Go through xmemmove to allow for - systems which have the prototype (using size_t, which we don't want - to use since some systems won't have it) but not the function. */ -#if HAVE_MEMMOVE -#define xmemmove memmove -#else /* ! HAVE_MEMMOVE */ -extern pointer xmemmove P((pointer, constpointer, int)); -#endif /* ! HAVE_MEMMOVE */ - -/* Look up a character in a string. */ -#if ! HAVE_STRCHR -#if HAVE_INDEX -#define strchr index -extern char *index (); -#else /* ! HAVE_INDEX */ -extern char *strchr P((const char *z, int b)); -#endif /* ! HAVE_INDEX */ -#endif /* ! HAVE_STRCHR */ - -#if ! HAVE_STRRCHR -#if HAVE_RINDEX -#define strrchr rindex -extern char *rindex (); -#else /* ! HAVE_RINDEX */ -extern char *strrchr P((const char *z, int b)); -#endif /* ! HAVE_RINDEX */ -#endif /* ! HAVE_STRRCHR */ - -/* Turn a string into a long integer. */ -#if ! HAVE_STRTOL -extern long strtol P((const char *, char **, int)); -#endif - -/* Lookup a key in a sorted array. */ -#if ! HAVE_BSEARCH -extern pointer bsearch P((constpointer pkey, constpointer parray, - int celes, int cbytes, - int (*pficmp) P((constpointer, constpointer)))); -#endif - -/* Convert a string to lower case. */ -#if ! HAVE_STRLWR -extern char *strlwr P((char *)); -#endif - -/* Global variables. */ - -/* The name of the program being run. This is statically initialized, - although it should perhaps be set from argv[0]. */ -extern char abProgram[]; - -/* Version number string. */ -extern char abVersion[]; - -/* Local UUCP name. */ -extern const char *zLocalname; - -/* System information file names. */ -extern char *zSysfile; - -/* Port information file names. */ -extern char *zPortfile; - -/* Dialer information file names. */ -extern char *zDialfile; - -/* Local spool directory. */ -extern const char *zSpooldir; - -/* Public directory. */ -extern const char *zPubdir; - -/* Log file name. */ -extern const char *zLogfile; - -/* Statistics file name. */ -extern const char *zStatfile; - -#if DEBUG > 1 -/* Debugging file name. */ -extern const char *zDebugfile; -#endif - -/* Files containing login names and passwords to use when calling out. */ -extern char *zCallfile; - -/* Files containing login names and passwords to check when somebody - calls in. */ -extern char *zPwdfile; - -/* Files containing dialcodes. */ -extern char *zDialcodefile; - -#if HAVE_V2_CONFIG -/* TRUE if we should read V2 configuration files. */ -extern boolean fV2; - -/* Read the V2 L.sys file. */ -extern void uv2_read_systems P((int *pc, struct ssysteminfo **ppas)); - -#endif /* HAVE_V2_CONFIG */ - -#if HAVE_BNU_CONFIG -/* TRUE if we should read BNU configuration files. */ -extern boolean fBnu; - -/* The names of the BNU system files to read. */ -extern char *zBnu_systems; - -/* The names of the BNU dialers files to read. */ -extern char *zBnu_dialers; - -/* The names of the BNU devices files to read. */ -extern char *zBnu_devices; - -/* Routines to read BNU files. */ -extern void ubnu_read_sysfiles P((void)); -extern void ubnu_read_systems P((int *pc, struct ssysteminfo **ppas)); - -#endif /* HAVE_BNU_CONFIG */ - -/* TRUE if we accept calls from unknown system. */ -extern boolean fUnknown_ok; - -/* The ssysteminfo structure we use for unknown systems. */ -extern struct ssysteminfo sUnknown; - -/* The ssysteminfo structure we use for the local system. */ -extern struct ssysteminfo sLocalsys; - -/* The maximum number of uuxqt processes which may be running at one - time. */ -extern int cMaxuuxqts; - -/* When a signal occurs, the signal handlers sets the appropriate - element of the arrays afSignal and afLog_signal to TRUE. The - afSignal array is used to check whether a signal occurred. The - afLog_signal array tells ulog to log the signal; ulog will clear - the element after logging it, which means that if a signal comes in - at just the right moment it will not be logged. It will always be - recorded in afSignal, though. At the moment we handle 5 signals: - SIGHUP, SIGINT, SIGQUIT, SIGTERM and SIGPIPE (the Unix code also - handles SIGALRM). If we want to handle more, the afSignal array - must be extended; I see little point to handling any of the other - ANSI C or POSIX signals, as they are either unlikely to occur - (SIGABRT, SIGUSR1) or nearly impossible to handle cleanly (SIGILL, - SIGSEGV). */ -#define INDEXSIG_SIGHUP (0) -#define INDEXSIG_SIGINT (1) -#define INDEXSIG_SIGQUIT (2) -#define INDEXSIG_SIGTERM (3) -#define INDEXSIG_SIGPIPE (4) -#define INDEXSIG_COUNT (5) - -extern volatile sig_atomic_t afSignal[INDEXSIG_COUNT]; -extern volatile sig_atomic_t afLog_signal[INDEXSIG_COUNT]; - -/* The names of the signals to use in error messages, as an - initializer for an array. */ -#define INDEXSIG_NAMES \ - { "hangup", "interrupt", "quit", "termination", "SIGPIPE" } - -/* Check to see whether we've received a signal. It would be nice if - we could use a single variable for this, but we sometimes want to - clear our knowledge of a signal and that would cause race - conditions (clearing a single element of the array is not a race - assuming that we don't care about a particular signal, even if it - occurs after we've examined the array). */ -#define FGOT_SIGNAL() \ - (afSignal[INDEXSIG_SIGHUP] || afSignal[INDEXSIG_SIGINT] \ - || afSignal[INDEXSIG_SIGQUIT] || afSignal[INDEXSIG_SIGTERM] \ - || afSignal[INDEXSIG_SIGPIPE]) - -/* If we get a SIGINT in uucico, we continue the current communication - session but don't start any new ones. This macros checks for any - signal other than SIGINT, which means we should get out - immediately. */ -#define FGOT_QUIT_SIGNAL() \ - (afSignal[INDEXSIG_SIGHUP] || afSignal[INDEXSIG_SIGQUIT] \ - || afSignal[INDEXSIG_SIGTERM] || afSignal[INDEXSIG_SIGPIPE]) - -/* File being sent. */ -extern openfile_t eSendfile; - -/* File being received. */ -extern openfile_t eRecfile; - -/* Device name to log. This is set by fport_open. It may be NULL. */ -extern char *zLdevice; diff --git a/gnu/libexec/uucp/uucp.info b/gnu/libexec/uucp/uucp.info deleted file mode 100644 index 0f23271b8ff0..000000000000 --- a/gnu/libexec/uucp/uucp.info +++ /dev/null @@ -1,98 +0,0 @@ -Info file uucp.info, produced by Makeinfo, -*- Text -*- from input -file uucp.texi. - - This file documents Taylor UUCP, version 1.03. - - Copyright (C) 1992 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 also -that the section entitled "Copying" are included exactly as in the -original, and 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 the section entitled "Copying" may be included -in a translation approved by the author instead of in the original -English. - -Indirect: -uucp.info-1: 984 -uucp.info-2: 49152 -uucp.info-3: 98532 -uucp.info-4: 148069 - -Tag Table: -(Indirect) -Node: Top986 -Node: Copying5410 -Node: Introduction7937 -Node: Overall Installation14735 -Node: Configuration15321 -Node: Compilation17211 -Node: Testing22098 -Node: Installation27587 -Node: Usage27959 -Node: TCP29382 -Node: Configuration Files32661 -Node: Configuration File Format34119 -Node: Configuration Examples35799 -Node: config File Examples36462 -Node: Leaf Example40328 -Node: Gateway Example43008 -Node: Time Strings47380 -Node: Chat Scripts49154 -Node: config File57228 -Node: Miscellaneous (config)57841 -Node: Configuration File Names60294 -Node: Log File Names64498 -Node: Debugging Levels65766 -Node: sys File68632 -Node: Defaults and Alternates69512 -Node: Naming the System72606 -Node: Calling Out74334 -Node: When to Call74691 -Node: Placing the Call78279 -Node: Logging In81504 -Node: Accepting a Call84766 -Node: Protocol Selection87579 -Node: File Transfer Control93689 -Node: Miscellaneous (sys)98534 -Node: Default sys File Values102756 -Node: port File103508 -Node: dial File110240 -Node: Security115883 -Node: Protocols121151 -Node: Grades122501 -Node: Lock Files126091 -Node: UUCP Protocol128421 -Node: Initial Handshake129139 -Node: File Requests135702 -Node: S Request136896 -Node: R Request142317 -Node: X Request145480 -Node: H Request147195 -Node: Final Handshake148071 -Node: g Protocol148888 -Node: f Protocol159203 -Node: t Protocol162285 -Node: e Protocol163346 -Node: x Protocol164142 -Node: d Protocol164620 -Node: Capital G Protocol165006 -Node: Documentation References165559 -Node: Hacking166526 -Node: System Dependence166894 -Node: Naming Conventions168827 -Node: Patches170994 -Node: Acknowledgements171490 -Node: Index (concepts)177031 -Node: Index (configuration file)180596 - -End Tag Table diff --git a/gnu/libexec/uucp/uucp.info-1 b/gnu/libexec/uucp/uucp.info-1 deleted file mode 100644 index e8daa0a58796..000000000000 --- a/gnu/libexec/uucp/uucp.info-1 +++ /dev/null @@ -1,1149 +0,0 @@ -Info file uucp.info, produced by Makeinfo, -*- Text -*- from input -file uucp.texi. - - This file documents Taylor UUCP, version 1.03. - - Copyright (C) 1992 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 also -that the section entitled "Copying" are included exactly as in the -original, and 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 the section entitled "Copying" may be included -in a translation approved by the author instead of in the original -English. - - -File: uucp.info, Node: Top, Next: Copying, Prev: (dir), Up: (dir) - -Taylor UUCP 1.03 -**************** - - This is the documentation for the Taylor UUCP package, version 1.03. -The programs were written by Ian Lance Taylor. The author can be -reached at `', or, equivalently, `', or -`c/o Infinity Development, P.O. Box 520, Waltham MA, 02254'. - - There is a mailing list for discussion of the package. To join the -list, send a message to `'. Make -sure you include the address you want to receive messages at; do not -rely on the `From:' header. To send a message to the list, send it to -`'. - -* Menu: - -* Copying:: Taylor UUCP copying conditions -* Introduction:: Introduction to Taylor UUCP -* Overall Installation:: Taylor UUCP installation -* Configuration Files:: Taylor UUCP configuration files -* Protocols:: UUCP protocol internals -* Hacking:: Hacking Taylor UUCP -* Acknowledgements:: Acknowledgements - -* Index (concepts):: Concept index -* Index (configuration file):: Index to new configuration files - - -- The Detailed Node Listing -- - -Taylor UUCP Overall Installation - -* Configuration:: Configuring Taylor UUCP -* Compilation:: Compiling Taylor UUCP -* Testing:: Testing Taylor UUCP -* Installation:: Installing Taylor UUCP -* Usage:: Using Taylor UUCP -* TCP:: TCP together with Taylor UUCP - -Taylor UUCP Configuration Files - -* Configuration File Format:: Configuration file format -* Configuration Examples:: Examples of configuration files -* Time Strings:: How to write time strings -* Chat Scripts:: How to write chat scripts -* config File:: The main configuration file -* sys File:: The system configuration file -* port File:: The port configuration files -* dial File:: The dialer configuration files -* Security:: Security issues - -Examples of Configuration Files - -* config File Examples:: Examples of the main configuration file -* Leaf Example:: Call a single remote site -* Gateway Example:: The gateway for several local systems - -The Main Configuration File - -* Miscellaneous (config):: Miscellaneous config file commands -* Configuration File Names:: Using different configuration files -* Log File Names:: Using different log files -* Debugging Levels:: Debugging levels - -The System Configuration File - -* Defaults and Alternates:: Using defaults and alternates -* Naming the System:: Naming the system -* Calling Out:: Calling out -* Accepting a Call:: Accepting a call -* Protocol Selection:: Protocol selection -* File Transfer Control:: File transfer control -* Miscellaneous (sys):: Miscellaneous sys file commands -* Default sys File Values:: Default values - -Calling Out - -* When to Call:: When to call -* Placing the Call:: Placing the call -* Logging In:: Logging in - -UUCP protocol internals - -* Grades:: UUCP grades -* Lock Files:: UUCP lock file format -* UUCP Protocol:: The common UUCP protocol -* g Protocol:: The UUCP `g' protocol -* f Protocol:: The UUCP `f' protocol -* t Protocol:: The UUCP `t' protocol -* e Protocol:: The UUCP `e' protocol -* x Protocol:: The UUCP `x' protocol -* d Protocol:: The UUCP `d' protocol -* Capital G Protocol:: The UUCP `G' protocol -* Documentation References:: Documentation references - -The Common UUCP Protocol - -* Initial Handshake:: Initial handshake -* File Requests:: File requests -* Final Handshake:: Final handshake - -File Requests - -* S Request:: S request -* R Request:: R request -* X Request:: X request -* H Request:: H request - -Hacking Taylor UUCP - -* System Dependence:: System Dependence -* Naming Conventions:: Naming Conventions -* Patches:: Patches - - -File: uucp.info, Node: Copying, Next: Introduction, Prev: Top, Up: Top - -Taylor UUCP Copying Conditions -****************************** - - This package is covered by the GNU Public License. See the file -`COPYING' for details. If you would like to do something with this -package that you feel is reasonable but you feel is prohibited by the -license, contact me to see if we can work it out. - - Here is some propaganda from the Free Software Foundation. If you -find this stuff offensive or annoying, remember that you probably did -not spend any money to get this code. I did not write this code to -make life easier for developers of UUCP packages, I wrote it to help -end users, and I believe that these are the most appropriate -conditions for distribution. - - All the programs, scripts and documents relating to Taylor UUCP are -"free"; this means that everyone is free to use them and free to -redistribute them on a free basis. The Taylor UUCP-related programs -are not in the public domain; they are copyrighted and there are -restrictions on their distribution, but these restrictions are designed -to permit everything that a good cooperating citizen would want to do. -What is not allowed is to try to prevent others from further sharing -any version of these programs that they might get from you. - - Specifically, we want to make sure that you have the right to give -away copies of the programs that relate to Taylor UUCP, that you -receive source code or else can get it if you want it, that you can -change these programs or use pieces of them in new free programs, and -that you know you can do these things. - - To make sure that everyone has such rights, we have to forbid you to -deprive anyone else of these rights. For example, if you distribute -copies of the Taylor UUCP related programs, 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 tell them -their rights. - - Also, for our own protection, we must make certain that everyone -finds out that there is no warranty for the programs that relate to -Taylor UUCP. If these programs are modified by someone else and -passed on, we want their recipients to know that what they have is not -what we distributed, so that any problems introduced by others will -not reflect on our reputation. - - The precise conditions of the licenses for the programs currently -being distributed that relate to Taylor UUCP are found in the General -Public Licenses that accompany them. - - -File: uucp.info, Node: Introduction, Next: Overall Installation, Prev: Copying, Up: Top - -Introduction to Taylor UUCP -*************************** - - General introductions to UUCP are available, and perhaps one day I -will write one. In the meantime, here is a very brief one that -concentrates on the programs provided by Taylor UUCP. - - Taylor UUCP is a complete UUCP package. It is covered by the GNU -Public License, which means that the source code is always available. -It is composed of several programs, the names of which were -established by earlier UUCP packages. - -`uucp' - The `uucp' program is used to copy file between systems. It is - similar to the standard Unix `cp' program, except that you can - refer to a file on a remote system by using `system!' before the - file name. For example, to copy the file `notes.txt' to the - system `airs', you would say `uucp notes.txt airs!~/notes.txt'. - In this example `~' is used to name the UUCP public directory on - `airs'. - -`uux' - The `uux' program is used to request a program to be executed on a - remote system. This is how mail and news are transferred over - UUCP. As with `uucp', programs and files on remote systems may - be named by using `system!'. For example, to run the `rnews' - program on `airs' passing it standard input, you would say `uux - - airs!rnews'. The `-' means to read standard input and set things - up so that when `rnews' runs on `airs' it will receive the same - standard input. - - Neither `uucp' nor `uux' actually do any work immediately. -Instead, they queue up requests for later processing. They then start -a daemon process which processes the requests and calls up the -appropriate systems. Usually the daemon will also be started -regularly to check if there is any work to be done and to do it. The -advantage of this system is that it all happens automatically. You -don't have to sit around waiting for the files to be transferred. The -disadvantage is that if anything goes wrong it might be a while before -anybody notices. - -`uustat' - The `uustat' program does several things. By default it will - simply list all the jobs you have queued with `uucp' or `uux' - that have not yet been processed. You can use `uustat' to remove - any of your jobs from the queue. You can also it use it to show - the status of the UUCP system in various ways, such as showing the - connection status of all systems your system knows about. - -`uuname' - The `uuname' program by default lists all the remote systems your - system knows about. You can also use it to get the name of your - local system. It is mostly useful for shell scripts. - -`uulog' - The `uulog' program can be used to display entries in the UUCP log - file. It can select the entries for a particular system or a - particular user. You can use it to see what has happened to your - queued jobs in the past. - - These five programs just described, `uucp', `uux', `uustat', -`uuname', and `uulog', are the user programs provided by Taylor UUCP. -The first two add requests to the work queue, the third examines the -work queue, the fourth examines the configuration files, and the last -examines the log files. The real work is actually done by two daemon -processes, which are normally run automatically rather than by a user. - -`uucico' - The `uucico' daemon is the program which actually calls the remote - system and transfers files and requests. `uucico' is normally - started automatically by `uucp' and `uux'. Most systems will - also start it periodically to make sure that all work requests are - handled. `uucico' checks the queue to see what work needs to be - done, and then calls the appropriate systems. If the call fails, - perhaps because the phone line is busy, `uucico' leaves the - requests in the queue and goes on to the next system to call. It - is also possible to force `uucico' to call a remote system even if - there is no work to be done for it, so that it can pick up any - work that may be queued up remotely. - -`uuxqt' - The `uuxqt' daemon processes execution requests made by the `uux' - program on remote systems. It also processes requests made on - the local system which require files from a remote system. It is - normally started by `uucico'. - - Suppose you, on the system `bantam', want to copy a file to the -system `airs'. You would run the `uucp' command locally, with a -command like `uucp notes.txt airs!~/notes.txt'. This would queue up a -request on `bantam' for `airs', and would then start the `uucico' -daemon. `uucico' would see that there was a request for `airs' and -attempt to call it. When the call succeeded, another copy of `uucico' -would be started on `airs'. The two copies of `uucico' would tell -each other what they had to do and transfer the file from `bantam' to -`airs'. When the file transfer was complete the `uucico' on `airs' -would move it into the UUCP public directory. - - UUCP is often used to transfer mail. This is normally done -automatically by mailer programs. When `bantam' has a mail message to -send to `ian' at `airs', it executes `uux - airs!rmail ian' and writes -the mail message to the `uux' process as standard input. The `uux' -program, running on `bantam', will read the standard input and store -it and the `rmail' request on the work queue for `airs'. `uux' will -then start the `uucico' daemon. The `uucico' daemon will call up -`airs', just as in the `uucp' example, and transfer the work request -and the mail message itself. The `uucico' daemon on `airs' will put -the files on a local work queue. When the communication session is -over, the `uucico' daemon on `airs' will start the `uuxqt' daemon. -`uuxqt' will see the request to run, and will run `rmail ian' with the -mail message as standard input. The `rmail' program, which is not -part of the UUCP package, is then responsible for either putting the -message in the right mailbox on `airs' or forwarding the message on to -another system. - - Taylor UUCP comes with two other programs that are useful when -installing and configuring UUCP. - -`uuchk' - The `uuchk' program reads the UUCP configuration files and - displays a rather lengthy description of what it finds. This is - very useful when configuring UUCP to make certain that the UUCP - package will do what you expect it to do. - -`tstuu' - The `tstuu' program is a test harness for the UUCP package, which - will help ensure that it has been configured and compiled - correctly. It does not test everything, however, and it only - runs on Unix systems which support Berkeley style - pseudo-terminals. It can be useful when initially installing - Taylor UUCP. - - -File: uucp.info, Node: Overall Installation, Next: Configuration Files, Prev: Introduction, Up: Top - -Taylor UUCP Overall Installation -******************************** - - These are the installation instructions for the Taylor UUCP package. - -* Menu: - -* Configuration:: Configuring Taylor UUCP -* Compilation:: Compiling Taylor UUCP -* Testing:: Testing Taylor UUCP -* Installation:: Installing Taylor UUCP -* Usage:: Using Taylor UUCP -* TCP:: TCP together with Taylor UUCP - - -File: uucp.info, Node: Configuration, Next: Compilation, Prev: Overall Installation, Up: Overall Installation - -Configuring Taylor UUCP -======================= - - You will have to decide what types of configuration files you want -to use. This package supports a new sort of configuration file; *Note -Configuration files::. It also supports V2 configuration files -(`L.sys', `L-devices', etc.) and BNU configuration files (`Systems', -`Devices', etc.). No documentation is provided for V2 or BNU -configuration files. All types of configuration files can be used at -once, if you are so inclined. Currently using just V2 configuration -files is not really possible, because there is no way to specify a -dialer (there are no built in dialers, and the program does not know -how to read `acucap' or `modemcap'); however, V2 configuration files -can be used with a new style dialer file (*note dial file::.), or with -a BNU `Dialers' file. - - Use of BNU configuration files has two known bugs. A blank line in -the middle of an entry in the `Permissions' file will not be ignored as -it should be. Dialer programs are not recognized directly. If you -must use a dialer program, rather than an entry in `Devices', you must -use the `chat-program' command in a new style dialer file; see *Note -dial file::. You will have to invoke the dialer program via a shell -script, since an exit code of 0 is required to recognize success. - - If you are installing a new system, or you want to use the new form -of configuration files, you must write the configuration files. - - You must also decide what sort of spool directory you want to use. -If you will only be using these programs, I recommend -`SPOOLDIR_TAYLOR'; otherwise select the spool directory corresponding -to your existing UUCP package. The details of the spool directory -choices are described at somewhat tedious length in `sys3.unx'. - - -File: uucp.info, Node: Compilation, Next: Testing, Prev: Configuration, Up: Overall Installation - -Compiling Taylor UUCP -===================== - - 1. Take a look at the top of `Makefile.in' and set the appropriate - values for your system. These control where the program is - installed and which user on the system owns them (normally they - will be owned by a special user `uucp' rather than a real person; - they should probably not be owned by `root'). - - 2. Run the shell script `configure'. This script was generated using - David MacKenzie's `autoconf' program. It takes a while to run. - It will generate a file `conf.h', and copy `Makefile.in' to - `Makefile' with substitions (specifically, it will replace all - words between `@' characters in `Makefile.in'). - - You can pass certain arguments to `configure' in the - environment. Because `configure' will compile and run little - test programs to see what is available on your system, you must - tell it how to run your compiler. It recognizes the following - environment variables: - - `CC' - The C compiler. If this is not set, then if `configure' can - find `gcc' it will use `gcc -O', otherwise it will use `cc'. - - `DEFS' - Flags to pass the C compiler during configuration testing. - If this is not set, `configure' will use the empty string. - - `CFLAGS' - Flags to pass to the C compiler when compiling the actual - code. If this is not set, `configure' will use `-g'. - - `LDFLAGS' - Flags to pass to the C compiler when only linking, not - compiling. If this is not set, `configure' will use the - empty string. - - `LIBS' - Libraries to pass to the C compiler. If this is not set, - `configure' will use the empty string. - - `INSTALL' - The program to run to install UUCP in the binary directory. - If `configure' finds the BSD `install' program, it will set - this to `install -c'; otherwise, it will use `cp'. - - `INSTALLDATA' - The program to run to install UUCP data files, such as the - man pages and the info pages. If `configure' finds the BSD - `install' program, it will set this to `install -c -m 644'; - otherwise, it will use `cp'. - - Suppose you want to set the environment variable `CC' to - `rcc'. If you are using `sh' or `bash', invoke `configure' as - `CC=rcc configure'. If you are using `csh', do `setenv CC rcc; - sh configure'. - - On some systems you will want to use `LIBS=-lmalloc'. On some - you will want `LIBS=-lsocket'. On Xenix derived systems do not - use `LIBS=-lx' because this will bring in the wrong versions of - certain routines; if you want to use `-lx' you must specify - `LIBS=-lc -lx'. - - If `configure' fails for some reason, or if you have a very - wierd system, you may have to configure the package by hand. To - do this, copy the file `conf.h-dist' to `conf.h' and edit it for - your system. Then copy `Makefile.in' to `Makefile', find the - words within `@' characters, and set them correctly for your - system. - - 3. You should verify that `configure' worked correctly by checking - the files `conf.h' and `Makefile'. - - 4. This package uses the `alloca' function. The `configure' script - will try to figure out how to make it work on your system. If - `alloca' cannot be found, a simplistic substitute from `alloca.c' - will be used. If you provide your own `alloca.o' file, it will - be used instead; you might, for example, use the one from the GNU - emacs distribution. If none of this makes any sense to you, - don't worry; everything will probably work fine. - - 5. Edit `policy.h' for your local system. The comments should - explain the various choices. The default values are intended to - be reasonable, so you may not have to make any changes. - - 6. Type `make' to compile everything. You may get warnings about - implicit function declarations; ignore these (if you think they - can be eliminated, and you really know what you are talking - about, you may tell me about them). You may also get warnings - about `getopt.c' (this is from the GNU library and I do not want - to change it) and about a variable not protected from `setjmp' in - `sys2.c' (the data flow ensures that this can never be a - problem). The `tstuu.c' file is not particularly portable; if - you can't figure out how to compile it you can safely ignore it, - as it is only used for testing. If you have any other problems - there is probably a bug in the `configure' script. - - 7. Please report any problems you have. That is the only way they - will get fixed for other people. Supply a patch if you can, or - just ask for help. - - -File: uucp.info, Node: Testing, Next: Installation, Prev: Compilation, Up: Overall Installation - -Testing Taylor UUCP -=================== - - This package is in use at many sites, and has been running at -`airs.com' for several months. However, it will doubtless fail in -some situations. Do not rely on this code until you have proven to -yourself that it will work. - - You can use the `uuchk' program to test your configuration files. -It will read them and print out a verbose description. This is -particularly important if you are using V2 or BNU configuration files, -because there may be bugs in how they are read. This program should -not be made suid, because it will display passwords if it can read -them. - - If your system supports BSD style pseudo-terminals, and you -compiled the code to support the new style of configuration files, you -should be able to use the `tstuu' program to test the `uucico' daemon. - Just type `tstuu' with no arguments while logged in to the compilation -directory (since it runs `./uucp', `./uux' and `./uucico') to run a -lengthy series of tests (it takes over ten minutes on a slow VAX). -You will need a fair amount of space available in `/usr/tmp'. You -will probably want to put it in the background. Do not use `^Z', -because the program traps on `SIGCHLD' and winds up dying. It will -create a directory `/usr/tmp/tstuu' and fill it with configuration -files, and create spool directories `/usr/tmp/tstuu/spool1' and -`/usr/tmp/tstuu/spool2'. - - The program will finish with an execute file `X.SOMETHING' and a -data file `D.SOMETHING' in `/usr/tmp/tstuu/spool1' (or, more likely, -in subdirectories, depending on the choice of `SPOOLDIR' in -`sysdep.h'). The log files `/usr/tmp/tstuu/Log1' and -`/usr/tmp/tstuu/Log2' (or, if you have selected `HAVE_BNU_LOGGING', -`/usr/tmp/tstuu/Log1/uucico/test2' and -`/usr/tmp/tstuu/Log2/uucico/test1') should look fairly normal. You -can test `uuxqt' by typing `./uuxqt -I /usr/tmp/tstuu/Config1'. This -should leave a command file `C.SOMETHING' and a data file -`D.SOMETHING' in `/usr/tmp/tstuu/spool1' or in subdirectories. Again, -there should be no errors in the log file. - - Assuming you compiled the code with debugging enabled, the `-x' -switch can be used to set debugging modes; see the `debug' command for -details (*note Debugging Levels::.). Use `-x all' to turn on all -debugging and generate far more output than you will ever want to see. - The `uucico' daemons will put debugging output in -`/usr/tmp/tstuu/Debug1' and `/usr/tmp/tstuu/Debug2'. At this point -you're pretty much on your own. - - On some systems you can also use `tstuu' to test my `uucico' -against the system `uucico', by using the `-u' switch. For this to -work, change the definitions of `ZUUCICO_CMD' and `UUCICO_EXECL' at -the top of `tstuu.c' to something appropriate for your system. The -definitions in `tstuu.c' are what I used for Ultrix 4.0, in which -`/usr/lib/uucp/uucico' is particularly obstinate about being run as a -child; I was only able to run it by creating a login name with no -password whose shell was `/usr/lib/uucp/uucico'. Calling login in -this way will leave fake entries in `wtmp' and `utmp'; if you compile -`tstout.c' (in the `contrib' directory) as an suid `root' program, -`tstuu' will run it to clear those entries out. On most systems, such -hackery should not be necessary, although on SCO I had to su to `root' -(`uucp' might also have worked) before I could run -`/usr/lib/uucp/uucico'. - - You can test `uucp' and `uux' (give them the `-r' switch to keep -them from starting `uucico') to make sure they create the right sorts -of files. Unfortunately if you don't know what the right sorts of -files are I'm not going to tell you here. - - If `tstuu' passes, or you can't run it for some reason or other, -move on to testing with some other system. Set up the configuration -files (*note Configuration files::.), or use an existing configuration. -Tell `uucico' to dial out to the system by using the `-s' system -switch (e.g. `uucico -s uunet'). The log file should tell you what -happens. - - If you compiled the code with debugging enabled, you can use -debugging mode to get a great deal of information about what sort of -data is flowing back and forth; the various possibilities are -described under the `debug' command (*note Debugging Levels::.). When -initially setting up a connection `-x chat' is probably the most -useful (e.g. `uucico -s uunet -x chat'); you may also want to use `-x -handshake,incoming,outgoing'. You can use `-x' multiple times on one -command line, or you can give it comma separated arguments as in the -last example. Use `-x all' to turn on all possible debugging -information. The debugging information is written to a file, normally -`/usr/spool/uucp/Debug' although the default can be changed in -`policy.h' and the configuration file can override the name with the -`debugfile' command. The debugging file may contain passwords and -some file contents as they are transmitted over the line, so the -debugging file is only readable by the `uucp' user. - - You can use the `-f' switch to force `uucico' to call out even if -the last call failed recently; using `-S' when naming a system has the -same effect. Otherwise the status file (in the `.Status' subdirectory -of the main spool directory, normally `/usr/spool/uucp') will prevent -too many attempts from occurring in rapid succession. - - Again, let me know about any problems you have and how you got -around them. - - -File: uucp.info, Node: Installation, Next: Usage, Prev: Testing, Up: Overall Installation - -Installing Taylor UUCP -====================== - - You can install by suing to `root' and typing `make install'. Or -you can look at what make install does and do it by hand. It tries to -preserve your old programs, if any. You can retrieve them by typing -`make uninstall'. - - -File: uucp.info, Node: Usage, Next: TCP, Prev: Installation, Up: Overall Installation - -Using Taylor UUCP -================= - - This package does not come with any fancy shell scripts or -scheduling programs. Maybe someday. If you have another package, you -may well be able to use the scheduling mechanisms it provides. - - Otherwise, the program can be used by making crontab entries. -Whenever you want to call all systems with outstanding work, use - - uucico -r1 - - Whenever you want to call a specific system `foo', use - - uucico -s foo - - If you want to make sure that a system foo gets retried if the -original call fails, create an empty work file for it. For example, -if using `SPOOLDIR_TAYLOR', - - touch /usr/spool/uucp/foo/C./C.A0000 - - If using `SPOOLDIR_BNU', use - - touch /usr/spool/uucp/foo/C.fooA0000 - - I use the following crontab entries locally: - - 45 * * * * /bin/echo /usr/lib/uucp/uucico -r1 | /bin/su uucpa - 40 4,10,15 * * * touch /usr/spool/uucp/uunet/C./C.A0000 - - Every hour, at 45 minutes past, this will check if there is any -work to be done. Also, at 4:40am, 10:40am and 3:40pm this will create -an empty work file for `uunet', forcing the next check to call `uunet'. - - You will also want to periodically trim the log files, which by -default are `/usr/spool/uucp/Log' and `/usr/spool/uucp/Stats'. The -`savelog' program in the `contrib' directory may be of use. - - -File: uucp.info, Node: TCP, Prev: Usage, Up: Overall Installation - -TCP together with Taylor UUCP -============================= - - If your system has a Berkeley style socket library, you can compile -the code to permit making connections over TCP. Specifying that a -system should be reached via TCP is easy, but nonobvious. - - If you are using the new style configuration files, see *Note -Configuration files::. Basically, you can just add the line `port -type tcp' to the entry in the system configuration file. By default -UUCP will get the port number by looking up `uucp' in `/etc/services'; -if `uucp' is not found, port 540 will be used. You can set the port -number to use with the command `port service XXX', where XXX can be -either a number or a name to look up in `/etc/services'. You can -specify the address of the remote host with `address A.B.C'; if you -don't give an address, the remote system name will be used. You -should give an explicit chat script for the system when you use TCP; -the default chat script begins with a carriage return, which will not -work with some UUCP TCP servers. - - If you are using V2 configuration files, add a line like this to -`L.sys': - - foo Any TCP uucp foo.domain chat-script - - This will make an entry for system foo, to be called at any time, -over TCP, using port number `uucp' (as found in `/etc/services'; this -may be specified as a number), using remote host `foo.domain', with -some chat script. - - If you are using BNU configuration files, add a line like this to -Systems: - - foo Any TCP - foo.domain chat-script - - and a line like this to Devices: - - TCP uucp - - - - You only need one line in Devices regardless of how many systems you -contact over TCP. This will make an entry for system foo, to be called -at any time, over TCP, using port number `uucp' (as found in -`/etc/services'; this may be specified as a number), using remote host -`foo.domain', with some chat script. - - The `uucico' daemon can also be run as a TCP server. This code -mostly works, but it's not perfect. I don't recommend investigating it -unless you are willing to tinker a bit. You will not be able to use -the default port number because `uucico' will not be running as `root' -and will therefore not be able to bind a reserved port. - - Basically, you must define a port, either using the port file -(*note port file::.) if you are using the new configuration method or -with an entry in Devices if you are using BNU; there is no way to -define a port using V2. If you are using BNU the port must be named -`TCP'; a line as shown above will suffice. You can then start -`uucico' as `uucico -p TCP' (after the `-p', name the port; in BNU it -must be `TCP'). This will wait for incoming connections, and fork off -a child for each one. Each connection will be prompted with `login:' -and `Password:'; the results will be checked against the UUCP (not the -system) password file (*note Configuration File Names::.). Of course, -you can get a similar effect by using the BSD `uucpd' program. - - You can also have `inetd' start up `uucico' with the `-l' switch, -which will cause it to prompt with `login:' and `Password:' and check -the results against the UUCP (not the system) password file. This may -be used in place of `uucpd'. - - -File: uucp.info, Node: Configuration Files, Next: Protocols, Prev: Overall Installation, Up: Top - -Taylor UUCP Configuration Files -******************************* - - This chapter describes the configuration files accepted by the -Taylor UUCP package if compiled with `HAVE_TAYLOR_CONFIG' defined in -`conf.h'. - - The configuration files are normally found in the directory -NEWCONFIGDIR, which is defined by the `Makefile' variable -`newconfigdir'; by default NEWCONFIGDIR is `/usr/local/lib/uucp'. -However, the main configuration file, `config', is the only one which -must be in that directory, since it may specify a different location -for any or all of the other files. You may run any of the UUCP -programs with a different main configuration file by using the `-I' -option; this can be useful when testing a new configuration. When you -use the `-I' option the programs will revoke their setuid privileges. - -* Menu: - -* Configuration File Format:: Configuration file format -* Configuration Examples:: Examples of configuration files -* Time Strings:: How to write time strings -* Chat Scripts:: How to write chat scripts -* config File:: The main configuration file -* sys File:: The system configuration file -* port File:: The port configuration files -* dial File:: The dialer configuration files -* Security:: Security issues - - -File: uucp.info, Node: Configuration File Format, Next: Configuration Examples, Prev: Configuration Files, Up: Configuration Files - -Configuration File Format -========================= - - All the configuration files follow a simple line-oriented `KEYWORD -VALUE' format. Empty lines are ignored, as are leading spaces; unlike -BNU, lines with leading spaces are read. The first word on each line -is a keyword. The rest of the line is interpreted according to the -keyword. Most keywords are followed by numbers, boolean values or -simple strings with no embedded spaces. - - The `#' character is used for comments. Everything from a `#' to -the end of the line is ignored unless the `#' is preceded by a `\' -(backslash); if the `#' is preceeded by a `\', the `\' is removed but -the `#' remains in the line. This can be useful for a phone number -containing a `#'. To enter the sequence `\#', you would use `\\#'. - - The backslash character may be used to continue lines. If the last -character in a line is a backslash, the backslash is removed and the -line is continued by the next line. The second line is attached to the -first with no intervening characters; if you want any whitespace -between the end of the first line and the start of the second line, -you must insert it yourself. - - However, the backslash is not a general quoting character. For -example, you cannot use it to get an embedded space in a string -argument. - - Everything after the keyword must be on the same line. A BOOLEAN -may be specified as `y', `Y', `t', or `T' for true and `n', `N', `f', -or `F' for false; any trailing characters are ignored, so `true', -`false', etc., are also acceptable. - - -File: uucp.info, Node: Configuration Examples, Next: Time Strings, Prev: Configuration File Format, Up: Configuration Files - -Examples of Configuration Files -=============================== - - All the configuration commands are explained in the following -sections. However, I'll start by giving a few examples of -configuration files. For a more complete description of any of the -commands used here see the appropriate section of this chapter. - -* Menu: - -* config File Examples:: Examples of the main configuration file -* Leaf Example:: Call a single remote site -* Gateway Example:: The gateway for several local systems - - -File: uucp.info, Node: config File Examples, Next: Leaf Example, Prev: Configuration Examples, Up: Configuration Examples - -config File Examples --------------------- - - To start with, here are some examples of uses of the main -configuration file, `config'. For a complete description of the -commands that are permitted in `config', see *Note config file::. - - In many cases you will not need to create a `config' file at all. -The most common reason to create one is to give your machine a special -UUCP name. Other reasons might be to change the UUCP spool directory -or to permit any remote system to call in. - - If you have an internal network of machines, then it is likely that -the internal name of your UUCP machine is not the name you want to use -when calling other systems. For example, here at `airs.com' our -mail/news gateway machine is named `elmer.airs.com' (it is one of -several machines all named `LOCALNAME.airs.com'). If we did not -provide a `config' file, then our UUCP name would be `elmer'; however, -we actually want it to be `airs'. Therefore, we use the following -line in `config': - - nodename airs - - The UUCP spool directory name is set in `policy.h' when the code is -compiled. You might at some point decide that it is appropriate to -move the spool directory, perhaps to put it on a different disk -partition. You might use the following commands in `config' to change -to directories on the partition `/uucp': - - spool /uucp/spool - pubdir /uucp/uucppublic - logfile /uucp/spool/Log - debugfile /uucp/spool/Debug - - You would then move the contents of the current spool directory to -`/uucp/spool'. If you do this, make sure that no UUCP processes are -running while you change `config' and move the spool directory. - - Suppose you wanted to permit any system to call in to your system -and request files. This is generally known as "anonymous UUCP", since -the systems which call in are effectively anonymous. By default, -unknown systems are not permitted to call in. To permit this you must -use the `unknown' command in `config'. The `unknown' command is -followed by any command that may appear in the system file; for full -details, see *Note sys file::. - - I will show two possible anonymous UUCP configurations. The first -will let any system call in and download files, but will not permit -them to upload files to your system. - - # No files may be transferred to this system - unknown request no - # The public directory is /usr/spool/anonymous - unknown pubdir /usr/spool/anonymous - # Only files in the public directory may be sent (the default anyhow) - unknown remote-send ~ - -Setting the public directory is convenient for the systems which call -in. It permits to request a file by prefixing it with `~/'. For -example, assuming your system is known as `server', then to retrieve -the file `/usr/spool/anonymous/INDEX' a user on a remote site could -just enter `uucp server!~/INDEX ~'; this would transfer `INDEX' from -`server''s public directory to the user's local public directory. -Note that when using `csh' or `bash' the `!' and the second `~' must -be quoted. - - The next example will permit remote systems to upload files to a -special directory `/usr/spool/anonymous/upload'. Permitting a remote -system to upload files permits it to send work requests as well; this -example is careful to prohibit commands from unknown systems. - - # No commands may be executed (the list of permitted commands is empty) - unknown commands - # The public directory is /usr/spool/anonymous - unknown pubdir /usr/spool/anonymous - # Only files in the public directory may be sent; users may not download - # files from the upload directory - unknown remote-send ~ !~/upload - # May only upload files into /usr/spool/anonymous/upload - unknown remote-receive ~/upload - - -File: uucp.info, Node: Leaf Example, Next: Gateway Example, Prev: config File Examples, Up: Configuration Examples - -Leaf Example ------------- - - A relatively common simple case is a "leaf site", a system which -only calls or is called by a single remote site. Here is a typical -`sys' file that might be used in such a case. For full details on -what commands can appear in the `sys' file, see *Note sys file::. - - This is the `sys' file that is used at `airs.com'. We use a single -modem to dial out to `uunet'. This example shows how you can specify -the port and dialer information directly in the `sys' file for simple -cases. It also shows the use of the following: - -`call-login' - Using `call-login' and `call-password' allows the default login - chat script to be used. In this case, the login name is specified - in the call-out login file (*note Configuration File Names::.). - -`call-timegrade' - `uunet' is requested to not send us news during the daytime. - -`chat-fail' - If the modem returns `BUSY' or `NO CARRIER' the call is - immediately aborted. - -`protocol-parameter' - Since `uunet' tends to be slow, the default timeout has been - increased. - - This `sys' file relies on certain defaults. It will allow `uunet' -to queue up `rmail' and `rnews' commands. It will allow users to -request files from `uunet' into the UUCP public directory. It will -also `uunet' to request files from the UUCP public directory; in fact -`uunet' never requests files, but for additional security we could add -the line `request false'. - - # The following information is for uunet - system uunet - - # The login name and password are kept in the callout password file - call-login * - call-password * - - # We can send anything at any time. - time any - - # During the day we only accept grade 'Z' or above; at other times - # (not mentioned here) we accept all grades. uunet queues up news - # at grade 'd', which is lower than 'Z'. - call-timegrade Z Wk0755-2305,Su1655-2305 - - # The phone number. - phone 7389449 - - # uunet tends to be slow, so we increase the timeout - chat-timeout 120 - - # We are using a preconfigured Telebit 2500. - port type modem - port device /dev/ttyd0 - port baud 19200 - port carrier true - port dialer chat "" ATZ\r\d\c OK ATDT\D CONNECT - port dialer chat-fail BUSY - port dialer chat-fail NO\sCARRIER - port dialer complete \d\d+++\d\dATH\r\c - port dialer abort \d\d+++\d\dATH\r\c - - # Increase the timeout and the number of retries. - protocol-parameter g timeout 20 - protocol-parameter g retries 10 - - -File: uucp.info, Node: Gateway Example, Prev: Leaf Example, Up: Configuration Examples - -Gateway Example ---------------- - - Many organizations have several local machines which are connected -by UUCP, and a single machine which connects to the outside world. -This single machine is often referred to as a "gateway" machine. - - For this example I will assume a fairly simple case. It should -still provide a good general example. There are three machines, -`elmer', `comton' and `bugs'. `elmer' is the gateway machine for -which I will show the configuration file. `elmer' calls out to -`uupsi'. As an additional complication, `uupsi' knows `elmer' as -`airs'; this will show how a machine can have one name on an internal -network but a different name to the external world. `elmer' has two -modems. It also has an TCP/IP connection to `uupsi', but since that -is supposed to be reserved for interactive work (it is, perhaps, only -a 9600 baud SLIP line) it will only use it if the modems are not -available. - - A network this small would normally use a single `sys' file. -However, for pedagogical purposes I will show two separate `sys' -files, one for the local systems and one for `uupsi'. This is done -with the `sysfile' command in the `config' file. Here is the `config' -file. - - # This is config - # The local sys file - sysfile /usr/local/lib/uucp/sys.local - # The remote sys file - sysfile /usr/local/lib/uucp/sys.remote - - Using the defaults feature of the `sys' file can greatly simplify -the listing of local systems. Here is `sys.local'. Note that this -assumes that the local systems are trusted; they are permited to -request any world readable file and to write files into any world -writable directory. - - # This is sys.local - # Get the login name and password to use from the call-out file - call-login * - call-password * - - # The systems must use a particular login - called-login Ulocal - - # Permit sending any world readable file - local-send / - remote-send / - - # Permit requesting into any world writable directory - local-receive / - remote-receive / - - # Call at any time - time any - - # Use port1, then port2 - port port1 - - alternate - - port port2 - - # Now define the systems themselves. Because of all the defaults we - # used, there is very little to specify for the systems themselves. - - system comton - phone 5551212 - - system bugs - phone 5552424 - - The `sys.remote' file describes the `uupsi' connection. The -`myname' command is used to change the UUCP name to `airs' when -talking to `uupsi'. - - # This is sys.remote - # Define uupsi - system uupsi - - # The login name and password are in the call-out file - call-login * - call-password * - - # We can call out at any time - time any - - # uupsi uses a special login name - called-login Uuupsi - - # uuspi thinks of us as `airs' - myname airs - - # The phone number - phone 5554848 - - # We use port2 first, then port1, then TCP - - port port2 - - alternate - - port port1 - - alternate - - # We don't bother to make a special entry in the port file for TCP, we - # just describe the entire port right here. We use a special chat - # script over TCP because the usual one confuses some TCP servers. - port type TCP - address uu.psi.com - chat ogin: \L word: \P - - The ports are defined in the file `port' (*note port file::.). For -this example they are both connected to the same type of 2400 baud -Hayes-compatible modem. - - # This is port - - port port1 - type modem - device /dev/ttyd0 - dialer hayes - speed 2400 - - port port2 - type modem - device /dev/ttyd1 - dialer hayes - speed 2400 - - Dialers are described in the `dial' file (*note dial file::.). - - # This is dial - - dialer hayes - - # The chat script used to dial the phone. \D is the phone number. - chat "" ATZ\r\d\c OK ATDT\D CONNECT - - # If we get BUSY or NO CARRIER we abort the dial immediately - chat-fail BUSY - chat-fail NO\sCARRIER - - # When the call is over we make sure we hangup the modem. - complete \d\d+++\d\dATH\r\c - abort \d\d+++\d\dATH\r\c - - -File: uucp.info, Node: Time Strings, Next: Chat Scripts, Prev: Configuration Examples, Up: Configuration Files - -Time Strings -============ - - Several commands use time strings to specify a range of times. This -section describes how to write time strings. - - A time string may be a list of simple time strings separated with a -vertical bar `|' or a command `,'. - - Each simple time string must begin with `Su', `Mo', `Tu', `We', -`Th', `Fr', or `Sa', or `Wk' for any weekday, or `Any' for any day. - - Following the day may be a range of hours separated with a hyphen -using 24 hour time. The range of hours may cross 0; for example -`2300-0700' means any time except 7 AM to 11 PM. If no time is given, -calls may be made at any time on the specified day(s). - - The time string may also consist of the single word `Never', which -does not match any time, or a single word with a name defined in a -previous `timetable' command (*note Miscellaneous (sys)::.). - - Here are a few sample time strings with an explanation of what they -mean. - -`Wk2305-0855,Sa,Su2305-1655' - This means weekdays before 8:55 AM or after 11:05 PM, any time - Saturday, or Sunday before 4:55 PM or after 11:05 PM. These are - approximately the times during which night rates apply to phone - calls in the U.S.A. Note that this time string uses, for - example, `2305' rather than `2300'; this will ensure a cheap rate - phone call even if the computer clock is running up to five - minutes ahead of the real time. - -`Wk0905-2255,Su1705-2255' - This means weekdays from 9:05 AM to 10:55 PM, or Sunday from 5:05 - PM to 10:55 PM. This is approximately the opposite of the - previous example. - -`Any' - Since no time is specified, this means any time on any day. - - \ No newline at end of file diff --git a/gnu/libexec/uucp/uucp.info-2 b/gnu/libexec/uucp/uucp.info-2 deleted file mode 100644 index ec224c203d30..000000000000 --- a/gnu/libexec/uucp/uucp.info-2 +++ /dev/null @@ -1,1142 +0,0 @@ -Info file uucp.info, produced by Makeinfo, -*- Text -*- from input -file uucp.texi. - - This file documents Taylor UUCP, version 1.03. - - Copyright (C) 1992 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 also -that the section entitled "Copying" are included exactly as in the -original, and 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 the section entitled "Copying" may be included -in a translation approved by the author instead of in the original -English. - - -File: uucp.info, Node: Chat Scripts, Next: config File, Prev: Time Strings, Up: Configuration Files - -Chat Scripts -============ - - Chat scripts are used in several different places, such as dialing -out on modems or logging in to remote systems. Chat scripts are made -up of pairs of strings. The program waits until it sees the first -string, known as the "expect" string, and then sends out the second -string, the "send" string. - - Each chat script is defined using a set of commands. These commands -always end in a string beginning with `chat', but may start with -different strings. For example, in the `sys' file there is one set of -commands beginning with `chat' and another set beginning with -`called-chat'. The prefixes are only used to disambiguate different -types of chat scripts, and this section ignores the prefixes when -describing the commands. - -`chat STRINGS' - Specify a chat script. The arguments to the `chat' command are - pairs of strings separated by whitespace. The first string of - each pair is an expect string, the second is a send string. The - program will wait for the expect string to appear; when it does, - the program will send the send string. If the expect string does - not appear within a certain number of seconds (as set by the - `chat-timeout' command) the chat script fails and, typically, the - call is aborted. If the final expect string is seen (and the - optional final send string has been sent), the chat script is - successful. - - An expect string may contain additional subsend and subexpect - strings, separated by hyphens. If the expect string is not seen, - the subsend string is sent and the chat script continues by - waiting for the subexpect string. This means that a hyphen may - not appear in an expect string; use `\055' instead. - - An expect string may simply be `""', meaning to skip the expect - phase. Otherwise, the following escape characters may appear in - expect strings: - - `\b' - a backspace character - - `\n' - a newline or line feed character - - `\N' - a null character (for BNU compatibility) - - `\r' - a carriage return character - - `\s' - a space character - - `\t' - a tab character - - `\\' - a backslash character - - `\DDD' - character DDD, where DDD are up to three octal digits - - `\xDDD' - character DDD, where DDD are hexadecimal digits. - - As in C, there may be up to three octal digits following a - backslash, but the hexadecimal escape sequence continues as far - as possible. To follow a hexadecimal escape sequence with a hex - digit, interpose a send string of `""'. - - A send string may also simply be `""' to skip the send phase. - Otherwise, all of the escape characters legal for expect strings - may be used, and the following escape characters are also - permitted: - - `EOT' - send an end of transmission character (`^D') - - `BREAK' - send a break character (may not work on all systems) - - `\c' - suppress trailing carriage return at end of send string - - `\d' - delay sending for 1 second - - `\e' - disable echo checking - - `\E' - enable echo checking (wait for echo before continuing) - - `\K' - same as `BREAK' (for BNU compatibility) - - `\p' - pause sending for a fraction of a second - - Some specific types of chat scripts also define additional escape - sequences that may appear in the send string. For example, the - login chat script defines `\L' and `\P' to send the login name and - password, respectively. - - A carriage return will be sent at the end of each send string, - unless the `\c' escape sequence appears in the string. Note that - some UUCP packages use `\b' for break, but here it means - backspace. - - Echo checking means that after writing each character the program - will wait until the character is echoed. Echo checking must be - turned on separately for each send string for which it is - desired; it will be turned on for characters following `\E' and - turned off for characters following `\e'. - -`chat-timeout NUMBER' - The number of seconds to wait for an expect string in the chat - script before timing out and sending the next subsend or failing - the chat script entirely. The default value is 10 for a login - chat or 60 for any other type of chat. - -`chat-fail STRING' - If the STRING is seen at any time during a chat script, the chat - script is aborted. The string may not contain any whitespace - characters; escape sequences must be used for them. Multiple - `chat-fail' commands may appear in a single chat script. The - default is to have none. - - This permits a chat script to be quickly aborted if an error - string is seen. For example, a script used to dial out on a - modem might use the command `chat-fail BUSY' to stop the chat - script immediately if the string `BUSY' was seen. - -`chat-seven-bit BOOLEAN' - If the argument is true, all incoming characters are stripped to - seven bits when being compared to the expect string. Otherwise - all eight bits are used in the comparison. The default is true - because some Unix systems generate parity bits during the login - prompt which must be ignored while running a chat script. This - has no effect on any `chat-program', which must ignore parity by - itself if necessary. - -`chat-program STRINGS' - Specify a program to run before executing the chat script. This - program could run its own version of a chat script, or it could - do whatever it wants. If both `chat-program' and `chat' are - specified, the program is executed first followed by the chat - script. - - The first argument to the `chat-program' command is the program - name to run. The remaining arguments are passed to the program. - The following escape sequences are recognized in the arguments: - - `\Y' - port device name - - `\S' - port speed - - `\\' - backslash - - Some specific uses of `chat-program' define additional escape - sequences. - - Arguments other than escape sequences are passed exactly as they - appear in the configuration file, except that sequences of - whitespace are compressed to a single space character; this - exception may be removed in the future. - - If the `chat-program' command is not used, no program is run. - - On Unix, the standard input and standard output of the program - will be attached to the port in use. Anything the program writes - to standard error will be written to the UUCP log file. No other - file descriptors will be open. If the program does not exit with - a status of 0, it will be assumed to have failed; this means that - the dialing programs used by some versions of BNU may not be used - directly, although of course a shell script could be used as an - interface. - - The program will be run as the `uucp' user, and the environment - will be that of the process that started `uucico', so care must be - taken to maintain security. - - No search path is used to find the program; a full path name must - be given. If the program is an executable shell script, it will - be passed to `/bin/sh' even on systems which are unable to - execute shell scripts. It is also easy to invoke `/bin/sh' - directly. - - Here is a simple example of a chat script that might be used to -reset a Hayes compatible modem. - - chat "" ATZ OK-ATZ-OK - - The first expect string is `""', so it is ignored. The chat script -then sends `ATZ'. If the modem responds with `OK', the chat script -finishes. If 60 seconds (the default timeout) pass before seeing -`OK', the chat script sends another `ATZ'. If it then sees `OK', the -chat script succeeds. Otherwise, the chat script fails. - - For a more complex chat script example, see *Note Logging In::. - - -File: uucp.info, Node: config File, Next: sys File, Prev: Chat Scripts, Up: Configuration Files - -The Main Configuration File -=========================== - - The main configuration file is named `config'. - - Since all the values that may be specified in the main configuration -file also have defaults, there need not be a main configuration file at -all. - -* Menu: - -* Miscellaneous (config):: Miscellaneous config file commands -* Configuration File Names:: Using different configuration files -* Log File Names:: Using different log files -* Debugging Levels:: Debugging levels - - -File: uucp.info, Node: Miscellaneous (config), Next: Configuration File Names, Prev: config File, Up: config File - -Miscellaneous config File Commands ----------------------------------- - -`nodename STRING' -`hostname STRING' -`uuname STRING' - These keywords are equivalent. They specify the UUCP name of the - local host. If there is no configuration file, an appropriate - function will be used to get the host name, if possible. - -`spool STRING' - Specify the spool directory. The default is from `policy.h'. - Command files, work files, temporary files, etc., are stored in - this directory and in subdirectories of it. - -`pubdir STRING' - Specify the public directory. The default is from `policy.h'. On - Unix, when a file is named using a leading `~/', it is taken from - or to the public directory. Each system may use a separate public - directory by using the `pubdir' command in the system - configuration file; see *Note Miscellaneous (sys)::. - -`unknown STRING ...' - The STRING and subsequent arguments are treated as though they - appeared in the system file (*note sys file::.). They are used - to apply to any unknown systems that may call in, probably to set - file transfer permissions and the like. If the `unknown' command - is not used, unknown systems are not permitted to call in. - -`max-uuxqts NUMBER' - Specify the maximum number of `uuxqt' processes which may run at - the same time. Having several `uuxqt' processes running at once - can significantly slow down a system, but since `uuxqt' is - automatically started by `uucico', it can happen quite easily. - The default for `max-uuxqts' is 0, which means that there is no - limit. If BNU configuration files are being read and the code - was compiled without `HAVE_TAYLOR_CONFIG', then if the file - `Maxuuxqts' in the configuration directory contains a readable - number it will be used as the value for `max-uuxqts'. - -`v2-files BOOLEAN' - If the code was compiled to be able to read V2 configuration - files, a false argument to this command will prevent them from - being read. This can be useful while testing. The default is - true. - -`bnu-files BOOLEAN' - If the code was compiled to be able to read BNU configuration - files, a false argument to this command will prevent them from - being read. This can be useful while testing. The default is - true. - - -File: uucp.info, Node: Configuration File Names, Next: Log File Names, Prev: Miscellaneous (config), Up: config File - -Configuration File Names ------------------------- - -`sysfile STRINGS' - Specify the system file(s). The default is the file `sys' in the - directory NEWCONFIGDIR. These files hold information about other - systems with which this system communicates; see *Note sys file::. - Multiple system files may be given on the line, and the `sysfile' - command may be repeated; each system file has its own set of - defaults. - -`portfile STRINGS' - Specify the port file(s). The default is the file `port' in the - directory NEWCONFIGDIR. These files describe ports which are used - to call other systems and accept calls from other systems; see - *Note port file::. No port files need be named at all. Multiple - port files may be given on the line, and the `portfile' command - may be repeated. - -`dialfile STRINGS' - Specify the dial file(s). The default is the file `dial' in the - directory NEWCONFIGDIR. These files describe dialing devices - (modems); *Note dial file::. No dial files need be named at all. - Multiple dial files may be given on the line, and the `dialfile' - command may be repeated. - -`dialcodefile STRINGS' - Specify the dialcode file(s). The default is the file `dialcode' - in the directory NEWCONFIGDIR. These files specify dialcodes that - may be used when sending phone numbers to a modem. This permits - using the same set of phone numbers in different area-codes or - with different phone systems, by using dialcodes to specify the - calling sequence. When a phone number goes through dialcode - translation, the leading alphabetic characters are stripped off. - The dialcode files are read line by line, just like any other - configuration file, and when a line is found whose first word is - the same as the leading characters from the phone number, the - second word on the line (which would normally consist of numbers) - replaces the dialcode in the phone number. No dialcode file need - be used. Multiple dialcode files may be specified on the line, - and the `dialcodefile' command may be repeated; all the dialcode - files will be read in turn until a dialcode is located. - -`callfile STRINGS' - Specify the call out login name and password file(s). The - default is the file `call' in the directory NEWCONFIGDIR. If the - call out login name or password for a system are given as `*' - (*note Logging In::.), these files are read to get the real login - name or password. Each line in the file(s) has three words: the - system name, the login name, and the password. This file is only - used when placing calls to remote systems; the password file - described under `passwdfile' below is used for incoming calls. - The intention of the call out file is to permit the system file - to be publically readable; the call out files must obviously be - kept secure. These files need not be used. Multiple call out - files may be specified on the line, and the `callfile' command - may be repeated; all the files will be read in turn until the - system is found. - -`passwdfile STRINGS' - Specify the password file(s) to use for login names when `uucico' - is doing its own login prompting, which it does when given the - `-e', `-l' or `-w' switch. The default is the file `passwd' in - the directory NEWCONFIGDIR. Each line in the file(s) has two - words: the login name and the password (e.g. `Ufoo foopas'). The - login name is accepted before the system name is known, so these - are independent of which system is calling in; a particular login - may be required for a system by using the `called-login' command - in the system file (*note Accepting a Call::.). These password - files are optional, although one must exist if `uucico' is to - present its own login prompts. Multiple password files may be - specified on the line, and the `passwdfile' command may be - repeated; all the files will be read in turn until the login name - is found. - - -File: uucp.info, Node: Log File Names, Next: Debugging Levels, Prev: Configuration File Names, Up: config File - -Log File Names --------------- - -`logfile STRING' - Name the log file. The default is from `policy.h'. Logging - information is written to this file. If `HAVE_BNU_LOGGING' is - defined in `conf.h', then by default a separate log file is used - for each system. Using this command to name a log file will - cause all the systems to use it. - -`statfile STRING' - Name the statistics file. The default is from `policy.h'. - Statistical information about file transfers is written to this - file. - -`debugfile STRING' - Name the file to which debugging information is written. The - default is from `policy.h'. This command is only effective if - the code has been compiled to include debugging (this is - controlled by the `DEBUG' variable in `policy.h'). After the - first debugging message has been written, messages written to the - log file are also written to the debugging file to make it easier - to keep the order of actions straight. The debugging file is - different from the log file because information such as passwords - can appear in it, so it must be not be publically readable. - - -File: uucp.info, Node: Debugging Levels, Prev: Log File Names, Up: config File - -Debugging Levels ----------------- - -`debug STRING ...' - Set the debugging level. This command is only effective if the - code has been compiled to include debugging. The default is to - have no debugging. The arguments are strings which name the - types of debugging to be turned on. The following types of - debugging are defined: - - `abnormal' - Output debugging messages for abnormal situations, such as - recoverable errors. - - `chat' - Output debugging messages for chat scripts. - - `handshake' - Output debugging messages for the initial handshake. - - `uucp-proto' - Output debugging messages for the UUCP protocol itself. - - `proto' - Output debugging messages for the individual protocols. - - `port' - Output debugging messages for actions on the communication - port. - - `config' - Output debugging messages while reading the configuration - files. - - `spooldir' - Output debugging messages for actions in the spool directory. - - `execute' - Output debugging messages whenever another program is - executed. - - `incoming' - List all incoming data in the debugging file. - - `outgoing' - List all outgoing data in the debugging file. - - `all' - All of the above. - - The debugging level may also be specified as a number. A 1 will - set `chat' debugging, a 2 will set both `chat' and `handshake' - debugging, and so on down the possibilities. Currently an 11 - will turn on all possible debugging, since there are 11 types of - debugging messages listed above; more debugging types may be - added in the future. The `debug' command may be used several - times in the configuration file; every debugging type named will - be turned on. When running any of the programs, the `-x' switch - (actually, for `uulog' it's the `-X' switch) may be used to turn - on debugging. The argument to the `-x' switch is one of the - strings listed above, or a number as described above, or a comma - separated list of strings (e.g. `-x chat,handshake'). The `-x' - switch may also appear several times on the command line, in - which case all named debugging types will be turned on. The `-x' - debugging is in addition to any debugging specified by the - `debug' command; there is no way to cancel debugging information. - The debugging level may also be set specifically for calls to or - from a specific system with the `debug' command in the system - file (*note Miscellaneous (sys)::.). - - The debugging messages are somewhat idiosyncratic; it may be - necessary to refer to the source code for additional information - in some cases. - - -File: uucp.info, Node: sys File, Next: port File, Prev: config File, Up: Configuration Files - -The System Configuration File -============================= - - By default there is a single system configuration, named `sys' in -the directory NEWCONFIGDIR. This may be overridden by the `sysfile' -command in the main configuration file; see *Note Configuration File -Names::. - - These files describe all remote systems known to the UUCP package. - -* Menu: - -* Defaults and Alternates:: Using defaults and alternates -* Naming the System:: Naming the system -* Calling Out:: Calling out -* Accepting a Call:: Accepting a call -* Protocol Selection:: Protocol selection -* File Transfer Control:: File transfer control -* Miscellaneous (sys):: Miscellaneous sys file commands -* Default sys File Values:: Default values - - -File: uucp.info, Node: Defaults and Alternates, Next: Naming the System, Prev: sys File, Up: sys File - -Defaults and Alternates ------------------------ - - The first set of commands in the file, up to the first `system' -command, specify defaults to be used for all systems in that file. -Each system file uses a different set of defaults. - - Subsequently, each set of commands from `system' up to the next -`system' command describe a particular system. Default values may be -overridden for specific systems. - - Each system may then have a series of alternate choices to use when -calling out or calling in. The first set of commands for a particular -system, up to the first `alternate' command, provide the first choice. - Subsequently, each set of commands from `alternate' up to the next -`alternate' command describe an alternate choice for calling out or -calling in. - - When a system is called, the commands before the first `alternate' -are used to select a phone number, port, and so forth; if the call -fails for some reason, the commands between the first `alternate' and -the second are used, and so forth. Well, not quite. Actually, each -succeeding alternate will only be used if it is different in some -relevant way (different phone number, different chat script, etc.). If -you want to force the same alternate to be used again (to retry a phone -call more than once, for example), enter the phone number (or any other -relevant field) again to make it appear different. - - The alternates can also be used to give different permissions to an -incoming call based on the login name. This will only be done if the -first set of commands, before the first `alternate' command, uses the -`called-login' command. The list of alternates will be searched, and -the first alternate with a matching `called-login' command will be -used. If no alternates match, the call will be rejected. - - The `alternate' command may also be used in the file-wide defaults -(the set of commands before the first `system' command). This might -be used to specify a list of ports which are available for all systems -(for an example of this, see *Note Gateway Example::) or to specify -permissions based on the login name used by the remote system when it -calls in. The first alternate for each system will default to the -first alternate for the file-wide defaults (as modified by the -commands used before the first `alternate' command for this system), -the second alternate for each system to the second alternate for the -file-wide defaults (as modified the same way), and so forth. If a -system specifies more alternates than the file-wide defaults, the -trailing ones will default to the last file-wide default alternate. If -a system specifies fewer alternates than the file-wide defaults, the -trailing file-wide default alternates will be used unmodified. The -`default-alternates' command may be used to modify this behaviour. - - This can all get rather confusing, although it's easier to use than -to describe concisely; the `uuchk' program may be used to ensure that -you are getting what you want. - - -File: uucp.info, Node: Naming the System, Next: Calling Out, Prev: Defaults and Alternates, Up: sys File - -Naming the System ------------------ - -`system STRING' - Specify the remote system name. Subsequent commands up to the - next `system' command refer to this system. - -`alternate [STRING]' - Start an alternate set of commands (*note Defaults and - Alternates::.). An optional argument may be used to name the - alternate. This name will be put in the log file if the - alternate is used to call the system. There is no way to name - the first alternate (the commands before the first `alternate' - command). - -`default-alternates BOOLEAN' - If the argument is false, any remaining default alternates (from - the defaults specified at the top of the current system file) - will not be used. The default is true. - -`alias STRING' - Specify an alias for the current system. The alias may be used - by local `uucp' and `uux' commands. The default is to have no - aliases. - -`myname STRING' - Specifies a different system name to use when calling the remote - system. Also, if `called-login' is used and is not `ANY', then, - when a system logs in with that login name, STRING is used as the - system name. Because the local system name must be determined - before the remote system has identified itself, using `myname' and - `called-login' together for any system will set the local name for - that login; this means that each locally used system name must - have a unique login name associated with it. This allows a - system to have different names for an external and an internal - network. The default is to not use a special local name. - - -File: uucp.info, Node: Calling Out, Next: Accepting a Call, Prev: Naming the System, Up: sys File - -Calling Out ------------ - - This section describes commands used when placing a call to another -system. - -* Menu: - -* When to Call:: When to call -* Placing the Call:: Placing the call -* Logging In:: Logging in - - -File: uucp.info, Node: When to Call, Next: Placing the Call, Prev: Calling Out, Up: Calling Out - -When to Call -............ - -`time STRING [NUMBER]' - Specify when the system may be called. The first argument is a - time string; see *Note Time Strings::. The optional second - argument specifies a retry time in minutes. If a call made - during a time that matches the time string fails, no more calls - are permitted until the retry time has passed. By default an - exponentially increasing retry time is used: after each failure - the next retry period is longer. A retry time specified in the - `time' command is always a fixed amount of time. - - The `time' command may appear multiple times in a single - alternate, in which case if any time string matches the system - may be called. The default time string is `Never'. - -`timegrade CHARACTER STRING [NUMBER]' - The CHARACTER specifies a grade. It must be a single letter or - digit. The STRING is a time string (*note Time Strings::.). All - jobs of grade CHARACTER or higher (where `0' > `9' > `A' > `Z' > - `a' > `z') may be run at the specified time. An ordinary `time' - command is equivalent to using `timegrade' with a grade of `z', - permitting all jobs. If there are no jobs of a sufficiently high - grade according to the time string, the system will not be - called. Giving the `-s' switch to `uucico' to force it to call a - system causes it to assume there is a job of grade `0' waiting to - be run. - - The optional third argument specifies a retry time in minutes. - See the `time' command, above, for more details. - - Note that the `timegrade' command serves two purposes: 1) if there - is no job of sufficiently high grade the system will not be - called, and 2) if the system is called anyway (because the `-s' - switch was given to `uucico') only jobs of sufficiently high - grade will be transferred. However, if the other system calls - in, the `timegrade' commands are ignored, and jobs of any grade - may be transferred (but see `call-timegrade' below). Also, the - `timegrade' command will not prevent the other system from - transferring any job it chooses, regardless of who placed the - call. - - The `timegrade' command may appear multiple times without using - `alternate'. If this command does not appear, there are no - restrictions on what grade of work may be done at what time. - -`call-timegrade CHARACTER STRING' - The CHARACTER is a single character `A' to `Z', `a' to `z', or - `0' to `9' and specifies a grade. The STRING is a time string as - described under the `time' command. If a call is placed to the - other system during a time which matches the time string, the - remote system will be requested to only run jobs of grade - CHARACTER or higher. Unfortunately, there is no way to guarantee - that the other system will obey the request (this UUCP package - will, but there are others which will not); moreover job grades - are historically somewhat arbitrary, so specifying a grade will - only be meaningful if the other system cooperates in assigning - grades. This grade restriction only applies when the other - system is called, not when the other system calls in. - - The `call-timegrade' command may appear multiple times without - using `alternate'. If this command does not appear, or if none of - the time strings match, the remote system will be allowed to send - whatever grades of work it chooses. - - -File: uucp.info, Node: Placing the Call, Next: Logging In, Prev: When to Call, Up: Calling Out - -Placing the Call -................ - -`baud NUMBER' -`speed NUMBER' - Specify the speed (the term "baud" is technically incorrect, but - widely understood) at which to call the system. This will try all - available ports with that baud rate until an unlocked port is - found. The ports are defined in the port file. If both `baud' - and `port' commands appear, both are used when selecting a port. - To allow calls at more than one baud rate, the `alternate' command - must be used (*note Defaults and Alternates::.). If this command - does not appear, there is no default; the baud rate may be - specified in the port file, but if it is not then the natural - baud rate of the port will be used (whatever that means on the - system). Specifying an explicit baud rate of 0 will request the - natural baud rate of the port, overriding any default baud rate - from the defaults at the top of the file. - -`port STRING' - Name a particular port or type of port to use when calling the - system. The information for this port is obtained from the port - file. If this command does not appear, there is no default; a - port must somehow be specified in order to call out (it may be - specified implicitly using the `baud' command or explicitly using - the next version of `port'). There may be many ports with the - same name; each will be tried in turn until an unlocked one is - found which matches the desired baud rate. - -`port STRING ...' - If more than one string follows the `port' command, the subsequent - strings are treated as commands that might appear in the port file - (*note port file::.). If a port is named (by using a single - string following `port') these commands are ignored; their - purpose is to permit defining the port completely in the system - file rather than always requiring entries in two different files. - In order to call out, a port must be specified using some - version of the `port' command, or by using the `baud' command to - select ports from the port file. - -`phone STRING' -`address STRING' - Give a phone number to call (when using a modem port) or a remote - host to contact (when using a TCP port). The commands `phone' and - `address' are equivalent, but are intended to be more mnemonic - depending on the type of port in use. - - When used with a modem port, an `=' character in the phone number - means to wait for a secondary dial tone (although only some modems - support this); a `-' character means to pause while dialing for 1 - second (again, only some modems support this). If the system has - more than one phone number, each one must appear in a different - alternate. The `phone' command must appear in order to call out - on a modem; there is no default. - - When used with a TCP port, the string names the host to contact. - It may be a domain name or a numeric Internet address. If no - address is specified, the system name is used. - - When used with a port that neither is a modem nor TCP, this - command is ignored. - - -File: uucp.info, Node: Logging In, Prev: Placing the Call, Up: Calling Out - -Logging In -.......... - -`chat STRINGS' -`chat-timeout NUMBER' -`chat-fail STRING' -`chat-seven-bit BOOLEAN' -`chat-program STRINGS' - These commands describe a chat script to use when logging on to a - remote system. Chat scripts are explained in *Note Chat - Scripts::. - - Two additional escape sequences may be used in send strings. - - `\L' - Send the login name, as set by the `call-login' command. - - `\P' - Send the passowrd, as set by the `call-password' command. - - Three additional escape sequences may be used with the - `chat-program' command. These are `\L' and `\P', which become - the login name and password, respectively, and `\Z', which - becomes the name of the system of being called. - - The default chat script is: - - chat "" \r\c ogin:-BREAK-ogin:-BREAK-ogin: \L word: \P - - This will send a carriage return (the `\c' suppresses the - additional trailing carriage return that would otherwise be sent) - and waits for the string `ogin:' (which would be the last part of - the `login:' prompt supplied by a Unix system). If it doesn't - see `ogin:', it sends a break and waits for `ogin:' again. If it - still doesn't see `ogin:', it sends another break and waits for - `ogin:' again. If it still doesn't see `ogin:', the chat script - aborts and hangs up the phone. If it does see `ogin:' at some - point, it sends the login name (as specified by the `call-login' - command) followed by a carriage return (since all send strings - are followed by a carriage return unless `\c' is used) and waits - for the string `word:' (which would be the last part of the - `Password:' prompt supplied by a Unix system). If it sees - `word:', it sends the password and a carriage return, completing - the chat script. The program will then enter the handshake phase - of the UUCP protocol. - - This chat script will work for most systems, so you will only be - required to use the `call-login' and `call-password' commands. - In fact, in the file-wide defaults you could set defaults of - `call-login *' and `call-password *'; you would then just have to - make an entry for each system in the call-out login file. - - Some systems seem to flush input after the `login:' prompt, so - they may need a version of this chat script with a `\d' before the - `\L'. When using UUCP over TCP, some servers will not be handle - the initial carriage return sent by this chat script; in this - case you may have to specify the simple chat script `ogin: \L - word: \P'. - -`call-login STRING' - Specify the login name to send with `\L' in the chat script. If - the string is `*' (e.g. `call-login *') the login name will be - fetched from the call out login name and password file (*note - Configuration File Names::.). There is no default. - -`call-password STRING' - Specify the password to send with `\P' in the chat script. If the - string is `*' (e.g. `call-password *') the password will be - fetched from the call-out login name and password file (*note - Configuration File Names::.). There is no default. - - -File: uucp.info, Node: Accepting a Call, Next: Protocol Selection, Prev: Calling Out, Up: sys File - -Accepting a Call ----------------- - -`called-login STRINGS' - The first STRING specifies the login name that the system must use - when calling in. If it is `ANY' (e.g. `called-login ANY') any - login name may be used; this is useful to override a file-wide - default and to indicate that future alternates may have different - login names. Case is significant. The default value is `ANY'. - - Different alternates (*note Defaults and Alternates::.) may use - different `called-login' commands, in which case the login name - will be used to select which alternate is in effect; this will - only work if the first alternate (before the first `alternate' - command) uses the `called-login' command. - - Additional strings may be specified after the login name; they - are a list of which systems are permitted to use this login name. - If this feature is used, then normally the login name will only - be given in a single `called-login' command. Only systems which - appear on the list, or which use an explicit `called-login' - command, will be permitted to use that login name. If the same - login name is used more than once with a list of systems, all the - lists are concatenated together. This feature permits you to - restrict a login name to a particular set of systems without - requiring you to use the `called-login' command for every single - system; you can achieve a similar effect by using a different - system file for each permitted login name with an appropriate - `called-login' command in the file-wide defaults. - -`callback BOOLEAN' - If BOOLEAN is true, then when the remote system calls `uucico' - will hang up the connection and prepare to call it back. This is - false by default. - -`called-chat STRINGS' -`called-chat-timeout NUMBER' -`called-chat-fail STRING' -`called-chat-seven-bit BOOLEAN' -`called-chat-program STRINGS' - These commands may be used to define a chat script (*note Chat - Scripts::.) that is run whenever the local system is called by - the system being defined. The chat script defined by the `chat' - command (*note Logging In::.), on the other hand, is used when - the remote system is called. This called chat script might be - used to set special modem parameters that are appropriate to a - particular system. It is run after protocol negotiation is - complete, but before the protocol has been started. See *Note - Logging In:: for additional escape sequence which may be used - besides those defined for all chat scripts. There is no default - called chat script. If the called chat script fails, the - incoming call will be aborted. - - -File: uucp.info, Node: Protocol Selection, Next: File Transfer Control, Prev: Accepting a Call, Up: sys File - -Protocol Selection ------------------- - -`protocol STRING' - Specifies which protocols to use for the other system, and in - which order to use them. This would not normally be used. For - example, `protocol tfg'. - - The default depends on the characteristics of the port and the - dialer, as specified by the `seven-bit' and `reliable' commands. - If neither the port nor the dialer use either of these commands, - the default is to assume an eight-bit reliable connection. The - commands `seven-bit true' or `reliable false' might be used in - either the port or the dialer to change this. Each protocol has - particular requirements that must be met before it will be - considered during negotiation with the remote side. - - The `t' and `e' protocols are intended for use over TCP or some - other communication path with end to end reliability, as they do - no checking of the data at all. They will only be considered on - a TCP port which is both reliable and eight bit. - - The `g' protocol is robust, but requires an eight-bit connection. - - The `f' protocol is intended for use with X.25 connections; it - checksums each file as a whole, so any error causes the entire - file to be retransmitted. It requires a reliable connection, but - only uses seven-bit transmissions. It is a streaming protocol, - so, while it can be used on a serial port, the port must be - completely reliable and flow controlled; many aren't. - - The protocols will be considered in the order shown above. This - means that if neither the `seven-bit' nor the `reliable' command - are used, the `t' protocol will be used over a TCP connection and - the `g' protocol will be used over any other type of connection - (subject, of course, to what is supported by the remote system; - it may be assumed that all systems support the `g' protocol). - - Note that currently specifying both `seven-bit true' and - `reliable false' will not match any protocol. If this occurs - through a combination of port and dialer specifications, you will - have to use the `protocol' command for the system or no protocol - will be selected at all (the only reasonable choice would be - `protocol f'). - - A protocol list may also be specified for a port (*note port - file::.), but if there is a list for the system the list for the - port is ignored. - -`protocol-parameter CHARACTER STRING ...' - CHARACTER is a single character specifying a protocol. The - remaining strings are a command specific to that protocol which - will be executed if that protocol is used. A typical command is - something like `window 7'. The particular commands are protocol - specific. - - The `g' protocol supports the following commands, all of which - take numeric arguments: - - `window' - The window size to request the remote system to use. This - must be between 1 and 7 inclusive. The default is 7. - - `packet-size' - The packet size to request the remote system to use. This - must be a power of 2 between 32 and 4096 inclusive. The - default is 64, which is the only packet size supported by - many older UUCP packages. Some UUCP packages will even dump - core if a larger packet size is requested. - - `startup-retries' - The number of times to retry the initialization sequence. - The default is 8. - - `init-retries' - The number of times to retry one phase of the initialization - sequence (there are three phases). The default is 4. - - `init-timeout' - The timeout in seconds for one phase of the initialization - sequence. The default is 10. - - `retries' - The number of times to retry sending either a data packet or - a request for the next packet. The default is 6. - - `timeout' - The timeout in seconds when waiting for either a data packet - or an acknowledgement. The default is 10. - - `garbage' - The number of unrecognized bytes to permit before dropping - the connection. This must be larger than the packet size. - The default is 10000. - - `errors' - The number of errors (malformed packets, out of order - packets, bad checksums, or packets rejected by the remote - system) to permit before dropping the connection. The - default is 100. - - `remote-window' - If this is between 1 and 7 inclusive, the window size - requested by the remote system is ignored and this is used - instead. This can be useful when dealing with some poor - UUCP packages. The default is 0, which means that the - remote system's request is honored. - - `remote-packet-size' - If this is between 32 and 4096 inclusive the packet size - requested by the remote system is ignored and this is used - instead. There is probably no good reason to use this. The - default is 0, which means that the remote system's request - is honored. - - The `f' protocol is intended for use with error-correcting modems - only; it checksums each file as a whole, so any error causes the - entire file to be retransmitted. It supports the following - commands, both of which take numeric arguments: - - `timeout' - The timeout in seconds before giving up. The default is 120. - - `retries' - How many times to retry sending a file. The default is 2. - - The `t' and `e' protocols are intended for use over TCP or some - other communication path with end to end reliability, as they do - no checking of the data at all. They both support a single - command, which takes a numeric argument: - - `timeout' - The timeout in seconds before giving up. The default is 120. - - The protocol parameters are reset to their default values after - each call. - - -File: uucp.info, Node: File Transfer Control, Next: Miscellaneous (sys), Prev: Protocol Selection, Up: sys File - -File Transfer Control ---------------------- - -`call-request BOOLEAN' - The BOOLEAN is checked when the local system places the call. It - determines whether the remote system may request any file - transfers. The default is yes. - -`called-request BOOLEAN' - The BOOLEAN is checked when the remote system calls in. It - determines whether the remote system may request any file - transfers. The default is yes. - -`request BOOLEAN' - Equivalent to specifying both `call-request BOOLEAN' and - `called-request BOOLEAN'. - -`call-transfer BOOLEAN' - The BOOLEAN is checked when the local system places the call. It - determines whether the local system may do file transfers queued - up for the remote system. The default is yes. - -`called-transfer BOOLEAN' - The BOOLEAN is checked when the remote system calls in. It - determines whether the local system may do file transfers queued - up for the remote system. The default is yes. - -`transfer BOOLEAN' - Equivalent to specifying both `call-transfer BOOLEAN' - `called-transfer BOOLEAN'. - -`call-local-size NUMBER STRING' - The STRING is a time string (*note Time Strings::.). The NUMBER - is the size in bytes of the largest file that should be - transferred at a time matching the time string if the local system - placed the call and the request was made by the local system. - This command may appear multiple times in a single alternate. If - this command does not appear, or if none of the time strings - match, there are no size restrictions. - - With all the size control commands, the size of a file from the - remote system (as opposed to a file from the local system) will - only be checked if the other system is running this package; - other UUCP packages will not understand a maximum size request, - nor will they inform this package of the size of remote files. - -`call-remote-size NUMBER STRING' - Specify the size in bytes of the largest file that should be - transferred at a given time by remote request when the local - system placed the call. This command may appear multiple times - in a single alternate. If this command does not appear, there - are no size restrictions. - -`called-local-size NUMBER STRING' - Specify the size in bytes of the largest file that should be - transferred at a given time by local request when the remote - system placed the call. This command may appear multiple times - in a single alternate. If this command does not appear, there are - no size restrictions. - -`called-remote-size NUMBER STRING' - Specify the size in bytes of the largest file that should be - transferred at a given time by remote request when the remote - system placed the call. This command may appear multiple times - in a single alternate. If this command does not appear, there are - no size restrictions. - -`local-send STRINGS' - Specifies that files in the directories named by the STRINGS may - be sent to the remote system when requested locally (using `uucp' - or `uux'). The directories in the list should be separated by - whitespace. A `~' may be used for the public directory. On a - Unix system, this is typically `/usr/spool/uucppublic'; the public - directory may be set with the `pubdir' command. Here is an - example of `local-send': - - local-send ~ /usr/spool/ftp/pub - - Listing a directory allows all files within the directory and all - subdirectories to be sent. Directories may be excluded by - preceding them with an exclamation point. For example: - - local-send /usr/ftp !/usr/ftp/private ~ - - means that all files in `/usr/ftp' or the public directory may be - sent, except those files in `/usr/ftp/private'. The list of - directories is read from left to right, and the last directory to - apply takes effect; this means that directories should be listed - from top down. The default is the root directory (i.e., any file - at all may be sent by local request). - -`remote-send STRINGS' - Specifies that files in the named directories may be sent to the - remote system when requested by the remote system. The default - is `~'. - -`local-receive STRINGS' - Specifies that files may be received into the named directories - when requested by a local user. The default is `~'. - -`remote-receive STRINGS' - Specifies that files may be received into the named directories - when requested by the remote system. The default is `~'. On - Unix, the remote system may only request that files be received - into directories that are writeable by the world, regardless of - how this is set. - - \ No newline at end of file diff --git a/gnu/libexec/uucp/uucp.info-3 b/gnu/libexec/uucp/uucp.info-3 deleted file mode 100644 index 618fd745d3ce..000000000000 --- a/gnu/libexec/uucp/uucp.info-3 +++ /dev/null @@ -1,1194 +0,0 @@ -Info file uucp.info, produced by Makeinfo, -*- Text -*- from input -file uucp.texi. - - This file documents Taylor UUCP, version 1.03. - - Copyright (C) 1992 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 also -that the section entitled "Copying" are included exactly as in the -original, and 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 the section entitled "Copying" may be included -in a translation approved by the author instead of in the original -English. - - -File: uucp.info, Node: Miscellaneous (sys), Next: Default sys File Values, Prev: File Transfer Control, Up: sys File - -Miscellaneous sys File Commands -------------------------------- - -`sequence BOOLEAN' - If BOOLEAN is true, then conversation sequencing is automatically - used for the remote system, so that if somebody manages to spoof - as the remote system, it will be detected the next time the - remote system actually calls. This is false by default. - -`command-path STRING' - Specifies the path (a list of whitespace separated directories) - to be searched to locate commands to execute. This is only used - for commands requested by `uux', not for chat programs. The - default is from `policy.h'. - -`commands STRINGS' - The list of commands which the remote system is permitted to - execute locally. For example: `commands rnews rmail'. If the - value is `ALL' (case significant), all commands may be executed. - The default is `rnews rmail'. - -`free-space NUMBER' - Specify the minimum amount of file system space (in bytes) to - leave free after receiving a file. If the incoming file will not - fit, it will be rejected. This will only work when talking to - another instance of this package, since older UUCP packages do - not provide the file size of incoming files. There is no - provision for reserving space, so it is still possible for - multiple `uucico' daemons to use up all available file space; a - sufficiently large value for `free-space' will avoid this problem - to some extent. The default is from `policy.h'. Not all systems - may be able to provide the amount of available space. - -`pubdir STRING' - Specifies the public directory that is used when `~' is specifed - in a file transfer or a list of directories. This essentially - overrides the public directory specified in the main - configuration file for this system only. The default is the - public directory specified in the main configuration file (which - defaults to a value from `policy.h'). - -`debug STRING ...' - Set additional debugging for calls to or from the system. This - may be used to debug a connection with a specific system. It is - particularly useful when debugging incoming calls, since - debugging information will be generated whenever the call comes - in. See the `debug' command in the main configuration file - (*note Debugging Levels::.) for more details. The debugging - information specified here is in addition to that specified in - the main configuration file or on the command line. - -`max-remote-debug STRING ...' - When the system calls in, it may request that the debugging level - be set to a certain value. This command may be used to put a - limit on the debugging level which the system may request, to - avoid filling up the disk with debugging information. Only the - debugging types named in the `max-remote-debug' command may be - turned on by the remote system. To prohibit any debugging, use - `max-remote-debug none'. The default is - `abnormal,chat,handshake'; to turn off these default entries, you - must use `max-remote-debug none' followed by other - `max-remote-debug' commands specifying the settings you want. - -`timetable STRING STRING' - This is actually not specific to a system; it can appear anywhere - in the file(s). In a future release this command will probably - be moved to the main configuration file. - - The `timetable' defines a timetable that may be used in - subsequently appearing time strings; *Note Time Strings::. The - first string names the timetable entry; the second is a time - string. - - The following `timetable' commands are predefined. The NonPeak - timetable is included for compatibility. It originally described - the offpeak hours of Tymnet and Telenet, but both have since - changed their schedules. - - timetable Evening Wk1705-0755,Sa,Su - timetable Night Wk2305-0755,Sa,Su2305-1655 - timetable NonPeak Wk1805-0655,Sa,Su - - If this command does not appear, then obviously no additional - timetables will be defined. - - -File: uucp.info, Node: Default sys File Values, Prev: Miscellaneous (sys), Up: sys File - -Default sys File Values ------------------------ - - The following are used as default values for all systems; they can -be considered as appearing before the start of the file. - - timetable Evening Wk1705-0755,Sa,Su - timetable Night Wk2305-0755,Sa,Su2305-1655 - timetable NonPeak Wk1805-0655,Sa,Su - time Never - chat "" \r\c ogin:-BREAK-ogin:-BREAK-ogin: \L word: \P - chat-timeout 10 - callback n - sequence n - request y - transfer y - local-send / - remote-send ~ - local-receive ~ - remove-receive ~ - command-path [ from `policy.h' ] - commands rnews rmail - max-remote-debug abnormal,chat,handshake - - -File: uucp.info, Node: port File, Next: dial File, Prev: sys File, Up: Configuration Files - -The Port Configuration File -=========================== - - The port files may be used to name and describe ports. The first -command in each file must be `port'. All command up to the next -`port' command then describe that port. There are different types of -ports; each type supports its own set of commands. Each command -indicates which types of ports support it. There may be many ports -with the same name; if a system requests a port by name then each port -with that name will be tried until an unlocked one is found. - -`port STRING' - Introduces and names a port. - -`type STRING' - Define the type of port. The default is `modem'. If this command - appears, it must immediately follow the `port' command. The type - defines what commands are subsequently allowed. Currently the - types are: - - `modem' - For a modem hookup. - - `stdin' - For a connection through standard input and standard output, - as when `uucico' is run as a login shell. - - `direct' - For a direct connection to another system. - - `tcp' - For a connection using TCP. - -`protocol STRING' - Specify a list of protocols to use for this port. This is just - like the corresponding command for a system (*note Protocol - Selection::.). A protocol list for a system takes precedence - over a list for a port. - -`protocol-parameter CHARACTER STRINGS [ any type ]' - The same command as the `protocol-parameter' command used for - systems (*note Protocol Selection::.). This one takes precedence. - -`seven-bit BOOLEAN [ any type ]' - This is only used during protocol negotiation; if the argument is - `true', it forces the selection of a protocol which works across a - seven-bit link. It does not prevent eight bit characters from - being transmitted. The default is `false'. - -`reliable BOOLEAN [ any type ]' - This is only used during protocol negotiation; if the argument is - `false', it forces the selection of a protocol which works across - an unreliable communication link. The default is `true'. It - would be more common to specify this for a dialer rather than a - port. - -`device STRING [ modem and direct only ]' - Names the device associated with this port. If the device is not - named, the port name is taken as the device. Device names are - system dependent, but a Unix example would be `/dev/ttyd0'. - -`baud NUMBER [ modem and direct only ]' -`speed NUMBER [modem and direct only ]' - The speed this port runs at. If a system specifies a speed but - no port name, then all ports which match the speed will be tried - in order. If the speed is not specified here and is not - specified by the system, the natural speed of the port will be - used by default. - -`baud-range NUMBER NUMBER [ modem only ]' -`speed-range NUMBER NUMBER [ modem only ]' - Specify a range of speeds this port can run at. The first number - is the minimum speed, the second number is the maximum speed. - These numbers will be used when matching a system which specifies - a desired speed. The simple `speed' (or `baud') command is still - used to determine the speed to run at if the system does not - specify a speed. For example, the command `speed-range 300 - 19200' means that the port will match any system which uses a - speed from 300 to 19200 baud (and will use the speed specified by - the system); this could be combined with `speed 2400', which - means that when this port is used with a system that does not - specify a speed, the port will be used at 2400 baud. - -`carrier BOOLEAN [ modem only ]' - The argument indicates whether the port supports carrier. If it - does not, carrier will never be required on this port, regardless - of what the modem chat script indicates. The default is `true'. - -`dial-device STRING [ modem only ]' - Dialing instructions should be output to the named device, rather - than to the normal port device. The default is to output to the - normal port device. - -`dialer STRING [ modem only ]' - Name a dialer to use. The information is looked up in the dialer - file. There is no default. Some sort of dialer information must - be specified to call out on a modem. - -`dialer STRING ... [ modem only ]' - Execute a dialer command. If a dialer is named (by using the - first form of this command, described just above), these commands - are ignored. They may be used to specify dialer information - directly in simple situations without needing to go to a separate - file. There is no default. Some sort of dialer information must - be specified to call out on a modem. - -`dialer-sequence STRINGS [ modem only ]' - Name a sequence of dialers and tokens (phone numbers) to use. - The first argument names a dialer, and the second argument names - a token. The third argument names another dialer, and so on. If - there are an odd number of arguments, the phone number specified - with a `phone' command in the system file is used as the final - token. The token is what is used for `\D' or `\T' in the dialer - chat script. If the token in this string is `\D', the system - phone number will be used; if it is `\T', the system phone number - will be used after undergoing dialcodes translation. A missing - final token is taken as `\D'. - - This command currently does not work if `dial-device' is - specified; to handle this correctly will require a more - systematic notion of chat scripts. Moreover, only the `complete' - and `abort' chat scripts from the first dialer specified are - used, and only the protocol parameters from the first dialer are - used. - -`lockname STRING [ modem and direct only ]' - Give the name to use when locking this port. On Unix, this is - the name of the file that will be created in the lock directory. - It is used as is, so on Unix it should generally start with - `LCK..'. For example, if a single port were named both - `/dev/ttycu0' and `/dev/tty0' (perhaps with different - characteristics keyed on the minor device number), then the - command `lockname LCK..ttycu0' could be used to force the latter - to use the same lock file name as the former. - -`service STRING [ tcp only ]' - Name the TCP port number to use. This may be a number. If not, - it will be looked up in `/etc/services'. If this is not - specified, the string `uucp' is looked up in `/etc/services'. If - it is not found, port number 540 (the standard UUCP-over-TCP port - number) will be used. - - -File: uucp.info, Node: dial File, Next: Security, Prev: port File, Up: Configuration Files - -The Dialer Configuration File -============================= - - The dialer configuration files define dialers. The first command in -each file must be a `dialer' command, which names the dialer. -Subsequent commands up to the next `dialer' command are associated -with the named dialer. - -`dialer STRING' - Introduces and names a dialer. - -`chat STRINGS' -`chat-timeout NUMBER' -`chat-fail STRING' -`chat-seven-bit BOOLEAN' -`chat-program STRINGS' - Specify a chat script to be used to dial the phone. See *Note - Chat Scripts:: for full details on chat scripts. - - Taylor UUCP will sleep for one second between attempts to dial - out on a modem. If your modem requires a longer wait period, you - must start your chat script with delays (`\d' in a send string). - - The chat script will be read from and sent to the port specified - by the `dial-device' command for the port, if there is one. - - The following escape addition escape sequences may appear in send - strings: - - `\D' - send phone number without dialcode translation - - `\T' - send phone number with dialcode translation - - `\M' - do not require carrier - - `\m' - require carrier (fail if not present) - - See the description of the dialcodes file (*note Configuration - File Names::.) for a description of dialcode translation. If the - port does not support carrier (as set by the `carrier' command in - the port file) `\M' and `\m' are ignored. If both the port and - the dialer support carrier (as set by the `carrier' command in - the port file and the `carrier' command in the dialer file), then - every chat script implicitly begins with `\M' and ends with `\m'. - There is no default chat script for dialers. - - The following additional escape sequences may be used in - `chat-program': - - `\D' - phone number without dialcode translation - - `\T' - phone number with dialcode translation - - If the program changes the port in any way (e.g., sets parity) the - changes will be preserved during protocol negotiation, but once - the protocol is selected it will change the port settings. - -`dialtone STRING' - A string to output when dialing the phone number which causes the - modem to wait for a secondary dial tone. This is used to - translate the `=' character in a phone number. The default is a - comma. - -`pause STRING' - A string to output when dialing the phone number which causes the - modem to wait for 1 second. This is used to translate the `-' - character in a phone number. The default is a comma. - -`carrier BOOLEAN' - If the argument is `true', the dialer supports the modem carrier - signal. After the phone number is dialed, `uucico' will require - that carrier be on. One some systems, it will be able to wait - for it. If the argument is `false', carrier will not be - required. The default is `true'. - -`carrier-wait NUMBER' - If the port is supposed to wait for carrier, this may be used to - indicate how many seconds to wait. The default is 60 seconds. - Only some systems support waiting for carrier. - -`dtr-toggle BOOLEAN BOOLEAN' - If the first argument is `true', then DTR is toggled before using - the modem. This is only supported on some systems and some - ports. The second BOOLEAN need not be present; if it is, and it - is `true', the program will sleep for 1 second after toggling DTR. - The default is not to toggle DTR. - -`complete-chat STRINGS' -`complete-chat-timeout NUMBER' -`complete-chat-fail STRING' -`complete-chat-seven-bit BOOLEAN' -`complete-chat-program STRINGS' - These commands define a chat script (*note Chat Scripts::.) which - is run when a call is finished normally. This allows the modem - to be reset. There is no default. No additional escape - sequences may be used. - -`complete STRING' - This is a simple use of `complete-chat'. It is equivalent to - `complete-chat "" STRING'; this has the effect of sending STRING - to the modem when a call finishes normally. - -`abort-chat STRINGS' -`abort-chat-timeout NUMBER' -`abort-chat-fail STRING' -`abort-chat-seven-bit BOOLEAN' -`abort-chat-program STRINGS' - These commands define a chat script (*note Chat Scripts::.) to be - run when a call is aborted. They may be used to interrupt and - reset the modem. There is no default. No additional escape - sequences may be used. - -`abort STRING' - This is a simple use of `abort-chat'. It is equivalent to - `abort-chat "" STRING'; this has the effect of sending STRING to - the modem when a call is aborted. - -`protocol-parameter CHARACTER STRINGS' - Set protocol parameters, just like the `protocol-parameter' - command in the system configuration file or the port - configuration file; see *Note Protocol Selection::. These - parameters take precedence, then those for the port, then those - for the system. - -`seven-bit BOOLEAN' - This is only used during protocol negotiation; if it is `true', it - forces selection of a protocol which works across a seven-bit - link. It does not prevent eight bit characters from being - transmitted. The default is `false'. It would be more common to - specify this for a port than for a dialer. - -`reliable BOOLEAN' - This is only used during protocol negotiation; if it is `false', - it forces selection of a protocol which works across an unreliable - communication link. The default is `true'. - - -File: uucp.info, Node: Security, Prev: dial File, Up: Configuration Files - -Security -======== - - This discussion of UUCP security applies only to Unix. It is a bit -cursory; suggestions for improvement are solicited. - - UUCP is traditionally not very secure. Taylor UUCP addresses some -security issues, but is still far from being a secure system. - - If security is very important to you, then you should not permit any -external access to your computer, including UUCP. Any opening to the -outside world is a potential security risk. - - By default Taylor UUCP provides few mechanisms to secure local -users of the system from each other. You can allow increased security -by putting the owner of the UUCP programs (normally `uucp') into a -separate group; the use of this is explained in the following -paragraphs, which refer to this separate group as `uucp-group'. - - When the `uucp' program is invoked to copy a file to a remote -system, it will by default copy the file into the UUCP spool directory. -When the `uux' program is used, the `-C' switch must be used to copy -the file into the UUCP spool directory. In any case, once the file -has been copied into the spool directory, other local users will not -be able to access it. In version 1.03 there is a security hole in -that for the file to be copied it must be readable by `uucp'. -Changing the group of the file to `uucp-group' and making it group -readable will permit UUCP to read it without granting access to other -users. - - When a file is requested from a remote system, UUCP will only -permit it to be placed in a directory which is writable by the -requesting user. The directory must also be writable by UUCP. A -local user can create a directory with a group of `uucp-group' and set -the mode to permit group write access. This will allow the file be -requested without permitting it to be viewed by any other user. - - There is no provision for security for `uucp' requests (as opposed -to `uux' requests) made by a user on a remote system. A file sent -over by a remote request may only be placed in a directory which is -world writable, and the file will be world readable and writable. This -will permit any local user to destroy or replace the contents of the -file. A file requested by a remote system must be world readable, and -the directory it is in must be world readable. Any local user will be -able to examine, although not necessarily modify, the file before it is -sent. - - There are some security holes and race conditions that apply to the -above discussion which I will not elaborate on. They are not hidden -from anybody who reads the source code, but they are somewhat technical -and difficult (but scarcely impossible) to exploit. Suffice it to say -that even under the best of conditions UUCP is not completely secure. - - For many sites, security from remote sites is a more important -consideration. Fortunately, Taylor UUCP does provide some support in -this area. - - The greatest security is provided by always dialing out to the other -site. This prevents anybody from pretending to be the other site. Of -course, only one side of the connection can do this. - - If remote dialins must be permitted, then it is best if the dialin -line is used only for UUCP. If this is the case, then you should -create a call-in password file (*note Configuration File Names::.) and -let `uucico' do its own login prompting. For example, to let remote -sites log in on a port named `entry' in the port file (*note port -file::.) you might invoke `uucico -p entry'. This would cause -`uucico' to enter an endless loop of login prompts and daemon -executions. The advantage of this approach is that even if remote -users break into the system by guessing or learning the password, they -will only be able to do whatever `uucico' permits them to do. They -will not be able to start a shell on your system. - - If remote users can dial in and log on to your system, then you -have a security hazard more serious than that posed by UUCP. But -then, you probably knew that already. - - Once your system has connected with the remote UUCP, there is a fair -amount of control you can exercise. You can use the `remote-send' and -`remote-receive' commands to control the directories the remote UUCP -can access. You can use the `request' command to prevent the remote -UUCP from making any requests of your system at all; however, if you -do this it will not even be able to send you mail or news. If you do -permit remote requests, you should be careful to restrict what -commands may be executed at the remote system's request. The default -is `rmail' and `rnews', which will suffice for most systems. - - If different remote systems call in and they must be granted -different privileges (perhaps some systems are within the same -organization and some are not) then the `called-login' command should -be used for each system to require that they different login names. -Otherwise it would be simple for a remote system to use the `myname' -command and pretend to be a different system. The `sequence' command -can be used to detect when one system pretended to be another, but -since the sequence numbers must be reset manually after a failed -handshake this can sometimes be more trouble than it's worth. - - -File: uucp.info, Node: Protocols, Next: Hacking, Prev: Configuration Files, Up: Top - -UUCP protocol internals -*********************** - - This chapter describes how the various UUCP protocols work, and -discusses some other internal UUCP issues. - - This chapter is quite technical. You do not need to understand it, -or even read it, in order to use Taylor UUCP. It is intended for -people who are interested in how UUCP code works. - - Most of the discussion covers the protocols used by all UUCP -packages, not just Taylor UUCP. Any information specific to Taylor -UUCP is indicated as such. There are some pointers to the actual -functions in the Taylor UUCP source code, for those who are extremely -interested in actual UUCP implementation. - -* Menu: - -* Grades:: UUCP grades -* Lock Files:: UUCP lock file format -* UUCP Protocol:: The common UUCP protocol -* g Protocol:: The UUCP `g' protocol -* f Protocol:: The UUCP `f' protocol -* t Protocol:: The UUCP `t' protocol -* e Protocol:: The UUCP `e' protocol -* x Protocol:: The UUCP `x' protocol -* d Protocol:: The UUCP `d' protocol -* Capital G Protocol:: The UUCP `G' protocol -* Documentation References:: Documentation references - - -File: uucp.info, Node: Grades, Next: Lock Files, Prev: Protocols, Up: Protocols - -UUCP Grades -=========== - - Modern UUCP packages support grades for each command. The grades -generally range from `A' (the highest) to `Z' followed by `a' to `z'. -Taylor UUCP also supports `0' to `9' before `A'. Some UUCP packages -may permit any ASCII character as a grade. - - On Unix, these grades are encoded in the name of the command file. -A command file name generally has the form - - C.nnnngssss - -where NNNN is the remote system name for which the command is queued, -G is a single character grade, and SSSS is a four character sequence -number. For example, a command file created for the system `airs' at -grade `Z' might be named - - C.airsZ2551 - - The remote system name will be truncated to seven characters, to -ensure that the command file name will fit in the 14 character file -name limit of the traditional Unix file system. UUCP packages which -have no other means of distinguishing which command files are intended -for which systems thus require all *systems they connect to* to have -names that are unique in the first seven characters. Some UUCP -packages use a variant of this format which truncates the system name -to six characters. BNU uses a different spool directory format, which -allows up to fourteen characters to be used for each system name. The -Taylor UUCP spool directory format is configurable. The new Taylor -spool directory format permits system names to be as long as file -names; the maximum length of a file name depends on the particular -Unix file system being used. - - The sequence number in the command file name may be a decimal -integer, or it may be a hexadecimal integer, or it may contain any -alphanumeric character. Different UUCP packages are different. - - Taylor UUCP creates command files in the function -`zsysdep_spool_commands'. The file name is constructed by the -function `zsfile_name', which knows about all the different types of -spool directories supported by Taylor UUCP. The Taylor UUCP sequence -number can contain any alphanumeric character; the next sequence number -is determined by the function `fscmd_seq'. - - I do not know how command grades are handled in non-Unix UUCP -packages. - - Modern UUCP packages allow you to restrict file transfer by grade -depending on the time of day. Typically this is done with a line in -the `Systems' (or `L.sys') file like this: - - airs Any/Z,Any2305-0855 ... - - This allows only grades `Z' and above to be transferred at any -time. Lower grades may only be transferred at night. I believe that -this grade restriction applies to local commands as well as to remote -commands, but I am not sure. It may only apply if the UUCP package -places the call, not if it is called by the remote system. Taylor UUCP -can use the `timegrade' and `call-timegrade' commands (*note When to -Call::.) to achieve the same effect (and supports the above format -when reading `Systems' or `L.sys'). - - This sort of grade restriction is most useful if you know what -grades are being used at the remote site. The default grades used -depend on the UUCP package. Generally `uucp' and `uux' have different -defaults. A particular grade can be specified with the `-g' option to -`uucp' or `uux'. For example, to request execution of rnews on airs -with grade `d', you might use something like - - uux -gd - airs!rnews
= 128', let `b2' be the second byte in the data field. - Then there are `l - ((b1 & 0x7f) + (b2 << 7))' valid bytes of data - in the data field, beginning with the third byte. In all cases - `l' bytes of data are sent (and all data bytes participate in the - checksum calculation) but some of the trailing bytes may be - dropped by the receiver. The XXX and YYY fields are described - below. - - In a data packet (short or not) the XXX field gives the sequence -number of the packet. Thus sequence numbers can range from 0 to 7, -inclusive. The YYY field gives the sequence number of the last -correctly received packet. - - Each communication direction uses a window which indicates how many -unacknowledged packets may be transmitted before waiting for an -acknowledgement. The window may range from 1 to 7 packets, and may be -different in each direction. For example, if the window is 3 and the -last packet acknowledged was packet number 6, packet numbers 7, 0 and 1 -may be sent but the sender must wait for an acknowledgement before -sending packet number 2. This acknowledgement could come as the YYY -field of a data packet or as the YYY field of a `RJ' or `RR' control -packet (described below). - - Each packet must be transmitted in order (the sender may not skip -sequence numbers). Each packet must be acknowledged, and each packet -must be acknowledged in order. - - In a control packet, the XXX field takes on the following values: - -1 `CLOSE' - The connection should be closed immediately. This is typically - sent when one side has seen too many errors and wants to give up. - It is also sent when shutting down the protocol. If an - unexpected `CLOSE' packet is received, a `CLOSE' packet should be - sent in reply and the `g' protocol should halt, causing UUCP to - enter the final handshake. - -2 `RJ' or `NAK' - The last packet was not received correctly. The YYY field - contains the sequence number of the last correctly received - packet. - -3 `SRJ' - Selective reject. The YYY field contains the sequence number of a - packet that was not received correctly, and should be - retransmitted. This is not used by UUCP, and most - implementations will not recognize it. Taylor UUCP will - recognize it but not generate it. - -4 `RR' or `ACK' - Packet acknowledgement. The YYY field contains the sequence - number of the last correctly received packet. - -5 `INITC' - Third initialization packet. The YYY field contains the maximum - window size to use. - -6 `INITB' - Second initialization packet. The YYY field contains the packet - size to use. It requests a size of 2 ** (YYY + 5). Note that - this is not the same coding used for the K byte in the packet - header (it is 1 less). Some UUCP implementations can handle any - packet size up to that specified; some can only handled exactly - the size specified. Taylor UUCP will always accept any packet - size. - -7 `INITA' - First initialization packet. The YYY field contains the maximum - window size to use. - - To compute the checksum, call the control byte (the fifth byte in -the header) `c'. - - The checksum of a control packet is simply `0xaaaa - c'. - - The checksum of a data packet is `0xaaaa - (CHECK ^ c)' (`^' -denotes exclusive or, as in C), and `CHECK' is the result of the -following routine run on the contents of the data field (every byte in -the data field participates in the checksum, even for a short data -packet). Below is the routine used by Taylor UUCP; it is a slightly -modified version of a routine which John Gilmore patched from G.L. -Chesson's original paper. The `z' argument points to the data and the -`c' argument indicates how much data there is. - - int - igchecksum (z, c) - register const char *z; - register int c; - { - register unsigned int ichk1, ichk2; - - ichk1 = 0xffff; - ichk2 = 0; - - do - { - register unsigned int b; - - /* Rotate ichk1 left. */ - if ((ichk1 & 0x8000) == 0) - ichk1 <<= 1; - else - { - ichk1 <<= 1; - ++ichk1; - } - - /* Add the next character to ichk1. */ - b = *z++ & 0xff; - ichk1 += b; - - /* Add ichk1 xor the character position in the buffer - counting from the back to ichk2. */ - ichk2 += ichk1 ^ c; - - /* If the character was zero, or adding it to ichk1 - caused an overflow, xor ichk2 to ichk1. */ - if (b == 0 || (ichk1 & 0xffff) < b) - ichk1 ^= ichk2; - } - while (--c > 0); - - return ichk1 & 0xffff; - } - - When the `g' protocol is started, the calling UUCP sends an INITA -control packet with the window size it wishes the called UUCP to use. -The called UUCP responds with an INITA packet with the window size it -wishes the calling UUCP to use. Pairs of INITB and INITC packets are -then similarly exchanged. When these exchanges are completed, the -protocol is considered to have been started. The window size is sent -twice, with both the INITA and the INITC packets. - - When a UUCP package transmits a command, it sends one or more data -packets. All the data packets will normally be complete, although some -UUCP packages may send the last one as a short packet. The command -string is sent with a trailing null byte, to let the receiving package -know when the command is finished. Some UUCP packages require the last -byte of the last packet sent to be null, even if the command ends -earlier in the packet. Some packages may require all the trailing -bytes in the last packet to be null, but I have not confirmed this. - - When a UUCP package sends a file, it will send a sequence of data -packets. The end of the file is signalled by a short data packet -containing zero valid bytes (it will normally be preceeded by a short -data packet containing the last few bytes in the file). - - Note that the sequence numbers cover the entire communication -session, including both command and file data. - - When the protocol is shut down, each UUCP package sends a `CLOSE' -control packet. - - -File: uucp.info, Node: f Protocol, Next: t Protocol, Prev: g Protocol, Up: Protocols - -The UUCP `f' Protocol -===================== - - The `f' protocol is a seven bit protocol which checksums an entire -file at a time. It only uses the characters between \040 and \176 -(ASCII space and `~') inclusive as well as the carriage return -character. It can be very efficient for transferring text only data, -but it is very inefficient at transferring eight bit data (such as -compressed news). It is not flow controlled, and the checksum is -fairly insecure over large files, so using it over a serial connection -requires handshaking (`XON'/`XOFF' can be used) and error correcting -modems. Some people think it should not be used even under those -circumstances. - - I believe the `f' protocol originated in BSD versions of UUCP. It -was originally intended for transmission over X.25 PAD links. - - The Taylor UUCP code for the `f' protocol is in `protf.c'. - - The `f' protocol has no startup or finish protocol. However, both -sides typically sleep for a couple of seconds before starting up, -because they switch the terminal into `XON'/`XOFF' mode and want to -allow the changes to settle before beginning transmission. - - When a UUCP package transmits a command, it simply sends a string -terminated by a carriage return. - - When a UUCP package transmits a file, each byte b of the file is -translated according to the following table: - - 0 <= b <= 037: 0172, b + 0100 (0100 to 0137) - 040 <= b <= 0171: b ( 040 to 0171) - 0172 <= b <= 0177: 0173, b - 0100 ( 072 to 077) - 0200 <= b <= 0237: 0174, b - 0100 (0100 to 0137) - 0240 <= b <= 0371: 0175, b - 0200 ( 040 to 0171) - 0372 <= b <= 0377: 0176, b - 0300 ( 072 to 077) - - That is, a byte between \040 and \171 inclusive is transmitted as -is, and all other bytes are prefixed and modified as shown. - - When all the file data is sent, a seven byte sequence is sent: two -bytes of \176 followed by four ASCII bytes of the checksum as printed -in base 16 followed by a carriage return. For example, if the -checksum was 0x1234, this would be sent: "\176\1761234\r". - - The checksum is initialized to 0xffff. For each byte that is sent -it is modified as follows (where `b' is the byte before it has been -transformed as described above): - - /* Rotate the checksum left. */ - if ((ichk & 0x8000) == 0) - ichk <<= 1; - else - { - ichk <<= 1; - ++ichk; - } - - /* Add the next byte into the checksum. */ - ichk += b; - - When the receiving UUCP sees the checksum, it compares it against -its own calculated checksum and replies with a single character -followed by a carriage return. - -`G' - The file was received correctly. - -`R' - The checksum did not match, and the file should be resent from the - beginning. - -`Q' - The checksum did not match, but too many retries have occurred - and the communication session should be abandoned. - - The sending UUCP checks the returned character and acts accordingly. - - -File: uucp.info, Node: t Protocol, Next: e Protocol, Prev: f Protocol, Up: Protocols - -The UUCP `t' Protocol -===================== - - The `t' protocol is intended for TCP links. It does no error -checking or flow control, and requires an eight bit clear channel. - - I believe the `t' protocol originated in BSD versions of UUCP. - - The Taylor UUCP code for the `t' protocol is in `prott.c'. - - When a UUCP package transmits a command, it first gets the length -of the command string, C. It then sends ((C / 512) + 1) * 512 bytes -(the smallest multiple of 512 which can hold C bytes plus a null byte) -consisting of the command string itself followed by trailing null -bytes. - - When a UUCP package sends a file, it sends it in blocks. Each block -contains at most 1024 bytes of data. Each block consists of four bytes -containing the amount of data in binary (most significant byte first, -the same format as used by the Unix function `htonl') followed by that -amount of data. The end of the file is signalled by a block -containing zero bytes of data. - - -File: uucp.info, Node: e Protocol, Next: x Protocol, Prev: t Protocol, Up: Protocols - -The UUCP `e' Protocol -===================== - - The `e' protocol is similar to the `t' protocol. It does no flow -control or error checking and is intended for use over TCP. - - The `e' protocol originated in versions of BNU UUCP. - - The Taylor UUCP code for the `e' protocol is in `prote.c'. - - When a UUCP package transmits a command, it simply sends the -command as an ASCII string terminated by a null byte. - - When a UUCP package transmits a file, it sends the complete size of -the file as an ASCII decimal number. The ASCII string is padded out -to 20 bytes with null bytes (i.e., if the file is 1000 bytes long, it -sends `1000\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'). It then sends the -entire file. - - -File: uucp.info, Node: x Protocol, Next: d Protocol, Prev: e Protocol, Up: Protocols - -The UUCP `x' Protocol -===================== - - I believe that the `x' protocol was intended for use over X.25 -virtual circuits. It relies on a write of zero bytes being read as -zero bytes without stopping communication. I have heard that it does -not work correctly. If someone would care to fill this in more, I -would be grateful. Taylor UUCP does not implement the `x' protocol. - - -File: uucp.info, Node: d Protocol, Next: Capital G Protocol, Prev: x Protocol, Up: Protocols - -The UUCP `d' Protocol -===================== - - This is apparently used for DataKit connections, and relies on a -write of zero bytes being read as zero bytes, much as the `x' protocol -does. I don't really know anything else about it. Taylor UUCP does -not implement the `d' protocol. - - -File: uucp.info, Node: Capital G Protocol, Next: Documentation References, Prev: d Protocol, Up: Protocols - -The UUCP `G' Protocol -===================== - - The `G' protocol is apparently simply the `g' protocol, except that -it is known to support all possible window and packet sizes. It was -introduced by SVR4 UUCP; the SVR4 implementation of the `g' protocol -is apparently fixed at a packet size of 64 and a window size of 7. -Taylor UUCP does not recognize the `G' protocol. It does support all -window and packet sizes for the `g' protocol. - - -File: uucp.info, Node: Documentation References, Prev: Capital G Protocol, Up: Protocols - -Documentation References -======================== - - I took a lot of the information from Jamie E. Hanrahan's paper in -the Fall 1990 DECUS Symposium, and from Managing UUCP and Usenet by Tim -O'Reilly and Grace Todino (with contributions by several other people). -The latter includes most of the former, and is published by O'Reilly & -Associates, Inc. - - Some information is originally due to a Usenet article by Chuck -Wegrzyn. The information on the `g' protocol comes partially from a -paper by G.L. Chesson of Bell Laboratories, partially from Jamie E. -Hanrahan's paper, and partially from source code by John Gilmore. The -information on the `f' protocol comes from the source code by Piet -Berteema. The information on the `t' protocol comes from the source -code by Rick Adams. The information on the `e' protocol comes from a -Usenet article by Matthias Urlichs. - - -File: uucp.info, Node: Hacking, Next: Acknowledgements, Prev: Protocols, Up: Top - -Hacking Taylor UUCP -******************* - - This chapter provides the briefest of guides to the Taylor UUCP -source code itself. - -* Menu: - -* System Dependence:: System Dependence -* Naming Conventions:: Naming Conventions -* Patches:: Patches - - -File: uucp.info, Node: System Dependence, Next: Naming Conventions, Prev: Hacking, Up: Hacking - -System Dependence -================= - - The code is carefully segregated into a system independent portion -and a system dependent portion. The system dependent code is in -`sys?.*' and `tcp.c'. Note that `sysh.*' is included as `sysdep.h'. -Currently the only system dependent files are for Unix, and the file -name for all of them ends in `.unx'. Hopefully the code will -eventually be ported to other systems. - - With the right configuration parameters, the system independent code -calls only ANSI C functions. Some of the less common ANSI C functions -are also provided in `util.c'. The replacement function `strtol' in -`util.c' assumes that the characters `A' to `F' and `a' to `f' appear -in strictly sequential order. The function `igradecmp' in `config.c' -assumes that the upper and lower case letters appear in order. Both -assumptions are true for ASCII and EBCDIC, but neither is guaranteed -by ANSI C. The replacement function `memmove' in `util.c' assumes -that two arbitrary pointers may be safely compared. Disregarding -these caveats, I believe that the system independent portion of the -code is strictly conforming. - - That's not too exciting, since all the work is done in the system -dependent code. I think that this code can conform to POSIX 1003.1, -given the right compilation parameters. I'm a bit less certain about -this, though. - - The code is in use on a 16 bit segmented system with no function -prototypes, so I'm certain that all casts to long and pointers are done -when necessary. - - The code uses alloca extensively. It comes with a simple -replacement, in `alloca.c' (otherwise I would lost ANSI C conformance, -after all). Using a real `alloca' function will be considerably more -efficient. It will also cause significant stack usage, which may be a -problem on systems without virtual memory. - - -File: uucp.info, Node: Naming Conventions, Next: Patches, Prev: System Dependence, Up: Hacking - -Naming Conventions -================== - - I use a modified Hungarian naming convention for my variables and -functions. As with all naming conventions, the code is rather opaque -if you are not familiar with it, but becomes clear and easy to use with -time. - - The first character indicates the type of the variable (or function -return value). Sometimes additional characters are used. I use the -following type prefixes: - -`a' - array; the next character is the type of an element - -`b' - byte or character - -`c' - count of something - -`e' - stdio FILE * - -`f' - boolean - -`i' - generic integer - -`l' - double - -`o' - file descriptor (as returned by open, creat, etc.) - -`p' - generic pointer - -`q' - pointer to structure - -`s' - structure - -`u' - void (function return values only) - -`z' - character string - - A generic pointer ('p') is sometimes a `void *', sometimes a -function pointer in which case the prefix is pf, and sometimes a -pointer to another type, in which case the next character is the type -to which it points (pf is overloaded). - - An array of strings (`char *[]') would be named `az' (array of -string). If this array were passed to a function, the function -parameter would be named `paz' (pointer to array of string). - - Note that the variable name prefixes do not necessarily indicate the -type of the variable. For example, a variable prefixed with i may be -int, long or short. Similarly, a variable prefixed with b may be a -char or an int; for example, the return value of getchar would be -caught in an int variable prefixed with b. - - For a non-local variable (extern or file static), the first -character after the type prefix is capitalized. - - Most static variables and functions use another letter after the -type prefix to indicate which module they come from. This is to help -distinguish different names in the debugger. For example, all static -functions in `protg.c', the `g' protocol source code, use a module -prefix of `g'. This isn't too useful, as a number of modules use a -module prefix of `s'. - - -File: uucp.info, Node: Patches, Prev: Naming Conventions, Up: Hacking - -Patches -======= - - I am always grateful for any patches sent in. Much of the -flexibility and portability of the code is due to other people. -Please do not hesitate to send me any changes you have found necessary -or useful. - - I rarely apply the patches directly. Instead I work my way through -them and apply each one separately. This ensures that the naming -remains consistent and that I understand all the code. - - -File: uucp.info, Node: Acknowledgements, Next: Index (concepts), Prev: Hacking, Up: Top - -Acknowledgements -**************** - - This is a list of people who gave help or suggestions while I was -working on the Taylor UUCP project. Appearance on this list does not -constitute endorsement of the program, particularly since some of the -comments were criticisms. I've probably left some people off, and I -apologize for any oversight; it does not mean your contribution was -unappreciated. - - First of all, I would like to thank the people at Infinity -Development Systems (formerly AIRS, which lives on in the domain name, -at least for now) for permitting me to use their computers and `uunet' -access. I would also like to thank Richard Stallman -`' for founding the Free Software Foundation and -John Gilmore `' for writing the initial version of -gnuucp which was a direct inspiration for this somewhat larger -project. Chip Salzenberg `' contributed many early -patches. Franc,ois Pinard `' tirelessly -tested the code and suggested many improvements. He also put together -the initial version of this document. Finally, Verbus M. Counts -`' and Centel Federal Systems, Inc. deserve -special thanks, since they actually paid me money to port this code to -System III. - - In alphabetical order: - - "Earle F. Ake - SAIC" `' - `mra@searchtech.com' (Michael Almond) - `cambler@zeus.calpoly.edu' (Christopher J. Ambler) - Brian W. Antoine `' - `jantypas@soft21.s21.com' (John Antypas) - `nba@sysware.DK' (Niels Baggesen) - `uunet!hotmomma!sdb' (Scott Ballantyne) - `magus!dolphin!zack' (Zacharias Beckman) - `mike@mbsun.ann-arbor.mi.us' (Mike Bernson) - `bob@usixth.sublink.org' (Roberto Biancardi) - Marc Boucher `' - `dean@coplex.com' (Dean Brooks) - `dave@dlb.com' (Dave Buck) - `gordon@sneaky.lonestar.org' (Gordon Burditt) - `mib@gnu.ai.mit.edu' (Michael I Bushnell) - Brian Campbell `' - `verbus@westmark.westmark.com' (Verbus M. Counts) - `cbmvax!snark.thyrsus.com!cowan' (John Cowan) - `denny@dakota.alisa.com' (Bob Denny) - `dje@ersys.edmonton.ab.ca' (Doug Evans) - `fenner@jazz.psu.edu' (Bill Fenner) - "David J. Fiander" `' - Thomas Fischer `' - `erik@eab.retix.com' (Erik Forsberg) - Lele Gaifax `' - `Peter.Galbavy@micromuse.co.uk' - `hunter@phoenix.pub.uu.oz.au' (James Gardiner [hunter]) - Terry Gardner `' - `jimmy@tokyo07.info.com' (Jim Gottlieb) - `ryan@cs.umb.edu' (Daniel R. Guilderson) - `greg@gagme.chi.il.us' (Gregory Gulik) - Michael Haberler `' - `guy@auspex.auspex.com' (Guy Harris) - Petri Helenius `' - Peter Honeyman `' - `bei@dogface.austin.tx.us' (Bob Izenberg) - `harvee!esj' (Eric S Johansson) - `chris@cj_net.in-berlin.de' (Christof Junge) - `tron@Veritas.COM' (Ronald S. Karr) - `kent@sparky.IMD.Sterling.COM' (Kent Landfield) - `lebaron@inrs-telecom.uquebec.ca' (Gregory LeBaron) - `karl@sugar.NeoSoft.Com' (Karl Lehenbauer) - `libove@libove.det.dec.com' (Jay Vassos-Libove) - `bruce%blilly@Broadcast.Sony.COM' (Bruce Lilly) - Ted Lindgreen `' - "Arne Ludwig" `' - Matthew Lyle `' - `djm@eng.umd.edu' (David J. MacKenzie) - John R MacMillan `' - `mem@mv.MV.COM' (Mark E. Mallett) - `martelli@cadlab.sublink.org' (Alex Martelli) - Yanek Martinson `' - `les@chinet.chi.il.us' (Leslie Mikesell) - `mmitchel@digi.lonestar.org' (Mitch Mitchell) - `rmohr@infoac.rmi.de' (Rupert Mohr) - `service@infohh.rmi.de' (Dirk Musstopf) - `lyndon@cs.athabascau.ca' (Lyndon Nerenberg) - `nolan@helios.unl.edu' (Michael Nolan) - david nugent `' - `abekas!dragoman!mikep@decwrl.dec.com' (Mike Park) - "Mark Pizzolato 415-369-9366" `' - `dplatt@ntg.com' (Dave Platt) - `eldorado@tharr.UUCP' (Mark Powell) - `pozar@kumr.lns.com' (Tim Pozar) - `putsch@uicc.com' (Jeff Putsch) - Jarmo Raiha `' - `mcr@Sandelman.OCUnix.On.Ca' (Michael Richardson) - `ross@sun490.fdu.edu' (Jeff Ross) - Aleksey P. Rudnev `' - `wolfgang@wsrcc.com' (Wolfgang S. Rupprecht) - `tbr@tfic.bc.ca' (Tom Rushworth) - `rsalz@bbn.com' (Rich Salz) - `sojurn!mike@hobbes.cert.sei.cmu.edu' (Mike Sangrey) - `swiers@plains.NoDak.edu' - `s4mjs!mjs@nirvo.nirvonics.com' (M. J. Shannon Jr.) - `peter@ficc.ferranti.com' (Peter da Silva) - `frumious!pat' (Patrick Smith) - `roscom!monty@bu.edu' (Monty Solomon) - `chs@antic.apu.fi' (Hannu Strang) - `ralf@reswi.ruhr.de' (Ralf E. Stranzenbach) - Oleg Tabarovsky `' - John Theus `' - `rmtodd@servalan.servalan.com' (Richard Todd) - Len Tower `' - `mju@mudos.ann-arbor.mi.us' (Marc Unangst) - `jv@mh.nl' (Johan Vromans) - `rna-nl!gerben@relay.nluug.nl' (Drs. Gerben C. Th. Wierda) - `frnkmth!twwells.com!bill' (T. William Wells) - `mauxci!eci386!woods@apple.com' (Greg A. Woods) - `jon@console.ais.org' (Jon Zeeff) - Eric Ziegast `' - - -File: uucp.info, Node: Index (concepts), Next: Index (configuration file), Prev: Acknowledgements, Up: Top - -Concept Index -************* - -* Menu: - -* /usr/spool/uucp: Miscellaneous (config). -* /usr/spool/uucppublic: Miscellaneous (config). -* UUCP protocol: UUCP Protocol. -* UUCP system name: Miscellaneous (config). -* anonymous UUCP: config File Examples. -* call configuration file: Configuration File Names. -* call in login name: Configuration File Names. -* call in password: Configuration File Names. -* call out file: Configuration File Names. -* call out login name: Configuration File Names. -* call out password: Configuration File Names. -* changing spool directory: config File Examples. -* chat scripts: Chat Scripts. -* config file: config File. -* config file examples: config File Examples. -* configuration file (call): Configuration File Names. -* configuration file (config): config File. -* configuration file (dial): dial File. -* configuration file (dialcode): Configuration File Names. -* configuration file (passwd): Configuration File Names. -* configuration file (port): port File. -* configuration file (sys): sys File. -* debugging file: Log File Names. -* dial file: dial File. -* dialcode configuration file: Configuration File Names. -* dialcode file: Configuration File Names. -* dialer configuration file: dial File. -* e protocol: e Protocol. -* f protocol: f Protocol. -* g protocol: g Protocol. -* gateway: Gateway Example. -* grades: Grades. -* handshake: UUCP Protocol. -* leaf site: Leaf Example. -* lock files: Lock Files. -* log file: Log File Names. -* main configuration file: config File. -* passwd configuration file: Configuration File Names. -* passwd file: Configuration File Names. -* port configuration file: port File. -* port file: port File. -* protocol (UUCP): UUCP Protocol. -* protocol (e): e Protocol. -* protocol (f): f Protocol. -* protocol (g): g Protocol. -* protocol (t): t Protocol. -* public directory: Miscellaneous (config). -* spool directory: Miscellaneous (config). -* spool directory (changing): config File Examples. -* statistics file: Log File Names. -* sys file: sys File. -* sys file example (gateway): Gateway Example. -* sys file example (leaf): Leaf Example. -* system configuration file: sys File. -* system name: Miscellaneous (config). -* t protocol: t Protocol. -* time strings: Time Strings. -* unknown systems: Miscellaneous (config). -* uucppublic: Miscellaneous (config). - - -File: uucp.info, Node: Index (configuration file), Prev: Index (concepts), Up: Top - -Index to New Configuration File -******************************* - -* Menu: - -* abort: dial File. -* abort-chat: dial File. -* abort-chat-fail: dial File. -* abort-chat-program: dial File. -* abort-chat-seven-bit: dial File. -* abort-chat-timeout: dial File. -* address: Placing the Call. -* alias: Naming the System. -* alternate: Naming the System. -* baud in port file: port File. -* baud in sys file: Placing the Call. -* baud-range: port File. -* bnu-files: Miscellaneous (config). -* call-local-size: File Transfer Control. -* call-login: Logging In. -* call-password: Logging In. -* call-remote-size: File Transfer Control. -* call-request: File Transfer Control. -* call-timegrade: When to Call. -* call-transfer: File Transfer Control. -* callback: Accepting a Call. -* called-chat: Accepting a Call. -* called-chat-fail: Accepting a Call. -* called-chat-program: Accepting a Call. -* called-chat-seven-bit: Accepting a Call. -* called-chat-timeout: Accepting a Call. -* called-local-size: File Transfer Control. -* called-login: Accepting a Call. -* called-remote-size: File Transfer Control. -* called-request: File Transfer Control. -* called-transfer: File Transfer Control. -* callfile: Configuration File Names. -* carrier in dial file: dial File. -* carrier in port file: port File. -* carrier-wait: dial File. -* chat: Chat Scripts. -* chat in dial file: dial File. -* chat in sys file: Logging In. -* chat-fail: Chat Scripts. -* chat-fail in dial file: dial File. -* chat-fail in sys file: Logging In. -* chat-program in dial file: dial File. -* chat-program in sys file: Logging In. -* chat-program in sys file: Chat Scripts. -* chat-seven-bit: Chat Scripts. -* chat-seven-bit in dial file: dial File. -* chat-seven-bit in sys file: Logging In. -* chat-timeout: Chat Scripts. -* chat-timeout in dial file: dial File. -* chat-timeout in sys file: Logging In. -* command-path: Miscellaneous (sys). -* commands: Miscellaneous (sys). -* complete: dial File. -* complete-chat: dial File. -* complete-chat-fail: dial File. -* complete-chat-program: dial File. -* complete-chat-seven-bit: dial File. -* complete-chat-timeout: dial File. -* debug in config file: Debugging Levels. -* debug in sys file: Miscellaneous (sys). -* debugfile: Log File Names. -* default-alternates: Naming the System. -* device: port File. -* dial-device: port File. -* dialcodefile: Configuration File Names. -* dialer in dial file: dial File. -* dialer in port file: port File. -* dialer-sequence: port File. -* dialfile: Configuration File Names. -* dialtone: dial File. -* dtr-toggle: dial File. -* free-space: Miscellaneous (sys). -* hostname: Miscellaneous (config). -* local-receive: File Transfer Control. -* local-send: File Transfer Control. -* lockname: port File. -* logfile: Log File Names. -* max-remote-debug: Miscellaneous (sys). -* max-uuxqts: Miscellaneous (config). -* myname: Naming the System. -* nodename: Miscellaneous (config). -* passwdfile: Configuration File Names. -* pause: dial File. -* phone: Placing the Call. -* port in port file: port File. -* port in sys file: Placing the Call. -* portfile: Configuration File Names. -* protocol in port file: port File. -* protocol in sys file: Protocol Selection. -* protocol-parameter in dial file: dial File. -* protocol-parameter in port file: port File. -* protocol-parameter in sys file: Protocol Selection. -* pubdir in config file: Miscellaneous (config). -* pubdir in sys file: Miscellaneous (sys). -* reliable in dial file: dial File. -* reliable in port file: port File. -* remote-receive: File Transfer Control. -* remote-send: File Transfer Control. -* request: File Transfer Control. -* sequence: Miscellaneous (sys). -* service: port File. -* seven-bit in dial file: dial File. -* seven-bit in port file: port File. -* speed in port file: port File. -* speed in sys file: Placing the Call. -* speed-range: port File. -* spool: Miscellaneous (config). -* statfile: Log File Names. -* sysfile: Configuration File Names. -* system: Naming the System. -* time: When to Call. -* timegrade: When to Call. -* timetable: Miscellaneous (sys). -* transfer: File Transfer Control. -* type: port File. -* unknown: Miscellaneous (config). -* uuname: Miscellaneous (config). -* v2-files: Miscellaneous (config). - - diff --git a/gnu/libexec/uucp/uucp.texi b/gnu/libexec/uucp/uucp.texi deleted file mode 100644 index 18155a02de27..000000000000 --- a/gnu/libexec/uucp/uucp.texi +++ /dev/null @@ -1,4495 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header -@setfilename uucp.info -@settitle Taylor UUCP -@setchapternewpage odd -@c %**end of header -@setchapternewpage odd - -@ignore -----------------------------------------------------------------------> -Franc,ois Pinard says: - -Hi, Ian! This is the promised merging of the current documents from -Taylor UUCP 1.01, plus the patches to documentation you sent to me, into -a taylor.texi file. Many things remain to do, among which: - -- merging in the Taylor UUCP program man pages. -- integrating the three documents describing the protocol. -- gleaning miscellaneous information from my archives. -----------------------------------------------------------------------< -@end ignore - -@ifinfo -This file documents Taylor UUCP, version 1.03. - -Copyright @copyright{} 1992 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 a 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 also that the -section entitled ``Copying'' are included exactly as in the original, and -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 the section entitled ``Copying'' may be included in a -translation approved by the author instead of in the original English. -@end ifinfo - -@titlepage -@title Taylor UUCP -@subtitle Version 1.03 -@author Ian Lance Taylor @file{} - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1992 Free Software Foundation, Inc. - -Published by Ian Lance Taylor @file{}. - -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 also that the -section entitled ``Copying'' are included exactly as in the original, and -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 the section entitled ``Copying'' may be included in a -translation approved by the author instead of in the original English. -@end titlepage - -@node Top, Copying, (dir), (dir) -@top Taylor UUCP 1.03 - -This is the documentation for the Taylor UUCP package, version 1.03. -The programs were written by Ian Lance Taylor. The author can be -reached at @file{}, or, equivalently, -@file{}, or @cite{c/o Infinity Development, P.O. Box -520, Waltham MA, 02254}. - -There is a mailing list for discussion of the package. To join the -list, send a message to @file{}. -Make sure you include the address you want to receive messages at; do -not rely on the @code{From:} header. To send a message to the list, -send it to @file{}. - -@menu -* Copying:: Taylor UUCP copying conditions -* Introduction:: Introduction to Taylor UUCP -* Overall Installation:: Taylor UUCP installation -* Configuration Files:: Taylor UUCP configuration files -* Protocols:: UUCP protocol internals -* Hacking:: Hacking Taylor UUCP -* Acknowledgements:: Acknowledgements - -* Index (concepts):: Concept index -* Index (configuration file):: Index to new configuration files - - --- The Detailed Node Listing --- - -Taylor UUCP Overall Installation - -* Configuration:: Configuring Taylor UUCP -* Compilation:: Compiling Taylor UUCP -* Testing:: Testing Taylor UUCP -* Installation:: Installing Taylor UUCP -* Usage:: Using Taylor UUCP -* TCP:: TCP together with Taylor UUCP - -Taylor UUCP Configuration Files - -* Configuration File Format:: Configuration file format -* Configuration Examples:: Examples of configuration files -* Time Strings:: How to write time strings -* Chat Scripts:: How to write chat scripts -* config File:: The main configuration file -* sys File:: The system configuration file -* port File:: The port configuration files -* dial File:: The dialer configuration files -* Security:: Security issues - -Examples of Configuration Files - -* config File Examples:: Examples of the main configuration file -* Leaf Example:: Call a single remote site -* Gateway Example:: The gateway for several local systems - -The Main Configuration File - -* Miscellaneous (config):: Miscellaneous config file commands -* Configuration File Names:: Using different configuration files -* Log File Names:: Using different log files -* Debugging Levels:: Debugging levels - -The System Configuration File - -* Defaults and Alternates:: Using defaults and alternates -* Naming the System:: Naming the system -* Calling Out:: Calling out -* Accepting a Call:: Accepting a call -* Protocol Selection:: Protocol selection -* File Transfer Control:: File transfer control -* Miscellaneous (sys):: Miscellaneous sys file commands -* Default sys File Values:: Default values - -Calling Out - -* When to Call:: When to call -* Placing the Call:: Placing the call -* Logging In:: Logging in - -UUCP protocol internals - -* Grades:: UUCP grades -* Lock Files:: UUCP lock file format -* UUCP Protocol:: The common UUCP protocol -* g Protocol:: The UUCP @samp{g} protocol -* f Protocol:: The UUCP @samp{f} protocol -* t Protocol:: The UUCP @samp{t} protocol -* e Protocol:: The UUCP @samp{e} protocol -* x Protocol:: The UUCP @samp{x} protocol -* d Protocol:: The UUCP @samp{d} protocol -* Capital G Protocol:: The UUCP @samp{G} protocol -* Documentation References:: Documentation references - -The Common UUCP Protocol - -* Initial Handshake:: Initial handshake -* File Requests:: File requests -* Final Handshake:: Final handshake - -File Requests - -* S Request:: S request -* R Request:: R request -* X Request:: X request -* H Request:: H request - -Hacking Taylor UUCP - -* System Dependence:: System Dependence -* Naming Conventions:: Naming Conventions -* Patches:: Patches -@end menu - -@node Copying, Introduction, Top, Top -@unnumbered Taylor UUCP Copying Conditions - -This package is covered by the GNU Public License. See the file -@file{COPYING} for details. If you would like to do something with this -package that you feel is reasonable but you feel is prohibited by the -license, contact me to see if we can work it out. - -Here is some propaganda from the Free Software Foundation. If you find -this stuff offensive or annoying, remember that you probably did not -spend any money to get this code. I did not write this code to make -life easier for developers of UUCP packages, I wrote it to help end -users, and I believe that these are the most appropriate conditions for -distribution. - -All the programs, scripts and documents relating to Taylor UUCP are -@dfn{free}; this means that everyone is free to use them and free to -redistribute them on a free basis. The Taylor UUCP-related programs are -not in the public domain; they are copyrighted and there are -restrictions on their distribution, but these restrictions are designed -to permit everything that a good cooperating citizen would want to do. -What is not allowed is to try to prevent others from further sharing any -version of these programs that they might get from you. - -Specifically, we want to make sure that you have the right to give away -copies of the programs that relate to Taylor UUCP, that you receive -source code or else can get it if you want it, that you can change these -programs or use pieces of them in new free programs, and that you know -you can do these things. - -To make sure that everyone has such rights, we have to forbid you to -deprive anyone else of these rights. For example, if you distribute -copies of the Taylor UUCP related programs, 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 tell them their -rights. - -Also, for our own protection, we must make certain that everyone finds -out that there is no warranty for the programs that relate to Taylor -UUCP. If these programs are modified by someone else and passed on, we -want their recipients to know that what they have is not what we -distributed, so that any problems introduced by others will not reflect -on our reputation. - -The precise conditions of the licenses for the programs currently being -distributed that relate to Taylor UUCP are found in the General Public -Licenses that accompany them. - -@node Introduction, Overall Installation, Copying, Top -@chapter Introduction to Taylor UUCP - -General introductions to UUCP are available, and perhaps one day I will -write one. In the meantime, here is a very brief one that concentrates -on the programs provided by Taylor UUCP. - -Taylor UUCP is a complete UUCP package. It is covered by the GNU Public -License, which means that the source code is always available. It is -composed of several programs, the names of which were established by -earlier UUCP packages. - -@table @code - -@item uucp - -The @code{uucp} program is used to copy file between systems. It is -similar to the standard Unix @code{cp} program, except that you can -refer to a file on a remote system by using @samp{system!} before the -file name. For example, to copy the file @file{notes.txt} to the system -@samp{airs}, you would say @samp{uucp notes.txt airs!~/notes.txt}. In -this example @samp{~} is used to name the UUCP public directory on -@samp{airs}. - -@item uux - -The @code{uux} program is used to request a program to be executed on a -remote system. This is how mail and news are transferred over UUCP. As -with @code{uucp}, programs and files on remote systems may be named by -using @samp{system!}. For example, to run the @code{rnews} program on -@samp{airs} passing it standard input, you would say @samp{uux - -airs!rnews}. The @samp{-} means to read standard input and set things -up so that when @code{rnews} runs on @samp{airs} it will receive the -same standard input. - -@end table - -Neither @code{uucp} nor @code{uux} actually do any work immediately. -Instead, they queue up requests for later processing. They then start a -daemon process which processes the requests and calls up the appropriate -systems. Usually the daemon will also be started regularly to check if -there is any work to be done and to do it. The advantage of this system -is that it all happens automatically. You don't have to sit around -waiting for the files to be transferred. The disadvantage is that if -anything goes wrong it might be a while before anybody notices. - -@table @code - -@item uustat - -The @code{uustat} program does several things. By default it will -simply list all the jobs you have queued with @code{uucp} or @code{uux} -that have not yet been processed. You can use @code{uustat} to remove -any of your jobs from the queue. You can also it use it to show the -status of the UUCP system in various ways, such as showing the -connection status of all systems your system knows about. - -@item uuname - -The @code{uuname} program by default lists all the remote systems your -system knows about. You can also use it to get the name of your local -system. It is mostly useful for shell scripts. - -@item uulog - -The @code{uulog} program can be used to display entries in the UUCP log -file. It can select the entries for a particular system or a particular -user. You can use it to see what has happened to your queued jobs in -the past. - -@end table - -These five programs just described, @code{uucp}, @code{uux}, -@code{uustat}, @code{uuname}, and @code{uulog}, are the user programs -provided by Taylor UUCP. The first two add requests to the work queue, -the third examines the work queue, the fourth examines the configuration -files, and the last examines the log files. The real work is actually -done by two daemon processes, which are normally run automatically -rather than by a user. - -@table @code - -@item uucico - -The @code{uucico} daemon is the program which actually calls the remote -system and transfers files and requests. @code{uucico} is normally -started automatically by @code{uucp} and @code{uux}. Most systems will -also start it periodically to make sure that all work requests are -handled. @code{uucico} checks the queue to see what work needs to be -done, and then calls the appropriate systems. If the call fails, -perhaps because the phone line is busy, @code{uucico} leaves the -requests in the queue and goes on to the next system to call. It is -also possible to force @code{uucico} to call a remote system even if -there is no work to be done for it, so that it can pick up any work that -may be queued up remotely. - -@item uuxqt - -The @code{uuxqt} daemon processes execution requests made by the -@code{uux} program on remote systems. It also processes requests made -on the local system which require files from a remote system. It is -normally started by @code{uucico}. - -@end table - -Suppose you, on the system @samp{bantam}, want to copy a file to the -system @samp{airs}. You would run the @code{uucp} command locally, with -a command like @samp{uucp notes.txt airs!~/notes.txt}. This would queue -up a request on @samp{bantam} for @samp{airs}, and would then start the -@code{uucico} daemon. @code{uucico} would see that there was a request -for @samp{airs} and attempt to call it. When the call succeeded, -another copy of @code{uucico} would be started on @samp{airs}. The two -copies of @code{uucico} would tell each other what they had to do and -transfer the file from @samp{bantam} to @samp{airs}. When the file -transfer was complete the @code{uucico} on @samp{airs} would move it -into the UUCP public directory. - -UUCP is often used to transfer mail. This is normally done -automatically by mailer programs. When @samp{bantam} has a mail message -to send to @samp{ian} at @samp{airs}, it executes @samp{uux - airs!rmail -ian} and writes the mail message to the @code{uux} process as standard -input. The @code{uux} program, running on @samp{bantam}, will read the -standard input and store it and the @code{rmail} request on the work -queue for @code{airs}. @code{uux} will then start the @code{uucico} -daemon. The @code{uucico} daemon will call up @samp{airs}, just as in -the @code{uucp} example, and transfer the work request and the mail -message itself. The @code{uucico} daemon on @samp{airs} will put the -files on a local work queue. When the communication session is over, -the @code{uucico} daemon on @samp{airs} will start the @code{uuxqt} -daemon. @code{uuxqt} will see the request to run, and will run -@samp{rmail ian} with the mail message as standard input. The -@code{rmail} program, which is not part of the UUCP package, is then -responsible for either putting the message in the right mailbox on -@samp{airs} or forwarding the message on to another system. - -Taylor UUCP comes with two other programs that are useful when -installing and configuring UUCP. - -@table @code - -@item uuchk - -The @code{uuchk} program reads the UUCP configuration files and displays -a rather lengthy description of what it finds. This is very useful when -configuring UUCP to make certain that the UUCP package will do what you -expect it to do. - -@item tstuu - -The @code{tstuu} program is a test harness for the UUCP package, which -will help ensure that it has been configured and compiled correctly. It -does not test everything, however, and it only runs on Unix systems -which support Berkeley style pseudo-terminals. It can be useful when -initially installing Taylor UUCP. - -@end table - -@node Overall Installation, Configuration Files, Introduction, Top -@chapter Taylor UUCP Overall Installation - -These are the installation instructions for the Taylor UUCP package. - -@menu -* Configuration:: Configuring Taylor UUCP -* Compilation:: Compiling Taylor UUCP -* Testing:: Testing Taylor UUCP -* Installation:: Installing Taylor UUCP -* Usage:: Using Taylor UUCP -* TCP:: TCP together with Taylor UUCP -@end menu - -@node Configuration, Compilation, Overall Installation, Overall Installation -@section Configuring Taylor UUCP - -You will have to decide what types of configuration files you want to -use. This package supports a new sort of configuration file; -@xref{Configuration files}. It also supports V2 configuration files -(@file{L.sys}, @file{L-devices}, etc.) and BNU configuration files -(@file{Systems}, @file{Devices}, etc.). No documentation is provided -for V2 or BNU configuration files. All types of configuration files can -be used at once, if you are so inclined. Currently using just V2 -configuration files is not really possible, because there is no way to -specify a dialer (there are no built in dialers, and the program does -not know how to read @file{acucap} or @file{modemcap}); however, V2 -configuration files can be used with a new style dialer file -(@pxref{dial file}), or with a BNU @file{Dialers} file. - -Use of BNU configuration files has two known bugs. A blank line in the -middle of an entry in the @file{Permissions} file will not be ignored as -it should be. Dialer programs are not recognized directly. If you must -use a dialer program, rather than an entry in @file{Devices}, you must -use the @code{chat-program} command in a new style dialer file; see -@ref{dial file}. You will have to invoke the dialer program via a shell -script, since an exit code of 0 is required to recognize success. - -If you are installing a new system, or you want to use the new form of -configuration files, you must write the configuration files. - -You must also decide what sort of spool directory you want to use. If -you will only be using these programs, I recommend -@samp{SPOOLDIR_TAYLOR}; otherwise select the spool directory -corresponding to your existing UUCP package. The details of the spool -directory choices are described at somewhat tedious length in -@file{sys3.unx}. - -@node Compilation, Testing, Configuration, Overall Installation -@section Compiling Taylor UUCP - -@enumerate - -@item -Take a look at the top of @file{Makefile.in} and set the appropriate -values for your system. These control where the program is installed -and which user on the system owns them (normally they will be owned by a -special user @code{uucp} rather than a real person; they should probably -not be owned by @code{root}). - -@item -Run the shell script @code{configure}. This script was generated using -David MacKenzie's @code{autoconf} program. It takes a while to run. It -will generate a file @file{conf.h}, and copy @file{Makefile.in} to -@file{Makefile} with substitions (specifically, it will replace all -words between @kbd{@@} characters in @file{Makefile.in}). - -You can pass certain arguments to @code{configure} in the environment. -Because @code{configure} will compile and run little test programs to -see what is available on your system, you must tell it how to run your -compiler. It recognizes the following environment variables: - -@table @samp -@item CC -The C compiler. If this is not set, then if @code{configure} can find -@code{gcc} it will use @samp{gcc -O}, otherwise it will use @samp{cc}. -@item DEFS -Flags to pass the C compiler during configuration testing. If this is -not set, @code{configure} will use the empty string. -@item CFLAGS -Flags to pass to the C compiler when compiling the actual code. If this -is not set, @code{configure} will use @samp{-g}. -@item LDFLAGS -Flags to pass to the C compiler when only linking, not compiling. If -this is not set, @code{configure} will use the empty string. -@item LIBS -Libraries to pass to the C compiler. If this is not set, -@code{configure} will use the empty string. -@item INSTALL -The program to run to install UUCP in the binary directory. If -@code{configure} finds the BSD @code{install} program, it will set this -to @samp{install -c}; otherwise, it will use @samp{cp}. -@item INSTALLDATA -The program to run to install UUCP data files, such as the man pages and -the info pages. If @code{configure} finds the BSD @code{install} -program, it will set this to @samp{install -c -m 644}; otherwise, it -will use @samp{cp}. -@end table - -Suppose you want to set the environment variable @samp{CC} to -@samp{rcc}. If you are using @code{sh} or @code{bash}, invoke -@code{configure} as @samp{CC=rcc configure}. If you are using -@code{csh}, do @samp{setenv CC rcc; sh configure}. - -On some systems you will want to use @samp{LIBS=-lmalloc}. On some you -will want @samp{LIBS=-lsocket}. On Xenix derived systems do not use -@samp{LIBS=-lx} because this will bring in the wrong versions of certain -routines; if you want to use @samp{-lx} you must specify @samp{LIBS=-lc --lx}. - -If @code{configure} fails for some reason, or if you have a very wierd -system, you may have to configure the package by hand. To do this, copy -the file @file{conf.h-dist} to @file{conf.h} and edit it for your -system. Then copy @file{Makefile.in} to @file{Makefile}, find the words -within @kbd{@@} characters, and set them correctly for your system. - -@item -You should verify that @code{configure} worked correctly by checking -the files @file{conf.h} and @file{Makefile}. - -@item -This package uses the @code{alloca} function. The @code{configure} -script will try to figure out how to make it work on your system. If -@code{alloca} cannot be found, a simplistic substitute from -@file{alloca.c} will be used. If you provide your own @file{alloca.o} -file, it will be used instead; you might, for example, use the one from -the GNU emacs distribution. If none of this makes any sense to you, -don't worry; everything will probably work fine. - -@item -Edit @file{policy.h} for your local system. The comments should explain -the various choices. The default values are intended to be reasonable, -so you may not have to make any changes. - -@item -Type @samp{make} to compile everything. You may get warnings about -implicit function declarations; ignore these (if you think they can be -eliminated, and you really know what you are talking about, you may tell -me about them). You may also get warnings about @file{getopt.c} (this -is from the GNU library and I do not want to change it) and about a -variable not protected from @code{setjmp} in @file{sys2.c} (the data -flow ensures that this can never be a problem). The @file{tstuu.c} file -is not particularly portable; if you can't figure out how to compile it -you can safely ignore it, as it is only used for testing. If you have -any other problems there is probably a bug in the @code{configure} -script. - -@item -Please report any problems you have. That is the only way they will get -fixed for other people. Supply a patch if you can, or just ask for -help. - -@end enumerate - -@node Testing, Installation, Compilation, Overall Installation -@section Testing Taylor UUCP - -This package is in use at many sites, and has been running at -@file{airs.com} for several months. However, it will doubtless fail in -some situations. Do not rely on this code until you have proven to -yourself that it will work. - -You can use the @code{uuchk} program to test your configuration files. -It will read them and print out a verbose description. This is -particularly important if you are using V2 or BNU configuration files, -because there may be bugs in how they are read. This program should not -be made suid, because it will display passwords if it can read them. - -If your system supports BSD style pseudo-terminals, and you compiled the -code to support the new style of configuration files, you should be able -to use the @code{tstuu} program to test the @code{uucico} daemon. Just -type @samp{tstuu} with no arguments while logged in to the compilation -directory (since it runs @file{./uucp}, @file{./uux} and -@file{./uucico}) to run a lengthy series of tests (it takes over ten -minutes on a slow VAX). You will need a fair amount of space available -in @file{/usr/tmp}. You will probably want to put it in the background. -Do not use @kbd{^Z}, because the program traps on @code{SIGCHLD} and -winds up dying. It will create a directory @file{/usr/tmp/tstuu} and -fill it with configuration files, and create spool directories -@file{/usr/tmp/tstuu/spool1} and @file{/usr/tmp/tstuu/spool2}. - -The program will finish with an execute file @file{X.@var{something}} -and a data file @file{D.@var{something}} in @file{/usr/tmp/tstuu/spool1} -(or, more likely, in subdirectories, depending on the choice of -@code{SPOOLDIR} in @file{sysdep.h}). The log files -@file{/usr/tmp/tstuu/Log1} and @file{/usr/tmp/tstuu/Log2} (or, if you -have selected @code{HAVE_BNU_LOGGING}, -@file{/usr/tmp/tstuu/Log1/uucico/test2} and -@file{/usr/tmp/tstuu/Log2/uucico/test1}) should look fairly normal. You -can test @code{uuxqt} by typing @samp{./uuxqt -I -/usr/tmp/tstuu/Config1}. This should leave a command file -@file{C.@var{something}} and a data file @file{D.@var{something}} in -@file{/usr/tmp/tstuu/spool1} or in subdirectories. Again, there should -be no errors in the log file. - -Assuming you compiled the code with debugging enabled, the @samp{-x} -switch can be used to set debugging modes; see the @code{debug} command -for details (@pxref{Debugging Levels}). Use @samp{-x all} to turn on -all debugging and generate far more output than you will ever want to -see. The @code{uucico} daemons will put debugging output in -@file{/usr/tmp/tstuu/Debug1} and @file{/usr/tmp/tstuu/Debug2}. At this -point you're pretty much on your own. - -On some systems you can also use @code{tstuu} to test my @code{uucico} -against the system @code{uucico}, by using the @samp{-u} switch. For -this to work, change the definitions of @code{ZUUCICO_CMD} and -@code{UUCICO_EXECL} at the top of @file{tstuu.c} to something -appropriate for your system. The definitions in @file{tstuu.c} are what -I used for Ultrix 4.0, in which @file{/usr/lib/uucp/uucico} is -particularly obstinate about being run as a child; I was only able to -run it by creating a login name with no password whose shell was -@file{/usr/lib/uucp/uucico}. Calling login in this way will leave fake -entries in @file{wtmp} and @file{utmp}; if you compile @file{tstout.c} -(in the @file{contrib} directory) as an suid @code{root} program, -@code{tstuu} will run it to clear those entries out. On most systems, -such hackery should not be necessary, although on SCO I had to su to -@code{root} (@code{uucp} might also have worked) before I could run -@file{/usr/lib/uucp/uucico}. - -You can test @code{uucp} and @code{uux} (give them the @samp{-r} switch -to keep them from starting @code{uucico}) to make sure they create the -right sorts of files. Unfortunately if you don't know what the right -sorts of files are I'm not going to tell you here. - -If @code{tstuu} passes, or you can't run it for some reason or other, -move on to testing with some other system. Set up the configuration -files (@pxref{Configuration files}), or use an existing configuration. -Tell @code{uucico} to dial out to the system by using the @samp{-s} -system switch (e.g. @samp{uucico -s uunet}). The log file should tell -you what happens. - -If you compiled the code with debugging enabled, you can use debugging -mode to get a great deal of information about what sort of data is -flowing back and forth; the various possibilities are described under -the @code{debug} command (@pxref{Debugging Levels}). When initially -setting up a connection @samp{-x chat} is probably the most useful (e.g. -@samp{uucico -s uunet -x chat}); you may also want to use @samp{-x -handshake,incoming,outgoing}. You can use @samp{-x} multiple times on -one command line, or you can give it comma separated arguments as in the -last example. Use @samp{-x all} to turn on all possible debugging -information. The debugging information is written to a file, normally -@file{/usr/spool/uucp/Debug} although the default can be changed in -@file{policy.h} and the configuration file can override the name with -the @code{debugfile} command. The debugging file may contain passwords -and some file contents as they are transmitted over the line, so the -debugging file is only readable by the @code{uucp} user. - -You can use the @samp{-f} switch to force @code{uucico} to call out even -if the last call failed recently; using @samp{-S} when naming a system -has the same effect. Otherwise the status file (in the @file{.Status} -subdirectory of the main spool directory, normally -@file{/usr/spool/uucp}) will prevent too many attempts from occurring in -rapid succession. - -Again, let me know about any problems you have and how you got around -them. - -@node Installation, Usage, Testing, Overall Installation -@section Installing Taylor UUCP - -You can install by suing to @code{root} and typing @samp{make install}. -Or you can look at what make install does and do it by hand. It tries -to preserve your old programs, if any. You can retrieve them by typing -@samp{make uninstall}. - -@node Usage, TCP, Installation, Overall Installation -@section Using Taylor UUCP - -This package does not come with any fancy shell scripts or scheduling -programs. Maybe someday. If you have another package, you may well -be able to use the scheduling mechanisms it provides. - -Otherwise, the program can be used by making crontab entries. -Whenever you want to call all systems with outstanding work, use -@example -uucico -r1 -@end example -Whenever you want to call a specific system @samp{foo}, use -@example -uucico -s foo -@end example -If you want to make sure that a system foo gets retried if the -original call fails, create an empty work file for it. For example, -if using @code{SPOOLDIR_TAYLOR}, -@example -touch /usr/spool/uucp/foo/C./C.A0000 -@end example -If using @code{SPOOLDIR_BNU}, use -@example -touch /usr/spool/uucp/foo/C.fooA0000 -@end example - -I use the following crontab entries locally: - -@example -45 * * * * /bin/echo /usr/lib/uucp/uucico -r1 | /bin/su uucpa -40 4,10,15 * * * touch /usr/spool/uucp/uunet/C./C.A0000 -@end example - -Every hour, at 45 minutes past, this will check if there is any work to -be done. Also, at 4:40am, 10:40am and 3:40pm this will create an empty -work file for @file{uunet}, forcing the next check to call @file{uunet}. - -You will also want to periodically trim the log files, which by default -are @file{/usr/spool/uucp/Log} and @file{/usr/spool/uucp/Stats}. The -@code{savelog} program in the @file{contrib} directory may be of use. - -@node TCP, , Usage, Overall Installation -@section TCP together with Taylor UUCP - -If your system has a Berkeley style socket library, you can compile -the code to permit making connections over TCP. Specifying that a -system should be reached via TCP is easy, but nonobvious. - -If you are using the new style configuration files, see -@ref{Configuration files}. Basically, you can just add the line -@samp{port type tcp} to the entry in the system configuration file. By -default UUCP will get the port number by looking up @samp{uucp} in -@file{/etc/services}; if @samp{uucp} is not found, port 540 will be -used. You can set the port number to use with the command @samp{port -service @var{xxx}}, where @var{xxx} can be either a number or a name to -look up in @file{/etc/services}. You can specify the address of the -remote host with @samp{address @var{a.b.c}}; if you don't give an -address, the remote system name will be used. You should give an -explicit chat script for the system when you use TCP; the default chat -script begins with a carriage return, which will not work with some UUCP -TCP servers. - -If you are using V2 configuration files, add a line like this to -@file{L.sys}: - -@example -foo Any TCP uucp foo.domain chat-script -@end example - -This will make an entry for system foo, to be called at any time, over -TCP, using port number @samp{uucp} (as found in @file{/etc/services}; -this may be specified as a number), using remote host @file{foo.domain}, -with some chat script. - -If you are using BNU configuration files, add a line like this to -Systems: - -@example -foo Any TCP - foo.domain chat-script -@end example - -and a line like this to Devices: - -@example -TCP uucp - - -@end example - -You only need one line in Devices regardless of how many systems you -contact over TCP. This will make an entry for system foo, to be called -at any time, over TCP, using port number @samp{uucp} (as found in -@file{/etc/services}; this may be specified as a number), using remote -host @file{foo.domain}, with some chat script. - -The @code{uucico} daemon can also be run as a TCP server. This code -mostly works, but it's not perfect. I don't recommend investigating it -unless you are willing to tinker a bit. You will not be able to use the -default port number because @code{uucico} will not be running as -@code{root} and will therefore not be able to bind a reserved port. - -Basically, you must define a port, either using the port file -(@pxref{port file}) if you are using the new configuration method or -with an entry in Devices if you are using BNU; there is no way to define -a port using V2. If you are using BNU the port must be named -@samp{TCP}; a line as shown above will suffice. You can then start -@code{uucico} as @samp{uucico -p TCP} (after the @samp{-p}, name the -port; in BNU it must be @samp{TCP}). This will wait for incoming -connections, and fork off a child for each one. Each connection will be -prompted with @samp{login:} and @samp{Password:}; the results will be -checked against the UUCP (not the system) password file -(@pxref{Configuration File Names}). Of course, you can get a similar -effect by using the BSD @code{uucpd} program. - -You can also have @code{inetd} start up @code{uucico} with the @samp{-l} -switch, which will cause it to prompt with @samp{login:} and -@samp{Password:} and check the results against the UUCP (not the system) -password file. This may be used in place of @code{uucpd}. - -@node Configuration Files, Protocols, Overall Installation, Top -@chapter Taylor UUCP Configuration Files - -This chapter describes the configuration files accepted by the Taylor -UUCP package if compiled with @code{HAVE_TAYLOR_CONFIG} defined in -@file{conf.h}. - -The configuration files are normally found in the directory -@var{newconfigdir}, which is defined by the @file{Makefile} variable -@file{newconfigdir}; by default @var{newconfigdir} is -@file{/usr/local/lib/uucp}. However, the main configuration file, -@file{config}, is the only one which must be in that directory, since it -may specify a different location for any or all of the other files. You -may run any of the UUCP programs with a different main configuration -file by using the @samp{-I} option; this can be useful when testing a -new configuration. When you use the @samp{-I} option the programs will -revoke their setuid privileges. - -@menu -* Configuration File Format:: Configuration file format -* Configuration Examples:: Examples of configuration files -* Time Strings:: How to write time strings -* Chat Scripts:: How to write chat scripts -* config File:: The main configuration file -* sys File:: The system configuration file -* port File:: The port configuration files -* dial File:: The dialer configuration files -* Security:: Security issues -@end menu - -@node Configuration File Format, Configuration Examples, Configuration Files, Configuration Files -@section Configuration File Format - -All the configuration files follow a simple line-oriented -@samp{@var{keyword} @var{value}} format. Empty lines are ignored, as -are leading spaces; unlike BNU, lines with leading spaces are read. The -first word on each line is a keyword. The rest of the line is -interpreted according to the keyword. Most keywords are followed by -numbers, boolean values or simple strings with no embedded spaces. - -The @kbd{#} character is used for comments. Everything from a @kbd{#} -to the end of the line is ignored unless the @kbd{#} is preceded by a -@kbd{\} (backslash); if the @kbd{#} is preceeded by a @kbd{\}, the -@kbd{\} is removed but the @kbd{#} remains in the line. This can be -useful for a phone number containing a @kbd{#}. To enter the sequence -@samp{\#}, you would use @samp{\\#}. - -The backslash character may be used to continue lines. If the last -character in a line is a backslash, the backslash is removed and the -line is continued by the next line. The second line is attached to the -first with no intervening characters; if you want any whitespace between -the end of the first line and the start of the second line, you must -insert it yourself. - -However, the backslash is not a general quoting character. For example, -you cannot use it to get an embedded space in a string argument. - -Everything after the keyword must be on the same line. A @var{boolean} -may be specified as @kbd{y}, @kbd{Y}, @kbd{t}, or @kbd{T} for true and -@kbd{n}, @kbd{N}, @kbd{f}, or @kbd{F} for false; any trailing characters -are ignored, so @code{true}, @code{false}, etc., are also acceptable. - -@node Configuration Examples, Time Strings, Configuration File Format, Configuration Files -@section Examples of Configuration Files - -All the configuration commands are explained in the following sections. -However, I'll start by giving a few examples of configuration files. -For a more complete description of any of the commands used here see the -appropriate section of this chapter. - -@menu -* config File Examples:: Examples of the main configuration file -* Leaf Example:: Call a single remote site -* Gateway Example:: The gateway for several local systems -@end menu - -@node config File Examples, Leaf Example, Configuration Examples, Configuration Examples -@subsection config File Examples -@cindex config file examples - -To start with, here are some examples of uses of the main configuration -file, @file{config}. For a complete description of the commands that -are permitted in @file{config}, see @ref{config file}. - -In many cases you will not need to create a @file{config} file at all. -The most common reason to create one is to give your machine a special -UUCP name. Other reasons might be to change the UUCP spool directory or -to permit any remote system to call in. - -If you have an internal network of machines, then it is likely that the -internal name of your UUCP machine is not the name you want to use when -calling other systems. For example, here at @file{airs.com} our -mail/news gateway machine is named @file{elmer.airs.com} (it is one of -several machines all named @file{@var{localname}.airs.com}). If we did -not provide a @file{config} file, then our UUCP name would be -@file{elmer}; however, we actually want it to be @file{airs}. -Therefore, we use the following line in @file{config}: - -@example -nodename airs -@end example - -@cindex changing spool directory -@cindex spool directory (changing) -The UUCP spool directory name is set in @file{policy.h} when the code is -compiled. You might at some point decide that it is appropriate to move -the spool directory, perhaps to put it on a different disk partition. -You might use the following commands in @file{config} to change to -directories on the partition @file{/uucp}: - -@example -spool /uucp/spool -pubdir /uucp/uucppublic -logfile /uucp/spool/Log -debugfile /uucp/spool/Debug -@end example - -You would then move the contents of the current spool directory to -@file{/uucp/spool}. If you do this, make sure that no UUCP processes -are running while you change @file{config} and move the spool directory. - -@cindex anonymous UUCP -Suppose you wanted to permit any system to call in to your system and -request files. This is generally known as @dfn{anonymous UUCP}, since -the systems which call in are effectively anonymous. By default, -unknown systems are not permitted to call in. To permit this you must -use the @code{unknown} command in @file{config}. The @code{unknown} -command is followed by any command that may appear in the system file; -for full details, see @ref{sys file}. - -I will show two possible anonymous UUCP configurations. The first will -let any system call in and download files, but will not permit them to -upload files to your system. - -@example -# No files may be transferred to this system -unknown request no -# The public directory is /usr/spool/anonymous -unknown pubdir /usr/spool/anonymous -# Only files in the public directory may be sent (the default anyhow) -unknown remote-send ~ -@end example - -@noindent -Setting the public directory is convenient for the systems which call -in. It permits to request a file by prefixing it with @file{~/}. For -example, assuming your system is known as @samp{server}, then to -retrieve the file @file{/usr/spool/anonymous/INDEX} a user on a remote -site could just enter @samp{uucp server!~/INDEX ~}; this would transfer -@file{INDEX} from @samp{server}'s public directory to the user's local -public directory. Note that when using @samp{csh} or @samp{bash} the -@kbd{!} and the second @kbd{~} must be quoted. - -The next example will permit remote systems to upload files to a special -directory @file{/usr/spool/anonymous/upload}. Permitting a remote -system to upload files permits it to send work requests as well; this -example is careful to prohibit commands from unknown systems. - -@example -# No commands may be executed (the list of permitted commands is empty) -unknown commands -# The public directory is /usr/spool/anonymous -unknown pubdir /usr/spool/anonymous -# Only files in the public directory may be sent; users may not download -# files from the upload directory -unknown remote-send ~ !~/upload -# May only upload files into /usr/spool/anonymous/upload -unknown remote-receive ~/upload -@end example - -@node Leaf Example, Gateway Example, config File Examples, Configuration Examples -@subsection Leaf Example - -@cindex leaf site -@cindex sys file example (leaf) -A relatively common simple case is a @dfn{leaf site}, a system which -only calls or is called by a single remote site. Here is a typical -@file{sys} file that might be used in such a case. For full details on -what commands can appear in the @file{sys} file, see @ref{sys file}. - -This is the @file{sys} file that is used at @file{airs.com}. We use a -single modem to dial out to @file{uunet}. This example shows how you -can specify the port and dialer information directly in the @file{sys} -file for simple cases. It also shows the use of the following: - -@table @code - -@item call-login -Using @code{call-login} and @code{call-password} allows the default -login chat script to be used. In this case, the login name is specified -in the call-out login file (@pxref{Configuration File Names}). - -@item call-timegrade -@file{uunet} is requested to not send us news during the daytime. - -@item chat-fail -If the modem returns @samp{BUSY} or @samp{NO CARRIER} the call is -immediately aborted. - -@item protocol-parameter -Since @file{uunet} tends to be slow, the default timeout has been -increased. - -@end table - -This @file{sys} file relies on certain defaults. It will allow -@file{uunet} to queue up @samp{rmail} and @samp{rnews} commands. It -will allow users to request files from @file{uunet} into the UUCP public -directory. It will also @file{uunet} to request files from the UUCP -public directory; in fact @file{uunet} never requests files, but for -additional security we could add the line @samp{request false}. - -@example -# The following information is for uunet -system uunet - -# The login name and password are kept in the callout password file -call-login * -call-password * - -# We can send anything at any time. -time any - -# During the day we only accept grade 'Z' or above; at other times -# (not mentioned here) we accept all grades. uunet queues up news -# at grade 'd', which is lower than 'Z'. -call-timegrade Z Wk0755-2305,Su1655-2305 - -# The phone number. -phone 7389449 - -# uunet tends to be slow, so we increase the timeout -chat-timeout 120 - -# We are using a preconfigured Telebit 2500. -port type modem -port device /dev/ttyd0 -port baud 19200 -port carrier true -port dialer chat "" ATZ\r\d\c OK ATDT\D CONNECT -port dialer chat-fail BUSY -port dialer chat-fail NO\sCARRIER -port dialer complete \d\d+++\d\dATH\r\c -port dialer abort \d\d+++\d\dATH\r\c - -# Increase the timeout and the number of retries. -protocol-parameter g timeout 20 -protocol-parameter g retries 10 -@end example - -@node Gateway Example, , Leaf Example, Configuration Examples -@subsection Gateway Example - -@cindex gateway -@cindex sys file example (gateway) -Many organizations have several local machines which are connected by -UUCP, and a single machine which connects to the outside world. This -single machine is often referred to as a @dfn{gateway} machine. - -For this example I will assume a fairly simple case. It should still -provide a good general example. There are three machines, @file{elmer}, -@file{comton} and @file{bugs}. @file{elmer} is the gateway machine for -which I will show the configuration file. @file{elmer} calls out to -@file{uupsi}. As an additional complication, @file{uupsi} knows -@file{elmer} as @file{airs}; this will show how a machine can have one -name on an internal network but a different name to the external world. -@file{elmer} has two modems. It also has an TCP/IP connection to -@file{uupsi}, but since that is supposed to be reserved for interactive -work (it is, perhaps, only a 9600 baud SLIP line) it will only use it if -the modems are not available. - -A network this small would normally use a single @file{sys} file. -However, for pedagogical purposes I will show two separate @file{sys} -files, one for the local systems and one for @file{uupsi}. This is done -with the @code{sysfile} command in the @file{config} file. Here is the -@file{config} file. - -@example -# This is config -# The local sys file -sysfile /usr/local/lib/uucp/sys.local -# The remote sys file -sysfile /usr/local/lib/uucp/sys.remote -@end example - -Using the defaults feature of the @file{sys} file can greatly simplify -the listing of local systems. Here is @file{sys.local}. Note that this -assumes that the local systems are trusted; they are permited to request -any world readable file and to write files into any world writable -directory. - -@example -# This is sys.local -# Get the login name and password to use from the call-out file -call-login * -call-password * - -# The systems must use a particular login -called-login Ulocal - -# Permit sending any world readable file -local-send / -remote-send / - -# Permit requesting into any world writable directory -local-receive / -remote-receive / - -# Call at any time -time any - -# Use port1, then port2 -port port1 - -alternate - -port port2 - -# Now define the systems themselves. Because of all the defaults we -# used, there is very little to specify for the systems themselves. - -system comton -phone 5551212 - -system bugs -phone 5552424 -@end example - -The @file{sys.remote} file describes the @file{uupsi} connection. The -@code{myname} command is used to change the UUCP name to @file{airs} -when talking to @file{uupsi}. - -@example -# This is sys.remote -# Define uupsi -system uupsi - -# The login name and password are in the call-out file -call-login * -call-password * - -# We can call out at any time -time any - -# uupsi uses a special login name -called-login Uuupsi - -# uuspi thinks of us as `airs' -myname airs - -# The phone number -phone 5554848 - -# We use port2 first, then port1, then TCP - -port port2 - -alternate - -port port1 - -alternate - -# We don't bother to make a special entry in the port file for TCP, we -# just describe the entire port right here. We use a special chat -# script over TCP because the usual one confuses some TCP servers. -port type TCP -address uu.psi.com -chat ogin: \L word: \P -@end example - -The ports are defined in the file @file{port} (@pxref{port file}). For -this example they are both connected to the same type of 2400 baud -Hayes-compatible modem. - -@example -# This is port - -port port1 -type modem -device /dev/ttyd0 -dialer hayes -speed 2400 - -port port2 -type modem -device /dev/ttyd1 -dialer hayes -speed 2400 -@end example - -Dialers are described in the @file{dial} file (@pxref{dial file}). - -@example -# This is dial - -dialer hayes - -# The chat script used to dial the phone. \D is the phone number. -chat "" ATZ\r\d\c OK ATDT\D CONNECT - -# If we get BUSY or NO CARRIER we abort the dial immediately -chat-fail BUSY -chat-fail NO\sCARRIER - -# When the call is over we make sure we hangup the modem. -complete \d\d+++\d\dATH\r\c -abort \d\d+++\d\dATH\r\c -@end example - -@node Time Strings, Chat Scripts, Configuration Examples, Configuration Files -@section Time Strings -@cindex time strings - -Several commands use time strings to specify a range of times. This -section describes how to write time strings. - -A time string may be a list of simple time strings separated with a -vertical bar @kbd{|} or a command @kbd{,}. - -Each simple time string must begin with @samp{Su}, @samp{Mo}, @samp{Tu}, -@samp{We}, @samp{Th}, @samp{Fr}, or @samp{Sa}, or @samp{Wk} for any -weekday, or @samp{Any} for any day. - -Following the day may be a range of hours separated with a hyphen using -24 hour time. The range of hours may cross 0; for example -@samp{2300-0700} means any time except 7 AM to 11 PM. If no time is -given, calls may be made at any time on the specified day(s). - -The time string may also consist of the single word @samp{Never}, which -does not match any time, or a single word with a name defined in a -previous @code{timetable} command (@pxref{Miscellaneous (sys)}). - -Here are a few sample time strings with an explanation of what they -mean. - -@table @samp - -@item Wk2305-0855,Sa,Su2305-1655 - -This means weekdays before 8:55 AM or after 11:05 PM, any time Saturday, -or Sunday before 4:55 PM or after 11:05 PM. These are approximately the -times during which night rates apply to phone calls in the U.S.A. Note -that this time string uses, for example, @samp{2305} rather than -@samp{2300}; this will ensure a cheap rate phone call even if the -computer clock is running up to five minutes ahead of the real time. - -@item Wk0905-2255,Su1705-2255 - -This means weekdays from 9:05 AM to 10:55 PM, or Sunday from 5:05 PM to -10:55 PM. This is approximately the opposite of the previous example. - -@item Any - -Since no time is specified, this means any time on any day. - -@end table - -@node Chat Scripts, config File, Time Strings, Configuration Files -@section Chat Scripts -@cindex chat scripts - -Chat scripts are used in several different places, such as dialing out -on modems or logging in to remote systems. Chat scripts are made up of -pairs of strings. The program waits until it sees the first string, -known as the @dfn{expect} string, and then sends out the second string, -the @dfn{send} string. - -Each chat script is defined using a set of commands. These commands -always end in a string beginning with @code{chat}, but may start with -different strings. For example, in the @file{sys} file there is one set -of commands beginning with @code{chat} and another set beginning with -@code{called-chat}. The prefixes are only used to disambiguate -different types of chat scripts, and this section ignores the prefixes -when describing the commands. - -@table @code - -@item chat @var{strings} -@findex chat - -Specify a chat script. The arguments to the @code{chat} command are -pairs of strings separated by whitespace. The first string of each pair -is an expect string, the second is a send string. The program will wait -for the expect string to appear; when it does, the program will send the -send string. If the expect string does not appear within a certain -number of seconds (as set by the @code{chat-timeout} command) the chat -script fails and, typically, the call is aborted. If the final expect -string is seen (and the optional final send string has been sent), the -chat script is successful. - -An expect string may contain additional subsend and subexpect strings, -separated by hyphens. If the expect string is not seen, the subsend -string is sent and the chat script continues by waiting for the -subexpect string. This means that a hyphen may not appear in an expect -string; use @samp{\055} instead. - -An expect string may simply be @samp{""}, meaning to skip the expect -phase. Otherwise, the following escape characters may appear in expect -strings: - -@table @samp -@item \b -a backspace character -@item \n -a newline or line feed character -@item \N -a null character (for BNU compatibility) -@item \r -a carriage return character -@item \s -a space character -@item \t -a tab character -@item \\ -a backslash character -@item \@var{ddd} -character @var{ddd}, where @var{ddd} are up to three octal digits -@item \x@var{ddd} -character @var{ddd}, where @var{ddd} are hexadecimal digits. -@end table - -As in C, there may be up to three octal digits following a backslash, -but the hexadecimal escape sequence continues as far as possible. To -follow a hexadecimal escape sequence with a hex digit, interpose a send -string of @samp{""}. - -A send string may also simply be @samp{""} to skip the send phase. -Otherwise, all of the escape characters legal for expect strings may be -used, and the following escape characters are also permitted: - -@table @samp -@item EOT -send an end of transmission character (@kbd{^D}) -@item BREAK -send a break character (may not work on all systems) -@item \c -suppress trailing carriage return at end of send string -@item \d -delay sending for 1 second -@item \e -disable echo checking -@item \E -enable echo checking (wait for echo before continuing) -@item \K -same as @kbd{BREAK} (for BNU compatibility) -@item \p -pause sending for a fraction of a second -@end table - -Some specific types of chat scripts also define additional escape -sequences that may appear in the send string. For example, the login -chat script defines @samp{\L} and @samp{\P} to send the login name and -password, respectively. - -A carriage return will be sent at the end of each send string, unless -the @kbd{\c} escape sequence appears in the string. Note that some UUCP -packages use @kbd{\b} for break, but here it means backspace. - -Echo checking means that after writing each character the program will -wait until the character is echoed. Echo checking must be turned on -separately for each send string for which it is desired; it will be -turned on for characters following @kbd{\E} and turned off for characters -following @kbd{\e}. - -@item chat-timeout @var{number} -@findex chat-timeout - -The number of seconds to wait for an expect string in the chat script -before timing out and sending the next subsend or failing the chat -script entirely. The default value is 10 for a login chat or 60 for -any other type of chat. - -@item chat-fail @var{string} -@findex chat-fail - -If the @var{string} is seen at any time during a chat script, the chat -script is aborted. The string may not contain any whitespace -characters; escape sequences must be used for them. Multiple -@code{chat-fail} commands may appear in a single chat script. The -default is to have none. - -This permits a chat script to be quickly aborted if an error string is -seen. For example, a script used to dial out on a modem might use the -command @samp{chat-fail BUSY} to stop the chat script immediately if the -string @samp{BUSY} was seen. - -@item chat-seven-bit @var{boolean} -@findex chat-seven-bit - -If the argument is true, all incoming characters are stripped to seven -bits when being compared to the expect string. Otherwise all eight bits -are used in the comparison. The default is true because some Unix -systems generate parity bits during the login prompt which must be -ignored while running a chat script. This has no effect on any -@code{chat-program}, which must ignore parity by itself if necessary. - -@item chat-program @var{strings} -@findex chat-program in sys file - -Specify a program to run before executing the chat script. This program -could run its own version of a chat script, or it could do whatever it -wants. If both @code{chat-program} and @code{chat} are specified, the -program is executed first followed by the chat script. - -The first argument to the @code{chat-program} command is the program -name to run. The remaining arguments are passed to the program. The -following escape sequences are recognized in the arguments: - -@table @kbd -@item \Y -port device name -@item \S -port speed -@item \\ -backslash -@end table - -Some specific uses of @code{chat-program} define additional escape -sequences. - -Arguments other than escape sequences are passed exactly as they appear -in the configuration file, except that sequences of whitespace are -compressed to a single space character; this exception may be removed in -the future. - -If the @code{chat-program} command is not used, no program is run. - -On Unix, the standard input and standard output of the program will be -attached to the port in use. Anything the program writes to standard -error will be written to the UUCP log file. No other file descriptors -will be open. If the program does not exit with a status of 0, it will -be assumed to have failed; this means that the dialing programs used by -some versions of BNU may not be used directly, although of course a -shell script could be used as an interface. - -The program will be run as the @code{uucp} user, and the environment -will be that of the process that started @code{uucico}, so care must be -taken to maintain security. - -No search path is used to find the program; a full path name must be -given. If the program is an executable shell script, it will be passed -to @file{/bin/sh} even on systems which are unable to execute shell -scripts. It is also easy to invoke @file{/bin/sh} directly. - -@end table - -Here is a simple example of a chat script that might be used to reset a -Hayes compatible modem. - -@example -chat "" ATZ OK-ATZ-OK -@end example - -The first expect string is @samp{""}, so it is ignored. The chat script -then sends @samp{ATZ}. If the modem responds with @samp{OK}, the chat -script finishes. If 60 seconds (the default timeout) pass before seeing -@samp{OK}, the chat script sends another @samp{ATZ}. If it then sees -@samp{OK}, the chat script succeeds. Otherwise, the chat script fails. - -For a more complex chat script example, see @ref{Logging In}. - -@node config File, sys File, Chat Scripts, Configuration Files -@section The Main Configuration File -@cindex config file -@cindex main configuration file -@cindex configuration file (config) - -The main configuration file is named @file{config}. - -Since all the values that may be specified in the main configuration -file also have defaults, there need not be a main configuration file at -all. - -@menu -* Miscellaneous (config):: Miscellaneous config file commands -* Configuration File Names:: Using different configuration files -* Log File Names:: Using different log files -* Debugging Levels:: Debugging levels -@end menu - -@node Miscellaneous (config), Configuration File Names, config File, config File -@subsection Miscellaneous config File Commands - -@table @code - -@item nodename @var{string} -@findex nodename -@itemx hostname @var{string} -@findex hostname -@itemx uuname @var{string} -@findex uuname -@cindex UUCP system name -@cindex system name - -These keywords are equivalent. They specify the UUCP name of the -local host. If there is no configuration file, an appropriate -function will be used to get the host name, if possible. - -@item spool @var{string} -@findex spool -@cindex spool directory -@cindex /usr/spool/uucp - -Specify the spool directory. The default is from @file{policy.h}. -Command files, work files, temporary files, etc., are stored in this -directory and in subdirectories of it. - -@item pubdir @var{string} -@findex pubdir in config file -@cindex public directory -@cindex uucppublic -@cindex /usr/spool/uucppublic - -Specify the public directory. The default is from @file{policy.h}. On -Unix, when a file is named using a leading @kbd{~/}, it is taken from or -to the public directory. Each system may use a separate public -directory by using the @code{pubdir} command in the system configuration -file; see @ref{Miscellaneous (sys)}. - -@item unknown @var{string} @dots{} -@findex unknown -@cindex unknown systems - -The @var{string} and subsequent arguments are treated as though they -appeared in the system file (@pxref{sys file}). They are used to apply -to any unknown systems that may call in, probably to set file transfer -permissions and the like. If the @code{unknown} command is not used, -unknown systems are not permitted to call in. - -@item max-uuxqts @var{number} -@findex max-uuxqts - -Specify the maximum number of @code{uuxqt} processes which may run at -the same time. Having several @code{uuxqt} processes running at once -can significantly slow down a system, but since @code{uuxqt} is -automatically started by @code{uucico}, it can happen quite easily. The -default for @code{max-uuxqts} is 0, which means that there is no limit. -If BNU configuration files are being read and the code was compiled -without @code{HAVE_TAYLOR_CONFIG}, then if the file @file{Maxuuxqts} in -the configuration directory contains a readable number it will be used as -the value for @code{max-uuxqts}. - -@item v2-files @var{boolean} -@findex v2-files - -If the code was compiled to be able to read V2 configuration files, a -false argument to this command will prevent them from being read. -This can be useful while testing. The default is true. - -@item bnu-files @var{boolean} -@findex bnu-files - -If the code was compiled to be able to read BNU configuration files, a -false argument to this command will prevent them from being read. -This can be useful while testing. The default is true. - -@end table - -@node Configuration File Names, Log File Names, Miscellaneous (config), config File -@subsection Configuration File Names - -@table @code - -@item sysfile @var{strings} -@findex sysfile - -Specify the system file(s). The default is the file @file{sys} in the -directory @var{newconfigdir}. These files hold information about other -systems with which this system communicates; see @ref{sys file}. -Multiple system files may be given on the line, and the @code{sysfile} -command may be repeated; each system file has its own set of defaults. - -@item portfile @var{strings} -@findex portfile - -Specify the port file(s). The default is the file @file{port} in the -directory @var{newconfigdir}. These files describe ports which are used -to call other systems and accept calls from other systems; see @ref{port -file}. No port files need be named at all. Multiple port files may be -given on the line, and the @code{portfile} command may be repeated. - -@item dialfile @var{strings} -@findex dialfile - -Specify the dial file(s). The default is the file @file{dial} in the -directory @var{newconfigdir}. These files describe dialing devices -(modems); @xref{dial file}. No dial files need be named at all. -Multiple dial files may be given on the line, and the @code{dialfile} -command may be repeated. - -@item dialcodefile @var{strings} -@findex dialcodefile -@cindex configuration file (dialcode) -@cindex dialcode file -@cindex dialcode configuration file - -Specify the dialcode file(s). The default is the file @file{dialcode} -in the directory @var{newconfigdir}. These files specify dialcodes that -may be used when sending phone numbers to a modem. This permits using -the same set of phone numbers in different area-codes or with different -phone systems, by using dialcodes to specify the calling sequence. When -a phone number goes through dialcode translation, the leading alphabetic -characters are stripped off. The dialcode files are read line by line, -just like any other configuration file, and when a line is found whose -first word is the same as the leading characters from the phone number, -the second word on the line (which would normally consist of numbers) -replaces the dialcode in the phone number. No dialcode file need be -used. Multiple dialcode files may be specified on the line, and the -@code{dialcodefile} command may be repeated; all the dialcode files will -be read in turn until a dialcode is located. - -@item callfile @var{strings} -@findex callfile -@cindex call out file -@cindex call configuration file -@cindex call out login name -@cindex call out password -@cindex configuration file (call) - -Specify the call out login name and password file(s). The default is -the file @file{call} in the directory @var{newconfigdir}. If the call -out login name or password for a system are given as @kbd{*} -(@pxref{Logging In}), these files are read to get the real login name or -password. Each line in the file(s) has three words: the system name, -the login name, and the password. This file is only used when placing -calls to remote systems; the password file described under -@code{passwdfile} below is used for incoming calls. The intention of -the call out file is to permit the system file to be publically -readable; the call out files must obviously be kept secure. These files -need not be used. Multiple call out files may be specified on the line, -and the @code{callfile} command may be repeated; all the files will be -read in turn until the system is found. - -@item passwdfile @var{strings} -@findex passwdfile -@cindex passwd file -@cindex passwd configuration file -@cindex configuration file (passwd) -@cindex call in login name -@cindex call in password - -Specify the password file(s) to use for login names when @code{uucico} -is doing its own login prompting, which it does when given the -@samp{-e}, @samp{-l} or @samp{-w} switch. The default is the file -@file{passwd} in the directory @var{newconfigdir}. Each line in the -file(s) has two words: the login name and the password (e.g. @code{Ufoo -foopas}). The login name is accepted before the system name is known, -so these are independent of which system is calling in; a particular -login may be required for a system by using the @code{called-login} -command in the system file (@pxref{Accepting a Call}). These password -files are optional, although one must exist if @code{uucico} is to -present its own login prompts. Multiple password files may be specified -on the line, and the @code{passwdfile} command may be repeated; all the -files will be read in turn until the login name is found. - -@end table - -@node Log File Names, Debugging Levels, Configuration File Names, config File -@subsection Log File Names - -@table @code - -@item logfile @var{string} -@findex logfile -@cindex log file - -Name the log file. The default is from @file{policy.h}. Logging -information is written to this file. If @code{HAVE_BNU_LOGGING} is -defined in @file{conf.h}, then by default a separate log file is used -for each system. Using this command to name a log file will cause all -the systems to use it. - -@item statfile @var{string} -@findex statfile -@cindex statistics file - -Name the statistics file. The default is from @file{policy.h}. -Statistical information about file transfers is written to this file. - -@item debugfile @var{string} -@findex debugfile -@cindex debugging file - -Name the file to which debugging information is written. The default is -from @file{policy.h}. This command is only effective if the code has -been compiled to include debugging (this is controlled by the -@code{DEBUG} variable in @file{policy.h}). After the first debugging -message has been written, messages written to the log file are also -written to the debugging file to make it easier to keep the order of -actions straight. The debugging file is different from the log file -because information such as passwords can appear in it, so it must be -not be publically readable. - -@end table - -@node Debugging Levels, , Log File Names, config File -@subsection Debugging Levels - -@table @code - -@item debug @var{string} @dots{} -@findex debug in config file - -Set the debugging level. This command is only effective if the code has -been compiled to include debugging. The default is to have no -debugging. The arguments are strings which name the types of debugging -to be turned on. The following types of debugging are defined: - -@table @samp -@item abnormal -Output debugging messages for abnormal situations, such as recoverable errors. -@item chat -Output debugging messages for chat scripts. -@item handshake -Output debugging messages for the initial handshake. -@item uucp-proto -Output debugging messages for the UUCP protocol itself. -@item proto -Output debugging messages for the individual protocols. -@item port -Output debugging messages for actions on the communication port. -@item config -Output debugging messages while reading the configuration files. -@item spooldir -Output debugging messages for actions in the spool directory. -@item execute -Output debugging messages whenever another program is executed. -@item incoming -List all incoming data in the debugging file. -@item outgoing -List all outgoing data in the debugging file. -@item all -All of the above. -@end table - -The debugging level may also be specified as a number. A 1 will set -@samp{chat} debugging, a 2 will set both @samp{chat} and -@samp{handshake} debugging, and so on down the possibilities. Currently -an 11 will turn on all possible debugging, since there are 11 types of -debugging messages listed above; more debugging types may be added in -the future. The @code{debug} command may be used several times in the -configuration file; every debugging type named will be turned on. When -running any of the programs, the @samp{-x} switch (actually, for -@code{uulog} it's the @samp{-X} switch) may be used to turn on -debugging. The argument to the @samp{-x} switch is one of the strings -listed above, or a number as described above, or a comma separated list -of strings (e.g. @samp{-x chat,handshake}). The @samp{-x} switch may -also appear several times on the command line, in which case all named -debugging types will be turned on. The @samp{-x} debugging is in -addition to any debugging specified by the @code{debug} command; there -is no way to cancel debugging information. The debugging level may also -be set specifically for calls to or from a specific system with the -@code{debug} command in the system file (@pxref{Miscellaneous (sys)}). - -The debugging messages are somewhat idiosyncratic; it may be necessary -to refer to the source code for additional information in some cases. - -@end table - -@node sys File, port File, config File, Configuration Files -@section The System Configuration File -@cindex sys file -@cindex system configuration file -@cindex configuration file (sys) - -By default there is a single system configuration, named @file{sys} in -the directory @var{newconfigdir}. This may be overridden by the -@code{sysfile} command in the main configuration file; see -@ref{Configuration File Names}. - -These files describe all remote systems known to the UUCP package. - -@menu -* Defaults and Alternates:: Using defaults and alternates -* Naming the System:: Naming the system -* Calling Out:: Calling out -* Accepting a Call:: Accepting a call -* Protocol Selection:: Protocol selection -* File Transfer Control:: File transfer control -* Miscellaneous (sys):: Miscellaneous sys file commands -* Default sys File Values:: Default values -@end menu - -@node Defaults and Alternates, Naming the System, sys File, sys File -@subsection Defaults and Alternates - -The first set of commands in the file, up to the first @code{system} -command, specify defaults to be used for all systems in that file. Each -system file uses a different set of defaults. - -Subsequently, each set of commands from @code{system} up to the next -@code{system} command describe a particular system. Default values may -be overridden for specific systems. - -Each system may then have a series of alternate choices to use when -calling out or calling in. The first set of commands for a particular -system, up to the first @code{alternate} command, provide the first -choice. Subsequently, each set of commands from @code{alternate} up to -the next @code{alternate} command describe an alternate choice for -calling out or calling in. - -When a system is called, the commands before the first @code{alternate} -are used to select a phone number, port, and so forth; if the call fails -for some reason, the commands between the first @code{alternate} and the -second are used, and so forth. Well, not quite. Actually, each -succeeding alternate will only be used if it is different in some -relevant way (different phone number, different chat script, etc.). If -you want to force the same alternate to be used again (to retry a phone -call more than once, for example), enter the phone number (or any other -relevant field) again to make it appear different. - -The alternates can also be used to give different permissions to an -incoming call based on the login name. This will only be done if the -first set of commands, before the first @code{alternate} command, uses -the @code{called-login} command. The list of alternates will be -searched, and the first alternate with a matching @code{called-login} -command will be used. If no alternates match, the call will be -rejected. - -The @code{alternate} command may also be used in the file-wide defaults -(the set of commands before the first @code{system} command). This -might be used to specify a list of ports which are available for all -systems (for an example of this, see @ref{Gateway Example}) or to -specify permissions based on the login name used by the remote system -when it calls in. The first alternate for each system will default to -the first alternate for the file-wide defaults (as modified by the -commands used before the first @code{alternate} command for this -system), the second alternate for each system to the second alternate -for the file-wide defaults (as modified the same way), and so forth. If -a system specifies more alternates than the file-wide defaults, the -trailing ones will default to the last file-wide default alternate. If -a system specifies fewer alternates than the file-wide defaults, the -trailing file-wide default alternates will be used unmodified. The -@code{default-alternates} command may be used to modify this behaviour. - -This can all get rather confusing, although it's easier to use than to -describe concisely; the @code{uuchk} program may be used to ensure that -you are getting what you want. - -@node Naming the System, Calling Out, Defaults and Alternates, sys File -@subsection Naming the System - -@table @code - -@item system @var{string} -@findex system - -Specify the remote system name. Subsequent commands up to the next -@code{system} command refer to this system. - -@item alternate [@var{string}] -@findex alternate - -Start an alternate set of commands (@pxref{Defaults and Alternates}). -An optional argument may be used to name the alternate. This name will -be put in the log file if the alternate is used to call the system. -There is no way to name the first alternate (the commands before the -first @code{alternate} command). - -@item default-alternates @var{boolean} -@findex default-alternates - -If the argument is false, any remaining default alternates (from the -defaults specified at the top of the current system file) will not be -used. The default is true. - -@item alias @var{string} -@findex alias - -Specify an alias for the current system. The alias may be used by local -@code{uucp} and @code{uux} commands. The default is to have no aliases. - -@item myname @var{string} -@findex myname - -Specifies a different system name to use when calling the remote system. -Also, if @code{called-login} is used and is not @samp{ANY}, then, when a -system logs in with that login name, @var{string} is used as the system -name. Because the local system name must be determined before the -remote system has identified itself, using @code{myname} and -@code{called-login} together for any system will set the local name for -that login; this means that each locally used system name must have a -unique login name associated with it. This allows a system to have -different names for an external and an internal network. The default is -to not use a special local name. - -@end table - -@node Calling Out, Accepting a Call, Naming the System, sys File -@subsection Calling Out - -This section describes commands used when placing a call to another -system. - -@menu -* When to Call:: When to call -* Placing the Call:: Placing the call -* Logging In:: Logging in -@end menu - -@node When to Call, Placing the Call, Calling Out, Calling Out -@subsubsection When to Call - -@table @code - -@item time @var{string} [@var{number}] -@findex time - -Specify when the system may be called. The first argument is a time -string; see @ref{Time Strings}. The optional second argument specifies -a retry time in minutes. If a call made during a time that matches the -time string fails, no more calls are permitted until the retry time has -passed. By default an exponentially increasing retry time is used: -after each failure the next retry period is longer. A retry time -specified in the @code{time} command is always a fixed amount of time. - -The @code{time} command may appear multiple times in a single alternate, -in which case if any time string matches the system may be called. The -default time string is @samp{Never}. - -@item timegrade @var{character} @var{string} [@var{number}] -@findex timegrade - -The @var{character} specifies a grade. It must be a single letter or -digit. The @var{string} is a time string (@pxref{Time Strings}). All -jobs of grade @var{character} or higher (where @kbd{0} > @kbd{9} > -@kbd{A} > @kbd{Z} > @kbd{a} > @kbd{z}) may be run at the specified time. -An ordinary @code{time} command is equivalent to using @code{timegrade} -with a grade of @kbd{z}, permitting all jobs. If there are no jobs of a -sufficiently high grade according to the time string, the system will -not be called. Giving the @samp{-s} switch to @code{uucico} to force it -to call a system causes it to assume there is a job of grade @kbd{0} -waiting to be run. - -The optional third argument specifies a retry time in minutes. See the -@code{time} command, above, for more details. - -Note that the @code{timegrade} command serves two purposes: 1) if there -is no job of sufficiently high grade the system will not be called, and -2) if the system is called anyway (because the @samp{-s} switch was -given to @code{uucico}) only jobs of sufficiently high grade will be -transferred. However, if the other system calls in, the -@code{timegrade} commands are ignored, and jobs of any grade may be -transferred (but see @code{call-timegrade} below). Also, the -@code{timegrade} command will not prevent the other system from -transferring any job it chooses, regardless of who placed the call. - -The @code{timegrade} command may appear multiple times without using -@code{alternate}. If this command does not appear, there are no -restrictions on what grade of work may be done at what time. - -@item call-timegrade @var{character} @var{string} -@findex call-timegrade - -The @var{character} is a single character @kbd{A} to @kbd{Z}, @kbd{a} to -@kbd{z}, or @kbd{0} to @kbd{9} and specifies a grade. The @var{string} -is a time string as described under the @code{time} command. If a call -is placed to the other system during a time which matches the time -string, the remote system will be requested to only run jobs of grade -@var{character} or higher. Unfortunately, there is no way to guarantee -that the other system will obey the request (this UUCP package will, but -there are others which will not); moreover job grades are historically -somewhat arbitrary, so specifying a grade will only be meaningful if the -other system cooperates in assigning grades. This grade restriction -only applies when the other system is called, not when the other system -calls in. - -The @code{call-timegrade} command may appear multiple times without -using @code{alternate}. If this command does not appear, or if none of -the time strings match, the remote system will be allowed to send -whatever grades of work it chooses. - -@end table - -@node Placing the Call, Logging In, When to Call, Calling Out -@subsubsection Placing the Call - -@table @code - -@item baud @var{number} -@findex baud in sys file -@itemx speed @var{number} -@findex speed in sys file - -Specify the speed (the term @dfn{baud} is technically incorrect, but -widely understood) at which to call the system. This will try all -available ports with that baud rate until an unlocked port is found. -The ports are defined in the port file. If both @code{baud} and -@code{port} commands appear, both are used when selecting a port. To -allow calls at more than one baud rate, the @code{alternate} command -must be used (@pxref{Defaults and Alternates}). If this command does -not appear, there is no default; the baud rate may be specified in the -port file, but if it is not then the natural baud rate of the port will -be used (whatever that means on the system). Specifying an explicit -baud rate of 0 will request the natural baud rate of the port, -overriding any default baud rate from the defaults at the top of the -file. - -@item port @var{string} -@findex port in sys file - -Name a particular port or type of port to use when calling the system. -The information for this port is obtained from the port file. If this -command does not appear, there is no default; a port must somehow be -specified in order to call out (it may be specified implicitly using the -@code{baud} command or explicitly using the next version of -@code{port}). There may be many ports with the same name; each will be -tried in turn until an unlocked one is found which matches the desired -baud rate. - -@item port @var{string} @dots{} - -If more than one string follows the @code{port} command, the subsequent -strings are treated as commands that might appear in the port file -(@pxref{port file}). If a port is named (by using a single string -following @code{port}) these commands are ignored; their purpose is to -permit defining the port completely in the system file rather than -always requiring entries in two different files. In order to call out, -a port must be specified using some version of the @code{port} command, -or by using the @code{baud} command to select ports from the port file. - -@item phone @var{string} -@findex phone -@itemx address @var{string} -@findex address - -Give a phone number to call (when using a modem port) or a remote host -to contact (when using a TCP port). The commands @code{phone} and -@code{address} are equivalent, but are intended to be more mnemonic -depending on the type of port in use. - -When used with a modem port, an @kbd{=} character in the phone number -means to wait for a secondary dial tone (although only some modems -support this); a @kbd{-} character means to pause while dialing for 1 -second (again, only some modems support this). If the system has more -than one phone number, each one must appear in a different alternate. -The @code{phone} command must appear in order to call out on a modem; -there is no default. - -When used with a TCP port, the string names the host to contact. It may -be a domain name or a numeric Internet address. If no address is -specified, the system name is used. - -When used with a port that neither is a modem nor TCP, this command is -ignored. - -@end table - -@node Logging In, , Placing the Call, Calling Out -@subsubsection Logging In -@table @code - -@item chat @var{strings} -@findex chat in sys file -@item chat-timeout @var{number} -@findex chat-timeout in sys file -@item chat-fail @var{string} -@findex chat-fail in sys file -@item chat-seven-bit @var{boolean} -@findex chat-seven-bit in sys file -@item chat-program @var{strings} -@findex chat-program in sys file - -These commands describe a chat script to use when logging on to a remote -system. Chat scripts are explained in @ref{Chat Scripts}. - -Two additional escape sequences may be used in send strings. - -@table @samp -@item \L -Send the login name, as set by the @code{call-login} command. -@item \P -Send the passowrd, as set by the @code{call-password} command. -@end table - -Three additional escape sequences may be used with the -@code{chat-program} command. These are @samp{\L} and @samp{\P}, which -become the login name and password, respectively, and @samp{\Z}, which -becomes the name of the system of being called. - -The default chat script is: - -@example -chat "" \r\c ogin:-BREAK-ogin:-BREAK-ogin: \L word: \P -@end example - -This will send a carriage return (the @kbd{\c} suppresses the additional -trailing carriage return that would otherwise be sent) and waits for the -string @samp{ogin:} (which would be the last part of the @samp{login:} -prompt supplied by a Unix system). If it doesn't see @samp{ogin:}, it -sends a break and waits for @samp{ogin:} again. If it still doesn't see -@samp{ogin:}, it sends another break and waits for @samp{ogin:} again. -If it still doesn't see @samp{ogin:}, the chat script aborts and hangs -up the phone. If it does see @samp{ogin:} at some point, it sends the -login name (as specified by the @code{call-login} command) followed by a -carriage return (since all send strings are followed by a carriage -return unless @kbd{\c} is used) and waits for the string @samp{word:} -(which would be the last part of the @samp{Password:} prompt supplied by -a Unix system). If it sees @samp{word:}, it sends the password and a -carriage return, completing the chat script. The program will then -enter the handshake phase of the UUCP protocol. - -This chat script will work for most systems, so you will only be -required to use the @code{call-login} and @code{call-password} commands. -In fact, in the file-wide defaults you could set defaults of -@samp{call-login *} and @samp{call-password *}; you would then just have -to make an entry for each system in the call-out login file. - -Some systems seem to flush input after the @samp{login:} prompt, so they -may need a version of this chat script with a @kbd{\d} before the -@kbd{\L}. When using UUCP over TCP, some servers will not be handle the -initial carriage return sent by this chat script; in this case you may -have to specify the simple chat script @samp{ogin: \L word: \P}. - -@item call-login @var{string} -@findex call-login - -Specify the login name to send with @kbd{\L} in the chat script. If the -string is @samp{*} (e.g. @samp{call-login *}) the login name will be -fetched from the call out login name and password file -(@pxref{Configuration File Names}). There is no default. - -@item call-password @var{string} -@findex call-password - -Specify the password to send with @kbd{\P} in the chat script. If the -string is @samp{*} (e.g. @samp{call-password *}) the password will be -fetched from the call-out login name and password file -(@pxref{Configuration File Names}). There is no default. - -@end table - -@node Accepting a Call, Protocol Selection, Calling Out, sys File -@subsection Accepting a Call - -@table @code - -@item called-login @var{strings} -@findex called-login - -The first @var{string} specifies the login name that the system must use -when calling in. If it is @samp{ANY} (e.g. @samp{called-login ANY}) any -login name may be used; this is useful to override a file-wide default -and to indicate that future alternates may have different login names. -Case is significant. The default value is @samp{ANY}. - -Different alternates (@pxref{Defaults and Alternates}) may use different -@code{called-login} commands, in which case the login name will be used -to select which alternate is in effect; this will only work if the first -alternate (before the first @code{alternate} command) uses the -@code{called-login} command. - -Additional strings may be specified after the login name; they are a -list of which systems are permitted to use this login name. If this -feature is used, then normally the login name will only be given in a -single @code{called-login} command. Only systems which appear on the -list, or which use an explicit @code{called-login} command, will be -permitted to use that login name. If the same login name is used more -than once with a list of systems, all the lists are concatenated -together. This feature permits you to restrict a login name to a -particular set of systems without requiring you to use the -@code{called-login} command for every single system; you can achieve a -similar effect by using a different system file for each permitted login -name with an appropriate @code{called-login} command in the file-wide -defaults. - -@item callback @var{boolean} -@findex callback - -If @var{boolean} is true, then when the remote system calls -@code{uucico} will hang up the connection and prepare to call it back. -This is false by default. - -@item called-chat @var{strings} -@findex called-chat -@item called-chat-timeout @var{number} -@findex called-chat-timeout -@item called-chat-fail @var{string} -@findex called-chat-fail -@item called-chat-seven-bit @var{boolean} -@findex called-chat-seven-bit -@item called-chat-program @var{strings} -@findex called-chat-program - -These commands may be used to define a chat script (@pxref{Chat -Scripts}) that is run whenever the local system is called by the system -being defined. The chat script defined by the @code{chat} command -(@pxref{Logging In}), on the other hand, is used when the remote system -is called. This called chat script might be used to set special modem -parameters that are appropriate to a particular system. It is run after -protocol negotiation is complete, but before the protocol has been -started. See @ref{Logging In} for additional escape sequence which may -be used besides those defined for all chat scripts. There is no default -called chat script. If the called chat script fails, the incoming call -will be aborted. - -@end table - -@node Protocol Selection, File Transfer Control, Accepting a Call, sys File -@subsection Protocol Selection - -@table @code - -@item protocol @var{string} -@findex protocol in sys file - -Specifies which protocols to use for the other system, and in which -order to use them. This would not normally be used. For example, -@samp{protocol tfg}. - -The default depends on the characteristics of the port and the dialer, -as specified by the @code{seven-bit} and @code{reliable} commands. If -neither the port nor the dialer use either of these commands, the -default is to assume an eight-bit reliable connection. The commands -@samp{seven-bit true} or @samp{reliable false} might be used in either -the port or the dialer to change this. Each protocol has particular -requirements that must be met before it will be considered during -negotiation with the remote side. - -The @samp{t} and @samp{e} protocols are intended for use over TCP or -some other communication path with end to end reliability, as they do no -checking of the data at all. They will only be considered on a TCP port -which is both reliable and eight bit. - -The @samp{g} protocol is robust, but requires an eight-bit connection. - -The @samp{f} protocol is intended for use with X.25 connections; it -checksums each file as a whole, so any error causes the entire file to -be retransmitted. It requires a reliable connection, but only uses -seven-bit transmissions. It is a streaming protocol, so, while it can -be used on a serial port, the port must be completely reliable and flow -controlled; many aren't. - -The protocols will be considered in the order shown above. This means -that if neither the @code{seven-bit} nor the @code{reliable} command are -used, the @samp{t} protocol will be used over a TCP connection and the -@samp{g} protocol will be used over any other type of connection -(subject, of course, to what is supported by the remote system; it may -be assumed that all systems support the @samp{g} protocol). - -Note that currently specifying both @samp{seven-bit true} and -@samp{reliable false} will not match any protocol. If this occurs -through a combination of port and dialer specifications, you will have -to use the @code{protocol} command for the system or no protocol will be -selected at all (the only reasonable choice would be @samp{protocol f}). - -A protocol list may also be specified for a port (@pxref{port file}), -but if there is a list for the system the list for the port is ignored. - -@item protocol-parameter @var{character} @var{string} @dots{} -@findex protocol-parameter in sys file - -@var{character} is a single character specifying a protocol. The -remaining strings are a command specific to that protocol which will be -executed if that protocol is used. A typical command is something like -@samp{window 7}. The particular commands are protocol specific. - -The @samp{g} protocol supports the following commands, all of which take -numeric arguments: - -@table @code -@item window -The window size to request the remote system to use. This must be -between 1 and 7 inclusive. The default is 7. -@item packet-size -The packet size to request the remote system to use. This must be a -power of 2 between 32 and 4096 inclusive. The default is 64, which is -the only packet size supported by many older UUCP packages. Some UUCP -packages will even dump core if a larger packet size is requested. -@item startup-retries -The number of times to retry the initialization sequence. The default -is 8. -@item init-retries -The number of times to retry one phase of the initialization sequence -(there are three phases). The default is 4. -@item init-timeout -The timeout in seconds for one phase of the initialization sequence. The -default is 10. -@item retries -The number of times to retry sending either a data packet or a request -for the next packet. The default is 6. -@item timeout -The timeout in seconds when waiting for either a data packet or an -acknowledgement. The default is 10. -@item garbage -The number of unrecognized bytes to permit before dropping the -connection. This must be larger than the packet size. The default is -10000. -@item errors -The number of errors (malformed packets, out of order packets, bad -checksums, or packets rejected by the remote system) to permit before -dropping the connection. The default is 100. -@item remote-window -If this is between 1 and 7 inclusive, the window size requested by the -remote system is ignored and this is used instead. This can be useful -when dealing with some poor UUCP packages. The default is 0, which -means that the remote system's request is honored. -@item remote-packet-size -If this is between 32 and 4096 inclusive the packet size requested by -the remote system is ignored and this is used instead. There is -probably no good reason to use this. The default is 0, which means that -the remote system's request is honored. -@end table - -The @samp{f} protocol is intended for use with error-correcting modems -only; it checksums each file as a whole, so any error causes the entire -file to be retransmitted. It supports the following commands, both of -which take numeric arguments: - -@table @code -@item timeout -The timeout in seconds before giving up. The default is 120. -@item retries -How many times to retry sending a file. The default is 2. -@end table - -The @samp{t} and @samp{e} protocols are intended for use over TCP or -some other communication path with end to end reliability, as they do no -checking of the data at all. They both support a single command, which -takes a numeric argument: - -@table @code -@item timeout -The timeout in seconds before giving up. The default is 120. -@end table - -The protocol parameters are reset to their default values after each -call. - -@end table - -@node File Transfer Control, Miscellaneous (sys), Protocol Selection, sys File -@subsection File Transfer Control - -@table @code - -@item call-request @var{boolean} -@findex call-request - -The @var{boolean} is checked when the local system places the call. It -determines whether the remote system may request any file transfers. -The default is yes. - -@item called-request @var{boolean} -@findex called-request - -The @var{boolean} is checked when the remote system calls in. It -determines whether the remote system may request any file transfers. -The default is yes. - -@item request @var{boolean} -@findex request - -Equivalent to specifying both @samp{call-request @var{boolean}} and -@samp{called-request @var{boolean}}. - -@item call-transfer @var{boolean} -@findex call-transfer - -The @var{boolean} is checked when the local system places the call. It -determines whether the local system may do file transfers queued up for -the remote system. The default is yes. - -@item called-transfer @var{boolean} -@findex called-transfer - -The @var{boolean} is checked when the remote system calls in. It -determines whether the local system may do file transfers queued up for -the remote system. The default is yes. - -@item transfer @var{boolean} -@findex transfer - -Equivalent to specifying both @samp{call-transfer @var{boolean}} -@samp{called-transfer @var{boolean}}. - -@item call-local-size @var{number} @var{string} -@findex call-local-size - -The @var{string} is a time string (@pxref{Time Strings}). The -@var{number} is the size in bytes of the largest file that should be -transferred at a time matching the time string if the local system -placed the call and the request was made by the local system. This -command may appear multiple times in a single alternate. If this -command does not appear, or if none of the time strings match, there are -no size restrictions. - -With all the size control commands, the size of a file from the remote -system (as opposed to a file from the local system) will only be checked -if the other system is running this package; other UUCP packages will -not understand a maximum size request, nor will they inform this package -of the size of remote files. - -@item call-remote-size @var{number} @var{string} -@findex call-remote-size - -Specify the size in bytes of the largest file that should be -transferred at a given time by remote request when the local system -placed the call. This command may appear multiple times in a single -alternate. If this command does not appear, there are no size -restrictions. - -@item called-local-size @var{number} @var{string} -@findex called-local-size - -Specify the size in bytes of the largest file that should be transferred -at a given time by local request when the remote system placed the call. -This command may appear multiple times in a single alternate. If this -command does not appear, there are no size restrictions. - -@item called-remote-size @var{number} @var{string} -@findex called-remote-size - -Specify the size in bytes of the largest file that should be transferred -at a given time by remote request when the remote system placed the -call. This command may appear multiple times in a single alternate. If -this command does not appear, there are no size restrictions. - -@item local-send @var{strings} -@findex local-send - -Specifies that files in the directories named by the @var{strings} may -be sent to the remote system when requested locally (using @code{uucp} -or @code{uux}). The directories in the list should be separated by -whitespace. A @kbd{~} may be used for the public directory. On a Unix -system, this is typically @file{/usr/spool/uucppublic}; the public -directory may be set with the @code{pubdir} command. Here is an example -of @code{local-send}: - -@example -local-send ~ /usr/spool/ftp/pub -@end example - -Listing a directory allows all files within the directory and all -subdirectories to be sent. Directories may be excluded by preceding -them with an exclamation point. For example: - -@example -local-send /usr/ftp !/usr/ftp/private ~ -@end example - -@noindent -means that all files in @file{/usr/ftp} or the public directory may be -sent, except those files in @file{/usr/ftp/private}. The list of -directories is read from left to right, and the last directory to apply -takes effect; this means that directories should be listed from top -down. The default is the root directory (i.e., any file at all may be -sent by local request). - -@item remote-send @var{strings} -@findex remote-send - -Specifies that files in the named directories may be sent to the remote -system when requested by the remote system. The default is @kbd{~}. - -@item local-receive @var{strings} -@findex local-receive - -Specifies that files may be received into the named directories when -requested by a local user. The default is @kbd{~}. - -@item remote-receive @var{strings} -@findex remote-receive - -Specifies that files may be received into the named directories when -requested by the remote system. The default is @kbd{~}. On Unix, the -remote system may only request that files be received into directories -that are writeable by the world, regardless of how this is set. - -@end table - -@node Miscellaneous (sys), Default sys File Values, File Transfer Control, sys File -@subsection Miscellaneous sys File Commands - -@table @code - -@item sequence @var{boolean} -@findex sequence - -If @var{boolean} is true, then conversation sequencing is automatically -used for the remote system, so that if somebody manages to spoof as the -remote system, it will be detected the next time the remote system -actually calls. This is false by default. - -@item command-path @var{string} -@findex command-path - -Specifies the path (a list of whitespace separated directories) to be -searched to locate commands to execute. This is only used for commands -requested by @code{uux}, not for chat programs. The default is from -@file{policy.h}. - -@item commands @var{strings} -@findex commands - -The list of commands which the remote system is permitted to execute -locally. For example: @samp{commands rnews rmail}. If the value is -@samp{ALL} (case significant), all commands may be executed. The -default is @samp{rnews rmail}. - -@item free-space @var{number} -@findex free-space - -Specify the minimum amount of file system space (in bytes) to leave free -after receiving a file. If the incoming file will not fit, it will be -rejected. This will only work when talking to another instance of this -package, since older UUCP packages do not provide the file size of -incoming files. There is no provision for reserving space, so it is -still possible for multiple @code{uucico} daemons to use up all -available file space; a sufficiently large value for @code{free-space} -will avoid this problem to some extent. The default is from -@file{policy.h}. Not all systems may be able to provide the amount of -available space. - -@item pubdir @var{string} -@findex pubdir in sys file - -Specifies the public directory that is used when @kbd{~} is specifed in -a file transfer or a list of directories. This essentially overrides -the public directory specified in the main configuration file for this -system only. The default is the public directory specified in the main -configuration file (which defaults to a value from @file{policy.h}). - -@item debug @var{string} @dots{} -@findex debug in sys file - -Set additional debugging for calls to or from the system. This may be -used to debug a connection with a specific system. It is particularly -useful when debugging incoming calls, since debugging information will -be generated whenever the call comes in. See the @code{debug} command -in the main configuration file (@pxref{Debugging Levels}) for more -details. The debugging information specified here is in addition to -that specified in the main configuration file or on the command line. - -@item max-remote-debug @var{string} @dots{} -@findex max-remote-debug - -When the system calls in, it may request that the debugging level be set -to a certain value. This command may be used to put a limit on the -debugging level which the system may request, to avoid filling up the -disk with debugging information. Only the debugging types named in the -@code{max-remote-debug} command may be turned on by the remote system. -To prohibit any debugging, use @samp{max-remote-debug none}. The -default is @samp{abnormal,chat,handshake}; to turn off these default -entries, you must use @samp{max-remote-debug none} followed by other -@code{max-remote-debug} commands specifying the settings you want. - -@item timetable @var{string} @var{string} -@findex timetable - -This is actually not specific to a system; it can appear anywhere in the -file(s). In a future release this command will probably be moved to the -main configuration file. - -The @code{timetable} defines a timetable that may be used in -subsequently appearing time strings; @ref{Time Strings}. The first -string names the timetable entry; the second is a time string. - -The following @code{timetable} commands are predefined. The NonPeak -timetable is included for compatibility. It originally described the -offpeak hours of Tymnet and Telenet, but both have since changed their -schedules. - -@example -timetable Evening Wk1705-0755,Sa,Su -timetable Night Wk2305-0755,Sa,Su2305-1655 -timetable NonPeak Wk1805-0655,Sa,Su -@end example - -If this command does not appear, then obviously no additional timetables -will be defined. - -@end table - -@node Default sys File Values, , Miscellaneous (sys), sys File -@subsection Default sys File Values - -The following are used as default values for all systems; they can be -considered as appearing before the start of the file. - -@example -timetable Evening Wk1705-0755,Sa,Su -timetable Night Wk2305-0755,Sa,Su2305-1655 -timetable NonPeak Wk1805-0655,Sa,Su -time Never -chat "" \r\c ogin:-BREAK-ogin:-BREAK-ogin: \L word: \P -chat-timeout 10 -callback n -sequence n -request y -transfer y -local-send / -remote-send ~ -local-receive ~ -remove-receive ~ -command-path [ from @file{policy.h} ] -commands rnews rmail -max-remote-debug abnormal,chat,handshake -@end example - -@node port File, dial File, sys File, Configuration Files -@section The Port Configuration File -@cindex port file -@cindex port configuration file -@cindex configuration file (port) - -The port files may be used to name and describe ports. The first -command in each file must be @code{port}. All command up to the next -@code{port} command then describe that port. There are different types -of ports; each type supports its own set of commands. Each command -indicates which types of ports support it. There may be many ports with -the same name; if a system requests a port by name then each port with -that name will be tried until an unlocked one is found. - -@table @code - -@item port @var{string} -@findex port in port file - -Introduces and names a port. - -@item type @var{string} -@findex type - -Define the type of port. The default is @samp{modem}. If this command -appears, it must immediately follow the @code{port} command. The type defines -what commands are subsequently allowed. Currently the types are: - -@table @samp -@item modem -For a modem hookup. -@item stdin -For a connection through standard input and standard output, as when -@code{uucico} is run as a login shell. -@item direct -For a direct connection to another system. -@item tcp -For a connection using TCP. -@end table - -@item protocol @var{string} -@findex protocol in port file - -Specify a list of protocols to use for this port. This is just like the -corresponding command for a system (@pxref{Protocol Selection}). A -protocol list for a system takes precedence over a list for a port. - -@item protocol-parameter @var{character} @var{strings} [ any type ] -@findex protocol-parameter in port file - -The same command as the @code{protocol-parameter} command used for -systems (@pxref{Protocol Selection}). This one takes precedence. - -@item seven-bit @var{boolean} [ any type ] -@findex seven-bit in port file - -This is only used during protocol negotiation; if the argument is -@samp{true}, it forces the selection of a protocol which works across a -seven-bit link. It does not prevent eight bit characters from being -transmitted. The default is @samp{false}. - -@item reliable @var{boolean} [ any type ] -@findex reliable in port file - -This is only used during protocol negotiation; if the argument is -@samp{false}, it forces the selection of a protocol which works across -an unreliable communication link. The default is @samp{true}. It would -be more common to specify this for a dialer rather than a port. - -@item device @var{string} [ modem and direct only ] -@findex device - -Names the device associated with this port. If the device is not named, -the port name is taken as the device. Device names are system -dependent, but a Unix example would be @file{/dev/ttyd0}. - -@item baud @var{number} [ modem and direct only ] -@findex baud in port file -@itemx speed @var{number} [modem and direct only ] -@findex speed in port file - -The speed this port runs at. If a system specifies a speed but no port -name, then all ports which match the speed will be tried in order. If -the speed is not specified here and is not specified by the system, the -natural speed of the port will be used by default. - -@item baud-range @var{number} @var{number} [ modem only ] -@findex baud-range -@itemx speed-range @var{number} @var{number} [ modem only ] -@findex speed-range - -Specify a range of speeds this port can run at. The first number is the -minimum speed, the second number is the maximum speed. These numbers -will be used when matching a system which specifies a desired speed. -The simple @code{speed} (or @code{baud}) command is still used to -determine the speed to run at if the system does not specify a speed. -For example, the command @samp{speed-range 300 19200} means that the -port will match any system which uses a speed from 300 to 19200 baud -(and will use the speed specified by the system); this could be combined -with @samp{speed 2400}, which means that when this port is used with a -system that does not specify a speed, the port will be used at 2400 -baud. - -@item carrier @var{boolean} [ modem only ] -@findex carrier in port file - -The argument indicates whether the port supports carrier. If it does -not, carrier will never be required on this port, regardless of what the -modem chat script indicates. The default is @samp{true}. - -@item dial-device @var{string} [ modem only ] -@findex dial-device - -Dialing instructions should be output to the named device, rather than -to the normal port device. The default is to output to the normal port -device. - -@item dialer @var{string} [ modem only ] -@findex dialer in port file - -Name a dialer to use. The information is looked up in the dialer file. -There is no default. Some sort of dialer information must be specified -to call out on a modem. - -@item dialer @var{string} @dots{} [ modem only ] - -Execute a dialer command. If a dialer is named (by using the first form -of this command, described just above), these commands are ignored. -They may be used to specify dialer information directly in simple -situations without needing to go to a separate file. There is no -default. Some sort of dialer information must be specified to call out -on a modem. - -@item dialer-sequence @var{strings} [ modem only ] -@findex dialer-sequence - -Name a sequence of dialers and tokens (phone numbers) to use. The first -argument names a dialer, and the second argument names a token. The -third argument names another dialer, and so on. If there are an odd -number of arguments, the phone number specified with a @code{phone} -command in the system file is used as the final token. The token is -what is used for @kbd{\D} or @kbd{\T} in the dialer chat script. If the -token in this string is @kbd{\D}, the system phone number will be used; -if it is @kbd{\T}, the system phone number will be used after undergoing -dialcodes translation. A missing final token is taken as @kbd{\D}. - -This command currently does not work if @code{dial-device} is specified; -to handle this correctly will require a more systematic notion of chat -scripts. Moreover, only the @code{complete} and @code{abort} chat -scripts from the first dialer specified are used, and only the protocol -parameters from the first dialer are used. - -@item lockname @var{string} [ modem and direct only ] -@findex lockname - -Give the name to use when locking this port. On Unix, this is the name -of the file that will be created in the lock directory. It is used as -is, so on Unix it should generally start with @samp{LCK..}. For -example, if a single port were named both @file{/dev/ttycu0} and -@file{/dev/tty0} (perhaps with different characteristics keyed on the -minor device number), then the command @code{lockname LCK..ttycu0} could -be used to force the latter to use the same lock file name as the -former. - -@item service @var{string} [ tcp only ] -@findex service - -Name the TCP port number to use. This may be a number. If not, it will -be looked up in @file{/etc/services}. If this is not specified, the -string @samp{uucp} is looked up in @file{/etc/services}. If it is not -found, port number 540 (the standard UUCP-over-TCP port number) will be -used. - -@end table - -@node dial File, Security, port File, Configuration Files -@section The Dialer Configuration File -@cindex dial file -@cindex dialer configuration file -@cindex configuration file (dial) - -The dialer configuration files define dialers. The first command in -each file must be a @code{dialer} command, which names the dialer. -Subsequent commands up to the next @code{dialer} command are associated -with the named dialer. - -@table @code - -@item dialer @var{string} -@findex dialer in dial file - -Introduces and names a dialer. - -@item chat @var{strings} -@findex chat in dial file -@item chat-timeout @var{number} -@findex chat-timeout in dial file -@item chat-fail @var{string} -@findex chat-fail in dial file -@item chat-seven-bit @var{boolean} -@findex chat-seven-bit in dial file -@item chat-program @var{strings} -@findex chat-program in dial file - -Specify a chat script to be used to dial the phone. See @ref{Chat -Scripts} for full details on chat scripts. - -Taylor UUCP will sleep for one second between attempts to dial out on a -modem. If your modem requires a longer wait period, you must start your -chat script with delays (@samp{\d} in a send string). - -The chat script will be read from and sent to the port specified by the -@code{dial-device} command for the port, if there is one. - -The following escape addition escape sequences may appear in send -strings: - -@table @kbd -@item \D -send phone number without dialcode translation -@item \T -send phone number with dialcode translation -@item \M -do not require carrier -@item \m -require carrier (fail if not present) -@end table - -See the description of the dialcodes file (@pxref{Configuration File -Names}) for a description of dialcode translation. If the port does not -support carrier (as set by the @code{carrier} command in the port file) -@kbd{\M} and @kbd{\m} are ignored. If both the port and the dialer -support carrier (as set by the @code{carrier} command in the port file -and the @code{carrier} command in the dialer file), then every chat -script implicitly begins with @kbd{\M} and ends with @kbd{\m}. There is -no default chat script for dialers. - -The following additional escape sequences may be used in -@code{chat-program}: - -@table @kbd -@item \D -phone number without dialcode translation -@item \T -phone number with dialcode translation -@end table - -If the program changes the port in any way (e.g., sets parity) the -changes will be preserved during protocol negotiation, but once the -protocol is selected it will change the port settings. - -@item dialtone @var{string} -@findex dialtone - -A string to output when dialing the phone number which causes the modem -to wait for a secondary dial tone. This is used to translate the -@kbd{=} character in a phone number. The default is a comma. - -@item pause @var{string} -@findex pause - -A string to output when dialing the phone number which causes the modem -to wait for 1 second. This is used to translate the @kbd{-} character -in a phone number. The default is a comma. - -@item carrier @var{boolean} -@findex carrier in dial file - -If the argument is @samp{true}, the dialer supports the modem carrier -signal. After the phone number is dialed, @code{uucico} will require -that carrier be on. One some systems, it will be able to wait for it. -If the argument is @samp{false}, carrier will not be required. The -default is @samp{true}. - -@item carrier-wait @var{number} -@findex carrier-wait - -If the port is supposed to wait for carrier, this may be used to -indicate how many seconds to wait. The default is 60 seconds. Only -some systems support waiting for carrier. - -@item dtr-toggle @var{boolean} @var{boolean} -@findex dtr-toggle - -If the first argument is @samp{true}, then DTR is toggled before using -the modem. This is only supported on some systems and some ports. The -second @var{boolean} need not be present; if it is, and it is -@samp{true}, the program will sleep for 1 second after toggling DTR. -The default is not to toggle DTR. - -@item complete-chat @var{strings} -@findex complete-chat -@item complete-chat-timeout @var{number} -@findex complete-chat-timeout -@item complete-chat-fail @var{string} -@findex complete-chat-fail -@item complete-chat-seven-bit @var{boolean} -@findex complete-chat-seven-bit -@item complete-chat-program @var{strings} -@findex complete-chat-program - -These commands define a chat script (@pxref{Chat Scripts}) which is run -when a call is finished normally. This allows the modem to be reset. -There is no default. No additional escape sequences may be used. - -@item complete @var{string} -@findex complete - -This is a simple use of @code{complete-chat}. It is equivalent to -@code{complete-chat "" @var{string}}; this has the effect of sending -@var{string} to the modem when a call finishes normally. - -@item abort-chat @var{strings} -@findex abort-chat -@item abort-chat-timeout @var{number} -@findex abort-chat-timeout -@item abort-chat-fail @var{string} -@findex abort-chat-fail -@item abort-chat-seven-bit @var{boolean} -@findex abort-chat-seven-bit -@item abort-chat-program @var{strings} -@findex abort-chat-program - -These commands define a chat script (@pxref{Chat Scripts}) to be run -when a call is aborted. They may be used to interrupt and reset the -modem. There is no default. No additional escape sequences may be -used. - -@item abort @var{string} -@findex abort - -This is a simple use of @code{abort-chat}. It is equivalent to -@code{abort-chat "" @var{string}}; this has the effect of sending -@var{string} to the modem when a call is aborted. - -@item protocol-parameter @var{character} @var{strings} -@findex protocol-parameter in dial file - -Set protocol parameters, just like the @code{protocol-parameter} command -in the system configuration file or the port configuration file; see -@ref{Protocol Selection}. These parameters take precedence, then those -for the port, then those for the system. - -@item seven-bit @var{boolean} -@findex seven-bit in dial file - -This is only used during protocol negotiation; if it is @samp{true}, it -forces selection of a protocol which works across a seven-bit link. It -does not prevent eight bit characters from being transmitted. The -default is @samp{false}. It would be more common to specify this for a -port than for a dialer. - -@item reliable @var{boolean} -@findex reliable in dial file - -This is only used during protocol negotiation; if it is @samp{false}, it -forces selection of a protocol which works across an unreliable -communication link. The default is @samp{true}. - -@end table - -@node Security, , dial File, Configuration Files -@section Security - -This discussion of UUCP security applies only to Unix. It is a bit -cursory; suggestions for improvement are solicited. - -UUCP is traditionally not very secure. Taylor UUCP addresses some -security issues, but is still far from being a secure system. - -If security is very important to you, then you should not permit any -external access to your computer, including UUCP. Any opening to the -outside world is a potential security risk. - -By default Taylor UUCP provides few mechanisms to secure local users of -the system from each other. You can allow increased security by putting -the owner of the UUCP programs (normally @code{uucp}) into a separate -group; the use of this is explained in the following paragraphs, which -refer to this separate group as @code{uucp-group}. - -When the @code{uucp} program is invoked to copy a file to a remote -system, it will by default copy the file into the UUCP spool directory. -When the @code{uux} program is used, the @samp{-C} switch must be used -to copy the file into the UUCP spool directory. In any case, once the -file has been copied into the spool directory, other local users will -not be able to access it. In version 1.03 there is a security hole in -that for the file to be copied it must be readable by @code{uucp}. -Changing the group of the file to @code{uucp-group} and making it group -readable will permit UUCP to read it without granting access to other -users. - -When a file is requested from a remote system, UUCP will only permit it -to be placed in a directory which is writable by the requesting user. -The directory must also be writable by UUCP. A local user can create a -directory with a group of @code{uucp-group} and set the mode to permit -group write access. This will allow the file be requested without -permitting it to be viewed by any other user. - -There is no provision for security for @code{uucp} requests (as opposed -to @code{uux} requests) made by a user on a remote system. A file sent -over by a remote request may only be placed in a directory which is -world writable, and the file will be world readable and writable. This -will permit any local user to destroy or replace the contents of the -file. A file requested by a remote system must be world readable, and -the directory it is in must be world readable. Any local user will be -able to examine, although not necessarily modify, the file before it is -sent. - -There are some security holes and race conditions that apply to the -above discussion which I will not elaborate on. They are not hidden -from anybody who reads the source code, but they are somewhat technical -and difficult (but scarcely impossible) to exploit. Suffice it to say -that even under the best of conditions UUCP is not completely secure. - -For many sites, security from remote sites is a more important -consideration. Fortunately, Taylor UUCP does provide some support in -this area. - -The greatest security is provided by always dialing out to the other -site. This prevents anybody from pretending to be the other site. Of -course, only one side of the connection can do this. - -If remote dialins must be permitted, then it is best if the dialin line -is used only for UUCP. If this is the case, then you should create a -call-in password file (@pxref{Configuration File Names}) and let -@code{uucico} do its own login prompting. For example, to let remote -sites log in on a port named @samp{entry} in the port file (@pxref{port -file}) you might invoke @samp{uucico -p entry}. This would cause -@code{uucico} to enter an endless loop of login prompts and daemon -executions. The advantage of this approach is that even if remote users -break into the system by guessing or learning the password, they will -only be able to do whatever @code{uucico} permits them to do. They will -not be able to start a shell on your system. - -If remote users can dial in and log on to your system, then you have a -security hazard more serious than that posed by UUCP. But then, you -probably knew that already. - -Once your system has connected with the remote UUCP, there is a fair -amount of control you can exercise. You can use the @code{remote-send} -and @code{remote-receive} commands to control the directories the remote -UUCP can access. You can use the @code{request} command to prevent the -remote UUCP from making any requests of your system at all; however, if -you do this it will not even be able to send you mail or news. If you -do permit remote requests, you should be careful to restrict what -commands may be executed at the remote system's request. The default is -@code{rmail} and @code{rnews}, which will suffice for most systems. - -If different remote systems call in and they must be granted different -privileges (perhaps some systems are within the same organization and -some are not) then the @code{called-login} command should be used for -each system to require that they different login names. Otherwise it -would be simple for a remote system to use the @code{myname} command and -pretend to be a different system. The @code{sequence} command can be -used to detect when one system pretended to be another, but since the -sequence numbers must be reset manually after a failed handshake this -can sometimes be more trouble than it's worth. - -@node Protocols, Hacking, Configuration Files, Top -@chapter UUCP protocol internals - -This chapter describes how the various UUCP protocols work, and -discusses some other internal UUCP issues. - -This chapter is quite technical. You do not need to understand it, or -even read it, in order to use Taylor UUCP. It is intended for people -who are interested in how UUCP code works. - -Most of the discussion covers the protocols used by all UUCP packages, -not just Taylor UUCP. Any information specific to Taylor UUCP is -indicated as such. There are some pointers to the actual functions in -the Taylor UUCP source code, for those who are extremely interested in -actual UUCP implementation. - -@menu -* Grades:: UUCP grades -* Lock Files:: UUCP lock file format -* UUCP Protocol:: The common UUCP protocol -* g Protocol:: The UUCP @samp{g} protocol -* f Protocol:: The UUCP @samp{f} protocol -* t Protocol:: The UUCP @samp{t} protocol -* e Protocol:: The UUCP @samp{e} protocol -* x Protocol:: The UUCP @samp{x} protocol -* d Protocol:: The UUCP @samp{d} protocol -* Capital G Protocol:: The UUCP @samp{G} protocol -* Documentation References:: Documentation references -@end menu - -@node Grades, Lock Files, Protocols, Protocols -@section UUCP Grades -@cindex grades - -Modern UUCP packages support grades for each command. The grades -generally range from @samp{A} (the highest) to @samp{Z} followed by -@samp{a} to @samp{z}. Taylor UUCP also supports @samp{0} to @samp{9} -before @samp{A}. Some UUCP packages may permit any ASCII character as a -grade. - -On Unix, these grades are encoded in the name of the command file. A -command file name generally has the form - -@example -C.nnnngssss -@end example - -@noindent -where @var{nnnn} is the remote system name for which the command is -queued, @var{g} is a single character grade, and @var{ssss} is a four -character sequence number. For example, a command file created for the -system @file{airs} at grade @samp{Z} might be named - -@example -C.airsZ2551 -@end example - -The remote system name will be truncated to seven characters, to ensure -that the command file name will fit in the 14 character file name limit -of the traditional Unix file system. UUCP packages which have no other -means of distinguishing which command files are intended for which -systems thus require all @emph{systems they connect to} to have names -that are unique in the first seven characters. Some UUCP packages use a -variant of this format which truncates the system name to six -characters. BNU uses a different spool directory format, which allows -up to fourteen characters to be used for each system name. The Taylor -UUCP spool directory format is configurable. The new Taylor spool -directory format permits system names to be as long as file names; the -maximum length of a file name depends on the particular Unix file system -being used. - -The sequence number in the command file name may be a decimal integer, -or it may be a hexadecimal integer, or it may contain any alphanumeric -character. Different UUCP packages are different. - -Taylor UUCP creates command files in the function -@code{zsysdep_spool_commands}. The file name is constructed by the -function @code{zsfile_name}, which knows about all the different types -of spool directories supported by Taylor UUCP. The Taylor UUCP sequence -number can contain any alphanumeric character; the next sequence number -is determined by the function @code{fscmd_seq}. - -I do not know how command grades are handled in non-Unix UUCP -packages. - -Modern UUCP packages allow you to restrict file transfer by grade -depending on the time of day. Typically this is done with a line in -the @file{Systems} (or @file{L.sys}) file like this: - -@example -airs Any/Z,Any2305-0855 ... -@end example - -This allows only grades @samp{Z} and above to be transferred at any -time. Lower grades may only be transferred at night. I believe that -this grade restriction applies to local commands as well as to remote -commands, but I am not sure. It may only apply if the UUCP package -places the call, not if it is called by the remote system. Taylor UUCP -can use the @code{timegrade} and @code{call-timegrade} commands -(@pxref{When to Call}) to achieve the same effect (and supports the -above format when reading @file{Systems} or @file{L.sys}). - -This sort of grade restriction is most useful if you know what grades -are being used at the remote site. The default grades used depend on -the UUCP package. Generally @code{uucp} and @code{uux} have different -defaults. A particular grade can be specified with the @samp{-g} option -to @code{uucp} or @code{uux}. For example, to request execution of -rnews on airs with grade @samp{d}, you might use something like - -@example -uux -gd - airs!rnews
= 128}, let @code{b2} be the second byte in the data field. -Then there are @code{l - ((b1 & 0x7f) + (b2 << 7))} valid bytes of data -in the data field, beginning with the third byte. In all cases @code{l} -bytes of data are sent (and all data bytes participate in the checksum -calculation) but some of the trailing bytes may be dropped by the -receiver. The @var{xxx} and @var{yyy} fields are described below. - -@end table - -In a data packet (short or not) the @var{xxx} field gives the sequence -number of the packet. Thus sequence numbers can range from 0 to 7, -inclusive. The @var{yyy} field gives the sequence number of the last -correctly received packet. - -Each communication direction uses a window which indicates how many -unacknowledged packets may be transmitted before waiting for an -acknowledgement. The window may range from 1 to 7 packets, and may be -different in each direction. For example, if the window is 3 and the -last packet acknowledged was packet number 6, packet numbers 7, 0 and 1 -may be sent but the sender must wait for an acknowledgement before -sending packet number 2. This acknowledgement could come as the -@var{yyy} field of a data packet or as the @var{yyy} field of a -@code{RJ} or @code{RR} control packet (described below). - -Each packet must be transmitted in order (the sender may not skip -sequence numbers). Each packet must be acknowledged, and each packet -must be acknowledged in order. - -In a control packet, the @var{xxx} field takes on the following values: - -@table @asis - -@item 1 @code{CLOSE} -The connection should be closed immediately. This is typically sent -when one side has seen too many errors and wants to give up. It is also -sent when shutting down the protocol. If an unexpected @code{CLOSE} -packet is received, a @code{CLOSE} packet should be sent in reply and -the @samp{g} protocol should halt, causing UUCP to enter the final -handshake. - -@item 2 @code{RJ} or @code{NAK} -The last packet was not received correctly. The @var{yyy} field -contains the sequence number of the last correctly received packet. - -@item 3 @code{SRJ} -Selective reject. The @var{yyy} field contains the sequence number of a -packet that was not received correctly, and should be retransmitted. -This is not used by UUCP, and most implementations will not recognize -it. Taylor UUCP will recognize it but not generate it. - -@item 4 @code{RR} or @code{ACK} -Packet acknowledgement. The @var{yyy} field contains the sequence -number of the last correctly received packet. - -@item 5 @code{INITC} -Third initialization packet. The @var{yyy} field contains the maximum -window size to use. - -@item 6 @code{INITB} -@ifinfo -Second initialization packet. The @var{yyy} field contains the packet -size to use. It requests a size of 2 ** (@var{yyy} + 5). Note that -this is not the same coding used for the @var{k} byte in the packet -header (it is 1 less). Some UUCP implementations can handle any packet -size up to that specified; some can only handled exactly the size -specified. Taylor UUCP will always accept any packet size. -@end ifinfo -@iftex -Second initialization packet. The @var{yyy} field contains the packet -size to use. It requests a size of @math{2^{@var{yyy}+5}}. Note that -this is not the same coding used for the @var{k} byte in the packet -header (it is 1 less). Some UUCP implementations can handle any packet -size up to that specified; some can only handled exactly the size -specified. Taylor UUCP will always accept any packet size. -@end iftex - -@item 7 @code{INITA} -First initialization packet. The @var{yyy} field contains the maximum -window size to use. - -@end table - -To compute the checksum, call the control byte (the fifth byte in the -header) @code{c}. - -The checksum of a control packet is simply @code{0xaaaa - c}. - -The checksum of a data packet is @code{0xaaaa - (@var{check} ^ c)} -(@code{^} denotes exclusive or, as in C), and @code{@var{check}} is the -result of the following routine run on the contents of the data field -(every byte in the data field participates in the checksum, even for a -short data packet). Below is the routine used by Taylor UUCP; it is a -slightly modified version of a routine which John Gilmore patched from -G.L. Chesson's original paper. The @code{z} argument points to the -data and the @code{c} argument indicates how much data there is. - -@example -int -igchecksum (z, c) - register const char *z; - register int c; -@{ - register unsigned int ichk1, ichk2; - - ichk1 = 0xffff; - ichk2 = 0; - - do - @{ - register unsigned int b; - - /* Rotate ichk1 left. */ - if ((ichk1 & 0x8000) == 0) - ichk1 <<= 1; - else - @{ - ichk1 <<= 1; - ++ichk1; - @} - - /* Add the next character to ichk1. */ - b = *z++ & 0xff; - ichk1 += b; - - /* Add ichk1 xor the character position in the buffer - counting from the back to ichk2. */ - ichk2 += ichk1 ^ c; - - /* If the character was zero, or adding it to ichk1 - caused an overflow, xor ichk2 to ichk1. */ - if (b == 0 || (ichk1 & 0xffff) < b) - ichk1 ^= ichk2; - @} - while (--c > 0); - - return ichk1 & 0xffff; -@} -@end example - -When the @samp{g} protocol is started, the calling UUCP sends an INITA -control packet with the window size it wishes the called UUCP to use. -The called UUCP responds with an INITA packet with the window size it -wishes the calling UUCP to use. Pairs of INITB and INITC packets are -then similarly exchanged. When these exchanges are completed, the -protocol is considered to have been started. The window size is sent -twice, with both the INITA and the INITC packets. - -When a UUCP package transmits a command, it sends one or more data -packets. All the data packets will normally be complete, although some -UUCP packages may send the last one as a short packet. The command -string is sent with a trailing null byte, to let the receiving package -know when the command is finished. Some UUCP packages require the last -byte of the last packet sent to be null, even if the command ends -earlier in the packet. Some packages may require all the trailing bytes -in the last packet to be null, but I have not confirmed this. - -When a UUCP package sends a file, it will send a sequence of data -packets. The end of the file is signalled by a short data packet -containing zero valid bytes (it will normally be preceeded by a short -data packet containing the last few bytes in the file). - -Note that the sequence numbers cover the entire communication session, -including both command and file data. - -When the protocol is shut down, each UUCP package sends a @code{CLOSE} -control packet. - -@node f Protocol, t Protocol, g Protocol, Protocols -@section The UUCP @samp{f} Protocol -@cindex f protocol -@cindex protocol (f) - -The @samp{f} protocol is a seven bit protocol which checksums an entire -file at a time. It only uses the characters between \040 and \176 -(ASCII space and @samp{~}) inclusive as well as the carriage return -character. It can be very efficient for transferring text only data, -but it is very inefficient at transferring eight bit data (such as -compressed news). It is not flow controlled, and the checksum is fairly -insecure over large files, so using it over a serial connection requires -handshaking (@code{XON}/@code{XOFF} can be used) and error correcting -modems. Some people think it should not be used even under those -circumstances. - -I believe the @samp{f} protocol originated in BSD versions of UUCP. It was -originally intended for transmission over X.25 PAD links. - -The Taylor UUCP code for the @samp{f} protocol is in @file{protf.c}. - -The @samp{f} protocol has no startup or finish protocol. However, both -sides typically sleep for a couple of seconds before starting up, -because they switch the terminal into @code{XON}/@code{XOFF} mode and -want to allow the changes to settle before beginning transmission. - -When a UUCP package transmits a command, it simply sends a string -terminated by a carriage return. - -When a UUCP package transmits a file, each byte b of the file is -translated according to the following table: - -@example - 0 <= b <= 037: 0172, b + 0100 (0100 to 0137) - 040 <= b <= 0171: b ( 040 to 0171) - 0172 <= b <= 0177: 0173, b - 0100 ( 072 to 077) - 0200 <= b <= 0237: 0174, b - 0100 (0100 to 0137) - 0240 <= b <= 0371: 0175, b - 0200 ( 040 to 0171) - 0372 <= b <= 0377: 0176, b - 0300 ( 072 to 077) -@end example - -That is, a byte between \040 and \171 inclusive is transmitted as is, -and all other bytes are prefixed and modified as shown. - -When all the file data is sent, a seven byte sequence is sent: two bytes -of \176 followed by four ASCII bytes of the checksum as printed in base -16 followed by a carriage return. For example, if the checksum was -0x1234, this would be sent: "\176\1761234\r". - -The checksum is initialized to 0xffff. For each byte that is sent it is -modified as follows (where @code{b} is the byte before it has been -transformed as described above): - -@example -/* Rotate the checksum left. */ -if ((ichk & 0x8000) == 0) - ichk <<= 1; -else - @{ - ichk <<= 1; - ++ichk; - @} - -/* Add the next byte into the checksum. */ -ichk += b; -@end example - -When the receiving UUCP sees the checksum, it compares it against its -own calculated checksum and replies with a single character followed -by a carriage return. - -@table @samp - -@item G -The file was received correctly. - -@item R -The checksum did not match, and the file should be resent from the -beginning. - -@item Q -The checksum did not match, but too many retries have occurred and the -communication session should be abandoned. - -@end table - -The sending UUCP checks the returned character and acts accordingly. - -@node t Protocol, e Protocol, f Protocol, Protocols -@section The UUCP @samp{t} Protocol -@cindex t protocol -@cindex protocol (t) - -The @samp{t} protocol is intended for TCP links. It does no error -checking or flow control, and requires an eight bit clear channel. - -I believe the @samp{t} protocol originated in BSD versions of UUCP. - -The Taylor UUCP code for the @samp{t} protocol is in @file{prott.c}. - -When a UUCP package transmits a command, it first gets the length of the -command string, @var{c}. It then sends ((@var{c} / 512) + 1) * 512 -bytes (the smallest multiple of 512 which can hold @var{c} bytes plus a -null byte) consisting of the command string itself followed by trailing -null bytes. - -When a UUCP package sends a file, it sends it in blocks. Each block -contains at most 1024 bytes of data. Each block consists of four bytes -containing the amount of data in binary (most significant byte first, -the same format as used by the Unix function @code{htonl}) followed by -that amount of data. The end of the file is signalled by a block -containing zero bytes of data. - -@node e Protocol, x Protocol, t Protocol, Protocols -@section The UUCP @samp{e} Protocol -@cindex e protocol -@cindex protocol (e) - -The @samp{e} protocol is similar to the @samp{t} protocol. It does no -flow control or error checking and is intended for use over TCP. - -The @samp{e} protocol originated in versions of BNU UUCP. - -The Taylor UUCP code for the @samp{e} protocol is in @file{prote.c}. - -When a UUCP package transmits a command, it simply sends the command as -an ASCII string terminated by a null byte. - -When a UUCP package transmits a file, it sends the complete size of the -file as an ASCII decimal number. The ASCII string is padded out to 20 -bytes with null bytes (i.e., if the file is 1000 bytes long, it sends -@samp{1000\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0}). It then sends the entire -file. - -@node x Protocol, d Protocol, e Protocol, Protocols -@section The UUCP @samp{x} Protocol - -I believe that the @samp{x} protocol was intended for use over X.25 -virtual circuits. It relies on a write of zero bytes being read as zero -bytes without stopping communication. I have heard that it does not -work correctly. If someone would care to fill this in more, I would be -grateful. Taylor UUCP does not implement the @samp{x} protocol. - -@node d Protocol, Capital G Protocol, x Protocol, Protocols -@section The UUCP @samp{d} Protocol - -This is apparently used for DataKit connections, and relies on a write -of zero bytes being read as zero bytes, much as the @samp{x} protocol -does. I don't really know anything else about it. Taylor UUCP does not -implement the @samp{d} protocol. - -@node Capital G Protocol, Documentation References, d Protocol, Protocols -@section The UUCP @samp{G} Protocol - -The @samp{G} protocol is apparently simply the @samp{g} protocol, except -that it is known to support all possible window and packet sizes. It -was introduced by SVR4 UUCP; the SVR4 implementation of the @samp{g} -protocol is apparently fixed at a packet size of 64 and a window size of -7. Taylor UUCP does not recognize the @samp{G} protocol. It does -support all window and packet sizes for the @samp{g} protocol. - -@node Documentation References, , Capital G Protocol, Protocols -@section Documentation References - -I took a lot of the information from Jamie E. Hanrahan's paper in the -Fall 1990 DECUS Symposium, and from Managing UUCP and Usenet by Tim -O'Reilly and Grace Todino (with contributions by several other people). -The latter includes most of the former, and is published by O'Reilly & -Associates, Inc. - -Some information is originally due to a Usenet article by Chuck Wegrzyn. -The information on the @samp{g} protocol comes partially from a paper by -G.L. Chesson of Bell Laboratories, partially from Jamie E. Hanrahan's -paper, and partially from source code by John Gilmore. The information -on the @samp{f} protocol comes from the source code by Piet Berteema. -The information on the @samp{t} protocol comes from the source code by -Rick Adams. The information on the @samp{e} protocol comes from a -Usenet article by Matthias Urlichs. - -@node Hacking, Acknowledgements, Protocols, Top -@chapter Hacking Taylor UUCP - -This chapter provides the briefest of guides to the Taylor UUCP source -code itself. - -@menu -* System Dependence:: System Dependence -* Naming Conventions:: Naming Conventions -* Patches:: Patches -@end menu - -@node System Dependence, Naming Conventions, Hacking, Hacking -@section System Dependence - -The code is carefully segregated into a system independent portion and a -system dependent portion. The system dependent code is in @file{sys?.*} -and @file{tcp.c}. Note that @file{sysh.*} is included as -@file{sysdep.h}. Currently the only system dependent files are for -Unix, and the file name for all of them ends in @file{.unx}. Hopefully -the code will eventually be ported to other systems. - -With the right configuration parameters, the system independent code -calls only ANSI C functions. Some of the less common ANSI C functions -are also provided in @file{util.c}. The replacement function -@code{strtol} in @file{util.c} assumes that the characters @kbd{A} to -@kbd{F} and @kbd{a} to @kbd{f} appear in strictly sequential order. The -function @code{igradecmp} in @file{config.c} assumes that the upper and -lower case letters appear in order. Both assumptions are true for ASCII -and EBCDIC, but neither is guaranteed by ANSI C. The replacement -function @code{memmove} in @file{util.c} assumes that two arbitrary -pointers may be safely compared. Disregarding these caveats, I believe -that the system independent portion of the code is strictly conforming. - -That's not too exciting, since all the work is done in the system -dependent code. I think that this code can conform to POSIX 1003.1, -given the right compilation parameters. I'm a bit less certain about -this, though. - -The code is in use on a 16 bit segmented system with no function -prototypes, so I'm certain that all casts to long and pointers are done -when necessary. - -The code uses alloca extensively. It comes with a simple replacement, -in @file{alloca.c} (otherwise I would lost ANSI C conformance, after -all). Using a real @code{alloca} function will be considerably more -efficient. It will also cause significant stack usage, which may be a -problem on systems without virtual memory. - -@node Naming Conventions, Patches, System Dependence, Hacking -@section Naming Conventions - -I use a modified Hungarian naming convention for my variables and -functions. As with all naming conventions, the code is rather opaque if -you are not familiar with it, but becomes clear and easy to use with -time. - -The first character indicates the type of the variable (or function -return value). Sometimes additional characters are used. I use the -following type prefixes: - -@table @samp -@item a -array; the next character is the type of an element -@item b -byte or character -@item c -count of something -@item e -stdio FILE * -@item f -boolean -@item i -generic integer -@item l -double -@item o -file descriptor (as returned by open, creat, etc.) -@item p -generic pointer -@item q -pointer to structure -@item s -structure -@item u -void (function return values only) -@item z -character string -@end table - -A generic pointer ('p') is sometimes a @code{void *}, sometimes a -function pointer in which case the prefix is pf, and sometimes a pointer -to another type, in which case the next character is the type to which -it points (pf is overloaded). - -An array of strings (@code{char *[]}) would be named @code{az} (array of -string). If this array were passed to a function, the function -parameter would be named @code{paz} (pointer to array of string). - -Note that the variable name prefixes do not necessarily indicate the -type of the variable. For example, a variable prefixed with i may be -int, long or short. Similarly, a variable prefixed with b may be a char -or an int; for example, the return value of getchar would be caught in -an int variable prefixed with b. - -For a non-local variable (extern or file static), the first character -after the type prefix is capitalized. - -Most static variables and functions use another letter after the type -prefix to indicate which module they come from. This is to help -distinguish different names in the debugger. For example, all static -functions in @file{protg.c}, the @samp{g} protocol source code, use a -module prefix of @samp{g}. This isn't too useful, as a number of -modules use a module prefix of @samp{s}. - -@node Patches, , Naming Conventions, Hacking -@section Patches - -I am always grateful for any patches sent in. Much of the flexibility -and portability of the code is due to other people. Please do not -hesitate to send me any changes you have found necessary or useful. - -I rarely apply the patches directly. Instead I work my way through them -and apply each one separately. This ensures that the naming remains -consistent and that I understand all the code. - -@node Acknowledgements, Index (concepts), Hacking, Top -@chapter Acknowledgements - -This is a list of people who gave help or suggestions while I was -working on the Taylor UUCP project. Appearance on this list does not -constitute endorsement of the program, particularly since some of the -comments were criticisms. I've probably left some people off, and I -apologize for any oversight; it does not mean your contribution was -unappreciated. - -@ifinfo -First of all, I would like to thank the people at Infinity Development -Systems (formerly AIRS, which lives on in the domain name, at least for -now) for permitting me to use their computers and @file{uunet} access. -I would also like to thank Richard Stallman @file{} -for founding the Free Software Foundation and John Gilmore -@file{} for writing the initial version of gnuucp which -was a direct inspiration for this somewhat larger project. Chip -Salzenberg @file{} contributed many early patches. -Franc,ois Pinard @file{} tirelessly tested the -code and suggested many improvements. He also put together the initial -version of this document. Finally, Verbus M. Counts -@file{} and Centel Federal Systems, Inc. deserve -special thanks, since they actually paid me money to port this code to -System III. -@end ifinfo -@iftex -First of all, I would like to thank the people at Infinity Development -Systems (formerly AIRS, which lives on in the domain name, at least for -now) for permitting me to use their computers and @file{uunet} access. -I would also like to thank Richard Stallman @file{} -for founding the Free Software Foundation and John Gilmore -@file{} for writing the initial version of gnuucp which -was a direct inspiration for this somewhat larger project. Chip -Salzenberg @file{} contributed many early patches. -@tex -Fran\c cois Pinard -@end tex -@file{} tirelessly tested -the code and suggested many improvements. He also put together the -initial version of this document. Finally, Verbus M. Counts -@file{} and Centel Federal Systems, Inc. deserve -special thanks, since they actually paid me money to port this code to -System III. -@end iftex - -In alphabetical order: - -@example -"Earle F. Ake - SAIC" @file{} -@file{mra@@searchtech.com} (Michael Almond) -@file{cambler@@zeus.calpoly.edu} (Christopher J. Ambler) -Brian W. Antoine @file{} -@file{jantypas@@soft21.s21.com} (John Antypas) -@file{nba@@sysware.DK} (Niels Baggesen) -@file{uunet!hotmomma!sdb} (Scott Ballantyne) -@file{magus!dolphin!zack} (Zacharias Beckman) -@file{mike@@mbsun.ann-arbor.mi.us} (Mike Bernson) -@file{bob@@usixth.sublink.org} (Roberto Biancardi) -Marc Boucher @file{} -@file{dean@@coplex.com} (Dean Brooks) -@file{dave@@dlb.com} (Dave Buck) -@file{gordon@@sneaky.lonestar.org} (Gordon Burditt) -@file{mib@@gnu.ai.mit.edu} (Michael I Bushnell) -Brian Campbell @file{} -@file{verbus@@westmark.westmark.com} (Verbus M. Counts) -@file{cbmvax!snark.thyrsus.com!cowan} (John Cowan) -@file{denny@@dakota.alisa.com} (Bob Denny) -@file{dje@@ersys.edmonton.ab.ca} (Doug Evans) -@file{fenner@@jazz.psu.edu} (Bill Fenner) -"David J. Fiander" @file{} -Thomas Fischer @file{} -@file{erik@@eab.retix.com} (Erik Forsberg) -Lele Gaifax @file{} -@file{Peter.Galbavy@@micromuse.co.uk} -@file{hunter@@phoenix.pub.uu.oz.au} (James Gardiner [hunter]) -Terry Gardner @file{} -@file{jimmy@@tokyo07.info.com} (Jim Gottlieb) -@file{ryan@@cs.umb.edu} (Daniel R. Guilderson) -@file{greg@@gagme.chi.il.us} (Gregory Gulik) -Michael Haberler @file{} -@file{guy@@auspex.auspex.com} (Guy Harris) -Petri Helenius @file{} -Peter Honeyman @file{} -@file{bei@@dogface.austin.tx.us} (Bob Izenberg) -@file{harvee!esj} (Eric S Johansson) -@file{chris@@cj_net.in-berlin.de} (Christof Junge) -@file{tron@@Veritas.COM} (Ronald S. Karr) -@file{kent@@sparky.IMD.Sterling.COM} (Kent Landfield) -@file{lebaron@@inrs-telecom.uquebec.ca} (Gregory LeBaron) -@file{karl@@sugar.NeoSoft.Com} (Karl Lehenbauer) -@file{libove@@libove.det.dec.com} (Jay Vassos-Libove) -@file{bruce%blilly@@Broadcast.Sony.COM} (Bruce Lilly) -Ted Lindgreen @file{} -"Arne Ludwig" @file{} -Matthew Lyle @file{} -@file{djm@@eng.umd.edu} (David J. MacKenzie) -John R MacMillan @file{} -@file{mem@@mv.MV.COM} (Mark E. Mallett) -@file{martelli@@cadlab.sublink.org} (Alex Martelli) -Yanek Martinson @file{} -@file{les@@chinet.chi.il.us} (Leslie Mikesell) -@file{mmitchel@@digi.lonestar.org} (Mitch Mitchell) -@file{rmohr@@infoac.rmi.de} (Rupert Mohr) -@file{service@@infohh.rmi.de} (Dirk Musstopf) -@file{lyndon@@cs.athabascau.ca} (Lyndon Nerenberg) -@file{nolan@@helios.unl.edu} (Michael Nolan) -david nugent @file{} -@file{abekas!dragoman!mikep@@decwrl.dec.com} (Mike Park) -"Mark Pizzolato 415-369-9366" @file{} -@file{dplatt@@ntg.com} (Dave Platt) -@file{eldorado@@tharr.UUCP} (Mark Powell) -@file{pozar@@kumr.lns.com} (Tim Pozar) -@file{putsch@@uicc.com} (Jeff Putsch) -Jarmo Raiha @file{} -@file{mcr@@Sandelman.OCUnix.On.Ca} (Michael Richardson) -@file{ross@@sun490.fdu.edu} (Jeff Ross) -Aleksey P. Rudnev @file{} -@file{wolfgang@@wsrcc.com} (Wolfgang S. Rupprecht) -@file{tbr@@tfic.bc.ca} (Tom Rushworth) -@file{rsalz@@bbn.com} (Rich Salz) -@file{sojurn!mike@@hobbes.cert.sei.cmu.edu} (Mike Sangrey) -@file{swiers@@plains.NoDak.edu} -@file{s4mjs!mjs@@nirvo.nirvonics.com} (M. J. Shannon Jr.) -@file{peter@@ficc.ferranti.com} (Peter da Silva) -@file{frumious!pat} (Patrick Smith) -@file{roscom!monty@@bu.edu} (Monty Solomon) -@file{chs@@antic.apu.fi} (Hannu Strang) -@file{ralf@@reswi.ruhr.de} (Ralf E. Stranzenbach) -Oleg Tabarovsky @file{} -John Theus @file{} -@file{rmtodd@@servalan.servalan.com} (Richard Todd) -Len Tower @file{} -@file{mju@@mudos.ann-arbor.mi.us} (Marc Unangst) -@file{jv@@mh.nl} (Johan Vromans) -@file{rna-nl!gerben@@relay.nluug.nl} (Drs. Gerben C. Th. Wierda) -@file{frnkmth!twwells.com!bill} (T. William Wells) -@file{mauxci!eci386!woods@@apple.com} (Greg A. Woods) -@file{jon@@console.ais.org} (Jon Zeeff) -Eric Ziegast @file{} -@end example - -@node Index (concepts), Index (configuration file), Acknowledgements, Top -@unnumbered Concept Index - -@printindex cp - -@node Index (configuration file), , Index (concepts), Top -@unnumbered Index to New Configuration File - -@printindex fn - -@contents -@bye diff --git a/gnu/libexec/uucp/uudir.c b/gnu/libexec/uucp/uudir.c deleted file mode 100644 index b59cfa43c3d2..000000000000 --- a/gnu/libexec/uucp/uudir.c +++ /dev/null @@ -1,109 +0,0 @@ -/* uudir.c - Create a directory owned by uucp. This is Unix specific. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: uudir.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.1 1992/02/09 05:11:42 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char uudir_rcsid[] = "$Id: uudir.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#if USE_STDIO && HAVE_UNISTD_H -#include -#endif - -#include "sysdep.h" - -/* External functions. */ -extern int setuid (); -extern struct passwd *getpwnam (); - -/* This is a simple program which sets its real uid to uucp and then - invokes /bin/mkdir. It is only used if the system does not support - the mkdir system call. It must be installed suid to root. - - This program is needed because the UUCP programs will be run suid - to uucp. On a system without the mkdir system call, /bin/mkdir is - a suid root program. This means that /bin/mkdir always creates - directories using the real uid, rather than the effective uid. - This is wrong, since the UUCP programs always want to create - directories that are owned by uucp. Therefore, this simple suid - root program is used to force /bin/mkdir into making a directory - owned by uucp. - - If we made the program publically executable, this would mean that - anybody could create a directory owned by uucp. This is probably - not a good thing, but since the program must be owned by root we - can't simply make it executable only by uucp. Therefore, the - Makefile hides the program away in /usr/lib/uucp/util, and makes - that directory searchable only by uucp. This should prevent - anybody else from getting to the program. - - This is not a perfect solution, since any suid root program is by - definition a potential security hole. I really can't see any way - to avoid this, though. */ - -int -main (argc, argv) - int argc; - char **argv; -{ - struct passwd *q; - const char *zprog, *zname; - - /* We don't print any error messages, since this program should - never be run directly by a user. */ - - if (argc != 2) - exit (EXIT_FAILURE); - - /* OWNER is passed in from the Makefile. It will normally be - "uucp". */ - q = getpwnam (OWNER); - if (q == NULL) - exit (EXIT_FAILURE); - - if (setuid (q->pw_uid) < 0) - exit (EXIT_FAILURE); - - zprog = MKDIR_PROGRAM; - zname = strrchr (zprog, '/'); - if (zname == NULL) - zname = zprog; - else - ++zname; - - (void) execl (zprog, zname, argv[1], (char *) NULL); - exit (EXIT_FAILURE); -} diff --git a/gnu/libexec/uucp/uulog.c b/gnu/libexec/uucp/uulog.c deleted file mode 100644 index b33b3a5198d9..000000000000 --- a/gnu/libexec/uucp/uulog.c +++ /dev/null @@ -1,264 +0,0 @@ -/* uulog.c - Display the UUCP log file. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: uulog.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.4 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.3 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.2 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.1 1992/02/14 21:22:51 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char uulog_rcsid[] = "$Id: uulog.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#include "system.h" -#include "sysdep.h" -#include "getopt.h" - -/* This is a pretty bad implementation of uulog, which I don't think - is a very useful program anyhow. It only takes a single -s and/or - -u switch. When using HAVE_BNU_LOGGING it requires a system. It - does not provide -f. */ - -/* The program name. */ -char abProgram[] = "uulog"; - -/* Local functions. */ - -static void ulusage P((void)); - -/* Long getopt options. */ - -static const struct option asLongopts[] = { { NULL, 0, NULL, 0 } }; - -const struct option *_getopt_long_options = asLongopts; - -int -main (argc, argv) - int argc; - char **argv; -{ - int iopt; - /* -s: system name. */ - const char *zsystem = NULL; - /* -u: user name. */ - const char *zuser = NULL; - /* -I: configuration file name. */ - const char *zconfig = NULL; - /* -x: display uuxqt log file. */ - boolean fuuxqt = FALSE; - const char *zfile; - FILE *e; - char *zline; - int csystem = 0; - int cuser = 0; - - while ((iopt = getopt (argc, argv, "I:s:u:xX:")) != EOF) - { - switch (iopt) - { - case 'I': - /* Configuration file name. */ - zconfig = optarg; - break; - - case 's': - /* System name. */ - zsystem = optarg; - break; - - case 'u': - /* User name. */ - zuser = optarg; - break; - - case 'x': - /* Display uuxqt log file. */ - fuuxqt = TRUE; - break; - - case 'X': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 0: - /* Long option found and flag set. */ - break; - - default: - ulusage (); - break; - } - } - - if (optind != argc) - ulusage (); - - uread_config (zconfig); - - usysdep_initialize (FALSE, FALSE); - -#if ! HAVE_BNU_LOGGING - zfile = zLogfile; -#else - { - const char *zprogram; - char *zalc; - - /* We need a system to find a BNU log file. */ - if (zsystem == NULL) - ulusage (); - - if (fuuxqt) - zprogram = "uuxqt"; - else - zprogram = "uucico"; - - zalc = (char *) alloca (strlen (zLogfile) - + strlen (zprogram) - + strlen (zsystem) - + 1); - sprintf (zalc, zLogfile, zprogram, zsystem); - zfile = zalc; - } -#endif - - e = fopen (zfile, "r"); - if (e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", zfile, strerror (errno)); - usysdep_exit (FALSE); - } - - /* Read the log file and output the appropriate lines. */ - - if (zsystem != NULL) - csystem = strlen (zsystem); - - if (zuser != NULL) - cuser = strlen (zuser); - - while ((zline = zfgets (e, FALSE)) != NULL) - { - char *zluser, *zlsys, *znext; - int cluser, clsys; - - /* Skip any leading whitespace (not that there should be any). */ - znext = zline + strspn (zline, " \t"); - -#if ! HAVE_TAYLOR_LOGGING - /* The user name is the first field on the line. */ - zluser = znext; - cluser = strcspn (znext, " \t"); -#endif - - /* Skip the first field. */ - znext += strcspn (znext, " \t"); - znext += strspn (znext, " \t"); - - /* The system is the second field on the line. */ - zlsys = znext; - clsys = strcspn (znext, " \t"); - - /* Skip the second field. */ - znext += clsys; - znext += strspn (znext, " \t"); - -#if HAVE_TAYLOR_LOGGING - /* The user is the third field on the line. */ - zluser = znext; - cluser = strcspn (znext, " \t"); -#endif - - /* See if we should print this line. */ - - if (zsystem != NULL - && (csystem != clsys - || strncmp (zsystem, zlsys, clsys) != 0)) - continue; - - if (zuser != NULL - && (cuser != cluser - || strncmp (zuser, zluser, cluser) != 0)) - continue; - - /* Output the line. */ - - printf ("%s", zline); - } - - ulog_close (); - - usysdep_exit (TRUE); - - /* Avoid errors about not returning a value. */ - return 0; -} - -/* Print a usage message and die. */ - -static void -ulusage () -{ - fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", - abVersion); - fprintf (stderr, - "Usage: uulog [-s system] [-u user] [-x] [-I file] [-X debug]\n"); - fprintf (stderr, - " -s: print entries for named system\n"); - fprintf (stderr, - " -u: print entries for name user\n"); -#if HAVE_BNU_LOGGING - fprintf (stderr, - " -x: print uuxqt log rather than uucico log\n"); -#endif - fprintf (stderr, - " -X debug: Set debugging level (0 for none, 9 is max)\n"); -#if HAVE_TAYLOR_CONFIG - fprintf (stderr, - " -I file: Set configuration file to use (default %s%s)\n", - NEWCONFIGLIB, CONFIGFILE); -#endif /* HAVE_TAYLOR_CONFIG */ - exit (EXIT_FAILURE); -} diff --git a/gnu/libexec/uucp/uuname.c b/gnu/libexec/uucp/uuname.c deleted file mode 100644 index dcdfcd0e1bf5..000000000000 --- a/gnu/libexec/uucp/uuname.c +++ /dev/null @@ -1,183 +0,0 @@ -/* uuname.c - List the names of known remote UUCP sites. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: uuname.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.5 1992/03/28 04:42:32 ian - Franc,ois Pinard: output aliases, added -a switch - - Revision 1.4 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.3 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.2 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.1 1992/02/14 20:25:55 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char uuname_rcsid[] = "$Id: uuname.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include "system.h" -#include "sysdep.h" -#include "getopt.h" - -/* The program name. */ -char abProgram[] = "uuname"; - -/* Local functions. */ - -static void unusage P((void)); - -/* Long getopt options. */ - -static const struct option asLongopts[] = { { NULL, 0, NULL, 0 } }; - -const struct option *_getopt_long_options = asLongopts; - -int -main (argc, argv) - int argc; - char **argv; -{ - int iopt; - /* -a: don't display aliases. */ - boolean fnoalias = FALSE; - /* -l: if true, output local node name. */ - boolean flocal = FALSE; - /* -I: configuration file name. */ - const char *zconfig = NULL; - - while ((iopt = getopt (argc, argv, "alI:x:")) != EOF) - { - switch (iopt) - { - case 'a': - /* Don't display aliases. */ - fnoalias = TRUE; - break; - - case 'l': - /* Output local node name. */ - flocal = TRUE; - break; - - case 'I': - /* Configuration file name. */ - zconfig = optarg; - break; - - case 'x': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 0: - /* Long option found and flag set. */ - break; - - default: - unusage (); - break; - } - } - - if (optind != argc) - unusage (); - - uread_config (zconfig); - - usysdep_initialize (FALSE, FALSE); - - if (flocal) - printf ("%s\n", zLocalname); - else - { - int c; - struct ssysteminfo *pas; - int i; - - uread_all_system_info (&c, &pas); - - for (i = 0; i < c; i++) - { - printf ("%s\n", pas[i].zname); - - if (! fnoalias && pas[i].zalias != NULL) - { - char *zcopy, *ztok; - - zcopy = (char *) alloca (strlen (pas[i].zalias) + 1); - strcpy (zcopy, pas[i].zalias); - for (ztok = strtok (zcopy, " "); - ztok != NULL; - ztok = strtok ((char *) NULL, " ")) - printf ("%s\n", ztok); - } - } - } - - ulog_close (); - - usysdep_exit (TRUE); - - /* Avoid errors about not returning a value. */ - return 0; -} - -/* Print a usage message and die. */ - -static void -unusage () -{ - fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", - abVersion); - fprintf (stderr, - "Usage: uuname [-a] [-l] [-I file] [-x debug]\n"); - fprintf (stderr, - " -a: don't display aliases\n"); - fprintf (stderr, - " -l: print local name\n"); - fprintf (stderr, - " -x debug: Set debugging level (0 for none, 9 is max)\n"); -#if HAVE_TAYLOR_CONFIG - fprintf (stderr, - " -I file: Set configuration file to use (default %s%s)\n", - NEWCONFIGLIB, CONFIGFILE); -#endif /* HAVE_TAYLOR_CONFIG */ - exit (EXIT_FAILURE); -} diff --git a/gnu/libexec/uucp/uustat.1 b/gnu/libexec/uucp/uustat.1 deleted file mode 100644 index 635f86ea320f..000000000000 --- a/gnu/libexec/uucp/uustat.1 +++ /dev/null @@ -1,253 +0,0 @@ -''' $Id: uustat.1,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ -''' $Log: uustat.1,v $ -''' Revision 1.1.1.1 1993/03/21 09:45:37 cgd -''' initial import of 386bsd-0.1 sources -''' -''' Revision 1.2 1992/04/01 21:13:46 ian -''' Added RCS ID and log strings -''' -''' Revision 1.1 1992/04/01 21:10:46 ian -''' Initial revision -''' -.TH uustat 1 "Taylor UUCP 1.03" -.SH NAME -uustat \- UUCP status inquiry and control -.SH SYNOPSIS -.B uustat \-a -.PP -.B uustat -[ -.B \-s -system ] [ -.B \-u -user ] [ -.B \-o -hours ] [ -.B \-y -hours ] -.PP -.B uustat -[ -.B \-k -jobid ] [ -.B \-r -jobid ] -.PP -.B uustat \-q -.PP -.B uustat \-m -.PP -.B uustat \-p -.SH DESCRIPTION -The -.I uustat -command can display various types of status information about the UUCP -system. It can also be used to cancel or rejuvenate requests made by -.I uucp -(1) or -.I uux -(1). - -By default -.I uustat -displays all jobs queued up for the invoking user, as if given the -.B \-u -option with the appropriate argument. -.SH OPTIONS -The following options may be given to -.I uustat. -.TP 5 -.B \-a -List all queued jobs. -.TP 5 -.B \-s system -List all jobs queued up for the named system. This option may be -specified multiple times, in which case all jobs for all the systems -will be listed. The -.B \-u, -.B \-o, -and -.B \-y -options may be used to restrict which jobs are listed. -.TP 5 -.B \-u user -List all jobs queued up for the named user. This option may be -specified multiple times, in which case all jobs for all the users -will be listed. The -.B \-s, -.B \-o, -and -.B \-y -options may be used to restrict which jobs are listed. -.TP 5 -.B \-o hours -List all queued jobs older than the given number of hours. The -.B \-s, -.B \-u, -and -.B \-y -options may be used to further restrict which jobs are listed. -.TP 5 -.B \-y hours -List all queued jobs younger than the given number of hours. The -.B \-s, -.B \-u, -and -.B \-o -options may be used to further restrict which jobs are listed. -.TP 5 -.B \-k jobid -Kill the named job. The job id is shown by the -.B \-s, -.B \-u, -.B \-o, -or -.B \-y -options, as well as by the -.B \-j -option to -.I uucp -(1) or -.I uux -(1). A job may only be killed by the user who created the job, or by -the UUCP administrator or the superuser. The -.B \-k -option may be used multiple times on the command line to kill several -jobs. -.TP 5 -.B \-r jobid -Rejuvenate the named job. This will mark it as having been invoked at -the current time, affecting the output of the -.B \-o -or -.B \-y -options and preserving it from any automated cleanup daemon. The job -id is shown by the -.B \-s, -.B \-u, -.B \-o, -or -.B \-y -options, as well as by the -.B \-j -option to -.I uucp -(1) or -.I uux -(1). A job may only be rejuvenated by the user who created the job, -or by the UUCP administrator or the superuser. The -.B \-r -option may be used multiple times on the command line to rejuvenate -several jobs. -.TP 5 -.B \-q -Display the status of commands, executions and conversations for all -remote systems for which commands or executions are queued. -.TP 5 -.B \-m -Display the status of conversations for all remote systems. -.TP 5 -.B \-p -Display the status of all processes holding UUCP locks on systems or -ports. -.TP 5 -.B \-x type -Turn on particular debugging types. The following types are -recognized: abnormal, chat, handshake, uucp-proto, proto, port, -config, spooldir, execute, incoming, outgoing. Only abnormal, config, -spooldir and execute are meaningful for -.I uustat. - -Multiple types may be given, separated by commas, and the -.B \-x -option may appear multiple times. A number may also be given, which -will turn on that many types from the foregoing list; for example, -.B \-x 2 -is equivalent to -.B \-x abnormal,chat. -.TP 5 -.B \-I file -Set configuration file to use. This option may not be available, -depending upon how -.I uustat -was compiled. -.SH EXAMPLES -.EX -uustat -a -.EE -Display status of all jobs. A sample output line is as follows: -.EX -bugsA027h bugs ian 1992-04-01 13:50:04 Executing rmail ian@airs.com (sending 1283 bytes) -.EE -The format is -.EX -jobid system user queue-date command (size) -.EE -The jobid may be passed to the -.B \-k -or -.B \-r -options. -The size indicates how much data is to be transferred to the remote -system, and is absent for a file receive request. - -The -.B \-s, -.B \-u, -.B \-o, -and -.B \-y -options also produce output in the above format. - -.EX -uustat -q -.EE -Display status for all systems with queued up commands. A sample -output line is as follows: -.EX -bugs 4C (1 hour) 0X (0 secs) 1992-04-01 14:45:47 Dial failed -.EE -This indicates the system, the number of queued commands, the age of -the oldest queued command, the number of queued local executions, the -age of the oldest queued execution, the date of the last conversation, -and the status of that conversation. - -.EX -uustat -m -.EE -Display conversation status for all remote systems. A sample output -line is as follows: -.EX -bugs 1992-04-01 15:51:30 Conversation complete -.EE -This indicates the system, the date of the last conversation, and the -status of that conversation. If the last conversation failed, -.I uustat -will indicate how many attempts have been made to call the system. If -the retry period is currently preventing calls to that system, -.I uustat -also displays the time when the next call will be permitted. - -.EX -uustat -p -.EE -Display the status of all processes holding UUCP locks. The output -format is system dependent, as -.I uustat -simply invokes -.I ps -(1) on each process holding a lock. -.SH FILES -The file names may be changed at compilation time or by the -configuration file, so these are only approximations. - -.br -/usr/lib/uucp/config - Configuration file. -.br -/usr/spool/uucp - -UUCP spool directory. -.SH SEE ALSO -ps(1), uucp(1), uux(1), uucico(8), uuxqt(8) -.SH AUTHOR -Ian Lance Taylor -(ian@airs.com or uunet!airs!ian) diff --git a/gnu/libexec/uucp/uustat.c b/gnu/libexec/uucp/uustat.c deleted file mode 100644 index c3ba5cc8e08e..000000000000 --- a/gnu/libexec/uucp/uustat.c +++ /dev/null @@ -1,1071 +0,0 @@ -/* uustat.c - UUCP status program - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: uustat.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.7 1992/03/28 22:54:45 ian - Allow multiple systems and users or kills and rejuvenates at once - - Revision 1.6 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.5 1992/03/03 21:34:55 ian - Handle local execution files - - Revision 1.4 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.3 1992/02/24 20:36:27 ian - Roberto Biancardi: skip spaces after strtok (NULL, "") - - Revision 1.2 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.1 1992/02/20 04:18:59 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char uustat_rcsid[] = "$Id: uustat.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#if HAVE_TIME_H -#include -#endif - -#include "system.h" -#include "sysdep.h" -#include "getopt.h" - -/* The uustat program permits various listings and manipulations of - files in the spool directory. This implementation supports the - following switches: - - -a list all jobs - -kjobid kill job with specified ID - -m report status for all remote machines - -ohour report jobs older than specified number of hours - -p do "ps -flp" on all processes holding lock files (Unix specific) - -q list number of jobs for all systems - -rjobid rejuvenate job with specified ID - -ssystem report on all jobs for specified system - -uuser report on all jobs for specified user - -yhour report jobs younger than specified number of hours - -Ifile set configuration file name - -xdebug set debugging level */ - -/* The program name. */ -char abProgram[] = "uustat"; - -/* Local functions. */ - -static void ususage P((void)); -static boolean fsworkfiles P((int csystems, char **pazsystems, - int cusers, char **pazusers, - long iold, long iyoung)); -static boolean fsworkfiles_system P((const struct ssysteminfo *qsys, - int cusers, char **pazusers, - long iold, long iyoung)); -static boolean fsworkfile_show P((const struct ssysteminfo *qsys, - const struct scmd *qcmd, - long itime)); -static void usworkfile_header P((const struct ssysteminfo *qsys, - const struct scmd *qcmd, - const char *zjobid, - long itime, boolean ffirst)); -static boolean fsquery P((void)); -static void usunits_show P((long idiff)); -static boolean fsmachines P((void)); - -/* Long getopt options. */ - -static const struct option asLongopts[] = { { NULL, 0, NULL, 0 } }; - -const struct option *_getopt_long_options = asLongopts; - -int -main (argc, argv) - int argc; - char **argv; -{ - int iopt; - /* -a: list all jobs. */ - boolean fall = FALSE; - /* -k jobid: kill specified job. */ - int ckills = 0; - char **pazkills = NULL; - /* -m: report machine status. */ - boolean fmachine = FALSE; - /* -o hour: report jobs older than given number of hours. */ - int ioldhours = -1; - /* -p: report status of jobs holding lock files. */ - boolean fps = FALSE; - /* -q: list number of jobs for each system. */ - boolean fquery = FALSE; - /* -r jobid: rejuvenate specified job. */ - int crejuvs = 0; - char **pazrejuvs = NULL; - /* -s system: list all jobs for specified system. */ - int csystems = 0; - char **pazsystems = NULL; - /* -u user: list all jobs for specified user. */ - int cusers = 0; - char **pazusers = NULL; - /* -y hour: report jobs younger than given number of hours. */ - int iyounghours = -1; - /* -I file: set configuration file. */ - const char *zconfig = NULL; - int ccmds; - long iold; - long iyoung; - char *azoneuser[1]; - boolean fret; - - while ((iopt = getopt (argc, argv, "aI:k:mo:pqr:s:u:x:y:")) != EOF) - { - switch (iopt) - { - case 'a': - /* List all jobs. */ - fall = TRUE; - break; - - case 'I': - /* Set configuration file name. */ - zconfig = optarg; - break; - - case 'k': - /* Kill specified job. */ - ++ckills; - pazkills = (char **) xrealloc ((pointer) pazkills, - ckills * sizeof (char *)); - pazkills[ckills - 1] = optarg; - break; - - case 'm': - /* Report machine status. */ - fmachine = TRUE; - break; - - case 'o': - /* Report old jobs. */ - ioldhours = atoi (optarg); - break; - - case 'p': - /* Get status of processes holding locks. */ - fps = TRUE; - break; - - case 'q': - /* List number of jobs for each system. */ - fquery = TRUE; - break; - - case 'r': - /* Rejuvenate specified job. */ - ++crejuvs; - pazrejuvs = (char **) xrealloc ((pointer) pazrejuvs, - crejuvs * sizeof (char *)); - pazrejuvs[crejuvs - 1] = optarg; - break; - - case 's': - /* List jobs for specified system. */ - ++csystems; - pazsystems = (char **) xrealloc ((pointer) pazsystems, - csystems * sizeof (char *)); - pazsystems[csystems - 1] = optarg; - break; - - case 'u': - /* List jobs for specified user. */ - ++cusers; - pazusers = (char **) xrealloc ((pointer) pazusers, - cusers * sizeof (char *)); - pazusers[cusers - 1] = optarg; - break; - - case 'x': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'y': - /* List jobs younger than given number of hours. */ - iyounghours = atoi (optarg); - break; - - case 0: - /* Long option found and flag set. */ - break; - - default: - ususage (); - break; - } - } - - if (optind != argc) - ususage (); - - /* To avoid confusion, most options are only permitted by - themselves. This restriction might be removed later, but it is - imposed by most implementations. We do permit any combination of - -s, -u, -o and -y, and any combination of -k and -r. */ - ccmds = 0; - if (fall) - ++ccmds; - if (ckills > 0 || crejuvs > 0) - ++ccmds; - if (fmachine) - ++ccmds; - if (fps) - ++ccmds; - if (fquery) - ++ccmds; - if (csystems > 0 || cusers > 0 - || ioldhours != -1 || iyounghours != -1) - ++ccmds; - - if (ccmds > 1) - { - fprintf (stderr, "uustat: Too many options\n"); - ususage (); - } - - uread_config (zconfig); - - usysdep_initialize (FALSE, FALSE); - - /* If no commands were specified, we list all commands for the given - user. */ - if (ccmds == 0) - { - cusers = 1; - azoneuser[0] = xstrdup (zsysdep_login_name ()); - pazusers = azoneuser; - } - - if (ioldhours == -1) - iold = (long) -1; - else - { - iold = (isysdep_time ((long *) NULL) - - (long) ioldhours * (long) 60 * (long) 60); - if (iold < 0L) - iold = 0L; - } - if (iyounghours == -1) - iyoung = (long) -1; - else - { - iyoung = (isysdep_time ((long *) NULL) - - (long) iyounghours * (long) 60 * (long) 60); - if (iyoung < 0L) - iyoung = 0L; - } - - if (fall - || ioldhours != -1 - || csystems > 0 - || cusers > 0 - || iyounghours != -1) - fret = fsworkfiles (csystems, pazsystems, cusers, pazusers, iold, - iyoung); - else if (fquery) - fret = fsquery (); - else if (fmachine) - fret = fsmachines (); - else if (ckills > 0 || crejuvs > 0) - { - int i; - - fret = TRUE; - for (i = 0; i < ckills; i++) - if (! fsysdep_kill_job (pazkills[i])) - fret = FALSE; - - for (i = 0; i < crejuvs; i++) - if (! fsysdep_rejuvenate_job (pazrejuvs[i])) - fret = FALSE; - } - else if (fps) - fret = fsysdep_lock_status (); - else - { -#if DEBUG > 0 - ulog (LOG_FATAL, "Can't happen"); -#endif - fret = FALSE; - } - - ulog_close (); - - usysdep_exit (fret); - - /* Avoid errors about not returning a value. */ - return 0; -} - -/* Print a usage message and die. */ - -static void -ususage () -{ - fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", - abVersion); - fprintf (stderr, - "Usage: uustat [-ampq] [-kr job] [-oy hours] [-s system] [-u user]\n"); - fprintf (stderr, - " -a: list all UUCP jobs\n"); - fprintf (stderr, - " -k job: kill specified UUCP job\n"); - fprintf (stderr, - " -m: report status for all remote machines\n"); - fprintf (stderr, - " -o hours: list all jobs older than given number of hours\n"); - fprintf (stderr, - " -p: show status of all processes holding UUCP locks\n"); - fprintf (stderr, - " -q: list number of jobs for each system\n"); - fprintf (stderr, - " -r job: rejuvenate specified UUCP job\n"); - fprintf (stderr, - " -s system: list all jobs for specified system\n"); - fprintf (stderr, - " -u user: list all jobs for specified user\n"); - fprintf (stderr, - " -y hours: list all jobs younger than given number of hours\n"); - fprintf (stderr, - " -x debug: Set debugging level (0 for none, 9 is max)\n"); -#if HAVE_TAYLOR_CONFIG - fprintf (stderr, - " -I file: Set configuration file to use (default %s%s)\n", - NEWCONFIGLIB, CONFIGFILE); -#endif /* HAVE_TAYLOR_CONFIG */ - exit (EXIT_FAILURE); -} - -/* Handle various possible requests to look at work files. */ - -static boolean -fsworkfiles (csystems, pazsystems, cusers, pazusers, iold, iyoung) - int csystems; - char **pazsystems; - int cusers; - char **pazusers; - long iold; - long iyoung; -{ - boolean fret; - int i; - - fret = TRUE; - - if (csystems > 0) - { - struct ssysteminfo ssys; - - for (i = 0; i < csystems; i++) - { - if (! fread_system_info (pazsystems[i], &ssys)) - { - ulog (LOG_ERROR, "%s: unknown system", pazsystems[i]); - fret = FALSE; - continue; - } - - if (! fsworkfiles_system (&ssys, cusers, pazusers, iold, iyoung)) - fret = FALSE; - } - } - else - { - int cs; - struct ssysteminfo *pas; - - uread_all_system_info (&cs, &pas); - - for (i = 0; i < cs; i++) - if (! fsworkfiles_system (&pas[i], cusers, pazusers, iold, iyoung)) - fret = FALSE; - } - - return fret; -} - -/* Look at the work files for a particular system. */ - -static boolean -fsworkfiles_system (qsys, cusers, pazusers, iold, iyoung) - const struct ssysteminfo *qsys; - int cusers; - char **pazusers; - long iold; - long iyoung; -{ - boolean fret; - - if (! fsysdep_get_work_init (qsys, BGRADE_LOW)) - return FALSE; - - while (TRUE) - { - struct scmd s; - long itime; - - if (! fsysdep_get_work (qsys, BGRADE_LOW, &s)) - { - usysdep_get_work_free (qsys); - return FALSE; - } - if (s.bcmd == 'H') - break; - - if (cusers > 0) - { - int i; - - for (i = 0; i < cusers; i++) - if (strcmp (pazusers[i], s.zuser) == 0) - break; - if (i >= cusers) - continue; - } - - itime = isysdep_work_time (qsys, s.pseq); - - if (iold != (long) -1 && itime > iold) - continue; - - if (iyoung != (long) -1 && itime < iyoung) - continue; - - if (! fsworkfile_show (qsys, &s, itime)) - { - usysdep_get_work_free (qsys); - return FALSE; - } - } - - fret = fsworkfile_show (qsys, (const struct scmd *) NULL, 0L); - - usysdep_get_work_free (qsys); - - return fret; -} - -/* Show a single workfile. This is actually called once for each line - in the workfile, so we accumulate the lines and show them all at - once. This lets us show an execution in a useful fashion. */ - -struct scmdlist -{ - struct scmdlist *qnext; - struct scmd s; - long itime; -}; - -static boolean -fsworkfile_show (qsys, qcmd, itime) - const struct ssysteminfo *qsys; - const struct scmd *qcmd; - long itime; -{ - static struct scmdlist *qlist; - static const char *zlistid; - const char *zid; - - if (qcmd == NULL) - zid = NULL; - else - { - zid = zsysdep_jobid (qsys, qcmd->pseq); - if (zid == NULL) - return FALSE; - } - - /* If this is the same jobid as the list, put it on the end. */ - - if (qcmd != NULL - && qlist != NULL - && strcmp (zlistid, zid) == 0) - { - struct scmdlist *qnew, **pq; - - qnew = (struct scmdlist *) xmalloc (sizeof (struct scmdlist)); - qnew->qnext = NULL; - qnew->s = *qcmd; - qnew->itime = itime; - for (pq = &qlist; *pq != NULL; pq = &(*pq)->qnext) - ; - *pq = qnew; - return TRUE; - } - - if (qcmd != NULL) - zid = xstrdup (zid); - - /* Here we have found a different job ID, so we print the scmd - structures that we have accumulated. We look for the special - case of an execution (one of the destination files begins with - X.). We could be more clever about other situations as well. */ - - if (qlist != NULL) - { - struct scmdlist *qlook; - - for (qlook = qlist; qlook != NULL; qlook = qlook->qnext) - if (qlook->s.bcmd == 'S' - && qlook->s.zto[0] == 'X' - && qlook->s.zto[1] == '.' - && fspool_file (qlook->s.zfrom)) - break; - - if (qlook == NULL) - { - /* Show all the lines in a regular work file. */ - - for (qlook = qlist; qlook != NULL; qlook = qlook->qnext) - { - const char *zfile; - - usworkfile_header (qsys, &qlook->s, zlistid, qlook->itime, - qlook == qlist); - - switch (qlook->s.bcmd) - { - case 'S': - if (strchr (qlook->s.zoptions, 'C') != NULL - || fspool_file (qlook->s.zfrom)) - zfile = zsysdep_spool_file_name (qsys, qlook->s.ztemp); - else - zfile = zsysdep_real_file_name (qsys, qlook->s.zfrom, - (const char *) NULL); - printf ("Sending %s (%ld bytes) to %s", qlook->s.zfrom, - zfile == NULL ? 0L : csysdep_size (zfile), - qlook->s.zto); - break; - case 'R': - printf ("Requesting %s to %s", qlook->s.zfrom, - qlook->s.zto); - break; - case 'X': - printf ("Requesting %s to %s", qlook->s.zfrom, - qlook->s.zto); - break; -#if DEBUG > 0 - default: - printf ("Bad line %d", qlook->s.bcmd); - break; -#endif - } - - printf ("\n"); - } - } - else - { - const char *zxqt; - FILE *e; - long csize; - struct scmdlist *qsize; - char *zline; - - /* Show the command for an execution file. */ - zxqt = zsysdep_spool_file_name (qsys, qlook->s.zfrom); - if (zxqt == NULL) - return FALSE; - - e = fopen (zxqt, "r"); - if (e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", zxqt, strerror (errno)); - return FALSE; - } - - csize = 0L; - for (qsize = qlist; qsize != NULL; qsize = qsize->qnext) - { - if (qsize->s.bcmd == 'S') - { - const char *zfile; - - if (strchr (qsize->s.zoptions, 'C') != NULL - || fspool_file (qsize->s.zfrom)) - zfile = zsysdep_spool_file_name (qsys, qsize->s.ztemp); - else - zfile = zsysdep_real_file_name (qsys, qsize->s.zfrom, - (const char *) NULL); - if (zfile != NULL) - csize += csysdep_size (zfile); - } - } - - usworkfile_header (qsys, &qlook->s, zlistid, qlook->itime, - TRUE); - - while ((zline = zfgets (e, FALSE)) != NULL) - { - char *ztok; - - ztok = strtok (zline, " \t"); - if (ztok != NULL - && strcmp (ztok, "C") == 0) - { - char *zcmd; - int clen; - - zcmd = strtok ((char *) NULL, ""); - zcmd += strspn (zcmd, " \t"); - clen = strlen (zcmd); - if (zcmd[clen - 1] == '\n') - zcmd[clen - 1] = '\0'; - printf ("Executing %s", zcmd); - xfree ((pointer) zline); - break; - } - xfree ((pointer) zline); - } - - if (zline == NULL) - printf ("Unrecognized execution"); - - printf (" (sending %ld bytes)\n", csize); - - (void) fclose (e); - } - - /* Free up the list of entries. */ - qlook = qlist; - while (qlook != NULL) - { - struct scmdlist *qnext; - - qnext = qlook->qnext; - xfree ((pointer) qlook); - qlook = qnext; - } - - xfree ((pointer) zlistid); - - qlist = NULL; - zlistid = NULL; - } - - /* Start a new list with the entry we just got. */ - - if (qcmd != NULL) - { - qlist = (struct scmdlist *) xmalloc (sizeof (struct scmdlist)); - qlist->qnext = NULL; - qlist->s = *qcmd; - qlist->itime = itime; - zlistid = zid; - } - - return TRUE; -} - -/* Show the header of the line describing a workfile. */ - -static void -usworkfile_header (qsys, qcmd, zjobid, itime, ffirst) - const struct ssysteminfo *qsys; - const struct scmd *qcmd; - const char *zjobid; - long itime; - boolean ffirst; -{ - const char *zshowid; - struct tm stime; - - if (ffirst) - zshowid = zjobid; - else - zshowid = "-"; - - printf ("%.14s %s %s ", zshowid, qsys->zname, qcmd->zuser); - - usysdep_localtime (itime, &stime); - printf ("%04d-%02d-%02d %02d:%02d:%02d ", - stime.tm_year + 1900, stime.tm_mon + 1, - stime.tm_mday, stime.tm_hour, - stime.tm_min, stime.tm_sec); -} - -/* Handle the -q option. For each remote system this lists the number - of jobs queued, the number of executions queued, and the current - call status. We get the executions all at once, because they are - not accessed by system. They could be, but it is possible to have - executions pending for an unknown system, so special handling would - still be required. */ - -struct sxqtlist -{ - struct sxqtlist *qnext; - char *zsystem; - int cxqts; - long ifirst; -}; - -/* These local functions need the definition of sxqtlist for the - prototype. */ - -static boolean fsquery_system P((const struct ssysteminfo *qsys, - struct sxqtlist **pq, - long inow)); -static boolean fsquery_show P((const struct ssysteminfo *qsys, int cwork, - long ifirstwork, - struct sxqtlist *qxqt, - long inow)); - -static boolean -fsquery () -{ - struct sxqtlist *qlist; - const char *zfile; - const char *zsystem; - boolean ferr; - long inow; - int csystems; - struct ssysteminfo *pas; - boolean fret; - int i; - - /* Get a count of all the execution files. */ - - if (! fsysdep_get_xqt_init ()) - return FALSE; - - qlist = NULL; - while ((zfile = zsysdep_get_xqt (&zsystem, &ferr)) != NULL) - { - struct sxqtlist *qlook; - - for (qlook = qlist; qlook != NULL; qlook = qlook->qnext) - if (strcmp (zsystem, qlook->zsystem) == 0) - break; - - if (qlook != NULL) - { - long itime; - - ++qlook->cxqts; - itime = isysdep_file_time (zfile); - if (itime < qlook->ifirst) - qlook->ifirst = itime; - } - else - { - struct sxqtlist *qnew; - - qnew = (struct sxqtlist *) xmalloc (sizeof (struct sxqtlist)); - qnew->qnext = qlist; - qnew->zsystem = xstrdup (zsystem); - qnew->cxqts = 1; - qnew->ifirst = isysdep_file_time (zfile); - qlist = qnew; - } - } - - usysdep_get_xqt_free (); - - if (ferr) - return FALSE; - - inow = isysdep_time ((long *) NULL); - - /* Get a count of all the work files, and print out the system. */ - - uread_all_system_info (&csystems, &pas); - - fret = TRUE; - for (i = 0; i < csystems; i++) - if (! fsquery_system (&pas[i], &qlist, inow)) - fret = FALSE; - - /* Check for the local system in the list of execution files. */ - if (qlist != NULL) - { - struct sxqtlist **pq; - - for (pq = &qlist; *pq != NULL; pq = &(*pq)->qnext) - { - if (strcmp ((*pq)->zsystem, zLocalname) == 0) - { - struct sxqtlist *qfree; - - if (! fsquery_show (&sLocalsys, 0, 0L, *pq, inow)) - fret = FALSE; - qfree = *pq; - *pq = qfree->qnext; - xfree ((pointer) qfree->zsystem); - xfree ((pointer) qfree); - break; - } - } - } - - /* Print out information for any unknown systems for which we have - execution files. */ - - if (qlist != NULL && ! fUnknown_ok) - { - ulog (LOG_ERROR, "Executions queued up for unknown systems"); - return FALSE; - } - - while (qlist != NULL) - { - struct sxqtlist *qnext; - - sUnknown.zname = qlist->zsystem; - if (! fsquery_show (&sUnknown, 0, 0L, qlist, inow)) - fret = FALSE; - qnext = qlist->qnext; - xfree ((pointer) qlist->zsystem); - xfree ((pointer) qlist); - qlist = qnext; - } - - return fret; -} - -/* Query a single known system. */ - -static boolean -fsquery_system (qsys, pq, inow) - const struct ssysteminfo *qsys; - struct sxqtlist **pq; - long inow; -{ - int cwork; - long ifirstwork; - boolean fret; - - if (! fsysdep_get_work_init (qsys, BGRADE_LOW)) - return FALSE; - - cwork = 0; - ifirstwork = 0L; - while (TRUE) - { - struct scmd s; - long itime; - - if (! fsysdep_get_work (qsys, BGRADE_LOW, &s)) - return FALSE; - if (s.bcmd == 'H') - break; - - ++cwork; - - itime = isysdep_work_time (qsys, s.pseq); - if (ifirstwork == 0L || ifirstwork > itime) - ifirstwork = itime; - } - - usysdep_get_work_free (qsys); - - /* Find the execution information, if any. */ - while (*pq != NULL) - { - if (strcmp ((*pq)->zsystem, qsys->zname) == 0) - break; - pq = &(*pq)->qnext; - } - - /* If there are no commands and no executions, don't print any - information for this system. */ - if (cwork == 0 && *pq == NULL) - return TRUE; - - fret = fsquery_show (qsys, cwork, ifirstwork, *pq, inow); - - if (*pq != NULL) - { - struct sxqtlist *qfree; - - qfree = *pq; - *pq = qfree->qnext; - xfree ((pointer) qfree->zsystem); - xfree ((pointer) qfree); - } - - return fret; -} - -/* Print out the query information for a single system. We handle the - local system specially. */ - -static boolean -fsquery_show (qsys, cwork, ifirstwork, qxqt, inow) - const struct ssysteminfo *qsys; - int cwork; - long ifirstwork; - struct sxqtlist *qxqt; - long inow; -{ - boolean flocal; - struct sstatus sstat; - struct tm stime; - - flocal = strcmp (qsys->zname, zLocalname) == 0; - - if (! flocal) - { - if (! fsysdep_get_status (qsys, &sstat)) - return FALSE; - } - - printf ("%s %dC (", qsys->zname, cwork); - - if (cwork == 0) - printf ("0 secs"); - else - usunits_show (inow - ifirstwork); - - printf (") "); - - if (qxqt == NULL) - printf ("0X (0 secs)"); - else - { - printf ("%dX (", qxqt->cxqts); - usunits_show (inow - qxqt->ifirst); - printf (")"); - } - - if (flocal) - { - printf ("\n"); - return TRUE; - } - - usysdep_localtime (sstat.ilast, &stime); - - printf (" %04d-%02d-%02d %02d:%02d:%02d ", - stime.tm_year + 1900, stime.tm_mon + 1, - stime.tm_mday, stime.tm_hour, - stime.tm_min, stime.tm_sec); - - printf ("%s\n", azStatus[(int) sstat.ttype]); - - return TRUE; -} - -/* Print a time difference in the largest applicable units. */ - -static void -usunits_show (idiff) - long idiff; -{ - const char *zunit; - long iunits; - - if (idiff > (long) 24 * (long) 60 * (long) 60) - { - iunits = idiff / ((long) 24 * (long) 60 * (long) 60); - zunit = "day"; - } - else if (idiff > (long) 60 * 60) - { - iunits = idiff / (long) (60 * 60); - zunit = "hour"; - } - else if (idiff > (long) 60) - { - iunits = idiff / (long) 60; - zunit = "min"; - } - else - { - iunits = idiff; - zunit = "sec"; - } - - printf ("%ld %s%s", iunits, zunit, iunits == 1 ? "" : "s"); -} - -/* Give a list of all status entries for all machines that we have - status entries for. We need to get a list of status entries in a - system dependent fashion, since we may have status for unknown - systems. */ - -static boolean -fsmachines () -{ - pointer phold; - const char *zsystem; - boolean ferr; - struct sstatus sstat; - - if (! fsysdep_all_status_init (&phold)) - return FALSE; - - while ((zsystem = zsysdep_all_status (phold, &ferr, &sstat)) != NULL) - { - struct tm stime; - - usysdep_localtime (sstat.ilast, &stime); - printf ("%-14s %04d-%02d-%02d %02d:%02d:%02d %s", zsystem, - stime.tm_year + 1900, stime.tm_mon + 1, - stime.tm_mday, stime.tm_hour, - stime.tm_min, stime.tm_sec, - azStatus[(int) sstat.ttype]); - if (sstat.ttype != STATUS_TALKING - && sstat.cwait > 0) - { - printf (" (%d %s", sstat.cretries, - sstat.cretries == 1 ? "try" : "tries"); - if (sstat.ilast + sstat.cwait > isysdep_time ((long *) NULL)) - { - usysdep_localtime (sstat.ilast + sstat.cwait, &stime); - printf (", next %04d-%02d-%02d %02d:%02d:%02d", - stime.tm_year + 1900, stime.tm_mon + 1, - stime.tm_mday, stime.tm_hour, - stime.tm_min, stime.tm_sec); - } - printf (")"); - } - printf ("\n"); - } - - usysdep_all_status_free (phold); - - return ! ferr; -} diff --git a/gnu/libexec/uucp/uutime.h b/gnu/libexec/uucp/uutime.h deleted file mode 100644 index 7954c3276ee3..000000000000 --- a/gnu/libexec/uucp/uutime.h +++ /dev/null @@ -1,137 +0,0 @@ -/* uutime.h - Header file for UUCP time routines. - - Copyright (C) 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Id: uutime.h,v 1.2 1993/08/02 17:25:16 mycroft Exp $ -*/ - -#ifndef UUTIME_H - -#define UUTIME_H - -/* Timetables are kept in a array of pairs of strings. */ - -struct stimetable -{ - /* Name of timetable. */ - const char *zname; - /* Time string. */ - const char *ztime; -}; - -extern int cTtable; -extern struct stimetable *pasTtable; - -/* A time string is parsed into a list of the following structures. - Each element of the list represents a span of time. The time - string matches any time that is one of the spans. The time may - only depend on the day of the week, not on the day of the month or - of the year. Also, the time is specified only down to the minute, - not down to the second or below. - - The starting and ending time are expressed in minutes since the - beginning of the week, which is considered to be 12 midnight on - Sunday. Thus 60 is 1 am on Sunday, 1440 (== 60 * 24) is 12 - midnight on Monday, and the largest possible value is 10080 (== 60 - * 24 * 7) which is 12 midnight on the following Sunday. - - Each span of time has a value associated with it. This is the - lowest grade or the largest file size that may be transferred - during the span. When we add a new time span that overlaps with an - existing one, we use the span with the higher grade or the smaller - file size. Thus specifying ``call-timegrade z Any'' and - ``call-timegrade Z Mo'' means that only grade Z or higher may be - sent on Monday, since Z is the higer grade of the overlapping - spans. After determining which grade or file size to use, we - eliminate all overlaps. - - Each span also has a retry time associated with it. This permits - different retry times to be used at different times of day. */ - -struct sspan -{ - /* Next time span in this list. */ - struct sspan *qnext; - /* Value for this span (lowest grade or largest file that may be - transferred at this time). */ - long ival; - /* Starting minute. */ - int istart; - /* Ending minute. */ - int iend; - /* Retry time. */ - int cretry; -}; - -/* Time functions. */ - -/* Initialize the array of timetables. */ -extern void uinittimetables P((void)); - -/* Add a new timetable entry. */ -extern void uaddtimetable P((const char *zname, const char *ztime)); - -/* Parse a timegrade string into a time span. A timegrade string is a - sequence of strings separated by a single space. The first - character of each string is a grade. The second character begins a - time string. The time string may end in a semicolon followed by a - retry time. */ -extern struct sspan *qtimegrade_parse P((const char *ztimegrade)); - -/* Parse a timesize string into a time span. A timespan string is a - sequence of pairs of strings, all separated by a single space. The - first string in each pair is a numeric size. The second string is - a time string. */ -extern struct sspan *qtimesize_parse P((const char *ztimesize)); - -/* See if the current time matches a time span. If not, return FALSE. - Otherwise, return TRUE and set *pival and *pcretry to the values - from the matching element of the span. */ -extern boolean ftimespan_match P((const struct sspan *, - long *pival, int *pcretry)); - -/* Free a time span returned by either qtparse_timesize or - qtparse_timegrade. */ -extern void utimespan_free P((struct sspan *)); - -/* Determine the grade of work permitted at the current time, given a - timegrade string. This parses the timegrade string, locates the - entry corresponding to the current time, and returns the associated - grade. If no time in the timegrade string matches, this returns - '\0'. */ -extern char btimegrade P((const char *ztimegrade)); - -/* Determine the maximum size that may be transferred at the current - time, given a timesize string. This parses the timesize string, - locates the entry corresponding to the current time, and returns - the associated size. If no time in the timesize string matches, - this returns -1. */ -extern long cmax_size_now P((const char *ztimesize)); - -/* Determine the maximum size that may ever be transferred, given a - timesize string. If there are any time gaps larger than 1 hour not - described by the timesize string, this returns -1. Otherwise it - returns the largest size that may be transferred at some time. */ -extern long cmax_size_ever P((const char *ztimesize)); - -#endif /* ! defined (UUTIME_H) */ diff --git a/gnu/libexec/uucp/uux.1 b/gnu/libexec/uucp/uux.1 deleted file mode 100644 index 3e9056c42aef..000000000000 --- a/gnu/libexec/uucp/uux.1 +++ /dev/null @@ -1,260 +0,0 @@ -''' $Id: uux.1,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ -''' $Log: uux.1,v $ -''' Revision 1.1.1.1 1993/03/21 09:45:37 cgd -''' initial import of 386bsd-0.1 sources -''' -''' Revision 1.7 1992/04/01 21:11:19 ian -''' Cleaned up a bit, updated -x switch -''' -''' Revision 1.6 1992/03/28 04:34:11 ian -''' David J. MacKenzie: change .TP5 to .TP 5; also updated to 1.03 -''' -''' Revision 1.5 1992/02/29 04:07:08 ian -''' Added -j option to uucp and uux -''' -''' Revision 1.4 1992/01/20 23:52:23 ian -''' Change to version 1.02 -''' -''' Revision 1.3 1991/12/18 04:37:01 ian -''' Clarified -z switch somewhat -''' -''' Revision 1.2 1991/12/14 19:11:54 ian -''' Added -l option to link files -''' -''' Revision 1.1 1991/12/14 19:05:30 ian -''' Initial revision -''' -''' -.TH uux 1 "Taylor UUCP 1.03" -.SH NAME -uux \- Remote command execution over UUCP -.SH SYNOPSIS -.B uux -[ options ] command -.SH DESCRIPTION -The -.I uux -command is used to execute a command on a remote system, or to execute -a command on the local system using files from remote systems. -The command -is not executed immediately; the request is queued until the -.I uucico -(8) daemon calls the system and executes it. The daemon is -started automatically unless the -.B \-r -switch is given. - -The actual command execution is done by the -.I uuxqt -(8) daemon. - -File arguments can be gathered from remote systems to the execution -system, as can standard input. Standard output may be directed to a -file on a remote system. - -The command name may be preceded by a system name followed by an -exclamation point if it is to be executed on a remote system. An -empty system name is taken as the local system. - -Each argument that contains an exclamation point is treated as naming -a file. The system which the file is on is before the exclamation -point, and the pathname on that system follows it. An empty system -name is taken as the local system; this must be used to transfer a -file to a command being executed on a remote system. If the path is -not absolute, it will be appended to the current working directory on -the local system; the result may not be meaningful on the remote -system. A pathname may begin with ~/, in which case it is relative to -the UUCP public directory (usually /usr/spool/uucppublic) on the -appropriate system. A pathname may begin with ~name/, in which case -it is relative to the home directory of the named user on the -appropriate system. - -Standard input and output may be redirected as usual; the pathnames -used may contain exclamation points to indicate that they are on -remote systems. Note that the redirection characters must be quoted -so that they are passed to -.I uux -rather than interpreted by the shell. Append redirection (>>) does -not work. - -All specified files are gathered together into a single directory -before execution of the command begins. This means that each file -must have a distinct base name. For example, -.EX -uux 'sys1!diff sys2!~user1/foo sys3!~user2/foo >!foo.diff' -.EE -will fail because both files will be copied to sys1 and stored under -the name foo. - -Arguments may be quoted by parentheses to avoid interpretation of -exclamation points. This is useful when executing the -.I uucp -command on a remote system. -.SH OPTIONS -The following options may be given to -.I uux. -.TP 5 -.B \-,\-p -Read standard input and use it as the standard input for the command -to be executed. -.TP 5 -.B \-c -Do not copy local files to the spool directory. This is the default. -If they are -removed before being processed by the -.I uucico -(8) daemon, the copy will fail. The files must be readable by the -.I uucico -(8) daemon, -as well as the by the invoker of -.I uux. -.TP 5 -.B \-C -Copy local files to the spool directory. -.TP 5 -.B \-l -Link local files into the spool directory. If a file can not be -linked because it is on a different device, it will be copied unless -the -.B \-c -option also appears (in other words, use of -.B \-l -switches the default from -.B \-c -to -.B \-C). -If the files are changed before being processed by the -.I uucico -(8) daemon, the changed versions will be used. The files must be -readable by the -.I uucico -(8) daemon, as well as by the invoker of -.I uux. -.TP 5 -.B \-g grade -Set the grade of the file transfer command. Jobs of a higher grade -are executed first. Grades run 0 ... 9 A ... Z a ... z from high to -low. -.TP 5 -.B \-n -Do not send mail about the status of the job, even if it fails. -.TP 5 -.B \-z -Send mail about the status of the job if an error occurs. For many -.I uuxqt -daemons, including the Taylor UUCP -.I uuxqt, -this is the default action; for those, -.B \-z -will have no effect. However, some -.I uuxqt -daemons will send mail if the job succeeds unless the -.B \-z -option is used, and some other -.I uuxqt -daemons will not send mail if the job fails unless the -.B \-z -option is used. -.TP 5 -.B \-r -Do not start the -.I uucico -(8) daemon immediately; merely queue up the execution request for later -processing. -.TP 5 -.B \-j -Print jobids on standard output. A jobid will be generated for each -file copy operation required to perform the operation. These file -copies may be cancelled by -passing the jobid to the -.B \-k -switch of -.I uustat -(1), which will make the execution impossible to complete. -.TP 5 -.B \-a address -Report job status to the specified e-mail address. -.TP 5 -.B \-x type -Turn on particular debugging types. The following types are -recognized: abnormal, chat, handshake, uucp-proto, proto, port, -config, spooldir, execute, incoming, outgoing. Only abnormal, config, -spooldir and execute are meaningful for -.I uux. - -Multiple types may be given, separated by commas, and the -.B \-x -option may appear multiple times. A number may also be given, which -will turn on that many types from the foregoing list; for example, -.B \-x 2 -is equivalent to -.B \-x abnormal,chat. -.TP 5 -.B \-I file -Set configuration file to use. This option may not be available, -depending upon how -.I uux -was compiled. -.SH EXAMPLES -.EX -uux -z - sys1!rmail user1 -.EE -Execute the command ``rmail user1'' on the system sys1, giving it as -standard input whatever is given to -.I uux -as standard input. If a failure occurs, send a message using -.I mail -(1). -.EX -uux 'diff -c sys1!~user1/file1 sys2!~user2/file2 >!file.diff' -.EE -Fetch the two named files from system sys1 and system sys2 and execute -.I diff -putting the result in file.diff in the current directory. The current -directory must be writable by the -.I uuxqt -(8) daemon for this to work. -.EX -uux 'sys1!uucp ~user1/file1 (sys2!~user2/file2)' -.EE -Execute -.I uucp -on the system sys1 copying file1 (on system sys1) to sys2. This -illustrates the use of parentheses for quoting. -.SH RESTRICTIONS -The remote system may not permit you to execute certain commands. -Many remote systems only permit the execution of -.I rmail -and -.I rnews. - -Some of the options are dependent on the capabilities of the -.I uuxqt -(8) daemon on the remote system. -.SH FILES -The file names may be changed at compilation time or by the -configuration file, so these are only approximations. - -.br -/usr/lib/uucp/config - Configuration file. -.br -/usr/spool/uucp - -UUCP spool directory. -.br -/usr/spool/uucp/Log - -UUCP log file. -.br -/usr/spool/uucppublic - -Default UUCP public directory. -.SH SEE ALSO -mail(1), uustat(1), uucp(1), uucico(8), uuxqt(8) -.SH BUGS -Files can not be referenced across multiple systems. - -Too many jobids are output by -.B \-j, -and there is no good way to cancel a local execution requiring remote -files. -.SH AUTHOR -Ian Lance Taylor -(ian@airs.com or uunet!airs!ian) diff --git a/gnu/libexec/uucp/uux.c b/gnu/libexec/uucp/uux.c deleted file mode 100644 index 132ad69e6c87..000000000000 --- a/gnu/libexec/uucp/uux.c +++ /dev/null @@ -1,1280 +0,0 @@ -/* uux.c - Prepare to execute a command on a remote system. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: uux.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.32 1992/03/15 04:51:17 ian - Keep an array of signals we've received rather than a single variable - - Revision 1.31 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.30 1992/03/02 15:20:43 ian - Check iSignal before entering fread - - Revision 1.29 1992/02/29 04:07:08 ian - Added -j option to uucp and uux - - Revision 1.28 1992/02/29 01:06:59 ian - Chip Salzenberg: recheck file permissions before sending - - Revision 1.27 1992/02/28 05:06:15 ian - T. William Wells: fsysdep_catch must be a macro - - Revision 1.26 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.25 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.24 1992/02/08 22:33:32 ian - Only get the current working directory if it's going to be needed - - Revision 1.23 1992/02/08 20:33:57 ian - Handle all possible signals raised by abort - - Revision 1.22 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.21 1992/02/02 20:34:36 ian - Niels Baggesen: must check user permissions on access to local files - - Revision 1.20 1992/01/21 19:39:12 ian - Chip Salzenberg: uucp and uux start uucico for right system, not any - - Revision 1.19 1992/01/15 07:06:29 ian - Set configuration directory in Makefile rather than sysdep.h - - Revision 1.18 1992/01/05 03:09:17 ian - Changed abProgram and abVersion to non const to avoid compiler bug - - Revision 1.17 1992/01/05 02:51:38 ian - Allocate enough space for log message - - Revision 1.16 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.15 1991/12/21 21:16:05 ian - Franc,ois Pinard: remove parentheses from ZSHELLSEPS - - Revision 1.14 1991/12/20 03:07:54 ian - Added space and tab to ZSHELLSEPS to stop command at whitespace - - Revision 1.13 1991/12/18 03:54:14 ian - Made error messages to terminal appear more normal - - Revision 1.12 1991/12/14 16:09:07 ian - Added -l option to uux to link files into the spool directory - - Revision 1.11 1991/12/11 03:59:19 ian - Create directories when necessary; don't just assume they exist - - Revision 1.10 1991/12/07 03:03:12 ian - Split arguments like sh; request sh execution if any metachars appear - - Revision 1.9 1991/11/21 22:17:06 ian - Add version string, print version when printing usage - - Revision 1.8 1991/11/15 19:17:32 ian - Hannu Strang: copy stdin using fread/fwrite, not fgets/fputs - - Revision 1.7 1991/11/13 23:08:40 ian - Expand remote pathnames in uucp and uux; fix up uux special cases - - Revision 1.6 1991/11/08 21:53:17 ian - Brian Campbell: fix argument handling when looking for '-' - - Revision 1.5 1991/11/07 22:52:49 ian - Chip Salzenberg: avoid recursive strtok, handle redirection better - - Revision 1.4 1991/09/19 03:23:34 ian - Chip Salzenberg: append to private debugging file, don't overwrite it - - Revision 1.3 1991/09/19 02:30:37 ian - From Chip Salzenberg: check whether signal is ignored differently - - Revision 1.2 1991/09/11 02:33:14 ian - Added ffork argument to fsysdep_run - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char uux_rcsid[] = "$Id: uux.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#include "getopt.h" - -#include "system.h" -#include "sysdep.h" - -/* External functions. */ -extern int fclose (); - -/* These character lists should, perhaps, be in sysdep.h. */ - -/* This is the list of shell metacharacters that we check for. If one - of these is present, we request uuxqt to execute the command with - /bin/sh. Otherwise we let it execute using execve. */ - -#define ZSHELLCHARS "\"'`*?[;&()|<>\\$" - -/* This is the list of word separators. We break filename arguments - at these characters. */ -#define ZSHELLSEPS ";&*|<> \t" - -/* This is the list of word separators without the redirection - operators. */ -#define ZSHELLNONREDIRSEPS ";&*| \t" - -/* The program name. */ -char abProgram[] = "uux"; - -/* Long getopt options. */ - -static const struct option asXlongopts[] = { { NULL, 0, NULL, 0 } }; - -const struct option *_getopt_long_options = asXlongopts; - -/* The execute file we are creating. */ - -static FILE *eXxqt_file; - -/* A list of commands to be spooled. */ - -static struct scmd *pasXcmds; -static int cXcmds; - -/* A file to close if we're forced to exit. */ - -static FILE *eXclose; - -/* Local functions. */ - -static void uxusage P((void)); -static void uxadd_xqt_line P((int bchar, const char *z1, const char *z2)); -static void uxadd_send_file P((const char *zfrom, const char *zto, - const char *zoptions, const char *ztemp)); -static void uxcopy_stdin P((FILE *e)); -static void uxrecord_file P((const char *zfile)); -static void uxabort P((void)); - -int -main (argc, argv) - int argc; - char **argv; -{ - int iopt; - /* -a: requestor address for status reports. */ - const char *zrequestor = NULL; - /* -b: if true, return standard input on error. */ - boolean fretstdin = FALSE; - /* -c,-C: if true, copy to spool directory. */ - boolean fcopy = FALSE; - /* -c: set if -c appears explicitly; if it and -l appear, then if the - link fails we don't copy the file. */ - boolean fdontcopy = FALSE; - /* -I: configuration file name. */ - const char *zconfig = NULL; - /* -j: output job id. */ - boolean fjobid = FALSE; - /* -g: job grade. */ - char bgrade = BDEFAULT_UUX_GRADE; - /* -l: link file to spool directory. */ - boolean flink = FALSE; - /* -n: do not notify upon command completion. */ - boolean fno_ack = FALSE; - /* -p: read standard input for command standard input. */ - boolean fread_stdin = FALSE; - /* -r: do not start uucico when finished. */ - boolean fuucico = TRUE; - /* -s: report status to named file. */ - const char *zstatus_file = NULL; - /* -W: only expand local file names. */ - boolean fexpand = TRUE; - /* -z: report status only on error. */ - boolean ferror_ack = FALSE; - int i; - int clen; - char *zargs; - char *zarg; - char *zcmd; - char *zexclam; - boolean fgetcwd; - const char *zuser; - struct ssysteminfo sxqtsys; - const struct ssysteminfo *qxqtsys; - boolean fxqtlocal; - char **pzargs; - int calloc_args; - int cargs; - const char *zxqtname; - char abxqt_tname[CFILE_NAME_LEN]; - char abxqt_xname[CFILE_NAME_LEN]; - boolean fneedshell; - char *zprint; - const char *zcall_system; - boolean fcall_any; - boolean fexit; - - /* We need to be able to read a single - as an option, which getopt - won't do. So that we can still use getopt, we run through the - options looking for an option "-"; if we find one we change it to - "-p", which is an equivalent option. */ - - for (i = 1; i < argc; i++) - { - if (argv[i][0] != '-') - break; - if (argv[i][1] == '\0') - argv[i] = xstrdup ("-p"); - else - { - const char *z; - - for (z = argv[i] + 1; *z != '\0'; z++) - { - /* If the option takes an argument, and the argument is - not appended, then skip the next argument. */ - if (*z == 'a' || *z == 'g' || *z == 'I' - || *z == 's' || *z == 'x') - { - if (z[1] == '\0') - i++; - break; - } - } - } - } - - /* The leading + in the getopt string means to stop processing - options as soon as a non-option argument is seen. */ - - while ((iopt = getopt (argc, argv, "+a:bcCg:I:jlnprs:Wx:z")) != EOF) - { - switch (iopt) - { - case 'a': - /* Set requestor name: mail address to which status reports - should be sent. */ - zrequestor = optarg; - break; - - case 'b': - /* Return standard input on error. */ - fretstdin = TRUE; - break; - - case 'c': - /* Do not copy local files to spool directory. */ - fcopy = FALSE; - fdontcopy = TRUE; - break; - - case 'C': - /* Copy local files to spool directory. */ - fcopy = TRUE; - break; - - case 'I': - /* Configuration file name. */ - zconfig = optarg; - break; - - case 'j': - /* Output jobid. */ - fjobid = TRUE; - break; - - case 'g': - /* Set job grade. */ - bgrade = optarg[0]; - break; - - case 'l': - /* Link file to spool directory. */ - flink = TRUE; - break; - - case 'n': - /* Do not notify upon command completion. */ - fno_ack = TRUE; - break; - - case 'p': - /* Read standard input for command standard input. */ - fread_stdin = TRUE; - break; - - case 'r': - /* Do not start uucico when finished. */ - fuucico = FALSE; - break; - - case 's': - /* Report status to named file. */ - zstatus_file = optarg; - break; - - case 'W': - /* Only expand local file names. */ - fexpand = FALSE; - break; - - case 'x': -#if DEBUG > 1 - /* Set debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 'z': - /* Report status only on error. */ - ferror_ack = TRUE; - break; - - case 0: - /* Long option found and flag set. */ - break; - - default: - uxusage (); - break; - } - } - - if (! FGRADE_LEGAL (bgrade)) - { - ulog (LOG_ERROR, "Ignoring illegal grade"); - bgrade = BDEFAULT_UUX_GRADE; - } - - if (optind == argc) - uxusage (); - - uread_config (zconfig); - - /* The command and files arguments could be quoted in any number of - ways, so we split them apart ourselves. We do this before - calling usysdep_initialize because we want to set fgetcwd - correctly. */ - clen = 1; - for (i = optind; i < argc; i++) - clen += strlen (argv[i]) + 1; - - zargs = (char *) alloca (clen); - *zargs = '\0'; - for (i = optind; i < argc; i++) - { - strcat (zargs, argv[i]); - strcat (zargs, " "); - } - - /* The first argument is the command to execute. */ - clen = strcspn (zargs, ZSHELLSEPS); - zcmd = (char *) alloca (clen + 1); - strncpy (zcmd, zargs, clen); - zcmd[clen] = '\0'; - zargs += clen; - - /* Split the arguments out into an array. We break the arguments - into alternating sequences of characters not in ZSHELLSEPS - and characters in ZSHELLSEPS. We remove whitespace. We - separate the redirection characters '>' and '<' into their - own arguments to make them easier to process below. */ - - calloc_args = 10; - pzargs = (char **) xmalloc (calloc_args * sizeof (char *)); - cargs = 0; - - for (zarg = strtok (zargs, " \t"); - zarg != NULL; - zarg = strtok ((char *) NULL, " \t")) - { - while (*zarg != '\0') - { - if (cargs >= calloc_args + 1) - { - calloc_args += 10; - pzargs = (char **) xrealloc ((pointer) pzargs, - calloc_args * sizeof (char *)); - } - - clen = strcspn (zarg, ZSHELLSEPS); - if (clen > 0) - { - pzargs[cargs] = (char *) xmalloc (clen + 1); - strncpy (pzargs[cargs], zarg, clen); - pzargs[cargs][clen] = '\0'; - ++cargs; - zarg += clen; - } - - /* We deliberately separate '>' and '<' out. */ - if (*zarg != '\0') - { - clen = strspn (zarg, ZSHELLNONREDIRSEPS); - if (clen == 0) - clen = 1; - pzargs[cargs] = (char *) xmalloc (clen + 1); - strncpy (pzargs[cargs], zarg, clen); - pzargs[cargs][clen] = '\0'; - ++cargs; - zarg += clen; - } - } - } - - /* Now look through the arguments to see if we are going to need the - current working directory. We don't try to make a precise - determination, just a conservative one. The basic idea is that - we don't want to get the cwd for 'rmail - foo!user' (note that we - don't examine the command itself). */ - fgetcwd = FALSE; - for (i = 0; i < cargs; i++) - { - zexclam = strrchr (pzargs[i], '!'); - if (zexclam != NULL && fsysdep_needs_cwd (zexclam + 1)) - { - fgetcwd = TRUE; - break; - } - if ((pzargs[i][0] == '<' || pzargs[i][0] == '>') - && i + 1 < cargs - && strchr (pzargs[i + 1], '!') == NULL - && fsysdep_needs_cwd (pzargs[i + 1])) - { - fgetcwd = TRUE; - break; - } - } - -#ifdef SIGINT - usysdep_signal (SIGINT); -#endif -#ifdef SIGHUP - usysdep_signal (SIGHUP); -#endif -#ifdef SIGQUIT - usysdep_signal (SIGQUIT); -#endif -#ifdef SIGTERM - usysdep_signal (SIGTERM); -#endif -#ifdef SIGPIPE - usysdep_signal (SIGPIPE); -#endif - - usysdep_initialize (FALSE, fgetcwd); - - ulog_fatal_fn (uxabort); - - zuser = zsysdep_login_name (); - - /* Figure out which system the command is to be executed on. */ - zexclam = strchr (zcmd, '!'); - if (zexclam == NULL) - { - qxqtsys = &sLocalsys; - fxqtlocal = TRUE; - } - else - { - *zexclam = '\0'; - - if (*zcmd == '\0' || strcmp (zcmd, zLocalname) == 0) - { - qxqtsys = &sLocalsys; - fxqtlocal = TRUE; - } - else - { - if (fread_system_info (zcmd, &sxqtsys)) - qxqtsys = &sxqtsys; - else - { - if (! fUnknown_ok) - ulog (LOG_FATAL, "System %s unknown", zcmd); - qxqtsys = &sUnknown; - sUnknown.zname = zcmd; - } - - fxqtlocal = FALSE; - } - - zcmd = zexclam + 1; - } - - /* Make sure we have a spool directory. */ - - if (! fsysdep_make_spool_dir (qxqtsys)) - uxabort (); - - /* Name and open the execute file. If the execution is to occur on - a remote system, we must create a data file and copy it over. */ - if (fxqtlocal) - zxqtname = zsysdep_xqt_file_name (); - else - zxqtname = zsysdep_data_file_name (qxqtsys, 'X', abxqt_tname, - (char *) NULL, abxqt_xname); - if (zxqtname == NULL) - uxabort (); - - eXxqt_file = esysdep_fopen (zxqtname, FALSE, FALSE, TRUE); - if (eXxqt_file == NULL) - uxabort (); - - uxrecord_file (xstrdup (zxqtname)); - - /* Specify the user. */ - uxadd_xqt_line ('U', zuser, zLocalname); - - /* Look through the arguments. Any argument containing an - exclamation point character is interpreted as a file name, and is - sent to the appropriate system. */ - - zcall_system = NULL; - fcall_any = FALSE; - - for (i = 0; i < cargs; i++) - { - const char *zsystem, *zconst; - char *zfile; - boolean finput, foutput; - boolean flocal; - - /* Check for a parenthesized argument; remove the parentheses - and otherwise ignore it (this is how an exclamation point is - quoted). */ - - if (pzargs[i][0] == '(') - { - clen = strlen (pzargs[i]); - if (pzargs[i][clen - 1] != ')') - ulog (LOG_ERROR, "Mismatched parentheses"); - else - pzargs[i][clen - 1] = '\0'; - ++pzargs[i]; - continue; - } - - /* Check whether we are doing a redirection. */ - - finput = FALSE; - foutput = FALSE; - if (i + 1 < cargs) - { - if (pzargs[i][0] == '<') - finput = TRUE; - else if (pzargs[i][0] == '>') - foutput = TRUE; - if (finput || foutput) - { - pzargs[i] = NULL; - i++; - } - } - - zexclam = strchr (pzargs[i], '!'); - - /* If there is no exclamation point and no redirection, this - argument is left untouched. */ - - if (zexclam == NULL && ! finput && ! foutput) - continue; - - /* Get the system name and file name for this file. */ - - if (zexclam == NULL) - { - zsystem = zLocalname; - zfile = pzargs[i]; - flocal = TRUE; - } - else - { - *zexclam = '\0'; - zsystem = pzargs[i]; - if (zsystem[0] != '\0') - flocal = strcmp (zsystem, zLocalname) == 0; - else - { - zsystem = zLocalname; - flocal = TRUE; - } - zfile = zexclam + 1; - } - - /* Add the current working directory to the file name if it's - not an absolute path. */ - if (fexpand || flocal) - { - zconst = zsysdep_add_cwd (zfile, flocal); - if (zconst == NULL) - uxabort (); - zfile = xstrdup (zconst); - } - - /* Check for output redirection. We strip this argument out, - and create an O command which tells uuxqt where to send the - output. */ - - if (foutput) - { - if (flocal) - { - if (! fin_directory_list (qxqtsys, zfile, - qxqtsys->zremote_receive, TRUE, - FALSE, (const char *) NULL)) - ulog (LOG_FATAL, "Not permitted to create %s", zfile); - } - - if (strcmp (zsystem, qxqtsys->zname) == 0) - uxadd_xqt_line ('O', zfile, (const char *) NULL); - else - uxadd_xqt_line ('O', zfile, zsystem); - pzargs[i] = NULL; - continue; - } - - if (finput) - { - if (fread_stdin) - ulog (LOG_FATAL, "Standard input specified twice"); - pzargs[i] = NULL; - } - - if (flocal) - { - char *zuse; - const char *zdata; - char abtname[CFILE_NAME_LEN]; - char abdname[CFILE_NAME_LEN]; - - /* It's a local file. If requested by -C, copy the file to - the spool directory. If requested by -l, link the file - to the spool directory; if the link fails, we copy the - file, unless -c was explictly used. If the execution is - occurring on the local system, we force the copy as well, - because otherwise we would have to have some way to tell - uuxqt not to move the file. If the file is being shipped - to another system, we must set up a transfer request. - First make sure the user has legitimate access, since we - are running setuid. */ - - if (! fsysdep_access (zfile)) - uxabort (); - - if (fcopy || flink || fxqtlocal) - { - char *zdup; - boolean fdid; - - zdata = zsysdep_data_file_name (qxqtsys, bgrade, abtname, - abdname, (char *) NULL); - if (zdata == NULL) - uxabort (); - - zdup = xstrdup (zdata); - uxrecord_file (zdup); - - fdid = FALSE; - if (flink) - { - boolean fworked; - - if (! fsysdep_link (zfile, zdup, &fworked)) - uxabort (); - - if (fworked) - fdid = TRUE; - else if (fdontcopy) - ulog (LOG_FATAL, "%s: Can't link to spool directory", - zfile); - } - - if (! fdid) - { - if (! fcopy_file (zfile, zdup, FALSE, TRUE)) - uxabort (); - } - - xfree ((pointer) zdup); - - zuse = abtname; - } - else - { - /* Make sure the daemon can access the file. */ - if (! fsysdep_daemon_access (zfile)) - uxabort (); - if (! fin_directory_list (&sLocalsys, zfile, - sLocalsys.zlocal_send, - TRUE, TRUE, zuser)) - ulog (LOG_FATAL, "Not permitted to send from %s", - zfile); - - zuse = zfile; - - zdata = zsysdep_data_file_name (qxqtsys, bgrade, - (char *) NULL, abdname, - (char *) NULL); - if (zdata == NULL) - uxabort (); - strcpy (abtname, "D.0"); - } - - if (fxqtlocal) - { - if (finput) - uxadd_xqt_line ('I', zuse, (char *) NULL); - else - pzargs[i] = zuse; - } - else - { - uxadd_send_file (zuse, abdname, - fcopy || flink || fxqtlocal ? "C" : "c", - abtname); - - if (finput) - { - uxadd_xqt_line ('F', abdname, (char *) NULL); - uxadd_xqt_line ('I', abdname, (char *) NULL); - } - else - { - const char *zbase; - - zbase = zsysdep_base_name (zfile); - if (zbase == NULL) - uxabort (); - uxadd_xqt_line ('F', abdname, zbase); - pzargs[i] = xstrdup (zbase); - } - } - } - else if (strcmp (qxqtsys->zname, zsystem) == 0) - { - /* The file is already on the system where the command is to - be executed. */ - if (finput) - uxadd_xqt_line ('I', zfile, (const char *) NULL); - else - pzargs[i] = zfile; - } - else - { - struct ssysteminfo sfromsys; - const struct ssysteminfo *qfromsys; - char abtname[CFILE_NAME_LEN]; - char abdname[CFILE_NAME_LEN]; - char *ztemp; - struct scmd s; - const char *zjobid; - - /* We need to request a remote file. Make sure we have a - spool directory for the remote system. */ - - if (! fread_system_info (zsystem, &sfromsys)) - { - if (! fUnknown_ok) - ulog (LOG_FATAL, "System %s unknown", zsystem); - sfromsys = sUnknown; - sfromsys.zname = zsystem; - } - qfromsys = &sfromsys; - - if (! fsysdep_make_spool_dir (qfromsys)) - uxabort (); - - /* We want the file to wind up in the spool directory of the - local system (whether the execution is occurring - locally or not); we have to use an absolute file name - here, because otherwise the file would wind up in the - spool directory of the system it is coming from. */ - - if (! fxqtlocal) - { - if (! fsysdep_make_spool_dir (&sLocalsys)) - uxabort (); - } - - zconst = zsysdep_data_file_name (&sLocalsys, bgrade, - abtname, (char *) NULL, - (char *) NULL); - if (zconst == NULL) - uxabort (); - - /* Request the file. The special option '9' is a signal to - uucico that it's OK to receive a file into the spool - directory; normally such requests are rejected. */ - - s.bcmd = 'R'; - s.pseq = NULL; - s.zfrom = zfile; - s.zto = abtname; - s.zuser = zuser; - s.zoptions = "9"; - s.ztemp = ""; - s.imode = 0600; - s.znotify = ""; - s.cbytes = -1; - - zjobid = zsysdep_spool_commands (qfromsys, bgrade, 1, &s); - if (zjobid == NULL) - uxabort (); - - if (fjobid) - printf ("%s\n", zjobid); - - if (fcall_any) - zcall_system = NULL; - else - { - fcall_any = TRUE; - zcall_system = xstrdup (qfromsys->zname); - } - - /* Now if the execution is to occur on another system, we - must create an execute file to send the file there. The - name of the file on the execution system is put into - abdname. */ - - if (fxqtlocal) - ztemp = abtname; - else - { - const char *zxqt_file; - FILE *e; - - /* Get a file name to use on the execution system. */ - - if (zsysdep_data_file_name (qxqtsys, bgrade, - (char *) NULL, abdname, - (char *) NULL) == NULL) - uxabort (); - ztemp = abdname; - - /* The local spool directory was created above, if it - didn't already exist. */ - - zxqt_file = zsysdep_xqt_file_name (); - if (zxqt_file == NULL) - uxabort (); - - /* Queue up a uucp command to be executed locally once - the file arrives. We take advantage of the file - renaming and moving that uuxqt does to remove the - file and avoid the hassles of adding the current - directory. The -W switch to uucp prevents from - adding the current directory to the remote file. */ - - e = esysdep_fopen (zxqt_file, FALSE, FALSE, TRUE); - if (e == NULL) - uxabort (); - - eXclose = e; - uxrecord_file (xstrdup (zxqt_file)); - - fprintf (e, "U %s %s\n", zuser, zLocalname); - fprintf (e, "F %s foo\n", abtname); - fprintf (e, "C uucp -CW foo %s!%s\n", qxqtsys->zname, - abdname); - - eXclose = NULL; - if (fclose (e) != 0) - ulog (LOG_FATAL, "fclose: %s", strerror (errno)); - } - - /* Tell the command execution to wait until the file has - been received, and tell it the real file name to use. */ - - if (finput) - { - uxadd_xqt_line ('F', ztemp, (char *) NULL); - uxadd_xqt_line ('I', ztemp, (char *) NULL); - } - else - { - const char *zbase; - - zbase = zsysdep_base_name (zfile); - if (zbase == NULL) - uxabort (); - uxadd_xqt_line ('F', ztemp, zbase); - pzargs[i] = xstrdup (zbase); - } - } - } - - /* If standard input is to be read from the stdin of uux, we read it - here into a temporary file and send it to the execute system. */ - - if (fread_stdin) - { - const char *zdata; - char abtname[CFILE_NAME_LEN]; - char abdname[CFILE_NAME_LEN]; - FILE *e; - - zdata = zsysdep_data_file_name (qxqtsys, bgrade, abtname, abdname, - (char *) NULL); - if (zdata == NULL) - uxabort (); - - e = esysdep_fopen (zdata, FALSE, FALSE, TRUE); - if (e == NULL) - uxabort (); - - eXclose = e; - uxrecord_file (xstrdup (zdata)); - - uxcopy_stdin (e); - - eXclose = NULL; - if (fclose (e) != 0) - ulog (LOG_FATAL, "fclose: %s", strerror (errno)); - - if (fxqtlocal) - uxadd_xqt_line ('I', abtname, (const char *) NULL); - else - { - uxadd_xqt_line ('F', abdname, (const char *) NULL); - uxadd_xqt_line ('I', abdname, (const char *) NULL); - uxadd_send_file (abtname, abdname, "C", abtname); - } - } - - /* Here all the arguments have been determined, so the command can - be written out. If any of the arguments contain shell - metacharacters, we request remote execution with /bin/sh (this is - the 'e' command in the execute file). The default is assumed to - be remote execution with execve. */ - - fprintf (eXxqt_file, "C %s", zcmd); - - fneedshell = FALSE; - - if (zcmd[strcspn (zcmd, ZSHELLCHARS)] != '\0') - fneedshell = TRUE; - - for (i = 0; i < cargs; i++) - { - if (pzargs[i] != NULL) - { - fprintf (eXxqt_file, " %s", pzargs[i]); - if (pzargs[i][strcspn (pzargs[i], ZSHELLCHARS)] != '\0') - fneedshell = TRUE; - } - } - - fprintf (eXxqt_file, "\n"); - - /* Write out all the other miscellaneous junk. */ - - if (fno_ack) - uxadd_xqt_line ('N', (const char *) NULL, (const char *) NULL); - - if (ferror_ack) - uxadd_xqt_line ('Z', (const char *) NULL, (const char *) NULL); - - if (zrequestor != NULL) - uxadd_xqt_line ('R', zrequestor, (const char *) NULL); - - if (fretstdin) - uxadd_xqt_line ('B', (const char *) NULL, (const char *) NULL); - - if (zstatus_file != NULL) - uxadd_xqt_line ('M', zstatus_file, (const char *) NULL); - - if (fneedshell) - uxadd_xqt_line ('e', (const char *) NULL, (const char *) NULL); - - if (fclose (eXxqt_file) != 0) - ulog (LOG_FATAL, "fclose: %s", strerror (errno)); - eXxqt_file = NULL; - - /* If the execution is to occur on another system, we must now - arrange to copy the execute file to this system. */ - - if (! fxqtlocal) - uxadd_send_file (abxqt_tname, abxqt_xname, "C", abxqt_tname); - - /* If we got a signal, get out before spooling anything. */ - - if (FGOT_SIGNAL ()) - uxabort (); - - /* From here on in, it's too late. We don't call uxabort. */ - - if (cXcmds > 0) - { - const char *zjobid; - - zjobid = zsysdep_spool_commands (qxqtsys, bgrade, cXcmds, pasXcmds); - if (zjobid == NULL) - { - ulog_close (); - usysdep_exit (FALSE); - } - - if (fjobid) - printf ("%s\n", zjobid); - - if (fcall_any) - zcall_system = NULL; - else - { - fcall_any = TRUE; - zcall_system = qxqtsys->zname; - } - } - - /* If all that worked, make a log file entry. All log file reports - up to this point went to stderr. */ - - ulog_to_file (TRUE); - ulog_system (qxqtsys->zname); - ulog_user (zuser); - - clen = strlen (zcmd) + 2; - for (i = 0; i < cargs; i++) - if (pzargs[i] != NULL) - clen += strlen (pzargs[i]) + 1; - - zprint = (char *) alloca (clen); - strcpy (zprint, zcmd); - strcat (zprint, " "); - for (i = 0; i < cargs; i++) - { - if (pzargs[i] != NULL) - { - strcat (zprint, pzargs[i]); - strcat (zprint, " "); - } - } - zprint[strlen (zprint) - 1] = '\0'; - - ulog (LOG_NORMAL, "Queuing %s", zprint); - - ulog_close (); - - if (! fuucico) - fexit = TRUE; - else - { - if (zcall_system != NULL) - fexit = fsysdep_run (TRUE, "uucico", "-s", zcall_system); - else if (fcall_any) - fexit = fsysdep_run (TRUE, "uucico", "-r1", (const char *) NULL); - else - fexit = TRUE; - } - - usysdep_exit (fexit); - - /* Avoid error about not returning a value. */ - return 0; -} - -/* Report command usage. */ - -static void -uxusage () -{ - fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", - abVersion); - fprintf (stderr, - "Usage: uux [options] [-] command\n"); - fprintf (stderr, - " -,-p: Read standard input for standard input of command\n"); - fprintf (stderr, - " -c: Do not copy local files to spool directory (default)\n"); - fprintf (stderr, - " -C: Copy local files to spool directory\n"); - fprintf (stderr, - " -l: link local files to spool directory\n"); - fprintf (stderr, - " -g grade: Set job grade (must be alphabetic)\n"); - fprintf (stderr, - " -n: Do not report completion status\n"); - fprintf (stderr, - " -z: Report completion status only on error\n"); - fprintf (stderr, - " -r: Do not start uucico daemon\n"); - fprintf (stderr, - " -a address: Address to mail status report to\n"); - fprintf (stderr, - " -b: Return standard input with status report\n"); - fprintf (stderr, - " -s file: Report completion status to file\n"); - fprintf (stderr, - " -j: Report job id\n"); - fprintf (stderr, - " -x debug: Set debugging level\n"); -#if HAVE_TAYLOR_CONFIG - fprintf (stderr, - " -I file: Set configuration file to use (default %s%s)\n", - NEWCONFIGLIB, CONFIGFILE); -#endif /* HAVE_TAYLOR_CONFIG */ - exit (EXIT_FAILURE); -} - -/* Add a line to the execute file. */ - -static void -uxadd_xqt_line (bchar, z1, z2) - int bchar; - const char *z1; - const char *z2; -{ - if (z1 == NULL) - fprintf (eXxqt_file, "%c\n", bchar); - else if (z2 == NULL) - fprintf (eXxqt_file, "%c %s\n", bchar, z1); - else - fprintf (eXxqt_file, "%c %s %s\n", bchar, z1, z2); -} - -/* Add a file to be sent to the execute system. */ - -static void -uxadd_send_file (zfrom, zto, zoptions, ztemp) - const char *zfrom; - const char *zto; - const char *zoptions; - const char *ztemp; -{ - struct scmd s; - - s.bcmd = 'S'; - s.pseq = NULL; - s.zfrom = xstrdup (zfrom); - s.zto = xstrdup (zto); - s.zuser = zsysdep_login_name (); - s.zoptions = xstrdup (zoptions); - s.ztemp = xstrdup (ztemp); - s.imode = 0666; - s.znotify = ""; - s.cbytes = -1; - - ++cXcmds; - pasXcmds = (struct scmd *) xrealloc ((pointer) pasXcmds, - cXcmds * sizeof (struct scmd)); - pasXcmds[cXcmds - 1] = s; -} - -/* Copy stdin to a file. This is a separate function because it may - call setjump. */ - -static void -uxcopy_stdin (e) - FILE *e; -{ - CATCH_PROTECT int cread; - char ab[1024]; - - do - { - int cwrite; - - if (fsysdep_catch ()) - { - usysdep_start_catch (); - if (FGOT_SIGNAL ()) - uxabort (); - - /* There's an unimportant race here. If the user hits ^C - between the FGOT_SIGNAL we just did and the time we enter - fread, we won't know about the signal (unless we're doing - a longjmp, but we normally aren't). It's not a big - problem, because the user can just hit ^C again. */ - - cread = fread (ab, sizeof (char), sizeof ab, stdin); - } - - usysdep_end_catch (); - - if (FGOT_SIGNAL ()) - uxabort (); - - if (cread > 0) - { - cwrite = fwrite (ab, sizeof (char), cread, e); - if (cwrite != cread) - { - if (cwrite == EOF) - ulog (LOG_FATAL, "fwrite: %s", strerror (errno)); - else - ulog (LOG_FATAL, "fwrite: Wrote %d when attempted %d", - cwrite, cread); - } - } - } - while (cread == sizeof ab); -} - -/* Keep track of all files we have created so that we can delete them - if we get a signal. The argument will be on the heap. */ - -static int cxfiles; -static const char **pxaz; - -static void -uxrecord_file (zfile) - const char *zfile; -{ - pxaz = (const char **) xrealloc ((pointer) pxaz, - (cxfiles + 1) * sizeof (const char *)); - pxaz[cxfiles] = zfile; - ++cxfiles; -} - -/* Delete all the files we have recorded and exit. */ - -static void -uxabort () -{ - int i; - - if (eXxqt_file != NULL) - (void) fclose (eXxqt_file); - if (eXclose != NULL) - (void) fclose (eXclose); - for (i = 0; i < cxfiles; i++) - (void) remove (pxaz[i]); - ulog_close (); - usysdep_exit (FALSE); -} diff --git a/gnu/libexec/uucp/uuxqt.8 b/gnu/libexec/uucp/uuxqt.8 deleted file mode 100644 index 30f007f065bb..000000000000 --- a/gnu/libexec/uucp/uuxqt.8 +++ /dev/null @@ -1,109 +0,0 @@ -''' $Id: uuxqt.8,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ -''' $Log: uuxqt.8,v $ -''' Revision 1.1.1.1 1993/03/21 09:45:37 cgd -''' initial import of 386bsd-0.1 sources -''' -''' Revision 1.4 1992/04/01 21:11:19 ian -''' Cleaned up a bit, updated -x switch -''' -''' Revision 1.3 1992/03/28 04:34:11 ian -''' David J. MacKenzie: change .TP5 to .TP 5; also updated to 1.03 -''' -''' Revision 1.2 1992/01/20 23:52:23 ian -''' Change to version 1.02 -''' -''' Revision 1.1 1991/12/14 19:05:30 ian -''' Initial revision -''' -''' -.TH uuxqt 8 "Taylor UUCP 1.03" -.SH NAME -uuxqt \- UUCP execution daemon -.SH SYNOPSIS -.B uuxqt -[ options ] -.SH DESCRIPTION -The -.I uuxqt -daemon executes commands requested by -.I uux -(1) from either the local system or from remote systems. -It is started automatically by the -.I uucico -(8) daemon (unless -.I uucico -(8) is given the -.B \-q -option). - -There is normally no need to run this command, since it will be -invoked by -.I uucico -(8). However, it can be used to provide greater control over the -processing of the work queue. - -Multiple invocations of -.I uuxqt -may be run at once, as controlled by the -.I max-uuxqts -configuration command. -.SH OPTIONS -The following options may be given to -.I uuxqt. -.TP 5 -.B \-c command -Only execute requests for the specified command. For example: -.EX -uuxqt -c rmail -.EE -.TP 5 -.B \-s system -Only execute requests originating from the specified system. -.TP 5 -.B \-x type -Turn on particular debugging types. The following types are -recognized: abnormal, chat, handshake, uucp-proto, proto, port, -config, spooldir, execute, incoming, outgoing. Only abnormal, config, -spooldir and execute are meaningful for -.I uuxqt. - -Multiple types may be given, separated by commas, and the -.B \-x -option may appear multiple times. A number may also be given, which -will turn on that many types from the foregoing list; for example, -.B \-x 2 -is equivalent to -.B \-x abnormal,chat. - -The debugging output is sent to the debugging file, usually one of -/usr/spool/uucp/Debug, /usr/spool/uucp/DEBUG, or -/usr/spool/uucp/.Admin/audit.local. -.TP 5 -.B \-I file -Set configuration file to use. This option may not be available, -depending upon how -.I uuxqt -was compiled. -.SH FILES -The file names may be changed at compilation time or by the -configuration file, so these are only approximations. - -.br -/usr/lib/uucp/config - Configuration file. -.br -/usr/spool/uucp - -UUCP spool directory. -.br -/usr/spool/uucp/Log - -UUCP log file. -.br -/usr/spool/uucppublic - -Default UUCP public directory. -.br -/usr/spool/uucp/Debug - -Debugging file. -.SH SEE ALSO -uucp(1), uux(1), uucico(8) -.SH AUTHOR -Ian Lance Taylor -(ian@airs.com or uunet!airs!ian) diff --git a/gnu/libexec/uucp/uuxqt.c b/gnu/libexec/uucp/uuxqt.c deleted file mode 100644 index c1d9f990fdaf..000000000000 --- a/gnu/libexec/uucp/uuxqt.c +++ /dev/null @@ -1,1370 +0,0 @@ -/* uuxqt.c - Run uux commands. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: uuxqt.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.43 1992/03/17 04:42:41 ian - Correct bug in previous patch - - Revision 1.42 1992/03/17 03:15:40 ian - Pass command to fsysdep_execute as first element of argument array - - Revision 1.41 1992/03/17 01:07:15 ian - Miscellaneous cleanup - - Revision 1.40 1992/03/16 19:44:45 ian - Cast result of alloca - - Revision 1.39 1992/03/15 04:51:17 ian - Keep an array of signals we've received rather than a single variable - - Revision 1.38 1992/03/15 01:54:46 ian - All execs are now done in isspawn, all waits are done in iswait - - Revision 1.37 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.36 1992/03/11 22:34:25 ian - Chip Salzenberg: support Internet mail addresses in uuxqt replies - - Revision 1.35 1992/03/11 22:06:37 ian - Marty Shannon: added max-uuxqts command - - Revision 1.34 1992/03/11 17:04:53 ian - Jon Zeeff: retry execution later if temporary failure - - Revision 1.33 1992/03/11 02:09:19 ian - Correct bug in previous change - - Revision 1.32 1992/03/04 02:32:26 ian - Handle executions on local system - - Revision 1.31 1992/02/29 04:07:08 ian - Added -j option to uucp and uux - - Revision 1.30 1992/02/29 01:06:59 ian - Chip Salzenberg: recheck file permissions before sending - - Revision 1.29 1992/02/27 05:40:54 ian - T. William Wells: detach from controlling terminal, handle signals safely - - Revision 1.28 1992/02/24 04:58:47 ian - Only permit files to be received into directories that are world-writeable - - Revision 1.27 1992/02/23 19:50:50 ian - Handle READ and WRITE in Permissions correctly - - Revision 1.26 1992/02/23 03:26:51 ian - Overhaul to use automatic configure shell script - - Revision 1.25 1992/02/18 19:03:02 ian - Pass fdaemon argument correctly to usysdep_initialize - - Revision 1.24 1992/02/18 04:53:26 ian - T. William Wells: make sure sh execution uses absolute path - - Revision 1.23 1992/02/14 21:32:50 ian - Niels Baggesen: under HAVE_BNU_LOGGING, don't lost system name when dieing - - Revision 1.22 1992/02/08 22:33:32 ian - Only get the current working directory if it's going to be needed - - Revision 1.21 1992/02/08 20:33:57 ian - Handle all possible signals raised by abort - - Revision 1.20 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.19 1992/01/16 17:48:41 ian - Niels Baggesen: was checking strcmp return incorrectly - - Revision 1.18 1992/01/15 07:06:29 ian - Set configuration directory in Makefile rather than sysdep.h - - Revision 1.17 1992/01/05 03:09:17 ian - Changed abProgram and abVersion to non const to avoid compiler bug - - Revision 1.16 1992/01/04 21:43:24 ian - Chip Salzenberg: added ALLOW_FILENAME_ARGUMENTS to permit them - - Revision 1.15 1992/01/04 04:12:54 ian - David J. Fiander: make sure execution arguments are not bad file names - - Revision 1.14 1991/12/29 04:22:41 ian - The mailing address was not getting initialized - - Revision 1.13 1991/12/29 04:04:18 ian - Added a bunch of extern definitions - - Revision 1.12 1991/12/20 00:17:38 ian - Don't process execute files for unknown systems - - Revision 1.11 1991/12/19 03:52:07 ian - David Nugent: rescan the list of execute files until nothing can be done - - Revision 1.10 1991/12/18 03:54:14 ian - Made error messages to terminal appear more normal - - Revision 1.9 1991/12/17 04:55:01 ian - David Nugent: ignore SIGHUP in uucico and uuxqt - - Revision 1.8 1991/12/09 18:49:06 ian - Richard Todd: the requestor address is relative to the requesting system - - Revision 1.7 1991/12/06 23:42:18 ian - Don't acknowledge success by default - - Revision 1.6 1991/12/01 01:28:44 ian - Mitch Mitchell: fixed comment listing supported commands - - Revision 1.5 1991/11/21 22:17:06 ian - Add version string, print version when printing usage - - Revision 1.4 1991/11/07 20:52:33 ian - Chip Salzenberg: pass command as single argument to /bin/sh - - Revision 1.3 1991/09/19 16:15:58 ian - Chip Salzenberg: configuration option for permitting execution via sh - - Revision 1.2 1991/09/19 02:30:37 ian - From Chip Salzenberg: check whether signal is ignored differently - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char uuxqt_rcsid[] = "$Id: uuxqt.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include -#include - -#include "getopt.h" - -#include "system.h" -#include "sysdep.h" - -/* External functions. */ -extern int fclose (); - -/* The program name. */ -char abProgram[] = "uuxqt"; - -/* Static variables used to unlock things if we get a fatal error. */ - -static int iQunlock_seq = -1; -static const char *zQunlock_cmd; -static const char *zQunlock_file; -static boolean fQunlock_directory; - -/* Local functions. */ - -static void uqusage P((void)); -static void uqabort P((void)); -static void uqdo_xqt_file P((const char *zfile, - const struct ssysteminfo *qsys, - const char *zcmd, boolean *pfprocessed)); -static void uqcleanup P((const char *zfile, int iflags)); - -/* Long getopt options. */ - -static const struct option asQlongopts[] = { { NULL, 0, NULL, 0 } }; - -const struct option *_getopt_long_options = asQlongopts; - -int -main (argc, argv) - int argc; - char **argv; -{ - int iopt; - /* The type of command to execute (NULL for any type). */ - const char *zcmd = NULL; - /* The configuration file name. */ - const char *zconfig = NULL; - /* The system to execute commands for. */ - const char *zdosys = NULL; - boolean fany; - const char *z; - const char *zgetsys; - boolean ferr; - struct ssysteminfo sreadsys; - const struct ssysteminfo *qreadsys; - - while ((iopt = getopt (argc, argv, "c:I:s:x:")) != EOF) - { - switch (iopt) - { - case 'c': - /* Set the type of command to execute. */ - zcmd = optarg; - break; - - case 'I': - /* Set the configuration file name. */ - zconfig = optarg; - break; - - case 's': - zdosys = optarg; - break; - - case 'x': -#if DEBUG > 1 - /* Set the debugging level. */ - iDebug |= idebug_parse (optarg); -#endif - break; - - case 0: - /* Long option found and flag set. */ - break; - - default: - uqusage (); - break; - } - } - - if (optind != argc) - uqusage (); - - uread_config (zconfig); - -#ifdef SIGINT - usysdep_signal (SIGINT); -#endif -#ifdef SIGHUP - usysdep_signal (SIGHUP); -#endif -#ifdef SIGQUIT - usysdep_signal (SIGQUIT); -#endif -#ifdef SIGTERM - usysdep_signal (SIGTERM); -#endif -#ifdef SIGPIPE - usysdep_signal (SIGPIPE); -#endif - - usysdep_initialize (TRUE, FALSE); - - ulog_to_file (TRUE); - ulog_fatal_fn (uqabort); - - /* Limit the number of uuxqt processes, and make sure we're the only - uuxqt daemon running for this command. */ - iQunlock_seq = isysdep_lock_uuxqt (zcmd); - if (iQunlock_seq < 0) - { - ulog_close (); - usysdep_exit (TRUE); - } - zQunlock_cmd = zcmd; - - /* Keep scanning the execute files until we don't process any of - them. */ - - do - { - fany = FALSE; - - /* Look for each execute file, and run it. */ - - if (! fsysdep_get_xqt_init ()) - { - ulog_close (); - usysdep_exit (FALSE); - } - - qreadsys = NULL; - - while ((z = zsysdep_get_xqt (&zgetsys, &ferr)) != NULL) - { - char *zcopy; - boolean fprocessed; - const struct ssysteminfo *qusesys; - -#if ! HAVE_ALLOCA - /* Clear out any accumulated alloca buffers. */ - (void) alloca (0); -#endif - - /* It would be more efficient to pass zdosys down to the - routines which retrieve execute files. */ - if (zdosys != NULL && strcmp (zdosys, zgetsys) != 0) - continue; - - if (strcmp (zgetsys, zLocalname) == 0) - qusesys = &sLocalsys; - else - { - if (qreadsys == NULL - || strcmp (qreadsys->zname, zgetsys) != 0) - { - if (fread_system_info (zgetsys, &sreadsys)) - qreadsys = &sreadsys; - else - { - if (! fUnknown_ok) - { - ulog (LOG_ERROR, - "%s: Execute file for unknown system %s", - z, zgetsys); - (void) remove (z); - continue; - } - qreadsys = &sUnknown; - sUnknown.zname = xstrdup (zgetsys); - } - - if (! fsysdep_make_spool_dir (qreadsys)) - continue; - } - - qusesys = qreadsys; - } - - /* If we've received a signal, get out of the loop. */ - if (FGOT_SIGNAL ()) - break; - - zcopy = xstrdup (z); - - ulog_system (qusesys->zname); - uqdo_xqt_file (zcopy, qusesys, zcmd, &fprocessed); - ulog_system ((const char *) NULL); - ulog_user ((const char *) NULL); - - if (fprocessed) - fany = TRUE; - xfree ((pointer) zcopy); - } - - usysdep_get_xqt_free (); - } - while (fany && ! FGOT_SIGNAL ()); - - (void) fsysdep_unlock_uuxqt (iQunlock_seq, zcmd); - iQunlock_seq = -1; - - ulog_close (); - - if (FGOT_SIGNAL ()) - ferr = TRUE; - - usysdep_exit (! ferr); - - /* Avoid errors about not returning a value. */ - return 0; -} - -static void -uqusage () -{ - fprintf (stderr, - "Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n", - abVersion); - fprintf (stderr, - "Usage: uuxqt [-c cmd] [-I file] [-s system] [-x debug]\n"); - fprintf (stderr, - " -c cmd: Set type of command to execute\n"); - fprintf (stderr, - " -s system: Execute commands only for named system\n"); - fprintf (stderr, - " -x debug: Set debugging level (0 for none, 9 is max)\n"); -#if HAVE_TAYLOR_CONFIG - fprintf (stderr, - " -I file: Set configuration file to use (default %s%s)\n", - NEWCONFIGLIB, CONFIGFILE); -#endif /* HAVE_TAYLOR_CONFIG */ - exit (EXIT_FAILURE); -} - -/* This is the abort function called when we get a fatal error. */ - -static void -uqabort () -{ -#if ! HAVE_BNU_LOGGING - /* When using BNU logging, it's a pain to have no system name. */ - ulog_system ((const char *) NULL); -#endif - - ulog_user ((const char *) NULL); - - if (fQunlock_directory) - (void) fsysdep_unlock_uuxqt_dir (); - - if (zQunlock_file != NULL) - (void) fsysdep_unlock_uuxqt_file (zQunlock_file); - - if (iQunlock_seq >= 0) - (void) fsysdep_unlock_uuxqt (iQunlock_seq, zQunlock_cmd); - - ulog_close (); - - usysdep_exit (FALSE); -} - -/* An execute file is a series of lines. The first character of each - line is a command. The following commands are defined: - - C command-line - I standard-input - O standard-output [ system ] - F required-file filename-to-use - R requestor-address - U user system - Z (acknowledge if command failed; default) - N (no acknowledgement on failure) - n (acknowledge if command succeeded) - B (return command input on error) - e (process with sh) - E (process with exec) - M status-file - # comment - - Unrecognized commands are ignored. We actually do not recognize - the Z command, since it requests default behaviour. We always send - mail on failure, unless the N command appears. We never send mail - on success, unless the n command appears. - - This code does not currently support the B or M commands. */ - -/* Command arguments. */ -static const char **azQargs; -/* Command as a complete string. */ -static char *zQcmd; -/* Standard input file name. */ -static const char *zQinput; -/* Standard output file name. */ -static const char *zQoutfile; -/* Standard output system. */ -static const char *zQoutsys; -/* Number of required files. */ -static int cQfiles; -/* Names of required files. */ -static char **azQfiles; -/* Names required files should be renamed to (NULL if original is OK). */ -static char **azQfiles_to; -/* Requestor address (this is where mail should be sent). */ -static const char *zQrequestor; -/* User name. */ -static const char *zQuser; -/* System name. */ -static const char *zQsystem; -/* This is set by the N flag, meaning that no acknowledgement should - be mailed on failure. */ -static boolean fQno_ack; -/* This is set by the n flag, meaning that acknowledgement should be - mailed if the command succeeded. */ -static boolean fQsuccess_ack; -/* This is set by the B flag, meaning that command input should be - mailed to the requestor if an error occurred. */ -static boolean fQsend_input; -/* This is set by the E flag, meaning that exec should be used to - execute the command. */ -static boolean fQuse_exec; -/* The status should be copied to this file on the requesting host. */ -static const char *zQstatus_file; -#if ALLOW_SH_EXECUTION -/* This is set by the e flag, meaning that sh should be used to - execute the command. */ -static boolean fQuse_sh; -#endif /* ALLOW_SH_EXECUTION */ - -static enum tcmdtabret tqcmd P((int argc, char **argv, pointer pvar, - const char *zerr)); -static enum tcmdtabret tqout P((int argc, char **argv, pointer pvar, - const char *zerr)); -static enum tcmdtabret tqfile P((int argc, char **argv, pointer pvar, - const char *zerr)); -static enum tcmdtabret tquser P((int argc, char **argv, pointer pvar, - const char *zerr)); -static enum tcmdtabret tqset P((int argc, char **argv, pointer pvar, - const char *zerr)); - -static struct scmdtab asQcmds[] = -{ - { "C", CMDTABTYPE_FN | 0, NULL, tqcmd }, - { "I", CMDTABTYPE_STRING, (pointer) &zQinput, NULL }, - { "O", CMDTABTYPE_FN | 0, NULL, tqout }, - { "F", CMDTABTYPE_FN | 0, NULL, tqfile }, - { "R", CMDTABTYPE_STRING, (pointer) &zQrequestor, NULL }, - { "U", CMDTABTYPE_FN | 3, NULL, tquser }, - { "N", CMDTABTYPE_FN | 1, (pointer) &fQno_ack, tqset }, - { "n", CMDTABTYPE_FN | 1, (pointer) &fQsuccess_ack, tqset }, - { "B", CMDTABTYPE_FN | 1, (pointer) &fQsend_input, tqset }, -#if ALLOW_SH_EXECUTION - { "e", CMDTABTYPE_FN | 1, (pointer) &fQuse_sh, tqset }, -#endif - { "E", CMDTABTYPE_FN | 1, (pointer) &fQuse_exec, tqset }, - { "M", CMDTABTYPE_STRING, (pointer) &zQstatus_file, NULL }, - { NULL, 0, NULL, NULL } -}; - -/* Handle the C command: store off the arguments. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tqcmd (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - int i; - int clen; - - if (argc <= 1) - return CMDTABRET_FREE; - - azQargs = (const char **) xmalloc (argc * sizeof (char *)); - clen = 0; - for (i = 1; i < argc; i++) - { - azQargs[i - 1] = argv[i]; - clen += strlen (argv[i]) + 1; - } - azQargs[i - 1] = NULL; - - zQcmd = (char *) xmalloc (clen); - zQcmd[0] = '\0'; - for (i = 1; i < argc - 1; i++) - { - strcat (zQcmd, argv[i]); - strcat (zQcmd, " "); - } - strcat (zQcmd, argv[i]); - - return CMDTABRET_CONTINUE; -} - -/* Handle the O command, which may have one or two arguments. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tqout (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - if (argc != 2 && argc != 3) - { - ulog (LOG_ERROR, "%s: %s: Wrong number of arguments", - zerr, argv[0]); - return CMDTABRET_FREE; - } - - zQoutfile = argv[1]; - if (argc == 3) - zQoutsys = argv[2]; - - return CMDTABRET_CONTINUE; -} - -/* Handle the F command, which may have one or two arguments. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tqfile (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - if (argc != 2 && argc != 3) - { - ulog (LOG_ERROR, "%s: %s: Wrong number of arguments", - zerr, argv[0]); - return CMDTABRET_FREE; - } - - /* If this file is not in the spool directory, just ignore it. */ - if (! fspool_file (argv[1])) - return CMDTABRET_FREE; - - ++cQfiles; - azQfiles = (char **) xrealloc ((pointer) azQfiles, - cQfiles * sizeof (char *)); - azQfiles_to = (char **) xrealloc ((pointer) azQfiles_to, - cQfiles * sizeof (char *)); - - azQfiles[cQfiles - 1] = xstrdup (argv[1]); - if (argc == 3) - azQfiles_to[cQfiles - 1] = xstrdup (argv[2]); - else - azQfiles_to[cQfiles - 1] = NULL; - - return CMDTABRET_FREE; -} - -/* Handle the U command, which takes two arguments. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tquser (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - zQuser = argv[1]; - zQsystem = argv[2]; - return CMDTABRET_CONTINUE; -} - -/* Handle various commands which just set boolean variables. */ - -/*ARGSUSED*/ -static enum tcmdtabret -tqset (argc, argv, pvar, zerr) - int argc; - char **argv; - pointer pvar; - const char *zerr; -{ - boolean *pf = (boolean *) pvar; - - *pf = TRUE; - return CMDTABRET_FREE; -} - -/* The execution processing does a lot of things that have to be - cleaned up. Rather than try to add the appropriate statements - to each return point, we keep a set of flags indicating what - has to be cleaned up. The actual clean up is done by the - function uqcleanup. */ - -#define REMOVE_FILE (01) -#define REMOVE_NEEDED (02) -#define FREE_QINPUT (04) - -/* Process an execute file. The zfile argument is the name of the - execute file. The qsys argument describes the system it came from. - The zcmd argument is the name of the command we are executing (from - the -c option) or NULL if any command is OK. This sets - *pfprocessed to TRUE if the file is ready to be executed. */ - -static void -uqdo_xqt_file (zfile, qsys, zcmd, pfprocessed) - const char *zfile; - const struct ssysteminfo *qsys; - const char *zcmd; - boolean *pfprocessed; -{ - const char *zcmds; - const char *zabsolute; - boolean ferr; - FILE *e; - int i; - int iclean; - const char *zmail; - const char *zoutput; - char abtemp[CFILE_NAME_LEN]; - char abdata[CFILE_NAME_LEN]; - const char *zerror; - struct ssysteminfo soutsys; - const struct ssysteminfo *qoutsys; - boolean fshell; - char *zfullcmd; - boolean ftemp; - - *pfprocessed = FALSE; - - /* If we're not permitted to execute anything for this system, - we can just clobber the file without even looking at it. */ - zcmds = qsys->zcmds; - - if (*zcmds == '\0') - { - ulog (LOG_ERROR, "%s: No commands permitted for system %s", - zfile, qsys->zname); - (void) remove (zfile); - return; - } - - /* If we are only willing to execute a particular command, and it - is not one of those accepted by this system, quit now. */ - if (zcmd != NULL - && strcmp (zcmds, "ALL") != 0 - && strstr (zcmds, zcmd) == NULL) - return; - - e = fopen (zfile, "r"); - if (e == NULL) - return; - - azQargs = NULL; - zQcmd = NULL; - zQinput = NULL; - zQoutfile = NULL; - zQoutsys = NULL; - cQfiles = 0; - azQfiles = NULL; - azQfiles_to = NULL; - zQrequestor = NULL; - zQuser = NULL; - zQsystem = NULL; - fQno_ack = FALSE; - fQsuccess_ack = FALSE; - fQsend_input = FALSE; - fQuse_exec = FALSE; - zQstatus_file = NULL; -#if ALLOW_SH_EXECUTION - fQuse_sh = FALSE; -#endif - - uprocesscmds (e, (struct smulti_file *) NULL, asQcmds, zfile, 0); - - (void) fclose (e); - - iclean = 0; - - if (azQargs == NULL) - { - ulog (LOG_ERROR, "%s: No command given", zfile); - uqcleanup (zfile, iclean | REMOVE_FILE); - return; - } - - if (zcmd != NULL) - { - if (strcmp (zcmd, azQargs[0]) != 0) - { - uqcleanup (zfile, iclean); - return; - } - } - else - { - /* If there is a lock file for this particular command already, - it means that some other uuxqt is supposed to handle it. */ - if (fsysdep_uuxqt_locked (azQargs[0])) - { - uqcleanup (zfile, iclean); - return; - } - } - - /* Lock this particular file. */ - - if (! fsysdep_lock_uuxqt_file (zfile)) - { - uqcleanup (zfile, iclean); - return; - } - - zQunlock_file = zfile; - - if (zQuser != NULL) - ulog_user (zQuser); - else if (zQrequestor != NULL) - ulog_user (zQrequestor); - else - ulog_user ("unknown"); - - /* Make sure that all the required files exist, and get their - full names in the spool directory. */ - - for (i = 0; i < cQfiles; i++) - { - const char *zreal; - - zreal = zsysdep_spool_file_name (qsys, azQfiles[i]); - if (zreal == NULL) - { - uqcleanup (zfile, iclean); - return; - } - if (! fsysdep_file_exists (zreal)) - { - uqcleanup (zfile, iclean); - return; - } - xfree ((pointer) azQfiles[i]); - azQfiles[i] = xstrdup (zreal); - } - - /* See if we need the execute directory, and lock it if we do. */ - - for (i = 0; i < cQfiles; i++) - { - int itries; - - if (azQfiles_to[i] == NULL) - continue; - - for (itries = 0; itries < 5; itries++) - { - if (fsysdep_lock_uuxqt_dir ()) - break; - usysdep_sleep (30); - } - if (itries >= 5) - { - ulog (LOG_ERROR, "Could not lock execute directory"); - uqcleanup (zfile, iclean); - return; - } - - fQunlock_directory = TRUE; - break; - } - - iclean |= REMOVE_FILE | REMOVE_NEEDED; - *pfprocessed = TRUE; - - /* Get the address to mail results to. Prepend the system from - which the execute file originated, since mail addresses are - relative to it. */ - - zmail = NULL; - if (zQrequestor != NULL) - zmail = zQrequestor; - else if (zQuser != NULL) - zmail = zQuser; - if (zmail != NULL - && zQsystem != NULL -#if HAVE_INTERNET_MAIL - && strchr (zmail, '@') == NULL -#endif - && strcmp (zQsystem, zLocalname) != 0) - { - char *zset; - - zset = (char *) alloca (strlen (zQsystem) + strlen (zmail) + 2); - - sprintf (zset, "%s!%s", zQsystem, zmail); - zmail = zset; - } - - /* Get the pathname to execute. */ - - zabsolute = zsysdep_find_command (azQargs[0], zcmds, qsys->zpath, - &ferr); - if (zabsolute == NULL) - { - if (ferr) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - - /* Not permitted. Send mail to requestor. */ - - ulog (LOG_ERROR, "Not permitted to execute %s", - azQargs[0]); - - if (zmail != NULL && ! fQno_ack) - { - const char *az[20]; - - i = 0; - az[i++] = "Your execution request failed because you are not"; - az[i++] = " permitted to execute\n\t"; - az[i++] = azQargs[0]; - az[i++] = "\non this system.\n"; - az[i++] = "Execution requested was:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution failed", i, az); - } - - uqcleanup (zfile, iclean); - return; - } - - { - char *zcopy; - - zcopy = (char *) alloca (strlen (zabsolute) + 1); - strcpy (zcopy, zabsolute); - zabsolute = zcopy; - } - - azQargs[0] = zabsolute; - -#if ! ALLOW_FILENAME_ARGUMENTS - - /* Check all the arguments to make sure they don't try to specify - files they are not permitted to access. */ - - for (i = 1; azQargs[i] != NULL; i++) - { - if (! fsysdep_xqt_check_file (qsys, azQargs[i])) - { - if (zmail != NULL && ! fQno_ack) - { - const char *az[20]; - const char *zfailed; - - zfailed = azQargs[i]; - i = 0; - az[i++] = "Your execution request failed because you are not"; - az[i++] = " permitted to refer to file\n\t"; - az[i++] = zfailed; - az[i++] = "\non this system.\n"; - az[i++] = "Execution requested was:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution failed", i, az); - } - - uqcleanup (zfile, iclean); - return; - } - } - -#endif /* ! ALLOW_FILENAME_ARGUMENTS */ - - ulog (LOG_NORMAL, "Executing %s (%s)", zfile, zQcmd); - - if (zQinput != NULL) - { - boolean fspool; - - fspool = fspool_file (zQinput); - if (fspool) - zQinput = zsysdep_spool_file_name (qsys, zQinput); - else - zQinput = zsysdep_real_file_name (qsys, zQinput, - (const char *) NULL); - if (zQinput == NULL) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - - zQinput = xstrdup (zQinput); - iclean |= FREE_QINPUT; - - if (! fspool - && ! fin_directory_list (qsys, zQinput, - qsys->zremote_send, TRUE, TRUE, - (const char *) NULL)) - { - ulog (LOG_ERROR, "Not permitted to read %s", zQinput); - - if (zmail != NULL && ! fQno_ack) - { - const char *az[20]; - - i = 0; - az[i++] = "Your execution request failed because you are"; - az[i++] = " not permitted to read\n\t"; - az[i++] = zQinput; - az[i++] = "\non this system.\n"; - az[i++] = "Execution requested was:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution failed", i, az); - } - - uqcleanup (zfile, iclean); - return; - } - } - - if (zQoutfile == NULL) - { - zoutput = NULL; - qoutsys = NULL; - } - else if (zQoutsys != NULL - && strcmp (zQoutsys, zLocalname) != 0) - { - const char *zdata; - char *zcopy; - - /* The output file is destined for some other system, so we must - use a temporary file to catch standard output. */ - - if (strcmp (zQoutsys, qsys->zname) == 0) - qoutsys = qsys; - else - { - if (! fread_system_info (zQoutsys, &soutsys)) - { - if (! fUnknown_ok) - { - ulog (LOG_ERROR, - "Can't send standard output to unknown system %s", - zQoutsys); - /* We don't send mail to unknown systems, either. - Maybe we should. */ - uqcleanup (zfile, iclean); - return; - } - soutsys = sUnknown; - soutsys.zname = zQoutsys; - } - - qoutsys = &soutsys; - - if (! fsysdep_make_spool_dir (qoutsys)) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - } - - zdata = zsysdep_data_file_name (qoutsys, BDEFAULT_UUX_GRADE, abtemp, - abdata, (char *) NULL); - if (zdata == NULL) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - - zcopy = (char *) alloca (strlen (zdata) + 1); - strcpy (zcopy, zdata); - zoutput = zcopy; - } - else - { - boolean fok; - char *zcopy; - - qoutsys = NULL; - - /* If we permitted the standard output to be redirected into - the spool directory, people could set up phony commands. */ - - if (fspool_file (zQoutfile)) - fok = FALSE; - else - { - zQoutfile = zsysdep_real_file_name (&sLocalsys, zQoutfile, - (const char *) NULL); - if (zQoutfile == NULL) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - - /* Make sure it's OK to receive this file. Note that this - means that a locally executed uux (which presumably - requires remote files) will only be able to create files - in standard directories. If we don't it this way, users - could clobber files which uucp has access to; still, it - would be nice to allow them to direct the output to their - home directory. */ - - fok = fin_directory_list (qsys, zQoutfile, qsys->zremote_receive, - TRUE, FALSE, (const char *) NULL); - } - - if (! fok) - { - ulog (LOG_ERROR, "Not permitted to write to %s", zQoutfile); - - if (zmail != NULL && ! fQno_ack) - { - const char *az[20]; - - i = 0; - az[i++] = "Your execution request failed because you are"; - az[i++] = " not permitted to write to\n\t"; - az[i++] = zQoutfile; - az[i++] = "\non this system.\n"; - az[i++] = "Execution requested was:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution failed", i, az); - } - - uqcleanup (zfile, iclean); - return; - } - - zcopy = (char *) alloca (strlen (zQoutfile) + 1); - strcpy (zcopy, zQoutfile); - zQoutfile = zcopy; - zoutput = zcopy; - } - - /* Move the required files to the execution directory if necessary. */ - - for (i = 0; i < cQfiles; i++) - { - if (azQfiles_to[i] != NULL) - { - const char *zname; - - /* Move the file to the execute directory. */ - - zname = zsysdep_in_dir (XQTDIR, azQfiles_to[i]); - if (zname == NULL) - { - /* If we get an error, try again later. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - if (! fsysdep_move_file (azQfiles[i], zname, 0, FALSE, - (const char *) NULL)) - { - /* If we get an error, try again later. This may not be - correct, depending on what kind of error we get. */ - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - - /* If we just moved the standard input file, adjust the - file name. */ - if (zQinput != NULL && strcmp (azQfiles[i], zQinput) == 0) - { - xfree ((pointer) zQinput); - zQinput = xstrdup (zname); - } - } - } - -#if ALLOW_SH_EXECUTION - fshell = fQuse_sh; -#else - fshell = FALSE; -#endif - - /* Get a shell command which uses the full path of the command to - execute. */ - zfullcmd = (char *) alloca (strlen (zQcmd) + strlen (azQargs[0]) + 2); - *zfullcmd = '\0'; - for (i = 0; azQargs[i] != NULL; i++) - { - strcat (zfullcmd, azQargs[i]); - strcat (zfullcmd, " "); - } - zfullcmd[strlen (zfullcmd) - 1] = '\0'; - - if (! fsysdep_execute (qsys, - zQuser == NULL ? (const char *) "uucp" : zQuser, - azQargs, zfullcmd, zQinput, zoutput, fshell, - &zerror, &ftemp)) - { - if (ftemp) - { - ulog (LOG_NORMAL, "Will retry later (%s)", zfile); - if (zoutput != NULL) - (void) remove (zoutput); - if (zerror != NULL) - (void) remove (zerror); - uqcleanup (zfile, iclean &~ (REMOVE_FILE | REMOVE_NEEDED)); - *pfprocessed = FALSE; - return; - } - - ulog (LOG_NORMAL, "Execution failed (%s)", zfile); - - if (zmail != NULL && ! fQno_ack) - { - const char **pz; - int cgot; - FILE *eerr; - int istart; - - cgot = 20; - pz = (const char **) xmalloc (cgot * sizeof (const char *)); - i = 0; - pz[i++] = "Execution request failed:\n\t"; - pz[i++] = zQcmd; - pz[i++] = "\n"; - - if (zerror == NULL) - eerr = NULL; - else - eerr = fopen (zerror, "r"); - if (eerr == NULL) - { - pz[i++] = "There was no output on standard error\n"; - istart = i; - } - else - { - char *zline; - - pz[i++] = "Standard error output was:\n"; - istart = i; - - while ((zline = zfgets (eerr, FALSE)) != NULL) - { - if (i >= cgot) - { - cgot += 20; - pz = ((const char **) - xrealloc ((pointer) pz, - cgot * sizeof (const char *))); - } - pz[i++] = zline; - } - - (void) fclose (eerr); - } - - (void) fsysdep_mail (zmail, "Execution failed", i, pz); - - for (; istart < i; istart++) - xfree ((pointer) pz[istart]); - xfree ((pointer) pz); - } - - if (qoutsys != NULL) - (void) remove (zoutput); - } - else - { - if (zmail != NULL && fQsuccess_ack) - { - const char *az[20]; - - i = 0; - az[i++] = "\nExecution request succeeded:\n\t"; - az[i++] = zQcmd; - az[i++] = "\n"; - - (void) fsysdep_mail (zmail, "Execution succeded", i, az); - } - - /* Now we may have to uucp the output to some other machine. */ - - if (qoutsys != NULL) - { - struct scmd s; - - /* Fill in the command structure. */ - - s.bcmd = 'S'; - s.pseq = NULL; - s.zfrom = abtemp; - s.zto = zQoutfile; - if (zQuser != NULL) - s.zuser = zQuser; - else - s.zuser = "uucp"; - if (zmail != NULL && fQsuccess_ack) - s.zoptions = "Cn"; - else - s.zoptions = "C"; - s.ztemp = abtemp; - s.imode = 0666; - if (zmail != NULL && fQsuccess_ack) - s.znotify = zmail; - else - s.znotify = ""; - /* The number of bytes will be filled in when the file is - actually sent. */ - s.cbytes = -1; - - (void) zsysdep_spool_commands (qoutsys, BDEFAULT_UUX_GRADE, - 1, &s); - } - } - - if (zerror != NULL) - (void) remove (zerror); - - uqcleanup (zfile, iclean); -} - -/* Clean up the results of uqdo_xqt_file. */ - -static void -uqcleanup (zfile, iflags) - const char *zfile; - int iflags; -{ - int i; - - DEBUG_MESSAGE2 (DEBUG_SPOOLDIR, - "uqcleanup: %s, %d", zfile, iflags); - - if (zQunlock_file != NULL) - { - (void) fsysdep_unlock_uuxqt_file (zQunlock_file); - zQunlock_file = NULL; - } - - if ((iflags & REMOVE_FILE) != 0) - (void) remove (zfile); - - if ((iflags & REMOVE_NEEDED) != 0) - { - for (i = 0; i < cQfiles; i++) - { - if (azQfiles[i] != NULL) - (void) remove (azQfiles[i]); - } - } - - if ((iflags & FREE_QINPUT) != 0) - xfree ((pointer) zQinput); - - if (fQunlock_directory) - { - (void) fsysdep_unlock_uuxqt_dir (); - fQunlock_directory = FALSE; - } - - for (i = 0; i < cQfiles; i++) - { - xfree ((pointer) azQfiles[i]); - xfree ((pointer) azQfiles_to[i]); - } - - xfree ((pointer) azQargs); - azQargs = NULL; - - xfree ((pointer) zQcmd); - zQcmd = NULL; - - xfree ((pointer) azQfiles); - azQfiles = NULL; - - xfree ((pointer) azQfiles_to); - azQfiles_to = NULL; -} diff --git a/gnu/libexec/uucp/v2.c b/gnu/libexec/uucp/v2.c deleted file mode 100644 index e514688889cc..000000000000 --- a/gnu/libexec/uucp/v2.c +++ /dev/null @@ -1,652 +0,0 @@ -/* v2.c - Read V2 configuration files. Much of this file is identical to bnu.c, - and they really should be partially merged. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: v2.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.15 1992/03/12 19:54:43 ian - Debugging based on types rather than number - - Revision 1.14 1992/03/10 21:47:39 ian - Added protocol command for ports - - Revision 1.13 1992/03/04 02:09:36 ian - Jeff Putsch: infinite loop when parsing time string - - Revision 1.12 1992/02/24 20:36:27 ian - Roberto Biancardi: skip spaces after strtok (NULL, "") - - Revision 1.11 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.10 1992/01/15 07:06:29 ian - Set configuration directory in Makefile rather than sysdep.h - - Revision 1.9 1992/01/05 04:30:45 ian - Set chat script correctly - - Revision 1.8 1991/12/28 03:49:23 ian - Added HAVE_MEMFNS and HAVE_BFNS; changed uses of memset to bzero - - Revision 1.7 1991/12/01 19:35:38 ian - David Nugent: read V2 and BNU files by default even with TAYLOR_CONFIG - - Revision 1.6 1991/11/26 01:04:04 ian - Marty Shannon: initialize ireliable for BNU and V2 configuration files - - Revision 1.5 1991/11/14 03:20:13 ian - Added seven-bit and reliable commands to help when selecting protocols - - Revision 1.4 1991/11/13 20:38:00 ian - Added TCP port type for connections over TCP - - Revision 1.3 1991/11/11 16:59:05 ian - Eliminate fread_port_info, allow NULL pflock arg to ffind_port - - Revision 1.2 1991/09/19 02:22:44 ian - Chip Salzenberg's patch to allow ";retrytime" at the end of a time string - - Revision 1.1 1991/09/10 19:40:31 ian - Initial revision - - */ - -#include "uucp.h" - -#if HAVE_V2_CONFIG - -#if USE_RCS_ID -char v2_rcsid[] = "$Id: v2.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -#include - -#include "port.h" -#include "sysdep.h" - -/* Whether to use V2 configuration files. */ -boolean fV2 = TRUE; - -/* A little routine to add a grade and a time string to a system. */ - -static void uvadd_time P((struct ssysteminfo *q, int bgrade, - const char *ztime, int cretry)); - -static void -uvadd_time (q, bgrade, ztime, cretry) - struct ssysteminfo *q; - int bgrade; - const char *ztime; - int cretry; -{ - char *zset; - - zset = (char *) alloca (strlen (ztime) + 20); - if (cretry == 0) - sprintf (zset, "%c%s", bgrade, ztime); - else - sprintf (zset, "%c%s;%d", bgrade, ztime, cretry); - uadd_string (&q->ztime, zset, ' '); -} - -/* Read V2 system information. This means reading the L.sys file and - the USERFILE file. */ - -void -uv2_read_systems (pc, ppas) - int *pc; - struct ssysteminfo **ppas; -{ - int calc; - char ab[sizeof OLDCONFIGLIB + sizeof V2_SYSTEMS - 1]; - FILE *e; - char *zline; - - *pc = 0; - *ppas = NULL; - calc = 0; - - /* Read the L.sys file first. */ - - sprintf (ab, "%s%s", OLDCONFIGLIB, V2_SYSTEMS); - e = fopen (ab, "r"); - if (e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", ab, strerror (errno)); - return; - } - - while ((zline = zfgets (e, FALSE)) != NULL) - { - char *ztok; - int i, cretry; - struct ssysteminfo *qset; - char *zsemi, *zslash; - - zline[strcspn (zline, "#\n")] = '\0'; - ztok = strtok (zline, " \t"); - if (ztok == NULL) - { - xfree ((pointer) zline); - continue; - } - - DEBUG_MESSAGE1 (DEBUG_CONFIG, - "uv2_read_systems: Reading system %s", ztok); - - /* See if we already have information for this system. */ - for (i = 0; i < *pc; i++) - if (strcmp ((*ppas)[i].zname, ztok) == 0) - break; - if (i >= *pc) - { - if (*pc >= calc) - { - calc += 10; - *ppas = ((struct ssysteminfo *) - xrealloc ((pointer) *ppas, - calc * sizeof (struct ssysteminfo))); - } - qset = &(*ppas)[*pc]; - (*pc)++; - } - else - { - struct ssysteminfo **pq; - - for (pq = &(*ppas)[i].qalternate; - *pq != NULL; - pq = &(*pq)->qalternate) - ; - *pq = (struct ssysteminfo *) xmalloc (sizeof (struct ssysteminfo)); - qset = *pq; - } - - uset_system_defaults (qset); - qset->zname = ztok; - - /* Get the time string. */ - ztok = strtok ((char *) NULL, " \t"); - if (ztok == NULL) - continue; - - /* The format of the time string appears to be time/grade, - time/grade;retry. A missing grade is taken as 'z'. */ - - cretry = 0; - zsemi = strchr (ztok, ';'); - if (zsemi != NULL) - { - *zsemi = '\0'; - cretry = atoi (zsemi + 1); - } - - qset->ztime = NULL; - while (TRUE) - { - char *zcomma; - - zcomma = strchr (ztok, ','); - if (zcomma != NULL) - *zcomma = '\0'; - - zslash = strchr (ztok, '/'); - if (zslash == NULL || zslash[1] == '\0') - uvadd_time (qset, BGRADE_LOW, ztok, cretry); - else - { - *zslash = '\0'; - uvadd_time (qset, zslash[1], ztok, cretry); - } - - if (zcomma == NULL) - break; - - ztok = zcomma + 1; - } - - /* Get the devices entry. */ - qset->zport = strtok ((char *) NULL, " \t"); - - if (qset->zport != NULL) - { - /* Get the speed entry. This is the baud rate to use. */ - ztok = strtok ((char *) NULL, " \t"); - -#if HAVE_TCP - /* If the port is "TCP", we set up a system specific port. - The baud rate becomes the service number and the phone - number becomes the address (which is still stored in - qsys->zphone). */ - if (strcmp (qset->zport, "TCP") == 0) - { - qset->zport = NULL; - qset->qport = ((struct sport *) - xmalloc (sizeof (struct sport))); - qset->qport->zname = "TCP"; - qset->qport->ttype = PORTTYPE_TCP; - qset->qport->zprotocols = NULL; - qset->qport->cproto_params = 0; - qset->qport->qproto_params = NULL; - qset->qport->ireliable = (RELIABLE_ENDTOEND - | RELIABLE_RELIABLE - | RELIABLE_EIGHT - | RELIABLE_SPECIFIED); - qset->qport->zlockname = NULL; - qset->qport->u.stcp.o = -1; - if (ztok == NULL) - qset->qport->u.stcp.zport = "uucp"; - else - qset->qport->u.stcp.zport = ztok; - } -#endif /* HAVE_TCP */ - - if (ztok != NULL) - { - qset->ibaud = atol (ztok); - - /* Get the phone number. */ - qset->zphone = strtok ((char *) NULL, " \t"); - - /* The rest of the line is the login script. */ - if (qset->zphone != NULL) - { - qset->schat.zchat = strtok ((char *) NULL, ""); - qset->schat.zchat += strspn (qset->schat.zchat, " \t"); - } - } - } - } - - (void) fclose (e); - - /* Now read USERFILE and L.cmds to get permissions. We can't fully - handle USERFILE since that specifies permissions based on local - users which we do not support. */ - - { - char abuserfile[sizeof OLDCONFIGLIB + sizeof V2_USERFILE - 1]; - - sprintf (abuserfile, "%s%s", OLDCONFIGLIB, V2_USERFILE); - e = fopen (abuserfile, "r"); - if (e == NULL) - ulog (LOG_ERROR, "fopen (%s): %s", abuserfile, strerror (errno)); - else - { - boolean *affound; - boolean fothercallback; - char *zother; - - affound = (boolean *) alloca (*pc * sizeof (boolean)); - bzero (affound, *pc * sizeof (boolean)); - - fothercallback = FALSE; - zother = NULL; - - while ((zline = zfgets (e, FALSE)) != NULL) - { - char *ztok, *zcomma, *zfiles, *zset; - boolean fcallback; - - zline[strcspn (zline, "#\n")] = '\0'; - - /* The first field is username,machinename */ - - ztok = strtok (zline, " \t"); - if (ztok == NULL) - { - xfree ((pointer) zline); - continue; - } - - zcomma = strchr (ztok, ','); - if (zcomma == NULL) - { - xfree ((pointer) zline); - continue; - } - - *zcomma++ = '\0'; - - /* The rest of the line is the list of directories, expect - that if the first directory is "c" we must call the - system back. */ - zfiles = strtok ((char *) NULL, ""); - zfiles += strspn (zfiles, " \t"); - fcallback = FALSE; - if (*zfiles == 'c' - && (zfiles[1] == '\0' - || zfiles[1] == ' ' - || zfiles[1] == '\t')) - { - fcallback = TRUE; - ++zfiles; - } - - zset = NULL; - for (zfiles = strtok (zfiles, " \t"); - zfiles != NULL; - zfiles = strtok ((char *) NULL, " \t")) - uadd_string (&zset, zfiles, ' '); - - if (*ztok == '\0') - { - /* There is no user name. If this is the first entry - with no user name, then this line specifies the - directories which may be sent by local request - for login names which are not listed otherwise. */ - if (zother == NULL) - { - zother = zset; - fothercallback = fcallback; - } - } - else if (*zcomma == '\0') - { - int i; - - /* There is no system name. This entry specifies - permissions based on the login name. We must add - an alternate to each system specifying what to do - when this login name is used. */ - for (i = 0; i < *pc; i++) - { - struct ssysteminfo *q; - - if ((*ppas)[i].zcalled_login != NULL - && strcmp ((*ppas)[i].zcalled_login, "ANY") != 0) - continue; - - (*ppas)[i].zcalled_login = "ANY"; - - q = ((struct ssysteminfo *) - xmalloc (sizeof (struct ssysteminfo))); - *q = (*ppas)[i]; - q->qalternate = (*ppas)[i].qalternate; - (*ppas)[i].qalternate = q; - - q->zcalled_login = xstrdup (ztok); - q->fcallback = fcallback; - q->zremote_send = q->zremote_receive = zset; - } - } - else - { - int i; - struct ssysteminfo *q; - - /* Both the login name and the machine name were - listed; require the machine to be logged in under - this name. This is not fully backward compatible, - and perhaps should be changed. On the other hand, - it is more useful. */ - - for (i = 0; i < *pc; i++) - if (strcmp ((*ppas)->zname, zcomma) == 0) - break; - if (i >= *pc) - { - /* We don't warn about systems which don't already - exist, since they may appear in sample - USERFILES. */ - xfree ((pointer) zline); - continue; - } - - affound[i] = TRUE; - - for (q = &(*ppas)[i]; q != NULL; q = q->qalternate) - { - q->zcalled_login = xstrdup (ztok); - q->zlocal_send = q->zlocal_receive = zset; - q->zremote_send = q->zremote_receive = zset; - q->fcallback = fcallback; - } - } - - xfree ((pointer) zline); - } - - (void) fclose (e); - - if (zother != NULL) - { - int i; - - for (i = 0; i < *pc; i++) - { - struct ssysteminfo *q; - - if (affound[i]) - continue; - q = &(*ppas)[i]; - if (q->zcalled_login != NULL - && strcmp (q->zcalled_login, "ANY") != 0) - continue; - q->zlocal_send = q->zlocal_receive = zother; - q->fcallback = fothercallback; - } - } - } - } - - /* Now we must read L.cmds to determine which commands may be - executed. */ - - { - char abcmds[sizeof OLDCONFIGLIB + sizeof V2_CMDS - 1]; - - sprintf (abcmds, "%s%s", OLDCONFIGLIB, V2_CMDS); - e = fopen (abcmds, "r"); - if (e == NULL) - ulog (LOG_ERROR, "fopen (%s): %s", abcmds, strerror (errno)); - else - { - char *zcmds; - int i; - struct ssysteminfo *q; - - zline = zfgets (e, FALSE); - zline[strcspn (zline, "#\n")] = '\0'; - if (strncmp (zline, "PATH=", sizeof "PATH=" - 1) == 0) - { - char *z; - - zline += sizeof "PATH=" - 1; - while ((z = strchr (zline, ':')) != NULL) - *z = ' '; - for (i = 0; i < *pc; i++) - for (q = &(*ppas)[i]; q != NULL; q = q->qalternate) - q->zpath = zline; - - zline = zfgets (e, FALSE); - } - - zcmds = NULL; - while (zline != NULL) - { - zline[strcspn (zline, "#\n")] = '\0'; - uadd_string (&zcmds, zline, ' '); - xfree ((pointer) zline); - zline = zfgets (e, FALSE); - } - - (void) fclose (e); - - for (i = 0; i < *pc; i++) - for (q = &(*ppas)[i]; q != NULL; q = q->qalternate) - q->zcmds = zcmds; - } - } -} - -/* Find a port with a given name and speed in the file L-devices and - lock it. If found and locked, fill in the structure pointed at by - qport. Set *pffound to TRUE if a port was found but could not be - locked. */ - -boolean -fv2_find_port (zname, ibaud, ihighbaud, qport, pflock, pffound) - const char *zname; - long ibaud; - long ihighbaud; - struct sport *qport; - boolean (*pflock) P((struct sport *, boolean fin)); - boolean *pffound; -{ - char ab[sizeof OLDCONFIGLIB + sizeof V2_DEVICES - 1]; - FILE *e; - char *zline; - - sprintf (ab, "%s%s", OLDCONFIGLIB, V2_DEVICES); - e = fopen (ab, "r"); - if (e == NULL) - { - ulog (LOG_ERROR, "fopen (%s): %s", ab, strerror (errno)); - return FALSE; - } - - while ((zline = zfgets (e, FALSE)) != NULL) - { - char *ztok, *zdevice, *zdial_device; - long ilow, ihigh; - - zline[strcspn (zline, "#\n")] = '\0'; - - /* An entry in L-devices is type device dial-device baud. */ - ztok = strtok (zline, " \t"); - if (ztok == NULL) - { - xfree ((pointer) zline); - continue; - } - - if (zname != NULL - && strcmp (zname, ztok) != 0) - { - xfree ((pointer) zline); - continue; - } - qport->zname = ztok; - - zdevice = strtok ((char *) NULL, " \t"); - if (zdevice == NULL) - { - xfree ((pointer) zline); - continue; - } - - zdial_device = strtok ((char *) NULL, " \t"); - if (zdial_device == NULL) - { - xfree ((pointer) zline); - continue; - } - if (strcmp (zdial_device, "-") == 0) - zdial_device = NULL; - - ztok = strtok ((char *) NULL, " \t"); - if (ztok == NULL) - { - xfree ((pointer) zline); - continue; - } - ilow = strtol (ztok, &ztok, 10); - if (ilow == 0) - ihigh = 38400L; - else - { - if (*ztok == '-') - ihigh = atol (ztok + 1); - else - ihigh = ilow; - } - - if (ibaud != 0 - && (ihighbaud < ilow || ibaud > ihigh)) - { - xfree ((pointer) zline); - continue; - } - - /* We have found a matching port. We now fill in the sport - structure so that we can try to lock it. */ - qport->zprotocols = NULL; - qport->cproto_params = 0; - qport->qproto_params = NULL; - qport->ireliable = 0; - qport->zlockname = NULL; - if (strcmp (qport->zname, "DIR") == 0) - { - qport->ttype = PORTTYPE_DIRECT; - qport->u.sdirect.zdevice = zdevice; - qport->u.sdirect.ibaud = ilow; -#ifdef SYSDEP_DIRECT_INIT - SYSDEP_DIRECT_INIT (&qport->u.sdirect.s); -#endif - } - else - { - qport->ttype = PORTTYPE_MODEM; - qport->u.smodem.zdevice = zdevice; - qport->u.smodem.zdial_device = zdial_device; - if (ilow != ihigh) - qport->u.smodem.ibaud = 0; - else - qport->u.smodem.ibaud = ilow; - qport->u.smodem.ilowbaud = ilow; - qport->u.smodem.ihighbaud = ihigh; - qport->u.smodem.fcarrier = TRUE; - qport->u.smodem.zdialer = strtok ((char *) NULL, ""); - qport->u.smodem.zdialer += strspn (qport->u.smodem.zdialer, - " \t"); - qport->u.smodem.qdialer = NULL; -#ifdef SYSDEP_MODEM_INIT - SYSDEP_MODEM_INIT (&qport->u.smodem.s); -#endif - } - - if (pffound != NULL) - *pffound = TRUE; - - if (pflock != NULL - && ! (*pflock) (qport, FALSE)) - { - xfree ((pointer) zline); - continue; - } - - (void) fclose (e); - - return TRUE; - } - - (void) fclose (e); - - return FALSE; -} - -#endif /* HAVE_V2_CONFIG */ diff --git a/gnu/libexec/uucp/version.c b/gnu/libexec/uucp/version.c deleted file mode 100644 index a907891c62fa..000000000000 --- a/gnu/libexec/uucp/version.c +++ /dev/null @@ -1,55 +0,0 @@ -/* version.c - The version number string. - - Copyright (C) 1991, 1992 Ian Lance Taylor - - This file is part of the Taylor UUCP package. - - 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. - - The author of the program may be contacted at ian@airs.com or - c/o AIRS, P.O. Box 520, Waltham, MA 02254. - - $Log: version.c,v $ - Revision 1.1.1.1 1993/03/21 09:45:37 cgd - initial import of 386bsd-0.1 sources - - Revision 1.6 1992/04/07 05:30:43 ian - Changed version to 1.03 - - Revision 1.5 1992/03/16 19:10:33 ian - Changed version to beta 1.03 - - Revision 1.4 1992/02/08 03:54:18 ian - Include only in , added 1992 copyright - - Revision 1.3 1992/01/20 23:53:25 ian - Changed version to 1.02 - - Revision 1.2 1992/01/05 03:09:44 ian - Changed abVersion to non const; changed version to beta 1.02 - - Revision 1.1 1991/11/21 22:17:06 ian - Initial revision - - */ - -#include "uucp.h" - -#if USE_RCS_ID -char version_rcsid[] = "$Id: version.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -char abVersion[] = "1.03"; diff --git a/gnu/usr.bin/awk/bi_funct.c b/gnu/usr.bin/awk/bi_funct.c deleted file mode 100644 index 6d8c23715eb7..000000000000 --- a/gnu/usr.bin/awk/bi_funct.c +++ /dev/null @@ -1,892 +0,0 @@ - -/******************************************** -bi_funct.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: bi_funct.c,v $ -/* Revision 1.2 1993/07/02 23:57:02 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.3.1.2 1993/01/27 01:04:06 mike - * minor tuning to str_str() - * - * Revision 5.3.1.1 1993/01/15 03:33:35 mike - * patch3: safer double to int conversion - * - * Revision 5.3 1992/12/17 02:48:01 mike - * 1.1.2d changes for DOS - * - * Revision 5.2 1992/07/08 15:43:41 brennan - * patch2: length returns. I am a wimp - * - * Revision 5.1 1991/12/05 07:55:35 brennan - * 1.1 pre-release - * -*/ - - -#include "mawk.h" -#include "bi_funct.h" -#include "bi_vars.h" -#include "memory.h" -#include "init.h" -#include "files.h" -#include "fin.h" -#include "field.h" -#include "regexp.h" -#include "repl.h" -#include - - -/* statics */ -static STRING *PROTO(gsub, (PTR, CELL *, char *, int) ) ; -static void PROTO( fplib_err, (char *, double, char *) ) ; - - -/* global for the disassembler */ -BI_REC bi_funct[] = { /* info to load builtins */ - -"length" , bi_length, 0, 1, /* special must come first */ -"index" , bi_index , 2, 2 , -"substr" , bi_substr, 2, 3, -"sprintf" , bi_sprintf, 1, 255, -"sin", bi_sin , 1, 1 , -"cos", bi_cos , 1, 1 , -"atan2", bi_atan2, 2,2, -"exp", bi_exp, 1, 1, -"log", bi_log , 1, 1 , -"int", bi_int, 1, 1, -"sqrt", bi_sqrt, 1, 1, -"rand" , bi_rand, 0, 0, -"srand", bi_srand, 0, 1, -"close", bi_close, 1, 1, -"system", bi_system, 1, 1, -"toupper", bi_toupper, 1, 1, -"tolower", bi_tolower, 1, 1, - -(char *) 0, (PF_CP) 0, 0, 0 } ; - - -/* load built-in functions in symbol table */ -void bi_funct_init() -{ register BI_REC *p ; - register SYMTAB *stp ; - - /* length is special (posix bozo) */ - stp = insert(bi_funct->name) ; - stp->type = ST_LENGTH ; - stp->stval.bip = bi_funct ; - - for( p = bi_funct + 1 ; p->name ; p++ ) - { stp = insert( p->name ) ; - stp->type = ST_BUILTIN ; - stp->stval.bip = p ; - } - - /* seed rand() off the clock */ - { CELL c ; - - c.type = 0 ; (void) bi_srand(&c) ; - } - -} - -/************************************************** - string builtins (except split (in split.c) and [g]sub (at end)) - **************************************************/ - -CELL *bi_length(sp) - register CELL *sp ; -{ unsigned len ; - - if ( sp->type == 0 ) cellcpy(sp, field) ; - else sp-- ; - - if ( sp->type < C_STRING ) cast1_to_s(sp) ; - len = string(sp)->len ; - - free_STRING( string(sp) ) ; - sp->type = C_DOUBLE ; - sp->dval = (double) len ; - - return sp ; -} - -char *str_str(target, key , key_len) - register char *target; - char *key ; - unsigned key_len ; -{ - register int k = key[0] ; - - switch( key_len ) - { - case 0 : return (char *) 0 ; - case 1 : return strchr( target, k) ; - case 2 : - { int k1 = key[1] ; - while ( target = strchr(target, k) ) - if ( target[1] == k1 ) return target ; - else target++ ; - /*failed*/ - return (char *) 0 ; - } - } - - key_len-- ; - while ( target = strchr(target, k) ) - { - if ( memcmp(target+1, key+1, SIZE_T(key_len)) == 0 ) - return target ; - else target++ ; - } - /*failed*/ - return (char *) 0 ; -} - - - -CELL *bi_index(sp) - register CELL *sp ; -{ register int idx ; - unsigned len ; - char *p ; - - sp-- ; - if ( TEST2(sp) != TWO_STRINGS ) - cast2_to_s(sp) ; - - if ( len = string(sp+1)->len ) - idx = (p = str_str(string(sp)->str,string(sp+1)->str,len)) - ? p - string(sp)->str + 1 : 0 ; - - else /* index of the empty string */ - idx = 1 ; - - free_STRING( string(sp) ) ; - free_STRING( string(sp+1) ) ; - sp->type = C_DOUBLE ; - sp->dval = (double) idx ; - return sp ; -} - -/* substr(s, i, n) - if l = length(s) - then get the characters - from max(1,i) to min(l,n-i-1) inclusive */ - -CELL *bi_substr(sp) - CELL *sp ; -{ int n_args, len ; - register int i, n ; - STRING *sval ; /* substr(sval->str, i, n) */ - - n_args = sp->type ; - sp -= n_args ; - if ( sp->type != C_STRING ) cast1_to_s(sp) ; - /* don't use < C_STRING shortcut */ - sval = string(sp) ; - - if ( (len = sval->len) == 0 ) /* substr on null string */ - { if ( n_args == 3 ) cell_destroy(sp+2) ; - cell_destroy(sp+1) ; - return sp ; - } - - if ( n_args == 2 ) - { n = MAX__INT ; - if ( sp[1].type != C_DOUBLE ) cast1_to_d(sp+1) ; - } - else - { if ( TEST2(sp+1) != TWO_DOUBLES ) cast2_to_d(sp+1) ; - n = d_to_i(sp[2].dval) ; - } - i = d_to_i(sp[1].dval) - 1 ; /* i now indexes into string */ - - if ( i < 0 ) { n += i ; i = 0 ; } - if ( n > len - i ) n = len - i ; - - if ( n <= 0 ) /* the null string */ - { - sp->ptr = (PTR) &null_str ; - null_str.ref_cnt++ ; - } - else /* got something */ - { - sp->ptr = (PTR) new_STRING((char *)0, n) ; - (void) memcpy(string(sp)->str, sval->str + i, SIZE_T(n)) ; - } - - free_STRING(sval) ; - return sp ; -} - -/* - match(s,r) - sp[0] holds r, sp[-1] holds s -*/ - -CELL *bi_match(sp) - register CELL *sp ; -{ - char *p ; - unsigned length ; - - if ( sp->type != C_RE ) cast_to_RE(sp) ; - if ( (--sp)->type < C_STRING ) cast1_to_s(sp) ; - - cell_destroy(RSTART) ; - cell_destroy(RLENGTH) ; - RSTART->type = C_DOUBLE ; - RLENGTH->type = C_DOUBLE ; - - p = REmatch(string(sp)->str, (sp+1)->ptr, &length) ; - - if ( p ) - { sp->dval = (double) ( p - string(sp)->str + 1 ) ; - RLENGTH->dval = (double) length ; - } - else - { sp->dval = 0.0 ; - RLENGTH->dval = -1.0 ; /* posix */ - } - - free_STRING(string(sp)) ; - sp->type = C_DOUBLE ; - - RSTART->dval = sp->dval ; - - return sp ; -} - -CELL *bi_toupper(sp) - CELL *sp ; -{ STRING *old ; - register char *p, *q ; - - if ( sp->type != C_STRING ) cast1_to_s(sp) ; - old = string(sp) ; - sp->ptr = (PTR) new_STRING((char *) 0, old->len) ; - - q = string(sp)->str ; p = old->str ; - - while ( *p ) - { - *q = *p++ ; - if ( *q >= 'a' && *q <= 'z' ) *q += 'A' - 'a' ; - q++ ; - } - free_STRING(old) ; - return sp ; -} - -CELL *bi_tolower(sp) - CELL *sp ; -{ STRING *old ; - register char *p, *q ; - - if ( sp->type != C_STRING ) cast1_to_s(sp) ; - old = string(sp) ; - sp->ptr = (PTR) new_STRING((char *) 0, old->len) ; - - q = string(sp)->str ; p = old->str ; - - while ( *p ) - { - *q = *p++ ; - if ( *q >= 'A' && *q <= 'Z' ) *q += 'a' - 'A' ; - q++ ; - } - free_STRING(old) ; - return sp ; -} - - -/************************************************ - arithemetic builtins - ************************************************/ - -static void fplib_err( fname, val, error) - char *fname ; - double val ; - char *error ; -{ - rt_error("%s(%g) : %s" , fname, val, error) ; -} - - -CELL *bi_sin(sp) - register CELL *sp ; -{ -#if ! STDC_MATHERR - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - sp->dval = sin( sp->dval ) ; - return sp ; -#else - double x ; - - errno = 0 ; - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - x = sp->dval ; - sp->dval = sin( sp->dval ) ; - if ( errno ) fplib_err("sin", x, "loss of precision") ; - return sp ; -#endif -} - -CELL *bi_cos(sp) - register CELL *sp ; -{ -#if ! STDC_MATHERR - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - sp->dval = cos( sp->dval ) ; - return sp ; -#else - double x ; - - errno = 0 ; - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - x = sp->dval ; - sp->dval = cos( sp->dval ) ; - if ( errno ) fplib_err("cos", x, "loss of precision") ; - return sp ; -#endif -} - -CELL *bi_atan2(sp) - register CELL *sp ; -{ -#if ! STDC_MATHERR - sp-- ; - if ( TEST2(sp) != TWO_DOUBLES ) cast2_to_d(sp) ; - sp->dval = atan2(sp->dval, (sp+1)->dval) ; - return sp ; -#else - - errno = 0 ; - sp-- ; - if ( TEST2(sp) != TWO_DOUBLES ) cast2_to_d(sp) ; - sp->dval = atan2(sp->dval, (sp+1)->dval) ; - if ( errno ) rt_error("atan2(0,0) : domain error") ; - return sp ; -#endif -} - -CELL *bi_log(sp) - register CELL *sp ; -{ -#if ! STDC_MATHERR - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - sp->dval = log( sp->dval ) ; - return sp ; -#else - double x ; - - errno = 0 ; - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - x = sp->dval ; - sp->dval = log( sp->dval ) ; - if ( errno ) fplib_err("log", x, "domain error") ; - return sp ; -#endif -} - -CELL *bi_exp(sp) - register CELL *sp ; -{ -#if ! STDC_MATHERR - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - sp->dval = exp(sp->dval) ; - return sp ; -#else - double x ; - - errno = 0 ; - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - x = sp->dval ; - sp->dval = exp(sp->dval) ; - if ( errno && sp->dval) fplib_err("exp", x, "overflow") ; - /* on underflow sp->dval==0, ignore */ - return sp ; -#endif -} - -CELL *bi_int(sp) - register CELL *sp ; -{ if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - sp->dval = sp->dval >= 0.0 ? floor( sp->dval ) : ceil(sp->dval) ; - return sp ; -} - -CELL *bi_sqrt(sp) - register CELL *sp ; -{ -#if ! STDC_MATHERR - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - sp->dval = sqrt( sp->dval ) ; - return sp ; -#else - double x ; - - errno = 0 ; - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - x = sp->dval ; - sp->dval = sqrt( sp->dval ) ; - if ( errno ) fplib_err("sqrt", x, "domain error") ; - return sp ; -#endif -} - -#ifdef HAVE_TIME_H -#include -#else -#include -#endif - - -/* For portability, we'll use our own random number generator , taken - from: Park, SK and Miller KW, "Random Number Generators: - Good Ones are Hard to Find", CACM, 31, 1192-1201, 1988. -*/ - -static long seed ; /* must be >=1 and <= 2^31-1 */ -static CELL cseed ; /* argument of last call to srand() */ - -#define M 0x7fffffff /* 2^31-1 */ - -CELL *bi_srand(sp) - register CELL *sp ; -{ CELL c ; - - if ( sp->type == 0 ) /* seed off clock */ - { (void) cellcpy(sp, &cseed) ; - cell_destroy(&cseed) ; - cseed.type = C_DOUBLE ; - cseed.dval = (double) time((time_t*) 0) ; - } - else /* user seed */ - { sp-- ; - /* swap cseed and *sp ; don't need to adjust ref_cnts */ - c = *sp ; *sp = cseed ; cseed = c ; - } - - /* The old seed is now in *sp ; move the value in cseed to - seed in range 1 to M */ - - (void) cellcpy(&c, &cseed) ; - if ( c.type == C_NOINIT ) cast1_to_d(&c) ; - - seed = c.type == C_DOUBLE ? (d_to_i(c.dval) & M) % M + 1 : - hash(string(&c)->str) % M + 1 ; - - cell_destroy(&c) ; - - /* crank it once so close seeds don't give a close - first result */ -#define A 16807 -#define Q 127773 /* M/A */ -#define R 2836 /* M%A */ - seed = A * (seed%Q) - R * (seed/Q) ; - if ( seed <= 0 ) seed += M ; - - return sp ; -} - -CELL *bi_rand(sp) - register CELL *sp ; -{ - register long test ; - - test = A * (seed%Q) - R * (seed/Q) ; - if ( test <= 0 ) test += M ; - - (++sp)->type = C_DOUBLE ; - sp->dval = (double)( seed = test ) / (double) M ; - return sp ; - -#undef A -#undef M -#undef Q -#undef R -} - -/************************************************* - miscellaneous builtins - close, system and getline - *************************************************/ - -CELL *bi_close(sp) - register CELL *sp ; -{ int x ; - - if ( sp->type < C_STRING ) cast1_to_s(sp) ; - x = file_close( (STRING *) sp->ptr) ; - free_STRING( string(sp) ) ; - sp->type = C_DOUBLE ; - sp->dval = (double) x ; - return sp ; -} - -#if HAVE_REAL_PIPES - -CELL *bi_system(sp) - CELL *sp ; -{ int pid ; - unsigned ret_val ; - - if ( sp->type < C_STRING ) cast1_to_s(sp) ; - - fflush(stdout) ; fflush(stderr) ; - - switch( pid = fork() ) - { case -1 : /* fork failed */ - - errmsg(errno, "could not create a new process") ; - ret_val = 127 ; - break ; - - case 0 : /* the child */ - (void) execl(shell, shell, "-c", string(sp)->str, (char *) 0) ; - /* if get here, execl() failed */ - errmsg(errno, "execute of %s failed", shell) ; - fflush(stderr) ; - _exit(127) ; - - default : /* wait for the child */ - ret_val = wait_for(pid) ; - break ; - } - - cell_destroy(sp) ; - sp->type = C_DOUBLE ; - sp->dval = (double) ret_val ; - return sp ; -} - -#endif /* HAVE_REAL_PIPES */ - -#ifdef THINK_C - -CELL *bi_system( sp ) - register CELL *sp ; -{ rt_error("no system call for the Macintosh Toy Operating System!!!") ; - return sp ; -} - -#endif - - -#if MSDOS - - -CELL *bi_system( sp ) - register CELL *sp ; -{ int retval ; - - if ( sp->type < C_STRING ) cast1_to_s(sp) ; - retval = DOSexec(string(sp)->str) ; - free_STRING(string(sp)) ; - sp->type = C_DOUBLE ; - sp->dval = (double) retval ; - return sp ; -} - -#endif - - -/* getline() */ - -/* if type == 0 : stack is 0 , target address - - if type == F_IN : stack is F_IN, expr(filename), target address - - if type == PIPE_IN : stack is PIPE_IN, target address, expr(pipename) -*/ - -CELL *bi_getline(sp) - register CELL *sp ; -{ - CELL tc , *cp ; - char *p ; - unsigned len ; - FIN *fin_p ; - - - switch( sp->type ) - { - case 0 : - sp-- ; - if ( ! main_fin ) open_main() ; - - if ( ! (p = FINgets(main_fin, &len)) ) - goto eof ; - - cp = (CELL *) sp->ptr ; - if ( TEST2(NR) != TWO_DOUBLES ) cast2_to_d(NR) ; - NR->dval += 1.0 ; - FNR->dval += 1.0 ; - break ; - - case F_IN : - sp-- ; - if ( sp->type < C_STRING ) cast1_to_s(sp) ; - fin_p = (FIN *) file_find(sp->ptr, F_IN) ; - free_STRING(string(sp) ) ; - sp-- ; - - if ( ! fin_p ) goto open_failure ; - if ( ! (p = FINgets(fin_p, &len)) ) - { - FINsemi_close(fin_p) ; - goto eof ; - } - cp = (CELL *) sp->ptr ; - break ; - - case PIPE_IN : - sp -= 2 ; - if ( sp->type < C_STRING ) cast1_to_s(sp) ; - fin_p = (FIN *) file_find(sp->ptr, PIPE_IN) ; - free_STRING(string(sp)) ; - - if ( ! fin_p ) goto open_failure ; - if ( ! (p = FINgets(fin_p, &len)) ) - { - FINsemi_close(fin_p) ; -#if HAVE_REAL_PIPES - /* reclaim process slot */ - (void) wait_for(0) ; -#endif - goto eof ; - } - cp = (CELL *) (sp+1)->ptr ; - break ; - - default : bozo("type in bi_getline") ; - - } - - /* we've read a line , store it */ - - if ( len == 0 ) - { tc.type = C_STRING ; - tc.ptr = (PTR) &null_str ; - null_str.ref_cnt++ ; - } - else - { tc.type = C_MBSTRN ; - tc.ptr = (PTR) new_STRING((char *) 0, len) ; - (void) memcpy( string(&tc)->str, p, SIZE_T(len)) ; - } - - slow_cell_assign(cp, &tc) ; - - cell_destroy(&tc) ; - - sp->dval = 1.0 ; goto done ; - -open_failure : - sp->dval = -1.0 ; goto done ; - -eof : - sp->dval = 0.0 ; /* fall thru to done */ - -done : - sp->type = C_DOUBLE ; - return sp ; -} - -/********************************************** - sub() and gsub() - **********************************************/ - -/* entry: sp[0] = address of CELL to sub on - sp[-1] = substitution CELL - sp[-2] = regular expression to match -*/ - -CELL *bi_sub( sp ) - register CELL *sp ; -{ CELL *cp ; /* pointer to the replacement target */ - CELL tc ; /* build the new string here */ - CELL sc ; /* copy of the target CELL */ - char *front, *middle, *back ; /* pieces */ - unsigned front_len, middle_len, back_len ; - - sp -= 2 ; - if ( sp->type != C_RE ) cast_to_RE(sp) ; - if ( sp[1].type != C_REPL && sp[1].type != C_REPLV ) - cast_to_REPL(sp+1) ; - cp = (CELL *) (sp+2)->ptr ; - /* make a copy of the target, because we won't change anything - including type unless the match works */ - (void) cellcpy(&sc, cp) ; - if ( sc.type < C_STRING ) cast1_to_s(&sc) ; - front = string(&sc)->str ; - - if ( middle = REmatch(front, sp->ptr, &middle_len) ) - { - front_len = middle - front ; - back = middle + middle_len ; - back_len = string(&sc)->len - front_len - middle_len ; - - if ( (sp+1)->type == C_REPLV ) - { STRING *sval = new_STRING((char *) 0, middle_len) ; - - (void) memcpy(sval->str, middle, SIZE_T(middle_len)) ; - (void) replv_to_repl(sp+1, sval) ; - free_STRING(sval) ; - } - - tc.type = C_STRING ; - tc.ptr = (PTR) new_STRING((char *) 0, - front_len + string(sp+1)->len + back_len ) ; - - { char *p = string(&tc)->str ; - - if ( front_len ) - { (void) memcpy(p, front, SIZE_T(front_len)) ; - p += front_len ; - } - if ( string(sp+1)->len ) - { (void) memcpy(p, string(sp+1)->str, SIZE_T(string(sp+1)->len)) ; - p += string(sp+1)->len ; - } - if ( back_len ) (void) memcpy(p, back, SIZE_T(back_len)) ; - } - - slow_cell_assign(cp, &tc) ; - - free_STRING(string(&tc)) ; - } - - free_STRING(string(&sc)) ; - repl_destroy(sp+1) ; - sp->type = C_DOUBLE ; - sp->dval = middle != (char *) 0 ? 1.0 : 0.0 ; - return sp ; -} - -static unsigned repl_cnt ; /* number of global replacements */ - -/* recursive global subsitution - dealing with empty matches makes this mildly painful -*/ - -static STRING *gsub( re, repl, target, flag) - PTR re ; - CELL *repl ; /* always of type REPL or REPLV, - destroyed by caller */ - char *target ; - int flag ; /* if on, match of empty string at front is OK */ -{ char *front, *middle ; - STRING *back ; - unsigned front_len, middle_len ; - STRING *ret_val ; - CELL xrepl ; /* a copy of repl so we can change repl */ - - if ( ! (middle = REmatch(target, re, &middle_len)) ) - return new_STRING(target) ; /* no match */ - - (void) cellcpy(&xrepl, repl) ; - - if ( !flag && middle_len == 0 && middle == target ) - { /* match at front that's not allowed */ - - if ( *target == 0 ) /* target is empty string */ - { repl_destroy(&xrepl) ; - null_str.ref_cnt++ ; - return & null_str ; - } - else - { char xbuff[2] ; - - front_len = 0 ; - /* make new repl with target[0] */ - repl_destroy(repl) ; - xbuff[0] = *target++ ; xbuff[1] = 0 ; - repl->type = C_REPL ; - repl->ptr = (PTR) new_STRING( xbuff ) ; - back = gsub(re, &xrepl, target, 1) ; - } - } - else /* a match that counts */ - { repl_cnt++ ; - - front = target ; - front_len = middle - target ; - - if ( *middle == 0 ) /* matched back of target */ - { back = &null_str ; null_str.ref_cnt++ ; } - else back = gsub(re, &xrepl, middle + middle_len, 0) ; - - /* patch the &'s if needed */ - if ( repl->type == C_REPLV ) - { STRING *sval = new_STRING((char *) 0, middle_len) ; - - (void) memcpy(sval->str, middle, SIZE_T(middle_len)) ; - (void) replv_to_repl(repl, sval) ; - free_STRING(sval) ; - } - } - - /* put the three pieces together */ - ret_val = new_STRING((char *)0, - front_len + string(repl)->len + back->len); - { char *p = ret_val->str ; - - if ( front_len ) - { (void) memcpy(p, front, SIZE_T(front_len)) ; p += front_len ; } - if ( string(repl)->len ) - { (void) memcpy(p, string(repl)->str, SIZE_T(string(repl)->len)) ; - p += string(repl)->len ; - } - if ( back->len ) (void) memcpy(p, back->str, SIZE_T(back->len)) ; - } - - /* cleanup, repl is freed by the caller */ - repl_destroy(&xrepl) ; - free_STRING(back) ; - - return ret_val ; -} - -/* set up for call to gsub() */ -CELL *bi_gsub( sp ) - register CELL *sp ; -{ CELL *cp ; /* pts at the replacement target */ - CELL sc ; /* copy of replacement target */ - CELL tc ; /* build the result here */ - - sp -= 2 ; - if ( sp->type != C_RE ) cast_to_RE(sp) ; - if ( (sp+1)->type != C_REPL && (sp+1)->type != C_REPLV ) - cast_to_REPL(sp+1) ; - - (void) cellcpy(&sc, cp = (CELL *)(sp+2)->ptr) ; - if ( sc.type < C_STRING ) cast1_to_s(&sc) ; - - repl_cnt = 0 ; - tc.ptr = (PTR) gsub(sp->ptr, sp+1, string(&sc)->str, 1) ; - - if ( repl_cnt ) - { - tc.type = C_STRING ; - slow_cell_assign(cp, &tc) ; - } - - /* cleanup */ - free_STRING(string(&sc)) ; free_STRING(string(&tc)) ; - repl_destroy(sp+1) ; - - sp->type = C_DOUBLE ; - sp->dval = (double) repl_cnt ; - return sp ; -} diff --git a/gnu/usr.bin/awk/bi_funct.h b/gnu/usr.bin/awk/bi_funct.h deleted file mode 100644 index ef6bfd1ca53e..000000000000 --- a/gnu/usr.bin/awk/bi_funct.h +++ /dev/null @@ -1,63 +0,0 @@ - -/******************************************** -bi_funct.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: bi_funct.h,v $ -/* Revision 1.2 1993/07/02 23:57:03 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:59:03 brennan - * 1.1 pre-release - * -*/ - -#ifndef BI_FUNCT_H -#define BI_FUNCT_H 1 - -#include "symtype.h" - -extern BI_REC bi_funct[] ; - -void PROTO(bi_init, (void) ) ; - -/* builtin string functions */ -CELL *PROTO( bi_print, (CELL *) ) ; -CELL *PROTO( bi_printf, (CELL *) ) ; -CELL *PROTO( bi_length, (CELL *) ) ; -CELL *PROTO( bi_index, (CELL *) ) ; -CELL *PROTO( bi_substr, (CELL *) ) ; -CELL *PROTO( bi_sprintf, (CELL *) ) ; -CELL *PROTO( bi_split, (CELL *) ) ; -CELL *PROTO( bi_match, (CELL *) ) ; -CELL *PROTO( bi_getline, (CELL *) ) ; -CELL *PROTO( bi_sub, (CELL *) ) ; -CELL *PROTO( bi_gsub, (CELL *) ) ; -CELL *PROTO( bi_toupper, (CELL*) ) ; -CELL *PROTO( bi_tolower, (CELL*) ) ; - -/* builtin arith functions */ -CELL *PROTO( bi_sin, (CELL *) ) ; -CELL *PROTO( bi_cos, (CELL *) ) ; -CELL *PROTO( bi_atan2, (CELL *) ) ; -CELL *PROTO( bi_log, (CELL *) ) ; -CELL *PROTO( bi_exp, (CELL *) ) ; -CELL *PROTO( bi_int, (CELL *) ) ; -CELL *PROTO( bi_sqrt, (CELL *) ) ; -CELL *PROTO( bi_srand, (CELL *) ) ; -CELL *PROTO( bi_rand, (CELL *) ) ; - -/* other builtins */ -CELL *PROTO( bi_close, (CELL *) ) ; -CELL *PROTO( bi_system, (CELL *) ) ; - -#endif /* BI_FUNCT_H */ - diff --git a/gnu/usr.bin/awk/bi_vars.c b/gnu/usr.bin/awk/bi_vars.c deleted file mode 100644 index cc5b302b15da..000000000000 --- a/gnu/usr.bin/awk/bi_vars.c +++ /dev/null @@ -1,92 +0,0 @@ - -/******************************************** -bi_vars.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: bi_vars.c,v $ -/* Revision 1.2 1993/07/02 23:57:04 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.2 1992/07/10 16:17:10 brennan - * MsDOS: remove NO_BINMODE macro - * - * Revision 5.1 1991/12/05 07:55:38 brennan - * 1.1 pre-release - * -*/ - - -/* bi_vars.c */ - -#include "mawk.h" -#include "symtype.h" -#include "bi_vars.h" -#include "field.h" -#include "init.h" -#include "memory.h" - -/* the builtin variables */ -CELL bi_vars[NUM_BI_VAR] ; - -/* the order here must match the order in bi_vars.h */ - -static char *bi_var_names[NUM_BI_VAR] = { -"NR" , -"FNR" , -"ARGC" , -"FILENAME" , -"OFS" , -"ORS" , -"RLENGTH" , -"RSTART" , -"SUBSEP" -#if MSDOS -, "BINMODE" -#endif -} ; - -/* insert the builtin vars in the hash table */ - -void bi_vars_init() -{ register int i ; - register SYMTAB *s ; - - - for ( i = 0 ; i < NUM_BI_VAR ; i++ ) - { s = insert( bi_var_names[i] ) ; - s->type = i <= 1 ? ST_NR : ST_VAR ; - s->stval.cp = bi_vars + i ; - /* bi_vars[i].type = 0 which is C_NOINIT */ - } - - s = insert("ENVIRON") ; - s->type = ST_ENV ; - - /* set defaults */ - - FILENAME->type = C_STRING ; - FILENAME->ptr = (PTR) new_STRING( "" ) ; - - OFS->type = C_STRING ; - OFS->ptr = (PTR) new_STRING( " " ) ; - - ORS->type = C_STRING ; - ORS->ptr = (PTR) new_STRING( "\n" ) ; - - SUBSEP->type = C_STRING ; - SUBSEP->ptr = (PTR) new_STRING( "\034" ) ; - - NR->type = FNR->type = C_DOUBLE ; - /* dval is already 0.0 */ - -#if MSDOS - BINMODE->type = C_DOUBLE ; -#endif -} diff --git a/gnu/usr.bin/awk/bi_vars.h b/gnu/usr.bin/awk/bi_vars.h deleted file mode 100644 index 5dc90fc72768..000000000000 --- a/gnu/usr.bin/awk/bi_vars.h +++ /dev/null @@ -1,59 +0,0 @@ - -/******************************************** -bi_vars.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: bi_vars.h,v $ -/* Revision 1.2 1993/07/02 23:57:05 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.2 1992/07/10 16:17:10 brennan - * MsDOS: remove NO_BINMODE macro - * - * Revision 5.1 1991/12/05 07:59:05 brennan - * 1.1 pre-release - * -*/ - - -/* bi_vars.h */ - -#ifndef BI_VARS_H -#define BI_VARS_H 1 - - -/* builtin variables NF, RS, FS, OFMT are stored - internally in field[], so side effects of assignment can - be handled -*/ - -/* NR and FNR must be next to each other */ -#define NR bi_vars -#define FNR (bi_vars+1) -#define ARGC (bi_vars+2) -#define FILENAME (bi_vars+3) -#define OFS (bi_vars+4) -#define ORS (bi_vars+5) -#define RLENGTH (bi_vars+6) -#define RSTART (bi_vars+7) -#define SUBSEP (bi_vars+8) - -#if MSDOS -#define BINMODE (bi_vars+9) -#define NUM_BI_VAR 10 -#else -#define NUM_BI_VAR 9 -#endif - -extern CELL bi_vars[NUM_BI_VAR] ; - - -#endif diff --git a/gnu/usr.bin/awk/cast.c b/gnu/usr.bin/awk/cast.c deleted file mode 100644 index 6f39e3c4c89e..000000000000 --- a/gnu/usr.bin/awk/cast.c +++ /dev/null @@ -1,452 +0,0 @@ - -/******************************************** -cast.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: cast.c,v $ -/* Revision 1.2 1993/07/02 23:57:06 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.3.1.5 1993/05/05 00:11:22 mike - * patch4: overflow in check_strnum() implies pure string - * - * Revision 5.3.1.4 1993/01/22 15:05:19 mike - * pow2->mpow2 for linux - * - * Revision 5.3.1.3 1993/01/22 14:18:33 mike - * const for strtod and ansi picky compilers - * - * Revision 5.3.1.2 1993/01/20 12:53:06 mike - * d_to_l() - * - * Revision 5.3.1.1 1993/01/15 03:33:37 mike - * patch3: safer double to int conversion - * - * Revision 5.3 1992/11/28 23:48:42 mike - * For internal conversion numeric->string, when testing - * if integer, use longs instead of ints so 16 and 32 bit - * systems behave the same - * - * Revision 5.2 1992/08/17 14:19:45 brennan - * patch2: After parsing, only bi_sprintf() uses string_buff. - * - * Revision 5.1 1991/12/05 07:55:41 brennan - * 1.1 pre-release - * -*/ - - -/* cast.c */ - -#include "mawk.h" -#include "field.h" -#include "memory.h" -#include "scan.h" -#include "repl.h" - -int mpow2[NUM_CELL_TYPES] = {1,2,4,8,16,32,64,128,256,512} ; - -void cast1_to_d( cp ) - register CELL *cp ; -{ - switch( cp->type ) - { case C_NOINIT : cp->dval = 0.0 ; break ; - - case C_DOUBLE : return ; - - case C_MBSTRN : - case C_STRING : - { register STRING *s = (STRING *) cp->ptr ; - -#if FPE_TRAPS_ON /* look for overflow error */ - errno = 0 ; - cp->dval = strtod(s->str,(char **)0) ; - if ( errno && cp->dval != 0.0 ) /* ignore underflow */ - rt_error("overflow converting %s to double", s) ; -#else - cp->dval = strtod(s->str,(char **)0) ; -#endif - free_STRING(s) ; - } - break ; - - case C_STRNUM : - /* don't need to convert, but do need to free the STRING part */ - free_STRING( string(cp) ) ; - break ; - - - default : - bozo("cast on bad type") ; - } - cp->type = C_DOUBLE ; -} - -void cast2_to_d( cp ) - register CELL *cp ; -{ register STRING *s ; - - switch( cp->type ) - { case C_NOINIT : cp->dval = 0.0 ; break ; - - case C_DOUBLE : goto two ; - case C_STRNUM : - free_STRING( string(cp) ) ; - break ; - - case C_MBSTRN : - case C_STRING : - s = (STRING *) cp->ptr ; - -#if FPE_TRAPS_ON /* look for overflow error */ - errno = 0 ; - cp->dval = strtod(s->str,(char **)0) ; - if ( errno && cp->dval != 0.0 ) /* ignore underflow */ - rt_error("overflow converting %s to double", s) ; -#else - cp->dval = strtod(s->str,(char **)0) ; -#endif - free_STRING(s) ; - break ; - - default : - bozo("cast on bad type") ; - } - cp->type = C_DOUBLE ; - -two: cp++ ; - switch( cp->type ) - { case C_NOINIT : cp->dval = 0.0 ; break ; - - case C_DOUBLE : return ; - case C_STRNUM : - free_STRING( string(cp) ) ; - break ; - - case C_MBSTRN : - case C_STRING : - s = (STRING *) cp->ptr ; - -#if FPE_TRAPS_ON /* look for overflow error */ - errno = 0 ; - cp->dval = strtod(s->str,(char **)0) ; - if ( errno && cp->dval != 0.0 ) /* ignore underflow */ - rt_error("overflow converting %s to double", s) ; -#else - cp->dval = strtod(s->str,(char **)0) ; -#endif - free_STRING(s) ; - break ; - - default : - bozo("cast on bad type") ; - } - cp->type = C_DOUBLE ; -} - -void cast1_to_s( cp ) - register CELL *cp ; -{ - register long lval ; - char xbuff[260] ; - - switch( cp->type ) - { case C_NOINIT : - null_str.ref_cnt++ ; - cp->ptr = (PTR) &null_str ; - break ; - - case C_DOUBLE : - - lval = d_to_l(cp->dval) ; - if ( lval == cp->dval ) - (void) sprintf(xbuff, INT_FMT, lval) ; - else - (void) sprintf(xbuff , string(CONVFMT)->str, cp->dval) ; - - cp->ptr = (PTR) new_STRING(xbuff) ; - break ; - - case C_STRING : return ; - - case C_MBSTRN : - case C_STRNUM : break ; - - default : bozo("bad type on cast") ; - } - cp->type = C_STRING ; -} - -void cast2_to_s( cp ) - register CELL *cp ; -{ - register long lval ; - char xbuff[260] ; - - switch( cp->type ) - { case C_NOINIT : - null_str.ref_cnt++ ; - cp->ptr = (PTR) &null_str ; - break ; - - case C_DOUBLE : - - lval = d_to_l(cp->dval) ; - if ( lval == cp->dval ) - (void) sprintf(xbuff, INT_FMT, lval) ; - else - (void) sprintf(xbuff , string(CONVFMT)->str, cp->dval) ; - - cp->ptr = (PTR) new_STRING(xbuff) ; - break ; - - case C_STRING : goto two ; - - case C_MBSTRN : - case C_STRNUM : break ; - - default : bozo("bad type on cast") ; - } - cp->type = C_STRING ; - -two: - cp++ ; - - switch( cp->type ) - { case C_NOINIT : - null_str.ref_cnt++ ; - cp->ptr = (PTR) &null_str ; - break ; - - case C_DOUBLE : - - lval = d_to_l(cp->dval) ; - if ( lval == cp->dval ) - (void) sprintf(xbuff, INT_FMT, lval) ; - else - (void) sprintf(xbuff , string(CONVFMT)->str, cp->dval) ; - - cp->ptr = (PTR) new_STRING(xbuff) ; - break ; - - case C_STRING : return ; - - case C_MBSTRN : - case C_STRNUM : break ; - - default : bozo("bad type on cast") ; - } - cp->type = C_STRING ; -} - -void cast_to_RE( cp ) - register CELL *cp ; -{ register PTR p ; - - if ( cp->type < C_STRING ) cast1_to_s(cp) ; - - p = re_compile( string(cp) ) ; - free_STRING( string(cp) ) ; - cp->type = C_RE ; - cp->ptr = p ; - -} - -void cast_for_split(cp) - register CELL *cp ; -{ - static char meta[] = "^$.*+?|[]()" ; - static char xbuff[] = "\\X" ; - int c ; - unsigned len ; - - if ( cp->type < C_STRING ) cast1_to_s(cp) ; - - if ( (len = string(cp)->len) == 1 ) - { - if ( (c = string(cp)->str[0]) == ' ' ) - { free_STRING(string(cp)) ; - cp->type = C_SPACE ; - return ; - } - else - if ( strchr(meta, c) ) - { xbuff[1] = c ; - free_STRING(string(cp)) ; - cp->ptr = (PTR) new_STRING(xbuff) ; - } - } - else - if ( len == 0 ) - { free_STRING(string(cp)) ; - cp->type = C_SNULL ; - return ; - } - - cast_to_RE(cp) ; -} - -/* input: cp-> a CELL of type C_MBSTRN (maybe strnum) - test it -- casting it to the appropriate type - which is C_STRING or C_STRNUM -*/ - -void check_strnum( cp ) - CELL *cp ; -{ char *test ; - register unsigned char *s , *q ; - - cp->type = C_STRING ; /* assume not C_STRNUM */ - s = (unsigned char *) string(cp)->str ; - q = s + string(cp)->len ; - while ( scan_code[*s] == SC_SPACE ) s++ ; - if ( s == q ) return ; - - while ( scan_code[ q[-1] ] == SC_SPACE ) q-- ; - if ( scan_code[ q[-1] ] != SC_DIGIT && - q[-1] != '.' ) return ; - - switch ( scan_code[*s] ) - { - case SC_DIGIT : - case SC_PLUS : - case SC_MINUS : - case SC_DOT : - -#if FPE_TRAPS_ON - errno = 0 ; - cp->dval = strtod((char *)s, &test) ; - /* treat overflow as pure string */ - if ( errno && cp->dval != 0.0 ) return ; -#else - cp->dval = strtod((char *)s, &test) ; -#endif - - if ((char *) q <= test ) cp->type = C_STRNUM ; - /* <= instead of == , for some buggy strtod - e.g. Apple Unix */ - } -} - -/* cast a CELL to a replacement cell */ - -void cast_to_REPL( cp ) - register CELL *cp ; -{ register STRING *sval ; - - if ( cp->type < C_STRING ) cast1_to_s(cp) ; - sval = (STRING *) cp->ptr ; - - (void) cellcpy(cp, repl_compile(sval)) ; - free_STRING(sval) ; -} - - -/* convert a double to long (this is not as simple as a - cast because the results are undefined if it won't fit). - Truncate large values to +MAX__LONG or -MAX__LONG - Send nans to -MAX__LONG -*/ - -long -d_to_l(d) - double d ; -{ - if ( d >= MAX__LONG ) return MAX__LONG ; - if ( d > -MAX__LONG ) return (int) d ; - return -MAX__LONG ; -} - -#if HAVE_STRTOD==0 - -/* don't use this unless you really don't have strtod() because - (1) its probably slower than your real strtod() - (2) atof() may call the real strtod() -*/ - -#if __STDC__ == 0 -#define const -#endif - -double strtod(s, endptr) - const char *s ; - char **endptr ; -{ - register unsigned char *p ; - int flag ; - double atof() ; - - if ( endptr ) - { - p = (unsigned char*) s ; - - flag = 0 ; - while ( *p == ' ' || *p == '\t' ) p++ ; - if ( *p == '-' || *p == '+' ) p++ ; - while ( scan_code[*p] == SC_DIGIT ) { flag++ ; p++ ; } - if ( *p == '.' ) - { - p++ ; - while ( scan_code[*p] == SC_DIGIT ) { flag++ ; p++ ; } - } - /* done with number part */ - if ( flag == 0 ) - { /* no number part */ - *endptr = s ; return 0.0 ; - } - else *endptr = (char *) p ; - - /* now look for exponent */ - if ( *p == 'e' || *p == 'E' ) - { - flag = 0 ; - p++ ; - if ( *p == '-' || *p == '+' ) p++ ; - while ( scan_code[*p] == SC_DIGIT ) { flag++ ; p++ ; } - if ( flag ) *endptr = (char *) p ; - } - } - return atof(s) ; -} -#endif /* HAVE_STRTOD==0 */ - -#if HAVE_FMOD==0 - -#if SW_FP_CHECK /* this is V7 and XNX23A specific */ - -double fmod(x, y) - double x, y ; -{ double modf() ; - double dtmp, ipart ; - - clrerr(); - dtmp = x / y; - fpcheck(); - (void) modf(dtmp, &ipart) ; - return x - ipart*y ; -} - -#else - -double fmod(x, y) - double x, y ; -{ double modf() ; - double ipart ; - - (void) modf(x/y, &ipart) ; - return x - ipart*y ; -} - -#endif -#endif - - - diff --git a/gnu/usr.bin/awk/code.c b/gnu/usr.bin/awk/code.c deleted file mode 100644 index 2fb4ca537c95..000000000000 --- a/gnu/usr.bin/awk/code.c +++ /dev/null @@ -1,164 +0,0 @@ - -/******************************************** -code.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: code.c,v $ -/* Revision 1.2 1993/07/02 23:57:08 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:55:43 brennan - * 1.1 pre-release - * -*/ - -/* code.c */ - -#include "mawk.h" -#include "code.h" -#include "init.h" -#include "jmp.h" -#include "field.h" - - -#define MAIN_CODE_SZ (MAIN_PAGE_SZ*sizeof(INST)) - -INST *code_ptr ; -INST *main_start , *main_code_ptr ; - -#if 0 -INST *begin_start , *begin_code_ptr ; -INST *end_start , *end_code_ptr ; -#endif -unsigned main_size /*, begin_size, end_size*/ ; - /* when the code is done executing its freed, - that's why this is global */ - -struct be_code begin_code , end_code ; - -void PROTO(fdump, (void) ) ; - -void be_expand( p ) - struct be_code *p ; -{ int delta ; - - main_code_ptr = code_ptr ; - - if ( p->start ) - { - delta = p->ptr - p->start ; - p->start = (INST*) zrealloc(p->start, INST_BYTES(p->size), - INST_BYTES(PAGE_SZ)) ; - } - else - { - delta = 0 ; - p->start = (INST*) zmalloc(INST_BYTES(PAGE_SZ)) ; - } - - p->size = PAGE_SZ ; - code_ptr = p->start + delta ; -} - -void be_shrink(p) - struct be_code *p ; -{ - int delta = code_ptr - p->start ; - - code_ptr = main_code_ptr ; - - if ( delta > p->size ) - overflow( p == & begin_code ? - "BEGIN code" : "END code" , p->size) ; - - p->start = (INST*) zrealloc(p->start, INST_BYTES(p->size) , - INST_BYTES(delta+2)) ; - - p->ptr = p->start + delta ; - p->size = delta + 2 ; -} - - -void code_init() -{ - code_ptr = main_code_ptr = main_start - = (INST *) zmalloc(MAIN_CODE_SZ) ; - - code1(_OMAIN) ; -} - -void code_cleanup() -{ int some_code_flag = 0 ; /* might only have functions */ - - - /* set the END code */ - if ( end_code.start ) - { - end_code.ptr++ -> op = _EXIT0 ; - end_code.ptr++ -> op = _HALT ; - end_code.size = INST_BYTES(end_code.size) ; - } - - /* set the main code */ - if ( end_code.start || code_ptr - main_start > 1 ) - { int gl_offset = code_ptr - main_start ; - extern INST *next_label ; - extern int NR_flag ; - - if ( NR_flag ) code1(OL_GL_NR) ; - else code1(OL_GL) ; - - code1(_HALT) ; - - main_size = code_ptr - main_start ; - if ( main_size > MAIN_PAGE_SZ ) - overflow("MAIN code" , MAIN_PAGE_SZ) ; - main_size *= sizeof(INST) ; - code_ptr = main_start = - (INST*) zrealloc(main_start, MAIN_CODE_SZ, main_size) ; - - next_label = main_start+gl_offset ; - some_code_flag = 1 ; - } - else /* only BEGIN */ - { - zfree(main_start, MAIN_CODE_SZ) ; - main_start = (INST*) 0 ; - } - - /* set the BEGIN code */ - if ( begin_code.start ) - { - some_code_flag = 1 ; - begin_code.ptr++ -> op = main_start ? _JMAIN : _EXIT0 ; - begin_code.ptr++ -> op = _HALT ; - begin_code.size = INST_BYTES(begin_code.size) ; - - /* execution starts at code_ptr */ - code_ptr = begin_code.start ; - } - -#if ! SM_DOS - if ( dump_code ) - { - fdump() ; /* dumps all user functions */ - if ( begin_code.start ) - { fprintf(stderr, "BEGIN\n") ; da(begin_code.start, stderr) ; } - if ( end_code.start ) - { fprintf(stderr, "END\n") ; da(end_code.start, stderr) ; } - if ( main_start ) - { fprintf(stderr, "MAIN\n") ; da(main_start, stderr) ; } - } -#endif - - if ( some_code_flag == 0 ) mawk_exit(0) ; -} - diff --git a/gnu/usr.bin/awk/code.h b/gnu/usr.bin/awk/code.h deleted file mode 100644 index b45647b50b7e..000000000000 --- a/gnu/usr.bin/awk/code.h +++ /dev/null @@ -1,153 +0,0 @@ - -/******************************************** -code.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: code.h,v $ -/* Revision 1.2 1993/07/02 23:57:09 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:59:07 brennan - * 1.1 pre-release - * -*/ - - -/* code.h */ - -#ifndef CODE_H -#define CODE_H - -#include "memory.h" - -/* coding scope */ -#define SCOPE_MAIN 0 -#define SCOPE_BEGIN 1 -#define SCOPE_END 2 -#define SCOPE_FUNCT 3 - - -extern INST *code_ptr ; -extern INST *main_start, *main_code_ptr ; -extern unsigned main_size ; - -extern struct be_code { -INST *start , *ptr ; -unsigned size ; } begin_code , end_code ; - -void PROTO(be_shrink, (struct be_code *)) ; -void PROTO(be_expand, (struct be_code *)) ; - -#define INST_BYTES(x) (sizeof(INST)*(x)) - -extern CELL eval_stack[] ; - - -#define code1(x) code_ptr++ -> op = (x) - -#define code2(x,y) (void)( code_ptr++ -> op = (x) ,\ - code_ptr++ -> ptr = (PTR)(y) ) - -extern int exit_code ; - -/* the machine opcodes */ -/* to avoid confusion with a ptr FE_PUSHA must have op code 0 */ -/* unfortunately enums are less portable than defines */ - -#define FE_PUSHA 0 -#define FE_PUSHI 1 -#define F_PUSHA 2 -#define F_PUSHI 3 -#define NF_PUSHI 4 -#define _HALT 5 -#define _STOP 6 -#define _PUSHC 7 -#define _PUSHD 8 -#define _PUSHS 9 -#define _PUSHINT 10 -#define _PUSHA 11 -#define _PUSHI 12 -#define L_PUSHA 13 -#define L_PUSHI 14 -#define AE_PUSHA 15 -#define AE_PUSHI 16 -#define A_PUSHA 17 -#define LAE_PUSHA 18 -#define LAE_PUSHI 19 -#define LA_PUSHA 20 -#define _POP 21 -#define _DUP 22 -#define _ADD 23 -#define _SUB 24 -#define _MUL 25 -#define _DIV 26 -#define _MOD 27 -#define _POW 28 -#define _NOT 29 -#define _TEST 30 -#define A_TEST 31 -#define A_DEL 32 -#define ALOOP 33 -#define A_CAT 34 -#define _UMINUS 35 -#define _UPLUS 36 -#define _ASSIGN 37 -#define _ADD_ASG 38 -#define _SUB_ASG 39 -#define _MUL_ASG 40 -#define _DIV_ASG 41 -#define _MOD_ASG 42 -#define _POW_ASG 43 -#define F_ASSIGN 44 -#define F_ADD_ASG 45 -#define F_SUB_ASG 46 -#define F_MUL_ASG 47 -#define F_DIV_ASG 48 -#define F_MOD_ASG 49 -#define F_POW_ASG 50 -#define _CAT 51 -#define _BUILTIN 52 -#define _PRINT 53 -#define _POST_INC 54 -#define _POST_DEC 55 -#define _PRE_INC 56 -#define _PRE_DEC 57 -#define F_POST_INC 58 -#define F_POST_DEC 59 -#define F_PRE_INC 60 -#define F_PRE_DEC 61 -#define _JMP 62 -#define _JNZ 63 -#define _JZ 64 -#define _EQ 65 -#define _NEQ 66 -#define _LT 67 -#define _LTE 68 -#define _GT 69 -#define _GTE 70 -#define _MATCH0 71 -#define _MATCH1 72 -#define _MATCH2 73 -#define _EXIT 74 -#define _EXIT0 75 -#define _NEXT 76 -#define _RANGE 77 -#define _CALL 78 -#define _RET 79 -#define _RET0 80 -#define SET_ALOOP 81 -#define OL_GL 82 -#define OL_GL_NR 83 -#define _OMAIN 84 -#define _JMAIN 85 - - -#endif /* CODE_H */ diff --git a/gnu/usr.bin/awk/config.h b/gnu/usr.bin/awk/config.h deleted file mode 100644 index f2c5681df7c2..000000000000 --- a/gnu/usr.bin/awk/config.h +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************** -386bsd.h -copyright 1993, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* - * $Log: config.h,v $ - * Revision 1.3 1993/07/02 23:57:10 jtc - * Updated to mawk 1.1.4 - * - * Revision 1.1 1993/02/05 02:20:10 mike - * Initial revision - * - */ - -#ifndef CONFIG_H -#define CONFIG_H 1 - -#define FPE_TRAPS_ON 1 -#define FPE_ZERODIVIDE FPE_FLTDIV_TRAP -#define FPE_OVERFLOW FPE_FLTOVF_TRAP - -#define HAVE_STRTOD 1 - -#define HAVE_MATHERR 0 - -#define DONT_PROTO_OPEN - -#include "config/Idefault.h" - -#endif /* CONFIG_H */ diff --git a/gnu/usr.bin/awk/config/msc_dos.h b/gnu/usr.bin/awk/config/msc_dos.h deleted file mode 100644 index 519a81b46e1a..000000000000 --- a/gnu/usr.bin/awk/config/msc_dos.h +++ /dev/null @@ -1,53 +0,0 @@ - -/******************************************** -msc_dos.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* Microsoft C 6.0A under MSDOS */ - -/*$Log: msc_dos.h,v $ -/*Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/*initial import of 386bsd-0.1 sources -/* - * Revision 4.3 92/01/09 08:54:09 brennan - * changed SAMESEG macro - * - * Revision 4.2 91/10/29 09:36:59 brennan - * Large model macro - * -*/ - -#ifndef CONFIG_H -#define CONFIG_H 1 - -#define MSDOS_MSC 1 -#define MSDOS 1 - -#define HAVE_PROTOS 1 -#define HAVE_STDARG_H 1 -#define HAVE_STDLIB_H 1 - -#define FPE_TRAPS_ON 1 -#define NOINFO_SIGFPE 1 - -#ifndef HAVE_SMALL_MEMORY /* allow large model override */ -#define HAVE_SMALL_MEMORY 1 -#endif - -#if HAVE_SMALL_MEMORY==0 -/* how to test far pointers have the same segment */ -#define SAMESEG(p,q) \ - (((unsigned long)(p)^(unsigned long)(q))<0x10000L) -#endif - -#include "config/Idefault.h" - - -#endif /* CONFIG_H */ diff --git a/gnu/usr.bin/awk/config/next.h b/gnu/usr.bin/awk/config/next.h deleted file mode 100644 index ccc39bc56e01..000000000000 --- a/gnu/usr.bin/awk/config/next.h +++ /dev/null @@ -1,34 +0,0 @@ - -/******************************************** -next.h - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* - Next OS 2.1 -*/ - -/* $Log: next.h,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 1.1 92/02/25 08:13:12 brennan - * Initial revision - * -*/ - -#ifndef CONFIG_H -#define CONFIG_H 1 - -/* system compiler is gcc and has */ -#define HAVE_STDLIB_H 1 - -#include "config/Idefault.h" - -#endif - diff --git a/gnu/usr.bin/awk/config/sgi.h b/gnu/usr.bin/awk/config/sgi.h deleted file mode 100644 index ced1b5e72507..000000000000 --- a/gnu/usr.bin/awk/config/sgi.h +++ /dev/null @@ -1,33 +0,0 @@ - -/******************************************** -sgi.h - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* - SGI IRIX4.0.1 -*/ - -/* $Log: sgi.h,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 1.1 92/02/25 08:10:22 brennan - * Initial revision - * -*/ - -#ifndef CONFIG_H -#define CONFIG_H 1 - -#define HAVE_STRTOD 0 - -#include "config/Idefault.h" - -#endif - diff --git a/gnu/usr.bin/awk/config/sun_os40.h b/gnu/usr.bin/awk/config/sun_os40.h deleted file mode 100644 index c73777ef4c85..000000000000 --- a/gnu/usr.bin/awk/config/sun_os40.h +++ /dev/null @@ -1,68 +0,0 @@ - -/******************************************** -sun_os40.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: sun_os40.h,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.2 91/11/17 12:34:11 brennan - * added a declaration for sprintf() - * - * Revision 4.1 91/09/25 11:41:35 brennan - * VERSION 1.0 - * - * Revision 3.4 91/08/26 13:04:38 brennan - * changed file name - * - * Revision 3.3 91/08/23 08:48:42 brennan - * discovered strtod() bug can also happen on sun3 - * - * Revision 3.2 91/08/13 09:04:13 brennan - * VERSION .9994 - * - * Revision 3.1 91/06/07 10:38:50 brennan - * VERSION 0.995 - * -*/ - -/* On some, not all, sun4's SunOS4.0.3 there is a bug in strtod(). - strtod("0",0) sets errno to ERANGE sometimes! which announces - underflow which is not true. - - If you get strange error messages: - - mawk: line xx: 0 : decimal underflow - - then your strtod() is broken and use this file as config.h - - Otherwise use generic.h as config.h. - - I've talked to Sun and they tell me its a known bug thats - fixed in 4.1 - - ---------------- - It can happen on sun3's too. (8/23) -*/ - -#ifndef CONFIG_H -#define CONFIG_H - - -#define STRTOD_UNDERFLOW_ON_ZERO_BUG 1 - -extern char *sprintf() ; /* missing in /usr/include/*.h */ - - -#include "config/Idefault.h" - -#endif diff --git a/gnu/usr.bin/awk/config/sun_os41.h b/gnu/usr.bin/awk/config/sun_os41.h deleted file mode 100644 index fb4edc78dab3..000000000000 --- a/gnu/usr.bin/awk/config/sun_os41.h +++ /dev/null @@ -1,32 +0,0 @@ - -/******************************************** -sun_os41.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: sun_os41.h,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 1.3 91/12/05 08:24:02 brennan - * 1.1 pre-release - * -*/ - -#ifndef CONFIG_H -#define CONFIG_H - -/* this is missing (actually its in 5include) */ -int fprintf() ; - - -#include "config/Idefault.h" - -#endif diff --git a/gnu/usr.bin/awk/config/sysV.h b/gnu/usr.bin/awk/config/sysV.h deleted file mode 100644 index 78b772f590e6..000000000000 --- a/gnu/usr.bin/awk/config/sysV.h +++ /dev/null @@ -1,50 +0,0 @@ - -/******************************************** -sysV.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* - This is for sysVR3+ - without IEEE754 floating point - - Even with IEEE754 hardware e.g. a 80x87 or 486 - you might need this, because the math library doesn't - support the hardware. - - tested on SCO UNIX VR3.2v2.0 - -*/ - -/*$Log: sysV.h,v $ -/*Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/*initial import of 386bsd-0.1 sources -/* - * Revision 4.1 91/09/25 11:41:40 brennan - * VERSION 1.0 - * - * Revision 1.2 91/08/13 09:04:15 brennan - * VERSION .9994 - * - * Revision 1.1 91/08/03 05:49:52 brennan - * Initial revision - * -*/ - -#ifndef CONFIG_H -#define CONFIG_H 1 - -#define FPE_TRAPS_ON 1 -#define NOINFO_SIGFPE 1 - - -#include "config/Idefault.h" - -#endif /* CONFIG_H */ diff --git a/gnu/usr.bin/awk/config/sysV_ieeefp.h b/gnu/usr.bin/awk/config/sysV_ieeefp.h deleted file mode 100644 index 07c0555dd465..000000000000 --- a/gnu/usr.bin/awk/config/sysV_ieeefp.h +++ /dev/null @@ -1,49 +0,0 @@ - -/******************************************** -sysV_ieeefp.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: sysV_ieeefp.h,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.1 91/09/25 11:41:45 brennan - * VERSION 1.0 - * - * Revision 1.3 91/09/10 09:19:41 brennan - * fixed comment typo - * - * Revision 1.2 91/08/13 09:04:17 brennan - * VERSION .9994 - * - * Revision 1.1 91/07/03 06:36:41 brennan - * Initial revision - * -*/ - -/* This is the config.h file for - SystemV R3+ - with IEEE754 floating point - **and a math library that supports ieee754** - - This should work on SysV R3+ systems on i386 or i486 - compiled and tested on: - -*/ - -#ifndef CONFIG_H -#define CONFIG_H 1 - - -#define TURN_OFF_FPE_TRAPS() (void) fpsetmask(0) - -#include "config/Idefault.h" -#endif /* CONFIG_H */ diff --git a/gnu/usr.bin/awk/config/tcc_dos.h b/gnu/usr.bin/awk/config/tcc_dos.h deleted file mode 100644 index d9e422f6588e..000000000000 --- a/gnu/usr.bin/awk/config/tcc_dos.h +++ /dev/null @@ -1,66 +0,0 @@ - -/******************************************** -tcc_dos.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* Turbo C under MSDOS */ - -/* $Log: tcc_dos.h,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.2 91/10/29 09:37:54 brennan - * changes for 1.09 - * - * Revision 4.1 91/09/25 11:41:51 brennan - * VERSION 1.0 - * - * Revision 3.2 91/08/13 09:04:19 brennan - * VERSION .9994 - * - * Revision 3.1 91/06/07 10:38:51 brennan - * VERSION 0.995 - * -*/ - -#ifndef CONFIG_H -#define CONFIG_H 1 - -#define MSDOS 1 - -#define HAVE_PROTOS 1 -#define HAVE_STDARG_H 1 -#define HAVE_STDLIB_H 1 - - - -/* Turbo C float lib bungles comparison of NaNs so we - have to keep traps on */ - - -#define FPE_TRAPS_ON 1 -#define FPE_ZERODIVIDE 131 -#define FPE_OVERFLOW 132 - - -#ifndef HAVE_SMALL_MEMORY /* allow large model override */ -#define HAVE_SMALL_MEMORY 1 -#endif - -#if HAVE_SMALL_MEMORY==0 -/* how to test far pointers have the same segment */ -#include -#define SAMESEG(p,q) (FP_SEG(p)==FP_SEG(q)) -#endif - -#include "config/Idefault.h" - - -#endif /* CONFIG_H */ diff --git a/gnu/usr.bin/awk/config/template.h b/gnu/usr.bin/awk/config/template.h deleted file mode 100644 index 009dfe08c3f7..000000000000 --- a/gnu/usr.bin/awk/config/template.h +++ /dev/null @@ -1,17 +0,0 @@ - -/* template.h */ - -/* all .h's that link for move to .. as config.h - should have the following form -*/ - -#ifndef CONFIG_H -#define CONFIG_H 1 - - -... -non default defines -... - -#include "config/Idefault.h" -#endif /* CONFIG_H */ diff --git a/gnu/usr.bin/awk/config/think_c.h b/gnu/usr.bin/awk/config/think_c.h deleted file mode 100644 index 9eee669eff52..000000000000 --- a/gnu/usr.bin/awk/config/think_c.h +++ /dev/null @@ -1,31 +0,0 @@ - -/******************************************** -Think_C.h - -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* Think C 4.0 for the Macintosh */ - -#ifndef CONFIG_H -#define CONFIG_H 1 - -#define HAVE_PROTOS 1 -#define HAVE_STDARG_H 1 -#define HAVE_STDLIB_H 1 - -#define HAVE_MATHERR 0 -#define FPE_TRAPS_ON 1 -#define NOINFO_SIGFPE 1 - -#define SIZE_T(x) (size_t)(x) - -#include ":config:Idefault.h" - -#endif /* CONFIG_H */ diff --git a/gnu/usr.bin/awk/config/ultrix42mips.h b/gnu/usr.bin/awk/config/ultrix42mips.h deleted file mode 100644 index bd08bbc84702..000000000000 --- a/gnu/usr.bin/awk/config/ultrix42mips.h +++ /dev/null @@ -1,35 +0,0 @@ - -/******************************************** -ultrix42mips.h -copyright 1992, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: ultrix42mips.h,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 1.1 92/03/03 12:35:21 brennan - * Initial revision - * -*/ - - -#ifndef CONFIG_H -#define CONFIG_H 1 - -#define HAVE_PROTOS 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STDARG_H 1 - -/* The only reason __STDC__ is not turned on is - compiler doesn't recognize const */ - -#include "config/Idefault.h" -#endif /* CONFIG_H */ diff --git a/gnu/usr.bin/awk/config/ultrix_vax.h b/gnu/usr.bin/awk/config/ultrix_vax.h deleted file mode 100644 index dbc4cc6e3ba1..000000000000 --- a/gnu/usr.bin/awk/config/ultrix_vax.h +++ /dev/null @@ -1,50 +0,0 @@ - -/******************************************** -ultrix_vax.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: ultrix_vax.h,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.1 91/09/25 11:42:07 brennan - * VERSION 1.0 - * - * Revision 3.2 91/08/13 09:04:23 brennan - * VERSION .9994 - * - * Revision 3.1 91/06/07 10:38:53 brennan - * VERSION 0.995 - * -*/ - -/* tested on: - ULTRIX V4.1 (Rev. 200) System #3 on MicroVax 3600 - ULTRIX V3.1 on vax?? -*/ - -#ifndef CONFIG_H -#define CONFIG_H 1 - -/* don't have IEEE hardware */ -#define FPE_TRAPS_ON 1 -#define FPE_ZERODIVIDE FPE_FLTDIV_FAULT -#define FPE_OVERFLOW FPE_FLTOVF_FAULT - -/* want SysV style matherr(), - so set -YSYSTEM_FIVE compiler flag - in Makefile -*/ - -#include "config/Idefault.h" - - -#endif /* CONFIG_H */ diff --git a/gnu/usr.bin/awk/config/xenix_r2.h b/gnu/usr.bin/awk/config/xenix_r2.h deleted file mode 100644 index 356a7bf121ee..000000000000 --- a/gnu/usr.bin/awk/config/xenix_r2.h +++ /dev/null @@ -1,55 +0,0 @@ - -/******************************************** -xenix_r2.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* - This has been compiled and tested on - SCO XENIX R2.3.1 SysV on a i386 - - The floating point support is poor. - Even with a coprocessor there is no access to IEEE754 - functionality. - - There is no way to tell what caused SIGFPE - -*/ - -/*$Log: xenix_r2.h,v $ -/*Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/*initial import of 386bsd-0.1 sources -/* - * Revision 4.1 91/09/25 11:42:13 brennan - * VERSION 1.0 - * - * Revision 1.2 91/08/13 09:04:24 brennan - * VERSION .9994 - * - * Revision 1.1 91/06/19 10:17:08 brennan - * Initial revision - * -*/ - -#ifndef CONFIG_H -#define CONFIG_H 1 - -#define FPE_TRAPS_ON 1 -#define NOINFO_SIGFPE 1 - -#if 0 -I would guess that on a 286 you would want to -#define HAVE_SMALL_MEMORY 1 -#endif - - -#include "config/Idefault.h" - -#endif /* CONFIG_H */ diff --git a/gnu/usr.bin/awk/da.c b/gnu/usr.bin/awk/da.c deleted file mode 100644 index 07d84fd179a1..000000000000 --- a/gnu/usr.bin/awk/da.c +++ /dev/null @@ -1,370 +0,0 @@ - -/******************************************** -da.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: da.c,v $ -/* Revision 1.2 1993/07/02 23:57:11 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.2 1992/07/25 21:35:25 brennan - * patch2 - * fixed small typo on da of _PRE_DEC - * - * Revision 5.1 1991/12/05 07:55:45 brennan - * 1.1 pre-release - * -*/ - - -/* da.c */ -/* disassemble code */ - -/* This and new posix stuff won't fit in small model DOS */ - - - -#include "mawk.h" - -#if ! SM_DOS - -#include "code.h" -#include "bi_funct.h" -#include "repl.h" -#include "field.h" - -static char *PROTO(find_bi_name, (PF_CP) ) ; - -static struct sc { -char op ; char *name ; -} simple_code[] = { -_STOP, "stop", -FE_PUSHA, "fe_pusha", -FE_PUSHI, "fe_pushi", -A_TEST, "a_test", -A_DEL , "a_del", -A_CAT, "a_cat", -_POP, "pop", -_ADD, "add", -_SUB, "sub", -_MUL, "mul", -_DIV, "div", -_MOD, "mod", -_POW, "pow", -_NOT, "not", -_UMINUS, "uminus", -_UPLUS, "uplus", -_DUP, "dup", -_TEST, "test", -_CAT, "cat", -_ASSIGN, "assign", -_ADD_ASG, "add_asg", -_SUB_ASG, "sub_asg", -_MUL_ASG, "mul_asg", -_DIV_ASG, "div_asg", -_MOD_ASG, "mod_asg", -_POW_ASG, "pow_asg", -NF_PUSHI, "nf_pushi", -F_ASSIGN, "f_assign", -F_ADD_ASG, "f_add_asg", -F_SUB_ASG, "f_sub_asg", -F_MUL_ASG, "f_mul_asg", -F_DIV_ASG, "f_div_asg", -F_MOD_ASG, "f_mod_asg", -F_POW_ASG, "f_pow_asg", -_POST_INC, "post_inc", -_POST_DEC, "post_dec", -_PRE_INC, "pre_inc", -_PRE_DEC, "pre_dec", -F_POST_INC, "f_post_inc", -F_POST_DEC, "f_post_dec", -F_PRE_INC, "f_pre_inc", -F_PRE_DEC, "f_pre_dec", -_EQ, "eq", -_NEQ, "neq", -_LT, "lt", -_LTE, "lte", -_GT, "gt", -_GTE, "gte", -_MATCH2, "match2", -_EXIT, "exit", -_EXIT0, "exit0", -_NEXT, "next", -_RET, "ret", -_RET0, "ret0", -_OMAIN, "omain", -_JMAIN, "jmain", -OL_GL, "ol_gl", -OL_GL_NR, "ol_gl_nr", -_HALT , (char *) 0 } ; - -void da(start, fp) - INST *start ; - FILE *fp ; -{ CELL *cp ; - register INST *p = start ; - char *name ; - - while ( p->op != _HALT ) - { /* print the relative code address (label) */ - fprintf(fp,"%03d ", p - start) ; - - switch( p++->op ) - { - - case _PUSHC : - cp = (CELL *) p++->ptr ; - switch( cp->type ) - { - case C_RE : - fprintf(fp,"pushc\t0x%lx\t/%s/\n" , (long) cp->ptr , - re_uncompile(cp->ptr) ) ; - break ; - - case C_SPACE : - fprintf(fp, "pushc\tspace split\n") ; - break ; - - case C_SNULL : - fprintf(fp, "pushc\tnull split\n") ; - break ; - case C_REPL : - fprintf(fp, "pushc\trepl\t%s\n" , - repl_uncompile(cp) ) ; - break ; - case C_REPLV : - fprintf(fp, "pushc\treplv\t%s\n" , - repl_uncompile(cp) ) ; - break ; - - default : - fprintf(fp,"pushc\tWEIRD\n") ; ; - break ; - } - break ; - - case _PUSHD : - fprintf(fp,"pushd\t%.6g\n" , *(double*)p++->ptr) ; - break ; - case _PUSHS : - { STRING *sval = (STRING *) p++->ptr ; - fprintf(fp,"pushs\t\"%s\"\n" , sval->str) ; - break ; - } - - case _MATCH0 : - case _MATCH1 : - fprintf(fp, "match%d\t0x%lx\t/%s/\n" , - p[-1].op == _MATCH1, (long) p->ptr, - re_uncompile(p->ptr) ) ; - p++ ; - break ; - - case _PUSHA : - fprintf(fp,"pusha\t%s\n", - reverse_find(ST_VAR, & p++ -> ptr)) ; - break ; - - case _PUSHI : - cp = (CELL *) p++ -> ptr ; - if ( cp == field ) - fprintf(fp, "pushi\t$0\n") ; - else - if ( cp == &fs_shadow ) - fprintf(fp, "pushi\t@fs_shadow\n") ; - else - { - if ( -#if LM_DOS - SAMESEG(cp,field) && -#endif - cp > NF && cp <= LAST_PFIELD ) - name = reverse_find(ST_FIELD, &cp) ; - else - name = reverse_find(ST_VAR, &cp) ; - - fprintf(fp, "pushi\t%s\n", name) ; - } - break ; - - case L_PUSHA : - fprintf( fp, "l_pusha\t%d\n", p++->op) ; - break ; - - case L_PUSHI : - fprintf( fp, "l_pushi\t%d\n", p++->op) ; - break ; - - case LAE_PUSHI : - fprintf( fp, "lae_pushi\t%d\n", p++->op) ; - break ; - - case LAE_PUSHA : - fprintf( fp, "lae_pusha\t%d\n", p++->op) ; - break ; - - case LA_PUSHA : - fprintf( fp, "la_pusha\t%d\n", p++->op) ; - break ; - - case F_PUSHA : - cp = (CELL *) p++ -> ptr ; - if ( -#if LM_DOS - SAMESEG(cp,field) && -#endif - cp >= NF && cp <= LAST_PFIELD ) - fprintf(fp, "f_pusha\t%s\n", - reverse_find(ST_FIELD, &cp)) ; - else - fprintf(fp, "f_pusha\t$%d\n", - field_addr_to_index(cp)) ; - break ; - - case F_PUSHI : - p++ ; - fprintf(fp, "f_pushi\t$%d\n", p++ -> op) ; - break ; - - case AE_PUSHA : - fprintf(fp,"ae_pusha\t%s\n" , - reverse_find(ST_ARRAY, & p++->ptr) ) ; - break ; - - case AE_PUSHI : - fprintf(fp,"ae_pushi\t%s\n" , - reverse_find(ST_ARRAY, & p++->ptr)) ; - break ; - - case A_PUSHA : - fprintf(fp,"a_pusha\t%s\n" , - reverse_find(ST_ARRAY, & p++->ptr)) ; - break ; - - case _PUSHINT : - fprintf(fp,"pushint\t%d\n" , p++ -> op ) ; - break ; - - case _BUILTIN : - fprintf(fp,"%s\n" , - find_bi_name( (PF_CP) p++ -> ptr ) ) ; - break ; - - case _PRINT : - fprintf(fp,"%s\n", - (PF_CP) p++ -> ptr == bi_printf - ? "printf" : "print") ; - break ; - - case _JMP : - case _JNZ : - case _JZ : - { int j = (p-1)->op ; - char *s = j == _JMP ? "jmp" : - j == _JNZ ? "jnz" : "jz" ; - - fprintf(fp,"%s\t\t%03d\n" , s , - (p - start) + p->op ) ; - p++ ; - break ; - } - - case SET_ALOOP : - fprintf(fp, "s_aloop\t%03d\n", p + p->op - start ) ; - p++ ; - break ; - - case ALOOP : - fprintf(fp,"aloop\t%03d\n", p-start+p->op) ; - p += 2 ; - break ; - - case _CALL : - fprintf(fp, "call\t%s\t%d\n", - ((FBLOCK*)p->ptr)->name , p[1].op) ; - p += 2 ; - break ; - - case _RANGE : - fprintf(fp, "range\t%03d %03d %03d\n", - /* label for pat2, action, follow */ - p - start + p[1].op , - p - start + p[2].op , - p - start + p[3].op ) ; - p += 4 ; - break ; - default : - { - struct sc *q = simple_code ; - int k = (p-1)->op ; - - while ( q->op != _HALT && q->op != k ) q++ ; - - fprintf(fp, "%s\n", - q->op != _HALT ? q->name : "bad instruction") ; - } - break ; - } - } -} - -static struct { -PF_CP action ; -char *name ; -} special_cases[] = { -bi_split, "split", -bi_match, "match", -bi_getline,"getline", -bi_sub, "sub", -bi_gsub , "gsub", -(PF_CP) 0, (char *) 0 } ; - -static char *find_bi_name( p ) - PF_CP p ; -{ BI_REC *q ; - int i ; - - for( q = bi_funct ; q->name ; q++ ) - if ( q->fp == p ) /* found */ - return q->name ; - /* next check some special cases */ - for( i = 0 ; special_cases[i].action ; i++) - if ( special_cases[i].action == p ) - return special_cases[i].name ; - - return "unknown builtin" ; -} - -static struct fdump { -struct fdump *link ; -FBLOCK *fbp ; -} *fdump_list ; /* linked list of all user functions */ - -void add_to_fdump_list( fbp ) - FBLOCK *fbp ; -{ struct fdump *p = (struct fdump *)zmalloc(sizeof(struct fdump)) ; - p->fbp = fbp ; - p->link = fdump_list ; fdump_list = p ; -} - -void fdump() -{ - register struct fdump *p, *q = fdump_list ; - - while ( p = q ) - { q = p->link ; - fprintf(stderr, "function %s\n" , p->fbp->name) ; - da(p->fbp->code, stderr) ; - zfree(p, sizeof(struct fdump)) ; - } -} - -#endif /* SM_DOS */ diff --git a/gnu/usr.bin/awk/error.c b/gnu/usr.bin/awk/error.c deleted file mode 100644 index bbbf3ab9e78f..000000000000 --- a/gnu/usr.bin/awk/error.c +++ /dev/null @@ -1,393 +0,0 @@ - -/******************************************** -error.c -copyright 1991, 1992 Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: error.c,v $ -/* Revision 1.2 1993/07/02 23:57:12 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.3 1993/01/22 14:55:46 mike - * trivial change for unexpected_char() - * - * Revision 5.2 1992/10/02 23:26:04 mike - * using vargs.h - * - * Revision 5.1 1991/12/05 07:55:48 brennan - * 1.1 pre-release - * -*/ - - -#include "mawk.h" -#include "scan.h" -#include "bi_vars.h" -#include "vargs.h" - - -#ifndef EOF -#define EOF (-1) -#endif - -static void PROTO( rt_where, (void) ) ; -static void PROTO( unexpected_char, (void) ) ; -static void PROTO( missing, (int, char *, int) ) ; -static char *PROTO( type_to_str, (int) ) ; - -#if HAVE_STRERROR == 0 -#define strerror(n) ((n)>0&&(n)", -GTE, ">=" , -MATCH, string_buff, -PLUS , "+" , -MINUS, "-" , -MUL , "*" , -DIV, "/" , -MOD, "%" , -POW, "^" , -NOT, "!" , -COMMA, "," , -INC_or_DEC , string_buff , -DOUBLE , string_buff , -STRING_ , string_buff , -ID , string_buff , -FUNCT_ID , string_buff , -BUILTIN , string_buff , -IO_OUT , string_buff , -IO_IN, "<" , -PIPE, "|" , -DOLLAR, "$" , -FIELD, "$" , -0, (char *) 0 } ; - -/* if paren_cnt >0 and we see one of these, we are missing a ')' */ -static int missing_rparen[] = -{ EOF, NL, SEMI_COLON, SC_FAKE_SEMI_COLON, RBRACE, 0 } ; - -/* ditto for '}' */ -static int missing_rbrace[] = -{ EOF, BEGIN, END , 0 } ; - -static void missing( c, n , ln) - int c ; - char *n ; - int ln ; -{ char *s0, *s1 ; - - if ( pfile_name ) - { s0 = pfile_name ; s1 = ": " ; } - else s0 = s1 = "" ; - - errmsg(0, "%s%sline %u: missing %c near %s" ,s0, s1, ln, c, n) ; -} - -void yyerror(s) - char *s ; /* we won't use s as input - (yacc and bison force this). - We will use s for storage to keep lint or the compiler - off our back */ -{ struct token_str *p ; - int *ip ; - - s = (char *) 0 ; - - for ( p = token_str ; p->token ; p++ ) - if ( current_token == p->token ) - { s = p->str ; break ; } - - if ( ! s ) /* search the keywords */ - s = find_kw_str(current_token) ; - - if ( s ) - { - if ( paren_cnt ) - for( ip = missing_rparen ; *ip ; ip++) - if ( *ip == current_token ) - { missing(')', s, token_lineno) ; - paren_cnt = 0 ; - goto done ; - } - - if ( brace_cnt ) - for( ip = missing_rbrace ; *ip ; ip++) - if ( *ip == current_token ) - { missing('}', s, token_lineno) ; - brace_cnt = 0 ; - goto done ; - } - - compile_error("syntax error at or near %s", s) ; - - } - else /* special cases */ - switch ( current_token ) - { - case UNEXPECTED : - unexpected_char() ; - goto done ; - - case BAD_DECIMAL : - compile_error( - "syntax error in decimal constant %s", - string_buff ) ; - break ; - - case RE : - compile_error( - "syntax error at or near /%s/", - string_buff ) ; - break ; - - default : - compile_error("syntax error") ; - break ; - } - return ; - -done : - if ( ++compile_error_count == MAX_COMPILE_ERRORS ) mawk_exit(1) ; -} - - -/* generic error message with a hook into the system error - messages if errnum > 0 */ - -void errmsg VA_ALIST2(int , errnum, char *, format) - va_list args ; - - fprintf(stderr, "%s: " , progname) ; - - VA_START2(args, int, errnum, char *, format) ; - (void) vfprintf(stderr, format, args) ; - va_end(args) ; - - if ( errnum > 0 ) fprintf(stderr, " (%s)" , strerror(errnum) ) ; - - fprintf( stderr, "\n") ; -} - -void compile_error VA_ALIST(char *, format) - va_list args ; - char *s0, *s1 ; - - /* with multiple program files put program name in - error message */ - if ( pfile_name ) - { s0 = pfile_name ; s1 = ": " ; } - else - { s0 = s1 = "" ; } - - fprintf(stderr, "%s: %s%sline %u: " , progname, s0, s1,token_lineno) ; - VA_START(args, char *, format) ; - vfprintf(stderr, format, args) ; - va_end(args) ; - fprintf(stderr, "\n") ; - if ( ++compile_error_count == MAX_COMPILE_ERRORS ) mawk_exit(1) ; -} - -void rt_error VA_ALIST( char *, format) - va_list args ; - - fprintf(stderr, "%s: run time error: " , progname ) ; - VA_START(args, char *, format) ; - vfprintf(stderr, format, args) ; - va_end(args) ; - putc('\n',stderr) ; - rt_where() ; - mawk_exit(1) ; -} - - -void bozo(s) - char *s ; -{ - errmsg(0, "bozo: %s" , s) ; - mawk_exit(1) ; -} - -void overflow(s, size) - char *s ; unsigned size ; -{ - errmsg(0 , "program limit exceeded: %s size=%u", s, size) ; - mawk_exit(1) ; -} - - -/* print as much as we know about where a rt error occured */ - -static void rt_where() -{ - if ( FILENAME->type != C_STRING ) cast1_to_s(FILENAME) ; - if ( TEST2(NR) != TWO_DOUBLES ) cast2_to_d(NR) ; - - fprintf(stderr, "\tFILENAME=\"%s\"", string(FILENAME)->str) ; - if ( NR_flag ) - fprintf(stderr, " FNR=%g NR=%g" , FNR->dval, NR->dval) ; - - fprintf(stderr, "\n") ; -} - -/* run time */ -void rt_overflow(s, size) - char *s ; unsigned size ; -{ - errmsg(0 , "program limit exceeded: %s size=%u", s, size) ; - rt_where() ; - mawk_exit(1) ; -} - -static void unexpected_char() -{ int c = yylval.ival ; - - fprintf(stderr, "%s: %u: ", progname, token_lineno) ; - if ( c > ' ' && c < 127 ) - fprintf(stderr, "unexpected character '%c'\n" , c) ; - else - fprintf(stderr, "unexpected character 0x%02x\n" , c) ; -} - -static char *type_to_str( type ) - int type ; -{ char *retval ; - - switch( type ) - { - case ST_VAR : retval = "variable" ; break ; - case ST_ARRAY : retval = "array" ; break ; - case ST_FUNCT : retval = "function" ; break ; - case ST_LOCAL_VAR : retval = "local variable" ; break ; - case ST_LOCAL_ARRAY : retval = "local array" ; break ; - default : bozo("type_to_str") ; - } - return retval ; -} - -/* emit an error message about a type clash */ -void type_error(p) - SYMTAB *p ; -{ compile_error("illegal reference to %s %s", - type_to_str(p->type) , p->name) ; -} - - - - -#ifdef USE_SIMPLE_VFPRINTF - -/* a minimal vfprintf */ -int simple_vfprintf( fp, format, argp) - FILE *fp ; - char *format ; - va_list argp ; -{ - char *q , *p, *t ; - int l_flag ; - char xbuff[64] ; - - q = format ; - xbuff[0] = '%' ; - - while ( *q != 0 ) - { - if ( *q != '%' ) - { - putc(*q, fp) ; q++ ; continue ; - } - - /* mark the start with p */ - p = ++q ; t = xbuff + 1 ; - - if ( *q == '-' ) *t++ = *q++ ; - while ( scan_code[*(unsigned char*)q] == SC_DIGIT ) *t++ = *q++ ; - if ( *q == '.' ) - { *t++ = *q++ ; - while ( scan_code[*(unsigned char*)q] == SC_DIGIT ) *t++ = *q++ ; - } - - if ( *q == 'l' ) { l_flag = 1 ; *t++ = *q++ ; } - else l_flag = 0 ; - - - *t = *q++ ; t[1] = 0 ; - - switch( *t ) - { - case 'c' : - case 'd' : - case 'o' : - case 'x' : - case 'u' : - if ( l_flag ) fprintf(fp, xbuff, va_arg(argp,long) ) ; - else fprintf(fp, xbuff, va_arg(argp, int)) ; - break ; - - case 's' : - fprintf(fp, xbuff, va_arg(argp, char*)) ; - break ; - - case 'g' : - case 'f' : - fprintf(fp, xbuff, va_arg(argp, double)) ; - break ; - - default: - putc('%', fp) ; - q = p ; - break ; - } - } - return 0 ; /* shut up */ -} - -#endif /* USE_SIMPLE_VFPRINTF */ - - diff --git a/gnu/usr.bin/awk/execute.c b/gnu/usr.bin/awk/execute.c deleted file mode 100644 index 61106b64b169..000000000000 --- a/gnu/usr.bin/awk/execute.c +++ /dev/null @@ -1,1266 +0,0 @@ - -/******************************************** -execute.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: execute.c,v $ -/* Revision 1.2 1993/07/02 23:57:14 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.7.1.1 1993/01/15 03:33:39 mike - * patch3: safer double to int conversion - * - * Revision 5.7 1992/12/17 02:48:01 mike - * 1.1.2d changes for DOS - * - * Revision 5.6 1992/11/29 18:57:50 mike - * field expressions convert to long so 16 bit and 32 bit - * systems behave the same - * - * Revision 5.5 1992/08/11 15:24:55 brennan - * patch2: F_PUSHA and FE_PUSHA - * If this is preparation for g?sub(r,s,$expr) or (++|--) on $expr, - * then if expr > NF, make sure $expr is set to "" - * - * Revision 5.4 1992/08/11 14:51:54 brennan - * patch2: $expr++ is numeric even if $expr is string. - * I forgot to do this earlier when handling x++ case. - * - * Revision 5.3 1992/07/08 17:03:30 brennan - * patch 2 - * revert to version 1.0 comparisons, i.e. - * page 44-45 of AWK book - * - * Revision 5.2 1992/04/20 21:40:40 brennan - * patch 2 - * x++ is numeric, even if x is string - * - * Revision 5.1 1991/12/05 07:55:50 brennan - * 1.1 pre-release - * -*/ - - -#include "mawk.h" -#include "code.h" -#include "memory.h" -#include "symtype.h" -#include "field.h" -#include "bi_funct.h" -#include "bi_vars.h" -#include "regexp.h" -#include "repl.h" -#include "fin.h" -#include - -static int PROTO( compare, (CELL *) ) ; -static int PROTO( d_to_index, (double)) ; - -#if NOINFO_SIGFPE -static char dz_msg[] = "division by zero" ; -#endif - -#ifdef DEBUG -static void PROTO( eval_overflow, (void) ) ; - -#define inc_sp() if( ++sp == eval_stack+EVAL_STACK_SIZE )\ - eval_overflow() -#else - -/* If things are working, the eval stack should not overflow */ - -#define inc_sp() sp++ -#endif - -#define SAFETY 16 -#define DANGER (EVAL_STACK_SIZE-SAFETY) - -/* The stack machine that executes the code */ - -CELL eval_stack[EVAL_STACK_SIZE] ; -/* these can move for deep recursion */ -static CELL *stack_base = eval_stack ; -static CELL *stack_danger = eval_stack + DANGER ; - -#ifdef DEBUG -static void eval_overflow() -{ overflow("eval stack" , EVAL_STACK_SIZE) ; mawk_exit(1) ; } -#endif - -static INST *restart_label ; /* control flow labels */ -INST *next_label ; -static CELL tc ; /*useful temp */ - -void execute(cdp, sp, fp) - register INST *cdp ; /* code ptr, start execution here */ - register CELL *sp ; /* eval_stack pointer */ - CELL *fp ; /* frame ptr into eval_stack for - user defined functions */ -{ - /* some useful temporaries */ - CELL *cp ; - int t ; - - /* for moving the stack (deep recursion) */ - CELL *old_stack_base ; - CELL *old_sp ; - -#ifdef DEBUG - CELL *entry_sp = sp ; -#endif - - - if ( fp ) /* we are a function call, check for deep recursion */ - { - if (sp > stack_danger) - { /* change stacks */ - old_stack_base = stack_base ; - old_sp = sp ; - stack_base = (CELL *) zmalloc(sizeof(CELL)*EVAL_STACK_SIZE) ; - stack_danger = stack_base + DANGER ; - sp = stack_base ; - /* waste 1 slot for ANSI, actually LM_DOS breaks in - RET if we don't */ -#ifdef DEBUG - entry_sp = sp ; -#endif - } - else old_stack_base = (CELL*) 0 ; - } - - while ( 1 ) - switch( cdp++ -> op ) - { - -/* HALT only used by the disassemble now ; this remains - so compilers don't offset the jump table */ - case _HALT : - - case _STOP : /* only for range patterns */ -#ifdef DEBUG - if ( sp != entry_sp+1 ) bozo("stop0") ; -#endif - return ; - - case _PUSHC : - inc_sp() ; - (void) cellcpy(sp, cdp++ -> ptr) ; - break ; - - case _PUSHD : - inc_sp() ; - sp->type = C_DOUBLE ; - sp->dval = *(double*) cdp++->ptr ; - break ; - - case _PUSHS : - inc_sp() ; - sp->type = C_STRING ; - sp->ptr = cdp++->ptr ; - string(sp)->ref_cnt++ ; - break ; - - case F_PUSHA : - cp = (CELL*)cdp->ptr ; - if ( cp != field ) - { - if ( nf < 0 ) split_field0() ; - - if ( ! ( -#if LM_DOS - SAMESEG(cp,field) && -#endif - cp >= NF && cp <= LAST_PFIELD ) ) - { - /* its a real field $1, $2 ... - If its greater than $NF, we have to - make sure its set to "" so that - (++|--) and g?sub() work right - */ - t = field_addr_to_index(cp) ; - if ( t > nf ) - { - cell_destroy(cp) ; - cp->type = C_STRING ; - cp->ptr = (PTR) &null_str ; - null_str.ref_cnt++ ; - } - } - } - /* fall thru */ - - case _PUSHA : - case A_PUSHA : - inc_sp() ; - sp -> ptr = cdp++ -> ptr ; - break ; - - case _PUSHI : /* put contents of next address on stack*/ - inc_sp() ; - (void) cellcpy(sp, cdp++ -> ptr) ; - break ; - - case L_PUSHI : - /* put the contents of a local var on stack, - cdp->op holds the offset from the frame pointer */ - inc_sp() ; - (void) cellcpy(sp, fp + cdp++->op) ; - break ; - - case L_PUSHA : /* put a local address on eval stack */ - inc_sp() ; - sp->ptr = (PTR)(fp + cdp++->op) ; - break ; - - - case F_PUSHI : - - /* push contents of $i - cdp[0] holds & $i , cdp[1] holds i */ - - inc_sp() ; - if ( nf < 0 ) split_field0() ; - cp = (CELL *) cdp->ptr ; - t = (cdp+1)->op ; - cdp += 2 ; - - if ( t <= nf ) (void) cellcpy(sp, cp) ; - else /* an unset field */ - { sp->type = C_STRING ; - sp->ptr = (PTR) & null_str ; - null_str.ref_cnt++ ; - } - break ; - - case NF_PUSHI : - - inc_sp() ; - if ( nf < 0 ) split_field0() ; - (void) cellcpy(sp, NF) ; - break ; - - case FE_PUSHA : - - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - - t = d_to_index(sp->dval) ; - if ( t && nf < 0 ) split_field0() ; - sp->ptr = (PTR) field_ptr(t) ; - if ( t > nf ) - { - /* make sure its set to "" */ - cp = sp->ptr ; - cell_destroy(cp) ; - cp->type = C_STRING ; - cp->ptr = (PTR) &null_str ; - null_str.ref_cnt++ ; - } - break ; - - case FE_PUSHI : - - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - - t = d_to_index(sp->dval) ; - - if ( nf < 0) split_field0() ; - if ( t <= nf ) (void) cellcpy(sp, field_ptr(t)) ; - else - { sp->type = C_STRING ; - sp->ptr = (PTR) & null_str ; - null_str.ref_cnt++ ; - } - break ; - - - case AE_PUSHA : - /* top of stack has an expr, cdp->ptr points at an - array, replace the expr with the cell address inside - the array */ - - cp = array_find((ARRAY)cdp++->ptr, sp, CREATE) ; - cell_destroy(sp) ; - sp->ptr = (PTR) cp ; - break ; - - case AE_PUSHI : - /* top of stack has an expr, cdp->ptr points at an - array, replace the expr with the contents of the - cell inside the array */ - - cp = array_find((ARRAY) cdp++->ptr, sp, CREATE) ; - cell_destroy(sp) ; - (void) cellcpy(sp, cp) ; - break ; - - case LAE_PUSHI : - /* sp[0] is an expression - cdp->op is offset from frame pointer of a CELL which - has an ARRAY in the ptr field, replace expr - with array[expr] - */ - cp = array_find( (ARRAY)fp[cdp++->op].ptr, sp, CREATE) ; - cell_destroy(sp) ; - (void) cellcpy(sp, cp) ; - break ; - - case LAE_PUSHA : - /* sp[0] is an expression - cdp->op is offset from frame pointer of a CELL which - has an ARRAY in the ptr field, replace expr - with & array[expr] - */ - cp = array_find( (ARRAY)fp[cdp++->op].ptr, sp, CREATE) ; - cell_destroy(sp) ; - sp->ptr = (PTR) cp ; - break ; - - case LA_PUSHA : - /* cdp->op is offset from frame pointer of a CELL which - has an ARRAY in the ptr field. Push this ARRAY - on the eval stack - */ - inc_sp() ; - sp->ptr = fp[cdp++->op].ptr ; - break ; - - case SET_ALOOP : - { ALOOP_STATE *ap = (ALOOP_STATE *) - (cdp + cdp->op + 2)->ptr ; - - ap->var = (CELL *) sp[-1].ptr ; - ap->A = (ARRAY) sp->ptr ; - sp -= 2 ; - - ap->index = -1 ; - if ( inc_aloop_state(ap) ) cdp++ ; - else cdp += cdp->op + 3 ; - } - break ; - - case ALOOP : - - if ( inc_aloop_state( (ALOOP_STATE*) cdp[1].ptr ) ) - cdp += cdp->op ; - else cdp += 2 ; - break ; - - case _POP : - cell_destroy(sp) ; - sp-- ; - break ; - - case _DUP : - (void) cellcpy(sp+1, sp) ; - sp++ ; break ; - - case _ASSIGN : - /* top of stack has an expr, next down is an - address, put the expression in *address and - replace the address with the expression */ - - /* don't propagate type C_MBSTRN */ - if ( sp->type == C_MBSTRN ) check_strnum(sp) ; - sp-- ; - cell_destroy( ((CELL *)sp->ptr) ) ; - (void) cellcpy( sp, cellcpy(sp->ptr, sp+1) ) ; - cell_destroy(sp+1) ; - break ; - - case F_ASSIGN : /* assign to a field */ - if (sp->type == C_MBSTRN) check_strnum(sp) ; - sp-- ; - field_assign((CELL*)sp->ptr, sp+1) ; - cell_destroy(sp+1) ; - (void) cellcpy(sp, (CELL *) sp->ptr) ; - break ; - - case _ADD_ASG: - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - -#if SW_FP_CHECK /* specific to V7 and XNX23A */ - clrerr(); -#endif - cp->dval += sp-- -> dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - sp->type = C_DOUBLE ; - sp->dval = cp->dval ; - break ; - - case _SUB_ASG: - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; -#if SW_FP_CHECK - clrerr(); -#endif - cp->dval -= sp-- -> dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - sp->type = C_DOUBLE ; - sp->dval = cp->dval ; - break ; - - case _MUL_ASG: - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; -#if SW_FP_CHECK - clrerr(); -#endif - cp->dval *= sp-- -> dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - sp->type = C_DOUBLE ; - sp->dval = cp->dval ; - break ; - - case _DIV_ASG: - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - -#if NOINFO_SIGFPE - CHECK_DIVZERO(sp->dval) ; -#endif - -#if SW_FP_CHECK - clrerr(); -#endif - cp->dval /= sp-- -> dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - sp->type = C_DOUBLE ; - sp->dval = cp->dval ; - break ; - - case _MOD_ASG: - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - -#if NOINFO_SIGFPE - CHECK_DIVZERO(sp->dval) ; -#endif - - cp->dval = fmod(cp->dval,sp-- -> dval) ; - sp->type = C_DOUBLE ; - sp->dval = cp->dval ; - break ; - - case _POW_ASG: - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - cp->dval = pow(cp->dval,sp-- -> dval) ; - sp->type = C_DOUBLE ; - sp->dval = cp->dval ; - break ; - - /* will anyone ever use these ? */ - - case F_ADD_ASG : - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - cast1_to_d( cellcpy(&tc, cp) ) ; -#if SW_FP_CHECK - clrerr(); -#endif - tc.dval += sp-- -> dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - sp->type = C_DOUBLE ; - sp->dval = tc.dval ; - field_assign(cp, &tc) ; - break ; - - case F_SUB_ASG : - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - cast1_to_d( cellcpy(&tc, cp) ) ; -#if SW_FP_CHECK - clrerr(); -#endif - tc.dval -= sp-- -> dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - sp->type = C_DOUBLE ; - sp->dval = tc.dval ; - field_assign(cp, &tc) ; - break ; - - case F_MUL_ASG : - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - cast1_to_d( cellcpy(&tc, cp) ) ; -#if SW_FP_CHECK - clrerr(); -#endif - tc.dval *= sp-- -> dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - sp->type = C_DOUBLE ; - sp->dval = tc.dval ; - field_assign(cp, &tc) ; - break ; - - case F_DIV_ASG : - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - cast1_to_d( cellcpy(&tc, cp) ) ; - -#if NOINFO_SIGFPE - CHECK_DIVZERO(sp->dval) ; -#endif - -#if SW_FP_CHECK - clrerr(); -#endif - tc.dval /= sp-- -> dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - sp->type = C_DOUBLE ; - sp->dval = tc.dval ; - field_assign(cp, &tc) ; - break ; - - case F_MOD_ASG : - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - cast1_to_d( cellcpy(&tc, cp) ) ; - -#if NOINFO_SIGFPE - CHECK_DIVZERO(sp->dval) ; -#endif - - tc.dval = fmod(tc.dval, sp-- -> dval) ; - sp->type = C_DOUBLE ; - sp->dval = tc.dval ; - field_assign(cp, &tc) ; - break ; - - case F_POW_ASG : - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - cp = (CELL *) (sp-1)->ptr ; - cast1_to_d( cellcpy(&tc, cp) ) ; - tc.dval = pow(tc.dval, sp-- -> dval) ; - sp->type = C_DOUBLE ; - sp->dval = tc.dval ; - field_assign(cp, &tc) ; - break ; - - case _ADD : - sp-- ; - if ( TEST2(sp) != TWO_DOUBLES ) - cast2_to_d(sp) ; -#if SW_FP_CHECK - clrerr(); -#endif - sp[0].dval += sp[1].dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - break ; - - case _SUB : - sp-- ; - if ( TEST2(sp) != TWO_DOUBLES ) - cast2_to_d(sp) ; -#if SW_FP_CHECK - clrerr(); -#endif - sp[0].dval -= sp[1].dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - break ; - - case _MUL : - sp-- ; - if ( TEST2(sp) != TWO_DOUBLES ) - cast2_to_d(sp) ; -#if SW_FP_CHECK - clrerr(); -#endif - sp[0].dval *= sp[1].dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - break ; - - case _DIV : - sp-- ; - if ( TEST2(sp) != TWO_DOUBLES ) - cast2_to_d(sp) ; - -#if NOINFO_SIGFPE - CHECK_DIVZERO(sp[1].dval) ; -#endif - -#if SW_FP_CHECK - clrerr(); -#endif - sp[0].dval /= sp[1].dval ; -#if SW_FP_CHECK - fpcheck(); -#endif - break ; - - case _MOD : - sp-- ; - if ( TEST2(sp) != TWO_DOUBLES ) - cast2_to_d(sp) ; - -#if NOINFO_SIGFPE - CHECK_DIVZERO(sp[1].dval) ; -#endif - - sp[0].dval = fmod(sp[0].dval,sp[1].dval) ; - break ; - - case _POW : - sp-- ; - if ( TEST2(sp) != TWO_DOUBLES ) - cast2_to_d(sp) ; - sp[0].dval = pow(sp[0].dval,sp[1].dval) ; - break ; - - case _NOT : - reswitch_1: - switch( sp->type ) - { case C_NOINIT : - sp->dval = 1.0 ; break ; - case C_DOUBLE : - sp->dval = D2BOOL(sp->dval) ? 0.0 : 1.0 ; - break ; - case C_STRING : - sp->dval = string(sp)->len ? 0.0 : 1.0 ; - free_STRING(string(sp)) ; - break ; - case C_STRNUM : /* test as a number */ - sp->dval = D2BOOL(sp->dval) ? 0.0 : 1.0 ; - free_STRING(string(sp)) ; - break ; - case C_MBSTRN : - check_strnum(sp) ; - goto reswitch_1 ; - default : - bozo("bad type on eval stack") ; - } - sp->type = C_DOUBLE ; - break ; - - case _TEST : - reswitch_2: - switch( sp->type ) - { case C_NOINIT : - sp->dval = 0.0 ; break ; - case C_DOUBLE : - sp->dval = D2BOOL(sp->dval) ? 1.0 : 0.0 ; - break ; - case C_STRING : - sp->dval = string(sp)->len ? 1.0 : 0.0 ; - free_STRING(string(sp)) ; - break ; - case C_STRNUM : /* test as a number */ - sp->dval = D2BOOL(sp->dval) ? 1.0 : 0.0 ; - free_STRING(string(sp)) ; - break ; - case C_MBSTRN : - check_strnum(sp) ; - goto reswitch_2 ; - default : - bozo("bad type on eval stack") ; - } - sp->type = C_DOUBLE ; - break ; - - case _UMINUS : - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - sp->dval = - sp->dval ; - break ; - - case _UPLUS : - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - break ; - - case _CAT : - { unsigned len1, len2 ; - char *str1, *str2 ; - STRING *b ; - - sp-- ; - if ( TEST2(sp) != TWO_STRINGS ) - cast2_to_s(sp) ; - str1 = string(sp)->str ; - len1 = string(sp)->len ; - str2 = string(sp+1)->str ; - len2 = string(sp+1)->len ; - - b = new_STRING((char *)0, len1+len2) ; - (void) memcpy(b->str, str1, SIZE_T(len1)) ; - (void) memcpy(b->str + len1, str2, SIZE_T(len2)) ; - free_STRING(string(sp)) ; - free_STRING( string(sp+1) ) ; - - sp->ptr = (PTR) b ; - break ; - } - - case _PUSHINT : - inc_sp() ; - sp->type = cdp++ -> op ; - break ; - - case _BUILTIN : - case _PRINT : - sp = (* (PF_CP) cdp++ -> ptr) (sp) ; - break ; - - case _POST_INC : - cp = (CELL *)sp->ptr ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - sp->type = C_DOUBLE ; - sp->dval = cp->dval ; - cp->dval += 1.0 ; - break ; - - case _POST_DEC : - cp = (CELL *)sp->ptr ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - sp->type = C_DOUBLE ; - sp->dval = cp->dval ; - cp->dval -= 1.0 ; - break ; - - case _PRE_INC : - cp = (CELL *) sp->ptr ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - sp->dval = cp->dval += 1.0 ; - sp->type = C_DOUBLE ; - break ; - - case _PRE_DEC : - cp = (CELL *) sp->ptr ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - sp->dval = cp->dval -= 1.0 ; - sp->type = C_DOUBLE ; - break ; - - - case F_POST_INC : - cp = (CELL *) sp->ptr ; - (void) cellcpy(&tc, cp) ; - cast1_to_d(&tc) ; - sp->type = C_DOUBLE ; - sp->dval = tc.dval ; - tc.dval += 1.0 ; - field_assign(cp, &tc) ; - break ; - - case F_POST_DEC : - cp = (CELL *) sp->ptr ; - (void) cellcpy(&tc, cp) ; - cast1_to_d(&tc) ; - sp->type = C_DOUBLE ; - sp->dval = tc.dval ; - tc.dval -= 1.0 ; - field_assign(cp, &tc) ; - break ; - - case F_PRE_INC : - cp = (CELL *) sp->ptr ; - cast1_to_d(cellcpy(sp, cp)) ; - sp->dval += 1.0 ; - field_assign(cp, sp) ; - break ; - - case F_PRE_DEC : - cp = (CELL *) sp->ptr ; - cast1_to_d(cellcpy(sp, cp)) ; - sp->dval -= 1.0 ; - field_assign(cp, sp) ; - break ; - - case _JMP : - cdp += cdp->op ; - break ; - - case _JNZ : - /* jmp if top of stack is non-zero and pop stack */ - if ( test( sp ) ) - cdp += cdp->op ; - else cdp++ ; - cell_destroy(sp) ; - sp-- ; - break ; - - case _JZ : - /* jmp if top of stack is zero and pop stack */ - if ( ! test( sp ) ) - cdp += cdp->op ; - else cdp++ ; - cell_destroy(sp) ; - sp-- ; - break ; - - /* the relation operations */ - /* compare() makes sure string ref counts are OK */ - case _EQ : - t = compare(--sp) ; - sp->type = C_DOUBLE ; - sp->dval = t == 0 ? 1.0 : 0.0 ; - break ; - - case _NEQ : - t = compare(--sp) ; - sp->type = C_DOUBLE ; - sp->dval = t ? 1.0 : 0.0 ; - break ; - - case _LT : - t = compare(--sp) ; - sp->type = C_DOUBLE ; - sp->dval = t < 0 ? 1.0 : 0.0 ; - break ; - - case _LTE : - t = compare(--sp) ; - sp->type = C_DOUBLE ; - sp->dval = t <= 0 ? 1.0 : 0.0 ; - break ; - - case _GT : - t = compare(--sp) ; - sp->type = C_DOUBLE ; - sp->dval = t > 0 ? 1.0 : 0.0 ; - break ; - - case _GTE : - t = compare(--sp) ; - sp->type = C_DOUBLE ; - sp->dval = t >= 0 ? 1.0 : 0.0 ; - break ; - - case _MATCH0 : - /* does $0 match, the RE at cdp */ - - inc_sp() ; - if ( field->type >= C_STRING ) - { sp->type = C_DOUBLE ; - sp->dval = REtest(string(field)->str, cdp++->ptr) - ? 1.0 : 0.0 ; - - break /* the case */ ; - } - else - { - cellcpy(sp, field) ; - /* and FALL THRU */ - } - - case _MATCH1 : - /* does expr at sp[0] match RE at cdp */ - if ( sp->type < C_STRING ) cast1_to_s(sp) ; - t = REtest(string(sp)->str, cdp++->ptr) ; - free_STRING(string(sp)) ; - sp->type = C_DOUBLE ; - sp->dval = t ? 1.0 : 0.0 ; - break ; - - - case _MATCH2 : - /* does sp[-1] match sp[0] as re */ - cast_to_RE(sp) ; - - if ( (--sp)->type < C_STRING ) cast1_to_s(sp) ; - t = REtest(string(sp)->str, (sp+1)->ptr) ; - - free_STRING(string(sp)) ; - sp->type = C_DOUBLE ; - sp->dval = t ? 1.0 : 0.0 ; - break ; - - case A_TEST : - /* entry : sp[0].ptr-> an array - sp[-1] is an expression - - we compute expression in array */ - sp-- ; - cp = array_find( (sp+1)->ptr, sp, NO_CREATE) ; - cell_destroy(sp) ; - sp->type = C_DOUBLE ; - sp->dval = (cp!=(CELL*)0) ? 1.0 : 0.0 ; - break ; - - case A_DEL : - /* sp[0].ptr -> array - sp[-1] is an expr - delete array[expr] */ - - array_delete(sp->ptr, sp-1) ; - cell_destroy(sp-1) ; - sp -= 2 ; - break ; - - /* form a multiple array index */ - case A_CAT : - sp = array_cat(sp, cdp++->op) ; - break ; - - case _EXIT : - if ( sp->type != C_DOUBLE ) cast1_to_d(sp) ; - exit_code = d_to_i(sp->dval) ; - sp-- ; - /* fall thru */ - - case _EXIT0 : - if ( !(cdp = end_code.start) ) mawk_exit(exit_code) ; - - end_code.start = (INST *) 0 ; /* makes sure next exit exits */ - if ( begin_code.start ) - zfree(begin_code.start, begin_code.size) ; - if ( main_start ) zfree(main_start, main_size); - sp = eval_stack - 1 ; /* might be in user function */ - break ; - - case _JMAIN : /* go from BEGIN code to MAIN code */ - zfree(begin_code.start, begin_code.size) ; - begin_code.start = (INST *) 0 ; - cdp = main_start ; - break ; - - case _OMAIN : - if ( !main_fin ) open_main() ; - restart_label = cdp ; - cdp = next_label ; - break ; - - case _NEXT : - cdp = next_label ; - break ; - - case OL_GL : - { - char *p ; - unsigned len ; - - if ( !(p = FINgets(main_fin, &len)) ) - { - if ( !end_code.start ) mawk_exit(0) ; - - cdp = end_code.start ; - zfree(main_start, main_size) ; - main_start = end_code.start = (INST*) 0 ; - } - else - { set_field0(p, len) ; cdp = restart_label ; } - } - break ; - - case OL_GL_NR : - { - char *p ; - unsigned len ; - - if ( !(p = FINgets(main_fin, &len)) ) - { - if ( !end_code.start ) mawk_exit(0) ; - - cdp = end_code.start ; - zfree(main_start, main_size) ; - main_start = end_code.start = (INST*) 0 ; - } - else - { - set_field0(p, len) ; - cdp = restart_label ; - - if ( TEST2(NR) != TWO_DOUBLES ) cast2_to_d(NR) ; - - NR->dval += 1.0 ; - FNR->dval += 1.0 ; - } - } - break ; - - - case _RANGE : -/* test a range pattern: pat1, pat2 { action } - entry : - cdp[0].op -- a flag, test pat1 if on else pat2 - cdp[1].op -- offset of pat2 code from cdp - cdp[2].op -- offset of action code from cdp - cdp[3].op -- offset of code after the action from cdp - cdp[4] -- start of pat1 code -*/ - -#define FLAG cdp[0].op -#define PAT2 cdp[1].op -#define ACTION cdp[2].op -#define FOLLOW cdp[3].op -#define PAT1 4 - - if ( FLAG ) /* test again pat1 */ - { - execute(cdp + PAT1,sp, fp) ; - t = test(sp+1) ; - cell_destroy(sp+1) ; - if ( t ) FLAG = 0 ; - else - { cdp += FOLLOW ; - break ; /* break the switch */ - } - } - - /* test against pat2 and then perform the action */ - execute(cdp + PAT2, sp, fp) ; - FLAG = test(sp+1) ; - cell_destroy(sp+1) ; - cdp += ACTION ; - break ; - -/* function calls */ - - case _RET0 : - inc_sp() ; - sp->type = C_NOINIT ; - /* fall thru */ - - case _RET : - -#ifdef DEBUG - if ( sp != entry_sp+1 ) bozo("ret") ; -#endif - if ( old_stack_base ) /* reset stack */ - { - /* move the return value */ - (void) cellcpy(old_sp+1, sp) ; - cell_destroy(sp) ; - zfree(stack_base, sizeof(CELL)*EVAL_STACK_SIZE) ; - stack_base = old_stack_base ; - stack_danger = old_stack_base + DANGER ; - } - - return ; - - case _CALL : - - { FBLOCK *fbp = (FBLOCK*) cdp++->ptr ; - int a_args = cdp++->op ; /* actual number of args */ - CELL *nfp = sp - a_args + 1 ; /* new fp for callee */ - CELL *local_p = sp+1; /* first local argument on stack */ - char *type_p ; /* pts to type of an argument */ - - if ( fbp->nargs ) type_p = fbp->typev + a_args ; - - /* create space for locals */ - if ( t = fbp->nargs - a_args ) /* have local args */ - { - while ( t-- ) - { (++sp)->type = C_NOINIT ; - if ( *type_p++ == ST_LOCAL_ARRAY ) - sp->ptr = (PTR) new_ARRAY() ; - } - } - type_p-- ; /* *type_p is type of last arg */ - - execute(fbp->code, sp, nfp) ; - - /* cleanup the callee's arguments */ - if ( sp >= nfp ) - { - cp = sp+1 ; /* cp -> the function return */ - - do - { - if ( *type_p-- == ST_LOCAL_ARRAY ) - { if ( sp >= local_p ) array_free(sp->ptr) ; } - else cell_destroy(sp) ; - - } while ( --sp >= nfp ) ; - - (void) cellcpy(++sp, cp) ; - cell_destroy(cp) ; - } - else sp++ ; /* no arguments passed */ - } - break ; - - default : - bozo("bad opcode") ; - } -} - -int test( cp ) /* test if a cell is null or not */ - register CELL *cp ; -{ -reswitch : - - switch ( cp->type ) - { - case C_NOINIT : return 0 ; - case C_STRNUM : /* test as a number */ - case C_DOUBLE : return cp->dval != 0.0 ; - case C_STRING : return string(cp)->len ; - case C_MBSTRN : check_strnum(cp) ; goto reswitch ; - - default : - bozo("bad cell type in call to test") ; - } - return 0 ; /*can't get here: shutup */ -} - -/* compare cells at cp and cp+1 and - frees STRINGs at those cells -*/ -static int compare(cp) - register CELL *cp ; -{ int k ; - -reswitch : - - switch( TEST2(cp) ) - { case TWO_NOINITS : return 0 ; - - case TWO_DOUBLES : - two_d: - return cp->dval > (cp+1)->dval ? 1 : - cp->dval < (cp+1)->dval ? -1 : 0 ; - - case TWO_STRINGS : - case STRING_AND_STRNUM : - two_s: - k = strcmp(string(cp)->str, string(cp+1)->str) ; - free_STRING( string(cp) ) ; - free_STRING( string(cp+1) ) ; - return k ; - - case NOINIT_AND_DOUBLE : - case NOINIT_AND_STRNUM : - case DOUBLE_AND_STRNUM : - case TWO_STRNUMS : - cast2_to_d(cp) ; goto two_d ; - - case NOINIT_AND_STRING : - case DOUBLE_AND_STRING : - cast2_to_s(cp) ; goto two_s ; - - case TWO_MBSTRNS : - check_strnum(cp) ; check_strnum(cp+1) ; - goto reswitch ; - - case NOINIT_AND_MBSTRN : - case DOUBLE_AND_MBSTRN : - case STRING_AND_MBSTRN : - case STRNUM_AND_MBSTRN : - check_strnum( cp->type == C_MBSTRN ? cp : cp+1 ) ; - goto reswitch ; - - default : /* there are no default cases */ - bozo("bad cell type passed to compare") ; - } - return 0 ; /* shut up */ -} - -/* does not assume target was a cell, if so - then caller should have made a previous - call to cell_destroy */ - -CELL *cellcpy(target, source) - register CELL *target, *source ; -{ switch( target->type = source->type ) - { case C_NOINIT : - case C_SPACE : - case C_SNULL : - break ; - - case C_DOUBLE : - target->dval = source->dval ; - break ; - - case C_STRNUM : - target->dval = source->dval ; - /* fall thru */ - - case C_REPL : - case C_MBSTRN : - case C_STRING : - string(source)->ref_cnt++ ; - /* fall thru */ - - case C_RE : - target->ptr = source->ptr ; - break ; - - case C_REPLV : - (void) replv_cpy(target, source) ; - break ; - - default : - bozo("bad cell passed to cellcpy()") ; - break ; - } - return target ; -} - -#ifdef DEBUG - -void DB_cell_destroy(cp) /* HANGOVER time */ - register CELL *cp ; -{ - switch( cp->type ) - { case C_NOINIT : - case C_DOUBLE : break ; - - case C_MBSTRN : - case C_STRING : - case C_STRNUM : - if ( -- string(cp)->ref_cnt == 0 ) - zfree(string(cp) , string(cp)->len+STRING_OH) ; - break ; - - case C_RE : - bozo("cell destroy called on RE cell") ; - default : - bozo("cell destroy called on bad cell type") ; - } -} - -#endif - - - -/* convert a double d to a field index $d -> $i */ -static int -d_to_index( d ) - double d ; -{ - - if ( d > MAX_FIELD ) - rt_overflow("maximum number of fields", MAX_FIELD) ; - - if ( d >= 0.0 ) return (int) d ; - - /* might include nan */ - rt_error("negative field index $%.6g", d) ; - return 0 ; /* shutup */ -} diff --git a/gnu/usr.bin/awk/fcall.c b/gnu/usr.bin/awk/fcall.c deleted file mode 100644 index d8aee53d6964..000000000000 --- a/gnu/usr.bin/awk/fcall.c +++ /dev/null @@ -1,365 +0,0 @@ - -/******************************************** -fcall.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/*$Log: fcall.c,v $ -/*Revision 1.2 1993/07/02 23:57:16 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:55:54 brennan - * 1.1 pre-release - * -*/ - -#include "mawk.h" -#include "symtype.h" -#include "code.h" - -/* This file has functions involved with type checking of - function calls -*/ - -static FCALL_REC *PROTO(first_pass, (FCALL_REC *) ) ; -static CA_REC *PROTO(call_arg_check, (FBLOCK *, CA_REC *, - INST *, unsigned) ) ; -static int PROTO(arg_cnt_ok, (FBLOCK *,CA_REC *, unsigned) ) ; - - -static int check_progress ; - /* flag that indicates call_arg_check() was able to type - check some call arguments */ - -/* type checks a list of call arguments, - returns a list of arguments whose type is still unknown -*/ -static CA_REC *call_arg_check( callee, entry_list , start, line_no) - FBLOCK *callee ; - CA_REC *entry_list ; - INST *start ; /* to locate patch */ - unsigned line_no ; /* for error messages */ -{ register CA_REC *q ; - CA_REC *exit_list = (CA_REC *) 0 ; - - check_progress = 0 ; - - /* loop : - take q off entry_list - test it - if OK zfree(q) else put on exit_list - */ - - while ( q = entry_list ) - { - entry_list = q->link ; - - if ( q->type == ST_NONE ) - { /* try to infer the type */ - /* it might now be in symbol table */ - if ( q->sym_p->type == ST_VAR ) - { /* set type and patch */ - q->type = CA_EXPR ; - start[q->call_offset+1].ptr = (PTR) q->sym_p->stval.cp ; - } - else - if ( q->sym_p->type == ST_ARRAY ) - { q->type = CA_ARRAY ; - start[q->call_offset].op = A_PUSHA ; - start[q->call_offset+1].ptr = (PTR) q->sym_p->stval.array ; - } - else /* try to infer from callee */ - { - switch( callee->typev[q->arg_num] ) - { - case ST_LOCAL_VAR : - q->type = CA_EXPR ; - q->sym_p->type = ST_VAR ; - q->sym_p->stval.cp = new_CELL() ; - q->sym_p->stval.cp->type = C_NOINIT ; - start[q->call_offset+1].ptr = - (PTR) q->sym_p->stval.cp ; - break ; - - case ST_LOCAL_ARRAY : - q->type = CA_ARRAY ; - q->sym_p->type = ST_ARRAY ; - q->sym_p->stval.array = new_ARRAY() ; - start[q->call_offset].op = A_PUSHA ; - start[q->call_offset+1].ptr = - (PTR) q->sym_p->stval.array ; - break ; - } - } - } - else - if ( q->type == ST_LOCAL_NONE ) - { /* try to infer the type */ - if ( * q->type_p == ST_LOCAL_VAR ) - { /* set type , don't need to patch */ - q->type = CA_EXPR ; - } - else - if ( * q->type_p == ST_LOCAL_ARRAY ) - { q->type = CA_ARRAY ; - start[q->call_offset].op = LA_PUSHA ; - /* offset+1 op is OK */ - } - else /* try to infer from callee */ - { - switch( callee->typev[q->arg_num] ) - { - case ST_LOCAL_VAR : - q->type = CA_EXPR ; - * q->type_p = ST_LOCAL_VAR ; - /* do not need to patch */ - break ; - - case ST_LOCAL_ARRAY : - q->type = CA_ARRAY ; - * q->type_p = ST_LOCAL_ARRAY ; - start[q->call_offset].op = LA_PUSHA ; - break ; - } - } - } - - /* if we still do not know the type put on the new list - else type check */ - - if ( q->type == ST_NONE || q->type == ST_LOCAL_NONE ) - { - q->link = exit_list ; - exit_list = q ; - } - else /* type known */ - { - if ( callee->typev[q->arg_num] == ST_LOCAL_NONE ) - callee->typev[q->arg_num] = q->type ; - - else - if ( q->type != callee->typev[q->arg_num] ) - { - errmsg(0, "line %u: type error in arg(%d) in call to %s", - line_no, q->arg_num+1, callee->name) ; - if ( ++compile_error_count == MAX_COMPILE_ERRORS ) - mawk_exit(1) ; - } - - zfree(q, sizeof(CA_REC)) ; - check_progress = 1 ; - } - } /* while */ - - return exit_list ; -} - - -static int arg_cnt_ok( fbp, q, line_no ) - FBLOCK *fbp ; - CA_REC *q ; - unsigned line_no ; -{ - if ( q->arg_num >= fbp->nargs ) - { - errmsg(0, "line %u: too many arguments in call to %s" , - line_no, fbp->name ) ; - if ( ++compile_error_count == MAX_COMPILE_ERRORS ) - mawk_exit(1) ; - - return 0 ; - } - else return 1 ; -} - - -FCALL_REC *resolve_list ; - /* function calls whose arg types need checking - are stored on this list */ - - -/* on first pass thru the resolve list - we check : - if forward referenced functions were really defined - if right number of arguments - and compute call_start which is now known -*/ - -static FCALL_REC *first_pass( p ) - register FCALL_REC *p ; -{ FCALL_REC dummy ; - register FCALL_REC *q = &dummy ; /* trails p */ - - q->link = p ; - while ( p ) - { - if ( ! p->callee->code ) - { /* callee never defined */ - errmsg(0, "line %u: function %s never defined" , - p->line_no, p->callee->name) ; - if ( ++compile_error_count == MAX_COMPILE_ERRORS ) - mawk_exit(1) ; - /* delete p from list */ - q->link = p->link ; - /* don't worry about freeing memory, we'll exit soon */ - } - else /* note p->arg_list starts with last argument */ - if ( ! p->arg_list /* nothing to do */ || - ! p->arg_cnt_checked && - ! arg_cnt_ok(p->callee, p->arg_list, p->line_no) ) - { q->link = p->link ; /* delete p */ - /* the ! arg_list case is not an error so free memory */ - zfree(p, sizeof(FCALL_REC)) ; - } - else - { /* keep p and set call_start */ - q = p ; - switch ( p->call_scope ) - { - case SCOPE_MAIN : - p->call_start = main_start ; - break ; - - case SCOPE_BEGIN : - p->call_start = begin_code.start ; - break ; - - case SCOPE_END : - p->call_start = end_code.start ; - break ; - - case SCOPE_FUNCT : - p->call_start = p->call->code ; - break ; - } - } - p = q->link ; - } - return dummy.link ; -} - -/* continuously walk the resolve_list making type deductions - until this list goes empty or no more progress can be made - (An example where no more progress can be made is at end of file -*/ - -void resolve_fcalls() -{ register FCALL_REC *p, *old_list , *new_list ; - int progress ; /* a flag */ - - old_list = first_pass(resolve_list) ; - new_list = (FCALL_REC *) 0 ; - progress = 0 ; - - while ( 1 ) - { - if ( !(p = old_list) ) - { /* flop the lists */ - if ( !(p = old_list = new_list) /* nothing left */ - || ! progress /* can't do any more */ ) return ; - - /* reset after flop */ - new_list = (FCALL_REC *) 0 ; progress = 0 ; - } - - old_list = p->link ; - - if ( p->arg_list = call_arg_check(p->callee, p->arg_list , - p->call_start, p->line_no) ) - { - /* still have work to do , put on new_list */ - progress |= check_progress ; - p->link = new_list ; new_list = p ; - } - else /* done with p */ - { progress = 1 ; zfree(p, sizeof(FCALL_REC)) ; } - } -} - -/* the parser has just reduced a function call ; - the info needed to type check is passed in. If type checking - can not be done yet (most common reason -- function referenced - but not defined), a node is added to the resolve list. -*/ -void check_fcall( callee, call_scope, call, arg_list, line_no ) - FBLOCK *callee ; - int call_scope ; - FBLOCK *call ; - CA_REC *arg_list ; - unsigned line_no ; -{ - FCALL_REC *p ; - INST *call_start ; - - if ( ! callee->code ) - { /* forward reference to a function to be defined later */ - p = (FCALL_REC *) zmalloc(sizeof(FCALL_REC)) ; - p->callee = callee ; - p->call_scope = call_scope ; - p->call = call ; - p->arg_list = arg_list ; - p->arg_cnt_checked = 0 ; - p->line_no = line_no ; - /* add to resolve list */ - p->link = resolve_list ; resolve_list = p ; - } - else - if ( arg_list && arg_cnt_ok( callee, arg_list, line_no ) ) - { - switch ( call_scope ) - { - case SCOPE_MAIN : - call_start = main_start ; - break ; - - case SCOPE_BEGIN : - call_start = begin_code.start ; - break ; - - case SCOPE_END : - call_start = end_code.start ; - break ; - - case SCOPE_FUNCT : - call_start = call->code ; - break ; - } - - /* usually arg_list disappears here and all is well - otherwise add to resolve list */ - - if ( arg_list = call_arg_check(callee, arg_list, - call_start, line_no) ) - { - p = (FCALL_REC *) zmalloc(sizeof(FCALL_REC)) ; - p->callee = callee ; - p->call_scope = call_scope ; - p->call = call ; - p->arg_list = arg_list ; - p->arg_cnt_checked = 1 ; - p->line_no = line_no ; - /* add to resolve list */ - p->link = resolve_list ; resolve_list = p ; - } - } -} - - - -/* example where typing cannot progress - -{ f(z) } - -function f(x) { print NR } - -# this is legal, does something useful, but absurdly written -# We have to design so this works -*/ - diff --git a/gnu/usr.bin/awk/field.c b/gnu/usr.bin/awk/field.c deleted file mode 100644 index 918b5416a68d..000000000000 --- a/gnu/usr.bin/awk/field.c +++ /dev/null @@ -1,635 +0,0 @@ - -/******************************************** -field.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: field.c,v $ -/* Revision 1.2 1993/07/02 23:57:17 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.4.1.2 1993/01/20 12:53:08 mike - * d_to_l() - * - * Revision 5.4.1.1 1993/01/15 03:33:42 mike - * patch3: safer double to int conversion - * - * Revision 5.4 1992/11/29 22:52:11 mike - * double->string conversions uses long ints for 16/32 bit - * compatibility. - * Fixed small LM_DOS bozo. - * - * Revision 5.3 1992/08/17 14:21:10 brennan - * patch2: After parsing, only bi_sprintf() uses string_buff. - * - * Revision 5.2 1992/07/10 16:17:10 brennan - * MsDOS: remove NO_BINMODE macro - * - * Revision 5.1 1991/12/05 07:55:57 brennan - * 1.1 pre-release - * -*/ - - -/* field.c */ - -#include "mawk.h" -#include "field.h" -#include "init.h" -#include "memory.h" -#include "scan.h" -#include "bi_vars.h" -#include "repl.h" -#include "regexp.h" - -CELL field[FBANK_SZ+NUM_PFIELDS] ; - -CELL *fbank[NUM_FBANK] = {field} ; - -static int max_field = MAX_SPLIT ; /* maximum field actually created*/ - -static void PROTO( build_field0, (void) ) ; -static void PROTO( set_rs_shadow, (void) ) ; -static void PROTO( load_pfield, (char*, CELL*)) ; -static void PROTO( load_field_ov, (void)) ; - - - -/* a description of how to split based on RS. - If RS is changed, so is rs_shadow */ -SEPARATOR rs_shadow = {SEP_CHAR, '\n'} ; -/* a splitting CELL version of FS */ -CELL fs_shadow = {C_SPACE} ; -int nf ; - /* nf holds the true value of NF. If nf < 0 , then - NF has not been computed, i.e., $0 has not been split - */ - -static void set_rs_shadow() -{ CELL c ; - STRING *sval ; - char *s ; - unsigned len ; - - if ( posix_space_flag && mawk_state == EXECUTION ) - scan_code['\n'] = SC_UNEXPECTED ; - - if ( rs_shadow.type == SEP_STR ) free_STRING((STRING*) rs_shadow.ptr) ; - - cast_for_split( cellcpy(&c, RS) ) ; - switch( c.type ) - { - case C_RE : - if ( s = is_string_split(c.ptr, &len) ) - if ( len == 1 ) - { rs_shadow.type = SEP_CHAR ; - rs_shadow.c = s[0] ; - } - else - { rs_shadow.type = SEP_STR ; - rs_shadow.ptr = (PTR) new_STRING(s) ; - } - else - { rs_shadow.type = SEP_RE ; - rs_shadow.ptr = c.ptr ; - } - break ; - - case C_SPACE : - rs_shadow.type = SEP_CHAR ; - rs_shadow.c = ' ' ; - break ; - - case C_SNULL : /* RS becomes one or more blank lines */ - if ( mawk_state == EXECUTION ) scan_code['\n'] = SC_SPACE ; - rs_shadow.type = SEP_MLR ; - sval = new_STRING( "\n\n+" ) ; - rs_shadow.ptr = re_compile(sval) ; - free_STRING(sval) ; - break ; - - default : bozo("bad cell in set_rs_shadow") ; - } -} - -static void load_pfield(name, cp) - char *name ; - CELL *cp ; -{ SYMTAB *stp ; - - stp = insert(name) ; stp->type = ST_FIELD ; - stp->stval.cp = cp ; -} - -/* initialize $0 and the pseudo fields */ -void field_init() -{ - field[0].type = C_STRING ; - field[0].ptr = (PTR) & null_str ; - null_str.ref_cnt++ ; - - load_pfield("NF",NF) ; - NF->type = C_DOUBLE ; - NF->dval = 0.0 ; - - load_pfield("RS", RS) ; - RS->type = C_STRING ; - RS->ptr = (PTR) new_STRING( "\n" ) ; - /* rs_shadow already set */ - - load_pfield("FS", FS) ; - FS->type = C_STRING ; - FS->ptr = (PTR) new_STRING( " " ) ; - /* fs_shadow is already set */ - - load_pfield("OFMT", OFMT) ; - OFMT->type = C_STRING ; - OFMT->ptr = (PTR) new_STRING( "%.6g" ) ; - - load_pfield("CONVFMT", CONVFMT) ; - CONVFMT->type = C_STRING ; - CONVFMT->ptr = OFMT->ptr ; - string(OFMT)->ref_cnt++ ; -} - - - -void set_field0( s, len) - char *s ; - unsigned len ; -{ - cell_destroy( & field[0] ) ; - nf = -1 ; - - if ( len ) - { - field[0].type = C_MBSTRN ; - field[0].ptr = (PTR) new_STRING( (char *) 0, len) ; - (void) memcpy( string(&field[0])->str, s, SIZE_T(len) ) ; - } - else - { - field[0].type = C_STRING ; - field[0].ptr = (PTR) &null_str ; - null_str.ref_cnt++ ; - } -} - - - -/* split field[0] into $1, $2 ... and set NF */ - -void split_field0() -{ register CELL *cp ; - register int cnt ; - CELL c ; /* copy field[0] here if not string */ - - - if ( field[0].type < C_STRING ) - { cast1_to_s(cellcpy(&c, field+0)) ; - cp = &c ; - } - else cp = &field[0] ; - - if ( string(cp)->len == 0 ) nf = 0 ; - else - { - switch( fs_shadow.type ) - { - case C_SNULL : /* FS == "" */ - nf = 1 ; - cell_destroy(NF) ; - NF->type = C_DOUBLE ; - NF->dval = 1.0 ; - field[1].type = C_MBSTRN ; - field[1].ptr = cp->ptr ; - - if ( cp == field ) string(cp)->ref_cnt++ ; - /* else we gain one ref_cnt and lose one for a wash */ - - return ; - - case C_SPACE : - nf = space_split(string(cp)->str, string(cp)->len) ; - break ; - - default : - nf = re_split(string(cp)->str, fs_shadow.ptr) ; - break ; - } - - } - - cell_destroy(NF) ; - NF->type = C_DOUBLE ; - NF->dval = (double) nf ; - - if ( nf > MAX_SPLIT ) - { - cnt = MAX_SPLIT ; load_field_ov() ; - } - else cnt = nf ; - - while ( cnt > 0 ) - { - cell_destroy(field+cnt) ; - field[cnt].ptr = (PTR) split_buff[cnt-1] ; - field[cnt--].type = C_MBSTRN ; - } - - if ( cp == &c ) free_STRING( string(cp) ) ; -} - -/* - assign CELL *cp to field or pseudo field - and take care of all side effects -*/ - -void field_assign( fp, cp) - register CELL *fp ; - CELL *cp ; -{ - CELL c ; - int i , j ; - - /* the most common case first */ - if ( fp == field ) - { cell_destroy(field) ; - (void) cellcpy(fp, cp) ; - nf = -1 ; - return ; - } - - /* its not important to do any of this fast */ - - if ( nf < 0 ) split_field0() ; - -#if LM_DOS - if ( !SAMESEG(fp,field) ) - { - i = -1 ; - goto lm_dos_label ; - } -#endif - - switch( i = (fp - field) ) - { - - case NF_field : - - cell_destroy(NF) ; - (void) cellcpy(NF, cellcpy(&c,cp) ) ; - if ( c.type != C_DOUBLE ) cast1_to_d(&c) ; - - if ( (j = d_to_i(c.dval)) < 0 ) - rt_error("negative value assigned to NF") ; - - if ( j > nf ) - for ( i = nf+1 ; i <= j ; i++ ) - { - cp = field_ptr(i) ; - cell_destroy(cp) ; - cp->type = C_STRING ; - cp->ptr = (PTR) &null_str ; - null_str.ref_cnt++ ; - } - - nf = j ; - build_field0() ; - break ; - - case RS_field : - cell_destroy(RS) ; - (void) cellcpy(RS, cp) ; - set_rs_shadow() ; - break ; - - case FS_field : - cell_destroy(FS) ; - cast_for_split( cellcpy(&fs_shadow, cellcpy(FS, cp)) ) ; - break ; - - case OFMT_field : - case CONVFMT_field: - /* If the user does something stupid with OFMT or CONVFMT, - we could crash. - We'll make an attempt to protect ourselves here. This is - why OFMT and CONVFMT are pseudo fields. - - The ptrs of OFMT and CONVFMT always have a valid STRING, - even if assigned a DOUBLE or NOINIT - */ - - free_STRING( string(fp) ) ; - (void) cellcpy(fp, cp) ; - if ( fp->type < C_STRING ) /* !! */ - fp->ptr = (PTR) new_STRING( "%.6g" ) ; - else - if ( fp == CONVFMT ) - { - /* It's a string, but if it's really goofy and CONVFMT, - it could still damage us. Test it . - */ - char xbuff[512] ; - - xbuff[256] = 0 ; - (void) sprintf( xbuff, string(fp)->str, 3.1459) ; - if ( xbuff[256] ) - rt_error("CONVFMT assigned unusable value") ; - } - break ; - -#if LM_DOS -lm_dos_label : -#endif - - default: /* $1 or $2 or ... */ - - - cell_destroy(fp) ; - (void) cellcpy(fp, cp) ; - - if ( i < 0 || i > MAX_SPLIT ) i = field_addr_to_index(fp) ; - - if ( i > nf ) - { for ( j = nf+1 ; j < i ; j++ ) - { - cp = field_ptr(j) ; - cell_destroy(cp) ; - cp->type = C_STRING ; - cp->ptr = (PTR) &null_str ; - null_str.ref_cnt++ ; - } - nf = i ; - cell_destroy(NF) ; - NF->type = C_DOUBLE ; - NF->dval = (double) i ; - } - - build_field0() ; - - } -} - - -/* construct field[0] from the other fields */ - -static void build_field0() -{ - - -#ifdef DEBUG - if ( nf < 0 ) - bozo("nf <0 in build_field0") ; -#endif - - cell_destroy( field+0 ) ; - - if ( nf == 0 ) - { field[0].type = C_STRING ; - field[0].ptr = (PTR) &null_str ; - null_str.ref_cnt++ ; - } - else - if ( nf == 1 ) (void) cellcpy(field, field+1) ; - - else - { CELL c ; - STRING *ofs, *tail ; - unsigned len ; - register CELL *cp ; - register char *p, *q ; - int cnt ; - CELL **fbp, *cp_limit ; - - - cast1_to_s(cellcpy(&c,OFS)) ; - ofs = (STRING *) c.ptr ; - cast1_to_s(cellcpy(&c, field_ptr(nf))) ; - tail = (STRING *) c.ptr ; - cnt = nf-1 ; - - len = cnt*ofs->len + tail->len ; - - fbp = fbank ; cp_limit = field + FBANK_SZ ; - cp = field + 1 ; - - while ( cnt-- > 0 ) - { - if ( cp->type < C_STRING ) - { /* use the string field temporarily */ - if ( cp->type == C_NOINIT ) - { - cp->ptr = (PTR) &null_str ; - null_str.ref_cnt++ ; - } - else /* its a double */ - { - long ival ; - char xbuff[260] ; - - ival = d_to_l(cp->dval) ; - if ( ival == cp->dval ) - (void) sprintf(xbuff, INT_FMT, ival) ; - else - (void) sprintf(xbuff, string(CONVFMT)->str, cp->dval) ; - - cp->ptr = (PTR) new_STRING(xbuff) ; - } - } - - len += string(cp)->len ; - - if ( ++cp == cp_limit ) - { cp = * ++fbp ; cp_limit = cp + FBANK_SZ ; } - } - - field[0].type = C_STRING ; - field[0].ptr = (PTR) new_STRING((char *) 0, len) ; - - p = string(field)->str ; - - /* walk it again , putting things together */ - cnt = nf-1 ; fbp = fbank ; - cp = field+1 ; cp_limit = field + FBANK_SZ ; - - while ( cnt-- > 0 ) - { - (void) memcpy(p, string(cp)->str,SIZE_T(string(cp)->len)) ; - p += string(cp)->len ; - /* if not really string, free temp use of ptr */ - if ( cp->type < C_STRING ) free_STRING(string(cp)) ; - if ( ++cp == cp_limit ) - { cp = * ++fbp ; cp_limit = cp + FBANK_SZ ; } - - /* add the separator */ - q = ofs->str ; while( *q ) *p++ = *q++ ; - } - /* tack tail on the end */ - (void) memcpy(p, tail->str, SIZE_T(tail->len)) ; - - /* cleanup */ - free_STRING(tail) ; free_STRING(ofs) ; - } -} - -/* We are assigning to a CELL and we aren't sure if its - a field */ - -void slow_cell_assign(target, source) - register CELL *target ; - CELL *source ; -{ - if ( - -#if LM_DOS /* the dreaded segment nonsense */ - SAMESEG(target,field) && -#endif - target >= field && target <= LAST_PFIELD ) - field_assign(target, source) ; - else - { CELL **p = fbank + 1 ; - - while ( *p ) - { - if ( -#if LM_DOS - SAMESEG(target, *p) && -#endif - target >= *p && target < *p + FBANK_SZ ) - { - field_assign(target, source) ; - return ; - } - p++ ; - } - /* its not a field */ - cell_destroy(target) ; - (void) cellcpy(target, source) ; - } -} - -int field_addr_to_index(cp) - CELL *cp ; -{ CELL **p = fbank ; - - while( - -#if LM_DOS - ! SAMESEG(cp,*p) || -#endif - - cp < *p || cp >= *p + FBANK_SZ ) p++ ; - - return ((p-fbank)< MAX_SPLIT -*/ - -CELL *slow_field_ptr(i) - register int i ; -{ - - if ( i > max_field ) - { int j ; - - if ( i > MAX_FIELD ) - rt_overflow("maximum number of fields", MAX_FIELD) ; - - j = 1 ; while( fbank[j] ) j++ ; - do - { - fbank[j] = (CELL*)zmalloc(sizeof(CELL)*FBANK_SZ) ; - (void) memset(fbank[j], 0, SIZE_T(sizeof(CELL)*FBANK_SZ)) ; - j++ ; - max_field += FBANK_SZ ; - } - while ( i > max_field ) ; - } - - return & fbank[i>>FB_SHIFT][i & (FBANK_SZ-1)] ; -} - -/* - $0 split into more than MAX_SPLIT fields, - $(MAX_FIELD+1) ... are on the split_ov_list. - Copy into fields which start at fbank[1] -*/ - -static void load_field_ov() -{ - register SPLIT_OV *p ; /* walks split_ov_list */ - register CELL *cp ; /* target of copy */ - int j ; /* current fbank[] */ - CELL *cp_limit ; /* change fbank[] */ - SPLIT_OV *q ; /* trails p */ - - /* make sure the fields are allocated */ - (void) slow_field_ptr(nf) ; - - p = split_ov_list ; split_ov_list = (SPLIT_OV*) 0 ; - j = 1 ; cp = fbank[j] ; cp_limit = cp + FBANK_SZ ; - - while ( p ) - { - cell_destroy(cp) ; - cp->type = C_MBSTRN ; - cp->ptr = (PTR) p->sval ; - - if ( ++cp == cp_limit ) - { - cp = fbank[++j] ; cp_limit = cp + FBANK_SZ ; - } - - q = p ; p = p->link ; ZFREE(q) ; - } -} - - -#if MSDOS - -int binmode() /* read current value of BINMODE */ -{ CELL c ; - - cast1_to_d(cellcpy(&c, BINMODE)) ; - return d_to_i(c.dval) ; -} - -/* set BINMODE and RS and ORS - from environment or -W binmode= */ - -void set_binmode(x) - int x ; -{ - CELL c ; - - /* set RS */ - c.type = C_STRING ; - c.ptr = (PTR) new_STRING ( (x&1) ? "\r\n" : "\n" ) ; - field_assign(RS, &c) ; - free_STRING(string(&c)) ; - - /* set ORS */ - cell_destroy(ORS) ; - ORS->type = C_STRING ; - ORS->ptr = (PTR) new_STRING( (x&2) ? "\r\n" : "\n") ; - - cell_destroy(BINMODE) ; - BINMODE->type = C_DOUBLE ; - BINMODE->dval = (double) x ; -} - -#endif /* MSDOS */ - - diff --git a/gnu/usr.bin/awk/field.h b/gnu/usr.bin/awk/field.h deleted file mode 100644 index 4bd082511434..000000000000 --- a/gnu/usr.bin/awk/field.h +++ /dev/null @@ -1,100 +0,0 @@ - -/******************************************** -field.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: field.h,v $ -/* Revision 1.2 1993/07/02 23:57:19 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.2 1992/01/06 08:10:24 brennan - * set_binmode() proto for MSDOS - * - * Revision 5.1 91/12/05 07:59:16 brennan - * 1.1 pre-release - * -*/ - -/* field.h */ - - -#ifndef FIELD_H -#define FIELD_H 1 - -void PROTO( set_field0, (char *, unsigned) ) ; -void PROTO( split_field0, (void) ) ; -int PROTO( space_split, (char *, unsigned) ) ; -void PROTO( field_assign, (CELL*, CELL *) ) ; -char *PROTO( is_string_split, (PTR , unsigned *) ) ; -void PROTO( slow_cell_assign, (CELL*, CELL*)) ; -CELL *PROTO( slow_field_ptr, (int)) ; -int PROTO( field_addr_to_index, (CELL*)) ; -void PROTO( set_binmode, (int)) ; - - -#define NUM_PFIELDS 5 -extern CELL field[FBANK_SZ+NUM_PFIELDS] ; - /* $0, $1 ... $(MAX_SPLIT), NF, RS, RS, CONVFMT, OFMT */ - -/* more fields if needed go here */ -extern CELL *fbank[NUM_FBANK] ; /* fbank[0] == field */ - -/* index to CELL * for a field */ -#define field_ptr(i) ((i)<=MAX_SPLIT?field+(i):slow_field_ptr(i)) - -/* the pseudo fields, assignment has side effects */ -#define NF (field+MAX_SPLIT+1) /* must be first */ -#define RS (field+MAX_SPLIT+2) -#define FS (field+MAX_SPLIT+3) -#define CONVFMT (field+MAX_SPLIT+4) -#define OFMT (field+MAX_SPLIT+5) /* must be last */ - -#define LAST_PFIELD OFMT - -/* some compilers choke on (NF-field) in a case statement - even though it's constant so ... -*/ -#define NF_field (MAX_SPLIT+1) -#define RS_field (MAX_SPLIT+2) -#define FS_field (MAX_SPLIT+3) -#define CONVFMT_field (MAX_SPLIT+4) -#define OFMT_field (MAX_SPLIT+5) - - -extern int nf ; /* shadows NF */ - -/* a shadow type for RS and FS */ -#define SEP_SPACE 0 -#define SEP_CHAR 1 -#define SEP_STR 2 -#define SEP_RE 3 -#define SEP_MLR 4 - -typedef struct { -char type ; -char c ; -PTR ptr ; /* STRING* or RE machine* */ -} SEPARATOR ; - -extern SEPARATOR rs_shadow ; -extern CELL fs_shadow ; - - -/* types for splitting overflow */ - -typedef struct spov { -struct spov *link ; -STRING *sval ; -} SPLIT_OV ; - -extern SPLIT_OV *split_ov_list ; - - -#endif /* FIELD_H */ diff --git a/gnu/usr.bin/awk/files.c b/gnu/usr.bin/awk/files.c deleted file mode 100644 index 95b716337f62..000000000000 --- a/gnu/usr.bin/awk/files.c +++ /dev/null @@ -1,471 +0,0 @@ - -/******************************************** -files.c -copyright 1991, 1992. Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: files.c,v $ -/*Revision 1.2 1993/07/02 23:57:20 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.5 1992/12/17 02:48:01 mike - * 1.1.2d changes for DOS - * - * Revision 5.4 1992/07/10 16:10:30 brennan - * patch2 - * MsDOS: remove useless NO_BINMODE macro - * get process exit code on in pipes - * - * Revision 5.3 1992/04/07 20:21:17 brennan - * patch 2 - * unbuffered output to a tty - * - * Revision 5.2 1992/04/07 16:03:08 brennan - * patch 2 - * allow same filename for output and input, but use different descriptors - * E.g. < "/dev/tty" and > "/dev/tty" - * - * Revision 5.1 91/12/05 07:56:00 brennan - * 1.1 pre-release - * -*/ - -/* files.c */ - -#include "mawk.h" -#include "files.h" -#include "memory.h" -#include "fin.h" - -static FILE *PROTO(tfopen, (char*,char*)) ; -static void PROTO(add_to_child_list, (int,int)) ; -static struct child *PROTO(remove_from_child_list, (int)) ; -extern int PROTO(isatty, (int)) ; - -#ifdef V7 -#include /* defines FIOCLEX */ -#endif - - -#if HAVE_FCNTL_H - -#include -#define CLOSE_ON_EXEC(fd) (void) fcntl(fd, F_SETFD, 1) - -#else -#define CLOSE_ON_EXEC(fd) ioctl(fd, FIOCLEX, (PTR) 0) -#endif - - -/* We store dynamically created files on a linked linear - list with move to the front (big surprise) */ - -typedef struct file { -struct file *link ; -STRING *name ; -short type ; -int pid ; /* we need to wait() when we close a pipe */ - /* holds temp file index under MSDOS */ - -#if HAVE_FAKE_PIPES -int inpipe_exit ; -#endif - -PTR ptr ; /* FIN* or FILE* */ -} FILE_NODE ; - -static FILE_NODE *file_list ; - - -/* find a file on file_list */ -PTR file_find( sval, type ) - STRING *sval ; - int type ; -{ register FILE_NODE *p = file_list ; - FILE_NODE *q = (FILE_NODE *) 0 ; - char *name = sval->str ; - char *ostr ; - - while (1) - { - if ( !p ) /* open a new one */ - { - p = ZMALLOC(FILE_NODE) ; - switch( p->type = type ) - { - case F_TRUNC : -#if MSDOS - ostr = (binmode()&2) ? "wb" : "w" ; -#else - ostr = "w" ; -#endif - if ( !(p->ptr = (PTR) tfopen(name, ostr)) ) - goto out_failure ; - break ; - - case F_APPEND : -#if MSDOS - ostr = (binmode()&2) ? "ab" : "a" ; -#else - ostr = "a" ; -#endif - if ( !(p->ptr = (PTR) tfopen(name, ostr)) ) - goto out_failure ; - break ; - - case F_IN : - if ( !(p->ptr = (PTR) FINopen(name, 0)) ) - { zfree(p, sizeof(FILE_NODE)) ; return (PTR) 0 ; } - break ; - - case PIPE_OUT : - case PIPE_IN : - -#if HAVE_REAL_PIPES || HAVE_FAKE_PIPES - - if ( !(p->ptr = get_pipe(name, type, &p->pid)) ) - if ( type == PIPE_OUT ) goto out_failure ; - else - { zfree(p, sizeof(FILE_NODE) ) ; - return (PTR) 0 ; - } -#else - rt_error("pipes not supported") ; -#endif - break ; - -#ifdef DEBUG - default : - bozo("bad file type") ; -#endif - } - /* successful open */ - p->name = sval ; - sval->ref_cnt++ ; - break ; /* while loop */ - } - - /* search is by name and type */ - if ( strcmp(name, p->name->str) == 0 && - ( p->type == type || - /* no distinction between F_APPEND and F_TRUNC here */ - p->type >= F_APPEND && type >= F_APPEND )) - - { /* found */ - if ( !q ) /*at front of list */ - return p->ptr ; - /* delete from list for move to front */ - q->link = p->link ; - break ; /* while loop */ - } - q = p ; p = p->link ; - } /* end while loop */ - - /* put p at the front of the list */ - p->link = file_list ; - return (PTR) (file_list = p)->ptr ; - -out_failure: - errmsg(errno, "cannot open \"%s\" for output", name) ; - mawk_exit(1) ; - -} - - -/* Close a file and delete it's node from the file_list. - Walk the whole list, in case a name has two nodes, - e.g. < "/dev/tty" and > "/dev/tty" -*/ - -int file_close( sval ) - STRING *sval ; -{ register FILE_NODE *p = file_list ; - FILE_NODE *q = (FILE_NODE *) 0 ; /* trails p */ - FILE_NODE *hold ; - char *name = sval->str ; - int retval = -1 ; - - while ( p ) - if ( strcmp(name,p->name->str) == 0 ) /* found */ - { - switch( p->type ) - { - case F_TRUNC : - case F_APPEND : - (void) fclose((FILE *) p->ptr) ; - retval = 0 ; - break ; - - case PIPE_OUT : - (void) fclose((FILE *) p->ptr) ; - -#if HAVE_REAL_PIPES - retval = wait_for(p->pid) ; -#endif -#if HAVE_FAKE_PIPES - retval = close_fake_outpipe(p->name->str,p->pid) ; -#endif - break ; - - case F_IN : - FINclose((FIN *) p->ptr) ; - retval = 0 ; - break ; - - case PIPE_IN : - FINclose((FIN *) p->ptr) ; - -#if HAVE_REAL_PIPES - retval = wait_for(p->pid) ; -#endif -#if HAVE_FAKE_PIPES - { - char xbuff[100] ; - (void) unlink(tmp_file_name(p->pid,xbuff)) ; - retval = p->inpipe_exit ; - } -#endif - break ; - } - - free_STRING(p->name) ; - hold = p ; - if ( q ) q->link = p = p->link ; - else file_list = p = p->link ; - - ZFREE(hold) ; - } - else { q = p ; p = p->link ; } - - return retval ; -} - -/* When we exit, we need to close and wait for all output pipes */ - - -#if HAVE_REAL_PIPES - -void close_out_pipes() -{ register FILE_NODE *p = file_list ; - - while ( p ) - { if ( p->type == PIPE_OUT ) - { (void) fclose((FILE *) p->ptr) ; (void) wait_for(p->pid) ; } - p = p->link ; - } -} - -#else -#if HAVE_FAKE_PIPES /* pipes are faked with temp files */ - -void close_fake_pipes() -{ register FILE_NODE *p = file_list ; - char xbuff[100] ; - - /* close input pipes first to free descriptors for children */ - while ( p ) - { - if ( p->type == PIPE_IN ) - { FINclose((FIN *) p->ptr) ; - (void) unlink(tmp_file_name(p->pid,xbuff)) ; - } - p = p->link ; - } - /* doit again */ - p = file_list ; - while ( p ) - { - if ( p->type == PIPE_OUT ) - { - (void) fclose(p->ptr) ; - (void) close_fake_outpipe(p->name->str,p->pid) ; - } - p = p->link ; - } -} -#endif /* HAVE_FAKE_PIPES */ -#endif /* ! HAVE_REAL_PIPES */ - -/* hardwire to /bin/sh for portability of programs */ -char *shell = "/bin/sh" ; - -#if HAVE_REAL_PIPES - -PTR get_pipe( name, type, pid_ptr) - char *name ; - int type ; - int *pid_ptr ; -{ int the_pipe[2], local_fd, remote_fd ; - - if ( pipe(the_pipe) == -1 ) return (PTR) 0 ; - local_fd = the_pipe[type == PIPE_OUT] ; - remote_fd = the_pipe[type == PIPE_IN ] ; - /* to keep output ordered correctly */ - fflush(stdout) ; fflush(stderr) ; - - switch( *pid_ptr = fork() ) - { case -1 : - (void) close(local_fd) ; - (void) close(remote_fd) ; - return (PTR) 0 ; - - case 0 : - (void) close(local_fd) ; - (void) close(type == PIPE_IN) ; - (void) dup( remote_fd ) ; - (void) close( remote_fd ) ; - (void) execl(shell, shell, "-c", name, (char *) 0 ) ; - errmsg(errno, "failed to exec %s -c %s" , shell, name) ; - fflush(stderr) ; - _exit(128) ; - - default : - (void) close(remote_fd) ; - /* we could deadlock if future child inherit the local fd , - set close on exec flag */ - CLOSE_ON_EXEC(local_fd) ; - break ; - } - - return type == PIPE_IN ? (PTR) FINdopen(local_fd, 0) : - (PTR) fdopen(local_fd, "w") ; -} - - - -/*------------ children ------------------*/ - -/* we need to wait for children at the end of output pipes to - complete so we know any files they have created are complete */ - -/* dead children are kept on this list */ - -static struct child { -int pid ; -int exit_status ; -struct child *link ; -} *child_list ; - -static void add_to_child_list(pid, exit_status) - int pid, exit_status ; -{ register struct child *p = - (struct child *) zmalloc(sizeof(struct child)) ; - - p->pid = pid ; p->exit_status = exit_status ; - p->link = child_list ; child_list = p ; -} - -static struct child *remove_from_child_list(pid) - int pid ; -{ register struct child *p = child_list ; - struct child *q = (struct child *) 0 ; - - while ( p ) - if ( p->pid == pid ) - { - if ( q ) q->link = p->link ; - else child_list = p->link ; - break ; - } - else { q = p ; p = p->link ; } - - return p ; /* null return if not in the list */ -} - - -/* wait for a specific child to complete and return its - exit status - - If pid is zero, wait for any single child -*/ - -int wait_for(pid) - int pid ; -{ int exit_status ; - struct child *p ; - int id ; - - if ( pid == 0 ) - { - id = wait(&exit_status) ; - add_to_child_list(id, exit_status) ; - } - else - /* see if an earlier wait() caught our child */ - if ( p = remove_from_child_list(pid) ) - { exit_status = p->exit_status ; - ZFREE(p) ; - } - else /* need to really wait */ - while ( (id = wait(&exit_status)) != pid ) - if ( id == -1 ) /* can't happen */ bozo("wait_for") ; - else - { /* we got the exit status of another child - put it on the child list and try again */ - add_to_child_list(id, exit_status ) ; - } - - if ( exit_status & 0xff ) - exit_status = 128 + (exit_status & 0xff) ; - else exit_status = (exit_status & 0xff00)>>8 ; - - return exit_status ; -} - -#endif /* HAVE_REAL_PIPES */ -void set_stderr() -{ - file_list = ZMALLOC(FILE_NODE) ; - file_list->link = (FILE_NODE*) 0 ; - file_list->type = F_TRUNC ; - file_list->name = new_STRING("/dev/stderr") ; - file_list->ptr = (PTR) stderr ; -} - -/* fopen() but no buffering to ttys */ -static FILE *tfopen(name, mode) - char *name, *mode ; -{ - FILE *retval = fopen(name,mode) ; - - if ( retval ) - { - if ( isatty(fileno(retval)) ) setbuf(retval, (char*)0) ; - else - { -#if LM_DOS - enlarge_output_buffer(retval) ; -#endif - } - } - return retval ; -} - -#if LM_DOS -void enlarge_output_buffer( fp ) - FILE *fp ; -{ - if ( setvbuf(fp, (char*) 0, _IOFBF, BUFFSZ) < 0 ) - { - errmsg(errno, "setvbuf failed on fileno %d", fileno(fp)) ; - mawk_exit(1) ; - } -} -#endif - -#if MSDOS -void -stdout_init() -{ -#if LM_DOS - if ( ! isatty(1) ) enlarge_output_buffer(stdout) ; -#endif - if ( binmode() & 2 ) { setmode(1,O_BINARY) ; setmode(2,O_BINARY) ; } -} -#endif /* MSDOS */ diff --git a/gnu/usr.bin/awk/files.h b/gnu/usr.bin/awk/files.h deleted file mode 100644 index 022a8b49e239..000000000000 --- a/gnu/usr.bin/awk/files.h +++ /dev/null @@ -1,57 +0,0 @@ - -/******************************************** -files.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: files.h,v $ -/*Revision 1.2 1993/07/02 23:57:22 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.2 1992/12/17 02:48:01 mike - * 1.1.2d changes for DOS - * - * Revision 5.1 1991/12/05 07:59:18 brennan - * 1.1 pre-release - * -*/ - -#ifndef FILES_H -#define FILES_H - -/* IO redirection types */ -#define F_IN (-5) -#define PIPE_IN (-4) -#define PIPE_OUT (-3) -#define F_APPEND (-2) -#define F_TRUNC (-1) - -extern char *shell ; /* for pipes and system() */ - -PTR PROTO(file_find, (STRING *, int)) ; -int PROTO(file_close, (STRING *)) ; -PTR PROTO(get_pipe, (char *, int, int *) ) ; -int PROTO(wait_for, (int) ) ; -void PROTO( close_out_pipes, (void) ) ; - -#if HAVE_FAKE_PIPES -void PROTO(close_fake_pipes, (void)) ; -int PROTO(close_fake_outpipe, (char *,int)) ; -char *PROTO(tmp_file_name, (int, char*)) ; -#endif - -#if MSDOS -int PROTO(DOSexec, (char *)) ; -int PROTO(binmode, (void)) ; -void PROTO(set_binmode, (int)) ; -void PROTO(enlarge_output_buffer, (FILE*)) ; -#endif - - -#endif diff --git a/gnu/usr.bin/awk/fin.c b/gnu/usr.bin/awk/fin.c deleted file mode 100644 index 48decc652a6c..000000000000 --- a/gnu/usr.bin/awk/fin.c +++ /dev/null @@ -1,529 +0,0 @@ - -/******************************************** -fin.c -copyright 1991, 1992. Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: fin.c,v $ -/*Revision 1.2 1993/07/02 23:57:23 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.6 1992/12/17 02:48:01 mike - * 1.1.2d changes for DOS - * - * Revision 5.5 1992/07/28 15:11:30 brennan - * minor change in finding eol, needed for MsDOS - * - * Revision 5.4 1992/07/10 16:17:10 brennan - * MsDOS: remove NO_BINMODE macro - * - * Revision 5.3 1992/07/08 16:14:27 brennan - * FILENAME and FNR retain last values in the - * END block. - * - * Revision 5.2 1992/02/21 13:30:08 brennan - * fixed bug that free'd FILENAME twice if - * command line was var=value only - * - * Revision 5.1 91/12/05 07:56:02 brennan - * 1.1 pre-release - * -*/ - -/* fin.c */ - -#include "mawk.h" -#include "fin.h" -#include "memory.h" -#include "bi_vars.h" -#include "field.h" -#include "symtype.h" -#include "scan.h" - -#if HAVE_FCNTL_H -#include -#endif - -/* This file handles input files. Opening, closing, - buffering and (most important) splitting files into - records, FINgets(). -*/ - -#ifndef MSDOS_MSC -extern int errno ; -#endif -int PROTO(isatty, (int) ) ; - -static FIN *PROTO( next_main, (int) ) ; -static char *PROTO( enlarge_fin_buffer, (FIN *) ) ; -static void PROTO(set_main_to_stdin, (void) ) ; -int PROTO( is_cmdline_assign, (char *) ) ; /* also used by init */ - -FIN *FINdopen( fd, main_flag ) - int fd , main_flag ; -{ register FIN *fin = (FIN *) zmalloc( sizeof(FIN) ) ; - - fin->fd = fd ; - fin->flags = main_flag ? (MAIN_FLAG|START_FLAG) : START_FLAG ; - fin->buffp = fin->buff = (char *) zmalloc(BUFFSZ+1) ; - fin->nbuffs = 1 ; - fin->buff[0] = 0 ; - - if ( isatty(fd) && rs_shadow.type == SEP_CHAR - && rs_shadow.c == '\n' ) - { - /* interactive, i.e., line buffer this file */ - if ( fd == 0 ) fin->fp = stdin ; - else - if ( !(fin->fp = fdopen(fd, "r")) ) - { errmsg(errno, "fdopen failed") ; exit(1) ; } - } - else fin->fp = (FILE *) 0 ; - - return fin ; -} - -FIN *FINopen( filename, main_flag ) - char *filename ; - int main_flag ; -{ int fd ; - int oflag = O_RDONLY ; - -#if MSDOS - int bm = binmode() & 1 ; - if ( bm ) oflag |= O_BINARY ; -#endif - - if ( filename[0] == '-' && filename[1] == 0 ) - { -#if MSDOS - if ( bm ) setmode(0, O_BINARY) ; -#endif - return FINdopen(0, main_flag) ; - } - -#ifdef THINK_C - if ( (fd = open( filename , oflag )) == -1 ) -#else - if ( (fd = open( filename , oflag, 0 )) == -1 ) -#endif - { errmsg( errno, "cannot open %s" , filename ) ; - return (FIN *) 0 ; } - - return FINdopen( fd, main_flag ) ; -} - -/* frees the buffer and fd, but leaves FIN structure until - the user calls close() */ - -void FINsemi_close(fin) - register FIN *fin ; -{ static char dead = 0 ; - - if ( fin->buff != &dead ) - { - zfree(fin->buff, fin->nbuffs*BUFFSZ + 1) ; - - if ( fin->fd ) - if ( fin->fp ) (void) fclose(fin->fp) ; - else (void) close(fin->fd) ; - - fin->buff = fin->buffp = &dead ; /* marks it semi_closed */ - } - /* else was already semi_closed */ -} - -/* user called close() on input file */ -void FINclose( fin ) - FIN *fin ; -{ - FINsemi_close(fin) ; - zfree( fin , sizeof(FIN) ) ; -} - -/* return one input record as determined by RS, - from input file (FIN) fin -*/ - -char *FINgets( fin, len_p ) - FIN *fin ; - unsigned *len_p ; -{ register char *p, *q ; - unsigned match_len ; - unsigned r ; - -restart : - - if ( ! (p = fin->buffp)[0] ) /* need a refill */ - { - if ( fin->flags & EOF_FLAG ) - if ( fin->flags & MAIN_FLAG ) - { fin = next_main(0) ; goto restart ; } - else - { *len_p = 0 ; return (char *) 0 ; } - - if ( fin->fp ) /* line buffering */ - if ( ! fgets(fin->buff, BUFFSZ+1, fin->fp) ) - { - fin->flags |= EOF_FLAG ; - fin->buff[0] = 0 ; - fin->buffp = fin->buff ; - goto restart ; /* might be main_fin */ - } - else /* return this line */ - { - /* find eol */ - p = fin->buff ; - while ( *p != '\n' && *p != 0 ) p++ ; - - *p = 0 ; *len_p = p - fin->buff ; - fin->buffp = p ; -#ifdef THINK_C - /* - * I still don't understand why this is needed, unless fgets() - * also does this conversion internally for no good reason. :-( - */ - for ( p = fin->buff ; *p ; ++p ) - { - if (*p == '\n') *p = '\r'; - else if (*p == '\r') *p = '\n'; - } -#endif - return fin->buff ; - } - else /* block buffering */ - { - if ( (r = fillbuff(fin->fd, fin->buff, fin->nbuffs*BUFFSZ)) == 0 ) - { - fin->flags |= EOF_FLAG ; - fin->buffp = fin->buff ; - goto restart ; /* might be main */ - } - else - if ( r < fin->nbuffs*BUFFSZ ) fin->flags |= EOF_FLAG ; - - p = fin->buffp = fin->buff ; - - if ( fin->flags & START_FLAG ) - { - fin->flags &= ~START_FLAG ; - if ( rs_shadow.type == SEP_MLR ) - { /* trim blank lines from front of file */ - while ( *p == '\n' ) p++ ; - fin->buffp = p ; - if ( *p == 0 ) goto restart ; - } - } - } - } - -retry: - - switch( rs_shadow.type ) - { - case SEP_CHAR : - q = strchr(p, rs_shadow.c) ; - match_len = 1 ; - break ; - - case SEP_STR : - q = str_str(p, ((STRING *) rs_shadow.ptr)->str, - match_len = ((STRING *) rs_shadow.ptr)->len ) ; - break ; - - case SEP_MLR : - case SEP_RE : - q = re_pos_match(p, rs_shadow.ptr, &match_len) ; - /* if the match is at the end, there might still be - more to match in the file */ - if ( q && q[match_len] == 0 && ! (fin->flags & EOF_FLAG)) - q = (char *) 0 ; - break ; - - default : - bozo("type of rs_shadow") ; - } - - if ( q ) - { /* the easy and normal case */ - *q = 0 ; *len_p = q - p ; - fin->buffp = q + match_len ; - return p ; - } - - if ( fin->flags & EOF_FLAG ) - { /* last line without a record terminator */ - *len_p = r = strlen(p) ; fin->buffp = p+r ; - - if ( rs_shadow.type == SEP_MLR && fin->buffp[-1] == '\n' - && r != 0 ) - { (*len_p)-- ; * -- fin->buffp = 0 ; } - return p ; - } - - if ( p == fin->buff ) - { /* current record is too big for the input buffer, grow buffer */ - p = enlarge_fin_buffer(fin) ; - } - else - { - /* move a partial line to front of buffer and try again */ - unsigned rr ; - - p = (char *) memcpy( fin->buff, p, SIZE_T(r = strlen(p)) ) ; - q = p+r ; rr = fin->nbuffs*BUFFSZ - r ; - - if ( (r = fillbuff(fin->fd, q, rr)) < rr ) fin->flags |= EOF_FLAG ; - } - goto retry ; -} - -static char *enlarge_fin_buffer(fin) - FIN *fin ; -{ - unsigned r ; - unsigned oldsize = fin->nbuffs*BUFFSZ+1 ; - -#if LM_DOS - /* I'm not sure this can really happen: - avoid "16bit wrap" */ - if ( fin->nbuffs == MAX_BUFFS ) - { - errmsg(0, "out of input buffer space") ; - mawk_exit(1) ; - } -#endif - - fin->buffp = - fin->buff = (char *) zrealloc(fin->buff, oldsize, oldsize+BUFFSZ); - fin->nbuffs++ ; - - r = fillbuff(fin->fd, fin->buff + (oldsize-1) , BUFFSZ ) ; - if ( r < BUFFSZ ) fin->flags |= EOF_FLAG ; - - return fin->buff ; -} - -/*-------- - target is big enough to hold size + 1 chars - on exit the back of the target is zero terminated - *--------------*/ -unsigned fillbuff(fd, target, size) - int fd ; - register char *target ; - unsigned size ; -{ register int r ; - unsigned entry_size = size ; -#ifdef THINK_C - register char *p = target; -#endif - - while ( size ) - switch( r = read(fd, target, size) ) - { case -1 : - errmsg(errno, "read error") ; - exit(1) ; - - case 0 : - goto out ; - - default : - target += r ; size -= r ; - break ; - } - -out : - *target = 0 ; -#ifdef THINK_C - /* - * I still don't understand why this is needed, unless read() also does - * this conversion internally for no good reason. :-( - */ - for ( ; *p ; ++p ) - { - if (*p == '\r') - *p = '\n'; - else if (*p == '\n') - *p = '\r'; - } -#endif - return entry_size - size ; -} - -/* main_fin is a handle to the main input stream - == 0 never been opened */ - -FIN *main_fin ; -ARRAY Argv ; /* to the user this is ARGV */ -static double argi = 1.0 ; /* index of next ARGV[argi] to try to open */ - - -static void set_main_to_stdin() -{ - cell_destroy( FILENAME ) ; - FILENAME->type = C_STRING ; - FILENAME->ptr = (PTR) new_STRING( "-") ; - cell_destroy(FNR) ; - FNR->type = C_DOUBLE ; - FNR->dval = 0.0 ; - main_fin = FINdopen(0, 1) ; -} - - -/* this gets called once to get the input stream going. - It is called after the execution of the BEGIN block - unless there is a getline inside BEGIN {} -*/ -void open_main() -{ CELL argc ; - -#if MSDOS - int k = binmode() ; - - if ( k & 1 ) setmode(0, O_BINARY) ; - if ( k & 2 ) { setmode(1,O_BINARY) ; setmode(2,O_BINARY) ; } -#endif - - (void) cellcpy(&argc, ARGC) ; - if ( argc.type != C_DOUBLE ) cast1_to_d(&argc) ; - - if ( argc.dval == 1.0 ) set_main_to_stdin() ; - else (void) next_main(1) ; -} - -/* get the next command line file open */ -static FIN *next_main(open_flag) - int open_flag ; /* called by open_main() if on */ -{ - register CELL *cp ; - CELL argc ; /* copy of ARGC */ - CELL c_argi ; /* cell copy of argi */ - CELL argval ; /* copy of ARGV[c_argi] */ - - - argval.type = C_NOINIT ; - c_argi.type = C_DOUBLE ; - - if ( main_fin ) FINclose(main_fin) ; - /* FILENAME and FNR don't change unless we really open - a new file */ - - /* make a copy of ARGC to avoid side effect */ - if ( cellcpy(&argc, ARGC)->type != C_DOUBLE ) - cast1_to_d(&argc) ; - - while ( argi < argc.dval ) - { - c_argi.dval = argi ; - argi += 1.0 ; - - if ( !(cp = array_find( Argv, &c_argi, NO_CREATE)) ) - continue ; /* its deleted */ - - /* make a copy so we can cast w/o side effect */ - cell_destroy(&argval) ; - cp = cellcpy(&argval, cp) ; - if ( cp->type < C_STRING ) cast1_to_s(cp) ; - if ( string(cp)->len == 0 ) continue ; - /* file argument is "" */ - - /* it might be a command line assignment */ - if ( is_cmdline_assign(string(cp)->str) ) continue ; - - /* try to open it -- we used to continue on failure, - but posix says we should quit */ - if ( ! (main_fin = FINopen( string(cp)->str, 1 )) ) mawk_exit(1) ; - - /* success -- set FILENAME and FNR */ - cell_destroy(FILENAME) ; - (void) cellcpy(FILENAME , cp ) ; - free_STRING( string(cp) ) ; - cell_destroy(FNR) ; - FNR->type = C_DOUBLE ; - FNR->dval = 0.0 ; - - return main_fin ; - } - /* failure */ - cell_destroy(&argval) ; - - if ( open_flag ) /* all arguments were null or assignment */ - { set_main_to_stdin() ; return main_fin ; } - - /* real failure */ - { /* this is how we mark EOF on main_fin */ - static char dead_buff = 0 ; - static FIN dead_main = {0, (FILE*)0, &dead_buff, &dead_buff, - 1, EOF_FLAG} ; - - return main_fin = &dead_main ; - /* since MAIN_FLAG is not set, FINgets won't call next_main() */ - } -} - - -int is_cmdline_assign(s) - char *s ; -{ - register char *p ; - int c ; - SYMTAB *stp ; - CELL *cp ; - unsigned len ; - CELL cell ; /* used if command line assign to pseudo field */ - CELL *fp = (CELL *) 0 ; /* ditto */ - - if ( scan_code[*(unsigned char *)s] != SC_IDCHAR ) return 0 ; - - p = s+1 ; - while ( (c = scan_code[*(unsigned char*)p]) == SC_IDCHAR - || c == SC_DIGIT ) p++ ; - - if ( *p != '=' ) return 0 ; - - *p = 0 ; - stp = find(s) ; - - switch( stp->type ) - { - case ST_NONE : - stp->type = ST_VAR ; - stp->stval.cp = cp = new_CELL() ; - break ; - - case ST_VAR : - case ST_NR : /* !! no one will do this */ - cp = stp->stval.cp ; - cell_destroy(cp) ; - break ; - - case ST_FIELD : - /* must be pseudo field */ - fp = stp->stval.cp ; - cp = &cell ; - break ; - - default : - rt_error( - "cannot command line assign to %s\n\ttype clash or keyword" - , s ) ; - } - - /* we need to keep ARGV[i] intact */ - *p++ = '=' ; - len = strlen(p)+1 ; - /* posix says escape sequences are on from command line */ - p = rm_escape( strcpy((char*)zmalloc(len), p) ) ; - cp->ptr = (PTR) new_STRING(p) ; - zfree(p,len) ; - check_strnum(cp) ; /* sets cp->type */ - if ( fp ) /* move it from cell to pfield[] */ - { field_assign(fp, cp) ; free_STRING(string(cp)) ; } - return 1 ; -} diff --git a/gnu/usr.bin/awk/fin.h b/gnu/usr.bin/awk/fin.h deleted file mode 100644 index 4cb9564bf60e..000000000000 --- a/gnu/usr.bin/awk/fin.h +++ /dev/null @@ -1,56 +0,0 @@ - -/******************************************** -fin.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: fin.h,v $ -/*Revision 1.2 1993/07/02 23:57:24 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.2 1992/01/06 08:16:24 brennan - * setmode() proto for MSDOS - * - * Revision 5.1 91/12/05 07:59:20 brennan - * 1.1 pre-release - * -*/ - -/* fin.h */ - -#ifndef FIN_H -#define FIN_H -/* structure to control input files */ - -typedef struct { -int fd ; -FILE *fp ; /* NULL unless interactive */ -char *buff ; -char *buffp ; -unsigned nbuffs ; /* sizeof *buff in BUFFSZs */ -int flags ; -} FIN ; - -#define MAIN_FLAG 1 /* part of main input stream if on */ -#define EOF_FLAG 2 -#define START_FLAG 4 /* used when RS == "" */ - -FIN * PROTO (FINdopen, (int, int) ); -FIN * PROTO (FINopen, (char *, int) ); -void PROTO (FINclose, (FIN *) ) ; -void PROTO (FINsemi_close, (FIN *)) ; -char* PROTO (FINgets, (FIN *, unsigned *) ) ; -unsigned PROTO ( fillbuff, (int, char *, unsigned) ) ; - - -extern FIN *main_fin ; /* for the main input stream */ -void PROTO( open_main, (void) ) ; - -void PROTO(setmode, (int,int)) ; -#endif /* FIN_H */ diff --git a/gnu/usr.bin/awk/hash.c b/gnu/usr.bin/awk/hash.c deleted file mode 100644 index 30073ad318ff..000000000000 --- a/gnu/usr.bin/awk/hash.c +++ /dev/null @@ -1,229 +0,0 @@ - -/******************************************** -hash.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: hash.c,v $ -/* Revision 1.2 1993/07/02 23:57:26 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:56:05 brennan - * 1.1 pre-release - * -*/ - - -/* hash.c */ - -#include "mawk.h" -#include "memory.h" -#include "symtype.h" - - -unsigned hash(s) - register char *s ; -{ register unsigned h = 0 ; - - while ( *s ) h += h + *s++ ; - return h ; -} - -typedef struct hash { -struct hash *link ; -SYMTAB symtab ; -} HASHNODE ; - -static HASHNODE *PROTO( delete, (char *) ) ; - -#define new_HASHNODE() (HASHNODE *) zmalloc(sizeof(HASHNODE)) - -static HASHNODE *hash_table[HASH_PRIME] ; - -/* - * insert -- s is not there and need not be duplicated - * -- used during initialization - */ - -SYMTAB *insert(s) - char *s ; -{ register HASHNODE *p = new_HASHNODE(); - register unsigned h ; - - p->link = hash_table[h = hash(s) % HASH_PRIME ] ; - p->symtab.name = s ; - hash_table[h] = p ; - return &p->symtab ; -} - -/* - * find -- s might be there, find it else insert and dup - * s - */ - -SYMTAB *find(s) - char *s ; -{ register HASHNODE *p ; - HASHNODE *q ; - unsigned h ; - - p = hash_table[h = hash(s) % HASH_PRIME ] ; - q = (HASHNODE *) 0 ; - while ( 1 ) - { if ( !p ) - { p = new_HASHNODE() ; - p->symtab.type = ST_NONE ; - p->symtab.name = strcpy(zmalloc( strlen(s)+1 ), s) ; - break ; - } - - if ( strcmp(p->symtab.name, s) == 0 ) /* found */ - if ( !q ) /* already at the front */ - return &p->symtab ; - else /* delete from the list */ - { q->link = p->link ; break ; } - - q = p ; p = p->link ; - } - /* put p on front of the list */ - p->link = hash_table[h] ; - hash_table[h] = p ; - return & p->symtab ; -} - - -/* remove a node from the hash table - return a ptr to the node */ - -static unsigned last_hash ; - -static HASHNODE *delete( s ) - char *s ; -{ register HASHNODE *p ; - HASHNODE *q = (HASHNODE *) 0 ; - unsigned h ; - - p = hash_table[ last_hash = h = hash(s) % HASH_PRIME ] ; - while ( p ) - if ( strcmp(p->symtab.name, s) == 0 ) /* found */ - { - if ( q ) q->link = p->link ; - else hash_table[h] = p->link ; - return p ; - } - else { q = p ; p = p->link ; } - -#ifdef DEBUG /* we should not ever get here */ - bozo("delete") ; -#endif - return (HASHNODE *) 0 ; -} - -/* when processing user functions, global ids which are - replaced by local ids are saved on this list */ - -static HASHNODE *save_list ; - -/* store a global id on the save list, - return a ptr to the local symtab */ -SYMTAB *save_id( s ) - char *s ; -{ HASHNODE *p, *q ; - unsigned h ; - - p = delete(s) ; - q = new_HASHNODE() ; - q->symtab.type = ST_LOCAL_NONE ; - q->symtab.name = p->symtab.name ; - /* put q in the hash table */ - q->link = hash_table[ h = last_hash ] ; - hash_table[h] = q ; - - /* save p */ - p->link = save_list ; save_list = p ; - - return & q->symtab ; -} - -/* restore all global indentifiers */ -void restore_ids() -{ register HASHNODE *p, *q ; - register unsigned h ; - - q = save_list ; save_list = (HASHNODE *) 0 ; - while ( q ) - { - p = q ; q = q->link ; - zfree( delete(p->symtab.name) , sizeof(HASHNODE) ) ; - p->link = hash_table[h = last_hash ] ; - hash_table[h] = p ; - } -} - - -/* search the symbol table backwards for the - disassembler. This is slow -- so what -*/ - -#if ! SM_DOS - -char *reverse_find( type, ptr) - int type ; - PTR ptr ; -{ - CELL *cp ; - ARRAY array ; - static char uk[] = "unknown" ; - - int i ; - HASHNODE *p ; - - - switch( type ) - { - case ST_VAR : - case ST_FIELD : - cp = *(CELL **) ptr ; - break ; - - case ST_ARRAY : - array = *(ARRAY *) ptr ; - break ; - - default : return uk ; - } - - for(i = 0 ; i < HASH_PRIME ; i++) - { - p = hash_table[i] ; - while ( p ) - { - if ( p->symtab.type == type ) - switch(type) - { - case ST_VAR : - case ST_FIELD : - if ( cp == p->symtab.stval.cp ) - return p->symtab.name ; - break ; - - case ST_ARRAY : - if ( array == p->symtab.stval.array ) - return p->symtab.name ; - break ; - } - - p = p->link ; - } - } - return uk ; -} - -#endif diff --git a/gnu/usr.bin/awk/init.c b/gnu/usr.bin/awk/init.c deleted file mode 100644 index 7bf7336a1973..000000000000 --- a/gnu/usr.bin/awk/init.c +++ /dev/null @@ -1,361 +0,0 @@ - -/******************************************** -init.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: init.c,v $ -/* Revision 1.2 1993/07/02 23:57:29 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.4 1992/12/24 01:58:19 mike - * 1.1.2d changes for MsDOS - * - * Revision 5.3 1992/07/10 16:17:10 brennan - * MsDOS: remove NO_BINMODE macro - * - * Revision 5.2 1992/01/09 08:46:14 brennan - * small change for MSC - * - * Revision 5.1 91/12/05 07:56:07 brennan - * 1.1 pre-release - * -*/ - - -/* init.c */ -#include "mawk.h" -#include "code.h" -#include "memory.h" -#include "symtype.h" -#include "init.h" -#include "bi_vars.h" -#include "field.h" - -#ifdef THINK_C -#include -#endif - -#if MSDOS -#include -#endif - -static void PROTO( process_cmdline , (int, char **) ) ; -static void PROTO( set_ARGV, (int, char **, int)) ; -static void PROTO( bad_option, (char *)) ; - -extern void PROTO( print_version, (void) ) ; -extern int PROTO( is_cmdline_assign, (char*)) ; - -#if MSDOS -void PROTO(stdout_init,(void)) ; -#if HAVE_REARGV -void PROTO(reargv, (int*,char***)) ; -#endif -#endif - -char *progname ; - -void initialize(argc, argv) - int argc ; char **argv ; -{ - SET_PROGNAME() ; - - bi_vars_init() ; /* load the builtin variables */ - bi_funct_init() ; /* load the builtin functions */ - kw_init() ; /* load the keywords */ - field_init() ; - -#ifdef THINK_C - fputc('\n',stderr); /* (causes Think C console window to appear) */ - SetWTitle( FrontWindow(), "\pMacMAWK" ); - argc = ccommand(&argv); -#endif - -#if MSDOS - { char *p = getenv("MAWKBINMODE") ; - - if ( p ) set_binmode( atoi(p) ) ; - } -#endif - - - process_cmdline(argc, argv) ; - - code_init() ; - fpe_init() ; - set_stderr() ; - -#if MSDOS - stdout_init() ; -#endif -} - -void compile_cleanup() -/* program has parsed OK, free some memory - we don't need anymore */ -{ - scan_cleanup() ; - code_cleanup() ; -} - -int dump_code ; /* if on dump internal code */ -int posix_space_flag ; - -#ifdef DEBUG -int dump_RE ; /* if on dump compiled REs */ -#endif - - -static void bad_option(s) - char *s ; -{ errmsg(0, "not an option: %s", s) ; mawk_exit(1) ; } - - -static void process_cmdline(argc, argv) - int argc ; - char **argv ; -{ - int i , nextarg ; - char *optarg ; - PFILE dummy ; /* starts linked list of filenames */ - PFILE *tail = &dummy ; - - for( i = 1 ; i < argc && argv[i][0] == '-' ; i = nextarg ) - { - if ( argv[i][1] == 0 ) /* - alone */ - { - if ( ! pfile_name ) - { errmsg(0, "no program") ; exit(1) ; } - break ; /* the for loop */ - } - /* safe to look at argv[i][2] */ - - if ( argv[i][2] == 0 ) - { - if ( i == argc-1 && argv[i][1] != '-' ) - { - if ( strchr("WFvf", argv[i][1]) ) - { errmsg(0, "option %s lacks argument", argv[i]) ; - mawk_exit(1) ; - } - bad_option(argv[i]) ; - } - - optarg = argv[i+1] ; - nextarg = i+2 ; - } - else /* argument glued to option */ - { - optarg = &argv[i][2] ; - nextarg = i+1 ; - } - - switch( argv[i][1] ) - { - case 'W' : - - if ( optarg[0] >= 'a' && optarg[0] <= 'z') - optarg[0] += 'A' - 'a' ; - if ( optarg[0] == 'V' ) print_version() ; - else - if ( optarg[0] == 'D' ) - { dump_code = 1 ; -#if SM_DOS - errmsg(0, "-W dump option unavailable in small model") ; - dump_code=0 ; -#endif - } - else - if ( optarg[0] == 'S' ) - { - char *p = strchr(optarg,'=') ; - int x = p ? atoi(p+1) : 0 ; - - if ( x > SPRINTF_SZ ) - { - sprintf_buff = (char *) zmalloc(x) ; - sprintf_limit = sprintf_buff + x ; - } - } -#if MSDOS - else - if ( optarg[0] == 'B' ) - { - char *p = strchr(optarg,'=') ; - int x = p ? atoi(p+1) : 0 ; - - set_binmode(x) ; - } -#endif - else - if ( optarg[0] == 'P' ) - { - posix_space_flag = 1 ; - } - else - errmsg(0,"vacuous option: -W %s", optarg) ; - - - break ; - - case 'v' : - if ( ! is_cmdline_assign(optarg) ) - { errmsg(0 , "improper assignment: -v %s" , optarg) ; - exit(1) ; - } - break ; - - case 'F' : - - rm_escape(optarg) ; /* recognize escape sequences */ - cell_destroy(FS) ; - FS->type = C_STRING ; - FS->ptr = (PTR) new_STRING(optarg) ; - cast_for_split( cellcpy(&fs_shadow, FS) ) ; - break ; - - case '-' : - if ( argv[i][2] != 0 ) bad_option(argv[i]) ; - i++ ; - goto no_more_opts ; - - case 'f' : - /* first file goes in pfile_name ; any more go - on a list */ - if ( ! pfile_name ) pfile_name = optarg ; - else - { tail = tail->link = ZMALLOC(PFILE) ; - tail->fname = optarg ; - } - break ; - - default : bad_option(argv[i]) ; - - } - - i = nextarg ; - } - -no_more_opts: - - tail->link = (PFILE*) 0 ; - pfile_list = dummy.link ; - - if ( pfile_name ) - { - set_ARGV(argc, argv, i) ; - scan_init( (char *) 0 ) ; - } - else /* program on command line */ - { -#if 0 -#if MSDOS && ! HAVE_REARGV /* prompt for program */ - set_ARGV(argc, argv, i) ; - emit_prompt() ; - pfile_name = "CON" ; - scan_init( (char *) 0 ) ; -#else /* the real world */ -#endif -#endif /* 0 */ - if ( i == argc ) - { errmsg(0, "no program") ; mawk_exit(1) ; } - set_ARGV(argc, argv, i+1) ; - -#if MSDOS && ! HAVE_REARGV /* reversed quotes */ - { char *p ; - - for( p = argv[i] ; *p ; p++ ) - if ( *p == '\'' ) *p = '\"' ; - } -#endif - scan_init( argv[i]) ; -/* #endif */ - } -} - - -static void set_ARGV(argc, argv, i) - int argc ; char **argv ; - int i ; /* argv[i] = ARGV[1] */ -{ - SYMTAB *st_p ; - CELL argi ; - register CELL *cp ; - - st_p = insert( "ARGV" ) ; - st_p->type = ST_ARRAY ; - Argv = st_p->stval.array = new_ARRAY() ; - argi.type = C_DOUBLE ; - argi.dval = 0.0 ; - cp = array_find( st_p->stval.array, &argi, CREATE) ; - cp->type = C_STRING ; - cp->ptr = (PTR) new_STRING( progname ) ; - - /* ARGV[0] is set, do the rest - The type of ARGV[1] ... should be C_MBSTRN - because the user might enter numbers from the command line */ - - for( argi.dval = 1.0 ; i < argc ; i++, argi.dval += 1.0 ) - { - cp = array_find( st_p->stval.array, &argi, CREATE) ; - cp->type = C_MBSTRN ; - cp->ptr = (PTR) new_STRING( argv[i] ) ; - } - ARGC->type = C_DOUBLE ; - ARGC->dval = argi.dval ; -} - -#if 0 -#if MSDOS && ! HAVE_REARGV - -static void emit_prompt() -{ static char prompt[] = "mawk> " ; - int fd = open("CON", O_WRONLY, 0) ; - - (void) write(fd, prompt, strlen(prompt)) ; - (void) close(fd) ; -} -#endif -#endif - - -/*----- ENVIRON ----------*/ - -void load_environ( ENV ) - ARRAY ENV ; -{ - CELL c ; -#ifndef MSDOS_MSC /* MSC declares it near */ - extern char **environ ; -#endif - register char **p = environ ; /* walks environ */ - char *s ; /* looks for the '=' */ - CELL *cp ; /* pts at ENV[&c] */ - - c.type = C_STRING ; - - while ( *p ) - { - if ( s = strchr(*p, '=') ) /* shouldn't fail */ - { - *s = 0 ; - c.ptr = (PTR) new_STRING(*p) ; - *s++ = '=' ; - - cp = array_find(ENV, &c, CREATE) ; - cp->type = C_MBSTRN ; - cp->ptr = (PTR) new_STRING(s) ; - - free_STRING(string(&c)) ; - } - p++ ; - } -} diff --git a/gnu/usr.bin/awk/init.h b/gnu/usr.bin/awk/init.h deleted file mode 100644 index 81e4362e78b3..000000000000 --- a/gnu/usr.bin/awk/init.h +++ /dev/null @@ -1,58 +0,0 @@ - -/******************************************** -init.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: init.h,v $ -/* Revision 1.2 1993/07/02 23:57:30 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:59:22 brennan - * 1.1 pre-release - * -*/ - -/* init.h */ - - -#ifndef INIT_H -#define INIT_H - -#include "symtype.h" - -/* nodes to link file names for multiple - -f option */ - -typedef struct pfile { -struct pfile *link ; -char *fname ; -} PFILE ; - -extern PFILE *pfile_list ; - -extern char *sprintf_buff, *sprintf_limit ; - - -void PROTO( initialize, (int, char **) ) ; -void PROTO( code_init, (void) ) ; -void PROTO( code_cleanup, (void) ) ; -void PROTO( compile_cleanup, (void) ) ; -void PROTO(scan_init, ( char *) ) ; -void PROTO(scan_cleanup, (void) ) ; -void PROTO(bi_vars_init, (void) ) ; -void PROTO(bi_funct_init, (void) ) ; -void PROTO(print_init, (void) ) ; -void PROTO(kw_init, (void) ) ; -void PROTO( field_init, (void) ) ; -void PROTO( fpe_init, (void) ) ; -void PROTO( load_environ, (ARRAY)) ; -void PROTO( set_stderr, (void)) ; - -#endif /* INIT_H */ diff --git a/gnu/usr.bin/awk/jmp.c b/gnu/usr.bin/awk/jmp.c deleted file mode 100644 index 5d3547274492..000000000000 --- a/gnu/usr.bin/awk/jmp.c +++ /dev/null @@ -1,215 +0,0 @@ - -/******************************************** -jmp.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: jmp.c,v $ -/* Revision 1.2 1993/07/02 23:57:31 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:56:10 brennan - * 1.1 pre-release - * -*/ - -/* this module deals with back patching jumps, breaks and continues, - and with save and restoring code when we move code. - There are three stacks. If we encounter a compile error, the - stacks are frozen, i.e., we do not attempt error recovery - on the stacks -*/ - - -#include "mawk.h" -#include "jmp.h" -#include "code.h" -#include "sizes.h" -#include "init.h" -#include "memory.h" - -extern unsigned compile_error_count ; -#define error_state (compile_error_count>0) - - -/*---------- back patching jumps ---------------*/ - -typedef struct jmp { -struct jmp *link ; -INST *source ; -} JMP ; - -static JMP *jmp_top ; - -void code_jmp( jtype, target) - int jtype ; - INST *target ; -{ - register INST *source ; - - if (error_state) return ; - - code1(jtype) ; - source = code_ptr++ ; - - if ( target ) source->op = target - source ; - else /* save source on jump stack */ - { - register JMP *p = (JMP*) zmalloc(sizeof(JMP)) ; - p->source = source ; - p->link = jmp_top ; - jmp_top = p ; - } -} - -void patch_jmp(target) /* patch a jump on the jmp_stack */ - INST *target ; -{ register JMP *p ; - - if ( ! error_state ) - { -#ifdef DEBUG - if (!jmp_top) bozo("jmp stack underflow") ; -#endif - - p = jmp_top ; jmp_top = p->link ; - - p->source->op = target - p->source ; - - zfree(p, sizeof(JMP)) ; - } -} - - -/*-- break and continue -------*/ - -typedef struct bc { -struct bc *link ; /* stack as linked list */ -int type ; /* 'B' or 'C' or mark start with 0 */ -INST *source ; /* position of _JMP */ -} BC ; - -static BC *bc_top ; - - - -void BC_new() /* mark the start of a loop */ -{ - BC_insert(0, (INST*) 0 ) ; -} - -void BC_insert(type, address) - int type ; INST *address ; -{ register BC * p ; - - if ( error_state ) return ; - - if ( type && ! bc_top ) - { - compile_error("%s statement outside of loop", - type == 'B' ? "break" : "continue" ) ; - - return ; - } - else - { - p = (BC*) zmalloc(sizeof(BC)) ; - p->type = type ; - p->source = address ; - p->link = bc_top ; - bc_top = p ; - } -} - - -void BC_clear(B_address, C_address) -/* patch all break and continues for one loop */ -INST *B_address, *C_address ; -{ register BC *p , *q ; - - if (error_state) return ; - - p = bc_top ; - /* pop down to the mark node */ - while ( p->type ) - { - p->source->op = (p->type == 'B' ? B_address : C_address) - - p->source ; - - q = p ; p = p->link ; zfree(q, sizeof(BC)) ; - } - /* remove the mark node */ - bc_top = p->link ; - zfree(p, sizeof(BC)) ; -} - -/*----- moving code --------------------------*/ - -/* a stack to hold some pieces of code while - reorganizing loops . - This used to be used on all loops. Now it is used - only for the 3rd expression on a for loop and - for the fist part of a range pattern -*/ - -typedef struct mc { /* mc -- move code */ -struct mc *link ; -INST *code ; -unsigned len ; -} MC ; - -static MC *mc_top ; - - -void code_push( code, len) - INST *code ; unsigned len ; -{ - register MC *p ; - - if (! error_state ) - { - p = (MC*) zmalloc(sizeof(MC)) ; - p->len = len ; - p->link = mc_top ; - mc_top = p ; - - if ( len ) - { - p->code = (INST*) zmalloc(sizeof(INST)*len) ; - (void) memcpy(p->code, code, SIZE_T(sizeof(INST)*len)) ; - } - } -} - -/* copy the code at the top of the mc stack to target. - return the number of INSTs moved */ - -unsigned code_pop(target) - INST *target ; -{ - register MC *p ; - unsigned retval ; - - if (error_state) return 0 ; - -#ifdef DEBUG - if ( ! mc_top ) bozo("mc underflow") ; -#endif - - p = mc_top ; mc_top = p->link ; - - if ( retval = p->len ) - { - (void) memcpy(target, p->code, SIZE_T(p->len*sizeof(INST))) ; - zfree(p->code, p->len*sizeof(INST)) ; - } - - zfree(p, sizeof(MC)) ; - return retval ; -} diff --git a/gnu/usr.bin/awk/jmp.h b/gnu/usr.bin/awk/jmp.h deleted file mode 100644 index ac1c4806548e..000000000000 --- a/gnu/usr.bin/awk/jmp.h +++ /dev/null @@ -1,35 +0,0 @@ - -/******************************************** -jmp.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: jmp.h,v $ -/* Revision 1.2 1993/07/02 23:57:32 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:59:24 brennan - * 1.1 pre-release - * -*/ - -#ifndef JMP_H -#define JMP_H - -void PROTO(BC_new, (void) ) ; -void PROTO(BC_insert, (int, INST*) ) ; -void PROTO(BC_clear, (INST *, INST *) ) ; -void PROTO(code_push, (INST *, unsigned) ) ; -unsigned PROTO(code_pop, (INST *) ) ; -void PROTO(code_jmp, (int, INST *) ) ; -void PROTO(patch_jmp, (INST *) ) ; - - -#endif /* JMP_H */ - diff --git a/gnu/usr.bin/awk/kw.c b/gnu/usr.bin/awk/kw.c deleted file mode 100644 index 09ec59379c24..000000000000 --- a/gnu/usr.bin/awk/kw.c +++ /dev/null @@ -1,83 +0,0 @@ - -/******************************************** -kw.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: kw.c,v $ -/* Revision 1.2 1993/07/02 23:57:33 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:56:12 brennan - * 1.1 pre-release - * -*/ - - -/* kw.c */ - - -#include "mawk.h" -#include "symtype.h" -#include "parse.h" -#include "init.h" - - -static struct kw { -char *text ; -short kw ; -} keywords[] = { - -"print", PRINT, -"printf", PRINTF, -"do" , DO , -"while" , WHILE , -"for" , FOR , -"break" , BREAK , -"continue" , CONTINUE , -"if" , IF , -"else", ELSE , -"in" , IN , -"delete", DELETE , -"split" , SPLIT , -"match" , MATCH_FUNC , -"BEGIN" , BEGIN, -"END" , END , -"exit" , EXIT , -"next" , NEXT , -"return", RETURN, -"getline", GETLINE, -"sub" , SUB, -"gsub", GSUB, -"function", FUNCTION, -(char *) 0 , 0 } ; - -/* put keywords in the symbol table */ -void kw_init() -{ register struct kw *p = keywords ; - register SYMTAB *q ; - - while ( p->text ) - { q = insert( p->text ) ; - q->type = ST_KEYWORD ; - q->stval.kw = p++ -> kw ; - } -} - -/* find a keyword to emit an error message */ -char *find_kw_str( kw_token ) - int kw_token ; -{ struct kw *p ; - - for( p = keywords ; p->text ; p++ ) - if ( p->kw == kw_token ) return p->text ; - /* search failed */ - return (char *) 0 ; -} diff --git a/gnu/usr.bin/awk/main.c b/gnu/usr.bin/awk/main.c deleted file mode 100644 index 00dd6fcb942c..000000000000 --- a/gnu/usr.bin/awk/main.c +++ /dev/null @@ -1,73 +0,0 @@ - -/******************************************** -main.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: main.c,v $ -/* Revision 1.2 1993/07/02 23:57:35 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.2.1.1 1993/01/15 03:33:44 mike - * patch3: safer double to int conversion - * - * Revision 5.2 1992/12/17 02:48:01 mike - * 1.1.2d changes for DOS - * - * Revision 5.1 1991/12/05 07:56:14 brennan - * 1.1 pre-release - * -*/ - - - -/* main.c */ - -#include "mawk.h" -#include "code.h" -#include "init.h" -#include "fin.h" -#include "bi_vars.h" -#include "field.h" -#include "files.h" -#include - - -short mawk_state ; /* 0 is compiling */ -int exit_code ; - -int -main(argc , argv ) - int argc ; char **argv ; -{ - - initialize(argc, argv) ; - - if ( parse() || compile_error_count ) mawk_exit(1) ; - - compile_cleanup() ; - mawk_state = EXECUTION ; - execute(code_ptr, eval_stack-1, 0) ; - /* never returns */ - return 0 ; -} - -void mawk_exit(x) - int x ; -{ -#if HAVE_REAL_PIPES - close_out_pipes() ; /* no effect, if no out pipes */ -#else -#if HAVE_FAKE_PIPES - close_fake_pipes() ; -#endif -#endif - - exit(x) ; -} diff --git a/gnu/usr.bin/awk/makescan.c b/gnu/usr.bin/awk/makescan.c deleted file mode 100644 index 80276a93117d..000000000000 --- a/gnu/usr.bin/awk/makescan.c +++ /dev/null @@ -1,123 +0,0 @@ - -/******************************************** -makescan.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: makescan.c,v $ -/*Revision 1.2 1993/07/02 23:57:38 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:56:16 brennan - * 1.1 pre-release - * -*/ - -/* source for makescan.exe which builds the scancode[] - via: makescan.exe > scancode.c -*/ - -#ifdef THINK_C -#include -#include -#include -#define SIZE_T(x) (size_t)(x) -#endif - -#ifndef SIZE_T -#define SIZE_T(x) (x) -#endif - -#define MAKESCAN - -#include "scan.h" - -char scan_code[256] ; - -void scan_init() -{ - register char *p ; - - (void) memset(scan_code, SC_UNEXPECTED, SIZE_T(sizeof(scan_code))) ; - for( p = scan_code + '0' ; p <= scan_code + '9' ; p++ ) - *p = SC_DIGIT ; - scan_code[0] = 0 ; - scan_code[ ' ' ] = scan_code['\t'] = scan_code['\f'] = SC_SPACE ; - scan_code[ '\r'] = scan_code['\013'] = SC_SPACE ; - - scan_code[';'] = SC_SEMI_COLON ; - scan_code['\n'] = SC_NL ; - scan_code['{'] = SC_LBRACE ; - scan_code[ '}'] = SC_RBRACE ; - scan_code['+'] = SC_PLUS ; - scan_code['-'] = SC_MINUS ; - scan_code['*'] = SC_MUL ; - scan_code['/'] = SC_DIV ; - scan_code['%'] = SC_MOD ; - scan_code['^'] = SC_POW ; - scan_code['('] = SC_LPAREN ; - scan_code[')'] = SC_RPAREN ; - scan_code['_'] = SC_IDCHAR ; - scan_code['='] = SC_EQUAL ; - scan_code['#'] = SC_COMMENT ; - scan_code['\"'] = SC_DQUOTE ; - scan_code[','] = SC_COMMA ; - scan_code['!'] = SC_NOT ; - scan_code['<'] = SC_LT ; - scan_code['>'] = SC_GT ; - scan_code['|'] = SC_OR ; - scan_code['&'] = SC_AND ; - scan_code['?'] = SC_QMARK ; - scan_code[':'] = SC_COLON ; - scan_code['['] = SC_LBOX ; - scan_code[']'] = SC_RBOX ; - scan_code['\\'] = SC_ESCAPE ; - scan_code['.'] = SC_DOT ; - scan_code['~'] = SC_MATCH ; - scan_code['$'] = SC_DOLLAR ; - - for( p = scan_code + 'A' ; p <= scan_code + 'Z' ; p++ ) - *p = *(p + 'a' - 'A') = SC_IDCHAR ; - -} - -void scan_print() -{ register char *p = scan_code ; - register int c ; /* column */ - register int r ; /* row */ - - printf("\n\n/* scancode.c */\n\n\n") ; - printf( "char scan_code[256] = {\n" ) ; - - for( r = 1 ; r <= 16 ; r++) - { - for( c = 1 ; c <= 16 ; c++) - { - printf("%2d" , *p++) ; - if ( r != 16 || c != 16 ) putchar(',') ; - } - putchar('\n') ; - } - - printf("} ;\n") ; -} - - -int main(argc,argv) -int argc; -char **argv; -{ -#ifdef THINK_C -fprintf(stderr, "MAKESCAN for MacMAWK\n"); -SetWTitle( FrontWindow(), "\pPC-KIMMO"); -argc = ccommand(&argv); -#endif - scan_init() ; scan_print() ; - return 0 ; -} diff --git a/gnu/usr.bin/awk/matherr.c b/gnu/usr.bin/awk/matherr.c deleted file mode 100644 index 5849b36b7364..000000000000 --- a/gnu/usr.bin/awk/matherr.c +++ /dev/null @@ -1,191 +0,0 @@ - -/******************************************** -matherr.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: matherr.c,v $ -/*Revision 1.2 1993/07/02 23:57:39 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.2 1992/03/31 16:14:44 brennan - * patch2: - * TURN_ON_FPE_TRAPS() macro - * USE_IEEEFP_H macro - * - * Revision 5.1 91/12/05 07:56:18 brennan - * 1.1 pre-release - * -*/ - -#include "mawk.h" -#include - -#ifdef USE_IEEEFP_H -#include -#endif - -#if FPE_TRAPS_ON -#include - -/* machine dependent changes might be needed here */ - -static void fpe_catch( signal, why) - int signal, why ; -{ - -#if NOINFO_SIGFPE - /* some systems give no hook to find out what the exception - was -- stuff like this is why people still use fortran - - If this fits, #define NOINFO_SIGFPE 1 in your config.h -*/ - rt_error("floating point exception, probably overflow") ; -#else - - switch(why) - { - case FPE_ZERODIVIDE : - rt_error("division by zero") ; - - case FPE_OVERFLOW : - rt_error("floating point overflow") ; - - default : - rt_error("floating point exception") ; - } -#endif -} - -void fpe_init() -{ - TURN_ON_FPE_TRAPS() ; - (void) signal(SIGFPE, fpe_catch) ; -} - -#else /* FPE_TRAPS_ON==0 */ - -void fpe_init() -{ - TURN_OFF_FPE_TRAPS() ; -} -#endif - -#if HAVE_MATHERR - -#if ! FPE_TRAPS_ON - -/* If we are not trapping math errors, we will shutup the library calls -*/ - -int matherr( e ) - struct exception *e ; -{ return 1 ; } - -#else /* print error message and exit */ - -int matherr( e ) - struct exception *e ; -{ char *error ; - - switch( e->type ) - { - case DOMAIN : - case SING : - error = "domain error" ; - break ; - - case OVERFLOW : - error = "overflow" ; - break ; - - case TLOSS : - case PLOSS : - error = "loss of significance" ; - break ; - - case UNDERFLOW : - e->retval = 0.0 ; - return 1 ; /* ignore it */ - } - - if ( strcmp(e->name, "atan2") == 0 ) - rt_error("atan2(%g,%g) : %s" , - e->arg1, e->arg2, error ) ; - else - rt_error("%s(%g) : %s" , e->name, e->arg1, error) ; - - /* won't get here */ - return 0 ; -} -#endif /* FPE_TRAPS */ - -#endif /* HAVE_MATHERR */ - - -/* this is how one gets the libm calls to do the right -thing on bsd43_vax -*/ - -#ifdef BSD43_VAX - -#include - -double infnan( arg ) - int arg ; -{ - switch(arg) - { - case ERANGE : errno = ERANGE ; return HUGE ; - case -ERANGE : errno = EDOM ; return -HUGE ; - default : errno = EDOM ; - } - return 0.0 ; -} - -#endif /* BSD43_VAX */ - -/* This routine is for XENIX-68K 2.3A. - Error check routine to be called after fp arithmetic. -*/ - -#if SW_FP_CHECK -/* Definitions of bit values in iserr() return value */ - -#define OVFLOW 2 -#define UFLOW 4 -#define ZERODIV 8 -#define OVFLFIX 32 -#define INFNAN 64 - -void -fpcheck() -{ - register int fperrval ; - char *errdesc ; - - if ((fperrval = iserr()) == 0) - return ; /* no error */ - - errdesc = (char *) 0 ; - - if (fperrval & INFNAN) - errdesc = "arg is infinity or NAN" ; - else if (fperrval & ZERODIV) - errdesc = "division by zero" ; - else if (fperrval & OVFLOW) - errdesc = "overflow" ; - else if (fperrval & UFLOW) - ; /* ignored */ - - if (errdesc) - rt_error("%s", errdesc) ; -} - -#endif diff --git a/gnu/usr.bin/awk/mawk.h b/gnu/usr.bin/awk/mawk.h deleted file mode 100644 index a56b40c83e0c..000000000000 --- a/gnu/usr.bin/awk/mawk.h +++ /dev/null @@ -1,205 +0,0 @@ - -/******************************************** -mawk.h -copyright 1991 1992, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: mawk.h,v $ -/* Revision 1.2 1993/07/02 23:57:40 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.5.1.3 1993/01/22 15:04:50 mike - * pow2->mpow2 for linux - * - * Revision 5.5.1.2 1993/01/20 12:53:10 mike - * d_to_l() - * - * Revision 5.5.1.1 1993/01/15 03:33:46 mike - * patch3: safer double to int conversion - * - * Revision 5.5 1992/07/06 20:15:49 brennan - * DONT_PROTO_OPEN macro - * - * Revision 5.4 1992/03/03 16:34:41 brennan - * conditional around open() proto - * - * Revision 5.3 92/01/09 08:46:58 brennan - * cell destroy macro - * - * Revision 5.2 92/01/06 08:08:56 brennan - * binmode() proto for MSDOS - * - * Revision 5.1 91/12/05 07:59:26 brennan - * 1.1 pre-release - * -*/ - - -/* mawk.h */ - -#ifndef MAWK_H -#define MAWK_H - -#include "config.h" - -#ifdef DEBUG -#define YYDEBUG 1 -extern int yydebug ; /* print parse if on */ -extern int dump_RE ; -#endif -extern int dump_code ; -extern int posix_space_flag ; - -#include - -#if HAVE_STRING_H -#include -#else -char *strchr() ; -char *strcpy() ; -char *strrchr() ; -#endif - -#if HAVE_STDLIB_H -#include -#endif - -#include "types.h" - - - - -/*---------------- - * GLOBAL VARIABLES - *----------------*/ - -/* a well known string */ -extern STRING null_str ; - -#ifndef TEMPBUFF_GOES_HERE -#define EXTERN extern -#else -#define EXTERN /* empty */ -#endif - -/* a useful scratch area */ -EXTERN union { -STRING *_split_buff[MAX_SPLIT] ; -char _string_buff[MIN_SPRINTF] ; -} tempbuff ; - -/* anonymous union */ -#define string_buff tempbuff._string_buff -#define split_buff tempbuff._split_buff - -#define SPRINTF_SZ sizeof(tempbuff) - -/* help with casts */ -extern int mpow2[] ; - - - /* these are used by the parser, scanner and error messages - from the compile */ - -extern char *pfile_name ; /* program input file */ -extern int current_token ; -extern unsigned token_lineno ; /* lineno of current token */ -extern unsigned compile_error_count ; -extern int paren_cnt, brace_cnt ; -extern int print_flag, getline_flag ; -extern short mawk_state ; -#define EXECUTION 1 /* other state is 0 compiling */ - -/*---------*/ - -#ifndef MSDOS_MSC -extern int errno ; -#endif -extern char *progname ; /* for error messages */ - -/* macro to test the type of two adjacent cells */ -#define TEST2(cp) (mpow2[(cp)->type]+mpow2[((cp)+1)->type]) - -/* macro to get at the string part of a CELL */ -#define string(cp) ((STRING *)(cp)->ptr) - -#ifdef DEBUG -#define cell_destroy(cp) DB_cell_destroy(cp) -#else - -#define cell_destroy(cp) if ( (cp)->type >= C_STRING &&\ - -- string(cp)->ref_cnt == 0 )\ - zfree(string(cp),string(cp)->len+STRING_OH);else -#endif - -/* prototypes */ - -void PROTO( cast1_to_s, (CELL *) ) ; -void PROTO( cast1_to_d, (CELL *) ) ; -void PROTO( cast2_to_s, (CELL *) ) ; -void PROTO( cast2_to_d, (CELL *) ) ; -void PROTO( cast_to_RE, (CELL *) ) ; -void PROTO( cast_for_split, (CELL *) ) ; -void PROTO( check_strnum, (CELL *) ) ; -void PROTO( cast_to_REPL, (CELL *) ) ; -long PROTO( d_to_l, (double)) ; - -#define d_to_i(d) ((int)d_to_l(d)) - -int PROTO( test, (CELL *) ) ; /* test for null non-null */ -CELL *PROTO( cellcpy, (CELL *, CELL *) ) ; -CELL *PROTO( repl_cpy, (CELL *, CELL *) ) ; -void PROTO( DB_cell_destroy, (CELL *) ) ; -void PROTO( overflow, (char *, unsigned) ) ; -void PROTO( rt_overflow, (char *, unsigned) ) ; -void PROTO( rt_error, ( char *, ...) ) ; -void PROTO( mawk_exit, (int) ) ; -void PROTO( da, (INST *, FILE *)) ; -char *PROTO( str_str, (char*, char*, unsigned) ) ; -char *PROTO( rm_escape, (char *) ) ; -int PROTO( re_split, (char *, PTR) ) ; -char *PROTO( re_pos_match, (char *, PTR, unsigned *) ) ; -int PROTO( binmode, (void)) ; - -void PROTO( exit, (int) ) ; - -#ifdef THINK_C -#include -#else -int PROTO( close, (int) ) ; - -/* ANSI compilers won't like open() if they've ever seen open as - int open(char *,int, ...). If so , - #define DONT_PROTO_OPEN -*/ - -#ifndef DONT_PROTO_OPEN -int PROTO( open, (char *,int, int) ) ; -#endif - -int PROTO( read, (int , PTR, unsigned) ) ; -#endif - -int PROTO ( parse, (void) ) ; -int PROTO ( yylex, (void) ) ; -int PROTO( yyparse, (void) ) ; -void PROTO( yyerror, (char *) ) ; - -void PROTO( bozo, (char *) ) ; -void PROTO( errmsg , (int, char*, ...) ) ; -void PROTO( compile_error, ( char *, ...) ) ; - -void PROTO( execute, (INST *, CELL *, CELL *) ) ; -char *PROTO( find_kw_str, (int) ) ; - -double strtod() ; -double fmod() ; - -#endif /* MAWK_H */ diff --git a/gnu/usr.bin/awk/memory.c b/gnu/usr.bin/awk/memory.c deleted file mode 100644 index 1793341cb3e1..000000000000 --- a/gnu/usr.bin/awk/memory.c +++ /dev/null @@ -1,74 +0,0 @@ - -/******************************************** -memory.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: memory.c,v $ -/* Revision 1.2 1993/07/02 23:57:41 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:56:21 brennan - * 1.1 pre-release - * -*/ - - -/* memory.c */ - -#include "mawk.h" - -#if HAVE_PROTOS -#define SUPPRESS_NEW_STRING_PROTO /* get compiler off our back on - the definition of new_STRING() */ -#endif - -#include "memory.h" - -STRING null_str = {0, 1, "" } ; - - -STRING *new_STRING(s, xlen) - char *s ; unsigned xlen ; - /* WARNING: if s != NULL, don't access xlen - because it won't be there */ -{ register STRING *sval ; - unsigned len ; - - if ( s ) - { - if ( *s == 0 ){ sval = &null_str ; null_str.ref_cnt++ ; } - else - { - len = strlen(s) ; - sval = (STRING *) zmalloc(len + STRING_OH) ; - sval->len = len ; - sval->ref_cnt = 1 ; - (void) strcpy(sval->str, s) ; - } - } - else - { sval = (STRING *) zmalloc( xlen + STRING_OH ) ; - sval->ref_cnt = 1 ; sval->len = xlen ; - /* zero out the end marker */ - sval->str[xlen] = 0 ; - } - - return sval ; -} - - -#ifdef DEBUG - -void DB_free_STRING(sval) - register STRING *sval ; -{ if ( -- sval->ref_cnt == 0 ) zfree(sval, sval->len+STRING_OH) ; } - -#endif diff --git a/gnu/usr.bin/awk/memory.h b/gnu/usr.bin/awk/memory.h deleted file mode 100644 index f9cd9eaac861..000000000000 --- a/gnu/usr.bin/awk/memory.h +++ /dev/null @@ -1,50 +0,0 @@ - -/******************************************** -memory.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: memory.h,v $ -/* Revision 1.2 1993/07/02 23:57:42 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:59:28 brennan - * 1.1 pre-release - * -*/ - - -/* memory.h */ - -#ifndef MEMORY_H -#define MEMORY_H - -#include "zmalloc.h" - -#define new_CELL() (CELL *) zmalloc(sizeof(CELL)) -#define free_CELL(p) zfree(p,sizeof(CELL)) - -#ifndef SUPPRESS_NEW_STRING_PROTO -STRING *PROTO( new_STRING, (char *, ...) ) ; -#endif - -#ifdef DEBUG -void PROTO( DB_free_STRING , (STRING *) ) ; - -#define free_STRING(s) DB_free_STRING(s) - -#else - -#define free_STRING(sval) if ( -- (sval)->ref_cnt == 0 )\ - zfree(sval, (sval)->len+STRING_OH) ; else -#endif - - -#endif /* MEMORY_H */ diff --git a/gnu/usr.bin/awk/parse.y b/gnu/usr.bin/awk/parse.y deleted file mode 100644 index ca8aa49aeb82..000000000000 --- a/gnu/usr.bin/awk/parse.y +++ /dev/null @@ -1,1294 +0,0 @@ - -/******************************************** -parse.y -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: parse.y,v $ -/* Revision 1.2 1993/07/02 23:57:44 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.4.1.1 1993/05/05 00:08:26 mike - * patch4: forgot to set $$ in LENGTH alone production - * - * Revision 5.4 1992/08/08 17:17:20 brennan - * patch 2: improved timing of error recovery in - * bungled function definitions. Fixes a core dump - * - * Revision 5.3 1992/07/08 15:43:41 brennan - * patch2: length returns. I am a wimp - * - * Revision 5.2 1992/01/08 16:11:42 brennan - * code FE_PUSHA carefully for MSDOS large mode - * - * Revision 5.1 91/12/05 07:50:22 brennan - * 1.1 pre-release - * -*/ - - -%{ -#include -#include "mawk.h" -#include "code.h" -#include "symtype.h" -#include "memory.h" -#include "bi_funct.h" -#include "bi_vars.h" -#include "jmp.h" -#include "field.h" -#include "files.h" - -#ifdef YYXBYACC -#define YYBYACC 1 -#endif - -#define YYMAXDEPTH 200 - -/* Bison's use of MSDOS and ours clashes */ -#undef MSDOS - -extern void PROTO( eat_nl, (void) ) ; -static void PROTO( resize_fblock, (FBLOCK *, INST *) ) ; -static void PROTO( code_array, (SYMTAB *) ) ; -static void PROTO( code_call_id, (CA_REC *, SYMTAB *) ) ; -static void PROTO( field_A2I, (void)) ; -static int PROTO( current_offset, (void) ) ; -static void PROTO( check_var, (SYMTAB *) ) ; -static void PROTO( check_array, (SYMTAB *) ) ; -static void PROTO( RE_as_arg, (void)) ; - -static int scope ; -static FBLOCK *active_funct ; - /* when scope is SCOPE_FUNCT */ - -#define code_address(x) if( is_local(x) )\ - { code1(L_PUSHA) ; code1((x)->offset) ; }\ - else code2(_PUSHA, (x)->stval.cp) - -/* this nonsense caters to MSDOS large model */ -#define CODE_FE_PUSHA() code_ptr->ptr = (PTR) 0 ; code1(FE_PUSHA) - -%} - -%union{ -CELL *cp ; -SYMTAB *stp ; -INST *start ; /* code starting address */ -PF_CP fp ; /* ptr to a (print/printf) or (sub/gsub) function */ -BI_REC *bip ; /* ptr to info about a builtin */ -FBLOCK *fbp ; /* ptr to a function block */ -ARG2_REC *arg2p ; -CA_REC *ca_p ; -int ival ; -PTR ptr ; -} - -/* two tokens to help with errors */ -%token UNEXPECTED /* unexpected character */ -%token BAD_DECIMAL - -%token NL -%token SEMI_COLON -%token LBRACE RBRACE -%token LBOX RBOX -%token COMMA -%token IO_OUT /* > or output pipe */ - -%right ASSIGN ADD_ASG SUB_ASG MUL_ASG DIV_ASG MOD_ASG POW_ASG -%right QMARK COLON -%left OR -%left AND -%left IN -%left MATCH /* ~ or !~ */ -%left EQ NEQ LT LTE GT GTE -%left CAT -%left GETLINE -%left PLUS MINUS -%left MUL DIV MOD -%left NOT UMINUS -%nonassoc IO_IN PIPE -%right POW -%left INC_or_DEC -%left DOLLAR FIELD /* last to remove a SR conflict - with getline */ -%right LPAREN RPAREN /* removes some SR conflicts */ - -%token DOUBLE STRING_ RE -%token ID D_ID -%token FUNCT_ID -%token BUILTIN LENGTH -%token FIELD - -%token PRINT PRINTF SPLIT MATCH_FUNC SUB GSUB -/* keywords */ -%token DO WHILE FOR BREAK CONTINUE IF ELSE IN -%token DELETE BEGIN END EXIT NEXT RETURN FUNCTION - -%type block block_or_separator -%type statement_list statement mark -%type pr_args -%type arg2 -%type builtin -%type getline_file -%type lvalue field fvalue -%type expr cat_expr p_expr -%type while_front if_front -%type for1 for2 -%type array_loop_front -%type return_statement -%type split_front re_arg sub_back -%type arglist args -%type print sub_or_gsub -%type funct_start funct_head -%type call_args ca_front ca_back -%type f_arglist f_args - -%% -/* productions */ - -program : program_block - | program program_block - ; - -program_block : PA_block /* pattern-action */ - | function_def - | outside_error block - ; - -PA_block : block - { /* this do nothing action removes a vacuous warning - from Bison */ - } - - | BEGIN - { - be_expand(&begin_code) ; - scope = SCOPE_BEGIN ; - } - - block - { be_shrink(&begin_code) ; - scope = SCOPE_MAIN ; - } - - | END - { - be_expand(&end_code) ; - scope = SCOPE_END ; - } - - block - { be_shrink(&end_code) ; - scope = SCOPE_MAIN ; - } - - | expr /* this works just like an if statement */ - { code_jmp(_JZ, (INST*)0) ; } - - block_or_separator - { patch_jmp( code_ptr ) ; } - - /* range pattern, see comment in execute.c near _RANGE */ - | expr COMMA - { code_push($1, code_ptr - $1) ; - code_ptr = $1 ; - code1(_RANGE) ; code1(1) ; - code_ptr += 3 ; - code_ptr += code_pop(code_ptr) ; - code1(_STOP) ; - $1[2].op = code_ptr - ($1+1) ; - } - expr - { code1(_STOP) ; } - - block_or_separator - { $1[3].op = $6 - ($1+1) ; - $1[4].op = code_ptr - ($1+1) ; - } - ; - - - -block : LBRACE statement_list RBRACE - { $$ = $2 ; } - | LBRACE error RBRACE - { $$ = code_ptr ; /* does nothing won't be executed */ - print_flag = getline_flag = paren_cnt = 0 ; - yyerrok ; } - ; - -block_or_separator : block - | separator /* default print action */ - { $$ = code_ptr ; - code1(_PUSHINT) ; code1(0) ; - code2(_PRINT, bi_print) ; - } - -statement_list : statement - | statement_list statement - ; - - -statement : block - | expr separator - { code1(_POP) ; } - | /* empty */ separator - { $$ = code_ptr ; } - | error separator - { $$ = code_ptr ; - print_flag = getline_flag = 0 ; - paren_cnt = 0 ; - yyerrok ; - } - | BREAK separator - { $$ = code_ptr ; BC_insert('B', code_ptr+1) ; - code2(_JMP, 0) /* don't use code_jmp ! */ ; } - | CONTINUE separator - { $$ = code_ptr ; BC_insert('C', code_ptr+1) ; - code2(_JMP, 0) ; } - | return_statement - { if ( scope != SCOPE_FUNCT ) - compile_error("return outside function body") ; - } - | NEXT separator - { if ( scope != SCOPE_MAIN ) - compile_error( "improper use of next" ) ; - $$ = code_ptr ; - code1(_NEXT) ; - } - ; - -separator : NL | SEMI_COLON - ; - -expr : cat_expr - | lvalue ASSIGN expr { code1(_ASSIGN) ; } - | lvalue ADD_ASG expr { code1(_ADD_ASG) ; } - | lvalue SUB_ASG expr { code1(_SUB_ASG) ; } - | lvalue MUL_ASG expr { code1(_MUL_ASG) ; } - | lvalue DIV_ASG expr { code1(_DIV_ASG) ; } - | lvalue MOD_ASG expr { code1(_MOD_ASG) ; } - | lvalue POW_ASG expr { code1(_POW_ASG) ; } - | expr EQ expr { code1(_EQ) ; } - | expr NEQ expr { code1(_NEQ) ; } - | expr LT expr { code1(_LT) ; } - | expr LTE expr { code1(_LTE) ; } - | expr GT expr { code1(_GT) ; } - | expr GTE expr { code1(_GTE) ; } - - | expr MATCH expr - { - if ( $3 == code_ptr - 2 ) - { - if ( $3->op == _MATCH0 ) $3->op = _MATCH1 ; - - else /* check for string */ - if ( $3->op == _PUSHS ) - { CELL *cp = ZMALLOC(CELL) ; - - cp->type = C_STRING ; - cp->ptr = $3[1].ptr ; - cast_to_RE(cp) ; - code_ptr -= 2 ; - code2(_MATCH1, cp->ptr) ; - ZFREE(cp) ; - } - else code1(_MATCH2) ; - } - else code1(_MATCH2) ; - - if ( !$2 ) code1(_NOT) ; - } - -/* short circuit boolean evaluation */ - | expr OR - { code1(_DUP) ; - code_jmp(_JNZ, (INST*)0) ; - code1(_POP) ; - } - expr - { patch_jmp(code_ptr) ; code1(_TEST) ; } - - | expr AND - { code1(_DUP) ; code_jmp(_JZ, (INST*)0) ; - code1(_POP) ; } - expr - { patch_jmp(code_ptr) ; code1(_TEST) ; } - - | expr QMARK { code_jmp(_JZ, (INST*)0) ; } - expr COLON { code_jmp(_JMP, (INST*)0) ; } - expr - { patch_jmp(code_ptr) ; patch_jmp($7) ; } - ; - -cat_expr : p_expr %prec CAT - | cat_expr p_expr %prec CAT - { code1(_CAT) ; } - ; - -p_expr : DOUBLE - { $$ = code_ptr ; code2(_PUSHD, $1) ; } - | STRING_ - { $$ = code_ptr ; code2(_PUSHS, $1) ; } - | ID %prec AND /* anything less than IN */ - { check_var($1) ; - $$ = code_ptr ; - if ( is_local($1) ) - { code1(L_PUSHI) ; code1($1->offset) ; } - else code2(_PUSHI, $1->stval.cp) ; - } - - | LPAREN expr RPAREN - { $$ = $2 ; } - ; - -p_expr : RE - { $$ = code_ptr ; code2(_MATCH0, $1) ; } - ; - -p_expr : p_expr PLUS p_expr { code1(_ADD) ; } - | p_expr MINUS p_expr { code1(_SUB) ; } - | p_expr MUL p_expr { code1(_MUL) ; } - | p_expr DIV p_expr { code1(_DIV) ; } - | p_expr MOD p_expr { code1(_MOD) ; } - | p_expr POW p_expr { code1(_POW) ; } - | NOT p_expr - { $$ = $2 ; code1(_NOT) ; } - | PLUS p_expr %prec UMINUS - { $$ = $2 ; code1(_UPLUS) ; } - | MINUS p_expr %prec UMINUS - { $$ = $2 ; code1(_UMINUS) ; } - | builtin - ; - -p_expr : ID INC_or_DEC - { check_var($1) ; - $$ = code_ptr ; - code_address($1) ; - - if ( $2 == '+' ) code1(_POST_INC) ; - else code1(_POST_DEC) ; - } - | INC_or_DEC lvalue - { $$ = $2 ; - if ( $1 == '+' ) code1(_PRE_INC) ; - else code1(_PRE_DEC) ; - } - ; - -p_expr : field INC_or_DEC - { if ($2 == '+' ) code1(F_POST_INC ) ; - else code1(F_POST_DEC) ; - } - | INC_or_DEC field - { $$ = $2 ; - if ( $1 == '+' ) code1(F_PRE_INC) ; - else code1( F_PRE_DEC) ; - } - ; - -lvalue : ID - { $$ = code_ptr ; - check_var($1) ; - code_address($1) ; - } - ; - - -arglist : /* empty */ - { $$ = 0 ; } - | args - ; - -args : expr %prec LPAREN - { $$ = 1 ; } - | args COMMA expr - { $$ = $1 + 1 ; } - ; - -builtin : - BUILTIN mark LPAREN arglist RPAREN - { BI_REC *p = $1 ; - $$ = $2 ; - if ( p-> min_args > $4 || p->max_args < $4 ) - compile_error( - "wrong number of arguments in call to %s" , - p->name ) ; - if ( p->min_args != p->max_args ) /* variable args */ - { code1(_PUSHINT) ; code1($4) ; } - code2(_BUILTIN , p->fp) ; - } - | LENGTH /* this is an irritation */ - { $$ = code_ptr ; - code1(_PUSHINT) ; code1(0) ; - code2(_BUILTIN, $1->fp) ; - } - ; - -/* an empty production to store the code_ptr */ -mark : /* empty */ - { $$ = code_ptr ; } - -/* print_statement */ -statement : print mark pr_args pr_direction separator - { code2(_PRINT, $1) ; $$ = $2 ; - if ( $1 == bi_printf && $3 == 0 ) - compile_error("no arguments in call to printf") ; - print_flag = 0 ; - $$ = $2 ; - } - ; - -print : PRINT { $$ = bi_print ; print_flag = 1 ;} - | PRINTF { $$ = bi_printf ; print_flag = 1 ; } - ; - -pr_args : arglist { code1(_PUSHINT) ; code1($1) ; } - | LPAREN arg2 RPAREN - { $$ = $2->cnt ; zfree($2,sizeof(ARG2_REC)) ; - code1(_PUSHINT) ; code1($$) ; - } - | LPAREN RPAREN - { $$=0 ; code1(_PUSHINT) ; code1(0) ; } - ; - -arg2 : expr COMMA expr - { $$ = (ARG2_REC*) zmalloc(sizeof(ARG2_REC)) ; - $$->start = $1 ; - $$->cnt = 2 ; - } - | arg2 COMMA expr - { $$ = $1 ; $$->cnt++ ; } - ; - -pr_direction : /* empty */ - | IO_OUT expr - { code1(_PUSHINT) ; code1($1) ; } - ; - - -/* IF and IF-ELSE */ - -if_front : IF LPAREN expr RPAREN - { $$ = $3 ; eat_nl() ; code_jmp(_JZ, (INST*)0) ; } - ; - -/* if_statement */ -statement : if_front statement - { patch_jmp( code_ptr ) ; } - ; - -else : ELSE { eat_nl() ; code_jmp(_JMP, (INST*)0) ; } - ; - -/* if_else_statement */ -statement : if_front statement else statement - { patch_jmp(code_ptr) ; patch_jmp($4) ; } - - -/* LOOPS */ - -do : DO - { eat_nl() ; BC_new() ; } - ; - -/* do_statement */ -statement : do statement WHILE LPAREN expr RPAREN separator - { $$ = $2 ; - code_jmp(_JNZ, $2) ; - BC_clear(code_ptr, $5) ; } - ; - -while_front : WHILE LPAREN expr RPAREN - { eat_nl() ; BC_new() ; - $$ = $3 ; - - /* check if const expression */ - if ( code_ptr - 2 == $3 && - code_ptr[-2].op == _PUSHD && - *(double*)code_ptr[-1].ptr != 0.0 - ) - code_ptr -= 2 ; - else - { - code_push($3, code_ptr-$3) ; - code_ptr = $3 ; - code2(_JMP, (INST*)0) ; /* code2() not code_jmp() */ - } - } - ; - -/* while_statement */ -statement : while_front statement - { - INST *c_addr ; int len ; - - if ( $1 != $2 ) /* real test in loop */ - { - $1[1].op = code_ptr-($1+1) ; - c_addr = code_ptr ; - len = code_pop(code_ptr) ; - code_ptr += len ; - code_jmp(_JNZ, $2) ; - BC_clear(code_ptr, c_addr) ; - } - else /* while(1) */ - { - code_jmp(_JMP, $1) ; - BC_clear(code_ptr, $2) ; - } - } - ; - - -/* for_statement */ -statement : for1 for2 for3 statement - { - INST *cont_address = code_ptr ; - unsigned len = code_pop(code_ptr) ; - - code_ptr += len ; - - if ( $2 != $4 ) /* real test in for2 */ - { - $4[-1].op = code_ptr - $4 + 1 ; - len = code_pop(code_ptr) ; - code_ptr += len ; - code_jmp(_JNZ, $4) ; - } - else /* for(;;) */ - code_jmp(_JMP, $4) ; - - BC_clear(code_ptr, cont_address) ; - - } - ; - -for1 : FOR LPAREN SEMI_COLON { $$ = code_ptr ; } - | FOR LPAREN expr SEMI_COLON - { $$ = $3 ; code1(_POP) ; } - ; - -for2 : SEMI_COLON { $$ = code_ptr ; } - | expr SEMI_COLON - { - if ( code_ptr - 2 == $1 && - code_ptr[-2].op == _PUSHD && - * (double*) code_ptr[-1].ptr != 0.0 - ) - code_ptr -= 2 ; - else - { - code_push($1, code_ptr-$1) ; - code_ptr = $1 ; - code2(_JMP, (INST*)0) ; - } - } - ; - -for3 : RPAREN - { eat_nl() ; BC_new() ; code_push((INST*)0,0) ; } - | expr RPAREN - { eat_nl() ; BC_new() ; - code1(_POP) ; - code_push($1, code_ptr - $1) ; - code_ptr -= code_ptr - $1 ; - } - ; - - -/* arrays */ - -expr : expr IN ID - { check_array($3) ; - code_array($3) ; - code1(A_TEST) ; - } - | LPAREN arg2 RPAREN IN ID - { $$ = $2->start ; - code1(A_CAT) ; code1($2->cnt) ; - zfree($2, sizeof(ARG2_REC)) ; - - check_array($5) ; - code_array($5) ; - code1(A_TEST) ; - } - ; - -lvalue : ID mark LBOX args RBOX - { - if ( $4 > 1 ) - { code1(A_CAT) ; code1($4) ; } - - check_array($1) ; - if( is_local($1) ) - { code1(LAE_PUSHA) ; code1($1->offset) ; } - else code2(AE_PUSHA, $1->stval.array) ; - $$ = $2 ; - } - ; - -p_expr : ID mark LBOX args RBOX %prec AND - { - if ( $4 > 1 ) - { code1(A_CAT) ; code1($4) ; } - - check_array($1) ; - if( is_local($1) ) - { code1(LAE_PUSHI) ; code1($1->offset) ; } - else code2(AE_PUSHI, $1->stval.array) ; - $$ = $2 ; - } - - | ID mark LBOX args RBOX INC_or_DEC - { - if ( $4 > 1 ) - { code1(A_CAT) ; code1($4) ; } - - check_array($1) ; - if( is_local($1) ) - { code1(LAE_PUSHA) ; code1($1->offset) ; } - else code2(AE_PUSHA, $1->stval.array) ; - if ( $6 == '+' ) code1(_POST_INC) ; - else code1(_POST_DEC) ; - - $$ = $2 ; - } - ; - -/* delete A[i] */ -statement : DELETE ID mark LBOX args RBOX separator - { - $$ = $3 ; - if ( $5 > 1 ) { code1(A_CAT) ; code1($5) ; } - check_array($2) ; - code_array($2) ; - code1(A_DEL) ; - } - - ; - -/* for ( i in A ) statement */ - -array_loop_front : FOR LPAREN ID IN ID RPAREN - { eat_nl() ; BC_new() ; - $$ = code_ptr ; - - check_var($3) ; - code_address($3) ; - check_array($5) ; - code_array($5) ; - - code2(SET_ALOOP, (INST*)0) ; - } - ; - -/* array_loop */ -statement : array_loop_front statement - { - $2[-1].op = code_ptr - $2 + 1 ; - BC_clear( code_ptr+3 , code_ptr) ; - code_jmp(ALOOP, $2) ; - code_ptr++->ptr = (PTR) ZMALLOC(ALOOP_STATE) ; - } - ; - -/* fields - D_ID is a special token , same as an ID, but yylex() - only returns it after a '$'. In essense, - DOLLAR D_ID is really one token. -*/ - -field : FIELD - { $$ = code_ptr ; code2(F_PUSHA, $1) ; } - | DOLLAR D_ID - { check_var($2) ; - $$ = code_ptr ; - if ( is_local($2) ) - { code1(L_PUSHI) ; code1($2->offset) ; } - else code2(_PUSHI, $2->stval.cp) ; - - CODE_FE_PUSHA() ; - } - | DOLLAR D_ID mark LBOX args RBOX - { - if ( $5 > 1 ) - { code1(A_CAT) ; code1($5) ; } - - check_array($2) ; - if( is_local($2) ) - { code1(LAE_PUSHI) ; code1($2->offset) ; } - else code2(AE_PUSHI, $2->stval.array) ; - - CODE_FE_PUSHA() ; - - $$ = $3 ; - } - | DOLLAR p_expr - { $$ = $2 ; CODE_FE_PUSHA() ; } - | LPAREN field RPAREN - { $$ = $2 ; } - ; - -p_expr : field %prec CAT /* removes field (++|--) sr conflict */ - { field_A2I() ; } - ; - -expr : field ASSIGN expr { code1(F_ASSIGN) ; } - | field ADD_ASG expr { code1(F_ADD_ASG) ; } - | field SUB_ASG expr { code1(F_SUB_ASG) ; } - | field MUL_ASG expr { code1(F_MUL_ASG) ; } - | field DIV_ASG expr { code1(F_DIV_ASG) ; } - | field MOD_ASG expr { code1(F_MOD_ASG) ; } - | field POW_ASG expr { code1(F_POW_ASG) ; } - ; - -/* split is handled different than a builtin because - it takes an array and optionally a regular expression as args */ - -p_expr : split_front split_back - { code2(_BUILTIN, bi_split) ; } - ; - -split_front : SPLIT LPAREN expr COMMA ID - { $$ = $3 ; - check_array($5) ; - code_array($5) ; - } - ; - -split_back : RPAREN - { code2(_PUSHI, &fs_shadow) ; } - | COMMA expr RPAREN - { - if ( $2 == code_ptr - 2 ) - { - if ( code_ptr[-2].op == _MATCH0 ) - RE_as_arg() ; - else - if ( code_ptr[-2].op == _PUSHS ) - { CELL *cp = ZMALLOC(CELL) ; - - cp->type = C_STRING ; - cp->ptr = code_ptr[-1].ptr ; - cast_for_split(cp) ; - code_ptr[-2].op = _PUSHC ; - code_ptr[-1].ptr = (PTR) cp ; - } - } - } - ; - - - -/* match(expr, RE) */ - -p_expr : MATCH_FUNC LPAREN expr COMMA re_arg RPAREN - { $$ = $3 ; - code2(_BUILTIN, bi_match) ; - } - ; - - -re_arg : expr - { - if ( $1 == code_ptr - 2 ) - { - if ( $1->op == _MATCH0 ) RE_as_arg() ; - else - if ( $1->op == _PUSHS ) - { CELL *cp = ZMALLOC(CELL) ; - - cp->type = C_STRING ; - cp->ptr = $1[1].ptr ; - cast_to_RE(cp) ; - $1->op = _PUSHC ; - $1[1].ptr = (PTR) cp ; - } - } - } - - - -/* exit_statement */ -statement : EXIT separator - { $$ = code_ptr ; - code1(_EXIT0) ; } - | EXIT expr separator - { $$ = $2 ; code1(_EXIT) ; } - -return_statement : RETURN separator - { $$ = code_ptr ; - code1(_RET0) ; } - | RETURN expr separator - { $$ = $2 ; code1(_RET) ; } - -/* getline */ - -p_expr : getline %prec GETLINE - { $$ = code_ptr ; - code2(F_PUSHA, &field[0]) ; - code1(_PUSHINT) ; code1(0) ; - code2(_BUILTIN, bi_getline) ; - getline_flag = 0 ; - } - | getline fvalue %prec GETLINE - { $$ = $2 ; - code1(_PUSHINT) ; code1(0) ; - code2(_BUILTIN, bi_getline) ; - getline_flag = 0 ; - } - | getline_file p_expr %prec IO_IN - { code1(_PUSHINT) ; code1(F_IN) ; - code2(_BUILTIN, bi_getline) ; - /* getline_flag already off in yylex() */ - } - | p_expr PIPE GETLINE - { code2(F_PUSHA, &field[0]) ; - code1(_PUSHINT) ; code1(PIPE_IN) ; - code2(_BUILTIN, bi_getline) ; - } - | p_expr PIPE GETLINE fvalue - { - code1(_PUSHINT) ; code1(PIPE_IN) ; - code2(_BUILTIN, bi_getline) ; - } - ; - -getline : GETLINE { getline_flag = 1 ; } - -fvalue : lvalue | field ; - -getline_file : getline IO_IN - { $$ = code_ptr ; - code2(F_PUSHA, field+0) ; - } - | getline fvalue IO_IN - { $$ = $2 ; } - ; - -/*========================================== - sub and gsub - ==========================================*/ - -p_expr : sub_or_gsub LPAREN re_arg COMMA expr sub_back - { - if ( $6 - $5 == 2 && $5->op == _PUSHS ) - { /* cast from STRING to REPL at compile time */ - CELL *cp = ZMALLOC(CELL) ; - cp->type = C_STRING ; - cp->ptr = $5[1].ptr ; - cast_to_REPL(cp) ; - $5->op = _PUSHC ; - $5[1].ptr = (PTR) cp ; - } - code2(_BUILTIN, $1) ; - $$ = $3 ; - } - ; - -sub_or_gsub : SUB { $$ = bi_sub ; } - | GSUB { $$ = bi_gsub ; } - ; - - -sub_back : RPAREN /* substitute into $0 */ - { $$ = code_ptr ; - code2(F_PUSHA, &field[0]) ; - } - - | COMMA fvalue RPAREN - { $$ = $2 ; } - ; - -/*================================================ - user defined functions - *=================================*/ - -function_def : funct_start block - { resize_fblock($1, code_ptr) ; - code_ptr = main_code_ptr ; - scope = SCOPE_MAIN ; - active_funct = (FBLOCK *) 0 ; - restore_ids() ; - } - ; - - -funct_start : funct_head LPAREN f_arglist RPAREN - { eat_nl() ; - scope = SCOPE_FUNCT ; - active_funct = $1 ; - main_code_ptr = code_ptr ; - - if ( $1->nargs = $3 ) - $1->typev = (char *) - memset( zmalloc($3), ST_LOCAL_NONE, SIZE_T($3)) ; - else $1->typev = (char *) 0 ; - code_ptr = $1->code = - (INST *) zmalloc(PAGE_SZ*sizeof(INST)) ; - } - ; - -funct_head : FUNCTION ID - { FBLOCK *fbp ; - - if ( $2->type == ST_NONE ) - { - $2->type = ST_FUNCT ; - fbp = $2->stval.fbp = - (FBLOCK *) zmalloc(sizeof(FBLOCK)) ; - fbp->name = $2->name ; - } - else - { - type_error( $2 ) ; - - /* this FBLOCK will not be put in - the symbol table */ - fbp = (FBLOCK*) zmalloc(sizeof(FBLOCK)) ; - fbp->name = "" ; - } - $$ = fbp ; - } - - | FUNCTION FUNCT_ID - { $$ = $2 ; - if ( $2->code ) - compile_error("redefinition of %s" , $2->name) ; - } - ; - -f_arglist : /* empty */ { $$ = 0 ; } - | f_args - ; - -f_args : ID - { $1 = save_id($1->name) ; - $1->type = ST_LOCAL_NONE ; - $1->offset = 0 ; - $$ = 1 ; - } - | f_args COMMA ID - { if ( is_local($3) ) - compile_error("%s is duplicated in argument list", - $3->name) ; - else - { $3 = save_id($3->name) ; - $3->type = ST_LOCAL_NONE ; - $3->offset = $1 ; - $$ = $1 + 1 ; - } - } - ; - -outside_error : error - { /* we may have to recover from a bungled function - definition */ - - /* can have local ids, before code scope - changes */ - restore_ids() ; - - if (scope == SCOPE_FUNCT) - { scope = SCOPE_MAIN ; - active_funct = (FBLOCK*) 0 ; - } - - code_ptr = main_code_ptr ; - } - ; - -/* a call to a user defined function */ - -p_expr : FUNCT_ID mark call_args - { $$ = $2 ; - code2(_CALL, $1) ; - - if ( $3 ) code1($3->arg_num+1) ; - else code1(0) ; - - check_fcall($1, scope, active_funct, - $3, token_lineno) ; - } - ; - -call_args : LPAREN RPAREN - { $$ = (CA_REC *) 0 ; } - | ca_front ca_back - { $$ = $2 ; - $$->link = $1 ; - $$->arg_num = $1 ? $1->arg_num+1 : 0 ; - } - ; - -/* The funny definition of ca_front with the COMMA bound to the ID is to - force a shift to avoid a reduce/reduce conflict - ID->id or ID->array - - Or to avoid a decision, if the type of the ID has not yet been - determined -*/ - -ca_front : LPAREN - { $$ = (CA_REC *) 0 ; } - | ca_front expr COMMA - { $$ = (CA_REC *) zmalloc(sizeof(CA_REC)) ; - $$->link = $1 ; - $$->type = CA_EXPR ; - $$->arg_num = $1 ? $1->arg_num+1 : 0 ; - } - | ca_front ID COMMA - { $$ = (CA_REC *) zmalloc(sizeof(CA_REC)) ; - $$->link = $1 ; - $$->arg_num = $1 ? $1->arg_num+1 : 0 ; - - code_call_id($$, $2) ; - } - ; - -ca_back : expr RPAREN - { $$ = (CA_REC *) zmalloc(sizeof(CA_REC)) ; - $$->type = CA_EXPR ; - } - - | ID RPAREN - { $$ = (CA_REC *) zmalloc(sizeof(CA_REC)) ; - code_call_id($$, $1) ; - } - ; - - - - -%% - -/* resize the code for a user function */ - -static void resize_fblock( fbp, code_ptr ) - FBLOCK *fbp ; - INST *code_ptr ; -{ int size ; - - code1(_RET0) ; /* make sure there is always a return statement */ - -#if !SM_DOS - if ( dump_code ) - { code1(_HALT) ; /*stops da() */ - add_to_fdump_list(fbp) ; - } -#endif - - if ( (size = code_ptr - fbp->code) > PAGE_SZ-1 ) - overflow("function code size", PAGE_SZ ) ; - - /* resize the code */ - fbp->code = (INST*) zrealloc(fbp->code, PAGE_SZ*sizeof(INST), - size * sizeof(INST) ) ; - -} - - -/* convert FE_PUSHA to FE_PUSHI - or F_PUSH to F_PUSHI -*/ - -static void field_A2I() -{ CELL *cp ; - - if ( code_ptr[-1].op == FE_PUSHA && - code_ptr[-1].ptr == (PTR) 0) - /* On most architectures, the two tests are the same; a good - compiler might eliminate one. On LM_DOS, and possibly other - segmented architectures, they are not */ - { code_ptr[-1].op = FE_PUSHI ; } - else - { - cp = (CELL *) code_ptr[-1].ptr ; - - if ( cp == field || - -#if LM_DOS - SAMESEG(cp,field) && -#endif - cp > NF && cp <= LAST_PFIELD ) - { - code_ptr[-2].op = _PUSHI ; - } - else if ( cp == NF ) - { code_ptr[-2].op = NF_PUSHI ; code_ptr-- ; } - - else - { - code_ptr[-2].op = F_PUSHI ; - code_ptr -> op = field_addr_to_index( code_ptr[-1].ptr ) ; - code_ptr++ ; - } - } -} - -/* we've seen an ID in a context where it should be a VAR, - check that's consistent with previous usage */ - -static void check_var( p ) - register SYMTAB *p ; -{ - switch(p->type) - { - case ST_NONE : /* new id */ - p->type = ST_VAR ; - p->stval.cp = new_CELL() ; - p->stval.cp->type = C_NOINIT ; - break ; - - case ST_LOCAL_NONE : - p->type = ST_LOCAL_VAR ; - active_funct->typev[p->offset] = ST_LOCAL_VAR ; - break ; - - case ST_VAR : - case ST_LOCAL_VAR : break ; - - default : - type_error(p) ; - break ; - } -} - -/* we've seen an ID in a context where it should be an ARRAY, - check that's consistent with previous usage */ -static void check_array(p) - register SYMTAB *p ; -{ - switch(p->type) - { - case ST_NONE : /* a new array */ - p->type = ST_ARRAY ; - p->stval.array = new_ARRAY() ; - break ; - - case ST_ARRAY : - case ST_LOCAL_ARRAY : - break ; - - case ST_LOCAL_NONE : - p->type = ST_LOCAL_ARRAY ; - active_funct->typev[p->offset] = ST_LOCAL_ARRAY ; - break ; - - default : type_error(p) ; break ; - } -} - -static void code_array(p) - register SYMTAB *p ; -{ if ( is_local(p) ) - { code1(LA_PUSHA) ; code1(p->offset) ; } - else code2(A_PUSHA, p->stval.array) ; -} - - -static int current_offset() -{ - switch( scope ) - { - case SCOPE_MAIN : return code_ptr - main_start ; - case SCOPE_BEGIN : return code_ptr - begin_code.start ; - case SCOPE_END : return code_ptr - end_code.start ; - case SCOPE_FUNCT : return code_ptr - active_funct->code ; - } - /* can't get here */ - return 0 ; -} - -/* we've seen an ID as an argument to a user defined function */ - -static void code_call_id( p, ip ) - register CA_REC *p ; - register SYMTAB *ip ; -{ static CELL dummy ; - - switch( ip->type ) - { - case ST_VAR : - p->type = CA_EXPR ; - code2(_PUSHI, ip->stval.cp) ; - break ; - - case ST_LOCAL_VAR : - p->type = CA_EXPR ; - code1(L_PUSHI) ; - code1(ip->offset) ; - break ; - - case ST_ARRAY : - p->type = CA_ARRAY ; - code2(A_PUSHA, ip->stval.array) ; - break ; - - case ST_LOCAL_ARRAY : - p->type = CA_ARRAY ; - code1(LA_PUSHA) ; - code1(ip->offset) ; - break ; - - /* not enough info to code it now; it will have to - be patched later */ - - case ST_NONE : - p->type = ST_NONE ; - p->call_offset = current_offset() ; - p->sym_p = ip ; - code2(_PUSHI, &dummy) ; - break ; - - case ST_LOCAL_NONE : - p->type = ST_LOCAL_NONE ; - p->call_offset = current_offset() ; - p->type_p = & active_funct->typev[ip->offset] ; - code1(L_PUSHI) ; - code1(ip->offset) ; - break ; - - -#ifdef DEBUG - default : - bozo("code_call_id") ; -#endif - - } -} - -/* an RE by itself was coded as _MATCH0 , change to - push as an expression */ - -static void RE_as_arg() -{ CELL *cp = ZMALLOC(CELL) ; - - code_ptr -= 2 ; - cp->type = C_RE ; - cp->ptr = code_ptr[1].ptr ; - code2(_PUSHC, cp) ; -} - - -int parse() -{ int yy = yyparse() ; - -#if YYBYACC - extern struct yacc_mem *yacc_memp ; - - yacc_memp++ ; /* puts parser tables in mem pool */ -#endif - - if ( resolve_list ) resolve_fcalls() ; - return yy ; -} - diff --git a/gnu/usr.bin/awk/parse2.xc b/gnu/usr.bin/awk/parse2.xc deleted file mode 100644 index 95bc446b4bcb..000000000000 --- a/gnu/usr.bin/awk/parse2.xc +++ /dev/null @@ -1,46 +0,0 @@ - -/******************************************** -parse2.xc -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* If using Berkeley yacc, we can put the parser table - memory to the zmalloc pool. This is kind of ugly and - with paged vm probably a nop, but for DOS and MINIX and ?? - it frees a considerably amount of memory. - - This file is part of parse.c via - cat y.tab.c parse2.xc > parse.c -*/ - -static struct yacc_mem yacc_mem[] = -{ -0 , 0 , /* don't remove this */ - -#ifdef YYBYACC -(PTR) yycheck, sizeof(yycheck)/ZBLOCKSZ, -(PTR) yytable, sizeof(yytable)/ZBLOCKSZ, -#ifndef YYXBYACC /* with xbyacc these are storage auto */ -(PTR) yyvs , sizeof(yyvs)/ZBLOCKSZ, -(PTR) yyss, sizeof(yyss)/ZBLOCKSZ, -#endif -(PTR) yydefred, sizeof(yydefred)/ZBLOCKSZ, -(PTR) yydgoto, sizeof(yydgoto)/ZBLOCKSZ, -(PTR) yygindex, sizeof(yygindex)/ZBLOCKSZ, -(PTR) yylen, sizeof(yylen)/ZBLOCKSZ, -(PTR) yylhs, sizeof(yylhs)/ZBLOCKSZ, -(PTR) yyrindex, sizeof(yyrindex)/ZBLOCKSZ, -(PTR) yysindex, sizeof(yysindex)/ZBLOCKSZ, -#endif - -0,0 } ; - -struct yacc_mem *yacc_memp = yacc_mem ; - diff --git a/gnu/usr.bin/awk/patchlev.h b/gnu/usr.bin/awk/patchlev.h deleted file mode 100644 index afceea0be3a7..000000000000 --- a/gnu/usr.bin/awk/patchlev.h +++ /dev/null @@ -1,4 +0,0 @@ -/* mawk 1.1 */ -#define PATCHLEVEL 4 -#define PATCH_STRING ".4" -#define DATE_STRING "May 1993" diff --git a/gnu/usr.bin/awk/print.c b/gnu/usr.bin/awk/print.c deleted file mode 100644 index 503c12c3eb91..000000000000 --- a/gnu/usr.bin/awk/print.c +++ /dev/null @@ -1,523 +0,0 @@ - -/******************************************** -print.c -copyright 1992, 1991. Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: print.c,v $ -/* Revision 1.2 1993/07/02 23:57:48 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.4.1.2 1993/01/20 12:53:11 mike - * d_to_l() - * - * Revision 5.4.1.1 1993/01/15 03:33:47 mike - * patch3: safer double to int conversion - * - * Revision 5.4 1992/11/29 18:03:11 mike - * when printing integers, convert doubles to - * longs so output is the same on 16bit systems as 32bit systems - * - * Revision 5.3 1992/08/17 14:23:21 brennan - * patch2: After parsing, only bi_sprintf() uses string_buff. - * - * Revision 5.2 1992/02/24 10:52:16 brennan - * printf and sprintf() can now have more args than % conversions - * removed HAVE_PRINTF_HD -- it was too obscure - * - * Revision 5.1 91/12/05 07:56:22 brennan - * 1.1 pre-release - * -*/ - -#include "mawk.h" -#include "bi_vars.h" -#include "bi_funct.h" -#include "memory.h" -#include "field.h" -#include "scan.h" -#include "files.h" - -static void PROTO( print_cell, (CELL *, FILE *) ) ; -static STRING* PROTO( do_printf, (FILE *, char *, unsigned, CELL *) ) ; -static void PROTO( bad_conversion, (int, char *, char *)) ; - - - -/* this can be moved and enlarged by -W sprintf=num */ -char *sprintf_buff = string_buff ; -char *sprintf_limit = string_buff + SPRINTF_SZ ; - -/* Once execute() starts the sprintf code is (belatedly) the only - code allowed to use string_buff */ - -static void print_cell(p, fp) - register CELL *p ; - register FILE *fp ; -{ - int len ; - - switch( p->type ) - { - case C_NOINIT : break ; - case C_MBSTRN : - case C_STRING : - case C_STRNUM : - switch( len = string(p)->len ) - { - case 0 : break ; - case 1 : - putc(string(p)->str[0],fp) ; - break ; - - default : - fwrite(string(p)->str, SIZE_T(1), SIZE_T(len), fp) ; - } - break ; - - case C_DOUBLE : - { - long ival = d_to_l(p->dval) ; - - /* integers print as "%[l]d" */ - if ( (double) ival == p->dval ) - fprintf(fp, INT_FMT, ival) ; - else - fprintf(fp, string(OFMT)->str, p->dval) ; - } - break ; - - default : - bozo("bad cell passed to print_cell") ; - } -} - -/* on entry to bi_print or bi_printf the stack is: - - sp[0] = an integer k - if ( k < 0 ) output is to a file with name in sp[-1] - { so open file and sp -= 2 } - - sp[0] = k >= 0 is the number of print args - sp[-k] holds the first argument -*/ - -CELL *bi_print(sp) - CELL *sp ; /* stack ptr passed in */ -{ - register CELL *p ; - register int k ; - FILE *fp ; - - k = sp->type ; - if ( k < 0 ) - { - /* k holds redirection */ - if ( (--sp)->type < C_STRING ) cast1_to_s(sp) ; - fp = (FILE *) file_find( string(sp), k ) ; - free_STRING(string(sp)) ; - k = (--sp)->type ; - /* k now has number of arguments */ - } - else fp = stdout ; - - if ( k ) - { - p = sp - k ; /* clear k variables off the stack */ - sp = p - 1 ; - k-- ; - - while ( k > 0 ) - { - print_cell(p,fp) ; print_cell(OFS,fp) ; - cell_destroy(p) ; - p++ ; k-- ; - } - - print_cell(p, fp) ; cell_destroy(p) ; - } - else - { /* print $0 */ - sp-- ; - print_cell( &field[0], fp ) ; - } - - print_cell(ORS , fp) ; - return sp ; -} - -/*---------- types and defs for doing printf and sprintf----*/ -#define PF_C 0 /* %c */ -#define PF_S 1 /* %s */ -#define PF_D 2 /* int conversion */ -#define PF_F 3 /* float conversion */ - -/* for switch on number of '*' and type */ -#define AST(num,type) ((PF_F+1)*(num)+(type)) - -/* some picky ANSI compilers go berserk without this */ -#if HAVE_PROTOS -typedef int (*PRINTER)(PTR,char *,...) ; -#else -typedef int (*PRINTER)() ; -#endif - -/*-------------------------------------------------------*/ - -static void bad_conversion(cnt, who, format) - int cnt ; - char *who , *format ; -{ - rt_error( "improper conversion(number %d) in %s(\"%s\")", - cnt, who, format ) ; -} - -/* the contents of format are preserved, - caller does CELL cleanup - - This routine does both printf and sprintf (if fp==0) -*/ -static STRING *do_printf( fp, format, argcnt, cp) - FILE *fp ; - char *format ; - CELL *cp ; /* ptr to an array of arguments ( on the eval stack) */ - unsigned argcnt ; /* number of args on eval stack */ -{ - char save ; - char *p ; - register char *q = format ; - register char *target ; - int l_flag , h_flag ; /* seen %ld or %hd */ - int ast_cnt ; - int ast[2] ; - long lval ; /* hold integer values */ - int num_conversion = 0 ; /* for error messages */ - char *who ; /*ditto*/ - int pf_type ; /* conversion type */ - PRINTER printer ; /* pts at fprintf() or sprintf() */ - -#ifdef SHORT_INTS - char xbuff[256] ; /* splice in l qualifier here */ -#endif - - if ( fp == (FILE *) 0 ) /* doing sprintf */ - { - target = sprintf_buff ; - printer = (PRINTER) sprintf ; - who = "sprintf" ; - } - else /* doing printf */ - { - target = (char *) fp ; /* will never change */ - printer = (PRINTER) fprintf ; - who = "printf" ; - } - - while ( 1 ) - { - if ( fp ) /* printf */ - { - while ( *q != '%' ) - if ( *q == 0 ) return (STRING *) 0 ; - else - { putc(*q,fp) ; q++ ; } - } - else /* sprintf */ - { - while ( *q != '%' ) - if ( *q == 0 ) - { - if ( target > sprintf_limit ) /* damaged */ - { - /* hope this works */ - rt_overflow("sprintf buffer", - sprintf_limit - sprintf_buff) ; - } - else /* really done */ - { - STRING *retval ; - int len = target - sprintf_buff ; - - retval = new_STRING((char*)0, len) ; - (void)memcpy(retval->str, sprintf_buff, SIZE_T(len)) ; - return retval ; - } - } - else *target++ = *q++ ; - } - - - /* *q == '%' */ - num_conversion++ ; - - if ( * ++q == '%' ) /* %% */ - { - if ( fp ) putc(*q, fp) ; - else *target++ = *q ; - - q++ ; continue ; - } - - /* mark the '%' with p */ - p = q-1 ; - - /* eat the flags */ - while ( *q == '-' || *q == '+' || *q == ' ' || - *q == '#' || *q == '0' ) q++ ; - - ast_cnt = 0 ; - if ( *q == '*' ) - { - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - ast[ast_cnt++] = d_to_i(cp++ ->dval) ; - argcnt-- ; q++ ; - } - else - while ( scan_code[*(unsigned char *)q] == SC_DIGIT ) q++ ; - /* width is done */ - - if ( *q == '.' ) /* have precision */ - { q++ ; - if ( *q == '*' ) - { - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - ast[ast_cnt++] = d_to_i(cp++ ->dval) ; - argcnt-- ; q++ ; - } - else - while ( scan_code[*(unsigned char*)q] == SC_DIGIT ) q++ ; - } - - if ( argcnt <= 0 ) - rt_error("not enough arguments passed to %s(\"%s\")", - who, format) ; - - l_flag = h_flag = 0 ; - - if ( *q == 'l' ) { q++ ; l_flag = 1 ; } - else - if ( *q == 'h' ) { q++ ; h_flag = 1 ; } - - switch( *q++ ) - { - case 's' : - if ( l_flag + h_flag ) - bad_conversion(num_conversion,who,format) ; - if ( cp->type < C_STRING ) cast1_to_s(cp) ; - pf_type = PF_S ; - break ; - - case 'c' : - if ( l_flag + h_flag ) - bad_conversion(num_conversion,who,format) ; - - switch( cp->type ) - { - case C_NOINIT : - lval = 0 ; - break ; - - case C_STRNUM : - case C_DOUBLE : - lval = (long) d_to_i(cp->dval) ; - break ; - - case C_STRING : - lval = string(cp)->str[0] ; - break ; - - case C_MBSTRN : - check_strnum(cp) ; - lval = cp->type == C_STRING ? - string(cp)->str[0] : (long) d_to_i(cp->dval) ; - break ; - - default : - bozo("printf %c") ; - } - - pf_type = PF_C ; - break ; - - case 'd' : - case 'o' : - case 'x' : - case 'X' : - case 'i' : - case 'u' : - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - if ( cp->dval > MAX__LONG ) lval = MAX__LONG ; - else - if ( cp->dval > -MAX__LONG ) lval = (long) cp->dval ; - else lval = -MAX__LONG ; - - pf_type = PF_D ; - break ; - - case 'e' : - case 'g' : - case 'f' : - case 'E' : - case 'G' : - if ( h_flag + l_flag ) - bad_conversion(num_conversion,who,format) ; - if ( cp->type != C_DOUBLE ) cast1_to_d(cp) ; - pf_type = PF_F ; - break ; - - default : bad_conversion(num_conversion,who,format) ; - } - - save = *q ; - *q = 0 ; - -#ifdef SHORT_INTS - if ( pf_type == PF_D ) - { - /* need to splice in long modifier */ - strcpy(xbuff, p) ; - - if ( l_flag ) /* do nothing */ ; - else - { - int k = q - p ; - - if ( h_flag ) - { - lval = (short) lval ; - /* replace the 'h' with 'l' (really!) */ - xbuff[k-2] = 'l' ; - if ( xbuff[k-1] != 'd' && xbuff[k-1] != 'i' ) lval &= 0xffff ; - } - else - { - /* the usual case */ - xbuff[k] = xbuff[k-1] ; - xbuff[k-1] = 'l' ; - xbuff[k+1] = 0 ; - } - } - } -#endif - - /* ready to call printf() */ - switch( AST(ast_cnt, pf_type ) ) - { - case AST(0, PF_C ) : - (*printer)((PTR) target, p, (int) lval) ; - break ; - - case AST(1, PF_C ) : - (*printer)((PTR) target, p, ast[0], (int) lval) ; - break ; - - case AST(2, PF_C ) : - (*printer)((PTR) target, p, ast[0], ast[1], (int)lval) ; - break ; - - case AST(0, PF_S) : - (*printer)((PTR) target, p, string(cp)->str) ; - break ; - - case AST(1, PF_S) : - (*printer)((PTR) target, p, ast[0],string(cp)->str) ; - break ; - - case AST(2, PF_S) : - (*printer)((PTR) target,p,ast[0],ast[1],string(cp)->str) ; - break ; - -#ifdef SHORT_INTS -#define FMT xbuff /* format in xbuff */ -#else -#define FMT p /* p -> format */ -#endif - case AST(0, PF_D) : - (*printer)((PTR) target, FMT, lval) ; - break ; - - case AST(1, PF_D) : - (*printer)((PTR) target, FMT, ast[0], lval) ; - break ; - - case AST(2, PF_D) : - (*printer)((PTR) target, FMT, ast[0], ast[1], lval) ; - break ; - -#undef FMT - - - case AST(0, PF_F) : - (*printer)((PTR) target, p, cp->dval) ; - break ; - - case AST(1, PF_F) : - (*printer)((PTR) target, p, ast[0], cp->dval) ; - break ; - - case AST(2, PF_F) : - (*printer)((PTR) target, p, ast[0], ast[1], cp->dval) ; - break ; - } - if ( fp == (FILE *) 0 ) while ( *target ) target++ ; - *q = save ; argcnt-- ; cp++ ; - } -} - -CELL *bi_printf(sp) - register CELL *sp ; -{ register int k ; - register CELL *p ; - FILE *fp ; - - k = sp->type ; - if ( k < 0 ) - { - /* k has redirection */ - if ( (--sp)->type < C_STRING ) cast1_to_s(sp) ; - fp = (FILE *) file_find( string(sp), k ) ; - free_STRING(string(sp)) ; - k = (--sp)->type ; - /* k is now number of args including format */ - } - else fp = stdout ; - - sp -= k ; /* sp points at the format string */ - k-- ; - - if ( sp->type < C_STRING ) cast1_to_s(sp) ; - do_printf(fp, string(sp)->str, k, sp+1) ; - free_STRING(string(sp)) ; - - /* cleanup arguments on eval stack */ - for ( p = sp+1 ; k ; k--, p++ ) cell_destroy(p) ; - return --sp ; -} - -CELL *bi_sprintf(sp) - CELL *sp ; -{ CELL *p ; - int argcnt = sp->type ; - STRING *sval ; - - sp -= argcnt ; /* sp points at the format string */ - argcnt-- ; - - if ( sp->type != C_STRING ) cast1_to_s(sp) ; - sval = do_printf((FILE *)0, string(sp)->str, argcnt, sp+1) ; - free_STRING(string(sp)) ; - sp->ptr = (PTR) sval ; - - /* cleanup */ - for (p = sp+1 ; argcnt ; argcnt--, p++ ) cell_destroy(p) ; - - return sp ; -} - - diff --git a/gnu/usr.bin/awk/re_cmpl.c b/gnu/usr.bin/awk/re_cmpl.c deleted file mode 100644 index 89e0f094b212..000000000000 --- a/gnu/usr.bin/awk/re_cmpl.c +++ /dev/null @@ -1,337 +0,0 @@ - -/******************************************** -re_cmpl.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: re_cmpl.c,v $ -/* Revision 1.2 1993/07/02 23:57:49 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:56:25 brennan - * 1.1 pre-release - * -*/ - - -/* re_cmpl.c */ - -#include "mawk.h" -#include "memory.h" -#include "scan.h" -#include "regexp.h" -#include "repl.h" - - -static CELL *PROTO( REPL_compile, (STRING *) ) ; - -typedef struct re_node { -STRING *sval ; -PTR re ; -struct re_node *link ; -} RE_NODE ; - -static RE_NODE *re_list ; /* a list of compiled regular expressions */ - -static char efmt[] = "regular expression compile failed (%s)\n%s" ; - -PTR re_compile( sval ) - STRING *sval ; -{ register RE_NODE *p ; - RE_NODE *q ; - char *s ; - - /* search list */ - s = sval->str ; - p = re_list ; - q = (RE_NODE *) 0 ; - while ( p ) - if ( strcmp(s, p->sval->str) == 0 ) /* found */ - if ( !q ) /* already at front */ goto _return ; - else /* delete from list for move to front */ - { q->link = p->link ; goto found ; } - else - { q = p ; p = p->link ; } - - /* not found */ - p = (RE_NODE *) zmalloc( sizeof(RE_NODE) ) ; - p->sval = sval ; - - sval->ref_cnt++ ; - if( !(p->re = REcompile(s)) ) - if ( mawk_state == EXECUTION ) - rt_error(efmt, REerrlist[REerrno] , s) ; - else /* compiling */ - { compile_error(efmt, REerrlist[REerrno] , s) ; - return (PTR) 0 ; - } - - -found : -/* insert p at the front of the list */ - p->link = re_list ; re_list = p ; - -_return : - -#ifdef DEBUG - if ( dump_RE ) REmprint(p->re, stderr) ; -#endif - return p->re ; -} - - - -/* this is only used by da() */ - -#if ! SM_DOS - -char *re_uncompile( m ) - PTR m ; -{ register RE_NODE *p ; - - for( p = re_list ; p ; p = p->link ) - if ( p->re == m ) return p->sval->str ; -#ifdef DEBUG - bozo("non compiled machine") ; -#endif -} -#endif /* not SM_DOS */ - - - -/*=================================================*/ -/* replacement operations */ - -/* create a replacement CELL from a STRING * */ - -static CELL *REPL_compile( sval ) - STRING *sval ; -{ int i = 0 ; - register char *p = sval->str ; - register char *q ; - char *xbuff ; - CELL *cp ; - - q = xbuff = (char *) zmalloc( sval->len + 1 ) ; - - while ( 1 ) - { - switch( *p ) - { - case 0 : *q = 0 ; - goto done ; - - case '\\': - if ( p[1] == '&' ) - { *q++ = '&' ; p += 2 ; continue ; } - else break ; - - case '&': - /* if empty we don't need to make a node */ - if ( q != xbuff ) - { *q = 0 ; - split_buff[i++] = new_STRING(xbuff) ; - } - /* and a null node for the '&' */ - split_buff[i++] = (STRING *) 0 ; - /* reset */ - p++ ; q = xbuff ; - continue ; - - default : - break ; - } - - *q++ = *p++ ; - } - -done : - /* if we have one empty string it will get made now */ - if ( q > xbuff || i == 0 ) - split_buff[i++] = new_STRING(xbuff) ; - - /* This will never happen */ - if ( i > MAX_SPLIT ) - overflow("replacement pieces", MAX_SPLIT) ; - - cp = new_CELL() ; - if ( i == 1 ) - { - cp->type = C_REPL ; - cp->ptr = (PTR) split_buff[0] ; - } - else - { - STRING **sp = (STRING**) - (cp->ptr = zmalloc(sizeof(STRING *)*i)) ; - int j = 0 ; - - while ( j < i ) *sp++ = split_buff[j++] ; - - cp->type = C_REPLV ; - cp->vcnt = i ; - } - zfree(xbuff, sval->len+1) ; - return cp ; -} - -/* free memory used by a replacement CELL */ - -void repl_destroy( cp ) - register CELL *cp ; -{ register STRING **p ; - unsigned cnt ; - - if ( cp->type == C_REPL ) free_STRING(string(cp)) ; - else /* an C_REPLV */ - { - p = (STRING **) cp->ptr ; - for( cnt = cp->vcnt ; cnt ; cnt--) - { - if ( *p ) free_STRING( *p ) ; - p++ ; - } - zfree( cp->ptr, cp->vcnt * sizeof(STRING *) ) ; - } -} - -/* copy a C_REPLV cell to another CELL */ - -CELL *replv_cpy( target, source ) - CELL *target , *source ; -{ STRING **t, **s ; - unsigned cnt ; - - target->type = C_REPLV ; - target->vcnt = source->vcnt ; - - target->ptr = (PTR) zmalloc( target->vcnt * sizeof(STRING *) ) ; - cnt = target->vcnt ; - t = (STRING **) target->ptr ; - s = (STRING **) source->ptr ; - while ( cnt-- ) - { - if ( *t = *s++ ) (*t)->ref_cnt++ ; - t++ ; - } - return target ; -} - -/* here's our old friend linked linear list with move to the front - for compilation of replacement CELLs */ - -typedef struct repl_node { - struct repl_node *link ; - STRING *sval ; /* the input */ - CELL *cp ; /* the output */ -} REPL_NODE ; - -static REPL_NODE *repl_list ; - -/* search the list (with move to the front) for a compiled - separator. - return a ptr to a CELL (C_REPL or C_REPLV) -*/ - -CELL *repl_compile( sval ) - STRING *sval ; -{ register REPL_NODE *p ; - REPL_NODE *q ; - char *s ; - - /* search the list */ - s = sval->str ; - p = repl_list ; - q = (REPL_NODE *) 0 ; - while ( p ) - if ( strcmp(s, p->sval->str) == 0 ) /* found */ - if ( !q ) /* already at front */ return p->cp ; - else /* delete from list for move to front */ - { q->link = p->link ; goto found ; } - else - { q = p ; p = p->link ; } - - /* not found */ - p = (REPL_NODE *) zmalloc( sizeof(REPL_NODE) ) ; - p->sval = sval ; - sval->ref_cnt++ ; - p->cp = REPL_compile(sval) ; - -found : -/* insert p at the front of the list */ - p->link = repl_list ; repl_list = p ; - return p->cp ; -} - -/* return the string for a CELL or type REPL or REPLV, - this is only used by da() */ - -#if ! SM_DOS - -char *repl_uncompile( cp ) - CELL *cp ; -{ - register REPL_NODE *p = repl_list ; - - if ( cp->type == C_REPL ) - while ( p ) - if ( p->cp->type == C_REPL && - p->cp->ptr == cp->ptr ) return p->sval->str ; - else p = p->link ; - else - while ( p ) - if ( p->cp->type == C_REPLV && - memcmp( cp->ptr, p->cp->ptr, SIZE_T(cp->vcnt * sizeof(STRING*))) - == 0 ) return p->sval->str ; - else p = p->link ; - -#if DEBUG - bozo("unable to uncompile an repl") ; -#endif -} -#endif /* ! SM_DOS */ - -/* - convert a C_REPLV to C_REPL - replacing the &s with sval -*/ - -CELL *replv_to_repl( cp, sval) - CELL *cp ; STRING *sval ; -{ register STRING **p ; - STRING **sblock = (STRING **) cp->ptr ; - unsigned cnt , vcnt = cp->vcnt ; - unsigned len ; - char *target ; - -#ifdef DEBUG - if ( cp->type != C_REPLV ) bozo("not replv") ; -#endif - - p = sblock ; cnt = vcnt ; len = 0 ; - while ( cnt-- ) - if ( *p ) len += (*p++)->len ; - else - { *p++ = sval ; sval->ref_cnt++ ; len += sval->len ; } - - cp->type = C_REPL ; - cp->ptr = (PTR) new_STRING((char *) 0, len) ; - - p = sblock ; cnt = vcnt ; target = string(cp)->str ; - while ( cnt-- ) - { (void) memcpy(target, (*p)->str, SIZE_T((*p)->len)) ; - target += (*p)->len ; - free_STRING(*p) ; - p++ ; - } - - zfree( sblock, vcnt * sizeof(STRING *) ) ; - return cp ; -} - diff --git a/gnu/usr.bin/awk/regexp.h b/gnu/usr.bin/awk/regexp.h deleted file mode 100644 index ec96ca477dc5..000000000000 --- a/gnu/usr.bin/awk/regexp.h +++ /dev/null @@ -1,32 +0,0 @@ - -/******************************************** -regexp.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: regexp.h,v $ -/*Revision 1.2 1993/07/02 23:57:51 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:59:30 brennan - * 1.1 pre-release - * -*/ - -#include - -PTR PROTO( REcompile , (char *) ) ; -int PROTO( REtest, (char *, PTR) ) ; -char *PROTO( REmatch, (char *, PTR, unsigned *) ) ; -void PROTO( REmprint, (PTR , FILE*) ) ; - -extern int REerrno ; -extern char *REerrlist[] ; - - diff --git a/gnu/usr.bin/awk/repl.h b/gnu/usr.bin/awk/repl.h deleted file mode 100644 index afc4eb95fa6f..000000000000 --- a/gnu/usr.bin/awk/repl.h +++ /dev/null @@ -1,37 +0,0 @@ - -/******************************************** -repl.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: repl.h,v $ -/*Revision 1.2 1993/07/02 23:57:52 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:59:32 brennan - * 1.1 pre-release - * -*/ - -/* repl.h */ - -#ifndef REPL_H -#define REPL_H - -PTR PROTO( re_compile, (STRING *) ) ; -char *PROTO( re_uncompile, (PTR) ) ; - - -CELL *PROTO( repl_compile, (STRING *) ) ; -char *PROTO( repl_uncompile, (CELL *) ) ; -void PROTO( repl_destroy, (CELL *) ) ; -CELL *PROTO( replv_cpy, (CELL *, CELL *) ) ; -CELL *PROTO( replv_to_repl, (CELL *, STRING *) ) ; - -#endif diff --git a/gnu/usr.bin/awk/scan.c b/gnu/usr.bin/awk/scan.c deleted file mode 100644 index 66d134bc21d6..000000000000 --- a/gnu/usr.bin/awk/scan.c +++ /dev/null @@ -1,861 +0,0 @@ - -/******************************************** -scan.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: scan.c,v $ -/* Revision 1.2 1993/07/02 23:57:54 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.4.1.1 1993/01/15 03:33:50 mike - * patch3: safer double to int conversion - * - * Revision 5.4 1992/11/29 18:57:50 mike - * field expressions convert to long so 16 bit and 32 bit - * systems behave the same - * - * Revision 5.3 1992/07/08 15:43:41 brennan - * patch2: length returns. I am a wimp - * - * Revision 5.2 1992/02/21 14:16:53 brennan - * fix: getline <= - * - * Revision 5.1 91/12/05 07:56:27 brennan - * 1.1 pre-release - * -*/ - - -#include "mawk.h" -#include "sizes.h" -#include "scan.h" -#include "memory.h" -#include "field.h" -#include "init.h" -#include "fin.h" -#include "repl.h" -#include "code.h" - -#if HAVE_FCNTL_H -#include -#endif - -#include "files.h" - - -/* static functions */ -static void PROTO(scan_fillbuff, (void) ) ; -static void PROTO(scan_open, (void) ) ; -static int PROTO(slow_next, (void) ) ; -static void PROTO(eat_comment, (void) ) ; -static void PROTO(eat_semi_colon, (void) ) ; -static double PROTO(collect_decimal, (int, int *) ) ; -static int PROTO(collect_string, (void) ) ; -static int PROTO(collect_RE, (void) ) ; - - -/*----------------------------- - program file management - *----------------------------*/ - -char *pfile_name ; -STRING *program_string ; -PFILE *pfile_list ; -static unsigned char *buffer ; -static unsigned char *buffp ; - /* unsigned so it works with 8 bit chars */ -static int program_fd ; -static int eof_flag ; - -void scan_init(cmdline_program) - char * cmdline_program ; -{ - if ( cmdline_program ) - { - program_fd = -1 ; /* command line program */ - program_string = new_STRING((char *)0, - strlen(cmdline_program) + 1 ) ; - (void) strcpy(program_string->str, cmdline_program) ; - /* simulate file termination */ - program_string->str[program_string->len-1] = '\n' ; - buffp = (unsigned char *) program_string->str ; - eof_flag = 1 ; - } - else /* program from file[s] */ - { - scan_open() ; - buffp = buffer = (unsigned char *) zmalloc( BUFFSZ+1 ) ; - scan_fillbuff() ; - } - - eat_nl() ; /* scan to first token */ - if ( next() == 0 ) { errmsg(0, "no program") ; mawk_exit(1) ; } - un_next() ; - -} - -static void scan_open() /* open pfile_name */ -{ - if ( pfile_name[0] == '-' && pfile_name[1] == 0 ) - program_fd = 0 ; - else - if ( (program_fd = open(pfile_name, O_RDONLY, 0)) == -1 ) - { errmsg( errno, "cannot open %s", pfile_name) ; mawk_exit(1) ; } -} - -void scan_cleanup() -{ - if ( program_fd >= 0 ) zfree(buffer, BUFFSZ+1) ; - else free_STRING(program_string) ; - - if ( program_fd > 0 ) (void) close(program_fd) ; - - /* redefine SPACE as [ \t\n] */ - - scan_code['\n'] = posix_space_flag && rs_shadow.type != SEP_MLR - ? SC_UNEXPECTED : SC_SPACE ; - scan_code['\f'] = SC_UNEXPECTED ; /*value doesn't matter */ - scan_code['\013'] = SC_UNEXPECTED ; /* \v not space */ - scan_code['\r'] = SC_UNEXPECTED ; -} - -/*-------------------------------- - global variables shared by yyparse() and yylex() - and used for error messages too - *-------------------------------*/ - -int current_token = -1 ; -unsigned token_lineno ; -unsigned compile_error_count ; -int NR_flag ; /* are we tracking NR */ -int paren_cnt ; -int brace_cnt ; -int print_flag ; /* changes meaning of '>' */ -int getline_flag ; /* changes meaning of '<' */ - -extern YYSTYPE yylval ; - -/*---------------------------------------- - file reading functions - next() and un_next(c) are macros in scan.h - - *---------------------*/ - -static unsigned lineno = 1 ; - - -static void scan_fillbuff() -{ unsigned r ; - - r = fillbuff(program_fd, (char *)buffer, BUFFSZ) ; - if ( r < BUFFSZ ) - { eof_flag = 1 ; - /* check eof is terminated */ - if ( r && buffer[r-1] != '\n' ) - { buffer[r] = '\n' ; buffer[r+1] = 0 ; } - } -} - -/* read one character -- slowly */ -static int slow_next() -{ - - while ( *buffp == 0 ) - { - if ( !eof_flag ) - { buffp = buffer ; scan_fillbuff() ; } - else - if ( pfile_list /* open another program file */ ) - { - PFILE *q ; - - if ( program_fd > 0 ) (void) close(program_fd) ; - eof_flag = 0 ; - pfile_name = pfile_list->fname ; - q = pfile_list ; - pfile_list = pfile_list->link ; - ZFREE(q) ; - scan_open() ; - token_lineno = lineno = 1 ; - } - else break /* real eof */ ; - } - - return *buffp++ ; /* note can un_next() , eof which is zero */ -} - -static void eat_comment() -{ register int c ; - - while ( (c = next()) != '\n' && scan_code[c] ) ; - un_next() ; -} - -/* this is how we handle extra semi-colons that are - now allowed to separate pattern-action blocks - - A proof that they are useless clutter to the language: - we throw them away -*/ - -static void eat_semi_colon() -/* eat one semi-colon on the current line */ -{ register int c ; - - while ( scan_code[c = next()] == SC_SPACE ) ; - if ( c != ';' ) un_next() ; -} - -void eat_nl() /* eat all space including newlines */ -{ - while ( 1 ) - switch( scan_code[next()] ) - { - case SC_COMMENT : - eat_comment() ; - break ; - - case SC_NL : lineno++ ; - /* fall thru */ - case SC_SPACE : break ; - default : - un_next() ; return ; - } -} - -int yylex() -{ - register int c ; - - token_lineno = lineno ; - -reswitch: - - switch( scan_code[c = next()] ) - { - case 0 : - ct_ret(EOF) ; - - case SC_SPACE : goto reswitch ; - - case SC_COMMENT : - eat_comment() ; goto reswitch ; - - case SC_NL : - lineno++ ; eat_nl() ; - ct_ret(NL) ; - - case SC_ESCAPE : - while ( scan_code[ c = next() ] == SC_SPACE ) ; - if ( c == '\n') - { token_lineno = ++lineno ; goto reswitch ; } - if ( c == 0 ) ct_ret(EOF) ; - un_next() ; - yylval.ival = '\\' ; - ct_ret(UNEXPECTED) ; - - - case SC_SEMI_COLON : - eat_nl() ; - ct_ret(SEMI_COLON) ; - - case SC_LBRACE : - eat_nl() ; brace_cnt++ ; - ct_ret(LBRACE) ; - - case SC_PLUS : - switch( next() ) - { - case '+' : - yylval.ival = '+' ; - string_buff[0] = - string_buff[1] = '+' ; - string_buff[2] = 0 ; - ct_ret(INC_or_DEC) ; - - case '=' : - ct_ret(ADD_ASG) ; - - default : un_next() ; ct_ret(PLUS) ; - } - - case SC_MINUS : - switch( next() ) - { - case '-' : - yylval.ival = '-' ; - string_buff[0] = - string_buff[1] = '-' ; - string_buff[2] = 0 ; - ct_ret(INC_or_DEC) ; - - case '=' : - ct_ret(SUB_ASG) ; - - default : un_next() ; ct_ret(MINUS) ; - } - - case SC_COMMA : eat_nl() ; ct_ret(COMMA) ; - - case SC_MUL : test1_ret('=', MUL_ASG, MUL) ; - case SC_DIV : - { static int can_precede_div[] = - { DOUBLE, STRING_, RPAREN, ID, D_ID, RE, RBOX, FIELD, - GETLINE, INC_or_DEC, -1 } ; - - int *p = can_precede_div ; - - do - if ( *p == current_token ) - { - if ( *p != INC_or_DEC ) - test1_ret('=', DIV_ASG, DIV) ; - - if ( next() == '=' ) - { un_next() ; ct_ret( collect_RE() ) ; } - } - - while ( * ++p != -1 ) ; - - ct_ret( collect_RE() ) ; - } - - case SC_MOD : test1_ret('=', MOD_ASG, MOD) ; - case SC_POW : test1_ret('=' , POW_ASG, POW) ; - case SC_LPAREN : - paren_cnt++ ; - ct_ret(LPAREN) ; - - case SC_RPAREN : - if ( --paren_cnt < 0 ) - { compile_error( "extra ')'" ) ; - paren_cnt = 0 ; - goto reswitch ; } - - ct_ret(RPAREN) ; - - case SC_LBOX : ct_ret(LBOX) ; - case SC_RBOX : ct_ret(RBOX) ; - - case SC_MATCH : - string_buff[0] = '~' ; string_buff[0] = 0 ; - yylval.ival = 1 ; - ct_ret(MATCH) ; - - case SC_EQUAL : - test1_ret( '=', EQ, ASSIGN ) ; - - case SC_NOT : /* ! */ - if ( (c = next()) == '~' ) - { - string_buff[0] = '!' ; - string_buff[1] = '~' ; - string_buff[2] = 0 ; - yylval.ival = 0 ; - ct_ret(MATCH) ; - } - else - if ( c == '=' ) ct_ret(NEQ) ; - - un_next() ; - ct_ret(NOT) ; - - - case SC_LT : /* '<' */ - if ( next() == '=' ) ct_ret(LTE) ; - else un_next() ; - - if ( getline_flag ) - { getline_flag = 0 ; ct_ret(IO_IN) ; } - else ct_ret(LT) ; - - case SC_GT : /* '>' */ - if ( print_flag && paren_cnt == 0 ) - { print_flag = 0 ; - /* there are 3 types of IO_OUT - -- build the error string in string_buff */ - string_buff[0] = '>' ; - if ( next() == '>' ) - { - yylval.ival = F_APPEND ; - string_buff[1] = '>' ; - string_buff[2] = 0 ; - } - else - { un_next() ; - yylval.ival = F_TRUNC ; - string_buff[1] = 0 ; - } - return current_token = IO_OUT ; - } - - test1_ret('=', GTE, GT) ; - - case SC_OR : - if ( next() == '|' ) - { eat_nl() ; ct_ret(OR) ; } - else - { un_next() ; - - if ( print_flag && paren_cnt == 0 ) - { print_flag = 0 ; - yylval.ival = PIPE_OUT; - string_buff[0] = '|' ; - string_buff[1] = 0 ; - ct_ret(IO_OUT) ; - } - else ct_ret(PIPE) ; - } - - case SC_AND : - if ( next() == '&' ) - { eat_nl() ; ct_ret(AND) ; } - else - { un_next() ; yylval.ival = '&' ; ct_ret(UNEXPECTED) ; } - - case SC_QMARK : ct_ret(QMARK) ; - case SC_COLON : ct_ret(COLON) ; - case SC_RBRACE : - if ( --brace_cnt < 0 ) - { compile_error("extra '}'" ) ; - eat_semi_colon() ; - brace_cnt = 0 ; goto reswitch ; } - - if ( (c = current_token) == NL || c == SEMI_COLON - || c == SC_FAKE_SEMI_COLON || c == RBRACE ) - { - /* if the brace_cnt is zero , we've completed - a pattern action block. If the user insists - on adding a semi-colon on the same line - we will eat it. Note what we do below: - physical law -- conservation of semi-colons */ - - if ( brace_cnt == 0 ) eat_semi_colon() ; - eat_nl() ; - ct_ret(RBRACE) ; - } - - /* supply missing semi-colon to statement that - precedes a '}' */ - brace_cnt++ ; un_next() ; - current_token = SC_FAKE_SEMI_COLON ; - return SEMI_COLON ; - - case SC_DIGIT : - case SC_DOT : - { double d ; - int flag ; - static double double_zero = 0.0 ; - static double double_one = 1.0 ; - - if ( (d = collect_decimal(c, &flag)) == 0.0 ) - if ( flag ) ct_ret(flag) ; - else yylval.ptr = (PTR) &double_zero ; - else if ( d == 1.0 ) yylval.ptr = (PTR) &double_one ; - else - { yylval.ptr = (PTR) ZMALLOC(double) ; - *(double*)yylval.ptr = d ; - } - ct_ret( DOUBLE ) ; - } - - case SC_DOLLAR : /* '$' */ - { double d ; - int flag ; - - while ( scan_code[c = next()] == SC_SPACE ) ; - if ( scan_code[c] != SC_DIGIT && - scan_code[c] != SC_DOT ) - { un_next() ; ct_ret(DOLLAR) ; } - /* compute field address at compile time */ - if ( (d = collect_decimal(c, &flag)) == 0.0 ) - if ( flag ) ct_ret(flag) ; /* an error */ - else yylval.cp = &field[0] ; - else - { - if ( d > MAX_FIELD ) - { compile_error( - "$%g exceeds maximum field(%d)" , d, MAX_FIELD) ; - d = MAX_FIELD ; - } - yylval.cp = field_ptr((int)d) ; - } - - ct_ret(FIELD) ; - } - - case SC_DQUOTE : - return current_token = collect_string() ; - - case SC_IDCHAR : /* collect an identifier */ - { unsigned char *p = - (unsigned char *)string_buff + 1 ; - SYMTAB *stp ; - - string_buff[0] = c ; - - while ( - (c = scan_code[ *p++ = next()]) == SC_IDCHAR || - c == SC_DIGIT ) ; - - un_next() ; * --p = 0 ; - - switch( (stp = find(string_buff))->type ) - { case ST_NONE : - /* check for function call before defined */ - if ( next() == '(' ) - { stp->type = ST_FUNCT ; - stp->stval.fbp = (FBLOCK *) - zmalloc(sizeof(FBLOCK)) ; - stp->stval.fbp->name = stp->name ; - stp->stval.fbp->code = (INST *) 0 ; - yylval.fbp = stp->stval.fbp ; - current_token = FUNCT_ID ; - } - else - { yylval.stp = stp ; - current_token = - current_token == DOLLAR ? D_ID : ID ; - } - un_next() ; - break ; - - case ST_NR : - NR_flag = 1 ; - stp->type = ST_VAR ; - /* fall thru */ - - case ST_VAR : - case ST_ARRAY : - case ST_LOCAL_NONE : - case ST_LOCAL_VAR : - case ST_LOCAL_ARRAY : - - yylval.stp = stp ; - current_token = - current_token == DOLLAR ? D_ID : ID ; - break ; - - case ST_ENV : - stp->type = ST_ARRAY ; - stp->stval.array = new_ARRAY() ; - load_environ(stp->stval.array) ; - yylval.stp = stp ; - current_token = - current_token == DOLLAR ? D_ID : ID ; - break ; - - case ST_FUNCT : - yylval.fbp = stp->stval.fbp ; - current_token = FUNCT_ID ; - break ; - - case ST_KEYWORD : - current_token = stp->stval.kw ; - break ; - - case ST_BUILTIN : - yylval.bip = stp->stval.bip ; - current_token = BUILTIN ; - break ; - - case ST_LENGTH : - - yylval.bip = stp->stval.bip ; - - /* check for length alone, this is an ugly - hack */ - while ( scan_code[ c = next() ] == SC_SPACE ) ; - un_next() ; - - current_token = c == '(' ? BUILTIN : LENGTH ; - break ; - - case ST_FIELD : - yylval.cp = stp->stval.cp ; - current_token = FIELD ; - break ; - - default : - bozo("find returned bad st type") ; - } - return current_token ; - } - - - case SC_UNEXPECTED : - yylval.ival = c & 0xff ; - ct_ret(UNEXPECTED) ; - } - return 0 ; /* never get here make lint happy */ -} - -/* collect a decimal constant in temp_buff. - Return the value and error conditions by reference */ - -static double collect_decimal(c, flag) - int c ; int *flag ; -{ register unsigned char *p = (unsigned char*) string_buff + 1; - unsigned char *endp ; - double d ; - - *flag = 0 ; - string_buff[0] = c ; - - if ( c == '.' ) - { if ( scan_code[*p++ = next()] != SC_DIGIT ) - { *flag = UNEXPECTED ; yylval.ival = '.' ; - return 0.0 ; } - } - else - { while ( scan_code[*p++ = next()] == SC_DIGIT ) ; - if ( p[-1] != '.' ) - { un_next() ; p-- ; } - } - /* get rest of digits after decimal point */ - while ( scan_code[*p++ = next()] == SC_DIGIT ) ; - - /* check for exponent */ - if ( p[-1] != 'e' && p[-1] != 'E' ) - { un_next() ; * --p = 0 ; } - else /* get the exponent */ - if ( scan_code[*p = next()] != SC_DIGIT && - *p != '-' && *p != '+' ) - { *++p = 0 ; *flag = BAD_DECIMAL ; - return 0.0 ; } - else /* get the rest of the exponent */ - { p++ ; - while ( scan_code[*p++ = next()] == SC_DIGIT ) ; - un_next() ; * --p = 0 ; - } - - errno = 0 ; /* check for overflow/underflow */ - d = strtod( string_buff, (char **)&endp ) ; - -#ifndef STRTOD_UNDERFLOW_ON_ZERO_BUG - if ( errno ) - compile_error( "%s : decimal %sflow" , string_buff, - d == 0.0 ? "under" : "over") ; -#else /* sun4 bug */ - if ( errno && d != 0.0 ) - compile_error( "%s : decimal overflow", string_buff) ; -#endif - - if ( endp < p ) - { *flag = BAD_DECIMAL ; return 0.0 ; } - return d ; -} - -/*---------- process escape characters ---------------*/ - -static char hex_val['f' - 'A' + 1] = { -10,11,12,13,14,15, 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, -10,11,12,13,14,15 } ; - -#define isoctal(x) ((x)>='0'&&(x)<='7') - -#define hex_value(x) hex_val[(x)-'A'] - -#define ishex(x) (scan_code[x] == SC_DIGIT ||\ - 'A' <= (x) && (x) <= 'f' && hex_value(x)) - -static int PROTO(octal, (char **)) ; -static int PROTO(hex, (char **)) ; - -/* process one , two or three octal digits - moving a pointer forward by reference */ -static int octal( start_p ) - char **start_p ; -{ register char *p = *start_p ; - register unsigned x ; - - x = *p++ - '0' ; - if ( isoctal(*p) ) - { - x = (x<<3) + *p++ - '0' ; - if ( isoctal(*p) ) x = (x<<3) + *p++ - '0' ; - } - *start_p = p ; - return x & 0xff ; -} - -/* process one or two hex digits - moving a pointer forward by reference */ - -static int hex( start_p ) - char **start_p ; -{ register unsigned char *p = (unsigned char*) *start_p ; - register unsigned x ; - unsigned t ; - - if ( scan_code[*p] == SC_DIGIT ) - x = *p++ - '0' ; - else x = hex_value(*p++) ; - - if ( scan_code[*p] == SC_DIGIT ) - x = (x<<4) + *p++ - '0' ; - else - if ( 'A' <= *p && *p <= 'f' && (t = hex_value(*p)) ) - { x = (x<<4) + t ; p++ ; } - - *start_p = (char *) p ; - return x ; -} - -#define ET_END 9 - -static struct { char in , out ; } escape_test[ET_END+1] = { -'n' , '\n', -'t' , '\t', -'f' , '\f', -'b' , '\b', -'r' , '\r', -'a' , '\07', -'v' , '\013', -'\\', '\\', -'\"', '\"', -0 , 0 } ; - - -/* process the escape characters in a string, in place . */ - -char *rm_escape(s) - char *s ; -{ register char *p, *q ; - char *t ; - int i ; - - q = p = s ; - - while ( *p ) - if ( *p == '\\' ) - { - escape_test[ET_END].in = * ++p ; /* sentinal */ - i = 0 ; - while ( escape_test[i].in != *p ) i++ ; - - if ( i != ET_END ) /* in table */ - { - p++ ; *q++ = escape_test[i].out ; - } - else - if ( isoctal(*p) ) - { - t = p ; *q++ = octal(&t) ; p = t ; - } - else - if ( *p == 'x' && ishex(*(unsigned char*)(p+1)) ) - { - t = p+1 ; *q++ = hex(&t) ; p = t ; - } - else - if ( *p == 0 ) /* can only happen with command line assign */ - *q++ = '\\' ; - else /* not an escape sequence */ - { - *q++ = '\\' ; *q++ = *p++ ; - } - } - else *q++ = *p++ ; - - *q = 0 ; - return s ; -} - -static int collect_string() -{ register unsigned char *p = (unsigned char *)string_buff ; - int c ; - int e_flag = 0 ; /* on if have an escape char */ - - while ( 1 ) - switch( scan_code[ *p++ = next() ] ) - { case SC_DQUOTE : /* done */ - * --p = 0 ; goto out ; - - case SC_NL : - p[-1] = 0 ; - /* fall thru */ - - case 0 : /* unterminated string */ - compile_error( - "runaway string constant \"%.10s ..." , - string_buff, token_lineno ) ; - mawk_exit(1) ; - - case SC_ESCAPE : - if ( (c = next()) == '\n' ) - { p-- ; lineno++ ; } - else - if ( c == 0 ) un_next() ; - else - { *p++ = c ; e_flag = 1 ; } - - break ; - - default : break ; - } - -out: - yylval.ptr = (PTR) new_STRING( - e_flag ? rm_escape( string_buff ) - : string_buff ) ; - return STRING_ ; -} - - -static int collect_RE() -{ register unsigned char *p = (unsigned char*) string_buff ; - int c ; - STRING *sval ; - - while ( 1 ) - switch( scan_code[ *p++ = next() ] ) - { case SC_DIV : /* done */ - * --p = 0 ; goto out ; - - case SC_NL : - p[-1] = 0 ; - /* fall thru */ - - case 0 : /* unterminated re */ - compile_error( - "runaway regular expression /%.10s ..." , - string_buff, token_lineno ) ; - mawk_exit(1) ; - - case SC_ESCAPE : - switch( c = next() ) - { case '/' : - p[-1] = '/' ; break ; - - case '\n' : - p-- ; break ; - - case 0 : - un_next() ; break ; - - default : - *p++ = c ; break ; - } - break ; - } - -out: - /* now we've got the RE, so compile it */ - sval = new_STRING( string_buff ) ; - yylval.ptr = re_compile(sval) ; - free_STRING(sval) ; - return RE ; -} - diff --git a/gnu/usr.bin/awk/scan.h b/gnu/usr.bin/awk/scan.h deleted file mode 100644 index 2a0c6459a310..000000000000 --- a/gnu/usr.bin/awk/scan.h +++ /dev/null @@ -1,102 +0,0 @@ - -/******************************************** -scan.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: scan.h,v $ -/* Revision 1.2 1993/07/02 23:57:55 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:59:33 brennan - * 1.1 pre-release - * -*/ - - -/* scan.h */ - -#ifndef SCAN_H_INCLUDED -#define SCAN_H_INCLUDED 1 - -#include - -#ifndef MAKESCAN -#include "symtype.h" -#include "parse.h" -#endif - - -extern char scan_code[256] ; - -/* the scan codes to compactify the main switch */ - -#define SC_SPACE 1 -#define SC_NL 2 -#define SC_SEMI_COLON 3 -#define SC_FAKE_SEMI_COLON 4 -#define SC_LBRACE 5 -#define SC_RBRACE 6 -#define SC_QMARK 7 -#define SC_COLON 8 -#define SC_OR 9 -#define SC_AND 10 -#define SC_PLUS 11 -#define SC_MINUS 12 -#define SC_MUL 13 -#define SC_DIV 14 -#define SC_MOD 15 -#define SC_POW 16 -#define SC_LPAREN 17 -#define SC_RPAREN 18 -#define SC_LBOX 19 -#define SC_RBOX 20 -#define SC_IDCHAR 21 -#define SC_DIGIT 22 -#define SC_DQUOTE 23 -#define SC_ESCAPE 24 -#define SC_COMMENT 25 -#define SC_EQUAL 26 -#define SC_NOT 27 -#define SC_LT 28 -#define SC_GT 29 -#define SC_COMMA 30 -#define SC_DOT 31 -#define SC_MATCH 32 -#define SC_DOLLAR 33 -#define SC_UNEXPECTED 34 - -#ifndef MAKESCAN - -/* global functions in scan.c */ - -void PROTO(scan_init, (char *) ) ; -void PROTO(scan_cleanup, (void) ) ; -void PROTO(eat_nl, (void) ) ; -int PROTO(yylex, (void) ) ; - - -extern YYSTYPE yylval ; - -#define ct_ret(x) return current_token = (x) - -#define next() (*buffp ? *buffp++ : slow_next()) -#define un_next() buffp-- - -#define test1_ret(c,x,d) if ( next() == (c) ) ct_ret(x) ;\ - else { un_next() ; ct_ret(d) ; } - -#define test2_ret(c1,x1,c2,x2,d) switch( next() )\ - { case c1: ct_ret(x1) ;\ - case c2: ct_ret(x2) ;\ - default: un_next() ;\ - ct_ret(d) ; } -#endif /* ! MAKESCAN */ -#endif diff --git a/gnu/usr.bin/awk/scancode.c b/gnu/usr.bin/awk/scancode.c deleted file mode 100644 index 4a4b8fe58fe5..000000000000 --- a/gnu/usr.bin/awk/scancode.c +++ /dev/null @@ -1,23 +0,0 @@ - - -/* scancode.c */ - - -char scan_code[256] = { - 0,34,34,34,34,34,34,34,34, 1, 2, 1, 1, 1,34,34, -34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34, - 1,27,23,25,33,15,10,34,17,18,13,11,30,12,31,14, -22,22,22,22,22,22,22,22,22,22, 8, 3,28,26,29, 7, -34,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21, -21,21,21,21,21,21,21,21,21,21,21,19,24,20,16,21, -34,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21, -21,21,21,21,21,21,21,21,21,21,21, 5, 9, 6,32,34, -34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34, -34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34, -34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34, -34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34, -34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34, -34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34, -34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34, -34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34 -} ; diff --git a/gnu/usr.bin/awk/sizes.h b/gnu/usr.bin/awk/sizes.h deleted file mode 100644 index 03f4f311d149..000000000000 --- a/gnu/usr.bin/awk/sizes.h +++ /dev/null @@ -1,89 +0,0 @@ - -/******************************************** -sizes.h -copyright 1991, 1992. Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: sizes.h,v $ -/* Revision 1.2 1993/07/02 23:57:56 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.3 1992/12/17 02:48:01 mike - * 1.1.2d changes for DOS - * - * Revision 5.2 1992/08/27 03:20:08 mike - * patch2: increase A_HASH_PRIME - * - * Revision 5.1 1991/12/05 07:59:35 brennan - * 1.1 pre-release - * -*/ - -/* sizes.h */ - -#ifndef SIZES_H -#define SIZES_H - -#if ! HAVE_SMALL_MEMORY -#define EVAL_STACK_SIZE 256 /* initial size , can grow */ -/* number of fields at startup, must be a power of 2 - and FBANK_SZ-1 must be divisible by 3! */ -#define FBANK_SZ 256 -#define FB_SHIFT 8 /* lg(FBANK_SZ) */ -#define NUM_FBANK 128 /* see MAX_FIELD below */ - -#else /* have to be frugal with memory */ - -#define EVAL_STACK_SIZE 64 -#define FBANK_SZ 64 -#define FB_SHIFT 6 /* lg(FBANK_SZ) */ -#define NUM_FBANK 16 /* see MAX_FIELD below */ - -#endif - -#define MAX_SPLIT (FBANK_SZ-1) /* needs to be divisble by 3*/ -#define MAX_FIELD (NUM_FBANK*FBANK_SZ - 1) - -#define MIN_SPRINTF 400 - - -#define BUFFSZ 4096 - /* starting buffer size for input files, grows if - necessary */ - -#if LM_DOS -/* trade some space for IO speed */ -#undef BUFFSZ -#define BUFFSZ 8192 -/* maximum input buffers that will fit in 64K */ -#define MAX_BUFFS ((int)(0x10000L/BUFFSZ) - 1) -#endif - -#define HASH_PRIME 53 - -#if ! HAVE_SMALL_MEMORY -#define A_HASH_PRIME 199 -#else -#define A_HASH_PRIME 37 -#endif - - -#define MAX_COMPILE_ERRORS 5 /* quit if more than 4 errors */ - - - -/* AWF showed the need for this */ -#define MAIN_PAGE_SZ 4096 /* max instr in main block */ -#if 0 -#define PAGE_SZ 1024 /* max instructions for other blocks */ -#endif -/* these used to be different */ -#define PAGE_SZ 4096 - -#endif /* SIZES_H */ diff --git a/gnu/usr.bin/awk/split.c b/gnu/usr.bin/awk/split.c deleted file mode 100644 index 52892db1ea38..000000000000 --- a/gnu/usr.bin/awk/split.c +++ /dev/null @@ -1,263 +0,0 @@ - -/******************************************** -split.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/* $Log: split.c,v $ -/* Revision 1.2 1993/07/02 23:57:57 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.2 1992/07/08 21:19:09 brennan - * patch2 - * change in split() requires that - * bi_split() call load_array() even - * when cnt is 0. - * - * Revision 5.1 1991/12/05 07:56:31 brennan - * 1.1 pre-release - * -*/ - -/* split.c */ - -#define TEMPBUFF_GOES_HERE - -#include "mawk.h" -#include "symtype.h" -#include "bi_vars.h" -#include "bi_funct.h" -#include "memory.h" -#include "scan.h" -#include "regexp.h" -#include "field.h" - -SPLIT_OV *split_ov_list ; - -static int PROTO(re_ov_split, (char *, PTR) ) ; -static int PROTO(space_ov_split, (char *, char *) ) ; - -/* split string s of length slen on SPACE without changing s. - load the pieces into STRINGS and ptrs into - split_buff[] - return the number of pieces */ - -int space_split( s , slen) - register char *s ; - unsigned slen ; -{ char *back = s + slen ; - int i = 0 ; - int len ; - char *q ; - STRING *sval ; - int lcnt = MAX_SPLIT/3 ; - -#define EAT_SPACE() while ( scan_code[*(unsigned char*)s] ==\ - SC_SPACE ) s++ -#define EAT_NON_SPACE() \ - *back = ' ' ; /* sentinel */\ - while ( scan_code[*(unsigned char*)s] != SC_SPACE ) s++ ;\ - *back = 0 - - - while ( lcnt-- ) - { - EAT_SPACE() ; - if ( *s == 0 ) goto done ; - /* mark the front with q */ - q = s++ ; - EAT_NON_SPACE() ; - sval = split_buff[i++] = new_STRING((char *) 0, len = s - q ) ; - (void) memcpy(sval->str, q, SIZE_T(len)) ; - - EAT_SPACE() ; - if ( *s == 0 ) goto done ; - q = s++ ; - EAT_NON_SPACE() ; - sval = split_buff[i++] = new_STRING((char *) 0, len = s - q ) ; - (void) memcpy(sval->str, q, SIZE_T(len)) ; - - EAT_SPACE() ; - if ( *s == 0 ) goto done ; - q = s++ ; - EAT_NON_SPACE() ; - sval = split_buff[i++] = new_STRING((char *) 0, len = s - q ) ; - (void) memcpy(sval->str, q, SIZE_T(len)) ; - - } - /* we've overflowed */ - return i + space_ov_split(s, back) ; - -done: - return i ; -} - -static int space_ov_split(s, back) - register char *s ; - char *back ; - -{ - SPLIT_OV dummy ; - register SPLIT_OV *tail = &dummy ; - char *q ; - int cnt = 0 ; - unsigned len ; - - while ( 1 ) - { - EAT_SPACE() ; - if ( *s == 0 ) break ; /* done */ - q = s++ ; - EAT_NON_SPACE() ; - - tail = tail->link = (SPLIT_OV*) zmalloc(sizeof(SPLIT_OV)) ; - tail->sval = new_STRING((char *) 0 , len = s-q) ; - (void) memcpy(tail->sval->str, q, SIZE_T(len)) ; - cnt++ ; - } - - tail->link = (SPLIT_OV*) 0 ; - split_ov_list = dummy.link ; - return cnt ; -} - - -char *re_pos_match(s, re, lenp) - register char *s ; - PTR re ; unsigned *lenp ; -{ - while ( s = REmatch(s, re, lenp) ) - if ( *lenp ) return s ; - else - if ( *s == 0 ) break ; - else s++ ; - - return (char *) 0 ; -} - -int re_split(s, re) - char *s ; - PTR re ; -{ register char *t ; - int i = 0 ; - unsigned mlen, len ; - STRING *sval ; - int lcnt = MAX_SPLIT / 3 ; - - while ( lcnt-- ) - { - if ( !(t = re_pos_match(s, re, &mlen)) ) goto done ; - sval = split_buff[i++] = new_STRING( (char *)0, len = t-s) ; - (void) memcpy(sval->str, s, SIZE_T(len)) ; - s = t + mlen ; - - if ( !(t = re_pos_match(s, re, &mlen)) ) goto done ; - sval = split_buff[i++] = new_STRING( (char *)0, len = t-s) ; - (void) memcpy(sval->str, s, SIZE_T(len)) ; - s = t + mlen ; - - if ( !(t = re_pos_match(s, re, &mlen)) ) goto done ; - sval = split_buff[i++] = new_STRING( (char *)0, len = t-s) ; - (void) memcpy(sval->str, s, SIZE_T(len)) ; - s = t + mlen ; - } - /* we've overflowed */ - return i + re_ov_split(s, re) ; - -done: - split_buff[i++] = new_STRING(s) ; - return i ; -} - -/* - we've overflowed split_buff[] , put - the rest on the split_ov_list - return number of pieces -*/ - -static int re_ov_split(s, re) - char *s ; - PTR re ; -{ - SPLIT_OV dummy ; - register SPLIT_OV *tail = &dummy ; - int cnt = 1 ; - char *t ; - unsigned len, mlen ; - - while ( t = re_pos_match(s, re, &mlen) ) - { - tail = tail->link = (SPLIT_OV *) zmalloc(sizeof(SPLIT_OV)) ; - tail->sval = new_STRING( (char *)0, len = t-s) ; - (void) memcpy(tail->sval->str, s, SIZE_T(len)) ; - s = t + mlen ; - cnt++ ; - } - /* and one more */ - tail = tail->link = (SPLIT_OV *) zmalloc(sizeof(SPLIT_OV)) ; - tail->sval = new_STRING(s) ; - tail->link = (SPLIT_OV*) 0 ; - split_ov_list = dummy.link ; - - return cnt ; -} - -/* split(s, X, r) - split s into array X on r - - entry: sp[0] holds r - sp[-1] pts at X - sp[-2] holds s -*/ -CELL *bi_split(sp) - register CELL *sp ; -{ - int cnt ; /* the number of pieces */ - - - if ( sp->type < C_RE ) cast_for_split(sp) ; - /* can be C_RE, C_SPACE or C_SNULL */ - sp -= 2 ; - if ( sp->type < C_STRING ) cast1_to_s(sp) ; - - if ( string(sp)->len == 0 ) /* nothing to split */ - cnt = 0 ; - else - switch ( (sp+2)->type ) - { - case C_RE : - cnt = re_split(string(sp)->str, (sp+2)->ptr) ; - break ; - - case C_SPACE : - cnt = space_split(string(sp)->str, string(sp)->len) ; - break ; - - /* this case could be done by C_RE, but very slowly. - Since it is the common way to eliminate fields, - we'll treat the special case for speed */ - case C_SNULL : /* split on empty string */ - cnt = 1 ; - split_buff[0] = (STRING *) sp->ptr ; - string(sp)->ref_cnt++ ; - break ; - - default : bozo("bad splitting cell in bi_split") ; - } - - - free_STRING( string(sp) ) ; - sp->type = C_DOUBLE ; - sp->dval = (double) cnt ; - - load_array((ARRAY)(sp+1)->ptr, cnt) ; - - return sp ; -} - diff --git a/gnu/usr.bin/awk/symtype.h b/gnu/usr.bin/awk/symtype.h deleted file mode 100644 index cd61f5c115d6..000000000000 --- a/gnu/usr.bin/awk/symtype.h +++ /dev/null @@ -1,192 +0,0 @@ - -/******************************************** -symtype.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: symtype.h,v $ -/*Revision 1.2 1993/07/02 23:57:58 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.3 1992/12/17 02:48:01 mike - * 1.1.2d changes for DOS - * - * Revision 5.2 1992/07/08 15:44:44 brennan - * patch2: length returns. I am a wimp - * - * Revision 5.1 1991/12/05 07:59:37 brennan - * 1.1 pre-release - * -*/ - -/* types related to symbols are defined here */ - -#ifndef SYMTYPE_H -#define SYMTYPE_H - - -/* struct to hold info about builtins */ -typedef struct { -char *name ; -PF_CP fp ; /* ptr to function that does the builtin */ -unsigned char min_args, max_args ; -/* info for parser to check correct number of arguments */ -} BI_REC ; - -/*--------------------------- - structures and types for arrays - *--------------------------*/ - -/* array hash nodes */ - -/* string node */ -typedef struct anode { -struct anode *link , *ilink ; -STRING *sval ; -long ival ; -CELL *cp ; -} ANODE ; - - -typedef struct array { -ANODE *link , *ilink ; -} *ARRAY ; - -#define CREATE 1 -#define NO_CREATE 0 - -/* note ARRAY is a ptr to a hash table */ - -CELL *PROTO(array_find, (ARRAY,CELL *, int) ) ; -INST *PROTO(array_loop, (INST *, CELL *, CELL *) ) ; -void PROTO(array_delete, (ARRAY, CELL *) ) ; -CELL *PROTO(array_cat, (CELL *, int) ) ; -void PROTO(array_free, (ARRAY) ) ; -void PROTO(load_array, (ARRAY,int)) ; - -#define new_ARRAY() (ARRAY)memset(zmalloc(A_HASH_PRIME *\ - sizeof(struct array)),\ - 0 , SIZE_T(A_HASH_PRIME*sizeof(struct array))) - -extern ARRAY Argv ; - -/* struct to hold the state of an array loop */ -typedef struct { -CELL *var ; -ARRAY A ; -int index ; /* A[index] */ -ANODE *ptr ; -} ALOOP_STATE ; - -int PROTO( inc_aloop_state, (ALOOP_STATE*)) ; - -/* for parsing (i,j) in A */ -typedef struct { -INST *start ; -int cnt ; -} ARG2_REC ; - -/*------------------------ - user defined functions - ------------------------*/ - -typedef struct fblock { -char *name ; -INST *code ; -unsigned short nargs ; -char *typev ; /* array of size nargs holding types */ -} FBLOCK ; /* function block */ - -void PROTO(add_to_fdump_list, (FBLOCK *) ) ; -void PROTO( fdump, (void) ) ; - -/*------------------------- - elements of the symbol table - -----------------------*/ - -#define ST_NONE 0 -#define ST_VAR 1 -#define ST_KEYWORD 2 -#define ST_BUILTIN 3 /* a pointer to a builtin record */ -#define ST_ARRAY 4 /* a void * ptr to a hash table */ -#define ST_FIELD 5 /* a cell ptr to a field */ -#define ST_FUNCT 6 -#define ST_NR 7 /* NR is special */ -#define ST_ENV 8 /* and so is ENVIRON */ -#define ST_LENGTH 9 /* ditto and bozo */ -#define ST_LOCAL_NONE 10 -#define ST_LOCAL_VAR 11 -#define ST_LOCAL_ARRAY 12 - -#define is_local(stp) ((stp)->type>=ST_LOCAL_NONE) - -typedef struct { -char *name ; -char type ; -unsigned char offset ; /* offset in stack frame for local vars */ -union { -CELL *cp ; -int kw ; -PF_CP fp ; -BI_REC *bip ; -ARRAY array ; -FBLOCK *fbp ; -} stval ; -} SYMTAB ; - - -/***************************** - structures for type checking function calls - ******************************/ - -typedef struct ca_rec { -struct ca_rec *link ; -short type ; -short arg_num ; /* position in callee's stack */ -/*--------- this data only set if we'll need to patch -------*/ -/* happens if argument is an ID or type ST_NONE or ST_LOCAL_NONE */ - -int call_offset ; -/* where the type is stored */ -SYMTAB *sym_p ; /* if type is ST_NONE */ -char *type_p ; /* if type is ST_LOCAL_NONE */ -} CA_REC ; /* call argument record */ - -/* type field of CA_REC matches with ST_ types */ -#define CA_EXPR ST_LOCAL_VAR -#define CA_ARRAY ST_LOCAL_ARRAY - -typedef struct fcall { -struct fcall *link ; -FBLOCK *callee ; -short call_scope ; -FBLOCK *call ; /* only used if call_scope == SCOPE_FUNCT */ -INST *call_start ; /* computed later as code may be moved */ -CA_REC *arg_list ; -short arg_cnt_checked ; -unsigned line_no ; /* for error messages */ -} FCALL_REC ; - -extern FCALL_REC *resolve_list ; - -void PROTO(resolve_fcalls, (void) ) ; -void PROTO(check_fcall, (FBLOCK*,int,FBLOCK*,CA_REC*,unsigned) ) ; - -/* hash.c */ -unsigned PROTO( hash, (char *) ) ; -SYMTAB *PROTO( insert, (char *) ) ; -SYMTAB *PROTO( find, (char *) ) ; -char *PROTO( reverse_find, (int, PTR)) ; -SYMTAB *PROTO( save_id, (char *) ) ; -void PROTO( restore_ids, (void) ) ; - -/* error.c */ -void PROTO(type_error, (SYMTAB *) ) ; - -#endif /* SYMTYPE_H */ diff --git a/gnu/usr.bin/awk/types.h b/gnu/usr.bin/awk/types.h deleted file mode 100644 index 8b959eb4ddd3..000000000000 --- a/gnu/usr.bin/awk/types.h +++ /dev/null @@ -1,117 +0,0 @@ - -/******************************************** -types.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - - -/* $Log: types.h,v $ -/* Revision 1.2 1993/07/02 23:58:00 jtc -/* Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:59:39 brennan - * 1.1 pre-release - * -*/ - - -/* types.h */ - -#ifndef MAWK_TYPES_H -#define MAWK_TYPES_H - -#if HAVE_VOID_PTR -typedef void *PTR ; -#else -typedef char *PTR ; -#endif - -#include "sizes.h" - - -/* CELL types */ - -#define C_NOINIT 0 -#define C_DOUBLE 1 -#define C_STRING 2 -#define C_STRNUM 3 -#define C_MBSTRN 4 - /*could be STRNUM, has not been checked */ -#define C_RE 5 -#define C_SPACE 6 - /* split on space */ -#define C_SNULL 7 - /* split on the empty string */ -#define C_REPL 8 - /* a replacement string '\&' changed to & */ -#define C_REPLV 9 - /* a vector replacement -- broken on & */ -#define NUM_CELL_TYPES 10 - -/* these defines are used to check types for two - CELLs which are adjacent in memory */ - -#define TWO_NOINITS (2*(1< or - only used for error messages -*/ - - -#if HAVE_STDARG_H == 0 -#include - -#ifndef VA_ALIST - -#define VA_ALIST(type, arg) (va_alist) va_dcl { type arg ; -#define VA_ALIST2(t1,a1,t2,a2) (va_alist) va_dcl { t1 a1 ; t2 a2 ; - -#endif - -#define VA_START(p,type, last) va_start(p) ;\ - last = va_arg(p,type) - - -#define VA_START2(p,t1,a1,t2,a2) va_start(p) ;\ - a1 = va_arg(p,t1);\ - a2 = va_arg(p,t2) - -#else /* HAVE_STDARG_H */ -#include - -#ifndef VA_ALIST -#define VA_ALIST(type, arg) (type arg, ...) { -#define VA_ALIST2(t1,a1,t2,a2) (t1 a1,t2 a2,...) { -#endif - -#define VA_START(p,type,last) va_start(p,last) - -#define VA_START2(p,t1,a1,t2,a2) va_start(p,a2) - -#endif - diff --git a/gnu/usr.bin/awk/version.c b/gnu/usr.bin/awk/version.c deleted file mode 100644 index 6aaee40cde6a..000000000000 --- a/gnu/usr.bin/awk/version.c +++ /dev/null @@ -1,184 +0,0 @@ - -/******************************************** -version.c -copyright 1991, 1992. Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: version.c,v $ -/*Revision 1.2 1993/07/02 23:58:02 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.6.1.3 1993/05/05 00:02:18 mike - * patch4 - * - * Revision 5.6.1.2 1993/01/20 12:53:13 mike - * d_to_l() - * - * Revision 5.6.1.1 1993/01/15 03:33:54 mike - * patch3: safer double to int conversion - * - * Revision 5.6 1992/12/17 02:48:01 mike - * 1.1.2d changes for DOS - * - * Revision 5.5 1992/12/02 03:18:12 mike - * coherent patch - * - * Revision 5.4 1992/08/27 11:50:38 mike - * patch2 - * - * Revision 5.3 1992/03/03 16:42:23 brennan - * patch 1 - * - * Revision 5.2 92/01/22 05:34:10 brennan - * version 1.1 - * - * Revision 5.1 91/12/05 07:56:33 brennan - * 1.1 pre-release - * -*/ - -#include "mawk.h" -#include "patchlev.h" - -static char rcsid[] = -"@(#) $Id: version.c,v 1.2 1993/07/02 23:58:02 jtc Exp $" ; - -#define VERSION_STRING \ - "mawk 1.1%s%s %s, Copyright (C) Michael D. Brennan\n\n" - -#define DOS_STRING "" - -/* If use different command line syntax for MSDOS - mark that in VERSION */ - -#if MSDOS -#undef DOS_STRING - -#if SM_DOS - -#if HAVE_REARGV -#define DOS_STRING "SM" -#else -#define DOS_STRING "SMDOS" -#endif - -#else /* LM_DOS */ - -#if HAVE_REARGV -#define DOS_STRING "LM" -#else -#define DOS_STRING "LMDOS" -#endif - -#endif -#endif /* MSDOS */ - -#ifdef THINK_C -#undef DOS_STRING -#define DOS_STRING ":Mac" -#endif - -static char fmt[] = "%-14s%10lu\n" ; - -/* print VERSION and exit */ -void print_version() -{ - - printf(VERSION_STRING, PATCH_STRING, DOS_STRING, DATE_STRING) ; - fflush(stdout) ; - - print_compiler_id() ; - fprintf(stderr, "compiled limits:\n") ; - fprintf(stderr, fmt, "largest field", (long)MAX_FIELD) ; - fprintf(stderr, fmt, "sprintf buffer", (long)SPRINTF_SZ) ; - print_aux_limits() ; - exit(0) ; -} - - -/* - Extra info for MSDOS. This code contributed by - Ben Myers -*/ - -#ifdef __TURBOC__ -#include /* coreleft() */ -#define BORL -#endif - -#ifdef __BORLANDC__ -#include /* coreleft() */ -#define BORL -#endif - -#ifdef BORL -#if LM_DOS -extern unsigned _stklen = 16 * 1024U ; - /* 4K of stack is enough for a user function call - nesting depth of 75 so this is enough for 300 */ -#endif -#endif - -#ifdef _MSC_VER -#include -#endif - -#ifdef __ZTC__ -#include /* _chkstack */ -#endif - - -int print_compiler_id() -{ - -#ifdef __TURBOC__ - fprintf(stderr, "MsDOS Turbo C++ %d.%d\n", - __TURBOC__>>8, __TURBOC__&0xff) ; -#endif - -#ifdef __BORLANDC__ - fprintf (stderr, "MS-DOS Borland C++ __BORLANDC__ %x\n", - __BORLANDC__ ); -#endif - -#ifdef _MSC_VER - fprintf (stderr, "MS-DOS Microsoft C/C++ _MSC_VER %u\n", _MSC_VER ); -#endif - -#ifdef __ZTC__ - fprintf (stderr, "MS-DOS Zortech C++ __ZTC__ %x\n", __ZTC__ ); -#endif - - return 0 ; /*shut up */ -} - - -int print_aux_limits() -{ -#ifdef BORL - extern unsigned _stklen ; - fprintf(stderr, fmt, "stack size", (unsigned long)_stklen) ; - fprintf(stderr, fmt, "heap size", (unsigned long) coreleft()) ; -#endif - -#ifdef _MSC_VER - fprintf(stderr, fmt, "stack size", (unsigned long)_stackavail()) ; -#if SM_DOS - fprintf(stderr, fmt, "heap size", (unsigned long) _memavl()) ; -#endif -#endif - -#ifdef __ZTC__ -/* large memory model only with ztc */ - fprintf(stderr, fmt, "stack size??", (unsigned long)_chkstack()) ; - fprintf(stderr, fmt, "heap size", farcoreleft()) ; -#endif - - return 0 ; -} diff --git a/gnu/usr.bin/awk/zmalloc.c b/gnu/usr.bin/awk/zmalloc.c deleted file mode 100644 index 1a38d9c50e66..000000000000 --- a/gnu/usr.bin/awk/zmalloc.c +++ /dev/null @@ -1,161 +0,0 @@ - -/******************************************** -zmalloc.c -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: zmalloc.c,v $ -/*Revision 1.2 1993/07/02 23:58:03 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.1.1.1 1993/02/06 11:12:19 mike - * fix bug in reuse of parser table memory - * for most users ifdef the mess out - * - * Revision 5.1 1991/12/05 07:56:35 brennan - * 1.1 pre-release - * -*/ - -/* zmalloc.c */ -#include "mawk.h" -#include "zmalloc.h" - -void PROTO( mawk_exit, (int) ) ; - -extern struct yacc_mem *yacc_memp ; - -/* - zmalloc() gets mem from malloc() in CHUNKS of 2048 bytes - and cuts these blocks into smaller pieces that are multiples - of eight bytes. When a piece is returned via zfree(), it goes - on a linked linear list indexed by its size. The lists are - an array, pool[]. - - E.g., if you ask for 22 bytes with p = zmalloc(22), you actually get - a piece of size 24. When you free it with zfree(p,22) , it is added - to the list at pool[2]. -*/ - -#define POOLSZ 16 - -#define CHUNK 256 - /* number of blocks to get from malloc */ - -static PTR PROTO( emalloc, (unsigned) ) ; -void PROTO( errmsg, (int , char *, ...) ) ; - -static PTR emalloc(size) - unsigned size ; -{ PTR p ; - static char out[] = "out of memory" ; - - if( !(p = (PTR) malloc(SIZE_T(size))) ) - if ( mawk_state == EXECUTION ) rt_error(out) ; - else /* I don't think this will ever happen */ - { compile_error(out) ; mawk_exit(1) ; } - return p ; -} - - -typedef union zblock { -char dummy[ZBLOCKSZ] ; -union zblock *link ; -} ZBLOCK ; - -/* ZBLOCKS of sizes 1, 2, ... 16 - which is bytes of sizes 8, 16, ... , 128 - are stored on the linked linear lists in - pool[0], pool[1], ... , pool[15] -*/ - -static ZBLOCK *pool[POOLSZ] ; - -PTR bmalloc( blocks ) - register unsigned blocks ; -{ - register ZBLOCK *p ; - static unsigned amt_avail ; - static ZBLOCK *avail ; - - if ( blocks > POOLSZ ) return emalloc(blocks<link ; return (PTR) p ; } - - if ( blocks > amt_avail ) - { - if ( amt_avail != 0 ) /* free avail */ - { - avail->link = pool[--amt_avail] ; - pool[amt_avail] = avail ; - } - -#if MSDOS || HAVE_SMALL_MEMORY -/* this hack is dangerous (I've blown it twice), not portable, - and counts on byacc not changing, but it is a big win on - DOS. On paged vmem systems it is a nop so ifdef it out. -*/ - /* use parser tables first */ - if ( yacc_memp->zblocks > blocks ) - { - avail = (ZBLOCK *) yacc_memp->mem ; - amt_avail = yacc_memp++ -> zblocks ; - /* make sure its -- aligned */ - { - int k = (int) avail & 7 ; - if ( k ) - { - avail = (ZBLOCK*)((char *)avail + (8-k)) ; - amt_avail-- ; - } - } - } - else -#endif - - if ( !(avail = (ZBLOCK *) malloc(SIZE_T(CHUNK*ZBLOCKSZ))) ) - { /* if we get here, almost out of memory */ - amt_avail = 0 ; - return emalloc(blocks << ZSHIFT) ; - } - else amt_avail = CHUNK ; - } - - /* get p from the avail pile */ - p = avail ; avail += blocks ; amt_avail -= blocks ; - return (PTR) p ; -} - -void bfree( p, blocks) - register PTR p ; - register unsigned blocks ; -{ - - if ( blocks > POOLSZ ) free(p) ; - else - { - ((ZBLOCK *)p)->link = pool[--blocks] ; - pool[blocks] = (ZBLOCK *) p ; - } -} - -PTR zrealloc( p, old_size, new_size ) - register PTR p ; - unsigned old_size, new_size ; -{ register PTR q ; - - (void) memcpy(q = zmalloc(new_size), p, - SIZE_T(old_size < new_size ? old_size : new_size)) ; - - zfree(p, old_size) ; - return q ; -} - - diff --git a/gnu/usr.bin/awk/zmalloc.h b/gnu/usr.bin/awk/zmalloc.h deleted file mode 100644 index 9d9d90c8abb5..000000000000 --- a/gnu/usr.bin/awk/zmalloc.h +++ /dev/null @@ -1,49 +0,0 @@ - -/******************************************** -zmalloc.h -copyright 1991, Michael D. Brennan - -This is a source file for mawk, an implementation of -the AWK programming language. - -Mawk is distributed without warranty under the terms of -the GNU General Public License, version 2, 1991. -********************************************/ - -/*$Log: zmalloc.h,v $ -/*Revision 1.2 1993/07/02 23:58:04 jtc -/*Updated to mawk 1.1.4 -/* - * Revision 5.1 1991/12/05 07:59:41 brennan - * 1.1 pre-release - * -*/ - -/* zmalloc.h */ - -#ifndef ZMALLOC_H -#define ZMALLOC_H - -#if ! HAVE_STDLIB_H -char *malloc() , *realloc() ; -void free() ; -#endif - - -PTR PROTO( bmalloc, (unsigned) ) ; -void PROTO( bfree, (PTR, unsigned) ) ; -PTR PROTO( zrealloc , (PTR,unsigned,unsigned) ) ; - - -#define ZBLOCKSZ 8 -#define ZSHIFT 3 - - -#define zmalloc(size) bmalloc((((unsigned)size)+ZBLOCKSZ-1)>>ZSHIFT) -#define zfree(p,size) bfree(p,(((unsigned)size)+ZBLOCKSZ-1)>>ZSHIFT) - -#define ZMALLOC(type) ((type*)zmalloc(sizeof(type))) -#define ZFREE(p) zfree(p,sizeof(*(p))) - - -#endif /* ZMALLOC_H */ diff --git a/gnu/usr.bin/bc-1.02/Test/ln.b b/gnu/usr.bin/bc-1.02/Test/ln.b deleted file mode 100644 index 00a1deb78181..000000000000 --- a/gnu/usr.bin/bc-1.02/Test/ln.b +++ /dev/null @@ -1,3 +0,0 @@ -for (a=1; a<10000000000000000000000000000; a = a*2) x=l(a) -x -quit diff --git a/gnu/usr.bin/bc-1.02/Test/mul.b b/gnu/usr.bin/bc-1.02/Test/mul.b deleted file mode 100644 index 1970ed131310..000000000000 --- a/gnu/usr.bin/bc-1.02/Test/mul.b +++ /dev/null @@ -1,7 +0,0 @@ -scale = 20 -for (i=0; i<1000; i++) { - for (j=1; j<100; j++) b=i*j -} -b -quit - diff --git a/gnu/usr.bin/bc-1.02/Test/raise.b b/gnu/usr.bin/bc-1.02/Test/raise.b deleted file mode 100644 index a8858151999a..000000000000 --- a/gnu/usr.bin/bc-1.02/Test/raise.b +++ /dev/null @@ -1,3 +0,0 @@ -for (i=0; i<1000; i++) a = 2^i; -a -quit diff --git a/gnu/usr.bin/bc-1.02/Test/sine.b b/gnu/usr.bin/bc-1.02/Test/sine.b deleted file mode 100644 index 8dae0b6dd892..000000000000 --- a/gnu/usr.bin/bc-1.02/Test/sine.b +++ /dev/null @@ -1,3 +0,0 @@ -for (i=0; i<8*a(1); i=i+.01) x=s(i) -x -quit diff --git a/gnu/usr.bin/bc-1.02/Test/sqrt.b b/gnu/usr.bin/bc-1.02/Test/sqrt.b deleted file mode 100644 index 6365794b2f07..000000000000 --- a/gnu/usr.bin/bc-1.02/Test/sqrt.b +++ /dev/null @@ -1,4 +0,0 @@ -scale = 20 -for (a=1; a<500; a++) r=sqrt(a) -r -quit diff --git a/gnu/usr.bin/bc-1.02/Test/testfn.b b/gnu/usr.bin/bc-1.02/Test/testfn.b deleted file mode 100644 index 7578fc5d45fd..000000000000 --- a/gnu/usr.bin/bc-1.02/Test/testfn.b +++ /dev/null @@ -1,47 +0,0 @@ -/* This function "t" tests the function "f" to see if computing at - two different scales has much effect on the accuracy. - test from f(x) to f(y) incrementing the index by d. f(i) is - computed at two scales, scale s and then scale t, where t>s. - the result from scale t is divided by 1 at scale s and the - results are compared. If they are different, the function is - said to have failed. It will then print out the value of i - (called index) and the two original values val1 (scale s) and - val2 (scale t) */ - -define t (x,y,d,s,t) { - auto u, v, w, i, b, c; - - if (s >= t) { - "Bad Scales. Try again. -"; return; - } - - for (i = x; i < y; i += d) { - scale = s; - u = f(i); - scale = t; - v = f(i); - scale = s; - w = v / 1; - b += 1; - if (u != w) { - c += 1; -" -Failed: -" - " index = "; i; - " val1 = "; u; - " val2 = "; v; -" -" - } - } - -" -Total tests: "; b; -" -Total failures: "; c; -" -Percent failed: "; scale = 2; c*100/b; - -} diff --git a/gnu/usr.bin/bc-1.02/Test/timetest b/gnu/usr.bin/bc-1.02/Test/timetest deleted file mode 100644 index 90da6ab7ad67..000000000000 --- a/gnu/usr.bin/bc-1.02/Test/timetest +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# Time the functions. -# -BC=../bc -SYSBC=/usr/bin/bc -for file in exp.b ln.b sine.b atan.b jn.b mul.b div.b raise.b sqrt.b -do -for prog in $BC $SYSBC -do -echo Timing $file with $prog -time $prog -l $file -done -done diff --git a/gnu/usr.bin/bc-1.02/bc.c.dist b/gnu/usr.bin/bc-1.02/bc.c.dist deleted file mode 100644 index 923215ed7900..000000000000 --- a/gnu/usr.bin/bc-1.02/bc.c.dist +++ /dev/null @@ -1,1369 +0,0 @@ -#ifndef lint -static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; -#endif -#define YYBYACC 1 -#line 2 "bc.y" -/* bc.y: The grammar for a POSIX compatable bc processor with some - extensions to the language. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -#include "bcdefs.h" -#include "global.h" -#include "proto.h" -#line 38 "bc.y" -typedef union { - char *s_value; - char c_value; - int i_value; - arg_list *a_value; - } YYSTYPE; -#line 46 "y.tab.c" -#define NEWLINE 257 -#define AND 258 -#define OR 259 -#define NOT 260 -#define STRING 261 -#define NAME 262 -#define NUMBER 263 -#define MUL_OP 264 -#define ASSIGN_OP 265 -#define REL_OP 266 -#define INCR_DECR 267 -#define Define 268 -#define Break 269 -#define Quit 270 -#define Length 271 -#define Return 272 -#define For 273 -#define If 274 -#define While 275 -#define Sqrt 276 -#define Else 277 -#define Scale 278 -#define Ibase 279 -#define Obase 280 -#define Auto 281 -#define Read 282 -#define Warranty 283 -#define Halt 284 -#define Last 285 -#define Continue 286 -#define Print 287 -#define Limits 288 -#define UNARY_MINUS 289 -#define YYERRCODE 256 -short yylhs[] = { -1, - 0, 0, 10, 10, 10, 11, 11, 11, 11, 12, - 12, 12, 12, 12, 12, 15, 15, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 16, 17, 18, - 19, 13, 20, 13, 22, 23, 13, 13, 25, 13, - 24, 24, 26, 26, 21, 27, 21, 28, 14, 5, - 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, - 9, 9, 9, 9, 4, 4, 2, 2, 29, 1, - 30, 1, 31, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 3, 3, 3, 3, 3, 3, -}; -short yylen[] = { 2, - 0, 2, 2, 1, 2, 0, 1, 3, 2, 0, - 1, 2, 3, 2, 3, 1, 2, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, - 0, 13, 0, 7, 0, 0, 7, 3, 0, 3, - 1, 3, 1, 1, 0, 0, 3, 0, 12, 0, - 1, 0, 3, 3, 1, 3, 3, 5, 0, 1, - 1, 3, 3, 5, 0, 1, 0, 1, 0, 4, - 0, 4, 0, 4, 2, 3, 3, 3, 3, 3, - 2, 1, 1, 3, 4, 2, 2, 4, 4, 4, - 3, 1, 4, 1, 1, 1, 1, -}; -short yydefred[] = { 1, - 0, 0, 0, 21, 0, 83, 0, 0, 22, 24, - 0, 0, 28, 0, 35, 0, 0, 94, 95, 0, - 18, 25, 97, 23, 39, 19, 0, 0, 0, 0, - 0, 2, 0, 16, 4, 7, 5, 17, 0, 0, - 0, 0, 96, 86, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 81, 0, 0, 0, 11, 71, - 73, 0, 0, 0, 0, 0, 69, 87, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 91, 43, 0, 40, 0, 84, - 0, 0, 38, 0, 0, 0, 0, 0, 0, 0, - 0, 8, 0, 85, 0, 93, 0, 0, 0, 88, - 27, 0, 0, 33, 0, 89, 90, 0, 13, 15, - 0, 0, 0, 62, 0, 0, 0, 0, 0, 29, - 0, 0, 42, 0, 56, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 46, 34, 37, 0, 48, 58, - 30, 0, 0, 0, 0, 47, 53, 54, 0, 0, - 0, 31, 49, 0, 32, -}; -short yydgoto[] = { 1, - 30, 79, 31, 113, 108, 149, 109, 73, 74, 32, - 33, 58, 34, 35, 59, 48, 138, 155, 164, 131, - 146, 50, 132, 88, 54, 89, 152, 154, 101, 94, - 95, -}; -short yysindex[] = { 0, - -7, 58, 212, 0, -22, 0, -233, -241, 0, 0, - -8, -5, 0, -4, 0, 2, 4, 0, 0, 9, - 0, 0, 0, 0, 0, 0, 212, 212, 91, 725, - -240, 0, -29, 0, 0, 0, 0, 0, 84, 245, - 212, -57, 0, 0, 10, 212, 212, 14, 212, 16, - 212, 212, 23, 156, 0, 549, 127, -52, 0, 0, - 0, 212, 212, 212, 212, 212, 0, 0, 0, 91, - -17, 725, 24, -3, 578, -205, 562, 725, 27, 212, - 606, 212, 669, 716, 0, 0, 725, 0, 19, 0, - 91, 127, 0, 212, 212, -36, -39, -91, -91, -36, - 212, 0, 166, 0, 277, 0, -21, 36, 40, 0, - 0, 725, 28, 0, 725, 0, 0, 156, 0, 0, - 84, 540, -39, 0, -9, 725, -2, -37, -174, 0, - 127, 48, 0, 346, 0, -167, 3, 212, -185, 127, - 0, -188, 6, 37, 0, 0, 0, -205, 0, 0, - 0, 127, -42, 91, 212, 0, 0, 0, -20, 54, - 26, 0, 0, 127, 0, -}; -short yyrindex[] = { 0, - -16, 0, 0, 0, 409, 0, 0, 0, 0, 0, - 0, -58, 0, 0, 0, 0, 426, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -50, 46, - 470, 0, 0, 0, 0, 0, 0, 0, 661, 56, - 0, 525, 0, 0, 0, 0, 59, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, -6, - 705, 7, 0, 60, 0, 61, 0, 63, 0, 49, - 0, 0, 0, 0, 0, 0, 17, 0, 78, 0, - -47, -45, 0, 0, 0, 537, 440, 620, 637, 594, - 0, 0, 0, 0, 0, 0, -33, 0, 66, 0, - 0, -19, 0, 0, 68, 0, 0, 0, 0, 0, - 667, 680, 508, 0, 705, 18, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, -31, 49, -44, 0, - 0, -40, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 69, 0, 0, 0, 0, 0, - 13, 0, 0, 0, 0, -}; -short yygindex[] = { 0, - 958, 0, 104, -118, 0, 0, -35, 0, 0, 0, - 0, -34, 22, 0, 15, 0, 0, 0, 0, 0, - 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, - 0, -}; -#define YYTABLESIZE 1113 -short yytable[] = { 52, - 26, 129, 66, 64, 52, 65, 92, 55, 10, 57, - 55, 12, 57, 14, 45, 36, 158, 40, 52, 144, - 45, 66, 40, 38, 67, 55, 68, 57, 42, 70, - 40, 46, 28, 41, 47, 49, 160, 27, 92, 66, - 105, 51, 6, 52, 43, 18, 19, 61, 53, 76, - 61, 23, 9, 80, 66, 82, 107, 66, 63, 10, - 44, 63, 118, 85, 104, 28, 26, 111, 41, 127, - 27, 12, 93, 103, 10, 44, 128, 12, 38, 14, - 45, 134, 52, 129, 102, 136, 130, 137, 140, 142, - 135, 145, 148, 143, 162, 151, 59, 28, 150, 67, - 60, 50, 27, 68, 20, 119, 51, 65, 36, 65, - 44, 0, 153, 120, 0, 29, 133, 0, 0, 159, - 0, 0, 0, 0, 0, 0, 64, 0, 65, 0, - 28, 0, 0, 0, 0, 27, 41, 0, 0, 0, - 0, 44, 0, 0, 0, 0, 0, 0, 29, 0, - 163, 0, 139, 0, 0, 0, 0, 0, 0, 0, - 0, 147, 0, 0, 0, 0, 28, 0, 0, 0, - 20, 27, 62, 156, 0, 119, 0, 66, 0, 0, - 29, 0, 0, 0, 0, 165, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 28, 0, 0, 26, 0, - 27, 0, 41, 0, 91, 28, 10, 0, 0, 12, - 27, 14, 45, 29, 157, 52, 52, 0, 26, 52, - 52, 52, 52, 55, 62, 57, 52, 69, 52, 52, - 52, 52, 52, 52, 52, 52, 161, 52, 52, 52, - 6, 52, 52, 52, 52, 52, 52, 52, 2, 29, - 9, 28, 3, 4, 5, 6, 27, 10, 124, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 12, - 17, 18, 19, 44, 20, 21, 22, 23, 24, 25, - 26, 57, 0, 0, 28, 3, 4, 5, 6, 27, - 0, 0, 7, 44, 9, 10, 11, 12, 13, 14, - 15, 16, 20, 17, 18, 19, 0, 20, 21, 22, - 23, 24, 25, 26, 37, 0, 28, 3, 4, 5, - 6, 27, 20, 0, 7, 0, 9, 10, 11, 12, - 13, 14, 15, 16, 41, 17, 18, 19, 0, 20, - 21, 22, 23, 24, 25, 26, 57, 62, 0, 63, - 3, 4, 5, 6, 41, 0, 0, 7, 0, 9, - 10, 11, 12, 13, 14, 15, 16, 0, 17, 18, - 19, 0, 20, 21, 22, 23, 24, 25, 26, 0, - 0, 0, 0, 0, 0, 28, 3, 4, 5, 6, - 27, 0, 0, 7, 0, 9, 10, 11, 12, 13, - 14, 15, 16, 0, 17, 18, 19, 0, 20, 21, - 22, 23, 24, 25, 26, 3, 86, 5, 6, 0, - 0, 0, 7, 0, 0, 3, 11, 5, 6, 0, - 0, 16, 7, 17, 18, 19, 11, 20, 141, 0, - 23, 16, 0, 17, 18, 19, 0, 20, 0, 92, - 23, 92, 92, 92, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 96, 92, 96, 96, - 96, 3, 0, 5, 6, 0, 0, 0, 7, 0, - 76, 0, 11, 76, 96, 0, 0, 16, 0, 17, - 18, 19, 0, 20, 0, 0, 23, 0, 76, 0, - 0, 92, 92, 0, 3, 0, 71, 6, 0, 0, - 82, 7, 82, 82, 82, 11, 0, 0, 96, 96, - 16, 0, 17, 18, 19, 0, 20, 0, 82, 23, - 0, 0, 76, 92, 0, 0, 3, 0, 125, 6, - 0, 0, 0, 7, 0, 0, 0, 11, 70, 0, - 96, 70, 16, 0, 17, 18, 19, 0, 20, 0, - 0, 23, 82, 82, 76, 92, 70, 92, 92, 92, - 0, 0, 0, 0, 0, 0, 0, 79, 0, 79, - 79, 79, 64, 92, 65, 0, 0, 0, 0, 90, - 0, 64, 0, 65, 82, 79, 0, 0, 0, 0, - 70, 0, 110, 0, 64, 3, 65, 5, 6, 0, - 0, 0, 7, 0, 0, 0, 11, 92, 92, 0, - 64, 16, 65, 17, 18, 19, 0, 20, 0, 79, - 23, 0, 70, 66, 80, 0, 80, 80, 80, 0, - 0, 0, 66, 0, 0, 0, 114, 0, 64, 92, - 65, 0, 80, 0, 0, 66, 0, 0, 0, 0, - 77, 79, 77, 77, 77, 92, 92, 92, 0, 0, - 106, 66, 92, 92, 92, 92, 0, 78, 77, 78, - 78, 78, 96, 96, 96, 92, 80, 0, 0, 96, - 96, 96, 96, 0, 0, 78, 76, 76, 76, 66, - 0, 75, 96, 0, 75, 76, 0, 72, 0, 116, - 72, 64, 77, 65, 0, 0, 76, 0, 80, 75, - 74, 0, 0, 74, 0, 72, 82, 82, 82, 78, - 0, 0, 0, 82, 0, 82, 0, 0, 74, 0, - 0, 0, 0, 0, 77, 92, 82, 92, 92, 92, - 0, 0, 0, 75, 0, 0, 117, 0, 64, 72, - 65, 78, 66, 0, 70, 70, 70, 64, 0, 65, - 0, 0, 74, 70, 0, 0, 0, 0, 0, 0, - 0, 92, 92, 92, 70, 75, 0, 0, 92, 0, - 92, 72, 0, 79, 79, 79, 0, 60, 92, 0, - 79, 92, 79, 62, 74, 63, 60, 61, 0, 66, - 0, 0, 62, 79, 63, 0, 0, 0, 66, 60, - 61, 0, 0, 0, 0, 62, 0, 63, 0, 0, - 0, 0, 0, 0, 0, 60, 61, 0, 0, 0, - 0, 62, 0, 63, 0, 0, 0, 0, 0, 0, - 80, 80, 80, 0, 0, 0, 0, 80, 0, 80, - 0, 0, 0, 60, 61, 0, 0, 0, 0, 62, - 80, 63, 0, 0, 0, 0, 77, 77, 77, 0, - 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, - 0, 0, 0, 78, 78, 78, 77, 0, 0, 0, - 0, 0, 78, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 78, 0, 0, 0, 75, 75, 75, - 0, 0, 0, 72, 72, 72, 60, 61, 0, 0, - 0, 0, 62, 0, 63, 0, 74, 75, 74, 0, - 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 74, 0, 0, 0, - 39, 0, 92, 92, 0, 0, 0, 0, 92, 92, - 92, 92, 0, 60, 61, 0, 0, 0, 0, 62, - 0, 63, 60, 61, 55, 56, 0, 0, 62, 0, - 63, 0, 0, 0, 0, 0, 0, 72, 75, 0, - 0, 0, 0, 77, 78, 0, 81, 0, 83, 84, - 0, 87, 0, 0, 0, 0, 0, 0, 0, 96, - 97, 98, 99, 100, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 112, 0, 115, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 121, 122, 0, 0, 0, 0, 0, 123, 0, - 75, 0, 126, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 87, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 75, 0, 0, 0, 112, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 112, -}; -short yycheck[] = { 40, - 59, 44, 94, 43, 45, 45, 59, 41, 59, 41, - 44, 59, 44, 59, 59, 1, 59, 40, 59, 138, - 262, 41, 40, 2, 265, 59, 267, 59, 262, 59, - 40, 40, 40, 91, 40, 40, 155, 45, 59, 59, - 44, 40, 59, 40, 278, 279, 280, 41, 40, 40, - 44, 285, 59, 40, 94, 40, 262, 94, 41, 59, - 44, 44, 44, 41, 41, 40, 125, 41, 91, 91, - 45, 59, 125, 91, 125, 59, 41, 125, 57, 125, - 125, 91, 123, 44, 70, 123, 59, 262, 41, 257, - 93, 277, 281, 91, 41, 59, 41, 40, 93, 41, - 41, 41, 45, 41, 59, 91, 41, 59, 41, 41, - 7, -1, 148, 92, -1, 123, 118, -1, -1, 154, - -1, -1, -1, -1, -1, -1, 43, -1, 45, -1, - 40, -1, -1, -1, -1, 45, 59, -1, -1, -1, - -1, 125, -1, -1, -1, -1, -1, -1, 123, -1, - 125, -1, 131, -1, -1, -1, -1, -1, -1, -1, - -1, 140, -1, -1, -1, -1, 40, -1, -1, -1, - 125, 45, 264, 152, -1, 161, -1, 94, -1, -1, - 123, -1, -1, -1, -1, 164, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 40, -1, -1, 257, -1, - 45, -1, 125, -1, 257, 40, 257, -1, -1, 257, - 45, 257, 257, 123, 257, 256, 257, -1, 277, 260, - 261, 262, 263, 257, 264, 257, 267, 257, 269, 270, - 271, 272, 273, 274, 275, 276, 257, 278, 279, 280, - 257, 282, 283, 284, 285, 286, 287, 288, 256, 123, - 257, 40, 260, 261, 262, 263, 45, 257, 93, 267, - 268, 269, 270, 271, 272, 273, 274, 275, 276, 257, - 278, 279, 280, 257, 282, 283, 284, 285, 286, 287, - 288, 256, -1, -1, 40, 260, 261, 262, 263, 45, - -1, -1, 267, 277, 269, 270, 271, 272, 273, 274, - 275, 276, 257, 278, 279, 280, -1, 282, 283, 284, - 285, 286, 287, 288, 257, -1, 40, 260, 261, 262, - 263, 45, 277, -1, 267, -1, 269, 270, 271, 272, - 273, 274, 275, 276, 257, 278, 279, 280, -1, 282, - 283, 284, 285, 286, 287, 288, 256, 264, -1, 266, - 260, 261, 262, 263, 277, -1, -1, 267, -1, 269, - 270, 271, 272, 273, 274, 275, 276, -1, 278, 279, - 280, -1, 282, 283, 284, 285, 286, 287, 288, -1, - -1, -1, -1, -1, -1, 40, 260, 261, 262, 263, - 45, -1, -1, 267, -1, 269, 270, 271, 272, 273, - 274, 275, 276, -1, 278, 279, 280, -1, 282, 283, - 284, 285, 286, 287, 288, 260, 261, 262, 263, -1, - -1, -1, 267, -1, -1, 260, 271, 262, 263, -1, - -1, 276, 267, 278, 279, 280, 271, 282, 93, -1, - 285, 276, -1, 278, 279, 280, -1, 282, -1, 41, - 285, 43, 44, 45, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 41, 59, 43, 44, - 45, 260, -1, 262, 263, -1, -1, -1, 267, -1, - 41, -1, 271, 44, 59, -1, -1, 276, -1, 278, - 279, 280, -1, 282, -1, -1, 285, -1, 59, -1, - -1, 93, 94, -1, 260, -1, 262, 263, -1, -1, - 41, 267, 43, 44, 45, 271, -1, -1, 93, 94, - 276, -1, 278, 279, 280, -1, 282, -1, 59, 285, - -1, -1, 93, 125, -1, -1, 260, -1, 262, 263, - -1, -1, -1, 267, -1, -1, -1, 271, 41, -1, - 125, 44, 276, -1, 278, 279, 280, -1, 282, -1, - -1, 285, 93, 94, 125, 41, 59, 43, 44, 45, - -1, -1, -1, -1, -1, -1, -1, 41, -1, 43, - 44, 45, 43, 59, 45, -1, -1, -1, -1, 41, - -1, 43, -1, 45, 125, 59, -1, -1, -1, -1, - 93, -1, 41, -1, 43, 260, 45, 262, 263, -1, - -1, -1, 267, -1, -1, -1, 271, 93, 94, -1, - 43, 276, 45, 278, 279, 280, -1, 282, -1, 93, - 285, -1, 125, 94, 41, -1, 43, 44, 45, -1, - -1, -1, 94, -1, -1, -1, 41, -1, 43, 125, - 45, -1, 59, -1, -1, 94, -1, -1, -1, -1, - 41, 125, 43, 44, 45, 257, 258, 259, -1, -1, - 93, 94, 264, 265, 266, 267, -1, 41, 59, 43, - 44, 45, 257, 258, 259, 277, 93, -1, -1, 264, - 265, 266, 267, -1, -1, 59, 257, 258, 259, 94, - -1, 41, 277, -1, 44, 266, -1, 41, -1, 41, - 44, 43, 93, 45, -1, -1, 277, -1, 125, 59, - 41, -1, -1, 44, -1, 59, 257, 258, 259, 93, - -1, -1, -1, 264, -1, 266, -1, -1, 59, -1, - -1, -1, -1, -1, 125, 41, 277, 43, 44, 45, - -1, -1, -1, 93, -1, -1, 41, -1, 43, 93, - 45, 125, 94, -1, 257, 258, 259, 43, -1, 45, - -1, -1, 93, 266, -1, -1, -1, -1, -1, -1, - -1, 257, 258, 259, 277, 125, -1, -1, 264, -1, - 266, 125, -1, 257, 258, 259, -1, 258, 94, -1, - 264, 277, 266, 264, 125, 266, 258, 259, -1, 94, - -1, -1, 264, 277, 266, -1, -1, -1, 94, 258, - 259, -1, -1, -1, -1, 264, -1, 266, -1, -1, - -1, -1, -1, -1, -1, 258, 259, -1, -1, -1, - -1, 264, -1, 266, -1, -1, -1, -1, -1, -1, - 257, 258, 259, -1, -1, -1, -1, 264, -1, 266, - -1, -1, -1, 258, 259, -1, -1, -1, -1, 264, - 277, 266, -1, -1, -1, -1, 257, 258, 259, -1, - -1, -1, -1, -1, -1, 266, -1, -1, -1, -1, - -1, -1, -1, 257, 258, 259, 277, -1, -1, -1, - -1, -1, 266, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 277, -1, -1, -1, 257, 258, 259, - -1, -1, -1, 257, 258, 259, 258, 259, -1, -1, - -1, -1, 264, -1, 266, -1, 257, 277, 259, -1, - -1, -1, -1, 277, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 277, -1, -1, -1, - 3, -1, 258, 259, -1, -1, -1, -1, 264, 265, - 266, 267, -1, 258, 259, -1, -1, -1, -1, 264, - -1, 266, 258, 259, 27, 28, -1, -1, 264, -1, - 266, -1, -1, -1, -1, -1, -1, 40, 41, -1, - -1, -1, -1, 46, 47, -1, 49, -1, 51, 52, - -1, 54, -1, -1, -1, -1, -1, -1, -1, 62, - 63, 64, 65, 66, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 80, -1, 82, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 94, 95, -1, -1, -1, -1, -1, 101, -1, - 103, -1, 105, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 118, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 134, -1, -1, -1, 138, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 155, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 289 -#if YYDEBUG -char *yyname[] = { -"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,"'('","')'",0,"'+'","','","'-'",0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,"NEWLINE","AND","OR","NOT","STRING","NAME","NUMBER","MUL_OP", -"ASSIGN_OP","REL_OP","INCR_DECR","Define","Break","Quit","Length","Return", -"For","If","While","Sqrt","Else","Scale","Ibase","Obase","Auto","Read", -"Warranty","Halt","Last","Continue","Print","Limits","UNARY_MINUS", -}; -char *yyrule[] = { -"$accept : program", -"program :", -"program : program input_item", -"input_item : semicolon_list NEWLINE", -"input_item : function", -"input_item : error NEWLINE", -"semicolon_list :", -"semicolon_list : statement_or_error", -"semicolon_list : semicolon_list ';' statement_or_error", -"semicolon_list : semicolon_list ';'", -"statement_list :", -"statement_list : statement_or_error", -"statement_list : statement_list NEWLINE", -"statement_list : statement_list NEWLINE statement_or_error", -"statement_list : statement_list ';'", -"statement_list : statement_list ';' statement", -"statement_or_error : statement", -"statement_or_error : error statement", -"statement : Warranty", -"statement : Limits", -"statement : expression", -"statement : STRING", -"statement : Break", -"statement : Continue", -"statement : Quit", -"statement : Halt", -"statement : Return", -"statement : Return '(' return_expression ')'", -"$$1 :", -"$$2 :", -"$$3 :", -"$$4 :", -"statement : For $$1 '(' opt_expression ';' $$2 opt_expression ';' $$3 opt_expression ')' $$4 statement", -"$$5 :", -"statement : If '(' expression ')' $$5 statement opt_else", -"$$6 :", -"$$7 :", -"statement : While $$6 '(' expression $$7 ')' statement", -"statement : '{' statement_list '}'", -"$$8 :", -"statement : Print $$8 print_list", -"print_list : print_element", -"print_list : print_element ',' print_list", -"print_element : STRING", -"print_element : expression", -"opt_else :", -"$$9 :", -"opt_else : Else $$9 statement", -"$$10 :", -"function : Define NAME '(' opt_parameter_list ')' '{' NEWLINE opt_auto_define_list $$10 statement_list NEWLINE '}'", -"opt_parameter_list :", -"opt_parameter_list : define_list", -"opt_auto_define_list :", -"opt_auto_define_list : Auto define_list NEWLINE", -"opt_auto_define_list : Auto define_list ';'", -"define_list : NAME", -"define_list : NAME '[' ']'", -"define_list : define_list ',' NAME", -"define_list : define_list ',' NAME '[' ']'", -"opt_argument_list :", -"opt_argument_list : argument_list", -"argument_list : expression", -"argument_list : NAME '[' ']'", -"argument_list : argument_list ',' expression", -"argument_list : argument_list ',' NAME '[' ']'", -"opt_expression :", -"opt_expression : expression", -"return_expression :", -"return_expression : expression", -"$$11 :", -"expression : named_expression ASSIGN_OP $$11 expression", -"$$12 :", -"expression : expression AND $$12 expression", -"$$13 :", -"expression : expression OR $$13 expression", -"expression : NOT expression", -"expression : expression REL_OP expression", -"expression : expression '+' expression", -"expression : expression '-' expression", -"expression : expression MUL_OP expression", -"expression : expression '^' expression", -"expression : '-' expression", -"expression : named_expression", -"expression : NUMBER", -"expression : '(' expression ')'", -"expression : NAME '(' opt_argument_list ')'", -"expression : INCR_DECR named_expression", -"expression : named_expression INCR_DECR", -"expression : Length '(' expression ')'", -"expression : Sqrt '(' expression ')'", -"expression : Scale '(' expression ')'", -"expression : Read '(' ')'", -"named_expression : NAME", -"named_expression : NAME '[' expression ']'", -"named_expression : Ibase", -"named_expression : Obase", -"named_expression : Scale", -"named_expression : Last", -}; -#endif -#define yyclearin (yychar=(-1)) -#define yyerrok (yyerrflag=0) -#ifdef YYSTACKSIZE -#ifndef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#endif -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 -#endif -#endif -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -short *yyssp; -YYSTYPE *yyvsp; -YYSTYPE yyval; -YYSTYPE yylval; -short yyss[YYSTACKSIZE]; -YYSTYPE yyvs[YYSTACKSIZE]; -#define yystacksize YYSTACKSIZE -#define YYABORT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab -int -yyparse() -{ - register int yym, yyn, yystate; -#if YYDEBUG - register char *yys; - extern char *getenv(); - - if (yys = getenv("YYDEBUG")) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - -yyloop: - if (yyn = yydefred[yystate]) goto yyreduce; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, reading %d (%s)\n", yystate, - yychar, yys); - } -#endif - } - if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, shifting to state %d\n", - yystate, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - yychar = (-1); - if (yyerrflag > 0) --yyerrflag; - goto yyloop; - } - if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; -#ifdef lint - goto yynewerror; -#endif -yynewerror: - yyerror("syntax error"); -#ifdef lint - goto yyerrlab; -#endif -yyerrlab: - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, error recovery shifting\ - to state %d\n", *yyssp, yytable[yyn]); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate = yytable[yyn]; - *++yyvsp = yylval; - goto yyloop; - } - else - { -#if YYDEBUG - if (yydebug) - printf("yydebug: error recovery discarding state %d\n", - *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, error recovery discards token %d (%s)\n", - yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, reducing by rule %d (%s)\n", - yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 1: -#line 106 "bc.y" -{ - yyval.i_value = 0; - if (interactive) - { - printf ("%s\n", BC_VERSION); - welcome (); - } - } -break; -case 3: -#line 117 "bc.y" -{ run_code (); } -break; -case 4: -#line 119 "bc.y" -{ run_code (); } -break; -case 5: -#line 121 "bc.y" -{ - yyerrok; - init_gen (); - } -break; -case 6: -#line 127 "bc.y" -{ yyval.i_value = 0; } -break; -case 10: -#line 133 "bc.y" -{ yyval.i_value = 0; } -break; -case 17: -#line 142 "bc.y" -{ yyval.i_value = yyvsp[0].i_value; } -break; -case 18: -#line 145 "bc.y" -{ warranty (""); } -break; -case 19: -#line 147 "bc.y" -{ limits (); } -break; -case 20: -#line 149 "bc.y" -{ - if (yyvsp[0].i_value & 2) - warn ("comparison in expression"); - if (yyvsp[0].i_value & 1) - generate ("W"); - else - generate ("p"); - } -break; -case 21: -#line 158 "bc.y" -{ - yyval.i_value = 0; - generate ("w"); - generate (yyvsp[0].s_value); - free (yyvsp[0].s_value); - } -break; -case 22: -#line 165 "bc.y" -{ - if (break_label == 0) - yyerror ("Break outside a for/while"); - else - { - sprintf (genstr, "J%1d:", break_label); - generate (genstr); - } - } -break; -case 23: -#line 175 "bc.y" -{ - warn ("Continue statement"); - if (continue_label == 0) - yyerror ("Continue outside a for"); - else - { - sprintf (genstr, "J%1d:", continue_label); - generate (genstr); - } - } -break; -case 24: -#line 186 "bc.y" -{ exit (0); } -break; -case 25: -#line 188 "bc.y" -{ generate ("h"); } -break; -case 26: -#line 190 "bc.y" -{ generate ("0R"); } -break; -case 27: -#line 192 "bc.y" -{ generate ("R"); } -break; -case 28: -#line 194 "bc.y" -{ - yyvsp[0].i_value = break_label; - break_label = next_label++; - } -break; -case 29: -#line 199 "bc.y" -{ - if (yyvsp[-1].i_value > 1) - warn ("Comparison in first for expression"); - yyvsp[-1].i_value = next_label++; - if (yyvsp[-1].i_value < 0) - sprintf (genstr, "N%1d:", yyvsp[-1].i_value); - else - sprintf (genstr, "pN%1d:", yyvsp[-1].i_value); - generate (genstr); - } -break; -case 30: -#line 210 "bc.y" -{ - if (yyvsp[-1].i_value < 0) generate ("1"); - yyvsp[-1].i_value = next_label++; - sprintf (genstr, "B%1d:J%1d:", yyvsp[-1].i_value, break_label); - generate (genstr); - yyval.i_value = continue_label; - continue_label = next_label++; - sprintf (genstr, "N%1d:", continue_label); - generate (genstr); - } -break; -case 31: -#line 221 "bc.y" -{ - if (yyvsp[-1].i_value > 1) - warn ("Comparison in third for expression"); - if (yyvsp[-1].i_value < 0) - sprintf (genstr, "J%1d:N%1d:", yyvsp[-7].i_value, yyvsp[-4].i_value); - else - sprintf (genstr, "pJ%1d:N%1d:", yyvsp[-7].i_value, yyvsp[-4].i_value); - generate (genstr); - } -break; -case 32: -#line 231 "bc.y" -{ - sprintf (genstr, "J%1d:N%1d:", - continue_label, break_label); - generate (genstr); - break_label = yyvsp[-12].i_value; - continue_label = yyvsp[-4].i_value; - } -break; -case 33: -#line 239 "bc.y" -{ - yyvsp[-1].i_value = if_label; - if_label = next_label++; - sprintf (genstr, "Z%1d:", if_label); - generate (genstr); - } -break; -case 34: -#line 246 "bc.y" -{ - sprintf (genstr, "N%1d:", if_label); - generate (genstr); - if_label = yyvsp[-4].i_value; - } -break; -case 35: -#line 252 "bc.y" -{ - yyvsp[0].i_value = next_label++; - sprintf (genstr, "N%1d:", yyvsp[0].i_value); - generate (genstr); - } -break; -case 36: -#line 258 "bc.y" -{ - yyvsp[0].i_value = break_label; - break_label = next_label++; - sprintf (genstr, "Z%1d:", break_label); - generate (genstr); - } -break; -case 37: -#line 265 "bc.y" -{ - sprintf (genstr, "J%1d:N%1d:", yyvsp[-6].i_value, break_label); - generate (genstr); - break_label = yyvsp[-3].i_value; - } -break; -case 38: -#line 271 "bc.y" -{ yyval.i_value = 0; } -break; -case 39: -#line 273 "bc.y" -{ warn ("print statement"); } -break; -case 43: -#line 280 "bc.y" -{ - generate ("O"); - generate (yyvsp[0].s_value); - free (yyvsp[0].s_value); - } -break; -case 44: -#line 286 "bc.y" -{ generate ("P"); } -break; -case 46: -#line 290 "bc.y" -{ - warn ("else clause in if statement"); - yyvsp[0].i_value = next_label++; - sprintf (genstr, "J%d:N%1d:", yyvsp[0].i_value, if_label); - generate (genstr); - if_label = yyvsp[0].i_value; - } -break; -case 48: -#line 300 "bc.y" -{ - /* Check auto list against parameter list? */ - check_params (yyvsp[-4].a_value,yyvsp[0].a_value); - sprintf (genstr, "F%d,%s.%s[", lookup(yyvsp[-6].s_value,FUNCT), - arg_str (yyvsp[-4].a_value,TRUE), arg_str (yyvsp[0].a_value,TRUE)); - generate (genstr); - free_args (yyvsp[-4].a_value); - free_args (yyvsp[0].a_value); - yyvsp[-7].i_value = next_label; - next_label = 0; - } -break; -case 49: -#line 312 "bc.y" -{ - generate ("0R]"); - next_label = yyvsp[-11].i_value; - } -break; -case 50: -#line 318 "bc.y" -{ yyval.a_value = NULL; } -break; -case 52: -#line 322 "bc.y" -{ yyval.a_value = NULL; } -break; -case 53: -#line 324 "bc.y" -{ yyval.a_value = yyvsp[-1].a_value; } -break; -case 54: -#line 326 "bc.y" -{ yyval.a_value = yyvsp[-1].a_value; } -break; -case 55: -#line 329 "bc.y" -{ yyval.a_value = nextarg (NULL, lookup (yyvsp[0].s_value,SIMPLE)); } -break; -case 56: -#line 331 "bc.y" -{ yyval.a_value = nextarg (NULL, lookup (yyvsp[-2].s_value,ARRAY)); } -break; -case 57: -#line 333 "bc.y" -{ yyval.a_value = nextarg (yyvsp[-2].a_value, lookup (yyvsp[0].s_value,SIMPLE)); } -break; -case 58: -#line 335 "bc.y" -{ yyval.a_value = nextarg (yyvsp[-4].a_value, lookup (yyvsp[-2].s_value,ARRAY)); } -break; -case 59: -#line 338 "bc.y" -{ yyval.a_value = NULL; } -break; -case 61: -#line 342 "bc.y" -{ - if (yyvsp[0].i_value > 1) warn ("comparison in argument"); - yyval.a_value = nextarg (NULL,0); - } -break; -case 62: -#line 347 "bc.y" -{ - sprintf (genstr, "K%d:", -lookup (yyvsp[-2].s_value,ARRAY)); - generate (genstr); - yyval.a_value = nextarg (NULL,1); - } -break; -case 63: -#line 353 "bc.y" -{ - if (yyvsp[0].i_value > 1) warn ("comparison in argument"); - yyval.a_value = nextarg (yyvsp[-2].a_value,0); - } -break; -case 64: -#line 358 "bc.y" -{ - sprintf (genstr, "K%d:", -lookup (yyvsp[-2].s_value,ARRAY)); - generate (genstr); - yyval.a_value = nextarg (yyvsp[-4].a_value,1); - } -break; -case 65: -#line 365 "bc.y" -{ - yyval.i_value = -1; - warn ("Missing expression in for statement"); - } -break; -case 67: -#line 372 "bc.y" -{ - yyval.i_value = 0; - generate ("0"); - } -break; -case 68: -#line 377 "bc.y" -{ - if (yyvsp[0].i_value > 1) - warn ("comparison in return expresion"); - } -break; -case 69: -#line 383 "bc.y" -{ - if (yyvsp[0].c_value != '=') - { - if (yyvsp[-1].i_value < 0) - sprintf (genstr, "DL%d:", -yyvsp[-1].i_value); - else - sprintf (genstr, "l%d:", yyvsp[-1].i_value); - generate (genstr); - } - } -break; -case 70: -#line 394 "bc.y" -{ - if (yyvsp[0].i_value > 1) warn("comparison in assignment"); - if (yyvsp[-2].c_value != '=') - { - sprintf (genstr, "%c", yyvsp[-2].c_value); - generate (genstr); - } - if (yyvsp[-3].i_value < 0) - sprintf (genstr, "S%d:", -yyvsp[-3].i_value); - else - sprintf (genstr, "s%d:", yyvsp[-3].i_value); - generate (genstr); - yyval.i_value = 0; - } -break; -case 71: -#line 410 "bc.y" -{ - warn("&& operator"); - yyvsp[0].i_value = next_label++; - sprintf (genstr, "DZ%d:p", yyvsp[0].i_value); - generate (genstr); - } -break; -case 72: -#line 417 "bc.y" -{ - sprintf (genstr, "DZ%d:p1N%d:", yyvsp[-2].i_value, yyvsp[-2].i_value); - generate (genstr); - yyval.i_value = yyvsp[-3].i_value | yyvsp[0].i_value; - } -break; -case 73: -#line 423 "bc.y" -{ - warn("|| operator"); - yyvsp[0].i_value = next_label++; - sprintf (genstr, "B%d:", yyvsp[0].i_value); - generate (genstr); - } -break; -case 74: -#line 430 "bc.y" -{ - int tmplab; - tmplab = next_label++; - sprintf (genstr, "B%d:0J%d:N%d:1N%d:", - yyvsp[-2].i_value, tmplab, yyvsp[-2].i_value, tmplab); - generate (genstr); - yyval.i_value = yyvsp[-3].i_value | yyvsp[0].i_value; - } -break; -case 75: -#line 439 "bc.y" -{ - yyval.i_value = yyvsp[0].i_value; - warn("! operator"); - generate ("!"); - } -break; -case 76: -#line 445 "bc.y" -{ - yyval.i_value = 3; - switch (*(yyvsp[-1].s_value)) - { - case '=': - generate ("="); - break; - - case '!': - generate ("#"); - break; - - case '<': - if (yyvsp[-1].s_value[1] == '=') - generate ("{"); - else - generate ("<"); - break; - - case '>': - if (yyvsp[-1].s_value[1] == '=') - generate ("}"); - else - generate (">"); - break; - } - } -break; -case 77: -#line 473 "bc.y" -{ - generate ("+"); - yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value; - } -break; -case 78: -#line 478 "bc.y" -{ - generate ("-"); - yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value; - } -break; -case 79: -#line 483 "bc.y" -{ - genstr[0] = yyvsp[-1].c_value; - genstr[1] = 0; - generate (genstr); - yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value; - } -break; -case 80: -#line 490 "bc.y" -{ - generate ("^"); - yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value; - } -break; -case 81: -#line 495 "bc.y" -{ - generate ("n"); - yyval.i_value = yyvsp[0].i_value; - } -break; -case 82: -#line 500 "bc.y" -{ - yyval.i_value = 1; - if (yyvsp[0].i_value < 0) - sprintf (genstr, "L%d:", -yyvsp[0].i_value); - else - sprintf (genstr, "l%d:", yyvsp[0].i_value); - generate (genstr); - } -break; -case 83: -#line 509 "bc.y" -{ - int len = strlen(yyvsp[0].s_value); - yyval.i_value = 1; - if (len == 1 && *yyvsp[0].s_value == '0') - generate ("0"); - else if (len == 1 && *yyvsp[0].s_value == '1') - generate ("1"); - else - { - generate ("K"); - generate (yyvsp[0].s_value); - generate (":"); - } - free (yyvsp[0].s_value); - } -break; -case 84: -#line 525 "bc.y" -{ yyval.i_value = yyvsp[-1].i_value | 1; } -break; -case 85: -#line 527 "bc.y" -{ - yyval.i_value = 1; - if (yyvsp[-1].a_value != NULL) - { - sprintf (genstr, "C%d,%s:", - lookup (yyvsp[-3].s_value,FUNCT), - arg_str (yyvsp[-1].a_value,FALSE)); - free_args (yyvsp[-1].a_value); - } - else - { - sprintf (genstr, "C%d:", lookup (yyvsp[-3].s_value,FUNCT)); - } - generate (genstr); - } -break; -case 86: -#line 543 "bc.y" -{ - yyval.i_value = 1; - if (yyvsp[0].i_value < 0) - { - if (yyvsp[-1].c_value == '+') - sprintf (genstr, "DA%d:L%d:", -yyvsp[0].i_value, -yyvsp[0].i_value); - else - sprintf (genstr, "DM%d:L%d:", -yyvsp[0].i_value, -yyvsp[0].i_value); - } - else - { - if (yyvsp[-1].c_value == '+') - sprintf (genstr, "i%d:l%d:", yyvsp[0].i_value, yyvsp[0].i_value); - else - sprintf (genstr, "d%d:l%d:", yyvsp[0].i_value, yyvsp[0].i_value); - } - generate (genstr); - } -break; -case 87: -#line 562 "bc.y" -{ - yyval.i_value = 1; - if (yyvsp[-1].i_value < 0) - { - sprintf (genstr, "DL%d:x", -yyvsp[-1].i_value); - generate (genstr); - if (yyvsp[0].c_value == '+') - sprintf (genstr, "A%d:", -yyvsp[-1].i_value); - else - sprintf (genstr, "M%d:", -yyvsp[-1].i_value); - } - else - { - sprintf (genstr, "l%d:", yyvsp[-1].i_value); - generate (genstr); - if (yyvsp[0].c_value == '+') - sprintf (genstr, "i%d:", yyvsp[-1].i_value); - else - sprintf (genstr, "d%d:", yyvsp[-1].i_value); - } - generate (genstr); - } -break; -case 88: -#line 585 "bc.y" -{ generate ("cL"); yyval.i_value = 1;} -break; -case 89: -#line 587 "bc.y" -{ generate ("cR"); yyval.i_value = 1;} -break; -case 90: -#line 589 "bc.y" -{ generate ("cS"); yyval.i_value = 1;} -break; -case 91: -#line 591 "bc.y" -{ - warn ("read function"); - generate ("cI"); yyval.i_value = 1; - } -break; -case 92: -#line 597 "bc.y" -{ yyval.i_value = lookup(yyvsp[0].s_value,SIMPLE); } -break; -case 93: -#line 599 "bc.y" -{ - if (yyvsp[-1].i_value > 1) warn("comparison in subscript"); - yyval.i_value = lookup(yyvsp[-3].s_value,ARRAY); - } -break; -case 94: -#line 604 "bc.y" -{ yyval.i_value = 0; } -break; -case 95: -#line 606 "bc.y" -{ yyval.i_value = 1; } -break; -case 96: -#line 608 "bc.y" -{ yyval.i_value = 2; } -break; -case 97: -#line 610 "bc.y" -{ yyval.i_value = 3; } -break; -#line 1314 "y.tab.c" - } - yyssp -= yym; - yystate = *yyssp; - yyvsp -= yym; - yym = yylhs[yyn]; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: after reduction, shifting from state 0 to\ - state %d\n", YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, reading %d (%s)\n", - YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("yydebug: after reduction, shifting from state %d \ -to state %d\n", *yyssp, yystate); -#endif - if (yyssp >= yyss + yystacksize - 1) - { - goto yyoverflow; - } - *++yyssp = yystate; - *++yyvsp = yyval; - goto yyloop; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); -} diff --git a/gnu/usr.bin/bc-1.02/bc.y b/gnu/usr.bin/bc-1.02/bc.y deleted file mode 100644 index e67e10174496..000000000000 --- a/gnu/usr.bin/bc-1.02/bc.y +++ /dev/null @@ -1,612 +0,0 @@ -%{ -/* bc.y: The grammar for a POSIX compatable bc processor with some - extensions to the language. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -#include "bcdefs.h" -#include "global.h" -#include "proto.h" -%} - -%start program - -%union { - char *s_value; - char c_value; - int i_value; - arg_list *a_value; - } - -/* Extensions over POSIX bc. - a) NAME was LETTER. This grammer allows longer names. - Single letter names will still work. - b) Relational_expression allowed only one comparison. - This grammar has added boolean expressions with - && (and) || (or) and ! (not) and allowed all of them in - full expressions. - c) Added an else to the if. - d) Call by variable array parameters - e) read() procedure that reads a number under program control from stdin. - f) halt statement that halts the the program under program control. It - is an executed statement. - g) continue statement for for loops. - h) optional expressions in the for loop. - i) print statement to print multiple numbers per line. - j) warranty statement to print an extended warranty notice. - j) limits statement to print the processor's limits. -*/ - -%token NEWLINE AND OR NOT -%token STRING NAME NUMBER -/* '-', '+' are tokens themselves */ -%token MUL_OP -/* '*', '/', '%' */ -%token ASSIGN_OP -/* '=', '+=', '-=', '*=', '/=', '%=', '^=' */ -%token REL_OP -/* '==', '<=', '>=', '!=', '<', '>' */ -%token INCR_DECR -/* '++', '--' */ -%token Define Break Quit Length -/* 'define', 'break', 'quit', 'length' */ -%token Return For If While Sqrt Else -/* 'return', 'for', 'if', 'while', 'sqrt', 'else' */ -%token Scale Ibase Obase Auto Read -/* 'scale', 'ibase', 'obase', 'auto', 'read' */ -%token Warranty, Halt, Last, Continue, Print, Limits -/* 'warranty', 'halt', 'last', 'continue', 'print', 'limits' */ - -/* Types of all other things. */ -%type expression return_expression named_expression opt_expression -%type '+' '-' -%type opt_parameter_list opt_auto_define_list define_list -%type opt_argument_list argument_list -%type program input_item semicolon_list statement_list -%type statement function statement_or_error - -/* precedence */ -%left OR -%left AND -%nonassoc NOT -%left REL_OP -%right ASSIGN_OP -%left '+' '-' -%left MUL_OP -%right '^' -%nonassoc UNARY_MINUS -%nonassoc INCR_DECR - -%% -program : /* empty */ - { - $$ = 0; - if (interactive) - { - printf ("%s\n", BC_VERSION); - welcome (); - } - } - | program input_item - ; -input_item : semicolon_list NEWLINE - { run_code (); } - | function - { run_code (); } - | error NEWLINE - { - yyerrok; - init_gen (); - } - ; -semicolon_list : /* empty */ - { $$ = 0; } - | statement_or_error - | semicolon_list ';' statement_or_error - | semicolon_list ';' - ; -statement_list : /* empty */ - { $$ = 0; } - | statement_or_error - | statement_list NEWLINE - | statement_list NEWLINE statement_or_error - | statement_list ';' - | statement_list ';' statement - ; -statement_or_error : statement - | error statement - { $$ = $2; } - ; -statement : Warranty - { warranty (""); } - | Limits - { limits (); } - | expression - { - if ($1 & 2) - warn ("comparison in expression"); - if ($1 & 1) - generate ("W"); - else - generate ("p"); - } - | STRING - { - $$ = 0; - generate ("w"); - generate ($1); - free ($1); - } - | Break - { - if (break_label == 0) - yyerror ("Break outside a for/while"); - else - { - sprintf (genstr, "J%1d:", break_label); - generate (genstr); - } - } - | Continue - { - warn ("Continue statement"); - if (continue_label == 0) - yyerror ("Continue outside a for"); - else - { - sprintf (genstr, "J%1d:", continue_label); - generate (genstr); - } - } - | Quit - { exit (0); } - | Halt - { generate ("h"); } - | Return - { generate ("0R"); } - | Return '(' return_expression ')' - { generate ("R"); } - | For - { - $1 = break_label; - break_label = next_label++; - } - '(' opt_expression ';' - { - if ($4 > 1) - warn ("Comparison in first for expression"); - $4 = next_label++; - if ($4 < 0) - sprintf (genstr, "N%1d:", $4); - else - sprintf (genstr, "pN%1d:", $4); - generate (genstr); - } - opt_expression ';' - { - if ($7 < 0) generate ("1"); - $7 = next_label++; - sprintf (genstr, "B%1d:J%1d:", $7, break_label); - generate (genstr); - $$ = continue_label; - continue_label = next_label++; - sprintf (genstr, "N%1d:", continue_label); - generate (genstr); - } - opt_expression ')' - { - if ($10 > 1) - warn ("Comparison in third for expression"); - if ($10 < 0) - sprintf (genstr, "J%1d:N%1d:", $4, $7); - else - sprintf (genstr, "pJ%1d:N%1d:", $4, $7); - generate (genstr); - } - statement - { - sprintf (genstr, "J%1d:N%1d:", - continue_label, break_label); - generate (genstr); - break_label = $1; - continue_label = $9; - } - | If '(' expression ')' - { - $3 = if_label; - if_label = next_label++; - sprintf (genstr, "Z%1d:", if_label); - generate (genstr); - } - statement opt_else - { - sprintf (genstr, "N%1d:", if_label); - generate (genstr); - if_label = $3; - } - | While - { - $1 = next_label++; - sprintf (genstr, "N%1d:", $1); - generate (genstr); - } - '(' expression - { - $4 = break_label; - break_label = next_label++; - sprintf (genstr, "Z%1d:", break_label); - generate (genstr); - } - ')' statement - { - sprintf (genstr, "J%1d:N%1d:", $1, break_label); - generate (genstr); - break_label = $4; - } - | '{' statement_list '}' - { $$ = 0; } - | Print - { warn ("print statement"); } - print_list - ; -print_list : print_element - | print_element ',' print_list - ; -print_element : STRING - { - generate ("O"); - generate ($1); - free ($1); - } - | expression - { generate ("P"); } - ; -opt_else : /* nothing */ - | Else - { - warn ("else clause in if statement"); - $1 = next_label++; - sprintf (genstr, "J%d:N%1d:", $1, if_label); - generate (genstr); - if_label = $1; - } - statement -function : Define NAME '(' opt_parameter_list ')' '{' - NEWLINE opt_auto_define_list - { - /* Check auto list against parameter list? */ - check_params ($4,$8); - sprintf (genstr, "F%d,%s.%s[", lookup($2,FUNCT), - arg_str ($4,TRUE), arg_str ($8,TRUE)); - generate (genstr); - free_args ($4); - free_args ($8); - $1 = next_label; - next_label = 0; - } - statement_list NEWLINE '}' - { - generate ("0R]"); - next_label = $1; - } - ; -opt_parameter_list : /* empty */ - { $$ = NULL; } - | define_list - ; -opt_auto_define_list : /* empty */ - { $$ = NULL; } - | Auto define_list NEWLINE - { $$ = $2; } - | Auto define_list ';' - { $$ = $2; } - ; -define_list : NAME - { $$ = nextarg (NULL, lookup ($1,SIMPLE)); } - | NAME '[' ']' - { $$ = nextarg (NULL, lookup ($1,ARRAY)); } - | define_list ',' NAME - { $$ = nextarg ($1, lookup ($3,SIMPLE)); } - | define_list ',' NAME '[' ']' - { $$ = nextarg ($1, lookup ($3,ARRAY)); } - ; -opt_argument_list : /* empty */ - { $$ = NULL; } - | argument_list - ; -argument_list : expression - { - if ($1 > 1) warn ("comparison in argument"); - $$ = nextarg (NULL,0); - } - | NAME '[' ']' - { - sprintf (genstr, "K%d:", -lookup ($1,ARRAY)); - generate (genstr); - $$ = nextarg (NULL,1); - } - | argument_list ',' expression - { - if ($3 > 1) warn ("comparison in argument"); - $$ = nextarg ($1,0); - } - | argument_list ',' NAME '[' ']' - { - sprintf (genstr, "K%d:", -lookup ($3,ARRAY)); - generate (genstr); - $$ = nextarg ($1,1); - } - ; -opt_expression : /* empty */ - { - $$ = -1; - warn ("Missing expression in for statement"); - } - | expression - ; -return_expression : /* empty */ - { - $$ = 0; - generate ("0"); - } - | expression - { - if ($1 > 1) - warn ("comparison in return expresion"); - } - ; -expression : named_expression ASSIGN_OP - { - if ($2 != '=') - { - if ($1 < 0) - sprintf (genstr, "DL%d:", -$1); - else - sprintf (genstr, "l%d:", $1); - generate (genstr); - } - } - expression - { - if ($4 > 1) warn("comparison in assignment"); - if ($2 != '=') - { - sprintf (genstr, "%c", $2); - generate (genstr); - } - if ($1 < 0) - sprintf (genstr, "S%d:", -$1); - else - sprintf (genstr, "s%d:", $1); - generate (genstr); - $$ = 0; - } - ; - | expression AND - { - warn("&& operator"); - $2 = next_label++; - sprintf (genstr, "DZ%d:p", $2); - generate (genstr); - } - expression - { - sprintf (genstr, "DZ%d:p1N%d:", $2, $2); - generate (genstr); - $$ = $1 | $4; - } - | expression OR - { - warn("|| operator"); - $2 = next_label++; - sprintf (genstr, "B%d:", $2); - generate (genstr); - } - expression - { - int tmplab; - tmplab = next_label++; - sprintf (genstr, "B%d:0J%d:N%d:1N%d:", - $2, tmplab, $2, tmplab); - generate (genstr); - $$ = $1 | $4; - } - | NOT expression - { - $$ = $2; - warn("! operator"); - generate ("!"); - } - | expression REL_OP expression - { - $$ = 3; - switch (*($2)) - { - case '=': - generate ("="); - break; - - case '!': - generate ("#"); - break; - - case '<': - if ($2[1] == '=') - generate ("{"); - else - generate ("<"); - break; - - case '>': - if ($2[1] == '=') - generate ("}"); - else - generate (">"); - break; - } - } - | expression '+' expression - { - generate ("+"); - $$ = $1 | $3; - } - | expression '-' expression - { - generate ("-"); - $$ = $1 | $3; - } - | expression MUL_OP expression - { - genstr[0] = $2; - genstr[1] = 0; - generate (genstr); - $$ = $1 | $3; - } - | expression '^' expression - { - generate ("^"); - $$ = $1 | $3; - } - | '-' expression %prec UNARY_MINUS - { - generate ("n"); - $$ = $2; - } - | named_expression - { - $$ = 1; - if ($1 < 0) - sprintf (genstr, "L%d:", -$1); - else - sprintf (genstr, "l%d:", $1); - generate (genstr); - } - | NUMBER - { - int len = strlen($1); - $$ = 1; - if (len == 1 && *$1 == '0') - generate ("0"); - else if (len == 1 && *$1 == '1') - generate ("1"); - else - { - generate ("K"); - generate ($1); - generate (":"); - } - free ($1); - } - | '(' expression ')' - { $$ = $2 | 1; } - | NAME '(' opt_argument_list ')' - { - $$ = 1; - if ($3 != NULL) - { - sprintf (genstr, "C%d,%s:", - lookup ($1,FUNCT), - arg_str ($3,FALSE)); - free_args ($3); - } - else - { - sprintf (genstr, "C%d:", lookup ($1,FUNCT)); - } - generate (genstr); - } - | INCR_DECR named_expression - { - $$ = 1; - if ($2 < 0) - { - if ($1 == '+') - sprintf (genstr, "DA%d:L%d:", -$2, -$2); - else - sprintf (genstr, "DM%d:L%d:", -$2, -$2); - } - else - { - if ($1 == '+') - sprintf (genstr, "i%d:l%d:", $2, $2); - else - sprintf (genstr, "d%d:l%d:", $2, $2); - } - generate (genstr); - } - | named_expression INCR_DECR - { - $$ = 1; - if ($1 < 0) - { - sprintf (genstr, "DL%d:x", -$1); - generate (genstr); - if ($2 == '+') - sprintf (genstr, "A%d:", -$1); - else - sprintf (genstr, "M%d:", -$1); - } - else - { - sprintf (genstr, "l%d:", $1); - generate (genstr); - if ($2 == '+') - sprintf (genstr, "i%d:", $1); - else - sprintf (genstr, "d%d:", $1); - } - generate (genstr); - } - | Length '(' expression ')' - { generate ("cL"); $$ = 1;} - | Sqrt '(' expression ')' - { generate ("cR"); $$ = 1;} - | Scale '(' expression ')' - { generate ("cS"); $$ = 1;} - | Read '(' ')' - { - warn ("read function"); - generate ("cI"); $$ = 1; - } - ; -named_expression : NAME - { $$ = lookup($1,SIMPLE); } - | NAME '[' expression ']' - { - if ($3 > 1) warn("comparison in subscript"); - $$ = lookup($1,ARRAY); - } - | Ibase - { $$ = 0; } - | Obase - { $$ = 1; } - | Scale - { $$ = 2; } - | Last - { $$ = 3; } - ; -%% diff --git a/gnu/usr.bin/bc-1.02/bcdefs.h b/gnu/usr.bin/bc-1.02/bcdefs.h deleted file mode 100644 index a9d217657086..000000000000 --- a/gnu/usr.bin/bc-1.02/bcdefs.h +++ /dev/null @@ -1,154 +0,0 @@ -/* bcdefs.h: The single file to include all constants and type definitions. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -/* Include the configuration file. */ -#include "config.h" - -/* Standard includes for all files. */ -#include -#include -#include -#ifdef STRINGS_H -#include -#else -#include -#endif -#ifndef NO_LIMITS -#include -#endif - -/* Include the other definitions. */ -#include "const.h" -#include "number.h" - - -/* These definitions define all the structures used in - code and data storage. This includes the representation of - labels. The "guiding" principle is to make structures that - take a minimum of space when unused but can be built to contain - the full structures. */ - -/* Labels are first. Labels are generated sequentially in functions - and full code. They just "point" to a single bye in the code. The - "address" is the byte number. The byte number is used to get an - actual character pointer. */ - -typedef struct bc_label_group - { - long l_adrs [ BC_LABEL_GROUP ]; - struct bc_label_group *l_next; - } bc_label_group; - - -/* Each function has its own code segments and labels. There can be - no jumps between functions so labels are unique to a function. */ - -typedef struct arg_list - { - int av_name; - struct arg_list *next; - } arg_list; - -typedef struct - { - char f_defined; /* Is this function defined yet. */ - char *f_body[BC_MAX_SEGS]; - int f_code_size; - bc_label_group *f_label; - arg_list *f_params; - arg_list *f_autos; - } bc_function; - -/* Code addresses. */ -typedef struct { - int pc_func; - int pc_addr; - } program_counter; - - -/* Variables are "pushable" (auto) and thus we need a stack mechanism. - This is built into the variable record. */ - -typedef struct bc_var - { - bc_num v_value; - struct bc_var *v_next; - } bc_var; - - -/* bc arrays can also be "auto" variables and thus need the same - kind of stacking mechanisms. */ - -typedef struct bc_array_node - { - union - { - bc_num n_num [NODE_SIZE]; - struct bc_array_node *n_down [NODE_SIZE]; - } n_items; - } bc_array_node; - -typedef struct bc_array - { - bc_array_node *a_tree; - short a_depth; - } bc_array; - -typedef struct bc_var_array - { - bc_array *a_value; - char a_param; - struct bc_var_array *a_next; - } bc_var_array; - - -/* For the stacks, execution and function, we need records to allow - for arbitrary size. */ - -typedef struct estack_rec { - bc_num s_num; - struct estack_rec *s_next; -} estack_rec; - -typedef struct fstack_rec { - int s_val; - struct fstack_rec *s_next; -} fstack_rec; - - -/* The following are for the name tree. */ - -typedef struct id_rec { - char *id; /* The program name. */ - /* A name == 0 => nothing assigned yet. */ - int a_name; /* The array variable name (number). */ - int f_name; /* The function name (number). */ - int v_name; /* The variable name (number). */ - short balance; /* For the balanced tree. */ - struct id_rec *left, *right; /* Tree pointers. */ -} id_rec; diff --git a/gnu/usr.bin/bc-1.02/config.h b/gnu/usr.bin/bc-1.02/config.h deleted file mode 100644 index a9bd0be5f5ea..000000000000 --- a/gnu/usr.bin/bc-1.02/config.h +++ /dev/null @@ -1,4 +0,0 @@ -/* config.h */ -#ifndef __STDC__ -#define VARARGS -#endif diff --git a/gnu/usr.bin/bc-1.02/configure b/gnu/usr.bin/bc-1.02/configure deleted file mode 100644 index 598cb915ce8b..000000000000 --- a/gnu/usr.bin/bc-1.02/configure +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/sh -# -# The shell script for bc to automatically create the config.h file. -# -# Syntax: configure [ include-dir [ lib-file [ c-compiler ]]] -# -# Set some standard things. -# -INCLUDE=${1-/usr/include} -LIBFILE=${2-libmath.b} -CC=${3-cc} -# -# Initialize the exit status -# -EXIT=0 -# -# Remove the current copy and make sure there is at least an empty file -# -rm -f config.h -echo "/* config.h */" > config.h -# -# Check for the argument passing mechanism. -# -if test -r $INCLUDE/varargs.h -then -echo "Using varargs.h for variable arguments (non ansi compilers). " -echo "#ifndef __STDC__" >> config.h -echo "#define VARARGS" >> config.h -echo "#endif" >> config.h -else -if test -r $INCLUDE/stdarg.h -then -echo "Using stdarg.h for variable arguments. " -else -echo "Unknown variable argument mechanism. " -EXIT=1 -fi -fi -# -# Limits file? -# -if test -r $INCLUDE/limits.h -then -echo "You have a limits.h file." -else -echo "You need to check the limits in const.h." -echo "#define NO_LIMITS" >> config.h -fi -# -# unistd? -# -if test -r $INCLUDE/unistd.h -then -echo "You have a unistd.h file." -else -echo "#define NO_UNISTD" >> config.h -fi -# -# Stdlib? -# -if test -r $INCLUDE/stdlib.h -then -echo "You have a stdlib.h file." -else -echo "#define NO_STDLIB" >> config.h -fi -# -# Strinog? -# -if test -r $INCLUDE/string.h -then -echo "You have a string.h file." -else -echo "#define STRINGS_H" >> config.h -fi -# -# At least one BSD system did not define "extern int errno;" in errno.h -# -if grep -s extern $INCLUDE/errno.h -then -true -else -echo "extern int errno;" >> config.h -fi -# -# On MINIX pc systems we want to define some extra files. -# -if test -r $INCLUDE/minix -then -# We must be on a minix system. Check for the machine type. -if test `machine` = IBM_PC -then -echo "#define SMALL_BUF" >> config.h -echo "#define BC_MATH_FILE \"$LIBFILE\"" >> config.h -echo "#define SHORTNAMES" >> config.h -else -echo "Your Minix is not on a PC. The bc library will be loaded in the" -echo "executable file. You will not have to install a library file." -fi -else -# Test to see if the compiler will compile long strings... -echo "char libmath[] =" > JUNK.c -echo "#include \"math.h\"" >> JUNK.c -echo ";" >> JUNK.c -if $CC -c JUNK.c >/dev/null 2>&1 -then -echo "The bc library will be loaded in the executable file. You will" -echo "not have to install a library file." -else -echo "Your C compiler does not like long strings. You will have to" -echo "load the math library from a file." -echo "#define BC_MATH_FILE \"$LIBFILE\"" >> config.h -fi -rm -f JUNK.c JUNK.o -fi -# -# exit -# -exit $EXIT diff --git a/gnu/usr.bin/bc-1.02/const.h b/gnu/usr.bin/bc-1.02/const.h deleted file mode 100644 index 0cee3cc62a6d..000000000000 --- a/gnu/usr.bin/bc-1.02/const.h +++ /dev/null @@ -1,87 +0,0 @@ -/* const.h: Constants for bc. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - - -/* Define INT_MAX and LONG_MAX if not defined. Assuming 32 bits... */ - -#ifdef NO_LIMITS -#define INT_MAX 0x7FFFFFFF -#define LONG_MAX 0x7FFFFFFF -#endif - - -/* Define constants in some reasonable size. The next 4 constants are - POSIX constants. */ - -#define BC_BASE_MAX INT_MAX -#define BC_SCALE_MAX INT_MAX -#define BC_STRING_MAX INT_MAX - - -/* Definitions for arrays. */ - -#define BC_DIM_MAX 65535 /* this should be NODE_SIZE^NODE_DEPTH-1 */ - -#define NODE_SIZE 16 /* Must be a power of 2. */ -#define NODE_MASK 0xf /* Must be NODE_SIZE-1. */ -#define NODE_SHIFT 4 /* Number of 1 bits in NODE_MASK. */ -#define NODE_DEPTH 4 - - -/* Other BC limits defined but not part of POSIX. */ - -#define BC_LABEL_GROUP 64 -#define BC_LABEL_LOG 6 -#define BC_MAX_SEGS 16 /* Code segments. */ -#define BC_SEG_SIZE 1024 -#define BC_SEG_LOG 10 - -/* Maximum number of variables, arrays and functions and the - allocation increment for the dynamic arrays. */ - -#define MAX_STORE 32767 -#define STORE_INCR 32 - -/* Other interesting constants. */ - -#define FALSE 0 -#define TRUE 1 -#define SIMPLE 0 -#define ARRAY 1 -#define FUNCT 2 -#define EXTERN extern -#ifdef __STDC__ -#define CONST const -#define VOID void -#else -#define CONST -#define VOID -#endif - -/* Include the version definition. */ -#include "version.h" diff --git a/gnu/usr.bin/bc-1.02/execute.c b/gnu/usr.bin/bc-1.02/execute.c deleted file mode 100644 index a7bc9c733520..000000000000 --- a/gnu/usr.bin/bc-1.02/execute.c +++ /dev/null @@ -1,783 +0,0 @@ -/* execute.c - run a bc program. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -#include "bcdefs.h" -#include -#include "global.h" -#include "proto.h" - - -/* The SIGINT interrupt handling routine. */ - -int had_sigint; - -void -stop_execution (sig) - int sig; -{ - had_sigint = TRUE; - printf ("\n"); - rt_error ("interrupted execution"); -} - - -/* Get the current byte and advance the PC counter. */ - -unsigned char -byte (pc) - program_counter *pc; -{ - int seg, offset; - - seg = pc->pc_addr >> BC_SEG_LOG; - offset = pc->pc_addr++ % BC_SEG_SIZE; - return (functions[pc->pc_func].f_body[seg][offset]); -} - - -/* The routine that actually runs the machine. */ - -void -execute () -{ - int label_num, l_gp, l_off; - bc_label_group *gp; - - char inst, ch; - int new_func; - int var_name; - - int const_base; - - bc_num temp_num; - arg_list *auto_list; - - /* Initialize this run... */ - pc.pc_func = 0; - pc.pc_addr = 0; - runtime_error = FALSE; - init_num (&temp_num); - - /* Set up the interrupt mechanism for an interactive session. */ - if (interactive) - { - signal (SIGINT, stop_execution); - had_sigint = FALSE; - } - - while (pc.pc_addr < functions[pc.pc_func].f_code_size && !runtime_error) - { - inst = byte(&pc); - -#if DEBUG > 3 - { /* Print out address and the stack before each instruction.*/ - int depth; estack_rec *temp = ex_stack; - - printf ("func=%d addr=%d inst=%c\n",pc.pc_func, pc.pc_addr, inst); - if (temp == NULL) printf ("empty stack.\n", inst); - else - { - depth = 1; - while (temp != NULL) - { - printf (" %d = ", depth); - out_num (temp->s_num, 10, out_char); - depth++; - temp = temp->s_next; - } - } - } -#endif - - switch ( inst ) - { - - case 'A' : /* increment array variable (Add one). */ - var_name = byte(&pc); - if ((var_name & 0x80) != 0) - var_name = ((var_name << 8) & 0x7f) + byte(&pc); - incr_array (var_name); - break; - - case 'B' : /* Branch to a label if TOS != 0. Remove value on TOS. */ - case 'Z' : /* Branch to a label if TOS == 0. Remove value on TOS. */ - c_code = !is_zero (ex_stack->s_num); - pop (); - case 'J' : /* Jump to a label. */ - label_num = byte(&pc); /* Low order bits first. */ - label_num += byte(&pc) << 8; - if (inst == 'J' || (inst == 'B' && c_code) - || (inst == 'Z' && !c_code)) { - gp = functions[pc.pc_func].f_label; - l_gp = label_num >> BC_LABEL_LOG; - l_off = label_num % BC_LABEL_GROUP; - while (l_gp-- > 0) gp = gp->l_next; - pc.pc_addr = gp->l_adrs[l_off]; - } - break; - - case 'C' : /* Call a function. */ - /* Get the function number. */ - new_func = byte(&pc); - if ((new_func & 0x80) != 0) - new_func = ((new_func << 8) & 0x7f) + byte(&pc); - - /* Check to make sure it is defined. */ - if (!functions[new_func].f_defined) - { - rt_error ("Function %s not defined.", f_names[new_func]); - break; - } - - /* Check and push parameters. */ - process_params (&pc, new_func); - - /* Push auto variables. */ - for (auto_list = functions[new_func].f_autos; - auto_list != NULL; - auto_list = auto_list->next) - auto_var (auto_list->av_name); - - /* Push pc and ibase. */ - fpush (pc.pc_func); - fpush (pc.pc_addr); - fpush (i_base); - - /* Reset pc to start of function. */ - pc.pc_func = new_func; - pc.pc_addr = 0; - break; - - case 'D' : /* Duplicate top of stack */ - push_copy (ex_stack->s_num); - break; - - case 'K' : /* Push a constant */ - /* Get the input base and convert it to a bc number. */ - if (pc.pc_func == 0) - const_base = i_base; - else - const_base = fn_stack->s_val; - if (const_base == 10) - push_b10_const (&pc); - else - push_constant (prog_char, const_base); - break; - - case 'L' : /* load array variable */ - var_name = byte(&pc); - if ((var_name & 0x80) != 0) - var_name = ((var_name << 8) & 0x7f) + byte(&pc); - load_array (var_name); - break; - - case 'M' : /* decrement array variable (Minus!) */ - var_name = byte(&pc); - if ((var_name & 0x80) != 0) - var_name = ((var_name << 8) & 0x7f) + byte(&pc); - decr_array (var_name); - break; - - case 'O' : /* Write a string to the output with processing. */ - while ((ch = byte(&pc)) != '"') - if (ch != '\\') - out_char (ch); - else - { - ch = byte(&pc); - if (ch == '"') break; - switch (ch) - { - case 'n': out_char ('\n'); break; - case 't': out_char ('\t'); break; - case 'r': out_char ('\r'); break; - case 'b': out_char (007); break; - case 'f': out_char ('\f'); break; - case '\\': out_char ('\\'); break; - default: break; - } - } - if (interactive) fflush (stdout); - break; - - case 'R' : /* Return from function */ - if (pc.pc_func != 0) - { - /* "Pop" autos and parameters. */ - pop_vars(functions[pc.pc_func].f_autos); - pop_vars(functions[pc.pc_func].f_params); - /* reset the pc. */ - fpop (); - pc.pc_addr = fpop (); - pc.pc_func = fpop (); - } - else - rt_error ("Return from main program."); - break; - - case 'S' : /* store array variable */ - var_name = byte(&pc); - if ((var_name & 0x80) != 0) - var_name = ((var_name << 8) & 0x7f) + byte(&pc); - store_array (var_name); - break; - - case 'T' : /* Test tos for zero */ - c_code = is_zero (ex_stack->s_num); - assign (c_code); - break; - - case 'W' : /* Write the value on the top of the stack. */ - case 'P' : /* Write the value on the top of the stack. No newline. */ - out_num (ex_stack->s_num, o_base, out_char); - if (inst == 'W') out_char ('\n'); - store_var (3); /* Special variable "last". */ - if (interactive) fflush (stdout); - break; - - case 'c' : /* Call special function. */ - new_func = byte(&pc); - - switch (new_func) - { - case 'L': /* Length function. */ - /* For the number 0.xxxx, 0 is not significant. */ - if (ex_stack->s_num->n_len == 1 && - ex_stack->s_num->n_scale != 0 && - ex_stack->s_num->n_value[0] == 0 ) - int2num (&ex_stack->s_num, ex_stack->s_num->n_scale); - else - int2num (&ex_stack->s_num, ex_stack->s_num->n_len - + ex_stack->s_num->n_scale); - break; - - case 'S': /* Scale function. */ - int2num (&ex_stack->s_num, ex_stack->s_num->n_scale); - break; - - case 'R': /* Square Root function. */ - if (!bc_sqrt (&ex_stack->s_num, scale)) - rt_error ("Square root of a negative number"); - break; - - case 'I': /* Read function. */ - push_constant (input_char, i_base); - break; - } - break; - - case 'd' : /* Decrement number */ - var_name = byte(&pc); - if ((var_name & 0x80) != 0) - var_name = ((var_name << 8) & 0x7f) + byte(&pc); - decr_var (var_name); - break; - - case 'h' : /* Halt the machine. */ - exit (0); - - case 'i' : /* increment number */ - var_name = byte(&pc); - if ((var_name & 0x80) != 0) - var_name = ((var_name << 8) & 0x7f) + byte(&pc); - incr_var (var_name); - break; - - case 'l' : /* load variable */ - var_name = byte(&pc); - if ((var_name & 0x80) != 0) - var_name = ((var_name << 8) & 0x7f) + byte(&pc); - load_var (var_name); - break; - - case 'n' : /* Negate top of stack. */ - bc_sub (_zero_, ex_stack->s_num, &ex_stack->s_num); - break; - - case 'p' : /* Pop the execution stack. */ - pop (); - break; - - case 's' : /* store variable */ - var_name = byte(&pc); - if ((var_name & 0x80) != 0) - var_name = ((var_name << 8) & 0x7f) + byte(&pc); - store_var (var_name); - break; - - case 'w' : /* Write a string to the output. */ - while ((ch = byte(&pc)) != '"') out_char (ch); - if (interactive) fflush (stdout); - break; - - case 'x' : /* Exchange Top of Stack with the one under the tos. */ - if (check_stack(2)) { - bc_num temp = ex_stack->s_num; - ex_stack->s_num = ex_stack->s_next->s_num; - ex_stack->s_next->s_num = temp; - } - break; - - case '0' : /* Load Constant 0. */ - push_copy (_zero_); - break; - - case '1' : /* Load Constant 0. */ - push_copy (_one_); - break; - - case '!' : /* Negate the boolean value on top of the stack. */ - c_code = is_zero (ex_stack->s_num); - assign (c_code); - break; - - case '&' : /* compare greater than */ - if (check_stack(2)) - { - c_code = !is_zero (ex_stack->s_next->s_num) - && !is_zero (ex_stack->s_num); - pop (); - assign (c_code); - } - break; - - case '|' : /* compare greater than */ - if (check_stack(2)) - { - c_code = !is_zero (ex_stack->s_next->s_num) - || !is_zero (ex_stack->s_num); - pop (); - assign (c_code); - } - break; - - case '+' : /* add */ - if (check_stack(2)) - { - bc_add (ex_stack->s_next->s_num, ex_stack->s_num, &temp_num); - pop(); - pop(); - push_num (temp_num); - init_num (&temp_num); - } - break; - - case '-' : /* subtract */ - if (check_stack(2)) - { - bc_sub (ex_stack->s_next->s_num, ex_stack->s_num, &temp_num); - pop(); - pop(); - push_num (temp_num); - init_num (&temp_num); - } - break; - - case '*' : /* multiply */ - if (check_stack(2)) - { - bc_multiply (ex_stack->s_next->s_num, ex_stack->s_num, - &temp_num, scale); - pop(); - pop(); - push_num (temp_num); - init_num (&temp_num); - } - break; - - case '/' : /* divide */ - if (check_stack(2)) - { - if (bc_divide (ex_stack->s_next->s_num, - ex_stack->s_num, &temp_num, scale) == 0) - { - pop(); - pop(); - push_num (temp_num); - init_num (&temp_num); - } - else - rt_error ("Divide by zero"); - } - break; - - case '%' : /* remainder */ - if (check_stack(2)) - { - if (is_zero (ex_stack->s_num)) - rt_error ("Modulo by zero"); - else - { - bc_modulo (ex_stack->s_next->s_num, - ex_stack->s_num, &temp_num, scale); - pop(); - pop(); - push_num (temp_num); - init_num (&temp_num); - } - } - break; - - case '^' : /* raise */ - if (check_stack(2)) - { - bc_raise (ex_stack->s_next->s_num, - ex_stack->s_num, &temp_num, scale); - if (is_zero (ex_stack->s_next->s_num) && is_neg (ex_stack->s_num)) - rt_error ("divide by zero"); - pop(); - pop(); - push_num (temp_num); - init_num (&temp_num); - } - break; - - case '=' : /* compare equal */ - if (check_stack(2)) - { - c_code = bc_compare (ex_stack->s_next->s_num, - ex_stack->s_num) == 0; - pop (); - assign (c_code); - } - break; - - case '#' : /* compare not equal */ - if (check_stack(2)) - { - c_code = bc_compare (ex_stack->s_next->s_num, - ex_stack->s_num) != 0; - pop (); - assign (c_code); - } - break; - - case '<' : /* compare less than */ - if (check_stack(2)) - { - c_code = bc_compare (ex_stack->s_next->s_num, - ex_stack->s_num) == -1; - pop (); - assign (c_code); - } - break; - - case '{' : /* compare less than or equal */ - if (check_stack(2)) - { - c_code = bc_compare (ex_stack->s_next->s_num, - ex_stack->s_num) <= 0; - pop (); - assign (c_code); - } - break; - - case '>' : /* compare greater than */ - if (check_stack(2)) - { - c_code = bc_compare (ex_stack->s_next->s_num, - ex_stack->s_num) == 1; - pop (); - assign (c_code); - } - break; - - case '}' : /* compare greater than or equal */ - if (check_stack(2)) - { - c_code = bc_compare (ex_stack->s_next->s_num, - ex_stack->s_num) >= 0; - pop (); - assign (c_code); - } - break; - - default : /* error! */ - rt_error ("bad instruction: inst=%c", inst); - } - } - - /* Clean up the function stack and pop all autos/parameters. */ - while (pc.pc_func != 0) - { - pop_vars(functions[pc.pc_func].f_autos); - pop_vars(functions[pc.pc_func].f_params); - fpop (); - pc.pc_addr = fpop (); - pc.pc_func = fpop (); - } - - /* Clean up the execution stack. */ - while (ex_stack != NULL) pop(); - - /* Clean up the interrupt stuff. */ - if (interactive) - { - signal (SIGINT, use_quit); - if (had_sigint) - printf ("Interruption completed.\n"); - } -} - - -/* Prog_char gets another byte from the program. It is used for - conversion of text constants in the code to numbers. */ - -char -prog_char () -{ - return byte(&pc); -} - - -/* Read a character from the standard input. This function is used - by the "read" function. */ - -char -input_char () -{ - char in_ch; - - /* Get a character from the standard input for the read function. */ - in_ch = getchar(); - - /* Check for a \ quoted newline. */ - if (in_ch == '\\') - { - in_ch = getchar(); - if (in_ch == '\n') - in_ch = getchar(); - } - - /* Classify and preprocess the input character. */ - if (isdigit(in_ch)) - return (in_ch - '0'); - if (in_ch >= 'A' && in_ch <= 'F') - return (in_ch + 10 - 'A'); - if (in_ch >= 'a' && in_ch <= 'f') - return (in_ch + 10 - 'a'); - if (in_ch == '.' || in_ch == '+' || in_ch == '-') - return (in_ch); - if (in_ch <= ' ') - return (' '); - - return (':'); -} - - -/* Push_constant converts a sequence of input characters as returned - by IN_CHAR into a number. The number is pushed onto the execution - stack. The number is converted as a number in base CONV_BASE. */ - -void -push_constant (in_char, conv_base) - char (*in_char)(VOID); - int conv_base; -{ - int digits; - bc_num build, temp, result, mult, divisor; - char in_ch, first_ch; - char negative; - - /* Initialize all bc numbers */ - init_num (&temp); - init_num (&result); - init_num (&mult); - build = copy_num (_zero_); - negative = FALSE; - - /* The conversion base. */ - int2num (&mult, conv_base); - - /* Get things ready. */ - in_ch = in_char(); - while (in_ch == ' ') - in_ch = in_char(); - - if (in_ch == '+') - in_ch = in_char(); - else - if (in_ch == '-') - { - negative = TRUE; - in_ch = in_char(); - } - - /* Check for the special case of a single digit. */ - if (in_ch < 16) - { - first_ch = in_ch; - in_ch = in_char(); - if (in_ch < 16 && first_ch >= conv_base) - first_ch = conv_base - 1; - int2num (&build, (int) first_ch); - } - - /* Convert the integer part. */ - while (in_ch < 16) - { - if (in_ch < 16 && in_ch >= conv_base) in_ch = conv_base-1; - bc_multiply (build, mult, &result, 0); - int2num (&temp, (int) in_ch); - bc_add (result, temp, &build); - in_ch = in_char(); - } - if (in_ch == '.') - { - in_ch = in_char(); - if (in_ch >= conv_base) in_ch = conv_base-1; - free_num (&result); - free_num (&temp); - divisor = copy_num (_one_); - result = copy_num (_zero_); - digits = 0; - while (in_ch < 16) - { - bc_multiply (result, mult, &result, 0); - int2num (&temp, (int) in_ch); - bc_add (result, temp, &result); - bc_multiply (divisor, mult, &divisor, 0); - digits++; - in_ch = in_char(); - if (in_ch < 16 && in_ch >= conv_base) in_ch = conv_base-1; - } - bc_divide (result, divisor, &result, digits); - bc_add (build, result, &build); - } - - /* Final work. */ - if (negative) - bc_sub (_zero_, build, &build); - - push_num (build); - free_num (&temp); - free_num (&result); - free_num (&mult); -} - - -/* When converting base 10 constants from the program, we use this - more efficient way to convert them to numbers. PC tells where - the constant starts and is expected to be advanced to after - the constant. */ - -void -push_b10_const (pc) - program_counter *pc; -{ - bc_num build; - program_counter look_pc; - int kdigits, kscale; - char inchar; - char *ptr; - - /* Count the digits and get things ready. */ - look_pc = *pc; - kdigits = 0; - kscale = 0; - inchar = byte (&look_pc); - while (inchar != '.' && inchar != ':') - { - kdigits++; - inchar = byte(&look_pc); - } - if (inchar == '.' ) - { - inchar = byte(&look_pc); - while (inchar != ':') - { - kscale++; - inchar = byte(&look_pc); - } - } - - /* Get the first character again and move the pc. */ - inchar = byte(pc); - - /* Secial cases of 0, 1, and A-F single inputs. */ - if (kdigits == 1 && kscale == 0) - { - if (inchar == 0) - { - push_copy (_zero_); - inchar = byte(pc); - return; - } - if (inchar == 1) { - push_copy (_one_); - inchar = byte(pc); - return; - } - if (inchar > 9) - { - init_num (&build); - int2num (&build, inchar); - push_num (build); - inchar = byte(pc); - return; - } - } - - /* Build the new number. */ - if (kdigits == 0) - { - build = new_num (1,kscale); - ptr = build->n_value; - *ptr++ = 0; - } - else - { - build = new_num (kdigits,kscale); - ptr = build->n_value; - } - - while (inchar != ':') - { - if (inchar != '.') - if (inchar > 9) - *ptr++ = 9; - else - *ptr++ = inchar; - inchar = byte(pc); - } - push_num (build); -} - - -/* Put the correct value on the stack for C_CODE. Frees TOS num. */ - -void -assign (c_code) - char c_code; -{ - free_num (&ex_stack->s_num); - if (c_code) - ex_stack->s_num = copy_num (_one_); - else - ex_stack->s_num = copy_num (_zero_); -} diff --git a/gnu/usr.bin/bc-1.02/fix_math.h b/gnu/usr.bin/bc-1.02/fix_math.h deleted file mode 100644 index 020e4112df50..000000000000 --- a/gnu/usr.bin/bc-1.02/fix_math.h +++ /dev/null @@ -1,8 +0,0 @@ -ed math.h < 1) { - f += 1; - x /= 2; - } - - /* Initialize the variables. */ - v = 1+x - a = x - d = 1 - - for (i=2; 1; i++) { - e = (a *= x) / (d *= i) - if (e == 0) { - if (f>0) while (f--) v = v*v; - scale = z - if (m) return (1/v); - return (v/1); - } - v += e - } -} - -/* Natural log. Uses the fact that ln(x^2) = 2*ln(x) - The series used is: - ln(x) = 2(a+a^3/3+a^5/5+...) where a=(x-1)/(x+1) -*/ - -define l(x) { - auto e, f, i, m, n, v, z - - /* return something for the special case. */ - if (x <= 0) return (1 - 10^scale) - - /* Precondition x to make .5 < x < 2.0. */ - z = scale; - scale += 4; - f = 2; - i=0 - while (x >= 2) { /* for large numbers */ - f *= 2; - x = sqrt(x); - } - while (x <= .5) { /* for small numbers */ - f *= 2; - x = sqrt(x); - } - - /* Set up the loop. */ - v = n = (x-1)/(x+1) - m = n*n - - /* Sum the series. */ - for (i=3; 1; i+=2) { - e = (n *= m) / i - if (e == 0) { - v = f*v - scale = z - return (v/1) - } - v += e - } -} - -/* Sin(x) uses the standard series: - sin(x) = x - x^3/3! + x^5/5! - x^7/7! ... */ - -define s(x) { - auto e, i, m, n, s, v, z - - /* precondition x. */ - z = scale - scale = 1.1*z + 1; - v = a(1) - if (x < 0) { - m = 1; - x = -x; - } - scale = 0 - n = (x / v + 2 )/4 - x = x - 4*n*v - if (n%2) x = -x - - /* Do the loop. */ - scale = z + 2; - v = e = x - s = -x*x - for (i=3; 1; i+=2) { - e *= s/(i*(i-1)) - if (e == 0) { - scale = z - if (m) return (-v/1); - return (v/1); - } - v += e - } -} - -/* Cosine : cos(x) = sin(x+pi/2) */ -define c(x) { - auto v; - scale += 1; - v = s(x+a(1)*2); - scale -= 1; - return (v/1); -} - -/* Arctan: Using the formula: - atan(x) = atan(c) + atan((x-c)/(1+xc)) for a small c (.2 here) - For under .2, use the series: - atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ... */ - -define a(x) { - auto a, e, f, i, m, n, s, v, z - - /* Special case and for fast answers */ - if (x==1) { - if (scale <= 25) return (.7853981633974483096156608/1) - if (scale <= 40) return (.7853981633974483096156608458198757210492/1) - if (scale <= 60) \ - return (.785398163397448309615660845819875721049292349843776455243736/1) - } - if (x==.2) { - if (scale <= 25) return (.1973955598498807583700497/1) - if (scale <= 40) return (.1973955598498807583700497651947902934475/1) - if (scale <= 60) \ - return (.197395559849880758370049765194790293447585103787852101517688/1) - } - - /* Negative x? */ - if (x<0) { - m = 1; - x = -x; - } - - /* Save the scale. */ - z = scale; - - /* Note: a and f are known to be zero due to being auto vars. */ - /* Calculate atan of a known number. */ - if (x > .2) { - scale = z+4; - a = a(.2); - } - - /* Precondition x. */ - scale = z+2; - while (x > .2) { - f += 1; - x = (x-.2) / (1+x*.2); - } - - /* Initialize the series. */ - v = n = x; - s = -x*x; - - /* Calculate the series. */ - for (i=3; 1; i+=2) { - e = (n *= s) / i; - if (e == 0) { - scale = z; - if (m) return ((f*a+v)/-1); - return ((f*a+v)/1); - } - v += e - } -} - - -/* Bessel function of integer order. Uses the following: - j(-n,x) = (-1)^n*j(n,x) - j(n,x) = x^n/(2^n*n!) * (1 - x^2/(2^2*1!*(n+1)) + x^4/(2^4*2!*(n+1)*(n+2)) - - x^6/(2^6*3!*(n+1)*(n+2)*(n+3)) .... ) -*/ -define j(n,x) { - auto a, d, e, f, i, m, s, v, z - - /* Make n an integer and check for negative n. */ - z = scale; - scale = 0; - n = n/1; - if (n<0) { - n = -n; - if (n%2 == 1) m = 1; - } - - /* Compute the factor of x^n/(2^n*n!) */ - f = 1; - for (i=2; i<=n; i++) f = f*i; - scale = 1.5*z; - f = x^n / 2^n / f; - - /* Initialize the loop .*/ - v = e = 1; - s = -x*x/4 - scale = 1.5*z - - /* The Loop.... */ - for (i=1; 1; i++) { - e = e * s / i / (n+i); - if (e == 0) { - scale = z - if (m) return (-f*v/1); - return (f*v/1); - } - v += e; - } -} diff --git a/gnu/usr.bin/bc-1.02/load.c b/gnu/usr.bin/bc-1.02/load.c deleted file mode 100644 index be4ab3a52160..000000000000 --- a/gnu/usr.bin/bc-1.02/load.c +++ /dev/null @@ -1,333 +0,0 @@ -/* load.c: This code "loads" code into the code segments. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -#include "bcdefs.h" -#include "global.h" -#include "proto.h" - -/* Load variables. */ - -program_counter load_adr; -char load_str; -char load_const; - -/* Initialize the load sequence. */ -void -init_load () -{ - clear_func(0); - load_adr.pc_func = 0; - load_adr.pc_addr = 0; - load_str = FALSE; - load_const = FALSE; -} - -/* addbyte adds one BYTE to the current code segment. */ -void -addbyte (byte) - char byte; -{ - int seg, offset, func; - - /* If there was an error, don't continue. */ - if (had_error) return; - - /* Calculate the segment and offset. */ - seg = load_adr.pc_addr >> BC_SEG_LOG; - offset = load_adr.pc_addr++ % BC_SEG_SIZE; - func = load_adr.pc_func; - - if (seg >= BC_MAX_SEGS) - { - yyerror ("Function too big."); - return; - } - - if (functions[func].f_body[seg] == NULL) - functions[func].f_body[seg] = (char *) bc_malloc (BC_SEG_SIZE); - - /* Store the byte. */ - functions[func].f_body[seg][offset] = byte; - functions[func].f_code_size++; -} - - -/* Define a label LAB to be the current program counter. */ - -void -def_label (lab) - long lab; -{ - bc_label_group *temp; - int group, offset, func; - - /* Get things ready. */ - group = lab >> BC_LABEL_LOG; - offset = lab % BC_LABEL_GROUP; - func = load_adr.pc_func; - - /* Make sure there is at least one label group. */ - if (functions[func].f_label == NULL) - { - functions[func].f_label = - (bc_label_group *) bc_malloc (sizeof(bc_label_group)); - functions[func].f_label->l_next = NULL; - } - - /* Add the label group. */ - temp = functions[func].f_label; - while (group > 0) - { - if (temp->l_next == NULL) - { - temp->l_next = (bc_label_group *) bc_malloc (sizeof(bc_label_group)); - temp->l_next->l_next = NULL; - } - temp = temp->l_next; - group --; - } - - /* Define it! */ - temp->l_adrs [offset] = load_adr.pc_addr; -} - -/* Several instructions have integers in the code. They - are all known to be legal longs. So, no error code - is added. STR is the pointer to the load string and - must be moved to the last non-digit character. */ - -long -long_val (str) - char **str; -{ int val = 0; - char neg = FALSE; - - if (**str == '-') - { - neg = TRUE; - (*str)++; - } - while (isdigit(**str)) - val = val*10 + *(*str)++ - '0'; - - if (neg) - return -val; - else - return val; -} - - -/* load_code loads the CODE into the machine. */ - -void -load_code (code) - char *code; -{ - char *str; - long ap_name; /* auto or parameter name. */ - long label_no; - long vaf_name; /* variable, array or function number. */ - long func; - program_counter save_adr; - - /* Initialize. */ - str = code; - - /* Scan the code. */ - while (*str != 0) - { - /* If there was an error, don't continue. */ - if (had_error) return; - - if (load_str) - { - if (*str == '"') load_str = FALSE; - addbyte (*str++); - } - else - if (load_const) - { - if (*str == '\n') - str++; - else - { - if (*str == ':') - { - load_const = FALSE; - addbyte (*str++); - } - else - if (*str == '.') - addbyte (*str++); - else - if (*str >= 'A') - addbyte (*str++ + 10 - 'A'); - else - addbyte (*str++ - '0'); - } - } - else - { - switch (*str) - { - - case '"': /* Starts a string. */ - load_str = TRUE; - break; - - case 'N': /* A label */ - str++; - label_no = long_val (&str); - def_label (label_no); - break; - - case 'B': /* Branch to label. */ - case 'J': /* Jump to label. */ - case 'Z': /* Branch Zero to label. */ - addbyte(*str++); - label_no = long_val (&str); - if (label_no > 65535L) - { /* Better message? */ - fprintf (stderr,"Program too big.\n"); - exit(1); - } - addbyte ( (char) label_no & 0xFF); - addbyte ( (char) label_no >> 8); - break; - - case 'F': /* A function, get the name and initialize it. */ - str++; - func = long_val (&str); - clear_func (func); -#if DEBUG > 2 - printf ("Loading function number %d\n", func); -#endif - /* get the parameters */ - while (*str++ != '.') - { - if (*str == '.') - { - str++; - break; - } - ap_name = long_val (&str); -#if DEBUG > 2 - printf ("parameter number %d\n", ap_name); -#endif - functions[(int)func].f_params = - nextarg (functions[(int)func].f_params, ap_name); - } - - /* get the auto vars */ - while (*str != '[') - { - if (*str == ',') str++; - ap_name = long_val (&str); -#if DEBUG > 2 - printf ("auto number %d\n", ap_name); -#endif - functions[(int)func].f_autos = - nextarg (functions[(int)func].f_autos, ap_name); - } - save_adr = load_adr; - load_adr.pc_func = func; - load_adr.pc_addr = 0; - break; - - case ']': /* A function end */ - functions[load_adr.pc_func].f_defined = TRUE; - load_adr = save_adr; - break; - - case 'C': /* Call a function. */ - addbyte (*str++); - func = long_val (&str); - if (func < 128) - addbyte ( (char) func); - else - { - addbyte ((func >> 8) & 0xff | 0x80); - addbyte (func & 0xff); - } - if (*str == ',') str++; - while (*str != ':') - addbyte (*str++); - addbyte (':'); - break; - - case 'c': /* Call a special function. */ - addbyte (*str++); - addbyte (*str); - break; - - case 'K': /* A constant.... may have an "F" in it. */ - addbyte (*str); - load_const = TRUE; - break; - - case 'd': /* Decrement. */ - case 'i': /* Increment. */ - case 'l': /* Load. */ - case 's': /* Store. */ - case 'A': /* Array Increment */ - case 'M': /* Array Decrement */ - case 'L': /* Array Load */ - case 'S': /* Array Store */ - addbyte (*str++); - vaf_name = long_val (&str); - if (vaf_name < 128) - addbyte (vaf_name); - else - { - addbyte ((vaf_name >> 8) & 0xff | 0x80); - addbyte (vaf_name & 0xff); - } - break; - - case '@': /* A command! */ - switch (*(++str)) - { - case 'i': - init_load (); - break; - case 'r': - execute (); - break; - } - break; - - case '\n': /* Ignore the newlines */ - break; - - default: /* Anything else */ - addbyte (*str); - } - str++; - } - } -} diff --git a/gnu/usr.bin/bc-1.02/main.c b/gnu/usr.bin/bc-1.02/main.c deleted file mode 100644 index 33827cc84b88..000000000000 --- a/gnu/usr.bin/bc-1.02/main.c +++ /dev/null @@ -1,204 +0,0 @@ -/* main.c: The main program for bc. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -#include "bcdefs.h" -#include -#include "global.h" -#include "proto.h" - -/* Variables for processing multiple files. */ -char first_file; -extern FILE *yyin; - - -/* The main program for bc. */ -int -main (argc, argv) - int argc; - char *argv[]; -{ - int ch; - - /* Initialize many variables. */ - compile_only = FALSE; - use_math = FALSE; - warn_not_std = FALSE; - std_only = FALSE; - if (isatty(0) && isatty(1)) - interactive = TRUE; - else - interactive = FALSE; - - /* Parse the command line */ - ch = getopt (argc, argv, "lcisvw"); - while (ch != EOF) - { - switch (ch) - { - case 'c': /* compile only */ - compile_only = TRUE; - break; - case 'l': /* math lib */ - use_math = TRUE; - break; - case 'i': /* force interactive */ - interactive = TRUE; - break; - case 'w': /* Non standard features give warnings. */ - warn_not_std = TRUE; - break; - case 's': /* Non standard features give errors. */ - std_only = TRUE; - break; - case 'v': /* Print the version. */ - printf ("%s\n", BC_VERSION); - break; - } - ch = getopt (argc, argv, "lcisvw"); - } - - /* Initialize the machine. */ - init_storage(); - init_load(); - - /* Set up interrupts to print a message. */ - if (interactive) - signal (SIGINT, use_quit); - - /* Initialize the front end. */ - init_tree(); - init_gen (); - g_argv = argv; - g_argc = argc; - is_std_in = FALSE; - first_file = TRUE; - if (!open_new_file ()) - exit (1); - - /* Do the parse. */ - yyparse (); - - /* End the compile only output with a newline. */ - if (compile_only) - printf ("\n"); - - exit (0); -} - - -/* This is the function that opens all the files. - It returns TRUE if the file was opened, otherwise - it returns FALSE. */ - -int -open_new_file () -{ - FILE *new_file; - - /* Set the line number. */ - line_no = 1; - - /* Check to see if we are done. */ - if (is_std_in) return (FALSE); - - /* Open the other files. */ - if (use_math && first_file) - { -#ifdef BC_MATH_FILE - /* Make the first file be the math library. */ - new_file = fopen (BC_MATH_FILE, "r"); - use_math = FALSE; - if (new_file != NULL) - { - new_yy_file (new_file); - return TRUE; - } - else - { - fprintf (stderr, "Math Library unavailable.\n"); - exit (1); - } -#else - /* Load the code from a precompiled version of the math libarary. */ - extern char libmath[]; - char tmp; - /* These MUST be in the order of first mention of each function. - That is why "a" comes before "c" even though "a" is defined after - after "c". "a" is used in "s"! */ - tmp = lookup ("e", FUNCT); - tmp = lookup ("l", FUNCT); - tmp = lookup ("s", FUNCT); - tmp = lookup ("a", FUNCT); - tmp = lookup ("c", FUNCT); - tmp = lookup ("j", FUNCT); - load_code (libmath); -#endif - } - - /* One of the argv values. */ - while (optind < g_argc) - { - new_file = fopen (g_argv[optind], "r"); - if (new_file != NULL) - { - new_yy_file (new_file); - optind++; - return TRUE; - } - fprintf (stderr, "File %s is unavailable.\n", g_argv[optind++]); - exit (1); - } - - /* If we fall through to here, we should return stdin. */ - new_yy_file (stdin); - is_std_in = TRUE; - return TRUE; -} - - -/* Set yyin to the new file. */ - -void -new_yy_file (file) - FILE *file; -{ - if (!first_file) fclose (yyin); - yyin = file; - first_file = FALSE; -} - - -/* Message to use quit. */ - -void -use_quit (sig) - int sig; -{ - printf ("\n(interrupt) use quit to exit.\n"); - signal (SIGINT, use_quit); -} diff --git a/gnu/usr.bin/bc-1.02/math.h b/gnu/usr.bin/bc-1.02/math.h deleted file mode 100644 index a1fc146c3a9f..000000000000 --- a/gnu/usr.bin/bc-1.02/math.h +++ /dev/null @@ -1,40 +0,0 @@ -"@iK20:s2:p@r\ -@iF1,4.5,6,7,8,9,10,11,12[l4:0Z2:l8:1+s8:pl4:K2:/s4:pJ1:N2:1l4:\ -+s11:pl4:s5:p1s6:pK2:s9:pN4:1B5:J3:N6:l9:i9:pJ4:N5:l5:l4:*s5:\ -l6:l9:*s6:/s7:pl7:0=Z7:l8:0>Z8:N9:l8:d8:Z10:l11:l11:*s11:pJ9:N10:\ -N8:l12:s2:pl10:Z11:1l11:/RN11:l11:1/RN7:l11:l7:+s11:pJ6:N3:0R]\ -@r\ -@iF2,4.7,8,9,10,13,11,12[l4:0{Z0:1K10:l2:^-RN0:l2:s12:pl2:K4:\ -+s2:pK2:s8:p0s9:pN1:l4:K2:}Z2:l8:K2:*s8:pl4:cRs4:pJ1:N2:N3:l4:\ -K.5:{Z4:l8:K2:*s8:pl4:cRs4:pJ3:N4:l4:1-l4:1+/s13:s11:pl13:l13:\ -*s10:pK3:s9:pN6:1B7:J5:N8:l9:K2:+s9:pJ6:N7:l13:l10:*s13:l9:/s7:\ -pl7:0=Z9:l8:l11:*s11:pl12:s2:pl11:1/RN9:l11:l7:+s11:pJ8:N5:0R]\ -@r\ -@iF3,4.7,9,10,13,14,11,12[l2:s12:pK1.1:l12:*1+s2:p1C4,0:s11:p\ -l4:0Z9:l12:K4:\ -+s2:pK.2:C4,0:s5:pN9:l12:K2:+s2:pN10:l4:K.2:>Z11:l8:1+s8:pl4:\ -K.2:-1l4:K.2:*+/s4:pJ10:N11:l4:s13:s11:pl4:nl4:*s14:pK3:s9:pN13:\ -1B14:J12:N15:l9:K2:+s9:pJ13:N14:l13:l14:*s13:l9:/s7:pl7:0=Z16:\ -l12:s2:pl10:Z17:l8:l5:*l11:+1n/RN17:l8:l5:*l11:+1/RN16:l11:l7:\ -+s11:pJ15:N12:0R]@r\ -@iF6,13,4.5,6,7,8,9,10,14,11,12[l2:s12:p0s2:pl13:1/s13:pl13:0\ -n_refs--; - if ((*num)->n_refs == 0) free(*num); - *num = NULL; -} - - -/* new_num allocates a number and sets fields to known values. */ - -bc_num -new_num (length, scale) - int length, scale; -{ - bc_num temp; - - temp = (bc_num) malloc (sizeof(bc_struct)+length+scale); - if (temp == NULL) out_of_memory (); - temp->n_sign = PLUS; - temp->n_len = length; - temp->n_scale = scale; - temp->n_refs = 1; - temp->n_value[0] = 0; - return temp; -} - - -/* Intitialize the number package! */ - -void -init_numbers () -{ - _zero_ = new_num (1,0); - _one_ = new_num (1,0); - _one_->n_value[0] = 1; - _two_ = new_num (1,0); - _two_->n_value[0] = 2; -} - - -/* Make a copy of a number! Just increments the reference count! */ - -bc_num -copy_num (num) - bc_num num; -{ - num->n_refs++; - return num; -} - - -/* Initialize a number NUM by making it a copy of zero. */ - -void -init_num (num) - bc_num *num; -{ - *num = copy_num (_zero_); -} - - -/* Convert an integer VAL to a bc number NUM. */ - -void -int2num (num, val) - bc_num *num; - int val; -{ - char buffer[30]; - char *bptr, *vptr; - int ix = 1; - char neg = 0; - - /* Sign. */ - if (val < 0) - { - neg = 1; - val = -val; - } - - /* Get things going. */ - bptr = buffer; - *bptr++ = val % 10; - val = val / 10; - - /* Extract remaining digits. */ - while (val != 0) - { - *bptr++ = val % 10; - val = val / 10; - ix++; /* Count the digits. */ - } - - /* Make the number. */ - free_num (num); - *num = new_num (ix, 0); - if (neg) (*num)->n_sign = MINUS; - - /* Assign the digits. */ - vptr = (*num)->n_value; - while (ix-- > 0) - *vptr++ = *--bptr; -} - - -/* Convert a number NUM to a long. The function returns only the integer - part of the number. For numbers that are too large to represent as - a long, this function returns a zero. This can be detected by checking - the NUM for zero after having a zero returned. */ - -long -num2long (num) - bc_num num; -{ - long val; - char *nptr; - int index; - - /* Extract the int value, ignore the fraction. */ - val = 0; - nptr = num->n_value; - for (index=num->n_len; (index>0) && (val<=(LONG_MAX/10)); index--) - val = val*10 + *nptr++; - - /* Check for overflow. If overflow, return zero. */ - if (index>0) val = 0; - if (val < 0) val = 0; - - /* Return the value. */ - if (num->n_sign == PLUS) - return (val); - else - return (-val); -} - - -/* The following are some math routines for numbers. */ -_PROTOTYPE(static int _do_compare, (bc_num n1, bc_num n2, int use_sign, - int ignore_last)); -_PROTOTYPE(static void _rm_leading_zeros, (bc_num num)); -_PROTOTYPE(static bc_num _do_add, (bc_num n1, bc_num n2)); -_PROTOTYPE(static bc_num _do_sub, (bc_num n1, bc_num n2)); -_PROTOTYPE(static void _one_mult, (unsigned char *num, int size, int digit, - unsigned char *result)); - - - -/* Compare two bc numbers. Return value is 0 if equal, -1 if N1 is less - than N2 and +1 if N1 is greater than N2. If USE_SIGN is false, just - compare the magnitudes. */ - -static int -_do_compare (n1, n2, use_sign, ignore_last) - bc_num n1, n2; - int use_sign; - int ignore_last; -{ - char *n1ptr, *n2ptr; - int count; - - /* First, compare signs. */ - if (use_sign && n1->n_sign != n2->n_sign) - { - if (n1->n_sign == PLUS) - return (1); /* Positive N1 > Negative N2 */ - else - return (-1); /* Negative N1 < Positive N1 */ - } - - /* Now compare the magnitude. */ - if (n1->n_len != n2->n_len) - { - if (n1->n_len > n2->n_len) - { - /* Magnitude of n1 > n2. */ - if (!use_sign || n1->n_sign == PLUS) - return (1); - else - return (-1); - } - else - { - /* Magnitude of n1 < n2. */ - if (!use_sign || n1->n_sign == PLUS) - return (-1); - else - return (1); - } - } - - /* If we get here, they have the same number of integer digits. - check the integer part and the equal length part of the fraction. */ - count = n1->n_len + MIN (n1->n_scale, n2->n_scale); - n1ptr = n1->n_value; - n2ptr = n2->n_value; - - while ((count > 0) && (*n1ptr == *n2ptr)) - { - n1ptr++; - n2ptr++; - count--; - } - if (ignore_last && count == 1 && n1->n_scale == n2->n_scale) - return (0); - if (count != 0) - { - if (*n1ptr > *n2ptr) - { - /* Magnitude of n1 > n2. */ - if (!use_sign || n1->n_sign == PLUS) - return (1); - else - return (-1); - } - else - { - /* Magnitude of n1 < n2. */ - if (!use_sign || n1->n_sign == PLUS) - return (-1); - else - return (1); - } - } - - /* They are equal up to the last part of the equal part of the fraction. */ - if (n1->n_scale != n2->n_scale) - if (n1->n_scale > n2->n_scale) - { - for (count = n1->n_scale-n2->n_scale; count>0; count--) - if (*n1ptr++ != 0) - { - /* Magnitude of n1 > n2. */ - if (!use_sign || n1->n_sign == PLUS) - return (1); - else - return (-1); - } - } - else - { - for (count = n2->n_scale-n1->n_scale; count>0; count--) - if (*n2ptr++ != 0) - { - /* Magnitude of n1 < n2. */ - if (!use_sign || n1->n_sign == PLUS) - return (-1); - else - return (1); - } - } - - /* They must be equal! */ - return (0); -} - - -/* This is the "user callable" routine to compare numbers N1 and N2. */ - -int -bc_compare (n1, n2) - bc_num n1, n2; -{ - return _do_compare (n1, n2, TRUE, FALSE); -} - - -/* In some places we need to check if the number NUM is zero. */ - -char -is_zero (num) - bc_num num; -{ - int count; - char *nptr; - - /* Quick check. */ - if (num == _zero_) return TRUE; - - /* Initialize */ - count = num->n_len + num->n_scale; - nptr = num->n_value; - - /* The check */ - while ((count > 0) && (*nptr++ == 0)) count--; - - if (count != 0) - return FALSE; - else - return TRUE; -} - - -/* In some places we need to check if the number is negative. */ - -char -is_neg (num) - bc_num num; -{ - return num->n_sign == MINUS; -} - - -/* For many things, we may have leading zeros in a number NUM. - _rm_leading_zeros just moves the data to the correct - place and adjusts the length. */ - -static void -_rm_leading_zeros (num) - bc_num num; -{ - int bytes; - char *dst, *src; - - /* Do a quick check to see if we need to do it. */ - if (*num->n_value != 0) return; - - /* The first digit is 0, find the first non-zero digit in the 10's or - greater place. */ - bytes = num->n_len; - src = num->n_value; - while (bytes > 1 && *src == 0) src++, bytes--; - num->n_len = bytes; - bytes += num->n_scale; - dst = num->n_value; - while (bytes-- > 0) *dst++ = *src++; - -} - - -/* Perform addition: N1 is added to N2 and the value is - returned. The signs of N1 and N2 are ignored. */ - -static bc_num -_do_add (n1, n2) - bc_num n1, n2; -{ - bc_num sum; - int sum_scale, sum_digits; - char *n1ptr, *n2ptr, *sumptr; - int carry, n1bytes, n2bytes; - - /* Prepare sum. */ - sum_scale = MAX (n1->n_scale, n2->n_scale); - sum_digits = MAX (n1->n_len, n2->n_len) + 1; - sum = new_num (sum_digits,sum_scale); - - /* Start with the fraction part. Initialize the pointers. */ - n1bytes = n1->n_scale; - n2bytes = n2->n_scale; - n1ptr = (char *) (n1->n_value + n1->n_len + n1bytes - 1); - n2ptr = (char *) (n2->n_value + n2->n_len + n2bytes - 1); - sumptr = (char *) (sum->n_value + sum_scale + sum_digits - 1); - - /* Add the fraction part. First copy the longer fraction.*/ - if (n1bytes != n2bytes) - { - if (n1bytes > n2bytes) - while (n1bytes>n2bytes) - { *sumptr-- = *n1ptr--; n1bytes--;} - else - while (n2bytes>n1bytes) - { *sumptr-- = *n2ptr--; n2bytes--;} - } - - /* Now add the remaining fraction part and equal size integer parts. */ - n1bytes += n1->n_len; - n2bytes += n2->n_len; - carry = 0; - while ((n1bytes > 0) && (n2bytes > 0)) - { - *sumptr = *n1ptr-- + *n2ptr-- + carry; - if (*sumptr > 9) - { - carry = 1; - *sumptr -= 10; - } - else - carry = 0; - sumptr--; - n1bytes--; - n2bytes--; - } - - /* Now add carry the longer integer part. */ - if (n1bytes == 0) - { n1bytes = n2bytes; n1ptr = n2ptr; } - while (n1bytes-- > 0) - { - *sumptr = *n1ptr-- + carry; - if (*sumptr > 9) - { - carry = 1; - *sumptr -= 10; - } - else - carry = 0; - sumptr--; - } - - /* Set final carry. */ - if (carry == 1) - *sumptr += 1; - - /* Adjust sum and return. */ - _rm_leading_zeros (sum); - return sum; -} - - -/* Perform subtraction: N2 is subtracted from N1 and the value is - returned. The signs of N1 and N2 are ignored. Also, N1 is - assumed to be larger than N2. */ - -static bc_num -_do_sub (n1, n2) - bc_num n1, n2; -{ - bc_num diff; - int diff_scale, diff_len; - int min_scale, min_len; - char *n1ptr, *n2ptr, *diffptr; - int borrow, count, val; - - /* Allocate temporary storage. */ - diff_len = MAX (n1->n_len, n2->n_len); - diff_scale = MAX (n1->n_scale, n2->n_scale); - min_len = MIN (n1->n_len, n2->n_len); - min_scale = MIN (n1->n_scale, n2->n_scale); - diff = new_num (diff_len, diff_scale); - - /* Initialize the subtract. */ - n1ptr = (char *) (n1->n_value + n1->n_len + n1->n_scale -1); - n2ptr = (char *) (n2->n_value + n2->n_len + n2->n_scale -1); - diffptr = (char *) (diff->n_value + diff_len + diff_scale -1); - - /* Subtract the numbers. */ - borrow = 0; - - /* Take care of the longer scaled number. */ - if (n1->n_scale != min_scale) - { - /* n1 has the longer scale */ - for (count = n1->n_scale - min_scale; count > 0; count--) - *diffptr-- = *n1ptr--; - } - else - { - /* n2 has the longer scale */ - for (count = n2->n_scale - min_scale; count > 0; count--) - { - val = - *n2ptr-- - borrow; - if (val < 0) - { - val += 10; - borrow = 1; - } - else - borrow = 0; - *diffptr-- = val; - } - } - - /* Now do the equal length scale and integer parts. */ - - for (count = 0; count < min_len + min_scale; count++) - { - val = *n1ptr-- - *n2ptr-- - borrow; - if (val < 0) - { - val += 10; - borrow = 1; - } - else - borrow = 0; - *diffptr-- = val; - } - - /* If n1 has more digits then n2, we now do that subtract. */ - if (diff_len != min_len) - { - for (count = diff_len - min_len; count > 0; count--) - { - val = *n1ptr-- - borrow; - if (val < 0) - { - val += 10; - borrow = 1; - } - else - borrow = 0; - *diffptr-- = val; - } - } - - /* Clean up and return. */ - _rm_leading_zeros (diff); - return diff; -} - - -/* Here is the full add routine that takes care of negative numbers. - N1 is added to N2 and the result placed into RESULT. */ - -void -bc_add ( n1, n2, result) - bc_num n1, n2, *result; -{ - bc_num sum; - int cmp_res; - - if (n1->n_sign == n2->n_sign) - { - sum = _do_add (n1, n2); - sum->n_sign = n1->n_sign; - } - else - { - /* subtraction must be done. */ - cmp_res = _do_compare (n1, n2, FALSE, FALSE); /* Compare magnitudes. */ - switch (cmp_res) - { - case -1: - /* n1 is less than n2, subtract n1 from n2. */ - sum = _do_sub (n2, n1); - sum->n_sign = n2->n_sign; - break; - case 0: - /* They are equal! return zero! */ - sum = copy_num (_zero_); - break; - case 1: - /* n2 is less than n1, subtract n2 from n1. */ - sum = _do_sub (n1, n2); - sum->n_sign = n1->n_sign; - } - } - - /* Clean up and return. */ - free_num (result); - *result = sum; -} - - -/* Here is the full subtract routine that takes care of negative numbers. - N2 is subtracted from N1 and the result placed in RESULT. */ - -void -bc_sub ( n1, n2, result) - bc_num n1, n2, *result; -{ - bc_num diff; - int cmp_res; - - if (n1->n_sign != n2->n_sign) - { - diff = _do_add (n1, n2); - diff->n_sign = n1->n_sign; - } - else - { - /* subtraction must be done. */ - cmp_res = _do_compare (n1, n2, FALSE, FALSE); /* Compare magnitudes. */ - switch (cmp_res) - { - case -1: - /* n1 is less than n2, subtract n1 from n2. */ - diff = _do_sub (n2, n1); - diff->n_sign = (n2->n_sign == PLUS ? MINUS : PLUS); - break; - case 0: - /* They are equal! return zero! */ - diff = copy_num (_zero_); - break; - case 1: - /* n2 is less than n1, subtract n2 from n1. */ - diff = _do_sub (n1, n2); - diff->n_sign = n1->n_sign; - break; - } - } - - /* Clean up and return. */ - free_num (result); - *result = diff; -} - - -/* The multiply routine. N2 time N1 is put int PROD with the scale of - the result being MIN(N2 scale+N1 scale, MAX (SCALE, N2 scale, N1 scale)). - */ - -void -bc_multiply (n1, n2, prod, scale) - bc_num n1, n2, *prod; - int scale; -{ - bc_num pval; /* For the working storage. */ - char *n1ptr, *n2ptr, *pvptr; /* Work pointers. */ - char *n1end, *n2end; /* To the end of n1 and n2. */ - - int indx; - int len1, len2, total_digits; - long sum; - int full_scale, prod_scale; - int toss; - - /* Initialize things. */ - len1 = n1->n_len + n1->n_scale; - len2 = n2->n_len + n2->n_scale; - total_digits = len1 + len2; - full_scale = n1->n_scale + n2->n_scale; - prod_scale = MIN(full_scale,MAX(scale,MAX(n1->n_scale,n2->n_scale))); - toss = full_scale - prod_scale; - pval = new_num (total_digits-full_scale, prod_scale); - pval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS ); - n1end = (char *) (n1->n_value + len1 - 1); - n2end = (char *) (n2->n_value + len2 - 1); - pvptr = (char *) (pval->n_value + total_digits - toss - 1); - sum = 0; - - /* Here are the loops... */ - for (indx = 0; indx < toss; indx++) - { - n1ptr = (char *) (n1end - MAX(0, indx-len2+1)); - n2ptr = (char *) (n2end - MIN(indx, len2-1)); - while ((n1ptr >= n1->n_value) && (n2ptr <= n2end)) - sum += *n1ptr-- * *n2ptr++; - sum = sum / 10; - } - for ( ; indx < total_digits-1; indx++) - { - n1ptr = (char *) (n1end - MAX(0, indx-len2+1)); - n2ptr = (char *) (n2end - MIN(indx, len2-1)); - while ((n1ptr >= n1->n_value) && (n2ptr <= n2end)) - sum += *n1ptr-- * *n2ptr++; - *pvptr-- = sum % 10; - sum = sum / 10; - } - *pvptr-- = sum; - - /* Assign to prod and clean up the number. */ - free_num (prod); - *prod = pval; - _rm_leading_zeros (*prod); - if (is_zero (*prod)) - (*prod)->n_sign = PLUS; -} - - -/* Some utility routines for the divide: First a one digit multiply. - NUM (with SIZE digits) is multiplied by DIGIT and the result is - placed into RESULT. It is written so that NUM and RESULT can be - the same pointers. */ - -static void -_one_mult (num, size, digit, result) - unsigned char *num; - int size, digit; - unsigned char *result; -{ - int carry, value; - unsigned char *nptr, *rptr; - - if (digit == 0) - memset (result, 0, size); - else - { - if (digit == 1) - memcpy (result, num, size); - else - { - /* Initialize */ - nptr = (unsigned char *) (num+size-1); - rptr = (unsigned char *) (result+size-1); - carry = 0; - - while (size-- > 0) - { - value = *nptr-- * digit + carry; - *rptr-- = value % 10; - carry = value / 10; - } - - if (carry != 0) *rptr = carry; - } - } -} - - -/* The full division routine. This computes N1 / N2. It returns - 0 if the division is ok and the result is in QUOT. The number of - digits after the decimal point is SCALE. It returns -1 if division - by zero is tried. The algorithm is found in Knuth Vol 2. p237. */ - -int -bc_divide (n1, n2, quot, scale) - bc_num n1, n2, *quot; - int scale; -{ - bc_num qval; - unsigned char *num1, *num2; - unsigned char *ptr1, *ptr2, *n2ptr, *qptr; - int scale1, val; - unsigned int len1, len2, scale2, qdigits, extra, count; - unsigned int qdig, qguess, borrow, carry; - unsigned char *mval; - char zero; - unsigned int norm; - - /* Test for divide by zero. */ - if (is_zero (n2)) return -1; - - /* Test for divide by 1. If it is we must truncate. */ - if (n2->n_scale == 0) - { - if (n2->n_len == 1 && *n2->n_value == 1) - { - qval = new_num (n1->n_len, scale); - qval->n_sign = (n1->n_sign == n2->n_sign ? PLUS : MINUS); - memset (&qval->n_value[n1->n_len],0,scale); - memcpy (qval->n_value, n1->n_value, - n1->n_len + MIN(n1->n_scale,scale)); - free_num (quot); - *quot = qval; - } - } - - /* Set up the divide. Move the decimal point on n1 by n2's scale. - Remember, zeros on the end of num2 are wasted effort for dividing. */ - scale2 = n2->n_scale; - n2ptr = (unsigned char *) n2->n_value+n2->n_len+scale2-1; - while ((scale2 > 0) && (*n2ptr-- == 0)) scale2--; - - len1 = n1->n_len + scale2; - scale1 = n1->n_scale - scale2; - if (scale1 < scale) - extra = scale - scale1; - else - extra = 0; - num1 = (unsigned char *) malloc (n1->n_len+n1->n_scale+extra+2); - if (num1 == NULL) out_of_memory(); - memset (num1, 0, n1->n_len+n1->n_scale+extra+2); - memcpy (num1+1, n1->n_value, n1->n_len+n1->n_scale); - - len2 = n2->n_len + scale2; - num2 = (unsigned char *) malloc (len2+1); - if (num2 == NULL) out_of_memory(); - memcpy (num2, n2->n_value, len2); - *(num2+len2) = 0; - n2ptr = num2; - while (*n2ptr == 0) - { - n2ptr++; - len2--; - } - - /* Calculate the number of quotient digits. */ - if (len2 > len1+scale) - { - qdigits = scale+1; - zero = TRUE; - } - else - { - zero = FALSE; - if (len2>len1) - qdigits = scale+1; /* One for the zero integer part. */ - else - qdigits = len1-len2+scale+1; - } - - /* Allocate and zero the storage for the quotient. */ - qval = new_num (qdigits-scale,scale); - memset (qval->n_value, 0, qdigits); - - /* Allocate storage for the temporary storage mval. */ - mval = (unsigned char *) malloc (len2+1); - if (mval == NULL) out_of_memory (); - - /* Now for the full divide algorithm. */ - if (!zero) - { - /* Normalize */ - norm = 10 / ((int)*n2ptr + 1); - if (norm != 1) - { - _one_mult (num1, len1+scale1+extra+1, norm, num1); - _one_mult (n2ptr, len2, norm, n2ptr); - } - - /* Initialize divide loop. */ - qdig = 0; - if (len2 > len1) - qptr = (unsigned char *) qval->n_value+len2-len1; - else - qptr = (unsigned char *) qval->n_value; - - /* Loop */ - while (qdig <= len1+scale-len2) - { - /* Calculate the quotient digit guess. */ - if (*n2ptr == num1[qdig]) - qguess = 9; - else - qguess = (num1[qdig]*10 + num1[qdig+1]) / *n2ptr; - - /* Test qguess. */ - if (n2ptr[1]*qguess > - (num1[qdig]*10 + num1[qdig+1] - *n2ptr*qguess)*10 - + num1[qdig+2]) - { - qguess--; - /* And again. */ - if (n2ptr[1]*qguess > - (num1[qdig]*10 + num1[qdig+1] - *n2ptr*qguess)*10 - + num1[qdig+2]) - qguess--; - } - - /* Multiply and subtract. */ - borrow = 0; - if (qguess != 0) - { - *mval = 0; - _one_mult (n2ptr, len2, qguess, mval+1); - ptr1 = (unsigned char *) num1+qdig+len2; - ptr2 = (unsigned char *) mval+len2; - for (count = 0; count < len2+1; count++) - { - val = (int) *ptr1 - (int) *ptr2-- - borrow; - if (val < 0) - { - val += 10; - borrow = 1; - } - else - borrow = 0; - *ptr1-- = val; - } - } - - /* Test for negative result. */ - if (borrow == 1) - { - qguess--; - ptr1 = (unsigned char *) num1+qdig+len2; - ptr2 = (unsigned char *) n2ptr+len2-1; - carry = 0; - for (count = 0; count < len2; count++) - { - val = (int) *ptr1 + (int) *ptr2-- + carry; - if (val > 9) - { - val -= 10; - carry = 1; - } - else - carry = 0; - *ptr1-- = val; - } - if (carry == 1) *ptr1 = (*ptr1 + 1) % 10; - } - - /* We now know the quotient digit. */ - *qptr++ = qguess; - qdig++; - } - } - - /* Clean up and return the number. */ - qval->n_sign = ( n1->n_sign == n2->n_sign ? PLUS : MINUS ); - if (is_zero (qval)) qval->n_sign = PLUS; - _rm_leading_zeros (qval); - free_num (quot); - *quot = qval; - - /* Clean up temporary storage. */ - free (mval); - free (num1); - free (num2); - - return 0; /* Everything is OK. */ -} - - -/* Modulo for numbers. This computes NUM1 % NUM2 and puts the - result in RESULT. */ - -int -bc_modulo (num1, num2, result, scale) - bc_num num1, num2, *result; - int scale; -{ - bc_num temp; - int rscale; - - /* Check for correct numbers. */ - if (is_zero (num2)) return -1; - - /* Calculate final scale. */ - rscale = MAX (num1->n_scale, num2->n_scale+scale); - init_num (&temp); - - /* Calculate it. */ - bc_divide (num1, num2, &temp, scale); - bc_multiply (temp, num2, &temp, rscale); - bc_sub (num1, temp, result); - free_num (&temp); - - return 0; /* Everything is OK. */ -} - - -/* Raise NUM1 to the NUM2 power. The result is placed in RESULT. - Maximum exponent is LONG_MAX. If a NUM2 is not an integer, - only the integer part is used. */ - -void -bc_raise (num1, num2, result, scale) - bc_num num1, num2, *result; - int scale; -{ - bc_num temp, power; - long exponent; - int rscale; - char neg; - - /* Check the exponent for scale digits and convert to a long. */ - if (num2->n_scale != 0) - rt_warn ("non-zero scale in exponent"); - exponent = num2long (num2); - if (exponent == 0 && (num2->n_len > 1 || num2->n_value[0] != 0)) - rt_error ("exponent too large in raise"); - - /* Special case if exponent is a zero. */ - if (exponent == 0) - { - free_num (result); - *result = copy_num (_one_); - return; - } - - /* Other initializations. */ - if (exponent < 0) - { - neg = TRUE; - exponent = -exponent; - rscale = scale; - } - else - { - neg = FALSE; - rscale = MIN (num1->n_scale*exponent, MAX(scale, num1->n_scale)); - } - temp = copy_num (_one_); - power = copy_num (num1); - - /* Do the calculation. */ - while (exponent != 0) - { - if (exponent & 1 != 0) - bc_multiply (temp, power, &temp, rscale); - bc_multiply (power, power, &power, rscale); - exponent = exponent >> 1; - } - - /* Assign the value. */ - if (neg) - { - bc_divide (_one_, temp, result, rscale); - free_num (&temp); - } - else - { - free_num (result); - *result = temp; - } - free_num (&power); -} - - -/* Take the square root NUM and return it in NUM with SCALE digits - after the decimal place. */ - -int -bc_sqrt (num, scale) - bc_num *num; - int scale; -{ - int rscale, cmp_res, done; - int cscale; - bc_num guess, guess1, point5; - - /* Initial checks. */ - cmp_res = bc_compare (*num, _zero_); - if (cmp_res < 0) - return 0; /* error */ - else - { - if (cmp_res == 0) - { - free_num (num); - *num = copy_num (_zero_); - return 1; - } - } - cmp_res = bc_compare (*num, _one_); - if (cmp_res == 0) - { - free_num (num); - *num = copy_num (_one_); - return 1; - } - - /* Initialize the variables. */ - rscale = MAX (scale, (*num)->n_scale); - cscale = rscale + 2; - init_num (&guess); - init_num (&guess1); - point5 = new_num (1,1); - point5->n_value[1] = 5; - - - /* Calculate the initial guess. */ - if (cmp_res < 0) - /* The number is between 0 and 1. Guess should start at 1. */ - guess = copy_num (_one_); - else - { - /* The number is greater than 1. Guess should start at 10^(exp/2). */ - int2num (&guess,10); - int2num (&guess1,(*num)->n_len); - bc_multiply (guess1, point5, &guess1, rscale); - guess1->n_scale = 0; - bc_raise (guess, guess1, &guess, rscale); - free_num (&guess1); - } - - /* Find the square root using Newton's algorithm. */ - done = FALSE; - while (!done) - { - free_num (&guess1); - guess1 = copy_num (guess); - bc_divide (*num,guess,&guess,cscale); - bc_add (guess,guess1,&guess); - bc_multiply (guess,point5,&guess,cscale); - cmp_res = _do_compare (guess,guess1,FALSE,TRUE); - if (cmp_res == 0) done = TRUE; - } - - /* Assign the number and clean up. */ - free_num (num); - bc_divide (guess,_one_,num,rscale); - free_num (&guess); - free_num (&guess1); - free_num (&point5); - return 1; -} - - -/* The following routines provide output for bcd numbers package - using the rules of POSIX bc for output. */ - -/* This structure is used for saving digits in the conversion process. */ -typedef struct stk_rec { - long digit; - struct stk_rec *next; -} stk_rec; - -/* The reference string for digits. */ -char ref_str[] = "0123456789ABCDEF"; - - -/* A special output routine for "multi-character digits." Exactly - SIZE characters must be output for the value VAL. If SPACE is - non-zero, we must output one space before the number. OUT_CHAR - is the actual routine for writing the characters. */ - -void -out_long (val, size, space, out_char) - long val; - int size, space; -#ifdef __STDC__ - void (*out_char)(int); -#else - void (*out_char)(); -#endif -{ - char digits[40]; - int len, ix; - - if (space) (*out_char) (' '); - sprintf (digits, "%ld", val); - len = strlen (digits); - while (size > len) - { - (*out_char) ('0'); - size--; - } - for (ix=0; ix < len; ix++) - (*out_char) (digits[ix]); -} - -/* Output of a bcd number. NUM is written in base O_BASE using OUT_CHAR - as the routine to do the actual output of the characters. */ - -void -out_num (num, o_base, out_char) - bc_num num; - int o_base; -#ifdef __STDC__ - void (*out_char)(int); -#else - void (*out_char)(); -#endif -{ - char *nptr; - int index, fdigit, pre_space; - stk_rec *digits, *temp; - bc_num int_part, frac_part, base, cur_dig, t_num, max_o_digit; - - /* The negative sign if needed. */ - if (num->n_sign == MINUS) (*out_char) ('-'); - - /* Output the number. */ - if (is_zero (num)) - (*out_char) ('0'); - else - if (o_base == 10) - { - /* The number is in base 10, do it the fast way. */ - nptr = num->n_value; - if (num->n_len > 1 || *nptr != 0) - for (index=num->n_len; index>0; index--) - (*out_char) (BCD_CHAR(*nptr++)); - else - nptr++; - - /* Now the fraction. */ - if (num->n_scale > 0) - { - (*out_char) ('.'); - for (index=0; indexn_scale; index++) - (*out_char) (BCD_CHAR(*nptr++)); - } - } - else - { - /* The number is some other base. */ - digits = NULL; - init_num (&int_part); - bc_divide (num, _one_, &int_part, 0); - init_num (&frac_part); - init_num (&cur_dig); - init_num (&base); - bc_sub (num, int_part, &frac_part); - int2num (&base, o_base); - init_num (&max_o_digit); - int2num (&max_o_digit, o_base-1); - - - /* Get the digits of the integer part and push them on a stack. */ - while (!is_zero (int_part)) - { - bc_modulo (int_part, base, &cur_dig, 0); - temp = (stk_rec *) malloc (sizeof(stk_rec)); - if (temp == NULL) out_of_memory(); - temp->digit = num2long (cur_dig); - temp->next = digits; - digits = temp; - bc_divide (int_part, base, &int_part, 0); - } - - /* Print the digits on the stack. */ - if (digits != NULL) - { - /* Output the digits. */ - while (digits != NULL) - { - temp = digits; - digits = digits->next; - if (o_base <= 16) - (*out_char) (ref_str[ (int) temp->digit]); - else - out_long (temp->digit, max_o_digit->n_len, 1, out_char); - free (temp); - } - } - - /* Get and print the digits of the fraction part. */ - if (num->n_scale > 0) - { - (*out_char) ('.'); - pre_space = 0; - t_num = copy_num (_one_); - while (t_num->n_len <= num->n_scale) { - bc_multiply (frac_part, base, &frac_part, num->n_scale); - fdigit = num2long (frac_part); - int2num (&int_part, fdigit); - bc_sub (frac_part, int_part, &frac_part); - if (o_base <= 16) - (*out_char) (ref_str[fdigit]); - else { - out_long (fdigit, max_o_digit->n_len, pre_space, out_char); - pre_space = 1; - } - bc_multiply (t_num, base, &t_num, 0); - } - } - - /* Clean up. */ - free_num (&int_part); - free_num (&frac_part); - free_num (&base); - free_num (&cur_dig); - } -} - - -#if DEBUG > 0 - -/* Debugging procedures. Some are just so one can call them from the - debugger. */ - -/* p_n prints the number NUM in base 10. */ - -void -p_n (num) - bc_num num; -{ - out_num (num, 10, out_char); - return 0; -} - - -/* p_b prints a character array as if it was a string of bcd digits. */ -void -p_v (name, num, len) - char *name; - unsigned char *num; - int len; -{ - int i; - printf ("%s=", name); - for (i=0; in_sign = MINUS; - ptr++; - } - else - { - (*num)->n_sign = PLUS; - if (*ptr == '+') ptr++; - } - while (*ptr == '0') ptr++; /* Skip leading zeros. */ - nptr = (*num)->n_value; - if (zero_int) - { - *nptr++ = 0; - digits = 0; - } - for (;digits > 0; digits--) - *nptr++ = CH_VAL(*ptr++); - - - /* Build the fractional part. */ - if (strscale > 0) - { - ptr++; /* skip the decimal point! */ - for (;strscale > 0; strscale--) - *nptr++ = CH_VAL(*ptr++); - } -} - -/* Convert a numbers to a string. Base 10 only.*/ - -char -*num2str (num) - bc_num num; -{ - char *str, *sptr; - char *nptr; - int index, signch; - - /* Allocate the string memory. */ - signch = ( num->n_sign == PLUS ? 0 : 1 ); /* Number of sign chars. */ - if (num->n_scale > 0) - str = (char *) malloc (num->n_len + num->n_scale + 2 + signch); - else - str = (char *) malloc (num->n_len + 1 + signch); - if (str == NULL) out_of_memory(); - - /* The negative sign if needed. */ - sptr = str; - if (signch) *sptr++ = '-'; - - /* Load the whole number. */ - nptr = num->n_value; - for (index=num->n_len; index>0; index--) - *sptr++ = BCD_CHAR(*nptr++); - - /* Now the fraction. */ - if (num->n_scale > 0) - { - *sptr++ = '.'; - for (index=0; indexn_scale; index++) - *sptr++ = BCD_CHAR(*nptr++); - } - - /* Terminate the string and return it! */ - *sptr = '\0'; - return (str); -} -#endif diff --git a/gnu/usr.bin/bc-1.02/number.h b/gnu/usr.bin/bc-1.02/number.h deleted file mode 100644 index 993851517a45..000000000000 --- a/gnu/usr.bin/bc-1.02/number.h +++ /dev/null @@ -1,60 +0,0 @@ -/* number.h: Arbitrary precision numbers header file. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - - -typedef enum {PLUS, MINUS} sign; - -typedef struct - { - sign n_sign; - int n_len; /* The number of digits before the decimal point. */ - int n_scale; /* The number of digits after the decimal point. */ - int n_refs; /* The number of pointers to this number. */ - char n_value[1]; /* The storage. Not zero char terminated. It is - allocated with all other fields. */ - } bc_struct; - -typedef bc_struct *bc_num; - -/* Some useful macros and constants. */ - -#define CH_VAL(c) (c - '0') -#define BCD_CHAR(d) (d + '0') - -#ifdef MIN -#undef MIN -#undef MAX -#endif -#define MAX(a,b) (a>b?a:b) -#define MIN(a,b) (a>b?b:a) -#define ODD(a) (a&1) - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif diff --git a/gnu/usr.bin/bc-1.02/proto.h b/gnu/usr.bin/bc-1.02/proto.h deleted file mode 100644 index fea94053863d..000000000000 --- a/gnu/usr.bin/bc-1.02/proto.h +++ /dev/null @@ -1,165 +0,0 @@ -/* proto.h: Prototype function definitions for "external" functions. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -/* For the pc version using k&r ACK. (minix1.5 and earlier.) */ -#ifdef SHORTNAMES -#define init_numbers i_numbers -#define push_constant push__constant -#define load_const in_load_const -#define yy_get_next_buffer yyget_next_buffer -#define yy_init_buffer yyinit_buffer -#define yy_last_accepting_state yylast_accepting_state -#define arglist1 arg1list -#endif - -/* Include the standard library header files. */ -#ifndef NO_UNISTD -#include -#endif -#ifndef NO_STDLIB -#ifdef __STDC__ -#include -#endif -#endif - -/* Define the _PROTOTYPE macro if it is needed. */ - -#ifndef _PROTOTYPE -#ifdef __STDC__ -#define _PROTOTYPE(func, args) func args -#else -#define _PROTOTYPE(func, args) func() -#endif -#endif - -/* From execute.c */ -_PROTOTYPE(void stop_execution, (int)); -_PROTOTYPE(unsigned char byte, (program_counter *pc)); -_PROTOTYPE(void execute, (void)); -_PROTOTYPE(char prog_char, (void)); -_PROTOTYPE(char input_char, (void)); -_PROTOTYPE(void push_constant, (char (*in_char)(void), int conv_base)); -_PROTOTYPE(void push_b10_const, (program_counter *pc)); -_PROTOTYPE(void assign, (int c_code)); - -/* From util.c */ -_PROTOTYPE(char *strcopyof, (char *str)); -_PROTOTYPE(arg_list *nextarg, (arg_list *args, int val)); -_PROTOTYPE(char *arg_str, (arg_list *args, int)); -_PROTOTYPE(void free_args, (arg_list *args)); -_PROTOTYPE(void check_params, (arg_list *params, arg_list *autos)); -_PROTOTYPE(void init_gen, (void)); -_PROTOTYPE(void generate, (char *str)); -_PROTOTYPE(void run_code, (void)); -_PROTOTYPE(void out_char, (int ch)); -_PROTOTYPE(id_rec *find_id, (id_rec *tree, char *id)); -_PROTOTYPE(int insert_id_rec, (id_rec **root, id_rec *new_id)); -_PROTOTYPE(void init_tree, (void)); -_PROTOTYPE(int lookup, (char *name, int namekind)); -_PROTOTYPE(char *bc_malloc, (int)); -_PROTOTYPE(void out_of_memory, (void)); -_PROTOTYPE(void welcome, (void)); -_PROTOTYPE(void warranty, (char *)); -_PROTOTYPE(void limits, (void)); -_PROTOTYPE(void yyerror, (char *str ,...)); -_PROTOTYPE(void warn, (char *mesg ,...)); -_PROTOTYPE(void rt_error, (char *mesg ,...)); -_PROTOTYPE(void rt_warn, (char *mesg ,...)); - -/* From load.c */ -_PROTOTYPE(void init_load, (void)); -_PROTOTYPE(void addbyte, (int byte)); -_PROTOTYPE(void def_label, (long lab)); -_PROTOTYPE(long long_val, (char **str)); -_PROTOTYPE(void load_code, (char *code)); - -/* From main.c */ -_PROTOTYPE(int main, (int argc , char *argv [])); -_PROTOTYPE(int open_new_file, (void)); -_PROTOTYPE(void new_yy_file, (FILE *file)); -_PROTOTYPE(void use_quit, (int)); - -/* From number.c */ -_PROTOTYPE(void free_num, (bc_num *num)); -_PROTOTYPE(bc_num new_num, (int length, int scale)); -_PROTOTYPE(void init_numbers, (void)); -_PROTOTYPE(bc_num copy_num, (bc_num num)); -_PROTOTYPE(void init_num, (bc_num *num)); -_PROTOTYPE(void str2num, (bc_num *num, char *str, int scale)); -_PROTOTYPE(char *num2str, (bc_num num)); -_PROTOTYPE(void int2num, (bc_num *num, int val)); -_PROTOTYPE(long num2long, (bc_num num)); -_PROTOTYPE(int bc_compare, (bc_num n1, bc_num n2)); -_PROTOTYPE(char is_zero, (bc_num num)); -_PROTOTYPE(char is_neg, (bc_num num)); -_PROTOTYPE(void bc_add, (bc_num n1, bc_num n2, bc_num *result)); -_PROTOTYPE(void bc_sub, (bc_num n1, bc_num n2, bc_num *result)); -_PROTOTYPE(void bc_multiply, (bc_num n1, bc_num n2, bc_num *prod, int scale)); -_PROTOTYPE(int bc_divide, (bc_num n1, bc_num n2, bc_num *quot, int scale)); -_PROTOTYPE(int bc_modulo, (bc_num num1, bc_num num2, bc_num *result, int scale)); -_PROTOTYPE(void bc_raise, (bc_num num1, bc_num num2, bc_num *result, int scale)); -_PROTOTYPE(int bc_sqrt, (bc_num *num, int scale)); -_PROTOTYPE(void out_long, (long val, int size, int space, - void (*out_char)(int))); -_PROTOTYPE(void out_num, (bc_num num, int o_base, void (* out_char)(int))); - - -/* From storage.c */ -_PROTOTYPE(void init_storage, (void)); -_PROTOTYPE(void more_functions, (void)); -_PROTOTYPE(void more_variables, (void)); -_PROTOTYPE(void more_arrays, (void)); -_PROTOTYPE(void clear_func, (int func )); -_PROTOTYPE(int fpop, (void)); -_PROTOTYPE(void fpush, (int val )); -_PROTOTYPE(void pop, (void)); -_PROTOTYPE(void push_copy, (bc_num num )); -_PROTOTYPE(void push_num, (bc_num num )); -_PROTOTYPE(char check_stack, (int depth )); -_PROTOTYPE(bc_var *get_var, (int var_name )); -_PROTOTYPE(bc_num *get_array_num, (int var_index, long index )); -_PROTOTYPE(void store_var, (int var_name )); -_PROTOTYPE(void store_array, (int var_name )); -_PROTOTYPE(void load_var, (int var_name )); -_PROTOTYPE(void load_array, (int var_name )); -_PROTOTYPE(void decr_var, (int var_name )); -_PROTOTYPE(void decr_array, (int var_name )); -_PROTOTYPE(void incr_var, (int var_name )); -_PROTOTYPE(void incr_array, (int var_name )); -_PROTOTYPE(void auto_var, (int name )); -_PROTOTYPE(void free_a_tree, (bc_array_node *root, int depth )); -_PROTOTYPE(void pop_vars, (arg_list *list )); -_PROTOTYPE(void process_params, (program_counter *pc, int func )); - -/* For the scanner and parser.... */ -_PROTOTYPE(int yyparse, (void)); -_PROTOTYPE(int yylex, (void)); - -/* Other things... */ -_PROTOTYPE (int getopt, (int, char *[], CONST char *)); - diff --git a/gnu/usr.bin/bc-1.02/sbc.y b/gnu/usr.bin/bc-1.02/sbc.y deleted file mode 100644 index 81594106361a..000000000000 --- a/gnu/usr.bin/bc-1.02/sbc.y +++ /dev/null @@ -1,448 +0,0 @@ -, %{ -/* sbc.y: A POSIX bc processor written for minix with no extensions. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -#include "bcdefs.h" -#include "global.h" /* To get the global variables. */ -#include "proto.h" -%} - -%start program - -%union { - char *s_value; - char c_value; - int i_value; - arg_list *a_value; - } - -%token NEWLINE AND OR NOT -%token STRING NAME NUMBER -/* '-', '+' are tokens themselves */ -%token MUL_OP -/* '*', '/', '%' */ -%token ASSIGN_OP -/* '=', '+=', '-=', '*=', '/=', '%=', '^=' */ -%token REL_OP -/* '==', '<=', '>=', '!=', '<', '>' */ -%token INCR_DECR -/* '++', '--' */ -%token Define Break Quit Length -/* 'define', 'break', 'quit', 'length' */ -%token Return For If While Sqrt Else -/* 'return', 'for', 'if', 'while', 'sqrt', 'else' */ -%token Scale Ibase Obase Auto Read -/* 'scale', 'ibase', 'obase', 'auto', 'read' */ -%token Warranty, Halt, Last, Continue, Print, Limits -/* 'warranty', 'halt', 'last', 'continue', 'print', 'limits' */ - -/* The types of all other non-terminals. */ -%type expression named_expression return_expression -%type opt_parameter_list parameter_list opt_auto_define_list -%type define_list opt_argument_list argument_list -%type program input_item semicolon_list statement_list -%type statement_or_error statement function relational_expression - -/* precedence */ -%nonassoc REL_OP -%right ASSIGN_OP -%left '+' '-' -%left MUL_OP -%right '^' -%nonassoc UNARY_MINUS -%nonassoc INCR_DECR - -%% -program : /* empty */ - { - $$ = 0; - std_only = TRUE; - if (interactive) - { - printf ("s%s\n", BC_VERSION); - welcome(); - } - } - | program input_item - ; -input_item : semicolon_list NEWLINE - { run_code(); } - | function - { run_code(); } - | error NEWLINE - { - yyerrok; - init_gen() ; - } - ; -semicolon_list : /* empty */ - { $$ = 0; } - | statement_or_error - | semicolon_list ';' statement_or_error - | semicolon_list ';' - ; -statement_list : /* empty */ - { $$ = 0; } - | statement - | statement_list NEWLINE - | statement_list NEWLINE statement - | statement_list ';' - | statement_list ';' statement - ; -statement_or_error : statement - | error statement - { $$ = $2; } - ; -statement : Warranty - { warranty("s"); } - | expression - { - if ($1 & 1) - generate ("W"); - else - generate ("p"); - } - | STRING - { - $$ = 0; - generate ("w"); - generate ($1); - free ($1); - } - | Break - { - if (break_label == 0) - yyerror ("Break outside a for/while"); - else - { - sprintf (genstr, "J%1d:", break_label); - generate (genstr); - } - } - | Quit - { exit(0); } - | Return - { generate ("0R"); } - | Return '(' return_expression ')' - { generate ("R"); } - | For - { - $1 = break_label; - break_label = next_label++; - } - '(' expression ';' - { - $4 = next_label++; - sprintf (genstr, "pN%1d:", $4); - generate (genstr); - } - relational_expression ';' - { - $7 = next_label++; - sprintf (genstr, "B%1d:J%1d:", $7, break_label); - generate (genstr); - $$ = next_label++; - sprintf (genstr, "N%1d:", $$); - generate (genstr); - } - expression ')' - { - sprintf (genstr, "pJ%1d:N%1d:", $4, $7); - generate (genstr); - } - statement - { - sprintf (genstr, "J%1d:N%1d:", $9, - break_label); - generate (genstr); - break_label = $1; - } - | If '(' relational_expression ')' - { - $3 = next_label++; - sprintf (genstr, "Z%1d:", $3); - generate (genstr); - } - statement - { - sprintf (genstr, "N%1d:", $3); - generate (genstr); - } - | While - { - $1 = next_label++; - sprintf (genstr, "N%1d:", $1); - generate (genstr); - } - '(' relational_expression - { - $4 = break_label; - break_label = next_label++; - sprintf (genstr, "Z%1d:", break_label); - generate (genstr); - } - ')' statement - { - sprintf (genstr, "J%1d:N%1d:", $1, break_label); - generate (genstr); - break_label = $4; - } - | '{' statement_list '}' - { $$ = 0; } - ; -function : Define NAME '(' opt_parameter_list ')' '{' - NEWLINE opt_auto_define_list - { - check_params ($4,$8); - sprintf (genstr, "F%d,%s.%s[", lookup($2,FUNCT), - arg_str ($4,TRUE), arg_str ($8,TRUE)); - generate (genstr); - free_args ($4); - free_args ($8); - $1 = next_label; - next_label = 0; - } - statement_list NEWLINE '}' - { - generate ("0R]"); - next_label = $1; - } - ; -opt_parameter_list : /* empty */ - { $$ = NULL; } - | parameter_list - ; -parameter_list : NAME - { $$ = nextarg (NULL, lookup($1,SIMPLE)); } - | define_list ',' NAME - { $$ = nextarg ($1, lookup($3,SIMPLE)); } - ; -opt_auto_define_list : /* empty */ - { $$ = NULL; } - | Auto define_list NEWLINE - { $$ = $2; } - | Auto define_list ';' - { $$ = $2; } - ; -define_list : NAME - { $$ = nextarg (NULL, lookup($1,SIMPLE)); } - | NAME '[' ']' - { $$ = nextarg (NULL, lookup($1,ARRAY)); } - | define_list ',' NAME - { $$ = nextarg ($1, lookup($3,SIMPLE)); } - | define_list ',' NAME '[' ']' - { $$ = nextarg ($1, lookup($3,ARRAY)); } - ; -opt_argument_list : /* empty */ - { $$ = NULL; } - | argument_list - ; -argument_list : expression - { $$ = nextarg (NULL,0); } - | argument_list ',' expression - { $$ = nextarg ($1,0); } - ; -relational_expression : expression - { $$ = 0; } - | expression REL_OP expression - { - $$ = 0; - switch (*($2)) - { - case '=': - generate ("="); - break; - case '!': - generate ("#"); - break; - case '<': - if ($2[1] == '=') - generate ("{"); - else - generate ("<"); - break; - case '>': - if ($2[1] == '=') - generate ("}"); - else - generate (">"); - break; - } - } - ; -return_expression : /* empty */ - { - $$ = 0; - generate ("0"); - } - | expression - ; -expression : named_expression ASSIGN_OP - { - if ($2 != '=') - { - if ($1 < 0) - sprintf (genstr, "DL%d:", -$1); - else - sprintf (genstr, "l%d:", $1); - generate (genstr); - } - } - expression - { - $$ = 0; - if ($2 != '=') - { - sprintf (genstr, "%c", $2); - generate (genstr); - } - if ($1 < 0) - sprintf (genstr, "S%d:", -$1); - else - sprintf (genstr, "s%d:", $1); - generate (genstr); - } - | expression '+' expression - { generate ("+"); } - | expression '-' expression - { generate ("-"); } - | expression MUL_OP expression - { - genstr[0] = $2; - genstr[1] = 0; - generate (genstr); - } - | expression '^' expression - { generate ("^"); } - | '-' expression %prec UNARY_MINUS - { generate ("n"); $$ = 1;} - | named_expression - { - $$ = 1; - if ($1 < 0) - sprintf (genstr, "L%d:", -$1); - else - sprintf (genstr, "l%d:", $1); - generate (genstr); - } - | NUMBER - { - int len = strlen($1); - $$ = 1; - if (len == 1 && *$1 == '0') - generate ("0"); - else - { - if (len == 1 && *$1 == '1') - generate ("1"); - else - { - generate ("K"); - generate ($1); - generate (":"); - } - free ($1); - } - } - | '(' expression ')' - { $$ = 1; } - | NAME '(' opt_argument_list ')' - { - $$ = 1; - if ($3 != NULL) - { - sprintf (genstr, "C%d,%s:", lookup($1,FUNCT), - arg_str ($3,FALSE)); - free_args ($3); - } - else - sprintf (genstr, "C%d:", lookup($1,FUNCT)); - generate (genstr); - } - | INCR_DECR named_expression - { - $$ = 1; - if ($2 < 0) - { - if ($1 == '+') - sprintf (genstr, "DA%d:L%d:", -$2, -$2); - else - sprintf (genstr, "DM%d:L%d:", -$2, -$2); - } - else - { - if ($1 == '+') - sprintf (genstr, "i%d:l%d:", $2, $2); - else - sprintf (genstr, "d%d:l%d:", $2, $2); - } - generate (genstr); - } - | named_expression INCR_DECR - { - $$ = 1; - if ($1 < 0) - { - sprintf (genstr, "DL%d:x", -$1); - generate (genstr); - if ($2 == '+') - sprintf (genstr, "A%d:", -$1); - else - sprintf (genstr, "M%d:", -$1); - } - else - { - sprintf (genstr, "l%d:", $1); - generate (genstr); - if ($2 == '+') - sprintf (genstr, "i%d:", $1); - else - sprintf (genstr, "d%d:", $1); - } - generate (genstr); - } - | Length '(' expression ')' - { generate ("cL"); $$ = 1;} - | Sqrt '(' expression ')' - { generate ("cR"); $$ = 1;} - | Scale '(' expression ')' - { generate ("cS"); $$ = 1;} - ; -named_expression : NAME - { $$ = lookup($1,SIMPLE); } - | NAME '[' expression ']' - { $$ = lookup($1,ARRAY); } - | Ibase - { $$ = 0; } - | Obase - { $$ = 1; } - | Scale - { $$ = 2; } - ; - -%% diff --git a/gnu/usr.bin/bc-1.02/scan.c.dist b/gnu/usr.bin/bc-1.02/scan.c.dist deleted file mode 100644 index 34a4a97f06d6..000000000000 --- a/gnu/usr.bin/bc-1.02/scan.c.dist +++ /dev/null @@ -1,1368 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* scanner skeleton version: - * $Header: /cvsroot/src/gnu/usr.bin/bc-1.02/Attic/scan.c.dist,v 1.1 1993/04/10 15:52:36 cgd Exp $ - */ - -#define FLEX_SCANNER - -#include - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include -#include - -/* use prototypes in function declarations */ -#define YY_USE_PROTOS - -/* the "const" storage-class-modifier is valid */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#ifdef __STDC__ - -#ifdef __GNUC__ -#include -void *malloc( size_t ); -void free( void* ); -#else -#include -#endif /* __GNUC__ */ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - - -#ifdef __TURBOC__ -#define YY_USE_CONST -#endif - - -#ifndef YY_USE_CONST -#define const -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -/* we can't get here if it's an ANSI C compiler, or a C++ compiler, - * so it's got to be a K&R compiler, and therefore there's no standard - * place from which to include these definitions - */ -/* char *malloc(); -int free(); */ -int read(); -#endif - - -/* amount of stuff to slurp up with each read */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* returned upon end-of-file */ -#define YY_END_TOK 0 - -/* copy whatever the last rule matched to the standard output */ - -/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */ -/* this used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite() - */ -#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout ) - -/* gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#define YY_INPUT(buf,result,max_size) \ - if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ - YY_FATAL_ERROR( "read() in flex scanner failed" ); -#define YY_NULL 0 - -/* no semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#define yyterminate() return ( YY_NULL ) - -/* report a fatal error */ - -/* The funky do-while is used to turn this macro definition into - * a single C statement (which needs a semi-colon terminator). - * This avoids problems with code like: - * - * if ( something_happens ) - * YY_FATAL_ERROR( "oops, the something happened" ); - * else - * everything_okay(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the YY_FATAL_ERROR() call. - */ - -#define YY_FATAL_ERROR(msg) \ - do \ - { \ - (void) fputs( msg, stderr ); \ - (void) putc( '\n', stderr ); \ - exit( 1 ); \ - } \ - while ( 0 ) - -/* default yywrap function - always treat EOF as an EOF */ -#define yywrap() 1 - -/* enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN - */ -#define BEGIN yy_start = 1 + 2 * - -/* action number for EOF rule of a given start state */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* special action meaning "start processing a new file" */ -#define YY_NEW_FILE \ - do \ - { \ - yy_init_buffer( yy_current_buffer, yyin ); \ - yy_load_buffer_state(); \ - } \ - while ( 0 ) - -/* default declaration of generated scanner - a define so the user can - * easily add parameters - */ -#define YY_DECL int yylex YY_PROTO(( void )) - -/* code executed at the end of each rule */ -#define YY_BREAK break; - -#define YY_END_OF_BUFFER_CHAR 0 - -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */ -#endif - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -#define YY_CHAR unsigned char -# line 1 "scan.l" -#define INITIAL 0 -# line 2 "scan.l" -/* scan.l: the (f)lex description file for the scanner. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -#include "bcdefs.h" -#include "y.tab.h" -#include "global.h" -#include "proto.h" - -/* Using flex, we can ask for a smaller input buffer. With lex, this - does nothing! */ - -#ifdef SMALL_BUF -#undef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 512 -#endif - -/* We want to define our own yywrap. */ -#undef yywrap -_PROTOTYPE(int yywrap, (void)); - -/* MINIX returns from read with < 0 if SIGINT is encountered. - In flex, we can redefine YY_INPUT to the following. In lex, this - does nothing! */ -#include -#undef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - while ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ - if (errno != EINTR) \ - YY_FATAL_ERROR( "read() in flex scanner failed" ); - -# line 60 "scan.l" - -/* done after the current pattern has been matched and before the - * corresponding action - sets up yytext - */ -#define YY_DO_BEFORE_ACTION \ - yytext = yy_bp; \ - yyleng = yy_cp - yy_bp; \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* return all but the first 'n' matched characters back to the input stream */ -#define yyless(n) \ - do \ - { \ - /* undo effects of setting up yytext */ \ - *yy_cp = yy_hold_char; \ - yy_c_buf_p = yy_cp = yy_bp + n; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext ) - - -struct yy_buffer_state - { - FILE *yy_input_file; - - YY_CHAR *yy_ch_buf; /* input buffer */ - YY_CHAR *yy_buf_pos; /* current position in input buffer */ - - /* size of input buffer in bytes, not including room for EOB characters*/ - int yy_buf_size; - - /* number of characters read into yy_ch_buf, not including EOB characters */ - int yy_n_chars; - - int yy_eof_status; /* whether we've seen an EOF on this buffer */ -#define EOF_NOT_SEEN 0 - /* "pending" happens when the EOF has been seen but there's still - * some text process - */ -#define EOF_PENDING 1 -#define EOF_DONE 2 - }; - -static YY_BUFFER_STATE yy_current_buffer; - -/* we provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state" - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed */ -static YY_CHAR yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - - -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -#ifndef YY_USER_INIT -#define YY_USER_INIT -#endif - -extern YY_CHAR *yytext; -extern int yyleng; -extern FILE *yyin, *yyout; - -YY_CHAR *yytext; -int yyleng; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; - -#define YY_END_OF_BUFFER 40 -typedef int yy_state_type; -static const short int yy_accept[144] = - { 0, - 0, 0, 40, 38, 33, 31, 25, 38, 26, 38, - 22, 26, 22, 22, 38, 26, 37, 29, 27, 29, - 38, 22, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 38, 33, - 29, 0, 36, 27, 23, 30, 37, 0, 34, 37, - 37, 0, 28, 32, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 7, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 24, 37, 0, 0, 37, - 0, 35, 35, 35, 35, 35, 6, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - - 35, 13, 35, 35, 35, 14, 16, 35, 17, 35, - 35, 35, 35, 3, 15, 35, 35, 9, 35, 35, - 2, 35, 35, 11, 35, 35, 12, 20, 35, 10, - 35, 8, 35, 1, 4, 21, 5, 35, 35, 35, - 19, 18, 0 - } ; - -static const YY_CHAR yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 1, 1, 6, 7, 1, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 1, 17, 18, - 19, 20, 1, 1, 21, 21, 21, 21, 21, 21, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 22, 23, 24, 25, 26, 1, 27, 28, 29, 30, - - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 36, 48, 36, - 49, 36, 50, 51, 52, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const YY_CHAR yy_meta[53] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, - 1, 1 - } ; - -static const short int yy_base[146] = - { 0, - 0, 0, 193, 194, 190, 194, 172, 185, 170, 181, - 194, 168, 42, 41, 41, 46, 52, 167, 61, 166, - 181, 164, 135, 137, 139, 148, 140, 136, 0, 149, - 27, 50, 147, 130, 126, 141, 40, 36, 120, 168, - 194, 164, 194, 194, 194, 194, 66, 165, 194, 72, - 76, 164, 194, 194, 0, 120, 134, 124, 131, 117, - 117, 122, 132, 0, 113, 117, 117, 128, 119, 118, - 52, 125, 107, 106, 114, 194, 80, 145, 84, 88, - 144, 105, 118, 98, 108, 111, 0, 95, 95, 93, - 105, 102, 91, 95, 88, 103, 85, 93, 84, 85, - - 90, 0, 90, 91, 85, 0, 0, 93, 0, 77, - 76, 90, 74, 0, 0, 75, 87, 0, 90, 85, - 0, 75, 83, 0, 76, 63, 0, 0, 66, 0, - 62, 0, 47, 0, 0, 0, 0, 45, 53, 29, - 0, 0, 194, 111, 56 - } ; - -static const short int yy_def[146] = - { 0, - 143, 1, 143, 143, 143, 143, 143, 144, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 143, 143, - 143, 144, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 143, 143, 143, 143, 143, - 143, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, - 145, 145, 0, 143, 143 - } ; - -static const short int yy_nxt[247] = - { 0, - 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, - 13, 11, 14, 15, 16, 17, 11, 18, 19, 20, - 17, 11, 21, 11, 22, 4, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 29, 29, 32, 29, 29, - 33, 34, 35, 36, 37, 29, 29, 38, 29, 11, - 39, 11, 46, 46, 63, 49, 47, 55, 64, 44, - 44, 47, 74, 48, 44, 50, 53, 51, 72, 75, - 53, 53, 51, 53, 52, 53, 65, 142, 96, 41, - 66, 77, 73, 141, 67, 53, 77, 80, 78, 50, - 140, 51, 80, 139, 81, 77, 51, 97, 52, 47, - - 77, 138, 78, 80, 47, 137, 48, 136, 80, 135, - 81, 42, 42, 134, 133, 132, 131, 130, 129, 128, - 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, - 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, - 107, 106, 105, 104, 103, 102, 80, 77, 101, 100, - 99, 98, 95, 94, 93, 92, 91, 90, 89, 88, - 87, 86, 85, 84, 83, 82, 51, 79, 43, 40, - 76, 71, 70, 69, 68, 62, 61, 60, 59, 58, - 57, 56, 44, 54, 41, 41, 44, 45, 44, 43, - 41, 40, 143, 3, 143, 143, 143, 143, 143, 143, - - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143 - } ; - -static const short int yy_chk[247] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 13, 14, 31, 16, 15, 145, 31, 14, - 13, 15, 38, 15, 16, 17, 19, 17, 37, 38, - 19, 19, 17, 19, 17, 19, 32, 140, 71, 19, - 32, 47, 37, 139, 32, 19, 47, 50, 47, 51, - 138, 51, 50, 133, 50, 77, 51, 71, 51, 79, - - 77, 131, 77, 80, 79, 129, 79, 126, 80, 125, - 80, 144, 144, 123, 122, 120, 119, 117, 116, 113, - 112, 111, 110, 108, 105, 104, 103, 101, 100, 99, - 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, - 88, 86, 85, 84, 83, 82, 81, 78, 75, 74, - 73, 72, 70, 69, 68, 67, 66, 65, 63, 62, - 61, 60, 59, 58, 57, 56, 52, 48, 42, 40, - 39, 36, 35, 34, 33, 30, 28, 27, 26, 25, - 24, 23, 22, 21, 20, 18, 12, 10, 9, 8, - 7, 5, 3, 143, 143, 143, 143, 143, 143, 143, - - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143 - } ; - -static yy_state_type yy_last_accepting_state; -static YY_CHAR *yy_last_accepting_cpos; - -/* the intent behind this definition is that it'll catch - * any uses of REJECT which flex missed - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 - -/* these variables are all declared out here so that section 3 code can - * manipulate them - */ -/* points to current character in buffer */ -static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr )); -void yyrestart YY_PROTO(( FILE *input_file )); -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); - -#define yy_new_buffer yy_create_buffer - -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif - -YY_DECL - { - register yy_state_type yy_current_state; - register YY_CHAR *yy_cp, *yy_bp; - register int yy_act; - - - - if ( yy_init ) - { - YY_USER_INIT; - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( yy_current_buffer ) - yy_init_buffer( yy_current_buffer, yyin ); - else - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - - yy_init = 0; - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* support of yytext */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of the - * current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[*yy_cp]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = yy_def[yy_current_state]; - if ( yy_current_state >= 144 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 194 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - YY_USER_ACTION; - -do_action: /* this label is used only to access EOF actions */ - - - switch ( yy_act ) - { - case 0: /* must backtrack */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -# line 61 "scan.l" -return(Define); - YY_BREAK -case 2: -# line 62 "scan.l" -return(Break); - YY_BREAK -case 3: -# line 63 "scan.l" -return(Quit); - YY_BREAK -case 4: -# line 64 "scan.l" -return(Length); - YY_BREAK -case 5: -# line 65 "scan.l" -return(Return); - YY_BREAK -case 6: -# line 66 "scan.l" -return(For); - YY_BREAK -case 7: -# line 67 "scan.l" -return(If); - YY_BREAK -case 8: -# line 68 "scan.l" -return(While); - YY_BREAK -case 9: -# line 69 "scan.l" -return(Sqrt); - YY_BREAK -case 10: -# line 70 "scan.l" -return(Scale); - YY_BREAK -case 11: -# line 71 "scan.l" -return(Ibase); - YY_BREAK -case 12: -# line 72 "scan.l" -return(Obase); - YY_BREAK -case 13: -# line 73 "scan.l" -return(Auto); - YY_BREAK -case 14: -# line 74 "scan.l" -return(Else); - YY_BREAK -case 15: -# line 75 "scan.l" -return(Read); - YY_BREAK -case 16: -# line 76 "scan.l" -return(Halt); - YY_BREAK -case 17: -# line 77 "scan.l" -return(Last); - YY_BREAK -case 18: -# line 78 "scan.l" -return(Warranty); - YY_BREAK -case 19: -# line 79 "scan.l" -return(Continue); - YY_BREAK -case 20: -# line 80 "scan.l" -return(Print); - YY_BREAK -case 21: -# line 81 "scan.l" -return(Limits); - YY_BREAK -case 22: -# line 82 "scan.l" -{ yylval.c_value = yytext[0]; - return((int)yytext[0]); } - YY_BREAK -case 23: -# line 84 "scan.l" -{ return(AND); } - YY_BREAK -case 24: -# line 85 "scan.l" -{ return(OR); } - YY_BREAK -case 25: -# line 86 "scan.l" -{ return(NOT); } - YY_BREAK -case 26: -# line 87 "scan.l" -{ yylval.c_value = yytext[0]; return(MUL_OP); } - YY_BREAK -case 27: -# line 88 "scan.l" -{ yylval.c_value = yytext[0]; return(ASSIGN_OP); } - YY_BREAK -case 28: -# line 89 "scan.l" -{ -#ifdef OLD_EQ_OP - char warn_save; - warn_save = warn_not_std; - warn_not_std = TRUE; - warn ("Old fashioned ="); - warn_not_std = warn_save; - yylval.c_value = yytext[1]; -#else - yylval.c_value = '='; - yyless (1); -#endif - return(ASSIGN_OP); - } - YY_BREAK -case 29: -# line 103 "scan.l" -{ yylval.s_value = strcopyof(yytext); return(REL_OP); } - YY_BREAK -case 30: -# line 104 "scan.l" -{ yylval.c_value = yytext[0]; return(INCR_DECR); } - YY_BREAK -case 31: -# line 105 "scan.l" -{ line_no++; return(NEWLINE); } - YY_BREAK -case 32: -# line 106 "scan.l" -{ line_no++; /* ignore a "quoted" newline */ } - YY_BREAK -case 33: -# line 107 "scan.l" -{ /* ignore spaces and tabs */ } - YY_BREAK -case 34: -# line 108 "scan.l" -{ - int c; - - for (;;) - { - while ( ((c=input()) != '*') && (c != EOF)) - /* eat it */ - if (c == '\n') line_no++; - if (c == '*') - { - while ( (c=input()) == '*') /* eat it*/; - if (c == '/') break; /* at end of comment */ - if (c == '\n') line_no++; - } - if (c == EOF) - { - fprintf (stderr,"EOF encountered in a comment.\n"); - break; - } - } - } - YY_BREAK -case 35: -# line 129 "scan.l" -{ yylval.s_value = strcopyof(yytext); return(NAME); } - YY_BREAK -case 36: -# line 130 "scan.l" -{ - unsigned char *look; - int count = 0; - yylval.s_value = strcopyof(yytext); - for (look = yytext; *look != 0; look++) - { - if (*look == '\n') line_no++; - if (*look == '"') count++; - } - if (count != 2) yyerror ("NUL character in string."); - return(STRING); - } - YY_BREAK -case 37: -# line 142 "scan.l" -{ - unsigned char *src, *dst; - int len; - /* remove a trailing decimal point. */ - len = strlen(yytext); - if (yytext[len-1] == '.') - yytext[len-1] = 0; - /* remove leading zeros. */ - src = yytext; - dst = yytext; - while (*src == '0') src++; - if (*src == 0) src--; - /* Copy strings removing the newlines. */ - while (*src != 0) - { - if (*src == '\\') - { - src++; src++; - line_no++; - } - else - *dst++ = *src++; - } - *dst = 0; - yylval.s_value = strcopyof(yytext); - return(NUMBER); - } - YY_BREAK -case 38: -# line 169 "scan.l" -{ - if (yytext[0] < ' ') - yyerror ("illegal character: ^%c",yytext[0] + '@'); - else - if (yytext[0] > '~') - yyerror ("illegal character: \\%3d", (int) yytext[0]); - else - yyerror ("illegal character: %s",yytext); - } - YY_BREAK -case 39: -# line 178 "scan.l" -ECHO; - YY_BREAK -case YY_STATE_EOF(INITIAL): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* amount of text matched not including the EOB char */ - int yy_amount_of_matched_text = yy_cp - yytext - 1; - - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - - /* note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the end- - * of-buffer state). Contrast this with the test in yyinput(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* this was really a NUL */ - { - yy_state_type yy_next_state; - - yy_c_buf_p = yytext + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* okay, we're now positioned to make the - * NUL transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we - * don't want to build jamming into it because - * then it will run more slowly) - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* consume the NUL */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* note: because we've taken care in - * yy_get_next_buffer() to have set up yytext, - * we can now set up yy_c_buf_p so that if some - * total hoser (like flex itself) wants - * to call the scanner after we return the - * YY_NULL, it'll still work - another YY_NULL - * will get returned. - */ - yy_c_buf_p = yytext + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF((yy_start - 1) / 2); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - } - break; - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: -#ifdef FLEX_DEBUG - printf( "action # %d\n", yy_act ); -#endif - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } - } - } - - -/* yy_get_next_buffer - try to read in a new buffer - * - * synopsis - * int yy_get_next_buffer(); - * - * returns a code representing an action - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - - { - register YY_CHAR *dest = yy_current_buffer->yy_ch_buf; - register YY_CHAR *source = yytext - 1; /* copy prev. char, too */ - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - /* try to read more data */ - - /* first move last chars to start of buffer */ - number_to_move = yy_c_buf_p - yytext; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_n_chars = 0; - - else - { - int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - else if ( num_to_read <= 0 ) - YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - - /* read in more data */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == 1 ) - { - ret_val = EOB_ACT_END_OF_FILE; - yy_current_buffer->yy_eof_status = EOF_DONE; - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_eof_status = EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - /* yytext begins at the second character in yy_ch_buf; the first - * character is the one which preceded it before reading in the latest - * buffer; it needs to be kept around in case it's a newline, so - * yy_get_previous_state() will have with '^' rules active - */ - - yytext = &yy_current_buffer->yy_ch_buf[1]; - - return ( ret_val ); - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached - * - * synopsis - * yy_state_type yy_get_previous_state(); - */ - -static yy_state_type yy_get_previous_state() - - { - register yy_state_type yy_current_state; - register YY_CHAR *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = yy_def[yy_current_state]; - if ( yy_current_state >= 144 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - } - - return ( yy_current_state ); - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -register yy_state_type yy_current_state; -#endif - - { - register int yy_is_jam; - register YY_CHAR *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = yy_def[yy_current_state]; - if ( yy_current_state >= 144 ) - yy_c = yy_meta[yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 143); - - return ( yy_is_jam ? 0 : yy_current_state ); - } - - -#ifdef YY_USE_PROTOS -static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp ) -#else -static void yyunput( c, yy_bp ) -YY_CHAR c; -register YY_CHAR *yy_bp; -#endif - - { - register YY_CHAR *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */ - register YY_CHAR *dest = - &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2]; - register YY_CHAR *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += dest - source; - yy_bp += dest - source; - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - if ( yy_cp > yy_bp && yy_cp[-1] == '\n' ) - yy_cp[-2] = '\n'; - - *--yy_cp = c; - - /* note: the formal parameter *must* be called "yy_bp" for this - * macro to now work correctly - */ - YY_DO_BEFORE_ACTION; /* set up yytext again */ - } - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - - { - int c; - YY_CHAR *yy_cp = yy_c_buf_p; - - *yy_cp = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* this was really a NUL */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - yytext = yy_c_buf_p; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - { - yy_c_buf_p = yytext + YY_MORE_ADJ; - return ( EOF ); - } - - YY_NEW_FILE; - -#ifdef __cplusplus - return ( yyinput() ); -#else - return ( input() ); -#endif - } - break; - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext + YY_MORE_ADJ; - break; - - case EOB_ACT_LAST_MATCH: -#ifdef __cplusplus - YY_FATAL_ERROR( "unexpected last match in yyinput()" ); -#else - YY_FATAL_ERROR( "unexpected last match in input()" ); -#endif - } - } - } - - c = *yy_c_buf_p; - yy_hold_char = *++yy_c_buf_p; - - return ( c ); - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - - { - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* flush out information for old buffer */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* we don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) ); - - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) ); - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - yy_init_buffer( b, file ); - - return ( b ); - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - free( (char *) b->yy_ch_buf ); - free( (char *) b ); - } - - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - { - b->yy_input_file = file; - - /* we put in the '\n' and start reading from [1] so that an - * initial match-at-newline will be true. - */ - - b->yy_ch_buf[0] = '\n'; - b->yy_n_chars = 1; - - /* we always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[1]; - - b->yy_eof_status = EOF_NOT_SEEN; - } -# line 178 "scan.l" - - - - -/* This is the way to get multiple files input into lex. */ - -int -yywrap() -{ - if (!open_new_file ()) return (1); /* EOF on standard in. */ - return (0); /* We have more input. */ -} diff --git a/gnu/usr.bin/bc-1.02/scan.l b/gnu/usr.bin/bc-1.02/scan.l deleted file mode 100644 index bb182b6e3fc3..000000000000 --- a/gnu/usr.bin/bc-1.02/scan.l +++ /dev/null @@ -1,189 +0,0 @@ -%{ -/* scan.l: the (f)lex description file for the scanner. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -#include "bcdefs.h" -#include "y.tab.h" -#include "global.h" -#include "proto.h" - -/* Using flex, we can ask for a smaller input buffer. With lex, this - does nothing! */ - -#ifdef SMALL_BUF -#undef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 512 -#endif - -/* We want to define our own yywrap. */ -#undef yywrap -_PROTOTYPE(int yywrap, (void)); - -/* MINIX returns from read with < 0 if SIGINT is encountered. - In flex, we can redefine YY_INPUT to the following. In lex, this - does nothing! */ -#include -#undef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - while ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ - if (errno != EINTR) \ - YY_FATAL_ERROR( "read() in flex scanner failed" ); - -%} -DIGIT [0-9A-F] -LETTER [a-z] -%% -define return(Define); -break return(Break); -quit return(Quit); -length return(Length); -return return(Return); -for return(For); -if return(If); -while return(While); -sqrt return(Sqrt); -scale return(Scale); -ibase return(Ibase); -obase return(Obase); -auto return(Auto); -else return(Else); -read return(Read); -halt return(Halt); -last return(Last); -warranty return(Warranty); -continue return(Continue); -print return(Print); -limits return(Limits); -"+"|"-"|";"|"("|")"|"{"|"}"|"["|"]"|","|"^" { yylval.c_value = yytext[0]; - return((int)yytext[0]); } -&& { return(AND); } -\|\| { return(OR); } -"!" { return(NOT); } -"*"|"/"|"%" { yylval.c_value = yytext[0]; return(MUL_OP); } -"="|\+=|-=|\*=|\/=|%=|\^= { yylval.c_value = yytext[0]; return(ASSIGN_OP); } -=\+|=-|=\*|=\/|=%|=\^ { -#ifdef OLD_EQ_OP - char warn_save; - warn_save = warn_not_std; - warn_not_std = TRUE; - warn ("Old fashioned ="); - warn_not_std = warn_save; - yylval.c_value = yytext[1]; -#else - yylval.c_value = '='; - yyless (1); -#endif - return(ASSIGN_OP); - } -==|\<=|\>=|\!=|"<"|">" { yylval.s_value = strcopyof(yytext); return(REL_OP); } -\+\+|-- { yylval.c_value = yytext[0]; return(INCR_DECR); } -"\n" { line_no++; return(NEWLINE); } -\\\n { line_no++; /* ignore a "quoted" newline */ } -[ \t]+ { /* ignore spaces and tabs */ } -"/*" { - int c; - - for (;;) - { - while ( ((c=input()) != '*') && (c != EOF)) - /* eat it */ - if (c == '\n') line_no++; - if (c == '*') - { - while ( (c=input()) == '*') /* eat it*/; - if (c == '/') break; /* at end of comment */ - if (c == '\n') line_no++; - } - if (c == EOF) - { - fprintf (stderr,"EOF encountered in a comment.\n"); - break; - } - } - } -[a-z][a-z0-9_]* { yylval.s_value = strcopyof(yytext); return(NAME); } -\"[^\"]*\" { - unsigned char *look; - int count = 0; - yylval.s_value = strcopyof(yytext); - for (look = yytext; *look != 0; look++) - { - if (*look == '\n') line_no++; - if (*look == '"') count++; - } - if (count != 2) yyerror ("NUL character in string."); - return(STRING); - } -{DIGIT}({DIGIT}|\\\n)*("."({DIGIT}|\\\n)*)?|"."(\\\n)*{DIGIT}({DIGIT}|\\\n)* { - unsigned char *src, *dst; - int len; - /* remove a trailing decimal point. */ - len = strlen(yytext); - if (yytext[len-1] == '.') - yytext[len-1] = 0; - /* remove leading zeros. */ - src = yytext; - dst = yytext; - while (*src == '0') src++; - if (*src == 0) src--; - /* Copy strings removing the newlines. */ - while (*src != 0) - { - if (*src == '\\') - { - src++; src++; - line_no++; - } - else - *dst++ = *src++; - } - *dst = 0; - yylval.s_value = strcopyof(yytext); - return(NUMBER); - } -. { - if (yytext[0] < ' ') - yyerror ("illegal character: ^%c",yytext[0] + '@'); - else - if (yytext[0] > '~') - yyerror ("illegal character: \\%3d", (int) yytext[0]); - else - yyerror ("illegal character: %s",yytext); - } -%% - - - -/* This is the way to get multiple files input into lex. */ - -int -yywrap() -{ - if (!open_new_file ()) return (1); /* EOF on standard in. */ - return (0); /* We have more input. */ -} diff --git a/gnu/usr.bin/bc-1.02/storage.c b/gnu/usr.bin/bc-1.02/storage.c deleted file mode 100644 index 1edd6e22fc75..000000000000 --- a/gnu/usr.bin/bc-1.02/storage.c +++ /dev/null @@ -1,967 +0,0 @@ -/* storage.c: Code and data storage manipulations. This includes labels. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -#include "bcdefs.h" -#include "global.h" -#include "proto.h" - - -/* Initialize the storage at the beginning of the run. */ - -void -init_storage () -{ - - /* Functions: we start with none and ask for more. */ - f_count = 0; - more_functions (); - f_names[0] = "(main)"; - - /* Variables. */ - v_count = 0; - more_variables (); - - /* Arrays. */ - a_count = 0; - more_arrays (); - - /* Other things... */ - ex_stack = NULL; - fn_stack = NULL; - i_base = 10; - o_base = 10; - scale = 0; - c_code = FALSE; - init_numbers(); -} - -/* Three functions for increasing the number of functions, variables, or - arrays that are needed. This adds another 32 of the requested object. */ - -void -more_functions (VOID) -{ - int old_count; - int indx1, indx2; - bc_function *old_f; - bc_function *f; - char **old_names; - - /* Save old information. */ - old_count = f_count; - old_f = functions; - old_names = f_names; - - /* Add a fixed amount and allocate new space. */ - f_count += STORE_INCR; - functions = (bc_function *) bc_malloc (f_count*sizeof (bc_function)); - f_names = (char **) bc_malloc (f_count*sizeof (char *)); - - /* Copy old ones. */ - for (indx1 = 0; indx1 < old_count; indx1++) - { - functions[indx1] = old_f[indx1]; - f_names[indx1] = old_names[indx1]; - } - - /* Initialize the new ones. */ - for (; indx1 < f_count; indx1++) - { - f = &functions[indx1]; - f->f_defined = FALSE; - for (indx2 = 0; indx2 < BC_MAX_SEGS; indx2++) - f->f_body [indx2] = NULL; - f->f_code_size = 0; - f->f_label = NULL; - f->f_autos = NULL; - f->f_params = NULL; - } - - /* Free the old elements. */ - if (old_count != 0) - { - free (old_f); - free (old_names); - } -} - -void -more_variables () -{ - int indx; - int old_count; - bc_var **old_var; - char **old_names; - - /* Save the old values. */ - old_count = v_count; - old_var = variables; - old_names = v_names; - - /* Increment by a fixed amount and allocate. */ - v_count += STORE_INCR; - variables = (bc_var **) bc_malloc (v_count*sizeof(bc_var *)); - v_names = (char **) bc_malloc (v_count*sizeof(char *)); - - /* Copy the old variables. */ - for (indx = 3; indx < old_count; indx++) - variables[indx] = old_var[indx]; - - /* Initialize the new elements. */ - for (; indx < v_count; indx++) - variables[indx] = NULL; - - /* Free the old elements. */ - if (old_count != 0) - { - free (old_var); - free (old_names); - } -} - -void -more_arrays () -{ - int indx; - int old_count; - bc_var_array **old_ary; - char **old_names; - - /* Save the old values. */ - old_count = a_count; - old_ary = arrays; - old_names = a_names; - - /* Increment by a fixed amount and allocate. */ - a_count += STORE_INCR; - arrays = (bc_var_array **) bc_malloc (a_count*sizeof(bc_var_array *)); - a_names = (char **) bc_malloc (a_count*sizeof(char *)); - - /* Copy the old arrays. */ - for (indx = 1; indx < old_count; indx++) - arrays[indx] = old_ary[indx]; - - - /* Initialize the new elements. */ - for (; indx < v_count; indx++) - arrays[indx] = NULL; - - /* Free the old elements. */ - if (old_count != 0) - { - free (old_ary); - free (old_names); - } -} - - -/* clear_func clears out function FUNC and makes it ready to redefine. */ - -void -clear_func (func) - char func; -{ - bc_function *f; - int indx; - bc_label_group *lg; - - /* Set the pointer to the function. */ - f = &functions[func]; - f->f_defined = FALSE; - - /* Clear the code segments. */ - for (indx = 0; indx < BC_MAX_SEGS; indx++) - { - if (f->f_body[indx] != NULL) - { - free (f->f_body[indx]); - f->f_body[indx] = NULL; - } - } - - f->f_code_size = 0; - if (f->f_autos != NULL) - { - free_args (f->f_autos); - f->f_autos = NULL; - } - if (f->f_params != NULL) - { - free_args (f->f_params); - f->f_params = NULL; - } - while (f->f_label != NULL) - { - lg = f->f_label->l_next; - free (f->f_label); - f->f_label = lg; - } -} - - -/* Pop the function execution stack and return the top. */ - -int -fpop() -{ - fstack_rec *temp; - int retval; - - if (fn_stack != NULL) - { - temp = fn_stack; - fn_stack = temp->s_next; - retval = temp->s_val; - free (temp); - } - return (retval); -} - - -/* Push VAL on to the function stack. */ - -void -fpush (val) - int val; -{ - fstack_rec *temp; - - temp = (fstack_rec *) bc_malloc (sizeof (fstack_rec)); - temp->s_next = fn_stack; - temp->s_val = val; - fn_stack = temp; -} - - -/* Pop and discard the top element of the regular execution stack. */ - -void -pop () -{ - estack_rec *temp; - - if (ex_stack != NULL) - { - temp = ex_stack; - ex_stack = temp->s_next; - free_num (&temp->s_num); - free (temp); - } -} - - -/* Push a copy of NUM on to the regular execution stack. */ - -void -push_copy (num) - bc_num num; -{ - estack_rec *temp; - - temp = (estack_rec *) bc_malloc (sizeof (estack_rec)); - temp->s_num = copy_num (num); - temp->s_next = ex_stack; - ex_stack = temp; -} - - -/* Push NUM on to the regular execution stack. Do NOT push a copy. */ - -void -push_num (num) - bc_num num; -{ - estack_rec *temp; - - temp = (estack_rec *) bc_malloc (sizeof (estack_rec)); - temp->s_num = num; - temp->s_next = ex_stack; - ex_stack = temp; -} - - -/* Make sure the ex_stack has at least DEPTH elements on it. - Return TRUE if it has at least DEPTH elements, otherwise - return FALSE. */ - -char -check_stack (depth) - int depth; -{ - estack_rec *temp; - - temp = ex_stack; - while ((temp != NULL) && (depth > 0)) - { - temp = temp->s_next; - depth--; - } - if (depth > 0) - { - rt_error ("Stack error."); - return FALSE; - } - return TRUE; -} - - -/* The following routines manipulate simple variables and - array variables. */ - -/* get_var returns a pointer to the variable VAR_NAME. If one does not - exist, one is created. */ - -bc_var * -get_var (var_name) - int var_name; -{ - bc_var *var_ptr; - - var_ptr = variables[var_name]; - if (var_ptr == NULL) - { - var_ptr = variables[var_name] = (bc_var *) bc_malloc (sizeof (bc_var)); - init_num (&var_ptr->v_value); - } - return var_ptr; -} - - -/* get_array_num returns the address of the bc_num in the array - structure. If more structure is requried to get to the index, - this routine does the work to create that structure. VAR_INDEX - is a zero based index into the arrays storage array. INDEX is - the index into the bc array. */ - -bc_num * -get_array_num (var_index, index) - int var_index; - long index; -{ - bc_var_array *ary_ptr; - bc_array *a_var; - bc_array_node *temp; - int log, ix, ix1; - int sub [NODE_DEPTH]; - - /* Get the array entry. */ - ary_ptr = arrays[var_index]; - if (ary_ptr == NULL) - { - ary_ptr = arrays[var_index] = - (bc_var_array *) bc_malloc (sizeof (bc_var_array)); - ary_ptr->a_value = NULL; - ary_ptr->a_next = NULL; - ary_ptr->a_param = FALSE; - } - - a_var = ary_ptr->a_value; - if (a_var == NULL) { - a_var = ary_ptr->a_value = (bc_array *) bc_malloc (sizeof (bc_array)); - a_var->a_tree = NULL; - a_var->a_depth = 0; - } - - /* Get the index variable. */ - sub[0] = index & NODE_MASK; - ix = index >> NODE_SHIFT; - log = 1; - while (ix > 0 || log < a_var->a_depth) - { - sub[log] = ix & NODE_MASK; - ix >>= NODE_SHIFT; - log++; - } - - /* Build any tree that is necessary. */ - while (log > a_var->a_depth) - { - temp = (bc_array_node *) bc_malloc (sizeof(bc_array_node)); - if (a_var->a_depth != 0) - { - temp->n_items.n_down[0] = a_var->a_tree; - for (ix=1; ix < NODE_SIZE; ix++) - temp->n_items.n_down[ix] = NULL; - } - else - { - for (ix=0; ix < NODE_SIZE; ix++) - temp->n_items.n_num[ix] = copy_num(_zero_); - } - a_var->a_tree = temp; - a_var->a_depth++; - } - - /* Find the indexed variable. */ - temp = a_var->a_tree; - while ( log-- > 1) - { - ix1 = sub[log]; - if (temp->n_items.n_down[ix1] == NULL) - { - temp->n_items.n_down[ix1] = - (bc_array_node *) bc_malloc (sizeof(bc_array_node)); - temp = temp->n_items.n_down[ix1]; - if (log > 1) - for (ix=0; ix < NODE_SIZE; ix++) - temp->n_items.n_down[ix] = NULL; - else - for (ix=0; ix < NODE_SIZE; ix++) - temp->n_items.n_num[ix] = copy_num(_zero_); - } - else - temp = temp->n_items.n_down[ix1]; - } - - /* Return the address of the indexed variable. */ - return &(temp->n_items.n_num[sub[0]]); -} - - -/* Store the top of the execution stack into VAR_NAME. - This includes the special variables ibase, obase, and scale. */ - -void -store_var (var_name) - int var_name; -{ - bc_var *var_ptr; - long temp; - char toobig; - - if (var_name > 2) - { - /* It is a simple variable. */ - var_ptr = get_var (var_name); - if (var_ptr != NULL) - { - free_num(&var_ptr->v_value); - var_ptr->v_value = copy_num (ex_stack->s_num); - } - } - else - { - /* It is a special variable... */ - toobig = FALSE; - if (is_neg (ex_stack->s_num)) - { - switch (var_name) - { - case 0: - rt_warn ("negative ibase, set to 2"); - temp = 2; - break; - case 1: - rt_warn ("negative obase, set to 2"); - temp = 2; - break; - case 2: - rt_warn ("negative scale, set to 0"); - temp = 0; - break; - } - } - else - { - temp = num2long (ex_stack->s_num); - if (!is_zero (ex_stack->s_num) && temp == 0) - toobig = TRUE; - } - switch (var_name) - { - case 0: - if (temp < 2 && !toobig) - { - i_base = 2; - rt_warn ("ibase too small, set to 2"); - } - else - if (temp > 16 || toobig) - { - i_base = 16; - rt_warn ("ibase too large, set to 16"); - } - else - i_base = (int) temp; - break; - - case 1: - if (temp < 2 && !toobig) - { - o_base = 2; - rt_warn ("obase too small, set to 2"); - } - else - if (temp > BC_BASE_MAX || toobig) - { - o_base = BC_BASE_MAX; - rt_warn ("obase too large, set to %d", BC_BASE_MAX); - } - else - o_base = (int) temp; - break; - - case 2: - /* WARNING: The following if statement may generate a compiler - warning if INT_MAX == LONG_MAX. This is NOT a problem. */ - if (temp > BC_SCALE_MAX || toobig ) - { - scale = BC_SCALE_MAX; - rt_warn ("scale too large, set to %d", BC_SCALE_MAX); - } - else - scale = (int) temp; - } - } -} - - -/* Store the top of the execution stack into array VAR_NAME. - VAR_NAME is the name of an array, and the next to the top - of stack for the index into the array. */ - -void -store_array (var_name) - int var_name; -{ - bc_num *num_ptr; - long index; - - if (!check_stack(2)) return; - index = num2long (ex_stack->s_next->s_num); - if (index < 0 || index > BC_DIM_MAX || - (index == 0 && !is_zero(ex_stack->s_next->s_num))) - rt_error ("Array %s subscript out of bounds.", a_names[var_name]); - else - { - num_ptr = get_array_num (var_name, index); - if (num_ptr != NULL) - { - free_num (num_ptr); - *num_ptr = copy_num (ex_stack->s_num); - free_num (&ex_stack->s_next->s_num); - ex_stack->s_next->s_num = ex_stack->s_num; - init_num (&ex_stack->s_num); - pop(); - } - } -} - - -/* Load a copy of VAR_NAME on to the execution stack. This includes - the special variables ibase, obase and scale. */ - -void -load_var (var_name) - int var_name; -{ - bc_var *var_ptr; - - switch (var_name) - { - - case 0: - /* Special variable ibase. */ - push_copy (_zero_); - int2num (&ex_stack->s_num, i_base); - break; - - case 1: - /* Special variable obase. */ - push_copy (_zero_); - int2num (&ex_stack->s_num, o_base); - break; - - case 2: - /* Special variable scale. */ - push_copy (_zero_); - int2num (&ex_stack->s_num, scale); - break; - - default: - /* It is a simple variable. */ - var_ptr = variables[var_name]; - if (var_ptr != NULL) - push_copy (var_ptr->v_value); - else - push_copy (_zero_); - } -} - - -/* Load a copy of VAR_NAME on to the execution stack. This includes - the special variables ibase, obase and scale. */ - -void -load_array (var_name) - int var_name; -{ - bc_num *num_ptr; - long index; - - if (!check_stack(1)) return; - index = num2long (ex_stack->s_num); - if (index < 0 || index > BC_DIM_MAX || - (index == 0 && !is_zero(ex_stack->s_num))) - rt_error ("Array %s subscript out of bounds.", a_names[var_name]); - else - { - num_ptr = get_array_num (var_name, index); - if (num_ptr != NULL) - { - pop(); - push_copy (*num_ptr); - } - } -} - - -/* Decrement VAR_NAME by one. This includes the special variables - ibase, obase, and scale. */ - -void -decr_var (var_name) - int var_name; -{ - bc_var *var_ptr; - - switch (var_name) - { - - case 0: /* ibase */ - if (i_base > 2) - i_base--; - else - rt_warn ("ibase too small in --"); - break; - - case 1: /* obase */ - if (o_base > 2) - o_base--; - else - rt_warn ("obase too small in --"); - break; - - case 2: /* scale */ - if (scale > 0) - scale--; - else - rt_warn ("scale can not be negative in -- "); - break; - - default: /* It is a simple variable. */ - var_ptr = get_var (var_name); - if (var_ptr != NULL) - bc_sub (var_ptr->v_value,_one_,&var_ptr->v_value); - } -} - - -/* Decrement VAR_NAME by one. VAR_NAME is an array, and the top of - the execution stack is the index and it is popped off the stack. */ - -void -decr_array (var_name) - char var_name; -{ - bc_num *num_ptr; - long index; - - /* It is an array variable. */ - if (!check_stack (1)) return; - index = num2long (ex_stack->s_num); - if (index < 0 || index > BC_DIM_MAX || - (index == 0 && !is_zero (ex_stack->s_num))) - rt_error ("Array %s subscript out of bounds.", a_names[var_name]); - else - { - num_ptr = get_array_num (var_name, index); - if (num_ptr != NULL) - { - pop (); - bc_sub (*num_ptr, _one_, num_ptr); - } - } -} - - -/* Increment VAR_NAME by one. This includes the special variables - ibase, obase, and scale. */ - -void -incr_var (var_name) - int var_name; -{ - bc_var *var_ptr; - - switch (var_name) - { - - case 0: /* ibase */ - if (i_base < 16) - i_base++; - else - rt_warn ("ibase too big in ++"); - break; - - case 1: /* obase */ - if (o_base < BC_BASE_MAX) - o_base++; - else - rt_warn ("obase too big in ++"); - break; - - case 2: - if (scale < BC_SCALE_MAX) - scale++; - else - rt_warn ("Scale too big in ++"); - break; - - default: /* It is a simple variable. */ - var_ptr = get_var (var_name); - if (var_ptr != NULL) - bc_add (var_ptr->v_value, _one_, &var_ptr->v_value); - - } -} - - -/* Increment VAR_NAME by one. VAR_NAME is an array and top of - execution stack is the index and is popped off the stack. */ - -void -incr_array (var_name) - int var_name; -{ - bc_num *num_ptr; - long index; - - if (!check_stack (1)) return; - index = num2long (ex_stack->s_num); - if (index < 0 || index > BC_DIM_MAX || - (index == 0 && !is_zero (ex_stack->s_num))) - rt_error ("Array %s subscript out of bounds.", a_names[var_name]); - else - { - num_ptr = get_array_num (var_name, index); - if (num_ptr != NULL) - { - pop (); - bc_add (*num_ptr, _one_, num_ptr); - } - } -} - - -/* Routines for processing autos variables and parameters. */ - -/* NAME is an auto variable that needs to be pushed on its stack. */ - -void -auto_var (name) - int name; -{ - bc_var *v_temp; - bc_var_array *a_temp; - int ix; - - if (name > 0) - { - /* A simple variable. */ - ix = name; - v_temp = (bc_var *) bc_malloc (sizeof (bc_var)); - v_temp->v_next = variables[ix]; - init_num (&v_temp->v_value); - variables[ix] = v_temp; - } - else - { - /* An array variable. */ - ix = -name; - a_temp = (bc_var_array *) bc_malloc (sizeof (bc_var_array)); - a_temp->a_next = arrays[ix]; - a_temp->a_value = NULL; - a_temp->a_param = FALSE; - arrays[ix] = a_temp; - } -} - - -/* Free_a_tree frees everything associated with an array variable tree. - This is used when popping an array variable off its auto stack. */ - -void -free_a_tree ( root, depth ) - bc_array_node *root; - int depth; -{ - int ix; - - if (root != NULL) - { - if (depth > 1) - for (ix = 0; ix < NODE_SIZE; ix++) - free_a_tree (root->n_items.n_down[ix], depth-1); - else - for (ix = 0; ix < NODE_SIZE; ix++) - free_num ( &(root->n_items.n_num[ix])); - free (root); - } -} - - -/* LIST is an NULL terminated list of varible names that need to be - popped off their auto stacks. */ - -void -pop_vars (list) - arg_list *list; -{ - bc_var *v_temp; - bc_var_array *a_temp; - int ix; - - while (list != NULL) - { - ix = list->av_name; - if (ix > 0) - { - /* A simple variable. */ - v_temp = variables[ix]; - if (v_temp != NULL) - { - variables[ix] = v_temp->v_next; - free_num (&v_temp->v_value); - free (v_temp); - } - } - else - { - /* An array variable. */ - ix = -ix; - a_temp = arrays[ix]; - if (a_temp != NULL) - { - arrays[ix] = a_temp->a_next; - if (!a_temp->a_param && a_temp->a_value != NULL) - { - free_a_tree (a_temp->a_value->a_tree, - a_temp->a_value->a_depth); - free (a_temp->a_value); - } - free (a_temp); - } - } - list = list->next; - } -} - - -/* A call is being made to FUNC. The call types are at PC. Process - the parameters by doing an auto on the parameter variable and then - store the value at the new variable or put a pointer the the array - variable. */ - -void -process_params (pc, func) - program_counter *pc; - int func; -{ - char ch; - arg_list *params; - char warned = FALSE; - int ix, ix1; - bc_var *v_temp; - bc_var_array *a_src, *a_dest; - bc_num *n_temp; - - /* Get the parameter names from the function. */ - params = functions[func].f_params; - - while ((ch = byte(pc)) != ':') - { - if (params != NULL) - { - if ((ch == '0') && params->av_name > 0) - { - /* A simple variable. */ - ix = params->av_name; - v_temp = (bc_var *) bc_malloc (sizeof(bc_var)); - v_temp->v_next = variables[ix]; - v_temp->v_value = ex_stack->s_num; - init_num (&ex_stack->s_num); - variables[ix] = v_temp; - } - else - if ((ch == '1') && (params->av_name < 0)) - { - /* The variables is an array variable. */ - - /* Compute source index and make sure some structure exists. */ - ix = (int) num2long (ex_stack->s_num); - n_temp = get_array_num (ix, 0); - - /* Push a new array and Compute Destination index */ - auto_var (params->av_name); - ix1 = -params->av_name; - - /* Set up the correct pointers in the structure. */ - if (ix == ix1) - a_src = arrays[ix]->a_next; - else - a_src = arrays[ix]; - a_dest = arrays[ix1]; - a_dest->a_param = TRUE; - a_dest->a_value = a_src->a_value; - } - else - { - if (params->av_name < 0) - rt_error ("Parameter type mismatch parameter %s.", - a_names[-params->av_name]); - else - rt_error ("Parameter type mismatch, parameter %s.", - v_names[params->av_name]); - params++; - } - pop (); - } - else - { - if (!warned) - { - rt_error ("Parameter number mismatch"); - warned = TRUE; - } - } - params = params->next; - } - if (params != NULL) - rt_error ("Parameter number mismatch"); -} diff --git a/gnu/usr.bin/bc-1.02/util.c b/gnu/usr.bin/bc-1.02/util.c deleted file mode 100644 index 954c7199c9e4..000000000000 --- a/gnu/usr.bin/bc-1.02/util.c +++ /dev/null @@ -1,794 +0,0 @@ -/* util.c: Utility routines for bc. */ - -/* This file is part of bc written for MINIX. - Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@cs.wwu.edu - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - - -#include "bcdefs.h" -#ifndef VARARGS -#include -#else -#include -#endif -#include "global.h" -#include "proto.h" - - -/* strcopyof mallocs new memory and copies a string to to the new - memory. */ - -char * -strcopyof (str) - char *str; -{ - char *temp; - - temp = (char *) bc_malloc (strlen (str)+1); - return (strcpy (temp,str)); -} - - -/* nextarg adds another value to the list of arguments. */ - -arg_list * -nextarg (args, val) - arg_list *args; - char val; -{ arg_list *temp; - - temp = (arg_list *) bc_malloc (sizeof (arg_list)); - temp->av_name = val; - temp->next = args; - - return (temp); -} - - -/* For generate, we must produce a string in the form - "val,val,...,val". We also need a couple of static variables - for retaining old generated strings. It also uses a recursive - function that builds the string. */ - -static char *arglist1 = NULL, *arglist2 = NULL; - - -/* make_arg_str does the actual construction of the argument string. - ARGS is the pointer to the list and LEN is the maximum number of - characters needed. 1 char is the minimum needed. COMMAS tells - if each number should be seperated by commas.*/ - -_PROTOTYPE (static char *make_arg_str, (arg_list *args, int len, int commas)); - -static char * -make_arg_str (args, len, commas) - arg_list *args; - int len; - int commas; -{ - char *temp; - char sval[20]; - - /* Recursive call. */ - if (args != NULL) - temp = make_arg_str (args->next, len+11, commas); - else - { - temp = (char *) bc_malloc (len); - *temp = 0; - return temp; - } - - /* Add the current number to the end of the string. */ - if (len != 1 && commas) - sprintf (sval, "%d,", args->av_name); - else - sprintf (sval, "%d", args->av_name); - temp = strcat (temp, sval); - return (temp); -} - -char * -arg_str (args, commas) - arg_list *args; - int commas; -{ - if (arglist2 != NULL) - free (arglist2); - arglist2 = arglist1; - arglist1 = make_arg_str (args, 1, commas); - return (arglist1); -} - - -/* free_args frees an argument list ARGS. */ - -void -free_args (args) - arg_list *args; -{ - arg_list *temp; - - temp = args; - while (temp != NULL) - { - args = args->next; - free (temp); - temp = args; - } -} - - -/* Check for valid parameter (PARAMS) and auto (AUTOS) lists. - There must be no duplicates any where. Also, this is where - warnings are generated for array parameters. */ - -void -check_params ( params, autos ) - arg_list *params, *autos; -{ - arg_list *tmp1, *tmp2; - - /* Check for duplicate parameters. */ - if (params != NULL) - { - tmp1 = params; - while (tmp1 != NULL) - { - tmp2 = tmp1->next; - while (tmp2 != NULL) - { - if (tmp2->av_name == tmp1->av_name) - yyerror ("duplicate parameter names"); - tmp2 = tmp2->next; - } - if (tmp1->av_name < 0) - warn ("Array parameter"); - tmp1 = tmp1->next; - } - } - - /* Check for duplicate autos. */ - if (autos != NULL) - { - tmp1 = autos; - while (tmp1 != NULL) - { - tmp2 = tmp1->next; - while (tmp2 != NULL) - { - if (tmp2->av_name == tmp1->av_name) - yyerror ("duplicate auto variable names"); - tmp2 = tmp2->next; - } - tmp1 = tmp1->next; - } - } - - /* Check for duplicate between parameters and autos. */ - if ((params != NULL) && (autos != NULL)) - { - tmp1 = params; - while (tmp1 != NULL) - { - tmp2 = autos; - while (tmp2 != NULL) - { - if (tmp2->av_name == tmp1->av_name) - yyerror ("variable in both parameter and auto lists"); - tmp2 = tmp2->next; - } - tmp1 = tmp1->next; - } - } -} - - -/* Initialize the code generator the parser. */ - -void -init_gen () -{ - /* Get things ready. */ - break_label = 0; - continue_label = 0; - next_label = 1; - out_count = 2; - if (compile_only) - printf ("@i"); - else - init_load (); - had_error = FALSE; - did_gen = FALSE; -} - - -/* generate code STR for the machine. */ - -void -generate (str) - char *str; -{ - did_gen = TRUE; - if (compile_only) - { - printf ("%s",str); - out_count += strlen(str); - if (out_count > 60) - { - printf ("\n"); - out_count = 0; - } - } - else - load_code (str); -} - - -/* Execute the current code as loaded. */ - -void -run_code() -{ - /* If no compile errors run the current code. */ - if (!had_error && did_gen) - { - if (compile_only) - { - printf ("@r\n"); - out_count = 0; - } - else - execute (); - } - - /* Reinitialize the code generation and machine. */ - if (did_gen) - init_gen(); - else - had_error = FALSE; -} - - -/* Output routines: Write a character CH to the standard output. - It keeps track of the number of characters output and may - break the output with a "\". */ - -void -out_char (ch) - char ch; -{ - if (ch == '\n') - { - out_col = 0; - putchar ('\n'); - } - else - { - out_col++; - if (out_col == 70) - { - putchar ('\\'); - putchar ('\n'); - out_col = 1; - } - putchar (ch); - } -} - - -/* The following are "Symbol Table" routines for the parser. */ - -/* find_id returns a pointer to node in TREE that has the correct - ID. If there is no node in TREE with ID, NULL is returned. */ - -id_rec * -find_id (tree, id) - id_rec *tree; - char *id; -{ - int cmp_result; - - /* Check for an empty tree. */ - if (tree == NULL) - return NULL; - - /* Recursively search the tree. */ - cmp_result = strcmp (id, tree->id); - if (cmp_result == 0) - return tree; /* This is the item. */ - else if (cmp_result < 0) - return find_id (tree->left, id); - else - return find_id (tree->right, id); -} - - -/* insert_id_rec inserts a NEW_ID rec into the tree whose ROOT is - provided. insert_id_rec returns TRUE if the tree height from - ROOT down is increased otherwise it returns FALSE. This is a - recursive balanced binary tree insertion algorithm. */ - -int insert_id_rec (root, new_id) - id_rec **root; - id_rec *new_id; -{ - id_rec *A, *B; - - /* If root is NULL, this where it is to be inserted. */ - if (*root == NULL) - { - *root = new_id; - new_id->left = NULL; - new_id->right = NULL; - new_id->balance = 0; - return (TRUE); - } - - /* We need to search for a leaf. */ - if (strcmp (new_id->id, (*root)->id) < 0) - { - /* Insert it on the left. */ - if (insert_id_rec (&((*root)->left), new_id)) - { - /* The height increased. */ - (*root)->balance --; - - switch ((*root)->balance) - { - case 0: /* no height increase. */ - return (FALSE); - case -1: /* height increase. */ - return (FALSE); - case -2: /* we need to do a rebalancing act. */ - A = *root; - B = (*root)->left; - if (B->balance <= 0) - { - /* Single Rotate. */ - A->left = B->right; - B->right = A; - *root = B; - A->balance = 0; - B->balance = 0; - } - else - { - /* Double Rotate. */ - *root = B->right; - B->right = (*root)->left; - A->left = (*root)->right; - (*root)->left = B; - (*root)->right = A; - switch ((*root)->balance) - { - case -1: - A->balance = 1; - B->balance = 0; - break; - case 0: - A->balance = 0; - B->balance = 0; - break; - case 1: - A->balance = 0; - B->balance = -1; - break; - } - (*root)->balance = 0; - } - } - } - } - else - { - /* Insert it on the right. */ - if (insert_id_rec (&((*root)->right), new_id)) - { - /* The height increased. */ - (*root)->balance ++; - switch ((*root)->balance) - { - case 0: /* no height increase. */ - return (FALSE); - case 1: /* height increase. */ - return (FALSE); - case 2: /* we need to do a rebalancing act. */ - A = *root; - B = (*root)->right; - if (B->balance >= 0) - { - /* Single Rotate. */ - A->right = B->left; - B->left = A; - *root = B; - A->balance = 0; - B->balance = 0; - } - else - { - /* Double Rotate. */ - *root = B->left; - B->left = (*root)->right; - A->right = (*root)->left; - (*root)->left = A; - (*root)->right = B; - switch ((*root)->balance) - { - case -1: - A->balance = 0; - B->balance = 1; - break; - case 0: - A->balance = 0; - B->balance = 0; - break; - case 1: - A->balance = -1; - B->balance = 0; - break; - } - (*root)->balance = 0; - } - } - } - } - - /* If we fall through to here, the tree did not grow in height. */ - return (FALSE); -} - - -/* Initialize variables for the symbol table tree. */ - -void -init_tree() -{ - name_tree = NULL; - next_array = 1; - next_func = 1; - next_var = 4; /* 0 => ibase, 1 => obase, 2 => scale, 3 => last. */ -} - - -/* Lookup routines for symbol table names. */ - -int -lookup (name, namekind) - char *name; - int namekind; -{ - id_rec *id; - - /* Warn about non-standard name. */ - if (strlen(name) != 1) - warn ("multiple letter name - %s", name); - - /* Look for the id. */ - id = find_id (name_tree, name); - if (id == NULL) - { - /* We need to make a new item. */ - id = (id_rec *) bc_malloc (sizeof (id_rec)); - id->id = strcopyof (name); - id->a_name = 0; - id->f_name = 0; - id->v_name = 0; - insert_id_rec (&name_tree, id); - } - - /* Return the correct value. */ - switch (namekind) - { - - case ARRAY: - /* ARRAY variable numbers are returned as negative numbers. */ - if (id->a_name != 0) - { - free (name); - return (-id->a_name); - } - id->a_name = next_array++; - a_names[id->a_name] = name; - if (id->a_name < MAX_STORE) - { - if (id->a_name >= a_count) - more_arrays (); - return (-id->a_name); - } - yyerror ("Too many array variables"); - exit (1); - - case FUNCT: - if (id->f_name != 0) - { - free(name); - return (id->f_name); - } - id->f_name = next_func++; - f_names[id->f_name] = name; - if (id->f_name < MAX_STORE) - { - if (id->f_name >= f_count) - more_functions (); - return (id->f_name); - } - yyerror ("Too many functions"); - exit (1); - - case SIMPLE: - if (id->v_name != 0) - { - free(name); - return (id->v_name); - } - id->v_name = next_var++; - v_names[id->v_name - 1] = name; - if (id->v_name <= MAX_STORE) - { - if (id->v_name >= v_count) - more_variables (); - return (id->v_name); - } - yyerror ("Too many variables"); - exit (1); - } -} - - -/* Print the welcome banner. */ - -void -welcome() -{ - printf ("This is free software with ABSOLUTELY NO WARRANTY.\n"); - printf ("For details type `warranty'. \n"); -} - - -/* Print out the warranty information. */ - -void -warranty(prefix) - char *prefix; -{ - printf ("\n%s%s\n\n", prefix, BC_VERSION); - printf ("%s%s%s%s%s%s%s%s%s%s%s", -" This program is free software; you can redistribute it and/or modify\n", -" it under the terms of the GNU General Public License as published by\n", -" the Free Software Foundation; either version 2 of the License , or\n", -" (at your option) any later version.\n\n", -" This program is distributed in the hope that it will be useful,\n", -" but WITHOUT ANY WARRANTY; without even the implied warranty of\n", -" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n", -" GNU General Public License for more details.\n\n", -" You should have received a copy of the GNU General Public License\n", -" along with this program. If not, write to the Free Software\n", -" Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.\n\n"); -} - -/* Print out the limits of this program. */ - -void -limits() -{ - printf ("BC_BASE_MAX = %d\n", BC_BASE_MAX); - printf ("BC_DIM_MAX = %ld\n", (long) BC_DIM_MAX); - printf ("BC_SCALE_MAX = %d\n", BC_SCALE_MAX); - printf ("BC_STRING_MAX = %d\n", BC_STRING_MAX); - printf ("MAX Exponent = %ld\n", (long) LONG_MAX); - printf ("MAX code = %ld\n", (long) BC_MAX_SEGS * (long) BC_SEG_SIZE); - printf ("multiply digits = %ld\n", (long) LONG_MAX / (long) 90); - printf ("Number of vars = %ld\n", (long) MAX_STORE); -#ifdef OLD_EQ_OP - printf ("Old assignment operatiors are valid. (=-, =+, ...)\n"); -#endif -} - -/* bc_malloc will check the return value so all other places do not - have to do it! SIZE is the number of types to allocate. */ - -char * -bc_malloc (size) - int size; -{ - char *ptr; - - ptr = (char *) malloc (size); - if (ptr == NULL) - out_of_memory (); - - return ptr; -} - - -/* The following routines are error routines for various problems. */ - -/* Malloc could not get enought memory. */ - -void -out_of_memory() -{ - fprintf (stderr, "Fatal error: Out of memory for malloc.\n"); - exit (1); -} - - - -/* The standard yyerror routine. Built with variable number of argumnets. */ - -#ifndef VARARGS -#ifdef __STDC__ -void -yyerror (char *str, ...) -#else -void -yyerror (str) - char *str; -#endif -#else -void -yyerror (str, va_alist) - char *str; -#endif -{ - char *name; - va_list args; - -#ifndef VARARGS - va_start (args, str); -#else - va_start (args); -#endif - if (is_std_in) - name = "(standard_in)"; - else - name = g_argv[optind-1]; - fprintf (stderr,"%s %d: ",name,line_no); - vfprintf (stderr, str, args); - fprintf (stderr, "\n"); - had_error = TRUE; - va_end (args); -} - - -/* The routine to produce warnings about non-standard features - found during parsing. */ - -#ifndef VARARGS -#ifdef __STDC__ -void -warn (char *mesg, ...) -#else -void -warn (mesg) - char *mesg; -#endif -#else -void -warn (mesg, va_alist) - char *mesg; -#endif -{ - char *name; - va_list args; - -#ifndef VARARGS - va_start (args, mesg); -#else - va_start (args); -#endif - if (std_only) - { - if (is_std_in) - name = "(standard_in)"; - else - name = g_argv[optind-1]; - fprintf (stderr,"%s %d: ",name,line_no); - vfprintf (stderr, mesg, args); - fprintf (stderr, "\n"); - had_error = TRUE; - } - else - if (warn_not_std) - { - if (is_std_in) - name = "(standard_in)"; - else - name = g_argv[optind-1]; - fprintf (stderr,"%s %d: (Warning) ",name,line_no); - vfprintf (stderr, mesg, args); - fprintf (stderr, "\n"); - } - va_end (args); -} - -/* Runtime error will print a message and stop the machine. */ - -#ifndef VARARGS -#ifdef __STDC__ -void -rt_error (char *mesg, ...) -#else -void -rt_error (mesg) - char *mesg; -#endif -#else -void -rt_error (mesg, va_alist) - char *mesg; -#endif -{ - va_list args; - char error_mesg [255]; - -#ifndef VARARGS - va_start (args, mesg); -#else - va_start (args); -#endif - vsprintf (error_mesg, mesg, args); - va_end (args); - - fprintf (stderr, "Runtime error (func=%s, adr=%d): %s\n", - f_names[pc.pc_func], pc.pc_addr, error_mesg); - runtime_error = TRUE; -} - - -/* A runtime warning tells of some action taken by the processor that - may change the program execution but was not enough of a problem - to stop the execution. */ - -#ifndef VARARGS -#ifdef __STDC__ -void -rt_warn (char *mesg, ...) -#else -void -rt_warn (mesg) - char *mesg; -#endif -#else -void -rt_warn (mesg, va_alist) - char *mesg; -#endif -{ - va_list args; - char error_mesg [255]; - -#ifndef VARARGS - va_start (args, mesg); -#else - va_start (args); -#endif - vsprintf (error_mesg, mesg, args); - va_end (args); - - fprintf (stderr, "Runtime warning (func=%s, adr=%d): %s\n", - f_names[pc.pc_func], pc.pc_addr, error_mesg); -} diff --git a/gnu/usr.bin/bc-1.02/version.h b/gnu/usr.bin/bc-1.02/version.h deleted file mode 100644 index 6b3f909639d8..000000000000 --- a/gnu/usr.bin/bc-1.02/version.h +++ /dev/null @@ -1,3 +0,0 @@ -#define BC_VERSION \ - "bc 1.02 (Mar 3, 92) Copyright (C) 1991, 1992 Free Software Foundation, Inc." - diff --git a/gnu/usr.bin/bc-1.02/vfprintf.c b/gnu/usr.bin/bc-1.02/vfprintf.c deleted file mode 100644 index 4c0091032926..000000000000 --- a/gnu/usr.bin/bc-1.02/vfprintf.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include - -int vfprintf(file, format, argp) -FILE *file; -_CONST char *format; -va_list argp; -{ - _doprintf(file, format, argp); - if (testflag(file, PERPRINTF)) fflush(file); - return 0; -} diff --git a/gnu/usr.bin/bc-1.02/y.tab.h.dist b/gnu/usr.bin/bc-1.02/y.tab.h.dist deleted file mode 100644 index 9e65a2f20ff8..000000000000 --- a/gnu/usr.bin/bc-1.02/y.tab.h.dist +++ /dev/null @@ -1,40 +0,0 @@ -#define NEWLINE 257 -#define AND 258 -#define OR 259 -#define NOT 260 -#define STRING 261 -#define NAME 262 -#define NUMBER 263 -#define MUL_OP 264 -#define ASSIGN_OP 265 -#define REL_OP 266 -#define INCR_DECR 267 -#define Define 268 -#define Break 269 -#define Quit 270 -#define Length 271 -#define Return 272 -#define For 273 -#define If 274 -#define While 275 -#define Sqrt 276 -#define Else 277 -#define Scale 278 -#define Ibase 279 -#define Obase 280 -#define Auto 281 -#define Read 282 -#define Warranty 283 -#define Halt 284 -#define Last 285 -#define Continue 286 -#define Print 287 -#define Limits 288 -#define UNARY_MINUS 289 -typedef union { - char *s_value; - char c_value; - int i_value; - arg_list *a_value; - } YYSTYPE; -extern YYSTYPE yylval; diff --git a/gnu/usr.bin/fgrep/fgrep b/gnu/usr.bin/fgrep/fgrep deleted file mode 100644 index 309e3b1a45b1d2800119e7a10ec7373bd5acb54d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 37700 zcmeHwe|%KcweLwXlT5;d86Y5Hlu=^^`IRULAwfgJ@Y7&0B;b!2LNY@FNhX~+Cn1GE zaF{kH$Eo%{d9{7ot3_MytG#V+#iCRUKQ4jW_BNueQ9)zNt7m%B8ZQ*0rq27Wz4w`! zAhx#me(oRd5jf|pv-a9+uf6u#>+Ih%CP|W{4Y-`R@b_8nh8`RhDqTqF&HagU2kP9y!_g zQ^9G#i;q_F4Qz4uq2I3h{lcj5@1 zHv|^C_?02x3<@jPs%)CujwGg*>Cav(NoD2Hd07pTRDU1%*Dvr&lD-BEjY%fHK8DW+ zzSrsmF^yY3ieExQqXKQ_p5|BN0L{~|P zm+L$3g51Y~M=hbZWM}BSV&5#)zXgW+kHA133VVj{z5m1!PVcs93JE*5vP^%m9Py3> zkJ^kem3lrg!HXqy9!%bfGif9y{elU&f)Dhob=ZQ7hA1oYjJ%Tvp4}u#2M0GwQt+dl zZT9n)Nl9{QSD(dYBzN_7S*8^4`X~z09q*cP()LpfBRLQ1{y0;T_CAKvpu~F=hbjHp zPohx>r+%cB+QW16)mQ0h$^|kNme=lS<3 zouVp3VfVQ*%{?@|p9-6$yLlp4A5`bq{X67UD;)_g(wTy8DyXuxW^`_gW;jBJ5EQmt zS>PUW1b+m$v+zn_zXvGtZQO#31}TbT_a5BUH$x{JyB`7+I_cQ`6+8gpOU9WD zWQ*Eo+`2-(k@B_1%+lAPBK2_as1sR%AfYxGf?-kn4SPvJ)sW-M7ofAep0MW(uPD%& zR$+Vc=a4`DaI3R(L57kVwI0Q5QU2k!A$1~!oH%kr;D%c1hB~@6D!BU;xkZs(9>3q` z=X$r0-W6MSl|3&STx3V>kd*Y`qGw4l@(l&^1^_sMf5zLg?$o7)8IIi_kZKs-KNvZK zm*64`MU$^^96VAMo%bAK)bCA!c|0_QnMZJu#KNzs)ZNGxQ9a2dEvtWq$m$uHGq`Ak zCF&vqb!dk56kb!TeYls^f1e0%=lpo$f#L&aJS5fFuF{dEj)Sj6SJ~RfYO5v}tg`JK z+tpW?A=|W+E@w2w$SA){{~3#G>+Bc-UWk8WKXLG0D6$tx^3~CKO9hLuk|?Y^rsGoJwvgwAy-jwHBq$Q7+lmtH1ajkOaeB~ zin6GB2d^!htnCf%kY>UCh&r#>v<`cv{?FtQ&gS)?z7|-A!Jxw>I6GDeAeF3L`Jjl0 zZyyLQB05%%=UCG7gNuI1fY~B7lrR%qzPf&`75P;sQ!XvW*v+%b^)r7)^~|1(T<5>t z_Q$;Q`R}w&Sh{&(x&E_wz&mY!&?XXdbs}Y|*Gl|JSL6YOGw1n;GE>ptLvFRJ$(sJA ztcVI&Cp=k3_n5AX zl45dW(-#pgX%SghaM6C;B}eG1xIfts_!Yf?#R<6BYf{f%!os$Rq3-%98r@3}G{nMZ zFygW&3C9xy=}(Dt`W+Aewb~v!+2P^_#w&kEN?2H!F#&$(k)Gf{(q4w0NCK)K zq+}9THS-Ma2?^vM3OG8qMlYx`g?DOVHZWO^cB%6Ki4f(jT9$L>rRln9a$ z#Dvadi7~P#iFO9#87oO5tQm zu06fXbx~-qwMWotZrff`BG(dy;mg1GIbisA8;&b4s?DPWjg19X5?h(dmC>5YbW_9M zAUmyy2zE7Wj zYMU%uUE%U>@_Sllx>`N{K!dN@l{Y(2QUW!bJk&UH-8<{vdlwg1xvC1Am8RRO=)I(} zw!WdUIndg+wTdA;UOWpuTU-3Mx$Z6WHZ*zyvuDq~t%{~q;`p_26z zIi%&>yqj;CJMY%{3-T8)EM8brxv|!>(7Vt~pdAgf3~83+rv@56G8s}~K(1?OzKx0s zyu~-Y)UJ(FCsG?NbW*-)^BkU}{xNG3K#B6C816mbiuMvI)SDOWbq^D(UiUfv7@|j{ z4E{M>(ia?F;rPn!fTKB~FmkhR%;&rQ744tTx^(cc*(GTjuFso!b?i}_7djFb0(Sq zh9)5L8+fPayeFu!_kEPkUP7{#qa)mlpvX({@GylFFA@G-3V$58UMs~)rlMqt5)@Gp zP+v`UmxR*eE%&cqN0IH3CKhP~kpM`M``IfsP3RR?!LZA54@G6GJ`Z0dZ4rsMP9F#3 zQ{5wwATrGipNQ~!D-sd;C|%0z3zj#rJ}r)Z9&JjPonhVoFd7BwF*NP7Opnd-|H@fb z?GH#6Nh;S3ys5pt?h%MYIrd&yYIjLWex=$!!#z^AISK7JG@Q%yH^)=BGt{%=YC>h% z)QXY(SCwBTy;Z(W{}tmx$-cbn6G~T>EA^sDjHA&2%craw8+xrnLK()|UTa(vLo9f4 zuaz2D44xMcHm3Jl$)z#;)xFk1lf}4RD>aoF-m0HRQ>Xr26ohb0Uq+jrx+eDE$5BV< zAIK?1l{s3etsryl2J|YXK1mPs4z$8uQ7ggg^luiLYB#L<(_k1?M%L*?$Q+#b3`T@J z28WY&ID;MMBn6*yYBG`pFVjtb94WkXlSiu!SguvyaIgc{<~ zj1`G3{~U?saGKyE>fcIo+J35JMzT6wrvLdGROp0$LvYZBPiOrC8)W;)yx){M$>{cVt-fVGa{ zq&7ROT>GL;TWn8RJXu>a`NGL-`_#qu8H+928t05Pmi)sVsam^JZMSRfcD3E62Brm% zW}&ual}IW~mjAX!lH0s~$!NHKpQFwc@eJ z|?=8wcCw%>4nIaYCA2)t07d(Nn8N6 zVz<`uNN-3+TBHe$K`F)df?{XuxadB@N0mqPLTHvsXb&Nh)}fGgYwdrfkk&ZWHFj-{ zU0q{Cio5>@*!QO4CiO1kMN;vITG6TQ*$$Rm0v7^5OM(}nC?)}sYmYNI?tvVg+8Ue6 z#QMu7lOPSxg}TlbI;mvr??JvJjj(rZnN3&?0AV%DY|yw`W}~noZZrgOqe0+3StaWF zEEdX)24&E-&VFoJrnEY^9R+|+*phvH>H=dLdv3KDQwiwYnkgw)a*EW>qRgm~M(9t9 zGFQWrPlwJsb}J|^PLRQ3fJm84h$KhoZiESX$L>4COLtLb;U{utVX|ZQZs;*Gnd6^= ztIL4vl&^`T5@s#L;p&>AR&{BsENZz$%`mo)3ShRUA)um5TWQgf)hTL;g)3dX$D)qu z{8DC;Y{~60l7AT0_K=}=6=!M{UBJV(x+r-X0fCH^{7p!nV|gM(uYnDcPf;hR#g=2m znbNV6Ov%_Znt+wEHi4u_COMc`e~T6e9Z%Qw8PSsuF{n5d>C70~URNR5eK}v8ly&HT6^DdN8jl zyVikmM7eZbdGuEO4Cn#0TJ$#ofn6?25e?@F-K*^jSK8$<0gE=?_@j20#fShsMq6sr zR@&6%P9syhmqrr%fKj(P&29($8F?~{nj!}Z2;`}iH2O;E0Dy#)j^law^1?57q^N~o zHe)hh7|YjrC2c>fPcjxoZ!On+uQt$ZsTmnI@KKS*y@YW`eH;o+VjVp~)v1BfydYcS<2wG$Y z4!s8lXYvmsnl5VTNWq$!jt5qfH!2<3b%^+@rNe-OhvurKXQ%=24fYAFIz^+%*%@lp z5ZNC!3}zyGW7Up9?QVQf&qeHD((9)79`Vu^&qUWGzppJ*D;=7CNG%esZzG}keqyR?7da$Ykf)XXBPnLTp0wj7#zEtoIKsl==F9L4zJrcoYa5LP4P({Jw+#Ts!)nLlqxzJv(TW1>h2JS4c%g|ir z8FPeGAd!cd{4fU@i5a*5y|P~$mwik@#b6sUppVMHcY+CPYrp$@)biX%~G#Kj?}v?gtH}iT5N-X|~ zXkiANy(KVmm_Z5qfEyWQcj*gYH}F8^`uv5|x;5u=n5T2YS3A)(u)avm6x3Dg{$Vta zDY;eITIpnUl}k-osg_TU-lCOcNBi(;442tdc$;#&dN^f*>Qu{}q5&aT^YIL7H)E_^ zyC0vv5p9Qk#txf0oZ_~tA07HAC466U9U8~lH3e0}J5m5em0@iuv0rLY4{2yQBi~iS zVaphGsZ&kTmQF4T4yWw63Xy-GjPDmbLiWSzeP6S!Y(J|G2M0!2Pv&s`>pL6>>&{N@ zx-Y|4od5dH4}ynm>S|jG65nAr+p?&mG<#BtCLI~2Bmc19Qs8V&gE>M0AB1`wdk(98 z@W8RLGk8#Zu(V}FJ|+Jc$a7oAYwIm=FD?k(&wBC7?-1%#+w5waO>?U2oa!=*kq!@L z)&GbR81=14m`6h*G=XIq`VErQxj<6xESSf7p||i3nkBfGhs;v0ASOm9QexEM*Gs zcJ(rBcD5w#hiyh9*C7Xt#&J;E+v!6Om=Oer7s}4EsN&Rri8eO-%qiu;MMN+Q%}o~d zJs4I@CQQ7LOuW}@?vC?96Y9S05E zPH9}vwU`xDCsGn|mOQB^N!(H2-{7F79Ah4&gP>>Roy}6XYNUK~ioOC3>dmS819&)I z#w=qdq(Sd7ReuV}pc4s_FCZ*DoAH9dtqIvTxjE%s^6u430lG_BevLlKRRD*7|vMAY^?II#Dda(vjq_TQ8$T z@6sPYc0)ZKBEb~Rty71a_(rt(#6SvLZ@~SV1g1&;2+a>;Xr#N;o_BJgO-WV{lX26; zU`mnkM@0M_;ldfA{kUziy3OXjP-3^?V-wuwl$6YJed!F+H`V^-UUkUv{E#+g#wusQ zs;upfa(&!vGjK-U2~3=6DPHwIXs&EA2;@xSg?cn8_(_H`u3Z1^tVDe#Crt4q_{EMa zv@ab$KpXhHydk*LB6XyRexeFT$eImCUO5JaqVx3!ZpGlwRD9*aSz|C9HvR2&`Vshc zHcTelHTUrJp}dn96uU7+tG48y^&hX~@m3<<^fpV9C~c8rkvJ4T$!)xi&QmC2n2TV-o!!Fpw^bvNd?9&v5a# z6xq#zBv?LK9V~wx9@7sMl#X;v4@I}z3o3@%(iD3^>A4+gFSE*FXX9^18rfppChdIEN8+#D|LKbQmV2S^LZ?Ah+@o4c-D4D0>F{%mA5T+zRx z`^v7#Mfv~cKfgbdFrGeIXaRCocP&_jf^k=Tg!Jve(FzS4EODCtg`4np1Z|?L>z_w8 zB}0Ni*mB9-uyUaz!^_$g=(^nQRZGUAuHa!;@6E=T*E6fB)iLum_L%0pliplQ@VLOs zP0rYyOhaVJ+1o zik|tE7o}7vVQK=xmJGyLu5=6s)2P_>o%u85F`fAv6=!FA(hMcz02vb-=u7XzryPoh z2%@tDoj`^vn>V=4j;1DOgfSrT>DvWJI1IRo0;mYCLOq5i$NAtkmn3IJ1KC;$+5yai zbXX6Pu~39gH2b0fr{2T#X9;f0mEV_nw;I<`_?1%=I=nvt& zw`2(+xx!;hWu&5M*H6cagvNk8yEc8^?7Uppv|^8ci>J}kKHYWmoV@%w`FT=BbDhWA z(Cn$>ix(EUa-}<4JpLNivS{|nF1$1~$h1~xwa*n$YU^Dz+vW24U3F+;)XG@T6ANka z`)WObfV84nM#4%9Vz~nCSm@K_s;y~k1Rkp-=8Re_vBcBbQ0s9~O0~XbZ^I_VkE9lx zjh4oSfb5ceK3Ai!d6VSc>Zx^keg38zbFD>jO&yn~&J(EhH?%+;l7?pM>Rdt`Pe8iM z6Ywd1q*LdqscZDrZgJJL`WotxQb|oSr48wPwKcNG#Ro5?GRk#;O%B$1nj1h!Db>`~ zp;Z--iW!SKF1l!J)kz{N8)_S(eT(j}~uyR0>B%UkKQUiT9dc3j=ZBQZh3ehqRcsyI6^qRU^ zzUIbu&W9U9To%#unuca7Mx{~M1Ct|G zt}rp^u*Tnj)Rg9$)|!UKnvIQ~QJQWejUdaI`$ZYXt-Pku4@uicg_grcJV-iL6_Cef zU-PU0!=tDJazit(B*G|MF*_&)d(0)r&9=<%lYO|t>8DdQI zQRtYBNJ28kgd)U4;yD_Pk1_JrG?9Krhc4ze?YdMT8DxtoJSUJ$`UI^h0T0!q8)34j zGMk#2Dxe`)v{_?Td*n8se~YUjfU<0BmJ;5TW~jfmo)wpgu7hE=AUa$^Gkgs7a_}GJ z=8>TQuiRGS_rRqf;ZZa-8&Qv>l6WK*gXO~GVUA&=;`Ms`!g%9mB9sd0%xsC2QSswp zq_{Yq=Q!YLMlQYZcP?I>u0XvavpmM?q~C)yJ-wVNlWXAIYCRtEpyhH6eBJ7$<-D5L*EH9m;>991 z#zgjG@h7<&RKgm$Ub?HS#1)YJN-dLeV@(~ym`gHPRbdzivuQSyl9iVPbKc~yX^Ji0 z;FRQ^nb>vsfUw#{@jyquirh7dHdeKkD$U%es6-o@S{gmnLq=XkJ4N=PV-*d4k$-mR zJKL0lMkKCBas3Of!?@nW^#@!j=#EUmH4|46u5w&WxOU_EpSZq_Yd@}|xcYGY2AAav zl9Yw(dR%jH-G$4GD}?J2TzhdHz;ztg+qnLK>qA^qZp4BjTzBB|;@XXCFRmV3uizTO zm4+_cHMkbwD#O)`>sz??;d%|%8C)OZnmQfw;<_7G0M|pfzKiQPuHWN|;u??U%v@Z{ zaIMAV!PSoIL0ta}*AH<0E3Wr&eTZueTA)*L&BJvku8p|1;VOd;sUKEqqq!@|i}@*U za3I}_*$|8^r2~Z#c-tC%#D%t6GVeryo|;|3MP2A7N{Ut25ZGH{!3%3}VTr&LYDZZl zWfeWqSNl}sjM}uKapo%5zXb-oANQ^|SZlu!8w_LfRo>t#yT!<3?XVe%?Xam(Dx!&Y zm{wAVQ7-BeYvl{n2}TX;C1MHP&#z`=lw67=XV#xVOIF{8?h@i^~-{YYgVF zfimx|T6^@J;5Li2^J*o7Qg=m`qHSnq5s0G5JRoSTDjStUd7*s=cS}~^R1?@TJAg*s z&53QiJT&s=&&kh~B2_42NxLJ*7W|M_2`tI6pvf*7sam=Ug@>o&Dy|UbSLBVDv~TUewlQs};w!bu-n9{&3Z^;n1^K zWTB?0?w=A*MD2C=@W)X~0fSeNv|Rr(VCo5>Pfor5t1x~78!%h*?)^oQZ1o23v=^Z< z{`3=I$%bK9G<&7hHLDZ)ZZ#Wg(fXFAH7kvc(-ZKEi%XWcmr5IzP2??Gy=bI0%ie`9 zI7wXi+Q$A^9xdq9uu%&PR65o0a+<&>#lXd4K5)^F%5Wv=N}D1~UKYb`2OKnfYZEna z3Tj}6a+NpOK33YE72QXCFhF3_e+(e<5NOqXO8|zI=TrqFIcx~W9MB0ZKnRHyEMFBmx}PbLB28?A~X+l986ckgb$ri-sY$oj9v|oV0DqaM&oZ|HTJHq zwj^OPV zA}&gAs1N}pdT+=TgK}cf+!&M#i2ja+$_RH+9?XnUe!`0fg2U?_UwH$DiG_5(&Xc5t zw@A`63;9)^0Gl}TS&gu-iSQ7fj|=#ox$s_}<1+dDwdeSGSagJo=*(wgoR^T6`Mv_f z9wwal{NjQ*{%8W6NOLLpUGTnAq)%znbwc1w`d^9ke~&?^GNk`lf(&m6cxytMeSkY( zVg=&})u0S`DY+sQfP-NwV_Ree?i#Bg;WZX@534CFN7OKtF?I)pr{j6yaeCu1oRKR4 zb51iNV*p>W(1Rb|q|Ch(U$VW>33C85RSOY94Ur*5UIN(55M+BAs|NEobW%VGNd z%M&l+;dr@t#29}OQY#+81U3mMl$3elaeC!tJBtk$MNXtpL6B91Y4Hp*4`C$3+C8w7 zX(adKGjWgZ<9EX72eZhr(!BjGr$dA}ZOy?q_3by_8TeLfnnPjBr)aVE=AVTmZGN2oG7Rs?CDZJ}GD7tJ-bRY9)p|#*p7TrhHD7ugMj*|LuwAxgb zE6nS6zC^_M=!=YVC*GNlod6#r(@~~}$PmDU0-c*spwrAUFso?sh?jeFuNt<2w^y}A z*wV&}s&erNCqwWKT1@`8naxlBlG$J$`6(#mV#&yPkQuSz!rqV*!VRFnc*;e+AyVE} zD(Fq05t(cPUq2KCK_5_DR=U!5Xq)tmf%bhAq(99Tywawy8)h(Ku5ez;`G*|gucH~D zhRL)d4+7)?0 z3l3x5*!QReU%@TP+9Tb}k>sRVa=B@DB^~-c89|EjPFya>?jA(w%+Gb~{z)t*r$3gI z8`%pSmms}$K4;6n4liUN1S9nysCz7sw>wPt&O^DTLljjM3t|ac~pj0VVBxIf19&$&lNtO*je6(d-G(@k)Ra}Qfh(K+34YeAUG z6!Yw?y@pN)i>QVs1Ir^*hsF{54(=NJG-1sPtETwIfAwKtx#pcaN_$hQ>)?==T99oi zh41HYg9Ew2VV5KHzY&{jdq$W_;xjew z`#c&?i>LNy$n}{TCuVI1!sSxu446R;hoGpcI;x%_p+xdu$Ge}Dew#JSzTxpCvB`p1`eT-t`H z%l)_3+9U7B^zj0sf2IwQ3rMsfvwJx)-o4yvvQqpSv+e@sSI7s=g@(xok{- zy-k|BPT+ELjLS^XZ-z_}R%}G+q*V{pnauzlrf4xwJq)>77ag5>j4H%i_6v|2))K-8 znM=HgQvBr6-z?!8~Dn0zdG7BWvyEEE|o!={DX z(H1;i)gN^aXdMHZlCv7)B&XfOZ=5;ZkLIwvn#k~eYF;5&W77mU>0>BP#n37165vi{ z#zWMztM!-AoP{iw+^!U`in<5m+?0ROD$az94+Mv=bA07%@TKT%mn=qSu~?FR;g+No zOZb!E|IUlj|0U$0^l4F|JYi{pk`ox$J*n%8Wd!>FWLS=+dBrMe8Qo1B!N#$h=d z3+6XtWA$>_+5oNNI2Bd;bw7N%>K=%e>PQsZ5=!t+5(t87c2KktO&Er!ew^+AD7bM7`9}U83a~7#M9$VVG_%+I|SC3GHeNrNpc^t@;ZoW z9XIULZnI$JL&oiK*7AZ&G5ay%j$-!3QOuCr&rvhhLsFE9SxHGp$U;=k8C5-ui5LVQ zH@aNpq-E;x4EI37LR|2Yq?{u5keo%#FSGTp9Zn5Pm#ZdsS7e`d+e{CT&Ag@c6#Unz zQk$szr%@44_Zv>f!Nb9xzOuK-Ra;J14WG820Uf*}A9$GFSpdse^+`%+LH>@yV=1}$ zZ!6=mswnMPN?tV0xan9)G;g(W{VL;it<=?-KZ{mYQH0KdTqP5Cq! z*}d~{Zr3;j?|gR!JbIF<=O1sK*gdXm!s3$r<89}SbO>5PzP<#@Zl3NzJaO)eSVM+S zZmB)kZi5MVVd~xs%lIhwPK}QoD?n3bA-weO#3OvsTIRo2A0=reoGjeI!cEr zQnDo9Z;YeG-3Z45dJ7HtR1BjK4V**)E^QWd2ur#L~zp7b^5naSJ>h{M~F7_8uPX4to*ZWSFz=Q z7t32n6cb}fRGLX3JD1J|_EW*nMrb?f=)K~Y*~u1|OX`p9MV(Q(IfJr7>zRel?#r=gcpl;Nc1^xI zFN-iQF~Ti#@)oc~S!|d88y)AoTE#iqvf8dMYt;;P4DBp%5m-u=AuF;a1us^tvk7R!4bu(_ANK8E0hn+ zDNOj1(Q~>#VfC4o+bX4E5?3^M+vwFI$$Ua~)WW#0qUneVFD7JZD)%ihN66+`X)4vm zW@S^$bz09#oUjIWoR~D!%Cj!Ki9HL(cnW}1u%N6{w2~~f#AXVLSj9x{)>roFG-)6(JZe-S)l3gp+xc!)6%Ml6W=z<;w!D6F0}A2DTAem%qmHd^|9!#<9aPTo ziTjff@W6v!_|9^hR$`%g^(8EKy*_w&?eg}s*dwGkH)rUyja5Z+pXSzS!`n$DUGD8I zM$z>`a(JX-YBA#h4by}Ak9c78oF0?u0dmyc-r`)2o68?d_+vReXhkibOeY!jtDrn4 znvq6(mD07VX3*sR&i}w61GX}K0N)}tg~tGWy=^t-^yxGPZu4=S_gZO{0+j?p_*w@y z#!VDEk0K+)m`cYZ!O(GN03DA6Bj!s;jnpz7A0NS!&s;lRUS|I%)!z()%W^*jjt44t!FaTNQP|LOt89NhLV!g{^6LKc+9U z>PSiQI9lGzW3(X#1m(1etY#x%RNTbC#S{xWfowdUk4LPe-?W*?owA*3%Z{Wj~cn%d- z0n|^BXBJUsorb5(a)ushg)(g!ayu^^CZm*BX_K+}4Lg9;s(x*~O~vND_1FqApsjae z2ZpvjORdti^`IHl)@Rd>zV$9_l+f1a(5|QT*v&T*EIpNk;tBrdeeAxnmDOj-GdnSd z^HCDLOr)38vieDQuF+c{46Wdf=hyLag&hqXTEt!7DqA{9W; zaA9%0>>gof?m;VB@iZ{ydc|g60i)4_Pr%A)v`UA<#CwkUj-~5JzHFLWMlsB~u*;Q2 zQ-T{TpX}OT--M$gc5Sdl(W~3F+$QnDVzSxDWXuHy?vc(Zso3*UzfG2~eCI1n=-EL3-(y1qbGn}*d3`UEF4=Q#+K{<2oj*F2%7TF?O2W3jl~Nd8Oi_HKbDc^oj-tz5jDm?Nl`RLWmsPskgr`D&PvJu z$basDjRLZM3{NnwQlAd?{DpKg5xpGyJ|Z}l{602ZbQLFsi!CunAIo3(&J@-`fAx2v z^E;Ln%%ikA99kwl)#KD(J7Q$g5ov@tKvup+@5KWruEBUFs#z~l8b(^!GD*c2t5x`* zoQtKx>J9Bh!I%5W@bZz){P&e{j^`IAy~rfben7oawLc)-G}SStb2~Ojbl`J1W}U9! zGaLCOWvtW|zI&vz;C&@+spI+bBxAdQP&&HT=$%uMHl-GIrHY_x}F1#}NMatu=zbTl=G+_-MCQ2+AIGn;T zD4z8Ej{;U?%E%{wF$HCWLSCnzK!u})U^s7-S?5&+icQYS|G3qn4&#)V{xY_H${^{` zg&uW&AFt_oCtfDCVDGr)A)0f{e-(R7k738!abtY324AfFVR7)ot9QIDIv(bsXAuoN z@fWrh;U2ebwkB|+pDzZ?OYB?BopbXov=$J0y(7o+NoON|&N;}NNHohIklwe2}hq?DC^A&@n4D3W~kX?hF3n{xK4 z>ie;U(RK_cIPLy;pWdl6Ao+1`5)13^2j*z1C(=T=iQP>dNXV8FM^5)!}OH@Qd+W~7D8O^AX?px>N zvBoITfK8oeE2GK3RBE4>rVX3>K3f`|cQ0-AWJIGz>gUZ#$XAW*YhWa!bZ=^h^NEXm zF%f6P@-F*jAJ6-!#7s_thPSL~hxRC43y~_Cw=`qJq`5m=6#XS1#Lr9nf0^*3)P3`u zdGT`dHr8z7g*&SF&0^zo8nunSfQK;}wWSC+#7v&%X9&l39+_{Hom=@NgOpqTw7U*eC#U6)kkeW-Uh3hMm7k3!}Nn9&e7>T2svykLdy~ zNrZAGxpCYYlz zF_KZ%1(LY`^tRPBZu#sYXYyd*byI_nd$Um=k9p!F1ldU@Y&5QI;$=R{F^;lBb_fK| z+o;T$f`b>8|5F(1pzHGAWer@`z-0|w*1%;AT-Ly44g6PWfZ7;S1v6UDLhyaK(0ym^ z4}xzJa0{N)$)|Zn`hgd0jAk(XTtNw7;&l|)N&yezSuWsg3<}VUF2$uEvO^P*(boY_ z%^Skg?_+Ee_~mF)?iP6Zp^L8xn0^4`TY_dg8jIf%c={=#9|-s;-~$4F7Vu#~-vj!8 z6L|Xljb96R05oq4n10ei7w~hye;{D`agL7#Oh0Nu$41!jehP4gfa%APCJC5+nTuAp zkWMCBu_935dw`!O;2#2BBxu%y#x3yl`zvb%OuxE9n`4QO3scq}fqxD7Mgi{!EDN|F z@D2h06fiAauput}!qP*4iO*mf&XW-^mIX=Q7Vvh!-xKuoqa!~N_}p|!qTh(2xb$l; zSf|V29>Biz_y76~X5cU|J3Wu_QY4#R~f-c-m}9njqkZ0cR(`HwgF{;AaYW5b&)6 zmgY#(Z31=zULoMDWzeU9pIw2vEZ_mabpkFz#cvewGk_HV_W<4@U>)#R1pLS<)N286 zzXKD)0`9|7Li+7N%1g^?_zM9)4EU!4ratgd0k6LkIu!5|fPZb$-z7=!nDl_(6L1gU zKMJ@X@Oc3b0sch5HaIR?azZlX0(J;^Ip9eG-T?R-0n<;d+$i9jO4M-y7XmI6@WX)J z0`37^3K-R1B3q@SV+cMD8SWAAE6}Y+z@&#Jz^J;?+6~aHz&|=0whA~Mcsl7fB=9oy z{Gh<^2L9^;Pi6Ei0h0_*3z*8{M*`k}Iz?OmNglG>Ljoq<{#?Mv%Ot5^z+^M;2zYQU z{HK6PheHCkgJ)F0S+n3X!JPP$os1Xoe(;d8Z{9O9bAs27Xe& zk0I{;COzu4SHN^KX+XeaC))%}b$qvg_g^JR{{WcyKLP&V08IMqg5I7MG!MH_mjz6I zW50lD4Cb(apMea&6fm+X{Yt>(Lrx2rRyCdx@WY`0K)_V@KNj#ga6Yvj_ z_c;QVHoyl0CO(gVPZ41JmvVq#0f2Zu2s^13aLXi|#4X_Uu!m*=lh0QKYyrF-F#b!l z{4*r*GIaYj0hd81w409jZ-8u%3wS?deg-hfL(5%$An?y2?tTGxK|hBCoDBWYQfcBd zGZ$yF33x4R;7tJ!AiwVlnEd~H0;X@)9|WA8AxUQi{F+meMg&a1CzXu$0r9Vg%;^Fi z22ZDnN7-E^V312U3Yh%)90AWndCdb%`J$fzE);nB4${e5NKSfY6WWjhuU~=hj-aP; zu=N5@-^UGtzH9?z5;RYMrUmdECE%aa*syUG(eJQjOz8o26=R4Ne-As<$?=aXJ8)%b{airE1w<(;S$cE17Jh>ZTgGw!Yfy zYpeqgoEnRx4^1QvOvJ&4f&zz9*5ReOF@S>^rD_ZxH`d^EL;_@-a@g361R)T99})sl zOsN{jC{_m`E0$j}`i3TsqtgNzh66+vkFc?w1OV4K>skm7#HN}S;*Dt={Kg}43{(uJ z!yjkgOu;gaW97+g^xz~yAqG2l5{khzjLBMX_4s&7LO}?n19BPnjUJ@Z(A*%iDC~qx z2GLJqGJqs+XvRT|NRg0IwK$Yfs%AfuDQ%(A_)8RA^A{D50?}l@$K%BbtWYe0b)H7K zMyjsI!DV37&XLWOA>YP;TvNN{Q>^fNm!HCknNFX?r!RdHo1(;n&qDenG1cgkw$Q8; z-etd^<`sOBm|*ltY=#hq$0h+;j2dvhpW(^p z$b1qA=#b@4S#qGZHqcNf;S^6HQNm$;K1ocCA(lsOX`l?Vi6HQeWeKK>sUe>fo7F*} zn3w@1wjKE-wwVaBv-ub%GR?UF&nH%pZ$5hhjF=*!*lZF603Xq(=xo@Y$x|oOajb!c zFL}U*etp!3Cm)aZN#>Y4LU5LJEeXhu5608f5Q>%1rh>%iI|N~qN+=PUh4o2|bWSjy zyhZ~cRp97cGhtfD2rgy;Y^?RQv;$GiOaRpZ6-BD9hW)b*Sg>lA1q#6Fyr}tHv+Nxx z3df8U#i(uc)HExw?1n%ytM|m20s=xqEG~-!*0?S4eDk7;m z=8AY$ffu%24P!%<0B3FnQZ*=0Jc3JuV3Tl;qsVWJCt}vtvlwzMoi@7>X>FnCkjIS9 zEe5>X1LUsg)NG{53XCO46#;7C)s2hP)X)s|GRf*1;Cd(*kb+kT24do#1+zjE^7^>E zC|~jpykbdBwLXQsArnbZP>xweA$;x`lYLh~_cnmui`^$JeKX3{r9e3mM+ zodhzttp+M>$cV!bK?6N9!vMt0ki}xg3@BE>@KwSGifYA5Hg4Z67Ox*tbu6c31^${g z`bzLGOf|2qJPlq2DPypMmQ8--My{>%(+Snpyv{MYrJOhOsnyjuWt&+FvjiM=OA2Dg zWHT!jMh}CegShd{;SS$a5)jR;4LCg-(ach0l7VYoHPS~mTbQdRuLv%*q5>ZVs%I>v zO^xK3z4(%t-%K79U`4_*!fhKWZAJ|vJu{P_!o!RoGKL+C_!7jlh!nYLd#SS1SC%Y@ z+$d>{Q~`>H=30~#r(=~JMnVeKI5#Sd+N{t Z;7EMYNhQb|cfzcSGs{7p#mV5({{=qvtvCPx diff --git a/gnu/usr.bin/fgrep/obstack.c b/gnu/usr.bin/fgrep/obstack.c deleted file mode 100644 index 13dc0fc31ae2..000000000000 --- a/gnu/usr.bin/fgrep/obstack.c +++ /dev/null @@ -1,326 +0,0 @@ -/* obstack.c - subroutines used implicitly by object stack macros - Copyright (C) 1988 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 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, 675 Mass Ave, Cambridge, MA 02139, USA. - - -In other words, you are welcome to use, share and improve this program. -You are forbidden to forbid anyone else to use, share and improve -what you give them. Help stamp out software-hoarding! */ - - -#include "obstack.h" - -#ifdef __STDC__ -#define POINTER void * -#else -#define POINTER char * -#endif - -/* Determine default alignment. */ -struct fooalign {char x; double d;}; -#define DEFAULT_ALIGNMENT ((char *)&((struct fooalign *) 0)->d - (char *)0) -/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. - But in fact it might be less smart and round addresses to as much as - DEFAULT_ROUNDING. So we prepare for it to do that. */ -union fooround {long x; double d;}; -#define DEFAULT_ROUNDING (sizeof (union fooround)) - -/* When we copy a long block of data, this is the unit to do it with. - On some machines, copying successive ints does not work; - in such a case, redefine COPYING_UNIT to `long' (if that works) - or `char' as a last resort. */ -#ifndef COPYING_UNIT -#define COPYING_UNIT int -#endif - -/* The non-GNU-C macros copy the obstack into this global variable - to avoid multiple evaluation. */ - -struct obstack *_obstack; - -/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). - Objects start on multiples of ALIGNMENT (0 means use default). - CHUNKFUN is the function to use to allocate chunks, - and FREEFUN the function to free them. */ - -void -_obstack_begin (h, size, alignment, chunkfun, freefun) - struct obstack *h; - int size; - int alignment; - POINTER (*chunkfun) (); - void (*freefun) (); -{ - register struct _obstack_chunk* chunk; /* points to new chunk */ - - if (alignment == 0) - alignment = DEFAULT_ALIGNMENT; - if (size == 0) - /* Default size is what GNU malloc can fit in a 4096-byte block. - Pick a number small enough that when rounded up to DEFAULT_ROUNDING - it is still smaller than 4096 - 4. */ - { - int extra = 4; - if (extra < DEFAULT_ROUNDING) - extra = DEFAULT_ROUNDING; - size = 4096 - extra; - } - - h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; - h->freefun = freefun; - h->chunk_size = size; - h->alignment_mask = alignment - 1; - - chunk = h->chunk = (*h->chunkfun) (h->chunk_size); - h->next_free = h->object_base = chunk->contents; - h->chunk_limit = chunk->limit - = (char *) chunk + h->chunk_size; - chunk->prev = 0; -} - -/* Allocate a new current chunk for the obstack *H - on the assumption that LENGTH bytes need to be added - to the current object, or a new object of length LENGTH allocated. - Copies any partial object from the end of the old chunk - to the beginning of the new one. */ - -void -_obstack_newchunk (h, length) - struct obstack *h; - int length; -{ - register struct _obstack_chunk* old_chunk = h->chunk; - register struct _obstack_chunk* new_chunk; - register long new_size; - register int obj_size = h->next_free - h->object_base; - register int i; - int already; - - /* Compute size for new chunk. */ - new_size = (obj_size + length) + (obj_size >> 3) + 100; - if (new_size < h->chunk_size) - new_size = h->chunk_size; - - /* Allocate and initialize the new chunk. */ - new_chunk = h->chunk = (*h->chunkfun) (new_size); - new_chunk->prev = old_chunk; - new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; - - /* Move the existing object to the new chunk. - Word at a time is fast and is safe if the object - is sufficiently aligned. */ - if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) - { - for (i = obj_size / sizeof (COPYING_UNIT) - 1; - i >= 0; i--) - ((COPYING_UNIT *)new_chunk->contents)[i] - = ((COPYING_UNIT *)h->object_base)[i]; - /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, - but that can cross a page boundary on a machine - which does not do strict alignment for COPYING_UNITS. */ - already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); - } - else - already = 0; - /* Copy remaining bytes one by one. */ - for (i = already; i < obj_size; i++) - new_chunk->contents[i] = h->object_base[i]; - - h->object_base = new_chunk->contents; - h->next_free = h->object_base + obj_size; -} - -/* Return nonzero if object OBJ has been allocated from obstack H. - This is here for debugging. - If you use it in a program, you are probably losing. */ - -int -_obstack_allocated_p (h, obj) - struct obstack *h; - POINTER obj; -{ - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ - - lp = (h)->chunk; - while (lp != 0 && ((POINTER)lp > obj || (POINTER)(lp)->limit < obj)) - { - plp = lp -> prev; - lp = plp; - } - return lp != 0; -} - -/* Free objects in obstack H, including OBJ and everything allocate - more recently than OBJ. If OBJ is zero, free everything in H. */ - -void -#ifdef __STDC__ -#undef obstack_free -obstack_free (struct obstack *h, POINTER obj) -#else -_obstack_free (h, obj) - struct obstack *h; - POINTER obj; -#endif -{ - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ - - lp = (h)->chunk; - while (lp != 0 && ((POINTER)lp > obj || (POINTER)(lp)->limit < obj)) - { - plp = lp -> prev; - (*h->freefun) (lp); - lp = plp; - } - if (lp) - { - (h)->object_base = (h)->next_free = (char *)(obj); - (h)->chunk_limit = lp->limit; - (h)->chunk = lp; - } - else if (obj != 0) - /* obj is not in any of the chunks! */ - abort (); -} - -/* Let same .o link with output of gcc and other compilers. */ - -#ifdef __STDC__ -void -_obstack_free (h, obj) - struct obstack *h; - POINTER obj; -{ - obstack_free (h, obj); -} -#endif - -#if 0 -/* These are now turned off because the applications do not use it - and it uses bcopy via obstack_grow, which causes trouble on sysV. */ - -/* Now define the functional versions of the obstack macros. - Define them to simply use the corresponding macros to do the job. */ - -#ifdef __STDC__ -/* These function definitions do not work with non-ANSI preprocessors; - they won't pass through the macro names in parentheses. */ - -/* The function names appear in parentheses in order to prevent - the macro-definitions of the names from being expanded there. */ - -POINTER (obstack_base) (obstack) - struct obstack *obstack; -{ - return obstack_base (obstack); -} - -POINTER (obstack_next_free) (obstack) - struct obstack *obstack; -{ - return obstack_next_free (obstack); -} - -int (obstack_object_size) (obstack) - struct obstack *obstack; -{ - return obstack_object_size (obstack); -} - -int (obstack_room) (obstack) - struct obstack *obstack; -{ - return obstack_room (obstack); -} - -void (obstack_grow) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - obstack_grow (obstack, pointer, length); -} - -void (obstack_grow0) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - obstack_grow0 (obstack, pointer, length); -} - -void (obstack_1grow) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow (obstack, character); -} - -void (obstack_blank) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank (obstack, length); -} - -void (obstack_1grow_fast) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow_fast (obstack, character); -} - -void (obstack_blank_fast) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank_fast (obstack, length); -} - -POINTER (obstack_finish) (obstack) - struct obstack *obstack; -{ - return obstack_finish (obstack); -} - -POINTER (obstack_alloc) (obstack, length) - struct obstack *obstack; - int length; -{ - return obstack_alloc (obstack, length); -} - -POINTER (obstack_copy) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - return obstack_copy (obstack, pointer, length); -} - -POINTER (obstack_copy0) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - return obstack_copy0 (obstack, pointer, length); -} - -#endif /* __STDC__ */ - -#endif /* 0 */ diff --git a/gnu/usr.bin/fgrep/obstack.h b/gnu/usr.bin/fgrep/obstack.h deleted file mode 100644 index b1bcad77c23f..000000000000 --- a/gnu/usr.bin/fgrep/obstack.h +++ /dev/null @@ -1,410 +0,0 @@ -/* obstack.h - object stack macros - Copyright (C) 1988 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 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, 675 Mass Ave, Cambridge, MA 02139, USA. - - -In other words, you are welcome to use, share and improve this program. -You are forbidden to forbid anyone else to use, share and improve -what you give them. Help stamp out software-hoarding! */ - - -/* Summary: - -All the apparent functions defined here are macros. The idea -is that you would use these pre-tested macros to solve a -very specific set of problems, and they would run fast. -Caution: no side-effects in arguments please!! They may be -evaluated MANY times!! - -These macros operate a stack of objects. Each object starts life -small, and may grow to maturity. (Consider building a word syllable -by syllable.) An object can move while it is growing. Once it has -been "finished" it never changes address again. So the "top of the -stack" is typically an immature growing object, while the rest of the -stack is of mature, fixed size and fixed address objects. - -These routines grab large chunks of memory, using a function you -supply, called `obstack_chunk_alloc'. On occasion, they free chunks, -by calling `obstack_chunk_free'. You must define them and declare -them before using any obstack macros. - -Each independent stack is represented by a `struct obstack'. -Each of the obstack macros expects a pointer to such a structure -as the first argument. - -One motivation for this package is the problem of growing char strings -in symbol tables. Unless you are "fascist pig with a read-only mind" -[Gosper's immortal quote from HAKMEM item 154, out of context] you -would not like to put any arbitrary upper limit on the length of your -symbols. - -In practice this often means you will build many short symbols and a -few long symbols. At the time you are reading a symbol you don't know -how long it is. One traditional method is to read a symbol into a -buffer, realloc()ating the buffer every time you try to read a symbol -that is longer than the buffer. This is beaut, but you still will -want to copy the symbol from the buffer to a more permanent -symbol-table entry say about half the time. - -With obstacks, you can work differently. Use one obstack for all symbol -names. As you read a symbol, grow the name in the obstack gradually. -When the name is complete, finalize it. Then, if the symbol exists already, -free the newly read name. - -The way we do this is to take a large chunk, allocating memory from -low addresses. When you want to build a symbol in the chunk you just -add chars above the current "high water mark" in the chunk. When you -have finished adding chars, because you got to the end of the symbol, -you know how long the chars are, and you can create a new object. -Mostly the chars will not burst over the highest address of the chunk, -because you would typically expect a chunk to be (say) 100 times as -long as an average object. - -In case that isn't clear, when we have enough chars to make up -the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) -so we just point to it where it lies. No moving of chars is -needed and this is the second win: potentially long strings need -never be explicitly shuffled. Once an object is formed, it does not -change its address during its lifetime. - -When the chars burst over a chunk boundary, we allocate a larger -chunk, and then copy the partly formed object from the end of the old -chunk to the beginning of the new larger chunk. We then carry on -accreting characters to the end of the object as we normally would. - -A special macro is provided to add a single char at a time to a -growing object. This allows the use of register variables, which -break the ordinary 'growth' macro. - -Summary: - We allocate large chunks. - We carve out one object at a time from the current chunk. - Once carved, an object never moves. - We are free to append data of any size to the currently - growing object. - Exactly one object is growing in an obstack at any one time. - You can run one obstack per control block. - You may have as many control blocks as you dare. - Because of the way we do it, you can `unwind' a obstack - back to a previous state. (You may remove objects much - as you would with a stack.) -*/ - - -/* Don't do the contents of this file more than once. */ - -#ifndef __OBSTACKS__ -#define __OBSTACKS__ - -/* We use subtraction of (char *)0 instead of casting to int - because on word-addressable machines a simple cast to int - may ignore the byte-within-word field of the pointer. */ - -#ifndef __PTR_TO_INT -#define __PTR_TO_INT(P) ((P) - (char *)0) -#endif - -#ifndef __INT_TO_PTR -#define __INT_TO_PTR(P) ((P) + (char *)0) -#endif - -struct _obstack_chunk /* Lives at front of each chunk. */ -{ - char *limit; /* 1 past end of this chunk */ - struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ -}; - -struct obstack /* control current object in current chunk */ -{ - long chunk_size; /* preferred size to allocate chunks in */ - struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ - int temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ - struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ - void (*freefun) (); /* User's function to free a chunk. */ -}; - -#ifdef __STDC__ - -/* Do the function-declarations after the structs - but before defining the macros. */ - -void obstack_init (struct obstack *obstack); - -void * obstack_alloc (struct obstack *obstack, int size); - -void * obstack_copy (struct obstack *obstack, void *address, int size); -void * obstack_copy0 (struct obstack *obstack, void *address, int size); - -void obstack_free (struct obstack *obstack, void *block); - -void obstack_blank (struct obstack *obstack, int size); - -void obstack_grow (struct obstack *obstack, void *data, int size); -void obstack_grow0 (struct obstack *obstack, void *data, int size); - -void obstack_1grow (struct obstack *obstack, int data_char); -void obstack_ptr_grow (struct obstack *obstack, void *data); -void obstack_int_grow (struct obstack *obstack, int data); - -void * obstack_finish (struct obstack *obstack); - -int obstack_object_size (struct obstack *obstack); - -int obstack_room (struct obstack *obstack); -void obstack_1grow_fast (struct obstack *obstack, int data_char); -void obstack_ptr_grow_fast (struct obstack *obstack, void *data); -void obstack_int_grow_fast (struct obstack *obstack, int data); -void obstack_blank_fast (struct obstack *obstack, int size); - -void * obstack_base (struct obstack *obstack); -void * obstack_next_free (struct obstack *obstack); -int obstack_alignment_mask (struct obstack *obstack); -int obstack_chunk_size (struct obstack *obstack); - -#endif /* __STDC__ */ - -/* Non-ANSI C cannot really support alternative functions for these macros, - so we do not declare them. */ - -/* Pointer to beginning of object being allocated or to be allocated next. - Note that this might not be the final address of the object - because a new chunk might be needed to hold the final size. */ - -#define obstack_base(h) ((h)->object_base) - -/* Size for allocating ordinary chunks. */ - -#define obstack_chunk_size(h) ((h)->chunk_size) - -/* Pointer to next byte not yet allocated in current chunk. */ - -#define obstack_next_free(h) ((h)->next_free) - -/* Mask specifying low bits that should be clear in address of an object. */ - -#define obstack_alignment_mask(h) ((h)->alignment_mask) - -#define obstack_init(h) \ - _obstack_begin ((h), 0, 0, obstack_chunk_alloc, obstack_chunk_free) - -#define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, obstack_chunk_alloc, obstack_chunk_free) - -#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) - -#define obstack_blank_fast(h,n) ((h)->next_free += (n)) - -#if defined (__GNUC__) && defined (__STDC__) - -/* For GNU C, if not -traditional, - we can define these macros to compute all args only once - without using a global variable. - Also, we can avoid using the `temp' slot, to make faster code. */ - -#define obstack_object_size(OBSTACK) \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->next_free - __o->object_base); }) - -#define obstack_room(OBSTACK) \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->chunk_limit - __o->next_free); }) - -#define obstack_grow(OBSTACK,where,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len) : 0); \ - bcopy (where, __o->next_free, __len); \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_grow0(OBSTACK,where,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len + 1 > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len + 1) : 0), \ - bcopy (where, __o->next_free, __len), \ - __o->next_free += __len, \ - *(__o->next_free)++ = 0; \ - (void) 0; }) - -#define obstack_1grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + 1 > __o->chunk_limit) \ - ? _obstack_newchunk (__o, 1) : 0), \ - *(__o->next_free)++ = (datum); \ - (void) 0; }) - -/* These assume that the obstack alignment is good enough for pointers or ints, - and that the data added so far to the current object - shares that much alignment. */ - -#define obstack_ptr_grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + sizeof (void *) > __o->chunk_limit) \ - ? _obstack_newchunk (__o, sizeof (void *)) : 0), \ - *((void **)__o->next_free)++ = ((void *)datum); \ - (void) 0; }) - -#define obstack_int_grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + sizeof (int) > __o->chunk_limit) \ - ? _obstack_newchunk (__o, sizeof (int)) : 0), \ - *((int *)__o->next_free)++ = ((int)datum); \ - (void) 0; }) - -#define obstack_ptr_grow_fast(h,aptr) (*((void **)(h)->next_free)++ = (void *)aptr) -#define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint) - -#define obstack_blank(OBSTACK,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len) : 0); \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_alloc(OBSTACK,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_blank (__h, (length)); \ - obstack_finish (__h); }) - -#define obstack_copy(OBSTACK,where,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_copy0(OBSTACK,where,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow0 (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_finish(OBSTACK) \ -({ struct obstack *__o = (OBSTACK); \ - void *value = (void *) __o->object_base; \ - __o->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT (__o->next_free)+__o->alignment_mask)\ - & ~ (__o->alignment_mask)); \ - ((__o->next_free - (char *)__o->chunk \ - > __o->chunk_limit - (char *)__o->chunk) \ - ? (__o->next_free = __o->chunk_limit) : 0); \ - __o->object_base = __o->next_free; \ - value; }) - -#define obstack_free(OBSTACK, OBJ) \ -({ struct obstack *__o = (OBSTACK); \ - void *__obj = (OBJ); \ - if (__obj >= (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ - __o->next_free = __o->object_base = __obj; \ - else (obstack_free) (__o, __obj); }) - -#else /* not __GNUC__ or not __STDC__ */ - -/* The non-GNU macros copy the obstack-pointer into this global variable - to avoid multiple evaluation. */ - -extern struct obstack *_obstack; - -#define obstack_object_size(h) \ - (unsigned) (_obstack = (h), (h)->next_free - (h)->object_base) - -#define obstack_room(h) \ - (unsigned) (_obstack = (h), (h)->chunk_limit - (h)->next_free) - -#define obstack_grow(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp) - -#define obstack_grow0(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp + 1) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp, \ - *((h)->next_free)++ = 0) - -#define obstack_1grow(h,datum) \ -( (((h)->next_free + 1 > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), 1) : 0), \ - *((h)->next_free)++ = (datum)) - -#define obstack_ptr_grow(h,datum) \ -( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), sizeof (char *)) : 0), \ - *((char **)(h)->next_free)++ = ((char *)datum)) - -#define obstack_int_grow(h,datum) \ -( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), sizeof (int)) : 0), \ - *((int *)(h)->next_free)++ = ((int)datum)) - -#define obstack_ptr_grow_fast(h,aptr) (*((char **)(h)->next_free)++ = (char *)aptr) -#define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint) - -#define obstack_blank(h,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp) : 0), \ - (h)->next_free += (h)->temp) - -#define obstack_alloc(h,length) \ - (obstack_blank ((h), (length)), obstack_finish ((h))) - -#define obstack_copy(h,where,length) \ - (obstack_grow ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_copy0(h,where,length) \ - (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_finish(h) \ -( (h)->temp = __PTR_TO_INT ((h)->object_base), \ - (h)->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ - & ~ ((h)->alignment_mask)), \ - (((h)->next_free - (char *)(h)->chunk \ - > (h)->chunk_limit - (char *)(h)->chunk) \ - ? ((h)->next_free = (h)->chunk_limit) : 0), \ - (h)->object_base = (h)->next_free, \ - __INT_TO_PTR ((h)->temp)) - -#ifdef __STDC__ -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : ((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0))) -#else -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (int) _obstack_free ((h), (h)->temp + (char *) (h)->chunk))) -#endif - -#endif /* not __GNUC__ or not __STDC__ */ - -#endif /* not __OBSTACKS__ */ - diff --git a/gnu/usr.bin/fgrep/std.c b/gnu/usr.bin/fgrep/std.c deleted file mode 100644 index fb98fe614847..000000000000 --- a/gnu/usr.bin/fgrep/std.c +++ /dev/null @@ -1,55 +0,0 @@ -/* std.c - compensate for a few missing library functions. - In the Public Domain; written by Mike Haertel. */ - -#include "std.h" -#include "unix.h" - -#ifdef X_memmove -PTR -DEFUN(memmove, (d, s, n), PTR d AND PTRCONST s AND size_t n) -{ - char *dd; - const char *ss; - - dd = d; - ss = s; - if (dd > ss && dd < ss + n) - { - dd += n; - ss += n; - while (n--) - *--dd = *--ss; - } - else - while (n--) - *dd++ = *ss++; - return d; -} -#endif /* X_memmove */ - -#ifdef X_remove -#if defined(unix) || defined(__unix__) -int -DEFUN(remove, (filename), const char *filename) -{ - extern int EXFUN(unlink, (const char *)); - - return unlink(filename); -} -#endif /* unix */ -#endif /* X_strerror */ - -#ifdef X_strerror -#if defined(unix) || defined(__unix__) -char * -DEFUN(strerror, (errnum), int errnum) -{ - extern int sys_nerr; - extern char *sys_errlist[]; - - if (errnum > 0 && errnum < sys_nerr) - return sys_errlist[errnum]; - return ""; -} -#endif /* unix */ -#endif /* X_strerror */ diff --git a/gnu/usr.bin/fgrep/std.h b/gnu/usr.bin/fgrep/std.h deleted file mode 100644 index 5185cac250da..000000000000 --- a/gnu/usr.bin/fgrep/std.h +++ /dev/null @@ -1,145 +0,0 @@ -/* std.h - automagically adapt to old and new compilers. - In the Public Domain; written by Mike Haertel. */ - -#if __STDC__ - -#include -#include - -typedef void *PTR; -typedef const void *PTRCONST; - -#define AND , -#define DEFUN(F, L, P) F(P) -#define EXFUN(F, P) F P - -#else - -#define const -#define volatile - -/* The following approximations of and are appropriate - for most machines. */ -typedef int ptrdiff_t; -typedef unsigned int size_t; -#define NULL 0 -#define offsetof(T, M) ((size_t)&((T *) 0)->(M)) - -#define CHAR_BIT 8 -#define SCHAR_MIN -128 -#define SCHAR_MAX 127 -#define UCHAR_MAX 255 -#define CHAR_MIN ((char) UCHAR_MAX < 0 ? SCHAR_MIN : 0) -#define CHAR_MAX ((char) UCHAR_MAX < 0 ? SCHAR_MAX : UCHAR_MAX) -#define SHRT_MIN -32768 -#define SHRT_MAX 32767 -#define USHRT_MAX 65535 -#define INT_MIN (sizeof (int) == 2 ? -32768 : -2147483648) -#define INT_MAX (sizeof (int) == 2 ? 32767 : 2147483647) -#define UINT_MAX (sizeof (int) == 2 ? 65535 : 4294967295) -#define LONG_MIN -2147483648L -#define LONG_MAX 2147483647L -#define ULONG_MAX 4294967295 - -typedef char *PTR; -typedef const char *PTRCONST; - -#define AND ; -#define DEFUN(F, L, P) F L P ; -#define EXFUN(F, P) F() - -#endif - -/* Deal with lossage. */ -#include - -#ifndef isascii - -#define ISALNUM(C) isalnum(C) -#define ISALPHA(C) isalpha(C) -#define ISCNTRL(C) iscntrl(C) -#define ISDIGIT(C) isdigit(C) -#define ISGRAPH(C) isgraph(C) -#define ISLOWER(C) islower(C) -#define ISPRINT(C) isprint(C) -#define ISPUNCT(C) ispunct(C) -#define ISSPACE(C) isspace(C) -#define ISUPPER(C) isupper(C) -#define ISXDIGIT(C) isxdigit(C) -#define TOLOWER(C) tolower(C) -#define TOUPPER(C) toupper(C) - -#else - -#define ISALNUM(C) (isascii(C) && isalnum(C)) -#define ISALPHA(C) (isascii(C) && isalpha(C)) -#define ISCNTRL(C) (isascii(C) && iscntrl(C)) -#define ISDIGIT(C) (isascii(C) && isdigit(C)) -#define ISGRAPH(C) (isascii(C) && isgraph(C)) -#define ISLOWER(C) (isascii(C) && islower(C)) -#define ISPRINT(C) (isascii(C) && isprint(C)) -#define ISPUNCT(C) (isascii(C) && ispunct(C)) -#define ISSPACE(C) (isascii(C) && isspace(C)) -#define ISUPPER(C) (isascii(C) && isupper(C)) -#define ISXDIGIT(C) (isascii(C) && isxdigit(C)) -#define TOLOWER(C) (ISUPPER(C) ? tolower(C) : (C)) -#define TOUPPER(C) (ISLOWER(C) ? toupper(C) : (C)) - -#endif - -/* Declaring this here should be safe. Some losing 's don't. */ -extern int errno; - -/* Adapt variable arguments to new implementations (with ) - or old (which are assumed to have ). */ - -#if __STDC__ - -#include - -#define VA_ALIST ... -#define VA_DCL ... -#define VA_LIST va_list -#define VA_START(AP, LASTARG) va_start(AP, LASTARG) -#define VA_ARG(AP, TYPE) va_arg(AP, TYPE) -#define VA_END(AP) va_end(AP) - -#define VA_DEFUN(F, L, P) F(P) - -#else - -#include - -#define VA_ALIST va_alist -#define VA_DCL va_dcl -#define VA_LIST va_list -#define VA_START(AP, LASTARG) va_start(AP) -#define VA_ARG(AP, TYPE) va_arg(AP, TYPE) -#define VA_END(AP) va_end(AP) - -#define VA_DEFUN(F, L, P) F L P - -#endif - -/* Declarations of traditional library routines. */ -extern double EXFUN(atof, (const char *)); -extern int EXFUN(atoi, (const char *)); -extern long int EXFUN(atol, (const char *)); -extern int EXFUN(rand, (void)); -extern void EXFUN(srand, (int)); -extern PTR EXFUN(calloc, (size_t, size_t)); -extern void EXFUN(free, (PTR)); -extern PTR EXFUN(malloc, (size_t)); -extern PTR EXFUN(realloc, (PTR, size_t)); -extern void EXFUN(abort, (void)); -extern void EXFUN(exit, (int)); -extern char *EXFUN(getenv, (const char *)); -extern int EXFUN(system, (const char *)); -extern void EXFUN(qsort, (PTR, size_t, size_t, - int EXFUN((*), (PTRCONST, PTRCONST)))); -extern int EXFUN(abs, (int)); -extern long int EXFUN(labs, (long int)); - -#ifdef X_strerror -extern char *EXFUN(strerror, (int)); -#endif diff --git a/gnu/usr.bin/fgrep/unix.h b/gnu/usr.bin/fgrep/unix.h deleted file mode 100644 index 3ac8cbd0dfdd..000000000000 --- a/gnu/usr.bin/fgrep/unix.h +++ /dev/null @@ -1,79 +0,0 @@ -/* unix.h - prototype UNIX system calls and a few library routines. - In the Public Domain; written by Mike Haertel. */ - -#define size_t unix_size_t -#include -#undef size_t -#include -#include - -/* Optionally get the directory routines. The Makefile needs to - define which version. */ -#ifdef DIRENT -#include -#else -#ifdef SYSDIR -#include -#else -#ifdef NDIR -#include -#endif /* NDIR */ -#endif /* SYSDIR */ -#endif /* DIRENT */ - -/* Prototype certain UNIX system calls. */ -extern int EXFUN(access, (const char *, int)); -extern unsigned int EXFUN(alarm, (unsigned int)); -extern PTR EXFUN(sbrk, (size_t)); -extern int EXFUN(chdir, (const char *)); -/* extern int EXFUN(chmod, (const char *, int)); /* */ -extern int EXFUN(chown, (const char *, int, int)); -extern int EXFUN(close, (int)); -extern int EXFUN(creat, (const char *, int)); -extern int EXFUN(dup, (int)); -extern int EXFUN(execl, (const char *, ...)); -extern int EXFUN(execv, (const char *, char **)); -extern int EXFUN(execle, (const char *, ...)); -extern int EXFUN(execve, (const char *, char **, char **)); -extern int EXFUN(execlp, (const char *, ...)); -extern int EXFUN(execvp, (const char *, char **)); -extern void EXFUN(_exit, (int)); -extern int EXFUN(fcntl, (int, int, int)); -extern int EXFUN(fork, (void)); -extern int EXFUN(getpid, (void)); -extern int EXFUN(getppid, (void)); -extern int EXFUN(ioctl, (int, int, PTR)); -extern int EXFUN(kill, (int, int)); -extern int EXFUN(link, (const char *, const char *)); -extern long int EXFUN(lseek, (int, long int, int)); -extern int EXFUN(open, (const char *, int, ...)); -extern void EXFUN(pause, (void)); -extern int EXFUN(pipe, (int *)); -extern int EXFUN(read, (int, char *, size_t)); -extern int EXFUN(stat, (const char *, struct stat *)); -extern int EXFUN(fstat, (int, struct stat *)); -/* extern int EXFUN(umask, (int)); /* */ -extern int EXFUN(unlink, (const char *)); -extern int EXFUN(wait, (int *)); -extern int EXFUN(write, (int, const char *, size_t)); - -/* Prototype certain UNIX library routines. */ -extern char *EXFUN(crypt, (const char *, const char *)); -extern int EXFUN(getopt, (int, char **, const char *)); -extern char EXFUN(getpass, (const char *)); -extern unsigned int EXFUN(sleep, (unsigned int)); -extern int EXFUN(isatty, (int)); -extern const char *EXFUN(ttyname, (int)); -extern int EXFUN(tgetent, (char *, const char *)); -extern int EXFUN(tgetnum, (const char *)); -extern int EXFUN(tgetflag, (const char *)); -extern char *EXFUN(tgetstr, (const char *, char **)); -extern char *EXFUN(tgoto, (const char *, int, int)); -extern int EXFUN(tputs, (const char *, int, int EXFUN((*), (int)))); -extern char *EXFUN(tparam, (const char *, char *, size_t, ...)); - -/* Declare a few UNIX-specific external objects. */ -extern char PC, *BC, *UP; -extern short int ospeed; -extern char *optarg; -extern int optind; diff --git a/gnu/usr.bin/g++/cc1plus/cplus-class.c b/gnu/usr.bin/g++/cc1plus/cplus-class.c deleted file mode 100644 index 9113820700ff..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-class.c +++ /dev/null @@ -1,6277 +0,0 @@ -/* Functions related to building and playing with classes. - Copyright (C) 1987 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* High-level class interface. */ - -#include "config.h" -#include "tree.h" -#include "cplus-tree.h" -#include "flags.h" -#include "rtl.h" -#include "assert.h" -#include - -#include "obstack.h" -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -extern int xmalloc (); -extern void free (); - -#define NULL 0 -#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) -#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) - -/* See cplus-decl.c for comment of this variable. */ -extern int flag_int_enum_equivalence; - -/* some statistics gathering help. */ -static int n_vtables, n_vtable_entries, n_vtable_searches, n_vtable_elems; -static int n_convert_harshness, n_compute_conversion_costs, n_build_method_call; -static int n_inner_fields_searched; - -/* Compute the ease with which a conversion can be performed - between an expected and the given type. */ -static int convert_harshness (); - -/* in decl.c. */ -extern tree lookup_tag_current_binding_level (); - -/* in method.c. */ -extern void do_inline_function_hair (); - -/* Way of stacking class types. */ -static tree *current_class_base, *current_class_stack; -static int current_class_stacksize; - -struct class_level -{ - /* The previous class level. */ - struct class_level *level_chain; - - /* The class instance variable, as a PARM_DECL. */ - tree decl; - /* The class instance variable, as an object. */ - tree object; - /* The virtual function table pointer - for the class instance variable. */ - tree vtable_decl; - - /* Name of the current class. */ - tree name; - /* Type of the current class. */ - tree type; - - /* Flags for this class level. */ - int this_is_variable; - int memoized_lookups; - int save_memoized; - int unused; -}; - -tree current_class_decl, C_C_D; /* PARM_DECL: the class instance variable */ -tree current_vtable_decl; - -/* The following two can be derived from the previous one */ -tree current_class_name; /* IDENTIFIER_NODE: name of current class */ -tree current_class_type; /* _TYPE: the type of the current class */ -tree prev_class_type; /* _TYPE: the previous type that was a class */ - -static tree get_vtable_name (), get_vfield_name (); -tree the_null_vtable_entry; - -/* Way of stacking langauge names. */ -static tree *current_lang_base, *current_lang_stack; -static int current_lang_stacksize; - -/* Names of languages we recognize. */ -tree lang_name_c, lang_name_cplusplus; -tree current_lang_name; - -tree minus_one_node; - -/* When layout out an aggregate type, the size of the - basetypes (virtual and non-virtual) is passed to layout_record - via this node. */ -static tree base_layout_decl; - -#if 0 -/* Make sure that the tag NAME is defined *in the current binding level* - at least as a forward reference. - CODE says which kind of tag NAME ought to be. - - Not used for C++. Not maintained. */ - -tree -start_struct (code, name) - enum tree_code code; - tree name; -{ - /* If there is already a tag defined at this binding level - (as a forward reference), just return it. */ - register tree ref = 0; - - if (name != 0) - ref = lookup_tag (code, name, current_binding_level, 1); - if (ref && TREE_CODE (ref) == code) - { - if (TYPE_FIELDS (ref)) - error ((code == UNION_TYPE ? "redefinition of `union %s'" - : "redefinition of `struct %s'"), - IDENTIFIER_POINTER (name)); - - return ref; - } - - /* Otherwise create a forward-reference just so the tag is in scope. */ - - ref = make_lang_type (code); - /* Must re-synch this with xref_tag if you are going to use it. */ - assert (0); - pushtag (name, ref); - return ref; -} -#endif - -/* Virtual baseclass things. */ -tree -build_vbase_pointer (exp, type) - tree exp, type; -{ - char *name; - - name = (char *) alloca (TYPE_NAME_LENGTH (type) + sizeof (VBASE_NAME) + 1); - sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (type)); - return build_component_ref (exp, get_identifier (name), 0, 0); -} - -/* Build multi-level access to EXPR using hierarchy path PATH. - CODE is PLUS_EXPR if we are going with the grain, - and MINUS_EXPR if we are not (in which case, we cannot traverse - virtual baseclass links). - - TYPE is the type we want this path to have on exit. - - ALIAS_THIS is non-zero if EXPR in an expression involving `this'. */ -tree -build_vbase_path (code, type, expr, path, alias_this) - enum tree_code code; - tree type; - tree expr; - tree path; - int alias_this; -{ - register int changed = 0; - tree last = NULL_TREE, last_virtual = NULL_TREE; - int fixed_type_p = 0 && resolves_to_fixed_type_p (expr); - tree basetype; - tree offset = integer_zero_node; - - if (TREE_CHAIN (path)) - path = nreverse (copy_list (path)); - - basetype = TREE_VALUE (path); - while (path) - { - if (TREE_VIA_VIRTUAL (path)) - { - last_virtual = TYPE_MAIN_VARIANT (TREE_VALUE (path)); - if (code == PLUS_EXPR) - { - changed = ! fixed_type_p; - - if (last) - expr = convert_pointer_to (TREE_VALUE (last), expr); - if (changed) - expr = build_vbase_pointer (build_indirect_ref (expr, 0), - last_virtual); - else - offset = ASSOC_OFFSET (value_member (last_virtual, - CLASSTYPE_VBASECLASSES (basetype))); - /* Happens in the case of parse errors. */ - if (expr == error_mark_node) - return expr; - } - else - { - error_with_aggr_type (last_virtual, "cannot cast up from virtual baseclass `%s'"); - return error_mark_node; - } - } - last = path; - path = TREE_CHAIN (path); - } - /* LAST is now the last basetype on the path. */ - last = TREE_VALUE (last); - - /* If we go through any virtual base pointers, make sure that - casts to BASETYPE from the last virtual base class use - the right value for BASETYPE. */ - if (changed) - { - tree intype = TREE_TYPE (TREE_TYPE (expr)); - if (TYPE_MAIN_VARIANT (intype) == TYPE_MAIN_VARIANT (last)) - basetype = intype; - else - { - basetype = get_base_type (last, TYPE_MAIN_VARIANT (intype), 0); - offset = CLASSTYPE_OFFSET (basetype); - } - } - else - { - if (last_virtual && last != last_virtual) - basetype = get_base_type (last, last_virtual, 0); - else - basetype = last; - - offset = genop (code, offset, CLASSTYPE_OFFSET (basetype)); - /* 900324 JRV: If code was MINUS_EXPR, genop returned a negative - offset, so shouldn't the code always be PLUS_EXPR now? */ - code = PLUS_EXPR; - } - - if (TREE_INT_CST_LOW (offset)) - { - /* For multiple inheritance: if `this' can be set by - any function, then it could be 0 on entry - to any function. Preserve such zeroness here. - Otherwise, only in the case of constructors need - we worry, and in those cases, it will be zero, - or initialized to some legal value to which we may - add. */ - tree addr = TREE_CODE (expr) == ADDR_EXPR - ? expr : save_expr (expr); - expr = build (code, type, addr, offset); - - if (alias_this == 0 || flag_this_is_variable) - return build (COND_EXPR, type, - build (EQ_EXPR, integer_type_node, addr, integer_zero_node), - build1 (NOP_EXPR, type, addr), - expr); - } - return build1 (NOP_EXPR, type, expr); -} - -/* Virtual function things. */ - -/* Virtual functions to be dealt with after laying out our - virtual base classes (only if the type has any). */ -static tree pending_hard_virtuals; - -/* The names of the entries in the virtual table structure. */ -static tree delta_name, pfn_name; - -/* Temporary assoc list to memoize lookups of the left-most non-virtual - baseclass B in a lattice topped by T. B can appear multiple times - in the lattice. - TREE_PURPOSE is B's TYPE_MAIN_VARIANT. - TREE_VALUE is the path by which B is reached from T. - TREE_TYPE is B's real type. - - If TREE_TYPE is NULL_TREE, it means that B was reached via - a virtual baseclass. - N.B.: This list consists of nodes on the temporary obstack. */ -static tree leftmost_baseclasses; - -/* Build an entry in the virtual function table. - DELTA is the offset for the `this' pointer. - PFN is an ADDR_EXPR containing a pointer to the virtual function. - Note that the index (DELTA2) in the virtual function table - is always 0. */ -tree -build_vtable_entry (delta, pfn) - tree delta, pfn; -{ - tree elems = tree_cons (NULL_TREE, delta, - tree_cons (NULL_TREE, integer_zero_node, - build_tree_list (NULL_TREE, pfn))); - tree entry = build (CONSTRUCTOR, vtable_entry_type, NULL_TREE, elems); - TREE_LITERAL (entry) = 1; - TREE_STATIC (entry) = 1; - TREE_READONLY (entry) = 1; - -#ifdef GATHER_STATISTICS - n_vtable_entries += 1; -#endif - - return entry; -} - -/* Given an object INSTANCE, return an expression which yields - the virtual function corresponding to INDEX. There are many special - cases for INSTANCE which we take care of here, mainly to avoid - creating extra tree nodes when we don't have to. */ -tree -build_vfn_ref (ptr_to_instptr, instance, index) - tree *ptr_to_instptr, instance; - tree index; -{ - extern int building_cleanup; - tree vtbl, aref; - tree basetype = TREE_TYPE (instance); - - if (TREE_CODE (basetype) == REFERENCE_TYPE) - basetype = TREE_TYPE (basetype); - - if (instance == C_C_D) - { - if (current_vtable_decl == NULL_TREE - || current_vtable_decl == error_mark_node - || get_base_type (DECL_FCONTEXT (CLASSTYPE_VFIELD (current_class_type)), basetype, 0) == NULL_TREE) - vtbl = build_indirect_ref (build_vfield_ref (instance, basetype)); - else - vtbl = current_vtable_decl; - } - else - { - if (optimize) - { - /* Try to figure out what a reference refers to, and - access its virtual function table directly. */ - tree ref = 0; - - if (TREE_CODE (instance) == INDIRECT_REF - && TREE_CODE (TREE_TYPE (TREE_OPERAND (instance, 0))) == REFERENCE_TYPE) - ref = TREE_OPERAND (instance, 0); - else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE) - ref = instance; - - if (ref && TREE_CODE (ref) == VAR_DECL - && DECL_INITIAL (ref)) - { - tree init = DECL_INITIAL (ref); - - while (TREE_CODE (init) == NOP_EXPR - || TREE_CODE (init) == REFERENCE_EXPR) - init = TREE_OPERAND (init, 0); - if (TREE_CODE (init) == ADDR_EXPR) - { - init = TREE_OPERAND (init, 0); - if (IS_AGGR_TYPE (TREE_TYPE (init)) - && (TREE_CODE (init) == PARM_DECL - || TREE_CODE (init) == VAR_DECL)) - instance = init; - } - } - } - - if (IS_AGGR_TYPE (instance) - && (TREE_CODE (instance) == RESULT_DECL - || TREE_CODE (instance) == PARM_DECL - || TREE_CODE (instance) == VAR_DECL)) - vtbl = CLASS_ASSOC_VTABLE (basetype); - else - vtbl = build_indirect_ref (build_vfield_ref (instance, basetype), 0); - } - aref = build_array_ref (vtbl, index); - if (!building_cleanup && TREE_CODE (aref) == INDIRECT_REF) - TREE_OPERAND (aref, 0) = save_expr (TREE_OPERAND (aref, 0)); - - *ptr_to_instptr = build (PLUS_EXPR, TREE_TYPE (*ptr_to_instptr), - *ptr_to_instptr, - convert (integer_type_node, build_component_ref (aref, delta_name, 0, 0))); - return build_component_ref (aref, pfn_name, 0, 0); -} - -/* Build a virtual function for type TYPE. - If ASSOC is non-NULL, build the vtable starting with the intial - approximation that it is the same as the one which is the head of - the assocation list. */ -static tree -build_vtable (assoc, type) - tree assoc, type; -{ - tree name = get_vtable_name (type); - tree virtuals, decl; - - if (assoc) - { - virtuals = copy_list (ASSOC_VIRTUALS (assoc)); - decl = build_decl (VAR_DECL, name, TREE_TYPE (ASSOC_VTABLE (assoc))); - } - else - { - virtuals = NULL_TREE; - decl = build_decl (VAR_DECL, name, void_type_node); - } - -#ifdef GATHER_STATISTICS - n_vtables += 1; - n_vtable_elems += list_length (virtuals); -#endif - - if (write_virtuals >= 2) - { - if (CLASSTYPE_INTERFACE_UNKNOWN (type) == 0) - { - TREE_PUBLIC (decl) = CLASSTYPE_VTABLE_NEEDS_WRITING (type); - TREE_EXTERNAL (decl) = ! CLASSTYPE_VTABLE_NEEDS_WRITING (type); - } - } - else if (write_virtuals > 0) - TREE_PUBLIC (decl) = 1; - else if (write_virtuals < 0) - TREE_EXTERNAL (decl) = 1; - - IDENTIFIER_GLOBAL_VALUE (name) = decl = pushdecl_top_level (decl); - /* Initialize the association list for this type, based - on our first approximation. */ - CLASS_ASSOC_VTABLE (type) = decl; - CLASS_ASSOC_VIRTUALS (type) = virtuals; - - TREE_STATIC (decl) = 1; - DECL_ALIGN (decl) = MAX (TYPE_ALIGN (double_type_node), - DECL_ALIGN (decl)); - - if (assoc && write_virtuals >= 0) - DECL_VIRTUAL_P (decl) = 1; - /* Remember which class this vtable is really for. */ - DECL_VPARENT (decl) = type; - DECL_CONTEXT (decl) = type; - CLASSTYPE_MARKED3 (type) = 1; - CLASSTYPE_MARKED4 (type) = 1; - return decl; -} - -/* Give TYPE a new virtual function table which is initialized - with a skeleton-copy of its original initialization. The only - entry that changes is the `delta' entry, so we can really - share a lot of structure. - - FOR_TYPE is the derived type which caused this table to - be needed. - - ASSOC is the type association which provided TYPE for FOR_TYPE. - - The way we update BASE_ASSOC's vtable information is just to change the - association information in FOR_TYPE's association list. */ -static void -prepare_fresh_vtable (assoc, base_assoc, for_type) - tree assoc, base_assoc, for_type; -{ - tree basetype = ASSOC_TYPE (assoc); - tree orig_decl = ASSOC_VTABLE (assoc); - tree name = build_type_pathname (VTABLE_NAME_FORMAT, basetype, for_type); - tree new_decl = build_decl (VAR_DECL, name, TREE_TYPE (orig_decl)); - tree path; - int result; - - assert (TREE_USED (assoc) == 0); - - /* Remember which class this vtable is really for. */ - DECL_VPARENT (new_decl) = ASSOC_TYPE (base_assoc); - DECL_CONTEXT (new_decl) = for_type; - - TREE_STATIC (new_decl) = 1; - ASSOC_VTABLE (assoc) = pushdecl_top_level (new_decl); - DECL_VIRTUAL_P (new_decl) = 1; - DECL_ALIGN (new_decl) = DECL_ALIGN (orig_decl); - - /* Make fresh virtual list, so we can smash it later. */ - assert (ASSOC_VIRTUALS (assoc)); - ASSOC_VIRTUALS (assoc) = copy_list (ASSOC_VIRTUALS (assoc)); - -#ifdef GATHER_STATISTICS - n_vtables += 1; - n_vtable_elems += list_length (ASSOC_VIRTUALS (assoc)); -#endif - - /* Set `new_decl's PUBLIC and EXTERNAL bits. */ - if (write_virtuals >= 2) - { - if (CLASSTYPE_INTERFACE_UNKNOWN (for_type) == 0) - { - TREE_PUBLIC (new_decl) = CLASSTYPE_VTABLE_NEEDS_WRITING (for_type); - TREE_EXTERNAL (new_decl) = ! CLASSTYPE_VTABLE_NEEDS_WRITING (for_type); - } - } - else if (write_virtuals > 0) - TREE_PUBLIC (new_decl) = 1; - else if (write_virtuals < 0) - TREE_EXTERNAL (new_decl) = 1; - - CLASSTYPE_MARKED3 (basetype) = 1; - CLASSTYPE_MARKED4 (basetype) = 1; - - /* Mark all types between FOR_TYPE and TYPE as having been - touched, so that if we change virtual function table entries, - new vtables will be initialized. We may reach the virtual - baseclass via ambiguous intervening baseclasses. This - loop makes sure we get through to the actual baseclass we marked. */ - - do - { - result = get_base_distance (basetype, for_type, 0, &path); - for_type = TREE_VALUE (path); - while (path) - { - CLASSTYPE_MARKED3 (TREE_VALUE (path)) = 1; - path = TREE_CHAIN (path); - } - } - while (result == -2); -} - -/* Access the virtual function table entry that logically - contains BASE_FNDECL. VIRTUALS is the virtual function table's - initializer. */ -static tree -get_vtable_entry (virtuals, base_fndecl) - tree virtuals, base_fndecl; -{ - int i = (HOST_BITS_PER_INT >= BITS_PER_WORD -#ifdef VTABLE_USES_MASK - && 0 -#endif - ? (TREE_INT_CST_LOW (DECL_VINDEX (base_fndecl)) - & ((1<<(BITS_PER_WORD-1))-1)) - : TREE_INT_CST_LOW (DECL_VINDEX (base_fndecl))); - -#ifdef GATHER_STATISTICS - n_vtable_searches += i; -#endif - - while (i > 0) - { - virtuals = TREE_CHAIN (virtuals); - i -= 1; - } - return virtuals; -} - -/* Put new entry ENTRY into virtual function table initializer - VIRTUALS. The virtual function table is for type CONTEXT. - - Also update DECL_VINDEX (FNDECL). */ - -static void -modify_vtable_entry (old_entry_in_list, new_entry, fndecl, context) - tree old_entry_in_list, new_entry, fndecl, context; -{ - tree base_pfn = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (old_entry_in_list)); - tree vindex; - - /* We can't put in the really right offset information - here, since we have not yet laid out the class to - take into account virtual base classes. */ - TREE_VALUE (old_entry_in_list) = new_entry; - vindex = DECL_VINDEX (TREE_OPERAND (base_pfn, 0)); - if (TREE_CODE (DECL_VINDEX (fndecl)) != INTEGER_CST) - SET_DECL_VINDEX (fndecl, vindex); - else - { - if (! tree_int_cst_equal (DECL_VINDEX (fndecl), vindex)) - { - tree elts = CONSTRUCTOR_ELTS (new_entry); - tree vfield = CLASSTYPE_VFIELD (context); - /* Compute the relative offset of vtable we are really looking for. */ - TREE_VALUE (elts) = genop (PLUS_EXPR, - build_int (DECL_OFFSET (vfield) - / DECL_SIZE_UNIT (vfield)), - TREE_VALUE (elts)); - /* Say what index to use when we use that vtable. */ -#ifndef VTABLE_USES_MASK - vindex = build_int_2 (TREE_INT_CST_LOW (vindex) & ~(1 << (BITS_PER_WORD -1)), 0); -#endif - TREE_VALUE (TREE_CHAIN (elts)) = vindex; - } - } -} - -/* Modify virtual function tables in lattice topped by T to - place FNDECL in tables which previously held BASE_FNDECL. - PFN is just FNDECL wrapped in an ADDR_EXPR, so that it - is suitable for placement directly into an initializer. - - All distinct virtual function tables that this type uses - must be updated. */ -static void -modify_vtable_entries (t, fndecl, base_fndecl, pfn) - tree t; - tree fndecl, base_fndecl, pfn; -{ - tree base_offset, offset; - tree context = DECL_CONTEXT (base_fndecl); - tree vfield = CLASSTYPE_VFIELD (t); - tree vfields, vbases; - - DECL_VCONTEXT (fndecl) = DECL_VCONTEXT (base_fndecl); - - if (DECL_CONTEXT (fndecl) == t - || !(TYPE_USES_VIRTUAL_BASECLASSES (t) - || TYPE_USES_MULTIPLE_INHERITANCE (t))) - offset = integer_zero_node; - else - { - tree assoc = virtual_member (DECL_CONTEXT (fndecl), CLASSTYPE_VBASECLASSES (t)); - if (assoc == NULL_TREE) - assoc = assoc_value (DECL_CONTEXT (fndecl), t); - assert (assoc != NULL_TREE); - offset = ASSOC_OFFSET (assoc); - } - - /* For each layer of base class (i.e., the first base class, and each - virtual base class from that one), modify the virtual function table - of the derived class to contain the new virtual function. - A class has as many vfields as it has virtual base classes (total). */ - for (vfields = CLASSTYPE_VFIELDS (t); vfields; vfields = TREE_CHAIN (vfields)) - { - int normal = 1; - tree assoc, this_offset; - tree base, path; - - /* Find the right base class for this derived class, call it BASE. */ - base = TREE_VALUE (vfields); - - if (base != context) - { - /* If BASE_FNDECL is not contained in the vtable accessed by - the vslot, don't try to modify the vtable. - - Virtual functions from virtual baseclasses are not in derived - virtual function tables. This is an implementation decision; - it keeps there from being a combinatorial exposion in the - number of different vtables which must be maintained. */ - - if (get_base_distance (base, context, 0, 0) == -1) - continue; - - /* BASE_FNDECL is defined in a class derived from - the base class owning this VFIELD. */ - } - /* Get the path starting from the deepest base class CONTEXT - of T (i.e., first defn of BASE_FNDECL). */ - get_base_distance (context, t, 0, &path); - - /* Get our best approximation of what to use for constructing - the virtual function table for T. */ - do - { - /* Walk from base toward derived, stopping at the - most derived baseclass that matters. */ - if (TREE_VIA_VIRTUAL (path)) - { - base = TREE_VALUE (path); - assoc = value_member (TYPE_MAIN_VARIANT (base), CLASSTYPE_VBASECLASSES (t)); - break; - } - if (TREE_CHAIN (path) == NULL_TREE - || (CLASSTYPE_BASECLASS (TREE_VALUE (TREE_CHAIN (path)), 1) - != TREE_VALUE (path)) - || TREE_CHAIN (TREE_CHAIN (path)) == NULL_TREE) - { - base = TREE_VALUE (path); - assoc = assoc_value (TYPE_MAIN_VARIANT (base), t); - break; - } - path = TREE_CHAIN (path); - } - while (1); - - /* Find the right offset for the this pointer based on the base - class we just found. */ - base_offset = ASSOC_OFFSET (assoc); - if (base_offset == integer_zero_node) - this_offset = offset; - else - this_offset = genop (MINUS_EXPR, offset, base_offset); - - /* Make sure we can modify the derived association with immunity. */ - if (TREE_USED (CLASSTYPE_ASSOC (t))) - CLASSTYPE_ASSOC (t) = copy_assoc (CLASSTYPE_ASSOC (t)); - - /* We call this case NORMAL iff this virtual function table - pointer field has its storage reserved in this class. - This is normally the case without virtual baseclasses - or off-center multiple baseclasses. */ - normal = (vfield != NULL_TREE - && TREE_VALUE (vfields) == DECL_FCONTEXT (vfield) - && (TREE_PURPOSE (vfields) == NULL_TREE - || ! TREE_VIA_VIRTUAL (TREE_PURPOSE (vfields)))); - - if (normal && TREE_PURPOSE (vfields)) - /* Everything looks normal so far...check that we are really - working from VFIELD's basetype, and not some other appearance - of that basetype in the lattice. */ - normal = (TREE_PURPOSE (vfields) == get_base_type (TREE_VALUE (vfields), t, 0)); - - if (normal) - { - /* In this case, it is *type*'s vtable we are modifying. */ - context = t; - if (! CLASSTYPE_MARKED4 (t)) - build_vtable (assoc, t); - assoc = CLASSTYPE_ASSOC (t); - } - else - { - /* This is our very own copy of `basetype' to play with. */ - if (! CLASSTYPE_MARKED4 (ASSOC_TYPE (assoc))) - prepare_fresh_vtable (assoc, CLASSTYPE_ASSOC (base), t); - } - - modify_vtable_entry (get_vtable_entry (ASSOC_VIRTUALS (assoc), base_fndecl), - build_vtable_entry (this_offset, pfn), - fndecl, context); - } - for (vbases = CLASSTYPE_VBASECLASSES (t); vbases; vbases = TREE_CHAIN (vbases)) - { - tree this_offset; - tree base, path; - - if (! ASSOC_VTABLE (vbases)) - /* There are only two ways that a type can fail to have - virtual functions: neither it nor any of its base - types define virtual functions (in which case - no updating need be done), or virtual functions - accessible to it come from virtual base classes - (in which case we have or will get them modified - in other passes of this loop). */ - continue; - - base = TREE_VALUE (vbases); - path = NULL_TREE; - - if (base != context - && get_base_distance (context, base, 0, &path) == -1) - continue; - - /* Doesn't matter if not actually from this virtual base class, - but shouldn't come from deeper virtual baseclasses. The enclosing - loop should take care of such baseclasses. */ - while (path) - { - if (TREE_VIA_VIRTUAL (path)) - goto skip; - path = TREE_CHAIN (path); - } - - base_offset = ASSOC_OFFSET (vbases); - if (base_offset == integer_zero_node) - this_offset = offset; - else - this_offset = genop (MINUS_EXPR, offset, base_offset); - - /* Make sure we can modify the derived association with immunity. */ - if (TREE_USED (CLASSTYPE_ASSOC (t))) - CLASSTYPE_ASSOC (t) = copy_assoc (CLASSTYPE_ASSOC (t)); - - /* This is our very own copy of `basetype' to play with. */ - if (! CLASSTYPE_MARKED4 (ASSOC_TYPE (vbases))) - { - tree context_assoc = assoc_value (context, base); - prepare_fresh_vtable (vbases, context_assoc, t); - } - modify_vtable_entry (get_vtable_entry (ASSOC_VIRTUALS (vbases), base_fndecl), - build_vtable_entry (this_offset, pfn), - fndecl, context); - skip: {} - } -} - -static tree -add_virtual_function (pending_virtuals, has_virtual, x, first) - tree pending_virtuals; - int *has_virtual; - tree x; - int first; -{ - int debug_vbase = 1; - - /* FUNCTION_TYPEs and OFFSET_TYPEs no longer freely - convert to void *. Make such a conversion here. */ - tree vfn = build1 (ADDR_EXPR, ptr_type_node, x); - TREE_LITERAL (vfn) = 1; - TREE_ADDRESSABLE (x) = CLASSTYPE_VTABLE_NEEDS_WRITING (current_class_type); - - /* If the virtual function is a redefinition of a prior one, - figure out in which base class the new definition goes, - and if necessary, make a fresh virtual function table - to hold that entry. */ - if (DECL_VINDEX (x) == NULL_TREE) - { - tree entry = build_vtable_entry (integer_zero_node, vfn); - - /* Build a new INT_CST for this DECL_VINDEX. */ -#ifdef VTABLE_USES_MASK - SET_DECL_VINDEX (x, build_int_2 (++(*has_virtual), 0)); -#else - SET_DECL_VINDEX (x, build_int_2 (((1 << (BITS_PER_WORD - 1)) | ++(*has_virtual)), ~0)); -#endif - pending_virtuals = tree_cons (DECL_VINDEX (x), entry, pending_virtuals); - } - /* Happens if declared twice in class. We will give error - later. */ - else if (TREE_CODE (DECL_VINDEX (x)) == INTEGER_CST) - return pending_virtuals; - else if (debug_vbase && TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)) - { - /* Need an entry in some other virtual function table. - Deal with this after we have laid out our virtual base classes. */ - pending_hard_virtuals = temp_tree_cons (x, vfn, pending_hard_virtuals); - } - else - { - /* Need an entry in some other virtual function table. - We can do this now. */ - tree base_fndecl_list = DECL_VINDEX (x), base_fndecls, prev = 0; - tree vtable_context = DECL_FCONTEXT (CLASSTYPE_VFIELD (current_class_type)); - tree true_base_fndecl = 0; - - /* First assign DECL_VINDEX from the base vfn with which - we share our vtable. */ - base_fndecls = base_fndecl_list; - while (base_fndecls) - { - if (TREE_CHAIN (base_fndecls) == NULL_TREE - || DECL_FCONTEXT (CLASSTYPE_VFIELD (DECL_CONTEXT (TREE_VALUE (base_fndecls)))) == vtable_context) - { - true_base_fndecl = TREE_VALUE (base_fndecls); - modify_vtable_entries (current_class_type, x, - true_base_fndecl, vfn); - if (prev) - TREE_CHAIN (prev) = TREE_CHAIN (base_fndecls); - else - base_fndecl_list = prev; - break; - } - prev = base_fndecls; - base_fndecls = TREE_CHAIN (base_fndecls); - } - - /* Now fill in the rest of the vtables. */ - base_fndecls = base_fndecl_list; - while (base_fndecls) - { - /* If we haven't found one we like, first one wins. */ - if (true_base_fndecl == 0) - true_base_fndecl = TREE_VALUE (base_fndecls); - - modify_vtable_entries (current_class_type, x, - TREE_VALUE (base_fndecls), vfn); - base_fndecls = TREE_CHAIN (base_fndecls); - } - - DECL_VCONTEXT (x) = DECL_VCONTEXT (true_base_fndecl); - } - return pending_virtuals; -} - -/* Obstack on which to build the vector of class methods. */ -struct obstack class_obstack; -extern struct obstack *current_obstack; - -/* Add method METHOD to class TYPE. This is used when a method - has been defined which did not initially appear in the class definition, - and helps cut down on spurious error messages. - - FIELDS is the entry in the METHOD_VEC vector entry of the class type where - the method should be added. */ -void -add_method (type, fields, method) - tree type, *fields, method; -{ - /* We must make a copy of METHOD here, since we must be sure that - we have exclusive title to this method's TREE_CHAIN. */ - int temp = allocation_temporary_p (); - tree decl; - - if (temp) - end_temporary_allocation (); - { - decl = copy_node (method); - if (DECL_RTL (decl) == 0) - make_function_rtl (decl); - } - - if (fields && *fields) - { - /* Take care not to hide destructor. */ - TREE_CHAIN (decl) = TREE_CHAIN (*fields); - TREE_CHAIN (*fields) = decl; - } - else if (CLASSTYPE_METHOD_VEC (type) == 0) - { - tree method_vec = make_node (TREE_VEC); - if (DECL_NAME (TYPE_NAME (type)) == DECL_ORIGINAL_NAME (decl)) - { - TREE_VEC_ELT (method_vec, 0) = decl; - TREE_VEC_LENGTH (method_vec) = 1; - } - else - { - obstack_free (current_obstack, method_vec); - obstack_blank (current_obstack, sizeof (struct tree_vec) + sizeof (tree *)); - TREE_VEC_ELT (method_vec, 1) = decl; - TREE_VEC_LENGTH (method_vec) = 2; - obstack_finish (current_obstack); - } - CLASSTYPE_METHOD_VEC (type) = method_vec; - } - else - { - tree method_vec = CLASSTYPE_METHOD_VEC (type); - int len = TREE_VEC_LENGTH (method_vec); - - /* Adding a new ctor or dtor. */ - if (DECL_NAME (TYPE_NAME (type)) == DECL_ORIGINAL_NAME (decl)) - TREE_VEC_ELT (method_vec, 0) = decl; - else - { - tree *end = (tree *)obstack_next_free (&class_obstack); - if (end != TREE_VEC_END (method_vec)) - { - tree tmp_vec = copy_node (method_vec); - obstack_copy (current_obstack, &TREE_VEC_ELT (method_vec, 1), len); - obstack_blank (current_obstack, sizeof (tree *)); - obstack_finish (current_obstack); - method_vec = tmp_vec; - } - else - { - /* We can easily extend the last such method_vec created. */ - obstack_free (&class_obstack, method_vec); - obstack_blank (&class_obstack, - ((char *)end - (char *)method_vec) + sizeof (tree *)); - method_vec = (tree)obstack_base (&class_obstack); - obstack_finish (&class_obstack); - } - TREE_VEC_ELT (method_vec, len) = decl; - TREE_VEC_LENGTH (method_vec) = len + 1; - CLASSTYPE_METHOD_VEC (type) = method_vec; - - if (CLASSTYPE_BASELINK_VEC (type)) - { - /* ??? May be better to know whether these can be extended? */ - tree baselink_vec = copy_node (CLASSTYPE_BASELINK_VEC (type)); - - obstack_copy (current_obstack, &TREE_VEC_ELT (CLASSTYPE_BASELINK_VEC (type), 1), len); - TREE_VEC_ELT (baselink_vec, len) = 0; - TREE_VEC_LENGTH (baselink_vec) = len + 1; - CLASSTYPE_BASELINK_VEC (type) = baselink_vec; - } - } - } - DECL_CONTEXT (decl) = type; - DECL_VCONTEXT (decl) = type; - - if (temp) - resume_temporary_allocation (); -} - -/* Subroutines of finish_struct. */ - -/* Look through the list of fields for this struct, deleting - duplicates as we go. This must be recursive to handle - anonymous unions. - - FIELD is the field which may not appear anywhere in FIELDS. - FIELD_PTR, if non-null, is the starting point at which - chained deletions may take place. - The value returned is the first acceptable entry found - in FIELDS. - - Note that anonymous fields which are not of UNION_TYPE are - not duplicates, they are just anonymous fields. This happens - when we have unnamed bitfields, for example. */ -static tree -delete_duplicate_fields_1 (field, field_ptr, fields) - tree field, *field_ptr, fields; -{ - tree x; - tree prev = field_ptr ? *field_ptr : 0; - if (DECL_NAME (field) == 0) - { - if (TREE_CODE (TREE_TYPE (field)) != UNION_TYPE) - return fields; - - for (x = TYPE_FIELDS (TREE_TYPE (field)); x; x = TREE_CHAIN (x)) - fields = delete_duplicate_fields_1 (x, field_ptr, fields); - if (prev) - TREE_CHAIN (prev) = fields; - return fields; - } - else - { - for (x = fields; x; prev = x, x = TREE_CHAIN (x)) - { - if (DECL_NAME (x) == 0) - { - if (TREE_CODE (TREE_TYPE (x)) != UNION_TYPE) - continue; - TYPE_FIELDS (TREE_TYPE (x)) - = delete_duplicate_fields_1 (field, 0, TYPE_FIELDS (TREE_TYPE (x))); - if (TYPE_FIELDS (TREE_TYPE (x)) == 0) - { - if (prev == 0) - fields = TREE_CHAIN (fields); - else - TREE_CHAIN (prev) = TREE_CHAIN (x); - } - } - else - { - if (DECL_NAME (field) == DECL_NAME (x)) - { - if (TREE_CODE (field) == CONST_DECL - && TREE_CODE (x) == CONST_DECL) - error_with_decl (x, "duplicate enum value `%s'"); - else if (TREE_CODE (field) == CONST_DECL - || TREE_CODE (x) == CONST_DECL) - error_with_decl (x, "duplicate field `%s' (as enum and non-enum)"); - else - error_with_decl (x, "duplicate member `%s'"); - if (prev == 0) - fields = TREE_CHAIN (fields); - else - TREE_CHAIN (prev) = TREE_CHAIN (x); - } - } - } - } - return fields; -} - -static void -delete_duplicate_fields (fields) - tree fields; -{ - tree x; - for (x = fields; x && TREE_CHAIN (x); x = TREE_CHAIN (x)) - TREE_CHAIN (x) = delete_duplicate_fields_1 (x, &x, TREE_CHAIN (x)); -} - -/* Add OFFSET to all child types of T. - - OFFSET, which is a type offset, is number of bytes. - - Note that we don't have to worry about having two paths to the - same base type, since this type owns its association list. */ -static void -propagate_basetype_offsets (for_type, t, offset) - tree for_type, t; - tree offset; -{ - int i, n_baselinks = CLASSTYPE_N_BASECLASSES (t); - - for (i = 1; i <= n_baselinks; i++) - if (! CLASSTYPE_VIA_VIRTUAL (t, i)) - { - int j; - tree basetype = CLASSTYPE_BASECLASS (t, i); - tree assoc = assoc_value (TYPE_MAIN_VARIANT (basetype), for_type); - tree delta; - - for (j = i+1; j <= n_baselinks; j++) - if (! CLASSTYPE_VIA_VIRTUAL (t, j)) - { - /* The next basetype offset must take into account the space - between the classes, not just the size of each class. */ - delta = genop (MINUS_EXPR, - CLASSTYPE_OFFSET (CLASSTYPE_BASECLASS (t, j)), - CLASSTYPE_OFFSET (basetype)); - break; - } - - if (CLASSTYPE_OFFSET (basetype) == integer_zero_node) - basetype = build_classtype_variant (basetype, offset, 0); - else - basetype = build_classtype_variant (basetype, - genop (PLUS_EXPR, CLASSTYPE_OFFSET (basetype), offset), 0); - /* Now make our own copy of this base type we can munge. */ - basetype = copy_node (basetype); - copy_type_lang_specific (basetype); - - CLASSTYPE_BASECLASS (t, i) = basetype; - ASSOC_TYPE (assoc) = basetype; - ASSOC_OFFSET (assoc) = CLASSTYPE_OFFSET (basetype); - TYPE_NAME (basetype) = copy_node (TYPE_NAME (basetype)); - TREE_TYPE (TYPE_NAME (basetype)) = basetype; - DECL_OFFSET (TYPE_NAME (basetype)) - = TREE_INT_CST_LOW (CLASSTYPE_OFFSET (basetype)) * BITS_PER_UNIT; - propagate_basetype_offsets (for_type, basetype, offset); - - /* Go to our next class that counts for offset propagation. */ - i = j; - if (i <= n_baselinks) - offset = genop (PLUS_EXPR, offset, delta); - } -} - -/* Change the visibility of T::FDECL to VISIBILITY. - Return 1 if change was legit, otherwise return 0. */ -static int -alter_visibility (t, fdecl, visibility) - tree t; - tree fdecl; - enum visibility_type visibility; -{ - tree elem = purpose_member (t, DECL_VISIBILITY (fdecl)); - if (elem && TREE_VALUE (elem) != (tree)visibility) - { - if (TREE_CODE (TREE_TYPE (fdecl)) == FUNCTION_DECL) - { - error_with_decl (TREE_TYPE (fdecl), "conflicting visibility specifications for method `%s', ignored"); - } - else error ("conflicting visibility specifications for field `%s', ignored", IDENTIFIER_POINTER (DECL_NAME (fdecl))); - } - else if (TREE_PRIVATE (fdecl) && visibility != visibility_private) - error_with_decl (fdecl, "cannot make private %s non-private"); - else if (TREE_PROTECTED (fdecl) && visibility == visibility_public) - - error_with_decl (fdecl, "cannot make protected %s public"); - else if (elem == NULL_TREE) - { - DECL_VISIBILITY (fdecl) = tree_cons (t, (tree)visibility, - DECL_VISIBILITY (fdecl)); - return 1; - } - return 0; -} - -/* If FOR_TYPE needs to reinitialize virtual function table pointers - for TYPE's sub-objects, add such reinitializations to BASE_INIT_LIST. - Returns BASE_INIT_LIST appropriately modified. */ - -static tree -maybe_fixup_vptrs (for_type, type, base_init_list) - tree for_type, type, base_init_list; -{ - /* Now reinitialize any slots that don't fall under our virtual - function table pointer. */ - tree vfields = CLASSTYPE_VFIELDS (type); - while (vfields) - { - tree basetype = get_base_type (TREE_VALUE (vfields), for_type, 0); - if (CLASSTYPE_NEEDS_VIRTUAL_REINIT (basetype) - && ((DECL_OFFSET (CLASSTYPE_VFIELD (basetype)) - + DECL_OFFSET (TYPE_NAME (basetype))) - != DECL_OFFSET (CLASSTYPE_VFIELD (for_type))) - && ((DECL_OFFSET (CLASSTYPE_VFIELD (basetype)) - + DECL_OFFSET (TYPE_NAME (basetype))) - != (DECL_OFFSET (CLASSTYPE_VFIELD (type)) - + DECL_OFFSET (TYPE_NAME (type))))) - base_init_list = tree_cons (error_mark_node, basetype, - base_init_list); - vfields = TREE_CHAIN (vfields); - } - return base_init_list; -} - -/* If TYPE does not have a constructor, then the compiler must - manually deal with all of the initialization this type requires. - - If a base initializer exists only to fill in the virtual function - table pointer, then we mark that fact with the TREE_VIRTUAL bit. - This way, we avoid multiple initializations of the same field by - each virtual function table up the class hierarchy. - - Virtual base class pointers are not initialized here. They are - initialized only at the "top level" of object creation. If we - initialized them here, we would have to skip a lot of work. */ - -static void -build_class_init_list (type) - tree type; -{ - tree base_init_list = NULL_TREE; - tree member_init_list = NULL_TREE; - - /* Since we build member_init_list and base_init_list using - tree_cons, backwards fields the all through work. */ - tree x; - int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (type); - - for (x = TYPE_FIELDS (type); x; x = TREE_CHAIN (x)) - { - if (TREE_CODE (x) != FIELD_DECL) - continue; - - if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (x)) - || DECL_INITIAL (x) != NULL_TREE) - member_init_list = tree_cons (x, type, member_init_list); - } - member_init_list = nreverse (member_init_list); - - /* We will end up doing this last. Need special marker - to avoid infinite regress. */ - if (TYPE_VIRTUAL_P (type)) - { - base_init_list = build_tree_list (error_mark_node, type); - if (CLASSTYPE_NEEDS_VIRTUAL_REINIT (type) == 0) - TREE_VALUE (base_init_list) = NULL_TREE; - TREE_ADDRESSABLE (base_init_list) = 1; - } - - /* Each base class which needs to have initialization - of some kind gets to make such requests known here. */ - for (i = n_baseclasses; i > 0; i--) - { - tree basetype = CLASSTYPE_BASECLASS (type, i); - tree blist; - - /* Don't initialize virtual baseclasses this way. */ - if (TREE_VIA_VIRTUAL (basetype)) - continue; - - if (TYPE_HAS_CONSTRUCTOR (basetype)) - { - /* ...and the last shall come first... */ - base_init_list = maybe_fixup_vptrs (type, basetype, base_init_list); - base_init_list = tree_cons (NULL_TREE, basetype, - base_init_list); - continue; - } - - if ((blist = CLASSTYPE_BASE_INIT_LIST (basetype)) == NULL_TREE) - /* Nothing to initialize. */ - continue; - - /* ...ditto... */ - base_init_list = maybe_fixup_vptrs (type, basetype, base_init_list); - - /* This is normally true for single inheritance. - The win is we can shrink the chain of initializations - to be done by only converting to the actual type - we are interested in. */ - if (TREE_VALUE (blist) - && TREE_CODE (TREE_VALUE (blist)) == RECORD_TYPE - && (DECL_OFFSET (TYPE_NAME (basetype)) - == DECL_OFFSET (TYPE_NAME (TREE_VALUE (blist))))) - { - if (base_init_list) - { - /* Does it do more than just fill in a - virtual function table pointer? */ - if (! TREE_ADDRESSABLE (blist)) - base_init_list = build_tree_list (blist, base_init_list); - /* Can we get by just with the virtual function table - pointer that it fills in? */ - else if (TREE_ADDRESSABLE (base_init_list) - && TREE_VALUE (base_init_list) == 0) - base_init_list = blist; - /* Maybe, but it is not obvious as the previous case. */ - else if (! CLASSTYPE_NEEDS_VIRTUAL_REINIT (type)) - { - tree last = tree_last (base_init_list); - while (TREE_VALUE (last) - && TREE_CODE (TREE_VALUE (last)) == TREE_LIST) - last = tree_last (TREE_VALUE (last)); - if (TREE_VALUE (last) == 0) - base_init_list = build_tree_list (blist, base_init_list); - } - } - else - base_init_list = blist; - } - else - { - /* The function expand_aggr_init knows how to do the - initialization of `basetype' without getting - an explicit `blist'. */ - if (base_init_list) - base_init_list = tree_cons (NULL_TREE, basetype, base_init_list); - else - base_init_list = CLASSTYPE_AS_LIST (basetype); - } - } - - if (base_init_list) - if (member_init_list) - CLASSTYPE_BASE_INIT_LIST (type) = build_tree_list (base_init_list, member_init_list); - else - CLASSTYPE_BASE_INIT_LIST (type) = base_init_list; - else if (member_init_list) - CLASSTYPE_BASE_INIT_LIST (type) = member_init_list; -} - -struct base_info -{ - int has_virtual; - int max_has_virtual; - int n_ancestors; - tree vfield; - tree vfields; - char needs_default_ctor; - char cant_have_default_ctor; - char needs_const_ctor; - char cant_have_const_ctor; -}; - -/* Record information about type T derived from its base classes. - Store most of that information in T itself, and place the - remaining information in the struct BASE_INFO. - - Returns the index of the first base class to have virtual functions, - or zero if no such base class. */ - -static int -finish_base_struct (t, b) - tree t; - struct base_info *b; -{ - int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (t); - int first_vfn_base_index = 0; - - bzero (b, sizeof (struct base_info)); - - for (i = 1; i <= n_baseclasses; i++) - { - tree basetype = CLASSTYPE_BASECLASS (t, i); - - /* If the type of basetype is incomplete, then - we already complained about that fact - (and we should have fixed it up as well). */ - if (TYPE_SIZE (basetype) == 0) - { - int j; - /* The base type is of incomplete type. It is - probably best to pretend that it does not - exist. */ - if (i == n_baseclasses) - CLASSTYPE_BASECLASS (t, i) = NULL_TREE; - CLASSTYPE_N_BASECLASSES (t) -= 1; - n_baseclasses -= 1; - for (j = i; j < n_baseclasses; j++) - { - CLASSTYPE_BASECLASS (t, j) = CLASSTYPE_BASECLASS (t, j+1); - SET_CLASSTYPE_VIAS (t, j, - CLASSTYPE_VIA_PUBLIC (t, j+1), - CLASSTYPE_VIA_VIRTUAL (t, j+1)); - } - } - - if (TYPE_WRAP_TYPE (t) == NULL_TREE) - TYPE_WRAP_TYPE (t) = TYPE_WRAP_TYPE (basetype); - else if (TYPE_WRAP_TYPE (basetype) - && TYPE_WRAP_TYPE (t) != TYPE_WRAP_TYPE (basetype)) - /* Must have its own. */ - TYPE_WRAP_TYPE (t) = error_mark_node; - - if (TYPE_HAS_DEFAULT_CONSTRUCTOR (basetype)) - b->needs_default_ctor = 1; - else if (TYPE_HAS_CONSTRUCTOR (basetype)) - b->cant_have_default_ctor = 1; - if (TYPE_GETS_CONST_INIT_REF (basetype)) - b->needs_const_ctor = 1; - else if (TYPE_GETS_INIT_REF (basetype)) - b->cant_have_const_ctor = 1; - - CLASSTYPE_ALTERS_VISIBILITIES_P (t) - |= CLASSTYPE_ALTERS_VISIBILITIES_P (basetype); - - b->n_ancestors += CLASSTYPE_N_SUPERCLASSES (basetype); - TYPE_NEEDS_CONSTRUCTING (t) |= TYPE_NEEDS_CONSTRUCTING (basetype); - TYPE_NEEDS_CONSTRUCTOR (t) |= TYPE_NEEDS_CONSTRUCTOR (basetype); - TYPE_NEEDS_DESTRUCTOR (t) |= TYPE_NEEDS_DESTRUCTOR (basetype); - TYPE_ANY_ASSIGNS_THIS (t) |= TYPE_ANY_ASSIGNS_THIS (basetype); - TYPE_GETS_ASSIGNMENT (t) |= TYPE_GETS_ASSIGNMENT (basetype); - TYPE_GETS_INIT_REF (t) |= TYPE_GETS_INIT_REF (basetype); - - TYPE_OVERLOADS_CALL_EXPR (t) |= TYPE_OVERLOADS_CALL_EXPR (basetype); - TYPE_OVERLOADS_ARRAY_REF (t) |= TYPE_OVERLOADS_ARRAY_REF (basetype); - - if (CLASSTYPE_OFFSET (basetype) != integer_zero_node) - { - /* Completely unshare potentially shared data, and - update what is ours. */ - tree assoc = assoc_value (TYPE_MAIN_VARIANT (basetype), t); - basetype = copy_node (basetype); - copy_type_lang_specific (basetype); - CLASSTYPE_BASECLASS (t, i) = basetype; - ASSOC_TYPE (assoc) = basetype; - - /* Propagate this offset through all the children. Do this - before uniquizing baseclasses for virtual functions. */ - CLASSTYPE_ASSOC (basetype) = copy_assoc (CLASSTYPE_ASSOC (TYPE_MAIN_VARIANT (basetype))); - - propagate_basetype_offsets (basetype, basetype, CLASSTYPE_OFFSET (basetype)); - } - - if (! CLASSTYPE_VIA_VIRTUAL (t, i)) - CLASSTYPE_N_SUPERCLASSES (t) += 1; - - if (TYPE_VIRTUAL_P (basetype)) - { - if (CLASSTYPE_VSIZE (basetype) > b->max_has_virtual) - b->max_has_virtual = CLASSTYPE_VSIZE (basetype); - - /* Don't borrow virtuals from virtual baseclasses. */ - if (TREE_VIA_VIRTUAL (basetype)) - continue; - - if (first_vfn_base_index == 0) - { - first_vfn_base_index = i; - - b->has_virtual = CLASSTYPE_VSIZE (basetype); - b->vfield = CLASSTYPE_VFIELD (basetype); - b->vfields = CLASSTYPE_VFIELDS (basetype); - CLASSTYPE_VFIELD (t) = b->vfield; - } - else - { - /* Only add unique vfields, and flatten them out as we go. */ - tree vfields = CLASSTYPE_VFIELDS (basetype); - while (vfields) - { - if (TREE_PURPOSE (vfields) == NULL_TREE - || ! TREE_VIA_VIRTUAL (TREE_PURPOSE (vfields))) - { - tree value = TREE_VALUE (vfields); - if (TYPE_MAIN_VARIANT (basetype) == value) - b->vfields = tree_cons (basetype, value, b->vfields); - else - b->vfields = tree_cons (get_base_type (value, basetype, 0), - value, b->vfields); - TREE_TYPE (b->vfields) = basetype; - } - vfields = TREE_CHAIN (vfields); - } - - if (b->has_virtual == 0) - { - first_vfn_base_index = i; - b->has_virtual = CLASSTYPE_VSIZE (basetype); - b->vfield = CLASSTYPE_VFIELD (basetype); - CLASSTYPE_VFIELD (t) = b->vfield; - } - } - } - } - if (b->vfield == 0) - /* If all virtual functions come only from virtual baseclasses. */ - return 0; - return first_vfn_base_index; -} - -static int -typecode_p (type, code) - tree type; - enum tree_code code; -{ - return (TREE_CODE (type) == code - || (TREE_CODE (type) == REFERENCE_TYPE - && TREE_CODE (TREE_TYPE (type)) == code)); -} - -/* Set memoizing fields and bits of T (and its variants) for later use. - FIRST_VFN_BASE_INDEX is the first baseclass of T with virtual functions. - MAX_HAS_VIRTUAL is the largest size of any T's virtual function tables. */ -static void -finish_struct_bits (t, first_vfn_base_index, max_has_virtual) - tree t; - int first_vfn_base_index, max_has_virtual; -{ - int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (t); - tree method_vec = CLASSTYPE_METHOD_VEC (t); - - /* Fix up variants (if any). */ - tree variants = TYPE_NEXT_VARIANT (t); - while (variants) - { - TYPE_NEEDS_CONSTRUCTOR (variants) = TYPE_NEEDS_CONSTRUCTOR (t); - TYPE_NEEDS_CONSTRUCTING (variants) = TYPE_NEEDS_CONSTRUCTING (t); - TYPE_NEEDS_DESTRUCTOR (variants) = TYPE_NEEDS_DESTRUCTOR (t); - variants = TYPE_NEXT_VARIANT (variants); - } - - if (n_baseclasses && max_has_virtual) - { - /* Done by `finish_struct' for classes without baseclasses. */ - int has_abstract_virtuals = CLASSTYPE_ABSTRACT_VIRTUALS (t) != 0; - if (has_abstract_virtuals == 0) - for (i = CLASSTYPE_N_BASECLASSES (t); i >= 1; i--) - has_abstract_virtuals - |= (CLASSTYPE_ABSTRACT_VIRTUALS (CLASSTYPE_BASECLASS (t, i)) != 0); - if (has_abstract_virtuals) - CLASSTYPE_ABSTRACT_VIRTUALS (t) = get_abstract_virtuals (t); - } - - if (n_baseclasses) - { - /* Notice whether this class has type conversion functions defined. - Also report whether joining two types yields an ambiguity in the - virtual function table, e.g., - - struct A { virtual int f (); }; - struct B { virtual int f (); }; - struct C : A, B { / * no f (); * / }; / / error, ambiguous - */ - tree basetypes = CLASSTYPE_VBASECLASSES (t), basetype; - int n_vbases = list_length (basetypes), j; - - build_mi_virtuals (n_baseclasses + (n_vbases*n_baseclasses), max_has_virtual); - /* Fill in virutal function table with values which do not come - "normal"ly, i.e., those which come from virtual and/or - non-leftmost base classes. */ - for (i = n_baseclasses; basetypes; basetypes = TREE_CHAIN (basetypes)) - { - basetype = TREE_VALUE (basetypes); - if (CLASSTYPE_VSIZE (basetype)) - for (j = n_baseclasses; j > 0; j--) - { - tree this_base = CLASSTYPE_BASECLASS (t, j); - if (get_base_distance (basetype, TYPE_MAIN_VARIANT (this_base), 0, 0) != -1) - add_mi_virtuals (++i, TREE_CHAIN (ASSOC_VIRTUALS (basetypes))); - } - } - for (i = n_baseclasses; i > 0; i--) - { - basetype = CLASSTYPE_BASECLASS (t, i); - - if (TYPE_HAS_CONVERSION (basetype)) - { - TYPE_HAS_CONVERSION (t) = 1; - TYPE_HAS_INT_CONVERSION (t) |= TYPE_HAS_INT_CONVERSION (basetype); - TYPE_HAS_REAL_CONVERSION (t) |= TYPE_HAS_REAL_CONVERSION (basetype); - } - if (TREE_VIA_VIRTUAL (basetype)) - /* Virtual functions from virtual baseclasses are done above. */; - else if (i == first_vfn_base_index) - add_mi_virtuals (i, TREE_CHAIN (CLASS_ASSOC_VIRTUALS (t))); - else if (CLASSTYPE_VSIZE (basetype) != 0) - add_mi_virtuals (i, TREE_CHAIN (CLASS_ASSOC_VIRTUALS (basetype))); - } - report_ambiguous_mi_virtuals (n_baseclasses + (n_vbases*n_baseclasses), t); -#if 0 - /* Now that we know what the virtual functiond table looks like, - fix up offsets in the presence of virtual base classes. */ - if (n_vbases) - fixup_vbase_offsets (t); -#endif - } - - /* Need to test METHOD_VEC here in case all methods - (conversions and otherwise) are inherited. */ - if (TYPE_HAS_CONVERSION (t) && method_vec != NULL_TREE) - { - tree first_conversions[last_conversion_type]; - tree last_conversions[last_conversion_type]; - enum conversion_type conv_index; - tree *tmp; - int i; - - bzero (first_conversions, sizeof (first_conversions)); - for (tmp = &TREE_VEC_ELT (method_vec, 1); - tmp != TREE_VEC_END (method_vec); tmp += 1) - { - if (OPERATOR_TYPENAME_P (DECL_ORIGINAL_NAME (*tmp))) - { - tree fntype = TREE_TYPE (*tmp); - tree return_type = TREE_TYPE (fntype); - assert (TREE_CODE (fntype) == METHOD_TYPE); - - if (typecode_p (return_type, POINTER_TYPE)) - { - if (TREE_READONLY (TREE_TYPE (return_type))) - conv_index = constptr_conv; - else - conv_index = ptr_conv; - } - else if (typecode_p (return_type, INTEGER_TYPE)) - { - TYPE_HAS_INT_CONVERSION (t) = 1; - conv_index = int_conv; - } - else if (typecode_p (return_type, REAL_TYPE)) - { - TYPE_HAS_REAL_CONVERSION (t) = 1; - conv_index = real_conv; - } - else - continue; - - if (first_conversions[(int) conv_index] == NULL_TREE) - first_conversions[(int) conv_index] = *tmp; - last_conversions[(int) conv_index] = *tmp; - } - } - - for (i = 0; i < (int) last_conversion_type; i++) - if (first_conversions[i] != last_conversions[i]) - CLASSTYPE_CONVERSION (t, i) = error_mark_node; - else - CLASSTYPE_CONVERSION (t, i) = first_conversions[i]; - } - - /* If this type has constructors, force its mode to be BLKmode, - and force its TREE_ADDRESSABLE bit to be nonzero. */ - if (TYPE_NEEDS_CONSTRUCTING (t) || TYPE_NEEDS_DESTRUCTOR (t)) - { - tree variants = t; - - if (TREE_CODE (TYPE_NAME (t)) == TYPE_DECL) - DECL_MODE (TYPE_NAME (t)) = BLKmode; - while (variants) - { - TYPE_MODE (variants) = BLKmode; - TREE_ADDRESSABLE (variants) = 1; - variants = TYPE_NEXT_VARIANT (variants); - } - } -} - -/* Create a RECORD_TYPE or UNION_TYPE node for a C struct or union declaration - (or C++ class declaration). - - For C++, we must handle the building of derived classes. - Also, C++ allows static class members. The way that this is - handled is to keep the field name where it is (as the DECL_NAME - of the field), and place the overloaded decl in the DECL_OFFSET - of the field. layout_record and layout_union will know about this. - - More C++ hair: inline functions have text in their - DECL_PENDING_INLINE_INFO nodes which must somehow be parsed into - meaningful tree structure. After the struct has been laid out, set - things up so that this can happen. - - And still more: virtual functions. In the case of single inheritance, - when a new virtual function is seen which redefines a virtual function - from the base class, the new virtual function is placed into - the virtual function table at exactly the same address that - it had in the base class. When this is extended to multiple - inheritance, the same thing happens, except that multiple virtual - function tables must be maintained. The first virtual function - table is treated in exactly the same way as in the case of single - inheritance. Additional virtual function tables have different - DELTAs, which tell how to adjust `this' to point to the right thing. - - LIST_OF_FIELDLISTS is just that. The elements of the list are - TREE_LIST elements, whose TREE_PURPOSE field tells what visibility - the list has, and the TREE_VALUE slot gives the actual fields. - - EMPTY is non-zero if this structure has no declarations following it. - - If flag_all_virtual == 1, then we lay all functions into - the virtual function table, as though they were declared - virtual. Constructors do not lay down in the virtual function table. - - If flag_all_virtual == 2, then we lay all functions into - the virtual function table, such that virtual functions - occupy a space by themselves, and then all functions - of the class occupy a space by themselves. This is illustrated - in the following diagram: - - class A; class B : A; - - Class A's vtbl: Class B's vtbl: - -------------------------------------------------------------------- - | A's virtual functions| | B's virtual funcitions | - | | | (may inherit some from A). | - -------------------------------------------------------------------- - | All of A's functions | | All of A's functions | - | (such as a->A::f). | | (such as b->A::f) | - -------------------------------------------------------------------- - | B's new virtual functions | - | (not defined in A.) | - ------------------------------- - | All of B's functions | - | (such as b->B::f) | - ------------------------------- - - this allows the program to make references to any function, virtual - or otherwise in a type-consistant manner. */ - -tree -finish_struct (t, list_of_fieldlists, empty, warn_anon) - tree t; - tree list_of_fieldlists; - int empty; - int warn_anon; -{ - extern int interface_only, interface_unknown; - int old; - int round_up_size = 1; - /* Set non-zero to debug using default functions. - Not set by program. */ - static int debug_default_functions = 0; - - enum tree_code code = TREE_CODE (t); - register tree x, y, method_vec; - int needs_ctor = 0, needs_dtor = 0; - int members_need_dtors = 0; - tree name = TYPE_NAME (t), fields, fn_fields, tail; - enum visibility_type visibility; - int all_virtual; - int has_virtual; - int max_has_virtual; - tree pending_virtuals = NULL_TREE; - tree abstract_virtuals = NULL_TREE; - tree vfield; - tree vfields; - int needs_default_ctor; - int cant_have_default_ctor; - int needs_const_ctor; - int cant_have_const_ctor; - - /* The index of the first base class which has virtual - functions. Only applied to non-virtual baseclasses. */ - int first_vfn_base_index; - - int i, n_baseclasses; - int any_default_members = 0; - char *err_name; - int const_sans_init = 0; - int ref_sans_init = 0; - int nonprivate_method = 0; - - if (TREE_CODE (name) == TYPE_DECL) - { - extern int lineno; - - DECL_SOURCE_FILE (name) = input_filename; - DECL_SOURCE_LINE (name) = lineno; - name = DECL_NAME (name); - } - err_name = IDENTIFIER_POINTER (name); - - if (warn_anon && code != UNION_TYPE && ANON_AGGRNAME_P (name)) - { - warning ("un-usable class ignored (anonymous classes and unions are useless)"); - err_name = "(anon)"; - } - - leftmost_baseclasses = NULL_TREE; - if (TYPE_SIZE (t)) - { - if (TREE_CODE (t) == UNION_TYPE) - error ("redefinition of `union %s'", err_name); - else if (TREE_CODE (t) == RECORD_TYPE) - error ("redefinition of `struct %s'", err_name); - else - assert (0); - popclass (0); - return t; - } - -#ifdef FIELD_XREF - FIELD_xref_decl(current_function_decl,t); -#endif - - /* If this type was previously laid out as a forward reference, - make sure we lay it out again. */ - - TYPE_SIZE (t) = 0; - CLASSTYPE_GOT_SEMICOLON (t) = 0; - CLASSTYPE_INTERFACE_ONLY (t) = interface_only; - CLASSTYPE_INTERFACE_UNKNOWN (t) = interface_unknown; - - old = suspend_momentary (); - - /* Install struct as DECL_FIELD_CONTEXT of each field decl. - Also process specified field sizes. - Set DECL_SIZE_UNIT to the specified size, or 0 if none specified. - The specified size is found in the DECL_INITIAL. - Store 0 there, except for ": 0" fields (so we can find them - and delete them, below). */ - - n_baseclasses = CLASSTYPE_N_BASECLASSES (t); - if (n_baseclasses >= 1) - { - struct base_info base_info; - - /* If using multiple inheritance, this may cause variants of our - basetypes to be used (instead of their canonical forms). */ - fields = layout_basetypes (t); - y = tree_last (fields); - - first_vfn_base_index = finish_base_struct (t, &base_info); - has_virtual = base_info.has_virtual; - max_has_virtual = base_info.max_has_virtual; - CLASSTYPE_N_SUPERCLASSES (t) += base_info.n_ancestors; - vfield = base_info.vfield; - vfields = base_info.vfields; - needs_default_ctor = base_info.needs_default_ctor; - cant_have_default_ctor = base_info.cant_have_default_ctor; - needs_const_ctor = base_info.needs_const_ctor; - cant_have_const_ctor = base_info.cant_have_const_ctor; - n_baseclasses = CLASSTYPE_N_BASECLASSES (t); - } - else - { - first_vfn_base_index = 0; - has_virtual = 0; - max_has_virtual = 0; - vfield = NULL_TREE; - vfields = NULL_TREE; - fields = NULL_TREE; - y = NULL_TREE; - needs_default_ctor = 0; - cant_have_default_ctor = 0; - needs_const_ctor = 0; - cant_have_const_ctor = 0; - } - - if (write_virtuals == 3 && ! CLASSTYPE_INTERFACE_UNKNOWN (t)) - { - CLASSTYPE_INTERFACE_ONLY (t) = interface_only; - CLASSTYPE_VTABLE_NEEDS_WRITING (t) = ! interface_only; - } - - /* The three of these are approximations which may later be - modified. Needed at this point to make add_virtual_function - and modify_vtable_entries work. */ - CLASSTYPE_ASSOC (t) = make_assoc (integer_zero_node, t, - 0, 0, CLASSTYPE_ASSOC (t)); - CLASSTYPE_VFIELDS (t) = vfields; - CLASSTYPE_VFIELD (t) = vfield; - - fn_fields = NULL_TREE; - tail = NULL_TREE; - if (y && list_of_fieldlists) - TREE_CHAIN (y) = TREE_VALUE (list_of_fieldlists); - -#ifdef SOS - if (flag_all_virtual == 2) - all_virtual = 2; - else -#endif - { - if (flag_all_virtual == 1 && TYPE_OVERLOADS_METHOD_CALL_EXPR (t)) - all_virtual = 1; - else - all_virtual = 0; - } - - if (CLASSTYPE_DECLARED_CLASS (t) == 0) - { - nonprivate_method = 1; - if (list_of_fieldlists - && TREE_PURPOSE (list_of_fieldlists) == (tree)visibility_default) - TREE_PURPOSE (list_of_fieldlists) = (tree)visibility_public; - } - else if (list_of_fieldlists - && TREE_PURPOSE (list_of_fieldlists) == (tree)visibility_default) - TREE_PURPOSE (list_of_fieldlists) = (tree)visibility_private; - - while (list_of_fieldlists) - { - visibility = (enum visibility_type)TREE_PURPOSE (list_of_fieldlists); - - for (x = TREE_VALUE (list_of_fieldlists); x; x = TREE_CHAIN (x)) - { - TREE_PRIVATE (x) = visibility == visibility_private; - TREE_PROTECTED (x) = visibility == visibility_protected; -#ifdef FIELD_XREF - FIELD_xref_member(current_class_name,x); -#endif - - if (TREE_CODE (x) == FUNCTION_DECL) - { - /* Clear out this flag. - - @@ Doug may figure out how to break - @@ this with nested classes and friends. */ - DECL_IN_AGGR_P (x) = 0; - - nonprivate_method |= ! TREE_PRIVATE (x); - - /* If this was an evil function, don't keep it in class. */ - if (IDENTIFIER_ERROR_LOCUS (DECL_NAME (x))) - continue; - - if (y) TREE_CHAIN (y) = TREE_CHAIN (x); - if (! fn_fields) fn_fields = x; - else TREE_CHAIN (tail) = x; - tail = x; - if (DECL_CONTEXT (x)) - continue; - - DECL_CONTEXT (x) = t; - DECL_VCONTEXT (x) = t; - - DECL_SIZE_UNIT (x) = 0; - - /* The name of the field is the original field name - Save this in auxiliary field for later overloading. */ - if (DECL_VIRTUAL_P (x) - || (all_virtual == 1 && ! DECL_CONSTRUCTOR_P (x))) - { - pending_virtuals = add_virtual_function (pending_virtuals, - &has_virtual, x, - first_vfn_base_index); - if (DECL_ABSTRACT_VIRTUAL_P (x)) - abstract_virtuals = tree_cons (NULL_TREE, x, abstract_virtuals); - } - continue; - } - - /* Handle visibility declarations. */ - if (DECL_NAME (x) && TREE_CODE (DECL_NAME (x)) == SCOPE_REF) - { - tree fdecl = TREE_OPERAND (DECL_NAME (x), 1); - - if (y) TREE_CHAIN (y) = TREE_CHAIN (x); - /* Make type T see field decl FDECL with - the visibility VISIBILITY. */ - if (TREE_CODE (fdecl) == TREE_LIST) - { - fdecl = TREE_VALUE (fdecl); - while (fdecl) - { - if (alter_visibility (t, fdecl, visibility) == 0) - break; - fdecl = TREE_CHAIN (fdecl); - } - } - else alter_visibility (t, fdecl, visibility); - CLASSTYPE_ALTERS_VISIBILITIES_P (t) = 1; - continue; - } - - /* Perform error checking that did not get done in grokdeclarator. */ - if (TREE_CODE (TREE_TYPE (x)) == FUNCTION_TYPE) - { - error_with_decl (x, "field `%s' invalidly declared function type"); - TREE_TYPE (x) = build_pointer_type (TREE_TYPE (x)); - } - else if (TREE_CODE (TREE_TYPE (x)) == METHOD_TYPE) - { - error_with_decl (x, "field `%s' invalidly declared method type"); - TREE_TYPE (x) = build_pointer_type (TREE_TYPE (x)); - } - else if (TREE_CODE (TREE_TYPE (x)) == OFFSET_TYPE) - { - error_with_decl (x, "field `%s' invalidly declared offset type"); - TREE_TYPE (x) = build_pointer_type (TREE_TYPE (x)); - } - /* If this is of reference type, check if it needs an init. */ - if (TREE_CODE (TREE_TYPE (x)) == REFERENCE_TYPE - && DECL_INITIAL (x) == 0) - ref_sans_init = 1; - - /* When this goes into scope, it will be a non-local reference. */ - TREE_NONLOCAL (x) = 1; - - if (TREE_CODE (x) == FIELD_DECL) - { - /* Never let anything with uninheritable virutals - make it through without complaint. */ - if (TYPE_LANG_SPECIFIC (TREE_TYPE (x)) - && CLASSTYPE_ABSTRACT_VIRTUALS (TREE_TYPE (x))) - abstract_virtuals_error (x, TREE_TYPE (x)); - - if (TYPE_LANG_SPECIFIC (TREE_TYPE (x))) - { - if (TYPE_HAS_DEFAULT_CONSTRUCTOR (TREE_TYPE (x))) - needs_default_ctor = 1; - if (TYPE_GETS_CONST_INIT_REF (TREE_TYPE (x))) - needs_const_ctor = 1; - else if (TYPE_GETS_INIT_REF (TREE_TYPE (x))) - cant_have_const_ctor = 1; - } - else if (DECL_INITIAL (x) == NULL_TREE - && (TYPE_HAS_CONSTRUCTOR (TREE_TYPE (x)) - || TREE_CODE (TREE_TYPE (x)) == REFERENCE_TYPE)) - cant_have_default_ctor = 1; - - /* If any field is const, the structure type is pseudo-const. */ - if (TREE_READONLY (x)) - { - C_TYPE_FIELDS_READONLY (t) = 1; - if (DECL_INITIAL (x) == 0) - const_sans_init = 1; - } - else - { - /* A field that is pseudo-const makes the structure likewise. */ - tree t1 = TREE_TYPE (x); - while (TREE_CODE (t1) == ARRAY_TYPE) - t1 = TREE_TYPE (t1); - if (IS_AGGR_TYPE (t1)) - { - if (C_TYPE_FIELDS_READONLY (t1)) - C_TYPE_FIELDS_READONLY (t) = 1; - if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (t1)) - const_sans_init = 1; - } - } - } - else if (TREE_STATIC (x) && TREE_CODE (t) == UNION_TYPE) - /* Unions cannot have static members. */ - error_with_decl (x, "field `%s' declared static in union"); - - if (! fields) fields = x; - DECL_FIELD_CONTEXT (x) = t; - DECL_SIZE_UNIT (x) = 0; - - if (TREE_PACKED (x)) - { - /* Invalid bit-field size done by grokfield. */ - /* Detect invalid bit-field type. */ - if (DECL_INITIAL (x) - && TREE_CODE (TREE_TYPE (x)) != INTEGER_TYPE - && TREE_CODE (TREE_TYPE (x)) != ENUMERAL_TYPE) - { - error_with_decl (x, "bit-field `%s' has invalid type"); - DECL_INITIAL (x) = NULL; - } - if (DECL_INITIAL (x) && pedantic - && TREE_TYPE (x) != integer_type_node - && TREE_TYPE (x) != unsigned_type_node) - warning_with_decl (x, "bit-field `%s' type invalid in ANSI C"); - - /* Detect and ignore out of range field width. */ - if (DECL_INITIAL (x)) - { - register int width = TREE_INT_CST_LOW (DECL_INITIAL (x)); - - if (width < 0) - { - DECL_INITIAL (x) = NULL; - warning_with_decl (x, "negative width in bit-field `%s'"); - } - else if (width == 0 && DECL_NAME (x) != 0) - { - error_with_decl (x, "zero width for bit-field `%s'"); - DECL_INITIAL (x) = NULL; - } - else if (width > TYPE_PRECISION (TREE_TYPE (x))) - { - DECL_INITIAL (x) = NULL; - warning_with_decl (x, "width of `%s' exceeds its type"); - } - } - - /* Process valid field width. */ - if (DECL_INITIAL (x)) - { - register int width = TREE_INT_CST_LOW (DECL_INITIAL (x)); - - if (width == 0) - { - /* field size 0 => mark following field as "aligned" */ - if (TREE_CHAIN (x)) - DECL_ALIGN (TREE_CHAIN (x)) - = MAX (DECL_ALIGN (TREE_CHAIN (x)), EMPTY_FIELD_BOUNDARY); - /* field of size 0 at the end => round up the size. */ - else - round_up_size = EMPTY_FIELD_BOUNDARY; - } - else - { - DECL_INITIAL (x) = NULL_TREE; - DECL_SIZE_UNIT (x) = width; - TREE_PACKED (x) = 1; - /* Traditionally a bit field is unsigned - even if declared signed. */ - if (flag_traditional - && TREE_CODE (TREE_TYPE (x)) == INTEGER_TYPE) - TREE_TYPE (x) = unsigned_type_node; - } - } - else - /* Non-bit-fields are aligned for their type. */ - DECL_ALIGN (x) = MAX (DECL_ALIGN (x), TYPE_ALIGN (TREE_TYPE (x))); - } - else if (TREE_CODE (x) == FIELD_DECL) - { - tree type = TREE_TYPE (x); - if (TREE_CODE (type) == ARRAY_TYPE) - type = TREE_TYPE (type); - if (code == UNION_TYPE) - { - if (TYPE_NEEDS_CONSTRUCTING (type)) - error ("member %s::%s with constructor not allowed in union", - IDENTIFIER_POINTER (name), IDENTIFIER_POINTER (DECL_NAME (x))); - if (TYPE_NEEDS_DESTRUCTOR (type)) - error ("member %s::%s with destructor (also) not allowed in union", - IDENTIFIER_POINTER (name), IDENTIFIER_POINTER (DECL_NAME (x))); - } - else if (code == RECORD_TYPE) - { - /* Array of record type doesn't matter for this bit. */ - TYPE_NEEDS_CONSTRUCTING (t) |= TYPE_NEEDS_CONSTRUCTING (type); - if (IS_AGGR_TYPE (type)) - { - needs_ctor |= TYPE_NEEDS_CONSTRUCTOR (type); - needs_dtor |= TYPE_NEEDS_DESTRUCTOR (type); - members_need_dtors |= TYPE_NEEDS_DESTRUCTOR (type); - TYPE_GETS_ASSIGNMENT (t) |= TYPE_GETS_ASSIGNMENT (type); - TYPE_GETS_INIT_REF (t) |= TYPE_GETS_INIT_REF (type); - TYPE_GETS_CONST_INIT_REF (t) |= TYPE_GETS_CONST_INIT_REF (type); - } - } - if (DECL_INITIAL (x) != NULL_TREE) - { - /* `build_class_init_list' does not recognize non-FIELD_DECLs. */ - if (code == UNION_TYPE && any_default_members != 0) - error ("multiple fields in union initialized"); - any_default_members = 1; - } - } - y = x; - } - list_of_fieldlists = TREE_CHAIN (list_of_fieldlists); - /* link the tail while we have it! */ - if (y) - { - TREE_CHAIN (y) = NULL_TREE; - - if (list_of_fieldlists - && TREE_VALUE (list_of_fieldlists) - && TREE_CODE (TREE_VALUE (list_of_fieldlists)) != FUNCTION_DECL) - TREE_CHAIN (y) = TREE_VALUE (list_of_fieldlists); - } - } - - if (tail) TREE_CHAIN (tail) = NULL_TREE; - - /* If this type has any constant members which did not come - with their own initialization, mark that fact here. It is - not an error here, since such types can be saved either by their - constructors, or by fortuitous initialization. */ - CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) = const_sans_init; - CLASSTYPE_REF_FIELDS_NEED_INIT (t) = ref_sans_init; - CLASSTYPE_ABSTRACT_VIRTUALS (t) = abstract_virtuals; - - if (vfield == 0 - && (has_virtual -#ifdef SOS - || TYPE_DYNAMIC (t) -#endif - )) - { - /* We build this decl with ptr_type_node, and - change the type when we know what it should be. */ - vfield = build_decl (FIELD_DECL, get_vfield_name (t), ptr_type_node); - CLASSTYPE_VFIELD (t) = vfield; - DECL_VIRTUAL_P (vfield) = 1; - DECL_FIELD_CONTEXT (vfield) = t; - SET_DECL_FCONTEXT (vfield, t); - DECL_SIZE_UNIT (vfield) = 0; - if (y) - { - assert (TREE_CHAIN (y) == 0); - TREE_CHAIN (y) = vfield; - y = vfield; - } - else fields = vfield; - vfields = chainon (vfields, CLASSTYPE_AS_LIST (t)); - } - - /* Now DECL_INITIAL is null on all members except for zero-width bit-fields. - And they have already done their work. - - C++: maybe we will support default field initialization some day... */ - - /* Delete all zero-width bit-fields from the front of the fieldlist */ - while (fields && TREE_PACKED (fields) - && DECL_INITIAL (fields)) - fields = TREE_CHAIN (fields); - /* Delete all such fields from the rest of the fields. */ - for (x = fields; x;) - { - if (TREE_CHAIN (x) && TREE_PACKED (TREE_CHAIN (x)) - && DECL_INITIAL (TREE_CHAIN (x))) - TREE_CHAIN (x) = TREE_CHAIN (TREE_CHAIN (x)); - else x = TREE_CHAIN (x); - } - /* Delete all duplicate fields from the fields */ - delete_duplicate_fields (fields); - - /* Now we have the final fieldlist for the data fields. Record it, - then lay out the structure or union (including the fields). */ - - TYPE_FIELDS (t) = fields; - - /* If there's a :0 field at the end, round the size to the - EMPTY_FIELD_BOUNDARY. */ - TYPE_ALIGN (t) = round_up_size; - - if (debug_default_functions) - { - if ((TYPE_NEEDS_CONSTRUCTOR (t) || TYPE_HAS_CONSTRUCTOR (t) || needs_ctor) - && ! TYPE_HAS_INIT_REF (t)) - { - tree default_fn = cons_up_default_function (t, name, 1); - TREE_CHAIN (default_fn) = fn_fields; - DECL_CONTEXT (default_fn) = t; - DECL_VCONTEXT (default_fn) = t; - fn_fields = default_fn; - TYPE_HAS_INIT_REF (t) = 1; - default_fn = cons_up_default_function (t, name, 3); - TREE_CHAIN (default_fn) = fn_fields; - DECL_CONTEXT (default_fn) = t; - DECL_VCONTEXT (default_fn) = t; - fn_fields = default_fn; - nonprivate_method = 1; - } - - if (! TYPE_HAS_DEFAULT_CONSTRUCTOR (t) - && needs_default_ctor && ! cant_have_default_ctor) - { - tree default_fn = cons_up_default_function (t, name, 2); - TREE_CHAIN (default_fn) = fn_fields; - DECL_CONTEXT (default_fn) = t; - DECL_VCONTEXT (default_fn) = t; - fn_fields = default_fn; - TYPE_HAS_DEFAULT_CONSTRUCTOR (t) = 1; - nonprivate_method = 1; - } - } - /* Warn about duplicate methods in fn_fields. Also compact - method lists so that lookup can be made faster. - - Algorithm: Outer loop builds lists by method name. - Inner loop checks for redundant method names within a list. - - Data Structure: List of method lists. The outer list - is a TREE_LIST, whose TREE_PURPOSE field is the field name - and the TREE_VALUE is the TREE_CHAIN of the FUNCTION_DECLs. - Friends are chained in the same way as member functions, but - they live in the TREE_TYPE field of the outer list. - That allows them to be quicky deleted, and requires - no extra storage. - - If there are any constructors/destructors, they are moved to - the front of the list. This makes pushclass more efficient. - - We also link each field which has shares a name with its - baseclass to the head of the list of fields for that base class. - This allows us to reduce search time in places like `build_method_call' - to consider only reasonably likely functions. */ - - if (fn_fields) - { - /* Now prepare to gather fn_fields into vector. */ - struct obstack *ambient_obstack = current_obstack; - current_obstack = &class_obstack; - method_vec = make_node (TREE_VEC); - /* Room has been saved for constructors and destructors. */ - current_obstack = ambient_obstack; - /* Now make this a live vector. */ - obstack_free (&class_obstack, method_vec); - obstack_blank (&class_obstack, sizeof (struct tree_vec)); - - while (fn_fields) - { - /* NEXT Pointer, TEST Pointer, and BASE Pointer. */ - tree nextp, *testp; - - nextp = TREE_CHAIN (fn_fields); - TREE_CHAIN (fn_fields) = NULL_TREE; - /* Constrcutors are handled easily in search routines. - Besides, we know we wont find any, so do not bother looking. */ - if (DECL_ORIGINAL_NAME (fn_fields) == name - && TREE_VEC_ELT (method_vec, 0) == 0) - TREE_VEC_ELT (method_vec, 0) = fn_fields; - else - { - testp = &TREE_VEC_ELT (method_vec, 0); - if (*testp == NULL_TREE) - testp++; - while ((int)testp < (int)obstack_next_free (&class_obstack) - && DECL_ORIGINAL_NAME (*testp) != DECL_ORIGINAL_NAME (fn_fields)) - testp++; - if ((int)testp < (int)obstack_next_free (&class_obstack)) - { - for (x = *testp; x; x = TREE_CHAIN (x)) - { - if (DECL_NAME (fn_fields) == DECL_NAME (x)) - { - /* We complain about multiple destructors on sight, - so we do not repeat the warning here. Friend-friend - ambiguities are warned about outside this loop. */ - if (! DESTRUCTOR_NAME_P (DECL_NAME (fn_fields))) - error_with_file_and_line (DECL_SOURCE_FILE (fn_fields), - DECL_SOURCE_LINE (fn_fields), - "ambiguous method `%s' in structure", - lang_printable_name (fn_fields)); - break; - } - y = x; - } - if (x == 0) - if (*testp) - TREE_CHAIN (y) = fn_fields; - else - *testp = fn_fields; - } - else - { - obstack_ptr_grow (&class_obstack, fn_fields); - method_vec = (tree)obstack_base (&class_obstack); - } - } - fn_fields = nextp; - } - - TREE_VEC_LENGTH (method_vec) - = (tree *)obstack_next_free (&class_obstack) - (&TREE_VEC_ELT (method_vec, 0)); - obstack_finish (&class_obstack); - CLASSTYPE_METHOD_VEC (t) = method_vec; - - if (nonprivate_method == 0 - && CLASSTYPE_FRIEND_CLASSES (t) == NULL_TREE - && DECL_FRIENDLIST (TYPE_NAME (t)) == NULL_TREE) - { - for (i = 0; i <= n_baseclasses; i++) - if (CLASSTYPE_VIA_PUBLIC (t, i)) - { - nonprivate_method = 1; - break; - } - if (nonprivate_method == 0) - warning ("all class member functions are private"); - } - } - else - { - method_vec = 0; - - /* Just in case these got accidently - filled in by syntax errors. */ - TYPE_HAS_CONSTRUCTOR (t) = 0; - TYPE_HAS_DESTRUCTOR (t) = 0; - } - - /* If there are constructors (and destructors), they are at the - front. Place destructors at very front. Also warn if all - constructors and/or destructors are private (in which case this - class is effectively unusable. */ - if (TYPE_HAS_DESTRUCTOR (t)) - { - tree dtor, prev; - - for (dtor = TREE_VEC_ELT (method_vec, 0); dtor; prev = dtor, dtor = TREE_CHAIN (dtor)) - { - if (DESTRUCTOR_NAME_P (DECL_NAME (dtor))) - { - if (TREE_PRIVATE (dtor) - && CLASSTYPE_FRIEND_CLASSES (t) == NULL_TREE - && DECL_FRIENDLIST (TYPE_NAME (t)) == NULL_TREE) - warning_with_decl (TYPE_NAME (t), "class `%s' only defines a private destructor and has no friends"); - break; - } - } - /* Wild parse errors can cause this to happen. */ - if (dtor == NULL_TREE) - TYPE_HAS_DESTRUCTOR (t) = 0; - else if (dtor != TREE_VEC_ELT (method_vec, 0)) - { - TREE_CHAIN (prev) = TREE_CHAIN (dtor); - TREE_CHAIN (dtor) = TREE_VEC_ELT (method_vec, 0); - TREE_VEC_ELT (method_vec, 0) = dtor; - } - } - else if (members_need_dtors - || TYPE_USES_VIRTUAL_BASECLASSES (t) - || TYPE_USES_MULTIPLE_INHERITANCE (t)) - { - /* Here we must cons up a destructor on the fly. */ - tree dtor = cons_up_default_function (t, name, 0); - - /* If we couldn't make it work, then pretend we didn't need it. */ - if (dtor == void_type_node) - TYPE_NEEDS_DESTRUCTOR (t) = 0; - else - { - DECL_CONTEXT (dtor) = t; - DECL_VCONTEXT (dtor) = t; - if (DECL_VIRTUAL_P (dtor)) - pending_virtuals = add_virtual_function (pending_virtuals, - &has_virtual, dtor); - if (TYPE_HAS_CONSTRUCTOR (t)) - TREE_CHAIN (dtor) = TREE_VEC_ELT (method_vec, 0); - else if (method_vec == 0) - { - /* Now prepare to gather fn_fields into vector. */ - struct obstack *ambient_obstack = current_obstack; - current_obstack = &class_obstack; - method_vec = make_node (TREE_VEC); - /* Room has been saved for constructors and destructors. */ - current_obstack = ambient_obstack; - TREE_VEC_LENGTH (method_vec) = 1; - CLASSTYPE_METHOD_VEC (t) = method_vec; - } - TREE_VEC_ELT (method_vec, 0) = dtor; - TYPE_HAS_DESTRUCTOR (t) = 1; - } - } - if (TYPE_HAS_CONSTRUCTOR (t) - && ! CLASSTYPE_DECLARED_EXCEPTION (t) - && CLASSTYPE_FRIEND_CLASSES (t) == NULL_TREE - && DECL_FRIENDLIST (TYPE_NAME (t)) == NULL_TREE) - { - int nonprivate_ctor = 0; - tree ctor; - - for (ctor = TREE_VEC_ELT (method_vec, 0); ctor; ctor = TREE_CHAIN (ctor)) - if (! TREE_PRIVATE (ctor)) - { - nonprivate_ctor = 1; - break; - } - if (nonprivate_ctor == 0) - warning ("class %s only defines private constructors and has no friends", - TYPE_NAME_STRING (t)); - } - - /* Now for each member function (except for constructors and - destructors), compute where member functions of the same - name reside in base classes. */ - if (n_baseclasses != 0 - && method_vec != NULL_TREE - && TREE_VEC_LENGTH (method_vec) > 1) - { - int len = TREE_VEC_LENGTH (method_vec); - tree baselink_vec = make_tree_vec (len); - int any_links = 0; - - for (i = 1; i < len; i++) - { - TREE_VEC_ELT (baselink_vec, i) - = get_baselinks (t, DECL_ORIGINAL_NAME (TREE_VEC_ELT (method_vec, i))); - if (TREE_VEC_ELT (baselink_vec, i) != 0) - any_links = 1; - } - if (any_links != 0) - CLASSTYPE_BASELINK_VEC (t) = baselink_vec; - else - obstack_free (current_obstack, baselink_vec); - } - - /* We can't know this information until we have seen all of the - constructors. */ - TYPE_NONE_ASSIGN_THIS (t) = 0; - - /* Pass layout information about base classes to layout_type, if any. */ - - if (n_baseclasses) - { - tree pseudo_basetype = TREE_TYPE (base_layout_decl); - - TREE_CHAIN (base_layout_decl) = TYPE_FIELDS (t); - TYPE_FIELDS (t) = base_layout_decl; - - TYPE_SIZE (pseudo_basetype) = CLASSTYPE_SIZE (t); - TYPE_SIZE_UNIT (pseudo_basetype) = TYPE_SIZE_UNIT (t); - TYPE_MODE (pseudo_basetype) = TYPE_MODE (t); - TYPE_ALIGN (pseudo_basetype) = CLASSTYPE_ALIGN (t); - DECL_ALIGN (base_layout_decl) = TYPE_ALIGN (pseudo_basetype); - } - - layout_type (t); - - if (n_baseclasses) - TYPE_FIELDS (t) = TREE_CHAIN (TYPE_FIELDS (t)); - - /* C++: do not let empty structures exist. */ - if (integer_zerop (TYPE_SIZE (t))) - TYPE_SIZE (t) = TYPE_SIZE (char_type_node); - - /* Set the TYPE_DECL for this type to contain the right - value for DECL_OFFSET, so that we can use it as part - of a COMPONENT_REF for multiple inheritance. */ - - if (TREE_CODE (TYPE_NAME (t)) == TYPE_DECL) - layout_decl (TYPE_NAME (t)); - - if (TYPE_USES_VIRTUAL_BASECLASSES (t)) - { - tree vbases; - - max_has_virtual = layout_vbasetypes (t, max_has_virtual); - vbases = CLASSTYPE_VBASECLASSES (t); - CLASSTYPE_N_VBASECLASSES (t) = list_length (vbases); - - /* Now fix up any virtual base class types that we - left lying around. We must get these done - before we try to lay out the virtual function table. */ - pending_hard_virtuals = nreverse (pending_hard_virtuals); -#if 1 - /* This loop makes all the entries in the virtual function tables - of interest contain the "latest" version of the functions - we have defined. */ - - while (vbases) - { - tree virtuals = ASSOC_VIRTUALS (vbases); - - if (virtuals) - virtuals = TREE_CHAIN (virtuals); - - while (virtuals != NULL_TREE) - { - tree pfn = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (virtuals)); - tree base_fndecl = TREE_OPERAND (pfn, 0); - tree decl = get_first_matching_virtual (t, base_fndecl, 0); - tree context = DECL_CONTEXT (decl); - if (decl != base_fndecl && context != t) - { - tree assoc = NULL_TREE, these_virtuals; - int i = TREE_INT_CST_LOW (DECL_VINDEX (base_fndecl)) & ((1<<(BITS_PER_WORD-1))-1); - - if (TYPE_USES_VIRTUAL_BASECLASSES (context)) - assoc = virtual_member (DECL_CONTEXT (base_fndecl), - CLASSTYPE_VBASECLASSES (context)); - if (assoc == NULL_TREE) - assoc = assoc_value (DECL_CONTEXT (base_fndecl), context); - if (assoc != NULL_TREE) - { - these_virtuals = ASSOC_VIRTUALS (assoc); - - while (i-- > 0) - these_virtuals = TREE_CHAIN (these_virtuals); - pfn = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (these_virtuals)); - modify_vtable_entries (t, decl, base_fndecl, pfn); - } - } - virtuals = TREE_CHAIN (virtuals); - } - vbases = TREE_CHAIN (vbases); - } -#endif /* 1 */ - while (pending_hard_virtuals) - { - /* Need an entry in some other virtual function table. */ - tree base_fndecls = DECL_VINDEX (TREE_PURPOSE (pending_hard_virtuals)); - while (base_fndecls) - { - modify_vtable_entries (t, TREE_PURPOSE (pending_hard_virtuals), - TREE_VALUE (base_fndecls), - TREE_VALUE (pending_hard_virtuals)); - base_fndecls = TREE_CHAIN (base_fndecls); - } - pending_hard_virtuals = TREE_CHAIN (pending_hard_virtuals); - } - } - else - CLASSTYPE_VBASE_SIZE (t) = integer_zero_node; - - if (pending_virtuals) - { - pending_virtuals = nreverse (pending_virtuals); - /* We must enter these virtuals into the table. */ - if (first_vfn_base_index == 0) - { - pending_virtuals = tree_cons (NULL_TREE, the_null_vtable_entry, - pending_virtuals); - build_vtable (0, t); - } - else - { - /* Here we know enough to change the type of our virtual - function table, but we will wait until later this function. */ - if (! CLASSTYPE_MARKED4 (t)) - build_vtable (assoc_value (TYPE_MAIN_VARIANT (CLASSTYPE_BASECLASS (t, first_vfn_base_index)), t), t); - } - - /* If this type has basetypes with constructors, then those - constructors might clobber the virtual function table. But - they don't if the derived class shares the exact vtable of the base - class. */ - - CLASSTYPE_NEEDS_VIRTUAL_REINIT (t) = 1; - } - else if (first_vfn_base_index) - { - tree basetype = get_base_type (DECL_FIELD_CONTEXT (vfield), t, 0); - tree assoc; - - if (TREE_VIA_VIRTUAL (basetype)) - assoc = virtual_member (DECL_FIELD_CONTEXT (vfield), CLASSTYPE_VBASECLASSES (t)); - else - assoc = assoc_value (TYPE_MAIN_VARIANT (basetype), t); - - /* This class contributes nothing new to the virtual function - table. However, it may have declared functions which - went into the virtual function table "inherited" from the - base class. If so, we grab a copy of those updated functions, - and pretend they are ours. */ - -#ifdef SOS - /* Don't define this ahead of time if we have more - fields to add later. */ - if (all_virtual == 2 && fn_fields != NULL_TREE) - ; - else -#endif - { - /* See if we should steal the virtual info from base class. */ - if (CLASS_ASSOC_VTABLE (t) == NULL_TREE) - CLASS_ASSOC_VTABLE (t) = ASSOC_VTABLE (assoc); - if (CLASS_ASSOC_VIRTUALS (t) == NULL_TREE) - CLASS_ASSOC_VIRTUALS (t) = ASSOC_VIRTUALS (assoc); - } - if (CLASS_ASSOC_VTABLE (t) != ASSOC_VTABLE (assoc)) - CLASSTYPE_NEEDS_VIRTUAL_REINIT (t) = 1; - } - - if (has_virtual > max_has_virtual) - max_has_virtual = has_virtual; - if (max_has_virtual || first_vfn_base_index) - { -#ifdef VTABLE_USES_MASK - if (max_has_virtual >= VINDEX_MAX) - { - error ("too many virtual functions for class `%s' (VINDEX_MAX < %d)", TYPE_NAME_STRING (t), has_virtual); - } -#endif - TYPE_VIRTUAL_P (t) = 1; - CLASSTYPE_VSIZE (t) = has_virtual; - if (first_vfn_base_index) - { - if (pending_virtuals) - CLASS_ASSOC_VIRTUALS (t) = chainon (CLASS_ASSOC_VIRTUALS (t), - pending_virtuals); - } - else if (has_virtual) - { - CLASS_ASSOC_VIRTUALS (t) = pending_virtuals; - if (write_virtuals >= 0) - DECL_VIRTUAL_P (CLASS_ASSOC_VTABLE (t)) = 1; - } - } - -#ifdef SOS - if (all_virtual == 2 && (max_has_virtual || method_vec)) - { - /* Now that we know the size of the virtual table, lay out - the absolute table following it. */ - int i; - tree tmp; - tree pending_absolutes = NULL_TREE; - int has_absolute = has_virtual; - - /* Local variables for building a table filled with strings - containing the names of interesting things. */ - tree decl, init; - tree start = NULL_TREE, next = NULL_TREE; - tree *outer = &TREE_VEC_ELT (method_vec, 0); - - while (outer != TREE_VEC_END (method_vec)) - { - tree inner; - for (inner = *outer; inner; inner = TREE_CHAIN (inner)) - { - tree entry; - tree fn; - - /* Don't bother with functions which appear - for visibility reasons. */ - if (DECL_FIELD_CONTEXT (inner) != t) - continue; - - /* Must lay this function into its absolute table as well. - This forces an inline function to be written out. */ - fn = build1 (ADDR_EXPR, ptr_type_node, inner); - TREE_LITERAL (fn) = 1; - DECL_DINDEX (inner) = build_int_2 (++has_absolute, 0); - entry = build_vtable_entry (integer_zero_node, fn); - pending_absolutes = tree_cons (DECL_DINDEX (inner), entry, - pending_absolutes); - } - outer++; - } - - CLASS_ASSOC_VIRTUALS (t) = chainon (CLASS_ASSOC_VIRTUALS (t), - nreverse (pending_absolutes)); - if (TYPE_DYNAMIC (t)) - { - for (outer = &TREE_VEC_ELT (method_vec, 0); - outer != TREE_VEC_END (method_vec); - outer++) - { - tree inner; - for (inner = *outer; inner; inner = TREE_CHAIN (inner)) - { - tree str = make_node (STRING_CST); - TREE_STRING_LENGTH (str) = IDENTIFIER_LENGTH (DECL_NAME (inner)); - TREE_STRING_POINTER (str) = IDENTIFIER_POINTER (DECL_NAME (inner)); - TREE_LITERAL (str) = 1; - TREE_STATIC (str) = 1; - TREE_TYPE (str) - = build_cplus_array_type (char_type_node, - build_index_type (build_int_2 (TREE_STRING_LENGTH (str) - 1, 0))); - - if (start) - { - TREE_CHAIN (next) = build_tree_list (NULL_TREE, str); - next = TREE_CHAIN (next); - } - else - { - start = build_tree_list (NULL_TREE, str); - next = start; - } - } - } - - /* Lay out dynamic link table for SOS. */ - - decl = finish_table (get_linktable_name (t), - string_type_node, start, 0); - } - has_virtual = has_absolute; - CLASSTYPE_VSIZE (t) = has_virtual; - if (has_virtual > max_has_virtual) - max_has_virtual = has_virtual; - if (vfield == 0) - { - /* We build this decl with ptr_type_node, and - change the type when we know what it should be. */ - vfield = build_decl (FIELD_DECL, get_vfield_name (t), ptr_type_node); - CLASSTYPE_VFIELD (t) = vfield; - DECL_VIRTUAL_P (vfield) = 1; - DECL_FIELD_CONTEXT (vfield) = t; - SET_DECL_FCONTEXT (vfield, t); - DECL_SIZE_UNIT (vfield) = 0; - y = tree_last (fields); - if (y) - TREE_CHAIN (y) = vfield; - else - fields = vfield; - vfields = chainon (vfields, CLASSTYPE_AS_LIST (t)); - } - } -#endif - - /* Now lay out the virtual function table. */ - if (has_virtual) - { - tree atype, itype; - - if (TREE_TYPE (vfield) == ptr_type_node) - { - /* We must create a pointer to this table because - the one inherited from base class does not exist. - We will fill in the type when we know what it - should really be. */ - itype = build_index_type (build_int_2 (has_virtual, 0)); - atype = build_array_type (vtable_entry_type, itype); - layout_type (atype); - TREE_TYPE (vfield) = build_pointer_type (atype); - } - else - { - atype = TREE_TYPE (TREE_TYPE (vfield)); - - if (has_virtual != TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (atype)))) - { - /* We must extend (or create) the boundaries on this array, - because we picked up virtual functions from multiple - base classes. */ - itype = build_index_type (build_int_2 (has_virtual, 0)); - atype = build_array_type (vtable_entry_type, itype); - layout_type (atype); - vfield = copy_node (vfield); - TREE_TYPE (vfield) = build_pointer_type (atype); -#if 0 - /* In the case of single inheritance, we can - just move up the tree, since we share the - same vptr slot. */ - if (TREE_CHAIN (vfields) == NULL_TREE) - vfields = CLASSTYPE_AS_LIST (t); -#endif - } - } - - CLASSTYPE_VFIELD (t) = vfield; - if (TREE_TYPE (CLASS_ASSOC_VTABLE (t)) != atype) - { - TREE_TYPE (CLASS_ASSOC_VTABLE (t)) = atype; - layout_decl (CLASS_ASSOC_VTABLE (t)); - DECL_ALIGN (CLASS_ASSOC_VTABLE (t)) - = MAX (TYPE_ALIGN (double_type_node), - DECL_ALIGN (CLASS_ASSOC_VTABLE (t))); - } - } - else if (first_vfn_base_index) - CLASSTYPE_VFIELD (t) = vfield; - CLASSTYPE_VFIELDS (t) = vfields; - - /* Set all appropriate CLASSTYPE_... flags for this type - and its variants. */ - TYPE_NEEDS_CONSTRUCTOR (t) |= needs_ctor || TYPE_HAS_CONSTRUCTOR (t); - TYPE_NEEDS_CONSTRUCTING (t) - |= ((TYPE_NEEDS_CONSTRUCTOR (t)|TYPE_USES_VIRTUAL_BASECLASSES (t)) - || (has_virtual | first_vfn_base_index) - || any_default_members); - TYPE_NEEDS_DESTRUCTOR (t) |= needs_dtor || TYPE_HAS_DESTRUCTOR (t); - finish_struct_bits (t, first_vfn_base_index, max_has_virtual); - - /* Promote each bit-field's type to int if it is narrower than that. - Also warn (or error) if static members are specified for a class - which takes a constructor. */ - for (x = fields; x; x = TREE_CHAIN (x)) - { - if (TREE_PACKED (x) - && TREE_CODE (TREE_TYPE (x)) == INTEGER_TYPE - && (TREE_INT_CST_LOW (DECL_SIZE (x)) * DECL_SIZE_UNIT (x) - < TYPE_PRECISION (integer_type_node))) - TREE_TYPE (x) = integer_type_node; - } - - if (TYPE_HAS_CONSTRUCTOR (t)) - { - tree vfields = CLASSTYPE_VFIELDS (t); - - while (vfields) - { - /* Mark the fact that constructor for T - could affect anybody inheriting from T - who wants to initialize vtables for VFIELDS's type. */ - if (TREE_TYPE (vfields)) - TREE_ADDRESSABLE (vfields) = 1; - vfields = TREE_CHAIN (vfields); - } - if (any_default_members != 0) - build_class_init_list (t); - } - else if (TYPE_NEEDS_CONSTRUCTING (t)) - build_class_init_list (t); - - if (current_lang_name == lang_name_cplusplus) - { - if (! CLASSTYPE_DECLARED_EXCEPTION (t)) - embrace_waiting_friends (t); - - /* Write out inline function definitions. */ - do_inline_function_hair (t, CLASSTYPE_INLINE_FRIENDS (t)); - CLASSTYPE_INLINE_FRIENDS (t) = 0; - } - - if (CLASSTYPE_VSIZE (t) != 0) - { - TYPE_NONCOPIED_PARTS (t) = build_tree_list (default_conversion (CLASS_ASSOC_VTABLE (t)), vfield); - - if ((flag_this_is_variable & 1) == 0) - { - tree vtbl_ptr = build_decl (VAR_DECL, get_identifier (VPTR_NAME), - TREE_TYPE (vfield)); - TREE_REGDECL (vtbl_ptr) = 1; - CLASSTYPE_VTBL_PTR (t) = vtbl_ptr; - } - if (DECL_FIELD_CONTEXT (vfield) != t) - { - tree assoc = assoc_value (DECL_FIELD_CONTEXT (vfield), t); - tree offset = ASSOC_OFFSET (assoc); - - vfield = copy_node (vfield); - - if (! integer_zerop (offset)) - offset = convert_units (offset, BITS_PER_UNIT, 1); - if (DECL_OFFSET (vfield)) - offset = genop (PLUS_EXPR, offset, build_int (DECL_OFFSET (vfield))); - DECL_FIELD_CONTEXT (vfield) = t; - DECL_OFFSET (vfield) = TREE_INT_CST_LOW (offset); - CLASSTYPE_VFIELD (t) = vfield; - } - } - - /* Make the rtl for any new vtables we have created, and unmark - the base types we marked. */ - unmark_finished_struct (t); - - /* Now out of this class's scope. However, if this class defined - any new typedefs, then we must export those to the outer - binding level. This is unpleasant. */ - x = gettags (); - - popclass (0); - -#if 0 - /* Remove aggregate types from the list of tags, - since these appear at global scope. */ - while (x && IS_AGGR_TYPE (TREE_VALUE (x))) - x = TREE_CHAIN (x); - CLASSTYPE_TAGS (t) = x; - y = x; - while (x) - { - if (IS_AGGR_TYPE (TREE_VALUE (x))) - TREE_CHAIN (y) = TREE_CHAIN (x); - x = TREE_CHAIN (x); - } -#endif - - hack_incomplete_structures (t); - - resume_momentary (old); - - if (flag_cadillac) - cadillac_finish_struct (t); - - return t; -} - -/* Return non-zero if the effective type of INSTANCE is static. - Used to determine whether the virtual function table is needed - or not. */ -int -resolves_to_fixed_type_p (instance) - tree instance; -{ - switch (TREE_CODE (instance)) - { - case ADDR_EXPR: - return resolves_to_fixed_type_p (TREE_OPERAND (instance, 0)); - - case COMPONENT_REF: - /* Don't let pointers to members look like they hold a fixed type. */ - if (TREE_CODE (TREE_OPERAND (instance, 1)) != FIELD_DECL) - return 0; - - case VAR_DECL: - case PARM_DECL: - case NEW_EXPR: - if (IS_AGGR_TYPE (TREE_TYPE (instance))) - return 1; - - default: - return 0; - } -} - -/* Ordering function for overload resolution. */ -int -rank_for_overload (x, y) - struct candidate *x, *y; -{ - if (y->evil - x->evil) - return y->evil - x->evil; - if ((y->harshness[0] & 128) ^ (x->harshness[0] & 128)) - return y->harshness[0] - x->harshness[0]; - if (y->user - x->user) - return y->user - x->user; - if (y->b_or_d - x->b_or_d) - return y->b_or_d - x->b_or_d; - return y->easy - x->easy; -} - -/* TYPE is the type we wish to convert to. PARM is the parameter - we have to work with. We use a somewhat arbitrary cost function - to measure this conversion. */ -static int -convert_harshness (type, parmtype, parm) - register tree type, parmtype; - tree parm; -{ - register enum tree_code codel = TREE_CODE (type); - register enum tree_code coder = TREE_CODE (parmtype); - -#ifdef GATHER_STATISTICS - n_convert_harshness++; -#endif - - if (TYPE_MAIN_VARIANT (parmtype) == TYPE_MAIN_VARIANT (type)) - return 0; - - if (coder == ERROR_MARK) - return 1; - - if (codel == POINTER_TYPE - && (coder == METHOD_TYPE || coder == FUNCTION_TYPE)) - { - tree p1, p2; - int harshness, new_harshness; - - /* Get to the METHOD_TYPE or FUNCTION_TYPE that this might be. */ - type = TREE_TYPE (type); - - if (coder != TREE_CODE (type)) - return 1; - - harshness = 0; - - /* We allow the default conversion between function type - and pointer-to-function type for free. */ - if (type == parmtype) - return 0; - - /* Compare return types. */ - harshness |= convert_harshness (TREE_TYPE (type), TREE_TYPE (parmtype), 0); - if (harshness & 1) - return 1; - p1 = TYPE_ARG_TYPES (type); - p2 = TYPE_ARG_TYPES (parmtype); - while (p1 && p2) - { - new_harshness = convert_harshness (TREE_VALUE (p1), TREE_VALUE (p2), 0); - if (new_harshness & 1) - return 1; - if ((new_harshness & 7) == 0) - harshness += new_harshness; - else - harshness |= new_harshness; - p1 = TREE_CHAIN (p1); - p2 = TREE_CHAIN (p2); - } - if (p1 == p2) - return harshness; - if (p2) - return 1; - if (p1) - return harshness | (TREE_PURPOSE (p1) == NULL_TREE); - } - else if (codel == POINTER_TYPE && coder == OFFSET_TYPE) - { - int harshness; - - /* Get to the OFFSET_TYPE that this might be. */ - type = TREE_TYPE (type); - - if (coder != TREE_CODE (type)) - return 1; - - harshness = 0; - - if (TYPE_OFFSET_BASETYPE (type) == TYPE_OFFSET_BASETYPE (parmtype)) - harshness = 0; - else if (get_base_type (TYPE_OFFSET_BASETYPE (type), - TYPE_OFFSET_BASETYPE (parmtype), 0)) - harshness = (1<<3); - else - return 1; - /* Now test the OFFSET_TYPE's target compatability. */ - type = TREE_TYPE (type); - parmtype = TREE_TYPE (parmtype); - } - - if (coder == UNKNOWN_TYPE) - { - if (codel == FUNCTION_TYPE - || codel == METHOD_TYPE - || (codel == POINTER_TYPE - && (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE))) - return 0; - return 1; - } - - if (coder == VOID_TYPE) - return 1; - - if (codel == ENUMERAL_TYPE || codel == INTEGER_TYPE) - { - /* Control equivalence of ints an enums. */ - - if (codel == ENUMERAL_TYPE - && flag_int_enum_equivalence == 0) - { - /* Enums can be converted to ints, but not vice-versa. */ - if (coder != ENUMERAL_TYPE - || TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (parmtype)) - return 1; - } - - /* else enums and ints (almost) freely interconvert. */ - - if (coder == INTEGER_TYPE || coder == ENUMERAL_TYPE) - { - int easy = TREE_UNSIGNED (type) ^ TREE_UNSIGNED (parmtype); - if (codel != coder) - easy += 1; - if (TYPE_MODE (type) != TYPE_MODE (parmtype)) - easy += 2; - return (easy << 4); - } - else if (coder == REAL_TYPE) - return (4<<4); - } - - if (codel == REAL_TYPE) - if (coder == REAL_TYPE) - /* Shun converting between float and double if a choice exists. */ - { - if (TYPE_MODE (type) != TYPE_MODE (parmtype)) - return (2<<4); - return 0; - } - else if (coder == INTEGER_TYPE || coder == ENUMERAL_TYPE) - return (4<<4); - - /* convert arrays which have not previously been converted. */ - if (codel == ARRAY_TYPE) - codel = POINTER_TYPE; - if (coder == ARRAY_TYPE) - coder = POINTER_TYPE; - - /* Conversions among pointers */ - if (codel == POINTER_TYPE && coder == POINTER_TYPE) - { - register tree ttl = TYPE_MAIN_VARIANT (TREE_TYPE (type)); - register tree ttr = TYPE_MAIN_VARIANT (TREE_TYPE (parmtype)); - int penalty = 4 * (ttl != ttr); - /* Anything converts to void *. void * converts to anything. - Since these may be `const void *' (etc.) use VOID_TYPE - instead of void_type_node. - Otherwise, the targets must be the same, - except that we do allow (at some cost) conversion - between signed and unsinged pointer types. */ - - if ((TREE_CODE (ttl) == METHOD_TYPE - || TREE_CODE (ttl) == FUNCTION_TYPE) - && TREE_CODE (ttl) == TREE_CODE (ttr)) - { - if (comptypes (ttl, ttr, -1)) - return penalty<<4; - return 1; - } - - if (!(TREE_CODE (ttl) == VOID_TYPE - || TREE_CODE (ttr) == VOID_TYPE - || (TREE_UNSIGNED (ttl) ^ TREE_UNSIGNED (ttr) - && (ttl = unsigned_type (ttl), - ttr = unsigned_type (ttr), - penalty = 10, 0)) - || (comp_target_types (ttl, ttr, 0)))) - return 1; - - if (ttr == ttl) - return 4; - - if (IS_AGGR_TYPE (ttl) && IS_AGGR_TYPE (ttr)) - { - int b_or_d = get_base_distance (ttl, ttr, 0, 0); - if (b_or_d < 0) - return 1; - return (b_or_d<<3) | 4; - } - - return (penalty<<4); - } - - if (codel == POINTER_TYPE && coder == INTEGER_TYPE) - { - /* This is not a bad match, but don't let it beat - integer-enum combinations. */ - if (parm && integer_zerop (parm)) - return (4<<4); - } - - /* C++: one of the types must be a reference type. */ - { - tree ttl, ttr; - register tree intype = TYPE_MAIN_VARIANT (parmtype); - register enum tree_code form = TREE_CODE (intype); - int penalty; - - if (codel == REFERENCE_TYPE || coder == REFERENCE_TYPE) - { - ttl = TYPE_MAIN_VARIANT (type); - - if (codel == REFERENCE_TYPE) - { - ttl = TYPE_MAIN_VARIANT (TREE_TYPE (ttl)); - - if (form == OFFSET_TYPE) - { - intype = TREE_TYPE (intype); - form = TREE_CODE (intype); - } - - if (form == REFERENCE_TYPE) - { - intype = TYPE_MAIN_VARIANT (TREE_TYPE (intype)); - - if (ttl == intype) - return 0; - penalty = 2; - } - else - { - /* Can reference be built up? */ - if (ttl == intype) - { - return 0; - } - else - penalty = 2; - } - } - else if (form == REFERENCE_TYPE) - { - if (parm) - { - tree tmp = convert_from_reference (parm); - intype = TYPE_MAIN_VARIANT (TREE_TYPE (tmp)); - } - else - { - intype = parmtype; - do - { - intype = TREE_TYPE (intype); - } - while (TREE_CODE (intype) == REFERENCE_TYPE); - intype = TYPE_MAIN_VARIANT (intype); - } - - if (ttl == intype) - return 0; - else - penalty = 2; - } - - if (TREE_UNSIGNED (ttl) ^ TREE_UNSIGNED (intype)) - { - ttl = unsigned_type (ttl); - intype = unsigned_type (intype); - penalty += 2; - } - - ttr = intype; - - /* If the initializer is not an lvalue, then it does not - matter if we make life easier for the programmer - by creating a temporary variable with which to - hold the result. */ - if (parm && (coder == INTEGER_TYPE - || coder == ENUMERAL_TYPE - || coder == REAL_TYPE) - && ! lvalue_p (parm)) - return (convert_harshness (ttl, ttr, 0) | (penalty << 4)); - - if (ttl == ttr) - return 4; - - /* Pointers to voids always convert for pointers. But - make them less natural than more specific matches. */ - if (TREE_CODE (ttl) == POINTER_TYPE && TREE_CODE (ttr) == POINTER_TYPE) - if (TREE_TYPE (ttl) == void_type_node - || TREE_TYPE (ttr) == void_type_node) - return ((penalty+1)<<4); - - if (parm && codel != REFERENCE_TYPE) - return (convert_harshness (ttl, ttr, 0) | (penalty << 4)); - - /* Here it does matter. If this conversion is from - derived to base, allow it. Otherwise, types must - be compatible in the strong sense. */ - if (IS_AGGR_TYPE (ttl) && IS_AGGR_TYPE (ttr)) - { - int b_or_d = get_base_distance (ttl, ttr, 0, 0); - if (b_or_d < 0) - return 1; -#if AMBIGUOUS_WORKING - if (ttl == TYPE_MAIN_VARIANT (type) - && TYPE_GETS_INIT_REF (type)) - return (b_or_d<<3) | 6; -#endif - return (b_or_d<<3) | 4; - } - - if (comp_target_types (ttl, intype, 1)) - return (penalty<<4); - } - } - if (codel == RECORD_TYPE && coder == RECORD_TYPE) - { - int b_or_d = get_base_distance (type, parmtype, 0, 0); - if (b_or_d < 0) - return 1; -#if AMBIGUOUS_WORKING - if (TYPE_GETS_INIT_REF (type)) - return (b_or_d<<3) | 6; -#endif - return (b_or_d<<3) | 4; - } - return 1; -} - -/* Algorithm: Start out with no stikes against. For each argument - which requires a (subjective) hard conversion (such as between - floating point and integer), issue a strike. If there are the same - number of formal and actual parameters in the list, there will be at - least on strike, otherwise an exact match would have been found. If - there are not the same number of arguments in the type lists, we are - not dead yet: a `...' means that we can have more parms then were - declared, and if we wind up in the default argument section of the - list those can be used as well. If an exact match could be found for - one of those cases, return it immediately. Otherwise, Rank the fields - so that fields with fewer strikes are tried first. - - Conversions between builtin and user-defined types are allowed, but - no function involving such a conversion is prefered to one which - does not require such a conversion. Furthermore, such conversions - must be unique. */ - -void -compute_conversion_costs (function, tta_in, cp, arglen) - tree function; - tree tta_in; - struct candidate *cp; - int arglen; -{ - tree ttf_in = TYPE_ARG_TYPES (TREE_TYPE (function)); - tree ttf = ttf_in; - tree tta = tta_in; - - /* Start out with no strikes against. */ - int evil_strikes = 0; - int user_strikes = 0; - int b_or_d_strikes = 0; - int easy_strikes = 0; - - int strike_index = 0, win, lose; - -#ifdef GATHER_STATISTICS - n_compute_conversion_costs++; -#endif - - cp->function = function; - cp->arg = tta ? TREE_VALUE (tta) : NULL_TREE; - cp->u.bad_arg = 0; /* optimistic! */ - - bzero (cp->harshness, (arglen+1) * sizeof (short)); - - while (ttf && tta) - { - int harshness; - - if (ttf == void_list_node) - break; - - if (type_unknown_p (TREE_VALUE (tta))) - { - /* Must perform some instantiation here. */ - tree rhs = TREE_VALUE (tta); - tree lhstype = TREE_VALUE (ttf); - - /* @@ This is to undo what `grokdeclarator' does to - parameter types. It really should go through - something more general. */ - - TREE_TYPE (tta) = unknown_type_node; - if (TREE_CODE (rhs) == OP_IDENTIFIER) - rhs = build_instantiated_decl (lhstype, rhs); - else - { - /* Keep quiet about possible contravariance violations. */ - extern int inhibit_warnings; - int old_inhibit_warnings = inhibit_warnings; - inhibit_warnings = 1; - - rhs = instantiate_type (lhstype, rhs, 0); - - inhibit_warnings = old_inhibit_warnings; - } - - if (TREE_CODE (rhs) == ERROR_MARK) - harshness = 1; - else - { - harshness = convert_harshness (lhstype, TREE_TYPE (rhs), rhs); - /* harshness |= 2; */ - } - } - else - harshness = convert_harshness (TREE_VALUE (ttf), TREE_TYPE (TREE_VALUE (tta)), TREE_VALUE (tta)); - - cp->harshness[strike_index] = harshness; - if (harshness & 1) - { - cp->u.bad_arg = strike_index; - evil_strikes = 1; - } - else if (harshness & 2) - { - user_strikes += 1; - } - else if (harshness & 4) - { - b_or_d_strikes += (harshness >> 3); - } - else - easy_strikes += harshness >> 4; - ttf = TREE_CHAIN (ttf); - tta = TREE_CHAIN (tta); - strike_index += 1; - } - - if (tta) - { - /* ran out of formals, and parmlist is fixed size. */ - if (ttf /* == void_type_node */) - { - cp->evil = 1; - cp->u.bad_arg = -1; - return; - } - } - else if (ttf && ttf != void_list_node) - { - /* ran out of actuals, and no defaults. */ - if (TREE_PURPOSE (ttf) == NULL_TREE) - { - cp->evil = 1; - cp->u.bad_arg = -2; - return; - } - /* Store index of first default. */ - cp->harshness[arglen] = strike_index+1; - } - else cp->harshness[arglen] = 0; - - /* Argument list lengths work out, so don't need to check them again. */ - if (evil_strikes) - { - /* We do not check for derived->base conversions here, since in - no case would they give evil strike counts, unless such conversions - are somehow ambiguous. */ - - /* See if any user-defined conversions apply. - But make sure that we do not loop. */ - static int dont_convert_types = 0; - - if (dont_convert_types) - { - cp->evil = 1; - return; - } - - win = 0; /* Only get one chance to win. */ - ttf = TYPE_ARG_TYPES (TREE_TYPE (function)); - tta = tta_in; - strike_index = 0; - evil_strikes = 0; - - while (ttf && tta) - { - if (ttf == void_list_node) - break; - - lose = cp->harshness[strike_index]; - if (lose&1) - { - tree actual_type = TREE_TYPE (TREE_VALUE (tta)); - tree formal_type = TREE_VALUE (ttf); - - dont_convert_types = 1; - - if (TREE_CODE (formal_type) == REFERENCE_TYPE) - formal_type = TREE_TYPE (formal_type); - if (TREE_CODE (actual_type) == REFERENCE_TYPE) - actual_type = TREE_TYPE (actual_type); - - if (formal_type != error_mark_node - && actual_type != error_mark_node) - { - formal_type = TYPE_MAIN_VARIANT (formal_type); - actual_type = TYPE_MAIN_VARIANT (actual_type); - - if (TYPE_HAS_CONSTRUCTOR (formal_type)) - { - /* If it has a constructor for this type, try to use it. */ - if (convert_to_aggr (formal_type, TREE_VALUE (tta), 0, 1) - != error_mark_node) - { - /* @@ There is no way to save this result yet. - @@ So success is NULL_TREE for now. */ - win++; - } - } - if (TYPE_LANG_SPECIFIC (actual_type) && TYPE_HAS_CONVERSION (actual_type)) - { - if (TREE_CODE (formal_type) == INTEGER_TYPE - && TYPE_HAS_INT_CONVERSION (actual_type)) - win++; - else if (TREE_CODE (formal_type) == REAL_TYPE - && TYPE_HAS_REAL_CONVERSION (actual_type)) - win++; - else - { - tree conv = build_type_conversion (CALL_EXPR, TREE_VALUE (ttf), TREE_VALUE (tta), 0); - if (conv) - { - if (conv == error_mark_node) - win += 2; - else - win++; - } - else if (TREE_CODE (TREE_VALUE (ttf)) == REFERENCE_TYPE) - { - conv = build_type_conversion (CALL_EXPR, formal_type, TREE_VALUE (tta), 0); - if (conv) - { - if (conv == error_mark_node) - win += 2; - else - win++; - } - } - } - } - } - dont_convert_types = 0; - - if (win == 1) - { - user_strikes += 1; - cp->harshness[strike_index] = 2; - win = 0; - } - else - { - if (cp->u.bad_arg > strike_index) - cp->u.bad_arg = strike_index; - - evil_strikes = win ? 2 : 1; - break; - } - } - - ttf = TREE_CHAIN (ttf); - tta = TREE_CHAIN (tta); - strike_index += 1; - } - } - - /* Calling a non-const member function from a const member function - is probably invalid, but for now we let it only draw a warning. - We indicate that such a mismatch has occured by setting the - harshness to a maximum value. */ - if (TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE - && TREE_CODE (TREE_TYPE (TREE_VALUE (tta_in))) == POINTER_TYPE - && (TREE_READONLY (TREE_TYPE (TREE_TYPE (TREE_VALUE (tta_in)))) - > TREE_READONLY (TREE_TYPE (TREE_VALUE (ttf_in))))) - cp->harshness[0] |= 128; - - cp->evil = evil_strikes; - cp->user = user_strikes; - cp->b_or_d = b_or_d_strikes; - cp->easy = easy_strikes; -} - -struct candidate * -ideal_candidate (basetype, candidates, n_candidates, parms, len) - tree basetype; - struct candidate *candidates; - int n_candidates; - tree parms; - int len; -{ - struct candidate *cp = candidates + n_candidates; - int index, i; - tree ttf; - - qsort (candidates, /* char *base */ - n_candidates, /* int nel */ - sizeof (struct candidate), /* int width */ - rank_for_overload); /* int (*compar)() */ - - /* If the best candidate requires user-defined conversions, - and its user-defined conversions are a strict subset - of all other candidates requiring user-defined conversions, - then it is, in fact, the best. */ - for (i = -1; cp + i != candidates; i--) - if (cp[i].user == 0) - break; - - if (i < -1) - { - tree ttf0; - - /* Check that every other candidate requires those conversions - as a strict subset of their conversions. */ - if (cp[i].user == cp[-1].user) - goto non_subset; - - /* Look at subset relationship more closely. */ - while (i != -1) - { - for (ttf = TYPE_ARG_TYPES (TREE_TYPE (cp[i].function)), - ttf0 = TYPE_ARG_TYPES (TREE_TYPE (cp[-1].function)), - index = 0; - index < len; - ttf = TREE_CHAIN (ttf), ttf0 = TREE_CHAIN (ttf0), index++) - if (cp[i].harshness[index] & 2) - { - /* If our "best" candidate also needs a conversion, - it must be the same one. */ - if ((cp[-1].harshness[index] & 2) - && TREE_VALUE (ttf) != TREE_VALUE (ttf0)) - goto non_subset; - } - i++; - } - /* The best was the best. */ - return cp - 1; - non_subset: - /* Use other rules for determining "bestness". */ - ; - } - - /* If the best two candidates we find require user-defined - conversions, we may need to report and error message. */ - if (cp[-1].user && cp[-2].user - && (cp[-1].b_or_d || cp[-2].b_or_d == 0)) - { - /* If the best two methods found involved user-defined - type conversions, then we must see whether one - of them is exactly what we wanted. If not, then - we have an ambiguity. */ - int best = 0; - tree tta = parms; - tree f1, p1; - -#if AMBIGUOUS_WORKING - if (cp[-1].b_or_d == 0 - && cp[-1].easy == 0 - && (cp[-2].b_or_d | cp[-2].easy) > 0) - return cp - 1; -#endif - - /* Stash all of our parameters in safe places - so that we can perform type conversions in place. */ - while (tta) - { - TREE_PURPOSE (tta) = TREE_VALUE (tta); - tta = TREE_CHAIN (tta); - } - - i = 0; - do - { - int exact_conversions = 0; - - i -= 1; - tta = parms; - if (DECL_STATIC_FUNCTION_P (cp[i].function)) - tta = TREE_CHAIN (tta); - for (ttf = TYPE_ARG_TYPES (TREE_TYPE (cp[i].function)), index = 0; - index < len; - tta = TREE_CHAIN (tta), ttf = TREE_CHAIN (ttf), index++) - { - if (cp[i].harshness[index] & 2) - { - TREE_VALUE (tta) - = build_type_conversion (CALL_EXPR, TREE_VALUE (ttf), TREE_PURPOSE (tta), 2); - if (TREE_VALUE (tta)) - { - if (TREE_CODE (TREE_VALUE (tta)) != CONVERT_EXPR - && (TREE_CODE (TREE_VALUE (tta)) != NOP_EXPR - || comp_target_types (TREE_TYPE (TREE_VALUE (tta)), - TREE_TYPE (TREE_OPERAND (TREE_VALUE (tta), 0)), 1))) - exact_conversions += 1; - } - else if (IS_AGGR_TYPE (TREE_VALUE (ttf)) - || (TREE_CODE (TREE_VALUE (ttf)) == REFERENCE_TYPE - && IS_AGGR_TYPE (TREE_TYPE (TREE_VALUE (ttf))))) - { - /* To get here we had to have succeeded via - a constructor. */ - TREE_VALUE (tta) = TREE_PURPOSE (tta); - exact_conversions += 1; - } - } - } - if (exact_conversions == cp[i].user) - { - if (best == 0) - { - best = i; - f1 = cp[best].function; - p1 = TYPE_ARG_TYPES (TREE_TYPE (f1)); - } - else - { - /* Don't complain if next best is from base class. */ - tree f2 = cp[i].function; - tree p2 = TYPE_ARG_TYPES (TREE_TYPE (f2)); - - if (TREE_CODE (TREE_TYPE (f1)) == METHOD_TYPE - && TREE_CODE (TREE_TYPE (f2)) == METHOD_TYPE - && (cp[i].harshness[0] & 4) != 0 - && cp[best].harshness[0] < cp[i].harshness[0]) - { -#if 0 - /* For LUCID. */ - if (! compparms (TREE_CHAIN (p1), TREE_CHAIN (p2), 1)) - goto ret0; - else -#endif - continue; - } - else goto ret0; - } - } - } while (cp + i != candidates); - - if (best) - { - int exact_conversions = cp[best].user; - tta = parms; - if (DECL_STATIC_FUNCTION_P (cp[best].function)) - tta = TREE_CHAIN (parms); - for (ttf = TYPE_ARG_TYPES (TREE_TYPE (cp[best].function)), index = 0; - exact_conversions > 0; - tta = TREE_CHAIN (tta), ttf = TREE_CHAIN (ttf), index++) - { - if (cp[best].harshness[index] & 2) - { - /* We must now fill in the slot we left behind. - @@ This could be optimized to use the value previously - @@ computed by build_type_conversion in some cases. */ - TREE_VALUE (tta) = convert (TREE_VALUE (ttf), TREE_PURPOSE (tta)); - exact_conversions -= 1; - } - else TREE_VALUE (tta) = TREE_PURPOSE (tta); - } - return cp + best; - } - goto ret0; - } - /* If the best two candidates we find both use default parameters, - we may need to report and error. Don't need to worry if next-best - candidate is forced to use user-defined conversion when best is not. */ - if (cp[-2].user == 0 - && cp[-1].harshness[len] != 0 && cp[-2].harshness[len] != 0) - { - tree tt1 = TYPE_ARG_TYPES (TREE_TYPE (cp[-1].function)); - tree tt2 = TYPE_ARG_TYPES (TREE_TYPE (cp[-2].function)); - int i = cp[-1].harshness[len]; - if (cp[-2].harshness[len] < i) - i = cp[-2].harshness[len]; - while (--i > 0) - { - if (TYPE_MAIN_VARIANT (TREE_VALUE (tt1)) - != TYPE_MAIN_VARIANT (TREE_VALUE (tt2))) - /* These lists are not identical, so we can choose our best candidate. */ - return cp - 1; - tt1 = TREE_CHAIN (tt1); - tt2 = TREE_CHAIN (tt2); - } - /* To get here, both lists had the same parameters up to the defaults - which were used. This is an ambiguous request. */ - goto ret0; - } - - /* Otherwise, return our best candidate. Note that if we get candidates - from independent base classes, we have an ambiguity, even if one - argument list look a little better than another one. */ - if (cp[-1].b_or_d && basetype && TYPE_USES_MULTIPLE_INHERITANCE (basetype)) - { - int i = n_candidates - 1, best; - tree base1 = NULL_TREE; - - if (TREE_CODE (TREE_TYPE (candidates[i].function)) == FUNCTION_TYPE) - return cp - 1; - - for (; i >= 0 && candidates[i].user == 0 && candidates[i].evil == 0; i--) - { - if (TREE_CODE (TREE_TYPE (candidates[i].function)) == METHOD_TYPE) - { - tree newbase = TYPE_METHOD_BASETYPE (TREE_TYPE (candidates[i].function)); - - if (base1 != NULL_TREE) - { - if (newbase != base1 - && ! get_base_type (newbase, base1, 0)) - { - char *buf = (char *)alloca (8192); - error ("ambiguous request for function from distinct base classes of type `%s'", TYPE_NAME_STRING (basetype)); - error ("first candidate is `%s'", fndecl_as_string (buf, 0, candidates[best].function, 1)); - error ("second candidates is `%s'", fndecl_as_string (buf, 0, candidates[i].function, 1)); - return cp - 1; - } - } - else - { - best = i; - base1 = newbase; - } - } - else return cp - 1; - } - } - -#if AMBIGUOUS_WORKING - if (cp[-1].user == cp[-2].user - && cp[-1].b_or_d == cp[-2].b_or_d - && cp[-1].easy == cp[-2].easy) - goto ret0; -#endif - - return cp - 1; - - ret0: - /* In the case where there is no ideal candidate, restore - TREE_VALUE slots of PARMS from TREE_PURPOSE slots. */ - while (parms) - { - TREE_VALUE (parms) = TREE_PURPOSE (parms); - parms = TREE_CHAIN (parms); - } - return 0; -} - -/* Assume that if the class referred to is not in the - current class hierarchy, that it may be remote. - PARENT is assumed to be of aggregate type here. */ -static int -may_be_remote (parent) - tree parent; -{ - if (TYPE_OVERLOADS_METHOD_CALL_EXPR (parent) == 0) - return 0; - - if (current_class_type == NULL_TREE) - return 0; - if (parent == current_class_type) - return 0; - - if (get_base_type (parent, current_class_type, 0)) - return 0; - return 1; -} - -/* Return the number of bytes that the arglist in PARMS would - occupy on the stack. */ -int -get_arglist_len_in_bytes (parms) - tree parms; -{ - register tree parm; - register int bytecount = 0; - - for (parm = parms; parm; parm = TREE_CHAIN (parm)) - { - register tree pval = TREE_VALUE (parm); - register int used, size; - - if (TREE_CODE (pval) == ERROR_MARK) - continue; - else if (TYPE_MODE (TREE_TYPE (pval)) != BLKmode) - { - used = size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (pval))); -#ifdef PUSH_ROUNDING - size = PUSH_ROUNDING (size); -#endif - used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1) - / (PARM_BOUNDARY / BITS_PER_UNIT)) - * (PARM_BOUNDARY / BITS_PER_UNIT)); - } - else - { - register tree size = size_in_bytes (TREE_TYPE (pval)); - register tree used_t = convert_units (convert_units (size, BITS_PER_UNIT, PARM_BOUNDARY), - PARM_BOUNDARY, BITS_PER_UNIT); - used = TREE_INT_CST_LOW (used_t); - } - bytecount += used; - } - return bytecount; -} - -tree -build_vfield_ref (datum, type) - tree datum, type; -{ - if (TREE_CODE (TREE_TYPE (datum)) == REFERENCE_TYPE) - datum = convert_from_reference (datum); - - if (! TYPE_USES_VIRTUAL_BASECLASSES (type)) - return build (COMPONENT_REF, TREE_TYPE (CLASSTYPE_VFIELD (type)), - datum, CLASSTYPE_VFIELD (type)); - return build_component_ref (datum, DECL_NAME (CLASSTYPE_VFIELD (type)), 0, 0); -} - -/* Build a call to a member of an object. I.e., one that overloads - operator ()(), or is a pointer-to-function or pointer-to-method. */ -static tree -build_field_call (basetype_path, instance_ptr, name, parms, err_name) - tree basetype_path; - tree instance_ptr, name, parms; - char *err_name; -{ - tree field, instance; - - if (instance_ptr == current_class_decl) - { - /* Check to see if we really have a reference to an instance variable - with `operator()()' overloaded. */ -#if 1 - field = IDENTIFIER_CLASS_VALUE (name); -#else - field = identifier_class_value (name); -#endif - - if (field == NULL_TREE) - { - error ("`this' has no member named `%s'", err_name); - return error_mark_node; - } - - if (TREE_CODE (field) == FIELD_DECL) - { - /* If it's a field, try overloading operator (), - or calling if the field is a pointer-to-function. */ - instance = build_component_ref_1 (C_C_D, field, 0, 1); - if (instance == error_mark_node) - return error_mark_node; - - if (TYPE_LANG_SPECIFIC (TREE_TYPE (instance)) - && TYPE_OVERLOADS_CALL_EXPR (TREE_TYPE (instance))) - return build_opfncall (CALL_EXPR, LOOKUP_NORMAL, instance, parms); - - if (TREE_CODE (TREE_TYPE (instance)) == POINTER_TYPE) - if (TREE_CODE (TREE_TYPE (TREE_TYPE (instance))) == FUNCTION_TYPE) - return build_function_call (instance, parms); - else if (TREE_CODE (TREE_TYPE (TREE_TYPE (instance))) == METHOD_TYPE) - return build_function_call (instance, tree_cons (NULL_TREE, current_class_decl, parms)); - } - return NULL_TREE; - } - - /* Check to see if this is not really a reference to an instance variable - with `operator()()' overloaded. */ - field = lookup_field (basetype_path, name, 1); - - /* This can happen if the reference was ambiguous - or for visibility violations. */ - if (field == error_mark_node) - return error_mark_node; - if (field) - { - tree basetype; - tree ftype = TREE_TYPE (field); - - if (TYPE_LANG_SPECIFIC (ftype) && TYPE_OVERLOADS_CALL_EXPR (ftype)) - { - /* Make the next search for this field very short. */ - basetype = DECL_FIELD_CONTEXT (field); - instance_ptr = convert_pointer_to (basetype, instance_ptr); - - instance = build_indirect_ref (instance_ptr, 0); - return build_opfncall (CALL_EXPR, LOOKUP_NORMAL, - build_component_ref_1 (instance, field, 0, 0), - parms); - } - if (TREE_CODE (ftype) == POINTER_TYPE) - { - if (TREE_CODE (TREE_TYPE (ftype)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (ftype)) == METHOD_TYPE) - { - /* This is a member which is a pointer to function. */ - tree ref = build_component_ref_1 (build_indirect_ref (instance_ptr, 0, 0), - field, LOOKUP_COMPLAIN); - if (ref == error_mark_node) - return error_mark_node; - return build_function_call (ref, parms); - } - } - else if (TREE_CODE (ftype) == METHOD_TYPE) - { - error ("invalid call via pointer-to-member function"); - return error_mark_node; - } - else - return NULL_TREE; - } - return NULL_TREE; -} - -/* Build a method call of the form `EXP->SCOPES::NAME (PARMS)'. - This is how virtual function calls are avoided. */ -tree -build_scoped_method_call (exp, scopes, name, parms) - tree exp; - tree scopes; - tree name; - tree parms; -{ - /* Because this syntactic form does not allow - a pointer to a base class to be `stolen', - we need not protect the drived->base conversion - that happens here. - - @@ But we do have to check visibility privileges later. */ - tree basename = (TREE_CODE (scopes) == SCOPE_REF) ? TREE_OPERAND (scopes, 1) : scopes; - tree basetype, decl; - tree type = TREE_TYPE (exp); - - if (type == error_mark_node - || ! is_aggr_typedef (basename, 1)) - return error_mark_node; - - if (! IS_AGGR_TYPE (type)) - { - error ("base object of scoped method call is not of aggregate type"); - return error_mark_node; - } - - basetype = TREE_TYPE (TREE_TYPE (basename)); - - if (basetype = basetype_or_else (basetype, type)) - { - if (basetype == error_mark_node) - return error_mark_node; - if (TREE_CODE (exp) == INDIRECT_REF) - decl = build_indirect_ref (convert_pointer_to (basetype, - build_unary_op (ADDR_EXPR, exp, 0)), 0); - else - decl = build_scoped_ref (exp, scopes); - - /* Call to a destructor. */ - if (TREE_CODE (name) == BIT_NOT_EXPR) - { - /* Explicit call to destructor. */ - name = TREE_OPERAND (name, 0); - if (! is_aggr_typedef (name, 1)) - return error_mark_node; - if (TREE_TYPE (decl) != TREE_TYPE (TREE_TYPE (name))) - { - error_with_aggr_type (TREE_TYPE (decl), - "qualified type `%s' does not match destructor type `%s'", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - if (! TYPE_HAS_DESTRUCTOR (TREE_TYPE (decl))) - error_with_aggr_type (TREE_TYPE (decl), "type `%s' has no destructor"); - return build_delete (TREE_TYPE (decl), decl, integer_two_node, - LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0); - } - - /* Call to a method. */ - return build_method_call (decl, name, parms, NULL_TREE, - LOOKUP_NORMAL|LOOKUP_NONVIRTUAL); - } - return error_mark_node; -} - -/* Build something of the form ptr->method (args) - or object.method (args). This can also build - calls to constructors, and find friends. - - Member functions always take their class variable - as a pointer. - - INSTANCE is a class instance. - - NAME is the NAME field of the struct, union, or class - whose type is that of INSTANCE. - - PARMS help to figure out what that NAME really refers to. - - BASETYPE_PATH, if non-NULL, tells which basetypes of INSTANCE - we should be traversed before starting our search. We need - this information to get protected accesses correct. - - FLAGS is the logical disjunction of zero or more LOOKUP_ - flags. See cplus-tree.h for more info. - - If this is all OK, calls build_function_call with the resolved - member function. - - This function must also handle being called to perform - initialization, promotion/coercion of arguments, and - instantiation of default parameters. - - Note that NAME may refer to an instance variable name. If - `operator()()' is defined for the type of that field, then we return - that result. */ -tree -build_method_call (instance, name, parms, basetype_path, flags) - tree instance, name, parms, basetype_path; - int flags; -{ - register tree function, fntype, value_type; - register tree basetype, save_basetype; - register tree baselink, result, method_name, parmtypes, parm; - tree last; - int pass; - enum visibility_type visibility; - int rank_for_overload (); - - /* Range of cases for vtable optimization. */ - enum vtable_needs - { - not_needed, maybe_needed, unneeded, needed, - }; - enum vtable_needs need_vtbl = not_needed; - - char *err_name; - char *name_kind; - int ever_seen = 0; - int wrap; - tree wrap_type; - tree instance_ptr = NULL_TREE; - int all_virtual = flag_all_virtual; - int static_call_context; - tree saw_private = 0; - tree saw_protected = 0; -#ifdef SOS - /* If call is a call to a constructor, then `dtbl' - will first be initialized with the function table pointer - of the appropriate type (calling "sosFindCode" as a last - resort), the the call to the constructor will go through there. */ - tree dtbl = (flags & LOOKUP_DYNAMIC) ? TREE_VALUE (parms) : NULL_TREE; - - /* Flag saying whether or not `dtbl' has been inserted into the - parameter list. This is needed because we cannot tell (until - we have a match) whether this parameter should go in or not. - - If 1, then `dtbl' is living naturally. - If 0, then `dtbl' is not among the parms that we know about. - If -1, the `dtbl' was place into the parms unnaturally. - - Note that we may side-effect the parameter list, but in such a way - that the caller of this function would never know. */ - int dtbl_inserted = (flags & LOOKUP_DYNAMIC); -#endif - - /* Keep track of `const' and `volatile' objects. */ - int constp, volatilep; - - /* Know if this is explicit destructor call. */ - int dtor_specd = 0; - -#ifdef GATHER_STATISTICS - n_build_method_call++; -#endif - - if (instance == error_mark_node - || name == error_mark_node - || parms == error_mark_node - || (instance != 0 && TREE_TYPE (instance) == error_mark_node)) - return error_mark_node; - -#if 0 - /* C++ 2.1 does not allow this, but ANSI probably will. */ - if (TREE_CODE (name) == BIT_NOT_EXPR) - { - error ("invalid call to destructor, use qualified name `%s::~%s'", - IDENTIFIER_POINTER (name), IDENTIFIER_POINTER (name)); - return error_mark_node; - } -#else - if (TREE_CODE (name) == BIT_NOT_EXPR) - { - flags |= LOOKUP_DESTRUCTOR; - name = TREE_OPERAND (name, 0); - if (! is_aggr_typedef (name, 1)) - return error_mark_node; - if (parms) - error ("destructors take no parameters"); - basetype = TREE_TYPE (TREE_TYPE (name)); - if (! TYPE_HAS_DESTRUCTOR (basetype)) - error_with_aggr_type (basetype, "type `%s' has no destructor"); - instance = default_conversion (instance); - if (TREE_CODE (TREE_TYPE (instance)) == POINTER_TYPE) - instance_ptr = instance; - else - instance_ptr = build_unary_op (ADDR_EXPR, instance, 0); - return build_delete (basetype, instance_ptr, integer_two_node, - LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 0); - } -#endif - - if (TREE_CODE (name) == WRAPPER_EXPR) - { - wrap_type = TREE_OPERAND (name, 0); - name = TREE_OPERAND (name, 1); - wrap = 1; - } - else if (TREE_CODE (name) == ANTI_WRAPPER_EXPR) - { - wrap_type = TREE_OPERAND (name, 0); - name = TREE_OPERAND (name, 1); - wrap = -1; - } - else - { - wrap_type = NULL_TREE; - wrap = 0; - } - - /* Initialize name for error reporting. */ - if (TREE_CODE (name) == OP_IDENTIFIER) - name = build_operator_fnname (&name, parms, 1); - - if (OPERATOR_NAME_P (name)) - { - char *p = operator_name_string (name); - err_name = (char *)alloca (strlen (p) + 10); - sprintf (err_name, "operator %s", p); - } - else if (name == wrapper_name) - err_name = "wrapper"; - else if (OPERATOR_TYPENAME_P (name)) - err_name = "type conversion operator"; - else if (TREE_CODE (name) == SCOPE_REF) - err_name = IDENTIFIER_POINTER (TREE_OPERAND (name, 1)); - else - err_name = IDENTIFIER_POINTER (name); - -#ifdef FIELD_XREF - FIELD_xref_call(current_function_decl,err_name); -#endif - - if (wrap) - { - char *p = (char *)alloca (strlen (err_name) + 32); - sprintf (p, "%s for `%s'", wrap < 0 ? "anti-wrapper" : "wrapper", err_name); - err_name = p; - } - - if (instance == NULL_TREE) - { - static_call_context = 0; - - basetype = NULL_TREE; - /* Check cases where this is really a call to raise - an exception. */ - if (current_class_type && TREE_CODE (name) == IDENTIFIER_NODE) - { - basetype = purpose_member (name, CLASSTYPE_TAGS (current_class_type)); - if (basetype) - basetype = TREE_VALUE (basetype); - } - else if (TREE_CODE (name) == SCOPE_REF - && TREE_CODE (TREE_OPERAND (name, 0)) == IDENTIFIER_NODE) - { - if (! is_aggr_typedef (TREE_OPERAND (name, 0), 1)) - return error_mark_node; - basetype = purpose_member (TREE_OPERAND (name, 1), - CLASSTYPE_TAGS (TREE_TYPE (TREE_TYPE (TREE_OPERAND (name, 0))))); - if (basetype) - basetype = TREE_VALUE (basetype); - } - - if (basetype != NULL_TREE) - ; - /* call to a constructor... */ - else if (TREE_TYPE (name)) - basetype = TREE_TYPE (TREE_TYPE (name)); - else - { - tree typedef_name = lookup_name (name); - if (typedef_name && TREE_CODE (typedef_name) == TYPE_DECL) - { - /* Cannonicalize the typedef name. */ - basetype = TREE_TYPE (typedef_name); - name = DECL_NAME (TYPE_NAME (basetype)); - } - else - { - error ("no constructor named `%s' in visible scope", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - } - if (wrap_type && wrap_type != basetype) - { - error_with_aggr_type (wrap_type, "invalid constructor `%s::%s'", - TYPE_NAME_STRING (basetype)); - return error_mark_node; - } - if (TYPE_VIRTUAL_P (basetype)) - { - wrap_type = basetype; - } - - if (! IS_AGGR_TYPE (basetype)) - { - non_aggr_error: - if ((flags & LOOKUP_COMPLAIN) && TREE_CODE (basetype) != ERROR_MARK) - error ("request for member `%s' in something not a structure or union", err_name); - - return error_mark_node; - } - } - else if (instance == C_C_D || instance == current_class_decl) - { - extern tree ctor_label, dtor_label; - - /* When doing initialization, we side-effect the TREE_TYPE of - C_C_D, hence we cannot set up BASETYPE from CURRENT_CLASS_TYPE. */ - basetype = TREE_TYPE (C_C_D); - - /* Anything manifestly `this' in constructors and destructors - has a known type, so virtual function tables are not needed. */ - if (TYPE_VIRTUAL_P (basetype) - && !(flags & LOOKUP_NONVIRTUAL) - && wrap_type == NULL_TREE) - need_vtbl = (dtor_label || ctor_label) - ? unneeded : maybe_needed; - - static_call_context = 0; - instance = C_C_D; - instance_ptr = current_class_decl; - result = build_field_call (CLASSTYPE_AS_LIST (current_class_type), - instance_ptr, name, parms, err_name); - - if (result) - return result; - } - else if (TREE_CODE (instance) == RESULT_DECL) - { - static_call_context = 0; - basetype = TREE_TYPE (instance); - if (wrap_type) - { - if (basetype_or_else (basetype, wrap_type)) - basetype = wrap_type; - else - return error_mark_node; - } - /* Should we ever have to make a virtual function reference - from a RESULT_DECL, know that it must be of fixed type - within the scope of this function. */ - else if (!(flags & LOOKUP_NONVIRTUAL) && TYPE_VIRTUAL_P (basetype)) - need_vtbl = maybe_needed; - instance_ptr = build1 (ADDR_EXPR, TYPE_POINTER_TO (basetype), instance); - } - else if (instance == current_exception_object) - { - instance_ptr = build1 (ADDR_EXPR, TYPE_POINTER_TO (current_exception_type), - TREE_OPERAND (current_exception_object, 0)); - mark_addressable (TREE_OPERAND (current_exception_object, 0)); - result = build_field_call (CLASSTYPE_AS_LIST (current_exception_type), - instance_ptr, name, parms, err_name); - if (result) - return result; - error ("exception member `%s' cannot be invoked", err_name); - return error_mark_node; - } - else - { - /* The MAIN_VARIANT of the type that `instance_ptr' winds up being. */ - tree inst_ptr_basetype; - - /* from the file "cplus-typeck.c". */ - extern tree unary_complex_lvalue (); - - static_call_context = (TREE_CODE (instance) == NOP_EXPR - && TREE_OPERAND (instance, 0) == error_mark_node); - - /* the base type of an instance variable is pointer to class */ - basetype = TREE_TYPE (instance); - - if (TREE_CODE (basetype) == REFERENCE_TYPE) - { - basetype = TYPE_MAIN_VARIANT (TREE_TYPE (basetype)); - if (! IS_AGGR_TYPE (basetype)) - goto non_aggr_error; - /* Call to convert not needed because we are remaining - within the same type. */ - instance_ptr = build1 (NOP_EXPR, TYPE_POINTER_TO (basetype), instance); - inst_ptr_basetype = basetype; - } - else - { - if (TREE_CODE (basetype) == POINTER_TYPE) - { - basetype = TREE_TYPE (basetype); - instance_ptr = instance; - } - - if (! IS_AGGR_TYPE (basetype)) - goto non_aggr_error; - - if (! instance_ptr) - { - if ((lvalue_p (instance) - && (instance_ptr = build_unary_op (ADDR_EXPR, instance, 0))) - || (instance_ptr = unary_complex_lvalue (ADDR_EXPR, instance))) - { - if (instance_ptr == error_mark_node) - return error_mark_node; - } - else if (TREE_CODE (instance) == NOP_EXPR - || TREE_CODE (instance) == CONSTRUCTOR) - { - /* A cast is not an lvalue. Initialize a fresh temp - with the value we are casting from, and proceed with - that temporary. We can't cast to a reference type, - so that simplifies the initialization to something - we can manage. */ - tree temp = get_temp_name (TREE_TYPE (instance), 0); - if (IS_AGGR_TYPE (TREE_TYPE (instance))) - expand_aggr_init (temp, instance, 0); - else - { - store_init_value (temp, instance); - expand_decl_init (temp); - } - instance = temp; - instance_ptr = build_unary_op (ADDR_EXPR, instance, 0); - } - else - { - assert (TREE_CODE (instance) == CALL_EXPR); - if (TYPE_NEEDS_CONSTRUCTOR (basetype)) - instance = build_cplus_new (basetype, instance); - else - { - instance = get_temp_name (basetype, 0); - TREE_ADDRESSABLE (instance) = 1; - } - instance_ptr = build_unary_op (ADDR_EXPR, instance, 0); - } - /* @@ Should we call comp_target_types here? */ - inst_ptr_basetype = TREE_TYPE (TREE_TYPE (instance_ptr)); - if (TYPE_MAIN_VARIANT (basetype) == TYPE_MAIN_VARIANT (inst_ptr_basetype)) - basetype = inst_ptr_basetype; - else - instance_ptr = convert (TYPE_POINTER_TO (basetype), instance_ptr); - } - else - inst_ptr_basetype = TREE_TYPE (TREE_TYPE (instance_ptr)); - } - - if (basetype_path == NULL_TREE) - basetype_path = CLASSTYPE_AS_LIST (inst_ptr_basetype); - - result = build_field_call (basetype_path, instance_ptr, name, parms, err_name); - if (result) - return result; - - if (wrap_type) - { - if (basetype_or_else (basetype, wrap_type)) - basetype = wrap_type; - else - return error_mark_node; - } - else if (!(flags & LOOKUP_NONVIRTUAL) && TYPE_VIRTUAL_P (basetype)) - { - if (TREE_VOLATILE (instance_ptr)) - { - /* This action is needed because the instance is needed - for providing the base of the virtual function table. - Without using a SAVE_EXPR, the function we are building - may be called twice, or side effects on the instance - variable (such as a post-increment), may happen twice. */ - instance_ptr = save_expr (instance_ptr); - instance = build_indirect_ref (instance_ptr, 0); - } - else if (TREE_CODE (TREE_TYPE (instance)) == POINTER_TYPE) - { - /* This happens when called for operator new (). */ - instance = build_indirect_ref (instance, 0); - } - - need_vtbl = maybe_needed; - } - } - - if (TYPE_SIZE (basetype) == 0) - { - /* This is worth complaining about, I think. */ - error_with_aggr_type (basetype, "cannot lookup method in incomplete type `%s'"); - return error_mark_node; - } - - /* Are we building a non-virtual wrapper? */ - if (flags & LOOKUP_NONVIRTUAL) - { - if (all_virtual) - sorry ("non-virtual call with -fall-virtual"); - if (wrap) - wrap_type = basetype; - } - - save_basetype = basetype; - - if (all_virtual == 1 - && (! strncmp (IDENTIFIER_POINTER (name), OPERATOR_METHOD_FORMAT, - OPERATOR_METHOD_LENGTH) - || instance_ptr == NULL_TREE - || (TYPE_OVERLOADS_METHOD_CALL_EXPR (basetype) == 0 - && TYPE_NEEDS_WRAPPER (basetype) == 0))) - all_virtual = 0; - - last = NULL_TREE; - for (parmtypes = 0, parm = parms; parm; parm = TREE_CHAIN (parm)) - { - tree t = TREE_TYPE (TREE_VALUE (parm)); - if (TREE_CODE (t) == OFFSET_TYPE) - { - /* Convert OFFSET_TYPE entities to their normal selves. */ - TREE_VALUE (parm) = resolve_offset_ref (TREE_VALUE (parm)); - t = TREE_TYPE (TREE_VALUE (parm)); - } - if (TREE_CODE (t) == ARRAY_TYPE) - { - /* Perform the conversion from ARRAY_TYPE to POINTER_TYPE in place. - This eliminates needless calls to `compute_conversion_costs'. */ - TREE_VALUE (parm) = default_conversion (TREE_VALUE (parm)); - t = TREE_TYPE (TREE_VALUE (parm)); - } - if (t == error_mark_node) - return error_mark_node; - last = build_tree_list (NULL_TREE, t); - parmtypes = chainon (parmtypes, last); - } - - if (instance) - { - constp = TREE_READONLY (instance); - volatilep = TREE_THIS_VOLATILE (instance); - parms = tree_cons (NULL_TREE, instance_ptr, parms); - } - else - { - /* Raw constructors are always in charge. */ - if (TYPE_USES_VIRTUAL_BASECLASSES (basetype) - && ! (flags & LOOKUP_HAS_IN_CHARGE)) - { - flags |= LOOKUP_HAS_IN_CHARGE; - parms = tree_cons (NULL_TREE, integer_one_node, parms); - parmtypes = tree_cons (NULL_TREE, integer_type_node, parmtypes); - } - - if (flag_this_is_variable) - { - constp = 0; - volatilep = 0; - parms = tree_cons (NULL_TREE, build1 (NOP_EXPR, TYPE_POINTER_TO (basetype), integer_zero_node), parms); - } - else - { - constp = 0; - volatilep = 0; - instance_ptr = build_new (NULL_TREE, basetype, void_type_node, 0); - if (instance_ptr == error_mark_node) - return error_mark_node; - instance_ptr = save_expr (instance_ptr); - TREE_CALLS_NEW (instance_ptr) = 1; - instance = build_indirect_ref (instance_ptr, 0); - parms = tree_cons (NULL_TREE, instance_ptr, parms); - } - } - parmtypes = tree_cons (NULL_TREE, - build_pointer_type (build_type_variant (basetype, constp, volatilep)), - parmtypes); - if (last == NULL_TREE) - last = parmtypes; - - /* Look up function name in the structure type definition. */ - - if (wrap) - { - if (wrap > 0) - name_kind = "wrapper"; - else - name_kind = "anti-wrapper"; - baselink = get_wrapper (basetype); - } - else - { - if (TREE_TYPE (name) - && TREE_CODE (TREE_TYPE (name)) == TYPE_DECL - && IS_AGGR_TYPE (TREE_TYPE (TREE_TYPE (name)))) - { - tree tmp = NULL_TREE; - if (TREE_TYPE (name) == TYPE_NAME (basetype)) - tmp = basetype; - else - tmp = get_base_type (TREE_TYPE (TREE_TYPE (name)), basetype, 0); - if (tmp != 0) - { - name_kind = "constructor"; - - if (TYPE_USES_VIRTUAL_BASECLASSES (basetype) - && ! (flags & LOOKUP_HAS_IN_CHARGE)) - { - /* Constructors called for initialization - only are never in charge. */ - tree tmplist; - - flags |= LOOKUP_HAS_IN_CHARGE; - tmplist = tree_cons (NULL_TREE, integer_zero_node, - TREE_CHAIN (parms)); - TREE_CHAIN (parms) = tmplist; - tmplist = tree_cons (NULL_TREE, integer_type_node, TREE_CHAIN (parmtypes)); - TREE_CHAIN (parmtypes) = tmplist; - } - -#ifdef SOS - if (TYPE_DYNAMIC (basetype) && dtbl_inserted == 0) - { - tree parm, parmtype; - dtbl = get_sos_dtable (basetype); - parm = tree_cons (NULL_TREE, dtbl, TREE_CHAIN (parms)); - parmtype = tree_cons (NULL_TREE, build_pointer_type (ptr_type_node), TREE_CHAIN (parmtypes)); - TREE_CHAIN (parms) = parm; - TREE_CHAIN (parmtypes) = parmtype; - dtbl_inserted = -1; - } -#endif - /* constructors are in very specific places. */ -#ifdef SOS - if (dtbl_inserted == -1) - { - TREE_CHAIN (parmtypes) = TREE_CHAIN (TREE_CHAIN (parmtypes)); - TREE_CHAIN (parms) = TREE_CHAIN (TREE_CHAIN (parms)); - dtbl_inserted = 0; - } -#endif - basetype = tmp; - } - else - name_kind = "method"; - } - else name_kind = "method"; - - if (basetype_path == NULL_TREE) - basetype_path = CLASSTYPE_AS_LIST (basetype); - result = lookup_fnfields (basetype_path, name, - (flags & LOOKUP_COMPLAIN)); - if (result == error_mark_node) - return error_mark_node; - } - - /* Now, go look for this method name. We do not find destructors here. - - Putting `void_list_node' on the end of the parmtypes - fakes out `build_decl_overload' into doing the right thing. */ - TREE_CHAIN (last) = void_list_node; - method_name = build_decl_overload (IDENTIFIER_POINTER (name), - parmtypes, - 1 + (name == DECL_NAME (TYPE_NAME (save_basetype)))); - TREE_CHAIN (last) = NULL_TREE; - - for (pass = 0; pass < 2; pass++) - { - struct candidate *candidates; - struct candidate *cp; - int len, best = 2; - - /* This increments every time we go up the type hierarchy. - The idea is to prefer a function of the derived class if possible. */ - int b_or_d; - - baselink = result; - - if (pass > 0) - { - candidates = (struct candidate *) alloca ((ever_seen+1) * sizeof (struct candidate)); - cp = candidates; - len = list_length (parms); - b_or_d = 0; - - /* First see if a global function has a shot at it. */ - if (flags & LOOKUP_GLOBAL) - { - tree friend_parms; - tree parm = TREE_VALUE (parms); - - if (TREE_CODE (TREE_TYPE (parm)) == REFERENCE_TYPE) - friend_parms = parms; - else if (TREE_CODE (TREE_TYPE (parm)) == POINTER_TYPE) - { - parm = build_indirect_ref (parm, "friendifying parms (compiler error)"); - parm = convert (build_reference_type (TREE_TYPE (parm)), parm); - friend_parms = tree_cons (NULL_TREE, parm, TREE_CHAIN (parms)); - } - else - assert (0); - - cp->harshness - = (unsigned short *)alloca ((len+1) * sizeof (short)); - result = build_overload_call (name, friend_parms, 0, cp); - /* If it turns out to be the one we were actually looking for - (it was probably a friend function), the return the - good result. */ - if (TREE_CODE (result) == CALL_EXPR) - return result; - - while (cp->evil == 0) - { - /* non-standard uses: set the field to 0 to indicate - we are using a non-member function. */ - cp->u.field = 0; - if (cp->harshness[len] == 0 - && cp->harshness[len] == 0 - && cp->user == 0 && cp->b_or_d == 0 - && cp->easy < best) - best = cp->easy; - cp += 1; - } - } - } - - while (baselink) - { - /* We have a hit (of sorts). If the parameter list is - "error_mark_node", or some variant thereof, it won't - match any methods. Since we have verified that the is - some method vaguely matching this one (in name at least), - silently return. - - Don't stop for friends, however. */ - tree basetypes = TREE_PURPOSE (baselink); - - function = TREE_VALUE (baselink); - basetype = TREE_VALUE (basetypes); - - /* Cast the instance variable to the approriate type. */ - TREE_VALUE (parmtypes) = TYPE_POINTER_TO (basetype); - - if (DESTRUCTOR_NAME_P (DECL_NAME (function))) - function = TREE_CHAIN (function); - - for (; function; function = TREE_CHAIN (function)) - { -#ifdef GATHER_STATISTICS - n_inner_fields_searched++; -#endif - ever_seen++; - - /* Not looking for friends here. */ - if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE - && ! DECL_STATIC_FUNCTION_P (function)) - continue; - - if (pass == 0 - && DECL_NAME (function) == method_name) - { - if (flags & LOOKUP_PROTECT) - { - visibility = compute_visibility (basetypes, function); - if (visibility == visibility_protected - && flags & LOOKUP_PROTECTED_OK) - visibility = visibility_public; - } - - if ((flags & LOOKUP_PROTECT) == 0 - || visibility == visibility_public) - goto found_and_ok; - else if (visibility == visibility_private) - saw_private = function; - else if (visibility == visibility_protected) - saw_protected = function; - /* If we fail on the exact match, we have - an immediate failure. */ - goto found; - } - if (pass > 0) - { - tree these_parms = parms; - -#ifdef GATHER_STATISTICS - n_inner_fields_searched++; -#endif - cp->harshness - = (unsigned short *)alloca ((len+1) * sizeof (short)); - if (DECL_STATIC_FUNCTION_P (function)) - these_parms = TREE_CHAIN (these_parms); - compute_conversion_costs (function, these_parms, cp, len); - cp->b_or_d += b_or_d; - if (cp->evil == 0) - { - cp->u.field = function; - cp->function = function; - if (flags & LOOKUP_PROTECT) - { - enum visibility_type this_v; - this_v = compute_visibility (basetypes, function); - if (this_v == visibility_protected - && (flags & LOOKUP_PROTECTED_OK)) - this_v = visibility_public; - if (this_v != visibility_public) - { - if (this_v == visibility_private) - saw_private = function; - else - saw_protected = function; - continue; - } - } - - /* No "two-level" conversions. */ - if (flags & LOOKUP_NO_CONVERSION && cp->user != 0) - continue; - - /* If we used default parameters, we must - check to see whether anyone else might - use them also, and report a possible - ambiguity. */ - if (! TYPE_USES_MULTIPLE_INHERITANCE (save_basetype) - && cp->harshness[len] == 0 - && (cp->harshness[0] & 128) == 0 - && cp->user == 0 && cp->b_or_d == 0 - && cp->easy < best) - { - if (! DECL_STATIC_FUNCTION_P (function)) - TREE_VALUE (parms) = cp->arg; - if (best == 2) - goto found_and_maybe_warn; - } - cp++; - } - } - } - /* Now we have run through one link's member functions. - arrange to head-insert this link's links. */ - baselink = next_baselink (baselink); - b_or_d += 1; - } - if (pass == 0) - { - /* No exact match could be found. Now try to find match - using default conversions. */ - if ((flags & LOOKUP_GLOBAL) && IDENTIFIER_GLOBAL_VALUE (name)) - if (TREE_CODE (IDENTIFIER_GLOBAL_VALUE (name)) == FUNCTION_DECL) - ever_seen += 1; - else if (TREE_CODE (IDENTIFIER_GLOBAL_VALUE (name)) == TREE_LIST) - ever_seen += list_length (IDENTIFIER_GLOBAL_VALUE (name)); - - if (ever_seen == 0) - { - if (flags & LOOKUP_GLOBAL) - error ("no global or member function `%s' defined", err_name); - else - error_with_aggr_type (save_basetype, "no member function `%s::%s'", err_name); - return error_mark_node; - } - continue; - } - - if (cp - candidates != 0) - { - /* Rank from worst to best. Then cp will point to best one. - Private fields have their bits flipped. For unsigned - numbers, this should make them look very large. - If the best alternate has a (signed) negative value, - then all we ever saw were private members. */ - if (cp - candidates > 1) - { - cp = ideal_candidate (save_basetype, candidates, - cp - candidates, parms, len); - if (cp == 0) - { - error ("ambiguous type conversion requested for %s `%s'", - name_kind, err_name); - return error_mark_node; - } - } - else if (cp[-1].evil == 2) - { - error ("ambiguous type conversion requested for %s `%s'", - name_kind, err_name); - return error_mark_node; - } - else cp--; - - /* The global function was the best, so use it. */ - if (cp->u.field == 0) - { - /* We must convert the instance pointer into a reference type. - Global overloaded functions can only either take - aggregate objects (which come for free from references) - or reference data types anyway. */ - TREE_VALUE (parms) = copy_node (instance_ptr); - TREE_TYPE (TREE_VALUE (parms)) = build_reference_type (TREE_TYPE (TREE_TYPE (instance_ptr))); - return build_function_call (cp->function, parms); - } - - function = cp->function; - if (DECL_STATIC_FUNCTION_P (function)) - basetype = NULL_TREE; - else - { - basetype = TREE_TYPE (TREE_TYPE (cp->arg)); - TREE_VALUE (parms) = cp->arg; - } - goto found_and_maybe_warn; - } - - if ((flags & ~LOOKUP_GLOBAL) & (LOOKUP_COMPLAIN|LOOKUP_SPECULATIVELY)) - { - char *tag_name, *buf; - - if ((flags & (LOOKUP_SPECULATIVELY|LOOKUP_COMPLAIN)) - == LOOKUP_SPECULATIVELY) - return NULL_TREE; - - if (DECL_STATIC_FUNCTION_P (cp->function)) - parms = TREE_CHAIN (parms); - if (ever_seen) - { - if (((int)saw_protected|(int)saw_private) == 0) - { - if (flags & LOOKUP_SPECULATIVELY) - return NULL_TREE; - if (static_call_context && TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE) - error_with_aggr_type (TREE_TYPE (TREE_TYPE (instance_ptr)), - "object missing in call to `%s::%s'", - err_name); - else - report_type_mismatch (cp, parms, name_kind, err_name); - } - else - { - char buf[80]; - char *msg; - tree seen = saw_private; - - if (saw_private) - if (saw_protected) - msg = "%s %%s (and the like) are private or protected"; - else - msg = "the %s %%s is private"; - else - { - msg = "the %s %%s is protected"; - seen = saw_protected; - } - sprintf (buf, msg, name_kind); - error_with_decl (seen, buf); - error ("within this context"); - } - return error_mark_node; - } - - if ((flags & (LOOKUP_SPECULATIVELY|LOOKUP_COMPLAIN)) - == LOOKUP_COMPLAIN) - { - if (TREE_CODE (save_basetype) == RECORD_TYPE) - tag_name = "structure"; - else - tag_name = "union"; - - if (wrap) - buf = "%s has no appropriate wrapper function defined"; - else - { - buf = (char *)alloca (30 + strlen (err_name)); - strcpy (buf, "%s has no method named `%s'"); - } - - error (buf, tag_name, err_name); - return error_mark_node; - } - return NULL_TREE; - } - continue; - - found_and_maybe_warn: - if (cp->harshness[0] & 128) - { - if (flags & LOOKUP_COMPLAIN) - { - error_with_decl (cp->function, "non-const member function `%s'"); - error ("called for const object at this point in file"); - } - /* Not good enough for a match. */ - else return error_mark_node; - } - goto found_and_ok; - } - /* Silently return error_mark_node. */ - return error_mark_node; - - found: - if (visibility == visibility_private) - { - if (flags & LOOKUP_COMPLAIN) - error (TREE_PRIVATE (function) - ? "%s `%s' is private" - : "%s `%s' is from private base class", - name_kind, - lang_printable_name (function)); - return error_mark_node; - } - else if (visibility == visibility_protected) - { - if (flags & LOOKUP_COMPLAIN) - error (TREE_PROTECTED (function) - ? "%s `%s' is protected" - : "%s `%s' has protected visibility from this point", - name_kind, - lang_printable_name (function)); - return error_mark_node; - } - abort (); - - found_and_ok: - - /* From here on down, BASETYPE is the type that INSTANCE_PTR's - type (if it exists) is a pointer to. */ - basetype = DECL_CONTEXT (function); - fntype = TREE_TYPE (function); - - if (TREE_CODE (fntype) == POINTER_TYPE) - fntype = TREE_TYPE (fntype); - - /* If we are referencing a virtual function from an object - of effectively static type, then there is no need - to go through the virtual function table. */ - if (need_vtbl == maybe_needed) - { - int fixed_type = resolves_to_fixed_type_p (instance); - - if (all_virtual == 1 - && DECL_VINDEX (function) - && may_be_remote (basetype)) - need_vtbl = needed; - else if (DECL_VIRTUAL_P (function)) - need_vtbl = fixed_type ? unneeded : needed; - else - need_vtbl = not_needed; - - if (fixed_type && DECL_ABSTRACT_VIRTUAL_P (function)) - { - error_with_decl (function, "invalid call to abstract function `%s'"); - return error_mark_node; - } - } - - if (TREE_CODE (fntype) == METHOD_TYPE && static_call_context) - { - /* Let's be nice to the user for now, and give reasonable - default behavior. */ - instance_ptr = current_class_decl; - if (instance_ptr) - { - if (basetype != current_class_type) - { - basetype = get_base_type (basetype, current_class_type, 1); - if (basetype == 0) - { - error_not_base_type (DECL_CONTEXT (function), current_class_type); - return error_mark_node; - } - else if (basetype == error_mark_node) - return error_mark_node; - } - } - else - { - error_with_aggr_type (basetype, "cannot call member function `%s::%s' without object", - err_name); - return error_mark_node; - } - } - - value_type = TREE_TYPE (fntype) ? TREE_TYPE (fntype) : void_type_node; - - if (TYPE_SIZE (value_type) == 0) - { - if (flags & LOOKUP_COMPLAIN) - incomplete_type_error (0, value_type); - return error_mark_node; - } - - /* We do not pass FUNCTION into `actualparameterlist', because by - now everything should be ok. If not, then we have a serious error. */ - if (DECL_STATIC_FUNCTION_P (function)) - parms = actualparameterlist (NULL_TREE, TYPE_ARG_TYPES (fntype), - TREE_CHAIN (parms), NULL_TREE, LOOKUP_NORMAL); - else if (need_vtbl == unneeded) - { - int sub_flags = DECL_CONSTRUCTOR_P (function) ? flags : LOOKUP_NORMAL; - basetype = TREE_TYPE (instance); - if (DECL_CONTEXT (function) != TYPE_MAIN_VARIANT (basetype) - && (TYPE_USES_MULTIPLE_INHERITANCE (basetype) - || TYPE_USES_VIRTUAL_BASECLASSES (basetype))) - { - basetype = DECL_CONTEXT (function); - instance_ptr = convert_pointer_to (basetype, instance_ptr); - instance = build_indirect_ref (instance_ptr, 0); - } - parms = tree_cons (NULL_TREE, instance_ptr, - actualparameterlist (NULL_TREE, TREE_CHAIN (TYPE_ARG_TYPES (fntype)), TREE_CHAIN (parms), NULL_TREE, sub_flags)); - } - else - { - if ((flags & LOOKUP_NONVIRTUAL) == 0) - basetype = DECL_VCONTEXT (function); - - /* First parm could be integer_zerop with casts like - ((Object*)0)->Object::IsA() */ - if (!integer_zerop (TREE_VALUE (parms))) - { - instance_ptr = convert_pointer_to (build_type_variant (basetype, constp, volatilep), - TREE_VALUE (parms)); - if (TREE_CODE (instance_ptr) == COND_EXPR) - { - instance_ptr = save_expr (instance_ptr); - instance = build_indirect_ref (instance_ptr); - } - else if (TREE_CODE (instance_ptr) == NOP_EXPR - && TREE_CODE (TREE_OPERAND (instance_ptr, 0)) == ADDR_EXPR - && TREE_OPERAND (TREE_OPERAND (instance_ptr, 0), 0) == instance) - ; - else if (instance == NULL_TREE - || TREE_CODE (instance) != INDIRECT_REF - || TREE_OPERAND (instance, 0) != instance_ptr) - instance = build_indirect_ref (instance_ptr); - } - parms = tree_cons (NULL_TREE, instance_ptr, - actualparameterlist (NULL_TREE, TREE_CHAIN (TYPE_ARG_TYPES (fntype)), TREE_CHAIN (parms), NULL_TREE, LOOKUP_NORMAL)); - } - - /* See if there is a wrapper for this thing. */ - if (wrap < 0 - || static_call_context - || name == wrapper_name - || name == DECL_NAME (TYPE_NAME (basetype))) - ; - else if (wrap > 0 || TYPE_NEEDS_WRAPPER (basetype)) - { - flags &= ~LOOKUP_PROTECT; - if (wrap == 0) - { - wrap = TYPE_NEEDS_WRAPPER (basetype); - /* If no wrapper specified, wrapper may be virtual. */ - flags &= ~LOOKUP_NONVIRTUAL; - } - - if (wrap) - { - tree wrapped_result, unwrapped_result; - register int bytecount = get_arglist_len_in_bytes (parms); - - if (!all_virtual && TREE_CODE (function) == FUNCTION_DECL) - parm = build_unary_op (ADDR_EXPR, function, 0); - else - { - fntype = build_cplus_method_type (basetype, TREE_TYPE (fntype), TYPE_ARG_TYPES (fntype)); - parm = build1 (NOP_EXPR, build_pointer_type (fntype), DECL_VINDEX (function)); - } - - if (TYPE_HAS_WRAPPER_PRED (basetype)) - { - unwrapped_result = build_nt (CALL_EXPR, default_conversion (function), parms, NULL_TREE); - - assert (TREE_OPERAND (unwrapped_result, 1) != error_mark_node); - - TREE_TYPE (unwrapped_result) = value_type; - TREE_VOLATILE (unwrapped_result) = 1; - TREE_RAISES (unwrapped_result) = !! TYPE_RAISES_EXCEPTIONS (fntype); - } - - /* If this pointer walked as a result of multiple inheritance, - keep its displaced value. */ - parms = tree_cons (NULL_TREE, build_int_2 (bytecount, 0), - tree_cons (NULL_TREE, parm, TREE_CHAIN (parms))); - - wrapped_result = get_wrapper (basetype); - assert (wrapped_result != NULL_TREE); - assert (wrapped_result != error_mark_node); - - /* @@ Should BASETYPE_PATH get TREE_PURPOSE (wrapped_result) here? */ - wrapped_result - = build_method_call (instance, - DECL_ORIGINAL_NAME (TREE_VALUE (wrapped_result)), - parms, basetype_path, flags); -#if 0 - /* Do this if we want the result of operator->() to inherit - the type of the function it is subbing for. */ - if (wrapped_result != error_mark_node) - TREE_TYPE (wrapped_result) = value_type; -#endif - - if (TYPE_HAS_WRAPPER_PRED (basetype)) - { - result = build_conditional_expr - (build_method_call (instance, wrapper_pred_name, build_tree_list (NULL_TREE, parm), basetype_path, LOOKUP_NORMAL), - wrapped_result, - unwrapped_result); - - } - else - { - result = wrapped_result; - } - - TREE_VOLATILE (result) = 1; - return result; - } - } - /* Constructors do not overload method calls. */ - else if (TYPE_OVERLOADS_METHOD_CALL_EXPR (basetype) - && name != DECL_NAME (TYPE_NAME (basetype)) - && (TREE_CODE (function) != FUNCTION_DECL - || strncmp (IDENTIFIER_POINTER (DECL_NAME (function)), - OPERATOR_METHOD_FORMAT, - OPERATOR_METHOD_LENGTH)) -#if 0 - && (may_be_remote (basetype) - || (C_C_D ? TREE_TYPE (instance) != current_class_type : 1)) -#else - /* This change by Larry Ketcham. */ - && (may_be_remote (basetype) || instance != C_C_D) -#endif - ) - { -#ifdef ESKIT - register int bytecount = 0; -#else - register int bytecount = get_arglist_len_in_bytes (parms); -#endif - tree fn_as_int; - - parms = tree_cons (NULL_TREE, build_int_2 (bytecount, 0), - TREE_CHAIN (parms)); - - if (!all_virtual && TREE_CODE (function) == FUNCTION_DECL) - fn_as_int = build_unary_op (ADDR_EXPR, function, 0); - else - fn_as_int = convert (TREE_TYPE (default_conversion (function)), DECL_VINDEX (function)); - if (all_virtual == 1) - fn_as_int = convert (integer_type_node, fn_as_int); - - result = build_opfncall (METHOD_CALL_EXPR, LOOKUP_NORMAL, instance, fn_as_int, parms); - - if (result == NULL_TREE) - { - compiler_error ("could not overload `operator->()(...)'"); - return error_mark_node; - } - else if (result == error_mark_node) - return error_mark_node; - -#if 0 - /* Do this if we want the result of operator->() to inherit - the type of the function it is subbing for. */ - TREE_TYPE (result) = value_type; -#endif - -#ifdef ESKIT - { - int used, size; - - /* Count the number of bytes of arguements to operator->(), - not to the method itself. In the tally, don't count bytes - for pointer to member function or for the bytecount. */ - parms = TREE_OPERAND (result, 1); - bytecount = get_arglist_len_in_bytes (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (parms)))); - used = size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (TREE_VALUE (parms)))); -#ifdef PUSH_ROUNDING - size = PUSH_ROUNDING (size); -#endif - used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1) - / (PARM_BOUNDARY / BITS_PER_UNIT)) - * (PARM_BOUNDARY / BITS_PER_UNIT)); - bytecount += used; - TREE_CHAIN (TREE_CHAIN (parms)) - = tree_cons (NULL_TREE, build_int_2 (bytecount, 0), - TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (parms)))); - } -#endif - - return result; - } - - if (need_vtbl == needed) - { - function = build_vfn_ref (&TREE_VALUE (parms), instance, DECL_VINDEX (function)); - TREE_TYPE (function) = build_pointer_type (fntype); - } -#ifdef SOS - else if (basetype && TYPE_DYNAMIC (basetype)) - { - function = build_array_ref (dtbl, DECL_DINDEX (function)); - TREE_TYPE (function) = build_pointer_type (fntype); - } -#endif - - if (TREE_INLINE (function) && TREE_CODE (function) == FUNCTION_DECL) - function = build1 (ADDR_EXPR, build_pointer_type (fntype), function); - else function = default_conversion (function); - - result = - build_nt (CALL_EXPR, function, parms, NULL_TREE); - - TREE_TYPE (result) = value_type; - TREE_VOLATILE (result) = 1; - TREE_RAISES (result) - = TYPE_RAISES_EXCEPTIONS (fntype) || (parms && TREE_RAISES (parms)); - return result; -} - -/* Similar to `build_method_call', but for overloaded non-member functions. - The name of this function comes through NAME. The name depends - on PARMS. - - Note that this function must handle simple `C' promotions, - as well as variable numbers of arguments (...), and - default arguments to boot. - - If the overloading is successful, we return a treenode which - contains the call to the function. - - If overloading produces candidates which are probabe, but not definite, - we hold these candidates. If FINAL_CP is non-zero, then we are free - to assume that final_cp points to enough storage for all candidates that - this function might generate. The `harshness' array is preallocated for - the first candidate, but not for subsequent ones. - - Note that the DECL_RTL of FUNCTION must be made to agree with this - function's new name. */ - -tree -build_overload_call (fnname, parms, complain, final_cp) - tree fnname, parms; - int complain; - struct candidate *final_cp; -{ - /* must check for overloading here */ - tree overload_name, functions, function, parm; - tree parmtypes = NULL_TREE, last = NULL_TREE; - register tree outer; - int length; - int parmlength = list_length (parms); - - struct candidate *candidates, *cp; - int rank_for_overload (); - - if (final_cp) - { - final_cp[0].evil = 0; - final_cp[0].user = 0; - final_cp[0].b_or_d = 0; - final_cp[0].easy = 0; - final_cp[0].function = 0; - /* end marker. */ - final_cp[1].evil = 1; - } - - for (parm = parms; parm; parm = TREE_CHAIN (parm)) - { - register tree t = TREE_TYPE (TREE_VALUE (parm)); - - if (t == error_mark_node) - return error_mark_node; - if (TREE_CODE (t) == ARRAY_TYPE || TREE_CODE (t) == OFFSET_TYPE) - { - /* Perform the conversion from ARRAY_TYPE to POINTER_TYPE in place. - Also convert OFFSET_TYPE entities to their normal selves. - This eliminates needless calls to `compute_conversion_costs'. */ - TREE_VALUE (parm) = default_conversion (TREE_VALUE (parm)); - t = TREE_TYPE (TREE_VALUE (parm)); - } - last = build_tree_list (NULL_TREE, t); - parmtypes = chainon (parmtypes, last); - } - if (last) - TREE_CHAIN (last) = void_list_node; - else - parmtypes = void_list_node; - overload_name = build_decl_overload (IDENTIFIER_POINTER (fnname), parmtypes, 0); - - /* Now check to see whether or not we can win. - Note that if we are called from `build_method_call', - then we cannot have a mis-match, because we would have - already found such a winning case. */ - - if (IDENTIFIER_GLOBAL_VALUE (overload_name)) - if (TREE_CODE (IDENTIFIER_GLOBAL_VALUE (overload_name)) != TREE_LIST) - return build_function_call (DECL_MAIN_VARIANT (IDENTIFIER_GLOBAL_VALUE (overload_name)), parms); - - functions = IDENTIFIER_GLOBAL_VALUE (fnname); - - if (functions == NULL_TREE) - { - if (complain) - error ("only member functions apply"); - if (final_cp) - final_cp->evil = 1; - return error_mark_node; - } - - if (TREE_CODE (functions) == FUNCTION_DECL) - { - functions = DECL_MAIN_VARIANT (functions); - if (final_cp) - { - /* We are just curious whether this is a viable alternative or not. */ - compute_conversion_costs (functions, parms, final_cp, parmlength); - return functions; - } - else - return build_function_call (functions, parms); - } - - if (TREE_VALUE (functions) == NULL_TREE) - { - if (complain) - error ("function `%s' declared overloaded, but no instances of that function declared", - IDENTIFIER_POINTER (TREE_PURPOSE (functions))); - return error_mark_node; - } - - if (TREE_CODE (TREE_VALUE (functions)) == TREE_LIST) - { - register tree outer; - length = 0; - - /* The list-of-lists should only occur for class things. */ - assert (functions == IDENTIFIER_CLASS_VALUE (fnname)); - - for (outer = functions; outer; outer = TREE_CHAIN (outer)) - { - /* member functions. */ - length += list_length (TREE_VALUE (TREE_VALUE (outer))); - /* friend functions. */ - length += list_length (TREE_TYPE (TREE_VALUE (outer))); - } - } - else - { - length = list_length (functions); - } - - if (final_cp) - candidates = final_cp; - else - candidates = (struct candidate *)alloca ((length+1) * sizeof (struct candidate)); - - cp = candidates; - - assert (TREE_CODE (TREE_VALUE (functions)) != TREE_LIST); - /* OUTER is the list of FUNCTION_DECLS, in a TREE_LIST. */ - - for (outer = functions; outer; outer = TREE_CHAIN (outer)) - { - function = TREE_VALUE (outer); - if (TREE_CODE (function) != FUNCTION_DECL) - { - if (TREE_CODE (function) == CONST_DECL) - error_with_decl (function, "enumeral value `%s' conflicts with function of same name"); - else if (TREE_CODE (function) == VAR_DECL) - if (TREE_STATIC (function)) - error_with_decl (function, "variable `%s' conflicts with function of same name"); - else - error_with_decl (function, "constant field `%s' conflicts with function of same name"); - else if (TREE_CODE (function) == TYPE_DECL) - continue; - else abort (); - error ("at this point in file"); - continue; - } - function = DECL_MAIN_VARIANT (function); - /* Can't use alloca here, since result might be - passed to calling function. */ - cp->harshness - = (unsigned short *)oballoc ((parmlength+1) * sizeof (short)); - compute_conversion_costs (function, parms, cp, parmlength); - if (cp[0].evil == 0) - { - cp[1].evil = 1; - if (final_cp - && cp[0].user == 0 && cp[0].b_or_d == 0 - && cp[0].easy <= 1) - { - final_cp[0].easy = cp[0].easy; - return function; - } - cp++; - } - } - - if (cp - candidates) - { - tree rval = error_mark_node; - - /* Leave marker. */ - cp[0].evil = 1; - if (cp - candidates > 1) - { - struct candidate *best_cp - = ideal_candidate (NULL_TREE, candidates, - cp - candidates, parms, parmlength); - if (best_cp == 0) - { - if (complain) - error ("call of overloaded `%s' is ambiguous", IDENTIFIER_POINTER (fnname)); - return error_mark_node; - } - else - rval = best_cp->function; - } - else - { - cp -= 1; - if (cp->evil > 1) - { - if (complain) - error ("type conversion ambiguous"); - } - else - rval = cp->function; - } - - if (final_cp) - return rval; - - return build_function_call (rval, parms); - } - else if (complain) - { - tree name; - char *err_name; - /* Initialize name for error reporting. */ - if (TREE_CODE (functions) == TREE_LIST) - name = TREE_PURPOSE (functions); - else - name = DECL_ORIGINAL_NAME (functions); - - if (OPERATOR_NAME_P (name)) - { - char *opname = operator_name_string (name); - err_name = (char *)alloca (strlen (opname) + 12); - sprintf (err_name, "operator %s", opname); - } - else - err_name = IDENTIFIER_POINTER (name); - - report_type_mismatch (cp, parms, "function", err_name); - } - return error_mark_node; -} - -void -init_class_processing () -{ - current_class_stacksize = 10; - current_class_base = (tree *)xmalloc(current_class_stacksize * sizeof (tree)); - current_class_stack = current_class_base; - - current_lang_stacksize = 10; - current_lang_base = (tree *)xmalloc(current_lang_stacksize * sizeof (tree)); - current_lang_stack = current_lang_base; - - delta_name = get_identifier (VTABLE_DELTA_NAME); - pfn_name = get_identifier (VTABLE_PFN_NAME); - - /* Keep these values lying around. */ - minus_one_node = build_int_2 (-1, 0); - the_null_vtable_entry = build_vtable_entry (integer_zero_node, integer_zero_node); - base_layout_decl = build_lang_field_decl (FIELD_DECL, NULL_TREE, error_mark_node); - TREE_TYPE (base_layout_decl) = make_node (RECORD_TYPE); - - obstack_init (&class_obstack); -} - -/* Set current scope to NAME. CODE tells us if this is a - STRUCT, UNION, or ENUM environment. - - NAME may end up being NULL_TREE if this is an anonymous or - late-bound struct (as in "struct { ... } foo;") */ - -/* Here's a subroutine we need because C lacks lambdas. */ -void -unuse_fields (type) - tree type; -{ - tree fields; - - for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields)) - { - if (TREE_CODE (fields) != FIELD_DECL) - continue; - - TREE_USED (fields) = 0; - if (DECL_ANON_UNION_ELEM (fields)) - unuse_fields (TREE_TYPE (fields)); - } -} - -/* Set global variables CURRENT_CLASS_NAME and CURRENT_CLASS_TYPE to - appropriate values, found by looking up the type definition of - NAME (as a CODE). - - If MODIFY is 1, we set IDENTIFIER_CLASS_VALUE's of names - which can be seen locally to the class. They are shadowed by - any subsequent local declaration (including parameter names). - - If MODIFY is 2, we set IDENTIFIER_CLASS_VALUE's of names - which have static meaning (i.e., static members, static - member functions, enum declarations, etc). - - So that we may avoid calls to lookup_name, we cache the TYPE_DECL - in the TREE_TYPE field of the name. - - For multiple inheritance, we perform a two-pass depth-first search - of the type lattice. The first pass performs a pre-order search, - marking types after the type has had its fields installed in - the appropriate IDENTIFIER_CLASS_VALUE slot. The second pass merely - unmarks the marked types. If a field or member function name - appears in an ambiguous way, the IDENTIFIER_CLASS_VALUE of - that name becomes `error_mark_node'. */ - -void -pushclass (type, modify) - tree type; - int modify; -{ - push_memoized_context (type, modify); - - *current_class_stack++ = current_class_name; - *current_class_stack++ = current_class_type; - if (current_class_stack >= current_class_base + current_class_stacksize) - { - current_class_base = - (tree *)xrealloc (current_class_base, - sizeof (tree) * (current_class_stacksize + 10)); - current_class_stack = current_class_base + current_class_stacksize; - current_class_stacksize += 10; - } - - type = TYPE_MAIN_VARIANT (type); - current_class_name = TYPE_NAME (type); - if (TREE_CODE (current_class_name) == TYPE_DECL) - current_class_name = DECL_NAME (current_class_name); - current_class_type = type; - - if (type != prev_class_type && prev_class_type != NULL_TREE - && current_class_stack == current_class_base + 2) - { - popclass (-1); - prev_class_type = 0; - } - - if (modify) - { - tree tags; - - if (type != prev_class_type) - { - build_mi_matrix (type); - push_class_decls (type); - free_mi_matrix (); - prev_class_type = type; - } - else - unuse_fields (type); - - tags = CLASSTYPE_TAGS (type); - while (tags) - { - TREE_NONLOCAL (TREE_VALUE (tags)) = 1; - pushtag (TREE_PURPOSE (tags), TREE_VALUE (tags)); - if (IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (tags)) == NULL_TREE - && TREE_CODE (TYPE_NAME (TREE_VALUE (tags))) == TYPE_DECL) - IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (tags)) - = TYPE_NAME (TREE_VALUE (tags)); - tags = TREE_CHAIN (tags); - } - } - else - pushlevel_class (); - - if (flag_cadillac) - cadillac_push_class (type); -} - -/* Get out of the current class scope. If we were in a class scope - previously, that is the one popped to. The flag MODIFY tells - whether the current scope declarations needs to be modified - as a result of popping to the new scope. */ -void -popclass (modify) - int modify; -{ - if (flag_cadillac) - cadillac_pop_class (); - - if (modify < 0) - { - /* Back this old class out completely. */ - tree tags = CLASSTYPE_TAGS (prev_class_type); - - pop_class_decls (prev_class_type); - while (tags) - { - TREE_NONLOCAL (TREE_VALUE (tags)) = 0; - IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (tags)) = NULL_TREE; - tags = TREE_CHAIN (tags); - } - return; - } - if (modify) - { - /* Just remove from this class what didn't make - it into IDENTIFIER_CLASS_VALUE. */ - tree tags = CLASSTYPE_TAGS (current_class_type); - - while (tags) - { - TREE_NONLOCAL (TREE_VALUE (tags)) = 0; - IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (tags)) = NULL_TREE; - tags = TREE_CHAIN (tags); - } - } - else - poplevel_class (); - - current_class_type = *--current_class_stack; - current_class_name = *--current_class_stack; - - if (current_class_type) - { - if (CLASSTYPE_VTBL_PTR (current_class_type)) - { - current_vtable_decl = lookup_name (DECL_NAME (CLASSTYPE_VTBL_PTR (current_class_type))); - if (current_vtable_decl) - current_vtable_decl = build_indirect_ref (current_vtable_decl, 0); - } - current_class_decl = lookup_name (get_identifier (THIS_NAME)); - if (current_class_decl) - { - if (TREE_CODE (TREE_TYPE (current_class_decl)) == POINTER_TYPE) - { - /* Can't call build_indirect_ref here, because it has special - logic to return C_C_D given this argument. */ - C_C_D = build1 (INDIRECT_REF, current_class_type, current_class_decl); - TREE_READONLY (C_C_D) = TREE_READONLY (TREE_TYPE (TREE_TYPE (current_class_decl))); - TREE_VOLATILE (C_C_D) = TREE_VOLATILE (TREE_TYPE (TREE_TYPE (current_class_decl))); - } - else - C_C_D = current_class_decl; - } - else C_C_D = NULL_TREE; - } - else - { - current_class_decl = NULL_TREE; - current_vtable_decl = NULL_TREE; - C_C_D = NULL_TREE; - } - - pop_memoized_context (modify); -} - -/* Set global variables CURRENT_LANG_NAME to appropriate value - so that behavior of name-mangline machinery is correct. */ - -void -push_lang_context (name) - tree name; -{ - *current_lang_stack++ = current_lang_name; - if (current_lang_stack >= current_lang_base + current_lang_stacksize) - { - current_lang_base = - (tree *)xrealloc (current_lang_base, - sizeof (tree) * (current_lang_stacksize + 10)); - current_lang_stack = current_lang_base + current_lang_stacksize; - current_lang_stacksize += 10; - } - - if (name == lang_name_cplusplus) - { - strict_prototype = strict_prototypes_lang_cplusplus; - current_lang_name = name; - } - else if (name == lang_name_c) - { - strict_prototype = strict_prototypes_lang_c; - current_lang_name = name; - } - else - error ("language string `\"%s\"' not recognized", IDENTIFIER_POINTER (name)); - - if (flag_cadillac) - cadillac_push_lang (name); -} - -/* Get out of the current language scope. */ -void -pop_lang_context () -{ - if (flag_cadillac) - cadillac_pop_lang (); - - current_lang_name = *--current_lang_stack; - if (current_lang_name == lang_name_cplusplus) - strict_prototype = strict_prototypes_lang_cplusplus; - else if (current_lang_name == lang_name_c) - strict_prototype = strict_prototypes_lang_c; -} - -int -root_lang_context_p () -{ - return current_lang_stack == current_lang_base; -} - -/* Type instantiation routines. */ - -/* This function will instantiate the type of the expression given - in RHS to match the type of LHSTYPE. If LHSTYPE is NULL_TREE, - or other errors exist, the TREE_TYPE of RHS will be ERROR_MARK_NODE. - - This function is used in build_modify_expr, actualparameterlist, - build_c_cast, and compute_conversion_costs. */ -tree -instantiate_type (lhstype, rhs, complain) - tree lhstype, rhs; - int complain; -{ - if (TREE_CODE (rhs) == OP_IDENTIFIER) - return build_instantiated_decl (lhstype, rhs); - - if (TREE_CODE (lhstype) == UNKNOWN_TYPE) - { - if (complain) - error ("not enough type information"); - return error_mark_node; - } - - if (TREE_TYPE (rhs) != NULL_TREE && ! (type_unknown_p (rhs))) - return rhs; - - /* This should really only be used when attempting to distinguish - what sort of a pointer to function we have. For now, any - arithmethic operation which is not supported on pointers - is rejected as an error. */ - - switch (TREE_CODE (rhs)) - { - case TYPE_EXPR: - case CONVERT_EXPR: - case SAVE_EXPR: - case CONSTRUCTOR: - case BUFFER_REF: - assert (0); - return error_mark_node; - - case INDIRECT_REF: - case ARRAY_REF: - TREE_TYPE (rhs) = lhstype; - lhstype = build_pointer_type (lhstype); - TREE_OPERAND (rhs, 0) - = instantiate_type (lhstype, TREE_OPERAND (rhs, 0), complain); - if (TREE_OPERAND (rhs, 0) == error_mark_node) - return error_mark_node; - - return rhs; - - case NOP_EXPR: - rhs = copy_node (TREE_OPERAND (rhs, 0)); - TREE_TYPE (rhs) = unknown_type_node; - return instantiate_type (lhstype, rhs, complain); - - case COMPONENT_REF: - { - tree field = TREE_OPERAND (rhs, 1); - if (TREE_CODE (field) == TREE_LIST) - { - tree function = instantiate_type (lhstype, field, complain); - if (function == error_mark_node) - return error_mark_node; - assert (TREE_CODE (function) == FUNCTION_DECL); - if (DECL_VIRTUAL_P (function)) - { - tree base = TREE_OPERAND (rhs, 0); - tree base_ptr = build_unary_op (ADDR_EXPR, base, 0); - if (base_ptr == error_mark_node) - return error_mark_node; - base_ptr = convert_pointer_to (DECL_VCONTEXT (function), base_ptr); - if (base_ptr == error_mark_node) - return error_mark_node; - return build_vfn_ref (&base_ptr, base, DECL_VINDEX (function)); - } - return function; - } - - assert (TREE_CODE (field) == FIELD_DECL); - assert (!(TREE_CODE (TREE_TYPE (field)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (field)) == METHOD_TYPE)); - - TREE_TYPE (rhs) = lhstype; - /* First look for an exact match */ - - while (field && TREE_TYPE (field) != lhstype) - field = TREE_CHAIN (field); - if (field) - { - TREE_OPERAND (rhs, 1) = field; - return rhs; - } - - /* No exact match found, look for a compatible function. */ - field = TREE_OPERAND (rhs, 1); - while (field && ! comptypes (lhstype, TREE_TYPE (field), 0)) - field = TREE_CHAIN (field); - if (field) - { - TREE_OPERAND (rhs, 1) = field; - field = TREE_CHAIN (field); - while (field && ! comptypes (lhstype, TREE_TYPE (field), 0)) - field = TREE_CHAIN (field); - if (field) - { - if (complain) - error ("ambiguous overload for COMPONENT_REF requested"); - return error_mark_node; - } - } - else - { - if (complain) - error ("no appropriate overload exists for COMPONENT_REF"); - return error_mark_node; - } - return rhs; - } - - case TREE_LIST: - { - tree elem, baselink, name; - int globals = overloaded_globals_p (rhs); - - /* If there's only one function we know about, return that. */ - if (globals > 0 && TREE_CHAIN (rhs) == NULL_TREE) - return TREE_VALUE (rhs); - - /* First look for an exact match. Search either overloaded - functions or member functions. May have to undo what - `default_conversion' or `datatype' might do to lhstype. */ - - if (TREE_CODE (lhstype) == POINTER_TYPE) - if (TREE_CODE (TREE_TYPE (lhstype)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (lhstype)) == METHOD_TYPE) - lhstype = TREE_TYPE (lhstype); - else - { - if (complain) - error ("invalid type combination for overload"); - return error_mark_node; - } - - if (TREE_CODE (lhstype) != FUNCTION_TYPE && globals > 0) - { - if (complain) - error ("cannot resolve overloaded function `%s' based on non-function type", - IDENTIFIER_POINTER (TREE_PURPOSE (rhs))); - return error_mark_node; - } - - if (globals > 0) - { - assert (TREE_CODE (TREE_VALUE (rhs)) == FUNCTION_DECL); - elem = rhs; - while (elem) - if (TREE_TYPE (TREE_VALUE (elem)) != lhstype) - elem = TREE_CHAIN (elem); - else - return TREE_VALUE (elem); - /* No exact match found, look for a compatible function. */ - elem = rhs; - while (elem && ! comp_target_types (lhstype, TREE_TYPE (TREE_VALUE (elem)), 1)) - elem = TREE_CHAIN (elem); - if (elem) - { - tree save_elem = TREE_VALUE (elem); - elem = TREE_CHAIN (elem); - while (elem && ! comp_target_types (lhstype, TREE_TYPE (TREE_VALUE (elem)), 0)) - elem = TREE_CHAIN (elem); - if (elem) - { - if (complain) - error ("ambiguous overload for overloaded function requested"); - return error_mark_node; - } - return save_elem; - } - if (complain) - { - if (TREE_CHAIN (rhs)) - error ("no appropriate overload for overloaded function `%s' exists", - IDENTIFIER_POINTER (TREE_PURPOSE (rhs))); - else - error ("function `%s' has inappropriate type signature", - IDENTIFIER_POINTER (TREE_PURPOSE (rhs))); - } - return error_mark_node; - } - - if (TREE_NONLOCAL (rhs)) - { - /* Got to get it as a baselink. */ - rhs = lookup_fnfields (CLASSTYPE_AS_LIST (current_class_type), - TREE_PURPOSE (rhs), 0); - } - else - { - assert (TREE_CHAIN (rhs) == NULL_TREE); - if (TREE_CODE (TREE_VALUE (rhs)) == TREE_LIST) - rhs = TREE_VALUE (rhs); - assert (TREE_CODE (TREE_VALUE (rhs)) == FUNCTION_DECL); - } - - for (baselink = rhs; baselink; - baselink = next_baselink (baselink)) - { - elem = TREE_VALUE (baselink); - while (elem) - if (TREE_TYPE (elem) != lhstype) - elem = TREE_CHAIN (elem); - else - return elem; - } - - /* No exact match found, look for a compatible method. */ - for (baselink = rhs; baselink; - baselink = next_baselink (baselink)) - { - elem = TREE_VALUE (baselink); - while (elem && ! comp_target_types (lhstype, TREE_TYPE (elem), 1)) - elem = TREE_CHAIN (elem); - if (elem) - { - tree save_elem = elem; - elem = TREE_CHAIN (elem); - while (elem && ! comp_target_types (lhstype, TREE_TYPE (elem), 0)) - elem = TREE_CHAIN (elem); - if (elem) - { - if (complain) - error ("ambiguous overload for overloaded method requested"); - return error_mark_node; - } - return save_elem; - } - name = DECL_ORIGINAL_NAME (TREE_VALUE (rhs)); - if (TREE_CODE (lhstype) == FUNCTION_TYPE && globals < 0) - { - /* Try to instantiate from non-member functions. */ - rhs = IDENTIFIER_GLOBAL_VALUE (name); - if (rhs && TREE_CODE (rhs) == TREE_LIST) - { - /* This code seems to be missing a `return'. */ - abort (); - instantiate_type (lhstype, rhs, complain); - } - } - - if (complain) - error ("no static member functions named `%s'", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - } - - case CALL_EXPR: - /* This is too hard for now. */ - assert (0); - return error_mark_node; - - case PLUS_EXPR: - case MINUS_EXPR: - case COMPOUND_EXPR: - TREE_OPERAND (rhs, 0) = instantiate_type (lhstype, TREE_OPERAND (rhs, 0), complain); - if (TREE_OPERAND (rhs, 0) == error_mark_node) - return error_mark_node; - TREE_OPERAND (rhs, 1) = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), complain); - if (TREE_OPERAND (rhs, 1) == error_mark_node) - return error_mark_node; - - TREE_TYPE (rhs) = lhstype; - return rhs; - - case MULT_EXPR: - case TRUNC_DIV_EXPR: - case FLOOR_DIV_EXPR: - case CEIL_DIV_EXPR: - case ROUND_DIV_EXPR: - case RDIV_EXPR: - case TRUNC_MOD_EXPR: - case FLOOR_MOD_EXPR: - case CEIL_MOD_EXPR: - case ROUND_MOD_EXPR: - case FIX_ROUND_EXPR: - case FIX_FLOOR_EXPR: - case FIX_CEIL_EXPR: - case FIX_TRUNC_EXPR: - case FLOAT_EXPR: - case NEGATE_EXPR: - case ABS_EXPR: - case MAX_EXPR: - case MIN_EXPR: - case FFS_EXPR: - - case BIT_AND_EXPR: - case BIT_IOR_EXPR: - case BIT_XOR_EXPR: - case LSHIFT_EXPR: - case RSHIFT_EXPR: - case LROTATE_EXPR: - case RROTATE_EXPR: - - case PREINCREMENT_EXPR: - case PREDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - if (complain) - error ("illegal operation on uninstantiated type"); - return error_mark_node; - - case TRUTH_AND_EXPR: - case TRUTH_OR_EXPR: - case LT_EXPR: - case LE_EXPR: - case GT_EXPR: - case GE_EXPR: - case EQ_EXPR: - case NE_EXPR: - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - case TRUTH_NOT_EXPR: - if (complain) - error ("not enough type information"); - return error_mark_node; - - case COND_EXPR: - if (type_unknown_p (TREE_OPERAND (rhs, 0))) - { - if (complain) - error ("not enough type information"); - return error_mark_node; - } - TREE_OPERAND (rhs, 1) = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), complain); - if (TREE_OPERAND (rhs, 1) == error_mark_node) - return error_mark_node; - TREE_OPERAND (rhs, 2) = instantiate_type (lhstype, TREE_OPERAND (rhs, 2), complain); - if (TREE_OPERAND (rhs, 2) == error_mark_node) - return error_mark_node; - - TREE_TYPE (rhs) = lhstype; - return rhs; - - case MODIFY_EXPR: - TREE_OPERAND (rhs, 1) = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), complain); - if (TREE_OPERAND (rhs, 1) == error_mark_node) - return error_mark_node; - - TREE_TYPE (rhs) = lhstype; - return rhs; - - case ADDR_EXPR: - if (TREE_CODE (lhstype) != POINTER_TYPE) - { - if (complain) - error ("type for resolving address of overloaded function must be pointer type"); - return error_mark_node; - } - TREE_TYPE (rhs) = lhstype; - lhstype = TREE_TYPE (lhstype); - TREE_OPERAND (rhs, 0) = instantiate_type (lhstype, TREE_OPERAND (rhs, 0), complain); - if (TREE_OPERAND (rhs, 0) == error_mark_node) - return error_mark_node; - - mark_addressable (TREE_OPERAND (rhs, 0)); - return rhs; - - case ENTRY_VALUE_EXPR: - assert (0); - return error_mark_node; - - case ERROR_MARK: - return error_mark_node; - - default: - assert (0); - return error_mark_node; - } -} - -/* This routine is called when we finally know the type of expression - we are looking for. If the operator encoded by EXP can take an - argument of type TYPE, return the FUNCTION_DECL for that operator. */ -tree -build_instantiated_decl (type, exp) - tree type, exp; -{ - tree parmtypes, decl, name; - - assert (TREE_CODE (exp) == OP_IDENTIFIER); - type = datatype (type); - if (TREE_CODE (type) != POINTER_TYPE - || (TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE - && TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE)) - { - error ("invalid type used to resolve overloaded function"); - return error_mark_node; - } - - - /* Now we know the type of this function, so overload it. */ - parmtypes = TYPE_ARG_TYPES (TREE_TYPE (type)); - name = build_operator_fnname (&exp, parmtypes, 0); - if (name) - { - name = build_decl_overload (IDENTIFIER_POINTER (name), parmtypes, 1); - decl = lookup_name (name); - if (decl) - return decl; - error ("no suitable declaration of `operator %s' for overloading", - operator_name_string (name)); - return error_mark_node; - } - return error_mark_node; -} - -/* Return the name of the virtual function table (as an IDENTIFIER_NODE) - for the given TYPE. */ -static tree -get_vtable_name (type) - tree type; -{ - char *buf = (char *)alloca (sizeof (VTABLE_NAME_FORMAT) - + TYPE_NAME_LENGTH (type) + 2); - sprintf (buf, VTABLE_NAME_FORMAT, TYPE_NAME_STRING (type)); - return get_identifier (buf); -} - -/* Return the name of the virtual function pointer field - (as an IDENTIFIER_NODE) for the given TYPE. Note that - this may have to look back through base types to find the - ultimate field name. (For single inheritance, these could - all be the same name. Who knows for multiple inheritance). */ -static tree -get_vfield_name (type) - tree type; -{ - char *buf; - - while (CLASSTYPE_N_BASECLASSES (type) - && TYPE_VIRTUAL_P (CLASSTYPE_BASECLASS (type, 1)) - && ! CLASSTYPE_VIA_VIRTUAL (type, 1)) - type = CLASSTYPE_BASECLASS (type, 1); - - buf = (char *)alloca (sizeof (VFIELD_NAME_FORMAT) - + TYPE_NAME_LENGTH (type) + 2); - sprintf (buf, VFIELD_NAME_FORMAT, TYPE_NAME_STRING (type)); - return get_identifier (buf); -} - -void -print_class_statistics () -{ -#ifdef GATHER_STATISTICS - fprintf (stderr, "convert_harshness = %d\n", n_convert_harshness); - fprintf (stderr, "compute_conversion_costs = %d\n", n_compute_conversion_costs); - fprintf (stderr, "build_method_call = %d (inner = %d)\n", - n_build_method_call, n_inner_fields_searched); - if (n_vtables) - { - fprintf (stderr, "vtables = %d; vtable searches = %d\n", - n_vtables, n_vtable_searches); - fprintf (stderr, "vtable entries = %d; vtable elems = %d\n", - n_vtable_entries, n_vtable_elems); - } -#endif -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-cvt.c b/gnu/usr.bin/g++/cc1plus/cplus-cvt.c deleted file mode 100644 index d26596e64ac6..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-cvt.c +++ /dev/null @@ -1,1841 +0,0 @@ -/* Language-level data type conversion for GNU C++. - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file contains the functions for converting C expressions - to different data types. The only entry point is `convert'. - Every language front end must have a `convert' function - but what kind of conversions it does will depend on the language. */ - -#include "config.h" -#include "tree.h" -#include "cplus-tree.h" -#include "assert.h" - -#define NULL 0 - -static tree build_up_reference (); - -/* Change of width--truncation and extension of integers or reals-- - is represented with NOP_EXPR. Proper functioning of many things - assumes that no other conversions can be NOP_EXPRs. - - Conversion between integer and pointer is represented with CONVERT_EXPR. - Converting integer to real uses FLOAT_EXPR - and real to integer uses FIX_TRUNC_EXPR. - - Here is a list of all the functions that assume that widening and - narrowing is always done with a NOP_EXPR: - In c-convert.c, convert_to_integer. - In c-typeck.c, build_binary_op_nodefault (boolean ops), - and truthvalue_conversion. - In expr.c: expand_expr, for operands of a MULT_EXPR. - In fold-const.c: fold. - In tree.c: get_narrower and get_unwidened. - - C++: in multiple-inheritance, converting between pointers may involve - adjusting them by a delta stored within the class definition. */ - -/* Subroutines of `convert'. */ - -static tree -convert_to_pointer (type, expr) - tree type, expr; -{ - register tree intype = TREE_TYPE (expr); - register enum tree_code form = TREE_CODE (intype); - - if (integer_zerop (expr)) - { - if (type == TREE_TYPE (null_pointer_node)) - return null_pointer_node; - expr = build_int_2 (0, 0); - TREE_TYPE (expr) = type; - return expr; - } - - if (form == POINTER_TYPE) - { - intype = TYPE_MAIN_VARIANT (intype); - - if (TYPE_MAIN_VARIANT (type) != intype - && IS_AGGR_TYPE (TREE_TYPE (type)) && IS_AGGR_TYPE (TREE_TYPE (intype))) - { - enum tree_code code = PLUS_EXPR; - tree basetype = get_base_type (TREE_TYPE (TYPE_MAIN_VARIANT (type)), - TREE_TYPE (intype), 1); - if (basetype == error_mark_node) - return error_mark_node; - if (basetype == NULL_TREE) - { - basetype = get_base_type (TREE_TYPE (intype), - TREE_TYPE (TYPE_MAIN_VARIANT (type)), 1); - if (basetype == error_mark_node) - return error_mark_node; - code = MINUS_EXPR; - } - if (basetype) - { - if (TYPE_USES_VIRTUAL_BASECLASSES (TREE_TYPE (type)) - || TYPE_USES_VIRTUAL_BASECLASSES (TREE_TYPE (intype)) - || DECL_OFFSET (TYPE_NAME (basetype)) != 0) - { - /* Need to get the path we took. */ - tree path; - - if (code == PLUS_EXPR) - get_base_distance (TREE_TYPE (type), TREE_TYPE (intype), 0, &path); - else - get_base_distance (TREE_TYPE (intype), TREE_TYPE (type), 0, &path); - return build_vbase_path (code, type, expr, path, 0); - } - } - } - return build1 (NOP_EXPR, type, expr); - } - - if (form == INTEGER_TYPE || form == ENUMERAL_TYPE) - { - if (type_precision (intype) == POINTER_SIZE) - return build1 (CONVERT_EXPR, type, expr); - return convert_to_pointer (type, - convert (type_for_size (POINTER_SIZE, 0), - expr)); - } - - assert (form != OFFSET_TYPE); - - if (IS_AGGR_TYPE (intype)) - { - /* If we cannot convert to the specific pointer type, - try to convert to the type `void *'. */ - tree rval; - rval = build_type_conversion (CONVERT_EXPR, type, expr, 1); - if (rval) - { - if (rval == error_mark_node) - error ("ambiguous pointer conversion"); - return rval; - } - } - - error ("cannot convert to a pointer type"); - - return null_pointer_node; -} - -/* Like convert, except permit conversions to take place which - are not normally allowed due to visibility restrictions - (such as conversion from sub-type to private super-type). */ -static tree -convert_to_pointer_force (type, expr) - tree type, expr; -{ - register tree intype = TREE_TYPE (expr); - register enum tree_code form = TREE_CODE (intype); - - if (integer_zerop (expr)) - { - if (type == TREE_TYPE (null_pointer_node)) - return null_pointer_node; - expr = build_int_2 (0, 0); - TREE_TYPE (expr) = type; - return expr; - } - - if (form == POINTER_TYPE) - { - intype = TYPE_MAIN_VARIANT (intype); - - if (TYPE_MAIN_VARIANT (type) != intype - && IS_AGGR_TYPE (TREE_TYPE (type)) && IS_AGGR_TYPE (TREE_TYPE (intype))) - { - enum tree_code code = PLUS_EXPR; - tree path, basetype; - int distance = get_base_distance (TREE_TYPE (type), - TYPE_MAIN_VARIANT (TREE_TYPE (intype)), 0, &path); - if (distance == -2) - { - ambig: - error_with_aggr_type (TREE_TYPE (type), "type `%s' is ambiguous baseclass of `%s'", - TYPE_NAME_STRING (TREE_TYPE (intype))); - return error_mark_node; - } - if (distance == -1) - { - distance = get_base_distance (TREE_TYPE (intype), - TYPE_MAIN_VARIANT (TREE_TYPE (type)), 0, &path); - if (distance == -2) - goto ambig; - if (distance < 0) - /* Doesn't need any special help from us. */ - return build1 (NOP_EXPR, type, expr); - - code = MINUS_EXPR; - } - return build_vbase_path (code, type, expr, path, 0); - } - return build1 (NOP_EXPR, type, expr); - } - - return convert_to_pointer (type, expr); -} - -/* We are passing something to a function which requires a reference. - The type we are interested in is in TYPE. The initial - value we have to begin with is in ARG. - - FLAGS controls how we manage visibility checking. */ -static tree -build_up_reference (type, arg, flags) - tree type, arg; - int flags; -{ - tree rval; - int literal_flag = 0; - tree argtype = TREE_TYPE (arg), basetype = argtype; - tree target_type = TREE_TYPE (type); - - assert (TREE_CODE (type) == REFERENCE_TYPE); - if (TYPE_MAIN_VARIANT (argtype) != TYPE_MAIN_VARIANT (target_type) - && IS_AGGR_TYPE (argtype) - && IS_AGGR_TYPE (target_type)) - { - basetype = get_base_type (target_type, TYPE_MAIN_VARIANT (argtype), - (flags & LOOKUP_PROTECTED_OK) ? 3 : 2); - if ((flags & LOOKUP_PROTECT) && basetype == error_mark_node) - return error_mark_node; - if (basetype == NULL_TREE) - { - error_not_base_type (target_type, argtype); - return error_mark_node; - } - } - - switch (TREE_CODE (arg)) - { - case INDIRECT_REF: - /* This is a call to a constructor which did not know what it was - initializing until now: it needs to initialize a temporary. */ - if (TYPE_HAS_CONSTRUCTOR (arg)) - { - tree temp = build_cplus_new (argtype, TREE_OPERAND (arg, 0)); - TYPE_HAS_CONSTRUCTOR (arg) = 0; - return build_up_reference (type, temp, flags); - } - /* Let &* cancel out to simplify resulting code. - Also, throw away intervening NOP_EXPRs. */ - arg = TREE_OPERAND (arg, 0); - if (TREE_CODE (arg) == NOP_EXPR || TREE_CODE (arg) == REFERENCE_EXPR) - arg = TREE_OPERAND (arg, 0); - - rval = build1 (REFERENCE_EXPR, type, arg); - literal_flag = TREE_LITERAL (arg); - goto done; - - /* Get this out of a register if we happened to be in one by accident. - Also, build up references to non-lvalues it we must. */ - /* For &x[y], return (&) x+y */ - case ARRAY_REF: - if (mark_addressable (TREE_OPERAND (arg, 0)) == 0) - return error_mark_node; - rval = build_binary_op (PLUS_EXPR, TREE_OPERAND (arg, 0), - TREE_OPERAND (arg, 1)); - TREE_TYPE (rval) = type; - if (TREE_LITERAL (TREE_OPERAND (arg, 1)) - && staticp (TREE_OPERAND (arg, 0))) - TREE_LITERAL (rval) = 1; - return rval; - - case SCOPE_REF: - /* Could be a reference to a static member. */ - { - tree field = TREE_OPERAND (arg, 1); - if (TREE_STATIC (field)) - { - rval = build1 (ADDR_EXPR, type, field); - literal_flag = 1; - goto done; - } - } - /* we should have farmed out member pointers above. */ - assert (0); - - case COMPONENT_REF: - rval = build_component_addr (arg, build_pointer_type (argtype), - "attempt to make a reference to bit-field structure member `%s'"); - rval = build1 (NOP_EXPR, type, rval); - literal_flag = staticp (TREE_OPERAND (arg, 0)); -#if 0 - goto done_but_maybe_warn; -#else - goto done; -#endif - - /* Anything not already handled and not a true memory reference - needs to have a reference built up. Do so silently for - things like integers and return values from function, - but complain if we need a reference to something declared - as `register'. */ - - case RESULT_DECL: - if (staticp (arg)) - literal_flag = 1; - TREE_ADDRESSABLE (arg) = 1; - put_var_into_stack (arg); - break; - - case PARM_DECL: - if (arg == current_class_decl) - { - error ("address of `this' not available"); - TREE_ADDRESSABLE (arg) = 1; /* so compiler doesn't die later */ - put_var_into_stack (arg); - break; - } - /* Fall through. */ - case VAR_DECL: - case CONST_DECL: - if (TREE_REGDECL (arg) && !TREE_ADDRESSABLE (arg)) - warning ("address needed to build reference for `%s', which is declared `register'", - IDENTIFIER_POINTER (DECL_NAME (arg))); - else if (staticp (arg)) - literal_flag = 1; - - TREE_ADDRESSABLE (arg) = 1; - put_var_into_stack (arg); - break; - - case COMPOUND_EXPR: - { - tree real_reference = build_up_reference (type, TREE_OPERAND (arg, 1), 1); - rval = build (COMPOUND_EXPR, type, TREE_OPERAND (arg, 0), real_reference); - TREE_LITERAL (rval) = staticp (TREE_OPERAND (arg, 1)); - return rval; - } - - case MODIFY_EXPR: - case INIT_EXPR: - { - tree real_reference = build_up_reference (type, TREE_OPERAND (arg, 0), 1); - rval = build (COMPOUND_EXPR, type, arg, real_reference); - TREE_LITERAL (rval) = staticp (TREE_OPERAND (arg, 0)); - return rval; - } - - case COND_EXPR: - return build (COND_EXPR, type, - TREE_OPERAND (arg, 0), - build_up_reference (type, TREE_OPERAND (arg, 1), 1), - build_up_reference (type, TREE_OPERAND (arg, 2), 1)); - - case WITH_CLEANUP_EXPR: - rval = build (WITH_CLEANUP_EXPR, type, - build_up_reference (type, TREE_OPERAND (arg, 0), 1), - 0, TREE_OPERAND (arg, 2)); - return rval; - - default: - break; - } - - if (TREE_ADDRESSABLE (arg) == 0) - { - tree temp; - - if (TREE_CODE (arg) == CALL_EXPR && IS_AGGR_TYPE (argtype)) - { - temp = build_cplus_new (argtype, arg); - rval = build1 (ADDR_EXPR, type, temp); - goto done; - } - else - { - temp = get_temp_name (argtype, 0); - if (global_bindings_p ()) - { - /* Give this new temp some rtl and initialize it. */ - DECL_INITIAL (temp) = arg; - TREE_STATIC (temp) = 1; - finish_decl (temp, arg, NULL_TREE); - /* Do this after declaring it static. */ - rval = build_unary_op (ADDR_EXPR, temp, 0); - literal_flag = TREE_LITERAL (rval); - goto done; - } - else - { - rval = build_unary_op (ADDR_EXPR, temp, 0); - /* Put a value into the rtl. */ - if (IS_AGGR_TYPE (argtype)) - { - /* This may produce surprising results, - since we commit to initializing the temp - when the temp may not actually get used. */ - expand_aggr_init (temp, arg, 0); - TREE_TYPE (rval) = type; - literal_flag = TREE_LITERAL (rval); - goto done; - } - else - { - if (basetype != argtype) - rval = convert_pointer_to (target_type, rval); - else - TREE_TYPE (rval) = type; - return build (COMPOUND_EXPR, type, - build (MODIFY_EXPR, argtype, temp, arg), rval); - } - } - } - } - else - rval = build1 (ADDR_EXPR, type, arg); - - done_but_maybe_warn: - if (TREE_READONLY (arg) - && ! TREE_READONLY (target_type)) - readonly_warning_or_error (arg, "conversion to reference"); - - done: - if (TYPE_LANG_SPECIFIC (argtype) - && (TYPE_USES_MULTIPLE_INHERITANCE (argtype) - || TYPE_USES_VIRTUAL_BASECLASSES (argtype))) - { - TREE_TYPE (rval) = TYPE_POINTER_TO (argtype); - rval = convert_pointer_to (target_type, rval); - rval = build1 (NOP_EXPR, type, rval); - } - TREE_LITERAL (rval) = literal_flag; - return rval; -} - -/* For C++: Only need to do one-level references, but cannot - get tripped up on signed/unsigned differences. - - If DECL is NULL_TREE it means convert as though casting (by force). - If it is ERROR_MARK_NODE, it means the conversion is implicit, - and that temporaries may be created. - Otherwise, DECL is a _DECL node which can be used in error reporting. */ -tree -convert_to_reference (decl, reftype, expr, strict, flags) - tree decl; - tree reftype, expr; - int strict, flags; -{ - register tree type = TYPE_MAIN_VARIANT (TREE_TYPE (reftype)); - register tree intype = TREE_TYPE (expr); - register enum tree_code form = TREE_CODE (intype); - - assert (TREE_CODE (reftype) == REFERENCE_TYPE); - - if (form == REFERENCE_TYPE) - intype = TREE_TYPE (intype); - intype = TYPE_MAIN_VARIANT (intype); - - /* @@ Probably need to have a check for X(X&) here. */ - - if (IS_AGGR_TYPE (intype)) - { - tree rval = build_type_conversion (CONVERT_EXPR, reftype, expr, 1); - if (rval) - { - if (rval == error_mark_node) - error ("ambiguous pointer conversion"); - return rval; - } - else if (rval = build_type_conversion (CONVERT_EXPR, type, expr, 1)) - { - if (TYPE_NEEDS_DESTRUCTOR (type)) - rval = cleanup_after_call (rval); - else - { - decl = get_temp_name (type, 0); - rval = build (INIT_EXPR, type, decl, rval); - rval = build (COMPOUND_EXPR, reftype, rval, - convert_to_reference (NULL_TREE, reftype, decl, - strict, flags)); - - } - return rval; - } - - if (form == REFERENCE_TYPE - && type != intype - && TYPE_LANG_SPECIFIC (intype) - && (TYPE_USES_VIRTUAL_BASECLASSES (intype) - || TYPE_USES_MULTIPLE_INHERITANCE (intype))) - { - /* If it may move around, build a fresh reference. */ - expr = convert_from_reference (expr); - form = TREE_CODE (TREE_TYPE (expr)); - } - } - - /* @@ Perhaps this should try to go through a constructor first - @@ for proper initialization, but I am not sure when that - @@ is needed or desirable. - - @@ The second disjunct is provided to make references behave - @@ as some people think they should, i.e., an interconvertability - @@ between references to builtin types (such as short and - @@ unsigned short). There should be no conversion between - @@ types whose codes are different, or whose sizes are different. */ - - if (((IS_AGGR_TYPE (type) || IS_AGGR_TYPE (intype)) - && comptypes (type, intype, strict)) - || (!IS_AGGR_TYPE (type) - && TREE_CODE (type) == TREE_CODE (intype) - && int_size_in_bytes (type) == int_size_in_bytes (intype))) - { - /* If EXPR is of aggregate type, and is really a CALL_EXPR, - then we don't need to convert it to reference type if - it is only being used to initialize DECL which is also - of the same aggregate type. */ - if (form == REFERENCE_TYPE - || (decl != NULL_TREE && decl != error_mark_node - && IS_AGGR_TYPE (type) - && TREE_CODE (expr) == CALL_EXPR - && TYPE_MAIN_VARIANT (type) == intype)) - { - if (decl && decl != error_mark_node) - { - tree e1 = build (INIT_EXPR, void_type_node, decl, expr); - tree e2; - - TREE_VOLATILE (e1) = 1; - if (form == REFERENCE_TYPE) - e2 = build1 (NOP_EXPR, reftype, decl); - else - { - e2 = build_unary_op (ADDR_EXPR, decl, 0); - e2 = build1 (REFERENCE_EXPR, reftype, e2); - } - return build_compound_expr (tree_cons (NULL_TREE, e1, - build_tree_list (NULL_TREE, e2))); - } - expr = copy_node (expr); - TREE_TYPE (expr) = reftype; - return expr; - } - if (decl == error_mark_node) - flags |= LOOKUP_PROTECTED_OK; - return build_up_reference (reftype, expr, flags); - } - - /* Definitely need to go through a constructor here. */ - if (TYPE_HAS_CONSTRUCTOR (type)) - { - tree init = build_method_call (NULL_TREE, DECL_NAME (TYPE_NAME (type)), build_tree_list (NULL_TREE, expr), CLASSTYPE_AS_LIST (type), LOOKUP_NORMAL); - tree rval; - - if (init == error_mark_node) - return error_mark_node; - rval = build_cplus_new (type, init); - if (decl == error_mark_node) - flags |= LOOKUP_PROTECTED_OK; - return build_up_reference (reftype, rval, flags); - } - - assert (form != OFFSET_TYPE); - - error ("cannot convert to a reference type"); - - return error_mark_node; -} - -/* We are using a reference VAL for its value. Bash that reference all the - way down to its lowest form. */ -tree -convert_from_reference (val) - tree val; -{ - tree type = TREE_TYPE (val); - -#if 0 - if (TREE_CODE (val) == REFERENCE_EXPR) - { - val = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (type)), - TREE_OPERAND (val, 0)); - return val; - } -#endif - if (TREE_CODE (type) == OFFSET_TYPE) - type = TREE_TYPE (type); - if (TREE_CODE (type) == REFERENCE_TYPE) - { - tree dt = TREE_TYPE (type); - - /* This can happen if we cast to a reference type. */ - if (TREE_CODE (val) == ADDR_EXPR) - { - val = build1 (NOP_EXPR, build_pointer_type (dt), val); - val = build_indirect_ref (val, 0); - return val; - } - - val = build1 (INDIRECT_REF, TYPE_MAIN_VARIANT (dt), val); - - TREE_THIS_VOLATILE (val) = TREE_VOLATILE (dt); - TREE_READONLY (val) = TREE_READONLY (dt); - } - return val; -} - -static tree -convert_to_real (type, expr) - tree type, expr; -{ - register enum tree_code form = TREE_CODE (TREE_TYPE (expr)); - extern int flag_float_store; - - if (form == REAL_TYPE) - return build1 (flag_float_store ? CONVERT_EXPR : NOP_EXPR, - type, expr); - - if (form == INTEGER_TYPE || form == ENUMERAL_TYPE) - return build1 (FLOAT_EXPR, type, expr); - - assert (form != OFFSET_TYPE); - - if (form == POINTER_TYPE) - error ("pointer value used where a floating point value was expected"); - /* C++: check to see if we can convert this aggregate type - into the required scalar type. */ - else if (IS_AGGR_TYPE (TREE_TYPE (expr))) - { - tree rval; - rval = build_type_conversion (CONVERT_EXPR, type, expr, 1); - if (rval) - return rval; - else - error ("aggregate value used where a floating point value was expected"); - } - - { - register tree tem = make_node (REAL_CST); - TREE_TYPE (tem) = type; - TREE_REAL_CST (tem) = 0; - return tem; - } -} - -/* The result of this is always supposed to be a newly created tree node - not in use in any existing structure. */ - -static tree -convert_to_integer (type, expr) - tree type, expr; -{ - register tree intype = TREE_TYPE (expr); - register enum tree_code form = TREE_CODE (intype); - extern tree build_binary_op_nodefault (); - extern tree build_unary_op (); - - if (form == POINTER_TYPE) - { - if (integer_zerop (expr)) - expr = integer_zero_node; - else - expr = fold (build1 (CONVERT_EXPR, - type_for_size (POINTER_SIZE, 0), expr)); - intype = TREE_TYPE (expr); - form = TREE_CODE (intype); - if (intype == type) - return expr; - } - - if (form == INTEGER_TYPE || form == ENUMERAL_TYPE) - { - register int outprec = TYPE_PRECISION (type); - register int inprec = TYPE_PRECISION (intype); - register enum tree_code ex_form = TREE_CODE (expr); - - if (outprec >= inprec) - return build1 (NOP_EXPR, type, expr); - -/* Here detect when we can distribute the truncation down past some arithmetic. - For example, if adding two longs and converting to an int, - we can equally well convert both to ints and then add. - For the operations handled here, such truncation distribution - is always safe. - It is desirable in these cases: - 1) when truncating down to full-word from a larger size - 2) when truncating takes no work. - 3) when at least one operand of the arithmetic has been extended - (as by C's default conversions). In this case we need two conversions - if we do the arithmetic as already requested, so we might as well - truncate both and then combine. Perhaps that way we need only one. - - Note that in general we cannot do the arithmetic in a type - shorter than the desired result of conversion, even if the operands - are both extended from a shorter type, because they might overflow - if combined in that type. The exceptions to this--the times when - two narrow values can be combined in their narrow type even to - make a wider result--are handled by "shorten" in build_binary_op. */ - - switch (ex_form) - { - case RSHIFT_EXPR: - /* We can pass truncation down through right shifting - when the shift count is a negative constant. */ - if (TREE_CODE (TREE_OPERAND (expr, 1)) != INTEGER_CST - || TREE_INT_CST_LOW (TREE_OPERAND (expr, 1)) > 0) - break; - goto trunc1; - - case LSHIFT_EXPR: - /* We can pass truncation down through left shifting - when the shift count is a positive constant. */ - if (TREE_CODE (TREE_OPERAND (expr, 1)) != INTEGER_CST - || TREE_INT_CST_LOW (TREE_OPERAND (expr, 1)) < 0) - break; - /* In this case, shifting is like multiplication. */ - goto trunc1; - - case MAX_EXPR: - case MIN_EXPR: - case MULT_EXPR: - { - tree arg0 = get_unwidened (TREE_OPERAND (expr, 0), type); - tree arg1 = get_unwidened (TREE_OPERAND (expr, 1), type); - - /* Don't distribute unless the output precision is at least as big - as the actual inputs. Otherwise, the comparison of the - truncated values will be wrong. */ - if (outprec >= TYPE_PRECISION (TREE_TYPE (arg0)) - && outprec >= TYPE_PRECISION (TREE_TYPE (arg1)) - /* If signedness of arg0 and arg1 don't match, - we can't necessarily find a type to compare them in. */ - && (TREE_UNSIGNED (TREE_TYPE (arg0)) - == TREE_UNSIGNED (TREE_TYPE (arg1)))) - goto trunc1; - break; - } - - case PLUS_EXPR: - case MINUS_EXPR: - case BIT_AND_EXPR: - case BIT_IOR_EXPR: - case BIT_XOR_EXPR: - case BIT_ANDTC_EXPR: - trunc1: - { - tree arg0 = get_unwidened (TREE_OPERAND (expr, 0), type); - tree arg1 = get_unwidened (TREE_OPERAND (expr, 1), type); - - if (outprec >= BITS_PER_WORD - || TRULY_NOOP_TRUNCATION (outprec, inprec) - || inprec > TYPE_PRECISION (TREE_TYPE (arg0)) - || inprec > TYPE_PRECISION (TREE_TYPE (arg1))) - { - /* Do the arithmetic in type TYPEX, - then convert result to TYPE. */ - register tree typex = type; - - /* Can't do arithmetic in enumeral types - so use an integer type that will hold the values. */ - if (TREE_CODE (typex) == ENUMERAL_TYPE) - typex = type_for_size (TYPE_PRECISION (typex), - TREE_UNSIGNED (typex)); - - /* But now perhaps TYPEX is as wide as INPREC. - In that case, do nothing special here. - (Otherwise would recurse infinitely in convert. */ - if (TYPE_PRECISION (typex) != inprec) - { - /* Don't do unsigned arithmetic where signed was wanted, - or vice versa. - Exception: if the original operands were unsigned - then can safely do the work as unsigned. - And we may need to do it as unsigned - if we truncate to the original size. */ - typex = ((TREE_UNSIGNED (TREE_TYPE (expr)) - || TREE_UNSIGNED (TREE_TYPE (arg0))) - ? unsigned_type (typex) : signed_type (typex)); - return convert (type, - build_binary_op_nodefault (ex_form, - convert (typex, arg0), - convert (typex, arg1), - ex_form)); - } - } - } - break; - - case EQ_EXPR: - case NE_EXPR: - case GT_EXPR: - case GE_EXPR: - case LT_EXPR: - case LE_EXPR: - case TRUTH_AND_EXPR: - case TRUTH_ANDIF_EXPR: - case TRUTH_OR_EXPR: - case TRUTH_ORIF_EXPR: - case TRUTH_NOT_EXPR: - /* If we want result of comparison converted to a byte, - we can just regard it as a byte, since it is 0 or 1. */ - TREE_TYPE (expr) = type; - return expr; - - case NEGATE_EXPR: - case BIT_NOT_EXPR: - case ABS_EXPR: - { - register tree typex = type; - - /* Can't do arithmetic in enumeral types - so use an integer type that will hold the values. */ - if (TREE_CODE (typex) == ENUMERAL_TYPE) - typex = type_for_size (TYPE_PRECISION (typex), - TREE_UNSIGNED (typex)); - - /* But now perhaps TYPEX is as wide as INPREC. - In that case, do nothing special here. - (Otherwise would recurse infinitely in convert. */ - if (TYPE_PRECISION (typex) != inprec) - { - /* Don't do unsigned arithmetic where signed was wanted, - or vice versa. */ - typex = (TREE_UNSIGNED (TREE_TYPE (expr)) - ? unsigned_type (typex) : signed_type (typex)); - return convert (type, - build_unary_op (ex_form, - convert (typex, TREE_OPERAND (expr, 0)), - 1)); - } - } - - case NOP_EXPR: - /* If truncating after truncating, might as well do all at once. - If truncating after extending, we may get rid of wasted work. */ - return convert (type, get_unwidened (TREE_OPERAND (expr, 0), type)); - - case COND_EXPR: - /* Can treat the two alternative values like the operands - of an arithmetic expression. */ - { - tree arg1 = get_unwidened (TREE_OPERAND (expr, 1), type); - tree arg2 = get_unwidened (TREE_OPERAND (expr, 2), type); - - if (outprec >= BITS_PER_WORD - || TRULY_NOOP_TRUNCATION (outprec, inprec) - || inprec > TYPE_PRECISION (TREE_TYPE (arg1)) - || inprec > TYPE_PRECISION (TREE_TYPE (arg2))) - { - /* Do the arithmetic in type TYPEX, - then convert result to TYPE. */ - register tree typex = type; - - /* Can't do arithmetic in enumeral types - so use an integer type that will hold the values. */ - if (TREE_CODE (typex) == ENUMERAL_TYPE) - typex = type_for_size (TYPE_PRECISION (typex), - TREE_UNSIGNED (typex)); - - /* But now perhaps TYPEX is as wide as INPREC. - In that case, do nothing special here. - (Otherwise would recurse infinitely in convert. */ - if (TYPE_PRECISION (typex) != inprec) - { - /* Don't do unsigned arithmetic where signed was wanted, - or vice versa. */ - typex = (TREE_UNSIGNED (TREE_TYPE (expr)) - ? unsigned_type (typex) : signed_type (typex)); - return convert (type, - build (COND_EXPR, typex, - TREE_OPERAND (expr, 0), - convert (typex, arg1), - convert (typex, arg2))); - } - } - } - - } - - return build1 (NOP_EXPR, type, expr); - } - - if (form == REAL_TYPE) - return build1 (FIX_TRUNC_EXPR, type, expr); - - if (form == OFFSET_TYPE) - error_with_decl (TYPE_NAME (TYPE_OFFSET_BASETYPE (intype)), - "pointer-to-member expression object not composed with type `%s' object"); - else - { - if (IS_AGGR_TYPE (intype)) - { - tree rval; - rval = build_type_conversion (CONVERT_EXPR, type, expr, 1); - if (rval) return rval; - } - - error ("aggregate value used where an integer was expected"); - } - - { - register tree tem = build_int_2 (0, 0); - TREE_TYPE (tem) = type; - return tem; - } -} - -/* See if there is a constructor of type TYPE which will convert - EXPR. The reference manual seems to suggest (8.5.6) that we need - not worry about finding constructors for base classes, then converting - to the derived class. - - MSGP is a pointer to a message that would be an appropriate error - string. If MSGP is NULL, then we are not interested in reporting - errors. */ -tree -convert_to_aggr (type, expr, msgp, protect) - tree type, expr; - char **msgp; -{ - tree basetype = TYPE_MAIN_VARIANT (type); - tree name = DECL_NAME (TYPE_NAME (basetype)); - tree field; - tree function, fntype, parmtypes, parmlist, result; - tree method_name; - enum visibility_type visibility; - int can_be_private, can_be_protected; - - if (! TYPE_HAS_CONSTRUCTOR (basetype)) - { - if (msgp) - *msgp = "type `%s' does not have a constructor"; - return error_mark_node; - } - - visibility = visibility_public; - can_be_private = 0; - can_be_protected = IDENTIFIER_CLASS_VALUE (name) || name == current_class_name; - - parmlist = build_tree_list (NULL_TREE, expr); - parmtypes = tree_cons (NULL_TREE, TREE_TYPE (expr), void_list_node); - - if (TYPE_USES_VIRTUAL_BASECLASSES (basetype)) - { - parmtypes = tree_cons (NULL_TREE, integer_type_node, parmtypes); - parmlist = tree_cons (NULL_TREE, integer_one_node, parmlist); - } - - /* The type of the first argument will be filled in inside the loop. */ - parmlist = tree_cons (NULL_TREE, integer_zero_node, parmlist); - parmtypes = tree_cons (NULL_TREE, TYPE_POINTER_TO (basetype), parmtypes); - - method_name = build_decl_overload (IDENTIFIER_POINTER (name), parmtypes, 1); - - /* constructors are up front. */ - field = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype), 0); - if (TYPE_HAS_DESTRUCTOR (basetype)) - field = TREE_CHAIN (field); - - while (field) - { - if (DECL_NAME (field) == method_name) - { - function = field; - if (protect) - { - if (TREE_PRIVATE (field)) - { - can_be_private = - (basetype == current_class_type - || is_friend (basetype, current_function_decl) - || purpose_member (basetype, DECL_VISIBILITY (field))); - if (! can_be_private) - goto found; - } - else if (TREE_PROTECTED (field)) - { - if (! can_be_protected) - goto found; - } - } - goto found_and_ok; - } - field = TREE_CHAIN (field); - } - - /* No exact conversion was found. See if an approximate - one will do. */ - field = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype), 0); - if (TYPE_HAS_DESTRUCTOR (basetype)) - field = TREE_CHAIN (field); - - { - int saw_private = 0; - int saw_protected = 0; - struct candidate *candidates = - (struct candidate *) alloca ((list_length (field)+1) * sizeof (struct candidate)); - struct candidate *cp = candidates; - - while (field) - { - function = field; - cp->harshness = (unsigned short *)alloca (3 * sizeof (short)); - compute_conversion_costs (function, parmlist, cp, 2); - if (cp->evil == 0) - { - cp->u.field = field; - if (protect) - { - if (TREE_PRIVATE (field)) - visibility = visibility_private; - else if (TREE_PROTECTED (field)) - visibility = visibility_protected; - else - visibility = visibility_public; - } - else - visibility = visibility_public; - - if (visibility == visibility_private - ? (basetype == current_class_type - || is_friend (basetype, cp->function) - || purpose_member (basetype, DECL_VISIBILITY (field))) - : visibility == visibility_protected - ? (can_be_protected - || purpose_member (basetype, DECL_VISIBILITY (field))) - : 1) - { - if (cp->user == 0 && cp->b_or_d == 0 - && cp->easy <= 1) - { - goto found_and_ok; - } - cp++; - } - else - { - if (visibility == visibility_private) - saw_private = 1; - else - saw_protected = 1; - } - } - field = TREE_CHAIN (field); - } - if (cp - candidates) - { - /* Rank from worst to best. Then cp will point to best one. - Private fields have their bits flipped. For unsigned - numbers, this should make them look very large. - If the best alternate has a (signed) negative value, - then all we ever saw were private members. */ - if (cp - candidates > 1) - qsort (candidates, /* char *base */ - cp - candidates, /* int nel */ - sizeof (struct candidate), /* int width */ - rank_for_overload); /* int (*compar)() */ - - --cp; - if (cp->evil > 1) - { - if (msgp) - *msgp = "ambiguous type conversion possible for `%s'"; - return error_mark_node; - } - - function = cp->function; - field = cp->u.field; - goto found_and_ok; - } - else if (msgp) - { - if (saw_private) - if (saw_protected) - *msgp = "only private and protected conversions apply"; - else - *msgp = "only private conversions apply"; - else if (saw_protected) - *msgp = "only protected conversions apply"; - } - return error_mark_node; - } - /* NOTREACHED */ - - not_found: - if (msgp) *msgp = "no appropriate conversion to type `%s'"; - return error_mark_node; - found: - if (visibility == visibility_private) - if (! can_be_private) - { - if (msgp) - *msgp = TREE_PRIVATE (field) - ? "conversion to type `%s' is private" - : "conversion to type `%s' is from private base class"; - return error_mark_node; - } - if (visibility == visibility_protected) - if (! can_be_protected) - { - if (msgp) - *msgp = TREE_PRIVATE (field) - ? "conversion to type `%s' is protected" - : "conversion to type `%s' is from protected base class"; - return error_mark_node; - } - function = field; - found_and_ok: - - /* It will convert, but we don't do anything about it yet. */ - if (msgp == 0) - return NULL_TREE; - - fntype = TREE_TYPE (function); - if (TREE_INLINE (function) && TREE_CODE (function) == FUNCTION_DECL) - function = build1 (ADDR_EXPR, build_pointer_type (fntype), function); - else - function = default_conversion (function); - - result = build_nt (CALL_EXPR, function, - actualparameterlist (NULL_TREE, TYPE_ARG_TYPES (fntype), parmlist, NULL_TREE, LOOKUP_NORMAL), - NULL_TREE); - TREE_TYPE (result) = TREE_TYPE (fntype); - TREE_VOLATILE (result) = 1; - TREE_RAISES (result) = !! TYPE_RAISES_EXCEPTIONS (fntype); - return result; -} - -/* Call this when we know (for any reason) that expr is - not, in fact, zero. */ -tree -convert_pointer_to (type, expr) - tree type, expr; -{ - register tree intype = TREE_TYPE (expr); - register enum tree_code form = TREE_CODE (intype); - tree ptr_type = build_pointer_type (type); - tree rval; - - if (TYPE_MAIN_VARIANT (ptr_type) == TYPE_MAIN_VARIANT (intype)) - return expr; - - if (intype == error_mark_node) - return error_mark_node; - - assert (form == POINTER_TYPE); - assert (!integer_zerop (expr)); - - if (IS_AGGR_TYPE (type) - && IS_AGGR_TYPE (TREE_TYPE (intype)) - && TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (TREE_TYPE (intype))) - { - tree path, basetype; - int distance = get_base_distance (type, TYPE_MAIN_VARIANT (TREE_TYPE (intype)), 0, &path); - - /* This function shouldn't be called with - unqualified arguments. */ - assert (distance >= 0); - - return build_vbase_path (PLUS_EXPR, ptr_type, expr, path, 1); - } - rval = build1 (NOP_EXPR, ptr_type, - TREE_CODE (expr) == NOP_EXPR - ? TREE_OPERAND (expr, 0) : expr); - TREE_LITERAL (rval) = TREE_LITERAL (expr); - return rval; -} - -/* Same as above, but don't abort if we get an "ambiguous" baseclass. - There's only one virtual baseclass we are looking for, and once - we find one such virtual baseclass, we have found them all. */ - -tree -convert_pointer_to_vbase (type, expr) - tree type; - tree expr; -{ - tree intype = TREE_TYPE (TREE_TYPE (expr)); - int i; - - for (i = CLASSTYPE_N_BASECLASSES (intype); i > 0; i--) - { - tree basetype = CLASSTYPE_BASECLASS (intype, i); - if (type == basetype) - return convert_pointer_to (type, expr); - if (value_member (TYPE_MAIN_VARIANT (type), - CLASSTYPE_VBASECLASSES (basetype))) - return convert_pointer_to_vbase (type, convert_pointer_to (TYPE_MAIN_VARIANT (basetype), expr)); - } - abort (); -} - -/* Create an expression whose value is that of EXPR, - converted to type TYPE. The TREE_TYPE of the value - is always TYPE. This function implements all reasonable - conversions; callers should filter out those that are - not permitted by the language being compiled. */ - -tree -convert (type, expr) - tree type, expr; -{ - register tree e = expr; - register enum tree_code code = TREE_CODE (type); - - if (type == TREE_TYPE (expr) || TREE_CODE (expr) == ERROR_MARK) - return expr; - if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK) - return error_mark_node; - if (TREE_CODE (TREE_TYPE (expr)) == VOID_TYPE) - { - error ("void value not ignored as it ought to be"); - return error_mark_node; - } - if (code == VOID_TYPE) - { - tree rval = build_type_conversion (NOP_EXPR, type, e, 0); - /* If we can convert to void type via a type conversion, do so. */ - if (rval) - return rval; - return build1 (CONVERT_EXPR, type, e); - } -#if 0 - /* This is incorrect. A truncation can't be stripped this way. - Extensions will be stripped by the use of get_unwidened. */ - if (TREE_CODE (expr) == NOP_EXPR) - return convert (type, TREE_OPERAND (expr, 0)); -#endif - - /* Just convert to the type of the member. */ - if (code == OFFSET_TYPE) - { - type = TREE_TYPE (type); - code = TREE_CODE (type); - } - - /* C++ */ - if (code == REFERENCE_TYPE) - return fold (convert_to_reference (error_mark_node, type, e, -1, LOOKUP_NORMAL)); - else if (TREE_CODE (TREE_TYPE (e)) == REFERENCE_TYPE) - e = convert_from_reference (e); - - if (code == INTEGER_TYPE || code == ENUMERAL_TYPE) - return fold (convert_to_integer (type, e)); - if (code == POINTER_TYPE) - return fold (convert_to_pointer (type, e)); - if (code == REAL_TYPE) - return fold (convert_to_real (type, e)); - - /* New C++ semantics: since assignment is now based on - memberwise copying, if the rhs type is derived from the - lhs type, then we may still do a conversion. */ - if (IS_AGGR_TYPE_CODE (code)) - { - tree dtype = TREE_TYPE (e); - - if (TREE_CODE (dtype) == REFERENCE_TYPE) - { - e = convert_from_reference (e); - dtype = TREE_TYPE (e); - } - dtype = TYPE_MAIN_VARIANT (dtype); - - /* Conversion between aggregate types. New C++ semantics allow - objects of derived type to be cast to objects of base type. - Old semantics only allowed this bwteen pointers. - - There may be some ambiguity between using a constructor - vs. using a type conversion operator when both apply. */ - - if (IS_AGGR_TYPE (dtype)) - { - tree basetype; - - tree conversion = TYPE_HAS_CONVERSION (dtype) - ? build_type_conversion (CONVERT_EXPR, type, e, 1) : NULL_TREE; - - if (TYPE_HAS_CONSTRUCTOR (type)) - { - tree rval = build_method_call (NULL_TREE, DECL_NAME (TYPE_NAME (type)), build_tree_list (NULL_TREE, e), CLASSTYPE_AS_LIST (type), - conversion ? LOOKUP_NO_CONVERSION : 0); - - if (rval != error_mark_node) - { - if (conversion) - { - error ("both constructor and type conversion operator apply"); - return error_mark_node; - } - /* call to constructor successful. */ - rval = build_cplus_new (type, rval); - return rval; - } - } - /* Type conversion successful/applies. */ - if (conversion) - { - if (conversion == error_mark_node) - error ("ambiguous pointer conversion"); - return conversion; - } - - /* now try normal C++ assignment semantics. */ - basetype = dtype; - if (type == basetype - || (basetype = get_base_type (type, dtype, 1))) - { - if (basetype == error_mark_node) - return error_mark_node; - -#if 0 - if (TYPE_VIRTUAL_P (type)) - warning ("assignment to virtual aggregate type"); -#endif - return build (COMPONENT_REF, type, e, TYPE_NAME (basetype)); - } - error ("conversion between incompatible aggregate types requested"); - return error_mark_node; - } - /* conversion from non-aggregate to aggregate type requires constructor. */ - else if (TYPE_HAS_CONSTRUCTOR (type)) - { - tree rval; - tree init = build_method_call (NULL_TREE, DECL_NAME (TYPE_NAME (type)), build_tree_list (NULL_TREE, e), CLASSTYPE_AS_LIST (type), LOOKUP_NORMAL); - if (init == error_mark_node) - { - error_with_aggr_type (type, "in conversion to type `%s'"); - return error_mark_node; - } - rval = build_cplus_new (type, init); - return rval; - } - } - - error ("conversion to non-scalar type requested"); - return error_mark_node; -} - -/* Like convert, except permit conversions to take place which - are not normally allowed due to visibility restrictions - (such as conversion from sub-type to private super-type). */ -tree -convert_force (type, expr) - tree type; - tree expr; -{ - register tree e = expr; - register enum tree_code code = TREE_CODE (type); - - if (code == REFERENCE_TYPE) - return fold (convert_to_reference (0, type, e, -1, 0)); - else if (TREE_CODE (TREE_TYPE (e)) == REFERENCE_TYPE) - e = convert_from_reference (e); - - if (code == POINTER_TYPE) - return fold (convert_to_pointer_force (type, e)); - return convert (type, e); -} - -/* Subroutine of build_type_conversion. */ -static tree -build_type_conversion_1 (xtype, basetype, expr, typename, for_sure) - tree xtype, basetype; - tree expr; - tree typename; - int for_sure; -{ - tree first_arg = expr; - tree rval; - int flags; - - if (for_sure == 0) - { - if (! lvalue_p (expr)) - first_arg = build1 (NOP_EXPR, TYPE_POINTER_TO (basetype), integer_zero_node); - flags = LOOKUP_PROTECT; - } - else - flags = LOOKUP_NORMAL; - - rval = build_method_call (first_arg, typename, NULL_TREE, NULL_TREE, flags); - if (rval == error_mark_node) - { - if (for_sure == 0) - return NULL_TREE; - return error_mark_node; - } - if (first_arg != expr) - { - expr = build_up_reference (build_reference_type (TREE_TYPE (expr)), expr, 0); - TREE_VALUE (TREE_OPERAND (rval, 1)) = build_unary_op (ADDR_EXPR, expr, 0); - } - if (TREE_CODE (TREE_TYPE (rval)) == REFERENCE_TYPE - && TREE_CODE (xtype) != REFERENCE_TYPE) - rval = default_conversion (rval); - return convert (xtype, rval); -} - -/* Convert an aggregate EXPR to type XTYPE. If a conversion - exists, return the attempted conversion. This may - return ERROR_MARK_NODE if the conversion is not - allowed (references private members, etc). - If no conversion exists, NULL_TREE is returned. - - If (FOR_SURE & 1) is non-zero, then we allow this type conversion - to take place immediately. Otherwise, we build a SAVE_EXPR - which can be evaluated if the results are ever needed. - - If FOR_SURE >= 2, then we only look for exact conversions. - - TYPE may be a reference type, in which case we first look - for something that will convert to a reference type. If - that fails, we will try to look for something of the - reference's target type, and then return a reference to that. */ -tree -build_type_conversion (code, xtype, expr, for_sure) - enum tree_code code; - tree xtype, expr; - int for_sure; -{ - /* C++: check to see if we can convert this aggregate type - into the required scalar type. */ - tree type, type_default; - tree typename = build_typename_overload (xtype), *typenames; - int n_variants = 0; - tree basetype, save_basetype; - tree rval; - int exact_conversion = for_sure >= 2; - for_sure &= 1; - - if (expr == error_mark_node) - return error_mark_node; - - basetype = TREE_TYPE (expr); - if (TREE_CODE (basetype) == REFERENCE_TYPE) - basetype = TREE_TYPE (basetype); - - basetype = TYPE_MAIN_VARIANT (basetype); - if (! TYPE_LANG_SPECIFIC (basetype) || ! TYPE_HAS_CONVERSION (basetype)) - return 0; - - if (TREE_CODE (xtype) == POINTER_TYPE - || TREE_CODE (xtype) == REFERENCE_TYPE) - { - /* Prepare to match a variant of this type. */ - type = TYPE_MAIN_VARIANT (TREE_TYPE (xtype)); - for (n_variants = 0; type; type = TYPE_NEXT_VARIANT (type)) - n_variants++; - typenames = (tree *)alloca (n_variants * sizeof (tree)); - for (n_variants = 0, type = TYPE_MAIN_VARIANT (TREE_TYPE (xtype)); - type; n_variants++, type = TYPE_NEXT_VARIANT (type)) - { - if (type == TREE_TYPE (xtype)) - typenames[n_variants] = typename; - else if (TREE_CODE (xtype) == POINTER_TYPE) - typenames[n_variants] = build_typename_overload (build_pointer_type (type)); - else - typenames[n_variants] = build_typename_overload (build_reference_type (type)); - } - } - - save_basetype = basetype; - type = xtype; - - while (TYPE_HAS_CONVERSION (basetype)) - { - int i; - if (lookup_fnfields (CLASSTYPE_AS_LIST (basetype), typename, 0)) - return build_type_conversion_1 (xtype, basetype, expr, typename, for_sure); - for (i = 0; i < n_variants; i++) - if (typenames[i] != typename - && lookup_fnfields (CLASSTYPE_AS_LIST (basetype), typenames[i], 0)) - return build_type_conversion_1 (xtype, basetype, expr, typenames[i], for_sure); - - if (CLASSTYPE_N_BASECLASSES (basetype)) - basetype = CLASSTYPE_BASECLASS (basetype, 1); - else break; - } - - if (TREE_CODE (type) == REFERENCE_TYPE) - { - tree first_arg = expr; - type = TYPE_MAIN_VARIANT (TREE_TYPE (type)); - basetype = save_basetype; - - /* May need to build a temporary for this. */ - while (TYPE_HAS_CONVERSION (basetype)) - { - if (lookup_fnfields (CLASSTYPE_AS_LIST (basetype), typename, 0)) - { - int flags; - - if (for_sure == 0) - { - if (! lvalue_p (expr)) - first_arg = build1 (NOP_EXPR, TYPE_POINTER_TO (basetype), integer_zero_node); - flags = LOOKUP_PROTECT; - } - else - flags = LOOKUP_NORMAL; - rval = build_method_call (first_arg, typename, NULL_TREE, NULL_TREE, flags); - if (rval == error_mark_node) - { - if (for_sure == 0) - return NULL_TREE; - return error_mark_node; - } - TREE_VALUE (TREE_OPERAND (rval, 1)) = expr; - - if (IS_AGGR_TYPE (type)) - { - tree init = build_method_call (NULL_TREE, DECL_NAME (TYPE_NAME (type)), build_tree_list (NULL_TREE, rval), NULL_TREE, LOOKUP_NORMAL); - tree temp = build_cplus_new (type, init); - return build_up_reference (TYPE_REFERENCE_TO (type), temp, 0); - } - return convert (xtype, rval); - } - if (CLASSTYPE_N_BASECLASSES (basetype)) - basetype = CLASSTYPE_BASECLASS (basetype, 1); - else break; - } - /* No free conversions for reference types, right?. */ - return NULL_TREE; - } - - if (exact_conversion) - return NULL_TREE; - - /* No perfect match found, try default. */ - if (code == CONVERT_EXPR && TREE_CODE (type) == POINTER_TYPE) - type_default = ptr_type_node; - else if (type == void_type_node) - return NULL_TREE; - else - { - extern tree default_conversion (); - tree tmp = default_conversion (build1 (NOP_EXPR, type, integer_zero_node)); - if (tmp == error_mark_node) - return NULL_TREE; - type_default = TREE_TYPE (tmp); - } - - basetype = save_basetype; - - if (type_default != type) - { - type = type_default; - typename = build_typename_overload (type); - - while (TYPE_HAS_CONVERSION (basetype)) - { - if (lookup_fnfields (CLASSTYPE_AS_LIST (basetype), typename, 0)) - return build_type_conversion_1 (xtype, basetype, expr, typename, for_sure); - if (CLASSTYPE_N_BASECLASSES (basetype)) - basetype = CLASSTYPE_BASECLASS (basetype, 1); - else break; - } - } - - try_pointer: - - if (type == ptr_type_node) - { - /* Try converting to some other pointer type - with which void* is compatible, or in situations - in which void* is appropriate (such as &&,||, and !). */ - - while (TYPE_HAS_CONVERSION (basetype)) - { - if (CLASSTYPE_CONVERSION (basetype, ptr_conv) != 0) - { - if (CLASSTYPE_CONVERSION (basetype, ptr_conv) == error_mark_node) - return error_mark_node; - typename = DECL_ORIGINAL_NAME (CLASSTYPE_CONVERSION (basetype, ptr_conv)); - return build_type_conversion_1 (xtype, basetype, expr, typename, for_sure); - } - if (CLASSTYPE_N_BASECLASSES (basetype)) - basetype = CLASSTYPE_BASECLASS (basetype, 1); - else break; - } - } - if (TREE_CODE (type) == POINTER_TYPE - && TREE_READONLY (TREE_TYPE (type)) - && TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node) - { - /* Try converting to some other pointer type - with which const void* is compatible. */ - - while (TYPE_HAS_CONVERSION (basetype)) - { - if (CLASSTYPE_CONVERSION (basetype, constptr_conv) != 0) - { - if (CLASSTYPE_CONVERSION (basetype, constptr_conv) == error_mark_node) - return error_mark_node; - typename = DECL_ORIGINAL_NAME (CLASSTYPE_CONVERSION (basetype, constptr_conv)); - return build_type_conversion_1 (xtype, basetype, expr, typename, for_sure); - } - if (CLASSTYPE_N_BASECLASSES (basetype)) - basetype = CLASSTYPE_BASECLASS (basetype, 1); - else break; - } - } - /* Use the longer or shorter conversion that is appropriate. */ - if (TREE_CODE (type) == INTEGER_TYPE - && TYPE_HAS_INT_CONVERSION (basetype) - && CLASSTYPE_CONVERSION (basetype, int_conv) != error_mark_node) - { - typename = DECL_ORIGINAL_NAME (CLASSTYPE_CONVERSION (basetype, int_conv)); - return build_type_conversion_1 (xtype, basetype, expr, typename, for_sure); - } - if (TREE_CODE (type) == REAL_TYPE - && TYPE_HAS_REAL_CONVERSION (basetype) - && CLASSTYPE_CONVERSION (basetype, real_conv) != error_mark_node) - { - typename = DECL_ORIGINAL_NAME (CLASSTYPE_CONVERSION (basetype, real_conv)); - return build_type_conversion_1 (xtype, basetype, expr, typename, for_sure); - } - - /* THIS IS A KLUDGE. */ - if (TREE_CODE (type) != POINTER_TYPE - && (code == TRUTH_ANDIF_EXPR - || code == TRUTH_ORIF_EXPR - || code == TRUTH_NOT_EXPR)) - { - /* Here's when we can convert to a pointer. */ - type = ptr_type_node; - goto try_pointer; - } - - /* THESE ARE TOTAL KLUDGES. */ - /* Default promotion yields no new alternatives, try - conversions which are anti-default, such as - - double -> float or int -> unsigned or unsigned -> long - - */ - if (type_default == type) - { - int not_again = 0; - - if (type == double_type_node) - typename = build_typename_overload (float_type_node); - else if (type == integer_type_node) - typename = build_typename_overload (unsigned_type_node); - else if (type == unsigned_type_node) - typename = build_typename_overload (long_integer_type_node); - - again: - basetype = save_basetype; - while (TYPE_HAS_CONVERSION (basetype)) - { - if (lookup_fnfields (CLASSTYPE_AS_LIST (basetype), typename, 0)) - return build_type_conversion_1 (xtype, basetype, expr, typename, for_sure); - if (CLASSTYPE_N_BASECLASSES (basetype)) - basetype = CLASSTYPE_BASECLASS (basetype, 1); - else break; - } - if (! not_again && type == integer_type_node) - { - typename = build_typename_overload (long_integer_type_node); - not_again = 1; - goto again; - } - } - - /* Now, try C promotions... - - float -> int - int -> float, void * - void * -> int - - Truthvalue conversions let us try to convert - to pointer if we were going for int, and to int - if we were looking for pointer. */ - - basetype = save_basetype; - if (TREE_CODE (type) == REAL_TYPE - || (TREE_CODE (type) == POINTER_TYPE - && (code == TRUTH_ANDIF_EXPR - || code == TRUTH_ORIF_EXPR - || code == TRUTH_NOT_EXPR))) - type = integer_type_node; - else if (TREE_CODE (type) == INTEGER_TYPE) - if (TYPE_HAS_REAL_CONVERSION (basetype)) - type = double_type_node; - else - return NULL_TREE; - else - return NULL_TREE; - - typename = build_typename_overload (type); - while (TYPE_HAS_CONVERSION (basetype)) - { - if (lookup_fnfields (CLASSTYPE_AS_LIST (basetype), typename, 0)) - { - rval = build_type_conversion_1 (xtype, basetype, expr, typename, for_sure); - return rval; - } - if (CLASSTYPE_N_BASECLASSES (basetype)) - basetype = CLASSTYPE_BASECLASS (basetype, 1); - else - break; - } - - return NULL_TREE; -} - -/* Must convert two aggregate types to non-aggregate type. - Attempts to find a non-ambiguous, "best" type conversion. - - Return 1 on success, 0 on failure. - - @@ What are the real semantics of this supposed to be??? */ -int -build_default_binary_type_conversion (code, arg1, arg2) - enum tree_code code; - tree *arg1, *arg2; -{ - tree type1 = TREE_TYPE (*arg1); - tree type2 = TREE_TYPE (*arg2); - char *name1, *name2; - - if (TREE_CODE (type1) == REFERENCE_TYPE) - type1 = TREE_TYPE (type1); - if (TREE_CODE (type2) == REFERENCE_TYPE) - type2 = TREE_TYPE (type2); - - if (TREE_CODE (TYPE_NAME (type1)) != TYPE_DECL) - { - tree decl = typedecl_for_tag (type1); - if (decl) - error ("type conversion nonexistant for type `%s'", - IDENTIFIER_POINTER (DECL_NAME (decl))); - else - error ("type conversion nonexistant for non-C++ type"); - return 0; - } - if (TREE_CODE (TYPE_NAME (type2)) != TYPE_DECL) - { - tree decl = typedecl_for_tag (type2); - if (decl) - error ("type conversion nonexistant for type `%s'", - IDENTIFIER_POINTER (decl)); - else - error ("type conversion nonexistant for non-C++ type"); - return 0; - } - - name1 = TYPE_NAME_STRING (type1); - name2 = TYPE_NAME_STRING (type2); - - if (! TYPE_HAS_CONVERSION (type1)) - { - if (! TYPE_HAS_CONVERSION (type2)) - error ("type conversion required for binary operation on types `%s' and `%s'", - name1, name2); - else - error ("type conversion required for type `%s'", name1); - return 0; - } - else if (! TYPE_HAS_CONVERSION (type2)) - { - error ("type conversion required for type `%s'", name2); - return 0; - } - - if (TYPE_HAS_INT_CONVERSION (type1) && TYPE_HAS_REAL_CONVERSION (type1)) - warning ("ambiguous type conversion for type `%s', defaulting to int", name1); - if (TYPE_HAS_INT_CONVERSION (type1)) - { - *arg1 = build_type_conversion (code, integer_type_node, *arg1, 1); - *arg2 = build_type_conversion (code, integer_type_node, *arg2, 1); - } - else if (TYPE_HAS_REAL_CONVERSION (type1)) - { - *arg1 = build_type_conversion (code, double_type_node, *arg1, 1); - *arg2 = build_type_conversion (code, double_type_node, *arg2, 1); - } - else - { - *arg1 = build_type_conversion (code, ptr_type_node, *arg1, 1); - if (*arg1 == error_mark_node) - error ("ambiguous pointer conversion"); - *arg2 = build_type_conversion (code, ptr_type_node, *arg2, 1); - if (*arg1 != error_mark_node && *arg2 == error_mark_node) - error ("ambiguous pointer conversion"); - } - if (*arg1 == 0) - { - if (*arg2 == 0 && type1 != type2) - error ("default type conversion for types `%s' and `%s' failed", - name1, name2); - else - error ("default type conversion for type `%s' failed", name1); - return 0; - } - else if (*arg2 == 0) - { - error ("default type conversion for type `%s' failed", name2); - return 0; - } - return 1; -} - -/* Must convert two aggregate types to non-aggregate type. - Attempts to find a non-ambiguous, "best" type conversion. - - Return 1 on success, 0 on failure. - - The type of the argument is expected to be of aggregate type here. - - @@ What are the real semantics of this supposed to be??? */ -int -build_default_unary_type_conversion (code, arg) - enum tree_code code; - tree *arg; -{ - tree type = TREE_TYPE (*arg); - tree id = TREE_CODE (TYPE_NAME (type)) == TYPE_DECL - ? DECL_NAME (TYPE_NAME (type)) : TYPE_NAME (type); - char *name = IDENTIFIER_POINTER (id); - - if (! TYPE_HAS_CONVERSION (type)) - { - error ("type conversion required for type `%s'", name); - return 0; - } - - if (TYPE_HAS_INT_CONVERSION (type) && TYPE_HAS_REAL_CONVERSION (type)) - warning ("ambiguous type conversion for type `%s', defaulting to int", name); - if (TYPE_HAS_INT_CONVERSION (type)) - *arg = build_type_conversion (code, integer_type_node, *arg, 1); - else if (TYPE_HAS_REAL_CONVERSION (type)) - *arg = build_type_conversion (code, double_type_node, *arg, 1); - else - { - *arg = build_type_conversion (code, ptr_type_node, *arg, 1); - if (*arg == error_mark_node) - error ("ambiguous pointer conversion"); - } - if (*arg == 0) - { - error ("default type conversion for type `%s' failed", name); - return 0; - } - return 1; -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-decl.c b/gnu/usr.bin/g++/cc1plus/cplus-decl.c deleted file mode 100644 index 287d8d7f7b7b..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-decl.c +++ /dev/null @@ -1,8825 +0,0 @@ -/* Process declarations and variables for C compiler. - Copyright (C) 1988 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* Process declarations and symbol lookup for C front end. - Also constructs types; the standard scalar types at initialization, - and structure, union, array and enum types when they are declared. */ - -/* ??? not all decl nodes are given the most useful possible - line numbers. For example, the CONST_DECLs for enum values. */ -/* - * - * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE - * -------------------- ----- ---------------------- - * CURRENT PATCH LEVEL: 1 00056 - * -------------------- ----- ---------------------- - * - * 27 Nov 1992 James Clark Fixed memory bug in g++ - */ - -#include "config.h" -#include "tree.h" -#include "flags.h" -#include "cplus-tree.h" -#include "cplus-parse.h" -#include -#include "assert.h" -#include "obstack.h" -#include "rtl.h" -#include "insn-flags.h" - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -extern int xmalloc (); -extern void free (); - -/* Define this if C structs should have gratuitous typedefing - done just like C++ structs do. */ -#define BREAK_C_TAGS - -/* Stack of places to restore the search obstack back to. */ - -/* Obstack used for remembering local class declarations (like - enums and static (const) members. */ -#include "stack.h" -static struct obstack decl_obstack; -static struct stack_level *decl_stack; - -#include "cplus-decl.h" - -#define NULL 0 -#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) -#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) - -#ifndef CHAR_TYPE_SIZE -#define CHAR_TYPE_SIZE BITS_PER_UNIT -#endif - -#ifndef SHORT_TYPE_SIZE -#define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2)) -#endif - -#ifndef INT_TYPE_SIZE -#define INT_TYPE_SIZE BITS_PER_WORD -#endif - -#ifndef LONG_TYPE_SIZE -#define LONG_TYPE_SIZE BITS_PER_WORD -#endif - -#ifndef LONG_LONG_TYPE_SIZE -#define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2) -#endif - -#ifndef FLOAT_TYPE_SIZE -#define FLOAT_TYPE_SIZE BITS_PER_WORD -#endif - -#ifndef DOUBLE_TYPE_SIZE -#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2) -#endif - -#ifndef LONG_DOUBLE_TYPE_SIZE -#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2) -#endif - -static tree grokparms (); -tree grokdeclarator (); -tree pushdecl (); -void push_overloaded_decl (); -void pop_implicit_try_blocks (); - -#define builtin_function(NAME, TYPE, CODE) \ - define_function (NAME, TYPE, CODE, (void (*)())&pushdecl) -#define auto_function(NAME, TYPE, CODE) \ - define_function (NAME, TYPE, CODE, (void (*)())&push_overloaded_decl) - -/* static */ void grokclassfn (); -/* static */ tree grokopexpr (), grokoptypename (); - -static tree lookup_tag (); -static tree lookup_tag_reverse (); -static tree lookup_name_current_level (); -static char *redeclaration_error_message (); -static int parmlist_is_exprlist (); -static int parmlist_is_random (); -static void grok_ctor_properties (); -static void grok_op_properties (); -static void expand_static_init (); -static void deactivate_exception_cleanups (); - -tree finish_table (); -#ifdef FIELD_XREF -static void FIELD_end_scope(); -#endif - -/* a node which has tree code ERROR_MARK, and whose type is itself. - All erroneous expressions are replaced with this node. All functions - that accept nodes as arguments should avoid generating error messages - if this node is one of the arguments, since it is undesirable to get - multiple error messages from one error in the input. */ - -#undef error_mark_node -tree error_mark_node; -#define error_mark_node (&ERROR_MARK_NODE) - -/* Erroneous argument lists can use this *IFF* they do not modify it. */ -tree error_mark_list; - -/* INTEGER_TYPE and REAL_TYPE nodes for the standard data types */ - -tree short_integer_type_node; -tree integer_type_node; -tree long_integer_type_node; -tree long_long_integer_type_node; - -tree short_unsigned_type_node; -tree unsigned_type_node; -tree long_unsigned_type_node; -tree long_long_unsigned_type_node; - -tree unsigned_char_type_node; -tree signed_char_type_node; -tree char_type_node; - -tree float_type_node; -tree double_type_node; -tree long_double_type_node; - -/* a VOID_TYPE node, and the same, packaged in a TREE_LIST. */ - -tree void_type_node, void_list_node; - -/* A node for type `void *'. */ - -tree ptr_type_node; - -/* A node for type `char *'. */ - -tree string_type_node; - -/* Type `char[256]' or something like it. - Used when an array of char is needed and the size is irrelevant. */ - -tree char_array_type_node; - -/* Type `int[256]' or something like it. - Used when an array of int needed and the size is irrelevant. */ - -tree int_array_type_node; - -/* type `int ()' -- used for implicit declaration of functions. */ - -tree default_function_type; - -/* function types `double (double)' and `double (double, double)', etc. */ - -tree double_ftype_double, double_ftype_double_double; -tree int_ftype_int, long_ftype_long; - -/* Function type `void (void *, void *, int)' and similar ones. */ - -tree void_ftype_ptr_ptr_int, int_ftype_ptr_ptr_int, void_ftype_ptr_int_int; - -/* C++ extensions */ -tree vtable_entry_type; -tree class_type_node, record_type_node, union_type_node, enum_type_node; -tree exception_type_node, unknown_type_node; - -/* Function type `void * (long)', 'void (void *)' */ -tree ptr_ftype_long, void_ftype_ptr; -tree ptr_ftype_ptr_int_int_ptr, void_ftype_ptr_int_int_ptr_int_int; - -/* Used for virtual function tables. */ -tree vtbl_mask; - -/* Array type `(void *)[]' */ -tree vtbl_type_node; - -#ifdef SOS -/* SOS extensions. */ -tree zlink_type, zret_type; -tree zlink, zret; -#endif - -/* Static decls which do not have static initializers have no - initializers as far as GNU C is concerned. EMPTY_INIT_NODE - is a static initializer which makes varasm code place the decl - in data rather than in bss space. Such gymnastics are necessary - to avoid the problem that the linker will not include a library - file if all the library appears to contribute are bss variables. */ - -tree empty_init_node; - -/* In a destructor, the point at which all derived class destroying - has been done, just before any base class destroying will be done. */ - -tree dtor_label; - -/* In a constructor, the point at which we are ready to return - the pointer to the initialized object. */ - -tree ctor_label; - -/* A FUNCTION_DECL which can call `unhandled_exception'. - Not neccessarily the one that the user will declare, - but sufficient to be called by routines that want to abort the program. */ - -tree unhandled_exception_fndecl; - -/* A FUNCTION_DECL which can call `abort'. Not neccessarily the - one that the user will declare, but sufficient to be called - by routines that want to abort the program. */ - -tree abort_fndecl; - -/* -- end of C++ */ - -/* Two expressions that are constants with value zero. - The first is of type `int', the second of type `void *'. */ - -tree integer_zero_node; -tree null_pointer_node; - -/* A node for the integer constants 1, 2, and 3. */ - -tree integer_one_node, integer_two_node, integer_three_node; - -/* An identifier whose name is . This is used as the "name" - of the RESULT_DECLs for values of functions. */ - -tree value_identifier; - -/* If original DECL_RESULT of current function was a register, - but due to being an addressable named return value, would up - on the stack, this variable holds the named return value's - original location. */ -struct rtx_def *original_result_rtx; - -/* Sequence of insns which represents base initialization. */ -struct rtx_def *base_init_insns; - -/* C++: Keep these around to reduce calls to `get_identifier'. - Identifiers for `this' in member functions and the auto-delete - parameter for destructors. */ -tree this_identifier, in_charge_identifier; - -/* While defining an enum type, this is 1 plus the last enumerator - constant value. */ - -static tree enum_next_value; - -/* Parsing a function declarator leaves a list of parameter names - or a chain or parameter decls here. */ - -tree last_function_parms; - -/* Parsing a function declarator leaves here a chain of structure - and enum types declared in the parmlist. */ - -static tree last_function_parm_tags; - -/* After parsing the declarator that starts a function definition, - `start_function' puts here the list of parameter names or chain of decls. - `store_parm_decls' finds it here. */ - -static tree current_function_parms; - -/* Similar, for last_function_parm_tags. */ -static tree current_function_parm_tags; - -/* A list (chain of TREE_LIST nodes) of all LABEL_STMTs in the function - that have names. Here so we can clear out their names' definitions - at the end of the function. */ - -static tree named_labels; - -/* A list (chain of TREE_LIST nodes) of named label uses. - The TREE_PURPOSE field is the list of variables defined - the the label's scope defined at the point of use. - The TREE_VALUE field is the LABEL_DECL used. - The TREE_TYPE field holds `current_binding_level' at the - point of the label's use. - - Used only for jumps to as-yet undefined labels, since - jumps to defined labels can have their validity checked - by stmt.c. */ - -static tree named_label_uses; - -/* A list of objects which have constructors or destructors - which reside in the global scope. The decl is stored in - the TREE_VALUE slot and the initializer is stored - in the TREE_PURPOSE slot. */ -tree static_aggregates; - -/* A list of functions which were declared inline, but later had their - address taken. Used only for non-virtual member functions, since we can - find other functions easily enough. */ -tree pending_addressable_inlines; - -/* A list of overloaded functions which we should forget ever - existed, such as functions declared in a function's scope, - once we leave that function's scope. */ -static tree overloads_to_forget; - -/* The FUNCTION_DECL for the function currently being compiled, - or 0 if between functions. */ -tree current_function_decl; - -/* Set to 0 at beginning of a function definition, set to 1 if - a return statement that specifies a return value is seen. */ - -int current_function_returns_value; - -/* Set to 0 at beginning of a function definition, set to 1 if - a return statement with no argument is seen. */ - -int current_function_returns_null; - -/* Set to nonzero by `grokdeclarator' for a function - whose return type is defaulted, if warnings for this are desired. */ - -static int warn_about_return_type; - -/* Nonzero when starting a function delcared `extern inline'. */ - -static int current_extern_inline; - -char *language_string = "GNU C++"; - -/* Set to 0 at beginning of a constructor, set to 1 - if that function does an allocation before referencing its - instance variable. */ -int current_function_assigns_this; -int current_function_just_assigned_this; - -/* Set to 0 at beginning of a function. Set non-zero when - store_parm_decls is called. Don't call store_parm_decls - if this flag is non-zero! */ -int current_function_parms_stored; - -/* Allocate a level of searching. */ -struct stack_level * -push_decl_level (stack, obstack) - struct stack_level *stack; - struct obstack *obstack; -{ - struct stack_level tem; - tem.prev = stack; - - return push_stack_level (obstack, &tem, sizeof (tem)); -} - -/* Discard a level of decl allocation. */ - -static struct stack_level * -pop_decl_level (stack) - struct stack_level *stack; -{ - tree *bp, *tp; - struct obstack *obstack = stack->obstack; - bp = stack->first; - tp = (tree *)obstack_next_free (obstack); - while (tp != bp) - { - --tp; - IDENTIFIER_CLASS_VALUE (DECL_NAME (*tp)) = NULL_TREE; - } - return pop_stack_level (stack); -} - -/* For each binding contour we allocate a binding_level structure - * which records the names defined in that contour. - * Contours include: - * 0) the global one - * 1) one for each function definition, - * where internal declarations of the parameters appear. - * 2) one for each compound statement, - * to record its declarations. - * - * The current meaning of a name can be found by searching the levels from - * the current one out to the global one. - * - * Off to the side, may be the class_binding_level. This exists - * only to catch class-local declarations. It is otherwise - * nonexistent. - * - * Also there may be binding levels that catch cleanups that - * must be run when exceptions occur. - */ - -/* Note that the information in the `names' component of the global contour - is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers. */ - -struct binding_level - { - /* A chain of _DECL nodes for all variables, constants, functions, - * and typedef types. These are in the reverse of the order supplied. - */ - tree names; - - /* A list of structure, union and enum definitions, - * for looking up tag names. - * It is a chain of TREE_LIST nodes, each of whose TREE_PURPOSE is a name, - * or NULL_TREE; and whose TREE_VALUE is a RECORD_TYPE, UNION_TYPE, - * or ENUMERAL_TYPE node. - * - * C++: the TREE_VALUE nodes can be simple types for component_bindings. - * - */ - tree tags; - - /* For each level, a list of shadowed outer-level local definitions - to be restored when this level is popped. - Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and - whose TREE_VALUE is its old definition (a kind of ..._DECL node). */ - tree shadowed; - - /* Same, for IDENTIFIER_CLASS_VALUE. */ - tree class_shadowed; - - /* For each level (except not the global one), - a chain of LET_STMT nodes for all the levels - that were entered and exited one level down. */ - tree blocks; - - /* The binding level which this one is contained in (inherits from). */ - struct binding_level *level_chain; - - /* Number of decls in `names' that have incomplete - structure or union types. */ - unsigned short n_incomplete; - - /* 1 for the level that holds the parameters of a function. - 2 for the level that holds a class declaration. - 3 for levels that hold parameter declarations. */ - unsigned parm_flag : 4; - - /* 1 means make a LET_STMT for this level regardless of all else. - 2 for temporary binding contours created by the compiler. */ - unsigned keep : 3; - - /* Nonzero if this level "doesn't exist" for tags. */ - unsigned tag_transparent : 1; - - /* Nonzero if this level can safely have additional - cleanup-needing variables added to it. */ - unsigned more_cleanups_ok : 1; - unsigned have_cleanups : 1; - - /* Nonzero if this level can safely have additional - exception-raising statements added to it. */ - unsigned more_exceptions_ok : 1; - unsigned have_exceptions : 1; - - /* Four bits left for this word. */ - }; - -#define NULL_BINDING_LEVEL (struct binding_level *) NULL - -/* The binding level currently in effect. */ - -static struct binding_level *current_binding_level; - -/* The binding level of the current class, if any. */ - -static struct binding_level *class_binding_level; - -/* A chain of binding_level structures awaiting reuse. */ - -static struct binding_level *free_binding_level; - -/* The outermost binding level, for names of file scope. - This is created when the compiler is started and exists - through the entire run. */ - -static struct binding_level *global_binding_level; - -/* Binding level structures are initialized by copying this one. */ - -static struct binding_level clear_binding_level; - -/* Nonzero means unconditionally make a LET_STMT for the next level pushed. */ - -static int keep_next_level_flag; - -#define PUSH_BINDING_LEVEL(NEWLEVEL, TAG_TRANSPARENT, KEEP) \ -do { \ - /* Add this level to the front of the chain (stack) of levels that \ - are active. */ \ - *NEWLEVEL = clear_binding_level; \ - if (class_binding_level) \ - { \ - NEWLEVEL->level_chain = class_binding_level; \ - class_binding_level = 0; \ - } \ - else \ - { \ - NEWLEVEL->level_chain = current_binding_level; \ - } \ - current_binding_level = NEWLEVEL; \ - NEWLEVEL->tag_transparent = TAG_TRANSPARENT; \ - NEWLEVEL->more_cleanups_ok = 1; \ - NEWLEVEL->more_exceptions_ok = 1; \ - NEWLEVEL->keep = KEEP; \ -} while (0) - -#define POP_BINDING_LEVEL \ -do { \ - /* Pop the current level, and free the structure for reuse. */ \ - { \ - register struct binding_level *level = current_binding_level; \ - current_binding_level = current_binding_level->level_chain; \ - level->level_chain = free_binding_level; \ - free_binding_level = level; \ - if (current_binding_level->parm_flag == 2) \ - { \ - class_binding_level = current_binding_level; \ - do \ - { \ - current_binding_level = current_binding_level->level_chain; \ - } \ - while (current_binding_level->parm_flag == 2); \ - } \ - } \ -} while (0) - -/* Create a new `struct binding_level'. */ - -static -struct binding_level * -make_binding_level () -{ - /* NOSTRICT */ - return (struct binding_level *) xmalloc (sizeof (struct binding_level)); -} - -/* Nonzero if we are currently in the global binding level. */ - -int -global_bindings_p () -{ - return current_binding_level == global_binding_level; -} - -void -keep_next_level () -{ - keep_next_level_flag = 1; -} - -/* Identify this binding level as a level of parameters. */ - -void -declare_parm_level () -{ - current_binding_level->parm_flag = 1; -} - -/* Identify this binding level as a level of a default exception handler. */ - -void -declare_implicit_exception () -{ - current_binding_level->parm_flag = 3; -} - -/* Nonzero if current binding contour contains expressions - that might raise exceptions. */ - -int -have_exceptions_p () -{ - return current_binding_level->have_exceptions; -} - -/* Enter a new binding level. - If TAG_TRANSPARENT is nonzero, do so only for the name space of variables, - not for that of tags. */ - -void -pushlevel (tag_transparent) - int tag_transparent; -{ - register struct binding_level *newlevel = NULL_BINDING_LEVEL; - - /* If this is the top level of a function, - just make sure that NAMED_LABELS is 0. - They should have been set to 0 at the end of the previous function. */ - - if (current_binding_level == global_binding_level) - assert (named_labels == NULL_TREE); - - /* Reuse or create a struct for this binding level. */ - - if (free_binding_level) - { - newlevel = free_binding_level; - free_binding_level = free_binding_level->level_chain; - } - else - { - newlevel = make_binding_level (); - } - PUSH_BINDING_LEVEL (newlevel, tag_transparent, keep_next_level_flag); -#ifdef FIELD_XREF - FIELD_xref_start_scope(newlevel); -#endif - keep_next_level_flag = 0; -} - -void -pushlevel_temporary (tag_transparent) - int tag_transparent; -{ - pushlevel (tag_transparent); - current_binding_level->keep = 2; - clear_last_expr (); -#if 0 - /* Don't call push_momentary here! It will cause cleanups - to be allocated on the momentary obstack, and they - will be overwritten by the next statement. */ - push_momentary (); -#endif - expand_start_bindings (0); -} - -/* Exit a binding level. - Pop the level off, and restore the state of the identifier-decl mappings - that were in effect when this level was entered. - - If KEEP == 1, this level had explicit declarations, so - and create a "block" (a LET_STMT node) for the level - to record its declarations and subblocks for symbol table output. - - If KEEP == 2, this level's subblocks go to the front, - not the back of the current binding level. This happens, - for instance, when code for constructors and destructors - need to generate code at the end of a function which must - be moved up to the front of the function. - - If FUNCTIONBODY is nonzero, this level is the body of a function, - so create a block as if KEEP were set and also clear out all - label names. - - If REVERSE is nonzero, reverse the order of decls before putting - them into the LET_STMT. */ - -tree -poplevel (keep, reverse, functionbody) - int keep; - int reverse; - int functionbody; -{ - register tree link; - /* The chain of decls was accumulated in reverse order. - Put it into forward order, just for cleanliness. */ - tree decls; - int tmp = functionbody; - int implicit_try_block = current_binding_level->parm_flag == 3; - int real_functionbody = current_binding_level->keep == 2 - ? ((functionbody = 0), tmp) : functionbody; - tree tags = functionbody >= 0 ? current_binding_level->tags : 0; - tree subblocks = functionbody >= 0 ? current_binding_level->blocks : 0; - tree block = 0; - -#ifdef FIELD_XREF - FIELD_xref_end_scope(current_binding_level, - current_binding_level->level_chain, - current_binding_level->parm_flag, - current_binding_level->keep, - current_binding_level->tag_transparent); -#endif - - if (current_binding_level->keep == 1) - keep = 1; - - /* This warning is turned off because it causes warnings for - declarations like `extern struct foo *x'. */ -#if 0 - /* Warn about incomplete structure types in this level. */ - for (link = tags; link; link = TREE_CHAIN (link)) - if (TYPE_SIZE (TREE_VALUE (link)) == 0) - { - tree type = TREE_VALUE (link); - char *errmsg; - switch (TREE_CODE (type)) - { - case RECORD_TYPE: - errmsg = "`struct %s' incomplete in scope ending here"; - break; - case UNION_TYPE: - errmsg = "`union %s' incomplete in scope ending here"; - break; - case ENUMERAL_TYPE: - errmsg = "`enum %s' incomplete in scope ending here"; - break; - } - if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) - error (errmsg, IDENTIFIER_POINTER (TYPE_NAME (type))); - else - /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL. */ - error (errmsg, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)))); - } -#endif /* 0 */ - - /* Get the decls in the order they were written. - Usually current_binding_level->names is in reverse order. - But parameter decls were previously put in forward order. */ - - if (reverse) - current_binding_level->names - = decls = nreverse (current_binding_level->names); - else - decls = current_binding_level->names; - - /* If there were any declarations or structure tags in that level, - or if this level is a function body, - create a LET_STMT to record them for the life of this function. */ - - if (keep == 1 || functionbody > 0) - block = build_let (0, 0, keep ? decls : 0, - subblocks, 0, keep ? tags : 0); - - /* In each subblock, record that this is its superior. */ - - if (keep >= 0) - for (link = subblocks; link; link = TREE_CHAIN (link)) - STMT_SUPERCONTEXT (link) = block; - - /* Clear out the meanings of the local variables of this level; - also record in each decl which block it belongs to. */ - - for (link = decls; link; link = TREE_CHAIN (link)) - { - if (DECL_NAME (link) != 0) - IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = 0; - DECL_CONTEXT (link) = block; - } - - /* Restore all name-meanings of the outer levels - that were shadowed by this level. */ - - for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link)) - IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); - for (link = current_binding_level->class_shadowed; - link; - link = TREE_CHAIN (link)) - IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); - - /* If the level being exited is the top level of a function, - check over all the labels. */ - - if (functionbody) - { - /* Clear out the definitions of all label names, - since their scopes end here. */ - - for (link = named_labels; link; link = TREE_CHAIN (link)) - { - if (DECL_SOURCE_LINE (TREE_VALUE (link)) == 0) - { - error ("label `%s' used somewhere above but not defined", - IDENTIFIER_POINTER (DECL_NAME (TREE_VALUE (link)))); - /* Avoid crashing later. */ - define_label (input_filename, 1, DECL_NAME (TREE_VALUE (link))); - } - else if (warn_unused && !TREE_USED (TREE_VALUE (link))) - warning_with_decl (TREE_VALUE (link), - "label `%s' defined but not used"); - SET_IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link)), 0); - } - - named_labels = 0; - } - - /* Any uses of undefined labels now operate under constraints - of next binding contour. */ - { - struct binding_level *level_chain; - level_chain = current_binding_level->level_chain; - if (level_chain) - { - tree labels; - for (labels = named_label_uses; labels; labels = TREE_CHAIN (labels)) - if (TREE_TYPE (labels) == (tree)current_binding_level) - { - TREE_TYPE (labels) = (tree)level_chain; - TREE_PURPOSE (labels) = level_chain->names; - } - } - } - - tmp = current_binding_level->keep; - - POP_BINDING_LEVEL; - if (functionbody > 0) - { - DECL_INITIAL (current_function_decl) = block; - /* If this is the top level block of a function, - the vars are the function's parameters. - Don't leave them in the LET_STMT because they are - found in the FUNCTION_DECL instead. */ - STMT_VARS (block) = 0; - } - else if (block) - current_binding_level->blocks - = chainon (current_binding_level->blocks, block); - /* If we did not make a block for the level just exited, - any blocks made for inner levels - (since they cannot be recorded as subblocks in that level) - must be carried forward so they will later become subblocks - of something else. */ - else if (subblocks) - if (keep == 2) - current_binding_level->blocks = chainon (subblocks, current_binding_level->blocks); - else - current_binding_level->blocks - = chainon (current_binding_level->blocks, subblocks); - - /* Take care of compiler's internal binding structures. */ - if (tmp == 2 && !implicit_try_block) - { -#if 0 - /* We did not call push_momentary for this - binding contour, so there is nothing to pop. */ - pop_momentary (); -#endif - expand_end_bindings (getdecls (), keep, 1); - block = poplevel (keep, reverse, real_functionbody); - } - if (block) - TREE_USED (block) = 1; - return block; -} - -/* Add BLOCK to the current list of blocks for this binding contour. */ -void -add_block_current_level (block) - tree block; -{ - current_binding_level->blocks - = chainon (current_binding_level->blocks, block); -} - -/* Do a pushlevel for class declarations. */ -void -pushlevel_class () -{ - pushlevel (0); - decl_stack = push_decl_level (decl_stack, &decl_obstack); - class_binding_level = current_binding_level; - class_binding_level->parm_flag = 2; - do - { - current_binding_level = current_binding_level->level_chain; - } - while (current_binding_level->parm_flag == 2); -} - -/* ...and a poplevel for class declarations. */ -tree -poplevel_class () -{ - register struct binding_level *level = class_binding_level; - tree block = 0; - tree shadowed; - - if (level == 0) - { - while (current_binding_level && class_binding_level == 0) - block = poplevel (0, 0, 0); - if (current_binding_level == 0) - fatal ("syntax error too serious"); - level = class_binding_level; - } - decl_stack = pop_decl_level (decl_stack); - for (shadowed = level->class_shadowed; shadowed; shadowed = TREE_CHAIN (shadowed)) - IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed); - -#ifdef FIELD_XREF - FIELD_xref_end_scope(class_binding_level, - class_binding_level->level_chain, - class_binding_level->parm_flag, - class_binding_level->keep, - class_binding_level->tag_transparent); -#endif - - class_binding_level = level->level_chain; - - level->level_chain = free_binding_level; - free_binding_level = level; - if (class_binding_level->parm_flag != 2) - class_binding_level = 0; - return block; -} - -/* Push a definition of struct, union or enum tag "name". - "type" should be the type node. - We assume that the tag "name" is not already defined. - - Note that the definition may really be just a forward reference. - In that case, the TYPE_SIZE will be zero. - - C++ gratuitously puts all these tags in the name space. */ - -void -pushtag (name, type) - tree name, type; -{ - register struct binding_level *b; - - if (class_binding_level) - b = class_binding_level; - else - { - b = current_binding_level; - while (b->tag_transparent) b = b->level_chain; - } - - if (name) - { - /* Record the identifier as the type's name if it has none. */ - - if (TYPE_NAME (type) == 0) - TYPE_NAME (type) = name; - - if (b == global_binding_level) - b->tags = perm_tree_cons (name, type, b->tags); - else - b->tags = saveable_tree_cons (name, type, b->tags); - - /* Do C++ gratuitous typedefing. Note that we put the - TYPE_DECL in the TREE_TYPE of the IDENTIFIER_NODE. */ - if (TREE_TYPE (name) != TYPE_NAME (type) -#ifndef BREAK_C_TAGS - /* This *should* only happen in C++ language scope. - But everybody else seems to think otherwise. */ - && current_lang_name == lang_name_cplusplus -#endif - && (TREE_CODE (type) != RECORD_TYPE - || class_binding_level == 0 - || !CLASSTYPE_DECLARED_EXCEPTION (type))) - { - register tree t = build_decl (TYPE_DECL, name, type); - if (!TREE_NONLOCAL (type)) - t = pushdecl (t); - TYPE_NAME (type) = t; - TREE_TYPE (name) = t; - } - if (b->parm_flag == 2) - { - TREE_NONLOCAL (type) = 1; - IDENTIFIER_CLASS_VALUE (name) = TYPE_NAME (type); - CLASSTYPE_TAGS (current_class_type) = b->tags; - } - } -} - -/* Subroutine of duplicate_decls: return truthvalue of whether - or not types of these decls match. */ -static int -decls_match (newdecl, olddecl) - tree newdecl, olddecl; -{ - int types_match; - - if (TREE_CODE (newdecl) == FUNCTION_DECL && TREE_CODE (olddecl) == FUNCTION_DECL) - { - tree f1 = TREE_TYPE (newdecl); - tree f2 = TREE_TYPE (olddecl); - tree p1 = TYPE_ARG_TYPES (f1); - tree p2 = TYPE_ARG_TYPES (f2); - - /* When we parse a static member function definition, - we put together a FUNCTION_DECL which thinks its type - is METHOD_TYPE. Change that to FUNCTION_TYPE, and - proceed. */ - if (TREE_CODE (f1) == METHOD_TYPE - && DECL_STATIC_FUNCTION_P (olddecl)) - { - tree n1; - p1 = TREE_CHAIN (p1); - n1 = build_function_type (TREE_TYPE (f1), p1); - n1 = build_type_variant (n1, TREE_READONLY (f1), TREE_VOLATILE (f1)); - n1 = build_exception_variant (TYPE_METHOD_BASETYPE (f1), n1, TYPE_RAISES_EXCEPTIONS (f1)); - TREE_TYPE (newdecl) = n1; - f1 = n1; - DECL_STATIC_FUNCTION_P (newdecl) = 1; - } - /* Here we must take care of the case where new default - parameters are specified. Also, warn if an old - declaration becomes ambiguous because default - parameters may cause the two to be ambiguous. */ - if (TREE_CODE (f1) != TREE_CODE (f2)) - { - if (TREE_CODE (f1) == OFFSET_TYPE) - compiler_error_with_decl (newdecl, "`%s' redeclared as member function"); - else - compiler_error_with_decl (newdecl, "`%s' redeclared as non-member function"); - return 0; - } - - if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (f1)), - TYPE_MAIN_VARIANT (TREE_TYPE (f2)), 1)) - { - types_match = compparms (p1, p2, 1); -#ifndef MERGED - /* C++: copy friendlist *before* we get smooshed. */ - if (DECL_FRIENDLIST (olddecl) && !DECL_FRIENDLIST (newdecl)) - DECL_FRIENDLIST (newdecl) = DECL_FRIENDLIST (olddecl); -#endif - } - else types_match = 0; - } - else - { - if (TREE_TYPE (newdecl) == error_mark_node) - types_match = TREE_TYPE (olddecl) == error_mark_node; - else - types_match = comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl), 1); - } - - return types_match; -} - -/* Handle when a new declaration NEWDECL has the same name as an old - one OLDDECL in the same binding contour. Prints an error message - if appropriate. - - If safely possible, alter OLDDECL to look like NEWDECL, and return 1. - Otherwise, return 0. */ - -static int -duplicate_decls (newdecl, olddecl) - register tree newdecl, olddecl; -{ - extern struct obstack permanent_obstack; - int types_match; - int new_is_definition; - - if (TREE_CODE (olddecl) == TREE_LIST - && TREE_CODE (newdecl) == FUNCTION_DECL) - { - /* If a new decl finds a list of old decls, then - we assume that the new decl has C linkage, and - that the old decls have C++ linkage. In this case, - we must look through the list to see whether - there is an ambiguity or not. */ - tree olddecls = olddecl; - - /* If the overload list is empty, just install the decl. */ - if (TREE_VALUE (olddecls) == NULL_TREE) - { - TREE_VALUE (olddecls) = newdecl; - return 1; - } - - while (olddecls) - { - if (decls_match (newdecl, TREE_VALUE (olddecls))) - { - if (TREE_CODE (newdecl) == VAR_DECL) - ; - else if (DECL_LANGUAGE (newdecl) - != DECL_LANGUAGE (TREE_VALUE (olddecls))) - { - error_with_decl (newdecl, "declaration of `%s' with different language linkage"); - error_with_decl (TREE_VALUE (olddecls), "previous declaration here"); - } - types_match = 1; - break; - } - olddecls = TREE_CHAIN (olddecls); - } - if (olddecls) - olddecl = TREE_VALUE (olddecl); - else - return 1; - } - else - types_match = decls_match (newdecl, olddecl); - - if (TREE_CODE (TREE_TYPE (newdecl)) == ERROR_MARK - || TREE_CODE (TREE_TYPE (olddecl)) == ERROR_MARK) - types_match = 0; - - /* If this decl has linkage, and the old one does too, maybe no error. */ - if (TREE_CODE (olddecl) != TREE_CODE (newdecl)) - { - error_with_decl (newdecl, "`%s' redeclared as different kind of symbol"); - if (TREE_CODE (olddecl) == TREE_LIST) - olddecl = TREE_VALUE (olddecl); - error_with_decl (olddecl, "previous declaration of `%s'"); - - /* New decl is completely inconsistent with the old one => - tell caller to replace the old one. */ - - return 0; - } - - if (TREE_CODE (newdecl) == FUNCTION_DECL) - { - /* Now that functions must hold information normally held - by field decls, there is extra work to do so that - declaration information does not get destroyed during - definition. */ - if (DECL_VINDEX (olddecl) && ! DECL_VINDEX (newdecl)) - DECL_VINDEX (newdecl) = DECL_VINDEX (olddecl); - if (DECL_VCONTEXT (olddecl) && ! DECL_VCONTEXT (newdecl)) - DECL_VCONTEXT (newdecl) = DECL_VCONTEXT (olddecl); - if (DECL_FIELD_CONTEXT (olddecl) && ! DECL_FIELD_CONTEXT (newdecl)) - DECL_FIELD_CONTEXT (newdecl) = DECL_FIELD_CONTEXT (olddecl); -#ifdef SOS - if (DECL_DINDEX (olddecl) && ! DECL_DINDEX (newdecl)) - DECL_DINDEX (newdecl) = DECL_DINDEX (newdecl); -#endif - if (DECL_PENDING_INLINE_INFO (newdecl) == 0) - DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl); - } - - if (flag_traditional && TREE_CODE (newdecl) == FUNCTION_DECL - && IDENTIFIER_IMPLICIT_DECL (DECL_NAME (newdecl)) == olddecl) - /* If -traditional, avoid error for redeclaring fcn - after implicit decl. */ - ; - else if (TREE_CODE (olddecl) == FUNCTION_DECL - && DECL_FUNCTION_CODE (olddecl) != NOT_BUILT_IN) - { - if (!types_match) - error_with_decl (newdecl, "conflicting types for built-in function `%s'"); - else if (extra_warnings) - warning_with_decl (newdecl, "built-in function `%s' redeclared"); - } - else if (!types_match) - { - tree oldtype = TREE_TYPE (olddecl); - tree newtype = TREE_TYPE (newdecl); - int give_error = 0; - - /* Already complained about this, so don't do so again. */ - if (current_class_type == NULL_TREE - || IDENTIFIER_ERROR_LOCUS (DECL_NAME (newdecl)) != current_class_type) - { - give_error = 1; - error_with_decl (newdecl, "conflicting types for `%s'"); - } - - /* Check for function type mismatch - involving an empty arglist vs a nonempty one. */ - if (TREE_CODE (olddecl) == FUNCTION_DECL - && comptypes (TREE_TYPE (oldtype), - TREE_TYPE (newtype), 1) - && ((TYPE_ARG_TYPES (oldtype) == 0 - && DECL_INITIAL (olddecl) == 0) - || (TYPE_ARG_TYPES (newtype) == 0 - && DECL_INITIAL (newdecl) == 0))) - { - /* Classify the problem further. */ - register tree t = TYPE_ARG_TYPES (oldtype); - if (t == 0) - t = TYPE_ARG_TYPES (newtype); - for (; t; t = TREE_CHAIN (t)) - { - register tree type = TREE_VALUE (t); - - if (TREE_CHAIN (t) == 0 && type != void_type_node) - { - error ("A parameter list with an ellipsis can't match"); - error ("an empty parameter name list declaration."); - break; - } - - if (type == float_type_node - || (TREE_CODE (type) == INTEGER_TYPE - && (TYPE_PRECISION (type) - < TYPE_PRECISION (integer_type_node)))) - { - error ("An argument type that has a default promotion"); - error ("can't match an empty parameter name list declaration."); - break; - } - } - } - if (give_error) - error_with_decl (olddecl, "previous declaration of `%s'"); - - /* There is one thing GNU C++ cannot tolerate: a constructor - which takes the type of object being constructed. - Farm that case out here. */ - if (TREE_CODE (newdecl) == FUNCTION_DECL - && DECL_CONSTRUCTOR_P (newdecl)) - { - tree tmp = TREE_CHAIN (TYPE_ARG_TYPES (newtype)); - - if (tmp != NULL_TREE - && (TYPE_MAIN_VARIANT (TREE_VALUE (tmp)) - == TYPE_METHOD_BASETYPE (newtype))) - { - tree parm = TREE_CHAIN (DECL_ARGUMENTS (newdecl)); - tree argtypes - = hash_tree_chain (build_reference_type (TREE_VALUE (tmp)), - TREE_CHAIN (tmp)); - - DECL_ARG_TYPE (parm) - = TREE_TYPE (parm) - = TYPE_REFERENCE_TO (TREE_VALUE (tmp)); - - TREE_TYPE (newdecl) = newtype - = build_cplus_method_type (TYPE_METHOD_BASETYPE (newtype), - TREE_TYPE (newtype), argtypes); - error ("constructor cannot take as argument the type being constructed"); - SET_IDENTIFIER_ERROR_LOCUS (DECL_NAME (newdecl), current_class_type); - } - } - } - else - { - char *errmsg = redeclaration_error_message (newdecl, olddecl); - if (errmsg) - { - error_with_decl (newdecl, errmsg); - if (DECL_LANG_SPECIFIC (olddecl) - && DECL_COMPILER_GENERATED_P (olddecl)) - DECL_COMPILER_GENERATED_P (olddecl) = 0; - else - error_with_decl (olddecl, - "here is the previous declaration of `%s'"); - } - else if (TREE_CODE (olddecl) == FUNCTION_DECL - && DECL_INITIAL (olddecl) != 0 - && TYPE_ARG_TYPES (TREE_TYPE (olddecl)) == 0 - && TYPE_ARG_TYPES (TREE_TYPE (newdecl)) != 0) - { - /* Prototype decl follows defn w/o prototype. */ - warning_with_decl (newdecl, "prototype for `%s'"); - warning_with_decl (olddecl, - "follows non-prototype definition here"); - } - - /* These bits are logically part of the type. */ - if (pedantic - && (TREE_READONLY (newdecl) != TREE_READONLY (olddecl) - || TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl))) - error_with_decl (newdecl, "type qualifiers for `%s' conflict with previous decl"); - } - - /* Deal with C++: must preserve virtual function table size. */ - if (TREE_CODE (olddecl) == TYPE_DECL) - { - if (TYPE_LANG_SPECIFIC (TREE_TYPE (newdecl)) - && TYPE_LANG_SPECIFIC (TREE_TYPE (olddecl))) - { - CLASSTYPE_VSIZE (TREE_TYPE (newdecl)) - = CLASSTYPE_VSIZE (TREE_TYPE (olddecl)); - CLASSTYPE_FRIEND_CLASSES (TREE_TYPE (newdecl)) - = CLASSTYPE_FRIEND_CLASSES (TREE_TYPE (olddecl)); - } - } - - new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL - && DECL_INITIAL (newdecl) != 0); - - /* Copy all the DECL_... slots specified in the new decl - except for any that we copy here from the old type. */ - - if (types_match) - { - /* Automatically handles default parameters. */ - tree oldtype = TREE_TYPE (olddecl); - /* Merge the data types specified in the two decls. */ - tree newtype = commontype (TREE_TYPE (newdecl), TREE_TYPE (olddecl)); - - if (TREE_CODE (newdecl) == VAR_DECL) - DECL_EXTERNAL (newdecl) |= DECL_EXTERNAL (olddecl); - /* Do this after calling `commontype' so that default - parameters don't confuse us. */ - else if (TREE_CODE (newdecl) == FUNCTION_DECL - && (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (newdecl)) - != TYPE_RAISES_EXCEPTIONS (TREE_TYPE (olddecl)))) - { - tree ctype = NULL_TREE; - if (TREE_CODE (newtype) == METHOD_TYPE) - ctype = TYPE_METHOD_BASETYPE (newtype); - else if (DECL_STATIC_FUNCTION_P (newdecl)) - ctype = DECL_STATIC_CONTEXT (newdecl); - TREE_TYPE (newdecl) = build_exception_variant (ctype, newtype, - TYPE_RAISES_EXCEPTIONS (TREE_TYPE (newdecl))); - TREE_TYPE (olddecl) = build_exception_variant (ctype, newtype, - TYPE_RAISES_EXCEPTIONS (oldtype)); - - if (! compexcepttypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl))) - { - error_with_decl (newdecl, "declaration of `%s' raises different exceptions..."); - error_with_decl (olddecl, "...from previous declaration here"); - } - } - TREE_TYPE (newdecl) = TREE_TYPE (olddecl) = newtype; - - /* Lay the type out, unless already done. */ - if (oldtype != TREE_TYPE (newdecl)) - { - if (TREE_TYPE (newdecl) != error_mark_node) - layout_type (TREE_TYPE (newdecl)); - if (TREE_CODE (newdecl) != FUNCTION_DECL - && TREE_CODE (newdecl) != TYPE_DECL - && TREE_CODE (newdecl) != CONST_DECL) - layout_decl (newdecl, 0); - } - else - { - /* Since the type is OLDDECL's, make OLDDECL's size go with. */ - DECL_SIZE (newdecl) = DECL_SIZE (olddecl); - DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl); - if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl)) - DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl); - } - - /* Merge the type qualifiers. */ - if (TREE_READONLY (newdecl)) - TREE_READONLY (olddecl) = 1; - if (TREE_THIS_VOLATILE (newdecl)) - TREE_THIS_VOLATILE (olddecl) = 1; - - /* Merge the initialization information. */ - if (DECL_INITIAL (newdecl) == 0) - DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); - /* Keep the old rtl since we can safely use it. */ - DECL_RTL (newdecl) = DECL_RTL (olddecl); - } - /* If cannot merge, then use the new type and qualifiers, - and don't preserve the old rtl. */ - else - { - /* Clean out any memory we had of the old declaration. */ - tree oldstatic = value_member (olddecl, static_aggregates); - if (oldstatic) - TREE_VALUE (oldstatic) = error_mark_node; - - TREE_TYPE (olddecl) = TREE_TYPE (newdecl); - TREE_READONLY (olddecl) = TREE_READONLY (newdecl); - TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl); - TREE_VOLATILE (olddecl) = TREE_VOLATILE (newdecl); - } - - /* Merge the storage class information. */ - if (TREE_EXTERNAL (newdecl)) - { - TREE_STATIC (newdecl) = TREE_STATIC (olddecl); - TREE_EXTERNAL (newdecl) = TREE_EXTERNAL (olddecl); - - /* For functions, static overrides non-static. */ - if (TREE_CODE (newdecl) == FUNCTION_DECL) - { - TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl); - /* This is since we don't automatically - copy the attributes of NEWDECL into OLDDECL. */ - TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl); - /* If this clears `static', clear it in the identifier too. */ - if (! TREE_PUBLIC (olddecl)) - TREE_PUBLIC (DECL_NAME (olddecl)) = 0; - } - else - TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl); - } - else - { - TREE_STATIC (olddecl) = TREE_STATIC (newdecl); - TREE_EXTERNAL (olddecl) = 0; - /* A `const' which was not declared `extern' and is - in static storage is invisible. */ - if (TREE_CODE (newdecl) == VAR_DECL - && TREE_READONLY (newdecl) && TREE_STATIC (newdecl) - && ! DECL_EXTERNAL (newdecl)) - TREE_PUBLIC (newdecl) = 0; - TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl); - } - /* If either decl says `inline', this fn is inline, - unless its definition was passed already. */ - TREE_INLINE (olddecl) |= TREE_INLINE (newdecl); - - if (TREE_CODE (newdecl) == FUNCTION_DECL) - { - if (new_is_definition) - /* If defining a function declared with other language - linkage, use the previously declared language linkage. */ - DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl); - else - { - /* If redeclaring a builtin function, and not a definition, - it stays built in. */ - DECL_SET_FUNCTION_CODE (newdecl, DECL_FUNCTION_CODE (olddecl)); - DECL_RESULT (newdecl) = DECL_RESULT (olddecl); - if (DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl)) - /* Previously saved insns go together with - the function's previous definition. */ - DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); - DECL_RESULT_TYPE (newdecl) = DECL_RESULT_TYPE (olddecl); - DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl); - } - } - - /* Now preserve various other info from the definition. */ - TREE_ADDRESSABLE (newdecl) = TREE_ADDRESSABLE (olddecl); - TREE_ASM_WRITTEN (newdecl) = TREE_ASM_WRITTEN (olddecl); - - /* Don't really know how much of the language-specific - values we should copy from old to new. */ -#if 1 - if (DECL_LANG_SPECIFIC (olddecl)) - DECL_IN_AGGR_P (newdecl) = DECL_IN_AGGR_P (olddecl); -#endif - - if (TREE_CODE (newdecl) == FUNCTION_DECL) - { - int function_size; - struct lang_decl *ol = DECL_LANG_SPECIFIC (olddecl); - struct lang_decl *nl = DECL_LANG_SPECIFIC (newdecl); - -#ifdef MERGED - function_size = sizeof (struct tree_decl); -#else - function_size = sizeof (struct tree_function_decl); -#endif - - /* Don't lose track of having output OLDDECL as GDB symbol. */ - DECL_BLOCK_SYMTAB_ADDRESS (newdecl) - = DECL_BLOCK_SYMTAB_ADDRESS (olddecl); - - bcopy ((char *) newdecl + sizeof (struct tree_common), - (char *) olddecl + sizeof (struct tree_common), - function_size - sizeof (struct tree_common)); - - if ((char *)newdecl == obstack_next_free (&permanent_obstack) - - (function_size + sizeof (struct lang_decl))) - { - DECL_MAIN_VARIANT (newdecl) = olddecl; - DECL_LANG_SPECIFIC (olddecl) = ol; - bcopy (nl, ol, sizeof (struct lang_decl)); - - obstack_free (&permanent_obstack, newdecl); - } -#ifdef LANG_DECL_PERMANENT - else if (LANG_DECL_PERMANENT (ol)) - { - if (DECL_MAIN_VARIANT (olddecl) == olddecl) - { - /* Save these lang_decls that would otherwise be lost. */ - extern tree free_lang_decl_chain; - tree free_lang_decl = (tree) ol; - TREE_CHAIN (free_lang_decl) = free_lang_decl_chain; - free_lang_decl_chain = free_lang_decl; - } - else - { - /* Storage leak. */ - } - } -#else - /* Storage leak. */ -#endif - } - else - { - bcopy ((char *) newdecl + sizeof (struct tree_common), - (char *) olddecl + sizeof (struct tree_common), - sizeof (struct tree_decl) - sizeof (struct tree_common) - + tree_code_length [(int)TREE_CODE (newdecl)] * sizeof (char *)); - } - - return 1; -} - -/* Record a decl-node X as belonging to the current lexical scope. - Check for errors (such as an incompatible declaration for the same - name already seen in the same scope). - - Returns either X or an old decl for the same name. - If an old decl is returned, it may have been smashed - to agree with what X says. */ - -tree -pushdecl (x) - tree x; -{ - register tree t; - register tree name = DECL_NAME (x); - register struct binding_level *b = current_binding_level; - - if (name) - { - char *file; - int line; - - t = lookup_name_current_level (name); - if (t != 0 && t == error_mark_node) - /* error_mark_node is 0 for a while during initialization! */ - { - t = 0; - error_with_decl (x, "`%s' used prior to declaration"); - } - - if (t != 0) - { - tree cntxt = t; - if (TREE_CODE (t) == PARM_DECL) - { - if (DECL_CONTEXT (t) == NULL_TREE) - fatal ("parse errors have confused me too much"); - cntxt = DECL_CONTEXT (t); - } - file = DECL_SOURCE_FILE (t); - line = DECL_SOURCE_LINE (t); - } - - if (t != 0 && TREE_CODE (t) != TREE_CODE (x)) - { - if (TREE_CODE (t) == TYPE_DECL) - { -#ifdef BREAK_C_TAGS - ; -#else - warning ("type declaration of %s shadowed", - IDENTIFIER_POINTER (name)); -#endif - } - else if (TREE_CODE (x) == TYPE_DECL) - { -#ifdef BREAK_C_TAGS - ; -#else - warning ("type declaration of %s shadows previous declaration", - IDENTIFIER_POINTER (name)); -#endif - } - else if (duplicate_decls (x, t)) - return t; - } - else if (t != 0 && duplicate_decls (x, t)) - { - /* If this decl is `static' and an `extern' was seen previously, - that is erroneous. But don't complain if -traditional, - since traditional compilers don't complain. - - Note that this does not apply to the C++ case of declaring - a variable `extern const' and then later `const'. */ - if (!flag_traditional && TREE_PUBLIC (name) - && ! TREE_PUBLIC (x) && ! TREE_EXTERNAL (x) && ! TREE_INLINE (x)) - { - /* Due to interference in memory reclamation (X may be - obstack-deallocated at this point, we must guard against - one really special case). */ - if (current_function_decl == x) - current_function_decl = t; - if (IDENTIFIER_IMPLICIT_DECL (name)) - warning ("`%s' was declared implicitly `extern' and later `static'", - lang_printable_name (t)); - else - warning ("`%s' was declared `extern' and later `static'", - lang_printable_name (t)); - warning_with_file_and_line (file, line, - "previous declaration of `%s'", - lang_printable_name (t)); - } - return t; - } - - /* If declaring a type as a typedef, and the type has no known - typedef name, install this TYPE_DECL as its typedef name. - - C++: If it had an anonymous aggregate or enum name, - give it a `better' one. */ - if (TREE_CODE (x) == TYPE_DECL) - { - tree name = TYPE_NAME (TREE_TYPE (x)); - - if (name == NULL_TREE - || (TREE_CODE (name) != TYPE_DECL -#ifndef BREAK_C_TAGS - && current_lang_name == lang_name_cplusplus -#endif - )) - { - /* If these are different names, make two equivalent - definitions. */ - TYPE_NAME (TREE_TYPE (x)) = x; - } - else - { - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - if (ANON_AGGRNAME_P (name)) - { - /* do gratuitous C++ typedefing, and make sure that - we access this type either through TREE_TYPE field - or via the tags list. */ - TYPE_NAME (TREE_TYPE (x)) = x; - pushtag (name, TREE_TYPE (x)); - } - } - } - - /* Multiple external decls of the same identifier ought to match. */ - - if (TREE_EXTERNAL (x) && IDENTIFIER_GLOBAL_VALUE (name) != 0 - && (TREE_EXTERNAL (IDENTIFIER_GLOBAL_VALUE (name)) - || TREE_PUBLIC (IDENTIFIER_GLOBAL_VALUE (name)))) - { - if (! comptypes (TREE_TYPE (x), - TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name)), 1)) - { - warning_with_decl (x, - "type mismatch with previous external decl"); - warning_with_decl (IDENTIFIER_GLOBAL_VALUE (name), - "previous external decl of `%s'"); - } - } - - /* In PCC-compatibility mode, extern decls of vars with no current decl - take effect at top level no matter where they are. */ - if (flag_traditional && TREE_EXTERNAL (x) - && lookup_name (name) == 0) - b = global_binding_level; - - /* This name is new in its binding level. - Install the new declaration and return it. */ - if (b == global_binding_level) - { - /* Install a global value. */ - - /* Rule for VAR_DECLs, but not for other kinds of _DECLs: - A `const' which was not declared `extern' is invisible. */ - if (TREE_CODE (x) == VAR_DECL - && TREE_READONLY (x) && ! DECL_EXTERNAL (x)) - TREE_PUBLIC (x) = 0; - - /* If the first global decl has external linkage, - warn if we later see static one. */ - if (IDENTIFIER_GLOBAL_VALUE (name) == 0 && TREE_PUBLIC (x)) - TREE_PUBLIC (name) = 1; - - IDENTIFIER_GLOBAL_VALUE (name) = x; - - /* Don't forget if the function was used via an implicit decl. */ - if (IDENTIFIER_IMPLICIT_DECL (name) - && TREE_USED (IDENTIFIER_IMPLICIT_DECL (name))) - TREE_USED (x) = 1; - - /* Don't forget if its address was taken in that way. */ - if (IDENTIFIER_IMPLICIT_DECL (name) - && TREE_ADDRESSABLE (IDENTIFIER_IMPLICIT_DECL (name))) - TREE_ADDRESSABLE (x) = 1; - - /* Warn about mismatches against previous implicit decl. */ - if (IDENTIFIER_IMPLICIT_DECL (name) != 0 - /* If this real decl matches the implicit, don't complain. */ - && ! (TREE_CODE (x) == FUNCTION_DECL - && TREE_TYPE (TREE_TYPE (x)) == integer_type_node)) - warning ("`%s' was previously implicitly declared to return `int'", - lang_printable_name (x)); - - /* If this decl is `static' and an `extern' was seen previously, - that is erroneous. */ - if (TREE_PUBLIC (name) - && ! TREE_PUBLIC (x) && ! TREE_EXTERNAL (x)) - { - if (IDENTIFIER_IMPLICIT_DECL (name)) - warning ("`%s' was declared implicitly `extern' and later `static'", - lang_printable_name (x)); - else - warning ("`%s' was declared `extern' and later `static'", - lang_printable_name (x)); - } - } - else - { - /* Here to install a non-global value. */ - tree oldlocal = IDENTIFIER_LOCAL_VALUE (name); - tree oldglobal = IDENTIFIER_GLOBAL_VALUE (name); - IDENTIFIER_LOCAL_VALUE (name) = x; - - /* If this is an extern function declaration, see if we - have a global definition for the function. */ - if (oldlocal == 0 - && oldglobal != 0 - && TREE_CODE (x) == FUNCTION_DECL - && TREE_CODE (oldglobal) == FUNCTION_DECL) - { - /* We have one. Their types must agree. */ - if (! comptypes (TREE_TYPE (x), TREE_TYPE (oldglobal), 1)) - warning_with_decl (x, "local declaration of `%s' doesn't match global one"); - /* If the global one is inline, make the local one inline. */ - else if (TREE_INLINE (oldglobal) - || DECL_FUNCTION_CODE (oldglobal) != NOT_BUILT_IN - || (TYPE_ARG_TYPES (TREE_TYPE (oldglobal)) != 0 - && TYPE_ARG_TYPES (TREE_TYPE (x)) == 0)) - IDENTIFIER_LOCAL_VALUE (name) = oldglobal; - } - /* If we have a local external declaration, - and no file-scope declaration has yet been seen, - then if we later have a file-scope decl it must not be static. */ - if (oldlocal == 0 - && oldglobal == 0 - && TREE_EXTERNAL (x) - && TREE_PUBLIC (x)) - { - TREE_PUBLIC (name) = 1; - } - - if (TREE_INLINE (x)) - /* Inline decls shadow nothing. */; - - /* Warn if shadowing an argument at the top level of the body. */ - else if (oldlocal != 0 && !TREE_EXTERNAL (x) - && TREE_CODE (oldlocal) == PARM_DECL - && TREE_CODE (x) != PARM_DECL - /* The parm level is two levels above the first user-visible - level. One level was created for parm cleanups, the - other declared by the user. */ - && current_binding_level->level_chain->level_chain->parm_flag == 1) - warning ("declaration of `%s' shadows a parameter", - IDENTIFIER_POINTER (name)); - - /* Maybe warn if shadowing something else. */ - else if (warn_shadow && !TREE_EXTERNAL (x)) - { - char *warnstring = 0; - - if (oldlocal != 0 && TREE_CODE (oldlocal) == PARM_DECL) - warnstring = "declaration of `%s' shadows a parameter"; - else if (IDENTIFIER_CLASS_VALUE (name) != 0) - warnstring = "declaration of `%s' shadows a member of `this'"; - else if (oldlocal != 0) - warnstring = "declaration of `%s' shadows previous local"; - else if (oldglobal != 0) - warnstring = "declaration of `%s' shadows global declaration"; - - if (warnstring) - warning (warnstring, IDENTIFIER_POINTER (name)); - } - - /* If storing a local value, there may already be one (inherited). - If so, record it for restoration when this binding level ends. */ - if (oldlocal != 0) - b->shadowed = tree_cons (name, oldlocal, b->shadowed); - } - - /* Keep count of variables in this level with incomplete type. */ - if (TYPE_SIZE (TREE_TYPE (x)) == 0 - && (IS_AGGR_TYPE (TREE_TYPE (x)) - || (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE - && IS_AGGR_TYPE (TREE_TYPE (TREE_TYPE (x)))))) - { - if (++b->n_incomplete == 0) - error ("too many incomplete variables at this point"); - } - } - - /* Put decls on list in reverse order. - We will reverse them later if necessary. */ - TREE_CHAIN (x) = b->names; - b->names = x; - - return x; -} - -/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, - if appropriate. */ -tree -pushdecl_top_level (x) - tree x; -{ - register tree t; - register struct binding_level *b = current_binding_level; - - current_binding_level = global_binding_level; - t = pushdecl (x); - current_binding_level = b; - return t; -} - -/* Make the declaration of X appear in CLASS scope. */ -tree -pushdecl_class_level (x) - tree x; -{ - register tree name = DECL_NAME (x); - - if (name) - { - tree oldclass = IDENTIFIER_CLASS_VALUE (name); - if (oldclass) - class_binding_level->class_shadowed - = tree_cons (name, oldclass, class_binding_level->class_shadowed); - IDENTIFIER_CLASS_VALUE (name) = x; - obstack_ptr_grow (&decl_obstack, x); - } - return x; -} - -/* Tell caller how to interpret a TREE_LIST which contains - chains of FUNCTION_DECLS. */ -int -overloaded_globals_p (list) - tree list; -{ - assert (TREE_CODE (list) == TREE_LIST); - - /* Don't commit caller to seeing them as globals. */ - if (TREE_NONLOCAL (list)) - return -1; - /* Do commit caller to seeing them as globals. */ - if (TREE_CODE (TREE_PURPOSE (list)) == IDENTIFIER_NODE) - return 1; - /* Do commit caller to not seeing them as globals. */ - return 0; -} - -/* DECL is a FUNCTION_DECL which may have other definitions already in place. - We get around this by making IDENTIFIER_GLOBAL_VALUE (DECL_ORIGINAL_NAME (DECL)) - point to a list of all the things that want to be referenced by that name. - It is then up to the users of that name to decide what to do with that - list. */ -void -push_overloaded_decl (decl) - tree decl; -{ - tree orig_name = DECL_ORIGINAL_NAME (decl); - tree glob = IDENTIFIER_GLOBAL_VALUE (orig_name); - - DECL_OVERLOADED (decl) = 1; - if (glob && TREE_CODE (glob) != TREE_LIST) - { - if (DECL_LANGUAGE (decl) == lang_c) - { - if (TREE_CODE (glob) == FUNCTION_DECL) - { - if (DECL_LANGUAGE (glob) == lang_c) - { - error_with_decl (decl, "C-language function `%s' overloaded here"); - error_with_decl (glob, "Previous C-language version of this function was `%s'"); - } - } - else abort (); - } - if (! flag_traditional - && TREE_PERMANENT (glob) == 1 - && current_binding_level != global_binding_level) - overloads_to_forget = tree_cons (orig_name, glob, overloads_to_forget); - if (TREE_CODE (glob) == FUNCTION_DECL - && DECL_LANGUAGE (glob) != DECL_LANGUAGE (decl) - && comptypes (TREE_TYPE (glob), TREE_TYPE (decl), 1)) - { - error_with_decl (decl, "conflicting language contexts for declaration of `%s';"); - error_with_decl (glob, "conflicts with previous declaration here"); - } - glob = tree_cons (DECL_NAME (glob), glob, NULL_TREE); - glob = tree_cons (TREE_PURPOSE (glob), decl, glob); - IDENTIFIER_GLOBAL_VALUE (orig_name) = glob; - TREE_TYPE (glob) = unknown_type_node; - return; - } - if (glob) - { - tree tmp, name; - - if (TREE_VALUE (glob) == NULL_TREE) - { - TREE_VALUE (glob) = decl; - return; - } - name = DECL_NAME (decl); - for (tmp = glob; tmp; tmp = TREE_CHAIN (tmp)) - { - if (TREE_CODE (TREE_VALUE (tmp)) == FUNCTION_DECL - && DECL_LANGUAGE (TREE_VALUE (tmp)) != DECL_LANGUAGE (decl) - && comptypes (TREE_TYPE (TREE_VALUE (tmp)), TREE_TYPE (decl), 1)) - { - error_with_decl (decl, "conflicting language contexts for declaration of `%s';"); - error_with_decl (TREE_VALUE (tmp), "conflicts with previous declaration here"); - } - if (DECL_NAME (TREE_VALUE (tmp)) == name) - return; - } - } - - if (DECL_LANGUAGE (decl) == lang_c) - { - tree decls = glob; - while (decls && DECL_LANGUAGE (TREE_VALUE (decls)) == lang_cplusplus) - decls = TREE_CHAIN (decls); - if (decls) - { - error_with_decl (decl, "C-language function `%s' overloaded here"); - error_with_decl (TREE_VALUE (decls), "Previous C-language version of this function was `%s'"); - } - } - - if (! flag_traditional - && (glob == 0 || TREE_PERMANENT (glob) == 1) - && current_binding_level != global_binding_level) - overloads_to_forget = tree_cons (orig_name, glob, overloads_to_forget); - glob = tree_cons (orig_name, decl, glob); - IDENTIFIER_GLOBAL_VALUE (orig_name) = glob; - TREE_TYPE (glob) = unknown_type_node; -} - -/* Generate an implicit declaration for identifier FUNCTIONID - as a function of type int (). Print a warning if appropriate. */ - -tree -implicitly_declare (functionid) - tree functionid; -{ - register tree decl; - int temp = allocation_temporary_p (); - - /* Save the decl permanently so we can warn if definition follows. */ - if (temp && (flag_traditional || !warn_implicit)) - end_temporary_allocation (); - - /* We used to reuse an old implicit decl here, - but this loses with inline functions because it can clobber - the saved decl chains. */ -/* if (IDENTIFIER_IMPLICIT_DECL (functionid) != 0) - decl = IDENTIFIER_IMPLICIT_DECL (functionid); - else */ - decl = build_lang_decl (FUNCTION_DECL, functionid, default_function_type); - - TREE_EXTERNAL (decl) = 1; - TREE_PUBLIC (decl) = 1; - - /* ANSI standard says implicit declarations are in the innermost block. - So we record the decl in the standard fashion. - If flag_traditional is set, pushdecl does it top-level. */ - pushdecl (decl); - rest_of_decl_compilation (decl, 0, 0, 0); - - if (warn_implicit - /* Only one warning per identifier. */ - && IDENTIFIER_IMPLICIT_DECL (functionid) == 0) - warning ("implicit declaration of function `%s'", - IDENTIFIER_POINTER (functionid)); - - SET_IDENTIFIER_IMPLICIT_DECL (functionid, decl); - - if (temp && (flag_traditional || ! warn_implicit)) - resume_temporary_allocation (); - - return decl; -} - -/* Return zero if the declaration NEWDECL is valid - when the declaration OLDDECL (assumed to be for the same name) - has already been seen. - Otherwise return an error message format string with a %s - where the identifier should go. */ - -static char * -redeclaration_error_message (newdecl, olddecl) - tree newdecl, olddecl; -{ - if (TREE_CODE (newdecl) == TYPE_DECL) - { - /* Because C++ can put things into name space for free, - constructs like "typedef struct foo { ... } foo" - would look like an erroneous redeclaration. */ - if (TREE_TYPE (olddecl) == TREE_TYPE (newdecl)) - return 0; - else - return "redefinition of `%s'"; - } - else if (TREE_CODE (newdecl) == FUNCTION_DECL) - { - /* Declarations of functions can insist on internal linkage - but they can't be inconsistent with internal linkage, - so there can be no error on that account. - However defining the same name twice is no good. */ - if (DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (newdecl) != 0 - /* However, defining once as extern inline and a second - time in another way is ok. */ - && !(TREE_INLINE (olddecl) && TREE_EXTERNAL (olddecl) - && !(TREE_INLINE (newdecl) && TREE_EXTERNAL (newdecl)))) - { - if (DECL_LANG_SPECIFIC (olddecl) - && DECL_COMPILER_GENERATED_P (olddecl)) - return "`%s' not declared in class"; - else - return "redefinition of `%s'"; - } - return 0; - } - else if (current_binding_level == global_binding_level) - { - /* Objects declared at top level: */ - /* If at least one is a reference, it's ok. */ - if (TREE_EXTERNAL (newdecl) || TREE_EXTERNAL (olddecl)) - return 0; - /* Reject two definitions. */ - if (DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (newdecl) != 0) - return "redefinition of `%s'"; - /* Now we have two tentative defs, or one tentative and one real def. */ - /* Insist that the linkage match. */ - if (TREE_PUBLIC (olddecl) != TREE_PUBLIC (newdecl)) - return "conflicting declarations of `%s'"; - return 0; - } - else - { - /* Objects declared with block scope: */ - /* Reject two definitions, and reject a definition - together with an external reference. */ - if (!(TREE_EXTERNAL (newdecl) && TREE_EXTERNAL (olddecl))) - return "redeclaration of `%s'"; - return 0; - } -} - -/* Get the LABEL_DECL corresponding to identifier ID as a label. - Create one if none exists so far for the current function. - This function is called for both label definitions and label references. */ - -tree -lookup_label (id) - tree id; -{ - register tree decl = IDENTIFIER_LABEL_VALUE (id); - - if ((decl == 0 - || DECL_SOURCE_LINE (decl) == 0) - && (named_label_uses == 0 - || TREE_PURPOSE (named_label_uses) != current_binding_level->names - || TREE_VALUE (named_label_uses) != decl)) - { - named_label_uses - = tree_cons (current_binding_level->names, decl, named_label_uses); - TREE_TYPE (named_label_uses) = (tree)current_binding_level; - } - - if (decl != 0) - return decl; - - /* By giving the label type `void *', we can use it as a value. */ - decl = build_decl (LABEL_DECL, id, ptr_type_node); - DECL_MODE (decl) = VOIDmode; - /* Mark that the label's definition has not been seen. */ - DECL_SOURCE_LINE (decl) = 0; - - SET_IDENTIFIER_LABEL_VALUE (id, decl); - - named_labels = tree_cons (NULL_TREE, decl, named_labels); - TREE_VALUE (named_label_uses) = decl; - - return decl; -} - -/* Define a label, specifying the location in the source file. - Return the LABEL_DECL node for the label, if the definition is valid. - Otherwise return 0. */ - -tree -define_label (filename, line, name) - char *filename; - int line; - tree name; -{ - tree decl = lookup_label (name); - - /* After labels, make any new cleanups go into their - own new (temporary) binding contour. */ - current_binding_level->more_cleanups_ok = 0; - - if (DECL_SOURCE_LINE (decl) != 0) - { - error_with_decl (decl, "duplicate label `%s'"); - return 0; - } - else - { - tree uses, prev; - - /* Mark label as having been defined. */ - DECL_SOURCE_FILE (decl) = filename; - DECL_SOURCE_LINE (decl) = line; - - for (prev = 0, uses = named_label_uses; - uses; - prev = uses, uses = TREE_CHAIN (uses)) - if (TREE_VALUE (uses) == decl) - { - struct binding_level *b = current_binding_level; - while (1) - { - tree new_decls = b->names; - tree old_decls = ((tree)b == TREE_TYPE (uses) - ? TREE_PURPOSE (uses) : NULL_TREE); - while (new_decls != old_decls) - { - if (TREE_CODE (new_decls) == VAR_DECL - /* Don't complain about crossing initialization - of temporaries. They can't be accessed, - and they should be cleaned up - by the time we get to the label. */ - && ! TEMP_NAME_P (DECL_NAME (new_decls)) - && ((DECL_INITIAL (new_decls) != NULL_TREE - && DECL_INITIAL (new_decls) != error_mark_node) - || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (new_decls)))) - { - if (IDENTIFIER_ERROR_LOCUS (decl) == NULL_TREE) - error_with_decl (decl, "invalid jump to label `%s'"); - SET_IDENTIFIER_ERROR_LOCUS (decl, current_function_decl); - error_with_decl (new_decls, "crosses initialization of `%s'"); - } - new_decls = TREE_CHAIN (new_decls); - } - if ((tree)b == TREE_TYPE (uses)) - break; - b = b->level_chain; - } - - if (prev) - TREE_CHAIN (prev) = TREE_CHAIN (uses); - else - named_label_uses = TREE_CHAIN (uses); - } - return decl; - } -} - -/* Same, but for CASE labels. */ -void -define_case_label (decl) - tree decl; -{ - /* After labels, make any new cleanups go into their - own new (temporary) binding contour. */ - - current_binding_level->more_cleanups_ok = 0; -} - -/* Return the list of declarations of the current level. - Note that this list is in reverse order unless/until - you nreverse it; and when you do nreverse it, you must - store the result back using `storedecls' or you will lose. */ - -tree -getdecls () -{ - return current_binding_level->names; -} - -/* Return the list of type-tags (for structs, etc) of the current level. */ - -tree -gettags () -{ - return current_binding_level->tags; -} - -/* Store the list of declarations of the current level. - This is done for the parameter declarations of a function being defined, - after they are modified in the light of any missing parameters. */ - -static void -storedecls (decls) - tree decls; -{ - current_binding_level->names = decls; -} - -/* Similarly, store the list of tags of the current level. */ - -static void -storetags (tags) - tree tags; -{ - current_binding_level->tags = tags; -} - -/* Given NAME, an IDENTIFIER_NODE, - return the structure (or union or enum) definition for that name. - Searches binding levels from BINDING_LEVEL up to the global level. - If THISLEVEL_ONLY is nonzero, searches only the specified context - (but skips any tag-transparent contexts to find one that is - meaningful for tags). - FORM says which kind of type the caller wants; - it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE. - If the wrong kind of type is found, an error is reported. */ - -static tree -lookup_tag (form, name, binding_level, thislevel_only) - enum tree_code form; - struct binding_level *binding_level; - tree name; - int thislevel_only; -{ - register struct binding_level *level; - - for (level = binding_level; level; level = level->level_chain) - { - register tree tail; - for (tail = level->tags; tail; tail = TREE_CHAIN (tail)) - { - if (TREE_PURPOSE (tail) == name) - { - if (TREE_CODE (TREE_VALUE (tail)) != form) - { - /* Definition isn't the kind we were looking for. */ - error ("`%s' defined as wrong kind of tag", - IDENTIFIER_POINTER (name)); - } - return TREE_VALUE (tail); - } - } - if (thislevel_only && ! level->tag_transparent) - return NULL_TREE; - if (current_class_type && level->level_chain == global_binding_level) - { - /* Try looking in this class's tags before heading into - global binding level. */ - tree these_tags = CLASSTYPE_TAGS (current_class_type); - while (these_tags) - { - if (TREE_PURPOSE (these_tags) == name) - { - if (TREE_CODE (TREE_VALUE (these_tags)) != form) - { - error ("`%s' defined as wrong kind of tag in class scope", - IDENTIFIER_POINTER (name)); - } - return TREE_VALUE (tail); - } - these_tags = TREE_CHAIN (these_tags); - } - } - } - return NULL_TREE; -} - -/* Given a type, find the tag that was defined for it and return the tag name. - Otherwise return 0. However, the value can never be 0 - in the cases in which this is used. - - C++: If NAME is non-zero, this is the new name to install. This is - done when replacing anonymous tags with real tag names. */ - -static tree -lookup_tag_reverse (type, name) - tree type; - tree name; -{ - register struct binding_level *level; - - for (level = current_binding_level; level; level = level->level_chain) - { - register tree tail; - for (tail = level->tags; tail; tail = TREE_CHAIN (tail)) - { - if (TREE_VALUE (tail) == type) - { - if (name) - TREE_PURPOSE (tail) = name; - return TREE_PURPOSE (tail); - } - } - } - return NULL_TREE; -} - -/* Given type TYPE which was not declared in C++ language context, - attempt to find a name by which it is refered. */ -tree -typedecl_for_tag (tag) - tree tag; -{ - struct binding_level *b = current_binding_level; - - if (TREE_CODE (TYPE_NAME (tag)) == TYPE_DECL) - return TYPE_NAME (tag); - - while (b) - { - tree decls = b->names; - while (decls) - { - if (TREE_CODE (decls) == TYPE_DECL && TREE_TYPE (decls) == tag) - break; - decls = TREE_CHAIN (decls); - } - if (decls) - return decls; - b = b->level_chain; - } - return NULL_TREE; -} - -/* Look up NAME in the current binding level and its superiors - in the namespace of variables, functions and typedefs. - Return a ..._DECL node of some kind representing its definition, - or return 0 if it is undefined. */ - -tree -lookup_name (name) - tree name; -{ - register tree val; - if (current_binding_level != global_binding_level - && IDENTIFIER_LOCAL_VALUE (name)) - val = IDENTIFIER_LOCAL_VALUE (name); - /* In C++ class fields are between local and global scope, - just before the global scope. */ - else if (current_class_type) - { - if (IDENTIFIER_CLASS_VALUE (name)) - val = IDENTIFIER_CLASS_VALUE (name); - else if (TYPE_SIZE (current_class_type) == 0 - && CLASSTYPE_LOCAL_TYPEDECLS (current_class_type)) - { - /* Try to find values from base classes - if we are presently defining a type. - We are presently only interested in TYPE_DECLs. */ - val = lookup_field (current_class_type, name, 0); - if (val == error_mark_node) - return val; - if (val && TREE_CODE (val) != TYPE_DECL) - val = NULL_TREE; - else if (val == NULL_TREE) - val = IDENTIFIER_GLOBAL_VALUE (name); - } - else - val = IDENTIFIER_GLOBAL_VALUE (name); - } - else - val = IDENTIFIER_GLOBAL_VALUE (name); - if (val && TREE_TYPE (val) == error_mark_node) - return error_mark_node; - return val; -} - -/* Similar to `lookup_name' but look only at current binding level. */ - -static tree -lookup_name_current_level (name) - tree name; -{ - register tree t; - - if (current_binding_level == global_binding_level) - return IDENTIFIER_GLOBAL_VALUE (name); - - if (IDENTIFIER_LOCAL_VALUE (name) == 0) - return 0; - - for (t = current_binding_level->names; t; t = TREE_CHAIN (t)) - if (DECL_NAME (t) == name) - break; - - return t; -} - -static void sigsegv () -{ - error ("Segmentation violation"); - signal (SIGSEGV, SIG_DFL); -} - -/* Create the predefined scalar types of C, - and some nodes representing standard constants (0, 1, (void *)0). - Initialize the global binding level. - Make definitions for built-in primitive functions. */ - -union tree_node ERROR_MARK_NODE; - -void -init_decl_processing () -{ - register tree endlink, int_endlink, double_endlink, ptr_endlink; - - /* Have to make these distinct before we try using them. */ - lang_name_cplusplus = get_identifier ("C++"); - lang_name_c = get_identifier ("C"); - - /* Initially, C. */ - current_lang_name = lang_name_c; - - current_function_decl = NULL_TREE; - named_labels = NULL_TREE; - named_label_uses = NULL_TREE; - current_binding_level = NULL_BINDING_LEVEL; - free_binding_level = NULL_BINDING_LEVEL; - - if (write_symbols == GDB_DEBUG) - fatal ("GNU C++ does not support GDB symbol info yet, use -g"); - - /* Handle signals. */ - signal (SIGSEGV, sigsegv); - - obstack_init (&decl_obstack); - - /* Must lay these out before anything else gets laid out. */ -#if 0 - error_mark_node = make_node (ERROR_MARK); -#else -#undef error_mark_node - error_mark_node = &ERROR_MARK_NODE; -#define error_mark_node (&ERROR_MARK_NODE) - TREE_PERMANENT (error_mark_node) = 1; -#endif - TREE_TYPE (error_mark_node) = error_mark_node; - error_mark_list = build_tree_list (error_mark_node, error_mark_node); - TREE_TYPE (error_mark_list) = error_mark_node; - - pushlevel (0); /* make the binding_level structure for global names. */ - global_binding_level = current_binding_level; - - value_identifier = get_identifier (""); - this_identifier = get_identifier (THIS_NAME); - in_charge_identifier = get_identifier (IN_CHARGE_NAME); - - /* Define `int' and `char' first so that dbx will output them first. */ - - integer_type_node = make_signed_type (INT_TYPE_SIZE); - IDENTIFIER_GLOBAL_VALUE (ridpointers[(int) RID_INT]) - = pushdecl (build_decl (TYPE_DECL, ridpointers[(int) RID_INT], - integer_type_node)); - - /* Define `char', which is like either `signed char' or `unsigned char' - but not the same as either. */ - - char_type_node = - (flag_signed_char - ? make_signed_type (CHAR_TYPE_SIZE) - : make_unsigned_type (CHAR_TYPE_SIZE)); - - IDENTIFIER_GLOBAL_VALUE (ridpointers[(int) RID_CHAR]) - = pushdecl (build_decl (TYPE_DECL, get_identifier ("char"), - char_type_node)); - - long_integer_type_node = make_signed_type (LONG_TYPE_SIZE); - IDENTIFIER_GLOBAL_VALUE (ridpointers[(int) RID_LONG]) - = pushdecl (build_decl (TYPE_DECL, get_identifier ("long int"), - long_integer_type_node)); - - unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE); - IDENTIFIER_GLOBAL_VALUE (ridpointers[(int) RID_UNSIGNED]) - = pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"), - unsigned_type_node)); - - long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE); - pushdecl (build_decl (TYPE_DECL, get_identifier ("long unsigned int"), - long_unsigned_type_node)); - - /* `unsigned long' or `unsigned int' is the standard type for sizeof. - Traditionally, use a signed type. */ - if (INT_TYPE_SIZE != BITS_PER_WORD) - sizetype = flag_traditional ? long_integer_type_node : long_unsigned_type_node; - else - sizetype = flag_traditional ? integer_type_node : unsigned_type_node; - - TREE_TYPE (TYPE_SIZE (integer_type_node)) = sizetype; - TREE_TYPE (TYPE_SIZE (char_type_node)) = sizetype; - TREE_TYPE (TYPE_SIZE (unsigned_type_node)) = sizetype; - TREE_TYPE (TYPE_SIZE (long_unsigned_type_node)) = sizetype; - TREE_TYPE (TYPE_SIZE (long_integer_type_node)) = sizetype; - - short_integer_type_node = make_signed_type (SHORT_TYPE_SIZE); - IDENTIFIER_GLOBAL_VALUE (ridpointers[(int) RID_SHORT]) - = pushdecl (build_decl (TYPE_DECL, get_identifier ("short int"), - short_integer_type_node)); - - long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE); - pushdecl (build_decl (TYPE_DECL, get_identifier ("long long int"), - long_long_integer_type_node)); - short_unsigned_type_node = make_unsigned_type (SHORT_TYPE_SIZE); - pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned short int"), - short_unsigned_type_node)); - long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE); - pushdecl (build_decl (TYPE_DECL, get_identifier ("long long unsigned int"), - long_long_unsigned_type_node)); - - /* Define both `signed char' and `unsigned char'. */ - signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE); - pushdecl (build_decl (TYPE_DECL, get_identifier ("signed char"), - signed_char_type_node)); - unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE); - pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned char"), - unsigned_char_type_node)); - - float_type_node = make_node (REAL_TYPE); - TYPE_PRECISION (float_type_node) = FLOAT_TYPE_SIZE; - IDENTIFIER_GLOBAL_VALUE (ridpointers[(int) RID_FLOAT]) - = pushdecl (build_decl (TYPE_DECL, ridpointers[(int) RID_FLOAT], - float_type_node)); - layout_type (float_type_node); - - double_type_node = make_node (REAL_TYPE); - TYPE_PRECISION (double_type_node) = DOUBLE_TYPE_SIZE; - IDENTIFIER_GLOBAL_VALUE (ridpointers[(int) RID_DOUBLE]) - = pushdecl (build_decl (TYPE_DECL, ridpointers[(int) RID_DOUBLE], - double_type_node)); - layout_type (double_type_node); - - long_double_type_node = make_node (REAL_TYPE); - TYPE_PRECISION (long_double_type_node) = DOUBLE_TYPE_SIZE; - pushdecl (build_decl (TYPE_DECL, get_identifier ("long double"), - long_double_type_node)); - layout_type (long_double_type_node); - - integer_zero_node = build_int_2 (0, 0); - TREE_TYPE (integer_zero_node) = integer_type_node; - integer_one_node = build_int_2 (1, 0); - TREE_TYPE (integer_one_node) = integer_type_node; - integer_two_node = build_int_2 (2, 0); - TREE_TYPE (integer_two_node) = integer_type_node; - integer_three_node = build_int_2 (3, 0); - TREE_TYPE (integer_three_node) = integer_type_node; - empty_init_node = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE); - - size_zero_node = build_int_2 (0, 0); - TREE_TYPE (size_zero_node) = sizetype; - size_one_node = build_int_2 (1, 0); - TREE_TYPE (size_one_node) = sizetype; - - void_type_node = make_node (VOID_TYPE); - IDENTIFIER_GLOBAL_VALUE (ridpointers[(int) RID_VOID]) - = pushdecl (build_decl (TYPE_DECL, - ridpointers[(int) RID_VOID], void_type_node)); - layout_type (void_type_node); /* Uses integer_zero_node. */ - void_list_node = build_tree_list (NULL_TREE, void_type_node); - TREE_PARMLIST (void_list_node) = 1; - - null_pointer_node = build_int_2 (0, 0); - TREE_TYPE (null_pointer_node) = build_pointer_type (void_type_node); - layout_type (TREE_TYPE (null_pointer_node)); - - string_type_node = build_pointer_type (char_type_node); - - /* make a type for arrays of 256 characters. - 256 is picked randomly because we have a type for integers from 0 to 255. - With luck nothing will ever really depend on the length of this - array type. */ - char_array_type_node - = build_array_type (char_type_node, unsigned_char_type_node); - /* Likewise for arrays of ints. */ - int_array_type_node - = build_array_type (integer_type_node, unsigned_char_type_node); - - default_function_type - = build_function_type (integer_type_node, NULL_TREE); - build_pointer_type (default_function_type); - - ptr_type_node = build_pointer_type (void_type_node); - endlink = void_list_node; - int_endlink = tree_cons (NULL_TREE, integer_type_node, endlink); - double_endlink = tree_cons (NULL_TREE, double_type_node, endlink); - ptr_endlink = tree_cons (NULL_TREE, ptr_type_node, endlink); - - double_ftype_double - = build_function_type (double_type_node, double_endlink); - - double_ftype_double_double - = build_function_type (double_type_node, - tree_cons (NULL_TREE, double_type_node, double_endlink)); - - int_ftype_int - = build_function_type (integer_type_node, int_endlink); - - long_ftype_long - = build_function_type (long_integer_type_node, - tree_cons (NULL_TREE, long_integer_type_node, endlink)); - - void_ftype_ptr_ptr_int - = build_function_type (void_type_node, - tree_cons (NULL_TREE, ptr_type_node, - tree_cons (NULL_TREE, ptr_type_node, - int_endlink))); - - int_ftype_ptr_ptr_int - = build_function_type (integer_type_node, TYPE_ARG_TYPES (void_ftype_ptr_ptr_int)); - - void_ftype_ptr_int_int - = build_function_type (void_type_node, - tree_cons (NULL_TREE, ptr_type_node, - tree_cons (NULL_TREE, integer_type_node, - int_endlink))); - - ptr_ftype_long - = build_function_type (ptr_type_node, TYPE_ARG_TYPES (long_ftype_long)); - - ptr_ftype_ptr_int_int_ptr - = build_function_type (ptr_type_node, - tree_cons (NULL_TREE, ptr_type_node, - tree_cons (NULL_TREE, integer_type_node, - tree_cons (NULL_TREE, integer_type_node, - ptr_endlink)))); - - void_ftype_ptr - = build_function_type (void_type_node, ptr_endlink); - - void_ftype_ptr_int_int_ptr_int_int - = build_function_type (void_type_node, - tree_cons (NULL_TREE, ptr_type_node, - tree_cons (NULL_TREE, integer_type_node, - tree_cons (NULL_TREE, integer_type_node, - TYPE_ARG_TYPES (void_ftype_ptr_int_int))))); - -#ifdef VTABLE_USES_MASK - /* This is primarily for virtual function definition. We - declare an array of `void *', which can later be - converted to the appropriate function pointer type. - To do pointers to members, we need a mask which can - distinguish an index value into a virtual function table - from an address. */ - vtbl_mask = build_int_2 (~(VINDEX_MAX - 1), -1); -#endif - - vtbl_type_node - = build_array_type (ptr_type_node, NULL_TREE); - layout_type (vtbl_type_node); - vtbl_type_node = build_type_variant (vtbl_type_node, 1, 0); - - builtin_function ("__builtin_alloca", - build_function_type (ptr_type_node, int_endlink), - BUILT_IN_ALLOCA); - - builtin_function ("__builtin_abs", int_ftype_int, BUILT_IN_ABS); - builtin_function ("__builtin_fabs", double_ftype_double, BUILT_IN_FABS); - builtin_function ("__builtin_labs", long_ftype_long, BUILT_IN_LABS); - builtin_function ("__builtin_ffs", int_ftype_int, BUILT_IN_FFS); -#if 0 - /* Support for these has not been written in either expand_builtin - or build_function_call. */ - builtin_function ("__builtin_div", default_ftype, BUILT_IN_DIV); - builtin_function ("__builtin_ldiv", default_ftype, BUILT_IN_LDIV); - builtin_function ("__builtin_ffloor", double_ftype_double, BUILT_IN_FFLOOR); - builtin_function ("__builtin_fceil", double_ftype_double, BUILT_IN_FCEIL); - builtin_function ("__builtin_fmod", double_ftype_double_double, BUILT_IN_FMOD); - builtin_function ("__builtin_frem", double_ftype_double_double, BUILT_IN_FREM); - builtin_function ("__builtin_memcpy", void_ftype_ptr_ptr_int, BUILT_IN_MEMCPY); - builtin_function ("__builtin_memcmp", int_ftype_ptr_ptr_int, BUILT_IN_MEMCMP); - builtin_function ("__builtin_memset", void_ftype_ptr_int_int, BUILT_IN_MEMSET); - builtin_function ("__builtin_fsqrt", double_ftype_double, BUILT_IN_FSQRT); - builtin_function ("__builtin_getexp", double_ftype_double, BUILT_IN_GETEXP); - builtin_function ("__builtin_getman", double_ftype_double, BUILT_IN_GETMAN); -#endif - - /* C++ extensions */ - - unknown_type_node = make_node (UNKNOWN_TYPE); - pushdecl (build_decl (TYPE_DECL, - get_identifier ("unknown type"), - unknown_type_node)); - TYPE_SIZE (unknown_type_node) = TYPE_SIZE (void_type_node); - TYPE_SIZE_UNIT (unknown_type_node) = TYPE_SIZE_UNIT (void_type_node); - TYPE_ALIGN (unknown_type_node) = 1; - TYPE_MODE (unknown_type_node) = TYPE_MODE (void_type_node); - /* Indirecting an UNKNOWN_TYPE node yields an UNKNOWN_TYPE node. */ - TREE_TYPE (unknown_type_node) = unknown_type_node; - /* Looking up TYPE_POINTER_TO and TYPE_REFERENCE_TO yield the same result. */ - TYPE_POINTER_TO (unknown_type_node) = unknown_type_node; - TYPE_REFERENCE_TO (unknown_type_node) = unknown_type_node; - - /* Define these now, but use 0 as their DECL_FUNCTION_CODE. This - will install them in the global binding level, but cause them - to be expanded normally. */ - builtin_function ("__main", default_function_type, NOT_BUILT_IN); - pushdecl (lookup_name (get_identifier ("__main"))); - - builtin_function ("__builtin_saveregs", default_function_type, - BUILT_IN_SAVEREGS); - builtin_function ("__builtin_classify_type", default_function_type, - BUILT_IN_CLASSIFY_TYPE); - - { - /* Simplify life by making a "vtable_entry_type". Give its - fields names so that the debugger can use them. */ - tree fields[4]; - int i; - - vtable_entry_type = make_lang_type (RECORD_TYPE); - CLASSTYPE_OFFSET (vtable_entry_type) = integer_zero_node; - fields[0] = build_lang_field_decl (FIELD_DECL, get_identifier (VTABLE_DELTA_NAME), short_integer_type_node); - fields[1] = build_lang_field_decl (FIELD_DECL, get_identifier (VTABLE_INDEX_NAME), short_integer_type_node); - fields[2] = build_lang_field_decl (FIELD_DECL, get_identifier (VTABLE_PFN_NAME), ptr_type_node); - TYPE_FIELDS (vtable_entry_type) = fields[0]; - for (i = 0; i < 2; i++) - { - DECL_FIELD_CONTEXT (fields[i]) = vtable_entry_type; - TREE_CHAIN (fields[i]) = fields[i+1]; - } - DECL_FIELD_CONTEXT (fields[i]) = vtable_entry_type; - TYPE_ALIGN (vtable_entry_type) = TYPE_ALIGN (double_type_node); - layout_type (vtable_entry_type); - CLASSTYPE_VBASE_SIZE (vtable_entry_type) = integer_zero_node; - TYPE_NAME (vtable_entry_type) = build_decl (TYPE_DECL, - get_identifier (VTBL_PTR_TYPE), - vtable_entry_type); - layout_decl (TYPE_NAME (vtable_entry_type)); - - /* Make this part of an invisible union. */ - fields[3] = copy_node (fields[2]); - TREE_TYPE (fields[3]) = short_integer_type_node; - DECL_NAME (fields[3]) = get_identifier (VTABLE_DELTA2_NAME); - DECL_MODE (fields[3]) = TYPE_MODE (short_integer_type_node); - DECL_SIZE (fields[3]) = TYPE_SIZE (short_integer_type_node); - DECL_SIZE_UNIT (fields[3]) = TYPE_SIZE_UNIT (short_integer_type_node); - TREE_UNSIGNED (fields[3]) = 0; - TREE_CHAIN (fields[2]) = fields[3]; - - vtable_entry_type = build_type_variant (vtable_entry_type, 1, 0); - } - -#ifdef SOS - if (flag_all_virtual == 2) - { - tree fields[5]; - tree ptr_ftype_default - = build_function_type (ptr_type_node, NULL_TREE); - int i; - - builtin_function ("sosFindCode", ptr_ftype_default, NOT_BUILT_IN); - builtin_function ("sosLookup", ptr_ftype_default, NOT_BUILT_IN); - builtin_function ("sosImport", ptr_ftype_default, NOT_BUILT_IN); - builtin_function ("sosDynError", ptr_ftype_default, NOT_BUILT_IN); - - zlink_type = make_lang_type (RECORD_TYPE); - CLASSTYPE_OFFSET (zlink_type) = integer_zero_node; - fields[0] = build_lang_field_decl (FIELD_DECL, get_identifier ("n"), string_type_node); - fields[1] = build_lang_field_decl (FIELD_DECL, get_identifier ("t"), char_type_node); - fields[2] = build_lang_field_decl (FIELD_DECL, get_identifier ("ptr"), TYPE_POINTER_TO (default_function_type)); - - TYPE_FIELDS (zlink_type) = fields[0]; - for (i = 0; i < 2; i++) - { - DECL_FIELD_CONTEXT (fields[i]) = zlink_type; - TREE_CHAIN (fields[i]) = fields[i+1]; - } - DECL_FIELD_CONTEXT (fields[i]) = zlink_type; - TYPE_ALIGN (zlink_type) = 1; - layout_type (zlink_type); - CLASSTYPE_VBASE_SIZE (zlink_type) = integer_zero_node; - - zret_type = make_lang_type (RECORD_TYPE); - CLASSTYPE_OFFSET (zret_type) = integer_zero_node; - fields[0] = build_lang_field_decl (FIELD_DECL, get_identifier ("cn"), string_type_node); - fields[1] = build_lang_field_decl (FIELD_DECL, get_identifier ("ptr"), build_pointer_type (TYPE_POINTER_TO (default_function_type))); - fields[2] = build_lang_field_decl (FIELD_DECL, get_identifier ("n"), integer_type_node); - fields[3] = build_lang_field_decl (FIELD_DECL, get_identifier ("bcl"), string_type_node); - fields[4] = build_lang_field_decl (FIELD_DECL, get_identifier ("f"), char_type_node); - - TYPE_FIELDS (zret_type) = fields[0]; - for (i = 0; i < 4; i++) - { - TREE_CHAIN (fields[i]) = fields[i+1]; - DECL_FIELD_CONTEXT (fields[i]) = zret_type; - } - DECL_FIELD_CONTEXT (fields[i]) = zret_type; - TYPE_ALIGN (zret_type) = 1; - layout_type (zret_type); - CLASSTYPE_VBASE_SIZE (zret_type) = integer_zero_node; - } -#endif - - /* Now, C++. */ - current_lang_name = lang_name_cplusplus; - - auto_function ("__builtin_new", ptr_ftype_long, NOT_BUILT_IN); - auto_function ("__builtin_vec_new", ptr_ftype_ptr_int_int_ptr, NOT_BUILT_IN); - auto_function ("__builtin_delete", void_ftype_ptr, NOT_BUILT_IN); - auto_function ("__builtin_vec_delete", void_ftype_ptr_int_int_ptr_int_int, NOT_BUILT_IN); - - abort_fndecl - = define_function ("abort", - build_function_type (void_type_node, void_list_node), - NOT_BUILT_IN, 0); - - unhandled_exception_fndecl - = define_function ("__unhandled_exception", - build_function_type (void_type_node, NULL_TREE), - NOT_BUILT_IN, 0); - - /* Perform other language dependent initializations. */ - init_class_processing (); - init_init_processing (); - init_search_processing (); - if (flag_handle_exceptions) - { - init_exception_processing (); - if (flag_handle_exceptions == 2) - /* Too much trouble to inline all the trys needed for this. */ - flag_this_is_variable = 2; - } - if (flag_no_inline) - flag_inline_functions = 0; - if (flag_cadillac) - init_cadillac (); -} - -/* Make a definition for a builtin function named NAME and whose data type - is TYPE. TYPE should be a function type with argument types. - FUNCTION_CODE tells later passes how to compile calls to this function. - See tree.h for its possible values. */ - -tree -define_function (name, type, function_code, pfn) - char *name; - tree type; - enum built_in_function function_code; - void (*pfn)(); -{ - tree decl = build_lang_decl (FUNCTION_DECL, get_identifier (name), type); - TREE_EXTERNAL (decl) = 1; - TREE_PUBLIC (decl) = 1; - make_function_rtl (decl); - if (pfn) pfn (decl); - DECL_SET_FUNCTION_CODE (decl, function_code); - return decl; -} - -/* Called when a declaration is seen that contains no names to declare. - If its type is a reference to a structure, union or enum inherited - from a containing scope, shadow that tag name for the current scope - with a forward reference. - If its type defines a new named structure or union - or defines an enum, it is valid but we need not do anything here. - Otherwise, it is an error. - - C++: may have to grok the declspecs to learn about static, - complain for anonymous unions. */ - -void -shadow_tag (declspecs) - tree declspecs; -{ - int found_tag = 0; - int warned = 0; - register tree link; - register enum tree_code code, ok_code = ERROR_MARK; - register tree t = NULL_TREE; - - for (link = declspecs; link; link = TREE_CHAIN (link)) - { - register tree value = TREE_VALUE (link); - - code = TREE_CODE (value); - if (IS_AGGR_TYPE_CODE (code) || code == ENUMERAL_TYPE) - /* Used to test also that TYPE_SIZE (value) != 0. - That caused warning for `struct foo;' at top level in the file. */ - { - register tree name = TYPE_NAME (value); - - if (name == NULL_TREE) - name = lookup_tag_reverse (value, NULL_TREE); - - if (name && TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - if (class_binding_level) - t = lookup_tag (code, name, class_binding_level, 1); - else - t = lookup_tag (code, name, current_binding_level, 1); - - if (t == 0) - { - int temp = allocation_temporary_p (); - if (temp) - end_temporary_allocation (); - if (IS_AGGR_TYPE_CODE (code)) - t = make_lang_type (code); - else - t = make_node (code); - pushtag (name, t); - if (temp) - resume_temporary_allocation (); - ok_code = code; - break; - } - else if (name != 0 || code == ENUMERAL_TYPE) - ok_code = code; - - if (ok_code != ERROR_MARK) - found_tag++; - else - { - if (!warned) - warning ("useless keyword or type name in declaration"); - warned = 1; - } - } - } - - /* This is where the variables in an anonymous union are - declared. An anonymous union declaration looks like: - union { ... } ; - because there is no declarator after the union, the parser - sends that declaration here. */ - if (ok_code == UNION_TYPE - && t != NULL_TREE - && ((TREE_CODE (TYPE_NAME (t)) == IDENTIFIER_NODE - && ANON_AGGRNAME_P (TYPE_NAME (t))) - || (TREE_CODE (TYPE_NAME (t)) == TYPE_DECL - && ANON_AGGRNAME_P (DECL_NAME (TYPE_NAME (t))))) - && TYPE_FIELDS (t)) - { - tree decl = grokdeclarator (NULL_TREE, declspecs, NORMAL, 0, NULL_TREE); - finish_anon_union (decl); - } - else if (ok_code == RECORD_TYPE - && found_tag == 1 - && TYPE_LANG_SPECIFIC (t) - && CLASSTYPE_DECLARED_EXCEPTION (t)) - { - if (TYPE_SIZE (t)) - error_with_aggr_type (t, "redeclaration of exception `%s'"); - else - { - tree ename, decl; - int temp = allocation_temporary_p (); - int momentary = suspend_momentary (); - if (temp) - end_temporary_allocation (); - - pushclass (t, 0); - finish_exception (t, NULL_TREE); - - ename = TYPE_NAME (t); - if (TREE_CODE (ename) == TYPE_DECL) - ename = DECL_NAME (ename); - decl = build_lang_field_decl (VAR_DECL, ename, t); - finish_exception_decl (current_class_name, decl); - end_exception_decls (); - - if (temp) - resume_temporary_allocation (); - if (momentary) - resume_momentary (); - } - } - else if (!warned) - { - if (found_tag > 1) - warning ("multiple types in one declaration"); - if (found_tag == 0) - warning ("empty declaration"); - } -} - -/* Decode a "typename", such as "int **", returning a ..._TYPE node. */ - -tree -groktypename (typename) - tree typename; -{ - if (TREE_CODE (typename) != TREE_LIST) - return typename; - return grokdeclarator (TREE_VALUE (typename), - TREE_PURPOSE (typename), - TYPENAME, 0, NULL_TREE); -} - -/* Decode a declarator in an ordinary declaration or data definition. - This is called as soon as the type information and variable name - have been parsed, before parsing the initializer if any. - Here we create the ..._DECL node, fill in its type, - and put it on the list of decls for the current context. - The ..._DECL node is returned as the value. - - Exception: for arrays where the length is not specified, - the type is left null, to be filled in by `finish_decl'. - - Function definitions do not come here; they go to start_function - instead. However, external and forward declarations of functions - do go through here. Structure field declarations are done by - grokfield and not through here. */ - -/* Set this to zero to debug not using the temporary obstack - to parse initializers. */ -int debug_temp_inits = 1; - -tree -start_decl (declarator, declspecs, initialized, raises) - tree declspecs, declarator; - int initialized; - tree raises; -{ - register tree decl = grokdeclarator (declarator, declspecs, - NORMAL, initialized, raises); - register tree type, tem; - int init_written = initialized; - - if (decl == NULL_TREE) return decl; - - type = TREE_TYPE (decl); - - /* Don't lose if destructors must be executed at file-level. */ - if (TREE_STATIC (decl) - && TYPE_NEEDS_DESTRUCTOR (type) - && TREE_PERMANENT (decl) == 0) - { - end_temporary_allocation (); - decl = copy_node (decl); - if (TREE_CODE (type) == ARRAY_TYPE) - { - tree itype = TYPE_DOMAIN (type); - if (itype && ! TREE_PERMANENT (itype)) - { - itype = build_index_type (copy_to_permanent (TYPE_MAX_VALUE (itype))); - type = build_cplus_array_type (TREE_TYPE (type), itype); - TREE_TYPE (decl) = type; - } - } - resume_temporary_allocation (); - } - - /* Interesting work for this is done in `finish_exception_decl'. */ - if (TREE_CODE (type) == RECORD_TYPE - && CLASSTYPE_DECLARED_EXCEPTION (type)) - return decl; - - if (DECL_CONTEXT (decl)) - { - /* If it was not explicitly declared `extern', - revoke any previous claims of TREE_EXTERNAL. */ - if (DECL_EXTERNAL (decl) == 0) - TREE_EXTERNAL (decl) = 0; - if (DECL_LANG_SPECIFIC (decl)) - DECL_IN_AGGR_P (decl) = 0; - pushclass (DECL_CONTEXT (decl), 2); - } - - /* If this type of object needs a cleanup, and control may - jump past it, make a new binding level so that it is cleaned - up only when it is initialized first. */ - if (TYPE_NEEDS_DESTRUCTOR (type) - && current_binding_level->more_cleanups_ok == 0) - pushlevel_temporary (1); - - if (initialized) - /* Is it valid for this decl to have an initializer at all? - If not, set INITIALIZED to zero, which will indirectly - tell `finish_decl' to ignore the initializer once it is parsed. */ - switch (TREE_CODE (decl)) - { - case TYPE_DECL: - /* typedef foo = bar means give foo the same type as bar. - We haven't parsed bar yet, so `finish_decl' will fix that up. - Any other case of an initialization in a TYPE_DECL is an error. */ - if (pedantic || list_length (declspecs) > 1) - { - error ("typedef `%s' is initialized", - IDENTIFIER_POINTER (DECL_NAME (decl))); - initialized = 0; - } - break; - - case FUNCTION_DECL: - error ("function `%s' is initialized like a variable", - IDENTIFIER_POINTER (DECL_NAME (decl))); - initialized = 0; - break; - - default: - /* Don't allow initializations for incomplete types - except for arrays which might be completed by the initialization. */ - if (TYPE_SIZE (type) != 0) - ; /* A complete type is ok. */ - else if (TREE_CODE (type) != ARRAY_TYPE) - { - error ("variable `%s' has initializer but incomplete type", - IDENTIFIER_POINTER (DECL_NAME (decl))); - initialized = 0; - } - else if (TYPE_SIZE (TREE_TYPE (type)) == 0) - { - error ("elements of array `%s' have incomplete type", - IDENTIFIER_POINTER (DECL_NAME (decl))); - initialized = 0; - } - } - - if (!initialized && TREE_CODE (decl) != TYPE_DECL - && IS_AGGR_TYPE (type) && ! TREE_EXTERNAL (decl)) - { - if (TYPE_SIZE (type) == 0) - { - error ("aggregate `%s' has incomplete type and cannot be initialized", - IDENTIFIER_POINTER (DECL_NAME (decl))); - /* Change the type so that assemble_variable will give - DECL an rtl we can live with: (mem (const_int 0)). */ - TREE_TYPE (decl) = error_mark_node; - type = error_mark_node; - } - else - { - /* If any base type in the hierarchy of TYPE needs a constructor, - then we set initialized to 1. This way any nodes which are - created for the purposes of initializing this aggregate - will live as long as it does. This is necessary for global - aggregates which do not have their initializers processed until - the end of the file. */ - initialized = TYPE_NEEDS_CONSTRUCTING (type); - } - } - - if (initialized) - { - if (current_binding_level != global_binding_level - && TREE_EXTERNAL (decl)) - warning ("declaration of `%s' has `extern' and is initialized", - IDENTIFIER_POINTER (DECL_NAME (decl))); - TREE_EXTERNAL (decl) = 0; - if (current_binding_level == global_binding_level) - TREE_STATIC (decl) = 1; - - /* Tell `pushdecl' this is an initialized decl - even though we don't yet have the initializer expression. - Also tell `finish_decl' it may store the real initializer. */ - DECL_INITIAL (decl) = error_mark_node; - } - - /* Add this decl to the current binding level, but not if it - comes from another scope, e.g. a static member variable. - TEM may equal DECL or it may be a previous decl of the same name. */ - if ((TREE_CODE (decl) != PARM_DECL && DECL_CONTEXT (decl) != NULL_TREE) - || TREE_CODE (type) == LANG_TYPE) - tem = decl; - else - { - tem = pushdecl (decl); - if (TREE_CODE (tem) == TREE_LIST) - { - tree tem2 = value_member (decl, tem); - if (tem2 != NULL_TREE) - tem = TREE_VALUE (tem2); - else - { - while (tem && ! decls_match (decl, TREE_VALUE (tem))) - tem = TREE_CHAIN (tem); - if (tem == NULL_TREE) - tem = decl; - else - tem = TREE_VALUE (tem); - } - } - } - -#if 0 - /* We don't do this yet for GNU C++. */ - /* For a local variable, define the RTL now. */ - if (current_binding_level != global_binding_level - /* But not if this is a duplicate decl - and we preserved the rtl from the previous one - (which may or may not happen). */ - && DECL_RTL (tem) == 0) - { - if (TYPE_SIZE (TREE_TYPE (tem)) != 0) - expand_decl (tem); - else if (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE - && DECL_INITIAL (tem) != 0) - expand_decl (tem); - } -#endif - - if (TREE_CODE (decl) == FUNCTION_DECL && DECL_OVERLOADED (decl)) - /* @@ Also done in start_function. */ - push_overloaded_decl (tem); - - if (init_written - && ! (TREE_CODE (tem) == PARM_DECL - || (TREE_READONLY (tem) - && (TREE_CODE (tem) == VAR_DECL - || TREE_CODE (tem) == FIELD_DECL)))) - { - /* When parsing and digesting the initializer, - use temporary storage. Do this even if we will ignore the value. */ - if (current_binding_level == global_binding_level && debug_temp_inits) - { - if (TYPE_NEEDS_CONSTRUCTING (type)) - /* In this case, the initializer must lay down in permanent - storage, since it will be saved until `finish_file' is run. */ - ; - else - temporary_allocation (); - } - } - - if (flag_cadillac) - cadillac_start_decl (tem); - - return tem; -} - -/* Handle initialization of references. - These three arguments from from `finish_decl', and have the - same meaning here that they do there. */ -static void -grok_reference_init (decl, type, init, cleanupp) - tree decl, type, init; - tree *cleanupp; -{ - char *errstr = 0; - int is_reference; - tree tmp; - tree this_ptr_type, actual_init; - - if (init == NULL_TREE) - { - if (DECL_LANG_SPECIFIC (decl) == 0 || DECL_IN_AGGR_P (decl) == 0) - { - error ("variable declared as reference not initialized"); - if (TREE_CODE (decl) == VAR_DECL) - SET_DECL_REFERENCE_SLOT (decl, error_mark_node); - } - return; - } - - if (TREE_CODE (init) == TREE_LIST) - init = build_compound_expr (init); - is_reference = TREE_CODE (TREE_TYPE (init)) == REFERENCE_TYPE; - tmp = is_reference ? convert_from_reference (init) : init; - - if (is_reference) - { - if (! comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (type)), - TYPE_MAIN_VARIANT (TREE_TYPE (tmp)), 0)) - errstr = "initialization of `%s' from dissimilar reference type"; - else if (TREE_READONLY (TREE_TYPE (type)) - >= TREE_READONLY (TREE_TYPE (TREE_TYPE (init)))) - { - is_reference = 0; - init = tmp; - } - } - else - { - if (TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE - && TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE) - { - /* Note: default conversion is only called in very - special cases. */ - init = default_conversion (init); - } - if (TREE_CODE (TREE_TYPE (type)) == TREE_CODE (TREE_TYPE (init))) - { - init = convert (TREE_TYPE (type), init); - } - else if (init != error_mark_node - && ! comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (type)), - TYPE_MAIN_VARIANT (TREE_TYPE (init)), 0)) - errstr = "invalid type conversion for reference"; - } - - if (errstr) - { - /* Things did not go smoothly; look for type conversion. */ - if (IS_AGGR_TYPE (TREE_TYPE (tmp))) - { - tmp = build_type_conversion (CONVERT_EXPR, type, init, 0); - if (tmp != NULL_TREE) - { - init = tmp; - if (tmp == error_mark_node) - errstr = "ambiguous pointer conversion"; - else - errstr = 0; - is_reference = 1; - } - else - { - tmp = build_type_conversion (CONVERT_EXPR, TREE_TYPE (type), init, 0); - if (tmp != NULL_TREE) - { - init = tmp; - if (tmp == error_mark_node) - errstr = "ambiguous pointer conversion"; - else - errstr = 0; - is_reference = 0; - } - } - } - } - - if (errstr) - { - error_with_decl (decl, errstr); - if (TREE_CODE (decl) == VAR_DECL) - SET_DECL_REFERENCE_SLOT (decl, error_mark_node); - return; - } - - /* In the case of initialization, it is permissable - to assign one reference to another. */ - this_ptr_type = build_pointer_type (TREE_TYPE (type)); - - if (is_reference) - { - if (TREE_VOLATILE (init)) - DECL_INITIAL (decl) = save_expr (init); - else - DECL_INITIAL (decl) = init; - } - else if (lvalue_p (init)) - { - DECL_INITIAL (decl) = convert_pointer_to (TREE_TYPE (this_ptr_type), build_unary_op (ADDR_EXPR, init, 0)); - DECL_INITIAL (decl) = save_expr (DECL_INITIAL (decl)); - if (DECL_INITIAL (decl) == current_class_decl) - DECL_INITIAL (decl) = copy_node (current_class_decl); - TREE_TYPE (DECL_INITIAL (decl)) = type; - } - else if ((actual_init = unary_complex_lvalue (ADDR_EXPR, init))) - { - /* The initializer for this decl goes into its - DECL_REFERENCE_SLOT. Make sure that we can handle - multiple evaluations without ill effect. */ - if (TREE_CODE (actual_init) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (actual_init, 0)) == NEW_EXPR) - actual_init = save_expr (actual_init); - DECL_INITIAL (decl) = convert_pointer_to (TREE_TYPE (this_ptr_type), actual_init); - DECL_INITIAL (decl) = save_expr (DECL_INITIAL (decl)); - TREE_TYPE (DECL_INITIAL (decl)) = type; - } - else if (TREE_READONLY (TREE_TYPE (type))) - /* Section 8.4.3 allows us to make a temporary for - the initialization of const&. */ - { - tree target_type = TREE_TYPE (type); - tree tmp_addr; - tmp = get_temp_name (target_type, - current_binding_level == global_binding_level); - tmp_addr = build_unary_op (ADDR_EXPR, tmp, 0); - TREE_TYPE (tmp_addr) = build_pointer_type (target_type); - DECL_INITIAL (decl) = convert_pointer_to (TREE_TYPE (this_ptr_type), tmp_addr); - TREE_TYPE (DECL_INITIAL (decl)) = type; - if (TYPE_NEEDS_CONSTRUCTING (target_type)) - { - if (current_binding_level == global_binding_level) - { - /* lay this variable out now. Otherwise `output_addressed_constants' - gets confused by its initializer. */ - make_decl_rtl (tmp, 0, 1); - static_aggregates = perm_tree_cons (init, tmp, static_aggregates); - } - else - { - init = build_method_call (tmp, DECL_NAME (TYPE_NAME (target_type)), build_tree_list (NULL_TREE, init), NULL_TREE, LOOKUP_NORMAL); - DECL_INITIAL (decl) = build (COMPOUND_EXPR, type, init, DECL_INITIAL (decl)); - *cleanupp = maybe_build_cleanup (tmp); - } - } - else - { - DECL_INITIAL (tmp) = init; - TREE_STATIC (tmp) = current_binding_level == global_binding_level; - finish_decl (tmp, init, 0); - } - } - else - { - error_with_decl (decl, "type mismatch in initialization of `%s' (use `const')"); - DECL_INITIAL (decl) = error_mark_node; - } - - /* ?? Can this be optimized in some cases to - hand back the DECL_INITIAL slot?? */ - if (TYPE_SIZE (TREE_TYPE (type))) - SET_DECL_REFERENCE_SLOT (decl, convert_from_reference (decl)); - - if (TREE_STATIC (decl) && ! TREE_LITERAL (DECL_INITIAL (decl))) - { - expand_static_init (decl, DECL_INITIAL (decl)); - DECL_INITIAL (decl) = 0; - } -} - -/* Finish processing of a declaration; - install its line number and initial value. - If the length of an array type is not known before, - it must be determined now, from the initial value, or it is an error. - - For C++, `finish_decl' must be fairly evasive: it must keep initializers - for aggregates that have constructors alive on the permanent obstack, - so that the global initializing functions can be written at the end. - - INIT0 holds the value of an initializer that should be allowed to escape - the normal rules. - - For functions that take defualt parameters, DECL points to its - "maximal" instantiation. finish_decl must then also declared its - subsequently lower and lower forms of instantiation, checking for - ambiguity as it goes. This can be sped up later. */ - -void -finish_decl (decl, init, asmspec_tree) - tree decl, init; - tree asmspec_tree; -{ - register tree type; - tree cleanup = NULL_TREE, ttype; - int was_incomplete; - int temporary = allocation_temporary_p (); - char *asmspec = 0; - int was_readonly = 0; - - /* If this is 0, then we did not change obstacks. */ - if (! decl) - { - if (init) - error ("assignment (not initialization) in declaration"); - return; - } - - if (asmspec_tree) - { - asmspec = TREE_STRING_POINTER (asmspec_tree); - /* Zero out old RTL, since we will rewrite it. */ - DECL_RTL (decl) = 0; - } - - /* If the type of the thing we are declaring either has - a constructor, or has a virtual function table pointer, - AND its initialization was accepted by `start_decl', - then we stayed on the permanent obstack through the - declaration, otherwise, changed obstacks as GCC would. */ - - type = TREE_TYPE (decl); - - was_incomplete = (DECL_SIZE (decl) == 0); - - /* Take care of TYPE_DECLs up front. */ - if (TREE_CODE (decl) == TYPE_DECL) - { - if (init && DECL_INITIAL (decl)) - { - /* typedef foo = bar; store the type of bar as the type of foo. */ - TREE_TYPE (decl) = type = TREE_TYPE (init); - DECL_INITIAL (decl) = init = 0; - } - if (IS_AGGR_TYPE (type)) - { -#ifndef BREAK_C_TAGS - if (current_lang_name == lang_name_cplusplus) -#endif - { - if (TREE_TYPE (DECL_NAME (decl)) && TREE_TYPE (decl) != type) - warning ("shadowing previous type declaration of `%s'", - IDENTIFIER_POINTER (DECL_NAME (decl))); - TREE_TYPE (DECL_NAME (decl)) = decl; - } - CLASSTYPE_GOT_SEMICOLON (type) = 1; - } - -#ifdef FIELD_XREF - FIELD_xref_decl(current_function_decl,decl); -#endif - - rest_of_decl_compilation (decl, 0, - current_binding_level == global_binding_level, 0); - goto finish_end; - } - if (IS_AGGR_TYPE (type) && CLASSTYPE_DECLARED_EXCEPTION (type)) - { - finish_exception_decl (NULL_TREE, decl); - CLASSTYPE_GOT_SEMICOLON (type) = 1; - goto finish_end; - } - if (TREE_CODE (decl) != FUNCTION_DECL) - { - ttype = target_type (type); - if (TYPE_NAME (ttype) - && TREE_CODE (TYPE_NAME (ttype)) == TYPE_DECL - && ANON_AGGRNAME_P (DECL_NAME (TYPE_NAME (ttype)))) - { - tree old_id = DECL_NAME (TYPE_NAME (ttype)); - char *newname = (char *)alloca (IDENTIFIER_LENGTH (old_id) + 2); - newname[0] = '_'; - bcopy (IDENTIFIER_POINTER (old_id), newname + 1, - IDENTIFIER_LENGTH (old_id) + 1); - old_id = get_identifier (newname); - lookup_tag_reverse (ttype, old_id); - DECL_NAME (TYPE_NAME (ttype)) = old_id; - } - } - - if (! TREE_EXTERNAL (decl) && TREE_READONLY (decl) - && TYPE_NEEDS_CONSTRUCTING (type)) - { - - /* Currently, GNU C++ puts constants in text space, making them - impossible to initialize. In the future, one would hope for - an operating system which understood the difference between - initialization and the running of a program. */ - was_readonly = 1; - TREE_READONLY (decl) = 0; - } - - if (TREE_CODE (decl) == FIELD_DECL) - { - if (init && init != error_mark_node) - assert (TREE_PERMANENT (init)); - - if (asmspec) - { - /* This must override the asm specifier which was placed - by grokclassfn. Lay this out fresh. - - @@ Should emit an error if this redefines an asm-specified - @@ name, or if we have already used the function's name. */ - DECL_RTL (TREE_TYPE (decl)) = 0; - DECL_ASSEMBLER_NAME (decl) = asmspec; - make_decl_rtl (decl, asmspec, 0); - } - } - /* If `start_decl' didn't like having an initialization, ignore it now. */ - else if (init != 0 && DECL_INITIAL (decl) == 0) - init = 0; - else if (TREE_EXTERNAL (decl)) - ; - else if (TREE_CODE (type) == REFERENCE_TYPE) - { - grok_reference_init (decl, type, init, &cleanup); - init = 0; - } - -#ifdef FIELD_XREF - FIELD_xref_decl(current_function_decl,decl); -#endif - - if (TREE_CODE (decl) == FIELD_DECL || TREE_EXTERNAL (decl)) - ; - else if (TREE_CODE (decl) == CONST_DECL) - { - assert (TREE_CODE (decl) != REFERENCE_TYPE); - - DECL_INITIAL (decl) = init; - - /* This will keep us from needing to worry about our obstacks. */ - assert (init != 0); - init = 0; - } - else if (init) - { - if (TYPE_NEEDS_CONSTRUCTING (type)) - { - if (TREE_CODE (type) == ARRAY_TYPE) - init = digest_init (type, init, 0); - else if (TREE_CODE (init) == CONSTRUCTOR - && CONSTRUCTOR_ELTS (init) != NULL_TREE) - { - error_with_decl (decl, "`%s' must be initialized by constructor, not by `{...}'"); - init = error_mark_node; - } -#if 0 - /* fix this in `build_functional_cast' instead. - Here's the trigger code: - - struct ostream - { - ostream (); - ostream (int, char *); - ostream (char *); - operator char *(); - ostream (void *); - operator void *(); - operator << (int); - }; - int buf_size = 1024; - static char buf[buf_size]; - const char *debug(int i) { - char *b = &buf[0]; - ostream o = ostream(buf_size, b); - o << i; - return buf; - } - */ - - else if (TREE_CODE (init) == NEW_EXPR - && TREE_CODE (TREE_OPERAND (init, 1) == CPLUS_NEW_EXPR)) - { - /* User wrote something like `foo x = foo (args)' */ - assert (TREE_CODE (TREE_OPERAND (init, 0)) == VAR_DECL); - assert (DECL_NAME (TREE_OPERAND (init, 0)) == NULL_TREE); - - /* User wrote exactly `foo x = foo (args)' */ - if (TYPE_MAIN_VARIANT (type) == TREE_TYPE (init)) - { - init = build (CALL_EXPR, TREE_TYPE (init), - TREE_OPERAND (TREE_OPERAND (init, 1), 0), - TREE_OPERAND (TREE_OPERAND (init, 1), 1), 0); - TREE_VOLATILE (init) = 1; - } - } -#endif - - /* We must hide the initializer so that expand_decl - won't try to do something it does not understand. */ - if (current_binding_level == global_binding_level) - { - tree value = digest_init (type, empty_init_node, 0); - DECL_INITIAL (decl) = value; - } - else - DECL_INITIAL (decl) = error_mark_node; - } - else - { - if (TREE_CODE (init) != TREE_VEC) - init = store_init_value (decl, init); - - if (init) - /* Don't let anyone try to initialize this variable - until we are ready to do so. */ - DECL_INITIAL (decl) = error_mark_node; - } - } - else if (IS_AGGR_TYPE (type) || TYPE_NEEDS_CONSTRUCTING (type)) - { - tree ctype = type; - while (TREE_CODE (ctype) == ARRAY_TYPE) - ctype = TREE_TYPE (ctype); - if (! TYPE_NEEDS_CONSTRUCTOR (ctype)) - { - if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (ctype)) - error_with_decl (decl, "structure `%s' with uninitialized const members"); - if (CLASSTYPE_REF_FIELDS_NEED_INIT (ctype)) - error_with_decl (decl, "structure `%s' with uninitialized reference members"); - } - - if (TREE_CODE (decl) == VAR_DECL - && !TYPE_NEEDS_CONSTRUCTING (type) - && (TREE_READONLY (type) || TREE_READONLY (decl))) - error_with_decl (decl, "uninitialized const `%s'"); - - /* Initialize variables in need of static initialization - with `empty_init_node' to keep assemble_variable from putting them - in the wrong program space. */ - if (TREE_STATIC (decl) - && TREE_CODE (decl) == VAR_DECL - && TYPE_NEEDS_CONSTRUCTING (type) - && (DECL_INITIAL (decl) == 0 - || DECL_INITIAL (decl) == error_mark_node)) - { - tree value = digest_init (type, empty_init_node, 0); - DECL_INITIAL (decl) = value; - } - } - else if (TREE_CODE (decl) == VAR_DECL - && TREE_CODE (type) != REFERENCE_TYPE - && (TREE_READONLY (type) || TREE_READONLY (decl))) - { - if (! TREE_STATIC (decl)) - error_with_decl (decl, "uninitialized const `%s'"); - } - - /* For top-level declaration, the initial value was read in - the temporary obstack. MAXINDEX, rtl, etc. to be made below - must go in the permanent obstack; but don't discard the - temporary data yet. */ - - if (current_binding_level == global_binding_level && temporary) - end_temporary_allocation (); - - /* Deduce size of array from initialization, if not already known. */ - - if (TREE_CODE (type) == ARRAY_TYPE - && TYPE_DOMAIN (type) == 0 - && TREE_CODE (decl) != TYPE_DECL) - { - int do_default = ! ((!pedantic && TREE_STATIC (decl)) - || TREE_EXTERNAL (decl)); - tree initializer = init ? init : DECL_INITIAL (decl); - int failure = complete_array_type (type, initializer, do_default); - - if (failure == 1) - error_with_decl (decl, "initializer fails to determine size of `%s'"); - - if (failure == 2) - { - if (do_default) - error_with_decl (decl, "array size missing in `%s'"); - else if (!pedantic && TREE_STATIC (decl)) - TREE_EXTERNAL (decl) = 1; - } - - if (pedantic && TYPE_DOMAIN (type) != 0 - && tree_int_cst_lt (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), - integer_zero_node)) - error_with_decl (decl, "zero-size array `%s'"); - - layout_decl (decl, 0); - } - - if (TREE_CODE (decl) == VAR_DECL) - { - if (TREE_STATIC (decl) && DECL_SIZE (decl) == 0) - { - /* A static variable with an incomplete type: - that is an error if it is initialized or `static'. - Otherwise, let it through, but if it is not `extern' - then it may cause an error message later. */ - if (! (TREE_PUBLIC (decl) && DECL_INITIAL (decl) == 0)) - error_with_decl (decl, "storage size of `%s' isn't known"); - init = 0; - } - else if (!TREE_EXTERNAL (decl) && DECL_SIZE (decl) == 0) - { - /* An automatic variable with an incomplete type: - that is an error. */ - error_with_decl (decl, "storage size of `%s' isn't known"); - TREE_TYPE (decl) = error_mark_node; - } - - if ((TREE_EXTERNAL (decl) || TREE_STATIC (decl)) - && DECL_SIZE (decl) != 0 && ! TREE_LITERAL (DECL_SIZE (decl))) - error_with_decl (decl, "storage size of `%s' isn't constant"); - - if (TYPE_NEEDS_DESTRUCTOR (type)) - { - int yes = suspend_momentary (); - cleanup = maybe_build_cleanup (decl); - resume_momentary (yes); - } - } - /* PARM_DECLs get cleanups, too. */ - else if (TREE_CODE (decl) == PARM_DECL - && TYPE_NEEDS_DESTRUCTOR (type)) - { - if (temporary) - end_temporary_allocation (); - cleanup = maybe_build_cleanup (decl); - if (temporary) - resume_temporary_allocation (); - } - - /* Output the assembler code and/or RTL code for variables and functions, - unless the type is an undefined structure or union. - If not, it will get done when the type is completed. */ - - if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL - || TREE_CODE (decl) == RESULT_DECL) - { - int toplev = current_binding_level == global_binding_level; - int was_temp - = ((flag_traditional - || (TREE_STATIC (decl) && TYPE_NEEDS_DESTRUCTOR (type))) - && allocation_temporary_p ()); - - if (was_temp) - end_temporary_allocation (); - - /* If we are in need of a cleanup, get out of any implicit - handlers that have been established so far. */ - if (cleanup && current_binding_level->parm_flag == 3) - { - pop_implicit_try_blocks (decl); - current_binding_level->more_exceptions_ok = 0; - } - - if (TREE_CODE (decl) == VAR_DECL && DECL_VIRTUAL_P (decl)) - make_decl_rtl (decl, 0, toplev); - else if (TREE_CODE (decl) == VAR_DECL - && TREE_READONLY (decl) - && DECL_INITIAL (decl) != 0 - && DECL_INITIAL (decl) != error_mark_node - && DECL_INITIAL (decl) != empty_init_node) - { - DECL_INITIAL (decl) = save_expr (DECL_INITIAL (decl)); - - if (asmspec) - DECL_ASSEMBLER_NAME (decl) = asmspec; - - if (! toplev - && TREE_STATIC (decl) - && ! TREE_VOLATILE (decl) - && ! TREE_PUBLIC (decl) - && ! TREE_EXTERNAL (decl) - && ! TYPE_NEEDS_DESTRUCTOR (type) - && DECL_MODE (decl) != BLKmode) - { - /* If this variable is really a constant, then fill its DECL_RTL - slot with something which won't take up storage. - If something later should take its address, we can always give - it legitimate RTL at that time. */ - DECL_RTL (decl) = (struct rtx_def *)gen_reg_rtx (DECL_MODE (decl)); - store_expr (DECL_INITIAL (decl), DECL_RTL (decl), 0); - TREE_ASM_WRITTEN (decl) = 1; - } - else if (toplev) - { - /* Keep GCC from complaining that this variable - is defined but never used. */ - TREE_USED (decl) = 1; - make_decl_rtl (decl, asmspec, toplev); - } - else - rest_of_decl_compilation (decl, asmspec, toplev, 0); - } - else if (TREE_CODE (decl) == VAR_DECL - && DECL_LANG_SPECIFIC (decl) - && DECL_IN_AGGR_P (decl)) - { - if (TREE_STATIC (decl)) - if (init == 0 && TYPE_NEEDS_CONSTRUCTING (type)) - { - TREE_EXTERNAL (decl) = 1; - make_decl_rtl (decl, asmspec, 1); - } - else - rest_of_decl_compilation (decl, asmspec, toplev, 0); - else - /* Just a constant field. Should not need any rtl. */ - goto finish_end0; - } - else - rest_of_decl_compilation (decl, asmspec, toplev, 0); - - if (was_temp) - resume_temporary_allocation (); - - if (TYPE_LANG_SPECIFIC (type) && CLASSTYPE_ABSTRACT_VIRTUALS (type)) - abstract_virtuals_error (decl, type); - else if (TREE_CODE (type) == FUNCTION_TYPE - && TYPE_LANG_SPECIFIC (TREE_TYPE (type)) - && CLASSTYPE_ABSTRACT_VIRTUALS (TREE_TYPE (type))) - abstract_virtuals_error (decl, TREE_TYPE (type)); - - if (TREE_CODE (decl) == FUNCTION_DECL) - { - /* C++: Handle overloaded functions with defualt parameters. */ - if (DECL_OVERLOADED (decl)) - { - tree parmtypes = TYPE_ARG_TYPES (type); - tree prev = NULL_TREE; - char *original_name = IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (decl)); - struct lang_decl *tmp_lang_decl = DECL_LANG_SPECIFIC (decl); - /* All variants will share an uncollectable lang_decl. */ - copy_decl_lang_specific (decl); - - while (parmtypes && parmtypes != void_list_node) - { - if (TREE_PURPOSE (parmtypes)) - { - tree fnname, fndecl; - tree *argp = prev - ? & TREE_CHAIN (prev) - : & TYPE_ARG_TYPES (type); - - *argp = NULL_TREE; - fnname = build_decl_overload (original_name, TYPE_ARG_TYPES (type), 0); - *argp = parmtypes; - fndecl = build_decl (FUNCTION_DECL, fnname, type); - TREE_EXTERNAL (fndecl) = TREE_EXTERNAL (decl); - TREE_PUBLIC (fndecl) = TREE_PUBLIC (decl); - TREE_INLINE (fndecl) = TREE_INLINE (decl); - /* Keep G++ from thinking this function is unused. - It is only used to speed up search in name space. */ - TREE_USED (fndecl) = 1; - TREE_ASM_WRITTEN (fndecl) = 1; - DECL_INITIAL (fndecl) = NULL_TREE; - DECL_LANG_SPECIFIC (fndecl) = DECL_LANG_SPECIFIC (decl); - fndecl = pushdecl (fndecl); - DECL_INITIAL (fndecl) = error_mark_node; - DECL_RTL (fndecl) = DECL_RTL (decl); - } - prev = parmtypes; - parmtypes = TREE_CHAIN (parmtypes); - } - DECL_LANG_SPECIFIC (decl) = tmp_lang_decl; - } - } - else if (TREE_EXTERNAL (decl)) - ; - else if (TREE_STATIC (decl)) - { - /* Cleanups for static variables are handled by `finish_file'. */ - if (TYPE_NEEDS_CONSTRUCTING (type) || init != NULL_TREE) - expand_static_init (decl, init); - } - else if (current_binding_level != global_binding_level) - { - /* This is a declared decl which must live until the - end of the binding contour. It may need a cleanup. */ - - /* Recompute the RTL of a local array now - if it used to be an incomplete type. */ - if (was_incomplete && ! TREE_STATIC (decl)) - { - /* If we used it already as memory, it must stay in memory. */ - TREE_ADDRESSABLE (decl) = TREE_USED (decl); - /* If it's still incomplete now, no init will save it. */ - if (DECL_SIZE (decl) == 0) - DECL_INITIAL (decl) = 0; - expand_decl (decl); - } - else if (! TREE_ASM_WRITTEN (decl) - && (TYPE_SIZE (type) != 0 || TREE_CODE (type) == ARRAY_TYPE)) - { - /* Do this here, because we did not expand this decl's - rtl in start_decl. */ - if (DECL_RTL (decl) == 0) - expand_decl (decl); - else if (cleanup) - { - expand_decl_cleanup (NULL_TREE, cleanup); - /* Cleanup used up here. */ - cleanup = 0; - } - } - - /* Compute and store the initial value. */ - expand_decl_init (decl); - - if (init || TYPE_NEEDS_CONSTRUCTING (type)) - { - emit_line_note (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); - expand_aggr_init (decl, init, 0); - } - - /* Set this to 0 so we can tell whether an aggregate - which was initialized was ever used. */ - if (TYPE_NEEDS_CONSTRUCTING (type)) - TREE_USED (decl) = 0; - - /* Store the cleanup, if there was one. */ - if (cleanup) - { - if (! expand_decl_cleanup (decl, cleanup)) - error_with_decl (decl, "parser lost in parsing declaration of `%s'"); - } - } - finish_end0: - - /* Undo call to `pushclass' that was done in `start_decl' - due to initialization of qualified member variable. - I.e., Foo::x = 10; */ - if (TREE_CODE (decl) == VAR_DECL && DECL_CONTEXT (decl)) - popclass (1); - } - - finish_end: - - /* Resume permanent allocation, if not within a function. */ - if (temporary && current_binding_level == global_binding_level) - { - permanent_allocation (); -#if 0 - /* @@ I don't know whether this is true for GNU C++. */ - /* We need to remember that this array HAD an initialization, - but discard the actual nodes, since they are temporary anyway. */ - if (DECL_INITIAL (decl) != 0) - DECL_INITIAL (decl) = error_mark_node; -#endif - } - if (was_readonly) - TREE_READONLY (decl) = 1; - - if (flag_cadillac) - cadillac_finish_decl (decl); -} - -static void -expand_static_init (decl, init) - tree decl; - tree init; -{ - tree oldstatic = value_member (decl, static_aggregates); - if (oldstatic) - { - if (TREE_PURPOSE (oldstatic)) - error_with_decl (decl, "multiple initializations given for `%s'"); - } - else if (current_binding_level != global_binding_level) - { - /* Emit code to perform this initialization but once. */ - tree temp = get_temp_name (integer_type_node, 1); - rest_of_decl_compilation (temp, NULL_TREE, 0, 0); - expand_start_cond (build_binary_op (EQ_EXPR, temp, integer_zero_node), 0); - expand_assignment (temp, integer_one_node, 0, 0); - if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl))) - { - expand_aggr_init (decl, init, 0); - do_pending_stack_adjust (); - } - else - expand_assignment (decl, init, 0, 0); - expand_end_cond (); - if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (decl))) - { - int temporary = allocation_temporary_p (); - if (temporary) - end_temporary_allocation (); - static_aggregates = tree_cons (temp, decl, static_aggregates); - TREE_STATIC (static_aggregates) = 1; - if (temporary) - resume_temporary_allocation (); - } - } - else - { - /* This code takes into account memory allocation - policy of `start_decl'. Namely, if TYPE_NEEDS_CONSTRUCTING - does not hold for this object, then we must make permanent - the storage currently in the temporary obstack. */ - if (! TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl))) - preserve_initializer (); - static_aggregates = perm_tree_cons (init, decl, static_aggregates); - } -} - -/* Make TYPE a complete type based on INITIAL_VALUE. - Return 0 if successful, 1 if INITIAL_VALUE can't be decyphered, - 2 if there was no information (in which case assume 1 if DO_DEFAULT). */ - -int -complete_array_type (type, initial_value, do_default) - tree type; - tree initial_value; - int do_default; -{ - register tree maxindex = NULL_TREE; - int value = 0; - int temporary = (TREE_PERMANENT (type) && allocation_temporary_p ()); - - /* Don't put temporary nodes in permanent type. */ - if (temporary) - end_temporary_allocation (); - - if (initial_value) - { - /* Note MAXINDEX is really the maximum index, - one less than the size. */ - if (TREE_CODE (initial_value) == STRING_CST) - maxindex = build_int_2 (TREE_STRING_LENGTH (initial_value) - 1, 0); - else if (TREE_CODE (initial_value) == CONSTRUCTOR) - { - register int nelts - = list_length (CONSTRUCTOR_ELTS (initial_value)); - maxindex = build_int_2 (nelts - 1, 0); - } - else - { - /* Make an error message unless that happened already. */ - if (initial_value != error_mark_node) - value = 1; - - /* Prevent further error messages. */ - maxindex = build_int_2 (1, 0); - } - } - - if (!maxindex) - { - if (do_default) - maxindex = build_int_2 (1, 0); - value = 2; - } - - if (maxindex) - { - TYPE_DOMAIN (type) = build_index_type (maxindex); - if (!TREE_TYPE (maxindex)) - TREE_TYPE (maxindex) = TYPE_DOMAIN (type); - } - - /* Lay out the type now that we can get the real answer. */ - - layout_type (type); - - if (temporary) - resume_temporary_allocation (); - - return value; -} - -/* Return zero if something is declared to be a member of type - CTYPE when in the context of CUR_TYPE. STRING is the error - message to print in that case. Otherwise, quietly return 1. */ -static int -member_function_or_else (ctype, cur_type, string) - tree ctype, cur_type; - char *string; -{ - if (ctype && ctype != cur_type) - { - error (string, TYPE_NAME_STRING (ctype)); - return 0; - } - return 1; -} - -/* Subroutine of `grokdeclarator'. */ - -/* CTYPE is class type, or null if non-class. - TYPE is type this FUNCTION_DECL should have, either FUNCTION_TYPE - or METHOD_TYPE. - DECLARATOR is the function's name. - VIRTUALP is truthvalue of whether the function is virtual or not. - FLAGS are to be passed through to `grokclassfn'. - QUALS are qualifiers indicating whether the function is `const' - or `volatile'. - RAISES is a list of exceptions that this function can raise. - CHECK is 1 if we must find this method in CTYPE, 0 if we should - not look, and -1 if we should not call `grokclassfn' at all. */ -static tree -grokfndecl (ctype, type, declarator, virtualp, flags, quals, raises, check) - tree ctype, type; - tree declarator; - int virtualp; - enum overload_flags flags; - tree quals, raises; - int check; -{ - tree cname, decl; - int staticp = ctype && TREE_CODE (type) == FUNCTION_TYPE; - - if (ctype) - cname = TREE_CODE (TYPE_NAME (ctype)) == TYPE_DECL - ? DECL_NAME (TYPE_NAME (ctype)) : TYPE_NAME (ctype); - else - cname = NULL_TREE; - - if (raises) - { - type = build_exception_variant (ctype, type, raises); - raises = TYPE_RAISES_EXCEPTIONS (type); - } - decl = build_lang_decl (FUNCTION_DECL, declarator, type); - if (staticp) - { - DECL_STATIC_FUNCTION_P (decl) = 1; - DECL_STATIC_CONTEXT (decl) = ctype; - } - TREE_EXTERNAL (decl) = 1; - if (quals != NULL_TREE && TREE_CODE (type) == FUNCTION_TYPE) - { - /* Dont have DECL_ORIGINAL_NAME yet, so we cannot pretty print it. */ - error ("functions cannot have method qualifiers"); - quals = NULL_TREE; - } - - /* Caller will do the rest of this. */ - if (check < 0) - return decl; - - if (flags == NO_SPECIAL && ctype && declarator == cname) - { - tree tmp; - /* Just handle constructors here. We could do this - inside the following if stmt, but I think - that the code is more legible by breaking this - case out. See comments below for what each of - the following calls is supposed to do. */ - DECL_CONSTRUCTOR_P (decl) = 1; - - grokclassfn (ctype, declarator, decl, flags, check, quals); - grok_ctor_properties (ctype, decl); - if (check == 0) - { - tmp = lookup_name (DECL_NAME (decl)); - if (tmp == 0) - IDENTIFIER_GLOBAL_VALUE (DECL_NAME (decl)) = decl; - else if (TREE_CODE (tmp) != TREE_CODE (decl)) - error_with_decl (decl, "inconsistant declarations for `%s'"); - else - { - duplicate_decls (decl, tmp); - decl = tmp; - } - make_decl_rtl (decl, NULL_TREE, 1); - } - } - else - { - tree tmp; - int i; - - /* Function gets the ugly name, field gets the nice one. - This call may change the type of the function (because - of default parameters)! - - Wrappers get field names which will not conflict - with constructors and destructors. */ - if (ctype != NULL_TREE) - grokclassfn (ctype, cname, decl, flags, check, quals); - - if (OPERATOR_NAME_P (DECL_NAME (decl))) - { - TREE_OPERATOR (decl) = 1; - grok_op_properties (decl); - } - - if (ctype == NULL_TREE || check) - return decl; - - /* Now install the declaration of this function so that - others may find it (esp. its DECL_FRIENDLIST). - Pretend we are at top level, we will get true - reference later, perhaps. */ - tmp = lookup_name (DECL_NAME (decl)); - if (tmp == 0) - IDENTIFIER_GLOBAL_VALUE (DECL_NAME (decl)) = decl; - else if (TREE_CODE (tmp) != TREE_CODE (decl)) - error_with_decl (decl, "inconsistant declarations for `%s'"); - else - { - duplicate_decls (decl, tmp); - decl = tmp; - } - make_decl_rtl (decl, NULL_TREE, 1); - - /* If this declaration supersedes the declaration of - a method declared virtual in the base class, then - mark this field as being virtual as well. */ - for (i = 1; i <= CLASSTYPE_N_BASECLASSES (ctype); i++) - { - tree basetype = CLASSTYPE_BASECLASS (ctype, i); - if (TYPE_VIRTUAL_P (basetype) || flag_all_virtual == 1) - { - tmp = get_first_matching_virtual (basetype, decl, - flags == DTOR_FLAG); - if (tmp) - { - /* The TMP we really want is the one from the deepest - baseclass on this path, taking care not to - duplicate if we have already found it (via another - path to its virtual baseclass. */ - if (staticp) - { - error_with_decl (decl, "method `%s' may not be declared static"); - error_with_decl (tmp, "(since `%s' declared virtual in base class.)"); - break; - } - virtualp = 1; - - if ((TYPE_USES_VIRTUAL_BASECLASSES (basetype) - || TYPE_USES_MULTIPLE_INHERITANCE (ctype)) - && TYPE_MAIN_VARIANT (basetype) != DECL_VCONTEXT (tmp)) - tmp = get_first_matching_virtual (DECL_VCONTEXT (tmp), - decl, flags == DTOR_FLAG); - if (value_member (tmp, DECL_VINDEX (decl)) == NULL_TREE) - { - /* The argument types may have changed... */ - tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl)); - tree base_variant = TREE_TYPE (TREE_VALUE (argtypes)); - - argtypes = commonparms (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (tmp))), - TREE_CHAIN (argtypes)); - /* But the return type has not. */ - type = build_cplus_method_type (base_variant, TREE_TYPE (type), argtypes); - if (raises) - { - type = build_exception_variant (ctype, type, raises); - raises == TYPE_RAISES_EXCEPTIONS (type); - } - TREE_TYPE (decl) = type; - SET_DECL_VINDEX (decl, tree_cons (NULL_TREE, tmp, DECL_VINDEX (decl))); - } - } - } - } - if (virtualp) - { - DECL_VIRTUAL_P (decl) = 1; - DECL_VIRTUAL_P (declarator) = 1; - if (ctype && CLASSTYPE_VTABLE_NEEDS_WRITING (ctype) - && (write_virtuals == 2 - || (write_virtuals == 3 - && ! CLASSTYPE_INTERFACE_UNKNOWN (ctype)))) - TREE_PUBLIC (decl) = 1; - } - } - return decl; -} - -static tree -grokvardecl (ctype, type, declarator, specbits, initialized) - tree ctype, type; - tree declarator; - int specbits; -{ - tree decl; - - if (TREE_CODE (type) == OFFSET_TYPE) - { - /* If you declare a static member so that it - can be initialized, the code will reach here. */ - tree field = lookup_field (TYPE_OFFSET_BASETYPE (type), - declarator, 0); - if (field == NULL_TREE || TREE_CODE (field) != VAR_DECL) - { - tree basetype = TYPE_OFFSET_BASETYPE (type); - error ("`%s' is not a static member of class `%s'", - IDENTIFIER_POINTER (declarator), - TYPE_NAME_STRING (basetype)); - type = TREE_TYPE (type); - decl = build_decl (VAR_DECL, declarator, type); - DECL_CONTEXT (decl) = basetype; - } - else - { - decl = field; - if (initialized && DECL_INITIAL (decl) - /* Complain about multiply-initialized - member variables, but don't be faked - out if initializer is faked up from `empty_init_node'. */ - && (TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR - || CONSTRUCTOR_ELTS (DECL_INITIAL (decl)) != NULL_TREE)) - error_with_aggr_type (DECL_CONTEXT (decl), - "multiple initializations of static member `%s::%s'", - IDENTIFIER_POINTER (DECL_NAME (decl))); - } - } - else decl = build_decl (VAR_DECL, declarator, type); - - if (specbits & (1 << (int) RID_EXTERN)) - { - DECL_EXTERNAL (decl) = 1; - TREE_EXTERNAL (decl) = !initialized; - } - - /* In class context, static means one per class, - public visibility, and static storage. */ - if (DECL_FIELD_CONTEXT (decl) != 0 - && IS_AGGR_TYPE (DECL_FIELD_CONTEXT (decl))) - { - TREE_PUBLIC (decl) = 1; - TREE_STATIC (decl) = 1; - } - /* At top level, either `static' or no s.c. makes a definition - (perhaps tentative), and absence of `static' makes it public. */ - else if (current_binding_level == global_binding_level) - { - TREE_PUBLIC (decl) = !(specbits & (1 << (int) RID_STATIC)); - TREE_STATIC (decl) = ! TREE_EXTERNAL (decl); - } - /* Not at top level, only `static' makes a static definition. */ - else - { - TREE_STATIC (decl) = (specbits & (1 << (int) RID_STATIC)) != 0; - TREE_PUBLIC (decl) = TREE_EXTERNAL (decl); - /* `extern' with initialization is invalid if not at top level. */ - if ((specbits & (1 << (int) RID_EXTERN)) && initialized) - error_with_decl (decl, "`%s' has both `extern' and initializer"); - } - return decl; -} - -/* Given declspecs and a declarator, - determine the name and type of the object declared - and construct a ..._DECL node for it. - (In one case we can return a ..._TYPE node instead. - For invalid input we sometimes return 0.) - - DECLSPECS is a chain of tree_list nodes whose value fields - are the storage classes and type specifiers. - - DECL_CONTEXT says which syntactic context this declaration is in: - NORMAL for most contexts. Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL. - FUNCDEF for a function definition. Like NORMAL but a few different - error messages in each case. Return value may be zero meaning - this definition is too screwy to try to parse. - MEMFUNCDEF for a function definition. Like FUNCDEF but prepares to - handle member functions (which have FIELD context). - Return value may be zero meaning this definition is too screwy to - try to parse. - PARM for a parameter declaration (either within a function prototype - or before a function body). Make a PARM_DECL, or return void_type_node. - TYPENAME if for a typename (in a cast or sizeof). - Don't make a DECL node; just return the ..._TYPE node. - FIELD for a struct or union field; make a FIELD_DECL. - INITIALIZED is 1 if the decl has an initializer. - - In the TYPENAME case, DECLARATOR is really an absolute declarator. - It may also be so in the PARM case, for a prototype where the - argument type is specified but not the name. - - This function is where the complicated C meanings of `static' - and `extern' are intrepreted. - - For C++, if there is any monkey business to do, the function which - calls this one must do it, i.e., prepending instance variables, - renaming overloaded function names, etc. - - Note that for this C++, it is an error to define a method within a class - which does not belong to that class. - - Execpt in the case where SCOPE_REFs are implicitly known (such as - methods within a class being redundantly qualified), - declarations which involve SCOPE_REFs are returned as SCOPE_REFs - (class_name::decl_name). The caller must also deal with this. - - If a constructor or destructor is seen, and the context is FIELD, - then the type gains the attribtue TREE_HAS_x. If such a declaration - is erroneous, NULL_TREE is returned. - - QUALS is used only for FUNCDEF and MEMFUNCDEF cases. For a member - function, these are the qualifiers to give to the `this' pointer. - - May return void_type_node if the declarator turned out to be a friend. - See grokfield for details. */ - -enum return_types { return_normal, return_ctor, return_dtor, return_conversion, }; - -tree -grokdeclarator (declarator, declspecs, decl_context, initialized, raises) - tree declspecs; - tree declarator; - enum decl_context decl_context; - int initialized; - tree raises; -{ - int specbits = 0; - int nclasses = 0; - tree spec; - tree type = NULL_TREE; - int longlong = 0; - int constp; - int volatilep; - int virtualp, friendp, inlinep, staticp; - int explicit_int = 0; - int explicit_char = 0; - char *name; - tree typedef_type = 0; - int funcdef_flag = 0; - int resume_temporary = 0; - enum tree_code innermost_code = ERROR_MARK; - /* Set this to error_mark_node for FIELD_DECLs we could not handle properly. - All FIELD_DECLs we build here have `init' put into their DECL_INITIAL. */ - tree init = 0; - - /* Keep track of what sort of function is being processed - so that we can warn about default return values, or explicit - return values which do not match prescribed defaults. */ - enum return_types return_type = return_normal; - - tree dname = NULL_TREE; - tree ctype = current_class_type; - tree ctor_return_type = NULL_TREE; - enum overload_flags flags = NO_SPECIAL; - int seen_scope_ref = 0; - tree quals = 0; - - if (decl_context == FUNCDEF) - funcdef_flag = 1, decl_context = NORMAL; - else if (decl_context == MEMFUNCDEF) - funcdef_flag = -1, decl_context = FIELD; - - if (flag_traditional && allocation_temporary_p ()) - { - resume_temporary = 1; - end_temporary_allocation (); - } - - /* Look inside a declarator for the name being declared - and get it as a string, for an error message. */ - { - tree type, last = 0; - register tree decl = declarator; - name = 0; - - /* If we see something of the form `aggr_type xyzzy (a, b, c)' - it is either an old-style function declaration or a call to - a constructor. The following conditional makes recognizes this - case as being a call to a constructor. Too bad if it is not. */ - - /* For Doug Lea, also grok `aggr_type xyzzy (a, b, c)[10][10][10]'. */ - while (decl && TREE_CODE (decl) == ARRAY_REF) - { - last = decl; - decl = TREE_OPERAND (decl, 0); - } - - if (current_lang_name == lang_name_cplusplus - && decl && declspecs - && TREE_CODE (decl) == CALL_EXPR - && TREE_OPERAND (decl, 0) - && (TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE - || TREE_CODE (TREE_OPERAND (decl, 0)) == SCOPE_REF)) - { - type = TREE_CODE (TREE_VALUE (declspecs)) == IDENTIFIER_NODE - ? lookup_name (TREE_VALUE (declspecs)) : - (IS_AGGR_TYPE (TREE_VALUE (declspecs)) - ? TYPE_NAME (TREE_VALUE (declspecs)) : NULL_TREE); - - if (type && TREE_CODE (type) == TYPE_DECL - && IS_AGGR_TYPE (TREE_TYPE (type)) - && parmlist_is_exprlist (TREE_OPERAND (decl, 1))) - { - if (decl_context == FIELD - && TREE_CHAIN (TREE_OPERAND (decl, 1))) - { - /* That was an initializer list. */ - sorry ("initializer lists for field declarations"); - decl = TREE_OPERAND (decl, 0); - if (last) - { - TREE_OPERAND (last, 0) = decl; - decl = declarator; - } - declarator = decl; - init = error_mark_node; - goto bot; - } - else - { - tree init = TREE_OPERAND (decl, 1); - if (last) - { - TREE_OPERAND (last, 0) = TREE_OPERAND (decl, 0); - if (pedantic && init) - error ("arrays cannot take initializers"); - } - else - declarator = TREE_OPERAND (declarator, 0); - decl = start_decl (declarator, declspecs, 1, NULL_TREE); - finish_decl (decl, init, NULL_TREE); - return 0; - } - } - - if (parmlist_is_random (TREE_OPERAND (decl, 1))) - { - decl = TREE_OPERAND (decl, 0); - if (TREE_CODE (decl) == SCOPE_REF) - decl = TREE_OPERAND (decl, 1); - if (TREE_CODE (decl) == IDENTIFIER_NODE) - name = IDENTIFIER_POINTER (decl); - if (name) - error ("bad parameter list specification for function `%s'", - name); - else - error ("bad parameter list specification for function"); - return 0; - } - bot: - ; - } - else - /* It didn't look like we thought it would, leave the ARRAY_REFs on. */ - decl = declarator; - - while (decl) - switch (TREE_CODE (decl)) - { - case WRAPPER_EXPR: /* for C++ wrappers. */ - if (current_lang_name != lang_name_cplusplus) - error ("wrapper declared in \"%s\" language context", - IDENTIFIER_POINTER (current_lang_name)); - - ctype = NULL_TREE; - assert (flags == NO_SPECIAL); - flags = WRAPPER_FLAG; - decl = TREE_OPERAND (decl, 0); - break; - - case ANTI_WRAPPER_EXPR: /* for C++ wrappers. */ - if (current_lang_name != lang_name_cplusplus) - error ("anti-wrapper declared in \"%s\" language context", - IDENTIFIER_POINTER (current_lang_name)); - - ctype = NULL_TREE; - assert (flags == NO_SPECIAL); - flags = ANTI_WRAPPER_FLAG; - decl = TREE_OPERAND (decl, 0); - break; - - case COND_EXPR: - if (current_lang_name != lang_name_cplusplus) - error ("wrapper predicate declared in \"%s\" language context", - IDENTIFIER_POINTER (current_lang_name)); - - ctype = NULL_TREE; - assert (flags == WRAPPER_FLAG); - flags = WRAPPER_PRED_FLAG; - decl = TREE_OPERAND (decl, 0); - break; - - case BIT_NOT_EXPR: /* for C++ destructors! */ - { - tree name = TREE_OPERAND (decl, 0); - tree rename = NULL_TREE; - - if (current_lang_name != lang_name_cplusplus) - error ("destructor declared in \"%s\" language context", - IDENTIFIER_POINTER (current_lang_name)); - - assert (flags == NO_SPECIAL); - flags = DTOR_FLAG; - return_type = return_dtor; - assert (TREE_CODE (name) == IDENTIFIER_NODE); - if (ctype == NULL_TREE) - { - if (current_class_type == NULL_TREE) - { - error ("destructors must be member functions"); - flags = NO_SPECIAL; - } - else if (current_class_name != name) - rename = current_class_name; - } - else if (DECL_NAME (TYPE_NAME (ctype)) != name) - rename = DECL_NAME (TYPE_NAME (ctype)); - - if (rename) - { - error ("destructor `%s' must match class name `%s'", - IDENTIFIER_POINTER (name), - IDENTIFIER_POINTER (rename)); - TREE_OPERAND (decl, 0) = rename; - } - decl = name; - } - break; - - case ADDR_EXPR: /* C++ reference declaration */ - /* fall through */ - case ARRAY_REF: - case INDIRECT_REF: - ctype = NULL_TREE; - innermost_code = TREE_CODE (decl); - decl = TREE_OPERAND (decl, 0); - break; - - case CALL_EXPR: - innermost_code = TREE_CODE (decl); - decl = TREE_OPERAND (decl, 0); - if (decl_context == FIELD && ctype == NULL_TREE) - ctype = current_class_type; - if (ctype != NULL_TREE - && decl != NULL_TREE && flags != DTOR_FLAG - && TREE_TYPE (decl) && TREE_TYPE (TREE_TYPE (decl)) == ctype) - { - return_type = return_ctor; - ctor_return_type = ctype; - } - ctype = NULL_TREE; - break; - - case IDENTIFIER_NODE: - dname = decl; - name = IDENTIFIER_POINTER (decl); - decl = 0; - break; - - case RECORD_TYPE: - case UNION_TYPE: - case ENUMERAL_TYPE: - /* Parse error puts this typespec where - a declarator should go. */ - error ("declarator name missing"); - dname = TYPE_NAME (decl); - if (dname && TREE_CODE (dname) == TYPE_DECL) - dname = DECL_NAME (dname); - name = dname ? IDENTIFIER_POINTER (dname) : ""; - declspecs = temp_tree_cons (NULL_TREE, decl, declspecs); - decl = 0; - break; - - case OP_IDENTIFIER: - if (current_lang_name != lang_name_cplusplus) - error ("operator declared in \"%s\" language context", - IDENTIFIER_POINTER (current_lang_name)); - - /* C++ operators: if these are member functions, then - they overload the same way normal methods do. However, - if they are declared outside of a classes scope, then - they are implicitly treated like `friends', i.e., - they do not take any unseen arguments. */ - assert (flags == NO_SPECIAL); - flags = OP_FLAG; - name = "operator name"; - decl = 0; - break; - - case TYPE_EXPR: - if (current_lang_name != lang_name_cplusplus) - error ("type conversion operator declared in \"%s\" language context", - IDENTIFIER_POINTER (current_lang_name)); - - ctype = NULL_TREE; - assert (flags == NO_SPECIAL); - flags = TYPENAME_FLAG; - name = "operator "; - /* Go to the absdcl. */ - decl = TREE_OPERAND (decl, 0); - return_type = return_conversion; - break; - - /* C++ extension */ - case SCOPE_REF: - if (current_lang_name != lang_name_cplusplus) - error ("member function declared in \"%s\" language context", - IDENTIFIER_POINTER (current_lang_name)); - if (seen_scope_ref == 1) - error ("multiple `::' terms in declarator invalid"); - seen_scope_ref += 1; - { - /* Perform error checking, and convert class names to types. - We may call grokdeclarator multiple times for the same - tree structure, so only do the conversion once. In this - case, we have exactly what we want for `ctype'. */ - tree cname = TREE_OPERAND (decl, 0); - if (cname == NULL_TREE) - ctype = NULL_TREE; - else if (IS_AGGR_TYPE (cname)) - ctype = cname; - else if (! is_aggr_typedef (cname, 1)) - { - TREE_OPERAND (decl, 0) = 0; - } - /* Must test TREE_OPERAND (decl, 1), in case user gives - us `typedef (class::memfunc)(int); memfunc *memfuncptr;' */ - else if (TREE_OPERAND (decl, 1) - && TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF) - { - TREE_OPERAND (decl, 0) = TREE_TYPE (TREE_TYPE (cname)); - } - else if (ctype == NULL_TREE) - { - ctype = TREE_TYPE (TREE_TYPE (cname)); - TREE_OPERAND (decl, 0) = ctype; - } - else - { - tree new_type = get_base_type (TREE_TYPE (TREE_TYPE (cname)), ctype, 0); - if (new_type == NULL_TREE) - { - error ("type `%s' is not derived from type `%s'", - IDENTIFIER_POINTER (cname), - TYPE_NAME_STRING (ctype)); - TREE_OPERAND (decl, 0) = 0; - } - else - { - ctype = new_type; - TREE_OPERAND (decl, 0) = ctype; - } - } - decl = TREE_OPERAND (decl, 1); - if (ctype != NULL_TREE && DECL_NAME (TYPE_NAME (ctype)) == decl) - { - return_type = return_ctor; - ctor_return_type = ctype; - } - } - break; - - case ERROR_MARK: - decl = NULL_TREE; - break; - - default: - assert (0); - } - if (name == 0) - name = "type name"; - } - - /* A function definition's declarator must have the form of - a function declarator. */ - - if (funcdef_flag && innermost_code != CALL_EXPR) - return 0; - - /* Anything declared one level down from the top level - must be one of the parameters of a function - (because the body is at least two levels down). */ - - /* This heuristic cannot be applied to C++ nodes! Fixed, however, - by not allowing C++ class definitions to specify their parameters - with xdecls (must be spec.d in the parmlist). - - Since we now wait to push a class scope until we are sure that - we are in a legitimate method context, we must set oldcname - explicitly (since current_class_name is not yet alive). */ - - if (decl_context == NORMAL - && current_binding_level->level_chain == global_binding_level) - decl_context = PARM; - - /* Look through the decl specs and record which ones appear. - Some typespecs are defined as built-in typenames. - Others, the ones that are modifiers of other types, - are represented by bits in SPECBITS: set the bits for - the modifiers that appear. Storage class keywords are also in SPECBITS. - - If there is a typedef name or a type, store the type in TYPE. - This includes builtin typedefs such as `int'. - - Set EXPLICIT_INT if the type is `int' or `char' and did not - come from a user typedef. - - Set LONGLONG if `long' is mentioned twice. - - For C++, constructors and destructors have their own fast treatment. */ - - for (spec = declspecs; spec; spec = TREE_CHAIN (spec)) - { - register int i; - register tree id = TREE_VALUE (spec); - - /* Certain parse errors slip through. For example, - `int class;' is not caught by the parser. Try - weakly to recover here. */ - if (TREE_CODE (spec) != TREE_LIST) - return 0; - - if (TREE_CODE (id) == IDENTIFIER_NODE) - { - if (id == ridpointers[(int) RID_INT]) - { - if (type) - error ("extraneous `int' ignored"); - else - { - explicit_int = 1; - type = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (id)); - } - goto found; - } - if (id == ridpointers[(int) RID_CHAR]) - { - if (type) - error ("extraneous `char' ignored"); - else - { - explicit_char = 1; - type = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (id)); - } - goto found; - } - /* C++ aggregate types. */ - if (TREE_TYPE (id)) - { - if (type) - error ("multiple declarations `%s' and `%s'", - IDENTIFIER_POINTER (type), - IDENTIFIER_POINTER (id)); - else - type = TREE_TYPE (TREE_TYPE (id)); - goto found; - } - - for (i = (int) RID_FIRST_MODIFIER; i < (int) RID_MAX; i++) - { - if (ridpointers[i] == id) - { - if (i == (int) RID_LONG && specbits & (1< 1) - warning ("duplicate `const'"); - if (volatilep > 1) - warning ("duplicate `volatile'"); - virtualp = specbits & (1 << (int) RID_VIRTUAL); - if (specbits & (1 << (int) RID_STATIC)) - staticp = 1 + (decl_context == FIELD); - - if (virtualp && staticp == 2) - { - error ("member `%s' cannot be declared both virtual and static", name); - staticp = 0; - } - friendp = specbits & (1 << (int) RID_FRIEND); - specbits &= ~ ((1 << (int) RID_VIRTUAL) | (1 << (int) RID_FRIEND)); - - /* Warn if two storage classes are given. Default to `auto'. */ - - if (specbits) - { - if (specbits & 1 << (int) RID_STATIC) nclasses++; - if (specbits & 1 << (int) RID_EXTERN) nclasses++; - if (decl_context == PARM && nclasses > 0) - error ("storage class specifiers invalid in parameter declarations"); - if (specbits & 1 << (int) RID_TYPEDEF) - { - if (decl_context == PARM) - error ("typedef declaration invalid in parameter declaration"); - nclasses++; - } - if (specbits & 1 << (int) RID_AUTO) nclasses++; - if (specbits & 1 << (int) RID_REGISTER) nclasses++; - } - - /* Give error if `virtual' is used outside of class declaration. */ - if (virtualp && current_class_name == NULL_TREE) - { - error ("virtual outside class declaration"); - virtualp = 0; - } - - /* Warn about storage classes that are invalid for certain - kinds of declarations (parameters, typenames, etc.). */ - - if (nclasses > 1) - error ("multiple storage classes in declaration of `%s'", name); - else if (decl_context != NORMAL && nclasses > 0) - { - if (decl_context == PARM && (specbits & ((1 << (int) RID_REGISTER)|(1 << (int) RID_AUTO)))) - ; - else if (decl_context == FIELD - && (specbits - & (/* C++ allows static class elements */ - (1 << (int) RID_STATIC) - /* ...and inlines */ - | (1 << (int) RID_INLINE) - /* ...and signed and unsigned elements. */ - | (1 << (int) RID_SIGNED) - | (1 << (int) RID_UNSIGNED)))) - ; - else if (decl_context == FIELD && (specbits & (1 << (int) RID_TYPEDEF))) - { - /* A typedef which was made in a class's scope. */ - tree loc_typedecl; - register int i = sizeof (struct lang_decl_flags) / sizeof (int); - register int *pi; - - /* keep `grokdeclarator' from thinking we are in PARM context. */ - pushlevel (0); - loc_typedecl = start_decl (declarator, declspecs, initialized, NULL_TREE); - - pi = (int *) permalloc (sizeof (struct lang_decl_flags)); - while (i > 0) - pi[--i] = 0; - DECL_LANG_SPECIFIC (loc_typedecl) = (struct lang_decl *) pi; - poplevel (0, 0, 0); - - if (TREE_CODE (TREE_TYPE (loc_typedecl)) == ENUMERAL_TYPE) - { - tree ref = lookup_tag (ENUMERAL_TYPE, DECL_NAME (loc_typedecl), current_binding_level, 0); - if (! ref) - pushtag (DECL_NAME (loc_typedecl), TREE_TYPE (loc_typedecl)); - } - if (IDENTIFIER_CLASS_VALUE (DECL_NAME (loc_typedecl))) - error_with_decl (loc_typedecl, - "typedef of `%s' in class scope hides previous declaration"); -#if 0 - /* Must push this into scope via `pushdecl_class_level'. */ - IDENTIFIER_CLASS_VALUE (DECL_NAME (loc_typedecl)) = loc_typedecl; -#endif - return loc_typedecl; - } - else - { - error ((decl_context == FIELD - ? "storage class specified for structure field `%s'" - : (decl_context == PARM - ? "storage class specified for parameter `%s'" - : "storage class specified for typename")), - name); - specbits &= ~ ((1 << (int) RID_REGISTER) | (1 << (int) RID_AUTO) - | (1 << (int) RID_EXTERN)); - } - } - else if (current_binding_level == global_binding_level) - { - if (specbits & (1 << (int) RID_AUTO)) - error ("top-level declaration of `%s' specifies `auto'", name); -#if 0 - if (specbits & (1 << (int) RID_REGISTER)) - error ("top-level declaration of `%s' specifies `register'", name); -#endif -#if 0 - /* I'm not sure under what circumstances we should turn - on the extern bit, and under what circumstances we should - warn if other bits are turned on. */ - if (decl_context == NORMAL - && (specbits & (1 << (int) RID_EXTERN)) == 0 - && ! root_lang_context_p ()) - { - specbits |= (1 << (int) RID_EXTERN); - } -#endif - } - - /* Now figure out the structure of the declarator proper. - Descend through it, creating more complex types, until we reach - the declared identifier (or NULL_TREE, in an absolute declarator). */ - - while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE) - { - /* Each level of DECLARATOR is either an ARRAY_REF (for ...[..]), - an INDIRECT_REF (for *...), - a CALL_EXPR (for ...(...)), - an identifier (for the name being declared) - or a null pointer (for the place in an absolute declarator - where the name was omitted). - For the last two cases, we have just exited the loop. - - For C++ it could also be - a SCOPE_REF (for class :: ...). In this case, we have converted - sensible names to types, and those are the values we use to - qualify the member name. - an ADDR_EXPR (for &...), - a BIT_NOT_EXPR (for destructors) - a TYPE_EXPR (for operator typenames) - a WRAPPER_EXPR (for wrappers) - an ANTI_WRAPPER_EXPR (for averting wrappers) - - At this point, TYPE is the type of elements of an array, - or for a function to return, or for a pointer to point to. - After this sequence of ifs, TYPE is the type of the - array or function or pointer, and DECLARATOR has had its - outermost layer removed. */ - - if (TREE_CODE (type) == ERROR_MARK - && TREE_CODE (declarator) != OP_IDENTIFIER) - { - if (TREE_CODE (declarator) == SCOPE_REF) - declarator = TREE_OPERAND (declarator, 1); - else - declarator = TREE_OPERAND (declarator, 0); - continue; - } - if (quals != NULL_TREE - && (declarator == NULL_TREE - || TREE_CODE (declarator) != SCOPE_REF)) - { - if (ctype == NULL_TREE && TREE_CODE (type) == METHOD_TYPE) - ctype = TYPE_METHOD_BASETYPE (type); - if (ctype != NULL_TREE) - { - tree dummy = build_decl (TYPE_DECL, NULL_TREE, type); - ctype = grok_method_quals (ctype, dummy, quals); - type = TREE_TYPE (dummy); - quals = NULL_TREE; - } - } - switch (TREE_CODE (declarator)) - { - case ARRAY_REF: - { - register tree itype = NULL_TREE; - register tree size = TREE_OPERAND (declarator, 1); - - declarator = TREE_OPERAND (declarator, 0); - - /* Check for some types that there cannot be arrays of. */ - - if (type == void_type_node) - { - error ("declaration of `%s' as array of voids", name); - type = error_mark_node; - } - - if (TREE_CODE (type) == FUNCTION_TYPE) - { - error ("declaration of `%s' as array of functions", name); - type = error_mark_node; - } - - if (size == error_mark_node) - type = error_mark_node; - - if (type == error_mark_node) - continue; - - if (size) - { - /* Must suspend_momentary here because the index - type may need to live until the end of the function. - For example, it is used in the declaration of a - variable which requires destructing at the end of - the function; then build_vec_delete will need this - value. */ - int yes = suspend_momentary (); - /* might be a cast */ - if (TREE_CODE (size) == NOP_EXPR - && TREE_TYPE (size) == TREE_TYPE (TREE_OPERAND (size, 0))) - size = TREE_OPERAND (size, 0); - - if (TREE_CODE (TREE_TYPE (size)) != INTEGER_TYPE - && TREE_CODE (TREE_TYPE (size)) != ENUMERAL_TYPE) - { - error ("size of array `%s' has non-integer type", name); - size = integer_one_node; - } - if (TREE_READONLY_DECL_P (size)) - size = decl_constant_value (size); - if (pedantic && integer_zerop (size)) - warning ("ANSI C forbids zero-size array `%s'", name); - if (TREE_LITERAL (size)) - { - if (INT_CST_LT (size, integer_zero_node)) - { - error ("size of array `%s' is negative", name); - size = integer_one_node; - } - itype = build_index_type (build_int_2 (TREE_INT_CST_LOW (size) - 1, 0)); - } - else - { - if (pedantic) - warning ("ANSI C forbids variable-size array `%s'", name); - itype = build_binary_op (MINUS_EXPR, size, integer_one_node); - itype = build_index_type (itype); - } - resume_momentary (yes); - } - - /* Build the array type itself. - Merge any constancy or volatility into the target type. */ - - if (constp || volatilep) - type = build_type_variant (type, constp, volatilep); - -#if 0 /* don't clear these; leave them set so that the array type - or the variable is itself const or volatile. */ - constp = 0; - volatilep = 0; -#endif - - type = build_cplus_array_type (type, itype); - ctype = NULL_TREE; - } - break; - - case CALL_EXPR: - { - tree arg_types; - - /* Declaring a function type. - Make sure we have a valid type for the function to return. */ - /* Is this an error? Should they be merged into TYPE here? */ - if (pedantic && (constp || volatilep)) - warning ("function declared to return const or volatile result"); - - /* Warn about some types functions can't return. */ - - if (TREE_CODE (type) == FUNCTION_TYPE) - { - error ("`%s' declared as function returning a function", name); - type = integer_type_node; - } - if (TREE_CODE (type) == ARRAY_TYPE) - { - error ("`%s' declared as function returning an array", name); - type = integer_type_node; - } - - if (ctype == NULL_TREE - && decl_context == FIELD - && (friendp == 0 || dname == current_class_name)) - ctype = current_class_type; - - if (ctype && flags == TYPENAME_FLAG) - TYPE_HAS_CONVERSION (ctype) = 1; - if (ctype && DECL_NAME (TYPE_NAME (ctype)) == dname) - { - /* We are within a class's scope. If our declarator name - is the same as the class name, and we are defining - a function, then it is a constructor/destructor, and - therefore returns a void type. */ - - if (flags == DTOR_FLAG) - { - if (staticp == 2) - error ("destructor cannot be static member function"); - if (decl_context == FIELD) - { - if (! member_function_or_else (ctype, current_class_type, - "destructor for alien class `%s' cannot be a member")) - return NULL_TREE; - if (TYPE_HAS_DESTRUCTOR (ctype)) - error_with_aggr_type (ctype, "class `%s' already has destructor defined"); - } - } - else if (flags == WRAPPER_FLAG || flags == ANTI_WRAPPER_FLAG) - { - if (staticp == 2) - error ("wrapper cannot be static member function"); - if (decl_context == FIELD) - { - if (! member_function_or_else (ctype, current_class_type, - "wrapper for alien class `%s' cannot be member")) - return NULL_TREE; - TYPE_WRAP_TYPE (ctype) = TYPE_MAIN_VARIANT (ctype); - } - } - else if (flags == WRAPPER_PRED_FLAG) - { - if (staticp == 2) - error ("wrapper predicate cannot be static member function"); - if (TREE_CODE (type) != INTEGER_TYPE) - { - error ("wrapper predicated must return an integer type"); - type = integer_type_node; - } - if (decl_context == FIELD) - { - if (! member_function_or_else (ctype, current_class_type, - "wrapper predicate for alien class `%s' cannot be member")) - return NULL_TREE; - TYPE_HAS_WRAPPER_PRED (ctype) = 1; - } - } - else /* its a constructor. */ - { - if (staticp == 2) - error ("constructor cannot be static member function"); - if (virtualp || friendp) - { - error ("constructors cannot be declared virtual or friend"); - virtualp = 0; - friendp = 0; - } - if (specbits & ~((1 << (int) RID_INLINE)|(1 << (int) RID_STATIC))) - error ("return value type specifier for `%s' ignored", - flags == DTOR_FLAG ? "destructor" : "constructor"); - type = TYPE_POINTER_TO (ctype); - if (decl_context == FIELD) - { - if (! member_function_or_else (ctype, current_class_type, - "constructor for alien class `%s' cannot be member")) - return NULL_TREE; - TYPE_HAS_CONSTRUCTOR (ctype) = 1; - assert (return_type == return_ctor); - } - } - if (decl_context == FIELD) - staticp = 0; - } - else if (friendp && virtualp) - { - /* Cannot be both friend and virtual. */ - error ("virtual functions cannot be friends"); - specbits ^= (1 << (int) RID_FRIEND); - } - - if (decl_context == NORMAL && friendp) - error ("friend declaration not in class definition"); - - /* Picky up type qualifiers which should be applied to `this'. */ - quals = TREE_OPERAND (declarator, 2); - - /* Traditionally, declaring return type float means double. */ - - if (flag_traditional && type == float_type_node) - type = double_type_node; - - /* Construct the function type and go to the next - inner layer of declarator. */ - - { - int funcdef_p; - tree inner_parms = TREE_OPERAND (declarator, 1); - tree inner_decl = TREE_OPERAND (declarator, 0); - - declarator = TREE_OPERAND (declarator, 0); - - if (inner_decl && TREE_CODE (inner_decl) == SCOPE_REF) - inner_decl = TREE_OPERAND (inner_decl, 1); - - /* Say it's a definition only for the CALL_EXPR - closest to the identifier. */ - funcdef_p = - (inner_decl && - (TREE_CODE (inner_decl) == IDENTIFIER_NODE - || TREE_CODE (inner_decl) == OP_IDENTIFIER - || TREE_CODE (inner_decl) == TYPE_EXPR)) ? funcdef_flag : 0; - - arg_types = grokparms (inner_parms, funcdef_p); - } - - if (declarator) - { - /* Get past destructors, wrappers, etc. - We know we have one because FLAGS will be non-zero. - - Complain about improper parameter lists here. */ - if (TREE_CODE (declarator) == BIT_NOT_EXPR) - { - declarator = TREE_OPERAND (declarator, 0); - - if (strict_prototype == 0 && arg_types == NULL_TREE) - arg_types = void_list_node; - else if (arg_types == NULL_TREE - || arg_types != void_list_node) - { - error ("destructors cannot be specified with parameters"); - arg_types = void_list_node; - } - } - else if (TREE_CODE (declarator) == WRAPPER_EXPR) - { - /* Report misuse of wrappers and their associates. - Note that because wrappers may be invoked - quite a bit implicitly, if we give an error - message, we make an effort to fix that error - so that spurious errors do not show up. */ - if (TREE_CODE (TREE_OPERAND (declarator, 0)) == COND_EXPR) - { - /* First parameter must be a pointer to a member function. - Rest of parameters must all be default parameters. */ - if (arg_types == NULL_TREE - || arg_types == void_list_node - || TREE_CODE (TREE_VALUE (arg_types)) != POINTER_TYPE - || TREE_CODE (TREE_TYPE (TREE_VALUE (arg_types))) != METHOD_TYPE) - { - error ("wrapper predicate takes a pointer-to-member-function as first argument"); - arg_types = NULL_TREE; - } - else if (TREE_CHAIN (arg_types) - && TREE_CHAIN (arg_types) != void_list_node - && TREE_PURPOSE (TREE_CHAIN (arg_types)) == NULL_TREE) - { - error ("all arguments past first must be default for wrapper predicate"); - TREE_CHAIN (arg_types) = NULL_TREE; - } - declarator = wrapper_pred_name; - } - else - { - /* First parameter must be an int. - Second parameter must be a pointer to a member function. */ - if (arg_types == NULL_TREE || TREE_CHAIN (arg_types) == NULL_TREE) - { - error ("wrappers must have at least two arguments (int, pointer-to-member-function)"); - arg_types = NULL_TREE; - } - else - { - if (TREE_CODE (TREE_VALUE (arg_types)) != INTEGER_TYPE) - { - error ("first argument to wrapper must be an integer"); - TREE_VALUE (arg_types) = integer_type_node; - } - if (TREE_CODE (TREE_VALUE (TREE_CHAIN (arg_types))) != POINTER_TYPE - || TREE_CODE (TREE_TYPE (TREE_VALUE (TREE_CHAIN (arg_types)))) != METHOD_TYPE) - { - error ("second argument to wrapper must be a pointer-to-member-function type"); - TREE_CHAIN (arg_types) = NULL_TREE; - } - } - declarator = wrapper_name; - } - } - else if (TREE_CODE (declarator) == ANTI_WRAPPER_EXPR) - declarator = anti_wrapper_name; - } - - type = build_function_type (type, flag_traditional ? 0 : arg_types); - } - break; - - case ADDR_EXPR: - case INDIRECT_REF: - /* Filter out pointers-to-references and references-to-references. - We can get these if a TYPE_DECL is used. */ - - if (TREE_CODE (type) == REFERENCE_TYPE) - { - error ("cannot declare %s to references", - TREE_CODE (declarator) == ADDR_EXPR - ? "references" : "pointers"); - declarator = TREE_OPERAND (declarator, 0); - continue; - } - - /* Merge any constancy or volatility into the target type - for the pointer. */ - - if (constp || volatilep) - { - type = build_type_variant (type, constp, volatilep); - if (IS_AGGR_TYPE (type)) - build_pointer_type (type); - } - constp = 0; - volatilep = 0; - - if (TREE_CODE (declarator) == ADDR_EXPR) - if (TREE_CODE (type) == FUNCTION_TYPE) - { - error ("cannot declare references to functions; use pointer to function instead"); - type = build_pointer_type (type); - } - else - { - if (TYPE_MAIN_VARIANT (type) == void_type_node) - error ("invalid type: `void &'"); - else - type = build_reference_type (type); - } - else - type = build_pointer_type (type); - - /* Process a list of type modifier keywords (such as - const or volatile) that were given inside the `*' or `&'. */ - - if (TREE_TYPE (declarator)) - { - register tree typemodlist; - int erred = 0; - for (typemodlist = TREE_TYPE (declarator); typemodlist; - typemodlist = TREE_CHAIN (typemodlist)) - { - if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_CONST]) - constp++; - else if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_VOLATILE]) - volatilep++; - else if (!erred) - { - erred = 1; - error ("invalid type modifier within %s declarator", - TREE_CODE (declarator) == ADDR_EXPR - ? "reference" : "pointer"); - } - } - if (constp > 1) - warning ("duplicate `const'"); - if (volatilep > 1) - warning ("duplicate `volatile'"); - } - declarator = TREE_OPERAND (declarator, 0); - ctype = NULL_TREE; - break; - - case SCOPE_REF: - { - /* We have converted type names to NULL_TREE if the - name was bogus, or to a _TYPE node, if not. - - The variable CTYPE holds the type we will ultimately - resolve to. The code here just needs to build - up appropriate member types. */ - tree sname = TREE_OPERAND (declarator, 1); - - if (TREE_OPERAND (declarator, 0) == NULL_TREE) - { - /* We had a reference to a global decl, or - perhaps we were given a non-aggregate typedef, - in which case we cleared this out, and should just - keep going as though it wasn't there. */ - declarator = sname; - continue; - } - ctype = TREE_OPERAND (declarator, 0); - - if (sname == NULL_TREE) - goto done_scoping; - - /* Destructors can have their visibilities changed as well. */ - if (TREE_CODE (sname) == BIT_NOT_EXPR) - sname = TREE_OPERAND (sname, 0); - - if (TREE_CODE (sname) == IDENTIFIER_NODE) - { - /* This is the `standard' use of the scoping operator: - basetype :: member . */ - - if (ctype == current_class_type || friendp) - if (TREE_CODE (type) == FUNCTION_TYPE) - type = build_cplus_method_type (ctype, TREE_TYPE (type), TYPE_ARG_TYPES (type)); - else - type = build_member_type (ctype, type); - else if (TYPE_SIZE (ctype) != 0 - || (specbits & (1<<(int)RID_TYPEDEF))) - { - tree t; - /* have to move this code elsewhere in this function. - this code is used for i.e., typedef int A::M; M *pm; */ - - if (decl_context == FIELD) - { - t = lookup_field (ctype, sname, 0); - if (t) - { - t = build_lang_field_decl (FIELD_DECL, build_nt (SCOPE_REF, ctype, t), type); - DECL_INITIAL (t) = init; - return t; - } - /* No such field, try member functions. */ - t = lookup_fnfields (CLASSTYPE_AS_LIST (ctype), sname, 0); - if (t) - { - if (flags == DTOR_FLAG) - t = TREE_VALUE (t); - else if (CLASSTYPE_METHOD_VEC (ctype) - && TREE_VALUE (t) == TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (ctype), 0)) - { - /* Don't include destructor with constructors. */ - t = TREE_CHAIN (TREE_VALUE (t)); - if (t == NULL_TREE) - error ("class `%s' does not have any constructors", IDENTIFIER_POINTER (sname)); - t = build_tree_list (NULL_TREE, t); - } - t = build_lang_field_decl (FIELD_DECL, build_nt (SCOPE_REF, ctype, t), type); - DECL_INITIAL (t) = init; - return t; - } - - if (flags == TYPENAME_FLAG) - error_with_aggr_type (ctype, "type conversion is not a member of structure `%s'"); - else - error ("field `%s' is not a member of structure `%s'", - IDENTIFIER_POINTER (sname), - TYPE_NAME_STRING (ctype)); - } - if (TREE_CODE (type) == FUNCTION_TYPE) - type = build_cplus_method_type (ctype, TREE_TYPE (type), TYPE_ARG_TYPES (type)); - else - type = build_member_type (ctype, type); - } - else - sorry ("structure `%s' not yet defined", - TYPE_NAME_STRING (ctype)); - declarator = sname; - } - else if (TREE_CODE (sname) == TYPE_EXPR) - { - /* A TYPE_EXPR will change types out from under us. - So do the TYPE_EXPR now, and make this SCOPE_REF - inner to the TYPE_EXPR's CALL_EXPR. - - This does not work if we don't get a CALL_EXPR back. - I did not think about error recovery, hence the - assert (0). */ - - /* Get the CALL_EXPR. */ - sname = grokoptypename (sname, 0); - assert (TREE_CODE (sname) == CALL_EXPR); - type = TREE_TYPE (TREE_OPERAND (sname, 0)); - /* Scope the CALL_EXPR's name. */ - TREE_OPERAND (declarator, 1) = TREE_OPERAND (sname, 0); - /* Put the SCOPE_EXPR in the CALL_EXPR's innermost position. */ - TREE_OPERAND (sname, 0) = declarator; - /* Now work from the CALL_EXPR. */ - declarator = sname; - continue; - } - else if (TREE_CODE (sname) == SCOPE_REF) - abort (); - else - { - done_scoping: - declarator = TREE_OPERAND (declarator, 1); - if (declarator && TREE_CODE (declarator) == CALL_EXPR) - /* In this case, we will deal with it later. */ - ; - else - { - if (TREE_CODE (type) == FUNCTION_TYPE) - type = build_cplus_method_type (ctype, TREE_TYPE (type), TYPE_ARG_TYPES (type)); - else - type = build_member_type (ctype, type); - } - } - } - break; - - case OP_IDENTIFIER: - /* This is exceptional, in that we must finalize a - member type before calling grokopexpr, if we want - to use the declared type information to resolve - ambiguities. Do not get fooled by friends, - which do not have a member type built for them - unless they were explicitly scoped (in which case that - will have been taken care of in the SCOPE_REF case. */ - if (TREE_CODE (type) != FUNCTION_TYPE - && TREE_CODE (type) != METHOD_TYPE) - { - error ("operator name missing at this point in file"); - if (ctype) - type = build_cplus_method_type (ctype, type, NULL_TREE); - else - type = build_function_type (type, NULL_TREE); - } - if (TREE_CODE (TREE_OPERAND (declarator, 0)) == NEW_EXPR) - { - int was_method = ctype || TREE_CODE (type) == METHOD_TYPE; - type = coerce_new_type (ctype, type); - if (was_method) - staticp = 2; - } - else if (TREE_CODE (TREE_OPERAND (declarator, 0)) == DELETE_EXPR) - { - int was_method = ctype || TREE_CODE (type) == METHOD_TYPE; - type = coerce_delete_type (ctype, type); - if (was_method) - staticp = 2; - } - else if (TREE_CODE (type) == FUNCTION_TYPE - && ctype != 0 - && (friendp == 0 || staticp < 2)) - type = build_cplus_method_type (ctype, TREE_TYPE (type), TYPE_ARG_TYPES (type)); - { - tree tmp = declarator; - declarator = grokopexpr (&tmp, ctype, type, 0, - staticp == 2 ? 2 : 1); - } - if (declarator == NULL_TREE) - return NULL_TREE; - name = IDENTIFIER_POINTER (declarator); - break; - - case BIT_NOT_EXPR: - declarator = TREE_OPERAND (declarator, 0); - break; - - case TYPE_EXPR: - declarator = grokoptypename (declarator, 0); - if (explicit_int != -1) - if (comp_target_types (type, TREE_TYPE (TREE_OPERAND (declarator, 0)), 1) == 0) - error ("type conversion function declared to return incongruent type"); - else - warning ("return type specified for type conversion function"); - type = TREE_TYPE (TREE_OPERAND (declarator, 0)); - break; - - case WRAPPER_EXPR: - if (TREE_CODE (TREE_OPERAND (declarator, 0)) == COND_EXPR) - declarator = wrapper_pred_name; - else - declarator = wrapper_name; - break; - - case ANTI_WRAPPER_EXPR: - declarator = anti_wrapper_name; - break; - - case RECORD_TYPE: - case UNION_TYPE: - case ENUMERAL_TYPE: - declarator = 0; - break; - - case ERROR_MARK: - declarator = 0; - break; - - default: - assert (0); - } - - /* layout_type (type); */ -#if 0 - /* @@ Should perhaps replace the following code by changes in - * @@ stor_layout.c. */ - if (TREE_CODE (type) == FUNCTION_DECL) - { - /* A function variable in C should be Pmode rather than EPmode - because it has just the address of a function, no static chain.*/ - TYPE_MODE (type) = Pmode; - } -#endif - } - - /* Now TYPE has the actual type. */ - - /* If this is declaring a typedef name, return a TYPE_DECL. */ - - if (specbits & (1 << (int) RID_TYPEDEF)) - { - tree decl; - - /* Note that the grammar rejects storage classes - in typenames, fields or parameters. */ - if (constp || volatilep) - type = build_type_variant (type, constp, volatilep); - - /* If the user declares "struct {...} foo" then `foo' will have - an anonymous name. Fill that name in now. Nothing can - refer to it, so nothing needs know about the name change. - The TYPE_NAME field was filled in by build_struct_xref. */ - if (TYPE_NAME (type) -#ifndef BREAK_C_TAGS - && current_lang_name == lang_name_cplusplus -#endif - && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL - && ANON_AGGRNAME_P (DECL_NAME (TYPE_NAME (type)))) - { - /* replace the anonymous name with the real name everywhere. */ - lookup_tag_reverse (type, declarator); - DECL_NAME (TYPE_NAME (type)) = declarator; - - /* Replace names of default constructors and/or destructors. */ - if (TYPE_LANG_SPECIFIC (type) && CLASSTYPE_METHOD_VEC (type)) - { - tree method_vec = CLASSTYPE_METHOD_VEC (type); - tree fnptr = TREE_VEC_ELT (method_vec, 0); - while (fnptr) - { - DECL_ORIGINAL_NAME (fnptr) = declarator; - fnptr = TREE_CHAIN (fnptr); - } - } - } - - decl = build_decl (TYPE_DECL, declarator, type); - if (quals) - { - if (ctype == NULL_TREE) - { - assert (TREE_CODE (type) == METHOD_TYPE); - ctype = TYPE_METHOD_BASETYPE (type); - } - grok_method_quals (ctype, decl, quals); - } - - if (resume_temporary) - resume_temporary_allocation (); - return decl; - } - - /* Detect the case of an array type of unspecified size - which came, as such, direct from a typedef name. - We must copy the type, so that each identifier gets - a distinct type, so that each identifier's size can be - controlled separately by its own initializer. */ - - if (type == typedef_type && TREE_CODE (type) == ARRAY_TYPE - && TYPE_DOMAIN (type) == 0) - { - type = build_cplus_array_type (TREE_TYPE (type), TYPE_DOMAIN (type)); - } - - /* If this is a type name (such as, in a cast or sizeof), - compute the type and return it now. */ - - if (decl_context == TYPENAME) - { - /* Note that the grammar rejects storage classes - in typenames, fields or parameters. */ - if (constp || volatilep) - type = build_type_variant (type, constp, volatilep); - - /* Special case: "friend class foo" looks like a TYPENAME context. */ - if (friendp) - { - /* A friendly class? */ - make_friend_class (current_class_type, TYPE_MAIN_VARIANT (type)); - type = void_type_node; - } - else if (quals) - { - tree dummy = build_decl (TYPE_DECL, declarator, type); - if (ctype == NULL_TREE) - { - assert (TREE_CODE (type) == METHOD_TYPE); - ctype = TYPE_METHOD_BASETYPE (type); - } - grok_method_quals (ctype, dummy, quals); - type = TREE_TYPE (dummy); - } - - if (resume_temporary) - resume_temporary_allocation (); - return type; - } - - /* `void' at top level (not within pointer) - is allowed only in typedefs or type names. - We don't complain about parms either, but that is because - a better error message can be made later. */ - - if (type == void_type_node && decl_context != PARM) - { - if (declarator != NULL_TREE - && TREE_CODE (declarator) == IDENTIFIER_NODE) - error ("variable or field `%s' declared void", name); - else - error ("variable or field declared void"); - type = integer_type_node; - } - - /* Now create the decl, which may be a VAR_DECL, a PARM_DECL - or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE. */ - - { - register tree decl; - - if (decl_context == PARM) - { - if (ctype) - error ("cannot use `::' in parameter declaration"); - if (virtualp) - error ("parameter declared `virtual'"); - if (quals) - error ("`const' and `volatile' function specifiers invalid in parameter declaration"); - if (friendp) - error ("invalid friend declaration"); - if (raises) - error ("invalid raises declaration"); - - /* A parameter declared as an array of T is really a pointer to T. - One declared as a function is really a pointer to a function. - One declared as a member is really a pointer to member. */ - - if (TREE_CODE (type) == ARRAY_TYPE) - { - /* Transfer const-ness of array into that of type pointed to. */ - type = build_pointer_type - (build_type_variant (TREE_TYPE (type), constp, volatilep)); - volatilep = constp = 0; - } - else if (TREE_CODE (type) == FUNCTION_TYPE) - type = build_pointer_type (type); - else if (TREE_CODE (type) == OFFSET_TYPE) - type = build_pointer_type (type); - - decl = build_decl (PARM_DECL, declarator, type); - - /* Compute the type actually passed in the parmlist, - for the case where there is no prototype. - (For example, shorts and chars are passed as ints.) - When there is a prototype, this is overridden later. */ - - DECL_ARG_TYPE (decl) = type; - if (type == float_type_node) - DECL_ARG_TYPE (decl) = double_type_node; - else if (TREE_CODE (type) == INTEGER_TYPE - && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) - DECL_ARG_TYPE (decl) = integer_type_node; - } - else if (decl_context == FIELD) - { - if (type == error_mark_node) - { - /* Happens when declaring arrays of sizes which - are error_mark_node, for example. */ - decl = NULL_TREE; - } - else if (TREE_CODE (type) == FUNCTION_TYPE) - { - if (current_lang_name == lang_name_c) - { - error ("field `%s' declared as a function in %s language context", - name, IDENTIFIER_POINTER (current_lang_name)); - type = build_pointer_type (type); - } - else - { - if (friendp == 0) - { - if (ctype == NULL_TREE) - ctype = current_class_type; - if (staticp < 2) - type = build_cplus_method_type (ctype, TREE_TYPE (type), TYPE_ARG_TYPES (type)); - } - decl = grokfndecl (ctype, type, declarator, virtualp, flags, quals, raises, friendp ? -1 : 0); - TREE_INLINE (decl) = inlinep; - if (specbits & (1 << (int) RID_EXTERN)) - TREE_PUBLIC (decl) = 1; - } - } - else if (TREE_CODE (type) == METHOD_TYPE) - { - decl = grokfndecl (ctype, type, declarator, virtualp, flags, quals, raises, friendp ? -1 : 0); - TREE_INLINE (decl) = inlinep; - if (specbits & (1 << (int) RID_EXTERN)) - TREE_PUBLIC (decl) = 1; - } - else if (TREE_CODE (type) == RECORD_TYPE - && CLASSTYPE_DECLARED_EXCEPTION (type)) - { - /* Handle a class-local exception declaration. */ - decl = build_lang_field_decl (VAR_DECL, declarator, type); - if (ctype == NULL_TREE) - ctype = current_class_type; - finish_exception_decl (TREE_CODE (TYPE_NAME (ctype)) == TYPE_DECL - ? DECL_NAME (TYPE_NAME (ctype)) : TYPE_NAME (ctype), decl); - return void_type_node; - } - else if (TYPE_SIZE (type) == 0 && !staticp - && (TREE_CODE (type) != ARRAY_TYPE || initialized == 0)) - { - if (declarator) - error ("field `%s' has incomplete type", - IDENTIFIER_POINTER (declarator)); - else - error ("field has incomplete type"); - type = error_mark_node; - decl = NULL_TREE; - } - else - { - if (friendp) - { - if (declarator) - error ("`%s' is neither function nor method; cannot be declared friend", - IDENTIFIER_POINTER (declarator)); - else - { - error ("invalid friend declaration"); - return void_type_node; - } - friendp = 0; - } - decl = NULL_TREE; - } - - if (friendp) - { - /* Friends are treated specially. */ - if (ctype == current_class_type) - warning ("member functions are implicitly friends of their class"); - else if (DECL_NAME (decl)) - return do_friend (ctype, declarator, decl, last_function_parms, flags, quals); - else return void_type_node; - } - - /* Structure field. It may not be a function, except for C++ */ - - if (decl == 0) - { - if (virtualp) - error ("field declared `virtual'"); - if (quals) - error ("`const' and `volatile' function specifiers invalid in field declaration"); - if (friendp) - error ("invalid friend declaration"); - if (raises) - error ("invalid raises declaration"); - - if (staticp || (constp && initialized)) - { - /* C++ allows static class members. - All other work for this is done by grokfield. - This VAR_DECL is built by build_lang_field_decl. - All other VAR_DECLs are built by build_decl. */ - if (current_lang_name == lang_name_c) - { - if (staticp) - error ("field `%s' declared static in %s language context", - name, IDENTIFIER_POINTER (current_lang_name)); - else - error ("field `%s' declared with initializer in %s language context", - name, IDENTIFIER_POINTER (current_lang_name)); - } - decl = build_lang_field_decl (VAR_DECL, declarator, type); - if (staticp) - TREE_STATIC (decl) = 1; - /* In class context, static means public visibility. */ - TREE_PUBLIC (decl) = 1; - } - else - decl = build_lang_field_decl (FIELD_DECL, declarator, type); - } - } - else if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE) - { - int was_overloaded = 0; - tree original_name = declarator; - - if (! declarator) return NULL_TREE; - - if (specbits & ((1 << (int) RID_AUTO) | (1 << (int) RID_REGISTER))) - error ("invalid storage class for function `%s'", name); - /* Function declaration not at top level. - Storage classes other than `extern' are not allowed - and `extern' makes no difference. */ - if (current_binding_level != global_binding_level - && (specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_INLINE))) - && pedantic) - warning ("invalid storage class for function `%s'", name); - - if (ctype == NULL_TREE) - { - if (virtualp) - { - error ("virtual non-class function `%s'", name); - virtualp = 0; - } -#ifdef NO_AUTO_OVERLOAD - if (is_overloaded (declarator)) - { - /* Plain overloading: will not be grok'd by grokclassfn. */ - if (current_lang_name == lang_name_cplusplus) - declarator = build_decl_overload (name, TYPE_ARG_TYPES (type), 0); - was_overloaded = 1; - } -#else - if (current_lang_name == lang_name_cplusplus - && ! (IDENTIFIER_LENGTH (original_name) == 4 - && IDENTIFIER_POINTER (original_name)[0] == 'm' - && strcmp (IDENTIFIER_POINTER (original_name), "main") == 0) - && ! (IDENTIFIER_LENGTH (original_name) > 10 - && IDENTIFIER_POINTER (original_name)[0] == '_' - && IDENTIFIER_POINTER (original_name)[1] == '_' - && strncmp (IDENTIFIER_POINTER (original_name)+2, "builtin_", 8) == 0)) - { - /* Plain overloading: will not be grok'd by grokclassfn. */ - declarator = build_decl_overload (name, TYPE_ARG_TYPES (type), 0); - was_overloaded = 1; - } -#endif - } - else if (TREE_CODE (type) == FUNCTION_TYPE && staticp < 2) - type = build_cplus_method_type (ctype, TREE_TYPE (type), TYPE_ARG_TYPES (type)); - - decl = grokfndecl (ctype, type, declarator, virtualp, flags, quals, raises, friendp ? 2 : 1); - /* Record presence of `static'. In C++, `inline' is like `static'. */ - TREE_PUBLIC (decl) = !(specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_INLINE))); - /* Record presence of `inline', if it is reasonable. */ - if (inlinep) - { - tree last = tree_last (TYPE_ARG_TYPES (type)); - - if (! was_overloaded - && ! ctype - && ! strcmp (IDENTIFIER_POINTER (original_name), "main")) - warning ("cannot inline function `main'"); - else if (last && last != void_list_node) - warning ("inline declaration ignored for function with `...'"); - else - /* Assume that otherwise the function can be inlined. */ - TREE_INLINE (decl) = 1; - - if (specbits & (1 << (int) RID_EXTERN)) - current_extern_inline = 1; - } - if (was_overloaded) - { - DECL_OVERLOADED (decl) = 1; - DECL_ORIGINAL_NAME (decl) = original_name; - } - } - else - { - /* It's a variable. */ - - if (virtualp) - error ("variable declared `virtual'"); - if (inlinep) - warning ("variable declared `inline'"); - if (quals) - error ("`const' and `volatile' function specifiers invalid in field declaration"); - if (friendp) - error ("invalid friend declaration"); - if (raises) - error ("invalid raises declaration"); - - /* An uninitialized decl with `extern' is a reference. */ - decl = grokvardecl (ctype, type, declarator, specbits, initialized); - } - - /* Record `register' declaration for warnings on & - and in case doing stupid register allocation. */ - - if (specbits & (1 << (int) RID_REGISTER)) - TREE_REGDECL (decl) = 1; - - /* Record constancy and volatility. */ - - if (constp) - TREE_READONLY (decl) = TREE_CODE (type) != REFERENCE_TYPE; - if (volatilep) - { - TREE_VOLATILE (decl) = 1; - TREE_THIS_VOLATILE (decl) = 1; - } - - if (resume_temporary) - resume_temporary_allocation (); - - return decl; - } -} - -/* Tell if a parmlist/exprlist looks like an exprlist or a parmlist. - An empty exprlist is a parmlist. An exprlist which - contains only identifiers at the global level - is a parmlist. Otherwise, it is an exprlist. */ -static int -parmlist_is_exprlist (exprs) - tree exprs; -{ - if (exprs == NULL_TREE || TREE_PARMLIST (exprs)) - return 0; - - if (current_binding_level == global_binding_level) - { - /* At the global level, if these are all identifiers, - then it is a parmlist. */ - while (exprs) - { - if (TREE_CODE (TREE_VALUE (exprs)) != IDENTIFIER_NODE) - return 1; - exprs = TREE_CHAIN (exprs); - } - return 0; - } - return 1; -} - -/* Make sure that the this list of PARMS has a chance of being - grokked by `grokparms'. - - @@ This is really weak, but the grammar does not allow us - @@ to easily reject things that this has to catch as syntax errors. */ -static int -parmlist_is_random (parms) - tree parms; -{ - if (parms == NULL_TREE) - return 0; - - if (TREE_CODE (parms) != TREE_LIST) - return 1; - - while (parms) - { - if (parms == void_list_node) - return 0; - - if (TREE_CODE (TREE_VALUE (parms)) != TREE_LIST) - return 1; - /* Don't get faked out by overloaded functions, which - masquerade as TREE_LISTs! */ - if (TREE_TYPE (TREE_VALUE (parms)) == unknown_type_node) - return 1; - parms = TREE_CHAIN (parms); - } - return 0; -} - -/* Subroutine of `grokparms'. In a fcn definition, arg types must - be complete. - - C++: also subroutine of `start_function'. */ -static void -require_complete_types_for_parms (parms) - tree parms; -{ - while (parms) - { - tree type = TREE_TYPE (parms); - if (TYPE_SIZE (type) == 0) - { - if (DECL_NAME (parms)) - error ("parameter `%s' has incomplete type", - IDENTIFIER_POINTER (DECL_NAME (parms))); - else - error ("parameter has incomplete type"); - TREE_TYPE (parms) = error_mark_node; - } -#if 0 - /* If the arg types are incomplete in a declaration, - they must include undefined tags. - These tags can never be defined in the scope of the declaration, - so the types can never be completed, - and no call can be compiled successfully. */ - /* This is not the right behavior for C++, but not having - it is also probably wrong. */ - else - { - /* Now warn if is a pointer to an incomplete type. */ - while (TREE_CODE (type) == POINTER_TYPE - || TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); - type = TYPE_MAIN_VARIANT (type); - if (TYPE_SIZE (type) == 0) - { - if (DECL_NAME (parm) != 0) - warning ("parameter `%s' points to incomplete type", - IDENTIFIER_POINTER (DECL_NAME (parm))); - else - warning ("parameter points to incomplete type"); - } - } -#endif - parms = TREE_CHAIN (parms); - } -} - -/* Decode the list of parameter types for a function type. - Given the list of things declared inside the parens, - return a list of types. - - The list we receive can have three kinds of elements: - an IDENTIFIER_NODE for names given without types, - a TREE_LIST node for arguments given as typespecs or names with typespecs, - or void_type_node, to mark the end of an argument list - when additional arguments are not permitted (... was not used). - - FUNCDEF_FLAG is nonzero for a function definition, 0 for - a mere declaration. A nonempty identifier-list gets an error message - when FUNCDEF_FLAG is zero. - If FUNCDEF_FLAG is 1, then parameter types must be complete. - If FUNCDEF_FLAG is -1, then parameter types may be incomplete. - - If all elements of the input list contain types, - we return a list of the types. - If all elements contain no type (except perhaps a void_type_node - at the end), we return a null list. - If some have types and some do not, it is an error, and we - return a null list. - - Also set last_function_parms to either - a list of names (IDENTIFIER_NODEs) or a chain of PARM_DECLs. - A list of names is converted to a chain of PARM_DECLs - by store_parm_decls so that ultimately it is always a chain of decls. - - Note that in C++, paramters can take default values. These default - values are in the TREE_PURPOSE field of the TREE_LIST. It is - an error to specify default values which are followed by parameters - that have no defualt values, or an ELLIPSES. For simplicities sake, - only parameters which are specified with their types can take on - default values. */ - -static tree -grokparms (first_parm, funcdef_flag) - tree first_parm; - int funcdef_flag; -{ - tree result = NULL_TREE; - tree decls = NULL_TREE; - - if (first_parm != 0 - && TREE_CODE (TREE_VALUE (first_parm)) == IDENTIFIER_NODE) - { - if (! funcdef_flag) - warning ("parameter names (without types) in function declaration"); - last_function_parms = first_parm; - return 0; - } - else - { - /* Types were specified. This is a list of declarators - each represented as a TREE_LIST node. */ - register tree parm, chain; - int any_init = 0, any_error = 0, saw_void = 0; - - if (first_parm != NULL_TREE) - { - tree last_result = NULL_TREE; - tree last_decl = NULL_TREE; - - for (parm = first_parm; parm != NULL_TREE; parm = chain) - { - tree type, list_node = parm; - register tree decl = TREE_VALUE (parm); - tree init = TREE_PURPOSE (parm); - - chain = TREE_CHAIN (parm); - /* @@ weak defense against parse errors. */ - if (decl != void_type_node && TREE_CODE (decl) != TREE_LIST) - { - /* Give various messages as the need arises. */ - if (TREE_CODE (decl) == STRING_CST) - error ("invalid string constant `%s'", - TREE_STRING_POINTER (decl)); - else if (TREE_CODE (decl) == INTEGER_CST) - error ("invalid integer constant in parameter list, did you forget to give parameter name?"); - continue; - } - - if (decl != void_type_node) - { - /* @@ May need to fetch out a `raises' here. */ - decl = grokdeclarator (TREE_VALUE (decl), - TREE_PURPOSE (decl), - PARM, 0, NULL_TREE); - if (! decl) continue; - type = TREE_TYPE (decl); - if (type == void_type_node) - decl = void_type_node; - else if (TREE_CODE (type) == METHOD_TYPE) - { - if (DECL_NAME (decl)) - /* Cannot use `error_with_decl' here because - we don't have DECL_CONTEXT set up yet. */ - error ("parameter `%s' invalidly declared method type", - IDENTIFIER_POINTER (DECL_NAME (decl))); - else - error ("parameter invalidly declared method type"); - type = build_pointer_type (type); - TREE_TYPE (decl) = type; - } - else if (TREE_CODE (type) == OFFSET_TYPE) - { - if (DECL_NAME (decl)) - error ("parameter `%s' invalidly declared offset type", - IDENTIFIER_POINTER (DECL_NAME (decl))); - else - error ("parameter invalidly declared offset type"); - type = build_pointer_type (type); - TREE_TYPE (decl) = type; - } - } - - if (decl == void_type_node) - { - if (result == NULL_TREE) - { - result = void_list_node; - last_result = result; - } - else - { - TREE_CHAIN (last_result) = void_list_node; - last_result = void_list_node; - } - saw_void = 1; - if (chain - && (chain != void_list_node || TREE_CHAIN (chain))) - error ("`void' in parameter list must be entire list"); - break; - } - - /* Since there is a prototype, args are passed in their own types. */ - DECL_ARG_TYPE (decl) = TREE_TYPE (decl); -#ifdef PROMOTE_PROTOTYPES - if (TREE_CODE (type) == INTEGER_TYPE - && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) - DECL_ARG_TYPE (decl) = integer_type_node; -#endif - if (!any_error) - { - if (init) - { - any_init++; - if (TREE_CODE (init) == SAVE_EXPR) - PARM_DECL_EXPR (init) = 1; - else - init = require_instantiated_type (type, init, integer_zero_node); - } - else if (any_init) - { - error ("all trailing parameters must have default arguments"); - any_error = 1; - } - } - else - init = NULL_TREE; - - if (decls == NULL_TREE) - { - decls = decl; - last_decl = decls; - } - else - { - TREE_CHAIN (last_decl) = decl; - last_decl = decl; - } - if (TREE_PERMANENT (list_node)) - { - TREE_PURPOSE (list_node) = init; - TREE_VALUE (list_node) = type; - TREE_CHAIN (list_node) = 0; - } - else - list_node = saveable_tree_cons (init, type, NULL_TREE); - if (result == NULL_TREE) - { - result = list_node; - last_result = result; - } - else - { - TREE_CHAIN (last_result) = list_node; - last_result = list_node; - } - } - if (last_result) - TREE_CHAIN (last_result) = NULL_TREE; - /* If there are no parameters, and the function does not end - with `...', then last_decl will be NULL_TREE. */ - if (last_decl != NULL_TREE) - TREE_CHAIN (last_decl) = NULL_TREE; - } - } - - last_function_parms = decls; - - /* In a fcn definition, arg types must be complete. */ - if (funcdef_flag > 0) - require_complete_types_for_parms (last_function_parms); - - return result; -} - -/* These memoizing functions keep track of special properties which - a class may have. `grok_ctor_properties' notices whether a class - has a constructor of the for X(X&), and also complains - if the class has a constructor of the form X(X). - `grok_op_properties' takes notice of the various forms of - operator= which are defined, as well as what sorts of type conversion - may apply. Both functions take a FUNCTION_DECL as an argument. */ -static void -grok_ctor_properties (ctype, decl) - tree ctype, decl; -{ - tree parmtypes = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl))); - tree parmtype = parmtypes ? TREE_VALUE (parmtypes) : void_type_node; - - if (TREE_CODE (parmtype) == REFERENCE_TYPE - && TYPE_MAIN_VARIANT (TREE_TYPE (parmtype)) == ctype) - { - if (TREE_CHAIN (parmtypes) == NULL_TREE - || TREE_CHAIN (parmtypes) == void_list_node - || TREE_PURPOSE (TREE_CHAIN (parmtypes))) - { - TYPE_HAS_INIT_REF (ctype) = 1; - TYPE_GETS_INIT_REF (ctype) = 1; - if (TREE_READONLY (TREE_TYPE (parmtype))) - TYPE_GETS_CONST_INIT_REF (ctype) = 1; - } - else - TYPE_GETS_INIT_AGGR (ctype) = 1; - } - else if (TYPE_MAIN_VARIANT (parmtype) == ctype) - { - if (TREE_CHAIN (parmtypes) != NULL_TREE - && TREE_CHAIN (parmtypes) == void_list_node) - error ("invalid constructor; you probably meant `%s (%s&)'", - IDENTIFIER_POINTER (current_class_name), - IDENTIFIER_POINTER (current_class_name)); - SET_IDENTIFIER_ERROR_LOCUS (DECL_NAME (decl), ctype); - TYPE_GETS_INIT_AGGR (ctype) = 1; - } - else if (TREE_CODE (parmtype) == VOID_TYPE - || TREE_PURPOSE (parmtypes) != NULL_TREE) - TYPE_HAS_DEFAULT_CONSTRUCTOR (ctype) = 1; -} - -static void -grok_op_properties (decl) - tree decl; -{ - char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); - tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl)); - - if (DECL_STATIC_FUNCTION_P (decl)) - { - if (! strncmp (name, OPERATOR_NEW_FORMAT, OPERATOR_NEW_LENGTH)) - { - /* Take care of function decl if we had syntax errors. */ - if (argtypes == NULL_TREE) - TREE_TYPE (decl) = build_function_type (ptr_type_node, - hash_tree_chain (integer_type_node, void_list_node)); - } - else if (! strncmp (name, OPERATOR_DELETE_FORMAT, OPERATOR_DELETE_LENGTH)) - { - if (argtypes == NULL_TREE) - TREE_TYPE (decl) = build_function_type (void_type_node, - hash_tree_chain (ptr_type_node, void_list_node)); - } - else - error_with_decl (decl, "`%s' cannot be a static member function"); - } - else if (! strncmp (name, OPERATOR_MODIFY_FORMAT, OPERATOR_MODIFY_LENGTH)) - { - tree parmtypes = TREE_CHAIN (argtypes); - tree parmtype = parmtypes ? TREE_VALUE (parmtypes) : void_type_node; - - if (TREE_CODE (parmtype) == REFERENCE_TYPE - && TREE_TYPE (parmtype) == current_class_type) - { - TYPE_HAS_ASSIGN_REF (current_class_type) = 1; - TYPE_GETS_ASSIGN_REF (current_class_type) = 1; - if (TREE_READONLY (TREE_TYPE (parmtype))) - TYPE_GETS_CONST_INIT_REF (current_class_type) = 1; - } - } -} - -/* Get the struct, enum or union (CODE says which) with tag NAME. - Define the tag as a forward-reference if it is not defined. - - C++: If a class derivation is given, process it here, and report - an error if multiple derivation declarations are not identical. - - If we are compiling for SOS, then - if CODE_TYPE_NODE is a TREE_LIST, then we have a dynamic class - declaration. The name associated with the class is the tree - purpose, and the real CODE is in the tree value slot. */ -tree -xref_tag (code_type_node, name, binfo) - tree code_type_node; - tree name, binfo; -{ - enum tag_types tag_code; - enum tree_code code; - int temp = 0; - int i, len; - register tree ref; - struct binding_level *b - = (class_binding_level ? class_binding_level : current_binding_level); -#ifdef SOS - tree dynamic_name = error_mark_node; - if (TREE_CODE (code_type_node) == TREE_LIST) - { - dynamic_name = TREE_PURPOSE (code_type_node); - code_type_node = TREE_VALUE (code_type_node); - } -#endif - - tag_code = (enum tag_types) TREE_INT_CST_LOW (code_type_node); - switch (tag_code) - { - case record_type: - case class_type: - case exception_type: - code = RECORD_TYPE; - len = list_length (binfo) + 1; - break; - case union_type: - code = UNION_TYPE; - if (binfo) - { - error ("derived union `%s' invalid", IDENTIFIER_POINTER (name)); - binfo = NULL_TREE; - } - len = 1; - break; - case enum_type: - code = ENUMERAL_TYPE; - break; - default: - abort (); - } - - /* If a cross reference is requested, look up the type - already defined for this tag and return it. */ - ref = lookup_tag (code, name, b, 0); - - if (! ref) - { - /* Try finding it as a type declaration. If that wins, use it. */ - ref = lookup_name (name); - if (ref && TREE_CODE (ref) == TYPE_DECL - && TREE_CODE (TREE_TYPE (ref)) == code) - ref = TREE_TYPE (ref); - else - ref = NULL_TREE; - } - - if (! ref) - { - /* If no such tag is yet defined, create a forward-reference node - and record it as the "definition". - When a real declaration of this type is found, - the forward-reference will be altered into a real type. */ - - /* In C++, since these migrate into the global scope, we must - build them on the permanent obstack. */ - if (temp == 0) - temp = allocation_temporary_p (); - if (temp) - end_temporary_allocation (); - - if (code == ENUMERAL_TYPE) - { - ref = make_node (ENUMERAL_TYPE); - - /* Give the type a default layout like unsigned int - to avoid crashing if it does not get defined. */ - TYPE_MODE (ref) = SImode; - TYPE_ALIGN (ref) = TYPE_ALIGN (unsigned_type_node); - TREE_UNSIGNED (ref) = 1; - TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node); - TYPE_MIN_VALUE (ref) = TYPE_MIN_VALUE (unsigned_type_node); - TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node); - - /* Enable us to recognize when a type is created in class context. - To do nested classes correctly, this should probably be cleared - out when we leave this classes scope. Currently this in only - done in `start_enum'. */ - - pushtag (name, ref); - if (flag_cadillac) - cadillac_start_enum (ref); - } - else if (tag_code == exception_type) - { - ref = make_lang_type (code); - CLASSTYPE_OFFSET (ref) = integer_zero_node; - /* Enable us to recognize when an exception type is created in - class context. To do nested classes correctly, this should - probably be cleared out when we leave this class's scope. */ - CLASSTYPE_DECLARED_EXCEPTION (ref) = 1; - pushtag (name, ref); - if (flag_cadillac) - cadillac_start_struct (ref); - } - else - { - extern tree pending_vtables; - struct binding_level *old_b = class_binding_level; - int needs_writing; - - ref = make_lang_type (code); - - CLASSTYPE_BASECLASSES (ref) = (tree *) malloc (len * sizeof (tree)); - CLASSTYPE_N_BASECLASSES (ref) = len - 1; - CLASSTYPE_OFFSET (ref) = integer_zero_node; - CLASSTYPE_VIAS (ref) = (unsigned char *) malloc (len); - - /* Record how to set the visibility of this class's - virtual functions. If write_virtuals == 2 or 3, then - inline virtuals are ``extern inline''. */ - switch (write_virtuals) - { - case 0: - case 1: - needs_writing = 1; - break; - case 2: - needs_writing = !! value_member (name, pending_vtables); - break; - case 3: - needs_writing - = ! (CLASSTYPE_INTERFACE_ONLY (ref) || CLASSTYPE_INTERFACE_UNKNOWN (ref)); - break; - default: - needs_writing = 0; - } - - CLASSTYPE_VTABLE_NEEDS_WRITING (ref) = needs_writing; - - /* Class types don't nest the way enums do. */ - class_binding_level = 0; - pushtag (name, ref); - class_binding_level = old_b; - - if (flag_cadillac) - cadillac_start_struct (ref); - } - } - else - { - if (IS_AGGR_TYPE_CODE (code)) - { -#if 0 - if (TREE_CODE (TYPE_NAME (ref)) == IDENTIFIER_NODE -#ifndef BREAK_C_TAGS - && current_lang_name == lang_name_cplusplus -#endif - && ! CLASSTYPE_DECLARED_EXCEPTION (ref)) - { - /* Silently typedef a tag which came from C. */ - register tree t = pushdecl (build_decl (TYPE_DECL, name, ref)); - TYPE_NAME (ref) = t; - TREE_TYPE (name) = t; - } -#endif - if (IS_AGGR_TYPE (ref) - && ((tag_code == exception_type) - != (CLASSTYPE_DECLARED_EXCEPTION (ref) == 1))) - { - error ("type `%s' is both exception and aggregate type", - IDENTIFIER_POINTER (name)); - CLASSTYPE_DECLARED_EXCEPTION (ref) = (tag_code == exception_type); - } - } - if (binfo) - { - tree tt1 = binfo; - tree *tt2 = CLASSTYPE_BASECLASSES (ref); - - if (CLASSTYPE_N_BASECLASSES (ref)) - for (i = 1; tt1; i++, tt1 = TREE_CHAIN (tt1)) - if (TREE_VALUE (tt1) != DECL_NAME (TYPE_NAME (tt2[i]))) - { - error ("redeclaration of derivation chain of type `%s'", - IDENTIFIER_POINTER (name)); - break; - } - - if (tt1 != NULL_TREE) - { - free (CLASSTYPE_BASECLASSES (ref)); - free (CLASSTYPE_VIAS (ref)); - CLASSTYPE_BASECLASSES (ref) = (tree *) malloc (len * sizeof (tree)); - CLASSTYPE_N_BASECLASSES (ref) = len - 1; - CLASSTYPE_OFFSET (ref) = integer_zero_node; - CLASSTYPE_ASSOC (ref) = NULL_TREE; - CLASSTYPE_VIAS (ref) = (unsigned char *) malloc (len); - } - else - { - /* The user told us something we already knew. */ - goto just_return; - } - } -#ifdef SOS - else if (TREE_CODE (ref) != ENUMERAL_TYPE - && (dynamic_name != error_mark_node) != TYPE_DYNAMIC (ref)) - error ("type `%s' declared both dynamic and non-dynamic", - IDENTIFIER_POINTER (name)); -#endif - } - - if (binfo) - { - CLASSTYPE_MARKED (ref) = 1; - for (i = 1; binfo; binfo = TREE_CHAIN (binfo)) - { - /* The base of a derived struct is public. */ - int via_public = (tag_code != class_type - || TREE_PURPOSE (binfo) == (tree)visibility_public - || TREE_PURPOSE (binfo) == (tree)visibility_public_virtual); - int via_virtual = (TREE_PURPOSE (binfo) == (tree)visibility_private_virtual - || TREE_PURPOSE (binfo) == (tree)visibility_public_virtual - || TREE_PURPOSE (binfo) == (tree)visibility_default_virtual); - tree basetype = TREE_TYPE (TREE_VALUE (binfo)); - -#ifdef FIELD_XREF - FIELD_xref_hier(IDENTIFIER_POINTER(name), - IDENTIFIER_POINTER(TREE_VALUE(binfo)), - via_public,via_virtual,0); -#endif - - if (basetype && TREE_CODE (basetype) == TYPE_DECL) - basetype = TREE_TYPE (basetype); - if (!basetype || TREE_CODE (basetype) != RECORD_TYPE) - { - error ("base type `%s' fails to be a struct or class type", - IDENTIFIER_POINTER (TREE_VALUE (binfo))); - continue; - } -#if 0 - else if (TYPE_SIZE (basetype) == 0) - { - error_with_aggr_type (basetype, "base class `%s' has incomplete type"); - continue; - } -#endif - else - { -#ifdef SOS - if (dynamic_name == error_mark_node && TYPE_DYNAMIC (basetype)) - error_with_aggr_type (ref, "non-dynamic type `%s' cannot derive from dynamic type `%s'", TYPE_NAME_STRING (basetype)); -#endif - if (CLASSTYPE_MARKED (basetype)) - { - if (basetype == ref) - error_with_aggr_type (basetype, "recursive type `%s' undefined"); - else - error_with_aggr_type (basetype, "duplicate base type `%s' invalid"); - continue; - } - CLASSTYPE_BASECLASS (ref, i) = basetype; - CLASSTYPE_MARKED (basetype) = 1; -#if 0 -/* XYZZY TEST VIRTUAL BASECLASSES */ -if (CLASSTYPE_N_BASECLASSES (basetype) == 0 - && TYPE_HAS_DEFAULT_CONSTRUCTOR (basetype) - && via_virtual == 0) - { - warning ("making type `%s' a virtual baseclass", - TYPE_NAME_STRING (basetype)); - via_virtual = 1; - } -#endif - SET_CLASSTYPE_VIAS (ref, i, via_public, via_virtual); - if (via_virtual || TYPE_USES_VIRTUAL_BASECLASSES (basetype)) - TYPE_USES_VIRTUAL_BASECLASSES (ref) = 1; - - TYPE_GETS_ASSIGNMENT (ref) |= TYPE_GETS_ASSIGNMENT (basetype); - TYPE_OVERLOADS_METHOD_CALL_EXPR (ref) |= TYPE_OVERLOADS_METHOD_CALL_EXPR (basetype); - TYPE_HAS_WRAPPER_PRED (ref) |= TYPE_HAS_WRAPPER_PRED (basetype); - TREE_GETS_NEW (ref) |= TREE_GETS_NEW (basetype); - TREE_GETS_DELETE (ref) |= TREE_GETS_DELETE (basetype); - CLASSTYPE_LOCAL_TYPEDECLS (ref) |= CLASSTYPE_LOCAL_TYPEDECLS (basetype); - i += 1; - } - } - /* Set the true number of baseclasses this type really has. */ - CLASSTYPE_N_BASECLASSES (ref) = --i; - - if (i > 1) - TYPE_USES_MULTIPLE_INHERITANCE (ref) = 1; - else if (i == 1) - TYPE_USES_MULTIPLE_INHERITANCE (ref) - = TYPE_USES_MULTIPLE_INHERITANCE (CLASSTYPE_BASECLASS (ref, 1)); - - while (i > 0) - { - CLASSTYPE_MARKED (CLASSTYPE_BASECLASS (ref, i)) = 0; - i -= 1; - } - CLASSTYPE_MARKED (ref) = 0; - } - - just_return: - -#ifdef SOS - if (dynamic_name != error_mark_node) - { - if (temp == 0) - temp = allocation_temporary_p (); - if (temp) - end_temporary_allocation (); - - if (dynamic_name) - CLASSTYPE_DYNAMIC_FILENAME (ref) = combine_strings (dynamic_name); - else - CLASSTYPE_DYNAMIC_FILENAME (ref) = NULL_TREE; - TYPE_DYNAMIC (ref) = 1; - CLASSTYPE_TYPENAME_AS_STRING (ref) = combine_strings (build_string (IDENTIFIER_LENGTH (name), IDENTIFIER_POINTER (name))); - - } -#endif - - /* Until the type is defined, tentatively accept whatever - structure tag the user hands us. */ - if (TYPE_SIZE (ref) == NULL_TREE - && ref != current_class_type - && IS_AGGR_TYPE (ref)) - { - if (tag_code == class_type) - CLASSTYPE_DECLARED_CLASS (ref) = 1; - else if (tag_code == record_type) - CLASSTYPE_DECLARED_CLASS (ref) = 0; - } - - if (temp) - resume_temporary_allocation (); - - return ref; -} - -/* Begin compiling the definition of an enumeration type. - NAME is its name (or null if anonymous). - Returns the type object, as yet incomplete. - Also records info about it so that build_enumerator - may be used to declare the individual values as they are read. */ - -tree -start_enum (name) - tree name; -{ - register tree enumtype = 0; - struct binding_level *b - = (class_binding_level ? class_binding_level : current_binding_level); - - /* If this is the real definition for a previous forward reference, - fill in the contents in the same object that used to be the - forward reference. */ - - if (name != 0) - enumtype = lookup_tag (ENUMERAL_TYPE, name, b, 1); - - if (enumtype == 0 || TREE_CODE (enumtype) != ENUMERAL_TYPE) - { - enumtype = make_node (ENUMERAL_TYPE); - pushtag (name, enumtype); - } - - if (TYPE_VALUES (enumtype) != 0) - { - /* This enum is a named one that has been declared already. */ - error ("redeclaration of `enum %s'", IDENTIFIER_POINTER (name)); - - /* Completely replace its old definition. - The old enumerators remain defined, however. */ - TYPE_VALUES (enumtype) = 0; - } - - /* Initially, set up this enum as like `int' - so that we can create the enumerators' declarations and values. - Later on, the precision of the type may be changed and - it may be laid out again. */ - - TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node); - TYPE_SIZE (enumtype) = 0; - fixup_unsigned_type (enumtype); - - /* We copy this value because enumerated type constants - are really of the type of the enumerator, not integer_type_node. */ - enum_next_value = copy_node (integer_zero_node); - -#ifdef FIELD_XREF - FIELD_xref_decl(current_function_decl,enumtype); -#endif - - return enumtype; -} - -/* After processing and defining all the values of an enumeration type, - install their decls in the enumeration type and finish it off. - ENUMTYPE is the type object and VALUES a list of name-value pairs. - Returns ENUMTYPE. */ - -tree -finish_enum (enumtype, values) - register tree enumtype, values; -{ - register tree pair; - register long maxvalue = 0; - register long minvalue = 0; - register int i; - - TYPE_VALUES (enumtype) = values; - - /* Calculate the maximum value of any enumerator in this type. */ - - if (values) - { - /* Speed up the main loop by performing some precalculations */ - - int value = TREE_INT_CST_LOW (TREE_VALUE (values)); - TREE_TYPE (TREE_VALUE (values)) = enumtype; - minvalue = maxvalue = value; - - for (pair = TREE_CHAIN (values); pair; pair = TREE_CHAIN (pair)) - { - value = TREE_INT_CST_LOW (TREE_VALUE (pair)); - if (value > maxvalue) - maxvalue = value; - else if (value < minvalue) - minvalue = value; - TREE_TYPE (TREE_VALUE (pair)) = enumtype; - } - } - - if (flag_short_enums) - { - /* Determine the precision this type needs, lay it out, and define it. */ - - for (i = maxvalue; i; i >>= 1) - TYPE_PRECISION (enumtype)++; - - if (!TYPE_PRECISION (enumtype)) - TYPE_PRECISION (enumtype) = 1; - - /* Cancel the laying out previously done for the enum type, - so that fixup_unsigned_type will do it over. */ - TYPE_SIZE (enumtype) = 0; - - fixup_unsigned_type (enumtype); - } - - TREE_INT_CST_LOW (TYPE_MAX_VALUE (enumtype)) = maxvalue; - - /* An enum can have some negative values; then it is signed. */ - if (minvalue < 0) - { - TREE_INT_CST_LOW (TYPE_MIN_VALUE (enumtype)) = minvalue; - TREE_INT_CST_HIGH (TYPE_MIN_VALUE (enumtype)) = -1; - TREE_UNSIGNED (enumtype) = 0; - } - if (flag_cadillac) - cadillac_finish_enum (enumtype); - - return enumtype; -} - -/* Build and install a CONST_DECL for one value of the - current enumeration type (one that was begun with start_enum). - Return a tree-list containing the name and its value. - Assignment of sequential values by default is handled here. */ - -tree -build_enumerator (name, value) - tree name, value; -{ - tree decl, result; - - /* Validate and default VALUE. */ - if (value != 0) - { - if (TREE_READONLY_DECL_P (value)) - value = decl_constant_value (value); - - if (TREE_CODE (value) != INTEGER_CST) - { - error ("enumerator value for `%s' not integer constant", - IDENTIFIER_POINTER (name)); - value = 0; - } - } - /* The order of things is reversed here so that we - can check for possible sharing of enum values, - to keep that from happening. */ - /* Default based on previous value. */ - if (value == 0) - value = enum_next_value; - - /* Remove no-op casts from the value. */ - while (value != 0 && TREE_CODE (value) == NOP_EXPR) - value = TREE_OPERAND (value, 0); - - /* Make up for hacks in cplus-lex.c. */ - if (value == integer_zero_node) - value = build_int_2 (0, 0); - else if (value == integer_one_node) - value = build_int_2 (1, 0); - else if (TREE_CODE (value) == INTEGER_CST - && TREE_CODE (TREE_TYPE (value)) == ENUMERAL_TYPE) - { - value = copy_node (value); - TREE_TYPE (value) = integer_type_node; - } - - result = saveable_tree_cons (name, value, NULL_TREE); - - /* C++ associates enums with global, function, or class declarations. */ - if (current_class_type == NULL_TREE || current_function_decl != NULL_TREE) - { - /* Create a declaration for the enum value name. */ - - decl = build_decl (CONST_DECL, name, integer_type_node); - DECL_INITIAL (decl) = value; - - pushdecl (decl); - } - - /* Set basis for default for next value. */ - enum_next_value = build_binary_op_nodefault (PLUS_EXPR, value, - integer_one_node, PLUS_EXPR); - if (TREE_UID (enum_next_value) < TREE_UID (result)) - enum_next_value = copy_node (enum_next_value); - - return result; -} - -tree -grok_enum_decls (type, decl) - tree type, decl; -{ - struct binding_level *b = class_binding_level; - tree tag = NULL_TREE; - tree values; - - while (b) - { - tag = value_member (type, b->tags); - if (tag) - break; - b = b->level_chain; - } - - if (b == 0) - { - tree name = TYPE_NAME (type); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - error ("class-local enum declaration `%s' is not in scope here", - IDENTIFIER_POINTER (name)); - } - else if (b != class_binding_level) - { - warning ("class-local declaration for enumeral type `%s' found", - IDENTIFIER_POINTER (TREE_PURPOSE (tag))); - warning ("(probably missing '}' before that enum declaration)"); - return decl; - } - else if (TREE_ADDRESSABLE (tag)) - return decl; - else - TREE_ADDRESSABLE (tag) = 1; - - values = TYPE_VALUES (type); - while (values) - { - /* Create a declaration for the enum value name. */ - tree next = build_lang_field_decl (CONST_DECL, TREE_PURPOSE (values), type); - DECL_INITIAL (next) = TREE_VALUE (values); - TREE_CHAIN (next) = decl; - decl = next; - pushdecl_class_level (decl); - values = TREE_CHAIN (values); - } - return decl; -} - -/* Create the FUNCTION_DECL for a function definition. - DECLSPECS and DECLARATOR are the parts of the declaration; - they describe the function's name and the type it returns, - but twisted together in a fashion that parallels the syntax of C. - - This function creates a binding context for the function body - as well as setting up the FUNCTION_DECL in current_function_decl. - - Returns 1 on success. If the DECLARATOR is not suitable for a function - (it defines a datum instead), we return 0, which tells - yyparse to report a parse error. - - For C++, we must first check whether that datum makes any sense. - For example, "class A local_a(1,2);" means that variable local - a is an aggregate of type A, which should have a constructor - applied to it with the argument list [1, 2]. - - @@ There is currently no way to retrieve the storage - @@ allocated to FUNCTION (or all of its parms) if we return - @@ something we had previously. */ - -int -start_function (declspecs, declarator, raises, pre_parsed_p) - tree declarator, declspecs, raises; - int pre_parsed_p; -{ - extern int interface_only, interface_unknown; - extern tree EHS_decl; - tree decl1, olddecl; - tree ctype = NULL_TREE; - tree fntype; - tree restype; - - if (flag_handle_exceptions && EHS_decl == NULL_TREE) - init_exception_processing_1 (); - - /* Sanity check. */ - assert (TREE_VALUE (void_list_node) == void_type_node); - assert (TREE_CHAIN (void_list_node) == NULL_TREE); - - /* Assume, until we see it does. */ - current_function_returns_value = 0; - current_function_returns_null = 0; - warn_about_return_type = 0; - current_extern_inline = 0; - current_function_assigns_this = 0; - current_function_just_assigned_this = 0; - current_function_parms_stored = 0; - original_result_rtx = 0; - - clear_temp_name (); - - if (pre_parsed_p) - { - decl1 = declarator; - last_function_parms = DECL_ARGUMENTS (decl1); - last_function_parm_tags = 0; - fntype = TREE_TYPE (decl1); - if (TREE_CODE (fntype) == METHOD_TYPE) - ctype = TYPE_METHOD_BASETYPE (fntype); - - if ( !(DECL_VIRTUAL_P (decl1) - && write_virtuals >= 2 - && CLASSTYPE_VTABLE_NEEDS_WRITING (ctype))) - current_extern_inline = TREE_PUBLIC (decl1); - - raises = TYPE_RAISES_EXCEPTIONS (fntype); - - /* In a fcn definition, arg types must be complete. */ - require_complete_types_for_parms (last_function_parms); - } - else - { - decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, raises); - /* If the declarator is not suitable for a function definition, - cause a syntax error. */ - if (decl1 == 0 || TREE_CODE (decl1) != FUNCTION_DECL) return 0; - - fntype = TREE_TYPE (decl1); - - restype = TREE_TYPE (fntype); - if (IS_AGGR_TYPE (restype) - && ! CLASSTYPE_GOT_SEMICOLON (restype)) - { - error_with_aggr_type (restype, "semicolon missing after declaration of `%s'"); - shadow_tag (build_tree_list (NULL_TREE, restype)); - CLASSTYPE_GOT_SEMICOLON (restype) = 1; - if (TREE_CODE (fntype) == FUNCTION_TYPE) - fntype = build_function_type (integer_type_node, - TYPE_ARG_TYPES (fntype)); - else - fntype = build_cplus_method_type (TYPE_METHOD_BASETYPE (fntype), - integer_type_node, - TYPE_ARG_TYPES (fntype)); - TREE_TYPE (decl1) = fntype; - } - - if (TREE_CODE (fntype) == METHOD_TYPE) - ctype = TYPE_METHOD_BASETYPE (fntype); - else if (IDENTIFIER_LENGTH (DECL_NAME (decl1)) == 4 - && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (decl1)), "main")) - { - /* If this doesn't return an integer type, complain. */ - if (TREE_CODE (TREE_TYPE (fntype)) != INTEGER_TYPE) - { -#if 0 - error ("return type for `main' must be integer type"); -#else - warning ("return type for `main' changed to integer type"); -#endif - TREE_TYPE (decl1) = fntype = default_function_type; - } - warn_about_return_type = 0; - } - } - - /* Warn if function was previously implicitly declared - (but not if we warned then). */ - if (! warn_implicit && IDENTIFIER_IMPLICIT_DECL (DECL_NAME (decl1)) != 0) - warning_with_decl (IDENTIFIER_IMPLICIT_DECL (DECL_NAME (decl1)), - "`%s' implicitly declared before its definition"); - - current_function_decl = decl1; - - if (flag_cadillac) - cadillac_start_function (decl1); - else - announce_function (decl1); - - if (TYPE_SIZE (TREE_TYPE (fntype)) == 0) - { - if (IS_AGGR_TYPE (TREE_TYPE (fntype))) - error_with_aggr_type (TREE_TYPE (fntype), - "return-type `%s' is an incomplete type"); - else - error ("return-type is an incomplete type"); - - /* Make it return void instead. */ - if (ctype) - TREE_TYPE (decl1) - = build_cplus_method_type (ctype, - void_type_node, - TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl1)))); - else - TREE_TYPE (decl1) - = build_function_type (void_type_node, - TYPE_ARG_TYPES (TREE_TYPE (decl1))); - } - - if (warn_about_return_type) - warning ("return-type defaults to `int'"); - - /* Make the init_value nonzero so pushdecl knows this is not tentative. - error_mark_node is replaced below (in poplevel) with the LET_STMT. */ - DECL_INITIAL (decl1) = error_mark_node; - -#ifdef NO_AUTO_OVERLOAD - /* If this definition isn't a prototype and we had a prototype declaration - before, copy the arg type info from that prototype. */ - olddecl = lookup_name_current_level (DECL_NAME (decl1)); - if (olddecl != 0 - && TREE_CODE (olddecl) != TREE_LIST - && TREE_TYPE (TREE_TYPE (decl1)) == TREE_TYPE (TREE_TYPE (olddecl)) - && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0) - { - fntype = TREE_TYPE (olddecl); - TREE_TYPE (decl1) = fntype; - } -#endif - - /* Didn't get anything from C. */ - olddecl = 0; - - /* This is a definition, not a reference. - So normally clear TREE_EXTERNAL. - However, `extern inline' acts like a declaration - except for defining how to inline. So set TREE_EXTERNAL in that case. */ - TREE_EXTERNAL (decl1) = current_extern_inline; - - /* This function exists in static storage. - (This does not mean `static' in the C sense!) */ - TREE_STATIC (decl1) = 1; - - /* If this inline function belongs to the implementation, make it public. */ - if (TREE_INLINE (decl1) && interface_unknown == 0) - { - TREE_PUBLIC (decl1) = ! interface_only; - TREE_EXTERNAL (decl1) = interface_only; - } - - /* Now see if this is the implementation of a function - declared with "C" linkage. */ - if (ctype == NULL_TREE && current_lang_name == lang_name_cplusplus) - { - olddecl = lookup_name_current_level (DECL_ORIGINAL_NAME (decl1)); - if (olddecl && TREE_CODE (olddecl) != FUNCTION_DECL) - olddecl = NULL_TREE; - if (olddecl - && DECL_ORIGINAL_NAME (decl1) != DECL_ORIGINAL_NAME (olddecl)) - { - /* Collision between user and internal naming scheme. */ - olddecl = lookup_name_current_level (DECL_NAME (decl1)); - if (olddecl == NULL_TREE) - olddecl = decl1; - } - if (olddecl && olddecl != decl1 - && DECL_ORIGINAL_NAME (decl1) == DECL_ORIGINAL_NAME (olddecl)) - { - if (TREE_CODE (olddecl) == FUNCTION_DECL - && (decls_match (decl1, olddecl) - || comp_target_parms (TYPE_ARG_TYPES (TREE_TYPE (decl1)), - TYPE_ARG_TYPES (TREE_TYPE (olddecl)), 1))) - { - olddecl = DECL_MAIN_VARIANT (olddecl); - DECL_NAME (decl1) = DECL_NAME (olddecl); - DECL_PRINT_NAME (decl1) = DECL_PRINT_NAME (olddecl); - DECL_OVERLOADED (decl1) = DECL_OVERLOADED (olddecl); - if (DECL_INITIAL (olddecl)) - redeclaration_error_message (decl1, olddecl); - if (! duplicate_decls (decl1, olddecl)) - abort (); - decl1 = olddecl; - } - else - olddecl = NULL_TREE; - } - } - - /* Record the decl so that the function name is defined. - If we already have a decl for this name, and it is a FUNCTION_DECL, - use the old decl. */ - - if (olddecl) - current_function_decl = olddecl; - else if (pre_parsed_p == 0) - { - current_function_decl = pushdecl (decl1); - if (TREE_CODE (current_function_decl) == TREE_LIST) - { - /* @@ revert to modified original declaration. */ - decl1 = DECL_MAIN_VARIANT (decl1); - current_function_decl = decl1; - } - else - { - decl1 = current_function_decl; - DECL_MAIN_VARIANT (decl1) = decl1; - } - fntype = TREE_TYPE (decl1); - } - else - current_function_decl = decl1; - - if (DECL_OVERLOADED (decl1)) - push_overloaded_decl (decl1); - - if (ctype != 0 && DECL_STATIC_FUNCTION_P (decl1)) - { - if (TREE_CODE (fntype) == METHOD_TYPE) - TREE_TYPE (decl1) = fntype - = build_function_type (TREE_TYPE (fntype), - TREE_CHAIN (TYPE_ARG_TYPES (fntype))); - last_function_parms = TREE_CHAIN (last_function_parms); - DECL_ARGUMENTS (decl1) = last_function_parms; - ctype = 0; - } - restype = TREE_TYPE (fntype); - - pushlevel (0); - current_binding_level->parm_flag = 1; - - /* Save the parm names or decls from this function's declarator - where store_parm_decls will find them. */ - current_function_parms = last_function_parms; - current_function_parm_tags = last_function_parm_tags; - -#ifdef FIELD_XREF - FIELD_xref_function(decl1,current_function_parms); -#endif - - make_function_rtl (decl1); - - if (ctype) - { - pushclass (ctype, 1); - /* We know that this was set up by `grokclassfn'. - We do not wait until `store_parm_decls', since evil - parse errors may never get us to that point. Here - we keep the consistency between `current_class_type' - and `current_class_decl'. */ - current_class_decl = last_function_parms; - assert (TREE_CODE (current_class_decl) == PARM_DECL); - if (TREE_CODE (TREE_TYPE (current_class_decl)) == POINTER_TYPE) - { - tree variant = TREE_TYPE (TREE_TYPE (current_class_decl)); - if (CLASSTYPE_INST_VAR (ctype) == NULL_TREE) - { - /* Can't call build_indirect_ref here, because it has special - logic to return C_C_D given this argument. */ - C_C_D = build1 (INDIRECT_REF, current_class_type, current_class_decl); - CLASSTYPE_INST_VAR (ctype) = C_C_D; - } - else - { - C_C_D = CLASSTYPE_INST_VAR (ctype); - /* `current_class_decl' is different for every - function we compile. */ - TREE_OPERAND (C_C_D, 0) = current_class_decl; - } - TREE_READONLY (C_C_D) = TREE_READONLY (variant); - TREE_VOLATILE (C_C_D) = TREE_VOLATILE (variant); - } - else - C_C_D = current_class_decl; - } - else - { - if (DECL_STATIC_FUNCTION_P (decl1)) - pushclass (DECL_STATIC_CONTEXT (decl1), 2); - else - push_memoized_context (0, 1); - } - - /* Promote the value to int before returning it. */ - if (TREE_CODE (restype) == INTEGER_TYPE - && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node)) - restype = integer_type_node; - DECL_RESULT_TYPE (decl1) = restype; - DECL_RESULT (decl1) = build_decl (RESULT_DECL, value_identifier, restype); - - if (DESTRUCTOR_NAME_P (DECL_NAME (decl1))) - { - dtor_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); - ctor_label = NULL_TREE; - } - else - { - dtor_label = NULL_TREE; - if (DECL_CONSTRUCTOR_P (decl1)) - { - ctor_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); - - /* Initializations from `emit_base_init' might go inline. - Protect the binding level of the parms. */ - pushlevel (0); - } - } - - /* Allocate further tree nodes temporarily during compilation - of this function only. */ - temporary_allocation (); - - /* If this fcn was already referenced via a block-scope `extern' decl - (or an implicit decl), propagate certain information about the usage. */ - if (TREE_ADDRESSABLE (DECL_NAME (decl1))) - TREE_ADDRESSABLE (decl1) = 1; - - return 1; -} - -/* Store the parameter declarations into the current function declaration. - This is called after parsing the parameter declarations, before - digesting the body of the function. - - Also install to binding contour return value identifier, if any. */ - -void -store_parm_decls () -{ - register tree fndecl = current_function_decl; - register tree parm; - int parms_have_cleanups = 0; - tree eh_decl; - - /* This is either a chain of PARM_DECLs (when a prototype is used). */ - tree specparms = current_function_parms; - - /* This is a list of types declared among parms in a prototype. */ - tree parmtags = current_function_parm_tags; - - /* This is a chain of any other decls that came in among the parm - declarations. If a parm is declared with enum {foo, bar} x; - then CONST_DECLs for foo and bar are put here. */ - tree nonparms = 0; - - if (current_binding_level == global_binding_level) - fatal ("parse errors have confused me too much"); - - /* Initialize RTL machinery. */ - init_function_start (fndecl); - - /* Create a binding level for the parms. */ - expand_start_bindings (0); - - /* Prepare to catch raises, if appropriate. */ - if (flag_handle_exceptions) - { - /* Get this cleanup to be run last, since it - is a call to `longjmp'. */ - setup_exception_throw_decl (); - eh_decl = current_binding_level->names; - current_binding_level->names = TREE_CHAIN (current_binding_level->names); - } - if (flag_handle_exceptions) - expand_start_try (integer_one_node, 0, 1); - - if (specparms != 0) - { - /* This case is when the function was defined with an ANSI prototype. - The parms already have decls, so we need not do anything here - except record them as in effect - and complain if any redundant old-style parm decls were written. */ - - register tree next; - - for (parm = nreverse (specparms); parm; parm = next) - { - tree cleanup = maybe_build_cleanup (parm); - next = TREE_CHAIN (parm); - if (DECL_NAME (parm) == 0) - { -#if 0 - error_with_decl (parm, "parameter name omitted"); -#else - /* for C++, this is not an error. */ - pushdecl (parm); -#endif - } - else if (TREE_TYPE (parm) == void_type_node) - error_with_decl (parm, "parameter `%s' declared void"); - else - { - /* Now fill in DECL_REFERENCE_SLOT for any of the parm decls. - A parameter is assumed not to have any side effects. - If this should change for any reason, then this - will have to wrap the bashed reference type in a save_expr. - - Also, if the parameter type is declared to be an X - and there is an X(X&) constructor, we cannot lay it - into the stack (any more), so we make this parameter - look like it is really of reference type. Functions - which pass parameters to this function will know to - create a temporary in their frame, and pass a reference - to that. */ - - if (TREE_CODE (TREE_TYPE (parm)) == REFERENCE_TYPE - && TYPE_SIZE (TREE_TYPE (TREE_TYPE (parm)))) - SET_DECL_REFERENCE_SLOT (parm, convert_from_reference (parm)); - - pushdecl (parm); - } - - if (cleanup) - { - expand_decl (parm); - expand_decl_cleanup (parm, cleanup); - parms_have_cleanups = 1; - } - } - - /* Get the decls in their original chain order - and record in the function. */ - DECL_ARGUMENTS (fndecl) = getdecls (); - - storetags (chainon (parmtags, gettags ())); - } - else - DECL_ARGUMENTS (fndecl) = 0; - - /* Now store the final chain of decls for the arguments - as the decl-chain of the current lexical scope. - Put the enumerators in as well, at the front so that - DECL_ARGUMENTS is not modified. */ - - storedecls (chainon (nonparms, DECL_ARGUMENTS (fndecl))); - - /* Initialize the RTL code for the function. */ - DECL_SAVED_INSNS (fndecl) = 0; - expand_function_start (fndecl, parms_have_cleanups); - - if (flag_handle_exceptions) - { - /* Make the throw decl visibile at this level, just - not in the way of the parameters. */ - pushdecl (eh_decl); - expand_decl_init (eh_decl); - } - - /* Create a binding contour which can be used to catch - cleanup-generated temporaries. Also, if the return value needs or - has initialization, deal with that now. */ - pushlevel (0); - expand_start_bindings (0); - current_function_parms_stored = 1; - - /* If this function is `main', emit a call to `__main' - to run global initializers, etc. */ - if (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 4 - && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main") == 0) - expand_expr (build_function_call (lookup_name (get_identifier ("__main")), NULL_TREE), - 0, VOIDmode, 0); -} - -/* Bind a name and initialization to the return value of - the current function. */ -void -store_return_init (init) - tree init; -{ - tree decl = DECL_RESULT (current_function_decl); - - /* Can't let this happen for constructors. */ - if (DECL_CONSTRUCTOR_P (current_function_decl)) - { - error ("can't redefine default return value for constructors"); - return; - } - - /* If we have a named return value, put that in our scope as well. */ - if (DECL_NAME (decl) != value_identifier) - { - /* If this named return value comes in a register, - put it in a pseudo-register. */ - if (TREE_REGDECL (decl)) - { - original_result_rtx = DECL_RTL (decl); - DECL_RTL (decl) = (struct rtx_def *)gen_reg_rtx (DECL_MODE (decl)); - } - - /* Let `finish_decl' know that this initializer is ok. */ - DECL_INITIAL (decl) = init; - pushdecl (decl); - finish_decl (decl, init, 0); - } -} - -/* Generate code for default X(X&) constructor. */ -static void -build_default_constructor (fndecl) - tree fndecl; -{ - int i = CLASSTYPE_N_BASECLASSES (current_class_type); - tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl)); - tree fields = TYPE_FIELDS (current_class_type); - if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)) - parm = TREE_CHAIN (parm); - parm = DECL_REFERENCE_SLOT (parm); - - while (i > 0) - { - tree basetype = CLASSTYPE_BASECLASS (current_class_type, i); - if (TYPE_GETS_INIT_REF (basetype)) - { - tree name = TYPE_NAME (basetype); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - current_base_init_list = tree_cons (name, parm, current_base_init_list); - } - i -= 1; - } - for (fields = TYPE_FIELDS (current_class_type); fields; - fields = TREE_CHAIN (fields)) - { - tree name, init; - if (TREE_STATIC (fields)) - continue; - if (TREE_CODE (fields) != FIELD_DECL) - continue; - if (DECL_NAME (fields)) - { - if (VFIELD_NAME_P (DECL_NAME (fields))) - continue; - if (VBASE_NAME_P (DECL_NAME (fields))) - continue; - - /* True for duplicate members. */ - if (IDENTIFIER_CLASS_VALUE (DECL_NAME (fields)) != fields) - continue; - } - - init = build (COMPONENT_REF, TREE_TYPE (fields), parm, fields); - - if (TREE_ANON_UNION_ELEM (fields)) - name = build (COMPONENT_REF, TREE_TYPE (fields), C_C_D, fields); - else - { - name = DECL_NAME (fields); - init = build_tree_list (NULL_TREE, init); - } - - current_member_init_list - = tree_cons (name, init, current_member_init_list); - } -} - - -/* Finish up a function declaration and compile that function - all the way to assembler language output. The free the storage - for the function definition. - - This is called after parsing the body of the function definition. - LINENO is the current line number. - - C++: CALL_POPLEVEL is non-zero if an extra call to poplevel - (and expand_end_bindings) must be made to take care of the binding - contour for the base initialazers. This is only relevant for - constructors. */ - -void -finish_function (lineno, call_poplevel) - int lineno; - int call_poplevel; -{ - register tree fndecl = current_function_decl; - tree fntype = TREE_TYPE (fndecl), ctype = NULL_TREE; - struct rtx_def *head, *last_parm_insn, *mark; - extern struct rtx_def *get_last_insn (); - extern struct rtx_def *cleanup_label, *return_label; - extern int sets_exception_throw_decl; - -/* TREE_READONLY (fndecl) = 1; - This caused &foo to be of type ptr-to-const-function - which then got a warning when stored in a ptr-to-function variable. */ - - /* This happens on strange parse errors. */ - if (! current_function_parms_stored) - { - call_poplevel = 0; - store_parm_decls (); - } - - /* Clean house because we will need to reorder insns here. */ - do_pending_stack_adjust (); - - if (dtor_label) - { - tree cond = integer_one_node; - tree exprstmt, vfields; - tree in_charge_node = lookup_name (in_charge_identifier); - int ok_to_optimize_dtor = 0; - - if (current_function_assigns_this) - cond = build (NE_EXPR, integer_type_node, - current_class_decl, integer_zero_node); - else - { - int n_baseclasses = CLASSTYPE_N_BASECLASSES (current_class_type); - - /* If this destructor is empty, then we don't need to check - whether `this' is NULL in some cases. */ - mark = get_last_insn (); - last_parm_insn = (struct rtx_def *)get_first_nonparm_insn (); - - if ((flag_this_is_variable & 1) == 0) - ok_to_optimize_dtor = 1; - else if (mark == last_parm_insn) - ok_to_optimize_dtor - = (n_baseclasses == 0 - || (n_baseclasses == 1 - && TYPE_HAS_DESTRUCTOR (CLASSTYPE_BASECLASS (current_class_type, 1)))); - } - - /* These initializations might go inline. Protect - the binding level of the parms. */ - pushlevel (0); - - if (current_function_assigns_this) - { - TYPE_ANY_ASSIGNS_THIS (current_class_type) = 1; - current_function_assigns_this = 0; - current_function_just_assigned_this = 0; - } - - /* Generate the code to call destructor on base class. - If this destructor belongs to a class with virtual - functions, then set the virtual function table - pointer to represent the type of our base class. */ - - /* This side-effect makes call to `build_delete' generate the - code we have to have at the end of this destructor. */ - TYPE_HAS_DESTRUCTOR (current_class_type) = 0; - - /* These are two cases where we cannot delegate deletion. */ - if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type) - || TREE_GETS_DELETE (current_class_type)) - exprstmt = build_delete (current_class_type, C_C_D, integer_zero_node, - LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0); - else - exprstmt = build_delete (current_class_type, C_C_D, in_charge_node, - LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0); - - /* If we did not assign to this, then `this' is non-zero at - the end of a destructor. As a special optimization, don't - emit test if this is an empty destructor. If it does nothing, - it does nothing. If it calls a base destructor, the base - destructor will perform the test. */ - - if (exprstmt != error_mark_node - && (TREE_CODE (exprstmt) != NOP_EXPR - || TREE_OPERAND (exprstmt, 0) != integer_zero_node - || TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))) - { - expand_label (dtor_label); - if (cond != integer_one_node) - expand_start_cond (cond, 0); - expand_expr_stmt (exprstmt); - - /* Run destructor on all virtual baseclasses. */ - if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)) - { - tree vbases = nreverse (copy_list (CLASSTYPE_VBASECLASSES (current_class_type))); - expand_start_cond (build (BIT_AND_EXPR, integer_type_node, - in_charge_node, integer_two_node), 0); - while (vbases) - { - if (TYPE_NEEDS_DESTRUCTOR (TREE_VALUE (vbases))) - { - tree ptr = convert_pointer_to_vbase (TREE_TYPE (vbases), current_class_decl); - expand_expr_stmt (build_delete (TYPE_POINTER_TO (TREE_VALUE (vbases)), - ptr, integer_zero_node, - LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR|LOOKUP_HAS_IN_CHARGE, 0)); - } - vbases = TREE_CHAIN (vbases); - } - expand_end_cond (); - } - - do_pending_stack_adjust (); - if (cond != integer_one_node) - expand_end_cond (); - } - - TYPE_HAS_DESTRUCTOR (current_class_type) = 1; - - /* At the end, call delete if that's what's requested. */ - if (TREE_GETS_DELETE (current_class_type)) - exprstmt = build_method_call (build1 (NOP_EXPR, TYPE_POINTER_TO (current_class_type), error_mark_node), - get_identifier (OPERATOR_DELETE_FORMAT), - build_tree_list (NULL_TREE, current_class_decl), - NULL_TREE, LOOKUP_NORMAL); - else if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)) - exprstmt = build_x_delete (ptr_type_node, current_class_decl, 0); - else - exprstmt = 0; - - if (exprstmt) - { - cond = build (BIT_AND_EXPR, integer_type_node, - in_charge_node, integer_one_node); - expand_start_cond (cond, 0); - expand_expr_stmt (exprstmt); - expand_end_cond (); - } - - /* End of destructor. */ - poplevel (2, 0, 0); - - /* Back to the top of destructor. */ - /* Dont execute destructor code if `this' is NULL. */ - mark = get_last_insn (); - last_parm_insn = (struct rtx_def *)get_first_nonparm_insn (); - if (last_parm_insn == 0) last_parm_insn = mark; - else last_parm_insn = (struct rtx_def *) previous_insn (last_parm_insn); - - /* Make all virtual function table pointers point to CURRENT_CLASS_TYPE's - virtual function tables. */ - if (CLASSTYPE_VFIELDS (current_class_type)) - { - for (vfields = CLASSTYPE_VFIELDS (current_class_type); - TREE_CHAIN (vfields); - vfields = TREE_CHAIN (vfields)) - expand_expr_stmt (build_virtual_init (current_class_type, - TREE_VALUE (vfields), - current_class_decl)); - expand_expr_stmt (build_virtual_init (current_class_type, - current_class_type, - current_class_decl)); - } - if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)) - expand_expr_stmt (build_vbase_vtables_init (current_class_type, - current_class_type, - C_C_D, current_class_decl, 0)); -#ifdef sparc - expand_asm_operands (build_string (32, "! end of vtable initialization"), 0, 0, 0, 0, input_filename, lineno); -#endif - - if (! ok_to_optimize_dtor) - { - cond = build_binary_op (NE_EXPR, current_class_decl, integer_zero_node); - expand_start_cond (cond, 0); - } - if (mark != get_last_insn ()) - reorder_insns (next_insn (mark), get_last_insn (), last_parm_insn); - if (! ok_to_optimize_dtor) - expand_end_cond (); - } - else if (current_function_assigns_this) - { - /* Does not need to call emit_base_init, because - that is done (if needed) just after assignment to this - is seen. */ - - TYPE_ANY_ASSIGNS_THIS (current_class_type) = 1; - - if (DECL_CONSTRUCTOR_P (current_function_decl)) - { - /* Undo call to pushlevel from `start_function'. */ - poplevel (2, 0, 0); - - expand_label (ctor_label); - ctor_label = NULL_TREE; - - if (call_poplevel) - { - tree decls = getdecls (); - if (flag_handle_exceptions == 2) - deactivate_exception_cleanups (); - expand_end_bindings (decls, decls != 0, 0); - poplevel (decls != 0, 0, 0); - } - - c_expand_return (current_class_decl); - } - - current_function_assigns_this = 0; - current_function_just_assigned_this = 0; - base_init_insns = 0; - } - else if (DECL_CONSTRUCTOR_P (fndecl)) - { - tree allocated_this; - tree cond, thenclause; - /* Allow constructor for a type to get a new instance of the object - using `build_new'. */ - tree abstract_virtuals = CLASSTYPE_ABSTRACT_VIRTUALS (current_class_type); - CLASSTYPE_ABSTRACT_VIRTUALS (current_class_type) = NULL_TREE; - - DECL_RETURNS_FIRST_ARG (fndecl) = 1; - - if (flag_this_is_variable) - { - cond = build_binary_op (EQ_EXPR, current_class_decl, integer_zero_node); - thenclause = build_modify_expr (current_class_decl, NOP_EXPR, - build_new (NULL_TREE, current_class_type, void_type_node, 0)); - if (flag_handle_exceptions == 2) - { - tree cleanup, cleanup_deallocate; - - allocated_this = build_decl (VAR_DECL, NULL_TREE, ptr_type_node); - TREE_REGDECL (allocated_this) = 1; - DECL_INITIAL (allocated_this) = error_mark_node; - expand_decl (allocated_this); - expand_decl_init (allocated_this); - /* How we cleanup `this' if an exception was raised before - we are ready to bail out. */ - cleanup = TREE_GETS_DELETE (current_class_type) - ? build_opfncall (DELETE_EXPR, LOOKUP_NORMAL, allocated_this) - : build_delete (TREE_TYPE (allocated_this), allocated_this, integer_three_node, LOOKUP_NORMAL|LOOKUP_HAS_IN_CHARGE, 1); - cleanup_deallocate - = build_modify_expr (current_class_decl, NOP_EXPR, integer_zero_node); - cleanup = tree_cons (NULL_TREE, cleanup, - build_tree_list (NULL_TREE, cleanup_deallocate)); - - expand_decl_cleanup (allocated_this, - build (COND_EXPR, integer_type_node, - build (NE_EXPR, integer_type_node, - allocated_this, integer_zero_node), - build_compound_expr (cleanup), - integer_zero_node)); - } - } - else if (TREE_GETS_NEW (current_class_type)) - /* Just check visibility here. */ - build_method_call (build1 (NOP_EXPR, TYPE_POINTER_TO (current_class_type), error_mark_node), - get_identifier (OPERATOR_NEW_FORMAT), - build_tree_list (NULL_TREE, integer_zero_node), - NULL_TREE, LOOKUP_NORMAL); - - CLASSTYPE_ABSTRACT_VIRTUALS (current_class_type) = abstract_virtuals; - - /* must keep the first insn safe. */ - head = (struct rtx_def *)get_insns (); - - /* this note will come up to the top with us. */ - mark = get_last_insn (); - - if (flag_this_is_variable) - { - expand_start_cond (cond, 0); - expand_expr_stmt (thenclause); - if (flag_handle_exceptions == 2) - expand_assignment (allocated_this, current_class_decl, 0, 0); - expand_end_cond (); - } - - if (DECL_COMPILER_GENERATED_P (fndecl) - && TREE_CHAIN (DECL_ARGUMENTS (fndecl)) != NULL_TREE) - build_default_constructor (fndecl); - - /* Emit insns from `emit_base_init' which sets up virtual - function table pointer(s). */ - emit_insns (base_init_insns); - base_init_insns = 0; - - /* This is where the body of the constructor begins. - If there were no insns in this function body, then the - last_parm_insn is also the last insn. - - If optimization is enabled, last_parm_insn may move, so - we don't hold on to it (across emit_base_init). */ - last_parm_insn = (struct rtx_def *)get_first_nonparm_insn (); - if (last_parm_insn == 0) last_parm_insn = mark; - else last_parm_insn = (struct rtx_def *) previous_insn (last_parm_insn); - - if (mark != get_last_insn ()) - reorder_insns (next_insn (mark), get_last_insn (), last_parm_insn); - - /* This is where the body of the constructor ends. */ - expand_label (ctor_label); - ctor_label = NULL_TREE; - if (flag_handle_exceptions == 2) - { - expand_assignment (allocated_this, integer_zero_node, 0, 0); - deactivate_exception_cleanups (); - } - - pop_implicit_try_blocks (NULL_TREE); - - /* Undo call to pushlevel from `start_function'. */ - poplevel (2, 0, 0); - - if (call_poplevel) - { - expand_end_bindings (getdecls (), 1, 0); - poplevel (1, 1, 0); - } - - if (any_pending_cleanups ()) - /* Do things the hard way. */ - c_expand_return (current_class_decl); - else - { - /* Just store CURRENT_CLASS_DECL in the - DECL_RESULT of our current function decl - and fall through to end. */ - struct rtx_def *val = DECL_RTL (DECL_RESULT (fndecl)); - store_expr (current_class_decl, val, 0); - emit_queue (); - use_variable (val); - } - - current_function_assigns_this = 0; - current_function_just_assigned_this = 0; - } - else if (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 4 - && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main")) - { - /* Make it so that `main' always returns 0 by default. */ -#ifdef VMS - c_expand_return (integer_one_node); -#else - c_expand_return (integer_zero_node); -#endif - } - - /* That's the end of the vtable decl's life. Need to mark it such - if doing stupid register allocation. - - Note that current_vtable_decl is really an INDIRECT_REF - on top of a VAR_DECL here. */ - if (obey_regdecls && current_vtable_decl) - use_variable (DECL_RTL (TREE_OPERAND (current_vtable_decl, 0))); - - /* remove the binding contour which is used - to catch cleanup-generated temporaries. */ - expand_end_bindings (0, 0, 0); - poplevel (0, 0, 0); - - /* Must mark the RESULT_DECL as being in this function. */ - - DECL_CONTEXT (DECL_RESULT (fndecl)) = DECL_INITIAL (fndecl); - - /* Obey `register' declarations if `setjmp' is called in this fn. */ - if (flag_traditional && current_function_calls_setjmp) - setjmp_protect (DECL_INITIAL (fndecl)); - - /* Generate rtl for function exit. */ - head = get_last_insn (); - expand_function_end (input_filename, lineno); - - if (cleanup_label) - { - mark = get_last_insn (); - /* Emit label at beginning of cleanup code for parmeters. */ - emit_label (cleanup_label); - } - -#if 1 - /* Cheap hack to get better code from GNU C++. Remove when cse is fixed. */ - if (exception_throw_decl && sets_exception_throw_decl == 0) - expand_assignment (exception_throw_decl, integer_zero_node, 0, 0); -#endif - - if (flag_handle_exceptions) - { - expand_end_try (); - expand_start_except (0, 0); - expand_end_except (); - } - expand_end_bindings (0, 0, 0); - - /* Get return value into reigster if that's where it's supposed to be. */ - if (original_result_rtx) - fixup_result_decl (DECL_RESULT (fndecl), original_result_rtx); - - /* reset scope for C++: if we were in the scope of a class, - then when we finish this function, we are not longer so. - This cannot be done until we know for sure that no more - class members will ever be referenced in this function - (i.e., calls to destructors). */ - if (current_class_name) - { - ctype = current_class_type; - popclass (1); - } - else - pop_memoized_context (1); - - /* Forget about all overloaded functions defined in - this scope which go away. */ - while (overloads_to_forget) - { - IDENTIFIER_GLOBAL_VALUE (TREE_PURPOSE (overloads_to_forget)) - = TREE_VALUE (overloads_to_forget); - overloads_to_forget = TREE_CHAIN (overloads_to_forget); - } - - poplevel (1, 0, 1); - - if (cleanup_label) - { - /* To keep us from getting the compiler confused about - what constitutes control dropping off the end, - send control to RETURN_LABEL. All this really - avoids is the NOTE_INSN_FUNCTION_END note. */ - if (return_label) - emit_jump_insn (gen_jump (return_label)); -#ifdef HAVE_return - else - emit_jump_insn (gen_return ()); -#endif - - emit_barrier (); - - reorder_insns (next_insn (mark), get_last_insn (), head); - } - - /* So we can tell if jump_optimize sets it to 1. */ - current_function_returns_null = 0; - - if (TREE_EXTERNAL (fndecl) && ! TREE_PUBLIC (fndecl) - /* This function is just along for the ride. If we can make - it inline, that's great. Otherwise, just punt it. */ - && (TREE_INLINE (fndecl) == 0 - || function_cannot_inline_p (fndecl))) - { - extern int rtl_dump_and_exit; - int old_rtl_dump_and_exit = rtl_dump_and_exit; - - /* This throws away the code for FNDECL. */ - rtl_dump_and_exit = 1; - rest_of_compilation (fndecl); - rtl_dump_and_exit = old_rtl_dump_and_exit; - } - else - /* Run the optimizers and output the assembler code for this function. */ - rest_of_compilation (fndecl); - - if (ctype && TREE_ASM_WRITTEN (fndecl)) - CLASSTYPE_ASM_WRITTEN (ctype) = 1; - - /* Since we don't normally go through c_expand_return for constructors, - this normally gets the wrong value. - Also, named return values have their return codes emitted after - NOTE_INSN_FUNCTION_END, confusing jump.c. */ - if (DECL_CONSTRUCTOR_P (fndecl) - || DECL_NAME (DECL_RESULT (fndecl)) != value_identifier) - current_function_returns_null = 0; - - if (TREE_THIS_VOLATILE (fndecl) && current_function_returns_null) - warning ("`volatile' function does return"); - else if (warn_return_type && current_function_returns_null - && TREE_TYPE (fntype) != void_type_node) - /* If this function returns non-void and control can drop through, - complain. */ - warning ("control reaches end of non-void function"); - /* With just -W, complain only if function returns both with - and without a value. */ - else if (extra_warnings - && current_function_returns_value && current_function_returns_null) - warning ("this function may return with or without a value"); - - /* Free all the tree nodes making up this function. */ - /* Switch back to allocating nodes permanently - until we start another function. */ - permanent_allocation (); - - if (flag_cadillac) - cadillac_finish_function (fndecl); - - if (DECL_SAVED_INSNS (fndecl) == 0) - { - /* Stop pointing to the local nodes about to be freed. */ - /* But DECL_INITIAL must remain nonzero so we know this - was an actual function definition. */ - DECL_INITIAL (fndecl) = error_mark_node; - if (! DECL_CONSTRUCTOR_P (fndecl) - || !TYPE_USES_VIRTUAL_BASECLASSES (TYPE_METHOD_BASETYPE (fntype))) - DECL_ARGUMENTS (fndecl) = 0; - } - - /* Let the error reporting routines know that we're outside a function. */ - current_function_decl = NULL_TREE; - named_label_uses = NULL_TREE; - clear_anon_parm_name (); -} - -/* Create the FUNCTION_DECL for a function definition. - LINE1 is the line number that the definition absolutely begins on. - LINE2 is the line number that the name of the function appears on. - DECLSPECS and DECLARATOR are the parts of the declaration; - they describe the function's name and the type it returns, - but twisted together in a fashion that parallels the syntax of C. - - This function creates a binding context for the function body - as well as setting up the FUNCTION_DECL in current_function_decl. - - Returns a FUNCTION_DECL on success. - - If the DECLARATOR is not suitable for a function (it defines a datum - instead), we return 0, which tells yyparse to report a parse error. - - May return void_type_node indicating that this method is actually - a friend. See grokfield for more details. - - Came here with a `.pushlevel' . - - DO NOT MAKE ANY CHANGES TO THIS CODE WITHOUT MAKING CORRESPONDING - CHANGES TO CODE IN `grokfield'. */ -tree -start_method (declspecs, declarator, raises) - tree declarator, declspecs, raises; -{ - tree fndecl = grokdeclarator (declarator, declspecs, MEMFUNCDEF, 0, raises); - - /* Something too ugly to handle. */ - if (fndecl == 0) - return 0; - - /* Pass friends other than inline friend functions back. */ - if (fndecl == void_type_node) - return void_type_node; - - if (TREE_CODE (fndecl) != FUNCTION_DECL) - /* Not a function, tell parser to report parse error. */ - return 0; - - if (DECL_IN_AGGR_P (fndecl)) - { - if (IDENTIFIER_ERROR_LOCUS (DECL_NAME (fndecl)) != current_class_type) - error_with_decl (fndecl, "`%s' is already defined in aggregate scope"); - return void_type_node; - } - - if (flag_default_inline) - TREE_INLINE (fndecl) = 1; - - /* We read in the parameters on the maybepermanent_obstack, - but we won't be getting back to them until after we - may have clobbered them. So the call to preserve_data - will keep them safe. */ - preserve_data (); - - if (! DECL_FRIEND_P (fndecl)) - { - if (TREE_CHAIN (fndecl) != NULL_TREE) - /* Need a fresh node here so that we don't get circularity - when we link these together. If FNDECL was a friend, then - `pushdecl' does the right thing, which is nothing wrt its - current value of TREE_CHAIN. */ - fndecl = copy_node (fndecl); - - if (DECL_CONSTRUCTOR_P (fndecl)) - grok_ctor_properties (current_class_type, fndecl); - else if (OPERATOR_NAME_P (DECL_NAME (fndecl))) - { - TREE_OPERATOR (fndecl) = 1; - grok_op_properties (fndecl); - } - } - - finish_decl (fndecl, NULL, NULL); - - /* Make a place for the parms */ - pushlevel (0); - current_binding_level->parm_flag = 1; - - DECL_IN_AGGR_P (fndecl) = 1; - return fndecl; -} - -/* Go through the motions of finishing a function definition. - We don't compile this method until after the whole class has - been processed. - - FINISH_METHOD must return something that looks as though it - came from GROKFIELD (since we are defining a method, after all). - - This is called after parsing the body of the function definition. - STMTS is the chain of statements that makes up the function body. - - DECL is the ..._DECL that `start_method' provided. */ - -tree -finish_method (decl) - tree decl; -{ - register tree fndecl = decl; - tree old_initial; - - register tree link; - - if (decl == void_type_node) - return decl; - - old_initial = DECL_INITIAL (fndecl); - - /* Undo the level for the parms (from start_method). - This is like poplevel, but it causes nothing to be - saved. Saving information here confuses symbol-table - output routines. Besides, this information will - be correctly output when this method is actually - compiled. */ - - /* Clear out the meanings of the local variables of this level; - also record in each decl which block it belongs to. */ - - for (link = current_binding_level->names; link; link = TREE_CHAIN (link)) - { - if (DECL_NAME (link) != 0) - IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = 0; - DECL_CONTEXT (link) = 0; - } - - /* Restore all name-meanings of the outer levels - that were shadowed by this level. */ - - for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link)) - IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); - for (link = current_binding_level->class_shadowed; - link; - link = TREE_CHAIN (link)) - IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link); - -#ifdef FIELD_XREF - FIELD_xref_end_scope(current_binding_level, - current_binding_level->level_chain, - current_binding_level->parm_flag, - current_binding_level->keep, - current_binding_level->tag_transparent); -#endif - - POP_BINDING_LEVEL; - - DECL_INITIAL (fndecl) = old_initial; - if (DECL_FRIEND_P (fndecl)) - { - if (current_lang_name == lang_name_cplusplus) - CLASSTYPE_INLINE_FRIENDS (current_class_type) - = tree_cons (NULL_TREE, fndecl, CLASSTYPE_INLINE_FRIENDS (current_class_type)); - return void_type_node; - } - return decl; -} - -/* Called when a new struct TYPE is defined. - If this structure or union completes the type of any previous - variable declaration, lay it out and output its rtl. */ - -void -hack_incomplete_structures (type) - tree type; -{ - tree decl; - - if (current_binding_level->n_incomplete == 0) - return; - - for (decl = current_binding_level->names; decl; decl = TREE_CHAIN (decl)) - if (TREE_TYPE (decl) == type - || (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE - && TREE_TYPE (TREE_TYPE (decl)) == type)) - { - if (TREE_CODE (decl) == TYPE_DECL) - layout_type (TREE_TYPE (decl)); - else - { - int toplevel = global_binding_level == current_binding_level; - layout_decl (decl, 0); - rest_of_decl_compilation (decl, 0, toplevel, 0); - if (! toplevel) - { - expand_decl (decl); - expand_decl_cleanup (decl, maybe_build_cleanup (decl)); - expand_decl_init (decl); - } - } - assert (current_binding_level->n_incomplete > 0); - --current_binding_level->n_incomplete; - } -} - -/* Nonzero if presently building a cleanup. Needed because - SAVE_EXPRs are not the right things to use inside of cleanups. - They are only ever evaluated once, where the cleanup - might be evaluated several times. In this case, a later evaluation - of the cleanup might fill in the SAVE_EXPR_RTL, and it will - not be valid for an earlier cleanup. */ - -int building_cleanup; - -/* If DECL is of a type which needs a cleanup, build that cleanup here. - We don't build cleanups if just going for syntax checking, since - fixup_cleanups does not know how to not handle them. - - Don't build these on the momentary obstack; they must live - the life of the binding contour. */ -tree -maybe_build_cleanup (decl) - tree decl; -{ - tree type = TREE_TYPE (decl); - if (TYPE_NEEDS_DESTRUCTOR (type)) - { - int temp; - tree rval; - int old_building_cleanup = building_cleanup; - building_cleanup = 1; - if (TREE_CODE (decl) == PARM_DECL) - { - temp = allocation_temporary_p (); - end_temporary_allocation (); - } - else - temp = suspend_momentary (); - - if (TREE_CODE (type) == ARRAY_TYPE) - rval = decl; - else - { - mark_addressable (decl); - rval = build1 (ADDR_EXPR, TYPE_POINTER_TO (type), decl); - } - rval = build_delete (TREE_TYPE (rval), rval, integer_two_node, - LOOKUP_NORMAL, 0); - - if (TYPE_LANG_SPECIFIC (type) - && ! TYPE_HAS_DESTRUCTOR (type) - && TYPE_USES_VIRTUAL_BASECLASSES (type)) - rval = build_compound_expr (tree_cons (NULL_TREE, rval, - build_tree_list (NULL_TREE, build_vbase_delete (type, decl)))); - - current_binding_level->have_cleanups = 1; - current_binding_level->more_exceptions_ok = 0; - - if (TREE_CODE (decl) == PARM_DECL) - { - if (temp) - resume_temporary_allocation (); - } - else - resume_momentary (temp); - - building_cleanup = old_building_cleanup; - - return rval; - } - return 0; -} - -tree -cleanup_after_call (expr) - tree expr; -{ - tree type = TREE_TYPE (expr); - tree decl = get_temp_name (type, 0); - tree rval = build (WITH_CLEANUP_EXPR, type, - build (INIT_EXPR, type, decl, expr), 0, - maybe_build_cleanup (decl)); - return rval; -} - -/* Expand a C++ expression at the statement level. - This is needed to ferret out nodes which have UNKNOWN_TYPE. - The C++ type checker should get all of these out when - expressions are combined with other, type-providing, expressions, - leaving only orphan expressions, such as: - - &class::bar; / / takes its address, but do nothing with it. - - */ -void -cplus_expand_expr_stmt (exp) - tree exp; -{ - if (TREE_TYPE (exp) == unknown_type_node) - { - if (TREE_CODE (exp) == ADDR_EXPR) - { - if (TREE_CODE (TREE_OPERAND (exp, 0)) == OP_IDENTIFIER) - error ("unresolved reference to user-defined operator"); - else - error ("address of overloaded function with no contextual type information"); - } - else if (TREE_CODE (exp) == TREE_LIST) - error ("address of overloaded function with no contextual type information"); - else if (TREE_CODE (exp) == OP_IDENTIFIER) - error ("unresolved reference to user-defined operator"); - else if (TREE_CODE (exp) == COMPONENT_REF) - warning ("useless reference to a member function name, did you forget the ()?"); - } - else - { - int remove_implicit_immediately = 0; - - if (TREE_CODE (exp) == CALL_EXPR - && TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (exp))) - exp = cleanup_after_call (exp); - else if (TREE_CODE (exp) == FUNCTION_DECL) - warning_with_decl (exp, "reference, not call, to function `%s'"); - if (TREE_RAISES (exp)) - { - assert (flag_handle_exceptions); - if (flag_handle_exceptions == 2) - { - if (! current_binding_level->more_exceptions_ok) - { - extern struct nesting *nesting_stack, *block_stack; - - remove_implicit_immediately - = (nesting_stack != block_stack); - cplus_expand_start_try (1); - } - current_binding_level->have_exceptions = 1; - } - } - expand_expr_stmt (exp); - if (remove_implicit_immediately) - pop_implicit_try_blocks (NULL_TREE); - } - - /* Clean up any pending cleanups. This happens when a function call - returns a cleanup-needing value that nobody uses. */ - expand_cleanups_to (NULL_TREE); -} - -/* When a stmt has been parsed, this function is called. - - Currently, this function only does something within a - constructor's scope: if a stmt has just assigned to this, - and we are in a derived class, we call `emit_base_init'. */ - -void -finish_stmt () -{ - extern struct nesting *cond_stack, *loop_stack, *case_stack; - - - if (current_function_assigns_this - || ! current_function_just_assigned_this) - return; - if (DECL_CONSTRUCTOR_P (current_function_decl)) - { - /* Constructors must wait until we are out of control - zones before calling base constructors. */ - if (cond_stack || loop_stack || case_stack) - return; - emit_insns (base_init_insns); - check_base_init (current_class_type); - } - current_function_assigns_this = 1; - - if (flag_cadillac) - cadillac_finish_stmt (); -} - -void -pop_implicit_try_blocks (decl) - tree decl; -{ - if (decl) - { - assert (current_binding_level->parm_flag == 3); - current_binding_level->names = TREE_CHAIN (decl); - } - - while (current_binding_level->parm_flag == 3) - { - tree name = get_identifier ("(compiler error)"); - tree orig_ex_type = current_exception_type; - tree orig_ex_decl = current_exception_decl; - tree orig_ex_obj = current_exception_object; - tree decl = cplus_expand_end_try (2), decls; - tree current_exception_ptr; - - /* @@ It would be nice to make all these point - to exactly the same handler. */ - /* Start hidden EXCEPT. */ - cplus_expand_start_except (name, decl); - /* reraise ALL. */ - cplus_expand_reraise (NULL_TREE); - current_exception_type = orig_ex_type; - current_exception_decl = orig_ex_decl; - current_exception_object = orig_ex_obj; - /* This will reraise for us. */ - cplus_expand_end_except (error_mark_node); - } - - if (decl) - { - TREE_CHAIN (decl) = current_binding_level->names; - current_binding_level->names = decl; - } -} - -#ifdef FIELD_XREF -static void -FIELD_end_scope(lvl) - struct binding_level * lvl; -{ - FIELD_xref_end_scope(lvl, - lvl->level_chain, - lvl->parm_flag, - lvl->keep, - lvl->tag_transparent); -}; - -#endif - -/* Push a cleanup onto the current binding contour that will cause - ADDR to be cleaned up, in the case that an exception propagates - through its binding contour. */ - -void -push_exception_cleanup (addr) - tree addr; -{ - tree decl = build_decl (VAR_DECL, get_identifier (EXCEPTION_CLEANUP_NAME), ptr_type_node); - tree cleanup; - - decl = pushdecl (decl); - TREE_REGDECL (decl) = 1; - store_init_value (decl, addr); - expand_decl (decl); - expand_decl_init (decl); - - cleanup = build (COND_EXPR, integer_type_node, - build (NE_EXPR, integer_type_node, - decl, integer_zero_node), - build_delete (TREE_TYPE (addr), decl, - lookup_name (in_charge_identifier), - LOOKUP_NORMAL, 0), - integer_zero_node); - expand_decl_cleanup (decl, cleanup); -} - -/* For each binding contour, emit code that deactivates the - exception cleanups. All other cleanups are left as they were. */ - -static void -deactivate_exception_cleanups () -{ - struct binding_level *b = current_binding_level; - tree xyzzy = get_identifier (EXCEPTION_CLEANUP_NAME); - while (b != class_binding_level) - { - if (b->parm_flag == 3) - { - tree decls = b->names; - while (decls) - { - if (DECL_NAME (decls) == xyzzy) - expand_assignment (decls, integer_zero_node, 0, 0); - decls = TREE_CHAIN (decls); - } - } - b = b->level_chain; - } -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-decl.h b/gnu/usr.bin/g++/cc1plus/cplus-decl.h deleted file mode 100644 index c8f47056fda1..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-decl.h +++ /dev/null @@ -1,40 +0,0 @@ -/* In grokdeclarator, distinguish syntactic contexts of declarators. */ -enum decl_context -{ NORMAL, /* Ordinary declaration */ - FUNCDEF, /* Function definition */ - PARM, /* Declaration of parm before function body */ - FIELD, /* Declaration inside struct or union */ - TYPENAME, /* Typename (inside cast or sizeof) */ - MEMFUNCDEF, /* Member function definition */ -}; - -/* C++: Keep these around to reduce calls to `get_identifier'. - Identifiers for `this' in member functions and the auto-delete - parameter for destructors. */ -extern tree this_identifier, in_charge_identifier; - -/* Parsing a function declarator leaves a list of parameter names - or a chain or parameter decls here. */ -extern tree last_function_parms; - -/* A list of static class variables. This is needed, because a - static class variable can be declared inside the class without - an initializer, and then initialized, staticly, outside the class. */ -extern tree pending_statics; - -/* A list of objects which have constructors or destructors - which reside in the global scope. The decl is stored in - the TREE_VALUE slot and the initializer is stored - in the TREE_PURPOSE slot. */ -extern tree static_aggregates; - -/* A list of functions which were declared inline, but later had their - address taken. Used only for non-virtual member functions, since we can - find other functions easily enough. */ -extern tree pending_addressable_inlines; - -#ifdef SOS -/* SOS extensions. */ -extern tree zlink_type, zret_type; -extern tree zlink, zret; -#endif diff --git a/gnu/usr.bin/g++/cc1plus/cplus-decl2.c b/gnu/usr.bin/g++/cc1plus/cplus-decl2.c deleted file mode 100644 index dcf0fc231ba9..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-decl2.c +++ /dev/null @@ -1,2323 +0,0 @@ -/* Process declarations and variables for C compiler. - Copyright (C) 1988 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* Process declarations and symbol lookup for C front end. - Also constructs types; the standard scalar types at initialization, - and structure, union, array and enum types when they are declared. */ - -/* ??? not all decl nodes are given the most useful possible - line numbers. For example, the CONST_DECLs for enum values. */ - -#include "config.h" -#include "tree.h" -#include "flags.h" -#include "cplus-tree.h" -#include "cplus-parse.h" -#include "cplus-decl.h" -#include "assert.h" - -#define NULL 0 - -extern tree grokdeclarator (); -static void grok_function_init (); - -/* A list of virtual function tables we must make sure to write out. */ -tree pending_vtables; - -/* A list of static class variables. This is needed, because a - static class variable can be declared inside the class without - an initializer, and then initialized, staticly, outside the class. */ -tree pending_statics; - -extern tree pending_addressable_inlines; - -/* Used to help generate temporary names which are unique within - a function. Reset to 0 by start_function. */ - -static int temp_name_counter; - -/* Same, but not reset. Local temp variables and global temp variables - can have the same name. */ -static int global_temp_name_counter; - -/* The (assembler) name of the first globally-visible object output. */ -extern char * first_global_object_name; - -/* C (and C++) language-specific option variables. */ - -/* Nonzero means allow type mismatches in conditional expressions; - just make their values `void'. */ - -int flag_cond_mismatch; - -/* Nonzero means don't recognize the keyword `asm'. */ - -int flag_no_asm; - -/* Nonzero means do some things the same way PCC does. */ - -int flag_traditional; - -/* Nonzero means warn about implicit declarations. */ - -int warn_implicit = 1; - -/* Nonzero means warn about function definitions that default the return type - or that use a null return and have a return-type other than void. */ - -int warn_return_type; - -/* Nonzero means give string constants the type `const char *' - to get extra warnings from them. These warnings will be too numerous - to be useful, except in thoroughly ANSIfied programs. */ - -int warn_write_strings; - -/* Nonzero means warn about pointer casts that can drop a type qualifier - from the pointer target type. */ - -int warn_cast_qual; - -/* Nonzero means warn about sizeof(function) or addition/subtraction - of function pointers. */ - -int warn_pointer_arith; - -/* Nonzero means warn for all old-style non-prototype function decls. */ - -int warn_strict_prototypes; - -/* Non-zero means warn in function declared in derived class has the - same name as a virtual in the base class, but fails to match the - type signature of any virtual function in the base class. */ -int warn_overloaded_virtual; - -/* Non-zero means warn when converting between different enumeral types. */ -int warn_enum_clash; - -/* Nonzero means `$' can be in an identifier. - See cccp.c for reasons why this breaks some obscure ANSI C programs. */ - -#ifndef DOLLARS_IN_IDENTIFIERS -#define DOLLARS_IN_IDENTIFIERS 0 -#endif -int dollars_in_ident = DOLLARS_IN_IDENTIFIERS; - -/* Nonzero for -no-strict-prototype switch: do not consider empty - argument prototype to mean function takes no arguments. */ - -int strict_prototype = 1; -int strict_prototypes_lang_c, strict_prototypes_lang_cplusplus = 1; - -/* Nonzero means that labels can be used as first-class objects */ - -int flag_labels_ok; - -/* Non-zero means to collect statistics which might be expensive - and to print them when we are done. */ -int flag_detailed_statistics; - -/* C++ specific flags. */ -/* Nonzero for -fall-virtual: make every member function (except - constructors) lay down in the virtual function table. Calls - can then either go through the virtual function table or not, - depending. */ - -int flag_all_virtual; - -/* Zero means that `this' is a *const. This gives nice behavior in the - 2.0 world. 1 gives 1.2-compatible behavior. 2 gives Spring behavior. */ - -int flag_this_is_variable; - -/* Nonzero means memoize our member lookups. */ - -int flag_memoize_lookups; int flag_save_memoized_contexts; - -/* Nonzero means to implement `dynamic' features a la SOS. */ - -int flag_dynamic; - -/* 3 means write out only virtuals function tables `defined' - in this implementation file. - 2 means write out only specific virtual function tables - and give them (C) public visibility. - 1 means write out virtual function tables and give them - (C) public visibility. - 0 means write out virtual function tables and give them - (C) static visibility (default). - -1 means declare virtual function tables extern. */ - -int write_virtuals; - -/* Nonzero means we should attempt to elide constructors when possible. */ - -int flag_elide_constructors; - -/* Nonzero means if the type has methods, only output debugging - information if methods are actually written to the asm file. */ - -int flag_minimal_debug = 1; - -/* Same, but for inline functions: nonzero means write out debug info - for inlines. Zero means do not. */ - -int flag_inline_debug; - -/* Nonzero means recognize and handle exception handling constructs. - 2 means handle exceptions the way Spring wants them handled. */ - -int flag_handle_exceptions; - -/* Nonzero means that member functions defined in class scope are - inline by default. */ - -int flag_default_inline = 1; - -/* Nonzero means that functions declared `inline' will be treated - as `static'. Used in conjunction with -g. */ -int flag_no_inline = 0; - -/* Controls whether enums and ints freely convert. - 1 means with complete freedom. - 0 means enums can convert to ints, but not vice-versa. */ -int flag_int_enum_equivalence; - -/* Controls whether compiler is operating under LUCID's Cadillac - system. 1 means yes, 0 means no. */ -int flag_cadillac; - -/* Table of language-dependent -f options. - STRING is the option name. VARIABLE is the address of the variable. - ON_VALUE is the value to store in VARIABLE - if `-fSTRING' is seen as an option. - (If `-fno-STRING' is seen as an option, the opposite value is stored.) */ - -static struct { char *string; int *variable; int on_value;} lang_f_options[] = -{ - {"signed-char", &flag_signed_char, 1}, - {"unsigned-char", &flag_signed_char, 0}, - {"short-enums", &flag_short_enums, 1}, - {"cond-mismatch", &flag_cond_mismatch, 1}, - {"asm", &flag_no_asm, 0}, - {"labels-ok", &flag_labels_ok, 1}, - {"stats", &flag_detailed_statistics, 1}, - {"this-is-variable", &flag_this_is_variable, 1}, - {"strict-prototype", &strict_prototypes_lang_cplusplus, 1}, - {"warn-implicit", &warn_implicit, 1}, - {"all-virtual", &flag_all_virtual, 1}, - {"memoize-lookups", &flag_memoize_lookups, 1}, - {"elide-constructors", &flag_elide_constructors, 1}, - {"minimal-debug", &flag_minimal_debug, 1}, - {"inline-debug", &flag_inline_debug, 0}, - {"handle-exceptions", &flag_handle_exceptions, 1}, - {"spring-exceptions", &flag_handle_exceptions, 2}, - {"default-inline", &flag_default_inline, 1}, - {"inline", &flag_no_inline, 0}, - {"dollars-in-identifiers", &dollars_in_ident, 1}, - {"enum-int-equiv", &flag_int_enum_equivalence, 1}, -}; - -/* Decode the string P as a language-specific option. - Return 1 if it is recognized (and handle it); - return 0 if not recognized. */ - -int -lang_decode_option (p) - char *p; -{ - if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional")) - flag_traditional = 1, dollars_in_ident = 1, flag_writable_strings = 1, - flag_this_is_variable = 1; - /* The +e options are for cfront compatability. */ - else if (p[0] == '+' && p[1] == 'e') - { - int old_write_virtuals = write_virtuals; - if (p[2] == '1') - write_virtuals = 1; - else if (p[2] == '0') - write_virtuals = -1; - else if (p[2] == '2') - write_virtuals = 2; - else error ("invalid +e option"); - if (old_write_virtuals != 0 - && write_virtuals != old_write_virtuals) - error ("conflicting +e options given"); - } - else if (p[0] == '-' && p[1] == 'f') - { - /* Some kind of -f option. - P's value is the option sans `-f'. - Search for it in the table of options. */ - int found = 0, j; - - p += 2; - /* Try special -f options. */ - - if (!strcmp (p, "save-memoized")) - { - flag_memoize_lookups = 1; - flag_save_memoized_contexts = 1; - found = 1; - } - else if (!strcmp (p, "SOS")) - { - flag_all_virtual = 2; - found = 1; - } - else if (! strncmp (p, "cadillac", 8)) - { - flag_cadillac = atoi (p+9); - found = 1; - } - else if (! strncmp (p, "no-cadillac", 11)) - { - flag_cadillac = 0; - found = 1; - } - else for (j = 0; - !found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]); - j++) - { - if (!strcmp (p, lang_f_options[j].string)) - { - *lang_f_options[j].variable = lang_f_options[j].on_value; - /* A goto here would be cleaner, - but breaks the vax pcc. */ - found = 1; - } - if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' - && ! strcmp (p+3, lang_f_options[j].string)) - { - *lang_f_options[j].variable = ! lang_f_options[j].on_value; - found = 1; - } - } - return found; - } - else if (p[0] == '-' && p[1] == 'W') - { - /* The -W options control the warning behavior of the compiler. */ - p += 2; - - if (!strcmp (p, "implicit")) - warn_implicit = 1; - else if (!strcmp (p, "return-type")) - warn_return_type = 1; - else if (!strcmp (p, "write-strings")) - warn_write_strings = 1; - else if (!strcmp (p, "cast-qual")) - warn_cast_qual = 1; - else if (!strcmp (p, "pointer-arith")) - warn_pointer_arith = 1; - else if (!strcmp (p, "strict-prototypes")) - warn_strict_prototypes = 1; - else if (!strcmp (p, "comment")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "comments")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "trigraphs")) - ; /* cpp handles this one. */ - else if (!strcmp (p, "all")) - { - extra_warnings = 1; - warn_implicit = 1; - warn_return_type = 1; - warn_unused = 1; - warn_switch = 1; -#if 0 - warn_enum_clash = 1; -#endif - warn_inline = 1; - } - - else if (!strcmp (p, "overloaded-virtual")) - warn_overloaded_virtual = 1; - else if (!strcmp (p, "enum-clash")) - warn_enum_clash = 1; - else return 0; - } - else if (!strcmp (p, "-ansi")) - flag_no_asm = 1, dollars_in_ident = 0; - else - return 0; - - return 1; -} - -/* Incorporate `const' and `volatile' qualifiers for member functions. - FUNCTION is a TYPE_DECL or a FUNCTION_DECL. - QUALS is a list of qualifiers. */ -tree -grok_method_quals (ctype, function, quals) - tree ctype, function, quals; -{ - tree fntype = TREE_TYPE (function); - tree raises = TYPE_RAISES_EXCEPTIONS (fntype); - - assert (quals != NULL_TREE); - do - { - extern tree ridpointers[]; - - if (TREE_VALUE (quals) == ridpointers[(int)RID_CONST]) - { - if (TREE_READONLY (ctype)) - error ("duplicate `%s' %s", - IDENTIFIER_POINTER (TREE_VALUE (quals)), - (TREE_CODE (function) == FUNCTION_DECL - ? "for member function" : "in type declaration")); - ctype = build_type_variant (ctype, 1, TREE_VOLATILE (ctype)); - build_pointer_type (ctype); - } - else if (TREE_VALUE (quals) == ridpointers[(int)RID_VOLATILE]) - { - if (TREE_VOLATILE (ctype)) - error ("duplicate `%s' %s", - IDENTIFIER_POINTER (TREE_VALUE (quals)), - (TREE_CODE (function) == FUNCTION_DECL - ? "for member function" : "in type declaration")); - ctype = build_type_variant (ctype, TREE_READONLY (ctype), 1); - build_pointer_type (ctype); - } - else - abort (); - quals = TREE_CHAIN (quals); - } - while (quals); - fntype = build_cplus_method_type (ctype, TREE_TYPE (fntype), - (TREE_CODE (fntype) == METHOD_TYPE - ? TREE_CHAIN (TYPE_ARG_TYPES (fntype)) - : TYPE_ARG_TYPES (fntype))); - if (raises) - fntype = build_exception_variant (ctype, fntype, raises); - - TREE_TYPE (function) = fntype; - return ctype; -} - - -/* Classes overload their constituent function names automatically. - When a function name is declared in a record structure, - its name is changed to it overloaded name. Since names for - constructors and destructors can conflict, we place a leading - '$' for destructors. - - CNAME is the name of the class we are grokking for. - - FUNCTION is a FUNCTION_DECL. It was created by `grokdeclarator'. - - FLAGS contains bits saying what's special about today's - arguments. 1 == DESTRUCTOR. 2 == OPERATOR. - - If FUNCTION is a destructor, then we must add the `auto-delete' field - as a second parameter. There is some hair associated with the fact - that we must "declare" this variable in the manner consistent with the - way the rest of the arguements were declared. - - If FUNCTION is a constructor, and we are doing SOS hacks for dynamic - classes, then the second hidden argument is the virtual function table - pointer with which to initialize the object. - - QUALS are the qualifiers for the this pointer. */ - -void -grokclassfn (ctype, cname, function, flags, complain, quals) - tree ctype, cname, function; - enum overload_flags flags; - tree quals; -{ - tree fn_name = DECL_NAME (function); - tree arg_types; - tree parm; - char *name; - - if (fn_name == NULL_TREE) - { - error ("name missing for member function"); - fn_name = get_identifier (""); - DECL_NAME (function) = DECL_ORIGINAL_NAME (function) = fn_name; - } - - if (quals) - ctype = grok_method_quals (ctype, function, quals); - - arg_types = TYPE_ARG_TYPES (TREE_TYPE (function)); - if (TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE) - { - /* Must add the class instance variable up front. */ - /* Right now we just make this a pointer. But later - we may wish to make it special. */ - tree type = TREE_VALUE (arg_types); - - if (flags == DTOR_FLAG) - type = TYPE_MAIN_VARIANT (type); - else if (DECL_CONSTRUCTOR_P (function)) - { - if (TYPE_DYNAMIC (ctype)) - { - parm = build_decl (PARM_DECL, get_identifier (AUTO_VTABLE_NAME), TYPE_POINTER_TO (ptr_type_node)); - TREE_USED (parm) = 1; - TREE_READONLY (parm) = 1; - DECL_ARG_TYPE (parm) = TYPE_POINTER_TO (ptr_type_node); - TREE_CHAIN (parm) = last_function_parms; - last_function_parms = parm; - } - - if (TYPE_USES_VIRTUAL_BASECLASSES (ctype)) - { - DECL_CONSTRUCTOR_FOR_VBASE_P (function) = 1; - /* In this case we need "in-charge" flag saying whether - this constructor is responsible for initialization - of virtual baseclasses or not. */ - parm = build_decl (PARM_DECL, in_charge_identifier, integer_type_node); - DECL_ARG_TYPE (parm) = integer_type_node; - TREE_REGDECL (parm) = 1; - TREE_CHAIN (parm) = last_function_parms; - last_function_parms = parm; - } - } - - parm = build_decl (PARM_DECL, this_identifier, type); - DECL_ARG_TYPE (parm) = type; - /* We can make this a register, so long as we don't - accidently complain if someone tries to take its address. */ - TREE_REGDECL (parm) = 1; - if (flags != DTOR_FLAG - && (!flag_this_is_variable || TREE_READONLY (type))) - TREE_READONLY (parm) = 1; - TREE_CHAIN (parm) = last_function_parms; - last_function_parms = parm; - } - - if (flags == DTOR_FLAG) - { - tree const_integer_type = build_type_variant (integer_type_node, 1, 0); - arg_types = hash_tree_chain (const_integer_type, void_list_node); - name = (char *)alloca (sizeof (DESTRUCTOR_DECL_FORMAT) - + IDENTIFIER_LENGTH (cname) + 2); - sprintf (name, DESTRUCTOR_DECL_FORMAT, IDENTIFIER_POINTER (cname)); - DECL_NAME (function) = get_identifier (name); - DECL_ASSEMBLER_NAME (function) = IDENTIFIER_POINTER (DECL_NAME (function)); - parm = build_decl (PARM_DECL, in_charge_identifier, const_integer_type); - TREE_USED (parm) = 1; - TREE_READONLY (parm) = 1; - DECL_ARG_TYPE (parm) = const_integer_type; - /* This is the same chain as DECL_ARGUMENTS (fndecl). */ - TREE_CHAIN (last_function_parms) = parm; - - TREE_TYPE (function) = build_cplus_method_type (ctype, void_type_node, arg_types); - TYPE_HAS_DESTRUCTOR (ctype) = 1; - } - else if (flags == WRAPPER_FLAG || flags == ANTI_WRAPPER_FLAG) - { - name = (char *)alloca (sizeof (WRAPPER_DECL_FORMAT) - + sizeof (ANTI_WRAPPER_DECL_FORMAT) - + IDENTIFIER_LENGTH (cname) + 2); - sprintf (name, - flags == WRAPPER_FLAG ? WRAPPER_DECL_FORMAT : ANTI_WRAPPER_DECL_FORMAT, - IDENTIFIER_POINTER (cname)); - DECL_NAME (function) = build_decl_overload (name, arg_types, 1); - DECL_ASSEMBLER_NAME (function) = IDENTIFIER_POINTER (DECL_NAME (function)); - sprintf (name, flags == WRAPPER_FLAG ? WRAPPER_NAME_FORMAT : ANTI_WRAPPER_NAME_FORMAT, - IDENTIFIER_POINTER (cname)); - DECL_ORIGINAL_NAME (function) = fn_name = get_identifier (name); - } - else if (flags == WRAPPER_PRED_FLAG) - { - name = (char *)alloca (sizeof (WRAPPER_PRED_DECL_FORMAT) - + sizeof (WRAPPER_PRED_NAME_FORMAT) - + IDENTIFIER_LENGTH (cname) + 2); - sprintf (name, WRAPPER_PRED_DECL_FORMAT, IDENTIFIER_POINTER (cname)); - DECL_NAME (function) = build_decl_overload (name, arg_types, 1); - DECL_ASSEMBLER_NAME (function) = IDENTIFIER_POINTER (DECL_NAME (function)); - sprintf (name, WRAPPER_PRED_NAME_FORMAT, IDENTIFIER_POINTER (cname)); - DECL_ORIGINAL_NAME (function) = fn_name = get_identifier (name); - } - else - { - tree these_arg_types; - - if (TYPE_DYNAMIC (ctype) && DECL_CONSTRUCTOR_P (function)) - { - arg_types = hash_tree_chain (build_pointer_type (ptr_type_node), - TREE_CHAIN (arg_types)); - TREE_TYPE (function) - = build_cplus_method_type (ctype, TREE_TYPE (TREE_TYPE (function)), arg_types); - arg_types = TYPE_ARG_TYPES (TREE_TYPE (function)); - } - - if (DECL_CONSTRUCTOR_FOR_VBASE_P (function)) - { - arg_types = hash_tree_chain (integer_type_node, TREE_CHAIN (arg_types)); - TREE_TYPE (function) - = build_cplus_method_type (ctype, TREE_TYPE (TREE_TYPE (function)), arg_types); - arg_types = TYPE_ARG_TYPES (TREE_TYPE (function)); - } - - these_arg_types = arg_types; - - if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE) - /* Only true for static member functions. */ - these_arg_types = hash_tree_chain (TYPE_POINTER_TO (ctype), arg_types); - - DECL_NAME (function) = build_decl_overload (IDENTIFIER_POINTER (fn_name), - these_arg_types, - 1 + DECL_CONSTRUCTOR_P (function)); - DECL_ASSEMBLER_NAME (function) = IDENTIFIER_POINTER (DECL_NAME (function)); - if (flags == TYPENAME_FLAG) - TREE_TYPE (DECL_NAME (function)) = TREE_TYPE (fn_name); - } - - DECL_ARGUMENTS (function) = last_function_parms; - - /* now, the sanity check: report error if this function is not - really a member of the class it is supposed to belong to. */ - if (complain) - { - tree field; - int need_quotes = 0; - char *err_name; - tree method_vec = CLASSTYPE_METHOD_VEC (ctype); - tree *methods = 0; - tree *end = 0; - - if (method_vec != 0) - { - methods = &TREE_VEC_ELT (method_vec, 0); - end = TREE_VEC_END (method_vec); - - if (*methods == 0) - methods++; - - while (methods != end) - { - if (fn_name == DECL_ORIGINAL_NAME (*methods)) - { - field = *methods; - while (field) - { - if (DECL_NAME (function) == DECL_NAME (field)) - return; - field = TREE_CHAIN (field); - } - break; /* loser */ - } - methods++; - } - } - - if (OPERATOR_NAME_P (fn_name)) - { - err_name = (char *)alloca (1024); - sprintf (err_name, "`operator %s'", operator_name_string (fn_name)); - } - else if (OPERATOR_TYPENAME_P (fn_name)) - if (complain && TYPE_HAS_CONVERSION (ctype)) - err_name = "such type conversion operator"; - else - err_name = "type conversion operator"; - else if (flags == WRAPPER_FLAG) - err_name = "wrapper"; - else if (flags == WRAPPER_PRED_FLAG) - err_name = "wrapper predicate"; - else - { - err_name = IDENTIFIER_POINTER (fn_name); - need_quotes = 1; - } - - if (methods != end) - if (need_quotes) - error ("argument list for `%s' does not match any in class", err_name); - else - error ("argument list for %s does not match any in class", err_name); - else - { - methods = 0; - if (need_quotes) - error ("no `%s' member function declared in class", err_name); - else - error ("no %s declared in class", err_name); - } - - /* If we did not find the method in the class, add it to - avoid spurious errors. */ - add_method (ctype, methods, function); - } -} - -/* Process the specs, declarator (NULL if omitted) and width (NULL if omitted) - of a structure component, returning a FIELD_DECL node. - QUALS is a list of type qualifiers for this decl (such as for declaring - const member functions). - - This is done during the parsing of the struct declaration. - The FIELD_DECL nodes are chained together and the lot of them - are ultimately passed to `build_struct' to make the RECORD_TYPE node. - - C++: - - If class A defines that certain functions in class B are friends, then - the way I have set things up, it is B who is interested in permission - granted by A. However, it is in A's context that these declarations - are parsed. By returning a void_type_node, class A does not attempt - to incorporate the declarations of the friends within its structure. - - DO NOT MAKE ANY CHANGES TO THIS CODE WITHOUT MAKING CORRESPONDING - CHANGES TO CODE IN `start_method'. */ - -tree -grokfield (declarator, declspecs, raises, init, asmspec_tree) - tree declarator, declspecs, raises, init; - tree asmspec_tree; -{ - register tree value = grokdeclarator (declarator, declspecs, FIELD, init != 0, raises); - char *asmspec = 0; - - if (! value) return NULL_TREE; /* friends went bad. */ - - /* Pass friendly classes back. */ - if (TREE_CODE (value) == VOID_TYPE) - return void_type_node; - - if (DECL_NAME (value) != NULL_TREE - && IDENTIFIER_POINTER (DECL_NAME (value))[0] == '_' - && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (value)), "_vptr")) - error_with_decl (value, "member `%s' conflicts with virtual function table field name"); - - /* Stash away type declarations. */ - if (TREE_CODE (value) == TYPE_DECL) - { - TREE_NONLOCAL (value) = 1; - CLASSTYPE_LOCAL_TYPEDECLS (current_class_type) = 1; - pushdecl_class_level (value); - return value; - } - - if (DECL_IN_AGGR_P (value)) - { - error_with_decl (value, "`%s' is already defined in aggregate scope"); - return void_type_node; - } - - if (flag_cadillac) - cadillac_start_decl (value); - - if (asmspec_tree) - asmspec = TREE_STRING_POINTER (asmspec_tree); - - if (init != 0) - { - if (TREE_CODE (value) == FUNCTION_DECL) - { - grok_function_init (value, init); - init = NULL_TREE; - } - else if (pedantic - && ! TREE_STATIC (value) - && ! TREE_READONLY (value)) - { - error ("fields cannot have initializers"); - init = error_mark_node; - } - else - { - /* We allow initializers to become parameters to base initializers. */ - if (TREE_CODE (init) == CONST_DECL) - init = DECL_INITIAL (init); - else if (TREE_READONLY_DECL_P (init)) - init = decl_constant_value (init); - else if (TREE_CODE (init) == CONSTRUCTOR) - init = digest_init (TREE_TYPE (value), init, 0); - assert (TREE_PERMANENT (init)); - if (init == error_mark_node) - /* We must make this look different than `error_mark_node' - because `decl_const_value' would mis-interpret it - as only meaning that this VAR_DECL is defined. */ - init = build1 (NOP_EXPR, TREE_TYPE (value), init); - else if (! TREE_LITERAL (init)) - { - /* We can allow references to things that are effectively - static, since references are initialized with the address. */ - if (TREE_CODE (TREE_TYPE (value)) != REFERENCE_TYPE - || (TREE_EXTERNAL (init) == 0 - && TREE_STATIC (init) == 0)) - { - error ("field initializer is not constant"); - init = error_mark_node; - } - } - } - } - - if (TREE_CODE (value) == VAR_DECL) - { - /* We cannot call pushdecl here, because that would - fill in the value of our TREE_CHAIN. Instead, we - modify finish_decl to do the right thing, namely, to - put this decl out straight away. */ - if (TREE_STATIC (value)) - { - if (asmspec == 0) - { - char *buf - = (char *)alloca (IDENTIFIER_LENGTH (current_class_name) - + IDENTIFIER_LENGTH (DECL_NAME (value)) - + sizeof (STATIC_NAME_FORMAT)); - tree name; - - sprintf (buf, STATIC_NAME_FORMAT, - IDENTIFIER_POINTER (current_class_name), - IDENTIFIER_POINTER (DECL_NAME (value))); - name = get_identifier (buf); - TREE_PUBLIC (value) = 1; - DECL_INITIAL (value) = error_mark_node; - asmspec = IDENTIFIER_POINTER (name); - DECL_ASSEMBLER_NAME (value) = asmspec; - asmspec_tree = build_string (IDENTIFIER_LENGTH (name), asmspec); - } - pending_statics = perm_tree_cons (NULL_TREE, value, pending_statics); - - /* Static consts need not be initialized in the class definition. */ - if (init != NULL_TREE && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (value))) - { - static int explanation = 0; - - error ("initializer invalid for static member with constructor"); - if (explanation++ == 0) - error ("(you really want to initialize it separately)"); - init = 0; - } - /* Force the user to know when an uninitialized static - member is being used. */ - if (TREE_READONLY (value) - && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (value))) - TREE_EXTERNAL (value) = 1; - } - DECL_INITIAL (value) = init; - DECL_IN_AGGR_P (value) = 1; - finish_decl (value, init, asmspec_tree); - pushdecl_class_level (value); - return value; - } - if (TREE_CODE (value) == FIELD_DECL) - { - DECL_ASSEMBLER_NAME (value) = asmspec; - if (DECL_INITIAL (value) == error_mark_node) - init = error_mark_node; - finish_decl (value, init, asmspec_tree); - DECL_INITIAL (value) = init; - DECL_IN_AGGR_P (value) = 1; - return value; - } - if (TREE_CODE (value) == FUNCTION_DECL) - { - /* grokdeclarator defers setting this. */ - TREE_PUBLIC (value) = 1; - if (TREE_CHAIN (value) != NULL_TREE) - { - /* Need a fresh node here so that we don't get circularity - when we link these together. */ - value = copy_node (value); - /* When does this happen? */ - assert (init == NULL_TREE); - } - finish_decl (value, init, asmspec_tree); - - /* Pass friends back this way. */ - if (DECL_FRIEND_P (value)) - return void_type_node; - - DECL_IN_AGGR_P (value) = 1; - return value; - } - abort (); -} - -/* Like `grokfield', but for bitfields. - WIDTH is non-NULL for bit fields only, and is an INTEGER_CST node. */ - -tree -grokbitfield (declarator, declspecs, width) - tree declarator, declspecs, width; -{ - register tree value = grokdeclarator (declarator, declspecs, FIELD, 0, NULL_TREE, NULL_TREE); - - if (! value) return NULL_TREE; /* friends went bad. */ - - /* Pass friendly classes back. */ - if (TREE_CODE (value) == VOID_TYPE) - return void_type_node; - - if (TREE_CODE (value) == TYPE_DECL) - { - error_with_decl (value, "cannot declare `%s' to be a bitfield type"); - return NULL_TREE; - } - - if (DECL_IN_AGGR_P (value)) - { - error_with_decl (value, "`%s' is already defined in aggregate scope"); - return void_type_node; - } - -#ifdef FIELD_XREF - FIELD_xref_member(current_class_name,value); -#endif - - if (TREE_STATIC (value)) - { - error_with_decl (value, "static member `%s' cannot be a bitfield"); - return NULL_TREE; - } - if (TREE_CODE (value) == FIELD_DECL) - { - finish_decl (value, NULL_TREE, NULL_TREE); - /* detect invalid field size. */ - if (TREE_CODE (width) == CONST_DECL) - width = DECL_INITIAL (width); - else if (TREE_READONLY_DECL_P (width)) - width = decl_constant_value (width); - - if (TREE_CODE (width) != INTEGER_CST) - { - error_with_decl (value, "structure field `%s' width not an integer constant"); - DECL_INITIAL (value) = NULL; - } - else - { - DECL_INITIAL (value) = width; - TREE_PACKED (value) = 1; - } - DECL_IN_AGGR_P (value) = 1; - return value; - } - abort (); -} - -/* Like GROKFIELD, except that the declarator has been - buried in DECLSPECS. Find the declarator, and - return something that looks like it came from - GROKFIELD. */ -tree -groktypefield (declspecs, parmlist) - tree declspecs; - tree parmlist; -{ - tree spec = declspecs; - tree prev = NULL_TREE; - - tree type_id = NULL_TREE; - tree quals = NULL_TREE; - tree lengths = NULL_TREE; - tree decl = NULL_TREE; - - while (spec) - { - register tree id = TREE_VALUE (spec); - - if (TREE_CODE (spec) != TREE_LIST) - /* Certain parse errors slip through. For example, - `int class ();' is not caught by the parser. Try - weakly to recover here. */ - return NULL_TREE; - - if (TREE_CODE (id) == TYPE_DECL - || (TREE_CODE (id) == IDENTIFIER_NODE && TREE_TYPE (id))) - { - /* We have a constructor/destructor or - conversion operator. Use it. */ - if (prev) - TREE_CHAIN (prev) = TREE_CHAIN (spec); - else - { - declspecs = TREE_CHAIN (spec); - } - type_id = id; - goto found; - } - prev = spec; - spec = TREE_CHAIN (spec); - } - - /* Nope, we have a conversion operator to a scalar type. */ - spec = declspecs; - while (spec) - { - tree id = TREE_VALUE (spec); - - if (TREE_CODE (id) == IDENTIFIER_NODE) - { - if (id == ridpointers[(int)RID_INT] - || id == ridpointers[(int)RID_DOUBLE] - || id == ridpointers[(int)RID_FLOAT]) - { - if (type_id) - error ("extra `%s' ignored", - IDENTIFIER_POINTER (id)); - else - type_id = id; - } - else if (id == ridpointers[(int)RID_LONG] - || id == ridpointers[(int)RID_SHORT] - || id == ridpointers[(int)RID_CHAR]) - { - lengths = tree_cons (NULL_TREE, id, lengths); - } - else if (id == ridpointers[(int)RID_VOID]) - { - if (type_id) - error ("spurious `void' type ignored"); - else - error ("conversion to `void' type invalid"); - } - else if (id == ridpointers[(int)RID_AUTO] - || id == ridpointers[(int)RID_REGISTER] - || id == ridpointers[(int)RID_TYPEDEF] - || id == ridpointers[(int)RID_CONST] - || id == ridpointers[(int)RID_VOLATILE]) - { - error ("type specifier `%s' used invalidly", - IDENTIFIER_POINTER (id)); - } - else if (id == ridpointers[(int)RID_FRIEND] - || id == ridpointers[(int)RID_VIRTUAL] - || id == ridpointers[(int)RID_INLINE] - || id == ridpointers[(int)RID_UNSIGNED] - || id == ridpointers[(int)RID_SIGNED] - || id == ridpointers[(int)RID_STATIC] - || id == ridpointers[(int)RID_EXTERN]) - { - quals = tree_cons (NULL_TREE, id, quals); - } - else - { - /* Happens when we have a global typedef - and a class-local member function with - the same name. */ - type_id = id; - goto found; - } - } - else if (TREE_CODE (id) == RECORD_TYPE) - { - type_id = TYPE_NAME (id); - if (TREE_CODE (type_id) == TYPE_DECL) - type_id = DECL_NAME (type_id); - if (type_id == NULL_TREE) - error ("identifier for aggregate type conversion omitted"); - } - else - assert (0); - spec = TREE_CHAIN (spec); - } - - if (type_id) - { - declspecs = chainon (lengths, quals); - } - else if (lengths) - { - if (TREE_CHAIN (lengths)) - error ("multiple length specifiers"); - type_id = ridpointers[(int)RID_INT]; - declspecs = chainon (lengths, quals); - } - else if (quals) - { - error ("no type given, defaulting to `operator int ...'"); - type_id = ridpointers[(int)RID_INT]; - declspecs = quals; - } - else return NULL_TREE; - found: - decl = grokdeclarator (build_parse_node (CALL_EXPR, type_id, parmlist, NULL_TREE), - declspecs, FIELD, 0, NULL_TREE); - if (decl == NULL_TREE) - return NULL_TREE; - - if (TREE_CODE (decl) == FUNCTION_DECL && TREE_CHAIN (decl) != NULL_TREE) - { - /* Need a fresh node here so that we don't get circularity - when we link these together. */ - decl = copy_node (decl); - } - - if (decl == void_type_node - || (TREE_CODE (decl) == FUNCTION_DECL - && TREE_CODE (TREE_TYPE (decl)) != METHOD_TYPE)) - /* bunch of friends. */ - return decl; - - if (DECL_IN_AGGR_P (decl)) - { - error_with_decl (decl, "`%s' already defined in aggregate scope"); - return void_type_node; - } - - finish_decl (decl, NULL_TREE, NULL_TREE); - - /* If this declaration is common to another declaration - complain about such redundancy, and return NULL_TREE - so that we don't build a circular list. */ - if (TREE_CHAIN (decl)) - { - error_with_decl (decl, "function `%s' declared twice in aggregate"); - return NULL_TREE; - } - DECL_IN_AGGR_P (decl) = 1; - return decl; -} - -/* The precedence rules of this grammar (or any other deterministic LALR - grammar, for that matter), place the CALL_EXPR somewhere where we - may not want it. The solution is to grab the first CALL_EXPR we see, - pretend that that is the one that belongs to the parameter list of - the type conversion function, and leave everything else alone. - We pull it out in place. - - CALL_REQUIRED is non-zero if we should complain if a CALL_EXPR - does not appear in DECL. */ -tree -grokoptypename (decl, call_required) - tree decl; - int call_required; -{ - tree tmp, last; - - assert (TREE_CODE (decl) == TYPE_EXPR); - - tmp = TREE_OPERAND (decl, 0); - last = NULL_TREE; - - while (tmp) - { - switch (TREE_CODE (tmp)) - { - case CALL_EXPR: - { - tree parms = TREE_OPERAND (tmp, 1); - - if (last) - TREE_OPERAND (last, 0) = TREE_OPERAND (tmp, 0); - else - TREE_OPERAND (decl, 0) = TREE_OPERAND (tmp, 0); - if (parms - && TREE_CODE (TREE_VALUE (parms)) == TREE_LIST) - TREE_VALUE (parms) - = grokdeclarator (TREE_VALUE (TREE_VALUE (parms)), - TREE_PURPOSE (TREE_VALUE (parms)), - TYPENAME, 0, NULL_TREE); - if (parms) - { - if (TREE_VALUE (parms) != void_type_node) - error ("operator requires empty parameter list"); - else - /* Canonicalize parameter lists. */ - TREE_OPERAND (tmp, 1) = void_list_node; - } - - last = grokdeclarator (TREE_OPERAND (decl, 0), - TREE_TYPE (decl), - TYPENAME, 0, NULL_TREE); - TREE_OPERAND (tmp, 0) = build_typename_overload (last); - TREE_TYPE (TREE_OPERAND (tmp, 0)) = last; - return tmp; - } - - case INDIRECT_REF: - case ADDR_EXPR: - case ARRAY_REF: - break; - - case SCOPE_REF: - /* This is legal when declaring a conversion to - something of type pointer-to-member. */ - if (TREE_CODE (TREE_OPERAND (tmp, 1)) == INDIRECT_REF) - { - tmp = TREE_OPERAND (tmp, 1); - } - else - { -#if 0 - /* We may need to do this if grokdeclarator cannot handle this. */ - error ("type `member of class %s' invalid return type", - TYPE_NAME_STRING (TREE_OPERAND (tmp, 0))); - TREE_OPERAND (tmp, 1) = build_parse_node (INDIRECT_REF, TREE_OPERAND (tmp, 1)); -#endif - tmp = TREE_OPERAND (tmp, 1); - } - break; - - default: - assert (0); - } - last = tmp; - tmp = TREE_OPERAND (tmp, 0); - } - - if (call_required) - error ("operator construct requires parameter list"); - - last = grokdeclarator (TREE_OPERAND (decl, 0), - TREE_TYPE (decl), - TYPENAME, 0, NULL_TREE); - tmp = build_parse_node (CALL_EXPR, build_typename_overload (last), - void_list_node, NULL_TREE); - TREE_TYPE (TREE_OPERAND (tmp, 0)) = last; - return tmp; -} - -/* Given an encoding for an operator name (see parse.y, the rules - for making an `operator_name' in the variable DECLARATOR, - return the name of the operator prefix as an IDENTIFIER_NODE. - - CTYPE is the class type to which this operator belongs. - Needed in case it is a static member function. - - TYPE, if nonnull, is the function type for this declarator. - This information helps to resolve potential ambiguities. - - If REPORT_AMBIGUOUS is non-zero, an error message - is reported, and a default arity of the operator is - returned. Otherwise, return the operator under an OP_EXPR, - for later evaluation when type information will enable - proper instantiation. - - IS_DECL is 1 if this is a decl (as opposed to an expression). - IS_DECL is 2 if this is a static function decl. - Otherwise IS_DECL is 0. */ -tree -grokopexpr (declp, ctype, type, report_ambiguous, is_decl) - tree *declp; - tree ctype, type; - int report_ambiguous; -{ - tree declarator = *declp; - tree name, parmtypes; - int seen_classtype_parm - = (type != NULL_TREE && TREE_CODE (type) == METHOD_TYPE) - || is_decl == 2; - - if (type != NULL_TREE) - { - if (ctype == 0 && TREE_CODE (TREE_OPERAND (declarator, 0)) == NEW_EXPR) - { - if (TYPE_ARG_TYPES (type) - && TREE_CHAIN (TYPE_ARG_TYPES (type)) - && TREE_CHAIN (TYPE_ARG_TYPES (type)) != void_list_node) - return get_identifier (OPERATOR_NEW_FORMAT); - return get_identifier ("__builtin_new"); - } - else if (ctype == 0 && TREE_CODE (TREE_OPERAND (declarator, 0)) == DELETE_EXPR) - return get_identifier ("__builtin_delete"); - else - { - /* Now we know the number of parameters, - so build the real operator fnname. */ - parmtypes = TYPE_ARG_TYPES (type); - if (is_decl > 1 && TREE_CODE (type) == METHOD_TYPE) - parmtypes = TREE_CHAIN (parmtypes); - name = build_operator_fnname (declp, parmtypes, is_decl > 1); - declarator = *declp; - } - } - else - { - if (TREE_PURPOSE (declarator) == NULL_TREE) - switch (TREE_CODE (TREE_VALUE (declarator))) - { - case PLUS_EXPR: - case CONVERT_EXPR: - case ADDR_EXPR: - case BIT_AND_EXPR: - case INDIRECT_REF: - case MULT_EXPR: - case NEGATE_EXPR: - case MINUS_EXPR: - if (report_ambiguous) - { - error ("operator '%s' ambiguous, (default binary)", - opname_tab[(int)TREE_CODE (TREE_VALUE (declarator))]); - name = build_operator_fnname (declp, NULL_TREE, 2); - declarator = *declp; - } - else - { - /* do something intellegent. */ - TREE_TYPE (declarator) = unknown_type_node; - return declarator; - } - break; - default: - name = build_operator_fnname (declp, NULL_TREE, -1); - declarator = *declp; - break; - } - else if (TREE_CODE (TREE_PURPOSE (declarator)) == MODIFY_EXPR) - { - name = build_operator_fnname (declp, NULL_TREE, -1); - declarator = *declp; - } - else abort (); - } - /* Now warn if the parameter list does not contain any args - which are of aggregate type. */ - if (is_decl && type != NULL_TREE && ! seen_classtype_parm) - for (parmtypes = TYPE_ARG_TYPES (type); - parmtypes; - parmtypes = TREE_CHAIN (parmtypes)) - if (IS_AGGR_TYPE (TREE_VALUE (parmtypes)) - || (TREE_CODE (TREE_VALUE (parmtypes)) == REFERENCE_TYPE - && IS_AGGR_TYPE (TREE_TYPE (TREE_VALUE (parmtypes))))) - { - seen_classtype_parm = 1; - break; - } - - if (is_decl && seen_classtype_parm == 0) - if (TREE_CODE (declarator) == OP_IDENTIFIER - && (TREE_CODE (TREE_OPERAND (declarator, 0)) == NEW_EXPR - || TREE_CODE (TREE_OPERAND (declarator, 0)) == DELETE_EXPR)) - /* Global operators new and delete are not overloaded. */ - TREE_OVERLOADED (name) = 0; - else - error ("operator has no %suser-defined argument type", - type == NULL_TREE ? "(default) " : ""); - - return name; -} - -/* When a function is declared with an initialializer, - do the right thing. Currently, there are two possibilities: - - class B - { - public: - // initialization possibility #1. - virtual void f () = 0; - int g (); - }; - - class D1 : B - { - public: - int d1; - // error, no f (); - }; - - class D2 : B - { - public: - int d2; - void f (); - }; - - class D3 : B - { - public: - int d3; - // initialization possibility #2 - void f () = B::f; - }; - -*/ - -static void -grok_function_init (decl, init) - tree decl; - tree init; -{ - /* An initializer for a function tells how this function should - be inherited. */ - tree type = TREE_TYPE (decl); - extern tree abort_fndecl; - - if (TREE_CODE (type) == FUNCTION_TYPE) - error_with_decl (decl, "initializer specified for non-member function `%s'"); - else if (! DECL_VIRTUAL_P (decl)) - error_with_decl (decl, "initializer specified for non-virtual method `%s'"); - else if (integer_zerop (init)) - { - /* Mark this function as being "defined". */ - DECL_INITIAL (decl) = error_mark_node; - /* Give this node rtl from `abort'. */ - DECL_RTL (decl) = DECL_RTL (abort_fndecl); - DECL_ABSTRACT_VIRTUAL_P (decl) = 1; - } - else if (TREE_CODE (init) == OFFSET_REF - && TREE_OPERAND (init, 0) == NULL_TREE - && TREE_CODE (TREE_TYPE (init)) == METHOD_TYPE) - { - tree basetype = TYPE_METHOD_BASETYPE (TREE_TYPE (init)); - tree basefn = TREE_OPERAND (init, 1); - if (TREE_CODE (basefn) != FUNCTION_DECL) - error_with_decl (decl, "non-method initializer invalid for method `%s'"); - else if (DECL_OFFSET (TYPE_NAME (basefn)) != 0) - sorry ("base member function from other than first base class"); - else - { - basetype = get_base_type (basetype, TYPE_METHOD_BASETYPE (type), 1); - if (basetype == error_mark_node) - ; - else if (basetype == 0) - error_not_base_type (TYPE_METHOD_BASETYPE (TREE_TYPE (init)), - TYPE_METHOD_BASETYPE (type)); - else - { - /* Mark this function as being defined, - and give it new rtl. */ - DECL_INITIAL (decl) = error_mark_node; - DECL_RTL (decl) = DECL_RTL (basefn); - } - } - } - else - error_with_decl (decl, "invalid initializer for virtual method `%s'"); -} - -/* Cache the value of this class's main virtual function table pointer - in a register variable. This will save one indirection if a - more than one virtual function call is made this function. */ -void -setup_vtbl_ptr () -{ - extern struct rtx_def *base_init_insns; - - if (base_init_insns == 0 - && DECL_CONSTRUCTOR_P (current_function_decl)) - emit_base_init (current_class_type, 0); - - if ((flag_this_is_variable & 1) == 0 - && optimize - && current_class_type - && CLASSTYPE_VSIZE (current_class_type) - && ! DECL_STATIC_FUNCTION_P (current_function_decl)) - { - tree vfield = build_vfield_ref (C_C_D, current_class_type); - current_vtable_decl = CLASSTYPE_VTBL_PTR (current_class_type); - DECL_RTL (current_vtable_decl) = 0; - DECL_INITIAL (current_vtable_decl) = error_mark_node; - /* Have to cast the initializer, since it may have come from a - more base class then we ascribe CURRENT_VTABLE_DECL to be. */ - finish_decl (current_vtable_decl, convert_force (TREE_TYPE (current_vtable_decl), vfield), 0); - current_vtable_decl = build_indirect_ref (current_vtable_decl, 0); - } - else - current_vtable_decl = NULL_TREE; -} - -/* Record the existence of an addressable inline function. */ -void -mark_inline_for_output (decl) - tree decl; -{ - pending_addressable_inlines = perm_tree_cons (NULL_TREE, decl, - pending_addressable_inlines); -} - -void -clear_temp_name () -{ - temp_name_counter = 0; -} - -/* Hand off a unique name which can be used for variable we don't really - want to know about anyway, for example, the anonymous variables which - are needed to make references work. Declare this thing so we can use it. - The variable created will be of type TYPE. - - STATICP is nonzero if this variable should be static. */ - -tree -get_temp_name (type, staticp) - tree type; - int staticp; -{ - char buf[sizeof (AUTO_TEMP_FORMAT) + 12]; - tree decl; - int temp = 0; - int toplev = global_bindings_p (); - if (toplev || staticp) - { - temp = allocation_temporary_p (); - if (temp) - end_temporary_allocation (); - sprintf (buf, AUTO_TEMP_FORMAT, global_temp_name_counter++); - decl = pushdecl_top_level (build_decl (VAR_DECL, get_identifier (buf), type)); - } - else - { - sprintf (buf, AUTO_TEMP_FORMAT, temp_name_counter++); - decl = pushdecl (build_decl (VAR_DECL, get_identifier (buf), type)); - } - TREE_USED (decl) = 1; - TREE_STATIC (decl) = staticp; - - /* If this is a local variable, then lay out its rtl now. - Otherwise, callers of this function are responsible for dealing - with this variable's rtl. */ - if (! toplev) - { - expand_decl (decl); - expand_decl_init (decl); - } - else if (temp) - resume_temporary_allocation (); - - return decl; -} - -/* Get a variable which we can use for multiple assignments. - It is not entered into current_binding_level, because - that breaks things when it comes time to do final cleanups - (which take place "outside" the binding contour of the function). - - Because it is not entered into the binding contour, `expand_end_bindings' - does not see this variable automatically. Users of this function - must either pass this variable to expand_end_bindings or do - themselves what expand_end_bindings was meant to do (like keeping - the variable live if -noreg was specified). */ -tree -get_temp_regvar (type, init) - tree type, init; -{ - static char buf[sizeof (AUTO_TEMP_FORMAT) + 8] = { '_' }; - tree decl; - - sprintf (buf+1, AUTO_TEMP_FORMAT, temp_name_counter++); - decl = pushdecl (build_decl (VAR_DECL, get_identifier (buf), type)); - TREE_USED (decl) = 1; - TREE_REGDECL (decl) = 1; - - if (init) - store_init_value (decl, init); - - /* We can expand these without fear, since they cannot need - constructors or destructors. */ - expand_decl (decl); - expand_decl_init (decl); - return decl; -} - -/* Make the macro TEMP_NAME_P available to units which do not - include c-tree.h. */ -int -temp_name_p (decl) - tree decl; -{ - return TEMP_NAME_P (decl); -} - -/* Finish off the processing of a UNION_TYPE structure. - If there are static members, then all members are - static, and must be laid out together. If the - union is an anonymous union, we arrage for that - as well. PUBLICP is nonzero if this union is - not declared static. */ -void -finish_anon_union (anon_union_decl) - tree anon_union_decl; -{ - tree type = TREE_TYPE (anon_union_decl); - tree field, decl; - tree elems = NULL_TREE; - int public_p = TREE_PUBLIC (anon_union_decl); - int static_p = TREE_STATIC (anon_union_decl); - int external_p = TREE_EXTERNAL (anon_union_decl); - - if ((field = TYPE_FIELDS (type)) == NULL_TREE) - return; - - if (public_p && (static_p || external_p)) - error ("optimizer cannot handle global anonymous unions"); - - while (field) - { - decl = build_decl (VAR_DECL, DECL_NAME (field), TREE_TYPE (field)); - /* tell `pushdecl' that this is not tentative. */ - DECL_INITIAL (decl) = error_mark_node; - TREE_PUBLIC (decl) = public_p; - TREE_STATIC (decl) = static_p; - TREE_EXTERNAL (decl) = external_p; - decl = pushdecl (decl); - DECL_INITIAL (decl) = NULL_TREE; - elems = tree_cons (DECL_ASSEMBLER_NAME (field), decl, elems); - TREE_TYPE (elems) = type; - field = TREE_CHAIN (field); - } - if (static_p) - make_decl_rtl (decl, 0, global_bindings_p ()); - expand_anon_union_decl (decl, NULL_TREE, elems); - - if (flag_cadillac) - cadillac_finish_anon_union (decl); -} - -/* Finish and output a table which is generated by the compiler. - NAME is the name to give the table. - TYPE is the type of the table entry. - INIT is all the elements in the table. - PUBLICP is non-zero if this table should be given external visibility. */ -tree -finish_table (name, type, init, publicp) - tree name, type, init; -{ - tree itype, atype, decl; - - itype = build_index_type (build_int_2 (list_length (init), 0)); - atype = build_cplus_array_type (type, itype); - layout_type (atype); - decl = build_decl (VAR_DECL, name, atype); - decl = pushdecl (decl); - TREE_STATIC (decl) = 1; - TREE_PUBLIC (decl) = publicp; - init = build (CONSTRUCTOR, atype, NULL_TREE, init); - TREE_LITERAL (init) = 1; - TREE_STATIC (init) = 1; - DECL_INITIAL (decl) = init; - finish_decl (decl, init, - build_string (IDENTIFIER_LENGTH (DECL_NAME (decl)), - IDENTIFIER_POINTER (DECL_NAME (decl)))); - return decl; -} - -/* Auxilliary functions to make type signatures for - `operator new' and `operator delete' correspond to - what compiler will be expecting. */ - -extern tree sizetype; - -tree -coerce_new_type (ctype, type) - tree ctype; - tree type; -{ - int e1 = 0, e2 = 0; - - if (TREE_CODE (type) == METHOD_TYPE) - type = build_function_type (TREE_TYPE (type), TREE_CHAIN (TYPE_ARG_TYPES (type))); - if (TREE_TYPE (type) != ptr_type_node) - e1 = 1, error ("`operator new' must return type `void *'"); - - /* Technically the type must be `size_t', but we may not know - what that is. */ - if (TYPE_ARG_TYPES (type) == NULL_TREE) - e1 = 1, error ("`operator new' takes type `size_t' parameter"); - else if (TREE_CODE (TREE_VALUE (TYPE_ARG_TYPES (type))) != INTEGER_TYPE - || TYPE_PRECISION (TREE_VALUE (TYPE_ARG_TYPES (type))) != TYPE_PRECISION (sizetype)) - e2 = 1, error ("`operator new' takes type `size_t' as first parameter"); - if (e2) - type = build_function_type (ptr_type_node, tree_cons (NULL_TREE, sizetype, TREE_CHAIN (TYPE_ARG_TYPES (type)))); - else if (e1) - type = build_function_type (ptr_type_node, TYPE_ARG_TYPES (type)); - return type; -} - -tree -coerce_delete_type (ctype, type) - tree ctype; - tree type; -{ - int e1 = 0, e2 = 0, e3 = 0; - tree arg_types = TYPE_ARG_TYPES (type); - - if (TREE_CODE (type) == METHOD_TYPE) - { - type = build_function_type (TREE_TYPE (type), TREE_CHAIN (arg_types)); - arg_types = TREE_CHAIN (arg_types); - } - if (TREE_TYPE (type) != void_type_node) - e1 = 1, error ("`operator delete' must return type `void'"); - if (arg_types == NULL_TREE - || TREE_VALUE (arg_types) != ptr_type_node) - e2 = 1, error ("`operator delete' takes type `void *' as first parameter"); - - if (arg_types - && TREE_CHAIN (arg_types) - && TREE_CHAIN (arg_types) != void_list_node) - { - /* Again, technically this argument must be `size_t', but again - we may not know what that is. */ - tree t2 = TREE_VALUE (TREE_CHAIN (arg_types)); - if (TREE_CODE (t2) != INTEGER_TYPE - || TYPE_PRECISION (t2) != TYPE_PRECISION (sizetype)) - e3 = 1, error ("second argument to `operator delete' must be of type `size_t'"); - else if (TREE_CHAIN (TREE_CHAIN (arg_types)) != void_list_node) - { - e3 = 1; - if (TREE_CHAIN (TREE_CHAIN (arg_types))) - error ("too many arguments in declaration of `operator delete'"); - else - error ("`...' invalid in specification of `operator delete'"); - } - } - if (e3) - arg_types = tree_cons (NULL_TREE, ptr_type_node, build_tree_list (NULL_TREE, sizetype)); - else if (e3 |= e2) - { - if (arg_types == NULL_TREE) - arg_types = void_list_node; - else - arg_types = tree_cons (NULL_TREE, ptr_type_node, TREE_CHAIN (arg_types)); - } - else e3 |= e1; - - if (e3) - type = build_function_type (void_type_node, arg_types); - - return type; -} - -static void -write_vtable_entries (decl) - tree decl; -{ - tree entries; - - for (entries = TREE_CHAIN (CONSTRUCTOR_ELTS (DECL_INITIAL (decl))); - entries; entries = TREE_CHAIN (entries)) - { - tree fnaddr = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries)); - tree fn = TREE_OPERAND (fnaddr, 0); - if (! TREE_ASM_WRITTEN (fn) - && DECL_SAVED_INSNS (fn)) - { - if (TREE_PUBLIC (DECL_CONTEXT (fn))) - TREE_PUBLIC (fn) = 1; - TREE_ADDRESSABLE (fn) = 1; - output_inline_function (fn); - } - } -} - -static void -finish_vtable_typedecl (prev, vars) - tree prev, vars; -{ - tree decl = CLASS_ASSOC_VTABLE (TREE_TYPE (vars)); - - /* If we are controlled by `+e2', obey. */ - if (write_virtuals == 2) - { - tree assoc = value_member (DECL_NAME (vars), pending_vtables); - if (assoc) - TREE_PURPOSE (assoc) = void_type_node; - else - decl = NULL_TREE; - } - /* If this type has inline virtual functions, then - write those functions out now. */ - if (decl && (TREE_PUBLIC (decl) - || (! TREE_EXTERNAL (decl) && TREE_USED (decl)))) - write_vtable_entries (decl); -} - -static void -finish_vtable_vardecl (prev, vars) - tree prev, vars; -{ - if (write_virtuals < 0) - ; - else if (write_virtuals == 0 - ? TREE_USED (vars) - : (TREE_PUBLIC (vars) - || (! TREE_EXTERNAL (vars) && TREE_USED (vars)))) - { - extern tree the_null_vtable_entry; - - /* Stuff this virtual function table's size into - `pfn' slot of `the_null_vtable_entry'. */ - tree nelts = array_type_nelts (TREE_TYPE (vars)); - tree *ppfn = &FNADDR_FROM_VTABLE_ENTRY (the_null_vtable_entry); - *ppfn = nelts; - assert (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (CONSTRUCTOR_ELTS (TREE_VALUE (CONSTRUCTOR_ELTS (DECL_INITIAL (vars))))))) == nelts); - /* Write it out. */ - write_vtable_entries (vars); - if (TREE_TYPE (DECL_INITIAL (vars)) == 0) - store_init_value (vars, DECL_INITIAL (vars)); - rest_of_decl_compilation (vars, 0, 1, 1); - } - /* We know that PREV must be non-zero here. */ - TREE_CHAIN (prev) = TREE_CHAIN (vars); -} - -void -walk_vtables (typedecl_fn, vardecl_fn) - register void (*typedecl_fn)(); - register void (*vardecl_fn)(); -{ - tree prev, vars; - - for (prev = 0, vars = getdecls (); vars; vars = TREE_CHAIN (vars)) - { - if (TREE_CODE (vars) == TYPE_DECL - && TYPE_LANG_SPECIFIC (TREE_TYPE (vars)) - && CLASSTYPE_VSIZE (TREE_TYPE (vars))) - { - if (typedecl_fn) (*typedecl_fn) (prev, vars); - } - else if (TREE_CODE (vars) == VAR_DECL && DECL_VIRTUAL_P (vars)) - { - if (vardecl_fn) (*vardecl_fn) (prev, vars); - } - else - prev = vars; - } -} - -extern int parse_time, varconst_time; - -#define TIMEVAR(VAR, BODY) \ -do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0) - -/* This routine is called from the last rule in yyparse (). - Its job is to create all the code needed to initialize and - destroy the global aggregates. We do the destruction - first, since that way we only need to reverse the decls once. */ - -void -finish_file () -{ - extern struct rtx_def *const0_rtx; - extern int lineno; - extern struct _iob *asm_out_file; - int start_time, this_time; - char *init_function_name; - - char *buf; - char *p; - tree fnname; - tree vars = static_aggregates; - int needs_cleaning = 0, needs_messing_up = 0; - - if (main_input_filename == 0) - main_input_filename = input_filename; - if (!first_global_object_name) - first_global_object_name = main_input_filename; - - buf = (char *) alloca (sizeof (FILE_FUNCTION_FORMAT) - + strlen (first_global_object_name)); - -#ifndef MERGED - if (flag_detailed_statistics) - dump_tree_statistics (); -#endif - - /* Bad parse errors. Just forget about it. */ - if (! global_bindings_p ()) - return; - -#ifndef MERGED - /* This is the first run of an unexec'd program, so save this till - we come back again. -- bryan@kewill.uucp */ - { - extern int just_done_unexec; - if (just_done_unexec) - return; - } -#endif - - start_time = gettime (); - - /* Push into C language context, because that's all - we'll need here. */ - push_lang_context (lang_name_c); - - /* Set up the name of the file-level functions we may need. */ - /* Use a global object (which is already required to be unique over - the program) rather than the file name (which imposes extra - constraints). -- Raeburn@MIT.EDU, 10 Jan 1990. */ - sprintf (buf, FILE_FUNCTION_FORMAT, first_global_object_name); - - /* Don't need to pull wierd characters out of global names. */ - if (first_global_object_name == main_input_filename) - { - for (p = buf+11; *p; p++) - if (! ((*p >= '0' && *p <= '9') -#ifndef ASM_IDENTIFY_GCC /* this is required if `.' is invalid -- k. raeburn */ - || *p == '.' -#endif -#ifndef NO_DOLLAR_IN_LABEL /* this for `$'; unlikely, but... -- kr */ - || *p == '$' -#endif - || (*p >= 'A' && *p <= 'Z') - || (*p >= 'a' && *p <= 'z'))) - *p = '_'; - } - - /* See if we really need the hassle. */ - while (vars && needs_cleaning == 0) - { - tree decl = TREE_VALUE (vars); - tree type = TREE_TYPE (decl); - if (TYPE_NEEDS_DESTRUCTOR (type)) - { - needs_cleaning = 1; - needs_messing_up = 1; - break; - } - else - needs_messing_up |= TYPE_NEEDS_CONSTRUCTING (type); - vars = TREE_CHAIN (vars); - } - if (needs_cleaning == 0) - goto mess_up; - - /* Otherwise, GDB can get confused, because in only knows - about source for LINENO-1 lines. */ - lineno -= 1; - -#if defined(sun) - /* Point Sun linker at this function. */ - fprintf (asm_out_file, ".stabs \"_fini\",10,0,0,0\n.stabs \""); - assemble_name (asm_out_file, buf); - fprintf (asm_out_file, "\",4,0,0,0\n"); -#endif - - fnname = get_identifier (buf); - start_function (void_list_node, build_parse_node (CALL_EXPR, fnname, void_list_node, NULL_TREE), 0, 0); - DECL_PRINT_NAME (current_function_decl) = "file cleanup"; - fnname = DECL_NAME (current_function_decl); - store_parm_decls (); - - pushlevel (0); - clear_last_expr (); - push_momentary (); - expand_start_bindings (0); - - /* These must be done in backward order to destroy, - in which they happen to be! */ - while (vars) - { - tree decl = TREE_VALUE (vars); - tree type = TREE_TYPE (decl); - tree temp = TREE_PURPOSE (vars); - - if (TYPE_NEEDS_DESTRUCTOR (type)) - { - if (TREE_STATIC (vars)) - expand_start_cond (build_binary_op (NE_EXPR, temp, integer_zero_node), 0); - if (TREE_CODE (type) == ARRAY_TYPE) - temp = decl; - else - { - mark_addressable (decl); - temp = build1 (ADDR_EXPR, TYPE_POINTER_TO (type), decl); - } - temp = build_delete (TREE_TYPE (temp), temp, integer_two_node, LOOKUP_NORMAL, 0); - expand_expr_stmt (temp); - - if (TREE_STATIC (vars)) - expand_end_cond (); - } - vars = TREE_CHAIN (vars); - } - - expand_end_bindings (getdecls (), 1, 0); - poplevel (1, 0, 1); - pop_momentary (); - - finish_function (lineno, 0); - -#if defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER) && !defined(SDB_DEBUGGING_INFO) - /* Now tell GNU LD that this is part of the static destructor set. */ - { - extern struct _iob *asm_out_file; - fprintf (asm_out_file, ".stabs \"___DTOR_LIST__\",22,0,0,"); - assemble_name (asm_out_file, IDENTIFIER_POINTER (fnname)); - fputc ('\n', asm_out_file); - } -#endif - - /* if it needed cleaning, then it will need messing up: drop through */ - - mess_up: - /* Must do this while we think we are at the top level. */ - vars = nreverse (static_aggregates); - if (vars != NULL_TREE) - { - buf[FILE_FUNCTION_PREFIX_LEN] = 'I'; - -#if defined(sun) - /* Point Sun linker at this function. */ - fprintf (asm_out_file, ".stabs \"_init\",10,0,0,0\n.stabs \""); - assemble_name (asm_out_file, buf); - fprintf (asm_out_file, "\",4,0,0,0\n"); -#endif - - fnname = get_identifier (buf); - start_function (void_list_node, build_parse_node (CALL_EXPR, fnname, void_list_node, NULL_TREE), 0, 0); - DECL_PRINT_NAME (current_function_decl) = "file initialization"; - fnname = DECL_NAME (current_function_decl); - store_parm_decls (); - - pushlevel (0); - clear_last_expr (); - push_momentary (); - expand_start_bindings (0); - -#ifdef SOS - if (flag_all_virtual == 2) - { - tree decl; - char c = buf[FILE_FUNCTION_PREFIX_LEN]; - buf[FILE_FUNCTION_PREFIX_LEN] = 'Z'; - - decl = pushdecl (build_lang_decl (FUNCTION_DECL, get_identifier (buf), default_function_type)); - finish_decl (decl, NULL_TREE, NULL_TREE); - expand_expr_stmt (build_function_call (decl, NULL_TREE)); - buf[FILE_FUNCTION_PREFIX_LEN] = c; - } -#endif - - while (vars) - { - tree decl = TREE_VALUE (vars); - tree init = TREE_PURPOSE (vars); - - /* If this was a static attribute within some function's scope, - then don't initialize it here. Also, don't bother - with initializers that contain errors. */ - if (TREE_STATIC (vars) - || (init && TREE_CODE (init) == TREE_LIST - && value_member (error_mark_node, init))) - { - vars = TREE_CHAIN (vars); - continue; - } - - if (TREE_CODE (decl) == VAR_DECL) - { - /* Set these global variables so that GDB at least puts - us near the declaration which required the initialization. */ - input_filename = DECL_SOURCE_FILE (decl); - lineno = DECL_SOURCE_LINE (decl); - emit_note (input_filename, lineno); - - if (init) - { - if (TREE_CODE (init) == VAR_DECL) - { - /* This behavior results when there are - multiple declarations of an aggregate, - the last of which defines it. */ - if (DECL_RTL (init) == DECL_RTL (decl)) - { - assert (DECL_INITIAL (decl) == error_mark_node - || (TREE_CODE (DECL_INITIAL (decl)) == CONSTRUCTOR - && CONSTRUCTOR_ELTS (DECL_INITIAL (decl)) == NULL_TREE)); - init = DECL_INITIAL (init); - if (TREE_CODE (init) == CONSTRUCTOR - && CONSTRUCTOR_ELTS (init) == NULL_TREE) - init = NULL_TREE; - } -#if 0 - else if (TREE_TYPE (decl) == TREE_TYPE (init)) - { -#if 1 - assert (0); -#else - /* point to real decl's rtl anyway. */ - DECL_RTL (init) = DECL_RTL (decl); - assert (DECL_INITIAL (decl) == error_mark_node); - init = DECL_INITIAL (init); -#endif /* 1 */ - } -#endif /* 0 */ - } - } - if (IS_AGGR_TYPE (TREE_TYPE (decl)) - || init == 0 - || TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) - expand_aggr_init (decl, init, 0); - else if (TREE_CODE (init) == TREE_VEC) - expand_expr (expand_vec_init (decl, TREE_VEC_ELT (init, 0), - TREE_VEC_ELT (init, 1), - TREE_VEC_ELT (init, 2), 0), - const0_rtx, VOIDmode, 0); - else - expand_assignment (decl, init, 0, 0); - } - else if (TREE_CODE (decl) == SAVE_EXPR) - { - if (! PARM_DECL_EXPR (decl)) - { - /* a `new' expression at top level. */ - expand_expr (decl, const0_rtx, VOIDmode, 0); - expand_aggr_init (build_indirect_ref (decl, 0), init, 0); - } - } - else if (decl == error_mark_node) - ; - else abort (); - vars = TREE_CHAIN (vars); - } - - expand_end_bindings (getdecls (), 1, 0); - poplevel (1, 0, 1); - pop_momentary (); - - finish_function (lineno, 0); -#if defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER) && !defined(SDB_DEBUGGING_INFO) - /* Now tell GNU LD that this is part of the static constructor set. */ - { - extern struct _iob *asm_out_file; - fprintf (asm_out_file, ".stabs \"___CTOR_LIST__\",22,0,0,"); - assemble_name (asm_out_file, IDENTIFIER_POINTER (fnname)); - fputc ('\n', asm_out_file); - } -#endif - } - -#ifdef SOS - if (flag_all_virtual == 2) - { - tree __sosDynError = default_conversion (lookup_name (get_identifier ("sosDynError"))); - - tree null_string = build1 (ADDR_EXPR, string_type_node, combine_strings (build_string (0, ""))); - tree tags = gettags (); - tree decls = getdecls (); - tree entry; - int i; - - entry = NULL_TREE; - for (i = 0; i < 3; i++) - entry = tree_cons (NULL_TREE, integer_zero_node, entry); - zlink = build_tree_list (NULL_TREE, build (CONSTRUCTOR, zlink_type, NULL_TREE, entry)); - TREE_LITERAL (TREE_VALUE (zlink)) = 1; - TREE_STATIC (TREE_VALUE (zlink)) = 1; - - entry = NULL_TREE; - for (i = 0; i < 5; i++) - entry = tree_cons (NULL_TREE, integer_zero_node, entry); - zret = build_tree_list (NULL_TREE, build (CONSTRUCTOR, zret_type, NULL_TREE, entry)); - TREE_LITERAL (TREE_VALUE (zret)) = 1; - TREE_STATIC (TREE_VALUE (zret)) = 1; - - /* Symbols with external visibility (except globally visible - dynamic member functions) into the `zlink' table. */ - while (decls) - { - if (TREE_PUBLIC (decls) - && TREE_ASM_WRITTEN (decls) - && (TREE_CODE (decls) != FUNCTION_DECL - || TREE_CODE (TREE_TYPE (decls)) != METHOD_TYPE - || TYPE_DYNAMIC (TYPE_METHOD_BASETYPE (TREE_TYPE (decls))) == 0)) - { - entry = build (CONSTRUCTOR, zlink_type, NULL_TREE, - tree_cons (NULL_TREE, - build1 (ADDR_EXPR, string_type_node, - combine_strings (build_string (IDENTIFIER_LENGTH (DECL_NAME (decls)), - IDENTIFIER_POINTER (DECL_NAME (decls))))), - tree_cons (NULL_TREE, integer_one_node, - build_tree_list (NULL_TREE, build_unary_op (ADDR_EXPR, decls, 0))))); - TREE_LITERAL (entry) = 1; - TREE_STATIC (entry) = 1; - zlink = tree_cons (NULL_TREE, entry, zlink); - } - decls = TREE_CHAIN (decls); - } - - buf[FILE_FUNCTION_PREFIX_LEN] = 'Z'; - - fnname = get_identifier (buf); - start_function (void_list_node, build_parse_node (CALL_EXPR, fnname, void_list_node, NULL_TREE), 0, 0); - fnname = DECL_NAME (current_function_decl); - store_parm_decls (); - - pushlevel (0); - clear_last_expr (); - push_momentary (); - expand_start_bindings (0); - - { - tree decl, type; - /* Lay out a table static to this function - with information about all text and data that - this file provides. */ - tree zlink_table = finish_table (get_identifier ("__ZLINK_tbl"), zlink_type, zlink, 0); - decl = pushdecl (build_decl (VAR_DECL, get_identifier ("_ZLINK_once"), integer_type_node)); - TREE_STATIC (decl) = 1; - finish_decl (decl, NULL_TREE, NULL_TREE); - expand_start_cond (truthvalue_conversion (decl), 0); - expand_null_return (); - expand_end_cond (); - finish_stmt (); - expand_expr_stmt (build_modify_expr (decl, NOP_EXPR, integer_one_node)); - type = build_function_type (void_type_node, NULL_TREE); - decl = pushdecl (build_lang_decl (FUNCTION_DECL, get_identifier ("_Ztable_from_cfront"), type)); - TREE_EXTERNAL (decl) = 1; - finish_decl (decl, NULL_TREE, NULL_TREE); - expand_expr_stmt (build_function_call (decl, build_tree_list (NULL_TREE, zlink_table))); - expand_null_return (); - } - expand_end_bindings (0, 1, 0); - poplevel (1, 0, 1); - pop_momentary (); - finish_function (lineno, 0); - - buf[FILE_FUNCTION_PREFIX_LEN] = 'Y'; - fnname = get_identifier (buf); - start_function (build_tree_list (NULL_TREE, get_identifier ("int")), - build_parse_node (INDIRECT_REF, build_parse_node (CALL_EXPR, fnname, void_list_node, NULL_TREE)), 0, 0); - fnname = DECL_NAME (current_function_decl); - store_parm_decls (); - - pushlevel (0); - clear_last_expr (); - push_momentary (); - expand_start_bindings (0); - - { -#define SOS_VERSION 2 - tree sosVersionNumber = build_int_2 (SOS_VERSION, 0); - tree zret_table; - - /* For each type defined, if is a dynamic type, write out - an entry linking its member functions with their names. */ - - while (tags) - { - tree type = TREE_VALUE (tags); - if (TYPE_DYNAMIC (type)) - { - /* SOS currently only implements single inheritance, - so we just pick up one string, if this class - has a base class. */ - tree base_name = CLASSTYPE_N_BASECLASSES (type) > 0 && TYPE_DYNAMIC (CLASSTYPE_BASECLASS (type, 1)) - ? build1 (ADDR_EXPR, string_type_node, CLASSTYPE_TYPENAME_AS_STRING (CLASSTYPE_BASECLASS (type, 1))) - : null_string; - tree dyn_table, dyn_entry = NULL_TREE, fns = CLASS_ASSOC_VIRTUALS (type); - while (fns) - { - if (TREE_ASM_WRITTEN (TREE_OPERAND (TREE_VALUE (fns), 0))) - dyn_entry = tree_cons (NULL_TREE, TREE_VALUE (fns), dyn_entry); - else - dyn_entry = tree_cons (NULL_TREE, __sosDynError, dyn_entry); - fns = TREE_CHAIN (fns); - } - dyn_entry = nreverse (dyn_entry); - dyn_entry = tree_cons (NULL_TREE, build1 (NOP_EXPR, TYPE_POINTER_TO (default_function_type), sosVersionNumber), - tree_cons (NULL_TREE, integer_zero_node, - tree_cons (NULL_TREE, integer_zero_node, - dyn_entry))); - dyn_table = finish_table (DECL_NAME (TYPE_NAME (type)), TYPE_POINTER_TO (default_function_type), dyn_entry, 0); - entry = build (CONSTRUCTOR, zret_type, NULL_TREE, - tree_cons (NULL_TREE, build1 (ADDR_EXPR, string_type_node, CLASSTYPE_TYPENAME_AS_STRING (type)), - tree_cons (NULL_TREE, default_conversion (dyn_table), - tree_cons (NULL_TREE, build_int_2 (CLASSTYPE_VSIZE (type), 0), - tree_cons (NULL_TREE, base_name, - build_tree_list (NULL_TREE, integer_zero_node)))))); - TREE_LITERAL (entry) = 1; - TREE_STATIC (entry) = 1; - zret = tree_cons (NULL_TREE, entry, zret); - } - tags = TREE_CHAIN (tags); - } - zret_table = finish_table (get_identifier ("__Zret"), zret_type, zret, 0); - c_expand_return (convert (build_pointer_type (integer_type_node), default_conversion (zret_table))); - } - expand_end_bindings (0, 1, 0); - poplevel (1, 0, 1); - pop_momentary (); - finish_function (lineno, 0); - -#if defined(DBX_DEBUGGING_INFO) && !defined(FASCIST_ASSEMBLER) - { - extern struct _iob *asm_out_file; - fprintf (asm_out_file, ".stabs \"___ZTOR_LIST__\",22,0,0,"); - assemble_name (asm_out_file, IDENTIFIER_POINTER (fnname)); - fputc ('\n', asm_out_file); - } -#endif - } -#endif - - /* Done with C language context needs. */ - pop_lang_context (); - - /* Now write out any static class variables (which may have since - learned how to be initialized). */ - while (pending_statics) - { - tree decl = TREE_VALUE (pending_statics); - if (TREE_USED (decl) == 1 - || TREE_READONLY (decl) == 0 - || DECL_INITIAL (decl) == 0) - rest_of_decl_compilation (decl, DECL_ASSEMBLER_NAME (decl), 1, 1); - pending_statics = TREE_CHAIN (pending_statics); - } - - this_time = gettime (); - parse_time -= this_time - start_time; - varconst_time += this_time - start_time; - - /* Now write out inline functions which had their addresses taken - and which were not declared virtual and which were not declared - `extern inline'. */ - while (pending_addressable_inlines) - { - tree decl = TREE_VALUE (pending_addressable_inlines); - if (! TREE_ASM_WRITTEN (decl) - && ! TREE_EXTERNAL (decl) - && DECL_SAVED_INSNS (decl)) - output_inline_function (decl); - pending_addressable_inlines = TREE_CHAIN (pending_addressable_inlines); - } - - start_time = gettime (); - - /* Now delete from the chain of variables all virtual function tables. - We output them all ourselves, because each will be treated specially. */ - - /* Make last thing in global scope not be a virtual function table. */ - vars = build_decl (VAR_DECL, get_identifier (" @%$#@!"), integer_type_node); - TREE_EXTERNAL (vars) = 1; - pushdecl (vars); - /* Make this dummy variable look used. */ - TREE_ASM_WRITTEN (vars) = 1; - DECL_INITIAL (vars) = error_mark_node; - - walk_vtables (finish_vtable_typedecl, finish_vtable_vardecl); - - if (write_virtuals == 2) - { - /* Now complain about an virtual function tables promised - but not delivered. */ - while (pending_vtables) - { - if (TREE_PURPOSE (pending_vtables) == NULL_TREE) - error ("virtual function table for `%s' not defined", - IDENTIFIER_POINTER (TREE_VALUE (pending_vtables))); - pending_vtables = TREE_CHAIN (pending_vtables); - } - } - - permanent_allocation (); - this_time = gettime (); - parse_time -= this_time - start_time; - varconst_time += this_time - start_time; - - if (flag_detailed_statistics) - dump_time_statistics (); -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-except.c b/gnu/usr.bin/g++/cc1plus/cplus-except.c deleted file mode 100644 index b9333c5129a8..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-except.c +++ /dev/null @@ -1,1027 +0,0 @@ -/* Handle exceptional things in C++. - Copyright (C) 1989 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* High-level class interface. */ - -#define NULL 0 -#define EXCEPTION_NAME_PREFIX "__exception_" - -#include "config.h" -#include "tree.h" -#include "cplus-tree.h" -#include "flags.h" -#include "assert.h" -/* On Suns this can get you to the right definition if you - set the right value for TARGET. */ -#include -#ifdef sequent -/* Can you believe they forgot this? */ -#define _JBLEN 11 -#endif - -#ifndef _JBLEN -#define _JBLEN (sizeof(jmp_buf)/sizeof(int)) -#endif - -void init_exception_processing (); -void init_exception_processing_1 (); - -/* If non-zero, a VAR_DECL whose cleanup will cause a throw to the - next exception handler. Its value says whether to throw or not. - In the case of functions which do not issue a RAISE, it should be - possible to optimize away this VAR_DECL (and overhead associated - with it). */ -tree exception_throw_decl; -/* Use this to know that we did not set `exception_throw_decl', - until GCC optimizer is smart enough to figure it out for itself. */ -int sets_exception_throw_decl; - -/* The exception `type' currently in scope, or NULL_TREE if none. */ -tree current_exception_type; - -/* The exception handler object for the given scope. */ -tree current_exception_decl; - -/* The ``object'' view of the current exception parameters. - We cast up from the `parms' field to `current_exception_type'. */ -tree current_exception_object; - -/* Low-level rtl interface. */ -#include "rtl.h" - -/* Cache `setjmp', `longjmp', `raise_exception', and `unhandled_exception' - after default conversion. Maybe later they will get built-in. */ -static tree BISJ, BILJ, BIR, BIUE; - -/* Local variables which give the appearance that exception - handling is part of the language and the execution model. */ - -/* The type of the exception handler stack. */ -static tree EHS_type; - -/* The global handler stack. */ -tree EHS_decl; - -/* Cached component refs to fields of `EHS_decl'. */ -static tree EHS_prev, EHS_handler, EHS_parms, EHS_name; - -/* The parameter names of this exception type. */ - -static tree last_exception_fields; -static tree last_exception_field_types; - -/* When ID is VOID_TYPE_NODE, it means ``raise all''. - Cannot be inline, since it uses `alloca', and that - breaks code which pushes the result of this function - on the stack. */ -static tree -exception_object_name (prefix, id) - tree prefix; - tree id; -{ - /* First, cons up the `name' of this exception. */ - char *name; - int length = (id == void_type_node ? 3 : IDENTIFIER_LENGTH (id)) + EXCEPTION_NAME_LENGTH; - - if (prefix) - length += IDENTIFIER_LENGTH (prefix) + 2; - - name = (char *)alloca (length); - strcpy (name, EXCEPTION_NAME_PREFIX); - length = EXCEPTION_NAME_LENGTH; - if (prefix) - { - strcpy (name + length, IDENTIFIER_POINTER (prefix)); - name[length + IDENTIFIER_LENGTH (prefix)] = JOINER; - length += IDENTIFIER_LENGTH (prefix) + 1; - } - if (id == void_type_node) - strcpy (name + length, "all"); - else - strcpy (name + length, IDENTIFIER_POINTER (id)); - return get_identifier (name); -} - -tree -lookup_exception_cname (ctype, cname, raise_id) - tree ctype, cname; - tree raise_id; -{ - tree this_cname = TREE_PURPOSE (raise_id); - if (this_cname == NULL_TREE) - { - if (cname) - { - tree name = TREE_VALUE (raise_id); - if (purpose_member (name, CLASSTYPE_TAGS (ctype))) - this_cname = cname; - } - } - else if (this_cname == void_type_node) - this_cname = NULL_TREE; - else if (TREE_CODE (this_cname) != IDENTIFIER_NODE) - { - sorry ("multiple scope refs in `cplus_expand_raise_stmt'"); - this_cname = error_mark_node; - } - return this_cname; -} - -tree -lookup_exception_tname (oname) - tree oname; -{ - return get_identifier (IDENTIFIER_POINTER (oname) + EXCEPTION_NAME_LENGTH); -} - -tree -lookup_exception_object (cname, name, complain) - tree cname, name; - int complain; -{ - tree oname; - tree decl; - - if (cname == void_type_node) - cname = NULL_TREE; - else if (cname && TREE_CODE (cname) != IDENTIFIER_NODE) - { - sorry ("multiple scope refs in `lookup_exception_object'"); - cname = NULL_TREE; - } - oname = exception_object_name (cname, name); - decl = IDENTIFIER_GLOBAL_VALUE (oname); - if (decl == NULL_TREE || TREE_CODE (decl) != VAR_DECL) - { - if (complain) - { - int temp = allocation_temporary_p (); - if (cname) - error ("no exception name object for name `%s::%s'", - IDENTIFIER_POINTER (cname), - IDENTIFIER_POINTER (name)); - else - error ("no exception name object for name `%s'", - IDENTIFIER_POINTER (name)); - if (temp) - end_temporary_allocation (); - /* Avoid further error messages. */ - pushdecl_top_level (build_lang_field_decl (VAR_DECL, - exception_object_name (cname, name), - error_mark_node)); - if (temp) - resume_temporary_allocation (); - } - return NULL_TREE; - } - return decl; -} - -tree -lookup_exception_type (ctype, cname, raise_id) - tree ctype, cname; - tree raise_id; -{ - tree name = TREE_VALUE (raise_id); - tree purpose = TREE_PURPOSE (raise_id); - - if (cname && purpose == NULL_TREE) - purpose = cname; - - if (purpose && purpose != void_type_node) - { - tree assoc = NULL_TREE; - - if (TREE_CODE (purpose) != IDENTIFIER_NODE) - { - sorry ("multiple scope refs in `lookup_exception_type'"); - TREE_PURPOSE (raise_id) = NULL_TREE; - return NULL_TREE; - } - if (! is_aggr_typedef (purpose, 1)) - return NULL_TREE; - ctype = TREE_TYPE (TREE_TYPE (purpose)); - assoc = purpose_member (name, CLASSTYPE_TAGS (ctype)); - if (assoc) - return TREE_VALUE (assoc); - } - - ctype = lookup_name (name); - if (ctype && TREE_CODE (ctype) == TYPE_DECL) - ctype = TREE_TYPE (ctype); - if (ctype && TREE_CODE (ctype) == RECORD_TYPE - && CLASSTYPE_DECLARED_EXCEPTION (ctype)) - return ctype; - return NULL_TREE; -} - -tree -finish_exception (e, list_of_fieldlists) - tree e; - tree list_of_fieldlists; -{ - tree parmtypes = NULL_TREE, name_field; - tree cname = TYPE_NAME (e); - - if (TREE_CODE (cname) == TYPE_DECL) - cname = DECL_NAME (cname); - - if (last_exception_fields) - error ("cannot declare exceptions within exceptions"); - if (list_of_fieldlists && ! ANON_AGGRNAME_P (cname)) - error_with_aggr_type (e, "exception name `%s' must follow body declaration"); - if (list_of_fieldlists) - { - tree prev, field; - - /* Note: no public, private, or protected allowed. */ - if (TREE_CHAIN (list_of_fieldlists)) - error ("visibility declarations invalid in exception declaration"); - else if (TREE_PURPOSE (list_of_fieldlists) != (tree)visibility_default) - error ("visibility declarations invalid in exception declaration"); - TREE_PURPOSE (list_of_fieldlists) = (tree)visibility_default; - - /* Note also: no member function declarations allowed. */ - for (prev = 0, field = TREE_VALUE (list_of_fieldlists); - field; prev = field, field = TREE_CHAIN (field)) - { - switch (TREE_CODE (field)) - { - case FIELD_DECL: - /* ok. */ - parmtypes = tree_cons (NULL_TREE, TREE_TYPE (field), parmtypes); - continue; - case FUNCTION_DECL: - error_with_decl (field, "declaration of function `%s' in exception invalid"); - break; - case VAR_DECL: - if (TREE_STATIC (field)) - error_with_decl (field, "declaration of static variable `%s' in exception invalid"); - else - error_with_decl (field, "declaration of constant field `%s' in exception invalid"); - break; - case CONST_DECL: - error_with_decl (field, "declaration of enum value `%s' in exception invalid"); - break; - case SCOPE_REF: - error ("use of `::' in exception context invalid"); - break; - } - if (prev) - TREE_CHAIN (prev) = TREE_CHAIN (field); - else - TREE_VALUE (list_of_fieldlists) = TREE_CHAIN (field); - } - } - - /* Now that we've cleaned up the fields, add a name identifier at front. */ - name_field = build_lang_field_decl (FIELD_DECL, get_identifier ("__name"), - ptr_type_node); - if (list_of_fieldlists) - { - TREE_CHAIN (name_field) = TREE_VALUE (list_of_fieldlists); - TREE_VALUE (list_of_fieldlists) = name_field; - } - else - list_of_fieldlists = build_tree_list (NULL_TREE, name_field); - - last_exception_fields = TREE_VALUE (list_of_fieldlists); - if (parmtypes) - { - last_exception_field_types = nreverse (parmtypes); - /* Set the TREE_CHAIN of what is now at the end of the - list to `void_list_node'. */ - TREE_CHAIN (parmtypes) = void_list_node; - } - else - last_exception_field_types = void_list_node; - - popclass (0); - -#if 0 - /* Remove aggregate types from the list of tags, - since these appear at global scope. */ - while (x && IS_AGGR_TYPE (TREE_VALUE (x))) - x = TREE_CHAIN (x); - CLASSTYPE_TAGS (t) = x; - y = x; - while (x) - { - if (IS_AGGR_TYPE (TREE_VALUE (x))) - TREE_CHAIN (y) = TREE_CHAIN (x); - x = TREE_CHAIN (x); - } -#endif - - if (flag_cadillac) - cadillac_finish_exception (e); - - return e; -} - -void -finish_exception_decl (cname, decl) - tree cname, decl; -{ - /* In cplus-decl.h. */ - extern tree last_function_parms; - - /* An exception declaration. */ - tree t, ctor; - tree parmdecls = NULL_TREE, fields; - tree list_of_fieldlists = temp_tree_cons (NULL_TREE, - copy_list (last_exception_fields), - NULL_TREE); - tree edecl = build_lang_field_decl (VAR_DECL, - exception_object_name (cname, DECL_NAME (decl)), - ptr_type_node); - - DECL_LANGUAGE (edecl) = lang_c; - TREE_STATIC (edecl) = 1; - TREE_PUBLIC (edecl) = 1; - finish_decl (pushdecl (edecl), 0, 0); - - /* Now instantiate the exception decl. */ - t = xref_tag (exception_type_node, DECL_NAME (decl), NULL_TREE); - - /* finish_struct will pop this. */ - pushclass (t, 0); - - /* Now add a constructor which takes as parameters all the types we - just defined. */ - ctor = build_lang_decl (FUNCTION_DECL, DECL_NAME (decl), - build_cplus_method_type (t, TYPE_POINTER_TO (t), - last_exception_field_types)); - /* Don't take `name'. The constructor handles that. */ - fields = TREE_CHAIN (TREE_VALUE (list_of_fieldlists)); - while (fields) - { - tree parm = build_decl (PARM_DECL, DECL_NAME (fields), TREE_TYPE (fields)); - /* Since there is a prototype, args are passed in their own types. */ - DECL_ARG_TYPE (parm) = TREE_TYPE (parm); -#ifdef PROMOTE_PROTOTYPES - if (TREE_CODE (TREE_TYPE (fields)) == INTEGER_TYPE - && TYPE_PRECISION (TREE_TYPE (fields)) < TYPE_PRECISION (integer_type_node)) - DECL_ARG_TYPE (parm) = integer_type_node; -#endif - TREE_CHAIN (parm) = parmdecls; - parmdecls = parm; - fields = TREE_CHAIN (fields); - } - fields = TREE_VALUE (list_of_fieldlists); - last_function_parms = nreverse (parmdecls); - - DECL_CONSTRUCTOR_P (ctor) = 1; - TYPE_HAS_CONSTRUCTOR (t) = 1; - grokclassfn (t, DECL_NAME (decl), ctor, NO_SPECIAL, 0, NULL_TREE); - TREE_EXTERNAL (ctor) = 1; - TREE_STATIC (ctor) = 1; - TREE_PUBLIC (ctor) = 0; - TREE_INLINE (ctor) = 1; - make_decl_rtl (ctor, 0, 1); - finish_decl (ctor, NULL_TREE, 0); - TREE_CHAIN (ctor) = TREE_VALUE (list_of_fieldlists); - TREE_VALUE (list_of_fieldlists) = ctor; - - finish_struct (t, list_of_fieldlists, 0, 0); - - if (current_function_decl) - error ("cannot define exception inside function scope"); - else - { - /* Now build the constructor for this exception. */ - parmdecls = DECL_ARGUMENTS (ctor); - start_function (NULL_TREE, ctor, 0, 1); - store_parm_decls (); - pushlevel (0); - clear_last_expr (); - push_momentary (); - expand_start_bindings (0); - - /* Move all the parameters to the fields, skipping `this'. */ - parmdecls = TREE_CHAIN (parmdecls); - /* Install `name' of this exception handler. */ - DECL_INITIAL (fields) = build_unary_op (ADDR_EXPR, edecl, 0); - fields = TREE_CHAIN (fields); - /* Install all the values. */ - while (fields) - { - /* Set up the initialization for this field. */ - DECL_INITIAL (fields) = parmdecls; - fields = TREE_CHAIN (fields); - parmdecls = TREE_CHAIN (parmdecls); - } - emit_base_init (t, 0); - - finish_function (DECL_SOURCE_LINE (ctor), 1); - } -} - -void -end_exception_decls () -{ - last_exception_field_types = NULL_TREE; - last_exception_fields = NULL_TREE; -} - -/* Statement-level exception semantics. */ - -void -cplus_expand_start_try (implicit) - int implicit; -{ - tree call_to_setjmp; - tree handler, ref; - - /* Start a new block enclosing the whole handler. */ - if (implicit) - { - pushlevel_temporary (1); - } - else - { - pushlevel (0); - clear_last_expr (); - push_momentary (); - - /* Encompass whole exception handler in one big binding contour. - If RAISE should throw out of the whole TRY/EXCEPT block, call - `expand_start_bindings' with argument of 1. */ - expand_start_bindings (0); - } - - /* Allocate handler in that block. It's real name will come later. - Note that it will be the first name in this binding contour. */ - handler = get_temp_name (EHS_type, 0); - DECL_INITIAL (handler) = error_mark_node; - finish_decl (handler, NULL_TREE, 0); - - /* Must come after call to `finish_decl', else the cleanup for the temp - for the handler will cause the contour we just created to be popped. */ - if (implicit) - declare_implicit_exception (); - - /* Catch via `setjmp'. */ - ref = build_component_ref (handler, get_identifier ("handler"), NULL_TREE, 0); - call_to_setjmp = build_function_call (BISJ, build_tree_list (NULL_TREE, ref)); - - /* RAISE throws to EXCEPT part. */ - expand_start_try (build_binary_op (EQ_EXPR, call_to_setjmp, integer_zero_node), 0, 1); -} - -/* If KEEP is 1, then declarations in the TRY statement are worth keeping. - If KEEP is 2, then the TRY statement was generated by the compiler. - If KEEP is 0, the declarations in the TRY statement contain errors. */ - -tree -cplus_expand_end_try (keep) - int keep; -{ - tree decls, decl, block; - - if (keep < 2) - pop_implicit_try_blocks (NULL_TREE); - - decls = getdecls (); - - /* Emit code to avoid falling through into a default - handler that might come later. */ - expand_end_try (); - - /* Pops binding contour local to TRY, and get the exception handler - object built by `...start_try'. */ - switch (keep) - { - case 0: - expand_end_bindings (decls, 0, 1); - block = poplevel (0, 0, 0); - pop_momentary (); - decl = getdecls (); - break; - - case 1: - expand_end_bindings (decls, 1, 1); - block = poplevel (1, 1, 0); - pop_momentary (); - decl = getdecls (); - break; - - default: - decl = tree_last (decls); - block = NULL_TREE; - break; - } - - assert (TREE_CODE (decl) == VAR_DECL && TREE_TYPE (decl) == EHS_type); - if (block) - { - TREE_LANG_FLAG_1 (block) = 1; - TREE_USED (block) = 1; - } - - /* Pass it back so that its rtl can be bound to its name - (or vice versa). */ - return decl; -} - -void -cplus_expand_start_except (name, decl) - tree name, decl; -{ - int yes; - tree tmp; - - expand_start_except (0, 1); - - /* This is internal `eh'. */ - current_exception_decl = decl; - /* Get the exception object into scope (user declared `ex'). */ - tmp = pushdecl (build_decl (VAR_DECL, name, ptr_type_node)); - DECL_INITIAL (tmp) = error_mark_node; - finish_decl (tmp, build (COMPONENT_REF, ptr_type_node, decl, TREE_OPERAND (EHS_parms, 1)), 0); - current_exception_type = NULL_TREE; - yes = suspend_momentary (); - /* From now on, send the user to our faked-up object. */ - current_exception_object = build1 (INDIRECT_REF, void_type_node, tmp); - IDENTIFIER_LOCAL_VALUE (name) = current_exception_object; - resume_momentary (yes); - - /* Pop exception handler stack. */ - expand_assignment (EHS_decl, EHS_prev, 0, 0); -} - -/* Generate the call to `unhandled_exception' that is appropriate - for this particular unhandled exception. */ -static tree -call_to_unhandled_exception () -{ - extern int lineno; - tree parms = tree_cons (NULL_TREE, - combine_strings (build_string (strlen (input_filename + 1), input_filename)), - build_tree_list (NULL_TREE, build_int_2 (lineno, 0))); - return build_function_call (BIUE, parms); -} - -/* Note that this must be mirror image of `...start_try'. - DFAULT is the default clause, if there was one. - DFAULT is ERROR_MARK_NODE when this ends an implicit handler. */ -void -cplus_expand_end_except (dfault) - tree dfault; -{ - extern tree expand_end_except (); /* stmt.c. */ - tree decls, raised; - - if (dfault == NULL_TREE) - { - /* Uncaught exception at outermost level. If raised locally, - reraise the exception. Otherwise, generate code to call `abort'. */ - if (in_try_block (1) == 0) - { - expand_start_cond (build (EQ_EXPR, integer_type_node, - exception_throw_decl, integer_zero_node), 0); - expand_expr (call_to_unhandled_exception (), 0, VOIDmode, 0); - expand_end_cond (); - } - /* Try the next handler. */ - if (! expand_escape_except ()) - compiler_error ("except nesting botch"); - } - - raised = expand_end_except (); - - decls = getdecls (); - expand_end_bindings (decls, decls != 0, 1); - poplevel (decls != 0, 1, 0); - - /* Implicit handlers do not use the momentary obstack. */ - if (dfault != error_mark_node) - pop_momentary (); - - if (! in_try_block (1)) - { - /* Check that this function is not raising exceptions - it is not supposed to. */ - while (raised) - { - error_with_decl (TREE_VALUE (raised), "exception `%s' raised but not declared raisable"); - raised = TREE_CHAIN (raised); - } - } - else if (dfault == NULL_TREE || dfault == error_mark_node) - { - expand_start_cond (build (NE_EXPR, integer_type_node, - exception_throw_decl, - integer_zero_node), 0); - /* We fell off the end of this try block. Try going to the next. - The escape_label will be the beginning of the next try block. */ - if (! expand_escape_except ()) - compiler_error ("except nesting botch"); - expand_end_cond (); - } -} - -/* Generate code to raise exception RAISE_ID. - If EXP is NULL_TREE, then PARMS is the list of parameters to use - for constructing this exception. - If EXP is non-NULL, then it is an already constructed object - of the kind that we want. */ -void -cplus_expand_raise (raise_id, parms, exp) - tree raise_id; - tree parms; - tree exp; -{ - /* Allocate new exception of appropriate type, passing - PARMS to its constructor. */ - tree cname, name; - tree decl; - tree xexp = exp; - - cname = lookup_exception_cname (current_class_type, current_class_name, raise_id); - if (cname == error_mark_node) - return; - name = TREE_VALUE (raise_id); - - decl = lookup_exception_object (cname, name, 1); - if (decl == NULL_TREE) - return; - - if (exp == NULL_TREE) - { - exp = build_method_call (NULL_TREE, name, parms, NULL_TREE, LOOKUP_COMPLAIN); - if (exp == error_mark_node) - return; - } - - if (in_try_block (1)) - { - expand_raise (decl); - } - else if (! current_function_decl) - { - if (xexp == NULL_TREE) - error_with_decl (decl, "invalid raise of `%s' outside of functions"); - else - error_with_decl (decl, "invalid reraise of `%s' outside of functions"); - } - else - { - /* Test this raise against what this function permits. */ - tree names = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (current_function_decl)); - while (names) - { - if (decl == TREE_TYPE (names)) - break; - names = TREE_CHAIN (names); - } - if (names == NULL_TREE) - { - error ("current function not declared to raise exception `%s'", - IDENTIFIER_POINTER (name)); - return; - } - } - - expand_assignment (EHS_parms, exp, 0, 0); - - /* Set the global exception handler stack's NAME field - to the `name' of this exception. The global exception - handler stack is the container for the exception object - we just built. - - We go through a function call to make life easier when debugging. */ -#if 0 - expand_assignment (EHS_name, build_unary_op (ADDR_EXPR, decl, 0), 0, 0); -#else - parms = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, EHS_name, 0), - build_tree_list (NULL_TREE, - build_unary_op (ADDR_EXPR, decl, 0))); - expand_expr (build_function_call (BIR, parms)); -#endif - - /* Activate thrower. If we are inside a TRY statement, - we can cheat and not do this, saving a longjmp. */ - if (in_try_block (1) == 0) - { - sets_exception_throw_decl = 1; - expand_assignment (exception_throw_decl, integer_one_node, 0, 0); - } - - if (xexp == NULL_TREE) - { - /* Invoke destructors for current procedure or handler. */ - if (! expand_escape_except ()) - compiler_error ("except nesting botch"); - /* Throw via `longjmp'... Done as side-effect of goto. */ - } - /* If we were re-raising, just let this fall through. - At the end of the reraises, the call to `expand_goto' - will take care of everybody. */ -} - -tree -cplus_expand_start_catch (raise_id) - tree raise_id; -{ - tree cname = lookup_exception_cname (current_class_type, current_class_name, raise_id); - tree decl; - tree ref, cond; - - if (cname == error_mark_node) - { - decl = error_mark_node; - cond = error_mark_node; - } - else - { - decl = lookup_exception_object (cname, TREE_VALUE (raise_id), 1); - if (decl == NULL_TREE) - { - cond = error_mark_node; - } - else - { - ref = build (COMPONENT_REF, ptr_type_node, - current_exception_decl, TREE_OPERAND (EHS_name, 1)); - cond = build_binary_op (EQ_EXPR, build_unary_op (ADDR_EXPR, decl, 0), ref); - } - } - expand_start_cond (cond, 0); - - /* Does nothing right now. */ - expand_catch (decl); - if (current_exception_type - && TYPE_NEEDS_DESTRUCTOR (current_exception_type)) - { - /* Make a cleanup for the name-specific exception object now in scope. */ - tree cleanup = maybe_build_cleanup (current_exception_object); - expand_start_bindings (0); - expand_decl_cleanup (NULL_TREE, cleanup); - } - return decl; -} - -void -cplus_expand_end_catch (for_reraise) - int for_reraise; -{ - if (current_exception_type - && TYPE_NEEDS_DESTRUCTOR (current_exception_type)) - { - /* Destroy the specific exception object now in scope. */ - expand_end_bindings (getdecls (), 0, 1); - } - if (for_reraise) - { - if (! expand_escape_except ()) - abort (); - } - else - { - if (! expand_end_catch ()) - abort (); - } - expand_end_cond (); -} - -/* Reraise an exception. - If EXCEPTIONS is NULL_TREE, it means reraise whatever exception was caught. - If EXCEPTIONS is an IDENTIFIER_NODE, it means reraise the exception - object named by EXCEPTIONS. This must be a variable declared in - an `except' clause. - If EXCEPTIONS is a TREE_LIST, it is the list of exceptions we are - willing to reraise. */ - -void -cplus_expand_reraise (exceptions) - tree exceptions; -{ - tree ex_ptr; - tree ex_object = current_exception_object; - - if (exceptions && TREE_CODE (exceptions) == IDENTIFIER_NODE) - { - /* Don't get tripped up if its TREE_TYPE is `error_mark_node'. */ - ex_object = IDENTIFIER_LOCAL_VALUE (exceptions); - if (ex_object == NULL_TREE || TREE_CODE (ex_object) != INDIRECT_REF) - { - error ("`%s' is not an exception decl", IDENTIFIER_POINTER (exceptions)); - return; - } - assert (TREE_CODE (TREE_OPERAND (ex_object, 0)) == VAR_DECL); - exceptions = NULL_TREE; - } - - /* reraise ALL, used by compiler. */ - if (exceptions == NULL_TREE) - { - /* Now treat reraise like catch/raise. */ - expand_catch (error_mark_node); - expand_raise (error_mark_node); - expand_assignment (EHS_name, - build (COMPONENT_REF, ptr_type_node, - current_exception_decl, TREE_OPERAND (EHS_name, 1)), 0, 0); - expand_assignment (EHS_parms, - build (COMPONENT_REF, ptr_type_node, - current_exception_decl, TREE_OPERAND (EHS_parms, 1)), 0, 0); - if (in_try_block (1) == 0) - { - sets_exception_throw_decl = 1; - expand_assignment (exception_throw_decl, integer_one_node, 0, 0); - } - /* Set to zero so that destructor will not be called. */ - expand_assignment (build1 (NOP_EXPR, ptr_type_node, TREE_OPERAND (ex_object, 0)), - integer_zero_node, 0, 0); - if (! expand_escape_except ()) - abort (); - return; - } - - ex_ptr = build1 (NOP_EXPR, NULL_TREE, TREE_OPERAND (ex_object, 0)); - - /* reraise from a list of exceptions. */ - while (exceptions) - { - tree type = lookup_exception_type (current_class_type, current_class_name, - exceptions); - if (type == NULL_TREE) - { - error ("`%s' is not an exception type", - IDENTIFIER_POINTER (TREE_VALUE (exceptions))); - current_exception_type = NULL_TREE; - TREE_TYPE (ex_object) = error_mark_node; - TREE_TYPE (ex_ptr) = error_mark_node; - } - else - { - current_exception_type = type; - /* In-place union. */ - TREE_TYPE (ex_object) = type; - TREE_TYPE (ex_ptr) = TYPE_POINTER_TO (type); - } - - /* Now treat reraise like catch/raise. */ - cplus_expand_start_catch (exceptions); - cplus_expand_raise (exceptions, NULL_TREE, ex_ptr); - /* Set to zero so that destructor will not be called. */ - if (TREE_TYPE (ex_ptr) != error_mark_node) - expand_assignment (ex_ptr, integer_zero_node, 0, 0); - cplus_expand_end_catch (1); - exceptions = TREE_CHAIN (exceptions); - } - /* Don't propagate any unhandled exceptions. */ - expand_expr (call_to_unhandled_exception (), 0, VOIDmode, 0); -} - -void -setup_exception_throw_decl () -{ - tree call_to_longjmp, parms; - - int old = suspend_momentary (); - - exception_throw_decl = build_decl (VAR_DECL, get_identifier (THROW_NAME), integer_type_node); - pushdecl (exception_throw_decl); - parms = tree_cons (NULL_TREE, EHS_handler, - build_tree_list (0, integer_one_node)); - call_to_longjmp = build_function_call (BILJ, parms); - - expand_decl (exception_throw_decl); - expand_decl_cleanup (exception_throw_decl, - build (COND_EXPR, void_type_node, - exception_throw_decl, - call_to_longjmp, integer_zero_node)); - DECL_INITIAL (exception_throw_decl) = integer_zero_node; - sets_exception_throw_decl = 0; - resume_momentary (old); -} - -void -init_exception_processing () -{ - extern tree unhandled_exception_fndecl; - tree cname = get_identifier ("ExceptionHandler"); - tree field, chain; - tree ctor, dtor; - tree jmp_buf_type = build_array_type (integer_type_node, - build_index_type (build_int_2 (_JBLEN-1, 0))); - tree jmp_buf_arg_type = build_pointer_type (integer_type_node); - - tree parmtypes = hash_tree_chain (jmp_buf_arg_type, NULL_TREE); - tree setjmp_fndecl, longjmp_fndecl, raise_fndecl; - - EHS_type = xref_tag (record_type_node, cname, NULL_TREE); - - push_lang_context (lang_name_c); - setjmp_fndecl = define_function ("setjmp", - build_function_type (integer_type_node, - parmtypes), - NOT_BUILT_IN, 0); - BISJ = default_conversion (setjmp_fndecl); - longjmp_fndecl = define_function ("longjmp", - build_function_type (integer_type_node, - hash_tree_chain (jmp_buf_arg_type, - hash_tree_chain (integer_type_node, NULL_TREE))), - NOT_BUILT_IN, 0); - raise_fndecl = define_function ("__raise_exception", - build_function_type (void_type_node, - hash_tree_chain (ptr_type_node, - hash_tree_chain (build_pointer_type (ptr_type_node), NULL_TREE)))); - BILJ = default_conversion (longjmp_fndecl); - BIR = default_conversion (raise_fndecl); - BIUE = default_conversion (unhandled_exception_fndecl); - - pop_lang_context (); - - /* finish_struct will pop this. */ - pushclass (EHS_type, 0); - field = build_lang_field_decl (FIELD_DECL, get_identifier ("parms"), ptr_type_node); - chain = field; - field = build_lang_field_decl (FIELD_DECL, get_identifier ("name"), - build_pointer_type (default_function_type)); - TREE_CHAIN (field) = chain; - chain = field; - field = build_lang_field_decl (FIELD_DECL, get_identifier ("handler"), jmp_buf_type); - TREE_CHAIN (field) = chain; - chain = field; - field = build_lang_field_decl (FIELD_DECL, get_identifier ("prev"), - TYPE_POINTER_TO (EHS_type)); - TREE_CHAIN (field) = chain; - chain = field; - - ctor = build_lang_decl (FUNCTION_DECL, cname, - build_cplus_method_type (EHS_type, TYPE_POINTER_TO (EHS_type), void_list_node)); - DECL_CONSTRUCTOR_P (ctor) = 1; - TREE_STATIC (ctor) = 1; - TREE_PUBLIC (ctor) = 1; - grokclassfn (EHS_type, cname, ctor, NO_SPECIAL, 0, 0); - finish_decl (ctor, 0, 0); - TREE_CHAIN (ctor) = chain; - chain = ctor; - dtor = build_lang_decl (FUNCTION_DECL, cname, - build_cplus_method_type (EHS_type, TYPE_POINTER_TO (EHS_type), void_list_node)); - TREE_STATIC (dtor) = 1; - TREE_PUBLIC (dtor) = 1; - grokclassfn (EHS_type, cname, dtor, DTOR_FLAG, 0, 0); - finish_decl (dtor, 0, 0); - TREE_CHAIN (dtor) = chain; - chain = dtor; - TYPE_HAS_CONSTRUCTOR (EHS_type) = 1; - TYPE_HAS_DESTRUCTOR (EHS_type) = 1; - finish_struct (EHS_type, temp_tree_cons (NULL_TREE, chain, NULL_TREE), 0, 0); -} - -void -init_exception_processing_1 () -{ - register tree EHS_id = get_identifier ("exceptionHandlerStack"); - - EHS_decl = IDENTIFIER_GLOBAL_VALUE (EHS_id); - - /* If we have no other definition, default to library implementation. */ - if (EHS_decl == NULL_TREE) - { - EHS_decl = build_decl (VAR_DECL, EHS_id, TYPE_POINTER_TO (EHS_type)); - /* If we don't push this, its definition, should it be encountered, - will not be seen. */ - EHS_decl = pushdecl (EHS_decl); - TREE_EXTERNAL (EHS_decl) = 1; - TREE_STATIC (EHS_decl) = 1; - TREE_PUBLIC (EHS_decl) = 1; - finish_decl (EHS_decl, 0, 0); - } - else if (TREE_CODE (EHS_decl) != VAR_DECL - || TREE_TYPE (EHS_decl) != TYPE_POINTER_TO (EHS_type)) - fatal ("exception handling declarations conflict with compiler's internal model"); - - if (EHS_prev == NULL_TREE) - { - register tree EHS_DECL = build1 (INDIRECT_REF, EHS_type, EHS_decl); - EHS_prev = build_component_ref (EHS_DECL, get_identifier ("prev"), 0, 0); - EHS_handler = build_component_ref (EHS_DECL, get_identifier ("handler"), 0, 0); - EHS_parms = build_component_ref (EHS_DECL, get_identifier ("parms"), 0, 0); - EHS_name = build_component_ref (EHS_DECL, get_identifier ("name"), 0, 0); - } - - if (use_gdb_dbx_extensions) - dbxout_eh_init (EHS_type, EHS_decl); -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-expr.c b/gnu/usr.bin/g++/cc1plus/cplus-expr.c deleted file mode 100644 index 716d44df88db..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-expr.c +++ /dev/null @@ -1,174 +0,0 @@ -/* Convert language-specific tree expression to rtl instructions, - for GNU compiler. Copyright (C) 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include "config.h" -#include "rtl.h" -#include "tree.h" -#include "flags.h" -#include "expr.h" -#include "cplus-tree.h" -#include "assert.h" - -rtx -cplus_expand_expr (exp, target, tmode, modifier) - tree exp; - rtx target; - enum machine_mode tmode; - enum expand_modifier modifier; -{ - register rtx op0, op1, temp; - tree type = TREE_TYPE (exp); - register enum machine_mode mode = TYPE_MODE (type); - register enum tree_code code = TREE_CODE (exp); - rtx original_target = target; - int ignore = target == const0_rtx; - - if (ignore) target = 0, original_target = 0; - - /* No sense saving up arithmetic to be done - if it's all in the wrong mode to form part of an address. - And force_operand won't know whether to sign-extend or zero-extend. */ - - if (mode != Pmode && modifier == EXPAND_SUM) - modifier = EXPAND_NORMAL; - - switch (code) - { - case CPLUS_NEW_EXPR: - { - /* Something needs to be initialized, but we didn't know - where that thing was when building the tree. For example, - it could be the return value of a function, or a parameter - to a function which lays down in the stack, or a temporary - variable which must be passed by reference . - - Cleanups are handled in a language-specific way: they - might be run by the called function (true in GNU C++ - for parameters with cleanups), or they might be - run by the caller, after the call (true in GNU C++ - for other cleanup needs). */ - - tree func = TREE_OPERAND (exp, 0); - tree args = TREE_OPERAND (exp, 1); - tree type = TREE_TYPE (exp), slot; - tree fn_type = TREE_TYPE (TREE_TYPE (func)); - tree return_type = TREE_TYPE (fn_type); - rtx call_target, return_target; - - /* The expression `init' wants to initialize what - `target' represents. SLOT holds the slot for TARGET. */ - slot = TREE_OPERAND (exp, 2); - - if (target == 0) - { - /* Should always be called with a target in BLKmode case. */ - assert (mode != BLKmode); - assert (DECL_RTL (slot) != 0); - - target = gen_reg_rtx (mode); - } - - /* The target the initializer will initialize (CALL_TARGET) - must now be directed to initialize the target we are - supposed to initialize (TARGET). The semantics for - choosing what CALL_TARGET is is language-specific, - as is building the call which will perform the - initialization. It is left here to show the choices that - exist for C++. */ - - if (TREE_CODE (func) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (func, 0)) == FUNCTION_DECL - && DECL_CONSTRUCTOR_P (TREE_OPERAND (func, 0))) - { - type = TYPE_POINTER_TO (type); - TREE_VALUE (args) = build1 (ADDR_EXPR, type, slot); - call_target = 0; - } - else if (TREE_CODE (return_type) == REFERENCE_TYPE) - { - type = return_type; - call_target = 0; - } - else - { - call_target = target; - } - return_target = expand_expr (build (CALL_EXPR, type, func, args, 0), call_target, mode, 0); - if (call_target == 0) - call_target = return_target; - else if (call_target != return_target) - emit_move_insn (call_target, return_target); - - if (TREE_CODE (return_type) == REFERENCE_TYPE) - { - tree init; - - if (GET_CODE (call_target) == REG - && REGNO (call_target) < FIRST_PSEUDO_REGISTER) - abort (); - - type = TREE_TYPE (exp); - - init = build (RTL_EXPR, return_type, 0, call_target); - /* We got back a reference to the type we want. Now intialize - target with that. */ - expand_aggr_init (slot, init, 0); - } - - if (DECL_RTL (slot) != target) - emit_move_insn (DECL_RTL (slot), target); - return DECL_RTL (slot); - } - - default: - break; - } - abort (); -} - -/* If DECL had its rtl moved from where callers expect it - to be, fix it up. RESULT is the nominal rtl for the RESULT_DECL, - which may be a pseudo instead of a hard register. */ - -void -fixup_result_decl (decl, result) - tree decl; - rtx result; -{ - if (REG_P (result)) - { - if (REGNO (result) >= FIRST_PSEUDO_REGISTER) - { - rtx real_decl_result; - -#ifdef FUNCTION_OUTGOING_VALUE - real_decl_result - = FUNCTION_OUTGOING_VALUE (TREE_TYPE (decl), current_function_decl); -#else - real_decl_result - = FUNCTION_VALUE (TREE_TYPE (decl), current_function_decl); -#endif - REG_FUNCTION_VALUE_P (real_decl_result) = 1; - result = real_decl_result; - } - emit_move_insn (result, DECL_RTL (decl)); - emit_insn (gen_rtx (USE, VOIDmode, result)); - } -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-field.c b/gnu/usr.bin/g++/cc1plus/cplus-field.c deleted file mode 100644 index 0d5ab5d8733b..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-field.c +++ /dev/null @@ -1,918 +0,0 @@ -/************************************************************************/ -/* */ -/* cplus-field.c */ -/* */ -/* Code for handling XREF output from g++ */ -/* */ -/************************************************************************/ - - -#ifdef FIELD_XREF - -#include "config.h" -#include "tree.h" -#include "cplus-tree.h" -#include "input.h" - -#include -#include -#include - - - - -/************************************************************************/ -/* */ -/* Common definitions */ -/* */ -/************************************************************************/ - -typedef int Integer; -typedef char * String; - - -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef NULL -#define NULL 0 -#endif - - -#define PALLOC(typ) ((typ *) calloc(1,sizeof(typ))) - - -#define SALLOC(str) ((String) ((str == NULL) ? NULL : (strcpy(malloc(strlen(str)+1),str)))) -#define SFREE(str) (str != NULL && (free(str),0)) - -#define STREQL(s1,s2) (strcmp((s1),(s2)) == 0) -#define STRNEQ(s1,s2) (strcmp((s1),(s2)) != 0) -#define STRLSS(s1,s2) (strcmp((s1),(s2)) < 0) -#define STRLEQ(s1,s2) (strcmp((s1),(s2)) <= 0) -#define STRGTR(s1,s2) (strcmp((s1),(s2)) > 0) -#define STRGEQ(s1,s2) (strcmp((s1),(s2)) >= 0) - - - - - -/************************************************************************/ -/* */ -/* Type definitions */ -/* */ -/************************************************************************/ - - -typedef struct _XREF_FILE * XREF_FILE; -typedef struct _XREF_SCOPE * XREF_SCOPE; - - - -typedef struct _XREF_FILE { - String name; - XREF_FILE next; -} XREF_FILE_INFO; - - - - - -typedef struct _XREF_SCOPE { - Integer gid; - Integer lid; - XREF_FILE file; - Integer start; - XREF_SCOPE outer; -} XREF_SCOPE_INFO; - - - - - - -/************************************************************************/ -/* */ -/* Local storage */ -/* */ -/************************************************************************/ - - -static char doing_xref = 0; -static FILE * xref_file = NULL; -static char xref_name[1024]; -static XREF_FILE all_files = NULL; -static String wd_name = NULL; -static XREF_SCOPE cur_scope = NULL; -static Integer scope_ctr = 0; -static XREF_FILE last_file = NULL; -static tree last_fct = NULL; - - - - -/************************************************************************/ -/* */ -/* Forward definitions */ -/* */ -/************************************************************************/ - - -extern void FIELD_xref_begin(); -extern void FIELD_xref_end(); -extern void FIELD_xref_file(); -extern void FIELD_xref_start_scope(); -extern void FIELD_xref_end_scope(); -extern void FIELD_xref_ref(); -extern void FIELD_xref_decl(); -extern void FIELD_xref_call(); -extern void FIELD_xref_function(); -extern void FIELD_xref_assign(); -extern void FIELD_xref_hier(); -extern void FIELD_xref_member(); - - -static void gen_assign(); -static XREF_FILE find_file(); -static String filename(); -static String fctname(); -static String declname(); -static void simplify_type(); -static String fixname(); -static void open_xref_file(); - -extern char * type_as_string(); - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_begin -- start cross referencing */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_begin(file) - String file; -{ - String s,t; - - doing_xref = 1; - - if (file != NULL && STRNEQ(file,"-")) { - open_xref_file(file); - FIELD_xref_file(file); - }; -}; - - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_end -- finish cross referencing */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_end(ect) - int ect; -{ - XREF_FILE xf; - - if (!doing_xref) return; - - xf = find_file(input_filename); - if (xf == NULL) return; - - while (cur_scope != NULL) { - FIELD_xref_end_scope(cur_scope->gid,0,0,0,0); - }; - - doing_xref = 0; - - if (xref_file == NULL) return; - - fclose(xref_file); - - xref_file = NULL; - all_files = NULL; - - if (ect > 0) unlink(xref_name); -}; - - - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_file -- handle file xrefing */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_file(name) - String name; -{ - XREF_FILE xf; - char wdbuf[1024]; - - if (!doing_xref || name == NULL) return; - - if (xref_file == NULL) { - open_xref_file(name); - if (!doing_xref) return; - }; - - if (all_files == NULL) { - fprintf(xref_file,"SCP * 0 0 0 0 RESET\n"); - }; - - xf = find_file(name); - if (xf != NULL) return; - - xf = PALLOC(XREF_FILE_INFO); - xf->name = SALLOC(name); - xf->next = all_files; - all_files = xf; - - if (wd_name == NULL) { - getwd(wdbuf); - wd_name = SALLOC(wdbuf); - }; - - fprintf(xref_file,"FIL %s %s 0\n",name,wd_name); - - filename(xf); - fctname(NULL); -}; - - - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_start_scope -- begin a scope */ -/* FIELD_xref_end_scope -- finish a scope */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_start_scope(id) - Integer id; -{ - XREF_SCOPE xs; - XREF_FILE xf; - - if (!doing_xref) return; - xf = find_file(input_filename); - - xs = PALLOC(XREF_SCOPE_INFO); - xs->file = xf; - xs->start = lineno; - if (xs->start <= 0) xs->start = 1; - xs->gid = id; - xs->lid = ++scope_ctr; - xs->outer = cur_scope; - cur_scope = xs; -}; - - - - - -void -FIELD_xref_end_scope(id,inid,prm,keep,trns) - Integer id; - Integer inid; - Integer prm,keep,trns; -{ - XREF_FILE xf; - XREF_SCOPE xs,lxs,oxs; - String stype; - - if (!doing_xref) return; - xf = find_file(input_filename); - if (xf == NULL) return; - - lxs = NULL; - for (xs = cur_scope; xs != NULL; xs = xs->outer) { - if (xs->gid == id) break; - lxs = xs; - }; - if (xs == NULL) return; - - if (inid != 0) { - for (oxs = cur_scope; oxs != NULL; oxs = oxs->outer) { - if (oxs->gid == inid) break; - }; - if (oxs == NULL) return; - inid = oxs->lid; - }; - - if (prm == 2) stype = "SUE"; - else if (prm != 0) stype = "ARGS"; - else if (keep == 2 || inid != 0) stype = "INTERN"; - else stype = "EXTERN"; - - fprintf(xref_file,"SCP %s %d %d %d %d %s\n", - filename(xf),xs->start,lineno,xs->lid,inid,stype); - - if (lxs == NULL) cur_scope = xs->outer; - else lxs->outer = xs->outer; - - free(xs); -}; - - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_ref -- handle reference */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_ref(fct,name) - tree fct; - String name; -{ - XREF_FILE xf; - - if (!doing_xref) return; - xf = find_file(input_filename); - if (xf == NULL) return; - - fprintf(xref_file,"REF %s %d %s %s\n", - filename(xf),lineno,fctname(fct),name); -}; - - - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_decl -- handle declaration */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_decl(fct,decl) - tree fct; - tree decl; -{ - XREF_FILE xf; - String cls; - String name; - char buf[10240]; - - if (!doing_xref) return; - xf = find_file(input_filename); - if (xf == NULL) return; - - if (DECL_NAME(decl) == NULL) return; - - if (TREE_CODE(decl) == TYPE_DECL) cls = "TYPEDEF"; - else if (TREE_CODE(decl) == FIELD_DECL) cls = "FIELD"; - else if (TREE_CODE(decl) == VAR_DECL) { - if (fct == NULL && TREE_STATIC(decl) && - TREE_READONLY(decl) && DECL_INITIAL(decl) != 0 && - !TREE_PUBLIC(decl) && !TREE_EXTERNAL(decl) && - DECL_MODE(decl) != BLKmode) cls = "CONST"; - else if (TREE_EXTERNAL(decl)) cls = "EXTERN"; - else if (TREE_PUBLIC(decl)) cls = "EXTDEF"; - else if (TREE_STATIC(decl)) cls = "STATIC"; - else if (TREE_REGDECL(decl)) cls = "REGISTER"; - else cls = "AUTO"; - } - else if (TREE_CODE(decl) == PARM_DECL) cls = "PARAM"; - else if (TREE_CODE(decl) == FIELD_DECL) cls = "FIELD"; - else if (TREE_CODE(decl) == CONST_DECL) cls = "CONST"; - else if (TREE_CODE(decl) == FUNCTION_DECL) { - if (TREE_EXTERNAL(decl)) cls = "EXTERN"; - else if (TREE_PUBLIC(decl)) cls = "EFUNCTION"; - else cls = "SFUNCTION"; - } - else if (TREE_CODE(decl) == LABEL_DECL) cls = "LABEL"; - else if (TREE_CODE(decl) == UNION_TYPE) { - cls = "UNIONID"; - decl = TYPE_NAME(decl); - } - else if (TREE_CODE(decl) == RECORD_TYPE) { - if (CLASSTYPE_DECLARED_CLASS(decl)) cls = "CLASSID"; - else cls = "STRUCTID"; - decl = TYPE_NAME(decl); - } - else if (TREE_CODE(decl) == ENUMERAL_TYPE) { - cls = "ENUMID"; - decl = TYPE_NAME(decl); - } - else cls = "UNKNOWN"; - - name = IDENTIFIER_POINTER(DECL_NAME(decl)); - - type_as_string(buf,TREE_TYPE(decl)); - simplify_type(buf); - - fprintf(xref_file,"DCL %s %d %s %d %s %s %s\n", - filename(xf),lineno,name, - (cur_scope != NULL ? cur_scope->lid : 0), - cls,fctname(fct),buf); -}; - - - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_call -- handle call */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_call(fct,name) - tree fct; - String name; -{ - XREF_FILE xf; - char buf[1024]; - - if (!doing_xref) return; - xf = find_file(input_filename); - if (xf == NULL) return; - name = fixname(name,buf); - - fprintf(xref_file,"CAL %s %d %s %s\n", - filename(xf),lineno,name,fctname(fct)); -}; - - - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_function -- handle functions */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_function(fct,args) - tree fct; - tree args; -{ - XREF_FILE xf; - int ct; - char buf[1024]; - - if (!doing_xref) return; - xf = find_file(input_filename); - if (xf == NULL) return; - - ct = 0; - buf[0] = 0; - if (args == NULL) args = DECL_ARGUMENTS(fct); - - FIELD_xref_decl(NULL,fct); - - for ( ; args != NULL; args = TREE_CHAIN(args)) { - FIELD_xref_decl(fct,args); - if (ct != 0) strcat(buf,","); - strcat(buf,declname(args)); - ++ct; - }; - - fprintf(xref_file,"PRC %s %d %s %d %d %s\n", - filename(xf),lineno,declname(fct), - (cur_scope != NULL ? cur_scope->lid : 0), - ct,buf); -}; - - - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_assign -- handle assignment */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_assign(name) - tree name; -{ - XREF_FILE xf; - - if (!doing_xref) return; - xf = find_file(input_filename); - if (xf == NULL) return; - - gen_assign(xf,name); -}; - - - -static void -gen_assign(xf,name) - XREF_FILE xf; - tree name; -{ - String s; - - s = NULL; - - switch (TREE_CODE(name)) { - case IDENTIFIER_NODE : - s = IDENTIFIER_POINTER(name); - break; - case VAR_DECL : - s = declname(name); - break; - case COMPONENT_REF : - gen_assign(xf,TREE_OPERAND(name,0)); - gen_assign(xf,TREE_OPERAND(name,1)); - break; - case INDIRECT_REF : - case OFFSET_REF : - case ARRAY_REF : - case BUFFER_REF : - gen_assign(xf,TREE_OPERAND(name,0)); - break; - case COMPOUND_EXPR : - gen_assign(xf,TREE_OPERAND(name,1)); - break; - default : - break; - }; - - if (s != NULL) { - fprintf(xref_file,"ASG %s %d %s\n",filename(xf),lineno,s); - }; -}; - - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_hier -- handle hierarchy */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_hier(cls,base,pub,virt,frnd) - String cls; - String base; - int pub; - int virt; - int frnd; -{ - XREF_FILE xf; - - if (!doing_xref) return; - xf = find_file(input_filename); - if (xf == NULL) return; - - fprintf(xref_file,"HIE %s %d %s %s %d %d %d\n", - filename(xf),lineno,cls,base,pub,virt,frnd); -}; - - - - - -/************************************************************************/ -/* */ -/* FIELD_xref_member -- handle member */ -/* */ -/************************************************************************/ - - -void -FIELD_xref_member(cls,fld) - tree cls; - tree fld; -{ - XREF_FILE xf; - String prot; - Integer confg,pure; - String d,p; - Integer i; - char buf[1024],bufa[1024]; - - if (!doing_xref) return; - xf = find_file(fld->decl.filename); - if (xf == NULL) return; - - if (TREE_PRIVATE(fld)) prot = "PRIVATE"; - else if (TREE_PROTECTED(fld)) prot = "PROTECTED"; - else prot = "PUBLIC"; - - confg = 0; - if (TREE_CODE(fld) == FUNCTION_DECL && DECL_CONST_MEMFUNC_P(fld)) confg = 1; - else if (TREE_CODE(fld) == CONST_DECL) confg = 1; - - pure = 0; - if (TREE_CODE(fld) == FUNCTION_DECL && DECL_ABSTRACT_VIRTUAL_P(fld)) pure = 1; - - d = IDENTIFIER_POINTER(cls); - sprintf(buf,"%d%s",strlen(d),d); - i = strlen(buf); - strcpy(bufa,declname(fld)); - for (p = &bufa[1]; *p != 0; ++p) { - if (p[0] == '_' && p[1] == '_' && p[2] >= '0' && p[2] <= '9') { - if (strncmp(&p[2],buf,i) == 0) *p = 0; - break; - } - else if (p[0] == '_' && p[1] == '_' && p[2] == 'C' && p[3] >= '0' && p[3] <= '9') { - if (strncmp(&p[3],buf,i) == 0) *p = 0; - break; - }; - }; - - fprintf(xref_file,"MEM %s %d %s %s %s %d %d %d %d %d %d %d\n", - filename(xf),fld->decl.linenum,d, - bufa, - prot, - (TREE_CODE(fld) == FUNCTION_DECL ? 0 : 1), - (TREE_INLINE(fld) ? 1 : 0), - (DECL_FRIEND_P(fld) ? 1 : 0), - (DECL_VIRTUAL_P(fld) ? 1 : 0), - (TREE_STATIC(fld) ? 1 : 0), - pure,confg); -}; - - - - - - -/************************************************************************/ -/* */ -/* find_file -- find file entry given name */ -/* */ -/************************************************************************/ - - - -static XREF_FILE -find_file(name) - String name; -{ - XREF_FILE xf; - - for (xf = all_files; xf != NULL; xf = xf->next) { - if (STREQL(name,xf->name)) break; - }; - - return xf; -}; - - - - - -/************************************************************************/ -/* */ -/* filename -- return name for output */ -/* */ -/************************************************************************/ - - -static String -filename(xf) - XREF_FILE xf; -{ - if (xf == NULL) { - last_file = NULL; - return "*"; - }; - - if (last_file == xf) return "*"; - - last_file = xf; - - return xf->name; -}; - - - - - - -/************************************************************************/ -/* */ -/* fctname -- return name for function */ -/* */ -/************************************************************************/ - - -static String -fctname(fct) - tree fct; -{ - extern char * declname(); - static char fctbuf[1024]; - String s; - - if (fct == NULL && last_fct == NULL) return "*"; - - if (fct == NULL) { - last_fct = NULL; - return "*TOP*"; - }; - - if (fct == last_fct) return "*"; - - last_fct = fct; - - s = declname(fct); - s = fixname(s,fctbuf); - - return s; -}; - - - - - - -/************************************************************************/ -/* */ -/* declname -- print name for declaration */ -/* */ -/************************************************************************/ - - -static String -declname(dcl) - tree dcl; -{ - if (DECL_NAME(dcl) == NULL) return "?"; - - return IDENTIFIER_POINTER (DECL_NAME (dcl)); -} - - - - - -/************************************************************************/ -/* */ -/* simplify_type -- simplify a type string */ -/* */ -/************************************************************************/ - - -static void -simplify_type(typ) - String typ; -{ - String s; - Integer lvl,i; - - i = strlen(typ); - while (i > 0 && isspace(typ[i-1])) typ[--i] = 0; - - if (i > 7 && STREQL(&typ[i-5],"const")) { - typ[i-5] = 0; - i -= 5; - }; - - if (typ[i-1] != ')') return; - - s = &typ[i-2]; - lvl = 1; - while (*s != 0) { - if (*s == ')') ++lvl; - else if (*s == '(') { - --lvl; - if (lvl == 0) { - s[1] = ')'; - s[2] = 0; - break; - }; - }; - --s; - }; - - if (*s != 0 && s[-1] == ')') { - --s; - --s; - if (*s == '(') s[2] = 0; - else if (*s == ':') { - while (*s != '(') --s; - s[1] = ')'; - s[2] = 0; - }; - }; -}; - - - - - -/************************************************************************/ -/* */ -/* fixname -- fixup a function name (take care of embedded spaces */ -/* */ -/************************************************************************/ - - -static String -fixname(nam,buf) - String nam; - String buf; -{ - String s,t; - int fg; - - s = nam; - t = buf; - fg = 0; - - while (*s != 0) { - if (*s == ' ') { - *t++ = '\36'; - ++fg; - } - else *t++ = *s; - ++s; - }; - - if (fg == 0) return nam; - - return buf; -}; - - - - - -/************************************************************************/ -/* */ -/* open_xref_file -- open file for xrefing */ -/* */ -/************************************************************************/ - - -static void -open_xref_file(file) - String file; -{ - String s,t; - - s = rindex(file,'/'); - if (s == NULL) sprintf(xref_name,".%s.gxref",file); - else { - ++s; - strcpy(xref_name,file); - t = rindex(xref_name,'/'); - ++t; - *t++ = '.'; - strcpy(t,s); - strcat(t,".gxref"); - }; - - xref_file = fopen(xref_name,"w"); - - if (xref_file == NULL) { - error("Can't create cross-reference file `%s'",xref_name); - doing_xref = 0; - }; -}; - - - -#endif - - -/* end of cplus-field.c */ diff --git a/gnu/usr.bin/g++/cc1plus/cplus-init.c b/gnu/usr.bin/g++/cc1plus/cplus-init.c deleted file mode 100644 index 51a13d1e1924..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-init.c +++ /dev/null @@ -1,3687 +0,0 @@ -/* Handle initialization things in C++. - Copyright (C) 1987 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* High-level class interface. */ - -#include "config.h" -#include "tree.h" -#include "cplus-tree.h" -#include "flags.h" -#include "assert.h" - -/* For expand_asm_operands. */ -extern char *input_filename; -extern int lineno; - -#define NULL 0 - -/* In C++, structures with well-defined constructors are initialized by - those constructors, unasked. CURRENT_BASE_INIT_LIST - holds a list of stmts for a BASE_INIT term in the grammar. - This list has one element for each base class which must be - initialized. The list elements are [basename, init], with - type basetype. This allows the possibly anachronistic form - (assuming d : a, b, c) "d (int a) : c(a+5), b (a-4), a (a+3)" - where each successive term can be handed down the constructor - line. Perhaps this was not intended. */ -tree current_base_init_list, current_member_init_list; - -void init_init_processing (); -void emit_base_init (); -void check_base_init (); -static void expand_aggr_vbase_init (); -void expand_member_init (); -void expand_aggr_init (); -tree build_virtual_init (); -tree build_vbase_delete (); - -static void expand_aggr_init_1 (); -static void expand_recursive_init_1 (); -static void expand_recursive_init (); -tree expand_vec_init (); -tree build_vec_delete (); - -static void add_friend (), add_friends (); - -int is_aggr_typedef (); -/* Cache _builtin_new and _builtin_delete exprs. */ -static tree BIN, BIVN, BID; - -#ifdef SOS -tree get_linktable_name (), get_dtable_name (), get_sos_dtable (); -static tree __sosFindCode, __sosLookup, __sosImport; -static tree build_dynamic_new (); -#endif -static tree minus_one; - -extern struct rtx_def *start_sequence (), *get_insns (), *get_last_insn (); -extern struct rtx_def *const0_rtx; - -/* Set up local variable for this file. MUST BE CALLED AFTER - INIT_DECL_PROCESSING. */ - -void init_init_processing () -{ - BIN = default_conversion (TREE_VALUE (lookup_name (get_identifier ("__builtin_new")))); - BIVN = default_conversion (TREE_VALUE (lookup_name (get_identifier ("__builtin_vec_new")))); - BID = default_conversion (TREE_VALUE (lookup_name (get_identifier ("__builtin_delete")))); - minus_one = build_int_2 (-1, -1); -#ifdef SOS - if (flag_all_virtual == 2) - { - __sosFindCode = default_conversion (lookup_name (get_identifier ("sosFindCode"))); - __sosLookup = default_conversion (lookup_name (get_identifier ("sosLookup"))); - __sosImport = default_conversion (lookup_name (get_identifier ("sosImport"))); - } -#endif -} - -/* Perform whatever initialization have yet to be done on the - base class of the class variable. These actions are in - the global variable CURRENT_BASE_INIT_LIST. Such an - action could be NULL_TREE, meaning that the user has explicitly - called the base class constructor with no arguments. - - If there is a need for a call to a constructor, we - must surround that call with a pushlevel/poplevel pair, - since we are technically at the PARM level of scope. - - Argument ASSIGNS_THIS_P is nonzero if the current function assigns - `this' explicitly. We cannot get this value by checking - `current_function_assigns_this', since it is set up after this - function is called. (although I don't know if its really - necessary to wait until afterward to do that.) - - Note that emit_base_init does *not* initialize virtual - base classes. That is done specially, elsewhere. */ - -void -emit_base_init (t, immediately) - tree t; - int immediately; -{ - extern tree in_charge_identifier; - - tree member, decl; - tree init_list, basetype; - int pass, start; - int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (t); - tree fields_to_unmark = NULL_TREE; - tree vfields; - - if (! immediately) - { - do_pending_stack_adjust (); - start_sequence (); - /* As a matter of principle, `start_sequence' should do this. */ - emit_note (0, -1); - } - - /* In this case, we always need IN_CHARGE_NODE, because we have - to know whether to deallocate or not before exiting. */ - if (flag_handle_exceptions == 2 - && lookup_name (in_charge_identifier) == NULL_TREE) - { - tree in_charge_node = pushdecl (build_decl (VAR_DECL, in_charge_identifier, - integer_type_node)); - store_init_value (in_charge_node, build (EQ_EXPR, integer_type_node, - current_class_decl, - integer_zero_node)); - expand_decl (in_charge_node); - expand_decl_init (in_charge_node); - } - - start = ! TYPE_USES_VIRTUAL_BASECLASSES (t); - for (pass = start; pass < 2; pass++) - { - tree vbase_init_list = NULL_TREE; - for (init_list = current_base_init_list; init_list; - init_list = TREE_CHAIN (init_list)) - { - tree basename = TREE_PURPOSE (init_list); - tree basetype; - tree init = TREE_VALUE (init_list); - - if (basename == NULL_TREE) - { - /* Initializer for single base class. Must not - use multiple inheritance or this is ambiguous. */ - switch (n_baseclasses) - { - case 0: - error ("type `%s' does not have a base class to initialize", - IDENTIFIER_POINTER (current_class_name)); - return; - case 1: - break; - default: - error ("unnamed initializer ambiguous for type `%s' which uses multiple inheritance", IDENTIFIER_POINTER (current_class_name)); - return; - } - basetype = CLASSTYPE_BASECLASS (t, 1); - } - else if (is_aggr_typedef (basename, 1)) - { - basetype = basetype_or_else (TREE_TYPE (TREE_TYPE (basename)), t); - if (basetype == NULL_TREE) - continue; - - /* Virtual base classes are special cases. Their initializers - are recorded with this constructor, and they are used when - this constructor is the top-level constructor called. */ - if (! TREE_VIA_VIRTUAL (basetype)) - { - /* Otherwise, if it is not an immediate base class, complain. */ - for (i = n_baseclasses; i > 0; i--) - if (basetype == CLASSTYPE_BASECLASS (t, i)) - break; - if (i == 0) - { - error ("type `%s' is not an immediate base class of type `%s'", - IDENTIFIER_POINTER (basename), - IDENTIFIER_POINTER (current_class_name)); - continue; - } - } - } - else - continue; - - /* The base initialization list goes up to the first - base class which can actually use it. */ - - if (CLASSTYPE_MARKED6 (basetype)) - { - error ("class `%s' initializer already specified", - IDENTIFIER_POINTER (basename)); - continue; - } - - if (pass == start) - { - char *msgp = (! TYPE_HAS_CONSTRUCTOR (basetype)) - ? "cannot pass initialization up to class `%s'" : 0; - - while (! TYPE_HAS_CONSTRUCTOR (basetype) - && CLASSTYPE_N_BASECLASSES (basetype) == 1) - basetype = CLASSTYPE_BASECLASS (basetype, 1); - - if (basetype) - { - if (msgp) - if (pedantic) - { - error_with_aggr_type (basetype, msgp); - continue; - } - else if (! TYPE_HAS_CONSTRUCTOR (basetype)) - { - if (CLASSTYPE_N_BASECLASSES (basetype) == 0) - error_with_aggr_type (basetype, msgp); - else - sorry ("passing initializations up multiple inheritance lattice"); - continue; - } - } - else - { - error ("no constructor found for initialization of `%s'", - IDENTIFIER_POINTER (basename)); - continue; - } - - if (TREE_VIA_VIRTUAL (basetype)) - { - CLASSTYPE_MARKED6 (basetype) = 1; - vbase_init_list = tree_cons (init, basetype, vbase_init_list); - } - if (pass == 0) - continue; - } - else if (TREE_VIA_VIRTUAL (basetype)) - continue; - - CLASSTYPE_MARKED6 (basetype) = 1; - member = convert_pointer_to (basetype, current_class_decl); - expand_aggr_init_1 (t, 0, - build_indirect_ref (member, 0), init, - ! DECL_OFFSET (TYPE_NAME (basetype)), - LOOKUP_PROTECTED_OK|LOOKUP_COMPLAIN); - if (flag_handle_exceptions == 2 && TYPE_NEEDS_DESTRUCTOR (basetype)) - { - cplus_expand_start_try (1); - push_exception_cleanup (member); - } - } - - if (pass == 0) - { - tree first_arg = TREE_CHAIN (DECL_ARGUMENTS (current_function_decl)); - tree vbases; - - if (DECL_COMPILER_GENERATED_P (current_function_decl) - && TREE_CHAIN (first_arg) != NULL_TREE) - { - /* If there are virtual baseclasses without initialization - specified, and this is a default X(X&) construcotr, - build the initialization list so that each virtual baseclass - of the new object is initialized from the virtual baseclass - of the incoming arg. */ - tree init_arg = build_unary_op (ADDR_EXPR, TREE_CHAIN (first_arg), 0); - for (vbases = CLASSTYPE_VBASECLASSES (t); - vbases; vbases = TREE_CHAIN (vbases)) - { - basetype = TREE_TYPE (vbases); - if (CLASSTYPE_MARKED6 (basetype) == 0) - { - member = convert_pointer_to (basetype, init_arg); - if (member == init_arg) - member = TREE_CHAIN (first_arg); - else - TREE_TYPE (member) = build_reference_type (basetype); - vbase_init_list = tree_cons (convert_from_reference (member), - basetype, vbase_init_list); - CLASSTYPE_MARKED6 (basetype) = 1; - } - } - } - expand_start_cond (first_arg, 0); - expand_aggr_vbase_init (t, C_C_D, current_class_decl, - vbase_init_list); - expand_expr_stmt (build_vbase_vtables_init (t, t, C_C_D, - current_class_decl, 1)); -#ifdef sparc - expand_asm_operands (build_string (32, "! end of vtable initialization"), 0, 0, 0, 0, input_filename, lineno); -#endif - expand_end_cond (); - } - } - current_base_init_list = NULL_TREE; - - /* Now, perform default initialization of all base classes which - have not yet been initialized, and unmark baseclasses which - have been initialized. */ - for (i = 1; i <= n_baseclasses; i++) - { - tree base = current_class_decl; - - basetype = CLASSTYPE_BASECLASS (t, i); - if (TYPE_NEEDS_CONSTRUCTING (basetype)) - { - if (! TREE_VIA_VIRTUAL (basetype) - && ! CLASSTYPE_MARKED6 (basetype)) - { - tree ref; - - if (CLASSTYPE_OFFSET (basetype) == integer_zero_node) - base = build1 (NOP_EXPR, TYPE_POINTER_TO (basetype), current_class_decl); - else - base = build (PLUS_EXPR, TYPE_POINTER_TO (basetype), current_class_decl, CLASSTYPE_OFFSET (basetype)); - - ref = build_indirect_ref (base, 0); - expand_aggr_init_1 (t, 0, ref, NULL_TREE, - ! DECL_OFFSET (TYPE_NAME (basetype)), - LOOKUP_PROTECTED_OK|LOOKUP_COMPLAIN); - if (flag_handle_exceptions == 2 && TYPE_NEEDS_DESTRUCTOR (basetype)) - { - cplus_expand_start_try (1); - push_exception_cleanup (base); - } - } - } - CLASSTYPE_MARKED6 (basetype) = 0; - } - - /* Initialize all the virtual function table fields that - do not come from virtual base classes. */ - vfields = CLASSTYPE_VFIELDS (t); - while (vfields) - { - /* If the vtable installed by the constructor was not - the right one, fix that here. */ - if (TREE_ADDRESSABLE (vfields) - && (TYPE_HAS_CONSTRUCTOR (TREE_TYPE (vfields)) - /* BASE_INIT_LIST has already initialized these guys. */ - || ! value_member (TREE_VALUE (vfields), CLASSTYPE_ASSOC (t)))) - { - tree basetype = TYPE_MAIN_VARIANT (TREE_TYPE (vfields)); - tree assoc = assoc_value (basetype, t); - if (ASSOC_VTABLE (assoc) != CLASS_ASSOC_VTABLE (basetype)) - { - tree ptr = convert_pointer_to (basetype, current_class_decl); - expand_expr_stmt (build_virtual_init (t, basetype, ptr)); - } - } - vfields = TREE_CHAIN (vfields); - } - - if (CLASSTYPE_NEEDS_VIRTUAL_REINIT (t) -#ifdef SOS - || TYPE_DYNAMIC (t) -#endif - ) - expand_expr_stmt (build_virtual_init (t, t, current_class_decl)); - - /* Members we through expand_member_init. We initialize all the members - needing initialization that did not get it so far. */ - for (; current_member_init_list; - current_member_init_list = TREE_CHAIN (current_member_init_list)) - { - tree name = TREE_PURPOSE (current_member_init_list); - tree init = TREE_VALUE (current_member_init_list); - tree field = (TREE_CODE (name) == COMPONENT_REF - ? TREE_OPERAND (name, 1) : IDENTIFIER_CLASS_VALUE (name)); - tree type; - - /* If one member shadows another, get the outermost one. */ - if (TREE_CODE (field) == TREE_LIST) - { - field = TREE_VALUE (field); - if (decl_type_context (field) != current_class_type) - error ("field `%s' not in immediate context"); - } - - type = TREE_TYPE (field); - - if (TREE_STATIC (field)) - { - error_with_aggr_type (DECL_FIELD_CONTEXT (field), - "field `%s::%s' is static; only point of initialization is its declaration", IDENTIFIER_POINTER (name)); - continue; - } - - if (DECL_NAME (field)) - { - if (TREE_HAS_CONSTRUCTOR (field)) - error ("multiple initializations given for member `%s'", - IDENTIFIER_POINTER (DECL_NAME (field))); - } - - /* Mark this node as having been initialized. */ - TREE_HAS_CONSTRUCTOR (field) = 1; - if (DECL_FIELD_CONTEXT (field) != t) - fields_to_unmark = tree_cons (NULL_TREE, field, fields_to_unmark); - - if (TREE_CODE (name) == COMPONENT_REF) - { - /* Initialization of anonymous union. */ - expand_assignment (name, init, 0, 0); - continue; - } - decl = build_component_ref (C_C_D, name, 0, 1); - - if (TYPE_NEEDS_CONSTRUCTING (type)) - { - if (TREE_CODE (type) == ARRAY_TYPE - && TREE_CHAIN (init) == NULL_TREE - && TREE_CODE (TREE_TYPE (TREE_VALUE (init))) == ARRAY_TYPE) - { - /* Initialization of one array from another. */ - expand_vec_init (TREE_OPERAND (decl, 1), decl, - array_type_nelts (type), TREE_VALUE (init), 1); - } - else - expand_aggr_init (decl, init, 0); - } - else - { - if (init == NULL_TREE) - { - error ("types without constructors must have complete initializers"); - init = error_mark_node; - } - else if (TREE_CHAIN (init)) - { - warning ("initializer list treated as compound expression"); - init = build_compound_expr (init); - } - else - init = TREE_VALUE (init); - - expand_expr_stmt (build_modify_expr (decl, INIT_EXPR, init)); - } - if (flag_handle_exceptions == 2 && TYPE_NEEDS_DESTRUCTOR (type)) - { - cplus_expand_start_try (1); - push_exception_cleanup (build_unary_op (ADDR_EXPR, decl, 0)); - } - } - - for (member = TYPE_FIELDS (t); member; member = TREE_CHAIN (member)) - { - /* All we care about is this unique member. It contains - all the information we need to know, and that right early. */ - tree type = TREE_TYPE (member); - tree init = TREE_HAS_CONSTRUCTOR (member) - ? error_mark_node : DECL_INITIAL (member); - - /* Unmark this field. If it is from an anonymous union, - then unmark the field recursively. */ - TREE_HAS_CONSTRUCTOR (member) = 0; - if (TREE_ANON_UNION_ELEM (member)) - emit_base_init (TREE_TYPE (member), 1); - - /* Member had explicit initializer. */ - if (init == error_mark_node) - continue; - - if (TREE_CODE (member) != FIELD_DECL) - continue; - - if (type == error_mark_node) - continue; - - if (TYPE_NEEDS_CONSTRUCTING (type)) - { - if (init) - init = build_tree_list (NULL_TREE, init); - decl = build_component_ref (C_C_D, DECL_NAME (member), 0, 0); - expand_aggr_init (decl, init, 0); - } - else - { - if (init) - { - decl = build_component_ref (C_C_D, DECL_NAME (member), 0, 0); - expand_expr_stmt (build_modify_expr (decl, INIT_EXPR, init)); - } - else if (TREE_CODE (TREE_TYPE (member)) == REFERENCE_TYPE) - warning ("uninitialized reference member `%s'", - IDENTIFIER_POINTER (DECL_NAME (member))); - } - if (flag_handle_exceptions == 2 && TYPE_NEEDS_DESTRUCTOR (type)) - { - cplus_expand_start_try (1); - push_exception_cleanup (build_unary_op (ADDR_EXPR, decl, 0)); - } - } - /* Unmark fields which are initialized for the base class. */ - while (fields_to_unmark) - { - TREE_HAS_CONSTRUCTOR (TREE_VALUE (fields_to_unmark)) = 0; - fields_to_unmark = TREE_CHAIN (fields_to_unmark); - } - - /* It is possible for the initializers to need cleanups. - Expand those cleanups now that all the initialization - has been done. */ - expand_cleanups_to (NULL_TREE); - - if (! immediately) - { - extern struct rtx_def *base_init_insns; - - do_pending_stack_adjust (); - assert (base_init_insns == 0); - base_init_insns = get_insns (); - end_sequence (); - } - - /* All the implicit try blocks we built up will be zapped - when we come to a real binding contour boundary. */ -} - -/* Check that all fields are properly initialized after - an assignment to `this'. */ -void -check_base_init (t) - tree t; -{ - tree member; - for (member = TYPE_FIELDS (t); member; member = TREE_CHAIN (member)) - { - if (DECL_NAME (member) && TREE_USED (member)) - error ("field `%s' used before initialized (after assignment to `this')", - IDENTIFIER_POINTER (DECL_NAME (member))); - } -} - -/* This code sets up the virtual function tables appropriate for - the pointer DECL. It is a one-ply initialization. - - TYPE is the exact type that DECL is supposed to be. In - muliple inheritance, this might mean "C's A" if C : A, B. */ -tree -build_virtual_init (for_type, type, decl) - tree for_type, type; - tree decl; -{ - tree vtbl, vtbl_ptr; - tree vtype; - -#ifdef SOS - if (TYPE_DYNAMIC (type)) - vtbl = build1 (NOP_EXPR, ptr_type_node, lookup_name (get_identifier (AUTO_VTABLE_NAME))); - else -#endif - { -#if 1 - vtbl = ASSOC_VTABLE (assoc_value (DECL_FIELD_CONTEXT (CLASSTYPE_VFIELD (type)), - for_type)); -#else - assert (for_type == type); - vtbl = CLASS_ASSOC_VTABLE (for_type); -#endif /* 1 */ - TREE_USED (vtbl) = 1; - vtbl = build1 (ADDR_EXPR, TYPE_POINTER_TO (TREE_TYPE (vtbl)), vtbl); - } - vtype = DECL_CONTEXT (CLASSTYPE_VFIELD (type)); - decl = convert_pointer_to (vtype, decl); - vtbl_ptr = build_vfield_ref (build_indirect_ref (decl, 0), vtype); - - /* Have to convert VTBL since array sizes may be different. */ - return build_modify_expr (vtbl_ptr, NOP_EXPR, - convert (TREE_TYPE (vtbl_ptr), vtbl)); -} - -/* Subroutine of `expand_aggr_vbase_init'. - BASETYPE is type that is being initialized. INIT_LIST - is the list of initializers for the virtual baseclass. */ -static void -expand_aggr_vbase_init_1 (basetype, exp, addr, init_list) - tree basetype, init_list; -{ - tree init = value_member (basetype, init_list); - tree ref = build_indirect_ref (addr, 0); - if (init) - init = TREE_PURPOSE (init); - /* Call constructors, but don't set up vtables. */ - expand_aggr_init_1 (basetype, exp, ref, init, 0, - LOOKUP_PROTECTED_OK|LOOKUP_COMPLAIN|LOOKUP_SPECULATIVELY); - CLASSTYPE_MARKED6 (basetype) = 0; -} - -/* Initialize this object's virtual base class pointers. This must be - done only at the top-level of the object being constructed. - - INIT_LIST is list of initialization for constructor to perform. */ -static void -expand_aggr_vbase_init (type, exp, addr, init_list) - tree type; - tree exp; - tree addr; - tree init_list; -{ - if (TYPE_USES_VIRTUAL_BASECLASSES (type)) - { - tree result = init_vbase_pointers (type, addr); - tree basetype, vbases; - - if (result) - expand_expr_stmt (build_compound_expr (result)); - - /* Mark everything as having an initializer - (either explicit or default). */ - for (vbases = CLASSTYPE_VBASECLASSES (type); - vbases; vbases = TREE_CHAIN (vbases)) - CLASSTYPE_MARKED6 (TREE_TYPE (vbases)) = 1; - - /* First, initialize baseclasses which could be baseclasses - for other virtual baseclasses. */ - for (vbases = CLASSTYPE_VBASECLASSES (type); - vbases; vbases = TREE_CHAIN (vbases)) - /* Don't initialize twice. */ - if (CLASSTYPE_MARKED6 (TREE_TYPE (vbases))) - { - tree assoc = purpose_member (TREE_TYPE (vbases), result); - assert (assoc != NULL_TREE); - expand_aggr_vbase_init_1 (TREE_PURPOSE (assoc), exp, - TREE_OPERAND (TREE_VALUE (assoc), 0), - init_list); - } - - /* Now initialize the baseclasses which don't have virtual baseclasses. */ - for (; result; result = TREE_CHAIN (result)) - /* Don't initialize twice. */ - if (CLASSTYPE_MARKED6 (TREE_PURPOSE (result))) - { - abort (); - expand_aggr_vbase_init_1 (TREE_PURPOSE (result), exp, - TREE_OPERAND (TREE_VALUE (result), 0), - init_list); - } - -#ifdef sparc - expand_asm_operands (build_string (30, "! end of vbase initialization"), 0, 0, 0, 0, input_filename, lineno); -#endif - } -} - -/* Function to give error message if member initialization specification - is erroneous. FIELD is the member we decided to initialize. - TYPE is the type for which the initialization is being performed. - FIELD must be a member of TYPE, or the base type from which FIELD - comes must not need a constructor. - - MEMBER_NAME is the name of the member. */ - -static int -member_init_ok_or_else (field, type, member_name) - tree field; - tree type; - char *member_name; -{ - if (field == error_mark_node) return 0; - if (field == NULL_TREE) - { - error_with_aggr_type (type, "class `%s' does not have any field named `%s'", - member_name); - return 0; - } - if (DECL_CONTEXT (field) != type - && TYPE_NEEDS_CONSTRUCTOR (DECL_CONTEXT (field))) - { - error ("member `%s' comes from base class needing constructor", member_name); - return 0; - } - return 1; -} - -/* If NAME is a viable field name for the aggregate DECL, - and PARMS is a viable parameter list, then expand an _EXPR - which describes this initialization. - - Note that we do not need to chase through the class's base classes - to look for NAME, because if it's in that list, it will be handled - by the constructor for that base class. - - We do not yet have a fixed-point finder to instantiate types - being fed to overloaded constructors. If there is a unique - constructor, then argument types can be got from that one. - - If INIT is non-NULL, then it the initialization should - be placed in `current_base_init_list', where it will be processed - by `emit_base_init'. */ -void -expand_member_init (exp, name, init) - tree exp, name, init; -{ - extern tree ptr_type_node; /* should be in tree.h */ - - tree basetype = NULL_TREE, field; - tree parm; - tree rval, type; - tree actual_name; - - if (exp == NULL_TREE) - return; /* complain about this later */ - - type = TYPE_MAIN_VARIANT (TREE_TYPE (exp)); - - if (name == NULL_TREE && IS_AGGR_TYPE (type)) - switch (CLASSTYPE_N_BASECLASSES (type)) - { - case 0: - error ("base class initializer specified, but no base class to initialize"); - return; - case 1: - basetype = CLASSTYPE_BASECLASS (type, 1); - break; - default: - error ("initializer for unnamed base class ambiguous"); - error_with_aggr_type (type, "(type `%s' uses multiple inheritance)"); - return; - } - - if (init) - { - /* The grammar should not allow fields which have names - that are TYPENAMEs. Therefore, if the field has - a non-NULL TREE_TYPE, we may assume that this is an - attempt to initialize a base class member of the current - type. Otherwise, it is an attempt to initialize a - member field. */ - - if (init == void_type_node) - init = NULL_TREE; - - if (name == NULL_TREE || TREE_TYPE (name)) - { - tree base_init; - - if (name == NULL_TREE) - if (basetype) - name = DECL_NAME (TYPE_NAME (basetype)); - else - { - error ("no base class to initialize"); - return; - } - else - { - basetype = TREE_TYPE (TREE_TYPE (name)); - if (basetype != type - && ! value_member (basetype, TYPE_BASETYPES (type)) - && ! value_member (basetype, CLASSTYPE_VBASECLASSES (type))) - { - if (IDENTIFIER_CLASS_VALUE (name)) - goto try_member; - if (TYPE_USES_VIRTUAL_BASECLASSES (type)) - error ("type `%s' is not an immediate or virtual basetype for `%s'", - IDENTIFIER_POINTER (name), - TYPE_NAME_STRING (type)); - else - error ("type `%s' is not an immediate basetype for `%s'", - IDENTIFIER_POINTER (name), - TYPE_NAME_STRING (type)); - return; - } - } - - if (purpose_member (name, current_base_init_list)) - { - error ("base class `%s' already initialized", - IDENTIFIER_POINTER (name)); - return; - } - - base_init = build_tree_list (name, init); - TREE_TYPE (base_init) = basetype; - current_base_init_list = chainon (current_base_init_list, base_init); - } - else - { - tree member_init; - - try_member: - field = lookup_field (type, name, 1); - - if (! member_init_ok_or_else (field, type, IDENTIFIER_POINTER (name))) - return; - - if (purpose_member (name, current_member_init_list)) - { - error ("field `%s' already initialized", DECL_NAME (name)); - return; - } - - member_init = build_tree_list (name, init); - TREE_TYPE (member_init) = TREE_TYPE (field); - current_member_init_list = chainon (current_member_init_list, member_init); - } - return; - } - else if (name == NULL_TREE) - { - compiler_error ("expand_member_init: name == NULL_TREE"); - return; - } - - basetype = type; - field = lookup_field (basetype, name, 0); - - if (! member_init_ok_or_else (field, basetype, IDENTIFIER_POINTER (name))) - return; - - /* now see if there is a constructor for this type - which will take these args. */ - - if (TYPE_HAS_CONSTRUCTOR (TREE_TYPE (field))) - { - tree parmtypes, fndecl; - - if (TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == PARM_DECL) - { - /* just know that we've seen something for this node */ - DECL_INITIAL (exp) = error_mark_node; - TREE_USED (exp) = 1; - } - type = TYPE_MAIN_VARIANT (TREE_TYPE (field)); - actual_name = DECL_NAME (TYPE_NAME (type)); - parm = build_component_ref (exp, name, 0, 0); - - /* Now get to the constructor. */ - field = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), 0); - /* Get past destructor, if any. */ - if (TYPE_HAS_DESTRUCTOR (type)) - field = TREE_CHAIN (field); - - /* If the field is unique, we can use the parameter - types to guide possible type instantiation. */ - if (TREE_CHAIN (field) == NULL_TREE) - { - fndecl = TREE_TYPE (field); - parmtypes = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (fndecl))); - } - else - { - parmtypes = NULL_TREE; - fndecl = NULL_TREE; - } - - init = actualparameterlist (parm, parmtypes, NULL_TREE, fndecl, LOOKUP_NORMAL); - if (init == NULL_TREE || TREE_TYPE (init) != error_mark_node) - rval = build_method_call (NULL_TREE, actual_name, init, NULL_TREE, LOOKUP_NORMAL); - else - return; - - if (rval != error_mark_node) - { - /* Now, fill in the first parm with our guy */ - TREE_VALUE (TREE_OPERAND (rval, 1)) - = build_unary_op (ADDR_EXPR, parm, 0); - TREE_TYPE (rval) = ptr_type_node; - TREE_VOLATILE (rval) = 1; - } - } - else if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (field))) - { - parm = build_component_ref (exp, name, 0, 0); - expand_aggr_init (parm, NULL_TREE, 0); - rval = error_mark_node; - } - - /* Now initialize the member. It does not have to - be of aggregate type to receive initialization. */ - if (rval != error_mark_node) - expand_expr_stmt (rval); -} - -/* This is like `expand_member_init', only it stores one aggregate - value into another. - - INIT comes in two flavors: it is either a value which - is to be stored in EXP, or it is a parameter list - to go to a constructor, which will operate on EXP. - If `init' is a CONSTRUCTOR, then we emit a warning message, - explaining that such initializaitions are illegal. - - ALIAS_THIS is nonzero iff we are initializing something which is - essentially an alias for C_C_D. In this case, the base constructor - may move it on us, and we must keep track of such deviations. - - If INIT resolves to a CALL_EXPR which happens to return - something of the type we are looking for, then we know - that we can safely use that call to perform the - initialization. - - The virtual function table pointer cannot be set up here, because - we do not really know its type. - - Virtual baseclass pointers are also set up here. - - This never calls operator=(). - - When initializing, nothing is CONST. */ - -void -expand_aggr_init (exp, init, alias_this) - tree exp, init; - int alias_this; -{ - tree type = TREE_TYPE (exp); - tree addr; - int was_const = TREE_READONLY (exp); - - if (init == error_mark_node) - return; - - TREE_READONLY (exp) = 0; - - if (TREE_CODE (type) == ARRAY_TYPE) - { - /* Must arrange to initialize each element of EXP - from elements of INIT. */ - int was_const_elts = TREE_READONLY (TREE_TYPE (type)); - tree itype = init ? TREE_TYPE (init) : NULL_TREE; - if (was_const_elts) - { - tree atype = build_cplus_array_type (TYPE_MAIN_VARIANT (TREE_TYPE (type)), - TYPE_DOMAIN (type)); - if (TREE_TYPE (exp) == TREE_TYPE (init)) - TREE_TYPE (init) = atype; - TREE_TYPE (exp) = atype; - } - expand_vec_init (exp, exp, array_type_nelts (type), init, - init && TREE_TYPE (init) == TREE_TYPE (exp)); - TREE_READONLY (exp) = was_const; - TREE_TYPE (exp) = type; - if (init) TREE_TYPE (init) = itype; - return; - } - - if (TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == PARM_DECL) - /* just know that we've seen something for this node */ - TREE_USED (exp) = 1; - - /* If initializing from a GNU C CONSTRUCTOR, consider the elts in the - constructor as parameters to an implicit GNU C++ constructor. */ - if (init && TREE_CODE (init) == CONSTRUCTOR - && TYPE_HAS_CONSTRUCTOR (type) - && TREE_TYPE (init) == type) - init = CONSTRUCTOR_ELTS (init); - expand_aggr_init_1 (type, exp, exp, init, alias_this, LOOKUP_NORMAL); - TREE_READONLY (exp) = was_const; -} - -/* This function is responsible for initializing EXP with INIT - (if any). - - FOR_TYPE is the type for who we are performing the initialization. - For example, if W is a virtual base class of A and B, and C : A, B - if we are initializing B, then W must contain B's W vtable, whereas - were we initializing C, W must contain C's W vtable. - - TRUE_EXP is nonzero if it is the true expression being initialized. - In this case, it may be EXP, or may just contain EXP. The reason we - need this is because if EXP is a base element of TRUE_EXP, we - don't necessarily know by looking at EXP where its virtual - baseclass fields should really be pointing. But we do know - from TRUE_EXP. In constructors, we don't know anything about - the value being initialized. - - ALIAS_THIS serves the same purpose it serves for expand_aggr_init. - - FLAGS is just passes to `build_method_call'. See that function for - its description. */ - -static void -expand_aggr_init_1 (for_type, true_exp, exp, init, alias_this, flags) - tree for_type; - tree true_exp, exp; - tree init; - int alias_this; - int flags; -{ - tree type = TREE_TYPE (exp); - tree init_type = NULL_TREE; - tree rval; - - assert (init != error_mark_node && type != error_mark_node); - - /* Use a function returning the desired type to initialize EXP for us. - If the function is a constructor, and its first argument is - NULL_TREE, know that it was meant for us--just slide exp on - in and expand the constructor. Constructors now come - as NEW_EXPRs. */ - if (init) - { - tree init_list = NULL_TREE; - - if (TREE_CODE (init) == TREE_LIST) - { - init_list = init; - if (TREE_CHAIN (init) == NULL_TREE) - init = TREE_VALUE (init); - } - - init_type = TREE_TYPE (init); - - if (TREE_CODE (init) != TREE_LIST) - { - if (TREE_CODE (init_type) == ERROR_MARK) - return; - -#if 0 - /* These lines are found troublesome 5/11/89. */ - if (TREE_CODE (init_type) == REFERENCE_TYPE) - init_type = TREE_TYPE (init_type); -#endif - - /* This happens when we use C++'s functional cast notation - to act as the initializer for something not of that same - type. In that case, we need to create the initializer - separately from the object being initialized. */ - if (TREE_CODE (init) == NEW_EXPR && init_type != type) - { - init = TREE_OPERAND (init, 1); - init = build (CALL_EXPR, init_type, - TREE_OPERAND (init, 0), TREE_OPERAND (init, 1), 0); - TREE_VOLATILE (init) = 1; -#if 0 - TREE_RAISES (init) = ?? -#endif - if (init_list) - TREE_VALUE (init_list) = init; - } - - if (init_type == type && TREE_CODE (init) == CALL_EXPR -#if 0 - /* It is legal to directly initialize from a CALL_EXPR - without going through X(X&), apparently. */ - && ! TYPE_GETS_INIT_REF (type) -#endif - ) - { - /* A CALL_EXPR is a legitmate form of initialization, so - we should not print this warning message. */ -#if 0 - /* Should have gone away due to 5/11/89 change. */ - if (TREE_CODE (TREE_TYPE (init)) == REFERENCE_TYPE) - init = convert_from_reference (init); -#endif -#if 0 - if (TYPE_GETS_ASSIGNMENT (type)) - warning ("bitwise copy: `%s' defines operator=()", - TYPE_NAME_STRING (type)); -#endif - expand_assignment (exp, init, 0, 0); - if (exp == DECL_RESULT (current_function_decl)) - { - /* Failing this assertion means that the return value - from receives multiple initializations. */ - assert (DECL_INITIAL (exp) == NULL_TREE || DECL_INITIAL (exp) == error_mark_node); - DECL_INITIAL (exp) = init; - } - return; - } - else if (init_type == type - && TREE_CODE (init) == COND_EXPR) - { - /* Push value to be initialized into the cond, where possible. - Avoid spurious warning messages when initializing the - result of this function. */ - TREE_OPERAND (init, 1) - = build_modify_expr (exp, INIT_EXPR, TREE_OPERAND (init, 1)); - if (exp == DECL_RESULT (current_function_decl)) - DECL_INITIAL (exp) = NULL_TREE; - TREE_OPERAND (init, 2) - = build_modify_expr (exp, INIT_EXPR, TREE_OPERAND (init, 2)); - if (exp == DECL_RESULT (current_function_decl)) - DECL_INITIAL (exp) = init; - expand_expr (init, const0_rtx, VOIDmode, 0); - return; - } - } - - /* We did not know what we were initializing before. Now we do. */ - if (TREE_CODE (init) == NEW_EXPR) - { - tree tmp = TREE_OPERAND (TREE_OPERAND (init, 1), 1); - - assert (tmp != NULL_TREE); - - if (TREE_CODE (TREE_VALUE (tmp)) == NOP_EXPR - && TREE_OPERAND (TREE_VALUE (tmp), 0) == integer_zero_node) - { - /* In order for this to work for RESULT_DECLs, if their - type has a constructor, then they must be BLKmode - so that they will be meaningfully addressable. */ - tree arg = build_unary_op (ADDR_EXPR, exp, 0); - init = TREE_OPERAND (init, 1); - init = build (CALL_EXPR, build_pointer_type (TREE_TYPE (init)), - TREE_OPERAND (init, 0), TREE_OPERAND (init, 1), 0); - TREE_VOLATILE (init) = 1; -#if 0 - TREE_RAISES (init) = ?? -#endif - TREE_VALUE (TREE_OPERAND (init, 1)) - = convert_pointer_to (TREE_TYPE (TREE_TYPE (TREE_VALUE (tmp))), arg); - - if (alias_this) - { - expand_assignment (current_function_decl, init, 0, 0); - return; - } - if (exp == DECL_RESULT (current_function_decl)) - { - if (DECL_INITIAL (DECL_RESULT (current_function_decl))) - fatal ("return value from function receives multiple initializations"); - DECL_INITIAL (exp) = init; - } - expand_expr_stmt (init); - return; - } - } - - /* Handle this case: when calling a constructor: xyzzy foo(bar); - which really means: xyzzy foo = bar; Ugh! - - We can also be called with an initializer for an object - which has virtual functions, but no constructors. In that - case, we perform the assignment first, then initialize - the virtual function table pointer fields. */ - - if (! TYPE_NEEDS_CONSTRUCTING (type)) - { - if (init_list && TREE_CHAIN (init_list)) - { - warning ("initializer list being treated as compound expression"); - init = convert (TREE_TYPE (exp), build_compound_expr (init_list)); - if (init == error_mark_node) - return; - } - if (TREE_CODE (exp) == VAR_DECL - && TREE_CODE (init) == CONSTRUCTOR - && TREE_HAS_CONSTRUCTOR (init)) - store_init_value (exp, init); - else - expand_assignment (exp, init, 0, 0); - - if (TYPE_VIRTUAL_P (type)) - expand_recursive_init (for_type, true_exp, exp, init, CLASSTYPE_BASE_INIT_LIST (type), alias_this); - return; - } - - /* See whether we can go through a type conversion operator. - This wins over going through a constructor because we may be - able to avoid an X(X&) constructor. */ - if (TREE_CODE (init) != TREE_LIST) - { - tree ttype = TREE_CODE (init_type) == REFERENCE_TYPE - ? TREE_TYPE (init_type) : init_type; - - if (ttype != type && IS_AGGR_TYPE (ttype)) - { - tree rval = build_type_conversion (CONVERT_EXPR, type, init, 0); - - if (rval) - { - expand_assignment (exp, rval, 0, 0); - return; - } - } - } - } - - if (TYPE_HAS_CONSTRUCTOR (type)) - { - /* It fails because there may not be a constructor which takes - its own type as the first (or only parameter), but which does - take other types via a conversion. So, if the thing initializing - the expression is a unit element of type X, first try X(X&), - followed by initialization by X. If neither of these work - out, then look hard. */ - tree parms = (init == NULL_TREE || TREE_CODE (init) == TREE_LIST) - ? init : build_tree_list (NULL_TREE, init); - int xxref_init_possible; - - if (parms) init = TREE_VALUE (parms); - - if (TYPE_HAS_INIT_REF (type) - || init == NULL_TREE - || TREE_CHAIN (parms) != NULL_TREE) - xxref_init_possible = 0; - else - { - xxref_init_possible = LOOKUP_SPECULATIVELY; - flags &= ~LOOKUP_COMPLAIN; - } - - if (TYPE_USES_VIRTUAL_BASECLASSES (type)) - { - assert (TYPE_USES_VIRTUAL_BASECLASSES (for_type)); - if (true_exp == exp) - parms = tree_cons (NULL_TREE, integer_one_node, parms); - else - parms = tree_cons (NULL_TREE, integer_zero_node, parms); - flags |= LOOKUP_HAS_IN_CHARGE; - } - rval = build_method_call (exp, DECL_NAME (TYPE_NAME (type)), parms, - CLASSTYPE_AS_LIST (for_type), flags|xxref_init_possible); - if (rval == NULL_TREE && xxref_init_possible) - { - tree init_type = TREE_TYPE (init); - if (TREE_CODE (init_type) == REFERENCE_TYPE) - init_type = TREE_TYPE (init_type); - if (TYPE_MAIN_VARIANT (init_type) == TYPE_MAIN_VARIANT (type) - || (IS_AGGR_TYPE (init_type) - && get_base_type (type, init_type, 0))) - { - if (type == for_type - && TYPE_USES_VIRTUAL_BASECLASSES (type)) - { - tree addr = build_unary_op (ADDR_EXPR, exp, 0); - expand_aggr_vbase_init (type, exp, addr, NULL_TREE); - - expand_expr_stmt (build_vbase_vtables_init (type, type, exp, addr, 1)); -#ifdef sparc - expand_asm_operands (build_string (32, "! end of vtable initialization"), 0, 0, 0, 0, input_filename, lineno); -#endif - } - expand_expr_stmt (build_modify_expr (exp, INIT_EXPR, init)); - return; - } - else - rval = build_method_call (exp, DECL_NAME (TYPE_NAME (type)), parms, - CLASSTYPE_AS_LIST (for_type), flags); - } - - /* Private, protected, or otherwise unavailable. */ - if (rval == error_mark_node && (flags&LOOKUP_COMPLAIN)) - error_with_aggr_type (for_type, "in base initialization for class `%s'"); - /* A valid initialization using constructor. */ - else if (rval != error_mark_node && rval != NULL_TREE) - { - /* p. 222: if the base class assigns to `this', then that - value is used in the derived class. */ - if ((flag_this_is_variable & 1) && alias_this) - { - TREE_TYPE (rval) = TREE_TYPE (current_class_decl); - expand_assignment (current_class_decl, rval, 0, 0); - } - else - expand_expr_stmt (rval); - } - else if (parms && TREE_CHAIN (parms) == NULL_TREE) - { - /* If we are initializing one aggregate value - from another, and though there are constructors, - and none accept the initializer, just do a bitwise - copy. - - @@ This should reject initializer which a constructor - @@ rejected on visibility gounds, but there is - @@ no way right now to recognize that case with - @@ just `error_mark_node'. */ - tree itype; - init = TREE_VALUE (parms); - itype = TREE_TYPE (init); - if (TREE_CODE (itype) == REFERENCE_TYPE) - { - init = convert_from_reference (init); - itype = TREE_TYPE (init); - } - itype = TYPE_MAIN_VARIANT (itype); - if (comptypes (TYPE_MAIN_VARIANT (type), itype, 0)) - { - warning ("bitwise copy in initialization of type `%s'", - TYPE_NAME_STRING (type)); - rval = build (INIT_EXPR, type, exp, init); - expand_expr_stmt (rval); - } - else - { - error_with_aggr_type (for_type, "in base initialization for class `%s',"); - error_with_aggr_type (type, "invalid initializer to constructor for type `%s'"); - return; - } - } - else - { - if (init == NULL_TREE) - assert (parms == NULL_TREE); - if (parms == NULL_TREE && TREE_VIA_VIRTUAL (for_type)) - error_with_aggr_type (for_type, "virtual baseclass `%s' does not have default initializer"); - else - { - error_with_aggr_type (for_type, "in base initialization for class `%s',"); - /* This will make an error message for us. */ - build_method_call (exp, DECL_NAME (TYPE_NAME (type)), parms, - CLASSTYPE_AS_LIST (for_type), - (TYPE_USES_VIRTUAL_BASECLASSES (type) - ? LOOKUP_NORMAL|LOOKUP_HAS_IN_CHARGE - : LOOKUP_NORMAL)); - } - return; - } - /* Constructor has been called, but vtables may be for TYPE - rather than for FOR_TYPE. */ - } - else if (TREE_CODE (type) == ARRAY_TYPE) - { - if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (type))) - expand_vec_init (exp, exp, array_type_nelts (type), init, 0); - else if (TYPE_VIRTUAL_P (TREE_TYPE (type))) - sorry ("arrays of objects with virtual functions but no constructors"); - } - else - expand_recursive_init (for_type, true_exp, exp, init, CLASSTYPE_BASE_INIT_LIST (type), alias_this); -} - -/* A pointer which holds the initializer. First call to - expand_aggr_init gets this value pointed to, and sets it to init_null. */ -static tree *init_ptr, init_null; - -/* Subroutine of expand_recursive_init: - - ADDR is the address of the expression being initialized. - INIT_LIST is the cons-list of initializations to be performed. - ALIAS_THIS is its same, lovable self. */ -static void -expand_recursive_init_1 (for_type, true_exp, addr, init_list, alias_this) - tree for_type, true_exp, addr; - tree init_list; - int alias_this; -{ - while (init_list) - { - if (TREE_PURPOSE (init_list)) - { - if (TREE_CODE (TREE_PURPOSE (init_list)) == FIELD_DECL) - { - tree member = TREE_PURPOSE (init_list); - tree subexp = build_indirect_ref (convert_pointer_to (TREE_VALUE (init_list), addr), 0); - tree member_base = build (COMPONENT_REF, TREE_TYPE (member), subexp, member); - if (IS_AGGR_TYPE (TREE_TYPE (member))) - expand_aggr_init (member_base, DECL_INITIAL (member), 0); - else if (TREE_CODE (TREE_TYPE (member)) == ARRAY_TYPE - && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (member))) - { - member_base = save_expr (default_conversion (member_base)); - expand_vec_init (member, member_base, - array_type_nelts (TREE_TYPE (member)), - DECL_INITIAL (member), 0); - } - else expand_expr_stmt (build_modify_expr (member_base, INIT_EXPR, DECL_INITIAL (member))); - } - else if (TREE_CODE (TREE_PURPOSE (init_list)) == TREE_LIST) - { - expand_recursive_init_1 (for_type, true_exp, addr, TREE_PURPOSE (init_list), alias_this); - expand_recursive_init_1 (for_type, true_exp, addr, TREE_VALUE (init_list), alias_this); - } - else if (TREE_CODE (TREE_PURPOSE (init_list)) == ERROR_MARK) - { - /* Only initialize the virtual function tables if we - are initializing the ultimate users of those vtables. */ - if (TREE_VALUE (init_list)) - { - expand_expr_stmt (build_virtual_init (for_type, TREE_VALUE (init_list), addr)); - if (TREE_VALUE (init_list) == for_type - && TYPE_USES_VIRTUAL_BASECLASSES (for_type)) - expand_expr_stmt (build_vbase_vtables_init (for_type, TREE_VALUE (init_list), true_exp, addr, 1)); -#ifdef sparc - expand_asm_operands (build_string (32, "! end of vtable initialization"), 0, 0, 0, 0, input_filename, lineno); -#endif - } - } - else abort (); - } - else if (TREE_VALUE (init_list) - && TREE_CODE (TREE_VALUE (init_list)) == RECORD_TYPE) - { - tree subexp = build_indirect_ref (convert_pointer_to (TREE_VALUE (init_list), addr), 0); - expand_aggr_init_1 (for_type, true_exp, subexp, *init_ptr, - alias_this && ! DECL_OFFSET (TYPE_NAME (TREE_VALUE (init_list))), - LOOKUP_PROTECTED_OK|LOOKUP_COMPLAIN); - - /* INIT_PTR is used up. */ - init_ptr = &init_null; - } - else - abort (); - init_list = TREE_CHAIN (init_list); - } -} - -/* Initialize EXP with INIT. Type EXP does not have a constructor, - but it has a baseclass with a constructor or a virtual function - table which needs initializing. - - INIT_LIST is a cons-list describing what parts of EXP actually - need to be initialized. INIT is given to the *unique*, first - constructor within INIT_LIST. If there are multiple first - constructors, such as with multiple inheritance, INIT must - be zero or an ambiguity error is reported. - - ALIAS_THIS is passed from `expand_aggr_init'. See comments - there. */ - -static void -expand_recursive_init (for_type, true_exp, exp, init, init_list, alias_this) - tree for_type, true_exp, exp, init; - tree init_list; - int alias_this; -{ - tree *old_init_ptr = init_ptr; - tree addr = build_unary_op (ADDR_EXPR, exp, 0); - init_ptr = &init; - - if (true_exp == exp && TYPE_USES_VIRTUAL_BASECLASSES (for_type)) - { - expand_aggr_vbase_init (for_type, exp, addr, init_list); - expand_expr_stmt (build_vbase_vtables_init (for_type, for_type, true_exp, addr, 1)); - } - expand_recursive_init_1 (for_type, true_exp, addr, init_list, alias_this); - - if (*init_ptr) - { - tree type = TREE_TYPE (exp); - - if (TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); - if (IS_AGGR_TYPE (type)) - error_with_aggr_type (type, "unexpected argument to constructor `%s'"); - else - error ("unexpected argument to constructor"); - } - init_ptr = old_init_ptr; -} - -/* Report an error if NAME is not the name of a user-defined, - aggregate type. If OR_ELSE is nonzero, give an error message. */ -int -is_aggr_typedef (name, or_else) - tree name; -{ - tree type = TREE_TYPE (name); - - if (type == NULL_TREE || TREE_CODE (type) != TYPE_DECL) - { - if (or_else) - error ("`%s' fails to be an aggregate typedef", - IDENTIFIER_POINTER (name)); - return 0; - } - type = TREE_TYPE (type); - if (! IS_AGGR_TYPE (type)) - { - fatal ("type `%s' is of non-aggregate type", - IDENTIFIER_POINTER (name)); - return 0; - } - return 1; -} - -/* This code could just as well go in `cplus-class.c', but is placed here for - modularity. */ - -/* For an expression of the form CNAME :: NAME (PARMLIST), build - the appropriate function call. */ -tree -build_member_call (cname, name, parmlist) - tree cname, name, parmlist; -{ - tree type, t; - tree method_name = name; - int dtor = 0; - int dont_use_this = 0; - tree basetype_path, decl; - - if (TREE_CODE (method_name) == BIT_NOT_EXPR) - { - method_name = TREE_OPERAND (method_name, 0); - dtor = 1; - } - - if (TREE_CODE (cname) == SCOPE_REF) - { - sorry ("multiple scope qualifications in build_member_call"); - return error_mark_node; - } - - if (! is_aggr_typedef (cname, 1)) - return error_mark_node; - - /* An operator we did not like. */ - if (name == NULL_TREE) - return error_mark_node; - - if (dtor) - { - if (! TYPE_HAS_DESTRUCTOR (TREE_TYPE (TREE_TYPE (cname)))) - error ("type `%s' does not have a destructor", - IDENTIFIER_POINTER (cname)); - else - error ("destructor specification error"); - return error_mark_node; - } - - if (TREE_CODE (name) == OP_IDENTIFIER) - method_name = build_operator_fnname (&name, parmlist, 1); - type = TREE_TYPE (TREE_TYPE (cname)); - - /* No object? Then just fake one up, and let build_method_call - figure out what to do. */ - if (current_class_type == 0 - || get_base_distance (type, current_class_type, 0, &basetype_path) == -1) - dont_use_this = 1; - - if (dont_use_this) - { - basetype_path = NULL_TREE; - decl = build1 (NOP_EXPR, - TYPE_POINTER_TO (TREE_TYPE (TREE_TYPE (cname))), - error_mark_node); - } - else if (current_class_decl == 0) - { - dont_use_this = 1; - decl = build1 (NOP_EXPR, - TYPE_POINTER_TO (TREE_TYPE (TREE_TYPE (cname))), - error_mark_node); - } - else decl = current_class_decl; - - if (t = lookup_fnfields (CLASSTYPE_AS_LIST (type), method_name, 0)) - return build_method_call (decl, method_name, parmlist, basetype_path, - LOOKUP_NORMAL|LOOKUP_NONVIRTUAL); - if (TREE_CODE (name) == IDENTIFIER_NODE - && (t = lookup_field (CLASSTYPE_AS_LIST (type), name, 1))) - { - if (t == error_mark_node) - return error_mark_node; - if (TREE_CODE (t) == FIELD_DECL) - { - if (dont_use_this) - { - error ("invalid use of non-static field `%s'", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - decl = build (COMPONENT_REF, TREE_TYPE (t), decl, t); - } - else if (TREE_CODE (t) == VAR_DECL) - decl = t; - else - { - error ("invalid use of member `%s::%s'", - IDENTIFIER_POINTER (cname), name); - return error_mark_node; - } - return build_opfncall (CALL_EXPR, LOOKUP_NORMAL, decl, parmlist); - } - else - { - char *err_name; - if (TREE_CODE (name) == OP_IDENTIFIER) - { - char *op_name = operator_name_string (method_name); - err_name = (char *)alloca (13 + strlen (op_name)); - sprintf (err_name, "operator %s", op_name); - } - else if (TREE_CODE (name) == IDENTIFIER_NODE) - err_name = IDENTIFIER_POINTER (name); - else - abort (); - - error ("no method `%s::%s'", IDENTIFIER_POINTER (cname), err_name); - return error_mark_node; - } -} - -/* Build a reference to a member of an aggregate. This is not a - C++ `&', but really something which can have its address taken, - and then act as a pointer to member, for example CNAME :: FIELD - can have its address taken by saying & CNAME :: FIELD. - - @@ Prints out lousy diagnostics for operator - @@ fields. - - @@ This function should be rewritten and placed in cplus-search.c. */ -tree -build_offset_ref (cname, name) - tree cname, name; -{ - tree decl, type, fnfields, fields, t = error_mark_node; - tree basetypes = NULL_TREE; - int dtor = 0; - - if (TREE_CODE (cname) == SCOPE_REF) - { - sorry ("multiple scope qualifications in build_offset_ref"); - return error_mark_node; - } - - if (! is_aggr_typedef (cname, 1)) - return error_mark_node; - - type = TREE_TYPE (TREE_TYPE (cname)); - - if (TREE_CODE (name) == BIT_NOT_EXPR) - { - dtor = 1; - name = TREE_OPERAND (name, 0); - } - - if (TYPE_SIZE (type) == 0) - { - t = IDENTIFIER_CLASS_VALUE (name); - if (t == 0) - { - error_with_aggr_type (type, "incomplete type `%s' does not have member `%s'", IDENTIFIER_POINTER (name)); - return error_mark_node; - } - if (TREE_CODE (t) == TYPE_DECL) - { - error_with_decl (t, "member `%s' is just a type declaration"); - return error_mark_node; - } - if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == CONST_DECL) - { - TREE_USED (t) = 1; - return t; - } - if (TREE_CODE (t) == FIELD_DECL) - sorry ("use of member in incomplete aggregate type"); - else if (TREE_CODE (t) == FUNCTION_DECL) - sorry ("use of member function in incomplete aggregate type"); - else - abort (); - return error_mark_node; - } - - /* Unresolved multi-arity operator. */ - if (TREE_CODE (name) == OP_IDENTIFIER) - { - t = copy_node (name); - TREE_TYPE (t) = unknown_type_node; - return t; - } - if (TREE_CODE (name) == TYPE_EXPR) - /* Pass a TYPE_DECL to build_component_type_expr. */ - return build_component_type_expr (TREE_TYPE (cname), name, NULL_TREE, 1); - - fnfields = lookup_fnfields (CLASSTYPE_AS_LIST (type), name, 0); - fields = lookup_field (type, name, 0); - - if (fields == error_mark_node) - return error_mark_node; - - if (fnfields) - { - basetypes = TREE_PURPOSE (fnfields); - - /* Go from the TREE_BASELINK to the member function info. */ - t = TREE_VALUE (fnfields); - - if (fields) - { - if (DECL_FIELD_CONTEXT (fields) == DECL_FIELD_CONTEXT (t)) - { - error ("ambiguous member reference: member `%s' defined as both field and function", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - if (get_base_type (DECL_FIELD_CONTEXT (fields), DECL_FIELD_CONTEXT (t), 0)) - ; - else if (get_base_type (DECL_FIELD_CONTEXT (t), DECL_FIELD_CONTEXT (fields), 0)) - t = fields; - else - { - error ("ambiguous member reference: member `%s' derives from distinct classes in multiple inheritance lattice"); - return error_mark_node; - } - } - - if (t == TREE_VALUE (fnfields)) - { - extern int flag_save_memoized_contexts; - - /* This does not handle visibility checking yet. */ - if (TREE_CHAIN (t) == NULL_TREE || dtor) - { - enum visibility_type visibility; - - /* unique functions are handled easily. */ - unique: - visibility = compute_visibility (basetypes, t); - if (visibility == visibility_protected) - { - error_with_decl (t, "member function `%s' is protected"); - error ("in this context"); - return error_mark_node; - } - if (visibility == visibility_private) - { - error_with_decl (t, "member function `%s' is private"); - error ("in this context"); - return error_mark_node; - } - return build (OFFSET_REF, TREE_TYPE (t), NULL_TREE, t); - } - - /* overloaded functions may need more work. */ - if (cname == name) - { - if (TYPE_HAS_DESTRUCTOR (type) - && TREE_CHAIN (TREE_CHAIN (t)) == NULL_TREE) - { - t = TREE_CHAIN (t); - goto unique; - } - } - if (flag_save_memoized_contexts - && !TREE_PERMANENT (fnfields) - && global_bindings_p ()) - fnfields = copy_list (fnfields); - t = build_tree_list (error_mark_node, fnfields); - TREE_TYPE (t) = build_member_type (type, unknown_type_node); - return t; - } - } - - /* Now that we know we are looking for a field, see if we - have access to that field. Lookup_field will give us the - error message. */ - - if (current_class_type == 0 - || get_base_distance (type, current_class_type, 0, &basetypes) == -1) - { - basetypes = CLASSTYPE_AS_LIST (type); - decl = build1 (NOP_EXPR, - TREE_TYPE (TREE_TYPE (cname)), - error_mark_node); - } - else if (current_class_decl == 0) - decl = build1 (NOP_EXPR, TREE_TYPE (TREE_TYPE (cname)), - error_mark_node); - else decl = C_C_D; - - t = lookup_field (basetypes, name, 1); - - if (t == error_mark_node) - return error_mark_node; - - if (t == NULL_TREE) - { - if (OPERATOR_TYPENAME_P (name)) - error ("type conversion operator not a member of type `%s'", - IDENTIFIER_POINTER (cname)); - else - error ("field `%s' is not a member of type `%s'", - IDENTIFIER_POINTER (name), - IDENTIFIER_POINTER (cname)); - return error_mark_node; - } - - if (TREE_CODE (t) == TYPE_DECL) - { - error_with_decl (t, "member `%s' is just a type declaration"); - return error_mark_node; - } - /* static class members and class-specific enum - values can be returned without further ado. */ - if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == CONST_DECL) - { - TREE_USED (t) = 1; - return t; - } - - /* static class functions too. */ - if (TREE_CODE (t) == FUNCTION_DECL && TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE) - abort (); - - /* In member functions, the form `cname::name' is no longer - equivalent to `this->cname::name'. */ - return build (OFFSET_REF, build_member_type (type, TREE_TYPE (t)), decl, t); -} - -/* Given an object EXP and a member function reference MEMBER, - return the address of the actual member function. */ -tree -get_member_function (exp_addr_ptr, exp, member) - tree *exp_addr_ptr; - tree exp, member; -{ - tree ctype = TREE_TYPE (exp); - tree function = save_expr (build_unary_op (ADDR_EXPR, member, 0)); - - if (TYPE_VIRTUAL_P (ctype) - || (flag_all_virtual == 1 - && (TYPE_OVERLOADS_METHOD_CALL_EXPR (ctype) - || TYPE_NEEDS_WRAPPER (ctype)))) - { - tree e0, e1, e3; - tree exp_addr; - - /* Save away the unadulterated `this' pointer. */ - exp_addr = save_expr (*exp_addr_ptr); - - /* Cast function to signed integer. */ - e0 = build1 (NOP_EXPR, integer_type_node, function); - -#ifdef VTABLE_USES_MASK - /* If we are willing to limit the number of - virtual functions a class may have to some - *small* number, then if, for a function address, - we are passed some small number, we know that - it is a virtual function index, and work from there. */ - e1 = build (BIT_AND_EXPR, integer_type_node, e0, vtbl_mask); -#else - /* There is a hack here that takes advantage of - twos complement arithmetic, and the fact that - there are more than one UNITS to the WORD. - If the high bit is set for the `function', - then we pretend it is a virtual function, - and the array indexing will knock this bit - out the top, leaving a valid index. */ -#if UNITS_PER_WORD <= 1 - virtual_functions_lose !; -#endif - e1 = build (GT_EXPR, integer_type_node, e0, integer_zero_node); - e1 = build_compound_expr (tree_cons (NULL_TREE, exp_addr, - build_tree_list (NULL_TREE, e1))); - e1 = save_expr (e1); -#endif - - if (TREE_VOLATILE (*exp_addr_ptr)) - { - exp = build_indirect_ref (exp_addr, 0); - *exp_addr_ptr = exp_addr; - } - - /* This is really hairy: if the function pointer is a pointer - to a non-virtual member function, then we can't go mucking - with the `this' pointer (any more than we aleady have to - this point). If it is a pointer to a virtual member function, - then we have to adjust the `this' pointer according to - what the virtual function table tells us. */ - - e3 = build_vfn_ref (exp_addr_ptr, exp, e0); - assert (e3 != error_mark_node); - - /* Change this pointer type from `void *' to the - type it is really supposed to be. */ - TREE_TYPE (e3) = TREE_TYPE (function); - - /* If non-virtual, use what we had originally. Otherwise, - use the value we get from the virtual function table. */ - *exp_addr_ptr = build_conditional_expr (e1, exp_addr, *exp_addr_ptr); - - function = build_conditional_expr (e1, function, e3); - } - return build_indirect_ref (function, 0); -} - -/* If a OFFSET_REF made it through to here, then it did - not have its address taken. */ - -tree -resolve_offset_ref (exp) - tree exp; -{ - tree base; - tree member; - tree basetype, addr; - - if (TREE_CODE (exp) == TREE_LIST) - return build_unary_op (ADDR_EXPR, exp, 0); - - assert (TREE_CODE (exp) == OFFSET_REF); - member = TREE_OPERAND (exp, 1); - if (TREE_STATIC (member)) - { - /* These were static members. */ - if (mark_addressable (member) == 0) - return error_mark_node; - return member; - } - - /* Syntax error can cause a member which should - have been seen as static to be grok'd as non-static. */ - if (TREE_CODE (member) == FIELD_DECL && C_C_D == NULL_TREE) - { - if (TREE_ADDRESSABLE (member) == 0) - { - error_with_decl (member, "member `%s' is non-static in static member function context"); - TREE_ADDRESSABLE (member) = 1; - } - return error_mark_node; - } - - base = TREE_OPERAND (exp, 0); - assert (base != NULL_TREE); - - /* The first case is really just a reference to a member of `this'. */ - if (TREE_CODE (member) == FIELD_DECL - && (base == C_C_D - || (TREE_CODE (base) == NOP_EXPR - && TREE_OPERAND (base, 0) == error_mark_node))) - { - tree basetype_path; - enum visibility_type visibility; - - basetype = DECL_CONTEXT (member); - if (get_base_distance (basetype, current_class_type, 0, &basetype_path) < 0) - { - error_not_base_type (basetype, current_class_type); - return error_mark_node; - } - addr = convert_pointer_to (basetype, current_class_decl); - visibility = compute_visibility (basetype_path, member); - if (visibility == visibility_public) - return build (COMPONENT_REF, TREE_TYPE (member), - build_indirect_ref (addr, 0), member); - if (visibility == visibility_protected) - { - error_with_decl ("member `%s' is protected"); - error ("in this context"); - return error_mark_node; - } - if (visibility == visibility_private) - { - error_with_decl ("member `%s' is private"); - error ("in this context"); - return error_mark_node; - } - abort (); - } - /* If this is a reference to a member function, then return - the address of the member function (which may involve going - through the object's vtable), otherwise, return an expression - for the derefernced pointer-to-member construct. */ - addr = build_unary_op (ADDR_EXPR, base, 0); - if (TREE_CODE (TREE_TYPE (member)) == METHOD_TYPE) - { - basetype = TYPE_METHOD_BASETYPE (TREE_TYPE (member)); - addr = convert_pointer_to (basetype, addr); - return build_unary_op (ADDR_EXPR, get_member_function (&addr, build_indirect_ref (addr, 0), member), 0); - } - else if (TREE_CODE (TREE_TYPE (member)) == OFFSET_TYPE) - { - basetype = TYPE_OFFSET_BASETYPE (TREE_TYPE (member)); - addr = convert_pointer_to (basetype, addr); - member = convert (ptr_type_node, build_unary_op (ADDR_EXPR, member, 0)); - return build1 (INDIRECT_REF, TREE_TYPE (exp), - build (PLUS_EXPR, ptr_type_node, addr, member)); - } - abort (); -} - -/* Return either DECL or its known constant value (if it has one). */ - -tree -decl_constant_value (decl) - tree decl; -{ - if ( -#if 0 - /* These may be necessary for C, but they break C++. */ - ! TREE_PUBLIC (decl) - /* Don't change a variable array bound or initial value to a constant - in a place where a variable is invalid. */ - && current_function_decl != 0 - && ! pedantic - && -#endif /* 0 */ - ! TREE_THIS_VOLATILE (decl) - && DECL_INITIAL (decl) != 0 - && TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK - /* This is invalid if initial value is not constant. - If it has either a function call, a memory reference, - or a variable, then re-evaluating it could give different results. */ - && TREE_LITERAL (DECL_INITIAL (decl)) -#if 0 - /* Check for cases where this is sub-optimal, even though valid. */ - && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR - && DECL_MODE (decl) != BLKmode -#endif - ) - return DECL_INITIAL (decl); - return decl; -} - -/* Friend handling routines. */ -/* Friend data structures: - - Friend lists come from TYPE_DECL nodes. Since all aggregate - types are automatically typedef'd, these node are guaranteed - to exist. - - The TREE_PURPOSE of a friend list is the name of the friend, - and its TREE_VALUE is another list. - - The TREE_PURPOSE of that list is a type, which allows - all functions of a given type to be friends. - The TREE_VALUE of that list is an individual function - which is a friend. - - Non-member friends will match only by their DECL. Their - member type is NULL_TREE, while the type of the inner - list will either be of aggregate type or error_mark_node. */ - -/* Tell if this function specified by FUNCTION_DECL - can be a friend of type TYPE. - Return nonzero if friend, zero otherwise. - - DECL can be zero if we are calling a constructor or accessing a - member in global scope. */ -int -is_friend (type, decl) - tree type, decl; -{ - tree typedecl = TYPE_NAME (type); - tree ctype = NULL_TREE; - tree list; - tree name; - - if (decl == NULL_TREE) - return 0; - - if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE) - ctype = TYPE_METHOD_BASETYPE (TREE_TYPE (decl)); - else if (DECL_STATIC_FUNCTION_P (decl)) - ctype = DECL_CONTEXT (decl); - if (ctype) - { - list = CLASSTYPE_FRIEND_CLASSES (TREE_TYPE (typedecl)); - while (list) - { - if (ctype == TREE_VALUE (list)) - return 1; - list = TREE_CHAIN (list); - } - } - - list = DECL_FRIENDLIST (typedecl); - name = DECL_ORIGINAL_NAME (decl); - while (list) - { - if (name == TREE_PURPOSE (list)) - { - tree friends = TREE_VALUE (list); - name = DECL_NAME (decl); - while (friends) - { - if (ctype == TREE_PURPOSE (friends)) - return 1; - if (name == DECL_NAME (TREE_VALUE (friends))) - return 1; - friends = TREE_CHAIN (friends); - } - return 0; - } - list = TREE_CHAIN (list); - } - return 0; -} - -/* Add a new friend to the friends of the aggregate type TYPE. - DECL is the FUNCTION_DECL of the friend being added. */ -static void -add_friend (type, decl) - tree type, decl; -{ - tree typedecl = TYPE_NAME (type); - tree list = DECL_FRIENDLIST (typedecl); - tree name = DECL_ORIGINAL_NAME (decl); - tree ctype = TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE - ? TYPE_METHOD_BASETYPE (TREE_TYPE (decl)) : error_mark_node; - - while (list) - { - if (name == TREE_PURPOSE (list)) - { - tree friends = TREE_VALUE (list); - while (friends) - { - if (decl == TREE_VALUE (friends)) - { - warning_with_decl (decl, "`%s' is already a friend of class `%s'", IDENTIFIER_POINTER (DECL_NAME (typedecl))); - return; - } - friends = TREE_CHAIN (friends); - } - TREE_VALUE (list) = tree_cons (ctype, decl, TREE_VALUE (list)); - return; - } - list = TREE_CHAIN (list); - } - DECL_FRIENDLIST (typedecl) - = tree_cons (DECL_ORIGINAL_NAME (decl), - build_tree_list (error_mark_node, decl), - DECL_FRIENDLIST (typedecl)); - if (! strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), - OPERATOR_MODIFY_FORMAT, - OPERATOR_MODIFY_LENGTH)) - { - tree parmtypes = TYPE_ARG_TYPES (TREE_TYPE (decl)); - TYPE_HAS_ASSIGNMENT (TREE_TYPE (typedecl)) = 1; - TYPE_GETS_ASSIGNMENT (TREE_TYPE (typedecl)) = 1; - if (parmtypes && TREE_CHAIN (parmtypes)) - { - tree parmtype = TREE_VALUE (TREE_CHAIN (parmtypes)); - if (TREE_CODE (parmtype) == REFERENCE_TYPE - && TREE_TYPE (parmtypes) == TREE_TYPE (typedecl)) - { - TYPE_HAS_ASSIGN_REF (TREE_TYPE (typedecl)) = 1; - TYPE_GETS_ASSIGN_REF (TREE_TYPE (typedecl)) = 1; - } - } - } -} - -/* Declare that every member function NAME in FRIEND_TYPE - (which may be NULL_TREE) is a friend of type TYPE. */ -static void -add_friends (type, name, friend_type) - tree type, name, friend_type; -{ - tree typedecl = TYPE_NAME (type); - tree list = DECL_FRIENDLIST (typedecl); - - while (list) - { - if (name == TREE_PURPOSE (list)) - { - tree friends = TREE_VALUE (list); - while (friends && TREE_PURPOSE (friends) != friend_type) - friends = TREE_CHAIN (friends); - if (friends) - if (friend_type) - warning ("method `%s::%s' is already a friend of class", - TYPE_NAME_STRING (friend_type), - IDENTIFIER_POINTER (name)); - else - warning ("function `%s' is already a friend of class `%s'", - IDENTIFIER_POINTER (name), - IDENTIFIER_POINTER (DECL_NAME (typedecl))); - else - TREE_VALUE (list) = tree_cons (friend_type, NULL_TREE, - TREE_VALUE (list)); - return; - } - list = TREE_CHAIN (list); - } - DECL_FRIENDLIST (typedecl) = - tree_cons (name, - build_tree_list (friend_type, NULL_TREE), - DECL_FRIENDLIST (typedecl)); - if (! strncmp (name, OPERATOR_MODIFY_FORMAT, OPERATOR_MODIFY_LENGTH)) - { - TYPE_HAS_ASSIGNMENT (TREE_TYPE (typedecl)) = 1; - TYPE_GETS_ASSIGNMENT (TREE_TYPE (typedecl)) = 1; - sorry ("declaring \"friend operator =\" will not find \"operator = (X&)\" if it exists"); - } -} - -/* Set up a cross reference so that type TYPE will - make member function CTYPE::DECL a friend when CTYPE - is finally defined. */ -void -xref_friend (type, decl, ctype) - tree type, decl, ctype; -{ - tree typedecl = TYPE_NAME (type); - tree friend_decl = TYPE_NAME (ctype); - tree t = tree_cons (NULL_TREE, ctype, DECL_UNDEFINED_FRIENDS (typedecl)); - - DECL_UNDEFINED_FRIENDS (typedecl) = t; - SET_DECL_WAITING_FRIENDS (friend_decl, tree_cons (type, t, DECL_WAITING_FRIENDS (friend_decl))); - TREE_TYPE (DECL_WAITING_FRIENDS (friend_decl)) = decl; -} - -/* Set up a cross reference so that functions with name NAME and - type CTYPE know that they are friends of TYPE. */ -void -xref_friends (type, name, ctype) - tree type, name, ctype; -{ - tree typedecl = TYPE_NAME (type); - tree friend_decl = TYPE_NAME (ctype); - tree t = tree_cons (NULL_TREE, ctype, - DECL_UNDEFINED_FRIENDS (typedecl)); - - DECL_UNDEFINED_FRIENDS (typedecl) = t; - SET_DECL_WAITING_FRIENDS (friend_decl, tree_cons (type, t, DECL_WAITING_FRIENDS (friend_decl))); - TREE_TYPE (DECL_WAITING_FRIENDS (friend_decl)) = name; -} - -/* Make FRIEND_TYPE a friend class to TYPE. If FRIEND_TYPE has already - been defined, we make all of its member functions friends of - TYPE. If not, we make it a pending friend, which can later be added - when its definition is seen. If a type is defined, then its TYPE_DECL's - DECL_UNDEFINED_FRIENDS contains a (possibly empty) list of friend - classes that are not defined. If a type has not yet been defined, - then the DECL_WAITING_FRIENDS contains a list of types - waiting to make it their friend. Note that these two can both - be in use at the same time! */ -void -make_friend_class (type, friend_type) - tree type, friend_type; -{ - tree classes; - - if (type == friend_type) - { - warning ("class `%s' is implicitly friends with itself", - TYPE_NAME_STRING (type)); - return; - } - -#ifdef FIELD_XREF - FIELD_xref_hier(TYPE_NAME_STRING(type), - TYPE_NAME_STRING(friend_type),0,0,1); -#endif - - classes = CLASSTYPE_FRIEND_CLASSES (type); - while (classes && TREE_VALUE (classes) != friend_type) - classes = TREE_CHAIN (classes); - if (classes) - warning ("class `%s' is already friends with class `%s'", - TYPE_NAME_STRING (TREE_VALUE (classes)), TYPE_NAME_STRING (type)); - else - { - CLASSTYPE_FRIEND_CLASSES (type) - = tree_cons (NULL_TREE, friend_type, CLASSTYPE_FRIEND_CLASSES (type)); - } -} - -/* Main friend processor. This is large, and for modularity purposes, - has been removed from grokdeclarator. It returns `void_type_node' - to indicate that something happened, though a FIELD_DECL is - not returned. - - CTYPE is the class this friend belongs to. - - DECLARATOR is the name of the friend. - - DECL is the FUNCTION_DECL that the friend is. - - In case we are parsing a friend which is part of an inline - definition, we will need to store PARM_DECL chain that comes - with it into the DECL_ARGUMENTS slot of the FUNCTION_DECL. - - FLAGS is just used for `grokclassfn'. - - QUALS say what special qualifies should apply to the object - pointed to by `this'. */ -tree -do_friend (ctype, declarator, decl, parmdecls, flags, quals) - tree ctype, declarator, decl, parmdecls; - enum overload_flags flags; - tree quals; -{ - if (ctype) - { - tree cname = TYPE_NAME (ctype); - if (TREE_CODE (cname) == TYPE_DECL) - cname = DECL_NAME (cname); - - /* A method friend. */ - if (TREE_CODE (decl) == FUNCTION_DECL) - { - if (flags == NO_SPECIAL && ctype && declarator == cname) - DECL_CONSTRUCTOR_P (decl) = 1; - - /* This will set up DECL_ARGUMENTS for us. */ - grokclassfn (ctype, cname, decl, flags, TYPE_SIZE (ctype) != 0, quals); - if (TREE_TYPE (decl) != error_mark_node) - { - if (TYPE_SIZE (ctype)) - { - /* We don't call pushdecl here yet, or ever on this - actual FUNCTION_DECL. We must preserve its TREE_CHAIN - until the end. */ - make_decl_rtl (decl, NULL_TREE, 1); - add_friend (current_class_type, decl); - } - else - xref_friend (current_class_type, decl, ctype); - DECL_FRIEND_P (decl) = 1; - } - } - else - { - /* Possibly a bunch of method friends. */ - - /* Get the class they belong to. */ - tree ctype = TREE_TYPE (TREE_TYPE (cname)); - - /* This class is defined, use its methods now. */ - if (TYPE_SIZE (ctype)) - { - tree fields = lookup_fnfields (CLASSTYPE_AS_LIST (ctype), declarator, 0); - if (fields) - add_friends (current_class_type, declarator, ctype); - else - error ("method `%s' is not a member of class `%s'", - IDENTIFIER_POINTER (declarator), - IDENTIFIER_POINTER (cname)); - } - else - xref_friends (current_class_type, declarator, ctype); - decl = void_type_node; - } - } - else if (TREE_CODE (decl) == FUNCTION_DECL - && ((IDENTIFIER_LENGTH (declarator) == 4 - && IDENTIFIER_POINTER (declarator)[0] == 'm' - && ! strcmp (IDENTIFIER_POINTER (declarator), "main")) - || (IDENTIFIER_LENGTH (declarator) > 10 - && IDENTIFIER_POINTER (declarator)[0] == '_' - && IDENTIFIER_POINTER (declarator)[1] == '_' - && strncmp (IDENTIFIER_POINTER (declarator)+2, - "builtin_", 8) == 0))) - { - /* raw "main", and builtin functions never gets overloaded, - but they can become friends. */ - TREE_PUBLIC (decl) = 1; - add_friend (current_class_type, decl); - DECL_FRIEND_P (decl) = 1; - if (IDENTIFIER_POINTER (declarator)[0] == '_') - { - if (! strcmp (IDENTIFIER_POINTER (declarator)+10, "new")) - TREE_GETS_NEW (current_class_type) = 0; - else if (! strcmp (IDENTIFIER_POINTER (declarator)+10, "delete")) - TREE_GETS_DELETE (current_class_type) = 0; - } - decl = void_type_node; - } - /* A global friend. - @@ or possibly a friend from a base class ?!? */ - else if (TREE_CODE (decl) == FUNCTION_DECL) - { - /* Friends must all go through the overload machinery, - even though they may not technically be overloaded. - - Note that because classes all wind up being top-level - in their scope, their friend wind up in top-level scope as well. */ - DECL_NAME (decl) = - build_decl_overload (IDENTIFIER_POINTER (declarator), - TYPE_ARG_TYPES (TREE_TYPE (decl)), - TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE); - DECL_ASSEMBLER_NAME (decl) = IDENTIFIER_POINTER (DECL_NAME (decl)); - DECL_ARGUMENTS (decl) = parmdecls; - /* We can call pushdecl here, because the TREE_CHAIN of this - FUNCTION_DECL is not needed for other purposes. */ - decl = pushdecl_top_level (decl); - - make_decl_rtl (decl, NULL_TREE, 1); - add_friend (current_class_type, decl); - - if (! TREE_OVERLOADED (declarator) - && IDENTIFIER_GLOBAL_VALUE (declarator) - && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (declarator)) == FUNCTION_DECL) - { - error ("friend `%s' implicitly overloaded", - IDENTIFIER_POINTER (declarator)); - error_with_decl (IDENTIFIER_GLOBAL_VALUE (declarator), - "after declaration of non-overloaded `%s'"); - } - DECL_FRIEND_P (decl) = 1; - DECL_OVERLOADED (decl) = 1; - TREE_OVERLOADED (declarator) = 1; - push_overloaded_decl (decl); - } - else - { - /* @@ Should be able to ingest later definitions of this function - before use. */ - tree decl = IDENTIFIER_GLOBAL_VALUE (declarator); - if (decl == NULL_TREE) - { - warning ("implicitly declaring `%s' as struct", - IDENTIFIER_POINTER (declarator)); - decl = xref_tag (record_type_node, declarator, NULL_TREE); - decl = TYPE_NAME (decl); - } - - /* Allow abbreviated declarations of overloaded functions, - but not if those functions are really class names. */ - if (TREE_CODE (decl) == TREE_LIST && TREE_TYPE (TREE_PURPOSE (decl))) - { - warning ("`friend %s' archaic, use `friend class %s' instead", - IDENTIFIER_POINTER (declarator), - IDENTIFIER_POINTER (declarator)); - decl = TREE_TYPE (TREE_PURPOSE (decl)); - } - - if (TREE_CODE (decl) == TREE_LIST) - add_friends (current_class_type, TREE_PURPOSE (decl), NULL_TREE); - else - make_friend_class (current_class_type, TREE_TYPE (decl)); - decl = void_type_node; - } - return decl; -} - -/* TYPE has now been defined. It may, however, have a number of things - waiting make make it their friend. We resolve these references - here. */ -void -embrace_waiting_friends (type) - tree type; -{ - tree decl = TYPE_NAME (type); - tree waiters; - - if (TREE_CODE (decl) != TYPE_DECL) - return; - - for (waiters = DECL_WAITING_FRIENDS (decl); waiters; - waiters = TREE_CHAIN (waiters)) - { - tree waiter = TREE_PURPOSE (waiters); - tree waiter_prev = TREE_VALUE (waiters); - tree decl = TREE_TYPE (waiters); - tree name = decl ? (TREE_CODE (decl) == IDENTIFIER_NODE - ? decl : DECL_ORIGINAL_NAME (decl)) : NULL_TREE; - if (name) - { - /* @@ There may be work to be done since we have not verified - @@ consistency between original and friend declarations - @@ of the functions waiting to become friends. */ - tree field = lookup_fnfields (CLASSTYPE_AS_LIST (type), name, 0); - if (field) - if (decl == name) - add_friends (waiter, name, type); - else - add_friend (waiter, decl); - else - error_with_file_and_line (DECL_SOURCE_FILE (TYPE_NAME (waiter)), - DECL_SOURCE_LINE (TYPE_NAME (waiter)), - "no method `%s' defined in class `%s' to be friend", - IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (TREE_TYPE (waiters))), - TYPE_NAME_STRING (type)); - } - else - make_friend_class (type, waiter); - - if (TREE_CHAIN (waiter_prev)) - TREE_CHAIN (waiter_prev) = TREE_CHAIN (TREE_CHAIN (waiter_prev)); - else - DECL_UNDEFINED_FRIENDS (TYPE_NAME (waiter)) = NULL_TREE; - } -} - -/* Generate a C++ "new" expression. DECL is either a TREE_LIST - (which needs to go through some sort of groktypename) or it - is the name of the class we are newing. INIT is an initialization value. - It is either an EXPRLIST, an EXPR_NO_COMMAS, or something in braces. - If INIT is void_type_node, it means do *not* call a constructor - for this instance. - - For types with constructors, the data returned is initialized - by the approriate constructor. - - Whether the type has a constructor or not, if it has a pointer - to a virtual function table, then that pointer is set up - here. - - Unless I am mistaken, a call to new () will return initialized - data regardless of whether the constructor itself is private or - not. - - PLACEMENT is the `placement' list for user-defined operator new (). */ - -tree -build_new (placement, decl, init, use_global_new) - tree placement; - tree decl, init; - int use_global_new; -{ - extern tree require_complete_type (); /* typecheck.c */ - tree type, true_type, size, rval; - tree init1 = NULL_TREE, nelts; - int has_call = 0, has_array = 0; - tree alignment = NULL_TREE; - tree pending_sizes = NULL_TREE; - - if (decl == error_mark_node) - return error_mark_node; - - if (TREE_CODE (decl) == TREE_LIST) - { - tree absdcl = TREE_VALUE (decl); - tree last_absdcl = NULL_TREE; - int old_immediate_size_expand; - - if (current_function_decl - && DECL_CONSTRUCTOR_P (current_function_decl)) - { - old_immediate_size_expand = immediate_size_expand; - immediate_size_expand = 0; - } - - nelts = integer_one_node; - - if (absdcl && TREE_CODE (absdcl) == CALL_EXPR) - { - /* probably meant to be a call */ - has_call = 1; - init1 = TREE_OPERAND (absdcl, 1); - absdcl = TREE_OPERAND (absdcl, 0); - TREE_VALUE (decl) = absdcl; - } - while (absdcl && TREE_CODE (absdcl) == INDIRECT_REF) - { - last_absdcl = absdcl; - absdcl = TREE_OPERAND (absdcl, 0); - } - - if (last_absdcl) - { - tree save_absdecl = TREE_VALUE (decl); - TREE_VALUE (decl) = last_absdcl; - true_type = groktypename (decl); - TREE_VALUE (decl) = save_absdecl; - } - else - true_type = groktypename (decl); - - while (absdcl && TREE_CODE (absdcl) == ARRAY_REF) - { - /* probably meant to be a vec new */ - tree this_nelts; - - has_array = 1; - this_nelts = save_expr (TREE_OPERAND (absdcl, 1)); - absdcl = TREE_OPERAND (absdcl, 0); - if (this_nelts == NULL_TREE) - error ("new of array type fails to specify size"); - else if (this_nelts == integer_zero_node) - { - warning ("zero size array reserves no space"); - nelts = integer_zero_node; - } - else - nelts = build_binary_op (MULT_EXPR, nelts, this_nelts); - } - - if (last_absdcl) - TREE_OPERAND (last_absdcl, 0) = absdcl; - else - TREE_VALUE (decl) = absdcl; - - type = groktypename (decl); - if (! type || type == error_mark_node - || true_type == error_mark_node) - return error_mark_node; - - type = TYPE_MAIN_VARIANT (type); - if (type == void_type_node) - { - error ("invalid type: `void []'"); - return error_mark_node; - } - if (current_function_decl - && DECL_CONSTRUCTOR_P (current_function_decl)) - { - pending_sizes = get_pending_sizes (); - immediate_size_expand = old_immediate_size_expand; - } - } - else if (TREE_CODE (decl) == IDENTIFIER_NODE) - { - if (TREE_TYPE (decl)) - { - /* An aggregate type. */ - decl = TREE_TYPE (decl); - type = TREE_TYPE (decl); - } - else - { - /* A builtin type. */ - decl = lookup_name (decl); - assert (TREE_CODE (decl) == TYPE_DECL); - type = TREE_TYPE (decl); - } - true_type = type; - } - else if (TREE_CODE (decl) == TYPE_DECL) - { - type = TREE_TYPE (decl); - true_type = type; - } - else - { - type = decl; - true_type = type; - decl = TYPE_NAME (type); - } - - if (TYPE_SIZE (type) == 0) - { - if (type == void_type_node) - error ("invalid type for new: `void'"); - else - incomplete_type_error (0, type); - return error_mark_node; - } - - if (TYPE_LANG_SPECIFIC (type) && CLASSTYPE_ABSTRACT_VIRTUALS (type)) - { - abstract_virtuals_error (NULL_TREE, type); - return error_mark_node; - } - - size = size_in_bytes (type); - if (has_array) - size = fold (build_binary_op (MULT_EXPR, size, nelts)); - - /* If this type has special alignment requirements, deal with them here. */ - if (TYPE_ALIGN (type) > BITS_PER_WORD) - { - alignment = fold (build (MINUS_EXPR, integer_type_node, - c_alignof (type), integer_one_node)); - size = fold (build (PLUS_EXPR, integer_type_node, size, alignment)); - } - - if (has_call) - init = init1; - - if (TREE_CODE (true_type) == ARRAY_TYPE) - type = TREE_TYPE (true_type); - else - type = true_type; - -#ifdef SOS - rval = NULL_TREE; - if (placement == void_type_node) - { - /* Simple "new dynamic" construct. */ - if (! IS_AGGR_TYPE (type)) - { - error ("dynamic new can only allocate objects of aggregate type"); - return error_mark_node; - } - else if (! is_aggr_typedef (DECL_NAME (TYPE_NAME (type)), 1)) - return error_mark_node; - else - rval = build_dynamic_new (type, size, NULL_TREE, init); - } - else if (placement && TREE_CODE (placement) == STRING_CST) - { - /* A "new dynamic" construct with filename argument. */ - if (! IS_AGGR_TYPE (type)) - { - error ("dynamic new can only allocate objects of aggregate type"); - return error_mark_node; - } - else if (! is_aggr_typedef (DECL_NAME (TYPE_NAME (type)), 1)) - return error_mark_node; - else - rval = build_dynamic_new (type, size, placement, init); - } - if (rval) - { - if (alignment) - { - rval = build (PLUS_EXPR, TYPE_POINTER_TO (type), rval, alignment); - rval = build (BIT_AND_EXPR, TYPE_POINTER_TO (type), - rval, build1 (BIT_NOT_EXPR, integer_type_node, alignment)); - } - goto done; - } -#endif - - if (has_array) - { - if (placement) - { - error ("placement syntax invalid for arrays"); - return error_mark_node; - } - rval = build (CALL_EXPR, build_pointer_type (type), - BIN, build_tree_list (NULL_TREE, size), 0); - if (alignment) - { - rval = build (PLUS_EXPR, TYPE_POINTER_TO (type), rval, alignment); - rval = build (BIT_AND_EXPR, TYPE_POINTER_TO (type), - rval, build1 (BIT_NOT_EXPR, integer_type_node, alignment)); - } - TREE_CALLS_NEW (rval) = 1; - TREE_VOLATILE (rval) = 1; - } - else - { - if (TYPE_LANG_SPECIFIC (type) - && (TREE_GETS_NEW (type) && !use_global_new)) - rval = build_opfncall (NEW_EXPR, LOOKUP_NORMAL, TYPE_POINTER_TO (type), size, placement); - else if (placement) - { - rval = build_opfncall (NEW_EXPR, LOOKUP_GLOBAL|LOOKUP_COMPLAIN, ptr_type_node, size, placement); - } - else if (flag_this_is_variable - && TYPE_HAS_CONSTRUCTOR (type) && init != void_type_node) - { - if (init == NULL_TREE || TREE_CODE (init) == TREE_LIST) - rval = NULL_TREE; - else - { - error ("constructors take parameter lists"); - return error_mark_node; - } - } - else - { - rval = build (CALL_EXPR, build_pointer_type (type), - BIN, build_tree_list (NULL_TREE, size), 0); - if (alignment) - { - rval = build (PLUS_EXPR, TYPE_POINTER_TO (type), rval, alignment); - rval = build (BIT_AND_EXPR, TYPE_POINTER_TO (type), - rval, build1 (BIT_NOT_EXPR, integer_type_node, alignment)); - } - TREE_CALLS_NEW (rval) = 1; - TREE_VOLATILE (rval) = 1; - } - /* We've figured out where the allocation is to go. - If we're not eliding constructors, then if a constructor - is defined, we must go through it. */ - if ((rval == NULL_TREE || !flag_elide_constructors) - && TYPE_HAS_CONSTRUCTOR (type) && init != void_type_node) - { - int flags = LOOKUP_NORMAL; - - if (rval && TYPE_USES_VIRTUAL_BASECLASSES (type)) - { - init = tree_cons (NULL_TREE, integer_one_node, init); - flags |= LOOKUP_HAS_IN_CHARGE; - } - rval = build_method_call (rval, DECL_NAME (TYPE_NAME (type)), init, - NULL_TREE, flags); - goto done; - } - } - if (rval == error_mark_node) - return error_mark_node; - rval = save_expr (rval); - TREE_HAS_CONSTRUCTOR (rval) = 1; - - /* Don't call any constructors or do any initialization. */ - if (init == void_type_node) - goto done; - - if (TYPE_NEEDS_CONSTRUCTING (type)) - { - extern tree static_aggregates; - - if (current_function_decl == NULL_TREE) - { - /* In case of static initialization, SAVE_EXPR is good enough. */ - init = copy_to_permanent (init); - rval = copy_to_permanent (rval); - static_aggregates = perm_tree_cons (init, rval, static_aggregates); - } - else - { - /* Have to wrap this in RTL_EXPR for two cases: - in base or member initialization and if we - are a branch of a ?: operator. Since we - can't easily know the latter, just do it always. */ - tree xval = make_node (RTL_EXPR); - - TREE_TYPE (xval) = TREE_TYPE (rval); - do_pending_stack_adjust (); - start_sequence (); - - /* As a matter of principle, `start_sequence' should do this. */ - emit_note (0, -1); - - if (has_array) - rval = expand_vec_init (decl, rval, - build_binary_op (MINUS_EXPR, nelts, integer_one_node), - init, 0); - else - expand_aggr_init (build_indirect_ref (rval, 0), init, 0); - - do_pending_stack_adjust (); - - TREE_VOLATILE (xval) = 1; - RTL_EXPR_SEQUENCE (xval) = get_insns (); - end_sequence (); - - if (TREE_CODE (rval) == SAVE_EXPR) - { - /* Errors may cause this to not get evaluated. */ - if (SAVE_EXPR_RTL (rval) == 0) - SAVE_EXPR_RTL (rval) = const0_rtx; - RTL_EXPR_RTL (xval) = SAVE_EXPR_RTL (rval); - } - else - { - assert (TREE_CODE (rval) == VAR_DECL); - RTL_EXPR_RTL (xval) = DECL_RTL (rval); - } - rval = xval; - } - } - else if (has_call || init) - { - if (IS_AGGR_TYPE (type)) - { - error_with_aggr_type (type, "no constructor for type `%s'"); - rval = error_mark_node; - } - else - { - /* New 2.0 interpretation: `new int (10)' means - allocate an int, and initialize it with 10. */ - init = build_c_cast (type, init); - rval = build (COMPOUND_EXPR, TREE_TYPE (rval), - build_modify_expr (build_indirect_ref (rval, 0), - NOP_EXPR, init), - rval); - TREE_VOLATILE (rval) = 1; - } - } - done: - if (pending_sizes) - rval = build_compound_expr (chainon (pending_sizes, - build_tree_list (NULL_TREE, rval))); - - return rval; -} - -#ifdef SOS -/* Build a "new dynamic" call for type TYPE. The size - of the object we are newing is SIZE. If "new dynamic" was - given with an argument, that argument is in NAME. - PARMS contains the parameters to the constructor. - The first parameter must be an `ImportRequest *'. - - This is slightly hairy, because we must find the correct - constructor by hand. */ -static tree -build_dynamic_new (type, size, name, parms) - tree type, size; - tree name, parms; -{ - tree import_parms, inner_parms; - tree import_ptr = integer_zero_node; - /* This variable is supposed to be the address of a "struct ref" - object, but how and where should it be defined? */ - tree lookup_tmp = integer_zero_node; - tree import_tmp = build_unary_op (ADDR_EXPR, get_temp_name (ptr_type_node, 0), 0); - - if (name) - { - inner_parms = tree_cons (NULL_TREE, name, - build_tree_list (NULL_TREE, integer_zero_node)); - inner_parms = tree_cons (NULL_TREE, lookup_tmp, inner_parms); - inner_parms = build_function_call (__sosLookup, inner_parms); - } - else - inner_parms = integer_zero_node; - - import_parms = build_tree_list (NULL_TREE, inner_parms); - - if (CLASSTYPE_DYNAMIC_FILENAME (type)) - { - inner_parms = tree_cons (NULL_TREE, CLASSTYPE_DYNAMIC_FILENAME (type), - build_tree_list (NULL_TREE, integer_zero_node)); - inner_parms = tree_cons (NULL_TREE, lookup_tmp, inner_parms); - inner_parms = build_function_call (__sosLookup, inner_parms); - } - else - inner_parms = integer_zero_node; - - import_parms = tree_cons (NULL_TREE, inner_parms, import_parms); - import_parms = tree_cons (NULL_TREE, CLASSTYPE_TYPENAME_AS_STRING (type), import_parms); - /* This is one parameter which could be (but should not be) evaluated twice. */ - TREE_VALUE (parms) = save_expr (TREE_VALUE (parms)); - - import_parms = tree_cons (NULL_TREE, TREE_VALUE (parms), import_parms); - - /* SOS?? Pass the address of a temporary which can hold the pointer - to dynamic class table, but how and where is it defined? */ - import_parms = tree_cons (NULL_TREE, import_tmp, import_parms); - - import_ptr = build_function_call (__sosImport, import_parms); - - /* SOS?? Now, generate call to ctor, but using `import_ptr' as the function - table. Return the result of the call to the ctor. */ - import_ptr = build1 (NOP_EXPR, TYPE_POINTER_TO (type), import_ptr); - return build_method_call (import_ptr, DECL_NAME (TYPE_NAME (type)), - tree_cons (NULL_TREE, import_tmp, parms), - NULL_TREE, LOOKUP_DYNAMIC); -} - -/* Return the name of the link table (as an IDENTIFIER_NODE) - for the given TYPE. */ -tree -get_linktable_name (type) - tree type; -{ - char *buf = (char *)alloca (4 + TYPE_NAME_LENGTH (type) + 1); - tree name; - - assert (TYPE_DYNAMIC (type)); - sprintf (buf, "ZN_%s_", TYPE_NAME_STRING (type)); - return get_identifier (buf); -} - -/* For a given type TYPE, grovel for a function table which - can be used to support dynamic linking. */ -tree -get_sos_dtable (type, parms) - tree type, parms; -{ - tree classname = CLASSTYPE_TYPENAME_AS_STRING (type); - tree filename = CLASSTYPE_DYNAMIC_FILENAME (type); - tree dyn_vtbl; - /* This variable is supposed to be the address of a "struct ref" - object, but how and where should it be defined? */ - tree lookup_tmp = integer_zero_node; - - assert (TYPE_DYNAMIC (type)); - - if (filename) - { - tree inner_parms = tree_cons (NULL_TREE, filename, - build_tree_list (NULL_TREE, integer_zero_node)); - inner_parms = tree_cons (NULL_TREE, lookup_tmp, inner_parms); - parms = build_tree_list (NULL_TREE, build_function_call (__sosLookup, inner_parms)); - } - else - parms = build_tree_list (NULL_TREE, integer_zero_node); - - parms = tree_cons (NULL_TREE, classname, parms); - - dyn_vtbl = build_function_call (__sosFindCode, parms); - TREE_TYPE (dyn_vtbl) = build_pointer_type (ptr_type_node); - return dyn_vtbl; -} -#endif - -/* `expand_vec_init' performs initialization of a vector of aggregate - types. - - DECL is passed only for error reporting, and provides line number - and source file name information. - BASE is the space where the vector will be. - MAXINDEX is the maximum index of the array (one less than the - number of elements). - INIT is the (possibly NULL) initializer. - - FROM_ARRAY is 0 if we should init everything with INIT - (i.e., every element initialized from INIT). - FROM_ARRAY is 1 if we should index into INIT in parallel - with initialization of DECL. - FROM_ARRAY is 2 if we should index into INIT in parallel, - but use assignment instead of initialization. */ - -tree -expand_vec_init (decl, base, maxindex, init, from_array) - tree decl, base, maxindex, init; -{ - tree rval; - tree iterator, base2 = NULL_TREE; - tree type = TREE_TYPE (TREE_TYPE (base)); - tree size; - - maxindex = convert (integer_type_node, maxindex); - if (maxindex == error_mark_node) - return error_mark_node; - - if (current_function_decl == NULL_TREE) - { - rval = make_tree_vec (3); - TREE_VEC_ELT (rval, 0) = base; - TREE_VEC_ELT (rval, 1) = maxindex; - TREE_VEC_ELT (rval, 2) = init; - return rval; - } - - size = size_in_bytes (type); - - /* Set to zero in case size is <= 0. Optimizer will delete this if - it is not needed. */ - rval = get_temp_regvar (TYPE_POINTER_TO (type), null_pointer_node); - base = default_conversion (base); - expand_assignment (rval, base, 0, 0); - base = get_temp_regvar (TYPE_POINTER_TO (type), base); - - if (init != NULL_TREE - && TREE_CODE (init) == CONSTRUCTOR - && TREE_TYPE (init) == TREE_TYPE (decl)) - { - /* Initialization of array from {...}. */ - tree elts = CONSTRUCTOR_ELTS (init); - tree baseref = build1 (INDIRECT_REF, type, base); - tree baseinc = build (PLUS_EXPR, TYPE_POINTER_TO (type), base, size); - int host_i = TREE_INT_CST_LOW (maxindex); - - if (IS_AGGR_TYPE (type)) - { - while (elts) - { - host_i -= 1; - expand_aggr_init (baseref, TREE_VALUE (elts), 0); - - expand_assignment (base, baseinc, 0, 0); - elts = TREE_CHAIN (elts); - } - /* Initialize any elements by default if possible. */ - if (host_i >= 0) - { - if (TYPE_NEEDS_CONSTRUCTING (type) == 0) - { - if (obey_regdecls) - use_variable (DECL_RTL (base)); - goto done_init; - } - - iterator = get_temp_regvar (integer_type_node, - build_int_2 (host_i, 0)); - init = NULL_TREE; - goto init_by_default; - } - } - else - while (elts) - { - expand_assignment (baseref, TREE_VALUE (elts), 0, 0); - - expand_assignment (base, baseinc, 0, 0); - elts = TREE_CHAIN (elts); - } - - if (obey_regdecls) - use_variable (DECL_RTL (base)); - } - else - { - iterator = get_temp_regvar (integer_type_node, maxindex); - - init_by_default: - - /* If initializing one array from another, - initialize element by element. */ - if (from_array) - { - if (decl == NULL_TREE - || (init && TREE_TYPE (init) != TREE_TYPE (decl))) - { - sorry ("initialization of array from dissimilar array type"); - return error_mark_node; - } - if (init) - { - base2 = default_conversion (init); - base2 = get_temp_regvar (TYPE_POINTER_TO (type), base2); - } - else if (TYPE_LANG_SPECIFIC (type) - && TYPE_NEEDS_CONSTRUCTING (type) - && ! TYPE_HAS_DEFAULT_CONSTRUCTOR (type)) - { - error ("initializer ends prematurely"); - return; - } - } - - expand_start_cond (build (GE_EXPR, integer_type_node, - iterator, integer_zero_node), 0); - expand_start_loop_continue_elsewhere (1); - - if (from_array) - { - tree to = build1 (INDIRECT_REF, type, base); - tree from; - - if (base2) - from = build1 (INDIRECT_REF, type, base2); - else - from = NULL_TREE; - - if (from_array == 2) - expand_expr_stmt (build_modify_expr (to, NOP_EXPR, from)); - else if (TYPE_NEEDS_CONSTRUCTING (type)) - expand_aggr_init (to, from, 0); - else if (from) - expand_assignment (to, from, 0, 0); - else abort (); - } - else if (TREE_CODE (type) == ARRAY_TYPE) - { - if (init != 0) - sorry ("cannot initialize multi-dimensional array with initializer"); - expand_vec_init (decl, build1 (NOP_EXPR, TYPE_POINTER_TO (TREE_TYPE (type)), base), - array_type_nelts (type), 0, 0); - } - else - expand_aggr_init (build1 (INDIRECT_REF, type, base), init, 0); - - expand_assignment (base, - build (PLUS_EXPR, TYPE_POINTER_TO (type), base, size), - 0, 0); - if (base2) - expand_assignment (base2, - build (PLUS_EXPR, TYPE_POINTER_TO (type), base2, size), 0, 0); - expand_loop_continue_here (); - expand_exit_loop_if_false (build (NE_EXPR, integer_type_node, - build (PREDECREMENT_EXPR, integer_type_node, iterator, integer_one_node), minus_one)); - - if (obey_regdecls) - { - use_variable (DECL_RTL (base)); - if (base2) - use_variable (DECL_RTL (base2)); - } - expand_end_loop (); - expand_end_cond (); - if (obey_regdecls) - use_variable (DECL_RTL (iterator)); - } - done_init: - - if (obey_regdecls) - use_variable (DECL_RTL (rval)); - return rval; -} - -/* Free up storage of type TYPE, at address ADDR. - TYPE is a POINTER_TYPE. - - This does not call any destructors. */ -tree -build_x_delete (type, addr, use_global_delete) - tree type, addr; - int use_global_delete; -{ - tree rval; - - if (!use_global_delete - && TYPE_LANG_SPECIFIC (TREE_TYPE (type)) - && TREE_GETS_DELETE (TREE_TYPE (type))) - rval = build_opfncall (DELETE_EXPR, LOOKUP_NORMAL, addr); - else - { - rval = build (CALL_EXPR, void_type_node, BID, - build_tree_list (NULL_TREE, addr), 0); - TREE_VOLATILE (rval) = 1; - } - return rval; -} - -/* Generate a call to a destructor. TYPE is the type to cast ADDR to. - ADDR is an expression which yields the store to be destroyed. - AUTO_DELETE is nonzero if a call to DELETE should be made or not. - If in the program, (AUTO_DELETE & 2) is non-zero, we tear down the - virtual baseclasses. - If in the program, (AUTO_DELETE & 1) is non-zero, then we deallocate. - - FLAGS is the logical disjunction of zero or more LOOKUP_ - flags. See cplus-tree.h for more info. - - This function does not delete an object's virtual base classes. */ -tree -build_delete (type, addr, auto_delete, flags, use_global_delete) - tree type, addr; - tree auto_delete; - int flags; - int use_global_delete; -{ - tree function, parms; - tree member; - tree expr; - tree ref; - int ptr; - - if (addr == error_mark_node) - return error_mark_node; - - /* Can happen when CURRENT_EXCEPTION_OBJECT gets its type - set to `error_mark_node' before it gets properly cleaned up. */ - if (type == error_mark_node) - return error_mark_node; - - type = TYPE_MAIN_VARIANT (type); - - if (TREE_CODE (type) == POINTER_TYPE) - { - type = TREE_TYPE (type); - if (TYPE_SIZE (type) == 0) - { - incomplete_type_error (0, type); - return error_mark_node; - } - if (! IS_AGGR_TYPE (type)) - { - expr = build (CALL_EXPR, void_type_node, - BID, build_tree_list (NULL_TREE, addr), 0); - TREE_VOLATILE (expr) = 1; - return expr; - } - if (TREE_VOLATILE (addr)) - addr = save_expr (addr); - ref = build_indirect_ref (addr, 0); - ptr = 1; - } - else if (TREE_CODE (type) == ARRAY_TYPE) - { - if (TREE_VOLATILE (addr)) - addr = save_expr (addr); - return build_vec_delete (addr, array_type_nelts (type), c_sizeof (TREE_TYPE (type)), - NULL_TREE, auto_delete, integer_two_node); - } - else - { - /* Don't check PROTECT here; leave that decision to the - destructor. If the destructor is visible, call it, - else report error. */ - addr = build_unary_op (ADDR_EXPR, addr, 0); - if (TREE_VOLATILE (addr)) - addr = save_expr (addr); - - if (TREE_LITERAL (addr)) - addr = convert_pointer_to (type, addr); - else - addr = convert_force (build_pointer_type (type), addr); - - if (TREE_CODE (addr) == NOP_EXPR - && TREE_OPERAND (addr, 0) == current_class_decl) - ref = C_C_D; - else - ref = build_indirect_ref (addr, 0); - ptr = 0; - } - - assert (IS_AGGR_TYPE (type)); - - if (! TYPE_NEEDS_DESTRUCTOR (type)) - { - if (auto_delete == integer_zero_node) - return build1 (NOP_EXPR, void_type_node, integer_zero_node); - else if (TREE_GETS_DELETE (type) && !use_global_delete) - return build_opfncall (DELETE_EXPR, LOOKUP_NORMAL, addr); - parms = build_tree_list (NULL_TREE, addr); - expr = build (CALL_EXPR, void_type_node, BID, parms, 0); - TREE_VOLATILE (expr) = 1; - return expr; - } - parms = build_tree_list (NULL_TREE, addr); - - /* Below, we will reverse the order in which these calls are made. - If we have a destructor, then that destructor will take care - of the base classes; otherwise, we must do that here. */ - if (TYPE_HAS_DESTRUCTOR (type)) - { - tree field = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), 0); - tree basetypes = CLASSTYPE_AS_LIST (type); - - if (flags & LOOKUP_PROTECT) - { - enum visibility_type visibility = compute_visibility (basetypes, field); - - if (visibility == visibility_private) - { - if (flags & LOOKUP_COMPLAIN) - error_with_aggr_type (type, "destructor for type `%s' is private in this scope"); - return error_mark_node; - } - else if (visibility == visibility_protected - && (flags & LOOKUP_PROTECTED_OK) == 0) - { - if (flags & LOOKUP_COMPLAIN) - error_with_aggr_type (type, "destructor for type `%s' is protected in this scope"); - return error_mark_node; - } - } - - /* Once we are in a destructor, try not going through - the virtual function table to find the next destructor. */ - if (DECL_VIRTUAL_P (field) - && ! (flags & LOOKUP_NONVIRTUAL) - && TREE_CODE (auto_delete) != PARM_DECL - && (ptr == 1 || ! resolves_to_fixed_type_p (ref))) - { - /* This destructor must be called via virtual function table. */ - field = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (DECL_VCONTEXT (field)), 0); - expr = convert_pointer_to (DECL_CONTEXT (field), TREE_VALUE (parms)); - if (expr != TREE_VALUE (parms)) - { - ref = build_indirect_ref (expr, 0); - TREE_VALUE (parms) = expr; - } - function = build_vfn_ref (&TREE_VALUE (parms), ref, DECL_VINDEX (field)); - if (function == error_mark_node) - return error_mark_node; - TREE_TYPE (function) = build_pointer_type (TREE_TYPE (field)); - TREE_CHAIN (parms) = build_tree_list (NULL_TREE, auto_delete); - expr = build_function_call (function, parms); - if (ptr && (flags & LOOKUP_DESTRUCTOR) == 0) - { - /* Handle the case where a virtual destructor is - being called on an item that is 0. - - @@ Does this really need to be done? */ - tree ifexp = build_binary_op (NE_EXPR, addr, integer_zero_node); -#if 0 - if (TREE_CODE (ref) == VAR_DECL - || TREE_CODE (ref) == COMPONENT_REF) - warning ("losing in build_delete"); -#endif - expr = build (COND_EXPR, void_type_node, - ifexp, expr, - build1 (NOP_EXPR, void_type_node, integer_zero_node)); - } - } - else - { - tree ifexp; - - if ((flags & LOOKUP_DESTRUCTOR) - || TREE_CODE (ref) == VAR_DECL - || TREE_CODE (ref) == PARM_DECL - || TREE_CODE (ref) == COMPONENT_REF - || TREE_CODE (ref) == ARRAY_REF) - /* These can't be 0. */ - ifexp = integer_one_node; - else - /* Handle the case where a non-virtual destructor is - being called on an item that is 0. */ - ifexp = build_binary_op (NE_EXPR, addr, integer_zero_node); - - function = field; - - /* Used to mean that this destructor was known to be empty, - but that's now obsolete. */ - assert (DECL_INITIAL (function) != void_type_node); - - TREE_CHAIN (parms) = build_tree_list (NULL_TREE, auto_delete); - expr = build_function_call (function, parms); - - if (ifexp != integer_one_node) - expr = build (COND_EXPR, void_type_node, - ifexp, expr, - build1 (NOP_EXPR, void_type_node, integer_zero_node)); - } - return expr; - } - else - { - /* This can get visibilties wrong. */ - int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (type); - tree basetype = n_baseclasses > 0 ? CLASSTYPE_BASECLASS (type, 1) : NULL_TREE; - tree exprstmt = NULL_TREE; - tree parent_auto_delete = auto_delete; - tree cond; - - /* If this type does not have a destructor, but does have - operator delete, call the parent parent destructor (if any), - but let this node do the deleting. Otherwise, it is ok - to let the parent destructor do the deleting. */ - if (TREE_GETS_DELETE (type) && !use_global_delete) - { - parent_auto_delete = integer_zero_node; - if (auto_delete == integer_zero_node) - cond = NULL_TREE; - else - { - expr = build_opfncall (DELETE_EXPR, LOOKUP_NORMAL, addr); - if (expr == error_mark_node) - return error_mark_node; - if (auto_delete != integer_one_node) - cond = build (COND_EXPR, void_type_node, - build (BIT_AND_EXPR, integer_type_node, auto_delete, integer_one_node), - expr, - build1 (NOP_EXPR, void_type_node, integer_zero_node)); - else cond = expr; - } - } - else if (basetype == NULL_TREE - || (CLASSTYPE_VIA_VIRTUAL (type, 1) == 0 - && ! TYPE_NEEDS_DESTRUCTOR (basetype))) - { - cond = build (COND_EXPR, void_type_node, - build (BIT_AND_EXPR, integer_type_node, auto_delete, integer_one_node), - build_function_call (BID, build_tree_list (NULL_TREE, addr)), - build1 (NOP_EXPR, void_type_node, integer_zero_node)); - } - else cond = NULL_TREE; - - if (cond) - exprstmt = build_tree_list (NULL_TREE, cond); - - if (basetype - && ! CLASSTYPE_VIA_VIRTUAL (type, 1) - && TYPE_NEEDS_DESTRUCTOR (basetype)) - { - tree this_auto_delete; - - if (CLASSTYPE_OFFSET (basetype) == integer_zero_node) - this_auto_delete = parent_auto_delete; - else - this_auto_delete = integer_zero_node; - - expr = build_delete (TYPE_POINTER_TO (basetype), addr, - this_auto_delete, flags|LOOKUP_PROTECTED_OK, 0); - exprstmt = tree_cons (NULL_TREE, expr, exprstmt); - } - - for (i = 2; i <= n_baseclasses; i++) - { - basetype = CLASSTYPE_BASECLASS (type, i); - if (! TYPE_NEEDS_DESTRUCTOR (basetype) - || CLASSTYPE_VIA_VIRTUAL (type, i)) - continue; - - /* May be zero offset if other baseclasses are virtual. */ - expr = fold (build (PLUS_EXPR, TYPE_POINTER_TO (basetype), - addr, CLASSTYPE_OFFSET (basetype))); - - expr = build_delete (TYPE_POINTER_TO (basetype), expr, - integer_zero_node, - flags|LOOKUP_PROTECTED_OK, 0); - - exprstmt = tree_cons (NULL_TREE, expr, exprstmt); - } - - for (member = TYPE_FIELDS (type); member; member = TREE_CHAIN (member)) - { - if (TREE_CODE (member) != FIELD_DECL) - continue; - if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (member))) - { - tree this_member = build_component_ref (ref, DECL_NAME (member), 0, 0); - tree this_type = TREE_TYPE (member); - expr = build_delete (this_type, this_member, integer_two_node, flags, 0); - exprstmt = tree_cons (NULL_TREE, expr, exprstmt); - } - } - - if (exprstmt) - return build_compound_expr (exprstmt); - /* Virtual base classes make this function do nothing. */ - return build1 (NOP_EXPR, void_type_node, integer_zero_node); - } -} - -/* For type TYPE, delete the virtual baseclass objects of DECL. */ - -tree -build_vbase_delete (type, decl) - tree type, decl; -{ - tree vbases = CLASSTYPE_VBASECLASSES (type); - tree result = NULL_TREE; - tree addr = build_unary_op (ADDR_EXPR, decl, 0); - assert (addr != error_mark_node); - while (vbases) - { - tree this_addr = convert_force (TYPE_POINTER_TO (TREE_VALUE (vbases)), addr); - result = tree_cons (NULL_TREE, - build_delete (TREE_TYPE (this_addr), this_addr, - integer_zero_node, LOOKUP_NORMAL, 0), - result); - vbases = TREE_CHAIN (vbases); - } - return build_compound_expr (nreverse (result)); -} - -/* Build a C++ vector delete expression. - MAXINDEX is the number of elements to be deleted. - ELT_SIZE is the nominal size of each element in the vector. - BASE is the expression that should yield the store to be deleted. - DTOR_DUMMY is a placeholder for a destructor. The library function - __builtin_vec_delete has a pointer to function in this position. - This function expands (or synthesizes) these calls itself. - AUTO_DELETE_VEC says whether the container (vector) should be deallocated. - AUTO_DELETE say whether each item in the container should be deallocated. - - This also calls delete for virtual baseclasses of elements of the vector. */ -tree -build_vec_delete (base, maxindex, elt_size, dtor_dummy, auto_delete_vec, auto_delete) - tree base, maxindex, elt_size; - tree dtor_dummy; - tree auto_delete_vec, auto_delete; -{ - tree ptype = TREE_TYPE (base); - tree type; - tree rval; - /* Temporary variables used by the loop. */ - tree iterator, tbase; - tree size_exp; - - /* This is the body of the loop that implements the deletion of a - single element, and moves temp variables to next elements. */ - tree body; - - /* This is the LOOP_STMT that governs the deletetion of the elements. */ - tree loop; - - /* This is the IF_STMT that governs whether the loop is executed at all. */ - tree if_stmt; - - /* This is the ELSE_STMT that governs what to do after the loop has run. */ - tree else_stmt = 0; - - /* This is the LET_STMT which holds the outermost iterator of the - loop. It is convenient to set this variable up and test it before - executing any other code in the loop. */ - tree block; - - if (TREE_CODE (ptype) == POINTER_TYPE) - { - if (maxindex == 0) - { - error ("must specify size for non array type"); - return error_mark_node; - } - maxindex = convert (integer_type_node, maxindex); - if (maxindex == error_mark_node) - return error_mark_node; - } - else if (TREE_CODE (ptype) == ARRAY_TYPE) - { - tree amaxindex = array_type_nelts (ptype); - int multi = 0; - - maxindex = fold (convert (integer_type_node, maxindex)); - - while (1) - { - if (maxindex == error_mark_node || integer_zerop (maxindex)) - return error_mark_node; - ptype = TREE_TYPE (ptype); - if (TREE_CODE (ptype) != ARRAY_TYPE) - break; - - if (multi == 0) - { - /* Convert from 0-based to 1-based indexing. */ - maxindex = fold (build (PLUS_EXPR, integer_type_node, - maxindex, integer_one_node)); - multi = 1; - } - amaxindex = array_type_nelts (ptype); - maxindex = fold (build (MULT_EXPR, integer_type_node, - fold (build (PLUS_EXPR, integer_type_node, - amaxindex, integer_one_node)), - maxindex)); - } - - if (multi) - { - /* Convert back to 0-based indexing. */ - maxindex = fold (build (MINUS_EXPR, integer_type_node, - maxindex, integer_one_node)); - ptype = TYPE_POINTER_TO (ptype); - base = build1 (NOP_EXPR, ptype, build_unary_op (ADDR_EXPR, base, 0)); - } - else - { - if (amaxindex != 0 - && (TREE_CODE (maxindex) == INTEGER_CST || TREE_CODE (amaxindex) == INTEGER_CST) - && ! tree_int_cst_equal (maxindex, amaxindex)) - warning ("argument to vector delete disagrees with declared type of array"); - base = default_conversion (base); - ptype = TREE_TYPE (base); - } - } - else - { - error ("type to vector delete is neither pointer or array type"); - return error_mark_node; - } - type = TREE_TYPE (ptype); - - if (! IS_AGGR_TYPE (type) || ! TYPE_NEEDS_DESTRUCTOR (type)) - { - if (extra_warnings) - warning ("array size expression for delete ignored"); - rval = build (CALL_EXPR, void_type_node, - BID, build_tree_list (NULL_TREE, base), 0); - TREE_VOLATILE (rval) = 1; - return rval; - } - - size_exp = size_in_bytes (type); - iterator = build_decl (VAR_DECL, NULL_TREE, integer_type_node); - TREE_REGDECL (iterator) = 1; - DECL_INITIAL (iterator) = maxindex; - tbase = build_decl (VAR_DECL, NULL_TREE, ptype); - TREE_REGDECL (tbase) = 1; - DECL_INITIAL (tbase) = build (PLUS_EXPR, ptype, base, - build (MULT_EXPR, integer_type_node, size_exp, - build (PLUS_EXPR, integer_type_node, maxindex, integer_one_node))); - - block = build_let (input_filename, lineno, iterator, 0, 0, 0); - TREE_TYPE (block) = void_type_node; - - if (auto_delete != integer_zero_node - && auto_delete != integer_two_node) - { - body = build_tree_list (NULL_TREE, - build (CALL_EXPR, void_type_node, - BID, build_tree_list (NULL_TREE, base), 0)); - body = build (COND_EXPR, void_type_node, - build (BIT_AND_EXPR, integer_type_node, - auto_delete, integer_one_node), - body, integer_zero_node); - } - else - body = NULL_TREE; - - body = tree_cons (NULL_TREE, - build_delete (ptype, tbase, auto_delete, LOOKUP_NORMAL, 0), - body); - - body = tree_cons (NULL_TREE, - build_modify_expr (tbase, NOP_EXPR, build (MINUS_EXPR, ptype, tbase, size_exp)), - body); - - loop = build_loop (input_filename, lineno, - tbase, - build (NE_EXPR, integer_type_node, - build (PREDECREMENT_EXPR, integer_type_node, - iterator, integer_one_node), - minus_one), - build_compound_expr (body)); - TREE_TYPE (loop) = void_type_node; - TREE_VOLATILE (loop) = 1; - - /* ELSE_STMT holds the code which deletes the container. - If you don't want to delete the container, make ELSE_STMT - zero here. */ - if (auto_delete_vec == integer_one_node) - else_stmt = build_delete (ptr_type_node, base, integer_one_node, 0, 1); - else if (auto_delete_vec != integer_zero_node - && auto_delete_vec != integer_two_node) - { - else_stmt = build (COND_EXPR, void_type_node, - build (BIT_AND_EXPR, integer_type_node, auto_delete_vec, integer_one_node), - build_delete (ptr_type_node, base, integer_one_node, 0, 1), - integer_zero_node); - TREE_VOLATILE (else_stmt) = 1; - } - else - else_stmt = 0; - - if_stmt = build_if (input_filename, lineno, - build (GE_EXPR, integer_type_node, - iterator, integer_zero_node), - loop, else_stmt); - - TREE_TYPE (if_stmt) = void_type_node; - TREE_VOLATILE (if_stmt) = 1; - - /* BASE may be a SAVE_EXPR which must be evaluated before either - branch of the IF/THEN/ELSE. */ - STMT_BODY (block) = build (COMPOUND_EXPR, void_type_node, base, if_stmt); - TREE_VOLATILE (block) = 1; - - return block; -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-lex.c b/gnu/usr.bin/g++/cc1plus/cplus-lex.c deleted file mode 100644 index ff9b2eff68d8..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-lex.c +++ /dev/null @@ -1,4037 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - */ - -#ifndef lint -static char sccsid[] = "@(#)cplus-lex.c 6.4 (Berkeley) 5/8/91"; -#endif /* not lint */ - -/* Separate lexical analyzer for GNU C++. - Copyright (C) 1987 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file is the lexical analyzer for GNU C++. */ - -#include -#include -#include -#include -#include -#include "config.h" -#include "input.h" -#include "tree.h" -#ifdef VMS -#define _IOFBF 2 /* Missing from GNU's stdio.h */ -#endif -#include "cplus-tab.h" -#include "cplus-parse.h" -#include "cplus-tree.h" -#include "flags.h" -#include "obstack.h" -#include "assert.h" -extern int errno; /* needed for VAX. */ -extern jmp_buf toplevel; - -#ifdef VMS -#define NULL_FILE "nla0:" -#else -#define NULL_FILE "/dev/null" -#endif - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -extern int xmalloc (); -extern void free (); - -extern double atof (); - -/* If you don't have strrchr, but instead have rindex, - add your machine to this list, and send mail to - tiemann@wheaties.ai.mit.edu. */ -#if defined(sequent) || defined(convex) -#define strrchr rindex -#endif -extern char *strrchr (); - -/* This obstack is needed to hold text. It is not safe to use - TOKEN_BUFFER because `check_newline' calls `yylex'. */ -static struct obstack inline_text_obstack; -static char *inline_text_firstobj; - -/* Holds translations from TREE_CODEs to operator name strings, - i.e., opname_tab[PLUS_EXPR] == "+". */ -char **opname_tab; -char **assignop_tab; - -#define YYEMPTY -1 -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#if 0 -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int end_of_file; - -/* the declaration found for the last IDENTIFIER token read in. - yylex must look this up to detect typedefs, which get token type TYPENAME, - so it is left around in case the identifier is not a typedef but is - used in a context which makes it a reference to a variable. */ -tree lastiddecl; - -/* C++ extensions */ -tree ridpointers[]; /* need this up here */ - -/* We may keep statistics about how long which files took to compile. */ -static int header_time, body_time; -static tree get_time_identifier (); -static tree filename_times; -static tree this_filename_time; - -/* For implementing #pragma unit. */ -tree current_unit_name; -tree current_unit_language; - -/* Array for holding counts of the numbers of tokens seen. */ -int *token_count; - -/* Return something to represent absolute declarators containing a *. - TARGET is the absolute declarator that the * contains. - TYPE_QUALS is a list of modifiers such as const or volatile - to apply to the pointer type, represented as identifiers. - - We return an INDIRECT_REF whose "contents" are TARGET - and whose type is the modifier list. */ - -tree -make_pointer_declarator (type_quals, target) - tree type_quals, target; -{ - if (target && TREE_CODE (target) == IDENTIFIER_NODE - && ANON_AGGRNAME_P (target)) - error ("type name expected before `*'"); - return build1 (INDIRECT_REF, type_quals, target); -} - -/* Return something to represent absolute declarators containing a &. - TARGET is the absolute declarator that the & contains. - TYPE_QUALS is a list of modifiers such as const or volatile - to apply to the reference type, represented as identifiers. - - We return an ADDR_EXPR whose "contents" are TARGET - and whose type is the modifier list. */ - -tree -make_reference_declarator (type_quals, target) - tree type_quals, target; -{ - if (target) - { - if (TREE_CODE (target) == ADDR_EXPR) - { - error ("cannot declare references to references"); - return target; - } - if (TREE_CODE (target) == INDIRECT_REF) - { - error ("cannot declare pointers to references"); - return target; - } - if (TREE_CODE (target) == IDENTIFIER_NODE && ANON_AGGRNAME_P (target)) - error ("type name expected before `&'"); - } - return build1 (ADDR_EXPR, type_quals, target); -} - -/* Given a chain of STRING_CST nodes, - concatenate them into one STRING_CST - and give it a suitable array-of-chars data type. */ - -tree -combine_strings (strings) - tree strings; -{ - register tree value, t; - register int length = 1; - int wide_length = 0; - int wide_flag = 0; - - if (TREE_CHAIN (strings)) - { - /* More than one in the chain, so concatenate. */ - register char *p, *q; - - /* Don't include the \0 at the end of each substring, - except for the last one. - Count wide strings and ordinary strings separately. */ - for (t = strings; t; t = TREE_CHAIN (t)) - { - if (TREE_TYPE (t) == int_array_type_node) - { - wide_length += (TREE_STRING_LENGTH (t) - 1); - wide_flag = 1; - } - else - length += (TREE_STRING_LENGTH (t) - 1); - } - - /* If anything is wide, the non-wides will be converted, - which makes them take more space. */ - if (wide_flag) - length = length * UNITS_PER_WORD + wide_length; - - p = (char *) savealloc (length); - - /* Copy the individual strings into the new combined string. - If the combined string is wide, convert the chars to ints - for any individual strings that are not wide. */ - - q = p; - for (t = strings; t; t = TREE_CHAIN (t)) - { - int len = TREE_STRING_LENGTH (t) - 1; - if ((TREE_TYPE (t) == int_array_type_node) == wide_flag) - { - bcopy (TREE_STRING_POINTER (t), q, len); - q += len; - } - else - { - int i; - for (i = 0; i < len; i++) - ((int *) q)[i] = TREE_STRING_POINTER (t)[i]; - q += len * UNITS_PER_WORD; - } - } - *q = 0; - - value = make_node (STRING_CST); - TREE_STRING_POINTER (value) = p; - TREE_STRING_LENGTH (value) = length; - TREE_LITERAL (value) = 1; - } - else - { - value = strings; - length = TREE_STRING_LENGTH (value); - if (TREE_TYPE (value) == int_array_type_node) - wide_flag = 1; - } - - /* Create the array type for the string constant. - -Wwrite-strings says make the string constant an array of const char - so that copying it to a non-const pointer will get a warning. */ - if (warn_write_strings) - { - tree elements - = build_type_variant (wide_flag ? integer_type_node : char_type_node, - 1, 0); - TREE_TYPE (value) - = build_array_type (elements, - build_index_type (build_int_2 (length - 1, 0))); - } - else - TREE_TYPE (value) - = build_array_type (wide_flag ? integer_type_node : char_type_node, - build_index_type (build_int_2 (length - 1, 0))); - TREE_LITERAL (value) = 1; - TREE_STATIC (value) = 1; - return value; -} - -/* Build names and nodes for overloaded operators. */ - -/* Memoized table for operator names. */ -tree *node_table; - -tree -build_opid (code1, code2) - enum tree_code code1, code2; -{ - register tree t = make_node (OP_IDENTIFIER); - register tree tmp; - extern struct obstack *expression_obstack, permanent_obstack; - struct obstack *ambient_obstack = expression_obstack; - expression_obstack = &permanent_obstack; - if (code1 != 0) - { - if ((tmp = node_table[(int)code1]) == 0) - node_table[(int)code1] = tmp = make_node (code1); - TREE_PURPOSE (t) = tmp; - } - if ((tmp = node_table[(int)code2]) == 0) - node_table[(int)code2] = tmp = make_node (code2); - TREE_VALUE (t) = tmp; - expression_obstack = ambient_obstack; - return t; -} - -#ifdef __GNUC__ -#define DEFTREECODE(SYM, NAME, TYPE, LEN) sizeof (NAME), -#else -#define DEFTREECODE(SYM, NAME, TYPE, LEN) -1, -#endif -static short opname_end[] = { -#include "tree.def" -7, /* sizeof ("@@dummy"), */ -#include "cplus-tree.def" -}; -#undef DEFTREECODE - -/* Given a TOKEN and its estimated tree code CODE, produce a name which - can be recognized by lookup_name. Based on the number of PARMS, - build an appropriate operator fnname. This function is needed because - until we know how many parameters we have, we cannot reliably tell - what function indeed we are trying to declare. - - NPARMS is the number of additional parameters that this operator - will ultimately have. If NPARMS == -1, then we are just building - a name, and should not complain. - - This would be a good candidate for memoizing. */ -tree -build_operator_fnname (declp, parms, nparms) - tree *declp; - tree parms; - int nparms; -{ - tree decl = *declp; - char **opname_table, *opname; - int assignop_p = 0; - tree rval; - enum tree_code code; - char buf[1024]; - int saw_class = nparms; - int erred = 0; - - while (parms) - { - tree type; - if (parms == void_list_node) - break; - - if (! saw_class) - { - type = TREE_VALUE (parms); - if (TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); - if (TREE_CODE (type) == POINTER_TYPE) - type = TREE_TYPE (type); - if (IS_AGGR_TYPE (type)) - saw_class = 1; - } - nparms++; - parms = TREE_CHAIN (parms); - } - - if (TREE_CODE (decl) == TYPE_EXPR) - { - /* @@ may need to perform type instantiation here. */ - if (nparms > 1) - error ("wrong number of arguments to type conversion operator"); - - /* The grammar will swallow an "()" if one was given. - We attempt to correct for this lossage here. */ - if (TREE_OPERAND (decl, 0) - && TREE_CODE (TREE_OPERAND (decl, 0)) == CALL_EXPR) - { - rval = build_typename_overload (groktypename (build_tree_list (TREE_TYPE (decl), NULL_TREE))); - yychar = LEFT_RIGHT; - } - else - { - rval = build_typename_overload (groktypename (build_tree_list (TREE_TYPE (decl), TREE_OPERAND (decl, 0)))); - } - return rval; - } - - if (TREE_PURPOSE (decl)) - if (TREE_CODE (TREE_PURPOSE (decl)) == MODIFY_EXPR) - { - opname_table = assignop_tab; - assignop_p = 1; - } - else - abort (); - else - opname_table = opname_tab; - - code = TREE_CODE (TREE_VALUE (decl)); - opname = opname_table[(int) code]; - - if (assignop_p) - { - if (nparms == 1 || nparms > 2) - error ("wrong number of parameters op `operator %s'", opname); - } - else switch (code) - { - case ERROR_MARK: - rval = get_identifier (""); - TREE_OVERLOADED (rval) = 1; - return rval; - - /* AC/DC */ - case PLUS_EXPR: - if (nparms == 1) - code = CONVERT_EXPR; - else if (nparms != 2) - erred = 1; - break; - - case ADDR_EXPR: - case BIT_AND_EXPR: - if (nparms == 1) - code = ADDR_EXPR; - else if (nparms == 2) - code = BIT_AND_EXPR; - else - { - code = BIT_AND_EXPR; - erred = 1; - } - break; - - case MULT_EXPR: - case INDIRECT_REF: - if (nparms == 1) - code = INDIRECT_REF; - else if (nparms == 2) - code = MULT_EXPR; - else - { - code = MULT_EXPR; - erred = 1; - } - break; - - case MINUS_EXPR: - case NEGATE_EXPR: - if (nparms == 1) - code = NEGATE_EXPR; - else if (nparms == 2) - code = MINUS_EXPR; - else - { - code = MINUS_EXPR; - erred = 1; - } - break; - - case POINTSAT: - if (nparms == 1 || nparms < 0) - code = COMPONENT_REF; - else - { - erred = -1; - error ("wrong number of parameters to `operator ->()'"); - } - break; - - case METHOD_CALL_EXPR: - switch (nparms) - { - case 0: - case 1: - erred = -1; - error ("too few arguments to `operator ->()(...)'"); - break; - /* 4 happens when we pass in the canonical number - of arguments. */ - case 4: - nparms = 3; - case -1: - case 2: - case 3: - break; - default: - erred = -1; - error ("too many arguments to `operator ->()(...)'"); - break; - } - break; - - /* The two following entrys are for two different ways of - encoding `operator ='. */ - case NOP_EXPR: - if (nparms != 2 && nparms >= 0) - erred = 1; - break; - - case MODIFY_EXPR: - if (nparms != 2 && nparms >= 0) - erred = 1; - break; - - case NEW_EXPR: - if (saw_class == 0) - { - if (nparms > 1) - return get_identifier (OPERATOR_NEW_FORMAT); - return get_identifier ("__builtin_new"); - } - break; - - case DELETE_EXPR: - if (saw_class == 0) - { - if (nparms > 1) - error ("too many parameters to `operator ::delete'"); - return get_identifier ("__builtin_delete"); - } - if (nparms > 2) - erred = 1; - break; - - /* Whatever it was, we know its arity. Just check that it - has the right number of parameters defined. */ - default: - /* These are the only operators which do not need - to have a class-type associated with them. */ - - if (code == PREDECREMENT_EXPR - || code == POSTINCREMENT_EXPR - || code == COMPONENT_REF) - { - if (nparms > 1) - erred = 1; - } - else if (nparms < 0 - || code == CALL_EXPR - || code == METHOD_CALL_EXPR) - ; - else if (nparms != tree_code_length [(int) code]) - erred = 1; - break; - } - - if (erred > 0) - error ("wrong number of parameters to `operator %s'", opname); - else if (erred == 0 && code != TREE_CODE (TREE_VALUE (decl))) - { - enum tree_code assign_code = ERROR_MARK; - if (TREE_PURPOSE (decl)) - assign_code = TREE_CODE (TREE_PURPOSE (decl)); - decl = build_opid (assign_code, code); - *declp = decl; - } - - if (! saw_class) - error ("`operator %s' must have at least one class type", opname); - - if (assignop_p) - { - sprintf (buf, OPERATOR_ASSIGN_FORMAT, tree_code_name [(int) code]); - buf[opname_end[(int) code] + sizeof (OPERATOR_ASSIGN_FORMAT) - 3] = '\0'; - } - else - { - sprintf (buf, OPERATOR_FORMAT, tree_code_name [(int) code]); - buf[opname_end[(int) code] + sizeof (OPERATOR_FORMAT) - 3] = '\0'; - } - rval = get_identifier (buf); - TREE_OVERLOADED (rval) = 1; - return rval; -} - -char * -operator_name_string (name) - tree name; -{ - char *opname = IDENTIFIER_POINTER (name) - + sizeof (OPERATOR_FORMAT) - sizeof ("%s"); - int i, assign; - - /* Works for builtin and user defined types. */ - if (IDENTIFIER_GLOBAL_VALUE (name) - && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (name)) == TYPE_DECL) - return IDENTIFIER_POINTER (name); - - if (! strncmp (opname, "assign", 6)) - { - opname += 7; - assign = 1; - } - else - assign = 0; - - for (i = 0; i < LAST_CPLUS_TREE_CODE; i++) - { - if (! strncmp (opname, tree_code_name[i], opname_end[i])) - break; - } - - assert (i != LAST_CPLUS_TREE_CODE); - - if (assign) - return assignop_tab[i]; - else - return opname_tab[i]; -} - -int lineno; /* current line number in file being read */ - -FILE *finput; /* input file. - Normally a pipe from the preprocessor. */ -static FILE *finput1; /* Real input files: 1 is main input file */ -static FILE *finput2; /* 2 is input file for inline functions */ - -int interface_only; /* whether or not current file is only for - interface definitions. */ -int interface_unknown; /* whether or not we know this class - to behave according to #pragma interface. */ - -/* lexical analyzer */ - -static int maxtoken; /* Current nominal length of token buffer. */ -char *token_buffer; /* Pointer to token buffer. - Actual allocated length is maxtoken + 2. */ -static int max_wide; /* Current nominal length of wide_buffer. */ -static int *wide_buffer; /* Pointer to wide-string buffer. - Actual allocated length is max_wide + 1. */ - -#define NORID RID_UNUSED - -/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf */ -struct resword { char *name; short token; enum rid rid;}; - -#define MIN_WORD_LENGTH 2 -#define MAX_WORD_LENGTH 13 -#define MIN_HASH_VALUE 4 -#define MAX_HASH_VALUE 147 -/* - 71 keywords - 144 is the maximum key range -*/ - -#ifdef __GNUC__ -inline -#endif -static int -hash (str, len) - register char *str; - register int unsigned len; -{ - static unsigned char hash_table[] = - { - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147, 147, 147, 147, 0, 147, 19, 6, 27, - 37, 0, 12, 1, 15, 63, 147, 4, 0, 56, - 20, 15, 42, 147, 31, 5, 26, 39, 32, 10, - 147, 40, 147, 147, 147, 147, 147, 147, - }; - register int hval = len ; - - switch (hval) - { - default: - case 4: - hval += hash_table[str[3]]; - case 3: - case 2: - case 1: - hval += hash_table[str[0]]; - } - return hval + hash_table[str[len - 1]] ; -} - -#ifdef __GNUC__ -inline -#endif -struct resword * -is_reserved_word (str, len) - register char *str; - register unsigned int len; -{ - - static struct resword wordlist[] = - { - {"",}, {"",}, {"",}, {"",}, - {"else", ELSE, NORID,}, - {"",}, - {"long", TYPESPEC, RID_LONG,}, - {"",}, {"",}, {"",}, {"",}, - {"__alignof__", ALIGNOF, NORID}, - {"__asm__", ASM, NORID}, - {"",}, {"",}, - {"while", WHILE, NORID,}, - {"",}, {"",}, {"",}, {"",}, {"",}, - {"__alignof", ALIGNOF, NORID}, - {"all", ALL, NORID /* Extension */,}, - {"sizeof", SIZEOF, NORID,}, - {"__const__", TYPE_QUAL, RID_CONST}, - {"__volatile", TYPE_QUAL, RID_VOLATILE}, - {"extern", SCSPEC, RID_EXTERN,}, - {"__volatile__", TYPE_QUAL, RID_VOLATILE}, - {"__inline", SCSPEC, RID_INLINE}, - {"exception", AGGR, RID_EXCEPTION /* Extension */,}, - {"__inline__", SCSPEC, RID_INLINE}, - {"case", CASE, NORID,}, - {"except", EXCEPT, NORID /* Extension */,}, - {"new", NEW, NORID,}, - {"break", BREAK, NORID,}, - {"goto", GOTO, NORID,}, - {"",}, - {"__attribute", ATTRIBUTE, NORID}, - {"",}, - {"__attribute__", ATTRIBUTE, NORID}, - {"this", THIS, NORID,}, - {"raise", RAISE, NORID /* Extension */,}, - {"class", AGGR, RID_CLASS,}, - {"delete", DELETE, NORID,}, - {"typeof", TYPEOF, NORID,}, - {"typedef", SCSPEC, RID_TYPEDEF,}, - {"for", FOR, NORID,}, - {"raises", RAISES, NORID /* Extension */,}, - {"__const", TYPE_QUAL, RID_CONST}, - {"double", TYPESPEC, RID_DOUBLE,}, - {"__typeof__", TYPEOF, NORID}, - {"",}, - {"switch", SWITCH, NORID,}, - {"auto", SCSPEC, RID_AUTO,}, - {"do", DO, NORID,}, - {"friend", SCSPEC, RID_FRIEND,}, - {"",}, - {"reraise", RERAISE, NORID /* Extension */,}, - {"",}, - {"volatile", TYPE_QUAL, RID_VOLATILE,}, - {"__typeof", TYPEOF, NORID}, - {"continue", CONTINUE, NORID,}, - {"float", TYPESPEC, RID_FLOAT,}, - {"const", TYPE_QUAL, RID_CONST,}, - {"static", SCSPEC, RID_STATIC,}, - {"virtual", SCSPEC, RID_VIRTUAL,}, - {"__asm", ASM, NORID}, - {"short", TYPESPEC, RID_SHORT,}, - {"signed", TYPESPEC, RID_SIGNED,}, - {"try", TRY, NORID /* Extension */,}, - {"",}, {"",}, {"",}, - {"__signed__", TYPESPEC, RID_SIGNED}, - {"catch", CATCH, NORID,}, - {"public", PUBLIC, NORID,}, - {"struct", AGGR, RID_RECORD,}, - {"if", IF, NORID,}, - {"asm", ASM, NORID,}, - {"union", AGGR, RID_UNION,}, - {"",}, - {"private", PRIVATE, NORID,}, - {"",}, {"",}, {"",}, - {"operator", OPERATOR, NORID,}, - {"",}, {"",}, {"",}, - {"default", DEFAULT, NORID,}, - {"dynamic", DYNAMIC, NORID,}, - {"overload", OVERLOAD, NORID,}, - {"int", TYPESPEC, RID_INT,}, - {"char", TYPESPEC, RID_CHAR,}, - {"",}, {"",}, - {"return", RETURN, NORID,}, - {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, - {"",}, {"",}, - {"__signed", TYPESPEC, RID_SIGNED}, - {"",}, - {"void", TYPESPEC, RID_VOID,}, - {"",}, {"",}, {"",}, - {"protected", PROTECTED, NORID,}, - {"",}, - {"enum", ENUM, NORID,}, - {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, - {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, - {"inline", SCSPEC, RID_INLINE,}, - {"register", SCSPEC, RID_REGISTER,}, - {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, - {"",}, {"",}, {"",}, {"",}, - {"unsigned", TYPESPEC, RID_UNSIGNED,}, - }; - - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) - { - register int key = hash (str, len); - - if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE) - { - register char *s = wordlist[key].name; - - if (*s == *str && !strcmp (str + 1, s + 1)) - return &wordlist[key]; - } - } - return 0; -} - -/* The elements of `ridpointers' are identifier nodes - for the reserved type names and storage classes. - It is indexed by a RID_... value. */ - -tree ridpointers[(int) RID_MAX]; - -int check_newline (); - -static int skip_white_space (); - -static tree -get_time_identifier (name) - char *name; -{ - tree time_identifier; - int len = strlen (name); - char *buf = (char *)alloca (len + 6); - strcpy (buf, "file "); - bcopy (name, buf+5, len); - buf[len+5] = '\0'; - time_identifier = get_identifier (buf); - if (IDENTIFIER_LOCAL_VALUE (time_identifier) == NULL_TREE) - { - int temp = allocation_temporary_p (); - if (temp) - end_temporary_allocation (); - IDENTIFIER_LOCAL_VALUE (time_identifier) = build_int_2 (0, 0); - IDENTIFIER_CLASS_VALUE (time_identifier) = build_int_2 (0, 1); - IDENTIFIER_GLOBAL_VALUE (time_identifier) = filename_times; - filename_times = time_identifier; - if (temp) - resume_temporary_allocation (); - } - return time_identifier; -} - -#ifdef __GNUC__ -__inline -#endif -static int -my_gettime () -{ - int old_quiet_flag = quiet_flag; - int this_time; - quiet_flag = 0; - this_time = gettime (); - quiet_flag = old_quiet_flag; - return this_time; -} - -/* Table indexed by tree code giving a string containing a character - classifying the tree code. Possibilities are - t, d, s, c, r and e. See cplus-tree.def for details. */ - -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, - -char *cplus_tree_code_type[] = { - "x", -#include "cplus-tree.def" -}; -#undef DEFTREECODE - -/* Table indexed by tree code giving number of expression - operands beyond the fixed part of the node structure. - Not used for types or decls. */ - -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, - -int cplus_tree_code_length[] = { - 0, -#include "cplus-tree.def" -}; -#undef DEFTREECODE - -/* Names of tree components. - Used for printing out the tree and error messages. */ -#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME, - -char *cplus_tree_code_name[] = { - "@@dummy", -#include "cplus-tree.def" -}; -#undef DEFTREECODE - -void -init_filename_times () -{ - this_filename_time = get_time_identifier (""); - if (flag_detailed_statistics) - { - header_time = 0; - body_time = my_gettime (); - TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) = body_time; - } -} - -/* Use 4.4 BSD fropen() stdio function to fake re-reads of inline functions. - We just decrement the buffer count until it reaches zero. */ - -static unsigned next_inline_count = 0; - -static int -read_next_inline(unused_cookie, unused_buf, count) - void *unused_cookie; - char *unused_buf; - unsigned count; -{ - count = count > next_inline_count ? next_inline_count : count; - next_inline_count -= count; - return count; -} - -/* Change by Bryan Boreham, Kewill, Thu Jul 27 09:46:05 1989. - Stuck this hack in to get the files open correctly; this is called - in place of init_lex if we are an unexec'd binary. */ -void -reinit_lex_for_unexec () -{ - finput1 = finput; - finput2 = fropen ((void *) 0, read_next_inline); - init_filename_times (); -} - -void -init_lex () -{ - extern int *init_parse (); - extern char *(*decl_printable_name) (); - extern char *lang_printable_name (); - extern struct rtx_def *(*lang_expand_expr) (); - extern struct rtx_def *cplus_expand_expr (); - - int i; - - /* Make identifier nodes long enough for the language-specific slots. */ - set_identifier_size (sizeof (struct lang_identifier)); - decl_printable_name = lang_printable_name; - lang_expand_expr = cplus_expand_expr; - - tree_code_type - = (char **) realloc (tree_code_type, - sizeof (char *) * LAST_CPLUS_TREE_CODE); - tree_code_length - = (int *) realloc (tree_code_length, - sizeof (int) * LAST_CPLUS_TREE_CODE); - tree_code_name - = (char **) realloc (tree_code_name, - sizeof (char *) * LAST_CPLUS_TREE_CODE); - bcopy (cplus_tree_code_type, - tree_code_type + LAST_AND_UNUSED_TREE_CODE, - (LAST_CPLUS_TREE_CODE - LAST_AND_UNUSED_TREE_CODE) * sizeof (char *)); - bcopy (cplus_tree_code_length, - tree_code_length + LAST_AND_UNUSED_TREE_CODE, - (LAST_CPLUS_TREE_CODE - LAST_AND_UNUSED_TREE_CODE) * sizeof (int)); - bcopy (cplus_tree_code_name, - tree_code_name + LAST_AND_UNUSED_TREE_CODE, - (LAST_CPLUS_TREE_CODE - LAST_AND_UNUSED_TREE_CODE) * sizeof (char *)); - - node_table = (tree *)oballoc (LAST_CPLUS_TREE_CODE * sizeof (tree)); - opname_tab = (char **)oballoc (LAST_CPLUS_TREE_CODE * sizeof (char *)); - assignop_tab = (char **)oballoc (LAST_CPLUS_TREE_CODE * sizeof (char *)); - - for (i = 0; i < LAST_CPLUS_TREE_CODE; i++) - /* Our only interest is _ref and _expr. */ - if (tree_code_type[i][0] == 'r' || tree_code_type[i][0] == 'e') - { - char *end = (char *)strrchr (tree_code_name[i], '_'); - if (end) - opname_end[i] = end - tree_code_name[i]; -#ifndef __GNUC__ - else - opname_end[i] = strlen (tree_code_name[i]); -#endif - } -#ifndef __GNUC__ - else - opname_end[i] = strlen (tree_code_name[i]); -#endif - - init_method (); - obstack_init (&inline_text_obstack); - inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0); - - /* Start it at 0, because check_newline is called at the very beginning - and will increment it to 1. */ - lineno = 0; - finput1 = finput; - finput2 = fropen ((void *) 0, read_next_inline); - current_function_decl = NULL; - - maxtoken = 40; - token_buffer = (char *) xmalloc (maxtoken + 2); - max_wide = 40; - wide_buffer = (int *) xmalloc (max_wide + 1); - - ridpointers[(int) RID_INT] = get_identifier ("int"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INT], - build_tree_list (NULL_TREE, ridpointers[(int) RID_INT])); - ridpointers[(int) RID_CHAR] = get_identifier ("char"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CHAR], - build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR])); - ridpointers[(int) RID_VOID] = get_identifier ("void"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOID], - build_tree_list (NULL_TREE, ridpointers[(int) RID_VOID])); - ridpointers[(int) RID_FLOAT] = get_identifier ("float"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FLOAT], - build_tree_list (NULL_TREE, ridpointers[(int) RID_FLOAT])); - ridpointers[(int) RID_DOUBLE] = get_identifier ("double"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_DOUBLE], - build_tree_list (NULL_TREE, ridpointers[(int) RID_DOUBLE])); - ridpointers[(int) RID_SHORT] = get_identifier ("short"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SHORT], - build_tree_list (NULL_TREE, ridpointers[(int) RID_SHORT])); - ridpointers[(int) RID_LONG] = get_identifier ("long"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_LONG], - build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG])); - ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_UNSIGNED], - build_tree_list (NULL_TREE, ridpointers[(int) RID_UNSIGNED])); - ridpointers[(int) RID_SIGNED] = get_identifier ("signed"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SIGNED], - build_tree_list (NULL_TREE, ridpointers[(int) RID_SIGNED])); - ridpointers[(int) RID_INLINE] = get_identifier ("inline"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INLINE], - build_tree_list (NULL_TREE, ridpointers[(int) RID_INLINE])); - ridpointers[(int) RID_CONST] = get_identifier ("const"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CONST], - build_tree_list (NULL_TREE, ridpointers[(int) RID_CONST])); - ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOLATILE], - build_tree_list (NULL_TREE, ridpointers[(int) RID_VOLATILE])); - ridpointers[(int) RID_AUTO] = get_identifier ("auto"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_AUTO], - build_tree_list (NULL_TREE, ridpointers[(int) RID_AUTO])); - ridpointers[(int) RID_STATIC] = get_identifier ("static"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_STATIC], - build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC])); - ridpointers[(int) RID_EXTERN] = get_identifier ("extern"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXTERN], - build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN])); - ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TYPEDEF], - build_tree_list (NULL_TREE, ridpointers[(int) RID_TYPEDEF])); - ridpointers[(int) RID_REGISTER] = get_identifier ("register"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_REGISTER], - build_tree_list (NULL_TREE, ridpointers[(int) RID_REGISTER])); - - /* C++ extensions. These are probably not correctly named. */ - class_type_node = build_int_2 (class_type, 0); - TREE_TYPE (class_type_node) = class_type_node; - ridpointers[(int) RID_CLASS] = class_type_node; - - record_type_node = build_int_2 (record_type, 0); - TREE_TYPE (record_type_node) = record_type_node; - ridpointers[(int) RID_RECORD] = record_type_node; - - union_type_node = build_int_2 (union_type, 0); - TREE_TYPE (union_type_node) = union_type_node; - ridpointers[(int) RID_UNION] = union_type_node; - - enum_type_node = build_int_2 (enum_type, 0); - TREE_TYPE (enum_type_node) = enum_type_node; - ridpointers[(int) RID_ENUM] = enum_type_node; - - ridpointers[(int) RID_VIRTUAL] = get_identifier ("virtual"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VIRTUAL], - build_tree_list (NULL_TREE, ridpointers[(int) RID_VIRTUAL])); - ridpointers[(int) RID_FRIEND] = get_identifier ("friend"); - SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FRIEND], - build_tree_list (NULL_TREE, ridpointers[(int) RID_FRIEND])); - - /* Exception handling extensions. */ - exception_type_node = build_int_2 (exception_type, 0); - TREE_TYPE (exception_type_node) = exception_type_node; - ridpointers[(int) RID_EXCEPTION] = exception_type_node; - - opname_tab[(int) COMPONENT_REF] = "->"; - opname_tab[(int) METHOD_CALL_EXPR] = "->()"; - opname_tab[(int) INDIRECT_REF] = "(unary *)"; - opname_tab[(int) ARRAY_REF] = "[]"; - opname_tab[(int) MODIFY_EXPR] = "="; - opname_tab[(int) NEW_EXPR] = "new"; - opname_tab[(int) DELETE_EXPR] = "delete"; - opname_tab[(int) COND_EXPR] = "... ? ... : ..."; - opname_tab[(int) CALL_EXPR] = "()"; - opname_tab[(int) PLUS_EXPR] = "+"; - opname_tab[(int) MINUS_EXPR] = "-"; - opname_tab[(int) MULT_EXPR] = "*"; - opname_tab[(int) TRUNC_DIV_EXPR] = "/"; - opname_tab[(int) CEIL_DIV_EXPR] = "(ceiling /)"; - opname_tab[(int) FLOOR_DIV_EXPR] = "(floor /)"; - opname_tab[(int) ROUND_DIV_EXPR] = "(round /)"; - opname_tab[(int) TRUNC_MOD_EXPR] = "%"; - opname_tab[(int) CEIL_MOD_EXPR] = "(ceiling %)"; - opname_tab[(int) FLOOR_MOD_EXPR] = "(floor %)"; - opname_tab[(int) ROUND_MOD_EXPR] = "(round %)"; - opname_tab[(int) NEGATE_EXPR] = "-"; - opname_tab[(int) MIN_EXPR] = "?"; - opname_tab[(int) ABS_EXPR] = "abs"; - opname_tab[(int) FFS_EXPR] = "ffs"; - opname_tab[(int) LSHIFT_EXPR] = "<<"; - opname_tab[(int) RSHIFT_EXPR] = ">>"; - opname_tab[(int) BIT_IOR_EXPR] = "|"; - opname_tab[(int) BIT_XOR_EXPR] = "^"; - opname_tab[(int) BIT_AND_EXPR] = "&"; - opname_tab[(int) BIT_ANDTC_EXPR] = "&~"; - opname_tab[(int) BIT_NOT_EXPR] = "~"; - opname_tab[(int) TRUTH_ANDIF_EXPR] = "&&"; - opname_tab[(int) TRUTH_ORIF_EXPR] = "||"; - opname_tab[(int) TRUTH_AND_EXPR] = "strict &&"; - opname_tab[(int) TRUTH_OR_EXPR] = "strict ||"; - opname_tab[(int) TRUTH_NOT_EXPR] = "!"; - opname_tab[(int) LT_EXPR] = "<"; - opname_tab[(int) LE_EXPR] = "<="; - opname_tab[(int) GT_EXPR] = ">"; - opname_tab[(int) GE_EXPR] = ">="; - opname_tab[(int) EQ_EXPR] = "=="; - opname_tab[(int) NE_EXPR] = "!="; - opname_tab[(int) IN_EXPR] = "in"; - opname_tab[(int) SET_LE_EXPR] = "subset"; - opname_tab[(int) CARD_EXPR] = "#"; - opname_tab[(int) RANGE_EXPR] = ".."; - opname_tab[(int) CONVERT_EXPR] = "(unary +)"; - opname_tab[(int) ADDR_EXPR] = "(unary &)"; - opname_tab[(int) PREDECREMENT_EXPR] = "--"; - opname_tab[(int) PREINCREMENT_EXPR] = "++"; - opname_tab[(int) POSTDECREMENT_EXPR] = "--"; - opname_tab[(int) POSTINCREMENT_EXPR] = "++"; - opname_tab[(int) COMPOUND_EXPR] = ","; - assignop_tab[(int) NOP_EXPR] = "="; - assignop_tab[(int) PLUS_EXPR] = "+="; - assignop_tab[(int) MINUS_EXPR] = "-="; - assignop_tab[(int) MULT_EXPR] = "*="; - assignop_tab[(int) TRUNC_DIV_EXPR] = "/="; - assignop_tab[(int) CEIL_DIV_EXPR] = "(ceiling /=)"; - assignop_tab[(int) FLOOR_DIV_EXPR] = "(floor /=)"; - assignop_tab[(int) ROUND_DIV_EXPR] = "(round /=)"; - assignop_tab[(int) TRUNC_MOD_EXPR] = "%="; - assignop_tab[(int) CEIL_MOD_EXPR] = "(ceiling %=)"; - assignop_tab[(int) FLOOR_MOD_EXPR] = "(floor %=)"; - assignop_tab[(int) ROUND_MOD_EXPR] = "(round %=)"; - assignop_tab[(int) MIN_EXPR] = "?="; - assignop_tab[(int) LSHIFT_EXPR] = "<<="; - assignop_tab[(int) RSHIFT_EXPR] = ">>="; - assignop_tab[(int) BIT_IOR_EXPR] = "|="; - assignop_tab[(int) BIT_XOR_EXPR] = "^="; - assignop_tab[(int) BIT_AND_EXPR] = "&="; - - init_filename_times (); - -#define UNSET_RESERVED_WORD(STRING) \ - do { is_reserved_word (STRING, sizeof (STRING) - 1)->name = ""; } while (0) - - if (! flag_handle_exceptions) - { - /* Easiest way to not reconize exception - handling extenions... */ - UNSET_RESERVED_WORD ("all"); - UNSET_RESERVED_WORD ("except"); - UNSET_RESERVED_WORD ("exception"); - UNSET_RESERVED_WORD ("raise"); - UNSET_RESERVED_WORD ("raises"); - UNSET_RESERVED_WORD ("reraise"); - UNSET_RESERVED_WORD ("try"); - } - if (flag_no_asm) - UNSET_RESERVED_WORD ("asm"); - if (flag_no_asm || flag_traditional) - UNSET_RESERVED_WORD ("typeof"); - token_count = init_parse (); - interface_unknown = 1; -} - -void -reinit_parse_for_function () -{ - current_base_init_list = NULL_TREE; - current_member_init_list = NULL_TREE; -} - -/* Functions and data structures for #pragma interface. - - `#pragma implementation' means that the main file being compiled - is considered to implement (provide) the classes that appear in - its main body. I.e., if this is file "foo.cc", and class `bar' - is defined in "foo.cc", then we say that "foo.cc implements bar". - - All main input files "implement" themselves automagically. - - `#pragma interface' means that unless this file (of the form "foo.h" - is not presently being included by file "foo.cc", the - CLASSTYPE_INTERFACE_ONLY bit gets set. The effect is that none - of the vtables nor any of the inline functions defined in foo.h - will every be output. - - There are cases when we want to link files such as "defs.h" and - "main.cc". In this case, we give "defs.h" a `#pragma interface', - and "main.cc" has `#pragma implementation "defs.h"'. */ - -struct impl_files -{ - char *filename; - struct impl_files *next; -}; - -static struct impl_files *impl_file_chain; - -/* Helper function to load global variables with interface - information. */ -static void -extract_interface_info () -{ - tree fileinfo = get_time_identifier (input_filename); - fileinfo = IDENTIFIER_CLASS_VALUE (fileinfo); - interface_only = TREE_INT_CST_LOW (fileinfo); - interface_unknown = TREE_INT_CST_HIGH (fileinfo); -} - -/* Return nonzero if S and T are not considered part of an - INTERFACE/IMPLEMENTATION pair. Otherwise, return 0. */ -static int -interface_strcmp (s) - char *s; -{ - /* Set the interface/implementation bits for this scope. */ - struct impl_files *ifiles; - char *s1 = strrchr (s, '/'); - if (s1++ == 0) - s1 = s; - s = s1; - - for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next) - { - char *t1 = ifiles->filename; - s1 = s; - - if (*s1 != *t1 || *s1 == 0) - continue; - - while (*s1 == *t1 && *s1 != 0) - s1++, t1++; - - /* A match. */ - if (*s1 == *t1) - return 0; - - /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc. */ - if (strchr (s1, '.')) - continue; - - if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.') - continue; - - /* A match. */ - return 0; - } - - /* No matches. */ - return 1; -} - -void -set_typedecl_interface_info (prev, vars) - tree prev, vars; -{ - tree id = get_time_identifier (DECL_SOURCE_FILE (vars)); - tree fileinfo = IDENTIFIER_CLASS_VALUE (id); - tree type = TREE_TYPE (vars); - - CLASSTYPE_INTERFACE_ONLY (type) = TREE_INT_CST_LOW (fileinfo) - = interface_strcmp (DECL_SOURCE_FILE (vars)); -} - -void -set_vardecl_interface_info (prev, vars) - tree prev, vars; -{ -#if 0 - tree type = DECL_VPARENT (vars); -#else - tree type = DECL_CONTEXT (vars); -#endif - - if (CLASSTYPE_INTERFACE_UNKNOWN (type) == 0) - { - if (CLASSTYPE_INTERFACE_ONLY (type)) - set_typedecl_interface_info (prev, TYPE_NAME (type)); - TREE_EXTERNAL (vars) = CLASSTYPE_INTERFACE_ONLY (type); - TREE_PUBLIC (vars) = ! CLASSTYPE_INTERFACE_ONLY (type); - CLASSTYPE_VTABLE_NEEDS_WRITING (type) |= TREE_PUBLIC (vars); - } -} - -/* Called from the top level: if there are any pending inlines to - do, set up to process them now. */ -void -do_pending_inlines () -{ - if (finput == finput1) - { - struct pending_inline *prev = 0, *tail; - struct pending_inline *t = - (struct pending_inline *) obstack_alloc (&inline_text_obstack, - sizeof (struct pending_inline)); - - /* Record state we were in when we decided to process - inline functions instead. */ - t->next = pending_inlines; - pending_inlines = t; - t->lineno = lineno; - t->filename = input_filename; - t->fndecl = NULL_TREE; - t->token = yychar; - t->token_value = yylval.itype; - - /* Reverse the pending inline functions, since - they were cons'd instead of appended. */ - - for (; t; t = tail) - { - tail = t->next; - t->next = prev; - prev = t; - } - pending_inlines = prev; - - /* Now start processing the first inline function. */ - t = pending_inlines; - pending_inlines = pending_inlines->next; - - finput = finput2; - clearerr(finput2); - setvbuf (finput2, t->buf, _IOFBF, t->len - 1); - next_inline_count = t->len - 1; - - lineno = t->lineno; - input_filename = t->filename; - yychar = PRE_PARSED_FUNCTION_DECL; - yylval.ttype = t->fndecl; - if (flag_default_inline) - TREE_INLINE (t->fndecl) = 1; - } -} - -/* Since inline methods can refer to text which has not yet been seen, - we store the text of the method in a structure which is placed in the - DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL. - After parsing the body of the class definition, the FUNCTION_DECL's are - scanned to see which ones have this field set. Those are then digested - one at a time. - - This function's FUNCTION_DECL will have a bit set in its common so - that we know to watch out for it. */ - -void -consume_string (this_obstack) - register struct obstack *this_obstack; -{ - register char c; - do - { - c = getc (finput); - if (c == '\\') - { - obstack_1grow (this_obstack, c); - c = getch (); - obstack_1grow (this_obstack, c); - continue; - } - if (c == '\n') - { - if (pedantic) - warning ("ANSI C forbids newline in string constant"); - lineno++; - } - obstack_1grow (this_obstack, c); - } - while (c != '\"'); -} - -static int nextchar = -1; -static int nextyychar = -1; -static YYSTYPE nextyylval; -static tree nextlastiddecl; - -/* Get input from stream. When compiling under Cadillac, - the bytes must be coaxed out via their read protocol. - Otherwise, they come easily via standard input interface. */ -int -getch () -{ - register int ch = getc (finput); - return ch; -} - -/* Return next non-whitespace input character, which may come - from `finput', or from `nextchar'. */ -static int -yynextch () -{ - int c; - - if (nextchar >= 0) - { - c = nextchar; - nextchar = -1; - } - else c = getc (finput); - return skip_white_space (c); -} - -/* Unget character CH from the input stream. - If RESCAN is non-zero, then we want to `see' this - character as the next input token. */ -void -yyungetc (ch, rescan) - int ch; - int rescan; -{ - /* Unget a characater from the input stream. */ - if (yychar == YYEMPTY || rescan == 0) - ungetc (ch, finput); - else - { - if (nextyychar >= 0) - abort (); - nextyychar = yychar; - nextyylval = yylval; - yychar = ch; - } -} - -void -reinit_parse_for_method (yychar, decl) - int yychar; - tree decl; -{ - register char c = 0; - int blev = 1; - tree fndecl = decl; - int starting_lineno = lineno; - char *starting_filename = input_filename; - int len; - - if (yychar != '{') - { - if (yychar != ':' && yychar != RETURN) - { - yyerror ("parse error in method specification"); - yychar = '{'; - } - obstack_1grow (&inline_text_obstack, yychar); - while (c >= 0) - { - int this_lineno = lineno; - - c = yynextch (); - - /* Don't lose our cool if there are lots of comments. */ - if (lineno - this_lineno) - if (lineno - this_lineno == 1) - obstack_1grow (&inline_text_obstack, '\n'); - else - { - char buf[12]; - sprintf (buf, "\n# %d \"", lineno); - len = strlen (buf); - obstack_grow (&inline_text_obstack, buf, len); - - len = strlen (input_filename); - obstack_grow (&inline_text_obstack, input_filename, len); - obstack_1grow (&inline_text_obstack, '\"'); - obstack_1grow (&inline_text_obstack, '\n'); - } - - /* strings must be read differently than text. */ - if (c == '\"') - { - obstack_1grow (&inline_text_obstack, c); - consume_string (&inline_text_obstack); - c = yynextch (); - } - while (c > ' ') /* ASCII dependent! */ - { - obstack_1grow (&inline_text_obstack, c); - if (c == '{') goto main_loop; - if (c == '\"') - consume_string (&inline_text_obstack); - if (c == ';') - { - error ("function body for constructor missing"); - obstack_1grow (&inline_text_obstack, '{'); - obstack_1grow (&inline_text_obstack, '}'); - len += 2; - goto done; - } - c = getch (); - } - if (c == '\n') - lineno++; - obstack_1grow (&inline_text_obstack, c); - } - if (c == EOF) - { - error_with_file_and_line (starting_filename, - starting_lineno, - "parse error in method specification"); - } - } - else obstack_1grow (&inline_text_obstack, '{'); - - main_loop: - while (c >= 0) - { - int this_lineno = lineno; - - c = skip_white_space (getc (finput)); - - /* Don't lose our cool if there are lots of comments. */ - if (lineno - this_lineno) - if (lineno - this_lineno == 1) - obstack_1grow (&inline_text_obstack, '\n'); - else - { - char buf[12]; - sprintf (buf, "\n# %d \"", lineno); - len = strlen (buf); - obstack_grow (&inline_text_obstack, buf, len); - - len = strlen (input_filename); - obstack_grow (&inline_text_obstack, input_filename, len); - obstack_1grow (&inline_text_obstack, '\"'); - obstack_1grow (&inline_text_obstack, '\n'); - } - - while (c > ' ') - { - obstack_1grow (&inline_text_obstack, c); - if (c == '{') blev++; - else if (c == '}') - { - blev--; - if (blev == 0) - goto done; - } - else if (c == '\"') - consume_string (&inline_text_obstack); - c = getch (); - } - if (c == '\n') - lineno++; - obstack_1grow (&inline_text_obstack, c); - } - done: - current_base_init_list = NULL_TREE; - current_member_init_list = NULL_TREE; - -#ifdef USG_STDIO - len = obstack_object_size (&inline_text_obstack); - /* If the buffer given to setvbuf is shorter than eight bytes long, - setvbuf will (in violation of its man page) ignore the buffer - and call malloc to get a bigger one. */ - while (len < 8) - { - len++; - obstack_1grow (&inline_text_obstack, ' '); - } -#endif - - obstack_1grow (&inline_text_obstack, '\0'); - len = obstack_object_size (&inline_text_obstack); - - if (fndecl == void_type_node) - { - /* Happens when we get two declarations of the same - function in the same scope. */ - char *buf = obstack_base (&inline_text_obstack); - obstack_free (&inline_text_obstack, buf); - return; - } - else - { - struct pending_inline *t; - char *buf = obstack_base (&inline_text_obstack); - - obstack_finish (&inline_text_obstack); - - t = (struct pending_inline *) obstack_alloc (&inline_text_obstack, - sizeof (struct pending_inline)); - t->buf = buf; - t->len = len; - t->lineno = starting_lineno; - t->filename = starting_filename; - t->token = YYEMPTY; - DECL_PENDING_INLINE_INFO (fndecl) = t; - } -} - -/* Build a default function named NAME for type TYPE. - KIND says what to build. Currently only two kinds of default functions - are recognized: - - When KIND == 0, build default X(X&) constructor. - When KIND == 1, build default destructor. */ - -tree -cons_up_default_function (type, name, kind) - tree type, name; - int kind; -{ - extern tree void_list_node; - int len; - tree fn, args; - tree argtype; - - switch (kind) - { - case 0: - /* Destructor. */ - name = build_parse_node (BIT_NOT_EXPR, name); - /* Fall through... */ - case 2: - /* Default constructor. */ - args = void_list_node; - break; - - case 3: - type = build_type_variant (type, 1, 0); - /* Fall through... */ - case 1: - argtype = build_reference_type (type); - args = tree_cons (NULL_TREE, - build_tree_list (hash_tree_chain (argtype, NULL_TREE), - get_identifier ("arg")), - void_list_node); - break; - - default: - abort (); - } - - fn = start_method (NULL_TREE, - build_parse_node (CALL_EXPR, name, args, NULL_TREE), - NULL_TREE); - if (fn == void_type_node) - return fn; - - obstack_1grow (&inline_text_obstack, '{'); - obstack_1grow (&inline_text_obstack, '}'); -#ifdef USG_STDIO - len = 2; - while (len++ < 8) - obstack_1grow (&inline_text_obstack, ' '); -#endif - - obstack_1grow (&inline_text_obstack, '\0'); - current_base_init_list = NULL_TREE; - current_member_init_list = NULL_TREE; - - len = obstack_object_size (&inline_text_obstack); - - { - struct pending_inline *t; - char *buf = obstack_base (&inline_text_obstack); - - obstack_finish (&inline_text_obstack); - - t = (struct pending_inline *) obstack_alloc (&inline_text_obstack, - sizeof (struct pending_inline)); - t->buf = buf; - t->len = len; - t->lineno = lineno; - t->filename = input_filename; - t->token = YYEMPTY; - DECL_PENDING_INLINE_INFO (fn) = t; - /* We make this declaration private (static in the C sense). */ - TREE_PUBLIC (fn) = 0; - } - finish_method (fn); - DECL_COMPILER_GENERATED_P (fn) = 1; - return fn; -} - -/* Heuristic to tell whether the user is missing a semicolon - after a struct or enum declaration. Emit an error message - if we know the user has blown it. */ -void -check_for_missing_semicolon (type) - tree type; -{ - if (yychar < 0) - yychar = yylex (); - - if (yychar > 255 - && yychar != IDENTIFIER - && yychar != TYPENAME) - { - if (ANON_AGGRNAME_P (DECL_NAME (TYPE_NAME (type)))) - error ("semicolon missing after %s declaration", - TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct"); - else - error ("semicolon missing after declaration of `%s'", - TYPE_NAME_STRING (type)); - shadow_tag (build_tree_list (0, type)); - } - /* Could probably also hack cases where class { ... } f (); appears. */ -} - -void -note_got_semicolon (type) - tree type; -{ - if (IS_AGGR_TYPE (type)) - CLASSTYPE_GOT_SEMICOLON (type) = 1; -} - -/* If C is not whitespace, return C. - Otherwise skip whitespace and return first nonwhite char read. */ - -static int -skip_white_space (c) - register int c; -{ -#if 0 - register int inside; -#endif - - for (;;) - { - switch (c) - { - /* Don't recognize comments in cc1: all comments are removed by cpp, - and cpp output can include / and * consecutively as operators. */ -#if 0 - case '/': - c = getc (finput); - if (c != '*' && c != '/') - { - ungetc (c, finput); - return '/'; - } - - if (c == '/') - { - while (c != EOF) - { - c = getch (); - if (c == '\n') - { - ungetc (c, finput); - break; - } - } - if (c == EOF) - { - error ("unterminated comment"); - return EOF; - } - c = getch (); - break; - } - - c = getch (); - - inside = 1; - while (inside) - { - if (c == '*') - { - while (c == '*') - c = getch (); - - if (c == '/') - { - inside = 0; - c = getch (); - } - } - else if (c == '\n') - { - lineno++; - c = getch (); - } - else if (c == EOF) - { - error ("unterminated comment"); - break; - } - else - c = getch (); - } - - break; -#endif - - case '\n': - c = check_newline (); - break; - - case ' ': - case '\t': - case '\f': - case '\r': - case '\v': - case '\b': - do - c = getc (finput); - while (c == ' ' || c == '\t'); - break; - - case '\\': - c = getch (); - if (c == '\n') - lineno++; - else - error ("stray '\\' in program"); - c = getch (); - break; - - default: - return (c); - } - } -} - - - -/* Make the token buffer longer, preserving the data in it. - P should point to just beyond the last valid character in the old buffer. - The value we return is a pointer to the new buffer - at a place corresponding to P. */ - -static char * -extend_token_buffer (p) - char *p; -{ - int offset = p - token_buffer; - - maxtoken = maxtoken * 2 + 10; - token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2); - - return token_buffer + offset; -} - -#ifdef HAVE_UNDUMP -#ifndef MERGED -/* This includes code from write_segment, stolen from unexec.c */ - -void dump_data() -{ - int new; - register caddr_t ptr, end; - register int i, nwrite, ret; - char buf[80]; - extern int errno; - char zeros[128]; - - extern int been_here_before, just_done_unexec, my_edata; - extern char *dump_source_name; - extern char *asm_file_name, previous_asm_file_name[]; - char dump_file_name[256]; /* Fixed-sized buffer -- sigh. */ - caddr_t end_of_data, end_of_heap; - int data_size, token; - register int c; - - bzero (zeros, sizeof zeros); - - /* Here we have just seen `#pragma dump '. - The name to dump to, a string constant, may follow. */ - - do - c = getch (); - while (c == ' ' || c == '\t'); - - /* If no argument, default to something like "dumped-cc1plus". */ - if (c == '\n') - { - char *tmp; - strcpy (dump_file_name, "dumped-"); - if (tmp = strrchr (dump_source_name, '/')) - dump_source_name = tmp + 1; - strcat (dump_file_name, dump_source_name); - } - else - { - ungetc (c, finput); - token = yylex (); - if (token != STRING - || TREE_CODE (yylval.ttype) != STRING_CST) - { - error ("invalid #pragma dump"); - return; - } - - strcpy (dump_file_name, TREE_STRING_POINTER (yylval.ttype)); - } - - been_here_before = 1; /* Raise the flag! */ - strcpy(previous_asm_file_name, asm_file_name); - printf("\nDumping %s to %s...\n", dump_source_name, dump_file_name); - - end_of_heap = (caddr_t)sbrk(0); - end_of_data = (caddr_t)((int)(&my_edata)&~(getpagesize()-1)); - data_size = (int)(end_of_heap-end_of_data); - printf("Data size = %d\n", data_size); - - new = creat (dump_file_name, 0666); - - ptr = end_of_data; - end = end_of_heap; - - for (i = 0; ptr < end;) - { - /* distance to next multiple of 128. */ - nwrite = (((int) ptr + 128) & -128) - (int) ptr; - /* But not beyond specified end. */ - if (nwrite > end - ptr) nwrite = end - ptr; - ret = write (new, ptr, nwrite); - /* If write gets a page fault, it means we reached - a gap between the old text segment and the old data segment. - This gap has probably been remapped into part of the text segment. - So write zeros for it. */ - if (ret == -1 && errno == EFAULT) - write (new, zeros, nwrite); - else if (nwrite != ret) - { - sprintf (buf, - "unexec write failure: addr 0x%x, fileno %d, size 0x%x, wrote 0x%x, errno %d", - ptr, new, nwrite, ret, errno); - perror (buf); - return; - } - i += nwrite; - ptr += nwrite; - } - - close (new); - - just_done_unexec = 1; /* Tell toplev not to output ending. */ -} -#endif -#endif - -static int -get_last_nonwhite_on_line () -{ - register int c; - - /* Is this the last nonwhite stuff on the line? */ - if (nextchar >= 0) - c = nextchar, nextchar = -1; - else - c = getc (finput); - - while (c == ' ' || c == '\t') - c = getc (finput); - return c; -} - -/* At the beginning of a line, increment the line number - and process any #-directive on this line. - If the line is a #-directive, read the entire line and return a newline. - Otherwise, return the line's first non-whitespace character. */ - -int -check_newline () -{ - register int c; - register int token; - - lineno++; - - /* Read first nonwhite char on the line. */ - - do - c = getc (finput); - while (c == ' ' || c == '\t'); - - if (c != '#') - { - /* If not #, return it so caller will use it. */ - return c; - } - - /* Read first nonwhite char after the `#'. */ - - do - c = getch (); - while (c == ' ' || c == '\t'); - - /* If a letter follows, then if the word here is `line', skip - it and ignore it; otherwise, ignore the line, with an error - if the word isn't `pragma'. */ - - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) - { - if (c == 'p') - { - if (getch () == 'r' - && getch () == 'a' - && getch () == 'g' - && getch () == 'm' - && getch () == 'a') -/* Change by Bryan Boreham, Kewill, Sun Jul 23 15:53:24 1989. - This whole section added to support dumping of - compilations in the middle. */ - { - /* Read first nonwhite char after the `#pragma'. */ - - do - c = getch (); - while (c == ' ' || c == '\t'); - -#ifndef MERGED - /* See if it is "dump" */ - - if (c == 'd' - && getch () == 'u' - && getch () == 'm' - && getch () == 'p' - && ((c = getch ()) == ' ' || c == '\t' || c == '\n')) - { -#ifndef HAVE_UNDUMP - ; /* Are you crazy? */ -#else - ungetc (c, finput); - dump_data(); - longjmp (toplevel, 1); -#endif - } - else -#endif - if (c == 'v' - && getch () == 't' - && getch () == 'a' - && getch () == 'b' - && getch () == 'l' - && getch () == 'e' - && ((c = getch ()) == ' ' || c == '\t' || c == '\n')) - { - extern tree pending_vtables; - - /* More follows: it must be a string constant (class name). */ - token = yylex (); - if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST) - { - error ("invalid #pragma vtable"); - goto skipline; - } - if (write_virtuals != 2) - { - warning ("use `+e2' option to enable #pragma vtable"); - goto skipline; - } - pending_vtables = perm_tree_cons (NULL_TREE, get_identifier (TREE_STRING_POINTER (yylval.ttype)), pending_vtables); - if (nextchar < 0) - nextchar = getch (); - c = nextchar; - if (c != '\n') - warning ("trailing characters ignored"); - } - else if (c == 'u' - && getch () == 'n' - && getch () == 'i' - && getch () == 't' - && ((c = getch ()) == ' ' || c == '\t' || c == '\n')) - { - /* More follows: it must be a string constant (unit name). */ - token = yylex (); - if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST) - { - error ("invalid #pragma unit"); - goto skipline; - } - current_unit_name = get_identifier (TREE_STRING_POINTER (yylval.ttype)); - current_unit_language = current_lang_name; - if (nextchar < 0) - nextchar = getch (); - c = nextchar; - if (c != '\n') - warning ("trailing characters ignored"); - } - else if (c == 'i') - { - tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename)); - c = getch (); - - if (c == 'n' - && getch () == 't' - && getch () == 'e' - && getch () == 'r' - && getch () == 'f' - && getch () == 'a' - && getch () == 'c' - && getch () == 'e' - && ((c = getch ()) == ' ' || c == '\t' || c == '\n')) - { - /* read to newline. */ - while (c != '\n') - c = getch (); - - write_virtuals = 3; - - if (impl_file_chain == 0) - { - char *filename; - tree fi; - - /* If this is zero at this point, then we are - auto-implementing. */ - if (main_input_filename == 0) - main_input_filename = input_filename; - - filename = strrchr (main_input_filename, '/'); - if (filename++ == 0) - filename = main_input_filename; - fi = get_time_identifier (filename); - fi = IDENTIFIER_CLASS_VALUE (fi); - TREE_INT_CST_LOW (fi) = 0; - TREE_INT_CST_LOW (fi) = 0; - /* Get default. */ - impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files)); - impl_file_chain->filename = filename; - impl_file_chain->next = 0; - } - - interface_only = interface_strcmp (input_filename); - interface_unknown = 0; - TREE_INT_CST_LOW (fileinfo) = interface_only; - TREE_INT_CST_HIGH (fileinfo) = interface_unknown; - } - else if (c == 'm' - && getch () == 'p' - && getch () == 'l' - && getch () == 'e' - && getch () == 'm' - && getch () == 'e' - && getch () == 'n' - && getch () == 't' - && getch () == 'a' - && getch () == 't' - && getch () == 'i' - && getch () == 'o' - && getch () == 'n' - && ((c = getch ()) == ' ' || c == '\t' || c == '\n')) - { - char *main_filename = main_input_filename ? main_input_filename : input_filename; - char *tmp; - - while (c == ' ' || c == '\t') - c = getch (); - if (c != '\n') - { - ungetc (c, finput); - token = yylex (); - if (token != STRING - || TREE_CODE (yylval.ttype) != STRING_CST) - { - error ("invalid `#pragma implementation'"); - goto skipline; - } - main_filename = TREE_STRING_POINTER (yylval.ttype); - } - tmp = strrchr (main_filename, '/'); - if (tmp++) - main_filename = tmp; - - /* read to newline. */ - while (c != '\n') - c = getch (); - - if (write_virtuals == 3) - { - struct impl_files *ifiles = impl_file_chain; - while (ifiles) - { - if (! strcmp (ifiles->filename, main_filename)) - break; - ifiles = ifiles->next; - } - if (ifiles == 0) - { - ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files)); - ifiles->filename = main_filename; - ifiles->next = impl_file_chain; - impl_file_chain = ifiles; - } - } - else if (main_input_filename == input_filename - || ! strcmp (input_filename, main_filename)) - { - write_virtuals = 3; - if (impl_file_chain == 0) - { - impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files)); - impl_file_chain->filename = main_filename; - impl_file_chain->next = 0; - } - } - else - error ("`#pragma implementation' can only appear at top-level"); - interface_only = 0; - interface_unknown = 0; - TREE_INT_CST_LOW (fileinfo) = interface_only; - TREE_INT_CST_HIGH (fileinfo) = interface_unknown; - } - } - } - goto skipline; - } - - else if (c == 'l') - { - if (getch () == 'i' - && getch () == 'n' - && getch () == 'e' - && ((c = getch ()) == ' ' || c == '\t')) - goto linenum; - } - else if (c == 'i') - { - if (getch () == 'd' - && getch () == 'e' - && getch () == 'n' - && getch () == 't' - && ((c = getch ()) == ' ' || c == '\t')) - { - /* Conditionally used. */ - extern FILE *asm_out_file; - - if (pedantic) - error ("ANSI C does not allow #ident"); - - /* Here we have just seen `#ident '. - A string constant should follow. */ - - while (c == ' ' || c == '\t') - c = getch (); - - /* If no argument, ignore the line. */ - if (c == '\n') - return c; - - ungetc (c, finput); - token = yylex (); - if (token != STRING - || TREE_CODE (yylval.ttype) != STRING_CST) - { - error ("invalid #ident"); - goto skipline; - } - -#ifdef ASM_OUTPUT_IDENT - ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (yylval.ttype)); -#endif - - /* Skip the rest of this line. */ - goto skipline; - } - } - else if (c == 'n') - { - if (getch () == 'e' - && getch () == 'w' - && getch () == 'w' - && getch () == 'o' - && getch () == 'r' - && getch () == 'l' - && getch () == 'd' - && ((c = getch ()) == ' ' || c == '\t')) - { - /* Used to test incremental compilation. */ - sorry ("#pragma newworld"); - goto skipline; - } - } - error ("undefined or invalid # directive"); - goto skipline; - } - -linenum: - /* Here we have either `#line' or `# '. - In either case, it should be a line number; a digit should follow. */ - - while (c == ' ' || c == '\t') - c = getch (); - - /* If the # is the only nonwhite char on the line, - just ignore it. Check the new newline. */ - if (c == '\n') - return c; - - /* Something follows the #; read a token. */ - - ungetc (c, finput); - token = yylex (); - - if (token == CONSTANT - && TREE_CODE (yylval.ttype) == INTEGER_CST) - { - int old_lineno = lineno; - /* subtract one, because it is the following line that - gets the specified number */ - - int l = TREE_INT_CST_LOW (yylval.ttype) - 1; - c = get_last_nonwhite_on_line (); - if (c == '\n') - { - /* No more: store the line number and check following line. */ - lineno = l; - return c; - } - ungetc (c, finput); - - /* More follows: it must be a string constant (filename). */ - - token = yylex (); - if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST) - { - error ("invalid #line"); - goto skipline; - } - - /* Changing files again. This means currently collected time - is charged against header time, and body time starts back - at 0. */ - if (flag_detailed_statistics) - { - int this_time = my_gettime (); - tree time_identifier = get_time_identifier (TREE_STRING_POINTER (yylval.ttype)); - header_time += this_time - body_time; - TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) - += this_time - body_time; - this_filename_time = time_identifier; - body_time = this_time; - } - - if (flag_cadillac) - cadillac_note_source (); - - input_filename - = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1); - strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype)); - lineno = l; -#ifdef FIELD_XREF - FIELD_xref_file(input_filename); -#endif - - if (main_input_filename == 0) - { - extern int been_here_before; - struct impl_files *ifiles = impl_file_chain; - - if (ifiles) - { - while (ifiles->next) - ifiles = ifiles->next; - ifiles->filename = (char *)strrchr (input_filename, '/'); - if (ifiles->filename++ == 0) - ifiles->filename = input_filename; - } - - main_input_filename = input_filename; - if (write_virtuals == 3) - walk_vtables (set_typedecl_interface_info, set_vardecl_interface_info); - } - - extract_interface_info (); - - c = get_last_nonwhite_on_line (); - if (c == '\n') - { - if (flag_cadillac) - cadillac_switch_source (-1); - return c; - } - ungetc (c, finput); - - token = yylex (); - - /* `1' after file name means entering new file. - `2' after file name means just left a file. */ - - if (token == CONSTANT - && TREE_CODE (yylval.ttype) == INTEGER_CST) - { - if (TREE_INT_CST_LOW (yylval.ttype) == 1) - { - struct file_stack *p - = (struct file_stack *) xmalloc (sizeof (struct file_stack)); - input_file_stack->line = old_lineno; - p->next = input_file_stack; - p->name = input_filename; - input_file_stack = p; - input_file_stack_tick++; - - if (flag_cadillac) - cadillac_push_source (); - } - else if (input_file_stack->next) - { - struct file_stack *p = input_file_stack; - - if (flag_cadillac) - cadillac_pop_source (); - - input_file_stack = p->next; - free (p); - input_file_stack_tick++; - } - else - error ("#-lines for entering and leaving files don't match"); - } - else if (flag_cadillac) - cadillac_switch_source (-1); - - /* If NEXTCHAR is not end of line, we don't care what it is. */ - if (nextchar == '\n') - return '\n'; - } - else - error ("invalid #-line"); - - /* skip the rest of this line. */ - skipline: - if (c == '\n') - return c; - while ((c = getch ()) != EOF && c != '\n'); - return c; -} - -#if 0 -#define isalnum(char) (char >= 'a' ? char <= 'z' : char >= '0' ? char <= '9' || (char >= 'A' && char <= 'Z') : 0) -#define isdigit(char) (char >= '0' && char <= '9') -#else -#include -#endif - -#define ENDFILE -1 /* token that represents end-of-file */ - -static int -readescape () -{ - register int c = getc (finput); - register int count, code; - int firstdig; - - switch (c) - { - case 'x': - code = 0; - count = 0; - while (1) - { - c = getch (); - if (! isxdigit (c)) - { - ungetc (c, finput); - break; - } - code *= 16; - if (c >= 'a' && c <= 'f') - code += c - 'a' + 10; - if (c >= 'A' && c <= 'F') - code += c - 'A' + 10; - if (c >= '0' && c <= '9') - code += c - '0'; - if (count == 0) - firstdig = code; - count++; - } - if (count == 0) - error ("\\x used with no following hex digits"); - else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node) - || ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4)) - <= firstdig)) - warning ("hex escape out of range"); - return code; - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': - code = 0; - count = 0; - while ((c <= '7') && (c >= '0') && (count++ < 3)) - { - code = (code * 8) + (c - '0'); - c = getch (); - } - ungetc (c, finput); - return code; - - case '\\': case '\'': case '"': - return c; - - case '\n': - lineno++; - return -1; - - case 'n': - return TARGET_NEWLINE; - - case 't': - return TARGET_TAB; - - case 'r': - return TARGET_CR; - - case 'f': - return TARGET_FF; - - case 'b': - return TARGET_BS; - - case 'a': - return TARGET_BELL; - - case 'v': - return TARGET_VT; - - case 'E': - return 033; - - case '?': - /* `\(', etc, are used at beginning of line to avoid confusing Emacs. */ - case '(': - case '{': - case '[': - return c; - } - if (c >= 040 && c <= 0177) - warning ("unknown escape sequence `\\%c'", c); - else - warning ("unknown escape sequence: `\\' followed by char code 0x%x", c); - return c; -} - -/* Value is 1 if we should try to make the next identifier look like a - typename (when it may be a local variable or a class variable). - Value is 0 if we treat this name in a default fashion. - Value is -1 if we must not see a type name. */ -int looking_for_typename = 0; - -void -dont_see_typename () -{ - looking_for_typename = -1; - if (yychar == TYPENAME) - { - yychar = IDENTIFIER; - lastiddecl = 0; - } -} - -void -see_typename () -{ - looking_for_typename = 0; - if (yychar == IDENTIFIER) - { - lastiddecl = lookup_name (yylval.ttype); - if (lastiddecl == 0 && flag_labels_ok) - lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype); - else if (lastiddecl != 0 - && TREE_CODE (lastiddecl) == TYPE_DECL) - yychar = TYPENAME; - } -} - -tree do_identifier (token) - register tree token; -{ - register tree id = lastiddecl; - - if (yychar == YYEMPTY) - yychar = yylex (); - /* Scope class declarations before global - declarations. */ - if (id == IDENTIFIER_GLOBAL_VALUE (token) - && current_class_type != 0 - && TYPE_SIZE (current_class_type) == 0) - { - /* Could be from one of the base classes. */ - tree field = lookup_field (current_class_type, token, 1); - if (field == 0) - ; - else if (field == error_mark_node) - /* We have already generated the error message. - But we still want to return this value. */ - id = lookup_field (current_class_type, token, 0); - else if (TREE_CODE (field) == VAR_DECL - || TREE_CODE (field) == CONST_DECL) - id = field; - else if (TREE_CODE (field) != FIELD_DECL) - abort (); - else - { - error_with_decl (field, "invalid use of member `%s' from base class `%s'", - TYPE_NAME_STRING (DECL_FIELD_CONTEXT (field))); - id = error_mark_node; - return id; - } - } - - if (!id || id == error_mark_node) - { - if (yychar == '(' || yychar == LEFT_RIGHT) - { - id = implicitly_declare (token); - assemble_external (id); - TREE_USED (id) = 1; - } - else if (current_function_decl == 0) - { - error ("`%s' undeclared, outside of functions", - IDENTIFIER_POINTER (token)); - id = error_mark_node; - } - else - { - if (IDENTIFIER_GLOBAL_VALUE (token) != error_mark_node - || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl) - { - extern int undeclared_variable_notice; - - error ("`%s' undeclared (first use this function)", - IDENTIFIER_POINTER (token)); - - if (! undeclared_variable_notice) - { - error ("(Each undeclared identifier is reported only once"); - error ("for each function it appears in.)"); - undeclared_variable_notice = 1; - } - } - id = error_mark_node; - /* Prevent repeated error messages. */ - IDENTIFIER_GLOBAL_VALUE (token) = error_mark_node; - SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl); - } - } - /* TREE_USED is set in `hack_identifier'. */ - if (TREE_CODE (id) == CONST_DECL) - { - if (IDENTIFIER_CLASS_VALUE (token) == id) - { - /* Check visibility. */ - enum visibility_type visibility - = compute_visibility (CLASSTYPE_AS_LIST (current_class_type), id); - if (visibility == visibility_private) - error_with_decl (id, "enum `%s' is private"); - /* protected is OK, since it's an enum of `this'. */ - } - id = DECL_INITIAL (id); - } - else id = hack_identifier (id, token, yychar); - return id; -} - -int -yylex () -{ - tree tmp; - register int c; - register int value; - int wide_flag = 0; - int dollar_seen = 0; - - relex: - if (nextyychar >= 0) - { - value = nextyychar; - yylval = nextyylval; - lastiddecl = nextlastiddecl; - nextyychar = -1; - if (value == IDENTIFIER) - { - tmp = yylval.ttype; - goto resume_identifier_processing; - } - goto done; - } - if (nextchar >= 0) - c = nextchar, nextchar = -1; - else - c = getc (finput); - - /* Effectively do c = skip_white_space (c) - but do it faster in the usual cases. */ - while (1) - switch (c) - { - case ' ': - case '\t': - case '\f': - case '\r': - case '\v': - case '\b': - c = getc (finput); - break; - - case '\n': - case '/': - case '\\': - c = skip_white_space (c); - default: - goto found_nonwhite; - } - found_nonwhite: - - token_buffer[0] = c; - token_buffer[1] = 0; - -/* yylloc.first_line = lineno; */ - - switch (c) - { - case EOF: - token_buffer[0] = '\0'; - if (pending_inlines) - { - struct pending_inline *t; - - t = pending_inlines; -#ifdef DO_METHODS_THE_OLD_WAY - yylval.itype = t->token_value; - value = t->token; -#else - if (t->fndecl == 0) - { - yylval.itype = t->token_value; - value = t->token; - } - else - { - yylval.ttype = t->fndecl; - value = PRE_PARSED_FUNCTION_DECL; - } -#endif - - lineno = t->lineno; -/* yylloc.first_line = lineno; */ - input_filename = t->filename; - - if (t->next) - { - /* The buffer we used will be freed at the - end of this function. */ - pending_inlines = pending_inlines->next; - clearerr(finput2); - setvbuf (finput2, t->buf, _IOFBF, t->len - 1); - next_inline_count = t->len - 1; - } - else - { - pending_inlines = NULL; - finput = finput1; - obstack_free (&inline_text_obstack, inline_text_firstobj); - } - /* The space used by T will be freed after all inline - functions have been processed. */ - if (value <= 0) - goto relex; - else - goto done; - } - end_of_file = 1; - value = ENDFILE; - break; - - case '$': - if (dollars_in_ident) - { - dollar_seen = 1; - goto letter; - } - value = '$'; - goto done; - - case 'L': - /* Capital L may start a wide-string or wide-character constant. */ - { - register int c = getch (); - if (c == '\'') - { - wide_flag = 1; - goto char_constant; - } - if (c == '"') - { - wide_flag = 1; - goto string_constant; - } - ungetc (c, finput); - } - - case 'A': case 'B': case 'C': case 'D': case 'E': - case 'F': case 'G': case 'H': case 'I': case 'J': - case 'K': case 'M': case 'N': case 'O': - case 'P': case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': case 'Y': - case 'Z': - case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'i': case 'j': - case 'k': case 'l': case 'm': case 'n': case 'o': - case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': - case 'z': - case '_': - letter: - { - register char *p; - - p = token_buffer; - while (isalnum(c) || (c == '_') || c == '$') - { - if (p >= token_buffer + maxtoken) - p = extend_token_buffer (p); - if (c == '$' && ! dollars_in_ident) - break; - - *p++ = c; - c = getc (finput); - } - - *p = 0; - nextchar = c; - - value = IDENTIFIER; - yylval.itype = 0; - - /* Try to recognize a keyword. Uses minimum-perfect hash function */ - - { - register struct resword *ptr; - - if (ptr = is_reserved_word (token_buffer, p - token_buffer)) - { - if (current_lang_name != lang_name_cplusplus) - { - if (ptr->rid != 0 - && (ptr->rid == RID_CLASS - || ptr->rid == RID_FRIEND - || ptr->rid == RID_VIRTUAL - || (flag_no_asm && ptr->rid == RID_INLINE))) - { - ptr = 0; - goto not_reserved_word_after_all; - } - if (flag_traditional - && ((int) ptr->token == TYPEOF - || ptr->rid == RID_SIGNED - || ptr->rid == RID_INLINE)) - { - ptr = 0; - goto not_reserved_word_after_all; - } - } - if (ptr->rid) - { - tree old_ttype = ridpointers[(int) ptr->rid]; - - /* If this provides a type for us, then revert lexical - state to standard state. */ - if (TREE_CODE (old_ttype) == IDENTIFIER_NODE - && IDENTIFIER_GLOBAL_VALUE (old_ttype) != 0 - && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (old_ttype)) == TYPE_DECL) - looking_for_typename = 0; - - /* Check if this is a language-type declaration. - Just glimpse the next non-white character. */ - nextchar = skip_white_space (nextchar); - if (nextchar == '"') - { - /* We are looking at a string. Complain - if the token before the string is no `extern'. - - Could cheat some memory by placing this string - on the temporary_, instead of the saveable_ - obstack. */ - - if (ptr->rid != RID_EXTERN) - error ("invalid modifier `%s' for language string", - ptr->name); - yylex (); - value = EXTERN_LANG_STRING; - yylval.ttype = get_identifier (TREE_STRING_POINTER (yylval.ttype)); - break; - } - yylval.ttype = old_ttype; - } - value = (int) ptr->token; - } - not_reserved_word_after_all: - ; - } - - /* If we did not find a keyword, look for an identifier - (or a typename). */ - -#ifdef FIELD_XREF - if (value == IDENTIFIER || value == TYPESPEC) - FIELD_xref_ref(current_function_decl,token_buffer); -#endif - if (value == IDENTIFIER) - { - tmp = get_identifier (token_buffer); -#ifndef VMS - /* Make sure that user does not collide with our internal - naming scheme. */ - if (JOINER == '$' - && dollar_seen - && (THIS_NAME_P (tmp) - || VPTR_NAME_P (tmp) - || DESTRUCTOR_NAME_P (tmp) - || WRAPPER_OR_ANTI_WRAPPER_NAME_P (tmp) - || OPERATOR_NAME_P (tmp) - || VTABLE_NAME_P (tmp) - || OPERATOR_TYPENAME_P (tmp) - || TEMP_NAME_P (tmp) - || ANON_AGGRNAME_P (tmp) - || ANON_PARMNAME_P (tmp))) - warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy", - token_buffer); -#endif - - /* Come into here if we must reprocess an identifier. */ - resume_identifier_processing: - - if (looking_for_typename == 1 - && TREE_TYPE (tmp) != 0) - lastiddecl = TREE_TYPE (tmp); - else lastiddecl = lookup_name (tmp); - - if (lastiddecl && TREE_CODE (lastiddecl) == TYPE_DECL - && looking_for_typename >= 0) - { - /* This call could blow away yylval. */ - - c = skip_white_space (nextchar); - if (c == ':') - { - c = getch (); - if (c == ':') - { - nextchar = -1; - value = TYPENAME_SCOPE; - } - else - { - nextchar = c; - value = TYPENAME_COLON; - } - } - else if (c == '.' - && current_function_decl == NULL_TREE - && current_class_type == NULL_TREE) - { - c = getch (); - if (c == '.') - { - nextchar = -1; - c = getch (); - if (c != '.') - error ("missing '.' in `...'"); - value = TYPENAME_ELLIPSIS; - tmp = build_tree_list (NULL_TREE, build_tree_list (TREE_TYPE (lastiddecl), NULL_TREE)); - } - else - { - nextchar = c; - warning ("use of obsolete scope operator `.'; use `::' instead"); - value = TYPENAME_SCOPE; - } - looking_for_typename = 0; - } - else - { - nextchar = c; - value = TYPENAME; - if (looking_for_typename == 1) - { - looking_for_typename = 0; -#if 0 - yylval.ttype = TREE_TYPE (lastiddecl); - break; -#endif - } - } - } - else if (lastiddecl == 0 && flag_labels_ok) - lastiddecl = IDENTIFIER_LABEL_VALUE (tmp); - - yylval.ttype = tmp; - } - if (value == NEW && ! global_bindings_p ()) - { - looking_for_typename = 1; - value = NEW; - goto done; - } - } - break; - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case '.': - { - register char *p; - int base = 10; - int count = 0; - int largest_digit = 0; - int numdigits = 0; - /* for multi-precision arithmetic, - we store only 8 live bits in each short, - giving us 64 bits of reliable precision */ - short shorts[8]; - - enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag - = NOT_FLOAT; - - p = token_buffer; - *p++ = c; - - /* Optimize for most frequent case. */ - if (c == '0' || c == '1') - { - register int c1 = getch (); - if (! isalnum (c1) && c1 != '.') - { - /* Terminate string. */ - *p = 0; - if (c == '0') - yylval.ttype = integer_zero_node; - else - yylval.ttype = integer_one_node; - nextchar = c1; - value = CONSTANT; - goto done; - } - ungetc (c1, finput); - } - - for (count = 0; count < 8; count++) - shorts[count] = 0; - - if (c == '0') - { - *p++ = (c = getch ()); - if ((c == 'x') || (c == 'X')) - { - base = 16; - *p++ = (c = getch ()); - } - else - { - base = 8; - numdigits++; - } - } - - /* Read all the digits-and-decimal-points. */ - - while (c == '.' - || (isalnum (c) && (c != 'l') && (c != 'L') - && (c != 'u') && (c != 'U') - && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F'))))) - { - if (c == '.') - { - if (base == 16) - error ("floating constant may not be in radix 16"); - if (floatflag == AFTER_POINT) - { - error ("malformed floating constant"); - floatflag = TOO_MANY_POINTS; - } - else - floatflag = AFTER_POINT; - - base = 10; - *p++ = c = getch (); - /* Accept '.' as the start of a floating-point number - only when it is followed by a digit. - Otherwise, unread the following non-digit - and use the '.' as a structural token. */ - if (p == token_buffer + 2 && !isdigit (c)) - { - if (c == '.') - { - c = getch (); - if (c == '.') - { - *p++ = '.'; - *p = '\0'; - value = ELLIPSIS; - goto done; - } - nextchar = c; - token_buffer[2] = '\0'; - value = RANGE; - goto done; - } - nextchar = c; - token_buffer[1] = '\0'; - value = '.'; - goto done; - } - } - else - { - /* It is not a decimal point. - It should be a digit (perhaps a hex digit). */ - - if (isdigit (c)) - { - c = c - '0'; - } - else if (base <= 10) - { - if ((c&~040) == 'E') - { - base = 10; - floatflag = AFTER_POINT; - break; /* start of exponent */ - } - error ("nondigits in number and not hexadecimal"); - c = 0; - } - else if (c >= 'a') - { - c = c - 'a' + 10; - } - else - { - c = c - 'A' + 10; - } - if (c >= largest_digit) - largest_digit = c; - numdigits++; - - for (count = 0; count < 8; count++) - { - (shorts[count] *= base); - if (count) - { - shorts[count] += (shorts[count-1] >> 8); - shorts[count-1] &= (1<<8)-1; - } - else shorts[0] += c; - } - - if (p >= token_buffer + maxtoken - 3) - p = extend_token_buffer (p); - *p++ = (c = getch ()); - } - } - - if (numdigits == 0) - error ("numeric constant with no digits"); - - if (largest_digit >= base) - error ("numeric constant contains digits beyond the radix"); - - /* Remove terminating char from the token buffer and delimit the string */ - *--p = 0; - - if (floatflag != NOT_FLOAT) - { - tree type = double_type_node; - char f_seen = 0; - char l_seen = 0; - double value; - - /* Read explicit exponent if any, and put it in tokenbuf. */ - - if ((c == 'e') || (c == 'E')) - { - if (p >= token_buffer + maxtoken - 3) - p = extend_token_buffer (p); - *p++ = c; - c = getch (); - if ((c == '+') || (c == '-')) - { - *p++ = c; - c = getch (); - } - if (! isdigit (c)) - error ("floating constant exponent has no digits"); - while (isdigit (c)) - { - if (p >= token_buffer + maxtoken - 3) - p = extend_token_buffer (p); - *p++ = c; - c = getch (); - } - } - - *p = 0; - errno = 0; - value = atof (token_buffer); -#ifdef ERANGE - if (errno == ERANGE && !flag_traditional) - { - char *p1 = token_buffer; - /* Check for "0.0" and variants; - Sunos 4 spuriously returns ERANGE for them. */ - while (*p1 == '0') p1++; - if (*p1 == '.') p1++; - while (*p1 == '0') p1++; - if (*p1 != 0) - warning ("floating point number exceeds range of `double'"); - } -#endif - - /* Read the suffixes to choose a data type. */ - while (1) - { - if (c == 'f' || c == 'F') - { - if (f_seen) - error ("two `f's in floating constant"); - f_seen = 1; - type = float_type_node; - } - else if (c == 'l' || c == 'L') - { - if (l_seen) - error ("two `l's in floating constant"); - l_seen = 1; - type = long_double_type_node; - } - else - { - if (isalnum (c)) - { - error ("garbage at end of number"); - while (isalnum (c)) - { - if (p >= token_buffer + maxtoken - 3) - p = extend_token_buffer (p); - *p++ = c; - c = getch (); - } - } - break; - } - if (p >= token_buffer + maxtoken - 3) - p = extend_token_buffer (p); - *p++ = c; - c = getch (); - } - - /* Create a node with determined type and value. */ - yylval.ttype = build_real (type, value); - - ungetc (c, finput); - *p = 0; - } - else - { - tree type; - int spec_unsigned = 0; - int spec_long = 0; - - while (1) - { - if (c == 'u' || c == 'U') - { - if (spec_unsigned) - error ("two `u's in integer constant"); - spec_unsigned = 1; - } - else if (c == 'l' || c == 'L') - { - if (spec_long) - error ("two `l's in integer constant"); - spec_long = 1; - } - else - { - if (isalnum (c)) - { - error ("garbage at end of number"); - while (isalnum (c)) - { - if (p >= token_buffer + maxtoken - 3) - p = extend_token_buffer (p); - *p++ = c; - c = getch (); - } - } - break; - } - if (p >= token_buffer + maxtoken - 3) - p = extend_token_buffer (p); - *p++ = c; - c = getch (); - } - - ungetc (c, finput); - - if (shorts[7] | shorts[6] | shorts[5] | shorts[4]) - warning ("integer constant out of range"); - - /* This is simplified by the fact that our constant - is always positive. */ - yylval.ttype - = build_int_2 ((shorts[3]<<24) + (shorts[2]<<16) + (shorts[1]<<8) + shorts[0], - 0); - - if (!spec_long && !spec_unsigned - && int_fits_type_p (yylval.ttype, integer_type_node)) - type = integer_type_node; - - else if (!spec_long && base != 10 - && int_fits_type_p (yylval.ttype, unsigned_type_node)) - type = unsigned_type_node; - - else if (!spec_unsigned - && int_fits_type_p (yylval.ttype, long_integer_type_node)) - type = long_integer_type_node; - - else - { - type = long_unsigned_type_node; - if (! int_fits_type_p (yylval.ttype, long_unsigned_type_node)) - warning ("integer constant out of range"); - } - TREE_TYPE (yylval.ttype) = type; - } - - value = CONSTANT; break; - } - - case '\'': - char_constant: - { - register int result = 0; - register num_chars = 0; - int width = TYPE_PRECISION (char_type_node); - int max_chars; - - if (wide_flag) width = TYPE_PRECISION (integer_type_node); - - max_chars = TYPE_PRECISION (integer_type_node) / width; - - while (1) - { - tryagain: - - c = getch (); - - if (c == '\'' || c == EOF) - break; - - if (c == '\\') - { - c = readescape (); - if (c < 0) - goto tryagain; - if (width < HOST_BITS_PER_INT - && (unsigned) c >= (1 << width)) - warning ("escape sequence out of range for character"); - } - else if (c == '\n') - { - if (pedantic) - warning ("ANSI C forbids newline in character constant"); - lineno++; - } - - num_chars++; - if (num_chars > maxtoken - 4) - extend_token_buffer (token_buffer); - - token_buffer[num_chars] = c; - - /* Merge character into result; ignore excess chars. */ - if (num_chars < max_chars + 1) - { - if (width < HOST_BITS_PER_INT) - result = (result << width) | (c & ((1 << width) - 1)); - else - result = c; - } - } - - token_buffer[num_chars + 1] = '\''; - token_buffer[num_chars + 2] = 0; - - if (c != '\'') - error ("malformatted character constant"); - else if (num_chars == 0) - error ("empty character constant"); - else if (num_chars > max_chars) - { - num_chars = max_chars; - error ("character constant too long"); - } - else if (num_chars != 1 && ! flag_traditional) - warning ("multi-character character constant"); - - /* If char type is signed, sign-extend the constant. */ - if (! wide_flag) - { - int num_bits = num_chars * width; - if (TREE_UNSIGNED (char_type_node) - || ((result >> (num_bits - 1)) & 1) == 0) - yylval.ttype - = build_int_2 (result & ((unsigned) ~0 - >> (HOST_BITS_PER_INT - num_bits)), - 0); - else - yylval.ttype - = build_int_2 (result | ~((unsigned) ~0 - >> (HOST_BITS_PER_INT - num_bits)), - -1); - TREE_TYPE (yylval.ttype) = char_type_node; - } - else - { - yylval.ttype = build_int_2 (result, 0); - TREE_TYPE (yylval.ttype) = integer_type_node; - } - value = CONSTANT; break; - } - - case '"': - string_constant: - { - int *widep; - register char *p; - - c = getch (); - p = token_buffer + 1; - - if (wide_flag) - widep = wide_buffer; - - while (c != '"' && c >= 0) - { - if (c == '\\') - { - c = readescape (); - if (c < 0) - goto skipnewline; - if (!wide_flag && c >= (1 << BITS_PER_UNIT)) - warning ("escape sequence out of range for character"); - } - else if (c == '\n') - { - if (pedantic) - warning ("ANSI C forbids newline in string constant"); - lineno++; - } - - /* Store the char in C into the appropriate buffer. */ - - if (wide_flag) - { - if (widep == wide_buffer + max_wide) - { - int n = widep - wide_buffer; - max_wide *= 2; - wide_buffer = (int *) xrealloc (wide_buffer, max_wide + 1); - widep = wide_buffer + n; - } - *widep++ = c; - } - else - { - if (p == token_buffer + maxtoken) - p = extend_token_buffer (p); - *p++ = c; - } - - skipnewline: - c = getch (); - if (c == EOF) { - error("Unterminated string"); - break; - } - } - - /* We have read the entire constant. - Construct a STRING_CST for the result. */ - - if (wide_flag) - { - /* If this is a L"..." wide-string, make a vector - of the ints in wide_buffer. */ - *widep = 0; - /* We have not implemented the case where `int' - on the target and on the execution machine differ in size. */ - assert (TYPE_PRECISION (integer_type_node) == sizeof (int) * BITS_PER_UNIT); - yylval.ttype = build_string ((widep - wide_buffer) * sizeof (int), - (char *)wide_buffer); - TREE_TYPE (yylval.ttype) = int_array_type_node; - } - else - { - *p = 0; - yylval.ttype = build_string (p - token_buffer, token_buffer + 1); - TREE_TYPE (yylval.ttype) = char_array_type_node; - } - - *p++ = '"'; - *p = 0; - - value = STRING; break; - } - - case '+': - case '-': - case '&': - case '|': - case '<': - case '>': - case '*': - case '/': - case '%': - case '^': - case '!': - case '=': - { - register int c1; - - combine: - - switch (c) - { - case '+': - yylval.code = PLUS_EXPR; break; - case '-': - yylval.code = MINUS_EXPR; break; - case '&': - yylval.code = BIT_AND_EXPR; break; - case '|': - yylval.code = BIT_IOR_EXPR; break; - case '*': - yylval.code = MULT_EXPR; break; - case '/': - yylval.code = TRUNC_DIV_EXPR; break; - case '%': - yylval.code = TRUNC_MOD_EXPR; break; - case '^': - yylval.code = BIT_XOR_EXPR; break; - case LSHIFT: - yylval.code = LSHIFT_EXPR; break; - case RSHIFT: - yylval.code = RSHIFT_EXPR; break; - case '<': - yylval.code = LT_EXPR; break; - case '>': - yylval.code = GT_EXPR; break; - } - - token_buffer[1] = c1 = getch (); - token_buffer[2] = 0; - - if (c1 == '=') - { - switch (c) - { - case '<': - value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done; - case '>': - value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done; - case '!': - value = EQCOMPARE; yylval.code = NE_EXPR; goto done; - case '=': - value = EQCOMPARE; yylval.code = EQ_EXPR; goto done; - } - value = ASSIGN; goto done; - } - else if (c == c1) - switch (c) - { - case '+': - value = PLUSPLUS; goto done; - case '-': - value = MINUSMINUS; goto done; - case '&': - value = ANDAND; goto done; - case '|': - value = OROR; goto done; - case '<': - c = LSHIFT; - goto combine; - case '>': - c = RSHIFT; - goto combine; - } - else if ((c == '-') && (c1 == '>')) - { - nextchar = skip_white_space (getch ()); - if (nextchar == '(') - { - int next_c = skip_white_space (getch ()); - if (next_c == ')') - { - nextchar = -1; - value = POINTSAT_LEFT_RIGHT; - goto done; - } - ungetc (next_c, finput); - } - value = POINTSAT; - goto done; - } - else if (c1 == '?' && (c == '<' || c == '>')) - { - token_buffer[3] = 0; - - c1 = getch (); - yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR); - if (c1 == '=') - { - /* ?= expression. */ - token_buffer[2] = c1; - value = ASSIGN; - } - else - { - value = MIN_MAX; - nextchar = c1; - } - if (pedantic) - error ("use of `operator %s' is not standard C++", - token_buffer); - goto done; - } - - nextchar = c1; - token_buffer[1] = 0; - - if ((c == '<') || (c == '>')) - value = ARITHCOMPARE; - else value = c; - goto done; - } - - case ':': - c = getch (); - if (c == ':') - { - token_buffer[1] = ':'; - token_buffer[2] = '\0'; - value = SCOPE; - yylval.itype = 1; - } - else - { - nextchar = c; - value = ':'; - } - break; - - case 0: - /* Don't make yyparse think this is eof. */ - value = 1; - break; - - case '(': - /* try, weakly, to handle casts to pointers to functions. */ - nextchar = skip_white_space (getch ()); - if (nextchar == '*') - { - int next_c = skip_white_space (getch ()); - if (next_c == ')') - { - nextchar = -1; - yylval.ttype = build1 (INDIRECT_REF, 0, 0); - value = PAREN_STAR_PAREN; - } - else - { - ungetc (next_c, finput); - value = c; - } - } - /* Go down for a (X::*) or (X::&). */ - else if (isalpha (nextchar) || nextchar == '_' || nextchar == '$') - { - YYSTYPE this_yylval = yylval; - tree this_lastiddecl = lastiddecl; - nextyychar = yylex (); - if (nextyychar == TYPENAME_SCOPE) - { - if (nextchar < 0) - nextchar = skip_white_space (getch ()); - if (nextchar == '*' || nextchar == '&') - { - int next_c = skip_white_space (getch ()); - if (next_c == ')') - { - nextyychar = -1; - if (nextchar == '*') - { - value = PAREN_X_SCOPE_STAR_PAREN; - yylval.ttype = build_parse_node (SCOPE_REF, yylval.ttype, - build_parse_node (INDIRECT_REF, 0)); - } - else - { - value = PAREN_X_SCOPE_REF_PAREN; - yylval.ttype = build_parse_node (SCOPE_REF, yylval.ttype, - build_parse_node (ADDR_EXPR, 0)); - } - nextchar = -1; - } - else - { - ungetc (next_c, finput); - nextyylval = yylval; - nextlastiddecl = lastiddecl; - yylval = this_yylval; - lastiddecl = this_lastiddecl; - value = c; - } - } - else - { - nextyylval = yylval; - nextlastiddecl = lastiddecl; - yylval = this_yylval; - lastiddecl = this_lastiddecl; - value = c; - } - } - else - { - nextyylval = yylval; - nextlastiddecl = lastiddecl; - yylval = this_yylval; - lastiddecl = this_lastiddecl; - value = c; - } - } - else if (nextchar == ')') - { - nextchar = -1; - yylval.ttype = NULL_TREE; - value = LEFT_RIGHT; - } - else value = c; - break; - - default: - value = c; - } - -done: -/* yylloc.last_line = lineno; */ -#ifdef GATHER_STATISTICS - token_count[value] += 1; -#endif - - return value; -} - -typedef enum -{ - d_kind, t_kind, s_kind, r_kind, e_kind, c_kind, - id_kind, op_id_kind, perm_list_kind, temp_list_kind, - x_kind, lang_decl, lang_type, all_kinds -} tree_node_kind; -extern int tree_node_kinds[]; -extern int tree_node_sizes[]; -extern char *tree_node_kind_names[]; - -/* Place to save freed lang_decls which were allocated on the - permanent_obstack. @@ Not currently used. */ -tree free_lang_decl_chain; - -tree -build_lang_decl (code, name, type) - enum tree_code code; - tree name; - tree type; -{ - extern struct obstack *current_obstack, *saveable_obstack; - extern struct obstack permanent_obstack; - register tree t = build_decl (code, name, type); - struct obstack *obstack = current_obstack; - register int i = sizeof (struct lang_decl) / sizeof (int); - register int *pi; - - if (! TREE_PERMANENT (t)) - obstack = saveable_obstack; - -#ifdef LANG_DECL_PERMANENT - if (free_lang_decl_chain && obstack == &permanent_obstack) - { - pi = (int *)free_lang_decl_chain; - free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain); - } - else - pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl)); -#else - pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl)); -#endif - - while (i > 0) - pi[--i] = 0; - - DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi; -#ifdef LANG_DECL_PERMANENT - LANG_DECL_PERMANENT ((struct lang_decl *) pi) - = obstack == &permanent_obstack; -#endif - DECL_MAIN_VARIANT (t) = t; - DECL_ORIGINAL_NAME (t) = name; - if (current_lang_name == lang_name_cplusplus) - { - DECL_LANGUAGE (t) = lang_cplusplus; - -#ifndef NO_AUTO_OVERLOAD - if (code == FUNCTION_DECL && name != 0 - && ! (IDENTIFIER_LENGTH (name) == 4 - && IDENTIFIER_POINTER (name)[0] == 'm' - && strcmp (IDENTIFIER_POINTER (name), "main") == 0) - && ! (IDENTIFIER_LENGTH (name) > 10 - && IDENTIFIER_POINTER (name)[0] == '_' - && IDENTIFIER_POINTER (name)[1] == '_' - && strncmp (IDENTIFIER_POINTER (name)+2, "builtin_", 8) == 0)) - TREE_OVERLOADED (name) = 1; -#endif - } - else if (current_lang_name == lang_name_c) - DECL_LANGUAGE (t) = lang_c; - else abort (); - -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)lang_decl] += 1; - tree_node_sizes[(int)lang_decl] += sizeof(struct lang_decl); -#endif - - return t; -} - -tree -build_lang_field_decl (code, name, type) - enum tree_code code; - tree name; - tree type; -{ - extern struct obstack *current_obstack, *saveable_obstack; - register tree t = build_decl (code, name, type); - struct obstack *obstack = current_obstack; - register int i = sizeof (struct lang_decl_flags) / sizeof (int); - register int *pi; - - if (! TREE_PERMANENT (t)) - obstack = saveable_obstack; - - pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags)); - while (i > 0) - pi[--i] = 0; - - DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi; - return t; -} - -tree -make_lang_type (code) - enum tree_code code; -{ - extern struct obstack *current_obstack, *saveable_obstack; - register tree t = make_node (code); - struct obstack *obstack = current_obstack; - register int i = sizeof (struct lang_type) / sizeof (int); - register int *pi; - - if (! TREE_PERMANENT (t)) - obstack = saveable_obstack; - - pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type)); - while (i > 0) - pi[--i] = 0; - - TYPE_LANG_SPECIFIC (t) = (struct lang_type *) pi; - CLASSTYPE_MAIN_VARIANT (t) = t; - CLASSTYPE_AS_LIST (t) = build_tree_list (NULL_TREE, t); - CLASSTYPE_INTERFACE_UNKNOWN (t) = interface_unknown; - CLASSTYPE_INTERFACE_ONLY (t) = interface_only; - - /* Make sure this is laid out, for ease of use later. - In the presence of parse errors, the normal was of assuring - this might not ever get executed, so we lay it out *immediately*. */ - build_pointer_type (t); - -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)lang_type] += 1; - tree_node_sizes[(int)lang_type] += sizeof(struct lang_type); -#endif - - return t; -} - -void -copy_decl_lang_specific (decl) - tree decl; -{ - extern struct obstack *current_obstack, *saveable_obstack; - register int *old = (int *)DECL_LANG_SPECIFIC (decl); - struct obstack *obstack = current_obstack; - register int i = sizeof (struct lang_decl) / sizeof (int); - register int *pi; - - if (! TREE_PERMANENT (decl)) - obstack = saveable_obstack; - - pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl)); - while (i-- > 0) - pi[i] = old[i]; - - DECL_LANG_SPECIFIC (decl) = (struct lang_decl *) pi; - -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)lang_decl] += 1; - tree_node_sizes[(int)lang_decl] += sizeof(struct lang_decl); -#endif -} - -void -copy_type_lang_specific (type) - tree type; -{ - extern struct obstack *current_obstack, *saveable_obstack; - register int *old = (int *)TYPE_LANG_SPECIFIC (type); - struct obstack *obstack = current_obstack; - register int i = sizeof (struct lang_type) / sizeof (int); - register int *pi; - - if (! TREE_PERMANENT (type)) - obstack = saveable_obstack; - - pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type)); - while (i-- > 0) - pi[i] = old[i]; - - TYPE_LANG_SPECIFIC (type) = (struct lang_type *) pi; - CLASSTYPE_AS_LIST (type) = build_tree_list (NULL_TREE, type); - if (CLASSTYPE_N_BASECLASSES (type) > 0) - CLASSTYPE_BASECLASSES (type) = (tree *)obstack_copy (obstack, CLASSTYPE_BASECLASSES (type), (CLASSTYPE_N_BASECLASSES (type)+1) * sizeof (tree)); - -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)lang_type] += 1; - tree_node_sizes[(int)lang_type] += sizeof(struct lang_type); -#endif -} - -tree -build_with_cleanup (exp, type, rtl) - tree exp; - tree type; - struct rtx_def *rtl; -{ - if (type != NULL_TREE || TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (exp))) - { - tree rval = make_node (WITH_CLEANUP_EXPR); - - if (type == NULL_TREE) - type = TREE_TYPE (exp); - - TREE_OPERAND (rval, 0) = exp; - TREE_OPERAND (rval, 1) = make_node (RTL_EXPR); - TREE_OPERAND (rval, 2) = build_delete (TYPE_POINTER_TO (type), - build1 (ADDR_EXPR, TYPE_POINTER_TO (type), TREE_OPERAND (rval, 1)), - integer_two_node, LOOKUP_NORMAL, 0); - if (rtl != 0) - RTL_EXPR_RTL (TREE_OPERAND (rval, 1)) = rtl; - if (TREE_CODE (exp) == CALL_EXPR - && TREE_VALUE (TREE_OPERAND (exp, 1)) == NULL_TREE) - TREE_VALUE (TREE_OPERAND (exp, 1)) = TREE_OPERAND (rval, 1); - TREE_TYPE (rval) = type; - return rval; - } - return NULL_TREE; -} - -void -dump_time_statistics () -{ - register tree prev = 0, decl, next; - int this_time = my_gettime (); - TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) - += this_time - body_time; - - fprintf (stderr, "\n******\n"); - print_time ("header files (total)", header_time); - print_time ("main file (total)", this_time - body_time); - fprintf (stderr, "ratio = %g : 1\n", - (double)header_time / (double)(this_time - body_time)); - fprintf (stderr, "\n******\n"); - - for (decl = filename_times; decl; decl = next) - { - next = IDENTIFIER_GLOBAL_VALUE (decl); - IDENTIFIER_GLOBAL_VALUE (decl) = prev; - prev = decl; - } - - for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl)) - print_time (IDENTIFIER_POINTER (decl), - TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (decl))); -} - -void -compiler_error (s, v, v2) - char *s; - int v, v2; /* @@also used as pointer */ -{ - char buf[1024]; - sprintf (buf, s, v, v2); - error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf); -} - -void -compiler_error_with_decl (decl, s) - tree decl; - char *s; -{ - char *name; - count_error (0); - - report_error_function (0); - - if (TREE_CODE (decl) == PARM_DECL) - fprintf (stderr, "%s:%d: ", - DECL_SOURCE_FILE (DECL_CONTEXT (decl)), - DECL_SOURCE_LINE (DECL_CONTEXT (decl))); - else - fprintf (stderr, "%s:%d: ", - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); - - name = lang_printable_name (decl); - if (name) - fprintf (stderr, s, name); - else - fprintf (stderr, s, "((anonymous))"); - fprintf (stderr, " (compiler error)\n"); -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-method.c b/gnu/usr.bin/g++/cc1plus/cplus-method.c deleted file mode 100644 index 70b19410cec8..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-method.c +++ /dev/null @@ -1,2504 +0,0 @@ -/* Handle the hair of processing (but not expanding) inline functions. - Also manage function and varaible name overloading. - Copyright (C) 1987 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@mcc.com) - - This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* Handle method declarations. */ -#include -#include "config.h" -#include "tree.h" -#include "cplus-tree.h" -#include "assert.h" - -/* TREE_LIST of the current inline functions that need to be - processed. */ -struct pending_inline *pending_inlines; - -# define MAX_INLINE_BUF_SIZE 8188 -# define OB_INIT() (inline_bufp = inline_buffer) -# define OB_PUTC(C) (*inline_bufp++ = (C)) -# define OB_PUTC2(C1,C2) (OB_PUTC (C1), OB_PUTC (C2)) -# define OB_PUTS(S) (strcpy (inline_bufp, S), inline_bufp += sizeof (S) - 1) -# define OB_PUTCP(S) (strcpy (inline_bufp, S), inline_bufp += strlen (S)) -# define OB_FINISH() (*inline_bufp++ = '\0') - -/* Counter to help build parameter names in case they were omitted. */ -static int dummy_name; -static int in_parmlist; -/* Just a pointer into INLINE_BUFFER. */ -static char *inline_bufp; -/* Also a pointer into INLINE_BUFFER. This points to a safe place to - cut back to if we assign it 0, in case of error. */ -static char *inline_errp; -static char *inline_buffer; -static void dump_type (), dump_decl (); -static void dump_init (), dump_unary_op (), dump_binary_op (); - -tree wrapper_name, wrapper_pred_name, anti_wrapper_name; - -#ifdef NO_AUTO_OVERLOAD -int is_overloaded (); -#endif - -void -init_method () -{ - char buf[sizeof (ANTI_WRAPPER_NAME_FORMAT) + 8]; - sprintf (buf, WRAPPER_NAME_FORMAT, ""); - wrapper_name = get_identifier (buf); - sprintf (buf, WRAPPER_PRED_NAME_FORMAT, ""); - wrapper_pred_name = get_identifier (buf); - sprintf (buf, ANTI_WRAPPER_NAME_FORMAT, ""); - anti_wrapper_name = get_identifier (buf); -} - -/* Return a pointer to the end of the new text in INLINE_BUFFER. - We cannot use `fatal' or `error' in here because that - might cause an infinite loop. */ -static char * -new_text_len (s) - char *s; -{ - while (*s++) ; - - if (s >= inline_buffer + MAX_INLINE_BUF_SIZE) - { - fprintf (stderr, "recompile c++ with larger MAX_INLINE_BUF_SIZE (%d)", MAX_INLINE_BUF_SIZE); - abort (); - } - return s - 1; -} - -/* Check that we have not overflowed INLINE_BUFFER. - We cannot use `fatal' or `error' in here because that - might cause an infinite loop. */ -static void -check_text_len (s) - char *s; -{ - if (s >= inline_buffer + MAX_INLINE_BUF_SIZE) - { - fprintf (stderr, "recompile c++ with larger MAX_INLINE_BUF_SIZE (%d)", MAX_INLINE_BUF_SIZE); - abort (); - } -} - -tree -make_anon_parm_name () -{ - char buf[32]; - - sprintf (buf, ANON_PARMNAME_FORMAT, dummy_name++); - return get_identifier (buf); -} - -void -clear_anon_parm_name () -{ - /* recycle these names. */ - dummy_name = 0; -} - -static void -dump_readonly_or_volatile (t) - tree t; -{ - if (TREE_READONLY (t)) - OB_PUTS ("const "); - if (TREE_VOLATILE (t)) - OB_PUTS ("volatile "); -} - -static void -dump_type_prefix (t, p) - tree t; - int *p; -{ - int old_p = 0; - int print_struct = 1; - tree name; - - if (t == NULL_TREE) - return; - - switch (TREE_CODE (t)) - { - case ERROR_MARK: - sprintf (inline_bufp, ANON_PARMNAME_FORMAT, dummy_name++); - break; - - case UNKNOWN_TYPE: - OB_PUTS (""); - return; - - case TREE_LIST: - dump_type (TREE_VALUE (t), &old_p); - if (TREE_CHAIN (t)) - { - if (TREE_CHAIN (t) != void_list_node) - { - OB_PUTC (','); - dump_type (TREE_CHAIN (t), &old_p); - } - } - else OB_PUTS ("..."); - return; - - case POINTER_TYPE: - *p += 1; - dump_type_prefix (TREE_TYPE (t), p); - while (*p) - { - OB_PUTC ('*'); - *p -= 1; - } - if (TREE_READONLY (t)) - OB_PUTS ("const "); - if (TREE_VOLATILE (t)) - OB_PUTS ("volatile "); - return; - - case OFFSET_TYPE: - { - tree type = TREE_TYPE (t); - if (TREE_CODE (type) == FUNCTION_TYPE) - { - type = TREE_TYPE (type); - if (in_parmlist) - OB_PUTS ("auto "); - } - - dump_type_prefix (type, &old_p); - - OB_PUTC ('('); - dump_type (TYPE_OFFSET_BASETYPE (t), &old_p); - OB_PUTC2 (':', ':'); - while (*p) - { - OB_PUTC ('*'); - *p -= 1; - } - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - return; - } - - case METHOD_TYPE: - { - tree type = TREE_TYPE (t); - if (in_parmlist) - OB_PUTS ("auto "); - - dump_type_prefix (type, &old_p); - - OB_PUTC ('('); - dump_type (TYPE_METHOD_BASETYPE (t), &old_p); - OB_PUTC2 (':', ':'); - while (*p) - { - OB_PUTC ('*'); - *p -= 1; - } - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - return; - } - - case REFERENCE_TYPE: - dump_type_prefix (TREE_TYPE (t), p); - OB_PUTC ('&'); - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - return; - - case ARRAY_TYPE: - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - dump_type_prefix (TREE_TYPE (t), p); - return; - - case FUNCTION_TYPE: - if (in_parmlist) - OB_PUTS ("auto "); - dump_type_prefix (TREE_TYPE (t), &old_p); - OB_PUTC ('('); - while (*p) - { - OB_PUTC ('*'); - *p -= 1; - } - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - return; - - case IDENTIFIER_NODE: - sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (t)); - break; - - case RECORD_TYPE: - if (TREE_READONLY (t)) - OB_PUTS ("const "); - if (TREE_VOLATILE (t)) - OB_PUTS ("volatile "); - if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t)) - print_struct = 0; - name = TYPE_NAME (t); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - if (print_struct) - sprintf (inline_bufp, "struct %s ", IDENTIFIER_POINTER (name)); - else - sprintf (inline_bufp, "class %s ", IDENTIFIER_POINTER (name)); - break; - - case UNION_TYPE: - if (TREE_READONLY (t)) - OB_PUTS ("const "); - if (TREE_VOLATILE (t)) - OB_PUTS ("volatile "); - name = TYPE_NAME (t); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - sprintf (inline_bufp, "union %s ", IDENTIFIER_POINTER (name)); - break; - - case ENUMERAL_TYPE: - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - name = TYPE_NAME (t); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - sprintf (inline_bufp, "enum %s ", IDENTIFIER_POINTER (name)); - break; - - case TYPE_DECL: - if (TREE_READONLY (t)) - OB_PUTS ("const "); - if (TREE_VOLATILE (t)) - OB_PUTS ("volatile "); - sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (DECL_NAME (t))); - break; - - case INTEGER_TYPE: - /* Normally, `unsigned' is part of the deal. Not so if it comes - with `const' or `volatile'. */ - if (TREE_UNSIGNED (t) - && (TREE_READONLY (t) || TREE_VOLATILE (t))) - OB_PUTS ("unsigned "); - /* fall through. */ - case REAL_TYPE: - case VOID_TYPE: - if (TREE_READONLY (t)) - OB_PUTS ("const "); - if (TREE_VOLATILE (t)) - OB_PUTS ("volatile "); - sprintf (inline_bufp, "%s ", TYPE_NAME_STRING (t)); - break; - - default: - abort (); - } - inline_bufp = new_text_len (inline_bufp); -} - -static void -dump_type_suffix (t, p) - tree t; - int *p; -{ - int old_p = 0; - - if (t == NULL_TREE) - return; - - switch (TREE_CODE (t)) - { - case ERROR_MARK: - sprintf (inline_bufp, ANON_PARMNAME_FORMAT, dummy_name++); - break; - - case UNKNOWN_TYPE: - return; - - case POINTER_TYPE: - dump_type_suffix (TREE_TYPE (t), p); - return; - - case OFFSET_TYPE: - { - tree type = TREE_TYPE (t); - - OB_PUTC (')'); - if (TREE_CODE (type) == FUNCTION_TYPE) - { -#if 0 - tree next_arg = TREE_CHAIN (TYPE_ARG_TYPES (type)); - OB_PUTC ('('); - if (next_arg) - { - if (next_arg != void_list_node) - { - in_parmlist++; - dump_type (next_arg, &old_p); - in_parmlist--; - } - } - else OB_PUTS ("..."); - OB_PUTC (')'); - dump_type_suffix (TREE_TYPE (type), p); -#else - abort (); -#endif - } - return; - } - - case METHOD_TYPE: - { - tree next_arg; - OB_PUTC (')'); - next_arg = TREE_CHAIN (TYPE_ARG_TYPES (t)); - OB_PUTC ('('); - if (next_arg) - { - if (next_arg != void_list_node) - { - in_parmlist++; - dump_type (next_arg, &old_p); - in_parmlist--; - } - } - else OB_PUTS ("..."); - OB_PUTC (')'); - dump_readonly_or_volatile (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t)))); - dump_type_suffix (TREE_TYPE (t), p); - return; - } - - case REFERENCE_TYPE: - dump_type_suffix (TREE_TYPE (t), p); - return; - - case ARRAY_TYPE: - dump_type_suffix (TREE_TYPE (t), p); - OB_PUTC2 ('[', ']'); - return; - - case FUNCTION_TYPE: - OB_PUTC2 (')', '('); - if (TYPE_ARG_TYPES (t) && TYPE_ARG_TYPES (t) != void_list_node) - { - in_parmlist++; - dump_type (TYPE_ARG_TYPES (t), &old_p); - in_parmlist--; - } - OB_PUTC (')'); - dump_type_suffix (TREE_TYPE (t), p); - return; - - case IDENTIFIER_NODE: - case RECORD_TYPE: - case UNION_TYPE: - case ENUMERAL_TYPE: - case TYPE_DECL: - case INTEGER_TYPE: - case REAL_TYPE: - case VOID_TYPE: - return; - - default: - abort (); - } - inline_bufp = new_text_len (inline_bufp); -} - -static void -dump_type (t, p) - tree t; - int *p; -{ - int old_p = 0; - int print_struct = 1; - - if (t == NULL_TREE) - return; - - switch (TREE_CODE (t)) - { - case ERROR_MARK: - sprintf (inline_bufp, ANON_PARMNAME_FORMAT, dummy_name++); - break; - - case UNKNOWN_TYPE: - OB_PUTS (""); - return; - - case TREE_LIST: - dump_type (TREE_VALUE (t), &old_p); - if (TREE_CHAIN (t)) - { - if (TREE_CHAIN (t) != void_list_node) - { - OB_PUTC (','); - dump_type (TREE_CHAIN (t), &old_p); - } - } - else OB_PUTS ("..."); - return; - - case POINTER_TYPE: - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - *p += 1; - dump_type (TREE_TYPE (t), p); - while (*p) - { - OB_PUTC ('*'); - *p -= 1; - } - return; - - case REFERENCE_TYPE: - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - dump_type (TREE_TYPE (t), p); - OB_PUTC ('&'); - return; - - case ARRAY_TYPE: - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - dump_type (TREE_TYPE (t), p); - OB_PUTC2 ('[', ']'); - return; - - case OFFSET_TYPE: - case METHOD_TYPE: - case FUNCTION_TYPE: - dump_type_prefix (t, p); - dump_type_suffix (t, p); - return; - - case IDENTIFIER_NODE: - sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (t)); - break; - - case RECORD_TYPE: - { - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t)) - print_struct = 0; - t = TYPE_NAME (t); - if (TREE_CODE (t) == TYPE_DECL) - t = DECL_NAME (t); - if (print_struct) - sprintf (inline_bufp, "struct %s ", IDENTIFIER_POINTER (t)); - else - sprintf (inline_bufp, "class %s ", IDENTIFIER_POINTER (t)); - break; - } - - case UNION_TYPE: - { - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - t = TYPE_NAME (t); - if (TREE_CODE (t) == TYPE_DECL) - t = DECL_NAME (t); - sprintf (inline_bufp, "union %s ", IDENTIFIER_POINTER (t)); - } - break; - - case ENUMERAL_TYPE: - { - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - t = TYPE_NAME (t); - if (TREE_CODE (t) == TYPE_DECL) - t = DECL_NAME (t); - sprintf (inline_bufp, "enum %s ", IDENTIFIER_POINTER (t)); - } - break; - - case TYPE_DECL: - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (DECL_NAME (t))); - break; - - case INTEGER_TYPE: - /* Normally, `unsigned' is part of the deal. Not so if it comes - with `const' or `volatile'. */ - if (TREE_READONLY (t) | TREE_VOLATILE (t)) - dump_readonly_or_volatile (t); - if (TREE_UNSIGNED (t) - && (TREE_READONLY (t) | TREE_VOLATILE (t))) - OB_PUTS ("unsigned "); - /* fall through. */ - case REAL_TYPE: - case VOID_TYPE: - sprintf (inline_bufp, "%s ", TYPE_NAME_STRING (t)); - break; - - default: - abort (); - } - inline_bufp = new_text_len (inline_bufp); -} - -static void -dump_decl (t) - tree t; -{ - int p = 0; - - if (t == NULL_TREE) - return; - - switch (TREE_CODE (t)) - { - case ERROR_MARK: - strcpy (inline_bufp, " /* decl error */ "); - break; - - case PARM_DECL: - dump_type_prefix (TREE_TYPE (t), &p); - if (DECL_NAME (t)) - dump_decl (DECL_NAME (t)); - else - { - sprintf (inline_bufp, ANON_PARMNAME_FORMAT, dummy_name++); - break; - } - dump_type_suffix (TREE_TYPE (t), &p); - return; - - case CALL_EXPR: - dump_decl (TREE_OPERAND (t, 0)); - OB_PUTC ('('); - in_parmlist++; - dump_decl (TREE_OPERAND (t, 1)); - in_parmlist--; - t = tree_last (TYPE_ARG_TYPES (TREE_TYPE (t))); - if (!t || t != void_list_node) - OB_PUTS ("..."); - OB_PUTC (')'); - return; - - case ARRAY_REF: - dump_decl (TREE_OPERAND (t, 0)); - OB_PUTC ('['); - dump_decl (TREE_OPERAND (t, 1)); - OB_PUTC (']'); - return; - - case TYPE_DECL: - sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (DECL_NAME (t))); - break; - - case TYPE_EXPR: - abort (); - break; - - case IDENTIFIER_NODE: - if (OPERATOR_NAME_P (t)) - sprintf (inline_bufp, "operator %s ", operator_name_string (t)); - else if (OPERATOR_TYPENAME_P (t)) - { - OB_PUTS ("operator "); - dump_type (TREE_TYPE (t), &p); - return; - } - else - sprintf (inline_bufp, "%s ", IDENTIFIER_POINTER (t)); - break; - - case BIT_NOT_EXPR: - OB_PUTC2 ('~', ' '); - dump_decl (TREE_OPERAND (t, 0)); - return; - - case SCOPE_REF: - sprintf (inline_bufp, "%s :: ", IDENTIFIER_POINTER (TREE_OPERAND (t, 0))); - inline_bufp += sizeof ("%s :: ") + IDENTIFIER_LENGTH (TREE_OPERAND (t, 0)); - dump_decl (TREE_OPERAND (t, 1)); - return; - - case INDIRECT_REF: - OB_PUTC ('*'); - dump_decl (TREE_OPERAND (t, 0)); - return; - - case ADDR_EXPR: - OB_PUTC ('&'); - dump_decl (TREE_OPERAND (t, 0)); - return; - - default: - abort (); - } - inline_bufp = new_text_len (inline_bufp); -} - -static void -dump_init_list (l) - tree l; -{ - while (l) - { - dump_init (TREE_VALUE (l)); - if (TREE_CHAIN (l)) - OB_PUTC (','); - l = TREE_CHAIN (l); - } -} - -static void -dump_init (t) - tree t; -{ - int dummy; - - switch (TREE_CODE (t)) - { - case VAR_DECL: - case PARM_DECL: - sprintf (inline_bufp, " %s ", IDENTIFIER_POINTER (DECL_NAME (t))); - break; - - case FUNCTION_DECL: - { - tree name = DECL_NAME (t); - - if (DESTRUCTOR_NAME_P (name)) - sprintf (inline_bufp, " ~%s ", - IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (t))); - else if (OPERATOR_NAME_P (name)) - sprintf (inline_bufp, "operator %s ", operator_name_string (name)); - else if (OPERATOR_TYPENAME_P (name)) - { - dummy = 0; - OB_PUTS ("operator "); - dump_type (TREE_TYPE (name), &dummy); - } -#if 0 - else if (WRAPPER_NAME_P (name)) - sprintf (inline_bufp, " ()%s ", - IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (t))); - else if (WRAPPER_PRED_NAME_P (name)) - sprintf (inline_bufp, " ()?%s ", - IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (t))); - else if (ANTI_WRAPPER_NAME_P (name)) - sprintf (inline_bufp, " ~()%s ", - IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (t))); -#endif - else sprintf (inline_bufp, " %s ", - IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (t))); - } - break; - - case CONST_DECL: - dummy = 0; - OB_PUTC2 ('(', '('); - dump_type (TREE_TYPE (t), &dummy); - OB_PUTC (')'); - dump_init (DECL_INITIAL (t)); - OB_PUTC (')'); - return; - - case INTEGER_CST: - sprintf (inline_bufp, " %d ", TREE_INT_CST_LOW (t)); - break; - - case REAL_CST: - sprintf (inline_bufp, " %g ", TREE_REAL_CST (t)); - break; - - case STRING_CST: - { - char *p = TREE_STRING_POINTER (t); - int len = TREE_STRING_LENGTH (t) - 1; - int i; - - check_text_len (inline_bufp + len + 2); - OB_PUTC ('\"'); - for (i = 0; i < len; i++) - { - register char c = p[i]; - if (c == '\"' || c == '\\') - OB_PUTC ('\\'); - if (c >= ' ' && c < 0177) - OB_PUTC (c); - else - { - sprintf (inline_bufp, "\\%03o", c); - inline_bufp = new_text_len (inline_bufp); - } - } - OB_PUTC ('\"'); - } - return; - - case COMPOUND_EXPR: - dump_binary_op (",", t, 1); - break; - - case COND_EXPR: - OB_PUTC ('('); - dump_init (TREE_OPERAND (t, 0)); - OB_PUTS (" ? "); - dump_init (TREE_OPERAND (t, 1)); - OB_PUTS (" : "); - dump_init (TREE_OPERAND (t, 2)); - OB_PUTC (')'); - return; - - case SAVE_EXPR: - if (TREE_HAS_CONSTRUCTOR (t)) - { - dummy = 0; - OB_PUTS ("new "); - dump_type (TREE_TYPE (TREE_TYPE (t)), &dummy); - PARM_DECL_EXPR (t) = 1; - } - else - { - sorry ("operand of SAVE_EXPR not understood"); - *inline_errp = '\0'; - inline_bufp = inline_errp + 1; - } - return; - - case NEW_EXPR: - strcpy (inline_bufp, TYPE_NAME_STRING (TREE_TYPE (t))); - inline_bufp = new_text_len (inline_bufp); - OB_PUTC ('('); - dump_init_list (TREE_CHAIN (TREE_OPERAND (t, 1))); - OB_PUTC (')'); - return; - - case CALL_EXPR: - OB_PUTC ('('); - dump_init (TREE_OPERAND (t, 0)); - dump_init_list (TREE_OPERAND (t, 1)); - OB_PUTC (')'); - return; - - case MODIFY_EXPR: - case PLUS_EXPR: - case MINUS_EXPR: - case MULT_EXPR: - case TRUNC_DIV_EXPR: - case TRUNC_MOD_EXPR: - case MIN_EXPR: - case MAX_EXPR: - case LSHIFT_EXPR: - case RSHIFT_EXPR: - case BIT_IOR_EXPR: - case BIT_XOR_EXPR: - case BIT_AND_EXPR: - case BIT_ANDTC_EXPR: - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - case LT_EXPR: - case LE_EXPR: - case GT_EXPR: - case GE_EXPR: - case EQ_EXPR: - case NE_EXPR: - dump_binary_op (opname_tab[(int) TREE_CODE (t)], t, - strlen (opname_tab[(int) TREE_CODE (t)])); - return; - - case CEIL_DIV_EXPR: - case FLOOR_DIV_EXPR: - case ROUND_DIV_EXPR: - dump_binary_op ("/", t, 1); - return; - - case CEIL_MOD_EXPR: - case FLOOR_MOD_EXPR: - case ROUND_MOD_EXPR: - dump_binary_op ("%", t, 1); - return; - - case COMPONENT_REF: - dump_binary_op (".", t, 1); - return; - - case CONVERT_EXPR: - dump_unary_op ("+", t, 1); - return; - - case ADDR_EXPR: - if (TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL - || TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST) - dump_init (TREE_OPERAND (t, 0)); - else - dump_unary_op ("&", t, 1); - return; - - case INDIRECT_REF: - dump_unary_op ("*", t, 1); - return; - - case NEGATE_EXPR: - case BIT_NOT_EXPR: - case TRUTH_NOT_EXPR: - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - dump_unary_op (opname_tab [(int)TREE_CODE (t)], t, - strlen (opname_tab[(int) TREE_CODE (t)])); - return; - - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - OB_PUTC ('('); - dump_init (TREE_OPERAND (t, 0)); - OB_PUTCP (opname_tab[(int)TREE_CODE (t)]); - OB_PUTC (')'); - return; - - case NOP_EXPR: - dummy = 0; - OB_PUTC2 ('(', '('); - dump_type (TREE_TYPE (t), &dummy); - OB_PUTC (')'); - dump_init (TREE_OPERAND (t, 0)); - OB_PUTC (')'); - return; - - case CONSTRUCTOR: - OB_PUTC ('{'); - dump_init_list (CONSTRUCTOR_ELTS (t)); - OB_PUTC ('}'); - return; - - /* This list is incomplete, but should suffice for now. - It is very important that `sorry' does not call - `report_error_function'. That could cause an infinite loop. */ - default: - sorry ("that operation not supported for default parameters"); - - /* fall through to ERROR_MARK... */ - case ERROR_MARK: - *inline_errp = '\0'; - inline_bufp = inline_errp + 1; - return; - } - inline_bufp = new_text_len (inline_bufp); -} - -static void -dump_binary_op (opstring, t, len) - char *opstring; - tree t; - int len; -{ - OB_PUTC ('('); - dump_init (TREE_OPERAND (t, 0)); - sprintf (inline_bufp, " %s ", opstring); - inline_bufp += len + 2; - dump_init (TREE_OPERAND (t, 1)); - OB_PUTC (')'); - check_text_len (inline_bufp); -} - -static void -dump_unary_op (opstring, t, len) - char *opstring; - tree t; - int len; -{ - OB_PUTC ('('); - sprintf (inline_bufp, " %s ", opstring); - inline_bufp += len + 2; - dump_init (TREE_OPERAND (t, 0)); - OB_PUTC (')'); - check_text_len (inline_bufp); -} - -#ifdef DO_METHODS_THE_OLD_WAY -/* Process the currently pending inline function definitions. - This entails: - (1) Creating a temporary file which contains return type, - delarator name, and argment names and types of the - function to be inlined. - (2) Reading that file into a buffer which can then be - made to look line another piece of inline code to - process, stuffing that on the top of the inline - stack, then letting the lexer and parser read from those - two. -*/ - -static struct pending_inline * -stash_inline_prefix (cname, field) - tree cname, field; -{ - extern int lineno; - struct pending_inline *t; - tree name, fndecl, fntype; - int p = 0; - inline_buffer = (char *)alloca (MAX_INLINE_BUF_SIZE + 4); - dummy_name = 0; - - name = DECL_ORIGINAL_NAME (field); - /* We still don't do friends right. */ - fndecl = field; - fntype = TREE_TYPE (fndecl); - - if (TREE_INLINE (fndecl)) - strcpy (inline_buffer, "inline "); - else - strcpy (inline_buffer, "static "); - inline_bufp = inline_buffer + strlen (inline_buffer); - if (! OPERATOR_TYPENAME_P (name)) - dump_type_prefix (TREE_TYPE (fntype), &p); - if (TREE_CODE (fntype) == METHOD_TYPE) - { - dump_type (cname, &p); - inline_bufp[-1] = ':'; - *inline_bufp++ = ':'; - if (DESTRUCTOR_NAME_P (DECL_NAME (fndecl))) - OB_PUTC ('~'); -#if 0 - else if (WRAPPER_NAME_P (DECL_NAME (fndecl))) - OB_PUTC2 ('(', ')'); - else if (WRAPPER_PRED_NAME_P (DECL_NAME (fndecl))) - OB_PUTS ("()?"); - else if (ANTI_WRAPPER_NAME_P (DECL_NAME (fndecl))) - OB_PUTS ("~()"); -#endif - } - dump_decl (name); - OB_PUTC ('('); - if (! DESTRUCTOR_NAME_P (DECL_NAME (fndecl))) - { - tree parmlist = DECL_ARGUMENTS (fndecl); - tree typelist = TYPE_ARG_TYPES (fntype); - - if (TREE_CODE (field) == FIELD_DECL) - { - parmlist = TREE_CHAIN (parmlist); - typelist = TREE_CHAIN (typelist); - } - - in_parmlist++; - while (parmlist) - { - dump_decl (parmlist); -#if 0 - if (TREE_PURPOSE (typelist)) - { - inline_errp = inline_bufp; - OB_PUTS (" = ("); - dump_init (TREE_PURPOSE (typelist)); - OB_PUTC (')'); - if (*inline_errp == '\0') - inline_bufp = inline_errp; - } -#endif - if (TREE_CHAIN (parmlist)) - OB_PUTC (','); - parmlist = TREE_CHAIN (parmlist); - typelist = TREE_CHAIN (typelist); - } - in_parmlist--; - if (!typelist || typelist != void_list_node) - OB_PUTS ("..."); - } - OB_PUTC (')'); - - if (! OPERATOR_TYPENAME_P (name)) - dump_type_suffix (TREE_TYPE (fntype), &p); - if (TREE_CODE (fntype) == METHOD_TYPE) - dump_readonly_or_volatile (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype)))); - { - extern tree value_identifier; - - if (DECL_RESULT (fndecl) != value_identifier) - { - tree result = DECL_RESULT (fndecl); - - OB_PUTS ("return "); - OB_PUTS (IDENTIFIER_POINTER (DECL_NAME (result))); - if (DECL_INITIAL (result)) - { - OB_PUTC ('='); - dump_init (DECL_INITIAL (result)); - OB_PUTC (';'); - } - } - } - OB_FINISH (); - check_text_len (inline_bufp); - - t = (struct pending_inline *)xmalloc (sizeof (struct pending_inline)); - t->len = inline_bufp - inline_buffer; - t->buf = (char *)xmalloc (t->len); - bcopy (inline_buffer, t->buf, t->len); - t->lineno = lineno; - t->filename = input_filename; - t->token = 0; - return t; -} -#endif - -#define OVERLOAD_MAX_LEN 1024 - -/* Pretty printing for announce_function. If BUF is nonzero, then - the text is written there. The buffer is assued to be of size - OVERLOAD_MAX_LEN. CNAME is the name of the class that FNDECL - belongs to, if we could not figure that out from FNDECL - itself. FNDECL is the declaration of the function we - are interested in seeing. PRINT_RET_TYPE_P is non-zero if - we should print the type that this function returns. */ -char * -fndecl_as_string (buf, cname, fndecl, print_ret_type_p) - char *buf; - tree cname, fndecl; - int print_ret_type_p; -{ - tree name = DECL_NAME (fndecl); - tree fntype = TREE_TYPE (fndecl); - tree parmtypes = TYPE_ARG_TYPES (fntype); - int p = 0; - int spaces = 0; - - inline_buffer = buf; - OB_INIT (); - - if (DECL_STATIC_FUNCTION_P (fndecl)) - cname = TYPE_NAME (DECL_STATIC_CONTEXT (fndecl)); - else if (! cname && TREE_CODE (fntype) == METHOD_TYPE) - cname = TYPE_NAME (TYPE_METHOD_BASETYPE (fntype)); - - if (print_ret_type_p && ! OPERATOR_TYPENAME_P (name)) - dump_type_prefix (TREE_TYPE (fntype), &p); - if (DECL_STATIC_FUNCTION_P (fndecl)) - OB_PUTS ("static "); - - if (cname) - { - dump_type (cname, &p); - inline_bufp[-1] = ':'; - *inline_bufp++ = ':'; - if (TREE_CODE (fntype) == METHOD_TYPE && parmtypes) - parmtypes = TREE_CHAIN (parmtypes); - if (DECL_CONSTRUCTOR_FOR_VBASE_P (fndecl)) - parmtypes = TREE_CHAIN (parmtypes); - } - - if (DESTRUCTOR_NAME_P (name)) - { - OB_PUTC ('~'); - parmtypes = TREE_CHAIN (parmtypes); - dump_decl (DECL_ORIGINAL_NAME (fndecl)); - } - else if (OPERATOR_NAME_P (name)) - { - sprintf (inline_bufp, "operator %s ", operator_name_string (name)); - inline_bufp += strlen (inline_bufp); - } - else if (OPERATOR_TYPENAME_P (name)) - { - /* This cannot use the hack that the operator's return - type is stashed off of its name because it may be - used for error reporting. In the case of conflicting - declarations, both will have the same name, yet - the types will be different, hence the TREE_TYPE field - of the first name will be clobbered by the second. */ - OB_PUTS ("operator "); - dump_type (TREE_TYPE (TREE_TYPE (fndecl)), &p); - } - else if (DECL_CONSTRUCTOR_P (fndecl)) - { -#ifdef SOS - if (TYPE_DYNAMIC (TREE_TYPE (TREE_TYPE (DECL_ORIGINAL_NAME (fndecl))))) - { - OB_PUTS ("dynamic "); - parmtypes = TREE_CHAIN (parmtypes); - } -#endif - dump_decl (DECL_ORIGINAL_NAME (fndecl)); - /* Skip past "in_charge" identifier. */ - if (TYPE_USES_VIRTUAL_BASECLASSES (TREE_TYPE (cname))) - parmtypes = TREE_CHAIN (parmtypes); - } - else - { -#if 0 - if (WRAPPER_NAME_P (name)) - OB_PUTC2 ('(', ')'); - if (WRAPPER_PRED_NAME_P (name)) - OB_PUTS ("()?"); - else if (ANTI_WRAPPER_NAME_P (name)) - OB_PUTS ("~()"); -#endif - dump_decl (DECL_ORIGINAL_NAME (fndecl)); - } - - OB_PUTC ('('); - if (parmtypes) - { - in_parmlist++; - if (parmtypes != void_list_node) - spaces = 2; - while (parmtypes && parmtypes != void_list_node) - { - dump_type (TREE_VALUE (parmtypes), &p); - while (inline_bufp[-1] == ' ') - inline_bufp--; - if (TREE_PURPOSE (parmtypes)) - { - inline_errp = inline_bufp; - OB_PUTS (" (= "); - dump_init (TREE_PURPOSE (parmtypes)); - OB_PUTC (')'); - } - OB_PUTC2 (',', ' '); - parmtypes = TREE_CHAIN (parmtypes); - } - in_parmlist--; - } - - if (parmtypes) - inline_bufp -= spaces; - else - OB_PUTS ("..."); - - OB_PUTC (')'); - - if (print_ret_type_p && ! OPERATOR_TYPENAME_P (name)) - dump_type_suffix (TREE_TYPE (fntype), &p); - - if (TREE_CODE (fntype) == METHOD_TYPE) - dump_readonly_or_volatile (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype)))); - - OB_FINISH (); - check_text_len (inline_bufp); - - if (strlen (buf) >= OVERLOAD_MAX_LEN) - { - fprintf (stderr, "fndecl_as_string returns something too large"); - abort (); - } - return buf; -} - -#ifdef FIELD_XREF - -char * -type_as_string (buf, typ) - char *buf; - tree typ; -{ - int p = 0; - int spaces = 0; - - inline_buffer = buf; - OB_INIT (); - - dump_type(typ,&p); - - OB_FINISH (); - - return buf; -} - -#endif - -/* Move inline function defintions out of structure so that they - can be processed normally. CNAME is the name of the class - we are working from, METHOD_LIST is the list of method lists - of the structure. We delete friend methods here, after - saving away their inline function definitions (if any). */ - -/* Subroutine of `do_inline_function_hair'. */ -static void -prepare_inline (cname, fndecl) - tree cname, fndecl; -{ - if (DECL_PENDING_INLINE_INFO (fndecl)) - { - struct pending_inline *t1, *t2; - tree args; - - t2 = DECL_PENDING_INLINE_INFO (fndecl); - t2->next = pending_inlines; - t2->fndecl = fndecl; - args = DECL_ARGUMENTS (fndecl); - while (args) - { - DECL_CONTEXT (args) = fndecl; - args = TREE_CHAIN (args); - } -#ifdef DO_METHODS_THE_OLD_WAY - t1 = stash_inline_prefix (cname, methods); - t1->next = t2; -#else - t1 = t2; -#endif - pending_inlines = t1; - - /* Allow this decl to be seen in global scope */ - IDENTIFIER_GLOBAL_VALUE (DECL_NAME (fndecl)) = fndecl; - } -} - -void -do_inline_function_hair (type, friend_list) - tree type, friend_list; -{ - tree cname = DECL_NAME (TYPE_NAME (type)); - tree method_vec = CLASSTYPE_METHOD_VEC (type); - if (method_vec != 0) - { - tree *methods = &TREE_VEC_ELT (method_vec, 0); - tree *end = TREE_VEC_END (method_vec); - while (methods != end) - { - /* Do inline member functions. */ - tree method = *methods; - while (method) - { - prepare_inline (cname, method); - method = TREE_CHAIN (method); - } - methods++; - } - } - while (friend_list) - { - prepare_inline (NULL_TREE, TREE_VALUE (friend_list)); - friend_list = TREE_CHAIN (friend_list); - } -} - -/* Report a argument type mismatch between the best declared function - we could find and the current argument list that we have. */ -void -report_type_mismatch (cp, parmtypes, name_kind, err_name) - struct candidate *cp; - tree parmtypes; - char *name_kind, *err_name; -{ - char buf[OVERLOAD_MAX_LEN]; - int i = cp->u.bad_arg; - tree ttf, tta; - - if (i == -3) - { - if (TREE_READONLY (TREE_TYPE (TREE_VALUE (parmtypes)))) - error ("call to const %s `%s' with non-const object", name_kind, err_name); - else - error ("call to non-const %s `%s' with const object", name_kind, err_name); - return; - } - if (i == -2) - { - error ("too few arguments for %s `%s'", name_kind, err_name); - return; - } - else if (i == -1) - { - error ("too many arguments for %s `%s'", name_kind, err_name); - return; - } - if (i == 0) - { - if (TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE) - { - /* Happens when we have an ambiguous base class. */ - assert (get_base_type (DECL_CONTEXT (cp->function), TREE_TYPE (TREE_TYPE (TREE_VALUE (parmtypes))), 1) == error_mark_node); - return; - } - } - ttf = TYPE_ARG_TYPES (TREE_TYPE (cp->function)); - tta = parmtypes; - - while (i-- > 0) - { - ttf = TREE_CHAIN (ttf); - tta = TREE_CHAIN (tta); - } - fndecl_as_string (buf, 0, cp->function, 0); - inline_bufp = inline_buffer + strlen (inline_buffer) + 1; - inline_buffer = inline_bufp; - - /* Reset `i' so that type printing routines do the right thing. */ - if (tta) - { - enum tree_code code = TREE_CODE (TREE_TYPE (TREE_VALUE (tta))); - if (code == ERROR_MARK) - OB_PUTS ("(failed type instatiation)"); - else - { - i = (code == FUNCTION_TYPE || code == METHOD_TYPE); - dump_type (TREE_TYPE (TREE_VALUE (tta)), &i); - } - } - else OB_PUTS ("void"); - - OB_FINISH (); - sprintf (inline_bufp, "bad argument %d for function `%s' (type was %s)", - cp->u.bad_arg - (TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE), buf, inline_buffer); - strcpy (buf, inline_bufp); - error (buf); -} - -/* Here is where overload code starts. */ - -#define OVERLOAD_MAX_LEN 1024 - -/* Array of types seen so far in top-level call to `build_overload_name'. - Allocated and deallocated by caller. */ -static tree *typevec; - -/* Number of types interned by `build_overload_name' so far. */ -static int maxtype; - -/* Number of occurances of last type seen. */ -static int nrepeats; - -/* Nonzero if we should not try folding parameter types. */ -static int nofold; - -#define ALLOCATE_TYPEVEC(PARMTYPES) \ - do { maxtype = 0, nrepeats = 0; \ - typevec = (tree *)alloca (list_length (PARMTYPES) * sizeof (tree)); } while (0) - -#define DEALLOCATE_TYPEVEC(PARMTYPES) \ - do { tree t = (PARMTYPES); \ - while (t) { TREE_USED (TREE_VALUE (t)) = 0; t = TREE_CHAIN (t); } \ - } while (0) - -/* Code to concatenate an asciified integer to a string, - and return the end of the string. */ -static -#ifdef __GNUC__ -__inline -#endif -char * -icat (s, i) - char *s; - int i; -{ - if (i < 10) - { - *s++ = '0' + i; - return s; - } - s = icat (s, i / 10); - *s++ = '0' + (i % 10); - return s; -} - -static -#ifdef __GNUC__ -__inline -#endif -char * -flush_repeats (s, type) - char *s; - tree type; -{ - int tindex = 0; - char *rval; - - while (typevec[tindex] != type) - tindex++; - - if (nrepeats > 1) - { - *s++ = 'N'; - s = icat (s, nrepeats); - if (nrepeats > 9) - *s++ = '_'; - } - else - *s++ = 'T'; - nrepeats = 0; - rval = icat (s, tindex); - if (tindex > 9) - *rval++ = '_'; - return rval; -} - -/* Given a list of parameters in PARMS, and a buffer in TEXT, of - length LEN bytes, create an unambiguous overload string. Should - distinguish any type that C (or C++) can distinguish. I.e., - pointers to functions are treated correctly. - - Caller must deal with whether a final `e' goes on the end or not. - - Any default conversions must take place before this function - is called. */ - -static char * -build_overload_name (parmtypes, text, text_end) - tree parmtypes; - char *text, *text_end; -{ - char *textp = text; - int just_one; - tree parmtype; - - if (just_one = (TREE_CODE (parmtypes) != TREE_LIST)) - { - parmtype = parmtypes; - goto only_one; - } - - while (parmtypes) - { - if (text_end - text < 4) - fatal ("Out of string space in build_overload_name!"); - parmtype = TREE_VALUE (parmtypes); - - only_one: - - if (! nofold) - { - if (! just_one) - /* Every argument gets counted. */ - typevec[maxtype++] = parmtype; - - if (TREE_USED (parmtype)) - { - if (! just_one && parmtype == typevec[maxtype-2]) - nrepeats++; - else - { - if (nrepeats) - textp = flush_repeats (textp, parmtype); - if (! just_one && TREE_CHAIN (parmtypes) - && parmtype == TREE_VALUE (TREE_CHAIN (parmtypes))) - nrepeats++; - else - { - int tindex = 0; - - while (typevec[tindex] != parmtype) - tindex++; - *textp++ = 'T'; - textp = icat (textp, tindex); - if (tindex > 9) - *textp++ = '_'; - } - } - goto next; - } - if (nrepeats) - textp = flush_repeats (textp, typevec[maxtype-2]); - if (! just_one - /* Only cache types which take more than one character. */ - && (parmtype != TYPE_MAIN_VARIANT (parmtype) - || (TREE_CODE (parmtype) != INTEGER_TYPE - && TREE_CODE (parmtype) != REAL_TYPE))) - TREE_USED (parmtype) = 1; - } - - if (TREE_READONLY (parmtype)) - *textp++ = 'C'; - if (TREE_CODE (parmtype) == INTEGER_TYPE && TREE_UNSIGNED (parmtype)) - *textp++ = 'U'; - if (TREE_VOLATILE (parmtype)) - *textp++ = 'V'; - - switch (TREE_CODE (parmtype)) - { - case OFFSET_TYPE: - *textp++ = 'O'; - textp = build_overload_name (TYPE_OFFSET_BASETYPE (parmtype), textp, text_end); - *textp++ = '_'; - textp = build_overload_name (TREE_TYPE (parmtype), textp, text_end); - break; - - case REFERENCE_TYPE: - *textp++ = 'R'; - goto more; - - case ARRAY_TYPE: -#ifdef PARM_CAN_BE_ARRAY_TYPE - { - tree length; - - *textp++ = 'A'; - length = array_type_nelts (parmtype); - if (TREE_CODE (length) == INTEGER_CST) - textp = icat (textp, TREE_INT_CST_LOW (length)); - *textp++ = '_'; - goto more; - } -#else - *textp++ = 'P'; - goto more; -#endif - - case POINTER_TYPE: - *textp++ = 'P'; - more: - textp = build_overload_name (TREE_TYPE (parmtype), textp, text_end); - break; - - case FUNCTION_TYPE: - case METHOD_TYPE: - { - tree firstarg = TYPE_ARG_TYPES (parmtype); - /* Otherwise have to implement reentrant typevecs, - unmark and remark types, etc. */ - int old_nofold = nofold; - nofold = 1; - - if (nrepeats) - textp = flush_repeats (textp, typevec[maxtype-1]); - - /* @@ It may be possible to pass a function type in - which is not preceded by a 'P'. */ - if (TREE_CODE (parmtype) == FUNCTION_TYPE) - { - *textp++ = 'F'; - if (firstarg == NULL_TREE) - *textp++ = 'e'; - else if (firstarg == void_list_node) - *textp++ = 'v'; - else - textp = build_overload_name (firstarg, textp, text_end); - } - else - { - int constp = TREE_READONLY (TREE_TYPE (TREE_VALUE (firstarg))); - int volatilep = TREE_VOLATILE (TREE_TYPE (TREE_VALUE (firstarg))); - *textp++ = 'M'; - firstarg = TREE_CHAIN (firstarg); - - textp = build_overload_name (TYPE_METHOD_BASETYPE (parmtype), textp, text_end); - if (constp) - *textp++ = 'C'; - if (volatilep) - *textp++ = 'V'; - - /* For cfront 2.0 compatability. */ - *textp++ = 'F'; - - if (firstarg == NULL_TREE) - *textp++ = 'e'; - else if (firstarg == void_list_node) - *textp++ = 'v'; - else - textp = build_overload_name (firstarg, textp, text_end); - } - - /* Separate args from return type. */ - *textp++ = '_'; - textp = build_overload_name (TREE_TYPE (parmtype), textp, text_end); - nofold = old_nofold; - break; - } - - case INTEGER_TYPE: - parmtype = TYPE_MAIN_VARIANT (parmtype); - switch (TYPE_MODE (parmtype)) - { - case TImode: - if (parmtype == long_integer_type_node - || parmtype == long_unsigned_type_node) - *textp++ = 'l'; - else - *textp++ = 'q'; - break; - case DImode: - if (parmtype == long_integer_type_node - || parmtype == long_unsigned_type_node) - *textp++ = 'l'; - else if (parmtype == integer_type_node - || parmtype == unsigned_type_node) - *textp++ = 'i'; - else if (parmtype == short_integer_type_node - || parmtype == short_unsigned_type_node) - *textp++ = 's'; - else - *textp++ = 'x'; - break; - case SImode: - if (parmtype == long_integer_type_node - || parmtype == long_unsigned_type_node) - *textp++ = 'l'; - else if (parmtype == short_integer_type_node - || parmtype == short_unsigned_type_node) - *textp++ = 's'; - else - *textp++ = 'i'; - break; - case HImode: - if (parmtype == integer_type_node - || parmtype == unsigned_type_node) - *textp++ = 'i'; - else - *textp++ = 's'; - break; - case QImode: - *textp++ = 'c'; - break; - default: - abort (); - } - break; - - case REAL_TYPE: - parmtype = TYPE_MAIN_VARIANT (parmtype); - if (parmtype == long_double_type_node) - *textp++ = 'r'; - else if (parmtype == double_type_node) - *textp++ = 'd'; - else if (parmtype == float_type_node) - *textp++ = 'f'; - else abort (); - break; - - case VOID_TYPE: - if (! just_one) - { -#if 0 - extern tree void_list_node; - - /* See if anybody is wasting memory. */ - assert (parmtypes == void_list_node); -#endif - /* This is the end of a parameter list. */ - *textp = '\0'; - return textp; - } - *textp++ = 'v'; - break; - - case ERROR_MARK: /* not right, but nothing is anyway */ - break; - - /* have to do these */ - case UNION_TYPE: - case RECORD_TYPE: - if (! just_one) - /* Make this type signature look incompatible - with AT&T. */ - *textp++ = 'G'; - goto common; - case ENUMERAL_TYPE: - common: - { - tree name = TYPE_NAME (parmtype); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - assert (TREE_CODE (name) == IDENTIFIER_NODE); - textp = icat (textp, IDENTIFIER_LENGTH (name)); - strcpy (textp, IDENTIFIER_POINTER (name)); - textp += IDENTIFIER_LENGTH (name); - break; - } - - case UNKNOWN_TYPE: - /* This will take some work. */ - *textp++ = '?'; - break; - - default: - abort (); - } - - next: - if (just_one) break; - parmtypes = TREE_CHAIN (parmtypes); - } - if (! just_one) - { - if (nrepeats) - textp = flush_repeats (textp, typevec[maxtype-1]); - - /* To get here, parms must end with `...'. */ - *textp++ = 'e'; - } - - *textp = '\0'; - return textp; -} - -/* Change the name of a function definition so that it may be - overloaded. NAME is the name of the function to overload, - PARMS is the parameter list (which determines what name the - final function obtains). - - FOR_METHOD is 1 if this overload is being performed - for a method, rather than a function type. It is 2 if - this overload is being performed for a constructor. */ -tree -build_decl_overload (name, parms, for_method) - char *name; - tree parms; - int for_method; -{ - int tmp; - char tname[OVERLOAD_MAX_LEN]; - - if (for_method == 2) - /* We can divine that this is a constructor, - and figure out its name without any extra encoding. */ - tmp = 0; - else - { - strcpy (tname, name); - tmp = strlen (tname); - } - tname[tmp++] = '_'; - tname[tmp++] = '_'; - if (for_method) - { -#if 0 - /* We can get away without doing this. */ - tname[tmp++] = 'M'; -#endif - parms = temp_tree_cons (NULL_TREE, TREE_TYPE (TREE_VALUE (parms)), TREE_CHAIN (parms)); - } - else - tname[tmp++] = 'F'; - - if (parms == NULL_TREE) - tname[tmp++] = 'e', tname[tmp] = '\0'; - else if (parms == void_list_node) - tname[tmp++] = 'v', tname[tmp] = '\0'; - else - { - ALLOCATE_TYPEVEC (parms); - nofold = 0; - if (for_method) - { - tmp = build_overload_name (TREE_VALUE (parms), tname+tmp, &tname[OVERLOAD_MAX_LEN]) - tname; - -#ifndef LONGERNAMES - typevec[maxtype++] = TREE_VALUE (parms); - TREE_USED (TREE_VALUE (parms)) = 1; -#endif - - if (TREE_CHAIN (parms)) - build_overload_name (TREE_CHAIN (parms), tname+tmp, &tname[OVERLOAD_MAX_LEN]); - else - { - tname[tmp++] = 'e'; - tname[tmp] = '\0'; - } - } - else - build_overload_name (parms, tname+tmp, &tname[OVERLOAD_MAX_LEN]); - DEALLOCATE_TYPEVEC (parms); - } - return get_identifier (tname); -} - -/* Build an overload name for the type expression TYPE. */ -tree -build_typename_overload (type) - tree type; -{ - char tname[OVERLOAD_MAX_LEN]; - int i = sizeof (OPERATOR_TYPENAME_FORMAT) - 1; - sprintf (tname, OPERATOR_TYPENAME_FORMAT); -#if 0 - /* We can get away without doing this--it really gets - overloaded later. */ - tname[i++] = '_'; - tname[i++] = '_'; - tname[i++] = 'M'; -#endif - nofold = 1; - build_overload_name (type, tname + i, &tname[OVERLOAD_MAX_LEN]); - return get_identifier (tname); -} - -/* Top-level interface to explicit overload requests. Allow NAME - to be overloaded. Error if NAME is already declared for the current - scope. Warning if function is redundanly overloaded. */ - -void -declare_overloaded (name) - tree name; -{ -#ifdef NO_AUTO_OVERLOAD - if (is_overloaded (name)) - warning ("function `%s' already declared overloaded", - IDENTIFIER_POINTER (name)); - else if (IDENTIFIER_GLOBAL_VALUE (name)) - error ("overloading function `%s' that is already defined", - IDENTIFIER_POINTER (name)); - else - { - TREE_OVERLOADED (name) = 1; - IDENTIFIER_GLOBAL_VALUE (name) = build_tree_list (name, NULL_TREE); - TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name)) = unknown_type_node; - } -#else - if (current_lang_name == lang_name_cplusplus) - { - if (0) - warning ("functions are implicitly overloaded in C++"); - } - else if (current_lang_name == lang_name_c) - error ("overloading function `%s' cannot be done in C language context"); - else - abort (); -#endif -} - -#ifdef NO_AUTO_OVERLOAD -/* Check to see if NAME is overloaded. For first approximation, - check to see if its TREE_OVERLOADED is set. This is used on - IDENTIFIER nodes. */ -int -is_overloaded (name) - tree name; -{ - /* @@ */ - return (TREE_OVERLOADED (name) - && (! IDENTIFIER_CLASS_VALUE (name) || current_class_type == 0) - && ! IDENTIFIER_LOCAL_VALUE (name)); -} -#endif - -/* Given a tree_code CODE, and some arguments (at least one), - attempt to use an overloaded operator on the arguments. - - For unary operators, only the first argument need be checked. - For binary operators, both arguments may need to be checked. - - Member functions can convert class references to class pointers, - for one-level deep indirection. More than that is not supported. - Operators [](), ()(), and ->() must be member functions. - - We call function call building calls with nonzero complain if - they are our only hope. This is true when we see a vanilla operator - applied to something of aggregate type. If this fails, we are free to - return `error_mark_node', because we will have reported the error. - - Operators NEW and DELETE overload in funny ways: operator new takes - a single `size' parameter, and operator delete takes a pointer to the - storage being deleted. When overloading these operators, success is - assumed. If there is a failure, report an error message and return - `error_mark_node'. */ - -/* NOSTRICT */ -tree -build_opfncall (code, flags, xarg1, xarg2, arg3) - enum tree_code code; - tree xarg1, xarg2; - tree arg3; -{ - tree rval = 0; - tree arg1, arg2; - tree type1, type2, fnname; - tree fields1 = 0, parms = 0; - tree global_fn; - int try_second; - int binary_is_unary; - - if (xarg1 == error_mark_node) - return error_mark_node; - - if (code == COND_EXPR) - { - if (TREE_CODE (xarg2) == ERROR_MARK - || TREE_CODE (arg3) == ERROR_MARK) - return error_mark_node; - } - if (code == COMPONENT_REF) - if (TREE_CODE (TREE_TYPE (xarg1)) == POINTER_TYPE) - return rval; - - /* First, see if we can work with the first argument */ - type1 = TREE_TYPE (xarg1); - - /* Some tree codes have length > 1, but we really only want to - overload them if their first argument has a user defined type. */ - switch (code) - { - case PREINCREMENT_EXPR: - code = POSTINCREMENT_EXPR; - binary_is_unary = 1; - try_second = 0; - break; - - case POSTDECREMENT_EXPR: - code = PREDECREMENT_EXPR; - binary_is_unary = 1; - try_second = 0; - break; - - case PREDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - case COMPONENT_REF: - binary_is_unary = 1; - try_second = 0; - break; - - /* ARRAY_REFs and CALL_EXPRs must overload successfully. - If they do not, return error_mark_node instead of NULL_TREE. */ - case ARRAY_REF: - if (xarg2 == error_mark_node) - return error_mark_node; - case CALL_EXPR: - rval = error_mark_node; - binary_is_unary = 0; - try_second = 0; - break; - - case NEW_EXPR: - { - /* For operators `new' (`delete'), only check visibility - if we are in a constructor (destructor), and we are - allocating for that constructor's (destructor's) type. */ - - fnname = get_identifier (OPERATOR_NEW_FORMAT); - if (flags & LOOKUP_GLOBAL) - return build_overload_call (fnname, tree_cons (NULL_TREE, xarg2, arg3), - flags & LOOKUP_COMPLAIN, 0); - - if (current_function_decl == NULL_TREE - || !DECL_CONSTRUCTOR_P (current_function_decl) - || current_class_type != TYPE_MAIN_VARIANT (type1)) - flags = LOOKUP_COMPLAIN; - rval = build_method_call (build1 (NOP_EXPR, xarg1, error_mark_node), - fnname, tree_cons (NULL_TREE, xarg2, arg3), - NULL_TREE, flags); - if (rval == error_mark_node) - /* User might declare fancy operator new, but invoke it - like standard one. */ - return rval; - - TREE_TYPE (rval) = xarg1; - TREE_CALLS_NEW (rval) = 1; - return rval; - } - break; - - case DELETE_EXPR: - { - /* See comment above. */ - - fnname = get_identifier (OPERATOR_DELETE_FORMAT); - if (flags & LOOKUP_GLOBAL) - return build_overload_call (fnname, build_tree_list (NULL_TREE, xarg1), - flags & LOOKUP_COMPLAIN, 0); - - if (current_function_decl == NULL_TREE - || !DESTRUCTOR_NAME_P (DECL_NAME (current_function_decl)) - || current_class_type != TYPE_MAIN_VARIANT (type1)) - flags = LOOKUP_COMPLAIN; - rval = build_method_call (build1 (NOP_EXPR, TREE_TYPE (xarg1), error_mark_node), - fnname, build_tree_list (NULL_TREE, xarg1), - NULL_TREE, flags); - /* This happens when the user mis-declares `operator delete'. - Should now be impossible. */ - assert (rval != error_mark_node); - TREE_TYPE (rval) = void_type_node; - return rval; - } - break; - - default: - binary_is_unary = 0; - try_second = tree_code_length [(int) code] == 2; - if (xarg2 == error_mark_node) - return error_mark_node; - break; - } - - if (try_second && xarg2 == error_mark_node) - return error_mark_node; - - /* What ever it was, we do not know how to deal with it. */ - if (type1 == NULL_TREE) - return rval; - - if (TREE_CODE (type1) == OFFSET_TYPE) - type1 = TREE_TYPE (type1); - - if (TREE_CODE (type1) == REFERENCE_TYPE) - { - arg1 = convert_from_reference (xarg1); - type1 = TREE_TYPE (arg1); - } - else - { - arg1 = xarg1; - } - - if (!IS_AGGR_TYPE (type1)) - { - /* Try to fail. First, fail if unary */ - if (! try_second) - return rval; - /* Second, see if second argument is non-aggregate. */ - type2 = TREE_TYPE (xarg2); - if (TREE_CODE (type2) == OFFSET_TYPE) - type2 = TREE_TYPE (type2); - if (TREE_CODE (type2) == REFERENCE_TYPE) - { - arg2 = convert_from_reference (xarg2); - type2 = TREE_TYPE (arg2); - } - else - { - arg2 = xarg2; - } - - if (!IS_AGGR_TYPE (type2)) - return rval; - try_second = 0; - } - - if (try_second) - { - /* First arg may succeed; see whether second should. */ - type2 = TREE_TYPE (xarg2); - if (TREE_CODE (type2) == OFFSET_TYPE) - type2 = TREE_TYPE (type2); - if (TREE_CODE (type2) == REFERENCE_TYPE) - { - arg2 = convert_from_reference (xarg2); - type2 = TREE_TYPE (arg2); - } - else - { - arg2 = xarg2; - } - - if (! IS_AGGR_TYPE (type2)) - try_second = 0; - } - - if (type1 == unknown_type_node - || (try_second && TREE_TYPE (xarg2) == unknown_type_node)) - { - /* This will not be implemented in the forseeable future. */ - return rval; - } - - if (code == MODIFY_EXPR) - { - tree op_id = build_opid (MODIFY_EXPR, arg3); - fnname = build_operator_fnname (&op_id, 0, 2); - } - else - { - tree op_id = build_opid (0, code); - if (binary_is_unary) - fnname = build_operator_fnname (&op_id, 0, 1); - else - fnname = build_operator_fnname (&op_id, 0, - tree_code_length [(int) code]); - } - - global_fn = IDENTIFIER_GLOBAL_VALUE (fnname); - - /* This is the last point where we will accept failure. This - may be too eager if we wish an overloaded operator not to match, - but would rather a normal operator be called on a type-converted - argument. */ - - if (IS_AGGR_TYPE (type1)) - fields1 = lookup_fnfields (CLASSTYPE_AS_LIST (type1), fnname, 0); - - if (fields1 == NULL_TREE && global_fn == NULL_TREE) - return rval; - - /* If RVAL winds up being `error_mark_node', we will return - that... There is no way that normal semantics of these - operators will succeed. */ - - /* This argument may be an uncommited OFFSET_REF. This is - the case for example when dealing with static class members - which are referenced from their class name rather than - from a class instance. */ - if (TREE_CODE (xarg1) == OFFSET_REF - && TREE_CODE (TREE_OPERAND (xarg1, 1)) == VAR_DECL) - xarg1 = TREE_OPERAND (xarg1, 1); - if (try_second && xarg2 && TREE_CODE (xarg2) == OFFSET_REF - && TREE_CODE (TREE_OPERAND (xarg2, 1)) == VAR_DECL) - xarg2 = TREE_OPERAND (xarg2, 1); - - if (global_fn) - flags |= LOOKUP_GLOBAL; - - if (code == CALL_EXPR) - { - /* This can only be a member function. */ - return build_method_call (xarg1, fnname, xarg2, - NULL_TREE, LOOKUP_NORMAL); - } - else if (tree_code_length[(int) code] == 1 || binary_is_unary) - { - parms = NULL_TREE; - rval = build_method_call (xarg1, fnname, NULL_TREE, NULL_TREE, flags); - } - else if (code == COND_EXPR) - { - parms = tree_cons (0, xarg2, build_tree_list (0, arg3)); - rval = build_method_call (xarg1, fnname, parms, NULL_TREE, flags); - } - else if (code == METHOD_CALL_EXPR) - { - /* must be a member function. */ - parms = tree_cons (NULL_TREE, xarg2, arg3); - return build_method_call (xarg1, fnname, parms, NULL_TREE, LOOKUP_NORMAL); - } - else if (fields1) - { - parms = build_tree_list (NULL_TREE, xarg2); - rval = build_method_call (xarg1, fnname, parms, NULL_TREE, flags); - } - else - { - parms = tree_cons (NULL_TREE, xarg1, - build_tree_list (NULL_TREE, xarg2)); - rval = build_overload_call (fnname, parms, flags & LOOKUP_COMPLAIN, 0); - } - - /* If we did not win, do not lose yet, since type conversion may work. */ - if (TREE_CODE (rval) == ERROR_MARK) - { - if (flags & LOOKUP_COMPLAIN) - return rval; - return 0; - } - - return rval; -} - -/* This function takes an identifier, ID, and attempts to figure out what - it means. There are a number of possible scenarios, presented in increasing - order of hair: - - 1) not in a class's scope - 2) in class's scope, member name of the class's method - 3) in class's scope, but not a member name of the class - 4) in class's scope, member name of a class's variable - - NAME is $1 from the bison rule. It is an IDENTIFIER_NODE. - VALUE is $$ from the bison rule. It is the value returned by lookup_name ($1) - yychar is the pending input character (suitably encoded :-). - - As a last ditch, try to look up the name as a label and return that - address. - - Values which are declared as being of REFERENCE_TYPE are - automatically dereferenced here (as a hack to make the - compiler faster). */ - -tree -hack_identifier (value, name, yychar) - tree value, name; -{ - tree type; - - if (TREE_CODE (value) == ERROR_MARK) - { - if (current_class_name) - { - tree fields = lookup_fnfields (CLASSTYPE_AS_LIST (current_class_type), name, 0); - if (fields) - { - fields = TREE_VALUE (fields); - assert (TREE_CODE (fields) == FUNCTION_DECL); - if (TREE_CHAIN (fields) == NULL_TREE) - { - warning ("methods cannot be converted to function pointers"); - return fields; - } - else - { - error ("ambiguous request for method pointer `%s'", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - } - } - if (flag_labels_ok && IDENTIFIER_LABEL_VALUE (name)) - { - return IDENTIFIER_LABEL_VALUE (name); - } - return error_mark_node; - } - - type = TREE_TYPE (value); - if (TREE_NONLOCAL (value)) - { - if (TREE_CODE (value) == FIELD_DECL) - { - if (current_class_decl == NULL_TREE) - { - error ("request for member `%s' in static member function", - IDENTIFIER_POINTER (DECL_NAME (value))); - return error_mark_node; - } - TREE_USED (current_class_decl) = 1; - if (yychar == '(') - if (! ((TYPE_LANG_SPECIFIC (type) - && TYPE_OVERLOADS_CALL_EXPR (type)) - || (TREE_CODE (type) == REFERENCE_TYPE - && TYPE_LANG_SPECIFIC (TREE_TYPE (type)) - && TYPE_OVERLOADS_CALL_EXPR (TREE_TYPE (type)))) - && TREE_CODE (type) != FUNCTION_TYPE - && TREE_CODE (type) != METHOD_TYPE - && (TREE_CODE (type) != POINTER_TYPE - || (TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE - && TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE))) - { - error ("component `%s' is not a method", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - /* Mark so that if we are in a constructor, and then find that - this field was initialized by a base initializer, - we can emit an error message. */ - TREE_USED (value) = 1; - return build_component_ref (C_C_D, name, 0, 1); - } - if (DECL_CONTEXT (value) != current_class_type - && (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == CONST_DECL)) - { - tree path; - enum visibility_type visibility; - - get_base_distance (DECL_CONTEXT (value), current_class_type, 0, &path); - visibility = compute_visibility (path, value); - if (visibility != visibility_public) - { - if (TREE_CODE (value) == VAR_DECL) - error ("static member `%s' is from private base class", - IDENTIFIER_POINTER (name)); - else - error ("enum `%s' is from private base class", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - } - else if (TREE_CODE (value) == TREE_LIST && type == 0) - { - error ("request for member `%s' is ambiguous in multiple inheritance lattice", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - - return value; - } - - if (! TREE_USED (value)) - { - if (TREE_EXTERNAL (value)) - assemble_external (value); - TREE_USED (value) = 1; - } - if (TREE_CODE (type) == REFERENCE_TYPE) - { - assert (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == PARM_DECL - || TREE_CODE (value) == RESULT_DECL); - if (DECL_REFERENCE_SLOT (value)) - return DECL_REFERENCE_SLOT (value); - } - return value; -} - -tree -hack_operator (op) - tree op; -{ - if (op == NULL_TREE) - return error_mark_node; - - if (TREE_CODE (op) != TYPE_EXPR) - return grokopexpr (&op, NULL_TREE, 0, 0, 0); - - return op; -} - -/* NONWRAPPER is nonzero if this call is not to be wrapped. - TYPE is the type that the wrapper belongs to (in case - it should be non-virtual). - DECL is the function will will be (not be) wrapped. */ -tree -hack_wrapper (nonwrapper, type, decl) - int nonwrapper; - tree type, decl; -{ - if (type == NULL_TREE || is_aggr_typedef (type, 1)) - { - if (type) - type = TREE_TYPE (type); - - switch (nonwrapper) - { - case 0: - return build_nt (WRAPPER_EXPR, type, decl); - case 1: - return build_nt (ANTI_WRAPPER_EXPR, type, decl); - case 2: - return build_nt (WRAPPER_EXPR, type, - build_nt (COND_EXPR, decl, NULL_TREE, NULL_TREE)); - default: - assert (0 <= nonwrapper && nonwrapper <= 2); - } - } - return error_mark_node; -} - -/* Return an IDENTIFIER which can be used as a name for - anonymous structs and unions. */ -tree -make_anon_name () -{ - static int cnt = 0; - char buf[32]; - - sprintf (buf, ANON_AGGRNAME_FORMAT, cnt++); - return get_identifier (buf); -} - -/* Given an object OF, and a type conversion operator COMPONENT - build a call to the conversion operator, if a call is requested, - or return the address (as a pointer to member function) if one is not. - - OF can be a TYPE_DECL or any kind of datum that would normally - be passed to `build_component_ref'. It may also be NULL_TREE, - in which case `current_class_type' and `current_class_decl' - provide default values. - - BASETYPE_PATH, if non-null, is the path of basetypes - to go through before we get the the instance of interest. - - PROTECT says whether we apply C++ scoping rules or not. */ -tree -build_component_type_expr (of, component, basetype_path, protect) - tree of, component, basetype_path; - int protect; -{ - tree cname = NULL_TREE; - tree tmp, last; - tree name; - int flags = protect ? LOOKUP_NORMAL : LOOKUP_COMPLAIN; - - assert (IS_AGGR_TYPE (TREE_TYPE (of))); - assert (TREE_CODE (component) == TYPE_EXPR); - - tmp = TREE_OPERAND (component, 0); - last = NULL_TREE; - - while (tmp) - { - switch (TREE_CODE (tmp)) - { - case CALL_EXPR: - if (last) - TREE_OPERAND (last, 0) = TREE_OPERAND (tmp, 0); - else - TREE_OPERAND (component, 0) = TREE_OPERAND (tmp, 0); - if (TREE_OPERAND (tmp, 0) - && TREE_OPERAND (tmp, 0) != void_list_node) - { - error ("operator requires empty parameter list"); - TREE_OPERAND (tmp, 0) = NULL_TREE; - } - last = groktypename (build_tree_list (TREE_TYPE (component), - TREE_OPERAND (component, 0))); - name = build_typename_overload (last); - TREE_TYPE (name) = last; - - if (of && TREE_CODE (of) != TYPE_DECL) - return build_method_call (of, name, NULL_TREE, NULL_TREE, flags); - else if (of) - { - tree this_this; - - if (current_class_decl == NULL_TREE) - { - error ("object required for `operator ' call"); - return error_mark_node; - } - - this_this = convert_pointer_to (TREE_TYPE (of), current_class_decl); - return build_method_call (this_this, name, NULL_TREE, - NULL_TREE, flags | LOOKUP_NONVIRTUAL); - } - else if (current_class_decl) - return build_method_call (tmp, name, NULL_TREE, NULL_TREE, flags); - - error ("object required for `operator ' call"); - return error_mark_node; - - case INDIRECT_REF: - case ADDR_EXPR: - case ARRAY_REF: - break; - - case SCOPE_REF: - assert (cname == 0); - cname = TREE_OPERAND (tmp, 0); - tmp = TREE_OPERAND (tmp, 1); - break; - - default: - abort (); - } - last = tmp; - tmp = TREE_OPERAND (tmp, 0); - } - - last = groktypename (build_tree_list (TREE_TYPE (component), TREE_OPERAND (component, 0))); - name = build_typename_overload (last); - TREE_TYPE (name) = last; - if (of && TREE_CODE (of) == TYPE_DECL) - { - if (cname == NULL_TREE) - { - cname = DECL_NAME (of); - of = NULL_TREE; - } - else assert (cname == DECL_NAME (of)); - } - - if (of) - { - tree this_this; - - if (current_class_decl == NULL_TREE) - { - error ("object required for `operator ' call"); - return error_mark_node; - } - - this_this = convert_pointer_to (TREE_TYPE (of), current_class_decl); - return build_component_ref (this_this, name, 0, protect); - } - else if (cname) - return build_offset_ref (cname, name); - else if (current_class_name) - return build_offset_ref (current_class_name, name); - - error ("object required for `operator ' member reference"); - return error_mark_node; -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-parse.h b/gnu/usr.bin/g++/cc1plus/cplus-parse.h deleted file mode 100644 index edfe6638d9de..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-parse.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Define constants for communication with parse.y. - Copyright (C) 1987 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - - - -enum rid -{ - RID_UNUSED, - RID_INT, - RID_CHAR, - RID_FLOAT, - RID_DOUBLE, - RID_VOID, - RID_UNUSED1, - - /* C++ extension */ - RID_CLASS, - RID_RECORD, - RID_UNION, - RID_ENUM, - RID_LONGLONG, - - RID_UNSIGNED, - RID_SHORT, - RID_LONG, - RID_AUTO, - RID_STATIC, - RID_EXTERN, - RID_REGISTER, - RID_TYPEDEF, - RID_SIGNED, - RID_CONST, - RID_VOLATILE, - RID_INLINE, - RID_NOALIAS, - - /* extensions */ - RID_FRIEND, - RID_VIRTUAL, - RID_EXCEPTION, - RID_RAISES, - - RID_MAX, -}; - -#define RID_FIRST_MODIFIER RID_UNSIGNED diff --git a/gnu/usr.bin/g++/cc1plus/cplus-parse.y b/gnu/usr.bin/g++/cc1plus/cplus-parse.y deleted file mode 100644 index 91d3a1b09185..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-parse.y +++ /dev/null @@ -1,3174 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - */ - -/* YACC parser for C++ syntax. - Copyright (C) 1988, 1989 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This grammar is based on the GNU CC grammar. */ - -/* Also note: this version contains experimental exception - handling features. They could break, change, disappear, - or otherwise exhibit volatile behavior. Don't depend on - me (Michael Tiemann) to protect you from any negative impact - this may have on your professional, personal, or spiritual life. */ - -%{ -#ifndef lint -static char sccsid[] = "@(#)cplus-parse.y 6.3 (Berkeley) 5/8/91"; -#endif /* not lint */ - -#include "config.h" -#include "tree.h" -#include "input.h" -#include "cplus-parse.h" -#include "cplus-tree.h" -#include "assert.h" - -/* C++ extensions */ -extern tree ridpointers[]; /* need this up here */ -extern tree void_list_node; - -/* Bison compatibility */ -#define YYEMPTY -1 -#define YYLEX yylex() - -#include -#include - -#ifndef errno -extern int errno; -#endif - -extern int end_of_file; - -void yyerror (); - -/* Contains error message to give if user tries to declare - a variable where one does not belong. */ -static char *stmt_decl_msg = 0; - -#ifndef YYDEBUG -/* Cause the `yydebug' variable to be defined. */ -int yydebug; -#endif - -/* Cons up an empty parameter list. */ -#ifdef __GNU__ -__inline -#endif -static tree -empty_parms () -{ - tree parms; - - if (strict_prototype) - parms = void_list_node; - else - parms = NULL_TREE; - return parms; -} - -void yyhook (); -%} - -%start program - -%union {long itype; tree ttype; enum tree_code code; } - -/* All identifiers that are not reserved words - and are not declared typedefs in the current block */ -%token IDENTIFIER - -/* All identifiers that are declared typedefs in the current block. - In some contexts, they are treated just like IDENTIFIER, - but they can also serve as typespecs in declarations. */ -%token TYPENAME - -/* Reserved words that specify storage class. - yylval contains an IDENTIFIER_NODE which indicates which one. */ -%token SCSPEC - -/* Reserved words that specify type. - yylval contains an IDENTIFIER_NODE which indicates which one. */ -%token TYPESPEC - -/* Reserved words that qualify type: "const" or "volatile". - yylval contains an IDENTIFIER_NODE which indicates which one. */ -%token TYPE_QUAL - -/* Character or numeric constants. - yylval is the node for the constant. */ -%token CONSTANT - -/* String constants in raw form. - yylval is a STRING_CST node. */ -%token STRING - -/* "...", used for functions with variable arglists. */ -%token ELLIPSIS - -/* the reserved words */ -%token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT -%token BREAK CONTINUE RETURN GOTO ASM TYPEOF ALIGNOF -%token ATTRIBUTE - -/* the reserved words... C++ extensions */ -%token AGGR -%token DELETE NEW OVERLOAD PRIVATE PUBLIC PROTECTED THIS OPERATOR -%token DYNAMIC POINTSAT_LEFT_RIGHT LEFT_RIGHT -%token SCOPE - -/* Define the operator tokens and their precedences. - The value is an integer because, if used, it is the tree code - to use in the expression made from the operator. */ - -%left EMPTY /* used to resolve s/r with epsilon */ - -/* Add precedence rules to solve dangling else s/r conflict */ -%nonassoc IF -%nonassoc ELSE - -%left IDENTIFIER TYPENAME TYPENAME_COLON SCSPEC TYPESPEC TYPE_QUAL ENUM AGGR - -%left '{' ',' - -%right ASSIGN '=' -%right '?' ':' RANGE -%left OROR -%left ANDAND -%left '|' -%left '^' -%left '&' -%left MIN_MAX -%left EQCOMPARE -%left ARITHCOMPARE -%left LSHIFT RSHIFT -%left '+' '-' -%left '*' '/' '%' -%right UNARY PLUSPLUS MINUSMINUS -%left HYPERUNARY -%left PAREN_STAR_PAREN PAREN_X_SCOPE_STAR_PAREN PAREN_X_SCOPE_REF_PAREN LEFT_RIGHT -%left POINTSAT '.' '(' '[' - -%right SCOPE /* C++ extension */ -%nonassoc NEW DELETE RAISE RAISES RERAISE TRY EXCEPT CATCH -%right DYNAMIC - -%type unop - -%type identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist /* exprlist */ -%type expr_no_commas cast_expr unary_expr primary string STRING -%type typed_declspecs reserved_declspecs -%type typed_typespecs reserved_typespecquals -%type declmods typespec typespecqual_reserved -%type SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual -%type initdecls notype_initdecls initdcl /* C++ modification */ -%type init initlist maybeasm -%type asm_operands nonnull_asm_operands asm_operand asm_clobbers -%type maybe_attribute attribute_list attrib - -%type compstmt except_stmts - -%type declarator notype_declarator after_type_declarator - -%type structsp opt.component_decl_list component_decl_list component_decl components component_declarator -%type enumlist enumerator -%type typename absdcl absdcl1 type_quals -%type xexpr see_typename parmlist parms parm bad_parm - -/* C++ extensions */ -%token TYPENAME_COLON TYPENAME_SCOPE TYPENAME_ELLIPSIS -%token PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL -%type fn.def2 dummy_decl x_typespec return_id -%type class_head opt.init base_class_list base_class_visibility_list -%type after_type_declarator_no_typename -%type maybe_raises raise_identifier raise_identifiers -%type component_declarator0 scoped_identifier -%type forhead.1 identifier_or_opname operator_name -%type new delete object primary_no_id aggr nonmomentary_expr -%type LC forhead.2 initdcl0 notype_initdcl0 wrapper member_init_list -%type .scope try - -%{ -/* the declaration found for the last IDENTIFIER token read in. - yylex must look this up to detect typedefs, which get token type TYPENAME, - so it is left around in case the identifier is not a typedef but is - used in a context which makes it a reference to a variable. */ -tree lastiddecl; - -tree make_pointer_declarator (), make_reference_declarator (); - -tree combine_strings (); -void reinit_parse_for_function (); -void reinit_parse_for_method (); - -/* List of types and structure classes of the current declaration. */ -tree current_declspecs; - -int undeclared_variable_notice; /* 1 if we explained undeclared var errors. */ - -int yylex (); -extern FILE *finput; -%} - -%% -program: .program /* empty */ - | .program extdefs - { finish_file (); } - ; - -.program: /* empty */ - { - if (flag_cadillac) - cadillac_start (); - } - -/* the reason for the strange actions in this rule - is so that notype_initdecls when reached via datadef - can find a valid list of type and sc specs in $0. */ - -extdefs: - {$$ = NULL_TREE; } extdef - | extdefs {$$ = NULL_TREE; } extdef - ; - -extdef: - fndef - { if (pending_inlines) do_pending_inlines (); } - | datadef - { if (pending_inlines) do_pending_inlines (); } - | overloaddef - | ASM '(' string ')' ';' - { if (pedantic) - warning ("ANSI C forbids use of `asm' keyword"); - if (TREE_CHAIN ($3)) $3 = combine_strings ($3); - assemble_asm ($3); } - | extern_lang_string '{' extdefs '}' - { pop_lang_context (); } - | extern_lang_string '{' '}' - { pop_lang_context (); } - | extern_lang_string fndef - { if (pending_inlines) do_pending_inlines (); - pop_lang_context (); } - | extern_lang_string datadef - { if (pending_inlines) do_pending_inlines (); - pop_lang_context (); } - ; - -extern_lang_string: - EXTERN_LANG_STRING - { push_lang_context ($1); } - ; - -overloaddef: - OVERLOAD ov_identifiers ';' - -ov_identifiers: IDENTIFIER - { declare_overloaded ($1); } - | ov_identifiers ',' IDENTIFIER - { declare_overloaded ($3); } - ; - -dummy_decl: /* empty */ - { $$ = NULL_TREE; } - ; - -datadef: - dummy_decl notype_initdecls ';' - { if (pedantic) - error ("ANSI C forbids data definition lacking type or storage class"); - else if (! flag_traditional) - warning ("data definition lacks type or storage class"); } - | declmods notype_initdecls ';' - {} - /* Normal case to make fast: "int i;". */ - | declmods declarator ';' - { tree d; - d = start_decl ($2, $1, 0, NULL_TREE); - finish_decl (d, NULL_TREE, NULL_TREE); - } - | typed_declspecs initdecls ';' - { - end_exception_decls (); - note_got_semicolon ($1); - } - /* Normal case: make this fast. */ - | typed_declspecs declarator ';' - { tree d; - d = start_decl ($2, $1, 0, NULL_TREE); - finish_decl (d, NULL_TREE, NULL_TREE); - end_exception_decls (); - note_got_semicolon ($1); - } - | declmods ';' - { error ("empty declaration"); } - | typed_declspecs ';' - { - shadow_tag ($1); - note_got_semicolon ($1); - } - | error ';' - | error '}' - | ';' - ; - -fndef: - fn.def1 base_init compstmt_or_error - { - finish_function (lineno, 1); - /* finish_function performs these three statements: - - expand_end_bindings (getdecls (), 1, 0); - poplevel (1, 1, 0); - - expand_end_bindings (0, 0, 0); - poplevel (0, 0, 1); - */ - } - | fn.def1 return_init base_init compstmt_or_error - { - finish_function (lineno, 1); - /* finish_function performs these three statements: - - expand_end_bindings (getdecls (), 1, 0); - poplevel (1, 1, 0); - - expand_end_bindings (0, 0, 0); - poplevel (0, 0, 1); - */ - } - | fn.def1 nodecls compstmt_or_error - { finish_function (lineno, 0); } - | fn.def1 return_init ';' nodecls compstmt_or_error - { finish_function (lineno, 0); } - | fn.def1 return_init nodecls compstmt_or_error - { finish_function (lineno, 0); } - | typed_declspecs declarator error - {} - | declmods notype_declarator error - {} - | dummy_decl notype_declarator error - {} - ; - -fn.def1: - typed_declspecs declarator maybe_raises - { if (! start_function ($1, $2, $3, 0)) - YYERROR; - reinit_parse_for_function (); } - | declmods notype_declarator maybe_raises - { if (! start_function ($1, $2, $3, 0)) - YYERROR; - reinit_parse_for_function (); } - | dummy_decl notype_declarator maybe_raises - { if (! start_function (NULL_TREE, $2, $3, 0)) - YYERROR; - reinit_parse_for_function (); } - | dummy_decl TYPENAME '(' parmlist ')' type_quals maybe_raises - { if (! start_function (NULL_TREE, build_parse_node (CALL_EXPR, $2, $4, $6), $7, 0)) - YYERROR; - reinit_parse_for_function (); } - | dummy_decl TYPENAME LEFT_RIGHT type_quals maybe_raises - { if (! start_function (NULL_TREE, build_parse_node (CALL_EXPR, $2, empty_parms (), $4), $5, 0)) - YYERROR; - reinit_parse_for_function (); } - | PRE_PARSED_FUNCTION_DECL - { start_function (NULL_TREE, $1, NULL_TREE, 1); - reinit_parse_for_function (); } - ; - -/* more C++ complexity */ -fn.def2: - typed_declspecs '(' parmlist ')' type_quals maybe_raises - { - tree decl = build_parse_node (CALL_EXPR, TREE_VALUE ($1), $3, $5); - $$ = start_method (TREE_CHAIN ($1), decl, $6); - if (! $$) - YYERROR; - if (yychar == -1) - yychar = yylex(); - reinit_parse_for_method (yychar, $$); } - | typed_declspecs LEFT_RIGHT type_quals maybe_raises - { - tree decl = build_parse_node (CALL_EXPR, TREE_VALUE ($1), empty_parms (), $3); - $$ = start_method (TREE_CHAIN ($1), decl, $4); - if (! $$) - YYERROR; - if (yychar == YYEMPTY) - yychar = YYLEX; - reinit_parse_for_method (yychar, $$); } - | typed_declspecs declarator maybe_raises - { $$ = start_method ($1, $2, $3); - if (! $$) - YYERROR; - if (yychar == YYEMPTY) - yychar = YYLEX; - reinit_parse_for_method (yychar, $$); } - | declmods '(' parmlist ')' type_quals maybe_raises - { - tree decl = build_parse_node (CALL_EXPR, TREE_VALUE ($1), $3, $5); - $$ = start_method (TREE_CHAIN ($1), decl, $6); - if (! $$) - YYERROR; - if (yychar == YYEMPTY) - yychar = YYLEX; - reinit_parse_for_method (yychar, $$); } - | declmods LEFT_RIGHT type_quals maybe_raises - { - tree decl = build_parse_node (CALL_EXPR, TREE_VALUE ($1), empty_parms (), $3); - $$ = start_method (TREE_CHAIN ($1), decl, $4); - if (! $$) - YYERROR; - if (yychar == YYEMPTY) - yychar = YYLEX; - reinit_parse_for_method (yychar, $$); } - | declmods declarator maybe_raises - { $$ = start_method ($1, $2, $3); - if (! $$) - YYERROR; - if (yychar == YYEMPTY) - yychar = YYLEX; - reinit_parse_for_method (yychar, $$); } - | dummy_decl notype_declarator maybe_raises - { $$ = start_method (NULL_TREE, $2, $3); - if (! $$) - YYERROR; - if (yychar == YYEMPTY) - yychar = YYLEX; - reinit_parse_for_method (yychar, $$); } - ; - -return_id: RETURN IDENTIFIER - { - if (! current_function_parms_stored) - store_parm_decls (); - $$ = $2; - } - ; - -return_init: return_id opt.init - { - extern tree value_identifier; - tree result; - - result = DECL_RESULT (current_function_decl); - if (DECL_NAME (result) == value_identifier) - DECL_NAME (result) = $1; - else - error ("return identifier `%s' already in place", - IDENTIFIER_POINTER (DECL_NAME (result))); - store_return_init ($2); - } - | return_id '(' nonnull_exprlist ')' - { - extern tree value_identifier; - tree result; - - result = DECL_RESULT (current_function_decl); - if (DECL_NAME (result) == value_identifier) - DECL_NAME (result) = $1; - else - error ("return identifier `%s' already in place", - IDENTIFIER_POINTER (DECL_NAME (result))); - store_return_init ($3); - } - | return_id LEFT_RIGHT - { - extern tree value_identifier; - tree result; - - result = DECL_RESULT (current_function_decl); - if (DECL_NAME (result) == value_identifier) - DECL_NAME (result) = $1; - else - error ("return identifier `%s' already in place", - IDENTIFIER_POINTER (DECL_NAME (result))); - store_return_init (NULL_TREE); - } - ; - -base_init: - ':' .set_base_init member_init_list - { - if ($3 == 0) - error ("no base initializers given following ':'"); - setup_vtbl_ptr (); - } - ; - -.set_base_init: - /* empty */ - { - int preserve = (current_class_type - && TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)); - preserve = 0; /* "in charge" arg means we no longer - need this hack. */ - if (! current_function_parms_stored) - store_parm_decls (); - else if (preserve) - preserve_data (); - - /* Flag that we are processing base and member initializers. */ - current_vtable_decl = error_mark_node; - - if (DECL_CONSTRUCTOR_P (current_function_decl)) - { - /* Make a contour for the initializer list. */ - pushlevel (0); - clear_last_expr (); - expand_start_bindings (0); - } - else if (current_class_type == NULL_TREE) - error ("base initializers not allowed for non-member functions"); - else if (! DECL_CONSTRUCTOR_P (current_function_decl)) - error ("only constructors take base initializers"); - } - ; - -member_init_list: - /* empty */ - { $$ = 0; } - | member_init - { $$ = 1; } - | member_init_list ',' member_init - | member_init_list error - ; - - - -member_init: '(' nonnull_exprlist ')' - { - if (current_class_name && pedantic) - warning ("old style base class initialization; use `%s (...)'", - IDENTIFIER_POINTER (current_class_name)); - expand_member_init (C_C_D, NULL_TREE, $2); - } - | LEFT_RIGHT - { - if (current_class_name && pedantic) - warning ("old style base class initialization; use `%s (...)'", - IDENTIFIER_POINTER (current_class_name)); - expand_member_init (C_C_D, NULL_TREE, void_type_node); - } - | identifier '(' nonnull_exprlist ')' - { - expand_member_init (C_C_D, $1, $3); - } - | identifier LEFT_RIGHT - { expand_member_init (C_C_D, $1, void_type_node); } - | scoped_identifier identifier '(' nonnull_exprlist ')' - { - tree base, basetype; - tree scopes = $1; - - if (TREE_CODE (scopes) == SCOPE_REF) - /* just a pain to do this right now. */ - abort (); - - if (current_class_type == NULL_TREE - || ! is_aggr_typedef (scopes, 1)) - break; - basetype = get_base_type (TREE_TYPE (TREE_TYPE (scopes)), - current_class_type, 1); - if (basetype == error_mark_node) - break; - if (basetype == 0) - { - error_not_base_type (TREE_TYPE (TREE_TYPE (scopes)), current_class_type); - break; - } - - base = convert_pointer_to (basetype, current_class_decl); - expand_member_init (build_indirect_ref (base), $2, $4); - } - | scoped_identifier identifier LEFT_RIGHT - { - tree basetype, base; - tree scopes = $1; - if (TREE_CODE (scopes) == SCOPE_REF) - /* just a pain to do this right now. */ - abort (); - - if (current_class_type == NULL_TREE - || ! is_aggr_typedef (scopes, 1)) - break; - basetype = get_base_type (TREE_TYPE (TREE_TYPE (scopes)), - current_class_type, 1); - if (basetype == error_mark_node) - break; - if (basetype == 0) - { - error_not_base_type (TREE_TYPE (TREE_TYPE (scopes)), current_class_type); - break; - } - - base = convert_pointer_to (basetype, current_class_decl); - expand_member_init (build_indirect_ref (base), $2, void_type_node); - } - ; - -identifier: - IDENTIFIER - | TYPENAME - ; - -identifier_or_opname: - IDENTIFIER - | TYPENAME - | '~' identifier - { $$ = build_parse_node (BIT_NOT_EXPR, $2); } - | operator_name - { $$ = hack_operator ($1); - if ($$ == error_mark_node) - $$ = get_identifier (""); } - | wrapper IDENTIFIER - { $$ = hack_wrapper ($1, NULL_TREE, $2); } - | wrapper TYPENAME - { $$ = hack_wrapper ($1, NULL_TREE, $2); } - | wrapper operator_name - { $$ = hack_wrapper ($1, NULL_TREE, $2); } - | wrapper scoped_identifier IDENTIFIER - { $$ = hack_wrapper ($1, $2, $3); } - | wrapper scoped_identifier operator_name - { $$ = hack_wrapper ($1, $2, $3); } - ; - -wrapper: LEFT_RIGHT - { $$ = 0; } - | '~' LEFT_RIGHT - { $$ = 1; } - | LEFT_RIGHT '?' - { $$ = 2; } - ; - -unop: '-' - { $$ = NEGATE_EXPR; } - | '+' - { $$ = CONVERT_EXPR; } - | PLUSPLUS - { $$ = PREINCREMENT_EXPR; } - | MINUSMINUS - { $$ = PREDECREMENT_EXPR; } - | '!' - { $$ = TRUTH_NOT_EXPR; } - ; - -expr: nonnull_exprlist - { $$ = build_x_compound_expr ($1); } - /* Ugly, but faster. */ - | expr_no_commas - { - if (TREE_CODE ($1) == CALL_EXPR - && TYPE_NEEDS_DESTRUCTOR (TREE_TYPE ($1))) - $$ = cleanup_after_call ($1); - } - ; - -/* Now obsolete. -exprlist: - / * empty * / - { $$ = NULL_TREE; } - | nonnull_exprlist - ; -*/ - -nonnull_exprlist: - expr_no_commas - { $$ = build_tree_list (NULL_TREE, $1); } - | nonnull_exprlist ',' expr_no_commas - { chainon ($1, build_tree_list (NULL_TREE, $3)); } - | nonnull_exprlist ',' error - { chainon ($1, build_tree_list (NULL_TREE, error_mark_node)); } - ; - -unary_expr: - primary %prec UNARY - { - if (TREE_CODE ($1) == TYPE_EXPR) - $$ = build_component_type_expr (C_C_D, $1, NULL_TREE, 1); - else - $$ = $1; - } - | '*' cast_expr %prec UNARY - { $$ = build_x_indirect_ref ($2, "unary *"); } - | '&' cast_expr %prec UNARY - { $$ = build_x_unary_op (ADDR_EXPR, $2); } - | '~' cast_expr %prec UNARY - { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); } - | unop cast_expr %prec UNARY - { $$ = build_x_unary_op ($1, $2); - if ($1 == NEGATE_EXPR && TREE_CODE ($2) == INTEGER_CST) - TREE_NEGATED_INT ($$) = 1; - } - | SIZEOF unary_expr %prec UNARY - { if (TREE_CODE ($2) == COMPONENT_REF - && TREE_PACKED (TREE_OPERAND ($2, 1))) - error ("sizeof applied to a bit-field"); - /* ANSI says arrays and functions are converted inside comma. - But we can't really convert them in build_compound_expr - because that would break commas in lvalues. - So do the conversion here if operand was a comma. */ - if (TREE_CODE ($2) == COMPOUND_EXPR - && (TREE_CODE (TREE_TYPE ($2)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE ($2)) == FUNCTION_TYPE)) - $2 = default_conversion ($2); - $$ = c_sizeof (TREE_TYPE ($2)); } - | SIZEOF '(' typename ')' %prec HYPERUNARY - { $$ = c_sizeof (groktypename ($3)); } - | ALIGNOF unary_expr %prec UNARY - { if (TREE_CODE ($2) == COMPONENT_REF - && TREE_PACKED (TREE_OPERAND ($2, 1))) - error ("`__alignof' applied to a bit-field"); - if (TREE_CODE ($2) == INDIRECT_REF) - { - tree t = TREE_OPERAND ($2, 0); - tree best = t; - int bestalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t))); - while (TREE_CODE (t) == NOP_EXPR - && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == POINTER_TYPE) - { - int thisalign; - t = TREE_OPERAND (t, 0); - thisalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t))); - if (thisalign > bestalign) - best = t, bestalign = thisalign; - } - $$ = c_alignof (TREE_TYPE (TREE_TYPE (best))); - } - else - { - /* ANSI says arrays and fns are converted inside comma. - But we can't convert them in build_compound_expr - because that would break commas in lvalues. - So do the conversion here if operand was a comma. */ - if (TREE_CODE ($2) == COMPOUND_EXPR - && (TREE_CODE (TREE_TYPE ($2)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE ($2)) == FUNCTION_TYPE)) - $2 = default_conversion ($2); - $$ = c_alignof (TREE_TYPE ($2)); - } - } - | ALIGNOF '(' typename ')' %prec HYPERUNARY - { $$ = c_alignof (groktypename ($3)); } - - | .scope new typename %prec '=' - { $$ = build_new ($2, $3, NULL_TREE, $1); } - | .scope new x_typespec '(' nonnull_exprlist ')' - { $$ = build_new ($2, $3, $5, $1); } - | .scope new x_typespec LEFT_RIGHT - { $$ = build_new ($2, $3, NULL_TREE, $1); } - | .scope new typename '=' init %prec '=' - { $$ = build_new ($2, $3, $5, $1); } - | .scope new '(' typename ')' - { $$ = build_new ($2, $4, NULL_TREE, $1); } - /* Unswallow a ':' which is probably meant for ?: expression. */ - | .scope new TYPENAME_COLON - { yyungetc (':', 1); - $$ = build_new ($2, $3, NULL_TREE, $1); } - - | delete cast_expr %prec UNARY - { tree expr = stabilize_reference (convert_from_reference ($2)); - tree type = TREE_TYPE (expr); - - if (integer_zerop (expr)) - $$ = build1 (NOP_EXPR, void_type_node, expr); - else if (TREE_CODE (type) != POINTER_TYPE) - { - error ("non-pointer type to `delete'"); - $$ = error_mark_node; - break; - } - if (TYPE_HAS_DESTRUCTOR (TREE_TYPE (type))) - $$ = build_delete (type, expr, integer_three_node, - LOOKUP_NORMAL|LOOKUP_HAS_IN_CHARGE, $1); - else if (! TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (type))) - $$ = build_x_delete (type, expr, $1); - else - $$ = build_delete (type, expr, integer_three_node, - LOOKUP_NORMAL|LOOKUP_HAS_IN_CHARGE, 0); - } - | delete '[' expr ']' cast_expr %prec UNARY - { - tree maxindex = build_binary_op (MINUS_EXPR, $3, integer_one_node); - tree exp = stabilize_reference (convert_from_reference ($5)); - tree elt_size = c_sizeof (TREE_TYPE (exp)); - - if (yychar == YYEMPTY) - yychar = YYLEX; - - $$ = build_vec_delete (exp, maxindex, elt_size, NULL_TREE, - integer_one_node, integer_two_node); - } - ; - -cast_expr: - unary_expr - | '(' typename ')' expr_no_commas %prec UNARY - { tree type = groktypename ($2); - $$ = build_c_cast (type, $4); } - | '(' typename ')' '{' initlist maybecomma '}' %prec UNARY - { tree type = groktypename ($2); - tree init = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($5)); - if (pedantic) - warning ("ANSI C forbids constructor-expressions"); - /* Indicate that this was a GNU C constructor expression. */ - TREE_HAS_CONSTRUCTOR (init) = 1; - $$ = digest_init (type, init, 0); - if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0) - { - int failure = complete_array_type (type, $$, 1); - if (failure) - abort (); - } - } - ; - -expr_no_commas: - cast_expr - | expr_no_commas '+' expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas '-' expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas '*' expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas '/' expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas '%' expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas LSHIFT expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas RSHIFT expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas ARITHCOMPARE expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas EQCOMPARE expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas MIN_MAX expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas '&' expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas '|' expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas '^' expr_no_commas - { $$ = build_x_binary_op ($2, $1, $3); } - | expr_no_commas ANDAND expr_no_commas - { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $1, $3); } - | expr_no_commas OROR expr_no_commas - { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $1, $3); } - | expr_no_commas '?' xexpr ':' expr_no_commas - { $$ = build_x_conditional_expr ($1, $3, $5); } - | expr_no_commas '=' expr_no_commas - { $$ = build_modify_expr ($1, NOP_EXPR, $3); } - | expr_no_commas ASSIGN expr_no_commas - { register tree rval; - if (rval = build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL, $1, $3, $2)) - $$ = rval; - else - $$ = build_modify_expr ($1, $2, $3); } - - /* Handle general members. */ - | object '*' expr_no_commas %prec UNARY - { $$ = build_m_component_ref ($1, build_x_indirect_ref ($3, "unary *")); } - | object '&' expr_no_commas %prec UNARY - { $$ = build_m_component_ref ($1, build_x_unary_op (ADDR_EXPR, $3)); } - | object unop expr_no_commas %prec UNARY - { $$ = build_m_component_ref ($1, build_x_unary_op ($2, $3)); } - | object '(' typename ')' expr_no_commas %prec UNARY - { tree type = groktypename ($3); - $$ = build_m_component_ref ($1, build_c_cast (type, $5)); } - | object primary_no_id %prec UNARY - { $$ = build_m_component_ref ($1, $2); } - ; - -primary: - IDENTIFIER - { $$ = do_identifier ($1); } - | operator_name - { - tree op = hack_operator ($1); - if (TREE_CODE (op) != IDENTIFIER_NODE) - $$ = op; - else - { - $$ = lookup_name (op); - if ($$ == NULL_TREE) - { - error ("operator %s not defined", operator_name_string (op)); - $$ = error_mark_node; - } - } - } - | CONSTANT - | string - { $$ = combine_strings ($1); } - | '(' expr ')' - { $$ = $2; } - | '(' error ')' - { $$ = error_mark_node; } - | '(' - { if (current_function_decl == 0) - { - error ("braced-group within expression allowed only inside a function"); - YYERROR; - } - keep_next_level (); - $$ = expand_start_stmt_expr (); } - compstmt ')' - { tree rtl_exp; - if (pedantic) - warning ("ANSI C forbids braced-groups within expressions"); - rtl_exp = expand_end_stmt_expr ($2); - $$ = $3; - TREE_USED ($$) = 0; - /* Since the statements have side effects, - consider this volatile. */ - TREE_VOLATILE ($$) = 1; - TREE_TYPE ($$) = TREE_TYPE (rtl_exp); - STMT_BODY ($$) = rtl_exp; } - | primary '(' nonnull_exprlist ')' - { $$ = build_x_function_call ($1, $3, current_class_decl); } - | primary LEFT_RIGHT - { $$ = build_x_function_call ($1, NULL_TREE, current_class_decl); } - | primary '[' expr ']' - { - do_array: - { - tree type = TREE_TYPE ($1); - if (type == error_mark_node || $3 == error_mark_node) - $$ = error_mark_node; - else if (type == NULL_TREE) - { - /* Something has gone very wrong. Assume we - are mistakenly reducing an expression - instead of a declaration. */ - error ("parser may be lost: is there a '{' missing somewhere?"); - $$ = NULL_TREE; - } - else - { - if (TREE_CODE (type) == OFFSET_TYPE) - type = TREE_TYPE (type); - if (TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); - - if (TYPE_LANG_SPECIFIC (type) && - TYPE_OVERLOADS_ARRAY_REF (type)) - $$ = build_opfncall (ARRAY_REF, LOOKUP_NORMAL, $1, $3); - else if (TREE_CODE (type) == POINTER_TYPE - || TREE_CODE (type) == ARRAY_TYPE) - $$ = build_array_ref ($1, $3); - else - error("[] applied to non-pointer type"); - } - } - } - | object identifier_or_opname %prec UNARY - { $$ = build_component_ref ($1, $2, NULL_TREE, 1); } - | object scoped_identifier identifier_or_opname %prec UNARY - { - tree basetype = (TREE_CODE ($2) == SCOPE_REF) ? TREE_OPERAND ($2, 1) : $2; - if (is_aggr_typedef (basetype, 1)) - { - basetype = TREE_TYPE (TREE_TYPE (basetype)); - - if ($1 == error_mark_node) - $$ = error_mark_node; - else if (basetype_or_else (basetype, TREE_TYPE ($1))) - $$ = build_component_ref (build_scoped_ref ($1, $2), $3, NULL_TREE, 1); - else - $$ = error_mark_node; - } - else $$ = error_mark_node; - } - | primary PLUSPLUS - { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $1); } - | primary MINUSMINUS - { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $1); } - - /* C++ extensions */ - | THIS - { if (current_class_decl) - { -#ifdef WARNING_ABOUT_CCD - TREE_USED (current_class_decl) = 1; -#endif - $$ = current_class_decl; - } - else if (current_function_decl - && DECL_STATIC_FUNCTION_P (current_function_decl)) - { - error ("`this' is unavailable for static member functions"); - $$ = error_mark_node; - } - else - { - if (current_function_decl) - error ("invalid use of `this' in non-member function"); - else - error ("invalid use of `this' at top level"); - $$ = error_mark_node; - } - } - | dummy_decl TYPE_QUAL '(' nonnull_exprlist ')' - { - tree type; - tree id = $2; - - /* This is a C cast in C++'s `functional' notation. */ - if ($4 == error_mark_node) - { - $$ = error_mark_node; - break; - } -#if 0 - if ($4 == NULL_TREE) - { - error ("cannot cast null list to type `%s'", - IDENTIFIER_POINTER (TYPE_NAME ($2))); - $$ = error_mark_node; - break; - } -#endif - if (type == error_mark_node) - $$ = error_mark_node; - else - { - if (id == ridpointers[(int) RID_CONST]) - type = build_type_variant (integer_type_node, 1, 0); - else if (id == ridpointers[(int) RID_VOLATILE]) - type = build_type_variant (integer_type_node, 0, 1); - else if (id == ridpointers[(int) RID_FRIEND]) - { - error ("cannot cast expression to `friend' type"); - $$ = error_mark_node; - break; - } - else abort (); - $$ = build_c_cast (type, build_compound_expr ($4)); - } - } - | x_typespec '(' nonnull_exprlist ')' - { $$ = build_functional_cast ($1, $3); } - | x_typespec LEFT_RIGHT - { $$ = build_functional_cast ($1, NULL_TREE); } - | SCOPE IDENTIFIER - { - do_scoped_identifier: - $$ = IDENTIFIER_GLOBAL_VALUE ($2); - if (yychar == YYEMPTY) - yychar = YYLEX; - if (! $$) - { - if (yychar == '(' || yychar == LEFT_RIGHT) - { - $$ = implicitly_declare ($2); - } - else - { - if (IDENTIFIER_GLOBAL_VALUE ($2) != error_mark_node) - error ("undeclared variable `%s' (first use here)", - IDENTIFIER_POINTER ($2)); - $$ = error_mark_node; - /* Prevent repeated error messages. */ - IDENTIFIER_GLOBAL_VALUE ($2) = error_mark_node; - } - } - else if (TREE_CODE ($$) == CONST_DECL) - $$ = DECL_INITIAL ($$); - if (! TREE_USED ($$)) - { - if (TREE_EXTERNAL ($$)) - assemble_external ($$); - TREE_USED ($$) = 1; - } - } - | SCOPE operator_name - { - $2 = hack_operator ($2); - if (TREE_CODE ($2) == IDENTIFIER_NODE) - goto do_scoped_identifier; - do_scoped_operator: - $$ = $2; - } - | scoped_identifier identifier_or_opname %prec HYPERUNARY - { $$ = build_offset_ref ($1, $2); } - | scoped_identifier identifier_or_opname '(' nonnull_exprlist ')' - { $$ = build_member_call ($1, $2, $4); } - | scoped_identifier identifier_or_opname LEFT_RIGHT - { $$ = build_member_call ($1, $2, NULL_TREE); } - - | object identifier_or_opname '(' nonnull_exprlist ')' - { $$ = build_method_call ($1, $2, $4, NULL_TREE, - (LOOKUP_NORMAL|LOOKUP_AGGR)); } - | object identifier_or_opname LEFT_RIGHT - { $$ = build_method_call ($1, $2, NULL_TREE, NULL_TREE, - (LOOKUP_NORMAL|LOOKUP_AGGR)); } - | object scoped_identifier identifier_or_opname '(' nonnull_exprlist ')' - { $$ = build_scoped_method_call ($1, $2, $3, $5); } - | object scoped_identifier identifier_or_opname LEFT_RIGHT - { $$ = build_scoped_method_call ($1, $2, $3, NULL_TREE); } - ; - -primary_no_id: - '(' expr ')' - { $$ = $2; } - | '(' error ')' - { $$ = error_mark_node; } - | '(' - { if (current_function_decl == 0) - { - error ("braced-group within expression allowed only inside a function"); - YYERROR; - } - $$ = expand_start_stmt_expr (); } - compstmt ')' - { if (pedantic) - warning ("ANSI C forbids braced-groups within expressions"); - $$ = expand_end_stmt_expr ($2); } - | primary_no_id '(' nonnull_exprlist ')' - { $$ = build_x_function_call ($1, $3, current_class_decl); } - | primary_no_id LEFT_RIGHT - { $$ = build_x_function_call ($1, NULL_TREE, current_class_decl); } - | primary_no_id '[' expr ']' - { goto do_array; } - | primary_no_id PLUSPLUS - { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $1); } - | primary_no_id MINUSMINUS - { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $1); } - | SCOPE IDENTIFIER - { goto do_scoped_identifier; } - | SCOPE operator_name - { $2 = hack_operator ($2); - if (TREE_CODE ($2) == IDENTIFIER_NODE) - goto do_scoped_identifier; - goto do_scoped_operator; - } - ; - -new: NEW - { $$ = NULL_TREE; } - | NEW '{' nonnull_exprlist '}' - { $$ = $3; } - | NEW DYNAMIC %prec EMPTY - { $$ = void_type_node; } - | NEW DYNAMIC '(' string ')' - { $$ = combine_strings ($4); } - ; - -.scope: - /* empty */ - { $$ = 0; } - | SCOPE - { $$ = 1; } - ; - -delete: DELETE - { $$ = NULL_TREE; } - | SCOPE delete - { if ($2) - error ("extra `::' before `delete' ignored"); - $$ = error_mark_node; - } - ; - -/* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */ -string: - STRING - | string STRING - { $$ = chainon ($1, $2); } - ; - -nodecls: - /* empty */ - { - if (! current_function_parms_stored) - store_parm_decls (); - setup_vtbl_ptr (); - } - ; - -object: primary '.' - { - if ($1 == error_mark_node) - $$ = error_mark_node; - else - { - tree type = TREE_TYPE ($1); - - if (IS_AGGR_TYPE (type) - || (TREE_CODE (type) == REFERENCE_TYPE - && IS_AGGR_TYPE (TREE_TYPE (type)))) - $$ = $1; - else - { - error ("object in '.' expression is not of aggregate type"); - $$ = error_mark_node; - } - } - } - | primary POINTSAT - { - $$ = build_x_arrow ($1); - } - ; - -decl: - typed_declspecs initdecls ';' - { - resume_momentary ($2); - note_got_semicolon ($1); - } - /* Normal case: make this fast. */ - | typed_declspecs declarator ';' - { tree d; - int yes = suspend_momentary (); - d = start_decl ($2, $1, 0, NULL_TREE); - finish_decl (d, NULL_TREE, NULL_TREE); - resume_momentary (yes); - note_got_semicolon ($1); - } - | declmods notype_initdecls ';' - { resume_momentary ($2); } - /* Normal case: make this fast. */ - | declmods declarator ';' - { tree d; - int yes = suspend_momentary (); - d = start_decl ($2, $1, 0, NULL_TREE); - finish_decl (d, NULL_TREE, NULL_TREE); - resume_momentary (yes); - } - | typed_declspecs ';' - { - shadow_tag ($1); - note_got_semicolon ($1); - } - | declmods ';' - { warning ("empty declaration"); } - ; - -/* Any kind of declarator (thus, all declarators allowed - after an explicit typespec). */ - -declarator: - after_type_declarator - | notype_declarator - ; - -/* Declspecs which contain at least one type specifier or typedef name. - (Just `const' or `volatile' is not enough.) - A typedef'd name following these is taken as a name to be declared. */ - -typed_declspecs: - x_typespec - { $$ = list_hash_lookup_or_cons ($1); } - | declmods typespec - { $$ = hash_tree_chain ($2, $1); } - | x_typespec reserved_declspecs - { $$ = hash_tree_chain ($1, $2); } - | declmods typespec reserved_declspecs - { $$ = hash_tree_chain ($2, hash_chainon ($3, $1)); } - ; - -reserved_declspecs: /* empty - { $$ = NULL_TREE; } */ - typespecqual_reserved - { $$ = build_decl_list (NULL_TREE, $1); } - | SCSPEC - { $$ = build_decl_list (NULL_TREE, $1); } - | reserved_declspecs typespecqual_reserved - { $$ = decl_tree_cons (NULL_TREE, $2, $1); } - | reserved_declspecs SCSPEC - { $$ = decl_tree_cons (NULL_TREE, $2, $1); } - ; - -/* List of just storage classes and type modifiers. - A declaration can start with just this, but then it cannot be used - to redeclare a typedef-name. */ - -declmods: - dummy_decl TYPE_QUAL - { $$ = IDENTIFIER_AS_LIST ($2); } - | dummy_decl SCSPEC - { $$ = IDENTIFIER_AS_LIST ($2); } - | declmods TYPE_QUAL - { $$ = hash_tree_chain ($2, $1); } - | declmods SCSPEC - { $$ = hash_tree_chain ($2, $1); } - ; - - -/* Used instead of declspecs where storage classes are not allowed - (that is, for typenames and structure components). - - C++ can takes storage classes for structure components. - Don't accept a typedef-name if anything but a modifier precedes it. */ - -typed_typespecs: - x_typespec %prec EMPTY - { $$ = build_decl_list_1 ($1); } - | nonempty_type_quals typespec - { $$ = decl_tree_cons (NULL_TREE, $2, $1); } - | x_typespec reserved_typespecquals - { $$ = decl_tree_cons (NULL_TREE, $1, $2); } - | nonempty_type_quals typespec reserved_typespecquals - { $$ = decl_tree_cons (NULL_TREE, $2, hash_chainon ($3, $1)); } - ; - -reserved_typespecquals: - typespecqual_reserved - { $$ = build_decl_list_1 ($1); } - | reserved_typespecquals typespecqual_reserved - { $$ = decl_tree_cons (NULL_TREE, $2, $1); } - ; - -/* A typespec (but not a type qualifier). - Once we have seen one of these in a declaration, - if a typedef name appears then it is being redeclared. */ - -typespec: TYPESPEC - | structsp - | TYPENAME - | TYPEOF '(' expr ')' - { $$ = TREE_TYPE ($3); - if (pedantic) - warning ("ANSI C forbids `typeof'"); } - | TYPEOF '(' typename ')' - { $$ = groktypename ($3); - if (pedantic) - warning ("ANSI C forbids `typeof'"); } - ; - -/* A typespec that is a reserved word, or a type qualifier. */ - -typespecqual_reserved: TYPESPEC - | TYPE_QUAL - | structsp - ; - -x_typespec: - dummy_decl TYPESPEC - { $$ = $2; } - | dummy_decl structsp - { $$ = $2; } - | dummy_decl TYPENAME - { $$ = $2; } - | dummy_decl TYPEOF '(' expr ')' - { $$ = TREE_TYPE ($4); - if (pedantic) - warning ("ANSI C forbids `typeof'"); } - | dummy_decl TYPEOF '(' typename ')' - { $$ = groktypename ($4); - if (pedantic) - warning ("ANSI C forbids `typeof'"); } - ; - -initdecls: - initdcl0 - | initdecls ',' initdcl - ; - -notype_initdecls: - notype_initdcl0 - | notype_initdecls ',' initdcl - ; - -maybeasm: - /* empty */ - { $$ = NULL_TREE; } - | ASM '(' string ')' - { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); - $$ = $3; - if (pedantic) - warning ("ANSI C forbids use of `asm' keyword"); - } - ; - -initdcl0: - declarator maybe_raises maybeasm maybe_attribute '=' - { current_declspecs = $0; - $5 = suspend_momentary (); - $$ = start_decl ($1, current_declspecs, 1, $2); } - init -/* Note how the declaration of the variable is in effect while its init is parsed! */ - { finish_decl ($6, $7, $3); - $$ = $5; } - | declarator maybe_raises maybeasm maybe_attribute - { tree d; - current_declspecs = $0; - $$ = suspend_momentary (); - d = start_decl ($1, current_declspecs, 0, $2); - finish_decl (d, NULL_TREE, $3); } - ; - -initdcl: - declarator maybe_raises maybeasm maybe_attribute '=' - { $$ = start_decl ($1, current_declspecs, 1, $2); } - init -/* Note how the declaration of the variable is in effect while its init is parsed! */ - { finish_decl ($6, $7, $3); } - | declarator maybe_raises maybeasm maybe_attribute - { tree d = start_decl ($1, current_declspecs, 0, $2); - finish_decl (d, NULL_TREE, $3); } - ; - -notype_initdcl0: - notype_declarator maybe_raises maybeasm maybe_attribute '=' - { current_declspecs = $0; - $5 = suspend_momentary (); - $$ = start_decl ($1, current_declspecs, 1, $2); } - init -/* Note how the declaration of the variable is in effect while its init is parsed! */ - { finish_decl ($6, $7, $3); - $$ = $5; } - | notype_declarator maybe_raises maybeasm maybe_attribute - { tree d; - current_declspecs = $0; - $$ = suspend_momentary (); - d = start_decl ($1, current_declspecs, 0, $2); - finish_decl (d, NULL_TREE, $3); } - ; - -/* the * rules are dummies to accept the Apollo extended syntax - so that the header files compile. */ -maybe_attribute: - /* empty */ - { $$ = NULL_TREE; } - | ATTRIBUTE '(' '(' attribute_list ')' ')' - { $$ = $4; } - ; - -attribute_list - : attrib - | attribute_list ',' attrib - ; - -attrib - : IDENTIFIER - { warning ("`%s' attribute directive ignored", - IDENTIFIER_POINTER ($1)); - $$ = $1; } - | IDENTIFIER '(' CONSTANT ')' - { /* if not "aligned(1)", then issue warning */ - if (strcmp (IDENTIFIER_POINTER ($1), "aligned") != 0 - || TREE_CODE ($3) != INTEGER_CST - || TREE_INT_CST_LOW ($3) != 1) - warning ("`%s' attribute directive ignored", - IDENTIFIER_POINTER ($1)); - $$ = $1; } - | IDENTIFIER '(' identifiers ')' - { warning ("`%s' attribute directive ignored", - IDENTIFIER_POINTER ($1)); - $$ = $1; } - ; - -identifiers: - IDENTIFIER - { } - | identifiers ',' IDENTIFIER - { } - ; - -init: - expr_no_commas %prec '=' - | '{' '}' - { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE); - TREE_HAS_CONSTRUCTOR ($$) = 1; - if (pedantic) - warning ("ANSI C forbids empty initializer braces"); } - | '{' initlist '}' - { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); - TREE_HAS_CONSTRUCTOR ($$) = 1; } - | '{' initlist ',' '}' - { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); - TREE_HAS_CONSTRUCTOR ($$) = 1; } - | error - { $$ = NULL_TREE; } - ; - -/* This chain is built in reverse order, - and put in forward order where initlist is used. */ -initlist: - init - { $$ = build_tree_list (NULL_TREE, $1); } - | initlist ',' init - { $$ = tree_cons (NULL_TREE, $3, $1); } - ; - -structsp: - ENUM identifier '{' - { $3 = suspend_momentary (); - $$ = start_enum ($2); } - enumlist maybecomma_warn '}' - { $$ = finish_enum ($4, $5); - resume_momentary ($3); - check_for_missing_semicolon ($4); } - | ENUM identifier '{' '}' - { $$ = finish_enum (start_enum ($2), NULL_TREE); - check_for_missing_semicolon ($$); } - | ENUM '{' - { $2 = suspend_momentary (); - $$ = start_enum (make_anon_name ()); } - enumlist maybecomma_warn '}' - { $$ = finish_enum ($3, $4); - resume_momentary ($1); - check_for_missing_semicolon ($3); } - | ENUM '{' '}' - { $$ = finish_enum (start_enum (make_anon_name()), NULL_TREE); - check_for_missing_semicolon ($$); } - | ENUM identifier - { $$ = xref_tag (enum_type_node, $2, NULL_TREE); } - - /* C++ extensions, merged with C to avoid shift/reduce conflicts */ - | class_head LC opt.component_decl_list '}' - { - if (TREE_CODE ($1) == ENUMERAL_TYPE) - $$ = $1; - else if (CLASSTYPE_DECLARED_EXCEPTION ($1)) - $$ = finish_exception ($1, $3); - else - $$ = finish_struct ($1, $3, 0, 0); - - if ($2 & 1) - resume_temporary_allocation (); - if ($2 & 2) - resume_momentary (1); - check_for_missing_semicolon ($$); - } - | class_head LC opt.component_decl_list '}' ';' - { if (TREE_CODE ($1) == ENUMERAL_TYPE) - $$ = $1; - else if (CLASSTYPE_DECLARED_EXCEPTION ($1)) - warning ("empty exception declaration\n"); - else - $$ = finish_struct ($1, $3, 1, 1); - if ($2 & 1) - resume_temporary_allocation (); - if ($2 & 2) - resume_momentary (1); - note_got_semicolon ($$); - yyungetc (';', 0); } - | class_head %prec EMPTY - { $$ = $1; } - ; - -maybecomma: - /* empty */ - | ',' - ; - -maybecomma_warn: - /* empty */ - | ',' - { if (pedantic) warning ("comma at end of enumerator list"); } - ; - -aggr: AGGR - { $$ = $1; } - | DYNAMIC AGGR - { $$ = build_tree_list (NULL_TREE, $2); } - | DYNAMIC '(' string ')' AGGR - { $$ = build_tree_list ($3, $5); } - | aggr SCSPEC - { error ("storage class specifier `%s' not allow after struct or class", IDENTIFIER_POINTER ($2)); - } - | aggr TYPESPEC - { error ("type specifier `%s' not allow after struct or class", IDENTIFIER_POINTER ($2)); - } - | aggr TYPE_QUAL - { error ("type qualifier `%s' not allow after struct or class", IDENTIFIER_POINTER ($2)); - } - | aggr AGGR - { error ("no body nor ';' separates two class, struct or union declarations"); - } - -class_head: - aggr %prec EMPTY - { $$ = xref_tag ($1, make_anon_name (), NULL_TREE); } - | aggr identifier %prec EMPTY - { $$ = xref_tag ($1, $2, NULL_TREE); } - | aggr IDENTIFIER ':' base_class_list %prec EMPTY - { $$ = xref_tag ($1, $2, $4); } - | aggr TYPENAME_COLON %prec EMPTY - { yyungetc (':', 1); - $$ = xref_tag ($1, $2, NULL_TREE); } - | aggr TYPENAME_COLON base_class_list %prec EMPTY - { $$ = xref_tag ($1, $2, $3); } - ; - -base_class_list: - identifier - { if (! is_aggr_typedef ($1, 1)) - $$ = NULL_TREE; - else $$ = build_tree_list ((tree)visibility_default, $1); } - | base_class_visibility_list identifier - { if (! is_aggr_typedef ($2, 1)) - $$ = NULL_TREE; - else $$ = build_tree_list ($1, $2); } - | base_class_list ',' identifier - { if (! is_aggr_typedef ($3, 1)) - $$ = NULL_TREE; - else $$ = chainon ($1, build_tree_list ((tree)visibility_default, $3)); } - | base_class_list ',' base_class_visibility_list identifier - { if (! is_aggr_typedef ($4, 1)) - $$ = NULL_TREE; - else $$ = chainon ($1, build_tree_list ($3, $4)); } - ; - -base_class_visibility_list: - PUBLIC - { $$ = (tree)visibility_public; } - | PRIVATE - { $$ = (tree)visibility_private; } - | SCSPEC - { if ($1 != ridpointers[(int)RID_VIRTUAL]) - sorry ("non-virtual visibility"); - $$ = (tree)visibility_default_virtual; } - | base_class_visibility_list PUBLIC - { if ($1 == (tree)visibility_private) - error ("base class cannot be public and private"); - else if ($1 == (tree)visibility_default_virtual) - $$ = (tree)visibility_public_virtual; } - | base_class_visibility_list PRIVATE - { if ($1 == (tree)visibility_public) - error ("base class cannot be private and public"); - else if ($1 == (tree)visibility_default_virtual) - $$ = (tree)visibility_private_virtual; } - | base_class_visibility_list SCSPEC - { if ($2 != ridpointers[(int)RID_VIRTUAL]) - sorry ("non-virtual visibility"); - if ($1 == (tree)visibility_public) - $$ = (tree)visibility_public_virtual; - else if ($1 == (tree)visibility_private) - $$ = (tree)visibility_private_virtual; } - ; - -LC: '{' - { int temp = allocation_temporary_p (); - int momentary = suspend_momentary (); - if (temp) - end_temporary_allocation (); - $$ = (momentary << 1) | temp; - if (! IS_AGGR_TYPE ($0)) - { - $0 = make_lang_type (RECORD_TYPE); - TYPE_NAME ($0) = get_identifier ("erroneous type"); - } - pushclass ($0, 0); } - -opt.component_decl_list: - /* empty */ - { $$ = NULL_TREE; } - | component_decl_list - { $$ = build_tree_list ((tree)visibility_default, $1); } - | opt.component_decl_list PUBLIC ':' component_decl_list - { $$ = chainon ($1, build_tree_list ((tree)visibility_public, $4)); } - | opt.component_decl_list PRIVATE ':' component_decl_list - { $$ = chainon ($1, build_tree_list ((tree)visibility_private, $4)); } - | opt.component_decl_list PROTECTED ':' component_decl_list - { $$ = chainon ($1, build_tree_list ((tree)visibility_protected, $4)); } - | opt.component_decl_list PUBLIC ':' - | opt.component_decl_list PRIVATE ':' - | opt.component_decl_list PROTECTED ':' - ; - -component_decl_list: - component_decl - { if ($1 == void_type_node) $$ = NULL_TREE; } - | component_decl_list component_decl - { if ($2 != NULL_TREE && $2 != void_type_node) - $$ = chainon ($1, $2); } - | component_decl_list ';' - { if (pedantic) - warning ("extra semicolon in struct or union specified"); } - ; - -component_decl: - typed_declspecs components ';' - { - do_components: - if ($2 == void_type_node) - /* We just got some friends. - They have been recorded elsewhere. */ - $$ = NULL_TREE; - else if ($2 == NULL_TREE) - { - tree t = groktypename (build_decl_list ($1, NULL_TREE)); - if (t == NULL_TREE) - { - error ("error in component specification"); - $$ = NULL_TREE; - } - else if (TREE_CODE (t) == UNION_TYPE) - { - /* handle anonymous unions */ - if (CLASSTYPE_METHOD_VEC (t)) - sorry ("methods in anonymous unions"); - $$ = build_lang_field_decl (FIELD_DECL, NULL_TREE, t); - DECL_ANON_UNION_ELEM ($$) = 1; - } - else if (TREE_CODE (t) == ENUMERAL_TYPE) - $$ = grok_enum_decls (t, NULL_TREE); - else if (TREE_CODE (t) == RECORD_TYPE) - { - if (TYPE_LANG_SPECIFIC (t) - && CLASSTYPE_DECLARED_EXCEPTION (t)) - shadow_tag ($1); - $$ = NULL_TREE; - } - else if (t != void_type_node) - { - error ("empty component declaration"); - $$ = NULL_TREE; - } - else $$ = NULL_TREE; - } - else - { - tree t = TREE_TYPE ($2); - if (TREE_CODE (t) == ENUMERAL_TYPE && TREE_NONLOCAL (t)) - $$ = grok_enum_decls (t, $2); - else - $$ = $2; - } - end_exception_decls (); - } - | typed_declspecs '(' parmlist ')' ';' - { $$ = groktypefield ($1, $3); } - | typed_declspecs '(' parmlist ')' '}' - { error ("missing ';' before right brace"); - yyungetc ('}', 0); - $$ = groktypefield ($1, $3); } - | typed_declspecs LEFT_RIGHT ';' - { $$ = groktypefield ($1, empty_parms ()); } - | typed_declspecs LEFT_RIGHT '}' - { error ("missing ';' before right brace"); - yyungetc ('}', 0); - $$ = groktypefield ($1, empty_parms ()); } - | declmods components ';' - { goto do_components; } - /* Normal case: make this fast. */ - | declmods declarator ';' - { $$ = grokfield ($2, $1, 0, 0, 0, 0); } - | declmods components '}' - { error ("missing ';' before right brace"); - yyungetc ('}', 0); - goto do_components; } - | declmods '(' parmlist ')' ';' - { $$ = groktypefield ($1, $3); } - | declmods '(' parmlist ')' '}' - { error ("missing ';' before right brace"); - yyungetc ('}', 0); - $$ = groktypefield ($1, $3); } - | declmods LEFT_RIGHT ';' - { $$ = groktypefield ($1, empty_parms ()); } - | declmods LEFT_RIGHT '}' - { error ("missing ';' before right brace"); - yyungetc ('}', 0); - $$ = groktypefield ($1, empty_parms ()); } - | ':' expr_no_commas ';' - { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); } - | ':' expr_no_commas '}' - { error ("missing ';' before right brace"); - yyungetc ('}', 0); - $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); } - | error - { $$ = NULL_TREE; } - - /* C++: handle constructors, destructors and inline functions */ - /* note that INLINE is like a TYPESPEC */ - | fn.def2 ':' /* base_init compstmt */ - { $$ = finish_method ($1); } - | fn.def2 '{' /* nodecls compstmt */ - { $$ = finish_method ($1); } - | dummy_decl notype_declarator maybe_raises ';' - { $$ = grokfield ($2, NULL_TREE, $3, NULL_TREE, NULL_TREE); } - | dummy_decl notype_declarator maybe_raises '}' - { error ("missing ';' before right brace"); - yyungetc ('}', 0); - $$ = grokfield ($2, NULL_TREE, $3, NULL_TREE, NULL_TREE); } - ; - -components: - /* empty: possibly anonymous */ - { $$ = NULL_TREE; } - | component_declarator0 - | components ',' component_declarator - { - /* In this context, void_type_node encodes - friends. They have been recorded elsewhere. */ - if ($1 == void_type_node) - $$ = $3; - else - $$ = chainon ($1, $3); - } - ; - -component_declarator0: - declarator maybe_raises maybeasm opt.init - { current_declspecs = $0; - $$ = grokfield ($1, current_declspecs, $2, $4, $3); } - | IDENTIFIER ':' expr_no_commas - { current_declspecs = $0; - $$ = grokbitfield ($1, current_declspecs, $3); } - | TYPENAME_COLON expr_no_commas - { current_declspecs = $0; - $$ = grokbitfield ($1, current_declspecs, $2); } - | ':' expr_no_commas - { current_declspecs = $0; - $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); } - ; - -component_declarator: - declarator maybe_raises maybeasm opt.init - { $$ = grokfield ($1, current_declspecs, $2, $4, $3); } - | IDENTIFIER ':' expr_no_commas - { $$ = grokbitfield ($1, current_declspecs, $3); } - | TYPENAME_COLON expr_no_commas - { $$ = grokbitfield ($1, current_declspecs, $2); } - | ':' expr_no_commas - { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); } - ; - -/* We chain the enumerators in reverse order. - Because of the way enums are built, the order is - insignificant. Take advantage of this fact. */ - -enumlist: - enumerator - | enumlist ',' enumerator - { TREE_CHAIN ($3) = $1; $$ = $3; } - ; - -enumerator: - identifier - { $$ = build_enumerator ($1, NULL_TREE); } - | identifier '=' expr_no_commas - { $$ = build_enumerator ($1, $3); } - ; - -typename: - typed_typespecs absdcl - { $$ = build_decl_list ($1, $2); } - | nonempty_type_quals absdcl - { $$ = build_decl_list ($1, $2); } - ; - -absdcl: /* an abstract declarator */ - /* empty */ %prec EMPTY - { $$ = NULL_TREE; } - | absdcl1 %prec EMPTY - ; - -nonempty_type_quals: - dummy_decl TYPE_QUAL - { $$ = IDENTIFIER_AS_LIST ($2); } - | nonempty_type_quals TYPE_QUAL - { $$ = decl_tree_cons (NULL_TREE, $2, $1); } - ; - -type_quals: - /* empty */ - { $$ = NULL_TREE; } - | type_quals TYPE_QUAL - { $$ = decl_tree_cons (NULL_TREE, $2, $1); } - ; - -/* These rules must follow the rules for function declarations - and component declarations. That way, longer rules are prefered. */ - -/* An expression which will not live on the momentary obstack. */ -nonmomentary_expr: - { $$ = suspend_momentary (); } expr - { resume_momentary ($1); $$ = $2; } - -/* A declarator that is allowed only after an explicit typespec. */ -/* may all be followed by prec '.' */ -after_type_declarator: - after_type_declarator '(' nonnull_exprlist ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } - | after_type_declarator '(' parmlist ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } - | after_type_declarator LEFT_RIGHT type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, empty_parms (), $3); } - | after_type_declarator '(' error ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, NULL_TREE, NULL_TREE); } - | after_type_declarator '[' nonmomentary_expr ']' - { $$ = build_parse_node (ARRAY_REF, $1, $3); } - | after_type_declarator '[' ']' - { $$ = build_parse_node (ARRAY_REF, $1, NULL_TREE); } - | '(' dummy_decl after_type_declarator_no_typename ')' - { $$ = $3; } - | '(' '*' type_quals after_type_declarator ')' - { $$ = make_pointer_declarator ($3, $4); } - | PAREN_STAR_PAREN - { $$ = $1; - see_typename (); } - | PAREN_X_SCOPE_STAR_PAREN - { $$ = $1; - see_typename (); } - | PAREN_X_SCOPE_REF_PAREN - { $$ = $1; - see_typename (); } - | '(' '&' type_quals after_type_declarator ')' - { $$ = make_reference_declarator ($3, $4); } - | '*' type_quals after_type_declarator %prec UNARY - { $$ = make_pointer_declarator ($2, $3); } - | '&' type_quals after_type_declarator %prec UNARY - { $$ = make_reference_declarator ($2, $3); } - | TYPENAME - ; - -after_type_declarator_no_typename: - after_type_declarator_no_typename '(' nonnull_exprlist ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } - | after_type_declarator_no_typename '(' parmlist ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } - | after_type_declarator_no_typename LEFT_RIGHT type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, empty_parms (), $3); } - | after_type_declarator_no_typename '(' error ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, NULL_TREE, NULL_TREE); } - | after_type_declarator_no_typename '[' nonmomentary_expr ']' - { $$ = build_parse_node (ARRAY_REF, $1, $3); } - | after_type_declarator_no_typename '[' ']' - { $$ = build_parse_node (ARRAY_REF, $1, NULL_TREE); } - | '(' dummy_decl after_type_declarator_no_typename ')' - { $$ = $3; } - | PAREN_STAR_PAREN - { $$ = $1; - see_typename (); } - | PAREN_X_SCOPE_STAR_PAREN - { $$ = $1; - see_typename (); } - | PAREN_X_SCOPE_REF_PAREN - { $$ = $1; - see_typename (); } - | '*' type_quals after_type_declarator %prec UNARY - { $$ = make_pointer_declarator ($2, $3); } - | '&' type_quals after_type_declarator %prec UNARY - { $$ = make_reference_declarator ($2, $3); } - ; - -/* A declarator allowed whether or not there has been - an explicit typespec. These cannot redeclare a typedef-name. */ - -notype_declarator: - notype_declarator '(' nonnull_exprlist ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } - | notype_declarator '(' parmlist ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } - | notype_declarator LEFT_RIGHT type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, empty_parms (), $3); } - | notype_declarator '(' error ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, NULL_TREE, NULL_TREE); } - | '(' notype_declarator ')' - { $$ = $2; } - | '*' type_quals notype_declarator %prec UNARY - { $$ = make_pointer_declarator ($2, $3); } - | '&' type_quals notype_declarator %prec UNARY - { $$ = make_reference_declarator ($2, $3); } - | notype_declarator '[' nonmomentary_expr ']' - { $$ = build_parse_node (ARRAY_REF, $1, $3); } - | notype_declarator '[' ']' - { $$ = build_parse_node (ARRAY_REF, $1, NULL_TREE); } - | IDENTIFIER - { see_typename (); } - - /* C++ extensions. */ - | operator_name - { see_typename (); } - - | '~' TYPENAME - { see_typename (); - $$ = build_parse_node (BIT_NOT_EXPR, $2); } - | '~' IDENTIFIER - { see_typename (); - $$ = build_parse_node (BIT_NOT_EXPR, $2); } - | LEFT_RIGHT identifier - { - see_typename (); - $$ = build_parse_node (WRAPPER_EXPR, $2); - } - | LEFT_RIGHT '?' identifier - { - see_typename (); - $$ = build_parse_node (WRAPPER_EXPR, - build_parse_node (COND_EXPR, $3, NULL_TREE, NULL_TREE)); - } - | '~' LEFT_RIGHT identifier - { see_typename (); - $$ = build_parse_node (ANTI_WRAPPER_EXPR, $3); } - | TYPENAME_SCOPE type_quals notype_declarator %prec '(' - { see_typename (); - $$ = build_parse_node (SCOPE_REF, $1, $3); } - | TYPENAME_SCOPE TYPENAME %prec '(' - { $$ = build_parse_node (SCOPE_REF, $1, $2); } - | TYPENAME_SCOPE see_typename TYPENAME '(' nonnull_exprlist ')' type_quals %prec '.' - { $$ = build_parse_node (SCOPE_REF, $1, - build_parse_node (CALL_EXPR, $3, $5, $7)); } - | TYPENAME_SCOPE see_typename TYPENAME '(' parmlist ')' type_quals %prec '.' - { $$ = build_parse_node (SCOPE_REF, $1, - build_parse_node (CALL_EXPR, $3, $5, $7)); } - | TYPENAME_SCOPE see_typename TYPENAME LEFT_RIGHT type_quals %prec '.' - { $$ = build_parse_node (SCOPE_REF, $1, - build_parse_node (CALL_EXPR, $3, empty_parms (), $5)); } - | TYPENAME_SCOPE see_typename TYPENAME '(' error ')' type_quals %prec '.' - { $$ = build_parse_node (SCOPE_REF, $1, build_parse_node (CALL_EXPR, $3, NULL_TREE, NULL_TREE)); } - | SCOPE see_typename notype_declarator - { $$ = build_parse_node (SCOPE_REF, NULL_TREE, $3); } - ; - -scoped_identifier: - TYPENAME_SCOPE - | IDENTIFIER SCOPE - | scoped_identifier TYPENAME_SCOPE - { $$ = build_parse_node (SCOPE_REF, $1, $2); } - ; - -absdcl1: /* a nonempty abstract declarator */ - '(' absdcl1 ')' - { see_typename (); - $$ = $2; } - /* `(typedef)1' is `int'. */ - | '*' type_quals absdcl1 %prec EMPTY - { $$ = make_pointer_declarator ($2, $3); } - | '*' type_quals %prec EMPTY - { $$ = make_pointer_declarator ($2, NULL_TREE); } - | PAREN_STAR_PAREN - { $$ = $1; - see_typename (); } - | PAREN_X_SCOPE_STAR_PAREN - { $$ = $1; - see_typename (); } - | PAREN_X_SCOPE_REF_PAREN - { $$ = $1; - see_typename (); } - | '&' type_quals absdcl1 %prec EMPTY - { $$ = make_reference_declarator ($2, $3); } - | '&' type_quals %prec EMPTY - { $$ = make_reference_declarator ($2, NULL_TREE); } - | absdcl1 '(' parmlist ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } - | absdcl1 LEFT_RIGHT type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, $1, empty_parms (), $3); } - | absdcl1 '[' nonmomentary_expr ']' %prec '.' - { $$ = build_parse_node (ARRAY_REF, $1, $3); } - | absdcl1 '[' ']' %prec '.' - { $$ = build_parse_node (ARRAY_REF, $1, NULL_TREE); } - | '(' parmlist ')' type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, NULL_TREE, $2, $4); } - | LEFT_RIGHT type_quals %prec '.' - { $$ = build_parse_node (CALL_EXPR, NULL_TREE, empty_parms (), $2); } - | '[' nonmomentary_expr ']' %prec '.' - { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); } - | '[' ']' %prec '.' - { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); } - | TYPENAME_SCOPE type_quals absdcl1 %prec EMPTY - { $$ = build_parse_node (SCOPE_REF, $1, $3); } - | IDENTIFIER SCOPE type_quals absdcl1 %prec EMPTY - { $$ = build_parse_node (SCOPE_REF, $1, $4); } - | TYPENAME_SCOPE type_quals %prec EMPTY - { $$ = build_parse_node (SCOPE_REF, $1, 0); } - | IDENTIFIER SCOPE type_quals %prec EMPTY - { $$ = build_parse_node (SCOPE_REF, $1, 0); } - ; - -/* at least one statement, the first of which parses without error. */ -/* stmts is used only after decls, so an invalid first statement - is actually regarded as an invalid decl and part of the decls. */ - -stmts: - stmt - | stmts stmt - | stmts errstmt - ; - -errstmt: error ';' - ; - -/* build the LET_STMT node before parsing its contents, - so that any LET_STMTs within the context can have their display pointers - set up to point at this one. */ - -.pushlevel: /* empty */ - { - pushlevel (0); - clear_last_expr (); - push_momentary (); - expand_start_bindings (0); - stmt_decl_msg = 0; - } - ; - -/* This is the body of a function definition. - It causes syntax errors to ignore to the next openbrace. */ -compstmt_or_error: - compstmt - {} - | error compstmt - ; - -compstmt: '{' '}' - { $$ = 0; } - | '{' .pushlevel stmts '}' - { tree decls; - - pop_implicit_try_blocks (NULL_TREE); - decls = getdecls (); - expand_end_bindings (decls, decls != 0, 1); - $$ = poplevel (decls != 0, 1, 0); - pop_momentary (); } - | '{' .pushlevel error '}' - { pop_implicit_try_blocks (NULL_TREE); - expand_end_bindings (getdecls (), 0, 1); - $$ = poplevel (0, 0, 0); - pop_momentary (); } - ; - -simple_if: - IF '(' expr ')' - { emit_line_note (input_filename, lineno); - expand_start_cond (truthvalue_conversion ($3), 0); - stmt_decl_msg = "if"; } - stmt - { stmt_decl_msg = 0; } - ; - -stmt: - compstmt - { finish_stmt (); } - | decl - { if (stmt_decl_msg) - error ("declaration after %s invalid", stmt_decl_msg); - stmt_decl_msg = 0; - finish_stmt (); } - | expr ';' - { emit_line_note (input_filename, lineno); - /* Do default conversion if safe and possibly important, - in case within ({...}). */ - if ((TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE - && lvalue_p ($1)) - || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE) - $1 = default_conversion ($1); - cplus_expand_expr_stmt ($1); - clear_momentary (); - finish_stmt (); } - | simple_if ELSE - { expand_start_else (); - stmt_decl_msg = "else"; } - stmt - { expand_end_else (); - stmt_decl_msg = 0; - finish_stmt (); } - | simple_if %prec IF - { expand_end_cond (); - stmt_decl_msg = 0; - finish_stmt (); } - | WHILE - { emit_nop (); - emit_line_note (input_filename, lineno); - expand_start_loop (1); } - '(' expr ')' - { expand_exit_loop_if_false (truthvalue_conversion ($4)); - stmt_decl_msg = "while"; } - stmt - { - expand_end_loop (); - stmt_decl_msg = 0; - finish_stmt (); } - | DO - { emit_nop (); - emit_line_note (input_filename, lineno); - expand_start_loop_continue_elsewhere (1); - stmt_decl_msg = "do"; } - stmt WHILE - { stmt_decl_msg = 0; - expand_loop_continue_here (); } - '(' expr ')' ';' - { emit_line_note (input_filename, lineno); - expand_exit_loop_if_false (truthvalue_conversion ($7)); - expand_end_loop (); - clear_momentary (); - finish_stmt (); } - | forhead.1 - { emit_nop (); - emit_line_note (input_filename, lineno); - if ($1) cplus_expand_expr_stmt ($1); - expand_start_loop_continue_elsewhere (1); } - xexpr ';' - { emit_line_note (input_filename, lineno); - if ($3) expand_exit_loop_if_false (truthvalue_conversion ($3)); } - xexpr ')' - /* Don't let the tree nodes for $6 be discarded - by clear_momentary during the parsing of the next stmt. */ - { push_momentary (); - stmt_decl_msg = "for"; } - stmt - { emit_line_note (input_filename, lineno); - expand_loop_continue_here (); - if ($6) cplus_expand_expr_stmt ($6); - pop_momentary (); - expand_end_loop (); - stmt_decl_msg = 0; - finish_stmt (); } - | forhead.2 - { emit_nop (); - emit_line_note (input_filename, lineno); - expand_start_loop_continue_elsewhere (1); } - xexpr ';' - { emit_line_note (input_filename, lineno); - if ($3) expand_exit_loop_if_false (truthvalue_conversion ($3)); } - xexpr ')' - /* Don't let the tree nodes for $6 be discarded - by clear_momentary during the parsing of the next stmt. */ - { push_momentary (); - stmt_decl_msg = "for"; - $7 = lineno; } - stmt - { emit_line_note (input_filename, $7); - expand_loop_continue_here (); - if ($6) cplus_expand_expr_stmt ($6); - pop_momentary (); - expand_end_loop (); - pop_implicit_try_blocks (NULL_TREE); - if ($1) - { - register keep = $1 > 0; - if (keep) expand_end_bindings (0, keep, 1); - poplevel (keep, 1, 0); - pop_momentary (); - } - stmt_decl_msg = 0; - finish_stmt (); - } - | SWITCH '(' expr ')' - { emit_line_note (input_filename, lineno); - c_expand_start_case ($3); - /* Don't let the tree nodes for $3 be discarded by - clear_momentary during the parsing of the next stmt. */ - push_momentary (); - stmt_decl_msg = "switch"; } - stmt - { expand_end_case ($3); - pop_momentary (); - stmt_decl_msg = 0; - finish_stmt (); } - | CASE expr ':' - { register tree value = $2; - register tree label - = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); - - /* build_c_cast puts on a NOP_EXPR to make a non-lvalue. - Strip such NOP_EXPRs. */ - if (TREE_CODE (value) == NOP_EXPR - && TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0))) - value = TREE_OPERAND (value, 0); - - if (TREE_READONLY_DECL_P (value)) - { - value = decl_constant_value (value); - /* build_c_cast puts on a NOP_EXPR to make a non-lvalue. - Strip such NOP_EXPRs. */ - if (TREE_CODE (value) == NOP_EXPR - && TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0))) - value = TREE_OPERAND (value, 0); - } - value = fold (value); - - if (TREE_CODE (value) != INTEGER_CST - && value != error_mark_node) - { - error ("case label does not reduce to an integer constant"); - value = error_mark_node; - } - else - /* Promote char or short to int. */ - value = default_conversion (value); - if (value != error_mark_node) - { - int success = pushcase (value, label); - if (success == 1) - error ("case label not within a switch statement"); - else if (success == 2) - error ("duplicate case value"); - else if (success == 3) - warning ("case value out of range"); - } - define_case_label (label); - } - stmt - | CASE expr RANGE expr ':' - { register tree value1 = $2; - register tree value2 = $4; - register tree label - = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); - - if (pedantic) - { - error ("ANSI C does not allow range expressions in switch statement"); - value1 = error_mark_node; - value2 = error_mark_node; - break; - } - /* build_c_cast puts on a NOP_EXPR to make a non-lvalue. - Strip such NOP_EXPRs. */ - if (TREE_CODE (value1) == NOP_EXPR - && TREE_TYPE (value1) == TREE_TYPE (TREE_OPERAND (value1, 0))) - value1 = TREE_OPERAND (value1, 0); - - if (TREE_READONLY_DECL_P (value1)) - { - value1 = decl_constant_value (value1); - /* build_c_cast puts on a NOP_EXPR to make a non-lvalue. - Strip such NOP_EXPRs. */ - if (TREE_CODE (value1) == NOP_EXPR - && TREE_TYPE (value1) == TREE_TYPE (TREE_OPERAND (value1, 0))) - value1 = TREE_OPERAND (value1, 0); - } - value1 = fold (value1); - - /* build_c_cast puts on a NOP_EXPR to make a non-lvalue. - Strip such NOP_EXPRs. */ - if (TREE_CODE (value2) == NOP_EXPR - && TREE_TYPE (value2) == TREE_TYPE (TREE_OPERAND (value2, 0))) - value2 = TREE_OPERAND (value2, 0); - - if (TREE_READONLY_DECL_P (value2)) - { - value2 = decl_constant_value (value2); - /* build_c_cast puts on a NOP_EXPR to make a non-lvalue. - Strip such NOP_EXPRs. */ - if (TREE_CODE (value2) == NOP_EXPR - && TREE_TYPE (value2) == TREE_TYPE (TREE_OPERAND (value2, 0))) - value2 = TREE_OPERAND (value2, 0); - } - value2 = fold (value2); - - - if (TREE_CODE (value1) != INTEGER_CST - && value1 != error_mark_node) - { - error ("case label does not reduce to an integer constant"); - value1 = error_mark_node; - } - if (TREE_CODE (value2) != INTEGER_CST - && value2 != error_mark_node) - { - error ("case label does not reduce to an integer constant"); - value2 = error_mark_node; - } - if (value1 != error_mark_node - && value2 != error_mark_node) - { - int success = pushcase_range (value1, value2, label); - if (success == 1) - error ("case label not within a switch statement"); - else if (success == 2) - error ("duplicate (or overlapping) case value"); - else if (success == 3) - warning ("case value out of range"); - else if (success == 4) - warning ("empty range specified"); - } - define_case_label (label); - } - stmt - | DEFAULT ':' - { - register tree label - = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); - int success = pushcase (NULL_TREE, label); - if (success == 1) - error ("default label not within a switch statement"); - else if (success == 2) - error ("multiple default labels in one switch"); - } - stmt - | BREAK ';' - { emit_line_note (input_filename, lineno); - if ( ! expand_exit_something ()) - error ("break statement not within loop or switch"); } - | CONTINUE ';' - { emit_line_note (input_filename, lineno); - if (! expand_continue_loop ()) - error ("continue statement not within a loop"); } - | RETURN ';' - { emit_line_note (input_filename, lineno); - c_expand_return (NULL_TREE); } - | RETURN expr ';' - { emit_line_note (input_filename, lineno); - c_expand_return ($2); - finish_stmt (); - } - | ASM maybe_type_qual '(' string ')' ';' - { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); - emit_line_note (input_filename, lineno); - expand_asm ($4); - finish_stmt (); - } - /* This is the case with just output operands. */ - | ASM maybe_type_qual '(' string ':' asm_operands ')' ';' - { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); - emit_line_note (input_filename, lineno); - c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE, - $2 == ridpointers[(int)RID_VOLATILE], - input_filename, lineno); - finish_stmt (); - } - /* This is the case with input operands as well. */ - | ASM maybe_type_qual '(' string ':' asm_operands ':' asm_operands ')' ';' - { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); - emit_line_note (input_filename, lineno); - c_expand_asm_operands ($4, $6, $8, NULL_TREE, - $2 == ridpointers[(int)RID_VOLATILE], - input_filename, lineno); - finish_stmt (); - } - /* This is the case with clobbered registers as well. */ - | ASM maybe_type_qual '(' string ':' asm_operands ':' - asm_operands ':' asm_clobbers ')' ';' - { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); - emit_line_note (input_filename, lineno); - c_expand_asm_operands ($4, $6, $8, $10, - $2 == ridpointers[(int)RID_VOLATILE], - input_filename, lineno); - finish_stmt (); - } - | GOTO identifier ';' - { tree decl; - emit_line_note (input_filename, lineno); - decl = lookup_label ($2); - TREE_USED (decl) = 1; - expand_goto (decl); } - | IDENTIFIER ':' - { tree label = define_label (input_filename, lineno, $1); - emit_nop (); - if (label) - expand_label (label); } - stmt - { finish_stmt (); } - | TYPENAME_COLON - { tree label = define_label (input_filename, lineno, $1); - if (label) - expand_label (label); } - stmt - { finish_stmt (); } - | ';' - { finish_stmt (); } - - /* Exception handling extentions. */ - | RAISE raise_identifier '(' nonnull_exprlist ')' ';' - { cplus_expand_raise ($2, $4, NULL_TREE); - finish_stmt (); } - | RAISE raise_identifier LEFT_RIGHT ';' - { cplus_expand_raise ($2, NULL_TREE, NULL_TREE); - finish_stmt (); } - | RAISE identifier ';' - { cplus_expand_reraise ($2); - finish_stmt (); } - | try EXCEPT identifier '{' - { - tree decl = cplus_expand_end_try ($1); - $2 = current_exception_type; - $4 = current_exception_decl; - $$ = current_exception_object; - cplus_expand_start_except ($3, decl); - pushlevel (0); - clear_last_expr (); - push_momentary (); - expand_start_bindings (0); - stmt_decl_msg = 0; - } - except_stmts '}' - { - tree decls = getdecls (); - tree block; - /* If there is a default exception to handle, - handle it here. */ - if ($6) - { - tree decl = build_decl (CPLUS_CATCH_DECL, NULL_TREE, 0); - - pushlevel (1); - expand_start_bindings (0); - expand_expr ($6, 0, 0, 0); - expand_end_bindings (0, 1, 0); - block = poplevel (1, 0, 0); - - /* This is a catch block. */ - TREE_LANG_FLAG_2 (block) = 1; - STMT_VARS (block) = decl; - } - - expand_end_bindings (decls, 1, 1); - block = poplevel (1, 1, 0); - TREE_LANG_FLAG_3 (block) = 1; - pop_momentary (); - current_exception_type = $2; - current_exception_decl = $4; - current_exception_object = $5; - cplus_expand_end_except ($6); - } - | try RERAISE raise_identifiers /* ';' checked for at bottom. */ - { tree name = get_identifier ("(compiler error)"); - tree orig_ex_type = current_exception_type; - tree orig_ex_decl = current_exception_decl; - tree orig_ex_obj = current_exception_object; - tree decl = cplus_expand_end_try ($1), decls; - tree block; - - /* Start hidden EXCEPT. */ - cplus_expand_start_except (name, decl); - pushlevel (0); - clear_last_expr (); - push_momentary (); - expand_start_bindings (0); - stmt_decl_msg = 0; - - /* This sets up the reraise. */ - cplus_expand_reraise ($3); - - decls = getdecls (); - expand_end_bindings (decls, 1, 1); - block = poplevel (1, 1, 0); - TREE_LANG_FLAG_3 (block) = 1; - pop_momentary (); - current_exception_type = orig_ex_type; - current_exception_decl = orig_ex_decl; - current_exception_object = orig_ex_obj; - /* This will reraise for us. */ - cplus_expand_end_except (error_mark_node); - if (yychar == YYEMPTY) - yychar = YYLEX; - if (yychar != ';') - error ("missing ';' after reraise statement"); - } - | try %prec EMPTY - { yyerror ("`except' missing after `try' statement"); - /* Terminate the binding contour started by special - code in `.pushlevel'. Automagically pops off - the conditional we started for `try' stmt. */ - cplus_expand_end_try ($1); - expand_end_bindings (0, 0, 1); - poplevel (0, 0, 0); - pop_momentary (); - YYERROR; } - ; - -try: TRY '{' '}' - { $$ = 0; } - | try_head stmts '}' - { - $$ = 1; - pop_implicit_try_blocks (NULL_TREE); - } - | try_head error '}' - { - $$ = 0; - pop_implicit_try_blocks (NULL_TREE); - } - ; - -try_head: TRY '{' { cplus_expand_start_try (0); } .pushlevel - -except_stmts: - /* empty */ - { $$ = NULL_TREE; } - | except_stmts raise_identifier - { - tree type = lookup_exception_type (current_class_type, current_class_name, $2); - if (type == NULL_TREE) - { - error ("`%s' is not an exception type", - IDENTIFIER_POINTER (TREE_VALUE ($2))); - current_exception_type = NULL_TREE; - TREE_TYPE (current_exception_object) = error_mark_node; - } - else - { - current_exception_type = type; - /* In-place union. */ - TREE_TYPE (current_exception_object) = type; - } - $2 = cplus_expand_start_catch ($2); - pushlevel (1); - expand_start_bindings (0); - } - compstmt - { - expand_end_bindings (0, 1, 0); - $4 = poplevel (1, 0, 0); - - cplus_expand_end_catch (0); - - /* Mark this as a catch block. */ - TREE_LANG_FLAG_2 ($4) = 1; - if ($2 != error_mark_node) - { - tree decl = build_decl (CPLUS_CATCH_DECL, DECL_NAME ($2), 0); - DECL_RTL (decl) = DECL_RTL ($2); - TREE_CHAIN (decl) = STMT_VARS ($4); - STMT_VARS ($4) = decl; - } - } - | except_stmts DEFAULT - { - if ($1) - error ("duplicate default in exception handler"); - current_exception_type = NULL_TREE; - /* Takes it right out of scope. */ - TREE_TYPE (current_exception_object) = error_mark_node; - - if (! expand_catch_default ()) - compiler_error ("default catch botch"); - - /* The default exception is handled as the - last in the chain of exceptions handled. */ - do_pending_stack_adjust (); - start_sequence (); - $1 = make_node (RTL_EXPR); - TREE_TYPE ($1) = void_type_node; - } - compstmt - { - do_pending_stack_adjust (); - if (! expand_catch (NULL_TREE)) - compiler_error ("except nesting botch"); - if (! expand_end_catch ()) - compiler_error ("except nesting botch"); - RTL_EXPR_SEQUENCE ($1) = (struct rtx_def *)get_insns (); - if ($4) - { - /* Mark this block as the default catch block. */ - TREE_LANG_FLAG_1 ($4) = 1; - TREE_LANG_FLAG_2 ($4) = 1; - } - end_sequence (); - } - ; - -forhead.1: - FOR '(' ';' - { $$ = NULL_TREE; } - | FOR '(' expr ';' - { $$ = $3; } - | FOR '(' '{' '}' - { $$ = NULL_TREE; } - ; - -forhead.2: - FOR '(' decl - { $$ = 0; } - | FOR '(' error ';' - { $$ = 0; } - | FOR '(' '{' .pushlevel stmts '}' - { $$ = 1; } - | FOR '(' '{' .pushlevel error '}' - { $$ = -1; } - ; - -/* Either a type-qualifier or nothing. First thing in an `asm' statement. */ - -maybe_type_qual: - /* empty */ - { if (pedantic) - warning ("ANSI C forbids use of `asm' keyword"); - emit_line_note (input_filename, lineno); } - | TYPE_QUAL - { if (pedantic) - warning ("ANSI C forbids use of `asm' keyword"); - emit_line_note (input_filename, lineno); } - ; - -xexpr: - /* empty */ - { $$ = NULL_TREE; } - | expr - | error - { $$ = NULL_TREE; } - ; - -/* These are the operands other than the first string and colon - in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */ -asm_operands: /* empty */ - { $$ = NULL_TREE; } - | nonnull_asm_operands - ; - -nonnull_asm_operands: - asm_operand - | nonnull_asm_operands ',' asm_operand - { $$ = chainon ($1, $3); } - ; - -asm_operand: - STRING '(' expr ')' - { $$ = build_tree_list ($1, $3); } - ; - -asm_clobbers: - STRING - { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); } - | asm_clobbers ',' STRING - { $$ = tree_cons (NULL_TREE, $3, $1); } - ; - -/* This is what appears inside the parens in a function declarator. - Its value is represented in the format that grokdeclarator expects. - - In C++, declaring a function with no parameters - means that that function takes *no* parameters. */ -parmlist: /* empty */ - { - if (strict_prototype) - $$ = void_list_node; - else - $$ = NULL_TREE; - } - | parms - { - $$ = chainon ($1, void_list_node); - TREE_PARMLIST ($$) = 1; - } - | parms ',' ELLIPSIS - { - $$ = $1; - TREE_PARMLIST ($$) = 1; - } - /* C++ allows an ellipsis without a separating ',' */ - | parms ELLIPSIS - { - $$ = $1; - TREE_PARMLIST ($$) = 1; - } - | ELLIPSIS - { - $$ = NULL_TREE; - } - | TYPENAME_ELLIPSIS - { - $$ = $1; - TREE_PARMLIST ($$) = 1; - } - | parms TYPENAME_ELLIPSIS - { - $$ = $1; - TREE_PARMLIST ($$) = 1; - } - | parms ':' - { - /* This helps us recover from really nasty - parse errors, for example, a missing right - parenthesis. */ - yyerror ("possibly missing ')'"); - $$ = chainon ($1, void_list_node); - TREE_PARMLIST ($$) = 1; - yyungetc (':', 0); - yychar = ')'; - } - ; - -/* A nonempty list of parameter declarations or type names. */ -parms: - parm opt.init - { $$ = build_tree_list ($2, $1); } - | parms ',' parm opt.init - { $$ = chainon ($1, build_tree_list ($4, $3)); } - | parms ',' bad_parm opt.init - { $$ = chainon ($1, build_tree_list ($4, $3)); } - ; - -/* A single parameter declaration or parameter type name, - as found in a parmlist. */ -parm: - typed_declspecs dont_see_typename notype_declarator - { $$ = build_tree_list ($1, $3); - see_typename (); } - | typed_declspecs dont_see_typename absdcl - { $$ = build_tree_list ($1, $3); - see_typename (); } - | declmods dont_see_typename notype_declarator - { $$ = build_tree_list ($1, $3); - see_typename (); } - | declmods dont_see_typename absdcl - { $$ = build_tree_list ($1, $3); - see_typename (); } - ; - -see_typename: type_quals - { see_typename (); } - ; - -dont_see_typename: /* empty */ - { dont_see_typename (); } - ; - -bad_parm: - dummy_decl notype_declarator - { - warning ("type specifier omitted for parameter"); - $$ = build_tree_list (TREE_PURPOSE (TREE_VALUE ($-1)), $2); - } - | dummy_decl absdcl - { - warning ("type specifier omitted for parameter"); - $$ = build_tree_list (TREE_PURPOSE (TREE_VALUE ($-1)), $2); - } - ; - - /* C++ extension: allow for initialization */ -opt.init: - /* empty */ - { $$ = NULL_TREE; } - | '=' init - { $$ = $2; } - ; - -maybe_raises: - /* empty */ - { $$ = NULL_TREE; } - | RAISES raise_identifiers %prec EMPTY - { $$ = $2; } - ; - -raise_identifier: - ALL - { $$ = void_list_node; } - | IDENTIFIER - { $$ = build_decl_list (NULL_TREE, $1); } - | TYPENAME - { $$ = build_decl_list (NULL_TREE, $1); } - | SCOPE IDENTIFIER - { $$ = build_decl_list (void_type_node, $2); } - | SCOPE TYPENAME - { $$ = build_decl_list (void_type_node, $2); } - | scoped_identifier IDENTIFIER - { $$ = build_decl_list ($1, $2); } - | scoped_identifier TYPENAME - { $$ = build_decl_list ($1, $2); } - -raise_identifiers: - raise_identifier - | raise_identifiers ',' raise_identifier - { - TREE_CHAIN ($3) = $1; - $$ = $3; - } - ; - -operator_name: - OPERATOR '*' - { $$ = build_opid (0, MULT_EXPR); } - | OPERATOR '/' - { $$ = build_opid (0, TRUNC_DIV_EXPR); } - | OPERATOR '%' - { $$ = build_opid (0, TRUNC_MOD_EXPR); } - | OPERATOR '+' - { $$ = build_opid (0, PLUS_EXPR); } - | OPERATOR '-' - { $$ = build_opid (0, MINUS_EXPR); } - | OPERATOR '&' - { $$ = build_opid (0, BIT_AND_EXPR); } - | OPERATOR '|' - { $$ = build_opid (0, BIT_IOR_EXPR); } - | OPERATOR '^' - { $$ = build_opid (0, BIT_XOR_EXPR); } - | OPERATOR '~' - { $$ = build_opid (0, BIT_NOT_EXPR); } - | OPERATOR ',' - { $$ = build_opid (0, COMPOUND_EXPR); } - | OPERATOR ARITHCOMPARE - { $$ = build_opid (0, $2); } - | OPERATOR EQCOMPARE - { $$ = build_opid (0, $2); } - | OPERATOR ASSIGN - { $$ = build_opid (MODIFY_EXPR, $2); } - | OPERATOR '=' - { - $$ = build_opid (MODIFY_EXPR, NOP_EXPR); - if (current_class_type) - { - TYPE_HAS_ASSIGNMENT (current_class_type) = 1; - TYPE_GETS_ASSIGNMENT (current_class_type) = 1; - } - } - | OPERATOR LSHIFT - { $$ = build_opid (0, $2); } - | OPERATOR RSHIFT - { $$ = build_opid (0, $2); } - | OPERATOR PLUSPLUS - { $$ = build_opid (0, POSTINCREMENT_EXPR); } - | OPERATOR MINUSMINUS - { $$ = build_opid (0, PREDECREMENT_EXPR); } - | OPERATOR ANDAND - { $$ = build_opid (0, TRUTH_ANDIF_EXPR); } - | OPERATOR OROR - { $$ = build_opid (0, TRUTH_ORIF_EXPR); } - | OPERATOR '!' - { $$ = build_opid (0, TRUTH_NOT_EXPR); } - | OPERATOR '?' ':' - { $$ = build_opid (0, COND_EXPR); } - | OPERATOR MIN_MAX - { $$ = build_opid (0, $2); } - | OPERATOR POINTSAT %prec EMPTY - { $$ = build_opid (0, COMPONENT_REF); } - | OPERATOR POINTSAT_LEFT_RIGHT type_quals %prec '.' - { - if (yychar == YYEMPTY) - yychar = YYLEX; - if (yychar == '(' || yychar == LEFT_RIGHT) - { - $$ = build_opid (0, METHOD_CALL_EXPR); - if (current_class_type) - { - tree t = current_class_type; - while (t) - { - TYPE_OVERLOADS_METHOD_CALL_EXPR (t) = 1; - t = TYPE_NEXT_VARIANT (t); - } - } - } - else - $$ = build_parse_node (CALL_EXPR, build_opid (0, COMPONENT_REF), void_list_node, $3); - } - | OPERATOR LEFT_RIGHT - { $$ = build_opid (0, CALL_EXPR); - if (current_class_type) - { - tree t = current_class_type; - while (t) - { - TYPE_OVERLOADS_CALL_EXPR (t) = 1; - t = TYPE_NEXT_VARIANT (t); - } - } - } - | OPERATOR '[' ']' - { $$ = build_opid (0, ARRAY_REF); - if (current_class_type) - { - tree t = current_class_type; - while (t) - { - TYPE_OVERLOADS_ARRAY_REF (t) = 1; - t = TYPE_NEXT_VARIANT (t); - } - } - } - | OPERATOR NEW - { - $$ = build_opid (0, NEW_EXPR); - if (current_class_type) - { - tree t = current_class_type; - while (t) - { - TREE_GETS_NEW (t) = 1; - t = TYPE_NEXT_VARIANT (t); - } - } - } - | OPERATOR DELETE - { - $$ = build_opid (0, DELETE_EXPR); - if (current_class_type) - { - tree t = current_class_type; - while (t) - { - TREE_GETS_DELETE (t) = 1; - t = TYPE_NEXT_VARIANT (t); - } - } - } - - /* These should do `groktypename' and set up TREE_HAS_X_CONVERSION - here, rather than doing it in class.c . */ - | OPERATOR typed_typespecs absdcl - { - $$ = build1 (TYPE_EXPR, $2, $3); - } - | OPERATOR error - { $$ = build_opid (ERROR_MARK, ERROR_MARK); } - ; - -%% - -#if YYDEBUG != 0 -db_yyerror (s, yyps, yychar) - char *s; - short *yyps; - int yychar; -{ - FILE *yyout; - char buf[1024]; - int st; - - yyerror (s); - printf ("State is %d, input token number is %d.\n", *yyps, yychar); - -#ifdef PARSE_OUTPUT - if (*yyps < 1) fatal ("Cannot start from here"); - else if ((yyout = fopen (PARSE_OUTPUT, "r")) == NULL) - error ("cannot open file %s", PARSE_OUTPUT); - else - { - printf ("That is to say,\n\n"); - while (fgets(buf, sizeof (buf)-1, yyout)) - { - if (buf[0] != 's') continue; - st = atoi (buf+6); - if (st != *yyps) continue; - printf ("%s", buf); - while (fgets (buf, sizeof (buf)-1, yyout)) - { - if (buf[0] == 's') break; - printf ("%s", buf); - } - break; - } - printf ("With the token %s\n", yytname[YYTRANSLATE (yychar)]); - fclose (yyout); - } -#endif -} -#endif - -void -yyerror (string) - char *string; -{ - extern FILE *finput; - extern char *token_buffer; - char buf[200]; - - strcpy (buf, string); - - /* We can't print string and character constants well - because the token_buffer contains the result of processing escapes. */ - if (end_of_file || feof (finput)) - strcat (buf, " at end of input"); - else if (token_buffer[0] == 0) - strcat (buf, " at null character"); - else if (token_buffer[0] == '"') - strcat (buf, " before string constant"); - else if (token_buffer[0] == '\'') - strcat (buf, " before character constant"); - else - strcat (buf, " before `%s'"); - - error (buf, token_buffer); -} - -#ifndef GATHER_STATISTICS -int *init_parse () { return 0; } -#else -static int *reduce_count; -static int *token_count; - -#define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0])) -#define TOKEN_LENGTH (256 + YYNTBASE + 1) - -int * -init_parse () -{ - reduce_count = (int *)malloc (sizeof (int) * (REDUCE_LENGTH + 1)); - bzero (reduce_count, sizeof (int) * (REDUCE_LENGTH + 1)); - reduce_count += 1; - token_count = (int *)malloc (sizeof (int) * (TOKEN_LENGTH + 1)); - bzero (token_count, sizeof (int) * (TOKEN_LENGTH + 1)); - token_count += 1; - return token_count; -} - -void -yyhook (yyn) - int yyn; -{ - reduce_count[yyn] += 1; -} - -static int reduce_cmp (p, q) - int *p, *q; -{ - return reduce_count[*q] - reduce_count[*p]; -} - -static int token_cmp (p, q) - int *p, *q; -{ - return token_count[*q] - token_count[*p]; -} - -void -print_parse_statistics () -{ - int i; - int maxlen = REDUCE_LENGTH; - unsigned *sorted; - - if (reduce_count[-1] == 0) - return; - - if (TOKEN_LENGTH > REDUCE_LENGTH) - maxlen = TOKEN_LENGTH; - sorted = (unsigned *) alloca (sizeof (int) * maxlen); - - for (i = 0; i < TOKEN_LENGTH; i++) - sorted[i] = i; - qsort (sorted, TOKEN_LENGTH, sizeof (int), token_cmp); - for (i = 0; i < TOKEN_LENGTH; i++) - { - int index = sorted[i]; - if (token_count[index] == 0) - break; - if (token_count[index] < token_count[-1]) - break; - fprintf (stderr, "token %d", index); -#if YYDEBUG - fprintf (stderr, ", `%s'", yytname[YYTRANSLATE (index)]); -#endif - fprintf (stderr, ", count = %d\n", token_count[index]); - } - fprintf (stderr, "\n"); - for (i = 0; i < REDUCE_LENGTH; i++) - sorted[i] = i; - qsort (sorted, REDUCE_LENGTH, sizeof (int), reduce_cmp); - for (i = 0; i < REDUCE_LENGTH; i++) - { - int index = sorted[i]; - if (reduce_count[index] == 0) - break; - if (reduce_count[index] < reduce_count[-1]) - break; - fprintf (stderr, "rule %d", index); -#if YYDEBUG - fprintf (stderr, ", line %d", yyrline[index]); -#endif - fprintf (stderr, ", count = %d\n", reduce_count[index]); - } - fprintf (stderr, "\n"); -} -#endif diff --git a/gnu/usr.bin/g++/cc1plus/cplus-ptree.c b/gnu/usr.bin/g++/cc1plus/cplus-ptree.c deleted file mode 100644 index 03445ad06406..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-ptree.c +++ /dev/null @@ -1,234 +0,0 @@ -/* Prints out tree in human readable form - GNU C++ compiler - Copyright (C) 1987 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include "config.h" -#include "tree.h" -#include "cplus-tree.h" -#include - - -extern char *tree_code_err_name[]; -extern char *tree_code_err_asg_name[]; -extern char *mode_name[]; - -extern char spaces[]; - -#define MIN(x,y) ((x < y) ? x : y) - -static FILE *outfile; - -/* This code is copied from print-tree.c. */ -static -void -wruid (node) - tree node; -{ - - if (node == NULL) - fputs ("<>", outfile); - else { - fprintf (outfile, "%1d", TREE_UID (node)); - } -} - -static -void -part (title, node) - char title[]; - tree node; -{ - fprintf (outfile, " %s = ", title); - wruid (node); - putc (';', outfile); -} - -/* Similar to `part' but prefix with @ if value is not constant - and print the constant value if it is constant. */ -static -void -cpart (title, ct, punct) - char *title; - tree ct; - char punct; -{ - fprintf (outfile, " %s = ", title); - if (ct == NULL) - fputs ("<>", outfile); - else - { - if (!TREE_LITERAL (ct)) - { - putc ('@', outfile); - wruid (ct); - } - else - fprintf (outfile, "%ld", TREE_INT_CST_LOW (ct)); - } - putc (punct, outfile); -} - -void -print_lang_decl (node) - tree node; -{ -} - -void walk_lang_decl (node) - tree node; -{ -} - -void -print_lang_type (node) - register tree node; -{ - int first; - if (! (TREE_CODE (node) == RECORD_TYPE - || TREE_CODE (node) == UNION_TYPE)) - return; - first = 1; - fputs (" [", outfile); - if (TYPE_NEEDS_CONSTRUCTOR (node)) - { - if (!first) putc (' ', outfile); - fputs ("needs-constructor", outfile); - first = 0; - } - if (TYPE_NEEDS_DESTRUCTOR (node)) - { - if (!first) putc (' ', outfile); - fputs ("needs-destructor", outfile); - first = 0; - } - if (TYPE_HAS_CONVERSION (node)) - { - if (!first) putc (' ', outfile); - fputs ("has-type-conversion", outfile); - first = 0; - } - if (TYPE_HAS_INT_CONVERSION (node)) - { - if (!first) putc (' ', outfile); - fputs ("has-int-conversion", outfile); - first = 0; - } - if (TYPE_HAS_REAL_CONVERSION (node)) - { - if (!first) putc (' ', outfile); - fputs ("has-float-conversion", outfile); - first = 0; - } - if (TYPE_HAS_INIT_REF (node)) - { - if (!first) putc (' ', outfile); - fputs ("X(X&)", outfile); - first = 0; - } - if (TREE_GETS_NEW (node)) - { - if (!first) putc (' ', outfile); - fputs ("gets-new", outfile); - first = 0; - } - if (TREE_GETS_DELETE (node)) - { - if (!first) putc (' ', outfile); - fputs ("gets-delete", outfile); - first = 0; - } - if (TYPE_HAS_ASSIGNMENT (node)) - { - if (!first) putc (' ', outfile); - fputs ("has=", outfile); - first = 0; - } - if (TYPE_GETS_ASSIGNMENT (node)) - { - if (!first) putc (' ', outfile); - fputs ("gets=", outfile); - first = 0; - } - if (TYPE_HAS_ASSIGN_REF (node)) - { - if (!first) putc (' ', outfile); - fputs ("this=(X&)", outfile); - first = 0; - } - if (TYPE_GETS_ASSIGN_REF (node)) - { - if (!first) putc (' ', outfile); - fputs ("gets=(X&)", outfile); - first = 0; - } - if (TYPE_HAS_WRAPPER (node)) - { - if (!first) putc (' ', outfile); - fputs ("wrapper", outfile); - first = 0; - } - if (TYPE_OVERLOADS_METHOD_CALL_EXPR (node)) - { - if (!first) putc (' ', outfile); - fputs ("op->()", outfile); - first = 0; - } - if (TYPE_GETS_INIT_AGGR (node)) - { - if (!first) putc (' ', outfile); - fputs ("gets X(X, ...)", outfile); - first = 0; - } - if (TYPE_OVERLOADS_CALL_EXPR (node)) - { - if (!first) putc (' ', outfile); - fputs ("op()", outfile); - first = 0; - } - if (TYPE_OVERLOADS_ARRAY_REF (node)) - { - if (!first) putc (' ', outfile); - fputs ("op[]", outfile); - first = 0; - } - if (TYPE_USES_MULTIPLE_INHERITANCE (node)) - { - if (!first) putc (' ', outfile); - fputs ("uses-multiple-inheritance", outfile); - first = 0; - } - - fputs ("] ", outfile); -} - -void -walk_lang_type (node) - tree node; -{ - if (! (TREE_CODE (node) == RECORD_TYPE)) - return; - - part ("member functions", CLASSTYPE_METHOD_VEC (node)); - part ("baselinks", CLASSTYPE_BASELINK_VEC (node)); - cpart ("offset", CLASSTYPE_OFFSET (node), ';'); - fprintf (outfile, "n_parents = %d; n_ancestors = %d;", - CLASSTYPE_N_BASECLASSES (node), - CLASSTYPE_N_SUPERCLASSES (node)); -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-search.c b/gnu/usr.bin/g++/cc1plus/cplus-search.c deleted file mode 100644 index 8658c9a33e45..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-search.c +++ /dev/null @@ -1,3225 +0,0 @@ -/* Breadth-first and depth-first routines for - searching multiple-inheritance lattice for GNU C++. - Copyright (C) 1987 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* High-level class interface. */ - -#include "config.h" -#include "tree.h" -#include "cplus-tree.h" -#include "obstack.h" -#include "flags.h" -#include "assert.h" -#include - -/* For expand_asm_operands. */ -extern char *input_filename; -extern int lineno; - -#define NULL 0 - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -extern int xmalloc (); -extern void free (); - -void init_search (); -extern struct obstack *current_obstack; - -#include "stack.h" - -/* Obstack used for remembering decision points of breadth-first. */ -static struct obstack search_obstack; - -/* Obstack used to bridge from one function context to another. */ -static struct obstack bridge_obstack; - -/* Methods for pushing and popping objects to and from obstacks. */ - -struct stack_level * -push_stack_level (obstack, tp, size) - struct obstack *obstack; - void *tp; - int size; -{ - struct stack_level *stack; - stack = (struct stack_level *) obstack_next_free (obstack); - obstack_grow (obstack, tp, size); - obstack_finish (obstack); - stack->obstack = obstack; - stack->first = (tree *) obstack_base (obstack); - stack->limit = obstack_room (obstack) / sizeof (tree *); - return stack; -} - -struct stack_level * -pop_stack_level (stack) - struct stack_level *stack; -{ - struct stack_level *tem = stack; - struct obstack *obstack = tem->obstack; - stack = tem->prev; - obstack_free (obstack, tem); - return stack; -} - -#define search_level stack_level -static struct search_level *search_stack; - -static tree lookup_field_1 (); -static int lookup_fnfields_1 (); - -/* Allocate a level of searching. */ -static struct search_level * -push_search_level (stack, obstack) - struct stack_level *stack; - struct obstack *obstack; -{ - struct search_level tem; - tem.prev = stack; - - return push_stack_level (obstack, &tem, sizeof (tem)); -} - -/* Discard a level of search allocation. */ -#define pop_search_level pop_stack_level - -/* Search memoization. */ -struct type_level -{ - struct stack_level base; - - /* First object allocated in obstack of entries. */ - char *entries; - - /* Number of types memoized in this context. */ - int len; - - /* Type being memoized; save this if we are saving - memoized contexts. */ - tree type; -}; - -/* Obstack used for memoizing member and member function lookup. */ - -static struct obstack type_obstack, type_obstack_entries; -static struct type_level *type_stack; -static tree _vptr_name; - -/* Make things that look like tree nodes, but allocate them - on type_obstack_entries. */ -static int my_tree_node_counter; -static tree my_tree_cons (), my_build_string (); - -extern int flag_memoize_lookups, flag_save_memoized_contexts; - -/* Variables for gathering statistics. */ -static int my_memoized_entry_counter; -static int memoized_fast_finds[2], memoized_adds[2], memoized_fast_rejects[2]; -static int memoized_fields_searched[2]; -static int n_fields_searched; -static int n_calls_lookup_field, n_calls_lookup_field_1; -static int n_calls_lookup_fnfields, n_calls_lookup_fnfields_1; -static int n_calls_get_base_type; -static int n_outer_fields_searched; -static int n_contexts_saved; - -/* Local variables to help save memoization contexts. */ -static tree prev_type_memoized; -static struct type_level *prev_type_stack; - -/* Allocate a level of type memoziation context. */ -static struct type_level * -push_type_level (stack, obstack) - struct stack_level *stack; - struct obstack *obstack; -{ - struct type_level tem; - - tem.base.prev = stack; - - obstack_finish (&type_obstack_entries); - tem.entries = (char *) obstack_base (&type_obstack_entries); - tem.len = 0; - tem.type = NULL_TREE; - - return (struct type_level *)push_stack_level (obstack, &tem, sizeof (tem)); -} - -/* Discard a level of type memoziation context. */ - -static struct type_level * -pop_type_level (stack) - struct type_level *stack; -{ - obstack_free (&type_obstack_entries, stack->entries); - return (struct type_level *)pop_stack_level (stack); -} - -/* Make something that looks like a TREE_LIST, but - do it on the type_obstack_entries obstack. */ -static tree -my_tree_cons (purpose, value, chain) - tree purpose, value, chain; -{ - tree p = (tree)obstack_alloc (&type_obstack_entries, sizeof (struct tree_list)); - TREE_UID (p) = ++my_tree_node_counter; - TREE_TYPE (p) = 0; - ((int *)p)[3] = 0; - TREE_SET_CODE (p, TREE_LIST); - TREE_PURPOSE (p) = purpose; - TREE_VALUE (p) = value; - TREE_CHAIN (p) = chain; - return p; -} - -static tree -my_build_string (str) - char *str; -{ - tree p = (tree)obstack_alloc (&type_obstack_entries, sizeof (struct tree_string)); - TREE_UID (p) = ++my_tree_node_counter; - TREE_TYPE (p) = 0; - ((int *)p)[3] = 0; - TREE_SET_CODE (p, STRING_CST); - TREE_STRING_POINTER (p) = str; - TREE_STRING_LENGTH (p) = strlen (str); - return p; -} - -static tree -my_copy_node (node) - tree node; -{ - struct obstack *ambient_obstack = current_obstack; - tree t; - - current_obstack = &type_obstack_entries; - - t = copy_node (node); - TREE_UID (t) = ++my_tree_node_counter; - - current_obstack = ambient_obstack; - return t; -} - -/* Memoizing machinery to make searches for multiple inheritance - reasonably efficient. */ -#define MEMOIZE_HASHSIZE 8 -typedef struct memoized_entry -{ - struct memoized_entry *chain; - int uid; - tree data_members[MEMOIZE_HASHSIZE]; - tree function_members[MEMOIZE_HASHSIZE]; -} *ME; - -#define MEMOIZED_CHAIN(ENTRY) (((ME)ENTRY)->chain) -#define MEMOIZED_UID(ENTRY) (((ME)ENTRY)->uid) -#define MEMOIZED_FIELDS(ENTRY,INDEX) (((ME)ENTRY)->data_members[INDEX]) -#define MEMOIZED_FNFIELDS(ENTRY,INDEX) (((ME)ENTRY)->function_members[INDEX]) -#define MEMOIZED_HASH_FN(NODE) (TREE_UID (NODE)&(MEMOIZE_HASHSIZE - 1)) - -static struct memoized_entry * -my_new_memoized_entry (chain) - struct memoized_entry *chain; -{ - struct memoized_entry *p = - (struct memoized_entry *)obstack_alloc (&type_obstack_entries, - sizeof (struct memoized_entry)); - bzero (p, sizeof (struct memoized_entry)); - MEMOIZED_CHAIN (p) = chain; - MEMOIZED_UID (p) = ++my_memoized_entry_counter; - return p; -} - -/* When a new function or class context is entered, we build - a table of types which have been searched for members. - The table is an array (obstack) of types. When a type is - entered into the obstack, its CLASSTYPE_MTABLE_ENTRY - field is set to point to a new record, of type struct memoized_entry. - - A non-NULL TREE_TYPE of the entry contains a visibility error message. - - The slots for the data members are arrays of tree nodes. - These tree nodes are lists, with the TREE_PURPOSE - of this list the known member name, and the TREE_VALUE - as the FIELD_DECL for the member. - - For member functions, the TREE_PURPOSE is again the - name of the member functions for that class, - and the TREE_VALUE of the list is a pairs - whose TREE_PURPOSE is a member functions of this name, - and whose TREE_VALUE is a list of known argument lists this - member function has been called with. The TREE_TYPE of the pair, - if non-NULL, is an error message to print. */ - -/* Tell search machinery that we are entering a new context, and - to update tables appropriately. - - TYPE is the type of the context we are entering, which can - be NULL_TREE if we are not in a class's scope. - - USE_OLD, if nonzero tries to use previous context. */ -void -push_memoized_context (type, use_old) - tree type; - int use_old; -{ - int len; - tree *tem; - - if (prev_type_stack) - { - if (use_old && prev_type_memoized == type) - { -#ifdef GATHER_STATISTICS - n_contexts_saved++; -#endif - type_stack = prev_type_stack; - prev_type_stack = 0; - - tem = &type_stack->base.first[0]; - len = type_stack->len; - while (len--) - CLASSTYPE_MTABLE_ENTRY (tem[len*2]) = tem[len*2+1]; - return; - } - /* Otherwise, need to pop old stack here. */ - type_stack = pop_type_level (prev_type_stack); - prev_type_memoized = 0; - prev_type_stack = 0; - } - - type_stack = push_type_level (type_stack, &type_obstack); - type_stack->type = type; -} - -/* Tell search machinery that we have left a context. - We do not currently save these contexts for later use. - If we wanted to, we could not use pop_search_level, since - poping that level allows the data we have collected to - be clobbered; a stack of obstacks would be needed. */ -pop_memoized_context (use_old) - int use_old; -{ - int len; - tree *tem = &type_stack->base.first[0]; - - if (! flag_save_memoized_contexts) - use_old = 0; - else if (use_old) - { - len = type_stack->len; - while (len--) - tem[len*2+1] = (tree)CLASSTYPE_MTABLE_ENTRY (tem[len*2]); - - prev_type_stack = type_stack; - prev_type_memoized = type_stack->type; - } - - if (flag_memoize_lookups) - { - len = type_stack->len; - while (len--) - CLASSTYPE_MTABLE_ENTRY (tem[len*2]) - = MEMOIZED_CHAIN (CLASSTYPE_MTABLE_ENTRY (tem[len*2])); - } - if (! use_old) - type_stack = pop_type_level (type_stack); - else - type_stack = (struct type_level *)type_stack->base.prev; -} - -/* Some simple list processing predicates. */ - -/* Check whether TYPE is immediately derived from PARENT. - Return actual base information if so. Otherwise, return 0. */ -tree -get_base_type_1 (parent, type) - register tree parent, type; -{ - register int i; - - parent = TYPE_MAIN_VARIANT (parent); - type = TYPE_MAIN_VARIANT (type); - - for (i = 1; i <= CLASSTYPE_N_BASECLASSES (type); i++) - if (TYPE_MAIN_VARIANT (CLASSTYPE_BASECLASS (type, i)) == parent) - return CLASSTYPE_BASECLASS (type, i); - - return 0; -} - -/* Check whether TYPE is derived from PARENT. - Return the actual base information if so. Otherwise return 0. - If PROTECT is 1, then emit an error message if access to - a public field of PARENT would be private. - If PROTECT is 2, then emit an error message if - TYPE is derived from PARENT via private visibility rules. - If PROTECT is 3, then immediately private baseclass is ok, - but deeper than that, if private, emit error message. */ -tree -get_base_type (parent, type, protect) - register tree parent, type; -{ - tree xtype = type; - tree otype; - int head = 0, tail = 0; - int is_private = 0; - tree rval = NULL_TREE; - int rval_private = 0; - tree friends = current_class_type - ? CLASSTYPE_FRIEND_CLASSES (type) : NULL_TREE; - -#ifdef GATHER_STATISTICS - n_calls_get_base_type++; -#endif - - parent = TYPE_MAIN_VARIANT (parent); - search_stack = push_search_level (search_stack, &search_obstack); - - while (1) - { - int i, n_baselinks = CLASSTYPE_N_BASECLASSES (type); - - /* Process and/or queue base types. */ - for (i = 1; i <= n_baselinks; i++) - if (CLASSTYPE_MARKED5 (CLASSTYPE_BASECLASS (type, i)) == 0) - { - int via_private = is_private || !CLASSTYPE_VIA_PUBLIC (type, i); - - if (via_private == 0) - ; - else if (protect == 0) - via_private = 0; - else if (protect == 1 && type == current_class_type) - /* The immediate base class of the class we are in - does let its public members through. */ - via_private = 0; -#ifndef NOJJG - else if (protect - && friends != NULL_TREE - && type == xtype - && value_member (current_class_type, friends)) - /* Friend types of the most derived type have access - to its baseclass pointers. */ - via_private = 0; -#endif - - CLASSTYPE_MARKED5 (CLASSTYPE_BASECLASS (type, i)) = 1; - otype = type; - obstack_ptr_grow (&search_obstack, CLASSTYPE_BASECLASS (type, i)); - obstack_int_grow (&search_obstack, via_private); - tail += 2; - if (tail >= search_stack->limit) - abort (); - } - else if (protect && ! CLASSTYPE_VIA_VIRTUAL (type, i)) - { - error_with_aggr_type (parent, "type `%s' is ambiguous base class for type `%s'", - TYPE_NAME_STRING (xtype)); - error ("(base class for types `%s' and `%s')", - TYPE_NAME_STRING (type), - TYPE_NAME_STRING (otype)); - rval = error_mark_node; - break; - } - - dont_queue: - /* Process head of queue, if one exists. */ - if (head >= tail) - break; - - type = search_stack->first[head++]; - is_private = (int)search_stack->first[head++]; - if (TYPE_MAIN_VARIANT (type) == parent) - { - if (rval == 0) - { - rval = type; - rval_private = is_private; - } - goto dont_queue; - } - } - { - tree *tp = search_stack->first; - tree *search_tail = tp + tail; - - while (tp < search_tail) - { - CLASSTYPE_MARKED5 (*tp) = 0; - tp += 2; - } - } - search_stack = pop_search_level (search_stack); - - if (rval == error_mark_node) - return error_mark_node; - - if (rval && protect && rval_private) - { - if (protect == 3) - { - int i; - - for (i = 1; i <= CLASSTYPE_N_BASECLASSES (xtype); i++) - if (parent == TYPE_MAIN_VARIANT (CLASSTYPE_BASECLASS (xtype, i))) - /* It's ok, since it's immedate. */ - return rval; - } - error ("type `%s' is derived from private `%s'", - TYPE_NAME_STRING (xtype), - TYPE_NAME_STRING (parent)); - return error_mark_node; - } - - return rval; -} - -/* Return the number of levels between type PARENT and type TYPE, - following the leftmost path to PARENT. If PARENT is its own main - type variant, then if PARENT appears in different places from TYPE's - point of view, the leftmost PARENT will be the one chosen. - - Return -1 if TYPE is not derived from PARENT. - Return -2 if PARENT is an ambiguous base class of TYPE. - Return -3 if PARENT is private to TYPE, and protect is non-zero. - - If PATH_PTR is non-NULL, then also build the list of types - from PARENT to TYPE, with TREE_VIA_VIRUAL and TREE_VIA_PUBLIC - set. */ -get_base_distance (parent, type, protect, path_ptr) - register tree parent, type; - int protect; - tree *path_ptr; -{ - int head = 0, tail = 0; - int is_private = 0; - int rval; - int depth = 0; - int rval_private = 0; - tree basetypes; - tree friends = current_class_type - ? CLASSTYPE_FRIEND_CLASSES (type) : NULL_TREE; - int use_leftmost; - - if (TREE_READONLY (parent) || TREE_VOLATILE (parent)) - parent = TYPE_MAIN_VARIANT (parent); - use_leftmost = (parent == TYPE_MAIN_VARIANT (parent)); - - if (path_ptr) - basetypes = CLASSTYPE_AS_LIST (type); - - if (TYPE_MAIN_VARIANT (parent) == type) - { - /* If the distance is 0, then we don't really need - a path pointer, but we shouldn't let garbage go back. */ - if (path_ptr) - *path_ptr = basetypes; - return 0; - } - - search_stack = push_search_level (search_stack, &search_obstack); - - while (1) - { - int i, n_baselinks = CLASSTYPE_N_BASECLASSES (type); - - /* Process and/or queue base types. */ - for (i = 1; i <= n_baselinks; i++) - if (CLASSTYPE_MARKED5 (CLASSTYPE_BASECLASS (type, i)) == 0) - { - tree btypes; - - int via_private = is_private || !CLASSTYPE_VIA_PUBLIC (type, i); - - if (via_private == 0) - ; - else if (protect == 0) - via_private = 0; -#if 0 - /* 13 Jan, 1990: I guess this is turned off because - `get_base_type' will emit a more eloquent message - if a message desired [--Michael]. */ - /* The immediate base class of the class we are in - does let its public members through. */ - else if (type == current_class_type) - via_private = 0; - else if (protect - && friends != NULL_TREE - && type == xtype - && value_member (current_class_type, friends)) - /* Friend types of the most derived type have access - to its baseclass pointers. */ - via_private = 0; -#endif - - CLASSTYPE_MARKED5 (CLASSTYPE_BASECLASS (type, i)) = 1; - obstack_ptr_grow (&search_obstack, CLASSTYPE_BASECLASS (type, i)); - - obstack_ptr_grow (&search_obstack, depth); - obstack_int_grow (&search_obstack, via_private); - if (path_ptr) - { - btypes = tree_cons (NULL_TREE, CLASSTYPE_BASECLASS (type, i), - basetypes); - TREE_VIA_PUBLIC (btypes) = CLASSTYPE_VIA_PUBLIC (type, i); - TREE_VIA_VIRTUAL (btypes) = CLASSTYPE_VIA_VIRTUAL (type, i); - obstack_ptr_grow (&search_obstack, btypes); - tail += 1; - } - tail += 3; - if (tail >= search_stack->limit) - abort (); - } - else if (! CLASSTYPE_VIA_VIRTUAL (type, i)) - { - rval = -2; - goto done; - } - - /* Process head of queue, if one exists. */ - if (head >= tail) - { - rval = -1; - break; - } - - type = search_stack->first[head++]; - depth = (int)search_stack->first[head++] + 1; - is_private = (int)search_stack->first[head++]; - if (path_ptr) - basetypes = search_stack->first[head++]; - if (type == parent - || (use_leftmost && TYPE_MAIN_VARIANT (type) == parent)) - { - rval = depth; - rval_private = is_private; - break; - } - } - done: - { - tree *tp = search_stack->first; - tree *search_tail = tp + tail; - int increment = path_ptr ? 4 : 3; - - while (tp < search_tail) - { - CLASSTYPE_MARKED5 (*tp) = 0; - tp += increment; - } - - /* Now, guarantee that we are following the leftmost - path in the chain. */ - if (use_leftmost - && rval > 0 - && (DECL_OFFSET (TYPE_NAME (type)) != 0 - || TREE_VIA_VIRTUAL (type))) - { - /* Reduce all types yet to be fully processed into - the base type we are looking for, or NULL_TREE. */ - for (tp = search_stack->first; tp < search_tail; tp += increment) - { - tree *sub_tp, sub_path_ptr; - int sub_rval; - - /* Don't chase down more right-most paths. */ - if (TREE_VIA_VIRTUAL (*tp) - || DECL_OFFSET (TYPE_NAME (*tp)) > DECL_OFFSET (TYPE_NAME (type))) - { - *tp = NULL_TREE; - continue; - } - - /* Don't hassle with duplicates. */ - if (*tp == type) - goto skip; - - for (sub_tp = search_stack->first; sub_tp < tp; sub_tp += increment) - if (*tp == *sub_tp) - goto skip; - - /* Find this type's TYPE basetype, if it has one. */ - sub_rval = get_base_distance (parent, *tp, 0, &sub_path_ptr); - if (sub_rval == -1) - *tp = NULL_TREE; - else - { - if (path_ptr && TREE_CHAIN (tp[3])) - { - tree last; - tree next_to_last = sub_path_ptr; - while (TREE_CHAIN (next_to_last) - && TREE_CHAIN (TREE_CHAIN (next_to_last))) - next_to_last = TREE_CHAIN (next_to_last); - if (next_to_last == sub_path_ptr) - { - sub_path_ptr = copy_node (sub_path_ptr); - last = sub_path_ptr; - } - else - { - last = copy_node (TREE_CHAIN (next_to_last)); - TREE_CHAIN (next_to_last) = last; - } - TREE_CHAIN (last) = TREE_CHAIN (tp[3]); - } - *tp = TREE_VALUE (sub_path_ptr); - if (path_ptr) - tp[3] = sub_path_ptr; - } - skip: {} - } - - /* For all the types which reduce to TYPE, choose - the leftmost non-virtual one of them. */ - for (tp = search_stack->first; tp < search_tail; tp += increment) - { - if (*tp == NULL_TREE) - continue; - - if (DECL_OFFSET (TYPE_NAME (*tp)) < DECL_OFFSET (TYPE_NAME (type))) - { - rval = -2; - type = *tp; - if (path_ptr) - basetypes = tp[3]; - } - } - if (rval == -2) - rval_private = 0; - } - } - search_stack = pop_search_level (search_stack); - - if (rval && protect && rval_private) - return -3; - - if (path_ptr) - *path_ptr = basetypes; - return rval; -} - -/* Search for a member with name NAME in a multiple inheritance lattice - specified by TYPE. If it does not exist, return NULL_TREE. - If the member is ambiguously referenced, return `error_mark_node'. - Otherwise, return the FIELD_DECL. */ - -/* Do a 1-level search for NAME as a member of TYPE. The caller - must figure out whether it has a visible path to this field. - (Since it is only one level, this is reasonable.) */ -static tree -lookup_field_1 (type, name) - tree type, name; -{ - register tree field = TYPE_FIELDS (type); - -#ifdef GATHER_STATISTICS - n_calls_lookup_field_1++; -#endif - while (field) - { -#ifdef GATHER_STATISTICS - n_fields_searched++; -#endif - if (DECL_ANON_UNION_ELEM (field)) - { - tree temp = lookup_field_1 (TREE_TYPE (field), name); - if (temp) - return temp; - } - if (DECL_NAME (field) == name) - return field; - field = TREE_CHAIN (field); - } - /* Not found. */ - if (name == _vptr_name) - { - /* Give the user what s/he thinks s/he wants. */ - if (TYPE_VIRTUAL_P (type)) - return CLASSTYPE_VFIELD (type); - } - return NULL_TREE; -} - -/* Compute the visibility of FIELD. This is done by computing - the visibility available to each type in BASETYPES (which comes - as a list of [via_public/basetype] in reverse order, namely base - class before derived class). The first one which defines a - visibility defines the visibility for the field. Otherwise, the - visibility of the field is that which occurs normally. - - Uses global variables CURRENT_CLASS_TYPE and - CURRENT_FUNCTION_DECL to use friend relationships - if necessary. - - This will be static when lookup_fnfield comes into this file. */ - -#define PUBLIC_RETURN do { TREE_FIELD_PUBLIC (field) = 1; return visibility_public; } while (0) -#define PROTECTED_RETURN do { TREE_FIELD_PROTECTED (field) = 1; return visibility_protected; } while (0) -#define PRIVATE_RETURN do { TREE_FIELD_PRIVATE (field) = 1; return visibility_private; } while (0) - -enum visibility_type -compute_visibility (basetypes, field) - tree basetypes, field; -{ - enum visibility_type visibility = visibility_public; - tree types, type; - tree context = DECL_FIELD_CONTEXT (field); - - /* Virtual function tables are never private. - But we should know that we are looking for this, - and not even try to hide it. */ - if (VFIELD_NAME_P (DECL_NAME (field)) == 1) - return visibility_public; - - /* Make these special cases fast. */ - if (TREE_VALUE (basetypes) == current_class_type) - { - if (TREE_FIELD_PUBLIC (field)) - return visibility_public; - if (TREE_FIELD_PROTECTED (field)) - return visibility_protected; - if (TREE_FIELD_PRIVATE (field)) - return visibility_private; - } - - /* Member function manipulating its own members. */ - if (current_class_type == context) - PUBLIC_RETURN; - - /* Member found immediately within object. */ - if (TREE_CHAIN (basetypes) == NULL_TREE) - { - /* At object's top level, public members are public. */ - if (TREE_PROTECTED (field) == 0 && TREE_PRIVATE (field) == 0) - PUBLIC_RETURN; - - /* Friend function manipulating members it gets (for being a friend). */ - if (is_friend (context, current_function_decl)) - PUBLIC_RETURN; - - /* Inner than that, without special visibility, - - protected members are ok if type of object is current_class_type - is derived therefrom. This means that if the type of the object - is a base type for our current class type, we cannot access - protected members. - - private members are not ok. */ - if (current_class_type && DECL_VISIBILITY (field) == NULL_TREE) - { - if (TREE_PRIVATE (field)) - PRIVATE_RETURN; - - if (TREE_PROTECTED (field)) - { - if (context == current_class_type - || (type = get_base_type (current_class_type, context, 0))) - PUBLIC_RETURN; - else - PROTECTED_RETURN; - } - else abort (); - } - } - /* Friend function manipulating members it gets (for being a friend). */ - if (is_friend (context, current_function_decl)) - PUBLIC_RETURN; - - /* must reverse more than one element */ - basetypes = nreverse (basetypes); - - types = basetypes; - - while (types) - { - tree member; - type = TYPE_MAIN_VARIANT (TREE_VALUE (types)); - - member = purpose_member (type, DECL_VISIBILITY (field)); - if (member) - { - visibility = (enum visibility_type)TREE_VALUE (member); - if (visibility == visibility_public - || is_friend (type, current_function_decl) - || (visibility == visibility_protected - && current_class_type - && get_base_type (context, current_class_type, 0))) - visibility = visibility_public; - goto ret; - } - - /* Friends inherit the visibility of the class they inherit from. */ - if (is_friend (type, current_function_decl)) - { - if (type == context) - { - visibility = visibility_public; - goto ret; - } - if (TREE_PROTECTED (field)) - { - visibility = visibility_public; - goto ret; - } -#if 0 - /* This short-cut is too short. */ - if (visibility == visibility_public) - goto ret; -#endif - /* else, may be a friend of a deeper base class */ - } - - if (type == context) - break; - - types = TREE_CHAIN (types); - /* If the next type was not VIA_PUBLIC, then fields of all - remaining class past that one are private. */ - if (types && ! TREE_VIA_PUBLIC (types)) - visibility = visibility_private; - } - - /* No special visibilities apply. Use normal rules. - No assignment needed for BASETYPEs here from the nreverse. - This is because we use it only for information about the - path to the base. The code earlier dealt with what - happens when we are at the base level. */ - - if (visibility == visibility_public) - { - basetypes = nreverse (basetypes); - if (TREE_PRIVATE (field)) - PRIVATE_RETURN; - if (TREE_PROTECTED (field)) - { - /* Used to check if the current class type was derived from - the type that contains the field. This is wrong for - multiple inheritance because is gives one class reference - to protected members via another classes protected path. - I.e., if A; B1 : A; B2 : A; Then B1 and B2 can access - their own members which are protected in A, but not - those same members in one another. */ - if ( -#if 1 - current_class_type - && get_base_type (context, current_class_type, 0) -#else - current_class_type - && value_member (current_class_type, basetypes) -#endif - ) - PUBLIC_RETURN; - PROTECTED_RETURN; - } - PUBLIC_RETURN; - } - - if (visibility == visibility_private - && current_class_type != NULL_TREE) - { - if (TREE_PRIVATE (field)) - { - nreverse (basetypes); - PRIVATE_RETURN; - } - - /* See if the field isn't protected. */ - if (TREE_PROTECTED (field)) - { - tree test; -#if 0 - test = get_base_type (type, current_class_type, 0); -#else - test = value_member (current_class_type, basetypes); -#endif - nreverse (basetypes); - if (test) - PUBLIC_RETURN; - PROTECTED_RETURN; - } - - /* See if the field isn't a public member of - a private base class. */ - - visibility = visibility_public; - types = TREE_CHAIN (basetypes); - while (types) - { - if (! TREE_VIA_PUBLIC (types)) - { - if (visibility == visibility_private) - { - visibility = visibility_private; - goto ret; - } - visibility = visibility_private; - } - if (TYPE_MAIN_VARIANT (TREE_VALUE (types)) == context) - { - visibility = visibility_public; - goto ret; - } - types = TREE_CHAIN (types); - } - abort (); - } - - ret: - nreverse (basetypes); - - if (visibility == visibility_public) - TREE_FIELD_PUBLIC (field) = 1; - else if (visibility == visibility_protected) - TREE_FIELD_PROTECTED (field) = 1; - else if (visibility == visibility_private) - TREE_FIELD_PRIVATE (field) = 1; - else abort (); - return visibility; -} - -/* Make an entry in the memoized table for type TYPE - that the entry for NAME is FIELD. */ - -tree -make_memoized_table_entry (type, name, function_p) - tree type, name; - int function_p; -{ - int index = MEMOIZED_HASH_FN (name); - tree entry, *prev_entry; - - memoized_adds[function_p] += 1; - if (CLASSTYPE_MTABLE_ENTRY (type) == NULL_TREE) - { - obstack_ptr_grow (&type_obstack, type); - obstack_blank (&type_obstack, sizeof (struct memoized_entry *)); - CLASSTYPE_MTABLE_ENTRY (type) = my_new_memoized_entry (0); - type_stack->len++; - if (type_stack->len * 2 >= type_stack->base.limit) - abort (); - } - if (function_p) - prev_entry = &MEMOIZED_FNFIELDS (CLASSTYPE_MTABLE_ENTRY (type), index); - else - prev_entry = &MEMOIZED_FIELDS (CLASSTYPE_MTABLE_ENTRY (type), index); - - entry = my_tree_cons (name, 0, *prev_entry); - *prev_entry = entry; - - /* Don't know the error message to give yet. */ - TREE_TYPE (entry) = error_mark_node; - - return entry; -} - -tree -lookup_field (xbasetype, name, protect) - register tree xbasetype, name; - int protect; -{ - int head = 0, tail = 0; - tree type, rval; - tree basetype, basetypes; - enum visibility_type this_v = visibility_default; - tree entry; - enum visibility_type own_visibility = visibility_default; - int vbase_name_p = VBASE_NAME_P (name); - - /* Things for memoization. */ - char *errstr = 0; - - /* Set this to nonzero if we don't know how to compute - accurate error messages for visibility. */ - int index = MEMOIZED_HASH_FN (name); - - if (TREE_CODE (xbasetype) == TREE_LIST) - basetypes = xbasetype, basetype = TREE_VALUE (xbasetype); - else - basetypes = CLASSTYPE_AS_LIST (xbasetype), basetype = xbasetype; - - if (CLASSTYPE_MTABLE_ENTRY (basetype)) - { - tree tem = MEMOIZED_FIELDS (CLASSTYPE_MTABLE_ENTRY (basetype), index); - - while (tem && TREE_PURPOSE (tem) != name) - { - memoized_fields_searched[0]++; - tem = TREE_CHAIN (tem); - } - if (tem) - { - if (protect && TREE_TYPE (tem)) - { - error (TREE_STRING_POINTER (TREE_TYPE (tem)), - IDENTIFIER_POINTER (name), - TYPE_NAME_STRING (DECL_FIELD_CONTEXT (TREE_VALUE (tem)))); - return error_mark_node; - } - if (TREE_VALUE (tem) == NULL_TREE) - memoized_fast_rejects[0] += 1; - else - memoized_fast_finds[0] += 1; - return TREE_VALUE (tem); - } - } - -#ifdef GATHER_STATISTICS - n_calls_lookup_field++; -#endif - if (flag_memoize_lookups && ! global_bindings_p ()) - entry = make_memoized_table_entry (basetype, name, 0); - else - entry = 0; - - rval = lookup_field_1 (basetype, name); - - if (rval) - { - if (flag_memoize_lookups || protect) - { - if (TREE_PRIVATE (rval) | TREE_PROTECTED (rval)) - this_v = compute_visibility (basetypes, rval); - if (TREE_CODE (rval) == CONST_DECL) - { - if (this_v == visibility_private) - errstr = "enum `%s' is a private value of class `%s'"; - else if (this_v == visibility_protected) - errstr = "enum `%s' is a protected value of class `%s'"; - } - else - { - if (this_v == visibility_private) - errstr = "member `%s' is a private member of class `%s'"; - else if (this_v == visibility_protected) - errstr = "member `%s' is a protected member of class `%s'"; - } - } - - if (entry) - { - if (errstr) - { - /* This depends on behavior of lookup_field_1! */ - tree error_string = my_build_string (errstr); - TREE_TYPE (entry) = error_string; - } - else - { - /* Let entry know there is no problem with this access. */ - TREE_TYPE (entry) = NULL_TREE; -#if 0 - /* And since everything is ok, bear the - cost of generating correct code. */ - if (DECL_OFFSET (TYPE_NAME (basetype)) != 0 - || TREE_VIA_VIRTUAL (basetype)) - { - rval = my_copy_node (rval); - DECL_FIELD_CONTEXT (rval) = basetype; - } -#endif - } - TREE_VALUE (entry) = rval; - } -#if 0 - else if ((DECL_OFFSET (TYPE_NAME (basetype)) != 0 - || TREE_VIA_VIRTUAL (basetype)) - && ! (errstr && protect)) - { - rval = my_copy_node (rval); - DECL_FIELD_CONTEXT (rval) = basetype; - } -#endif - - if (errstr && protect) - { - error (errstr, IDENTIFIER_POINTER (name), TYPE_NAME_STRING (basetype)); - return error_mark_node; - } - return rval; - } - - type = TYPE_MAIN_VARIANT (basetype); - - search_stack = push_search_level (search_stack, &search_obstack); - TREE_VIA_PUBLIC (basetypes) = 1; - - while (1) - { - int i, n_baselinks = CLASSTYPE_N_BASECLASSES (type); - - /* Process and/or queue base types. */ - for (i = 1; i <= n_baselinks; i++) - { - if (CLASSTYPE_MARKED2 (CLASSTYPE_BASECLASS (type, i)) == 0) - { - tree btypes; - - CLASSTYPE_MARKED2 (CLASSTYPE_BASECLASS (type, i)) = 1; - btypes = my_tree_cons (NULL_TREE, CLASSTYPE_BASECLASS (type, i), - basetypes); - TREE_VIA_PUBLIC (btypes) = CLASSTYPE_VIA_PUBLIC (type, i); - TREE_VIA_VIRTUAL (btypes) = CLASSTYPE_VIA_VIRTUAL (type, i); - obstack_ptr_grow (&search_obstack, btypes); - tail += 1; - if (tail >= search_stack->limit) - abort (); - } - } - - /* Process head of queue, if one exists. */ - if (head >= tail) - break; - - basetypes = search_stack->first[head++]; - type = TREE_VALUE (basetypes); - - /* See if we can find NAME in TYPE. If RVAL is nonzero, - and we do find NAME in TYPE, verify that such a second - sighting is in fact legal. */ - - if (rval) - { - /* Just another way of finding the same member. */ - if (DECL_FIELD_CONTEXT (rval) == type) - { - enum visibility_type new_v - = compute_visibility (basetypes, rval); - if (this_v != new_v) - errstr = "conflicting visibilities to member `%s'"; - } - /* Same baseclass, different places in the lattice. */ - else if (DECL_FIELD_CONTEXT (rval) == TYPE_MAIN_VARIANT (type)) - errstr = "member `%s' belongs to distinct base classes `%s'"; - else - { - tree nval = lookup_field_1 (type, name); - - if (nval && get_base_type (type, DECL_FIELD_CONTEXT (rval), 0) == 0) - { - /* We found it in other than a baseclass of RVAL's. */ - errstr = "request for member `%s' is ambiguous"; - } - } - if (errstr && entry) - { - tree error_string = my_build_string (errstr); - TREE_TYPE (entry) = error_string; - } - if (errstr && protect) - break; - } - else - { - rval = lookup_field_1 (type, name); - if (rval) - { -#if 0 - if (DECL_OFFSET (TYPE_NAME (type)) != 0 - || TREE_VIA_VIRTUAL (type)) - { - rval = my_copy_node (rval); - DECL_FIELD_CONTEXT (rval) = type; - } -#endif - - if (entry || protect) - this_v = compute_visibility (basetypes, rval); - if (entry) - TREE_VALUE (entry) = rval; - - /* These may look ambiguous, but they really are not. */ - if (vbase_name_p) - break; - } - } - } - { - tree *tp = search_stack->first; - tree *search_tail = tp + tail; - - /* If this FIELD_DECL defines its own visibility, deal with that. */ - if (rval && errstr == 0 - && DECL_VISIBILITY (rval) - && (protect || entry)) - { - while (tp < search_tail) - { - /* If is possible for one of the derived types on the - path to have defined special visibility for this - field. Look for such declarations and report an - error if a conflict is found. */ - enum visibility_type new_v; - - if (this_v != visibility_default) - new_v = compute_visibility (*tp, rval); - if (this_v != visibility_default && new_v != this_v) - { - errstr = "conflicting visibilities to member `%s'"; - this_v = visibility_default; - } - own_visibility = new_v; - CLASSTYPE_MARKED2 (TREE_VALUE (*tp++)) = 0; - } - } - else - { - while (tp < search_tail) - CLASSTYPE_MARKED2 (TREE_VALUE (*tp++)) = 0; - } - } - search_stack = pop_search_level (search_stack); - - if (errstr == 0) - { - if (own_visibility == visibility_private) - errstr = "member `%s' declared private"; - else if (own_visibility == visibility_protected) - errstr = "member `%s' declared protected"; - else if (this_v == visibility_private) - errstr = TREE_PRIVATE (rval) ? "member `%s' is private" : "member `%s' is from private base class"; - else if (this_v == visibility_protected) - errstr = "member `%s' is protected"; - } - - if (entry) - { - if (errstr) - { - tree error_string = my_build_string (errstr); - /* Save error message with entry. */ - TREE_TYPE (entry) = error_string; - } - else - { - /* Mark entry as having no error string. */ - TREE_TYPE (entry) = NULL_TREE; - } - } - - if (errstr && protect) - { - error (errstr, IDENTIFIER_POINTER (name), TYPE_NAME_STRING (type)); - rval = error_mark_node; - } - return rval; -} - -/* TYPE is a class type. Return the index of the fields within - the method vector with name NAME, or -1 is no such field exists. */ -static int -lookup_fnfields_1 (type, name) - tree type, name; -{ - register tree method_vec = CLASSTYPE_METHOD_VEC (type); - - if (method_vec != 0) - { - register tree *methods = &TREE_VEC_ELT (method_vec, 0); - register tree *end = TREE_VEC_END (method_vec); - -#ifdef GATHER_STATISTICS - n_calls_lookup_fnfields_1++; -#endif - if (*methods == 0) - methods++; - while (methods != end) - { -#ifdef GATHER_STATISTICS - n_outer_fields_searched++; -#endif - if (DECL_ORIGINAL_NAME (*methods) == name) - break; - methods++; - } - if (methods != end) - return methods - &TREE_VEC_ELT (method_vec, 0); - } - - return -1; -} - -/* Given a list of member functions FIELDS (which are implicitly - named TREE_PURPOSE (FIELDS), and come from base type - DECL_FIELD_CONTEXT (TREE_VALUE (FIELDS))), attempt to find the - actual method which can accept (using conversions) PARMS. - The types of PARMS are already computed in PARMTYPES. */ -tree -lookup_fnfield (fields, parms, parmtypes) - tree fields, parms, parmtypes; -{ - abort (); -} - -/* Starting from BASETYPE, return a TREE_BASELINK-like object - which gives the following information (in a list): - - TREE_TYPE: list of basetypes needed to get to... - TREE_VALUE: list of all functions in of given type - which have name NAME. - - No visibility information is computed by this function, - other then to adorn the list of basetypes with - TREE_VIA_PUBLIC. - - If FIND_AMBIGUOUS is non-zero, then if we find two ways to get - to the same member function, both those ways are found, - and the caller must know what to do about this. */ -tree -lookup_fnfields (basetypes, name, find_ambiguous) - tree basetypes, name; - int find_ambiguous; -{ - int head = 0, tail = 0; - tree type, rval, rvals = NULL_TREE; - tree basetype; - tree entry; - - /* For now, don't try this. */ - int protect = find_ambiguous; - - /* Things for memoization. */ - char *errstr = 0; - - /* Set this to nonzero if we don't know how to compute - accurate error messages for visibility. */ - int index = MEMOIZED_HASH_FN (name); - - basetype = TREE_VALUE (basetypes); - - if (CLASSTYPE_MTABLE_ENTRY (basetype)) - { - tree tem = MEMOIZED_FNFIELDS (CLASSTYPE_MTABLE_ENTRY (basetype), index); - - while (tem && TREE_PURPOSE (tem) != name) - { - memoized_fields_searched[1]++; - tem = TREE_CHAIN (tem); - } - if (tem) - { - if (protect && TREE_TYPE (tem)) - { - error (TREE_STRING_POINTER (TREE_TYPE (tem)), - IDENTIFIER_POINTER (name), - TYPE_NAME_STRING (DECL_FIELD_CONTEXT (TREE_VALUE (TREE_VALUE (tem))))); - return error_mark_node; - } - if (TREE_VALUE (tem) == NULL_TREE) - { - memoized_fast_rejects[1] += 1; - return NULL_TREE; - } - else - { - /* Want to return this, but we must make sure - that visibility information is consistent. */ - tree baselink = TREE_VALUE (tem); - tree memoized_basetypes = TREE_PURPOSE (baselink); - tree these_basetypes = basetypes; - while (memoized_basetypes && these_basetypes) - { - memoized_fields_searched[1]++; - if (TREE_VALUE (memoized_basetypes) != TREE_VALUE (these_basetypes)) - break; - memoized_basetypes = TREE_CHAIN (memoized_basetypes); - these_basetypes = TREE_CHAIN (these_basetypes); - } - if (memoized_basetypes == these_basetypes) - { - memoized_fast_finds[1] += 1; - return TREE_VALUE (tem); - } - /* else, we must re-find this field by hand. */ - baselink = tree_cons (basetypes, TREE_VALUE (baselink), TREE_CHAIN (baselink)); - return baselink; - } - } - } - -#ifdef GATHER_STATISTICS - n_calls_lookup_fnfields++; -#endif - if (flag_memoize_lookups && ! global_bindings_p ()) - entry = make_memoized_table_entry (basetype, name, 1); - else - entry = 0; - - index = lookup_fnfields_1 (basetype, name); - - if (index >= 0) - { - rval = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype), index); - rvals = my_tree_cons (basetypes, rval, NULL_TREE); - if (CLASSTYPE_BASELINK_VEC (basetype)) - TREE_TYPE (rvals) = TREE_VEC_ELT (CLASSTYPE_BASELINK_VEC (basetype), index); - - if (entry) - { - TREE_VALUE (entry) = rvals; - TREE_TYPE (entry) = NULL_TREE; - } - - if (errstr && protect) - { - error (errstr, IDENTIFIER_POINTER (name), TYPE_NAME_STRING (basetype)); - return error_mark_node; - } - return rvals; - } - rval = NULL_TREE; - type = TYPE_MAIN_VARIANT (basetype); - - search_stack = push_search_level (search_stack, &search_obstack); - TREE_VIA_PUBLIC (basetypes) = 1; - - while (1) - { - int i, n_baselinks = CLASSTYPE_N_BASECLASSES (type); - - /* Process and/or queue base types. */ - for (i = 1; i <= n_baselinks; i++) - { - if (CLASSTYPE_MARKED2 (CLASSTYPE_BASECLASS (type, i)) == 0) - { - tree btypes; - - CLASSTYPE_MARKED2 (CLASSTYPE_BASECLASS (type, i)) = 1; - btypes = my_tree_cons (NULL_TREE, CLASSTYPE_BASECLASS (type, i), - basetypes); - TREE_VIA_PUBLIC (btypes) = CLASSTYPE_VIA_PUBLIC (type, i); - TREE_VIA_VIRTUAL (btypes) = CLASSTYPE_VIA_VIRTUAL (type, i); - obstack_ptr_grow (&search_obstack, btypes); - tail += 1; - if (tail >= search_stack->limit) - abort (); - } - } - - /* Process head of queue, if one exists. */ - if (head >= tail) - break; - - basetypes = search_stack->first[head++]; - type = TREE_VALUE (basetypes); - - /* See if we can find NAME in TYPE. If RVAL is nonzero, - and we do find NAME in TYPE, verify that such a second - sighting is in fact legal. */ - - if (rval) - { - tree context = DECL_FIELD_CONTEXT (rval); - /* Just another way of finding the same member. */ - if (context == type) - ; - /* Same baseclass, maybe different places in the lattice. */ - else if (context == TYPE_MAIN_VARIANT (type)) - { - if (TREE_VIA_VIRTUAL (TREE_PURPOSE (rvals))) - if (TREE_VIA_VIRTUAL (basetypes)) - ; - else - errstr = "member `%s' belongs to virtual and non-virtual baseclasses `%s'"; - else if (TREE_VIA_VIRTUAL (basetypes)) - errstr = "member `%s' belongs to virtual and non-virtual baseclasses `%s'"; - else - errstr = "member `%s' belongs to MI-distinct base classes `%s'"; - } - else - { - int index = lookup_fnfields_1 (type, name); - - if (index >= 0 && get_base_type (type, context, 0) == 0) - { - /* We found it in other than a baseclass of RVAL's. */ - rvals = my_tree_cons (basetypes, TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), index), rvals); - if (CLASSTYPE_BASELINK_VEC (type)) - TREE_TYPE (rvals) = TREE_VEC_ELT (CLASSTYPE_BASELINK_VEC (type), index); - } - } - if (errstr && entry) - { - tree error_string = my_build_string (errstr); - TREE_TYPE (entry) = error_string; - } - if (errstr && find_ambiguous) - { - rvals = error_mark_node; - break; - } - } - else - { - int index = lookup_fnfields_1 (type, name); - if (index >= 0) - { - rval = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), index); - rvals = my_tree_cons (basetypes, rval, NULL_TREE); - if (CLASSTYPE_BASELINK_VEC (type)) - TREE_TYPE (rvals) = TREE_VEC_ELT (CLASSTYPE_BASELINK_VEC (type), index); - if (entry) - TREE_VALUE (entry) = rvals; - } - else - rval = NULL_TREE; - } - } - { - tree *tp = search_stack->first; - tree *search_tail = tp + tail; - - while (tp < search_tail) - CLASSTYPE_MARKED2 (TREE_VALUE (*tp++)) = 0; - } - search_stack = pop_search_level (search_stack); - - if (entry) - { - if (errstr) - { - tree error_string = my_build_string (errstr); - /* Save error message with entry. */ - TREE_TYPE (entry) = error_string; - } - else - { - /* Mark entry as having no error string. */ - TREE_TYPE (entry) = NULL_TREE; - } - } - - if (errstr && protect) - { - error (errstr, IDENTIFIER_POINTER (name), TYPE_NAME_STRING (type)); - rvals = error_mark_node; - } - - return rvals; -} - -/* BREADTH-FIRST SEARCH ROUTINES. */ - -/* Search a multiple inheritance hierarchy by breadth-first search. - - TYPE is an aggregate type, possibly in a multiple-inheritance hierarchy. - TESTFN is a function, which, if true, means that our condition has been met, - and its return value should be returned. - QFN, if non-NULL, is a predicate dictating whether the type should - even be queued. */ - -int -breadth_first_search (type, testfn, qfn) - tree type; - int (*testfn)(); - int (*qfn)(); -{ - int head = 0, tail = 0; - int rval = 0; - - search_stack = push_search_level (search_stack, &search_obstack); - - while (1) - { - int n_baselinks = CLASSTYPE_N_BASECLASSES (type); - int i; - - /* Process and/or queue base types. */ - for (i = 1; i <= n_baselinks; i++) - if (CLASSTYPE_MARKED (CLASSTYPE_BASECLASS (type, i)) == 0 - && (qfn == 0 || (*qfn) (type, i))) - { - CLASSTYPE_MARKED (CLASSTYPE_BASECLASS (type, i)) = 1; - obstack_ptr_grow (&search_obstack, type); - obstack_int_grow (&search_obstack, i); - tail += 2; - if (tail >= search_stack->limit) - abort (); - } - - /* Process head of queue, if one exists. */ - if (head >= tail) - { - rval = 0; - break; - } - - type = search_stack->first[head++]; - i = (int)search_stack->first[head++]; - if (rval = (*testfn) (type, i)) - break; - type = CLASSTYPE_BASECLASS (type, i); - } - { - tree *tp = search_stack->first; - tree *search_tail = tp + tail; - while (tp < search_tail) - { - tree type = *tp++; - int i = (int)(*tp++); - CLASSTYPE_MARKED (CLASSTYPE_BASECLASS (type, i)) = 0; - } - } - - search_stack = pop_search_level (search_stack); - return rval; -} - -/* Functions to use in breadth first searches. */ -typedef tree (*pft)(); -typedef int (*pfi)(); - -int tree_needs_constructor_p (type, i) - tree type; -{ - tree basetype = i == 0 ? type : CLASSTYPE_BASECLASS (type, i); - return TYPE_NEEDS_CONSTRUCTOR (basetype); -} - -static tree declarator; - -static tree -get_virtuals_named_this (type, i) - tree type; - int i; -{ - tree basetype = i == 0? type : CLASSTYPE_BASECLASS (type, i); - tree fields = lookup_fnfields (CLASSTYPE_AS_LIST (basetype), declarator, 0); - - if (fields == 0 || fields == error_mark_node) - return 0; - - /* Get to the function decls, and return the first virtual function - with this name, if there is one. */ - while (fields) - { - tree fndecl; - - for (fndecl = TREE_VALUE (fields); fndecl; fndecl = TREE_CHAIN (fndecl)) - if (DECL_VIRTUAL_P (fndecl)) - return fields; - fields = next_baselink (fields); - } - return NULL_TREE; -} - -static tree get_virtual_destructor (type, i) - tree type; - int i; -{ - type = i == 0 ? type : CLASSTYPE_BASECLASS (type, i); - if (TYPE_HAS_DESTRUCTOR (type) - && DECL_VIRTUAL_P (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), 0))) - return TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), 0); - return 0; -} - -int tree_has_any_destructor_p (type, i) - tree type; - int i; -{ - if (i == 0) - return TYPE_NEEDS_DESTRUCTOR (type); - return TYPE_NEEDS_DESTRUCTOR (CLASSTYPE_BASECLASS (type, i)); -} - -/* Given a class type TYPE, and a function decl FNDECL, - look for the first function the TYPE's heirarchy which - FNDECL could match as a virtual function. - - DTORP is nonzero if we are looking for a destructor. Destructors - need special treatment because they do not match by name. */ -tree -get_first_matching_virtual (type, fndecl, dtorp) - tree type, fndecl; - int dtorp; -{ - tree tmp = NULL_TREE; - - /* Breadth first search routines start searching basetypes - of TYPE, so we must perform first ply of search here. */ - if (dtorp) - { - if (tree_has_any_destructor_p (type, 0)) - tmp = get_virtual_destructor (type, 0); - - if (tmp) - return tmp; - - tmp = (tree) breadth_first_search (type, - (pfi) get_virtual_destructor, - tree_has_any_destructor_p); - return tmp; - } - else - { - tree drettype, dtypes, btypes, instptr_type; - tree basetype = TYPE_METHOD_BASETYPE (fndecl); - tree baselink, best = NULL_TREE; - tree name = DECL_NAME (fndecl); - - declarator = DECL_ORIGINAL_NAME (fndecl); - if (DECL_VIRTUAL_P (declarator) == 0) - return 0; - - drettype = TREE_TYPE (TREE_TYPE (fndecl)); - dtypes = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); - if (DECL_STATIC_FUNCTION_P (fndecl)) - instptr_type = NULL_TREE; - else - instptr_type = TREE_TYPE (TREE_VALUE (dtypes)); - - for (baselink = get_virtuals_named_this (type, 0); - baselink; baselink = next_baselink (baselink)) - { - for (tmp = TREE_VALUE (baselink); tmp; tmp = TREE_CHAIN (tmp)) - { - if (! DECL_VIRTUAL_P (tmp)) - continue; - - btypes = TYPE_ARG_TYPES (TREE_TYPE (tmp)); - if (instptr_type == NULL_TREE - && compparms (TREE_CHAIN (btypes), dtypes, 1)) - /* Caller knows to give error in this case. */ - return tmp; - - if ((TREE_READONLY (TREE_TYPE (TREE_VALUE (btypes))) - == TREE_READONLY (instptr_type)) - && compparms (TREE_CHAIN (btypes), TREE_CHAIN (dtypes), 1)) - { - if (IDENTIFIER_ERROR_LOCUS (name) == NULL_TREE - && ! comptypes (TREE_TYPE (TREE_TYPE (tmp)), drettype, 1)) - { - error_with_decl (fndecl, "conflicting return type specified for virtual function `%s'"); - SET_IDENTIFIER_ERROR_LOCUS (name, basetype); - } - break; - } - } - if (tmp) - { - /* If this is ambiguous, we will warn about it later. */ - if (best) - { - if (get_base_distance (TYPE_METHOD_BASETYPE (TREE_TYPE (best)), - TYPE_METHOD_BASETYPE (TREE_TYPE (tmp)), 0, 0) > 0) - best = tmp; - } - else - best = tmp; - } - } - if (IDENTIFIER_ERROR_LOCUS (name) == NULL_TREE - && best == NULL_TREE && warn_overloaded_virtual) - { - error_with_decl (fndecl, "conficting specification deriving virtual function `%s'"); - SET_IDENTIFIER_ERROR_LOCUS (name, basetype); - } - return best; - } -} - -/* Return the list of virtual functions which are abstract in type TYPE. - This information is cached, and so must be built on a - non-temporary obstack. */ -tree -get_abstract_virtuals (type) - tree type; -{ - /* For each layer of base class (i.e., the first base class, and each - virtual base class from that one), modify the virtual function table - of the derived class to contain the new virtual function. - A class has as many vfields as it has virtual base classes (total). */ - tree vfields, vbases, base, tmp; - tree vfield = CLASSTYPE_VFIELD (type); - tree fcontext = vfield ? DECL_FCONTEXT (vfield) : NULL_TREE; - tree abstract_virtuals = CLASSTYPE_ABSTRACT_VIRTUALS (type); - - for (vfields = CLASSTYPE_VFIELDS (type); vfields; vfields = TREE_CHAIN (vfields)) - { - int normal; - - /* Find the right base class for this derived class, call it BASE. */ - base = TREE_VALUE (vfields); - if (base == type) - continue; - - /* We call this case NORMAL iff this virtual function table - pointer field has its storage reserved in this class. - This is normally the case without virtual baseclasses - or off-center multiple baseclasses. */ - normal = (base == fcontext - && (TREE_PURPOSE (vfields) == NULL_TREE - || ! TREE_VIA_VIRTUAL (TREE_PURPOSE (vfields)))); - - if (normal) - tmp = TREE_CHAIN (CLASS_ASSOC_VIRTUALS (type)); - else - { - tree assoc = assoc_value (base, type); - tmp = TREE_CHAIN (ASSOC_VIRTUALS (assoc)); - } - - while (tmp) - { - tree base_pfn = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (tmp)); - tree base_fndecl = TREE_OPERAND (base_pfn, 0); - if (DECL_ABSTRACT_VIRTUAL_P (base_fndecl)) - abstract_virtuals = tree_cons (NULL_TREE, base_fndecl, abstract_virtuals); - tmp = TREE_CHAIN (tmp); - } - } - for (vbases = CLASSTYPE_VBASECLASSES (type); vbases; vbases = TREE_CHAIN (vbases)) - { - if (! ASSOC_VIRTUALS (vbases)); - continue; - - base = TREE_TYPE (vbases); - tmp = TREE_CHAIN (ASSOC_VIRTUALS (vbases)); - while (tmp) - { - tree base_pfn = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (tmp)); - tree base_fndecl = TREE_OPERAND (base_pfn, 0); - if (DECL_ABSTRACT_VIRTUAL_P (base_fndecl)) - abstract_virtuals = tree_cons (NULL_TREE, base_fndecl, abstract_virtuals); - tmp = TREE_CHAIN (tmp); - } - } - return nreverse (abstract_virtuals); -} - -/* For the type TYPE, return a list of member functions available from - base classes with name NAME. The TREE_VALUE of the list is a chain of - member functions with name NAME. The TREE_PURPOSE of the list is a - basetype, or a list of base types (in reverse order) which were - traversed to reach the chain of member functions. If we reach a base - type which provides a member function of name NAME, and which has at - most one base type itself, then we can terminate the search. */ - -tree -get_baselinks (type, name) - tree type, name; -{ - tree hash_tree_cons (); - int head = 0, tail = 0, index; - tree rval = 0, nval = 0; - tree basetypes = CLASSTYPE_AS_LIST (type); - - search_stack = push_search_level (search_stack, &search_obstack); - - while (1) - { - int i, n_baselinks = CLASSTYPE_N_BASECLASSES (type); - - /* Process and/or queue base types. */ - for (i = 1; i <= n_baselinks; i++) - if (CLASSTYPE_MARKED (CLASSTYPE_BASECLASS (type, i)) == 0) - { - tree btypes; - - btypes = hash_tree_cons (CLASSTYPE_VIA_PUBLIC (type, i), - CLASSTYPE_VIA_VIRTUAL (type, i), - NULL_TREE, CLASSTYPE_BASECLASS (type, i), - basetypes); - CLASSTYPE_MARKED (CLASSTYPE_BASECLASS (type, i)) = 1; - obstack_ptr_grow (&search_obstack, btypes); - - tail += 1; - if (tail >= search_stack->limit) - abort (); - } - - dont_queue: - /* Process head of queue, if one exists. */ - if (head >= tail) - break; - - basetypes = search_stack->first[head++]; - type = TREE_VALUE (basetypes); - index = lookup_fnfields_1 (type, name); - if (index >= 0) - { - nval = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), index); - rval = hash_tree_cons (0, 0, basetypes, nval, rval); - if (CLASSTYPE_N_BASECLASSES (type) <= 1) - { - if (CLASSTYPE_BASELINK_VEC (type)) - TREE_TYPE (rval) = TREE_VEC_ELT (CLASSTYPE_BASELINK_VEC (type), index); - goto dont_queue; - } - } - nval = NULL_TREE; - } - { - tree *tp = search_stack->first; - tree *search_tail = tp + tail; - - while (tp < search_tail) - { - CLASSTYPE_MARKED (TREE_VALUE (*tp++)) = 0; - } - } - search_stack = pop_search_level (search_stack); - return rval; -} - -tree -next_baselink (baselink) - tree baselink; -{ - tree tmp = TREE_TYPE (baselink); - baselink = TREE_CHAIN (baselink); - while (tmp) - { - /* @@ does not yet add previous base types. */ - baselink = tree_cons (TREE_PURPOSE (tmp), TREE_VALUE (tmp), - baselink); - TREE_TYPE (baselink) = TREE_TYPE (tmp); - tmp = TREE_CHAIN (tmp); - } - return baselink; -} - -/* DEPTH-FIRST SEARCH ROUTINES. */ - -/* Assign unique numbers to _CLASSTYPE members of the lattice - specified by TYPE. The root nodes are marked first; the nodes - are marked depth-fisrt, left-right. */ - -static int cid; - -/* Matrix implementing a relation from CLASSTYPE X CLASSTYPE => INT. - Relation yields 1 if C1 <= C2, 0 otherwise. */ -typedef char mi_boolean; -static mi_boolean *mi_matrix; - -/* Type for which this matrix is defined. */ -static tree mi_type; - -/* Size of the matrix for indexing purposes. */ -static int mi_size; - -/* Return nonzero if class C2 derives from class C1. */ -#define DERIVES_FROM(C1, C2) \ - ((mi_matrix+mi_size*(CLASSTYPE_CID (C1)-1))[CLASSTYPE_CID (C2)-1]) -#define DERIVES_FROM_STAR(C) \ - (mi_matrix+(CLASSTYPE_CID (C)-1)) - -/* The main function which implements depth first search. */ -static void -dfs_walk (type, fn, qfn) - tree type; - void (*fn)(); - int (*qfn)(); -{ - int i, n_baselinks = CLASSTYPE_N_BASECLASSES (type); - - for (i = 1; i <= n_baselinks; i++) - if ((*qfn)(CLASSTYPE_BASECLASS (type, i))) - { - dfs_walk (CLASSTYPE_BASECLASS (type, i), fn, qfn); - } - - fn (type); -} - -/* Predicate functions which serve for dfs_walk. */ -static int numberedp (type) tree type; -{ return CLASSTYPE_CID (type); } -static int unnumberedp (type) tree type; -{ return CLASSTYPE_CID (type) == 0; } - -static int markedp (type) tree type; -{ return CLASSTYPE_MARKED (type); } -static int bfs_markedp (type, i) tree type; int i; -{ return CLASSTYPE_MARKED (CLASSTYPE_BASECLASS (type, i)); } -static int unmarkedp (type) tree type; -{ return CLASSTYPE_MARKED (type) == 0; } -static int bfs_unmarkedp (type, i) tree type; int i; -{ return CLASSTYPE_MARKED (CLASSTYPE_BASECLASS (type, i)) == 0; } -static int marked2p (type) tree type; -{ return CLASSTYPE_MARKED2 (type); } -static int bfs_marked2p (type, i) tree type; int i; -{ return CLASSTYPE_MARKED2 (CLASSTYPE_BASECLASS (type, i)); } -static int unmarked2p (type) tree type; -{ return CLASSTYPE_MARKED2 (type) == 0; } -static int bfs_unmarked2p (type, i) tree type; int i; -{ return CLASSTYPE_MARKED2 (CLASSTYPE_BASECLASS (type, i)) == 0; } -static int marked3p (type) tree type; -{ return CLASSTYPE_MARKED3 (type); } -static int bfs_marked3p (type, i) tree type; int i; -{ return CLASSTYPE_MARKED3 (CLASSTYPE_BASECLASS (type, i)); } -static int unmarked3p (type) tree type; -{ return CLASSTYPE_MARKED3 (type) == 0; } -static int bfs_unmarked3p (type, i) tree type; int i; -{ return CLASSTYPE_MARKED3 (CLASSTYPE_BASECLASS (type, i)) == 0; } -static int marked4p (type) tree type; -{ return CLASSTYPE_MARKED4 (type); } -static int bfs_marked4p (type, i) tree type; int i; -{ return CLASSTYPE_MARKED4 (CLASSTYPE_BASECLASS (type, i)); } -static int unmarked4p (type) tree type; -{ return CLASSTYPE_MARKED4 (type) == 0; } -static int bfs_unmarked4p (type, i) tree type; int i; -{ return CLASSTYPE_MARKED4 (CLASSTYPE_BASECLASS (type, i)) == 0; } - -static int dfs_search_slot_nonempty_p (type) tree type; -{ return CLASSTYPE_SEARCH_SLOT (type) != 0; } - - -/* The worker functions for `dfs_walk'. These do not need to - test anything (vis a vis marking) if they are paired with - a predicate function (above). */ - -/* Assign each type within the lattice a number which is unique - in the lattice. The first number assigned is 1. */ - -static void -dfs_number (type) - tree type; -{ - CLASSTYPE_CID (type) = ++cid; -} - -static void -dfs_unnumber (type) - tree type; -{ - CLASSTYPE_CID (type) = 0; -} - -static void -dfs_mark (type) tree type; -{ CLASSTYPE_MARKED (type) = 1; } - -static void -dfs_unmark (type) tree type; -{ CLASSTYPE_MARKED (type) = 0; } - -static void -dfs_mark2 (type) tree type; -{ CLASSTYPE_MARKED2 (type) = 1; } - -static void -dfs_unmark2 (type) tree type; -{ CLASSTYPE_MARKED2 (type) = 0; } - -static void -dfs_mark3 (type) tree type; -{ CLASSTYPE_MARKED3 (type) = 1; } - -static void -dfs_unmark3 (type) tree type; -{ CLASSTYPE_MARKED3 (type) = 0; } - -static void -dfs_mark4 (type) tree type; -{ CLASSTYPE_MARKED4 (type) = 1; } - -static void -dfs_unmark4 (type) tree type; -{ CLASSTYPE_MARKED4 (type) = 0; } - -static void -dfs_unmark12 (type) tree type; -{ CLASSTYPE_MARKED (type) = 0; - CLASSTYPE_MARKED2 (type) = 0; } - -static void -dfs_unmark34 (type) tree type; -{ CLASSTYPE_MARKED3 (type) = 0; - CLASSTYPE_MARKED4 (type) = 0; } - -static tree -dfs_clear_search_slot (type) tree type; -{ CLASSTYPE_SEARCH_SLOT (type) = 0; } - -static tree vbase_types; -static tree vbase_decl, vbase_decl_ptr; -static tree vbase_init_result; - -static void -dfs_find_vbases (type) - tree type; -{ - int i, n_baselinks = CLASSTYPE_N_BASECLASSES (type); - - for (i = n_baselinks; i > 0; i--) - if (CLASSTYPE_VIA_VIRTUAL (type, i) - && CLASSTYPE_SEARCH_SLOT (CLASSTYPE_BASECLASS (type, i)) == 0) - { - tree vbase = CLASSTYPE_BASECLASS (type, i); - /* ??? ASSOC_VALUE and TREE_VALUE must be the same for this to work. */ - tree assoc = value_member (TYPE_MAIN_VARIANT (vbase), vbase_types); - - CLASSTYPE_SEARCH_SLOT (vbase) - = build (PLUS_EXPR, TYPE_POINTER_TO (vbase), - vbase_decl_ptr, ASSOC_OFFSET (assoc)); - } - CLASSTYPE_MARKED3 (type) = 1; - CLASSTYPE_MARKED4 (type) = 1; -} - -static void -dfs_init_vbase_pointers (type) - tree type; -{ - tree fields = TYPE_FIELDS (type); - tree path, this_vbase_ptr; - int distance; - - CLASSTYPE_MARKED3 (type) = 0; - - if (fields == NULL_TREE - || DECL_NAME (fields) == NULL_TREE - || ! VBASE_NAME_P (DECL_NAME (fields))) - return; - - distance = get_base_distance (type, TREE_TYPE (vbase_decl), 0, &path); - while (path) - { - if (TREE_VIA_VIRTUAL (path)) - break; - distance -= 1; - path = TREE_CHAIN (path); - } - - if (distance > 0) - this_vbase_ptr = convert_pointer_to (type, CLASSTYPE_SEARCH_SLOT (TREE_VALUE (path))); - else - this_vbase_ptr = convert_pointer_to (type, vbase_decl_ptr); - - while (fields && DECL_NAME (fields) - && VBASE_NAME_P (DECL_NAME (fields))) - { - tree ref = build (COMPONENT_REF, TREE_TYPE (fields), - build_indirect_ref (this_vbase_ptr, 0), fields); - tree init = CLASSTYPE_SEARCH_SLOT (TREE_TYPE (TREE_TYPE (fields))); - vbase_init_result = tree_cons (TREE_TYPE (TREE_TYPE (fields)), - build_modify_expr (ref, NOP_EXPR, init), - vbase_init_result); - fields = TREE_CHAIN (fields); - } -} - -/* Sometimes this needs to clear both 3 and 4. Other times, - just 4, but optimizer should make both with equal efficiency - (though it does not currently). */ -static void -dfs_clear_vbase_slots (type) - tree type; -{ - CLASSTYPE_SEARCH_SLOT (type) = 0; - CLASSTYPE_MARKED3 (type) = 0; - CLASSTYPE_MARKED4 (type) = 0; -} - -tree -init_vbase_pointers (type, decl_ptr) - tree type; - tree decl_ptr; -{ - if (TYPE_USES_VIRTUAL_BASECLASSES (type)) - { - int old_flag = flag_this_is_variable; - flag_this_is_variable = 0; - vbase_types = CLASSTYPE_VBASECLASSES (type); - vbase_decl_ptr = decl_ptr; - vbase_decl = build_indirect_ref (decl_ptr, 0); - vbase_init_result = NULL_TREE; -#ifdef sparc - expand_asm_operands (build_string (32, "! start of vbase initialization"), 0, 0, 0, 0, input_filename, lineno); -#endif - dfs_walk (type, dfs_find_vbases, unmarked3p); - dfs_walk (type, dfs_init_vbase_pointers, marked3p); - dfs_walk (type, dfs_clear_vbase_slots, marked4p); - flag_this_is_variable = old_flag; - return vbase_init_result; - } - return 0; -} - -/* Build a COMPOUND_EXPR which when expanded will generate the code - needed to initialize all the virtual function table slots of all - the virtual baseclasses. FOR_TYPE is the type which determines the - virtual baseclasses to use; TYPE is the type of the object to which - the initialization applies. TRUE_EXP is the true object we are - initializing, and DECL_PTR is the pointer to the sub-object we - are initializing. - - CTOR_P is non-zero if the caller of this function is a top-level - constructor. It is zero when called from a destructor. When - non-zero, we can use computed offsets to store the vtables. When - zero, we must store new vtables through virtual baseclass pointers. */ - -tree -build_vbase_vtables_init (for_type, type, true_exp, decl_ptr, ctor_p) - tree for_type, type; - tree true_exp, decl_ptr; - int ctor_p; -{ - if (TYPE_USES_VIRTUAL_BASECLASSES (type)) - { - int old_flag = flag_this_is_variable; - tree vtable_init_result = NULL_TREE; - tree vbases = CLASSTYPE_VBASECLASSES (type); - - vbase_types = CLASSTYPE_VBASECLASSES (for_type); - vbase_decl_ptr = true_exp ? build_unary_op (ADDR_EXPR, true_exp, 0) : decl_ptr; - vbase_decl = true_exp ? true_exp : build_indirect_ref (decl_ptr, 0); -#ifdef sparc - expand_asm_operands (build_string (32, "! start of vtable initialization"), 0, 0, 0, 0, input_filename, lineno); -#endif - flag_this_is_variable = 0; - - if (ctor_p) - /* This is an object of type IN_TYPE, */ - dfs_walk (for_type, dfs_find_vbases, unmarked4p); - - /* Initialized with vtables of type TYPE. */ - while (vbases) - { - tree basetype = get_base_type (ASSOC_VALUE (vbases), type, 0); - - /* This time through, not every class's vtable - is going to be initialized. That is, we only initialize - the "last" vtable pointer. */ - - assert (basetype == ASSOC_TYPE (vbases)); - - if (basetype - && CLASSTYPE_VSIZE (basetype) - && TYPE_MAIN_VARIANT (basetype) == ASSOC_VALUE (vbases)) - { - tree addr; - tree vtbl = ASSOC_VTABLE (vbases); - tree init = build_unary_op (ADDR_EXPR, vtbl, 0); - TREE_USED (vtbl) = 1; - - if (ctor_p == 0) - addr = convert_pointer_to (basetype, vbase_decl_ptr); - else - addr = CLASSTYPE_SEARCH_SLOT (basetype); - - if (addr) - { - tree ref = build_vfield_ref (build_indirect_ref (addr, 0), basetype); - init = convert_force (TREE_TYPE (ref), init); - vtable_init_result = tree_cons (NULL_TREE, build_modify_expr (ref, NOP_EXPR, init), - vtable_init_result); - } - } - vbases = TREE_CHAIN (vbases); - } - - dfs_walk (type, dfs_clear_vbase_slots, marked4p); - - flag_this_is_variable = old_flag; - if (vtable_init_result) - return build_compound_expr (vtable_init_result); - } - return error_mark_node; -} - -tree -clear_search_slots (type) - tree type; -{ - dfs_walk (type, dfs_clear_search_slot, dfs_search_slot_nonempty_p); -} - -static void -dfs_get_vbase_types (type) - tree type; -{ - int i; - tree these_vbase_types = CLASSTYPE_VBASECLASSES (type); - tree basetype; - - if (these_vbase_types) - { - while (these_vbase_types) - { - basetype = ASSOC_TYPE (these_vbase_types); - if (! CLASSTYPE_MARKED2 (basetype)) - { - vbase_types = make_assoc (integer_zero_node, - basetype, - CLASS_ASSOC_VTABLE (basetype), - CLASS_ASSOC_VIRTUALS (basetype), - vbase_types); - CLASSTYPE_MARKED2 (basetype) = 1; - } - these_vbase_types = TREE_CHAIN (these_vbase_types); - } - } - else for (i = CLASSTYPE_N_BASECLASSES (type); i > 0; i--) - { - basetype = CLASSTYPE_BASECLASS (type, i); - if (CLASSTYPE_VIA_VIRTUAL (type, i) && ! CLASSTYPE_MARKED2 (basetype)) - { - vbase_types = make_assoc (integer_zero_node, - basetype, - CLASS_ASSOC_VTABLE (basetype), - CLASS_ASSOC_VIRTUALS (basetype), - vbase_types); - CLASSTYPE_MARKED2 (basetype) = 1; - } - } - CLASSTYPE_MARKED (type) = 1; -} - -/* Some virtual baseclasses might be virtual baseclasses for - other virtual baseclasses. We sort the virtual baseclasses - topologically: in the list returned, the first virtual base - classes have no virtual baseclasses themselves, and any entry - on the list has no dependency on virtual base classes later in the - list. */ -tree -get_vbase_types (type) - tree type; -{ - tree ordered_vbase_types = NULL_TREE, prev, next; - tree vbases; - - vbase_types = NULL_TREE; - dfs_walk (type, dfs_get_vbase_types, unmarkedp); - dfs_walk (type, dfs_unmark, markedp); - - while (vbase_types) - { - /* Now sort these types. This is essentially a bubble merge. */ - - /* Farm out virtual baseclasses which have no marked ancestors. */ - for (vbases = vbase_types, prev = NULL_TREE; - vbases; vbases = next) - { - next = TREE_CHAIN (vbases); - if (! TYPE_USES_VIRTUAL_BASECLASSES (ASSOC_TYPE (vbases)) - || CLASSTYPE_MARKED2 (ASSOC_TYPE (vbases)) == 0) - { - if (prev) - TREE_CHAIN (prev) = TREE_CHAIN (vbases); - else - vbase_types = TREE_CHAIN (vbases); - TREE_CHAIN (vbases) = NULL_TREE; - ordered_vbase_types = chainon (ordered_vbase_types, vbases); - CLASSTYPE_MARKED2 (ASSOC_TYPE (vbases)) = 0; - } - else - prev = vbases; - } - - /* Now unmark types all of whose ancestors are now on the - `ordered_vbase_types' list. */ - for (vbases = vbase_types; vbases; vbases = TREE_CHAIN (vbases)) - { - /* If all our virtual baseclasses are unmarked, ok. */ - tree t = CLASSTYPE_VBASECLASSES (ASSOC_VALUE (vbases)); - while (t && (CLASSTYPE_MARKED2 (ASSOC_TYPE (t)) == 0 - || !TYPE_USES_VIRTUAL_BASECLASSES (ASSOC_TYPE (t)))) - t = TREE_CHAIN (t); - if (t == NULL_TREE) - CLASSTYPE_MARKED2 (ASSOC_TYPE (vbases)) = 0; - } - } - - return ordered_vbase_types; -} - -static void -dfs_record_inheritance (type) - tree type; -{ - int i, n_baselinks = CLASSTYPE_N_BASECLASSES (type); - mi_boolean *derived_row = DERIVES_FROM_STAR (type); - - for (i = n_baselinks; i > 0; i--) - { - int j; - tree baseclass = TYPE_MAIN_VARIANT (CLASSTYPE_BASECLASS (type, i)); - mi_boolean *base_row = DERIVES_FROM_STAR (baseclass); - - /* Don't search if there's nothing there! MI_SIZE can be - zero as a result of parse errors. */ - if (CLASSTYPE_N_BASECLASSES (baseclass) && mi_size > 0) - for (j = mi_size*(CLASSTYPE_CID (baseclass)-1); j >= 0; j -= mi_size) - derived_row[j] |= base_row[j]; - DERIVES_FROM (baseclass, type) = 1; - } - - CLASSTYPE_MARKED (type) = 1; -} - -/* Given a _CLASSTYPE node in a multiple inheritance lattice, - convert the lattice into a simple relation such that, - given to CIDs, C1 and C2, one can determine if C1 <= C2 - or C2 <= C1 or C1 <> C2. - - Once constructed, we walk the lattice depth fisrt, - applying various functions to elements as they are encountered. - - We use malloc here, in case we want to randomly free these tables. */ - -#define SAVE_MI_MATRIX - -void -build_mi_matrix (type) - tree type; -{ - cid = 0; - -#ifdef SAVE_MI_MATRIX - if (CLASSTYPE_MI_MATRIX (type)) - { - mi_size = CLASSTYPE_N_SUPERCLASSES (type) + CLASSTYPE_N_VBASECLASSES (type); - mi_matrix = CLASSTYPE_MI_MATRIX (type); - mi_type = type; - dfs_walk (type, dfs_number, unnumberedp); - return; - } -#endif - - mi_size = CLASSTYPE_N_SUPERCLASSES (type) + CLASSTYPE_N_VBASECLASSES (type); - mi_matrix = (char *)malloc ((mi_size+1) * (mi_size+1)); - mi_type = type; - bzero (mi_matrix, mi_size * mi_size); - dfs_walk (type, dfs_number, unnumberedp); - dfs_walk (type, dfs_record_inheritance, unmarkedp); - dfs_walk (type, dfs_unmark, markedp); -} - -void -free_mi_matrix () -{ - dfs_walk (mi_type, dfs_unnumber, numberedp); - -#ifdef SAVE_MI_MATRIX - CLASSTYPE_MI_MATRIX (mi_type) = mi_matrix; -#else - free (mi_matrix); - mi_size = 0; - cid = 0; -#endif -} - -/* Local variables for detecting ambiguities of virtual functions - when two or more classes are joined at a multiple inheritance - seam. */ -typedef tree mi_ventry[3]; -static mi_ventry *mi_vmatrix; -static int *mi_vmax; -static int mi_vrows, mi_vcols; -#define MI_VMATRIX(ROW,COL) ((mi_vmatrix + (ROW)*mi_vcols)[COL]) - -/* Build a table of virtual functions for a multiple-inheritance - structure. Here, there are N base classes, and at most - M entries per class. - - This function does nothing if N is 0 or 1. */ -void -build_mi_virtuals (rows, cols) - int rows, cols; -{ - if (rows < 2) - return; - mi_vrows = rows; - mi_vcols = cols; - mi_vmatrix = (mi_ventry *)malloc ((rows+1) * cols * sizeof (mi_ventry)); - mi_vmax = (int *)malloc ((rows+1) * sizeof (int)); - - bzero (mi_vmax, rows * sizeof (int)); - - /* Row indicies start at 1, so adjust this. */ - mi_vmatrix -= cols; - mi_vmax -= 1; -} - -/* Comparison function for ordering virtual function table entries. */ -static int -rank_mi_virtuals (v1, v2) - mi_ventry *v1, *v2; -{ - tree p1, p2; - int i; - - i = (TREE_UID (DECL_ORIGINAL_NAME ((*v1)[0])) - - TREE_UID (DECL_ORIGINAL_NAME ((*v2)[0]))); - if (i) - return i; - p1 = (*v1)[1]; - p2 = (*v2)[1]; - - if (p1 == p2) - return 0; - - while (p1 && p2) - { - i = (TREE_UID (TREE_VALUE (p1)) - - TREE_UID (TREE_VALUE (p2))); - if (i) - return i; - - if (TREE_CHAIN (p1)) - { - if (! TREE_CHAIN (p2)) - return 1; - p1 = TREE_CHAIN (p1); - p2 = TREE_CHAIN (p2); - } - else if (TREE_CHAIN (p2)) - return -1; - else - { - /* When matches of argument lists occur, pick lowest - TREE_UID to keep searching time to a minimum on - later passes--like hashing, only different. - *MUST BE STABLE*. */ - if (TREE_UID ((*v2)[1]) < TREE_UID ((*v1)[1])) - (*v1)[1] = (*v2)[1]; - else - (*v2)[1] = (*v1)[1]; - return 0; - } - } - return 0; -} - -/* Install the virtuals functions got from the initializer VIRTUALS to - the table at index ROW. */ -void -add_mi_virtuals (row, virtuals) - int row; - tree virtuals; -{ - int col = 0; - - if (mi_vmatrix == 0) - return; - while (virtuals) - { - tree decl = TREE_OPERAND (FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (virtuals)), 0); - MI_VMATRIX (row, col)[0] = decl; - MI_VMATRIX (row, col)[1] = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl))); - MI_VMATRIX (row, col)[2] = TREE_VALUE (virtuals); - virtuals = TREE_CHAIN (virtuals); - col += 1; - } - mi_vmax[row] = col; - - qsort (mi_vmatrix + row * mi_vcols, - col, - sizeof (mi_ventry), - rank_mi_virtuals); -} - -/* If joining two types results in an ambiguity in the virtual - function table, report such here. */ -void -report_ambiguous_mi_virtuals (rows, type) - int rows; - tree type; -{ - int *mi_vmin; - int row1, col1, row, col; - - if (mi_vmatrix == 0) - return; - - /* Now virtuals are all sorted, so we merge to find ambiguous cases. */ - mi_vmin = (int *)alloca ((rows+1) * sizeof (int)); - bzero (mi_vmin, rows * sizeof (int)); - - /* adjust. */ - mi_vmin -= 1; - - /* For each base class with virtual functions (and this includes views - of the virtual baseclasses from different base classes), see that - each virtual function in that base class has a unique meet. - - When the column loop is finished, THIS_DECL is in fact the meet. - If that value does not appear in the virtual function table for - the row, install it. This happens when that virtual function comes - from a virtual baseclass, or a non-leftmost baseclass. */ - - for (row1 = 1; row1 < rows; row1++) - { - tree this_decl = 0; - - for (col1 = mi_vmax[row1]-1; col1 >= mi_vmin[row1]; col1--) - { - tree these_args = MI_VMATRIX (row1, col1)[1]; - tree this_context; - - this_decl = MI_VMATRIX (row1, col1)[0]; - if (this_decl == 0) - continue; - this_context = DECL_CONTEXT (this_decl); - - if (this_context != type) - this_context = get_base_type (this_context, type, 0); - - for (row = row1+1; row <= rows; row++) - for (col = mi_vmax[row]-1; col >= mi_vmin[row]; col--) - { - mi_ventry this_entry; - - if (MI_VMATRIX (row, col)[0] == 0) - continue; - - this_entry[0] = this_decl; - this_entry[1] = these_args; - this_entry[2] = MI_VMATRIX (row1, col1)[2]; - if (rank_mi_virtuals (&this_entry, - &MI_VMATRIX (row, col)) == 0) - { - /* They are equal. There are four possibilities: - - (1) Derived class is defining this virtual function. - (2) Two paths to the same virtual function in the - same base class. - (3) A path to a virtual function declared in one base - class, and another path to a virtual function in a - base class of the base class. - (4) Two paths to the same virtual function in different - base classes. - - The first three cases are ok (non-ambiguous). */ - - tree that_context, tmp; - int this_before_that; - - if (type == this_context) - /* case 1. */ - goto ok; - that_context = get_base_type (DECL_CONTEXT (MI_VMATRIX (row, col)[0]), type, 0); - if (that_context == this_context) - /* case 2. */ - goto ok; - if (that_context != NULL_TREE) - { - tmp = get_base_type (that_context, this_context, 0); - this_before_that = (that_context != tmp); - if (this_before_that == 0) - /* case 3a. */ - goto ok; - tmp = get_base_type (this_context, that_context, 0); - this_before_that = (this_context == tmp); - if (this_before_that != 0) - /* case 3b. */ - goto ok; - - /* case 4. */ - error_with_decl (MI_VMATRIX (row, col)[0], "ambiguous virtual function `%s'"); - error_with_decl (this_decl, "ambiguating function `%s' (joined by type `%s')", IDENTIFIER_POINTER (current_class_name)); - } - ok: - MI_VMATRIX (row, col)[0] = 0; - - /* Let zeros propagate. */ - if (col == mi_vmax[row]-1) - { - int i = col; - while (i >= mi_vmin[row] - && MI_VMATRIX (row, i)[0] == 0) - i--; - mi_vmax[row] = i; - } - else if (col == mi_vmin[row]) - { - int i = col; - while (i < mi_vmax[row] - && MI_VMATRIX (row, i)[0] == 0) - i++; - mi_vmin[row] = i; - } - } - } - } - } - free (mi_vmatrix + mi_vcols); - mi_vmatrix = 0; - free (mi_vmax + 1); - mi_vmax = 0; -} - -/* Subroutines of push_class_decls (). */ - -/* Add the instance variables which this class contributed to the - current class binding contour. When a redefinition occurs, - if the redefinition is strictly within a single inheritance path, - we just overwrite (in the case of a data field) or - cons (in the case of a member function) the old declaration with - the new. If the fields are not within a single inheritance path, - we must cons them in either case. */ - -static void -dfs_pushdecls (type) - tree type; -{ - tree fields, *methods, *end; - tree method_vec; - - for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields)) - { - /* Unmark so that if we are in a constructor, and then find that - this field was initialized by a base initializer, - we can emit an error message. */ - if (TREE_CODE (fields) == FIELD_DECL) - TREE_USED (fields) = 0; - - if (DECL_ANON_UNION_ELEM (fields)) - { - dfs_pushdecls (TREE_TYPE (fields)); - continue; - } - if (TREE_CODE (fields) != TYPE_DECL) - { - TREE_FIELD_PUBLIC (fields) = 0; - TREE_FIELD_PROTECTED (fields) = 0; - TREE_FIELD_PRIVATE (fields) = 0; - } - - if (DECL_NAME (fields)) - { - tree value = IDENTIFIER_CLASS_VALUE (DECL_NAME (fields)); - if (value) - { - /* Possible ambiguity. If its defining type(s) - is (are all) derived from us, no problem. */ - - if (TREE_CODE (value) != TREE_LIST) - { - if (DECL_FIELD_CONTEXT (value) == type - || DERIVES_FROM (DECL_FIELD_CONTEXT (value), type)) - value = fields; - else - value = tree_cons (NULL_TREE, fields, - build_tree_list (NULL_TREE, value)); - } - else - { - /* All children may derive from us, in which case - there is no problem. Otherwise, we have to - keep lists around of what the ambiguities might be. */ - tree values; - int problem = 0; - - for (values = value; values; values = TREE_CHAIN (values)) - { - tree sub_values = TREE_VALUE (values); - if (TREE_CODE (sub_values) == TREE_LIST) - { - for (; sub_values; sub_values = TREE_CHAIN (sub_values)) - if (! DERIVES_FROM (DECL_FIELD_CONTEXT (TREE_VALUE (sub_values)), type)) - { - value = tree_cons (NULL_TREE, TREE_VALUE (values), value); - problem = 1; - break; - } - } - else - { - if (! DERIVES_FROM (DECL_FIELD_CONTEXT (sub_values), type)) - { - value = tree_cons (NULL_TREE, values, value); - problem = 1; - break; - } - } - } - if (! problem) value = fields; - } - - /* Mark this as a potentially ambiguous member. */ - if (TREE_CODE (value) == TREE_LIST) - { - /* Leaving TREE_TYPE blank is intentional. - We cannot use `error_mark_node' (lookup_name) - or `unknown_type_node' (all member functions use this). */ - TREE_NONLOCAL (value) = 1; - } - - IDENTIFIER_CLASS_VALUE (DECL_NAME (fields)) = value; - } - else IDENTIFIER_CLASS_VALUE (DECL_NAME (fields)) = fields; - } - } - - method_vec = CLASSTYPE_METHOD_VEC (type); - if (method_vec != 0) - { - /* Farm out constructors and destructors. */ - methods = &TREE_VEC_ELT (method_vec, 1); - end = TREE_VEC_END (method_vec); - - /* This does not work for multiple inheritance yet. */ - while (methods != end) - { - /* This will cause lookup_name to return a pointer - to the tree_list of possible methods of this name. - If the order is a problem, we can nreverse them. */ - tree tmp; - tree old = IDENTIFIER_CLASS_VALUE (DECL_ORIGINAL_NAME (*methods)); - - if (old && TREE_CODE (old) == TREE_LIST) - tmp = tree_cons (DECL_ORIGINAL_NAME (*methods), *methods, old); - else - { - /* Only complain if we shadow something we can access. */ - if (old && (DECL_CONTEXT (old) == current_class_type - || ! TREE_PRIVATE (old))) - /* Should figure out visibility more accurately. */ - warning ("shadowing member `%s' with member function", - IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (*methods))); - tmp = build_tree_list (DECL_ORIGINAL_NAME (*methods), *methods); - } - - TREE_TYPE (tmp) = unknown_type_node; -#if 0 - TREE_OVERLOADED (tmp) = DECL_OVERLOADED (*methods); -#endif - TREE_NONLOCAL (tmp) = 1; - IDENTIFIER_CLASS_VALUE (DECL_ORIGINAL_NAME (*methods)) = tmp; - - tmp = *methods; - while (tmp != 0) - { - TREE_FIELD_PUBLIC (tmp) = 0; - TREE_FIELD_PROTECTED (tmp) = 0; - TREE_FIELD_PRIVATE (tmp) = 0; - tmp = TREE_CHAIN (tmp); - } - - methods++; - } - } - CLASSTYPE_MARKED (type) = 1; -} - -/* Consolidate unique (by name) member functions. */ -static void -dfs_compress_decls (type) - tree type; -{ - tree method_vec = CLASSTYPE_METHOD_VEC (type); - - if (method_vec != 0) - { - /* Farm out constructors and destructors. */ - tree *methods = &TREE_VEC_ELT (method_vec, 1); - tree *end = TREE_VEC_END (method_vec); - - for (; methods != end; methods++) - { - tree tmp = IDENTIFIER_CLASS_VALUE (DECL_ORIGINAL_NAME (*methods)); - - /* This was replaced in scope by somebody else. Just leave it - alone. */ - if (TREE_CODE (tmp) != TREE_LIST) - continue; - - if (TREE_CHAIN (tmp) == NULL_TREE - && TREE_VALUE (tmp) - && TREE_CHAIN (TREE_VALUE (tmp)) == NULL_TREE) - { - IDENTIFIER_CLASS_VALUE (DECL_ORIGINAL_NAME (*methods)) - = TREE_VALUE (tmp); - } - } - } - CLASSTYPE_MARKED (type) = 0; -} - -/* When entering the scope of a class, we cache all of the - fields that that class provides within its inheritance - lattice. Where ambiguities result, we mark them - with `error_mark_node' so that if they are encountered - without explicit qualification, we can emit an error - message. */ -void -push_class_decls (type) - tree type; -{ - struct obstack *ambient_obstack = current_obstack; - -#if 0 - tree tags = CLASSTYPE_TAGS (type); - - while (tags) - { - tree code_type_node; - tree tag; - - switch (TREE_CODE (TREE_VALUE (tags))) - { - case ENUMERAL_TYPE: - code_type_node = enum_type_node; - break; - case RECORD_TYPE: - code_type_node = record_type_node; - break; - case CLASS_TYPE: - code_type_node = class_type_node; - break; - case UNION_TYPE: - code_type_node = union_type_node; - break; - default: - assert (0); - } - tag = xref_tag (code_type_node, TREE_PURPOSE (tags), - CLASSTYPE_BASECLASS (TREE_VALUE (tags), 1)); - pushdecl (build_decl (TYPE_DECL, TREE_PURPOSE (tags), TREE_VALUE (tags))); - } -#endif - - current_obstack = &bridge_obstack; - search_stack = push_search_level (search_stack, &bridge_obstack); - - /* Push class fields into CLASS_VALUE scope, and mark. */ - dfs_walk (type, dfs_pushdecls, unmarkedp); - - /* Compress fields which have only a single entry - by a given name, and unmark. */ - dfs_walk (type, dfs_compress_decls, markedp); - current_obstack = ambient_obstack; -} - -static void -dfs_popdecls (type) - tree type; -{ - tree fields = TYPE_FIELDS (type); - tree method_vec = CLASSTYPE_METHOD_VEC (type); - - while (fields) - { - if (DECL_ANON_UNION_ELEM (fields)) - { - dfs_popdecls (TREE_TYPE (fields)); - } - else if (DECL_NAME (fields)) - IDENTIFIER_CLASS_VALUE (DECL_NAME (fields)) = NULL_TREE; - fields = TREE_CHAIN (fields); - } - if (method_vec != 0) - { - tree *methods = &TREE_VEC_ELT (method_vec, 0); - tree *end = TREE_VEC_END (method_vec); - - if (*methods == 0) - methods += 1; - - for (; methods != end; methods++) - IDENTIFIER_CLASS_VALUE (DECL_ORIGINAL_NAME (*methods)) = NULL_TREE; - } - - CLASSTYPE_MARKED (type) = 1; -} - -void -pop_class_decls (type) - tree type; -{ - /* Clear out the IDENTIFIER_CLASS_VALUE which this - class may have occupied, and mark. */ - dfs_walk (type, dfs_popdecls, unmarkedp); - - /* Unmark. */ - dfs_walk (type, dfs_unmark, markedp); - search_stack = pop_search_level (search_stack); -} - -/* Given a base type PARENT, and a derived type TYPE, build - a name which distinguishes exactly the PARENT member of TYPE's type. - - FORMAT is a string which controls how sprintf formats the name - we have generated. - - For example, given - - class A; class B; class C : A, B; - - it is possible to distinguish "A" from "C's A". And given - - class L; - class A : L; class B : L; class C : A, B; - - it is possible to distinguish "L" from "A's L", and also from - "C's L from A". */ -tree -build_type_pathname (format, parent, type) - char *format; - tree parent, type; -{ - extern struct obstack temporary_obstack; - char *first, *base, *name; - int i; - tree id; - - parent = TYPE_MAIN_VARIANT (parent); - - /* Remember where to cut the obstack to. */ - first = obstack_base (&temporary_obstack); - - /* Put on TYPE+PARENT. */ - obstack_grow (&temporary_obstack, - TYPE_NAME_STRING (type), TYPE_NAME_LENGTH (type)); - obstack_1grow (&temporary_obstack, JOINER); - obstack_grow0 (&temporary_obstack, - TYPE_NAME_STRING (parent), TYPE_NAME_LENGTH (parent)); - i = obstack_object_size (&temporary_obstack); - base = obstack_base (&temporary_obstack); - obstack_finish (&temporary_obstack); - - /* Put on FORMAT+TYPE+PARENT. */ - obstack_blank (&temporary_obstack, strlen (format) + i + 1); - name = obstack_base (&temporary_obstack); - sprintf (name, format, base); - id = get_identifier (name); - obstack_free (&temporary_obstack, first); - - return id; -} - -static int -bfs_unmark_finished_struct (type, i) - tree type; - int i; -{ - type = i == 0 ? type : CLASSTYPE_BASECLASS (type, i); - if (CLASSTYPE_MARKED4 (type)) - { - tree assoc, decl, context; - - if (type == current_class_type) - assoc = CLASSTYPE_ASSOC (type); - else if (TREE_VIA_VIRTUAL (type)) - assoc = value_member (TYPE_MAIN_VARIANT (type), CLASSTYPE_VBASECLASSES (current_class_type)); - else - assoc = assoc_value (TYPE_MAIN_VARIANT (type), current_class_type); - decl = ASSOC_VTABLE (assoc); - context = DECL_CONTEXT (decl); - DECL_CONTEXT (decl) = 0; - if (write_virtuals >= 0 - && DECL_INITIAL (decl) != ASSOC_VIRTUALS (assoc)) - DECL_INITIAL (decl) = build_nt (CONSTRUCTOR, NULL_TREE, - ASSOC_VIRTUALS (assoc)); - finish_decl (decl, DECL_INITIAL (decl), NULL_TREE); - DECL_CONTEXT (decl) = context; - } - CLASSTYPE_MARKED3 (type) = 0; - CLASSTYPE_MARKED4 (type) = 0; - return 0; -} - -void -unmark_finished_struct (type) - tree type; -{ - bfs_unmark_finished_struct (type, 0); - breadth_first_search (type, bfs_unmark_finished_struct, bfs_marked3p); -} - -void -print_search_statistics () -{ -#ifdef GATHER_STATISTICS - if (flag_memoize_lookups) - { - fprintf (stderr, "%d memoized contexts saved\n", - n_contexts_saved); - fprintf (stderr, "%d local tree nodes made\n", my_tree_node_counter); - fprintf (stderr, "%d local hash nodes made\n", my_memoized_entry_counter); - fprintf (stderr, "fields statistics:\n"); - fprintf (stderr, " memoized finds = %d; rejects = %d; (searches = %d)\n", - memoized_fast_finds[0], memoized_fast_rejects[0], - memoized_fields_searched[0]); - fprintf (stderr, " memoized_adds = %d\n", memoized_adds[0]); - fprintf (stderr, "fnfields statistics:\n"); - fprintf (stderr, " memoized finds = %d; rejects = %d; (searches = %d)\n", - memoized_fast_finds[1], memoized_fast_rejects[1], - memoized_fields_searched[1]); - fprintf (stderr, " memoized_adds = %d\n", memoized_adds[1]); - } - fprintf (stderr, "%d fields searched in %d[%d] calls to lookup_field[_1]\n", - n_fields_searched, n_calls_lookup_field, n_calls_lookup_field_1); - fprintf (stderr, "%d fnfields searched in %d calls to lookup_fnfields\n", - n_outer_fields_searched, n_calls_lookup_fnfields); - fprintf (stderr, "%d calls to get_base_type\n", n_calls_get_base_type); -#else - fprintf (stderr, "no search statistics\n"); -#endif -} - -void -init_search_processing () -{ - obstack_init (&search_obstack); - obstack_init (&type_obstack); - obstack_init (&type_obstack_entries); - obstack_init (&bridge_obstack); - - /* This gives us room to build our chains of basetypes, - whether or not we decide to memoize them. */ - type_stack = push_type_level (0, &type_obstack); - _vptr_name = get_identifier ("_vptr"); -} - -tree -get_wrapper (type) - tree type; -{ - tree wrap_type; - char *name; - assert (IS_AGGR_TYPE (type)); - wrap_type = TYPE_WRAP_TYPE (type); - name = (char *)alloca (TYPE_NAME_LENGTH (wrap_type) - + strlen (WRAPPER_NAME_FORMAT)); - sprintf (name, WRAPPER_NAME_FORMAT, TYPE_NAME_STRING (wrap_type)); - return lookup_fnfields (CLASSTYPE_AS_LIST (wrap_type), - get_identifier (name), 0); -} - -void -reinit_search_statistics () -{ - my_memoized_entry_counter = 0; - memoized_fast_finds[0] = 0; - memoized_fast_finds[1] = 0; - memoized_adds[0] = 0; - memoized_adds[1] = 0; - memoized_fast_rejects[0] = 0; - memoized_fast_rejects[1] = 0; - memoized_fields_searched[0] = 0; - memoized_fields_searched[1] = 0; - n_fields_searched = 0; - n_calls_lookup_field = 0, n_calls_lookup_field_1 = 0; - n_calls_lookup_fnfields = 0, n_calls_lookup_fnfields_1 = 0; - n_calls_get_base_type = 0; - n_outer_fields_searched = 0; - n_contexts_saved = 0; -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-tree.c b/gnu/usr.bin/g++/cc1plus/cplus-tree.c deleted file mode 100644 index 9387d985e03d..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-tree.c +++ /dev/null @@ -1,1320 +0,0 @@ -/* Language-depednent node constructors for parse phase of GNU compiler. - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "config.h" -#include -#include "obstack.h" -#include "tree.h" -#include "cplus-tree.h" -#include "flags.h" -#include "assert.h" - -#define MAX(x,y) ((x) > (y) ? (x) : (y)) -#define MIN(x,y) ((x) < (y) ? (x) : (y)) -#define CEIL(x,y) (((x) + (y) - 1) / (y)) - -/* Return nonzero if REF is an lvalue valid for this language. - Lvalues can be assigned, unless they have TREE_READONLY. - Lvalues can have their address taken, unless they have TREE_REGDECL. */ - -int -lvalue_p (ref) - tree ref; -{ - register enum tree_code code = TREE_CODE (ref); - - if (language_lvalue_valid (ref)) - switch (code) - { - case COMPONENT_REF: - return lvalue_p (TREE_OPERAND (ref, 0)); - - case STRING_CST: - return 1; - - case VAR_DECL: - if (TREE_READONLY (ref) && ! TREE_STATIC (ref) - && DECL_LANG_SPECIFIC (ref) - && DECL_IN_AGGR_P (ref)) - return 0; - case INDIRECT_REF: - case ARRAY_REF: - case PARM_DECL: - case RESULT_DECL: - case ERROR_MARK: - if (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE - && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE) - return 1; - break; - - case NEW_EXPR: - return 1; - - case CALL_EXPR: - if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE - /* unary_complex_lvalue knows how to deal with this case. */ - || TREE_ADDRESSABLE (TREE_TYPE (ref))) - return 1; - break; - - /* A currently unresolved scope ref. */ - case SCOPE_REF: - abort (); - case OFFSET_REF: - if (TREE_CODE (TREE_OPERAND (ref, 1)) == FUNCTION_DECL) - return 1; - if (TREE_CODE (TREE_OPERAND (ref, 1)) == VAR_DECL) - if (TREE_READONLY (ref) && ! TREE_STATIC (ref) - && DECL_LANG_SPECIFIC (ref) - && DECL_IN_AGGR_P (ref)) - return 0; - else - return 1; - break; - } - return 0; -} - -/* Return nonzero if REF is an lvalue valid for this language; - otherwise, print an error message and return zero. */ - -int -lvalue_or_else (ref, string) - tree ref; - char *string; -{ - int win = lvalue_p (ref); - if (! win) - error ("invalid lvalue in %s", string); - return win; -} - -/* INIT is a CALL_EXPR which needs info about its target. - TYPE is the type that this initialization should appear to have. - - Build an encapsultation of the initialization to perfom - and return it so that it can be processed by language-independent - and language-specific expression expanders. */ -tree -build_cplus_new (type, init) - tree type; - tree init; -{ - tree slot = build (VAR_DECL, type); - tree rval = build (CPLUS_NEW_EXPR, type, - TREE_OPERAND (init, 0), TREE_OPERAND (init, 1), slot); - TREE_ADDRESSABLE (rval) = 1; - rval = build (NEW_EXPR, type, slot, rval, 0); - TREE_ADDRESSABLE (rval) = 1; - return rval; -} - -extern struct obstack *current_obstack; -extern struct obstack permanent_obstack, class_obstack; -extern struct obstack *saveable_obstack; - -/* Return a type like TYPE except that its CLASSTYPE_OFFSET - is OFFSET. - - Such variant types already made are recorded so that duplicates - are not made. - - A variant types should never be used as the type of an expression. - Use TYPE_MAIN_VARIANT to find the main variant. */ - -tree -build_classtype_variant (type, offset, virtualp) - tree type; - tree offset; - int virtualp; -{ - register tree t, m = CLASSTYPE_MAIN_VARIANT (type); - register struct obstack *ambient_obstack = current_obstack; - register struct obstack *ambient_saveable_obstack = saveable_obstack; - register int lo = TREE_INT_CST_LOW (offset); - register int hi = TREE_INT_CST_HIGH (offset); - /* First search the chain variants for one that is what we want. */ - - if (hi == 0 && lo == 0) - offset = integer_zero_node; - - for (t = m; t; t = CLASSTYPE_NEXT_VARIANT (t)) - if (virtualp == TREE_VIA_VIRTUAL (t) - && lo == TREE_INT_CST_LOW (CLASSTYPE_OFFSET (t)) - && hi == TREE_INT_CST_HIGH (CLASSTYPE_OFFSET (t))) - return t; - - /* We need a new one. */ - if (TREE_PERMANENT (type)) - saveable_obstack = &permanent_obstack; - current_obstack = saveable_obstack; - - t = copy_node (type); - copy_type_lang_specific (t); - CLASSTYPE_AS_LIST (t) = build_tree_list (NULL_TREE, t); - - TYPE_POINTER_TO (t) = 0; - TYPE_REFERENCE_TO (t) = 0; - CLASSTYPE_OFFSET (t) = offset; - TREE_VIA_VIRTUAL (t) = virtualp; - - /* Always promise to have TYPE_POINTER_TO filled in. */ - build_pointer_type (t); - - /* Add this type to the chain of variants of TYPE. */ - CLASSTYPE_NEXT_VARIANT (t) = CLASSTYPE_NEXT_VARIANT (m); - CLASSTYPE_NEXT_VARIANT (m) = t; - - current_obstack = ambient_obstack; - saveable_obstack = ambient_saveable_obstack; - return t; -} - -/* Here is how primitive or already-canonicalized types' hash - codes are made. MUST BE CONSISTENT WITH tree.c !!! */ -#define TYPE_HASH(TYPE) TREE_UID (TYPE) - -/* Construct, lay out and return the type of methods belonging to class - BASETYPE and whose arguments and values are described by TYPE. - If that type exists already, reuse it. - TYPE must be a FUNCTION_TYPE node. */ - -tree -build_cplus_method_type (basetype, rettype, argtypes) - tree basetype, rettype, argtypes; -{ - register tree t; - tree ptype = build_pointer_type (basetype); - int hashcode; - - /* Make a node of the sort we want. */ - t = make_node (METHOD_TYPE); - - TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype); - TREE_TYPE (t) = rettype; - ptype = build_type_variant (ptype, !flag_this_is_variable, 0); - - /* The actual arglist for this function includes a "hidden" argument - which is "this". Put it into the list of argument types. */ - - TYPE_ARG_TYPES (t) = tree_cons (NULL, ptype, argtypes); - - /* If we already have such a type, use the old one and free this one. - Note that it also frees up the above cons cell if found. */ - hashcode = TYPE_HASH (basetype) + TYPE_HASH (rettype) + type_hash_list (argtypes); - t = type_hash_canon (hashcode, t); - - if (TYPE_SIZE (t) == 0) - layout_type (t); - - return t; -} - -tree -build_cplus_array_type (elt_type, index_type) - tree elt_type; - tree index_type; -{ - register struct obstack *ambient_obstack = current_obstack; - register struct obstack *ambient_saveable_obstack = saveable_obstack; - tree t; - - /* We need a new one. If ELT_TYPE is permanent, make this permanent too. */ - if (TREE_PERMANENT (elt_type)) - { - current_obstack = &permanent_obstack; - saveable_obstack = &permanent_obstack; - } - - t = build_array_type (elt_type, index_type); - - /* Push these needs up so that initialization takes place - more easily. */ - TYPE_NEEDS_CONSTRUCTING (t) = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (elt_type)); - TYPE_NEEDS_DESTRUCTOR (t) = TYPE_NEEDS_DESTRUCTOR (TYPE_MAIN_VARIANT (elt_type)); - current_obstack = ambient_obstack; - saveable_obstack = ambient_saveable_obstack; - return t; -} - -/* This is temporary until later. */ -/* Construct, lay out and return the type of objects which are of type TYPE - as members of type BASETYPE. If that type exists already, reuse it. */ -tree -build_member_type (basetype, type) - tree basetype, type; -{ - register tree t; - int hashcode; - - assert (TREE_CODE (type) != FUNCTION_TYPE); - - /* Make a node of the sort we want. */ - t = make_node (OFFSET_TYPE); - TYPE_OFFSET_BASETYPE (t) = basetype; - TREE_TYPE (t) = type; - hashcode = TREE_UID (basetype) + TREE_UID (type); - t = type_hash_canon (hashcode, t); - - return t; -} - -/* Compute the actual offsets that our virtual base classes - will have *for this type*. This must be performed after - the fields are laid out, since virtual baseclasses must - lay down at the end of the record. - - Returns the maximum number of virtual functions any of the virtual - baseclasses provide. */ -int -layout_vbasetypes (rec, max) - tree rec; - int max; -{ - /* Get all the virtual base types that this type uses. - The TREE_VALUE slot holds the virtual baseclass type. */ - tree vbase_types = get_vbase_types (rec); - -#ifdef STRUCTURE_SIZE_BOUNDARY - int record_align = MAX (STRUCTURE_SIZE_BOUNDARY, TYPE_ALIGN (rec)); -#else - int record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (rec)); -#endif - - /* Record size so far is CONST_SIZE + VAR_SIZE * SIZE_UNIT bits, - where CONST_SIZE is an integer - and VAR_SIZE is a tree expression. - If VAR_SIZE is null, the size is just CONST_SIZE. - Naturally we try to avoid using VAR_SIZE. */ - register int const_size = 0; - register tree var_size = 0; - register int size_unit = BITS_PER_UNIT; - int nonvirtual_const_size; - tree nonvirtual_var_size; - - CLASSTYPE_VBASECLASSES (rec) = vbase_types; - - if (TREE_CODE (TYPE_SIZE (rec)) == INTEGER_CST) - const_size = TREE_INT_CST_LOW (TYPE_SIZE (rec)) * TYPE_SIZE_UNIT (rec); - else - { - var_size = TYPE_SIZE (rec); - size_unit = record_align; - } - - nonvirtual_const_size = const_size; - nonvirtual_var_size = var_size; - - while (vbase_types) - { - int inc; - tree basetype = ASSOC_TYPE (vbase_types); - tree offset; - - if (const_size == 0) - offset = integer_zero_node; - else - offset = convert_units (build_int (const_size), 1, BITS_PER_UNIT); - - if (CLASSTYPE_VSIZE (basetype) > max) - max = CLASSTYPE_VSIZE (basetype); - ASSOC_OFFSET (vbase_types) = offset; - - inc = MAX (record_align, - (TREE_INT_CST_LOW (TYPE_SIZE (basetype)) - - TREE_INT_CST_LOW (CLASSTYPE_VBASE_SIZE (basetype))) - * TYPE_SIZE_UNIT (basetype)); - - const_size += inc; - vbase_types = TREE_CHAIN (vbase_types); - } - - if (const_size - nonvirtual_const_size) - { - CLASSTYPE_VBASE_SIZE (rec) = convert_units (build_int (const_size - nonvirtual_const_size), - 1, BITS_PER_UNIT); - TYPE_SIZE (rec) = convert_units (build_int (const_size), 1, BITS_PER_UNIT); - } - else - CLASSTYPE_VBASE_SIZE (rec) = integer_zero_node; - return max; -} - -#if 0 -/* This function should never be needed. */ -void -fixup_vbase_offsets (type) - tree type; -{ - tree virtuals = TREE_CHAIN (CLASS_ASSOC_VIRTUALS (type)); - - while (virtuals) - { - tree pfn = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (virtuals)); - tree decl = TREE_OPERAND (pfn, 0); - tree vcontext = get_base_type (DECL_VCONTEXT (decl), DECL_CONTEXT (decl), 0); - if (vcontext != NULL_TREE && TREE_VIA_VIRTUAL (vcontext)) - { - tree offset; - tree vbase_offset_info; - tree parent_type; - - if (DECL_CONTEXT (decl) == TYPE_MAIN_VARIANT (type)) - parent_type = type; - else - { - parent_type = get_base_type (DECL_CONTEXT (decl), type, 0); - if (parent_type == 0) - parent_type = type; - } - vbase_offset_info = value_member (vcontext, - CLASSTYPE_VBASECLASSES (parent_type)); - offset = genop (MINUS_EXPR, CLASSTYPE_OFFSET (parent_type), - TREE_PURPOSE (vbase_offset_info)); - TREE_VALUE (virtuals) = build_vtable_entry (offset, pfn); - } - virtuals = TREE_CHAIN (virtuals); - } -} -#endif - -/* Lay out the base types of a record type, REC. - Tentatively set the size and alignment of REC - according to the base types alone. - - Returns list of virtual base classes in a FIELD_DECL chain. */ -tree -layout_basetypes (rec) - tree rec; -{ - /* Chain to hold all the new FIELD_DECLs which point at virtual - base classes. */ - tree vbase_decls = NULL_TREE; - -#ifdef STRUCTURE_SIZE_BOUNDARY - int record_align = MAX (STRUCTURE_SIZE_BOUNDARY, TYPE_ALIGN (rec)); -#else - int record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (rec)); -#endif - - /* Record size so far is CONST_SIZE + VAR_SIZE * SIZE_UNIT bits, - where CONST_SIZE is an integer - and VAR_SIZE is a tree expression. - If VAR_SIZE is null, the size is just CONST_SIZE. - Naturally we try to avoid using VAR_SIZE. */ - register int const_size = 0; - register tree var_size = 0; - register int size_unit = BITS_PER_UNIT; - int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (rec); - - /* Handle basetypes almost like fields, but record their - offsets differently. */ - - for (i = 1; i <= n_baseclasses; i++) - { - int inc, desired_align; - register tree basetype = CLASSTYPE_BASECLASS (rec, i); - tree decl; - - if (TYPE_SIZE (basetype) == 0) - { - error_with_aggr_type (basetype, "base class `%s' has incomplete type"); - SET_CLASSTYPE_VIAS (rec, i, 1, 0); - continue; - } - - /* All basetypes are recorded in the association list of the - derived type. */ - - if (CLASSTYPE_VIA_VIRTUAL (rec, i)) - { - int j; - char *name = (char *)alloca (TYPE_NAME_LENGTH (basetype) - + sizeof (VBASE_NAME) + 1); - sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (basetype)); - - /* The offset for a virtual base class is only - used in computing virtual function tables and - for initializing virtual base pointers. The assoc - for this base type is built once `get_vbase_types' - is called. */ - CLASSTYPE_BASECLASS (rec, i) = basetype - = build_classtype_variant (basetype, integer_zero_node, 1); - - /* If this basetype can come from another vbase pointer - without an additional indirection, we will share - that pointer. If an indirection is involved, we - make our own pointer. */ - for (j = 1; j <= n_baseclasses; j++) - if (! CLASSTYPE_VIA_VIRTUAL (rec, j) - && TYPE_USES_VIRTUAL_BASECLASSES (CLASSTYPE_BASECLASS (rec, j)) - && value_member (TYPE_MAIN_VARIANT (basetype), - CLASSTYPE_VBASECLASSES (CLASSTYPE_BASECLASS (rec, j)))) - { - goto got_it; - } - - decl = build_lang_decl (FIELD_DECL, get_identifier (name), - build_pointer_type (basetype)); - DECL_FIELD_CONTEXT (decl) = rec; - SET_DECL_FCONTEXT (decl, TYPE_MAIN_VARIANT (basetype)); - DECL_VBASE_P (decl) = 1; - TREE_CHAIN (decl) = vbase_decls; - vbase_decls = decl; - - got_it: - /* The space this decl occupies has already been accounted for. */ - continue; - } - else - { - tree class_offset; - tree assoc; - - if (const_size == 0) - class_offset = integer_zero_node; - else - { - /* Give each base type the alignment it wants. */ - const_size = CEIL (const_size, TYPE_ALIGN (basetype)) - * TYPE_ALIGN (basetype); - class_offset = convert_units (build_int (const_size), 1, BITS_PER_UNIT); - CLASSTYPE_BASECLASS (rec, i) = basetype - = build_classtype_variant (basetype, class_offset, 0); - } - - if (CLASSTYPE_VSIZE (basetype)) - assoc = make_assoc (class_offset, basetype, - CLASS_ASSOC_VTABLE (basetype), - CLASS_ASSOC_VIRTUALS (basetype), - CLASSTYPE_ASSOC (rec)); - else - assoc = make_assoc (class_offset, basetype, 0, 0, - CLASSTYPE_ASSOC (rec)); - CLASSTYPE_ASSOC (rec) = assoc; - if (const_size != 0) - { - TYPE_NAME (basetype) = copy_node (TYPE_NAME (basetype)); - TREE_TYPE (TYPE_NAME (basetype)) = basetype; - DECL_OFFSET (TYPE_NAME (basetype)) = const_size; - } - } - - /* Add only the amount of storage not present in - the virtual baseclasses. */ - inc = MAX (record_align, - (TREE_INT_CST_LOW (TYPE_SIZE (basetype)) - - TREE_INT_CST_LOW (CLASSTYPE_VBASE_SIZE (basetype))) - * TYPE_SIZE_UNIT (basetype)); - - /* Record must have at least as much alignment as any field. */ - desired_align = TYPE_ALIGN (basetype); - record_align = MAX (record_align, desired_align); - - const_size += inc; - } - - if (const_size) - CLASSTYPE_SIZE (rec) = build_int_2 (const_size, 0); - else - CLASSTYPE_SIZE (rec) = integer_zero_node; - CLASSTYPE_ALIGN (rec) = record_align; - - return vbase_decls; -} - -/* Hashing of lists so that we don't make duplicates. - The entry point is `list_hash_canon'. */ - -/* Each hash table slot is a bucket containing a chain - of these structures. */ - -struct list_hash -{ - struct list_hash *next; /* Next structure in the bucket. */ - int hashcode; /* Hash code of this list. */ - tree list; /* The list recorded here. */ -}; - -/* Now here is the hash table. When recording a list, it is added - to the slot whose index is the hash code mod the table size. - Note that the hash table is used for several kinds of lists. - While all these live in the same table, they are completely independent, - and the hash code is computed differently for each of these. */ - -#define TYPE_HASH_SIZE 59 -struct list_hash *list_hash_table[TYPE_HASH_SIZE]; - -/* Here is how primitive or already-canonicalized lists' hash - codes are made. */ -#define TYPE_HASH(TYPE) TREE_UID (TYPE) - -/* Compute a hash code for a list (chain of TREE_LIST nodes - with goodies in the TREE_PURPOSE, TREE_VALUE, and bits of the - TREE_COMMON slots), by adding the hash codes of the individual entries. */ - -int -list_hash (list) - tree list; -{ - register int hashcode = 0; - - if (TREE_CHAIN (list)) - hashcode = TYPE_HASH (TREE_CHAIN (list)); - else - hashcode = 0; - if (TREE_VALUE (list)) - hashcode += TYPE_HASH (TREE_VALUE (list)); - else - hashcode += 1007; - if (TREE_PURPOSE (list)) - hashcode += TYPE_HASH (TREE_PURPOSE (list)); - else - hashcode += 1009; - return hashcode; -} - -/* Look in the type hash table for a type isomorphic to TYPE. - If one is found, return it. Otherwise return 0. */ - -tree -list_hash_lookup (hashcode, list) - int hashcode; - tree list; -{ - register struct list_hash *h; - for (h = list_hash_table[hashcode % TYPE_HASH_SIZE]; h; h = h->next) - if (h->hashcode == hashcode - && TREE_VIA_VIRTUAL (h->list) == TREE_VIA_VIRTUAL (list) - && TREE_VIA_PUBLIC (h->list) == TREE_VIA_PUBLIC (list) - && TREE_PURPOSE (h->list) == TREE_PURPOSE (list) - && TREE_VALUE (h->list) == TREE_VALUE (list)) - { - assert (TREE_TYPE (h->list) == TREE_TYPE (list)); - assert (TREE_CHAIN (h->list) == TREE_CHAIN (list)); - return h->list; - } - return 0; -} - -/* Add an entry to the list-hash-table - for a list TYPE whose hash code is HASHCODE. */ - -void -list_hash_add (hashcode, list) - int hashcode; - tree list; -{ - register struct list_hash *h; - - h = (struct list_hash *) obstack_alloc (&class_obstack, sizeof (struct list_hash)); - h->hashcode = hashcode; - h->list = list; - h->next = list_hash_table[hashcode % TYPE_HASH_SIZE]; - list_hash_table[hashcode % TYPE_HASH_SIZE] = h; -} - -/* Given TYPE, and HASHCODE its hash code, return the canonical - object for an identical list if one already exists. - Otherwise, return TYPE, and record it as the canonical object - if it is a permanent object. - - To use this function, first create a list of the sort you want. - Then compute its hash code from the fields of the list that - make it different from other similar lists. - Then call this function and use the value. - This function frees the list you pass in if it is a duplicate. */ - -/* Set to 1 to debug without canonicalization. Never set by program. */ -int debug_no_list_hash = 0; - -tree -list_hash_canon (hashcode, list) - int hashcode; - tree list; -{ - tree t1; - - if (debug_no_list_hash) - return list; - - t1 = list_hash_lookup (hashcode, list); - if (t1 != 0) - { - obstack_free (&class_obstack, list); - return t1; - } - - /* If this is a new list, record it for later reuse. */ - list_hash_add (hashcode, list); - - return list; -} - -tree -hash_tree_cons (via_public, via_virtual, purpose, value, chain) - int via_public, via_virtual; - tree purpose, value, chain; -{ - struct obstack *ambient_obstack = current_obstack; - tree t; - int hashcode; - - current_obstack = &class_obstack; - t = tree_cons (purpose, value, chain); - TREE_VIA_PUBLIC (t) = via_public; - TREE_VIA_VIRTUAL (t) = via_virtual; - hashcode = list_hash (t); - t = list_hash_canon (hashcode, t); - current_obstack = ambient_obstack; - return t; -} - -/* Constructor for hashed lists. */ -tree -hash_tree_chain (value, chain) - tree value, chain; -{ - struct obstack *ambient_obstack = current_obstack; - tree t; - int hashcode; - - current_obstack = &class_obstack; - t = tree_cons (NULL_TREE, value, chain); - hashcode = list_hash (t); - t = list_hash_canon (hashcode, t); - current_obstack = ambient_obstack; - return t; -} - -/* Similar, but used for concatenating two lists. */ -tree -hash_chainon (list1, list2) - tree list1, list2; -{ - if (list2 == 0) - return list1; - if (list1 == 0) - return list2; - if (TREE_CHAIN (list1) == NULL_TREE) - return hash_tree_chain (TREE_VALUE (list1), list2); - return hash_tree_chain (TREE_VALUE (list1), - hash_chainon (TREE_CHAIN (list1), list2)); -} - -tree -build_decl_list_1 (value) - tree value; -{ - tree list = NULL_TREE; - - if (TREE_CODE (value) == IDENTIFIER_NODE) - { - list = IDENTIFIER_AS_LIST (value); - if (list != NULL_TREE - && (TREE_CODE (list) != TREE_LIST - || TREE_VALUE (list) != value)) - list = NULL_TREE; - else if (TREE_TYPE (value) != NULL_TREE - && TREE_CODE (TREE_TYPE (TREE_TYPE (value))) == RECORD_TYPE) - { - tree type = TREE_TYPE (TREE_TYPE (value)); - if (CLASSTYPE_AS_ID_LIST (type) == NULL_TREE) - CLASSTYPE_AS_ID_LIST (type) = perm_tree_cons (NULL_TREE, value, NULL_TREE); - list = CLASSTYPE_AS_ID_LIST (type); - } - } - else if (TREE_CODE (value) == RECORD_TYPE - && TYPE_LANG_SPECIFIC (value)) - list = CLASSTYPE_AS_LIST (value); - - if (list != NULL_TREE) - { - assert (TREE_CHAIN (list) == NULL_TREE); - return list; - } - - return build_decl_list (NULL_TREE, value); -} - -/* Look in the type hash table for a type isomorphic to - `build_tree_list (NULL_TREE, VALUE)'. - If one is found, return it. Otherwise return 0. */ - -tree -list_hash_lookup_or_cons (value) - tree value; -{ - register int hashcode = TYPE_HASH (value); - register struct list_hash *h; - struct obstack *ambient_obstack; - tree list = NULL_TREE; - - if (TREE_CODE (value) == IDENTIFIER_NODE) - { - list = IDENTIFIER_AS_LIST (value); - if (list != NULL_TREE - && (TREE_CODE (list) != TREE_LIST - || TREE_VALUE (list) != value)) - list = NULL_TREE; - else if (TREE_TYPE (value) != NULL_TREE - && TREE_CODE (TREE_TYPE (TREE_TYPE (value))) == RECORD_TYPE) - { - tree type = TREE_TYPE (TREE_TYPE (value)); - if (CLASSTYPE_AS_ID_LIST (type) == NULL_TREE) - CLASSTYPE_AS_ID_LIST (type) = perm_tree_cons (NULL_TREE, value, NULL_TREE); - list = CLASSTYPE_AS_ID_LIST (type); - } - } - else if (TREE_CODE (value) == TYPE_DECL - && TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE - && TYPE_LANG_SPECIFIC (TREE_TYPE (value))) - list = CLASSTYPE_AS_ID_LIST (TREE_TYPE (value)); - else if (TREE_CODE (value) == RECORD_TYPE - && TYPE_LANG_SPECIFIC (value)) - list = CLASSTYPE_AS_LIST (value); - - if (list != NULL_TREE) - { - assert (TREE_CHAIN (list) == NULL_TREE); - return list; - } - - if (debug_no_list_hash) - return hash_tree_chain (value, NULL_TREE); - - for (h = list_hash_table[hashcode % TYPE_HASH_SIZE]; h; h = h->next) - if (h->hashcode == hashcode - && TREE_VIA_VIRTUAL (h->list) == 0 - && TREE_VIA_PUBLIC (h->list) == 0 - && TREE_PURPOSE (h->list) == 0 - && TREE_VALUE (h->list) == value) - { - assert (TREE_TYPE (h->list) == 0); - assert (TREE_CHAIN (h->list) == 0); - return h->list; - } - - ambient_obstack = current_obstack; - current_obstack = &class_obstack; - list = build_tree_list (NULL_TREE, value); - list_hash_add (hashcode, list); - current_obstack = ambient_obstack; - return list; -} - -/* Build an association between TYPE and some parameters: - - OFFSET is the offset added to `this' to convert it to a pointer - of type `TYPE *' - - VTABLE is the virtual function table with which to initialize - sub-objects of type TYPE. - - VIRTUALS are the virtual functions sitting in VTABLE. - - CHAIN are more associations we must retain. */ - -tree -make_assoc (offset, type, vtable, virtuals, chain) - tree offset, type; - tree vtable, virtuals; - tree chain; -{ - tree assoc = make_tree_vec (4); - - TREE_TYPE (assoc) = type; - TREE_CHAIN (assoc) = chain; - if (chain) - TREE_USED (assoc) = TREE_USED (chain); - - /* n.b.: TREE_VEC_ELT (assoc, 0) <=> TREE_VALUE (assoc). */ - TREE_VEC_ELT (assoc, 0) = TYPE_MAIN_VARIANT (type); - TREE_VEC_ELT (assoc, 1) = offset; - TREE_VEC_ELT (assoc, 2) = vtable; - TREE_VEC_ELT (assoc, 3) = virtuals; - return assoc; -} - -tree -copy_assoc (list) - tree list; -{ - tree assoc = copy_list (list); - tree rval = assoc; - while (assoc) - { - TREE_USED (assoc) = 0; - assoc = TREE_CHAIN (assoc); - } - return rval; -} - -tree -assoc_value (elem, type) - tree elem; - tree type; -{ - tree assoc = CLASSTYPE_ASSOC (type); - tree rval = NULL_TREE; - - /* Dispose quickly of degenerate case. */ - if (elem == type) - return assoc; - - while (assoc) - { - if (elem == ASSOC_VALUE (assoc)) - /* If we find it on the main spine, then - there can be no ambiguity. */ - return assoc; - - if (ASSOC_VALUE (assoc) != type) - { - tree nval = assoc_value (elem, ASSOC_TYPE (assoc)); - - if (nval) - if (rval && ASSOC_TYPE (rval) != ASSOC_TYPE (nval)) - /* If we find it underneath, we must make sure that - there are no two ways to do it. */ - compiler_error ("base class `%s' ambiguous in assoc_value", - TYPE_NAME_STRING (elem)); - else - rval = nval; - } - assoc = TREE_CHAIN (assoc); - } - return rval; -} - -tree -virtual_member (elem, list) - tree elem; - tree list; -{ - tree t; - tree rval, nval; - - for (t = list; t; t = TREE_CHAIN (t)) - if (elem == TREE_VALUE (t)) - return t; - rval = 0; - for (t = list; t; t = TREE_CHAIN (t)) - { - int i; - for (i = CLASSTYPE_N_BASECLASSES (TREE_TYPE (t)); i > 0; i--) - { - nval = assoc_value (elem, CLASSTYPE_BASECLASS (TREE_TYPE (t), i)); - if (nval) - { - if (rval && TREE_TYPE (nval) != TREE_TYPE (rval)) - abort (); - rval = nval; - } - } - } - return rval; -} - -void -debug_dump_assoc (elem) - tree elem; -{ - int i; - tree virtuals; - - fprintf (stderr, "type \"%s\"; offset = %d\n", - IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (ASSOC_VALUE (elem)))), - TREE_INT_CST_LOW (ASSOC_OFFSET (elem))); - fprintf (stderr, "vtable type:\n"); - dump_tree (stderr, ASSOC_TYPE (elem)); - if (ASSOC_VTABLE (elem)) - fprintf (stderr, "vtable decl \"%s\"\n", IDENTIFIER_POINTER (DECL_NAME (ASSOC_VTABLE (elem)))); - else - fprintf (stderr, "no vtable decl yet\n"); - fprintf (stderr, "virtuals:\n"); - virtuals = ASSOC_VIRTUALS (elem); - if (virtuals != 0) - virtuals = TREE_CHAIN (virtuals); - i = 1; - while (virtuals) - { - tree fndecl = TREE_OPERAND (FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (virtuals)), 0); - fprintf (stderr, "%s [%d =? %d]\n", - IDENTIFIER_POINTER (DECL_NAME (fndecl)), - i, TREE_INT_CST_LOW (DECL_VINDEX (fndecl))); - virtuals = TREE_CHAIN (virtuals); - i += 1; - } -} - -char * -lang_printable_name (decl) - tree decl; -{ - if (TREE_CODE (decl) != FUNCTION_DECL - || DECL_LANG_SPECIFIC (decl) == 0) - { - if (DECL_NAME (decl)) - { - if (THIS_NAME_P (DECL_NAME (decl))) - return "this"; - return IDENTIFIER_POINTER (DECL_NAME (decl)); - } - return "((anonymous))"; - } - if (DECL_PRINT_NAME (decl) == 0) - { - int print_ret_type_p - = (!DECL_CONSTRUCTOR_P (decl) - && !DESTRUCTOR_NAME_P (DECL_NAME (decl))); - int temp = allocation_temporary_p (); - char *buf = (char *)alloca (8192); - char *name = (char *)fndecl_as_string (buf, 0, decl, print_ret_type_p); - end_temporary_allocation (); - DECL_PRINT_NAME (decl) = oballoc (strlen (name) + 1); - strcpy (DECL_PRINT_NAME (decl), name); - if (temp) - resume_temporary_allocation (); - } - else if (DECL_NAME (decl) == 0) - DECL_PRINT_NAME (decl) = "((anonymous))"; - - return DECL_PRINT_NAME (decl); -} - -/* Return truthvalue about whether debugger should - output full info about this type or not. - - Current strategy is to permit types which define - no member functions to be output normally. For - those which do define member functions, if no - member functions have yet been output, then don't - output the definition of the type. If member functions - for the type are later seen, a full definition of the - type will eventually be output. */ -int -lang_output_debug_info (type) - tree type; -{ - extern tree pending_vtables; - - if (! IS_AGGR_TYPE (type)) - return 1; - if (TYPE_LANG_SPECIFIC (type) == 0) - return 1; - if (CLASSTYPE_METHOD_VEC (type) == 0) - return 1; - - if (flag_minimal_debug) - { - /* Don't output full info about any type - which does not have its implementation defined here. */ - if (TYPE_VIRTUAL_P (type) && write_virtuals == 2) - return value_member (DECL_NAME (TYPE_NAME (type)), pending_vtables) != 0; - if (CLASSTYPE_INTERFACE_ONLY (type)) - return 0; - - return CLASSTYPE_ASM_WRITTEN (type); - } - else - /* Can't work until GDB is modified. */ - return 1; -} - -/* Comparison function for sorting identifiers in RAISES lists. - Note that because IDENTIFIER_NODEs are unique, we can sort - them by address, saving an indirection. */ -static int -id_cmp (p1, p2) - int *p1, *p2; -{ - return *p1 - *p2; -} - -/* Build the FUNCTION_TYPE or METHOD_TYPE which may raise exceptions - listed in RAISES. */ -tree -build_exception_variant (ctype, type, raises) - tree ctype, type; - tree raises; -{ - int i; - tree v = TYPE_MAIN_VARIANT (type); - tree t, t2, cname; - tree *a = (tree *)alloca ((list_length (raises)+1) * sizeof (tree)); - int constp = TREE_READONLY (type); - int volatilep = TREE_VOLATILE (type); - - if (raises && TREE_CHAIN (raises)) - { - for (i = 0, t = raises; t; t = TREE_CHAIN (t), i++) - a[i] = t; - /* NULL terminator for list. */ - a[i] = NULL_TREE; - qsort (a, i, sizeof (tree), id_cmp); - while (i--) - TREE_CHAIN (a[i]) = a[i+1]; - raises = a[0]; - } - else if (raises) - /* do nothing. */; - else - return build_type_variant (v, constp, volatilep); - - if (ctype) - { - cname = TYPE_NAME (ctype); - if (TREE_CODE (cname) == TYPE_DECL) - cname = DECL_NAME (cname); - } - else - cname = NULL_TREE; - - for (t = raises; t; t = TREE_CHAIN (t)) - { - /* See that all the exceptions we are thinking about - raising have been declared. */ - tree this_cname = lookup_exception_cname (ctype, cname, t); - tree decl = lookup_exception_object (this_cname, TREE_VALUE (t), 1); - - if (decl == NULL_TREE) - decl = lookup_exception_object (this_cname, TREE_VALUE (t), 0); - /* Place canonical exception decl into TREE_TYPE of RAISES list. */ - TREE_TYPE (t) = decl; - } - - for (v = TYPE_NEXT_VARIANT (v); v; v = TYPE_NEXT_VARIANT (v)) - { - if (TREE_READONLY (v) != constp - || TREE_VOLATILE (v) != volatilep) - continue; - - t = raises; - t2 = TYPE_RAISES_EXCEPTIONS (v); - while (t && t2) - { - if (TREE_TYPE (t) == TREE_TYPE (t2)) - { - t = TREE_CHAIN (t); - t2 = TREE_CHAIN (t2); - } - else break; - } - if (t || t2) - continue; - /* List of exceptions raised matches previously found list. - - @@ Nice to free up storage used in consing up the - @@ list of exceptions raised. */ - return v; - } - - /* Need to build a new variant. */ - v = copy_node (type); - TYPE_NEXT_VARIANT (v) = TYPE_NEXT_VARIANT (type); - TYPE_NEXT_VARIANT (type) = v; - if (raises && ! TREE_PERMANENT (raises)) - { - int temporary = allocation_temporary_p (); - if (temporary) - end_temporary_allocation (); - raises = copy_list (raises); - if (temporary) - resume_temporary_allocation (); - } - TYPE_RAISES_EXCEPTIONS (v) = raises; - return v; -} - -/* Subroutine of make_permanent_node. - - Assuming T is a node build bottom-up, make it all exist on - permanent obstack, if it is not permanent already. */ -static tree -make_deep_copy (t) - tree t; -{ - enum tree_code code; - - if (t == NULL_TREE || TREE_PERMANENT (t)) - return t; - - switch (code = TREE_CODE (t)) - { - case ERROR_MARK: - return error_mark_node; - - case VAR_DECL: - case PARM_DECL: - case FUNCTION_DECL: - case CONST_DECL: - break; - - case TREE_LIST: - { - tree chain = TREE_CHAIN (t); - t = copy_node (t); - TREE_PURPOSE (t) = make_deep_copy (TREE_PURPOSE (t)); - TREE_VALUE (t) = make_deep_copy (TREE_VALUE (t)); - TREE_CHAIN (t) = make_deep_copy (chain); - return t; - } - - case TREE_VEC: - { - int len = TREE_VEC_LENGTH (t); - - t = copy_node (t); - while (len--) - TREE_VEC_ELT (t, len) = make_deep_copy (TREE_VEC_ELT (t, len)); - return t; - } - - case INTEGER_CST: - case REAL_CST: - case STRING_CST: - return copy_node (t); - - case COND_EXPR: - case NEW_EXPR: - t = copy_node (t); - TREE_OPERAND (t, 0) = make_deep_copy (TREE_OPERAND (t, 0)); - TREE_OPERAND (t, 1) = make_deep_copy (TREE_OPERAND (t, 1)); - TREE_OPERAND (t, 2) = make_deep_copy (TREE_OPERAND (t, 2)); - return t; - - case SAVE_EXPR: - t = copy_node (t); - TREE_OPERAND (t, 0) = make_deep_copy (TREE_OPERAND (t, 0)); - return t; - - case MODIFY_EXPR: - case PLUS_EXPR: - case MINUS_EXPR: - case MULT_EXPR: - case TRUNC_DIV_EXPR: - case TRUNC_MOD_EXPR: - case MIN_EXPR: - case MAX_EXPR: - case LSHIFT_EXPR: - case RSHIFT_EXPR: - case BIT_IOR_EXPR: - case BIT_XOR_EXPR: - case BIT_AND_EXPR: - case BIT_ANDTC_EXPR: - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - case LT_EXPR: - case LE_EXPR: - case GT_EXPR: - case GE_EXPR: - case EQ_EXPR: - case NE_EXPR: - case CEIL_DIV_EXPR: - case FLOOR_DIV_EXPR: - case ROUND_DIV_EXPR: - case CEIL_MOD_EXPR: - case FLOOR_MOD_EXPR: - case ROUND_MOD_EXPR: - case COMPOUND_EXPR: - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - case CALL_EXPR: - t = copy_node (t); - TREE_OPERAND (t, 0) = make_deep_copy (TREE_OPERAND (t, 0)); - TREE_OPERAND (t, 1) = make_deep_copy (TREE_OPERAND (t, 1)); - return t; - - case CONVERT_EXPR: - case ADDR_EXPR: - case INDIRECT_REF: - case NEGATE_EXPR: - case BIT_NOT_EXPR: - case TRUTH_NOT_EXPR: - case NOP_EXPR: - case COMPONENT_REF: - t = copy_node (t); - TREE_OPERAND (t, 0) = make_deep_copy (TREE_OPERAND (t, 0)); - return t; - - /* This list is incomplete, but should suffice for now. - It is very important that `sorry' does not call - `report_error_function'. That could cause an infinite loop. */ - default: - sorry ("initializer contains unrecognized tree code"); - return error_mark_node; - - } - abort (); -} - -/* Assuming T is a node built bottom-up, make it all exist on - permanent obstack, if it is not permanent already. */ -tree -copy_to_permanent (t) - tree t; -{ - register struct obstack *ambient_obstack = current_obstack; - register struct obstack *ambient_saveable_obstack = saveable_obstack; - - if (t == NULL_TREE || TREE_PERMANENT (t)) - return t; - - saveable_obstack = &permanent_obstack; - current_obstack = saveable_obstack; - - t = make_deep_copy (t); - - current_obstack = ambient_obstack; - saveable_obstack = ambient_saveable_obstack; - - return t; -} - -int -lang_simple_cst_equal (t1, t2) - tree t1, t2; -{ - register enum tree_code code1, code2; - int cmp; - - if (t1 == t2) - return 1; - if (t1 == 0 || t2 == 0) - return 0; - - code1 = TREE_CODE (t1); - code2 = TREE_CODE (t2); - - switch (code1) - { - case CPLUS_NEW_EXPR: - cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)); - if (cmp <= 0) - return cmp; - return simple_cst_list_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)); - - default: - return -1; - } -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-tree.def b/gnu/usr.bin/g++/cc1plus/cplus-tree.def deleted file mode 100644 index 60840c7394ac..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-tree.def +++ /dev/null @@ -1,28 +0,0 @@ -/* For DELETE_EXPR, operand 0 is the store to be destroyed. - Operand 1 is the value to pass to the destroying function - saying whether the store should be deallocated as well. */ -DEFTREECODE (DELETE_EXPR, "delete_expr", "e", 2) - -/* Value is reference to particular overloaded class method. - Operand 0 is the class name (an IDENTIFIER_NODE); - operand 1 is the field (also an IDENTIFIER_NODE). */ -DEFTREECODE (SCOPE_REF, "scope_ref", "r", 2) - -/* When composing an object with a member, this is the result. - Operand 0 is the object. Operand 1 is the member (usually - a dereferenced pointer to member). */ -DEFTREECODE (MEMBER_REF, "member_ref", "r", 2) - -/* Type conversion operator in C++. TREE_TYPE is type that this - operator converts to. Operand is expression to be converted. */ -DEFTREECODE (TYPE_EXPR, "type_expr", "e", 1) - -/* For CPLUS_NEW_EXPR, operand 0 is function which performs initialization, - operand 1 is argument list to initialization function, - and operand 2 is the slot which was allocated for this expression. */ -DEFTREECODE (CPLUS_NEW_EXPR, "cplus_new_expr", "e", 3) - -/* Distinguish variables that are only used to identify exceptions - that were caught. Only the DECL_NAME (and TREE_CHAIN) - is really used. */ -DEFTREECODE (CPLUS_CATCH_DECL, "cplus_catch_decl", "d", 0) diff --git a/gnu/usr.bin/g++/cc1plus/cplus-tree.h b/gnu/usr.bin/g++/cc1plus/cplus-tree.h deleted file mode 100644 index a0dee89ff8eb..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-tree.h +++ /dev/null @@ -1,1604 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * - * @(#)cplus-tree.h 6.4 (Berkeley) 5/8/91 - */ - -/* Definitions for C++ parsing and type checking. - Copyright (C) 1987 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -and this notice must be preserved on all copies. */ - -/* Borrow everything that is C from c-tree.h, - but do so by copy, not by inclusion, since c-tree.h defines - lang_identifier. */ - -/* Definitions for C parsing and type checking. - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Language-dependent contents of an identifier. */ - -struct lang_identifier -{ - struct tree_identifier ignore; - tree global_value, local_value; - tree class_value; - struct lang_id2 *x; -}; - -struct lang_id2 -{ - tree label_value, implicit_decl; - tree error_locus; -}; - -/* Macros for access to language-specific slots in an identifier. */ - -#define IDENTIFIER_GLOBAL_VALUE(NODE) \ - (((struct lang_identifier *)(NODE))->global_value) -#define IDENTIFIER_CLASS_VALUE(NODE) \ - (((struct lang_identifier *)(NODE))->class_value) -#define IDENTIFIER_LOCAL_VALUE(NODE) \ - (((struct lang_identifier *)(NODE))->local_value) -#define IDENTIFIER_AS_LIST(NODE) \ - ((tree)((struct lang_identifier *)(NODE))->x) -#define SET_IDENTIFIER_AS_LIST(NODE,LIST) \ - (((struct lang_identifier *)(NODE))->x = (struct lang_id2*)(LIST)) - -#define IDENTIFIER_LABEL_VALUE(NODE) \ - (((struct lang_identifier *)(NODE))->x \ - ? ((struct lang_identifier *)(NODE))->x->label_value : 0) -#define SET_IDENTIFIER_LABEL_VALUE(NODE,VALUE) \ - (((struct lang_identifier *)(NODE))->x == 0 ? ((struct lang_identifier *)(NODE))->x = (struct lang_id2 *)permalloc (sizeof (struct lang_id2)) : 0, \ - ((struct lang_identifier *)(NODE))->x->label_value = (VALUE)) -#define IDENTIFIER_IMPLICIT_DECL(NODE) \ - (((struct lang_identifier *)(NODE))->x \ - ? ((struct lang_identifier *)(NODE))->x->implicit_decl : 0) -#define SET_IDENTIFIER_IMPLICIT_DECL(NODE,VALUE) \ - (((struct lang_identifier *)(NODE))->x == 0 ? ((struct lang_identifier *)(NODE))->x = (struct lang_id2 *)permalloc (sizeof (struct lang_id2)) : 0, \ - ((struct lang_identifier *)(NODE))->x->implicit_decl = (VALUE)) -#define IDENTIFIER_ERROR_LOCUS(NODE) \ - (((struct lang_identifier *)(NODE))->x \ - ? ((struct lang_identifier *)(NODE))->x->error_locus : 0) -#define SET_IDENTIFIER_ERROR_LOCUS(NODE,VALUE) \ - (((struct lang_identifier *)(NODE))->x == 0 ? ((struct lang_identifier *)(NODE))->x = (struct lang_id2 *)permalloc (sizeof (struct lang_id2)) : 0, \ - ((struct lang_identifier *)(NODE))->x->error_locus = (VALUE)) - -/* Nonzero means reject anything that ANSI standard C forbids. */ -extern int pedantic; - -/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */ -#define C_TYPE_FIELDS_READONLY(type) TYPE_SEP_UNIT (type) - -/* in c-typeck.c */ -extern tree build_component_ref(), build_conditional_expr(); -extern tree build_x_compound_expr (), build_compound_expr(); -extern tree build_unary_op(), build_binary_op(), build_function_call(); -extern tree build_binary_op_nodefault (); -extern tree build_indirect_ref(), build_array_ref(), build_c_cast(); -extern tree build_modify_expr(); -extern tree c_sizeof (), c_alignof (); -extern tree store_init_value (); -extern tree digest_init (); -extern tree c_expand_start_case (); -extern tree default_conversion (); - -/* Given two integer or real types, return the type for their sum. - Given two compatible ANSI C types, returns the merged type. */ - -extern tree commontype (); - -/* in c-decl.c */ -extern tree build_label (); - -/* If non-zero, a VAR_DECL whose cleanup will cause a throw to the - next exception handler. */ -extern tree exception_throw_decl; - -extern int start_function (); -extern void finish_function (); -extern void store_parm_decls (); -extern tree get_parm_info (); - -extern void pushlevel (); -extern tree poplevel (); - -extern tree groktypename(), lookup_name(); - -extern tree lookup_label(), define_label(); - -extern tree implicitly_declare(), getdecls(), gettags (); - -extern tree start_decl(); -extern void finish_decl(); - -extern tree start_struct(), finish_struct(), xref_tag(); -extern tree finish_exception (); -extern tree grokfield(), grokbitfield (); - -extern tree start_enum(), finish_enum(); -extern tree build_enumerator(); - -extern tree make_index_type (); - -extern tree double_type_node, long_double_type_node, float_type_node; -extern tree char_type_node, unsigned_char_type_node, signed_char_type_node; - -extern tree short_integer_type_node, short_unsigned_type_node; -extern tree long_integer_type_node, long_unsigned_type_node; -extern tree long_long_integer_type_node, long_long_unsigned_type_node; -extern tree unsigned_type_node; -extern tree string_type_node, char_array_type_node, int_array_type_node; - -extern int current_function_returns_value; -extern int current_function_returns_null; - -extern tree ridpointers[]; - -/* Nonzero means `$' can be in an identifier. */ - -extern int dollars_in_ident; - -/* Nonzero means allow type mismatches in conditional expressions; - just make their values `void'. */ - -extern int flag_cond_mismatch; - -/* Nonzero means don't recognize the keyword `asm'. */ - -extern int flag_no_asm; - -/* Nonzero means warn about implicit declarations. */ - -extern int warn_implicit; - -/* Nonzero means warn about function definitions that default the return type - or that use a null return and have a return-type other than void. */ - -extern int warn_return_type; - -/* Nonzero means give string constants the type `const char *' - to get extra warnings from them. These warnings will be too numerous - to be useful, except in thoroughly ANSIfied programs. */ - -extern int warn_write_strings; - -/* Nonzero means warn about sizeof(function) or addition/subtraction - of function pointers. */ - -extern int warn_pointer_arith; - -/* Nonzero means warn for all old-style non-prototype function decls. */ - -extern int warn_strict_prototypes; - -/* Nonzero means warn about pointer casts that can drop a type qualifier - from the pointer target type. */ - -extern int warn_cast_qual; - -/* Nonzero means do some things the same way PCC does. */ - -extern int flag_traditional; - -/* 2 means write out only specific virtual function tables - and give them (C) public visibility. - 1 means write out virtual function tables and give them - (C) public visibility. - 0 means write out virtual function tables and give them - (C) static visibility. - -1 means declare virtual function tables extern. */ - -extern int write_virtuals; - -/* Nonzero means that we are in an "interface" section of the compiler. */ -extern int interface_only; - -/* Nonzero means we should attempt to elide constructors when possible. */ - -extern int flag_elide_constructors; - -/* Nonzero means if the type has methods, only output debugging - information if methods are actually written to the asm file. */ - -extern int flag_minimal_debug; - -/* Nonzero means recognize and handle exception handling constructs. */ - -extern int flag_handle_exceptions; - -/* Nonzero means that member functions defined in class scope are - inline by default. */ - -extern int flag_default_inline; - -/* Nonzero means recognize and handle exception handling constructs. */ - -extern int flag_no_inline; - -/* Nonzero means emit cadillac protocol. */ - -extern int flag_cadillac; - -#ifndef HAVE_CADILLAC -#define cadillac_finish_anon_union(decl) -#define cadillac_finish_decl(decl) -#define cadillac_finish_enum(enumtype) -#define cadillac_finish_exception(e) -#define cadillac_finish_function(fndecl) -#define cadillac_finish_stmt() -#define cadillac_finish_struct(t) -#define cadillac_note_source() -#define cadillac_pop_class() -#define cadillac_pop_lang() -#define cadillac_pop_source() -#define cadillac_push_class(type) -#define cadillac_push_lang(name) -#define cadillac_push_source() -#define cadillac_start() -#define cadillac_start_decl(value) -#define cadillac_start_enum(ref) -#define cadillac_start_function(decl1) -#define cadillac_start_struct(ref) -#define cadillac_switch_source(flag) -#define init_cadillac() -#endif - -/* C++ language-specific tree codes. */ -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM, -enum cplus_tree_code { - __DUMMY = LAST_AND_UNUSED_TREE_CODE, -#include "cplus-tree.def" - LAST_CPLUS_TREE_CODE -}; -#undef DEFTREECODE - -enum languages { lang_c, lang_cplusplus }; - -/* Macros to make error reporting functions' lives easier. */ -#define TYPE_NAME_STRING(NODE) (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (NODE)))) -#define TYPE_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (DECL_NAME (TYPE_NAME (NODE)))) - -/* Virtual function addresses can be gotten from a virtual function - table entry using this macro. */ -#define FNADDR_FROM_VTABLE_ENTRY(ENTRY) \ - TREE_VALUE (TREE_CHAIN (TREE_CHAIN (CONSTRUCTOR_ELTS (ENTRY)))) - -enum conversion_type { ptr_conv, constptr_conv, int_conv, real_conv, last_conversion_type }; - -/* Statistics show that while the GNU C++ compiler may generate - thousands of different types during a compilation run, it - generates relatively few (tens) of classtypes. Because of this, - it is not costly to store a generous amount of information - in classtype nodes. */ -struct lang_type -{ - /* This must fill out to a multiple of 4 bytes. */ - struct - { - unsigned has_type_conversion : 1; - unsigned has_int_conversion : 1; - unsigned has_float_conversion : 1; - unsigned has_init_ref : 1; - unsigned gets_init_ref : 1; - unsigned gets_init_aggr : 1; - unsigned has_assignment : 1; - unsigned gets_assignment : 1; - - unsigned has_assign_ref : 1; - unsigned gets_assign_ref : 1; - unsigned gets_new : 1; - unsigned gets_delete : 1; - unsigned has_wrapper_pred : 1; - unsigned has_method_call_overloaded : 1; - unsigned has_call_overloaded : 1; - unsigned has_array_ref_overloaded : 1; - - unsigned any_assigns_this : 1; - unsigned none_assign_this : 1; - unsigned marked : 1; - unsigned marked2 : 1; - unsigned marked3 : 1; - unsigned marked4 : 1; - unsigned marked5 : 1; - unsigned marked6 : 1; - - unsigned virtual_attr : 1; - unsigned needs_constructor : 1; - unsigned declared_class : 1; - unsigned private_attr : 1; - unsigned const_needs_init : 1; - unsigned ref_needs_init : 1; - unsigned uses_virtual_base_classes : 1; - unsigned uses_multiple_inheritance : 1; - - unsigned got_semicolon : 1; - unsigned alters_visibilities : 1; - unsigned needs_virtual_reinit : 1; - unsigned asm_written : 1; - unsigned declared_exception : 1; - unsigned vtable_needs_writing : 1; - unsigned local_typedecls : 1; - unsigned gets_const_init_ref : 1; - - unsigned dynamic : 1; - unsigned has_default_ctor : 1; - unsigned gets_const_assign_ref : 1; - unsigned has_const_assign_ref : 1; - unsigned interface_only : 1; - unsigned interface_unknown : 1; - unsigned dummy3 : 2; - } type_flags; - - unsigned n_parents : 16; - int cid; - int n_ancestors; - int n_vancestors; - int vsize; - - union tree_node *method_vec, *baselink_vec; - union tree_node *offset; - union tree_node *vfield, *vfields; - union tree_node *vbases; - union tree_node *vbase_size; - - union tree_node *tags; - union tree_node *main_class_variant; - union tree_node *this_class_variant; - union tree_node *next_class_variant; - void *memoized_table_entry; - - unsigned char *via_pub_or_virt; - - union tree_node **types; - void *search_slot; - - enum machine_mode mode : 8; - unsigned char size_unit; - unsigned char align; - unsigned char sep_unit; - - union tree_node *sep; - union tree_node *size; - - union tree_node *base_init_list; - union tree_node *abstract_virtuals; - union tree_node *as_list; - union tree_node *as_id_list; - union tree_node *vtbl_ptr; - union tree_node *instance_variable; - union tree_node *friend_classes; - - char *mi_matrix; - union tree_node *conversions[last_conversion_type]; - union tree_node *wrap_type; - -#ifdef SOS - union tree_node *typename_as_string; - union tree_node *dynamic_filename; - union tree_node *dynamic_table; -#endif -}; - -/* Fields used for storing information before the class is defined. - After the class is defined, these fields hold other information. */ - -/* List of friends which were defined inline in this class definition. */ -#define CLASSTYPE_INLINE_FRIENDS(NODE) (TYPE_NONCOPIED_PARTS (NODE)) - -/* Nonzero for _CLASSTYPE means that the _CLASSTYPE either has - a special meaning for the assignment operator ("operator="), - or one of its fields (or base members) has a special meaning - defined. */ -#define TYPE_HAS_ASSIGNMENT(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_assignment) -#define TYPE_GETS_ASSIGNMENT(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_assignment) - -/* Nonzero for _CLASSTYPE means that operator new and delete are defined, - respectively. */ -#define TREE_GETS_NEW(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_new) -#define TREE_GETS_DELETE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_delete) - -/* Nonzero for TREE_LIST or _CLASSTYPE node means that the path to the - base class is via a `public' declaration, which preserves public - fields from the base class as public. - OVERLOADED. */ -#define TREE_VIA_PUBLIC(NODE) ((NODE)->common.used_attr) /* overloaded! */ - -/* Nonzero for TREE_LIST node means that the path to the - base class is via a `protected' declaration, which preserves - protected fields from the base class as protected. - OVERLOADED. */ -#define TREE_VIA_PROTECTED(NODE) ((NODE)->common.literal_attr) /* overloaded! */ - -/* Nonzero for a _CLASSTYPE node which we know to be private. */ -#define TYPE_PRIVATE_P(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.private_attr) - -/* Nonzero for a _CLASSTYPE node means that the derivation chain is via - a `virtual' declaration. */ -#define TREE_VIA_VIRTUAL(NODE) ((NODE)->common.literal_attr) /* overloaded! */ - -/* Nonzero means that this _CLASSTYPE node defines ways of converting - itself to other types. */ -#define TYPE_HAS_CONVERSION(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_type_conversion) - -/* Nonzero means that this _CLASSTYPE node can convert itself to an - INTEGER_TYPE. */ -#define TYPE_HAS_INT_CONVERSION(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_int_conversion) - -/* Nonzero means that this _CLASSTYPE node can convert itself to an - REAL_TYPE. */ -#define TYPE_HAS_REAL_CONVERSION(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_float_conversion) - -/* Nonzero means that this _CLASSTYPE node overloads operator=(X&). */ -#define TYPE_HAS_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_assign_ref) -#define TYPE_GETS_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_assign_ref) -#define TYPE_HAS_CONST_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_const_assign_ref) -#define TYPE_GETS_CONST_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_const_assign_ref) - -/* Nonzero means that this _CLASSTYPE node has an X(X&) constructor. */ -#define TYPE_HAS_INIT_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_init_ref) -#define TYPE_GETS_INIT_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_init_ref) -#define TYPE_GETS_CONST_INIT_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_const_init_ref) - -/* Nonzero means that this _CLASSTYPE node has an X(X ...) constructor. - Note that there must be other arguments, or this constructor is flaged - as being erroneous. */ -#define TYPE_GETS_INIT_AGGR(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_init_aggr) - -/* Nonzero means that this _CLASSTYPE node overloads the method call - operator. In this case, all method calls go through `operator->()(...). */ -#define TYPE_OVERLOADS_METHOD_CALL_EXPR(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_method_call_overloaded) - -#define TYPE_WRAP_TYPE(NODE) (TYPE_LANG_SPECIFIC(NODE)->wrap_type) - -#define TYPE_HAS_WRAPPER(NODE) (TYPE_LANG_SPECIFIC(NODE)->wrap_type == TYPE_MAIN_VARIANT (NODE)) -#define TYPE_NEEDS_WRAPPER(NODE) (TYPE_LANG_SPECIFIC(NODE)->wrap_type != 0 && TYPE_LANG_SPECIFIC(NODE)->wrap_type != TYPE_MAIN_VARIANT (NODE)) -#define TYPE_HAS_WRAPPER_PRED(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_wrapper_pred) - -/* Nonzero means that this _CLASSTYPE node overloads operator(). */ -#define TYPE_OVERLOADS_CALL_EXPR(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_call_overloaded) - -/* Nonzero means that this _CLASSTYPE node overloads operator[]. */ -#define TYPE_OVERLOADS_ARRAY_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_array_ref_overloaded) - -/* Nonzero means that this _CLASSTYPE (or one of its ancestors) uses - multiple inheritance. If this is 0 for the root of a type - hierarchy, then we can use more efficient search techniques. */ -#define TYPE_USES_MULTIPLE_INHERITANCE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.uses_multiple_inheritance) - -/* Nonzero means that this _CLASSTYPE (or one of its ancestors) uses - virtual base classes. If this is 0 for the root of a type - hierarchy, then we can use more efficient search techniques. */ -#define TYPE_USES_VIRTUAL_BASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.uses_virtual_base_classes) - -/* List of lists of member functions defined in this class. */ -#define CLASSTYPE_METHOD_VEC(NODE) (TYPE_LANG_SPECIFIC(NODE)->method_vec) - -/* Pointer from any member function to the head of the list of - member functions of the type that member function belongs to. */ -#define CLASSTYPE_BASELINK_VEC(NODE) (TYPE_LANG_SPECIFIC(NODE)->baselink_vec) - -/* Nonzero if the Nth baseclass of this class is via `public'. */ -#define CLASSTYPE_VIA_PUBLIC(NODE, N) (TYPE_LANG_SPECIFIC(NODE)->via_pub_or_virt[N]&1) -/* Nonzero if the Nth baseclass of this class is via `virtual'. */ -#define CLASSTYPE_VIA_VIRTUAL(NODE, N) ((TYPE_LANG_SPECIFIC(NODE)->via_pub_or_virt[N]&2)>>1) - -/* Accessor macros for the above two constructs. */ -#define CLASSTYPE_VIAS(NODE) (TYPE_LANG_SPECIFIC(NODE)->via_pub_or_virt) -#define SET_CLASSTYPE_VIAS(NODE, N, PUB, VIRT) (TYPE_LANG_SPECIFIC(NODE)->via_pub_or_virt[N] = (PUB|(VIRT<<1))) - -/* Mark bits for depth-first and breath-first searches. */ -#define CLASSTYPE_MARKED(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked) -#define CLASSTYPE_MARKED2(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked2) -#define CLASSTYPE_MARKED3(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked3) -#define CLASSTYPE_MARKED4(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked4) -#define CLASSTYPE_MARKED5(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked5) -#define CLASSTYPE_MARKED6(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked6) - -/* When building a matrix to determine by a single lookup - whether one class is derived from another or not, - this field is the index of the class in the table. */ -#define CLASSTYPE_CID(NODE) (TYPE_LANG_SPECIFIC(TYPE_MAIN_VARIANT (NODE))->cid) - -#define CLASSTYPE_TAGS(NODE) (TYPE_LANG_SPECIFIC(NODE)->tags) -#define CLASSTYPE_NAMES(NODE) (TYPE_LANG_SPECIFIC(NODE)->names) - -/* When a class becomes a non-leftmost baseclass in a multiple - inheritance hierarchy, the number of bytes that subobjects - of this type are offset from the begining of the containing record. - This is an INTEGER_CST which holds the value of - DECL_OFFSET (TYPE_NAME (NODE)). - - Note that for virtual base classes, the offset is only meaningful - for the construction and initialization of virtual baseclass pointers - and virtual function table entries. Otherwise, the offset of a - virtual baseclass is irrelevant, since it is accessed through a - pointer, and not via a delta. */ -#define CLASSTYPE_OFFSET(NODE) (TYPE_LANG_SPECIFIC (NODE)->offset) - -/* The virtual function table pointer field. */ -#define CLASSTYPE_VFIELD(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfield) -/* The number of virtual functions defined for this - _CLASSTYPE node. */ -#define CLASSTYPE_VSIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->vsize) -/* The virtual base classes that this type uses. */ -#define CLASSTYPE_VBASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->vbases) -/* The virtual function pointer fields that this type contains. */ -#define CLASSTYPE_VFIELDS(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfields) - -/* Number of baseclasses defined for this type. - 0 means no base classes. */ -#define CLASSTYPE_N_BASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->n_parents) -/* Vector of base classes for this type. This vector is - indexed starting at 1. */ -#define CLASSTYPE_BASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->types) -/* Accessor macro for the Nth baseclass of type NODE. */ -#define CLASSTYPE_BASECLASS(NODE, N) (TYPE_LANG_SPECIFIC(NODE)->types[N]) - -/* Memoize the number of super classes (base classes) tha this node - has. That way we can know immediately (albeit conservatively how - large a multiple-inheritance matrix we need to build to find - derivation information. */ -#define CLASSTYPE_N_SUPERCLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->n_ancestors) -#define CLASSTYPE_N_VBASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->n_vancestors) - -/* Used for keeping search-specific information. Any search routine - which uses this must define what exactly this slot is used for. */ -#define CLASSTYPE_SEARCH_SLOT(NODE) (TYPE_LANG_SPECIFIC(NODE)->search_slot) - -/* The canonical form of this base class. It also happens to be - TYPE_MAIN_VARIANT. */ -#define CLASSTYPE_MAIN_VARIANT(NODE) (TYPE_LANG_SPECIFIC(NODE)->main_class_variant) -/* For baseclasses with non-zero valued offsets, a chain of - such versions of this baseclass. */ -#define CLASSTYPE_NEXT_VARIANT(NODE) (TYPE_LANG_SPECIFIC(NODE)->next_class_variant) - -/* Entry for keeping memoization tables for this type to - hopefully speed up search routines. Since it is a pointer, - it can mean almost anything. */ -#define CLASSTYPE_MTABLE_ENTRY(NODE) (TYPE_LANG_SPECIFIC(NODE)->memoized_table_entry) - -/* This is the total size of the baseclasses defined for this type. - Needed because it is desirable to layout such information - before begining to process the class itself, and we - don't want to compute it second time when actually laying - out the type for real. */ -#define CLASSTYPE_SIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->size) -#define CLASSTYPE_SIZE_UNIT(NODE) (TYPE_LANG_SPECIFIC(NODE)->size_unit) -#define CLASSTYPE_MODE(NODE) (TYPE_LANG_SPECIFIC(NODE)->mode) -#define CLASSTYPE_ALIGN(NODE) (TYPE_LANG_SPECIFIC(NODE)->align) - -/* This is the space needed for virtual base classes. */ -#define CLASSTYPE_VBASE_SIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->vbase_size) - -/* A cons list of structure elements which either have constructors - to be called, or virtual function table pointers which - need initializing. Depending on what is being initialized, - the TREE_PURPOSE and TREE_VALUE fields have different meanings: - - Member initialization: - Base class construction: - Base class initialization: - Whole type: . */ -#define CLASSTYPE_BASE_INIT_LIST(NODE) (TYPE_LANG_SPECIFIC(NODE)->base_init_list) - -/* A cons list of virtual functions which cannot be inherited by - derived classes. When deriving from this type, the derived - class must provide its own definition for each of these functions. */ -#define CLASSTYPE_ABSTRACT_VIRTUALS(NODE) (TYPE_LANG_SPECIFIC(NODE)->abstract_virtuals) - -#define CLASSTYPE_ALTERS_VISIBILITIES_P(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.alters_visibilities) - -/* Nonzero means that this aggr type has been `closed' by a semicolon. */ -#define CLASSTYPE_GOT_SEMICOLON(NODE) (TYPE_LANG_SPECIFIC (NODE)->type_flags.got_semicolon) - -/* Nonzero means that the main virtual function table pointer needs to be - set because base constructors have placed the wrong value there. - If this is zero, it means that they placed the right value there, - and there is no need to change it. */ -#define CLASSTYPE_NEEDS_VIRTUAL_REINIT(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.needs_virtual_reinit) - -/* Nonzero means that a member function has actually been output for - this type. */ -#define CLASSTYPE_ASM_WRITTEN(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.asm_written) - -/* Nonzero means that if this type has virtual functions, that - the virtual function table will be written out. */ -#define CLASSTYPE_VTABLE_NEEDS_WRITING(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.vtable_needs_writing) - -/* Nonzero means that this type defines its own local type declarations. */ -#define CLASSTYPE_LOCAL_TYPEDECLS(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.local_typedecls) - -/* Nonzero means that this type has an X() constructor. */ -#define TYPE_HAS_DEFAULT_CONSTRUCTOR(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_default_ctor) - -/* Many routines need to cons up a list of basetypes for visibility - checking. This field contains a TREE_LIST node whose TREE_VALUE - is the main variant of the type, and whose TREE_VIA_PUBLIC - and TREE_VIA_VIRTUAL bits are correctly set. */ -#define CLASSTYPE_AS_LIST(NODE) (TYPE_LANG_SPECIFIC(NODE)->as_list) -/* Same, but cache a list whose value is the name of this type. */ -#define CLASSTYPE_AS_ID_LIST(NODE) (TYPE_LANG_SPECIFIC(NODE)->as_id_list) - -/* Slot in which to cache a copy of the local vtable pointer. */ -#define CLASSTYPE_VTBL_PTR(NODE) (TYPE_LANG_SPECIFIC(NODE)->vtbl_ptr) - -/* Hold the instance object associated with this method. */ -#define CLASSTYPE_INST_VAR(NODE) (TYPE_LANG_SPECIFIC(NODE)->instance_variable) - -/* A list of class types with which this type is a friend. */ -#define CLASSTYPE_FRIEND_CLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->friend_classes) - -/* Keep an inheritance lattice around so we can quickly tell whether - a type is derived from another or not. */ -#define CLASSTYPE_MI_MATRIX(NODE) (TYPE_LANG_SPECIFIC(NODE)->mi_matrix) - -/* If there is exactly one conversion to a non-void, non-const pointer type, - remember that here. If there are more than one, put - `error_mark_node' here. If there are none, this holds NULL_TREE. */ -#define CLASSTYPE_CONVERSION(NODE,KIND) (TYPE_LANG_SPECIFIC(NODE)->conversions[KIND]) - -/* Nonzero means that class is "dynamic" in SOS sense. (IRIA-specific.) */ -#define TYPE_DYNAMIC(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.dynamic) - -#ifdef SOS -/* The name of this type as a STRING. */ -#define CLASSTYPE_TYPENAME_AS_STRING(NODE) (TYPE_LANG_SPECIFIC(NODE)->typename_as_string) -/* The name of the file which defines this type. */ -#define CLASSTYPE_DYNAMIC_FILENAME(NODE) (TYPE_LANG_SPECIFIC(NODE)->dynamic_filename) -/* The table of all member functions, linearized. */ -#define CLASSTYPE_DYNAMIC_TABLE(NODE) (TYPE_LANG_SPECIFIC(NODE)->dynamic_table) -#endif - -/* Say whether this node was declared as a "class" or a "struct". */ -#define CLASSTYPE_DECLARED_CLASS(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.declared_class) -/* Say whether this node was declared as a "class" or a "struct". */ -#define CLASSTYPE_DECLARED_EXCEPTION(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.declared_exception) - -/* Nonzero if this class has const members which have no specified initialization. */ -#define CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.const_needs_init) - -/* Nonzero if this class has ref members which have no specified initialization. */ -#define CLASSTYPE_REF_FIELDS_NEED_INIT(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.ref_needs_init) - -/* Nonzero if this class is included from a header file which employs - `#pragma interface', and it is not included in its implementation file. */ -#define CLASSTYPE_INTERFACE_ONLY(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.interface_only) - -/* Same as above, but for classes whose purpose we do not know. */ -#define CLASSTYPE_INTERFACE_UNKNOWN(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.interface_unknown) - -/* Depending on a class's "owner" they may have different properties, - such as the offset which must be added to `this', and the - virtual function table with which they are initialized. This is - managed by an association list of type TREE_LIST. This is - the interfact to the association list. */ - -/* The class's virtual function table. */ -#define ASSOC_VTABLE(NODE) TREE_VEC_ELT ((NODE), 2) -#define CLASS_ASSOC_VTABLE(NODE) ASSOC_VTABLE (TYPE_BASETYPES (NODE)) - -/* The virtual functions in the virtual function table. */ -#define ASSOC_VIRTUALS(NODE) TREE_VEC_ELT ((NODE), 3) -#define CLASS_ASSOC_VIRTUALS(NODE) ASSOC_VIRTUALS (TYPE_BASETYPES (NODE)) - -/* The class's offset to be added to `this'. */ -#define ASSOC_OFFSET(NODE) TREE_VEC_ELT ((NODE), 1) -#define CLASS_ASSOC_OFFSET(NODE) ASSOC_OFFSET (TYPE_BASETYPES (NODE)) - -/* The association key. */ -#define ASSOC_VALUE(NODE) TREE_VEC_ELT ((NODE), 0) -/* And its specific value. */ -#define ASSOC_TYPE(NODE) TREE_TYPE (NODE) - -#define CLASSTYPE_ASSOC(NODE) (TYPE_BASETYPES (NODE)) - -/* Nonzero for TREE_LIST node means that this list of things - is a list of parameters, as opposed to a list of expressions. */ -#define TREE_PARMLIST(NODE) TREE_UNSIGNED (NODE) /* overloaded! */ - -/* Nonzero for FIELD_DECL node means that this FIELD_DECL is - a member of an anonymous union construct. The name of the - union is . */ -#define TREE_ANON_UNION_ELEM(NODE) TREE_REGDECL (NODE) /* overloaded! */ - -/* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that - this type can raise. */ -#define TYPE_RAISES_EXCEPTIONS(NODE) TYPE_NONCOPIED_PARTS (NODE) - -struct lang_decl_flags -{ - enum languages language : 8; - - unsigned this_private : 1; - unsigned this_protected : 1; - unsigned this_public : 1; - unsigned operator_attr : 1; - unsigned overloaded_attr : 1; - unsigned constructor_attr : 1; - unsigned returns_first_arg : 1; - unsigned preserves_first_arg : 1; - - unsigned in_aggr : 1; - unsigned friend_attr : 1; - unsigned static_function : 1; - unsigned const_memfunc : 1; - unsigned volatile_memfunc : 1; - unsigned abstract_virtual : 1; - unsigned compiler_generated : 1; - unsigned permanent_attr : 1 ; - unsigned constructor_for_vbase_attr : 1; - unsigned dummy7 : 7; - - tree visibility; -}; - -struct lang_decl -{ - struct lang_decl_flags decl_flags; - - tree original_name; - tree vindex; - tree vcontext; - tree main_decl_variant; - struct pending_inline *pending_inline_info; - union tree_node *vbase_init_list; - -#ifdef SOS - tree dynamic_index; -#endif -}; - -/* Non-zero if NODE is a _DECL with TREE_READONLY set. */ -#define TREE_READONLY_DECL_P(NODE) \ - (TREE_READONLY (NODE) && *(tree_code_type[TREE_CODE (NODE)]) == 'd') - -/* For FUNCTION_DECLs: return the language in which this decl - was declared. */ -#define DECL_LANGUAGE(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.language) - -/* For FUNCTION_DECLs: nonzero means that this function is a constructor. */ -#define DECL_CONSTRUCTOR_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.constructor_attr) -/* For FUNCTION_DECLs: nonzero means that this function is a constructor - for an object with virtual baseclasses. */ -#define DECL_CONSTRUCTOR_FOR_VBASE_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.constructor_for_vbase_attr) - -/* For FUNCTION_DECLs: nonzero means that the constructor - is known to return a non-zero `this' unchanged. */ -#define DECL_RETURNS_FIRST_ARG(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.returns_first_arg) - -/* Nonzero for FUNCTION_DECL means that this constructor is known to - not make any assignment to `this', and therefore can be trusted - to return it unchanged. Otherwise, we must re-assign `current_class_decl' - after performing base initializations. */ -#define DECL_PRESERVES_THIS(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.preserves_first_arg) - -/* Nonzero for _DECL means that this decl appears in (or will appear - in) as a member in a RECORD_TYPE or UNION_TYPE node. It is also for - detecting circularity in case members are multiply defined. In the - case of a VAR_DECL, it is also used to determince how program storage - should be allocated. */ -#define DECL_IN_AGGR_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.in_aggr) - -/* Nonzero for FUNCTION_DECL means that this decl is just a - friend declaration, and should not be added to the list of - member functions for this class. */ -#define DECL_FRIEND_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.friend_attr) - -/* Nonzero for FUNCTION_DECL means that this decl is a static - member function. */ -#define DECL_STATIC_FUNCTION_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.static_function) - -/* Nonzero for FUNCTION_DECL means that this member function - has `this' as const X *const. */ -#define DECL_CONST_MEMFUNC_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.const_memfunc) - -/* Nonzero for FUNCTION_DECL means that this member function - has `this' as volatile X *const. */ -#define DECL_VOLATILE_MEMFUNC_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.volatile_memfunc) - -/* Nonzero for FUNCTION_DECL means that this member function - exists only as part of an abstract class's interface. */ -#define DECL_ABSTRACT_VIRTUAL_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.abstract_virtual) - -/* Nonzero for FUNCTION_DECL means that this member function - was generated by the compiler. This helps us give better - error messages. */ -#define DECL_COMPILER_GENERATED_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.compiler_generated) - -/* Nonzero if allocated on permanent_obstack. */ -#if 0 -/* @@ Not currently used. */ -#define LANG_DECL_PERMANENT(LANGDECL) ((LANGDECL)->decl_flags.permanent_attr) -#endif - -/* Nonzero for FIELD_DECL node means that this FIELD_DECL is - a member of an anonymous union construct. */ -#define DECL_ANON_UNION_ELEM(NODE) TREE_REGDECL (NODE) /* overloaded! */ - -/* For a FUNCTION_DECL: the name of the function before being overloaded. */ -#define DECL_ORIGINAL_NAME(NODE) (DECL_LANG_SPECIFIC(NODE)->original_name) - -/* Points back to the decl which caused this lang_decl to be allocated. */ -#define DECL_MAIN_VARIANT(NODE) (DECL_LANG_SPECIFIC(NODE)->main_decl_variant) - -/* For a FUNCTION_DECL: if this function was declared inline inside of - a class declaration, this is where the text for the function is - squirreled away. */ -#define DECL_PENDING_INLINE_INFO(NODE) (DECL_LANG_SPECIFIC(NODE)->pending_inline_info) - -/* Holds information about how virtual base classes should be initialized - by this constructor *if* this constructor is the one to perform - such initialization. */ -#define DECL_VBASE_INIT_LIST(NODE) (DECL_LANG_SPECIFIC(NODE)->vbase_init_list) - -/* Nonzero in INT_CST means that this int is negative by dint of - using a twos-complement negated operand. */ -#define TREE_NEGATED_INT(NODE) (TREE_LANG_FLAG_1 (NODE)) - -/* Nonzero in any kind of _EXPR or _REF node means that it is a call - to a storage allocation routine. If, later, alternate storage - is found to hold the object, this call can be ignored. */ -#define TREE_CALLS_NEW(NODE) (TREE_LANG_FLAG_2 (NODE)) - -/* Nonzero in IDENTIFIER_NODE means that this name is overloaded, and - should be looked up in a non-standard way. */ -#define TREE_OVERLOADED(NODE) (TREE_LANG_FLAG_1 (NODE)) -#define DECL_OVERLOADED(NODE) (DECL_LANG_SPECIFIC (NODE)->decl_flags.overloaded_attr) - -/* Nonzero if this (non-TYPE)_DECL has its virtual attribute set. - For a FUNCTION_DECL, this is when the function is a virtual function. - For a VAR_DECL, this is when the variable is a virtual function table. - For a FIELD_DECL, when the field is the field for the virtual function table. - For an IDENTIFIER_NODE, nonzero if any function with this name - has been declared virtual. */ -#define DECL_VIRTUAL_P(NODE) (TREE_LANG_FLAG_2 (NODE)) - -/* Nonzero for FIELD_DECL means that this field is a - virtual baseclass field. Used for printing debugging info. */ -#define DECL_VBASE_P(NODE) ((NODE)->common.external_attr) - -/* Nonzero for FIELD_DECLs means that this field is private, - and can only be accessed within the scope of the class - which defines it (or its friends). */ -#define TREE_PRIVATE(NODE) (TREE_LANG_FLAG_3 (NODE)) -/* Same, but tells if this field is private in current context. */ -#define TREE_FIELD_PRIVATE(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.this_private) - -/* Nonzero for FIELD_DECLs means that this field is protected, - and can only be accessed within the scope of the class - which defines it, its friends, or if there is a path in - the type hierarchy from the current class scope to - the one that defines it. */ -#define TREE_PROTECTED(NODE) (TREE_LANG_FLAG_4 (NODE)) -/* Same, but tells if this field is private in current context. */ -#define TREE_FIELD_PROTECTED(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.this_protected) - -#define TREE_FIELD_PUBLIC(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.this_public) - -/* Nonzero for _TYPE means that the _TYPE defines - at least one constructor. */ -#define TYPE_HAS_CONSTRUCTOR(NODE) (TREE_LANG_FLAG_1(NODE)) - -/* When appearing in an INDIRECT_REF, it means that the tree structure - underneath is actually a call to a constructor. This is needed - when the constructor must initialize local storage (which can - be automatically destroyed), rather than allowing it to allocate - space from the heap. - - When appearing in a SAVE_EXPR, it means that underneath - is a call to a constructor. - - When appearing in a CONSTRUCTOR, it means that it was - a GNU C constructor expression. - - When appearing in a FIELD_DECL, it means that this field - has been duly initialized in its constructor. */ -#define TREE_HAS_CONSTRUCTOR(NODE) (TREE_LANG_FLAG_1(NODE)) - -/* Nonzero for _TYPE means that the _TYPE defines a destructor. */ -#define TYPE_HAS_DESTRUCTOR(NODE) (TREE_LANG_FLAG_2(NODE)) - -/* Nonzero for _TYPE node means that creating an object of this type - will involve a call to a constructor. This can apply to objects - of ARRAY_TYPE if the type of the elements needs a constructor. */ -#define TYPE_NEEDS_CONSTRUCTING(NODE) (TREE_LANG_FLAG_3(NODE)) -#define TYPE_NEEDS_CONSTRUCTOR(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.needs_constructor) - -/* Nonzero for _TYPE node means that destroying an object of this type - will involve a call to a destructor. This can apply to objects - of ARRAY_TYPE is the type of the elements needs a destructor. */ -#define TYPE_NEEDS_DESTRUCTOR(NODE) (TREE_LANG_FLAG_4(NODE)) - -/* Nonzero for VAR_DECL node means that `external' was specified in - its declaration. */ -#define DECL_EXTERNAL(NODE) (TREE_LANG_FLAG_1(NODE)) - -/* Nonzero for SAVE_EXPR if used to initialize a PARM_DECL. */ -#define PARM_DECL_EXPR(NODE) (TREE_LANG_FLAG_3(NODE)) - -/* Nonzero in FUNCTION_DECL means it is really an operator. - Just used to communicate formatting information to dbxout.c. */ -#define TREE_OPERATOR(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.operator_attr) - -/* Nonzero for _TYPEs means that the argument defines or uses a - virtual function table for some of its methods. */ -#define TYPE_VIRTUAL_P(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.virtual_attr) - -/* May be useful for optimization using strictness analysis. - TYPE_ANY_ASSIGNS_THIS nonzero means that there is one constructor - within the hierarchy of TYPE which is known to assign to `this'. - - TYPE_NONE_ASSIGNS_THIS nonzero means that it is known that - no constructor within the hierarchy of TYPE makes an assignment - to `this'. - - Both of these can be zero, in which case it just means that we don't - have sufficient information yet. They cannot, however, both be nonzero. */ -#define TYPE_ANY_ASSIGNS_THIS(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.any_assigns_this) -#define TYPE_NONE_ASSIGN_THIS(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.none_assign_this) - -/* Define fields and accessors for nodes representing declared names. */ - -/* C++: A derived class may be able to directly use the virtual - function table of a base class. When it does so, it may - still have a decl node used to access the virtual function - table (so that variables of this type can initialize their - virtual function table pointers by name). When such thievery - is commited, know exactly which base class's virtual function - table is the one being stolen. This effectively computes the - transitive closure. */ -#define DECL_VPARENT(NODE) ((NODE)->decl.arguments) - -/* C++: all of these are overloaded! These apply only to TYPE_DECLs. */ -#define DECL_FRIENDLIST(NODE) ((NODE)->decl.voffset) -#define DECL_UNDEFINED_FRIENDS(NODE) ((NODE)->decl.context) -#define DECL_WAITING_FRIENDS(NODE) ((tree)(NODE)->decl.rtl) -#define SET_DECL_WAITING_FRIENDS(NODE,VALUE) ((NODE)->decl.rtl=(struct rtx_def*)VALUE) - -/* C++: all of these are overloaded! These apply only to FIELD_DECLs. */ -#define DECL_STATIC_NAME(NODE) ((tree)(NODE)->decl.offset) -#define SET_DECL_STATIC_NAME(NODE,VAL) ((NODE)->decl.offset = (int)VAL) - -/* The DECL_VISIBILITY is used to record under which context - special visibility rules apply. */ -#define DECL_VISIBILITY(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.visibility) - -/* The DECL_VINDEX is used for FUNCTION_DECLS in two different ways. - Before the struct containing the FUNCTION_DECL is laid out, - DECL_VINDEX may point to a FUNCTION_DECL in a base class which - is the FUNCTION_DECL which this FUNCTION_DECL will replace as a virtual - function. When the class is laid out, this pointer is changed - to an INT_CST node which is suitable for use as an index - into the virtual function table. */ -#define DECL_VINDEX(NODE) (DECL_LANG_SPECIFIC(NODE)->vindex) -#define SET_DECL_VINDEX(NODE,VAL) (DECL_LANG_SPECIFIC(NODE)->vindex = VAL) - -/* DECL_VCONTEXT is the *first* baseclass in which this FUNCTION_DECL - is defined. Contrast this with DECL_CONTEXT (or DECL_FIELD_CONTEXT), - which is the *last* such baseclass. */ -#define DECL_VCONTEXT(NODE) (DECL_LANG_SPECIFIC(NODE)->vcontext) - -/* DECL_FCONTEXT is the *first* baseclass in which this FIELD_DECL - is defined. This only applies to vfield and vbase decls. */ -#define SET_DECL_FCONTEXT(NODE,VALUE) (DECL_LANG_SPECIFIC(NODE) = (struct lang_decl *)(VALUE)) -#define DECL_FCONTEXT(NODE) ((tree)DECL_LANG_SPECIFIC(NODE)) - -/* For static member functions, which can never be virtual, - we need to know to what class the method belongs. This - is where we stash the information. */ -#define DECL_STATIC_CONTEXT(NODE) (DECL_LANG_SPECIFIC(NODE)->vcontext) - -/* C++: all of these are overloaded! - These apply to PARM_DECLs and VAR_DECLs and RESULT_DECLs. */ -#define DECL_REFERENCE_SLOT(NODE) ((tree)(NODE)->decl.arguments) -#define SET_DECL_REFERENCE_SLOT(NODE,VAL) ((NODE)->decl.arguments=VAL) - -#ifdef SOS -#define DECL_DINDEX(NODE) (DECL_LANG_SPECIFIC(NODE)->dynamic_index) -#endif - -/* An enumeration of the kind of tags that C++ accepts. */ -enum tag_types { record_type, class_type, union_type, enum_type, exception_type }; - -/* Zero means prototype weakly, as in ANSI C (no args means nothing). - Each language context defines how this variable should be set. */ -extern int strict_prototype; -extern int strict_prototypes_lang_c, strict_prototypes_lang_cplusplus; - -/* Non-zero means that if a label exists, and no other identifier - applies, use the value of the label. */ -extern int flag_labels_ok; - -/* Non-zero means to collect statistics which might be expensive - and to print them when we are done. */ -extern int flag_detailed_statistics; - -/* Non-zero means warn in function declared in derived class has the - same name as a virtual in the base class, but fails to match the - type signature of any virtual function in the base class. */ -extern int warn_overloaded_virtual; - -/* in cplus-decl{2}.c */ -extern tree void_list_node; -extern tree default_function_type; -extern tree define_function (); -extern tree build_member_type (); - -extern tree vtable_entry_type; -extern tree build_vtable_entry (); -extern tree build_vfn_ref (); -extern tree finish_table (); - -extern tree typedecl_for_tag (); -extern tree identifier_class_value (); - -extern int complete_array_type (); -extern tree coerce_new_type (), coerce_delete_type (); - -/* A node that is a list (length 1) of error_mark_nodes. */ -extern tree error_mark_list; - -extern tree ptr_type_node; -extern tree class_type_node, record_type_node, union_type_node, enum_type_node; -extern tree exception_type_node, unknown_type_node; - -extern tree get_temp_name (), get_temp_aggr (), get_temp_regvar (); -extern tree cleanup_after_call (); -extern tree build_type_conversion (); -extern tree convert_force (); -extern tree maybe_convert_decl_to_const (); -extern char *lang_printable_name (); - -/* The largest size a virtual function table can be. - Must be a (power of 2). */ -#ifndef VINDEX_MAX -#define VINDEX_MAX ((unsigned)128) -/* This is the integer ~ (vindex_max - 1). */ -#endif -extern tree vtbl_mask; - -/* Array type `(void *)[]' */ -extern tree vtbl_type_node; - -extern tree get_parm_types (); -extern tree grokopexpr (), getaggrs (), groktypefield (); -extern tree grok_method_quals (), grok_enum_decls (); -extern void finish_anon_union(); -extern tree long_long_integer_type_node, long_long_unsigned_type_node; -/* For building calls to `delete'. */ -extern tree integer_two_node, integer_three_node; -extern tree get_first_matching_virtual (), get_abstract_virtuals (); - -/* in cplus-typeck.c */ -extern tree build_x_conditional_expr (); -extern tree merge_component_comparisons (); -extern tree build_x_unary_op (), build_x_binary_op (); -extern tree build_component_addr (); -extern tree build_x_function_call (); -extern tree build_x_indirect_ref (), build_x_array_ref (); -extern tree build_x_modify_expr (), build_x_modify_op_expr (); - -extern tree build_m_component_ref (); -extern tree build_component_type_expr (); -extern tree build_x_arrow (); -extern tree build_component_ref_1 (); -extern tree datatype (), unary_complex_lvalue (), target_type (); -extern tree build_return_stmt (); -extern tree actualparameterlist (), commonparms (); -extern tree cplus_size_in_bytes (); -extern tree cplus_sizeof (), cplus_sizeof_nowarn (); -extern tree error_mark_list; - -/* in cplus-type2.c */ -extern tree basetype_or_else (); - -/* in tree.c */ -extern tree build_let (); -extern tree decl_type_context (); - -/* in cplus-tree.c */ -extern tree build1 (); -extern tree build_cplus_new (); -extern tree build_cplus_array_type (); -extern tree build_cplus_method_type (); -extern tree build_classtype_variant (); -extern tree hash_tree_cons (), hash_tree_chain (); -extern tree list_hash_lookup_or_cons (); -extern tree layout_basetypes (); -extern tree copy_to_permanent (); - -/* in cplus-except.c */ -extern tree current_exception_type; -extern tree current_exception_decl; -extern tree current_exception_object; -extern tree build_exception_variant (); -extern tree lookup_exception_type (), lookup_exception_cname (); -extern tree lookup_exception_object (); -extern tree cplus_expand_start_catch (); -extern tree cplus_expand_end_try (); - -/* in cplus-class.c */ -extern tree current_class_name; -extern tree current_class_type; -extern tree prev_class_type; - -extern tree current_lang_name, lang_name_cplusplus, lang_name_c; - -extern tree do_identifier (), hack_identifier (); -extern tree hack_operator (), hack_wrapper (); -extern tree convert_pointer_to (), convert_pointer_to_vbase (); -extern tree convert_to_reference (), convert_to_aggr (), convert_aggr (); -extern tree build_x_new (), build_x_delete (); -extern tree build_new (), build_vec_new (), build_delete (), build_vec_delete (); -extern tree make_destructor_name (); -extern tree build_scoped_ref (), build_vfield_ref (); -extern tree build_method_call (), build_overload_call (); -extern tree build_type_pathname (); -extern tree start_method (), start_type_method (); -extern tree finish_method (); - -extern tree lookup_field (), lookup_fnfields (); - -void pushclass (), popclass (), pushclasstype (); -extern tree build_operator_fnname (), build_opfncall (), build_type_conversion (); -extern tree build_wrapper (); - -/* Points to the name of that function. May not be the DECL_NAME - of CURRENT_FUNCTION_DECL due to overloading */ -extern tree original_function_name; - -# define IS_AGGR_TYPE(t) \ - (TREE_CODE (t) == RECORD_TYPE || TREE_CODE (t) == UNION_TYPE) - -# define IS_AGGR_TYPE_CODE(t) \ - (t == RECORD_TYPE || t == UNION_TYPE) - -extern tree build_decl_overload (), build_typename_overload (); -extern tree build_destructor_call (); -extern tree current_class_name, current_class_type, current_class_decl, C_C_D; -extern tree current_vtable_decl; - -/* in cplus-init.c */ -extern tree resolve_offset_ref (); -extern tree purpose_member (), value_member (); -extern void check_base_init (); -extern void do_member_init (); -extern tree global_base_init_list; -extern tree current_base_init_list, current_member_init_list; -#ifdef SOS -extern tree get_linktable_name (), get_dtable_name (), get_sos_dtable (); -#endif -extern tree get_member_function (); -extern tree build_member_call (), build_offset_ref (); - -extern int current_function_assigns_this; -extern int current_function_just_assigned_this; -extern int current_function_parms_stored; - -/* Cannot use '$' up front, because this confuses gdb. - Note that any format of this kind *must* make the - format for `this' lexicgraphically less than any other - parameter name, i.e. "$this" is less than anything else can be. - - Note that all forms in which the '$' is significant are long enough - for direct indexing. */ - -/* Define NO_DOLLAR_IN_LABEL in your favorite tm file if your assembler - doesn't allow '$' in symbol names. */ -#ifndef NO_DOLLAR_IN_LABEL - -#define JOINER '$' - -#define THIS_NAME "$t" -#define VPTR_NAME "$v" -#define THROW_NAME "$eh_throw" -#define DESTRUCTOR_DECL_FORMAT "_$_%s" -#define WRAPPER_DECL_FORMAT "__W$%s" -#define WRAPPER_PRED_DECL_FORMAT "__P$%s" -#define ANTI_WRAPPER_DECL_FORMAT "__w$%s" -#define IN_CHARGE_NAME "__in$chrg" -#define AUTO_VTABLE_NAME "__vtbl$me__" -#define AUTO_TEMP_NAME "_$tmp_" -#define AUTO_TEMP_FORMAT "_$tmp_%d" -#define OPERATOR_ASSIGN_FORMAT "op$assign_%s" -#define OPERATOR_MODIFY_FORMAT "op$modify" -#define OPERATOR_METHOD_FORMAT "op$method_call" -#define OPERATOR_NEW_FORMAT "op$new" -#define OPERATOR_DELETE_FORMAT "op$delete" -#define OPERATOR_FORMAT "op$%s" -#define VTBL_PTR_TYPE "$vtbl_ptr_type" -#define VTABLE_NAME_FORMAT "_vt$%s" -#define VFIELD_NAME "_vptr$" -#define VFIELD_NAME_FORMAT "_vptr$%s" -#define VBASE_NAME "_vb$" -#define VBASE_NAME_FORMAT "_vb$%s" -#define STATIC_NAME_FORMAT "_%s$%s" -#define OPERATOR_TYPENAME_FORMAT "type$" -#define FILE_FUNCTION_FORMAT "_GLOBAL_$D$%s" -#define ANON_AGGRNAME_FORMAT "$_%d" - -#else /* NO_DOLLAR_IN_LABEL */ - -#define JOINER '.' - -#define THIS_NAME ".t" -#define VPTR_NAME ".v" -#define THROW_NAME ".eh_throw" -#define DESTRUCTOR_DECL_FORMAT "_._%s" -#define WRAPPER_DECL_FORMAT "__W.%s" -#define WRAPPER_PRED_DECL_FORMAT "__P.%s" -#define ANTI_WRAPPER_DECL_FORMAT "__w.%s" -#define IN_CHARGE_NAME "__in.chrg" -#define AUTO_VTABLE_NAME "__vtbl.me__" -#define AUTO_TEMP_NAME "_.tmp_" -#define AUTO_TEMP_FORMAT "_.tmp_%d" -#define OPERATOR_ASSIGN_FORMAT "op.assign_%s" -#define OPERATOR_MODIFY_FORMAT "op.modify" -#define OPERATOR_METHOD_FORMAT "op.method_call" -#define OPERATOR_NEW_FORMAT "op.new" -#define OPERATOR_DELETE_FORMAT "op.delete" -#define OPERATOR_FORMAT "op.%s" -#define VTBL_PTR_TYPE ".vtbl_ptr_type" -#define VTABLE_NAME_FORMAT "_vt.%s" -#define VFIELD_NAME "_vptr." -#define VFIELD_NAME_FORMAT "_vptr.%s" -#define VBASE_NAME "_vb." -#define VBASE_NAME_FORMAT "_vb.%s" -#define STATIC_NAME_FORMAT "_%s.%s" -#define OPERATOR_TYPENAME_FORMAT "type." -#define FILE_FUNCTION_FORMAT "_GLOBAL_.D.%s" - -#define ANON_AGGRNAME_FORMAT "._%d" - -#endif /* NO_DOLLAR_IN_LABEL */ - -#define DESTRUCTOR_NAME_FORMAT "~%s" -#define WRAPPER_NAME_FORMAT "()%s" -#define WRAPPER_PRED_NAME_FORMAT "()?%s" -#define ANTI_WRAPPER_NAME_FORMAT "~()%s" -#define OPERATOR_MODIFY_LENGTH 8 -#define OPERATOR_METHOD_LENGTH 13 -#define OPERATOR_NEW_LENGTH 5 -#define OPERATOR_DELETE_LENGTH 8 -#define EXCEPTION_NAME_LENGTH 12 -#define FILE_FUNCTION_PREFIX_LEN 9 -#define VTABLE_DELTA_NAME "delta" -#define VTABLE_DELTA2_NAME "delta2" -#define VTABLE_INDEX_NAME "index" -#define VTABLE_PFN_NAME "pfn" -#define EXCEPTION_CLEANUP_NAME "exception cleanup" - -#define THIS_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == JOINER \ - && IDENTIFIER_POINTER (ID_NODE)[1] == 't') -#define VPTR_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == JOINER \ - && IDENTIFIER_POINTER (ID_NODE)[1] == 'v') -#define DESTRUCTOR_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[1] == JOINER) - -#define WRAPPER_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[1] == '_' \ - && IDENTIFIER_POINTER (ID_NODE)[2] == 'W' \ - && IDENTIFIER_POINTER (ID_NODE)[3] == JOINER) -#define WRAPPER_PRED_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[1] == '_' \ - && IDENTIFIER_POINTER (ID_NODE)[2] == 'P' \ - && IDENTIFIER_POINTER (ID_NODE)[3] == JOINER) -#define ANTI_WRAPPER_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[1] == '_' \ - && IDENTIFIER_POINTER (ID_NODE)[2] == 'w' \ - && IDENTIFIER_POINTER (ID_NODE)[3] == JOINER) -#define WRAPPER_OR_ANTI_WRAPPER_NAME_P(ID_NODE) \ - (IDENTIFIER_POINTER (ID_NODE)[1] == '_' \ - && (IDENTIFIER_POINTER (ID_NODE)[2]|('W'^'w')) == 'w' \ - && IDENTIFIER_POINTER (ID_NODE)[3] == JOINER) - -#define OPERATOR_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[2] == JOINER \ - && IDENTIFIER_POINTER (ID_NODE)[1]) - -#define VTABLE_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[3] == JOINER \ - && IDENTIFIER_POINTER (ID_NODE)[2] == 't'\ - && IDENTIFIER_POINTER (ID_NODE)[1] == 'v') - -#define VBASE_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[3] == JOINER \ - && IDENTIFIER_POINTER (ID_NODE)[2] == 'b'\ - && IDENTIFIER_POINTER (ID_NODE)[1] == 'v') - -#define OPERATOR_TYPENAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[4] == JOINER \ - && IDENTIFIER_POINTER (ID_NODE)[3] \ - && IDENTIFIER_POINTER (ID_NODE)[2] \ - && IDENTIFIER_POINTER (ID_NODE)[1]) - -#define TEMP_NAME_P(ID_NODE) (!strncmp (IDENTIFIER_POINTER (ID_NODE), AUTO_TEMP_NAME, sizeof (AUTO_TEMP_NAME)-1)) -#define VFIELD_NAME_P(ID_NODE) (!strncmp (IDENTIFIER_POINTER (ID_NODE), VFIELD_NAME, sizeof(VFIELD_NAME)-1)) - -/* For anonymous aggregate types, we need some sort of name to - hold on to. In practice, this should not appear, but it should - not be harmful if it does. */ -#define ANON_AGGRNAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == JOINER) - -#define ANON_PARMNAME_FORMAT "_%d" -#define ANON_PARMNAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == '_' \ - && IDENTIFIER_POINTER (ID_NODE)[1] <= '9') - -enum visibility_type { - visibility_default, - visibility_public, - visibility_private, - visibility_protected, - visibility_default_virtual, - visibility_public_virtual, - visibility_private_virtual, -}; - -enum visibility_type compute_visibility (); - -/* in cplus-lex.c */ -extern tree current_unit_name, current_unit_language; -extern char *operator_name_string (); - -/* Things for handling inline functions. */ - -struct pending_inline -{ - struct pending_inline *next; /* pointer to next in chain */ - int lineno; /* line number we got the text from */ - char *filename; /* name of file we were processing */ - tree fndecl; /* FUNCTION_DECL that brought us here */ - int token; /* token we were scanning */ - int token_value; /* value of token we were scanning (YYSTYPE) */ - - char *buf; /* pointer to character stream */ - int len; /* length of stream */ -}; - -extern tree combine_strings (); -extern int yylex (); - -/* in cplus-method.c */ -extern tree wrapper_name, wrapper_pred_name, anti_wrapper_name; -extern struct pending_inline *pending_inlines; -extern char *print_fndecl_with_types (); - -/* 1 for -fall-virtual: make every member function (except - constructors) lay down in the virtual function table. - Calls can then either go through the virtual function table or not, - depending on whether we know what function will actually be called. - - 2 for -fSOS: make every member function (including constructors) - lay down in the virtual function table. All calls go through the - virtual function table: this takes the place of using a linker. */ - -extern int flag_all_virtual; - -/* Nonzero means that we cannot make optimizing assumptions about `this'. */ - -extern int flag_this_is_variable; - -enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG, WRAPPER_FLAG, WRAPPER_PRED_FLAG, ANTI_WRAPPER_FLAG }; - -extern tree default_conversion (), pushdecl (), pushdecl_top_level (); -extern tree make_instance_name (), do_decl_overload (); -extern tree maybe_build_cleanup (); -extern tree build_instantiated_decl (), instantiate_type (); -extern tree require_instantiated_type (); -extern tree build_vtbl_ref (); -extern tree make_anon_parm_name (); -extern int resolves_to_fixed_type_p (); - -extern tree do_friend (); -extern void grokclassfn (); - -extern tree current_class_decl, C_C_D; /* PARM_DECL: the class instance variable */ - -/* The following two can be derived from the previous one */ -extern tree current_class_name; /* IDENTIFIER_NODE: name of current class */ -extern tree current_class_type; /* _TYPE: the type of the current class */ - -/* The following structure is used when comparing various alternatives - for overloading. The unsigned quantity `strikes.i' is used - for fast comparison of two possibilities. This number is an - aggregate of four constituents: - - EVIL: if this is non-zero, then the candidate should not be considered - USER: if this is non-zero, then a user-defined type conversion is needed - B_OR_D: if this is non-zero, then use a base pointer instead of the - type of the pointer we started with. - EASY: if this is non-zero, then we have a builtin conversion - (such as int to long, int to float, etc) to do. - - If two candidates require user-defined type conversions, and the - type conversions are not identical, then an ambiguity error - is reported. - - If two candidates agree on user-defined type conversions, - and one uses pointers of strictly higher type (derived where - another uses base), then that alternative is silently chosen. - - If two candidates have a non-monotonic derived/base pointer - relationship, and/or a non-monotonic easy conversion relationship, - then a warning is emitted to show which paths are possible, and - which one is being chosen. - - For example: - - int i; - double x; - - overload f; - int f (int, int); - double f (double, double); - - f (i, x); // draws a warning - - struct B - { - f (int); - } *bb; - struct D : B - { - f (double); - } *dd; - - dd->f (x); // exact match - dd->f (i); // draws warning - - Note that this technique really only works for 255 arguments. Perhaps - this is not enough. */ - -struct candidate -{ - tree function; /* A FUNCTION_DECL */ - - unsigned char evil; /* ~0 if this will never convert. */ - unsigned char user; /* ~0 if at least one user-defined type conv. */ - unsigned short b_or_d; /* count number of derived->base conv. */ - unsigned short easy; /* count number of builtin type conv. */ - tree arg; /* an _EXPR node that is first parm to function */ - unsigned short *harshness; /* Indexed by argument number, encodes - evil, user, b_or_d, and easy strikes for - that argument. - At end of array, we store the index+1 where we - started using default parameters, or 0 - if there are none. */ - union - { - tree field; /* If no evil strikes, the FUNCTION_DECL of - the function (if a member function). */ - int bad_arg; /* the index of the first bad argument: - 0 if no bad arguements - > 0 is first bad argument - -1 if extra actual arguments - -2 if too few actual arguments. - -3 if const/non const method mismatch. */ - } u; -}; -int rank_for_overload (); -struct candidate *ideal_candidate (); -/* Some macros for char-based bitfields. */ -#define B_SET(a,x) (a[x>>3] |= (1 << (x&7))) -#define B_CLR(a,x) (a[x>>3] &= ~(1 << (x&7))) -#define B_TST(a,x) (a[x>>3] & (1 << (x&7))) - -/* These are uses as bits in flags passed to build_method_call - to control its error reporting behavior. - - LOOKUP_PROTECT means flag visibility violations. - LOOKUP_COMPLAIN mean complain if no suitable member function - matching the arguments is found. - LOOKUP_NORMAL is just a combination of these two. - LOOKUP_AGGR requires the instance to be of aggregate type. - LOOKUP_NONVIRTUAL means make a direct call to the member function found - LOOKUP_GLOBAL means search through the space of overloaded functions, - rather than the space of member functions. - LOOKUP_HAS_IN_CHARGE means that the "in charge" variable is already - in the parameter list. - LOOKUP_PROTECTED_OK means that even if the constructor we find appears - to be non-visibile to current scope, call it anyway. - LOOKUP_DYNAMIC means call dynamic functions, a la SOS. - LOOKUP_NO_CONVERSION means that user-defined conversions are not - permitted. Built-in conversions are permitted. - LOOKUP_DESTRUCTOR means explicit call to destructor. */ - -#define LOOKUP_PROTECT (1) -#define LOOKUP_COMPLAIN (2) -#define LOOKUP_NORMAL (3) -#define LOOKUP_AGGR (4) -#define LOOKUP_NONVIRTUAL (8) -#define LOOKUP_GLOBAL (16) -#define LOOKUP_HAS_IN_CHARGE (32) -#define LOOKUP_SPECULATIVELY (64) -#define LOOKUP_PROTECTED_OK (128) -#define LOOKUP_DYNAMIC (256) -#define LOOKUP_NO_CONVERSION (512) -#define LOOKUP_DESTRUCTOR (512) - -/* Anatomy of a DECL_FRIENDLIST (which is a TREE_LIST): - purpose = friend name (IDENTIFIER_NODE); - value = TREE_LIST of FUNCTION_DECLS; - chain, type = EMPTY; */ -#define FRIEND_NAME(LIST) (TREE_PURPOSE (LIST)) -#define FRIEND_DECLS(LIST) (TREE_VALUE (LIST)) - -extern tree get_temp_name (), get_temp_aggr (), get_temp_regvar (); -extern tree build_method_call (); -extern tree build_type_conversion (); -extern tree build_functional_cast (); -extern tree build_scoped_method_call (); -extern tree decl_constant_value (); - -/* in cplus-init.c */ -extern tree resolve_offset_ref (); -extern tree build_with_cleanup (); - -/* in cplus-lex.c */ -extern char *operator_name_string (); - -extern tree get_base_type (); -extern tree build_opid (); - -/* Indexed by TREE_CODE, these tables give C-looking names to - operators represented by TREE_CODES. For example, - opname_tab[(int) MINUS_EXPR] == "-". */ -extern char **opname_tab, **assignop_tab; - -extern tree build_lang_decl (), build_lang_field_decl (); -extern tree make_lang_type (); -extern tree cons_up_default_function (); - -/* in cplus-convert.c */ -extern tree convert_from_reference (); - -/* in cplus-search.c */ -extern tree init_vbase_pointers (); -extern tree build_vbase_pointer (), build_vbase_path (); -extern tree lookup_fnfield (), next_baselink (); - -extern tree get_base_type (); -extern tree get_vbase_types (); -extern tree get_baselinks (); -extern tree get_wrapper (); -extern tree make_assoc (), copy_assoc (); -extern tree assoc_value (), virtual_member (); - -#define PRINT_LANG_DECL -#define PRINT_LANG_TYPE - -#define UNKNOWN_TYPE LANG_TYPE - -extern union tree_node ERROR_MARK_NODE; - -#define error_mark_node (&ERROR_MARK_NODE) - -/* -- end of C++ */ diff --git a/gnu/usr.bin/g++/cc1plus/cplus-type2.c b/gnu/usr.bin/g++/cc1plus/cplus-type2.c deleted file mode 100644 index 76df430175e2..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-type2.c +++ /dev/null @@ -1,1529 +0,0 @@ -/* Report error messages, build initializers, and perform - some front-end optimizations for C++ compiler. - Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file is part of the C front end. - It contains routines to build C expressions given their operands, - including computing the types of the result, C-specific error checks, - and some optimization. - - There are also routines to build RETURN_STMT nodes and CASE_STMT nodes, - and to process initializations in declarations (since they work - like a strange sort of assignment). */ - -#include "config.h" -#include -#include "tree.h" -#include "cplus-tree.h" -#include "flags.h" -#include "rtl.h" -#include "assert.h" - -static tree process_init_constructor (); -tree digest_init (); -void incomplete_type_error (); -void readonly_warning_or_error (); -extern tree convert_for_initialization (); - -/* Print an error message stemming from an attempt to use - BASETYPE as a base class for TYPE. */ -void -error_not_base_type (basetype, type) - tree basetype, type; -{ - tree name1 = TYPE_NAME (basetype); - tree name2 = TYPE_NAME (type); - if (TREE_CODE (name1) == TYPE_DECL) - name1 = DECL_NAME (name1); - if (TREE_CODE (name2) == TYPE_DECL) - name2 = DECL_NAME (name2); - error ("type `%s' is not a base type for type `%s'", - IDENTIFIER_POINTER (name1), IDENTIFIER_POINTER (name2)); -} - -tree -basetype_or_else (parent_or_type, type) - tree parent_or_type, type; -{ - tree basetype; - if (TYPE_MAIN_VARIANT (parent_or_type) == TYPE_MAIN_VARIANT (type)) - return parent_or_type; - if (basetype = get_base_type (parent_or_type, TYPE_MAIN_VARIANT (type), 0)) - { - if (basetype == error_mark_node) - return NULL_TREE; - return basetype; - } - error_not_base_type (parent_or_type, type); - return NULL_TREE; -} - -/* Print an error message stemming from an invalid use of an - aggregate type. - - TYPE is the type which draws the error. - MSG is the message to print. - ARG is an optional argument which may provide more information. */ -void -error_with_aggr_type (type, msg, arg) - tree type; - char *msg; - int arg; -{ - tree name = TYPE_NAME (type); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - error (msg, IDENTIFIER_POINTER (name), arg); -} - -/* Warn or give error about storing in something that is `const'. */ - -void -readonly_warning_or_error (arg, string) - tree arg; - char *string; -{ - char buf[80]; - strcpy (buf, string); - - if (TREE_CODE (arg) == COMPONENT_REF) - { - if (TREE_READONLY (TREE_OPERAND (arg, 0))) - strcat (buf, " of member `%s' in read-only structure"); - else - strcat (buf, " of read-only member `%s'"); - error (buf, lang_printable_name (TREE_OPERAND (arg, 1))); - } - else if (TREE_CODE (arg) == VAR_DECL) - { - if (DECL_LANG_SPECIFIC (arg) - && DECL_IN_AGGR_P (arg) - && !TREE_STATIC (arg)) - strcat (buf, " of constant field `%s'"); - else - strcat (buf, " of read-only variable `%s'"); - error (buf, lang_printable_name (arg)); - } - else if (TREE_CODE (arg) == PARM_DECL) - { - strcat (buf, " of read-only parameter `%s'"); - error (buf, lang_printable_name (arg)); - } - else if (TREE_CODE (arg) == INDIRECT_REF - && TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))) == REFERENCE_TYPE - && (TREE_CODE (TREE_OPERAND (arg, 0)) == VAR_DECL - || TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL)) - { - strcat (buf, " of read-only reference `%s'"); - error (buf, lang_printable_name (TREE_OPERAND (arg, 0))); - } - else - { - warning ("%s of read-only location", buf); - } -} - -/* Print an error message for invalid use of a type which declares - virtual functions which are not inheritable. */ -void -abstract_virtuals_error (decl, type) - tree decl; - tree type; -{ - char *typename = TYPE_NAME_STRING (type); - tree u = CLASSTYPE_ABSTRACT_VIRTUALS (type); - - if (decl) - { - if (TREE_CODE (decl) == RESULT_DECL) - return; - - if (TREE_CODE (decl) == VAR_DECL) - error_with_decl (decl, "cannot declare variable `%s' to be of type `%s'", typename); - else if (TREE_CODE (decl) == PARM_DECL) - error_with_decl (decl, "cannot declare parameter `%s' to be of type `%s'", typename); - else if (TREE_CODE (decl) == FIELD_DECL) - error_with_decl (decl, "cannot declare field `%s' to be of type `%s'", typename); - else if (TREE_CODE (decl) == FUNCTION_DECL) - error_with_decl (decl, "invalid return type for function `%s'"); - } - else error ("cannot allocate an object of type `%s'", typename); - /* Only go through this once. */ - if (TREE_PURPOSE (u) == NULL_TREE) - { - error ("since the following virtual functions are abstract:"); - TREE_PURPOSE (u) = error_mark_node; - while (u) - { - error_with_decl (TREE_VALUE (u), "%s"); - u = TREE_CHAIN (u); - } - } - else error ("since type `%s' has abstract virtual functions", typename); -} - -/* Print an error message for invalid use of an incomplete type. - VALUE is the expression that was used (or 0 if that isn't known) - and TYPE is the type that was invalid. */ - -void -incomplete_type_error (value, type) - tree value; - tree type; -{ - char *errmsg; - - /* Avoid duplicate error message. */ - if (TREE_CODE (type) == ERROR_MARK) - return; - - if (value != 0 && (TREE_CODE (value) == VAR_DECL - || TREE_CODE (value) == PARM_DECL)) - error ("`%s' has an incomplete type", - IDENTIFIER_POINTER (DECL_NAME (value))); - else - { - retry: - /* We must print an error message. Be clever about what it says. */ - - switch (TREE_CODE (type)) - { - case RECORD_TYPE: - errmsg = "invalid use of undefined type `struct %s'"; - break; - - case UNION_TYPE: - errmsg = "invalid use of undefined type `union %s'"; - break; - - case ENUMERAL_TYPE: - errmsg = "invalid use of undefined type `enum %s'"; - break; - - case VOID_TYPE: - error ("invalid use of void expression"); - return; - - case ARRAY_TYPE: - if (TYPE_DOMAIN (type)) - { - type = TREE_TYPE (type); - goto retry; - } - error ("invalid use of array with unspecified bounds"); - return; - - case OFFSET_TYPE: - error ("invalid use of member type (did you forget the `&' ?)"); - return; - - default: - abort (); - } - - error_with_aggr_type (type, errmsg); - } -} - -/* Return nonzero if VALUE is a valid constant-valued expression - for use in initializing a static variable; one that can be an - element of a "constant" initializer. - - Return 1 if the value is absolute; return 2 if it is relocatable. - We assume that VALUE has been folded as much as possible; - therefore, we do not need to check for such things as - arithmetic-combinations of integers. */ - -static int -initializer_constant_valid_p (value) - tree value; -{ - switch (TREE_CODE (value)) - { - case CONSTRUCTOR: - return TREE_STATIC (value); - - case INTEGER_CST: - case REAL_CST: - case STRING_CST: - return 1; - - case ADDR_EXPR: - return 2; - - case CONVERT_EXPR: - case NOP_EXPR: - /* Allow conversions between types of the same kind. */ - if (TREE_CODE (TREE_TYPE (value)) - == TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0)))) - return initializer_constant_valid_p (TREE_OPERAND (value, 0)); - /* Allow (int) &foo. */ - if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE - && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE) - return initializer_constant_valid_p (TREE_OPERAND (value, 0)); - return 0; - - case PLUS_EXPR: - { - int valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0)); - int valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1)); - if (valid0 == 1 && valid1 == 2) - return 2; - if (valid0 == 2 && valid1 == 1) - return 2; - return 0; - } - - case MINUS_EXPR: - { - int valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0)); - int valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1)); - if (valid0 == 2 && valid1 == 1) - return 2; - return 0; - } - } - - return 0; -} - -/* Perform appropriate conversions on the initial value of a variable, - store it in the declaration DECL, - and print any error messages that are appropriate. - If the init is invalid, store an ERROR_MARK. - - C++: Note that INIT might be a TREE_LIST, which would mean that it is - a base class initializer for some aggregate type, hopefully compatible - with DECL. If INIT is a single element, and DECL is an aggregate - type, we silently convert INIT into a TREE_LIST, allowing a constructor - to be called. - - If INIT is a TREE_LIST and there is no constructor, turn INIT - into a CONSTRUCTOR and use standard initialization techniques. - Perhaps a warning should be generated? - - Returns value of initializer if initialization could not be - performed for static variable. In that case, caller must do - the storing. */ - -tree -store_init_value (decl, init) - tree decl, init; -{ - register tree value, type; - - /* If variable's type was invalidly declared, just ignore it. */ - - type = TREE_TYPE (decl); - if (TREE_CODE (type) == ERROR_MARK) - return NULL_TREE; - - /* Take care of C++ business up here. */ - type = TYPE_MAIN_VARIANT (type); - - /* implicitly tests if IS_AGGR_TYPE. */ - if (TYPE_NEEDS_CONSTRUCTING (type)) - abort (); - else if (IS_AGGR_TYPE (type)) - { - /* @@ This may be wrong, but I do not know what is right. */ - if (TREE_CODE (init) == TREE_LIST) - { - error_with_aggr_type (type, "constructor syntax used, but no constructor declared for type `%s'"); - init = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (init)); - } - } - else if (TREE_CODE (init) == TREE_LIST - && TREE_TYPE (init) != unknown_type_node) - { - if (TREE_CODE (decl) == RESULT_DECL) - { - if (TREE_CHAIN (init)) - { - warning ("comma expression used to initialize return value"); - init = build_compound_expr (init); - } - else - init = TREE_VALUE (init); - } - else if (TREE_TYPE (init) != 0 - && TREE_CODE (TREE_TYPE (init)) == OFFSET_TYPE) - { - /* Use the type of our variable to instantiate - the type of our initializer. */ - init = instantiate_type (type, init, 1); - } - else abort (); - } - - /* End of special C++ code. */ - - /* Digest the specified initializer into an expression. */ - - value = digest_init (type, init, 0); - - /* Store the expression if valid; else report error. */ - - if (TREE_CODE (value) == ERROR_MARK) - ; - else if (TREE_STATIC (decl) - && (! TREE_LITERAL (value) - || ! initializer_constant_valid_p (value))) - return value; - else - { - if (pedantic && TREE_CODE (value) == CONSTRUCTOR) - { - if (! TREE_LITERAL (value)) - warning ("aggregate initializer is not constant"); - else if (! TREE_STATIC (value)) - warning ("aggregate initializer uses complicated arithmetic"); - } - } - DECL_INITIAL (decl) = value; - return NULL_TREE; -} - -/* Digest the parser output INIT as an initializer for type TYPE. - Return a C expression of type TYPE to represent the initial value. - - If TAIL is nonzero, it points to a variable holding a list of elements - of which INIT is the first. We update the list stored there by - removing from the head all the elements that we use. - Normally this is only one; we use more than one element only if - TYPE is an aggregate and INIT is not a constructor. */ - -tree -digest_init (type, init, tail) - tree type, init, *tail; -{ - enum tree_code code = TREE_CODE (type); - tree element = 0; - tree old_tail_contents; - /* Nonzero if INIT is a braced grouping, which comes in as a CONSTRUCTOR - tree node which has no TREE_TYPE. */ - int raw_constructor - = TREE_CODE (init) == CONSTRUCTOR && TREE_TYPE (init) == 0; - - /* By default, assume we use one element from a list. - We correct this later in the sole case where it is not true. */ - - if (tail) - { - old_tail_contents = *tail; - *tail = TREE_CHAIN (*tail); - } - - if (init == error_mark_node) - return error_mark_node; - - if (init && raw_constructor - && CONSTRUCTOR_ELTS (init) != 0 - && TREE_CHAIN (CONSTRUCTOR_ELTS (init)) == 0) - { - element = TREE_VALUE (CONSTRUCTOR_ELTS (init)); - if (element == error_mark_node) - return error_mark_node; - } - - /* Any type can be initialized from an expression of the same type, - optionally with braces. */ - - if (init && TREE_TYPE (init) - && (TYPE_MAIN_VARIANT (TREE_TYPE (init)) == type - || (code == ARRAY_TYPE && comptypes (TREE_TYPE (init), type, 1)))) - { - if (pedantic && code == ARRAY_TYPE - && TREE_CODE (init) != STRING_CST) - warning ("ANSI C forbids initializing array from array expression"); - if (TREE_CODE (init) == CONST_DECL) - init = DECL_INITIAL (init); - else if (TREE_READONLY_DECL_P (init)) - init = decl_constant_value (init); - return init; - } - - if (element && (TREE_TYPE (element) == type - || (code == ARRAY_TYPE && TREE_TYPE (element) - && comptypes (TREE_TYPE (element), type, 1)))) - { - if (pedantic && code == ARRAY_TYPE) - warning ("ANSI C forbids initializing array from array expression"); - if (pedantic && (code == RECORD_TYPE || code == UNION_TYPE)) - warning ("single-expression nonscalar initializer has braces"); - if (TREE_CODE (element) == CONST_DECL) - element = DECL_INITIAL (element); - else if (TREE_READONLY_DECL_P (element)) - element = decl_constant_value (element); - return element; - } - - /* Check for initializing a union by its first field. - Such an initializer must use braces. */ - - if (code == UNION_TYPE) - { - tree result; - - if (TYPE_FIELDS (type) == 0) - { - error ("union with no members cannot be initialized"); - return error_mark_node; - } - if (! raw_constructor) - { - error ("type mismatch in initialization"); - return error_mark_node; - } - if (element == 0) - { - if (!TYPE_NEEDS_CONSTRUCTING (type)) - { - error ("union initializer requires one element"); - return error_mark_node; - } - } - else - { - /* Take just the first element from within the constructor - and it should match the type of the first element. */ - element = digest_init (TREE_TYPE (TYPE_FIELDS (type)), element, 0); - result = build (CONSTRUCTOR, type, 0, build_tree_list (0, element)); - TREE_LITERAL (result) = TREE_LITERAL (element); - TREE_STATIC (result) = (initializer_constant_valid_p (element) - && TREE_LITERAL (element)); - return result; - } - } - - /* Initialization of an array of chars from a string constant - optionally enclosed in braces. */ - - if (code == ARRAY_TYPE) - { - tree typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type)); - if ((typ1 == char_type_node - || typ1 == signed_char_type_node - || typ1 == unsigned_char_type_node - || typ1 == unsigned_type_node - || typ1 == integer_type_node) - && ((init && TREE_CODE (init) == STRING_CST) - || (element && TREE_CODE (element) == STRING_CST))) - { - tree string = element ? element : init; - - if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string))) - != char_type_node) - && TYPE_PRECISION (typ1) == BITS_PER_UNIT) - { - error ("char-array initialized from wide string"); - return error_mark_node; - } - if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string))) - == char_type_node) - && TYPE_PRECISION (typ1) != BITS_PER_UNIT) - { - error ("int-array initialized from non-wide string"); - return error_mark_node; - } - - if (pedantic && typ1 != char_type_node) - warning ("ANSI C forbids string initializer except for `char' elements"); - TREE_TYPE (string) = type; - if (TYPE_DOMAIN (type) != 0 - && TREE_LITERAL (TYPE_SIZE (type))) - { - register int size - = TREE_INT_CST_LOW (TYPE_SIZE (type)) * TYPE_SIZE_UNIT (type); - size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT; - /* Subtract 1 because it's ok to ignore the terminating null char - that is counted in the length of the constant. */ - if (size < TREE_STRING_LENGTH (string) - 1) - warning ("initializer-string for array of chars is too long"); - } - return string; - } - } - - /* Handle scalar types, including conversions. */ - - if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE - || code == ENUMERAL_TYPE || code == REFERENCE_TYPE) - { - if (raw_constructor) - { - if (element == 0) - { - error ("initializer for scalar variable requires one element"); - return error_mark_node; - } - init = element; - } - - return convert_for_initialization (0, type, init, "initialization", LOOKUP_NORMAL); - } - - /* Come here only for records and arrays (and unions with constructors). */ - - if (TYPE_SIZE (type) && ! TREE_LITERAL (TYPE_SIZE (type))) - { - error ("variable-sized object may not be initialized"); - return error_mark_node; - } - - if (code == ARRAY_TYPE || code == RECORD_TYPE || code == UNION_TYPE) - { - if (raw_constructor) - return process_init_constructor (type, init, 0); - else if (TYPE_NEEDS_CONSTRUCTING (type)) - { - /* This can only be reached when caller is initializing - ARRAY_TYPE. In that case, we don't want to convert - INIT to TYPE. We will let `expand_vec_init' do it. */ - return init; - } - else if (tail != 0) - { - *tail = old_tail_contents; - return process_init_constructor (type, 0, tail); - } - else if (flag_traditional) - /* Traditionally one can say `char x[100] = 0;'. */ - return process_init_constructor (type, - build_nt (CONSTRUCTOR, 0, - tree_cons (0, init, 0)), - 0); - if (code != ARRAY_TYPE) - return convert_for_initialization (0, type, init, "initialization", LOOKUP_NORMAL); - } - - error ("invalid initializer"); - return error_mark_node; -} - -/* Process a constructor for a variable of type TYPE. - The constructor elements may be specified either with INIT or with ELTS, - only one of which should be non-null. - - If INIT is specified, it is a CONSTRUCTOR node which is specifically - and solely for initializing this datum. - - If ELTS is specified, it is the address of a variable containing - a list of expressions. We take as many elements as we need - from the head of the list and update the list. - - In the resulting constructor, TREE_LITERAL is set if all elts are - constant, and TREE_STATIC is set if, in addition, all elts are simple enough - constants that the assembler and linker can compute them. */ - -static tree -process_init_constructor (type, init, elts) - tree type, init, *elts; -{ - extern tree empty_init_node; - register tree tail; - /* List of the elements of the result constructor, - in reverse order. */ - register tree members = NULL; - tree result; - int allconstant = 1; - int allsimple = 1; - int erred = 0; - - /* Make TAIL be the list of elements to use for the initialization, - no matter how the data was given to us. */ - - if (elts) - tail = *elts; - else - tail = CONSTRUCTOR_ELTS (init); - - /* Gobble as many elements as needed, and make a constructor or initial value - for each element of this aggregate. Chain them together in result. - If there are too few, use 0 for each scalar ultimate component. */ - - if (TREE_CODE (type) == ARRAY_TYPE) - { - tree domain = TYPE_DOMAIN (type); - register long len; - register int i; - - if (domain) - len = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain)) - - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain)) - + 1; - else - len = -1; /* Take as many as there are */ - - for (i = 0; (len < 0 || i < len) && tail != 0; i++) - { - register tree next1; - - if (TREE_VALUE (tail) != 0) - { - tree tail1 = tail; - next1 = digest_init (TYPE_MAIN_VARIANT (TREE_TYPE (type)), - TREE_VALUE (tail), &tail1); - assert (tail1 == 0 || TREE_CODE (tail1) == TREE_LIST); - tail = tail1; - } - else - { - next1 = error_mark_node; - tail = TREE_CHAIN (tail); - } - - if (next1 == error_mark_node) - erred = 1; - else if (!TREE_LITERAL (next1)) - allconstant = 0; - else if (! initializer_constant_valid_p (next1)) - allsimple = 0; - members = tree_cons (NULL_TREE, next1, members); - } - } - if (TREE_CODE (type) == RECORD_TYPE && init != empty_init_node) - { - register tree field; - - if (tail) - { - if (TYPE_USES_VIRTUAL_BASECLASSES (type)) - { - sorry ("initializer list for object of class with virtual baseclasses"); - return error_mark_node; - } - - if (CLASSTYPE_N_BASECLASSES (type) > 0) - { - sorry ("initializer list for object of class with baseclasses"); - return error_mark_node; - } - - if (TYPE_VIRTUAL_P (type)) - { - sorry ("initializer list for object using virtual functions"); - return error_mark_node; - } - } - - for (field = TYPE_FIELDS (type); field && tail; - field = TREE_CHAIN (field)) - { - register tree next1; - - if (! DECL_NAME (field)) - { - members = tree_cons (field, integer_zero_node, members); - continue; - } - - if (TREE_CODE (field) == CONST_DECL || TREE_CODE (field) == TYPE_DECL) - continue; - if (TREE_CODE (field) == VAR_DECL && !TREE_STATIC (field)) - continue; - - if (TREE_VALUE (tail) != 0) - { - tree tail1 = tail; - next1 = digest_init (TREE_TYPE (field), - TREE_VALUE (tail), &tail1); - assert (tail1 == 0 || TREE_CODE (tail1) == TREE_LIST); - if (TREE_CODE (field) == VAR_DECL - && ! global_bindings_p ()) - warning_with_decl (field, "initialization of static member `%s'"); - tail = tail1; - } - else - { - next1 = error_mark_node; - tail = TREE_CHAIN (tail); - } - - if (next1 == error_mark_node) - erred = 1; - else if (!TREE_LITERAL (next1)) - allconstant = 0; - else if (! initializer_constant_valid_p (next1)) - allsimple = 0; - members = tree_cons (field, next1, members); - } - for (; field; field = TREE_CHAIN (field)) - { - if (TREE_CODE (field) != FIELD_DECL) - continue; - - /* Does this field have a default initializtion? */ - if (DECL_INITIAL (field)) - { - register tree next1 = DECL_INITIAL (field); - if (TREE_CODE (next1) == ERROR_MARK) - erred = 1; - else if (!TREE_LITERAL (next1)) - allconstant = 0; - else if (! initializer_constant_valid_p (next1)) - allsimple = 0; - members = tree_cons (field, next1, members); - } - else if (TREE_READONLY (field)) - error ("uninitialized const member `%s'", - IDENTIFIER_POINTER (DECL_NAME (field))); - else if (TYPE_LANG_SPECIFIC (TREE_TYPE (field)) - && CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field))) - error ("member `%s' with uninitialized const fields", - IDENTIFIER_POINTER (DECL_NAME (field))); - else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE) - error ("member `%s' is uninitialized reference", - IDENTIFIER_POINTER (DECL_NAME (field))); - } - } - - /* If arguments were specified as a list, just remove the ones we used. */ - if (elts) - *elts = tail; - /* If arguments were specified as a constructor, - complain unless we used all the elements of the constructor. */ - else if (tail) - warning ("excess elements in aggregate initializer"); - - if (erred) - return error_mark_node; - - result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (members)); - if (init) - TREE_HAS_CONSTRUCTOR (result) = TREE_HAS_CONSTRUCTOR (init); - if (allconstant) TREE_LITERAL (result) = 1; - if (allconstant && allsimple) TREE_STATIC (result) = 1; - return result; -} - -/* Given a structure or union value DATUM, construct and return - the structure or union component which results from narrowing - that value by the types specified in TYPES. For example, given the - hierarchy - - class L { int ii; }; - class A : L { ... }; - class B : L { ... }; - class C : A, B { ... }; - - and the declaration - - C x; - - then the expression - - x::C::A::L::ii refers to the ii member of the L part of - of A part of the C object named by X. In this case, - DATUM would be x, and TYPES would be a SCOPE_REF consisting of - - SCOPE_REF - SCOPE_REF - C A - L - - The last entry in the SCOPE_REF is always an IDENTIFIER_NODE. - -*/ - -tree -build_scoped_ref (datum, types) - tree datum; - tree types; -{ - tree orig_ref, ref; - tree type = TREE_TYPE (datum); - - if (datum == error_mark_node) - return error_mark_node; - type = TYPE_MAIN_VARIANT (type); - - if (TREE_CODE (types) == SCOPE_REF) - { - /* We have some work to do. */ - struct type_chain { tree type; struct type_chain *next; } *chain = 0, *head = 0; - orig_ref = ref = build_unary_op (ADDR_EXPR, datum, 0); - while (TREE_CODE (types) == SCOPE_REF) - { - tree t = TREE_OPERAND (types, 1); - if (is_aggr_typedef (t, 1)) - { - head = (struct type_chain *)alloca (sizeof (struct type_chain)); - head->type = TREE_TYPE (TREE_TYPE (t)); - head->next = chain; - chain = head; - types = TREE_OPERAND (types, 0); - } - else return error_mark_node; - } - if (! is_aggr_typedef (types, 1)) - return error_mark_node; - - head = (struct type_chain *)alloca (sizeof (struct type_chain)); - head->type = TREE_TYPE (TREE_TYPE (types)); - head->next = chain; - chain = head; - while (chain) - { - tree basetype = chain->type; - type = TREE_TYPE (TREE_TYPE (ref)); - if (basetype != type) - { - basetype = get_base_type (basetype, type, 1); - if (basetype == error_mark_node) - return error_mark_node; - if (basetype == 0) - { - error_not_base_type (TYPE_NAME_STRING (chain->type), TYPE_NAME_STRING (type)); - return error_mark_node; - } - ref = convert_pointer_to (basetype, ref); - } - chain = chain->next; - } - return build_indirect_ref (ref, "(compiler error in build_scoped_ref)"); - } - - /* This is an easy conversion. */ - if (is_aggr_typedef (types, 1)) - { - tree basetype = TREE_TYPE (TREE_TYPE (types)); - if (basetype != type) - { - basetype = get_base_type (basetype, type, 1); - if (basetype == error_mark_node) - return error_mark_node; - if (basetype == 0) - { - error_not_base_type (TREE_TYPE (TREE_TYPE (types)), type); - return error_mark_node; - } - } - - switch (TREE_CODE (datum)) - { - case NOP_EXPR: - case CONVERT_EXPR: - case FLOAT_EXPR: - case FIX_TRUNC_EXPR: - case FIX_FLOOR_EXPR: - case FIX_ROUND_EXPR: - case FIX_CEIL_EXPR: - ref = convert_pointer_to (basetype, - build_unary_op (ADDR_EXPR, TREE_OPERAND (datum, 0), 0)); - break; - default: - ref = convert_pointer_to (basetype, - build_unary_op (ADDR_EXPR, datum, 0)); - } - return build_indirect_ref (ref, "(compiler error in build_scoped_ref)"); - } - return error_mark_node; -} - -/* Build a reference to an object specified by the C++ `->' operator. - Usually this just involves dereferencing the object, but if the - `->' operator is overloaded, then such overloads must be - performed until an object which does not have the `->' operator - overloaded is found. An error is reported when circular pointer - delegation is detected. */ -tree -build_x_arrow (datum) - tree datum; -{ - tree types_memoized = NULL_TREE; - tree rval = datum; - tree last_rval = default_conversion (datum); - - if (last_rval == error_mark_node) - return error_mark_node; - - while (rval = build_opfncall (COMPONENT_REF, LOOKUP_NORMAL, rval)) - { - if (rval == error_mark_node) - return error_mark_node; - - if (value_member (TREE_TYPE (rval), types_memoized)) - { - error ("circular pointer delegation detected"); - return error_mark_node; - } - else - { - types_memoized = tree_cons (NULL_TREE, TREE_TYPE (rval), - types_memoized); - } - last_rval = rval; - } - - more: - if (TREE_CODE (TREE_TYPE (last_rval)) == REFERENCE_TYPE) - last_rval = convert_from_reference (last_rval); - - if (TREE_CODE (TREE_TYPE (last_rval)) == POINTER_TYPE) - return build_indirect_ref (last_rval, 0); - - if (TREE_CODE (TREE_TYPE (last_rval)) == OFFSET_TYPE) - { - if (TREE_CODE (last_rval) == OFFSET_REF - && TREE_STATIC (TREE_OPERAND (last_rval, 1))) - { - last_rval = TREE_OPERAND (last_rval, 1); - goto more; - } - compiler_error ("invalid member type in build_x_arrow"); - return error_mark_node; - } - - if (types_memoized) - error ("result of `operator->()' yields non-pointer result"); - else - error ("base operand of `->' is not a pointer"); - return error_mark_node; -} - -/* Make an expression to refer to the COMPONENT field of - structure or union value DATUM. COMPONENT is an arbitrary - expression. DATUM has already been checked out to be of - aggregate type. - - For C++, COMPONENT may be a TREE_LIST. This happens when we must - return an object of member type to a method of the current class, - but there is not yet enough typing information to know which one. - As a special case, if there is only one method by that name, - it is returned. Otherwise we return an expression which other - routines will have to know how to deal with later. */ -tree -build_m_component_ref (datum, component) - tree datum, component; -{ - tree type = TREE_TYPE (component); - tree objtype = TREE_TYPE (datum); - - if (datum == error_mark_node || component == error_mark_node) - return error_mark_node; - - if (TREE_CODE (type) != OFFSET_TYPE && TREE_CODE (type) != METHOD_TYPE) - { - error ("non-member type composed with object"); - return error_mark_node; - } - - if (TREE_CODE (objtype) == REFERENCE_TYPE) - objtype = TREE_TYPE (objtype); - - if (! comptypes (TYPE_METHOD_BASETYPE (type), objtype, 0)) - { - error ("member type `%s::' incompatible with object type `%s'", - TYPE_NAME_STRING (TYPE_METHOD_BASETYPE (type)), - TYPE_NAME_STRING (objtype)); - return error_mark_node; - } - - return build (OFFSET_REF, TREE_TYPE (TREE_TYPE (component)), datum, component); -} - -/* Return a tree node for the expression TYPENAME '(' PARMS ')'. */ -tree -build_functional_cast (exp, parms) - tree exp; - tree parms; -{ - /* This is either a call to a constructor, - or a C cast in C++'s `functional' notation. */ - tree type, name = NULL_TREE; - - if (parms == error_mark_node) - return error_mark_node; - - if (TREE_CODE (exp) == IDENTIFIER_NODE) - { - name = exp; - if (! TREE_TYPE (exp)) - { - type = lookup_name (exp); - if (!type || TREE_CODE (type) != TYPE_DECL) - { - error ("`%s' fails to be a typedef or built-in type", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - type = TREE_TYPE (type); - } - else - /* Either an enum or an aggregate type. */ - type = TREE_TYPE (TREE_TYPE (exp)); - } - else type = exp; - - if (! IS_AGGR_TYPE (type)) - { - /* this must build a C cast */ - if (parms == NULL_TREE) - { - error ("cannot cast null list to type `%s'", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - return build_c_cast (type, build_compound_expr (parms)); - } - - /* Call to a consructor. If this expression - is actually used, for example, - - return X (arg1, arg2, ...); - - then the slot being initialized will be filled in. */ - - if (name == NULL_TREE) - { - name = TYPE_NAME (type); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - } - - if (TYPE_SIZE (type) == NULL_TREE) - { - error ("type `%s' is not yet defined", IDENTIFIER_POINTER (name)); - return error_mark_node; - } - - if (! TYPE_NEEDS_CONSTRUCTOR (type)) - { - if (TREE_CHAIN (parms) == NULL_TREE) - { - tree rval = build_type_conversion (CONVERT_EXPR, type, - TREE_VALUE (parms), 1); - if (rval) - return rval; - } - error ("type `%s' does not have a constructor", - IDENTIFIER_POINTER (name)); - return error_mark_node; - } - - if (! TYPE_HAS_CONSTRUCTOR (type)) - { - /* Look through this type until we find the - base type which has a constructor. */ - do - { - int i, index = 0; - - while (CLASSTYPE_N_BASECLASSES (type) == 1 - && ! TYPE_HAS_CONSTRUCTOR (type)) - type = CLASSTYPE_BASECLASS (type, 1); - if (TYPE_HAS_CONSTRUCTOR (type)) - break; - /* Hack for MI. */ - i = CLASSTYPE_N_BASECLASSES (type); - while (i > 0) - { - if (TYPE_HAS_CONSTRUCTOR (CLASSTYPE_BASECLASS (type, i))) - { - if (index == 0) - index = i; - else - { - error ("multiple base classes with constructor, ambiguous"); - type = 0; - break; - } - } - i -= 1; - } - if (type == 0) - break; - } while (! TYPE_HAS_CONSTRUCTOR (type)); - if (type == 0) - return error_mark_node; - } - name = TYPE_NAME (type); - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - assert (TREE_CODE (name) == IDENTIFIER_NODE); - - { - int flags = (parms && TREE_CHAIN (parms) == NULL_TREE - ? LOOKUP_PROTECT|LOOKUP_NO_CONVERSION : LOOKUP_COMPLAIN); - tree rval; - - try_again: - rval = build_method_call (NULL_TREE, name, parms, NULL_TREE, flags); - - if (rval != error_mark_node) - { - rval = build_cplus_new (type, rval); - return rval; - } - - /* If it didn't work going through constructor, try type conversion. */ - if (! (flags & LOOKUP_COMPLAIN)) - { - rval = build_type_conversion (CONVERT_EXPR, type, TREE_VALUE (parms), - !! (flags & LOOKUP_NO_CONVERSION)); - if (rval) - return rval; - if (flags & LOOKUP_NO_CONVERSION) - { - flags = LOOKUP_NORMAL; - goto try_again; - } - } - - return error_mark_node; - } -} - -/* Perform optimizations for front end. - - @@ These should be moved to fold-const.c when they are working. */ - -static tree -make_merged_ref (ref, bitsize, bitpos, mode, volstruct) - tree ref; - int bitsize, bitpos; - enum machine_mode mode; - int volstruct; -{ - tree rval = make_node (RTL_EXPR); - rtx op, extract_bit_field (), change_address (); - - /* This type is probably not right, but what effect will it have? */ - TREE_TYPE (rval) = integer_type_node; - do_pending_stack_adjust (); - start_sequence (); - /* Get base reference for these fields. */ - op = expand_expr (ref, const0_rtx, VOIDmode, 0); - if (GET_CODE (op) == REG || GET_CODE (op) == SUBREG - || GET_MODE_SIZE (mode) * BITS_PER_UNIT != bitsize) - { - op = extract_bit_field (op, bitsize << 1, bitpos, 1, 0, mode, VOIDmode, - TYPE_ALIGN (TREE_TYPE (ref)) / BITS_PER_UNIT); - } - else - { - op = change_address (op, mode, - plus_constant (XEXP (op, 0), - bitpos / BITS_PER_UNIT)); - MEM_IN_STRUCT_P (op) = 1; - MEM_VOLATILE_P (op) |= volstruct; - } - do_pending_stack_adjust (); - - TREE_VOLATILE (rval) = 1; - RTL_EXPR_SEQUENCE (rval) = get_insns (); - end_sequence (); - RTL_EXPR_RTL (rval) = op; - return rval; -} - -/* Optimize COMPONENT_REFs in expressions that look like - (x.p == y.p && x.q == y.q) or (x.p != y.p || x.q != y.q). - - Also optimize (x.p == c1 && x.q == c2). - - Return NULL_TREE if we could not perform the optimization, - Otherwise, return the optimized result. */ -tree -merge_component_comparisons (code, op0, op1) - enum tree_code code; - tree op0; - tree op1; -{ - tree l0, r0, l1, r1; - - l0 = TREE_OPERAND (op0, 0); - r0 = TREE_OPERAND (op0, 1); - l1 = TREE_OPERAND (op1, 0); - r1 = TREE_OPERAND (op1, 1); - - if (TREE_CODE (l0) != TREE_CODE (l1) - || TREE_CODE (r0) != TREE_CODE (r1)) - return 0; - - if (TREE_CODE (l0) != COMPONENT_REF - && TREE_CODE (r0) == COMPONENT_REF) - { - l0 = TREE_OPERAND (op1, 0); - r0 = TREE_OPERAND (op1, 1); - l1 = TREE_OPERAND (op0, 0); - r1 = TREE_OPERAND (op0, 1); - } - - if (TREE_CODE (l0) == COMPONENT_REF - && ((TREE_LITERAL (r0) && TREE_LITERAL (r1)) - || (TREE_CODE (r0) == COMPONENT_REF - && TREE_OPERAND (l0, 1) == TREE_OPERAND (r0, 1) - && TREE_OPERAND (l1, 1) == TREE_OPERAND (r1, 1) - && simple_cst_equal (TREE_OPERAND (r0, 0), TREE_OPERAND (r1, 0)) > 0)) - && simple_cst_equal (TREE_OPERAND (l0, 0), TREE_OPERAND (l1, 0)) > 0) - { - tree f0 = TREE_OPERAND (l0, 1); - tree f1 = TREE_OPERAND (l1, 1); - tree tem0 = TREE_OPERAND (l0, 0); - tree tem1 = 0; - int align, bitsize, bitsize0, bitsize1; - int bitpos, bitpos0, bitpos1; - enum machine_mode trymode; - int volstruct0 = 0, volstruct1 = 0; - - bitsize0 = TREE_INT_CST_LOW (DECL_SIZE (f0)) * DECL_SIZE_UNIT (f0); - bitsize1 = TREE_INT_CST_LOW (DECL_SIZE (f1)) * DECL_SIZE_UNIT (f1); - - /* Only handles easy cases right now: - QImode+QImode => HImode - HImode+HImode => SImode. */ - if ((bitsize0 != bitsize1 && TREE_CODE (r0) != INTEGER_CST) - || bitsize0 + bitsize1 > BITS_PER_WORD) - return 0; - - /* Compute cumulative bit-offset for nested component-refs - and array-refs, and find the ultimate containing object. */ - - if (DECL_OFFSET (f1) > DECL_OFFSET (f0)) - bitpos0 = DECL_OFFSET (f0), bitpos1 = DECL_OFFSET (f1); - else - bitpos0 = DECL_OFFSET (f1), bitpos1 = DECL_OFFSET (f0); - - align = TYPE_ALIGN (TREE_TYPE (tem0)); - - if (TREE_CODE (r0) == COMPONENT_REF) - { - tem1 = TREE_OPERAND (r0, 0); - if (TYPE_ALIGN (TREE_TYPE (tem1)) < align) - align = TYPE_ALIGN (tem1); - } - - bitpos = bitpos0; - while (1) - { - if (TREE_CODE (tem0) == COMPONENT_REF) - { - bitpos0 += DECL_OFFSET (TREE_OPERAND (tem0, 1)); - if (TREE_THIS_VOLATILE (tem0)) - volstruct0 = 1; - } - else if (TREE_CODE (tem0) == ARRAY_REF - && TREE_CODE (TREE_OPERAND (tem0, 1)) == INTEGER_CST - && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem0))) == INTEGER_CST) - { - bitpos0 += (TREE_INT_CST_LOW (TREE_OPERAND (tem0, 1)) - * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem0))) - * TYPE_SIZE_UNIT (TREE_TYPE (tem0))); - } - else - break; - tem0 = TREE_OPERAND (tem0, 0); - if (tem1 == 0) - continue; - if (TREE_CODE (tem1) == COMPONENT_REF) - { - if (TREE_THIS_VOLATILE (tem1)) - volstruct1 = 1; - } - else if (TREE_CODE (tem1) == ARRAY_REF - && TREE_CODE (TREE_OPERAND (tem1, 1)) == INTEGER_CST - && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem1))) == INTEGER_CST) - ; - else - break; - } - bitpos1 += bitpos0 - bitpos; - - /* If these two accesses are not contiguous, - or they are not to the same byte, just fail. */ - - if (bitpos0 + bitsize0 == bitpos1) - /* This is the size of the access we want to make. */ - bitsize = bitsize0 << 1; - else if (((bitpos0 + bitsize0 + BITS_PER_UNIT - 1) / BITS_PER_UNIT) - == ((bitpos1 + BITS_PER_UNIT - 1) / BITS_PER_UNIT)) - /* Bits from the same byte. */ - bitsize = bitpos1 - bitpos0; - else - /* Failure. */ - return 0; - - if (align < bitsize) - return 0; - - /* Figure out the mode we will use for this access. */ - for (trymode = QImode; - trymode && GET_MODE_SIZE (trymode) * BITS_PER_UNIT < bitsize; - trymode = GET_MODE_WIDER_MODE (trymode)) - if (GET_MODE_SIZE (trymode) * BITS_PER_UNIT > align) - return 0; - - assert ((int)trymode != 0); - - /* Now build tree structure which distributes TREE_CODE (op0) over CODE. */ - tem0 = make_merged_ref (tem0, bitsize, bitpos0, trymode, volstruct0); - if (TREE_CODE (r0) == COMPONENT_REF) - { - tem1 = make_merged_ref (tem1, bitsize, bitpos0, trymode, volstruct1); - return build (TREE_CODE (op0), unsigned_type_node, tem0, tem1); - } - if (integer_zerop (r0) && integer_zerop (r1)) - tem1 = integer_zero_node; - else - tem1 = build_int_2 (TREE_INT_CST_LOW (r0)|(TREE_INT_CST_LOW (r1)<<(bitpos1-bitpos0)), 0); - if (bitpos0 + bitsize0 == bitpos1) - return build (TREE_CODE (op0), unsigned_type_node, tem0, tem1); - /* Test this quantity against a mask. */ - return build (NE_EXPR, integer_type_node, - build (BIT_AND_EXPR, unsigned_type_node, - tem0, tem1), - integer_zero_node); - } - - return 0; -} - -/* Return the character string for the name that encodes the - enumeral value VALUE in the domain TYPE. */ -char * -enum_name_string (value, type) - tree value; - tree type; -{ - register tree values = TYPE_VALUES (type); - register int intval = TREE_INT_CST_LOW (value); - - assert (TREE_CODE (type) == ENUMERAL_TYPE); - while (values - && TREE_INT_CST_LOW (TREE_VALUE (values)) != intval) - values = TREE_CHAIN (values); - if (values == NULL_TREE) - { - char *buf = (char *)oballoc (16 + TYPE_NAME_LENGTH (type)); - - /* Value must have been cast. */ - sprintf (buf, "(enum %s)%d", - TYPE_NAME_STRING (type), intval); - return buf; - } - return IDENTIFIER_POINTER (TREE_PURPOSE (values)); -} - -/* Print out a language-specific error message for - (Pascal) case or (C) switch statements. - CODE tells what sort of message to print. - TYPE is the type of the switch index expression. - NEW is the new value that we were trying to add. - OLD is the old value that stopped us from adding it. */ -void -report_case_error (code, type, new_value, old_value) - int code; - tree type; - tree new_value, old_value; -{ - if (code == 1) - { - if (new_value) - error ("case label not within a switch statement"); - else - error ("default label not within a switch statement"); - } - else if (code == 2) - { - if (new_value == 0) - { - error ("multiple default labels in one switch"); - return; - } - if (TREE_CODE (new_value) == RANGE_EXPR) - if (TREE_CODE (old_value) == RANGE_EXPR) - { - char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type))); - if (TREE_CODE (type) == ENUMERAL_TYPE) - sprintf (buf, "overlapping ranges [%s..%s], [%s..%s] in case expression", - enum_name_string (TREE_OPERAND (new_value, 0), type), - enum_name_string (TREE_OPERAND (new_value, 1), type), - enum_name_string (TREE_OPERAND (old_value, 0), type), - enum_name_string (TREE_OPERAND (old_value, 1), type)); - else - sprintf (buf, "overlapping ranges [%d..%d], [%d..%d] in case expression", - TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)), - TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)), - TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)), - TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1))); - error (buf); - } - else - { - char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type))); - if (TREE_CODE (type) == ENUMERAL_TYPE) - sprintf (buf, "range [%s..%s] includes element `%s' in case expression", - enum_name_string (TREE_OPERAND (new_value, 0), type), - enum_name_string (TREE_OPERAND (new_value, 1), type), - enum_name_string (old_value, type)); - else - sprintf (buf, "range [%d..%d] includes (%d) in case expression", - TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)), - TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)), - TREE_INT_CST_LOW (old_value)); - error (buf); - } - else if (TREE_CODE (old_value) == RANGE_EXPR) - { - char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type))); - if (TREE_CODE (type) == ENUMERAL_TYPE) - sprintf (buf, "range [%s..%s] includes element `%s' in case expression", - enum_name_string (TREE_OPERAND (old_value, 0), type), - enum_name_string (TREE_OPERAND (old_value, 1), type), - enum_name_string (new_value, type)); - else - sprintf (buf, "range [%d..%d] includes (%d) in case expression", - TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)), - TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)), - TREE_INT_CST_LOW (new_value)); - error (buf); - } - else - { - if (TREE_CODE (type) == ENUMERAL_TYPE) - error ("duplicate label `%s' in switch statement", - enum_name_string (new_value, type)); - else - error ("duplicate label (%d) in switch statement", - TREE_INT_CST_LOW (new_value)); - } - } - else if (code == 3) - { - if (TREE_CODE (type) == ENUMERAL_TYPE) - warning ("case value out of range for enum %s", - TYPE_NAME_STRING (type)); - else - warning ("case value out of range"); - } - else if (code == 4) - { - if (TREE_CODE (type) == ENUMERAL_TYPE) - error ("range values `%s' and `%s' reversed", - enum_name_string (new_value, type), - enum_name_string (old_value, type)); - else - error ("range values reversed"); - } -} diff --git a/gnu/usr.bin/g++/cc1plus/cplus-typeck.c b/gnu/usr.bin/g++/cc1plus/cplus-typeck.c deleted file mode 100644 index 86d3dfa35a9d..000000000000 --- a/gnu/usr.bin/g++/cc1plus/cplus-typeck.c +++ /dev/null @@ -1,6017 +0,0 @@ -/* Build expressions with type checking for C compiler. - Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file is part of the C front end. - It contains routines to build C expressions given their operands, - including computing the types of the result, C-specific error checks, - and some optimization. - - There are also routines to build RETURN_STMT nodes and CASE_STMT nodes, - and to process initializations in declarations (since they work - like a strange sort of assignment). */ - -extern void error (); -extern void warning (); - -#include "config.h" -#include -#include "tree.h" -#include "cplus-tree.h" -#include "flags.h" -#include "assert.h" - -#include "obstack.h" -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -extern int xmalloc (); -extern void free (); - -extern struct obstack *current_obstack; - -int mark_addressable (); -static tree convert_for_assignment (); -/* static */ tree convert_for_initialization (); -int compparms (); -int compparms1 (); -int comp_target_types (); -static tree shorten_compare (); -static void binary_op_error (); -static tree pointer_int_sum (); -static tree pointer_diff (); -static tree convert_sequence (); -/* static */ tree unary_complex_lvalue (); -tree truthvalue_conversion (); -static tree invert_truthvalue (); -extern void readonly_warning_or_error (); - -static void -message_2_types (pfn, s, type1, type2) - void (*pfn) (); - char *s; - tree type1, type2; -{ - tree name1 = TYPE_NAME (type1); - tree name2 = TYPE_NAME (type2); - if (TREE_CODE (name1) == TYPE_DECL) - name1 = DECL_NAME (name1); - if (TREE_CODE (name2) == TYPE_DECL) - name2 = DECL_NAME (name2); - (*pfn) (s, IDENTIFIER_POINTER (name1), IDENTIFIER_POINTER (name2)); -} - -/* Return the _TYPE node describing the data type - of the data which NODE represents as a C expression. - Arrays and functions are converted to pointers - just as they are when they appear as C expressions. - - C++: Member types are converted to the data - type of the member they are. */ - -tree -datatype (node) - tree node; -{ - register tree type = TREE_TYPE (node); - if (TREE_CODE (type) == ARRAY_TYPE) - return TYPE_POINTER_TO (TREE_TYPE (type)); - if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE) - return build_pointer_type (type); - if (TREE_CODE (type) == OFFSET_TYPE) - return datatype (type); - return type; -} - -/* Return the target type of TYPE, which meas return T for: - T*, T&, T[], T (...), and otherwise, just T. */ -tree -target_type (type) - tree type; -{ - if (TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); - while (TREE_CODE (type) == POINTER_TYPE - || TREE_CODE (type) == ARRAY_TYPE - || TREE_CODE (type) == FUNCTION_TYPE - || TREE_CODE (type) == METHOD_TYPE - || TREE_CODE (type) == OFFSET_TYPE) - type = TREE_TYPE (type); - return type; -} - -/* Do `exp = require_complete_type (exp);' to make sure exp - does not have an incomplete type. (That includes void types.) */ - -tree -require_complete_type (value) - tree value; -{ - tree type = TREE_TYPE (value); - - /* First, detect a valid value with a complete type. */ - if (TYPE_SIZE (type) != 0 - && type != void_type_node) - return value; - - /* If we see X::Y, we build an OFFSET_TYPE which has - not been laid out. Try to avoid an error by interpreting - it as this->X::Y, if reasonable. */ - if (TREE_CODE (value) == OFFSET_REF - && C_C_D != 0 - && TREE_OPERAND (value, 0) == C_C_D) - { - tree base, member = TREE_OPERAND (value, 1); - tree basetype = TYPE_OFFSET_BASETYPE (type); - assert (TREE_CODE (member) == FIELD_DECL); - base = convert_pointer_to (basetype, current_class_decl); - value = build (COMPONENT_REF, TREE_TYPE (TREE_OPERAND (value, 1)), - build_indirect_ref (base, 0), - TREE_OPERAND (value, 1)); - return require_complete_type (value); - } - - incomplete_type_error (value, type); - return error_mark_node; -} - -/* Return truthvalue of whether type of EXP is instantiated. */ -int -type_unknown_p (exp) - tree exp; -{ - return (TREE_TYPE (exp) == unknown_type_node - || (TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE - && TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node)); -} - -/* Do `exp = require_instantiated_type (type, exp);' to make sure EXP - does not have an uninstantiated type. - TYPE is type to instantiate with, if uninstantiated. */ -tree -require_instantiated_type (type, exp, errval) - tree type, exp, errval; -{ - if (TREE_TYPE (exp) == unknown_type_node - || (TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE - && TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node)) - { - exp = instantiate_type (type, exp, 1); - if (TREE_TYPE (exp) == error_mark_node) - return errval; - } - return exp; -} - -/* Return a variant of TYPE which has all the type qualifiers of LIKE - as well as those of TYPE. */ - -static tree -qualify_type (type, like) - tree type, like; -{ - int constflag = TREE_READONLY (type) || TREE_READONLY (like); - int volflag = TREE_VOLATILE (type) || TREE_VOLATILE (like); - /* @@ Must do member pointers here. */ - return build_type_variant (type, constflag, volflag); -} - -/* Return the common type of two parameter lists. - - As an optimization, free the space we allocate if the parameter - lists are already common. */ - -tree -commonparms (p1, p2) - tree p1, p2; -{ - tree oldargs = p1, newargs, n; - int i, len; - int any_change = 0; - char *first_obj = (char *)obstack_alloc (current_obstack, 0); - - len = list_length (p1); - newargs = 0; - - for (i = 0; i < len; i++) - newargs = tree_cons (0, 0, newargs); - - n = newargs; - - for (i = 0; p1; - p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2), n = TREE_CHAIN (n), i++) - { - if (TREE_PURPOSE (p1) && !TREE_PURPOSE (p2)) - { -#if 0 - if (! any_warning) - { - warning ("default argument given in prototype and not in declaration of function"); - any_warning++; - } -#endif - TREE_PURPOSE (p2) = TREE_PURPOSE (p1); - any_change = 1; - } - else if (! TREE_PURPOSE (p1)) - { - if (TREE_PURPOSE (p2)) - any_change = 1; - } - else - { - int cmp = simple_cst_equal (TREE_PURPOSE (p1), TREE_PURPOSE (p2)); - if (cmp < 0) - abort (); - if (cmp == 0) - { - error ("redeclaration of default argument %d", i); - any_change = 1; - } - } - TREE_PURPOSE (n) = TREE_PURPOSE (p2); - if (TREE_VALUE (p1) != TREE_VALUE (p2)) - { - any_change = 1; - TREE_VALUE (n) = commontype (TREE_VALUE (p1), TREE_VALUE (p2)); - } - else - TREE_VALUE (n) = TREE_VALUE (p1); - } - if (! any_change) - { - obstack_free (current_obstack, first_obj); - return oldargs; - } - - return newargs; -} - -/* Return the common type of two types. - We assume that comptypes has already been done and returned 1; - if that isn't so, this may crash. - - This is the type for the result of most arithmetic operations - if the operands have the given two types. - - We do not deal with enumeral types here because they have already been - converted to integer types. */ - -tree -commontype (t1, t2) - tree t1, t2; -{ - register enum tree_code form1; - register enum tree_code form2; - - /* Save time if the two types are the same. */ - - if (t1 == t2) return t1; - - /* Treat an enum type as the unsigned integer type of the same width. */ - - if (TREE_CODE (t1) == ENUMERAL_TYPE) - t1 = type_for_size (TYPE_PRECISION (t1), 1); - if (TREE_CODE (t2) == ENUMERAL_TYPE) - t2 = type_for_size (TYPE_PRECISION (t2), 1); - - form1 = TREE_CODE (t1); - form2 = TREE_CODE (t2); - - switch (form1) - { - case INTEGER_TYPE: - case REAL_TYPE: - /* If only one is real, use it as the result. */ - - if (form1 == REAL_TYPE && form2 != REAL_TYPE) - return t1; - - if (form2 == REAL_TYPE && form1 != REAL_TYPE) - return t2; - - /* Both real or both integers; use the one with greater precision. */ - - if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2)) - return t1; - else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1)) - return t2; - - /* Same precision. Prefer longs to ints even when same size. */ - - if (t1 == long_unsigned_type_node - || t2 == long_unsigned_type_node) - return long_unsigned_type_node; - - if (t1 == long_integer_type_node - || t2 == long_integer_type_node) - { - /* But preserve unsignedness from the other type, - since long cannot hold all the values of an unsigned int. */ - if (TREE_UNSIGNED (t1) || TREE_UNSIGNED (t2)) - return long_unsigned_type_node; - return long_integer_type_node; - } - - /* Otherwise prefer the unsigned one. */ - - if (TREE_UNSIGNED (t1)) - return t1; - else return t2; - -#if 1 - case POINTER_TYPE: - case REFERENCE_TYPE: - /* For two pointers, do this recursively on the target type, - and combine the qualifiers of the two types' targets. */ - { - tree target = commontype (TYPE_MAIN_VARIANT (TREE_TYPE (t1)), - TYPE_MAIN_VARIANT (TREE_TYPE (t2))); - int constp - = TREE_READONLY (TREE_TYPE (t1)) || TREE_READONLY (TREE_TYPE (t2)); - int volatilep - = TREE_VOLATILE (TREE_TYPE (t1)) || TREE_VOLATILE (TREE_TYPE (t2)); - target = build_type_variant (target, constp, volatilep); - if (form1 == POINTER_TYPE) - return build_pointer_type (target); - else - return build_reference_type (target); - } -#else - case POINTER_TYPE: - return build_pointer_type (commontype (TREE_TYPE (t1), TREE_TYPE (t2))); - - case REFERENCE_TYPE: - return build_reference_type (commontype (TREE_TYPE (t1), TREE_TYPE (t2))); -#endif - - case ARRAY_TYPE: - { - tree elt = commontype (TREE_TYPE (t1), TREE_TYPE (t2)); - /* Save space: see if the result is identical to one of the args. */ - if (elt == TREE_TYPE (t1) && TYPE_DOMAIN (t1)) - return t1; - if (elt == TREE_TYPE (t2) && TYPE_DOMAIN (t2)) - return t2; - /* Merge the element types, and have a size if either arg has one. */ - return build_array_type (elt, TYPE_DOMAIN (TYPE_DOMAIN (t1) ? t1 : t2)); - } - - case FUNCTION_TYPE: - /* Function types: prefer the one that specified arg types. - If both do, merge the arg types. Also merge the return types. */ - { - tree valtype = commontype (TREE_TYPE (t1), TREE_TYPE (t2)); - tree p1 = TYPE_ARG_TYPES (t1); - tree p2 = TYPE_ARG_TYPES (t2); - tree rval, raises; - - /* Save space: see if the result is identical to one of the args. */ - if (valtype == TREE_TYPE (t1) && ! TYPE_ARG_TYPES (t2)) - return t1; - if (valtype == TREE_TYPE (t2) && ! TYPE_ARG_TYPES (t1)) - return t2; - - /* Simple way if one arg fails to specify argument types. */ - if (TYPE_ARG_TYPES (t1) == 0) - { - rval = build_function_type (valtype, TYPE_ARG_TYPES (t2)); - if (raises = TYPE_RAISES_EXCEPTIONS (t2)) - rval = build_exception_variant (NULL_TREE, rval, raises); - return rval; - } - raises = TYPE_RAISES_EXCEPTIONS (t1); - if (TYPE_ARG_TYPES (t2) == 0) - { - rval = build_function_type (valtype, TYPE_ARG_TYPES (t1)); - if (raises) - rval = build_exception_variant (NULL_TREE, rval, raises); - return rval; - } - - /* If both args specify argument types, we must merge the two - lists, argument by argument. */ - rval = build_function_type (valtype, commonparms (p1, p2)); - return build_exception_variant (NULL_TREE, rval, raises); - } - - case RECORD_TYPE: - case UNION_TYPE: - assert (TYPE_MAIN_VARIANT (t1) == t1 && TYPE_MAIN_VARIANT (t2) == t2); - - if (basetype_or_else (t1, t2)) - return t1; - compiler_error ("commontype called with uncommon aggregate types"); - return t1; - - case METHOD_TYPE: - if (TYPE_METHOD_BASETYPE (t1) == TYPE_METHOD_BASETYPE (t2) - && TREE_CODE (TREE_TYPE (t1)) == TREE_CODE (TREE_TYPE (t2))) - { - /* Get this value the long way, since TYPE_METHOD_BASETYPE - is just the main variant of this. */ - tree basetype = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t1))); - tree raises, t3; - - raises = TYPE_RAISES_EXCEPTIONS (t1); - - /* If this was a member function type, get back to the - original type of type member function (i.e., without - the class instance variable up front. */ - t1 = build_function_type (TREE_TYPE (t1), TREE_CHAIN (TYPE_ARG_TYPES (t1))); - t2 = build_function_type (TREE_TYPE (t2), TREE_CHAIN (TYPE_ARG_TYPES (t2))); - t3 = commontype (t1, t2); - t3 = build_cplus_method_type (basetype, TREE_TYPE (t3), TYPE_ARG_TYPES (t3)); - return build_exception_variant (basetype, t3, raises); - } - compiler_error ("commontype called with uncommon method types"); - return t1; - - case OFFSET_TYPE: - if (TYPE_OFFSET_BASETYPE (t1) == TYPE_OFFSET_BASETYPE (t2) - && TREE_CODE (TREE_TYPE (t1)) == TREE_CODE (TREE_TYPE (t2))) - { - tree basetype = TYPE_OFFSET_BASETYPE (t1); - return build_member_type (basetype, - commontype (TREE_TYPE (t1), TREE_TYPE (t2))); - } - compiler_error ("commontype called with uncommon member types"); - return t1; - - default: - return t1; - } -} - -/* Return 1 if TYPE1 and TYPE2 raise the same exceptions. */ -int -compexcepttypes (t1, t2, strict) - tree t1, t2; - int strict; -{ - return TYPE_RAISES_EXCEPTIONS (t1) == TYPE_RAISES_EXCEPTIONS (t2); -} - -static int -comp_array_types (cmp, t1, t2, strict) - register int (*cmp)(); - tree t1, t2; -{ - tree d1 = TYPE_DOMAIN (t1); - tree d2 = TYPE_DOMAIN (t2); - - if (!(TREE_TYPE (t1) == TREE_TYPE (t2) - || (*cmp) (TREE_TYPE (t1), TREE_TYPE (t2), strict))) - return 0; - - /* Sizes must match unless one is missing or variable. */ - if (d1 == 0 || d2 == 0 || d1 == d2 - || TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST - || TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST - || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST - || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST) - return 1; - - return ((TREE_INT_CST_LOW (TYPE_MIN_VALUE (d1)) - == TREE_INT_CST_LOW (TYPE_MIN_VALUE (d2))) - && (TREE_INT_CST_HIGH (TYPE_MIN_VALUE (d1)) - == TREE_INT_CST_HIGH (TYPE_MIN_VALUE (d2))) - && (TREE_INT_CST_LOW (TYPE_MAX_VALUE (d1)) - == TREE_INT_CST_LOW (TYPE_MAX_VALUE (d2))) - && (TREE_INT_CST_HIGH (TYPE_MAX_VALUE (d1)) - == TREE_INT_CST_HIGH (TYPE_MAX_VALUE (d2)))); -} - -/* Return 1 if TYPE1 and TYPE2 are compatible types for assignment - or various other operations. This is what ANSI C speaks of as - "being the same". - - For C++: argument STRICT says we should be strict about this - comparison: - - 1 : strict (compared according to ANSI C) - 0 : <= (compared according to C++) - -1: <= or >= (relaxed) - - Otherwise, pointers involving base classes and derived classes - can be mixed as legal: i.e. a pointer to a base class may be assigned - to a pointer to one of its derived classes, as per C++. A pointer to - a derived class may be passed as a paramter to a function expecting a - pointer to a base classes. These allowances do not commute. In this - case, TYPE1 is assumed to be the base class, and TYPE2 is assumed to - be the derived class. */ -int -comptypes (type1, type2, strict) - tree type1, type2; - int strict; -{ - register tree t1 = type1; - register tree t2 = type2; - - /* Suppress errors caused by previously reported errors */ - - if (t1 == t2) - return 1; - /* This should never happen. */ - assert (t1 != error_mark_node); - - /* We don't want this to happen. */ - if (t2 == error_mark_node) - { - warning ("t2 == error_mark_node in `comptypes'"); - return 0; - } - - /* Treat an enum type as the unsigned integer type of the same width. */ - - if (TREE_CODE (t1) == ENUMERAL_TYPE) - t1 = type_for_size (TYPE_PRECISION (t1), 1); - if (TREE_CODE (t2) == ENUMERAL_TYPE) - t2 = type_for_size (TYPE_PRECISION (t2), 1); - - if (t1 == t2) - return 1; - - /* Different classes of types can't be compatible. */ - - if (TREE_CODE (t1) != TREE_CODE (t2)) return 0; - - /* Qualifiers must match. */ - - if (TREE_READONLY (t1) != TREE_READONLY (t2)) - return 0; - if (TREE_THIS_VOLATILE (t1) != TREE_THIS_VOLATILE (t2)) - return 0; - - switch (TREE_CODE (t1)) - { - case RECORD_TYPE: - case UNION_TYPE: - if (t1 == t2) - return 1; - if (strict <= 0) - goto look_hard; - return 0; - - case OFFSET_TYPE: - return (comptypes (TYPE_POINTER_TO (TYPE_OFFSET_BASETYPE (t1)), - TYPE_POINTER_TO (TYPE_OFFSET_BASETYPE (t2)), strict) - && comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict)); - - case METHOD_TYPE: - if (! compexcepttypes (t1, t2, strict)) - return 0; - - /* This case is anti-symmetrical! - One can pass a base member (or member function) - to something expecting a derived member (or member function), - but not vice-versa! */ - - return (comptypes (TYPE_POINTER_TO (TYPE_METHOD_BASETYPE (t2)), - TYPE_POINTER_TO (TYPE_METHOD_BASETYPE (t1)), strict) - && comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict) - && compparms (TREE_CHAIN (TYPE_ARG_TYPES (t1)), - TREE_CHAIN (TYPE_ARG_TYPES(t2)), strict)); - case POINTER_TYPE: - case REFERENCE_TYPE: - t1 = TREE_TYPE (t1); - t2 = TREE_TYPE (t2); - if (t1 == t2) - return 1; - if (strict <= 0) - { - if (IS_AGGR_TYPE (t1) && IS_AGGR_TYPE (t2)) - { - int rval; - look_hard: - rval = t1 == t2 || get_base_distance (t1, t2, 0, 0) >= 0; - - if (rval) - return 1; - if (strict < 0) - return (get_base_type (t2, t1, 0) != 0); - } - return 0; - } - else - return comptypes (t1, t2, strict); - - case FUNCTION_TYPE: - if (! compexcepttypes (t1, t2, strict)) - return 0; - - return ((TREE_TYPE (t1) == TREE_TYPE (t2) - || comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict)) - && compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2), strict)); - - case ARRAY_TYPE: - /* Target types must match incl. qualifiers. */ - return comp_array_types (&comptypes, t1, t2, strict); - - } - return 0; -} - -/* Return 1 if TTL and TTR are pointers to types that are equivalent, - ignoring their qualifiers. - - NPTRS is the number of pointers we can strip off and keep cool. - This is used to permit (for aggr A, aggr B) A, B* to convert to A*, - but to not permit B** to convert to A**. */ - -int -comp_target_types (ttl, ttr, nptrs) - tree ttl, ttr; - int nptrs; -{ - ttl = TYPE_MAIN_VARIANT (ttl); - ttr = TYPE_MAIN_VARIANT (ttr); - if (ttl == ttr) - return 1; - - if (TREE_CODE (ttr) != TREE_CODE (ttl)) - return 0; - - if (TREE_CODE (ttr) == POINTER_TYPE) - return comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs - 1); - - if (TREE_CODE (ttr) == REFERENCE_TYPE) - return comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs); - if (TREE_CODE (ttr) == ARRAY_TYPE) - return comp_array_types (&comp_target_types, ttl, ttr, 0); - else if (TREE_CODE (ttr) == FUNCTION_TYPE || TREE_CODE (ttr) == METHOD_TYPE) - if (comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs)) - switch (comp_target_parms (TYPE_ARG_TYPES (ttl), TYPE_ARG_TYPES (ttr), -1)) - { - case 0: - return 0; - case 1: - return 1; - case 2: - warning ("contravariance violation for method types ignored"); - return 1; - default: - abort (); - } - else - return 0; - - /* for C++ */ - else if (TREE_CODE (ttr) == OFFSET_TYPE) - { - /* Contravariance: we can assign a pointer to base member to a pointer - to derived member. Note difference from simple pointer case, where - we can pass a pointer to derived to a pointer to base. */ - if (comptypes (TYPE_OFFSET_BASETYPE (ttr), TYPE_OFFSET_BASETYPE (ttl), 0)) - return comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs); - else if (comptypes (TYPE_OFFSET_BASETYPE (ttl), TYPE_OFFSET_BASETYPE (ttr), 0) - && comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs)) - { - warning ("contravariance violation for member types ignored"); - return 1; - } - } - else if (IS_AGGR_TYPE (ttl)) - { - if (nptrs < 0) - return 0; - return comptypes (TYPE_POINTER_TO (ttl), TYPE_POINTER_TO (ttr), 0); - } - - return 0; -} - -/* If two types share a common base type, return that basetype. - There is not a unique most-derived base type, this function - returns ERROR_MARK_NODE. */ -tree -common_base_type (tt1, tt2) - tree tt1, tt2; -{ - tree first = NULL_TREE, second = NULL_TREE, tmp; - int i; - - for (i = CLASSTYPE_N_BASECLASSES (tt1); i > 0; i--) - { - tree basetype = CLASSTYPE_BASECLASS (tt1, i); - switch (get_base_distance (basetype, tt2, 0, 0)) - { - case -1: - tmp = common_base_type (basetype, tt2); - if (tmp == NULL_TREE) - break; - if (tmp == error_mark_node) - return error_mark_node; - if (first != NULL_TREE) - return error_mark_node; - first = tmp; - break; - - case -2: - first = error_mark_node; - break; - - default: - if (first != NULL_TREE) - return error_mark_node; - first = CLASSTYPE_BASECLASS (tt1, i); - break; - } - } - - for (i = CLASSTYPE_N_BASECLASSES (tt2); i > 0; i--) - { - tree basetype = CLASSTYPE_BASECLASS (tt2, i); - switch (get_base_distance (basetype, tt1, 0, 0)) - { - case -1: - tmp = common_base_type (basetype, tt1); - if (tmp == NULL_TREE) - break; - if (tmp == error_mark_node) - return error_mark_node; - if (second != NULL_TREE) - return error_mark_node; - second = tmp; - break; - - case -2: - second = error_mark_node; - break; - - default: - if (second != NULL_TREE) - return error_mark_node; - second = CLASSTYPE_BASECLASS (tt2, i); - break; - } - } - - if (first != NULL_TREE - && second != NULL_TREE - && TYPE_MAIN_VARIANT (first) == TYPE_MAIN_VARIANT (second)) - return first; - if (first) - return first; - if (second) - return second; - - return NULL_TREE; -} - -/* Subroutines of `comptypes'. */ - -/* Return 1 if two parameter type lists PARMS1 and PARMS2 - are equivalent in the sense that functions with those parameter types - can have equivalent types. - If either list is empty, we win. - Otherwise, the two lists must be equivalent, element by element. - - C++: See comment above about TYPE1, TYPE2, STRICT. */ -int -compparms (parms1, parms2, strict) - tree parms1, parms2; - int strict; -{ - register tree t1 = parms1, t2 = parms2; - - /* An unspecified parmlist matches any specified parmlist - whose argument types don't need default promotions. */ - - if (t1 == 0) - return compparms1 (t2); - if (t2 == 0) - return compparms1 (t1); - - while (1) - { - if (t1 == 0 && t2 == 0) - return 1; - /* If one parmlist is shorter than the other, - they fail to match, unless STRICT is <= 0. */ - if (t1 == 0 || t2 == 0) - { - if (strict > 0) - return 0; - if (strict < 0) - return 1; - if (strict == 0) - return t1 && TREE_PURPOSE (t1); - return ((t1 && TREE_PURPOSE (t1)) || TREE_PURPOSE (t2)); - } - if (! comptypes (TREE_VALUE (t2), TREE_VALUE (t1), strict)) - { - if (strict > 0) - return 0; - if (strict == 0) - return t2 == void_list_node && TREE_PURPOSE (t1); - return TREE_PURPOSE (t1) || TREE_PURPOSE (t2); - } - if (TREE_PURPOSE (t1) && TREE_PURPOSE (t2)) - { - int cmp = simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)); - if (cmp < 0) - abort (); - if (cmp == 0) - return 0; - } - - t1 = TREE_CHAIN (t1); - t2 = TREE_CHAIN (t2); - } -} - -/* This really wants return whether or not parameter type lists - would make their owning functions assignment compatible or not. */ -int -comp_target_parms (parms1, parms2, strict) - tree parms1, parms2; - int strict; -{ - register tree t1 = parms1, t2 = parms2; - int warn_contravariance = 0; - - /* An unspecified parmlist matches any specified parmlist - whose argument types don't need default promotions. */ - - if (t1 == 0) - return compparms1 (t2); - if (t2 == 0) - return compparms1 (t1); - - for (; t1 || t2; t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2)) - { - tree p1, p2; - - /* If one parmlist is shorter than the other, - they fail to match, unless STRICT is <= 0. */ - if (t1 == 0 || t2 == 0) - { - if (strict > 0) - return 0; - if (strict < 0) - return 1 + warn_contravariance; - return ((t1 && TREE_PURPOSE (t1)) + warn_contravariance); - } - p1 = TREE_VALUE (t1); - p2 = TREE_VALUE (t2); - if (p1 == p2) - continue; - if ((TREE_CODE (p1) == POINTER_TYPE && TREE_CODE (p2) == POINTER_TYPE) - || (TREE_CODE (p1) == REFERENCE_TYPE && TREE_CODE (p2) == REFERENCE_TYPE)) - { - /* The following is wrong for contravariance, - but many programs depend on it. */ - if (TREE_TYPE (p1) == void_type_node) - { - warn_contravariance = 1; - continue; - } - if (TREE_TYPE (p2) == void_type_node) - continue; - if (IS_AGGR_TYPE (TREE_TYPE (p1))) - { - if (comptypes (p2, p1, 0) == 0) - { - if (comptypes (p1, p2, 0) != 0) - warn_contravariance = 1; - else - return 0; - } - continue; - } - } - /* Note backwards order due to contravariance. */ - if (comp_target_types (p2, p1, 1) == 0) - { - if (comp_target_types (p1, p2, 1)) - { - warn_contravariance = 1; - continue; - } - if (strict > 0) - return 0; -#if 0 - /* What good do these cases do? */ - if (strict == 0) - return p2 == void_type_node && TREE_PURPOSE (t1); - return TREE_PURPOSE (t1) || TREE_PURPOSE (t2); -#endif - } - /* Target types are compatible--just make sure that if - we use parameter lists, that they are ok as well. */ - if (TREE_CODE (p1) == FUNCTION_TYPE || TREE_CODE (p1) == METHOD_TYPE) - switch (comp_target_parms (TYPE_ARG_TYPES (p1), TYPE_ARG_TYPES (p2), strict)) - { - case 0: - return 0; - case 1: - break; - case 2: - warn_contravariance = 1; - } - - if (TREE_PURPOSE (t1) && TREE_PURPOSE (t2)) - { - int cmp = simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)); - if (cmp < 0) - abort (); - if (cmp == 0) - return 0; - } - } - return 1 + warn_contravariance; -} - -/* Return 1 if PARMS specifies a fixed number of parameters - and none of their types is affected by default promotions. */ - -int -compparms1 (parms) - tree parms; -{ - register tree t; - for (t = parms; t; t = TREE_CHAIN (t)) - { - register tree type = TREE_VALUE (t); - - if (TREE_CHAIN (t) == 0 && type != void_type_node) - return 0; - - if (type == float_type_node) - return 0; - - if (TREE_CODE (type) == INTEGER_TYPE - && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) - return 0; - } - return 1; -} - -/* Return an unsigned type the same as TYPE in other respects. - - C++: must make these work for type variants as well. */ - -tree -unsigned_type (type) - tree type; -{ - type = TYPE_MAIN_VARIANT (type); - - if (type == signed_char_type_node || type == char_type_node) - return unsigned_char_type_node; - if (type == integer_type_node) - return unsigned_type_node; - if (type == short_integer_type_node) - return short_unsigned_type_node; - if (type == long_integer_type_node) - return long_unsigned_type_node; - if (type == long_long_integer_type_node) - return long_long_unsigned_type_node; - return type; -} - -/* Return a signed type the same as TYPE in other respects. */ - -tree -signed_type (type) - tree type; -{ - if (type == unsigned_char_type_node || type == char_type_node) - return signed_char_type_node; - if (type == unsigned_type_node) - return integer_type_node; - if (type == short_unsigned_type_node) - return short_integer_type_node; - if (type == long_unsigned_type_node) - return long_integer_type_node; - if (type == long_long_unsigned_type_node) - return long_long_integer_type_node; - return type; -} - -/* Return a type the same as TYPE except unsigned or - signed according to UNSIGNEDP. */ - -tree -signed_or_unsigned_type (unsignedp, type) - int unsignedp; - tree type; -{ - if (TREE_CODE (type) != INTEGER_TYPE) - return type; - if (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node)) - return unsignedp ? unsigned_char_type_node : signed_char_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)) - return unsignedp ? unsigned_type_node : integer_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (short_integer_type_node)) - return unsignedp ? short_unsigned_type_node : short_integer_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (long_integer_type_node)) - return unsignedp ? long_unsigned_type_node : long_integer_type_node; - if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node)) - return (unsignedp ? long_long_unsigned_type_node - : long_long_integer_type_node); - return type; -} - -/* Return an integer type with BITS bits of precision, - that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */ - -tree -type_for_size (bits, unsignedp) - int bits; - int unsignedp; -{ - if (bits <= TYPE_PRECISION (signed_char_type_node)) - return unsignedp ? unsigned_char_type_node : signed_char_type_node; - - if (bits <= TYPE_PRECISION (short_integer_type_node)) - return unsignedp ? short_unsigned_type_node : short_integer_type_node; - - if (bits <= TYPE_PRECISION (integer_type_node)) - return unsignedp ? unsigned_type_node : integer_type_node; - - if (bits <= TYPE_PRECISION (long_integer_type_node)) - return unsignedp ? long_unsigned_type_node : long_integer_type_node; - - if (bits <= TYPE_PRECISION (long_long_integer_type_node)) - return (unsignedp ? long_long_unsigned_type_node - : long_long_integer_type_node); - - return 0; -} - -tree -get_floating_type (mode) - enum machine_mode mode; -{ - if (mode == TYPE_MODE (float_type_node)) - return float_type_node; - if (mode == TYPE_MODE (double_type_node)) - return double_type_node; - if (mode == TYPE_MODE (long_double_type_node)) - return long_double_type_node; - abort (); -} - -tree -c_sizeof (type) - tree type; -{ - enum tree_code code = TREE_CODE (type); - - if (code == FUNCTION_TYPE) - { - if (pedantic || warn_pointer_arith) - warning ("sizeof applied to a function type"); - return build_int (1); - } - if (code == METHOD_TYPE) - { - if (pedantic || warn_pointer_arith) - warning ("sizeof applied to a method type"); - return build_int (1); - } - if (code == VOID_TYPE) - { - if (pedantic || warn_pointer_arith) - warning ("sizeof applied to a void type"); - return build_int (1); - } - - /* C++: this is really correct! */ - if (code == REFERENCE_TYPE) - type = TREE_TYPE (type); - - return size_in_bytes (type); -} - -tree -c_sizeof_nowarn (type) - tree type; -{ - enum tree_code code = TREE_CODE (type); - - if (code == FUNCTION_TYPE - || code == METHOD_TYPE - || code == VOID_TYPE) - return build_int (1); - if (code == REFERENCE_TYPE) - type = TREE_TYPE (type); - - return size_in_bytes (type); -} - -/* Implement the __alignof keyword: Return the minimum required - alignment of TYPE, measured in bytes. */ - -tree -c_alignof (type) - tree type; -{ - enum tree_code code = TREE_CODE (type); - - if (code == FUNCTION_TYPE || code == METHOD_TYPE) - return build_int (FUNCTION_BOUNDARY / BITS_PER_UNIT); - - if (code == VOID_TYPE) - return build_int (1); - - /* C++: this is really correct! */ - if (code == REFERENCE_TYPE) - type = TREE_TYPE (type); - - return build_int (TYPE_ALIGN (type) / BITS_PER_UNIT); -} - -/* Perform default promotions for C data used in expressions. - Arrays and functions are converted to pointers; - enumeral types or short or char, to int. - In addition, manifest constants symbols are replaced by their values. - - C++: this will automatically bash references to their target type. */ - -tree -default_conversion (exp) - tree exp; -{ - register tree dt = TREE_TYPE (exp); - register enum tree_code form = TREE_CODE (dt); - - if (form == OFFSET_TYPE) - { -#if 0 - warning ("conversion from member type"); -#endif - if (TREE_CODE (exp) == OFFSET_REF) - return default_conversion (resolve_offset_ref (exp)); - - dt = TREE_TYPE (dt); - form = TREE_CODE (dt); - } - - if (form == REFERENCE_TYPE) - { - exp = convert_from_reference (exp); - dt = TREE_TYPE (exp); - form = TREE_CODE (dt); - } - - if (TREE_CODE (exp) == CONST_DECL) - exp = DECL_INITIAL (exp); - else if (TREE_READONLY_DECL_P (exp)) - { - exp = decl_constant_value (exp); - dt = TREE_TYPE (exp); - } - - /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. - Strip such NOP_EXPRs, since EXP is being used in non-lvalue context. */ - if (TREE_CODE (exp) == NOP_EXPR - && TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0))) - exp = TREE_OPERAND (exp, 0); - - if (form == ENUMERAL_TYPE - || (form == INTEGER_TYPE - && (TYPE_PRECISION (dt) - < TYPE_PRECISION (integer_type_node)))) - { - /* Traditionally, unsignedness is preserved in default promotions. */ - if (flag_traditional && TREE_UNSIGNED (dt)) - return convert (unsigned_type_node, exp); - return convert (integer_type_node, exp); - } - if (flag_traditional && dt == float_type_node) - return convert (double_type_node, exp); - if (form == VOID_TYPE) - { - error ("void value not ignored as it ought to be"); - return error_mark_node; - } - if (form == FUNCTION_TYPE || form == METHOD_TYPE) - { - return build_unary_op (ADDR_EXPR, exp, 0); - } - if (form == ARRAY_TYPE) - { - register tree adr; - tree restype = TREE_TYPE (dt); - tree ptrtype; - - if (TREE_CODE (exp) == INDIRECT_REF) - { - /* Stripping away the INDIRECT_REF is not the right - thing to do for references... */ - tree inner = TREE_OPERAND (exp, 0); - if (TREE_CODE (TREE_TYPE (inner)) == REFERENCE_TYPE) - inner = build1 (REFERENCE_EXPR, - build_pointer_type (TREE_TYPE (TREE_TYPE (inner))), - inner); - return convert (TYPE_POINTER_TO (TREE_TYPE (dt)), inner); - } - - if (TREE_CODE (exp) == COMPOUND_EXPR) - { - tree op1 = default_conversion (TREE_OPERAND (exp, 1)); - return build (COMPOUND_EXPR, TREE_TYPE (op1), - TREE_OPERAND (exp, 0), op1); - } - - if (!lvalue_p (exp) - && ! (TREE_CODE (exp) == CONSTRUCTOR && TREE_STATIC (exp))) - { - error ("invalid use of non-lvalue array"); - return error_mark_node; - } - - if (TREE_READONLY (exp) || TREE_THIS_VOLATILE (exp)) - restype = build_type_variant (restype, TREE_READONLY (exp), - TREE_THIS_VOLATILE (exp)); - - ptrtype = build_pointer_type (restype); - - if (TREE_CODE (exp) == VAR_DECL) - { - /* ??? This is not really quite correct - in that the type of the operand of ADDR_EXPR - is not the target type of the type of the ADDR_EXPR itself. - Question is, can this lossage be avoided? */ - adr = build1 (ADDR_EXPR, ptrtype, exp); - if (mark_addressable (exp) == 0) - return error_mark_node; - TREE_LITERAL (adr) = staticp (exp); - TREE_VOLATILE (adr) = 0; /* Default would be, same as EXP. */ - return adr; - } - /* This way is better for a COMPONENT_REF since it can - simplify the offset for a component. */ - adr = build_unary_op (ADDR_EXPR, exp, 1); - return convert (ptrtype, adr); - } - return exp; -} - -/* Like `build_component_ref, but uses an already found field. - Must compute visibility for C_C_D. Otherwise, ok. */ -tree -build_component_ref_1 (datum, field, protect) - tree datum, field; - int protect; -{ - register tree basetype = TREE_TYPE (datum); - register enum tree_code form = TREE_CODE (basetype); - register tree ref; - - if (form == REFERENCE_TYPE) - { - datum = convert_from_reference (datum); - basetype = TREE_TYPE (datum); - form = TREE_CODE (basetype); - } - - if (! IS_AGGR_TYPE_CODE (form)) - { - if (form != ERROR_MARK) - error_with_decl (field, "request for member `%s' in something not a class, structure or union"); - return error_mark_node; - } - - if (TYPE_SIZE (basetype) == 0) - { - incomplete_type_error (0, basetype); - return error_mark_node; - } - - /* Look up component name in the structure type definition. */ - - if (field == error_mark_node) - abort (); - - if (TREE_STATIC (field)) - return field; - - if (datum == C_C_D && ! TREE_FIELD_PUBLIC (field)) - { - enum visibility_type visibility - = compute_visibility (build_tree_list (NULL_TREE, current_class_type), - field); - - if (visibility == visibility_private) - { - error_with_decl (field, "field `%s' is private"); - return error_mark_node; - } - else if (visibility == visibility_protected) - { - error_with_decl (field, "field `%s' is protected"); - return error_mark_node; - } - } - - ref = build (COMPONENT_REF, TREE_TYPE (field), datum, field); - - if (TREE_READONLY (datum) || TREE_READONLY (field)) - TREE_READONLY (ref) = 1; - if (TREE_THIS_VOLATILE (datum) || TREE_VOLATILE (field)) - TREE_THIS_VOLATILE (ref) = 1; - - return ref; -} - -tree -build_component_ref (datum, component, basetype_path, protect) - tree datum, component, basetype_path; - int protect; -{ - tree basetypes; - register tree basetype = TREE_TYPE (datum); - register enum tree_code form = TREE_CODE (basetype); - register tree field = NULL; - register tree ref; - - if (form == REFERENCE_TYPE) - { -#if 0 - /* REFERENCE_EXPRs are not converted by `convert_from_reference'. - @@ Maybe that is not right. */ - if (TREE_CODE (datum) == REFERENCE_EXPR) - datum = build1 (INDIRECT_REF, TREE_TYPE (basetype), datum); - else -#endif - datum = convert_from_reference (datum); - basetype = TREE_TYPE (datum); - form = TREE_CODE (basetype); - } - - /* First, see if there is a field or component with name COMPONENT. */ - if (TREE_CODE (component) == TREE_LIST) - { - assert (!(TREE_CHAIN (component) == NULL_TREE - && TREE_CHAIN (TREE_VALUE (component)) == NULL_TREE)); - return build (COMPONENT_REF, TREE_TYPE (component), datum, component); - } - if (TREE_CODE (component) == TYPE_EXPR) - return build_component_type_expr (datum, component, NULL_TREE, protect); - - if (! IS_AGGR_TYPE_CODE (form)) - { - if (form != ERROR_MARK) - error ("request for member `%s' in something not a class, structure or union", - IDENTIFIER_POINTER (component)); - return error_mark_node; - } - - if (TYPE_SIZE (basetype) == 0) - { - incomplete_type_error (0, basetype); - return error_mark_node; - } - - /* Look up component name in the structure type definition. */ - if (basetype_path == NULL_TREE) - basetype_path = CLASSTYPE_AS_LIST (basetype); - basetypes = basetype_path; - field = lookup_field (basetypes, component, - protect && ! VFIELD_NAME_P (component)); - - if (field == error_mark_node) - return error_mark_node; - - if (field == NULL_TREE) - { - /* Not found as a data field, look for it as a method. If found, - then if this is the only possible one, return it, else - report ambiguity error. */ - tree fields = lookup_fnfields (basetype_path, component, 1); - tree basename = TYPE_NAME (basetype); - if (fields) - { - if (TREE_CHAIN (fields) == NULL_TREE - && TREE_CHAIN (TREE_VALUE (fields)) == NULL_TREE) - { - enum visibility_type visibility; - - /* Unique, so use this one now. */ - basetype = TREE_PURPOSE (fields); - field = TREE_VALUE (fields); - visibility = compute_visibility (TREE_PURPOSE (fields), field); - if (visibility == visibility_public) - { - if (DECL_VIRTUAL_P (field) - && ! resolves_to_fixed_type_p (datum)) - { - tree addr = build_unary_op (ADDR_EXPR, datum, 0); - addr = convert_pointer_to (DECL_VCONTEXT (field), addr); - datum = build_indirect_ref (addr); - assert (datum != error_mark_node); - field = build_vfn_ref (&addr, datum, DECL_VINDEX (field)); - } - return field; - } - if (visibility == visibility_protected) - error_with_decl (field, "member function `%s' is protected"); - else - error_with_decl (field, "member function `%s' is private"); - return error_mark_node; - } - else - return build (COMPONENT_REF, unknown_type_node, datum, fields); - } - if (TREE_CODE (basename) == TYPE_DECL) - basename = DECL_NAME (basename); - - if (OPERATOR_TYPENAME_P (component)) - error ("%s `%s' has no such type conversion operator", - form == RECORD_TYPE ? "structure" : "union", - IDENTIFIER_POINTER (basename)); - else - error (form == RECORD_TYPE - ? "structure `%s' has no member named `%s'" - : "union `%s' has no member named `%s'", - IDENTIFIER_POINTER (basename), - IDENTIFIER_POINTER (component)); - return error_mark_node; - } - else if (TREE_TYPE (field) == error_mark_node) - return error_mark_node; - - if (TREE_CODE (field) == VAR_DECL || TREE_CODE (field) == CONST_DECL) - { - TREE_USED (field) = 1; - return field; - } - - if (DECL_FIELD_CONTEXT (field) != basetype - && (TYPE_USES_MULTIPLE_INHERITANCE (basetype) - || TYPE_USES_VIRTUAL_BASECLASSES (basetype))) - { - tree addr = build_unary_op (ADDR_EXPR, datum, 0); - addr = convert_pointer_to (DECL_FIELD_CONTEXT (field), addr); - datum = build_indirect_ref (addr); - assert (datum != error_mark_node); - } - ref = build (COMPONENT_REF, TREE_TYPE (field), datum, field); - - if (TREE_READONLY (datum) || TREE_READONLY (field)) - TREE_READONLY (ref) = 1; - if (TREE_THIS_VOLATILE (datum) || TREE_VOLATILE (field)) - TREE_THIS_VOLATILE (ref) = 1; - return ref; -} - -/* Given an expression PTR for a pointer, return an expression - for the value pointed to. - ERRORSTRING is the name of the operator to appear in error messages. - - This function may need to overload OPERATOR_FNNAME. - Must also handle REFERENCE_TYPEs for C++. */ - -tree -build_x_indirect_ref (ptr, errorstring) - tree ptr; - char *errorstring; -{ - tree rval = build_opfncall (INDIRECT_REF, LOOKUP_NORMAL, ptr); - - if (rval) return rval; - return build_indirect_ref (ptr, errorstring); -} - -tree -build_indirect_ref (ptr, errorstring) - tree ptr; - char *errorstring; -{ - register tree pointer = default_conversion (ptr); - register tree dt = TREE_TYPE (pointer); - - if (ptr == current_class_decl) - return C_C_D; - - if (TREE_CODE (dt) == POINTER_TYPE || TREE_CODE (dt) == REFERENCE_TYPE) - if (TREE_CODE (pointer) == ADDR_EXPR - && (TREE_TYPE (TREE_OPERAND (pointer, 0)) - == TREE_TYPE (dt))) - return TREE_OPERAND (pointer, 0); - else - { - tree t = TREE_TYPE (dt); - register tree ref = build1 (INDIRECT_REF, - TYPE_MAIN_VARIANT (t), pointer); - - TREE_READONLY (ref) = TREE_READONLY (t); - TREE_VOLATILE (ref) = TREE_VOLATILE (t) || TREE_VOLATILE (pointer); - TREE_THIS_VOLATILE (ref) = TREE_VOLATILE (t); - return ref; - } - else if (pointer != error_mark_node) - error ("invalid type argument of `%s'", errorstring); - return error_mark_node; -} - -/* This handles expressions of the form "a[i]", which denotes - an array reference. - - This is logically equivalent in C to *(a+i), but we may do it differently. - If A is a variable or a member, we generate a primitive ARRAY_REF. - This avoids forcing the array out of registers, and can work on - arrays that are not lvalues (for example, members of structures returned - by functions). - - If INDEX is of some user-defined type, it must be converted to - integer type. Otherwise, to make a compatible PLUS_EXPR, it - will inherit the type of the array, which will be some pointer type. */ - -tree -build_x_array_ref (array, index) - tree array, index; -{ - tree rval; - - rval = build_opfncall (ARRAY_REF, LOOKUP_NORMAL, array, index); - if (rval) - return rval; - return build_array_ref (array, index); -} - -tree -build_array_ref (array, index) - tree array, index; -{ - tree itype; - tree rval; - - if (index == 0) - { - error ("subscript missing in array reference"); - return error_mark_node; - } - - itype = TREE_TYPE (index); - if (TREE_CODE (itype) == REFERENCE_TYPE) - { - index = convert_from_reference (index); - itype = TREE_TYPE (index); - } - - if (IS_AGGR_TYPE (itype)) - if (TYPE_HAS_INT_CONVERSION (itype)) - index = build_type_conversion (CONVERT_EXPR, integer_type_node, index, 1); - else - { - error_with_aggr_type (itype, "type `%s' requires integer conversion for array indexing"); - return error_mark_node; - } - - if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE - && TREE_CODE (array) != INDIRECT_REF) - { - index = default_conversion (index); - if (index != error_mark_node - && TREE_CODE (TREE_TYPE (index)) != INTEGER_TYPE) - { - error ("array subscript is not an integer"); - return error_mark_node; - } - - /* An array that is indexed by a non-constant - cannot be stored in a register; we must be able to do - address arithmetic on its address. - Likewise an array of elements of variable size. */ - if (TREE_CODE (index) != INTEGER_CST - || (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array))) != 0 - && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST)) - { - if (mark_addressable (array) == 0) - return error_mark_node; - } - - if (pedantic && !lvalue_p (array)) - warning ("ANSI C forbids subscripting non-lvalue array"); - - if (pedantic) - { - tree foo = array; - while (TREE_CODE (foo) == COMPONENT_REF) - foo = TREE_OPERAND (foo, 0); - if (TREE_CODE (foo) == VAR_DECL && TREE_REGDECL (foo)) - warning ("ANSI C forbids subscripting non-lvalue array"); - } - - rval = build (ARRAY_REF, TREE_TYPE (TREE_TYPE (array)), array, index); - /* Array ref is const/volatile if the array elements are. */ - TREE_READONLY (rval) |= TREE_READONLY (TREE_TYPE (TREE_TYPE (array))); - TREE_VOLATILE (rval) |= TREE_VOLATILE (TREE_TYPE (TREE_TYPE (array))); - TREE_THIS_VOLATILE (rval) |= TREE_VOLATILE (TREE_TYPE (TREE_TYPE (array))); - return require_complete_type (fold (rval)); - } - - { - tree ar = default_conversion (array); - tree ind = default_conversion (index); - - if ((TREE_CODE (TREE_TYPE (ar)) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (ind)) != INTEGER_TYPE) - || (TREE_CODE (TREE_TYPE (ind)) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (ar)) != INTEGER_TYPE)) - { - error ("array subscript is not an integer"); - return error_mark_node; - } - - return build_indirect_ref (build_binary_op_nodefault (PLUS_EXPR, ar, ind, PLUS_EXPR), - "array indexing"); - } -} - -/* Build a function call to function FUNCTION with parameters PARAMS. - PARAMS is a list--a chain of TREE_LIST nodes--in which the - TREE_VALUE of each node is a parameter-expression. - FUNCTION's data type may be a function type or a pointer-to-function. - - For C++: If FUNCTION's data type is a TREE_LIST, then the tree list - is the list of possible methods that FUNCTION could conceivably - be. If the list of methods comes from a class, then it will be - a list of lists (where each element is associated with the class - that produced it), otherwise it will be a simple list (for - functions overloaded in global scope). - - In the first case, TREE_VALUE (function) is the head of one of those - lists, and TREE_PURPOSE is the name of the function. - - In the second case, TREE_PURPOSE (function) is the function's - name directly. - - DECL is the class instance variable, usually CURRENT_CLASS_DECL. */ - -tree -build_x_function_call (function, params, decl) - tree function, params, decl; -{ - tree type = TREE_TYPE (function); - int may_be_method - = ((TREE_CODE (function) == TREE_LIST - && current_class_type != NULL_TREE - && IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (function)) == function) - || TREE_CODE (function) == IDENTIFIER_NODE - || TREE_CODE (type) == METHOD_TYPE); - - /* Handle methods, friends, and overloaded functions, respectively. */ - if (may_be_method) - { - if (TREE_CODE (function) == FUNCTION_DECL) - function = DECL_ORIGINAL_NAME (function); - else if (TREE_CODE (function) == TREE_LIST) - { -#if 0 - if (TREE_CODE (TREE_VALUE (function)) == TREE_LIST) - function = TREE_PURPOSE (TREE_VALUE (function)); - else - function = TREE_PURPOSE (function); -#else - assert (TREE_CODE (TREE_VALUE (function)) == FUNCTION_DECL); - function = TREE_PURPOSE (function); -#endif - } - else if (TREE_CODE (function) != IDENTIFIER_NODE) - { - /* Call via a pointer to member function. */ - if (decl == NULL_TREE) - { - error ("pointer to member function called, but not in class scope"); - return error_mark_node; - } - function = build (OFFSET_REF, TREE_TYPE (type), NULL_TREE, function); - goto do_x_function; - } - - /* this is an abbreviated method call. - must go through here in case it is a virtual function. - @@ Perhaps this could be optimized. */ - - if (decl == NULL_TREE) - { - if (current_class_type == NULL_TREE) - { - error ("object missing in call to method `%s'", - IDENTIFIER_POINTER (function)); - return error_mark_node; - } - /* Yow: call from a static member function. */ - decl = build1 (NOP_EXPR, TYPE_POINTER_TO (current_class_type), error_mark_node); - } - - return build_method_call (decl, function, params, NULL_TREE, LOOKUP_NORMAL); - } - else if (TREE_CODE (function) == COMPONENT_REF - && type == unknown_type_node) - { - function = TREE_PURPOSE (TREE_OPERAND (function, 1)); - return build_method_call (decl, function, params, NULL_TREE, LOOKUP_NORMAL); - } - else if (TREE_CODE (function) == TREE_LIST) - { - if (TREE_CHAIN (function) != NULL_TREE) - return build_overload_call (TREE_PURPOSE (function), params, 1, 0); - else if (TREE_VALUE (function) != NULL_TREE) - function = TREE_VALUE (function); - else - { - error ("function `%s' declared overloaded, but no definitions appear with which to resolve it", - IDENTIFIER_POINTER (TREE_PURPOSE (function))); - return error_mark_node; - } - } - else if (TREE_CODE (type) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE - && (TREE_CODE (function) == VAR_DECL - || TREE_CODE (function) == PARM_DECL - || TREE_CODE (function) == FIELD_DECL)) - { - error_with_decl (function, "call via pointer-to-member-function `%s' must be composed with object"); - return error_mark_node; - } - - do_x_function: - if (TREE_CODE (function) == OFFSET_REF) - { - /* If the component is a data element (or a virtual function), we play - games here to make things work. */ - tree decl_addr; - - if (TREE_OPERAND (function, 0)) - decl = TREE_OPERAND (function, 0); - else - decl = C_C_D; - - decl_addr = build_unary_op (ADDR_EXPR, decl, 0); - function = get_member_function (&decl_addr, decl, TREE_OPERAND (function, 1)); - params = tree_cons (NULL_TREE, decl_addr, params); - return build_function_call (function, params); - } - - type = TREE_TYPE (function); - if (TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); - - if (TYPE_LANG_SPECIFIC (type) && TYPE_OVERLOADS_CALL_EXPR (type)) - return build_opfncall (CALL_EXPR, LOOKUP_NORMAL, function, params); - - if (may_be_method) - { - tree ctypeptr = TYPE_POINTER_TO (TYPE_METHOD_BASETYPE (TREE_TYPE (function))); - if (decl == NULL_TREE) - { - if (current_function_decl - && DECL_STATIC_FUNCTION_P (current_function_decl)) - error ("invalid call to member function needing `this' in static member function scope"); - else - error ("pointer to member function called, but not in class scope"); - return error_mark_node; - } - if (TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE) - { - decl = build_unary_op (ADDR_EXPR, decl, 0); - decl = convert_pointer_to (TREE_TYPE (ctypeptr), decl); - } - else - decl = build_c_cast (ctypeptr, decl); - params = tree_cons (NULL_TREE, decl, params); - } - - return build_function_call (function, params); -} - -tree -build_function_call (function, params) - tree function, params; -{ - register tree fntype, fndecl; - register tree value_type; - register tree coerced_params; - tree actualparameterlist (); - int is_method; - -#ifdef FIELD_XREF - if (TREE_CODE(function) == FUNCTION_DECL) - FIELD_xref_call(current_function_decl, - IDENTIFIER_POINTER(DECL_NAME(function))); -#endif - - /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. - Strip such NOP_EXPRs, since FUNCTION is used in non-lvalue context. */ - if (TREE_CODE (function) == NOP_EXPR - && TREE_TYPE (function) == TREE_TYPE (TREE_OPERAND (function, 0))) - function = TREE_OPERAND (function, 0); - - if (TREE_CODE (function) == FUNCTION_DECL) - fndecl = function; - else - fndecl = NULL_TREE; - - /* Convert anything with function type to a pointer-to-function. */ - if (TREE_CODE (function) == FUNCTION_DECL) - { - if (pedantic - && IDENTIFIER_LENGTH (DECL_NAME (function)) == 4 - && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (function)), "main")) - { - error ("cannot call `main' from within program"); - return error_mark_node; - } - - /* Differs from default_conversion by not setting TREE_ADDRESSABLE - (because calling an inline function does not mean the function - needs to be separately compiled). */ - - if (! TREE_INLINE (function)) - TREE_USED (function) = 1; - - function = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (function)), - function); - } - else - { - if (function == error_mark_node) - return error_mark_node; - function = default_conversion (function); - } - - fntype = TREE_TYPE (function); - - is_method = (TREE_CODE (fntype) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (fntype)) == METHOD_TYPE); - - if (!(TREE_CODE (fntype) == POINTER_TYPE - && (TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE || is_method))) - { - error ("called object is not a function"); - return error_mark_node; - } - - /* fntype now gets the type of function pointed to. */ - fntype = TREE_TYPE (fntype); - - /* Convert the parameters to the types declared in the - function prototype, or apply default promotions. */ - - coerced_params = actualparameterlist (NULL_TREE, TYPE_ARG_TYPES (fntype), params, fndecl, LOOKUP_NORMAL); - - /* Recognize certain built-in functions so we can make tree-codes - other than CALL_EXPR. We do this when it enables fold-const.c - to do something useful. */ - - if (TREE_CODE (function) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL) - switch (DECL_FUNCTION_CODE (TREE_OPERAND (function, 0))) - { - case BUILT_IN_ABS: - case BUILT_IN_LABS: - case BUILT_IN_FABS: - if (coerced_params == 0) - return integer_zero_node; - return build_unary_op (ABS_EXPR, TREE_VALUE (coerced_params), 0); - } - - value_type = TREE_TYPE (fntype) ? TREE_TYPE (fntype) : void_type_node; - - if (is_method) - { - tree parm = TREE_VALUE (coerced_params); - tree parmtype = TREE_TYPE (parm); - if (parmtype == error_mark_node) - return error_mark_node; - - parmtype = TREE_TYPE (parmtype); - if (TYPE_NEEDS_WRAPPER (parmtype)) - { - if (fndecl == NULL_TREE || ! WRAPPER_NAME_P (DECL_NAME (fndecl))) - { - int bytecount = get_arglist_len_in_bytes (coerced_params); - - params = tree_cons (NULL_TREE, build_int_2 (bytecount, 0), - tree_cons (NULL_TREE, function, TREE_CHAIN (coerced_params))); - - return build_method_call (TREE_VALUE (coerced_params), - wrapper_name, params, - NULL_TREE, LOOKUP_NORMAL); - } - } - } - { - register tree result = - build (CALL_EXPR, value_type, function, coerced_params, NULL_TREE); - - TREE_VOLATILE (result) = 1; - TREE_RAISES (result) |= !! TYPE_RAISES_EXCEPTIONS (fntype); - if (value_type == void_type_node) - return result; - return require_complete_type (result); - } -} - -/* Convert the actual parameter expressions in the list VALUES - to the types in the list TYPELIST. - If parmdecls is exhausted, or when an element has NULL as its type, - perform the default conversions. - - RETURN_LOC is the location of the return value, if known, NULL_TREE - otherwise. This is useful in the case where we can avoid creating - a temporary variable in the case where we can initialize the return - value directly. If we are not eliding constructors, then we set this - to NULL_TREE to avoid this avoidance. - - NAME is an IDENTIFIER_NODE or 0. It is used only for error messages. - - This is also where warnings about wrong number of args are generated. - - Return a list of expressions for the parameters as converted. - - Both VALUES and the returned value are chains of TREE_LIST nodes - with the elements of the list in the TREE_VALUE slots of those nodes. - - In C++, unspecified trailing parameters can be filled in with their - default arguments, if such were specified. Do so here. */ - -tree -actualparameterlist (return_loc, typelist, values, fndecl, flags) - tree return_loc, typelist, values, fndecl; - int flags; -{ - register tree typetail, valtail; - register tree result = NULL_TREE; - char *called_thing; - int maybe_raises = 0; - - if (! flag_elide_constructors) - return_loc = 0; - - if (fndecl) - if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE) - if (TREE_TYPE (DECL_ORIGINAL_NAME (fndecl))) - called_thing = "constructor"; - else - called_thing = "member function"; - else - called_thing = "function"; - - for (valtail = values, typetail = typelist; - valtail; - valtail = TREE_CHAIN (valtail)) - { - register tree type = typetail ? TREE_VALUE (typetail) : 0; - register tree val = TREE_VALUE (valtail); - register tree parm; - - if (type == void_type_node) - { - if (fndecl) - { - char *buf = (char *)alloca (80); - sprintf (buf, "too many arguments to %s `%%s'", called_thing); - error_with_decl (fndecl, buf); - error ("at this point in file"); - } - else - error ("too many arguments to function"); - /* In case anybody wants to know if this argument - list is valid. */ - if (result) - TREE_TYPE (result) = error_mark_node; - break; - } - - /* The tree type of the parameter being passed may not yet be - known. In this case, its type is TYPE_UNKNOWN, and will - be instantiated by the type given by TYPE. If TYPE - is also NULL, the tree type of VAL is ERROR_MARK_NODE. */ - if (type && type_unknown_p (val)) - val = require_instantiated_type (type, val, integer_zero_node); - else if (type_unknown_p (val)) - { - - if (TREE_CODE (val) == TREE_LIST - && TREE_CHAIN (val) == NULL_TREE - && (TREE_TYPE (val) == unknown_type_node - || TREE_CHAIN (TREE_VALUE (val)) == NULL_TREE)) - /* Instantiates automatically. */ - val = TREE_VALUE (val); - else - { - error ("insufficient type information in parameter list"); - val = integer_zero_node; - } - } - - { - /* Convert FUNCTION_DECLs for virtual functions - to proper representation. */ - tree basetype = NULL_TREE; - tree ttype = TREE_TYPE (val); - - if (TREE_CODE (ttype) == METHOD_TYPE) - basetype = TYPE_METHOD_BASETYPE (ttype); - else if (TREE_CODE (ttype) == OFFSET_TYPE) - basetype = TYPE_OFFSET_BASETYPE (ttype); - - /* If BASETYPE is set here, default_conversion will do the - actual conversion for us. */ - if (basetype && TREE_CODE (val) != OFFSET_REF) - { - val = build (OFFSET_REF, ttype, - build1 (NOP_EXPR, basetype, error_mark_node), val); - type = build_pointer_type (ttype); - } - else if (TREE_CODE (ttype) == FUNCTION_TYPE) - type = build_pointer_type (ttype); - } - - /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. - Strip such NOP_EXPRs, since VAL is used in non-lvalue context. */ - if (TREE_CODE (val) == NOP_EXPR - && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0))) - val = TREE_OPERAND (val, 0); - - if ((type == 0 || TREE_CODE (type) != REFERENCE_TYPE) - && (TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE (val)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (val)) == METHOD_TYPE)) - val = default_conversion (val); - - val = require_complete_type (val); - - maybe_raises |= TREE_RAISES (val); - - if (type != 0) - { - /* Formal parm type is specified by a function prototype. */ - tree parmval; - - if (TYPE_SIZE (type) == 0) - { - error ("parameter type of called function is incomplete"); - parmval = val; - } - else - { -#ifdef PROMOTE_PROTOTYPES - /* Rather than truncating and then reextending, - convert directly to int, if that's the type we will want. */ - if (! flag_traditional - && TREE_CODE (type) == INTEGER_TYPE - && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))) - type = integer_type_node; -#endif - parmval = convert_for_initialization (return_loc, type, val, - "argument passing", flags); -#ifdef PROMOTE_PROTOTYPES - if (TREE_CODE (type) == INTEGER_TYPE - && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))) - parmval = default_conversion (parmval); -#endif - } - parm = build_tree_list (0, parmval); - } - else - { - if (TREE_CODE (TREE_TYPE (val)) == REFERENCE_TYPE) - val = convert_from_reference (val); - - if (TREE_CODE (TREE_TYPE (val)) == REAL_TYPE - && (TYPE_PRECISION (TREE_TYPE (val)) - < TYPE_PRECISION (double_type_node))) - /* Convert `float' to `double'. */ - parm = build_tree_list (NULL_TREE, convert (double_type_node, val)); - else if (TYPE_LANG_SPECIFIC (TREE_TYPE (val)) - && (TYPE_GETS_INIT_REF (TREE_TYPE (val)) - || TYPE_GETS_ASSIGN_REF (TREE_TYPE (val)))) - { - if (pedantic) - error_with_aggr_type (TREE_TYPE (val), "cannot pass objects of type `%s' through `...'"); - else - warning ("cannot pass objects of type `%s' through `...'", - TYPE_NAME_STRING (TREE_TYPE (val))); - parm = build_tree_list (NULL_TREE, val); - } - else - /* Convert `short' and `char' to full-size `int'. */ - parm = build_tree_list (NULL_TREE, default_conversion (val)); - } - - result = chainon (result, parm); - if (typetail) - typetail = TREE_CHAIN (typetail); - } - - if (typetail != 0 && typetail != void_list_node) - { - /* See if there are default arguments that can be used */ - if (TREE_PURPOSE (typetail)) - { - while (typetail != void_list_node) - { - tree type = TREE_VALUE (typetail); - tree val = TREE_PURPOSE (typetail); - tree parm, parmval; - - if (val == NULL_TREE) - parmval = error_mark_node; - else if (TREE_CODE (val) == CONSTRUCTOR) - { - parmval = digest_init (type, val, NULL_TREE); - parmval = convert_for_initialization (return_loc, type, parmval, "default constructor", flags); - } - else - { - parmval = convert_for_initialization (return_loc, type, val, - "default argument", flags); -#ifdef PROMOTE_PROTOTYPES - if (TREE_CODE (type) == INTEGER_TYPE - && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))) - parmval = default_conversion (parmval); -#endif - } - maybe_raises |= TREE_RAISES (parmval); - parm = build_tree_list (0, parmval); - result = chainon (result, parm); - typetail = TREE_CHAIN (typetail); - /* ends with `...'. */ - if (typetail == NULL_TREE) - break; - } - } - else - { - if (fndecl) - { - char *buf = (char *)alloca (32 + strlen (called_thing)); - sprintf (buf, "too few arguments to %s `%%s'", called_thing); - error_with_decl (fndecl, buf); - error ("at this point in file"); - } - else - error ("too few arguments to function"); - return error_mark_list; - } - } - if (result) - TREE_RAISES (result) = maybe_raises; - - return result; -} - -/* Build a binary-operation expression, after performing default - conversions on the operands. CODE is the kind of expression to build. */ - -tree -build_x_binary_op (code, arg1, arg2) - enum tree_code code; - tree arg1, arg2; -{ - tree rval; - - if (rval = build_opfncall (code, LOOKUP_PROTECT, arg1, arg2)) - return rval; - rval = build_binary_op (code, arg1, arg2); - if (rval == error_mark_node) - build_opfncall (code, LOOKUP_NORMAL, arg1, arg2); - return rval; -} - -tree -build_binary_op (code, arg1, arg2) - enum tree_code code; - tree arg1, arg2; -{ - tree type1, type2; - tree args[2]; - arg1 = default_conversion (arg1); - arg2 = default_conversion (arg2); - - if (type_unknown_p (arg1)) - { - arg1 = instantiate_type (TREE_TYPE (arg2), arg1, 1); - arg1 = default_conversion (arg1); - } - else - { - arg2 = require_instantiated_type (TREE_TYPE (arg1), arg2, error_mark_node); - arg2 = default_conversion (arg2); - } - - type1 = TREE_TYPE (arg1); - type2 = TREE_TYPE (arg2); - - args[0] = arg1; - args[1] = arg2; - - if (IS_AGGR_TYPE (type1) && IS_AGGR_TYPE (type2)) - { - /* Try to convert this to something reasonable. */ - if (! build_default_binary_type_conversion (code, &args[0], &args[1])) - return error_mark_node; - } - else if (IS_AGGR_TYPE (type1) || IS_AGGR_TYPE (type2)) - { - int convert_index = IS_AGGR_TYPE (type2); - /* Avoid being tripped up by things like (ARG1 != 0). */ - tree types[2], try; - - types[0] = type1; types[1] = type2; - try = build_type_conversion (code, types[convert_index ^ 1], - args[convert_index], 1); - - if (try == 0 - && arg2 == integer_zero_node - && (code == NE_EXPR || code == EQ_EXPR)) - try = build_type_conversion (code, ptr_type_node, - args[convert_index], 1); - if (try == 0) - { - error_with_aggr_type (types[convert_index], "type conversion required for type `%s'"); - return error_mark_node; - } - if (try == error_mark_node) - error ("ambiguous pointer conversion"); - args[convert_index] = try; - } - - return build_binary_op_nodefault (code, args[0], args[1], code); -} - -/* Build a binary-operation expression without default conversions. - CODE is the kind of expression to build. - This function differs from `build' in several ways: - the data type of the result is computed and recorded in it, - warnings are generated if arg data types are invalid, - special handling for addition and subtraction of pointers is known, - and some optimization is done (operations on narrow ints - are done in the narrower type when that gives the same result). - Constant folding is also done before the result is returned. - - ERROR_CODE is the code that determines what to say in error messages. - It is usually, but not always, the same as CODE. - - Note that the operands will never have enumeral types - because either they have just had the default conversions performed - or they have both just been converted to some other type in which - the arithmetic is to be done. - - C++: must do special pointer arithmetic when implementing - multiple inheritance. */ - -tree -build_binary_op_nodefault (code, op0, op1, error_code) - enum tree_code code; - tree op0, op1; - enum tree_code error_code; -{ - tree dt0 = datatype (op0), dt1 = datatype (op1); - - /* The expression codes of the data types of the arguments tell us - whether the arguments are integers, floating, pointers, etc. */ - register enum tree_code code0 = TREE_CODE (dt0); - register enum tree_code code1 = TREE_CODE (dt1); - - /* Expression code to give to the expression when it is built. - Normally this is CODE, which is what the caller asked for, - but in some special cases we change it. */ - register enum tree_code resultcode = code; - - /* Data type in which the computation is to be performed. - In the simplest cases this is the common type of the arguments. */ - register tree result_type = NULL; - - /* Nonzero means operands have already been type-converted - in whatever way is necessary. - Zero means they need to be converted to RESULT_TYPE. */ - int converted = 0; - - /* Nonzero means after finally constructing the expression - give it this type. Otherwise, give it type RESULT_TYPE. */ - tree final_type = 0; - - /* Nonzero if this is an operation like MIN or MAX which can - safely be computed in short if both args are promoted shorts. - Also implies COMMON. - -1 indicates a bitwise operation; this makes a difference - in the exact conditions for when it is safe to do the operation - in a narrower mode. */ - int shorten = 0; - - /* Nonzero if this is a comparison operation; - if both args are promoted shorts, compare the original shorts. - Also implies COMMON. */ - int short_compare = 0; - - /* Nonzero if this is a right-shift operation, which can be computed on the - original short and then promoted if the operand is a promoted short. */ - int short_shift = 0; - - /* Nonzero means set RESULT_TYPE to the common type of the args. */ - int common = 0; - - /* If an error was already reported for one of the arguments, - avoid reporting another error. */ - - if (code0 == ERROR_MARK || code1 == ERROR_MARK) - return error_mark_node; - - switch (code) - { - case PLUS_EXPR: - /* Handle the pointer + int case. */ - if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) - return pointer_int_sum (PLUS_EXPR, op0, op1); - else if (code1 == POINTER_TYPE && code0 == INTEGER_TYPE) - return pointer_int_sum (PLUS_EXPR, op1, op0); - else - common = 1; - break; - - case MINUS_EXPR: - /* Subtraction of two similar pointers. - We must subtract them as integers, then divide by object size. */ - if (code0 == POINTER_TYPE && code1 == POINTER_TYPE - && comp_target_types (dt0, dt1, 1)) - return pointer_diff (op0, op1); - /* Handle pointer minus int. Just like pointer plus int. */ - else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) - return pointer_int_sum (MINUS_EXPR, op0, op1); - else - common = 1; - break; - - case MULT_EXPR: - common = 1; - break; - - case TRUNC_DIV_EXPR: - case CEIL_DIV_EXPR: - case FLOOR_DIV_EXPR: - case ROUND_DIV_EXPR: - case EXACT_DIV_EXPR: - if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE) - && (code1 == INTEGER_TYPE || code1 == REAL_TYPE)) - { - if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)) - resultcode = RDIV_EXPR; - else - shorten = 1; - common = 1; - } - break; - - case BIT_AND_EXPR: - case BIT_ANDTC_EXPR: - case BIT_IOR_EXPR: - case BIT_XOR_EXPR: - if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) - shorten = -1; - /* If one operand is a constant, and the other is a short type - that has been converted to an int, - really do the work in the short type and then convert the - result to int. If we are lucky, the constant will be 0 or 1 - in the short type, making the entire operation go away. */ - if (TREE_CODE (op0) == INTEGER_CST - && TREE_CODE (op1) == NOP_EXPR - && TYPE_PRECISION (dt1) > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op1, 0))) - && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op1, 0)))) - { - final_type = result_type; - op1 = TREE_OPERAND (op1, 0); - result_type = TREE_TYPE (op1); - } - if (TREE_CODE (op1) == INTEGER_CST - && TREE_CODE (op0) == NOP_EXPR - && TYPE_PRECISION (dt0) > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0))) - && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0)))) - { - final_type = result_type; - op0 = TREE_OPERAND (op0, 0); - result_type = TREE_TYPE (op0); - } - break; - - case TRUNC_MOD_EXPR: - if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) - shorten = 1; - break; - - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - case TRUTH_AND_EXPR: - case TRUTH_OR_EXPR: - if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE || code0 == REAL_TYPE) - && (code1 == INTEGER_TYPE || code1 == POINTER_TYPE || code1 == REAL_TYPE)) - { - /* Result of these operations is always an int, - but that does not mean the operands should be - converted to ints! */ - result_type = integer_type_node; - op0 = truthvalue_conversion (op0); - op1 = truthvalue_conversion (op1); - converted = 1; - - /* If these two expressions perform the same operation - on what are (or could be given alignment constraints) parts of - the same word, try chaining the operations. */ - if (optimize) - { - tree rval; - - if (TREE_CODE (op0) == TREE_CODE (op1)) - { - /* Do they look like (x.p == y.p && x.q == y.q) - or (x.p != y.p || x.q != y.q). */ - if (((code == TRUTH_ANDIF_EXPR && TREE_CODE (op0) == EQ_EXPR) - || (code == TRUTH_ORIF_EXPR && TREE_CODE (op0) == NE_EXPR)) - && (rval = merge_component_comparisons (code, op0, op1))) - return rval; - } - if (TREE_CODE (op0) == code - && TREE_CODE (TREE_OPERAND (op0, 1)) == TREE_CODE (op1)) - /* Associate the operation. */ - { - /* Now try to simplify right-hand term. */ - if (((code == TRUTH_ANDIF_EXPR && TREE_CODE (op1) == EQ_EXPR) - || (code == TRUTH_ORIF_EXPR && TREE_CODE (op1) == NE_EXPR)) - && (rval = merge_component_comparisons (code, TREE_OPERAND (op0, 1), op1))) - { - TREE_OPERAND (op0, 1) = rval; - return op0; - } - } - } - } - break; - - /* Shift operations: result has same type as first operand; - always convert second operand to int. - Also set SHORT_SHIFT if shifting rightward. */ - - case RSHIFT_EXPR: - if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) - { - result_type = dt0; - if (TREE_CODE (op1) == INTEGER_CST - && TREE_INT_CST_LOW (op1) > 0) - short_shift = 1; - /* Convert the shift-count to an integer, regardless of - size of value being shifted. */ - if (TREE_TYPE (op1) != integer_type_node) - op1 = convert (integer_type_node, op1); - } - break; - - case LSHIFT_EXPR: - if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) - { - result_type = dt0; - if (TREE_CODE (op1) == INTEGER_CST - && TREE_INT_CST_LOW (op1) < 0) - short_shift = 1; - /* Convert the shift-count to an integer, regardless of - size of value being shifted. */ - if (TREE_TYPE (op1) != integer_type_node) - op1 = convert (integer_type_node, op1); - } - break; - - case RROTATE_EXPR: - case LROTATE_EXPR: - if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE) - { - result_type = dt0; - /* Convert the shift-count to an integer, regardless of - size of value being shifted. */ - if (TREE_TYPE (op1) != integer_type_node) - op1 = convert (integer_type_node, op1); - } - break; - - case EQ_EXPR: - case NE_EXPR: - /* Result of comparison is always int, - but don't convert the args to int! */ - result_type = integer_type_node; - converted = 1; - if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE) - && (code1 == INTEGER_TYPE || code1 == REAL_TYPE)) - short_compare = 1; - else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE) - { - register tree tt0 = TYPE_MAIN_VARIANT (TREE_TYPE (dt0)); - register tree tt1 = TYPE_MAIN_VARIANT (TREE_TYPE (dt1)); - /* Anything compares with void *. void * compares with anything. - Otherwise, the targets must be the same. */ - if (tt0 != tt1 && IS_AGGR_TYPE (tt0) && IS_AGGR_TYPE (tt1)) - { - tree base = common_base_type (tt0, tt1); - if (base == NULL_TREE) - warning ("comparison of distinct object pointer types"); - else if (base == error_mark_node) - { - message_2_types (error, "comparison of pointer types `%s*' and `%s*' requires conversion to ambiguous supertype", tt0, tt1); - return error_mark_node; - } - op0 = convert (TYPE_POINTER_TO (base), op0); - op1 = convert (TYPE_POINTER_TO (base), op1); - } - else if (comp_target_types (dt0, dt1, 1)) - ; - else if (tt0 == void_type_node) - { - if (pedantic && TREE_CODE (tt1) == FUNCTION_TYPE) - warning ("ANSI C forbids comparison of `void *' with function pointer"); - } - else if (tt1 == void_type_node) - { - if (pedantic && TREE_CODE (tt0) == FUNCTION_TYPE) - warning ("ANSI C forbids comparison of `void *' with function pointer"); - } - else - warning ("comparison of distinct pointer types lacks a cast"); - } - else if (code0 == POINTER_TYPE && TREE_CODE (op1) == INTEGER_CST - && integer_zerop (op1)) - op1 = null_pointer_node; - else if (code1 == POINTER_TYPE && TREE_CODE (op0) == INTEGER_CST - && integer_zerop (op0)) - op0 = null_pointer_node; - else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) - { - error ("comparison between pointer and integer"); - op1 = convert (TREE_TYPE (op0), op1); - } - else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE) - { - error ("comparison between pointer and integer"); - op0 = convert (TREE_TYPE (op1), op0); - } - else - /* If args are not valid, clear out RESULT_TYPE - to cause an error message later. */ - result_type = 0; - break; - - case MAX_EXPR: - case MIN_EXPR: - if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE) - && (code1 == INTEGER_TYPE || code1 == REAL_TYPE)) - shorten = 1; - else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE) - { - if (! comp_target_types (dt0, dt1, 1)) - warning ("comparison of distinct pointer types lacks a cast"); - else if (pedantic - && TREE_CODE (TREE_TYPE (dt0)) == FUNCTION_TYPE) - warning ("ANSI C forbids ordered comparisons of pointers to functions"); - result_type = commontype (dt0, dt1); - } - break; - - case LE_EXPR: - case GE_EXPR: - case LT_EXPR: - case GT_EXPR: - if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE) - && (code1 == INTEGER_TYPE || code1 == REAL_TYPE)) - short_compare = 1; - else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE) - { - if (! comp_target_types (dt0, dt1, 1)) - warning ("comparison of distinct pointer types lacks a cast"); - else if (pedantic - && TREE_CODE (TREE_TYPE (dt0)) == FUNCTION_TYPE) - warning ("ANSI C forbids ordered comparisons of pointers to functions"); - result_type = integer_type_node; - } - else if (code0 == POINTER_TYPE && TREE_CODE (op1) == INTEGER_CST - && integer_zerop (op1)) - { - result_type = integer_type_node; - op1 = null_pointer_node; - if (! flag_traditional) - warning ("ordered comparison of pointer with integer zero"); - } - else if (code1 == POINTER_TYPE && TREE_CODE (op0) == INTEGER_CST - && integer_zerop (op0)) - { - result_type = integer_type_node; - op0 = null_pointer_node; - if (pedantic) - warning ("ordered comparison of pointer with integer zero"); - } - else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) - { - result_type = integer_type_node; - if (! flag_traditional) - warning ("comparison between pointer and integer"); - op1 = convert (TREE_TYPE (op0), op1); - } - else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE) - { - result_type = integer_type_node; - if (! flag_traditional) - warning ("comparison between pointer and integer"); - op0 = convert (TREE_TYPE (op1), op0); - } - converted = 1; - break; - } - - if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE) - && (code1 == INTEGER_TYPE || code1 == REAL_TYPE)) - { - if (shorten || common || short_compare) - result_type = commontype (dt0, dt1); - - /* For certain operations (which identify themselves by shorten != 0) - if both args were extended from the same smaller type, - do the arithmetic in that type and then extend. - - shorten !=0 and !=1 indicates a bitwise operation. - For them, this optimization is safe only if - both args are zero-extended or both are sign-extended. - Otherwise, we might change the result. - Eg, (short)-1 | (unsigned short)-1 is (int)-1 - but calculated in (unsigned short) it would be (unsigned short)-1. */ - - if (shorten) - { - int unsigned0, unsigned1; - tree arg0 = get_narrower (op0, &unsigned0); - tree arg1 = get_narrower (op1, &unsigned1); - /* UNS is 1 if the operation to be done is an unsigned one. */ - int uns = TREE_UNSIGNED (result_type); - tree type; - - final_type = result_type; - - /* Handle the case that OP0 does not *contain* a conversion - but it *requires* conversion to FINAL_TYPE. */ - - if (op0 == arg0 && TREE_TYPE (op0) != final_type) - unsigned0 = TREE_UNSIGNED (TREE_TYPE (op0)); - if (op1 == arg1 && TREE_TYPE (op1) != final_type) - unsigned1 = TREE_UNSIGNED (TREE_TYPE (op1)); - - /* Now UNSIGNED0 is 1 if ARG0 zero-extends to FINAL_TYPE. */ - - /* For bitwise operations, signedness of nominal type - does not matter. Consider only how operands were extended. */ - if (shorten == -1) - uns = unsigned0; - - /* Note that in all three cases below we refrain from optimizing - an unsigned operation on sign-extended args. - That would not be valid. */ - - /* Both args variable: if both extended in same way - from same width, do it in that width. - Do it unsigned if args were zero-extended. */ - if ((TYPE_PRECISION (TREE_TYPE (arg0)) - < TYPE_PRECISION (result_type)) - && (TYPE_PRECISION (TREE_TYPE (arg1)) - == TYPE_PRECISION (TREE_TYPE (arg0))) - && unsigned0 == unsigned1 - && (unsigned0 || !uns)) - result_type - = signed_or_unsigned_type (unsigned0, - commontype (TREE_TYPE (arg0), TREE_TYPE (arg1))); - else if (TREE_CODE (arg0) == INTEGER_CST - && (unsigned1 || !uns) - && (TYPE_PRECISION (TREE_TYPE (arg1)) - < TYPE_PRECISION (result_type)) - && (type = signed_or_unsigned_type (unsigned1, - TREE_TYPE (arg1)), - int_fits_type_p (arg0, type))) - result_type = type; - else if (TREE_CODE (arg1) == INTEGER_CST - && (unsigned0 || !uns) - && (TYPE_PRECISION (TREE_TYPE (arg0)) - < TYPE_PRECISION (result_type)) - && (type = signed_or_unsigned_type (unsigned0, - TREE_TYPE (arg0)), - int_fits_type_p (arg1, type))) - result_type = type; - } - - /* Shifts can be shortened if shifting right. */ - - if (short_shift) - { - int unsigned_arg; - tree arg0 = get_narrower (op0, &unsigned_arg); - - final_type = result_type; - - if (arg0 == op0 && final_type == TREE_TYPE (op0)) - unsigned_arg = TREE_UNSIGNED (TREE_TYPE (op0)); - - if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type) - /* If arg is sign-extended and then unsigned-shifted, - we can simulate this with a signed shift in arg's type - only if the extended result is at least twice as wide - as the arg. Otherwise, the shift could use up all the - ones made by sign-extension and bring in zeros. - We can't optimize that case at all, but in most machines - it never happens because available widths are 2**N. */ - && (!TREE_UNSIGNED (final_type) - || unsigned_arg - || 2 * TYPE_PRECISION (TREE_TYPE (arg0)) <= TYPE_PRECISION (result_type))) - { - /* Do an unsigned shift if the operand was zero-extended. */ - result_type - = signed_or_unsigned_type (unsigned_arg, - TREE_TYPE (arg0)); - /* Convert value-to-be-shifted to that type. */ - if (TREE_TYPE (op0) != result_type) - op0 = convert (result_type, op0); - converted = 1; - } - } - - /* Comparison operations are shortened too but differently. - They identify themselves by setting short_compare = 1. */ - - if (short_compare) - { - /* Don't write &op0, etc., because that would prevent op0 - from being kept in a register. - Instead, make copies of the our local variables and - pass the copies by reference, then copy them back afterward. */ - tree xop0 = op0, xop1 = op1, xresult_type = result_type; - enum tree_code xresultcode = resultcode; - tree val - = shorten_compare (&xop0, &xop1, &xresult_type, &xresultcode); - if (val != 0) - return val; - op0 = xop0, op1 = xop1, result_type = xresult_type; - resultcode = xresultcode; - } - } - - /* At this point, RESULT_TYPE must be nonzero to avoid an error message. - If CONVERTED is zero, both args will be converted to type RESULT_TYPE. - Then the expression will be built. - It will be given type FINAL_TYPE if that is nonzero; - otherwise, it will be given type RESULT_TYPE. */ - - if (!result_type) - { - binary_op_error (error_code); - return error_mark_node; - } - - if (! converted) - { - if (TREE_TYPE (op0) != result_type) - op0 = convert (result_type, op0); - if (TREE_TYPE (op1) != result_type) - op1 = convert (result_type, op1); - } - - { - register tree result = build (resultcode, result_type, op0, op1); - register tree folded; - - folded = fold (result); - if (folded == result) - TREE_LITERAL (folded) = TREE_LITERAL (op0) & TREE_LITERAL (op1); - if (final_type != 0) - return convert (final_type, folded); - return folded; - } -} - -/* Return a tree for the sum or difference (RESULTCODE says which) - of pointer PTROP and integer INTOP. */ - -static tree -pointer_int_sum (resultcode, ptrop, intop) - enum tree_code resultcode; - register tree ptrop, intop; -{ - tree size_exp; - - register tree result; - register tree folded = fold (intop); - - /* The result is a pointer of the same type that is being added. */ - - register tree result_type = datatype (ptrop); - - /* Needed to make OOPS V2R3 work. */ - intop = folded; - if (TREE_CODE (intop) == INTEGER_CST - && TREE_INT_CST_LOW (intop) == 0 - && TREE_INT_CST_HIGH (intop) == 0) - return ptrop; - - if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE) - { - if (pedantic || warn_pointer_arith) - warning ("pointer of type `void *' used in arithmetic"); - size_exp = integer_one_node; - } - else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE) - { - if (pedantic || warn_pointer_arith) - warning ("pointer to a function used in arithmetic"); - size_exp = integer_one_node; - } - else if (TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE) - { - if (pedantic) - warning ("pointer to a method used in arithmetic"); - size_exp = integer_one_node; - } - else if (TREE_CODE (TREE_TYPE (result_type)) == OFFSET_TYPE) - { - if (pedantic) - warning ("pointer to a member used in arithmetic"); - size_exp = integer_one_node; - } - else - size_exp = size_in_bytes (TREE_TYPE (result_type)); - - /* If what we are about to multiply by the size of the elements - contains a constant term, apply distributive law - and multiply that constant term separately. - This helps produce common subexpressions. */ - - if ((TREE_CODE (intop) == PLUS_EXPR || TREE_CODE (intop) == MINUS_EXPR) - && ! TREE_LITERAL (intop) - && TREE_LITERAL (TREE_OPERAND (intop, 1)) - && TREE_LITERAL (size_exp)) - { - enum tree_code subcode = resultcode; - if (TREE_CODE (intop) == MINUS_EXPR) - subcode = (subcode == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR); - ptrop = build_binary_op (subcode, ptrop, TREE_OPERAND (intop, 1)); - intop = TREE_OPERAND (intop, 0); - } - - /* Convert the integer argument to a type the same size as a pointer - so the multiply won't overflow spuriously. */ - - if (TYPE_PRECISION (TREE_TYPE (intop)) != POINTER_SIZE) - intop = convert (type_for_size (POINTER_SIZE, 0), intop); - - /* Replace the integer argument - with a suitable product by the object size. */ - - intop = build_binary_op (MULT_EXPR, intop, size_exp); - - /* Create the sum or difference. */ - - result = build (resultcode, result_type, ptrop, intop); - - folded = fold (result); - if (folded == result) - TREE_LITERAL (folded) = TREE_LITERAL (ptrop) & TREE_LITERAL (intop); - return folded; -} - -/* Return a tree for the difference of pointers OP0 and OP1. - The resulting tree has type int. */ - -static tree -pointer_diff (op0, op1) - register tree op0, op1; -{ - tree dt0 = datatype (op0); - register tree result, folded; - tree restype = type_for_size (POINTER_SIZE, 0); - - if (pedantic) - { - if (TREE_CODE (TREE_TYPE (dt0)) == VOID_TYPE) - warning ("pointer of type `void *' used in subtraction"); - if (TREE_CODE (TREE_TYPE (dt0)) == FUNCTION_TYPE) - warning ("pointer to a function used in subtraction"); - if (TREE_CODE (TREE_TYPE (dt0)) == METHOD_TYPE) - warning ("pointer to a method used in subtraction"); - if (TREE_CODE (TREE_TYPE (dt0)) == OFFSET_TYPE) - warning ("pointer to a member used in subtraction"); - } - - /* First do the subtraction as integers; - then drop through to build the divide operator. */ - - op0 = build_binary_op (MINUS_EXPR, - convert (restype, op0), convert (restype, op1)); - op1 = ((TREE_CODE (TREE_TYPE (dt0)) == VOID_TYPE - || TREE_CODE (TREE_TYPE (dt0)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (dt0)) == METHOD_TYPE - || TREE_CODE (TREE_TYPE (dt0)) == OFFSET_TYPE) - ? integer_one_node - : size_in_bytes (TREE_TYPE (dt0))); - - /* Create the sum or difference. */ - - result = build (EXACT_DIV_EXPR, restype, op0, op1); - - folded = fold (result); - if (folded == result) - TREE_LITERAL (folded) = TREE_LITERAL (op0) & TREE_LITERAL (op1); - return folded; -} - -/* Print an error message for invalid operands to arith operation CODE. - NOP_EXPR is used as a special case (see truthvalue_conversion). */ - -static void -binary_op_error (code) - enum tree_code code; -{ - register char *opname; - switch (code) - { - case NOP_EXPR: - error ("invalid truth-value expression"); - return; - - case PLUS_EXPR: - opname = "+"; break; - case MINUS_EXPR: - opname = "-"; break; - case MULT_EXPR: - opname = "*"; break; - case MAX_EXPR: - opname = "max"; break; - case MIN_EXPR: - opname = "min"; break; - case EQ_EXPR: - opname = "=="; break; - case NE_EXPR: - opname = "!="; break; - case LE_EXPR: - opname = "<="; break; - case GE_EXPR: - opname = ">="; break; - case LT_EXPR: - opname = "<"; break; - case GT_EXPR: - opname = ">"; break; - case LSHIFT_EXPR: - opname = "<<"; break; - case RSHIFT_EXPR: - opname = ">>"; break; - case TRUNC_MOD_EXPR: - opname = "%"; break; - case TRUNC_DIV_EXPR: - opname = "/"; break; - case BIT_AND_EXPR: - opname = "&"; break; - case BIT_IOR_EXPR: - opname = "|"; break; - case TRUTH_ANDIF_EXPR: - opname = "&&"; break; - case TRUTH_ORIF_EXPR: - opname = "||"; break; - case BIT_XOR_EXPR: - opname = "^"; break; - } - error ("invalid operands to binary %s", opname); -} - -/* Subroutine of build_binary_op_nodefault, used for comparison operations. - See if the operands have both been converted from subword integer types - and, if so, perhaps change them both back to their original type. - - The arguments of this function are all pointers to local variables - of build_binary_op_nodefault: OP0_PTR is &OP0, OP1_PTR is &OP1, - RESTYPE_PTR is &RESULT_TYPE and RESCODE_PTR is &RESULTCODE. - - If this function returns nonzero, it means that the comparison has - a constant value. What this function returns is an expression for - that value. */ - -static tree -shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr) - tree *op0_ptr, *op1_ptr; - tree *restype_ptr; - enum tree_code *rescode_ptr; -{ - register tree type; - tree op0 = *op0_ptr; - tree op1 = *op1_ptr; - int unsignedp0, unsignedp1; - int real1, real2; - tree primop0, primop1; - enum tree_code code = *rescode_ptr; - - /* Throw away any conversions to wider types - already present in the operands. */ - - primop0 = get_narrower (op0, &unsignedp0); - primop1 = get_narrower (op1, &unsignedp1); - - /* Handle the case that OP0 does not *contain* a conversion - but it *requires* conversion to FINAL_TYPE. */ - - if (op0 == primop0 && TREE_TYPE (op0) != *restype_ptr) - unsignedp0 = TREE_UNSIGNED (TREE_TYPE (op0)); - if (op1 == primop1 && TREE_TYPE (op1) != *restype_ptr) - unsignedp1 = TREE_UNSIGNED (TREE_TYPE (op1)); - - /* If one of the operands must be floated, we cannot optimize. */ - real1 = TREE_CODE (TREE_TYPE (primop0)) == REAL_TYPE; - real2 = TREE_CODE (TREE_TYPE (primop1)) == REAL_TYPE; - - /* If first arg is constant, swap the args (changing operation - so value is preserved), for canonicalization. */ - - if (TREE_LITERAL (primop0)) - { - register tree tem = primop0; - register int temi = unsignedp0; - primop0 = primop1; - primop1 = tem; - tem = op0; - op0 = op1; - op1 = tem; - *op0_ptr = op0; - *op1_ptr = op1; - unsignedp0 = unsignedp1; - unsignedp1 = temi; - temi = real1; - real1 = real2; - real2 = temi; - - switch (code) - { - case LT_EXPR: - code = GT_EXPR; - break; - case GT_EXPR: - code = LT_EXPR; - break; - case LE_EXPR: - code = GE_EXPR; - break; - case GE_EXPR: - code = LE_EXPR; - break; - } - *rescode_ptr = code; - } - - /* If comparing an integer against a constant more bits wide, - maybe we can deduce a value of 1 or 0 independent of the data. - Or else truncate the constant now - rather than extend the variable at run time. - - This is only interesting if the constant is the wider arg. - Also, it is not safe if the constant is unsigned and the - variable arg is signed, since in this case the variable - would be sign-extended and then regarded as unsigned. - Our technique fails in this case because the lowest/highest - possible unsigned results don't follow naturally from the - lowest/highest possible values of the variable operand. - For just EQ_EXPR and NE_EXPR there is another technique that - could be used: see if the constant can be faithfully represented - in the other operand's type, by truncating it and reextending it - and see if that preserves the constant's value. */ - - if (!real1 && !real2 - && TREE_CODE (primop1) == INTEGER_CST - && TYPE_PRECISION (TREE_TYPE (primop0)) < TYPE_PRECISION (*restype_ptr)) - { - int min_gt, max_gt, min_lt, max_lt; - tree maxval, minval; - /* 1 if comparison is nominally unsigned. */ - int unsignedp = TREE_UNSIGNED (*restype_ptr); - tree val; - - type = signed_or_unsigned_type (unsignedp0, TREE_TYPE (primop0)); - - maxval = TYPE_MAX_VALUE (type); - minval = TYPE_MIN_VALUE (type); - - if (unsignedp && !unsignedp0) - *restype_ptr = signed_type (*restype_ptr); - - if (TREE_TYPE (primop1) != *restype_ptr) - primop1 = convert (*restype_ptr, primop1); - if (type != *restype_ptr) - { - minval = convert (*restype_ptr, minval); - maxval = convert (*restype_ptr, maxval); - } - - if (unsignedp && unsignedp0) - { - min_gt = INT_CST_LT_UNSIGNED (primop1, minval); - max_gt = INT_CST_LT_UNSIGNED (primop1, maxval); - min_lt = INT_CST_LT_UNSIGNED (minval, primop1); - max_lt = INT_CST_LT_UNSIGNED (maxval, primop1); - } - else - { - min_gt = INT_CST_LT (primop1, minval); - max_gt = INT_CST_LT (primop1, maxval); - min_lt = INT_CST_LT (minval, primop1); - max_lt = INT_CST_LT (maxval, primop1); - } - - val = 0; - switch (code) - { - case NE_EXPR: - if (max_lt || min_gt) - val = integer_one_node; - break; - - case EQ_EXPR: - if (max_lt || min_gt) - val = integer_zero_node; - break; - - case LT_EXPR: - if (max_lt) - val = integer_one_node; - if (!min_lt) - val = integer_zero_node; - break; - - case GT_EXPR: - if (min_gt) - val = integer_one_node; - if (!max_gt) - val = integer_zero_node; - break; - - case LE_EXPR: - if (!max_gt) - val = integer_one_node; - if (min_gt) - val = integer_zero_node; - break; - - case GE_EXPR: - if (!min_lt) - val = integer_one_node; - if (max_lt) - val = integer_zero_node; - break; - } - - /* If primop0 was sign-extended and unsigned comparison specd, - we did a signed comparison above using the signed type bounds. - But the comparison we output must be unsigned. - - Also, for inequalities, VAL is no good; but if the signed - comparison had *any* fixed result, it follows that the - unsigned comparison just tests the sign in reverse - (positive values are LE, negative ones GE). - So we can generate an unsigned comparison - against an extreme value of the signed type. */ - - if (unsignedp && !unsignedp0) - { - if (val != 0) - switch (code) - { - case LT_EXPR: - case GE_EXPR: - primop1 = TYPE_MIN_VALUE (type); - val = 0; - break; - - case LE_EXPR: - case GT_EXPR: - primop1 = TYPE_MAX_VALUE (type); - val = 0; - break; - } - type = unsigned_type (type); - } - - if (max_lt && !unsignedp0) - { - /* This is the case of (char)x >?< 0x80, which people used to use - expecting old C compilers to change the 0x80 into -0x80. */ - if (val == integer_zero_node) - warning ("comparison is always 0 due to limited range of data type"); - if (val == integer_one_node) - warning ("comparison is always 1 due to limited range of data type"); - } - - if (val != 0) - { - /* Don't forget to evaluate PRIMOP0 if it has side effects. */ - if (TREE_VOLATILE (primop0)) - return build (COMPOUND_EXPR, TREE_TYPE (val), primop0, val); - return val; - } - - /* Value is not predetermined, but do the comparison - in the type of the operand that is not constant. - TYPE is already properly set. */ - } - else if (real1 && real2 - && TYPE_PRECISION (TREE_TYPE (primop0)) == TYPE_PRECISION (TREE_TYPE (primop1))) - type = TREE_TYPE (primop0); - - /* If args' natural types are both narrower than nominal type - and both extend in the same manner, compare them - in the type of the wider arg. - Otherwise must actually extend both to the nominal - common type lest different ways of extending - alter the result. - (eg, (short)-1 == (unsigned short)-1 should be 0.) */ - - else if (unsignedp0 == unsignedp1 && real1 == real2 - && TYPE_PRECISION (TREE_TYPE (primop0)) < TYPE_PRECISION (*restype_ptr) - && TYPE_PRECISION (TREE_TYPE (primop1)) < TYPE_PRECISION (*restype_ptr)) - { - type = commontype (TREE_TYPE (primop0), TREE_TYPE (primop1)); - type = signed_or_unsigned_type (unsignedp0 - || TREE_UNSIGNED (*restype_ptr), - type); - /* Make sure shorter operand is extended the right way - to match the longer operand. */ - primop0 = convert (signed_or_unsigned_type (unsignedp0, TREE_TYPE (primop0)), - primop0); - primop1 = convert (signed_or_unsigned_type (unsignedp1, TREE_TYPE (primop1)), - primop1); - } - else - { - /* Here we must do the comparison on the nominal type - using the args exactly as we received them. */ - type = *restype_ptr; - primop0 = op0; - primop1 = op1; - } - - *op0_ptr = convert (type, primop0); - *op1_ptr = convert (type, primop1); - - *restype_ptr = integer_type_node; - - return 0; -} - -/* Handle the case of taking the address of a COMPONENT_REF. - Called by `build_unary_op' and `build_up_reference'. - - ARG is the COMPONENT_REF whose address we want. - ARGTYPE is the pointer type that this address should have. - MSG is an error message to print if this COMPONENT_REF is not - addressable (such as a bitfield). */ - -tree -build_component_addr (arg, argtype, msg) - tree arg, argtype; - char *msg; -{ - tree field = TREE_OPERAND (arg, 1); - tree basetype = decl_type_context (field); - tree rval = build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 0), 0); - - if (TREE_PACKED (field)) - { - error (msg, IDENTIFIER_POINTER (DECL_NAME (field))); - return error_mark_node; - } - - if (TREE_CODE (field) == FIELD_DECL - && (TYPE_USES_MULTIPLE_INHERITANCE (basetype) - || TYPE_USES_VIRTUAL_BASECLASSES (basetype))) - /* Can't convert directly to ARGTYPE, since that - may have the same pointer type as one of our - baseclasses. */ - rval = build1 (NOP_EXPR, argtype, - convert_pointer_to (basetype, rval)); - else - /* This conversion is harmless. */ - rval = convert (argtype, rval); - - if (DECL_OFFSET (field) != 0) - { - tree offset = build_int_2 ((DECL_OFFSET (field) / BITS_PER_UNIT), 0); - TREE_TYPE (offset) = argtype; - rval = fold (build (PLUS_EXPR, argtype, rval, offset)); - } - return rval; -} - -/* Construct and perhaps optimize a tree representation - for a unary operation. CODE, a tree_code, specifies the operation - and XARG is the operand. */ - -tree -build_x_unary_op (code, xarg) - enum tree_code code; - tree xarg; -{ - tree rval; - - if (rval = build_opfncall (code, LOOKUP_PROTECT, xarg)) - return rval; - rval = build_unary_op (code, xarg, 0); - if (rval == error_mark_node) - build_opfncall (code, LOOKUP_NORMAL, xarg); - return rval; -} - -/* C++: Must handle pointers to members. - - Perhaps type instantiation should be extended to handle conversion - from aggregates to types we don't yet know we want? (Or are those - cases typically errors which should be reported?) - - NOCONVERT nonzero suppresses the default promotions - (such as from short to int). */ -tree -build_unary_op (code, xarg, noconvert) - enum tree_code code; - tree xarg; - int noconvert; -{ - /* No default_conversion here. It causes trouble for ADDR_EXPR. */ - register tree arg = xarg; - register tree argtype = 0; - register enum tree_code typecode = TREE_CODE (TREE_TYPE (arg)); - char *errstring = NULL; - tree val; - int isaggrtype; - - if (typecode == ERROR_MARK) - return error_mark_node; - - if (typecode == REFERENCE_TYPE && code != ADDR_EXPR && ! noconvert) - { - arg = convert_from_reference (arg); - typecode = TREE_CODE (TREE_TYPE (arg)); - } - - if (typecode == ENUMERAL_TYPE) - typecode = INTEGER_TYPE; - - isaggrtype = IS_AGGR_TYPE_CODE (typecode); - - switch (code) - { - case CONVERT_EXPR: - /* This is used for unary plus, because a CONVERT_EXPR - is enough to prevent anybody from looking inside for - associativity, but won't generate any code. */ - if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE)) - errstring = "wrong type argument to unary plus"; - else if (!noconvert) - arg = default_conversion (arg); - break; - - case NEGATE_EXPR: - if (isaggrtype) - { - if (!noconvert) - arg = default_conversion (arg); - else - { - error_with_aggr_type (TREE_TYPE (arg), "type conversion for type `%s' not allowed"); - return error_mark_node; - } - typecode = TREE_CODE (TREE_TYPE (arg)); - noconvert = 1; - } - - if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE)) - errstring = "wrong type argument to unary minus"; - else if (!noconvert) - arg = default_conversion (arg); - break; - - case BIT_NOT_EXPR: - if (isaggrtype) - { - if (!noconvert) - arg = default_conversion (arg); - else - { - error_with_aggr_type (TREE_TYPE (arg), "type conversion for type `%s' not allowed"); - return error_mark_node; - } - typecode = TREE_CODE (TREE_TYPE (arg)); - noconvert = 1; - } - - if (typecode != INTEGER_TYPE) - errstring = "wrong type argument to bit-complement"; - else if (!noconvert) - arg = default_conversion (arg); - break; - - case ABS_EXPR: - if (isaggrtype) - { - if (!noconvert) - arg = default_conversion (arg); - else - { - error_with_aggr_type (TREE_TYPE (arg), "type conversion for type `%s' not allowed"); - return error_mark_node; - } - typecode = TREE_CODE (TREE_TYPE (arg)); - noconvert = 1; - } - - if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE)) - errstring = "wrong type argument to abs"; - else if (!noconvert) - arg = default_conversion (arg); - break; - - case TRUTH_NOT_EXPR: - if (isaggrtype) - { - arg = truthvalue_conversion (arg); - typecode = TREE_CODE (TREE_TYPE (arg)); - } - - if (typecode != INTEGER_TYPE - && typecode != REAL_TYPE && typecode != POINTER_TYPE - /* These will convert to a pointer. */ - && typecode != ARRAY_TYPE && typecode != FUNCTION_TYPE) - { - errstring = "wrong type argument to unary exclamation mark"; - break; - } - arg = truthvalue_conversion (arg); - val = invert_truthvalue (arg); - if (val) return val; - break; - - case NOP_EXPR: - break; - - case PREINCREMENT_EXPR: - case POSTINCREMENT_EXPR: - case PREDECREMENT_EXPR: - case POSTDECREMENT_EXPR: - /* Handle complex lvalues (when permitted) - by reduction to simpler cases. */ - - val = unary_complex_lvalue (code, arg); - if (val != 0) - return val; - - /* Report invalid types. */ - - if (isaggrtype) - { - arg = default_conversion (arg); - typecode = TREE_CODE (TREE_TYPE (arg)); - } - - if (typecode != POINTER_TYPE - && typecode != INTEGER_TYPE && typecode != REAL_TYPE) - { - if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) - errstring ="wrong type argument to increment"; - else - errstring ="wrong type argument to decrement"; - break; - } - - /* Report something read-only. */ - - if (TREE_READONLY (arg)) - readonly_warning_or_error (arg, - ((code == PREINCREMENT_EXPR - || code == POSTINCREMENT_EXPR) - ? "increment" : "decrement")); - - { - register tree inc; - tree result_type = TREE_TYPE (arg); - - arg = get_unwidened (arg, 0); - argtype = TREE_TYPE (arg); - - /* Compute the increment. */ - - if (typecode == POINTER_TYPE) - { - if (pedantic && (TREE_CODE (argtype) == FUNCTION_TYPE - || TREE_CODE (argtype) == METHOD_TYPE - || TREE_CODE (argtype) == VOID_TYPE - || TREE_CODE (argtype) == OFFSET_TYPE)) - warning ("wrong type argument to %s", - ((code == PREINCREMENT_EXPR - || code == POSTINCREMENT_EXPR) - ? "increment" : "decrement")); - inc = c_sizeof_nowarn (TREE_TYPE (argtype)); - } - else - inc = integer_one_node; - - inc = convert (argtype, inc); - - /* Handle incrementing a cast-expression. */ - - if (!pedantic) - switch (TREE_CODE (arg)) - { - case NOP_EXPR: - case CONVERT_EXPR: - case FLOAT_EXPR: - case FIX_TRUNC_EXPR: - case FIX_FLOOR_EXPR: - case FIX_ROUND_EXPR: - case FIX_CEIL_EXPR: - { - tree incremented, modify, value; - arg = stabilize_reference (arg); - if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR) - value = arg; - else - value = save_expr (arg); - incremented = build (((code == PREINCREMENT_EXPR - || code == POSTINCREMENT_EXPR) - ? PLUS_EXPR : MINUS_EXPR), - argtype, value, inc); - TREE_VOLATILE (incremented) = 1; - modify = build_modify_expr (arg, NOP_EXPR, incremented); - return build (COMPOUND_EXPR, TREE_TYPE (arg), modify, value); - } - } - - if (TREE_CODE (arg) == OFFSET_REF) - arg = resolve_offset_ref (arg); - - /* Complain about anything else that is not a true lvalue. */ - if (!lvalue_or_else (arg, ((code == PREINCREMENT_EXPR - || code == POSTINCREMENT_EXPR) - ? "increment" : "decrement"))) - return error_mark_node; - - val = build (code, TREE_TYPE (arg), arg, inc); - TREE_VOLATILE (val) = 1; - return convert (result_type, val); - } - - case ADDR_EXPR: - /* Note that this operation never does default_conversion - regardless of NOCONVERT. */ - - if (TREE_CODE (arg) == REFERENCE_EXPR) - { - error ("references are not lvalues"); - return error_mark_node; - } - else if (typecode == REFERENCE_TYPE) - return build1 (REFERENCE_EXPR, build_pointer_type (TREE_TYPE (TREE_TYPE (arg))), arg); - - /* Let &* cancel out to simplify resulting code. */ - if (TREE_CODE (arg) == INDIRECT_REF) - { - /* Keep `default_conversion' from converting if - ARG is of REFERENCE_TYPE. */ - arg = TREE_OPERAND (arg, 0); - if (TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE) - { - if (TREE_CODE (arg) == VAR_DECL && DECL_INITIAL (arg)) - arg = DECL_INITIAL (arg); - arg = build1 (REFERENCE_EXPR, build_pointer_type (TREE_TYPE (TREE_TYPE (arg))), arg); - TREE_LITERAL (arg) = TREE_LITERAL (TREE_OPERAND (arg, 0)); - } - return arg; - } - - /* For &x[y], return x+y */ - if (TREE_CODE (arg) == ARRAY_REF) - { - if (mark_addressable (TREE_OPERAND (arg, 0)) == 0) - return error_mark_node; - return build_binary_op (PLUS_EXPR, TREE_OPERAND (arg, 0), - TREE_OPERAND (arg, 1)); - } - - /* Uninstantiated types are all functions. Taking the - address of a function is a no-op, so just return the - arguemnt. */ - - if (TREE_CODE (arg) == OP_IDENTIFIER) - /* We don't know the type yet, so just work around the problem. - We know that this will resolve to an lvalue. */ - return build1 (ADDR_EXPR, unknown_type_node, arg); - - if (TREE_CODE (arg) == TREE_LIST) - { - /* Look at methods with only this name. */ - if (TREE_CODE (TREE_VALUE (arg)) == FUNCTION_DECL) - { - tree targ = TREE_VALUE (arg); - - /* If this function is unique, or it is a unique - constructor, we can takes its address easily. */ - if (TREE_CHAIN (targ) == NULL_TREE - || (DESTRUCTOR_NAME_P (DECL_NAME (targ)) - && TREE_CHAIN (TREE_CHAIN (targ)) == NULL_TREE)) - { - if (TREE_CHAIN (targ)) - targ = TREE_CHAIN (targ); - targ = build (OFFSET_REF, TREE_TYPE (targ), C_C_D, targ); - - val = unary_complex_lvalue (ADDR_EXPR, targ); - if (val) - return val; - } - return build1 (ADDR_EXPR, unknown_type_node, arg); - } - if (TREE_CHAIN (arg) == NULL_TREE - && TREE_CHAIN (TREE_VALUE (TREE_VALUE (arg))) == NULL_TREE) - { - /* Unique overloaded member function. */ - return build_unary_op (ADDR_EXPR, TREE_VALUE (TREE_VALUE (arg)), 0); - } - return build1 (ADDR_EXPR, unknown_type_node, arg); - } - - /* Handle complex lvalues (when permitted) - by reduction to simpler cases. */ - val = unary_complex_lvalue (code, arg); - if (val != 0) - return val; - - /* Address of a cast is just a cast of the address - of the operand of the cast. */ - switch (TREE_CODE (arg)) - { - case NOP_EXPR: - case CONVERT_EXPR: - case FLOAT_EXPR: - case FIX_TRUNC_EXPR: - case FIX_FLOOR_EXPR: - case FIX_ROUND_EXPR: - case FIX_CEIL_EXPR: - if (pedantic) - warning ("ANSI C forbids the address of a cast expression"); - return convert (build_pointer_type (TREE_TYPE (arg)), - build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 0), 0)); - } - - /* Allow the address of a constructor if all the elements - are constant. */ - if (TREE_CODE (arg) == CONSTRUCTOR && TREE_LITERAL (arg)) - ; - /* Anything not already handled and not a true memory reference - is an error. */ - else if (typecode != FUNCTION_TYPE - && typecode != METHOD_TYPE - && !lvalue_or_else (arg, "unary `&'")) - return error_mark_node; - - /* Ordinary case; arg is a COMPONENT_REF or a decl. */ - argtype = TREE_TYPE (arg); - if (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg)) - argtype = build_type_variant (argtype, - TREE_READONLY (arg), - TREE_THIS_VOLATILE (arg)); - - argtype = build_pointer_type (argtype); - - if (mark_addressable (arg) == 0) - return error_mark_node; - - { - tree addr; - - if (TREE_CODE (arg) == COMPONENT_REF) - addr = build_component_addr (arg, argtype, - "attempt to take address of bit-field structure member `%s'"); - else - addr = build1 (code, argtype, arg); - - /* Address of a static or external variable or - function counts as a constant */ - TREE_LITERAL (addr) = staticp (arg); - return addr; - } - } - - if (!errstring) - { - if (argtype == 0) - argtype = TREE_TYPE (arg); - return fold (build1 (code, argtype, arg)); - } - - error (errstring); - return error_mark_node; -} - -/* If CONVERSIONS is a conversion expression or a nested sequence of such, - convert ARG with the same conversions in the same order - and return the result. */ - -static tree -convert_sequence (conversions, arg) - tree conversions; - tree arg; -{ - switch (TREE_CODE (conversions)) - { - case NOP_EXPR: - case CONVERT_EXPR: - case FLOAT_EXPR: - case FIX_TRUNC_EXPR: - case FIX_FLOOR_EXPR: - case FIX_ROUND_EXPR: - case FIX_CEIL_EXPR: - return convert (TREE_TYPE (conversions), - convert_sequence (TREE_OPERAND (conversions, 0), - arg)); - - default: - return arg; - } -} - -/* Apply unary lvalue-demanding operator CODE to the expression ARG - for certain kinds of expressions which are not really lvalues - but which we can accept as lvalues. - - If ARG is not a kind of expression we can handle, return zero. */ - -tree -unary_complex_lvalue (code, arg) - enum tree_code code; - tree arg; -{ - /* Handle (a, b) used as an "lvalue". */ - if (TREE_CODE (arg) == COMPOUND_EXPR) - { - tree real_result = build_unary_op (code, TREE_OPERAND (arg, 1), 0); - return build (COMPOUND_EXPR, TREE_TYPE (real_result), - TREE_OPERAND (arg, 0), real_result); - } - - /* Handle (a ? b : c) used as an "lvalue". */ - if (TREE_CODE (arg) == COND_EXPR) - return (build_conditional_expr - (TREE_OPERAND (arg, 0), - build_unary_op (code, TREE_OPERAND (arg, 1), 0), - build_unary_op (code, TREE_OPERAND (arg, 2), 0))); - - if (code != ADDR_EXPR) - return 0; - - /* Handle (a = b) used as an "lvalue" for `&'. */ - if (TREE_CODE (arg) == MODIFY_EXPR - || TREE_CODE (arg) == INIT_EXPR) - { - tree real_result = build_unary_op (code, TREE_OPERAND (arg, 0), 0); - return build (COMPOUND_EXPR, TREE_TYPE (real_result), arg, real_result); - } - - if (TREE_CODE (arg) == WITH_CLEANUP_EXPR) - { - tree real_result = build_unary_op (code, TREE_OPERAND (arg, 0), 0); - real_result = build (WITH_CLEANUP_EXPR, TREE_TYPE (real_result), - real_result, 0, TREE_OPERAND (arg, 2)); - return real_result; - } - - if (TREE_CODE (TREE_TYPE (arg)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (arg)) == METHOD_TYPE - || TREE_CODE (TREE_TYPE (arg)) == OFFSET_TYPE) - { - /* The representation of something of type OFFSET_TYPE - is really the representation of a pointer to it. - Here give the representation its true type. */ - tree t; - tree offset; - - assert (TREE_CODE (arg) != SCOPE_REF); - - if (TREE_CODE (arg) != OFFSET_REF) - return 0; - - t = TREE_OPERAND (arg, 1); - if (TREE_OPERAND (arg, 0) - && (TREE_CODE (TREE_OPERAND (arg, 0)) != NOP_EXPR - || TREE_OPERAND (TREE_OPERAND (arg, 0), 0) != error_mark_node)) - { - /* Don't know if this should return address to just - _DECL, or actual address resolved in this expression. */ - sorry ("address of bound pointer-to-member expression"); - return error_mark_node; - } - - if (TREE_CODE (t) == FUNCTION_DECL) - { - tree context = NULL_TREE; - - if (DECL_VIRTUAL_P (t) -#ifdef SOS - || flag_all_virtual == 2 -#endif - || (flag_all_virtual == 1 - && ((context = decl_type_context (t)) - && (TYPE_OVERLOADS_METHOD_CALL_EXPR (context) - || TYPE_NEEDS_WRAPPER (context)) - && ! DECL_CONSTRUCTOR_P (t)))) - { - offset = copy_node (DECL_VINDEX (t)); - TREE_TYPE (offset) = build_pointer_type (TREE_TYPE (arg)); - } - else - offset = build_unary_op (ADDR_EXPR, t, 0); - - return offset; - } - if (TREE_CODE (t) == VAR_DECL) - { - if (TREE_STATIC (t)) - offset = build_unary_op (ADDR_EXPR, t, 0); - else - return 0; - } - else - { - /* Can't build a pointer to member if the member must - go through virtual base classes. */ - if (virtual_member (DECL_FIELD_CONTEXT (t), - CLASSTYPE_VBASECLASSES (TREE_TYPE (TREE_OPERAND (arg, 0))))) - { - sorry ("pointer to member via virtual baseclass"); - return error_mark_node; - } - /* @@ What is the correct machine-independent way to do this? */ - offset = build_int_2 (DECL_OFFSET (t) / DECL_SIZE_UNIT (t), 0); - TREE_TYPE (offset) = build_pointer_type (TREE_TYPE (arg)); - return offset; - } - } - - if (TREE_CODE (arg) == OFFSET_REF) - { - tree left = TREE_OPERAND (arg, 0), left_addr; - tree right_addr = build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 1), 0); - - if (left == 0) - if (current_class_decl) - left_addr = current_class_decl; - else - { - error ("no `this' for pointer to member"); - return error_mark_node; - } - else - left_addr = build_unary_op (ADDR_EXPR, left, 0); - - return build (PLUS_EXPR, build_pointer_type (TREE_TYPE (arg)), - build1 (NOP_EXPR, integer_type_node, left_addr), - build1 (NOP_EXPR, integer_type_node, right_addr)); - } - - - /* We permit compiler to make function calls returning - objects of aggregate type look like lvalues. */ - if (TREE_CODE (arg) == CALL_EXPR && IS_AGGR_TYPE (TREE_TYPE (arg))) - { - tree temp = build_cplus_new (TREE_TYPE (arg), arg); - return build1 (ADDR_EXPR, TYPE_POINTER_TO (TREE_TYPE (arg)), temp); - } - - /* Don't let anything else be handled specially. */ - return 0; -} - -/* Prepare expr to be an argument of a TRUTH_NOT_EXPR, - or validate its data type for an `if' or `while' statement or ?..: exp. - - This preparation consists of taking the ordinary - representation of an expression expr and producing a valid tree - boolean expression describing whether expr is nonzero. We could - simply always do build_binary_op (NE_EXPR, expr, integer_zero_node), - but we optimize comparisons, &&, ||, and ! */ - -tree -truthvalue_conversion (expr) - tree expr; -{ - register enum tree_code form; - - /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. - Strip such NOP_EXPRs, since EXPR is being used in non-lvalue context. */ - if (TREE_CODE (expr) == NOP_EXPR - && TREE_TYPE (expr) == TREE_TYPE (TREE_OPERAND (expr, 0))) - expr = TREE_OPERAND (expr, 0); - - form = TREE_CODE (expr); - - if (form == EQ_EXPR && integer_zerop (TREE_OPERAND (expr, 1))) - return build_unary_op (TRUTH_NOT_EXPR, TREE_OPERAND (expr, 0), 0); - - /* A one-bit unsigned bit-field is already acceptable. */ - if (form == COMPONENT_REF - && 1 == TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (expr, 1))) - && 1 == DECL_SIZE_UNIT (TREE_OPERAND (expr, 1)) - && TREE_UNSIGNED (TREE_OPERAND (expr, 1))) - return expr; - - if (form == TRUTH_ANDIF_EXPR || form == TRUTH_ORIF_EXPR - || form == TRUTH_AND_EXPR || form == TRUTH_OR_EXPR - || form == TRUTH_NOT_EXPR - || form == EQ_EXPR || form == NE_EXPR - || form == LE_EXPR || form == GE_EXPR - || form == LT_EXPR || form == GT_EXPR - || form == ERROR_MARK) - return expr; - - /* Unary minus has no effect on whether its argument is nonzero. */ - if (form == NEGATE_EXPR) - return truthvalue_conversion (TREE_OPERAND (expr, 0)); - - /* Distribute the conversion into the arms of a COND_EXPR. */ - if (form == COND_EXPR) - return build (COND_EXPR, TREE_TYPE (expr), - TREE_OPERAND (expr, 0), - truthvalue_conversion (TREE_OPERAND (expr, 1)), - truthvalue_conversion (TREE_OPERAND (expr, 2))); - - /* Sign-extension and zero-extension has no effect. */ - if (form == NOP_EXPR - && TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE - && (TYPE_PRECISION (TREE_TYPE (expr)) - > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))) - return truthvalue_conversion (TREE_OPERAND (expr, 0)); - - return build_binary_op (NE_EXPR, expr, integer_zero_node); -} - -/* Return a simplified tree node for the truth-negation of ARG - (perhaps by altering ARG). - If it can't be simplified, return 0. */ - -static tree -invert_truthvalue (arg) - tree arg; -{ - switch (TREE_CODE (arg)) - { - case NE_EXPR: - TREE_SET_CODE (arg, EQ_EXPR); - return arg; - - case EQ_EXPR: - TREE_SET_CODE (arg, NE_EXPR); - return arg; - - case GE_EXPR: - TREE_SET_CODE (arg, LT_EXPR); - return arg; - - case GT_EXPR: - TREE_SET_CODE (arg, LE_EXPR); - return arg; - - case LE_EXPR: - TREE_SET_CODE (arg, GT_EXPR); - return arg; - - case LT_EXPR: - TREE_SET_CODE (arg, GE_EXPR); - return arg; - -#if 0 - case TRUTH_AND_EXPR: - return build (TRUTH_OR_EXPR, TREE_TYPE (arg), - build_unary_op (TRUTH_NOT_EXPR, - TREE_OPERAND (arg, 0), 0), - build_unary_op (TRUTH_NOT_EXPR, - TREE_OPERAND (arg, 1), 0)); - - case TRUTH_OR_EXPR: - return build (TRUTH_AND_EXPR, TREE_TYPE (arg), - build_unary_op (TRUTH_NOT_EXPR, - TREE_OPERAND (arg, 0), 0), - build_unary_op (TRUTH_NOT_EXPR, - TREE_OPERAND (arg, 1), 0)); -#endif - - case TRUTH_ANDIF_EXPR: - return build (TRUTH_ORIF_EXPR, TREE_TYPE (arg), - build_unary_op (TRUTH_NOT_EXPR, - TREE_OPERAND (arg, 0), 0), - build_unary_op (TRUTH_NOT_EXPR, - TREE_OPERAND (arg, 1), 0)); - - case TRUTH_ORIF_EXPR: - return build (TRUTH_ANDIF_EXPR, TREE_TYPE (arg), - build_unary_op (TRUTH_NOT_EXPR, - TREE_OPERAND (arg, 0), 0), - build_unary_op (TRUTH_NOT_EXPR, - TREE_OPERAND (arg, 1), 0)); - - case TRUTH_NOT_EXPR: - return TREE_OPERAND (arg, 0); - } - return 0; -} - -/* Mark EXP saying that we need to be able to take the - address of it; it should not be allocated in a register. - - Return 1 if taking address of this expression is ok. - Return 0 otherwise. - - C++: we do not allow `current_class_decl' to be addressable. */ - -int -mark_addressable (exp) - tree exp; -{ - register tree x = exp; - - if (TREE_ADDRESSABLE (x) == 1) - return 1; - - while (1) - switch (TREE_CODE (x)) - { - case ADDR_EXPR: - case COMPONENT_REF: - case ARRAY_REF: - x = TREE_OPERAND (x, 0); - break; - - case PARM_DECL: - if (x == current_class_decl) - { - error ("address of `this' not available"); - TREE_ADDRESSABLE (x) = 1; /* so compiler doesn't die later */ - put_var_into_stack (x); - return 1; - } - case VAR_DECL: - if (TREE_STATIC (x) - && TREE_READONLY (x) - && DECL_RTL (x) != 0 - && ! memory_operand (DECL_RTL (x), DECL_MODE (x))) - { - /* We thought this would make a good constant variable, - but we were wrong. */ - TREE_ASM_WRITTEN (x) = 0; - DECL_RTL (x) = 0; - rest_of_decl_compilation (x, 0, IDENTIFIER_LOCAL_VALUE (x) == 0, 0); - TREE_ADDRESSABLE (x) = 1; - return 1; - } - /* Caller should not be trying to mark initialized - constant fields addressable. */ - assert (DECL_LANG_SPECIFIC (x) == 0 || DECL_IN_AGGR_P (x) == 0 || TREE_STATIC (x)); - - case CONST_DECL: - if (TREE_REGDECL (x)) - { - if (TREE_PUBLIC (x)) - { - error ("address of global register variable `%s' requested", - IDENTIFIER_POINTER (DECL_NAME (x))); - return 0; - } - warning ("address requested for `%s', which is declared `register'", - IDENTIFIER_POINTER (DECL_NAME (x))); - } - put_var_into_stack (x); - TREE_ADDRESSABLE (x) = 1; - return 1; - - case RESULT_DECL: - put_var_into_stack (x); - TREE_ADDRESSABLE (x) = 1; - return 1; - - case FUNCTION_DECL: - if (TREE_INLINE (x)) - mark_inline_for_output (x); - TREE_ADDRESSABLE (x) = 1; - TREE_USED (x) = 1; - TREE_ADDRESSABLE (DECL_NAME (x)) = 1; - return 1; - - default: - return 1; - } -} - -/* Build and return a conditional expression IFEXP ? OP1 : OP2. */ - -tree -build_x_conditional_expr (ifexp, op1, op2) - tree ifexp, op1, op2; -{ - tree rval; - - if (op1 != 0 && (rval = build_opfncall (COND_EXPR, LOOKUP_PROTECT, ifexp, op1, op2))) - return rval; - rval = build_conditional_expr (ifexp, op1, op2); - if (op1 != 0 && rval == error_mark_node) - build_opfncall (COND_EXPR, LOOKUP_NORMAL, ifexp, op1, op2); - return rval; -} - -tree -build_conditional_expr (ifexp, op1, op2) - tree ifexp, op1, op2; -{ - register tree type1; - register tree type2; - register enum tree_code code1; - register enum tree_code code2; - register tree result_type = NULL_TREE; - - /* If second operand is omitted, it is the same as the first one; - make sure it is calculated only once. */ - if (op1 == 0) - { - if (pedantic) - warning ("ANSI C forbids omitting the middle term of a ?: expression"); - ifexp = op1 = save_expr (ifexp); - } - - ifexp = truthvalue_conversion (default_conversion (ifexp)); - - if (TREE_CODE (ifexp) == ERROR_MARK) - return error_mark_node; - - op1 = require_instantiated_type (TREE_TYPE (op2), op1, error_mark_node); - if (op1 == error_mark_node) - return error_mark_node; - op2 = require_instantiated_type (TREE_TYPE (op1), op2, error_mark_node); - if (op2 == error_mark_node) - return error_mark_node; - - /* C++: REFERENCE_TYPES must be dereferenced. */ - type1 = TREE_TYPE (op1); - code1 = TREE_CODE (type1); - type2 = TREE_TYPE (op2); - code2 = TREE_CODE (type2); - - if (code1 == REFERENCE_TYPE) - { - op1 = convert_from_reference (op1); - type1 = TREE_TYPE (op1); - code1 = TREE_CODE (type1); - } - if (code2 == REFERENCE_TYPE) - { - op2 = convert_from_reference (op2); - type2 = TREE_TYPE (op2); - code2 = TREE_CODE (type2); - } - - /* Don't promote the operands separately if they promote - the same way. Return the unpromoted type and let the combined - value get promoted if necessary. */ - - if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2) - && code2 != ARRAY_TYPE -#if 0 - /* For C++, let the enumeral type come through. */ - && code2 != ENUMERAL_TYPE -#endif - && code2 != FUNCTION_TYPE - && code2 != METHOD_TYPE) - { - if (TREE_LITERAL (ifexp) - && (TREE_CODE (ifexp) == INTEGER_CST - || TREE_CODE (ifexp) == ADDR_EXPR)) - return (integer_zerop (ifexp) ? op2 : op1); - - if (TREE_CODE (op1) == CONST_DECL) - op1 = DECL_INITIAL (op1); - else if (TREE_READONLY_DECL_P (op1)) - op1 = decl_constant_value (op1); - if (TREE_CODE (op2) == CONST_DECL) - op2 = DECL_INITIAL (op2); - else if (TREE_READONLY_DECL_P (op2)) - op2 = decl_constant_value (op2); - if (type1 != type2) - { - int constp = TREE_READONLY (type1) || TREE_READONLY (type2); - int volatilep = TREE_VOLATILE (type1) || TREE_VOLATILE (type2); - type1 = build_type_variant (type1, constp, volatilep); - } - return build (COND_EXPR, type1, ifexp, op1, op2); - } - - /* They don't match; promote them both and then try to reconcile them. - But don't permit mismatching enum types. */ - if (code1 == ENUMERAL_TYPE) - { - if (code2 == ENUMERAL_TYPE) - { - message_2_types (error, "enumeral mismatch in conditional expression: `%s' vs `%s'", type1, type2); - return error_mark_node; - } - else if (extra_warnings && ! IS_AGGR_TYPE_CODE (code2)) - warning ("enumeral and non-enumeral type in conditional expression"); - } - else if (extra_warnings - && code2 == ENUMERAL_TYPE && ! IS_AGGR_TYPE_CODE (code1)) - warning ("enumeral and non-enumeral type in conditional expression"); - - if (code1 != VOID_TYPE) - { - op1 = default_conversion (op1); - type1 = TREE_TYPE (op1); - code1 = TREE_CODE (type1); - } - if (code2 != VOID_TYPE) - { - op2 = default_conversion (op2); - type2 = TREE_TYPE (op2); - code2 = TREE_CODE (type2); - } - - /* Quickly detect the usual case where op1 and op2 have the same type - after promotion. */ - if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2)) - { - if (type1 != type2) - { - int constp = TREE_READONLY (type1) || TREE_READONLY (type2); - int volatilep = TREE_VOLATILE (type1) || TREE_VOLATILE (type2); - type1 = build_type_variant (type1, constp, volatilep); - } - result_type = type1; - } - else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE) - && (code2 == INTEGER_TYPE || code2 == REAL_TYPE)) - { - result_type = commontype (type1, type2); - } - else if (code1 == VOID_TYPE || code2 == VOID_TYPE) - { - if (pedantic && (code1 != VOID_TYPE || code2 != VOID_TYPE)) - warning ("ANSI C forbids conditional expr with only one void side"); - result_type = void_type_node; - } - else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE) - { - if (comp_target_types (type1, type2, 1)) - result_type = commontype (type1, type2); - else if (TYPE_MAIN_VARIANT (TREE_TYPE (type1)) == void_type_node) - { - if (pedantic && TREE_CODE (type2) == FUNCTION_TYPE) - warning ("ANSI C forbids conditional expr between `void *' and function pointer"); - result_type = qualify_type (type1, type2); - } - else if (TYPE_MAIN_VARIANT (TREE_TYPE (type2)) == void_type_node) - { - if (pedantic && TREE_CODE (type1) == FUNCTION_TYPE) - warning ("ANSI C forbids conditional expr between `void *' and function pointer"); - result_type = qualify_type (type2, type1); - } - /* C++ */ - else if (comptypes (type2, type1, 0)) - result_type = type2; - else if (result_type = common_base_type (TREE_TYPE (type1), TREE_TYPE (type2))) - { - if (result_type == error_mark_node) - { - message_2_types (error, "common base type of types `%s' and `%s' is ambiguous", - TREE_TYPE (type1), TREE_TYPE (type2)); - result_type = ptr_type_node; - } - else result_type = TYPE_POINTER_TO (result_type); - } - else - { - warning ("pointer type mismatch in conditional expression"); - result_type = ptr_type_node; - } - } - else if (code1 == POINTER_TYPE && code2 == INTEGER_TYPE) - { - if (!integer_zerop (op2)) - warning ("pointer/integer type mismatch in conditional expression"); - else - { - op2 = null_pointer_node; - if (pedantic && TREE_CODE (type1) == FUNCTION_TYPE) - warning ("ANSI C forbids conditional expr between 0 and function pointer"); - } - result_type = type1; - } - else if (code2 == POINTER_TYPE && code1 == INTEGER_TYPE) - { - if (!integer_zerop (op1)) - warning ("pointer/integer type mismatch in conditional expression"); - else - { - op1 = null_pointer_node; - if (pedantic && TREE_CODE (type2) == FUNCTION_TYPE) - warning ("ANSI C forbids conditional expr between 0 and function pointer"); - } - result_type = type2; - op1 = null_pointer_node; - } - - if (!result_type) - { - /* The match does not look good. If either is - an aggregate value, try converting to a scalar type. */ - if (code1 == RECORD_TYPE && code2 == RECORD_TYPE) - { - message_2_types (error, "aggregate mismatch in conditional expression: `%s' vs `%s'", type1, type2); - return error_mark_node; - } - if (code1 == RECORD_TYPE && TYPE_HAS_CONVERSION (type1)) - { - tree tmp = build_type_conversion (CONVERT_EXPR, type2, op1, 0); - if (tmp == NULL_TREE) - { - error_with_aggr_type (type1, "aggregate type `%s' could not convert on lhs of `:'"); - return error_mark_node; - } - if (tmp == error_mark_node) - error ("ambiguous pointer conversion"); - result_type = type2; - op1 = tmp; - } - else if (code2 == RECORD_TYPE && TYPE_HAS_CONVERSION (type2)) - { - tree tmp = build_type_conversion (CONVERT_EXPR, type1, op2, 0); - if (tmp == NULL_TREE) - { - error_with_aggr_type (type2, "aggregate type `%s' could not convert on rhs of `:'"); - return error_mark_node; - } - if (tmp == error_mark_node) - error ("ambiguous pointer conversion"); - result_type = type1; - op2 = tmp; - } - else if (flag_cond_mismatch) - result_type = void_type_node; - else - { - error ("type mismatch in conditional expression"); - return error_mark_node; - } - } - - if (result_type != TREE_TYPE (op1)) - op1 = convert (result_type, op1); - if (result_type != TREE_TYPE (op2)) - op2 = convert (result_type, op2); - -#if 0 - if (IS_AGGR_TYPE_CODE (code1)) - { - result_type = TREE_TYPE (op1); - if (TREE_LITERAL (ifexp)) - return (integer_zerop (ifexp) ? op2 : op1); - - if (TYPE_MODE (result_type) == BLKmode) - { - register tree tempvar - = build_decl (VAR_DECL, NULL_TREE, result_type); - register tree xop1 = build_modify_expr (tempvar, NOP_EXPR, op1); - register tree xop2 = build_modify_expr (tempvar, NOP_EXPR, op2); - register tree result = build (COND_EXPR, result_type, - ifexp, xop1, xop2); - - layout_decl (tempvar); - /* No way to handle variable-sized objects here. - I fear that the entire handling of BLKmode conditional exprs - needs to be redone. */ - assert (TREE_LITERAL (DECL_SIZE (tempvar))); - DECL_RTL (tempvar) - = assign_stack_local (DECL_MODE (tempvar), - (TREE_INT_CST_LOW (DECL_SIZE (tempvar)) - * DECL_SIZE_UNIT (tempvar) - + BITS_PER_UNIT - 1) - / BITS_PER_UNIT); - - TREE_VOLATILE (result) - = TREE_VOLATILE (ifexp) | TREE_VOLATILE (op1) - | TREE_VOLATILE (op2); - return build (COMPOUND_EXPR, result_type, result, tempvar); - } - } -#endif /* 0 */ - - if (TREE_LITERAL (ifexp)) - return (integer_zerop (ifexp) ? op2 : op1); - - return build (COND_EXPR, result_type, ifexp, op1, op2); -} - -/* Handle overloading of the ',' operator when needed. Otherwise, - this function just builds an expression list. */ -tree -build_x_compound_expr (list) - tree list; -{ - tree type, rest = TREE_CHAIN (list); - tree result; - - if (rest == NULL_TREE) - return build_compound_expr (list); - - result = build_opfncall (COMPOUND_EXPR, LOOKUP_NORMAL, - TREE_VALUE (list), TREE_VALUE (rest)); - if (result) - return build_x_compound_expr (tree_cons (NULL_TREE, result, TREE_CHAIN (rest))); - else - return build_compound_expr (tree_cons (NULL_TREE, TREE_VALUE (list), - build_tree_list (NULL_TREE, build_x_compound_expr (rest)))); -} - -/* Given a list of expressions, return a compound expression - that performs them all and returns the value of the last of them. */ - -tree -build_compound_expr (list) - tree list; -{ - register tree rest; - - if (TREE_CODE (TREE_VALUE (list)) == CALL_EXPR - && TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (TREE_VALUE (list)))) - TREE_VALUE (list) = cleanup_after_call (TREE_VALUE (list)); - else if (TREE_READONLY_DECL_P (TREE_VALUE (list))) - TREE_VALUE (list) = decl_constant_value (TREE_VALUE (list)); - - if (TREE_CHAIN (list) == 0) - { - /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. - Strip such NOP_EXPRs, since LIST is used in non-lvalue context. */ - if (TREE_CODE (list) == NOP_EXPR - && TREE_TYPE (list) == TREE_TYPE (TREE_OPERAND (list, 0))) - list = TREE_OPERAND (list, 0); - - return TREE_VALUE (list); - } - - rest = build_compound_expr (TREE_CHAIN (list)); - - /* This is patched out so that sizeof (0, array) is distinguishable from - sizeof array. */ -#if 0 - if (! TREE_VOLATILE (TREE_VALUE (list))) - return rest; -#endif - - if (! TREE_VOLATILE (TREE_VALUE (list))) - return rest; - - return build (COMPOUND_EXPR, TREE_TYPE (rest), TREE_VALUE (list), rest); -} - -/* Build an expression representing a cast to type TYPE of expression EXPR. */ - -tree -build_c_cast (type, expr) - register tree type; - tree expr; -{ - register tree value = expr; - - if (type == error_mark_node || expr == error_mark_node) - return error_mark_node; - type = TYPE_MAIN_VARIANT (type); - - /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. - Strip such NOP_EXPRs, since VALUE is being used in non-lvalue context. */ - if (TREE_CODE (value) == NOP_EXPR - && TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0))) - value = TREE_OPERAND (value, 0); - - if (type == TREE_TYPE (value)) - { - if (pedantic) - { - if (TREE_CODE (type) == RECORD_TYPE - || TREE_CODE (type) == UNION_TYPE) - warning ("ANSI C forbids casting nonscalar to the same type"); - } - return value; - } - - /* If there's only one function in the overloaded space, - just take it. */ - if (TREE_CODE (value) == TREE_LIST - && TREE_CHAIN (value) == NULL_TREE) - value = TREE_VALUE (value); - - if (TREE_TYPE (value) == NULL_TREE - || type_unknown_p (value)) - { - value = instantiate_type (type, value, 1); - /* Did we lose? */ - if (value == error_mark_node) - return error_mark_node; - } - else if (TREE_CODE (type) == REFERENCE_TYPE - && TREE_CODE (TREE_TYPE (value)) == REFERENCE_TYPE) - { - /* Reference-to-reference conversion is special. */ - value = build_unary_op (ADDR_EXPR, value, 0); - if (value != error_mark_node) - value = convert_force (build_pointer_type (TREE_TYPE (type)), value); - if (value == error_mark_node) - return error_mark_node; - return build1 (NOP_EXPR, type, value); - } - else - { - tree otype; - value = default_conversion (value); - otype = TREE_TYPE (value); - - /* Optionally warn about potentially worrysome casts. */ - - if (warn_cast_qual - && TREE_CODE (type) == POINTER_TYPE - && TREE_CODE (otype) == POINTER_TYPE) - { - if (TREE_VOLATILE (TREE_TYPE (otype)) - && ! TREE_VOLATILE (TREE_TYPE (type))) - warning ("cast discards `volatile' from pointer target type"); - if (TREE_READONLY (TREE_TYPE (otype)) - && ! TREE_READONLY (TREE_TYPE (type))) - warning ("cast discards `const' from pointer target type"); - } - value = convert_force (type, value); - } - if (value == expr) - /* Always produce some operator for an explicit cast, - so we can tell (for -pedantic) that the cast is no lvalue. */ - { - tree nvalue = build1 (NOP_EXPR, type, value); - TREE_LITERAL (nvalue) = TREE_LITERAL (value); - return nvalue; - } - - if (TREE_CODE (value) == CALL_EXPR - && TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (value))) - value = cleanup_after_call (value); - - return value; -} - -/* Build an assignment expression of lvalue LHS from value RHS. - - In C++, if the left hand side of the assignment is a REFERENCE_TYPE, - that reference becomes deferenced down to it base type. */ - -/* Return a reference to the BASE_INDEX part of EXPR. TYPE is - the type to which BASE_INDEX applies. */ -static tree -get_base_ref (type, base_index, expr) - tree type; - int base_index; - tree expr; -{ - tree basetype = CLASSTYPE_BASECLASS (type, base_index); - tree ref; - - if (TREE_CODE (expr) == ARRAY_REF - || CLASSTYPE_OFFSET (basetype) != integer_zero_node - || CLASSTYPE_VIA_VIRTUAL (type, base_index) - || TYPE_MODE (type) != TYPE_MODE (basetype)) - { - tree addr = build_unary_op (ADDR_EXPR, expr, 0); - ref = build_indirect_ref (convert_pointer_to (basetype, addr), 0); - } - else - { - ref = copy_node (expr); - TREE_TYPE (ref) = basetype; - } - return ref; -} - -/* Build an assignment expression of lvalue LHS from value RHS. - MODIFYCODE is the code for a binary operator that we use - to combine the old value of LHS with RHS to get the new value. - Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment. - - C++: If MODIFYCODE is INIT_EXPR, then leave references unbashed. - - `build_modify_expr_1' implements recursive part of memberwise - assignment operation. */ -static tree -build_modify_expr_1 (lhs, modifycode, rhs, basetype_path) - tree lhs, rhs; - enum tree_code modifycode; - tree basetype_path; -{ - register tree result; - tree newrhs = rhs; - tree lhstype = TREE_TYPE (lhs); - tree olhstype = lhstype; - - /* Avoid duplicate error messages from operands that had errors. */ - if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK) - return error_mark_node; - - /* If a binary op has been requested, combine the old LHS value with the RHS - producing the value we should actually store into the LHS. */ - - if (modifycode == INIT_EXPR) - ; - else if (modifycode == NOP_EXPR) - { - /* must deal with overloading of `operator=' here. */ - if (TREE_CODE (lhstype) == REFERENCE_TYPE) - lhstype = TREE_TYPE (lhstype); - lhstype = olhstype; - } - else - { - lhs = stabilize_reference (lhs); - newrhs = build_binary_op (modifycode, lhs, rhs); - modifycode = NOP_EXPR; - } - - /* If storing into a structure or union member, - it has probably been given type `int'. - Compute the type that would go with - the actual amount of storage the member occupies. */ - - if (TREE_CODE (lhs) == COMPONENT_REF - && (TREE_CODE (lhstype) == INTEGER_TYPE - || TREE_CODE (lhstype) == REAL_TYPE - || TREE_CODE (lhstype) == ENUMERAL_TYPE)) - lhstype = TREE_TYPE (get_unwidened (lhs, 0)); - - /* C++: The semantics of C++ differ from those of C when an - assignment of an aggregate is desired. Assignment in C++ is - now defined as memberwise assignment of non-static members - and base class objects. This rule applies recursively - until a member of a built-in type is found. - - Also, we cannot do a bit-wise copy of aggregates which - contain virtual function table pointers. Those - pointer values must be preserved through the copy. - However, this is handled in expand_expr, and not here. - This is because much better code can be generated at - that stage than this one. */ - if (TREE_CODE (lhstype) == RECORD_TYPE - && TYPE_LANG_SPECIFIC (lhstype) - && TYPE_MAIN_VARIANT (lhstype) == TYPE_MAIN_VARIANT (TREE_TYPE (newrhs))) - { - register tree elt; - int i; - - /* Perform operation on object. */ - if (modifycode == INIT_EXPR && TYPE_HAS_INIT_REF (lhstype)) - { - result = build_method_call (lhs, DECL_NAME (TYPE_NAME (lhstype)), - build_tree_list (NULL_TREE, rhs), - basetype_path, LOOKUP_NORMAL); - return build_indirect_ref (result, 0); - } - else if (modifycode == NOP_EXPR) - { - /* `operator=' is not an inheritable operator. */ - if (TYPE_LANG_SPECIFIC (lhstype) && TYPE_HAS_ASSIGNMENT (lhstype)) - { - result = build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL, lhs, rhs, (tree)NOP_EXPR); - if (result == NULL_TREE) - return error_mark_node; - return result; - } - } - - if (TYPE_USES_VIRTUAL_BASECLASSES (lhstype) - || (modifycode == NOP_EXPR && TYPE_GETS_ASSIGNMENT (lhstype)) - || (modifycode == INIT_EXPR && TYPE_GETS_INIT_REF (lhstype))) - { - result = NULL_TREE; - - /* Perform operation on each member, depth-first, left-right. */ - for (i = 1; i <= CLASSTYPE_N_BASECLASSES (lhstype); i++) - { - tree base_lhs, base_rhs; - tree new_result; - - /* Assignments from virtual baseclasses handled elsewhere. */ - if (CLASSTYPE_VIA_VIRTUAL (lhstype, i)) - continue; - - base_lhs = get_base_ref (lhstype, i, lhs); - base_rhs = get_base_ref (lhstype, i, newrhs); - - new_result - = build_modify_expr_1 (base_lhs, modifycode, base_rhs, - tree_cons (NULL_TREE, - TREE_TYPE (base_lhs), - basetype_path)); - - /* We either get back a compound stmt, or a simple one. */ - if (new_result && TREE_CODE (new_result) == TREE_LIST) - new_result = build_compound_expr (new_result); - result = tree_cons (NULL_TREE, new_result, result); - } - - for (elt = TYPE_FIELDS (lhstype); elt; elt = TREE_CHAIN (elt)) - { - tree vbases = NULL_TREE; - tree elt_lhs, elt_rhs; - - if (TREE_CODE (elt) == VAR_DECL || TREE_CODE (elt) == CONST_DECL) - continue; - if (DECL_NAME (elt) - && (VFIELD_NAME_P (DECL_NAME (elt)) - || VBASE_NAME_P (DECL_NAME (elt)))) - continue; - - if (IS_AGGR_TYPE (TREE_TYPE (elt)) - && TYPE_LANG_SPECIFIC (TREE_TYPE (elt))) - vbases = CLASSTYPE_VBASECLASSES (TREE_TYPE (elt)); - - elt_lhs = build (COMPONENT_REF, TREE_TYPE (elt), lhs, elt); - elt_rhs = build (COMPONENT_REF, TREE_TYPE (elt), newrhs, elt); - /* It is not always safe to go through `build_modify_expr_1' - when performing element-wise copying. This is because - an element may be of ARRAY_TYPE, which will not - be properly copied as a naked element. */ - if (TREE_CODE (TREE_TYPE (elt)) == RECORD_TYPE - && TYPE_LANG_SPECIFIC (TREE_TYPE (elt))) - basetype_path = CLASSTYPE_AS_LIST (TREE_TYPE (elt)); - - while (vbases) - { - tree elt_lhs_addr = build_unary_op (ADDR_EXPR, elt_lhs); - tree elt_rhs_addr = build_unary_op (ADDR_EXPR, elt_rhs); - - elt_lhs_addr = convert_pointer_to (TREE_TYPE (vbases), elt_lhs_addr); - elt_rhs_addr = convert_pointer_to (TREE_TYPE (vbases), elt_rhs_addr); - result = tree_cons (NULL_TREE, build_modify_expr_1 (build_indirect_ref (elt_lhs_addr, 0), modifycode, build_indirect_ref (elt_rhs_addr, 0), basetype_path), result); - if (TREE_VALUE (result) == error_mark_node) - return error_mark_node; - vbases = TREE_CHAIN (vbases); - } - elt_lhs = build_modify_expr_1 (elt_lhs, modifycode, elt_rhs, - basetype_path); - result = tree_cons (NULL_TREE, elt_lhs, result); - } - - if (result) - return build_compound_expr (result); - /* No fields to move. */ - return integer_zero_node; - } - else - { - result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR, - void_type_node, lhs, rhs); - TREE_VOLATILE (result) = 1; - return result; - } - } - - return build_modify_expr (lhs, modifycode, newrhs); -} - -tree -build_modify_expr (lhs, modifycode, rhs) - tree lhs, rhs; - enum tree_code modifycode; -{ - register tree result; - tree newrhs = rhs; - tree lhstype = TREE_TYPE (lhs); - tree olhstype = lhstype; - - /* Types that aren't fully specified cannot be used in assignments. */ - lhs = require_complete_type (lhs); - - /* Avoid duplicate error messages from operands that had errors. */ - if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK) - return error_mark_node; - - /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. - Strip such NOP_EXPRs, since RHS is being used in non-lvalue context. */ - if (TREE_CODE (rhs) == NOP_EXPR - && TREE_TYPE (rhs) == TREE_TYPE (TREE_OPERAND (rhs, 0))) - rhs = TREE_OPERAND (rhs, 0); - - newrhs = rhs; - - /* Handle control structure constructs used as "lvalues". */ - - if (!pedantic) - switch (TREE_CODE (lhs)) - { - /* Handle (a, b) used as an "lvalue". */ - case COMPOUND_EXPR: - return build (COMPOUND_EXPR, lhstype, - TREE_OPERAND (lhs, 0), - build_modify_expr (TREE_OPERAND (lhs, 1), - modifycode, rhs)); - - /* Handle (a ? b : c) used as an "lvalue". */ - case COND_EXPR: - rhs = save_expr (rhs); - { - /* Produce (a ? (b = rhs) : (c = rhs)) - except that the RHS goes through a save-expr - so the code to compute it is only emitted once. */ - tree cond - = build_conditional_expr - (TREE_OPERAND (lhs, 0), - build_modify_expr (TREE_OPERAND (lhs, 1), - modifycode, rhs), - build_modify_expr (TREE_OPERAND (lhs, 2), - modifycode, rhs)); - /* Make sure the code to compute the rhs comes out - before the split. */ - return build (COMPOUND_EXPR, TREE_TYPE (lhs), - /* Case to void to suppress warning - from warn_if_unused_value. */ - convert (void_type_node, rhs), - cond); - } - } - - /* If a binary op has been requested, combine the old LHS value with the RHS - producing the value we should actually store into the LHS. */ - - if (modifycode == INIT_EXPR) - ; - else if (modifycode == NOP_EXPR) - { - /* must deal with overloading of `operator=' here. */ - if (TREE_CODE (lhstype) == REFERENCE_TYPE) - lhstype = TREE_TYPE (lhstype); -#if 1 - /* `operator=' is not an inheritable operator. */ - if (TYPE_LANG_SPECIFIC (lhstype) && TYPE_HAS_ASSIGNMENT (lhstype)) - { - result = build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL, lhs, rhs, (tree)NOP_EXPR); - if (result == NULL_TREE) - return error_mark_node; - return result; - } -#else - /* Treat `operator=' as an inheritable operator. */ - if (TYPE_LANG_SPECIFIC (lhstype) && TYPE_GETS_ASSIGNMENT (lhstype)) - { - tree orig_lhstype = lhstype; - while (! TYPE_HAS_ASSIGNMENT (lhstype)) - { - int i; - tree basetype = NULL_TREE; - for (i = 1; i <= CLASSTYPE_N_BASECLASSES (lhstype); i++) - if (TYPE_GETS_ASSIGNMENT (CLASSTYPE_BASECLASS (lhstype, i))) - { - if (basetype != NULL_TREE) - { - message_2_types (error, "base classes `%s' and `%s' both have operator ='", - basetype, - CLASSTYPE_BASECLASS (lhstype, i)); - return error_mark_node; - } - basetype = CLASSTYPE_BASECLASS (lhstype, i); - } - lhstype = basetype; - } - if (orig_lhstype != lhstype) - { - lhs = build_indirect_ref (convert_pointer_to (lhstype, - build_unary_op (ADDR_EXPR, lhs, 0)), 0); - if (lhs == error_mark_node) - { - error_with_aggr_type (lhstype, "conversion to private basetype `%s'"); - return error_mark_node; - } - } - result = build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL, lhs, rhs, (tree)NOP_EXPR); - if (result == NULL_TREE) - return error_mark_node; - return result; - } -#endif - lhstype = olhstype; - } - else if (IS_AGGR_TYPE (lhstype) - || (TREE_CODE (lhstype) == REFERENCE_TYPE - && IS_AGGR_TYPE (TREE_TYPE (lhstype)))) - { - /* This case must convert to some sort of lvalue that - can participate in a op= operation. */ - tree lhs_tmp = lhs; - tree rhs_tmp = rhs; - if (build_default_binary_type_conversion (modifycode, &lhs_tmp, &rhs_tmp)) - { - lhs = stabilize_reference (lhs_tmp); - /* Forget is was ever anything else. */ - olhstype = lhstype = TREE_TYPE (lhs); - newrhs = build_binary_op (modifycode, lhs, rhs_tmp); - } - else - return error_mark_node; - } - else - { - lhs = stabilize_reference (lhs); - newrhs = build_binary_op (modifycode, lhs, rhs); - } - - /* Handle a cast used as an "lvalue". - We have already performed any binary operator using the value as cast. - Now convert the result to the true type of the lhs and store there; - then cast the result back to the specified type to be the value - of the assignment. */ - - if (!pedantic) - switch (TREE_CODE (lhs)) - { - case NOP_EXPR: - case CONVERT_EXPR: - case FLOAT_EXPR: - case FIX_TRUNC_EXPR: - case FIX_FLOOR_EXPR: - case FIX_ROUND_EXPR: - case FIX_CEIL_EXPR: - if (TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE (newrhs)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (newrhs)) == METHOD_TYPE - || TREE_CODE (TREE_TYPE (newrhs)) == OFFSET_TYPE) - newrhs = default_conversion (newrhs); - { - tree inner_lhs = TREE_OPERAND (lhs, 0); - tree result = build_modify_expr (inner_lhs, NOP_EXPR, - convert (TREE_TYPE (inner_lhs), - newrhs)); - return convert (TREE_TYPE (lhs), result); - } - } - - if (TREE_CODE (lhs) == OFFSET_REF) - if (TREE_OPERAND (lhs, 0) == NULL_TREE) - { - /* Static class member? */ - tree member = TREE_OPERAND (lhs, 1); - if (TREE_CODE (member) == VAR_DECL) - lhs = member; - else - { - compiler_error ("invalid static class member"); - return error_mark_node; - } - } - else - { - tree base = build_unary_op (ADDR_EXPR, TREE_OPERAND (lhs, 0), 0); - tree member = build_unary_op (ADDR_EXPR, TREE_OPERAND (lhs, 1), 0); - - if (TREE_CODE (base) == ERROR_MARK - || TREE_CODE (member) == ERROR_MARK) - return error_mark_node; - lhs = build_indirect_ref (build (PLUS_EXPR, build_pointer_type (TREE_TYPE (lhs)), - base, member)); - } - - /* Now we have handled acceptable kinds of LHS that are not truly lvalues. - Reject anything strange now. */ - - if (!lvalue_or_else (lhs, "assignment")) - return error_mark_node; - -#ifdef FIELD_XREF - FIELD_xref_assign(lhs); -#endif - - /* Warn about storing in something that is `const'. */ - /* For C++, don't warn if this is initialization. */ - if (modifycode != INIT_EXPR - && (TREE_READONLY (lhs) - || ((TREE_CODE (lhstype) == RECORD_TYPE - || TREE_CODE (lhstype) == UNION_TYPE) - && C_TYPE_FIELDS_READONLY (lhstype)) - || (TREE_CODE (lhstype) == REFERENCE_TYPE - && TREE_READONLY (TREE_TYPE (lhstype))))) - readonly_warning_or_error (lhs, "assignment"); - - /* If storing into a structure or union member, - it has probably been given type `int'. - Compute the type that would go with - the actual amount of storage the member occupies. */ - - if (TREE_CODE (lhs) == COMPONENT_REF - && (TREE_CODE (lhstype) == INTEGER_TYPE - || TREE_CODE (lhstype) == REAL_TYPE - || TREE_CODE (lhstype) == ENUMERAL_TYPE)) - lhstype = TREE_TYPE (get_unwidened (lhs, 0)); - - /* check to see if there is an assignment to `this' */ - if (lhs == current_class_decl) - { - if (flag_this_is_variable - && current_class_name != DECL_ORIGINAL_NAME (current_function_decl)) - warning ("assignment to `this' not in constructor or destructor"); - current_function_just_assigned_this = 1; - } - - /* The TREE_TYPE of RHS may be TYPE_UNKNOWN. This can happen - when the type of RHS is not yet known, i.e. its type - is inherited from LHS. */ - rhs = require_instantiated_type (lhstype, newrhs, error_mark_node); - if (rhs == error_mark_node) - return error_mark_node; - newrhs = rhs; - - if (modifycode != INIT_EXPR) - { - /* Make modifycode now either a NOP_EXPR or an INIT_EXPR. */ - modifycode = NOP_EXPR; - /* Reference-bashing */ - if (TREE_CODE (lhstype) == REFERENCE_TYPE) - { - tree tmp = convert_from_reference (lhs); - lhstype = TREE_TYPE (tmp); - if (TYPE_SIZE (lhstype) == 0) - { - incomplete_type_error (lhs, lhstype); - return error_mark_node; - } - lhs = tmp; - olhstype = lhstype; - } - if (TREE_CODE (TREE_TYPE (newrhs)) == REFERENCE_TYPE) - { - tree tmp = convert_from_reference (newrhs); - if (TYPE_SIZE (TREE_TYPE (tmp)) == 0) - { - incomplete_type_error (newrhs, TREE_TYPE (tmp)); - return error_mark_node; - } - newrhs = tmp; - } - } - - if (TREE_VOLATILE (lhs)) - lhs = stabilize_reference (lhs); - if (TREE_VOLATILE (newrhs)) - newrhs = stabilize_reference (newrhs); - - /* C++: The semantics of C++ differ from those of C when an - assignment of an aggregate is desired. Assignment in C++ is - now defined as memberwise assignment of non-static members - and base class objects. This rule applies recursively - until a member of a built-in type is found. - - Also, we cannot do a bit-wise copy of aggregates which - contain virtual function table pointers. Those - pointer values must be preserved through the copy. - However, this is handled in expand_expr, and not here. - This is because much better code can be generated at - that stage than this one. */ - if (TREE_CODE (lhstype) == RECORD_TYPE - && ((TYPE_USES_VIRTUAL_BASECLASSES (lhstype) - || (modifycode != INIT_EXPR && TYPE_GETS_ASSIGNMENT (lhstype)) - || (modifycode == INIT_EXPR && TYPE_GETS_INIT_REF (lhstype))) - && (TYPE_MAIN_VARIANT (lhstype) - == TYPE_MAIN_VARIANT (TREE_TYPE (newrhs)) - || (TREE_CODE (TREE_TYPE (newrhs)) == RECORD_TYPE - && get_base_type (lhstype, TREE_TYPE (newrhs), 0))))) - { - tree vbases = CLASSTYPE_VBASECLASSES (lhstype); - tree lhs_addr = build_unary_op (ADDR_EXPR, lhs); - tree rhs_addr = build_unary_op (ADDR_EXPR, newrhs); - result = NULL_TREE; - if (! comptypes (TREE_TYPE (lhs_addr), TREE_TYPE (rhs_addr), 1)) - { - rhs_addr = convert_pointer_to (TREE_TYPE (TREE_TYPE (lhs_addr)), rhs_addr); - newrhs = build_indirect_ref (rhs_addr, 0); - } - - while (vbases) - { - tree elt_lhs = convert_pointer_to (TREE_TYPE (vbases), lhs_addr); - tree elt_rhs = convert_pointer_to (TREE_TYPE (vbases), rhs_addr); - result = tree_cons (NULL_TREE, build_modify_expr_1 (build_indirect_ref (elt_lhs, 0), modifycode, build_indirect_ref (elt_rhs, 0), CLASSTYPE_AS_LIST (lhstype)), result); - if (TREE_VALUE (result) == error_mark_node) - return error_mark_node; - vbases = TREE_CHAIN (vbases); - } - result = tree_cons (NULL_TREE, - build_modify_expr_1 (lhs, modifycode, newrhs, CLASSTYPE_AS_LIST (lhstype)), - result); - return build_compound_expr (result); - } - - /* If storing in a field that is in actuality a short or narrower than one, - we must store in the field in its actual type. */ - - if (lhstype != TREE_TYPE (lhs)) - { - lhs = copy_node (lhs); - TREE_TYPE (lhs) = lhstype; - } - - /* Convert new value to destination type. */ - - if (modifycode == INIT_EXPR) - { - newrhs = convert_for_initialization (lhs, lhstype, newrhs, "assignment", LOOKUP_NORMAL); - if (lhs == DECL_RESULT (current_function_decl)) - { - if (DECL_INITIAL (lhs)) - warning ("return value from function receives multiple initializations"); - DECL_INITIAL (lhs) = newrhs; - } - } - else - { - if (IS_AGGR_TYPE (lhstype)) - { - if (TYPE_GETS_ASSIGNMENT (lhstype) - && ! TYPE_HAS_ASSIGNMENT (lhstype)) - { - error_with_aggr_type (lhstype, "assignment not defined for type `%s'"); - return error_mark_node; - } - if (result = build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL, lhs, newrhs, NOP_EXPR)) - return result; - } - else if (TREE_CODE (lhstype) == ARRAY_TYPE) - { - /* Have to wrap this in RTL_EXPR for two cases: - in base or member initialization and if we - are a branch of a ?: operator. Since we - can't easily know the latter, just do it always. */ - - extern struct rtx_def *get_insns (), *const0_rtx; - result = make_node (RTL_EXPR); - - TREE_TYPE (result) = void_type_node; - do_pending_stack_adjust (); - start_sequence (); - - /* As a matter of principle, `start_sequence' should do this. */ - emit_note (0, -1); - - expand_vec_init (lhs, lhs, array_type_nelts (lhstype), newrhs, 2); - - do_pending_stack_adjust (); - - TREE_VOLATILE (result) = 1; - RTL_EXPR_SEQUENCE (result) = get_insns (); - RTL_EXPR_RTL (result) = const0_rtx; - end_sequence (); - return result; - } - newrhs = convert_for_assignment (lhstype, newrhs, "assignment"); - if (flag_elide_constructors == 0 - && TREE_CODE (newrhs) == CALL_EXPR - && TREE_ADDRESSABLE (lhstype)) - { - /* Can't initialized directly from a CALL_EXPR, since - we don't know about what doesn't alias what. */ - - if (TYPE_NEEDS_DESTRUCTOR (lhstype)) - newrhs = cleanup_after_call (newrhs); - else - { - tree temp = get_temp_name (lhstype, 0); - newrhs = build (COMPOUND_EXPR, lhstype, - build_modify_expr (temp, INIT_EXPR, newrhs), - temp); - } - } - } - - if (TREE_CODE (newrhs) == ERROR_MARK) - return error_mark_node; - - result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR, - lhstype, lhs, newrhs); - TREE_VOLATILE (result) = 1; - - /* If we got the LHS in a different type for storing in, - convert the result back to the nominal type of LHS - so that the value we return always has the same type - as the LHS argument. */ - - if (olhstype == TREE_TYPE (result)) - return result; - return convert_for_assignment (olhstype, result, "assignment"); -} - - -/* Return 0 if EXP is not a valid lvalue in this language - even though `lvalue_or_else' would accept it. */ - -int -language_lvalue_valid (exp) - tree exp; -{ - return 1; -} - -/* Convert value RHS to type TYPE as preparation for an assignment - to an lvalue of type TYPE. - The real work of conversion is done by `convert'. - The purpose of this function is to generate error messages - for assignments that are not allowed in C. - ERRTYPE is a string to use in error messages: - "assignment", "return", etc. - - C++: attempts to allow `convert' to find conversions involving - implicit type conversion between aggregate and scalar types - as per 8.5.6 of C++ manual. Does not randomly dereference - pointers to aggregates! */ - -static tree -convert_for_assignment (type, rhs, errtype) - tree type, rhs; - char *errtype; -{ - register enum tree_code codel = TREE_CODE (type); - register tree rhstype = datatype (rhs); - register enum tree_code coder = TREE_CODE (rhstype); - - if (coder == UNKNOWN_TYPE) - { - rhs = instantiate_type (type, rhs, 1); - rhstype = TREE_TYPE (rhs); - coder = TREE_CODE (rhstype); - } - - if (coder == ERROR_MARK) - return error_mark_node; - - if (codel == OFFSET_TYPE) - { - type = TREE_TYPE (type); - codel = TREE_CODE (type); - } - - /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. - Strip such NOP_EXPRs, since RHS is used in non-lvalue context. */ - if (TREE_CODE (rhs) == NOP_EXPR - && TREE_TYPE (rhs) == TREE_TYPE (TREE_OPERAND (rhs, 0))) - rhs = TREE_OPERAND (rhs, 0); - - if (TREE_CODE (TREE_TYPE (rhs)) == OFFSET_TYPE) - { - rhs = resolve_offset_ref (rhs); - if (rhs == error_mark_node) - return error_mark_node; - rhstype = TREE_TYPE (rhs); - coder = TREE_CODE (rhstype); - } - - if (TREE_CODE (TREE_TYPE (rhs)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE) - { - rhs = default_conversion (rhs); - if (rhs == error_mark_node) - return rhs; - } - else if (coder == REFERENCE_TYPE) - { - rhs = convert_from_reference (rhs); - rhstype = TREE_TYPE (rhs); - coder = TREE_CODE (rhstype); - } - - /* This should no longer change types on us. */ - if (TREE_CODE (rhs) == CONST_DECL) - rhs = DECL_INITIAL (rhs); - else if (TREE_READONLY_DECL_P (rhs)) - rhs = decl_constant_value (rhs); - - if (type == rhstype) - return rhs; - - if (coder == VOID_TYPE) - { - error ("void value not ignored as it ought to be"); - return error_mark_node; - } - /* Arithmetic types all interconvert. */ - if ((codel == INTEGER_TYPE || codel == REAL_TYPE) - && (coder == INTEGER_TYPE || coder == REAL_TYPE)) - { - /* But we should warn if assigning REAL_TYPE to INTEGER_TYPE. */ - if (coder == REAL_TYPE && codel == INTEGER_TYPE) - warning ("float or double assigned to integer data type"); - /* And we should warn if assigning a negative value to - an unsigned variable. */ - else if (TREE_UNSIGNED (type)) - { - if (TREE_CODE (rhs) == INTEGER_CST - && TREE_NEGATED_INT (rhs)) - warning ("negative value assigned to unsigned quantity"); - if (TREE_LITERAL (rhs)) - rhs = fold (rhs); - } - - return convert (type, rhs); - } - /* Conversions involving enums. */ - else if ((codel == ENUMERAL_TYPE - && (coder == ENUMERAL_TYPE || coder == INTEGER_TYPE || coder == REAL_TYPE)) - || (coder == ENUMERAL_TYPE - && (codel == ENUMERAL_TYPE || codel == INTEGER_TYPE || codel == REAL_TYPE))) - { - extern int warn_enum_clash; - - if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype)) - return convert (type, rhs); - if (warn_enum_clash) - { - if (codel == ENUMERAL_TYPE && coder == ENUMERAL_TYPE) - message_2_types (warning, "conversion between incompatible enumeral types `%s' and `%s'", - type, rhstype); - else if (coder == REAL_TYPE) - warning ("float or double assigned to enumeral data type"); - else if (codel == REAL_TYPE) - warning ("enumeral value assigned to real data type"); - else if (coder == INTEGER_TYPE) - warning ("assignment of integer to enumeral data type"); - } - return convert (type, rhs); - } - /* Conversions among pointers */ - else if (codel == POINTER_TYPE && coder == POINTER_TYPE) - { - register tree ttl = TREE_TYPE (type); - register tree ttr = TREE_TYPE (rhstype); - - /* If both pointers are of aggregate type, then we - can give better error messages, and save some work - as well. */ - if (IS_AGGR_TYPE (ttl) && IS_AGGR_TYPE (ttr)) - { - tree basetype; - - if (TYPE_MAIN_VARIANT (ttl) == TYPE_MAIN_VARIANT (ttr)) - basetype = ttl; - else - basetype = get_base_type (ttl, ttr, 1); - - if (basetype == error_mark_node) - return error_mark_node; - if (basetype == 0) - { - error_not_base_type (ttl, ttr); - return error_mark_node; - } - if (! TREE_READONLY (ttl) && TREE_READONLY (ttr)) - warning ("%s of non-const * pointer from const *", errtype); - if (! TREE_VOLATILE (ttl) && TREE_VOLATILE (ttr)) - warning ("%s of non-volatile * pointer from volatile *", errtype); - } - /* Any non-function converts to a [const][volatile] void * - and vice versa; otherwise, targets must be the same. - Meanwhile, the lhs target must have all the qualifiers of the rhs. */ - else if (TYPE_MAIN_VARIANT (ttl) == void_type_node - || TYPE_MAIN_VARIANT (ttr) == void_type_node - || comp_target_types (type, rhstype, 1)) - { - if (pedantic - && ((TYPE_MAIN_VARIANT (ttl) == void_type_node - && (TREE_CODE (ttr) == FUNCTION_TYPE - || TREE_CODE (ttr) == METHOD_TYPE)) - || - (TYPE_MAIN_VARIANT (ttr) == void_type_node - && (TREE_CODE (ttl) == FUNCTION_TYPE - || TREE_CODE (ttl) == METHOD_TYPE)))) - warning ("%s between incompatible pointer types", errtype); - else - { - if (TREE_CODE (ttl) == OFFSET_TYPE - && virtual_member (TYPE_OFFSET_BASETYPE (ttr), - CLASSTYPE_VBASECLASSES (TYPE_OFFSET_BASETYPE (ttl)))) - { - sorry ("%s between pointer to members converting across virtual baseclasses", errtype); - return error_mark_node; - } - if (! TREE_READONLY (ttl) && TREE_READONLY (ttr)) - warning ("%s of non-const * pointer from const *", errtype); - if (! TREE_VOLATILE (ttl) && TREE_VOLATILE (ttr)) - warning ("%s of non-volatile * pointer from volatile *", errtype); - } - } - else if (TREE_CODE (ttr) == OFFSET_TYPE - && TREE_CODE (ttl) != OFFSET_TYPE) - { - /* Normally, pointers to different type codes (other - than void) are not compatible, but we perform - some type instantiation if that resolves the - ambiguity of (X Y::*) and (X *). */ - - if (current_class_decl) - { - if (TREE_CODE (rhs) == INTEGER_CST) - { - rhs = build (PLUS_EXPR, build_pointer_type (TREE_TYPE (ttr)), - current_class_decl, rhs); - return convert_for_assignment (type, rhs, errtype); - } - } - if (TREE_CODE (ttl) == METHOD_TYPE) - error ("%s between pointer-to-method and pointer-to-member types", errtype); - else - error ("%s between pointer and pointer-to-member types", errtype); - return error_mark_node; - } - else - { - int const_parity = TREE_READONLY (type) ^ TREE_READONLY (rhstype); - int volatile_parity = TREE_VOLATILE (type) ^ TREE_VOLATILE (rhstype); - int unsigned_parity; - int nptrs = 0; - - while (TREE_CODE (ttl) == POINTER_TYPE - && TREE_CODE (ttr) == POINTER_TYPE) - { - nptrs -= 1; - const_parity |= TREE_READONLY (ttl) ^ TREE_READONLY (ttr); - volatile_parity |= TREE_VOLATILE (ttl) ^ TREE_VOLATILE (ttr); - ttl = TREE_TYPE (ttl); - ttr = TREE_TYPE (ttr); - } - unsigned_parity = TREE_UNSIGNED (ttl) - TREE_UNSIGNED (ttr); - if (unsigned_parity) - if (TREE_UNSIGNED (ttl)) - ttr = unsigned_type (ttr); - else - ttl = unsigned_type (ttl); - - if (comp_target_types (ttl, ttr, nptrs)) - { - if (const_parity) - warning ("%s of non-const * pointer from const *", errtype); - if (volatile_parity) - warning ("%s of non-volatile * pointer from volatile *", errtype); - if (unsigned_parity > 0) - warning ("%s of unsigned pointer from signed pointer", errtype); - else if (unsigned_parity < 0) - warning ("%s of signed pointer from unsigned pointer", errtype); - - /* C++ is not so friendly about converting function and - member function pointers as C. Emit warnings here. */ - if (TREE_CODE (ttl) == FUNCTION_TYPE - || TREE_CODE (ttl) == METHOD_TYPE) - if (! comptypes (ttl, ttr, 0)) - { - char lhsbuf[2048]; - char rhsbuf[2048]; - tree null_name = get_identifier (""); - tree lhs = build_decl (FUNCTION_DECL, null_name, ttl); - tree rhs = build_decl (FUNCTION_DECL, null_name, ttr); - fndecl_as_string (lhsbuf, 0, lhs, 1); - fndecl_as_string (rhsbuf, 0, rhs, 1); - warning ("conflicting function types in %s:", errtype); - warning ("\t`%s' != `%s'", lhsbuf, rhsbuf); - } - } - else if (TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE) - { - /* When does this happen? */ - abort (); - /* Conversion of a pointer-to-member type to void *. */ - rhs = build_unary_op (ADDR_EXPR, rhs, 0); - TREE_TYPE (rhs) = type; - return rhs; - } - else if (TREE_CODE (TREE_TYPE (rhs)) == OFFSET_TYPE) - { - /* When does this happen? */ - abort (); - /* Conversion of a pointer-to-member type to void *. */ - rhs = build_unary_op (ADDR_EXPR, rhs, 0); - TREE_TYPE (rhs) = type; - return rhs; - } - else - { - error ("%s between incompatible pointer types", errtype); - return error_mark_node; - } - } - return convert (type, rhs); - } - else if (codel == POINTER_TYPE && coder == INTEGER_TYPE) - { - if (! integer_zerop (rhs)) - { - warning ("%s of pointer from integer lacks a cast", errtype); - return convert (type, rhs); - } - return null_pointer_node; - } - else if (codel == INTEGER_TYPE && coder == POINTER_TYPE) - { - warning ("%s of integer from pointer lacks a cast", errtype); - return convert (type, rhs); - } - - /* C++ */ - else if (codel == ERROR_MARK || coder == ERROR_MARK) - return error_mark_node; - - /* This should no longer happen. References are initialzed via - `convert_for_initialization'. They should otherwise be - bashed before coming here. */ - else if (codel == REFERENCE_TYPE) - assert (codel != REFERENCE_TYPE); - else if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (rhs))) - return build1 (NOP_EXPR, type, rhs); - else if (TYPE_HAS_CONSTRUCTOR (type) || IS_AGGR_TYPE (TREE_TYPE (rhs))) - return convert (type, rhs); - - error ("incompatible types in %s", errtype); - return error_mark_node; -} - -/* Convert RHS to be of type TYPE. If EXP is non-zero, - it is the target of the initialization. - ERRTYPE is a string to use in error messages. - - Two major differences between the behavior of - `convert_for_assignment' and `convert_for_initialization' - are that references are bashed in the former, while - copied in the latter, and aggregates are assigned in - the former (operator=) while initialized in the - latter (X(X&)). */ -tree -convert_for_initialization (exp, type, rhs, errtype, flags) - tree exp, type, rhs; - char *errtype; - int flags; -{ - register enum tree_code codel = TREE_CODE (type); - register tree rhstype; - register enum tree_code coder; - - /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. - Strip such NOP_EXPRs, since RHS is used in non-lvalue context. */ - if (TREE_CODE (rhs) == NOP_EXPR - && TREE_TYPE (rhs) == TREE_TYPE (TREE_OPERAND (rhs, 0))) - rhs = TREE_OPERAND (rhs, 0); - - if (TREE_CODE (TREE_TYPE (rhs)) == OFFSET_TYPE) - { - rhs = resolve_offset_ref (rhs); - if (rhs == error_mark_node) - return error_mark_node; - rhstype = TREE_TYPE (rhs); - coder = TREE_CODE (rhstype); - } - - if ((TREE_CODE (TREE_TYPE (rhs)) == ARRAY_TYPE - && TREE_CODE (type) != ARRAY_TYPE && TREE_CODE (type) != REFERENCE_TYPE) - || TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE - || TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE) - rhs = default_conversion (rhs); - - rhstype = TREE_TYPE (rhs); - coder = TREE_CODE (rhstype); - - if (coder == UNKNOWN_TYPE) - { - rhs = instantiate_type (type, rhs, 1); - rhstype = TREE_TYPE (rhs); - coder = TREE_CODE (rhstype); - } - - if (coder == ERROR_MARK) - return error_mark_node; - -#if 0 - /* This is *not* the quick way out! It is the way to disaster. */ - if (type == rhstype) - goto converted; -#endif - - /* We accept references to incomplete types, so we can - return here before checking if RHS is of complete type. */ - - if (codel == REFERENCE_TYPE) - return convert_to_reference ((exp ? exp : error_mark_node), type, rhs, 0, flags); - - rhs = require_complete_type (rhs); - if (rhs == error_mark_node) - return error_mark_node; - - if (exp != 0) exp = require_complete_type (exp); - if (exp == error_mark_node) - return error_mark_node; - - if (TREE_CODE (rhstype) == REFERENCE_TYPE) - rhstype = TREE_TYPE (rhstype); - - if (IS_AGGR_TYPE (type) && TYPE_NEEDS_CONSTRUCTOR (type)) - { - if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype)) - { - /* This is sufficient to perform initialization. No need, apparently, - to go through X(X&) to do first-cut initialization. Return through - a NEW_EXPR so that we get cleanups if it is used. */ - if (TREE_CODE (rhs) == CALL_EXPR) - { - rhs = build_cplus_new (type, rhs); - return rhs; - } - } - if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype) - || (IS_AGGR_TYPE (rhstype) && get_base_type (type, rhstype, 0))) - { - if (TYPE_HAS_INIT_REF (type)) - { - tree init = build_method_call (exp, DECL_NAME (TYPE_NAME (type)), - build_tree_list (NULL_TREE, rhs), - NULL_TREE, LOOKUP_NORMAL); - - if (init == error_mark_node) - return error_mark_node; - - if (exp == 0) - { - exp = build_cplus_new (type, init); - return exp; - } - - return build (COMPOUND_EXPR, type, init, exp); - } - - if (TYPE_GETS_ASSIGNMENT (type)) - warning ("bitwise copy: `%s' defines operator=()", - TYPE_NAME_STRING (type)); - - if (TREE_CODE (TREE_TYPE (rhs)) == REFERENCE_TYPE) - rhs = convert_from_reference (rhs); - if (type != rhstype) - return build1 (NOP_EXPR, type, rhs); - return rhs; - } - - return convert (type, rhs); - } - if (TYPE_LANG_SPECIFIC (type) && TYPE_GETS_ASSIGNMENT (type)) - warning ("bitwise copy: `%s' defines operator=()", - TYPE_NAME_STRING (type)); - - converted: - if (type == TREE_TYPE (rhs)) - { - if (TREE_READONLY_DECL_P (rhs)) - rhs = decl_constant_value (rhs); - return rhs; - } - - return convert_for_assignment (type, rhs, errtype); -} - -/* Expand an ASM statement with operands, handling output operands - that are not variables or INDIRECT_REFS by transforming such - cases into cases that expand_asm_operands can handle. - - Arguments are same as for expand_asm_operands. */ - -void -c_expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line) - tree string, outputs, inputs, clobbers; - int vol; - char *filename; - int line; -{ - int noutputs = list_length (outputs); - register int i; - /* o[I] is the place that output number I should be written. */ - register tree *o = (tree *) alloca (noutputs * sizeof (tree)); - register tree tail; - - /* Record the contents of OUTPUTS before it is modifed. */ - for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++) - o[i] = TREE_VALUE (tail); - -#if 0 /* Don't do this--it screws up operands expected to be in memory. */ - /* Perform default conversions on all inputs. */ - for (i = 0, tail = inputs; tail; tail = TREE_CHAIN (tail), i++) - TREE_VALUE (tail) = default_conversion (TREE_VALUE (tail)); -#endif - - /* Generate the ASM_OPERANDS insn; - store into the TREE_VALUEs of OUTPUTS some trees for - where the values were actually stored. */ - expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line); - - /* Copy all the intermediate outputs into the specified outputs. */ - for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++) - { - extern struct rtx_def *const0_rtx; - - if (o[i] != TREE_VALUE (tail)) - expand_expr (build_modify_expr (o[i], NOP_EXPR, TREE_VALUE (tail)), - const0_rtx, VOIDmode, 0); - /* Detect modification of read-only values. - (Otherwise done by build_modify_expr.) */ - else - { - tree type = TREE_TYPE (o[i]); - if (TREE_READONLY (o[i]) - || ((TREE_CODE (type) == RECORD_TYPE - || TREE_CODE (type) == UNION_TYPE) - && C_TYPE_FIELDS_READONLY (type))) - readonly_warning_or_error (o[i], "modification by `asm'"); - } - } - - /* Those MODIFY_EXPRs could do autoincrements. */ - emit_queue (); -} - -/* Expand a C `return' statement. - RETVAL is the expression for what to return, - or a null pointer for `return;' with no value. - - C++: upon seeing a `return', we must call destructors on all - variables in scope which had constructors called on them. - This means that if in a destructor, the base class destructors - must be called before returning. - - The RETURN statement in C++ has initialization semantics. */ - -void -c_expand_return (retval) - tree retval; -{ - extern struct rtx_def *original_result_rtx; - extern tree dtor_label, ctor_label; - tree result = DECL_RESULT (current_function_decl); - tree valtype = TREE_TYPE (result); - tree save_from_destructor = NULL_TREE; - - if (TREE_THIS_VOLATILE (current_function_decl)) - warning ("function declared `volatile' has a `return' statement"); - - if (retval == error_mark_node) - { - current_function_returns_null = 1; - return; - } - - if (retval == NULL_TREE) - { - /* A non-named return value does not count. */ - extern tree value_identifier; - - /* Can't just return from a destructor. */ - if (dtor_label) - { - expand_goto (dtor_label); - return; - } - - if (DECL_CONSTRUCTOR_P (current_function_decl)) - retval = current_class_decl; - else if (result != NULL_TREE - && DECL_NAME (result) != value_identifier - && TREE_CODE (valtype) != VOID_TYPE) - retval = result; - else - { - current_function_returns_null = 1; - if (valtype != 0 && TREE_CODE (valtype) != VOID_TYPE) - { - extern tree value_identifier; - if (DECL_NAME (DECL_RESULT (current_function_decl)) == value_identifier) - warning ("`return' with no value, in function returning non-void"); - } - - expand_null_return (); - return; - } - } - - if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE) - { - current_function_returns_null = 1; - if (pedantic || TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE) - warning ("`return' with a value, in function returning void"); - expand_return (retval); - } - else - { - register tree t; - register int use_temp = 0; - - if (retval == result) - ; - else if (IS_AGGR_TYPE (valtype) && TYPE_NEEDS_CONSTRUCTOR (valtype)) - { - expand_aggr_init (result, retval, 0); - save_from_destructor = DECL_INITIAL (result); - DECL_INITIAL (result) = NULL_TREE; - retval = 0; - } - else - { - /* Watch out for constructors, which "return" aggregates - via initialization, but which otherwise "return" a pointer. */ - if (DECL_CONSTRUCTOR_P (current_function_decl)) - { - if (retval != current_class_decl) - { - error ("return from a constructor: use `this = ...' instead"); - retval = current_class_decl; - } - } - else - { - retval = convert_for_initialization (result, valtype, retval, "return", LOOKUP_NORMAL); - if (retval == error_mark_node) - return; - save_from_destructor = DECL_INITIAL (result); - DECL_INITIAL (result) = NULL_TREE; - } - - /* Add some useful error checking for C++. */ - if (TREE_CODE (valtype) == REFERENCE_TYPE) - { - tree whats_returned = retval; - - /* Sort through common things to see what it is - we are returning. */ - if (TREE_CODE (retval) == COMPOUND_EXPR) - { - whats_returned = TREE_OPERAND (retval, 1); - if (TREE_CODE (whats_returned) == ADDR_EXPR) - whats_returned = TREE_OPERAND (whats_returned, 0); - } - if (TREE_CODE (retval) == VAR_DECL) - whats_returned = retval; - else if (TREE_CODE (retval) == ADDR_EXPR) - { - whats_returned = TREE_OPERAND (retval, 0); - if (TREE_CODE (whats_returned) == NEW_EXPR) - /* Get the target. */ - whats_returned = TREE_OPERAND (whats_returned, 0); - } - - if (TREE_CODE (whats_returned) == VAR_DECL) - if (DECL_NAME (whats_returned) == NULL_TREE - || TEMP_NAME_P (DECL_NAME (whats_returned))) - warning ("reference to non-lvalue returned"); - else if (! TREE_STATIC (whats_returned) - && IDENTIFIER_LOCAL_VALUE (DECL_NAME (whats_returned))) - warning_with_decl (whats_returned, "reference to local variable `%s' returned"); - } - } - - /* Now deal with possible C++ hair: - (1) Compute the return value. - (2) If there are aggregate values with destructors which - must be cleaned up, clean them (taking care - not to clobber the return value). - (3) If an X(X&) constructor is defined, the return - value must be returned via that. */ - - /* Keep anybody from thinking that our return value - is up for grabs (i.e., later inline function expansion). - We cannot use a `save_expr' here, because the - return value must be calculated _now_, - and wrapping it in a SAVE_EXPR just make it - be calculated _once_. - - We look up the binding contours to see whether there are - any cleanups to perform to avoid, where possible, the need - to pass the value through a temporary. This is needed to make - tail-recursion work in GCC. */ - /* use_variable (DECL_RTL (result)); */ - - if (retval && TYPE_MODE (valtype) != BLKmode - && any_pending_cleanups ()) - { - t = get_temp_regvar (valtype, retval); - use_temp = obey_regdecls; - } - else - t = retval; - - emit_queue (); - - if (t == result) - { - if (original_result_rtx) - store_expr (result, original_result_rtx, 0); - use_variable (DECL_RTL (t)); - if (ctor_label) - expand_goto (ctor_label); - else - expand_null_return (); - } - else - { - if (original_result_rtx) - { - if (t) - expand_assignment (result, t, 0, 0); - else - store_expr (result, original_result_rtx, 0); - result = build (SAVE_EXPR, TREE_TYPE (result), - error_mark_node, original_result_rtx); - } - - if (ctor_label) - { - result = build (INIT_EXPR, TREE_TYPE (result), result, t); - TREE_VOLATILE (result) = 1; - expand_expr_stmt (result); - expand_goto (ctor_label); - } - else if (t) - { - result = build (INIT_EXPR, TREE_TYPE (result), result, t); - TREE_VOLATILE (result) = 1; - expand_return (result); - } - else - expand_return (result); - } - - current_function_returns_value = 1; - if (original_result_rtx) - use_variable (original_result_rtx); - if (use_temp) - use_variable (DECL_RTL (t)); - } - /* One way to clear out cleanups that EXPR might - generate. Note that this code will really be - dead code, but that is ok--cleanups that were - needed were handled by the magic of `return'. */ - expand_cleanups_to (NULL_TREE); -} - -/* Start a C switch statement, testing expression EXP. - Return EXP if it is valid, an error node otherwise. */ - -tree -c_expand_start_case (exp) - tree exp; -{ - tree type = TREE_TYPE (exp); - register enum tree_code code = TREE_CODE (type); - - if (IS_AGGR_TYPE_CODE (code)) - exp = build_type_conversion (CONVERT_EXPR, integer_type_node, exp, 1); - else - exp = default_conversion (exp); - type = TREE_TYPE (exp); - code = TREE_CODE (type); - - if (code != INTEGER_TYPE && code != ENUMERAL_TYPE && code != ERROR_MARK) - { - error ("switch quantity not an integer"); - exp = error_mark_node; - } - else - { - tree index; - - index = get_unwidened (exp, 0); - /* We can't strip a conversion from a signed type to an unsigned, - because if we did, int_fits_type_p would do the wrong thing - when checking case values for being in range, - and it's too hard to do the right thing. */ - if (TREE_UNSIGNED (TREE_TYPE (exp)) - == TREE_UNSIGNED (TREE_TYPE (index))) - exp = index; - } - - expand_start_case (1, exp, type); - - return exp; -} diff --git a/gnu/usr.bin/g++/cc1plus/dbxout.c b/gnu/usr.bin/g++/cc1plus/dbxout.c deleted file mode 100644 index f8fe3516288a..000000000000 --- a/gnu/usr.bin/g++/cc1plus/dbxout.c +++ /dev/null @@ -1,1643 +0,0 @@ -/* Output dbx-format symbol table information from GNU compiler. - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* Output dbx-format symbol table data. - This consists of many symbol table entries, each of them - a .stabs assembler pseudo-op with four operands: - a "name" which is really a description of one symbol and its type, - a "code", which is a symbol defined in stab.h whose name starts with N_, - an unused operand always 0, - and a "value" which is an address or an offset. - The name is enclosed in doublequote characters. - - Each function, variable, typedef, and structure tag - has a symbol table entry to define it. - The beginning and end of each level of name scoping within - a function are also marked by special symbol table entries. - - The "name" consists of the symbol name, a colon, a kind-of-symbol letter, - and a data type number. The data type number may be followed by - "=" and a type definition; normally this will happen the first time - the type number is mentioned. The type definition may refer to - other types by number, and those type numbers may be followed - by "=" and nested definitions. - - This can make the "name" quite long. - When a name is more than 80 characters, we split the .stabs pseudo-op - into two .stabs pseudo-ops, both sharing the same "code" and "value". - The first one is marked as continued with a double-backslash at the - end of its "name". - - The kind-of-symbol letter distinguished function names from global - variables from file-scope variables from parameters from auto - variables in memory from typedef names from register variables. - See `dbxout_symbol'. - - The "code" is mostly redundant with the kind-of-symbol letter - that goes in the "name", but not entirely: for symbols located - in static storage, the "code" says which segment the address is in, - which controls how it is relocated. - - The "value" for a symbol in static storage - is the core address of the symbol (actually, the assembler - label for the symbol). For a symbol located in a stack slot - it is the stack offset; for one in a register, the register number. - For a typedef symbol, it is zero. - - If DEBUG_SYMS_TEXT is defined, all debugging symbols must be - output while in the text section. - - For more on data type definitions, see `dbxout_type'. */ - -#include "config.h" -#include "tree.h" -#include "cplus-tree.h" -#include "rtl.h" -#include "flags.h" -#include -#include "regs.h" - -/* Typical USG systems don't have stab.h, and they also have - no use for DBX-format debugging info. */ - -#ifdef DBX_DEBUGGING_INFO - -#ifdef DEBUG_SYMS_TEXT -#define FORCE_TEXT text_section (); -#else -#define FORCE_TEXT -#endif - -#ifdef USG -#include "stab.h" /* If doing DBX on sysV, use our own stab.h. */ -#else -#include /* On BSD, use the system's stab.h. */ -#endif /* not USG */ - -/* Stream for writing to assembler file. */ - -static FILE *asmfile; - -enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED}; - -/* Vector recording the status of describing C data types. - When we first notice a data type (a tree node), - we assign it a number using next_type_number. - That is its index in this vector. - The vector element says whether we have yet output - the definition of the type. TYPE_XREF says we have - output it as a cross-reference only. */ - -enum typestatus *typevec; - -/* Number of elements of space allocated in `typevec'. */ - -static int typevec_len; - -/* In dbx output, each type gets a unique number. - This is the number for the next type output. - The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */ - -static int next_type_number; - -/* In dbx output, we must assign symbol-blocks id numbers - in the order in which their beginnings are encountered. - We output debugging info that refers to the beginning and - end of the ranges of code in each block - with assembler labels LBBn and LBEn, where n is the block number. - The labels are generated in final, which assigns numbers to the - blocks in the same way. */ - -static int next_block_number; - -/* These variables are for dbxout_symbol to communicate to - dbxout_finish_symbol. - current_sym_code is the symbol-type-code, a symbol N_... define in stab.h. - current_sym_value and current_sym_addr are two ways to address the - value to store in the symtab entry. - current_sym_addr if nonzero represents the value as an rtx. - If that is zero, current_sym_value is used. This is used - when the value is an offset (such as for auto variables, - register variables and parms). */ - -static int current_sym_code; -static int current_sym_value; -static rtx current_sym_addr; - -/* Number of chars of symbol-description generated so far for the - current symbol. Used by CHARS and CONTIN. */ - -static int current_sym_nchars; - -/* Report having output N chars of the current symbol-description. */ - -#define CHARS(N) (current_sym_nchars += (N)) - -/* Break the current symbol-description, generating a continuation, - if it has become long. */ - -#ifndef DBX_CONTIN_LENGTH -#define DBX_CONTIN_LENGTH 80 -#endif - -#if DBX_CONTIN_LENGTH > 0 -#define CONTIN \ - do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0) -#else -#define CONTIN -#endif - -void dbxout_types (); -void dbxout_tags (); -void dbxout_args (); -void dbxout_symbol (); -static void dbxout_type_name (); -static void dbxout_type (); -static void dbxout_finish_symbol (); -static void dbxout_continue (); - -/* At the beginning of compilation, start writing the symbol table. - Initialize `typevec' and output the standard data types of C. */ - -void -dbxout_init (asm_file, input_file_name) - FILE *asm_file; - char *input_file_name; -{ - asmfile = asm_file; - - typevec_len = 100; - typevec = (enum typestatus *) xmalloc (typevec_len * sizeof typevec[0]); - bzero (typevec, typevec_len * sizeof typevec[0]); - - /* Used to put `Ltext:' before the reference, but that loses on sun 4. */ - fprintf (asmfile, - "\t.stabs \"%s\",%d,0,0,Ltext\nLtext:\n", - input_file_name, N_SO); - - next_type_number = 1; - next_block_number = 2; - - /* Make sure that types `int' and `char' have numbers 1 and 2. - Definitions of other integer types will refer to those numbers. */ - - dbxout_symbol (TYPE_NAME (integer_type_node), 0); - dbxout_symbol (TYPE_NAME (char_type_node), 0); - - /* Get all permanent types not yet gotten, and output them. */ - - dbxout_types (get_permanent_types ()); -} - -/* Change by Bryan Boreham, Kewill, Sun Aug 13 15:31:25 1989. - Added to support unexecing of compiler. */ - -void -re_init_dbxout_for_unexec (asm_file, input_file_name) - FILE *asm_file; - char *input_file_name; -{ - asmfile = asm_file; -} - -/* Continue a symbol-description that gets too big. - End one symbol table entry with a double-backslash - and start a new one, eventually producing something like - .stabs "start......\\",code,0,value - .stabs "...rest",code,0,value */ - -static void -dbxout_continue () -{ -#ifdef DBX_CONTIN_CHAR - fprintf (asmfile, "%c", DBX_CONTIN_CHAR); -#else - fprintf (asmfile, "\\\\"); -#endif - dbxout_finish_symbol (); - fprintf (asmfile, ".stabs \""); - current_sym_nchars = 0; -} - -static void -dbxout_type_fields (type) - tree type; -{ - tree tem; - for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) - { - /* Output the name, type, position (in bits), size (in bits) - of each field. */ - if (DECL_ANON_UNION_ELEM (tem)) - dbxout_type_fields (TREE_TYPE (tem)); - /* Omit here local type decls until we know how to support them. */ - else if (TREE_CODE (tem) == TYPE_DECL) - continue; - /* Omit here the nameless fields that are used to skip bits. */ - else if (DECL_NAME (tem) != 0 && TREE_CODE (tem) != CONST_DECL) - { - /* Continue the line if necessary, - but not before the first field. */ - if (tem != TYPE_FIELDS (type)) - CONTIN; - - if (use_gdb_dbx_extensions - && flag_minimal_debug - && TREE_CODE (tem) == FIELD_DECL - && (DECL_VIRTUAL_P (tem) || DECL_VBASE_P (tem))) - { - CHARS (3 + TYPE_NAME_LENGTH (DECL_FCONTEXT (tem))); - fprintf (asmfile, "$v%c", - DECL_VIRTUAL_P (tem) ? 'f' : 'b'); - dbxout_type (DECL_FCONTEXT (tem), 0); - fprintf (asmfile, ":"); - dbxout_type (TREE_TYPE (tem), 0); - fprintf (asmfile, ",%d;", DECL_OFFSET (tem)); - continue; - } - - fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem))); - CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem))); - - if (use_gdb_dbx_extensions) - { - putc ('/', asmfile); -#ifdef TREE_PRIVATE - putc ((TREE_PRIVATE (tem) ? '0' - : TREE_PROTECTED (tem) ? '1' : '2'), - asmfile); -#endif - CHARS (2); - } - - dbxout_type (TREE_TYPE (tem), 0); - if (TREE_CODE (tem) == VAR_DECL && TREE_STATIC (tem)) - { - if (use_gdb_dbx_extensions) - { - char *name = DECL_ASSEMBLER_NAME (tem); - - /* Adding 1 here only works on systems - which flush an initial underscore from - the .stabs entry. This loses for static names - which have an initial leading '_' on systems which - don't use leading underscores. */ - if (name[0] == '_') - name += 1; - - fprintf (asmfile, ":%s;", name); - CHARS (strlen (name)); - } - else - { - fprintf (asmfile, ",0,0;"); - } - } -#if 0 - else if (TREE_CODE (tem) == VAR_DECL || TREE_CODE (tem) == CONST_DECL) - { - /* GDB 3.2 can't understand these declarations yet. */ - continue; - } -#endif - else - { - fprintf (asmfile, ",%d,%d;", DECL_OFFSET (tem), - TREE_INT_CST_LOW (DECL_SIZE (tem)) * DECL_SIZE_UNIT (tem)); - } - CHARS (23); - } - } -} - -/* Output a reference to a type. If the type has not yet been - described in the dbx output, output its definition now. - For a type already defined, just refer to its definition - using the type number. - - If FULL is nonzero, and the type has been described only with - a forward-reference, output the definition now. - If FULL is zero in this case, just refer to the forward-reference - using the number previously allocated. */ - -static void -dbxout_type (type, full) - tree type; - int full; -{ - register tree fields, tem, method_vec; - tree *methods, *end; - char *vfield_name = 0; - tree virtual_basetype = 0; - - /* If there was an input error and we don't really have a type, - avoid crashing and write something that is at least valid - by assuming `int'. */ - if (type == error_mark_node) - type = integer_type_node; - else /* if (TYPE_SIZE (type) == 0) */ - type = TYPE_MAIN_VARIANT (type); - - if (TYPE_SYMTAB_ADDRESS (type) == 0) - { - /* Type has no dbx number assigned. Assign next available number. */ - TYPE_SYMTAB_ADDRESS (type) = next_type_number++; - - /* Make sure type vector is long enough to record about this type. */ - - if (next_type_number == typevec_len) - { - typevec = (enum typestatus *) xrealloc (typevec, typevec_len * 2 * sizeof typevec[0]); - bzero (typevec + typevec_len, typevec_len * sizeof typevec[0]); - typevec_len *= 2; - } - } - - /* Output the number of this type, to refer to it. */ - fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type)); - CHARS (3); - - /* If this type's definition has been output or is now being output, - that is all. */ - - switch (typevec[TYPE_SYMTAB_ADDRESS (type)]) - { - case TYPE_UNSEEN: - break; - case TYPE_XREF: - if (! full) - return; - break; - case TYPE_DEFINED: - return; - } - -#ifdef DBX_NO_XREFS - /* For systems where dbx output does not allow the `=xsNAME:' syntax, - leave the type-number completely undefined rather than output - a cross-reference. */ - if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE - || TREE_CODE (type) == ENUMERAL_TYPE) - - if ((TYPE_NAME (type) != 0 && !full) - || TYPE_SIZE (type) == 0) - { - typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF; - return; - } -#endif - - /* Output a definition now. */ - - fprintf (asmfile, "="); - CHARS (1); - - /* Mark it as defined, so that if it is self-referent - we will not get into an infinite recursion of definitions. */ - - typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_DEFINED; - - switch (TREE_CODE (type)) - { - case VOID_TYPE: - case LANG_TYPE: - /* For a void type, just define it as itself; ie, "5=5". - This makes us consider it defined - without saying what it is. The debugger will make it - a void type when the reference is seen, and nothing will - ever override that default. */ - fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type)); - CHARS (3); - break; - - case INTEGER_TYPE: - if (type == char_type_node && ! TREE_UNSIGNED (type)) - /* Output the type `char' as a subrange of itself! - I don't understand this definition, just copied it - from the output of pcc. */ - fprintf (asmfile, "r2;0;127;"); - else - /* Output other integer types as subranges of `int'. */ - fprintf (asmfile, "r1;%d;%d;", - TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)), - TREE_INT_CST_LOW (TYPE_MAX_VALUE (type))); - CHARS (25); - break; - - case REAL_TYPE: - /* This must be magic. */ - fprintf (asmfile, "r1;%d;0;", - TREE_INT_CST_LOW (size_in_bytes (type))); - CHARS (16); - break; - - case ARRAY_TYPE: - /* Output "a" followed by a range type definition - for the index type of the array - followed by a reference to the target-type. - ar1;0;N;M for an array of type M and size N. */ - fprintf (asmfile, "ar1;0;%d;", - (TYPE_DOMAIN (type) - ? TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) - : -1)); - CHARS (17); - dbxout_type (TREE_TYPE (type), 0); - break; - - case RECORD_TYPE: - case UNION_TYPE: - { - int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (type); - - /* Output a structure type. */ - if ((TYPE_NAME (type) != 0 && !full) - || TYPE_SIZE (type) == 0) - { - /* If the type is just a cross reference, output one - and mark the type as partially described. - If it later becomes defined, we will output - its real definition. - If the type has a name, don't nest its name within - another type's definition; instead, output an xref - and let the definition come when the name is defined. */ - fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu"); - CHARS (3); - dbxout_type_name (type); - fprintf (asmfile, ":"); - typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF; - break; - } - tem = size_in_bytes (type); - fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "s%d" : "u%d", - TREE_INT_CST_LOW (tem)); - - if (use_gdb_dbx_extensions) - { - if (n_baseclasses) - { - fprintf (asmfile, "!%d,", n_baseclasses); - CHARS (8); - } - } - for (i = 1; i <= n_baseclasses; i++) - { - tree basetype = CLASSTYPE_BASECLASS (type, i); - if (use_gdb_dbx_extensions) - { - putc (CLASSTYPE_VIA_VIRTUAL (type, i) ? '1' - : '0', - asmfile); - putc (CLASSTYPE_VIA_PUBLIC (type, i) ? '2' - : '0', - asmfile); - fprintf (asmfile, "%d,", DECL_OFFSET (TYPE_NAME (basetype))); - CHARS (15); - dbxout_type (basetype, 0); - putc (';', asmfile); - } - else - { - /* Print out the base class information with fields - which have the same names at the types they hold. */ - dbxout_type_name (basetype); - putc (':', asmfile); - dbxout_type (basetype, full); - fprintf (asmfile, ",%d,%d;", - DECL_OFFSET (TYPE_NAME (basetype)), - TREE_INT_CST_LOW (TYPE_SIZE (basetype)) * DECL_SIZE_UNIT (basetype)); - CHARS (20); - } - } - } - - CHARS (11); - - /* Write out the field declarations. */ - dbxout_type_fields (type); - - /* C++: put out the method names and their parameter lists */ - /* We do constructors, destructor, if any, followed by the method names. */ - method_vec = use_gdb_dbx_extensions ? CLASSTYPE_METHOD_VEC (type) : NULL_TREE; - methods = 0; - end = 0; - if (use_gdb_dbx_extensions - && TREE_CODE (type) == RECORD_TYPE - && (TYPE_HAS_DESTRUCTOR (type) | TYPE_HAS_CONSTRUCTOR (type))) - { - tree dtor; - - methods = &TREE_VEC_ELT (method_vec, 0); - end = TREE_VEC_END (method_vec); - /* Destructors lie in a special place. */ - if (TYPE_HAS_DESTRUCTOR (type)) - { - dtor = TREE_VEC_ELT (method_vec, 0); - tem = TREE_CHAIN (dtor); - } - else - { - dtor = NULL_TREE; - tem = *methods; - } - - CHARS (2); - - if (tem) - { - if (TREE_OPERATOR (tem)) - /* Operators do not belong here. This is for - constructors and destructors only. */ - abort (); - else - { - fprintf (asmfile, "%s::", IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (tem))); - CHARS (IDENTIFIER_LENGTH (DECL_ORIGINAL_NAME (tem)) + 3); - } - - while (tem) - { - /* Output the name of the field (after overloading), as - well as the name of the field before overloading, along - with its parameter list. */ - char c; - char *debug_name = IDENTIFIER_POINTER (DECL_NAME (tem)); - int old_minimal_debug = flag_minimal_debug; - - CONTIN; - - if (tem == dtor) - /* Always output destructors with full information. */ - flag_minimal_debug = 0; - - dbxout_type (TREE_TYPE (tem), 0); - flag_minimal_debug = old_minimal_debug; - - if (DECL_VIRTUAL_P (tem)) - c = '*'; - else if (DECL_STATIC_FUNCTION_P (tem)) - c = '?'; - else - c = '.'; - - if (flag_minimal_debug && tem != dtor) - { - /* Cut down on debugging information by not outputting - the parts of the name we can just as easily - have the debugger figure out. */ - - /* Get past '__'. */ - debug_name += 2; - /* Get past const and volatile qualifiers. */ - while (*debug_name == 'C' || *debug_name == 'V') - debug_name++; - /* Get past numeric type length prefix. */ - while (*debug_name >= '0' && *debug_name <= '9') - debug_name++; - /* Get past type of `this'. */ - debug_name += IDENTIFIER_LENGTH (DECL_NAME (TYPE_NAME (type))); - } - fprintf (asmfile, ":%s;%c%c", debug_name, - TREE_PRIVATE (tem) ? '0' : TREE_PROTECTED (tem) ? '1' : '2', c); - CHARS (IDENTIFIER_LENGTH (DECL_NAME (tem)) + 5 - - (debug_name - IDENTIFIER_POINTER (DECL_NAME (tem)))); - if (DECL_VIRTUAL_P (tem)) - { - fprintf (asmfile, "%d;", - TREE_INT_CST_LOW (DECL_VINDEX (tem))); - CHARS (8); - } - if (tem == dtor) - break; - tem = TREE_CHAIN (tem); - if (tem == NULL_TREE) - tem = dtor; - } - putc (';', asmfile); - } - if (methods != end) - methods++; - } - else if (method_vec != NULL_TREE) - { - methods = &TREE_VEC_ELT (method_vec, 1); - end = TREE_VEC_END (method_vec); - } - - for (; methods != end; methods++) - { - tem = *methods; - - if (tem) - { - if (TREE_OPERATOR (tem)) - { - char *name1 = operator_name_string (DECL_NAME (tem)); - fprintf (asmfile, "op$::%s.", name1); - CHARS (strlen (name1) + 6); - } - else - { - tree name = DECL_ORIGINAL_NAME (tem); - fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name)); - CHARS (IDENTIFIER_LENGTH (name) + 3); - } - - for (; tem; tem = TREE_CHAIN (tem)) - /* Output the name of the field (after overloading), as - well as the name of the field before overloading, along - with its parameter list */ - { - /* @@ */ - char c; - char *debug_name = IDENTIFIER_POINTER (DECL_NAME (tem)); - - CONTIN; - - dbxout_type (TREE_TYPE (tem), 0); - if (DECL_VIRTUAL_P (tem)) - c = '*'; - else if (DECL_STATIC_FUNCTION_P (tem)) - c = '?'; - else - c = '.'; - - if (flag_minimal_debug) - { - debug_name += IDENTIFIER_LENGTH (DECL_ORIGINAL_NAME (tem)) + 2; - while (*debug_name == 'C' || *debug_name == 'V') - debug_name++; - while (*debug_name >= '0' && *debug_name <= '9') - debug_name++; - debug_name += IDENTIFIER_LENGTH (DECL_NAME (TYPE_NAME (type))); - } - - fprintf (asmfile, ":%s;%c%c", debug_name, - TREE_PRIVATE (tem) ? '0' : TREE_PROTECTED (tem) ? '1' : '2', c); - CHARS (IDENTIFIER_LENGTH (DECL_NAME (tem)) + 6 - - (debug_name - IDENTIFIER_POINTER (DECL_NAME (tem)))); - if (DECL_VIRTUAL_P (tem)) - { - fprintf (asmfile, "%d;", - TREE_INT_CST_LOW (DECL_VINDEX (tem))); - CHARS (8); - } - } - putc (';', asmfile); - CHARS (1); - } - } - - putc (';', asmfile); - - if (use_gdb_dbx_extensions && TREE_CODE (type) == RECORD_TYPE) - { - /* Tell GDB+ that it may keep reading. */ - putc ('~', asmfile); - if (TYPE_HAS_DESTRUCTOR (type) && TYPE_HAS_CONSTRUCTOR (type)) - putc ('=', asmfile); - else if (TYPE_HAS_DESTRUCTOR (type)) - putc ('-', asmfile); - else if (TYPE_HAS_CONSTRUCTOR (type)) - putc ('+', asmfile); - - if (CLASSTYPE_VSIZE (type)) - { - putc ('%', asmfile); - dbxout_type (DECL_FCONTEXT (CLASSTYPE_VFIELD (type)), 0); - fprintf (asmfile, ";"); - } - else - { - putc (';', asmfile); - CHARS (3); - } - } - break; - - case ENUMERAL_TYPE: - if ((TYPE_NAME (type) != 0 - && !full - && ((TREE_CODE (TYPE_NAME (type)) == TYPE_DECL - && ! ANON_AGGRNAME_P (DECL_NAME (TYPE_NAME (type)))) - || (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE - && ! ANON_AGGRNAME_P (TYPE_NAME (type))))) - || TYPE_SIZE (type) == 0) - { - fprintf (asmfile, "xe"); - CHARS (3); - dbxout_type_name (type); - typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF; - fprintf (asmfile, ":"); - return; - } - putc ('e', asmfile); - CHARS (1); - for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem)) - { - fprintf (asmfile, "%s:%d,", IDENTIFIER_POINTER (TREE_PURPOSE (tem)), - TREE_INT_CST_LOW (TREE_VALUE (tem))); - CHARS (11 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem))); - if (TREE_CHAIN (tem) != 0) - CONTIN; - } - putc (';', asmfile); - CHARS (1); - break; - - case POINTER_TYPE: - putc ('*', asmfile); - CHARS (1); - dbxout_type (TREE_TYPE (type), 0); - break; - - case METHOD_TYPE: - if (use_gdb_dbx_extensions) - { - putc ('#', asmfile); - CHARS (1); - if (flag_minimal_debug) - { - putc ('#', asmfile); - dbxout_type (TREE_TYPE (type), 0); - putc (';', asmfile); - CHARS (1); - } - else - { - dbxout_type (TYPE_METHOD_BASETYPE (type), 0); - putc (',', asmfile); - CHARS (1); - dbxout_type (TREE_TYPE (type), 0); - dbxout_args (TYPE_ARG_TYPES (type)); - putc (';', asmfile); - CHARS (1); - } - } - else - { - /* Should print as an int, because it is really - just an offset. */ - dbxout_type (integer_type_node, 0); - } - break; - - case OFFSET_TYPE: - if (use_gdb_dbx_extensions) - { - putc ('@', asmfile); - CHARS (1); - dbxout_type (TYPE_OFFSET_BASETYPE (type), 0); - putc (',', asmfile); - CHARS (1); - dbxout_type (TREE_TYPE (type), 0); - } - else - { - /* Should print as an int, because it is really - just an offset. */ - dbxout_type (integer_type_node, 0); - } - break; - - case REFERENCE_TYPE: - putc (use_gdb_dbx_extensions ? '&' : '*', asmfile); - CHARS (1); - dbxout_type (TREE_TYPE (type), 0); - break; - - case FUNCTION_TYPE: - putc ('f', asmfile); - CHARS (1); - dbxout_type (TREE_TYPE (type), 0); - break; - - default: - abort (); - } -} - -/* Output the name of type TYPE, with no punctuation. - Such names can be set up either by typedef declarations - or by struct, enum and union tags. */ - -static void -dbxout_type_name (type) - register tree type; -{ - tree t; - if (TYPE_NAME (type) == 0) - abort (); - if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) - { - t = TYPE_NAME (type); - } - else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL) - { - t = DECL_NAME (TYPE_NAME (type)); - } - else - abort (); - - fprintf (asmfile, "%s", IDENTIFIER_POINTER (t)); - CHARS (IDENTIFIER_LENGTH (t)); -} - -/* Output a .stabs for the symbol defined by DECL, - which must be a ..._DECL node in the normal namespace. - It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL. - LOCAL is nonzero if the scope is less than the entire file. */ - -void -dbxout_symbol (decl, local) - tree decl; - int local; -{ - int letter = 0; - tree type = TREE_TYPE (decl); - char *name; - int regno = -1; - - /* If global, first output all types and all - struct, enum and union tags that have been created - and not yet output. */ - - if (local == 0) - { - /* Send out the tags first. */ - dbxout_tags (gettags ()); - dbxout_types (get_permanent_types ()); - } - - current_sym_code = 0; - current_sym_value = 0; - current_sym_addr = 0; - - /* The output will always start with the symbol name, - so count that always in the length-output-so-far. */ - - if (DECL_NAME (decl) == 0) - return; - - current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl)); - - switch (TREE_CODE (decl)) - { - case CONST_DECL: - /* Enum values are defined by defining the enum type. */ - break; - - case FUNCTION_DECL: - if (DECL_RTL (decl) == 0) - return; - if (TREE_EXTERNAL (decl)) - break; - if (GET_CODE (DECL_RTL (decl)) != MEM - || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF) - break; - FORCE_TEXT; - fprintf (asmfile, ".stabs \"%s:%c", - IDENTIFIER_POINTER (DECL_NAME (decl)), - TREE_PUBLIC (decl) ? 'F' : 'f'); - - current_sym_code = N_FUN; - current_sym_addr = XEXP (DECL_RTL (decl), 0); - - if (TREE_TYPE (TREE_TYPE (decl))) - dbxout_type (TREE_TYPE (TREE_TYPE (decl)), 0); - else - dbxout_type (void_type_node, 0); - dbxout_finish_symbol (); - break; - - case TYPE_DECL: -#if 0 - /* This seems all wrong. Outputting most kinds of types gives no name - at all. A true definition gives no name; a cross-ref for a - structure can give the tag name, but not a type name. - It seems that no typedef name is defined by outputting a type. */ - - /* If this typedef name was defined by outputting the type, - don't duplicate it. */ - if (typevec[TYPE_SYMTAB_ADDRESS (type)] == TYPE_DEFINED - && TYPE_NAME (TREE_TYPE (decl)) == decl) - return; -#endif - /* Don't output the same typedef twice. - And don't output what language-specific stuff doesn't want output. */ - if (TREE_ASM_WRITTEN (decl) - || lang_output_debug_info (TREE_TYPE (decl)) == 0) - return; - - /* Output typedef name. */ - FORCE_TEXT; - fprintf (asmfile, ".stabs \"%s:t", - IDENTIFIER_POINTER (DECL_NAME (decl))); - - current_sym_code = N_LSYM; - - dbxout_type (TREE_TYPE (decl), 1); - dbxout_finish_symbol (); - - /* Prevent duplicate output of a typedef. */ - TREE_ASM_WRITTEN (decl) = 1; - break; - - case PARM_DECL: - /* Parm decls go in their own separate chains - and are output by dbxout_reg_parms and dbxout_parms. */ - abort (); - - case RESULT_DECL: - /* Named return value, treat like a VAR_DECL. */ - case VAR_DECL: - if (DECL_RTL (decl) == 0) - return; - /* Don't mention a variable that is external. - Let the file that defines it describe it. */ - if (TREE_EXTERNAL (decl)) - break; - - /* If the variable is really a constant, inform dbx of such. */ - if (TREE_STATIC (decl) && TREE_READONLY (decl) - && DECL_INITIAL (decl) != 0 - && (DECL_FIELD_CONTEXT (decl) == NULL_TREE - || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == LET_STMT)) - { - if (TREE_PUBLIC (decl) == 0) - { - /* The sun4 assembler does not grok this. */ - name = IDENTIFIER_POINTER (DECL_NAME (decl)); - if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE - || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE) - { - int ival = TREE_INT_CST_LOW (DECL_INITIAL (decl)); - fprintf (asmfile, ".stabs \"%s:c=i%d\",0x%x,0,0,0\n", - name, ival, N_LSYM); - return; - } - else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE) - { - /* don't know how to do this yet. */ - } - break; - } - /* else it is something we handle like a normal variable. */ - } - - /* Don't mention a variable at all - if it was completely optimized into nothingness. - - If DECL was from an inline function, then it's rtl - is not identically the rtl that was used in this - particular compilation. */ - if (GET_CODE (DECL_RTL (decl)) == REG) - { - regno = REGNO (DECL_RTL (decl)); - if (regno >= FIRST_PSEUDO_REGISTER) - regno = reg_renumber[REGNO (DECL_RTL (decl))]; - if (regno < 0) - break; - } - - /* The kind-of-variable letter depends on where - the variable is and on the scope of its name: - G and N_GSYM for static storage and global scope, - S for static storage and file scope, - V for static storage and local scope, - for those two, use N_LCSYM if data is in bss segment, - N_STSYM if in data segment, N_FUN otherwise. - (We used N_FUN originally, then changed to N_STSYM - to please GDB. However, it seems that confused ld. - Now GDB has been fixed to like N_FUN, says Kingdon.) - no letter at all, and N_LSYM, for auto variable, - r and N_RSYM for register variable. */ - - if (GET_CODE (DECL_RTL (decl)) == MEM - && GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF) - { - if (TREE_PUBLIC (decl)) - { - letter = 'G'; - current_sym_code = N_GSYM; - } - else - { - current_sym_addr = XEXP (DECL_RTL (decl), 0); - - letter = TREE_PERMANENT (decl) ? 'S' : 'V'; - - if (!DECL_INITIAL (decl)) - current_sym_code = N_LCSYM; - else if (TREE_READONLY (decl) && ! TREE_VOLATILE (decl)) - /* This is not quite right, but it's the closest - of all the codes that Unix defines. */ - current_sym_code = N_FUN; - else - current_sym_code = N_STSYM; - } - } - else if (regno >= 0) - { - letter = 'r'; - current_sym_code = N_RSYM; - current_sym_value = DBX_REGISTER_NUMBER (regno); - } - else if (GET_CODE (DECL_RTL (decl)) == MEM - && (GET_CODE (XEXP (DECL_RTL (decl), 0)) == MEM - || (GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG - && REGNO (XEXP (DECL_RTL (decl), 0)) != FRAME_POINTER_REGNUM))) - /* If the value is indirect by memory or by a register - that isn't the frame pointer - then it means the object is variable-sized and address through - that register or stack slot. DBX has no way to represent this - so all we can do is output the variable as a pointer. - If it's not a parameter, ignore it. - (VAR_DECLs like this can be made by integrate.c.) */ - { - if (GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG) - { - letter = 'r'; - current_sym_code = N_RSYM; - current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (DECL_RTL (decl), 0))); - } - else - { - current_sym_code = N_LSYM; - /* DECL_RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))). - We want the value of that CONST_INT. */ - current_sym_value = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (decl), 0), 0), 1)); - } - - /* Effectively do build_pointer_type, but don't cache this type, - since it might be temporary whereas the type it points to - might have been saved for inlining. */ - type = make_node (POINTER_TYPE); - TREE_TYPE (type) = TREE_TYPE (decl); - } - else if (GET_CODE (DECL_RTL (decl)) == MEM - && GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG) - { - current_sym_code = N_LSYM; - current_sym_value = 0; - } - else if (GET_CODE (DECL_RTL (decl)) == MEM - && GET_CODE (XEXP (DECL_RTL (decl), 0)) == PLUS - && GET_CODE (XEXP (XEXP (DECL_RTL (decl), 0), 1)) == CONST_INT) - { - current_sym_code = N_LSYM; - /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))) - We want the value of that CONST_INT. */ - current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (decl), 0), 1)); - } - else - /* Address might be a MEM, when DECL is a variable-sized object. - Or it might be const0_rtx, meaning previous passes - want us to ignore this variable. */ - break; - - /* Ok, start a symtab entry and output the variable name. */ - FORCE_TEXT; - /* One slight hitch: if this is a VAR_DECL which is a static - class member, we must put out the mangled name instead of the - DECL_NAME. */ - /* Note also that static member (variable) names DO NOT begin - with underscores in .stabs directives. */ - if (DECL_LANG_SPECIFIC (decl)) - { - name = DECL_ASSEMBLER_NAME (decl); - - /* Adding 1 here only works on systems - which flush an initial underscore. */ - if (name[0] == '_') - name += 1; - } - else name = IDENTIFIER_POINTER (DECL_NAME (decl)); - - fprintf (asmfile, ".stabs \"%s:", name); - if (letter) putc (letter, asmfile); - dbxout_type (type, 0); - dbxout_finish_symbol (); - break; - } -} - -static void -dbxout_finish_symbol () -{ - fprintf (asmfile, "\",%d,0,0,", current_sym_code); - if (current_sym_addr) - output_addr_const (asmfile, current_sym_addr); - else - fprintf (asmfile, "%d", current_sym_value); - putc ('\n', asmfile); -} - -/* Output definitions of all the decls in a chain. */ - -static void -dbxout_syms (syms) - tree syms; -{ - while (syms) - { - dbxout_symbol (syms, 1); - syms = TREE_CHAIN (syms); - } -} - -/* The following two functions output definitions of function parameters. - Each parameter gets a definition locating it in the parameter list. - Each parameter that is a register variable gets a second definition - locating it in the register. - - Printing or argument lists in gdb uses the definitions that - locate in the parameter list. But reference to the variable in - expressions uses preferentially the definition as a register. */ - -/* Output definitions, referring to storage in the parmlist, - of all the parms in PARMS, which is a chain of PARM_DECL nodes. */ - -static void -dbxout_parms (parms) - tree parms; -{ - for (; parms; parms = TREE_CHAIN (parms)) - { - int regno = -1; - - if (GET_CODE (DECL_RTL (parms)) == REG) - regno = REGNO (DECL_RTL (parms)); - if (regno >= FIRST_PSEUDO_REGISTER) - regno = reg_renumber[regno]; - - if (DECL_OFFSET (parms) >= 0) - { - current_sym_code = N_PSYM; - current_sym_value = DECL_OFFSET (parms) / BITS_PER_UNIT; - current_sym_addr = 0; - - FORCE_TEXT; - if (DECL_NAME (parms)) - { - current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); - - fprintf (asmfile, ".stabs \"%s:p", - IDENTIFIER_POINTER (DECL_NAME (parms))); - } - else - { - current_sym_nchars = 8; - fprintf (asmfile, ".stabs \"(anon):p"); - } - - if (regno >= 0) - dbxout_type (DECL_ARG_TYPE (parms), 0); - else - { - /* This is the case where the parm is passed as an int or double - and it is converted to a char, short or float and stored back - in the parmlist. In this case, describe the parm - with the variable's declared type, and adjust the address - if the least significant bytes (which we are using) are not - the first ones. */ -#ifdef BYTES_BIG_ENDIAN - if (TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) - current_sym_value += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) - - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); -#endif - - if (GET_CODE (DECL_RTL (parms)) == MEM - && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS - && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT - && INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == current_sym_value) - dbxout_type (TREE_TYPE (parms), 0); - else - { - current_sym_value = DECL_OFFSET (parms) / BITS_PER_UNIT; - dbxout_type (DECL_ARG_TYPE (parms), 0); - } - } - dbxout_finish_symbol (); - } - /* Parm was passed in registers. - If it lives in a hard register, output a "regparm" symbol - for the register it lives in. */ - else if (regno >= 0) - { - current_sym_code = N_RSYM; - current_sym_value = DBX_REGISTER_NUMBER (regno); - current_sym_addr = 0; - - FORCE_TEXT; - if (DECL_NAME (parms)) - { - current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); - fprintf (asmfile, ".stabs \"%s:P", - IDENTIFIER_POINTER (DECL_NAME (parms))); - } - else - { - current_sym_nchars = 8; - fprintf (asmfile, ".stabs \"(anon):P"); - } - - dbxout_type (DECL_ARG_TYPE (parms), 0); - dbxout_finish_symbol (); - } - else if (GET_CODE (DECL_RTL (parms)) == MEM - && XEXP (DECL_RTL (parms), 0) != const0_rtx) - { - current_sym_code = N_LSYM; - /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))). - We want the value of that CONST_INT. */ - current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)); - current_sym_addr = 0; - - FORCE_TEXT; - if (DECL_NAME (parms)) - { - current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); - fprintf (asmfile, ".stabs \"%s:p", - IDENTIFIER_POINTER (DECL_NAME (parms))); - } - else - { - current_sym_nchars = 8; - fprintf (asmfile, ".stabs \"(anon):p"); - } - -#if 0 /* This is actually the case in which a parameter - is passed in registers but lives on the stack in a local slot. - The address we are using is already correct, so don't change it. */ - - /* This is the case where the parm is passed as an int or double - and it is converted to a char, short or float and stored back - in the parmlist. In this case, describe the parm - with the variable's declared type, and adjust the address - if the least significant bytes (which we are using) are not - the first ones. */ -#ifdef BYTES_BIG_ENDIAN - if (TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) - current_sym_value += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) - - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); -#endif -#endif /* 0 */ - - dbxout_type (TREE_TYPE (parms), 0); - dbxout_finish_symbol (); - } - } -} - -/* Output definitions, referring to registers, - of all the parms in PARMS which are stored in registers during the function. - PARMS is a chain of PARM_DECL nodes. */ - -static void -dbxout_reg_parms (parms) - tree parms; -{ - while (parms) - { - int regno = -1; - - if (GET_CODE (DECL_RTL (parms)) == REG) - regno = REGNO (DECL_RTL (parms)); - if (regno >= FIRST_PSEUDO_REGISTER) - regno = reg_renumber[regno]; - - /* Report parms that live in registers during the function. */ - if (regno >= 0 - && DECL_OFFSET (parms) >= 0) - { - current_sym_code = N_RSYM; - current_sym_value = DBX_REGISTER_NUMBER (regno); - current_sym_addr = 0; - - FORCE_TEXT; - if (DECL_NAME (parms)) - { - current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); - fprintf (asmfile, ".stabs \"%s:r", - IDENTIFIER_POINTER (DECL_NAME (parms))); - } - else - { - current_sym_nchars = 8; - fprintf (asmfile, ".stabs \"(anon):r"); - } - dbxout_type (TREE_TYPE (parms), 0); - dbxout_finish_symbol (); - } - /* Report parms that live in memory but outside the parmlist. */ - else if (GET_CODE (DECL_RTL (parms)) == MEM - && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS - && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT) - { - int offset = DECL_OFFSET (parms) / BITS_PER_UNIT; - /* A parm declared char is really passed as an int, - so it occupies the least significant bytes. - On a big-endian machine those are not the low-numbered ones. */ -#ifdef BYTES_BIG_ENDIAN - if (offset != -1 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) - offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) - - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); -#endif - if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) - { - current_sym_code = N_LSYM; - current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)); - current_sym_addr = 0; - FORCE_TEXT; - if (DECL_NAME (parms)) - { - current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); - fprintf (asmfile, ".stabs \"%s:", - IDENTIFIER_POINTER (DECL_NAME (parms))); - } - else - { - current_sym_nchars = 8; - fprintf (asmfile, ".stabs \"(anon):"); - } - dbxout_type (TREE_TYPE (parms), 0); - dbxout_finish_symbol (); - } - } - parms = TREE_CHAIN (parms); - } -} - -/* Given a chain of ..._TYPE nodes (as come in a parameter list), - output definitions of those names, in raw form */ - -void -dbxout_args (args) - tree args; -{ - while (args) - { - putc (',', asmfile); - dbxout_type (TREE_VALUE (args), 0); - CHARS (1); - args = TREE_CHAIN (args); - } -} - -/* Given a chain of ..._TYPE nodes, - find those which have typedef names and output those names. - This is to ensure those types get output. */ - -void -dbxout_types (types) - register tree types; -{ - while (types) - { - if (TYPE_NAME (types) - && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL - && ! TREE_ASM_WRITTEN (TYPE_NAME (types))) - dbxout_symbol (TYPE_NAME (types), 1); - types = TREE_CHAIN (types); - } -} - -/* Output the tags (struct, union and enum definitions with names) for a block, - given a list of them (a chain of TREE_LIST nodes) in TAGS. - We must check to include those that have been mentioned already with - only a cross-reference. */ - -void -dbxout_tags (tags) - tree tags; -{ - register tree link; - for (link = tags; link; link = TREE_CHAIN (link)) - { - register tree type = TYPE_MAIN_VARIANT (TREE_VALUE (link)); - if (TREE_PURPOSE (link) != 0 - && ! TREE_ASM_WRITTEN (link) - && TYPE_SIZE (type) != 0 - && lang_output_debug_info (type)) - { - TREE_ASM_WRITTEN (link) = 1; - current_sym_code = N_LSYM; - current_sym_value = 0; - current_sym_addr = 0; - current_sym_nchars = 2 + IDENTIFIER_LENGTH (TREE_PURPOSE (link)); - - FORCE_TEXT; - fprintf (asmfile, ".stabs \"%s:T", - ANON_AGGRNAME_P (TREE_PURPOSE (link)) - ? "" : IDENTIFIER_POINTER (TREE_PURPOSE (link))); - - /* If there is a typedecl for this type with the same name - as the tag, output an abbreviated form for that typedecl. */ - if (use_gdb_dbx_extensions - && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL - && DECL_NAME (TYPE_NAME (type)) == TREE_PURPOSE (link)) - { - putc ('t', asmfile); - TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1; - } - dbxout_type (type, 1); - dbxout_finish_symbol (); - -/* Change by Bryan Boreham, Kewill, Fri Sep 22 16:57:42 1989. - Added to make sure all fully-output structs have typedefs. */ - - if (!ANON_AGGRNAME_P (TREE_PURPOSE (link)) - && (TREE_CODE (TYPE_NAME (type)) != TYPE_DECL - || DECL_NAME (TYPE_NAME (type)) != TREE_PURPOSE (link))) - { - fprintf (asmfile, ".stabs \"%s:t", - IDENTIFIER_POINTER (TREE_PURPOSE (link))); - - current_sym_code = N_LSYM; - - dbxout_type (type, 1); - dbxout_finish_symbol (); - } - } - } -} - -/* Output everything about a symbol block (that is to say, a LET_STMT node - that represents a scope level), - including recursive output of contained blocks. - - STMT is the LET_STMT node. - DEPTH is its depth within containing symbol blocks. - ARGS is usually zero; but for the outermost block of the - body of a function, it is a chain of PARM_DECLs for the function parameters. - We output definitions of all the register parms - as if they were local variables of that block. - - Actually, STMT may be several statements chained together. - We handle them all in sequence. */ - -static void -dbxout_block (stmt, depth, args) - register tree stmt; - int depth; - tree args; -{ - int blocknum; - - while (stmt) - { - switch (TREE_CODE (stmt)) - { - case COMPOUND_STMT: - case LOOP_STMT: - dbxout_block (STMT_BODY (stmt), depth, 0); - break; - - case IF_STMT: - dbxout_block (STMT_THEN (stmt), depth, 0); - dbxout_block (STMT_ELSE (stmt), depth, 0); - break; - - case LET_STMT: - /* Ignore LET_STMTs for blocks never really used to make RTL. */ - if (! TREE_USED (stmt)) - break; - /* In dbx format, the syms of a block come before the N_LBRAC. */ - dbxout_tags (STMT_TYPE_TAGS (stmt)); - dbxout_syms (STMT_VARS (stmt)); - if (args) - dbxout_reg_parms (args); - - /* Now output an N_LBRAC symbol to represent the beginning of - the block. Use the block's tree-walk order to generate - the assembler symbols LBBn and LBEn - that final will define around the code in this block. */ - if (depth > 0) - { - char buf[20]; - blocknum = next_block_number++; - ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum); - - if (TREE_LANG_FLAG_1 (stmt) == 0 - && TREE_LANG_FLAG_2 (stmt) == 1) - { - /* A catch block. Must precede N_LBRAC. */ - tree decl = STMT_VARS (stmt); - char *name = DECL_NAME (decl) == NULL_TREE - ? "default" : EXCEPTION_NAME_LENGTH + IDENTIFIER_POINTER (DECL_NAME (decl)); - fprintf (asmfile, ".stabs \"%s:C1\",%d,0,0,", name, N_CATCH); - assemble_name (asmfile, buf); - fprintf (asmfile, "\n"); - } - - fprintf (asmfile, ".stabn %d,0,0,", N_LBRAC); - assemble_name (asmfile, buf); - fprintf (asmfile, "\n"); - } - - /* Output the subblocks. */ - dbxout_block (STMT_SUBBLOCKS (stmt), depth + 1, 0); - - /* Refer to the marker for the end of the block. */ - if (depth > 0) - { - char buf[20]; - ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum); - fprintf (asmfile, ".stabn %d,0,0,", N_RBRAC); - assemble_name (asmfile, buf); - fprintf (asmfile, "\n"); - } - } - stmt = TREE_CHAIN (stmt); - } -} - -/* Output dbx data for a function definition. - This includes a definition of the function name itself (a symbol), - definitions of the parameters (locating them in the parameter list) - and then output the block that makes up the function's body - (including all the auto variables of the function). */ - -void -dbxout_function (decl) - tree decl; -{ - extern tree value_identifier; - - dbxout_symbol (decl, 0); - dbxout_parms (DECL_ARGUMENTS (decl)); - if (DECL_NAME (DECL_RESULT (decl)) != value_identifier) - dbxout_symbol (DECL_RESULT (decl), 1); - dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl)); - - /* If we made any temporary types in this fn that weren't - output, output them now. */ - dbxout_types (get_temporary_types ()); -} - -/* GNU C++ extensions. */ - -/* At the start of the file, emit symbolic information to orient - GDB for this particular file's exception handling implementation. - EH_TYPE is the type name of the exception type. - EH_DECL is the global root of the exception handler stack. */ - -void -dbxout_eh_init (eh_type, eh_decl) - tree eh_type, eh_decl; -{ -} - -#else /* not DBX_DEBUGGING_INFO */ - -void -dbxout_init (asm_file, input_file_name) - FILE *asm_file; - char *input_file_name; -{} - -void -dbxout_symbol (decl, local) - tree decl; - int local; -{} - -void -dbxout_types (types) - register tree types; -{} - -void -dbxout_tags (tags) - tree tags; -{} - -void -dbxout_function (decl) - tree decl; -{} - -void -dbxout_eh_init (eh_type, eh_decl) - tree eh_type, eh_decl; -{ -} - -#endif /* DBX_DEBUGGING_INFO */ diff --git a/gnu/usr.bin/g++/cc1plus/expr.c b/gnu/usr.bin/g++/cc1plus/expr.c deleted file mode 100644 index 1e91ed6d6610..000000000000 --- a/gnu/usr.bin/g++/cc1plus/expr.c +++ /dev/null @@ -1,5748 +0,0 @@ -/* Convert tree expression to rtl instructions, for GNU compiler. - Copyright (C) 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include "config.h" -#include "rtl.h" -#include "tree.h" -#include "flags.h" -#include "insn-flags.h" -#include "insn-codes.h" -#include "expr.h" -#include "insn-config.h" -#include "recog.h" -#include "gvarargs.h" -#include "typeclass.h" - -/* Decide whether a function's arguments should be processed - from first to last or from last to first. */ - -#ifdef STACK_GROWS_DOWNWARD -#ifdef PUSH_ROUNDING -#define PUSH_ARGS_REVERSED /* If it's last to first */ -#endif -#endif - -/* Like STACK_BOUNDARY but in units of bytes, not bits. */ -#define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT) - -/* If this is nonzero, we do not bother generating VOLATILE - around volatile memory references, and we are willing to - output indirect addresses. If cse is to follow, we reject - indirect addresses so a useful potential cse is generated; - if it is used only once, instruction combination will produce - the same indirect address eventually. */ -int cse_not_expected; - -/* Nonzero to generate code for all the subroutines within an - expression before generating the upper levels of the expression. - Nowadays this is never zero. */ -int do_preexpand_calls = 1; - -/* Number of units that we should eventually pop off the stack. - These are the arguments to function calls that have already returned. */ -int pending_stack_adjust; - -/* Nonzero means stack pops must not be deferred, and deferred stack - pops must not be output. It is nonzero inside a function call, - inside a conditional expression, inside a statement expression, - and in other cases as well. */ -int inhibit_defer_pop; - -/* A list of all cleanups which belong to the arguments of - function calls being expanded by expand_call. */ -static tree cleanups_this_call; - -/* Nonzero means current function may call alloca - as a subroutine. (__builtin_alloca does not count.) */ -int may_call_alloca; - -rtx store_expr (); -static void store_constructor (); -static rtx store_field (); -static rtx expand_call (); -static void emit_call_1 (); -static rtx prepare_call_address (); -static rtx expand_builtin (); -static rtx compare (); -static rtx compare_constants (); -static rtx compare1 (); -static rtx do_store_flag (); -static void preexpand_calls (); -static rtx expand_increment (); -static void init_queue (); - -void do_pending_stack_adjust (); - -/* MOVE_RATIO is the number of move instructions that is better than - a block move. */ - -#ifndef MOVE_RATIO -#if defined (HAVE_movstrqi) || defined (HAVE_movstrhi) || defined (HAVE_movstrsi) -#define MOVE_RATIO 2 -#else -/* A value of around 6 would minimize code size; infinity would minimize - execution time. */ -#define MOVE_RATIO 15 -#endif -#endif - -/* Table indexed by tree code giving 1 if the code is for a - comparison operation, or anything that is most easily - computed with a conditional branch. - - We include tree.def to give it the proper length. - The contents thus created are irrelevant. - The real contents are initialized in init_comparisons. */ - -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) 0, - -static char comparison_code[] = { -#include "tree.def" -}; -#undef DEFTREECODE - -/* This is run once per compilation. */ - -void -init_comparisons () -{ - comparison_code[(int) EQ_EXPR] = 1; - comparison_code[(int) NE_EXPR] = 1; - comparison_code[(int) LT_EXPR] = 1; - comparison_code[(int) GT_EXPR] = 1; - comparison_code[(int) LE_EXPR] = 1; - comparison_code[(int) GE_EXPR] = 1; -} - -/* This is run at the start of compiling a function. */ - -void -init_expr () -{ - init_queue (); - may_call_alloca = 0; -} - -/* Manage the queue of increment instructions to be output - for POSTINCREMENT_EXPR expressions, etc. */ - -static rtx pending_chain; - -/* Queue up to increment (or change) VAR later. BODY says how: - BODY should be the same thing you would pass to emit_insn - to increment right away. It will go to emit_insn later on. - - The value is a QUEUED expression to be used in place of VAR - where you want to guarantee the pre-incrementation value of VAR. */ - -static rtx -enqueue_insn (var, body) - rtx var, body; -{ - pending_chain = gen_rtx (QUEUED, GET_MODE (var), - var, 0, 0, body, pending_chain); - return pending_chain; -} - -/* Use protect_from_queue to convert a QUEUED expression - into something that you can put immediately into an instruction. - If the queued incrementation has not happened yet, - protect_from_queue returns the variable itself. - If the incrementation has happened, protect_from_queue returns a temp - that contains a copy of the old value of the variable. - - Any time an rtx which might possibly be a QUEUED is to be put - into an instruction, it must be passed through protect_from_queue first. - QUEUED expressions are not meaningful in instructions. - - Do not pass a value through protect_from_queue and then hold - on to it for a while before putting it in an instruction! - If the queue is flushed in between, incorrect code will result. */ - -rtx -protect_from_queue (x, modify) - register rtx x; - int modify; -{ - register RTX_CODE code = GET_CODE (x); - - if (code != QUEUED) - { - /* A special hack for read access to (MEM (QUEUED ...)) - to facilitate use of autoincrement. - Make a copy of the contents of the memory location - rather than a copy of the address, but not - if the value is of mode BLKmode. */ - if (code == MEM && GET_MODE (x) != BLKmode - && GET_CODE (XEXP (x, 0)) == QUEUED && !modify) - { - register rtx y = XEXP (x, 0); - XEXP (x, 0) = QUEUED_VAR (y); - if (QUEUED_INSN (y)) - { - register rtx temp = gen_reg_rtx (GET_MODE (x)); - emit_insn_before (gen_move_insn (temp, x), - QUEUED_INSN (y)); - return temp; - } - return x; - } - /* Otherwise, recursively protect the subexpressions of all - the kinds of rtx's that can contain a QUEUED. */ - if (code == MEM) - XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0); - else if (code == PLUS || code == MULT) - { - XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0); - XEXP (x, 1) = protect_from_queue (XEXP (x, 1), 0); - } - return x; - } - /* If the increment has not happened, use the variable itself. */ - if (QUEUED_INSN (x) == 0) - return QUEUED_VAR (x); - /* If the increment has happened and a pre-increment copy exists, - use that copy. */ - if (QUEUED_COPY (x) != 0) - return QUEUED_COPY (x); - /* The increment has happened but we haven't set up a pre-increment copy. - Set one up now, and use it. */ - QUEUED_COPY (x) = gen_reg_rtx (GET_MODE (QUEUED_VAR (x))); - emit_insn_before (gen_move_insn (QUEUED_COPY (x), QUEUED_VAR (x)), - QUEUED_INSN (x)); - return QUEUED_COPY (x); -} - -/* Return nonzero if X contains a QUEUED expression: - if it contains anything that will be altered by a queued increment. - We handle only combinations of MEM, PLUS, MINUS and MULT operators - since memory addresses generally contain only those. */ - -static int -queued_subexp_p (x) - rtx x; -{ - register enum rtx_code code = GET_CODE (x); - switch (code) - { - case QUEUED: - return 1; - case MEM: - return queued_subexp_p (XEXP (x, 0)); - case MULT: - case PLUS: - case MINUS: - return queued_subexp_p (XEXP (x, 0)) - || queued_subexp_p (XEXP (x, 1)); - } - return 0; -} - -/* Perform all the pending incrementations. */ - -void -emit_queue () -{ - register rtx p; - while (p = pending_chain) - { - QUEUED_INSN (p) = emit_insn (QUEUED_BODY (p)); - pending_chain = QUEUED_NEXT (p); - } -} - -static void -init_queue () -{ - if (pending_chain) - abort (); -} - -/* Copy data from FROM to TO, where the machine modes are not the same. - Both modes may be integer, or both may be floating. - UNSIGNEDP should be nonzero if FROM is an unsigned type. - This causes zero-extension instead of sign-extension. */ - -void -convert_move (to, from, unsignedp) - register rtx to, from; - int unsignedp; -{ - enum machine_mode to_mode = GET_MODE (to); - enum machine_mode from_mode = GET_MODE (from); - int to_real = GET_MODE_CLASS (to_mode) == MODE_FLOAT; - int from_real = GET_MODE_CLASS (from_mode) == MODE_FLOAT; - int extending = (int) to_mode > (int) from_mode; - - to = protect_from_queue (to, 1); - from = protect_from_queue (from, 0); - - if (to_real != from_real) - abort (); - - if (to_mode == from_mode - || (from_mode == VOIDmode && CONSTANT_P (from))) - { - emit_move_insn (to, from); - return; - } - - if (to_real) - { -#ifdef HAVE_extendsfdf2 - if (HAVE_extendsfdf2 && extending) - { - emit_unop_insn (CODE_FOR_extendsfdf2, to, from, UNKNOWN); - return; - } -#endif -#ifdef HAVE_truncdfsf2 - if (HAVE_truncdfsf2 && ! extending) - { - emit_unop_insn (CODE_FOR_truncdfsf2, to, from, UNKNOWN); - return; - } -#endif - emit_library_call (gen_rtx (SYMBOL_REF, Pmode, (extending - ? "__extendsfdf2" - : "__truncdfsf2")), 0, - GET_MODE (to), 1, - from, (extending ? SFmode : DFmode)); - emit_move_insn (to, hard_libcall_value (GET_MODE (to))); - return; - } - - /* Now both modes are integers. */ - - if (to_mode == DImode) - { - if (unsignedp) - { -#ifdef HAVE_zero_extendsidi2 - if (HAVE_zero_extendsidi2 && from_mode == SImode) - emit_unop_insn (CODE_FOR_zero_extendsidi2, to, from, ZERO_EXTEND); - else -#endif -#ifdef HAVE_zero_extendhidi2 - if (HAVE_zero_extendhidi2 && from_mode == HImode) - emit_unop_insn (CODE_FOR_zero_extendhidi2, to, from, ZERO_EXTEND); - else -#endif -#ifdef HAVE_zero_extendqidi2 - if (HAVE_zero_extendqidi2 && from_mode == QImode) - emit_unop_insn (CODE_FOR_zero_extendqidi2, to, from, ZERO_EXTEND); - else -#endif -#ifdef HAVE_zero_extendsidi2 - if (HAVE_zero_extendsidi2) - { - convert_move (gen_lowpart (SImode, to), from, unsignedp); - emit_unop_insn (CODE_FOR_zero_extendsidi2, to, - gen_lowpart (SImode, to), ZERO_EXTEND); - } - else -#endif - { - emit_insn (gen_rtx (CLOBBER, VOIDmode, to)); - convert_move (gen_lowpart (SImode, to), from, unsignedp); - emit_clr_insn (gen_highpart (SImode, to)); - } - } -#ifdef HAVE_extendsidi2 - else if (HAVE_extendsidi2 && from_mode == SImode) - emit_unop_insn (CODE_FOR_extendsidi2, to, from, SIGN_EXTEND); -#endif -#ifdef HAVE_extendhidi2 - else if (HAVE_extendhidi2 && from_mode == HImode) - emit_unop_insn (CODE_FOR_extendhidi2, to, from, SIGN_EXTEND); -#endif -#ifdef HAVE_extendqidi2 - else if (HAVE_extendqidi2 && from_mode == QImode) - emit_unop_insn (CODE_FOR_extendqidi2, to, from, SIGN_EXTEND); -#endif -#ifdef HAVE_extendsidi2 - else if (HAVE_extendsidi2) - { - convert_move (gen_lowpart (SImode, to), from, unsignedp); - emit_unop_insn (CODE_FOR_extendsidi2, to, - gen_lowpart (SImode, to), SIGN_EXTEND); - } -#endif -#ifdef HAVE_slt - else if (HAVE_slt && insn_operand_mode[(int) CODE_FOR_slt][0] == SImode) - { - emit_insn (gen_rtx (CLOBBER, VOIDmode, to)); - convert_move (gen_lowpart (SImode, to), from, unsignedp); - emit_insn (gen_slt (gen_highpart (SImode, to))); - } -#endif - else - { - register rtx label = gen_label_rtx (); - - emit_insn (gen_rtx (CLOBBER, VOIDmode, to)); - emit_clr_insn (gen_highpart (SImode, to)); - convert_move (gen_lowpart (SImode, to), from, unsignedp); - emit_cmp_insn (gen_lowpart (SImode, to), - gen_rtx (CONST_INT, VOIDmode, 0), - 0, 0, 0); - NO_DEFER_POP; - emit_jump_insn (gen_bge (label)); - expand_unop (SImode, one_cmpl_optab, - gen_highpart (SImode, to), gen_highpart (SImode, to), - 1); - emit_label (label); - OK_DEFER_POP; - } - return; - } - - if (from_mode == DImode) - { - convert_move (to, gen_lowpart (SImode, from), 0); - return; - } - - /* Now follow all the conversions between integers - no more than a word long. */ - - /* For truncation, usually we can just refer to FROM in a narrower mode. */ - if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode) - && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode), - GET_MODE_BITSIZE (from_mode)) - && ((GET_CODE (from) == MEM - && ! MEM_VOLATILE_P (from) - && ! mode_dependent_address_p (XEXP (from, 0))) - || GET_CODE (from) == REG - || GET_CODE (from) == SUBREG)) - { - emit_move_insn (to, gen_lowpart (to_mode, from)); - return; - } - - if (to_mode == SImode && from_mode == HImode) - { - if (unsignedp) - { -#ifdef HAVE_zero_extendhisi2 - if (HAVE_zero_extendhisi2) - emit_unop_insn (CODE_FOR_zero_extendhisi2, to, from, ZERO_EXTEND); - else -#endif - abort (); - } - else - { -#ifdef HAVE_extendhisi2 - if (HAVE_extendhisi2) - emit_unop_insn (CODE_FOR_extendhisi2, to, from, SIGN_EXTEND); - else -#endif - abort (); - } - return; - } - - if (to_mode == SImode && from_mode == QImode) - { - if (unsignedp) - { -#ifdef HAVE_zero_extendqisi2 - if (HAVE_zero_extendqisi2) - { - emit_unop_insn (CODE_FOR_zero_extendqisi2, to, from, ZERO_EXTEND); - return; - } -#endif -#if defined (HAVE_zero_extendqihi2) && defined (HAVE_extendhisi2) - if (HAVE_zero_extendqihi2 && HAVE_extendhisi2) - { - register rtx temp = gen_reg_rtx (HImode); - emit_unop_insn (CODE_FOR_zero_extendqihi2, temp, from, ZERO_EXTEND); - emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND); - return; - } -#endif - } - else - { -#ifdef HAVE_extendqisi2 - if (HAVE_extendqisi2) - { - emit_unop_insn (CODE_FOR_extendqisi2, to, from, SIGN_EXTEND); - return; - } -#endif -#if defined (HAVE_extendqihi2) && defined (HAVE_extendhisi2) - if (HAVE_extendqihi2 && HAVE_extendhisi2) - { - register rtx temp = gen_reg_rtx (HImode); - emit_unop_insn (CODE_FOR_extendqihi2, temp, from, SIGN_EXTEND); - emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND); - return; - } -#endif - } - abort (); - } - - if (to_mode == HImode && from_mode == QImode) - { - if (unsignedp) - { -#ifdef HAVE_zero_extendqihi2 - if (HAVE_zero_extendqihi2) - { - emit_unop_insn (CODE_FOR_zero_extendqihi2, to, from, ZERO_EXTEND); - return; - } -#endif - } - else - { -#ifdef HAVE_extendqihi2 - if (HAVE_extendqihi2) - { - emit_unop_insn (CODE_FOR_extendqihi2, to, from, SIGN_EXTEND); - return; - } -#endif - } - abort (); - } - -#if 0 /* This seems to be redundant with code 100 lines up. */ - - /* Now we are truncating an integer to a smaller one. - If the result is a temporary, we might as well just copy it, - since only the low-order part of the result needs to be valid - and it is valid with no change. */ - - if (GET_CODE (to) == REG) - { - if (GET_CODE (from) == REG) - { - emit_move_insn (to, gen_lowpart (GET_MODE (to), from)); - return; - } - else if (GET_CODE (from) == SUBREG) - { - from = copy_rtx (from); - /* This is safe since FROM is not more than one word. */ - PUT_MODE (from, GET_MODE (to)); - emit_move_insn (to, from); - return; - } -#ifndef BYTES_BIG_ENDIAN - else if (GET_CODE (from) == MEM) - { - register rtx addr = XEXP (from, 0); - if (memory_address_p (GET_MODE (to), addr)) - { - emit_move_insn (to, gen_rtx (MEM, GET_MODE (to), addr)); - return; - } - } -#endif /* not BYTES_BIG_ENDIAN */ - } -#endif /* 0 */ - - if (from_mode == SImode && to_mode == HImode) - { -#ifdef HAVE_truncsihi2 - if (HAVE_truncsihi2) - { - emit_unop_insn (CODE_FOR_truncsihi2, to, from, UNKNOWN); - return; - } -#endif - abort (); - } - - if (from_mode == SImode && to_mode == QImode) - { -#ifdef HAVE_truncsiqi2 - if (HAVE_truncsiqi2) - { - emit_unop_insn (CODE_FOR_truncsiqi2, to, from, UNKNOWN); - return; - } -#endif - abort (); - } - - if (from_mode == HImode && to_mode == QImode) - { -#ifdef HAVE_trunchiqi2 - if (HAVE_trunchiqi2) - { - emit_unop_insn (CODE_FOR_trunchiqi2, to, from, UNKNOWN); - return; - } -#endif - abort (); - } - - /* Mode combination is not recognized. */ - abort (); -} - -/* Return an rtx for a value that would result - from converting X to mode MODE. - Both X and MODE may be floating, or both integer. - UNSIGNEDP is nonzero if X is an unsigned value. - This can be done by referring to a part of X in place - or by copying to a new temporary with conversion. */ - -rtx -convert_to_mode (mode, x, unsignedp) - enum machine_mode mode; - rtx x; - int unsignedp; -{ - register rtx temp; - if (mode == GET_MODE (x)) - return x; - if (integer_mode_p (mode) - && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (GET_MODE (x)) - && ! (GET_CODE (x) == MEM && MEM_VOLATILE_P (x))) - return gen_lowpart (mode, x); - temp = gen_reg_rtx (mode); - convert_move (temp, x, unsignedp); - return temp; -} - -int -integer_mode_p (mode) - enum machine_mode mode; -{ - return (int) mode > (int) VOIDmode && (int) mode <= (int) TImode; -} - -/* Generate several move instructions to copy LEN bytes - from block FROM to block TO. (These are MEM rtx's with BLKmode). - The caller must pass FROM and TO - through protect_from_queue before calling. - ALIGN (in bytes) is maximum alignment we can assume. */ - -struct move_by_pieces -{ - rtx to; - rtx to_addr; - int autinc_to; - int explicit_inc_to; - rtx from; - rtx from_addr; - int autinc_from; - int explicit_inc_from; - int len; - int offset; - int reverse; -}; - -static void move_by_pieces_1 (); -static int move_by_pieces_ninsns (); - -static void -move_by_pieces (to, from, len, align) - rtx to, from; - int len, align; -{ - struct move_by_pieces data; - rtx to_addr = XEXP (to, 0), from_addr = XEXP (from, 0); - - data.offset = 0; - data.to_addr = to_addr; - data.from_addr = from_addr; - data.to = to; - data.from = from; - data.autinc_to - = (GET_CODE (to_addr) == PRE_INC || GET_CODE (to_addr) == PRE_DEC - || GET_CODE (to_addr) == POST_INC || GET_CODE (to_addr) == POST_DEC); - data.autinc_from - = (GET_CODE (from_addr) == PRE_INC || GET_CODE (from_addr) == PRE_DEC - || GET_CODE (from_addr) == POST_INC - || GET_CODE (from_addr) == POST_DEC); - - data.explicit_inc_from = 0; - data.explicit_inc_to = 0; - data.reverse - = (GET_CODE (to_addr) == PRE_DEC || GET_CODE (to_addr) == POST_DEC); - if (data.reverse) data.offset = len; - data.len = len; - - /* If copying requires more than two move insns, - copy addresses to registers (to make displacements shorter) - and use post-increment if available. */ - if (!(data.autinc_from && data.autinc_to) - && move_by_pieces_ninsns (len, align) > 2) - { -#ifdef HAVE_PRE_DECREMENT - if (data.reverse && ! data.autinc_from) - { - data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len)); - data.autinc_from = 1; - data.explicit_inc_from = -1; - } -#endif -#ifdef HAVE_POST_INCREMENT - if (! data.autinc_from) - { - data.from_addr = copy_addr_to_reg (from_addr); - data.autinc_from = 1; - data.explicit_inc_from = 1; - } -#endif - if (!data.autinc_from && CONSTANT_P (from_addr)) - data.from_addr = copy_addr_to_reg (from_addr); -#ifdef HAVE_PRE_DECREMENT - if (data.reverse && ! data.autinc_to) - { - data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len)); - data.autinc_to = 1; - data.explicit_inc_to = -1; - } -#endif -#ifdef HAVE_POST_INCREMENT - if (! data.reverse && ! data.autinc_to) - { - data.to_addr = copy_addr_to_reg (to_addr); - data.autinc_to = 1; - data.explicit_inc_to = 1; - } -#endif - if (!data.autinc_to && CONSTANT_P (to_addr)) - data.to_addr = copy_addr_to_reg (to_addr); - } - -#ifdef STRICT_ALIGNMENT - if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT) - align = MOVE_MAX; -#else - align = MOVE_MAX; -#endif - -#ifdef HAVE_movti - if (HAVE_movti && align >= GET_MODE_SIZE (TImode)) - move_by_pieces_1 (gen_movti, TImode, &data); -#endif -#ifdef HAVE_movdi - if (HAVE_movdi && align >= GET_MODE_SIZE (DImode)) - move_by_pieces_1 (gen_movdi, DImode, &data); -#endif -#ifdef HAVE_movsi - if (align >= GET_MODE_SIZE (SImode)) - move_by_pieces_1 (gen_movsi, SImode, &data); -#endif -#ifdef HAVE_movhi - if (HAVE_movhi && align >= GET_MODE_SIZE (HImode)) - move_by_pieces_1 (gen_movhi, HImode, &data); -#endif -#ifdef HAVE_movqi - move_by_pieces_1 (gen_movqi, QImode, &data); -#else - movqi instruction required in machine description -#endif -} - -/* Return number of insns required to move L bytes by pieces. - ALIGN (in bytes) is maximum alignment we can assume. */ - -static int -move_by_pieces_ninsns (l, align) - unsigned int l; - int align; -{ - register int n_insns = 0; - -#ifdef STRICT_ALIGNMENT - if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT) - align = MOVE_MAX; -#else - align = MOVE_MAX; -#endif - -#ifdef HAVE_movti - if (HAVE_movti && align >= GET_MODE_SIZE (TImode)) - n_insns += l / GET_MODE_SIZE (TImode), l %= GET_MODE_SIZE (TImode); -#endif -#ifdef HAVE_movdi - if (HAVE_movdi && align >= GET_MODE_SIZE (DImode)) - n_insns += l / GET_MODE_SIZE (DImode), l %= GET_MODE_SIZE (DImode); -#endif -#ifdef HAVE_movsi - if (HAVE_movsi && align >= GET_MODE_SIZE (SImode)) - n_insns += l / GET_MODE_SIZE (SImode), l %= GET_MODE_SIZE (SImode); -#endif -#ifdef HAVE_movhi - if (HAVE_movhi && align >= GET_MODE_SIZE (HImode)) - n_insns += l / GET_MODE_SIZE (HImode), l %= GET_MODE_SIZE (HImode); -#endif - n_insns += l; - - return n_insns; -} - -/* Subroutine of move_by_pieces. Move as many bytes as appropriate - with move instructions for mode MODE. GENFUN is the gen_... function - to make a move insn for that mode. DATA has all the other info. */ - -static void -move_by_pieces_1 (genfun, mode, data) - rtx (*genfun) (); - enum machine_mode mode; - struct move_by_pieces *data; -{ - register int size = GET_MODE_SIZE (mode); - register rtx to1, from1; - - while (data->len >= size) - { - if (data->reverse) data->offset -= size; - - to1 = (data->autinc_to - ? gen_rtx (MEM, mode, data->to_addr) - : change_address (data->to, mode, - plus_constant (data->to_addr, data->offset))); - from1 = - (data->autinc_from - ? gen_rtx (MEM, mode, data->from_addr) - : change_address (data->from, mode, - plus_constant (data->from_addr, data->offset))); - -#ifdef HAVE_PRE_DECREMENT - if (data->explicit_inc_to < 0) - emit_insn (gen_sub2_insn (data->to_addr, - gen_rtx (CONST_INT, VOIDmode, size))); - if (data->explicit_inc_from < 0) - emit_insn (gen_sub2_insn (data->from_addr, - gen_rtx (CONST_INT, VOIDmode, size))); -#endif - - emit_insn ((*genfun) (to1, from1)); -#ifdef HAVE_POST_INCREMENT - if (data->explicit_inc_to > 0) - emit_insn (gen_add2_insn (data->to_addr, - gen_rtx (CONST_INT, VOIDmode, size))); - if (data->explicit_inc_from > 0) - emit_insn (gen_add2_insn (data->from_addr, - gen_rtx (CONST_INT, VOIDmode, size))); -#endif - - if (! data->reverse) data->offset += size; - - data->len -= size; - } -} - -/* Emit code to move a block Y to a block X. - This may be done with string-move instructions, - with multiple scalar move instructions, or with a library call. - - Both X and Y must be MEM rtx's (perhaps inside VOLATILE) - with mode BLKmode. - SIZE is an rtx that says how long they are. - ALIGN is the maximum alignment we can assume they have, - measured in bytes. */ - -static void -emit_block_move (x, y, size, align) - rtx x, y; - rtx size; - int align; -{ - if (GET_MODE (x) != BLKmode) - abort (); - - if (GET_MODE (y) != BLKmode) - abort (); - - x = protect_from_queue (x, 1); - y = protect_from_queue (y, 0); - - if (GET_CODE (x) != MEM) - abort (); - if (GET_CODE (y) != MEM) - abort (); - if (size == 0) - abort (); - - if (GET_CODE (size) == CONST_INT - && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align) - < MOVE_RATIO)) - move_by_pieces (x, y, INTVAL (size), align); - else - { - /* Try the most limited insn first, because there's no point - including more than one in the machine description unless - the more limited one has some advantage. */ -#ifdef HAVE_movstrqi - if (HAVE_movstrqi - && GET_CODE (size) == CONST_INT - && ((unsigned) INTVAL (size) - < (1 << (GET_MODE_BITSIZE (QImode) - 1)))) - { - emit_insn (gen_movstrqi (x, y, size, - gen_rtx (CONST_INT, VOIDmode, align))); - return; - } -#endif -#ifdef HAVE_movstrhi - if (HAVE_movstrhi - && GET_CODE (size) == CONST_INT - && ((unsigned) INTVAL (size) - < (1 << (GET_MODE_BITSIZE (HImode) - 1)))) - { - emit_insn (gen_movstrhi (x, y, size, - gen_rtx (CONST_INT, VOIDmode, align))); - return; - } -#endif -#ifdef HAVE_movstrsi - if (HAVE_movstrsi) - { - emit_insn (gen_movstrsi (x, y, size, - gen_rtx (CONST_INT, VOIDmode, align))); - return; - } -#endif - -#ifdef TARGET_MEM_FUNCTIONS - emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memcpy"), 0, - VOIDmode, 3, XEXP (x, 0), Pmode, - XEXP (y, 0), Pmode, - size, Pmode); -#else - emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcopy"), 0, - VOIDmode, 3, XEXP (y, 0), Pmode, - XEXP (x, 0), Pmode, - size, Pmode); -#endif - } -} - -/* Copy all or part of a BLKmode value X into registers starting at REGNO. - The number of registers to be filled is NREGS. */ - -void -move_block_to_reg (regno, x, nregs) - int regno; - rtx x; - int nregs; -{ - int i; - if (GET_CODE (x) == CONST_DOUBLE && x != dconst0_rtx) - x = force_const_double_mem (x); - for (i = 0; i < nregs; i++) - { - if (GET_CODE (x) == REG) - emit_move_insn (gen_rtx (REG, SImode, regno + i), - gen_rtx (SUBREG, SImode, x, i)); - else if (x == dconst0_rtx) - emit_move_insn (gen_rtx (REG, SImode, regno + i), - const0_rtx); - else - emit_move_insn (gen_rtx (REG, SImode, regno + i), - gen_rtx (MEM, SImode, - memory_address (SImode, - plus_constant (XEXP (x, 0), - i * GET_MODE_SIZE (SImode))))); - } -} - -/* Copy all or part of a BLKmode value X out of registers starting at REGNO. - The number of registers to be filled is NREGS. */ - -void -move_block_from_reg (regno, x, nregs) - int regno; - rtx x; - int nregs; -{ - int i; - for (i = 0; i < nregs; i++) - { - if (GET_CODE (x) == REG) - emit_move_insn (gen_rtx (SUBREG, SImode, x, i), - gen_rtx (REG, SImode, regno + i)); - else - emit_move_insn (gen_rtx (MEM, SImode, - memory_address (SImode, - plus_constant (XEXP (x, 0), - i * GET_MODE_SIZE (SImode)))), - gen_rtx (REG, SImode, regno + i)); - } -} - -/* Mark NREGS consecutive regs, starting at REGNO, as being live now. */ - -static void -use_regs (regno, nregs) - int regno; - int nregs; -{ - int i; - for (i = 0; i < nregs; i++) - emit_insn (gen_rtx (USE, VOIDmode, gen_rtx (REG, SImode, regno + i))); -} - -/* Write zeros through the storage of OBJECT. - If OBJECT has BLKmode, SIZE is its length in bytes. */ - -void -clear_storage (object, size) - rtx object; - int size; -{ - if (GET_MODE (object) == BLKmode) - { -#ifdef TARGET_MEM_FUNCTIONS - emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memset"), 0, - VOIDmode, 3, - XEXP (object, 0), Pmode, const0_rtx, Pmode, - gen_rtx (CONST_INT, VOIDmode, size), Pmode); -#else - emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bzero"), 0, - VOIDmode, 2, - XEXP (object, 0), Pmode, - gen_rtx (CONST_INT, VOIDmode, size), Pmode); -#endif - } - else - emit_move_insn (object, const0_rtx); -} - -/* Generate code to copy Y into X. - Both Y and X must have the same mode, except that - Y can be a constant with VOIDmode. - This mode cannot be BLKmode; use emit_block_move for that. - - Return the last instruction emitted. */ - -rtx -emit_move_insn (x, y) - rtx x, y; -{ - enum machine_mode mode = GET_MODE (x); - x = protect_from_queue (x, 1); - y = protect_from_queue (y, 0); - - if ((CONSTANT_P (y) || GET_CODE (y) == CONST_DOUBLE) - && ! LEGITIMATE_CONSTANT_P (y)) - { - y = force_const_mem (mode, y); - if (! memory_address_p (mode, XEXP (y, 0))) - y = gen_rtx (MEM, mode, memory_address (mode, XEXP (y, 0))); - } - - if (mode == BLKmode) - abort (); - if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing) - return - emit_insn (GEN_FCN (mov_optab->handlers[(int) mode].insn_code) (x, y)); -#if 0 - /* It turns out you get much better optimization (in cse and flow) - if you define movdi and movdf instruction patterns - even if they must turn into multiple assembler instructions. */ - else if (GET_MODE_SIZE (mode) >= GET_MODE_SIZE (SImode)) - { - register int count = GET_MODE_SIZE (mode) / GET_MODE_SIZE (SImode); - register int i; - if (GET_CODE (y) == CONST_DOUBLE && y != dconst0_rtx) - y = force_const_double_mem (y); - for (i = 0; i < count; i++) - { - rtx x1, y1; - if (GET_CODE (x) == REG) - x1 = gen_rtx (SUBREG, SImode, x, i); - else - x1 = gen_rtx (MEM, SImode, - memory_address (SImode, - plus_constant (XEXP (x, 0), - i * GET_MODE_SIZE (SImode)))); - if (GET_CODE (y) == REG) - y1 = gen_rtx (SUBREG, SImode, y, i); - else if (y == dconst0_rtx) - y1 = const0_rtx; - else - y1 = gen_rtx (MEM, SImode, - memory_address (SImode, - plus_constant (XEXP (y, 0), - i * GET_MODE_SIZE (SImode)))); - emit_insn (gen_movsi (protect_from_queue (x1, 1), protect_from_queue (y1, 0))); - } - } -#endif - else - abort (); -} - -/* Pushing data onto the stack. */ - -/* Push a block of length SIZE (perhaps variable) - and return an rtx to address the beginning of the block. - Note that it is not possible for the value returned to be a QUEUED. - The value may be stack_pointer_rtx. - - The value we return does take account of STACK_POINTER_OFFSET. */ - -rtx -push_block (size) - rtx size; -{ - register rtx temp; - if (CONSTANT_P (size) || GET_CODE (size) == REG) - anti_adjust_stack (size); - else - anti_adjust_stack (copy_to_mode_reg (Pmode, size)); - -#ifdef STACK_GROWS_DOWNWARD - temp = stack_pointer_rtx; -#else - temp = gen_rtx (PLUS, Pmode, - stack_pointer_rtx, - negate_rtx (Pmode, size)); - if (GET_CODE (size) != CONST_INT) - temp = force_operand (temp, 0); -#endif - -#ifdef STACK_POINTER_OFFSET - temp = plus_constant (temp, STACK_POINTER_OFFSET); -#endif /* STACK_POINTER_OFFSET */ - - return memory_address (QImode, temp); -} - -static rtx -gen_push_operand () -{ - return gen_rtx ( -#ifdef STACK_GROWS_DOWNWARD - PRE_DEC, -#else - PRE_INC, -#endif - Pmode, - stack_pointer_rtx); -} - -/* Generate code to push X onto the stack, assuming it has mode MODE. - MODE is redundant except when X is a CONST_INT (since they don't - carry mode info). - SIZE is an rtx for the size of data to be copied (in bytes), - needed only if X is BLKmode. - - ALIGN (in bytes) is maximum alignment we can assume. - - If PARTIAL is nonzero, then copy that many of the first words - of X into registers starting with REG, and push the rest of X. - The amount of space pushed is decreased by PARTIAL words, - rounded *down* to a multiple of PARM_BOUNDARY. - REG must be a hard register in this case. - - EXTRA is the amount in bytes of extra space to leave next to this arg. - - On a machine that lacks real push insns, ARGS_ADDR is the address of - the bottom of the argument block for this call. We use indexing off there - to store the arg. On machines with push insns, ARGS_ADDR is 0. - - ARGS_SO_FAR is the size of args previously pushed for this call. */ - -static void -emit_push_insn (x, mode, size, align, partial, reg, extra, args_addr, args_so_far) - register rtx x; - enum machine_mode mode; - rtx size; - int align; - int partial; - rtx reg; - int extra; - rtx args_addr; - rtx args_so_far; -{ - rtx xinner; - enum direction stack_direction -#ifdef STACK_GROWS_DOWNWARD - = downward; -#else - = upward; -#endif - - /* Decide where to pad the argument: `downward' for below, - `upward' for above, or `none' for don't pad it. - Default is below for small data on big-endian machines; else above. */ - enum direction where_pad = FUNCTION_ARG_PADDING (mode, size); - - xinner = x = protect_from_queue (x, 0); - - if (extra) - { - if (args_addr == 0) - { - /* Push padding now if padding above and stack grows down, - or if padding below and stack grows up. */ - if (where_pad != none && where_pad != stack_direction) - anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra)); - } - else - { - /* If space already allocated, just adjust the address we use. */ - if (where_pad == downward) - args_so_far = plus_constant (args_so_far, extra); - } - } - - if (mode == BLKmode) - { - /* Copy a block into the stack, entirely or partially. */ - - register rtx temp; - int used = partial * UNITS_PER_WORD; - int offset = used % (PARM_BOUNDARY / BITS_PER_UNIT); - int skip; - - if (size == 0) - abort (); - - used -= offset; - - /* USED is now the # of bytes we need not copy to the stack - because registers will take care of them. */ - - if (partial != 0) - xinner = change_address (xinner, BLKmode, - plus_constant (XEXP (xinner, 0), used)); - -/* If the partial register-part of the arg counts in its stack size, - skip the part of stack space corresponding to the registers. - Otherwise, start copying to the beginning of the stack space, - by setting SKIP to 0. */ -#ifndef FIRST_PARM_CALLER_OFFSET - skip = 0; -#else - skip = used; -#endif - -#ifdef PUSH_ROUNDING - /* Do it with several push insns if that doesn't take lots of insns - and if there is no difficulty with push insns that skip bytes - on the stack for alignment purposes. */ - if (args_addr == 0 - && GET_CODE (size) == CONST_INT - && args_addr == 0 - && skip == 0 - && (move_by_pieces_ninsns ((unsigned) INTVAL (size) - used, align) - < MOVE_RATIO) - && PUSH_ROUNDING (INTVAL (size)) == INTVAL (size)) - move_by_pieces (gen_rtx (MEM, BLKmode, gen_push_operand ()), xinner, - INTVAL (size) - used, align); - else -#endif /* PUSH_ROUNDING */ - { - /* Otherwise make space on the stack and copy the data - to the address of that space. */ - - /* Deduct words put into registers from the size we must copy. */ - if (partial != 0) - { - if (GET_CODE (size) == CONST_INT) - size = gen_rtx (CONST_INT, VOIDmode, INTVAL (size) - used); - else - size = expand_binop (GET_MODE (size), sub_optab, size, - gen_rtx (CONST_INT, VOIDmode, used), - 0, 0, OPTAB_LIB_WIDEN); - } - - /* Get the address of the stack space. */ - if (! args_addr) - temp = push_block (size); - else if (GET_CODE (args_so_far) == CONST_INT) - temp = memory_address (BLKmode, - plus_constant (args_addr, - skip + INTVAL (args_so_far))); - else - temp = memory_address (BLKmode, - plus_constant (gen_rtx (PLUS, Pmode, - args_addr, args_so_far), - skip)); - - /* TEMP is the address of the block. Copy the data there. */ - if (GET_CODE (size) == CONST_INT - && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align) - < MOVE_RATIO)) - { - move_by_pieces (gen_rtx (MEM, BLKmode, temp), xinner, - INTVAL (size), align); - goto ret; - } - /* Try the most limited insn first, because there's no point - including more than one in the machine description unless - the more limited one has some advantage. */ -#ifdef HAVE_movstrqi - if (HAVE_movstrqi - && GET_CODE (size) == CONST_INT - && ((unsigned) INTVAL (size) - < (1 << (GET_MODE_BITSIZE (QImode) - 1)))) - { - emit_insn (gen_movstrqi (gen_rtx (MEM, BLKmode, temp), - xinner, size, - gen_rtx (CONST_INT, VOIDmode, align))); - goto ret; - } -#endif -#ifdef HAVE_movstrhi - if (HAVE_movstrhi - && GET_CODE (size) == CONST_INT - && ((unsigned) INTVAL (size) - < (1 << (GET_MODE_BITSIZE (HImode) - 1)))) - { - emit_insn (gen_movstrhi (gen_rtx (MEM, BLKmode, temp), - xinner, size, - gen_rtx (CONST_INT, VOIDmode, align))); - goto ret; - } -#endif -#ifdef HAVE_movstrsi - if (HAVE_movstrsi) - { - emit_insn (gen_movstrsi (gen_rtx (MEM, BLKmode, temp), - xinner, size, - gen_rtx (CONST_INT, VOIDmode, align))); - goto ret; - } -#endif - - if (reg_mentioned_p (stack_pointer_rtx, temp)) - { - /* Now that emit_library_call does force_operand - before pushing anything, preadjustment does not work. */ - temp = copy_to_reg (temp); -#if 0 - /* Correct TEMP so it holds what will be a description of - the address to copy to, valid after one arg is pushed. */ - int xsize = GET_MODE_SIZE (Pmode); -#ifdef PUSH_ROUNDING - xsize = PUSH_ROUNDING (xsize); -#endif - xsize = ((xsize + PARM_BOUNDARY / BITS_PER_UNIT - 1) - / (PARM_BOUNDARY / BITS_PER_UNIT) - * (PARM_BOUNDARY / BITS_PER_UNIT)); -#ifdef TARGET_MEM_FUNCTIONS - /* If we are calling bcopy, we push one arg before TEMP. - If calling memcpy, we push two. */ - xsize *= 2; -#endif -#ifdef STACK_GROWS_DOWNWARD - temp = plus_constant (temp, xsize); -#else - temp = plus_constant (temp, -xsize); -#endif /* not STACK_GROWS_DOWNWARD */ -#endif /* 0 */ - } - - /* Make inhibit_defer_pop nonzero around the library call - to force it to pop the bcopy-arguments right away. */ - NO_DEFER_POP; -#ifdef TARGET_MEM_FUNCTIONS - emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memcpy"), 0, - VOIDmode, 3, temp, Pmode, XEXP (xinner, 0), Pmode, - size, Pmode); -#else - emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcopy"), 0, - VOIDmode, 3, XEXP (xinner, 0), Pmode, temp, Pmode, - size, Pmode); -#endif - OK_DEFER_POP; - } - } - else if (partial > 0) - { - /* Scalar partly in registers. */ - - int size = GET_MODE_SIZE (mode) / UNITS_PER_WORD; - int i; - int not_stack; - /* # words of start of argument - that we must make space for but need not store. */ - int offset = partial % (PARM_BOUNDARY / BITS_PER_WORD); - int args_offset = INTVAL (args_so_far); - int skip; - - /* If we make space by pushing it, we might as well push - the real data. Otherwise, we can leave OFFSET nonzero - and leave the space uninitialized. */ - if (args_addr == 0) - offset = 0; - - /* Now NOT_STACK gets the number of words that we don't need to - allocate on the stack. */ - not_stack = partial - offset; - -/* If the partial register-part of the arg counts in its stack size, - skip the part of stack space corresponding to the registers. - Otherwise, start copying to the beginning of the stack space, - by setting SKIP to 0. */ -#ifndef FIRST_PARM_CALLER_OFFSET - skip = 0; -#else - skip = not_stack; -#endif - - if (GET_CODE (x) == CONST_DOUBLE && x != dconst0_rtx) - x = force_const_double_mem (x); - - /* Loop over all the words allocated on the stack for this arg. */ - /* We can do it by words, because any scalar bigger than a word - has a size a multiple of a word. */ -#ifndef PUSH_ARGS_REVERSED - for (i = not_stack; i < size; i++) -#else - for (i = size - 1; i >= not_stack; i--) -#endif - if (i >= not_stack + offset) - { - rtx wd; - rtx addr; - /* Get the next word of the value in WD. */ - if (GET_CODE (x) == MEM) - { - rtx addr = memory_address (SImode, - plus_constant (XEXP (x, 0), - i * UNITS_PER_WORD)); - /* Copy to a reg, since machine may lack - memory-to-memory move insns. */ - wd = copy_to_reg (gen_rtx (MEM, SImode, addr)); - } - else if (GET_CODE (x) == REG) - wd = gen_rtx (SUBREG, SImode, x, i); - else if (x == dconst0_rtx) - wd = const0_rtx; - else - abort (); - - emit_push_insn (wd, - SImode, 0, align, 0, 0, 0, args_addr, - gen_rtx (CONST_INT, VOIDmode, - args_offset + (i - not_stack + skip) * UNITS_PER_WORD)); - } - } - else - { - rtx addr; -#ifdef PUSH_ROUNDING - if (args_addr == 0) - addr = gen_push_operand (); - else -#endif - if (GET_CODE (args_so_far) == CONST_INT) - addr - = memory_address (mode, - plus_constant (args_addr, INTVAL (args_so_far))); - else - addr = memory_address (mode, gen_rtx (PLUS, Pmode, args_addr, - args_so_far)); - - emit_move_insn (gen_rtx (MEM, mode, addr), x); - } - - ret: - /* If part should go in registers, copy that part - into the appropriate registers. Do this now, at the end, - since mem-to-mem copies above may do function calls. */ - if (partial > 0) - move_block_to_reg (REGNO (reg), x, partial); - - if (extra && args_addr == 0 && where_pad == stack_direction) - anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra)); -} - -/* Output a library call to function FUN (a SYMBOL_REF rtx) - (emitting the queue unless NO_QUEUE is nonzero), - for a value of mode OUTMODE, - with NARGS different arguments, passed as alternating rtx values - and machine_modes to convert them to. - The rtx values should have been passed through protect_from_queue already. */ - -void -emit_library_call (va_alist) - va_dcl -{ - register va_list p; - register int args_size = 0; - register int argnum; - enum machine_mode outmode; - int nargs; - rtx fun; - rtx orgfun; - int inc; - int count; - rtx *regvec; - rtx argblock = 0; - CUMULATIVE_ARGS args_so_far; - struct arg { rtx value; enum machine_mode mode; }; - struct arg *argvec; - int old_inhibit_defer_pop = inhibit_defer_pop; - int stack_padding = 0; - int no_queue = 0; - rtx use_insns; - - va_start (p); - orgfun = fun = va_arg (p, rtx); - no_queue = va_arg (p, int); - outmode = va_arg (p, enum machine_mode); - nargs = va_arg (p, int); - - regvec = (rtx *) alloca (nargs * sizeof (rtx)); - - /* Copy all the libcall-arguments out of the varargs data - and into a vector ARGVEC. */ - argvec = (struct arg *) alloca (nargs * sizeof (struct arg)); - for (count = 0; count < nargs; count++) - { - rtx val = va_arg (p, rtx); - enum machine_mode mode = va_arg (p, enum machine_mode); - - argvec[count].value = val; - - /* Convert the arg value to the mode the library wants. - Also make sure it is a reasonable operand - for a move or push insn. */ - /* ??? It is wrong to do it here; must do it earlier - where we know the signedness of the arg. */ - if (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode) - { - val = gen_reg_rtx (mode); - convert_move (val, argvec[count].value, 0); - } - else if (GET_CODE (val) != REG && GET_CODE (val) != MEM - - && ! ((CONSTANT_P (val) || GET_CODE (val) == CONST_DOUBLE) - && LEGITIMATE_CONSTANT_P (val))) - val = force_operand (val, 0); - - argvec[count].value = val; - argvec[count].mode = mode; - } - va_end (p); - - /* If we have no actual push instructions, make space for all the args - right now. */ -#ifndef PUSH_ROUNDING - INIT_CUMULATIVE_ARGS (args_so_far, (tree)0); - for (count = 0; count < nargs; count++) - { - register enum machine_mode mode = argvec[count].mode; - register rtx reg; - register int partial; - - reg = FUNCTION_ARG (args_so_far, mode, (tree)0, 1); -#ifdef FUNCTION_ARG_PARTIAL_NREGS - partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, (tree)0, 1); -#else - partial = 0; -#endif - if (reg == 0 || partial != 0) - args_size += GET_MODE_SIZE (mode); - if (partial != 0) - args_size -= partial * GET_MODE_SIZE (SImode); - FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1); - } - - if (args_size != 0) - { -#ifdef STACK_ARGS_ADJUST - struct args_size size; - size.constant = args_size; - size.var = 0; - STACK_ARGS_ADJUST (size); - args_size = size.constant; -#endif - argblock - = push_block (round_push (gen_rtx (CONST_INT, VOIDmode, args_size))); - } -#endif /* no PUSH_ROUNDING */ - - INIT_CUMULATIVE_ARGS (args_so_far, (tree)0); - -#ifdef PUSH_ARGS_REVERSED - inc = -1; - argnum = nargs - 1; -#else - inc = 1; - argnum = 0; -#endif - args_size = stack_padding; - - for (count = 0; count < nargs; count++, argnum += inc) - { - register enum machine_mode mode = argvec[argnum].mode; - register rtx val = argvec[argnum].value; - rtx reg; - int partial; - int arg_size; - - reg = FUNCTION_ARG (args_so_far, mode, (tree)0, 1); - regvec[argnum] = reg; -#ifdef FUNCTION_ARG_PARTIAL_NREGS - partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, (tree)0, 1); -#else - partial = 0; -#endif - - if (reg != 0 && partial == 0) - emit_move_insn (reg, val); - else - emit_push_insn (val, mode, 0, 0, partial, reg, 0, argblock, - gen_rtx (CONST_INT, VOIDmode, args_size)); - - /* Compute size of stack space used by this argument. */ - if (reg == 0 || partial != 0) - arg_size = GET_MODE_SIZE (mode); - else - arg_size = 0; - if (partial != 0) - arg_size - -= ((partial * UNITS_PER_WORD) - / (PARM_BOUNDARY / BITS_PER_UNIT) - * (PARM_BOUNDARY / BITS_PER_UNIT)); - - args_size += arg_size; - NO_DEFER_POP; - FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1); - } - - /* For version 1.37, try deleting this entirely. */ - if (! no_queue) - emit_queue (); - - fun = prepare_call_address (fun, 0); - - /* Any regs containing parms remain in use through the call. */ - start_sequence (); - for (count = 0; count < nargs; count++) - if (regvec[count] != 0) - emit_insn (gen_rtx (USE, VOIDmode, regvec[count])); - - use_insns = gen_sequence (); - end_sequence (); - -#ifdef STACK_BOUNDARY - args_size = (args_size + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES; -#endif - - /* Don't allow popping to be deferred, since then - cse'ing of library calls could delete a call and leave the pop. */ - NO_DEFER_POP; - emit_call_1 (fun, get_identifier (XSTR (orgfun, 0)), args_size, - FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1), - outmode != VOIDmode ? hard_libcall_value (outmode) : 0, - old_inhibit_defer_pop + 1, use_insns); - OK_DEFER_POP; -} - -/* Expand an assignment that stores the value of FROM into TO. - If WANT_VALUE is nonzero, return an rtx for the value of TO. - (This may contain a QUEUED rtx.) - Otherwise, the returned value is not meaningful. - - SUGGEST_REG is no longer actually used. - It used to mean, copy the value through a register - and return that register, if that is possible. - But now we do this if WANT_VALUE. - - If the value stored is a constant, we return the constant. */ - -rtx -expand_assignment (to, from, want_value, suggest_reg) - tree to, from; - int want_value; - int suggest_reg; -{ - register rtx to_rtx = 0; - - /* Don't crash if the lhs of the assignment was erroneous. */ - - if (TREE_CODE (to) == ERROR_MARK) - return expand_expr (from, 0, VOIDmode, 0); - - /* Assignment of a structure component needs special treatment - if the structure component's rtx is not simply a MEM. - Assignment of an array element at a constant index - has the same problem. */ - - if (TREE_CODE (to) == COMPONENT_REF - || (TREE_CODE (to) == ARRAY_REF - && TREE_CODE (TREE_OPERAND (to, 1)) == INTEGER_CST - && TREE_CODE (TYPE_SIZE (TREE_TYPE (to))) == INTEGER_CST)) - { - register enum machine_mode mode1; - int bitsize; - int volstruct = 0; - tree tem = to; - int bitpos = 0; - int unsignedp; - - if (TREE_CODE (to) == COMPONENT_REF) - { - tree field = TREE_OPERAND (to, 1); - bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field); - mode1 = DECL_MODE (TREE_OPERAND (to, 1)); - unsignedp = TREE_UNSIGNED (field); - } - else - { - mode1 = TYPE_MODE (TREE_TYPE (to)); - bitsize = GET_MODE_BITSIZE (mode1); - unsignedp = TREE_UNSIGNED (TREE_TYPE (to)); - } - - /* Compute cumulative bit-offset for nested component-refs - and array-refs, and find the ultimate containing object. */ - - while (1) - { - if (TREE_CODE (tem) == COMPONENT_REF) - { - bitpos += DECL_OFFSET (TREE_OPERAND (tem, 1)); - if (TREE_THIS_VOLATILE (tem)) - volstruct = 1; - } - else if (TREE_CODE (tem) == ARRAY_REF - && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST - && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST) - { - bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1)) - * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem))) - * TYPE_SIZE_UNIT (TREE_TYPE (tem))); - } - else - break; - tem = TREE_OPERAND (tem, 0); - } - /* TEM is now the containing data object. */ - - /* If we are going to use store_bit_field and extract_bit_field, - make sure to_rtx will be safe for multiple use. */ - if (mode1 == BImode && want_value) - tem = stabilize_reference (tem); - - to_rtx = expand_expr (tem, 0, VOIDmode, 0); - - return store_field (to_rtx, bitsize, bitpos, mode1, from, - (want_value - /* Spurious cast makes HPUX compiler happy. */ - ? (enum machine_mode) TYPE_MODE (TREE_TYPE (to)) - : VOIDmode), - unsignedp, - /* Required alignment of containing datum. */ - TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT); - } - - /* Ordinary treatment. Expand TO to get a REG or MEM rtx. - Don't re-expand if it was expanded already (in COMPONENT_REF case). */ - - if (to_rtx == 0) - to_rtx = expand_expr (to, 0, VOIDmode, 0); - - /* Compute FROM and store the value in the rtx we got. */ - - return store_expr (from, to_rtx, want_value); -} - -/* Generate code for computing expression EXP, - and storing the value into TARGET. - Returns TARGET or an equivalent value. - TARGET may contain a QUEUED rtx. - - If SUGGEST_REG is nonzero, copy the value through a register - and return that register, if that is possible. - - If the value stored is a constant, we return the constant. */ - -rtx -store_expr (exp, target, suggest_reg) - register tree exp; - register rtx target; - int suggest_reg; -{ - register rtx temp; - int dont_return_target = 0; - - /* Copying a non-constant CONSTRUCTOR needs special treatment. */ - - if (TREE_CODE (exp) == CONSTRUCTOR && ! TREE_LITERAL (exp)) - { - store_constructor (exp, target); - return target; - } - - if (suggest_reg && GET_CODE (target) == MEM && GET_MODE (target) != BLKmode) - /* If target is in memory and caller wants value in a register instead, - arrange that. Pass TARGET as target for expand_expr so that, - if EXP is another assignment, SUGGEST_REG will be nonzero for it. - We know expand_expr will not use the target in that case. */ - { - temp = expand_expr (exp, cse_not_expected ? 0 : target, - GET_MODE (target), 0); - if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode) - temp = copy_to_reg (temp); - dont_return_target = 1; - } - else if (queued_subexp_p (target)) - /* If target contains a postincrement, it is not safe - to use as the returned value. It would access the wrong - place by the time the queued increment gets output. - So copy the value through a temporary and use that temp - as the result. */ - { - temp = expand_expr (exp, 0, GET_MODE (target), 0); - if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode) - temp = copy_to_reg (temp); - dont_return_target = 1; - } - else - { - temp = expand_expr (exp, target, GET_MODE (target), 0); - /* DO return TARGET if it's a specified hardware register. - expand_return relies on this. */ - if (!(target && GET_CODE (target) == REG - && REGNO (target) < FIRST_PSEUDO_REGISTER) - && (CONSTANT_P (temp) || GET_CODE (temp) == CONST_DOUBLE)) - dont_return_target = 1; - } - - /* If value was not generated in the target, store it there. - Convert the value to TARGET's type first if nec. */ - - if (temp != target && TREE_CODE (exp) != ERROR_MARK) - { - target = protect_from_queue (target, 1); - if (GET_MODE (temp) != GET_MODE (target) - && GET_MODE (temp) != VOIDmode) - { - int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp)); - if (dont_return_target) - { - /* In this case, we will return TEMP, - so make sure it has the proper mode. - But don't forget to store the value into TARGET. */ - temp = convert_to_mode (GET_MODE (target), temp, unsignedp); - emit_move_insn (target, temp); - } - else - convert_move (target, temp, unsignedp); - } - - else if (GET_MODE (temp) == BLKmode) - emit_block_move (target, temp, expr_size (exp), - TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT); - else - emit_move_insn (target, temp); - } - if (dont_return_target) - return temp; - return target; -} - -/* Store the value of constructor EXP into the rtx TARGET. - TARGET is either a REG or a MEM. */ - -static void -store_constructor (exp, target) - tree exp; - rtx target; -{ - /* Don't try copying piece by piece into a hard register - since that is vulnerable to being clobbered by EXP. - Instead, construct in a pseudo register and then copy it all. */ - if (GET_CODE (target) == REG && REGNO (target) < FIRST_PSEUDO_REGISTER) - { - rtx temp = gen_reg_rtx (GET_MODE (target)); - store_constructor (exp, temp); - emit_move_insn (target, temp); - return; - } - - if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) - { - register tree elt; - - /* If the constructor has fewer fields than the structure, - clear the whole structure first. */ - - if (list_length (CONSTRUCTOR_ELTS (exp)) - != list_length (TYPE_FIELDS (TREE_TYPE (exp)))) - clear_storage (target, int_size_in_bytes (TREE_TYPE (exp))); - else - /* Inform later passes that the old value is dead. */ - emit_insn (gen_rtx (CLOBBER, VOIDmode, target)); - - /* Store each element of the constructor into - the corresponding field of TARGET. */ - - for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt)) - { - register tree field = TREE_PURPOSE (elt); - register enum machine_mode mode; - int bitsize; - int bitpos; - int unsignedp; - - bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field); - mode = DECL_MODE (field); - unsignedp = TREE_UNSIGNED (field); - - bitpos = DECL_OFFSET (field); - - store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt), - /* The alignment of TARGET is - at least what its type requires. */ - VOIDmode, 0, - TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT); - } - } - else if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) - { - register tree elt; - register int i; - tree domain = TYPE_DOMAIN (TREE_TYPE (exp)); - int minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain)); - int maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain)); - tree elttype = TREE_TYPE (TREE_TYPE (exp)); - - /* If the constructor has fewer fields than the structure, - clear the whole structure first. */ - - if (list_length (CONSTRUCTOR_ELTS (exp)) < maxelt - minelt + 1) - clear_storage (target, maxelt - minelt + 1); - else - /* Inform later passes that the old value is dead. */ - emit_insn (gen_rtx (CLOBBER, VOIDmode, target)); - - /* Store each element of the constructor into - the corresponding element of TARGET, determined - by counting the elements. */ - for (elt = CONSTRUCTOR_ELTS (exp), i = 0; - elt; - elt = TREE_CHAIN (elt), i++) - { - register enum machine_mode mode; - int bitsize; - int bitpos; - int unsignedp; - - mode = TYPE_MODE (elttype); - bitsize = GET_MODE_BITSIZE (mode); - unsignedp = TREE_UNSIGNED (elttype); - - bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype)) - * TYPE_SIZE_UNIT (elttype)); - - store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt), - /* The alignment of TARGET is - at least what its type requires. */ - VOIDmode, 0, - TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT); - } - } -} - -/* Store the value of EXP (an expression tree) - into a subfield of TARGET which has mode MODE and occupies - BITSIZE bits, starting BITPOS bits from the start of TARGET. - - If VALUE_MODE is VOIDmode, return nothing in particular. - UNSIGNEDP is not used in this case. - - Otherwise, return an rtx for the value stored. This rtx - has mode VALUE_MODE if that is convenient to do. - In this case, UNSIGNEDP must be nonzero if the value is an unsigned type. - - ALIGN is the alignment that TARGET is known to have, measured in bytes. */ - -static rtx -store_field (target, bitsize, bitpos, mode, exp, value_mode, unsignedp, align) - rtx target; - int bitsize, bitpos; - enum machine_mode mode; - tree exp; - enum machine_mode value_mode; - int unsignedp; - int align; -{ - /* If the structure is in a register or if the component - is a bit field, we cannot use addressing to access it. - Use bit-field techniques or SUBREG to store in it. */ - - if (mode == BImode || GET_CODE (target) == REG - || GET_CODE (target) == SUBREG) - { - store_bit_field (target, bitsize, bitpos, - mode, - expand_expr (exp, 0, VOIDmode, 0), - align); - if (value_mode != VOIDmode) - return extract_bit_field (target, bitsize, bitpos, unsignedp, - 0, value_mode, 0, align); - return const0_rtx; - } - else - { - rtx addr = XEXP (target, 0); - rtx to_rtx; - - /* If a value is wanted, it must be the lhs; - so make the address stable for multiple use. */ - - if (value_mode != VOIDmode && GET_CODE (addr) != REG - && ! CONSTANT_ADDRESS_P (addr)) - addr = copy_to_reg (addr); - - /* Now build a reference to just the desired component. */ - - to_rtx = change_address (target, mode, - plus_constant (addr, - (bitpos / BITS_PER_UNIT))); - MEM_IN_STRUCT_P (to_rtx) = 1; - - return store_expr (exp, to_rtx, value_mode != VOIDmode); - } -} - -/* Given an rtx VALUE that may contain additions and multiplications, - return an equivalent value that just refers to a register or memory. - This is done by generating instructions to perform the arithmetic - and returning a pseudo-register containing the value. */ - -rtx -force_operand (value, target) - rtx value, target; -{ - register optab binoptab = 0; - register rtx op2; - /* Use subtarget as the target for operand 0 of a binary operation. */ - register rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0); - - if (GET_CODE (value) == PLUS) - binoptab = add_optab; - else if (GET_CODE (value) == MINUS) - binoptab = sub_optab; - else if (GET_CODE (value) == MULT) - { - op2 = XEXP (value, 1); - if (!CONSTANT_P (op2) - && !(GET_CODE (op2) == REG && op2 != subtarget)) - subtarget = 0; - return expand_mult (GET_MODE (value), - force_operand (XEXP (value, 0), subtarget), - force_operand (op2, 0), - target, 0); - } - - if (binoptab) - { - op2 = XEXP (value, 1); - if (!CONSTANT_P (op2) - && !(GET_CODE (op2) == REG && op2 != subtarget)) - subtarget = 0; - if (binoptab == sub_optab - && GET_CODE (op2) == CONST_INT && INTVAL (op2) < 0) - { - binoptab = add_optab; - op2 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op2)); - } - return expand_binop (GET_MODE (value), binoptab, - force_operand (XEXP (value, 0), subtarget), - force_operand (op2, 0), - target, 0, OPTAB_LIB_WIDEN); - /* We give UNSIGNEP = 0 to expand_binop - because the only operations we are expanding here are signed ones. */ - } - return value; -} - -/* expand_expr: generate code for computing expression EXP. - An rtx for the computed value is returned. The value is never null. - In the case of a void EXP, const0_rtx is returned. - - The value may be stored in TARGET if TARGET is nonzero. - TARGET is just a suggestion; callers must assume that - the rtx returned may not be the same as TARGET. - - If TARGET is CONST0_RTX, it means that the value will be ignored. - - If TMODE is not VOIDmode, it suggests generating the - result in mode TMODE. But this is done only when convenient. - Otherwise, TMODE is ignored and the value generated in its natural mode. - TMODE is just a suggestion; callers must assume that - the rtx returned may not have mode TMODE. - - If MODIFIER is EXPAND_SUM then when EXP is an addition - we can return an rtx of the form (MULT (REG ...) (CONST_INT ...)) - or a nest of (PLUS ...) and (MINUS ...) where the terms are - products as above, or REG or MEM, or constant. - Ordinarily in such cases we would output mul or add instructions - and then return a pseudo reg containing the sum. - - If MODIFIER is EXPAND_CONST_ADDRESS then it is ok to return - a MEM rtx whose address is a constant that isn't a legitimate address. */ - -/* Subroutine of expand_expr: - save the non-copied parts (LIST) of an expr (LHS), and return a list - which can restore these values to their previous values, - should something modify their storage. */ -static tree -save_noncopied_parts (lhs, list) - tree lhs; - tree list; -{ - tree tail; - tree parts = 0; - - for (tail = list; tail; tail = TREE_CHAIN (tail)) - if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST) - parts = chainon (parts, save_noncopied_parts (lhs, TREE_VALUE (tail))); - else - { - tree part = TREE_VALUE (tail); - tree part_type = TREE_TYPE (part); - tree to_be_saved = build (COMPONENT_REF, part_type, lhs, part, 0); - rtx target = assign_stack_local (TYPE_MODE (part_type), - int_size_in_bytes (part_type)); - if (! memory_address_p (TYPE_MODE (part_type), XEXP (target, 0))) - target = change_address (target, TYPE_MODE (part_type), 0); - parts = tree_cons (to_be_saved, - build (RTL_EXPR, part_type, 0, (tree) target), - parts); - store_expr (TREE_PURPOSE (parts), RTL_EXPR_RTL (TREE_VALUE (parts)), 0); - } - return parts; -} - -/* Subroutine of expand_expr: - save the non-copied parts (LIST) of an expr (LHS), and return a list - which can restore these values to their previous values, - should something modify their storage. */ -static tree -init_noncopied_parts (lhs, list) - tree lhs; - tree list; -{ - tree tail; - tree parts = 0; - - for (tail = list; tail; tail = TREE_CHAIN (tail)) - if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST) - parts = chainon (parts, init_noncopied_parts (lhs, TREE_VALUE (tail))); - else - { - tree part = TREE_VALUE (tail); - tree part_type = TREE_TYPE (part); - tree to_be_initialized = build (COMPONENT_REF, part_type, lhs, part, 0); - parts = tree_cons (TREE_PURPOSE (tail), to_be_initialized, parts); - } - return parts; -} - -/* Subroutine of expand_expr: - return the target to use when recursively expanding - the first operand of an arithmetic operation. */ - -static rtx -validate_subtarget (subtarget, otherop) - rtx subtarget; - tree otherop; -{ - if (TREE_LITERAL (otherop)) - return subtarget; - if (TREE_CODE (otherop) == VAR_DECL - && DECL_RTL (otherop) != subtarget) - return subtarget; - return 0; -} - -static int -fixed_type_p (exp) - tree exp; -{ - if (TREE_CODE (exp) == PARM_DECL - || TREE_CODE (exp) == VAR_DECL - || TREE_CODE (exp) == CALL_EXPR || TREE_CODE (exp) == NEW_EXPR - || TREE_CODE (exp) == COMPONENT_REF - || TREE_CODE (exp) == ARRAY_REF) - return 1; - return 0; -} - -rtx -expand_expr (exp, target, tmode, modifier) - register tree exp; - rtx target; - enum machine_mode tmode; - enum expand_modifier modifier; -{ - extern rtx (*lang_expand_expr)(); - register rtx op0, op1, temp; - tree type = TREE_TYPE (exp); - register enum machine_mode mode = TYPE_MODE (type); - register enum tree_code code = TREE_CODE (exp); - optab this_optab; - int negate_1; - /* Use subtarget as the target for operand 0 of a binary operation. */ - rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0); - rtx original_target = target; - int ignore = target == const0_rtx; - - /* Don't use hard regs as subtargets, because the combiner - can only handle pseudo regs. */ - if (subtarget && REGNO (subtarget) < FIRST_PSEUDO_REGISTER) - subtarget = 0; - /* Avoid subtargets inside loops, - since they hide some invariant expressions. */ - if (optimize && inside_loop ()) - subtarget = 0; - - if (ignore) target = 0, original_target = 0; - - /* If will do cse, generate all results into registers - since 1) that allows cse to find more things - and 2) otherwise cse could produce an insn the machine - cannot support. */ - - if (! cse_not_expected && mode != BLKmode) - target = subtarget; - - /* No sense saving up arithmetic to be done - if it's all in the wrong mode to form part of an address. - And force_operand won't know whether to sign-extend or zero-extend. */ - - if (mode != Pmode && modifier == EXPAND_SUM) - modifier = EXPAND_NORMAL; - - switch (code) - { - case PARM_DECL: - if (DECL_RTL (exp) == 0) - { - error_with_decl (exp, "prior parameter's size depends on `%s'"); - return const0_rtx; - } - - case FUNCTION_DECL: - case VAR_DECL: - case RESULT_DECL: - if (DECL_RTL (exp) == 0) - abort (); - /* Must mark EXP used because it might be a compiler-generated - variable used by a compiler-generated expression. */ - TREE_USED (exp) = 1; - /* This is the case of an array whose size is to be determined - from its initializer, while the initializer is still being parsed. - See expand_decl. */ - if (GET_CODE (DECL_RTL (exp)) == MEM - && GET_CODE (XEXP (DECL_RTL (exp), 0)) == REG) - return change_address (DECL_RTL (exp), GET_MODE (DECL_RTL (exp)), - XEXP (DECL_RTL (exp), 0)); - if (GET_CODE (DECL_RTL (exp)) == MEM - && modifier != EXPAND_CONST_ADDRESS) - { - /* DECL_RTL probably contains a constant address. - On RISC machines where a constant address isn't valid, - make some insns to get that address into a register. */ - if (!memory_address_p (DECL_MODE (exp), XEXP (DECL_RTL (exp), 0)) - || (flag_force_addr - && CONSTANT_ADDRESS_P (XEXP (DECL_RTL (exp), 0)))) - return change_address (DECL_RTL (exp), VOIDmode, - copy_rtx (XEXP (DECL_RTL (exp), 0))); - } - return DECL_RTL (exp); - - case INTEGER_CST: - if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT) - return gen_rtx (CONST_INT, VOIDmode, TREE_INT_CST_LOW (exp)); - /* Generate immediate CONST_DOUBLE - which will be turned into memory by reload if necessary. */ - return immed_double_const (TREE_INT_CST_LOW (exp), - TREE_INT_CST_HIGH (exp), - mode); - - case CONST_DECL: - return expand_expr (DECL_INITIAL (exp), target, VOIDmode, 0); - - case REAL_CST: - /* If optimized, generate immediate CONST_DOUBLE - which will be turned into memory by reload if necessary. */ - if (!cse_not_expected) - return immed_real_const (exp); - case COMPLEX_CST: - case STRING_CST: - if (! TREE_CST_RTL (exp)) - output_constant_def (exp); - - /* TREE_CST_RTL probably contains a constant address. - On RISC machines where a constant address isn't valid, - make some insns to get that address into a register. */ - if (GET_CODE (TREE_CST_RTL (exp)) == MEM - && modifier != EXPAND_CONST_ADDRESS - && !memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0))) - return change_address (TREE_CST_RTL (exp), VOIDmode, - copy_rtx (XEXP (TREE_CST_RTL (exp), 0))); - return TREE_CST_RTL (exp); - - case SAVE_EXPR: - if (SAVE_EXPR_RTL (exp) == 0) - { - rtx reg = gen_reg_rtx (mode); - SAVE_EXPR_RTL (exp) = reg; - store_expr (TREE_OPERAND (exp, 0), reg, 0); - if (!optimize) - save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, reg, - save_expr_regs); - } - /* Don't let the same rtl node appear in two places. */ - return SAVE_EXPR_RTL (exp); - - case IF_STMT: - emit_line_note (STMT_SOURCE_FILE (exp), STMT_SOURCE_LINE (exp)); - - /* Exit flag is 0 for now. */ - expand_start_cond (STMT_COND (exp), 0); - expand_expr_stmt (STMT_THEN (exp)); - if (STMT_ELSE (exp) == 0) - expand_end_cond (); - else - { - expand_start_else (); - expand_expr_stmt (STMT_ELSE (exp)); - expand_end_else (); - } - return const0_rtx; - - case LOOP_STMT: - { - tree vars = STMT_LOOP_VARS (exp); - - emit_line_note (STMT_SOURCE_FILE (exp), STMT_SOURCE_LINE (exp)); - - while (vars) - { - if (DECL_RTL (vars) == 0) - expand_decl (vars); - expand_decl_init (vars); - vars = TREE_CHAIN (vars); - } - - if (TREE_READONLY (exp)) - { - /* Looks like a `while-do' loop. */ - expand_start_loop (1); - expand_exit_loop_if_false (STMT_LOOP_COND (exp)); - expand_expr_stmt (STMT_LOOP_BODY (exp)); - expand_end_loop (); - } - else - { - /* Looks like a `do-while' loop. */ - expand_start_loop_continue_elsewhere (1); - expand_expr_stmt (STMT_LOOP_BODY (exp)); - expand_loop_continue_here (); - expand_exit_loop_if_false (STMT_LOOP_COND (exp)); - expand_end_loop (); - } - - if (obey_regdecls) - for (vars = STMT_LOOP_VARS (exp); vars; vars = TREE_CHAIN (vars)) - use_variable (DECL_RTL (vars)); - } - return const0_rtx; - - case LET_STMT: - { - tree vars = STMT_VARS (exp); - - TREE_USED (exp) = 1; - - /* If VARS have not yet been expanded, expand them now. */ - while (vars) - { - if (DECL_RTL (vars) == 0) - expand_decl (vars); - /* Have to initialize these vars whereever this LET_STMT - is expanded. */ - expand_decl_init (vars); - vars = TREE_CHAIN (vars); - } - - temp = expand_expr (STMT_BODY (exp), target, tmode, modifier); - - if (obey_regdecls) - for (vars = STMT_VARS (exp); vars; vars = TREE_CHAIN (vars)) - /* TYPE_DECLs do not have rtl. */ - if (DECL_RTL (vars)) - use_variable (DECL_RTL (vars)); - - return temp; - } - - case RTL_EXPR: - if (RTL_EXPR_SEQUENCE (exp) == const0_rtx) - abort (); - emit_insns (RTL_EXPR_SEQUENCE (exp)); - RTL_EXPR_SEQUENCE (exp) = const0_rtx; - return RTL_EXPR_RTL (exp); - - case CONSTRUCTOR: - /* All elts simple constants => refer to a constant in memory. */ - if (TREE_STATIC (exp)) - /* For aggregate types with non-BLKmode modes, - this should ideally construct a CONST_INT. */ - { - rtx constructor = output_constant_def (exp); - if (! memory_address_p (GET_MODE (constructor), - XEXP (constructor, 0))) - constructor = change_address (constructor, VOIDmode, - XEXP (constructor, 0)); - return constructor; - } - - if (ignore) - { - tree elt; - for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt)) - expand_expr (TREE_VALUE (elt), const0_rtx, VOIDmode, 0); - return const0_rtx; - } - else - { - if (target == 0) - target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), - get_structure_value_addr (expr_size (exp))); - store_expr (exp, target, 0); - return target; - } - - case INDIRECT_REF: - { - tree exp1 = TREE_OPERAND (exp, 0); - tree exp2; - - /* A SAVE_EXPR as the address in an INDIRECT_EXPR is generated - for *PTR += ANYTHING where PTR is put inside the SAVE_EXPR. - This code has the same general effect as simply doing - expand_expr on the save expr, except that the expression PTR - is computed for use as a memory address. This means different - code, suitable for indexing, may be generated. */ - if (TREE_CODE (exp1) == SAVE_EXPR - && SAVE_EXPR_RTL (exp1) == 0 - && TREE_CODE (exp2 = TREE_OPERAND (exp1, 0)) != ERROR_MARK - && TYPE_MODE (TREE_TYPE (exp1)) == Pmode - && TYPE_MODE (TREE_TYPE (exp2)) == Pmode) - { - temp = expand_expr (TREE_OPERAND (exp1, 0), 0, VOIDmode, EXPAND_SUM); - op0 = memory_address (mode, temp); - op0 = copy_all_regs (op0); - SAVE_EXPR_RTL (exp1) = op0; - } - else - { - if (modifier == EXPAND_INTO_STACK - && original_target - && GET_CODE (original_target) == MEM) - op0 = expand_expr (exp1, XEXP (original_target, 0), - VOIDmode, EXPAND_INTO_STACK); - else - op0 = expand_expr (exp1, 0, VOIDmode, EXPAND_SUM); - op0 = memory_address (mode, op0); - } - } - temp = gen_rtx (MEM, mode, op0); - /* If address was computed by addition, - mark this as an element of an aggregate. */ - if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR - || (TREE_CODE (TREE_OPERAND (exp, 0)) == SAVE_EXPR - && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == PLUS_EXPR)) - MEM_IN_STRUCT_P (temp) = 1; - MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp) || flag_volatile; - RTX_UNCHANGING_P (temp) = TREE_READONLY (exp); - return temp; - - case ARRAY_REF: - if (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST - || TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST) - { - /* Nonconstant array index or nonconstant element size. - Generate the tree for *(&array+index) and expand that, - except do it in a language-independent way - and don't complain about non-lvalue arrays. - `mark_addressable' should already have been called - for any array for which this case will be reached. */ - - tree array_adr = build1 (ADDR_EXPR, TYPE_POINTER_TO (type), - TREE_OPERAND (exp, 0)); - tree index = TREE_OPERAND (exp, 1); - tree elt; - - /* Convert the integer argument to a type the same size as a pointer - so the multiply won't overflow spuriously. */ - if (TYPE_PRECISION (TREE_TYPE (index)) != POINTER_SIZE) - index = convert (type_for_size (POINTER_SIZE, 0), index); - - /* The array address isn't volatile even if the array is. */ - TREE_VOLATILE (array_adr) = 0; - - elt = build1 (INDIRECT_REF, type, - fold (build (PLUS_EXPR, TYPE_POINTER_TO (type), - array_adr, - fold (build (MULT_EXPR, - TYPE_POINTER_TO (type), - index, size_in_bytes (type)))))); - - return expand_expr (elt, target, tmode, modifier); - } - - /* Fold an expression like: "foo"[2]. - This is not done in fold so it won't happen inside &. */ - { - int i; - tree arg0 = TREE_OPERAND (exp, 0); - tree arg1 = TREE_OPERAND (exp, 1); - - if (TREE_CODE (arg0) == STRING_CST - && TREE_CODE (arg1) == INTEGER_CST - && !TREE_INT_CST_HIGH (arg1) - && (i = TREE_INT_CST_LOW (arg1)) < TREE_STRING_LENGTH (arg0)) - { - if (TREE_TYPE (TREE_TYPE (arg0)) == integer_type_node) - { - exp = build_int_2 (((int *)TREE_STRING_POINTER (arg0))[i], 0); - TREE_TYPE (exp) = integer_type_node; - return expand_expr (exp, target, tmode, modifier); - } - if (TREE_TYPE (TREE_TYPE (arg0)) == char_type_node) - { - exp = build_int_2 (TREE_STRING_POINTER (arg0)[i], 0); - TREE_TYPE (exp) = integer_type_node; - return expand_expr (convert (TREE_TYPE (TREE_TYPE (arg0)), exp), target, tmode, modifier); - } - } - } - - /* If this is a constant index into a constant array, - just get the value from the array. */ - if (TREE_READONLY (TREE_OPERAND (exp, 0)) - && ! TREE_VOLATILE (TREE_OPERAND (exp, 0)) - && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == ARRAY_TYPE - && TREE_LITERAL (TREE_OPERAND (exp, 1)) - && TREE_CODE (TREE_OPERAND (exp, 0)) == VAR_DECL - && DECL_INITIAL (TREE_OPERAND (exp, 0)) - && TREE_CODE (DECL_INITIAL (TREE_OPERAND (exp, 0))) != ERROR_MARK) - { - tree index = fold (TREE_OPERAND (exp, 1)); - if (TREE_CODE (index) == INTEGER_CST) - { - int i = TREE_INT_CST_LOW (index); - tree init = CONSTRUCTOR_ELTS (DECL_INITIAL (TREE_OPERAND (exp, 0))); - - while (init && i--) - init = TREE_CHAIN (init); - if (init) - return expand_expr (fold (TREE_VALUE (init)), target, tmode, modifier); - } - } - /* Treat array-ref with constant index as a component-ref. */ - - case COMPONENT_REF: - { - register enum machine_mode mode1; - int volstruct = 0; - int bitsize; - tree tem = exp; - int bitpos = 0; - int unsignedp; - - if (TREE_CODE (exp) == COMPONENT_REF) - { - tree field = TREE_OPERAND (exp, 1); - bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field); - mode1 = DECL_MODE (field); - unsignedp = TREE_UNSIGNED (field); - } - else - { - mode1 = TYPE_MODE (TREE_TYPE (exp)); - bitsize = GET_MODE_BITSIZE (mode1); - unsignedp = TREE_UNSIGNED (TREE_TYPE (exp)); - } - - /* Compute cumulative bit-offset for nested component-refs - and array-refs, and find the ultimate containing object. */ - - while (1) - { - if (TREE_CODE (tem) == COMPONENT_REF) - { - bitpos += DECL_OFFSET (TREE_OPERAND (tem, 1)); - if (TREE_THIS_VOLATILE (tem)) - volstruct = 1; - } - else if (TREE_CODE (tem) == ARRAY_REF - && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST - && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST) - { - bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1)) - * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem))) - * TYPE_SIZE_UNIT (TREE_TYPE (tem))); - } - else - break; - tem = TREE_OPERAND (tem, 0); - } - - op0 = expand_expr (tem, 0, VOIDmode, - (modifier == EXPAND_CONST_ADDRESS - ? modifier : EXPAND_NORMAL)); - - if (mode1 == BImode || GET_CODE (op0) == REG - || GET_CODE (op0) == SUBREG) - return extract_bit_field (op0, bitsize, bitpos, unsignedp, - target, mode, tmode, - TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT); - /* Get a reference to just this component. */ - if (modifier == EXPAND_CONST_ADDRESS) - op0 = gen_rtx (MEM, mode1, plus_constant (XEXP (op0, 0), - (bitpos / BITS_PER_UNIT))); - else - op0 = change_address (op0, mode1, - plus_constant (XEXP (op0, 0), - (bitpos / BITS_PER_UNIT))); - MEM_IN_STRUCT_P (op0) = 1; - MEM_VOLATILE_P (op0) |= volstruct; - /* If OP0 is in the shared structure-value stack slot, - and it is not BLKmode, copy it into a register. - The shared slot may be clobbered at any time by another call. - BLKmode is safe because our caller will either copy the value away - or take another component and come back here. */ - if (mode != BLKmode - && TREE_CODE (TREE_OPERAND (exp, 0)) == CALL_EXPR - && TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == BLKmode) - op0 = copy_to_reg (op0); - if (mode == mode1 || mode1 == BLKmode || mode1 == tmode) - return op0; - if (target == 0) - target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode); - convert_move (target, op0, unsignedp); - return target; - } - - /* Intended for a reference to a buffer of a file-object in Pascal. - But it's not certain that a special tree code will really be - necessary for these. INDIRECT_REF might work for them. */ - case BUFFER_REF: - abort (); - - case WITH_CLEANUP_EXPR: - if (RTL_EXPR_RTL (exp) == 0) - { - RTL_EXPR_RTL (exp) - = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier); - cleanups_this_call = tree_cons (0, TREE_OPERAND (exp, 2), cleanups_this_call); - /* That's it for this cleanup. */ - TREE_OPERAND (exp, 2) = 0; - } - return RTL_EXPR_RTL (exp); - - case OFFSET_REF: - return expand_expr (resolve_offset_ref (exp), target, tmode, modifier); - - case CALL_EXPR: - /* Check for a built-in function. */ - if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL - && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) - != NOT_BUILT_IN)) - return expand_builtin (exp, target, subtarget, tmode, ignore); - /* If this call was expanded already by preexpand_calls, - just return the result we got. */ - if (CALL_EXPR_RTL (exp) != 0) - return CALL_EXPR_RTL (exp); - return expand_call (exp, - (modifier == EXPAND_INTO_STACK) ? original_target : target, - ignore, modifier); - - case NOP_EXPR: - case CONVERT_EXPR: - case REFERENCE_EXPR: - if (TREE_CODE (type) == VOID_TYPE || ignore) - { - expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, modifier); - return const0_rtx; - } - if (mode == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))) - return expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, modifier); - op0 = expand_expr (TREE_OPERAND (exp, 0), 0, mode, 0); - if (GET_MODE (op0) == mode || GET_MODE (op0) == VOIDmode) - return op0; - if (flag_force_mem && GET_CODE (op0) == MEM) - op0 = copy_to_reg (op0); - if (GET_MODE (op0) == VOIDmode) - /* Avoid problem in convert_move due to unknown mode of OP0. */ - op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))), - op0); - if (target == 0) - target = gen_reg_rtx (mode); - convert_move (target, op0, TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)))); - return target; - - case PLUS_EXPR: - preexpand_calls (exp); - if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST - && modifier == EXPAND_SUM) - { - op1 = expand_expr (TREE_OPERAND (exp, 1), subtarget, VOIDmode, EXPAND_SUM); - op1 = plus_constant (op1, TREE_INT_CST_LOW (TREE_OPERAND (exp, 0))); - return op1; - } - negate_1 = 1; - plus_minus: - if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST - && modifier == EXPAND_SUM) - { - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM); - op0 = plus_constant (op0, - negate_1 * TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))); - return op0; - } - this_optab = add_optab; - if (modifier != EXPAND_SUM) goto binop; - subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1)); - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM); - op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, EXPAND_SUM); - /* Put a sum last, to simplify what follows. */ -#ifdef OLD_INDEXING - if (GET_CODE (op1) == MULT) - { - temp = op0; - op0 = op1; - op1 = temp; - } -#endif -#ifndef OLD_INDEXING - /* Make sure any term that's a sum with a constant comes last. */ - if (GET_CODE (op0) == PLUS - && CONSTANT_P (XEXP (op0, 1))) - { - temp = op0; - op0 = op1; - op1 = temp; - } - /* If adding to a sum including a constant, - associate it to put the constant outside. */ - if (GET_CODE (op1) == PLUS - && CONSTANT_P (XEXP (op1, 1))) - { - rtx tem; - int constant_term = 0; - - op0 = gen_rtx (PLUS, mode, XEXP (op1, 0), op0); - /* Let's also eliminate constants from op0 if possible. */ - tem = eliminate_constant_term (op0, &constant_term); - if (GET_CODE (XEXP (op1, 1)) == CONST_INT) - { - if (constant_term != 0) - return plus_constant (tem, INTVAL (XEXP (op1, 1)) + constant_term); - else - return plus_constant (op0, INTVAL (XEXP (op1, 1))); - } - else - return gen_rtx (PLUS, mode, op0, XEXP (op1, 1)); - } -#endif - return gen_rtx (PLUS, mode, op0, op1); - - case MINUS_EXPR: - preexpand_calls (exp); - if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST - && GET_MODE_BITSIZE (TYPE_MODE (type)) <= HOST_BITS_PER_INT) - { - int negated; - if (modifier == EXPAND_SUM) - { - negate_1 = -1; - goto plus_minus; - } - subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1)); - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - negated = - TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)); - if (GET_MODE_BITSIZE (mode) < HOST_BITS_PER_INT) - negated &= (1 << GET_MODE_BITSIZE (mode)) - 1; - op1 = gen_rtx (CONST_INT, VOIDmode, negated); - this_optab = add_optab; - goto binop2; - } - this_optab = sub_optab; - goto binop; - - case MULT_EXPR: - preexpand_calls (exp); - /* If first operand is constant, swap them. - Thus the following special case checks need only - check the second operand. */ - if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST) - { - register tree t1 = TREE_OPERAND (exp, 0); - TREE_OPERAND (exp, 0) = TREE_OPERAND (exp, 1); - TREE_OPERAND (exp, 1) = t1; - } - - /* Attempt to return something suitable for generating an - indexed address, for machines that support that. */ - - if (modifier == EXPAND_SUM - && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST) - { - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM); - - /* Apply distributive law if OP0 is x+c. */ - if (GET_CODE (op0) == PLUS - && GET_CODE (XEXP (op0, 1)) == CONST_INT) - return gen_rtx (PLUS, mode, - gen_rtx (MULT, mode, XEXP (op0, 0), - gen_rtx (CONST_INT, VOIDmode, - TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))), - gen_rtx (CONST_INT, VOIDmode, - (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)) - * INTVAL (XEXP (op0, 1))))); - - if (GET_CODE (op0) != REG) - op0 = force_operand (op0, 0); - if (GET_CODE (op0) != REG) - op0 = copy_to_mode_reg (mode, op0); - - return gen_rtx (MULT, mode, op0, - gen_rtx (CONST_INT, VOIDmode, - TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))); - } - subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1)); - /* Check for multiplying things that have been extended - from a narrower type. If this machine supports multiplying - in that narrower type with a result in the desired type, - do it that way, and avoid the explicit type-conversion. */ - if (TREE_CODE (TREE_OPERAND (exp, 0)) == NOP_EXPR - && TREE_CODE (TREE_TYPE (exp)) == INTEGER_TYPE - && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))) - < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0)))) - && ((TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST - && int_fits_type_p (TREE_OPERAND (exp, 1), - TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))) - /* Don't use a widening multiply if a shift will do. */ - && exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))) < 0) - || - (TREE_CODE (TREE_OPERAND (exp, 1)) == NOP_EXPR - && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0))) - == - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))) - /* If both operands are extended, they must either both - be zero-extended or both be sign-extended. */ - && (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0))) - == - TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))))))) - { - enum machine_mode innermode - = TYPE_MODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))); - this_optab = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))) - ? umul_widen_optab : smul_widen_optab); - if (mode == GET_MODE_WIDER_MODE (innermode) - && this_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing) - { - op0 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0), - 0, VOIDmode, 0); - if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST) - op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0); - else - op1 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), - 0, VOIDmode, 0); - goto binop2; - } - } - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0); - return expand_mult (mode, op0, op1, target, TREE_UNSIGNED (type)); - - case TRUNC_DIV_EXPR: - case FLOOR_DIV_EXPR: - case CEIL_DIV_EXPR: - case ROUND_DIV_EXPR: - case EXACT_DIV_EXPR: - preexpand_calls (exp); - subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1)); - /* Possible optimization: compute the dividend with EXPAND_SUM - then if the divisor is constant can optimize the case - where some terms of the dividend have coeffs divisible by it. */ - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0); - return expand_divmod (0, code, mode, op0, op1, target, - TREE_UNSIGNED (type)); - - case RDIV_EXPR: - preexpand_calls (exp); - this_optab = flodiv_optab; - goto binop; - - case TRUNC_MOD_EXPR: - case FLOOR_MOD_EXPR: - case CEIL_MOD_EXPR: - case ROUND_MOD_EXPR: - preexpand_calls (exp); - subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1)); - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0); - return expand_divmod (1, code, mode, op0, op1, target, - TREE_UNSIGNED (type)); -#if 0 -#ifdef HAVE_divmoddisi4 - if (GET_MODE (op0) != DImode) - { - temp = gen_reg_rtx (DImode); - convert_move (temp, op0, 0); - op0 = temp; - if (GET_MODE (op1) != SImode && GET_CODE (op1) != CONST_INT) - { - temp = gen_reg_rtx (SImode); - convert_move (temp, op1, 0); - op1 = temp; - } - temp = gen_reg_rtx (SImode); - if (target == 0) - target = gen_reg_rtx (SImode); - emit_insn (gen_divmoddisi4 (temp, protect_from_queue (op0, 0), - protect_from_queue (op1, 0), - protect_from_queue (target, 1))); - return target; - } -#endif -#endif - - case FIX_ROUND_EXPR: - case FIX_FLOOR_EXPR: - case FIX_CEIL_EXPR: - abort (); /* Not used for C. */ - - case FIX_TRUNC_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0); - if (target == 0) - target = gen_reg_rtx (mode); - { - int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp)); - if (mode == HImode || mode == QImode) - { - register rtx temp = gen_reg_rtx (SImode); - expand_fix (temp, op0, 0); - convert_move (target, temp, 0); - } - else - expand_fix (target, op0, unsignedp); - } - return target; - - case FLOAT_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0); - if (target == 0) - target = gen_reg_rtx (mode); - if (GET_MODE (op0) == VOIDmode) - /* Avoid problem in convert_move due to unknown mode of OP0. */ - op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))), - op0); - { - int unsignedp = TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))); - if (GET_MODE (op0) == HImode - || GET_MODE (op0) == QImode) - { - register rtx temp = gen_reg_rtx (SImode); - convert_move (temp, op0, unsignedp); - expand_float (target, temp, 0); - } - else - expand_float (target, op0, unsignedp); - } - return target; - - case NEGATE_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0); - temp = expand_unop (mode, neg_optab, op0, target, 0); - if (temp == 0) - abort (); - return temp; - - case ABS_EXPR: - /* First try to do it with a special abs instruction. - If that does not win, use conditional jump and negate. */ - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - temp = expand_unop (mode, abs_optab, op0, target, 0); - if (temp != 0) - return temp; - temp = gen_label_rtx (); - if (target == 0 || GET_CODE (target) != REG) - target = gen_reg_rtx (mode); - emit_move_insn (target, op0); - emit_cmp_insn (target, - expand_expr (convert (TREE_TYPE (exp), integer_zero_node), - 0, VOIDmode, 0), - 0, 0, 0); - NO_DEFER_POP; - emit_jump_insn (gen_bge (temp)); - op0 = expand_unop (mode, neg_optab, target, target, 0); - if (op0 != target) - emit_move_insn (target, op0); - emit_label (temp); - OK_DEFER_POP; - return target; - - case MAX_EXPR: - case MIN_EXPR: - mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1))); - op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0); - if (target == 0 || GET_CODE (target) != REG || target == op1) - target = gen_reg_rtx (mode); - op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0); - if (target != op0) - emit_move_insn (target, op0); - op0 = gen_label_rtx (); - if (code == MAX_EXPR) - temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1))) - ? compare1 (target, op1, GEU, LEU, 1, mode) - : compare1 (target, op1, GE, LE, 0, mode)); - else - temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1))) - ? compare1 (target, op1, LEU, GEU, 1, mode) - : compare1 (target, op1, LE, GE, 0, mode)); - if (temp == const0_rtx) - emit_move_insn (target, op1); - else if (temp != const1_rtx) - { - if (bcc_gen_fctn[(int) GET_CODE (temp)] != 0) - emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (temp)]) (op0)); - else - abort (); - emit_move_insn (target, op1); - } - emit_label (op0); - return target; - -/* ??? Can optimize when the operand of this is a bitwise operation, - by using a different bitwise operation. */ - case BIT_NOT_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - temp = expand_unop (mode, one_cmpl_optab, op0, target, 1); - if (temp == 0) - abort (); - return temp; - - case FFS_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - temp = expand_unop (mode, ffs_optab, op0, target, 1); - if (temp == 0) - abort (); - return temp; - -/* ??? Can optimize bitwise operations with one arg constant. - Pastel optimizes (a bitwise1 n) bitwise2 (a bitwise3 b) - and (a bitwise1 b) bitwise2 b (etc) - but that is probably not worth while. */ - -/* BIT_AND_EXPR is for bitwise anding. - TRUTH_AND_EXPR is for anding two boolean values - when we want in all cases to compute both of them. - In general it is fastest to do TRUTH_AND_EXPR by - computing both operands as actual zero-or-1 values - and then bitwise anding. In cases where there cannot - be any side effects, better code would be made by - treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR; - but the question is how to recognize those cases. */ - - case TRUTH_AND_EXPR: - case BIT_AND_EXPR: - preexpand_calls (exp); - subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1)); - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0); - return expand_bit_and (mode, op0, op1, target); - -/* See comment above about TRUTH_AND_EXPR; it applies here too. */ - case TRUTH_OR_EXPR: - case BIT_IOR_EXPR: - preexpand_calls (exp); - this_optab = ior_optab; - goto binop; - - case BIT_XOR_EXPR: - preexpand_calls (exp); - this_optab = xor_optab; - goto binop; - - case LSHIFT_EXPR: - case RSHIFT_EXPR: - case LROTATE_EXPR: - case RROTATE_EXPR: - preexpand_calls (exp); - subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1)); - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target, - TREE_UNSIGNED (type)); - -/* ??? cv's were used to effect here to combine additive constants - and to determine the answer when only additive constants differ. - Also, the addition of one can be handled by changing the condition. */ - case LT_EXPR: - case LE_EXPR: - case GT_EXPR: - case GE_EXPR: - case EQ_EXPR: - case NE_EXPR: - preexpand_calls (exp); - temp = do_store_flag (exp, target, mode); - if (temp != 0) - return temp; - /* For foo != 0, load foo, and if it is nonzero load 1 instead. */ - if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1)) - && subtarget - && (GET_MODE (subtarget) - == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))) - { - temp = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - if (temp != subtarget) - temp = copy_to_reg (temp); - op1 = gen_label_rtx (); - emit_cmp_insn (temp, const0_rtx, 0, TREE_UNSIGNED (type), 0); - emit_jump_insn (gen_beq (op1)); - emit_move_insn (temp, const1_rtx); - emit_label (op1); - return temp; - } - /* If no set-flag instruction, must generate a conditional - store into a temporary variable. Drop through - and handle this like && and ||. */ - - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - temp = gen_reg_rtx (mode); - emit_clr_insn (temp); - op1 = gen_label_rtx (); - jumpifnot (exp, op1); - emit_0_to_1_insn (temp); - emit_label (op1); - return temp; - - case TRUTH_NOT_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0); - /* The parser is careful to generate TRUTH_NOT_EXPR - only with operands that are always zero or one. */ - temp = expand_binop (mode, xor_optab, op0, - gen_rtx (CONST_INT, mode, 1), - target, 1, OPTAB_LIB_WIDEN); - if (temp == 0) - abort (); - return temp; - - case COMPOUND_EXPR: - expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0); - emit_queue (); - return expand_expr (TREE_OPERAND (exp, 1), target, VOIDmode, 0); - - case COND_EXPR: - { - /* Note that COND_EXPRs whose type is a structure or union - are required to be constructed to contain assignments of - a temporary variable, so that we can evaluate them here - for side effect only. If type is void, we must do likewise. */ - - /* If an arm of the branch requires a cleanup, that - only that cleanup is performed. */ - - tree old_cleanups = cleanups_this_call; - cleanups_this_call = 0; - - op0 = gen_label_rtx (); - op1 = gen_label_rtx (); - - if (mode == VOIDmode || ignore) - temp = 0; - else if (target) - temp = target; - else if (mode == BLKmode) - { - if (TYPE_SIZE (type) == 0 || ! TREE_LITERAL (TYPE_SIZE (type))) - abort (); - temp = assign_stack_local (BLKmode, - (TREE_INT_CST_LOW (TYPE_SIZE (type)) - * TYPE_SIZE_UNIT (type) - + BITS_PER_UNIT - 1) - / BITS_PER_UNIT); - } - else - temp = gen_reg_rtx (mode); - - jumpifnot (TREE_OPERAND (exp, 0), op0); - NO_DEFER_POP; - if (temp != 0) - store_expr (TREE_OPERAND (exp, 1), temp, 0); - else - expand_expr (TREE_OPERAND (exp, 1), ignore ? const0_rtx : 0, - VOIDmode, 0); - if (cleanups_this_call) - { - sorry ("aggreage value in COND_EXPR"); - cleanups_this_call = 0; - } - - emit_queue (); - emit_jump_insn (gen_jump (op1)); - emit_barrier (); - emit_label (op0); - if (temp != 0) - store_expr (TREE_OPERAND (exp, 2), temp, 0); - else - expand_expr (TREE_OPERAND (exp, 2), ignore ? const0_rtx : 0, - VOIDmode, 0); - if (cleanups_this_call) - { - sorry ("aggreage value in COND_EXPR"); - cleanups_this_call = 0; - } - - emit_queue (); - emit_label (op1); - OK_DEFER_POP; - cleanups_this_call = old_cleanups; - return temp; - } - - case NEW_EXPR: - { - /* Something needs to be initialized, but we didn't know - where that thing was when building the tree. For example, - it could be the return value of a function, or a parameter - to a function which lays down in the stack, or a temporary - variable which must be passed by reference. */ - - tree slot = TREE_OPERAND (exp, 0); - - if (TREE_CODE (slot) != VAR_DECL) - abort (); - - if (target == 0) - { - target = assign_stack_local (TYPE_MODE (type), - int_size_in_bytes (type)); - - DECL_RTL (slot) = target; - - /* Since SLOT is not known to the called function - to belong to its stack frame, we must build an explicit - cleanup. This case occurs when we must build up a reference - to pass the reference as an argument. In this case, - it is very likely that such a reference need not be - built here. */ - - if (TREE_OPERAND (exp, 2) == 0) - TREE_OPERAND (exp, 2) = (tree)maybe_build_cleanup (slot); - if (TREE_OPERAND (exp, 2)) - cleanups_this_call = tree_cons (0, TREE_OPERAND (exp, 2), - cleanups_this_call); - } - else - { - /* This case does occur, when expanding a parameter which - needs to be constructed on the stack. The target - is the actual stack address that we want to initialize. - - The function we call will perform the cleanup in this case. */ - DECL_RTL (slot) = target; - } - - /* Run the initialization expression now with the target. */ - return expand_expr (TREE_OPERAND (exp, 1), target, tmode, modifier); - } - - case INIT_EXPR: - { - tree lhs = TREE_OPERAND (exp, 0); - tree rhs = TREE_OPERAND (exp, 1); - tree noncopied_parts = 0; - tree type = TREE_TYPE (lhs); - - temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0); - if (TYPE_NONCOPIED_PARTS (type) != 0 && !fixed_type_p (rhs)) - noncopied_parts = init_noncopied_parts (stabilize_reference (lhs), - TYPE_NONCOPIED_PARTS (type)); - while (noncopied_parts != 0) - { - expand_assignment (TREE_VALUE (noncopied_parts), - TREE_PURPOSE (noncopied_parts), 0, 0); - noncopied_parts = TREE_CHAIN (noncopied_parts); - } - return temp; - } - - case MODIFY_EXPR: - { - /* If lhs is complex, expand calls in rhs before computing it. - That's so we don't compute a pointer and save it over a call. - If lhs is simple, compute it first so we can give it as a - target if the rhs is just a call. This avoids an extra temp and copy - and that prevents a partial-subsumption which makes bad code. - Actually we could treat component_ref's of vars like vars. */ - tree lhs = TREE_OPERAND (exp, 0); - tree rhs = TREE_OPERAND (exp, 1); - tree noncopied_parts = 0; - tree type = TREE_TYPE (lhs); - temp = 0; - - if (TREE_CODE (lhs) != VAR_DECL - && TREE_CODE (lhs) != RESULT_DECL - && TREE_CODE (lhs) != PARM_DECL) - preexpand_calls (exp); - - /* Check for |= or &= of a bitfield of size one into another bitfield - of size 1. In this case, (unless we need the result of the - assignment) we can do this more efficiently with a - test followed by an assignment, if necessary. */ - if (ignore - && TREE_CODE (lhs) == COMPONENT_REF - && (TREE_CODE (rhs) == BIT_IOR_EXPR - || TREE_CODE (rhs) == BIT_AND_EXPR) - && TREE_OPERAND (rhs, 0) == lhs - && TREE_CODE (TREE_OPERAND (rhs, 1)) == COMPONENT_REF - && (TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (lhs, 1))) - * DECL_SIZE_UNIT (TREE_OPERAND (lhs, 1))) == 1 - && (TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1))) - * DECL_SIZE_UNIT (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1))) == 1) - { - rtx label = gen_label_rtx (); - - do_jump (TREE_OPERAND (rhs, 1), - TREE_CODE (rhs) == BIT_IOR_EXPR ? label : 0, - TREE_CODE (rhs) == BIT_AND_EXPR ? label : 0); - expand_assignment (lhs, convert (TREE_TYPE (rhs), - (TREE_CODE (rhs) == BIT_IOR_EXPR - ? integer_one_node - : integer_zero_node)), - 0, 0); - emit_label (label); - return const0_rtx; - } - - if (TYPE_NONCOPIED_PARTS (type) != 0 - && ! (fixed_type_p (lhs) && fixed_type_p (rhs))) - noncopied_parts = save_noncopied_parts (stabilize_reference (lhs), - TYPE_NONCOPIED_PARTS (type)); - - temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0); - while (noncopied_parts != 0) - { - expand_assignment (TREE_PURPOSE (noncopied_parts), - TREE_VALUE (noncopied_parts), 0, 0); - noncopied_parts = TREE_CHAIN (noncopied_parts); - } - return temp; - } - - case PREINCREMENT_EXPR: - case PREDECREMENT_EXPR: - return expand_increment (exp, 0); - - case POSTINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - return expand_increment (exp, !ignore); - - case ADDR_EXPR: - op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, - modifier != EXPAND_INTO_STACK ? EXPAND_CONST_ADDRESS : EXPAND_INTO_STACK); - if (GET_CODE (op0) != MEM) - abort (); - if (modifier == EXPAND_SUM) - return XEXP (op0, 0); - op0 = force_operand (XEXP (op0, 0), target); - if (flag_force_addr && GET_CODE (op0) != REG) - return force_reg (Pmode, op0); - return op0; - - case ENTRY_VALUE_EXPR: - abort (); - - case ERROR_MARK: - return const0_rtx; - - default: - return (*lang_expand_expr) (exp, target, tmode, modifier); - } - - /* Here to do an ordinary binary operator, generating an instruction - from the optab already placed in `this_optab'. */ - binop: - /* Detect things like x = y | (a == b) - and do them as (x = y), (a == b ? x |= 1 : 0), x. */ - /* First, get the comparison or conditional into the second arg. */ - if (comparison_code[(int) TREE_CODE (TREE_OPERAND (exp, 0))] - || (TREE_CODE (TREE_OPERAND (exp, 0)) == COND_EXPR - && (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1)) - || integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 2))))) - { - if (this_optab == ior_optab || this_optab == add_optab - || this_optab == xor_optab) - { - tree exch = TREE_OPERAND (exp, 1); - TREE_OPERAND (exp, 1) = TREE_OPERAND (exp, 0); - TREE_OPERAND (exp, 0) = exch; - } - } - /* Optimize X + (Y ? Z : 0) by computing X and maybe adding Z. */ - if (comparison_code[(int) TREE_CODE (TREE_OPERAND (exp, 1))] - || (TREE_CODE (TREE_OPERAND (exp, 1)) == COND_EXPR - && (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 1)) - || integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 2))))) - { - if (this_optab == ior_optab || this_optab == add_optab - || this_optab == xor_optab || this_optab == sub_optab - || this_optab == lshl_optab || this_optab == ashl_optab - || this_optab == lshr_optab || this_optab == ashr_optab - || this_optab == rotl_optab || this_optab == rotr_optab) - { - tree thenexp; - rtx thenv = 0; - - /* TARGET gets a reg in which we can perform the computation. - Use the specified target if it's a pseudo reg and safe. */ - target = validate_subtarget (subtarget, TREE_OPERAND (exp, 1)); - if (target == 0) target = gen_reg_rtx (mode); - - /* Compute X into the target. */ - store_expr (TREE_OPERAND (exp, 0), target, 0); - op0 = gen_label_rtx (); - - /* If other operand is a comparison COMP, treat it as COMP ? 1 : 0 */ - if (TREE_CODE (TREE_OPERAND (exp, 1)) != COND_EXPR) - { - do_jump (TREE_OPERAND (exp, 1), op0, 0); - thenv = const1_rtx; - } - else if (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 2))) - { - do_jump (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), op0, 0); - thenexp = TREE_OPERAND (TREE_OPERAND (exp, 1), 1); - } - else - { - do_jump (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0, op0); - thenexp = TREE_OPERAND (TREE_OPERAND (exp, 1), 2); - } - - if (thenv == 0) - thenv = expand_expr (thenexp, 0, VOIDmode, 0); - - /* THENV is now Z, the value to operate on, as an rtx. - We have already tested that Y isn't zero, so do the operation. */ - - if (this_optab == rotl_optab || this_optab == rotr_optab) - temp = expand_binop (mode, this_optab, target, thenv, target, - -1, OPTAB_LIB); - else if (this_optab == lshl_optab || this_optab == lshr_optab) - temp = expand_binop (mode, this_optab, target, thenv, target, - 1, OPTAB_LIB_WIDEN); - else - temp = expand_binop (mode, this_optab, target, thenv, target, - 0, OPTAB_LIB_WIDEN); - if (target != temp) - emit_move_insn (target, temp); - - emit_queue (); - do_pending_stack_adjust (); - emit_label (op0); - return target; - } - } - subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1)); - op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0); - op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0); - binop2: - temp = expand_binop (mode, this_optab, op0, op1, target, - TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN); - if (temp == 0) - abort (); - return temp; -} - -/* Expand an expression EXP that calls a built-in function, - with result going to TARGET if that's convenient - (and in mode MODE if that's convenient). - SUBTARGET may be used as the target for computing one of EXP's operands. - IGNORE is nonzero if the value is to be ignored. */ - -static rtx -expand_builtin (exp, target, subtarget, mode, ignore) - tree exp; - rtx target; - rtx subtarget; - enum machine_mode mode; - int ignore; -{ - tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); - tree arglist = TREE_OPERAND (exp, 1); - rtx op0; - - switch (DECL_FUNCTION_CODE (fndecl)) - { - case BUILT_IN_ABS: - case BUILT_IN_LABS: - case BUILT_IN_FABS: - /* build_function_call changes these into ABS_EXPR. */ - abort (); - - case BUILT_IN_SAVEREGS: - { - /* When this function is called, it means that registers must be - saved on entry to this function. So we migrate the - call to the first insn of this function. */ - rtx last = get_last_insn (); - rtx temp, saving_insns, last_saving_insn; - - /* If there are parameters which must be saved from this function, - save them now. */ - saving_insns = save_from_saveregs; - emit_insns (saving_insns); - if (saving_insns) - { - emit_note (0, -1); - last_saving_insn = get_last_insn (); - } - - /* Now really call the function. `expand_call' does not call - expand_builtin, so there is no danger of infinite recursion here. */ - temp = expand_call (exp, target, ignore); - - if (saving_insns) - { - extern void use_variable (); - do - { - if (GET_CODE (saving_insns) == INSN) - note_stores (PATTERN (saving_insns), use_variable); - saving_insns = NEXT_INSN (saving_insns); - } while (saving_insns != last_saving_insn); - } - reorder_insns (NEXT_INSN (last), get_last_insn (), get_insns ()); - return temp; - } - - case BUILT_IN_CLASSIFY_TYPE: - if (arglist != 0) - { - tree type = TREE_TYPE (TREE_VALUE (arglist)); - enum tree_code code = TREE_CODE (type); - if (code == VOID_TYPE) - return gen_rtx (CONST_INT, VOIDmode, void_type_class); - if (code == INTEGER_TYPE) - return gen_rtx (CONST_INT, VOIDmode, integer_type_class); - if (code == CHAR_TYPE) - return gen_rtx (CONST_INT, VOIDmode, char_type_class); - if (code == ENUMERAL_TYPE) - return gen_rtx (CONST_INT, VOIDmode, enumeral_type_class); - if (code == BOOLEAN_TYPE) - return gen_rtx (CONST_INT, VOIDmode, boolean_type_class); - if (code == POINTER_TYPE) - return gen_rtx (CONST_INT, VOIDmode, pointer_type_class); - if (code == REFERENCE_TYPE) - return gen_rtx (CONST_INT, VOIDmode, reference_type_class); - if (code == OFFSET_TYPE) - return gen_rtx (CONST_INT, VOIDmode, offset_type_class); - if (code == REAL_TYPE) - return gen_rtx (CONST_INT, VOIDmode, real_type_class); - if (code == COMPLEX_TYPE) - return gen_rtx (CONST_INT, VOIDmode, complex_type_class); - if (code == FUNCTION_TYPE) - return gen_rtx (CONST_INT, VOIDmode, function_type_class); - if (code == METHOD_TYPE) - return gen_rtx (CONST_INT, VOIDmode, method_type_class); - if (code == RECORD_TYPE) - return gen_rtx (CONST_INT, VOIDmode, record_type_class); - if (code == UNION_TYPE) - return gen_rtx (CONST_INT, VOIDmode, union_type_class); - if (code == ARRAY_TYPE) - return gen_rtx (CONST_INT, VOIDmode, array_type_class); - if (code == STRING_TYPE) - return gen_rtx (CONST_INT, VOIDmode, string_type_class); - if (code == SET_TYPE) - return gen_rtx (CONST_INT, VOIDmode, set_type_class); - if (code == FILE_TYPE) - return gen_rtx (CONST_INT, VOIDmode, file_type_class); - if (code == LANG_TYPE) - return gen_rtx (CONST_INT, VOIDmode, lang_type_class); - } - return gen_rtx (CONST_INT, VOIDmode, no_type_class); - - case BUILT_IN_ALLOCA: - if (arglist == 0 - /* Arg could be non-integer if user redeclared this fcn wrong. */ - || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE) - return const0_rtx; - frame_pointer_needed = 1; - current_function_calls_alloca = 1; - /* Compute the argument. */ - op0 = expand_expr (TREE_VALUE (arglist), 0, VOIDmode, 0); - if (! CONSTANT_P (op0)) - { - op0 = force_reg (GET_MODE (op0), op0); - if (GET_MODE (op0) != Pmode) - op0 = convert_to_mode (Pmode, op0, 1); - } - /* Push that much space (rounding it up). */ - do_pending_stack_adjust (); - -#ifdef STACK_POINTER_OFFSET - /* If we will have to round the result down (which is up - if stack grows down), make sure we have extra space so the - user still gets at least as much space as he asked for. */ - if ((STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES - != STACK_POINTER_OFFSET / STACK_BYTES) - op0 = plus_constant (op0, STACK_BYTES); -#endif - -#ifdef STACK_GROWS_DOWNWARD - anti_adjust_stack (round_push (op0)); -#endif - /* Return a copy of current stack ptr, in TARGET if possible. */ - if (target) - emit_move_insn (target, stack_pointer_rtx); - else - target = copy_to_reg (stack_pointer_rtx); -#ifdef STACK_POINTER_OFFSET - /* If the contents of the stack pointer reg are offset from the - actual top-of-stack address, add the offset here. */ - if (GET_CODE (target) == REG) - emit_insn (gen_add2_insn (target, - gen_rtx (CONST_INT, VOIDmode, - (STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES))); - else - { - rtx temp = - expand_binop (GET_MODE (target), add_optab, target, - gen_rtx (CONST_INT, VOIDmode, - (STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES), - target, - 1, OPTAB_DIRECT); - if (temp == 0) abort (); - if (temp != target) - emit_move_insn (target, temp); - } -#endif -#ifndef STACK_GROWS_DOWNWARD - anti_adjust_stack (round_push (op0)); -#endif - /* Some systems require a particular insn to refer to the stack - to make the pages exist. */ -#ifdef HAVE_probe - if (HAVE_probe) - emit_insn (gen_probe ()); -#endif - return target; - - case BUILT_IN_FFS: - if (arglist == 0 - /* Arg could be non-integer if user redeclared this fcn wrong. */ - || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE) - return const0_rtx; - - /* Compute the argument. */ - op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0); - /* Compute ffs, into TARGET if possible. - Set TARGET to wherever the result comes back. */ - target = expand_unop (mode, ffs_optab, op0, target, 1); - if (target == 0) - abort (); - return target; - - default: - abort (); - } -} - -/* Expand code for a post- or pre- increment or decrement - and return the RTX for the result. - POST is 1 for postinc/decrements and 0 for preinc/decrements. */ - -static rtx -expand_increment (exp, post) - register tree exp; - int post; -{ - register rtx op0, op1; - register rtx temp; - register tree incremented = TREE_OPERAND (exp, 0); - optab this_optab = add_optab; - int icode; - enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp)); - int op0_is_copy = 0; - - /* Stabilize any component ref that might need to be - evaluated more than once below. */ - if (TREE_CODE (incremented) == COMPONENT_REF - && (TREE_CODE (TREE_OPERAND (incremented, 0)) != INDIRECT_REF - || DECL_MODE (TREE_OPERAND (incremented, 1)) == BImode)) - incremented = stabilize_reference (incremented); - - /* Compute the operands as RTX. - Note whether OP0 is the actual lvalue or a copy of it: - I believe it is a copy iff it is a register and insns were - generated in computing it. */ - temp = get_last_insn (); - op0 = expand_expr (incremented, 0, VOIDmode, 0); - if (temp != get_last_insn ()) - op0_is_copy = (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG); - op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0); - - /* Decide whether incrementing or decrementing. */ - if (TREE_CODE (exp) == POSTDECREMENT_EXPR - || TREE_CODE (exp) == PREDECREMENT_EXPR) - this_optab = sub_optab; - - /* If OP0 is not the actual lvalue, but rather a copy in a register, - then we cannot just increment OP0. We must - therefore contrive to increment the original value. - Then we can return OP0 since it is a copy of the old value. */ - if (op0_is_copy) - { - /* This is the easiest way to increment the value wherever it is. - Problems with multiple evaluation of INCREMENTED - are prevented because either (1) it is a component_ref, - in which case it was stabilized above, or (2) it is an array_ref - with constant index in an array in a register, which is - safe to reevaluate. */ - tree newexp = build ((this_optab == add_optab - ? PLUS_EXPR : MINUS_EXPR), - TREE_TYPE (exp), - incremented, - TREE_OPERAND (exp, 1)); - temp = expand_assignment (incremented, newexp, ! post, 0); - return post ? op0 : temp; - } - - /* Convert decrement by a constant into a negative increment. */ - if (this_optab == sub_optab - && GET_CODE (op1) == CONST_INT) - { - op1 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op1)); - this_optab = add_optab; - } - - if (post) - { - /* We have a true reference to the value in OP0. - If there is an insn to add or subtract in this mode, queue it. */ - - /* I'm not sure this is still necessary. */ - op0 = stabilize (op0); - - icode = (int) this_optab->handlers[(int) mode].insn_code; - if (icode != (int) CODE_FOR_nothing - /* Make sure that OP0 is valid for operands 0 and 1 - of the insn we want to queue. */ - && (*insn_operand_predicate[icode][0]) (op0, mode) - && (*insn_operand_predicate[icode][1]) (op0, mode)) - { - if (! (*insn_operand_predicate[icode][2]) (op1, mode)) - op1 = force_reg (mode, op1); - - return enqueue_insn (op0, GEN_FCN (icode) (op0, op0, op1)); - } - } - - /* Preincrement, or we can't increment with one simple insn. */ - if (post) - /* Save a copy of the value before inc or dec, to return it later. */ - temp = copy_to_reg (op0); - else - /* Arrange to return the incremented value. */ - /* Copy the rtx because expand_binop will protect from the queue, - and the results of that would be invalid for us to return - if our caller does emit_queue before using our result. */ - temp = copy_rtx (op0); - - /* Increment however we can. */ - op1 = expand_binop (mode, this_optab, op0, op1, op0, - TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN); - /* Make sure the value is stored into OP0. */ - if (op1 != op0) - emit_move_insn (op0, op1); - - return temp; -} - -/* Expand all function calls contained within EXP, innermost ones first. - But don't look within expressions that have sequence points. - For each CALL_EXPR, record the rtx for its value - in the CALL_EXPR_RTL field. - - Calls that return large structures for which a structure return - stack slot is needed are not preexpanded. Preexpanding them loses - because if more than one were preexpanded they would try to use the - same stack slot. */ - -static void -preexpand_calls (exp) - tree exp; -{ - register int nops, i; - - if (! do_preexpand_calls) - return; - - /* Only expressions and references can contain calls. */ - - if (tree_code_type[(int) TREE_CODE (exp)][0] != 'e' - && tree_code_type[(int) TREE_CODE (exp)][0] != 'r') - return; - - switch (TREE_CODE (exp)) - { - case CALL_EXPR: - /* Do nothing to built-in functions. */ - if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL - && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) - != NOT_BUILT_IN)) - return; - /* Precompute calls that don't return values in memory. */ - if (CALL_EXPR_RTL (exp) == 0 - && TYPE_MODE (TREE_TYPE (exp)) != BLKmode - && ! RETURN_IN_MEMORY (TREE_TYPE (exp))) - CALL_EXPR_RTL (exp) = expand_call (exp, 0, 0, 0); - return; - - case COMPOUND_EXPR: - case COND_EXPR: - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - /* If we find one of these, then we can be sure - the adjust will be done for it (since it makes jumps). - Do it now, so that if this is inside an argument - of a function, we don't get the stack adjustment - after some other args have already been pushed. */ - do_pending_stack_adjust (); - return; - - case RTL_EXPR: - return; - - case SAVE_EXPR: - if (SAVE_EXPR_RTL (exp) != 0) - return; - } - - nops = tree_code_length[(int) TREE_CODE (exp)]; - for (i = 0; i < nops; i++) - if (TREE_OPERAND (exp, i) != 0) - { - register int type = *tree_code_type[(int) TREE_CODE (TREE_OPERAND (exp, i))]; - if (type == 'e' || type == 'r') - preexpand_calls (TREE_OPERAND (exp, i)); - } -} - -/* Force FUNEXP into a form suitable for the address of a CALL, - and return that as an rtx. Also load the static chain register - from either FUNEXP or CONTEXT. */ - -static rtx -prepare_call_address (funexp, context) - rtx funexp; - rtx context; -{ - funexp = protect_from_queue (funexp, 0); - if (context != 0) - context = protect_from_queue (context, 0); - - /* Function variable in language with nested functions. */ - if (GET_MODE (funexp) == EPmode) - { - emit_move_insn (static_chain_rtx, gen_highpart (Pmode, funexp)); - funexp = memory_address (FUNCTION_MODE, gen_lowpart (Pmode, funexp)); - emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx)); - } - else - { - if (context != 0) - /* Unless function variable in C, or top level function constant */ - emit_move_insn (static_chain_rtx, lookup_static_chain (context)); - - /* Make a valid memory address and copy constants thru pseudo-regs, - but not for a constant address if -fno-function-cse. */ - if (GET_CODE (funexp) != SYMBOL_REF) - funexp = memory_address (FUNCTION_MODE, funexp); - else - { -#ifndef NO_FUNCTION_CSE - if (optimize && ! flag_no_function_cse) - funexp = force_reg (Pmode, funexp); -#endif - } - - if (context != 0) - emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx)); - } - return funexp; -} - -/* Generate instructions to call function FUNEXP, - and optionally pop the results. - The CALL_INSN is the first insn generated. - - FUNTYPE is the data type of the function, or, for a library call, - the identifier for the name of the call. This is given to the - macro RETURN_POPS_ARGS to determine whether this function pops its own args. - - STACK_SIZE is the number of bytes of arguments on the stack, - rounded up to STACK_BOUNDARY; zero if the size is variable. - This is both to put into the call insn and - to generate explicit popping code if necessary. - - NEXT_ARG_REG is the rtx that results from executing - FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1) - just after all the args have had their registers assigned. - This could be whatever you like, but normally it is the first - arg-register beyond those used for args in this call, - or 0 if all the arg-registers are used in this call. - It is passed on to `gen_call' so you can put this info in the call insn. - - VALREG is a hard register in which a value is returned, - or 0 if the call does not return a value. - - OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before - the args to this call were processed. - We restore `inhibit_defer_pop' to that value. - - USE_INSNS is a SEQUENCE of USE insns to be emitted immediately before - the actual CALL insn. */ - -static void -emit_call_1 (funexp, funtype, stack_size, next_arg_reg, valreg, old_inhibit_defer_pop, use_insns) - rtx funexp; - tree funtype; - int stack_size; - rtx next_arg_reg; - rtx valreg; - int old_inhibit_defer_pop; - rtx use_insns; -{ - rtx stack_size_rtx = gen_rtx (CONST_INT, VOIDmode, stack_size); - rtx call_insn; - - if (valreg) - emit_call_insn (gen_call_value (valreg, - gen_rtx (MEM, FUNCTION_MODE, funexp), - stack_size_rtx, next_arg_reg)); - else - emit_call_insn (gen_call (gen_rtx (MEM, FUNCTION_MODE, funexp), - stack_size_rtx, next_arg_reg)); - - /* Find the CALL insn we just emitted and write the USE insns before it. */ - for (call_insn = get_last_insn(); - call_insn && GET_CODE (call_insn) != CALL_INSN; - call_insn = PREV_INSN (call_insn)) - ; - - if (! call_insn) - abort (); - - /* Put the USE insns before the CALL. */ - emit_insn_before (use_insns, call_insn); - - inhibit_defer_pop = old_inhibit_defer_pop; - - /* If returning from the subroutine does not automatically pop the args, - we need an instruction to pop them sooner or later. - Perhaps do it now; perhaps just record how much space to pop later. */ - - if (! RETURN_POPS_ARGS (TREE_TYPE (funtype)) - && stack_size != 0) - { - if (flag_defer_pop && inhibit_defer_pop == 0) - pending_stack_adjust += stack_size; - else - adjust_stack (stack_size_rtx); - } -} - -/* At the start of a function, record that we have no previously-pushed - arguments waiting to be popped. */ - -void -init_pending_stack_adjust () -{ - pending_stack_adjust = 0; -} - -/* When exiting from function, if safe, clear out any pending stack adjust - so the adjustment won't get done. */ - -void -clear_pending_stack_adjust () -{ -#ifdef EXIT_IGNORE_STACK - if (!flag_omit_frame_pointer && EXIT_IGNORE_STACK - && ! TREE_INLINE (current_function_decl) - && ! flag_inline_functions) - pending_stack_adjust = 0; -#endif -} - -/* Pop any previously-pushed arguments that have not been popped yet. */ - -void -do_pending_stack_adjust () -{ - if (inhibit_defer_pop == 0) - { - if (pending_stack_adjust != 0) - adjust_stack (gen_rtx (CONST_INT, VOIDmode, pending_stack_adjust)); - pending_stack_adjust = 0; - } -} - -/* Expand all cleanups up to OLD_CLEANUPS. - Needed here, and also for language-dependent calls. */ -void -expand_cleanups_to (old_cleanups) - tree old_cleanups; -{ - while (cleanups_this_call != old_cleanups) - { - expand_expr (TREE_VALUE (cleanups_this_call), 0, VOIDmode, 0); - cleanups_this_call = TREE_CHAIN (cleanups_this_call); - } -} - -/* Data structure and subroutines used within expand_call. */ - -struct arg_data -{ - /* Tree node for this argument. */ - tree tree_value; - /* Precomputed RTL value, or 0 if it isn't precomputed. */ - rtx value; - /* Register to pass this argument in, or 0 if passed on stack. */ - rtx reg; - /* Number of registers to use. 0 means put the whole arg in registers. - Also 0 if not passed in registers. */ - int partial; - /* Offset of this argument from beginning of stack-args. */ - struct args_size offset; - /* Size of this argument on the stack, rounded up for any padding it gets, - parts of the argument passed in registers do not count. - If the FIRST_PARM_CALLER_OFFSET is negative, then register parms - are counted here as well. */ - struct args_size size; - /* Nonzero if this arg has already been stored. */ - int stored; - /* const0_rtx means should preallocate stack space for this arg. - Other non0 value is the stack slot, preallocated. - Used only for BLKmode. */ - rtx stack; -}; - -static void store_one_arg (); -static rtx target_for_arg (); - -/* Generate all the code for a function call - and return an rtx for its value. - Store the value in TARGET (specified as an rtx) if convenient. - If the value is stored in TARGET then TARGET is returned. - If IGNORE is nonzero, then we ignore the value of the function call. */ - -static rtx -expand_call (exp, target, ignore, modifier) - tree exp; - rtx target; - int ignore; - enum expand_modifier modifier; -{ - /* List of actual parameters. */ - tree actparms = TREE_OPERAND (exp, 1); - /* RTX for the function to be called. */ - rtx funexp; - /* Data type of the function. */ - tree funtype; - /* Declaration of the function being called, - or 0 if the function is computed (not known by name). */ - tree fndecl = 0; - - /* Register in which non-BLKmode value will be returned, - or 0 if no value or if value is BLKmode. */ - rtx valreg; - /* Address where we should return a BLKmode value; - 0 if value not BLKmode. */ - rtx structure_value_addr = 0; - /* Nonzero if that address is being passed by treating it as - an extra, implicit first parameter. Otherwise, - it is passed by being copied directly into struct_value_rtx. */ - int structure_value_addr_parm = 0; - /* Nonzero if called function returns an aggregate in memory PCC style, - by returning the address of where to find it. */ - int pcc_struct_value = 0; - - /* Number of actual parameters in this call, including struct value addr. */ - int num_actuals; - /* Number of named args. Args after this are anonymous ones - and they must all go on the stack. */ - int n_named_args; - - /* Vector of information about each argument. - Arguments are numbered in the order they will be pushed, - not the order they are written. */ - struct arg_data *args; - - /* Total size in bytes of all the stack-parms scanned so far. */ - struct args_size args_size; - /* Remember initial value of args_size.constant. */ - int starting_args_size; - /* Nonzero means count reg-parms' size in ARGS_SIZE. */ - int stack_count_regparms = 0; - /* Data on reg parms scanned so far. */ - CUMULATIVE_ARGS args_so_far; - /* Nonzero if a reg parm has been scanned. */ - int reg_parm_seen; - /* Nonzero if we must avoid push-insns in the args for this call. */ - int must_preallocate; - /* 1 if scanning parms front to back, -1 if scanning back to front. */ - int inc; - /* Address of space preallocated for stack parms - (on machines that lack push insns), or 0 if space not preallocated. */ - rtx argblock = 0; - - /* Nonzero if it is plausible that this is a call to alloca. */ - int may_be_alloca; - /* Nonzero if this is a call to setjmp or a related function. */ - int is_setjmp; - /* Nonzero if this is a call to longjmp or a related function. */ - int is_longjmp; - /* Nonzero if this is a call to an inline function. */ - int is_integrable = 0; - /* Nonzero if this is a call to __builtin_new. */ - int is_builtin_new; - /* Nonzero if this is a call to a `const' function. */ - int is_const = 0; - - /* Nonzero if there are BLKmode args whose data types require them - to be passed in memory, not (even partially) in registers. */ - int BLKmode_parms_forced = 0; - /* The offset of the first BLKmode parameter which - *must* be passed in memory. */ - int BLKmode_parms_first_offset = 0; - /* Total size of BLKmode parms which could usefully be preallocated. */ - int BLKmode_parms_sizes = 0; - - /* Amount stack was adjusted to protect BLKmode parameters - which are below the nominal "stack address" value. */ - rtx protected_stack = 0; - - /* The last insn before the things that are intrinsically part of the call. - The beginning reg-note goes on the insn after this one. */ - rtx insn_before; - - rtx old_stack_level = 0; - int old_pending_adj; - int old_inhibit_defer_pop = inhibit_defer_pop; - tree old_cleanups = cleanups_this_call; - rtx use_insns; - - register tree p; - register int i; - - /* See if we can find a DECL-node for the actual function. - As a result, decide whether this is a call to an integrable function. */ - - p = TREE_OPERAND (exp, 0); - if (TREE_CODE (p) == ADDR_EXPR) - { - fndecl = TREE_OPERAND (p, 0); - if (TREE_CODE (fndecl) != FUNCTION_DECL) - { - /* May still be a `const' function if it is - a call through a const function. */ - fndecl = 0; - } - else - { - extern tree current_function_decl; - extern int flag_no_inline; - - if (!flag_no_inline - && fndecl != current_function_decl - && DECL_SAVED_INSNS (fndecl)) - is_integrable = 1; - else if (! TREE_ADDRESSABLE (fndecl)) - { - /* In case this function later becomes inlineable, - record that there was already a non-inline call to it. - - Use abstraction instead of setting TREE_ADDRESSABLE - directly. */ - if (TREE_INLINE (fndecl) && extra_warnings) - warning_with_decl (fndecl, "can't inline call to `%s' which was declared inline"); - mark_addressable (fndecl); - } - - if (TREE_READONLY (fndecl) && ! TREE_THIS_VOLATILE (fndecl)) - is_const = 1; - } - } - - /* When calling a const function, we must pop the stack args right away, - so that the pop is deleted or moved with the call. */ - if (is_const) - NO_DEFER_POP; - - /* Set up a place to return a structure. */ - - /* Cater to broken compilers. */ - if (aggregate_value_p (exp)) - { - /* This call returns a big structure. */ -#ifdef PCC_STATIC_STRUCT_RETURN - if (flag_pcc_struct_return) - { - pcc_struct_value = 1; - is_integrable = 0; /* Easier than making that case work right. */ - } - else -#endif - { - if (target && GET_CODE (target) == MEM) - { - structure_value_addr = XEXP (target, 0); - if (reg_mentioned_p (stack_pointer_rtx, structure_value_addr)) - structure_value_addr = copy_to_reg (structure_value_addr); - } - else - { - /* Make room on the stack to hold the value. */ - structure_value_addr - = get_structure_value_addr (expr_size (exp)); - target = 0; - } - } - } - - /* If called function is inline, try to integrate it. */ - - if (is_integrable) - { - extern rtx expand_inline_function (); - rtx temp; - - temp = expand_inline_function (fndecl, actparms, target, - ignore, TREE_TYPE (exp), - structure_value_addr); - - /* If inlining succeeded, return. */ - if ((int) temp != -1) - { - /* Perform all cleanups needed for the arguments of this call - (i.e. destructors in C++). It is ok if these destructors - clobber RETURN_VALUE_REG, because the only time we care about - this is when TARGET is that register. But in C++, we take - care to never return that register directly. */ - expand_cleanups_to (old_cleanups); - return temp; - } - - /* If inlining failed, mark FNDECL as needing to be compiled - separately after all. - - Use abstraction instead of setting TREE_ADDRESSABLE directly. */ - mark_addressable (fndecl); - } - -#if 0 - /* Unless it's a call to a specific function that isn't alloca, - if it has one argument, we must assume it might be alloca. */ - - may_be_alloca = - (!(fndecl != 0 - && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), - "alloca")) - && actparms != 0 - && TREE_CHAIN (actparms) == 0); -#else - /* We assume that alloca will always be called by name. It - makes no sense to pass it as a pointer-to-function to - anything that does not understand its behavior. */ - may_be_alloca = - (fndecl && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "alloca") - || ! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), - "__builtin_alloca"))); -#endif - - /* See if this is a call to a function that can return more than once. */ - - is_setjmp - = (fndecl != 0 - && (!strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "setjmp") - || !strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "_setjmp"))); - - is_longjmp - = (fndecl != 0 - && (!strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "longjmp") - || !strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "_longjmp"))); - - is_builtin_new - = (fndecl != 0 - && (!strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "__builtin_new"))); - - if (may_be_alloca) - { - frame_pointer_needed = 1; - may_call_alloca = 1; - current_function_calls_alloca = 1; - } - - /* Don't let pending stack adjusts add up to too much. - Also, do all pending adjustments now - if there is any chance this might be a call to alloca (or longjmp). */ - - if (pending_stack_adjust >= 32 - || (pending_stack_adjust > 0 && (may_be_alloca || is_setjmp || is_longjmp))) - do_pending_stack_adjust (); - - /* Operand 0 is a pointer-to-function; get the type of the function. */ - funtype = TREE_TYPE (TREE_OPERAND (exp, 0)); - if (TREE_CODE (funtype) != POINTER_TYPE) - abort (); - funtype = TREE_TYPE (funtype); - - /* If struct_value_rtx is 0, it means pass the address - as if it were an extra parameter. */ - if (structure_value_addr && struct_value_rtx == 0) - { - rtx tem; - - INIT_CUMULATIVE_ARGS (args_so_far, funtype); - tem = FUNCTION_ARG (args_so_far, Pmode, - build_pointer_type (TREE_TYPE (funtype)), 1); - if (tem == 0) - { - actparms = tree_cons (error_mark_node, - build (SAVE_EXPR, - type_for_size (GET_MODE_BITSIZE (Pmode), 0), - 0, - force_reg (Pmode, structure_value_addr)), - actparms); - structure_value_addr_parm = 1; - } - } - - /* Count the arguments and set NUM_ACTUALS. */ - for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++; - num_actuals = i; - - /* Compute number of named args. - Don't include the last named arg if anonymous args follow. - (If no anonymous args follow, the result of list_length - is actually one too large.) */ - if (TYPE_ARG_TYPES (funtype) != 0) - n_named_args = list_length (TYPE_ARG_TYPES (funtype)) - 1; - else - /* If we know nothing, treat all args as named. */ - n_named_args = num_actuals; - - /* Make a vector to hold all the information about each arg. */ - args = (struct arg_data *) alloca (num_actuals * sizeof (struct arg_data)); - bzero (args, num_actuals * sizeof (struct arg_data)); - - args_size.constant = 0; - args_size.var = 0; -#ifdef FIRST_PARM_CALLER_OFFSET - args_size.constant = FIRST_PARM_CALLER_OFFSET (funtype); - stack_count_regparms = 1; -#endif - starting_args_size = args_size.constant; - - /* In this loop, we consider args in the order they are written. - We fill up ARGS from the front of from the back if necessary - so that in any case the first arg to be pushed ends up at the front. */ - -#ifdef PUSH_ARGS_REVERSED - i = num_actuals - 1, inc = -1; - /* In this case, must reverse order of args - so that we compute and push the last arg first. */ -#else - i = 0, inc = 1; -#endif - - INIT_CUMULATIVE_ARGS (args_so_far, funtype); - - for (p = actparms; p; p = TREE_CHAIN (p), i += inc) - { - tree type = TREE_TYPE (TREE_VALUE (p)); - args[i].tree_value = TREE_VALUE (p); - args[i].offset = args_size; - - if (type == error_mark_node - || TYPE_SIZE (type) == 0) - continue; - - /* Decide where to pass this arg. */ - /* args[i].reg is nonzero if all or part is passed in registers. - args[i].partial is nonzero if part but not all is passed in registers, - and the exact value says how many words are passed in registers. */ - - if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - && args_size.var == 0 - /* error_mark_node here is a flag for the fake argument - for a structure value address. */ - && TREE_PURPOSE (p) != error_mark_node) - { - args[i].reg = FUNCTION_ARG (args_so_far, TYPE_MODE (type), type, - i < n_named_args); - /* If this argument needs more than the usual parm alignment, do - extrinsic padding to reach that alignment. */ - -#ifdef MAX_PARM_BOUNDARY - /* If MAX_PARM_BOUNDARY is not defined, it means that the usual - alignment requirements are relaxed for parms, and that no parm - needs more than PARM_BOUNDARY, regardless of data type. */ - - if (PARM_BOUNDARY < TYPE_ALIGN (type)) - { - int boundary = PARM_BOUNDARY; - - /* Determine the boundary to pad up to. */ - if (TYPE_ALIGN (type) > boundary) - boundary = TYPE_ALIGN (type); - if (boundary > MAX_PARM_BOUNDARY) - boundary = MAX_PARM_BOUNDARY; - - /* If the previous args don't reach such a boundary, - advance to the next one. */ - boundary /= BITS_PER_UNIT; - args[i].offset.constant += boundary - 1; - args[i].offset.constant &= ~(boundary - 1); - args_size.constant += boundary - 1; - args_size.constant &= ~(boundary - 1); - - if (args_size.var != 0) - abort (); /* This case not implemented yet */ - } -#endif /* MAX_PARM_BOUNDARY */ - -#ifdef FUNCTION_ARG_PARTIAL_NREGS - args[i].partial - = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, - TYPE_MODE (type), type, - i < n_named_args); -#endif - } - - /* Compute the stack-size of this argument. */ - - if (args[i].reg != 0 && args[i].partial == 0 - && ! stack_count_regparms) - /* On most machines, don't count stack space for a register arg. */ - ; - else if (TYPE_MODE (type) != BLKmode) - { - register int size; - - size = GET_MODE_SIZE (TYPE_MODE (type)); - /* Compute how much space the push instruction will push. - On many machines, pushing a byte will advance the stack - pointer by a halfword. */ -#ifdef PUSH_ROUNDING - size = PUSH_ROUNDING (size); -#endif - /* Compute how much space the argument should get: - maybe pad to a multiple of the alignment for arguments. */ - if (none == FUNCTION_ARG_PADDING (TYPE_MODE (type), const0_rtx)) - args[i].size.constant = size; - else - args[i].size.constant - = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1) - / (PARM_BOUNDARY / BITS_PER_UNIT)) - * (PARM_BOUNDARY / BITS_PER_UNIT)); - } - else - { - register tree size = size_in_bytes (type); - - /* A nonscalar. Round its size up to a multiple - of PARM_BOUNDARY bits, unless it is not supposed to be padded. */ - if (none - != FUNCTION_ARG_PADDING (TYPE_MODE (type), - expand_expr (size, 0, VOIDmode, 0))) - size = convert_units (convert_units (size, BITS_PER_UNIT, - PARM_BOUNDARY), - PARM_BOUNDARY, BITS_PER_UNIT); - ADD_PARM_SIZE (args[i].size, size); - - /* Certain data types may not be passed in registers - (eg C++ classes with constructors). - Also, BLKmode parameters initialized from CALL_EXPRs - are treated specially, if it is a win to do so. */ - if (TREE_CODE (TREE_VALUE (p)) == CALL_EXPR - || TREE_ADDRESSABLE (type)) - { - if (TREE_ADDRESSABLE (type)) - BLKmode_parms_forced = 1; - /* This is a marker for such a parameter. */ - args[i].stack = const0_rtx; - BLKmode_parms_sizes += TREE_INT_CST_LOW (size); - - /* If this parm's location is "below" the nominal stack pointer, - note to decrement the stack pointer while it is computed. */ -#ifdef FIRST_PARM_CALLER_OFFSET - if (BLKmode_parms_first_offset == 0) - BLKmode_parms_first_offset - /* If parameter's offset is variable, assume the worst. */ - = (args[i].offset.var - ? FIRST_PARM_CALLER_OFFSET (funtype) - : args[i].offset.constant); -#endif - } - } - - /* If a part of the arg was put into registers, - don't include that part in the amount pushed. */ - if (! stack_count_regparms) - args[i].size.constant - -= ((args[i].partial * UNITS_PER_WORD) - / (PARM_BOUNDARY / BITS_PER_UNIT) - * (PARM_BOUNDARY / BITS_PER_UNIT)); - - /* Update ARGS_SIZE, the total stack space for args so far. */ - - args_size.constant += args[i].size.constant; - if (args[i].size.var) - { - ADD_PARM_SIZE (args_size, args[i].size.var); - } - - /* Increment ARGS_SO_FAR, which has info about which arg-registers - have been used, etc. */ - - FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type, - i < n_named_args); - } - - /* If we would have to push a partially-in-regs parm - before other stack parms, preallocate stack space instead. */ - must_preallocate = 0; - { - int partial_seen = 0; - for (i = 0; i < num_actuals; i++) - { - if (args[i].partial > 0) - partial_seen = 1; - else if (partial_seen && args[i].reg == 0) - must_preallocate = 1; - } - } - - /* Precompute all register parameters. It isn't safe to compute anything - once we have started filling any specific hard regs. - If this function call is cse'able, precompute all the parameters. */ - - reg_parm_seen = 0; - for (i = 0; i < num_actuals; i++) - if (args[i].reg != 0 || is_const) - { - int j; - int struct_value_lossage = 0; - - /* First, see if this is a precomputed struct-returning function call - and other subsequent parms are also such. */ - if ((TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode - || RETURN_IN_MEMORY (TREE_TYPE (args[i].tree_value))) - && TREE_CODE (args[i].tree_value) == CALL_EXPR) - for (j = i + 1; j < num_actuals; j++) - if (((TYPE_MODE (TREE_TYPE (args[j].tree_value)) == BLKmode - || RETURN_IN_MEMORY (TREE_TYPE (args[j].tree_value))) - && TREE_CODE (args[j].tree_value) == CALL_EXPR - && args[j].reg != 0) || is_const) - { - /* We have two precomputed structure-values call expressions - in our parm list. Both of them would normally use - the structure-value block. To avoid the conflict, - compute this parm with a different temporary block. */ - int size = int_size_in_bytes (TREE_TYPE (args[i].tree_value)); - rtx structval = assign_stack_local (BLKmode, size); - args[i].value = expand_expr (args[i].tree_value, structval, - VOIDmode, 0); - struct_value_lossage = 1; - break; - } - if (!struct_value_lossage) - args[i].value = expand_expr (args[i].tree_value, 0, VOIDmode, 0); - - if (args[i].reg != 0) - reg_parm_seen = 1; - - if (GET_CODE (args[i].value) != MEM - && ! CONSTANT_P (args[i].value) - && GET_CODE (args[i].value) != CONST_DOUBLE) - args[i].value - = force_reg (TYPE_MODE (TREE_TYPE (args[i].tree_value)), - args[i].value); - /* ANSI doesn't require a sequence point here, - but PCC has one, so this will avoid some problems. */ - emit_queue (); - } - - /* Get the function to call, in the form of RTL, if it is a constant. */ - if (fndecl && is_const) - { - /* Get a SYMBOL_REF rtx for the function address. */ - funexp = XEXP (DECL_RTL (fndecl), 0); - -#ifndef NO_FUNCTION_CSE - /* Pass the address through a pseudoreg, if desired, - before the "beginning" of the library call. - So this insn isn't "part of" the library call, in case that - is deleted, or cse'd. */ - if (! flag_no_function_cse) - funexp = copy_to_mode_reg (Pmode, funexp); -#endif - } - - /* Now we are about to start emitting insns that can be deleted - if the libcall is deleted. */ - insn_before = get_last_insn (); - - /* Maybe do additional rounding on the size of the arguments. */ -#ifdef STACK_ARGS_ADJUST - STACK_ARGS_ADJUST (args_size); -#endif - - /* If we have no actual push instructions, or shouldn't use them, - or we need a variable amount of space, make space for all args right now. - Round the needed size up to multiple of STACK_BOUNDARY. */ - - if (args_size.var != 0) - { - old_stack_level = copy_to_mode_reg (Pmode, stack_pointer_rtx); - old_pending_adj = pending_stack_adjust; - argblock = push_block (round_push (ARGS_SIZE_RTX (args_size))); - } - else if (args_size.constant > 0) - { - int needed = args_size.constant; - -#ifdef STACK_BOUNDARY - needed = (needed + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES; -#endif - args_size.constant = needed; - - if ( -#ifndef PUSH_ROUNDING - 1 /* Always preallocate if no push insns. */ -#else - must_preallocate || BLKmode_parms_forced - || BLKmode_parms_sizes > (args_size.constant >> 1) -#endif - ) - { - /* Try to reuse some or all of the pending_stack_adjust - to get this space. Maybe we can avoid any pushing. */ - if (needed > pending_stack_adjust) - { - needed -= pending_stack_adjust; - pending_stack_adjust = 0; - } - else - { - pending_stack_adjust -= needed; - needed = 0; - } - argblock = push_block (gen_rtx (CONST_INT, VOIDmode, needed)); - - /* Once this space is used, we cannot give other calls - (which might be part of the args to this call) - access to this space. This is because there is - no way to say that we are building arguments - in a place which should not be deallocated by - `emit_call_1', which, by the way, is the way this - this space gets deallocated. */ - do_pending_stack_adjust (); - } - } -#ifndef PUSH_ROUNDING - else if (BLKmode_parms_forced) - { - /* If we have reg-parms that need to be temporarily on the stack, - set up an arg block address even though there is no space - to be allocated for it. */ - argblock = push_block (const0_rtx); - } -#endif - -#if 0 - /* If stack needs padding below the args, increase all arg offsets - so the args are stored above the padding. */ - if (stack_padding) - for (i = 0; i < num_actuals; i++) - args[i].offset.constant += stack_padding; -#endif - - /* Don't try to defer pops if preallocating, not even from the first arg, - since ARGBLOCK probably refers to the SP. */ - if (argblock) - NO_DEFER_POP; - -#ifdef STACK_GROWS_DOWNWARD - /* If any BLKmode parms need to be preallocated in space - below the nominal stack-pointer address, we need to adjust the - stack pointer so that this location is temporarily above it. - This ensures that computation won't clobber that space. */ - if (BLKmode_parms_first_offset < 0 && argblock != 0) - { - int needed = -BLKmode_parms_first_offset; - argblock = copy_to_reg (argblock); - -#ifdef STACK_BOUNDARY - needed = (needed + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES; -#endif - protected_stack = gen_rtx (CONST_INT, VOIDmode, needed); - anti_adjust_stack (protected_stack); - } -#endif /* STACK_GROWS_DOWNWARD */ - - /* Get the function to call, in the form of RTL. */ - if (fndecl) - /* Get a SYMBOL_REF rtx for the function address. */ - funexp = XEXP (DECL_RTL (fndecl), 0); - else - /* Generate an rtx (probably a pseudo-register) for the address. */ - { - funexp = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0); - emit_queue (); - } - - /* Figure out the register where the value, if any, will come back. */ - valreg = 0; - if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode - && TYPE_MODE (TREE_TYPE (exp)) != BLKmode) - valreg = hard_function_value (TREE_TYPE (exp), fndecl); - - /* Now compute and store all non-register parms. - These come before register parms, since they can require block-moves, - which could clobber the registers used for register parms. - Parms which have partial registers are not stored here, - but we do preallocate space here if they want that. */ - - for (i = 0; i < num_actuals; i++) - { - /* Preallocate the stack space for a parm if appropriate - so it can be computed directly in the stack space. */ - if (args[i].stack != 0 && argblock != 0) - args[i].stack = target_for_arg (TREE_TYPE (args[i].tree_value), - ARGS_SIZE_RTX (args[i].size), - argblock, args[i].offset); - else - args[i].stack = 0; - - if (args[i].reg == 0 - && TYPE_SIZE (TREE_TYPE (args[i].tree_value)) != 0) - store_one_arg (&args[i], argblock, may_be_alloca); - } - - /* Now store any partially-in-registers parm. - This is the last place a block-move can happen. */ - if (reg_parm_seen) - for (i = 0; i < num_actuals; i++) - if (args[i].partial != 0) - store_one_arg (&args[i], argblock, may_be_alloca); - - if (protected_stack != 0) - adjust_stack (protected_stack); - - /* Pass the function the address in which to return a structure value. */ - if (structure_value_addr && ! structure_value_addr_parm) - emit_move_insn (struct_value_rtx, - force_reg (Pmode, force_operand (structure_value_addr, 0))); - - /* Now set up any wholly-register parms. They were computed already. */ - if (reg_parm_seen) - for (i = 0; i < num_actuals; i++) - if (args[i].reg != 0 && args[i].partial == 0) - store_one_arg (&args[i], argblock, may_be_alloca); - - /* Perform postincrements before actually calling the function. */ - emit_queue (); - - /* All arguments and registers used for the call must be set up by now! */ - - /* ??? Other languages need a nontrivial second argument (static chain). */ - funexp = prepare_call_address (funexp, 0); - - /* Mark all register-parms as living through the call. */ - start_sequence (); - for (i = 0; i < num_actuals; i++) - if (args[i].reg != 0) - { - if (args[i].partial > 0) - use_regs (REGNO (args[i].reg), args[i].partial); - else if (GET_MODE (args[i].reg) == BLKmode) - use_regs (REGNO (args[i].reg), - ((int_size_in_bytes (TREE_TYPE (args[i].tree_value)) - + UNITS_PER_WORD - 1) - / UNITS_PER_WORD)); - else - emit_insn (gen_rtx (USE, VOIDmode, args[i].reg)); - } - - if (structure_value_addr && ! structure_value_addr_parm - && GET_CODE (struct_value_rtx) == REG) - emit_insn (gen_rtx (USE, VOIDmode, struct_value_rtx)); - - use_insns = gen_sequence (); - end_sequence (); - - /* Generate the actual call instruction. */ - /* This also has the effect of turning off any pop-inhibition - done in expand_call. */ - if (args_size.constant < 0) - args_size.constant = 0; - emit_call_1 (funexp, funtype, args_size.constant, - FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1), - valreg, old_inhibit_defer_pop, use_insns); - -/* ??? Nothing has been done here to record control flow - when contained functions can do nonlocal gotos. */ - - /* For calls to `setjmp', etc., inform flow.c it should complain - if nonvolatile values are live. */ - - if (is_setjmp) - { - emit_note (IDENTIFIER_POINTER (DECL_NAME (fndecl)), NOTE_INSN_SETJMP); - current_function_calls_setjmp = 1; - } - - /* Notice functions that cannot return. - If optimizing, insns emitted below will be dead. - If not optimizing, they will exist, which is useful - if the user uses the `return' command in the debugger. */ - - if (fndecl && TREE_THIS_VOLATILE (fndecl)) - emit_barrier (); - - /* For calls to __builtin_new, note that it can never return 0. - This is because a new handler will be called, and 0 it not - among the numbers it is supposed to return. */ -#if 0 - if (is_builtin_new) - emit_note (IDENTIFIER_POINTER (DECL_NAME (fndecl)), NOTE_INSN_BUILTIN_NEW); -#endif - - /* If there are cleanups to be called, don't use a hard reg as target. */ - if (cleanups_this_call != old_cleanups - && target && REG_P (target) - && REGNO (target) < FIRST_PSEUDO_REGISTER) - target = 0; - - /* If value type not void, return an rtx for the value. */ - - if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode - || ignore) - { - target = const0_rtx; - } - else if (structure_value_addr) - { - if (target == 0 || GET_CODE (target) != MEM) - target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), - memory_address (BLKmode, structure_value_addr)); - } - else if (pcc_struct_value) - { - valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)), - fndecl); - if (target == 0) - target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), - copy_to_reg (valreg)); - else if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode) - emit_move_insn (target, gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), - copy_to_reg (valreg))); - else - emit_block_move (target, gen_rtx (MEM, BLKmode, copy_to_reg (valreg)), - expr_size (exp), - TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT); - } - else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp))) - { - if (!rtx_equal_p (target, valreg)) - emit_move_insn (target, valreg); - else - /* This tells expand_inline_function to copy valreg to its target. */ - emit_insn (gen_rtx (USE, VOIDmode, valreg)); - } - else - target = copy_to_reg (valreg); - - /* Perform all cleanups needed for the arguments of this call - (i.e. destructors in C++). */ - expand_cleanups_to (old_cleanups); - - /* If size of args is variable, restore saved stack-pointer value. */ - - if (old_stack_level) - { - emit_move_insn (stack_pointer_rtx, old_stack_level); - pending_stack_adjust = old_pending_adj; - } - - /* If call is cse'able, make appropriate pair of reg-notes around it. */ - if (is_const) - { - rtx insn_first = NEXT_INSN (insn_before); - rtx insn_last = get_last_insn (); - rtx note = 0; - - /* Don't put the notes on if we don't have insns that can hold them. */ - if ((GET_CODE (insn_first) == INSN - || GET_CODE (insn_first) == CALL_INSN - || GET_CODE (insn_first) == JUMP_INSN) - && (GET_CODE (insn_last) == INSN - || GET_CODE (insn_last) == CALL_INSN - || GET_CODE (insn_last) == JUMP_INSN)) - { - /* Construct an "equal form" for the value - which mentions all the arguments in order - as well as the function name. */ - for (i = 0; i < num_actuals; i++) - if (args[i].reg != 0 || is_const) - note = gen_rtx (EXPR_LIST, VOIDmode, args[i].value, note); - note = gen_rtx (EXPR_LIST, VOIDmode, - XEXP (DECL_RTL (fndecl), 0), note); - - REG_NOTES (insn_last) - = gen_rtx (EXPR_LIST, REG_EQUAL, note, - gen_rtx (INSN_LIST, REG_RETVAL, insn_first, - REG_NOTES (insn_last))); - REG_NOTES (insn_first) - = gen_rtx (INSN_LIST, REG_LIBCALL, insn_last, - REG_NOTES (insn_first)); - } - } - - return target; -} - -/* Return an rtx which represents a suitable home on the stack - given TYPE, the type of the argument looking for a home. - This is called only for BLKmode arguments. - - SIZE is the size needed for this target. - ARGS_ADDR is the address of the bottom of the argument block for this call. - OFFSET describes this parameter's offset into ARGS_ADDR. It is meaningless - if this machine uses push insns. */ - -static rtx -target_for_arg (type, size, args_addr, offset) - tree type; - rtx size; - rtx args_addr; - struct args_size offset; -{ - rtx target; - rtx offset_rtx = ARGS_SIZE_RTX (offset); - - /* We do not call memory_address if possible, - because we want to address as close to the stack - as possible. For non-variable sized arguments, - this will be stack-pointer relative addressing. */ - if (GET_CODE (offset_rtx) == CONST_INT) - target = plus_constant (args_addr, INTVAL (offset_rtx)); - else - { - /* I have no idea how to guarantee that this - will work in the presence of register parameters. */ - target = gen_rtx (PLUS, Pmode, args_addr, offset_rtx); - target = memory_address (QImode, target); - } - - return gen_rtx (MEM, BLKmode, target); -} - -/* Store a single argument for a function call - into the register or memory area where it must be passed. - *ARG describes the argument value and where to pass it. - ARGBLOCK is the address of the stack-block for all the arguments, - or 0 on a machine where arguemnts are pushed individually. - MAY_BE_ALLOCA nonzero says this could be a call to `alloca' - so must be careful about how the stack is used. */ - -static void -store_one_arg (arg, argblock, may_be_alloca) - struct arg_data *arg; - rtx argblock; - int may_be_alloca; -{ - register tree pval = arg->tree_value; - int used = 0; - - if (TREE_CODE (pval) == ERROR_MARK) - return; - - if (arg->reg != 0 && arg->partial == 0) - { - /* Being passed entirely in a register. */ - if (arg->value != 0) - { - if (GET_MODE (arg->value) == BLKmode) - move_block_to_reg (REGNO (arg->reg), arg->value, - ((int_size_in_bytes (TREE_TYPE (pval)) - + UNITS_PER_WORD - 1) - / UNITS_PER_WORD)); - else - emit_move_insn (arg->reg, arg->value); - } - else - store_expr (pval, arg->reg, 0); - - /* Don't allow anything left on stack from computation - of argument to alloca. */ - if (may_be_alloca) - do_pending_stack_adjust (); - } - else if (TYPE_MODE (TREE_TYPE (pval)) != BLKmode) - { - register int size; - rtx tem; - - /* Argument is a scalar, not entirely passed in registers. - (If part is passed in registers, arg->partial says how much - and emit_push_insn will take care of putting it there.) - - Push it, and if its size is less than the - amount of space allocated to it, - also bump stack pointer by the additional space. - Note that in C the default argument promotions - will prevent such mismatches. */ - - used = size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (pval))); - /* Compute how much space the push instruction will push. - On many machines, pushing a byte will advance the stack - pointer by a halfword. */ -#ifdef PUSH_ROUNDING - size = PUSH_ROUNDING (size); -#endif - /* Compute how much space the argument should get: - round up to a multiple of the alignment for arguments. */ - if (none != FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)), const0_rtx)) - used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1) - / (PARM_BOUNDARY / BITS_PER_UNIT)) - * (PARM_BOUNDARY / BITS_PER_UNIT)); - - tem = arg->value; - if (tem == 0) - { - tem = expand_expr (pval, 0, VOIDmode, 0); - /* ANSI doesn't require a sequence point here, - but PCC has one, so this will avoid some problems. */ - emit_queue (); - } - - /* Don't allow anything left on stack from computation - of argument to alloca. */ - if (may_be_alloca) - do_pending_stack_adjust (); - - emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), 0, 0, - arg->partial, arg->reg, used - size, - argblock, ARGS_SIZE_RTX (arg->offset)); - } - else if (arg->stack != 0) - { - /* BLKmode parm, not entirely passed in registers, - and with space already allocated. */ - - tree sizetree = size_in_bytes (TREE_TYPE (pval)); - - /* Find out if the parm needs padding, and whether above or below. */ - enum direction where_pad - = FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)), - expand_expr (sizetree, 0, VOIDmode, 0)); - - /* If it is padded below, adjust the stack address - upward over the padding. */ - - if (where_pad == downward) - { - rtx offset_rtx; - rtx address = XEXP (arg->stack, 0); - struct args_size stack_offset; - /* Hack for C++: see assign_parms for symmetric code. */ - int extra = 0; - - stack_offset.constant = 0; - stack_offset.var = 0; - - if (TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT != PARM_BOUNDARY) - { - /* Round the size up to multiple of PARM_BOUNDARY bits. */ - tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY); - tree s2 = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT); - /* Compute amount of padding. */ - ADD_PARM_SIZE (stack_offset, s2); - SUB_PARM_SIZE (stack_offset, sizetree); - extra = stack_offset.constant % UNITS_PER_WORD; - stack_offset.constant -= extra; - } - offset_rtx = ARGS_SIZE_RTX (stack_offset); - - /* If there is rounding to do for a BLKmode parameter, - add it in here, since STACK_OFFSET is not used for the - rest of this iteration. */ - stack_offset.constant += extra; - - /* Adjust the address to store at. */ - if (GET_CODE (offset_rtx) == CONST_INT) - address = plus_constant (address, INTVAL (offset_rtx)); - else - { - address = gen_rtx (PLUS, Pmode, address, offset_rtx); - address = memory_address (QImode, address); - } - arg->stack = change_address (arg->stack, VOIDmode, address); - } - - /* ARG->stack probably refers to the stack-pointer. If so, - stabilize it, in case stack-pointer changes during evaluation. */ - if (reg_mentioned_p (stack_pointer_rtx, arg->stack)) - arg->stack = change_address (arg->stack, VOIDmode, - copy_to_reg (XEXP (arg->stack, 0))); - /* BLKmode argument that should go in a prespecified stack location. */ - if (arg->value == 0) - /* Not yet computed => compute it there. */ - /* ??? This should be changed to tell expand_expr - that it can store directly in the target. */ - arg->value = store_expr (arg->tree_value, arg->stack, 0); - else if (arg->value != arg->stack) - /* It was computed somewhere, but not where we wanted. - For example, the value may have come from an official - local variable or parameter. In that case, expand_expr - does not fill our suggested target. */ - emit_block_move (arg->stack, arg->value, ARGS_SIZE_RTX (arg->size), - TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT); - - /* Now, if this value wanted to be partly in registers, - move the value from the stack to the registers - that are supposed to hold the values. */ - if (arg->partial > 0) - move_block_to_reg (REGNO (arg->reg), arg->stack, arg->partial); - } - else - { - /* BLKmode, at least partly to be pushed. */ - - register rtx tem - = arg->value ? arg->value : expand_expr (pval, 0, VOIDmode, 0); - register int excess; - rtx size_rtx; - - /* Pushing a nonscalar. - If part is passed in registers, arg->partial says how much - and emit_push_insn will take care of putting it there. */ - - /* Round its size up to a multiple - of the allocation unit for arguments. */ - - if (arg->size.var != 0) - { - excess = 0; - size_rtx = ARGS_SIZE_RTX (arg->size); - } - else - { - register tree size = size_in_bytes (TREE_TYPE (pval)); - /* PUSH_ROUNDING has no effect on us, because - emit_push_insn for BLKmode is careful to avoid it. */ - excess = (arg->size.constant - TREE_INT_CST_LOW (size) - + arg->partial * UNITS_PER_WORD); - size_rtx = expand_expr (size, 0, VOIDmode, 0); - } - - /* if (arg->stack) */ - /* abort (); */ - - emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), size_rtx, - TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT, - arg->partial, arg->reg, excess, argblock, - ARGS_SIZE_RTX (arg->offset)); - } - - /* Once we have pushed something, pops can't safely - be deferred during the rest of the arguments. */ - NO_DEFER_POP; -} - -/* Expand conditional expressions. */ - -/* Generate code to evaluate EXP and jump to LABEL if the value is zero. - LABEL is an rtx of code CODE_LABEL, in this function and all the - functions here. */ - -void -jumpifnot (exp, label) - tree exp; - rtx label; -{ - do_jump (exp, label, 0); -} - -/* Generate code to evaluate EXP and jump to LABEL if the value is nonzero. */ - -void -jumpif (exp, label) - tree exp; - rtx label; -{ - do_jump (exp, 0, label); -} - -/* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if - the result is zero, or IF_TRUE_LABEL if the result is one. - Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero, - meaning fall through in that case. - - This function is responsible for optimizing cases such as - &&, || and comparison operators in EXP. */ - -void -do_jump (exp, if_false_label, if_true_label) - tree exp; - rtx if_false_label, if_true_label; -{ - register enum tree_code code = TREE_CODE (exp); - /* Some cases need to create a label to jump to - in order to properly fall through. - These cases set DROP_THROUGH_LABEL nonzero. */ - rtx drop_through_label = 0; - rtx temp; - rtx comparison = 0; - - emit_queue (); - - switch (code) - { - case ERROR_MARK: - break; - - case INTEGER_CST: - temp = integer_zerop (exp) ? if_false_label : if_true_label; - if (temp) - emit_jump (temp); - break; - - case ADDR_EXPR: - /* The address of something can never be zero. */ - if (if_true_label) - emit_jump (if_true_label); - break; - - case NOP_EXPR: - do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label); - break; - - case TRUTH_NOT_EXPR: - do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label); - break; - - case TRUTH_ANDIF_EXPR: - if (if_false_label == 0) - if_false_label = drop_through_label = gen_label_rtx (); - do_jump (TREE_OPERAND (exp, 0), if_false_label, 0); - do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label); - break; - - case TRUTH_ORIF_EXPR: - if (if_true_label == 0) - if_true_label = drop_through_label = gen_label_rtx (); - do_jump (TREE_OPERAND (exp, 0), 0, if_true_label); - do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label); - break; - - case COMPOUND_EXPR: - expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0); - emit_queue (); - do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label); - break; - - case COND_EXPR: - { - register rtx label1 = gen_label_rtx (); - drop_through_label = gen_label_rtx (); - do_jump (TREE_OPERAND (exp, 0), label1, 0); - /* Now the THEN-expression. */ - do_jump (TREE_OPERAND (exp, 1), - if_false_label ? if_false_label : drop_through_label, - if_true_label ? if_true_label : drop_through_label); - emit_label (label1); - /* Now the ELSE-expression. */ - do_jump (TREE_OPERAND (exp, 2), - if_false_label ? if_false_label : drop_through_label, - if_true_label ? if_true_label : drop_through_label); - } - break; - - case EQ_EXPR: - comparison = compare (exp, EQ, EQ, EQ, EQ); - break; - - case NE_EXPR: - comparison = compare (exp, NE, NE, NE, NE); - break; - - case LT_EXPR: - comparison = compare (exp, LT, LTU, GT, GTU); - break; - - case LE_EXPR: - comparison = compare (exp, LE, LEU, GE, GEU); - break; - - case GT_EXPR: - comparison = compare (exp, GT, GTU, LT, LTU); - break; - - case GE_EXPR: - comparison = compare (exp, GE, GEU, LE, LEU); - break; - - default: - temp = expand_expr (exp, 0, VOIDmode, 0); - /* Copy to register to avoid generating bad insns by cse - from (set (mem ...) (arithop)) (set (cc0) (mem ...)). */ - if (!cse_not_expected && GET_CODE (temp) == MEM) - temp = copy_to_reg (temp); - do_pending_stack_adjust (); - { - rtx zero = CONST0_RTX (GET_MODE (temp)); - - if (GET_CODE (temp) == CONST_INT) - comparison = compare_constants (NE, 0, - INTVAL (temp), 0, BITS_PER_WORD); - else if (GET_MODE (temp) != VOIDmode) - comparison = compare1 (temp, zero, NE, NE, 0, GET_MODE (temp)); - else - abort (); - } - } - - /* Do any postincrements in the expression that was tested. */ - emit_queue (); - - /* If COMPARISON is nonzero here, it is an rtx that can be substituted - straight into a conditional jump instruction as the jump condition. - Otherwise, all the work has been done already. */ - - if (comparison == const1_rtx) - { - if (if_true_label) - emit_jump (if_true_label); - } - else if (comparison == const0_rtx) - { - if (if_false_label) - emit_jump (if_false_label); - } - else if (comparison) - { - if (if_true_label) - { - if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0) - emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_true_label)); - else - abort (); - - if (if_false_label) - emit_jump (if_false_label); - } - else if (if_false_label) - { - rtx pat; - - if (bcc_gen_fctn[(int) GET_CODE (comparison)] == 0) - abort (); - - pat = (*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_false_label); - /* Now invert the sense of the jump by exchanging the two arms - of each IF_THEN_ELSE. Note that inverting the condition - would be incorrect for IEEE floating point with nans! */ - if (GET_CODE (pat) == SEQUENCE) - { - int i; - /* We can invert a sequence if the only jump is at the end. */ - for (i = 0; i < (int) (XVECLEN (pat, 0) - 1); i++) - if (GET_CODE (XVECEXP (pat, 0, i)) == JUMP_INSN) - abort (); - invert_exp (PATTERN (XVECEXP (pat, 0, XVECLEN (pat, 0) - 1)), - 0, 0); - } - else - invert_exp (pat, 0, 0); - - emit_jump_insn (pat); - } - } - - if (drop_through_label) - emit_label (drop_through_label); -} - -/* Compare two integer constant rtx's, OP0 and OP1. - The comparison operation is OPERATION. - Return an rtx representing the value 1 or 0. - WIDTH is the width in bits that is significant. */ - -static rtx -compare_constants (operation, unsignedp, op0, op1, width) - enum rtx_code operation; - int unsignedp; - int op0, op1; - int width; -{ - int val; - - /* Sign-extend or zero-extend the operands to a full word - from an initial width of WIDTH bits. */ - if (width < HOST_BITS_PER_INT) - { - op0 &= (1 << width) - 1; - op1 &= (1 << width) - 1; - - if (! unsignedp) - { - if (op0 & (1 << (width - 1))) - op0 |= ((-1) << width); - if (op1 & (1 << (width - 1))) - op1 |= ((-1) << width); - } - } - - switch (operation) - { - case EQ: - val = op0 == op1; - break; - - case NE: - val = op0 != op1; - break; - - case GT: - case GTU: - val = op0 > op1; - break; - - case LT: - case LTU: - val = op0 < op1; - break; - - case GE: - case GEU: - val = op0 >= op1; - break; - - case LE: - case LEU: - val = op0 <= op1; - } - - return val ? const1_rtx : const0_rtx; -} - -/* Generate code for a comparison expression EXP - (including code to compute the values to be compared) - and set (CC0) according to the result. - SIGNED_FORWARD should be the rtx operation for this comparison for - signed data; UNSIGNED_FORWARD, likewise for use if data is unsigned. - SIGNED_REVERSE and UNSIGNED_REVERSE are used if it is desirable - to interchange the operands for the compare instruction. - - We force a stack adjustment unless there are currently - things pushed on the stack that aren't yet used. */ - -static rtx -compare (exp, signed_forward, unsigned_forward, - signed_reverse, unsigned_reverse) - register tree exp; - enum rtx_code signed_forward, unsigned_forward; - enum rtx_code signed_reverse, unsigned_reverse; -{ - - register rtx op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0); - register rtx op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0); - register enum machine_mode mode = GET_MODE (op0); - int unsignedp; - - /* If one operand is 0, make it the second one. */ - - if (op0 == const0_rtx - || (GET_MODE_CLASS (mode) == MODE_FLOAT && op0 == CONST0_RTX (mode))) - { - rtx tem = op0; - op0 = op1; - op1 = tem; - signed_forward = signed_reverse; - unsigned_forward = unsigned_reverse; - } - - if (flag_force_mem) - { - op0 = force_not_mem (op0); - op1 = force_not_mem (op1); - } - - do_pending_stack_adjust (); - - unsignedp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))) - || TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))); - - if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT) - return compare_constants (signed_forward, unsignedp, - INTVAL (op0), INTVAL (op1), - GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))); - - emit_cmp_insn (op0, op1, - (mode == BLKmode) ? expr_size (TREE_OPERAND (exp, 0)) : 0, - unsignedp, - TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT); - - return gen_rtx ((unsignedp ? unsigned_forward : signed_forward), - VOIDmode, cc0_rtx, const0_rtx); -} - -/* Like compare but expects the values to compare as two rtx's. - The decision as to signed or unsigned comparison must be made by the caller. - BLKmode is not allowed. */ - -static rtx -compare1 (op0, op1, forward_op, reverse_op, unsignedp, mode) - register rtx op0, op1; - enum rtx_code forward_op, reverse_op; - int unsignedp; - enum machine_mode mode; -{ - /* If one operand is 0, make it the second one. */ - - if (op0 == const0_rtx - || (GET_MODE_CLASS (mode) == MODE_FLOAT && op0 == CONST0_RTX (mode))) - { - rtx tem = op0; - op0 = op1; - op1 = tem; - forward_op = reverse_op; - } - - if (flag_force_mem) - { - op0 = force_not_mem (op0); - op1 = force_not_mem (op1); - } - - do_pending_stack_adjust (); - - if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT) - return compare_constants (forward_op, unsignedp, - INTVAL (op0), INTVAL (op1), - GET_MODE_BITSIZE (mode)); - - emit_cmp_insn (op0, op1, 0, unsignedp, 0); - - return gen_rtx (forward_op, VOIDmode, cc0_rtx, const0_rtx); -} - -/* Generate code to calculate EXP using a store-flag instruction - and return an rtx for the result. - If TARGET is nonzero, store the result there if convenient. - - Return zero if there is no suitable set-flag instruction - available on this machine. */ - -static rtx -do_store_flag (exp, target, mode) - tree exp; - rtx target; - enum machine_mode mode; -{ - register enum tree_code code = TREE_CODE (exp); - register rtx comparison = 0; - enum machine_mode compare_mode; - rtx prev_insn = get_last_insn (); - enum insn_code icode; - - switch (code) - { -#ifdef HAVE_seq - case EQ_EXPR: - if (HAVE_seq) - { - comparison = compare (exp, EQ, EQ, EQ, EQ); - icode = CODE_FOR_seq; - compare_mode = insn_operand_mode[(int) CODE_FOR_seq][0]; - } - break; -#endif - -#ifdef HAVE_sne - case NE_EXPR: - if (HAVE_sne) - { - comparison = compare (exp, NE, NE, NE, NE); - icode = CODE_FOR_sne; - compare_mode = insn_operand_mode[(int) CODE_FOR_sne][0]; - } - break; -#endif - -#if defined (HAVE_slt) && defined (HAVE_sltu) && defined (HAVE_sgt) && defined (HAVE_sgtu) - case LT_EXPR: - if (HAVE_slt && HAVE_sltu && HAVE_sgt && HAVE_sgtu) - { - comparison = compare (exp, LT, LTU, GT, GTU); - icode = CODE_FOR_slt; - compare_mode = insn_operand_mode[(int) CODE_FOR_slt][0]; - } - break; - - case GT_EXPR: - if (HAVE_slt && HAVE_sltu && HAVE_sgt && HAVE_sgtu) - { - comparison = compare (exp, GT, GTU, LT, LTU); - icode = CODE_FOR_slt; - compare_mode = insn_operand_mode[(int) CODE_FOR_slt][0]; - } - break; -#endif - -#if defined (HAVE_sle) && defined (HAVE_sleu) && defined (HAVE_sge) && defined (HAVE_sgeu) - case LE_EXPR: - if (HAVE_sle && HAVE_sleu && HAVE_sge && HAVE_sgeu) - { - comparison = compare (exp, LE, LEU, GE, GEU); - icode = CODE_FOR_sle; - compare_mode = insn_operand_mode[(int) CODE_FOR_sle][0]; - } - break; - - case GE_EXPR: - if (HAVE_sle && HAVE_sleu && HAVE_sge && HAVE_sgeu) - { - comparison = compare (exp, GE, GEU, LE, LEU); - icode = CODE_FOR_sle; - compare_mode = insn_operand_mode[(int) CODE_FOR_sle][0]; - } - break; -#endif - } - if (comparison == 0) - return 0; - - if (target == 0 || GET_MODE (target) != mode - /* Don't use specified target unless the insn can handle it. */ - || ! (*insn_operand_predicate[(int) icode][0]) (target, mode) - /* When modes don't match, don't use specified target, - because it might be the same as an operand, - and then the CLOBBER output below would screw up. */ - || (mode != compare_mode && GET_CODE (comparison) != CONST_INT)) - target = gen_reg_rtx (mode); - - /* Store the comparison in its proper mode. */ - if (GET_CODE (comparison) == CONST_INT) - emit_move_insn (target, comparison); - else if (GET_MODE (target) != compare_mode) - { - /* We want a different mode: store result in its natural mode. - Combine the mode conversion with the truncation we must do anyway. */ - /* Put a CLOBBER before the compare, so we don't come between - the compare and the insn that uses the result. */ - emit_insn_after (gen_rtx (CLOBBER, VOIDmode, target), prev_insn); - emit_insn ((*setcc_gen_fctn[(int) GET_CODE (comparison)]) - (gen_rtx (SUBREG, compare_mode, target, 0))); - /* If the desired mode is wider than what we got, - use an AND to convert it, but not if we will do one anyway. */ -#if STORE_FLAG_VALUE == 1 - if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (compare_mode)) - expand_bit_and (mode, target, const1_rtx, target); -#endif - } - else - emit_insn ((*setcc_gen_fctn[(int) GET_CODE (comparison)]) (target)); - -#if STORE_FLAG_VALUE != 1 -#if STORE_FLAG_VALUE & 1 - expand_bit_and (mode, target, const1_rtx, target); -#else - expand_shift (RSHIFT_EXPR, mode, target, - build_int_2 (GET_MODE_BITSIZE (mode) - 1, 0), - target, TRUE); -#endif -#endif - return target; -} - -/* Generate a tablejump instruction (used for switch statements). */ - -#ifdef HAVE_tablejump - -/* INDEX is the value being switched on, with the lowest value - in the table already subtracted. - RANGE is the length of the jump table. - TABLE_LABEL is a CODE_LABEL rtx for the table itself. - - DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the - index value is out of range. */ - -void -do_tablejump (index, range, table_label, default_label) - rtx index, range, table_label, default_label; -{ - register rtx temp; - - emit_cmp_insn (range, index, 0, 0, 0); - emit_jump_insn (gen_bltu (default_label)); - /* If flag_force_addr were to affect this address - it could interfere with the tricky assumptions made - about addresses that contain label-refs, - which may be valid only very near the tablejump itself. */ - index = memory_address_noforce - (CASE_VECTOR_MODE, - gen_rtx (PLUS, Pmode, - gen_rtx (MULT, Pmode, index, - gen_rtx (CONST_INT, VOIDmode, - GET_MODE_SIZE (CASE_VECTOR_MODE))), - gen_rtx (LABEL_REF, VOIDmode, table_label))); - temp = gen_reg_rtx (CASE_VECTOR_MODE); - convert_move (temp, gen_rtx (MEM, CASE_VECTOR_MODE, index), 0); - - emit_jump_insn (gen_tablejump (temp, table_label)); -} - -#endif /* HAVE_tablejump */ diff --git a/gnu/usr.bin/g++/cc1plus/expr.h b/gnu/usr.bin/g++/cc1plus/expr.h deleted file mode 100644 index 1d68e9e68b16..000000000000 --- a/gnu/usr.bin/g++/cc1plus/expr.h +++ /dev/null @@ -1,463 +0,0 @@ -/* Definitions for code generation pass of GNU compiler. - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#ifndef __STDC__ -#ifndef const -#define const -#endif -#endif - -/* Macros to access the slots of a QUEUED rtx. - Here rather than in rtl.h because only the expansion pass - should ever encounter a QUEUED. */ - -/* The variable for which an increment is queued. */ -#define QUEUED_VAR(P) XEXP (P, 0) -/* If the increment has been emitted, this is the insn - that does the increment. It is zero before the increment is emitted. */ -#define QUEUED_INSN(P) XEXP (P, 1) -/* If a pre-increment copy has been generated, this is the copy - (it is a temporary reg). Zero if no copy made yet. */ -#define QUEUED_COPY(P) XEXP (P, 2) -/* This is the body to use for the insn to do the increment. - It is used to emit the increment. */ -#define QUEUED_BODY(P) XEXP (P, 3) -/* Next QUEUED in the queue. */ -#define QUEUED_NEXT(P) XEXP (P, 4) - -/* This is the 4th arg to `expand_expr'. - EXPAND_SUM means it is ok to return a PLUS rtx or MULT rtx. - EXPAND_CONST_ADDRESS means it is ok to return a MEM whose address - is a constant that is not a legitimate address. - EXPAND_INTO_STACK means that if a temporary value needs to be - created, it should be done so that it lasts the life of - the call. This can be implemented either by returning - a pointer to a slot which is actually allocated on the stack, - or by returning a temporary in the callers frame. */ -enum expand_modifier {EXPAND_NORMAL, EXPAND_SUM, EXPAND_CONST_ADDRESS, - EXPAND_INTO_STACK}; - -/* If this is nonzero, we do not bother generating VOLATILE - around volatile memory references, and we are willing to - output indirect addresses. If cse is to follow, we reject - indirect addresses so a useful potential cse is generated; - if it is used only once, instruction combination will produce - the same indirect address eventually. */ -extern int cse_not_expected; - -/* List (chain of EXPR_LISTs) of pseudo-regs of SAVE_EXPRs. - So we can mark them all live at the end of the function, if stupid. */ -extern rtx save_expr_regs; - -extern int current_function_calls_alloca; - -/* Nonzero means stack pops must not be deferred, and deferred stack - pops must not be output. It is nonzero inside a function call, - inside a conditional expression, inside a statement expression, - and in other cases as well. */ -extern int inhibit_defer_pop; - -/* Number of function calls seen so far in current function. */ - -extern int function_call_count; - -/* RTX for stack slot that holds the current handler for nonlocal gotos. - Zero when function does not have nonlocal labels. */ - -extern rtx nonlocal_goto_handler_slot; - -/* RTX for stack slot that holds the stack pointer value to restore - for a nonlocal goto. - Zero when function does not have nonlocal labels. */ - -extern rtx nonlocal_goto_stack_level; - -/* List (chain of TREE_LIST) of LABEL_DECLs for all nonlocal labels - (labels to which there can be nonlocal gotos from nested functions) - in this function. */ - -#ifdef TREE_CODE /* Don't lose if tree.h not included. */ -extern tree nonlocal_labels; -#endif - -#define NO_DEFER_POP (inhibit_defer_pop += 1) -#define OK_DEFER_POP (inhibit_defer_pop -= 1) - -/* Number of units that we should eventually pop off the stack. - These are the arguments to function calls that have already returned. */ -extern int pending_stack_adjust; - -/* A list of all cleanups which belong to the arguments of - function calls being expanded by expand_call. */ -#ifdef TREE_CODE /* Don't lose if tree.h not included. */ -extern tree cleanups_this_call; -#endif - -/* Sequence of insns which must be emitted *prior* to calling - __builtin_saveregs. */ -rtx save_from_saveregs; - -#ifdef TREE_CODE /* Don't lose if tree.h not included. */ -/* Structure to record the size of a sequence of arguments - as the sum of a tree-expression and a constant. */ - -struct args_size -{ - int constant; - tree var; -}; -#endif - -/* Add the value of the tree INC to the `struct args_size' TO. */ - -#define ADD_PARM_SIZE(TO, INC) \ -{ tree inc = (INC); \ - if (TREE_CODE (inc) == INTEGER_CST) \ - (TO).constant += TREE_INT_CST_LOW (inc); \ - else if ((TO).var == 0) \ - (TO).var = inc; \ - else \ - (TO).var = genop (PLUS_EXPR, (TO).var, inc); } - -#define SUB_PARM_SIZE(TO, DEC) \ -{ tree dec = (DEC); \ - if (TREE_CODE (dec) == INTEGER_CST) \ - (TO).constant -= TREE_INT_CST_LOW (dec); \ - else if ((TO).var == 0) \ - (TO).var = genop (MINUS_EXPR, integer_zero_node, dec); \ - else \ - (TO).var = genop (MINUS_EXPR, (TO).var, dec); } - -/* Convert the implicit sum in a `struct args_size' into an rtx. */ -#define ARGS_SIZE_RTX(SIZE) \ -((SIZE).var == 0 ? gen_rtx (CONST_INT, VOIDmode, (SIZE).constant) \ - : plus_constant (expand_expr ((SIZE).var, 0, VOIDmode, 0), \ - (SIZE).constant)) - -/* Supply a default definition for FUNCTION_ARG_PADDING: - usually pad upward, but pad short args downward on big-endian machines. */ - -enum direction {none, upward, downward}; /* Value has this type. */ - -#ifndef FUNCTION_ARG_PADDING -#ifdef BYTES_BIG_ENDIAN -#define FUNCTION_ARG_PADDING(mode, size) \ - (((mode) == BLKmode \ - ? (GET_CODE (size) == CONST_INT \ - && INTVAL (size) < PARM_BOUNDARY / BITS_PER_UNIT) \ - : GET_MODE_BITSIZE (mode) < PARM_BOUNDARY) \ - ? downward : upward) -#else -#define FUNCTION_ARG_PADDING(mode, size) upward -#endif -#endif - -/* Nonzero if type TYPE should be returned in memory - (even though its mode is not BLKmode). - Most machines can use the following default definition. */ - -#ifndef RETURN_IN_MEMORY -#define RETURN_IN_MEMORY(type) 0 -#endif - -/* Optabs are tables saying how to generate insn bodies - for various machine modes and numbers of operands. - Each optab applies to one operation. - For example, add_optab applies to addition. - - The insn_code slot is the enum insn_code that says how to - generate an insn for this operation on a particular machine mode. - It is CODE_FOR_nothing if there is no such insn on the target machine. - - The `lib_call' slot is the name of the library function that - can be used to perform the operation. - - A few optabs, such as move_optab and cmp_optab, are used - by special code. */ - -/* Everything that uses expr.h needs to define enum insn_code - but we don't list it in the Makefile dependencies just for that. */ -#include "insn-codes.h" - -typedef struct optab -{ - enum rtx_code code; - struct { - enum insn_code insn_code; - char *lib_call; - } handlers [NUM_MACHINE_MODES]; -} * optab; - -/* Given an enum insn_code, access the function to construct - the body of that kind of insn. */ -#define GEN_FCN(CODE) (*insn_gen_function[(int) (CODE)]) -extern rtx (*const insn_gen_function[]) (); - -extern optab add_optab; -extern optab sub_optab; -extern optab smul_optab; /* Signed multiply */ -extern optab smul_widen_optab; /* Signed multiply with result - one machine mode wider than args */ -extern optab umul_widen_optab; -extern optab sdiv_optab; /* Signed divide */ -extern optab sdivmod_optab; /* Signed divide-and-remainder in one */ -extern optab udiv_optab; -extern optab udivmod_optab; -extern optab smod_optab; /* Signed remainder */ -extern optab umod_optab; -extern optab flodiv_optab; /* Optab for floating divide. */ -extern optab ftrunc_optab; /* Convert float to integer in float fmt */ -extern optab and_optab; /* Logical and */ -extern optab ior_optab; /* Logical or */ -extern optab xor_optab; /* Logical xor */ -extern optab ashl_optab; /* Arithmetic shift left */ -extern optab ashr_optab; /* Arithmetic shift right */ -extern optab lshl_optab; /* Logical shift left */ -extern optab lshr_optab; /* Logical shift right */ -extern optab rotl_optab; /* Rotate left */ -extern optab rotr_optab; /* Rotate right */ - -extern optab mov_optab; /* Move instruction. */ -extern optab movstrict_optab; /* Move, preserving high part of register. */ - -extern optab cmp_optab; /* Compare insn; two operands. */ -extern optab tst_optab; /* tst insn; compare one operand against 0 */ - -/* Unary operations */ -extern optab neg_optab; /* Negation */ -extern optab abs_optab; /* Abs value */ -extern optab one_cmpl_optab; /* Bitwise not */ -extern optab ffs_optab; /* Find first bit set */ - -/* Passed to expand_binop and expand_unop to say which options to try to use - if the requested operation can't be open-coded on the requisite mode. - Either OPTAB_LIB or OPTAB_LIB_WIDEN says try using a library call. - Either OPTAB_WIDEN or OPTAB_LIB_WIDEN says try using a wider mode. - OPTAB_MUST_WIDEN says try widening and don't try anything else. */ - -enum optab_methods -{ - OPTAB_DIRECT, - OPTAB_LIB, - OPTAB_WIDEN, - OPTAB_LIB_WIDEN, - OPTAB_MUST_WIDEN, -}; - -typedef rtx (*rtxfun) (); - -/* Indexed by the rtx-code for a conditional (eg. EQ, LT,...) - gives the gen_function to make a branch to test that condition. */ - -extern rtxfun bcc_gen_fctn[NUM_RTX_CODE]; - -/* Indexed by the rtx-code for a conditional (eg. EQ, LT,...) - gives the gen_function to make a store-condition insn - to test that condition. */ - -extern rtxfun setcc_gen_fctn[NUM_RTX_CODE]; - -/* Expand a binary operation given optab and rtx operands. */ -rtx expand_binop (); - -/* Expand a binary operation with both signed and unsigned forms. */ -rtx sign_expand_binop (); - -/* Expand a unary arithmetic operation given optab rtx operand. */ -rtx expand_unop (); - -/* Arguments MODE, RTX: return an rtx for the negation of that value. - May emit insns. */ -rtx negate_rtx (); - -/* Initialize the tables that control conversion between fixed and - floating values. */ -void init_fixtab (); -void init_floattab (); - -/* Generate code for a FIX_EXPR. */ -void expand_fix (); - -/* Generate code for a FLOAT_EXPR. */ -void expand_float (); - -/* Create but don't emit one rtl instruction to add one rtx into another. - Modes must match. - Likewise for subtraction and for just copying. - These do not call protect_from_queue; caller must do so. */ -rtx gen_add2_insn (); -rtx gen_sub2_insn (); -rtx gen_move_insn (); - -/* Emit one rtl instruction to store zero in specified rtx. */ -void emit_clr_insn (); - -/* Emit one rtl insn to store 1 in specified rtx assuming it contains 0. */ -void emit_0_to_1_insn (); - -/* Emit one rtl insn to compare two rtx's. */ -void emit_cmp_insn (); - -/* Emit some rtl insns to move data between rtx's, converting machine modes. - Both modes must be floating or both fixed. */ -void convert_move (); - -/* Convert an rtx to specified machine mode and return the result. */ -rtx convert_to_mode (); - -/* Emit code to push some arguments and call a library routine, - storing the value in a specified place. Calling sequence is - complicated. */ -void emit_library_call (); - -/* Given an rtx that may include add and multiply operations, - generate them as insns and return a pseudo-reg containing the value. - Useful after calling expand_expr with 1 as sum_ok. */ -rtx force_operand (); - -/* Return an rtx for the size in bytes of the value of an expr. */ -rtx expr_size (); - -/* Return an rtx for the sum of an rtx and an integer. */ -rtx plus_constant (); - -rtx lookup_static_chain (); - -/* Return an rtx like arg but sans any constant terms. - Returns the original rtx if it has no constant terms. - The constant terms are added and stored via a second arg. */ -rtx eliminate_constant_term (); - -/* Convert arg to a valid memory address for specified machine mode, - by emitting insns to perform arithmetic if nec. */ -rtx memory_address (); - -/* Like `memory_address' but pretent `flag_force_addr' is 0. */ -rtx memory_address_noforce (); - -/* Return a memory reference like MEMREF, but with its mode changed - to MODE and its address changed to ADDR. - (VOIDmode means don't change the mode. - NULL for ADDR means don't change the address.) */ -rtx change_address (); - -#if 0 -/* Convert a stack slot address ADDR valid in function FNDECL - into an address valid in this function (using a static chain). */ -rtx fix_lexical_addr (); - -/* Return the address of the trampoline for entering nested fn FUNCTION. */ -rtx trampoline_address (); - -/* Assemble the static constant template for function entry trampolines. */ -rtx assemble_trampoline_template (); -#endif - -/* Return 1 if two rtx's are equivalent in structure and elements. */ -int rtx_equal_p (); - -/* Given rtx, return new rtx whose address won't be affected by - any side effects. It has been copied to a new temporary reg. */ -rtx stabilize (); - -/* Given an rtx, copy all regs it refers to into new temps - and return a modified copy that refers to the new temps. */ -rtx copy_all_regs (); - -/* Copy given rtx to a new temp reg and return that. */ -rtx copy_to_reg (); - -/* Like copy_to_reg but always make the reg Pmode. */ -rtx copy_addr_to_reg (); - -/* Like copy_to_reg but always make the reg the specified mode MODE. */ -rtx copy_to_mode_reg (); - -/* Copy given rtx to given temp reg and return that. */ -rtx copy_to_suggested_reg (); - -/* Copy a value to a register if it isn't already a register. - Args are mode (in case value is a constant) and the value. */ -rtx force_reg (); - -/* Return given rtx, copied into a new temp reg if it was in memory. */ -rtx force_not_mem (); - -/* Remove some bytes from the stack. An rtx says how many. */ -void adjust_stack (); - -/* Add some bytes to the stack. An rtx says how many. */ -void anti_adjust_stack (); - -/* Emit code to copy function value to a new temp reg and return that reg. */ -rtx function_value (); - -/* Return an rtx that refers to the value returned by a function - in its original home. This becomes invalid if any more code is emitted. */ -rtx hard_function_value (); - -/* Return an rtx that refers to the value returned by a library call - in its original home. This becomes invalid if any more code is emitted. */ -rtx hard_libcall_value (); - -/* Emit code to copy function value to a specified place. */ -void copy_function_value (); - -/* Given an rtx, return an rtx for a value rounded up to a multiple - of STACK_BOUNDARY / BITS_PER_UNIT. */ -rtx round_push (); - -/* Push a block of length SIZE (perhaps variable) - and return an rtx to address the beginning of the block. */ -rtx push_block (); - -/* Generate code for computing expression EXP, - and storing the value into TARGET. - If SUGGEST_REG is nonzero, copy the value through a register - and return that register, if that is possible. */ -rtx store_expr (); - -rtx prepare_call_address (); -rtx expand_call (); -void emit_call_1 (); - -void emit_block_move (); -void emit_push_insn (); -void use_regs (); -void move_block_to_reg (); - -rtx store_bit_field (); -rtx extract_bit_field (); -rtx expand_shift (); -rtx expand_mult (); -rtx expand_divmod (); -rtx expand_mult_add (); -rtx get_structure_value_addr (); -rtx expand_stmt_expr (); -rtx emit_no_conflict_block (); - -void jumpifnot (); -void jumpif (); -void do_jump (); - -rtx assemble_static_space (); - -/* Needed for old compiler. */ -rtx expand_bit_and (); diff --git a/gnu/usr.bin/g++/cc1plus/flags.h b/gnu/usr.bin/g++/cc1plus/flags.h deleted file mode 100644 index 095c516002ea..000000000000 --- a/gnu/usr.bin/g++/cc1plus/flags.h +++ /dev/null @@ -1,212 +0,0 @@ -/* Compilation switch flag definitions for GNU CC. - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Name of the input .c file being compiled. */ -extern char *main_input_filename; - -/* 1 => write gdb debugging output (using symout.c). - 2 => write dbx debugging output (using dbxout.c). - 3 => write sdb debugging output (using sdbout.c). */ -enum debugger { NO_DEBUG = 0, GDB_DEBUG = 1, DBX_DEBUG = 2, SDB_DEBUG = 3, - EXTENDED_DBX_DEBUG = 4, LINENO_DEBUG }; - -extern enum debugger write_symbols; - -/* Nonzero means use GDB-only extensions of DBX format. */ -extern int use_gdb_dbx_extensions; - -/* Nonzero means do optimizations. -opt. */ - -extern int optimize; - -/* Nonzero means do stupid register allocation. -noreg. - Currently, this is 1 if `optimize' is 0. */ - -extern int obey_regdecls; - -/* Don't print functions as they are compiled and don't print - times taken by the various passes. -quiet. */ - -extern int quiet_flag; - -/* Don't print warning messages. -w. */ - -extern int inhibit_warnings; - -/* Do print extra warnings (such as for uninitialized variables). -W. */ - -extern int extra_warnings; - -/* Nonzero to warn about unused local variables. */ - -extern int warn_unused; - -/* Nonzero means warn about all declarations which shadow others. */ - -extern int warn_shadow; - -/* Warn if a switch on an enum fails to have a case for every enum value. */ - -extern int warn_switch; - -/* Warn if a type conversion is done that might have confusing results. */ - -extern int warn_conversion; - -/* Nonzero means warn about any identifiers that match in the first N - characters. The value N is in `id_clash_len'. */ - -extern int warn_id_clash; -extern int id_clash_len; - -/* Nonzero means warn if inline function is too large. */ - -extern int warn_inline; - -/* Nonzero if generating code to do profiling. */ - -extern int profile_flag; - -/* Nonzero if generating code to do profiling on the basis of basic blocks. */ - -extern int profile_block_flag; - -/* Nonzero for -pedantic switch: warn about anything - that standard C or C++ forbids. */ - -extern int pedantic; - -/* Now the symbols that are set with `-f' switches. */ - -/* Nonzero means `char' should be signed. */ - -extern int flag_signed_char; - -/* Nonzero means give an enum type only as many bytes as it needs. */ - -extern int flag_short_enums; - -/* Nonzero for -fcaller-saves: allocate values in regs that need to - be saved across function calls, if that produces overall better code. - Optional now, so people can test it. */ - -extern int flag_caller_saves; - -/* Nonzero for -fpcc-struct-return: return values the same way PCC does. */ - -extern int flag_pcc_struct_return; - -/* Nonzero for -fforce-mem: load memory value into a register - before arithmetic on it. This makes better cse but slower compilation. */ - -extern int flag_force_mem; - -/* Nonzero for -fforce-addr: load memory address into a register before - reference to memory. This makes better cse but slower compilation. */ - -extern int flag_force_addr; - -/* Nonzero for -fdefer-pop: don't pop args after each function call; - instead save them up to pop many calls' args with one insns. */ - -extern int flag_defer_pop; - -/* Nonzero for -ffloat-store: don't allocate floats and doubles - in extended-precision registers. */ - -extern int flag_float_store; - -/* Nonzero for -fcombine-regs: - allow instruction combiner to combine an insn - that just copies one reg to another. */ - -extern int flag_combine_regs; - -/* Nonzero enables strength-reduction in loop.c. */ - -extern int flag_strength_reduce; - -/* Nonzero for -fcse-follow-jumps: - have cse follow jumps to do a more extensive job. */ - -extern int flag_cse_follow_jumps; - -/* Nonzero for -fwritable-strings: - store string constants in data segment and don't uniquize them. */ - -extern int flag_writable_strings; - -/* Nonzero means don't put addresses of constant functions in registers. - Used for compiling the Unix kernel, where strange substitutions are - done on the assembly output. */ - -extern int flag_no_function_cse; - -/* Nonzero for -fomit-frame-pointer: - don't make a frame pointer in simple functions that don't require one. */ - -extern int flag_omit_frame_pointer; - -/* Nonzero to inhibit use of define_optimization peephole opts. */ - -extern int flag_no_peephole; - -/* Nonzero means all references through pointers are volatile. */ - -extern int flag_volatile; - -/* Nonzero means make functions that look like good inline candidates - go inline. */ - -extern int flag_inline_functions; - -/* Nonzero for -fkeep-inline-functions: even if we make a function - go inline everywhere, keep its defintion around for debugging - purposes. */ - -extern int flag_keep_inline_functions; - -/* Nonzero if we are only using compiler to check syntax errors. */ - -extern int flag_syntax_only; - -/* Nonzero means make the text shared if supported. */ - -extern int flag_shared_data; - -/* Nonzero means put things in delayed-branch slots if supported. */ - -extern int flag_delayed_branch; - -/* Nonzero means do basic-block instruction scheduling. */ - -extern int flag_schedule_insns; - -/* Other basic status info about current function. */ - -/* Nonzero means current function must be given a frame pointer. - Set in stmt.c if anything is allocated on the stack there. - Set in reload1.c if anything is allocated on the stack there. */ - -extern int frame_pointer_needed; - -/* Nonzero if function being compiled receives nonlocal gotos - from nested functions. */ - -extern int current_function_has_nonlocal_label; diff --git a/gnu/usr.bin/g++/cc1plus/gplus.gperf b/gnu/usr.bin/g++/cc1plus/gplus.gperf deleted file mode 100644 index 4a93315be52f..000000000000 --- a/gnu/usr.bin/g++/cc1plus/gplus.gperf +++ /dev/null @@ -1,76 +0,0 @@ -%{ -/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf */ -%} -struct resword { char *name; short token; enum rid rid;}; -%% -__alignof, ALIGNOF, NORID -__alignof__, ALIGNOF, NORID -__asm, ASM, NORID -__asm__, ASM, NORID -__attribute, ATTRIBUTE, NORID -__attribute__, ATTRIBUTE, NORID -__const, TYPE_QUAL, RID_CONST -__const__, TYPE_QUAL, RID_CONST -__inline, SCSPEC, RID_INLINE -__inline__, SCSPEC, RID_INLINE -__signed, TYPESPEC, RID_SIGNED -__signed__, TYPESPEC, RID_SIGNED -__typeof, TYPEOF, NORID -__typeof__, TYPEOF, NORID -__volatile, TYPE_QUAL, RID_VOLATILE -__volatile__, TYPE_QUAL, RID_VOLATILE -all, ALL, NORID /* Extension */, -except, EXCEPT, NORID /* Extension */, -exception, AGGR, RID_EXCEPTION /* Extension */, -raise, RAISE, NORID /* Extension */, -raises, RAISES, NORID /* Extension */, -reraise, RERAISE, NORID /* Extension */, -try, TRY, NORID /* Extension */, -asm, ASM, NORID, -auto, SCSPEC, RID_AUTO, -break, BREAK, NORID, -case, CASE, NORID, -catch, CATCH, NORID, -char, TYPESPEC, RID_CHAR, -class, AGGR, RID_CLASS, -const, TYPE_QUAL, RID_CONST, -continue, CONTINUE, NORID, -default, DEFAULT, NORID, -delete, DELETE, NORID, -do, DO, NORID, -double, TYPESPEC, RID_DOUBLE, -dynamic, DYNAMIC, NORID, -else, ELSE, NORID, -enum, ENUM, NORID, -extern, SCSPEC, RID_EXTERN, -float, TYPESPEC, RID_FLOAT, -for, FOR, NORID, -friend, SCSPEC, RID_FRIEND, -goto, GOTO, NORID, -if, IF, NORID, -inline, SCSPEC, RID_INLINE, -int, TYPESPEC, RID_INT, -long, TYPESPEC, RID_LONG, -new, NEW, NORID, -operator, OPERATOR, NORID, -overload, OVERLOAD, NORID, -private, PRIVATE, NORID, -protected, PROTECTED, NORID, -public, PUBLIC, NORID, -register, SCSPEC, RID_REGISTER, -return, RETURN, NORID, -short, TYPESPEC, RID_SHORT, -signed, TYPESPEC, RID_SIGNED, -sizeof, SIZEOF, NORID, -static, SCSPEC, RID_STATIC, -struct, AGGR, RID_RECORD, -switch, SWITCH, NORID, -this, THIS, NORID, -typedef, SCSPEC, RID_TYPEDEF, -typeof, TYPEOF, NORID, -union, AGGR, RID_UNION, -unsigned, TYPESPEC, RID_UNSIGNED, -virtual, SCSPEC, RID_VIRTUAL, -void, TYPESPEC, RID_VOID, -volatile, TYPE_QUAL, RID_VOLATILE, -while, WHILE, NORID, diff --git a/gnu/usr.bin/g++/cc1plus/input.h b/gnu/usr.bin/g++/cc1plus/input.h deleted file mode 100644 index 270f267750a0..000000000000 --- a/gnu/usr.bin/g++/cc1plus/input.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Source file current line is coming from. */ -extern char *input_filename; - -/* Top-level source file. */ -extern char *main_input_filename; - -/* Line number in current source file. */ -extern int lineno; - -struct file_stack - { - char *name; - struct file_stack *next; - int line; - }; - -/* Stack of currently pending input files. - The line member is not accurate for the innermost file on the stack. */ -extern struct file_stack *input_file_stack; - -/* Incremented on each change to input_file_stack. */ -extern int input_file_stack_tick; diff --git a/gnu/usr.bin/g++/cc1plus/integrate.c b/gnu/usr.bin/g++/cc1plus/integrate.c deleted file mode 100644 index 9d99a911cbe3..000000000000 --- a/gnu/usr.bin/g++/cc1plus/integrate.c +++ /dev/null @@ -1,2793 +0,0 @@ -/* Procedure integration for GNU CC. - Copyright (C) 1988 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@mcc.com) - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include - -#include "config.h" -#include "rtl.h" -#include "tree.h" -#include "flags.h" -#include "insn-flags.h" -#include "expr.h" - -#include "obstack.h" -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free -extern int xmalloc (); -extern void free (); - -extern struct obstack permanent_obstack, maybepermanent_obstack; -extern struct obstack *rtl_obstack, *saveable_obstack, *current_obstack; - -extern rtx stack_slot_list; - -#define MIN(x,y) ((x < y) ? x : y) - -extern tree pushdecl (); -extern tree poplevel (); - -/* Default max number of insns a function can have and still be inline. - This is overridden on RISC machines. */ -#ifndef INTEGRATE_THRESHOLD -#define INTEGRATE_THRESHOLD(DECL) \ - (8 * (8 + list_length (DECL_ARGUMENTS (DECL)) + 16*TREE_INLINE (DECL))) -#endif - -/* This is the target of the inline function being expanded, - or NULL if there is none. */ -static rtx inline_target; - -/* We must take special care not to disrupt life too severely - when performing procedure integration. One thing that that - involves is not creating illegitimate address which reload - cannot fix. Since we don't know what the frame pointer is - not capable of (in a machine independent way), we create - a pseudo-frame pointer which will have to do for now. */ -static rtx before_inline_fp_rtx, inline_fp_rtx; - -/* Convert old frame-pointer offsets to new. Parameters which only - produce values (no addresses, and are never assigned), map directly - to the pseudo-reg of the incoming value. Parameters that are - assigned to but do not have their address taken are given a fresh - pseudo-register. Parameters that have their address take are - given a fresh stack-slot. */ -static rtx *parm_map; - -/* ?? Should this be done here?? It is not right now. - Keep track of whether a given pseudo-register is the sum - of the frame pointer and a const_int (or zero). */ -static char *fp_addr_p; - -/* For the local variables of the procdure being integrated that live - on the frame, FRAME_POINTER_DELTA says how much to change their - offsets by, so that they now live in the correct place on the - frame of the function being compiled. */ -static int fp_delta; - -/* When an insn is being copied by copy_rtx_and_substitute, - this is nonzero if we have copied an ASM_OPERANDS. - In that case, it is the original input-operand vector. - Likewise in copy_for_inline. */ -static rtvec orig_asm_operands_vector; - -/* When an insn is being copied by copy_rtx_and_substitute, - this is nonzero if we have copied an ASM_OPERANDS. - In that case, it is the copied input-operand vector. - Likewise in copy_for_inline. */ -static rtvec copy_asm_operands_vector; - -/* Likewise, this is the copied constraints vector. */ -static rtvec copy_asm_constraints_vector; - -/* In save_for_inline, nonzero if past the parm-initialization insns. */ -static int in_nonparm_insns; - -/* Return a copy of an rtx (as needed), substituting pseudo-register, - labels, and frame-pointer offsets as necessary. */ -static rtx copy_rtx_and_substitute (); -/* Variant, used for memory addresses that are not memory_address_p. */ -static rtx copy_address (); - -/* Return the rtx corresponding to a given index in the stack arguments. */ -static rtx access_parm_map (); - -static void copy_parm_decls (); -static void copy_decl_tree (); - -static rtx try_fold_cc0 (); - -/* We do some simple constant folding optimization. This optimization - really exists primarily to save time inlining a function. It - also helps users who ask for inline functions without -O. */ -static rtx fold_out_const_cc0 (); - -/* Zero if the current function (whose FUNCTION_DECL is FNDECL) - is safe and reasonable to integrate into other functions. - Nonzero means value is a warning message with a single %s - for the function's name. */ - -char * -function_cannot_inline_p (fndecl) - register tree fndecl; -{ - register rtx insn; - tree last = tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl))); - int max_insns = INTEGRATE_THRESHOLD (fndecl); - register int ninsns = 0; - register tree parms; - - /* No inlines with varargs. `grokdeclarator' gives a warning - message about that if `inline' is specified. This code - it put in to catch the volunteers. */ - if (last && TREE_VALUE (last) != void_type_node) - return "varargs function cannot be inline"; - - /* If its not even close, don't even look. */ - if (get_max_uid () > 4 * max_insns) - return "function too large to be inline"; - - /* Don't inline functions with large stack usage, - since they can make other recursive functions burn up stack. */ - if (!TREE_INLINE (fndecl) && get_frame_size () > 100) - return "function stack frame for inlining"; - - /* We can't inline functions that return structures - the old-fashioned PCC way, copying into a static block. */ -#ifdef PCC_STATIC_STRUCT_RETURN - if (flag_pcc_struct_return - && (TYPE_MODE (TREE_TYPE (TREE_TYPE (fndecl))) == BLKmode - || RETURN_IN_MEMORY (TREE_TYPE (TREE_TYPE (fndecl))))) - return "inline functions not supported for this return value type"; -#endif - - /* Don't inline functions which have BLKmode arguments. - Don't inline functions that take the address of - a parameter and do not specify a function prototype. */ - for (parms = DECL_ARGUMENTS (fndecl); parms; parms = TREE_CHAIN (parms)) - { - if (TYPE_MODE (TREE_TYPE (parms)) == BLKmode) - { -#if 0 - return "function with large aggregate parameter cannot be inline"; -#else - TREE_ADDRESSABLE (parms) = 1; -#endif - } - if (last == NULL_TREE && TREE_ADDRESSABLE (parms)) - return "no prototype, and parameter address used; cannot be inline"; -#if 0 - /* If an aggregate is thought of as "in memory" - then its components are referred to by narrower memory refs. - If the actual parameter is a reg, these refs can't be translated, - esp. since copy_rtx_and_substitute doesn't know whether it is - reading or writing. */ - if ((TREE_CODE (TREE_TYPE (parms)) == RECORD_TYPE - || TREE_CODE (TREE_TYPE (parms)) == UNION_TYPE) - && GET_CODE (DECL_RTL (parms)) == MEM) - return "address of an aggregate parameter is used; cannot be inline"; -#endif - } - - if (get_max_uid () > max_insns) - { - for (ninsns = 0, insn = get_first_nonparm_insn (); insn && ninsns < max_insns; - insn = NEXT_INSN (insn)) - { - if (GET_CODE (insn) == INSN - || GET_CODE (insn) == JUMP_INSN - || GET_CODE (insn) == CALL_INSN) - ninsns++; - } - - if (ninsns >= max_insns) - return "function too large to be inline"; - } - - return 0; -} - -/* Variables used within save_for_inline. */ - -/* Mapping from old pesudo-register to new pseudo-registers. - The first element of this map is reg_map[FIRST_PSEUDO_REGISTER]. - It is allocated in `save_for_inline' and `expand_inline_function', - and deallocated on exit from each of those routines. */ -static rtx *reg_map; - -/* Mapping from old code-labels to new code-labels. - The first element of this map is label_map[min_labelno]. - It is allocated in `save_for_inline' and `expand_inline_function', - and deallocated on exit from each of those routines. */ -static rtx *label_map; - -/* Mapping from old insn uid's to copied insns. - It is allocated in `save_for_inline' and `expand_inline_function', - and deallocated on exit from each of those routines. */ -static rtx *insn_map; - -/* Map pseudo reg number into the PARM_DECL for the parm living in the reg. - Zero for a reg that isn't a parm's home. - Only reg numbers less than max_parm_reg are mapped here. */ -static tree *parmdecl_map; - -/* Map pseudo reg number to equivalent constant. We cannot in general - substitute constants into parameter pseudo registers, since a - machine descriptions (the Sparc md, maybe others) won't always handle - the resulting insns. So if an incoming parameter has a constant - equivalent, we record it here, and if the resulting insn is - recognizable, we go with it. */ -static rtx *const_equiv_map; - -/* Nonzero if we should try using a constant equivalent. - Set to zero if constant equivalent resulted in insn which could - not be recognized. */ -static int try_use_const; - -/* Use "iteration numbering" to speedily pull constant values - from registers when testing conditionals. */ -static unsigned int *const_age_map, const_age; - -/* Cleared before attempting to inline any functions. - Set when const equiv is used. Used to test whether insn - is safe for md or not. */ -static int used_const_equiv; - -/* Keep track of first pseudo-register beyond those that are parms. */ -static int max_parm_reg; - -/* Offset from arg ptr to the first parm of this inline function. */ -static int first_parm_offset; - -/* On machines that perform a function return with a single - instruction, such as the VAX, these return insns must be - mapped into branch statements. */ -extern rtx return_label; - -/* Save any constant pool constants in an insn. */ -static void save_constants (); - -/* Note when parameter registers are the destination of a SET. */ -static void note_modified_parmregs (); - -/* Copy an rtx for save_for_inline. */ -static rtx copy_for_inline (); - -/* Make the insns and PARM_DECLs of the current function permanent - and record other information in DECL_SAVED_INSNS to allow inlining - of this function in subsequent calls. */ - -void -save_for_inline (fndecl) - tree fndecl; -{ - extern rtx *regno_reg_rtx; /* in emit-rtl.c. */ - extern current_function_args_size; - - rtx first_insn, last_insn, insn; - rtx head, copy; - tree parms; - int max_labelno, min_labelno, i, len; - int max_reg; - int max_uid; - rtx first_nonparm_insn; - - /* Make and emit a return-label if we have not already done so. */ - - if (return_label == 0) - { - return_label = gen_label_rtx (); - emit_label (return_label); - } - - /* Get some bounds on the labels and registers used. */ - - max_labelno = max_label_num (); - min_labelno = get_first_label_num (); - max_parm_reg = max_parm_reg_num (); - max_reg = max_reg_num (); - - /* Set up PARMDECL_MAP which maps pseudo-reg number to its PARM_DECL. - - Set TREE_VOLATILE to 0 if the parm is in a register, otherwise 1. - Later we set TREE_READONLY to 0 if the parm is modified inside the fn. */ - - parmdecl_map = (tree *) alloca (max_parm_reg * sizeof (tree)); - bzero (parmdecl_map, max_parm_reg * sizeof (tree)); - - for (parms = DECL_ARGUMENTS (fndecl); parms; parms = TREE_CHAIN (parms)) - { - rtx p = DECL_RTL (parms); - - if (GET_CODE (p) == REG) - { - parmdecl_map[REGNO (p)] = parms; - TREE_VOLATILE (parms) = 0; - } - else - TREE_VOLATILE (parms) = 1; - TREE_READONLY (parms) = 1; - } - - /* Replace any constant pool references with the actual constant. We will - put the constant back in the copy made below. */ - for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) - if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN - || GET_CODE (insn) == CALL_INSN) - save_constants (PATTERN (insn)); - - /* The list of DECL_SAVED_INSNS, starts off with a header which - contains the following information: - - the first insn of the function (not including the insns that copy - parameters into registers). - the first parameter insn of the function, - the first label used by that function, - the last label used by that function, - the highest register number used for parameters, - the total number of registers used, - the stack slot list, - @@ not yet: and some flags that are used to restore compiler globals. */ - - head = gen_inline_header_rtx (NULL, NULL, min_labelno, max_labelno, - max_parm_reg, max_reg, - current_function_args_size, stack_slot_list); - max_uid = INSN_UID (head); - - /* We have now allocated all that needs to be allocated permanently - on the rtx obstack. Set our high-water mark, so that we - can free the rest of this when the time comes. */ - - preserve_data (); - - /* Copy the chain insns of this function. - Install the copied chain as the insns of this function, - for continued compilation; - the original chain is recorded as the DECL_SAVED_INSNS - for inlining future calls. */ - - /* If there are insns that copy parms from the stack into pseudo registers, - those insns are not copied. `expand_inline_function' must - emit the correct code to handle such things. */ - - insn = get_insns (); - if (GET_CODE (insn) != NOTE) - abort (); - first_insn = rtx_alloc (NOTE); - NOTE_SOURCE_FILE (first_insn) = NOTE_SOURCE_FILE (insn); - NOTE_LINE_NUMBER (first_insn) = NOTE_LINE_NUMBER (insn); - INSN_UID (first_insn) = INSN_UID (insn); - PREV_INSN (first_insn) = NULL; - NEXT_INSN (first_insn) = NULL; - last_insn = first_insn; - - /* Each pseudo-reg in the old insn chain must have a unique rtx in the copy. - Make these new rtx's now, and install them in regno_reg_rtx, so they - will be the official pseudo-reg rtx's for the rest of compilation. */ - - reg_map = (rtx *) alloca ((max_reg + 1) * sizeof (rtx)); - - len = sizeof (struct rtx_def) + (GET_RTX_LENGTH (REG) - 1) * sizeof (rtunion); - for (i = max_reg - 1; i >= FIRST_PSEUDO_REGISTER; i--) - reg_map[i] = (rtx)obstack_copy (&maybepermanent_obstack, regno_reg_rtx[i], len); - bcopy (reg_map + FIRST_PSEUDO_REGISTER, - regno_reg_rtx + FIRST_PSEUDO_REGISTER, - (max_reg - FIRST_PSEUDO_REGISTER) * sizeof (rtx)); - - /* Likewise each label rtx must have a unique rtx as its copy. */ - - label_map = (rtx *)alloca ((max_labelno - min_labelno) * sizeof (rtx)); - label_map -= min_labelno; - - for (i = min_labelno; i < max_labelno; i++) - label_map[i] = gen_label_rtx (); - - /* Record the mapping of old insns to copied insns. */ - - insn_map = (rtx *) alloca (max_uid * sizeof (rtx)); - bzero (insn_map, max_uid * sizeof (rtx)); - - in_nonparm_insns = 0; - first_nonparm_insn = get_first_nonparm_insn (); - - /* Now copy the chain of insns. */ - - for (insn = NEXT_INSN (insn); insn; insn = NEXT_INSN (insn)) - { - orig_asm_operands_vector = 0; - copy_asm_operands_vector = 0; - - if (insn == first_nonparm_insn) - in_nonparm_insns = 1; - - switch (GET_CODE (insn)) - { - case NOTE: - /* No need to keep these. */ - if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED) - continue; - - copy = rtx_alloc (NOTE); - NOTE_SOURCE_FILE (copy) = NOTE_SOURCE_FILE (insn); - NOTE_LINE_NUMBER (copy) = NOTE_LINE_NUMBER (insn); - break; - - case INSN: - case CALL_INSN: - case JUMP_INSN: - copy = rtx_alloc (GET_CODE (insn)); - PATTERN (copy) = copy_for_inline (PATTERN (insn)); - INSN_CODE (copy) = -1; - LOG_LINKS (copy) = NULL; - REG_NOTES (copy) = copy_for_inline (REG_NOTES (insn)); - RTX_INTEGRATED_P (copy) = RTX_INTEGRATED_P (insn); - break; - - case CODE_LABEL: - copy = label_map[CODE_LABEL_NUMBER (insn)]; - break; - - case BARRIER: - copy = rtx_alloc (BARRIER); - break; - - default: - abort (); - } - INSN_UID (copy) = INSN_UID (insn); - insn_map[INSN_UID (insn)] = copy; - NEXT_INSN (last_insn) = copy; - PREV_INSN (copy) = last_insn; - last_insn = copy; - } - - NEXT_INSN (last_insn) = NULL; - - NEXT_INSN (head) = get_first_nonparm_insn (); - FIRST_PARM_INSN (head) = get_insns (); - DECL_SAVED_INSNS (fndecl) = head; - DECL_FRAME_SIZE (fndecl) = get_frame_size (); - TREE_INLINE (fndecl) = 1; - - parmdecl_map = 0; - label_map = 0; - reg_map = 0; - return_label = 0; - - set_new_first_and_last_insn (first_insn, last_insn); - - /* The following code does not need preprocessing in the assembler. */ - - app_disable (); - - output_constant_pool (XSTR (XEXP (DECL_RTL (fndecl), 0), 0), fndecl); -} - -/* Make the insns and PARM_DECLs of the current function permanent - and record other information in DECL_SAVED_INSNS to allow inlining - of this function in subsequent calls. - - Other version. */ - -void -save_for_outline (fndecl) - tree fndecl; -{ - extern rtx *regno_reg_rtx; /* in emit-rtl.c. */ - extern current_function_args_size; - - rtx first_insn, last_insn, insn; - rtx head, copy; - tree parms; - int max_labelno, min_labelno, i, len; - int max_reg; - int max_uid; - rtx first_nonparm_insn; - - /* Make and emit a return-label if we have not already done so. */ - - if (return_label == 0) - { - return_label = gen_label_rtx (); - emit_label (return_label); - } - - /* Get some bounds on the labels and registers used. */ - - max_labelno = max_label_num (); - min_labelno = get_first_label_num (); - max_parm_reg = max_parm_reg_num (); - max_reg = max_reg_num (); - - /* Set up PARMDECL_MAP which maps pseudo-reg number to its PARM_DECL. - - Set TREE_VOLATILE to 0 if the parm is in a register, otherwise 1. - Later we set TREE_READONLY to 0 if the parm is modified inside the fn. */ - - parmdecl_map = (tree *) alloca (max_parm_reg * sizeof (tree)); - bzero (parmdecl_map, max_parm_reg * sizeof (tree)); - - for (parms = DECL_ARGUMENTS (fndecl); parms; parms = TREE_CHAIN (parms)) - { - rtx p = DECL_RTL (parms); - - if (GET_CODE (p) == REG) - { - parmdecl_map[REGNO (p)] = parms; - TREE_VOLATILE (parms) = 0; - } - else - TREE_VOLATILE (parms) = 1; - TREE_READONLY (parms) = 1; - } - - /* The list of DECL_SAVED_INSNS, starts off with a header which - contains the following information: - - the first insn of the function (not including the insns that copy - parameters into registers). - the first parameter insn of the function, - the first label used by that function, - the last label used by that function, - the highest register number used for parameters, - the total number of registers used, - the stack slot list, - @@ not yet: and some flags that are used to restore compiler globals. */ - - head = gen_inline_header_rtx (NULL, NULL, min_labelno, max_labelno, - max_parm_reg, max_reg, - current_function_args_size, stack_slot_list); - /* We have now allocated all that needs to be allocated permanently - on the rtx obstack. Set our high-water mark, so that we - can free the rest of this when the time comes. */ - - preserve_data (); - - /* Copy the chain insns of this function. - Install the copied chain as the insns of this function, - for continued compilation; - the original chain is recorded as the DECL_SAVED_INSNS - for inlining future calls. */ - - /* If there are insns that copy parms from the stack into pseudo registers, - those insns are not copied. `expand_inline_function' must - emit the correct code to handle such things. */ - - insn = get_insns (); - if (GET_CODE (insn) != NOTE) - abort (); - first_insn = rtx_alloc (NOTE); - NOTE_SOURCE_FILE (first_insn) = NOTE_SOURCE_FILE (insn); - NOTE_LINE_NUMBER (first_insn) = NOTE_LINE_NUMBER (insn); - INSN_UID (first_insn) = INSN_UID (insn); - PREV_INSN (first_insn) = NULL; - NEXT_INSN (first_insn) = NULL; - last_insn = first_insn; - - in_nonparm_insns = 0; - first_nonparm_insn = get_first_nonparm_insn (); - - /* Now copy the chain of insns. */ - - for (insn = NEXT_INSN (insn); insn; insn = NEXT_INSN (insn)) - { - orig_asm_operands_vector = 0; - copy_asm_operands_vector = 0; - - if (insn == first_nonparm_insn) - in_nonparm_insns = 1; - - switch (GET_CODE (insn)) - { - case INSN: - case CALL_INSN: - case JUMP_INSN: - note_modified_parmregs (PATTERN (insn)); - break; - - case NOTE: - case CODE_LABEL: - case BARRIER: - break; - - default: - abort (); - } - last_insn = insn; - } - - NEXT_INSN (head) = get_first_nonparm_insn (); - FIRST_PARM_INSN (head) = get_insns (); - DECL_SAVED_INSNS (fndecl) = head; - DECL_FRAME_SIZE (fndecl) = get_frame_size (); - TREE_INLINE (fndecl) = 1; - - /* Have to output these, since other functions may refer to them. */ - - /* The following code does not need preprocessing in the assembler. */ - - app_disable (); - - output_constant_pool (XSTR (XEXP (DECL_RTL (fndecl), 0), 0), fndecl); -} - -/* References to the constant pool are replaced by the actual constant - encapsulated with a CONST giving the mode and with RTX_INTEGRATED_P set. - - *** Note that the above only works if the address was not manipulated. - If the address was not valid and had to be loaded into a register, - we lose track of the fact that it was in the constant pool, which will - result in either an abort or generating a reference to an undefined - label in the assembler code. No current machine will run into this, but - this should probably be fixed someday. */ - -static void -save_constants (x) - rtx x; -{ - int i, j; - char *fmt = GET_RTX_FORMAT (GET_CODE (x)); - - for (i = 0; i < GET_RTX_LENGTH (GET_CODE (x)); i++) - { - switch (*fmt++) - { - case 'E': - for (j = 0; j < XVECLEN (x, i); j++) - if (GET_CODE (XVECEXP (x, i, j)) == MEM - && GET_CODE (XEXP (XVECEXP (x, i, j), 0)) == SYMBOL_REF - && CONSTANT_POOL_ADDRESS_P (XEXP (XVECEXP (x, i, j), 0))) - { - XVECEXP (x, i, j) = - gen_rtx (CONST, get_pool_mode (XEXP (XVECEXP (x, i, j), 0)), - get_pool_constant (XEXP (XVECEXP (x, i, j), 0))); - RTX_INTEGRATED_P (XVECEXP (x, i, j)) = 1; - } - else - save_constants (XVECEXP (x, i, j)); - break; - - case 'e': - if (GET_CODE (XEXP (x, i)) == MEM - && GET_CODE (XEXP (XEXP (x, i), 0)) == SYMBOL_REF - && CONSTANT_POOL_ADDRESS_P (XEXP (XEXP (x, i), 0))) - { - XEXP (x, i) = gen_rtx (CONST, - get_pool_mode (XEXP (XEXP (x, i), 0)), - get_pool_constant (XEXP (XEXP (x, i), 0))); - RTX_INTEGRATED_P (XEXP (x, i)) = 1; - } - else - save_constants (XEXP (x, i)); - break; - } - } -} - -/* Note (recursively) whether a parameter is modified or not. */ - -static void -note_modified_parmregs (orig) - rtx orig; -{ - register rtx x = orig; - register int i, len; - register enum rtx_code code; - register char *format_ptr; - - again: - - if (x == 0) - return; - - code = GET_CODE (x); - - /* These types may be freely shared. */ - - if (code == SET && in_nonparm_insns) - { - rtx dest = SET_DEST (x); - - if (GET_CODE (dest) == REG - && REGNO (dest) < max_parm_reg - && REGNO (dest) >= FIRST_PSEUDO_REGISTER - && parmdecl_map[REGNO (dest)] != 0) - TREE_READONLY (parmdecl_map[REGNO (dest)]) = 0; - return; - } - - /* Now scan the subexpressions recursively. */ - - format_ptr = GET_RTX_FORMAT (code); - len = GET_RTX_LENGTH (code); - - if (len > 2) - for (i = len-1; i > 1; i--) - if (format_ptr[i] == 'e') - note_modified_parmregs (XEXP (x, 2)); - else if (format_ptr[i] == 'E') - goto hard; - - if (len > 1) - if (format_ptr[1] == 'e') - note_modified_parmregs (XEXP (x, 1)); - else if (format_ptr[i=1] == 'E') - goto hard; - - if (len > 0) - if (format_ptr[0] == 'e') - { - x = XEXP (x, 0); - goto again; - } - else if (format_ptr[i=0] == 'E') - goto hard; - - return; - - i = len-1; - - hard: - - while (i >= 0) - { - switch (format_ptr[i]) - { - case 'e': - if (i == 0) - { - x = XEXP (x, 0); - goto again; - } - note_modified_parmregs (XEXP (x, i)); - break; - - case 'E': - if (XVEC (x, i) != NULL && XVECLEN (x, i) != 0) - { - register int j; - - for (j = 0; j < XVECLEN (x, i); j++) - note_modified_parmregs (XVECEXP (x, i, j)); - } - break; - } - i -= 1; - } -} - -/* Copy the rtx ORIG recursively, replacing pseudo-regs and labels - according to `reg_map' and `label_map'. - - If we find a saved constant pool entry, replace it with the constant. - Since the pool wasn't touched, this should simply restore the old - address. - - All other kinds of rtx are copied except those that can never be - changed during compilation. */ - -static rtx -copy_for_inline (orig) - rtx orig; -{ - register rtx x = orig; - register int i; - register enum rtx_code code; - register char *format_ptr; - - if (x == 0) - return x; - - code = GET_CODE (x); - - /* These types may be freely shared. */ - - switch (code) - { - case QUEUED: - case CONST_INT: - case CONST_DOUBLE: - case SYMBOL_REF: - case PC: - case CC0: - return x; - - case CONST: - /* Get constant pool entry for constant in the pool. */ - if (RTX_INTEGRATED_P (x)) - return force_const_mem (GET_MODE (x), XEXP (x, 0)); - break; - - case ASM_OPERANDS: - /* If a single asm insn contains multiple output operands - then it contains multiple ASM_OPERANDS rtx's that share operand 3. - We must make sure that the copied insn continues to share it. */ - if (orig_asm_operands_vector == XVEC (orig, 3)) - { - x = rtx_alloc (ASM_OPERANDS); - XSTR (x, 0) = XSTR (orig, 0); - XSTR (x, 1) = XSTR (orig, 1); - XINT (x, 2) = XINT (orig, 2); - XVEC (x, 3) = copy_asm_operands_vector; - XVEC (x, 4) = copy_asm_constraints_vector; - XSTR (x, 5) = XSTR (orig, 5); - XINT (x, 6) = XINT (orig, 6); - return x; - } - break; - - case MEM: - /* A MEM is allowed to be shared if its address is constant - or is a constant plus one of the special registers. */ - if (CONSTANT_ADDRESS_P (XEXP (x, 0))) - return x; -#if 0 /* This is turned off because it is possible for - unshare_all_rtl to copy the address, into memory that won't be saved. - Although the MEM can safely be shared, and won't be copied there, - the address itself cannot be shared, and may need to be copied. */ - if (GET_CODE (XEXP (x, 0)) == PLUS - && GET_CODE (XEXP (XEXP (x, 0), 0)) == REG - && (REGNO (XEXP (XEXP (x, 0), 0)) == FRAME_POINTER_REGNUM - || REGNO (XEXP (XEXP (x, 0), 0)) == ARG_POINTER_REGNUM) - && CONSTANT_ADDRESS_P (XEXP (XEXP (x, 0), 1))) -#if 0 - /* This statement was accidentally deleted in the remote past. - Reinsert it for 1.37. Don't take the risk now. */ - return x; -#endif - if (GET_CODE (XEXP (x, 0)) == REG - && (REGNO (XEXP (x, 0)) == FRAME_POINTER_REGNUM - || REGNO (XEXP (x, 0)) == ARG_POINTER_REGNUM) - && CONSTANT_ADDRESS_P (XEXP (x, 1))) - return x; -#endif /* 0 */ - break; - - case LABEL_REF: - { - /* Must point to the new insn. */ - return gen_rtx (LABEL_REF, GET_MODE (orig), - label_map[CODE_LABEL_NUMBER (XEXP (orig, 0))]); - } - - case REG: - if (REGNO (x) >= FIRST_PSEUDO_REGISTER) - return reg_map [REGNO (x)]; - else - return x; - - /* If a parm that gets modified lives in a pseudo-reg, - set its TREE_VOLATILE to prevent certain optimizations. */ - case SET: - if (in_nonparm_insns) - { - rtx dest = SET_DEST (x); - - if (GET_CODE (dest) == REG - && REGNO (dest) < max_parm_reg - && REGNO (dest) >= FIRST_PSEUDO_REGISTER - && parmdecl_map[REGNO (dest)] != 0) - TREE_READONLY (parmdecl_map[REGNO (dest)]) = 0; - } - /* The insn to load an arg pseudo from a stack slot - does not count as modifying it. */ - break; - - /* Arrange that CONST_INTs always appear as the second operand - if they appear, and that `frame_pointer_rtx' or `arg_pointer_rtx' - always appear as the first. */ - case PLUS: - if (GET_CODE (XEXP (x, 0)) == CONST_INT - || (XEXP (x, 1) == frame_pointer_rtx - || (ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM - && XEXP (x, 1) == arg_pointer_rtx))) - { - rtx t = XEXP (x, 0); - XEXP (x, 0) = XEXP (x, 1); - XEXP (x, 1) = t; - } - break; - } - - /* Replace this rtx with a copy of itself. */ - - x = rtx_alloc (code); - bcopy (orig, x, (sizeof (*x) - sizeof (x->fld) - + sizeof (x->fld[0]) * GET_RTX_LENGTH (code))); - - /* Now scan the subexpressions recursively. - We can store any replaced subexpressions directly into X - since we know X is not shared! Any vectors in X - must be copied if X was copied. */ - - format_ptr = GET_RTX_FORMAT (code); - - for (i = 0; i < GET_RTX_LENGTH (code); i++) - { - switch (*format_ptr++) - { - case 'e': - XEXP (x, i) = copy_for_inline (XEXP (x, i)); - break; - - case 'u': - /* Change any references to old-insns to point to the - corresponding copied insns. */ - return insn_map[INSN_UID (XEXP (x, i))]; - - case 'E': - if (XVEC (x, i) != NULL && XVECLEN (x, i) != 0) - { - register int j; - - XVEC (x, i) = gen_rtvec_v (XVECLEN (x, i), &XVECEXP (x, i, 0)); - for (j = 0; j < XVECLEN (x, i); j++) - XVECEXP (x, i, j) - = copy_for_inline (XVECEXP (x, i, j)); - } - break; - } - } - - if (code == ASM_OPERANDS && orig_asm_operands_vector == 0) - { - orig_asm_operands_vector = XVEC (orig, 3); - copy_asm_operands_vector = XVEC (x, 3); - copy_asm_constraints_vector = XVEC (x, 4); - } - - return x; -} - -/* Helper function to deal with using constants for kinds of INSNs. - Return zero if trouble arose by using constants. - Return one if not. Caller must know what to do in either case. */ -static int -note_integrated (copy) - rtx copy; -{ - if (used_const_equiv) - { - used_const_equiv = 0; - if (recog (PATTERN (copy), copy) < 0) - { - int old_optimize = optimize; - optimize = 1; - delete_insn (copy); - optimize = old_optimize; - try_use_const = 0; - return 0; - } - } - try_use_const = 1; - RTX_INTEGRATED_P (copy) = 1; - return 1; -} - - -/* Non-zero if we are trying to reduce the amount of debug information output */ -extern int flag_inline_debug; - -/* Integrate the procedure defined by FNDECL. Note that this function - may wind up calling itself. Since the static variables are not - reentrant, we do not assign them until after the possibility - or recursion is eliminated. - - If IGNORE is nonzero, do not produce a value. - Otherwise store the value in TARGET if it is nonzero and that is convenient. - - Value is: - (rtx)-1 if we could not substitute the function - 0 if we substituted it and it does not produce a value - else an rtx for where the value is stored. */ - -rtx -expand_inline_function (fndecl, parms, target, ignore, type, structure_value_addr) - tree fndecl, parms; - rtx target; - int ignore; - tree type; - rtx structure_value_addr; -{ - extern int lineno; - tree formal, actual; - rtx header = DECL_SAVED_INSNS (fndecl); - rtx insns = FIRST_FUNCTION_INSN (header); - rtx insn; - int max_regno = MAX_REGNUM (header) + 1; - register int i; - int min_labelno = FIRST_LABELNO (header); - int max_labelno = LAST_LABELNO (header); - int nargs; - rtx *arg_vec; - rtx local_return_label = 0; - rtx follows_call = 0; - rtx this_struct_value_rtx = 0; - - /* Hack around non-reentrancy of static variables. */ - rtx *old_const_equiv_map = const_equiv_map; - unsigned *old_const_age_map = const_age_map; - unsigned old_const_age = const_age; - - /* If we need INLINE_FP_RTX, set it up immediately - following this insn. */ - - if (max_regno < FIRST_PSEUDO_REGISTER) - abort (); - - nargs = list_length (DECL_ARGUMENTS (fndecl)); - - /* We expect PARMS to have the right length; don't crash if not. */ - if (list_length (parms) != nargs) - return (rtx)-1; - - /* Also check that the parms type match. Since the appropriate - conversions or default promotions have already been applied, - the machine modes should match exactly. */ - for (formal = DECL_ARGUMENTS (fndecl), - actual = parms; - formal; - formal = TREE_CHAIN (formal), - actual = TREE_CHAIN (actual)) - { - tree arg = TREE_VALUE (actual); - enum machine_mode mode = TYPE_MODE (DECL_ARG_TYPE (formal)); - if (mode != TYPE_MODE (TREE_TYPE (arg))) - return (rtx)-1; - /* If they are block mode, the types should match exactly. - They don't match exactly if TREE_TYPE (FORMAL) == ERROR_MARK_NODE, - which could happen if the parameter has incomplete type. */ - if (mode == BLKmode && TREE_TYPE (arg) != TREE_TYPE (formal)) - return (rtx)-1; - } - - const_equiv_map = (rtx *)alloca (max_regno * sizeof (rtx)); - bzero (const_equiv_map, max_regno * sizeof (rtx)); - const_age_map = (unsigned *)alloca (max_regno * sizeof (unsigned)); - bzero (const_age_map, max_regno * sizeof (unsigned)); - try_use_const = 1; - /* Trick: set to large number so that variables set in first - basic block keep their values. After first label is seen, - we wrap. */ - const_age = (unsigned)-1; - - /* Make a binding contour to keep inline cleanups called at - outer function-scope level from looking like they are shadowing - parameter declarations. */ - pushlevel (0); - - /* Make a fresh binding contour that we can easily remove. */ - pushlevel (0); - expand_start_bindings (0); - - /* Get all the actual args as RTL, and store them in ARG_VEC. */ - - arg_vec = (rtx *)alloca (nargs * sizeof (rtx)); - - if (flag_inline_debug) - /* Say where this function starts. */ - emit_note (DECL_SOURCE_FILE (fndecl), DECL_SOURCE_LINE (fndecl)); - - for (formal = DECL_ARGUMENTS (fndecl), - actual = parms, - i = 0; - formal; - formal = TREE_CHAIN (formal), - actual = TREE_CHAIN (actual), - i++) - { - /* Actual parameter, already converted to DECL_ARG_TYPE (formal). */ - tree arg = TREE_VALUE (actual); - /* Mode of the value supplied. */ - enum machine_mode tmode = TYPE_MODE (DECL_ARG_TYPE (formal)); - /* Mode of the variable used within the function. */ - enum machine_mode imode = TYPE_MODE (TREE_TYPE (formal)); - rtx copy; - -#if 0 - /* PARM_DECL nodes no longer have this. */ - emit_note (DECL_SOURCE_FILE (formal), DECL_SOURCE_LINE (formal)); -#endif - - /* Make a place to hold the argument value, still in mode TMODE, - and put it in COPY. */ - if (TREE_ADDRESSABLE (formal)) - { - int size = int_size_in_bytes (DECL_ARG_TYPE (formal)); - copy = assign_stack_local (tmode, size); - if (!memory_address_p (DECL_MODE (formal), XEXP (copy, 0))) - copy = change_address (copy, VOIDmode, copy_rtx (XEXP (copy, 0))); - store_expr (arg, copy, 0); - } - else if (! TREE_READONLY (formal) - || TREE_VOLATILE (formal)) - { - /* If parm is modified or if it hasn't a pseudo reg, - we may not simply substitute the actual value; - copy it through a register. */ - copy = gen_reg_rtx (tmode); - store_expr (arg, copy, 0); - } - else - { - copy = expand_expr (arg, 0, tmode, 0); - - /* We do not use CONSTANT_ADDRESS_P here because - the set of cases where that might make a difference - are a subset of the cases that arise even when - it is a CONSTANT_ADDRESS_P (i.e., fp_delta - gets into the act. */ - if (GET_CODE (copy) != REG) - { -#if 0 - if (! CONSTANT_P (copy)) - copy = copy_to_reg (copy); - else if (! optimize) - copy = copy_to_mode_reg (imode, copy); -#else - /* Sigh. */ - if (! CONSTANT_P (copy)) - copy = copy_to_reg (copy); - else - { - if (GET_CODE (DECL_RTL (formal)) == REG) - { - int regno = REGNO (DECL_RTL (formal)); - const_equiv_map[regno] = copy; - const_age_map[regno] = (unsigned)-2; - } - copy = copy_to_mode_reg (imode, copy); - } -#endif - } - } - /* If passed mode != nominal mode, COPY is now the passed mode. - Convert it to the nominal mode (i.e. truncate it). */ - if (tmode != imode) - copy = convert_to_mode (imode, copy, 0); - arg_vec[i] = copy; - } - - copy_parm_decls (DECL_ARGUMENTS (fndecl), arg_vec); - - /* Perform postincrements before actually calling the function. */ - emit_queue (); - - /* clean up stack so that variables might have smaller offsets. */ - do_pending_stack_adjust (); - - /* Pass the function the address in which to return a structure value. - Note that a constructor can cause someone to call us with - STRUCTURE_VALUE_ADDR, but the initialization takes place - via the first parameter, rather than the struct return address. */ - if (structure_value_addr && aggregate_value_p (DECL_RESULT (fndecl))) - { - if (GET_CODE (structure_value_addr) == REG - && (struct_value_rtx == 0 || GET_CODE (struct_value_rtx) == MEM)) - this_struct_value_rtx = structure_value_addr; - else - this_struct_value_rtx = copy_to_mode_reg (Pmode, structure_value_addr); - } - - /* Now prepare for copying the insns. - Set up reg_map, parm_map and label_map saying how to translate - the pseudo-registers, stack-parm references and labels when copying. */ - - reg_map = (rtx *) alloca (max_regno * sizeof (rtx)); - bzero (reg_map, max_regno * sizeof (rtx)); - - parm_map = (rtx *)alloca ((FUNCTION_ARGS_SIZE (header) + UNITS_PER_WORD - 1) - / UNITS_PER_WORD * sizeof (rtx)); - bzero (parm_map, ((FUNCTION_ARGS_SIZE (header) + UNITS_PER_WORD - 1) - / UNITS_PER_WORD * sizeof (rtx))); - - /* Note that expand_expr (called above) can clobber first_parm_offset. */ - first_parm_offset = FIRST_PARM_OFFSET (fndecl); - parm_map -= first_parm_offset / UNITS_PER_WORD; - - if (DECL_ARGUMENTS (fndecl)) - { - tree decl = DECL_ARGUMENTS (fndecl); - - for (formal = decl, i = 0; formal; formal = TREE_CHAIN (formal), i++) - { - /* Create an entry in PARM_MAP that says what pseudo register - is associated with an address we might compute. */ - if (DECL_OFFSET (formal) >= 0) - { - /* This parameter has a home in the stack. */ - parm_map[DECL_OFFSET (formal) / BITS_PER_WORD] = arg_vec[i]; - } - else - { - /* Parameter that was passed in a register; - does it have a home on the stack (as a local)? */ - rtx frtx = DECL_RTL (formal); - rtx offset = 0; - if (GET_CODE (frtx) == MEM) - { - frtx = XEXP (frtx, 0); - if (GET_CODE (frtx) == PLUS) - { - if (XEXP (frtx, 0) == frame_pointer_rtx - && GET_CODE (XEXP (frtx, 1)) == CONST_INT) - offset = XEXP (frtx, 1); - else if (XEXP (frtx, 1) == frame_pointer_rtx - && GET_CODE (XEXP (frtx, 0)) == CONST_INT) - offset = XEXP (frtx, 0); -#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM - /* If there is a separate arg pointer - and REG_PARM_STACK_SPACE is defined, - parms passed in regs can be copied - to slots reached via the arg pointer. */ - if (XEXP (frtx, 0) == arg_pointer_rtx - && GET_CODE (XEXP (frtx, 1)) == CONST_INT) - offset = XEXP (frtx, 1); - else if (XEXP (frtx, 1) == arg_pointer_rtx - && GET_CODE (XEXP (frtx, 0)) == CONST_INT) - offset = XEXP (frtx, 0); -#endif - } - if (offset) - parm_map[INTVAL (offset) / UNITS_PER_WORD] = arg_vec[i]; - else if (TREE_TYPE (formal) != error_mark_node) - abort (); - } - else if (GET_CODE (frtx) != REG) - abort (); - } - /* Create an entry in REG_MAP that says what rtx is associated - with a pseudo register from the function being inlined. */ - if (GET_CODE (DECL_RTL (formal)) == REG) - reg_map[REGNO (DECL_RTL (formal))] = arg_vec[i]; - } - } - - /* Make certain that we can accept struct_value_{incoming_rtx,rtx}, - and map it. */ - if (this_struct_value_rtx == 0) - ; - else if (GET_CODE (struct_value_incoming_rtx) == REG) - reg_map[REGNO (XEXP (DECL_RTL (DECL_RESULT (fndecl)), 0))] - = this_struct_value_rtx; - else if (GET_CODE (struct_value_incoming_rtx) == MEM - && XEXP (XEXP (struct_value_incoming_rtx, 0), 0) == frame_pointer_rtx - && GET_CODE (XEXP (XEXP (struct_value_incoming_rtx, 0), 1)) == CONST_INT) -#if 1 - reg_map[REGNO (XEXP (DECL_RTL (DECL_RESULT (fndecl)), 0))] - = this_struct_value_rtx; -#else - parm_map[INTVAL (XEXP (XEXP (struct_value_incoming_rtx, 0), 1)) / UNITS_PER_WORD] - = this_struct_value_rtx; -#endif - else - abort (); - - label_map = (rtx *)alloca ((max_labelno - min_labelno) * sizeof (rtx)); - label_map -= min_labelno; - - for (i = min_labelno; i < max_labelno; i++) - label_map[i] = gen_label_rtx (); - - /* As we copy insns, record the correspondence, so that inter-insn - references can be copied into isomorphic structure. */ - - insn_map = (rtx *) alloca (INSN_UID (header) * sizeof (rtx)); - bzero (insn_map, INSN_UID (header) * sizeof (rtx)); - - /* Set up a target to translate the inline function's value-register. */ - - if (structure_value_addr != 0 || TYPE_MODE (type) == VOIDmode) - inline_target = 0; - else - { - /* Machine mode function was declared to return. */ - enum machine_mode departing_mode = TYPE_MODE (type); - /* (Possibly wider) machine mode it actually computes - (for the sake of callers that fail to declare it right). */ - enum machine_mode arriving_mode - = TYPE_MODE (DECL_RESULT_TYPE (fndecl)); - - /* Don't use MEMs as direct targets because on some machines - substituting a MEM for a REG makes invalid insns. - Let the combiner substitute the MEM if that is valid. */ - if (target && GET_CODE (target) == REG - && GET_MODE (target) == departing_mode) - inline_target = target; - else - { - inline_target = gen_reg_rtx (departing_mode); - if (target == 0) - target = inline_target; - } - - /* If function's value was promoted before return, - avoid machine mode mismatch when we substitute INLINE_TARGET. - But TARGET is what we will return to the caller. */ - if (arriving_mode != departing_mode) - inline_target = gen_rtx (SUBREG, arriving_mode, inline_target, 0); - } - - /* Make space in current function's stack frame - for the stack frame of the inline function. - Adjust all frame-pointer references by the difference - between the offset to this space - and the offset to the equivalent space in the inline - function's frame. - This difference equals the size of preexisting locals. */ - - fp_delta = get_frame_size (); -#ifdef FRAME_GROWS_DOWNWARD - fp_delta = - fp_delta; -#endif - - before_inline_fp_rtx = get_last_insn (); - inline_fp_rtx = 0; - - /* Now allocate the space for that to point at. */ - - assign_stack_local (VOIDmode, DECL_FRAME_SIZE (fndecl)); - - /* Now copy the insns one by one. */ - - for (insn = insns; insn; insn = NEXT_INSN (insn)) - { - rtx copy, pattern, next = 0; - - retry: - orig_asm_operands_vector = 0; - copy_asm_operands_vector = 0; - - switch (GET_CODE (insn)) - { - case INSN: - pattern = PATTERN (insn); - - /* Special handling for the insn immediately after a CALL_INSN - that returned a value: - If it does copy the value, we must avoid the usual translation - of the return-register into INLINE_TARGET. - If it just USEs the value, the inline function expects it to - stay in the return-register and be returned, - so copy it into INLINE_TARGET. */ - - if (follows_call - /* Allow a stack-adjust, handled normally, to come in between - the call and the value-copying insn. */ - && ! (GET_CODE (pattern) == SET - && SET_DEST (pattern) == stack_pointer_rtx)) - { - if (GET_CODE (pattern) == SET - && rtx_equal_p (SET_SRC (pattern), follows_call)) - /* This insn copies the value: take special care to copy - that value to this insn's destination. */ - { - copy = emit_insn (gen_rtx (SET, VOIDmode, - copy_rtx_and_substitute (SET_DEST (pattern)), - follows_call)); - if (! note_integrated (copy)) - { - next = 0; - goto retry; - } - follows_call = 0; - break; - } - else if (GET_CODE (pattern) == USE - && rtx_equal_p (XEXP (pattern, 0), follows_call)) - /* This insn does nothing but says the value is expected - to flow through to the inline function's return-value. - Make that happen, then ignore this insn. */ - { - copy = emit_insn (gen_rtx (SET, VOIDmode, inline_target, - follows_call)); - if (! note_integrated (copy)) - { - next = 0; - goto retry; - } - follows_call = 0; - break; - } - /* If it does neither, this value must be ignored. */ - follows_call = 0; - } - - copy = 0; - if (GET_CODE (pattern) == USE - && GET_CODE (XEXP (pattern, 0)) == REG) - { - /* The (USE (REG n)) at return from the function should - be ignored since we are changing (REG n) into - inline_target. */ - if (! ignore && REG_FUNCTION_VALUE_P (XEXP (pattern, 0))) - break; - /* Don't emit a (USE (REG n)) of something which - is now constant. */ - if (REGNO (XEXP (pattern, 0)) >= FIRST_PSEUDO_REGISTER - && (const_age == (unsigned)-1 - || const_age_map[REGNO (XEXP (pattern, 0))] >= const_age)) - break; - } - - /* Ignore setting a function value that we don't want to use. */ - if (inline_target == 0 - && GET_CODE (pattern) == SET - && GET_CODE (SET_DEST (pattern)) == REG - && REG_FUNCTION_VALUE_P (SET_DEST (pattern))) - break; - - /* Try to do some quick constant folding here. - This will save save execution time of the compiler, - as well time and space of the program if done here. */ - if (GET_CODE (pattern) == SET - && SET_DEST (pattern) == cc0_rtx) - next = try_fold_cc0 (insn); - - if (next != 0) - { - used_const_equiv = 0; - insn = next; - } - else - { - rtx note = find_reg_note (insn, REG_EQUIV, 0); - copy = emit_insn (copy_rtx_and_substitute (pattern)); - if (! note_integrated (copy)) - { - next = 0; - goto retry; - } - - /* If we are copying an insn that loads a constant, - record the constantness. */ - if (note) - REG_NOTES (copy) - = gen_rtx (EXPR_LIST, REG_EQUIV, XEXP (note, 0), - REG_NOTES (copy)); - - if (GET_CODE (pattern) == SET) - { - rtx dest = SET_DEST (pattern); - if (GET_CODE (dest) == REG) - { - int regno = REGNO (dest); - - if (regno >= FIRST_PSEUDO_REGISTER - && CONSTANT_P (SET_SRC (pattern)) - && (const_equiv_map[regno] == 0 - /* Following clause is a hack to make - case work where GNU C++ reassigns - a variable to make cse work right. */ - || ! rtx_equal_p (const_equiv_map[regno], - SET_SRC (pattern)))) - { - const_equiv_map[regno] = SET_SRC (pattern); - const_age_map[regno] = const_age; - } - } - else - { - while (GET_CODE (dest) == SUBREG - || GET_CODE (dest) == STRICT_LOW_PART - || GET_CODE (dest) == SIGN_EXTRACT - || GET_CODE (dest) == ZERO_EXTRACT) - dest = SUBREG_REG (dest); - - /* Forget everything we thought we knew. */ - if (GET_CODE (dest) == REG - && REGNO (dest) >= FIRST_PSEUDO_REGISTER) - const_equiv_map[REGNO (dest)] = 0; - } - } - } - break; - - case JUMP_INSN: - follows_call = 0; - if (GET_CODE (PATTERN (insn)) == RETURN) - { - if (local_return_label == 0) - local_return_label = gen_label_rtx (); - emit_jump (local_return_label); - break; - } - copy = emit_jump_insn (copy_rtx_and_substitute (PATTERN (insn))); - if (! note_integrated (copy)) - { - next = 0; - goto retry; - } - break; - - case CALL_INSN: - copy = emit_call_insn (copy_rtx_and_substitute (PATTERN (insn))); - if (! note_integrated (copy)) - { - next = 0; - goto retry; - } - /* Special handling needed for the following INSN depending on - whether it copies the value from the fcn return reg. */ - if (GET_CODE (PATTERN (insn)) == SET) - follows_call = SET_DEST (PATTERN (insn)); - else if (GET_CODE (PATTERN (insn)) == PARALLEL - && GET_CODE (XVECEXP (PATTERN (insn), 0, 0)) == SET) - follows_call = SET_DEST (XVECEXP (PATTERN (insn), 0, 0)); - break; - - case CODE_LABEL: - const_age += 2; - copy = emit_label (label_map[CODE_LABEL_NUMBER (insn)]); - follows_call = 0; - if (const_age & 1) - { - int i; - - const_age += 1; - for (i = max_regno; i >= 0; i--) - if (const_age_map[i] == (unsigned)-1) - const_age_map[i] = 0; - } - break; - - case BARRIER: - const_age += 2; - copy = emit_barrier (); - break; - - case NOTE: - /* It is important to discard function-end and function-beg notes, - so we have only one of each in the current function. */ - if (NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_END - && NOTE_LINE_NUMBER (insn) != NOTE_INSN_FUNCTION_BEG - && (flag_inline_debug || NOTE_LINE_NUMBER (insn) < 0)) - copy = emit_note (NOTE_SOURCE_FILE (insn), NOTE_LINE_NUMBER (insn)); - else - copy = 0; - break; - - default: - abort (); - break; - } - if (! (used_const_equiv == 0)) - abort (); - insn_map[INSN_UID (insn)] = copy; - } - - if (local_return_label) - emit_label (local_return_label); - - /* Don't try substituting constants when making up a DECLs rtl. - That would probably only confuse the debugger, but I don't - know for sure. */ - try_use_const = 0; - /* Make copies of the decls of the symbols in the inline function, so that - the copies of the variables get declared in the current function. */ - copy_decl_tree (DECL_INITIAL (fndecl), 0); - /* For safety. */ - if (try_use_const) - used_const_equiv = 0; - - /* End the scope containing the copied formal parameter variables. */ - - expand_end_bindings (getdecls (), 1, 1); - poplevel (1, 1, 0); - poplevel (0, 0, 0); - emit_line_note (input_filename, lineno); - - reg_map = NULL; - label_map = NULL; - - const_equiv_map = old_const_equiv_map; - const_age_map = old_const_age_map; - const_age = old_const_age; - - if (ignore || TYPE_MODE (type) == VOIDmode) - return 0; - - if (structure_value_addr) - { - if (target) - return target; - return gen_rtx (MEM, TYPE_MODE (type), - memory_address (BLKmode, structure_value_addr)); - } - else if (target && target != inline_target - && (GET_CODE (inline_target) != SUBREG - || SUBREG_REG (inline_target) != target)) - { - /* Copy result back to TARGET if TARGET is not INLINE_TARGET. - In general, these should always wind up being the same mode, - after SUBREGs, if any, are stripped. */ - convert_move (target, inline_target, 0); - } - - return target; -} - -/* Given a chain of PARM_DECLs, ARGS, and a vector of RTL homes VEC, - copy each decl into a VAR_DECL, push all of those decls - and give each one the corresponding home. */ - -static void -copy_parm_decls (args, vec) - tree args; - rtx *vec; -{ - register tree tail; - register int i; - - for (tail = args, i = 0; tail; tail = TREE_CHAIN (tail), i++) - { - register tree decl = build_decl (VAR_DECL, DECL_NAME (tail), - TREE_TYPE (tail)); - /* These args would always appear unused, if not for this. */ - TREE_USED (decl) = 1; - /* Prevent warning for shadowing with these. */ - TREE_INLINE (decl) = 1; - pushdecl (decl); - DECL_RTL (decl) = vec[i]; - } -} - -/* Given a LET_STMT node, push decls and levels - so as to construct in the current function a tree of contexts - isomorphic to the one that is given. */ - -static void -copy_decl_tree (let, level) - tree let; - int level; -{ - tree t, node; - - pushlevel (0); - - for (t = STMT_VARS (let); t; t = TREE_CHAIN (t)) - { - tree d = build_decl (TREE_CODE (t), DECL_NAME (t), TREE_TYPE (t)); - DECL_SOURCE_LINE (d) = DECL_SOURCE_LINE (t); - DECL_SOURCE_FILE (d) = DECL_SOURCE_FILE (t); - if (DECL_RTL (t) != 0) - { - if (GET_CODE (DECL_RTL (t)) == MEM - && CONSTANT_ADDRESS_P (XEXP (DECL_RTL (t), 0))) - /* copy_rtx_and_substitute would call memory_address - which would copy the address into a register. - Then debugging-output wouldn't know how to handle it. */ - DECL_RTL (d) = DECL_RTL (t); - else - DECL_RTL (d) = copy_rtx_and_substitute (DECL_RTL (t)); - } - TREE_EXTERNAL (d) = TREE_EXTERNAL (t); - TREE_STATIC (d) = TREE_STATIC (t); - TREE_PUBLIC (d) = TREE_PUBLIC (t); - TREE_LITERAL (d) = TREE_LITERAL (t); - TREE_ADDRESSABLE (d) = TREE_ADDRESSABLE (t); - TREE_READONLY (d) = TREE_READONLY (t); - TREE_VOLATILE (d) = TREE_VOLATILE (t); - /* These args would always appear unused, if not for this. */ - TREE_USED (d) = 1; - /* Prevent warning for shadowing with these. */ - TREE_INLINE (d) = 1; - pushdecl (d); - } - - for (t = STMT_SUBBLOCKS (let); t; t = TREE_CHAIN (t)) - copy_decl_tree (t, level + 1); - - node = poplevel (level > 0, 0, 0); - if (node) - TREE_USED (node) = TREE_USED (let); -} - -/* Create a new copy of an rtx. - Recursively copies the operands of the rtx, - except for those few rtx codes that are sharable. - - Handle constants that need to be placed in the constant pool by - calling `force_const_mem'. */ - -static rtx -copy_rtx_and_substitute (orig) - register rtx orig; -{ - register rtx copy, temp; - register int i, j; - register RTX_CODE code; - register enum machine_mode mode; - register char *format_ptr; - int regno; - - if (orig == 0) - return 0; - - code = GET_CODE (orig); - mode = GET_MODE (orig); - - switch (code) - { - case REG: - /* If a frame-pointer register shows up, then we - must `fix' the reference. If the stack pointer - register shows up, it must be part of stack-adjustments - (*not* because we eliminated the frame pointer!). - Small hard registers are returned as-is. Pseudo-registers - go through their `reg_map'. */ - regno = REGNO (orig); - if (regno < FIRST_PSEUDO_REGISTER) - { - /* Some hard registers are also mapped, - but others are not translated. */ - if (reg_map[regno] != 0) - return reg_map[regno]; - if (REG_FUNCTION_VALUE_P (orig)) - { - /* This is a reference to the function return value. If - the function doesn't have a return value, error. - If it does, it may not be the same mode as `inline_target' - because SUBREG is not required for hard regs. - If not, adjust mode of inline_target to fit the context. */ - if (inline_target == 0) - { - /* If there isn't an inline target, so be it. - Just fake up a reg--it won't get used - for anything important anyway. */ - inline_target = gen_reg_rtx (mode); - return inline_target; - } - if (mode == GET_MODE (inline_target)) - return inline_target; - return gen_rtx (SUBREG, mode, inline_target, 0); - } - if (regno == FRAME_POINTER_REGNUM) - return plus_constant (orig, fp_delta); - return orig; - } - if (try_use_const - && const_equiv_map[regno] != 0 - && const_age_map[regno] == (unsigned)-2) - { - used_const_equiv = 1; - return const_equiv_map[regno]; - } - if (reg_map[regno] == NULL) - reg_map[regno] = gen_reg_rtx (mode); - return reg_map[regno]; - - case SUBREG: - copy = copy_rtx_and_substitute (SUBREG_REG (orig)); - /* SUBREG is ordinary, but don't make nested SUBREGs. */ - if (GET_CODE (copy) == SUBREG) - return gen_rtx (SUBREG, GET_MODE (orig), SUBREG_REG (copy), - SUBREG_WORD (orig) + SUBREG_WORD (copy)); - /* Don't build a SUBREG of a CONST_INT. */ - if (GET_CODE (copy) == CONST_INT) - return copy; - return gen_rtx (SUBREG, GET_MODE (orig), copy, - SUBREG_WORD (orig)); - - case CODE_LABEL: - return label_map[CODE_LABEL_NUMBER (orig)]; - - case LABEL_REF: - copy = rtx_alloc (LABEL_REF); - PUT_MODE (copy, mode); - XEXP (copy, 0) = label_map[CODE_LABEL_NUMBER (XEXP (orig, 0))]; - return copy; - - case PC: - case CC0: - case CONST_INT: - case CONST_DOUBLE: - case SYMBOL_REF: - return orig; - - case CONST: - /* Make new constant pool entry for a constant - that was in the pool of the inline function. */ - if (RTX_INTEGRATED_P (orig)) - return force_const_mem (GET_MODE (orig), XEXP (orig, 0)); - break; - - case ASM_OPERANDS: - /* If a single asm insn contains multiple output operands - then it contains multiple ASM_OPERANDS rtx's that share operand 3. - We must make sure that the copied insn continues to share it. */ - if (orig_asm_operands_vector == XVEC (orig, 3)) - { - copy = rtx_alloc (ASM_OPERANDS); - XSTR (copy, 0) = XSTR (orig, 0); - XSTR (copy, 1) = XSTR (orig, 1); - XINT (copy, 2) = XINT (orig, 2); - XVEC (copy, 3) = copy_asm_operands_vector; - XVEC (copy, 4) = copy_asm_constraints_vector; - XSTR (copy, 5) = XSTR (orig, 5); - XINT (copy, 6) = XINT (orig, 6); - return copy; - } - break; - - case CALL: - /* This is given special treatment because the first - operand of a CALL is a (MEM ...) which may get - forced into a register for cse. This is undesirable - if function-address cse isn't wanted or if we won't do cse. */ -#ifndef NO_FUNCTION_CSE - if (! (optimize && ! flag_no_function_cse)) -#endif - return gen_rtx (CALL, GET_MODE (orig), - gen_rtx (MEM, GET_MODE (XEXP (orig, 0)), - copy_rtx_and_substitute (XEXP (XEXP (orig, 0), 0))), - copy_rtx_and_substitute (XEXP (orig, 1))); - break; - - case PLUS: - /* Note: treat the PLUS case as though it might be needed - to be part of an address. If it turns out that the machine's - PLUS insns can handle something more exciting than a ``load - effective address'', the optimizer will discover this fact. */ - /* Take care of the easy case quickly. */ - if (XEXP (orig, 0) == frame_pointer_rtx - || (ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM - && XEXP (orig, 0) == arg_pointer_rtx)) - { - rtx reg = XEXP (orig, 0), copy = XEXP (orig, 1); - - if (GET_CODE (copy) == CONST_INT) - { - int c = INTVAL (copy); - - if (reg == arg_pointer_rtx && c >= first_parm_offset) - { - copy = access_parm_map (c, VOIDmode); - if (GET_CODE (copy) != MEM) - /* Should not happen, because a parm we need to address - should not be living in a register. - (expand_inline_function copied it to a stack slot.) */ - abort (); - return XEXP (copy, 0); - } - return gen_rtx (PLUS, mode, - frame_pointer_rtx, - gen_rtx (CONST_INT, SImode, - c + fp_delta)); - } - copy = copy_rtx_and_substitute (copy); - temp = force_reg (mode, gen_rtx (PLUS, mode, frame_pointer_rtx, copy)); - return plus_constant (temp, fp_delta); - } - else if (reg_mentioned_p (frame_pointer_rtx, orig) - || (ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM - && reg_mentioned_p (arg_pointer_rtx, orig))) - { - if (GET_CODE (XEXP (orig, 1)) == CONST_INT) - { - copy = copy_rtx_and_substitute (XEXP (orig, 0)); - temp = plus_constant (copy, INTVAL (XEXP (orig, 1))); - } - else - { - temp = gen_rtx (PLUS, GET_MODE (orig), - copy_rtx_and_substitute (XEXP (orig, 0)), - copy_rtx_and_substitute (XEXP (orig, 1))); - } - if (memory_address_p (mode, orig)) - temp = memory_address (mode, temp); - } - else - { - int old_used_const_equiv = used_const_equiv; - - used_const_equiv = 0; - temp = gen_rtx (PLUS, GET_MODE (orig), - copy_rtx_and_substitute (XEXP (orig, 0)), - copy_rtx_and_substitute (XEXP (orig, 1))); - if (used_const_equiv) - { - if (GET_CODE (XEXP (temp, 0)) == CONST_INT) - temp = plus_constant (XEXP (temp, 1), INTVAL (XEXP (temp, 0))); - else if (GET_CODE (XEXP (temp, 1)) == CONST_INT) - temp = plus_constant (XEXP (temp, 0), INTVAL (XEXP (temp, 1))); - else if (memory_address_p (mode, orig)) - { - try_use_const = 0; - used_const_equiv = 0; - temp = gen_rtx (PLUS, GET_MODE (orig), - copy_rtx_and_substitute (XEXP (orig, 0)), - copy_rtx_and_substitute (XEXP (orig, 1))); - } - } - else if (memory_address_p (mode, orig)) - temp = memory_address (mode, temp); - - used_const_equiv |= old_used_const_equiv; - } - return temp; - - case MULT: - { - int old_used_const_equiv = used_const_equiv; - - used_const_equiv = 0; - - temp = gen_rtx (MULT, GET_MODE (orig), - copy_rtx_and_substitute (XEXP (orig, 0)), - copy_rtx_and_substitute (XEXP (orig, 1))); - - if (used_const_equiv) - { - if (GET_CODE (XEXP (temp, 0)) == CONST_INT - && GET_CODE (XEXP (temp, 1)) == CONST_INT) - temp = gen_rtx (CONST_INT, VOIDmode, - INTVAL (XEXP (temp, 0)) * INTVAL (XEXP (temp, 1))); - else - { - try_use_const = 0; - used_const_equiv = 0; - temp = gen_rtx (MULT, GET_MODE (orig), - copy_rtx_and_substitute (XEXP (orig, 0)), - copy_rtx_and_substitute (XEXP (orig, 1))); - } - } - used_const_equiv |= old_used_const_equiv; - } - return temp; - - case MEM: - /* Take care of easiest case here. */ - copy = XEXP (orig, 0); - if (copy == frame_pointer_rtx || copy == arg_pointer_rtx) - return gen_rtx (MEM, mode, - plus_constant (frame_pointer_rtx, fp_delta)); - - /* Allow a pushing-address even if that is not valid as an - ordinary memory address. It indicates we are inlining a special - push-insn. These must be copied; otherwise unshare_all_rtl - might clobber them to point at temporary rtl of this function. */ -#ifdef STACK_GROWS_DOWNWARD - if (GET_CODE (copy) == PRE_DEC && XEXP (copy, 0) == stack_pointer_rtx) - return gen_rtx (MEM, mode, copy_rtx_and_substitute (copy)); -#else - if (GET_CODE (copy) == PRE_INC && XEXP (copy, 0) == stack_pointer_rtx) - return gen_rtx (MEM, mode, copy_rtx_and_substitute (copy)); -#endif - - /* If this is some other sort of address that isn't generally valid, - break out all the registers referred to. */ - if (! memory_address_p (mode, copy)) - return gen_rtx (MEM, mode, copy_address (copy)); - - /* There is no easy way to get our mode to `access_parm_map', which - may need to know it, so here is most of the PLUS code duplicated. */ - if (GET_CODE (copy) == PLUS) - { - if (XEXP (copy, 0) == frame_pointer_rtx - || (ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM - && XEXP (copy, 0) == arg_pointer_rtx)) - { - rtx reg; - reg = XEXP (copy, 0), copy = XEXP (copy, 1); - - if (GET_CODE (copy) == CONST_INT) - { - int c = INTVAL (copy); - - if (reg == arg_pointer_rtx && c >= first_parm_offset) - return access_parm_map (c, mode); - - temp = gen_rtx (PLUS, Pmode, - frame_pointer_rtx, - gen_rtx (CONST_INT, SImode, - c + fp_delta)); - if (! memory_address_p (Pmode, temp)) - { - if (inline_fp_rtx == 0) - { - rtx last = get_last_insn (); - inline_fp_rtx - = copy_to_mode_reg (Pmode, - plus_constant (frame_pointer_rtx, fp_delta)); - reorder_insns (NEXT_INSN (last), get_last_insn (), before_inline_fp_rtx); - } - return gen_rtx (MEM, mode, plus_constant (inline_fp_rtx, c)); - } - } - copy = copy_rtx_and_substitute (copy); - temp = gen_rtx (PLUS, Pmode, frame_pointer_rtx, copy); - temp = plus_constant (temp, fp_delta); - temp = memory_address (Pmode, temp); - } - else if (reg_mentioned_p (frame_pointer_rtx, copy) - || (ARG_POINTER_REGNUM != FRAME_POINTER_REGNUM - && reg_mentioned_p (arg_pointer_rtx, copy))) - { - if (GET_CODE (XEXP (copy, 1)) == CONST_INT) - { - temp = copy_rtx_and_substitute (XEXP (copy, 0)); - temp = plus_constant (temp, INTVAL (XEXP (copy, 1))); - } - else - { - temp = gen_rtx (PLUS, GET_MODE (copy), - copy_rtx_and_substitute (XEXP (copy, 0)), - copy_rtx_and_substitute (XEXP (copy, 1))); - } - } - else - { - if (GET_CODE (XEXP (copy, 1)) == CONST_INT) - temp = plus_constant (copy_rtx_and_substitute (XEXP (copy, 0)), - INTVAL (XEXP (copy, 1))); - else - { - rtx left = copy_rtx_and_substitute (XEXP (copy, 0)); - rtx right = copy_rtx_and_substitute (XEXP (copy, 1)); - - temp = gen_rtx (PLUS, GET_MODE (copy), left, right); - } - } - } - else - temp = copy_rtx_and_substitute (copy); - - temp = change_address (orig, mode, temp); - /* Deals with GCC bug for now. */ - RTX_UNCHANGING_P (temp) = 0; - return temp; - - case RETURN: - abort (); - } - - copy = rtx_alloc (code); - PUT_MODE (copy, mode); - copy->in_struct = orig->in_struct; - copy->volatil = orig->volatil; - copy->unchanging = orig->unchanging; - - format_ptr = GET_RTX_FORMAT (GET_CODE (copy)); - - for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++) - { - switch (*format_ptr++) - { - case '0': - break; - - case 'e': - XEXP (copy, i) = copy_rtx_and_substitute (XEXP (orig, i)); - break; - - case 'u': - /* Change any references to old-insns to point to the - corresponding copied insns. */ - XEXP (copy, i) = insn_map[INSN_UID (XEXP (orig, i))]; - break; - - case 'E': - XVEC (copy, i) = XVEC (orig, i); - if (XVEC (orig, i) != NULL && XVECLEN (orig, i) != 0) - { - XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i)); - for (j = 0; j < XVECLEN (copy, i); j++) - XVECEXP (copy, i, j) = copy_rtx_and_substitute (XVECEXP (orig, i, j)); - } - break; - - case 'i': - XINT (copy, i) = XINT (orig, i); - break; - - case 's': - XSTR (copy, i) = XSTR (orig, i); - break; - - default: - abort (); - } - } - - if (code == ASM_OPERANDS && orig_asm_operands_vector == 0) - { - orig_asm_operands_vector = XVEC (orig, 3); - copy_asm_operands_vector = XVEC (copy, 3); - copy_asm_constraints_vector = XVEC (copy, 4); - } - - return copy; -} - -/* Get the value corresponding to an address relative to the arg pointer - at index RELADDRESS. MODE is the machine mode of the reference. - MODE is used only when the value is a REG. - Pass VOIDmode for MODE when the mode is not known; - in such cases, you should make sure the value is a MEM. */ - -static rtx -access_parm_map (reladdress, mode) - int reladdress; - enum machine_mode mode; -{ - /* Index in parm_map. */ - int index = reladdress / UNITS_PER_WORD; - /* Offset of the data being referenced - from the beginning of the value for that parm. */ - int offset = reladdress % UNITS_PER_WORD; - rtx copy; - - /* If we are referring to the middle of a multiword parm, - find the beginning of that parm. - OFFSET gets the offset of the reference from - the beginning of the parm. */ - - while (parm_map[index] == 0) - { - index--; - if (index < first_parm_offset / UNITS_PER_WORD) - /* If this abort happens, it means we need - to handle "decrementing" INDEX back far - enough to start looking among the reg parms - instead of the stack parms. What a mess! */ - abort (); - offset += UNITS_PER_WORD; - } - - copy = parm_map[index]; - -#ifdef BYTES_BIG_ENDIAN - /* Subtract from OFFSET the offset of where - the actual (non-BLKmode) parm value would start. */ - if (GET_MODE (copy) != BLKmode - && GET_MODE_SIZE (GET_MODE (copy)) < UNITS_PER_WORD) - offset - -= (UNITS_PER_WORD - - GET_MODE_SIZE (GET_MODE (copy))); -#endif - - /* For memory ref, adjust it by the desired offset. */ - if (GET_CODE (copy) == MEM) - { - if (offset != 0 || GET_MODE (copy) != mode) - return change_address (copy, mode, - plus_constant (XEXP (copy, 0), - offset)); - return copy; - } - - if (GET_CODE (copy) != REG && GET_CODE (copy) != SUBREG - && ! CONSTANT_P (copy)) - abort (); - if (mode == VOIDmode) - abort (); - - /* A REG cannot be offset by bytes, so use a subreg - (which is possible only in certain cases). */ - if (GET_MODE (copy) != mode - && GET_MODE (copy) != VOIDmode) - { - int word; - /* Crash if the portion of the arg wanted - is not the least significant. - Functions with refs to other parts of a - parameter should not be inline-- - see function_cannot_inline_p. */ -#ifdef BYTES_BIG_ENDIAN - if (offset + GET_MODE_SIZE (mode) - != GET_MODE_SIZE (GET_MODE (copy))) - abort (); -#else - if (offset != 0) - abort (); -#endif - word = 0; - if (GET_CODE (copy) == SUBREG) - word = SUBREG_WORD (copy), copy = SUBREG_REG (copy); - if (CONSTANT_P (copy)) - copy = force_reg (GET_MODE (copy), copy); - return gen_rtx (SUBREG, mode, copy, word); - } - - return copy; -} - -/* Like copy_rtx_and_substitute but produces different output, suitable - for an ideosyncractic address that isn't memory_address_p. - The output resembles the input except that REGs and MEMs are replaced - with new psuedo registers. All the "real work" is done in separate - insns which set up the values of these new registers. */ - -static rtx -copy_address (orig) - register rtx orig; -{ - register rtx copy; - register int i, j; - register RTX_CODE code; - register enum machine_mode mode; - register char *format_ptr; - - if (orig == 0) - return 0; - - code = GET_CODE (orig); - mode = GET_MODE (orig); - - switch (code) - { - case REG: - if (REGNO (orig) != FRAME_POINTER_REGNUM) - return copy_rtx_and_substitute (orig); - return plus_constant (frame_pointer_rtx, fp_delta); - - case PLUS: - if (XEXP (orig, 0) == frame_pointer_rtx) - return plus_constant (orig, fp_delta); - break; - - case MEM: - return copy_to_reg (copy_rtx_and_substitute (orig)); - - case CODE_LABEL: - case LABEL_REF: - return copy_rtx_and_substitute (orig); - - case PC: - case CC0: - case CONST_INT: - case CONST_DOUBLE: - case SYMBOL_REF: - return orig; - } - - copy = rtx_alloc (code); - PUT_MODE (copy, mode); - copy->in_struct = orig->in_struct; - copy->volatil = orig->volatil; - copy->unchanging = orig->unchanging; - - format_ptr = GET_RTX_FORMAT (GET_CODE (copy)); - - for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++) - { - switch (*format_ptr++) - { - case '0': - break; - - case 'e': - XEXP (copy, i) = copy_rtx_and_substitute (XEXP (orig, i)); - break; - - case 'u': - /* Change any references to old-insns to point to the - corresponding copied insns. */ - XEXP (copy, i) = insn_map[INSN_UID (XEXP (orig, i))]; - break; - - case 'E': - XVEC (copy, i) = XVEC (orig, i); - if (XVEC (orig, i) != NULL && XVECLEN (orig, i) != 0) - { - XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i)); - for (j = 0; j < XVECLEN (copy, i); j++) - XVECEXP (copy, i, j) = copy_rtx_and_substitute (XVECEXP (orig, i, j)); - } - break; - - case 'i': - XINT (copy, i) = XINT (orig, i); - break; - - case 's': - XSTR (copy, i) = XSTR (orig, i); - break; - - default: - abort (); - } - } - return copy; -} - -/* Return the constant equivalent of X. If X is a manifest - constant, it is returned. If X is a register, we check - to see if we happen to know its value as a constant. */ -static rtx -const_equiv (x) - rtx x; -{ - if (GET_CODE (x) == REG) - { - int regno = REGNO (x); - if (const_equiv_map[regno] - && const_age_map[regno] >= const_age) - return const_equiv_map[regno]; - return 0; - } - if (CONSTANT_P (x)) - return x; - return 0; -} - -/* Attempt to simplify INSN while copying it from an inline fn, - assuming it is a SET that sets CC0. - - If we simplify it, we emit the appropriate insns and return - the last insn that we have handled (since we may handle the insn - that follows INSN as well as INSN itself). - - Otherwise we do nothing and return zero. */ - -static rtx -try_fold_cc0 (insn) - rtx insn; -{ - rtx cnst = copy_rtx_and_substitute (SET_SRC (PATTERN (insn))); - rtx pat, copy; - - if (! CONSTANT_P (cnst)) - /* Constant equivlancies are with old, not new rtl. */ - cnst = const_equiv (SET_SRC (PATTERN (insn))); - if (cnst - /* @@ Cautious: Don't know how many of these tests we need. */ - && NEXT_INSN (insn) - && GET_CODE (pat = PATTERN (NEXT_INSN (insn))) == SET - && SET_DEST (pat) == pc_rtx - && GET_CODE (pat = SET_SRC (pat)) == IF_THEN_ELSE - && GET_RTX_LENGTH (GET_CODE (XEXP (pat, 0))) == 2) - { - rtx cnst2; - rtx cond = XEXP (pat, 0); - - if ((XEXP (cond, 0) == cc0_rtx - && (cnst2 = const_equiv (XEXP (cond, 1)))) - || (XEXP (cond, 1) == cc0_rtx - && (cnst2 = const_equiv (XEXP (cond, 0))))) - { - copy = fold_out_const_cc0 (cond, XEXP (pat, 1), XEXP (pat, 2), - cnst, cnst2); - if (copy) - { - if (GET_CODE (copy) == LABEL_REF) - { - /* We will branch unconditionally to - the label specified by COPY. - Eliminate dead code by running down the - list of insn until we see a CODE_LABEL. - If the CODE_LABEL is the one specified - by COPY, we win, and can delete all code - up to (but not necessarily including) - that label. Otherwise only win a little: - emit the branch insn, and continue expanding. */ - rtx tmp = NEXT_INSN (insn); - while (tmp && GET_CODE (tmp) != CODE_LABEL) - tmp = NEXT_INSN (tmp); - if (! tmp) - abort (); - if (label_map[CODE_LABEL_NUMBER (tmp)] == XEXP (copy, 0)) - { - /* Big win. */ - return PREV_INSN (tmp); - } - else - { - /* Small win. Emit the unconditional branch, - followed by a BARRIER, so that jump optimization - will know what to do. */ - emit_jump (XEXP (copy, 0)); - return NEXT_INSN (insn); - } - } - else if (copy == pc_rtx) - { - /* Do not take the branch, just fall through. - Jump optimize should handle the elimination of - dead code if appropriate. */ - return NEXT_INSN (insn); - } - else - abort (); - } - } - } - return 0; -} - -/* If (COND_RTX CNST1 CNST2) yield a result we can treat - as being constant, return THEN_RTX if the result is always - non-zero, and return ELSE_RTX otherwise. */ -static rtx -fold_out_const_cc0 (cond_rtx, then_rtx, else_rtx, cnst1, cnst2) - rtx cond_rtx, then_rtx, else_rtx; - rtx cnst1, cnst2; -{ - int value1, value2; - int int1 = GET_CODE (cnst1) == CONST_INT; - int int2 = GET_CODE (cnst2) == CONST_INT; - if (int1) - value1 = INTVAL (cnst1); - else - value1 = 1; - if (int2) - value2 = INTVAL (cnst2); - else - value2 = 1; - - switch (GET_CODE (cond_rtx)) - { - case NE: - if (int1 && int2) - if (value1 != value2) - return copy_rtx_and_substitute (then_rtx); - else - return copy_rtx_and_substitute (else_rtx); - if (value1 == 0 || value2 == 0) - return copy_rtx_and_substitute (then_rtx); - if (int1 == 0 && int2 == 0) - if (rtx_equal_p (cnst1, cnst2)) - return copy_rtx_and_substitute (else_rtx); - break; - case EQ: - if (int1 && int2) - if (value1 == value2) - return copy_rtx_and_substitute (then_rtx); - else - return copy_rtx_and_substitute (else_rtx); - if (value1 == 0 || value2 == 0) - return copy_rtx_and_substitute (else_rtx); - if (int1 == 0 && int2 == 0) - if (rtx_equal_p (cnst1, cnst2)) - return copy_rtx_and_substitute (then_rtx); - break; - case GE: - if (int1 && int2) - if (value1 >= value2) - return copy_rtx_and_substitute (then_rtx); - else - return copy_rtx_and_substitute (else_rtx); - if (value1 == 0) - return copy_rtx_and_substitute (else_rtx); - if (value2 == 0) - return copy_rtx_and_substitute (then_rtx); - break; - case GT: - if (int1 && int2) - if (value1 > value2) - return copy_rtx_and_substitute (then_rtx); - else - return copy_rtx_and_substitute (else_rtx); - if (value1 == 0) - return copy_rtx_and_substitute (else_rtx); - if (value2 == 0) - return copy_rtx_and_substitute (then_rtx); - break; - case LE: - if (int1 && int2) - if (value1 <= value2) - return copy_rtx_and_substitute (then_rtx); - else - return copy_rtx_and_substitute (else_rtx); - if (value1 == 0) - return copy_rtx_and_substitute (then_rtx); - if (value2 == 0) - return copy_rtx_and_substitute (else_rtx); - break; - case LT: - if (int1 && int2) - if (value1 < value2) - return copy_rtx_and_substitute (then_rtx); - else - return copy_rtx_and_substitute (else_rtx); - if (value1 == 0) - return copy_rtx_and_substitute (then_rtx); - if (value2 == 0) - return copy_rtx_and_substitute (else_rtx); - break; - case GEU: - if (int1 && int2) - if ((unsigned)value1 >= (unsigned)value2) - return copy_rtx_and_substitute (then_rtx); - else - return copy_rtx_and_substitute (else_rtx); - if (value1 == 0) - return copy_rtx_and_substitute (else_rtx); - if (value2 == 0) - return copy_rtx_and_substitute (then_rtx); - break; - case GTU: - if (int1 && int2) - if ((unsigned)value1 > (unsigned)value2) - return copy_rtx_and_substitute (then_rtx); - else - return copy_rtx_and_substitute (else_rtx); - if (value1 == 0) - return copy_rtx_and_substitute (else_rtx); - if (value2 == 0) - return copy_rtx_and_substitute (then_rtx); - break; - case LEU: - if (int1 && int2) - if ((unsigned)value1 <= (unsigned)value2) - return copy_rtx_and_substitute (then_rtx); - else - return copy_rtx_and_substitute (else_rtx); - if (value1 == 0) - return copy_rtx_and_substitute (then_rtx); - if (value2 == 0) - return copy_rtx_and_substitute (else_rtx); - break; - case LTU: - if (int1 && int2) - if ((unsigned)value1 < (unsigned)value2) - return copy_rtx_and_substitute (then_rtx); - else - return copy_rtx_and_substitute (else_rtx); - if (value1 == 0) - return copy_rtx_and_substitute (then_rtx); - if (value2 == 0) - return copy_rtx_and_substitute (else_rtx); - break; - } - /* Could not hack it. */ - return 0; -} - -/* If any CONST expressions with RTX_INTEGRATED_P are present in X, - they should be in the constant pool. - Run force_const_mem to put them there. */ - -static void -restore_constants (x) - rtx x; -{ - int i, j; - char *fmt = GET_RTX_FORMAT (GET_CODE (x)); - - for (i = 0; i < GET_RTX_LENGTH (GET_CODE (x)); i++) - { - switch (*fmt++) - { - case 'E': - for (j = 0; j < XVECLEN (x, i); j++) - if (RTX_INTEGRATED_P (XVECEXP (x, i, j)) - && GET_CODE (XVECEXP (x, i, j)) == CONST) - XVECEXP (x, i, j) = force_const_mem (GET_MODE (XVECEXP (x, i, j)), - XEXP (XVECEXP (x, i, j), 0)); - else - restore_constants (XVECEXP (x, i, j)); - break; - - case 'e': - if (RTX_INTEGRATED_P (XEXP (x, i)) - && GET_CODE (XEXP (x, i)) == CONST) - XEXP (x, i) = force_const_mem (GET_MODE (XEXP (x, i)), - XEXP (XEXP (x, i), 0)); - else - restore_constants (XEXP (x, i)); - break; - } - } -} - -/* Output the assembly language code for the function FNDECL - from its DECL_SAVED_INSNS. Used for inline functions that are output - at end of compilation instead of where they came in the source. */ - -void -output_inline_function (fndecl) - tree fndecl; -{ - rtx head = DECL_SAVED_INSNS (fndecl); - rtx last; - extern rtx stack_slot_list; - - temporary_allocation (); - - current_function_decl = fndecl; - - /* This call is only used to initialize global variables. */ - init_function_start (fndecl); - - /* Set stack frame size. */ - assign_stack_local (BLKmode, DECL_FRAME_SIZE (fndecl)); - - restore_reg_data (FIRST_PARM_INSN (head)); - - stack_slot_list = XEXP (head, 9); - - /* There is no need to output a return label again. */ - return_label = 0; - expand_function_end (DECL_SOURCE_FILE (fndecl), DECL_SOURCE_LINE (fndecl)); - - /* Find last insn and rebuild the constant pool. */ - for (last = FIRST_PARM_INSN (head); - NEXT_INSN (last); last = NEXT_INSN (last)) - { -#if 0 - /* No need to restore these constants again. */ - if (GET_CODE (last) == INSN || GET_CODE (last) == JUMP_INSN - || GET_CODE (last) == CALL_INSN) - restore_constants (PATTERN (last)); -#endif - } - - set_new_first_and_last_insn (FIRST_PARM_INSN (head), last); - - /* Compile this function all the way down to assembly code. */ - rest_of_compilation (fndecl); - - current_function_decl = 0; - - permanent_allocation (); -} -#if 0 - -/* Hashing of rtxs so that we don't make duplicates. - The entry point is `rtx_hash_canon'. */ - -/* Each hash table slot is a bucket containing a chain - of these structures. */ - -struct rtx_hash -{ - struct rtx_hash *next; /* Next structure in the bucket. */ - int hashcode; /* Hash code of this type. */ - rtx x; /* The rtx recorded here. */ -}; - -/* Now here is the hash table. This works exactly the same way - that types are hashed in tree.c, except this is for rtxs. */ - -#define RTX_HASH_SIZE 199 -struct rtx_hash *rtx_hash_table[RTX_HASH_SIZE]; - -/* Here is how primitive or already-canonicalized types' hash - codes are made. */ -#define RTX_HASH(RTX) (RTX) - -/* Look in the type hash table for a type isomorphic to RTX. - If one is found, return it. Otherwise return 0. */ - -tree -rtx_hash_lookup (hashcode, x) - int hashcode; - tree x; -{ - register struct rtx_hash *h; - for (h = rtx_hash_table[hashcode % RTX_HASH_SIZE]; h; h = h->next) - if (h->hashcode == hashcode - && GET_CODE (h->x) == GET_CODE (x) - && GET_MODE (h->x) == GET_MODE (x) -#if 0 - && h->x->jump == x->jump - && h->x->call == x->call - && h->x->unchanging == x->unchanging - && h->x->volatil == x->volatil - && h->x->in_struct == x->in_struct - && h->x->used == x->used - && h->x->integrated == x->integrated -#endif - ) - { - int i, j; - int len = GET_RTX_LENGTH (GET_CODE (x)); - char *fmt = GET_RTX_FORMAT (GET_CODE (x)); - - for (i = 0; i < len; i++) - switch (fmt[i]) - { - case '0': - break; - - case 'e': - case 'u': - case 's': - case 'S': - if (XEXP (h->x, i) != XEXP (x, i)) - goto no_dice; - break; - - case 'E': - if (XVECLEN (h->x, i) != XVECLEN (x, i)) - goto no_dice; - for (j = 0; j < XVECLEN (x, i); j++) - if (XVECEXP (h->x, i, j) != XVECEXP (x, i, j)) - goto no_dice; - break; - - case 'i': - case 'n': - if (INTVAL (XEXP (h->x, i)) != INTVAL (XEXP (x, i))) - goto no_dice; - - default: - abort (); - } - - /* Everything matched. */ - return h->x; - - /* Try more. */ - no_dice: - ; - } - - /* Nothing matched. */ - return 0; -} - -/* Add an entry to the rtx-hash-table - for a type RTX whose hash code is HASHCODE. */ - -void -rtx_hash_add (hashcode, x) - int hashcode; - tree x; -{ - register struct rtx_hash *h; - - h = (struct rtx_hash *) oballoc (sizeof (struct rtx_hash)); - h->hashcode = hashcode; - h->x = x; - h->next = rtx_hash_table[hashcode % RTX_HASH_SIZE]; - rtx_hash_table[hashcode % RTX_HASH_SIZE] = h; -} - -/* Given RTX, and HASHCODE its hash code, return the canonical - object for an identical rtx if one already exists. - Otherwise, return RTX, and record it as the canonical object - if it is a permanent object. - - To use this function, first create a rtx of the sort you want. - Then compute its hash code from the fields of the rtx that - make it different from other similar rtxs. - Then call this function and use the value. - This function frees the rtx you pass in if it is a duplicate. */ - -/* Set to 1 to debug without canonicalization. Never set by program. */ -int debug_no_rtx_hash = 0; - -tree -rtx_hash_canon (hashcode, x) - int hashcode; - tree x; -{ - tree x1; - - if (debug_no_rtx_hash) - return x; - - x1 = rtx_hash_lookup (hashcode, x); - if (x1 != 0) - { - struct obstack *o = maybepermanent_obstack; - obstack_free (o, x); - return x1; - } - - /* If this is a new type, record it for later reuse. */ - rtx_hash_add (hashcode, x); - - return x; -} -#endif diff --git a/gnu/usr.bin/g++/cc1plus/print-tree.c b/gnu/usr.bin/g++/cc1plus/print-tree.c deleted file mode 100644 index ecbb5f770a2d..000000000000 --- a/gnu/usr.bin/g++/cc1plus/print-tree.c +++ /dev/null @@ -1,673 +0,0 @@ -/* Prints out tree in human readable form - GNU C-compiler - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include "config.h" -#include "tree.h" -#include - -extern char **tree_code_name; - -extern char *mode_name[]; - -extern char spaces[]; - -#define MIN(x,y) ((x < y) ? x : y) - -static FILE *outfile; - -extern int tree_node_counter; - -/* markvec[i] is 1 if node number i has been seen already. */ - -static char *markvec; - -static void dump (); -void dump_tree (); - -void -debug_dump_tree (root) - tree root; -{ - dump_tree (stderr, root); -} - -void -dump_tree (outf, root) - FILE *outf; - tree root; -{ - markvec = (char *) alloca (tree_node_counter + 1); - bzero (markvec, tree_node_counter + 1); - outfile = outf; - dump (root, 0); - fflush (outf); -} - -static -void -wruid (node) - tree node; -{ - - if (node == NULL) - fputs ("<>", outfile); - else { - fprintf (outfile, "%1d", TREE_UID (node)); - } -} - -static -void -part (title, node) - char title[]; - tree node; -{ - fprintf (outfile, " %s = ", title); - wruid (node); - putc (';', outfile); -} - -/* Similar to `part' but prefix with @ if value is not constant - and print the constant value if it is constant. */ -static -void -cpart (title, ct, punct) - char *title; - tree ct; - char punct; -{ - fprintf (outfile, " %s = ", title); - if (ct == NULL) - fputs ("<>", outfile); - else - { - if (!TREE_LITERAL (ct)) - { - putc ('@', outfile); - wruid (ct); - } - else - fprintf (outfile, "%ld", TREE_INT_CST_LOW (ct)); - } - putc (punct, outfile); -} - -static void -walk (node, leaf, indent) - tree node; - tree leaf; - int indent; -{ - if (node != NULL - /* Don't walk any global nodes reached from local nodes! - The global nodes will be dumped at the end, all together. - Also don't mention a FUNCTION_DECL node that is marked local - since it was fully described when it was dumped locally. */ - && (TREE_CODE (node) != FUNCTION_DECL - || TREE_PERMANENT (node)) - && (TREE_PERMANENT (leaf) == TREE_PERMANENT (node))) - dump (node, indent+1); -} - -static void -cwalk (s, leaf, indent) - tree s; - tree leaf; - int indent; -{ - if (s != NULL) - if (!TREE_LITERAL (s)) - walk (s, leaf, indent); -} - -static void -prtypeinfo (node) - register tree node; -{ - int first; - - part ("type", TREE_TYPE (node)); - first = 1; - fputs (" [", outfile); - if (TREE_EXTERNAL (node)) - { - if (!first) putc (' ', outfile); - fputs ("external", outfile); - first = 0; - } - if (TREE_PUBLIC (node)) - { - if (!first) putc (' ', outfile); - fputs ("public", outfile); - first = 0; - } - if (TREE_STATIC (node)) - { - if (!first) putc (' ', outfile); - fputs ("static", outfile); - first = 0; - } - if (TREE_VOLATILE (node)) - { - if (!first) putc (' ', outfile); - fputs ("volatile", outfile); - first = 0; - } - if (TREE_PACKED (node)) - { - if (!first) putc (' ', outfile); - fputs ("packed", outfile); - first = 0; - } - if (TREE_READONLY (node)) - { - if (!first) putc (' ', outfile); - fputs ("readonly", outfile); - first = 0; - } - if (TREE_LITERAL (node)) - { - if (!first) putc (' ', outfile); - fputs ("literal", outfile); - first = 0; - } - if (TREE_NONLOCAL (node)) - { - if (!first) putc (' ', outfile); - fputs ("nonlocal", outfile); - first = 0; - } - if (TREE_ADDRESSABLE (node)) - { - if (!first) putc (' ', outfile); - fputs ("addressable", outfile); - first = 0; - } - if (TREE_REGDECL (node)) - { - if (!first) putc (' ', outfile); - fputs ("regdecl", outfile); - first = 0; - } - if (TREE_THIS_VOLATILE (node)) - { - if (!first) putc (' ', outfile); - fputs ("this_vol", outfile); - first = 0; - } - if (TREE_UNSIGNED (node)) - { - if (!first) putc (' ', outfile); - fputs ("unsigned", outfile); - first = 0; - } - if (TREE_ASM_WRITTEN (node)) - { - if (!first) putc (' ', outfile); - fputs ("asm_written", outfile); - first = 0; - } - if (TREE_INLINE (node)) - { - if (!first) putc (' ', outfile); - fputs ("inline", outfile); - first = 0; - } - if (TREE_USED (node)) - { - if (!first) putc (' ', outfile); - fputs ("used", outfile); - first = 0; - } - if (TREE_PERMANENT (node)) - { - if (!first) putc (' ', outfile); - fputs ("permanent", outfile); - first = 0; - } - if (TREE_LANG_FLAG_1 (node)) - { - if (!first) putc (' ', outfile); - fputs ("lang_flag_1", outfile); - first = 0; - } - if (TREE_LANG_FLAG_2 (node)) - { - if (!first) putc (' ', outfile); - fputs ("lang_flag_2", outfile); - first = 0; - } - if (TREE_LANG_FLAG_3 (node)) - { - if (!first) putc (' ', outfile); - fputs ("lang_flag_3", outfile); - first = 0; - } - if (TREE_LANG_FLAG_4 (node)) - { - if (!first) putc (' ', outfile); - fputs ("lang_flag_4", outfile); - first = 0; - } - fputs ("] ", outfile); -} - -static void -prdeclmodeinfo (node) - tree node; -{ - register enum machine_mode mode = DECL_MODE (node); - fprintf (outfile, " %s;", mode_name[(int) mode]); - - cpart ("size", DECL_SIZE (node), '*'); - fprintf (outfile, "%d;", DECL_SIZE_UNIT (node)); - - fprintf (outfile, " alignment = %1d;", DECL_ALIGN (node)); -} - -static void -prtypemodeinfo (node) - tree node; -{ - register enum machine_mode mode = TYPE_MODE (node); - fprintf (outfile, " %s;", mode_name[(int) mode]); - - cpart ("size", TYPE_SIZE (node), '*'); - fprintf (outfile, "%d;", TYPE_SIZE_UNIT (node)); - - fprintf (outfile, " alignment = %1d;", TYPE_ALIGN (node)); -} - -static void -skip (indent) - int indent; -{ - putc ('\n',outfile); - fputs (spaces + (strlen (spaces) - (12 + MIN (40,(indent+1)*2))), outfile); -} - -/* Output a description of the tree node NODE - if its description has not been output already. */ - -static -void -dump (node, indent) - tree node; - int indent; -{ - register enum tree_code code = TREE_CODE (node); - register int i; - register int len, first_rtl; - int nochain = 0; - - if (markvec[TREE_UID (node)]) - return; - markvec[TREE_UID (node)] = 1; - - fputs (" ", outfile); - fprintf (outfile, "%5d", TREE_UID (node)); - fputs (spaces + (strlen (spaces) - MIN (40, (indent+1)*2)), outfile); - fputs (tree_code_name[(int) code], outfile); - - switch (*tree_code_type[(int) code]) - { - case 'd': - fputs (" name = ", outfile); - if (DECL_NAME (node) == NULL) - fputs ("<>;", outfile); - else - fprintf (outfile, "%s;", - IDENTIFIER_POINTER (DECL_NAME (node))); - if (code != PARM_DECL) - fprintf (outfile, " at %s line %d;", - DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node)); - skip (indent); - prdeclmodeinfo (node); - prtypeinfo (node); -#ifdef PRINT_LANG_DECL - print_lang_decl (node); -#endif - skip (indent); - fprintf (outfile, " offset = %1d;", DECL_OFFSET (node)); - if (DECL_VOFFSET (node) != NULL) - { - fputs ("voffset = ", outfile); - wruid (DECL_VOFFSET (node)); - fprintf (outfile, "*%1d;", DECL_VOFFSET_UNIT (node)); - } - part ("context", DECL_CONTEXT (node)); - if (code == FUNCTION_DECL) - { - if (DECL_ARGUMENTS (node) || DECL_RESULT (node) - || DECL_INITIAL (node)) - { - skip (indent); - part ("arguments", DECL_ARGUMENTS (node)); - part ("result", DECL_RESULT (node)); - if ((int) (DECL_INITIAL (node)) == 1) - fprintf (outfile, " initial = const 1;"); - else - part ("initial", DECL_INITIAL (node)); - } - } - else if (DECL_INITIAL (node)) - { - if ((int) (DECL_INITIAL (node)) == 1) - fprintf (outfile, " initial = const 1;"); - else - part ("initial", DECL_INITIAL (node)); - } -#ifdef PRINT_LANG_DECL - walk_lang_decl (node); -#endif - part ("chain", TREE_CHAIN (node)); - /* A Decl's chain contents is not part of the decl. */ - nochain = 1; - fputc ('\n', outfile); - cwalk (DECL_SIZE (node), node, indent); - walk (TREE_TYPE (node), node, indent); - walk (DECL_VOFFSET (node), node, indent); - walk (DECL_CONTEXT (node), node, indent); - if (code == FUNCTION_DECL) - { - walk (DECL_ARGUMENTS (node), node, indent); - walk (DECL_RESULT (node), node, indent); - } - if ((int) (DECL_INITIAL (node)) != 1) - walk (DECL_INITIAL (node), node, indent); - break; - - case 't': - prtypemodeinfo (node); - prtypeinfo (node); -#ifdef PRINT_LANG_TYPE - print_lang_type (node); -#endif - skip (indent); - part ("pointers_to_this", TYPE_POINTER_TO (node)); - if (code == ARRAY_TYPE || code == SET_TYPE) - { - part ("domain", TYPE_DOMAIN (node)); - cpart ("separation", TYPE_SEP (node), '*'); - fprintf (outfile, "%d;", TYPE_SEP_UNIT (node)); - } - else if (code == INTEGER_TYPE) - { - cpart ("min", TYPE_MIN_VALUE (node), ';'); - cpart ("max", TYPE_MAX_VALUE (node), ';'); - fprintf (outfile, "precision = %d;", TYPE_PRECISION (node)); - } - else if (code == ENUMERAL_TYPE) - { - cpart ("min", TYPE_MIN_VALUE (node), ';'); - cpart ("max", TYPE_MAX_VALUE (node), ';'); - part ("values", TYPE_VALUES (node)); - fprintf (outfile, "precision = %d;", TYPE_PRECISION (node)); - } - else if (code == REAL_TYPE) - { - fprintf (outfile, "precision = %d;", TYPE_PRECISION (node)); - } - else if (code == RECORD_TYPE - || code == UNION_TYPE) - { - part ("fields", TYPE_FIELDS (node)); - } - else if (code == FUNCTION_TYPE) - { - part ("arg_types", TYPE_ARG_TYPES (node)); - } - else if (code == METHOD_TYPE) - { - part ("arg_types", TYPE_ARG_TYPES (node)); - } -#ifdef PRINT_LANG_TYPE - walk_lang_type (node); -#endif - part ("chain", TREE_CHAIN (node)); - /* A type's chain's contents are not printed because the chain of types - is not part of the meaning of any particular type. */ - nochain = 1; - fputc ('\n', outfile); - cwalk (TYPE_SIZE (node), node, indent); - walk (TREE_TYPE (node), node, indent); - walk (TYPE_VALUES (node), node, indent); - walk (TYPE_SEP (node), node, indent); - walk (TYPE_POINTER_TO (node), node, indent); - walk (TYPE_REFERENCE_TO (node), node, indent); - break; - - case 'e': - case 'r': - prtypeinfo (node); - fputs (" ops =", outfile); - first_rtl = len = tree_code_length[(int) code]; - /* These kinds of nodes contain rtx's, not trees, - after a certain point. Print the rtx's as rtx's. */ - switch (code) - { - case SAVE_EXPR: - first_rtl = 1; - break; - case CALL_EXPR: - first_rtl = 2; - break; - case METHOD_CALL_EXPR: - first_rtl = 3; - break; - case WITH_CLEANUP_EXPR: - /* Should be defined to be 2. */ - first_rtl = 1; - break; - case RTL_EXPR: - first_rtl = 0; - } - for (i = 0; i < len; i++) - { - if (i >= first_rtl) - { - skip (indent); - if (TREE_OPERAND (node, i)) - print_rtl (outfile, TREE_OPERAND (node, i)); - else - fprintf (outfile, "(nil)"); - fprintf (outfile, "\n"); - } - else - { - fputs (" ", outfile); - wruid (TREE_OPERAND (node, i)); - fputs (";", outfile); - } - } - part ("chain", TREE_CHAIN (node)); - fputc ('\n', outfile); - walk (TREE_TYPE (node), node, indent); - for (i = 0; i < len && i < first_rtl; i++) - walk (TREE_OPERAND (node, i), node, indent); - break; - - case 's': - prtypeinfo (node); - fprintf (outfile, " at %s line %d;", - STMT_SOURCE_FILE (node), STMT_SOURCE_LINE (node)); - switch (TREE_CODE (node)) - { - case IF_STMT: - part ("cond", STMT_COND (node)); - part ("then", STMT_THEN (node)); - part ("else", STMT_ELSE (node)); - break; - - case LET_STMT: - case WITH_STMT: - part ("vars", STMT_VARS (node)); - part ("tags", STMT_TYPE_TAGS (node)); - part ("supercontext", STMT_SUPERCONTEXT (node)); - part ("bind_size", STMT_BIND_SIZE (node)); - part ("body", STMT_BODY (node)); - part ("subblocks", STMT_SUBBLOCKS (node)); - break; - - case CASE_STMT: - part ("case_index", STMT_CASE_INDEX (node)); - part ("case_list", STMT_CASE_LIST (node)); - break; - - default: - part ("body", STMT_BODY (node)); - break; - } - part ("chain", TREE_CHAIN (node)); - fputc ('\n', outfile); - walk (TREE_TYPE (node), node, indent); - switch (TREE_CODE (node)) - { - case IF_STMT: - walk (STMT_COND (node), node, indent); - walk (STMT_THEN (node), node, indent); - walk (STMT_ELSE (node), node, indent); - break; - - case LET_STMT: - case WITH_STMT: - walk (STMT_VARS (node), node, indent); - walk (STMT_TYPE_TAGS (node), node, indent); - walk (STMT_SUPERCONTEXT (node), node, indent); - walk (STMT_BIND_SIZE (node), node, indent); - walk (STMT_BODY (node), node, indent); - walk (STMT_SUBBLOCKS (node), node, indent); - break; - - case CASE_STMT: - walk (STMT_CASE_INDEX (node), node, indent); - walk (STMT_CASE_LIST (node), node, indent); - break; - - default: - walk (STMT_BODY (node), node, indent); - break; - } - break; - - case 'c': - switch (code) - { - case INTEGER_CST: - if (TREE_INT_CST_HIGH (node) == 0) - fprintf (outfile, " = %1u;", TREE_INT_CST_LOW (node)); - else if (TREE_INT_CST_HIGH (node) == -1 - && TREE_INT_CST_LOW (node) != 0) - fprintf (outfile, " = -%1u;", -TREE_INT_CST_LOW (node)); - else - fprintf (outfile, " = 0x%x%08x;", - TREE_INT_CST_HIGH (node), - TREE_INT_CST_LOW (node)); - break; - - case REAL_CST: -#ifndef REAL_IS_NOT_DOUBLE - fprintf (outfile, " = %e;", TREE_REAL_CST (node)); -#else - { - int i; - char *p = (char *) &TREE_REAL_CST (node); - fprintf (outfile, " = 0x"); - for (i = 0; i < sizeof TREE_REAL_CST (node); i++) - fprintf (outfile, "%02x", *p++); - fprintf (outfile, ";"); - } -#endif /* REAL_IS_NOT_DOUBLE */ - break; - - case COMPLEX_CST: - part ("realpart", TREE_REALPART (node)); - part ("imagpart", TREE_IMAGPART (node)); - walk (TREE_REALPART (node), node, indent); - walk (TREE_IMAGPART (node), node, indent); - break; - - case STRING_CST: - fprintf (outfile, " = \"%s\";", TREE_STRING_POINTER (node)); - } - prtypeinfo (node); - part ("chain", TREE_CHAIN (node)); - fputc ('\n', outfile); - walk (TREE_TYPE (node), node, indent); - break; - - case 'x': - if (code == IDENTIFIER_NODE) - { - fprintf (outfile, " = %s;\n", IDENTIFIER_POINTER (node)); - nochain = 1; - } - else if (code == TREE_LIST) - { - prtypeinfo (node); - part ("purpose", TREE_PURPOSE (node)); - part ("value", TREE_VALUE (node)); - part ("chain", TREE_CHAIN (node)); - fputc ('\n', outfile); - walk (TREE_TYPE (node), node, indent); - walk (TREE_PURPOSE (node), node, indent); - walk (TREE_VALUE (node), node, indent); - } - else if (code == TREE_VEC) - { - prtypeinfo (node); - len = TREE_VEC_LENGTH (node); - fprintf (outfile, "length = %d\n", len); - for (i = 0; i < len; i++) - { - fputs (" ", outfile); - wruid (TREE_VEC_ELT (node, i)); - fputs (";", outfile); - } - part ("chain", TREE_CHAIN (node)); - fputc ('\n', outfile); - walk (TREE_TYPE (node), node, indent); - for (i = 0; i < len; i++) - walk (TREE_VEC_ELT (node, i), node, indent); - } - else if (code == OP_IDENTIFIER) - { - prtypeinfo (node); - part ("op1", TREE_PURPOSE (node)); - part ("op2", TREE_VALUE (node)); - part ("chain", TREE_CHAIN (node)); - fputc ('\n', outfile); - walk (TREE_TYPE (node), node, indent); - walk (TREE_PURPOSE (node), node, indent); - walk (TREE_VALUE (node), node, indent); - } - else if (code == ERROR_MARK) - fputc ('\n', outfile); - else abort (); - - break; - - default: - abort (); - } /* switch */ - - if (TREE_CHAIN (node) != NULL && ! nochain) - dump (TREE_CHAIN (node), indent); -} diff --git a/gnu/usr.bin/g++/cc1plus/stab.def b/gnu/usr.bin/g++/cc1plus/stab.def deleted file mode 100644 index 57a6be62016d..000000000000 --- a/gnu/usr.bin/g++/cc1plus/stab.def +++ /dev/null @@ -1,171 +0,0 @@ -/* Table of DBX symbol codes for the GNU system. - Copyright (C) 1988 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 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. */ - -/* Global variable. Only the name is significant. - To find the address, look in the corresponding external symbol. */ -__define_stab (N_GSYM, 0x20, "GSYM") - -/* Function name for BSD Fortran. Only the name is significant. - To find the address, look in the corresponding external symbol. */ -__define_stab (N_FNAME, 0x22, "FNAME") - -/* Function name or text-segment variable for C. Value is its address. - Desc is supposedly starting line number, but GCC doesn't set it - and DBX seems not to miss it. */ -__define_stab (N_FUN, 0x24, "FUN") - -/* Data-segment variable with internal linkage. Value is its address. */ -__define_stab (N_STSYM, 0x26, "STSYM") - -/* BSS-segment variable with internal linkage. Value is its address. */ -__define_stab (N_LCSYM, 0x28, "LCSYM") - -/* Name of main routine. Only the name is significant. - This is not used in C. */ -__define_stab (N_MAIN, 0x2a, "MAIN") - -/* Register variable. Value is number of register. */ -__define_stab (N_RSYM, 0x40, "RSYM") - -/* Structure or union element. Value is offset in the structure. */ -__define_stab (N_SSYM, 0x60, "SSYM") - -/* Parameter variable. Value is offset from argument pointer. - (On most machines the argument pointer is the same as the frame pointer. */ -__define_stab (N_PSYM, 0xa0, "PSYM") - -/* Automatic variable in the stack. Value is offset from frame pointer. - Also used for type descriptions. */ -__define_stab (N_LSYM, 0x80, "LSYM") - -/* Alternate entry point. Value is its address. */ -__define_stab (N_ENTRY, 0xa4, "ENTRY") - -/* Name of main source file. - Value is starting text address of the compilation. */ -__define_stab (N_SO, 0x64, "SO") - -/* Name of sub-source file. - Value is starting text address of the compilation. */ -__define_stab (N_SOL, 0x84, "SOL") - -/* Line number in text segment. Desc is the line number; - value is corresponding address. */ -__define_stab (N_SLINE, 0x44, "SLINE") -/* Similar, for data segment. */ -__define_stab (N_DSLINE, 0x66, "DSLINE") -/* Similar, for bss segment. */ -__define_stab (N_BSLINE, 0x68, "BSLINE") - -/* Beginning of an include file. Only Sun uses this. - In an object file, only the name is significant. - The Sun linker puts data into some of the other fields. */ -__define_stab (N_BINCL, 0x82, "BINCL") -/* End of an include file. No name. - These two act as brackets around the file's output. - In an object file, there is no significant data in this entry. - The Sun linker puts data into some of the fields. */ -__define_stab (N_EINCL, 0xa2, "EINCL") -/* Place holder for deleted include file. - This appears only in output from the Sun linker. */ -__define_stab (N_EXCL, 0xc2, "EXCL") - -/* Beginning of lexical block. - The desc is the nesting level in lexical blocks. - The value is the address of the start of the text for the block. - The variables declared inside the block *precede* the N_LBRAC symbol. */ -__define_stab (N_LBRAC, 0xc0, "LBRAC") -/* End of a lexical block. Desc matches the N_LBRAC's desc. - The value is the address of the end of the text for the block. */ -__define_stab (N_RBRAC, 0xe0, "RBRAC") - -/* Begin named common block. Only the name is significant. */ -__define_stab (N_BCOMM, 0xe2, "BCOMM") -/* Begin named common block. Only the name is significant - (and it should match the N_BCOMM). */ -__define_stab (N_ECOMM, 0xe4, "ECOMM") -/* End common (local name): value is address. - I'm not sure how this is used. */ -__define_stab (N_ECOML, 0xe8, "ECOML") -/* Second symbol entry containing a length-value for the preceding entry. - The value is the length. */ -__define_stab (N_LENG, 0xfe, "LENG") - -/* Global symbol in Pascal. - Supposedly the value is its line number; I'm skeptical. */ -__define_stab (N_PC, 0x30, "PC") - -/* Modula-2 compilation unit. Can someone say what info it contains? */ -__define_stab (N_M2C, 0x42, "M2C") -/* Modula-2 scope information. Can someone say what info it contains? */ -__define_stab (N_SCOPE, 0xc4, "SCOPE") - -/* Sun's source-code browser stabs. ?? Don't know what the fields are. */ -__define_stab (N_BROWS, 0x48, "BROWS") - -/* GNU C++ exception stabs. */ - -/* GNU C++ exception variable. Name is variable name. */ -__define_stab (N_EHDECL, 0x50, "EHDECL") - -/* GNU C++ `catch' clause. Value is its address. Desc is nonzero if - this entry is immediately followed by a CAUGHT stab saying what exception - was caught. Multiple CAUGHT stabs means that multiple exceptions - can be caught here. If Desc is 0, it means all exceptions are caught - here. */ -__define_stab (N_CATCH, 0x54, "CATCH") - -/* The above information, in matrix format. - - STAB MATRIX - _________________________________________________ - | 00 - 1F are not dbx stab symbols | - | Entries with bits 01 set are external symbols | - | N_UNDEF | N_ABS | N_TEXT | N_DATA | - | N_BSS | N_COMM | | N_FN | - |_______________________________________________| - | 20 GSYM | 22 FNAME | 24 FUN | 26 STSYM | - | 28 LCSYM | 2A MAIN | 2C | 2E | - | 30 PC | 32 | 34 | 36 | - | 38 | 3A | 3C | 3E | - | 40 RSYM | 42 M2C | 44 SLINE | 46 | - | 48 BROWS | 4A | 4C | 4E | - | 50 EHDECL | 52 | 54 CATCH | 56 | - | 58 | 5A | 5C | 5E | - | 60 SSYM | 62 | 64 SO | 66 DSLINE | - | 68 BSLINE | 6A | 6C | 6E | - | 70 | 72 | 74 | 76 | - | 78 | 7A | 7C | 7E | - | 80 LSYM | 82 BINCL | 84 SOL | 86 | - | 88 | 8A | 8C | 8E | - | 90 | 92 | 94 | 96 | - | 98 | 9A | 9C | 9E | - | A0 PSYM | A2 EINCL | A4 ENTRY | A6 | - | A8 | AA | AC | AE | - | B0 | B2 | B4 | B6 | - | B8 | BA | BC | BE | - | C0 LBRAC | C2 EXCL | C4 SCOPE | C6 | - | C8 | CA | CC | CE | - | D0 | D2 | D4 | D6 | - | D8 | DA | DC | DE | - | E0 RBRAC | E2 BCOMM | E4 ECOMM | E6 | - | E8 ECOML | EA | EC | EE | - | F0 | F2 | F4 | F6 | - | F8 | FA | FC | FE LENG | - +-----------------------------------------------+ - -*/ diff --git a/gnu/usr.bin/g++/cc1plus/stab.h b/gnu/usr.bin/g++/cc1plus/stab.h deleted file mode 100644 index 77f2d411ce34..000000000000 --- a/gnu/usr.bin/g++/cc1plus/stab.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __GNU_STAB__ - -/* Indicate the GNU stab.h is in use. */ - -#define __GNU_STAB__ - -#define __define_stab(NAME, CODE, STRING) NAME=CODE, - -enum __stab_debug_code -{ -#include "stab.def" -}; - -#undef __define_stab - -#endif /* __GNU_STAB_ */ diff --git a/gnu/usr.bin/g++/cc1plus/stack.h b/gnu/usr.bin/g++/cc1plus/stack.h deleted file mode 100644 index 8f3401d7ca55..000000000000 --- a/gnu/usr.bin/g++/cc1plus/stack.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Stack of data placed on obstacks. */ - -struct stack_level -{ - /* Pointer back to previous such level. */ - struct stack_level *prev; - - /* Point to obstack we should return to. */ - struct obstack *obstack; - - /* First place we start putting data. */ - tree *first; - - /* Number of entries we can have from `first'. - Right now we are dumb: if we overflow, abort. */ - int limit; -}; - -struct stack_level *push_stack_level (); -struct stack_level *pop_stack_level (); - diff --git a/gnu/usr.bin/g++/cc1plus/stmt.c b/gnu/usr.bin/g++/cc1plus/stmt.c deleted file mode 100644 index 25a2a651322c..000000000000 --- a/gnu/usr.bin/g++/cc1plus/stmt.c +++ /dev/null @@ -1,4929 +0,0 @@ -/* Expands front end tree to back end RTL for GNU C-Compiler - Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file handles the generation of rtl code from tree structure - above the level of expressions, using subroutines in exp*.c and emit-rtl.c. - It also creates the rtl expressions for parameters and auto variables - and has full responsibility for allocating stack slots. - - The functions whose names start with `expand_' are called by the - parser to generate RTL instructions for various kinds of constructs. - - Some control and binding constructs require calling several such - functions at different times. For example, a simple if-then - is expanded by calling `expand_start_cond' (with the condition-expression - as argument) before parsing the then-clause and calling `expand_end_cond' - after parsing the then-clause. - - `expand_function_start' is called at the beginning of a function, - before the function body is parsed, and `expand_function_end' is - called after parsing the body. - - Call `assign_stack_local' to allocate a stack slot for a local variable. - This is usually done during the RTL generation for the function body, - but it can also be done in the reload pass when a pseudo-register does - not get a hard register. - - Call `put_var_into_stack' when you learn, belatedly, that a variable - previously given a pseudo-register must in fact go in the stack. - This function changes the DECL_RTL to be a stack slot instead of a reg - then scans all the RTL instructions so far generated to correct them. */ - -#include "config.h" - -#include - -#include "rtl.h" -#include "tree.h" -#include "flags.h" -#include "insn-flags.h" -#include "insn-config.h" -#include "insn-codes.h" -#include "expr.h" -#include "regs.h" -#include "hard-reg-set.h" -#include "recog.h" -#include "obstack.h" - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free -struct obstack stmt_obstack; - -extern int xmalloc (); -extern void free (); - -#define MAX(x,y) (((x) > (y)) ? (x) : (y)) -#define MIN(x,y) (((x) < (y)) ? (x) : (y)) - -/* Nonzero if function being compiled pops its args on return. - May affect compilation of return insn or of function epilogue. */ - -int current_function_pops_args; - -/* Nonzero if function being compiled needs to be given an address - where the value should be stored. */ - -int current_function_returns_struct; - -/* Nonzero if function being compiled needs to - return the address of where it has put a structure value. */ - -int current_function_returns_pcc_struct; - -/* Nonzero if function being compiled needs to be passed a static chain. */ - -int current_function_needs_context; - -/* Nonzero if function being compiled can call setjmp. */ - -int current_function_calls_setjmp; - -/* Nonzero if function being compiled can call alloca, - either as a subroutine or builtin. */ - -int current_function_calls_alloca; - -/* Nonzero if the current function returns a pointer type */ - -int current_function_returns_pointer; - -/* If function's args have a fixed size, this is that size, in bytes. - Otherwise, it is -1. - May affect compilation of return insn or of function epilogue. */ - -int current_function_args_size; - -/* # bytes the prologue should push and pretend that the caller pushed them. - The prologue must do this, but only if parms can be passed in registers. */ - -int current_function_pretend_args_size; - -/* Name of function now being compiled. */ - -char *current_function_name; - -/* Label that will go on parm cleanup code, if any. - Jumping to this label runs cleanup code for parameters, if - such code must be run. Following this code is the logical return label. */ - -rtx cleanup_label; - -/* Label that will go on function epilogue. - Jumping to this label serves as a "return" instruction - on machines which require execution of the epilogue on all returns. */ - -rtx return_label; - -/* List (chain of EXPR_LISTs) of pseudo-regs of SAVE_EXPRs. - So we can mark them all live at the end of the function, if nonopt. */ -rtx save_expr_regs; - -/* List (chain of EXPR_LISTs) of all stack slots in this function. - Made for the sake of unshare_all_rtl. */ -rtx stack_slot_list; - -/* Filename and line number of last line-number note, - whether we actually emitted it or not. */ -char *emit_filename; -int emit_lineno; - -/* Insn after which register parms and SAVE_EXPRs are born, if nonopt. */ -static rtx parm_birth_insn; - -/* The FUNCTION_DECL node for the function being compiled. */ - -static tree this_function; - -/* Offset to end of allocated area of stack frame. - If stack grows down, this is the address of the last stack slot allocated. - If stack grows up, this is the address for the next slot. */ -static int frame_offset; - -/* Nonzero if a stack slot has been generated whose address is not - actually valid. It means that the generated rtl must all be scanned - to detect and correct the invalid addresses where they occur. */ -static int invalid_stack_slot; - -/* Label to jump back to for tail recursion, or 0 if we have - not yet needed one for this function. */ -static rtx tail_recursion_label; - -/* Place after which to insert the tail_recursion_label if we need one. */ -static rtx tail_recursion_reentry; - -/* Each time we expand an expression-statement, - record the expr's type and its RTL value here. */ - -static tree last_expr_type; -static rtx last_expr_value; - -/* Number of binding contours started so far in this function. */ - -int block_start_count; - -/* Chain of all RTL_EXPRs that have insns in them. */ -static tree rtl_expr_chain; - -/* Last insn of those whose job was to put parms into their nominal homes. */ -static rtx last_parm_insn; - -/* Cleanup lists are required for binding levels regardless of whether - that binding level has cleanups or not. This node satisfies that - need for all binding levels. */ -static tree empty_cleanup_list; - -/* Functions and data structures for expanding case statements. */ - -/* Case label structure, used to hold info on labels within case - statements. We handle "range" labels; for a single-value label - as in C, the high and low limits are the same. */ - -struct case_node -{ - struct case_node *left; - struct case_node *right; - struct case_node *parent; - tree low; - tree high; - tree test_label; - tree code_label; -}; - -typedef struct case_node case_node; -typedef struct case_node *case_node_ptr; - -extern void balance_case_nodes (); -extern void emit_case_nodes (); -extern void group_case_nodes (); -extern void emit_jump_if_reachable (); - -/* Stack of control and binding constructs we are currently inside. - - These constructs begin when you call `expand_start_WHATEVER' - and end when you call `expand_end_WHATEVER'. This stack records - info about how the construct began that tells the end-function - what to do. It also may provide information about the construct - to alter the behavior of other constructs within the body. - For example, they may affect the behavior of C `break' and `continue'. - - Each construct gets one `struct nesting' object. - All of these objects are chained through the `all' field. - `nesting_stack' points to the first object (innermost construct). - The position of an entry on `nesting_stack' is in its `depth' field. - - Each type of construct has its own individual stack. - For example, loops have `loop_stack'. Each object points to the - next object of the same type through the `next' field. - - Some constructs are visible to `break' exit-statements and others - are not. Which constructs are visible depends on the language. - Therefore, the data structure allows each construct to be visible - or not, according to the args given when the construct is started. - The construct is visible if the `exit_label' field is non-null. - In that case, the value should be a CODE_LABEL rtx. */ - -struct nesting -{ - struct nesting *all; - struct nesting *next; - int depth; - rtx exit_label; - union - { - /* For conds (if-then and if-then-else statements). */ - struct - { - /* Label on the else-part, if any, else 0. */ - rtx else_label; - /* Label at the end of the whole construct. */ - rtx after_label; - } cond; - /* For loops. */ - struct - { - /* Label at the top of the loop; place to loop back to. */ - rtx start_label; - /* Label at the end of the whole construct. */ - rtx end_label; - /* Label for `continue' statement to jump to; - this is in front of the stepper of the loop. */ - rtx continue_label; - } loop; - /* For variable binding contours. */ - struct - { - /* Sequence number of this binding contour within the function, - in order of entry. */ - int block_start_count; - /* Nonzero => value to restore stack to on exit. */ - rtx stack_level; - /* The NOTE that starts this contour. - Used by expand_goto to check whether the destination - is within each contour or not. */ - rtx first_insn; - /* Innermost containing binding contour that has a stack level. */ - struct nesting *innermost_stack_block; - /* List of cleanups to be run on exit from this contour. - This is a list of expressions to be evaluated. - The TREE_PURPOSE of each link is the ..._DECL node - which the cleanup pertains to. */ - tree cleanups; - /* List of cleanup-lists of blocks containing this block, - as they were at the locus where this block appears. - There is an element for each containing block, - ordered innermost containing block first, once there are - any cleanups at all. - The element's TREE_VALUE is the cleanup-list of that block, - which may be null. */ - tree outer_cleanups; - /* Chain of labels defined inside this binding contour. - For contours that have stack levels or cleanups. */ - struct label_chain *label_chain; - } block; - /* For switch (C) or case (Pascal) statements, - and also for dummies (see `expand_start_case_dummy'). */ - struct - { - /* The insn after which the case dispatch should finally - be emitted. Zero for a dummy. */ - rtx start; - /* A list of case labels, kept in ascending order by value - as the list is built. - During expand_end_case, this list may be rearranged into a - nearly balanced binary tree. */ - struct case_node *case_list; - /* Label to jump to if no case matches. */ - tree default_label; - /* The expression to be dispatched on. */ - tree index_expr; - /* Type that INDEX_EXPR should be converted to. */ - tree nominal_type; - /* Number of range exprs in case statement. */ - short num_ranges; - } case_stmt; - /* For exception contours. */ - struct - { - /* List of exceptions raised. This is a TREE_LIST - of whatever you want. */ - tree raised; - /* List of exceptions caught. This is also a TREE_LIST - of whatever you want. As a special case, it has the - value `void_type_node' if it handles default exceptions. */ - tree handled; - - /* First insn of TRY block, in case resumptive model is needed. */ - rtx first_insn; - /* Label for the catch clauses. */ - rtx except_label; - /* Label for unhandled exceptions. */ - rtx unhandled_label; - /* Label at the end of whole construct. */ - rtx after_label; - /* Label which "escapes" the exception construct. - Like EXIT_LABEL for BREAK construct, but for exceptions. */ - rtx escape_label; - } except_stmt; - } data; -}; - -/* Chain of all pending binding contours. */ -struct nesting *block_stack; - -/* Chain of all pending binding contours that restore stack levels - or have cleanups. */ -struct nesting *stack_block_stack; - -/* Chain of all pending conditional statements. */ -struct nesting *cond_stack; - -/* Chain of all pending loops. */ -struct nesting *loop_stack; - -/* Chain of all pending case or switch statements. */ -struct nesting *case_stack; - -/* Chain of all pending exception contours. */ -struct nesting *except_stack; - -/* Separate chain including all of the above, - chained through the `all' field. */ -struct nesting *nesting_stack; - -/* Number of entries on nesting_stack now. */ -int nesting_depth; - -/* Pop one of the sub-stacks, such as `loop_stack' or `cond_stack'; - and pop off `nesting_stack' down to the same level. */ - -#define POPSTACK(STACK) \ -do { int initial_depth = nesting_stack->depth; \ - do { struct nesting *this = STACK; \ - STACK = this->next; \ - nesting_stack = this->all; \ - nesting_depth = this->depth; \ - obstack_free (&stmt_obstack, this); } \ - while (nesting_depth > initial_depth); } while (0) - -static int warn_if_unused_value (); -static void expand_goto_internal (); -static int expand_fixup (); -static void fixup_gotos (); -static void expand_cleanups (); -static void fixup_cleanups (); -static void expand_null_return_1 (); -static int tail_recursion_args (); -static void fixup_stack_slots (); -static rtx fixup_stack_1 (); -static rtx fixup_memory_subreg (); -static rtx walk_fixup_memory_subreg (); -static void fixup_var_refs (); -static void fixup_var_refs_insns (); -static rtx fixup_var_refs_1 (); -static rtx parm_stack_loc (); -static void optimize_bit_field (); -static void do_jump_if_equal (); - -/* Emit a no-op instruction. */ - -rtx -emit_nop () -{ - rtx last_insn = get_last_insn (); - if (!optimize - && (GET_CODE (last_insn) == CODE_LABEL - || prev_real_insn (last_insn) == 0)) - emit_insn (gen_nop ()); -} - -/* Return the rtx-label that corresponds to a LABEL_DECL, - creating it if necessary. */ - -rtx /* @@ non-static for case.c. */ -label_rtx (label) - tree label; -{ - if (TREE_CODE (label) != LABEL_DECL) - abort (); - - if (DECL_RTL (label)) - return DECL_RTL (label); - - return DECL_RTL (label) = gen_label_rtx (); -} - -/* Add an unconditional jump to LABEL as the next sequential instruction. */ - -void -emit_jump (label) - rtx label; -{ - do_pending_stack_adjust (); - emit_jump_insn (gen_jump (label)); - emit_barrier (); -} - -/* Handle goto statements and the labels that they can go to. */ - -/* In some cases it is impossible to generate code for a forward goto - until the label definition is seen. This happens when it may be necessary - for the goto to reset the stack pointer: we don't yet know how to do that. - So expand_goto puts an entry on this fixup list. - Each time a binding contour that resets the stack is exited, - we check each fixup. - If the target label has now been defined, we can insert the proper code. */ - -struct goto_fixup -{ - /* Points to following fixup. */ - struct goto_fixup *next; - /* Points to the insn before the jump insn. - If more code must be inserted, it goes after this insn. */ - rtx before_jump; - /* The LABEL_DECL that this jump is jumping to, or 0 - for break, continue or return. */ - tree target; - /* The CODE_LABEL rtx that this is jumping to. */ - rtx target_rtl; - /* Number of binding contours started in current function - before the label reference. */ - int block_start_count; - /* The outermost stack level that should be restored for this jump. - Each time a binding contour that resets the stack is exited, - if the target label is *not* yet defined, this slot is updated. */ - rtx stack_level; - /* List of lists of cleanup expressions to be run by this goto. - There is one element for each block that this goto is within, - once there are any cleanups at all. - The TREE_VALUE contains the cleanup list of that block as of the - time this goto was seen. - The TREE_ADDRESSABLE flag is 1 for a block that has been exited. */ - tree cleanup_list_list; -}; - -static struct goto_fixup *goto_fixup_chain; - -/* Within any binding contour that must restore a stack level, - all labels are recorded with a chain of these structures. */ - -struct label_chain -{ - /* Points to following fixup. */ - struct label_chain *next; - tree label; -}; - -/* Specify the location in the RTL code of a label BODY, - which is a LABEL_DECL tree node. - - This is used for the kind of label that the user can jump to with a - goto statement, and for alternatives of a switch or case statement. - RTL labels generated for loops and conditionals don't go through here; - they are generated directly at the RTL level, by other functions below. - - Note that this has nothing to do with defining label *names*. - Languages vary in how they do that and what that even means. */ - -void -expand_label (body) - tree body; -{ - struct label_chain *p; - - do_pending_stack_adjust (); - emit_label (label_rtx (body)); - - if (stack_block_stack != 0) - { - p = (struct label_chain *) oballoc (sizeof (struct label_chain)); - p->next = stack_block_stack->data.block.label_chain; - stack_block_stack->data.block.label_chain = p; - p->label = body; - } -} - -/* Generate RTL code for a `goto' statement with target label BODY. - BODY should be a LABEL_DECL tree node that was or will later be - defined with `expand_label'. */ - -void -expand_goto (body) - tree body; -{ - expand_goto_internal (body, label_rtx (body), 0); -} - -/* Generate RTL code for a `goto' statement with target label BODY. - LABEL should be a LABEL_REF. - LAST_INSN, if non-0, is the rtx we should consider as the last - insn emitted (for the purposes of cleaning up a return). */ - -static void -expand_goto_internal (body, label, last_insn) - tree body; - rtx label; - rtx last_insn; -{ - struct nesting *block; - rtx stack_level = 0; - - if (GET_CODE (label) != CODE_LABEL) - abort (); - - /* If label has already been defined, we can tell now - whether and how we must alter the stack level. */ - - if (PREV_INSN (label) != 0) - { - /* Find the innermost pending block that contains the label. - (Check containment by comparing insn-uids.) - Then restore the outermost stack level within that block, - and do cleanups of all blocks contained in it. */ - for (block = block_stack; block; block = block->next) - { - if (INSN_UID (block->data.block.first_insn) < INSN_UID (label)) - break; - if (block->data.block.stack_level != 0) - stack_level = block->data.block.stack_level; - /* Execute the cleanups for blocks we are exiting. */ - if (block->data.block.cleanups != 0) - { - expand_cleanups (block->data.block.cleanups, 0); - do_pending_stack_adjust (); - } - } - - if (stack_level) - emit_move_insn (stack_pointer_rtx, stack_level); - - if (body != 0 && TREE_PACKED (body)) - error ("jump to `%s' invalidly jumps into binding contour", - IDENTIFIER_POINTER (DECL_NAME (body))); - } - /* Label not yet defined: may need to put this goto - on the fixup list. */ - else if (! expand_fixup (body, label, last_insn)) - { - /* No fixup needed. Record that the label is the target - of at least one goto that has no fixup. */ - if (body != 0) - TREE_ADDRESSABLE (body) = 1; - } - - emit_jump (label); -} - -/* Return truth-value of whether there are any cleanups from - the current binding contour to the end of the current function's - binding contours. */ -int -any_pending_cleanups () -{ - struct nesting *block; - - if (block_stack->data.block.cleanups == 0 - || block_stack->data.block.outer_cleanups == empty_cleanup_list) - return 0; - - for (block = block_stack->next; block; block = block->next) - if (block->data.block.cleanups != 0) - break; - - return block != 0; -} - -/* Generate if necessary a fixup for a goto - whose target label in tree structure (if any) is TREE_LABEL - and whose target in rtl is RTL_LABEL. - - If LAST_INSN is nonzero, we pretend that the jump appears - after insn LAST_INSN instead of at the current point in the insn stream. - - The fixup will be used later to insert insns at this point - to restore the stack level as appropriate for the target label. - - Value is nonzero if a fixup is made. */ - -static int -expand_fixup (tree_label, rtl_label, last_insn) - tree tree_label; - rtx rtl_label; - rtx last_insn; -{ - struct nesting *block, *end_block; - - /* See if we can recognize which block the label will be output in. - This is possible in some very common cases. - If we succeed, set END_BLOCK to that block. - Otherwise, set it to 0. */ - - if (cond_stack - && (rtl_label == cond_stack->data.cond.else_label - || rtl_label == cond_stack->data.cond.after_label)) - end_block = cond_stack; - /* If we are in a loop, recognize certain labels which - are likely targets. This reduces the number of fixups - we need to create. */ - else if (loop_stack - && (rtl_label == loop_stack->data.loop.start_label - || rtl_label == loop_stack->data.loop.end_label - || rtl_label == loop_stack->data.loop.continue_label)) - end_block = loop_stack; - else - end_block = 0; - - /* Now set END_BLOCK to the binding level to which we will return. */ - - if (end_block) - { - struct nesting *next_block = end_block->all; - block = block_stack; - - /* First see if the END_BLOCK is inside the innermost binding level. - If so, then no cleanups or stack levels are relevant. */ - while (next_block && next_block != block) - next_block = next_block->all; - - if (next_block) - return 0; - - /* Otherwise, set END_BLOCK to the innermost binding level - which is outside the relevant control-structure nesting. */ - next_block = block_stack->next; - for (block = block_stack; block != end_block; block = block->all) - if (block == next_block) - next_block = next_block->next; - end_block = next_block; - } - - /* Does any containing block have a stack level or cleanups? - If not, no fixup is needed, and that is the normal case - (the only case, for standard C). */ - for (block = block_stack; block != end_block; block = block->next) - if (block->data.block.stack_level != 0 - || block->data.block.cleanups != 0) - break; - - if (block != end_block) - { - /* Ok, a fixup is needed. Add a fixup to the list of such. */ - struct goto_fixup *fixup - = (struct goto_fixup *) oballoc (sizeof (struct goto_fixup)); - /* In case an old stack level is restored, make sure that comes - after any pending stack adjust. */ - do_pending_stack_adjust (); - fixup->before_jump = last_insn ? last_insn : get_last_insn (); - fixup->target = tree_label; - fixup->target_rtl = rtl_label; - fixup->block_start_count = block_start_count; - fixup->stack_level = 0; - fixup->cleanup_list_list - = (((block->data.block.outer_cleanups - && block->data.block.outer_cleanups != empty_cleanup_list) - || block->data.block.cleanups) - ? tree_cons (0, block->data.block.cleanups, - block->data.block.outer_cleanups) - : 0); - fixup->next = goto_fixup_chain; - goto_fixup_chain = fixup; - } - - return block != 0; -} - -/* When exiting a binding contour, process all pending gotos requiring fixups. - THISBLOCK is the structure that describes the block being exited. - STACK_LEVEL is the rtx for the stack level to restore exiting this contour. - CLEANUP_LIST is a list of expressions to evaluate on exiting this contour. - FIRST_INSN is the insn that began this contour. - - Gotos that jump out of this contour must restore the - stack level and do the cleanups before actually jumping. - - DONT_JUMP_IN nonzero means report error there is a jump into this - contour from before the beginning of the contour. - This is also done if STACK_LEVEL is nonzero. */ - -static void -fixup_gotos (thisblock, stack_level, cleanup_list, first_insn, dont_jump_in) - struct nesting *thisblock; - rtx stack_level; - tree cleanup_list; - rtx first_insn; - int dont_jump_in; -{ - register struct goto_fixup *f, *prev; - - /* F is the fixup we are considering; PREV is the previous one. */ - - for (prev = 0, f = goto_fixup_chain; f; prev = f, f = f->next) - { - /* Test for a fixup that is inactive because it is already handled. */ - if (f->before_jump == 0) - { - /* Delete inactive fixup from the chain, if that is easy to do. */ - if (prev != 0) - prev->next = f->next; - } - /* Has this fixup's target label been defined? - If so, we can finalize it. */ - else if (PREV_INSN (f->target_rtl) != 0) - { - /* If this fixup jumped into this contour from before the beginning - of this contour, report an error. */ - /* ??? Bug: this does not detect jumping in through intermediate - blocks that have stack levels or cleanups. - It detects only a problem with the innermost block - around the label. */ - if (f->target != 0 - && (dont_jump_in || stack_level || cleanup_list) - && INSN_UID (first_insn) > INSN_UID (f->before_jump) - && ! TREE_ADDRESSABLE (f->target)) - { - error_with_decl (f->target, - "label `%s' used before containing binding contour"); - /* Prevent multiple errors for one label. */ - TREE_ADDRESSABLE (f->target) = 1; - } - - /* Execute cleanups for blocks this jump exits. */ - if (f->cleanup_list_list) - { - tree lists; - for (lists = f->cleanup_list_list; lists; lists = TREE_CHAIN (lists)) - /* Marked elements correspond to blocks that have been closed. - Do their cleanups. */ - if (TREE_ADDRESSABLE (lists) - && TREE_VALUE (lists) != 0) - fixup_cleanups (TREE_VALUE (lists), &f->before_jump); - } - - /* Restore stack level for the biggest contour that this - jump jumps out of. */ - if (f->stack_level) - emit_insn_after (gen_move_insn (stack_pointer_rtx, f->stack_level), - f->before_jump); - f->before_jump = 0; - } - /* Label has still not appeared. If we are exiting a block with - a stack level to restore, that started before the fixup, - mark this stack level as needing restoration - when the fixup is later finalized. - Also mark the cleanup_list_list element for F - that corresponds to this block, so that ultimately - this block's cleanups will be executed by the code above. */ - /* Note: if THISBLOCK == 0 and we have a label that hasn't appeared, - it means the label is undefined. That's erroneous, but possible. */ - else if (thisblock != 0 - && (thisblock->data.block.block_start_count - < f->block_start_count)) - { - tree lists = f->cleanup_list_list; - for (; lists; lists = TREE_CHAIN (lists)) - /* If the following elt. corresponds to our containing block - then the elt. must be for this block. */ - if (TREE_CHAIN (lists) == thisblock->data.block.outer_cleanups) - TREE_ADDRESSABLE (lists) = 1; - - if (stack_level) - f->stack_level = stack_level; - } - } -} - -/* Generate RTL for an asm statement (explicit assembler code). - BODY is a STRING_CST node containing the assembler code text. */ - -void -expand_asm (body) - tree body; -{ - emit_insn (gen_rtx (ASM_INPUT, VOIDmode, - TREE_STRING_POINTER (body))); - last_expr_type = 0; -} - -/* Generate RTL for an asm statement with arguments. - STRING is the instruction template. - OUTPUTS is a list of output arguments (lvalues); INPUTS a list of inputs. - Each output or input has an expression in the TREE_VALUE and - a constraint-string in the TREE_PURPOSE. - CLOBBERS is a list of STRING_CST nodes each naming a hard register - that is clobbered by this insn. - - Not all kinds of lvalue that may appear in OUTPUTS can be stored directly. - Some elements of OUTPUTS may be replaced with trees representing temporary - values. The caller should copy those temporary values to the originally - specified lvalues. - - VOL nonzero means the insn is volatile; don't optimize it. */ - -void -expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line) - tree string, outputs, inputs, clobbers; - int vol; - char *filename; - int line; -{ - rtvec argvec, constraints; - rtx body; - int ninputs = list_length (inputs); - int noutputs = list_length (outputs); - int nclobbers = list_length (clobbers); - tree tail; - register int i; - /* Vector of RTX's of evaluated output operands. */ - rtx *output_rtx = (rtx *) alloca (noutputs * sizeof (rtx)); - /* The insn we have emitted. */ - rtx insn; - - last_expr_type = 0; - - for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++) - { - tree val = TREE_VALUE (tail); - int j; - int found_equal; - - /* If there's an erroneous arg, emit no insn. */ - if (TREE_TYPE (val) == error_mark_node) - return; - - /* Make sure constraint has `=' and does not have `+'. */ - - found_equal = 0; - for (j = 0; j < TREE_STRING_LENGTH (TREE_PURPOSE (tail)); j++) - { - if (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '+') - { - error ("output operand constraint contains `+'"); - return; - } - if (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '=') - found_equal = 1; - } - if (! found_equal) - { - error ("output operand constraint lacks `='"); - return; - } - - /* If an output operand is not a variable or indirect ref, - create a SAVE_EXPR which is a pseudo-reg - to act as an intermediate temporary. - Make the asm insn write into that, then copy it to - the real output operand. */ - - if (TREE_CODE (val) != VAR_DECL - && TREE_CODE (val) != PARM_DECL - && TREE_CODE (val) != INDIRECT_REF) - { - rtx reg = gen_reg_rtx (TYPE_MODE (TREE_TYPE (val))); - /* `build' isn't safe; it really expects args to be trees. */ - tree t = build_nt (SAVE_EXPR, val, reg); - - save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, reg, save_expr_regs); - TREE_VALUE (tail) = t; - TREE_TYPE (t) = TREE_TYPE (val); - } - output_rtx[i] = expand_expr (TREE_VALUE (tail), 0, VOIDmode, 0); - } - - if (ninputs + noutputs > MAX_RECOG_OPERANDS) - { - error ("more than %d operands in `asm'", MAX_RECOG_OPERANDS); - return; - } - - /* Make vectors for the expression-rtx and constraint strings. */ - - argvec = rtvec_alloc (ninputs); - constraints = rtvec_alloc (ninputs); - - body = gen_rtx (ASM_OPERANDS, VOIDmode, - TREE_STRING_POINTER (string), "", 0, argvec, constraints, - filename, line); - MEM_VOLATILE_P (body) = vol; - - /* Eval the inputs and put them into ARGVEC. - Put their constraints into ASM_INPUTs and store in CONSTRAINTS. */ - - i = 0; - for (tail = inputs; tail; tail = TREE_CHAIN (tail)) - { - int j; - - /* If there's an erroneous arg, emit no insn, - because the ASM_INPUT would get VOIDmode - and that could cause a crash in reload. */ - if (TREE_TYPE (TREE_VALUE (tail)) == error_mark_node) - return; - if (TREE_PURPOSE (tail) == NULL_TREE) - { - error ("hard register `%s' listed as input operand to `asm'", - TREE_STRING_POINTER (TREE_VALUE (tail)) ); - return; - } - - /* Make sure constraint has neither `=' nor `+'. */ - - for (j = 0; j < TREE_STRING_LENGTH (TREE_PURPOSE (tail)); j++) - if (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '=' - || TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] == '+') - { - error ("input operand constraint contains `%c'", - TREE_STRING_POINTER (TREE_PURPOSE (tail))[j]); - return; - } - - XVECEXP (body, 3, i) /* argvec */ - = expand_expr (TREE_VALUE (tail), 0, VOIDmode, 0); - XVECEXP (body, 4, i) /* constraints */ - = gen_rtx (ASM_INPUT, TYPE_MODE (TREE_TYPE (TREE_VALUE (tail))), - TREE_STRING_POINTER (TREE_PURPOSE (tail))); - i++; - } - - /* Protect all the operands from the queue, - now that they have all been evaluated. */ - - for (i = 0; i < ninputs; i++) - XVECEXP (body, 3, i) = protect_from_queue (XVECEXP (body, 3, i), 0); - - for (i = 0; i < noutputs; i++) - output_rtx[i] = protect_from_queue (output_rtx[i], 1); - - /* Now, for each output, construct an rtx - (set OUTPUT (asm_operands INSN OUTPUTNUMBER OUTPUTCONSTRAINT - ARGVEC CONSTRAINTS)) - If there is more than one, put them inside a PARALLEL. */ - - if (noutputs == 1 && nclobbers == 0) - { - XSTR (body, 1) = TREE_STRING_POINTER (TREE_PURPOSE (outputs)); - insn = emit_insn (gen_rtx (SET, VOIDmode, output_rtx[0], body)); - } - else if (noutputs == 0 && nclobbers == 0) - { - /* No output operands: put in a raw ASM_OPERANDS rtx. */ - insn = emit_insn (body); - } - else - { - rtx obody = body; - int num = noutputs; - if (num == 0) num = 1; - body = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (num + nclobbers)); - - /* For each output operand, store a SET. */ - - for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++) - { - XVECEXP (body, 0, i) - = gen_rtx (SET, VOIDmode, - output_rtx[i], - gen_rtx (ASM_OPERANDS, VOIDmode, - TREE_STRING_POINTER (string), - TREE_STRING_POINTER (TREE_PURPOSE (tail)), - i, argvec, constraints, - filename, line)); - MEM_VOLATILE_P (SET_SRC (XVECEXP (body, 0, i))) = vol; - } - - /* If there are no outputs (but there are some clobbers) - store the bare ASM_OPERANDS into the PARALLEL. */ - - if (i == 0) - XVECEXP (body, 0, i++) = obody; - - /* Store (clobber REG) for each clobbered register specified. */ - - for (tail = clobbers; tail; tail = TREE_CHAIN (tail), i++) - { - int j; - char *regname = TREE_STRING_POINTER (TREE_VALUE (tail)); - extern char *reg_names[]; - - for (j = 0; j < FIRST_PSEUDO_REGISTER; j++) - if (!strcmp (regname, reg_names[j])) - break; - - if (j == FIRST_PSEUDO_REGISTER) - { - error ("unknown register name `%s' in `asm'", regname); - return; - } - - /* Use QImode since that's guaranteed to clobber just one reg. */ - XVECEXP (body, 0, i) - = gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, QImode, j)); - } - - insn = emit_insn (body); - } - - last_expr_type = 0; -} - -/* Nonzero if within a ({...}) grouping, in which case we must - always compute a value for each expr-stmt in case it is the last one. */ - -int expr_stmts_for_value; - -/* Generate RTL to evaluate the expression EXP - and remember it in case this is the VALUE in a ({... VALUE; }) constr. */ - -void -expand_expr_stmt (exp) - tree exp; -{ - /* If -W, warn about statements with no side effects, - except for statements explicitly casted to void (e.g. for assert()), and - except inside a ({...}) where they may be useful. */ - if (expr_stmts_for_value == 0 && exp != error_mark_node) - { - if (! TREE_VOLATILE (exp) - && !(TREE_CODE (exp) == CONVERT_EXPR - && TREE_TYPE (exp) == void_type_node) - && (extra_warnings || warn_unused)) - warning_with_file_and_line (emit_filename, emit_lineno, - "statement with no effect"); - else if (warn_unused) - warn_if_unused_value (exp); - } - last_expr_type = TREE_TYPE (exp); - if (! flag_syntax_only) - last_expr_value = expand_expr (exp, expr_stmts_for_value ? 0 : const0_rtx, - VOIDmode, 0); - emit_queue (); -} - -/* Warn if EXP contains any computations whose results are not used. - Return 1 if a warning is printed; 0 otherwise. */ - -static int -warn_if_unused_value (exp) - tree exp; -{ - switch (TREE_CODE (exp)) - { - case PREINCREMENT_EXPR: - case POSTINCREMENT_EXPR: - case PREDECREMENT_EXPR: - case POSTDECREMENT_EXPR: - case MODIFY_EXPR: - case INIT_EXPR: - case NEW_EXPR: - case CALL_EXPR: - case METHOD_CALL_EXPR: - case RTL_EXPR: - case WRAPPER_EXPR: - case ANTI_WRAPPER_EXPR: - case WITH_CLEANUP_EXPR: - /* We don't warn about COND_EXPR because it may be a useful - construct if either arm contains a side effect. */ - case COND_EXPR: - return 0; - - /* These kinds of exprs are really stmts. What to do? */ - case LOOP_STMT: - case LET_STMT: - case IF_STMT: - return 0; - - case TRUTH_ORIF_EXPR: - case TRUTH_ANDIF_EXPR: - /* In && or ||, warn if 2nd operand has no side effect. */ - return warn_if_unused_value (TREE_OPERAND (exp, 1)); - - case COMPOUND_EXPR: - if (warn_if_unused_value (TREE_OPERAND (exp, 0))) - return 1; - return warn_if_unused_value (TREE_OPERAND (exp, 1)); - - case NOP_EXPR: - case CONVERT_EXPR: - /* Don't warn about values cast to void. */ - if (TREE_TYPE (exp) == void_type_node) - return 0; - /* Assignment to a cast results in a cast of a modify. - Don't complain about that. */ - if (TREE_CODE (TREE_OPERAND (exp, 0)) == MODIFY_EXPR) - return 0; - - default: - warning_with_file_and_line (emit_filename, emit_lineno, - "value computed is not used"); - return 1; - } -} - -/* Clear out the memory of the last expression evaluated. */ - -void -clear_last_expr () -{ - last_expr_type = 0; -} - -/* Begin a statement which will return a value. - Return the RTL_EXPR for this statement expr. - The caller must save that value and pass it to expand_end_stmt_expr. */ - -tree -expand_start_stmt_expr () -{ - rtx save = start_sequence (); - /* Make the RTL_EXPR node temporary, not momentary, - so that rtl_expr_chain doesn't become garbage. */ - int momentary = suspend_momentary (); - tree t = make_node (RTL_EXPR); - resume_momentary (momentary); - RTL_EXPR_RTL (t) = save; - NO_DEFER_POP; - expr_stmts_for_value++; - return t; -} - -/* Restore the previous state at the end of a statement that returns a value. - Returns a tree node representing the statement's value and the - insns to compute the value. - - The nodes of that expression have been freed by now, so we cannot use them. - But we don't want to do that anyway; the expression has already been - evaluated and now we just want to use the value. So generate a RTL_EXPR - with the proper type and RTL value. - - If the last substatement was not an expression, - return something with type `void'. */ - -tree -expand_end_stmt_expr (t) - tree t; -{ - rtx saved = RTL_EXPR_RTL (t); - - OK_DEFER_POP; - - if (last_expr_type == 0) - { - last_expr_type = void_type_node; - last_expr_value = const0_rtx; - } - TREE_TYPE (t) = last_expr_type; - RTL_EXPR_RTL (t) = last_expr_value; - RTL_EXPR_SEQUENCE (t) = get_insns (); - - rtl_expr_chain = tree_cons (NULL_TREE, t, rtl_expr_chain); - - end_sequence (saved); - - /* Don't consider deleting this expr or containing exprs at tree level. */ - TREE_VOLATILE (t) = 1; - /* Propagate volatility of the actual RTL expr. */ - TREE_THIS_VOLATILE (t) = volatile_refs_p (last_expr_value); - - last_expr_type = 0; - expr_stmts_for_value--; - - return t; -} - -int -in_try_block (level) - int level; -{ - struct nesting *n = except_stack; - while (1) - { - while (n && n->data.except_stmt.after_label != 0) - n = n->next; - if (n == 0) - return 0; - if (level == 0) - return n != 0; - level--; - n = n->next; - } -} - -int -in_except_block (level) - int level; -{ - struct nesting *n = except_stack; - while (1) - { - while (n && n->data.except_stmt.after_label == 0) - n = n->next; - if (n == 0) - return 0; - if (level == 0) - return n != 0; - level--; - n = n->next; - } -} - -int -in_exception_handler (level) - int level; -{ - struct nesting *n = except_stack; - while (n && level--) - n = n->next; - return n != 0; -} - -int -expand_raise (ex) - tree ex; -{ - tree *raises_ptr; - - if (except_stack == 0) - return 0; - raises_ptr = &except_stack->data.except_stmt.raised; - if (! value_member (ex, *raises_ptr)) - *raises_ptr = tree_cons (NULL_TREE, ex, *raises_ptr); - return 1; -} - -/* Generate RTL for the start of a try block. - - TRY_CLAUSE is the condition to test to enter the try block. */ -void -expand_start_try (try_clause, exitflag, escapeflag) - tree try_clause; - int exitflag; - int escapeflag; -{ - struct nesting *thishandler - = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting)); - - /* Make an entry on cond_stack for the cond we are entering. */ - - thishandler->next = except_stack; - thishandler->all = nesting_stack; - thishandler->depth = ++nesting_depth; - thishandler->data.except_stmt.raised = 0; - thishandler->data.except_stmt.handled = 0; - thishandler->data.except_stmt.first_insn = get_insns (); - thishandler->data.except_stmt.except_label = gen_label_rtx (); - thishandler->data.except_stmt.unhandled_label = 0; - thishandler->data.except_stmt.after_label = 0; - thishandler->data.except_stmt.escape_label - = escapeflag ? thishandler->data.except_stmt.except_label : 0; - thishandler->exit_label = exitflag ? gen_label_rtx () : 0; - except_stack = thishandler; - nesting_stack = thishandler; - - do_jump (try_clause, thishandler->data.except_stmt.except_label, NULL); -} - -/* End of a TRY block. Nothing to do for now. */ -void -expand_end_try () -{ - except_stack->data.except_stmt.after_label = gen_label_rtx (); - expand_goto_internal (NULL, except_stack->data.except_stmt.after_label, 0); -} - -void -expand_start_except (exitflag, escapeflag) - int exitflag; - int escapeflag; -{ - if (exitflag) - { - struct nesting *n; - /* An `exit' from catch clauses goes out to next exit level, - if there is one. Otherwise, it just goes to the end - of the construct. */ - for (n = except_stack->next; n; n = n->next) - if (n->exit_label != 0) - { - except_stack->exit_label = n->exit_label; - break; - } - if (n == 0) - except_stack->exit_label = except_stack->data.except_stmt.after_label; - } - if (escapeflag) - { - struct nesting *n; - /* An `escape' from catch clauses goes out to next escape level, - if there is one. Otherwise, it just goes to the end - of the construct. */ - for (n = except_stack->next; n; n = n->next) - if (n->data.except_stmt.escape_label != 0) - { - except_stack->data.except_stmt.escape_label - = n->data.except_stmt.escape_label; - break; - } - if (n == 0) - except_stack->data.except_stmt.escape_label - = except_stack->data.except_stmt.after_label; - } - do_pending_stack_adjust (); - emit_label (except_stack->data.except_stmt.except_label); -} - -int -expand_escape_except () -{ - struct nesting *n; - last_expr_type = 0; - for (n = except_stack; n; n = n->next) - if (n->data.except_stmt.escape_label != 0) - { - expand_goto_internal (0, n->data.except_stmt.escape_label, 0); - return 1; - } - - return 0; -} - -tree -expand_end_except () -{ - struct nesting *n; - tree raised = NULL_TREE; - - do_pending_stack_adjust (); - emit_label (except_stack->data.except_stmt.after_label); - - n = except_stack->next; - if (n) - { - /* Propagate exceptions raised but not handled to next - highest level. */ - tree handled = except_stack->data.except_stmt.raised; - if (handled != void_type_node) - { - tree prev = NULL_TREE; - raised = except_stack->data.except_stmt.raised; - while (handled) - { - tree this_raise; - for (this_raise = raised, prev = 0; this_raise; - this_raise = TREE_CHAIN (this_raise)) - { - if (value_member (TREE_VALUE (this_raise), handled)) - { - if (prev) - TREE_CHAIN (prev) = TREE_CHAIN (this_raise); - else - { - raised = TREE_CHAIN (raised); - if (raised == NULL_TREE) - goto nada; - } - } - else - prev = this_raise; - } - handled = TREE_CHAIN (handled); - } - if (prev == NULL_TREE) - prev = raised; - if (prev) - TREE_CHAIN (prev) = n->data.except_stmt.raised; - nada: - n->data.except_stmt.raised = raised; - } - } - - POPSTACK (except_stack); - last_expr_type = 0; - return raised; -} - -int -expand_catch (ex) - tree ex; -{ - tree *raises_ptr; - - if (except_stack == 0) - return 0; - raises_ptr = &except_stack->data.except_stmt.handled; - if (*raises_ptr != void_type_node - && ex != NULL_TREE - && ! value_member (ex, *raises_ptr)) - *raises_ptr = tree_cons (NULL_TREE, ex, *raises_ptr); - return 1; -} - -int -expand_catch_default () -{ - if (except_stack == 0) - return 0; - except_stack->data.except_stmt.handled = void_type_node; -} - -int -expand_end_catch () -{ - if (except_stack == 0 || except_stack->data.except_stmt.after_label == 0) - return 0; - expand_goto_internal (0, except_stack->data.except_stmt.after_label, 0); - return 1; -} - -/* Generate RTL for the start of an if-then. COND is the expression - whose truth should be tested. - - If EXITFLAG is nonzero, this conditional is visible to - `exit_something'. */ - -void -expand_start_cond (cond, exitflag) - tree cond; - int exitflag; -{ - struct nesting *thiscond - = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting)); - - /* Make an entry on cond_stack for the cond we are entering. */ - - thiscond->next = cond_stack; - thiscond->all = nesting_stack; - thiscond->depth = ++nesting_depth; - thiscond->data.cond.after_label = 0; - thiscond->data.cond.else_label = gen_label_rtx (); - thiscond->exit_label = exitflag ? thiscond->data.cond.else_label : 0; - cond_stack = thiscond; - nesting_stack = thiscond; - - do_jump (cond, thiscond->data.cond.else_label, NULL); -} - -/* Generate RTL for the end of an if-then with no else-clause. - Pop the record for it off of cond_stack. */ - -void -expand_end_cond () -{ - struct nesting *thiscond = cond_stack; - - do_pending_stack_adjust (); - emit_label (thiscond->data.cond.else_label); - - POPSTACK (cond_stack); - last_expr_type = 0; -} - -/* Generate RTL between the then-clause and the else-clause - of an if-then-else. */ - -void -expand_start_else () -{ - cond_stack->data.cond.after_label = gen_label_rtx (); - if (cond_stack->exit_label != 0) - cond_stack->exit_label = cond_stack->data.cond.after_label; - emit_jump (cond_stack->data.cond.after_label); - if (cond_stack->data.cond.else_label) - emit_label (cond_stack->data.cond.else_label); -} - -/* Generate RTL for the end of an if-then-else. - Pop the record for it off of cond_stack. */ - -void -expand_end_else () -{ - struct nesting *thiscond = cond_stack; - - do_pending_stack_adjust (); - /* Note: a syntax error can cause this to be called - without first calling `expand_start_else'. */ - if (thiscond->data.cond.after_label) - emit_label (thiscond->data.cond.after_label); - - POPSTACK (cond_stack); - last_expr_type = 0; -} - -/* Generate RTL for the start of a loop. EXIT_FLAG is nonzero if this - loop should be exited by `exit_something'. This is a loop for which - `expand_continue' will jump to the top of the loop. - - Make an entry on loop_stack to record the labels associated with - this loop. */ - -void -expand_start_loop (exit_flag) - int exit_flag; -{ - register struct nesting *thisloop - = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting)); - - /* Make an entry on loop_stack for the loop we are entering. */ - - thisloop->next = loop_stack; - thisloop->all = nesting_stack; - thisloop->depth = ++nesting_depth; - thisloop->data.loop.start_label = gen_label_rtx (); - thisloop->data.loop.end_label = gen_label_rtx (); - thisloop->data.loop.continue_label = thisloop->data.loop.start_label; - thisloop->exit_label = exit_flag ? thisloop->data.loop.end_label : 0; - loop_stack = thisloop; - nesting_stack = thisloop; - - do_pending_stack_adjust (); - emit_queue (); - emit_note (0, NOTE_INSN_LOOP_BEG); - emit_label (thisloop->data.loop.start_label); -} - -/* Like expand_start_loop but for a loop where the continuation point - (for expand_continue_loop) will be specified explicitly. */ - -void -expand_start_loop_continue_elsewhere (exit_flag) - int exit_flag; -{ - expand_start_loop (exit_flag); - loop_stack->data.loop.continue_label = gen_label_rtx (); -} - -/* Specify the continuation point for a loop started with - expand_start_loop_continue_elsewhere. - Use this at the point in the code to which a continue statement - should jump. */ - -void -expand_loop_continue_here () -{ - do_pending_stack_adjust (); - emit_note (0, NOTE_INSN_LOOP_CONT); - emit_label (loop_stack->data.loop.continue_label); -} - -/* Finish a loop. Generate a jump back to the top and the loop-exit label. - Pop the block off of loop_stack. */ - -void -expand_end_loop () -{ - register rtx insn = get_last_insn (); - register rtx start_label = loop_stack->data.loop.start_label; - - do_pending_stack_adjust (); - - /* If optimizing, perhaps reorder the loop. If the loop - starts with a conditional exit, roll that to the end - where it will optimize together with the jump back. */ - if (optimize - && - ! (GET_CODE (insn) == JUMP_INSN - && GET_CODE (PATTERN (insn)) == SET - && SET_DEST (PATTERN (insn)) == pc_rtx - && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE)) - { - /* Scan insns from the top of the loop looking for a qualified - conditional exit. */ - for (insn = loop_stack->data.loop.start_label; insn; insn= NEXT_INSN (insn)) - if (GET_CODE (insn) == JUMP_INSN && GET_CODE (PATTERN (insn)) == SET - && SET_DEST (PATTERN (insn)) == pc_rtx - && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE - && - ((GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == LABEL_REF - && (XEXP (XEXP (SET_SRC (PATTERN (insn)), 1), 0) - == loop_stack->data.loop.end_label)) - || - (GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 2)) == LABEL_REF - && (XEXP (XEXP (SET_SRC (PATTERN (insn)), 2), 0) - == loop_stack->data.loop.end_label)))) - break; - if (insn != 0) - { - /* We found one. Move everything from there up - to the end of the loop, and add a jump into the loop - to jump to there. */ - register rtx newstart_label = gen_label_rtx (); - - emit_label_after (newstart_label, PREV_INSN (start_label)); - reorder_insns (start_label, insn, get_last_insn ()); - emit_jump_insn_after (gen_jump (start_label), PREV_INSN (newstart_label)); - emit_barrier_after (PREV_INSN (newstart_label)); - start_label = newstart_label; - } - } - - emit_jump (start_label); - emit_note (0, NOTE_INSN_LOOP_END); - emit_label (loop_stack->data.loop.end_label); - - POPSTACK (loop_stack); - - last_expr_type = 0; -} - -/* Generate a jump to the current loop's continue-point. - This is usually the top of the loop, but may be specified - explicitly elsewhere. If not currently inside a loop, - return 0 and do nothing; caller will print an error message. */ - -int -expand_continue_loop () -{ - last_expr_type = 0; - if (loop_stack == 0) - return 0; - expand_goto_internal (0, loop_stack->data.loop.continue_label, 0); - return 1; -} - -/* Generate a jump to exit the current loop. If not currently inside a loop, - return 0 and do nothing; caller will print an error message. */ - -int -expand_exit_loop () -{ - last_expr_type = 0; - if (loop_stack == 0) - return 0; - expand_goto_internal (0, loop_stack->data.loop.end_label, 0); - return 1; -} - -/* Generate a conditional jump to exit the current loop if COND - evaluates to zero. If not currently inside a loop, - return 0 and do nothing; caller will print an error message. */ - -int -expand_exit_loop_if_false (cond) - tree cond; -{ - last_expr_type = 0; - if (loop_stack == 0) - return 0; - do_jump (cond, loop_stack->data.loop.end_label, NULL); - return 1; -} - -/* Return non-zero if currently inside a loop. */ - -int -inside_loop () -{ - return loop_stack != 0; -} - -/* Generate a jump to exit the current loop, conditional, binding contour - or case statement. Not all such constructs are visible to this function, - only those started with EXIT_FLAG nonzero. Individual languages use - the EXIT_FLAG parameter to control which kinds of constructs you can - exit this way. - - If not currently inside anything that can be exited, - return 0 and do nothing; caller will print an error message. */ - -int -expand_exit_something () -{ - struct nesting *n; - last_expr_type = 0; - for (n = nesting_stack; n; n = n->all) - if (n->exit_label != 0) - { - expand_goto_internal (0, n->exit_label, 0); - return 1; - } - - return 0; -} - -/* Generate RTL to return from the current function, with no value. - (That is, we do not do anything about returning any value.) */ - -void -expand_null_return () -{ - struct nesting *block = block_stack; - rtx last_insn = 0; - - /* Does any pending block have cleanups? */ - - while (block && block->data.block.cleanups == 0) - block = block->next; - - /* If yes, use a goto to return, since that runs cleanups. */ - - expand_null_return_1 (last_insn, block != 0); -} - -/* Output a return with no value. If LAST_INSN is nonzero, - pretend that the return takes place after LAST_INSN. - If USE_GOTO is nonzero then don't use a return instruction; - go to the return label instead. This causes any cleanups - of pending blocks to be executed normally. */ - -static void -expand_null_return_1 (last_insn, use_goto) - rtx last_insn; - int use_goto; -{ - rtx end_label = cleanup_label ? cleanup_label : return_label; - - clear_pending_stack_adjust (); - do_pending_stack_adjust (); - last_expr_type = 0; - - /* PCC-struct return always uses an epilogue. */ - if (current_function_returns_pcc_struct || use_goto) - { - if (end_label == 0) - end_label = return_label = gen_label_rtx (); - expand_goto_internal (0, end_label, last_insn); - return; - } - - /* Otherwise output a simple return-insn if one is available, - unless it won't do the job. */ -#ifdef HAVE_return - if (HAVE_return && cleanup_label == 0) - { - emit_jump_insn (gen_return ()); - emit_barrier (); - return; - } -#endif - - /* Otherwise jump to the epilogue. */ - expand_goto_internal (0, end_label, last_insn); -} - -/* Generate RTL to evaluate the expression RETVAL and return it - from the current function. */ - -void -expand_return (retval) - tree retval; -{ - /* If there are any cleanups to be performed, then they will - be inserted following LAST_INSN. It is desirable - that the last_insn, for such purposes, should be the - last insn before computing the return value. Otherwise, cleanups - which call functions can clobber the return value. */ - /* ??? rms: I think that is erroneous, because in C++ it would - run destructors on variables that might be used in the subsequent - computation of the return value. */ - rtx last_insn = 0; - register rtx val = 0; - register rtx op0; - tree retval_rhs; - int cleanups; - struct nesting *block; - - /* Are any cleanups needed? E.g. C++ destructors to be run? */ - cleanups = 0; - for (block = block_stack; block; block = block->next) - if (block->data.block.cleanups != 0) - { - cleanups = 1; - break; - } - - if (TREE_CODE (retval) == RESULT_DECL) - retval_rhs = retval; - else if ((TREE_CODE (retval) == MODIFY_EXPR || TREE_CODE (retval) == INIT_EXPR) - && TREE_CODE (TREE_OPERAND (retval, 0)) == RESULT_DECL) - retval_rhs = TREE_OPERAND (retval, 1); - else if (TREE_TYPE (retval) == void_type_node) - /* Recognize tail-recursive call to void function. */ - retval_rhs = retval; - else - retval_rhs = NULL_TREE; - - /* Only use `last_insn' if there are cleanups which must be run. */ - if (cleanups || cleanup_label != 0) - last_insn = get_last_insn (); - - /* For tail-recursive call to current function, - just jump back to the beginning. - It's unsafe if any auto variable in this function - has its address taken; for simplicity, - require stack frame to be empty. */ - if (optimize && retval_rhs != 0 - && frame_offset == STARTING_FRAME_OFFSET - && TREE_CODE (retval_rhs) == CALL_EXPR - && TREE_CODE (TREE_OPERAND (retval_rhs, 0)) == ADDR_EXPR - && TREE_OPERAND (TREE_OPERAND (retval_rhs, 0), 0) == this_function - /* Finish checking validity, and if valid emit code - to set the argument variables for the new call. */ - && tail_recursion_args (TREE_OPERAND (retval_rhs, 1), - DECL_ARGUMENTS (this_function))) - { - if (tail_recursion_label == 0) - { - tail_recursion_label = gen_label_rtx (); - emit_label_after (tail_recursion_label, - tail_recursion_reentry); - } - expand_goto_internal (0, tail_recursion_label, last_insn); - emit_barrier (); - return; - } -#ifdef HAVE_return - /* This optimization is safe if there are local cleanups - because expand_null_return takes care of them. - ??? I think it should also be safe when there is a cleanup label, - because expand_null_return takes care of them, too. - Any reason why not? */ - if (HAVE_return && cleanup_label == 0 - && ! current_function_returns_pcc_struct) - { - /* If this is return x == y; then generate - if (x == y) return 1; else return 0; - if we can do it with explicit return insns. */ - if (retval_rhs) - switch (TREE_CODE (retval_rhs)) - { - case EQ_EXPR: - case NE_EXPR: - case GT_EXPR: - case GE_EXPR: - case LT_EXPR: - case LE_EXPR: - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - case TRUTH_AND_EXPR: - case TRUTH_OR_EXPR: - case TRUTH_NOT_EXPR: - op0 = gen_label_rtx (); - val = DECL_RTL (DECL_RESULT (this_function)); - jumpifnot (retval_rhs, op0); - emit_move_insn (val, const1_rtx); - emit_insn (gen_rtx (USE, VOIDmode, val)); - expand_null_return (); - emit_label (op0); - emit_move_insn (val, const0_rtx); - emit_insn (gen_rtx (USE, VOIDmode, val)); - expand_null_return (); - return; - } - } -#endif /* HAVE_return */ - - if (cleanups - && retval_rhs != 0 - && TREE_TYPE (retval_rhs) != void_type_node - && GET_CODE (DECL_RTL (DECL_RESULT (this_function))) == REG) - { - rtx last_insn; - /* Calculate the return value into a pseudo reg. */ - val = expand_expr (retval_rhs, 0, VOIDmode, 0); - emit_queue (); - /* Put the cleanups here. */ - last_insn = get_last_insn (); - /* Copy the value into hard return reg. */ - emit_move_insn (DECL_RTL (DECL_RESULT (this_function)), val); - val = DECL_RTL (DECL_RESULT (this_function)); - - if (GET_CODE (val) == REG) - emit_insn (gen_rtx (USE, VOIDmode, val)); - expand_null_return_1 (last_insn, cleanups); - } - else - { - /* No cleanups or no hard reg used; - calculate value into hard return reg - and let cleanups come after. */ - val = expand_expr (retval, 0, VOIDmode, 0); - emit_queue (); - - val = DECL_RTL (DECL_RESULT (this_function)); - if (val && GET_CODE (val) == REG) - emit_insn (gen_rtx (USE, VOIDmode, val)); - expand_null_return (); - } -} - -/* Return 1 if the end of the generated RTX is not a barrier. - This means code already compiled can drop through. */ - -int -drop_through_at_end_p () -{ - rtx insn = get_last_insn (); - while (insn && GET_CODE (insn) == NOTE) - insn = PREV_INSN (insn); - return insn && GET_CODE (insn) != BARRIER; -} - -/* Emit code to alter this function's formal parms for a tail-recursive call. - ACTUALS is a list of actual parameter expressions (chain of TREE_LISTs). - FORMALS is the chain of decls of formals. - Return 1 if this can be done; - otherwise return 0 and do not emit any code. */ - -static int -tail_recursion_args (actuals, formals) - tree actuals, formals; -{ - register tree a = actuals, f = formals; - register int i; - register rtx *argvec; - - /* Check that number and types of actuals are compatible - with the formals. This is not always true in valid C code. - Also check that no formal needs to be addressable - and that all formals are scalars. */ - - /* Also count the args. */ - - for (a = actuals, f = formals, i = 0; a && f; a = TREE_CHAIN (a), f = TREE_CHAIN (f), i++) - { - if (TREE_TYPE (TREE_VALUE (a)) != TREE_TYPE (f)) - return 0; - if (GET_CODE (DECL_RTL (f)) != REG || DECL_MODE (f) == BLKmode) - return 0; - } - if (a != 0 || f != 0) - return 0; - - /* Compute all the actuals. */ - - argvec = (rtx *) alloca (i * sizeof (rtx)); - - for (a = actuals, i = 0; a; a = TREE_CHAIN (a), i++) - argvec[i] = expand_expr (TREE_VALUE (a), 0, VOIDmode, 0); - - /* Find which actual values refer to current values of previous formals. - Copy each of them now, before any formal is changed. */ - - for (a = actuals, i = 0; a; a = TREE_CHAIN (a), i++) - { - int copy = 0; - register int j; - for (f = formals, j = 0; j < i; f = TREE_CHAIN (f), j++) - if (reg_mentioned_p (DECL_RTL (f), argvec[i])) - { copy = 1; break; } - if (copy) - argvec[i] = copy_to_reg (argvec[i]); - } - - /* Store the values of the actuals into the formals. */ - - for (f = formals, a = actuals, i = 0; f; - f = TREE_CHAIN (f), a = TREE_CHAIN (a), i++) - { - if (DECL_MODE (f) == GET_MODE (argvec[i])) - emit_move_insn (DECL_RTL (f), argvec[i]); - else - convert_move (DECL_RTL (f), argvec[i], - TREE_UNSIGNED (TREE_TYPE (TREE_VALUE (a)))); - } - - return 1; -} - -/* Generate the RTL code for entering a binding contour. - The variables are declared one by one, by calls to `expand_decl'. - - EXIT_FLAG is nonzero if this construct should be visible to - `exit_something'. */ - -void -expand_start_bindings (exit_flag) - int exit_flag; -{ - struct nesting *thisblock - = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting)); - - rtx note = emit_note (0, NOTE_INSN_BLOCK_BEG); - - /* Make an entry on block_stack for the block we are entering. */ - - thisblock->next = block_stack; - thisblock->all = nesting_stack; - thisblock->depth = ++nesting_depth; - thisblock->data.block.stack_level = 0; - thisblock->data.block.cleanups = 0; - /* We build this even if the cleanups lists are empty - because we rely on having an element in the chain - for each block that is pending. */ - if (block_stack) - { - if (block_stack->data.block.cleanups == NULL_TREE - && (block_stack->data.block.outer_cleanups == NULL_TREE - || block_stack->data.block.outer_cleanups == empty_cleanup_list)) - thisblock->data.block.outer_cleanups = empty_cleanup_list; - else - thisblock->data.block.outer_cleanups - = tree_cons (NULL_TREE, block_stack->data.block.cleanups, - block_stack->data.block.outer_cleanups); - } - else - thisblock->data.block.outer_cleanups = 0; - thisblock->data.block.label_chain = 0; - thisblock->data.block.innermost_stack_block = stack_block_stack; - thisblock->data.block.first_insn = note; - thisblock->data.block.block_start_count = ++block_start_count; - thisblock->exit_label = exit_flag ? gen_label_rtx () : 0; - block_stack = thisblock; - nesting_stack = thisblock; -} - -/* Output a USE for any register use in RTL. - This is used with -noreg to mark the extent of lifespan - of any registers used in a user-visible variable's DECL_RTL. */ - -void -use_variable (rtl) - rtx rtl; -{ - if (GET_CODE (rtl) == REG) - /* This is a register variable. */ - emit_insn (gen_rtx (USE, VOIDmode, rtl)); - else if (GET_CODE (rtl) == MEM - && GET_CODE (XEXP (rtl, 0)) == REG - && XEXP (rtl, 0) != frame_pointer_rtx - && XEXP (rtl, 0) != arg_pointer_rtx) - /* This is a variable-sized structure. */ - emit_insn (gen_rtx (USE, VOIDmode, XEXP (rtl, 0))); -} - -/* Like use_variable except that it outputs the USEs after INSN - instead of at the end of the insn-chain. */ - -static void -use_variable_after (rtl, insn) - rtx rtl, insn; -{ - if (GET_CODE (rtl) == REG) - /* This is a register variable. */ - emit_insn_after (gen_rtx (USE, VOIDmode, rtl), insn); - else if (GET_CODE (rtl) == MEM - && GET_CODE (XEXP (rtl, 0)) == REG - && XEXP (rtl, 0) != frame_pointer_rtx - && XEXP (rtl, 0) != arg_pointer_rtx) - /* This is a variable-sized structure. */ - emit_insn_after (gen_rtx (USE, VOIDmode, XEXP (rtl, 0)), insn); -} - -/* Generate RTL code to terminate a binding contour. - VARS is the chain of VAR_DECL nodes - for the variables bound in this contour. - MARK_ENDS is nonzero if we should put a note at the beginning - and end of this binding contour. - - DONT_JUMP_IN is nonzero if it is not valid to jump into this contour. - (That is true automatically if the contour has a saved stack level.) */ - -void -expand_end_bindings (vars, mark_ends, dont_jump_in) - tree vars; - int mark_ends; - int dont_jump_in; -{ - register struct nesting *thisblock = block_stack; - register tree decl; - - if (warn_unused) - for (decl = vars; decl; decl = TREE_CHAIN (decl)) - if (! TREE_USED (decl) && TREE_CODE (decl) == VAR_DECL) - warning_with_decl (decl, "unused variable `%s'"); - - /* Mark the beginning and end of the scope if requested. */ - - if (mark_ends) - emit_note (0, NOTE_INSN_BLOCK_END); - else - /* Get rid of the beginning-mark if we don't make an end-mark. */ - NOTE_LINE_NUMBER (thisblock->data.block.first_insn) = NOTE_INSN_DELETED; - - if (thisblock->exit_label) - { - do_pending_stack_adjust (); - emit_label (thisblock->exit_label); - } - - if (dont_jump_in - || thisblock->data.block.stack_level != 0 - || thisblock->data.block.cleanups != 0) - { - struct label_chain *chain; - - /* Any labels in this block are no longer valid to go to. - Mark them to cause an error message. */ - for (chain = thisblock->data.block.label_chain; chain; chain = chain->next) - { - TREE_PACKED (chain->label) = 1; - /* If any goto without a fixup came to this label, - that must be an error, because gotos without fixups - come from outside all saved stack-levels and all cleanups. */ - if (TREE_ADDRESSABLE (chain->label)) - error_with_decl (chain->label, - "label `%s' used before containing binding contour"); - } - } - - /* Restore stack level in effect before the block - (only if variable-size objects allocated). */ - - if (thisblock->data.block.stack_level != 0 - || thisblock->data.block.cleanups != 0) - { - /* Perform any cleanups associated with the block. */ - int old_expr_stmts_for_value = expr_stmts_for_value; - rtx old_last_expr_value = last_expr_value; - tree old_last_expr_type = last_expr_type; - - /* Don't let cleanups affect ({...}) constructs. */ - expr_stmts_for_value = 0; - expand_cleanups (thisblock->data.block.cleanups, 0); - do_pending_stack_adjust (); - expr_stmts_for_value = old_expr_stmts_for_value; - last_expr_value = old_last_expr_value; - last_expr_type = old_last_expr_type; - - /* Restore the stack level. */ - - if (thisblock->data.block.stack_level != 0) - emit_move_insn (stack_pointer_rtx, - thisblock->data.block.stack_level); - - /* Any gotos out of this block must also do these things. - Also report any gotos with fixups that came to labels in this level. */ - fixup_gotos (thisblock, - thisblock->data.block.stack_level, - thisblock->data.block.cleanups, - thisblock->data.block.first_insn, - dont_jump_in); - } - - /* If doing stupid register allocation, make sure lives of all - register variables declared here extend thru end of scope. */ - - if (obey_regdecls) - for (decl = vars; decl; decl = TREE_CHAIN (decl)) - { - rtx rtl = DECL_RTL (decl); - if (TREE_CODE (decl) == VAR_DECL && rtl != 0) - use_variable (rtl); - } - - /* Restore block_stack level for containing block. */ - - stack_block_stack = thisblock->data.block.innermost_stack_block; - POPSTACK (block_stack); -} - -/* Generate RTL for the automatic variable declaration DECL. - (Other kinds of declarations are simply ignored if seen here.) - There is no special support here for C++ constructors. - They should be handled by the proper code in DECL_INITIAL. */ - -void -expand_decl (decl) - register tree decl; -{ - struct nesting *thisblock = block_stack; - tree type = TREE_TYPE (decl); - - /* Only automatic variables need any expansion done. - Static and external variables, and external functions, - will be handled by `assemble_variable' (called from finish_decl). - TYPE_DECL and CONST_DECL require nothing. - PARM_DECLs are handled in `assign_parms'. */ - - if (TREE_CODE (decl) != VAR_DECL) - return; - if (TREE_STATIC (decl) || TREE_EXTERNAL (decl)) - return; - - /* Create the RTL representation for the variable. */ - - if (type == error_mark_node) - DECL_RTL (decl) = gen_rtx (MEM, BLKmode, const0_rtx); - else if (DECL_SIZE (decl) == 0) - /* Variable with incomplete type. */ - { - if (DECL_INITIAL (decl) == 0) - /* Error message was already done; now avoid a crash. */ - DECL_RTL (decl) = assign_stack_local (DECL_MODE (decl), 0); - else - /* An initializer is going to decide the size of this array. - Until we know the size, represent its address with a reg. */ - DECL_RTL (decl) = gen_rtx (MEM, BLKmode, gen_reg_rtx (Pmode)); - } - else if (DECL_MODE (decl) != BLKmode - /* If -ffloat-store, don't put explicit float vars - into regs. */ - && !(flag_float_store - && TREE_CODE (type) == REAL_TYPE) - && ! TREE_VOLATILE (decl) - && ! TREE_ADDRESSABLE (decl) - && (TREE_REGDECL (decl) || ! obey_regdecls)) - { - /* Automatic variable that can go in a register. */ - DECL_RTL (decl) = gen_reg_rtx (DECL_MODE (decl)); - if (TREE_CODE (type) == POINTER_TYPE) - mark_reg_pointer (DECL_RTL (decl)); - REG_USERVAR_P (DECL_RTL (decl)) = 1; - } - else if (TREE_LITERAL (DECL_SIZE (decl))) - { - rtx oldaddr = 0; - rtx addr; - - /* If we previously made RTL for this decl, it must be an array - whose size was determined by the initializer. - The old address was a register; set that register now - to the proper address. */ - if (DECL_RTL (decl) != 0) - { - if (GET_CODE (DECL_RTL (decl)) != MEM - || GET_CODE (XEXP (DECL_RTL (decl), 0)) != REG) - abort (); - oldaddr = XEXP (DECL_RTL (decl), 0); - } - - /* Variable of fixed size that goes on the stack. */ - DECL_RTL (decl) - = assign_stack_local (DECL_MODE (decl), - (TREE_INT_CST_LOW (DECL_SIZE (decl)) - * DECL_SIZE_UNIT (decl) - + BITS_PER_UNIT - 1) - / BITS_PER_UNIT); - if (oldaddr) - { - addr = force_operand (XEXP (DECL_RTL (decl), 0), oldaddr); - emit_move_insn (oldaddr, addr); - } - - /* If this is a memory ref that contains aggregate components, - mark it as such for cse and loop optimize. */ - MEM_IN_STRUCT_P (DECL_RTL (decl)) - = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE - || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE); -#if 0 - /* If this is in memory because of -ffloat-store, - set the volatile bit, to prevent optimizations from - undoing the effects. */ - if (flag_float_store && TREE_CODE (type) == REAL_TYPE) - MEM_VOLATILE_P (DECL_RTL (decl)) = 1; -#endif - } - else - /* Dynamic-size object: must push space on the stack. */ - { - rtx address, size; - - frame_pointer_needed = 1; - - /* Record the stack pointer on entry to block, if have - not already done so. */ - if (thisblock->data.block.stack_level == 0) - { - do_pending_stack_adjust (); - thisblock->data.block.stack_level - = copy_to_reg (stack_pointer_rtx); - stack_block_stack = thisblock; - } - - /* Compute the variable's size, in bytes. */ - size = expand_expr (convert_units (DECL_SIZE (decl), - DECL_SIZE_UNIT (decl), - BITS_PER_UNIT), - 0, VOIDmode, 0); - - /* Round it up to this machine's required stack boundary. */ -#ifdef STACK_BOUNDARY - /* Avoid extra code if we can prove it's a multiple already. */ - if (DECL_SIZE_UNIT (decl) % STACK_BOUNDARY) - { -#ifdef STACK_POINTER_OFFSET - /* Avoid extra code if we can prove that adding STACK_POINTER_OFFSET - will not give this address invalid alignment. */ - if (DECL_ALIGN (decl) > ((STACK_POINTER_OFFSET * BITS_PER_UNIT) % STACK_BOUNDARY)) - size = plus_constant (size, - STACK_POINTER_OFFSET % (STACK_BOUNDARY / BITS_PER_UNIT)); -#endif - size = round_push (size); - } -#endif /* STACK_BOUNDARY */ - - /* Make space on the stack, and get an rtx for the address of it. */ -#ifdef STACK_GROWS_DOWNWARD - anti_adjust_stack (size); -#endif - address = copy_to_reg (stack_pointer_rtx); -#ifdef STACK_POINTER_OFFSET - { - /* If the contents of the stack pointer reg are offset from the - actual top-of-stack address, add the offset here. */ - rtx sp_offset = gen_rtx (CONST_INT, VOIDmode, STACK_POINTER_OFFSET); -#ifdef STACK_BOUNDARY -#ifdef STACK_GROWS_DOWNWARD - int direction = 1; -#else /* not STACK_GROWS_DOWNWARD */ - int direction = 0; -#endif /* not STACK_GROWS_DOWNWARD */ - if (DECL_ALIGN (decl) > ((STACK_POINTER_OFFSET * BITS_PER_UNIT) % STACK_BOUNDARY)) - sp_offset = plus_constant (sp_offset, - (STACK_POINTER_OFFSET - % (STACK_BOUNDARY / BITS_PER_UNIT) - * direction)); -#endif /* STACK_BOUNDARY */ - emit_insn (gen_add2_insn (address, sp_offset)); - } -#endif /* STACK_POINTER_OFFSET */ -#ifndef STACK_GROWS_DOWNWARD - anti_adjust_stack (size); -#endif - - /* Some systems require a particular insn to refer to the stack - to make the pages exist. */ -#ifdef HAVE_probe - if (HAVE_probe) - emit_insn (gen_probe ()); -#endif - - /* Reference the variable indirect through that rtx. */ - DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl), address); - } - - if (TREE_VOLATILE (decl)) - MEM_VOLATILE_P (DECL_RTL (decl)) = 1; - if (TREE_READONLY (decl)) - RTX_UNCHANGING_P (DECL_RTL (decl)) = 1; - - /* If doing stupid register allocation, make sure life of any - register variable starts here, at the start of its scope. */ - - if (obey_regdecls) - use_variable (DECL_RTL (decl)); -} - -/* Emit code to perform the initialization of a declaration DECL. */ - -void -expand_decl_init (decl) - tree decl; -{ - if (TREE_STATIC (decl)) - return; - - /* Compute and store the initial value now. */ - - if (DECL_INITIAL (decl) == error_mark_node) - { - enum tree_code code = TREE_CODE (TREE_TYPE (decl)); - if (code == INTEGER_TYPE || code == REAL_TYPE || code == ENUMERAL_TYPE - || code == POINTER_TYPE) - expand_assignment (decl, convert (TREE_TYPE (decl), integer_zero_node), - 0, 0); - emit_queue (); - } - else if (DECL_INITIAL (decl) && TREE_CODE (DECL_INITIAL (decl)) != TREE_LIST) - { - emit_line_note (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); - expand_assignment (decl, DECL_INITIAL (decl), 0, 0); - emit_queue (); - } -} - -/* CLEANUP is an expression to be executed at exit from this binding contour; - for example, in C++, it might call the destructor for this variable. - - If CLEANUP contains any SAVE_EXPRs, then you must preevaluate them - either before or after calling `expand_decl' but before compiling - any subsequent expressions. This is because CLEANUP may be expanded - more than once, on different branches of execution. - For the same reason, CLEANUP may not contain a CALL_EXPR - except as its topmost node--else `preexpand_calls' would get confused. - - If CLEANUP is nonzero and DECL is zero, we record a cleanup - that is not associated with any particular variable. - - Return 0 if such an expansion is invalid. Otherwise, return 1. */ -int -expand_decl_cleanup (decl, cleanup) -{ - struct nesting *thisblock = block_stack; - - /* Record the cleanup if there is one. */ - - if (cleanup != 0) - { - if (thisblock == 0) - return 0; - - thisblock->data.block.cleanups - = temp_tree_cons (decl, cleanup, thisblock->data.block.cleanups); - /* If this block has a cleanup, it belongs in stack_block_stack. */ - stack_block_stack = thisblock; - } - return 1; -} - -/* DECL is an anonymous union. CLEANUP is a cleanup for DECL. - DECL_ELTS is the list of elements that belong to DECL's type. - In each, the TREE_VALUE is a VAR_DECL, and the TREE_PURPOSE a cleanup. */ - -void -expand_anon_union_decl (decl, cleanup, decl_elts) - tree decl, cleanup, decl_elts; -{ - struct nesting *thisblock = block_stack; - rtx x; - - expand_decl (decl, cleanup); - x = DECL_RTL (decl); - - while (decl_elts) - { - tree decl_elt = TREE_VALUE (decl_elts); - tree cleanup_elt = TREE_PURPOSE (decl_elts); - enum machine_mode tmode = TYPE_MODE (TREE_TYPE (decl_elt)); - - if (GET_CODE (x) == MEM) - { - /* @@ calling `change_address' means that we cannot - be at top-level, since `memory_address' might try - to kick this address into a register, which won't - work. Will this work? */ - rtx new = gen_rtx (MEM, tmode, XEXP (x, 0)); - DECL_RTL (decl_elt) = new; - MEM_VOLATILE_P (new) = MEM_VOLATILE_P (x); - RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (x); - MEM_IN_STRUCT_P (new) = MEM_IN_STRUCT_P (x); - } - else - DECL_RTL (decl_elt) = gen_rtx (SUBREG, tmode, x, 0); - - /* Record the cleanup if there is one. */ - - if (cleanup != 0) - thisblock->data.block.cleanups - = temp_tree_cons (decl_elt, cleanup_elt, - thisblock->data.block.cleanups); - - decl_elts = TREE_CHAIN (decl_elts); - } -} - -/* Expand a list of cleanups LIST. - Elements may be expressions or may be nested lists. - - If DONT_DO is nonnull, then any list-element - whose TREE_PURPOSE matches DONT_DO is omitted. - This is sometimes used to avoid a cleanup associated with - a value that is being returned out of the scope. */ - -static void -expand_cleanups (list, dont_do) - tree list; - tree dont_do; -{ - tree tail; - for (tail = list; tail; tail = TREE_CHAIN (tail)) - if (dont_do == 0 || TREE_PURPOSE (tail) != dont_do) - { - if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST) - expand_cleanups (TREE_VALUE (tail), dont_do); - else - expand_expr (TREE_VALUE (tail), const0_rtx, VOIDmode, 0); - } -} - -/* Expand a list of cleanups for a goto fixup. - The expansion is put into the insn chain after the insn *BEFORE_JUMP - and *BEFORE_JUMP is set to the insn that now comes before the jump. */ - -static void -fixup_cleanups (list, before_jump) - tree list; - rtx *before_jump; -{ - rtx beyond_jump = get_last_insn (); - rtx new_before_jump; - - expand_cleanups (list, 0); - do_pending_stack_adjust (); - - new_before_jump = get_last_insn (); - - if (beyond_jump != new_before_jump) - /* If cleanups expand to nothing, don't reorder. */ - reorder_insns (NEXT_INSN (beyond_jump), new_before_jump, *before_jump); - - *before_jump = new_before_jump; -} - -/* Move all cleanups from the current block_stack - to the containing block_stack, where they are assumed to - have been created. If anything can cause a temporary to - be created, but not expanded for more than one level of - block_stacks, then this code will have to change. */ - -void -move_cleanups_up () -{ - struct nesting *block = block_stack; - struct nesting *outer = block->next; - - outer->data.block.cleanups - = chainon (block->data.block.cleanups, - outer->data.block.cleanups); - block->data.block.cleanups = 0; -} - -int -this_contour_has_cleanups_p () -{ - return block_stack && block_stack->data.block.cleanups != 0; -} - -/* Enter a case (Pascal) or switch (C) statement. - Push a block onto case_stack and nesting_stack - to accumulate the case-labels that are seen - and to record the labels generated for the statement. - - EXIT_FLAG is nonzero if `exit_something' should exit this case stmt. - Otherwise, this construct is transparent for `exit_something'. - - EXPR is the index-expression to be dispatched on. - TYPE is its nominal type. We could simply convert EXPR to this type, - but instead we take short cuts. */ - -void -expand_start_case (exit_flag, expr, type) - int exit_flag; - tree expr; - tree type; -{ - register struct nesting *thiscase - = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting)); - - /* Make an entry on case_stack for the case we are entering. */ - - thiscase->next = case_stack; - thiscase->all = nesting_stack; - thiscase->depth = ++nesting_depth; - thiscase->exit_label = exit_flag ? gen_label_rtx () : 0; - thiscase->data.case_stmt.case_list = 0; - thiscase->data.case_stmt.index_expr = expr; - thiscase->data.case_stmt.nominal_type = type; - thiscase->data.case_stmt.default_label = 0; - thiscase->data.case_stmt.num_ranges = 0; - case_stack = thiscase; - nesting_stack = thiscase; - - do_pending_stack_adjust (); - - /* Make sure case_stmt.start points to something that won't - need any transformation before expand_end_case. */ - emit_note (0, NOTE_INSN_DELETED); - - thiscase->data.case_stmt.start = get_last_insn (); -} - -/* Start a "dummy case statement" within which case labels are invalid - and are not connected to any larger real case statement. - This can be used if you don't want to let a case statement jump - into the middle of certain kinds of constructs. */ - -void -expand_start_case_dummy () -{ - register struct nesting *thiscase - = (struct nesting *) obstack_alloc (&stmt_obstack, sizeof (struct nesting)); - - /* Make an entry on case_stack for the dummy. */ - - thiscase->next = case_stack; - thiscase->all = nesting_stack; - thiscase->depth = ++nesting_depth; - thiscase->exit_label = 0; - thiscase->data.case_stmt.case_list = 0; - thiscase->data.case_stmt.start = 0; - thiscase->data.case_stmt.nominal_type = 0; - thiscase->data.case_stmt.default_label = 0; - thiscase->data.case_stmt.num_ranges = 0; - case_stack = thiscase; - nesting_stack = thiscase; -} - -/* End a dummy case statement. */ - -void -expand_end_case_dummy () -{ - POPSTACK (case_stack); -} - -/* Accumulate one case or default label inside a case or switch statement. - VALUE is the value of the case (a null pointer, for a default label). - - If not currently inside a case or switch statement, return 1 and do - nothing. The caller will print a language-specific error message. - If VALUE is a duplicate or overlaps, return 2 and do nothing. - If VALUE is out of range, return 3 and do nothing. - Return 0 on success. - - Extended to handle range statements, should they ever - be adopted. */ - -int -pushcase (value, label) - register tree value; - register tree label; -{ - register struct case_node **l; - register struct case_node *n; - tree index_type; - tree nominal_type; - - /* Fail if not inside a real case statement. */ - if (! (case_stack && case_stack->data.case_stmt.start)) - return 1; - - index_type = TREE_TYPE (case_stack->data.case_stmt.index_expr); - nominal_type = case_stack->data.case_stmt.nominal_type; - - /* If the index is erroneous, avoid more problems: pretend to succeed. */ - if (index_type == error_mark_node) - return 0; - - /* Convert VALUE to the type in which the comparisons are nominally done. */ - if (value != 0) - value = convert (nominal_type, value); - - /* Fail if this value is out of range for the actual type of the index - (which may be narrower than NOMINAL_TYPE). */ - if (value != 0 && ! int_fits_type_p (value, index_type)) - return 3; - - /* Fail if this is a duplicate or overlaps another entry. */ - if (value == 0) - { - if (case_stack->data.case_stmt.default_label != 0) - return 2; - case_stack->data.case_stmt.default_label = label; - } - else - { - /* Find the elt in the chain before which to insert the new value, - to keep the chain sorted in increasing order. - But report an error if this element is a duplicate. */ - for (l = &case_stack->data.case_stmt.case_list; - /* Keep going past elements distinctly less than VALUE. */ - *l != 0 && tree_int_cst_lt ((*l)->high, value); - l = &(*l)->right) - ; - if (*l) - { - /* Element we will insert before must be distinctly greater; - overlap means error. */ - if (! tree_int_cst_lt (value, (*l)->low)) - return 2; - } - - /* Add this label to the chain, and succeed. - Copy VALUE so it is on temporary rather than momentary - obstack and will thus survive till the end of the case statement. */ - n = (struct case_node *) oballoc (sizeof (struct case_node)); - n->left = 0; - n->right = *l; - n->high = n->low = copy_node (value); - n->code_label = label; - n->test_label = 0; - *l = n; - } - - expand_label (label); - return 0; -} - -/* Like pushcase but this case applies to all values - between VALUE1 and VALUE2 (inclusive). - The return value is the same as that of pushcase - but there is one additional error code: - 4 means the specified range was empty. - - Note that this does not currently work, since expand_end_case - has yet to be extended to handle RANGE_EXPRs. */ - -int -pushcase_range (value1, value2, label) - register tree value1, value2; - register tree label; -{ - register struct case_node **l; - register struct case_node *n; - tree index_type; - tree nominal_type; - - /* Fail if not inside a real case statement. */ - if (! (case_stack && case_stack->data.case_stmt.start)) - return 1; - - index_type = TREE_TYPE (case_stack->data.case_stmt.index_expr); - nominal_type = case_stack->data.case_stmt.nominal_type; - - /* If the index is erroneous, avoid more problems: pretend to succeed. */ - if (index_type == error_mark_node) - return 0; - - /* Convert VALUEs to type in which the comparisons are nominally done. */ - if (value1 != 0) - value1 = convert (nominal_type, value1); - if (value2 != 0) - value2 = convert (nominal_type, value2); - - /* Fail if these values are out of range. */ - if (value1 != 0 && ! int_fits_type_p (value1, index_type)) - return 3; - - if (value2 != 0 && ! int_fits_type_p (value2, index_type)) - return 3; - - /* Fail if the range is empty. */ - if (tree_int_cst_lt (value2, value1)) - return 4; - - /* If the bounds are equal, turn this into the one-value case. */ - if (tree_int_cst_equal (value1, value2)) - return pushcase (value1, label); - - /* Find the elt in the chain before which to insert the new value, - to keep the chain sorted in increasing order. - But report an error if this element is a duplicate. */ - for (l = &case_stack->data.case_stmt.case_list; - /* Keep going past elements distinctly less than this range. */ - *l != 0 && tree_int_cst_lt ((*l)->high, value1); - l = &(*l)->right) - ; - if (*l) - { - /* Element we will insert before must be distinctly greater; - overlap means error. */ - if (! tree_int_cst_lt (value2, (*l)->low)) - return 2; - } - - /* Add this label to the chain, and succeed. - Copy VALUE1, VALUE2 so they are on temporary rather than momentary - obstack and will thus survive till the end of the case statement. */ - - n = (struct case_node *) oballoc (sizeof (struct case_node)); - n->left = 0; - n->right = *l; - n->low = copy_node (value1); - n->high = copy_node (value2); - n->code_label = label; - n->test_label = 0; - *l = n; - - expand_label (label); - - case_stack->data.case_stmt.num_ranges++; - - return 0; -} - -/* Check that all enumeration literals are covered by the case - expressions of a switch. Also, warn if there are any extra - switch cases that are *not* elements of the enumerated type. */ - -void -check_for_full_enumeration_handling (type) - tree type; -{ - register struct case_node *n; - register tree chain; - - /* The time complexity of this loop is currently O(N * M), with - N being the number of enumerals in the enumerated type, and - M being the number of case expressions in the switch. */ - - for (chain = TYPE_VALUES (type); - chain; - chain = TREE_CHAIN (chain)) - { - /* Find a match between enumeral and case expression, if possible. - Quit looking when we've gone too far (since case expressions - are kept sorted in ascending order). Warn about enumerals not - handled in the switch statement case expression list. */ - - for (n = case_stack->data.case_stmt.case_list; - n && tree_int_cst_lt (n->high, TREE_VALUE (chain)); - n = n->right) - ; - - if (!(n && tree_int_cst_equal (n->low, TREE_VALUE (chain)))) - warning ("enumerated value `%s' not handled in switch", - IDENTIFIER_POINTER (TREE_PURPOSE (chain))); - } - - /* Now we go the other way around; we warn if there are case - expressions that don't correspond to enumerals. This can - occur since C and C++ don't enforce type-checking of - assignments to enumeration variables. */ - - for (n = case_stack->data.case_stmt.case_list; n; n = n->right) - { - for (chain = TYPE_VALUES (type); - chain && !tree_int_cst_equal (n->low, TREE_VALUE (chain)); - chain = TREE_CHAIN (chain)) - ; - - if (!chain) - warning ("case value `%d' not in enumerated type `%s'", - TREE_INT_CST_LOW (n->low), - IDENTIFIER_POINTER (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE - ? TYPE_NAME (type) - : DECL_NAME (TYPE_NAME (type)))); - } -} - -/* Terminate a case (Pascal) or switch (C) statement - in which CASE_INDEX is the expression to be tested. - Generate the code to test it and jump to the right place. */ - -void -expand_end_case (orig_index) - tree orig_index; -{ - tree minval, maxval, range; - rtx default_label = 0; - register struct case_node *n; - int count; - rtx index; - rtx table_label = gen_label_rtx (); - int ncases; - rtx *labelvec; - register int i; - rtx before_case; - register struct nesting *thiscase = case_stack; - tree index_expr = thiscase->data.case_stmt.index_expr; - int unsignedp = TREE_UNSIGNED (TREE_TYPE (index_expr)); - - do_pending_stack_adjust (); - - /* An ERROR_MARK occurs for various reasons including invalid data type. */ - if (TREE_TYPE (index_expr) != error_mark_node) - { - /* If switch expression was an enumerated type, check that all - enumeration literals are covered by the cases. - No sense trying this if there's a default case, however. */ - - if (!thiscase->data.case_stmt.default_label - && TREE_CODE (TREE_TYPE (orig_index)) == ENUMERAL_TYPE - && TREE_CODE (index_expr) != INTEGER_CST - && warn_switch) - check_for_full_enumeration_handling (TREE_TYPE (orig_index)); - - /* If we don't have a default-label, create one here, - after the body of the switch. */ - if (thiscase->data.case_stmt.default_label == 0) - { - thiscase->data.case_stmt.default_label - = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); - expand_label (thiscase->data.case_stmt.default_label); - } - default_label = label_rtx (thiscase->data.case_stmt.default_label); - - before_case = get_last_insn (); - - /* Simplify the case-list before we count it. */ - group_case_nodes (thiscase->data.case_stmt.case_list); - - /* Get upper and lower bounds of case values. - Also convert all the case values to the index expr's data type. */ - - count = 0; - for (n = thiscase->data.case_stmt.case_list; n; n = n->right) - { - /* Check low and high label values are integers. */ - if (TREE_CODE (n->low) != INTEGER_CST) - abort (); - if (TREE_CODE (n->high) != INTEGER_CST) - abort (); - - n->low = convert (TREE_TYPE (index_expr), n->low); - n->high = convert (TREE_TYPE (index_expr), n->high); - - /* Count the elements and track the largest and smallest - of them (treating them as signed even if they are not). */ - if (count++ == 0) - { - minval = n->low; - maxval = n->high; - } - else - { - if (INT_CST_LT (n->low, minval)) - minval = n->low; - if (INT_CST_LT (maxval, n->high)) - maxval = n->high; - } - /* A range counts double, since it requires two compares. */ - if (! tree_int_cst_equal (n->low, n->high)) - count++; - } - - /* Compute span of values. */ - if (count != 0) - range = combine (MINUS_EXPR, maxval, minval); - - if (count == 0 || TREE_CODE (TREE_TYPE (index_expr)) == ERROR_MARK) - { - expand_expr (index_expr, const0_rtx, VOIDmode, 0); - emit_queue (); - emit_jump (default_label); - } - /* If range of values is much bigger than number of values, - make a sequence of conditional branches instead of a dispatch. - If the switch-index is a constant, do it this way - because we can optimize it. */ - else if (TREE_INT_CST_HIGH (range) != 0 -#ifdef HAVE_casesi - || count < 4 -#else - /* If machine does not have a case insn that compares the - bounds, this means extra overhead for dispatch tables - which raises the threshold for using them. */ - || count < 5 -#endif - || (unsigned) (TREE_INT_CST_LOW (range)) > 10 * count - || TREE_CODE (index_expr) == INTEGER_CST) - { - index = expand_expr (index_expr, 0, VOIDmode, 0); - - /* If the index is a short or char that we do not have - an insn to handle comparisons directly, convert it to - a full integer now, rather than letting each comparison - generate the conversion. */ - - if ((GET_MODE (index) == QImode || GET_MODE (index) == HImode) - && (cmp_optab->handlers[(int) GET_MODE(index)].insn_code - == CODE_FOR_nothing)) - index = convert_to_mode (SImode, index, unsignedp); - - emit_queue (); - do_pending_stack_adjust (); - - index = protect_from_queue (index, 0); - if (GET_CODE (index) == MEM) - index = copy_to_reg (index); - if (GET_CODE (index) == CONST_INT - || TREE_CODE (index_expr) == INTEGER_CST) - { - /* Make a tree node with the proper constant value - if we don't already have one. */ - if (TREE_CODE (index_expr) != INTEGER_CST) - { - index_expr - = build_int_2 (INTVAL (index), - !unsignedp && INTVAL (index) >= 0 ? 0 : -1); - index_expr = convert (TREE_TYPE (index_expr), index_expr); - } - - /* For constant index expressions we need only - issue a unconditional branch to the appropriate - target code. The job of removing any unreachable - code is left to the optimisation phase if the - "-O" option is specified. */ - for (n = thiscase->data.case_stmt.case_list; - n; - n = n->right) - { - if (! tree_int_cst_lt (index_expr, n->low) - && ! tree_int_cst_lt (n->high, index_expr)) - break; - } - if (n) - emit_jump (label_rtx (n->code_label)); - else - emit_jump (default_label); - } - else - { - /* If the index expression is not constant we generate - a binary decision tree to select the appropriate - target code. This is done as follows: - - The list of cases is rearranged into a binary tree, - nearly optimal assuming equal probability for each case. - - The tree is transformed into RTL, eliminating - redundant test conditions at the same time. - - If program flow could reach the end of the - decision tree an unconditional jump to the - default code is emitted. */ - if (optimize - && TREE_CODE (TREE_TYPE (orig_index)) != ENUMERAL_TYPE) - estimate_case_costs (thiscase->data.case_stmt.case_list, - default_label); - balance_case_nodes (&thiscase->data.case_stmt.case_list, 0); - emit_case_nodes (index, thiscase->data.case_stmt.case_list, - default_label, unsignedp); - emit_jump_if_reachable (default_label); - } - } - else - { -#ifdef HAVE_casesi - /* Convert the index to SImode. */ - if (TYPE_MODE (TREE_TYPE (index_expr)) == DImode) - { - index_expr = build (MINUS_EXPR, TREE_TYPE (index_expr), - index_expr, minval); - minval = integer_zero_node; - } - if (TYPE_MODE (TREE_TYPE (index_expr)) != SImode) - index_expr = convert (type_for_size (GET_MODE_BITSIZE (SImode), 0), - index_expr); - index = expand_expr (index_expr, 0, VOIDmode, 0); - emit_queue (); - index = protect_from_queue (index, 0); - do_pending_stack_adjust (); - - emit_jump_insn (gen_casesi (index, expand_expr (minval, 0, VOIDmode, 0), - expand_expr (range, 0, VOIDmode, 0), - table_label, default_label)); -#else -#ifdef HAVE_tablejump - index_expr = convert (type_for_size (GET_MODE_BITSIZE (SImode), 0), - build (MINUS_EXPR, TREE_TYPE (index_expr), - index_expr, minval)); - index = expand_expr (index_expr, 0, VOIDmode, 0); - emit_queue (); - index = protect_from_queue (index, 0); - do_pending_stack_adjust (); - - do_tablejump (index, - gen_rtx (CONST_INT, VOIDmode, TREE_INT_CST_LOW (range)), - table_label, default_label); -#else - lossage; -#endif /* not HAVE_tablejump */ -#endif /* not HAVE_casesi */ - - /* Get table of labels to jump to, in order of case index. */ - - ncases = TREE_INT_CST_LOW (range) + 1; - labelvec = (rtx *) alloca (ncases * sizeof (rtx)); - bzero (labelvec, ncases * sizeof (rtx)); - - for (n = thiscase->data.case_stmt.case_list; n; n = n->right) - { - register int i - = TREE_INT_CST_LOW (n->low) - TREE_INT_CST_LOW (minval); - - while (i + TREE_INT_CST_LOW (minval) - <= TREE_INT_CST_LOW (n->high)) - labelvec[i++] - = gen_rtx (LABEL_REF, Pmode, label_rtx (n->code_label)); - } - - /* Fill in the gaps with the default. */ - for (i = 0; i < ncases; i++) - if (labelvec[i] == 0) - labelvec[i] = gen_rtx (LABEL_REF, Pmode, default_label); - - /* Output the table */ - emit_label (table_label); - -#ifdef CASE_VECTOR_PC_RELATIVE - emit_jump_insn (gen_rtx (ADDR_DIFF_VEC, CASE_VECTOR_MODE, - gen_rtx (LABEL_REF, Pmode, table_label), - gen_rtvec_v (ncases, labelvec))); -#else - emit_jump_insn (gen_rtx (ADDR_VEC, CASE_VECTOR_MODE, - gen_rtvec_v (ncases, labelvec))); -#endif - /* If the case insn drops through the table, - after the table we must jump to the default-label. - Otherwise record no drop-through after the table. */ -#ifdef CASE_DROPS_THROUGH - emit_jump (default_label); -#else - emit_barrier (); -#endif - } - - reorder_insns (NEXT_INSN (before_case), get_last_insn (), - thiscase->data.case_stmt.start); - } - if (thiscase->exit_label) - emit_label (thiscase->exit_label); - - POPSTACK (case_stack); -} - -/* See case.c for CASE-handling code. */ - -/* Allocate fixed slots in the stack frame of the current function. */ - -/* Return size needed for stack frame based on slots so far allocated. */ - -int -get_frame_size () -{ -#ifdef FRAME_GROWS_DOWNWARD - return -frame_offset + STARTING_FRAME_OFFSET; -#else - return frame_offset - STARTING_FRAME_OFFSET; -#endif -} - -/* Allocate a stack slot of SIZE bytes and return a MEM rtx for it - with machine mode MODE. */ - -rtx -assign_stack_local (mode, size) - enum machine_mode mode; - int size; -{ - register rtx x, addr; - int bigend_correction = 0; - - frame_pointer_needed = 1; - - /* Make each stack slot a multiple of the main allocation unit. */ - size = (((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1) - / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)) - * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); - - /* On a big-endian machine, if we are allocating more space than we will use, - use the least significant bytes of those that are allocated. */ -#ifdef BYTES_BIG_ENDIAN - if (mode != BLKmode) - bigend_correction = size - GET_MODE_SIZE (mode); -#endif - -#ifdef FRAME_GROWS_DOWNWARD - frame_offset -= size; -#endif - addr = gen_rtx (PLUS, Pmode, frame_pointer_rtx, - gen_rtx (CONST_INT, VOIDmode, - (frame_offset + bigend_correction))); -#ifndef FRAME_GROWS_DOWNWARD - frame_offset += size; -#endif - - if (! memory_address_p (mode, addr)) - invalid_stack_slot = 1; - - x = gen_rtx (MEM, mode, addr); - - stack_slot_list = gen_rtx (EXPR_LIST, VOIDmode, x, stack_slot_list); - - return x; -} - -/* Retroactively move an auto variable from a register to a stack slot. - This is done when an address-reference to the variable is seen. */ - -void -put_var_into_stack (decl) - tree decl; -{ - register rtx reg = DECL_RTL (decl); - register rtx new; - - /* No need to do anything if decl has no rtx yet - since in that case caller is setting TREE_ADDRESSABLE - and a stack slot will be assigned when the rtl is made. */ - if (reg == 0) - return; - if (GET_CODE (reg) != REG) - return; - - new = parm_stack_loc (reg); - if (new == 0) - new = assign_stack_local (GET_MODE (reg), GET_MODE_SIZE (GET_MODE (reg))); - - XEXP (reg, 0) = XEXP (new, 0); - /* `volatil' bit means one thing for MEMs, another entirely for REGs. */ - REG_USERVAR_P (reg) = 0; - PUT_CODE (reg, MEM); - - /* If this is a memory ref that contains aggregate components, - mark it as such for cse and loop optimize. */ - MEM_IN_STRUCT_P (reg) - = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE - || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE); - - fixup_var_refs (reg); -} - -static void -fixup_var_refs (var) - rtx var; -{ - extern rtx sequence_stack; - rtx stack = sequence_stack; - tree pending; - - stack = sequence_stack; - - /* Must scan all insns for stack-refs that exceed the limit. */ - fixup_var_refs_insns (var, get_insns (), stack == 0); - - /* Scan all pending sequences too. */ - for (; stack; stack = XEXP (XEXP (stack, 1), 1)) - { - push_to_sequence (XEXP (stack, 0)); - fixup_var_refs_insns (var, XEXP (stack, 0), - XEXP (XEXP (stack, 1), 1) == 0); - /* Update remembered end of sequence - in case we added an insn at the end. */ - XEXP (XEXP (stack, 1), 0) = get_last_insn (); - end_sequence (); - } - - /* Scan all waiting RTL_EXPRs too. */ - for (pending = rtl_expr_chain; pending; pending = TREE_CHAIN (pending)) - { - rtx seq = RTL_EXPR_SEQUENCE (TREE_VALUE (pending)); - if (seq != const0_rtx && seq != 0) - { - push_to_sequence (seq); - fixup_var_refs_insns (var, seq, 0); - end_sequence (); - } - } -} - -/* Scan the insn-chain starting with INSN for refs to VAR - and fix them up. TOPLEVEL is nonzero if this chain is the - main chain of insns for the current function. */ - -static void -fixup_var_refs_insns (var, insn, toplevel) - rtx var; - rtx insn; - int toplevel; -{ - while (insn) - { - rtx next = NEXT_INSN (insn); - rtx note; - if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN - || GET_CODE (insn) == JUMP_INSN) - { - /* The insn to load VAR from a home in the arglist - is now a no-op. When we see it, just delete it. */ - if (toplevel - && GET_CODE (PATTERN (insn)) == SET - && SET_DEST (PATTERN (insn)) == var - && rtx_equal_p (SET_SRC (PATTERN (insn)), var)) - { - next = delete_insn (insn); - if (insn == last_parm_insn) - last_parm_insn = PREV_INSN (next); - } - else - fixup_var_refs_1 (var, PATTERN (insn), insn); - /* Also fix up any invalid exprs in the REG_NOTES of this insn. - But don't touch other insns referred to by reg-notes; - we will get them elsewhere. */ - for (note = REG_NOTES (insn); note; note = XEXP (note, 1)) - if (GET_CODE (note) != INSN_LIST) - XEXP (note, 0) = walk_fixup_memory_subreg (XEXP (note, 0), insn); - } - insn = next; - } -} - -static rtx -fixup_var_refs_1 (var, x, insn) - register rtx var; - register rtx x; - rtx insn; -{ - register int i; - RTX_CODE code = GET_CODE (x); - register char *fmt; - register rtx tem; - - switch (code) - { - case MEM: - if (var == x) - { - x = fixup_stack_1 (x, insn); - tem = gen_reg_rtx (GET_MODE (x)); - /* Put new insn before a CALL, before any USEs before it. */ - if (GET_CODE (insn) == CALL_INSN) - while (PREV_INSN (insn) != 0 && GET_CODE (PREV_INSN (insn)) == INSN - && GET_CODE (PATTERN (PREV_INSN (insn))) == USE) - insn = PREV_INSN (insn); - emit_insn_before (gen_move_insn (tem, x), insn); - return tem; - } - break; - - case REG: - case CC0: - case PC: - case CONST_INT: - case CONST: - case SYMBOL_REF: - case LABEL_REF: - case CONST_DOUBLE: - return x; - - case SIGN_EXTRACT: - case ZERO_EXTRACT: - /* Note that in some cases those types of expressions are altered - by optimize_bit_field, and do not survive to get here. */ - case SUBREG: - tem = x; - while (GET_CODE (tem) == SUBREG || GET_CODE (tem) == SIGN_EXTRACT - || GET_CODE (tem) == ZERO_EXTRACT) - tem = XEXP (tem, 0); - if (tem == var) - { - x = fixup_stack_1 (x, insn); - tem = gen_reg_rtx (GET_MODE (x)); - if (GET_CODE (x) == SUBREG) - x = fixup_memory_subreg (x, insn); - emit_insn_before (gen_move_insn (tem, x), insn); - return tem; - } - break; - - case SET: - /* First do special simplification of bit-field references. */ - if (GET_CODE (SET_DEST (x)) == SIGN_EXTRACT - || GET_CODE (SET_DEST (x)) == ZERO_EXTRACT) - optimize_bit_field (x, insn, 0); - if (GET_CODE (SET_SRC (x)) == SIGN_EXTRACT - || GET_CODE (SET_SRC (x)) == ZERO_EXTRACT) - optimize_bit_field (x, insn, 0); - - { - rtx dest = SET_DEST (x); - rtx src = SET_SRC (x); - rtx outerdest = dest; - rtx outersrc = src; - - while (GET_CODE (dest) == SUBREG || GET_CODE (dest) == STRICT_LOW_PART - || GET_CODE (dest) == SIGN_EXTRACT - || GET_CODE (dest) == ZERO_EXTRACT) - dest = XEXP (dest, 0); - while (GET_CODE (src) == SUBREG - || GET_CODE (src) == SIGN_EXTRACT - || GET_CODE (src) == ZERO_EXTRACT) - src = XEXP (src, 0); - - /* If VAR does not appear at the top level of the SET - just scan the lower levels of the tree. */ - - if (src != var && dest != var) - break; - - /* Clean up (SUBREG:SI (MEM:mode ...) 0) - that may appear inside a SIGN_EXTRACT or ZERO_EXTRACT. - This was legitimate when the MEM was a REG. */ - - if ((GET_CODE (outerdest) == SIGN_EXTRACT - || GET_CODE (outerdest) == ZERO_EXTRACT) - && GET_CODE (XEXP (outerdest, 0)) == SUBREG - && SUBREG_REG (XEXP (outerdest, 0)) == var) - XEXP (outerdest, 0) = fixup_memory_subreg (XEXP (outerdest, 0), insn); - - if ((GET_CODE (outersrc) == SIGN_EXTRACT - || GET_CODE (outersrc) == ZERO_EXTRACT) - && GET_CODE (XEXP (outersrc, 0)) == SUBREG - && SUBREG_REG (XEXP (outersrc, 0)) == var) - XEXP (outersrc, 0) = fixup_memory_subreg (XEXP (outersrc, 0), insn); - - /* Make sure that the machine's SIGN_EXTRACT and ZERO_EXTRACT insns - accept a memory operand. */ -#ifdef HAVE_extzv - if (GET_CODE (outersrc) == ZERO_EXTRACT - && ! ((*insn_operand_predicate[(int) CODE_FOR_extzv][0]) - (XEXP (outersrc, 0), VOIDmode))) - XEXP (outersrc, 0) = src - = fixup_var_refs_1 (var, XEXP (outersrc, 0), insn); -#endif -#ifdef HAVE_extv - if (GET_CODE (outersrc) == SIGN_EXTRACT - && ! ((*insn_operand_predicate[(int) CODE_FOR_extv][0]) - (XEXP (outersrc, 0), VOIDmode))) - XEXP (outersrc, 0) = src - = fixup_var_refs_1 (var, XEXP (outersrc, 0), insn); -#endif -#ifdef HAVE_insv - if (GET_CODE (outerdest) == ZERO_EXTRACT - && ! ((*insn_operand_predicate[(int) CODE_FOR_insv][0]) - (XEXP (outerdest, 0), VOIDmode))) - { - rtx tem = gen_reg_rtx (GET_MODE (XEXP (outerdest, 0))); - - emit_insn_before (gen_move_insn (tem, XEXP (outerdest, 0)), insn); - emit_insn_after (gen_move_insn (XEXP (outerdest, 0), tem), insn); - dest = XEXP (outerdest, 0) = tem; - } -#endif - - /* Make sure a MEM inside a SIGN_EXTRACT has QImode - since that's what bit-field insns want. */ - - if ((GET_CODE (outerdest) == SIGN_EXTRACT - || GET_CODE (outerdest) == ZERO_EXTRACT) - && GET_CODE (XEXP (outerdest, 0)) == MEM - && GET_MODE (XEXP (outerdest, 0)) != QImode) - { - XEXP (outerdest, 0) = copy_rtx (XEXP (outerdest, 0)); - PUT_MODE (XEXP (outerdest, 0), QImode); - /* Adjust the address so the bit field starts within the byte - addressed. This helps certain optimization patterns. */ - if (GET_CODE (XEXP (outerdest, 2)) == CONST_INT - && offsettable_memref_p (XEXP (outerdest, 0))) - { - int count = INTVAL (XEXP (outerdest, 2)); - XEXP (outerdest, 0) - = adj_offsettable_operand (XEXP (outerdest, 0), - count / GET_MODE_BITSIZE (QImode)); - XEXP (outerdest, 2) - = gen_rtx (CONST_INT, VOIDmode, - count % GET_MODE_BITSIZE (QImode)); - } - } - - if ((GET_CODE (outersrc) == SIGN_EXTRACT - || GET_CODE (outersrc) == ZERO_EXTRACT) - && GET_CODE (XEXP (outersrc, 0)) == MEM - && GET_MODE (XEXP (outersrc, 0)) != QImode) - { - XEXP (outersrc, 0) = copy_rtx (XEXP (outersrc, 0)); - PUT_MODE (XEXP (outersrc, 0), QImode); - /* Adjust the address so the bit field starts within the byte - addressed. This helps certain optimization patterns. */ - if (GET_CODE (XEXP (outersrc, 2)) == CONST_INT - && offsettable_memref_p (XEXP (outersrc, 0))) - { - int count = INTVAL (XEXP (outersrc, 2)); - XEXP (outersrc, 0) - = adj_offsettable_operand (XEXP (outersrc, 0), - count / GET_MODE_BITSIZE (QImode)); - XEXP (outersrc, 2) - = gen_rtx (CONST_INT, VOIDmode, - count % GET_MODE_BITSIZE (QImode)); - } - } - - /* STRICT_LOW_PART is a no-op on memory references - and it can cause combinations to be unrecognizable, - so eliminate it. */ - - if (dest == var && GET_CODE (SET_DEST (x)) == STRICT_LOW_PART) - SET_DEST (x) = XEXP (SET_DEST (x), 0); - - /* An insn to copy VAR into or out of a register - must be left alone, to avoid an infinite loop here. - But do fix up the address of VAR's stack slot if nec, - and fix up SUBREGs containing VAR - (since they are now memory subregs). */ - - if (GET_CODE (SET_SRC (x)) == REG || GET_CODE (SET_DEST (x)) == REG - || (GET_CODE (SET_SRC (x)) == SUBREG - && GET_CODE (SUBREG_REG (SET_SRC (x))) == REG) - || (GET_CODE (SET_DEST (x)) == SUBREG - && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG)) - { - if (src == var && GET_CODE (SET_SRC (x)) == SUBREG) - SET_SRC (x) = fixup_memory_subreg (SET_SRC (x), insn); - if (dest == var && GET_CODE (SET_DEST (x)) == SUBREG) - SET_DEST (x) = fixup_memory_subreg (SET_DEST (x), insn); - return fixup_stack_1 (x, insn); - } - - /* Otherwise, storing into VAR must be handled specially - by storing into a temporary and copying that into VAR - with a new insn after this one. */ - - if (dest == var) - { - rtx temp; - rtx fixeddest; - tem = SET_DEST (x); - /* STRICT_LOW_PART can be discarded, around a MEM. */ - if (GET_CODE (tem) == STRICT_LOW_PART) - tem = XEXP (tem, 0); - /* Convert (SUBREG (MEM)) to a MEM in a changed mode. */ - if (GET_CODE (tem) == SUBREG) - tem = fixup_memory_subreg (tem, insn); - fixeddest = fixup_stack_1 (tem, insn); - temp = gen_reg_rtx (GET_MODE (tem)); - emit_insn_after (gen_move_insn (fixeddest, temp), insn); - SET_DEST (x) = temp; - } - } - } - - /* Nothing special about this RTX; fix its operands. */ - - fmt = GET_RTX_FORMAT (code); - for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) - { - if (fmt[i] == 'e') - XEXP (x, i) = fixup_var_refs_1 (var, XEXP (x, i), insn); - if (fmt[i] == 'E') - { - register int j; - for (j = 0; j < XVECLEN (x, i); j++) - XVECEXP (x, i, j) - = fixup_var_refs_1 (var, XVECEXP (x, i, j), insn); - } - } - return x; -} - -/* Given X, an rtx of the form (SUBREG:m1 (MEM:m2 addr)), - return an rtx (MEM:m1 newaddr) which is equivalent. - If any insns must be emitted to compute NEWADDR, put them before INSN. */ - -static rtx -fixup_memory_subreg (x, insn) - rtx x; - rtx insn; -{ - int offset = SUBREG_WORD (x) * UNITS_PER_WORD; - rtx addr = XEXP (SUBREG_REG (x), 0); - enum machine_mode mode = GET_MODE (x); - rtx saved, result; - -#ifdef BYTES_BIG_ENDIAN - offset += (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) - - MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))); -#endif - addr = plus_constant (addr, offset); - if (memory_address_p (mode, addr)) - return change_address (SUBREG_REG (x), mode, addr); - saved = start_sequence (); - result = change_address (SUBREG_REG (x), mode, addr); - emit_insn_before (gen_sequence (), insn); - end_sequence (saved); - return result; -} - -/* Do fixup_memory_subreg on all (SUBREG (MEM ...) ...) contained in X. - Replace subexpressions of X in place. - If X itself is a (SUBREG (MEM ...) ...), return the replacement expression. - Otherwise return X, with its contents possibly altered. - - If any insns must be emitted to compute NEWADDR, put them before INSN. */ - -static rtx -walk_fixup_memory_subreg (x, insn) - register rtx x; - rtx insn; -{ - register enum rtx_code code; - register char *fmt; - register int i; - - if (x == 0) - return 0; - - code = GET_CODE (x); - - if (code == SUBREG && GET_CODE (SUBREG_REG (x)) == MEM) - return fixup_memory_subreg (x, insn); - - /* Nothing special about this RTX; fix its operands. */ - - fmt = GET_RTX_FORMAT (code); - for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) - { - if (fmt[i] == 'e') - XEXP (x, i) = walk_fixup_memory_subreg (XEXP (x, i), insn); - if (fmt[i] == 'E') - { - register int j; - for (j = 0; j < XVECLEN (x, i); j++) - XVECEXP (x, i, j) - = walk_fixup_memory_subreg (XVECEXP (x, i, j), insn); - } - } - return x; -} - -#if 0 -/* Fix up any references to stack slots that are invalid memory addresses - because they exceed the maximum range of a displacement. */ - -void -fixup_stack_slots () -{ - register rtx insn; - - /* Did we generate a stack slot that is out of range - or otherwise has an invalid address? */ - if (invalid_stack_slot) - { - /* Yes. Must scan all insns for stack-refs that exceed the limit. */ - for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) - if (GET_CODE (insn) == INSN || GET_CODE (insn) == CALL_INSN - || GET_CODE (insn) == JUMP_INSN) - fixup_stack_1 (PATTERN (insn), insn); - } -} -#endif - -/* For each memory ref within X, if it refers to a stack slot - with an out of range displacement, put the address in a temp register - (emitting new insns before INSN to load these registers) - and alter the memory ref to use that register. - Replace each such MEM rtx with a copy, to avoid clobberage. */ - -static rtx -fixup_stack_1 (x, insn) - rtx x; - rtx insn; -{ - register int i; - register RTX_CODE code = GET_CODE (x); - register char *fmt; - - if (code == MEM) - { - register rtx ad = XEXP (x, 0); - /* If we have address of a stack slot but it's not valid - (displacement is too large), compute the sum in a register. */ - if (GET_CODE (ad) == PLUS - && XEXP (ad, 0) == frame_pointer_rtx - && GET_CODE (XEXP (ad, 1)) == CONST_INT) - { - rtx temp; - if (memory_address_p (GET_MODE (x), ad)) - return x; - temp = gen_reg_rtx (GET_MODE (ad)); - emit_insn_before (gen_move_insn (temp, ad), insn); - return change_address (x, VOIDmode, temp); - } - return x; - } - - fmt = GET_RTX_FORMAT (code); - for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) - { - if (fmt[i] == 'e') - XEXP (x, i) = fixup_stack_1 (XEXP (x, i), insn); - if (fmt[i] == 'E') - { - register int j; - for (j = 0; j < XVECLEN (x, i); j++) - XVECEXP (x, i, j) = fixup_stack_1 (XVECEXP (x, i, j), insn); - } - } - return x; -} - -/* Optimization: a bit-field instruction whose field - happens to be a byte or halfword in memory - can be changed to a move instruction. - - We call here when INSN is an insn to examine or store into a bit-field. - BODY is the SET-rtx to be altered. - - EQUIV_MEM is the table `reg_equiv_mem' if that is available; else 0. - (Currently this is called only from stmt.c, and EQUIV_MEM is always 0.) */ - -static void -optimize_bit_field (body, insn, equiv_mem) - rtx body; - rtx insn; - rtx *equiv_mem; -{ - register rtx bitfield; - int destflag; - - if (GET_CODE (SET_DEST (body)) == SIGN_EXTRACT - || GET_CODE (SET_DEST (body)) == ZERO_EXTRACT) - bitfield = SET_DEST (body), destflag = 1; - else - bitfield = SET_SRC (body), destflag = 0; - - /* First check that the field being stored has constant size and position - and is in fact a byte or halfword suitably aligned. */ - - if (GET_CODE (XEXP (bitfield, 1)) == CONST_INT - && GET_CODE (XEXP (bitfield, 2)) == CONST_INT - && (INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (QImode) - || INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (HImode)) - && INTVAL (XEXP (bitfield, 2)) % INTVAL (XEXP (bitfield, 1)) == 0) - { - register rtx memref = 0; - - /* Now check that the containing word is memory, not a register, - and that it is safe to change the machine mode and to - add something to the address. */ - - if (GET_CODE (XEXP (bitfield, 0)) == MEM) - memref = XEXP (bitfield, 0); - else if (GET_CODE (XEXP (bitfield, 0)) == REG - && equiv_mem != 0) - memref = equiv_mem[REGNO (XEXP (bitfield, 0))]; - else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG - && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == MEM) - memref = SUBREG_REG (XEXP (bitfield, 0)); - else if (GET_CODE (XEXP (bitfield, 0)) == SUBREG - && equiv_mem != 0 - && GET_CODE (SUBREG_REG (XEXP (bitfield, 0))) == REG) - memref = equiv_mem[REGNO (SUBREG_REG (XEXP (bitfield, 0)))]; - - if (memref - && ! mode_dependent_address_p (XEXP (memref, 0)) - && offsettable_address_p (0, GET_MODE (bitfield), XEXP (memref, 0))) - { - /* Now adjust the address, first for any subreg'ing - that we are now getting rid of, - and then for which byte of the word is wanted. */ - - register int offset - = INTVAL (XEXP (bitfield, 2)) / GET_MODE_BITSIZE (QImode); - if (GET_CODE (XEXP (bitfield, 0)) == SUBREG) - { - offset += SUBREG_WORD (XEXP (bitfield, 0)) * UNITS_PER_WORD; -#ifdef BYTES_BIG_ENDIAN - offset -= (MIN (UNITS_PER_WORD, - GET_MODE_SIZE (GET_MODE (XEXP (bitfield, 0)))) - - MIN (UNITS_PER_WORD, - GET_MODE_SIZE (GET_MODE (memref)))); -#endif - } - - memref = gen_rtx (MEM, - (INTVAL (XEXP (bitfield, 1)) == GET_MODE_BITSIZE (QImode) - ? QImode : HImode), - XEXP (memref, 0)); - - /* Store this memory reference where - we found the bit field reference. */ - - if (destflag) - { - SET_DEST (body) - = adj_offsettable_operand (memref, offset); - if (! CONSTANT_ADDRESS_P (SET_SRC (body))) - { - rtx src = SET_SRC (body); - while (GET_CODE (src) == SUBREG - && SUBREG_WORD (src) == 0) - src = SUBREG_REG (src); - if (GET_MODE (src) != GET_MODE (memref)) - src = gen_lowpart (GET_MODE (memref), SET_SRC (body)); - SET_SRC (body) = src; - } - else if (GET_MODE (SET_SRC (body)) != VOIDmode - && GET_MODE (SET_SRC (body)) != GET_MODE (memref)) - /* This shouldn't happen because anything that didn't have - one of these modes should have got converted explicitly - and then referenced through a subreg. - This is so because the original bit-field was - handled by agg_mode and so its tree structure had - the same mode that memref now has. */ - abort (); - } - else - { - rtx dest = SET_DEST (body); - - while (GET_CODE (dest) == SUBREG - && SUBREG_WORD (dest) == 0) - dest = SUBREG_REG (dest); - SET_DEST (body) = dest; - - memref = adj_offsettable_operand (memref, offset); - if (GET_MODE (dest) == GET_MODE (memref)) - SET_SRC (body) = memref; - else - { - /* Convert the mem ref to the destination mode. */ - rtx last = get_last_insn (); - rtx newreg = gen_reg_rtx (GET_MODE (dest)); - convert_move (newreg, memref, - GET_CODE (SET_SRC (body)) == ZERO_EXTRACT); - /* Put the conversion before the insn being fixed. */ - reorder_insns (NEXT_INSN (last), get_last_insn (), - PREV_INSN (insn)); - SET_SRC (body) = newreg; - } - } - - /* Cause the insn to be re-recognized. */ - - INSN_CODE (insn) = -1; - } - } -} - -/* 1 + last pseudo register number used for loading a copy - of a parameter of this function. */ - -static int max_parm_reg; - -/* Vector indexed by REGNO, containing location on stack in which - to put the parm which is nominally in pseudo register REGNO, - if we discover that that parm must go in the stack. */ -static rtx *parm_reg_stack_loc; - -int -max_parm_reg_num () -{ - return max_parm_reg; -} - -/* Return the first insn following those generated by `assign_parms'. */ - -rtx -get_first_nonparm_insn () -{ - if (last_parm_insn) - return NEXT_INSN (last_parm_insn); - return get_insns (); -} - -/* Get the stack home of a REG rtx that is one of this function's parameters. - This is called rather than assign a new stack slot as a local. - Return 0 if there is no existing stack home suitable for such use. */ - -static rtx -parm_stack_loc (reg) - rtx reg; -{ - if (REGNO (reg) < max_parm_reg) - return parm_reg_stack_loc[REGNO (reg)]; - return 0; -} - -/* Return 1 if EXP returns an aggregate value, for which an address - must be passed to the function or returned by the function. */ - -int -aggregate_value_p (exp) - tree exp; -{ - if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode) - return 1; - if (RETURN_IN_MEMORY (TREE_TYPE (exp))) - return 1; - if (flag_pcc_struct_return - && (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE - || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE)) - return 1; - return 0; -} - -/* Convert a mem ref into one with a valid memory address. - Pass through anything else unchanged. */ - -rtx -validize_mem (ref) - rtx ref; -{ - if (GET_CODE (ref) != MEM) - return ref; - if (memory_address_p (GET_MODE (ref), XEXP (ref, 0))) - return ref; - return change_address (ref, VOIDmode, - memory_address (GET_MODE (ref), XEXP (ref, 0))); -} - -/* Assign RTL expressions to the function's parameters. - This may involve copying them into registers and using - those registers as the RTL for them. */ - -static void -assign_parms (fndecl) - tree fndecl; -{ - register tree parm; - register rtx entry_parm; - register rtx stack_parm; - register CUMULATIVE_ARGS args_so_far; - enum machine_mode passed_mode, nominal_mode; - /* Total space needed so far for args on the stack, - given as a constant and a tree-expression. */ - struct args_size stack_args_size; - int first_parm_offset = FIRST_PARM_OFFSET (fndecl); - tree fntype = TREE_TYPE (fndecl); - /* This is used for the arg pointer when referring to stack args. */ - rtx internal_arg_pointer; - - int nparmregs - = list_length (DECL_ARGUMENTS (fndecl)) + FIRST_PSEUDO_REGISTER; - - /* Nonzero if function takes extra anonymous args. - This means the last named arg must be on the stack - right before the anonymous ones. - Also nonzero if the first arg is named `__builtin_va_alist', - which is used on some machines for old-fashioned non-ANSI varargs.h; - this too should be stuck onto the stack as if it had arrived there. */ - int vararg - = ((DECL_ARGUMENTS (fndecl) != 0 - && DECL_NAME (DECL_ARGUMENTS (fndecl)) - && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (DECL_ARGUMENTS (fndecl))), - "__builtin_va_alist"))) - || - (TYPE_ARG_TYPES (fntype) != 0 - && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype))) - != void_type_node))); - int arg_pointer_copied = 0; - -#if ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM - internal_arg_pointer = arg_pointer_rtx; -#else - /* If the arg pointer reg is not a fixed reg, - make a copy of it, and address parms via the copy. */ - if (fixed_regs[ARG_POINTER_REGNUM]) - internal_arg_pointer = arg_pointer_rtx; - else - { - internal_arg_pointer = copy_to_reg (arg_pointer_rtx); - arg_pointer_copied = 1; - } -#endif - - stack_args_size.constant = 0; - stack_args_size.var = 0; - - /* If struct value address comes on the stack, count it in size of args. */ - if (aggregate_value_p (DECL_RESULT (fndecl)) - && GET_CODE (struct_value_incoming_rtx) == MEM) - stack_args_size.constant += GET_MODE_SIZE (Pmode); - - parm_reg_stack_loc = (rtx *) oballoc (nparmregs * sizeof (rtx)); - bzero (parm_reg_stack_loc, nparmregs * sizeof (rtx)); - - INIT_CUMULATIVE_ARGS (args_so_far, fntype); - - for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm)) - { - int aggregate - = (TREE_CODE (TREE_TYPE (parm)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE (parm)) == RECORD_TYPE - || TREE_CODE (TREE_TYPE (parm)) == UNION_TYPE); - struct args_size stack_offset; - rtx stack_offset_rtx; - enum direction where_pad; - /* Extra bytes to add in after parameter is assigned, in - case where argument cannot be assigned an offsetted - location. For example, BLKmode parameters cannot be - other than on a word boundary (no matter the size) - because `access_parm_map' does not know how to handle - that case. */ - int extra = 0; - - DECL_OFFSET (parm) = -1; - - if (TREE_TYPE (parm) == error_mark_node - /* This can happen after weird syntax errors - or if an enum type is defined among the parms. */ - || TREE_CODE (parm) != PARM_DECL - || DECL_ARG_TYPE (parm) == NULL) - { - DECL_RTL (parm) = gen_rtx (MEM, BLKmode, const0_rtx); - TREE_USED (parm) = 1; - continue; - } - - /* Find mode of arg as it is passed, and mode of arg - as it should be during execution of this function. */ - passed_mode = TYPE_MODE (DECL_ARG_TYPE (parm)); - nominal_mode = TYPE_MODE (TREE_TYPE (parm)); - - /* Get this parm's offset as an rtx. */ - stack_offset = stack_args_size; - stack_offset.constant += first_parm_offset; - - /* If this argument needs more than the usual parm alignment, do - extrinsic padding to reach that alignment. */ - -#ifdef MAX_PARM_BOUNDARY - /* If MAX_PARM_BOUNDARY is not defined, it means that the usual - alignment requirements are relaxed for parms, and that no parm - needs more alignment than PARM_BOUNDARY, regardless of data type. */ - - if (PARM_BOUNDARY < TYPE_ALIGN (DECL_ARG_TYPE (parm))) - { - int boundary = PARM_BOUNDARY; - - /* Determine the boundary to pad up to. */ - if (TYPE_ALIGN (DECL_ARG_TYPE (parm)) > boundary) - boundary = TYPE_ALIGN (DECL_ARG_TYPE (parm)); - if (boundary > MAX_PARM_BOUNDARY) - boundary = MAX_PARM_BOUNDARY; - - /* If the previous args don't reach such a boundary, - advance to the next one. */ - boundary /= BITS_PER_UNIT; - stack_offset.constant += boundary - 1; - stack_offset.constant &= ~(boundary - 1); - stack_args_size.constant += boundary - 1; - stack_args_size.constant &= ~(boundary - 1); - - if (stack_offset.var != 0) - abort (); /* This case not implemented yet */ - } -#endif /* MAX_PARM_BOUNDARY */ - - /* Find out if the parm needs intrinsic padding (up to PARM_BOUNDARY), - and whether above or below. */ - - where_pad - = FUNCTION_ARG_PADDING (passed_mode, - expand_expr (size_in_bytes (DECL_ARG_TYPE (parm)), - 0, VOIDmode, 0)); - - /* If arg should be padded below, adjust the stack address upward. - This padding is considered part of the space occupied by the - argument. It pads only up to PARM_BOUNDARY, and it does not - depend on the previous arguments, since they are assumed to - occupy a multiple of PARM_BOUNDARY. */ - - if (where_pad == downward) - { - if (passed_mode != BLKmode) - { - if (GET_MODE_BITSIZE (passed_mode) % PARM_BOUNDARY) - stack_offset.constant - += (((GET_MODE_BITSIZE (passed_mode) + PARM_BOUNDARY - 1) - / PARM_BOUNDARY * PARM_BOUNDARY / BITS_PER_UNIT) - - GET_MODE_SIZE (passed_mode)); - } - else - { - tree sizetree = size_in_bytes (DECL_ARG_TYPE (parm)); - if (TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT != PARM_BOUNDARY) - { - /* Round the size up to multiple of PARM_BOUNDARY bits. */ - tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY); - tree s2 = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT); - /* Add it in. */ - ADD_PARM_SIZE (stack_offset, s2); - SUB_PARM_SIZE (stack_offset, sizetree); - extra = stack_offset.constant % UNITS_PER_WORD; - stack_offset.constant -= extra; - } - } - } - - stack_offset_rtx = ARGS_SIZE_RTX (stack_offset); - - /* Determine parm's home in the stack, - in case it arrives in the stack or we should pretend it did. */ - stack_parm - = gen_rtx (MEM, passed_mode, - memory_address (passed_mode, - gen_rtx (PLUS, Pmode, - internal_arg_pointer, - stack_offset_rtx))); - - /* If this is a memory ref that contains aggregate components, - mark it as such for cse and loop optimize. */ - MEM_IN_STRUCT_P (stack_parm) = aggregate; - - /* Let machine desc say which reg (if any) the parm arrives in. - 0 means it arrives on the stack. */ - entry_parm = 0; - /* Variable-size args, and args following such, are never in regs. */ - if (TREE_CODE (TYPE_SIZE (TREE_TYPE (parm))) == INTEGER_CST - || stack_offset.var != 0) - { - /* Set LAST_NAMED if this is last named arg before some - anonymous args. We treat it as if it were anonymous too. */ - int last_named = (TREE_CHAIN (parm) == 0 && vararg); -#ifdef FUNCTION_INCOMING_ARG - entry_parm - = FUNCTION_INCOMING_ARG (args_so_far, passed_mode, - DECL_ARG_TYPE (parm), ! last_named); -#else - entry_parm - = FUNCTION_ARG (args_so_far, passed_mode, DECL_ARG_TYPE (parm), - ! last_named); -#endif - } - - /* If this parm was passed part in regs and part in memory, - pretend it arrived entirely in memory - by pushing the register-part onto the stack. - - In the special case of a DImode or DFmode that is split, - we could put it together in a pseudoreg directly, - but for now that's not worth bothering with. */ - - if (entry_parm) - { - int nregs = 0; - int i; -#ifdef FUNCTION_ARG_PARTIAL_NREGS - nregs = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, passed_mode, - DECL_ARG_TYPE (parm), 1); -#endif - -#if 0 /* Replaced by new calling convention - which actually passes these args on the stack. */ - /* If this is the last named arg and anonymous args follow, - likewise pretend this arg arrived on the stack - so varargs can find the anonymous args following it. */ - if (TREE_CHAIN (parm) == 0 && vararg) - { - if (GET_MODE (entry_parm) == BLKmode) - nregs = GET_MODE_SIZE (GET_MODE (entry_parm)) / UNITS_PER_WORD; - else - nregs = (int_size_in_bytes (DECL_ARG_TYPE (parm)) - / UNITS_PER_WORD); - } -#endif /* 0 */ - - if (nregs > 0) - { - current_function_pretend_args_size - = (((nregs * UNITS_PER_WORD) + (PARM_BOUNDARY / BITS_PER_UNIT) - 1) - / (PARM_BOUNDARY / BITS_PER_UNIT) - * (PARM_BOUNDARY / BITS_PER_UNIT)); - - i = nregs; - while (--i >= 0) - emit_move_insn (gen_rtx (MEM, SImode, - plus_constant (XEXP (stack_parm, 0), - i * GET_MODE_SIZE (SImode))), - gen_rtx (REG, SImode, REGNO (entry_parm) + i)); - entry_parm = stack_parm; - } - } - - /* If we didn't decide this parm came in a register, - by default it came on the stack. */ - if (entry_parm == 0) - entry_parm = stack_parm; - - /* For a stack parm, record in DECL_OFFSET the arglist offset - of the parm at the time it is passed (before conversion). */ - if (entry_parm == stack_parm) - DECL_OFFSET (parm) = stack_offset.constant * BITS_PER_UNIT; - - /* If there is actually space on the stack for this parm, - count it in stack_args_size; otherwise set stack_parm to 0 - to indicate there is no preallocated stack slot for the parm. */ - - if (entry_parm == stack_parm -#ifdef REG_PARM_STACK_SPACE - /* On some machines, even if a parm value arrives in a register - there is still an (uninitialized) stack slot allocated for it. */ - || 1 -#endif - ) - { - tree sizetree = size_in_bytes (DECL_ARG_TYPE (parm)); - if (where_pad != none - && TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT != PARM_BOUNDARY) - { - /* Round the size up to multiple of PARM_BOUNDARY bits. */ - tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY); - sizetree = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT); - } - /* Add it in. */ - ADD_PARM_SIZE (stack_args_size, sizetree); - } - else - /* No stack slot was pushed for this parm. */ - stack_parm = 0; - - /* Now adjust STACK_PARM to the mode and precise location - where this parameter should live during execution, - if we discover that it must live in the stack during execution. - To make debuggers happier on big-endian machines, we store - the value in the last bytes of the space available. */ - - if (nominal_mode != BLKmode && nominal_mode != passed_mode - && stack_parm != 0) - { -#ifdef BYTES_BIG_ENDIAN - if (GET_MODE_SIZE (nominal_mode) < UNITS_PER_WORD) - { - stack_offset.constant - += GET_MODE_SIZE (passed_mode) - - GET_MODE_SIZE (nominal_mode); - stack_offset_rtx = ARGS_SIZE_RTX (stack_offset); - } -#endif - - stack_parm - = gen_rtx (MEM, nominal_mode, - memory_address (nominal_mode, - gen_rtx (PLUS, Pmode, - arg_pointer_rtx, - stack_offset_rtx))); - - /* If this is a memory ref that contains aggregate components, - mark it as such for cse and loop optimize. */ - MEM_IN_STRUCT_P (stack_parm) = aggregate; - } - - /* If there is rounding to do for a BLKmode parameter, - add it in here, since STACK_OFFSET is not used for the - rest of this iteration. */ - stack_offset.constant += extra; - - /* ENTRY_PARM is an RTX for the parameter as it arrives, - in the mode in which it arrives. - STACK_PARM is an RTX for a stack slot where the parameter can live - during the function (in case we want to put it there). - STACK_PARM is 0 if no stack slot was pushed for it. - - Now output code if necessary to convert ENTRY_PARM to - the type in which this function declares it, - and store that result in an appropriate place, - which may be a pseudo reg, may be STACK_PARM, - or may be a local stack slot if STACK_PARM is 0. - - Set DECL_RTL to that place. */ - - if (nominal_mode == BLKmode) - { - /* If a BLKmode arrives in registers, copy it to a stack slot. */ - if (GET_CODE (entry_parm) == REG) - { - if (stack_parm == 0) - stack_parm - = assign_stack_local (GET_MODE (entry_parm), - int_size_in_bytes (TREE_TYPE (parm))); - - move_block_from_reg (REGNO (entry_parm), stack_parm, - ((int_size_in_bytes (TREE_TYPE (parm)) - + UNITS_PER_WORD - 1) - / UNITS_PER_WORD)); - } - else if (vararg) - { - /* If this function uses varargs, and `__builtin_saveregs' - can clobber this stack location, then protect it. */ - rtx pseudo_parm; -#ifdef FUNCTION_INCOMING_ARG - pseudo_parm - = FUNCTION_INCOMING_ARG (args_so_far, SImode, - integer_type_node, 1); -#else - pseudo_parm - = FUNCTION_ARG (args_so_far, SImode, - integer_type_node, 1); -#endif - if (pseudo_parm && GET_CODE (pseudo_parm) == REG) - { - push_to_sequence (save_from_saveregs); - move_block_to_reg (REGNO (pseudo_parm), stack_parm, - int_size_in_bytes (TREE_TYPE (parm)) - / UNITS_PER_WORD); - save_from_saveregs = get_insns (); - end_sequence (0); - } - } - DECL_RTL (parm) = stack_parm; - } - else if (! ((obey_regdecls && ! TREE_REGDECL (parm) - && ! TREE_INLINE (fndecl)) - /* layout_decl may set this. */ - || TREE_ADDRESSABLE (parm) - || TREE_VOLATILE (parm) - /* If -ffloat-store specified, don't put explicit - float variables into registers. */ - || (flag_float_store - && TREE_CODE (TREE_TYPE (parm)) == REAL_TYPE))) - { - /* Store the parm in a pseudoregister during the function. */ - register rtx parmreg = gen_reg_rtx (nominal_mode); - - REG_USERVAR_P (parmreg) = 1; - DECL_RTL (parm) = parmreg; - - /* Copy the value into the register. */ - if (GET_MODE (parmreg) != GET_MODE (entry_parm)) - convert_move (parmreg, validize_mem (entry_parm), 0); - else - emit_move_insn (parmreg, validize_mem (entry_parm)); - - /* In any case, record the parm's desired stack location - in case we later discover it must live in the stack. */ - if (REGNO (parmreg) >= nparmregs) - { - rtx *new; - nparmregs = REGNO (parmreg) + 5; - new = (rtx *) oballoc (nparmregs * sizeof (rtx)); - bcopy (parm_reg_stack_loc, new, nparmregs * sizeof (rtx)); - parm_reg_stack_loc = new; - } - parm_reg_stack_loc[REGNO (parmreg)] = stack_parm; - - /* Mark the register as eliminable if we did no conversion - and it was copied from memory at a fixed offset, - and the arg pointer was not copied to a pseudo-reg. - If the arg pointer is a pseudo reg, such memory-equivalences - as we make here would screw up life analysis for it. */ - if (nominal_mode == passed_mode - && GET_CODE (entry_parm) == MEM - && stack_offset.var == 0 - && ! arg_pointer_copied) - REG_NOTES (get_last_insn ()) - = gen_rtx (EXPR_LIST, REG_EQUIV, - entry_parm, REG_NOTES (get_last_insn ())); - - /* For pointer data type, suggest pointer register. */ - if (TREE_CODE (TREE_TYPE (parm)) == POINTER_TYPE) - mark_reg_pointer (parmreg); - } - else - { - /* Value must be stored in the stack slot STACK_PARM - during function execution. */ - - if (passed_mode != nominal_mode) - /* Conversion is required. */ - entry_parm = convert_to_mode (nominal_mode, entry_parm, 0); - - if (entry_parm != stack_parm) - { - if (stack_parm == 0) - stack_parm = assign_stack_local (GET_MODE (entry_parm), - GET_MODE_SIZE (GET_MODE (entry_parm))); - emit_move_insn (validize_mem (stack_parm), - validize_mem (entry_parm)); - } - - DECL_RTL (parm) = stack_parm; - frame_pointer_needed = 1; - } - - if (TREE_VOLATILE (parm)) - MEM_VOLATILE_P (DECL_RTL (parm)) = 1; - if (TREE_READONLY (parm)) - RTX_UNCHANGING_P (DECL_RTL (parm)) = 1; - - /* Update info on where next arg arrives in registers. */ - - FUNCTION_ARG_ADVANCE (args_so_far, passed_mode, DECL_ARG_TYPE (parm), 1); - } - - max_parm_reg = max_reg_num (); - last_parm_insn = get_last_insn (); - - current_function_args_size = stack_args_size.constant; -} - -/* Allocation of space for returned structure values. - During the rtl generation pass, `get_structure_value_addr' - is called from time to time to request the address of a block in our - stack frame in which called functions will store the structures - they are returning. The same space is used for all of these blocks. - - We allocate these blocks like stack locals. We keep reusing - the same block until a bigger one is needed. */ - -/* Length in bytes of largest structure value returned by - any function called so far in this function. */ -static int max_structure_value_size; - -/* An rtx for the addr we are currently using for structure values. - This is typically (PLUS (REG:SI stackptr) (CONST_INT...)). */ -static rtx structure_value; - -rtx -get_structure_value_addr (sizex) - rtx sizex; -{ - register int size; - if (GET_CODE (sizex) != CONST_INT) - abort (); - size = INTVAL (sizex); - - /* Round up to a multiple of the main allocation unit. */ - size = (((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1) - / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)) - * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); - - /* If this size is bigger than space we know to use, - get a bigger piece of space. */ - if (size > max_structure_value_size) - { - max_structure_value_size = size; - structure_value = assign_stack_local (BLKmode, size); - if (GET_CODE (structure_value) == MEM) - structure_value = XEXP (structure_value, 0); - } - - return structure_value; -} - -/* Walk the tree of LET_STMTs describing the binding levels within a function - and warn about uninitialized variables. - This is done after calling flow_analysis and before global_alloc - clobbers the pseudo-regs to hard regs. */ - -void -uninitialized_vars_warning (block) - tree block; -{ - register tree decl, sub; - for (decl = STMT_VARS (block); decl; decl = TREE_CHAIN (decl)) - { - if (TREE_CODE (decl) == VAR_DECL - /* These warnings are unreliable for and aggregates - because assigning the fields one by one can fail to convince - flow.c that the entire aggregate was initialized. - Unions are troublesome because members may be shorter. */ - && TREE_CODE (TREE_TYPE (decl)) != RECORD_TYPE - && TREE_CODE (TREE_TYPE (decl)) != UNION_TYPE - && TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE - && DECL_RTL (decl) != 0 - && GET_CODE (DECL_RTL (decl)) == REG - && regno_uninitialized (REGNO (DECL_RTL (decl)))) - warning_with_decl (decl, - "`%s' may be used uninitialized in this function"); - if (TREE_CODE (decl) == VAR_DECL - && DECL_RTL (decl) != 0 - && GET_CODE (DECL_RTL (decl)) == REG - && regno_clobbered_at_setjmp (REGNO (DECL_RTL (decl)))) - warning_with_decl (decl, - "variable `%s' may be clobbered by `longjmp'"); - } - for (sub = STMT_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub)) - uninitialized_vars_warning (sub); -} - -/* If this function call setjmp, put all vars into the stack - unless they were declared `register'. */ - -void -setjmp_protect (block) - tree block; -{ - register tree decl, sub; - for (decl = STMT_VARS (block); decl; decl = TREE_CHAIN (decl)) - if ((TREE_CODE (decl) == VAR_DECL - || TREE_CODE (decl) == PARM_DECL) - && DECL_RTL (decl) != 0 - && GET_CODE (DECL_RTL (decl)) == REG - && ! TREE_REGDECL (decl)) - put_var_into_stack (decl); - for (sub = STMT_SUBBLOCKS (block); sub; sub = TREE_CHAIN (sub)) - setjmp_protect (sub); -} - -/* Generate RTL for the start of the function SUBR (a FUNCTION_DECL tree node) - and initialize static variables for generating RTL for the statements - of the function. */ - -void -init_function_start (subr) - tree subr; -{ - this_function = subr; - cse_not_expected = ! optimize; - - /* We have not yet found a reason why a frame pointer cannot - be omitted for this function in particular, but maybe we know - a priori that it is required. - `flag_omit_frame_pointer' has its main effect here. */ - frame_pointer_needed = FRAME_POINTER_REQUIRED || ! flag_omit_frame_pointer; - - /* Caller save not needed yet. */ - caller_save_needed = 0; - - /* No gotos have been expanded yet. */ - goto_fixup_chain = 0; - - /* No stack slots have been made yet. */ - stack_slot_list = 0; - - /* No invalid stack slots have been made yet. */ - invalid_stack_slot = 0; - - /* No parm regs have been allocated. - (This is important for output_inline_function.) */ - max_parm_reg = FIRST_PSEUDO_REGISTER; - - /* Initialize the RTL mechanism. */ - init_emit (write_symbols); - - /* Initialize the queue of pending postincrement and postdecrements, - and some other info in expr.c. */ - init_expr (); - - init_const_rtx_hash_table (); - - /* Decide whether function should try to pop its args on return. */ - - current_function_pops_args = RETURN_POPS_ARGS (TREE_TYPE (subr)); - - current_function_name = (char *)lang_printable_name (subr); - - /* Nonzero if this is a nested function that uses a static chain. */ - - current_function_needs_context - = (DECL_CONTEXT (current_function_decl) != 0 - && TREE_CODE (DECL_CONTEXT (current_function_decl)) == LET_STMT); - - /* Set if a call to setjmp is seen. */ - - current_function_calls_setjmp = 0; - current_function_calls_alloca = 0; - - current_function_returns_pcc_struct = 0; - current_function_returns_struct = 0; - - /* No space assigned yet for structure values. */ - max_structure_value_size = 0; - structure_value = 0; - - /* We are not currently within any block, conditional, loop or case. - @@ No longer true. We are within the block for the parms. */ - block_stack = 0; - loop_stack = 0; - case_stack = 0; - cond_stack = 0; - nesting_stack = 0; - nesting_depth = 0; - - block_start_count = 0; - - /* We have not yet needed to make a label to jump to for tail-recursion. */ - tail_recursion_label = 0; - - /* No stack slots allocated yet. */ - frame_offset = STARTING_FRAME_OFFSET; - - /* No SAVE_EXPRs in this function yet. */ - save_expr_regs = 0; - - /* No parameters to protect from `__builtin_saveregs' yet. */ - save_from_saveregs = 0; - - /* No RTL_EXPRs in this function yet. */ - rtl_expr_chain = 0; - - /* Within function body, compute a type's size as soon it is laid out. */ - immediate_size_expand++; - - init_pending_stack_adjust (); - inhibit_defer_pop = 0; - current_function_pretend_args_size = 0; - - /* Prevent ever trying to delete the first instruction of a function. - Also tell final how to output a linenum before the function prologue. */ - emit_line_note (DECL_SOURCE_FILE (subr), DECL_SOURCE_LINE (subr)); - /* Make sure first insn is a note even if we don't want linenums. - This makes sure the first insn will never be deleted. - Also, final expects a note to appear there. */ - emit_note (0, NOTE_INSN_DELETED); - /* Indicate the beginning of the function body, - as opposed to parm setup. */ - emit_note (0, NOTE_INSN_FUNCTION_BEG); - - /* Set flags used by final.c. */ - if (aggregate_value_p (DECL_RESULT (subr))) - { -#ifdef PCC_STATIC_STRUCT_RETURN - if (flag_pcc_struct_return) - current_function_returns_pcc_struct = 1; - else -#endif - current_function_returns_struct = 1; - } -} - -/* Start the RTL for a new function, and set variables used for - emitting RTL. - SUBR is the FUNCTION_DECL node. - PARMS_HAVE_CLEANUPS is nonzero if there are cleanups associated with - the function's parameters, which must be run at any return statement. */ - -void -expand_function_start (subr, parms_have_cleanups) - tree subr; - int parms_have_cleanups; -{ - register int i; - tree tem; - - /* Make sure volatile mem refs aren't considered - valid operands of arithmetic insns. */ - init_recog (); - - /* If the parameters of this function need cleaning up, get a label - for the beginning of the code which executes those cleanups. This must - be done before doing anything with return_label. */ - if (parms_have_cleanups) - cleanup_label = gen_label_rtx (); - else - cleanup_label = 0; - - /* Make the label for return statements to jump to, if this machine - does not have a one-instruction return and uses an epilogue, - or if it returns a structure, or if it has parm cleanups. */ -#ifdef HAVE_return - if (cleanup_label == 0 && HAVE_return - && ! current_function_returns_pcc_struct - && ! (current_function_returns_struct && ! optimize)) - return_label = 0; - else - return_label = gen_label_rtx (); -#else - return_label = gen_label_rtx (); -#endif - - /* Initialize rtx used to return the value. */ - /* Do this before assign_parms so that we copy the struct value address - before any library calls that assign parms might generate. */ - - /* Decide whether to return the value in memory or in a register. */ - if (aggregate_value_p (DECL_RESULT (subr))) - { - /* Returning something that won't go in a register. */ - register rtx value_address; - -#ifdef PCC_STATIC_STRUCT_RETURN - if (flag_pcc_struct_return) - { - int size = int_size_in_bytes (TREE_TYPE (DECL_RESULT (subr))); - value_address = assemble_static_space (size); - current_function_returns_pcc_struct = 1; - } - else -#endif - { - /* Expect to be passed the address of a place to store the value. */ - value_address = gen_reg_rtx (Pmode); - emit_move_insn (value_address, struct_value_incoming_rtx); - current_function_returns_struct = 1; - } - DECL_RTL (DECL_RESULT (subr)) - = gen_rtx (MEM, DECL_MODE (DECL_RESULT (subr)), - value_address); - } - else if (DECL_MODE (DECL_RESULT (subr)) == VOIDmode) - /* If return mode is void, this decl rtl should not be used. */ - DECL_RTL (DECL_RESULT (subr)) = 0; - else if (parms_have_cleanups) - { - /* If function will end with cleanup code for parms, - compute the return values into a pseudo reg, - which we will copy into the true return register - after the cleanups are done. */ - DECL_RTL (DECL_RESULT (subr)) - = gen_reg_rtx (DECL_MODE (DECL_RESULT (subr))); - TREE_REGDECL (DECL_RESULT (subr)) = 1; - } - else - /* Scalar, returned in a register. */ - { -#ifdef FUNCTION_OUTGOING_VALUE - DECL_RTL (DECL_RESULT (subr)) - = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr); -#else - DECL_RTL (DECL_RESULT (subr)) - = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (subr)), subr); -#endif - - current_function_returns_pointer - = (TREE_CODE (DECL_RESULT_TYPE (subr)) == POINTER_TYPE); - - /* Mark this reg as the function's return value. */ - if (GET_CODE (DECL_RTL (DECL_RESULT (subr))) == REG) - { - REG_FUNCTION_VALUE_P (DECL_RTL (DECL_RESULT (subr))) = 1; - TREE_REGDECL (DECL_RESULT (subr)) = 1; - } - } - - /* Initialize rtx for parameters and local variables. - In some cases this requires emitting insns. */ - - assign_parms (subr); - -#if 0 - /* Not yet defined in GCC 1.37.1. */ - - /* Tell final that the parameters are in the final places - (either on the stack or in registers). */ - emit_note ((char *) 0, NOTE_INSN_PARMS_HOMED); -#endif - - /* If doing stupid allocation, mark parms as born here. */ - - if (GET_CODE (get_last_insn ()) != NOTE) - emit_note (0, NOTE_INSN_DELETED); - parm_birth_insn = get_last_insn (); - - if (obey_regdecls) - { - for (i = FIRST_PSEUDO_REGISTER; i < max_parm_reg; i++) - use_variable (regno_reg_rtx[i]); - } - - /* After the parm initializations is where the tail-recursion label - should go, if we end up needing one. */ - tail_recursion_reentry = get_last_insn (); - - /* Evaluate now the sizes of any types declared among the arguments. */ - for (tem = get_pending_sizes (); tem; tem = TREE_CHAIN (tem)) - expand_expr (TREE_VALUE (tem), 0, VOIDmode, 0); - - /* Make sure there is a line number after the function entry setup code. - There normally is one anyway, from the following statement, - but there could fail to be one if there is no newline here. */ - force_next_line_note (); -} - -/* Generate RTL for the end of the current function. - FILENAME and LINE are the current position in the source file. */ - -/* ??? Nobody seems to emit the cleanup_label and the cleanups themselves. - - !!! Not true. finish_function does this is cplus-decl.c. */ - -void -expand_function_end (filename, line) - char *filename; - int line; -{ - register int i; - tree decl; - extern rtx sequence_stack; - -#if 0 /* I think unused parms are legitimate enough. */ - /* Warn about unused parms. */ - if (warn_unused) - for (decl = DECL_ARGUMENTS (current_function_decl); - decl; decl = TREE_CHAIN (decl)) - if (! TREE_USED (decl) && TREE_CODE (decl) == VAR_DECL) - warning_with_decl (decl, "unused parameter `%s'"); -#endif - - /* End any sequences that failed to be closed due to syntax errors. */ - while (sequence_stack) - end_sequence (0); - - /* Outside function body, can't compute type's actual size - until next function's body starts. */ - immediate_size_expand--; - - /* If doing stupid register allocation, - mark register parms as dying here. */ - - if (obey_regdecls) - { - rtx tem; - for (i = FIRST_PSEUDO_REGISTER; i < max_parm_reg; i++) - use_variable (regno_reg_rtx[i]); - - /* Likewise for the regs of all the SAVE_EXPRs in the function. */ - - for (tem = save_expr_regs; tem; tem = XEXP (tem, 1)) - { - use_variable (XEXP (tem, 0)); - use_variable_after (XEXP (tem, 0), parm_birth_insn); - } - } - - clear_pending_stack_adjust (); - do_pending_stack_adjust (); - - /* Mark the end of the function body. - If control reaches this insn, the function can drop through - without returning a value. */ - emit_note (0, NOTE_INSN_FUNCTION_END); - - /* Output a linenumber for the end of the function. - SDB depends on this. */ - emit_line_note_force (filename, line); - - /* Output the label for the actual return from the function, - if one is expected. This happens either because a function epilogue - is used instead of a return instruction, or because a return was done - with a goto in order to run local cleanups, or because of pcc-style - structure returning. */ - - if (return_label) - emit_label (return_label); - - /* If we had calls to alloca, and this machine needs - an accurate stack pointer to exit the function, - insert some code to save and restore the stack pointer. */ -#ifdef EXIT_IGNORE_STACK - if (! EXIT_IGNORE_STACK) -#endif - if (current_function_calls_alloca) - { - rtx tem = gen_reg_rtx (Pmode); - emit_insn_after (gen_rtx (SET, VOIDmode, tem, stack_pointer_rtx), - parm_birth_insn); - emit_insn (gen_rtx (SET, VOIDmode, stack_pointer_rtx, tem)); - } - - /* If scalar return value was computed in a pseudo-reg, - copy that to the hard return register. */ - if (DECL_RTL (DECL_RESULT (current_function_decl)) != 0 - && GET_CODE (DECL_RTL (DECL_RESULT (current_function_decl))) == REG - && (REGNO (DECL_RTL (DECL_RESULT (current_function_decl))) - >= FIRST_PSEUDO_REGISTER)) - { - rtx real_decl_result; - -#ifdef FUNCTION_OUTGOING_VALUE - real_decl_result - = FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (current_function_decl)), - current_function_decl); -#else - real_decl_result - = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (current_function_decl)), - current_function_decl); -#endif - REG_FUNCTION_VALUE_P (real_decl_result) = 1; - emit_move_insn (real_decl_result, - DECL_RTL (DECL_RESULT (current_function_decl))); - emit_insn (gen_rtx (USE, VOIDmode, real_decl_result)); - } - - /* If returning a structure, arrange to return the address of the value - in a place where debuggers expect to find it. */ - /* If returning a structure PCC style, - the caller also depends on this value. - And current_function_returns_pcc_struct is not necessarily set. */ - if (current_function_returns_struct - || current_function_returns_pcc_struct) - { - rtx value_address = XEXP (DECL_RTL (DECL_RESULT (current_function_decl)), 0); - tree type = TREE_TYPE (DECL_RESULT (current_function_decl)); -#ifdef FUNCTION_OUTGOING_VALUE - rtx outgoing - = FUNCTION_OUTGOING_VALUE (build_pointer_type (type), - current_function_decl); -#else - rtx outgoing - = hard_function_value (build_pointer_type (type), - current_function_decl); -#endif - -#if 1 - /* If this works, leave it in. */ - /* This is not really the function value, - and it confuses integrate.c around line 1211. */ - REG_FUNCTION_VALUE_P (outgoing) = 1; -#endif - - emit_move_insn (outgoing, value_address); - use_variable (outgoing); - } - - /* Output a return insn if we are using one. - Otherwise, let the rtl chain end here, to drop through - into the epilogue. */ - -#ifdef HAVE_return - if (HAVE_return) - emit_jump_insn (gen_return ()); -#endif - - /* Fix up any gotos that jumped out to the outermost - binding level of the function. - Must follow emitting RETURN_LABEL. */ - - /* If you have any cleanups to do at this point, - and they need to create temporary variables, - then you will lose. */ - fixup_gotos (0, 0, 0, get_insns (), 0); -} - -init_stmt () -{ - obstack_init (&stmt_obstack); - empty_cleanup_list = build_tree_list (NULL_TREE, NULL_TREE); -} diff --git a/gnu/usr.bin/g++/cc1plus/stor-layout.c b/gnu/usr.bin/g++/cc1plus/stor-layout.c deleted file mode 100644 index 6affca5cb861..000000000000 --- a/gnu/usr.bin/g++/cc1plus/stor-layout.c +++ /dev/null @@ -1,1049 +0,0 @@ -/* C-compiler utilities for types and variables storage layout - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include "config.h" -#include - -#include "tree.h" -#include "rtl.h" /* For GET_MODE_SIZE */ - -#define MAX(x,y) ((x) > (y) ? (x) : (y)) -#define MIN(x,y) ((x) < (y) ? (x) : (y)) -#define CEIL(x,y) (((x) + (y) - 1) / (y)) - -/* Data type for the expressions representing sizes of data types. - It is the first integer type laid out. - In C, this is int. */ - -tree sizetype; - -/* An integer constant with value 0 whose type is sizetype. */ - -tree size_zero_node; - -/* An integer constant with value 1 whose type is sizetype. */ - -tree size_one_node; - -/* Integer constants with sizes for pointers and reference types, - function types, and method types respectively. */ -static tree ptr_size_node, function_size_node, method_size_node; - -#define GET_MODE_ALIGNMENT(MODE) \ - MIN (BIGGEST_ALIGNMENT, \ - MAX (1, (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT))) - -/* Chain of all permanent types we have allocated since last - call to get_permanent_types. */ - -tree permanent_type_chain; - -/* Chain of all temporary types we have allocated in this function. */ - -tree temporary_type_chain; - -/* When the chains is not null, these point at the last - types on the two chains. These help us tell whether a type - is already on a chain. */ -tree permanent_type_end; -tree temporary_type_end; - -/* Put the newly-made type T - on either permanent_type_chain or temporary_type_chain. - Types that are const or volatile variants of other types - are not put on any chain, since in the gdb symbol segment - we do not make those distinctions. - - If T is already on the chain, we do nothing. */ - -void -chain_type (t) - tree t; -{ - if (TYPE_MAIN_VARIANT (t) != t) - return; - if (TREE_CHAIN (t) != 0) - return; - if (TREE_PERMANENT (t)) - { - /* If T is on the chain at the end, don't chain it to itself! */ - if (t == permanent_type_end) - return; - /* Add T to the end of the chain. */ - if (permanent_type_chain == 0) - permanent_type_chain = t; - else - TREE_CHAIN (permanent_type_end) = t; - permanent_type_end = t; - } - else - { - if (t == temporary_type_end) - return; - if (temporary_type_chain == 0) - temporary_type_chain = t; - else - TREE_CHAIN (temporary_type_end) = t; - temporary_type_end = t; - } -} - -/* Get a chain of all permanent types made since this function - was last called. */ - -tree -get_permanent_types () -{ - register tree tem = permanent_type_chain; - permanent_type_chain = 0; - permanent_type_end = 0; - return tem; -} - -/* Get a chain of all temporary types made since this function - was last called. */ - -tree -get_temporary_types () -{ - register tree tem = temporary_type_chain; - temporary_type_chain = 0; - temporary_type_end = 0; - return tem; -} - -/* SAVE_EXPRs for sizes of types and decls, waiting to be expanded. */ - -static tree pending_sizes; - -/* Nonzero means cannot safely call expand_expr now, - so put variable sizes onto `pending_sizes' instead. */ - -int immediate_size_expand; - -tree -get_pending_sizes () -{ - tree chain = pending_sizes; - pending_sizes = 0; - return chain; -} - -/* Given a size SIZE that isn't constant, return a SAVE_EXPR - to serve as the actual size-expression for a type or decl. */ - -static tree -variable_size (size) - tree size; -{ - size = save_expr (size); - - if (global_bindings_p ()) - { - error ("variable-size type declared outside of any function"); - return build_int (1); - } - - if (immediate_size_expand) - expand_expr (size, 0, VOIDmode, 0); - else - pending_sizes = tree_cons (0, size, pending_sizes); - - return size; -} - -/* Return the machine mode to use for an aggregate of SIZE bits. - - Note!!! We only use a non-BLKmode mode if the size matches exactly. - There used to be the idea of using DImode for anything whose - size was less than DImode but more than SImode. This does not work - because DImode moves cannot be used to store such objects in memory. */ - -#ifndef MAX_FIXED_MODE_SIZE -#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (DImode) -#endif - -static -enum machine_mode -agg_mode (size) - unsigned int size; -{ - register int units = size / BITS_PER_UNIT; - register enum machine_mode t, val; - - if (size % BITS_PER_UNIT != 0) - return BLKmode; - - if (size > MAX_FIXED_MODE_SIZE) - return BLKmode; - - /* Get the last mode which has this size. */ - val = BLKmode; - for (t = QImode; GET_MODE_CLASS (t) == MODE_INT; - t = (enum machine_mode) ((int) t + 1)) - if (GET_MODE_SIZE (t) == units) - val = t; - - return val; -} - -/* Return an INTEGER_CST with value V and type from `sizetype'. */ - -tree -build_int (v) - int v; -{ - register tree t; - - t = build_int_2 (v, 0); - TREE_TYPE (t) = sizetype; - return t; -} - -/* Combine operands OP1 and OP2 with arithmetic operation OPC. - OPC is a tree code. Data type is taken from `sizetype', - If the operands are constant, so is the result. */ - -tree -genop (opc, op1, op2) - enum tree_code opc; - tree op1, op2; -{ - /* Handle the special case of two integer constants faster. */ - if (TREE_CODE (op1) == INTEGER_CST && TREE_CODE (op2) == INTEGER_CST) - { - /* And some specific cases even faster than that. */ - if (opc == PLUS_EXPR - && TREE_INT_CST_LOW (op1) == 0 - && TREE_INT_CST_HIGH (op1) == 0) - return op2; - if (opc == MINUS_EXPR - && TREE_INT_CST_LOW (op2) == 0 - && TREE_INT_CST_HIGH (op2) == 0) - return op1; - if (opc == MULT_EXPR - && TREE_INT_CST_LOW (op1) == 1 - && TREE_INT_CST_HIGH (op1) == 0) - return op2; - if (opc == CEIL_DIV_EXPR - && TREE_INT_CST_LOW (op1) == TREE_INT_CST_LOW (op2) - && TREE_INT_CST_HIGH (op1) == TREE_INT_CST_HIGH (op2)) - return size_one_node; - /* Handle general case of two integer constants. */ - return combine (opc, op1, op2); - } - - if (op1 == error_mark_node || op2 == error_mark_node) - return error_mark_node; - - return fold (build (opc, sizetype, op1, op2)); -} - -/* Convert a size which is SIZE when expressed in unit INUNITS - into the units OUTUNITS. Rounds up if conversion is not exact. - If SIZE is constant, so is the result. */ - -tree -convert_units (size, inunits, outunits) - tree size; - register int inunits, outunits; -{ - register tree t; - - if (inunits == outunits) - return size; - /* Check for inunits divisible by outunits. - In that case, just multiply by their ratio. */ - if (0 == (inunits % outunits)) - return genop (MULT_EXPR, size, build_int (inunits / outunits)); - /* The inverse case. */ - if (0 == (outunits % inunits)) - { - /* Discard anything in SIZE to round it up to a multiple - of a number N that divides our current divisor. */ - if (TREE_CODE (size) == MULT_EXPR - && TREE_CODE (TREE_OPERAND (size, 1)) == INTEGER_CST - && 0 == (outunits / inunits) % TREE_INT_CST_LOW (TREE_OPERAND (size, 1)) - && TREE_CODE (TREE_OPERAND (size, 0)) == CEIL_DIV_EXPR - && tree_int_cst_equal (TREE_OPERAND (size, 1), - TREE_OPERAND (TREE_OPERAND (size, 0), 1))) - size = TREE_OPERAND (TREE_OPERAND (size, 0), 0); - return genop (CEIL_DIV_EXPR, size, build_int (outunits / inunits)); - } - /* The general case. */ - t = genop (MULT_EXPR, size, - build_int (inunits)); /* convert to bits */ - return genop (CEIL_DIV_EXPR, t, - build_int (outunits)); /* then to outunits */ -} - -/* Set the size, mode and alignment of a ..._DECL node. - TYPE_DECL does need this for C++. It is up to language-specific - code to intialize the DECL_OFFSET of TYPE_DECL nodes. - Note that LABEL_DECL and CONST_DECL nodes do not need this, - and FUNCTION_DECL nodes have them set up in a special (and simple) way. - Don't call layout_decl for them. - - KNOWN_ALIGN is the amount of alignment we can assume this - decl has with no special effort. It is relevant only for FIELD_DECLs - and depends on the previous fields. - All that matters about KNOWN_ALIGN is which powers of 2 divide it. - If KNOWN_ALIGN is 0, it means, "as much alignment as you like": - the record will be aligned to suit. */ - -void -layout_decl (decl, known_align) - tree decl; - unsigned known_align; -{ - register tree type = TREE_TYPE (decl); - register enum tree_code code = TREE_CODE (decl); - int spec_size = DECL_SIZE_UNIT (decl); - int bitsize; - - if (code == CONST_DECL) - return; - - if (code != VAR_DECL && code != PARM_DECL && code != RESULT_DECL - && code != FIELD_DECL && code != TYPE_DECL) - abort (); - - if (type == error_mark_node) - { - type = void_type_node; - spec_size = 0; - } - if (TYPE_SIZE_UNIT (type) == 0) - abort (); - - /* Usually the size and mode come from the data type without change. */ - - DECL_MODE (decl) = TYPE_MODE (type); - DECL_SIZE (decl) = TYPE_SIZE (type); - DECL_SIZE_UNIT (decl) = TYPE_SIZE_UNIT (type); - TREE_UNSIGNED (decl) = TREE_UNSIGNED (type); - - if (code == FIELD_DECL && TREE_PACKED (decl)) - { - /* This is a bit-field. We don't know how to handle - them except for integers and enums, and front end should - never generate them otherwise. */ - - if (! (TREE_CODE (type) == INTEGER_TYPE - || TREE_CODE (type) == ENUMERAL_TYPE)) - abort (); - - if (spec_size == 0) - abort (); - - /* Mode is "integer bit field". */ - DECL_MODE (decl) = BImode; - /* Size is specified number of bits. */ - DECL_SIZE (decl) = size_one_node; - DECL_SIZE_UNIT (decl) = spec_size; - } - /* Force alignment required for the data type. - But if the decl itself wants greater alignment, don't override that. */ - else if (TYPE_ALIGN (type) > DECL_ALIGN (decl)) - DECL_ALIGN (decl) = TYPE_ALIGN (type); - - if (DECL_SIZE (decl)) - bitsize = TREE_INT_CST_LOW (DECL_SIZE (decl)) * DECL_SIZE_UNIT (decl); - - /* See if we can use a scalar mode such as QImode or SImode - in place of BLKmode or a packed byte mode. */ - /* Conditions are: a fixed size that is correct for another mode - and occupying a complete byte or bytes on proper boundary. */ - if ((DECL_MODE (decl) == BLKmode - || DECL_MODE (decl) == BImode) - /* Don't do this if DECL's type requires it to be BLKmode. */ - && TYPE_MODE (type) != BLKmode - && TYPE_SIZE (type) != 0 - && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST) - { - register enum machine_mode xmode = agg_mode (bitsize); - - if (xmode != BLKmode - && known_align % GET_MODE_ALIGNMENT (xmode) == 0) - { - DECL_ALIGN (decl) = MAX (GET_MODE_ALIGNMENT (xmode), - DECL_ALIGN (decl)); - DECL_MODE (decl) = xmode; - DECL_SIZE (decl) = build_int (GET_MODE_SIZE (xmode)); - DECL_SIZE_UNIT (decl) = BITS_PER_UNIT; - bitsize = GET_MODE_BITSIZE (xmode); - } - } - - /* Don't let more than one word of an aggregate occupy one register, - since then the SUBREG used to access the high part would malfunction. - Check that the expected # of registers is big enough that they - seem to hold this variable with just a word per register. */ - if (DECL_SIZE (decl) != 0 - && (TREE_CODE (type) == RECORD_TYPE - || TREE_CODE (type) == UNION_TYPE - || TREE_CODE (type) == ARRAY_TYPE)) - { - /* This test is not exactly right, since we really want the minimum - number of regs in any class that can hold this mode. - But it does distinguish the machines we need to distinguish, - for now. */ - if (CLASS_MAX_NREGS (ALL_REGS, TYPE_MODE (type)) * BITS_PER_WORD - < bitsize) - TREE_ADDRESSABLE (decl) = 1; - } - - /* Evaluate nonconstant size only once, either now or as soon as safe. */ - if (DECL_SIZE (decl) != 0 && ! TREE_LITERAL (DECL_SIZE (decl))) - DECL_SIZE (decl) = variable_size (DECL_SIZE (decl)); -} - -/* Lay out a RECORD_TYPE type (a C struct). - This means laying out the fields, determining their offsets, - and computing the overall size and required alignment of the record. - Note that if you set the TYPE_ALIGN before calling this - then the struct is aligned to at least that boundary. - - If the type has basetypes, you must call layout_basetypes - before calling this function. */ - -static void -layout_record (rec) - tree rec; -{ - register tree field; -#ifdef STRUCTURE_SIZE_BOUNDARY - int record_align = MAX (STRUCTURE_SIZE_BOUNDARY, TYPE_ALIGN (rec)); -#else - int record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (rec)); -#endif - /* These must be laid out *after* the record is. */ - tree pending_statics = NULL_TREE; - /* Record size so far is CONST_SIZE + VAR_SIZE * SIZE_UNIT bits, - where CONST_SIZE is an integer - and VAR_SIZE is a tree expression. - If VAR_SIZE is null, the size is just CONST_SIZE. - Naturally we try to avoid using VAR_SIZE. */ - register int const_size = 0; - register tree var_size = 0; - register int size_unit = BITS_PER_UNIT; - - for (field = TYPE_FIELDS (rec); field; field = TREE_CHAIN (field)) - { - register int desired_align; - - /* If FIELD is a VAR_DECL, then treat it like a separate variable, - not really like a structure field. - If it is a FUNCTION_DECL, it's a method. - In both cases, all we do is lay out the decl, - and we do it *after* the record is laid out. */ - - if (TREE_STATIC (field)) - { - pending_statics = tree_cons (NULL, field, pending_statics); - continue; - } - /* Enumerators and enum types which are local to this class need not - be laid out. Same with initialized constant fields. */ - if (TREE_CODE (field) != FIELD_DECL) - continue; - - /* Lay out the field so we know what alignment it needs. - For KNOWN_ALIGN, pass the number of bits from start of record - or some divisor of it. */ - - layout_decl (field, var_size ? size_unit : const_size); - desired_align = DECL_ALIGN (field); - - /* Record must have at least as much alignment as any field. - Otherwise, the alignment of the field within the record - is meaningless. */ - - record_align = MAX (record_align, desired_align); -#ifdef PCC_BITFIELD_TYPE_MATTERS - /* In PCC on Vax, Sony, etc., a bit field of declare type `int' - forces the entire structure to have `int' alignment. */ - if (DECL_NAME (field) != 0) - record_align = MAX (record_align, TYPE_ALIGN (TREE_TYPE (field))); -#endif - - /* Does this field automatically have alignment it needs - by virtue of the fields that precede it and the record's - own alignment? */ - - if (const_size % desired_align != 0 - || (size_unit % desired_align != 0 - && var_size)) - { - /* No, we need to skip space before this field. - Bump the cumulative size to multiple of field alignment. */ - - if (var_size == 0 - || size_unit % desired_align == 0) - const_size - = CEIL (const_size, desired_align) * desired_align; - else - { - var_size - = genop (PLUS_EXPR, var_size, - build_int (CEIL (const_size, size_unit))); - const_size = 0; - var_size = convert_units (var_size, size_unit, desired_align); - size_unit = desired_align; - } - } - -#ifdef PCC_BITFIELD_TYPE_MATTERS - if (TREE_CODE (field) == FIELD_DECL - && TREE_TYPE (field) != error_mark_node) - { - int type_align = TYPE_ALIGN (TREE_TYPE (field)); - register tree dsize = DECL_SIZE (field); - int field_size = TREE_INT_CST_LOW (dsize) * DECL_SIZE_UNIT (field); - - /* A bit field may not span the unit of alignment of its type. - Advance to next boundary if necessary. */ - if (const_size / type_align - != (const_size + field_size - 1) / type_align) - const_size = CEIL (const_size, type_align) * type_align; - } -#endif - - /* Size so far becomes the offset of this field. */ - - DECL_OFFSET (field) = const_size; - DECL_VOFFSET (field) = var_size; - DECL_VOFFSET_UNIT (field) = size_unit; - - /* If this field is an anonymous union, - give each union-member the same offset as the union has. */ - - if (DECL_NAME (field) == 0 - && TREE_CODE (TREE_TYPE (field)) == UNION_TYPE) - { - tree uelt = TYPE_FIELDS (TREE_TYPE (field)); - for (; uelt; uelt = TREE_CHAIN (uelt)) - { - DECL_FIELD_CONTEXT (uelt) = DECL_FIELD_CONTEXT (field); - DECL_OFFSET (uelt) = DECL_OFFSET (field); - DECL_VOFFSET (uelt) = DECL_VOFFSET (field); - DECL_VOFFSET_UNIT (uelt) = DECL_VOFFSET_UNIT (field); - } - } - - /* Now add size of this field to the size of the record. */ - - { - register tree dsize = DECL_SIZE (field); - - if (TREE_LITERAL (dsize)) - const_size += TREE_INT_CST_LOW (dsize) * DECL_SIZE_UNIT (field); - else if (var_size == 0) - { - var_size = dsize; - size_unit = DECL_SIZE_UNIT (field); - } - else - { - register int tunits = MIN (size_unit, DECL_SIZE_UNIT (field)); - var_size - = genop (PLUS_EXPR, - convert_units (var_size, size_unit, tunits), - convert_units (dsize, DECL_SIZE_UNIT (field), tunits)); - } - } - } - - /* Work out the total size and alignment of the record - as one expression and store in the record type. - Round it up to a multiple of the record's alignment. */ - - if (var_size == 0) - TYPE_SIZE (rec) - = build_int (CEIL (CEIL (const_size, record_align) * record_align, - size_unit)); - else - { - if (const_size) - var_size - = genop (PLUS_EXPR, var_size, - build_int (CEIL (const_size, size_unit))); - TYPE_SIZE (rec) - = convert_units (var_size, - size_unit, - record_align); - size_unit = record_align; - } - - TYPE_SIZE (rec) = convert_units (TYPE_SIZE (rec), size_unit, - BITS_PER_UNIT); - TYPE_SIZE_UNIT (rec) = BITS_PER_UNIT; - TYPE_ALIGN (rec) = MIN (BIGGEST_ALIGNMENT, record_align); - - /* Lay out any static members. This is done now - because their type may use the record's type. */ - - for (field = pending_statics; field; field = TREE_CHAIN (field)) - layout_decl (TREE_VALUE (field), 0); -} - -/* Lay out a UNION_TYPE type. - Lay out all the fields, set their offsets to zero, - and compute the size and alignment of the union (maximum of any field). - Note that if you set the TYPE_ALIGN before calling this - then the union align is aligned to at least that boundary. */ - -static void -layout_union (rec) - tree rec; -{ - register tree field; -#ifdef STRUCTURE_SIZE_BOUNDARY - int union_align = STRUCTURE_SIZE_BOUNDARY; -#else - int union_align = BITS_PER_UNIT; -#endif - - /* The size of the union, based on the fields scanned so far, - is max (CONST_SIZE, VAR_SIZE). - VAR_SIZE may be null; then CONST_SIZE by itself is the size. */ - register int const_size = 0; - register tree var_size = 0; - - for (field = TYPE_FIELDS (rec); field; field = TREE_CHAIN (field)) - { - /* Enums which are local to this class need not - be laid out. */ - if (TREE_CODE (field) != FIELD_DECL) - continue; - - layout_decl (field, 0); - DECL_OFFSET (field) = 0; - DECL_VOFFSET (field) = 0; - DECL_VOFFSET_UNIT (field) = BITS_PER_UNIT; - - /* Union must be at least as aligned as any field requires. */ - - union_align = MAX (union_align, DECL_ALIGN (field)); - -#ifdef PCC_BITFIELD_TYPE_MATTERS - /* On the m88000, a bit field of declare type `int' - forces the entire union to have `int' alignment. */ - union_align = MAX (union_align, TYPE_ALIGN (TREE_TYPE (field))); -#endif - - /* Set union_size to max (decl_size, union_size). - There are more and less general ways to do this. - Use only CONST_SIZE unless forced to use VAR_SIZE. */ - - if (TREE_LITERAL (DECL_SIZE (field))) - const_size = MAX (const_size, - TREE_INT_CST_LOW (DECL_SIZE (field)) - * DECL_SIZE_UNIT (field)); - else if (var_size == 0) - var_size = convert_units (DECL_SIZE (field), - DECL_SIZE_UNIT (field), - BITS_PER_UNIT); - else - var_size = genop (MAX_EXPR, - convert_units (DECL_SIZE (field), - DECL_SIZE_UNIT (field), - BITS_PER_UNIT), - var_size); - } - - /* Determine the ultimate size of the union (in bytes). */ - if (NULL == var_size) - TYPE_SIZE (rec) = build_int (CEIL (const_size, BITS_PER_UNIT)); - else if (const_size == 0) - TYPE_SIZE (rec) = var_size; - else - TYPE_SIZE (rec) = genop (MAX_EXPR, var_size, - build_int (CEIL (const_size, BITS_PER_UNIT))); - - /* Determine the desired alignment. */ - union_align = MIN (BIGGEST_ALIGNMENT, union_align); - TYPE_ALIGN (rec) = MAX (TYPE_ALIGN (rec), union_align); - - /* Round the size up to be a multiple of the required alignment */ - TYPE_SIZE (rec) - = convert_units (TYPE_SIZE (rec), BITS_PER_UNIT, TYPE_ALIGN (rec)); - TYPE_SIZE_UNIT (rec) = TYPE_ALIGN (rec); -} - -/* Calculate the mode, size, and alignment for TYPE. - For an array type, calculate the element separation as well. - Record TYPE on the chain of permanent or temporary types - so that dbxout will find out about it. - - TYPE_SIZE of a type is nonzero if the type has been laid out already. - layout_type does nothing on such a type. - - If the type is incomplete, its TYPE_SIZE remains zero. */ - -void -layout_type (type) - tree type; -{ - int old; - int temporary = 0; - - if (type == 0) - abort (); - - /* Do nothing if type has been laid out before. */ - if (TYPE_SIZE (type)) - return; - - /* Make sure all nodes we allocate are not momentary; - they must last past the current statement. */ - old = suspend_momentary (); - if (TREE_PERMANENT (type) && allocation_temporary_p ()) - { - temporary = 1; - end_temporary_allocation (); - } - - chain_type (type); - - switch (TREE_CODE (type)) - { - case LANG_TYPE: - /* This kind of type is the responsibility - of the languge-specific code. */ - abort (); - - case VOID_TYPE: - TYPE_SIZE (type) = size_zero_node; - TYPE_SIZE_UNIT (type) = BITS_PER_UNIT; - TYPE_ALIGN (type) = 1; - TYPE_MODE (type) = VOIDmode; - break; - - case INTEGER_TYPE: - case ENUMERAL_TYPE: - if (TREE_INT_CST_HIGH (TYPE_MIN_VALUE (type)) >= 0) - TREE_UNSIGNED (type) = 1; - - /* What follows is like agg_mode except that it ignores - MAX_FIXED_MODE_SIZE. That applies only to structures. */ - { - enum machine_mode mode, t; - - /* Get the last mode which has this size. */ - mode = BLKmode; - for (t = QImode; GET_MODE_CLASS (t) == MODE_INT; - t = (enum machine_mode) ((int) t + 1)) - if (GET_MODE_BITSIZE (t) == TYPE_PRECISION (type)) - mode = t; - - TYPE_MODE (type) = mode; - } - TYPE_SIZE (type) = build_int (GET_MODE_SIZE (TYPE_MODE (type))); - TYPE_SIZE_UNIT (type) = BITS_PER_UNIT; - TYPE_ALIGN (type) = GET_MODE_ALIGNMENT (TYPE_MODE (type)); - break; - - case REAL_TYPE: - { - register int prec = TYPE_PRECISION (type); - if (prec <= GET_MODE_BITSIZE (SFmode)) - TYPE_MODE (type) = SFmode; - else if (prec <= GET_MODE_BITSIZE (DFmode)) - TYPE_MODE (type) = DFmode; - else if (prec <= GET_MODE_BITSIZE (TFmode)) - TYPE_MODE (type) = TFmode; - else - abort (); - } - TYPE_SIZE (type) = build_int (GET_MODE_SIZE (TYPE_MODE (type))); - TYPE_SIZE_UNIT (type) = BITS_PER_UNIT; - TYPE_ALIGN (type) = GET_MODE_ALIGNMENT (TYPE_MODE (type)); - break; - - case POINTER_TYPE: - case REFERENCE_TYPE: - TYPE_MODE (type) = Pmode; - TYPE_SIZE (type) = ptr_size_node; - TYPE_SIZE_UNIT (type) = BITS_PER_UNIT; - TYPE_ALIGN (type) = POINTER_BOUNDARY; - TREE_UNSIGNED (type) = 1; - TYPE_PRECISION (type) = POINTER_SIZE; - break; - - case ARRAY_TYPE: - { - register tree index = TYPE_DOMAIN (type); - register tree length; - register tree element = TREE_TYPE (type); - -/* layout_type (element); */ - build_pointer_type (element); - - if (index == 0) - length = 0; - else - length = genop (PLUS_EXPR, size_one_node, - genop (MINUS_EXPR, TYPE_MAX_VALUE (index), - TYPE_MIN_VALUE (index))); - - if (TREE_PACKED (type)) - abort (); /* ??? Not written yet since not needed for C. */ - - TYPE_SIZE_UNIT (type) = TYPE_SIZE_UNIT (element); - if (length && TYPE_SIZE (element)) - TYPE_SIZE (type) = genop (MULT_EXPR, TYPE_SIZE (element), length); - TYPE_SEP (type) = TYPE_SIZE (element); - TYPE_SEP_UNIT (type) = TYPE_SIZE_UNIT (element); - TYPE_ALIGN (type) = MAX (TYPE_ALIGN (element), BITS_PER_UNIT); - TYPE_MODE (type) = BLKmode; - if (TYPE_SIZE (type) != 0 - && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - /* BLKmode elements force BLKmode aggregate; - else extract/store fields may lose. */ - && TYPE_MODE (TREE_TYPE (type)) != BLKmode -#ifdef STRICT_ALIGNMENT - && (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT - || TYPE_ALIGN (type) >= (TREE_INT_CST_LOW (TYPE_SIZE (type)) - * TYPE_SIZE_UNIT (type))) -#endif - ) - { - TYPE_MODE (type) - = agg_mode (TREE_INT_CST_LOW (TYPE_SIZE (type)) - * TYPE_SIZE_UNIT (type)); - } - break; - } - - case RECORD_TYPE: - layout_record (type); - TYPE_MODE (type) = BLKmode; - if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - /* If structure's known alignment is less than - what the scalar mode would need, and it matters, - then stick with BLKmode. */ -#ifdef STRICT_ALIGNMENT - && (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT - || TYPE_ALIGN (type) >= (TREE_INT_CST_LOW (TYPE_SIZE (type)) - * TYPE_SIZE_UNIT (type))) -#endif - ) - { - tree field; - /* A record which has any BLKmode members must itself be BLKmode; - it can't go in a register. */ - for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) - { - if (TREE_CODE (field) != FIELD_DECL) - continue; - - if (TYPE_MODE (TREE_TYPE (field)) == BLKmode) - goto record_lose; - - /* Must be BLKmode if any field crosses a word boundary, - since extract_bit_field can't handle that in registers. */ - if (DECL_OFFSET (field) / BITS_PER_WORD - != ((TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field) - + DECL_OFFSET (field) - 1) - / BITS_PER_WORD)) - goto record_lose; - } - - TYPE_MODE (type) - = agg_mode (TREE_INT_CST_LOW (TYPE_SIZE (type)) - * TYPE_SIZE_UNIT (type)); - record_lose: ; - } - break; - - case UNION_TYPE: - layout_union (type); - TYPE_MODE (type) = BLKmode; - if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - /* If structure's known alignment is less than - what the scalar mode would need, and it matters, - then stick with BLKmode. */ -#ifdef STRICT_ALIGNMENT - && (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT - || TYPE_ALIGN (type) >= (TREE_INT_CST_LOW (TYPE_SIZE (type)) - * TYPE_SIZE_UNIT (type))) -#endif - ) - { - tree field; - /* A union which has any BLKmode members must itself be BLKmode; - it can't go in a register. */ - for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) - if (TYPE_MODE (TREE_TYPE (field)) == BLKmode) - goto union_lose; - - TYPE_MODE (type) - = agg_mode (TREE_INT_CST_LOW (TYPE_SIZE (type)) - * TYPE_SIZE_UNIT (type)); - union_lose: ; - } - break; - - case FUNCTION_TYPE: - TYPE_MODE (type) = EPmode; - TYPE_SIZE (type) = function_size_node; - TYPE_SIZE_UNIT (type) = BITS_PER_UNIT; - TYPE_ALIGN (type) = POINTER_BOUNDARY; - break; - - case METHOD_TYPE: - TYPE_MODE (type) = EPmode; - TYPE_SIZE (type) = method_size_node; - TYPE_SIZE_UNIT (type) = BITS_PER_UNIT; - TYPE_ALIGN (type) = POINTER_BOUNDARY; - break; - - default: - abort (); - } /* end switch */ - - /* Evaluate nonconstant size only once, either now or as soon as safe. */ - if (TYPE_SIZE (type) != 0 && ! TREE_LITERAL (TYPE_SIZE (type))) - TYPE_SIZE (type) = variable_size (TYPE_SIZE (type)); - - /* Also layout any other variants of the type. */ - if (TYPE_NEXT_VARIANT (type) - || type != TYPE_MAIN_VARIANT (type)) - { - tree variant; - /* Record layout info of this variant. */ - tree size = TYPE_SIZE (type); - int size_unit = TYPE_SIZE_UNIT (type); - int align = TYPE_ALIGN (type); - enum machine_mode mode = TYPE_MODE (type); - - /* Copy it into all variants. */ - for (variant = TYPE_MAIN_VARIANT (type); - variant; - variant = TYPE_NEXT_VARIANT (variant)) - { - TYPE_SIZE (variant) = size; - TYPE_SIZE_UNIT (variant) = size_unit; - TYPE_ALIGN (variant) = align; - TYPE_MODE (variant) = mode; - } - } - - if (temporary) - resume_temporary_allocation (); - resume_momentary (old); -} - -/* Create and return a type for signed integers of PRECISION bits. */ - -tree -make_signed_type (precision) - int precision; -{ - register tree type = make_node (INTEGER_TYPE); - - TYPE_PRECISION (type) = precision; - - /* Create the extreme values based on the number of bits. */ - - TYPE_MIN_VALUE (type) - = build_int_2 ((precision-HOST_BITS_PER_INT > 0 ? 0 : (-1)<<(precision-1)), - (-1)<<(precision-HOST_BITS_PER_INT-1 > 0 - ? precision-HOST_BITS_PER_INT-1 - : 0)); - TYPE_MAX_VALUE (type) - = build_int_2 ((precision-HOST_BITS_PER_INT > 0 ? -1 : (1<<(precision-1))-1), - (precision-HOST_BITS_PER_INT-1 > 0 - ? (1<<(precision-HOST_BITS_PER_INT-1))-1 - : 0)); - - /* Give this type's extreme values this type as their type. */ - - TREE_TYPE (TYPE_MIN_VALUE (type)) = type; - TREE_TYPE (TYPE_MAX_VALUE (type)) = type; - - /* The first type made with this or `make_unsigned_type' - is the type for size values. */ - - if (sizetype == 0) - { - sizetype = type; - ptr_size_node = build_int (POINTER_SIZE / BITS_PER_UNIT); - function_size_node = ptr_size_node; - method_size_node = build_int (2 * POINTER_SIZE / BITS_PER_UNIT); - } - - /* Lay out the type: set its alignment, size, etc. */ - - layout_type (type); - - return type; -} - -/* Create and return a type for unsigned integers of PRECISION bits. */ - -tree -make_unsigned_type (precision) - int precision; -{ - register tree type = make_node (INTEGER_TYPE); - - TYPE_PRECISION (type) = precision; - - /* The first type made with this or `make_unsigned_type' - is the type for size values. */ - - if (sizetype == 0) - { - sizetype = type; - ptr_size_node = build_int (POINTER_SIZE / BITS_PER_UNIT); - function_size_node = ptr_size_node; - method_size_node = build_int (2 * POINTER_SIZE / BITS_PER_UNIT); - } - - fixup_unsigned_type (type); - return type; -} - -/* Set the extreme values of TYPE based on its precision in bits, - the lay it out. This is used both in `make_unsigned_type' - and for enumeral types. */ - -void -fixup_unsigned_type (type) - tree type; -{ - register int precision = TYPE_PRECISION (type); - - TYPE_MIN_VALUE (type) = build_int_2 (0, 0); - TYPE_MAX_VALUE (type) - = build_int_2 (precision-HOST_BITS_PER_INT >= 0 ? -1 : (1< 0 - ? ((unsigned) ~0 - >> (HOST_BITS_PER_INT - (precision - HOST_BITS_PER_INT))) - : 0); - TREE_TYPE (TYPE_MIN_VALUE (type)) = type; - TREE_TYPE (TYPE_MAX_VALUE (type)) = type; - - /* Lay out the type: set its alignment, size, etc. */ - - layout_type (type); -} diff --git a/gnu/usr.bin/g++/cc1plus/symout.c b/gnu/usr.bin/g++/cc1plus/symout.c deleted file mode 100644 index 7f42a30c7bb6..000000000000 --- a/gnu/usr.bin/g++/cc1plus/symout.c +++ /dev/null @@ -1,1267 +0,0 @@ -/* Output GDB-format symbol table information from GNU compiler. - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include "config.h" -#include "tree.h" -#include "symseg.h" -#include "rtl.h" -#include "gdbfiles.h" -#include -#undef NULL -/* <...> used here so one can prevent use of ./stddef.h - by changing the -I options used. */ -#include - -/* Get N_SO from stab.h if we can expect the file to exist. */ -#ifdef DBX_DEBUGGING_INFO -#ifdef USG -#include "stab.h" /* If doing DBX on sysV, use our own stab.h. */ -#else -#include /* On BSD, use the system's stab.h. */ -#endif /* not USG */ -#endif - -/* .stabs code for source file name. */ -#ifndef N_SO -#define N_SO 0x64 -#endif - -/* Unix maximum on file name length. Needed for getwd. */ -#define MAXNAMLEN 1024 - -/* Get the number to output for a reference to type TYPE. */ -#define TYPE_OUTPUT_ADDRESS(TYPE) \ - TYPE_SYMTAB_ADDRESS (TYPE_MAIN_VARIANT (TYPE)) - -/* Stream for writing symbol table file. */ -static FILE *symfile; - -/* Name of symbol table file. */ -static char *symfile_name; - -/* Stream for writing to assembler file. */ -static FILE *asmfile; - -/* Address for allocating space in symbol table file. - Changes in this variable are paired globally with writes to symfile, - but often we allocate many structures, advancing next_address, - before writing any of them. */ -static int next_address; - -/* Chain recording all the types that have been output, - giving the address-in-the-symseg of each one. */ - -struct typevec_elt -{ - int address; - struct typevec_elt *next; -}; - -static struct typevec_elt *typevec; - -/* Number of types recorded so far in the chain. */ - -static int total_types; - -/* Lists of types to which forward references have been made. - Separate lists for temporary and permanent types. */ - -static tree temporary_fwd_refs; -static tree permanent_fwd_refs; - -/* `blockvec' is a chain recording all the symbol-blocks that have been output, - giving the address-in-the-symseg of each one. */ - -struct blockvec_elt -{ - int address; - struct blockvec_elt *next; -}; - -static struct blockvec_elt *blockvec; - -/* Number of blocks recorded so far in the chain. */ - -static int total_blocks; - -static void symout_range_bounds (); -static void symout_array_domain (); -static void symout_record_fields (); -static void symout_enum_values (); -static void symout_record_field_names (); -static void symout_enum_value_names (); -static int subrange_p (); -static void symout_strings_skip (); -static void symout_strings_print (); - -/* At the beginning of compilation, start writing the symbol table. - Initialize the type and block chain. - Also open and initialize the symseg file. */ - -void -symout_init (filename, asm_file, sourcename) - char *filename; - FILE *asm_file; - char *sourcename; -{ - struct symbol_root buffer; - -#ifdef VMS - fatal ("Cannot write GDB debugging format on VMS"); -#endif - - asmfile = asm_file; - fprintf (asmfile, ".text 0\n.gdbbeg 0\n.gdbbeg 1\n"); - fprintf (asmfile, - "Ltext:\t.stabs \"%s\",%d,0,0,Ltext\n", - sourcename, N_SO); - fprintf (asmfile, ".data 0\nLdata:\n"); - ASM_OUTPUT_LOCAL (asmfile, "Lbss", 0, 0); - fprintf (asmfile, ".gdbsym Ldata,%d\n", - (char *) &buffer.databeg - (char *) &buffer); - fprintf (asmfile, ".gdbsym Lbss,%d\n", - (char *) &buffer.bssbeg - (char *) &buffer); - - symfile = fopen (filename, "w"); - if (symfile == 0) - pfatal_with_name (filename); - symfile_name = (char *) malloc (strlen (filename) + 1); - strcpy (symfile_name, filename); - - typevec = 0; - blockvec = 0; - total_types = 0; - total_blocks = 0; - - permanent_fwd_refs = 0; - temporary_fwd_refs = 0; - - bzero (&buffer, sizeof buffer); - fwrite (&buffer, sizeof buffer, 1, symfile); - - next_address = sizeof buffer; -} - -/* Functions for outputting strings into the symbol table. - The string to be output is effectively the concatenation of - the two strings P1 and P2. Their lengths are given as S1 and S2. - If P1 or P2 is zero, that string is not used. - - A null character is output to terminate the string, - and it is followed by more nulls as padding to a word boundary. */ - -static void -symout_strings (p1, s1, p2, s2) - char *p1; - int s1; - char *p2; - int s2; -{ - symout_strings_print (p1, s1, p2, s2); - symout_strings_skip (p1, s1, p2, s2); -} - -/* Like symout_strings but only output; do not update next_address. */ - -static void -symout_strings_print (p1, s1, p2, s2) - char *p1; - int s1; - char *p2; - int s2; -{ - register int total; - - if (p1 && s1 == 0) - s1 = strlen (p1); - if (p2 && s2 == 0) - s2 = strlen (p2); - - if (p1) - fwrite (p1, s1, 1, symfile); - if (p2) - fwrite (p2, s2, 1, symfile); - putc (0, symfile); - - total = s1 + s2 + 1; - while (total % sizeof (int)) - { - putc (0, symfile); - total++; - } -} - -/* Like symout_strings but just update next_address; do not output. */ - -static void -symout_strings_skip (p1, s1, p2, s2) - char *p1; - int s1; - char *p2; - int s2; -{ - register int total; - - if (p1 && s1 == 0) - s1 = strlen (p1); - if (p2 && s2 == 0) - s2 = strlen (p2); - - total = s1 + s2 + 1; - while (total % sizeof (int)) - total++; - - next_address += total; -} - -/* Call here to output a chain of types. - After each function, this is done first for the chain of permanent types - made during the function, and then for the chain of temporary types. - This must be done before outputting the symbols and blocks of the function. - - At the end of compilation, this is done for all the permanent types - made since the last function. - - Each permanent type is done once, at the beginning of the next function, - or at the end of the compilation if no functions follow. - Once a type has been processed here, its TYPE_SYMTAB_ADDRESS remains - set up. */ - -void -symout_types (types) - tree types; -{ - struct typerec - { - int number; - int address; - int nfields; - int fields_address; - int name_address; - char *name; - char *name_prefix; - }; - - register int n_types, i; - register struct typerec *records; - register tree next; - struct type buffer; - int this_run_address = next_address; - - /* Count the number of types to be handled here. */ - - for (next = types, n_types = 0; - next; - next = TREE_CHAIN (next), n_types++); - - records = (struct typerec *) alloca (n_types * sizeof (struct typerec)); - - /* Compute the amount of space each type needs, updating next_address - and storing the address of the data for each type. */ - - for (next = types, i = 0; - next; - next = TREE_CHAIN (next), i++) - { - register struct typevec_elt *velt - = (struct typevec_elt *) xmalloc (sizeof (struct typevec_elt)); - velt->next = typevec; - typevec = velt; - - total_types++; - - if (TYPE_NAME (next)) - { - records[i].name_address = next_address; - - if (TREE_CODE (TYPE_NAME (next)) == IDENTIFIER_NODE) - { - records[i].name = IDENTIFIER_POINTER (TYPE_NAME (next)); - switch (TREE_CODE (next)) - { - case RECORD_TYPE: - records[i].name_prefix = "struct "; - break; - - case UNION_TYPE: - records[i].name_prefix = "union "; - break; - - case ENUMERAL_TYPE: - records[i].name_prefix = "enum "; - break; - } - } - else - { - records[i].name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (next))); - records[i].name_prefix = 0; - } - symout_strings_skip (records[i].name_prefix, 0, - records[i].name, 0); - - } - else - { - records[i].name = 0; - records[i].name_address = 0; - records[i].name_prefix = 0; - } - - /* If this type was forward-referenced from a previous call - to symout_types, store this type's address into the reference. */ - if (TYPE_POINTER_TO (next) != 0 - && TYPE_SYMTAB_ADDRESS (TYPE_POINTER_TO (next)) != 0 - && TYPE_SYMTAB_ADDRESS (TYPE_POINTER_TO (next)) < this_run_address) - { - int pos = ftell (symfile); - int myaddr = next_address; - fflush (symfile); - fseek (symfile, - (TYPE_SYMTAB_ADDRESS (TYPE_POINTER_TO (next)) - + offsetof (struct type, target_type)), - 0); - fwrite (&myaddr, sizeof (int), 1, symfile); - fflush (symfile); - fseek (symfile, pos, 0); - } - - records[i].address = next_address; - TYPE_SYMTAB_ADDRESS (next) = next_address; - velt->address = next_address; - next_address += sizeof (struct type); - records[i].nfields = 0; - records[i].fields_address = 0; - switch (TREE_CODE (next)) - { - case ARRAY_TYPE: - records[i].nfields - = (TYPE_DOMAIN(next) - ? ! integer_zerop (TYPE_MIN_VALUE (TYPE_DOMAIN (next))) - : 0 ); - break; - - case INTEGER_TYPE: - if (subrange_p (next)) - buffer.nfields = 2; - break; - - case RECORD_TYPE: - case UNION_TYPE: - case ENUMERAL_TYPE: - records[i].nfields = list_length (TYPE_FIELDS (next)); - } - if (records[i].nfields) - records[i].fields_address = next_address; - next_address += records[i].nfields * sizeof (struct field); - } - - /* Now write the data whose space we have assigned. - First fill the data into BUFFER, then write BUFFER. */ - - for (next = types, i = 0; - next; - next = TREE_CHAIN (next), i++) - { - if (records[i].name) - symout_strings_print (records[i].name_prefix, 0, - records[i].name, 0); - - if (TREE_TYPE (next) != 0 && TYPE_OUTPUT_ADDRESS (TREE_TYPE (next)) == 0) - { - /* We are making a forward-reference to our target type. - Make a list of all of these. */ - if (TREE_PERMANENT (next)) - permanent_fwd_refs - = perm_tree_cons (TREE_TYPE (next), 0, permanent_fwd_refs); - else - temporary_fwd_refs - = tree_cons (TREE_TYPE (next), 0, temporary_fwd_refs); - } - - if (TYPE_SIZE (next) == 0) - buffer.length = 0; - else - buffer.length - = (TREE_INT_CST_LOW (TYPE_SIZE (next)) - * TYPE_SIZE_UNIT (next) / BITS_PER_UNIT); - - buffer.name = (char *) records[i].name_address; - buffer.target_type = (struct type *) (TREE_TYPE (next) ? TYPE_OUTPUT_ADDRESS (TREE_TYPE (next)) : 0); - - buffer.pointer_type = 0; - buffer.function_type = 0; - buffer.flags - = ((TREE_CODE (next) == INTEGER_TYPE || TREE_CODE (next) == ENUMERAL_TYPE) - && TREE_UNSIGNED (next)) - ? TYPE_FLAG_UNSIGNED : 0; - buffer.nfields = records[i].nfields; - buffer.fields = (struct field *) records[i].fields_address; - - switch (TREE_CODE (next)) - { - case INTEGER_TYPE: - buffer.code = TYPE_CODE_INT; - if (buffer.nfields) - buffer.code = TYPE_CODE_RANGE; - break; - - case REAL_TYPE: - buffer.code = TYPE_CODE_FLT; - break; - - case VOID_TYPE: - buffer.code = TYPE_CODE_VOID; - break; - - case POINTER_TYPE: - buffer.code = TYPE_CODE_PTR; - break; - - case ARRAY_TYPE: - if (buffer.nfields == 0) - buffer.code = TYPE_CODE_ARRAY; - else - buffer.code = TYPE_CODE_PASCAL_ARRAY; - break; - - case RECORD_TYPE: - buffer.code = TYPE_CODE_STRUCT; - break; - - case UNION_TYPE: - buffer.code = TYPE_CODE_UNION; - break; - - case FUNCTION_TYPE: - buffer.code = TYPE_CODE_FUNC; - break; - - case ENUMERAL_TYPE: - buffer.code = TYPE_CODE_ENUM; - break; - - default: - abort (); - } - - fwrite (&buffer, sizeof buffer, 1, symfile); - - /* Now write the `struct field's that certain kinds of type have. - This allocates space for the names of those fields, - incrementing next_address for the names. */ - - switch (TREE_CODE (next)) - { - case ARRAY_TYPE: - if (buffer.nfields) - symout_array_domain (next); - break; - - case RECORD_TYPE: - case UNION_TYPE: - symout_record_fields (next); - break; - - case ENUMERAL_TYPE: - symout_enum_values (next); - break; - - case INTEGER_TYPE: - if (buffer.nfields) - symout_range_bounds (next); - } - } - - /* Now output the strings referred to by the fields of certain types. - (next_address was already updated for these strings.) */ - - for (next = types, i = 0; - next; - next = TREE_CHAIN (next), i++) - { - switch (TREE_CODE (next)) - { - case RECORD_TYPE: - case UNION_TYPE: - symout_record_field_names (next); - break; - - case ENUMERAL_TYPE: - symout_enum_value_names (next); - break; - } - } -} - -/* Given a list of types TYPES, return a chain of just those - that haven't been written in the symbol table. */ - -static tree -filter_undefined_types (types) - tree types; -{ - tree new = 0; - tree next; - - for (next = types; next; next = TREE_CHAIN (next)) - if (TYPE_SYMTAB_ADDRESS (TREE_PURPOSE (next)) == 0) - { - TREE_CHAIN (TREE_PURPOSE (next)) = new; - new = TREE_PURPOSE (next); - } - - return new; -} - -/* Return nonzero if TYPE's range of possible values - is not the full range allowed by the number of bits it has. - TYPE is assumed to be an INTEGER_TYPE or ENUMERAL_TYPE. */ - -static int -subrange_p (type) - tree type; -{ - int uns = TREE_UNSIGNED (type); - - if (TYPE_PRECISION (type) >= HOST_BITS_PER_INT) - { - if (uns) - return integer_zerop (TYPE_MIN_VALUE (type)) - && TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)) == 0 - && (TREE_INT_CST_HIGH (TYPE_MAX_VALUE (type)) - == (1 << (TYPE_PRECISION (type) - HOST_BITS_PER_INT)) - 1); - return TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)) == 0 - && TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)) == 0 - && (TREE_INT_CST_HIGH (TYPE_MIN_VALUE (type)) - == (-1) << (TYPE_PRECISION (type) - 1 - HOST_BITS_PER_INT)) - && (TREE_INT_CST_HIGH (TYPE_MAX_VALUE (type)) - == (1 << (TYPE_PRECISION (type) - 1 - HOST_BITS_PER_INT)) - 1); - } - - if (uns) - { - int mask; - - if (TYPE_PRECISION (type) == HOST_BITS_PER_INT) - /* Shifting by 32 loses on some machines. */ - mask = -1; - else - mask = (1 << TYPE_PRECISION (type)) - 1; - - return (integer_zerop (TYPE_MIN_VALUE (type)) - && (TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)) == mask)); - } - else - return ((TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)) - == (-1) << (TYPE_PRECISION (type) - 1)) - && (TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)) - == (1 << (TYPE_PRECISION (type) - 1)) - 1)); -} - -/* Functions to output the "fields" of various kinds of types. - These assume that next_address has already been incremented to - cover these fields, and the fields of all the other types being - output in this batch; so next_address can be used to allocate - space to store field names, etc. */ - -static void -symout_array_domain (type) - tree type; -{ - struct field buffer; - - buffer.bitpos = 0; - buffer.bitsize = 0; - buffer.type = (struct type *) TYPE_OUTPUT_ADDRESS (TYPE_DOMAIN (type)); - buffer.name = 0; - fwrite (&buffer, sizeof (struct field), 1, symfile); -} - -static void -symout_range_bounds (type) - tree type; -{ - struct field buffer; - - buffer.bitpos = TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)); - buffer.bitsize = 0; - buffer.type = (struct type *) TYPE_OUTPUT_ADDRESS (type); - buffer.name = 0; - fwrite (&buffer, sizeof (struct field), 1, symfile); - - buffer.bitpos = TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)); - buffer.bitsize = 0; - buffer.type = (struct type *) TYPE_OUTPUT_ADDRESS (type); - buffer.name = 0; - fwrite (&buffer, sizeof (struct field), 1, symfile); -} - -static void -symout_record_fields (type) - tree type; -{ - struct field buffer; - register tree field; - - for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) - { - buffer.bitpos = DECL_OFFSET (field); - buffer.bitsize - = (TREE_PACKED (field) - ? TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field) - : 0); - buffer.type = (struct type *) TYPE_OUTPUT_ADDRESS (TREE_TYPE (field)); - if (DECL_NAME (field)) - { - buffer.name = (char *) next_address; - symout_strings_skip (0, IDENTIFIER_LENGTH (DECL_NAME (field)), 0, 0); - } - else - buffer.name = 0; - fwrite (&buffer, sizeof (struct field), 1, symfile); - } -} - -static void -symout_enum_values (type) - tree type; -{ - struct field buffer; - register tree link, value; - - for (link = TYPE_VALUES (type); link; link = TREE_CHAIN (link)) - { - value = TREE_VALUE (link); - buffer.bitpos = TREE_INT_CST_LOW (value); - buffer.bitsize = 0; - buffer.type = (struct type *) TYPE_OUTPUT_ADDRESS (type); - buffer.name = (char *) next_address; - symout_strings_skip (0, IDENTIFIER_LENGTH (TREE_PURPOSE (link)), 0, 0); - fwrite (&buffer, sizeof buffer, 1, symfile); - } -} - -/* Output field names or value names for the fields of a type. - This is called, for the types that need it, after the fields - have been output for all the types in the batch. - We do not update next_address here, because it has already been - updated for all the names in all the fields in all the types. */ - -static void -symout_record_field_names (type) - tree type; -{ - register tree field; - - for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) - if (DECL_NAME (field)) - symout_strings_print (IDENTIFIER_POINTER (DECL_NAME (field)), - IDENTIFIER_LENGTH (DECL_NAME (field)), - 0, 0); -} - -static void -symout_enum_value_names (type) - tree type; -{ - register tree value; - - for (value = TYPE_VALUES (type); value; value = TREE_CHAIN (value)) - symout_strings_print (IDENTIFIER_POINTER (TREE_PURPOSE (value)), - IDENTIFIER_LENGTH (TREE_PURPOSE (value)), - 0, 0); -} - -/* Output the symbols of a block, given the list of decl nodes. - Store the file addresses at which the symbols are output - into ADDR_BUFFER, a vector which has just the right length. - - If FILTER is 1, do only the private symbols in DECLS. - If FILTER is 2, do only the public ones (but no externals). - If FILTER is 0, do all (except external functions). */ - -static void -symout_block_symbols (decls, addr_buffer, filter) - tree decls; - int *addr_buffer; - int filter; -{ - register tree decl; - struct symbol buffer; - register int i; - - for (decl = decls, i = 0; decl; decl = TREE_CHAIN (decl)) - { - register int name_address = next_address; - - if (filter == (TREE_PUBLIC (decl) ? 1 : 2)) - continue; - - /* Do not mention external functions. - Let their own files mention them. - In the top blocks, don't mention external anything. */ - - if (TREE_EXTERNAL (decl) - && (filter || TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)) - continue; - - if (TREE_TYPE (decl) == error_mark_node) - continue; - - symout_strings (IDENTIFIER_POINTER (DECL_NAME (decl)), - IDENTIFIER_LENGTH (DECL_NAME (decl)), - 0, 0); - addr_buffer[i] = next_address; - buffer.name = (char *) name_address; - buffer.namespace = VAR_NAMESPACE; - buffer.type = (struct type *) TYPE_OUTPUT_ADDRESS (TREE_TYPE (decl)); - switch (TREE_CODE (decl)) - { - case PARM_DECL: - buffer.class = LOC_ARG; - buffer.value.value = DECL_OFFSET (decl) / BITS_PER_UNIT; - break; - - case VAR_DECL: - case RESULT_DECL: - if (TREE_STATIC (decl) || TREE_EXTERNAL (decl)) - { - if (! TREE_PUBLIC (decl) || DECL_INITIAL (decl)) - { - char *str = XSTR (XEXP (DECL_RTL (decl), 0), 0); - fprintf (asmfile, "\t.gdbsym "); - ASM_OUTPUT_LABELREF (asmfile, str); - fprintf (asmfile, ",%d\n", - next_address + (char *)&buffer.value - (char *)&buffer); - buffer.class = LOC_STATIC; - } - else - /* Uninitialized public symbols are output as .comm; - Tell GDB to get address from loader global symbol. - Also come here for symbols declared extern. */ - buffer.class = LOC_EXTERNAL; - } - else - { - if (GET_CODE (DECL_RTL (decl)) == REG) - { - buffer.class = LOC_REGISTER; - buffer.value.value = REGNO (DECL_RTL (decl)); - /* Detect vars that were optimized entirely away. */ - if (buffer.value.value == -1) - buffer.class = LOC_CONST; - } - else if (GET_CODE (DECL_RTL (decl)) == MEM - && (GET_CODE (XEXP (DECL_RTL (decl), 0)) == MEM - || (GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG - && REGNO (XEXP (DECL_RTL (decl), 0)) != FRAME_POINTER_REGNUM))) - /* If the value is indirect by memory or by a register - that isn't the frame pointer - then it means the object is variable-sized and address through - that register or stack slot. - If we have a pointer-type (which we should, for an array), - output the variable as a pointer. - Otherwise ignore it, since it is hard to create the ptr - type now and output it, and -gg is being retired. */ - { - tree ptype = TYPE_POINTER_TO (TREE_TYPE (TREE_TYPE (decl))); - if (ptype == 0 - || TYPE_OUTPUT_ADDRESS (ptype) == 0) - continue; - - buffer.type = (struct type *) TYPE_OUTPUT_ADDRESS (ptype); - - - if (GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG) - { - buffer.class = LOC_REGISTER; - buffer.value.value = REGNO (DECL_RTL (decl)); - /* Detect vars that were optimized entirely away. */ - if (buffer.value.value == -1) - buffer.class = LOC_CONST; - } - else - { - register rtx addr = XEXP (DECL_RTL (decl), 0); - if (GET_CODE (addr) != PLUS && GET_CODE (addr) != MINUS) - abort (); - if (GET_CODE (XEXP (addr, 1)) != CONST_INT) - abort (); - buffer.class = LOC_LOCAL; - buffer.value.value = INTVAL (XEXP (addr, 1)); - if (GET_CODE (addr) == MINUS) - buffer.value.value = - buffer.value.value; - } - } - /* Locals in memory are expected to be addressed as - (PLUS (REG ...) (CONST_INT ...)). - Bomb out if that is not so. */ - else if (GET_CODE (DECL_RTL (decl)) == MEM) - { - register rtx addr = XEXP (DECL_RTL (decl), 0); - if (GET_CODE (addr) != PLUS && GET_CODE (addr) != MINUS) - abort (); - if (GET_CODE (XEXP (addr, 1)) != CONST_INT) - abort (); - buffer.class = LOC_LOCAL; - buffer.value.value = INTVAL (XEXP (addr, 1)); - if (GET_CODE (addr) == MINUS) - buffer.value.value = - buffer.value.value; - } - else - abort (); - } - break; - - case TYPE_DECL: - buffer.class = LOC_TYPEDEF; - buffer.value.value = 0; - break; - - case CONST_DECL: - buffer.class = LOC_CONST; - buffer.value.value = TREE_INT_CST_LOW (DECL_INITIAL (decl)); - break; - - case FUNCTION_DECL: - if (DECL_INITIAL (decl)) - { - buffer.class = LOC_BLOCK; - buffer.value.value = DECL_BLOCK_SYMTAB_ADDRESS (decl); - } - else - buffer.class = LOC_EXTERNAL; - } - - fwrite (&buffer, sizeof buffer, 1, symfile); - next_address += sizeof buffer; - i++; - } -} - -/* Output the tags (struct, union and enum definitions) for a block, - given a list of them (a chain of TREE_LIST nodes) in TAGS. - Store their addresses in the file into ADDR_BUFFER. */ - -static void -symout_block_tags (tags, addr_buffer) - tree tags; - int *addr_buffer; -{ - register tree tag; - struct symbol buffer; - register int i; - - for (tag = tags, i = 0; tag; tag = TREE_CHAIN (tag), i++) - { - buffer.name = (char *) next_address; - - symout_strings (IDENTIFIER_POINTER (TREE_PURPOSE (tag)), - IDENTIFIER_LENGTH (TREE_PURPOSE (tag)), - 0, 0); - addr_buffer[i] = next_address; - buffer.namespace = STRUCT_NAMESPACE; - buffer.type = (struct type *) TYPE_OUTPUT_ADDRESS (TREE_VALUE (tag)); - buffer.class = LOC_TYPEDEF; - buffer.value.value = 0; - - fwrite (&buffer, sizeof buffer, 1, symfile); - next_address += sizeof buffer; - } -} - -/* Output all the data structure for a "block" - (any binding contour). - DECLS is the chain of declarations of variables in this block. - TAGS is the list of struct, union and enum tag definitions of this block. - SUPERBLOCK_ADDRESS is the symtab file address of the containing block's - data structure. */ - -int -symout_block (decls, tags, args, superblock_address) - tree decls; - tree tags; - tree args; - int superblock_address; -{ - register tree decl; - register int i; - register int *addr_buffer; - struct block buffer; - int n_decls, n_tags, n_args, total; - register struct blockvec_elt *velt; - int block_address; - - for (decl = decls, i = 0; decl; decl = TREE_CHAIN (decl)) - if (! TREE_EXTERNAL (decl) - || TREE_CODE (TREE_TYPE (decl)) != FUNCTION_TYPE) - i++; - - n_decls = i; - - for (decl = args, i = 0; decl; decl = TREE_CHAIN (decl), i++); - n_args = i; - - for (decl = tags, i = 0; decl; decl = TREE_CHAIN (decl), i++); - n_tags = i; - - total = n_decls + n_args + n_tags; - - addr_buffer = (int *) alloca (total * sizeof (int)); - - symout_block_symbols (args, addr_buffer, 0); - symout_block_symbols (decls, addr_buffer + n_args, 0); - symout_block_tags (tags, addr_buffer + n_decls + n_args); - - velt = (struct blockvec_elt *) xmalloc (sizeof (struct blockvec_elt)); - velt->next = blockvec; - velt->address = next_address; - blockvec = velt; - - buffer.startaddr = 0; - buffer.endaddr = 0; - buffer.superblock = (struct block *) superblock_address; - buffer.function = 0; - buffer.nsyms = total; - - block_address = next_address; - fwrite (&buffer, sizeof buffer - sizeof buffer.sym, 1, symfile); - next_address += sizeof buffer - sizeof buffer.sym; - - fwrite (addr_buffer, sizeof (int), total, symfile); - next_address += total * sizeof (int); - - fprintf (asmfile, "\t.gdbblock %d,%d\n", total_blocks + 2, block_address); - total_blocks++; - - return block_address; -} - -/* Walk STMT, the body of a function, and output symtab data on - all the blocks that compose it and all symbols inside them. - ARGS is a chain of decls for argument variables of the function. - SUPERBLOCK_ADDRESS is the address of symbol data for the - innermost block containing STMT; it is used for recursive calls, - and is always 0 for the outermost call (since the containing - block for a function is output later than the function). */ - -int -symout_function (stmt, args, superblock_address) - register tree stmt; - tree args; - int superblock_address; -{ - int address = superblock_address; - - while (stmt) - { - switch (TREE_CODE (stmt)) - { - case COMPOUND_STMT: - case LOOP_STMT: - symout_function (STMT_BODY (stmt), 0, address); - break; - - case IF_STMT: - symout_function (STMT_THEN (stmt), 0, address); - symout_function (STMT_ELSE (stmt), 0, address); - break; - - case LET_STMT: - /* Ignore LET_STMTs for blocks never really used to make RTL. */ - if (! TREE_USED (stmt)) - break; - address = - symout_block (STMT_VARS (stmt), STMT_TYPE_TAGS (stmt), args, - superblock_address); - - symout_function (STMT_SUBBLOCKS (stmt), 0, address); - } - stmt = TREE_CHAIN (stmt); - } - return address; -} - -symout_function_end () -{ - /* Output dummy entries for any undefined structure references. */ - symout_types (filter_undefined_types (temporary_fwd_refs)); - temporary_fwd_refs = 0; -} - -/* Output all the data structure for a top two blocks in a compilation. - The top block is for public (global) symbols; - the next one is for private (this file only) symbols. - - DECLS is the chain of declarations of variables in this block. - TAGS is the list of struct, union and enum tag definitions. */ - -void -symout_top_blocks (decls, tags) - tree decls; - tree tags; -{ - register tree decl; - register int i; - register int *addr_buffer; - struct block buffer; - int n_decls, n_tags; - register struct blockvec_elt *velt; - int top_block_addr; - - /* First do the public-symbols block. */ - - for (decl = decls, i = 0; decl; decl = TREE_CHAIN (decl)) - if (TREE_PUBLIC (decl) && ! TREE_EXTERNAL (decl)) - i++; - n_decls = i; - - addr_buffer = (int *) alloca (n_decls * sizeof (int)); - - symout_block_symbols (decls, addr_buffer, 2); - - fprintf (asmfile, ".text 0\n\t.gdbend 0\n"); - fprintf (asmfile, "\t.gdbblock 0,%d\n", next_address); - - total_blocks++; - velt = (struct blockvec_elt *) xmalloc (sizeof (struct blockvec_elt)); - velt->next = blockvec; - velt->address = next_address; - blockvec = velt; - - top_block_addr = next_address; - - buffer.startaddr = 0; - buffer.endaddr = 0; - buffer.superblock = 0; - buffer.function = 0; - buffer.nsyms = n_decls;; - - fwrite (&buffer, sizeof buffer - sizeof buffer.sym, 1, symfile); - next_address += sizeof buffer - sizeof buffer.sym; - - fwrite (addr_buffer, sizeof (int), n_decls, symfile); - next_address += n_decls * sizeof (int); - - /* Next do the private-symbols block. */ - - for (decl = decls, i = 0; decl; decl = TREE_CHAIN (decl)) - if (! TREE_PUBLIC (decl) && ! TREE_EXTERNAL (decl)) - i++; - n_decls = i; - - for (decl = tags, i = 0; decl; decl = TREE_CHAIN (decl), i++); - n_tags = i; - - addr_buffer = (int *) alloca ((n_decls + n_tags) * sizeof (int)); - - symout_block_symbols (decls, addr_buffer, 1); - symout_block_tags (tags, addr_buffer + n_decls); - - fprintf (asmfile, "\t.gdbend 1\n"); - fprintf (asmfile, "\t.gdbblock 1,%d\n", next_address); - - total_blocks++; - velt = (struct blockvec_elt *) xmalloc (sizeof (struct blockvec_elt)); - velt->next = blockvec; - velt->address = next_address; - blockvec = velt; - - buffer.startaddr = 0; - buffer.endaddr = 0; - buffer.superblock = (struct block *) top_block_addr; - buffer.function = 0; - buffer.nsyms = n_decls + n_tags;; - - fwrite (&buffer, sizeof buffer - sizeof buffer.sym, 1, symfile); - next_address += sizeof buffer - sizeof buffer.sym; - - fwrite (addr_buffer, sizeof (int), n_decls + n_tags, symfile); - next_address += (n_decls + n_tags) * sizeof (int); -} - -/* Output the source-line-number information. */ - -/* Output a `struct source' for the source file described by F. - Return the address-in-the-symseg of the `struct source'. */ - -static int -symout_source_file (f) - struct gdbfile *f; -{ - /* Make the `struct source' big enough for as many lines as - this file has. */ - int size = sizeof (struct source) + (f->nlines - 1) * sizeof (struct line); - struct source *buffer - = (struct source *) alloca (size); - int addr; - - /* Use zero for the line data, since assembler will store the real data. */ - bzero (buffer, size); - - /* Output the file's name as a string. The assembler doesn't know this. */ - buffer->name = (char *) next_address; - symout_strings (f->name, 0, 0, 0); - buffer->nlines = f->nlines; - - /* Write the structure. */ - addr = next_address; - fwrite (buffer, 1, size, symfile); - next_address += size; - - /* Tell assembler where to write the real line-number data. */ - fprintf (asmfile, "\t.gdblinetab %d,%d\n", - f->filenum, addr + sizeof (int)); - - return addr; -} - -/* Output the `struct sourcevector' which describes all the - source files and points a `struct source' for each one. */ - -static int -symout_sources () -{ - register struct gdbfile *f; - int nfiles = 0; - struct sourcevector *s; - int i; - int size; - int addr; - - /* Count number of files to determine size of the sourcevector. */ - for (f = gdbfiles; f; f = f->next) - ++nfiles; - - /* Allocate buffer for the sourcevector and record its length. */ - size = sizeof (int) + nfiles * sizeof (struct source *); - s = (struct sourcevector *) alloca (size); - s->length = nfiles; - - /* Output a `struct source' for each file; put address into sourcevector. */ - for (f = gdbfiles, i = 0; f; f = f->next, i++) - s->source[i] = (struct source *) symout_source_file (f); - - /* Output the sourcevector. */ - addr = next_address; - fwrite (s, 1, size, symfile); - next_address += size; - return addr; -} - -/* Call here at the end of compilation, after outputting all the - blocks and symbols, to output the blockvector and typevector - and close the symbol table file. FILETIME is source file's - creation time. */ - -void -symout_finish (filename, filetime) - char *filename; - int filetime; -{ - int *blockvector = (int *) alloca ((total_blocks + 1) * sizeof (int)); - int *typevector; - int now = time (0); - register int i; - struct symbol_root buffer; - char dir[MAXNAMLEN]; - - /* Output dummy entries for any undefined structure references. */ - symout_types (filter_undefined_types (permanent_fwd_refs)); - - typevector = (int *) alloca ((total_types + 1) * sizeof (int)); - - buffer.language = language_c; - buffer.blockvector = (struct blockvector *) next_address; - - /* The two blocks at the beginning of the chain - are the file's private symbols block and public symbols block. - They belong at the front of the blockvector, in that order. */ - blockvector[2] = blockvec->address; - blockvec = blockvec->next; - blockvector[1] = blockvec->address; - blockvec = blockvec->next; - - /* The rest of the blocks are in the chain in reverse order. */ - for (i = total_blocks; i > 2; i--) - { - blockvector[i] = blockvec->address; - blockvec = blockvec->next; - } - blockvector[0] = total_blocks; - - fwrite (blockvector, sizeof (int), total_blocks + 1, symfile); - next_address += sizeof (int) * (total_blocks + 1); - - buffer.typevector = (struct typevector *) next_address; - - for (i = total_types; i > 0; i--) - { - typevector[i] = typevec->address; - typevec = typevec->next; - } - typevector[0] = total_types; - - fwrite (typevector, sizeof (int), total_types + 1, symfile); - next_address += sizeof (int) * (total_types + 1); - - buffer.sourcevector = (struct sourcevector *) symout_sources (); - - buffer.format = 1; - buffer.textrel = 0; /* These four will be set up by linker. */ - buffer.datarel = 0; /* Make them 0 now, which is right for */ - buffer.bssrel = 0; /* looking at the .o file in gdb. */ - buffer.ldsymoff = 0; - - buffer.version = (char *) next_address; - symout_strings (ctime (&filetime), 0, 0, 0); - - buffer.compilation = (char *) next_address; - symout_strings (ctime (&now), 0, 0, 0); - - buffer.filename = (char *) next_address; - symout_strings (filename, 0, 0, 0); - - buffer.filedir = (char *) next_address; -#ifdef USG - strcpy (dir, getcwd (dir, MAXNAMLEN)); -#else -#ifndef VMS - getwd (dir); -#else - abort (); -#endif -#endif - symout_strings (dir, 0, 0, 0); - - fflush (symfile); - - if (ferror (symfile) != 0) - fatal_io_error (symfile_name); - - buffer.length = next_address; - - if (lseek (fileno (symfile), 0, 0) < 0) - pfatal_with_name (symfile_name); - if (write (fileno (symfile), &buffer, sizeof buffer) < 0) - pfatal_with_name (symfile_name); - close (fileno (symfile)); -} diff --git a/gnu/usr.bin/g++/cc1plus/toplev.c b/gnu/usr.bin/g++/cc1plus/toplev.c deleted file mode 100644 index 6e854437daf7..000000000000 --- a/gnu/usr.bin/g++/cc1plus/toplev.c +++ /dev/null @@ -1,2426 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - */ - -#ifndef lint -static char sccsid[] = "@(#)toplev.c 6.3 (Berkeley) 5/8/91"; -#endif /* not lint */ - -/* Top level of GNU C compiler - Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This is the top level of cc1/c++. - It parses command args, opens files, invokes the various passes - in the proper order, and counts the time used by each. - Error messages and low-level interface to malloc also handled here. */ - -#include "config.h" -#include -#include -#include - -#include -#include -#include - -#ifdef NO_UNISTD_H -#define SEEK_SET L_SET -#define SEEK_CUR L_INCR -#define SEEK_END L_XTND -#else -#include -#endif - -#ifdef USG -#include -#undef FLOAT -#include -/* This is for hpux. It is a real screw. They should change hpux. */ -#undef FLOAT -#include -#include /* Correct for hpux at least. Is it good on other USG? */ -#undef FFS /* Some systems define this in param.h. */ -#else -#ifndef VMS -#include -#include -#endif -#endif - -#include "input.h" -#include "tree.h" -#include "c-tree.h" -#include "rtl.h" -#include "flags.h" - -#ifndef _bufsiz -#define _bufsiz(p) ((p)->_bufsiz) -#endif - -/* Change by Bryan Boreham, Kewill, Sun Jul 23 14:41:26 1989. - Added some stuff for unexec-ing a part-done compilation. */ - -int been_here_before = 0; /* Is this an unexec'd program? */ -int just_done_unexec = 0; /* Is this the process that *was* unexec'd? */ -char *dump_source_name; /* Keep argv[0] for dumping. */ - -/* @@ Should there be a filename length limit? */ -char previous_asm_file_name[128]; /* asm_file_name from the first run. */ - -extern int yydebug; - -extern FILE *finput; - -extern int reload_completed; -extern int rtx_equal_function_value_matters; - -extern void init_lex (); -extern void init_decl_processing (); -extern void init_tree (); -extern void init_rtl (); -extern void init_optabs (); -extern void init_stmt (); -extern void init_reg_sets (); -extern void dump_flow_info (); -extern void dump_local_alloc (); - -void rest_of_decl_compilation (); -void error (); -void error_with_file_and_line (); -void fancy_abort (); -void set_target_switch (); -void print_target_switch_defaults (); -static char *decl_name (); - -/* Bit flags that specify the machine subtype we are compiling for. - Bits are tested using macros TARGET_... defined in the tm-...h file - and set by `-m...' switches. */ - -int target_flags; - -/* Name of current original source file (what was input to cpp). - This comes from each #-command in the actual input. */ - -char *input_filename; - -/* Name of top-level original source file (what was input to cpp). - This comes from the #-command at the beginning of the actual input. - If there isn't any there, then this is the cc1 input file name. */ - -char *main_input_filename; - -/* Current line number in real source file. */ - -int lineno; - -/* Stack of currently pending input files. */ - -struct file_stack *input_file_stack; - -/* Incremented on each change to input_file_stack. */ -int input_file_stack_tick; - -/* FUNCTION_DECL for function now being parsed or compiled. */ - -extern tree current_function_decl; - -/* Name to use as base of names for dump output files. */ - -char *dump_base_name; - -/* Flags saying which kinds of debugging dump have been requested. */ - -int rtl_dump = 0; -int rtl_dump_and_exit = 0; -int jump_opt_dump = 0; -int cse_dump = 0; -int loop_dump = 0; -int flow_dump = 0; -int combine_dump = 0; -int local_reg_dump = 0; -int global_reg_dump = 0; -int jump2_opt_dump = 0; -int dbr_sched_dump = 0; - -/* 1 => write gdb debugging output (using symout.c). -g0 - 2 => write dbx debugging output (using dbxout.c). -G0 */ - -enum debugger write_symbols = NO_DEBUG; - -/* Nonzero means can use our own extensions to DBX format. - Relevant only with write_symbols == DBX_DEBUG. */ - -int use_gdb_dbx_extensions; - -/* Nonzero means do optimizations. -opt. */ - -int optimize = 0; - -/* Nonzero means `char' should be signed. */ - -int flag_signed_char; - -/* Nonzero means give an enum type only as many bytes as it needs. */ - -int flag_short_enums; - -/* Nonzero for -fcaller-saves: allocate values in regs that need to - be saved across function calls, if that produces overall better code. - Optional now, so people can test it. */ - -#ifdef DEFAULT_CALLER_SAVES -int flag_caller_saves = 1; -#else -int flag_caller_saves = 0; -#endif - -/* Nonzero for -fpcc-struct-return: return values the same way PCC does. */ - -int flag_pcc_struct_return = 0; - -/* Nonzero for -fforce-mem: load memory value into a register - before arithmetic on it. This makes better cse but slower compilation. */ - -int flag_force_mem = 0; - -/* Nonzero for -fforce-addr: load memory address into a register before - reference to memory. This makes better cse but slower compilation. */ - -int flag_force_addr = 0; - -/* Nonzero for -fdefer-pop: don't pop args after each function call; - instead save them up to pop many calls' args with one insns. */ - -int flag_defer_pop = 1; - -/* Nonzero for -ffloat-store: don't allocate floats and doubles - in extended-precision registers. */ - -int flag_float_store = 0; - -/* Nonzero for -fcombine-regs: - allow instruction combiner to combine an insn - that just copies one reg to another. */ - -int flag_combine_regs = 0; - -/* Nonzero for -fcse-follow-jumps: - have cse follow jumps to do a more extensive job. */ - -int flag_cse_follow_jumps; - -/* Nonzero enables strength-reduction in loop.c. */ - -int flag_strength_reduce = 0; - -/* Nonzero for -fwritable-strings: - store string constants in data segment and don't uniquize them. */ - -int flag_writable_strings = 0; - -/* Nonzero means don't put addresses of constant functions in registers. - Used for compiling the Unix kernel, where strange substitutions are - done on the assembly output. */ - -int flag_no_function_cse = 0; - -/* Nonzero for -fomit-frame-pointer: - don't make a frame pointer in simple functions that don't require one. */ - -int flag_omit_frame_pointer = 0; - -/* Nonzero to inhibit use of define_optimization peephole opts. */ - -int flag_no_peephole = 0; - -/* Nonzero means all references through pointers are volatile. */ - -int flag_volatile; - -/* Nonzero means just do syntax checking; don't output anything. */ - -int flag_syntax_only = 0; - -/* Nonzero means do stupid register allocation. - Currently, this is 1 if `optimize' is 0. */ - -int obey_regdecls = 0; - -/* Don't print functions as they are compiled and don't print - times taken by the various passes. -quiet. */ - -int quiet_flag = 0; - -/* Don't print warning messages. -w. */ - -int inhibit_warnings = 0; - -/* Do print extra warnings (such as for uninitialized variables). -W. */ - -int extra_warnings = 0; - -/* Nonzero to warn about unused local variables. */ - -int warn_unused; - -/* Nonzero means warn about all declarations which shadow others. */ - -int warn_shadow; - -/* Warn if a switch on an enum fails to have a case for every enum value. */ - -int warn_switch; - -/* Warn if a type conversion is done that might have confusing results. */ - -int warn_conversion; - -/* Nonzero means warn about any identifiers that match in the first N - characters. The value N is in `id_clash_len'. */ - -int warn_id_clash; -int id_clash_len; - -/* Nonzero means warn if inline function is too large. */ - -int warn_inline; - -/* Number of error messages and warning messages so far. */ - -int errorcount = 0; -int warningcount = 0; -int sorrycount = 0; - -/* Pointer to function to compute the name to use to print a declaration. */ - -char *(*decl_printable_name) (); - -/* Pointer to function to compute rtl for a language-specific tree code. */ - -struct rtx_def *(*lang_expand_expr) (); - -/* Name of program invoked, sans directories. */ - -char *progname; - -/* Nonzero if generating code to do profiling. */ - -int profile_flag = 0; - -/* Nonzero if generating code to do profiling on a line-by-line basis. */ - -int profile_block_flag; - -/* Nonzero for -pedantic switch: warn about anything - that standard spec forbids. */ - -int pedantic = 0; - -/* Nonzero for -finline-functions: ok to inline functions that look like - good inline candidates. */ - -int flag_inline_functions; - -/* Nonzero for -fkeep-inline-functions: even if we make a function - go inline everywhere, keep its defintion around for debugging - purposes. */ - -int flag_keep_inline_functions; - -/* Nonzero means make the text shared if supported. */ - -int flag_shared_data; - -/* Nonzero means schedule into delayed branch slots if supported. */ - -int flag_delayed_branch; - -/* Copy of arguments to main. */ -int save_argc; -char **save_argv; - -/* Nonzero means schedule instructions within basic blocks. */ - -int flag_schedule_insns = 0; - -/* Name for output file of assembly code, specified with -o. */ - -char *asm_file_name; - -#if 0 -/* Name for output file of GDB symbol segment, specified with -symout. */ - -char *sym_file_name; -#endif /* 0 */ - -#ifdef G_SWITCH -/* Value of the -G nn switch if the machine needs it. */ - -int g_switch_value = 0; -int g_switch_used = 0; -#endif - -/* Table of language-independent -f options. - STRING is the option name. VARIABLE is the address of the variable. - ON_VALUE is the value to store in VARIABLE - if `-fSTRING' is seen as an option. - (If `-fno-STRING' is seen as an option, the opposite value is stored.) */ - -static struct { char *string; int *variable; int on_value;} f_options[] = -{ - {"float-store", &flag_float_store, 1}, - {"volatile", &flag_volatile, 1}, - {"defer-pop", &flag_defer_pop, 1}, - {"omit-frame-pointer", &flag_omit_frame_pointer, 1}, - {"cse-follow-jumps", &flag_cse_follow_jumps, 1}, - {"strength-reduce", &flag_strength_reduce, 1}, - {"writable-strings", &flag_writable_strings, 1}, - {"peephole", &flag_no_peephole, 0}, - {"force-mem", &flag_force_mem, 1}, - {"force-addr", &flag_force_addr, 1}, - {"combine-regs", &flag_combine_regs, 1}, - {"function-cse", &flag_no_function_cse, 0}, - {"inline-functions", &flag_inline_functions, 1}, - {"keep-inline-functions", &flag_keep_inline_functions, 1}, - {"syntax-only", &flag_syntax_only, 1}, - {"shared-data", &flag_shared_data, 1}, - {"caller-saves", &flag_caller_saves, 1}, - {"pcc-struct-return", &flag_pcc_struct_return, 1}, - {"delayed-branch", &flag_delayed_branch, 1}, - {"schedule-insns", &flag_schedule_insns, 1} -}; - -/* Output files for assembler code (real compiler output) - and debugging dumps. */ - -FILE *asm_out_file; -FILE *rtl_dump_file; -FILE *jump_opt_dump_file; -FILE *cse_dump_file; -FILE *loop_dump_file; -FILE *flow_dump_file; -FILE *combine_dump_file; -FILE *local_reg_dump_file; -FILE *global_reg_dump_file; -FILE *jump2_opt_dump_file; -FILE *dbr_sched_dump_file; - -/* Time accumulators, to count the total time spent in various passes. */ - -int parse_time; -int varconst_time; -int integration_time; -int jump_time; -int cse_time; -int loop_time; -int flow_time; -int combine_time; -int local_alloc_time; -int global_alloc_time; -int dbr_sched_time; -int shorten_branch_time; -int final_time; -int symout_time; -int dump_time; - -#ifdef FIELD_XREF - int field_xref = 0; /* cross referencing flag */ -#endif - -/* Return time used so far, in microseconds. */ - -int -gettime () -{ -#ifdef USG - struct tms tms; -#else -#ifndef VMS - struct rusage rusage; -#else /* VMS */ - struct - { - int proc_user_time; - int proc_system_time; - int child_user_time; - int child_system_time; - } vms_times; -#endif -#endif - - if (quiet_flag) - return 0; - -#ifdef USG - times (&tms); - return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ); -#else -#ifndef VMS - getrusage (0, &rusage); - return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec - + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); -#else /* VMS */ - times (&vms_times); - return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; -#endif -#endif -} - -#define TIMEVAR(VAR, BODY) \ -do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0) - -void -print_time (str, total) - char *str; - int total; -{ - fprintf (stderr, - "time in %s: %d.%06d\n", - str, total / 1000000, total % 1000000); -} - -/* Count an error or warning. Return 1 if the message should be printed. */ - -int -count_error (warningp) - int warningp; -{ - if (warningp && inhibit_warnings) - return 0; - - if (warningp) - warningcount++; - else - errorcount++; - - return 1; -} - -/* Print a fatal error message. NAME is the text. - Also include a system error message based on `errno'. */ - -void -pfatal_with_name (name) - char *name; -{ - fprintf (stderr, "%s: ", progname); - perror (name); - exit (35); -} - -void -fatal_io_error (name) - char *name; -{ - fprintf (stderr, "%s: %s: I/O error\n", progname, name); - exit (35); -} - -void -fatal (s, v) - char *s; - int v; -{ - error (s, v); - exit (34); -} - -/* Called from insn-extract to give a better error message when we - don't have an insn to match what we are looking for, rather - than just calling abort(). */ - -void -fatal_insn_not_found (insn) - rtx insn; -{ - error ("The following insn was not recognizable:", 0); - debug_rtx (insn); - abort (); -} - -/* This is the default decl_printable_name function. */ - -static char * -decl_name (decl) - tree decl; -{ - return IDENTIFIER_POINTER (DECL_NAME (decl)); -} - -static int need_error_newline; - -/* Function of last error message; - more generally, function such that if next error message is in it - then we don't have to mention the function name. */ -static tree last_error_function = NULL; - -/* Used to detect when input_file_stack has changed since last described. */ -static int last_error_tick; - -/* Called when the start of a function definition is parsed, - this function prints on stderr the name of the function. */ - -void -announce_function (decl) - tree decl; -{ - if (! quiet_flag) - { - if (rtl_dump_and_exit) - fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); - else - fprintf (stderr, " %s", (*decl_printable_name) (decl)); - fflush (stderr); - need_error_newline = 1; - last_error_function = current_function_decl; - } -} - -/* Prints out, if necessary, the name of the current function - which caused an error. Called from all error and warning functions. */ - -void -report_error_function (file) - char *file; -{ - struct file_stack *p; - - if (need_error_newline) - { - fprintf (stderr, "\n"); - need_error_newline = 0; - } - - if (last_error_function != current_function_decl) - { - if (file) - fprintf (stderr, "%s: ", file); - - if (current_function_decl == NULL) - fprintf (stderr, "At top level:\n"); - else if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE) - fprintf (stderr, "In method %s:\n", - (*decl_printable_name) (current_function_decl)); - else - fprintf (stderr, "In function %s:\n", - (*decl_printable_name) (current_function_decl)); - - last_error_function = current_function_decl; - } - if (input_file_stack && input_file_stack->next != 0 - && input_file_stack_tick != last_error_tick) - { - fprintf (stderr, "In file included"); - for (p = input_file_stack->next; p; p = p->next) - { - fprintf (stderr, " from %s:%d", p->name, p->line); - if (p->next) - fprintf (stderr, ","); - } - fprintf (stderr, ":\n"); - last_error_tick = input_file_stack_tick; - } -} - -/* Report an error at the current line number. - S and V are a string and an arg for `printf'. */ - -void -error (s, v, v2) - char *s; - int v; /* @@also used as pointer */ - int v2; /* @@also used as pointer */ -{ - error_with_file_and_line (input_filename, lineno, s, v, v2); -} - -/* Report an error at line LINE of file FILE. - S and V are a string and an arg for `printf'. */ - -void -error_with_file_and_line (file, line, s, v, v2) - char *file; - int line; - char *s; - int v; - int v2; -{ - count_error (0); - - report_error_function (file); - - if (file) - fprintf (stderr, "%s:%d: ", file, line); - else - fprintf (stderr, "%s: ", progname); - fprintf (stderr, s, v, v2); - fprintf (stderr, "\n"); -} - -/* Report an error at the declaration DECL. - S and V are a string and an arg which uses %s to substitute the declaration name. */ - -void -error_with_decl (decl, s, v) - tree decl; - char *s; - int v; -{ - count_error (0); - - report_error_function (DECL_SOURCE_FILE (decl)); - - if (TREE_CODE (decl) == PARM_DECL) - fprintf (stderr, "%s:%d: ", - DECL_SOURCE_FILE (DECL_CONTEXT (decl)), - DECL_SOURCE_LINE (DECL_CONTEXT (decl))); - else - fprintf (stderr, "%s:%d: ", - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); - - if (DECL_NAME (decl)) - fprintf (stderr, s, (*decl_printable_name) (decl), v); - else - fprintf (stderr, s, "((anonymous))", v); - fprintf (stderr, "\n"); -} - -/* Report an error at the line number of the insn INSN. - S and V are a string and an arg for `printf'. - This is used only when INSN is an `asm' with operands, - and each ASM_OPERANDS records its own source file and line. */ - -void -error_for_asm (insn, s, v, v2) - rtx insn; - char *s; - int v; /* @@also used as pointer */ - int v2; /* @@also used as pointer */ -{ - char *filename; - int line; - rtx body = PATTERN (insn); - rtx asmop; - - /* Find the (or one of the) ASM_OPERANDS in the insn. */ - if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) - asmop = SET_SRC (body); - else if (GET_CODE (body) == ASM_OPERANDS) - asmop = body; - else if (GET_CODE (body) == PARALLEL - && GET_CODE (XVECEXP (body, 0, 0)) == SET) - asmop = SET_SRC (XVECEXP (body, 0, 0)); - else if (GET_CODE (body) == PARALLEL - && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) - asmop = XVECEXP (body, 0, 0); - - filename = ASM_OPERANDS_SOURCE_FILE (asmop); - line = ASM_OPERANDS_SOURCE_LINE (asmop); - - error_with_file_and_line (filename, line, s, v, v2); -} - -/* Report a warning at line LINE. - S and V are a string and an arg for `printf'. */ - -void -warning_with_file_and_line (file, line, s, v, v2) - char *file; - int line; - char *s; - int v; - int v2; -{ - if (count_error (1) == 0) - return; - - report_error_function (file); - - if (file) - fprintf (stderr, "%s:%d: ", file, line); - else - fprintf (stderr, "%s: ", progname); - - fprintf (stderr, "warning: "); - fprintf (stderr, s, v, v2); - fprintf (stderr, "\n"); -} - -/* Report a warning at the current line number. - S and V are a string and an arg for `printf'. */ - -void -warning (s, v, v2) - char *s; - int v; /* @@also used as pointer */ - int v2; -{ - warning_with_file_and_line (input_filename, lineno, s, v, v2); -} - -/* Report a warning at the declaration DECL. - S is string which uses %s to substitute the declaration name. - V is a second parameter that S can refer to. */ - -void -warning_with_decl (decl, s, v) - tree decl; - char *s; - int v; -{ - if (count_error (1) == 0) - return; - - report_error_function (DECL_SOURCE_FILE (decl)); - - if (TREE_CODE (decl) == PARM_DECL) - fprintf (stderr, "%s:%d: ", - DECL_SOURCE_FILE (DECL_CONTEXT (decl)), - DECL_SOURCE_LINE (DECL_CONTEXT (decl))); - else - fprintf (stderr, "%s:%d: ", - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); - - fprintf (stderr, "warning: "); - if (DECL_NAME (decl)) - fprintf (stderr, s, (*decl_printable_name) (decl), v); - else - fprintf (stderr, s, "((anonymous))", v); - fprintf (stderr, "\n"); -} - -/* Apologize for not implementing some feature. - S, V, and V2 are a string and args for `printf'. */ - -void -sorry (s, v, v2) - char *s; - int v, v2; -{ - sorrycount++; - if (input_filename) - fprintf (stderr, "%s:%d: ", input_filename, lineno); - else - fprintf (stderr, "%s: ", progname); - - fprintf (stderr, "sorry, not implemented: "); - fprintf (stderr, s, v, v2); - fprintf (stderr, "\n"); -} - -/* Apologize for not implementing some feature, then quit. - S, V, and V2 are a string and args for `printf'. */ - -void -really_sorry (s, v, v2) - char *s; - int v, v2; -{ - if (input_filename) - fprintf (stderr, "%s:%d: ", input_filename, lineno); - else - fprintf (stderr, "c++: "); - - fprintf (stderr, "sorry, not implemented: "); - fprintf (stderr, s, v, v2); - fatal (" (fatal)\n"); -} - -/* More 'friendly' abort that prints the line and file. - config.h can #define abort fancy_abort if you like that sort of thing. */ - -void -fancy_abort () -{ - fatal ("Internal gcc abort."); -} - -/* When `malloc.c' is compiled with `rcheck' defined, - it calls this function to report clobberage. */ - -void -botch (s) -{ - abort (); -} - -/* Same as `malloc' but report error if no memory available. */ - -int -xmalloc (size) - unsigned size; -{ - register int value = (int) malloc (size); - if (value == 0) - fatal ("Virtual memory exhausted."); - return value; -} - -/* Same as `realloc' but report error if no memory available. */ - -int -xrealloc (ptr, size) - char *ptr; - int size; -{ - int result = realloc (ptr, size); - if (!result) - fatal ("Virtual memory exhausted."); - return result; -} - -/* Return the logarithm of X, base 2, considering X unsigned, - if X is a power of 2. Otherwise, returns -1. */ - -int -exact_log2 (x) - register unsigned int x; -{ - register int log = 0; - /* Test for 0 or a power of 2. */ - if (x == 0 || x != (x & -x)) - return -1; - while ((x >>= 1) != 0) - log++; - return log; -} - -/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X. - If X is 0, return -1. */ - -int -floor_log2 (x) - register unsigned int x; -{ - register int log = -1; - while (x != 0) - log++, - x >>= 1; - return log; -} - -int float_handled; -jmp_buf float_handler; -jmp_buf toplevel; - -/* Specify where to longjmp to when a floating arithmetic error happens. - If HANDLER is 0, it means don't handle the errors any more. */ - -void -set_float_handler (handler) - jmp_buf handler; -{ - float_handled = (handler != 0); - if (handler) - bcopy (handler, float_handler, sizeof (float_handler)); -} - -/* Signals actually come here. */ - -static void -float_signal () -{ - if (float_handled == 0) - abort (); - float_handled = 0; - longjmp (float_handler, 1); -} - -/* Handler for SIGPIPE. */ - -static void -pipe_closed () -{ - fatal ("output pipe has been closed"); -} - -/* Compile an entire file of output from cpp, named NAME. - Write a file of assembly output and various debugging dumps. */ - -static void -compile_file (name) - char *name; -{ - tree globals; - int start_time; - int dump_base_name_length; - - int name_specified = name != 0; - - if (dump_base_name == 0 || been_here_before) - dump_base_name = name ? name : "gccdump"; - dump_base_name_length = strlen (dump_base_name); - - parse_time = 0; - varconst_time = 0; - integration_time = 0; - jump_time = 0; - cse_time = 0; - loop_time = 0; - flow_time = 0; - combine_time = 0; - local_alloc_time = 0; - global_alloc_time = 0; - dbr_sched_time = 0; - shorten_branch_time = 0; - final_time = 0; - symout_time = 0; - dump_time = 0; - - /* Open input file. */ - - if (name == 0 || !strcmp (name, "-")) - { - finput = stdin; - name = "stdin"; - } - else - finput = fopen (name, "r"); - if (finput == 0) - pfatal_with_name (name); - - /* Initialize data in various passes, - checking if this is an unexec'd program - bryan@kewill.uucp. */ - - if (!been_here_before) - { - init_tree (); - init_lex (); - init_rtl (); - init_emit_once (); - init_decl_processing (); - init_optabs (); - init_stmt (); - } - else - { - extern void reinit_lex_for_unexec (); - main_input_filename = 0; - reinit_lex_for_unexec (); - reinit_search_statistics (); - } - -#ifdef FIELD_XREF - if (field_xref) FIELD_xref_begin(input_filename); -#endif - - /* If rtl dump desired, open the output file. */ - if (rtl_dump) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".rtl"); - rtl_dump_file = fopen (dumpname, "w"); - if (rtl_dump_file == 0) - pfatal_with_name (dumpname); - } - - /* If jump_opt dump desired, open the output file. */ - if (jump_opt_dump) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".jump"); - jump_opt_dump_file = fopen (dumpname, "w"); - if (jump_opt_dump_file == 0) - pfatal_with_name (dumpname); - } - - /* If cse dump desired, open the output file. */ - if (cse_dump) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".cse"); - cse_dump_file = fopen (dumpname, "w"); - if (cse_dump_file == 0) - pfatal_with_name (dumpname); - } - - /* If loop dump desired, open the output file. */ - if (loop_dump) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".loop"); - loop_dump_file = fopen (dumpname, "w"); - if (loop_dump_file == 0) - pfatal_with_name (dumpname); - } - - /* If flow dump desired, open the output file. */ - if (flow_dump) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".flow"); - flow_dump_file = fopen (dumpname, "w"); - if (flow_dump_file == 0) - pfatal_with_name (dumpname); - } - - /* If combine dump desired, open the output file. */ - if (combine_dump) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 10); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".combine"); - combine_dump_file = fopen (dumpname, "w"); - if (combine_dump_file == 0) - pfatal_with_name (dumpname); - } - - /* If local_reg dump desired, open the output file. */ - if (local_reg_dump) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".lreg"); - local_reg_dump_file = fopen (dumpname, "w"); - if (local_reg_dump_file == 0) - pfatal_with_name (dumpname); - } - - /* If global_reg dump desired, open the output file. */ - if (global_reg_dump) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".greg"); - global_reg_dump_file = fopen (dumpname, "w"); - if (global_reg_dump_file == 0) - pfatal_with_name (dumpname); - } - - /* If jump2_opt dump desired, open the output file. */ - if (jump2_opt_dump) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 7); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".jump2"); - jump2_opt_dump_file = fopen (dumpname, "w"); - if (jump2_opt_dump_file == 0) - pfatal_with_name (dumpname); - } - - /* If dbr_sched dump desired, open the output file. */ - if (dbr_sched_dump) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 7); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".dbr"); - dbr_sched_dump_file = fopen (dumpname, "w"); - if (dbr_sched_dump_file == 0) - pfatal_with_name (dumpname); - } - - /* Open assembler code output file. */ - - if (! name_specified && asm_file_name == 0) - asm_out_file = stdout; - else - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); - int len = strlen (dump_base_name); - strcpy (dumpname, dump_base_name); - if (len > 2 && ! strcmp (".c", dumpname + len - 2)) - dumpname[len - 2] = 0; - else if (len > 2 && ! strcmp (".i", dumpname + len - 2)) - dumpname[len - 2] = 0; - else if (len > 3 && ! strcmp (".co", dumpname + len - 3)) - dumpname[len - 3] = 0; - strcat (dumpname, ".s"); - if (asm_file_name == 0) - { - asm_file_name = (char *) malloc (strlen (dumpname) + 1); - strcpy (asm_file_name, dumpname); - } - if (!strcmp (asm_file_name, "-")) - asm_out_file = stdout; - else - asm_out_file = fopen (asm_file_name, "w"); - if (asm_out_file == 0) - pfatal_with_name (asm_file_name); - } - - input_filename = name; - - /* the beginning of the file is a new line; check for # */ - /* With luck, we discover the real source file's name from that - and put it in input_filename. */ - ungetc (check_newline (), finput); - - /* If the input doesn't start with a #line, use the input name - as the official input file name. */ - if (main_input_filename == 0) - main_input_filename = name; - - /* Put an entry on the input file stack for the main input file. */ - input_file_stack - = (struct file_stack *) xmalloc (sizeof (struct file_stack)); - input_file_stack->next = 0; - input_file_stack->name = input_filename; - -#ifdef HAVE_UNDUMP - if (!been_here_before) - { -#endif - ASM_FILE_START (asm_out_file); - - /* Output something to inform GDB that this compilation was by GCC. */ -#ifndef ASM_IDENTIFY_GCC - fprintf (asm_out_file, "gcc_compiled.:\n"); -#else - ASM_IDENTIFY_GCC (asm_out_file); -#endif - -#ifdef HAVE_UNDUMP - } - else - { - /* Copy what we output during the first run into this asm file. */ - FILE *prev_file; - int c; - prev_file = fopen (previous_asm_file_name, "r"); - if (prev_file == 0) - pfatal_with_name (previous_asm_file_name); -#ifndef VMS -#ifndef MASSCOMP - if (_bufsiz(asm_out_file) != _bufsiz(prev_file)) -#endif -#endif - { - while ((c = getc (prev_file)) != EOF) - putc (c, asm_out_file); - } -#ifndef VMS -#ifndef MASSCOMP - else - { - /* Copy quickly. */ - int dummy, size; - - fwrite (&dummy, 1, 1, asm_out_file); - asm_out_file->_ptr = asm_out_file->_base; - asm_out_file->_cnt = _bufsiz(asm_out_file); - do - { - size = fread (asm_out_file->_base, 1, _bufsiz(asm_out_file), prev_file); - asm_out_file->_ptr += size; - asm_out_file->_cnt -= size; - fflush (asm_out_file); - } - while (size == _bufsiz(asm_out_file)); - } -#endif -#endif - fclose (prev_file); - } -#endif /* HAVE_UNDUMP */ - -#if 0 /* This mode is discontinued. */ - /* If GDB symbol table desired, open the GDB symbol output file. */ - if (write_symbols == GDB_DEBUG) - { - register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); - int len = strlen (dump_base_name); - strcpy (dumpname, dump_base_name); - if (len > 2 && ! strcmp (".c", dumpname + len - 2)) - dumpname[len - 2] = 0; - else if (len > 2 && ! strcmp (".i", dumpname + len - 2)) - dumpname[len - 2] = 0; - else if (len > 3 && ! strcmp (".co", dumpname + len - 3)) - dumpname[len - 3] = 0; - strcat (dumpname, ".sym"); - if (sym_file_name == 0) - sym_file_name = dumpname; - symout_init (sym_file_name, asm_out_file, main_input_filename); - } -#endif /* 0 */ - - /* If dbx symbol table desired, initialize writing it - and output the predefined types. */ -#ifdef DBX_DEBUGGING_INFO - if (write_symbols == DBX_DEBUG) - { - if (!been_here_before) - dbxout_init (asm_out_file, main_input_filename); - else - { - extern void re_init_dbxout_for_unexec (); - re_init_dbxout_for_unexec (asm_out_file, main_input_filename); - } - } -#endif -#ifdef SDB_DEBUGGING_INFO - if (write_symbols == SDB_DEBUG) - sdbout_init (asm_out_file, main_input_filename); -#endif - - /* Initialize yet another pass. */ - - if (!been_here_before) - init_final (main_input_filename); - - start_time = gettime (); - - /* Call the parser, which parses the entire file - (calling rest_of_compilation for each function). */ - - if (setjmp (toplevel) == 0) - { - if (yyparse () != 0) - { - if (errorcount == 0) - { - fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)"); - errorcount = 1; - } - } - - /* Compilation is now finished except for writing - what's left of the symbol table output. */ - - parse_time += gettime () - start_time; - - parse_time -= integration_time; - parse_time -= varconst_time; - } - else - { - /* Change by Bryan Boreham, Kewill, Sat Aug 5 19:05:44 1989. - We'll be coming back later, so skip the finish. - Modified by Michael Tiemann. */ - - /* Compilation is now finished except for now. */ - - parse_time += gettime () - start_time; - - parse_time -= integration_time; - parse_time -= varconst_time; - - goto after_finish_compilation; - } - - globals = getdecls (); - - /* Really define vars that have had only a tentative definition. - Really output inline functions that must actually be callable - and have not been output so far. */ - - { - tree decl; - for (decl = globals; decl; decl = TREE_CHAIN (decl)) - { - if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) - && ! TREE_ASM_WRITTEN (decl)) - { - /* Don't write out static consts, unless we needed - to take their address for some reason. */ - if (! TREE_READONLY (decl) - || TREE_PUBLIC (decl) - || TREE_ADDRESSABLE (decl) - || TREE_ADDRESSABLE (DECL_NAME (decl))) - rest_of_decl_compilation (decl, 0, 1, 1); - /* Otherwise maybe mention them just for the debugger. */ -#ifdef DBX_DEBUGGING_INFO - else if (DECL_INITIAL (decl) && write_symbols == DBX_DEBUG) - TIMEVAR (varconst_time, dbxout_symbol (decl, 0)); -#endif -#ifdef SDB_DEBUGGING_INFO - else if (DECL_INITIAL (decl) && write_symbols == SDB_DEBUG) - TIMEVAR (varconst_time, sdbout_symbol (decl, 0)); -#endif - } - if (TREE_CODE (decl) == FUNCTION_DECL - && ! TREE_ASM_WRITTEN (decl) - && DECL_INITIAL (decl) != 0 - && (TREE_ADDRESSABLE (decl) || TREE_ADDRESSABLE (DECL_NAME (decl))) - && ! TREE_EXTERNAL (decl)) - output_inline_function (decl); - - /* Warn about any function or variable - declared static but not defined. */ - if ((warn_unused || TREE_USED (decl) || TREE_USED (DECL_NAME (decl))) -/* && TREE_CODE (decl) == FUNCTION_DECL */ - && DECL_INITIAL (decl) == 0 - && TREE_EXTERNAL (decl) - && ! TREE_PUBLIC (decl)) - warning_with_decl (decl, "`%s' declared `static' but never defined"); - /* Warn about static fns or vars defined but not used, - but not about inline functions - since unused inline statics is normal practice. */ - if (warn_unused - && (TREE_CODE (decl) == FUNCTION_DECL - || TREE_CODE (decl) == VAR_DECL) - && ! TREE_EXTERNAL (decl) - && ! TREE_PUBLIC (decl) - && ! TREE_USED (decl) - && ! TREE_INLINE (decl) - /* The TREE_USED bit for file-scope decls - is kept in the identifier, to handle multiple - external decls in different scopes. */ - && ! TREE_USED (DECL_NAME (decl))) - warning_with_decl (decl, "`%s' defined but not used"); - } - } - - /* Do dbx symbols */ -#ifdef DBX_DEBUGGING_INFO - if (write_symbols == DBX_DEBUG) - TIMEVAR (symout_time, - { - dbxout_tags (gettags ()); - dbxout_types (get_permanent_types ()); - }); -#endif - -#ifdef SDB_DEBUGGING_INFO - if (write_symbols == SDB_DEBUG) - TIMEVAR (symout_time, - { - sdbout_tags (gettags ()); - sdbout_types (get_permanent_types ()); - }); -#endif - -#if 0 /* This mode is discontinued */ - /* Do gdb symbols */ - if (write_symbols == GDB_DEBUG) - TIMEVAR (symout_time, - { - struct stat statbuf; - fstat (fileno (finput), &statbuf); - symout_types (get_permanent_types ()); - symout_top_blocks (globals, gettags ()); - symout_finish (name, statbuf.st_ctime); - }); -#endif /* 0 */ - - /* Output some stuff at end of file if nec. */ - - end_final (main_input_filename); - -#ifdef ASM_FILE_END - ASM_FILE_END (asm_out_file); -#endif - - after_finish_compilation: - - /* Close the dump files. */ - - if (rtl_dump) - fclose (rtl_dump_file); - - if (jump_opt_dump) - fclose (jump_opt_dump_file); - - if (cse_dump) - fclose (cse_dump_file); - - if (loop_dump) - fclose (loop_dump_file); - - if (flow_dump) - fclose (flow_dump_file); - - if (combine_dump) - { - dump_combine_total_stats (combine_dump_file); - fclose (combine_dump_file); - } - - if (local_reg_dump) - fclose (local_reg_dump_file); - - if (global_reg_dump) - fclose (global_reg_dump_file); - - if (jump2_opt_dump) - fclose (jump2_opt_dump_file); - - if (dbr_sched_dump) - fclose (dbr_sched_dump_file); - - /* Close non-debugging input and output files. Take special care to note - whether fclose returns an error, since the pages might still be on the - buffer chain while the file is open. */ - - fclose (finput); - if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0) - fatal_io_error (asm_file_name); - - /* Print the times. */ - - if (! quiet_flag) - { - fprintf (stderr,"\n"); - print_time ("parse", parse_time); - print_time ("integration", integration_time); - print_time ("jump", jump_time); - print_time ("cse", cse_time); - print_time ("loop", loop_time); - print_time ("flow", flow_time); - print_time ("combine", combine_time); - print_time ("local-alloc", local_alloc_time); - print_time ("global-alloc", global_alloc_time); - print_time ("shorten-branch", shorten_branch_time); - print_time ("dbranch", dbr_sched_time); - print_time ("final", final_time); - print_time ("varconst", varconst_time); - print_time ("symout", symout_time); - print_time ("dump", dump_time); - } -} - -/* This is called from finish_decl (within yyparse) - for each declaration of a function or variable. - This does nothing for automatic variables. - Otherwise, it sets up the RTL and outputs any assembler code - (label definition, storage allocation and initialization). - - DECL is the declaration. If ASMSPEC is nonzero, it specifies - the assembler symbol name to be used. TOP_LEVEL is nonzero - if this declaration is not within a function. */ - -void -rest_of_decl_compilation (decl, asmspec, top_level, at_end) - tree decl; - char *asmspec; - int top_level; - int at_end; -{ - /* Declarations of variables, and of functions defined elsewhere. */ - - if (TREE_STATIC (decl) || TREE_EXTERNAL (decl)) - TIMEVAR (varconst_time, - { - make_decl_rtl (decl, asmspec, top_level); - /* Don't output anything - when a tentative file-scope definition is seen. - But at end of compilation, do output code for them. */ - if (! (! at_end && top_level - && (DECL_INITIAL (decl) == 0 - || DECL_INITIAL (decl) == error_mark_node))) - assemble_variable (decl, top_level, write_symbols, at_end); - }); - else if (TREE_REGDECL (decl) && asmspec != 0) - { - if (decode_reg_name (asmspec) >= 0) - { - if (TREE_CODE (decl) == PARM_DECL) - error ("parameter cannot have special register declaration"); - else - { - DECL_RTL (decl) = 0; - make_decl_rtl (decl, asmspec, top_level); - } - } - else - error ("invalid register name `%s' for register variable", asmspec); - } -#ifdef DBX_DEBUGGING_INFO - else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL) - TIMEVAR (varconst_time, dbxout_symbol (decl, 0)); -#endif -#ifdef SDB_DEBUGGING_INFO - else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL) - TIMEVAR (varconst_time, sdbout_symbol (decl, 0)); -#endif - - if (top_level) - { -#if 0 /* This mode is discontinued */ - if (write_symbols == GDB_DEBUG) - { - TIMEVAR (symout_time, - { - /* The initizations make types when they contain - string constants. The types are on the temporary - obstack, so output them now before they go away. */ - symout_types (get_temporary_types ()); - }); - } - else -#endif /* 0 */ - /* Clean out the temporary type list, since the types will go away. */ - get_temporary_types (); - } -} - -/* This is called from finish_function (within yyparse) - after each top-level definition is parsed. - It is supposed to compile that function or variable - and output the assembler code for it. - After we return, the tree storage is freed. */ - -void -rest_of_compilation (decl) - tree decl; -{ - register rtx insns; - int start_time = gettime (); - int tem; - - /* If we are reconsidering an inline function - at the end of compilation, skip the stuff for making it inline. */ - - if (DECL_SAVED_INSNS (decl) == 0) - { - int specd = TREE_INLINE (decl); - char *lose; - - if (specd || flag_inline_functions) - { - lose = function_cannot_inline_p (decl); - if (lose) - { - if (warn_inline && specd) - warning_with_decl (decl, lose); - TREE_INLINE (decl) = 0; - } - } - else - lose = "compiler error"; - - insns = get_insns (); - - /* Dump the rtl code if we are dumping rtl. */ - - if (rtl_dump) - TIMEVAR (dump_time, - { - fprintf (rtl_dump_file, "\n;; Function %s\n\n", - IDENTIFIER_POINTER (DECL_NAME (decl))); - if (lose == 0) - fprintf (rtl_dump_file, ";; (integrable)\n\n"); - print_rtl (rtl_dump_file, insns); - fflush (rtl_dump_file); - }); - - /* If function is inline, and we don't yet know whether to - compile it by itself, defer decision till end of compilation. - finish_compilation will call rest_of_compilation again - for those functions that need to be output. */ - - if (TREE_INLINE (decl) - && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl) - && ! flag_keep_inline_functions) - || TREE_EXTERNAL (decl))) - { - save_for_outline (decl); - goto exit_rest_of_compilation; - } - - /* If we have to compile the function now, save its rtl - so that its compilation will not affect what others get. */ - if (TREE_INLINE (decl)) - TIMEVAR (integration_time, save_for_inline (decl)); - } - - TREE_ASM_WRITTEN (decl) = 1; - - if (rtl_dump_and_exit || flag_syntax_only) - { - get_temporary_types (); - goto exit_rest_of_compilation; - } - - insns = get_insns (); - - /* Copy any shared structure that should not be shared. */ - - unshare_all_rtl (insns); - - /* See if we have allocated stack slots that are not directly addressable. - If so, scan all the insns and create explicit address computation - for all references to such slots. */ -/* fixup_stack_slots (); */ - - /* Do jump optimization the first time, if -opt. - Also do it if -W, but in that case it doesn't change the rtl code, - it only computes whether control can drop off the end of the function. */ - - if (optimize || extra_warnings || warn_return_type - /* If function is `volatile', we should warn if it tries to return. */ - || TREE_THIS_VOLATILE (decl)) - TIMEVAR (jump_time, jump_optimize (insns, 0, 0)); - - /* Dump rtl code after jump, if we are doing that. */ - - if (jump_opt_dump) - TIMEVAR (dump_time, - { - fprintf (jump_opt_dump_file, "\n;; Function %s\n\n", - IDENTIFIER_POINTER (DECL_NAME (decl))); - print_rtl (jump_opt_dump_file, insns); - fflush (jump_opt_dump_file); - }); - - /* Perform common subexpression elimination. - Nonzero value from `cse_main' means that jumps were simplified - and some code may now be unreachable, so do - jump optimization again. */ - - if (cse_dump) - TIMEVAR (dump_time, - { - fprintf (cse_dump_file, "\n;; Function %s\n\n", - IDENTIFIER_POINTER (DECL_NAME (decl))); - }); - - if (optimize) - { - TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0)); - - TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (), cse_dump_file)); - - if (tem) - TIMEVAR (jump_time, jump_optimize (insns, 0, 0)); - } - - /* Dump rtl code after cse, if we are doing that. */ - - if (cse_dump) - TIMEVAR (dump_time, - { - print_rtl (cse_dump_file, insns); - fflush (cse_dump_file); - }); - - if (loop_dump) - TIMEVAR (dump_time, - { - fprintf (loop_dump_file, "\n;; Function %s\n\n", - IDENTIFIER_POINTER (DECL_NAME (decl))); - }); - - /* Move constant computations out of loops. */ - - if (optimize) - { - TIMEVAR (loop_time, - { - reg_scan (insns, max_reg_num (), 1); - loop_optimize (insns, loop_dump ? loop_dump_file : 0); - }); - } - - /* Dump rtl code after loop opt, if we are doing that. */ - - if (loop_dump) - TIMEVAR (dump_time, - { - print_rtl (loop_dump_file, insns); - fflush (loop_dump_file); - }); - - /* Now we choose between stupid (pcc-like) register allocation - (if we got the -noreg switch and not -opt) - and smart register allocation. */ - - if (optimize) /* Stupid allocation probably won't work */ - obey_regdecls = 0; /* if optimizations being done. */ - - regclass_init (); - - /* Print function header into flow dump now - because doing the flow analysis makes some of the dump. */ - - if (flow_dump) - TIMEVAR (dump_time, - { - fprintf (flow_dump_file, "\n;; Function %s\n\n", - IDENTIFIER_POINTER (DECL_NAME (decl))); - }); - - if (obey_regdecls) - { - TIMEVAR (flow_time, - { - regclass (insns, max_reg_num ()); - stupid_life_analysis (insns, max_reg_num (), - flow_dump_file); - }); - } - else - { - /* Do control and data flow analysis, - and write some of the results to dump file. */ - - TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (), - flow_dump_file)); - if (extra_warnings) - uninitialized_vars_warning (DECL_INITIAL (decl)); - } - - /* Dump rtl after flow analysis. */ - - if (flow_dump) - TIMEVAR (dump_time, - { - print_rtl (flow_dump_file, insns); - fflush (flow_dump_file); - }); - - /* If -opt, try combining insns through substitution. */ - - if (optimize) - TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ())); - - /* Dump rtl code after insn combination. */ - - if (combine_dump) - TIMEVAR (dump_time, - { - fprintf (combine_dump_file, "\n;; Function %s\n\n", - IDENTIFIER_POINTER (DECL_NAME (decl))); - dump_combine_stats (combine_dump_file); - print_rtl (combine_dump_file, insns); - fflush (combine_dump_file); - }); - - /* Unless we did stupid register allocation, - allocate pseudo-regs that are used only within 1 basic block. */ - - if (!obey_regdecls) - TIMEVAR (local_alloc_time, - { - regclass (insns, max_reg_num ()); - local_alloc (); - }); - - /* Dump rtl code after allocating regs within basic blocks. */ - - if (local_reg_dump) - TIMEVAR (dump_time, - { - fprintf (local_reg_dump_file, "\n;; Function %s\n\n", - IDENTIFIER_POINTER (DECL_NAME (decl))); - dump_flow_info (local_reg_dump_file); - dump_local_alloc (local_reg_dump_file); - print_rtl (local_reg_dump_file, insns); - fflush (local_reg_dump_file); - }); - - if (global_reg_dump) - TIMEVAR (dump_time, - fprintf (global_reg_dump_file, "\n;; Function %s\n\n", - IDENTIFIER_POINTER (DECL_NAME (decl)))); - - /* Unless we did stupid register allocation, - allocate remaining pseudo-regs, then do the reload pass - fixing up any insns that are invalid. */ - - TIMEVAR (global_alloc_time, - { - if (!obey_regdecls) - global_alloc (global_reg_dump ? global_reg_dump_file : 0); - else - reload (insns, 0, - global_reg_dump ? global_reg_dump_file : 0); - }); - - if (global_reg_dump) - TIMEVAR (dump_time, - { - dump_global_regs (global_reg_dump_file); - print_rtl (global_reg_dump_file, insns); - fflush (global_reg_dump_file); - }); - - rtx_equal_function_value_matters = 1; - reload_completed = 1; - - /* One more attempt to remove jumps to .+1 - left by dead-store-elimination. - Also do cross-jumping this time - and delete no-op move insns. */ - - if (optimize) - { - TIMEVAR (jump_time, jump_optimize (insns, 1, 1)); - } - - /* Dump rtl code after jump, if we are doing that. */ - - if (jump2_opt_dump) - TIMEVAR (dump_time, - { - fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n", - IDENTIFIER_POINTER (DECL_NAME (decl))); - print_rtl (jump2_opt_dump_file, insns); - fflush (jump2_opt_dump_file); - }); - - /* If a scheduling pass for delayed branches is to be done, - call the scheduling code. */ - -#ifdef HAVE_DELAYED_BRANCH - if (optimize && flag_delayed_branch) - { - TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file)); - if (dbr_sched_dump) - { - TIMEVAR (dump_time, - { - fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n", - IDENTIFIER_POINTER (DECL_NAME (decl))); - print_rtl (dbr_sched_dump_file, insns); - fflush (dbr_sched_dump_file); - }); - } - } -#endif - -#if 0 - if (optimize) - /* Shorten branches. */ - TIMEVAR (shorten_branch_time, - { - shorten_branches (get_insns ()); - }); -#endif - - /* Now turn the rtl into assembler code. */ - - TIMEVAR (final_time, - { - assemble_function (decl); - final_start_function (insns, asm_out_file, - write_symbols, optimize); - final (insns, asm_out_file, - write_symbols, optimize, 0); - final_end_function (insns, asm_out_file, - write_symbols, optimize); - fflush (asm_out_file); - }); - -#if 0 /* This mode is discontinued */ - /* Write GDB symbols if requested */ - - if (write_symbols == GDB_DEBUG) - { - TIMEVAR (symout_time, - { - symout_types (get_permanent_types ()); - symout_types (get_temporary_types ()); - - DECL_BLOCK_SYMTAB_ADDRESS (decl) - = symout_function (DECL_INITIAL (decl), - DECL_ARGUMENTS (decl), 0); - symout_function_end (); - }); - } - else -#endif /* 0 */ - get_temporary_types (); - - /* Write DBX symbols if requested */ - -#ifdef DBX_DEBUGGING_INFO - if (write_symbols == DBX_DEBUG) - TIMEVAR (symout_time, dbxout_function (decl)); -#endif - - exit_rest_of_compilation: - - rtx_equal_function_value_matters = 0; - reload_completed = 0; - - /* Clear out the real_constant_chain before some of the rtx's - it runs through become garbage. */ - - clear_const_double_mem (); - - /* The parsing time is all the time spent in yyparse - *except* what is spent in this function. */ - - parse_time -= gettime () - start_time; -} - -#ifdef HAVE_UNDUMP -#ifdef sun -#include -/* Hacky routine to read back entire data segment saved earlier. - Michael Tiemann (tiemann@cygnus.com). */ - -void undump_data (path, name) - char *path, *name; -{ - extern char *rindex (); - int file; - long file_size; - extern int my_edata; - char *data; - - if ((file = open (name, O_RDONLY)) == -1) - { - char buf[256], *p; - strcpy (buf, path); - p = rindex (buf, '/'); - if (p) - { - strcpy (p+1, name); - file = open (buf, O_RDONLY); - } - } - if (file == -1) - { - perror(name); - exit (-1); - } - - file_size = lseek (file, 0L, SEEK_END); - brk ((char*)(&my_edata) + file_size); - - data = (char *)((int)&my_edata&~(getpagesize()-1)); - if ((int)mmap (data, file_size, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_FIXED, file, 0) < 0) - { - perror (name); - exit (-1); - } -} -#else -/* Hacky routine to read back entire data segment saved earlier. - Bryan Boreham (bryan@kewill.uucp) */ - -void undump_data (path, name) - char *name; -{ - int file; - long file_size; - extern int my_edata; - char buf[256] = "/usr/local/lib/"; - - strcat (buf, name); - - if ((file = open(name, O_RDONLY)) == -1) - if ((file = open(buf, O_RDONLY)) == -1) - { - perror(name); - return; - } - file_size = lseek(file, 0L, SEEK_END); - lseek(file, 0L, SEEK_SET); - brk((char*)((int)&my_edata&~(getpagesize()-1)) + file_size); - if (read (file, &my_edata, file_size) != file_size) - perror(name); -} -#endif -#endif /* HAVE_UNDUMP */ - -/* Entry point of c++. Decode command args, then call compile_file. - Exit code is 35 if can't open files, 34 if fatal error, - 33 if had nonfatal errors, else success. */ - -int -main (argc, argv, envp) - int argc; - char **argv; - char **envp; -{ - register int i; - char *filename = 0; - int print_mem_flag = 0; - char *p; - - /* save in case md file wants to emit args as a comment. */ - save_argc = argc; - save_argv = argv; - - p = argv[0] + strlen (argv[0]); - while (p != argv[0] && p[-1] != '/') --p; - progname = p; - - /* Change by Bryan Boreham, Kewill, Sun Aug 6 13:42:47 1989. - Stuff for unexec'ing */ - dump_source_name = argv[0]; - asm_file_name = (char*) 0; - -#ifdef RLIMIT_STACK - /* Get rid of any avoidable limit on stack size. */ - { - struct rlimit rlim; - - /* Set the stack limit huge so that alloca does not fail. */ - getrlimit (RLIMIT_STACK, &rlim); - rlim.rlim_cur = rlim.rlim_max; - setrlimit (RLIMIT_STACK, &rlim); - } -#endif /* RLIMIT_STACK */ - - signal (SIGFPE, float_signal); - - signal (SIGPIPE, pipe_closed); - - decl_printable_name = decl_name; - lang_expand_expr = fancy_abort; - - /* Initialize whether `char' is signed. */ - flag_signed_char = DEFAULT_SIGNED_CHAR; -#ifdef DEFAULT_SHORT_ENUMS - /* Initialize how much space enums occupy, by default. */ - flag_short_enums = DEFAULT_SHORT_ENUMS; -#endif - - /* This is zeroed by -O. */ - obey_regdecls = 1; - - /* Initialize register usage now so switches may override. */ - init_reg_sets (); - - target_flags = 0; - set_target_switch (""); - - for (i = 1; i < argc; i++) - { - if (argv[i][0] == '-' && argv[i][1] != 0) - { - register char *str = argv[i] + 1; - if (str[0] == 'Y') - str++; - - if (str[0] == 'm') - set_target_switch (&str[1]); - else if (!strcmp (str, "dumpbase")) - { - dump_base_name = argv[++i]; - } - else if (str[0] == 'd') - { - register char *p = &str[1]; - while (*p) - switch (*p++) - { - case 'c': - combine_dump = 1; - break; - case 'd': - dbr_sched_dump = 1; - break; - case 'f': - flow_dump = 1; - break; - case 'g': - global_reg_dump = 1; - break; - case 'j': - jump_opt_dump = 1; - break; - case 'J': - jump2_opt_dump = 1; - break; - case 'l': - local_reg_dump = 1; - break; - case 'L': - loop_dump = 1; - break; - case 'm': - print_mem_flag = 1; - break; - case 'r': - rtl_dump = 1; - break; - case 's': - cse_dump = 1; - break; - case 'y': - yydebug = 1; - break; - case 'x': - rtl_dump_and_exit = 1; - break; - } - } - else if (str[0] == 'f') - { - int j; - register char *p = &str[1]; - int found = 0; - - /* Some kind of -f option. - P's value is the option sans `-f'. - Search for it in the table of options. */ - - for (j = 0; - !found && j < sizeof (f_options) / sizeof (f_options[0]); - j++) - { - if (!strcmp (p, f_options[j].string)) - { - *f_options[j].variable = f_options[j].on_value; - /* A goto here would be cleaner, - but breaks the vax pcc. */ - found = 1; - } - if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' - && ! strcmp (p+3, f_options[j].string)) - { - *f_options[j].variable = ! f_options[j].on_value; - found = 1; - } - } - - if (found) - ; -#ifdef HAVE_UNDUMP - else if (!strncmp (p, "undump-", 7)) - undump_data (argv[0], &p[7]); -#endif - else if (!strncmp (p, "fixed-", 6)) - fix_register (&p[6], 1, 1); - else if (!strncmp (p, "call-used-", 10)) - fix_register (&p[10], 0, 1); - else if (!strncmp (p, "call-saved-", 11)) - fix_register (&p[11], 0, 0); - else if (! lang_decode_option (argv[i])) - error ("Invalid option `%s'", argv[i]); - } - else if (!strcmp (str, "noreg")) - ; - else if (!strcmp (str, "opt")) - optimize = 1, obey_regdecls = 0; - else if (!strcmp (str, "O")) - optimize = 1, obey_regdecls = 0; - else if (!strcmp (str, "pedantic")) - pedantic = 1; - else if (lang_decode_option (argv[i])) - ; - else if (!strcmp (str, "quiet")) - quiet_flag = 1; - else if (!strcmp (str, "version")) - { - extern char *version_string, *language_string; - fprintf (stderr, "%s version %s", language_string, version_string); -#ifdef TARGET_VERSION - TARGET_VERSION; -#endif -#ifdef __GNUC__ -#ifndef __VERSION__ -#define __VERSION__ "[unknown]" -#endif - fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__); -#else - fprintf (stderr, " compiled by CC.\n"); -#endif - print_target_switch_defaults (); - } - else if (!strcmp (str, "w")) - inhibit_warnings = 1; - else if (!strcmp (str, "W")) - extra_warnings = 1; - else if (!strcmp (str, "Wunused")) - warn_unused = 1; - else if (!strcmp (str, "Wshadow")) - warn_shadow = 1; - else if (!strcmp (str, "Wswitch")) - warn_switch = 1; - else if (!strcmp (str, "Wconversion")) - warn_conversion = 1; - else if (!strncmp (str, "Wid-clash-", 10)) - { - char *endp = str + 10; - - while (*endp) - { - if (*endp >= '0' && *endp <= '9') - endp++; - else - error ("Invalid option `%s'", argv[i]); - } - warn_id_clash = 1; - id_clash_len = atoi (str + 10); - } - else if (!strcmp (str, "Winline")) - warn_inline = 1; - else if (!strcmp (str, "p")) - profile_flag = 1; - else if (!strcmp (str, "a")) - { -#if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) - warning ("`-a' option (basic block profile) not supported"); -#else - profile_block_flag = 1; -#endif - } -#ifdef 0 - else if (!strcmp (str, "gg")) - write_symbols = GDB_DEBUG; -#endif -#ifdef DBX_DEBUGGING_INFO - else if (!strcmp (str, "g0")) - write_symbols = DBX_DEBUG; - else if (!strcmp (str, "G0")) - write_symbols = DBX_DEBUG; -#ifdef SDB_DEBUGGING_INFO - else if (!strcmp (str, "gsdb")) - write_symbols = SDB_DEBUG; -#endif - else if (!strcmp (str, "g")) - { - write_symbols = DBX_DEBUG; - use_gdb_dbx_extensions = 1; - } - else if (!strcmp (str, "G")) - { - write_symbols = DBX_DEBUG; - use_gdb_dbx_extensions = 1; - } -#endif /* DBX_DEBUGGING_INFO */ -#ifdef SDB_DEBUGGING_INFO - else if (!strcmp (str, "g")) - write_symbols = SDB_DEBUG; - else if (!strcmp (str, "G")) - write_symbols = SDB_DEBUG; - else if (!strcmp (str, "g0")) - write_symbols = SDB_DEBUG; - else if (!strcmp (str, "G0")) - write_symbols = SDB_DEBUG; - else if (!strcmp (str, "gsdb")) - write_symbols = SDB_DEBUG; -#endif /* SDB_DEBUGGING_INFO */ -#if defined(ASM_OUTPUT_SOURCE_FILENAME) && defined(ASM_OUTPUT_SOURCE_LINE) - else if (!strcmp (str, "gline")) - write_symbols = LINENO_DEBUG; -#endif -#if 0 - else if (!strcmp (str, "symout")) - { - if (write_symbols == NO_DEBUG) - write_symbols = GDB_DEBUG; - sym_file_name = argv[++i]; - } -#endif /* 0 */ - else if (!strcmp (str, "o")) - { - asm_file_name = argv[++i]; - } -#ifdef FIELD_XREF - else if (!strcmp(str,"xref")) - field_xref = 1; -#endif - else - error ("Invalid option `%s'", argv[i]); - } - else if (argv[i][0] == '+') - { - if (lang_decode_option (argv[i])) - ; - else - error ("Invalid option `%s'", argv[i]); - } - else - filename = argv[i]; - } -#ifdef OVERRIDE_OPTIONS - /* Some machines may reject certain combinations of options. */ - OVERRIDE_OPTIONS; -#endif - - /* Now that register usage is specified, convert it to HARD_REG_SETs. */ - init_reg_sets_1 (); - - compile_file (filename); - -#ifndef USG -#ifndef VMS - if (print_mem_flag) - { - extern char **environ; - char *lim = (char *) sbrk (0); - - fprintf (stderr, "Data size %d.\n", - (int) lim - (int) &environ); - fflush (stderr); - - system ("ps v"); - } -#endif /* not VMS */ -#endif /* not USG */ - -#ifdef FIELD_XREF - FIELD_xref_end(errorcount+sorrycount); -#endif - - if (errorcount) - exit (FATAL_EXIT_CODE); - if (sorrycount) - exit (FATAL_EXIT_CODE); - exit (SUCCESS_EXIT_CODE); - return 34; -} - -/* Decode -m switches. */ - -/* Here is a table, controlled by the tm-...h file, listing each -m switch - and which bits in `target_switches' it should set or clear. - If VALUE is positive, it is bits to set. - If VALUE is negative, -VALUE is bits to clear. - (The sign bit is not used so there is no confusion.) */ - -struct {char *name; int value;} target_switches [] - = TARGET_SWITCHES; - -/* Decode the switch -mNAME. */ - -void -set_target_switch (name) - char *name; -{ - register int j; - int valid = 0; - - for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) - if (!strcmp (target_switches[j].name, name)) - { - if (target_switches[j].value < 0) - target_flags &= ~-target_switches[j].value; - else - target_flags |= target_switches[j].value; - valid = 1; - } - - if (!valid) - error ("Invalid option `%s'", name); -} - -/* Print default target switches for -version. */ - -void -print_target_switch_defaults () -{ - register int j; - register int mask = TARGET_DEFAULT; - - fprintf (stderr, "default target switches:"); - for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) - if (target_switches[j].name[0] != '\0' - && target_switches[j].value > 0 - && (target_switches[j].value & mask) == target_switches[j].value) - fprintf (stderr, " -m%s", target_switches[j].name); - - fprintf (stderr, "\n"); -} diff --git a/gnu/usr.bin/g++/cc1plus/tree.c b/gnu/usr.bin/g++/cc1plus/tree.c deleted file mode 100644 index fccdf2b866e8..000000000000 --- a/gnu/usr.bin/g++/cc1plus/tree.c +++ /dev/null @@ -1,2717 +0,0 @@ -/* Language-independent node constructors for parse phase of GNU compiler. - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file contains the low level primitives for operating on tree nodes, - including allocation, list operations, interning of identifiers, - construction of data type nodes and statement nodes, - and construction of type conversion nodes. It also contains - tables index by tree code that describe how to take apart - nodes of that code. - - It is intended to be language-independent, but occasionally - calls language-dependent routines defined (for C) in typecheck.c. - - The low-level allocation routines oballoc and permalloc - are used also for allocating many other kinds of objects - by all passes of the compiler. */ - -#include "config.h" -#include -#include "tree.h" -#include "obstack.h" -#include "gvarargs.h" -#include "flags.h" - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -extern int xmalloc (); -extern void free (); - -/* Tree nodes of permanent duration are allocated in this obstack. - They are the identifier nodes, and everything outside of - the bodies and parameters of function definitions. */ - -struct obstack permanent_obstack; - -/* The initial RTL, and all ..._TYPE nodes, in a function - are allocated in this obstack. Usually they are freed at the - end of the function, but if the function is inline they are saved. */ - -struct obstack maybepermanent_obstack; - -/* The contents of the current function definition are allocated - in this obstack, and all are freed at the end of the function. */ - -struct obstack temporary_obstack; - -/* The tree nodes of an expression are allocated - in this obstack, and all are freed at the end of the expression. */ - -struct obstack momentary_obstack; - -/* The tree nodes of a declarator are allocated - in this obstack, and all are freed when the declarator - has been parsed. */ - -static struct obstack temp_decl_obstack; - -/* This points at either permanent_obstack or maybepermanent_obstack. */ - -struct obstack *saveable_obstack; - -/* This is same as saveable_obstack during parse and expansion phase; - it points to temporary_obstack during optimization. - This is the obstack to be used for creating rtl objects. */ - -struct obstack *rtl_obstack; - -/* This points at either permanent_obstack or temporary_obstack. */ - -struct obstack *current_obstack; - -/* This points at either permanent_obstack or temporary_obstack - or momentary_obstack. */ - -struct obstack *expression_obstack; - -/* Addresses of first objects in some obstacks. - This is for freeing their entire contents. */ -char *maybepermanent_firstobj; -char *temporary_firstobj; -char *momentary_firstobj; -char *temp_decl_firstobj; - -/* Nonzero means all ..._TYPE nodes should be allocated permanently. */ - -int all_types_permanent; - -/* Stack of places to restore the momentary obstack back to. */ - -struct momentary_level -{ - /* Pointer back to previous such level. */ - struct momentary_level *prev; - /* First object allocated within this level. */ - char *base; - /* Value of expression_obstack saved at entry to this level. */ - struct obstack *obstack; -}; - -struct momentary_level *momentary_stack; - -/* Table indexed by tree code giving a string containing a character - classifying the tree code. Possibilities are - t, d, s, c, r and e. See tree.def for details. */ - -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, - -char *standard_tree_code_type[] = { -#include "tree.def" -}; -#undef DEFTREECODE - -/* Table indexed by tree code giving number of expression - operands beyond the fixed part of the node structure. - Not used for types or decls. */ - -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, - -int standard_tree_code_length[] = { -#include "tree.def" -}; -#undef DEFTREECODE - -/* Names of tree components. - Used for printing out the tree and error messages. */ -#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME, - -char *standard_tree_code_name[] = { -#include "tree.def" -}; -#undef DEFTREECODE - -/* Table indexed by tree code giving a string containing a character - classifying the tree code. Possibilities are - t, d, s, c, r and e. See tree.def for details. */ - -char **tree_code_type; - -/* Table indexed by tree code giving number of expression - operands beyond the fixed part of the node structure. - Not used for types or decls. */ - -int *tree_code_length; - -/* Table indexed by tree code giving name of tree code, as a string. */ - -char **tree_code_name; - -/* Counter for assigning unique ids to all tree nodes. */ - -int tree_node_counter = 0; - -/* Statistics-gathering stuff. */ -typedef enum -{ - d_kind, t_kind, s_kind, r_kind, e_kind, c_kind, - id_kind, op_id_kind, perm_list_kind, temp_list_kind, - x_kind, lang_decl, lang_type, all_kinds -} tree_node_kind; -int tree_node_kinds[(int)all_kinds]; -int tree_node_sizes[(int)all_kinds]; -int id_string_size = 0; -char *tree_node_kind_names[] = { "decls", "types", "stmts", "refs", "exprs", "constants", - "identifiers", "op_identifiers", "perm_tree_lists", "temp_tree_lists", - "random kinds", "lang_decl kinds", "lang_type kinds" }; - -/* Hash table for uniquizing IDENTIFIER_NODEs by name. */ - -#define MAX_HASH_TABLE 1009 -static tree hash_table[MAX_HASH_TABLE]; /* id hash buckets */ - -/* 0 while creating built-in identifiers. */ -static int do_identifier_warnings; - -/* Init data for node creation, at the beginning of compilation. */ - -void -init_tree () -{ - obstack_init (&permanent_obstack); - - obstack_init (&temporary_obstack); - temporary_firstobj = (char *) obstack_alloc (&temporary_obstack, 0); - obstack_init (&momentary_obstack); - momentary_firstobj = (char *) obstack_alloc (&momentary_obstack, 0); - obstack_init (&maybepermanent_obstack); - maybepermanent_firstobj - = (char *) obstack_alloc (&maybepermanent_obstack, 0); - obstack_init (&temp_decl_obstack); - temp_decl_firstobj = (char *) obstack_alloc (&temp_decl_obstack, 0); - - current_obstack = &permanent_obstack; - expression_obstack = &permanent_obstack; - rtl_obstack = saveable_obstack = &permanent_obstack; - tree_node_counter = 1; - /* bzero (hash_table, sizeof hash_table); */ - - tree_code_type = (char **) xmalloc (sizeof (standard_tree_code_type)); - tree_code_length = (int *) xmalloc (sizeof (standard_tree_code_length)); - tree_code_name = (char **) xmalloc (sizeof (standard_tree_code_name)); - bcopy (standard_tree_code_type, tree_code_type, - sizeof (standard_tree_code_type)); - bcopy (standard_tree_code_length, tree_code_length, - sizeof (standard_tree_code_length)); - bcopy (standard_tree_code_name, tree_code_name, - sizeof (standard_tree_code_name)); -} -#if 0 -/* Save all variables describing the current status into the structure *P. - This is used before starting a nested function. */ - -void -save_tree_status (p) - struct function *p; -{ - p->all_types_permanent = all_types_permanent; - p->momentary_stack = momentary_stack; - p->maybepermanent_firstobj = maybepermanent_firstobj; - p->temporary_firstobj = temporary_firstobj; - p->momentary_firstobj = momentary_firstobj; - p->current_obstack = current_obstack; - p->expression_obstack = expression_obstack; - p->saveable_obstack = saveable_obstack; - p->rtl_obstack = rtl_obstack; - - current_obstack = &permanent_obstack; - expression_obstack = &permanent_obstack; - rtl_obstack = saveable_obstack = &permanent_obstack; - - maybepermanent_firstobj = (char *) obstack_finish (&maybepermanent_obstack); - temporary_firstobj = (char *) obstack_finish (&temporary_obstack); - momentary_firstobj = (char *) obstack_finish (&momentary_obstack); -} - -/* Restore all variables describing the current status from the structure *P. - This is used after a nested function. */ - -void -restore_tree_status (p) - struct function *p; -{ - all_types_permanent = p->all_types_permanent; - momentary_stack = p->momentary_stack; - - obstack_free (&maybepermanent_obstack, maybepermanent_firstobj); - obstack_free (&temporary_obstack, temporary_firstobj); - obstack_free (&momentary_obstack, momentary_firstobj); - - maybepermanent_firstobj = p->maybepermanent_firstobj; - temporary_firstobj = p->temporary_firstobj; - momentary_firstobj = p->momentary_firstobj; - current_obstack = p->current_obstack; - expression_obstack = p->expression_obstack; - saveable_obstack = p->saveable_obstack; - rtl_obstack = p->rtl_obstack; -} -#endif - -/* Start allocating on the temporary (per function) obstack. - This is done in start_function before parsing the function body, - and before each initialization at top level, and to go back - to temporary allocation after doing end_temporary_allocation. */ - -void -temporary_allocation () -{ - current_obstack = &temporary_obstack; - expression_obstack = &temporary_obstack; - rtl_obstack = saveable_obstack = &maybepermanent_obstack; - momentary_stack = 0; -} - -/* Start allocating on the permanent obstack but don't - free the temporary data. After calling this, call - `permanent_allocation' to fully resume permanent allocation status. */ - -void -end_temporary_allocation () -{ - current_obstack = &permanent_obstack; - expression_obstack = &permanent_obstack; - rtl_obstack = saveable_obstack = &permanent_obstack; -} - -/* Resume allocating on the temporary obstack, undoing - effects of `end_temporary_allocation'. */ - -void -resume_temporary_allocation () -{ - current_obstack = &temporary_obstack; - expression_obstack = &temporary_obstack; - rtl_obstack = saveable_obstack = &maybepermanent_obstack; -} - -/* Nonzero if temporary allocation is currently in effect. - Zero if currently doing permanent allocation. */ - -int -allocation_temporary_p () -{ - return current_obstack == &temporary_obstack; -} - -/* Go back to allocating on the permanent obstack - and free everything in the temporary obstack. - This is done in finish_function after fully compiling a function. */ - -void -permanent_allocation () -{ - /* Free up previous temporary obstack data */ - obstack_free (&temporary_obstack, temporary_firstobj); - obstack_free (&momentary_obstack, momentary_firstobj); - obstack_free (&maybepermanent_obstack, maybepermanent_firstobj); - obstack_free (&temp_decl_obstack, temp_decl_firstobj); - - current_obstack = &permanent_obstack; - expression_obstack = &permanent_obstack; - rtl_obstack = saveable_obstack = &permanent_obstack; -} - -/* Save permanently everything on the maybepermanent_obstack. */ - -void -preserve_data () -{ - maybepermanent_firstobj - = (char *) obstack_alloc (&maybepermanent_obstack, 0); -} - -void -preserve_initializer () -{ - temporary_firstobj - = (char *) obstack_alloc (&temporary_obstack, 0); - momentary_firstobj - = (char *) obstack_alloc (&momentary_obstack, 0); - maybepermanent_firstobj - = (char *) obstack_alloc (&maybepermanent_obstack, 0); -} - -/* Allocate SIZE bytes in the current obstack - and return a pointer to them. - In practice the current obstack is always the temporary one. */ - -char * -oballoc (size) - int size; -{ - return (char *) obstack_alloc (current_obstack, size); -} - -/* Free the object PTR in the current obstack - as well as everything allocated since PTR. - In practice the current obstack is always the temporary one. */ - -void -obfree (ptr) - char *ptr; -{ - obstack_free (current_obstack, ptr); -} - -/* Allocate SIZE bytes in the permanent obstack - and return a pointer to them. */ - -char * -permalloc (size) - long size; -{ - return (char *) obstack_alloc (&permanent_obstack, size); -} - -/* Allocate SIZE bytes in the saveable obstack - and return a pointer to them. */ - -char * -savealloc (size) - int size; -{ - return (char *) obstack_alloc (saveable_obstack, size); -} - -/* Start a level of momentary allocation. - In C, each compound statement has its own level - and that level is freed at the end of each statement. - All expression nodes are allocated in the momentary allocation level. */ - -void -push_momentary () -{ - struct momentary_level *tem - = (struct momentary_level *) obstack_alloc (&momentary_obstack, - sizeof (struct momentary_level)); - tem->prev = momentary_stack; - tem->base = (char *) obstack_base (&momentary_obstack); - tem->obstack = expression_obstack; - momentary_stack = tem; - expression_obstack = &momentary_obstack; -} - -/* Free all the storage in the current momentary-allocation level. - In C, this happens at the end of each statement. */ - -void -clear_momentary () -{ - obstack_free (&momentary_obstack, momentary_stack->base); -} - -/* Discard a level of momentary allocation. - In C, this happens at the end of each compound statement. - Restore the status of expression node allocation - that was in effect before this level was created. */ - -void -pop_momentary () -{ - struct momentary_level *tem = momentary_stack; - momentary_stack = tem->prev; - obstack_free (&momentary_obstack, tem); - expression_obstack = tem->obstack; -} - -/* Call when starting to parse a declaration: - make expressions in the declaration last the length of the function. - Returns an argument that should be passed to resume_momentary later. */ - -int -suspend_momentary () -{ - register int tem = expression_obstack == &momentary_obstack; - expression_obstack = saveable_obstack; - return tem; -} - -/* Call when finished parsing a declaration: - restore the treatment of node-allocation that was - in effect before the suspension. - YES should be the value previously returned by suspend_momentary. */ - -void -resume_momentary (yes) - int yes; -{ - if (yes) - expression_obstack = &momentary_obstack; -} - -/* Return a newly allocated node of code CODE. - Initialize the node's unique id and its TREE_PERMANENT flag. - For decl and type nodes, some other fields are initialized. - The rest of the node is initialized to zero. - - Achoo! I got a code in the node. */ - -tree -make_node (code) - enum tree_code code; -{ - register tree t; - register int type = *tree_code_type[(int) code]; - register int length; - register struct obstack *obstack = current_obstack; - register int i; - register tree_node_kind kind; - - switch (type) - { - case 'd': /* A decl node */ - length = sizeof (struct tree_decl) - + tree_code_length[(int) code] * sizeof (char *); - kind = d_kind; - /* All decls in an inline function need to be saved. */ - if (obstack != &permanent_obstack) - obstack = saveable_obstack; - /* PARM_DECLs always go on the saveable_obstack, not permanent - even though we may make them before the function turns - on temporary allocation. */ - else if (code == PARM_DECL) - obstack = &maybepermanent_obstack; - break; - - case 't': /* a type node */ - length = sizeof (struct tree_type); - kind = t_kind; - /* All data types are put where we can preserve them if nec. */ - if (obstack != &permanent_obstack) - obstack = all_types_permanent ? &permanent_obstack : saveable_obstack; - break; - - case 's': /* a stmt node */ - length = sizeof (struct tree_common) - + 2 * sizeof (int) - + tree_code_length[(int) code] * sizeof (char *); - kind = s_kind; - /* All stmts are put where we can preserve them if nec. */ - if (obstack != &permanent_obstack) - obstack = saveable_obstack; - break; - - case 'r': /* a reference */ - obstack = expression_obstack; - length = sizeof (struct tree_exp) - + (tree_code_length[(int) code] - 1) * sizeof (char *); - kind = r_kind; - break; - - case 'e': /* an expression */ - obstack = expression_obstack; - length = sizeof (struct tree_exp) - + (tree_code_length[(int) code] - 1) * sizeof (char *); - kind = e_kind; - break; - - case 'c': /* a constant */ - obstack = expression_obstack; - /* We can't use tree_code_length for this, since the number of words - is machine-dependent due to varying alignment of `double'. */ - if (code == REAL_CST) - { - length = sizeof (struct tree_real_cst); - kind = c_kind; - break; - } - length = sizeof (struct tree_common) - + tree_code_length[(int) code] * sizeof (char *); - kind = c_kind; - break; - - case 'x': /* something random, like an identifier. */ - length = sizeof (struct tree_common) - + tree_code_length[(int) code] * sizeof (char *); - /* Identifier nodes are always permanent since they are - unique in a compiler run. */ - if (code == IDENTIFIER_NODE) - { - kind = id_kind; - obstack = &permanent_obstack; - } - else if (code == OP_IDENTIFIER) - kind = op_id_kind; - else - kind = x_kind; - } - - t = (tree) obstack_alloc (obstack, length); - -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)kind]++; - tree_node_sizes[(int)kind] += length; -#endif - - TREE_UID (t) = tree_node_counter++; - TREE_TYPE (t) = 0; - TREE_CHAIN (t) = 0; - for (i = (length / sizeof (int)) - 1; - i >= sizeof (struct tree_common) / sizeof (int) - 1; - i--) - ((int *) t)[i] = 0; - - TREE_SET_CODE (t, code); - if (obstack == &permanent_obstack) - TREE_PERMANENT (t) = 1; - - if (type == 'd') - { - extern int lineno; - - DECL_ALIGN (t) = 1; - DECL_SIZE_UNIT (t) = 1; - DECL_VOFFSET_UNIT (t) = 1; - if (code == PARM_DECL) - DECL_CONTEXT (t) = current_function_decl; - else - { - DECL_SOURCE_LINE (t) = lineno; - DECL_SOURCE_FILE (t) - = (input_filename) ? input_filename : ""; - } - } - - if (type == 't') - { - TYPE_ALIGN (t) = 1; - TYPE_SIZE_UNIT (t) = 1; - TYPE_MAIN_VARIANT (t) = t; - } - - if (type == 'c') - { - TREE_LITERAL (t) = 1; - } - - return t; -} - -/* Return a new node with the same contents as NODE - except that its TREE_CHAIN is zero and it has a fresh uid. */ - -tree -copy_node (node) - tree node; -{ - register tree t; - register enum tree_code code = TREE_CODE (node); - register int length; - register int i; - - switch (*tree_code_type[(int) code]) - { - case 'd': /* A decl node */ - length = sizeof (struct tree_decl) - + tree_code_length[(int) code] * sizeof (char *); - break; - - case 't': /* a type node */ - length = sizeof (struct tree_type); - break; - - case 's': - length = sizeof (struct tree_common) - + 2 * sizeof (int) - + tree_code_length[(int) code] * sizeof (char *); - break; - - case 'r': /* a reference */ - case 'e': /* a expression */ - length = sizeof (struct tree_exp) - + (tree_code_length[(int) code] - 1) * sizeof (char *); - break; - - case 'c': /* a constant */ - /* We can't use tree_code_length for this, since the number of words - is machine-dependent due to varying alignment of `double'. */ - if (code == REAL_CST) - { - length = sizeof (struct tree_real_cst); - break; - } - - case 'x': /* something random, like an identifier. */ - length = sizeof (struct tree_common) - + tree_code_length[(int) code] * sizeof (char *); - if (code == TREE_VEC) - length += (TREE_VEC_LENGTH (node) - 1) * sizeof (char *); - } - - t = (tree) obstack_alloc (current_obstack, length); - - for (i = ((length + sizeof (int) - 1) / sizeof (int)) - 1; - i >= 0; - i--) - ((int *) t)[i] = ((int *) node)[i]; - - TREE_UID (t) = tree_node_counter++; - TREE_CHAIN (t) = 0; - - TREE_PERMANENT (t) = (current_obstack == &permanent_obstack); - - return t; -} - -/* Return a copy of a chain of nodes, chained through the TREE_CHAIN field. - For example, this can copy a list made of TREE_LIST nodes. */ - -tree -copy_list (list) - tree list; -{ - tree head; - register tree prev, next; - - if (list == 0) - return 0; - - head = prev = copy_node (list); - next = TREE_CHAIN (list); - while (next) - { - TREE_CHAIN (prev) = copy_node (next); - prev = TREE_CHAIN (prev); - next = TREE_CHAIN (next); - } - return head; -} - -#define HASHBITS 30 - -/* Return an IDENTIFIER_NODE whose name is TEXT (a null-terminated string). - If an identifier with that name has previously been referred to, - the same node is returned this time. */ - -tree -get_identifier (text) - register char *text; -{ - register int hi; - register int i; - register tree idp; - register int len, hash_len; - - /* Compute length of text in len. */ - for (len = 0; text[len]; len++); - - /* Decide how much of that length to hash on */ - hash_len = len; - if (warn_id_clash && len > id_clash_len) - hash_len = id_clash_len; - - /* Compute hash code */ - hi = 17 * (unsigned)(text[0]) + len; - for (i = 1; i < hash_len; i += 2) - hi = ((hi * 613) + (unsigned)(text[i])); - - hi &= (1 << HASHBITS) - 1; - hi %= MAX_HASH_TABLE; - - /* Search table for identifier */ - for (idp = hash_table[hi]; idp; idp = TREE_CHAIN (idp)) - if (IDENTIFIER_LENGTH (idp) == len - && IDENTIFIER_POINTER (idp)[0] == text[0] - && !bcmp (IDENTIFIER_POINTER (idp), text, len)) - return idp; /* <-- return if found */ - - /* Not found; optionally warn about a similar identifier */ - if (warn_id_clash && do_identifier_warnings && len > id_clash_len) - for (idp = hash_table[hi]; idp; idp = TREE_CHAIN (idp)) - if (!strncmp (IDENTIFIER_POINTER (idp), text, id_clash_len)) - { - warning ("`%s' and `%s' identical in first n characters", - IDENTIFIER_POINTER (idp), text); - break; - } - - if (tree_code_length[(int) IDENTIFIER_NODE] < 0) - abort (); /* set_identifier_size hasn't been called. */ - - /* Not found, create one, add to chain */ - idp = make_node (IDENTIFIER_NODE); - IDENTIFIER_LENGTH (idp) = len; - id_string_size += len; - - IDENTIFIER_POINTER (idp) = obstack_copy0 (&permanent_obstack, text, len); - - TREE_CHAIN (idp) = hash_table[hi]; - hash_table[hi] = idp; - return idp; /* <-- return if created */ -} - -/* Enable warnings on similar identifiers (if requested). - Done after the built-in identifiers are created. */ - -void -start_identifier_warnings () -{ - do_identifier_warnings = 1; -} - -/* Record the size of an identifier node for the language in use. - SIZE is the total size in bytes. - This is called by the language-specific files. This must be - called before allocating any identifiers. */ - -void -set_identifier_size (size) - int size; -{ - tree_code_length[(int) IDENTIFIER_NODE] - = (size - sizeof (struct tree_common)) / sizeof (tree); -} - -/* Return a newly constructed INTEGER_CST node whose constant value - is specified by the two ints LOW and HI. - The TREE_TYPE is set to `int'. */ - -tree -build_int_2 (low, hi) - int low, hi; -{ - register tree t = make_node (INTEGER_CST); - TREE_INT_CST_LOW (t) = low; - TREE_INT_CST_HIGH (t) = hi; - TREE_TYPE (t) = integer_type_node; - return t; -} - -/* Return a new REAL_CST node whose type is TYPE and value is D. */ - -tree -build_real (type, d) - tree type; - REAL_VALUE_TYPE d; -{ - tree v; - - /* Check for valid float value for this type on this target machine; - if not, can print error message and store a valid value in D. */ -#ifdef CHECK_FLOAT_VALUE - CHECK_FLOAT_VALUE (TYPE_MODE (type), d); -#endif - - v = make_node (REAL_CST); - TREE_TYPE (v) = type; - TREE_REAL_CST (v) = d; - return v; -} - -/* Return a new REAL_CST node whose type is TYPE - and whose value is the integer value of the INTEGER_CST node I. */ - -#if !defined (REAL_IS_NOT_DOUBLE) || defined (REAL_ARITHMETIC) - -REAL_VALUE_TYPE -real_value_from_int_cst (i) - tree i; -{ - REAL_VALUE_TYPE d; -#ifdef REAL_ARITHMETIC - REAL_VALUE_FROM_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i)); -#else /* not REAL_ARITHMETIC */ - if (TREE_INT_CST_HIGH (i) < 0) - { - d = (double) (~ TREE_INT_CST_HIGH (i)); - d *= ((double) (1 << (HOST_BITS_PER_INT / 2)) - * (double) (1 << (HOST_BITS_PER_INT / 2))); - d += (double) (unsigned) (~ TREE_INT_CST_LOW (i)); - d = (- d - 1.0); - } - else - { - d = (double) TREE_INT_CST_HIGH (i); - d *= ((double) (1 << (HOST_BITS_PER_INT / 2)) - * (double) (1 << (HOST_BITS_PER_INT / 2))); - d += (double) (unsigned) TREE_INT_CST_LOW (i); - } -#endif /* not REAL_ARITHMETIC */ - return d; -} - -/* This function can't be implemented if we can't do arithmetic - on the float representation. */ - -tree -build_real_from_int_cst (type, i) - tree type; - tree i; -{ - tree v; - REAL_VALUE_TYPE d; - - v = make_node (REAL_CST); - TREE_TYPE (v) = type; - - d = real_value_from_int_cst (i); - /* Check for valid float value for this type on this target machine; - if not, can print error message and store a valid value in D. */ -#ifdef CHECK_FLOAT_VALUE - CHECK_FLOAT_VALUE (TYPE_MODE (type), d); -#endif - - TREE_REAL_CST (v) = d; - return v; -} - -#endif /* not REAL_IS_NOT_DOUBLE, or REAL_ARITHMETIC */ - -/* Return a newly constructed STRING_CST node whose value is - the LEN characters at STR. - The TREE_TYPE is not initialized. */ - -tree -build_string (len, str) - int len; - char *str; -{ - register tree s = make_node (STRING_CST); - TREE_STRING_LENGTH (s) = len; - TREE_STRING_POINTER (s) = obstack_copy0 (saveable_obstack, str, len); - return s; -} - -/* Return a newly constructed COMPLEX_CST node whose value is - specified by the real and imaginary parts REAL and IMAG. - Both REAL and IMAG should be constant nodes. - The TREE_TYPE is not initialized. */ - -tree -build_complex (real, imag) - tree real, imag; -{ - register tree t = make_node (COMPLEX_CST); - TREE_REALPART (t) = real; - TREE_IMAGPART (t) = imag; - return t; -} - -/* Build a newly constructed TREE_VEC node of length LEN. */ -tree -make_tree_vec (len) - int len; -{ - register tree t; - register int length = (len-1) * sizeof (tree) + sizeof (struct tree_vec); - register struct obstack *obstack = current_obstack; - register int i; - -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)x_kind]++; - tree_node_sizes[(int)x_kind] += length; -#endif - - t = (tree) obstack_alloc (obstack, length); - - TREE_UID (t) = tree_node_counter++; - TREE_TYPE (t) = 0; - TREE_CHAIN (t) = 0; - for (i = (length / sizeof (int)) - 1; - i >= sizeof (struct tree_common) / sizeof (int) - 1; - i--) - ((int *) t)[i] = 0; - TREE_SET_CODE (t, TREE_VEC); - TREE_VEC_LENGTH (t) = len; - if (obstack == &permanent_obstack) - TREE_PERMANENT (t) = 1; - - return t; -} - -/* Return 1 if EXPR is the integer constant zero. */ - -int -integer_zerop (expr) - tree expr; -{ - return (TREE_CODE (expr) == INTEGER_CST - && TREE_INT_CST_LOW (expr) == 0 - && TREE_INT_CST_HIGH (expr) == 0); -} - -/* Return 1 if EXPR is the integer constant one. */ - -int -integer_onep (expr) - tree expr; -{ - return (TREE_CODE (expr) == INTEGER_CST - && TREE_INT_CST_LOW (expr) == 1 - && TREE_INT_CST_HIGH (expr) == 0); -} - -/* Return 1 if EXPR is an integer containing all 1's - in as much precision as it contains. */ - -int -integer_all_onesp (expr) - tree expr; -{ - register int prec; - register int uns; - - if (TREE_CODE (expr) != INTEGER_CST) - return 0; - - uns = TREE_UNSIGNED (TREE_TYPE (expr)); - if (!uns) - return TREE_INT_CST_LOW (expr) == -1 && TREE_INT_CST_HIGH (expr) == -1; - - prec = TYPE_PRECISION (TREE_TYPE (expr)); - if (prec >= HOST_BITS_PER_INT) - return TREE_INT_CST_LOW (expr) == -1 - && TREE_INT_CST_HIGH (expr) == (1 << (prec - HOST_BITS_PER_INT)) - 1; - else - return TREE_INT_CST_LOW (expr) == (1 << prec) - 1; -} - -/* Return list element whose TREE_VALUE is ELEM. - Return 0 if ELEM is not in LIST. */ -tree -value_member (elem, list) - tree elem, list; -{ - while (list) - { - if (elem == TREE_VALUE (list)) - return list; - list = TREE_CHAIN (list); - } - return NULL_TREE; -} - -/* Return list element whose TREE_PURPOSE is ELEM. - Return 0 if ELEM is not in LIST. */ -tree -purpose_member (elem, list) - tree elem, list; -{ - while (list) - { - if (elem == TREE_PURPOSE (list)) - return list; - list = TREE_CHAIN (list); - } - return NULL_TREE; -} - -/* Return the length of a chain of nodes chained through TREE_CHAIN. - We expect a null pointer to mark the end of the chain. - This is the Lisp primitive `length'. */ - -int -list_length (t) - tree t; -{ - register tree tail; - register int len = 0; - - for (tail = t; tail; tail = TREE_CHAIN (tail)) - len++; - - return len; -} - -/* Concatenate two chains of nodes (chained through TREE_CHAIN) - by modifying the last node in chain 1 to point to chain 2. - This is the Lisp primitive `nconc'. */ - -tree -chainon (op1, op2) - tree op1, op2; -{ - tree t; - - if (op1) - { - for (t = op1; TREE_CHAIN (t); t = TREE_CHAIN (t)) - if (t == op2) abort (); /* Circularity being created */ - TREE_CHAIN (t) = op2; - return op1; - } - else return op2; -} - -/* Return a newly created TREE_LIST node whose - purpose and value fields are PARM and VALUE. */ - -tree -build_tree_list (parm, value) - tree parm, value; -{ -#if 0 - register tree t = make_node (TREE_LIST); -#else - register tree t; - register struct obstack *obstack = current_obstack; - register int i; - - t = (tree) obstack_alloc (obstack, sizeof (struct tree_list)); - TREE_UID (t) = tree_node_counter++; - TREE_TYPE (t) = 0; - TREE_CHAIN (t) = 0; - ((int *) t)[3] = 0; - - TREE_SET_CODE (t, TREE_LIST); - if (obstack == &permanent_obstack) - { - TREE_PERMANENT (t) = 1; -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)perm_list_kind]++; - tree_node_sizes[(int)perm_list_kind] += sizeof (struct tree_list); -#endif - } - else - { -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)temp_list_kind]++; - tree_node_sizes[(int)temp_list_kind] += sizeof (struct tree_list); -#endif - } -#endif - - TREE_PURPOSE (t) = parm; - TREE_VALUE (t) = value; - return t; -} - -/* Similar, but build on the temp_decl_obstack. */ -tree -build_decl_list (parm, value) - tree parm, value; -{ - register tree node; - register struct obstack *ambient_obstack = current_obstack; - current_obstack = &temp_decl_obstack; - node = build_tree_list (parm, value); - current_obstack = ambient_obstack; - return node; -} - -/* Return a newly created TREE_LIST node whose - purpose and value fields are PARM and VALUE - and whose TREE_CHAIN is CHAIN. */ - -tree -tree_cons (purpose, value, chain) - tree purpose, value, chain; -{ -#if 0 - register tree t = make_node (TREE_LIST); -#else - register tree t; - register struct obstack *obstack = current_obstack; - register int i; - - t = (tree) obstack_alloc (obstack, sizeof (struct tree_list)); - TREE_UID (t) = tree_node_counter++; - TREE_TYPE (t) = 0; - ((int *) t)[3] = 0; - - TREE_SET_CODE (t, TREE_LIST); - if (obstack == &permanent_obstack) - { - TREE_PERMANENT (t) = 1; -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)perm_list_kind]++; - tree_node_sizes[(int)perm_list_kind] += sizeof (struct tree_list); -#endif - } - else - { -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)temp_list_kind]++; - tree_node_sizes[(int)temp_list_kind] += sizeof (struct tree_list); -#endif - } -#endif - - TREE_CHAIN (t) = chain; - TREE_PURPOSE (t) = purpose; - TREE_VALUE (t) = value; - return t; -} - -/* Similar, but build on the temp_decl_obstack. */ -tree -decl_tree_cons (purpose, value, chain) - tree purpose, value, chain; -{ - register tree node; - register struct obstack *ambient_obstack = current_obstack; - current_obstack = &temp_decl_obstack; - - node = tree_cons (purpose, value, chain); - current_obstack = ambient_obstack; - return node; -} - -/* Same as `tree_cons' but make a permanent object. */ - -tree -perm_tree_cons (purpose, value, chain) - tree purpose, value, chain; -{ - register tree node; - register struct obstack *ambient_obstack = current_obstack; - current_obstack = &permanent_obstack; - - node = tree_cons (purpose, value, chain); - current_obstack = ambient_obstack; - return node; -} - -/* Same as `tree_cons', but make this node temporary, regardless. */ - -tree -temp_tree_cons (purpose, value, chain) - tree purpose, value, chain; -{ - register tree node; - register struct obstack *ambient_obstack = current_obstack; - current_obstack = &temporary_obstack; - - node = tree_cons (purpose, value, chain); - current_obstack = ambient_obstack; - return node; -} - -/* Same as `tree_cons', but save this node if the function's RTL is saved. */ - -tree -saveable_tree_cons (purpose, value, chain) - tree purpose, value, chain; -{ - register tree node; - register struct obstack *ambient_obstack = current_obstack; - current_obstack = saveable_obstack; - - node = tree_cons (purpose, value, chain); - current_obstack = ambient_obstack; - return node; -} - -/* Return the last node in a chain of nodes (chained through TREE_CHAIN). */ - -tree -tree_last (chain) - register tree chain; -{ - register tree next; - if (chain) - while (next = TREE_CHAIN (chain)) - chain = next; - return chain; -} - -/* Reverse the order of elements in the chain T, - and return the new head of the chain (old last element). */ - -tree -nreverse (t) - tree t; -{ - register tree prev = 0, decl, next; - for (decl = t; decl; decl = next) - { - next = TREE_CHAIN (decl); - TREE_CHAIN (decl) = prev; - prev = decl; - } - return prev; -} - -/* Given a chain CHAIN of tree nodes, - construct and return a list of those nodes. */ - -tree -listify (chain) - tree chain; -{ - tree result = NULL_TREE; - tree in_tail = chain; - tree out_tail = NULL_TREE; - - while (in_tail) - { - tree next = tree_cons (NULL_TREE, in_tail, NULL_TREE); - if (out_tail) - TREE_CHAIN (out_tail) = next; - else - result = next; - out_tail = next; - in_tail = TREE_CHAIN (in_tail); - } - - return result; -} - -/* Return the size nominally occupied by an object of type TYPE - when it resides in memory. The value is measured in units of bytes, - and its data type is that normally used for type sizes - (which is the first type created by make_signed_type or - make_unsigned_type). */ - -tree -size_in_bytes (type) - tree type; -{ - if (type == error_mark_node) - return integer_zero_node; - type = TYPE_MAIN_VARIANT (type); - if (TYPE_SIZE (type) == 0) - { - incomplete_type_error (0, type); - return integer_zero_node; - } - return convert_units (TYPE_SIZE (type), TYPE_SIZE_UNIT (type), - BITS_PER_UNIT); -} - -/* Return the size of TYPE (in bytes) as an integer, - or return -1 if the size can vary. */ - -int -int_size_in_bytes (type) - tree type; -{ - int size; - if (type == error_mark_node) - return 0; - type = TYPE_MAIN_VARIANT (type); - if (TYPE_SIZE (type) == 0) - return -1; - if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) - return -1; - size = TREE_INT_CST_LOW (TYPE_SIZE (type)) * TYPE_SIZE_UNIT (type); - return (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT; -} - -/* Return, as an INTEGER_CST node, the number of elements for - TYPE (which is an ARRAY_TYPE). */ - -tree -array_type_nelts (type) - tree type; -{ - tree index_type = TYPE_DOMAIN (type); - if (index_type == NULL_TREE) - { - incomplete_type_error (NULL_TREE, type); - return error_mark_node; - } - return (tree_int_cst_equal (TYPE_MIN_VALUE (index_type), integer_zero_node) - ? TYPE_MAX_VALUE (index_type) - : fold (build (MINUS_EXPR, integer_type_node, - TYPE_MAX_VALUE (index_type), - TYPE_MIN_VALUE (index_type)))); -} - -/* Return nonzero if arg is static -- a reference to an object in - static storage. This is not the same as the C meaning of `static'. */ - -int -staticp (arg) - tree arg; -{ - register enum tree_code code = TREE_CODE (arg); - - if ((code == VAR_DECL || code == FUNCTION_DECL || code == CONSTRUCTOR) - && (TREE_STATIC (arg) || TREE_EXTERNAL (arg))) - return 1; - - if (code == STRING_CST) - return 1; - - if (code == COMPONENT_REF) - return (DECL_VOFFSET (TREE_OPERAND (arg, 1)) == 0 - && staticp (TREE_OPERAND (arg, 0))); - - if (code == INDIRECT_REF) - return TREE_LITERAL (TREE_OPERAND (arg, 0)); - - if (code == ARRAY_REF) - { - if (TREE_CODE (TYPE_SIZE (TREE_TYPE (arg))) == INTEGER_CST - && TREE_CODE (TREE_OPERAND (arg, 1)) == INTEGER_CST) - return staticp (TREE_OPERAND (arg, 0)); - } - - return 0; -} - -/* This should be applied to any node which may be used in more than one place, - but must be evaluated only once. Normally, the code generator would - reevaluate the node each time; this forces it to compute it once and save - the result. This is done by encapsulating the node in a SAVE_EXPR. */ - -tree -save_expr (expr) - tree expr; -{ - register tree t = fold (expr); - - /* If the tree evaluates to a constant, then we don't want to hide that - fact (i.e. this allows further folding, and direct checks for constants). - Since it is no problem to reevaluate literals, we just return the - literal node. */ - - if (TREE_LITERAL (t) || TREE_READONLY (t) || TREE_CODE (t) == SAVE_EXPR) - return t; - - return build (SAVE_EXPR, TREE_TYPE (expr), t, NULL); -} - -/* Stabilize a reference so that we can use it any number of times - without causing its operands to be evaluated more than once. - Returns the stabilized reference. - - Also allows conversion expressions whose operands are references. - Any other kind of expression is returned unchanged. */ - -tree -stabilize_reference (ref) - tree ref; -{ - register tree result; - register enum tree_code code = TREE_CODE (ref); - - switch (code) - { - case VAR_DECL: - case PARM_DECL: - case RESULT_DECL: - result = ref; - break; - - case NOP_EXPR: - case CONVERT_EXPR: - case FLOAT_EXPR: - case FIX_TRUNC_EXPR: - case FIX_FLOOR_EXPR: - case FIX_ROUND_EXPR: - case FIX_CEIL_EXPR: - result = build_nt (code, stabilize_reference (TREE_OPERAND (ref, 0))); - break; - - case INDIRECT_REF: - result = build_nt (INDIRECT_REF, save_expr (TREE_OPERAND (ref, 0))); - break; - - case COMPONENT_REF: - result = build_nt (COMPONENT_REF, - stabilize_reference (TREE_OPERAND (ref, 0)), - TREE_OPERAND (ref, 1)); - break; - - case ARRAY_REF: - result = build_nt (ARRAY_REF, stabilize_reference (TREE_OPERAND (ref, 0)), - save_expr (TREE_OPERAND (ref, 1))); - break; - - /* If arg isn't a kind of lvalue we recognize, make no change. - Caller should recognize the error for an invalid lvalue. */ - default: - return ref; - - case ERROR_MARK: - return error_mark_node; - } - - TREE_TYPE (result) = TREE_TYPE (ref); - TREE_READONLY (result) = TREE_READONLY (ref); - TREE_VOLATILE (result) = TREE_VOLATILE (ref); - TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (ref); - TREE_RAISES (result) = TREE_RAISES (ref); - - return result; -} - -/* Low-level constructors for expressions. */ - -/* Build an expression of code CODE, data type TYPE, - and operands as specified by the arguments ARG1 and following arguments. - Expressions and reference nodes can be created this way. - Constants, decls, types and misc nodes cannot be. */ - -tree -build (va_alist) - va_dcl -{ - register va_list p; - enum tree_code code; - register tree t; - register int length; - register int i; - - va_start (p); - - code = va_arg (p, enum tree_code); - t = make_node (code); - length = tree_code_length[(int) code]; - TREE_TYPE (t) = va_arg (p, tree); - - if (length == 2) - { - /* This is equivalent to the loop below, but faster. */ - register tree arg0 = va_arg (p, tree); - register tree arg1 = va_arg (p, tree); - TREE_OPERAND (t, 0) = arg0; - TREE_OPERAND (t, 1) = arg1; - TREE_VOLATILE (t) - = (arg0 && TREE_VOLATILE (arg0)) || (arg1 && TREE_VOLATILE (arg1)); - TREE_RAISES (t) - = (arg0 && TREE_RAISES (arg0)) || (arg1 && TREE_RAISES (arg1)); - } - else - { - for (i = 0; i < length; i++) - { - register tree operand = va_arg (p, tree); - TREE_OPERAND (t, i) = operand; - if (operand) - { - if (TREE_VOLATILE (operand)) - TREE_VOLATILE (t) = 1; - if (TREE_RAISES (operand)) - TREE_RAISES (t) = 1; - } - } - } - va_end (p); - return t; -} - -/* Same as above, but only builds for unary operators. - Saves lions share of calls to `build'; cuts down use - of varargs, which is expensive for RISC machines. */ -tree -build1 (code, type, node) - enum tree_code code; - tree type; - tree node; -{ - register struct obstack *obstack = current_obstack; - register int i, length; - register tree_node_kind kind; - register tree t; - - if (*tree_code_type[(int) code] == 'r') - kind = r_kind; - else if (*tree_code_type[(int) code] == 'e') - kind = e_kind; - else - abort (); - - obstack = expression_obstack; - length = sizeof (struct tree_exp); - - t = (tree) obstack_alloc (obstack, length); - -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)kind]++; - tree_node_sizes[(int)kind] += length; -#endif - - TREE_UID (t) = tree_node_counter++; - TREE_TYPE (t) = type; - TREE_CHAIN (t) = 0; - - for (i = (length / sizeof (int)) - 2; - i >= sizeof (struct tree_common) / sizeof (int) - 1; - i--) - ((int *) t)[i] = 0; - TREE_SET_CODE (t, code); - - if (obstack == &permanent_obstack) - TREE_PERMANENT (t) = 1; - - TREE_OPERAND (t, 0) = node; - if (node) - { - if (TREE_VOLATILE (node)) - TREE_VOLATILE (t) = 1; - if (TREE_RAISES (node)) - TREE_RAISES (t) = 1; - } - return t; -} - -/* Similar except don't specify the TREE_TYPE - and leave the TREE_VOLATILE as 0. - It is permissible for arguments to be null, - or even garbage if their values do not matter. */ - -tree -build_nt (va_alist) - va_dcl -{ - register va_list p; - register enum tree_code code; - register tree t; - register int length; - register int i; - - va_start (p); - - code = va_arg (p, enum tree_code); - t = make_node (code); - length = tree_code_length[(int) code]; - - for (i = 0; i < length; i++) - TREE_OPERAND (t, i) = va_arg (p, tree); - - va_end (p); - return t; -} - -/* Similar to `build_nt', except we build - on the temp_decl_obstack, regardless. */ - -tree -build_parse_node (va_alist) - va_dcl -{ - register struct obstack *ambient_obstack = expression_obstack; - register va_list p; - register enum tree_code code; - register tree t; - register int length; - register int i; - - expression_obstack = &temp_decl_obstack; - - va_start (p); - - code = va_arg (p, enum tree_code); - t = make_node (code); - length = tree_code_length[(int) code]; - - for (i = 0; i < length; i++) - TREE_OPERAND (t, i) = va_arg (p, tree); - - va_end (p); - expression_obstack = ambient_obstack; - return t; -} - -#if 0 -/* Commented out because this wants to be done very - differently. See cplus-lex.c. */ -tree -build_op_identifier (op1, op2) - tree op1, op2; -{ - register tree t = make_node (OP_IDENTIFIER); - TREE_PURPOSE (t) = op1; - TREE_VALUE (t) = op2; - return t; -} -#endif - -/* Create a DECL_... node of code CODE, name NAME and data type TYPE. - We do NOT enter this node in any sort of symbol table. - - layout_decl is used to set up the decl's storage layout. - Other slots are initialized to 0 or null pointers. */ - -tree -build_decl (code, name, type) - enum tree_code code; - tree name, type; -{ - register tree t; - - t = make_node (code); - -/* if (type == error_mark_node) - type = integer_type_node; */ -/* That is not done, deliberately, so that having error_mark_node - as the type can suppress useless errors in the use of this variable. */ - - DECL_NAME (t) = name; - if (name) - { -#if 0 - DECL_PRINT_NAME (t) = IDENTIFIER_POINTER (name); -#endif - if (code != PARM_DECL) - DECL_ASSEMBLER_NAME (t) = IDENTIFIER_POINTER (name); - } - TREE_TYPE (t) = type; - - /* A freshly built node has these properties anyway. */ -#if 0 - DECL_ARGUMENTS (t) = NULL_TREE; - DECL_INITIAL (t) = NULL_TREE; -#endif /* 0 */ - - if (code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL) - layout_decl (t, 0); - else if (code == FUNCTION_DECL) - DECL_MODE (t) = FUNCTION_MODE; - - return t; -} - -/* Low-level constructors for statements. - These constructors all expect source file name and line number - as arguments, as well as enough arguments to fill in the data - in the statement node. */ - -tree -build_goto (filename, line, label) - char *filename; - int line; - tree label; -{ - register tree t = make_node (GOTO_STMT); - STMT_SOURCE_FILE (t) = filename; - STMT_SOURCE_LINE (t) = line; - STMT_BODY (t) = label; - return t; -} - -tree -build_return (filename, line, arg) - char *filename; - int line; - tree arg; -{ - register tree t = make_node (RETURN_STMT); - - STMT_SOURCE_FILE (t) = filename; - STMT_SOURCE_LINE (t) = line; - STMT_BODY (t) = arg; - return t; -} - -tree -build_expr_stmt (filename, line, expr) - char *filename; - int line; - tree expr; -{ - register tree t = make_node (EXPR_STMT); - - STMT_SOURCE_FILE (t) = filename; - STMT_SOURCE_LINE (t) = line; - STMT_BODY (t) = expr; - return t; -} - -tree -build_if (filename, line, cond, thenclause, elseclause) - char *filename; - int line; - tree cond, thenclause, elseclause; -{ - register tree t = make_node (IF_STMT); - - STMT_SOURCE_FILE (t) = filename; - STMT_SOURCE_LINE (t) = line; - STMT_COND (t) = cond; - STMT_THEN (t) = thenclause; - STMT_ELSE (t) = elseclause; - return t; -} - -tree -build_exit (filename, line, cond) - char *filename; - int line; - tree cond; -{ - register tree t = make_node (EXIT_STMT); - STMT_SOURCE_FILE (t) = filename; - STMT_SOURCE_LINE (t) = line; - STMT_BODY (t) = cond; - return t; -} - -tree -build_asm_stmt (filename, line, asmcode) - char *filename; - int line; - tree asmcode; -{ - register tree t = make_node (ASM_STMT); - STMT_SOURCE_FILE (t) = filename; - STMT_SOURCE_LINE (t) = line; - STMT_BODY (t) = asmcode; - return t; -} - -tree -build_case (filename, line, object, cases) - char *filename; - int line; - tree object, cases; -{ - register tree t = make_node (CASE_STMT); - STMT_SOURCE_FILE (t) = filename; - STMT_SOURCE_LINE (t) = line; - STMT_CASE_INDEX (t) = object; - STMT_CASE_LIST (t) = cases; - return t; -} - -tree -build_compound (filename, line, body) - char *filename; - int line; - tree body; -{ - register tree t = make_node (COMPOUND_STMT); - STMT_SOURCE_FILE (t) = filename; - STMT_SOURCE_LINE (t) = line; - STMT_BODY (t) = body; - return t; -} - -tree -build_loop (filename, line, vars, cond, body) - char *filename; - int line; - tree vars, cond, body; -{ - register tree t = make_node (LOOP_STMT); - STMT_SOURCE_FILE (t) = filename; - STMT_SOURCE_LINE (t) = line; - STMT_LOOP_VARS (t) = vars; - STMT_LOOP_COND (t) = cond; - STMT_LOOP_BODY (t) = body; - return t; -} - -/* LET_STMT nodes are used to represent the structure of binding contours - and declarations, once those contours have been exited and their contents - compiled. This information is used for outputting debugging info. */ - -tree -build_let (filename, line, vars, subblocks, supercontext, tags) - char *filename; - int line; - tree vars, subblocks, supercontext, tags; -{ - register tree t = make_node (LET_STMT); - STMT_SOURCE_FILE (t) = filename; - STMT_SOURCE_LINE (t) = line; - STMT_VARS (t) = vars; - STMT_SUBBLOCKS (t) = subblocks; - STMT_SUPERCONTEXT (t) = supercontext; - STMT_BIND_SIZE (t) = 0; - STMT_TYPE_TAGS (t) = tags; - return t; -} - -/* Return a type like TYPE except that its TREE_READONLY is CONSTP - and its TREE_VOLATILE is VOLATILEP. - - Such variant types already made are recorded so that duplicates - are not made. - - A variant types should never be used as the type of an expression. - Always copy the variant information into the TREE_READONLY - and TREE_VOLATILE of the expression, and then give the expression - as its type the "main variant", the variant whose TREE_READONLY - and TREE_VOLATILE are zero. Use TYPE_MAIN_VARIANT to find the - main variant. */ - -tree -build_type_variant (type, constp, volatilep) - tree type; - int constp, volatilep; -{ - register tree t, m = TYPE_MAIN_VARIANT (type); - register struct obstack *ambient_obstack = current_obstack; - - /* Treat any nonzero argument as 1. */ - constp = !!constp; - volatilep = !!volatilep; - - /* First search the chain variants for one that is what we want. */ - - for (t = m; t; t = TYPE_NEXT_VARIANT (t)) - if (constp == TREE_READONLY (t) - && volatilep == TREE_VOLATILE (t)) - return t; - - /* We need a new one. */ - current_obstack - = TREE_PERMANENT (type) ? &permanent_obstack : saveable_obstack; - - t = copy_node (type); - TREE_READONLY (t) = constp; - TREE_VOLATILE (t) = volatilep; - TYPE_POINTER_TO (t) = 0; - TYPE_REFERENCE_TO (t) = 0; - - /* Add this type to the chain of variants of TYPE. */ - TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m); - TYPE_NEXT_VARIANT (m) = t; - - current_obstack = ambient_obstack; - return t; -} - -/* Hashing of types so that we don't make duplicates. - The entry point is `type_hash_canon'. */ - -/* Each hash table slot is a bucket containing a chain - of these structures. */ - -struct type_hash -{ - struct type_hash *next; /* Next structure in the bucket. */ - int hashcode; /* Hash code of this type. */ - tree type; /* The type recorded here. */ -}; - -/* Now here is the hash table. When recording a type, it is added - to the slot whose index is the hash code mod the table size. - Note that the hash table is used for several kinds of types - (function types, array types and array index range types, for now). - While all these live in the same table, they are completely independent, - and the hash code is computed differently for each of these. */ - -#define TYPE_HASH_SIZE 59 -struct type_hash *type_hash_table[TYPE_HASH_SIZE]; - -/* Here is how primitive or already-canonicalized types' hash - codes are made. */ -#define TYPE_HASH(TYPE) TREE_UID (TYPE) - -/* Compute a hash code for a list of types (chain of TREE_LIST nodes - with types in the TREE_VALUE slots), by adding the hash codes - of the individual types. */ - -int -type_hash_list (list) - tree list; -{ - register int hashcode; - register tree tail; - for (hashcode = 0, tail = list; tail; tail = TREE_CHAIN (tail)) - hashcode += TYPE_HASH (TREE_VALUE (tail)); - return hashcode; -} - -/* Look in the type hash table for a type isomorphic to TYPE. - If one is found, return it. Otherwise return 0. */ - -tree -type_hash_lookup (hashcode, type) - int hashcode; - tree type; -{ - register struct type_hash *h; - for (h = type_hash_table[hashcode % TYPE_HASH_SIZE]; h; h = h->next) - if (h->hashcode == hashcode - && TREE_CODE (h->type) == TREE_CODE (type) - && TREE_TYPE (h->type) == TREE_TYPE (type) - && (TYPE_MAX_VALUE (h->type) == TYPE_MAX_VALUE (type) - || tree_int_cst_equal (TYPE_MAX_VALUE (h->type), - TYPE_MAX_VALUE (type))) - && (TYPE_MIN_VALUE (h->type) == TYPE_MIN_VALUE (type) - || tree_int_cst_equal (TYPE_MIN_VALUE (h->type), - TYPE_MIN_VALUE (type))) - && (TYPE_DOMAIN (h->type) == TYPE_DOMAIN (type) - || (TREE_CODE (TYPE_DOMAIN (h->type)) == TREE_LIST - && TREE_CODE (TYPE_DOMAIN (type)) == TREE_LIST - && type_list_equal (TYPE_DOMAIN (h->type), TYPE_DOMAIN (type))))) - return h->type; - return 0; -} - -/* Add an entry to the type-hash-table - for a type TYPE whose hash code is HASHCODE. */ - -void -type_hash_add (hashcode, type) - int hashcode; - tree type; -{ - register struct type_hash *h; - - h = (struct type_hash *) oballoc (sizeof (struct type_hash)); - h->hashcode = hashcode; - h->type = type; - h->next = type_hash_table[hashcode % TYPE_HASH_SIZE]; - type_hash_table[hashcode % TYPE_HASH_SIZE] = h; -} - -/* Given TYPE, and HASHCODE its hash code, return the canonical - object for an identical type if one already exists. - Otherwise, return TYPE, and record it as the canonical object - if it is a permanent object. - - To use this function, first create a type of the sort you want. - Then compute its hash code from the fields of the type that - make it different from other similar types. - Then call this function and use the value. - This function frees the type you pass in if it is a duplicate. */ - -/* Set to 1 to debug without canonicalization. Never set by program. */ -int debug_no_type_hash = 0; - -tree -type_hash_canon (hashcode, type) - int hashcode; - tree type; -{ - tree t1; - - if (debug_no_type_hash) - return type; - - t1 = type_hash_lookup (hashcode, type); - if (t1 != 0) - { - struct obstack *o - = TREE_PERMANENT (type) ? &permanent_obstack : saveable_obstack; - obstack_free (o, type); -#ifdef GATHER_STATISTICS - tree_node_kinds[(int)t_kind]--; - tree_node_sizes[(int)t_kind] -= sizeof (struct tree_type); -#endif - return t1; - } - - /* If this is a new type, record it for later reuse. */ - if (current_obstack == &permanent_obstack) - type_hash_add (hashcode, type); - - return type; -} - -/* Given two lists of types - (chains of TREE_LIST nodes with types in the TREE_VALUE slots) - return 1 if the lists contain the same types in the same order. - Also, the TREE_PURPOSEs must match. */ - -int -type_list_equal (l1, l2) - tree l1, l2; -{ - register tree t1, t2; - for (t1 = l1, t2 = l2; t1 && t2; t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2)) - { - if (TREE_VALUE (t1) != TREE_VALUE (t2)) - return 0; - if (TREE_PURPOSE (t1) != TREE_PURPOSE (t2)) - { - int cmp = simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)); - if (cmp < 0) - abort (); - if (cmp == 0) - return 0; - } - } - - return t1 == t2; -} - -/* Nonzero if integer constants T1 and T2 - represent the same constant value. */ - -int -tree_int_cst_equal (t1, t2) - tree t1, t2; -{ - if (t1 == t2) - return 1; - if (t1 == 0 || t2 == 0) - return 0; - if (TREE_CODE (t1) == INTEGER_CST - && TREE_CODE (t2) == INTEGER_CST - && TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2) - && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2)) - return 1; - return 0; -} - -/* Nonzero if integer constants T1 and T2 represent values that satisfy <. - The precise way of comparison depends on their data type. */ - -int -tree_int_cst_lt (t1, t2) - tree t1, t2; -{ - if (t1 == t2) - return 0; - - if (!TREE_UNSIGNED (TREE_TYPE (t1))) - return INT_CST_LT (t1, t2); - return INT_CST_LT_UNSIGNED (t1, t2); -} - -/* Compare two constructor-element-type constants. */ -int -simple_cst_list_equal (l1, l2) - tree l1, l2; -{ - while (l1 != NULL_TREE && l2 != NULL_TREE) - { - int cmp = simple_cst_equal (TREE_VALUE (l1), TREE_VALUE (l2)); - if (cmp < 0) - abort (); - if (cmp == 0) - return 0; - l1 = TREE_CHAIN (l1); - l2 = TREE_CHAIN (l2); - } - return (l1 == l2); -} - -/* Return truthvalue of whether T1 is the same tree structure as T2. - Return 1 if they are the same. - Return 0 if they are understandably different. - Return -1 if either contains tree structure not understood by - this function. */ -int -simple_cst_equal (t1, t2) - tree t1, t2; -{ - register enum tree_code code1, code2; - int cmp; - - if (t1 == t2) - return 1; - if (t1 == 0 || t2 == 0) - return 0; - - code1 = TREE_CODE (t1); - code2 = TREE_CODE (t2); - - if (code1 == NOP_EXPR || code1 == CONVERT_EXPR) - if (code2 == NOP_EXPR || code2 == CONVERT_EXPR) - return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)); - else - return simple_cst_equal (TREE_OPERAND (t1, 0), t2); - else if (code2 == NOP_EXPR || code2 == CONVERT_EXPR) - return simple_cst_equal (t1, TREE_OPERAND (t2, 0)); - - if (code1 != code2) - return 0; - - switch (code1) - { - case INTEGER_CST: - return TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2) - && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2); - - case REAL_CST: - return REAL_VALUES_EQUAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2)); - - case STRING_CST: - return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2) - && !bcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2), - TREE_STRING_LENGTH (t1)); - - case CONSTRUCTOR: - abort (); - - case SAVE_EXPR: - return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)); - - case NEW_EXPR: - return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)); - - case CALL_EXPR: - cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)); - if (cmp <= 0) - return cmp; - return simple_cst_list_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)); - - case COMPONENT_REF: - if (TREE_OPERAND (t1, 1) == TREE_OPERAND (t2, 1)) - return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)); - return 0; - - case VAR_DECL: - case PARM_DECL: - case CONST_DECL: - case FUNCTION_DECL: - return 0; - - case PLUS_EXPR: - case MINUS_EXPR: - case MULT_EXPR: - case TRUNC_DIV_EXPR: - case TRUNC_MOD_EXPR: - case LSHIFT_EXPR: - case RSHIFT_EXPR: - cmp = simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)); - if (cmp <= 0) - return cmp; - return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)); - - case NEGATE_EXPR: - case ADDR_EXPR: - case REFERENCE_EXPR: - case INDIRECT_REF: - return simple_cst_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)); - - default: - return lang_simple_cst_equal (t1, t2); - } -} - -/* Constructors for pointer, array and function types. - (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are - constructed by language-dependent code, not here.) */ - -/* Construct, lay out and return the type of pointers to TO_TYPE. - If such a type has already been constructed, reuse it. */ - -tree -build_pointer_type (to_type) - tree to_type; -{ - register tree t = TYPE_POINTER_TO (to_type); - register struct obstack *ambient_obstack = current_obstack; - register struct obstack *ambient_saveable_obstack = saveable_obstack; - - /* First, if we already have a type for pointers to TO_TYPE, use it. */ - - if (t) - return t; - - /* We need a new one. If TO_TYPE is permanent, make this permanent too. */ - if (TREE_PERMANENT (to_type)) - { - current_obstack = &permanent_obstack; - saveable_obstack = &permanent_obstack; - } - - t = make_node (POINTER_TYPE); - TREE_TYPE (t) = to_type; - - /* Record this type as the pointer to TO_TYPE. */ - TYPE_POINTER_TO (to_type) = t; - - /* Lay out the type. This function has many callers that are concerned - with expression-construction, and this simplifies them all. - Also, it guarantees the TYPE_SIZE is permanent if the type is. */ - layout_type (t); - - current_obstack = ambient_obstack; - saveable_obstack = ambient_saveable_obstack; - return t; -} - -/* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE. - MAXVAL should be the maximum value in the domain - (one less than the length of the array). */ - -tree -build_index_type (maxval) - tree maxval; -{ - register tree itype = make_node (INTEGER_TYPE); - int maxint = TREE_INT_CST_LOW (maxval); - TYPE_PRECISION (itype) = TYPE_PRECISION (sizetype); - TYPE_MIN_VALUE (itype) = build_int_2 (0, 0); - TREE_TYPE (TYPE_MIN_VALUE (itype)) = sizetype; - TYPE_MAX_VALUE (itype) = convert (sizetype, maxval); - TYPE_MODE (itype) = SImode; - TYPE_SIZE (itype) = TYPE_SIZE (sizetype); - TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (sizetype); - TYPE_ALIGN (itype) = TYPE_ALIGN (sizetype); - return type_hash_canon (maxint > 0 ? maxint : - maxint, itype); -} - -/* Construct, lay out and return the type of arrays of elements with ELT_TYPE - and number of elements specified by the range of values of INDEX_TYPE. - If such a type has already been constructed, reuse it. */ - -tree -build_array_type (elt_type, index_type) - tree elt_type, index_type; -{ - register tree t = make_node (ARRAY_TYPE); - int hashcode; - - if (TREE_CODE (elt_type) == FUNCTION_TYPE) - { - error ("arrays of functions are not meaningful"); - elt_type = integer_type_node; - } - - TREE_TYPE (t) = elt_type; - TYPE_DOMAIN (t) = index_type; - - /* Make sure TYPE_POINTER_TO (elt_type) is filled in. */ - build_pointer_type (elt_type); - - if (index_type == 0) - return t; - - hashcode = TYPE_HASH (elt_type) + TYPE_HASH (index_type); - t = type_hash_canon (hashcode, t); - - if (TYPE_SIZE (t) == 0) - layout_type (t); - return t; -} - -/* Construct, lay out and return - the type of functions returning type VALUE_TYPE - given arguments of types ARG_TYPES. - ARG_TYPES is a chain of TREE_LIST nodes whose TREE_VALUEs - are data type nodes for the arguments of the function. - If such a type has already been constructed, reuse it. */ - -tree -build_function_type (value_type, arg_types) - tree value_type, arg_types; -{ - register tree t; - int hashcode; - - if (TREE_CODE (value_type) == FUNCTION_TYPE - || TREE_CODE (value_type) == ARRAY_TYPE) - { - error ("function return type cannot be function or array"); - value_type = integer_type_node; - } - - /* Make a node of the sort we want. */ - t = make_node (FUNCTION_TYPE); - TREE_TYPE (t) = value_type; - TYPE_ARG_TYPES (t) = arg_types; - - /* If we already have such a type, use the old one and free this one. */ - hashcode = TYPE_HASH (value_type) + type_hash_list (arg_types); - t = type_hash_canon (hashcode, t); - - if (TYPE_SIZE (t) == 0) - layout_type (t); - return t; -} - -/* Build the node for the type of references-to-TO_TYPE. */ - -tree -build_reference_type (to_type) - tree to_type; -{ - register tree t = TYPE_REFERENCE_TO (to_type); - register struct obstack *ambient_obstack = current_obstack; - register struct obstack *ambient_saveable_obstack = saveable_obstack; - - /* First, if we already have a type for pointers to TO_TYPE, use it. */ - - if (t) - return t; - - /* We need a new one. If TO_TYPE is permanent, make this permanent too. */ - if (TREE_PERMANENT (to_type)) - { - current_obstack = &permanent_obstack; - saveable_obstack = &permanent_obstack; - } - - t = make_node (REFERENCE_TYPE); - TREE_TYPE (t) = to_type; - - /* Record this type as the pointer to TO_TYPE. */ - TYPE_REFERENCE_TO (to_type) = t; - - layout_type (t); - - current_obstack = ambient_obstack; - saveable_obstack = ambient_saveable_obstack; - return t; -} - -/* Construct, lay out and return the type of methods belonging to class - BASETYPE and whose arguments and values are described by TYPE. - If that type exists already, reuse it. - TYPE must be a FUNCTION_TYPE node. */ - -tree -build_method_type (basetype, type) - tree basetype, type; -{ - register tree t; - int hashcode; - - /* Make a node of the sort we want. */ - t = make_node (METHOD_TYPE); - - if (TREE_CODE (type) != FUNCTION_TYPE) - abort (); - - TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype); - TREE_TYPE (t) = TREE_TYPE (type); - - /* The actual arglist for this function includes a "hidden" argument - which is "this". Put it into the list of argument types. */ - - TYPE_ARG_TYPES (t) - = tree_cons (NULL, build_pointer_type (basetype), TYPE_ARG_TYPES (type)); - - /* If we already have such a type, use the old one and free this one. */ - hashcode = TYPE_HASH (basetype) + TYPE_HASH (type); - t = type_hash_canon (hashcode, t); - - if (TYPE_SIZE (t) == 0) - layout_type (t); - - return t; -} - -/* Construct, lay out and return the type of methods belonging to class - BASETYPE and whose arguments and values are described by TYPE. - If that type exists already, reuse it. - TYPE must be a FUNCTION_TYPE node. */ - -tree -build_offset_type (basetype, type) - tree basetype, type; -{ - register tree t; - int hashcode; - - /* Make a node of the sort we want. */ - t = make_node (OFFSET_TYPE); - - TYPE_OFFSET_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype); - TREE_TYPE (t) = type; - - /* If we already have such a type, use the old one and free this one. */ - hashcode = TYPE_HASH (basetype) + TYPE_HASH (type); - t = type_hash_canon (hashcode, t); - - if (TYPE_SIZE (t) == 0) - layout_type (t); - - return t; -} - -/* Return the innermost context enclosing FNDECL that is - a RECORD_TYPE or UNION_TYPE, or zero if none. - TYPE_DECLs and FUNCTION_DECLs are transparent to this function. */ - -tree -decl_type_context (fndecl) - tree fndecl; -{ - tree context = DECL_CONTEXT (fndecl); - - while (context) - { - if (TREE_CODE (context) == RECORD_TYPE - || TREE_CODE (context) == UNION_TYPE) - return context; - if (TREE_CODE (context) == TYPE_DECL - || TREE_CODE (context) == FUNCTION_DECL) - context = DECL_CONTEXT (context); - else if (TREE_CODE (context) == LET_STMT) - context = STMT_SUPERCONTEXT (context); - else - /* Unhandled CONTEXT!? */ - abort (); - } - return NULL_TREE; -} - -/* Return OP, stripped of any conversions to wider types as much as is safe. - Converting the value back to OP's type makes a value equivalent to OP. - - If FOR_TYPE is nonzero, we return a value which, if converted to - type FOR_TYPE, would be equivalent to converting OP to type FOR_TYPE. - - If FOR_TYPE is nonzero, unaligned bit-field references may be changed to the - narrowest type that can hold the value, even if they don't exactly fit. - Otherwise, bit-field references are changed to a narrower type - only if they can be fetched directly from memory in that type. - - OP must have integer, real or enumeral type. Pointers are not allowed! - - There are some cases where the obvious value we could return - would regenerate to OP if converted to OP's type, - but would not extend like OP to wider types. - If FOR_TYPE indicates such extension is contemplated, we eschew such values. - For example, if OP is (unsigned short)(signed char)-1, - we avoid returning (signed char)-1 if FOR_TYPE is int, - even though extending that to an unsigned short would regenerate OP, - since the result of extending (signed char)-1 to (int) - is different from (int) OP. */ - -tree -get_unwidened (op, for_type) - register tree op; - tree for_type; -{ - /* Set UNS initially if converting OP to FOR_TYPE is a zero-extension. */ - /* TYPE_PRECISION is safe in place of type_precision since - pointer types are not allowed. */ - register tree type = TREE_TYPE (op); - register int final_prec = TYPE_PRECISION (for_type != 0 ? for_type : type); - register int uns - = (for_type != 0 && for_type != type - && final_prec > TYPE_PRECISION (type) - && TREE_UNSIGNED (type)); - register tree win = op; - - while (TREE_CODE (op) == NOP_EXPR) - { - register int bitschange - = TYPE_PRECISION (TREE_TYPE (op)) - - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0))); - - /* Truncations are many-one so cannot be removed. - Unless we are later going to truncate down even farther. */ - if (bitschange < 0 - && final_prec > TYPE_PRECISION (TREE_TYPE (op))) - break; - - /* See what's inside this conversion. If we decide to strip it, - we will set WIN. */ - op = TREE_OPERAND (op, 0); - - /* If we have not stripped any zero-extensions (uns is 0), - we can strip any kind of extension. - If we have previously stripped a zero-extension, - only zero-extensions can safely be stripped. - Any extension can be stripped if the bits it would produce - are all going to be discarded later by truncating to FOR_TYPE. */ - - if (bitschange > 0) - { - if (! uns || final_prec <= TYPE_PRECISION (TREE_TYPE (op))) - win = op; - /* TREE_UNSIGNED says whether this is a zero-extension. - Let's avoid computing it if it does not affect WIN - and if UNS will not be needed again. */ - if ((uns || TREE_CODE (op) == NOP_EXPR) - && TREE_UNSIGNED (TREE_TYPE (op))) - { - uns = 1; - win = op; - } - } - } - - if (TREE_CODE (op) == COMPONENT_REF - /* Since type_for_size always gives an integer type. */ - && TREE_CODE (type) != REAL_TYPE) - { - int innerprec = (TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (op, 1))) - * DECL_SIZE_UNIT (TREE_OPERAND (op, 1))); - type = type_for_size (innerprec, TREE_UNSIGNED (TREE_OPERAND (op, 1))); - - /* We can get this structure field in the narrowest type it fits in. - If FOR_TYPE is 0, do this only for a field that matches the - narrower type exactly and is aligned for it (i.e. mode isn't BI). - The resulting extension to its nominal type (a fullword type) - must fit the same conditions as for other extensions. */ - - if (innerprec < TYPE_PRECISION (TREE_TYPE (op)) - && (for_type || DECL_MODE (TREE_OPERAND (op, 1)) != BImode) - && (! uns || final_prec <= innerprec - || TREE_UNSIGNED (TREE_OPERAND (op, 1))) - && type != 0) - { - win = build (COMPONENT_REF, type, TREE_OPERAND (op, 0), - TREE_OPERAND (op, 1)); - TREE_VOLATILE (win) = TREE_VOLATILE (op); - TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op); - TREE_RAISES (win) = TREE_RAISES (op); - } - } - return win; -} - -/* Return OP or a simpler expression for a narrower value - which can be sign-extended or zero-extended to give back OP. - Store in *UNSIGNEDP_PTR either 1 if the value should be zero-extended - or 0 if the value should be sign-extended. */ - -tree -get_narrower (op, unsignedp_ptr) - register tree op; - int *unsignedp_ptr; -{ - register int uns = 0; - int first = 1; - register tree win = op; - - while (TREE_CODE (op) == NOP_EXPR) - { - register int bitschange - = TYPE_PRECISION (TREE_TYPE (op)) - - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0))); - - /* Truncations are many-one so cannot be removed. */ - if (bitschange < 0) - break; - - /* See what's inside this conversion. If we decide to strip it, - we will set WIN. */ - op = TREE_OPERAND (op, 0); - - if (bitschange > 0) - { - /* An extension: the outermost one can be stripped, - but remember whether it is zero or sign extension. */ - if (first) - uns = TREE_UNSIGNED (TREE_TYPE (op)); - /* Otherwise, if a sign extension has been stripped, - only sign extensions can now be stripped; - if a zero extension has been stripped, only zero-extensions. */ - else if (uns != TREE_UNSIGNED (TREE_TYPE (op))) - break; - first = 0; - } - /* A change in nominal type can always be stripped. */ - - win = op; - } - - if (TREE_CODE (op) == COMPONENT_REF - /* Since type_for_size always gives an integer type. */ - && TREE_CODE (TREE_TYPE (op)) != REAL_TYPE) - { - int innerprec = (TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (op, 1))) - * DECL_SIZE_UNIT (TREE_OPERAND (op, 1))); - tree type = type_for_size (innerprec, TREE_UNSIGNED (op)); - - /* We can get this structure field in a narrower type that fits it, - but the resulting extension to its nominal type (a fullword type) - must satisfy the same conditions as for other extensions. - - Do this only for fields that are aligned (not BImode), - because when bit-field insns will be used there is no - advantage in doing this. */ - - if (innerprec < TYPE_PRECISION (TREE_TYPE (op)) - && DECL_MODE (TREE_OPERAND (op, 1)) != BImode - && (first || uns == TREE_UNSIGNED (TREE_OPERAND (op, 1))) - && type != 0) - { - if (first) - uns = TREE_UNSIGNED (TREE_OPERAND (op, 1)); - win = build (COMPONENT_REF, type, TREE_OPERAND (op, 0), - TREE_OPERAND (op, 1)); - TREE_VOLATILE (win) = TREE_VOLATILE (op); - TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op); - TREE_RAISES (win) = TREE_RAISES (op); - } - } - *unsignedp_ptr = uns; - return win; -} - -/* Return the precision of a type, for arithmetic purposes. - Supports all types on which arithmetic is possible - (including pointer types). - It's not clear yet what will be right for complex types. */ - -int -type_precision (type) - register tree type; -{ - return ((TREE_CODE (type) == INTEGER_TYPE - || TREE_CODE (type) == ENUMERAL_TYPE - || TREE_CODE (type) == REAL_TYPE) - ? TYPE_PRECISION (type) : POINTER_SIZE); -} - -/* Nonzero if integer constant C has a value that is permissible - for type TYPE (an INTEGER_TYPE). */ - -int -int_fits_type_p (c, type) - tree c, type; -{ - if (TREE_UNSIGNED (type)) - return (!INT_CST_LT_UNSIGNED (TYPE_MAX_VALUE (type), c) - && !INT_CST_LT_UNSIGNED (c, TYPE_MIN_VALUE (type))); - else - return (!INT_CST_LT (TYPE_MAX_VALUE (type), c) - && !INT_CST_LT (c, TYPE_MIN_VALUE (type))); -} - -void -print_obstack_statistics (str, o) - char *str; - struct obstack *o; -{ - struct _obstack_chunk *chunk = o->chunk; - int n_chunks = 0; - int n_alloc = 0; - - while (chunk) - { - n_chunks += 1; - n_alloc += chunk->limit - &chunk->contents[0]; - chunk = chunk->prev; - } - fprintf (stderr, "obstack %s: %d bytes, %d chunks\n", - str, n_alloc, n_chunks); -} - -void -dump_tree_statistics () -{ - int i; - int total_nodes, total_bytes; - extern struct obstack class_obstack; - - fprintf (stderr, "\n%d tree nodes created\n\n", tree_node_counter); -#ifdef GATHER_STATISTICS - fprintf (stderr, "Kind Nodes Bytes\n"); - fprintf (stderr, "-------------------------------------\n"); - total_nodes = total_bytes = 0; - for (i = 0; i < (int) all_kinds; i++) - { - fprintf (stderr, "%-20s %6d %9d\n", tree_node_kind_names[i], - tree_node_kinds[i], tree_node_sizes[i]); - total_nodes += tree_node_kinds[i]; - total_bytes += tree_node_sizes[i]; - } - fprintf (stderr, "%-20s %9d\n", "identifier names", id_string_size); - fprintf (stderr, "-------------------------------------\n"); - fprintf (stderr, "%-20s %6d %9d\n", "Total", total_nodes, total_bytes); - fprintf (stderr, "-------------------------------------\n"); -#else - fprintf (stderr, "(No per-node statistics)\n"); -#endif - print_obstack_statistics ("class_obstack", &class_obstack); - print_obstack_statistics ("permanent_obstack", &permanent_obstack); - print_obstack_statistics ("maybepermanent_obstack", &maybepermanent_obstack); - print_search_statistics (); - print_class_statistics (); -} diff --git a/gnu/usr.bin/g++/cc1plus/tree.def b/gnu/usr.bin/g++/cc1plus/tree.def deleted file mode 100644 index 8c8dc16f4f99..000000000000 --- a/gnu/usr.bin/g++/cc1plus/tree.def +++ /dev/null @@ -1,624 +0,0 @@ -/* This file contains the definitions and documentation for the - tree codes used in the GNU C compiler. - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* The third argument can be: - "x" for an exceptional code (fits no category). - "s" for a statement code. - "t" for a type object code. - - "c" for codes for constants. - "d" for codes for declarations (also serving as variable refs). - "r" for codes for references to storage. - "e" for codes for other kinds of expressions. */ - -/* For `r', `e' and `x' nodes, - the 4th element is the number of argument slots to allocate. - This determines the size of the tree node object. */ - -/* Any erroneous construct is parsed into a node of this type. - This type of node is accepted without complaint in all contexts - by later parsing activities, to avoid multiple error messages - for one error. - No fields in these nodes are used except the TREE_CODE. */ -DEFTREECODE (ERROR_MARK, "error_mark", "x", 0) - -/* Used to represent a name (such as, in the DECL_NAME of a decl node). - Internally it looks like a STRING_CST node. - There is only one IDENTIFIER_NODE ever made for any particular name. - Use `get_identifier' to get it (or create it, the first time). */ -DEFTREECODE (IDENTIFIER_NODE, "identifier_node", "x", 2) - -/* Used to hold information to identify an operator (or combination - of two operators) considered as a `noun' rather than a `verb'. - The first operand is encoded in the TREE_TYPE field. */ -DEFTREECODE (OP_IDENTIFIER, "op_identifier", "x", 2) - -/* Has the TREE_VALUE and TREE_PURPOSE fields. */ -/* These nodes are made into lists by chaining through the - TREE_CHAIN field. The elements of the list live in the - TREE_VALUE fields, while TREE_PURPOSE fields are occasionally - used as well to get the effect of Lisp association lists. */ -DEFTREECODE (TREE_LIST, "tree_list", "x", 2) - -/* These nodes contain an array of tree nodes. */ -DEFTREECODE (TREE_VEC, "tree_vec", "x", 2) - -/* Each data type is represented by a tree node whose code is one of - the following: */ -/* Each node that represents a data type has a component TYPE_SIZE - containing a tree that is an expression for the size in some units. - The TYPE_SIZE_UNIT component is the number of bits in a unit. - The TYPE_MODE contains the machine mode for values of this type. - The TYPE_POINTER_TO field contains a type for a pointer to this type, - or zero if no such has been created yet. - The TYPE_NEXT_VARIANT field is used to chain together types - that are variants made by type modifiers such as "const" and "volatile". - The TYPE_MAIN_VARIANT field, in any member of such a chain, - points to the start of the chain. - The TYPE_NONCOPIED_PARTS field is a list specifying which parts - of an object of this type should *not* be copied by assignment. - The TREE_PURPOSE of each element is the offset of the part - and the TREE_VALUE is the size in bits of the part. - The TYPE_NAME field contains info on the name used in the program - for this type (for GDB symbol table output). It is either a - TYPE_DECL node, for types that are typedefs, or an IDENTIFIER_NODE - in the case of structs, unions or enums that are known with a tag, - or zero for types that have no special name. */ -/* The TREE_CHAIN of a ..._TYPE node is normally used to put - every type onto permanent_type_chain or temporary_type_chain (see tree.c). - One exception is for ENUMERAL_TYPE, RECORD_TYPE and UNION_TYPE - nodes used as forward-references to names; see below. */ - -DEFTREECODE (VOID_TYPE, "void_type", "t", 0) /* The void type in C */ - -/* Integer types in all languages, including char in C. */ -/* Has components TYPE_MIN_VALUE, TYPE_MAX_VALUE (expressions, inclusive) - and TYPE_PRECISION (number of bits used by this type). - In the case of a subrange type in Pascal, the TREE_TYPE - of this will point at the supertype (another INTEGER_TYPE). - Otherwise, the TREE_TYPE is zero. */ -DEFTREECODE (INTEGER_TYPE, "integer_type", "t", 0) - -/* C's float and double. Different floating types are distinguished - by machine mode and by the TYPE_SIZE and the TYPE_PRECISION. */ -DEFTREECODE (REAL_TYPE, "real_type", "t", 0) - -/* Complex number types. The TREE_TYPE field is the data type - of the real and imaginary parts. */ -DEFTREECODE (COMPLEX_TYPE, "complex_type", "t", 0) - -/* C enums. The type node looks just like an INTEGER_TYPE node. - The symbols for the values of the enum type are defined by - CONST_DECL nodes, but the type does not point to them; - however, the TREE_VALUES is a list in which each elements' TREE_PURPOSE - is a name and the TREE_VALUE is the value (an INTEGER_CST node). */ -/* A forward reference `enum foo' when no enum named foo is defined yet - has zero (a null pointer) in its TYPE_SIZE. The tag name is in - the TYPE_NAME field. If the type is later defined, the normal - fields are filled in. - RECORD_TYPE and UNION_TYPE forward refs are treated similarly. */ -DEFTREECODE (ENUMERAL_TYPE, "enumeral_type", "t", 0) - -/* Pascal's boolean type (true or false are the only values); - no special fields needed. */ -DEFTREECODE (BOOLEAN_TYPE, "boolean_type", "t", 0) - -/* CHAR in Pascal; not used in C. - No special fields needed. */ -DEFTREECODE (CHAR_TYPE, "char_type", "t", 0) - -/* All pointer-to-x types have code POINTER_TYPE. - The TREE_TYPE points to the node for the type pointed to. */ -DEFTREECODE (POINTER_TYPE, "pointer_type", "t", 0) - -/* An offset is a pointer relative to an object. - The TREE_TYPE field is the type of the object at the offset. - The TYPE_OFFSET_BASETYPE points to the node for the type of object - that the offset is relative to. */ -DEFTREECODE (OFFSET_TYPE, "offset_type", "t", 0) - -/* A reference is like a pointer except that it is coerced - automatically to the value it points to. Used in C++. */ -DEFTREECODE (REFERENCE_TYPE, "reference_type", "t", 0) - -/* METHOD_TYPE is the type of a function which takes an extra first - argument for "self", which is not present in the declared argument list. - The TREE_TYPE is the return type of the method. The TYPE_METHOD_BASETYPE - is the type of "self". TYPE_ARG_TYPES is the real argument list, which - includes the hidden argument for "self". */ -DEFTREECODE (METHOD_TYPE, "method_type", "t", 0) - -/* Used for Pascal; details not determined right now. */ -DEFTREECODE (FILE_TYPE, "file_type", "t", 0) - -/* Types of arrays. Special fields: - TREE_TYPE Type of an array element. - TYPE_DOMAIN Type to index by. - Its range of values specifies the array length. - TYPE_SEP Expression for units from one elt to the next. - TYPE_SEP_UNIT Number of bits in a unit for previous. - The field TYPE_POINTER_TO (TREE_TYPE (array_type)) is always nonzero - and holds the type to coerce a value of that array type to in C. */ -/* Array types in C or Pascal */ -DEFTREECODE (ARRAY_TYPE, "array_type", "t", 0) - -/* Types of sets for Pascal. Special fields are the same as - in an array type. The target type is always a boolean type. */ -DEFTREECODE (SET_TYPE, "set_type", "t", 0) - -/* Not known whether Pascal really needs this - or what it should contain. */ -DEFTREECODE (STRING_TYPE, "string_type", "t", 0) - -/* Struct in C, or record in Pascal. */ -/* Special fields: - TYPE_FIELDS chain of FIELD_DECLs for the fields of the struct. - A few may need to be added for Pascal. */ -/* See the comment above, before ENUMERAL_TYPE, for how - forward references to struct tags are handled in C. */ -DEFTREECODE (RECORD_TYPE, "record_type", "t", 0) - -/* Union in C. Like a struct, except that the offsets of the fields - will all be zero. */ -/* See the comment above, before ENUMERAL_TYPE, for how - forward references to union tags are handled in C. */ -DEFTREECODE (UNION_TYPE, "union_type", "t", 0) /* C union type */ - -/* Type of functions. Special fields: - TREE_TYPE type of value returned. - TYPE_ARG_TYPES list of types of arguments expected. - this list is made of TREE_LIST nodes. - Types of "Procedures" in languages where they are different from functions - have code FUNCTION_TYPE also, but then TREE_TYPE is zero or void type. */ -DEFTREECODE (FUNCTION_TYPE, "function_type", "t", 0) - -/* This is a language-specific kind of type. - Its meaning is defined by the language front end. - layout_type does not know how to lay this out, - so the front-end must do so manually. */ -DEFTREECODE (LANG_TYPE, "lang_type", "t", 0) - -/* All statement types have fields STMT_SOURCE_FILE and STMT_SOURCE_LINE. */ -/* Consecutive statements within a compound statement are chained together - through the TREE_CHAIN field. */ - -/* A label definition, encapsulated as a statement. - STMT_BODY is the LABEL_DECL node for the label that appears here. */ -DEFTREECODE (LABEL_STMT, "label_stmt", "s", 1) - -/* GOTO, in any language. STMT_BODY is a LABEL_DECL node. */ -DEFTREECODE (GOTO_STMT, "goto_stmt", "s", 1) - -/* RETURN, in any language. - Evaluates the expression STMT_BODY, then returns from the current function. - Presumably STMT_BODY is an assignment that stores into the - RESULT_DECL that hold the value to be returned. - STMT_BODY may be zero. */ -DEFTREECODE (RETURN_STMT, "return_stmt", "s", 1) - -/* Statement that evaluates an expression. STMT_BODY is the expression. */ -DEFTREECODE (EXPR_STMT, "expr_stmt", "s", 1) - -/* Pascal WITH statement. - Contains a chain of variables (..._DECL nodes) in the STMT_VARS - and a chain of statements (the STMT_BODY). - STMT_SUPERCONTEXT points to the containing declaration scope. */ -DEFTREECODE (WITH_STMT, "with_stmt", "s", 5) - -/* Declare variables whose scope is less than a function. - This is used for C brace-pairs that contain declarations. - Contains a chain of variables (..._DECL nodes) in the STMT_VARS - and a chain of statements (the STMT_BODY). - STMT_SUPERCONTEXT points to the containing declaration scope. - STMT_BIND_SIZE is an expression for the size of local storage here. - STMT_TYPE_TAGS is a list (chain of TREE_LIST nodes) - pairing struct, union and enum tag names with the types they mean, - for tags defined in this context. - - A LET_STMT can be used as an expression. Its STMT_BODY is expanded - in its stead. Its TREE_USED is set if it is expanded. - - A LET_STMT whose TREE_USED is not set is ignored when symbols - are output. If the LET_STMT is passed to expand_expr but it - should not be ignored, set its TREE_USED by hand. */ -DEFTREECODE (LET_STMT, "let_stmt", "s", 6) - -/* if-then-else statements in C and other languages. - STMT_COND is the condition (an expression). - STMT_THEN is the then-branch (a statement or chain of statements). - STMT_ELSE is the else-branch (a statement or chain of statements). */ -DEFTREECODE (IF_STMT, "if_stmt", "s", 3) - -/* if-else-exit; used in building parts of iterations. - STMT_BODY is the condition (an expression). - Exit if the iteration if the condition is FALSE. */ -DEFTREECODE (EXIT_STMT, "exit_stmt", "s", 1) - -/* STMT_CASE_INDEX is an expression for the value to dispatch on. - STMT_CASE_LIST is a list (a chain of TREE_LIST nodes) - of the branches of the dispatch. - Each such TREE_LIST node has the case it is for (a constant expression) - as the TREE_PURPOSE - and the label to go to (a LABEL_DECL) as the TREE_VALUE. - - Normally, the labels reside inside a COMPOUND_STMT - which contains ths CASE_STMT as its first statement. */ -DEFTREECODE (CASE_STMT, "case_stmt", "s", 3) - -/* STMT_LOOP_VARS are the variables to be used as iterators - in the loop. - STMT_LOOP_COND is the condition to test each time through - the loop. If TREE_READONLY is set, condition is tested - before entering the loop; otherwise it is tested at the bottom. - STMT_LOOP_BODY contains a chain of statements to be executed in loop. */ -DEFTREECODE (LOOP_STMT, "loop_stmt", "s", 3) - -/* Contains as its STMT_BODY a chain of substatements. */ -DEFTREECODE (COMPOUND_STMT, "compound_stmt", "s", 1) - -/* Contains as its STMT_BODY a string of assembly code. */ -DEFTREECODE (ASM_STMT, "asm_stmt", "s", 1) - -/* Expressions */ - -/* First, the constants. */ - -/* Contents are in TREE_INT_CST_LOW and TREE_INT_CST_HIGH fields, - 32 bits each, giving us a 64 bit constant capability. - Note: constants of type char in Pascal are INTEGER_CST, - and so are pointer constants such as nil in Pascal or NULL in C. - `(int *) 1' in C also results in an INTEGER_CST. */ -DEFTREECODE (INTEGER_CST, "integer_cst", "c", 2) - -/* Contents are in TREE_REAL_CST field. Also there is TREE_CST_RTL. */ -DEFTREECODE (REAL_CST, "real_cst", "c", 3) - -/* Contents are in TREE_REALPART and TREE_IMAGPART fields, - whose contents are other constant nodes. - Also there is TREE_CST_RTL. */ -DEFTREECODE (COMPLEX_CST, "complex_cst", "c", 3) - -/* Contents are TREE_STRING_LENGTH and TREE_STRING_POINTER fields. - Also there is TREE_CST_RTL. */ -DEFTREECODE (STRING_CST, "string_cst", "c", 3) - -/* Declarations. All references to names are represented as ..._DECL nodes. - The decls in one binding context are chained through the TREE_CHAIN field. - Each DECL has a DECL_NAME field which contains an IDENTIFIER_NODE. - (Some decls, most often labels, may have zero as the DECL_NAME). - DECL_CONTEXT points to the node representing the context in which - this declaration has its scope. For FIELD_DECLs, this is the - RECORD_TYPE or UNION_TYPE node that the field belongs to; - for VAR_DECL, PARM_DECL, FUNCTION_DECL and LABEL_DECL, this - is the FUNCTION_DECL for the containing function, or 0 if global. - The TREE_TYPE field holds the data type of the object, when relevant. - LABEL_DECLs have no data type. For TYPE_DECL, the TREE_TYPE field - contents are the type whose name is being declared. - The DECL_ALIGN, DECL_SIZE, DECL_SIZE_UNIT - and DECL_MODE fields exist in decl nodes just as in type nodes. - They are unused in LABEL_DECL, TYPE_DECL and CONST_DECL nodes. - - DECL_OFFSET holds an integer number of bits offset for the location. - DECL_VOFFSET holds an expression for a variable offset; it is - to be multiplied by DECL_VOFFSET_UNIT (an integer). - These fields are relevant only in FIELD_DECLs and PARM_DECLs. - - DECL_INITIAL holds the value to initialize a variable to, - or the value of a constant. For a function, it holds the body - (a node of type LET_STMT representing the function's binding contour - and whose body contains the function's statements.) For a LABEL_DECL - in C, it is a flag, nonzero if the label's definition has been seen. - - PARM_DECLs use a special field: - DECL_ARG_TYPE is the type in which the argument is actually - passed, which may be different from its type within the function. - - FUNCTION_DECLs use four special fields: - DECL_ARGUMENTS holds a chain of PARM_DECL nodes for the arguments. - DECL_RESULT holds a RESULT_DECL node for the value of a function, - or it is 0 for a function that returns no value. - (C functions returning void have zero here.) - DECL_RESULT_TYPE holds the type in which the result is actually - returned. This is usually the same as the type of DECL_RESULT, - but (1) it may be a wider integer type and - (2) it remains valid, for the sake of inlining, even after the - function's compilation is done. - DECL_FUNCTION_CODE is a code number that is nonzero for - built-in functions. Its value is an enum built_in_function - that says which built-in function it is. - DECL_BLOCK_SYMTAB_ADDRESS records (after the symtab data for the function's - body has been output) the address in the symtab file of the - `struct block' for the function's top-level binding context. - This must be stored in the symtab structure for the function name. - Also, TREE_UNSIGNED (function_decl) is nonzero if the ({...}) - construct is used in the function. - - DECL_SOURCE_FILE holds a filename string and DECL_SOURCE_LINE - holds a line number. In some cases these can be the location of - a reference, if no definition has been seen. */ - -DEFTREECODE (FUNCTION_DECL, "function_decl", "d", 5) -DEFTREECODE (LABEL_DECL, "label_decl", "d", 0) -DEFTREECODE (CONST_DECL, "const_decl", "d", 0) -DEFTREECODE (TYPE_DECL, "type_decl", "d", 0) -DEFTREECODE (VAR_DECL, "var_decl", "d", 0) -DEFTREECODE (PARM_DECL, "parm_decl", "d", -3) -DEFTREECODE (RESULT_DECL, "result_decl", "d", 0) -DEFTREECODE (FIELD_DECL, "field_decl", "d", 0) - -/* References to storage. */ - -/* Value is structure or union component. - Operand 0 is the structure or union (an expression); - operand 1 is the field (a node of type FIELD_DECL). */ -DEFTREECODE (COMPONENT_REF, "component_ref", "r", 2) - -/* C unary `*' or Pascal `^'. One operand, an expression for a pointer. */ -DEFTREECODE (INDIRECT_REF, "indirect_ref", "r", 1) - -/* Reference to the contents of an offset - (a value whose type is an OFFSET_TYPE). - Operand 0 is the object within which the offset is taken. - Operand 1 is the offset. */ -DEFTREECODE (OFFSET_REF, "offset_ref", "r", 2) - -/* Pascal `^` on a file. One operand, an expression for the file. */ -DEFTREECODE (BUFFER_REF, "buffer_ref", "r", 1) - -/* Array indexing in languages other than C. - Operand 0 is the array; operand 1 is a list of indices - stored as a chain of TREE_LIST nodes. */ -DEFTREECODE (ARRAY_REF, "array_ref", "r", 2) - -/* Constructor: return an aggregate value made from specified components. - In C, this is used only for structure and array initializers. - The first "operand" is really a pointer to the RTL, - for constant constructors only. - The second operand is a list of component values - made out of a chain of TREE_LIST nodes. */ -DEFTREECODE (CONSTRUCTOR, "constructor", "e", 2) - -/* The expression types are mostly straightforward, - with the fourth argument of DEFTREECODE saying - how many operands there are. - Unless otherwise specified, the operands are expressions. */ - -/* Contains two expressions to compute, one followed by the other. - the first value is ignored. The second one's value is used. */ -DEFTREECODE (COMPOUND_EXPR, "compound_expr", "e", 2) - -/* Assignment expression. Operand 0 is the what to set; 1, the new value. */ -DEFTREECODE (MODIFY_EXPR, "modify_expr", "e", 2) - -/* Initialization expression. Operand 0 is the variable to initialize; - Operand 1 is the initializer. */ -DEFTREECODE (INIT_EXPR, "init_expr", "e", 2) - -/* For NEW_EXPR, operand 0 is function which performs initialization, - operand 1 is argument list to initialization function, - and operand 2 is the cleanup for this node, if any. */ -DEFTREECODE (NEW_EXPR, "new_expr", "e", 3) - -/* Conditional expression ( ... ? ... : ... in C). - Operand 0 is the condition. - Operand 1 is the then-value. - Operand 2 is the else-value. */ -DEFTREECODE (COND_EXPR, "cond_expr", "e", 3) - -/* Function call. Operand 0 is the function. - Operand 1 is the argument list, a list of expressions - made out of a chain of TREE_LIST nodes. - There is no operand 2. That slot is used for the - CALL_EXPR_RTL macro (see preexpand_calls). */ -DEFTREECODE (CALL_EXPR, "call_expr", "e", 3) - -/* Call a method. Operand 0 is the method, whose type is a METHOD_TYPE. - Operand 1 is the expression for "self". - Operand 2 is the list of explicit arguments. */ -DEFTREECODE (METHOD_CALL_EXPR, "method_call_expr", "e", 4) - -/* Specify a value to compute along with its corresponding cleanup. - Operand 0 argument is an expression whose value needs a cleanup. - Operand 1 is an RTL_EXPR which will eventually represent that value. - Operand 2 is the cleanup expression for the object. - The RTL_EXPR is used in this expression, which is how the expression - manages to act on the proper value. - The cleanup is executed when the value is no longer needed, - which is not at precisely the same time that this value is computed. */ -DEFTREECODE (WITH_CLEANUP_EXPR, "with_cleanup_expr", "e", 3) - -/* Simple arithmetic. Operands must have the same machine mode - and the value shares that mode. */ -DEFTREECODE (PLUS_EXPR, "plus_expr", "e", 2) -DEFTREECODE (MINUS_EXPR, "minus_expr", "e", 2) -DEFTREECODE (MULT_EXPR, "mult_expr", "e", 2) - -/* Division for integer result that rounds the quotient toward zero. */ -/* Operands must have the same machine mode. - In principle they may be real, but that is not currently supported. - The result is always fixed point, and it has the same type as the - operands if they are fixed point. */ -DEFTREECODE (TRUNC_DIV_EXPR, "trunc_div_expr", "e", 2) - -/* Division for integer result that rounds the quotient toward infinity. */ -DEFTREECODE (CEIL_DIV_EXPR, "ceil_div_expr", "e", 2) - -/* Division for integer result that rounds toward minus infinity. */ -DEFTREECODE (FLOOR_DIV_EXPR, "floor_div_expr", "e", 2) - -/* Division for integer result that rounds toward nearest integer. */ -DEFTREECODE (ROUND_DIV_EXPR, "round_div_expr", "e", 2) - -/* Four kinds of remainder that go with the four kinds of division. */ -DEFTREECODE (TRUNC_MOD_EXPR, "trunc_mod_expr", "e", 2) -DEFTREECODE (CEIL_MOD_EXPR, "ceil_mod_expr", "e", 2) -DEFTREECODE (FLOOR_MOD_EXPR, "floor_mod_expr", "e", 2) -DEFTREECODE (ROUND_MOD_EXPR, "round_mod_expr", "e", 2) - -/* Division for real result. The two operands must have the same type. - In principle they could be integers, but currently only real - operands are supported. The result must have the same type - as the operands. */ -DEFTREECODE (RDIV_EXPR, "rdiv_expr", "e", 2) - -/* Division which is not supposed to need rounding. - Used for pointer subtraction in C. */ -DEFTREECODE (EXACT_DIV_EXPR, "exact_div_expr", "e", 2) - -/* Conversion of real to fixed point: four ways to round, - like the four ways to divide. - CONVERT_EXPR can also be used to convert a real to an integer, - and that is what is used in languages that do not have ways of - specifying which of these is wanted. Maybe these are not needed. */ -DEFTREECODE (FIX_TRUNC_EXPR, "fix_trunc_expr", "e", 1) -DEFTREECODE (FIX_CEIL_EXPR, "fix_ceil_expr", "e", 1) -DEFTREECODE (FIX_FLOOR_EXPR, "fix_floor_expr", "e", 1) -DEFTREECODE (FIX_ROUND_EXPR, "fix_round_expr", "e", 1) - -/* Conversion of an integer to a real. */ -DEFTREECODE (FLOAT_EXPR, "float_expr", "e", 1) - -/* Exponentiation. Operands may have any types; - constraints on value type are not known yet. */ -DEFTREECODE (EXPON_EXPR, "expon_expr", "e", 2) - -/* Unary negation. Value has same type as operand. */ -DEFTREECODE (NEGATE_EXPR, "negate_expr", "e", 1) - -DEFTREECODE (MIN_EXPR, "min_expr", "e", 2) -DEFTREECODE (MAX_EXPR, "max_expr", "e", 2) -DEFTREECODE (ABS_EXPR, "abs_expr", "e", 1) -DEFTREECODE (FFS_EXPR, "ffs_expr", "e", 1) - -/* Shift operations for shift and rotate. - Shift is supposed to mean logical shift if done on an - unsigned type, arithmetic shift on a signed type. - The second operand is the number of bits to - shift by, and must always have mode SImode. - The result has the same mode as the first operand. */ -DEFTREECODE (LSHIFT_EXPR, "alshift_expr", "e", 2) -DEFTREECODE (RSHIFT_EXPR, "arshift_expr", "e", 2) -DEFTREECODE (LROTATE_EXPR, "lrotate_expr", "e", 2) -DEFTREECODE (RROTATE_EXPR, "rrotate_expr", "e", 2) - -/* Bitwise operations. Operands have same mode as result. */ -DEFTREECODE (BIT_IOR_EXPR, "bit_ior_expr", "e", 2) -DEFTREECODE (BIT_XOR_EXPR, "bit_xor_expr", "e", 2) -DEFTREECODE (BIT_AND_EXPR, "bit_and_expr", "e", 2) -DEFTREECODE (BIT_ANDTC_EXPR, "bit_andtc_expr", "e", 2) -DEFTREECODE (BIT_NOT_EXPR, "bit_not_expr", "e", 1) - -/* Combination of boolean values or of integers considered only - as zero or nonzero. ANDIF and ORIF allow the second operand - not to be computed if the value of the expression is determined - from the first operand. AND and OR always compute the second - operand whether its value is needed or not (for side effects). */ -DEFTREECODE (TRUTH_ANDIF_EXPR, "truth_andif_expr", "e", 2) -DEFTREECODE (TRUTH_ORIF_EXPR, "truth_orif_expr", "e", 2) -DEFTREECODE (TRUTH_AND_EXPR, "truth_and_expr", "e", 2) -DEFTREECODE (TRUTH_OR_EXPR, "truth_or_expr", "e", 2) -DEFTREECODE (TRUTH_NOT_EXPR, "truth_not_expr", "e", 1) - -/* Relational operators. - `EQ_EXPR' and `NE_EXPR' are allowed for any types. - The others are allowed only for integer (or pointer or enumeral) - or real types. - In all cases the operands will have the same type, - and the value is always the type used by the language for booleans. */ -DEFTREECODE (LT_EXPR, "lt_expr", "e", 2) -DEFTREECODE (LE_EXPR, "le_expr", "e", 2) -DEFTREECODE (GT_EXPR, "gt_expr", "e", 2) -DEFTREECODE (GE_EXPR, "ge_expr", "e", 2) -DEFTREECODE (EQ_EXPR, "eq_expr", "e", 2) -DEFTREECODE (NE_EXPR, "ne_expr", "e", 2) - -/* Operations for Pascal sets. Not used now. */ -DEFTREECODE (IN_EXPR, "in_expr", "e", 2) -DEFTREECODE (SET_LE_EXPR, "set_le_expr", "e", 2) -DEFTREECODE (CARD_EXPR, "card_expr", "e", 1) -DEFTREECODE (RANGE_EXPR, "range_expr", "e", 2) - -/* Represents a conversion of type of a value. - All conversions, including implicit ones, must be - represented by CONVERT_EXPR nodes. */ -DEFTREECODE (CONVERT_EXPR, "convert_expr", "e", 1) - -/* Represents a conversion expected to require no code to be generated. */ -DEFTREECODE (NOP_EXPR, "nop_expr", "e", 1) - -/* Represents something we computed once and will use multiple times. - First operand is that expression. Second is the RTL, - nonzero only after the expression has been computed. - TREE_UNSIGNED in a SAVE_EXPR is nonzero if that SAVE_EXPR - has been seen already in assign_vars_1. */ -DEFTREECODE (SAVE_EXPR, "save_expr", "e", 2) - -/* Represents something whose RTL has already been expanded - as a sequence which should be emitted when this expression is expanded. - The first operand is the RTL to emit. It is the first of a chain of insns. - The second is the RTL expression for the result. */ -DEFTREECODE (RTL_EXPR, "rtl_expr", "e", 2) - -/* & in C. Value is the address at which the operand's value resides. - Operand may have any mode. Result mode is Pmode. */ -DEFTREECODE (ADDR_EXPR, "addr_expr", "e", 1) - -/* Non-lvalue reference or pointer to an object. */ -DEFTREECODE (REFERENCE_EXPR, "reference_expr", "e", 1) - -/* A wrapper in C++. Operand 0 is the type that the wrapper - belongs to (if non-virtual). Operand 1 is the function - being wrapped. An anti-wrapper means do not wrap the function - (if it would be wrapped by default). */ -DEFTREECODE (WRAPPER_EXPR, "wrapper_expr", "e", 2) -DEFTREECODE (ANTI_WRAPPER_EXPR, "anti_wrapper_expr", "e", 2) - -/* Operand is a function constant; result is a function variable value - of typeEPmode. Used only for languages that need static chains. */ -DEFTREECODE (ENTRY_VALUE_EXPR, "entry_value_expr", "e", 1) - -/* Given two real or integer operands of the same type, - returns a complex value of the corresponding complex type. */ -DEFTREECODE (COMPLEX_EXPR, "complex_expr", "e", 2) - -/* Complex conjugate of operand. Used only on complex types. - The value has the same type as the operand. */ -DEFTREECODE (CONJ_EXPR, "conj_expr", "e", 1) - -/* Used only on an operand of complex type, these return - a value of the corresponding component type. */ -DEFTREECODE (REALPART_EXPR, "realpart_expr", "e", 1) -DEFTREECODE (IMAGPART_EXPR, "imagpart_expr", "e", 1) - -/* Nodes for ++ and -- in C. - The second arg is how much to increment or decrement by. - For a pointer, it would be the size of the object pointed to. */ -DEFTREECODE (PREDECREMENT_EXPR, "predecrement_expr", "e", 2) -DEFTREECODE (PREINCREMENT_EXPR, "preincrement_expr", "e", 2) -DEFTREECODE (POSTDECREMENT_EXPR, "postdecrement_expr", "e", 2) -DEFTREECODE (POSTINCREMENT_EXPR, "postincrement_expr", "e", 2) - -/* -Local variables: -mode:c -version-control: t -End: -*/ diff --git a/gnu/usr.bin/g++/cc1plus/tree.h b/gnu/usr.bin/g++/cc1plus/tree.h deleted file mode 100644 index 5b19ebc9b6f0..000000000000 --- a/gnu/usr.bin/g++/cc1plus/tree.h +++ /dev/null @@ -1,979 +0,0 @@ -/* Front-end tree definitions for GNU compiler. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* codes of tree nodes */ - -#define DEFTREECODE(SYM, STRING, TYPE, NARGS) SYM, - -enum tree_code { -#include "tree.def" - - LAST_AND_UNUSED_TREE_CODE /* A convienent way to get a value for - NUM_TREE_CODE. */ -}; - -#undef DEFTREECODE - -/* Number of tree codes. */ -#define NUM_TREE_CODES ((int)LAST_AND_UNUSED_TREE_CODE) - -/* Indexed by enum tree_code, contains a character which is - `e' for an expression, `r' for a reference, `c' for a constant, - `d' for a decl, `t' for a type, `s' for a statement, - and `x' for anything else (TREE_LIST, IDENTIFIER, etc). */ - -extern char **tree_code_type; - -/* Number of argument-words in each kind of tree-node. */ - -extern int *tree_code_length; - -/* Names of tree components. */ - -extern char **tree_code_name; - -/* Get the definition of `enum machine_mode' */ - -#ifndef HAVE_MACHINE_MODES -#define DEF_MACHMODE(SYM, NAME, TYPE, SIZE, UNIT, WIDER) SYM, - -enum machine_mode { -#include "machmode.def" -MAX_MACHINE_MODE }; - -#undef DEF_MACHMODE - -#define HAVE_MACHINE_MODES - -#endif /* not HAVE_MACHINE_MODES */ - -#ifndef NUM_MACHINE_MODES -#define NUM_MACHINE_MODES (int) MAX_MACHINE_MODE -#endif - -/* Codes that identify the various built in functions - so that expand_call can identify them quickly. */ - -enum built_in_function -{ - NOT_BUILT_IN, - BUILT_IN_ALLOCA, - BUILT_IN_ABS, - BUILT_IN_FABS, - BUILT_IN_LABS, - BUILT_IN_FFS, - BUILT_IN_DIV, - BUILT_IN_LDIV, - BUILT_IN_FFLOOR, - BUILT_IN_FCEIL, - BUILT_IN_FMOD, - BUILT_IN_FREM, - BUILT_IN_MEMCPY, - BUILT_IN_MEMCMP, - BUILT_IN_MEMSET, - BUILT_IN_FSQRT, - BUILT_IN_GETEXP, - BUILT_IN_GETMAN, - BUILT_IN_SAVEREGS, - BUILT_IN_CLASSIFY_TYPE, - - /* C++ extensions */ - BUILT_IN_NEW, - BUILT_IN_VEC_NEW, - BUILT_IN_DELETE, - BUILT_IN_VEC_DELETE, -}; - -/* The definition of tree nodes fills the next several pages. */ - -/* A tree node can represent a data type, a variable, an expression - or a statement. Each node has a TREE_CODE which says what kind of - thing it represents. Some common codes are: - INTEGER_TYPE -- represents a type of integers. - ARRAY_TYPE -- represents a type of pointer. - VAR_DECL -- represents a declared variable. - INTEGER_CST -- represents a constant integer value. - PLUS_EXPR -- represents a sum (an expression). - - As for the contents of a tree node: there are some fields - that all nodes share. Each TREE_CODE has various special-purpose - fields as well. The fields of a node are never accessed directly, - always through accessor macros. */ - -/* This type is used everywhere to refer to a tree node. */ - -typedef union tree_node *tree; - -#define NULL_TREE (tree) NULL - -/* Every kind of tree node starts with this structure, - so all nodes have these fields. - - See the accessor macros, defined below, for documentation of the fields. */ - -struct tree_common -{ - int uid; - union tree_node *chain; - union tree_node *type; - unsigned char code : 8; - - unsigned external_attr : 1; - unsigned public_attr : 1; - unsigned static_attr : 1; - unsigned volatile_attr : 1; - unsigned packed_attr : 1; - unsigned readonly_attr : 1; - unsigned literal_attr : 1; - unsigned nonlocal_attr : 1; - unsigned permanent_attr : 1; - unsigned addressable_attr : 1; - unsigned regdecl_attr : 1; - unsigned this_vol_attr : 1; - unsigned unsigned_attr : 1; - unsigned asm_written_attr: 1; - unsigned inline_attr : 1; - unsigned used_attr : 1; - unsigned lang_flag_1 : 1; - unsigned lang_flag_2 : 1; - unsigned lang_flag_3 : 1; - unsigned lang_flag_4 : 1; - unsigned raises_attr : 1; - /* There is room for three more attributes. */ -}; - -/* Define accessors for the fields that all tree nodes have - (though some fields are not used for all kinds of nodes). */ - -/* The unique id of a tree node distinguishes it from all other nodes - in the same compiler run. */ -#define TREE_UID(NODE) ((NODE)->common.uid) - -/* The tree-code says what kind of node it is. - Codes are defined in tree.def. */ -#define TREE_CODE(NODE) ((enum tree_code) (NODE)->common.code) -#define TREE_SET_CODE(NODE, VALUE) ((NODE)->common.code = (int) (VALUE)) - -/* In all nodes that are expressions, this is the data type of the expression. - In POINTER_TYPE nodes, this is the type that the pointer points to. - In ARRAY_TYPE nodes, this is the type of the elements. */ -#define TREE_TYPE(NODE) ((NODE)->common.type) - -/* Nodes are chained together for many purposes. - Types are chained together to record them for being output to the debugger - (see the function `chain_type'). - Decls in the same scope are chained together to record the contents - of the scope. - Statement nodes for successive statements used to be chained together. - Often lists of things are represented by TREE_LIST nodes that - are chained together. */ - -#define TREE_CHAIN(NODE) ((NODE)->common.chain) - -/* Define many boolean fields that all tree nodes have. */ - -/* In a VAR_DECL or FUNCTION_DECL, - nonzero means external reference: - do not allocate storage, and refer to a definition elsewhere. */ -#define TREE_EXTERNAL(NODE) ((NODE)->common.external_attr) - -/* In a VAR_DECL, nonzero means allocate static storage. - In a FUNCTION_DECL, currently nonzero if function has been defined. */ -#define TREE_STATIC(NODE) ((NODE)->common.static_attr) - -/* In a VAR_DECL or FUNCTION_DECL, - nonzero means name is to be accessible from outside this module. */ -#define TREE_PUBLIC(NODE) ((NODE)->common.public_attr) - -/* In VAR_DECL nodes, nonzero means address of this is needed. - So it cannot be in a register. - In a FUNCTION_DECL, nonzero means its address is needed. - So it must be compiled even if it is an inline function. - In CONSTRUCTOR nodes, it means the elements are all constants suitable - for output as assembly-language initializers. - In LABEL_DECL nodes, it means a goto for this label has been seen - from a place outside all binding contours that restore stack levels, - or that an error message about jumping into such a binding contour - has been printed for this label. - In ..._TYPE nodes, it means that objects of this type must - be fully addressable. This means that pieces of this - object cannot go into register parameters, for example. */ -#define TREE_ADDRESSABLE(NODE) ((NODE)->common.addressable_attr) - -/* In VAR_DECL nodes, nonzero means declared `register'. */ -#define TREE_REGDECL(NODE) ((NODE)->common.regdecl_attr) - -/* In any expression, nonzero means it has side effects or reevaluation - of the whole expression could produce a different value. - This is set if any subexpression is a function call, a side effect - or a reference to a volatile variable. - In a ..._DECL, this is set only if the declaration said `volatile'. - In a ..._TYPE, nonzero means the type is volatile-qualified. */ -#define TREE_VOLATILE(NODE) ((NODE)->common.volatile_attr) - -/* Nonzero means this expression is volatile in the C sense: - its address should be of type `volatile WHATEVER *'. - If this bit is set, so is `volatile_attr'. */ -#define TREE_THIS_VOLATILE(NODE) ((NODE)->common.this_vol_attr) - -/* In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node, - nonzero means it may not be the lhs of an assignment. - In a ..._TYPE node, means this type is const-qualified. */ -#define TREE_READONLY(NODE) ((NODE)->common.readonly_attr) - -/* Nonzero in a FIELD_DECL means it is a bit-field; it may occupy - less than a storage unit, and its address may not be taken, etc. - This controls layout of the containing record. - In a LABEL_DECL, nonzero means label was defined inside a binding - contour that restored a stack level and which is now exited. */ -#define TREE_PACKED(NODE) ((NODE)->common.packed_attr) - -/* Value of expression is constant. - Always appears in all ..._CST nodes. - May also appear in an arithmetic expression, an ADDR_EXPR or a CONSTRUCTOR - if the value is constant. */ -#define TREE_LITERAL(NODE) ((NODE)->common.literal_attr) - -/* Nonzero in a ..._DECL means this variable is ref'd from a nested function. - For VAR_DECL nodes, PARM_DECL nodes, and FUNCTION_DECL nodes. - - For LABEL_DECL nodes, nonzero if nonlocal gotos to the label are permitted. - - Also set in some languages for variables, etc., outside the normal - lexical scope, such as class instance variables. */ -#define TREE_NONLOCAL(NODE) ((NODE)->common.nonlocal_attr) - -/* Nonzero means permanent node; - node will continue to exist for the entire compiler run. - Otherwise it will be recycled at the end of the function. */ -#define TREE_PERMANENT(NODE) ((NODE)->common.permanent_attr) - -/* In INTEGER_TYPE or ENUMERAL_TYPE nodes, means an unsigned type. - In FIELD_DECL nodes, means an unsigned bit field. */ -#define TREE_UNSIGNED(NODE) ((NODE)->common.unsigned_attr) - -/* Nonzero in a VAR_DECL means assembler code has been written. - Nonzero in a FUNCTION_DECL means that the function has been compiled. - This is interesting in an inline function, since it might not need - to be compiled separately. */ -#define TREE_ASM_WRITTEN(NODE) ((NODE)->common.asm_written_attr) - -/* Nonzero in a FUNCTION_DECL means this function can be substituted - where it is called. - Nonzero in a VAR_DECL or PARM_DECL means this decl was made by inlining; - suppress any warnings about shadowing some other variable. */ -#define TREE_INLINE(NODE) ((NODE)->common.inline_attr) - -/* Nonzero in a _DECL if the name is used in its scope. */ -#define TREE_USED(NODE) ((NODE)->common.used_attr) - -#define TREE_LANG_FLAG_1(NODE) ((NODE)->common.lang_flag_1) -#define TREE_LANG_FLAG_2(NODE) ((NODE)->common.lang_flag_2) -#define TREE_LANG_FLAG_3(NODE) ((NODE)->common.lang_flag_3) -#define TREE_LANG_FLAG_4(NODE) ((NODE)->common.lang_flag_4) - -/* Nonzero for an expression that might raise an exception. */ -#define TREE_RAISES(NODE) ((NODE)->common.raises_attr) - -/* Define additional fields and accessors for nodes representing constants. */ - -/* In an INTEGER_CST node. These two together make a 64 bit integer. - If the data type is signed, the value is sign-extended to 64 bits - even though not all of them may really be in use. - In an unsigned constant shorter than 64 bits, the extra bits are 0. */ -#define TREE_INT_CST_LOW(NODE) ((NODE)->int_cst.int_cst_low) -#define TREE_INT_CST_HIGH(NODE) ((NODE)->int_cst.int_cst_high) - -#define INT_CST_LT(A, B) \ -(TREE_INT_CST_HIGH (A) < TREE_INT_CST_HIGH (B) \ - || (TREE_INT_CST_HIGH (A) == TREE_INT_CST_HIGH (B) \ - && ((unsigned) TREE_INT_CST_LOW (A) < (unsigned) TREE_INT_CST_LOW (B)))) - -#define INT_CST_LT_UNSIGNED(A, B) \ -((unsigned) TREE_INT_CST_HIGH (A) < (unsigned) TREE_INT_CST_HIGH (B) \ - || ((unsigned) TREE_INT_CST_HIGH (A) == (unsigned) TREE_INT_CST_HIGH (B) \ - && ((unsigned) TREE_INT_CST_LOW (A) < (unsigned) TREE_INT_CST_LOW (B)))) - -struct tree_int_cst -{ - char common[sizeof (struct tree_common)]; - long int_cst_low; - long int_cst_high; -}; - -/* In REAL_CST, STRING_CST, COMPLEX_CST nodes, and CONSTRUCTOR nodes, - and generally in all kinds of constants that could - be given labels (rather than being immediate). */ - -#define TREE_CST_RTL(NODE) ((NODE)->real_cst.rtl) - -/* In a REAL_CST node. */ -/* We can represent a real value as either a `double' or a string. - Strings don't allow for any optimization, but they do allow - for cross-compilation. */ - -#define TREE_REAL_CST(NODE) ((NODE)->real_cst.real_cst) - -#include "real.h" - -struct tree_real_cst -{ - char common[sizeof (struct tree_common)]; - struct rtx_def *rtl; /* acts as link to register transfer language - (rtl) info */ - REAL_VALUE_TYPE real_cst; -}; - -/* In a STRING_CST */ -#define TREE_STRING_LENGTH(NODE) ((NODE)->string.length) -#define TREE_STRING_POINTER(NODE) ((NODE)->string.pointer) - -struct tree_string -{ - char common[sizeof (struct tree_common)]; - struct rtx_def *rtl; /* acts as link to register transfer language - (rtl) info */ - int length; - char *pointer; -}; - -/* In a COMPLEX_CST node. */ -#define TREE_REALPART(NODE) ((NODE)->complex.real) -#define TREE_IMAGPART(NODE) ((NODE)->complex.imag) - -struct tree_complex -{ - char common[sizeof (struct tree_common)]; - struct rtx_def *rtl; /* acts as link to register transfer language - (rtl) info */ - union tree_node *real; - union tree_node *imag; -}; - -/* Define fields and accessors for some special-purpose tree nodes. */ - -#define IDENTIFIER_LENGTH(NODE) ((NODE)->identifier.length) -#define IDENTIFIER_POINTER(NODE) ((NODE)->identifier.pointer) - -struct tree_identifier -{ - char common[sizeof (struct tree_common)]; - int length; - char *pointer; -}; - -/* In a TREE_LIST node. */ -#define TREE_PURPOSE(NODE) ((NODE)->list.purpose) -#define TREE_VALUE(NODE) ((NODE)->list.value) - -struct tree_list -{ - char common[sizeof (struct tree_common)]; - union tree_node *purpose; - union tree_node *value; -}; - -/* In a TREE_VEC node. */ -#define TREE_VEC_LENGTH(NODE) ((NODE)->vec.length) -#define TREE_VEC_ELT(NODE,I) ((NODE)->vec.a[I]) -#define TREE_VEC_END(NODE) (&((NODE)->vec.a[(NODE)->vec.length])) - -struct tree_vec -{ - char common[sizeof (struct tree_common)]; - int length; - union tree_node *a[1]; -}; - -/* Define fields and accessors for some nodes that represent expressions. */ - -/* In a SAVE_EXPR node. */ -#define SAVE_EXPR_RTL(NODE) (*(struct rtx_def **) &(NODE)->exp.operands[1]) - -/* In a RTL_EXPR node. */ -#define RTL_EXPR_SEQUENCE(NODE) (*(struct rtx_def **) &(NODE)->exp.operands[0]) -#define RTL_EXPR_RTL(NODE) (*(struct rtx_def **) &(NODE)->exp.operands[1]) - -/* In a CALL_EXPR node. */ -#define CALL_EXPR_RTL(NODE) (*(struct rtx_def **) &(NODE)->exp.operands[2]) - -/* In a CONSTRUCTOR node. */ -#define CONSTRUCTOR_ELTS(NODE) TREE_OPERAND (NODE, 1) - -/* In expression and reference nodes. */ -#define TREE_OPERAND(NODE, I) ((NODE)->exp.operands[I]) -#define TREE_COMPLEXITY(NODE, I) ((NODE)->exp.complexity) - -struct tree_exp -{ - char common[sizeof (struct tree_common)]; - int complexity; - union tree_node *operands[1]; -}; - -/* Define fields and accessors for nodes representing data types. */ - -/* See tree.def for documentation of the use of these fields. - Look at the documentation of the various ..._TYPE tree codes. */ - -#define TYPE_SIZE(NODE) ((NODE)->type.size) -#define TYPE_SIZE_UNIT(NODE) ((NODE)->type.size_unit) -#define TYPE_MODE(NODE) ((NODE)->type.mode) -#define TYPE_ALIGN(NODE) ((NODE)->type.align) -#define TYPE_VALUES(NODE) ((NODE)->type.values) -#define TYPE_DOMAIN(NODE) ((NODE)->type.values) -#define TYPE_FIELDS(NODE) ((NODE)->type.values) -#define TYPE_ARG_TYPES(NODE) ((NODE)->type.values) -#define TYPE_METHOD_BASETYPE(NODE) ((NODE)->type.max) -#define TYPE_OFFSET_BASETYPE(NODE) ((NODE)->type.max) -#define TYPE_SEP(NODE) ((NODE)->type.sep) -#define TYPE_SEP_UNIT(NODE) ((NODE)->type.sep_unit) -#define TYPE_POINTER_TO(NODE) ((NODE)->type.pointer_to) -#define TYPE_REFERENCE_TO(NODE) ((NODE)->type.reference_to) -#define TYPE_MIN_VALUE(NODE) ((NODE)->type.sep) -#define TYPE_MAX_VALUE(NODE) ((NODE)->type.max) -#define TYPE_PRECISION(NODE) ((NODE)->type.sep_unit) -#define TYPE_SYMTAB_ADDRESS(NODE) ((NODE)->type.symtab_address) -#define TYPE_NAME(NODE) ((NODE)->type.name) -#define TYPE_NEXT_VARIANT(NODE) ((NODE)->type.next_variant) -#define TYPE_MAIN_VARIANT(NODE) ((NODE)->type.main_variant) -#define TYPE_BASETYPES(NODE) ((NODE)->type.basetypes) -#define TYPE_NONCOPIED_PARTS(NODE) ((NODE)->type.noncopied_parts) -#define TYPE_LANG_SPECIFIC(NODE) ((NODE)->type.lang_specific) - -struct tree_type -{ - char common[sizeof (struct tree_common)]; - union tree_node *values; - union tree_node *sep; - union tree_node *size; - - enum machine_mode mode : 8; - unsigned char size_unit; - unsigned char align; - unsigned char sep_unit; - - union tree_node *pointer_to; - union tree_node *reference_to; - int symtab_address; - union tree_node *name; - union tree_node *max; - union tree_node *next_variant; - union tree_node *main_variant; - union tree_node *basetypes; - union tree_node *noncopied_parts; - /* Points to a structure whose details depend on the language in use. */ - struct lang_type *lang_specific; -}; - -/* Define fields and accessors for nodes representing declared names. */ - -#define DECL_VOFFSET(NODE) ((NODE)->decl.voffset) /* In FIELD_DECLs and maybe PARM_DECLs. */ -#define DECL_RESULT_TYPE(NODE) ((NODE)->decl.voffset) /* In FUNCTION_DECLs. */ -#define DECL_VOFFSET_UNIT(NODE) ((NODE)->decl.voffset_unit) -#define DECL_OFFSET(NODE) ((NODE)->decl.offset) -#define DECL_FUNCTION_CODE(NODE) ((enum built_in_function) (NODE)->decl.offset) -#define DECL_SET_FUNCTION_CODE(NODE,VAL) ((NODE)->decl.offset = (int) (VAL)) -#define DECL_NAME(NODE) ((NODE)->decl.name) -#define DECL_CONTEXT(NODE) ((NODE)->decl.context) -#define DECL_FIELD_CONTEXT(NODE) ((NODE)->decl.context) -#define DECL_ARGUMENTS(NODE) ((NODE)->decl.arguments) /* In FUNCTION_DECL. */ -#define DECL_ARG_TYPE(NODE) ((NODE)->decl.initial) /* In PARM_DECL. */ -#define DECL_INITIAL(NODE) ((NODE)->decl.initial) -#define DECL_SOURCE_FILE(NODE) ((NODE)->decl.filename) -#define DECL_SOURCE_LINE(NODE) ((NODE)->decl.linenum) -#define DECL_SIZE(NODE) ((NODE)->decl.size) -#define DECL_SIZE_UNIT(NODE) ((NODE)->decl.size_unit) -#define DECL_ALIGN(NODE) ((NODE)->decl.align) -#define DECL_MODE(NODE) ((NODE)->decl.mode) -#define DECL_RTL(NODE) ((NODE)->decl.rtl) -#define DECL_ASSEMBLER_NAME(NODE) ((NODE)->decl.assembler_name) -#define DECL_LANG_SPECIFIC(NODE) ((NODE)->decl.lang_specific) - -struct tree_decl -{ - char common[sizeof (struct tree_common)]; - union tree_node *size; - enum machine_mode mode : 8; - unsigned char size_unit; - unsigned char align; - unsigned char voffset_unit; - union tree_node *name; - union tree_node *context; - int offset; - union tree_node *voffset; - union tree_node *initial; - union tree_node *arguments; - struct rtx_def *rtl; /* acts as link to register transfer language - (rtl) info */ - /* Points to a structure whose details depend on the language in use. */ - struct lang_decl *lang_specific; - - /* Unused by PARM_DECL. */ - char *filename; - int linenum; - char *assembler_name; -}; - -#define DECL_PRINT_NAME(NODE) ((NODE)->function_decl.print_name) -#define DECL_RESULT(NODE) ((NODE)->function_decl.result) -#define DECL_BLOCK_SYMTAB_ADDRESS(NODE) ((NODE)->function_decl.block_symtab_address) -#define DECL_SAVED_INSNS(NODE) ((NODE)->function_decl.saved_insns) -#define DECL_FRAME_SIZE(NODE) ((NODE)->function_decl.frame_size) - -struct tree_function_decl -{ - struct tree_decl ignore; - - char *print_name; - union tree_node *result; - int frame_size; /* For FUNCTION_DECLs: size of stack frame */ - struct rtx_def *saved_insns; /* For FUNCTION_DECLs: points to insn that - constitutes its definition on the - permanent obstack. */ - int block_symtab_address; -}; - -/* Define fields and accessors for nodes representing statements. - These are now obsolete for C, except for LET_STMT, which is used - to record the structure of binding contours (and the names declared - in each contour) for the sake of outputting debugging info. - Perhaps they will be used once again for other languages. */ - -/* For LABEL_STMT, GOTO_STMT, RETURN_STMT, COMPOUND_STMT, ASM_STMT. */ -#define STMT_SOURCE_LINE(NODE) ((NODE)->stmt.linenum) -#define STMT_SOURCE_FILE(NODE) ((NODE)->stmt.filename) -#define STMT_BODY(NODE) ((NODE)->stmt.body) - -struct tree_stmt -{ - char common[sizeof (struct tree_common)]; - char *filename; - int linenum; - union tree_node *body; -}; - -/* For IF_STMT. */ - -/* #define STMT_SOURCE_LINE(NODE) */ -/* #define STMT_SOURCE_FILE(NODE) */ -#define STMT_COND(NODE) ((NODE)->if_stmt.cond) -#define STMT_THEN(NODE) ((NODE)->if_stmt.thenpart) -#define STMT_ELSE(NODE) ((NODE)->if_stmt.elsepart) - -struct tree_if_stmt -{ - char common[sizeof (struct tree_common)]; - char *filename; - int linenum; - union tree_node *cond, *thenpart, *elsepart; -}; - -/* For LOOP_STMT. */ -#define STMT_LOOP_VARS(NODE) ((NODE)->loop_stmt.vars) -#define STMT_LOOP_COND(NODE) ((NODE)->loop_stmt.cond) -#define STMT_LOOP_BODY(NODE) ((NODE)->loop_stmt.body) - -struct tree_loop_stmt -{ - char common[sizeof (struct tree_common)]; - char *filename; - int linenum; - union tree_node *vars, *cond, *body; -}; - -/* For LET_STMT and WITH_STMT. */ - -/* #define STMT_SOURCE_LINE(NODE) */ -/* #define STMT_SOURCE_FILE(NODE) */ -/* #define STMT_BODY(NODE) */ -#define STMT_VARS(NODE) ((NODE)->bind_stmt.vars) -#define STMT_SUPERCONTEXT(NODE) ((NODE)->bind_stmt.supercontext) -#define STMT_BIND_SIZE(NODE) ((NODE)->bind_stmt.bind_size) -#define STMT_TYPE_TAGS(NODE) ((NODE)->bind_stmt.type_tags) -#define STMT_SUBBLOCKS(NODE) ((NODE)->bind_stmt.subblocks) - -struct tree_bind_stmt -{ - char common[sizeof (struct tree_common)]; - char *filename; - int linenum; - union tree_node *body, *vars, *supercontext, *bind_size, *type_tags; - union tree_node *subblocks; -}; - -/* For CASE_STMT. */ - -#define STMT_CASE_INDEX(NODE) ((NODE)->case_stmt.index) -#define STMT_CASE_LIST(NODE) ((NODE)->case_stmt.case_list) - -struct tree_case_stmt -{ - char common[sizeof (struct tree_common)]; - char *filename; - int linenum; - union tree_node *index, *case_list; -}; - -/* Define the overall contents of a tree node. - It may be any of the structures declared above - for various types of node. */ - -union tree_node -{ - struct tree_common common; - struct tree_int_cst int_cst; - struct tree_real_cst real_cst; - struct tree_string string; - struct tree_complex complex; - struct tree_identifier identifier; - struct tree_decl decl; - struct tree_function_decl function_decl; - struct tree_type type; - struct tree_list list; - struct tree_vec vec; - struct tree_exp exp; - struct tree_stmt stmt; - struct tree_if_stmt if_stmt; - struct tree_loop_stmt loop_stmt; - struct tree_bind_stmt bind_stmt; - struct tree_case_stmt case_stmt; -}; - -extern char *oballoc (); -extern char *permalloc (); - -/* Lowest level primitive for allocating a node. - The TREE_CODE is the only argument. Contents are initialized - to zero except for a few of the common fields. */ - -extern tree make_node (); - -/* Make a copy of a node, with all the same contents except - for TREE_UID and TREE_PERMANENT. (The copy is permanent - iff nodes being made now are permanent.) */ - -extern tree copy_node (); - -/* Make a copy of a chain of TREE_LIST nodes. */ - -extern tree copy_list (); - -/* Make a TREE_VEC. */ - -extern tree make_tree_vec (); - -/* Return the (unique) IDENTIFIER_NODE node for a given name. - The name is supplied as a char *. */ - -extern tree get_identifier (); - -/* Construct various types of nodes. */ - -extern tree build_int_2 (); -extern tree build_real (); -extern tree build_real_from_string (); -extern tree build_real_from_int_cst (); -extern tree build_complex (); -extern tree build_string (); -extern tree build (), build1 (); -extern tree build_nt (), build_parse_node (); -extern tree build_tree_list (), build_decl_list (), build_decl_list_1 (); -extern tree build_op_identifier (); -extern tree build_decl (); -extern tree build_if (); -extern tree build_loop (); -extern tree build_let (); - -/* Construct various nodes representing data types. */ - -extern tree make_signed_type (); -extern tree make_unsigned_type (); -extern void fixup_unsigned_type (); -extern tree build_pointer_type (); -extern tree build_reference_type (); -extern tree build_index_type (); -extern tree build_array_type (); -extern tree build_function_type (); -extern tree build_method_type (); -extern tree build_offset_type (); -extern tree array_type_nelts (); - -/* Construct expressions, performing type checking. */ - -extern tree build_binary_op (); -extern tree build_indirect_ref (); -extern tree build_unary_op (); - -/* Given a type node TYPE, and CONSTP and VOLATILEP, return a type - for the same kind of data as TYPE describes. - Variants point to the "main variant" (which has neither CONST nor VOLATILE) - via TYPE_MAIN_VARIANT, and it points to a chain of other variants - so that duplicate variants are never made. - Only main variants should ever appear as types of expressions. */ - -extern tree build_type_variant (); - -/* Given a ..._TYPE node, calculate the TYPE_SIZE, TYPE_SIZE_UNIT, - TYPE_ALIGN and TYPE_MODE fields. - If called more than once on one node, does nothing except - for the first time. */ - -extern void layout_type (); - -/* Given a hashcode and a ..._TYPE node (for which the hashcode was made), - return a canonicalized ..._TYPE node, so that duplicates are not made. - How the hash code is computed is up to the caller, as long as any two - callers that could hash identical-looking type nodes agree. */ - -extern tree type_hash_canon (); - -/* Given a VAR_DECL, PARM_DECL, RESULT_DECL or FIELD_DECL node, - calculates the DECL_SIZE, DECL_SIZE_UNIT, DECL_ALIGN and DECL_MODE - fields. Call this only once for any given decl node. - - Second argument is the boundary that this field can be assumed to - be starting at (in bits). Zero means it can be assumed aligned - on any boundary that may be needed. */ - -extern void layout_decl (); - -/* Fold constants as much as possible in an expression. - Returns the simplified expression. - Acts only on the top level of the expression; - if the argument itself cannot be simplified, its - subexpressions are not changed. */ - -extern tree fold (); - -/* combine (tree_code, exp1, exp2) where EXP1 and EXP2 are constants - returns a constant expression for the result of performing - the operation specified by TREE_CODE on EXP1 and EXP2. */ - -extern tree combine (); - -extern tree convert (); -extern tree convert_units (); -extern tree size_in_bytes (); -extern tree genop (); -extern tree build_int (); -extern tree get_pending_sizes (); - -/* Type for sizes of data-type. */ - -extern tree sizetype; - -/* Concatenate two lists (chains of TREE_LIST nodes) X and Y - by making the last node in X point to Y. - Returns X, except if X is 0 returns Y. */ - -extern tree chainon (); - -/* Make a new TREE_LIST node from specified PURPOSE, VALUE and CHAIN. */ - -extern tree tree_cons (), perm_tree_cons (), temp_tree_cons (); -extern tree saveable_tree_cons (), decl_tree_cons (); - -/* Return the last tree node in a chain. */ - -extern tree tree_last (); - -/* Reverse the order of elements in a chain, and return the new head. */ - -extern tree nreverse (); - -/* Returns the length of a chain of nodes - (number of chain pointers to follow before reaching a null pointer). */ - -extern int list_length (); - -/* integer_zerop (tree x) is nonzero if X is an integer constant of value 0 */ - -extern int integer_zerop (); - -/* integer_onep (tree x) is nonzero if X is an integer constant of value 1 */ - -extern int integer_onep (); - -/* integer_all_onesp (tree x) is nonzero if X is an integer constant - all of whose significant bits are 1. */ - -extern int integer_all_onesp (); - -/* type_unsigned_p (tree x) is nonzero if the type X is an unsigned type - (all of its possible values are >= 0). - If X is a pointer type, the value is 1. - If X is a real type, the value is 0. */ - -extern int type_unsigned_p (); - -/* staticp (tree x) is nonzero if X is a reference to data allocated - at a fixed address in memory. */ - -extern int staticp (); - -/* Gets an error if argument X is not an lvalue. - Also returns 1 if X is an lvalue, 0 if not. */ - -extern int lvalue_or_else (); - -/* save_expr (EXP) returns an expression equivalent to EXP - but it can be used multiple times within context CTX - and only evaluate EXP once. */ - -extern tree save_expr (); - -/* stabilize_reference (EXP) returns an reference equivalent to EXP - but it can be used multiple times - and only evaluate the subexpressions once. */ - -extern tree stabilize_reference (); - -/* Return EXP, stripped of any conversions to wider types - in such a way that the result of converting to type FOR_TYPE - is the same as if EXP were converted to FOR_TYPE. - If FOR_TYPE is 0, it signifies EXP's type. */ - -extern tree get_unwidened (); - -/* Return OP or a simpler expression for a narrower value - which can be sign-extended or zero-extended to give back OP. - Store in *UNSIGNEDP_PTR either 1 if the value should be zero-extended - or 0 if the value should be sign-extended. */ - -extern tree get_narrower (); - -/* Given PRECISION and UNSIGNEDP, return a suitable type-tree - for an integer type with at least that precision. - The definition of this resides in language-specific code - as the repertoire of available types may vary. */ - -extern tree type_for_size (); - -/* Given an integer type T, return a type like T but unsigned. - If T is unsigned, the value is T. - The definition of this resides in language-specific code - as the repertoire of available types may vary. */ - -extern tree unsigned_type (); - -/* Given an integer type T, return a type like T but signed. - If T is signed, the value is T. - The definition of this resides in language-specific code - as the repertoire of available types may vary. */ - -extern tree signed_type (); - -/* Return the floating type node for a given floating machine mode. */ - -extern tree get_floating_type (); - -/* Given the FUNCTION_DECL for the current function, - return zero if it is ok for this function to be inline. - Otherwise return a warning message with a single %s - for the function's name. */ - -extern char *function_cannot_inline_p (); - -/* Declare commonly used variables for tree structure. */ - -/* An integer constant with value 0 */ -extern tree integer_zero_node; - -/* An integer constant with value 1 */ -extern tree integer_one_node; - -/* An integer constant with value 0 whose type is sizetype. */ -extern tree size_zero_node; - -/* An integer constant with value 1 whose type is sizetype. */ -extern tree size_one_node; - -/* A constant of type pointer-to-int and value 0 */ -extern tree null_pointer_node; - -/* A node of type ERROR_MARK. */ -extern tree error_mark_node; - -/* The type node for the void type. */ -extern tree void_type_node; - -/* The type node for the ordinary (signed) integer type. */ -extern tree integer_type_node; - -/* The type node for the unsigned integer type. */ -extern tree unsigned_type_node; - -/* The type node for the ordinary character type. */ -extern tree char_type_node; - -/* Points to the name of the input file from which the current input - being parsed originally came (before it went into cpp). */ -extern char *input_filename; - -/* Nonzero for -pedantic switch: warn about anything - that standard C forbids. */ -extern int pedantic; - -/* Nonzero means can safely call expand_expr now; - otherwise layout_type puts variable sizes onto `pending_sizes' instead. */ - -extern int immediate_size_expand; - -/* Points to the FUNCTION_DECL of the function whose body we are reading. */ - -extern tree current_function_decl; - -/* Nonzero if function being compiled can call setjmp. */ - -extern int current_function_calls_setjmp; - -/* Nonzero means all ..._TYPE nodes should be allocated permanently. */ - -extern int all_types_permanent; - -/* Pointer to function to compute the name to use to print a declaration. */ - -extern char *(*decl_printable_name) (); - -/* In stmt.c */ - -extern tree expand_start_stmt_expr (); -extern tree expand_end_stmt_expr (); -extern void expand_expr_stmt (), clear_last_expr (); -extern void expand_label (), expand_goto (), expand_asm (); -extern void expand_start_cond (), expand_end_cond (); -extern void expand_start_else (), expand_end_else (); -extern void expand_start_loop (), expand_start_loop_continue_elsewhere (); -extern void expand_loop_continue_here (); -extern void expand_end_loop (); -extern int expand_continue_loop (); -extern int expand_exit_loop (), expand_exit_loop_if_false (); -extern int expand_exit_something (); - -extern void expand_start_delayed_expr (); -extern tree expand_end_delayed_expr (); -extern void expand_emit_delayed_expr (); - -extern void expand_null_return (), expand_return (); -extern void expand_start_bindings (), expand_end_bindings (); -extern void expand_start_case (), expand_end_case (); -extern int pushcase (), pushcase_range (); -extern void expand_start_function (), expand_end_function (); diff --git a/gnu/usr.bin/g++/cc1plus/varasm.c b/gnu/usr.bin/g++/cc1plus/varasm.c deleted file mode 100644 index 7650ab817344..000000000000 --- a/gnu/usr.bin/g++/cc1plus/varasm.c +++ /dev/null @@ -1,2241 +0,0 @@ -/* Output variables, constants and external declarations, for GNU compiler. - Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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 CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file handles generation of all the assembler code - *except* the instructions of a function. - This includes declarations of variables and their initial values. - - We also output the assembler code for constants stored in memory - and are responsible for combining constants with the same value. */ - -#include -#include -/* #include */ -#include "config.h" -#include "rtl.h" -#include "tree.h" -#include "flags.h" -#include "expr.h" -#include "hard-reg-set.h" - -#include "obstack.h" - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -/* File in which assembler code is being written. */ - -extern FILE *asm_out_file; - -/* The (assembler) name of the first globally-visible object output. */ -char *first_global_object_name = 0; - -extern struct obstack *current_obstack; -extern struct obstack *saveable_obstack; -extern struct obstack permanent_obstack; -#define obstack_chunk_alloc xmalloc -extern int xmalloc (); - -/* Number for making the label on the next - constant that is stored in memory. */ - -int const_labelno; - -/* Number for making the label on the next - static variable internal to a function. */ - -int var_labelno; - -/* Nonzero if at least one function definition has been seen. */ -static int function_defined; - -extern FILE *asm_out_file; - -static char *compare_constant_1 (); -static void record_constant_1 (); -void output_constant_pool (); -void assemble_name (); -void output_addressed_constants (); -void output_constant (); -void output_constructor (); - -#ifdef EXTRA_SECTIONS -static enum in_section {no_section, in_text, in_data, EXTRA_SECTIONS} in_section - = no_section; -#else -static enum in_section {no_section, in_text, in_data} in_section - = no_section; -#endif - -/* Define functions like text_section for any extra sections. */ -#ifdef EXTRA_SECTION_FUNCTIONS -EXTRA_SECTION_FUNCTIONS -#endif - -/* Tell assembler to switch to text section. */ - -void -text_section () -{ - if (in_section != in_text) - { - fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP); - in_section = in_text; - } -} - -/* Tell assembler to switch to data section. */ - -void -data_section () -{ - if (in_section != in_data) - { - if (flag_shared_data) - { -#ifdef SHARED_SECTION_ASM_OP - fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP); -#else - fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP); -#endif - } - else - fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP); - - in_section = in_data; - } -} - -/* Determine if we're in the text section. */ - -int -in_text_section () -{ - return in_section == in_text; -} - -/* Create the rtl to represent a function, for a function definition. - DECL is a FUNCTION_DECL node which describes which function. - The rtl is stored into DECL. */ - -void -make_function_rtl (decl) - tree decl; -{ - /* Rename a nested function to avoid conflicts. */ - if (DECL_CONTEXT (decl) != 0 && DECL_INITIAL (decl) != 0 - && DECL_RTL (decl) == 0) - { - char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); - char *label; - - ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno); - DECL_ASSEMBLER_NAME (decl) - = obstack_copy0 (saveable_obstack, label, strlen (label)); - var_labelno++; - } - - if (DECL_RTL (decl) == 0) - DECL_RTL (decl) - = gen_rtx (MEM, DECL_MODE (decl), - gen_rtx (SYMBOL_REF, Pmode, DECL_ASSEMBLER_NAME (decl))); - - /* Record at least one function has been defined. */ - function_defined = 1; -} - -/* Decode an `asm' spec for a declaration as a register name. - Return the register number, or -1 if nothing specified, - or -2 if the name is not a register. */ - -int -decode_reg_name (asmspec) - char *asmspec; -{ - if (asmspec != 0) - { - int i; - extern char *reg_names[]; - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (!strcmp (asmspec, reg_names[i])) - break; - - if (i < FIRST_PSEUDO_REGISTER) - return i; - else - return -2; - } - - return -1; -} - -/* Create the DECL_RTL for a declaration for a static or external variable - or static or external function. - ASMSPEC, if not 0, is the string which the user specified - as the assembler symbol name. - TOP_LEVEL is nonzero if this is a file-scope variable. - - This is never called for PARM_DECL nodes. */ - -void -make_decl_rtl (decl, asmspec, top_level) - tree decl; - char *asmspec; - int top_level; -{ - register char *name = DECL_ASSEMBLER_NAME (decl); - int reg_number = decode_reg_name (asmspec); - - if (reg_number == -2) - { - name = (char *) obstack_alloc (saveable_obstack, - strlen (asmspec) + 2); - name[0] = '*'; - strcpy (&name[1], asmspec); - } - - /* For a duplicate declaration, we can be called twice on the - same DECL node. Don't alter the RTL already made - unless the old mode is wrong (which can happen when - the previous rtl was made when the type was incomplete). */ - if (DECL_RTL (decl) == 0 - || GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl)) - { - DECL_RTL (decl) = 0; - - /* First detect errors in declaring global registers. */ - if (TREE_REGDECL (decl) && reg_number == -1) - error_with_decl (decl, - "register name not specified for `%s'"); - else if (TREE_REGDECL (decl) && reg_number == -2) - error_with_decl (decl, - "invalid register name for `%s'"); - else if (reg_number >= 0 && ! TREE_REGDECL (decl)) - error_with_decl (decl, - "register name given for non-register variable `%s'"); - else if (TREE_REGDECL (decl) && TREE_CODE (decl) == FUNCTION_DECL) - error ("function declared `register'"); - else if (TREE_REGDECL (decl) && TYPE_MODE (TREE_TYPE (decl)) == BLKmode) - error_with_decl (decl, "data type of `%s' isn't suitable for a register"); - /* Now handle properly declared static register variables. */ - else if (TREE_REGDECL (decl)) - { - int nregs; - if (pedantic) - warning ("ANSI C forbids global register variables"); - if (DECL_INITIAL (decl) != 0) - { - DECL_INITIAL (decl) = 0; - error ("global register variable has initial value"); - } - if (fixed_regs[reg_number] == 0 - && function_defined && top_level) - error ("global register variable follows a function definition"); - if (TREE_THIS_VOLATILE (decl)) - warning ("volatile register variables don't work as you might wish"); - DECL_RTL (decl) = gen_rtx (REG, DECL_MODE (decl), reg_number); - if (top_level) - { - /* Make this register fixed, so not usable for anything else. */ - nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl)); - while (nregs > 0) - global_regs[reg_number + --nregs] = 1; - init_reg_sets_1 (); - } - } - - /* Now handle ordinary static variables and functions (in memory). - Also handle vars declared register invalidly. */ - if (DECL_RTL (decl) == 0) - { - /* Can't use just the variable's own name for a variable - whose scope is less than the whole file. - Concatenate a distinguishing number. */ - if (!top_level && !TREE_EXTERNAL (decl) && asmspec == 0) - { - char *label; - - ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno); - name = obstack_copy0 (saveable_obstack, label, strlen (label)); - var_labelno++; - } - - DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl), - gen_rtx (SYMBOL_REF, Pmode, name)); - if (TREE_VOLATILE (decl)) - MEM_VOLATILE_P (DECL_RTL (decl)) = 1; - if (TREE_READONLY (decl)) - RTX_UNCHANGING_P (DECL_RTL (decl)) = 1; - MEM_IN_STRUCT_P (DECL_RTL (decl)) - = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE - || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE - || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE); - } - } -} - -/* Output a string of literal assembler code - for an `asm' keyword used between functions. */ - -void -assemble_asm (string) - tree string; -{ - app_enable (); - - fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string)); -} - -/* Output assembler code for the constant pool of a function and associated - with defining the name of the function. DECL describes the function. - For the constant pool, we use the current constant pool data. */ - -void -assemble_function (decl) - tree decl; -{ - rtx x, n; - char *fnname; - int align; - - /* Get the function's name, as described by its RTL. - This may be different from the DECL_NAME name used in the source file. */ - - x = DECL_RTL (decl); - if (GET_CODE (x) != MEM) - abort (); - n = XEXP (x, 0); - if (GET_CODE (n) != SYMBOL_REF) - abort (); - fnname = XSTR (n, 0); - - /* The following code does not need preprocessing in the assembler. */ - - app_disable (); - - output_constant_pool (fnname, decl); - - text_section (); - -#ifdef SDB_DEBUGGING_INFO - /* Make sure types are defined for debugger before fcn name is defined. */ - if (write_symbols == SDB_DEBUG) - sdbout_tags (gettags ()); -#endif - - /* Tell assembler to move to target machine's alignment for functions. */ - - align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT); - if (align > 0) - ASM_OUTPUT_ALIGN (asm_out_file, align); - -#ifdef SDB_DEBUGGING_INFO - /* Output SDB definition of the function. */ - if (write_symbols == SDB_DEBUG) - sdbout_mark_begin_function (); -#endif - - /* Make function name accessible from other files, if appropriate. */ - - if (TREE_PUBLIC (decl)) - { - if (!first_global_object_name) - first_global_object_name = fnname; - ASM_GLOBALIZE_LABEL (asm_out_file, fnname); - } - - /* Do any machine/system dependent processing of the function name */ -#ifdef ASM_DECLARE_FUNCTION_NAME - ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl); -#else - /* Standard thing is just output label for the function. */ - ASM_OUTPUT_LABEL (asm_out_file, fnname); -#endif /* ASM_DECLARE_FUNCTION_NAME */ -} - -/* Assemble " .int 0\n" or whatever this assembler wants. */ - -void -assemble_integer_zero () -{ - ASM_OUTPUT_INT (asm_out_file, const0_rtx); -} - -/* Assemble a string constant with the specified C string as contents. */ - -void -assemble_string (p, size) - unsigned char *p; - int size; -{ - register int i; - int pos = 0; - int maximum = 2000; - - /* If the string is very long, split it up. */ - - while (pos < size) - { - int thissize = size - pos; - if (thissize > maximum) - thissize = maximum; - -#ifdef ASM_OUTPUT_ASCII - ASM_OUTPUT_ASCII (asm_out_file, p, thissize); -#else - fprintf (asm_out_file, "\t.ascii \""); - - for (i = 0; i < thissize; i++) - { - register int c = p[i]; - if (c == '\"' || c == '\\') - putc ('\\', asm_out_file); - if (c >= ' ' && c < 0177) - putc (c, asm_out_file); - else - { - fprintf (asm_out_file, "\\%o", c); - /* After an octal-escape, if a digit follows, - terminate one string constant and start another. - The Vax assembler fails to stop reading the escape - after three digits, so this is the only way we - can get it to parse the data properly. */ - if (i < thissize - 1 - && p[i + 1] >= '0' && p[i + 1] <= '9') - fprintf (asm_out_file, "\"\n\t.ascii \""); - } - } - fprintf (asm_out_file, "\"\n"); -#endif /* no ASM_OUTPUT_ASCII */ - - pos += thissize; - p += thissize; - } -} - -/* Assemble everything that is needed for a variable or function declaration. - Not used for automatic variables, and not used for function definitions. - Should not be called for variables of incomplete structure type. - - TOP_LEVEL is nonzero if this variable has file scope. - WRITE_SYMBOLS is DBX_DEBUG if writing dbx symbol output. - The dbx data for a file-scope variable is written here. - AT_END is nonzero if this is the special handling, at end of compilation, - to define things that have had only tentative definitions. */ - -void -assemble_variable (decl, top_level, write_symbols, at_end) - tree decl; - int top_level; - enum debugger write_symbols; - int at_end; -{ - register char *name; - register int i; - int align; - - /* Do nothing for global register variables. */ - - if (GET_CODE (DECL_RTL (decl)) == REG) - return; - - /* Normally no need to say anything for external references, - since assembler considers all undefined symbols external. */ - - if (TREE_EXTERNAL (decl)) - return; - - /* Output no assembler code for a function declaration. - Only definitions of functions output anything. */ - - if (TREE_CODE (decl) == FUNCTION_DECL) - return; - - /* If type was incomplete when the variable was declared, - see if it is complete now. */ - - if (DECL_SIZE (decl) == 0) - layout_decl (decl, 0); - - /* Still incomplete => don't allocate it; treat the tentative defn - (which is what it must have been) as an `extern' reference. */ - - if (DECL_SIZE (decl) == 0) - { - error_with_file_and_line (DECL_SOURCE_FILE (decl), - DECL_SOURCE_LINE (decl), - "storage size of static var `%s' isn't known", - IDENTIFIER_POINTER (DECL_NAME (decl))); - return; - } - - /* The first declaration of a variable that comes through this function - decides whether it is global (in C, has external linkage) - or local (in C, has internal linkage). So do nothing more - if this function has already run. */ - - if (TREE_ASM_WRITTEN (decl)) - return; - - TREE_ASM_WRITTEN (decl) = 1; - -#ifdef DBX_DEBUGGING_INFO - /* File-scope global variables are output here. */ - if (write_symbols == DBX_DEBUG && top_level) - dbxout_symbol (decl, 0); -#endif -#ifdef SDB_DEBUGGING_INFO - if (write_symbols == SDB_DEBUG && top_level) - sdbout_symbol (decl, 0); -#endif - if (write_symbols == GDB_DEBUG) - /* Make sure the file is known to GDB even if it has no functions. */ - set_current_gdbfile (DECL_SOURCE_FILE (decl)); - - /* If storage size is erroneously variable, just continue. - Error message was already made. */ - - if (! TREE_LITERAL (DECL_SIZE (decl))) - return; - - app_disable (); - - name = XSTR (XEXP (DECL_RTL (decl), 0), 0); - - /* Handle uninitialized definitions. */ - - if (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node) - { - int size = (TREE_INT_CST_LOW (DECL_SIZE (decl)) - * DECL_SIZE_UNIT (decl) - / BITS_PER_UNIT); - int rounded = size; - /* Don't allocate zero bytes of common, - since that means "undefined external" in the linker. */ - if (size == 0) rounded = 1; - /* Round size up to multiple of BIGGEST_ALIGNMENT bits - so that each uninitialized object starts on such a boundary. */ - rounded = ((rounded + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1) - / (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); - if (flag_shared_data) - data_section (); - if (TREE_PUBLIC (decl)) - ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded); - else - ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded); - return; - } - - /* Handle initialized definitions. */ - - /* First make the assembler name(s) global if appropriate. */ - if (TREE_PUBLIC (decl) && DECL_NAME (decl)) - { - if (!first_global_object_name - && (DECL_INITIAL (decl) == 0 - || TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR - || CONSTRUCTOR_ELTS (DECL_INITIAL (decl)) != 0)) - first_global_object_name = name + (name[0] == '*'); - ASM_GLOBALIZE_LABEL (asm_out_file, name); - } -#if 0 - for (d = equivalents; d; d = TREE_CHAIN (d)) - { - tree e = TREE_VALUE (d); - if (TREE_PUBLIC (e) && DECL_NAME (e)) - ASM_GLOBALIZE_LABEL (asm_out_file, - XSTR (XEXP (DECL_RTL (e), 0), 0)); - } -#endif - - /* Output any data that we will need to use the address of. */ - if (DECL_INITIAL (decl)) - output_addressed_constants (DECL_INITIAL (decl)); - - /* Switch to the proper section for this data. */ -#ifdef SELECT_SECTION - SELECT_SECTION (decl); -#else - if (TREE_READONLY (decl) && ! TREE_VOLATILE (decl)) - text_section (); - else - data_section (); -#endif - - /* Output the alignment of this data. */ -#ifdef DATA_ALIGNMENT - /* On some machines, it is good to increase alignment sometimes. */ - align = DATA_ALIGNMENT (decl, DECL_ALIGN (decl)); -#else /* no DATA_ALIGNMENT */ - align = DECL_ALIGN (decl); -#endif /* DATA_ALIGNMENT */ - - for (i = 0; align >= BITS_PER_UNIT << (i + 1); i++); - if (i > 0) - ASM_OUTPUT_ALIGN (asm_out_file, i); - - /* Output the name(s) of this data. */ - ASM_OUTPUT_LABEL (asm_out_file, name); -#if 0 - for (d = equivalents; d; d = TREE_CHAIN (d)) - { - tree e = TREE_VALUE (d); - ASM_OUTPUT_LABEL (asm_out_file, XSTR (XEXP (DECL_RTL (e), 0), 0)); - } -#endif - - if (DECL_INITIAL (decl)) - /* Output the actual data. */ - output_constant (DECL_INITIAL (decl), int_size_in_bytes (TREE_TYPE (decl))); - else - /* Leave space for it. */ - ASM_OUTPUT_SKIP (asm_out_file, int_size_in_bytes (TREE_TYPE (decl))); -} - -/* Output something to declare an external symbol to the assembler. - (Most assemblers don't need this, so we normally output nothing.) */ - -void -assemble_external (decl) - tree decl; -{ - rtx rtl = DECL_RTL (decl); - - if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF) - { -#ifdef ASM_OUTPUT_EXTERNAL - /* Some systems do require some output. */ - ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0)); -#endif - } -} - -/* Output to FILE a reference to the assembler name of a C-level name NAME. - If NAME starts with a *, the rest of NAME is output verbatim. - Otherwise NAME is transformed in an implementation-defined way - (usually by the addition of an underscore). - Many macros in the tm file are defined to call this function. */ - -void -assemble_name (file, name) - FILE *file; - char *name; -{ - if (name[0] == '*') - fputs (&name[1], file); - else - ASM_OUTPUT_LABELREF (file, name); -} - -/* Allocate SIZE bytes writable static space with a gensym name - and return an RTX to refer to its address. */ - -rtx -assemble_static_space (size) - int size; -{ - char name[12]; - char *namestring; - rtx x; - /* Round size up to multiple of BIGGEST_ALIGNMENT bits - so that each uninitialized object starts on such a boundary. */ - int rounded = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1) - / (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); - - if (flag_shared_data) - data_section (); - ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno); - ++const_labelno; - - namestring = (char *) obstack_alloc (saveable_obstack, - strlen (name) + 2); - strcpy (namestring, name); - - x = gen_rtx (SYMBOL_REF, Pmode, namestring); - ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded); - return x; -} -#if 0 -/* Assemble the static constant template for function entry trampolines. - This is done at most once per compilation. - Returns an RTX for the address of the template. */ - -rtx -assemble_trampoline_template () -{ - char label[256]; - char *name; - int align; - - /* Write the assembler code to define one. */ - align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT); - if (align > 0) - ASM_OUTPUT_ALIGN (asm_out_file, align); - - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LTRAMP", 0); - TRAMPOLINE_TEMPLATE (asm_out_file); - - /* Record the rtl to refer to it. */ - ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0); - name - = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label)); - return gen_rtx (SYMBOL_REF, Pmode, name); -} -#endif - -/* Here we combine duplicate floating constants to make - CONST_DOUBLE rtx's, and force those out to memory when necessary. */ - -/* Chain of all CONST_DOUBLE rtx's constructed for the current function. - They are chained through the CONST_DOUBLE_CHAIN. - A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain. - In that case, CONST_DOUBLE_MEM is either a MEM, - or const0_rtx if no MEM has been made for this CONST_DOUBLE yet. */ - -static rtx real_constant_chain; - -/* Return a CONST_DOUBLE for a value specified as a pair of ints. - For an integer, I0 is the low-order word and I1 is the high-order word. - For a real number, I0 is the word with the low address - and I1 is the word with the high address. */ - -rtx -immed_double_const (i0, i1, mode) - int i0, i1; - enum machine_mode mode; -{ - register rtx r; - - if (mode == DImode && i0 == 0 && i1 == 0) - return const0_rtx; - - /* Search the chain for an existing CONST_DOUBLE with the right value. - If one is found, return it. */ - - for (r = real_constant_chain; r; r = CONST_DOUBLE_CHAIN (r)) - if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1 - && GET_MODE (r) == mode) - return r; - - /* No; make a new one and add it to the chain. */ - - r = gen_rtx (CONST_DOUBLE, mode, 0, i0, i1); - - CONST_DOUBLE_CHAIN (r) = real_constant_chain; - real_constant_chain = r; - - /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain. - Actual use of mem-slot is only through force_const_double_mem. */ - - CONST_DOUBLE_MEM (r) = const0_rtx; - - return r; -} - -/* Return a CONST_DOUBLE for a specified `double' value - and machine mode. */ - -rtx -immed_real_const_1 (d, mode) - REAL_VALUE_TYPE d; - enum machine_mode mode; -{ - union real_extract u; - register rtx r; - REAL_VALUE_TYPE negated; - - /* Get the desired `double' value as a sequence of ints - since that is how they are stored in a CONST_DOUBLE. */ - - u.d = d; - -#if 0 - /* Detect special cases. */ - - if (REAL_VALUES_EQUAL (dconst0, d)) - return (mode == DFmode ? dconst0_rtx : fconst0_rtx); - else if (REAL_VALUES_EQUAL (dconst1, d)) - return (mode == DFmode ? dconst1_rtx : fconst1_rtx); - - if (sizeof u == 2 * sizeof (int)) - return immed_double_const (u.i[0], u.i[1], mode); -#else - /* Detect zero. */ - - negated = REAL_VALUE_NEGATE (d); - if (REAL_VALUES_EQUAL (negated, d)) - return (mode == DFmode ? dconst0_rtx : fconst0_rtx); - - if (sizeof u == 2 * sizeof (int)) - return immed_double_const (u.i[0], u.i[1], mode); -#endif - - /* The rest of this function handles the case where - a float value requires more than 2 ints of space. - It will be deleted as dead code on machines that don't need it. */ - - /* Search the chain for an existing CONST_DOUBLE with the right value. - If one is found, return it. */ - - for (r = real_constant_chain; r; r = CONST_DOUBLE_CHAIN (r)) - if (! bcmp (&CONST_DOUBLE_LOW (r), &u, sizeof u) - && GET_MODE (r) == mode) - return r; - - /* No; make a new one and add it to the chain. */ - - r = rtx_alloc (CONST_DOUBLE); - PUT_MODE (r, mode); - bcopy (&u, &CONST_DOUBLE_LOW (r), sizeof u); - - CONST_DOUBLE_CHAIN (r) = real_constant_chain; - real_constant_chain = r; - - /* Store const0_rtx in slot 2 since this CONST_DOUBLE is on the chain. - Actual use of slot 2 is only through force_const_double_mem. */ - - CONST_DOUBLE_MEM (r) = const0_rtx; - - return r; -} - -/* Return a CONST_DOUBLE rtx for a value specified by EXP, - which must be a REAL_CST tree node. */ - -rtx -immed_real_const (exp) - tree exp; -{ - return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp))); -} - -/* Given a CONST_DOUBLE, cause a constant in memory to be created - (unless we already have one for the same value) - and return a MEM rtx to refer to it. - Put the CONST_DOUBLE on real_constant_chain if it isn't already there. */ - -rtx -force_const_double_mem (r) - rtx r; -{ - if (GET_CODE (CONST_DOUBLE_MEM (r)) != MEM) - force_const_mem (GET_MODE (r), r); - - /* CONST_DOUBLE_MEM (r) is now a MEM with a constant address. - If that is legitimate, return it. - Othewise it will need reloading, so return a copy of it. */ - if (memory_address_p (GET_MODE (r), XEXP (CONST_DOUBLE_MEM (r), 0))) - return CONST_DOUBLE_MEM (r); - return gen_rtx (MEM, GET_MODE (r), XEXP (CONST_DOUBLE_MEM (r), 0)); -} - -/* At the end of a function, forget the memory-constants - previously made for CONST_DOUBLEs. Mark them as not on real_constant_chain. - Also clear out real_constant_chain and clear out all the chain-pointers. */ - -void -clear_const_double_mem () -{ - register rtx r, next; - - for (r = real_constant_chain; r; r = next) - { - next = CONST_DOUBLE_CHAIN (r); - CONST_DOUBLE_CHAIN (r) = 0; - CONST_DOUBLE_MEM (r) = cc0_rtx; - } - real_constant_chain = 0; -} - -/* Given an expression EXP with a constant value, - reduce it to the sum of an assembler symbol and an integer. - Store them both in the structure *VALUE. - Abort if EXP does not reduce. */ - -struct addr_const -{ - rtx base; - int offset; -}; - -static void -decode_addr_const (exp, value) - tree exp; - struct addr_const *value; -{ - register tree target = TREE_OPERAND (exp, 0); - register int offset = 0; - register rtx x; - - while (1) - { - if (TREE_CODE (target) == COMPONENT_REF) - { - offset += DECL_OFFSET (TREE_OPERAND (target, 1)) / BITS_PER_UNIT; - target = TREE_OPERAND (target, 0); - } - else if (TREE_CODE (target) == ARRAY_REF) - { - if (TREE_CODE (TREE_OPERAND (target, 1)) != INTEGER_CST - || TREE_CODE (TYPE_SIZE (TREE_TYPE (target))) != INTEGER_CST) - abort (); - offset += ((TYPE_SIZE_UNIT (TREE_TYPE (target)) - * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target))) - * TREE_INT_CST_LOW (TREE_OPERAND (target, 1))) - / BITS_PER_UNIT); - target = TREE_OPERAND (target, 0); - } - else break; - } - - if (TREE_CODE (target) == VAR_DECL - || TREE_CODE (target) == FUNCTION_DECL) - x = DECL_RTL (target); - else if (TREE_LITERAL (target)) - x = TREE_CST_RTL (target); - else - abort (); - - if (GET_CODE (x) != MEM) - abort (); - x = XEXP (x, 0); - - value->base = x; - value->offset = offset; -} - -/* Uniquize all constants that appear in memory. - Each constant in memory thus far output is recorded - in `const_hash_table' with a `struct constant_descriptor' - that contains a polish representation of the value of - the constant. - - We cannot store the trees in the hash table - because the trees may be temporary. */ - -struct constant_descriptor -{ - struct constant_descriptor *next; - char *label; - char contents[1]; -}; - -#define HASHBITS 30 -#define MAX_HASH_TABLE 1009 -static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE]; - -/* Compute a hash code for a constant expression. */ - -int -const_hash (exp) - tree exp; -{ - register char *p; - register int len, hi, i; - register enum tree_code code = TREE_CODE (exp); - - if (code == INTEGER_CST) - { - p = (char *) &TREE_INT_CST_LOW (exp); - len = 2 * sizeof TREE_INT_CST_LOW (exp); - } - else if (code == REAL_CST) - { - p = (char *) &TREE_REAL_CST (exp); - len = sizeof TREE_REAL_CST (exp); - } - else if (code == STRING_CST) - p = TREE_STRING_POINTER (exp), len = TREE_STRING_LENGTH (exp); - else if (code == COMPLEX_CST) - return const_hash (TREE_REALPART (exp)) * 5 - + const_hash (TREE_IMAGPART (exp)); - else if (code == CONSTRUCTOR) - { - register tree link; - - /* For record type, include the type in the hashing. - We do not do so for array types - because (1) the sizes of the elements are sufficient - and (2) distinct array types can have the same constructor. */ - if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) - hi = ((int) TREE_TYPE (exp) & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE; - else - hi = 5; - - for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) - hi = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE; - - return hi; - } - else if (code == ADDR_EXPR) - { - struct addr_const value; - decode_addr_const (exp, &value); - p = (char *) &value; - len = sizeof value; - } - else if (code == PLUS_EXPR || code == MINUS_EXPR) - return const_hash (TREE_OPERAND (exp, 0)) * 9 - + const_hash (TREE_OPERAND (exp, 1)); - else if (code == NOP_EXPR || code == CONVERT_EXPR) - return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2; - - /* Compute hashing function */ - hi = len; - for (i = 0; i < len; i++) - hi = ((hi * 613) + (unsigned)(p[i])); - - hi &= (1 << HASHBITS) - 1; - hi %= MAX_HASH_TABLE; - return hi; -} - -/* Compare a constant expression EXP with a constant-descriptor DESC. - Return 1 if DESC describes a constant with the same value as EXP. */ - -static int -compare_constant (exp, desc) - tree exp; - struct constant_descriptor *desc; -{ - return 0 != compare_constant_1 (exp, desc->contents); -} - -/* Compare constant expression EXP with a substring P of a constant descriptor. - If they match, return a pointer to the end of the substring matched. - If they do not match, return 0. - - Since descriptors are written in polish prefix notation, - this function can be used recursively to test one operand of EXP - against a subdescriptor, and if it succeeds it returns the - address of the subdescriptor for the next operand. */ - -static char * -compare_constant_1 (exp, p) - tree exp; - char *p; -{ - register char *strp; - register int len; - register enum tree_code code = TREE_CODE (exp); - - if (code != (enum tree_code) *p++) - return 0; - - if (code == INTEGER_CST) - { - /* Integer constants are the same only if the same width of type. */ - if (*p++ != TYPE_PRECISION (TREE_TYPE (exp))) - return 0; - strp = (char *) &TREE_INT_CST_LOW (exp); - len = 2 * sizeof TREE_INT_CST_LOW (exp); - } - else if (code == REAL_CST) - { - /* Real constants are the same only if the same width of type. */ - if (*p++ != TYPE_PRECISION (TREE_TYPE (exp))) - return 0; - strp = (char *) &TREE_REAL_CST (exp); - len = sizeof TREE_REAL_CST (exp); - } - else if (code == STRING_CST) - { - if (flag_writable_strings) - return 0; - strp = TREE_STRING_POINTER (exp); - len = TREE_STRING_LENGTH (exp); - if (bcmp (&TREE_STRING_LENGTH (exp), p, - sizeof TREE_STRING_LENGTH (exp))) - return 0; - p += sizeof TREE_STRING_LENGTH (exp); - } - else if (code == COMPLEX_CST) - { - p = compare_constant_1 (TREE_REALPART (exp), p); - if (p == 0) return 0; - p = compare_constant_1 (TREE_IMAGPART (exp), p); - return p; - } - else if (code == CONSTRUCTOR) - { - register tree link; - int length = list_length (CONSTRUCTOR_ELTS (exp)); - tree type; - - if (bcmp (&length, p, sizeof length)) - return 0; - p += sizeof length; - - /* For record constructors, insist that the types match. - For arrays, just verify both constructors are for arrays. */ - if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) - type = TREE_TYPE (exp); - else - type = 0; - if (bcmp (&type, p, sizeof type)) - return 0; - p += sizeof type; - - for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) - if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0) - return 0; - return p; - } - else if (code == ADDR_EXPR) - { - struct addr_const value; - decode_addr_const (exp, &value); - strp = (char *) &value; - len = sizeof value; - /* Compare SYMBOL_REF address and offset. */ - while (--len >= 0) - if (*p++ != *strp++) - return 0; - /* Compare symbol name. */ - strp = XSTR (value.base, 0); - len = strlen (strp) + 1; - } - else if (code == PLUS_EXPR || code == MINUS_EXPR) - { - p = compare_constant_1 (TREE_OPERAND (exp, 0), p); - if (p == 0) return 0; - p = compare_constant_1 (TREE_OPERAND (exp, 1), p); - return p; - } - else if (code == NOP_EXPR || code == CONVERT_EXPR) - { - p = compare_constant_1 (TREE_OPERAND (exp, 0), p); - return p; - } - - /* Compare constant contents. */ - while (--len >= 0) - if (*p++ != *strp++) - return 0; - - return p; -} - -/* Construct a constant descriptor for the expression EXP. - It is up to the caller to enter the descriptor in the hash table. */ - -static struct constant_descriptor * -record_constant (exp) - tree exp; -{ - struct constant_descriptor *ptr = 0; - int buf; - - obstack_grow (&permanent_obstack, &ptr, sizeof ptr); - obstack_grow (&permanent_obstack, &buf, sizeof buf); - record_constant_1 (exp); - return (struct constant_descriptor *) obstack_finish (&permanent_obstack); -} - -/* Add a description of constant expression EXP - to the object growing in `permanent_obstack'. - No need to return its address; the caller will get that - from the obstack when the object is complete. */ - -static void -record_constant_1 (exp) - tree exp; -{ - register char *strp; - register int len; - register enum tree_code code = TREE_CODE (exp); - - obstack_1grow (&permanent_obstack, (unsigned int) code); - - if (code == INTEGER_CST) - { - obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp))); - strp = (char *) &TREE_INT_CST_LOW (exp); - len = 2 * sizeof TREE_INT_CST_LOW (exp); - } - else if (code == REAL_CST) - { - obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp))); - strp = (char *) &TREE_REAL_CST (exp); - len = sizeof TREE_REAL_CST (exp); - } - else if (code == STRING_CST) - { - if (flag_writable_strings) - return; - strp = TREE_STRING_POINTER (exp); - len = TREE_STRING_LENGTH (exp); - obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp), - sizeof TREE_STRING_LENGTH (exp)); - } - else if (code == COMPLEX_CST) - { - record_constant_1 (TREE_REALPART (exp)); - record_constant_1 (TREE_IMAGPART (exp)); - return; - } - else if (code == CONSTRUCTOR) - { - register tree link; - int length = list_length (CONSTRUCTOR_ELTS (exp)); - tree type; - - obstack_grow (&permanent_obstack, (char *) &length, sizeof length); - - /* For record constructors, insist that the types match. - For arrays, just verify both constructors are for arrays. */ - if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE) - type = TREE_TYPE (exp); - else - type = 0; - obstack_grow (&permanent_obstack, (char *) &type, sizeof type); - - for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) - record_constant_1 (TREE_VALUE (link)); - return; - } - else if (code == ADDR_EXPR) - { - struct addr_const value; - decode_addr_const (exp, &value); - /* Record the SYMBOL_REF address and the offset. */ - obstack_grow (&permanent_obstack, (char *) &value, sizeof value); - /* Record the symbol name. */ - obstack_grow (&permanent_obstack, XSTR (value.base, 0), - strlen (XSTR (value.base, 0)) + 1); - return; - } - else if (code == PLUS_EXPR || code == MINUS_EXPR) - { - record_constant_1 (TREE_OPERAND (exp, 0)); - record_constant_1 (TREE_OPERAND (exp, 1)); - return; - } - else if (code == NOP_EXPR || code == CONVERT_EXPR) - { - record_constant_1 (TREE_OPERAND (exp, 0)); - return; - } - - /* Record constant contents. */ - obstack_grow (&permanent_obstack, strp, len); -} - -/* Return the constant-label-string for constant value EXP. - If no constant equal to EXP has yet been output, - define a new label and output assembler code for it. - The const_hash_table records which constants already have label strings. */ - -static char * -get_or_assign_label (exp) - tree exp; -{ - register int hash, i, align; - register struct constant_descriptor *desc; - char label[256]; - - /* Make sure any other constants whose addresses appear in EXP - are assigned label numbers. */ - - output_addressed_constants (exp); - - /* Compute hash code of EXP. Search the descriptors for that hash code - to see if any of them describes EXP. If yes, the descriptor records - the label number already assigned. */ - - hash = const_hash (exp) % MAX_HASH_TABLE; - - for (desc = const_hash_table[hash]; desc; desc = desc->next) - if (compare_constant (exp, desc)) - return desc->label; - - /* No constant equal to EXP is known to have been output. - Make a constant descriptor to enter EXP in the hash table. - Assign the label number and record it in the descriptor for - future calls to this function to find. */ - - desc = record_constant (exp); - desc->next = const_hash_table[hash]; - const_hash_table[hash] = desc; - - /* Now output assembler code to define that label - and follow it with the data of EXP. */ - - /* First switch to text section, except for writable strings. */ -#ifdef SELECT_SECTION - SELECT_SECTION (exp); -#else - if ((TREE_CODE (exp) == STRING_CST) && flag_writable_strings) - data_section (); - else - text_section (); -#endif - - /* Align the location counter as required by EXP's data type. */ -#ifdef DATA_ALIGNMENT - align = DATA_ALIGNMENT (exp, TYPE_ALIGN (TREE_TYPE (exp))); -#else - align = TYPE_ALIGN (TREE_TYPE (exp)); -#endif - - for (i = 0; align >= BITS_PER_UNIT << (i + 1); i++); - if (i > 0) - ASM_OUTPUT_ALIGN (asm_out_file, i); - - /* Output the label itself. */ - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", const_labelno); - - /* Output the value of EXP. */ - output_constant (exp, - (TREE_CODE (exp) == STRING_CST - ? TREE_STRING_LENGTH (exp) - : int_size_in_bytes (TREE_TYPE (exp)))); - - /* Create a string containing the label name, in LABEL. */ - ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno); - - ++const_labelno; - - desc->label - = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label)); - - return desc->label; -} - -/* Return an rtx representing a reference to constant data in memory - for the constant expression EXP. - If assembler code for such a constant has already been output, - return an rtx to refer to it. - Otherwise, output such a constant in memory and generate - an rtx for it. The TREE_CST_RTL of EXP is set up to point to that rtx. */ - -rtx -output_constant_def (exp) - tree exp; -{ - register rtx def; - int temp_p = allocation_temporary_p (); - - if (TREE_CODE (exp) == INTEGER_CST) - abort (); /* No TREE_CST_RTL slot in these. */ - - if (TREE_CST_RTL (exp)) - return TREE_CST_RTL (exp); - - if (TREE_PERMANENT (exp)) - end_temporary_allocation (); - - def = gen_rtx (SYMBOL_REF, Pmode, get_or_assign_label (exp)); - - TREE_CST_RTL (exp) - = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), def); - RTX_UNCHANGING_P (TREE_CST_RTL (exp)) = 1; - - if (temp_p && TREE_PERMANENT (exp)) - resume_temporary_allocation (); - - return TREE_CST_RTL (exp); -} - -/* Similar hash facility for making memory-constants - from constant rtl-expressions. It is used on RISC machines - where immediate integer arguments and constant addresses are restricted - so that such constants must be stored in memory. - - This pool of constants is reinitialized for each function - so each function gets its own constants-pool that comes right before it. - - All structures allocated here are discarded when functions are saved for - inlining, so they do not need to be allocated permanently. */ - -#define MAX_RTX_HASH_TABLE 61 -static struct constant_descriptor *const_rtx_hash_table[MAX_RTX_HASH_TABLE]; - -/* Structure to represent sufficient information about a constant so that - it can be output when the constant pool is output, so that function - integration can be done, and to simplify handling on machines that reference - constant pool as base+displacement. */ - -struct pool_constant -{ - struct constant_descriptor *desc; - struct pool_constant *next; - enum machine_mode mode; - rtx constant; - int labelno; - int align; - int offset; -}; - -/* Pointers to first and last constant in pool. */ - -static struct pool_constant *first_pool, *last_pool; - -/* Current offset in constant pool (does not include any machine-specific - header. */ - -static int pool_offset; - -/* Structure used to maintain hash table mapping symbols used to their - corresponding constants. */ - -struct pool_sym -{ - char *label; - struct pool_constant *pool; - struct pool_sym *next; -}; - -static struct pool_sym *const_rtx_sym_hash_table[MAX_RTX_HASH_TABLE]; - -/* Hash code for a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true. - The argument is XSTR (... , 0) */ - -#define SYMHASH(LABEL) \ - ((((int) (LABEL)) & ((1 << HASHBITS) - 1)) % MAX_RTX_HASH_TABLE) - -/* Initialize constant pool hashing for next function. */ - -void -init_const_rtx_hash_table () -{ - bzero (const_rtx_hash_table, sizeof const_rtx_hash_table); - bzero (const_rtx_sym_hash_table, sizeof const_rtx_sym_hash_table); - - first_pool = last_pool = 0; - pool_offset = 0; -} - -struct rtx_const -{ - enum kind { RTX_DOUBLE, RTX_INT } kind : 16; - enum machine_mode mode : 16; - union { - union real_extract du; - struct addr_const addr; - } un; -}; - -/* Express an rtx for a constant integer (perhaps symbolic) - as the sum of a symbol or label plus an explicit integer. - They are stored into VALUE. */ - -static void -decode_rtx_const (mode, x, value) - enum machine_mode mode; - rtx x; - struct rtx_const *value; -{ - /* Clear the whole structure, including any gaps. */ - - { - int *p = (int *) value; - int *end = (int *) (value + 1); - while (p < end) - *p++ = 0; - } - - value->kind = RTX_INT; /* Most usual kind. */ - value->mode = mode; - - switch (GET_CODE (x)) - { - case CONST_DOUBLE: - value->kind = RTX_DOUBLE; - value->mode = GET_MODE (x); - bcopy (&CONST_DOUBLE_LOW (x), &value->un.du, sizeof value->un.du); - break; - - case CONST_INT: - value->un.addr.offset = INTVAL (x); - break; - - case SYMBOL_REF: - value->un.addr.base = x; - break; - - case LABEL_REF: - value->un.addr.base = x; - break; - - case CONST: - x = XEXP (x, 0); - if (GET_CODE (x) == PLUS) - { - value->un.addr.base = XEXP (XEXP (x, 0), 0); - if (GET_CODE (XEXP (x, 1)) != CONST_INT) - abort (); - value->un.addr.offset = INTVAL (XEXP (x, 1)); - } - else if (GET_CODE (x) == MINUS) - { - value->un.addr.base = XEXP (x, 0); - if (GET_CODE (XEXP (x, 1)) != CONST_INT) - abort (); - value->un.addr.offset = - INTVAL (XEXP (x, 1)); - } - else - abort (); - break; - - default: - abort (); - } - - if (value->kind == RTX_INT && value->un.addr.base != 0) - switch (GET_CODE (value->un.addr.base)) - { - case SYMBOL_REF: - case LABEL_REF: - /* Use the string's address, not the SYMBOL_REF's address, - for the sake of addresses of library routines. - For a LABEL_REF, compare labels. */ - value->un.addr.base = XEXP (value->un.addr.base, 0); - } -} - -/* Compute a hash code for a constant RTL expression. */ - -int -const_hash_rtx (mode, x) - enum machine_mode mode; - rtx x; -{ - register int hi, i; - - struct rtx_const value; - decode_rtx_const (mode, x, &value); - - /* Compute hashing function */ - hi = 0; - for (i = 0; i < sizeof value / sizeof (int); i++) - hi += ((int *) &value)[i]; - - hi &= (1 << HASHBITS) - 1; - hi %= MAX_RTX_HASH_TABLE; - return hi; -} - -/* Compare a constant rtl object X with a constant-descriptor DESC. - Return 1 if DESC describes a constant with the same value as X. */ - -static int -compare_constant_rtx (mode, x, desc) - enum machine_mode mode; - rtx x; - struct constant_descriptor *desc; -{ - register int *p = (int *) desc->contents; - register int *strp; - register int len; - struct rtx_const value; - - decode_rtx_const (mode, x, &value); - strp = (int *) &value; - len = sizeof value / sizeof (int); - - /* Compare constant contents. */ - while (--len >= 0) - if (*p++ != *strp++) - return 0; - - return 1; -} - -/* Construct a constant descriptor for the rtl-expression X. - It is up to the caller to enter the descriptor in the hash table. */ - -static struct constant_descriptor * -record_constant_rtx (mode, x) - enum machine_mode mode; - rtx x; -{ - struct constant_descriptor *ptr; - char *label; - struct rtx_const value; - - decode_rtx_const (mode, x, &value); - - obstack_grow (current_obstack, &ptr, sizeof ptr); - obstack_grow (current_obstack, &label, sizeof label); - - /* Record constant contents. */ - obstack_grow (current_obstack, &value, sizeof value); - - return (struct constant_descriptor *) obstack_finish (current_obstack); -} - -/* Given a constant rtx X, make (or find) a memory constant for its value - and return a MEM rtx to refer to it in memory. */ - -rtx -force_const_mem (mode, x) - enum machine_mode mode; - rtx x; -{ - register int hash; - register struct constant_descriptor *desc; - char label[256]; - char *found = 0; - rtx def; - - if (GET_CODE (x) == CONST_DOUBLE - && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM) - return CONST_DOUBLE_MEM (x); - - /* Compute hash code of X. Search the descriptors for that hash code - to see if any of them describes X. If yes, the descriptor records - the label number already assigned. */ - - hash = const_hash_rtx (mode, x); - - for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next) - if (compare_constant_rtx (mode, x, desc)) - { - found = desc->label; - break; - } - - if (found == 0) - { - register struct pool_constant *pool; - register struct pool_sym *sym; - int align; - - /* No constant equal to X is known to have been output. - Make a constant descriptor to enter X in the hash table. - Assign the label number and record it in the descriptor for - future calls to this function to find. */ - - desc = record_constant_rtx (mode, x); - desc->next = const_rtx_hash_table[hash]; - const_rtx_hash_table[hash] = desc; - - /* Align the location counter as required by EXP's data type. */ - align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode); - if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT) - align = BIGGEST_ALIGNMENT / BITS_PER_UNIT; - - pool_offset += align - 1; - pool_offset &= ~ (align - 1); - - /* Allocate a pool constant descriptor, fill it in, and chain it in. */ - - pool = (struct pool_constant *) oballoc (sizeof (struct pool_constant)); - pool->desc = desc; - pool->constant = x; - pool->mode = mode; - pool->labelno = const_labelno; - pool->align = align; - pool->offset = pool_offset; - pool->next = 0; - - if (last_pool == 0) - first_pool = pool; - else - last_pool->next = pool; - - last_pool = pool; - pool_offset += GET_MODE_SIZE (mode); - - /* Create a string containing the label name, in LABEL. */ - ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno); - - ++const_labelno; - - desc->label = found - = (char *) obstack_copy0 (saveable_obstack, label, strlen (label)); - - /* Add label to symbol hash table. */ - hash = SYMHASH (found); - sym = (struct pool_sym *) oballoc (sizeof (struct pool_sym)); - sym->label = found; - sym->pool = pool; - sym->next = const_rtx_sym_hash_table[hash]; - const_rtx_sym_hash_table[hash] = sym; - } - - /* We have a symbol name; construct the SYMBOL_REF and the MEM. */ - - def = gen_rtx (MEM, mode, gen_rtx (SYMBOL_REF, Pmode, found)); - - RTX_UNCHANGING_P (def) = 1; - /* Mark the symbol_ref as belonging to this constants pool. */ - CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1; - - if (GET_CODE (x) == CONST_DOUBLE) - { - if (CONST_DOUBLE_MEM (x) == cc0_rtx) - { - CONST_DOUBLE_CHAIN (x) = real_constant_chain; - real_constant_chain = x; - } - CONST_DOUBLE_MEM (x) = def; - } - - return def; -} - -/* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to - the corresponding pool_constant structure. */ - -static struct pool_constant * -find_pool_constant (addr) - rtx addr; -{ - struct pool_sym *sym; - char *label = XSTR (addr, 0); - - for (sym = const_rtx_sym_hash_table[SYMHASH (label)]; sym; sym = sym->next) - if (sym->label == label) - return sym->pool; - - abort (); -} - -/* Given a constant pool SYMBOL_REF, return the corresponding constant. */ - -rtx -get_pool_constant (addr) - rtx addr; -{ - return (find_pool_constant (addr))->constant; -} - -/* Similar, return the mode. */ - -enum machine_mode -get_pool_mode (addr) - rtx addr; -{ - return (find_pool_constant (addr))->mode; -} - -/* Similar, return the offset in the constant pool. */ - -int -get_pool_offset (addr) - rtx addr; -{ - return (find_pool_constant (addr))->offset; -} - -/* Write all the constants in the constant pool. */ - -void -output_constant_pool (fnname, fndecl) - char *fnname; - tree fndecl; -{ - struct pool_constant *pool; - rtx x; - -#ifdef ASM_OUTPUT_POOL_PROLOGUE - ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool_offset); -#endif - - for (pool = first_pool; pool; pool = pool->next) - { - x = pool->constant; - - /* First switch to correct section. */ -#ifdef SELECT_RTX_SECTION - SELECT_RTX_SECTION (pool->mode, x); -#else - text_section (); -#endif - - if (pool->align > 1) - ASM_OUTPUT_ALIGN (asm_out_file, exact_log2 (pool->align)); - - /* Output the label. */ - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", pool->labelno); - - /* Output the value of the constant itself. */ - if (GET_CODE (x) == CONST_DOUBLE) - { - union real_extract u; - - bcopy (&CONST_DOUBLE_LOW (x), &u, sizeof u); - switch (pool->mode) - { - /* Perhaps change the following to use - CONST_DOUBLE_LOW and CONST_DOUBLE_HIGH, rather than u.i. */ - case DImode: -#ifdef ASM_OUTPUT_DOUBLE_INT - ASM_OUTPUT_DOUBLE_INT (asm_out_file, x); -#else /* no ASM_OUTPUT_DOUBLE_INT */ -#ifndef WORDS_BIG_ENDIAN - /* Output two ints. */ - ASM_OUTPUT_INT (asm_out_file, - gen_rtx (CONST_INT, VOIDmode, u.i[0])); - ASM_OUTPUT_INT (asm_out_file, - gen_rtx (CONST_INT, VOIDmode, u.i[1])); -#else - /* Output two ints. */ - ASM_OUTPUT_INT (asm_out_file, - gen_rtx (CONST_INT, VOIDmode, u.i[1])); - ASM_OUTPUT_INT (asm_out_file, - gen_rtx (CONST_INT, VOIDmode, u.i[0])); -#endif /* WORDS_BIG_ENDIAN */ -#endif /* no ASM_OUTPUT_DOUBLE_INT */ - break; - - case DFmode: - ASM_OUTPUT_DOUBLE (asm_out_file, u.d); - break; - - case SFmode: - ASM_OUTPUT_FLOAT (asm_out_file, u.d); - } - } - else - switch (pool->mode) - { - case SImode: - ASM_OUTPUT_INT (asm_out_file, x); - break; - - case HImode: - ASM_OUTPUT_SHORT (asm_out_file, x); - break; - - case QImode: - ASM_OUTPUT_CHAR (asm_out_file, x); - break; - } - } - /* Done with this pool. */ - first_pool = last_pool = 0; -} - -/* Find all the constants whose addresses are referenced inside of EXP, - and make sure assembler code with a label has been output for each one. */ - -void -output_addressed_constants (exp) - tree exp; -{ - switch (TREE_CODE (exp)) - { - case ADDR_EXPR: - { - register tree constant = TREE_OPERAND (exp, 0); - - while (TREE_CODE (constant) == COMPONENT_REF) - { - constant = TREE_OPERAND (constant, 0); - } - - if (TREE_LITERAL (constant)) - /* No need to do anything here - for addresses of variables or functions. */ - output_constant_def (constant); - } - break; - - case PLUS_EXPR: - case MINUS_EXPR: - output_addressed_constants (TREE_OPERAND (exp, 0)); - output_addressed_constants (TREE_OPERAND (exp, 1)); - break; - - case NOP_EXPR: - case CONVERT_EXPR: - output_addressed_constants (TREE_OPERAND (exp, 0)); - break; - - case CONSTRUCTOR: - { - register tree link; - for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link)) - output_addressed_constants (TREE_VALUE (link)); - } - break; - - case ERROR_MARK: - break; - - default: - if (! TREE_LITERAL (exp)) - abort (); - } -} - -/* Output assembler code for constant EXP to FILE, with no label. - This includes the pseudo-op such as ".int" or ".byte", and a newline. - Assumes output_addressed_constants has been done on EXP already. - - Generate exactly SIZE bytes of assembler data, padding at the end - with zeros if necessary. SIZE must always be specified. - - SIZE is important for structure constructors, - since trailing members may have been omitted from the constructor. - It is also important for initialization of arrays from string constants - since the full length of the string constant might not be wanted. - It is also needed for initialization of unions, where the initializer's - type is just one member, and that may not be as long as the union. - - There a case in which we would fail to output exactly SIZE bytes: - for a structure constructor that wants to produce more than SIZE bytes. - But such constructors will never be generated for any possible input. */ - -void -output_constant (exp, size) - register tree exp; - register int size; -{ - register enum tree_code code = TREE_CODE (TREE_TYPE (exp)); - rtx x; - - if (size == 0) - return; - - /* Eliminate the NOP_EXPR that makes a cast not be an lvalue. - That way we get the constant (we hope) inside it. */ - if (TREE_CODE (exp) == NOP_EXPR - && TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0))) - exp = TREE_OPERAND (exp, 0); - - switch (code) - { - case INTEGER_TYPE: - case ENUMERAL_TYPE: - case POINTER_TYPE: - case REFERENCE_TYPE: - while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR) - exp = TREE_OPERAND (exp, 0); - -#ifndef ASM_OUTPUT_DOUBLE_INT - if (TYPE_MODE (TREE_TYPE (exp)) == DImode) - { - if (TREE_CODE (exp) == INTEGER_CST) - { -#ifndef WORDS_BIG_ENDIAN - ASM_OUTPUT_INT (asm_out_file, - gen_rtx (CONST_INT, VOIDmode, - TREE_INT_CST_LOW (exp))); - ASM_OUTPUT_INT (asm_out_file, - gen_rtx (CONST_INT, VOIDmode, - TREE_INT_CST_HIGH (exp))); -#else - ASM_OUTPUT_INT (asm_out_file, - gen_rtx (CONST_INT, VOIDmode, - TREE_INT_CST_HIGH (exp))); - ASM_OUTPUT_INT (asm_out_file, - gen_rtx (CONST_INT, VOIDmode, - TREE_INT_CST_LOW (exp))); -#endif - size -= GET_MODE_SIZE (DImode); - break; - } - else - error ("8-byte integer constant expression too complicated"); - - break; - } -#endif /* no ASM_OUTPUT_DOUBLE_INT */ - - x = expand_expr (exp, 0, VOIDmode, EXPAND_SUM); - - if (size == GET_MODE_SIZE (QImode)) - { - ASM_OUTPUT_CHAR (asm_out_file, x); - size -= GET_MODE_SIZE (QImode); - } - else if (size == GET_MODE_SIZE (HImode)) - { - ASM_OUTPUT_SHORT (asm_out_file, x); - size -= GET_MODE_SIZE (HImode); - } - else if (size == GET_MODE_SIZE (SImode)) - { - ASM_OUTPUT_INT (asm_out_file, x); - size -= GET_MODE_SIZE (SImode); - } -#ifdef ASM_OUTPUT_DOUBLE_INT - else if (size == GET_MODE_SIZE (DImode)) - { - ASM_OUTPUT_DOUBLE_INT (asm_out_file, x); - size -= GET_MODE_SIZE (DImode); - } -#endif /* ASM_OUTPUT_DOUBLE_INT */ - else - abort (); - - break; - - case REAL_TYPE: - if (TREE_CODE (exp) != REAL_CST) - error ("initializer for floating value is not a floating constant"); - else - { - REAL_VALUE_TYPE d; - jmp_buf output_constant_handler; - - d = TREE_REAL_CST (exp); - if (setjmp (output_constant_handler)) - { - error ("floating point trap outputting a constant"); -#ifdef REAL_IS_NOT_DOUBLE - bzero (&d, sizeof d); - d = REAL_VALUE_ATOF ("0"); -#else - d = 0; -#endif - } - set_float_handler (output_constant_handler); - - if (size < GET_MODE_SIZE (SFmode)) - break; - else if (size < GET_MODE_SIZE (DFmode)) - { - ASM_OUTPUT_FLOAT (asm_out_file, d); - size -= GET_MODE_SIZE (SFmode); - } - else - { - ASM_OUTPUT_DOUBLE (asm_out_file, d); - size -= GET_MODE_SIZE (DFmode); - } - set_float_handler (0); - } - break; - - case COMPLEX_TYPE: - output_constant (TREE_REALPART (exp), size / 2); - output_constant (TREE_IMAGPART (exp), size / 2); - size -= (size / 2) * 2; - break; - - case ARRAY_TYPE: - if (TREE_CODE (exp) == CONSTRUCTOR) - { - output_constructor (exp, size); - return; - } - else if (TREE_CODE (exp) == STRING_CST) - { - int excess = 0; - - if (size > TREE_STRING_LENGTH (exp)) - { - excess = size - TREE_STRING_LENGTH (exp); - size = TREE_STRING_LENGTH (exp); - } - - assemble_string (TREE_STRING_POINTER (exp), size); - size = excess; - } - else - abort (); - break; - - case RECORD_TYPE: - case UNION_TYPE: - if (TREE_CODE (exp) == CONSTRUCTOR) - output_constructor (exp, size); - else - abort (); - return; - } - - if (size > 0) - ASM_OUTPUT_SKIP (asm_out_file, size); -} - -/* Subroutine of output_constant, used for CONSTRUCTORs - (aggregate constants). - Generate at least SIZE bytes, padding if necessary. */ - -void -output_constructor (exp, size) - tree exp; - int size; -{ - register tree link, field = 0; - /* Number of bytes output or skipped so far. - In other words, current position within the constructor. */ - int total_bytes = 0; - /* Non-zero means BYTE contains part of a byte, to be output. */ - int byte_buffer_in_use = 0; - register int byte; - - if (HOST_BITS_PER_INT < BITS_PER_UNIT) - abort (); - - if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE - || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE) - field = TYPE_FIELDS (TREE_TYPE (exp)); - - /* As LINK goes through the elements of the constant, - FIELD goes through the structure fields, if the constant is a structure. - But the constant could also be an array. Then FIELD is zero. */ - for (link = CONSTRUCTOR_ELTS (exp); - link; - link = TREE_CHAIN (link), - field = field ? TREE_CHAIN (field) : 0) - { - tree val = TREE_VALUE (link); - - /* Eliminate the NOP_EXPR that makes a cast not be an lvalue. */ - if (TREE_CODE (val) == NOP_EXPR - && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0))) - val = TREE_OPERAND (val, 0); - - if (field == 0 - || (DECL_MODE (field) != BImode)) - { - register int fieldsize; - - /* An element that is not a bit-field. - Output any buffered-up bit-fields preceding it. */ - if (byte_buffer_in_use) - { - ASM_OUTPUT_BYTE (asm_out_file, byte); - total_bytes++; - byte_buffer_in_use = 0; - } - - /* Advance to offset of this element. - Note no alignment needed in an array, since that is guaranteed - if each element has the proper size. */ - if (field != 0 && DECL_OFFSET (field) / BITS_PER_UNIT != total_bytes) - { - ASM_OUTPUT_SKIP (asm_out_file, - (DECL_OFFSET (field) / BITS_PER_UNIT - - total_bytes)); - total_bytes = DECL_OFFSET (field) / BITS_PER_UNIT; - } - - /* Determine size this element should occupy. */ - if (field) - { - if (! TREE_LITERAL (DECL_SIZE (field))) - abort (); - fieldsize = TREE_INT_CST_LOW (DECL_SIZE (field)) - * DECL_SIZE_UNIT (field); - fieldsize = (fieldsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT; - } - else - fieldsize = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp))); - - /* Output the element's initial value. */ - output_constant (val, fieldsize); - - /* Count its size. */ - total_bytes += fieldsize; - } - else if (TREE_CODE (val) != INTEGER_CST) - error ("invalid initial value for member `%s'", - IDENTIFIER_POINTER (DECL_NAME (field))); - else - { - /* Element that is a bit-field. */ - - int next_offset = DECL_OFFSET (field); - int end_offset - = (next_offset - + (TREE_INT_CST_LOW (DECL_SIZE (field)) - * DECL_SIZE_UNIT (field))); - - /* If this field does not start in this (or, next) byte, - skip some bytes. */ - if (next_offset / BITS_PER_UNIT != total_bytes) - { - /* Output remnant of any bit field in previous bytes. */ - if (byte_buffer_in_use) - { - ASM_OUTPUT_BYTE (asm_out_file, byte); - total_bytes++; - byte_buffer_in_use = 0; - } - - /* If still not at proper byte, advance to there. */ - if (next_offset / BITS_PER_UNIT != total_bytes) - { - ASM_OUTPUT_SKIP (asm_out_file, - next_offset / BITS_PER_UNIT - total_bytes); - total_bytes = next_offset / BITS_PER_UNIT; - } - } - - if (! byte_buffer_in_use) - byte = 0; - - /* We must split the element into pieces that fall within - separate bytes, and combine each byte with previous or - following bit-fields. */ - - /* next_offset is the offset n fbits from the begining of - the structure to the next bit of this element to be processed. - end_offset is the offset of the first bit past the end of - this element. */ - while (next_offset < end_offset) - { - int this_time; - int next_byte = next_offset / BITS_PER_UNIT; - int next_bit = next_offset % BITS_PER_UNIT; - - /* Advance from byte to byte - within this element when necessary. */ - while (next_byte != total_bytes) - { - ASM_OUTPUT_BYTE (asm_out_file, byte); - total_bytes++; - byte = 0; - } - - /* Number of bits we can process at once - (all part of the same byte). */ - this_time = MIN (end_offset - next_offset, - BITS_PER_UNIT - next_bit); -#ifdef BYTES_BIG_ENDIAN - /* On big-endian machine, take the most significant bits - first (of the bits that are significant) - and put them into bytes from the most significant end. */ - byte |= (((TREE_INT_CST_LOW (val) - >> (end_offset - next_offset - this_time)) - & ((1 << this_time) - 1)) - << (BITS_PER_UNIT - this_time - next_bit)); -#else - /* On little-endian machines, - take first the least significant bits of the value - and pack them starting at the least significant - bits of the bytes. */ - byte |= ((TREE_INT_CST_LOW (val) - >> (next_offset - DECL_OFFSET (field))) - & ((1 << this_time) - 1)) << next_bit; -#endif - next_offset += this_time; - byte_buffer_in_use = 1; - } - } - } - if (byte_buffer_in_use) - { - ASM_OUTPUT_BYTE (asm_out_file, byte); - total_bytes++; - } - if (total_bytes < size) - ASM_OUTPUT_SKIP (asm_out_file, size - total_bytes); -} diff --git a/gnu/usr.bin/g++/cc1plus/version.c b/gnu/usr.bin/g++/cc1plus/version.c deleted file mode 100644 index 00d2df718fb8..000000000000 --- a/gnu/usr.bin/g++/cc1plus/version.c +++ /dev/null @@ -1 +0,0 @@ -char *version_string = "1.39.0 beta (based on GCC 1.39)"; diff --git a/gnu/usr.bin/g++/cc1plus/y.tab.h b/gnu/usr.bin/g++/cc1plus/y.tab.h deleted file mode 100644 index 762a26ff96a3..000000000000 --- a/gnu/usr.bin/g++/cc1plus/y.tab.h +++ /dev/null @@ -1,71 +0,0 @@ -#define IDENTIFIER 257 -#define TYPENAME 258 -#define SCSPEC 259 -#define TYPESPEC 260 -#define TYPE_QUAL 261 -#define CONSTANT 262 -#define STRING 263 -#define ELLIPSIS 264 -#define SIZEOF 265 -#define ENUM 266 -#define IF 267 -#define ELSE 268 -#define WHILE 269 -#define DO 270 -#define FOR 271 -#define SWITCH 272 -#define CASE 273 -#define DEFAULT 274 -#define BREAK 275 -#define CONTINUE 276 -#define RETURN 277 -#define GOTO 278 -#define ASM 279 -#define TYPEOF 280 -#define ALIGNOF 281 -#define ATTRIBUTE 282 -#define AGGR 283 -#define DELETE 284 -#define NEW 285 -#define OVERLOAD 286 -#define PRIVATE 287 -#define PUBLIC 288 -#define PROTECTED 289 -#define THIS 290 -#define OPERATOR 291 -#define DYNAMIC 292 -#define POINTSAT_LEFT_RIGHT 293 -#define LEFT_RIGHT 294 -#define SCOPE 295 -#define EMPTY 296 -#define TYPENAME_COLON 297 -#define ASSIGN 298 -#define RANGE 299 -#define OROR 300 -#define ANDAND 301 -#define MIN_MAX 302 -#define EQCOMPARE 303 -#define ARITHCOMPARE 304 -#define LSHIFT 305 -#define RSHIFT 306 -#define UNARY 307 -#define PLUSPLUS 308 -#define MINUSMINUS 309 -#define HYPERUNARY 310 -#define PAREN_STAR_PAREN 311 -#define PAREN_X_SCOPE_STAR_PAREN 312 -#define PAREN_X_SCOPE_REF_PAREN 313 -#define POINTSAT 314 -#define RAISE 315 -#define RAISES 316 -#define RERAISE 317 -#define TRY 318 -#define EXCEPT 319 -#define CATCH 320 -#define TYPENAME_SCOPE 321 -#define TYPENAME_ELLIPSIS 322 -#define PRE_PARSED_FUNCTION_DECL 323 -#define EXTERN_LANG_STRING 324 -#define ALL 325 -typedef union {long itype; tree ttype; enum tree_code code; } YYSTYPE; -extern YYSTYPE yylval; diff --git a/gnu/usr.bin/gas/config/i860.h b/gnu/usr.bin/gas/config/i860.h deleted file mode 100644 index 5025e7fe56aa..000000000000 --- a/gnu/usr.bin/gas/config/i860.h +++ /dev/null @@ -1,51 +0,0 @@ -/* i860.h -- Header file for the I860 - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: i860.h,v 1.2 1993/08/02 17:26:57 mycroft Exp $ -*/ - -enum reloc_type /* NOTE: three bits max, see struct reloc_info_i860.r_type */ -{ - NO_RELOC = 0, BRADDR, LOW0, LOW1, LOW2, LOW3, LOW4, SPLIT0, SPLIT1, SPLIT2, RELOC_32, -}; - -enum highlow_type /* NOTE: two bits max, see reloc_info_i860.r_type */ -{ - NO_SPEC = 0, PAIR, HIGH, HIGHADJ, -}; - -struct reloc_info_i860 -{ - unsigned long int r_address; -/* - * Using bit fields here is a bad idea because the order is not portable. :-( - */ - unsigned int r_symbolnum: 24; - unsigned int r_pcrel : 1; - unsigned int r_extern : 1; - /* combining the two field simplifies the argument passing in "new_fix()" */ - /* and is compatible with the existing Sparc #ifdef's */ - /* r_type: highlow_type - bits 5,4; reloc_type - bits 3-0 */ - unsigned int r_type : 6; - long int r_addend; -}; - -#define relocation_info reloc_info_i860 - - diff --git a/gnu/usr.bin/gas/config/m-hpux.h b/gnu/usr.bin/gas/config/m-hpux.h deleted file mode 100644 index f7383c27421c..000000000000 --- a/gnu/usr.bin/gas/config/m-hpux.h +++ /dev/null @@ -1,27 +0,0 @@ -/* m-hpux.h -- Header to compile the 68020 assembler under HP-UX - Copyright (C) 1988 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-hpux.h,v 1.2 1993/08/02 17:26:59 mycroft Exp $ -*/ - -/* This header file contains the #defines specific - to HPUX changes sent me by cph@zurich.ai.mit.edu */ -#ifndef hpux -#define hpux -#endif diff --git a/gnu/usr.bin/gas/config/m-sun3.h b/gnu/usr.bin/gas/config/m-sun3.h deleted file mode 100644 index f3c47922d09a..000000000000 --- a/gnu/usr.bin/gas/config/m-sun3.h +++ /dev/null @@ -1,34 +0,0 @@ -/* m-sun3.h -- 68020 version of the assembler for the Sun-3 - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-sun3.h,v 1.2 1993/08/02 17:27:01 mycroft Exp $ -*/ - - - -/* This header file contains the #defines specific - to SUN computer SUN 3 series computers. (The only kind - we have around here, unfortunatly.) - - Rumor has it that this file will work on the Sun-2 if the assembler - is called with -m68010 This is not tested. */ - - -#define M_SUN 1 -#define SUN_ASM_SYNTAX diff --git a/gnu/usr.bin/gas/config/m68k-opcode.h b/gnu/usr.bin/gas/config/m68k-opcode.h deleted file mode 100644 index f6cc2c0cf5d9..000000000000 --- a/gnu/usr.bin/gas/config/m68k-opcode.h +++ /dev/null @@ -1,1683 +0,0 @@ -/* Opcode table for m68000/m68020 and m68881. - Copyright (C) 1989, Free Software Foundation. - -This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler. - -Both GDB and GAS are free software; you can redistribute 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. - -GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m68k-opcode.h,v 1.2 1993/08/02 17:27:04 mycroft Exp $ -*/ - - -struct m68k_opcode -{ - char *name; - unsigned long opcode; - unsigned long match; - char *args; -}; - -/* We store four bytes of opcode for all opcodes because that - is the most any of them need. The actual length of an instruction - is always at least 2 bytes, and is as much longer as necessary to - hold the operands it has. - - The match component is a mask saying which bits must match - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing two characters - for each operand of the instruction. The first specifies - the kind of operand; the second, the place it is stored. */ - -/* Kinds of operands: - D data register only. Stored as 3 bits. - A address register only. Stored as 3 bits. - R either kind of register. Stored as 4 bits. - F floating point coprocessor register only. Stored as 3 bits. - O an offset (or width): immediate data 0-31 or data register. - Stored as 6 bits in special format for BF... insns. - + autoincrement only. Stored as 3 bits (number of the address register). - - autodecrement only. Stored as 3 bits (number of the address register). - Q quick immediate data. Stored as 3 bits. - This matches an immediate operand only when value is in range 1 .. 8. - M moveq immediate data. Stored as 8 bits. - This matches an immediate operand only when value is in range -128..127 - T trap vector immediate data. Stored as 4 bits. - - k K-factor for fmove.p instruction. Stored as a 7-bit constant or - a three bit register offset, depending on the field type. - - # immediate data. Stored in special places (b, w or l) - which say how many bits to store. - ^ immediate data for floating point instructions. Special places - are offset by 2 bytes from '#'... - B pc-relative address, converted to an offset - that is treated as immediate data. - d displacement and register. Stores the register as 3 bits - and stores the displacement in the entire second word. - - C the CCR. No need to store it; this is just for filtering validity. - S the SR. No need to store, just as with CCR. - U the USP. No need to store, just as with CCR. - - I Coprocessor ID. Not printed if 1. The Coprocessor ID is always - extracted from the 'd' field of word one, which means that an extended - coprocessor opcode can be skipped using the 'i' place, if needed. - - s System Control register for the floating point coprocessor. - S List of system control registers for floating point coprocessor. - - J Misc register for movec instruction, stored in 'j' format. - Possible values: - 000 SFC Source Function Code reg - 001 DFC Data Function Code reg - 002 CACR Cache Control Register - 800 USP User Stack Pointer - 801 VBR Vector Base reg - 802 CAAR Cache Address Register - 803 MSP Master Stack Pointer - 804 ISP Interrupt Stack Pointer - - L Register list of the type d0-d7/a0-a7 etc. - (New! Improved! Can also hold fp0-fp7, as well!) - The assembler tries to see if the registers match the insn by - looking at where the insn wants them stored. - - l Register list like L, but with all the bits reversed. - Used for going the other way. . . - - They are all stored as 6 bits using an address mode and a register number; - they differ in which addressing modes they match. - - * all (modes 0-6,7.*) - ~ alterable memory (modes 2-6,7.0,7.1)(not 0,1,7.~) - % alterable (modes 0-6,7.0,7.1)(not 7.~) - ; data (modes 0,2-6,7.*)(not 1) - @ data, but not immediate (modes 0,2-6,7.? ? ?)(not 1,7.?) This may really be ;, the 68020 book says it is - ! control (modes 2,5,6,7.*-)(not 0,1,3,4,7.4) - & alterable control (modes 2,5,6,7.0,7.1)(not 0,1,7.? ? ?) - $ alterable data (modes 0,2-6,7.0,7.1)(not 1,7.~) - ? alterable control, or data register (modes 0,2,5,6,7.0,7.1)(not 1,3,4,7.~) - / control, or data register (modes 0,2,5,6,7.0,7.1,7.2,7.3)(not 1,3,4,7.4) -*/ - -/* JF: for the 68851 */ -/* - I didn't use much imagination in choosing the - following codes, so many of them aren't very - mnemonic. -rab - - P pmmu register - Possible values: - 000 TC Translation Control reg - 100 CAL Current Access Level - 101 VAL Validate Access Level - 110 SCC Stack Change Control - 111 AC Access Control - - W wide pmmu registers - Possible values: - 001 DRP Dma Root Pointer - 010 SRP Supervisor Root Pointer - 011 CRP Cpu Root Pointer - - f function code register - 0 SFC - 1 DFC - - V VAL register only - - X BADx, BACx - 100 BAD Breakpoint Acknowledge Data - 101 BAC Breakpoint Acknowledge Control - - Y PSR - Z PCSR - - | memory (modes 2-6, 7.*) - -*/ - -/* Places to put an operand, for non-general operands: - s source, low bits of first word. - d dest, shifted 9 in first word - 1 second word, shifted 12 - 2 second word, shifted 6 - 3 second word, shifted 0 - 4 third word, shifted 12 - 5 third word, shifted 6 - 6 third word, shifted 0 - 7 second word, shifted 7 - 8 second word, shifted 10 - D store in both place 1 and place 3; for divul and divsl. - b second word, low byte - w second word (entire) - l second and third word (entire) - g branch offset for bra and similar instructions. - The place to store depends on the magnitude of offset. - t store in both place 7 and place 8; for floating point operations - c branch offset for cpBcc operations. - The place to store is word two if bit six of word one is zero, - and words two and three if bit six of word one is one. - i Increment by two, to skip over coprocessor extended operands. Only - works with the 'I' format. - k Dynamic K-factor field. Bits 6-4 of word 2, used as a register number. - Also used for dynamic fmovem instruction. - C floating point coprocessor constant - 7 bits. Also used for static - K-factors... - j Movec register #, stored in 12 low bits of second word. - - Places to put operand, for general operands: - d destination, shifted 6 bits in first word - b source, at low bit of first word, and immediate uses one byte - w source, at low bit of first word, and immediate uses two bytes - l source, at low bit of first word, and immediate uses four bytes - s source, at low bit of first word. - Used sometimes in contexts where immediate is not allowed anyway. - f single precision float, low bit of 1st word, immediate uses 4 bytes - F double precision float, low bit of 1st word, immediate uses 8 bytes - x extended precision float, low bit of 1st word, immediate uses 12 bytes - p packed float, low bit of 1st word, immediate uses 12 bytes -*/ - -#define one(x) ((x) << 16) -#define two(x, y) (((x) << 16) + y) - -/* - *** DANGER WILL ROBINSON *** - - The assembler requires that all instances of the same mnemonic must be - consecutive. If they aren't, the assembler will bomb at runtime - */ -struct m68k_opcode m68k_opcodes[] = -{ -{"abcd", one(0140400), one(0170770), "DsDd"}, -{"abcd", one(0140410), one(0170770), "-s-d"}, - - /* Add instructions */ -{"addal", one(0150700), one(0170700), "*lAd"}, -{"addaw", one(0150300), one(0170700), "*wAd"}, -{"addib", one(0003000), one(0177700), "#b$b"}, -{"addil", one(0003200), one(0177700), "#l$l"}, -{"addiw", one(0003100), one(0177700), "#w$w"}, -{"addqb", one(0050000), one(0170700), "Qd$b"}, -{"addql", one(0050200), one(0170700), "Qd%l"}, -{"addqw", one(0050100), one(0170700), "Qd%w"}, - -{"addb", one(0050000), one(0170700), "Qd$b"}, /* addq written as add */ -{"addb", one(0003000), one(0177700), "#b$b"}, /* addi written as add */ -{"addb", one(0150000), one(0170700), ";bDd"}, /* addb , Dd */ -{"addb", one(0150400), one(0170700), "Dd~b"}, /* addb Dd, */ - -{"addw", one(0050100), one(0170700), "Qd%w"}, /* addq written as add */ -{"addw", one(0003100), one(0177700), "#w$w"}, /* addi written as add */ -{"addw", one(0150300), one(0170700), "*wAd"}, /* adda written as add */ -{"addw", one(0150100), one(0170700), "*wDd"}, /* addw , Dd */ -{"addw", one(0150500), one(0170700), "Dd~w"}, /* addw Dd, */ - -{"addl", one(0050200), one(0170700), "Qd%l"}, /* addq written as add */ -{"addl", one(0003200), one(0177700), "#l$l"}, /* addi written as add */ -{"addl", one(0150700), one(0170700), "*lAd"}, /* adda written as add */ -{"addl", one(0150200), one(0170700), "*lDd"}, /* addl , Dd */ -{"addl", one(0150600), one(0170700), "Dd~l"}, /* addl Dd, */ - -{"addxb", one(0150400), one(0170770), "DsDd"}, -{"addxb", one(0150410), one(0170770), "-s-d"}, -{"addxl", one(0150600), one(0170770), "DsDd"}, -{"addxl", one(0150610), one(0170770), "-s-d"}, -{"addxw", one(0150500), one(0170770), "DsDd"}, -{"addxw", one(0150510), one(0170770), "-s-d"}, - -{"andib", one(0001000), one(0177700), "#b$b"}, -{"andib", one(0001074), one(0177777), "#bCb"}, /* andi to ccr */ -{"andiw", one(0001100), one(0177700), "#w$w"}, -{"andiw", one(0001174), one(0177777), "#wSw"}, /* andi to sr */ -{"andil", one(0001200), one(0177700), "#l$l"}, - -{"andb", one(0001000), one(0177700), "#b$b"}, /* andi written as or */ -{"andb", one(0001074), one(0177777), "#bCb"}, /* andi to ccr */ -{"andb", one(0140000), one(0170700), ";bDd"}, /* memory to register */ -{"andb", one(0140400), one(0170700), "Dd~b"}, /* register to memory */ -{"andw", one(0001100), one(0177700), "#w$w"}, /* andi written as or */ -{"andw", one(0001174), one(0177777), "#wSw"}, /* andi to sr */ -{"andw", one(0140100), one(0170700), ";wDd"}, /* memory to register */ -{"andw", one(0140500), one(0170700), "Dd~w"}, /* register to memory */ -{"andl", one(0001200), one(0177700), "#l$l"}, /* andi written as or */ -{"andl", one(0140200), one(0170700), ";lDd"}, /* memory to register */ -{"andl", one(0140600), one(0170700), "Dd~l"}, /* register to memory */ - -{"aslb", one(0160400), one(0170770), "QdDs"}, -{"aslb", one(0160440), one(0170770), "DdDs"}, -{"asll", one(0160600), one(0170770), "QdDs"}, -{"asll", one(0160640), one(0170770), "DdDs"}, -{"aslw", one(0160500), one(0170770), "QdDs"}, -{"aslw", one(0160540), one(0170770), "DdDs"}, -{"aslw", one(0160700), one(0177700), "~s"}, /* Shift memory */ -{"asrb", one(0160000), one(0170770), "QdDs"}, -{"asrb", one(0160040), one(0170770), "DdDs"}, -{"asrl", one(0160200), one(0170770), "QdDs"}, -{"asrl", one(0160240), one(0170770), "DdDs"}, -{"asrw", one(0160100), one(0170770), "QdDs"}, -{"asrw", one(0160140), one(0170770), "DdDs"}, -{"asrw", one(0160300), one(0177700), "~s"}, /* Shift memory */ - -{"bhi", one(0061000), one(0177400), "Bg"}, -{"bls", one(0061400), one(0177400), "Bg"}, -{"bcc", one(0062000), one(0177400), "Bg"}, -{"bcs", one(0062400), one(0177400), "Bg"}, -{"bne", one(0063000), one(0177400), "Bg"}, -{"beq", one(0063400), one(0177400), "Bg"}, -{"bvc", one(0064000), one(0177400), "Bg"}, -{"bvs", one(0064400), one(0177400), "Bg"}, -{"bpl", one(0065000), one(0177400), "Bg"}, -{"bmi", one(0065400), one(0177400), "Bg"}, -{"bge", one(0066000), one(0177400), "Bg"}, -{"blt", one(0066400), one(0177400), "Bg"}, -{"bgt", one(0067000), one(0177400), "Bg"}, -{"ble", one(0067400), one(0177400), "Bg"}, - -{"bchg", one(0000500), one(0170700), "Dd$s"}, -{"bchg", one(0004100), one(0177700), "#b$s"}, -{"bclr", one(0000600), one(0170700), "Dd$s"}, -{"bclr", one(0004200), one(0177700), "#b$s"}, -{"bfchg", two(0165300, 0), two(0177700, 0170000), "?sO2O3"}, -{"bfclr", two(0166300, 0), two(0177700, 0170000), "?sO2O3"}, -{"bfexts", two(0165700, 0), two(0177700, 0100000), "/sO2O3D1"}, -{"bfextu", two(0164700, 0), two(0177700, 0100000), "/sO2O3D1"}, -{"bfffo", two(0166700, 0), two(0177700, 0100000), "/sO2O3D1"}, -{"bfins", two(0167700, 0), two(0177700, 0100000), "D1?sO2O3"}, -{"bfset", two(0167300, 0), two(0177700, 0170000), "?sO2O3"}, -{"bftst", two(0164300, 0), two(0177700, 0170000), "/sO2O3"}, -{"bset", one(0000700), one(0170700), "Dd$s"}, -{"bset", one(0004300), one(0177700), "#b$s"}, -{"btst", one(0000400), one(0170700), "Dd@s"}, -{"btst", one(0004000), one(0177700), "#b@s"}, - -{"bkpt", one(0044110), one(0177770), "Qs"}, -{"bra", one(0060000), one(0177400), "Bg"}, -{"bras", one(0060000), one(0177400), "Bw"}, -{"bsr", one(0060400), one(0177400), "Bg"}, -{"bsrs", one(0060400), one(0177400), "Bw"}, - -{"callm", one(0003300), one(0177700), "#b!s"}, -{"cas2l", two(0007374, 0), two(0177777, 0107070), "D3D6D2D5R1R4"}, /* JF FOO this is really a 3 word ins */ -{"cas2w", two(0006374, 0), two(0177777, 0107070), "D3D6D2D5R1R4"}, /* JF ditto */ -{"casb", two(0005300, 0), two(0177700, 0177070), "D3D2~s"}, -{"casl", two(0007300, 0), two(0177700, 0177070), "D3D2~s"}, -{"casw", two(0006300, 0), two(0177700, 0177070), "D3D2~s"}, - -/* {"chk", one(0040600), one(0170700), ";wDd"}, JF FOO this looks wrong */ -{"chk2b", two(0000300, 0004000), two(0177700, 07777), "!sR1"}, -{"chk2l", two(0002300, 0004000), two(0177700, 07777), "!sR1"}, -{"chk2w", two(0001300, 0004000), two(0177700, 07777), "!sR1"}, -{"chkl", one(0040400), one(0170700), ";lDd"}, -{"chkw", one(0040600), one(0170700), ";wDd"}, -{"clrb", one(0041000), one(0177700), "$s"}, -{"clrl", one(0041200), one(0177700), "$s"}, -{"clrw", one(0041100), one(0177700), "$s"}, - -{"cmp2b", two(0000300, 0), two(0177700, 07777), "!sR1"}, -{"cmp2l", two(0002300, 0), two(0177700, 07777), "!sR1"}, -{"cmp2w", two(0001300, 0), two(0177700, 07777), "!sR1"}, -{"cmpal", one(0130700), one(0170700), "*lAd"}, -{"cmpaw", one(0130300), one(0170700), "*wAd"}, -{"cmpib", one(0006000), one(0177700), "#b;b"}, -{"cmpil", one(0006200), one(0177700), "#l;l"}, -{"cmpiw", one(0006100), one(0177700), "#w;w"}, -{"cmpb", one(0006000), one(0177700), "#b;b"}, /* cmpi written as cmp */ -{"cmpb", one(0130000), one(0170700), ";bDd"}, -{"cmpw", one(0006100), one(0177700), "#w;w"}, -{"cmpw", one(0130100), one(0170700), "*wDd"}, -{"cmpw", one(0130300), one(0170700), "*wAd"}, /* cmpa written as cmp */ -{"cmpl", one(0006200), one(0177700), "#l;l"}, -{"cmpl", one(0130200), one(0170700), "*lDd"}, -{"cmpl", one(0130700), one(0170700), "*lAd"}, -{"cmpmb", one(0130410), one(0170770), "+s+d"}, -{"cmpml", one(0130610), one(0170770), "+s+d"}, -{"cmpmw", one(0130510), one(0170770), "+s+d"}, - -{"dbcc", one(0052310), one(0177770), "DsBw"}, -{"dbcs", one(0052710), one(0177770), "DsBw"}, -{"dbeq", one(0053710), one(0177770), "DsBw"}, -{"dbf", one(0050710), one(0177770), "DsBw"}, -{"dbge", one(0056310), one(0177770), "DsBw"}, -{"dbgt", one(0057310), one(0177770), "DsBw"}, -{"dbhi", one(0051310), one(0177770), "DsBw"}, -{"dble", one(0057710), one(0177770), "DsBw"}, -{"dbls", one(0051710), one(0177770), "DsBw"}, -{"dblt", one(0056710), one(0177770), "DsBw"}, -{"dbmi", one(0055710), one(0177770), "DsBw"}, -{"dbne", one(0053310), one(0177770), "DsBw"}, -{"dbpl", one(0055310), one(0177770), "DsBw"}, -{"dbra", one(0050710), one(0177770), "DsBw"}, -{"dbt", one(0050310), one(0177770), "DsBw"}, -{"dbvc", one(0054310), one(0177770), "DsBw"}, -{"dbvs", one(0054710), one(0177770), "DsBw"}, - -{"divsl", two(0046100, 0006000), two(0177700, 0107770), ";lD3D1"}, -{"divsl", two(0046100, 0004000), two(0177700, 0107770), ";lDD"}, -{"divsll", two(0046100, 0004000), two(0177700, 0107770), ";lD3D1"}, -{"divsw", one(0100700), one(0170700), ";wDd"}, -{"divs", one(0100700), one(0170700), ";wDd"}, -{"divul", two(0046100, 0002000), two(0177700, 0107770), ";lD3D1"}, -{"divul", two(0046100, 0000000), two(0177700, 0107770), ";lDD"}, -{"divull", two(0046100, 0000000), two(0177700, 0107770), ";lD3D1"}, -{"divuw", one(0100300), one(0170700), ";wDd"}, -{"divu", one(0100300), one(0170700), ";wDd"}, -{"eorb", one(0005000), one(0177700), "#b$s"}, /* eori written as or */ -{"eorb", one(0005074), one(0177777), "#bCs"}, /* eori to ccr */ -{"eorb", one(0130400), one(0170700), "Dd$s"}, /* register to memory */ -{"eorib", one(0005000), one(0177700), "#b$s"}, -{"eorib", one(0005074), one(0177777), "#bCs"}, /* eori to ccr */ -{"eoril", one(0005200), one(0177700), "#l$s"}, -{"eoriw", one(0005100), one(0177700), "#w$s"}, -{"eoriw", one(0005174), one(0177777), "#wSs"}, /* eori to sr */ -{"eorl", one(0005200), one(0177700), "#l$s"}, -{"eorl", one(0130600), one(0170700), "Dd$s"}, -{"eorw", one(0005100), one(0177700), "#w$s"}, -{"eorw", one(0005174), one(0177777), "#wSs"}, /* eori to sr */ -{"eorw", one(0130500), one(0170700), "Dd$s"}, - -{"exg", one(0140500), one(0170770), "DdDs"}, -{"exg", one(0140510), one(0170770), "AdAs"}, -{"exg", one(0140610), one(0170770), "DdAs"}, -{"exg", one(0140610), one(0170770), "AsDd"}, - -{"extw", one(0044200), one(0177770), "Ds"}, -{"extl", one(0044300), one(0177770), "Ds"}, -{"extbl", one(0044700), one(0177770), "Ds"}, -{"extb.l", one(0044700), one(0177770), "Ds"}, /* Not sure we should support this one*/ - -{"illegal", one(0045374), one(0177777), ""}, -{"jmp", one(0047300), one(0177700), "!s"}, -{"jsr", one(0047200), one(0177700), "!s"}, -{"lea", one(0040700), one(0170700), "!sAd"}, -{"linkw", one(0047120), one(0177770), "As#w"}, -{"linkl", one(0044010), one(0177770), "As#l"}, -{"link", one(0047120), one(0177770), "As#w"}, -{"link", one(0044010), one(0177770), "As#l"}, - -{"lslb", one(0160410), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lslb", one(0160450), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ -{"lslw", one(0160510), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lslw", one(0160550), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ -{"lslw", one(0161700), one(0177700), "~s"}, /* Shift memory */ -{"lsll", one(0160610), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lsll", one(0160650), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ - -{"lsrb", one(0160010), one(0170770), "QdDs"} /* lsrb #Q, Ds */, -{"lsrb", one(0160050), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ -{"lsrl", one(0160210), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lsrl", one(0160250), one(0170770), "DdDs"}, /* lsrb #Q, Ds */ -{"lsrw", one(0160110), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lsrw", one(0160150), one(0170770), "DdDs"}, /* lsrb #Q, Ds */ -{"lsrw", one(0161300), one(0177700), "~s"}, /* Shift memory */ - -{"moveal", one(0020100), one(0170700), "*lAd"}, -{"moveaw", one(0030100), one(0170700), "*wAd"}, -{"moveb", one(0010000), one(0170000), ";b$d"}, /* move */ -{"movel", one(0070000), one(0170400), "MsDd"}, /* moveq written as move */ -{"movel", one(0020000), one(0170000), "*l$d"}, -{"movel", one(0020100), one(0170700), "*lAd"}, -{"movel", one(0047140), one(0177770), "AsUd"}, /* move to USP */ -{"movel", one(0047150), one(0177770), "UdAs"}, /* move from USP */ - -{"movec", one(0047173), one(0177777), "R1Jj"}, -{"movec", one(0047173), one(0177777), "R1#j"}, -{"movec", one(0047172), one(0177777), "JjR1"}, -{"movec", one(0047172), one(0177777), "#jR1"}, - -/* JF added these next four for the assembler */ -{"moveml", one(0044300), one(0177700), "Lw&s"}, /* movem reg to mem. */ -{"moveml", one(0044340), one(0177770), "lw-s"}, /* movem reg to autodecrement. */ -{"moveml", one(0046300), one(0177700), "!sLw"}, /* movem mem to reg. */ -{"moveml", one(0046330), one(0177770), "+sLw"}, /* movem autoinc to reg. */ - -{"moveml", one(0044300), one(0177700), "#w&s"}, /* movem reg to mem. */ -{"moveml", one(0044340), one(0177770), "#w-s"}, /* movem reg to autodecrement. */ -{"moveml", one(0046300), one(0177700), "!s#w"}, /* movem mem to reg. */ -{"moveml", one(0046330), one(0177770), "+s#w"}, /* movem autoinc to reg. */ - -/* JF added these next four for the assembler */ -{"movemw", one(0044200), one(0177700), "Lw&s"}, /* movem reg to mem. */ -{"movemw", one(0044240), one(0177770), "lw-s"}, /* movem reg to autodecrement. */ -{"movemw", one(0046200), one(0177700), "!sLw"}, /* movem mem to reg. */ -{"movemw", one(0046230), one(0177770), "+sLw"}, /* movem autoinc to reg. */ - -{"movemw", one(0044200), one(0177700), "#w&s"}, /* movem reg to mem. */ -{"movemw", one(0044240), one(0177770), "#w-s"}, /* movem reg to autodecrement. */ -{"movemw", one(0046200), one(0177700), "!s#w"}, /* movem mem to reg. */ -{"movemw", one(0046230), one(0177770), "+s#w"}, /* movem autoinc to reg. */ - -{"movepl", one(0000510), one(0170770), "dsDd"}, /* memory to register */ -{"movepl", one(0000710), one(0170770), "Ddds"}, /* register to memory */ -{"movepw", one(0000410), one(0170770), "dsDd"}, /* memory to register */ -{"movepw", one(0000610), one(0170770), "Ddds"}, /* register to memory */ -{"moveq", one(0070000), one(0170400), "MsDd"}, -{"movew", one(0030000), one(0170000), "*w$d"}, -{"movew", one(0030100), one(0170700), "*wAd"}, /* movea, written as move */ -{"movew", one(0040300), one(0177700), "Ss$s"}, /* Move from sr */ -{"movew", one(0041300), one(0177700), "Cs$s"}, /* Move from ccr */ -{"movew", one(0042300), one(0177700), ";wCd"}, /* move to ccr */ -{"movew", one(0043300), one(0177700), ";wSd"}, /* move to sr */ - -{"movesb", two(0007000, 0), two(0177700, 07777), "~sR1"}, /* moves from memory */ -{"movesb", two(0007000, 04000), two(0177700, 07777), "R1~s"}, /* moves to memory */ -{"movesl", two(0007200, 0), two(0177700, 07777), "~sR1"}, /* moves from memory */ -{"movesl", two(0007200, 04000), two(0177700, 07777), "R1~s"}, /* moves to memory */ -{"movesw", two(0007100, 0), two(0177700, 07777), "~sR1"}, /* moves from memory */ -{"movesw", two(0007100, 04000), two(0177700, 07777), "R1~s"}, /* moves to memory */ - -{"mulsl", two(0046000, 004000), two(0177700, 0107770), ";lD1"}, -{"mulsl", two(0046000, 006000), two(0177700, 0107770), ";lD3D1"}, -{"mulsw", one(0140700), one(0170700), ";wDd"}, -{"muls", one(0140700), one(0170700), ";wDd"}, -{"mulul", two(0046000, 000000), two(0177700, 0107770), ";lD1"}, -{"mulul", two(0046000, 002000), two(0177700, 0107770), ";lD3D1"}, -{"muluw", one(0140300), one(0170700), ";wDd"}, -{"mulu", one(0140300), one(0170700), ";wDd"}, -{"nbcd", one(0044000), one(0177700), "$s"}, -{"negb", one(0042000), one(0177700), "$s"}, -{"negl", one(0042200), one(0177700), "$s"}, -{"negw", one(0042100), one(0177700), "$s"}, -{"negxb", one(0040000), one(0177700), "$s"}, -{"negxl", one(0040200), one(0177700), "$s"}, -{"negxw", one(0040100), one(0177700), "$s"}, -{"nop", one(0047161), one(0177777), ""}, -{"notb", one(0043000), one(0177700), "$s"}, -{"notl", one(0043200), one(0177700), "$s"}, -{"notw", one(0043100), one(0177700), "$s"}, - -{"orb", one(0000000), one(0177700), "#b$s"}, /* ori written as or */ -{"orb", one(0000074), one(0177777), "#bCs"}, /* ori to ccr */ -{"orb", one(0100000), one(0170700), ";bDd"}, /* memory to register */ -{"orb", one(0100400), one(0170700), "Dd~s"}, /* register to memory */ -{"orib", one(0000000), one(0177700), "#b$s"}, -{"orib", one(0000074), one(0177777), "#bCs"}, /* ori to ccr */ -{"oril", one(0000200), one(0177700), "#l$s"}, -{"oriw", one(0000100), one(0177700), "#w$s"}, -{"oriw", one(0000174), one(0177777), "#wSs"}, /* ori to sr */ -{"orl", one(0000200), one(0177700), "#l$s"}, -{"orl", one(0100200), one(0170700), ";lDd"}, /* memory to register */ -{"orl", one(0100600), one(0170700), "Dd~s"}, /* register to memory */ -{"orw", one(0000100), one(0177700), "#w$s"}, -{"orw", one(0000174), one(0177777), "#wSs"}, /* ori to sr */ -{"orw", one(0100100), one(0170700), ";wDd"}, /* memory to register */ -{"orw", one(0100500), one(0170700), "Dd~s"}, /* register to memory */ - -{"pack", one(0100500), one(0170770), "DsDd#w"}, /* pack Ds, Dd, #w */ -{"pack", one(0100510), one(0170770), "-s-d#w"}, /* pack -(As), -(Ad), #w */ -{"pea", one(0044100), one(0177700), "!s"}, -{"reset", one(0047160), one(0177777), ""}, - -{"rolb", one(0160430), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rolb", one(0160470), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"roll", one(0160630), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"roll", one(0160670), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rolw", one(0160530), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rolw", one(0160570), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rolw", one(0163700), one(0177700), "~s"}, /* Rotate memory */ -{"rorb", one(0160030), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rorb", one(0160070), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rorl", one(0160230), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rorl", one(0160270), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rorw", one(0160130), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rorw", one(0160170), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rorw", one(0163300), one(0177700), "~s"}, /* Rotate memory */ - -{"roxlb", one(0160420), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxlb", one(0160460), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxll", one(0160620), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxll", one(0160660), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxlw", one(0160520), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxlw", one(0160560), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxlw", one(0162700), one(0177700), "~s"}, /* Rotate memory */ -{"roxrb", one(0160020), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxrb", one(0160060), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxrl", one(0160220), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxrl", one(0160260), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxrw", one(0160120), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxrw", one(0160160), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxrw", one(0162300), one(0177700), "~s"}, /* Rotate memory */ - -{"rtd", one(0047164), one(0177777), "#w"}, -{"rte", one(0047163), one(0177777), ""}, -{"rtm", one(0003300), one(0177760), "Rs"}, -{"rtr", one(0047167), one(0177777), ""}, -{"rts", one(0047165), one(0177777), ""}, - -{"scc", one(0052300), one(0177700), "$s"}, -{"scs", one(0052700), one(0177700), "$s"}, -{"seq", one(0053700), one(0177700), "$s"}, -{"sf", one(0050700), one(0177700), "$s"}, -{"sge", one(0056300), one(0177700), "$s"}, -{"sgt", one(0057300), one(0177700), "$s"}, -{"shi", one(0051300), one(0177700), "$s"}, -{"sle", one(0057700), one(0177700), "$s"}, -{"sls", one(0051700), one(0177700), "$s"}, -{"slt", one(0056700), one(0177700), "$s"}, -{"smi", one(0055700), one(0177700), "$s"}, -{"sne", one(0053300), one(0177700), "$s"}, -{"spl", one(0055300), one(0177700), "$s"}, -{"st", one(0050300), one(0177700), "$s"}, -{"svc", one(0054300), one(0177700), "$s"}, -{"svs", one(0054700), one(0177700), "$s"}, - -{"sbcd", one(0100400), one(0170770), "DsDd"}, -{"sbcd", one(0100410), one(0170770), "-s-d"}, -{"stop", one(0047162), one(0177777), "#w"}, - -{"subal", one(0110700), one(0170700), "*lAd"}, -{"subaw", one(0110300), one(0170700), "*wAd"}, -{"subb", one(0050400), one(0170700), "Qd%s"}, /* subq written as sub */ -{"subb", one(0002000), one(0177700), "#b$s"}, /* subi written as sub */ -{"subb", one(0110000), one(0170700), ";bDd"}, /* subb ? ?, Dd */ -{"subb", one(0110400), one(0170700), "Dd~s"}, /* subb Dd, ? ? */ -{"subib", one(0002000), one(0177700), "#b$s"}, -{"subil", one(0002200), one(0177700), "#l$s"}, -{"subiw", one(0002100), one(0177700), "#w$s"}, -{"subl", one(0050600), one(0170700), "Qd%s"}, -{"subl", one(0002200), one(0177700), "#l$s"}, -{"subl", one(0110700), one(0170700), "*lAd"}, -{"subl", one(0110200), one(0170700), "*lDd"}, -{"subl", one(0110600), one(0170700), "Dd~s"}, -{"subqb", one(0050400), one(0170700), "Qd%s"}, -{"subql", one(0050600), one(0170700), "Qd%s"}, -{"subqw", one(0050500), one(0170700), "Qd%s"}, -{"subw", one(0050500), one(0170700), "Qd%s"}, -{"subw", one(0002100), one(0177700), "#w$s"}, -{"subw", one(0110100), one(0170700), "*wDd"}, -{"subw", one(0110300), one(0170700), "*wAd"}, /* suba written as sub */ -{"subw", one(0110500), one(0170700), "Dd~s"}, -{"subxb", one(0110400), one(0170770), "DsDd"}, /* subxb Ds, Dd */ -{"subxb", one(0110410), one(0170770), "-s-d"}, /* subxb -(As), -(Ad) */ -{"subxl", one(0110600), one(0170770), "DsDd"}, -{"subxl", one(0110610), one(0170770), "-s-d"}, -{"subxw", one(0110500), one(0170770), "DsDd"}, -{"subxw", one(0110510), one(0170770), "-s-d"}, - -{"swap", one(0044100), one(0177770), "Ds"}, - -{"tas", one(0045300), one(0177700), "$s"}, -{"trap", one(0047100), one(0177760), "Ts"}, - -{"trapcc", one(0052374), one(0177777), ""}, -{"trapcs", one(0052774), one(0177777), ""}, -{"trapeq", one(0053774), one(0177777), ""}, -{"trapf", one(0050774), one(0177777), ""}, -{"trapge", one(0056374), one(0177777), ""}, -{"trapgt", one(0057374), one(0177777), ""}, -{"traphi", one(0051374), one(0177777), ""}, -{"traple", one(0057774), one(0177777), ""}, -{"trapls", one(0051774), one(0177777), ""}, -{"traplt", one(0056774), one(0177777), ""}, -{"trapmi", one(0055774), one(0177777), ""}, -{"trapne", one(0053374), one(0177777), ""}, -{"trappl", one(0055374), one(0177777), ""}, -{"trapt", one(0050374), one(0177777), ""}, -{"trapvc", one(0054374), one(0177777), ""}, -{"trapvs", one(0054774), one(0177777), ""}, - -{"trapcc.w", one(0052372), one(0177777), ""}, -{"trapcs.w", one(0052772), one(0177777), ""}, -{"trapeq.w", one(0053772), one(0177777), ""}, -{"trapf.w", one(0050772), one(0177777), ""}, -{"trapge.w", one(0056372), one(0177777), ""}, -{"trapgt.w", one(0057372), one(0177777), ""}, -{"traphi.w", one(0051372), one(0177777), ""}, -{"traple.w", one(0057772), one(0177777), ""}, -{"trapls.w", one(0051772), one(0177777), ""}, -{"traplt.w", one(0056772), one(0177777), ""}, -{"trapmi.w", one(0055772), one(0177777), ""}, -{"trapne.w", one(0053372), one(0177777), ""}, -{"trappl.w", one(0055372), one(0177777), ""}, -{"trapt.w", one(0050372), one(0177777), ""}, -{"trapvc.w", one(0054372), one(0177777), ""}, -{"trapvs.w", one(0054772), one(0177777), ""}, - -{"trapcc.l", one(0052373), one(0177777), ""}, -{"trapcs.l", one(0052773), one(0177777), ""}, -{"trapeq.l", one(0053773), one(0177777), ""}, -{"trapf.l", one(0050773), one(0177777), ""}, -{"trapge.l", one(0056373), one(0177777), ""}, -{"trapgt.l", one(0057373), one(0177777), ""}, -{"traphi.l", one(0051373), one(0177777), ""}, -{"traple.l", one(0057773), one(0177777), ""}, -{"trapls.l", one(0051773), one(0177777), ""}, -{"traplt.l", one(0056773), one(0177777), ""}, -{"trapmi.l", one(0055773), one(0177777), ""}, -{"trapne.l", one(0053373), one(0177777), ""}, -{"trappl.l", one(0055373), one(0177777), ""}, -{"trapt.l", one(0050373), one(0177777), ""}, -{"trapvc.l", one(0054373), one(0177777), ""}, -{"trapvs.l", one(0054773), one(0177777), ""}, - -{"trapv", one(0047166), one(0177777), ""}, - -{"tstb", one(0045000), one(0177700), ";b"}, -{"tstw", one(0045100), one(0177700), "*w"}, -{"tstl", one(0045200), one(0177700), "*l"}, - -{"unlk", one(0047130), one(0177770), "As"}, -{"unpk", one(0100600), one(0170770), "DsDd#w"}, -{"unpk", one(0100610), one(0170770), "-s-d#w"}, - /* JF floating pt stuff moved down here */ - -{"fabsb", two(0xF000, 0x5818), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fabsd", two(0xF000, 0x5418), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fabsl", two(0xF000, 0x4018), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fabsp", two(0xF000, 0x4C18), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fabss", two(0xF000, 0x4418), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fabsw", two(0xF000, 0x5018), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fabsx", two(0xF000, 0x4818), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiFt"}, - -{"facosb", two(0xF000, 0x581C), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"facosd", two(0xF000, 0x541C), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"facosl", two(0xF000, 0x401C), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"facosp", two(0xF000, 0x4C1C), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"facoss", two(0xF000, 0x441C), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"facosw", two(0xF000, 0x501C), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"facosx", two(0xF000, 0x481C), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiFt"}, - -{"faddb", two(0xF000, 0x5822), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"faddd", two(0xF000, 0x5422), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"faddl", two(0xF000, 0x4022), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"faddp", two(0xF000, 0x4C22), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fadds", two(0xF000, 0x4422), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"faddw", two(0xF000, 0x5022), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"faddx", two(0xF000, 0x4822), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiFt"}, JF removed */ - -{"fasinb", two(0xF000, 0x580C), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fasind", two(0xF000, 0x540C), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fasinl", two(0xF000, 0x400C), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fasinp", two(0xF000, 0x4C0C), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fasins", two(0xF000, 0x440C), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fasinw", two(0xF000, 0x500C), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fasinx", two(0xF000, 0x480C), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fatanb", two(0xF000, 0x580A), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fatand", two(0xF000, 0x540A), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fatanl", two(0xF000, 0x400A), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fatanp", two(0xF000, 0x4C0A), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fatans", two(0xF000, 0x440A), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fatanw", two(0xF000, 0x500A), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fatanx", two(0xF000, 0x480A), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fatanhb", two(0xF000, 0x580D), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fatanhd", two(0xF000, 0x540D), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fatanhl", two(0xF000, 0x400D), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fatanhp", two(0xF000, 0x4C0D), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fatanhs", two(0xF000, 0x440D), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fatanhw", two(0xF000, 0x500D), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fatanhx", two(0xF000, 0x480D), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fbeq", one(0xF081), one(0xF1BF), "IdBc"}, -{"fbf", one(0xF080), one(0xF1BF), "IdBc"}, -{"fbge", one(0xF093), one(0xF1BF), "IdBc"}, -{"fbgl", one(0xF096), one(0xF1BF), "IdBc"}, -{"fbgle", one(0xF097), one(0xF1BF), "IdBc"}, -{"fbgt", one(0xF092), one(0xF1BF), "IdBc"}, -{"fble", one(0xF095), one(0xF1BF), "IdBc"}, -{"fblt", one(0xF094), one(0xF1BF), "IdBc"}, -{"fbne", one(0xF08E), one(0xF1BF), "IdBc"}, -{"fbnge", one(0xF09C), one(0xF1BF), "IdBc"}, -{"fbngl", one(0xF099), one(0xF1BF), "IdBc"}, -{"fbngle", one(0xF098), one(0xF1BF), "IdBc"}, -{"fbngt", one(0xF09D), one(0xF1BF), "IdBc"}, -{"fbnle", one(0xF09A), one(0xF1BF), "IdBc"}, -{"fbnlt", one(0xF09B), one(0xF1BF), "IdBc"}, -{"fboge", one(0xF083), one(0xF1BF), "IdBc"}, -{"fbogl", one(0xF086), one(0xF1BF), "IdBc"}, -{"fbogt", one(0xF082), one(0xF1BF), "IdBc"}, -{"fbole", one(0xF085), one(0xF1BF), "IdBc"}, -{"fbolt", one(0xF084), one(0xF1BF), "IdBc"}, -{"fbor", one(0xF087), one(0xF1BF), "IdBc"}, -{"fbseq", one(0xF091), one(0xF1BF), "IdBc"}, -{"fbsf", one(0xF090), one(0xF1BF), "IdBc"}, -{"fbsne", one(0xF09E), one(0xF1BF), "IdBc"}, -{"fbst", one(0xF09F), one(0xF1BF), "IdBc"}, -{"fbt", one(0xF08F), one(0xF1BF), "IdBc"}, -{"fbueq", one(0xF089), one(0xF1BF), "IdBc"}, -{"fbuge", one(0xF08B), one(0xF1BF), "IdBc"}, -{"fbugt", one(0xF08A), one(0xF1BF), "IdBc"}, -{"fbule", one(0xF08D), one(0xF1BF), "IdBc"}, -{"fbult", one(0xF08C), one(0xF1BF), "IdBc"}, -{"fbun", one(0xF088), one(0xF1BF), "IdBc"}, - -{"fcmpb", two(0xF000, 0x5838), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fcmpd", two(0xF000, 0x5438), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fcmpl", two(0xF000, 0x4038), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fcmpp", two(0xF000, 0x4C38), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fcmps", two(0xF000, 0x4438), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fcmpw", two(0xF000, 0x5038), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fcmpx", two(0xF000, 0x4838), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiFt"}, JF removed */ - -{"fcosb", two(0xF000, 0x581D), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fcosd", two(0xF000, 0x541D), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fcosl", two(0xF000, 0x401D), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fcosp", two(0xF000, 0x4C1D), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fcoss", two(0xF000, 0x441D), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fcosw", two(0xF000, 0x501D), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fcosx", two(0xF000, 0x481D), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fcoshb", two(0xF000, 0x5819), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fcoshd", two(0xF000, 0x5419), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fcoshl", two(0xF000, 0x4019), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fcoshp", two(0xF000, 0x4C19), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fcoshs", two(0xF000, 0x4419), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fcoshw", two(0xF000, 0x5019), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fcoshx", two(0xF000, 0x4819), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fdbeq", two(0xF048, 0x0001), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbf", two(0xF048, 0x0000), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbge", two(0xF048, 0x0013), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbgl", two(0xF048, 0x0016), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbgle", two(0xF048, 0x0017), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbgt", two(0xF048, 0x0012), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdble", two(0xF048, 0x0015), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdblt", two(0xF048, 0x0014), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbne", two(0xF048, 0x000E), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbnge", two(0xF048, 0x001C), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbngl", two(0xF048, 0x0019), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbngle", two(0xF048, 0x0018), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbngt", two(0xF048, 0x001D), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbnle", two(0xF048, 0x001A), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbnlt", two(0xF048, 0x001B), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdboge", two(0xF048, 0x0003), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbogl", two(0xF048, 0x0006), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbogt", two(0xF048, 0x0002), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbole", two(0xF048, 0x0005), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbolt", two(0xF048, 0x0004), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbor", two(0xF048, 0x0007), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbseq", two(0xF048, 0x0011), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbsf", two(0xF048, 0x0010), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbsne", two(0xF048, 0x001E), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbst", two(0xF048, 0x001F), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbt", two(0xF048, 0x000F), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbueq", two(0xF048, 0x0009), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbuge", two(0xF048, 0x000B), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbugt", two(0xF048, 0x000A), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbule", two(0xF048, 0x000D), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbult", two(0xF048, 0x000C), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbun", two(0xF048, 0x0008), two(0xF1F8, 0xFFFF), "IiDsBw"}, - -{"fdivb", two(0xF000, 0x5820), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fdivd", two(0xF000, 0x5420), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fdivl", two(0xF000, 0x4020), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fdivp", two(0xF000, 0x4C20), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fdivs", two(0xF000, 0x4420), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fdivw", two(0xF000, 0x5020), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fdivx", two(0xF000, 0x4820), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"fetoxb", two(0xF000, 0x5810), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fetoxd", two(0xF000, 0x5410), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fetoxl", two(0xF000, 0x4010), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fetoxp", two(0xF000, 0x4C10), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fetoxs", two(0xF000, 0x4410), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fetoxw", two(0xF000, 0x5010), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fetoxx", two(0xF000, 0x4810), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fetoxm1b", two(0xF000, 0x5808), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fetoxm1d", two(0xF000, 0x5408), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fetoxm1l", two(0xF000, 0x4008), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fetoxm1p", two(0xF000, 0x4C08), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fetoxm1s", two(0xF000, 0x4408), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fetoxm1w", two(0xF000, 0x5008), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fetoxm1x", two(0xF000, 0x4808), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fgetexpb", two(0xF000, 0x581E), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fgetexpd", two(0xF000, 0x541E), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fgetexpl", two(0xF000, 0x401E), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fgetexpp", two(0xF000, 0x4C1E), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fgetexps", two(0xF000, 0x441E), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fgetexpw", two(0xF000, 0x501E), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fgetexpx", two(0xF000, 0x481E), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fgetmanb", two(0xF000, 0x581F), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fgetmand", two(0xF000, 0x541F), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fgetmanl", two(0xF000, 0x401F), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fgetmanp", two(0xF000, 0x4C1F), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fgetmans", two(0xF000, 0x441F), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fgetmanw", two(0xF000, 0x501F), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fgetmanx", two(0xF000, 0x481F), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fintb", two(0xF000, 0x5801), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fintd", two(0xF000, 0x5401), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fintl", two(0xF000, 0x4001), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fintp", two(0xF000, 0x4C01), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fints", two(0xF000, 0x4401), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fintw", two(0xF000, 0x5001), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fintx", two(0xF000, 0x4801), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fintrzb", two(0xF000, 0x5803), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fintrzd", two(0xF000, 0x5403), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fintrzl", two(0xF000, 0x4003), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fintrzp", two(0xF000, 0x4C03), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fintrzs", two(0xF000, 0x4403), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fintrzw", two(0xF000, 0x5003), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fintrzx", two(0xF000, 0x4803), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flog10b", two(0xF000, 0x5815), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flog10d", two(0xF000, 0x5415), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flog10l", two(0xF000, 0x4015), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flog10p", two(0xF000, 0x4C15), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flog10s", two(0xF000, 0x4415), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flog10w", two(0xF000, 0x5015), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flog10x", two(0xF000, 0x4815), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flog2b", two(0xF000, 0x5816), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flog2d", two(0xF000, 0x5416), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flog2l", two(0xF000, 0x4016), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flog2p", two(0xF000, 0x4C16), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flog2s", two(0xF000, 0x4416), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flog2w", two(0xF000, 0x5016), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flog2x", two(0xF000, 0x4816), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flognb", two(0xF000, 0x5814), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flognd", two(0xF000, 0x5414), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flognl", two(0xF000, 0x4014), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flognp", two(0xF000, 0x4C14), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flogns", two(0xF000, 0x4414), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flognw", two(0xF000, 0x5014), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flognx", two(0xF000, 0x4814), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flognp1b", two(0xF000, 0x5806), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flognp1d", two(0xF000, 0x5406), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flognp1l", two(0xF000, 0x4006), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flognp1p", two(0xF000, 0x4C06), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flognp1s", two(0xF000, 0x4406), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flognp1w", two(0xF000, 0x5006), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flognp1x", two(0xF000, 0x4806), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fmodb", two(0xF000, 0x5821), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fmodd", two(0xF000, 0x5421), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fmodl", two(0xF000, 0x4021), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fmodp", two(0xF000, 0x4C21), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fmods", two(0xF000, 0x4421), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fmodw", two(0xF000, 0x5021), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fmodx", two(0xF000, 0x4821), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"fmoveb", two(0xF000, 0x5800), two(0xF1C0, 0xFC7F), "Ii;bF7"}, /* fmove from to fp */ -{"fmoveb", two(0xF000, 0x7800), two(0xF1C0, 0xFC7F), "IiF7@b"}, /* fmove from fp to */ -{"fmoved", two(0xF000, 0x5400), two(0xF1C0, 0xFC7F), "Ii;FF7"}, /* fmove from to fp */ -{"fmoved", two(0xF000, 0x7400), two(0xF1C0, 0xFC7F), "IiF7@F"}, /* fmove from fp to */ -{"fmovel", two(0xF000, 0x4000), two(0xF1C0, 0xFC7F), "Ii;lF7"}, /* fmove from to fp */ -{"fmovel", two(0xF000, 0x6000), two(0xF1C0, 0xFC7F), "IiF7@l"}, /* fmove from fp to */ -/* Warning: The addressing modes on these are probably not right: - esp, Areg direct is only allowed for FPI */ - /* fmove.l from/to system control registers: */ -{"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, -{"fmovel", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ls8"}, - -/* {"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, -{"fmovel", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*ss8"}, */ - -{"fmovep", two(0xF000, 0x4C00), two(0xF1C0, 0xFC7F), "Ii;pF7"}, /* fmove from to fp */ -{"fmovep", two(0xF000, 0x6C00), two(0xF1C0, 0xFC00), "IiF7@pkC"}, /* fmove.p with k-factors: */ -{"fmovep", two(0xF000, 0x7C00), two(0xF1C0, 0xFC0F), "IiF7@pDk"}, /* fmove.p with k-factors: */ - -{"fmoves", two(0xF000, 0x4400), two(0xF1C0, 0xFC7F), "Ii;fF7"}, /* fmove from to fp */ -{"fmoves", two(0xF000, 0x6400), two(0xF1C0, 0xFC7F), "IiF7@f"}, /* fmove from fp to */ -{"fmovew", two(0xF000, 0x5000), two(0xF1C0, 0xFC7F), "Ii;wF7"}, /* fmove from to fp */ -{"fmovew", two(0xF000, 0x7000), two(0xF1C0, 0xFC7F), "IiF7@w"}, /* fmove from fp to */ -{"fmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiF8F7"}, /* fmove from to fp */ -{"fmovex", two(0xF000, 0x4800), two(0xF1C0, 0xFC7F), "Ii;xF7"}, /* fmove from to fp */ -{"fmovex", two(0xF000, 0x6800), two(0xF1C0, 0xFC7F), "IiF7@x"}, /* fmove from fp to */ -/* JF removed {"fmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiFt"}, / * fmove from to fp */ - -{"fmovecrx", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7"}, /* fmovecr.x #ccc, FPn */ -{"fmovecr", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7"}, - -/* Other fmovemx. */ -{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s"}, /* fmovem.x to autodecrement, static and dynamic */ -{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s"}, /* fmovem.x to autodecrement, static and dynamic */ - -{"fmovemx", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s"}, /* fmovem.x to autodecrement, static and dynamic */ - -{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3"}, /* fmovem.x from control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk"}, /* fmovem.x from control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3"}, /* fmovem.x from control, static and dynamic: */ - -{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovemx", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk"}, /* fmovem.x from autoincrement, static and dynamic: */ - -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8@s"}, -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Ii#8@s"}, -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, - -{"fmoveml", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8"}, -{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*s#8"}, -{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8"}, - -/* fmovemx with register lists */ -{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s"}, /* fmovem.x to autodecrement, static and dynamic */ -{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3"}, /* fmovem.x from control, static and dynamic: */ - - /* Alternate mnemonics for GNU as and GNU CC */ -{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s"}, /* fmovem.x to autodecrement, static and dynamic */ -{"fmovem", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s"}, /* fmovem.x to autodecrement, static and dynamic */ - -{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovem", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s"}, /* fmovem.x to control, static and dynamic: */ - -{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovem", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk"}, /* fmovem.x from autoincrement, static and dynamic: */ - -{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3"}, /* fmovem.x from control, static and dynamic: */ -{"fmovem", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk"}, /* fmovem.x from control, static and dynamic: */ - -/* fmoveml a FP-control register */ -{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, -{"fmovem", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8"}, - -/* fmoveml a FP-control reglist */ -{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8@s"}, -{"fmovem", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8"}, - -{"fmulb", two(0xF000, 0x5823), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fmuld", two(0xF000, 0x5423), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fmull", two(0xF000, 0x4023), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fmulp", two(0xF000, 0x4C23), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fmuls", two(0xF000, 0x4423), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fmulw", two(0xF000, 0x5023), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fmulx", two(0xF000, 0x4823), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"fnegb", two(0xF000, 0x581A), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fnegd", two(0xF000, 0x541A), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fnegl", two(0xF000, 0x401A), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fnegp", two(0xF000, 0x4C1A), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fnegs", two(0xF000, 0x441A), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fnegw", two(0xF000, 0x501A), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fnegx", two(0xF000, 0x481A), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fnop", two(0xF280, 0x0000), two(0xFFFF, 0xFFFF), "Ii"}, - -{"fremb", two(0xF000, 0x5825), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fremd", two(0xF000, 0x5425), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"freml", two(0xF000, 0x4025), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fremp", two(0xF000, 0x4C25), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"frems", two(0xF000, 0x4425), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fremw", two(0xF000, 0x5025), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fremx", two(0xF000, 0x4825), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"frestore", one(0xF140), one(0xF1C0), "Id&s"}, -{"frestore", one(0xF158), one(0xF1F8), "Id+s"}, -{"fsave", one(0xF100), one(0xF1C0), "Id&s"}, -{"fsave", one(0xF120), one(0xF1F8), "Id-s"}, - -{"fsincosb", two(0xF000, 0x5830), two(0xF1C0, 0xFC78), "Ii;bF3F7"}, -{"fsincosd", two(0xF000, 0x5430), two(0xF1C0, 0xFC78), "Ii;FF3F7"}, -{"fsincosl", two(0xF000, 0x4030), two(0xF1C0, 0xFC78), "Ii;lF3F7"}, -{"fsincosp", two(0xF000, 0x4C30), two(0xF1C0, 0xFC78), "Ii;pF3F7"}, -{"fsincoss", two(0xF000, 0x4430), two(0xF1C0, 0xFC78), "Ii;fF3F7"}, -{"fsincosw", two(0xF000, 0x5030), two(0xF1C0, 0xFC78), "Ii;wF3F7"}, -{"fsincosx", two(0xF000, 0x0030), two(0xF1C0, 0xE078), "IiF8F3F7"}, -{"fsincosx", two(0xF000, 0x4830), two(0xF1C0, 0xFC78), "Ii;xF3F7"}, - -{"fscaleb", two(0xF000, 0x5826), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fscaled", two(0xF000, 0x5426), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fscalel", two(0xF000, 0x4026), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fscalep", two(0xF000, 0x4C26), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fscales", two(0xF000, 0x4426), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fscalew", two(0xF000, 0x5026), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fscalex", two(0xF000, 0x4826), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -/* $ is necessary to prevent the assembler from using PC-relative. - If @ were used, "label: fseq label" could produce "ftrapeq", - because "label" became "pc@label". */ -{"fseq", two(0xF040, 0x0001), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsf", two(0xF040, 0x0000), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsge", two(0xF040, 0x0013), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsgl", two(0xF040, 0x0016), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsgle", two(0xF040, 0x0017), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsgt", two(0xF040, 0x0012), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsle", two(0xF040, 0x0015), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fslt", two(0xF040, 0x0014), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsne", two(0xF040, 0x000E), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsnge", two(0xF040, 0x001C), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsngl", two(0xF040, 0x0019), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsngle", two(0xF040, 0x0018), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsngt", two(0xF040, 0x001D), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsnle", two(0xF040, 0x001A), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsnlt", two(0xF040, 0x001B), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsoge", two(0xF040, 0x0003), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsogl", two(0xF040, 0x0006), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsogt", two(0xF040, 0x0002), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsole", two(0xF040, 0x0005), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsolt", two(0xF040, 0x0004), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsor", two(0xF040, 0x0007), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsseq", two(0xF040, 0x0011), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fssf", two(0xF040, 0x0010), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fssne", two(0xF040, 0x001E), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsst", two(0xF040, 0x001F), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fst", two(0xF040, 0x000F), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsueq", two(0xF040, 0x0009), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsuge", two(0xF040, 0x000B), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsugt", two(0xF040, 0x000A), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsule", two(0xF040, 0x000D), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsult", two(0xF040, 0x000C), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsun", two(0xF040, 0x0008), two(0xF1C0, 0xFFFF), "Ii$s"}, - -{"fsgldivb", two(0xF000, 0x5824), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsgldivd", two(0xF000, 0x5424), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsgldivl", two(0xF000, 0x4024), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsgldivp", two(0xF000, 0x4C24), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsgldivs", two(0xF000, 0x4424), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsgldivw", two(0xF000, 0x5024), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsgldivx", two(0xF000, 0x4824), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsglmulb", two(0xF000, 0x5827), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsglmuld", two(0xF000, 0x5427), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsglmull", two(0xF000, 0x4027), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsglmulp", two(0xF000, 0x4C27), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsglmuls", two(0xF000, 0x4427), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsglmulw", two(0xF000, 0x5027), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsglmulx", two(0xF000, 0x4827), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsinb", two(0xF000, 0x580E), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsind", two(0xF000, 0x540E), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsinl", two(0xF000, 0x400E), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsinp", two(0xF000, 0x4C0E), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsins", two(0xF000, 0x440E), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsinw", two(0xF000, 0x500E), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsinx", two(0xF000, 0x480E), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsinhb", two(0xF000, 0x5802), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsinhd", two(0xF000, 0x5402), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsinhl", two(0xF000, 0x4002), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsinhp", two(0xF000, 0x4C02), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsinhs", two(0xF000, 0x4402), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsinhw", two(0xF000, 0x5002), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsinhx", two(0xF000, 0x4802), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsqrtb", two(0xF000, 0x5804), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsqrtd", two(0xF000, 0x5404), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsqrtl", two(0xF000, 0x4004), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsqrtp", two(0xF000, 0x4C04), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsqrts", two(0xF000, 0x4404), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsqrtw", two(0xF000, 0x5004), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsqrtx", two(0xF000, 0x4804), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsubb", two(0xF000, 0x5828), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsubd", two(0xF000, 0x5428), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsubl", two(0xF000, 0x4028), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsubp", two(0xF000, 0x4C28), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsubs", two(0xF000, 0x4428), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsubw", two(0xF000, 0x5028), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsubx", two(0xF000, 0x4828), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftanb", two(0xF000, 0x580F), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftand", two(0xF000, 0x540F), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftanl", two(0xF000, 0x400F), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftanp", two(0xF000, 0x4C0F), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftans", two(0xF000, 0x440F), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftanw", two(0xF000, 0x500F), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftanx", two(0xF000, 0x480F), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftanhb", two(0xF000, 0x5809), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftanhd", two(0xF000, 0x5409), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftanhl", two(0xF000, 0x4009), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftanhp", two(0xF000, 0x4C09), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftanhs", two(0xF000, 0x4409), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftanhw", two(0xF000, 0x5009), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftanhx", two(0xF000, 0x4809), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftentoxb", two(0xF000, 0x5812), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftentoxd", two(0xF000, 0x5412), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftentoxl", two(0xF000, 0x4012), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftentoxp", two(0xF000, 0x4C12), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftentoxs", two(0xF000, 0x4412), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftentoxw", two(0xF000, 0x5012), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftentoxx", two(0xF000, 0x4812), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftrapeq", two(0xF07C, 0x0001), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapf", two(0xF07C, 0x0000), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapge", two(0xF07C, 0x0013), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapgl", two(0xF07C, 0x0016), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapgle", two(0xF07C, 0x0017), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapgt", two(0xF07C, 0x0012), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftraple", two(0xF07C, 0x0015), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftraplt", two(0xF07C, 0x0014), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapne", two(0xF07C, 0x000E), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapnge", two(0xF07C, 0x001C), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapngl", two(0xF07C, 0x0019), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapngle", two(0xF07C, 0x0018), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapngt", two(0xF07C, 0x001D), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapnle", two(0xF07C, 0x001A), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapnlt", two(0xF07C, 0x001B), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapoge", two(0xF07C, 0x0003), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapogl", two(0xF07C, 0x0006), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapogt", two(0xF07C, 0x0002), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapole", two(0xF07C, 0x0005), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapolt", two(0xF07C, 0x0004), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapor", two(0xF07C, 0x0007), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapseq", two(0xF07C, 0x0011), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapsf", two(0xF07C, 0x0010), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapsne", two(0xF07C, 0x001E), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapst", two(0xF07C, 0x001F), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapt", two(0xF07C, 0x000F), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapueq", two(0xF07C, 0x0009), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapuge", two(0xF07C, 0x000B), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapugt", two(0xF07C, 0x000A), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapule", two(0xF07C, 0x000D), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapult", two(0xF07C, 0x000C), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapun", two(0xF07C, 0x0008), two(0xF1FF, 0xFFFF), "Ii"}, - -{"ftrapeqw", two(0xF07A, 0x0001), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapfw", two(0xF07A, 0x0000), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapgew", two(0xF07A, 0x0013), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapglw", two(0xF07A, 0x0016), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapglew", two(0xF07A, 0x0017), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapgtw", two(0xF07A, 0x0012), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftraplew", two(0xF07A, 0x0015), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapltw", two(0xF07A, 0x0014), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnew", two(0xF07A, 0x000E), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapngew", two(0xF07A, 0x001C), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnglw", two(0xF07A, 0x0019), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnglew", two(0xF07A, 0x0018), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapngtw", two(0xF07A, 0x001D), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnlew", two(0xF07A, 0x001A), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnltw", two(0xF07A, 0x001B), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapogew", two(0xF07A, 0x0003), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapoglw", two(0xF07A, 0x0006), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapogtw", two(0xF07A, 0x0002), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapolew", two(0xF07A, 0x0005), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapoltw", two(0xF07A, 0x0004), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftraporw", two(0xF07A, 0x0007), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapseqw", two(0xF07A, 0x0011), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapsfw", two(0xF07A, 0x0010), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapsnew", two(0xF07A, 0x001E), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapstw", two(0xF07A, 0x001F), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftraptw", two(0xF07A, 0x000F), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapueqw", two(0xF07A, 0x0009), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapugew", two(0xF07A, 0x000B), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapugtw", two(0xF07A, 0x000A), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapulew", two(0xF07A, 0x000D), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapultw", two(0xF07A, 0x000C), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapunw", two(0xF07A, 0x0008), two(0xF1FF, 0xFFFF), "Ii^w"}, - -{"ftrapeql", two(0xF07B, 0x0001), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapfl", two(0xF07B, 0x0000), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapgel", two(0xF07B, 0x0013), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapgll", two(0xF07B, 0x0016), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapglel", two(0xF07B, 0x0017), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapgtl", two(0xF07B, 0x0012), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftraplel", two(0xF07B, 0x0015), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapltl", two(0xF07B, 0x0014), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnel", two(0xF07B, 0x000E), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapngel", two(0xF07B, 0x001C), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapngll", two(0xF07B, 0x0019), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnglel", two(0xF07B, 0x0018), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapngtl", two(0xF07B, 0x001D), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnlel", two(0xF07B, 0x001A), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnltl", two(0xF07B, 0x001B), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapogel", two(0xF07B, 0x0003), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapogll", two(0xF07B, 0x0006), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapogtl", two(0xF07B, 0x0002), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapolel", two(0xF07B, 0x0005), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapoltl", two(0xF07B, 0x0004), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftraporl", two(0xF07B, 0x0007), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapseql", two(0xF07B, 0x0011), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapsfl", two(0xF07B, 0x0010), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapsnel", two(0xF07B, 0x001E), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapstl", two(0xF07B, 0x001F), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftraptl", two(0xF07B, 0x000F), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapueql", two(0xF07B, 0x0009), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapugel", two(0xF07B, 0x000B), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapugtl", two(0xF07B, 0x000A), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapulel", two(0xF07B, 0x000D), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapultl", two(0xF07B, 0x000C), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapunl", two(0xF07B, 0x0008), two(0xF1FF, 0xFFFF), "Ii^l"}, - -{"ftstb", two(0xF000, 0x583A), two(0xF1C0, 0xFC7F), "Ii;b"}, -{"ftstd", two(0xF000, 0x543A), two(0xF1C0, 0xFC7F), "Ii;F"}, -{"ftstl", two(0xF000, 0x403A), two(0xF1C0, 0xFC7F), "Ii;l"}, -{"ftstp", two(0xF000, 0x4C3A), two(0xF1C0, 0xFC7F), "Ii;p"}, -{"ftsts", two(0xF000, 0x443A), two(0xF1C0, 0xFC7F), "Ii;f"}, -{"ftstw", two(0xF000, 0x503A), two(0xF1C0, 0xFC7F), "Ii;w"}, -{"ftstx", two(0xF000, 0x003A), two(0xF1C0, 0xE07F), "IiF8"}, -{"ftstx", two(0xF000, 0x483A), two(0xF1C0, 0xFC7F), "Ii;x"}, - -{"ftwotoxb", two(0xF000, 0x5811), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftwotoxd", two(0xF000, 0x5411), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftwotoxl", two(0xF000, 0x4011), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftwotoxp", two(0xF000, 0x4C11), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftwotoxs", two(0xF000, 0x4411), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftwotoxw", two(0xF000, 0x5011), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftwotoxx", two(0xF000, 0x4811), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiFt"}, - - -{"fjeq", one(0xF081), one(0xF1FF), "IdBc"}, -{"fjf", one(0xF080), one(0xF1FF), "IdBc"}, -{"fjge", one(0xF093), one(0xF1FF), "IdBc"}, -{"fjgl", one(0xF096), one(0xF1FF), "IdBc"}, -{"fjgle", one(0xF097), one(0xF1FF), "IdBc"}, -{"fjgt", one(0xF092), one(0xF1FF), "IdBc"}, -{"fjle", one(0xF095), one(0xF1FF), "IdBc"}, -{"fjlt", one(0xF094), one(0xF1FF), "IdBc"}, -{"fjne", one(0xF08E), one(0xF1FF), "IdBc"}, -{"fjnge", one(0xF09C), one(0xF1FF), "IdBc"}, -{"fjngl", one(0xF099), one(0xF1FF), "IdBc"}, -{"fjngle", one(0xF098), one(0xF1FF), "IdBc"}, -{"fjngt", one(0xF09D), one(0xF1FF), "IdBc"}, -{"fjnle", one(0xF09A), one(0xF1FF), "IdBc"}, -{"fjnlt", one(0xF09B), one(0xF1FF), "IdBc"}, -{"fjoge", one(0xF083), one(0xF1FF), "IdBc"}, -{"fjogl", one(0xF086), one(0xF1FF), "IdBc"}, -{"fjogt", one(0xF082), one(0xF1FF), "IdBc"}, -{"fjole", one(0xF085), one(0xF1FF), "IdBc"}, -{"fjolt", one(0xF084), one(0xF1FF), "IdBc"}, -{"fjor", one(0xF087), one(0xF1FF), "IdBc"}, -{"fjseq", one(0xF091), one(0xF1FF), "IdBc"}, -{"fjsf", one(0xF090), one(0xF1FF), "IdBc"}, -{"fjsne", one(0xF09E), one(0xF1FF), "IdBc"}, -{"fjst", one(0xF09F), one(0xF1FF), "IdBc"}, -{"fjt", one(0xF08F), one(0xF1FF), "IdBc"}, -{"fjueq", one(0xF089), one(0xF1FF), "IdBc"}, -{"fjuge", one(0xF08B), one(0xF1FF), "IdBc"}, -{"fjugt", one(0xF08A), one(0xF1FF), "IdBc"}, -{"fjule", one(0xF08D), one(0xF1FF), "IdBc"}, -{"fjult", one(0xF08C), one(0xF1FF), "IdBc"}, -{"fjun", one(0xF088), one(0xF1FF), "IdBc"}, - -/* The assembler will ignore attempts to force a short offset */ - -{"bhis", one(0061000), one(0177400), "Bg"}, -{"blss", one(0061400), one(0177400), "Bg"}, -{"bccs", one(0062000), one(0177400), "Bg"}, -{"bcss", one(0062400), one(0177400), "Bg"}, -{"bnes", one(0063000), one(0177400), "Bg"}, -{"beqs", one(0063400), one(0177400), "Bg"}, -{"bvcs", one(0064000), one(0177400), "Bg"}, -{"bvss", one(0064400), one(0177400), "Bg"}, -{"bpls", one(0065000), one(0177400), "Bg"}, -{"bmis", one(0065400), one(0177400), "Bg"}, -{"bges", one(0066000), one(0177400), "Bg"}, -{"blts", one(0066400), one(0177400), "Bg"}, -{"bgts", one(0067000), one(0177400), "Bg"}, -{"bles", one(0067400), one(0177400), "Bg"}, - -/* Alternate mnemonics for SUN */ - -{"jbsr", one(0060400), one(0177400), "Bg"}, -{"jbsr", one(0047200), one(0177700), "!s"}, -{"jra", one(0060000), one(0177400), "Bg"}, -{"jra", one(0047300), one(0177700), "!s"}, - -{"jhi", one(0061000), one(0177400), "Bg"}, -{"jls", one(0061400), one(0177400), "Bg"}, -{"jcc", one(0062000), one(0177400), "Bg"}, -{"jcs", one(0062400), one(0177400), "Bg"}, -{"jne", one(0063000), one(0177400), "Bg"}, -{"jeq", one(0063400), one(0177400), "Bg"}, -{"jvc", one(0064000), one(0177400), "Bg"}, -{"jvs", one(0064400), one(0177400), "Bg"}, -{"jpl", one(0065000), one(0177400), "Bg"}, -{"jmi", one(0065400), one(0177400), "Bg"}, -{"jge", one(0066000), one(0177400), "Bg"}, -{"jlt", one(0066400), one(0177400), "Bg"}, -{"jgt", one(0067000), one(0177400), "Bg"}, -{"jle", one(0067400), one(0177400), "Bg"}, - -/* Short offsets are ignored */ - -{"jbsrs", one(0060400), one(0177400), "Bg"}, -{"jras", one(0060000), one(0177400), "Bg"}, -{"jhis", one(0061000), one(0177400), "Bg"}, -{"jlss", one(0061400), one(0177400), "Bg"}, -{"jccs", one(0062000), one(0177400), "Bg"}, -{"jcss", one(0062400), one(0177400), "Bg"}, -{"jnes", one(0063000), one(0177400), "Bg"}, -{"jeqs", one(0063400), one(0177400), "Bg"}, -{"jvcs", one(0064000), one(0177400), "Bg"}, -{"jvss", one(0064400), one(0177400), "Bg"}, -{"jpls", one(0065000), one(0177400), "Bg"}, -{"jmis", one(0065400), one(0177400), "Bg"}, -{"jges", one(0066000), one(0177400), "Bg"}, -{"jlts", one(0066400), one(0177400), "Bg"}, -{"jgts", one(0067000), one(0177400), "Bg"}, -{"jles", one(0067400), one(0177400), "Bg"}, - -{"movql", one(0070000), one(0170400), "MsDd"}, -{"moveql", one(0070000), one(0170400), "MsDd"}, -{"moval", one(0020100), one(0170700), "*lAd"}, -{"movaw", one(0030100), one(0170700), "*wAd"}, -{"movb", one(0010000), one(0170000), ";b$d"}, /* mov */ -{"movl", one(0070000), one(0170400), "MsDd"}, /* movq written as mov */ -{"movl", one(0020000), one(0170000), "*l$d"}, -{"movl", one(0020100), one(0170700), "*lAd"}, -{"movl", one(0047140), one(0177770), "AsUd"}, /* mov to USP */ -{"movl", one(0047150), one(0177770), "UdAs"}, /* mov from USP */ -{"movc", one(0047173), one(0177777), "R1Jj"}, -{"movc", one(0047173), one(0177777), "R1#j"}, -{"movc", one(0047172), one(0177777), "JjR1"}, -{"movc", one(0047172), one(0177777), "#jR1"}, -{"movml", one(0044300), one(0177700), "#w&s"}, /* movm reg to mem. */ -{"movml", one(0044340), one(0177770), "#w-s"}, /* movm reg to autodecrement. */ -{"movml", one(0046300), one(0177700), "!s#w"}, /* movm mem to reg. */ -{"movml", one(0046330), one(0177770), "+s#w"}, /* movm autoinc to reg. */ -{"movml", one(0044300), one(0177700), "Lw&s"}, /* movm reg to mem. */ -{"movml", one(0044340), one(0177770), "lw-s"}, /* movm reg to autodecrement. */ -{"movml", one(0046300), one(0177700), "!sLw"}, /* movm mem to reg. */ -{"movml", one(0046330), one(0177770), "+sLw"}, /* movm autoinc to reg. */ -{"movmw", one(0044200), one(0177700), "#w&s"}, /* movm reg to mem. */ -{"movmw", one(0044240), one(0177770), "#w-s"}, /* movm reg to autodecrement. */ -{"movmw", one(0046200), one(0177700), "!s#w"}, /* movm mem to reg. */ -{"movmw", one(0046230), one(0177770), "+s#w"}, /* movm autoinc to reg. */ -{"movmw", one(0044200), one(0177700), "Lw&s"}, /* movm reg to mem. */ -{"movmw", one(0044240), one(0177770), "lw-s"}, /* movm reg to autodecrement. */ -{"movmw", one(0046200), one(0177700), "!sLw"}, /* movm mem to reg. */ -{"movmw", one(0046230), one(0177770), "+sLw"}, /* movm autoinc to reg. */ -{"movpl", one(0000510), one(0170770), "dsDd"}, /* memory to register */ -{"movpl", one(0000710), one(0170770), "Ddds"}, /* register to memory */ -{"movpw", one(0000410), one(0170770), "dsDd"}, /* memory to register */ -{"movpw", one(0000610), one(0170770), "Ddds"}, /* register to memory */ -{"movq", one(0070000), one(0170400), "MsDd"}, -{"movw", one(0030000), one(0170000), "*w$d"}, -{"movw", one(0030100), one(0170700), "*wAd"}, /* mova, written as mov */ -{"movw", one(0040300), one(0177700), "Ss$s"}, /* Move from sr */ -{"movw", one(0041300), one(0177700), "Cs$s"}, /* Move from ccr */ -{"movw", one(0042300), one(0177700), ";wCd"}, /* mov to ccr */ -{"movw", one(0043300), one(0177700), ";wSd"}, /* mov to sr */ - -{"movsb", two(0007000, 0), two(0177700, 07777), "~sR1"}, -{"movsb", two(0007000, 04000), two(0177700, 07777), "R1~s"}, -{"movsl", two(0007200, 0), two(0177700, 07777), "~sR1"}, -{"movsl", two(0007200, 04000), two(0177700, 07777), "R1~s"}, -{"movsw", two(0007100, 0), two(0177700, 07777), "~sR1"}, -{"movsw", two(0007100, 04000), two(0177700, 07777), "R1~s"}, - -#ifdef m68851 - /* name */ /* opcode */ /* match */ /* args */ - -{"pbac", one(0xf0c7), one(0xffbf), "Bc"}, -{"pbacw", one(0xf087), one(0xffbf), "Bc"}, -{"pbas", one(0xf0c6), one(0xffbf), "Bc"}, -{"pbasw", one(0xf086), one(0xffbf), "Bc"}, -{"pbbc", one(0xf0c1), one(0xffbf), "Bc"}, -{"pbbcw", one(0xf081), one(0xffbf), "Bc"}, -{"pbbs", one(0xf0c0), one(0xffbf), "Bc"}, -{"pbbsw", one(0xf080), one(0xffbf), "Bc"}, -{"pbcc", one(0xf0cf), one(0xffbf), "Bc"}, -{"pbccw", one(0xf08f), one(0xffbf), "Bc"}, -{"pbcs", one(0xf0ce), one(0xffbf), "Bc"}, -{"pbcsw", one(0xf08e), one(0xffbf), "Bc"}, -{"pbgc", one(0xf0cd), one(0xffbf), "Bc"}, -{"pbgcw", one(0xf08d), one(0xffbf), "Bc"}, -{"pbgs", one(0xf0cc), one(0xffbf), "Bc"}, -{"pbgsw", one(0xf08c), one(0xffbf), "Bc"}, -{"pbic", one(0xf0cb), one(0xffbf), "Bc"}, -{"pbicw", one(0xf08b), one(0xffbf), "Bc"}, -{"pbis", one(0xf0ca), one(0xffbf), "Bc"}, -{"pbisw", one(0xf08a), one(0xffbf), "Bc"}, -{"pblc", one(0xf0c3), one(0xffbf), "Bc"}, -{"pblcw", one(0xf083), one(0xffbf), "Bc"}, -{"pbls", one(0xf0c2), one(0xffbf), "Bc"}, -{"pblsw", one(0xf082), one(0xffbf), "Bc"}, -{"pbsc", one(0xf0c5), one(0xffbf), "Bc"}, -{"pbscw", one(0xf085), one(0xffbf), "Bc"}, -{"pbss", one(0xf0c4), one(0xffbf), "Bc"}, -{"pbssw", one(0xf084), one(0xffbf), "Bc"}, -{"pbwc", one(0xf0c9), one(0xffbf), "Bc"}, -{"pbwcw", one(0xf089), one(0xffbf), "Bc"}, -{"pbws", one(0xf0c8), one(0xffbf), "Bc"}, -{"pbwsw", one(0xf088), one(0xffbf), "Bc"}, - - -{"pdbac", two(0xf048, 0x0007), two(0xfff8, 0xffff), "DsBw"}, -{"pdbas", two(0xf048, 0x0006), two(0xfff8, 0xffff), "DsBw"}, -{"pdbbc", two(0xf048, 0x0001), two(0xfff8, 0xffff), "DsBw"}, -{"pdbbs", two(0xf048, 0x0000), two(0xfff8, 0xffff), "DsBw"}, -{"pdbcc", two(0xf048, 0x000f), two(0xfff8, 0xffff), "DsBw"}, -{"pdbcs", two(0xf048, 0x000e), two(0xfff8, 0xffff), "DsBw"}, -{"pdbgc", two(0xf048, 0x000d), two(0xfff8, 0xffff), "DsBw"}, -{"pdbgs", two(0xf048, 0x000c), two(0xfff8, 0xffff), "DsBw"}, -{"pdbic", two(0xf048, 0x000b), two(0xfff8, 0xffff), "DsBw"}, -{"pdbis", two(0xf048, 0x000a), two(0xfff8, 0xffff), "DsBw"}, -{"pdblc", two(0xf048, 0x0003), two(0xfff8, 0xffff), "DsBw"}, -{"pdbls", two(0xf048, 0x0002), two(0xfff8, 0xffff), "DsBw"}, -{"pdbsc", two(0xf048, 0x0005), two(0xfff8, 0xffff), "DsBw"}, -{"pdbss", two(0xf048, 0x0004), two(0xfff8, 0xffff), "DsBw"}, -{"pdbwc", two(0xf048, 0x0009), two(0xfff8, 0xffff), "DsBw"}, -{"pdbws", two(0xf048, 0x0008), two(0xfff8, 0xffff), "DsBw"}, - -{"pflusha", two(0xf000, 0x2400), two(0xffff, 0xffff), "" }, - -{"pflush", two(0xf000, 0x3010), two(0xffc0, 0xfe10), "T3T9" }, -{"pflush", two(0xf000, 0x3810), two(0xffc0, 0xfe10), "T3T9&s" }, -{"pflush", two(0xf000, 0x3008), two(0xffc0, 0xfe18), "D3T9" }, -{"pflush", two(0xf000, 0x3808), two(0xffc0, 0xfe18), "D3T9&s" }, -{"pflush", two(0xf000, 0x3000), two(0xffc0, 0xfe1e), "f3T9" }, -{"pflush", two(0xf000, 0x3800), two(0xffc0, 0xfe1e), "f3T9&s" }, - -{"pflushs", two(0xf000, 0x3410), two(0xfff8, 0xfe10), "T3T9" }, -{"pflushs", two(0xf000, 0x3c10), two(0xfff8, 0xfe00), "T3T9&s" }, -{"pflushs", two(0xf000, 0x3408), two(0xfff8, 0xfe18), "D3T9" }, -{"pflushs", two(0xf000, 0x3c08), two(0xfff8, 0xfe18), "D3T9&s" }, -{"pflushs", two(0xf000, 0x3400), two(0xfff8, 0xfe1e), "f3T9" }, -{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe1e), "f3T9&s"}, - -{"pflushr", two(0xf000, 0xa000), two(0xffc0, 0xffff), "|s" }, - -{"ploadr", two(0xf000, 0x2210), two(0xffc0, 0xfff0), "T3&s" }, -{"ploadr", two(0xf000, 0x2208), two(0xffc0, 0xfff8), "D3&s" }, -{"ploadr", two(0xf000, 0x2200), two(0xffc0, 0xfffe), "f3&s" }, -{"ploadw", two(0xf000, 0x2010), two(0xffc0, 0xfff0), "T3&s" }, -{"ploadw", two(0xf000, 0x2008), two(0xffc0, 0xfff8), "D3&s" }, -{"ploadw", two(0xf000, 0x2000), two(0xffc0, 0xfffe), "f3&s" }, - -/* TC, CRP, DRP, SRP, CAL, VAL, SCC, AC */ -{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "*sP8" }, -{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "P8%s" }, -{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "|sW8" }, -{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "W8~s" }, - -/* BADx, BACx */ -{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xe3e3), "*sX3" }, -{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xe3e3), "X3%s" }, - -/* PSR, PCSR */ -/* {"pmove", two(0xf000, 0x6100), two(oxffc0, oxffff), "*sZ8" }, */ -{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xffff), "*sY8" }, -{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xffff), "Y8%s" }, -{"pmove", two(0xf000, 0x6600), two(0xffc0, 0xffff), "Z8%s" }, - -{"prestore", one(0xf140), one(0xffc0), "&s"}, -{"prestore", one(0xf158), one(0xfff8), "+s"}, -{"psave", one(0xf100), one(0xffc0), "&s"}, -{"psave", one(0xf100), one(0xffc0), "+s"}, - -{"psac", two(0xf040, 0x0007), two(0xffc0, 0xffff), "@s"}, -{"psas", two(0xf040, 0x0006), two(0xffc0, 0xffff), "@s"}, -{"psbc", two(0xf040, 0x0001), two(0xffc0, 0xffff), "@s"}, -{"psbs", two(0xf040, 0x0000), two(0xffc0, 0xffff), "@s"}, -{"pscc", two(0xf040, 0x000f), two(0xffc0, 0xffff), "@s"}, -{"pscs", two(0xf040, 0x000e), two(0xffc0, 0xffff), "@s"}, -{"psgc", two(0xf040, 0x000d), two(0xffc0, 0xffff), "@s"}, -{"psgs", two(0xf040, 0x000c), two(0xffc0, 0xffff), "@s"}, -{"psic", two(0xf040, 0x000b), two(0xffc0, 0xffff), "@s"}, -{"psis", two(0xf040, 0x000a), two(0xffc0, 0xffff), "@s"}, -{"pslc", two(0xf040, 0x0003), two(0xffc0, 0xffff), "@s"}, -{"psls", two(0xf040, 0x0002), two(0xffc0, 0xffff), "@s"}, -{"pssc", two(0xf040, 0x0005), two(0xffc0, 0xffff), "@s"}, -{"psss", two(0xf040, 0x0004), two(0xffc0, 0xffff), "@s"}, -{"pswc", two(0xf040, 0x0009), two(0xffc0, 0xffff), "@s"}, -{"psws", two(0xf040, 0x0008), two(0xffc0, 0xffff), "@s"}, - -{"ptestr", two(0xf000, 0x8210), two(0xffc0, 0xe3f0), "T3&sQ8" }, -{"ptestr", two(0xf000, 0x8310), two(0xffc0, 0xe310), "T3&sQ8A9" }, -{"ptestr", two(0xf000, 0x8208), two(0xffc0, 0xe3f8), "D3&sQ8" }, -{"ptestr", two(0xf000, 0x8308), two(0xffc0, 0xe318), "D3&sQ8A9" }, -{"ptestr", two(0xf000, 0x8200), two(0xffc0, 0xe3fe), "f3&sQ8" }, -{"ptestr", two(0xf000, 0x8300), two(0xffc0, 0xe31e), "f3&sQ8A9" }, - -{"ptestw", two(0xf000, 0x8010), two(0xffc0, 0xe3f0), "T3&sQ8" }, -{"ptestw", two(0xf000, 0x8110), two(0xffc0, 0xe310), "T3&sQ8A9" }, -{"ptestw", two(0xf000, 0x8008), two(0xffc0, 0xe3f8), "D3&sQ8" }, -{"ptestw", two(0xf000, 0x8108), two(0xffc0, 0xe318), "D3&sQ8A9" }, -{"ptestw", two(0xf000, 0x8000), two(0xffc0, 0xe3fe), "f3&sQ8" }, -{"ptestw", two(0xf000, 0x8100), two(0xffc0, 0xe31e), "f3&sQ8A9" }, - -{"ptrapacw", two(0xf07a, 0x0007), two(0xffff, 0xffff), "#w"}, -{"ptrapacl", two(0xf07b, 0x0007), two(0xffff, 0xffff), "#l"}, -{"ptrapac", two(0xf07c, 0x0007), two(0xffff, 0xffff), ""}, - -{"ptrapasw", two(0xf07a, 0x0006), two(0xffff, 0xffff), "#w"}, -{"ptrapasl", two(0xf07b, 0x0006), two(0xffff, 0xffff), "#l"}, -{"ptrapas", two(0xf07c, 0x0006), two(0xffff, 0xffff), ""}, - -{"ptrapbcw", two(0xf07a, 0x0001), two(0xffff, 0xffff), "#w"}, -{"ptrapbcl", two(0xf07b, 0x0001), two(0xffff, 0xffff), "#l"}, -{"ptrapbc", two(0xf07c, 0x0001), two(0xffff, 0xffff), ""}, - -{"ptrapbsw", two(0xf07a, 0x0000), two(0xffff, 0xffff), "#w"}, -{"ptrapbsl", two(0xf07b, 0x0000), two(0xffff, 0xffff), "#l"}, -{"ptrapbs", two(0xf07c, 0x0000), two(0xffff, 0xffff), ""}, - -{"ptrapccw", two(0xf07a, 0x000f), two(0xffff, 0xffff), "#w"}, -{"ptrapccl", two(0xf07b, 0x000f), two(0xffff, 0xffff), "#l"}, -{"ptrapcc", two(0xf07c, 0x000f), two(0xffff, 0xffff), ""}, - -{"ptrapcsw", two(0xf07a, 0x000e), two(0xffff, 0xffff), "#w"}, -{"ptrapcsl", two(0xf07b, 0x000e), two(0xffff, 0xffff), "#l"}, -{"ptrapcs", two(0xf07c, 0x000e), two(0xffff, 0xffff), ""}, - -{"ptrapgcw", two(0xf07a, 0x000d), two(0xffff, 0xffff), "#w"}, -{"ptrapgcl", two(0xf07b, 0x000d), two(0xffff, 0xffff), "#l"}, -{"ptrapgc", two(0xf07c, 0x000d), two(0xffff, 0xffff), ""}, - -{"ptrapgsw", two(0xf07a, 0x000c), two(0xffff, 0xffff), "#w"}, -{"ptrapgsl", two(0xf07b, 0x000c), two(0xffff, 0xffff), "#l"}, -{"ptrapgs", two(0xf07c, 0x000c), two(0xffff, 0xffff), ""}, - -{"ptrapicw", two(0xf07a, 0x000b), two(0xffff, 0xffff), "#w"}, -{"ptrapicl", two(0xf07b, 0x000b), two(0xffff, 0xffff), "#l"}, -{"ptrapic", two(0xf07c, 0x000b), two(0xffff, 0xffff), ""}, - -{"ptrapisw", two(0xf07a, 0x000a), two(0xffff, 0xffff), "#w"}, -{"ptrapisl", two(0xf07b, 0x000a), two(0xffff, 0xffff), "#l"}, -{"ptrapis", two(0xf07c, 0x000a), two(0xffff, 0xffff), ""}, - -{"ptraplcw", two(0xf07a, 0x0003), two(0xffff, 0xffff), "#w"}, -{"ptraplcl", two(0xf07b, 0x0003), two(0xffff, 0xffff), "#l"}, -{"ptraplc", two(0xf07c, 0x0003), two(0xffff, 0xffff), ""}, - -{"ptraplsw", two(0xf07a, 0x0002), two(0xffff, 0xffff), "#w"}, -{"ptraplsl", two(0xf07b, 0x0002), two(0xffff, 0xffff), "#l"}, -{"ptrapls", two(0xf07c, 0x0002), two(0xffff, 0xffff), ""}, - -{"ptrapscw", two(0xf07a, 0x0005), two(0xffff, 0xffff), "#w"}, -{"ptrapscl", two(0xf07b, 0x0005), two(0xffff, 0xffff), "#l"}, -{"ptrapsc", two(0xf07c, 0x0005), two(0xffff, 0xffff), ""}, - -{"ptrapssw", two(0xf07a, 0x0004), two(0xffff, 0xffff), "#w"}, -{"ptrapssl", two(0xf07b, 0x0004), two(0xffff, 0xffff), "#l"}, -{"ptrapss", two(0xf07c, 0x0004), two(0xffff, 0xffff), ""}, - -{"ptrapwcw", two(0xf07a, 0x0009), two(0xffff, 0xffff), "#w"}, -{"ptrapwcl", two(0xf07b, 0x0009), two(0xffff, 0xffff), "#l"}, -{"ptrapwc", two(0xf07c, 0x0009), two(0xffff, 0xffff), ""}, - -{"ptrapwsw", two(0xf07a, 0x0008), two(0xffff, 0xffff), "#w"}, -{"ptrapwsl", two(0xf07b, 0x0008), two(0xffff, 0xffff), "#l"}, -{"ptrapws", two(0xf07c, 0x0008), two(0xffff, 0xffff), ""}, - -{"pvalid", two(0xf000, 0x2800), two(0xffc0, 0xffff), "Vs&s"}, -{"pvalid", two(0xf000, 0x2c00), two(0xffc0, 0xfff8), "A3&s" }, - -#endif /* m68851 */ - -}; - -int numopcodes=sizeof(m68k_opcodes)/sizeof(m68k_opcodes[0]); - -struct m68k_opcode *endop = m68k_opcodes+sizeof(m68k_opcodes)/sizeof(m68k_opcodes[0]); diff --git a/gnu/usr.bin/gas/config/m68k.c b/gnu/usr.bin/gas/config/m68k.c deleted file mode 100644 index 9dc2876cff5e..000000000000 --- a/gnu/usr.bin/gas/config/m68k.c +++ /dev/null @@ -1,3544 +0,0 @@ -/* m68k.c All the m68020 specific stuff in one convenient, huge, - slow to compile, easy to find file. - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: m68k.c,v 1.2 1993/08/02 17:27:08 mycroft Exp $"; -#endif /* not lint */ - -#include - -#include "m68k-opcode.h" -#include "as.h" -#include "obstack.h" -#include "frags.h" -#include "struc-symbol.h" -#include "flonum.h" -#include "expr.h" -#include "hash.h" -#include "md.h" -#include "m68k.h" - -#ifdef M_SUN -/* This variable contains the value to write out at the beginning of - the a.out file. The 2<<16 means that this is a 68020 file instead - of an old-style 68000 file */ - -long omagic = 2<<16|OMAGIC; /* Magic byte for header file */ -#else -long omagic = OMAGIC; -#endif - - -/* This array holds the chars that always start a comment. If the - pre-processor is disabled, these aren't very useful */ -const char comment_chars[] = "|"; - -/* This array holds the chars that only start a comment at the beginning of - a line. If the line seems to have the form '# 123 filename' - .line and .file directives will appear in the pre-processed output */ -/* Note that input_file.c hand checks for '#' at the beginning of the - first line of the input file. This is because the compiler outputs - #NO_APP at the beginning of its output. */ -/* Also note that '/*' will always start a comment */ -const char line_comment_chars[] = "#"; - -/* Chars that can be used to separate mant from exp in floating point nums */ -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* As in 0f12.456 */ -/* or 0d1.2345e12 */ - -const char FLT_CHARS[] = "rRsSfFdDxXeEpP"; - -/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be - changed in read.c . Ideally it shouldn't have to know about it at all, - but nothing is ideal around here. - */ - -void fix_new(); -void install_operand(); -void install_gen_operand(); - -/* Its an arbitrary name: This means I don't approve of it */ -/* See flames below */ -struct obstack robyn; - -#define TAB(x,y) (((x)<<2)+(y)) -#define TABTYPE(xy) ((xy) >> 2) -#define BYTE 0 -#define SHORT 1 -#define LONG 2 -#define SZ_UNDEF 3 - -#define BRANCH 1 -#define FBRANCH 2 -#define PCREL 3 -#define BCC68000 4 -#define DBCC 5 -#define PCLEA 6 - -/* BCC68000 is for patching in an extra jmp instruction for long offsets - on the 68000. The 68000 doesn't support long branches with branchs */ - -/* This table desribes how you change sizes for the various types of variable - size expressions. This version only supports two kinds. */ - -/* Note that calls to frag_var need to specify the maximum expansion needed */ -/* This is currently 10 bytes for DBCC */ - -/* The fields are: - How far Forward this mode will reach: - How far Backward this mode will reach: - How many bytes this mode will add to the size of the frag - Which mode to go to if the offset won't fit in this one - */ -const relax_typeS -md_relax_table[] = { -{ 1, 1, 0, 0 }, /* First entries aren't used */ -{ 1, 1, 0, 0 }, /* For no good reason except */ -{ 1, 1, 0, 0 }, /* that the VAX doesn't either */ -{ 1, 1, 0, 0 }, - -{ (127), (-128), 0, TAB(BRANCH,SHORT)}, -{ (32767), (-32768), 2, TAB(BRANCH,LONG) }, -{ 0, 0, 4, 0 }, -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE */ -{ (32767), (-32768), 2, TAB(FBRANCH,LONG)}, -{ 0, 0, 4, 0 }, -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* PCREL doesn't come BYTE */ -{ (32767), (-32768), 2, TAB(PCREL,LONG)}, -{ 0, 0, 4, 0 }, -{ 1, 1, 0, 0 }, - -{ (127), (-128), 0, TAB(BCC68000,SHORT)}, -{ (32767), (-32768), 2, TAB(BCC68000,LONG) }, -{ 0, 0, 6, 0 }, /* jmp long space */ -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* DBCC doesn't come BYTE */ -{ (32767), (-32768), 2, TAB(DBCC,LONG) }, -{ 0, 0, 10, 0 }, /* bra/jmp long space */ -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* PCLEA doesn't come BYTE */ -{ 32767, -32768, 2, TAB(PCLEA,LONG) }, -{ 0, 0, 6, 0 }, -{ 1, 1, 0, 0 }, - -}; - -void s_data1(), s_data2(), s_even(), s_space(); -void s_proc(), float_cons(); - -/* These are the machine dependent pseudo-ops. These are included so - the assembler can work on the output from the SUN C compiler, which - generates these. - */ - -/* This table describes all the machine specific pseudo-ops the assembler - has to support. The fields are: - pseudo-op name without dot - function to call to execute this pseudo-op - Integer arg to pass to the function - */ -const pseudo_typeS md_pseudo_table[] = { - { "data1", s_data1, 0 }, - { "data2", s_data2, 0 }, - { "even", s_even, 0 }, - { "skip", s_space, 0 }, - { "proc", s_proc, 0 }, - { 0, 0, 0 } -}; - - -/* #define isbyte(x) ((x)>=-128 && (x)<=127) */ -/* #define isword(x) ((x)>=-32768 && (x)<=32767) */ - -#define issbyte(x) ((x)>=-128 && (x)<=127) -#define isubyte(x) ((x)>=0 && (x)<=255) -#define issword(x) ((x)>=-32768 && (x)<=32767) -#define isuword(x) ((x)>=0 && (x)<=65535) - -#define isbyte(x) ((x)>=-128 && (x)<=255) -#define isword(x) ((x)>=-32768 && (x)<=65535) -#define islong(x) (1) - -extern char *input_line_pointer; - -/* Operands we can parse: (And associated modes) - -numb: 8 bit num -numw: 16 bit num -numl: 32 bit num -dreg: data reg 0-7 -reg: address or data register -areg: address register -apc: address register, PC, ZPC or empty string -num: 16 or 32 bit num -num2: like num -sz: w or l if omitted, l assumed -scale: 1 2 4 or 8 if omitted, 1 assumed - -7.4 IMMED #num --> NUM -0.? DREG dreg --> dreg -1.? AREG areg --> areg -2.? AINDR areg@ --> *(areg) -3.? AINC areg@+ --> *(areg++) -4.? ADEC areg@- --> *(--areg) -5.? AOFF apc@(numw) --> *(apc+numw) -- empty string and ZPC not allowed here -6.? AINDX apc@(num,reg:sz:scale) --> *(apc+num+reg*scale) -6.? AINDX apc@(reg:sz:scale) --> same, with num=0 -6.? APODX apc@(num)@(num2,reg:sz:scale) --> *(*(apc+num)+num2+reg*scale) -6.? APODX apc@(num)@(reg:sz:scale) --> same, with num2=0 -6.? AMIND apc@(num)@(num2) --> *(*(apc+num)+num2) (previous mode without an index reg) -6.? APRDX apc@(num,reg:sz:scale)@(num2) --> *(*(apc+num+reg*scale)+num2) -6.? APRDX apc@(reg:sz:scale)@(num2) --> same, with num=0 -7.0 ABSL num:sz --> *(num) - num --> *(num) (sz L assumed) -*** MSCR otherreg --> Magic -With -l option -5.? AOFF apc@(num) --> *(apc+num) -- empty string and ZPC not allowed here still - -examples: - #foo #0x35 #12 - d2 - a4 - a3@ - a5@+ - a6@- - a2@(12) pc@(14) - a1@(5,d2:w:1) @(45,d6:l:4) - pc@(a2) @(d4) - etc . . . - - -#name@(numw) -->turn into PC rel mode -apc@(num8,reg:sz:scale) --> *(apc+num8+reg*scale) - -*/ - -#define IMMED 1 -#define DREG 2 -#define AREG 3 -#define AINDR 4 -#define ADEC 5 -#define AINC 6 -#define AOFF 7 -#define AINDX 8 -#define APODX 9 -#define AMIND 10 -#define APRDX 11 -#define ABSL 12 -#define MSCR 13 -#define REGLST 14 - -#define FAIL 0 -#define OK 1 - -/* DATA and ADDR have to be contiguous, so that reg-DATA gives 0-7==data reg, - 8-15==addr reg for operands that take both types */ -#define DATA 1 /* 1- 8 == data registers 0-7 */ -#define ADDR (DATA+8) /* 9-16 == address regs 0-7 */ -#define FPREG (ADDR+8) /* 17-24 Eight FP registers */ -#define COPNUM (FPREG+8) /* 25-32 Co-processor #1-#8 */ - -#define PC (COPNUM+8) /* 33 Program counter */ -#define ZPC (PC+1) /* 34 Hack for Program space, but 0 addressing */ -#define SR (ZPC+1) /* 35 Status Reg */ -#define CCR (SR+1) /* 36 Condition code Reg */ - -/* These have to be in order for the movec instruction to work. */ -#define USP (CCR+1) /* 37 User Stack Pointer */ -#define ISP (USP+1) /* 38 Interrupt stack pointer */ -#define SFC (ISP+1) /* 39 */ -#define DFC (SFC+1) /* 40 */ -#define CACR (DFC+1) /* 41 */ -#define VBR (CACR+1) /* 42 */ -#define CAAR (VBR+1) /* 43 */ -#define MSP (CAAR+1) /* 44 */ - -#define FPI (MSP+1) /* 45 */ -#define FPS (FPI+1) /* 46 */ -#define FPC (FPS+1) /* 47 */ -/* - * these defines should be in m68k.c but - * i put them here to keep all the m68851 stuff - * together -rab - * JF--Make sure these #s don't clash with the ones in m68k.c - * That would be BAD. - */ -#define TC (FPC+1) /* 48 */ -#define DRP (TC+1) /* 49 */ -#define SRP (DRP+1) /* 50 */ -#define CRP (SRP+1) /* 51 */ -#define CAL (CRP+1) /* 52 */ -#define VAL (CAL+1) /* 53 */ -#define SCC (VAL+1) /* 54 */ -#define AC (SCC+1) /* 55 */ -#define BAD (AC+1) /* 56,57,58,59, 60,61,62,63 */ -#define BAC (BAD+8) /* 64,65,66,67, 68,69,70,71 */ -#define PSR (BAC+8) /* 72 */ -#define PCSR (PSR+1) /* 73 */ - - -/* Note that COPNUM==processor #1 -- COPNUM+7==#8, which stores as 000 */ -/* I think. . . */ - -#define SP ADDR+7 - -/* JF these tables here are for speed at the expense of size */ -/* You can replace them with the #if 0 versions if you really - need space and don't mind it running a bit slower */ - -static char mklower_table[256]; -#define mklower(c) (mklower_table[(unsigned char)(c)]) -static char notend_table[256]; -static char alt_notend_table[256]; -#define notend(s) ( !(notend_table[(unsigned char)(*s)] || (*s==':' &&\ - alt_notend_table[(unsigned char)(s[1])]))) - -#if 0 -#define mklower(c) (isupper(c) ? tolower(c) : c) -#endif - - -struct m68k_exp { - char *e_beg; - char *e_end; - expressionS e_exp; - short e_siz; /* 0== default 1==short/byte 2==word 3==long */ -}; - -/* Internal form of an operand. */ -struct m68k_op { - char *error; /* Couldn't parse it */ - int mode; /* What mode this instruction is in. */ - unsigned long int reg; /* Base register */ - struct m68k_exp *con1; - int ireg; /* Index register */ - int isiz; /* 0==unspec 1==byte(?) 2==short 3==long */ - int imul; /* Multipy ireg by this (1,2,4,or 8) */ - struct m68k_exp *con2; -}; - -/* internal form of a 68020 instruction */ -struct m68_it { - char *error; - char *args; /* list of opcode info */ - int numargs; - - int numo; /* Number of shorts in opcode */ - short opcode[11]; - - struct m68k_op operands[6]; - - int nexp; /* number of exprs in use */ - struct m68k_exp exprs[4]; - - int nfrag; /* Number of frags we have to produce */ - struct { - int fragoff; /* Where in the current opcode[] the frag ends */ - symbolS *fadd; - long int foff; - int fragty; - } fragb[4]; - - int nrel; /* Num of reloc strucs in use */ - struct { - int n; - symbolS *add, - *sub; - long int off; - char wid; - char pcrel; - } reloc[5]; /* Five is enough??? */ -}; - -struct m68_it the_ins; /* the instruction being assembled */ - - -/* Macros for adding things to the m68_it struct */ - -#define addword(w) the_ins.opcode[the_ins.numo++]=(w) - -/* Like addword, but goes BEFORE general operands */ -#define insop(w) {int z;\ - for(z=the_ins.numo;z>opcode->m_codenum;--z)\ - the_ins.opcode[z]=the_ins.opcode[z-1];\ - for(z=0;zm_codenum]=w;\ - the_ins.numo++;\ -} - - -#define add_exp(beg,end) (\ - the_ins.exprs[the_ins.nexp].e_beg=beg,\ - the_ins.exprs[the_ins.nexp].e_end=end,\ - &the_ins.exprs[the_ins.nexp++]\ -) - - -/* The numo+1 kludge is so we can hit the low order byte of the prev word. Blecch*/ -#define add_fix(width,exp,pc_rel) {\ - the_ins.reloc[the_ins.nrel].n= ((width)=='B') ? (the_ins.numo*2-1) : \ - (((width)=='b') ? ((the_ins.numo-1)*2) : (the_ins.numo*2));\ - the_ins.reloc[the_ins.nrel].add=adds((exp));\ - the_ins.reloc[the_ins.nrel].sub=subs((exp));\ - the_ins.reloc[the_ins.nrel].off=offs((exp));\ - the_ins.reloc[the_ins.nrel].wid=width;\ - the_ins.reloc[the_ins.nrel++].pcrel=pc_rel;\ -} - -#define add_frag(add,off,type) {\ - the_ins.fragb[the_ins.nfrag].fragoff=the_ins.numo;\ - the_ins.fragb[the_ins.nfrag].fadd=add;\ - the_ins.fragb[the_ins.nfrag].foff=off;\ - the_ins.fragb[the_ins.nfrag++].fragty=type;\ -} - -#define isvar(exp) ((exp) && (adds(exp) || subs(exp))) - -#define seg(exp) ((exp)->e_exp.X_seg) -#define adds(exp) ((exp)->e_exp.X_add_symbol) -#define subs(exp) ((exp)->e_exp.X_subtract_symbol) -#define offs(exp) ((exp)->e_exp.X_add_number) - - -struct m68_incant { - char *m_operands; - unsigned long m_opcode; - short m_opnum; - short m_codenum; - struct m68_incant *m_next; -}; - -#define getone(x) ((((x)->m_opcode)>>16)&0xffff) -#define gettwo(x) (((x)->m_opcode)&0xffff) - - -/* JF modified this to handle cases where the first part of a symbol name - looks like a register */ - -int -m68k_reg_parse(ccp) -register char **ccp; -{ - register char c1, - c2, - c3, - c4; - register int n = 0, - ret = FAIL; - - c1=mklower(ccp[0][0]); -#ifdef REGISTER_PREFIX - if(c1!=REGISTER_PREFIX) - return FAIL; - c1=mklower(ccp[0][1]); - c2=mklower(ccp[0][2]); - c3=mklower(ccp[0][3]); - c4=mklower(ccp[0][4]); -#else - c2=mklower(ccp[0][1]); - c3=mklower(ccp[0][2]); - c4=mklower(ccp[0][3]); -#endif - switch(c1) { - case 'a': - if(c2>='0' && c2<='7') { - n=2; - ret=ADDR+c2-'0'; - } -#ifdef m68851 - else if (c2 == 'c') { - n = 2; - ret = AC; - } -#endif - break; -#ifdef m68851 - case 'b': - if (c2 == 'a') { - if (c3 == 'd') { - if (c4 >= '0' && c4 <= '7') { - n = 4; - ret = BAD + c4 - '0'; - } - } - if (c3 == 'c') { - if (c4 >= '0' && c4 <= '7') { - n = 4; - ret = BAC + c4 - '0'; - } - } - } - break; -#endif - case 'c': -#ifdef m68851 - if (c2 == 'a' && c3 == 'l') { - n = 3; - ret = CAL; - } else -#endif - /* This supports both CCR and CC as the ccr reg. */ - if(c2=='c' && c3=='r') { - n=3; - ret = CCR; - } else if(c2=='c') { - n=2; - ret = CCR; - } else if(c2=='a' && (c3=='a' || c3=='c') && c4=='r') { - n=4; - ret = c3=='a' ? CAAR : CACR; - } -#ifdef m68851 - else if (c2 == 'r' && c3 == 'p') { - n = 3; - ret = (CRP); - } -#endif - break; - case 'd': - if(c2>='0' && c2<='7') { - n=2; - ret = DATA+c2-'0'; - } else if(c2=='f' && c3=='c') { - n=3; - ret = DFC; - } -#ifdef m68851 - else if (c2 == 'r' && c3 == 'p') { - n = 3; - ret = (DRP); - } -#endif - break; - case 'f': - if(c2=='p') { - if(c3>='0' && c3<='7') { - n=3; - ret = FPREG+c3-'0'; - if(c4==':') - ccp[0][3]=','; - } else if(c3=='i') { - n=3; - ret = FPI; - } else if(c3=='s') { - n= (c4 == 'r' ? 4 : 3); - ret = FPS; - } else if(c3=='c') { - n= (c4 == 'r' ? 4 : 3); - ret = FPC; - } - } - break; - case 'i': - if(c2=='s' && c3=='p') { - n=3; - ret = ISP; - } - break; - case 'm': - if(c2=='s' && c3=='p') { - n=3; - ret = MSP; - } - break; - case 'p': - if(c2=='c') { -#ifdef m68851 - if(c3 == 's' && c4=='r') { - n=4; - ret = (PCSR); - } else -#endif - { - n=2; - ret = PC; - } - } -#ifdef m68851 - else if (c2 == 's' && c3 == 'r') { - n = 3; - ret = (PSR); - } -#endif - break; - case 's': -#ifdef m68851 - if (c2 == 'c' && c3 == 'c') { - n = 3; - ret = (SCC); - } else if (c2 == 'r' && c3 == 'p') { - n = 3; - ret = (SRP); - } else -#endif - if(c2=='r') { - n=2; - ret = SR; - } else if(c2=='p') { - n=2; - ret = ADDR+7; - } else if(c2=='f' && c3=='c') { - n=3; - ret = SFC; - } - break; -#ifdef m68851 - case 't': - if(c2 == 'c') { - n=2; - ret=TC; - } - break; -#endif - case 'u': - if(c2=='s' && c3=='p') { - n=3; - ret = USP; - } - break; - case 'v': -#ifdef m68851 - if (c2 == 'a' && c3 == 'l') { - n = 3; - ret = (VAL); - } else -#endif - if(c2=='b' && c3=='r') { - n=3; - ret = VBR; - } - break; - case 'z': - if(c2=='p' && c3=='c') { - n=3; - ret = ZPC; - } - break; - default: - break; - } - if(n) { -#ifdef REGISTER_PREFIX - n++; -#endif - if(isalnum(ccp[0][n]) || ccp[0][n]=='_') - ret=FAIL; - else - ccp[0]+=n; - } else - ret = FAIL; - return ret; -} - -#define SKIP_WHITE() { str++; if(*str==' ') str++;} - -int -m68k_ip_op(str,opP) -char *str; -register struct m68k_op *opP; -{ - char *strend; - long i; - char *parse_index(); - - if(*str==' ') - str++; - /* Find the end of the string */ - if(!*str) { - /* Out of gas */ - opP->error="Missing operand"; - return FAIL; - } - for(strend=str;*strend;strend++) - ; - --strend; - - /* Guess what: A constant. Shar and enjoy */ - if(*str=='#') { - str++; - opP->con1=add_exp(str,strend); - opP->mode=IMMED; - return OK; - } - i=m68k_reg_parse(&str); - if((i==FAIL || *str!='\0') && *str!='@') { - char *stmp; - char *index(); - - if(i!=FAIL && (*str=='/' || *str=='-')) { - opP->mode=REGLST; - return get_regs(i,str,opP); - } - if(stmp=index(str,'@')) { - opP->con1=add_exp(str,stmp-1); - if(stmp==strend) { - opP->mode=AINDX; - return OK; - } - stmp++; - if(*stmp++!='(' || *strend--!=')') { - opP->error="Malformed operand"; - return FAIL; - } - i=try_index(&stmp,opP); - opP->con2=add_exp(stmp,strend); - if(i==FAIL) opP->mode=AMIND; - else opP->mode=APODX; - return OK; - } - opP->mode=ABSL; - opP->con1=add_exp(str,strend); - return OK; - } - opP->reg=i; - if(*str=='\0') { - if(i>=DATA+0 && i<=DATA+7) - opP->mode=DREG; - else if(i>=ADDR+0 && i<=ADDR+7) - opP->mode=AREG; - else - opP->mode=MSCR; - return OK; - } - if((iADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { /* Can't indirect off non address regs */ - opP->error="Invalid indirect register"; - return FAIL; - } - if(*str!='@') - abort(); - str++; - switch(*str) { - case '\0': - opP->mode=AINDR; - return OK; - case '-': - opP->mode=ADEC; - return OK; - case '+': - opP->mode=AINC; - return OK; - case '(': - str++; - break; - default: - opP->error="Junk after indirect"; - return FAIL; - } - /* Some kind of indexing involved. Lets find out how bad it is */ - i=try_index(&str,opP); - /* Didn't start with an index reg, maybe its offset or offset,reg */ - if(i==FAIL) { - char *beg_str; - - beg_str=str; - for(i=1;i;) { - switch(*str++) { - case '\0': - opP->error="Missing )"; - return FAIL; - case ',': i=0; break; - case '(': i++; break; - case ')': --i; break; - } - } - /* if(str[-3]==':') { - int siz; - - switch(str[-2]) { - case 'b': - case 'B': - siz=1; - break; - case 'w': - case 'W': - siz=2; - break; - case 'l': - case 'L': - siz=3; - break; - default: - opP->error="Specified size isn't :w or :l"; - return FAIL; - } - opP->con1=add_exp(beg_str,str-4); - opP->con1->e_siz=siz; - } else */ - opP->con1=add_exp(beg_str,str-2); - /* Should be offset,reg */ - if(str[-1]==',') { - i=try_index(&str,opP); - if(i==FAIL) { - opP->error="Malformed index reg"; - return FAIL; - } - } - } - /* We've now got offset) offset,reg) or reg) */ - - if(*str=='\0') { - /* Th-the-thats all folks */ - if(opP->reg==FAIL) opP->mode=AINDX; /* Other form of indirect */ - else if(opP->ireg==FAIL) opP->mode=AOFF; - else opP->mode=AINDX; - return OK; - } - /* Next thing had better be another @ */ - if(*str!='@' || str[1]!='(') { - opP->error="junk after indirect"; - return FAIL; - } - str+=2; - if(opP->ireg!=FAIL) { - opP->mode=APRDX; - i=try_index(&str,opP); - if(i!=FAIL) { - opP->error="Two index registers! not allowed!"; - return FAIL; - } - } else - i=try_index(&str,opP); - if(i==FAIL) { - char *beg_str; - - beg_str=str; - for(i=1;i;) { - switch(*str++) { - case '\0': - opP->error="Missing )"; - return FAIL; - case ',': i=0; break; - case '(': i++; break; - case ')': --i; break; - } - } - opP->con2=add_exp(beg_str,str-2); - if(str[-1]==',') { - if(opP->ireg!=FAIL) { - opP->error="Can't have two index regs"; - return FAIL; - } - i=try_index(&str,opP); - if(i==FAIL) { - opP->error="malformed index reg"; - return FAIL; - } - opP->mode=APODX; - } else if(opP->ireg!=FAIL) - opP->mode=APRDX; - else - opP->mode=AMIND; - } else - opP->mode=APODX; - if(*str!='\0') { - opP->error="Junk after indirect"; - return FAIL; - } - return OK; -} - -int -try_index(s,opP) -char **s; -struct m68k_op *opP; -{ - register int i; - char *ss; -#define SKIP_W() { ss++; if(*ss==' ') ss++;} - - ss= *s; - /* SKIP_W(); */ - i=m68k_reg_parse(&ss); - if(!(i>=DATA+0 && i<=ADDR+7)) { /* if i is not DATA or ADDR reg */ - *s=ss; - return FAIL; - } - opP->ireg=i; - /* SKIP_W(); */ - if(*ss==')') { - opP->isiz=0; - opP->imul=1; - SKIP_W(); - *s=ss; - return OK; - } - if(*ss!=':') { - opP->error="Missing : in index register"; - *s=ss; - return FAIL; - } - SKIP_W(); - switch(*ss) { - case 'w': - case 'W': - opP->isiz=2; - break; - case 'l': - case 'L': - opP->isiz=3; - break; - default: - opP->error="Index register size spec not :w or :l"; - *s=ss; - return FAIL; - } - SKIP_W(); - if(*ss==':') { - SKIP_W(); - switch(*ss) { - case '1': - case '2': - case '4': - case '8': - opP->imul= *ss-'0'; - break; - default: - opP->error="index multiplier not 1, 2, 4 or 8"; - *s=ss; - return FAIL; - } - SKIP_W(); - } else opP->imul=1; - if(*ss!=')') { - opP->error="Missing )"; - *s=ss; - return FAIL; - } - SKIP_W(); - *s=ss; - return OK; -} - -#ifdef TEST1 /* TEST1 tests m68k_ip_op(), which parses operands */ -main() -{ - char buf[128]; - struct m68k_op thark; - - for(;;) { - if(!gets(buf)) - break; - bzero(&thark,sizeof(thark)); - if(!m68k_ip_op(buf,&thark)) printf("FAIL:"); - if(thark.error) - printf("op1 error %s in %s\n",thark.error,buf); - printf("mode %d, reg %d, ",thark.mode,thark.reg); - if(thark.b_const) - printf("Constant: '%.*s',",1+thark.e_const-thark.b_const,thark.b_const); - printf("ireg %d, isiz %d, imul %d ",thark.ireg,thark.isiz,thark.imul); - if(thark.b_iadd) - printf("Iadd: '%.*s'",1+thark.e_iadd-thark.b_iadd,thark.b_iadd); - printf("\n"); - } - exit(0); -} - -#endif - - -static struct hash_control* op_hash = NULL; /* handle of the OPCODE hash table - NULL means any use before m68_ip_begin() - will crash */ - - -/* - * m 6 8 _ i p ( ) - * - * This converts a string into a 68k instruction. - * The string must be a bare single instruction in sun format - * with RMS-style 68020 indirects - * (example: ) - * - * It provides some error messages: at most one fatal error message (which - * stops the scan) and at most one warning message for each operand. - * The 68k instruction is returned in exploded form, since we have no - * knowledge of how you parse (or evaluate) your expressions. - * We do however strip off and decode addressing modes and operation - * mnemonic. - * - * This function's value is a string. If it is not "" then an internal - * logic error was found: read this code to assign meaning to the string. - * No argument string should generate such an error string: - * it means a bug in our code, not in the user's text. - * - * You MUST have called m86_ip_begin() once and m86_ip_end() never before using - * this function. - */ - -/* JF this function no longer returns a useful value. Sorry */ -void -m68_ip (instring) -char *instring; -{ - register char *p; - register struct m68k_op *opP; - register struct m68_incant *opcode; - register char *s; - register int tmpreg, - baseo, - outro, - nextword; - int siz1, - siz2; - char c; - int losing; - int opsfound; - char *crack_operand(); - LITTLENUM_TYPE words[6]; - LITTLENUM_TYPE *wordp; - - if (*instring == ' ') - instring++; /* skip leading whitespace */ - - /* Scan up to end of operation-code, which MUST end in end-of-string - or exactly 1 space. */ - for (p = instring; *p != '\0'; p++) - if (*p == ' ') - break; - - - if (p == instring) { - the_ins.error = "No operator"; - the_ins.opcode[0] = NULL; - /* the_ins.numo=1; */ - return; - } - - /* p now points to the end of the opcode name, probably whitespace. - make sure the name is null terminated by clobbering the whitespace, - look it up in the hash table, then fix it back. */ - c = *p; - *p = '\0'; - opcode = (struct m68_incant *)hash_find (op_hash, instring); - *p = c; - - if (opcode == NULL) { - the_ins.error = "Unknown operator"; - the_ins.opcode[0] = NULL; - /* the_ins.numo=1; */ - return; - } - - /* found a legitimate opcode, start matching operands */ - for(opP= &the_ins.operands[0];*p;opP++) { - p = crack_operand (p, opP); - if(opP->error) { - the_ins.error=opP->error; - return; - } - } - - opsfound=opP- &the_ins.operands[0]; - /* This ugly hack is to support the floating pt opcodes in their standard form */ - /* Essentially, we fake a first enty of type COP#1 */ - if(opcode->m_operands[0]=='I') { - int n; - - for(n=opsfound;n>0;--n) - the_ins.operands[n]=the_ins.operands[n-1]; - - /* bcopy((char *)(&the_ins.operands[0]),(char *)(&the_ins.operands[1]),opsfound*sizeof(the_ins.operands[0])); */ - bzero((char *)(&the_ins.operands[0]),sizeof(the_ins.operands[0])); - the_ins.operands[0].mode=MSCR; - the_ins.operands[0].reg=COPNUM; /* COP #1 */ - opsfound++; - } - /* We've got the operands. Find an opcode that'll - accept them */ - for(losing=0;;) { - if(opsfound!=opcode->m_opnum) - losing++; - else for(s=opcode->m_operands,opP= &the_ins.operands[0];*s && !losing;s+=2,opP++) { - /* Warning: this switch is huge! */ - /* I've tried to organize the cases into this order: - non-alpha first, then alpha by letter. lower-case goes directly - before uppercase counterpart. */ - /* Code with multiple case ...: gets sorted by the lowest case ... - it belongs to. I hope this makes sense. */ - switch(*s) { - case '!': - if(opP->mode==MSCR || opP->mode==IMMED || - opP->mode==DREG || opP->mode==AREG || opP->mode==AINC || opP->mode==ADEC || opP->mode==REGLST) - losing++; - break; - - case '#': - if(opP->mode!=IMMED) - losing++; - else { - long t; - - t=get_num(opP->con1,80); - if(s[1]=='b' && !isbyte(t)) - losing++; - else if(s[1]=='w' && !isword(t)) - losing++; - } - break; - - case '^': - case 'T': - if(opP->mode!=IMMED) - losing++; - break; - - case '$': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - - case '%': - if(opP->mode==MSCR || opP->reg==PC || - opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - - - case '&': - if(opP->mode==MSCR || opP->mode==DREG || - opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || - opP->mode==AINC || opP->mode==ADEC || opP->mode==REGLST) - losing++; - break; - - case '*': - if(opP->mode==MSCR || opP->mode==REGLST) - losing++; - break; - - case '+': - if(opP->mode!=AINC) - losing++; - break; - - case '-': - if(opP->mode!=ADEC) - losing++; - break; - - case '/': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->mode==REGLST) - losing++; - break; - - case ';': - if(opP->mode==MSCR || opP->mode==AREG || opP->mode==REGLST) - losing++; - break; - - case '?': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->reg==PC || - opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - - case '@': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==IMMED || opP->mode==REGLST) - losing++; - break; - - case '~': /* For now! (JF FOO is this right?) */ - if(opP->mode==MSCR || opP->mode==DREG || - opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - - case 'A': - if(opP->mode!=AREG) - losing++; - break; - - case 'B': /* FOO */ - if(opP->mode!=ABSL) - losing++; - break; - - case 'C': - if(opP->mode!=MSCR || opP->reg!=CCR) - losing++; - break; - - case 'd': /* FOO This mode is a KLUDGE!! */ - if(opP->mode!=AOFF && (opP->mode!=ABSL || - opP->con1->e_beg[0]!='(' || opP->con1->e_end[0]!=')')) - losing++; - break; - - case 'D': - if(opP->mode!=DREG) - losing++; - break; - - case 'F': - if(opP->mode!=MSCR || opP->reg<(FPREG+0) || opP->reg>(FPREG+7)) - losing++; - break; - - case 'I': - if(opP->mode!=MSCR || opP->regreg>=COPNUM+7) - losing++; - break; - - case 'J': - if(opP->mode!=MSCR || opP->regreg>MSP) - losing++; - break; - - case 'k': - if(opP->mode!=IMMED) - losing++; - break; - - case 'l': - case 'L': - if(opP->mode==DREG || opP->mode==AREG || opP->mode==FPREG) { - if(s[1]=='8') - losing++; - else { - opP->mode=REGLST; - opP->reg=1<<(opP->reg-DATA); - } - } else if(opP->mode!=REGLST) { - losing++; - } else if(s[1]=='8' && opP->reg&0x0FFffFF) - losing++; - else if(s[1]=='3' && opP->reg&0x7000000) - losing++; - break; - - case 'M': - if(opP->mode!=IMMED) - losing++; - else { - long t; - - t=get_num(opP->con1,80); - if(!issbyte(t) || isvar(opP->con1)) - losing++; - } - break; - - case 'O': - if(opP->mode!=DREG && opP->mode!=IMMED) - losing++; - break; - - case 'Q': - if(opP->mode!=IMMED) - losing++; - else { - long t; - - t=get_num(opP->con1,80); - if(t<1 || t>8 || isvar(opP->con1)) - losing++; - } - break; - - case 'R': - if(opP->mode!=DREG && opP->mode!=AREG) - losing++; - break; - - case 's': - if(opP->mode!=MSCR || !(opP->reg==FPI || opP->reg==FPS || opP->reg==FPC)) - losing++; - break; - - case 'S': - if(opP->mode!=MSCR || opP->reg!=SR) - losing++; - break; - - case 'U': - if(opP->mode!=MSCR || opP->reg!=USP) - losing++; - break; - - /* JF these are out of order. We could put them - in order if we were willing to put up with - bunches of #ifdef m68851s in the code */ -#ifdef m68851 - /* Memory addressing mode used by pflushr */ - case '|': - if(opP->mode==MSCR || opP->mode==DREG || - opP->mode==AREG || opP->mode==REGLST) - losing++; - break; - - case 'f': - if (opP->mode != MSCR || (opP->reg != SFC && opP->reg != DFC)) - losing++; - break; - - case 'P': - if (opP->mode != MSCR || (opP->reg != TC && opP->reg != CAL && - opP->reg != VAL && opP->reg != SCC && opP->reg != AC)) - losing++; - break; - - case 'V': - if (opP->reg != VAL) - losing++; - break; - - case 'W': - if (opP->mode != MSCR || (opP->reg != DRP && opP->reg != SRP && - opP->reg != CRP)) - losing++; - break; - - case 'X': - if (opP->mode != MSCR || - (!(opP->reg >= BAD && opP->reg <= BAD+7) && - !(opP->reg >= BAC && opP->reg <= BAC+7))) - losing++; - break; - - case 'Y': - if (opP->reg != PSR) - losing++; - break; - - case 'Z': - if (opP->reg != PCSR) - losing++; - break; -#endif - default: - as_fatal("Internal error: Operand mode %c unknown",*s); - } - } - if(!losing) - break; - opcode=opcode->m_next; - if(!opcode) { /* Fell off the end */ - the_ins.error="instruction/operands mismatch"; - return; - } - losing=0; - } - the_ins.args=opcode->m_operands; - the_ins.numargs=opcode->m_opnum; - the_ins.numo=opcode->m_codenum; - the_ins.opcode[0]=getone(opcode); - the_ins.opcode[1]=gettwo(opcode); - - for(s=the_ins.args,opP= &the_ins.operands[0];*s;s+=2,opP++) { - /* This switch is a doozy. - What the first step; its a big one! */ - switch(s[0]) { - - case '*': - case '~': - case '%': - case ';': - case '@': - case '!': - case '&': - case '$': - case '?': - case '/': -#ifdef m68851 - case '|': -#endif - switch(opP->mode) { - case IMMED: - tmpreg=0x3c; /* 7.4 */ - if(index("bwl",s[1])) nextword=get_num(opP->con1,80); - else nextword=nextword=get_num(opP->con1,0); - if(isvar(opP->con1)) - add_fix(s[1],opP->con1,0); - switch(s[1]) { - case 'b': - if(!isbyte(nextword)) - opP->error="operand out of range"; - addword(nextword); - baseo=0; - break; - case 'w': - if(!isword(nextword)) - opP->error="operand out of range"; - addword(nextword); - baseo=0; - break; - case 'l': - addword(nextword>>16); - addword(nextword); - baseo=0; - break; - - case 'f': - baseo=2; - outro=8; - break; - case 'F': - baseo=4; - outro=11; - break; - case 'x': - baseo=6; - outro=15; - break; - case 'p': - baseo=6; - outro= -1; - break; - default: - as_fatal("Internal error: Can't decode %c%c",*s,s[1]); - } - if(!baseo) - break; - - /* We gotta put out some float */ - if(seg(opP->con1)!=SEG_BIG) { - int_to_gen(nextword); - gen_to_words(words,baseo,(long int)outro); - for(wordp=words;baseo--;wordp++) - addword(*wordp); - break; - } /* Its BIG */ - if(offs(opP->con1)>0) { - as_warn("Bignum assumed to be binary bit-pattern"); - if(offs(opP->con1)>baseo) { - as_warn("Bignum too big for %c format; truncated",s[1]); - offs(opP->con1)=baseo; - } - baseo-=offs(opP->con1); - for(wordp=generic_bignum+offs(opP->con1)-1;offs(opP->con1)--;--wordp) - addword(*wordp); - while(baseo--) - addword(0); - break; - } - gen_to_words(words,baseo,(long int)outro); - for(wordp=words;baseo--;wordp++) - addword(*wordp); - break; - case DREG: - tmpreg=opP->reg-DATA; /* 0.dreg */ - break; - case AREG: - tmpreg=0x08+opP->reg-ADDR; /* 1.areg */ - break; - case AINDR: - tmpreg=0x10+opP->reg-ADDR; /* 2.areg */ - break; - case ADEC: - tmpreg=0x20+opP->reg-ADDR; /* 4.areg */ - break; - case AINC: - tmpreg=0x18+opP->reg-ADDR; /* 3.areg */ - break; - case AOFF: - - nextword=get_num(opP->con1,80); - /* Force into index mode. Hope this works */ - - /* We do the first bit for 32-bit displacements, - and the second bit for 16 bit ones. It is - possible that we should make the default be - WORD instead of LONG, but I think that'd - break GCC, so we put up with a little - inefficiency for the sake of working output. - */ - - if( !issword(nextword) - || ( isvar(opP->con1) - && ( ( opP->con1->e_siz==0 - && flagseen['l']==0) - || opP->con1->e_siz==3))) { - - if(opP->reg==PC) - tmpreg=0x3B; /* 7.3 */ - else - tmpreg=0x30+opP->reg-ADDR; /* 6.areg */ - if(isvar(opP->con1)) { - if(opP->reg==PC) { - add_frag(adds(opP->con1), - offs(opP->con1), - TAB(PCLEA,SZ_UNDEF)); - break; - } else { - addword(0x0170); - add_fix('l',opP->con1,1); - } - } else - addword(0x0170); - addword(nextword>>16); - } else { - if(opP->reg==PC) - tmpreg=0x3A; /* 7.2 */ - else - tmpreg=0x28+opP->reg-ADDR; /* 5.areg */ - - if(isvar(opP->con1)) { - if(opP->reg==PC) { - add_fix('w',opP->con1,1); - } else - add_fix('w',opP->con1,0); - } - } - addword(nextword); - break; - case AINDX: - case APODX: - case AMIND: - case APRDX: - nextword=0; - baseo=get_num(opP->con1,80); - outro=get_num(opP->con2,80); - /* Figure out the 'addressing mode' */ - /* Also turn on the BASE_DISABLE bit, if needed */ - if(opP->reg==PC || opP->reg==ZPC) { - tmpreg=0x3b; /* 7.3 */ - if(opP->reg==ZPC) - nextword|=0x80; - } else if(opP->reg==FAIL) { - nextword|=0x80; - tmpreg=0x30; /* 6.garbage */ - } else tmpreg=0x30+opP->reg-ADDR; /* 6.areg */ - - siz1= (opP->con1) ? opP->con1->e_siz : 0; - siz2= (opP->con2) ? opP->con2->e_siz : 0; - - /* Index register stuff */ - if(opP->ireg>=DATA+0 && opP->ireg<=ADDR+7) { - nextword|=(opP->ireg-DATA)<<12; - - if(opP->isiz==0 || opP->isiz==3) - nextword|=0x800; - switch(opP->imul) { - case 1: break; - case 2: nextword|=0x200; break; - case 4: nextword|=0x400; break; - case 8: nextword|=0x600; break; - default: abort(); - } - /* IF its simple, - GET US OUT OF HERE! */ - - /* Must be INDEX, with an index - register. Address register - cannot be ZERO-PC, and either - :b was forced, or we know - it will fit */ - if( opP->mode==AINDX - && opP->reg!=FAIL - && opP->reg!=ZPC - && ( siz1==1 - || ( issbyte(baseo) - && !isvar(opP->con1)))) { - nextword +=baseo&0xff; - addword(nextword); - if(isvar(opP->con1)) - add_fix('B',opP->con1,0); - break; - } - } else - nextword|=0x40; /* No index reg */ - - /* It aint simple */ - nextword|=0x100; - /* If the guy specified a width, we assume that - it is wide enough. Maybe it isn't. Ifso, we lose - */ - switch(siz1) { - case 0: - if(isvar(opP->con1) || !issword(baseo)) { - siz1=3; - nextword|=0x30; - } else if(baseo==0) - nextword|=0x10; - else { - nextword|=0x20; - siz1=2; - } - break; - case 1: - as_warn("Byte dispacement won't work. Defaulting to :w"); - case 2: - nextword|=0x20; - break; - case 3: - nextword|=0x30; - break; - } - - /* Figure out innner displacement stuff */ - if(opP->mode!=AINDX) { - switch(siz2) { - case 0: - if(isvar(opP->con2) || !issword(outro)) { - siz2=3; - nextword|=0x3; - } else if(outro==0) - nextword|=0x1; - else { - nextword|=0x2; - siz2=2; - } - break; - case 1: - as_warn("Byte dispacement won't work. Defaulting to :w"); - case 2: - nextword|=0x2; - break; - case 3: - nextword|=0x3; - break; - } - if(opP->mode==APODX) nextword|=0x04; - else if(opP->mode==AMIND) nextword|=0x40; - } - addword(nextword); - - if(isvar(opP->con1)) { - if(opP->reg==PC || opP->reg==ZPC) { - add_fix(siz1==3 ? 'l' : 'w',opP->con1,1); - opP->con1->e_exp.X_add_number+=6; - } else - add_fix(siz1==3 ? 'l' : 'w',opP->con1,0); - } - if(siz1==3) - addword(baseo>>16); - if(siz1) - addword(baseo); - - if(isvar(opP->con2)) { - if(opP->reg==PC || opP->reg==ZPC) { - add_fix(siz2==3 ? 'l' : 'w',opP->con2,1); - opP->con1->e_exp.X_add_number+=6; - } else - add_fix(siz2==3 ? 'l' : 'w',opP->con2,0); - } - if(siz2==3) - addword(outro>>16); - if(siz2) - addword(outro); - - break; - - case ABSL: - nextword=get_num(opP->con1,80); - switch(opP->con1->e_siz) { - default: - as_warn("Unknown size for absolute reference"); - case 0: - if(!isvar(opP->con1) && issword(offs(opP->con1))) { - tmpreg=0x38; /* 7.0 */ - addword(nextword); - break; - } - /* Don't generate pc relative code - on 68010 and 68000 */ - if(isvar(opP->con1) && - !subs(opP->con1) && - seg(opP->con1)==SEG_TEXT && - now_seg==SEG_TEXT && - flagseen['m']==0 && - !index("~%&$?", s[0])) { - tmpreg=0x3A; /* 7.2 */ - add_frag(adds(opP->con1), - offs(opP->con1), - TAB(PCREL,SZ_UNDEF)); - break; - } - case 3: /* Fall through into long */ - if(isvar(opP->con1)) - add_fix('l',opP->con1,0); - - tmpreg=0x39; /* 7.1 mode */ - addword(nextword>>16); - addword(nextword); - break; - - case 2: /* Word */ - if(isvar(opP->con1)) - add_fix('w',opP->con1,0); - - tmpreg=0x38; /* 7.0 mode */ - addword(nextword); - break; - } - break; - case MSCR: - default: - as_bad("unknown/incorrect operand"); - /* abort(); */ - } - install_gen_operand(s[1],tmpreg); - break; - - case '#': - case '^': - switch(s[1]) { /* JF: I hate floating point! */ - case 'j': - tmpreg=70; - break; - case '8': - tmpreg=20; - break; - case 'C': - tmpreg=50; - break; - case '3': - default: - tmpreg=80; - break; - } - tmpreg=get_num(opP->con1,tmpreg); - if(isvar(opP->con1)) - add_fix(s[1],opP->con1,0); - switch(s[1]) { - case 'b': /* Danger: These do no check for - certain types of overflow. - user beware! */ - if(!isbyte(tmpreg)) - opP->error="out of range"; - insop(tmpreg); - if(isvar(opP->con1)) - the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; - break; - case 'w': - if(!isword(tmpreg)) - opP->error="out of range"; - insop(tmpreg); - if(isvar(opP->con1)) - the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; - break; - case 'l': - insop(tmpreg); /* Because of the way insop works, we put these two out backwards */ - insop(tmpreg>>16); - if(isvar(opP->con1)) - the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; - break; - case '3': - tmpreg&=0xFF; - case '8': - case 'C': - install_operand(s[1],tmpreg); - break; - default: - as_fatal("Internal error: Unknown mode #%c",s[1]); - } - break; - - case '+': - case '-': - case 'A': - install_operand(s[1],opP->reg-ADDR); - break; - - case 'B': - tmpreg=get_num(opP->con1,80); - switch(s[1]) { - case 'g': - if(opP->con1->e_siz) { /* Deal with fixed size stuff by hand */ - switch(opP->con1->e_siz) { - case 1: - add_fix('b',opP->con1,1); - break; - case 2: - add_fix('w',opP->con1,1); - addword(0); - break; - case 3: - add_fix('l',opP->con1,1); - addword(0); - addword(0); - break; - default: - as_fatal("Bad size for expression %d",opP->con1->e_siz); - } - } else if(subs(opP->con1)) { - /* We can't relax it */ - the_ins.opcode[the_ins.numo-1]|=0xff; - add_fix('l',opP->con1,1); - addword(0); - addword(0); - } else if(adds(opP->con1)) { - if (flagseen['m'] && - (the_ins.opcode[0] >= 0x6200) && - (the_ins.opcode[0] <= 0x6f00)) { - add_frag(adds(opP->con1),offs(opP->con1),TAB(BCC68000,SZ_UNDEF)); - } else { - add_frag(adds(opP->con1),offs(opP->con1),TAB(BRANCH,SZ_UNDEF)); - } - } else { - /* JF: This is the WRONG thing to do - add_frag((symbolS *)0,offs(opP->con1),TAB(BRANCH,BYTE)); */ - the_ins.opcode[the_ins.numo-1]|=0xff; - offs(opP->con1)+=4; - add_fix('l',opP->con1,1); - addword(0); - addword(0); - } - break; - case 'w': - if(isvar(opP->con1)) { - /* check for DBcc instruction */ - if ((the_ins.opcode[0] & 0xf0f8) ==0x50c8) { - /* size varies if patch */ - /* needed for long form */ - add_frag(adds(opP->con1),offs(opP->con1),TAB(DBCC,SZ_UNDEF)); - break; - } - - /* Don't ask! */ - opP->con1->e_exp.X_add_number+=2; - add_fix('w',opP->con1,1); - } - addword(0); - break; - case 'c': - if(opP->con1->e_siz) { - switch(opP->con1->e_siz) { - case 2: - add_fix('w',opP->con1,1) - addword(0); - break; - case 3: - the_ins.opcode[the_ins.numo-1]|=0x40; - add_fix('l',opP->con1,1); - addword(0); - addword(0); - break; - default: - as_bad("Bad size for offset, must be word or long"); - break; - } - } else if(subs(opP->con1)) { - add_fix('l',opP->con1,1); - add_frag((symbolS *)0,(long)0,TAB(FBRANCH,LONG)); - } else if(adds(opP->con1)) { - add_frag(adds(opP->con1),offs(opP->con1),TAB(FBRANCH,SZ_UNDEF)); - } else { - /* add_frag((symbolS *)0,offs(opP->con1),TAB(FBRANCH,SHORT)); */ - the_ins.opcode[the_ins.numo-1]|=0x40; - add_fix('l',opP->con1,1); - addword(0); - addword(4); - } - break; - default: - as_fatal("Internal error: operand type B%c unknown",s[1]); - } - break; - - case 'C': /* Ignore it */ - break; - - case 'd': /* JF this is a kludge */ - if(opP->mode==AOFF) { - install_operand('s',opP->reg-ADDR); - } else { - char *tmpP; - - tmpP=opP->con1->e_end-2; - opP->con1->e_beg++; - opP->con1->e_end-=4; /* point to the , */ - baseo=m68k_reg_parse(&tmpP); - if(baseoADDR+7) { - as_bad("Unknown address reg, using A0"); - baseo=0; - } else baseo-=ADDR; - install_operand('s',baseo); - } - tmpreg=get_num(opP->con1,80); - if(!issword(tmpreg)) { - as_warn("Expression out of range, using 0"); - tmpreg=0; - } - addword(tmpreg); - break; - - case 'D': - install_operand(s[1],opP->reg-DATA); - break; - - case 'F': - install_operand(s[1],opP->reg-FPREG); - break; - - case 'I': - tmpreg=1+opP->reg-COPNUM; - if(tmpreg==8) - tmpreg=0; - install_operand(s[1],tmpreg); - break; - - case 'J': /* JF foo */ - switch(opP->reg) { - case SFC: - tmpreg=0; - break; - case DFC: - tmpreg=0x001; - break; - case CACR: - tmpreg=0x002; - break; - case USP: - tmpreg=0x800; - break; - case VBR: - tmpreg=0x801; - break; - case CAAR: - tmpreg=0x802; - break; - case MSP: - tmpreg=0x803; - break; - case ISP: - tmpreg=0x804; - break; - default: - abort(); - } - install_operand(s[1],tmpreg); - break; - - case 'k': - tmpreg=get_num(opP->con1,55); - install_operand(s[1],tmpreg&0x7f); - break; - - case 'l': - tmpreg=opP->reg; - if(s[1]=='w') { - if(tmpreg&0x7FF0000) - as_bad("Floating point register in register list"); - insop(reverse_16_bits(tmpreg)); - } else { - if(tmpreg&0x700FFFF) - as_bad("Wrong register in floating-point reglist"); - install_operand(s[1],reverse_8_bits(tmpreg>>16)); - } - break; - - case 'L': - tmpreg=opP->reg; - if(s[1]=='w') { - if(tmpreg&0x7FF0000) - as_bad("Floating point register in register list"); - insop(tmpreg); - } else if(s[1]=='8') { - if(tmpreg&0x0FFFFFF) - as_bad("incorrect register in reglist"); - install_operand(s[1],tmpreg>>24); - } else { - if(tmpreg&0x700FFFF) - as_bad("wrong register in floating-point reglist"); - else - install_operand(s[1],tmpreg>>16); - } - break; - - case 'M': - install_operand(s[1],get_num(opP->con1,60)); - break; - - case 'O': - tmpreg= (opP->mode==DREG) - ? 0x20+opP->reg-DATA - : (get_num(opP->con1,40)&0x1F); - install_operand(s[1],tmpreg); - break; - - case 'Q': - tmpreg=get_num(opP->con1,10); - if(tmpreg==8) - tmpreg=0; - install_operand(s[1],tmpreg); - break; - - case 'R': - /* This depends on the fact that ADDR registers are - eight more than their corresponding DATA regs, so - the result will have the ADDR_REG bit set */ - install_operand(s[1],opP->reg-DATA); - break; - - case 's': - if(opP->reg==FPI) tmpreg=0x1; - else if(opP->reg==FPS) tmpreg=0x2; - else if(opP->reg==FPC) tmpreg=0x4; - else abort(); - install_operand(s[1],tmpreg); - break; - - case 'S': /* Ignore it */ - break; - - case 'T': - install_operand(s[1],get_num(opP->con1,30)); - break; - - case 'U': /* Ignore it */ - break; - -#ifdef m68851 - /* JF: These are out of order, I fear. */ - case 'f': - switch (opP->reg) { - case SFC: - tmpreg=0; - break; - case DFC: - tmpreg=1; - break; - default: - abort(); - } - install_operand(s[1],tmpreg); - break; - - case 'P': - switch(opP->reg) { - case TC: - tmpreg=0; - break; - case CAL: - tmpreg=4; - break; - case VAL: - tmpreg=5; - break; - case SCC: - tmpreg=6; - break; - case AC: - tmpreg=7; - break; - default: - abort(); - } - install_operand(s[1],tmpreg); - break; - - case 'V': - if (opP->reg == VAL) - break; - abort(); - - case 'W': - switch(opP->reg) { - - case DRP: - tmpreg=1; - break; - case SRP: - tmpreg=2; - break; - case CRP: - tmpreg=3; - break; - default: - abort(); - } - install_operand(s[1],tmpreg); - break; - - case 'X': - switch (opP->reg) { - case BAD: case BAD+1: case BAD+2: case BAD+3: - case BAD+4: case BAD+5: case BAD+6: case BAD+7: - tmpreg = (4 << 10) | ((opP->reg - BAD) << 2); - break; - - case BAC: case BAC+1: case BAC+2: case BAC+3: - case BAC+4: case BAC+5: case BAC+6: case BAC+7: - tmpreg = (5 << 10) | ((opP->reg - BAC) << 2); - break; - - default: - abort(); - } - install_operand(s[1], tmpreg); - break; - case 'Y': - if (opP->reg == PSR) - break; - abort(); - - case 'Z': - if (opP->reg == PCSR) - break; - abort(); -#endif /* m68851 */ - default: - as_fatal("Internal error: Operand type %c unknown",s[0]); - } - } - /* By the time whe get here (FINALLY) the_ins contains the complete - instruction, ready to be emitted. . . */ -} - -int -get_regs(i,str,opP) -struct m68k_op *opP; -char *str; -{ - /* 26, 25, 24, 23-16, 15-8, 0-7 */ - /* Low order 24 bits encoded fpc,fps,fpi,fp7-fp0,a7-a0,d7-d0 */ - unsigned long int cur_regs = 0; - int reg1, - reg2; - -#define ADD_REG(x) { if(x==FPI) cur_regs|=(1<<24);\ - else if(x==FPS) cur_regs|=(1<<25);\ - else if(x==FPC) cur_regs|=(1<<26);\ - else cur_regs|=(1<<(x-1)); } - - reg1=i; - for(;;) { - if(*str=='/') { - ADD_REG(reg1); - str++; - } else if(*str=='-') { - str++; - reg2=m68k_reg_parse(&str); - if(reg2=FPREG+8 || reg1==FPI || reg1==FPS || reg1==FPC) { - opP->error="unknown register in register list"; - return FAIL; - } - while(reg1<=reg2) { - ADD_REG(reg1); - reg1++; - } - if(*str=='\0') - break; - } else if(*str=='\0') { - ADD_REG(reg1); - break; - } else { - opP->error="unknow character in register list"; - return FAIL; - } -/* DJA -- Bug Fix. Did't handle d1-d2/a1 until the following instruction was added */ - if (*str=='/') - str ++; - reg1=m68k_reg_parse(&str); - if((reg1=FPREG+8) && !(reg1==FPI || reg1==FPS || reg1==FPC)) { - opP->error="unknown register in register list"; - return FAIL; - } - } - opP->reg=cur_regs; - return OK; -} - -int -reverse_16_bits(in) -int in; -{ - int out=0; - int n; - - static int mask[16] = { -0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, -0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000 - }; - for(n=0;n<16;n++) { - if(in&mask[n]) - out|=mask[15-n]; - } - return out; -} - -int -reverse_8_bits(in) -int in; -{ - int out=0; - int n; - - static int mask[8] = { -0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, - }; - - for(n=0;n<8;n++) { - if(in&mask[n]) - out|=mask[7-n]; - } - return out; -} - -void -install_operand(mode,val) -int mode; -int val; -{ - switch(mode) { - case 's': - the_ins.opcode[0]|=val & 0xFF; /* JF FF is for M kludge */ - break; - case 'd': - the_ins.opcode[0]|=val<<9; - break; - case '1': - the_ins.opcode[1]|=val<<12; - break; - case '2': - the_ins.opcode[1]|=val<<6; - break; - case '3': - the_ins.opcode[1]|=val; - break; - case '4': - the_ins.opcode[2]|=val<<12; - break; - case '5': - the_ins.opcode[2]|=val<<6; - break; - case '6': - /* DANGER! This is a hack to force cas2l and cas2w cmds - to be three words long! */ - the_ins.numo++; - the_ins.opcode[2]|=val; - break; - case '7': - the_ins.opcode[1]|=val<<7; - break; - case '8': - the_ins.opcode[1]|=val<<10; - break; -#ifdef m68851 - case '9': - the_ins.opcode[1]|=val<<5; - break; -#endif - - case 't': - the_ins.opcode[1]|=(val<<10)|(val<<7); - break; - case 'D': - the_ins.opcode[1]|=(val<<12)|val; - break; - case 'g': - the_ins.opcode[0]|=val=0xff; - break; - case 'i': - the_ins.opcode[0]|=val<<9; - break; - case 'C': - the_ins.opcode[1]|=val; - break; - case 'j': - the_ins.opcode[1]|=val; - the_ins.numo++; /* What a hack */ - break; - case 'k': - the_ins.opcode[1]|=val<<4; - break; - case 'b': - case 'w': - case 'l': - break; - case 'c': - default: - abort(); - } -} - -void -install_gen_operand(mode,val) -int mode; -int val; -{ - switch(mode) { - case 's': - the_ins.opcode[0]|=val; - break; - case 'd': - /* This is a kludge!!! */ - the_ins.opcode[0]|=(val&0x07)<<9|(val&0x38)<<3; - break; - case 'b': - case 'w': - case 'l': - case 'f': - case 'F': - case 'x': - case 'p': - the_ins.opcode[0]|=val; - break; - /* more stuff goes here */ - default: - abort(); - } -} - -char * -crack_operand(str,opP) -register char *str; -register struct m68k_op *opP; -{ - register int parens; - register int c; - register char *beg_str; - - if(!str) { - return str; - } - beg_str=str; - for(parens=0;*str && (parens>0 || notend(str));str++) { - if(*str=='(') parens++; - else if(*str==')') { - if(!parens) { /* ERROR */ - opP->error="Extra )"; - return str; - } - --parens; - } - } - if(!*str && parens) { /* ERROR */ - opP->error="Missing )"; - return str; - } - c= *str; - *str='\0'; - if(m68k_ip_op(beg_str,opP)==FAIL) { - *str=c; - return str; - } - *str=c; - if(c=='}') - c= *++str; /* JF bitfield hack */ - if(c) { - c= *++str; - if(!c) - as_bad("Missing operand"); - } - return str; -} - -/* See the comment up above where the #define notend(... is */ -#if 0 -notend(s) -char *s; -{ - if(*s==',') return 0; - if(*s=='{' || *s=='}') - return 0; - if(*s!=':') return 1; - /* This kludge here is for the division cmd, which is a kludge */ - if(index("aAdD#",s[1])) return 0; - return 1; -} -#endif - -/* This is the guts of the machine-dependent assembler. STR points to a - machine dependent instruction. This funciton is supposed to emit - the frags/bytes it assembles to. - */ -void -md_assemble(str) -char *str; -{ - char *er; - short *fromP; - char *toP; - int m,n; - char *to_beg_P; - int shorts_this_frag; - - bzero((char *)(&the_ins),sizeof(the_ins)); /* JF for paranoia sake */ - m68_ip(str); - er=the_ins.error; - if(!er) { - for(n=the_ins.numargs;n;--n) - if(the_ins.operands[n].error) { - er=the_ins.operands[n].error; - break; - } - } - if(er) { - as_bad("\"%s\" -- Statement '%s' ignored",er,str); - return; - } - - if(the_ins.nfrag==0) { /* No frag hacking involved; just put it out */ - toP=frag_more(2*the_ins.numo); - fromP= &the_ins.opcode[0]; - for(m=the_ins.numo;m;--m) { - md_number_to_chars(toP,(long)(*fromP),2); - toP+=2; - fromP++; - } - /* put out symbol-dependent info */ - for(m=0;mfr_literal)-the_ins.numo*2+the_ins.reloc[m].n, - n, - the_ins.reloc[m].add, - the_ins.reloc[m].sub, - the_ins.reloc[m].off, - the_ins.reloc[m].pcrel); - } - return; - } - - /* There's some frag hacking */ - for(n=0,fromP= &the_ins.opcode[0];n= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */) { - the_ins.reloc[m].n-= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */; - break; - } - wid=the_ins.reloc[m].wid; - if(wid==0) - continue; - the_ins.reloc[m].wid=0; - wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000; - - fix_new(frag_now, - (toP-frag_now->fr_literal)-the_ins.numo*2+the_ins.reloc[m].n, - wid, - the_ins.reloc[m].add, - the_ins.reloc[m].sub, - the_ins.reloc[m].off, - the_ins.reloc[m].pcrel); - } - know(the_ins.fragb[n].fadd); - (void)frag_var(rs_machine_dependent,10,0,(relax_substateT)(the_ins.fragb[n].fragty), - the_ins.fragb[n].fadd,the_ins.fragb[n].foff,to_beg_P); - } - n=(the_ins.numo-the_ins.fragb[n-1].fragoff); - shorts_this_frag=0; - if(n) { - toP=frag_more(n*sizeof(short)); - while(n--) { - md_number_to_chars(toP,(long)(*fromP),2); - toP+=2; - fromP++; - shorts_this_frag++; - } - } - for(m=0;mfr_literal)-/* the_ins.numo */ shorts_this_frag*2, - wid, - the_ins.reloc[m].add, - the_ins.reloc[m].sub, - the_ins.reloc[m].off, - the_ins.reloc[m].pcrel); - } -} - -/* This function is called once, at assembler startup time. This should - set up all the tables, etc that the MD part of the assembler needs - */ -void -md_begin() -{ -/* - * md_begin -- set up hash tables with 68000 instructions. - * similar to what the vax assembler does. ---phr - */ - /* RMS claims the thing to do is take the m68k-opcode.h table, and make - a copy of it at runtime, adding in the information we want but isn't - there. I think it'd be better to have an awk script hack the table - at compile time. Or even just xstr the table and use it as-is. But - my lord ghod hath spoken, so we do it this way. Excuse the ugly var - names. */ - - register struct m68k_opcode *ins; - register struct m68_incant *hack, - *slak; - register char *retval = 0; /* empty string, or error msg text */ - register int i; - register char c; - - if ((op_hash = hash_new()) == NULL) - as_fatal("Virtual memory exhausted"); - - obstack_begin(&robyn,4000); - for (ins = m68k_opcodes; ins < endop; ins++) { - hack=slak=(struct m68_incant *)obstack_alloc(&robyn,sizeof(struct m68_incant)); - do { - slak->m_operands=ins->args; - slak->m_opnum=strlen(slak->m_operands)/2; - slak->m_opcode=ins->opcode; - /* This is kludgey */ - slak->m_codenum=((ins->match)&0xffffL) ? 2 : 1; - if((ins+1)!=endop && !strcmp(ins->name,(ins+1)->name)) { - slak->m_next=(struct m68_incant *) -obstack_alloc(&robyn,sizeof(struct m68_incant)); - ins++; - } else - slak->m_next=0; - slak=slak->m_next; - } while(slak); - - retval = hash_insert (op_hash, ins->name,(char *)hack); - /* Didn't his mommy tell him about null pointers? */ - if(retval && *retval) - as_fatal("Internal Error: Can't hash %s: %s",ins->name,retval); - } - - for (i = 0; i < sizeof(mklower_table) ; i++) - mklower_table[i] = (isupper(c = (char) i)) ? tolower(c) : c; - - for (i = 0 ; i < sizeof(notend_table) ; i++) { - notend_table[i] = 0; - alt_notend_table[i] = 0; - } - notend_table[','] = 1; - notend_table['{'] = 1; - notend_table['}'] = 1; - alt_notend_table['a'] = 1; - alt_notend_table['A'] = 1; - alt_notend_table['d'] = 1; - alt_notend_table['D'] = 1; - alt_notend_table['#'] = 1; - alt_notend_table['f'] = 1; - alt_notend_table['F'] = 1; -#ifdef REGISTER_PREFIX - alt_notend_table[REGISTER_PREFIX] = 1; -#endif -} - -#if 0 -#define notend(s) ((*s == ',' || *s == '}' || *s == '{' \ - || (*s == ':' && index("aAdD#", s[1]))) \ - ? 0 : 1) -#endif - -/* This funciton is called once, before the assembler exits. It is - supposed to do any final cleanup for this part of the assembler. - */ -void -md_end() -{ -} - -/* Equal to MAX_PRECISION in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -/* Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. - */ -char * -md_atof(type,litP,sizeP) -char type; -char *litP; -int *sizeP; -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - char *atof_ieee(); - - switch(type) { - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; - - case 'p': - case 'P': - prec = 6; - break; - - default: - *sizeP=0; - return "Bad call to MD_ATOF()"; - } - t=atof_ieee(input_line_pointer,type,words); - if(t) - input_line_pointer=t; - - *sizeP=prec * sizeof(LITTLENUM_TYPE); - for(wordP=words;prec--;) { - md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE)); - litP+=sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ -} - -/* Turn an integer of n bytes (in val) into a stream of bytes appropriate - for use in the a.out file, and stores them in the array pointed to by buf. - This knows about the endian-ness of the target machine and does - THE RIGHT THING, whatever it is. Possible values for n are 1 (byte) - 2 (short) and 4 (long) Floating numbers are put out as a series of - LITTLENUMS (shorts, here at least) - */ -void -md_number_to_chars(buf,val,n) -char *buf; -long val; -int n; -{ - switch(n) { - case 1: - *buf++=val; - break; - case 2: - *buf++=(val>>8); - *buf++=val; - break; - case 4: - *buf++=(val>>24); - *buf++=(val>>16); - *buf++=(val>>8); - *buf++=val; - break; - default: - abort(); - } -} - -void -md_number_to_imm(buf,val,n) -char *buf; -long val; -int n; -{ - switch(n) { - case 1: - *buf++=val; - break; - case 2: - *buf++=(val>>8); - *buf++=val; - break; - case 4: - *buf++=(val>>24); - *buf++=(val>>16); - *buf++=(val>>8); - *buf++=val; - break; - default: - abort(); - } -} - -void -md_number_to_disp(buf,val,n) -char *buf; -long val; -int n; -{ - abort(); -} - -void -md_number_to_field(buf,val,fix) -char *buf; -long val; -void *fix; -{ - abort(); -} - - -/* *fragP has been relaxed to its final size, and now needs to have - the bytes inside it modified to conform to the new size There is UGLY - MAGIC here. .. - */ -void -md_convert_frag(fragP) -register fragS *fragP; -{ - long disp; - long ext; - - /* Address in gas core of the place to store the displacement. */ - register char *buffer_address = fragP -> fr_fix + fragP -> fr_literal; - /* Address in object code of the displacement. */ - register int object_address = fragP -> fr_fix + fragP -> fr_address; - - know(fragP->fr_symbol); - - /* The displacement of the address, from current location. */ - disp = (fragP->fr_symbol->sy_value + fragP->fr_offset) - object_address; - - switch(fragP->fr_subtype) { - case TAB(BCC68000,BYTE): - case TAB(BRANCH,BYTE): - know(issbyte(disp)); - if(disp==0) - as_bad("short branch with zero offset: use :w"); - fragP->fr_opcode[1]=disp; - ext=0; - break; - case TAB(DBCC,SHORT): - know(issword(disp)); - ext=2; - break; - case TAB(BCC68000,SHORT): - case TAB(BRANCH,SHORT): - know(issword(disp)); - fragP->fr_opcode[1]=0x00; - ext=2; - break; - case TAB(BRANCH,LONG): - if(flagseen['m']) { - if(fragP->fr_opcode[0]==0x61) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset, 0); - fragP->fr_fix+=4; - ext=0; - } else if(fragP->fr_opcode[0]==0x60) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset,0); - fragP->fr_fix+=4; - ext=0; - }else { - as_bad("Long branch offset not supported."); - } - } else { - fragP->fr_opcode[1]=0xff; - ext=4; - } - break; - case TAB(BCC68000,LONG): - /* only Bcc 68000 instructions can come here */ - /* change bcc into b!cc/jmp absl long */ - fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ - fragP->fr_opcode[1] = 0x6; /* branch offset = 6 */ - - /* JF: these used to be fr_opcode[2,3], but they may be in a - different frag, in which case refering to them is a no-no. - Only fr_opcode[0,1] are guaranteed to work. */ - *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */ - *buffer_address++ = 0xf9; - fragP->fr_fix += 2; /* account for jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, - fragP->fr_offset,0); - fragP->fr_fix += 4; - ext=0; - break; - case TAB(DBCC,LONG): - /* only DBcc 68000 instructions can come here */ - /* change dbcc into dbcc/jmp absl long */ - /* JF: these used to be fr_opcode[2-7], but that's wrong */ - *buffer_address++ = 0x00; /* branch offset = 4 */ - *buffer_address++ = 0x04; - *buffer_address++ = 0x60; /* put in bra pc+6 */ - *buffer_address++ = 0x06; - *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */ - *buffer_address++ = 0xf9; - - fragP->fr_fix += 6; /* account for bra/jmp instructions */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, - fragP->fr_offset,0); - fragP->fr_fix += 4; - ext=0; - break; - case TAB(FBRANCH,SHORT): - know((fragP->fr_opcode[1]&0x40)==0); - ext=2; - break; - case TAB(FBRANCH,LONG): - fragP->fr_opcode[1]|=0x40; /* Turn on LONG bit */ - ext=4; - break; - case TAB(PCREL,SHORT): - ext=2; - break; - case TAB(PCREL,LONG): - /* The thing to do here is force it to ABSOLUTE LONG, since - PCREL is really trying to shorten an ABSOLUTE address anyway */ - /* JF FOO This code has not been tested */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset, 0); - if((fragP->fr_opcode[1] & 0x3F) != 0x3A) - as_bad("Internal error (long PC-relative operand) for insn 0x%04lx at 0x%lx", - fragP->fr_opcode[0],fragP->fr_address); - fragP->fr_opcode[1]&= ~0x3F; - fragP->fr_opcode[1]|=0x39; /* Mode 7.1 */ - fragP->fr_fix+=4; - /* md_number_to_chars(buffer_address, - (long)(fragP->fr_symbol->sy_value + fragP->fr_offset), - 4); */ - ext=0; - break; - case TAB(PCLEA,SHORT): - subseg_change(SEG_TEXT,0); - fix_new(fragP,(int)(fragP->fr_fix),2,fragP->fr_symbol,(symbolS *)0,fragP->fr_offset,1); - fragP->fr_opcode[1] &= ~0x3F; - fragP->fr_opcode[1] |= 0x3A; - ext=2; - break; - case TAB(PCLEA,LONG): - subseg_change(SEG_TEXT,0); - fix_new(fragP,(int)(fragP->fr_fix)+2,4,fragP->fr_symbol,(symbolS *)0,fragP->fr_offset+2,1); - *buffer_address++ = 0x01; - *buffer_address++ = 0x70; - fragP->fr_fix+=2; - /* buffer_address+=2; */ - ext=4; - break; - - } - if(ext) { - md_number_to_chars(buffer_address,(long)disp,(int)ext); - fragP->fr_fix+=ext; - } -} - -/* Force truly undefined symbols to their maximum size, and generally set up - the frag list to be relaxed - */ -int -md_estimate_size_before_relax(fragP,segtype) -register fragS *fragP; -int segtype; -{ - int old_fix; - register char *buffer_address = fragP -> fr_fix + fragP -> fr_literal; - - old_fix=fragP->fr_fix; - - /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */ - switch(fragP->fr_subtype) { - case TAB(BRANCH,SZ_UNDEF): - if((fragP->fr_symbol->sy_type&N_TYPE)==segtype) { - fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),BYTE); - break; - } else if(flagseen['m']) { - if(fragP->fr_opcode[0]==0x61) { - if(flagseen['l']) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xB8; /* JBSR with ABSL WORD offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 2, - fragP->fr_symbol, 0, fragP->fr_offset, 0); - fragP->fr_fix+=2; - } else { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 4, - fragP->fr_symbol, 0, fragP->fr_offset, 0); - fragP->fr_fix+=4; - } - frag_wane(fragP); - } else if(fragP->fr_opcode[0]==0x60) { - if(flagseen['l']) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xF8; /* JMP with ABSL WORD offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 2, - fragP->fr_symbol, 0, fragP->fr_offset, 0); - fragP->fr_fix+=2; - } else { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 4, - fragP->fr_symbol, 0, fragP->fr_offset, 0); - fragP->fr_fix+=4; - } - frag_wane(fragP); - } else { - as_warn("Long branch offset to extern symbol not supported."); - } - } else if(flagseen['l']) { /* Symbol is still undefined. Make it simple */ - fix_new(fragP,(int)(fragP->fr_fix),2,fragP->fr_symbol, - (symbolS *)0,fragP->fr_offset + 2,1); - fragP->fr_fix+=2; - fragP->fr_opcode[1]=0x00; - frag_wane(fragP); - } else { - fix_new(fragP,(int)(fragP->fr_fix),4,fragP->fr_symbol, - (symbolS *)0,fragP->fr_offset + 4,1); - fragP->fr_fix+=4; - fragP->fr_opcode[1]=0xff; - frag_wane(fragP); - break; - } - break; - - case TAB(FBRANCH,SZ_UNDEF): - if((fragP->fr_symbol->sy_type&N_TYPE)==segtype || flagseen['l']) { - fragP->fr_subtype=TAB(FBRANCH,SHORT); - fragP->fr_var+=2; - } else { - fragP->fr_subtype=TAB(FBRANCH,LONG); - fragP->fr_var+=4; - } - break; - - case TAB(PCREL,SZ_UNDEF): - if((fragP->fr_symbol->sy_type&N_TYPE)==segtype || flagseen['l']) { - fragP->fr_subtype=TAB(PCREL,SHORT); - fragP->fr_var+=2; - } else { - fragP->fr_subtype=TAB(PCREL,LONG); - fragP->fr_var+=4; - } - break; - - case TAB(BCC68000,SZ_UNDEF): - if((fragP->fr_symbol->sy_type&N_TYPE)==segtype) { - fragP->fr_subtype=TAB(BCC68000,BYTE); - break; - } - /* only Bcc 68000 instructions can come here */ - /* change bcc into b!cc/jmp absl long */ - fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ - if(flagseen['l']) { - fragP->fr_opcode[1] = 0x04; /* branch offset = 6 */ - /* JF: these were fr_opcode[2,3] */ - buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */ - buffer_address[1] = 0xf8; - fragP->fr_fix += 2; /* account for jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, - fragP->fr_offset,0); - fragP->fr_fix += 2; - } else { - fragP->fr_opcode[1] = 0x06; /* branch offset = 6 */ - /* JF: these were fr_opcode[2,3] */ - buffer_address[2] = 0x4e; /* put in jmp long (0x4ef9) */ - buffer_address[3] = 0xf9; - fragP->fr_fix += 2; /* account for jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, - fragP->fr_offset,0); - fragP->fr_fix += 4; - } - frag_wane(fragP); - break; - - case TAB(DBCC,SZ_UNDEF): - if((fragP->fr_symbol->sy_type&N_TYPE)==segtype) { - fragP->fr_subtype=TAB(DBCC,SHORT); - fragP->fr_var+=2; - break; - } - /* only DBcc 68000 instructions can come here */ - /* change dbcc into dbcc/jmp absl long */ - /* JF: these used to be fr_opcode[2-4], which is wrong. */ - buffer_address[0] = 0x00; /* branch offset = 4 */ - buffer_address[1] = 0x04; - buffer_address[2] = 0x60; /* put in bra pc + ... */ - if(flagseen['l']) { - /* JF: these were fr_opcode[5-7] */ - buffer_address[3] = 0x04; /* plus 4 */ - buffer_address[4] = 0x4e;/* Put in Jump Word */ - buffer_address[5] = 0xf8; - fragP->fr_fix += 6; /* account for bra/jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, - fragP->fr_offset,0); - fragP->fr_fix+=2; - } else { - /* JF: these were fr_opcode[5-7] */ - buffer_address[3] = 0x06; /* Plus 6 */ - buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */ - buffer_address[5] = 0xf9; - fragP->fr_fix += 6; /* account for bra/jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, - fragP->fr_offset,0); - fragP->fr_fix += 4; - } - frag_wane(fragP); - break; - - case TAB(PCLEA,SZ_UNDEF): - if((fragP->fr_symbol->sy_type&N_TYPE)==segtype || flagseen['l']) { - fragP->fr_subtype=TAB(PCLEA,SHORT); - fragP->fr_var+=2; - } else { - fragP->fr_subtype=TAB(PCLEA,LONG); - fragP->fr_var+=6; - } - break; - - default: - break; - } - - /* now that SZ_UNDEF are taken care of, check others */ - switch(fragP->fr_subtype) { - case TAB(BCC68000,BYTE): - case TAB(BRANCH,BYTE): - /* We can't do a short jump to the next instruction, - so we force word mode. */ - if(fragP->fr_symbol && fragP->fr_symbol->sy_value==0 && - fragP->fr_symbol->sy_frag==fragP->fr_next) { - fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),SHORT); - fragP->fr_var+=2; - } - break; - default: - break; - } - return fragP->fr_var + fragP->fr_fix - old_fix; -} - -/* the bit-field entries in the relocation_info struct plays hell - with the byte-order problems of cross-assembly. So as a hack, - I added this mach. dependent ri twiddler. Ugly, but it gets - you there. -KWK */ -/* on m68k: first 4 bytes are normal unsigned long, next three bytes -are symbolnum, most sig. byte first. Last byte is broken up with -bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower -nibble as nuthin. (on Sun 3 at least) */ -void -md_ri_to_chars(ri_p, ri) - struct relocation_info *ri_p, ri; -{ - unsigned char the_bytes[8]; - - /* this is easy */ - md_number_to_chars(the_bytes, ri.r_address, sizeof(ri.r_address)); - /* now the fun stuff */ - the_bytes[4] = (ri.r_symbolnum >> 16) & 0x0ff; - the_bytes[5] = (ri.r_symbolnum >> 8) & 0x0ff; - the_bytes[6] = ri.r_symbolnum & 0x0ff; - the_bytes[7] = (((ri.r_pcrel << 7) & 0x80) | ((ri.r_length << 5) & 0x60) | - ((ri.r_extern << 4) & 0x10)); - /* now put it back where you found it */ - bcopy (the_bytes, (char *)ri_p, sizeof(struct relocation_info)); -} - -#ifndef WORKING_DOT_WORD -const int md_short_jump_size = 4; -const int md_long_jump_size = 6; - -void -md_create_short_jump(ptr,from_addr,to_addr,frag,to_symbol) -char *ptr; -long from_addr, - to_addr; -fragS *frag; -symbolS *to_symbol; -{ - long offset; - - offset = to_addr - (from_addr+2); - - md_number_to_chars(ptr ,(long)0x6000,2); - md_number_to_chars(ptr+2,(long)offset,2); -} - -void -md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol) -char *ptr; -long from_addr, - to_addr; -fragS *frag; -symbolS *to_symbol; -{ - long offset; - - if(flagseen['m']) { - offset=to_addr-to_symbol->sy_value; - md_number_to_chars(ptr ,(long)0x4EF9,2); - md_number_to_chars(ptr+2,(long)offset,4); - fix_new(frag,(ptr+2)-frag->fr_literal,4,to_symbol,(symbolS *)0,(long int)0,0); - } else { - offset=to_addr - (from_addr+2); - md_number_to_chars(ptr ,(long)0x60ff,2); - md_number_to_chars(ptr+2,(long)offset,4); - } -} - -#endif -/* Different values of OK tell what its OK to return. Things that aren't OK are an error (what a shock, no?) - - 0: Everything is OK - 10: Absolute 1:8 only - 20: Absolute 0:7 only - 30: absolute 0:15 only - 40: Absolute 0:31 only - 50: absolute 0:127 only - 55: absolute -64:63 only - 60: absolute -128:127 only - 70: absolute 0:4095 only - 80: No bignums - -*/ -int -get_num(exp,ok) -struct m68k_exp *exp; -int ok; -{ -#ifdef TEST2 - long l = 0; - - if(!exp->e_beg) - return 0; - if(*exp->e_beg=='0') { - if(exp->e_beg[1]=='x') - sscanf(exp->e_beg+2,"%x",&l); - else - sscanf(exp->e_beg+1,"%O",&l); - return l; - } - return atol(exp->e_beg); -#else - char *save_in; - char c_save; - - if(!exp) { - /* Can't do anything */ - return 0; - } - if(!exp->e_beg || !exp->e_end) { - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Null expression defaults to %ld",offs(exp)); - return 0; - } - - exp->e_siz=0; - if(/* ok!=80 && */exp->e_end[-1]==':' && (exp->e_end-exp->e_beg)>=2) { - switch(exp->e_end[0]) { - case 's': - case 'S': - case 'b': - case 'B': - exp->e_siz=1; - break; - case 'w': - case 'W': - exp->e_siz=2; - break; - case 'l': - case 'L': - exp->e_siz=3; - break; - default: - as_bad("Unknown size for expression \"%c\"",exp->e_end[0]); - } - exp->e_end-=2; - } - c_save=exp->e_end[1]; - exp->e_end[1]='\0'; - save_in=input_line_pointer; - input_line_pointer=exp->e_beg; - switch(expression(&(exp->e_exp))) { - case SEG_PASS1: - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Unknown expression: '%s' defaulting to %d",exp->e_beg,offs(exp)); - break; - - case SEG_NONE: - /* Do the same thing the VAX asm does */ - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)=0; - if(ok==10) { - as_warn("expression out of range: defaulting to 1"); - offs(exp)=1; - } - break; - case SEG_ABSOLUTE: - switch(ok) { - case 10: - if(offs(exp)<1 || offs(exp)>8) { - as_warn("expression out of range: defaulting to 1"); - offs(exp)=1; - } - break; - case 20: - if(offs(exp)<0 || offs(exp)>7) - goto outrange; - break; - case 30: - if(offs(exp)<0 || offs(exp)>15) - goto outrange; - break; - case 40: - if(offs(exp)<0 || offs(exp)>32) - goto outrange; - break; - case 50: - if(offs(exp)<0 || offs(exp)>127) - goto outrange; - break; - case 55: - if(offs(exp)<-64 || offs(exp)>63) - goto outrange; - break; - case 60: - if(offs(exp)<-128 || offs(exp)>127) - goto outrange; - break; - case 70: - if(offs(exp)<0 || offs(exp)>4095) { - outrange: - as_warn("expression out of range: defaulting to 0"); - offs(exp)=0; - } - break; - default: - break; - } - break; - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_UNKNOWN: - case SEG_DIFFERENCE: - if(ok>=10 && ok<=70) { - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp)); - } - break; - case SEG_BIG: - if(ok==80 && offs(exp)<0) { /* HACK! Turn it into a long */ - LITTLENUM_TYPE words[6]; - - gen_to_words(words,2,8L);/* These numbers are magic! */ - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)=words[1]|(words[0]<<16); - } else if(ok!=0) { - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp)); - } - break; - default: - abort(); - } - if(input_line_pointer!=exp->e_end+1) - as_bad("Ignoring junk after expression"); - exp->e_end[1]=c_save; - input_line_pointer=save_in; - if(exp->e_siz) { - switch(exp->e_siz) { - case 1: - if(!isbyte(offs(exp))) - as_warn("expression doesn't fit in BYTE"); - break; - case 2: - if(!isword(offs(exp))) - as_warn("expression doesn't fit in WORD"); - break; - } - } - return offs(exp); -#endif -} - -/* These are the back-ends for the various machine dependent pseudo-ops. */ -void demand_empty_rest_of_line(); /* Hate those extra verbose names */ - -void -s_data1() -{ - subseg_new(SEG_DATA,1); - demand_empty_rest_of_line(); -} - -void -s_data2() -{ - subseg_new(SEG_DATA,2); - demand_empty_rest_of_line(); -} - -void -s_even() -{ - register int temp; - register long int temp_fill; - - temp = 1; /* JF should be 2? */ - temp_fill = get_absolute_expression (); - if ( ! need_pass_2 ) /* Never make frag if expect extra pass. */ - frag_align (temp, (int)temp_fill); - demand_empty_rest_of_line(); -} - -void -s_proc() -{ - demand_empty_rest_of_line(); -} - -/* s_space is defined in read.c .skip is simply an alias to it. */ - -int -md_parse_option(argP,cntP,vecP) -char **argP; -int *cntP; -char ***vecP; -{ - switch(**argP) { - case 'l': /* -l means keep external to 2 bit offset - rather than 16 bit one */ - break; - - case 'm': - /* Gas almost ignores this option! */ - (*argP)++; - if(**argP=='c') - (*argP)++; - if(!strcmp(*argP,"68000")) - flagseen['m']=2; - else if(!strcmp(*argP,"68010")) { -#ifdef M_SUN - omagic= 1<<16|OMAGIC; -#endif - flagseen['m']=1; - } else if(!strcmp(*argP,"68020")) - flagseen['m']=0; - else - as_warn("Unknown -m option ignored"); - while(**argP) - (*argP)++; - break; - - default: - return 0; - } - return 1; -} - - -#ifdef TEST2 - -/* TEST2: Test md_assemble() */ -/* Warning, this routine probably doesn't work anymore */ - -main() -{ - struct m68_it the_ins; - char buf[120]; - char *cp; - int n; - - m68_ip_begin(); - for(;;) { - if(!gets(buf) || !*buf) - break; - if(buf[0]=='|' || buf[1]=='.') - continue; - for(cp=buf;*cp;cp++) - if(*cp=='\t') - *cp=' '; - if(is_label(buf)) - continue; - bzero(&the_ins,sizeof(the_ins)); - m68_ip(&the_ins,buf); - if(the_ins.error) { - printf("Error %s in %s\n",the_ins.error,buf); - } else { - printf("Opcode(%d.%s): ",the_ins.numo,the_ins.args); - for(n=0;nfr_next) { - printf("addr %lu next 0x%x fix %ld var %ld symbol 0x%x offset %ld\n", - fragP->fr_address,fragP->fr_next,fragP->fr_fix,fragP->fr_var,fragP->fr_symbol,fragP->fr_offset); - printf("opcode 0x%x type %d subtype %d\n\n",fragP->fr_opcode,fragP->fr_type,fragP->fr_subtype); - } - fflush(stdout); - return 0; -} -#endif - -#ifdef DONTDEF -/*VARARGS1*/ -panic(format,args) -char *format; -{ - fputs("Internal error:",stderr); - _doprnt(format,&args,stderr); - (void)putc('\n',stderr); - as_where(); - abort(); -} -#endif diff --git a/gnu/usr.bin/gas/config/m68k.h b/gnu/usr.bin/gas/config/m68k.h deleted file mode 100644 index 7cdb223bbea7..000000000000 --- a/gnu/usr.bin/gas/config/m68k.h +++ /dev/null @@ -1,23 +0,0 @@ -/* m-generic.h Generic machine-specific header file. - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m68k.h,v 1.2 1993/08/02 17:27:12 mycroft Exp $ -*/ - -#define M_GENERIC 1 diff --git a/gnu/usr.bin/gas/config/ns32k-opcode.h b/gnu/usr.bin/gas/config/ns32k-opcode.h deleted file mode 100644 index 1d1586cd653c..000000000000 --- a/gnu/usr.bin/gas/config/ns32k-opcode.h +++ /dev/null @@ -1,437 +0,0 @@ -/* ns32k-opcode.h -- Opcode table for National Semi 32k processor - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: ns32k-opcode.h,v 1.2 1993/08/02 17:27:14 mycroft Exp $ -*/ - - -#ifdef SEQUENT_COMPATABILITY -#define DEF_MODEC 20 -#define DEF_MODEL 21 -#endif - -#ifndef DEF_MODEC -#define DEF_MODEC 20 -#endif - -#ifndef DEF_MODEL -#define DEF_MODEL 20 -#endif -/* - After deciding the instruction entry (via hash.c) the instruction parser - will try to match the operands after the instruction to the required set - given in the entry operandfield. Every operand will result in a change in - the opcode or the addition of data to the opcode. - The operands in the source instruction are checked for inconsistent - semantics. - - F : 32 bit float general form - L : 64 bit float " - B : byte " - W : word " - D : double-word " - Q : quad-word " - A : double-word gen-address-form ie no regs allowed - d : displacement - b : displacement - pc relative addressing acb - p : displacement - pc relative addressing br bcond bsr cxp - q : quick - i : immediate (8 bits) - This is not a standard ns32k operandtype, it is used to build - instructions like svc arg1,arg2 - Svc is the instruction SuperVisorCall and is sometimes used to - call OS-routines from usermode. Some args might be handy! - r : register number (3 bits) - O : setcfg instruction optionslist - C : cinv instruction optionslist - S : stringinstruction optionslist - U : registerlist save,enter - u : registerlist restore,exit - M : mmu register - P : cpu register - g : 3:rd operand of inss or exts instruction - G : 4:th operand of inss or exts instruction - Those operands are encoded in the same byte. - This byte is placed last in the instruction. - f : operand of sfsr - H : sequent-hack for bsr (Warning) - -column 1 instructions - 2 number of bits in opcode. - 3 number of bits in opcode explicitly - determined by the instruction type. - 4 opcodeseed, the number we build our opcode - from. - 5 operandtypes, used by operandparser. - 6 size in bytes of immediate -*/ -struct ns32k_opcode { - char *name; - unsigned char opcode_id_size; /* not used by the assembler */ - unsigned char opcode_size; - unsigned long opcode_seed; - char *operands; - unsigned char im_size; /* not used by dissassembler */ - char *default_args; /* default to those args when none given */ - char default_modec; /* default to this addr-mode when ambigous - ie when the argument of a general addr-mode - is a plain constant */ - char default_model; /* is a plain label */ -}; - -struct ns32k_opcode ns32k_opcodes[]= -{ - { "absf", 14,24, 0x35be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "absl", 14,24, 0x34be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "absb", 14,24, 0x304e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "absw", 14,24, 0x314e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "absd", 14,24, 0x334e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "acbb", 7,16, 0x4c, "2B1q3p", 1, "", DEF_MODEC,DEF_MODEL }, - { "acbw", 7,16, 0x4d, "2W1q3p", 2, "", DEF_MODEC,DEF_MODEL }, - { "acbd", 7,16, 0x4f, "2D1q3p", 4, "", DEF_MODEC,DEF_MODEL }, - { "addf", 14,24, 0x01be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "addl", 14,24, 0x00be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "addb", 6,16, 0x00, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "addw", 6,16, 0x01, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "addd", 6,16, 0x03, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "addcb", 6,16, 0x10, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "addcw", 6,16, 0x11, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "addcd", 6,16, 0x13, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "addpb", 14,24, 0x3c4e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "addpw", 14,24, 0x3d4e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "addpd", 14,24, 0x3f4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "addqb", 7,16, 0x0c, "2B1q", 1, "", DEF_MODEC,DEF_MODEL }, - { "addqw", 7,16, 0x0d, "2W1q", 2, "", DEF_MODEC,DEF_MODEL }, - { "addqd", 7,16, 0x0f, "2D1q", 4, "", DEF_MODEC,DEF_MODEL }, - { "addr", 6,16, 0x27, "1A2D", 4, "", 21,21 }, - { "adjspb", 11,16, 0x057c, "1B", 1, "", DEF_MODEC,DEF_MODEL }, - { "adjspw", 11,16, 0x057d, "1W", 2, "", DEF_MODEC,DEF_MODEL }, - { "adjspd", 11,16, 0x057f, "1D", 4, "", DEF_MODEC,DEF_MODEL }, - { "andb", 6,16, 0x28, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "andw", 6,16, 0x29, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "andd", 6,16, 0x2b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "ashb", 14,24, 0x044e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "ashw", 14,24, 0x054e, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "ashd", 14,24, 0x074e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "beq", 8,8, 0x0a, "1p", 0, "", 21,21 }, - { "bne", 8,8, 0x1a, "1p", 0, "", 21,21 }, - { "bcs", 8,8, 0x2a, "1p", 0, "", 21,21 }, - { "bcc", 8,8, 0x3a, "1p", 0, "", 21,21 }, - { "bhi", 8,8, 0x4a, "1p", 0, "", 21,21 }, - { "bls", 8,8, 0x5a, "1p", 0, "", 21,21 }, - { "bgt", 8,8, 0x6a, "1p", 0, "", 21,21 }, - { "ble", 8,8, 0x7a, "1p", 0, "", 21,21 }, - { "bfs", 8,8, 0x8a, "1p", 0, "", 21,21 }, - { "bfc", 8,8, 0x9a, "1p", 0, "", 21,21 }, - { "blo", 8,8, 0xaa, "1p", 0, "", 21,21 }, - { "bhs", 8,8, 0xba, "1p", 0, "", 21,21 }, - { "blt", 8,8, 0xca, "1p", 0, "", 21,21 }, - { "bge", 8,8, 0xda, "1p", 0, "", 21,21 }, - { "but", 8,8, 0xea, "1p", 0, "", 21,21 }, - { "buf", 8,8, 0xfa, "1p", 0, "", 21,21 }, - { "bicb", 6,16, 0x08, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "bicw", 6,16, 0x09, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "bicd", 6,16, 0x0b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "bicpsrb", 11,16, 0x17c, "1B", 1, "", DEF_MODEC,DEF_MODEL }, - { "bicpsrw", 11,16, 0x17d, "1W", 2, "", DEF_MODEC,DEF_MODEL }, - { "bispsrb", 11,16, 0x37c, "1B", 1, "", DEF_MODEC,DEF_MODEL }, - { "bispsrw", 11,16, 0x37d, "1W", 2, "", DEF_MODEC,DEF_MODEL }, - { "bpt", 8,8, 0xf2, "", 0, "", DEF_MODEC,DEF_MODEL }, - { "br", 8,8, 0xea, "1p", 0, "", 21,21 }, -#ifdef SEQUENT_COMPATABILITY - { "bsr", 8,8, 0x02, "1H", 0, "", 21,21 }, -#else - { "bsr", 8,8, 0x02, "1p", 0, "", 21,21 }, -#endif - { "caseb", 11,16, 0x77c, "1B", 1, "", DEF_MODEC,DEF_MODEL }, - { "casew", 11,16, 0x77d, "1W", 2, "", DEF_MODEC,DEF_MODEL }, - { "cased", 11,16, 0x77f, "1D", 4, "", DEF_MODEC,DEF_MODEL }, - { "cbitb", 14,24, 0x084e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "cbitw", 14,24, 0x094e, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "cbitd", 14,24, 0x0b4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "cbitib", 14,24, 0x0c4e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "cbitiw", 14,24, 0x0d4e, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "cbitid", 14,24, 0x0f4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "checkb", 11,24, 0x0ee, "2A3B1r", 1, "", DEF_MODEC,DEF_MODEL }, - { "checkw", 11,24, 0x1ee, "2A3W1r", 2, "", DEF_MODEC,DEF_MODEL }, - { "checkd", 11,24, 0x3ee, "2A3D1r", 4, "", DEF_MODEC,DEF_MODEL }, - { "cinv", 14,24, 0x271e, "2D1C", 4, "", DEF_MODEC,DEF_MODEL }, - { "cmpf", 14,24, 0x09be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "cmpl", 14,24, 0x08be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "cmpb", 6,16, 0x04, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "cmpw", 6,16, 0x05, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "cmpd", 6,16, 0x07, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "cmpmb", 14,24, 0x04ce, "1A2A3b", 1, "", DEF_MODEC,DEF_MODEL }, - { "cmpmw", 14,24, 0x05ce, "1A2A3b", 2, "", DEF_MODEC,DEF_MODEL }, - { "cmpmd", 14,24, 0x07ce, "1A2A3b", 4, "", DEF_MODEC,DEF_MODEL }, - { "cmpqb", 7,16, 0x1c, "2B1q", 1, "", DEF_MODEC,DEF_MODEL }, - { "cmpqw", 7,16, 0x1d, "2W1q", 2, "", DEF_MODEC,DEF_MODEL }, - { "cmpqd", 7,16, 0x1f, "2D1q", 4, "", DEF_MODEC,DEF_MODEL }, - { "cmpsb", 16,24, 0x040e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "cmpsw", 16,24, 0x050e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "cmpsd", 16,24, 0x070e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "cmpst", 16,24, 0x840e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "comb", 14,24, 0x344e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "comw", 14,24, 0x354e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "comd", 14,24, 0x374e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "cvtp", 11,24, 0x036e, "2A3D1r", 4, "", DEF_MODEC,DEF_MODEL }, - { "cxp", 8,8, 0x22, "1p", 0, "", 21,21 }, - { "cxpd", 11,16, 0x07f, "1A", 4, "", DEF_MODEC,DEF_MODEL }, - { "deib", 14,24, 0x2cce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "deiw", 14,24, 0x2dce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "deid", 14,24, 0x2fce, "1D2Q", 4, "", DEF_MODEC,DEF_MODEL }, - { "dia", 8,8, 0xc2, "", 1, "", DEF_MODEC,DEF_MODEL }, - { "divf", 14,24, 0x21be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "divl", 14,24, 0x20be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "divb", 14,24, 0x3cce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "divw", 14,24, 0x3dce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "divd", 14,24, 0x3fce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "enter", 8,8, 0x82, "1U2d", 0, "", DEF_MODEC,DEF_MODEL }, - { "exit", 8,8, 0x92, "1u", 0, "", DEF_MODEC,DEF_MODEL }, - { "extb", 11,24, 0x02e, "2D3B1r4d", 1, "", DEF_MODEC,DEF_MODEL }, - { "extw", 11,24, 0x12e, "2D3W1r4d", 2, "", DEF_MODEC,DEF_MODEL }, - { "extd", 11,24, 0x32e, "2D3D1r4d", 4, "", DEF_MODEC,DEF_MODEL }, - { "extsb", 14,24, 0x0cce, "1D2B3g4G", 1, "", DEF_MODEC,DEF_MODEL }, - { "extsw", 14,24, 0x0dce, "1D2W3g4G", 2, "", DEF_MODEC,DEF_MODEL }, - { "extsd", 14,24, 0x0fce, "1D2D3g4G", 4, "", DEF_MODEC,DEF_MODEL }, - { "ffsb", 14,24, 0x046e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "ffsw", 14,24, 0x056e, "1W2B", 2, "", DEF_MODEC,DEF_MODEL }, - { "ffsd", 14,24, 0x076e, "1D2B", 4, "", DEF_MODEC,DEF_MODEL }, - { "flag", 8,8, 0xd2, "", 0, "", DEF_MODEC,DEF_MODEL }, - { "floorfb", 14,24, 0x3c3e, "1F2B", 4, "", DEF_MODEC,DEF_MODEL }, - { "floorfw", 14,24, 0x3d3e, "1F2W", 4, "", DEF_MODEC,DEF_MODEL }, - { "floorfd", 14,24, 0x3f3e, "1F2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "floorlb", 14,24, 0x383e, "1L2B", 8, "", DEF_MODEC,DEF_MODEL }, - { "floorlw", 14,24, 0x393e, "1L2W", 8, "", DEF_MODEC,DEF_MODEL }, - { "floorld", 14,24, 0x3b3e, "1L2D", 8, "", DEF_MODEC,DEF_MODEL }, - { "ibitb", 14,24, 0x384e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "ibitw", 14,24, 0x394e, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "ibitd", 14,24, 0x3b4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "indexb", 11,24, 0x42e, "2B3B1r", 1, "", DEF_MODEC,DEF_MODEL }, - { "indexw", 11,24, 0x52e, "2W3W1r", 2, "", DEF_MODEC,DEF_MODEL }, - { "indexd", 11,24, 0x72e, "2D3D1r", 4, "", DEF_MODEC,DEF_MODEL }, - { "insb", 11,24, 0x0ae, "2B3B1r4d", 1, "", DEF_MODEC,DEF_MODEL }, - { "insw", 11,24, 0x1ae, "2W3W1r4d", 2, "", DEF_MODEC,DEF_MODEL }, - { "insd", 11,24, 0x3ae, "2D3D1r4d", 4, "", DEF_MODEC,DEF_MODEL }, - { "inssb", 14,24, 0x08ce, "1B2D3g4G", 1, "", DEF_MODEC,DEF_MODEL }, - { "inssw", 14,24, 0x09ce, "1W2D3g4G", 2, "", DEF_MODEC,DEF_MODEL }, - { "inssd", 14,24, 0x0bce, "1D2D3g4G", 4, "", DEF_MODEC,DEF_MODEL }, - { "jsr", 11,16, 0x67f, "1A", 4, "", 21,21 }, - { "jump", 11,16, 0x27f, "1A", 4, "", 21,21 }, - { "lfsr", 19,24, 0x00f3e,"1D", 4, "", DEF_MODEC,DEF_MODEL }, - { "lmr", 15,24, 0x0b1e, "2D1M", 4, "", DEF_MODEC,DEF_MODEL }, - { "lprb", 7,16, 0x6c, "2B1P", 1, "", DEF_MODEC,DEF_MODEL }, - { "lprw", 7,16, 0x6d, "2W1P", 2, "", DEF_MODEC,DEF_MODEL }, - { "lprd", 7,16, 0x6f, "2D1P", 4, "", DEF_MODEC,DEF_MODEL }, - { "lshb", 14,24, 0x144e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "lshw", 14,24, 0x154e, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "lshd", 14,24, 0x174e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "meib", 14,24, 0x24ce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "meiw", 14,24, 0x25ce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "meid", 14,24, 0x27ce, "1D2Q", 4, "", DEF_MODEC,DEF_MODEL }, - { "modb", 14,24, 0x38ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "modw", 14,24, 0x39ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "modd", 14,24, 0x3bce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "movf", 14,24, 0x05be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "movl", 14,24, 0x04be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "movb", 6,16, 0x14, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "movw", 6,16, 0x15, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "movd", 6,16, 0x17, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "movbf", 14,24, 0x043e, "1B2F", 1, "", DEF_MODEC,DEF_MODEL }, - { "movwf", 14,24, 0x053e, "1W2F", 2, "", DEF_MODEC,DEF_MODEL }, - { "movdf", 14,24, 0x073e, "1D2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "movbl", 14,24, 0x003e, "1B2L", 1, "", DEF_MODEC,DEF_MODEL }, - { "movwl", 14,24, 0x013e, "1W2L", 2, "", DEF_MODEC,DEF_MODEL }, - { "movdl", 14,24, 0x033e, "1D2L", 4, "", DEF_MODEC,DEF_MODEL }, - { "movfl", 14,24, 0x1b3e, "1F2L", 4, "", DEF_MODEC,DEF_MODEL }, - { "movlf", 14,24, 0x163e, "1L2F", 8, "", DEF_MODEC,DEF_MODEL }, - { "movmb", 14,24, 0x00ce, "1A2A3b", 1, "", DEF_MODEC,DEF_MODEL }, - { "movmw", 14,24, 0x01ce, "1A2A3b", 2, "", DEF_MODEC,DEF_MODEL }, - { "movmd", 14,24, 0x03ce, "1A2A3b", 4, "", DEF_MODEC,DEF_MODEL }, - { "movqb", 7,16, 0x5c, "2B1q", 1, "", DEF_MODEC,DEF_MODEL }, - { "movqw", 7,16, 0x5d, "2B1q", 2, "", DEF_MODEC,DEF_MODEL }, - { "movqd", 7,16, 0x5f, "2B1q", 4, "", DEF_MODEC,DEF_MODEL }, - { "movsb", 16,24, 0x000e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "movsw", 16,24, 0x010e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "movsd", 16,24, 0x030e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "movst", 16,24, 0x800e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "movsub", 14,24, 0x0cae, "1A2A", 1, "", DEF_MODEC,DEF_MODEL }, - { "movsuw", 14,24, 0x0dae, "1A2A", 2, "", DEF_MODEC,DEF_MODEL }, - { "movsud", 14,24, 0x0fae, "1A2A", 4, "", DEF_MODEC,DEF_MODEL }, - { "movusb", 14,24, 0x1cae, "1A2A", 1, "", DEF_MODEC,DEF_MODEL }, - { "movusw", 14,24, 0x1dae, "1A2A", 2, "", DEF_MODEC,DEF_MODEL }, - { "movusd", 14,24, 0x1fae, "1A2A", 4, "", DEF_MODEC,DEF_MODEL }, - { "movxbd", 14,24, 0x1cce, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "movxwd", 14,24, 0x1dce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "movxbw", 14,24, 0x10ce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "movzbd", 14,24, 0x18ce, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "movzwd", 14,24, 0x19ce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "movzbw", 14,24, 0x14ce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "mulf", 14,24, 0x31be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "mull", 14,24, 0x30be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "mulb", 14,24, 0x20ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "mulw", 14,24, 0x21ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "muld", 14,24, 0x23ce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "negf", 14,24, 0x15be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "negl", 14,24, 0x14be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "negb", 14,24, 0x204e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "negw", 14,24, 0x214e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "negd", 14,24, 0x234e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "nop", 8,8, 0xa2, "", 0, "", DEF_MODEC,DEF_MODEL }, - { "notb", 14,24, 0x244e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "notw", 14,24, 0x254e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "notd", 14,24, 0x274e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "orb", 6,16, 0x18, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "orw", 6,16, 0x19, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "ord", 6,16, 0x1b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "quob", 14,24, 0x30ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "quow", 14,24, 0x31ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "quod", 14,24, 0x33ce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "rdval", 19,24, 0x0031e,"1A", 4, "", DEF_MODEC,DEF_MODEL }, - { "remb", 14,24, 0x34ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "remw", 14,24, 0x35ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "remd", 14,24, 0x37ce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "restore", 8,8, 0x72, "1u", 0, "", DEF_MODEC,DEF_MODEL }, - { "ret", 8,8, 0x12, "1d", 0, "", DEF_MODEC,DEF_MODEL }, - { "reti", 8,8, 0x52, "", 0, "", DEF_MODEC,DEF_MODEL }, - { "rett", 8,8, 0x42, "1d", 0, "", DEF_MODEC,DEF_MODEL }, - { "rotb", 14,24, 0x004e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "rotw", 14,24, 0x014e, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "rotd", 14,24, 0x034e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "roundfb", 14,24, 0x243e, "1F2B", 4, "", DEF_MODEC,DEF_MODEL }, - { "roundfw", 14,24, 0x253e, "1F2W", 4, "", DEF_MODEC,DEF_MODEL }, - { "roundfd", 14,24, 0x273e, "1F2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "roundlb", 14,24, 0x203e, "1L2B", 8, "", DEF_MODEC,DEF_MODEL }, - { "roundlw", 14,24, 0x213e, "1L2W", 8, "", DEF_MODEC,DEF_MODEL }, - { "roundld", 14,24, 0x233e, "1L2D", 8, "", DEF_MODEC,DEF_MODEL }, - { "rxp", 8,8, 0x32, "1d", 0, "", DEF_MODEC,DEF_MODEL }, - { "seqb", 11,16, 0x3c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "seqw", 11,16, 0x3d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "seqd", 11,16, 0x3f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sneb", 11,16, 0xbc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "snew", 11,16, 0xbd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sned", 11,16, 0xbf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "scsb", 11,16, 0x13c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "scsw", 11,16, 0x13d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "scsd", 11,16, 0x13f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sccb", 11,16, 0x1bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sccw", 11,16, 0x1bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sccd", 11,16, 0x1bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "shib", 11,16, 0x23c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "shiw", 11,16, 0x23d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "shid", 11,16, 0x23f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "slsb", 11,16, 0x2bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "slsw", 11,16, 0x2bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "slsd", 11,16, 0x2bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sgtb", 11,16, 0x33c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sgtw", 11,16, 0x33d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sgtd", 11,16, 0x33f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sleb", 11,16, 0x3bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "slew", 11,16, 0x3bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sled", 11,16, 0x3bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfsb", 11,16, 0x43c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfsw", 11,16, 0x43d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfsd", 11,16, 0x43f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfcb", 11,16, 0x4bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfcw", 11,16, 0x4bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfcd", 11,16, 0x4bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "slob", 11,16, 0x53c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "slow", 11,16, 0x53d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "slod", 11,16, 0x53f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "shsb", 11,16, 0x5bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "shsw", 11,16, 0x5bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "shsd", 11,16, 0x5bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sltb", 11,16, 0x63c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sltw", 11,16, 0x63d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sltd", 11,16, 0x63f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sgeb", 11,16, 0x6bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sgew", 11,16, 0x6bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sged", 11,16, 0x6bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sutb", 11,16, 0x73c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sutw", 11,16, 0x73d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sutd", 11,16, 0x73f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sufb", 11,16, 0x7bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sufw", 11,16, 0x7bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sufd", 11,16, 0x7bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "save", 8,8, 0x62, "1U", 0, "", DEF_MODEC,DEF_MODEL }, - { "sbitb", 14,24, 0x184e, "1B2A", 1, "", DEF_MODEC,DEF_MODEL }, - { "sbitw", 14,24, 0x194e, "1W2A", 2, "", DEF_MODEC,DEF_MODEL }, - { "sbitd", 14,24, 0x1b4e, "1D2A", 4, "", DEF_MODEC,DEF_MODEL }, - { "sbitib", 14,24, 0x1c4e, "1B2A", 1, "", DEF_MODEC,DEF_MODEL }, - { "sbitiw", 14,24, 0x1d4e, "1W2A", 2, "", DEF_MODEC,DEF_MODEL }, - { "sbitid", 14,24, 0x1f4e, "1D2A", 4, "", DEF_MODEC,DEF_MODEL }, - { "setcfg", 15,24, 0x0b0e, "1O", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfsr", 14,24, 0x373e, "1f", 0, "", DEF_MODEC,DEF_MODEL }, - { "skpsb", 16,24, 0x0c0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "skpsw", 16,24, 0x0d0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "skpsd", 16,24, 0x0f0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "skpst", 16,24, 0x8c0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "smr", 15,24, 0x0f1e, "2D1M", 4, "", DEF_MODEC,DEF_MODEL }, - { "sprb", 7,16, 0x2c, "2B1P", 1, "", DEF_MODEC,DEF_MODEL }, - { "sprw", 7,16, 0x2d, "2W1P", 2, "", DEF_MODEC,DEF_MODEL }, - { "sprd", 7,16, 0x2f, "2D1P", 4, "", DEF_MODEC,DEF_MODEL }, - { "subf", 14,24, 0x11be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "subl", 14,24, 0x10be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "subb", 6,16, 0x20, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "subw", 6,16, 0x21, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "subd", 6,16, 0x23, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "subcb", 6,16, 0x30, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "subcw", 6,16, 0x31, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "subcd", 6,16, 0x33, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "subpb", 14,24, 0x2c4e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "subpw", 14,24, 0x2d4e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "subpd", 14,24, 0x2f4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, -#ifdef NS32K_SVC_IMMED_OPERANDS - { "svc", 8,8, 0xe2, "2i1i", 1, "", DEF_MODEC,DEF_MODEL }, /* not really, but unix uses it */ -#else - { "svc", 8,8, 0xe2, "", 0, "", DEF_MODEC,DEF_MODEL }, -#endif - { "tbitb", 6,16, 0x34, "1B2A", 1, "", DEF_MODEC,DEF_MODEL }, - { "tbitw", 6,16, 0x35, "1W2A", 2, "", DEF_MODEC,DEF_MODEL }, - { "tbitd", 6,16, 0x37, "1D2A", 4, "", DEF_MODEC,DEF_MODEL }, - { "truncfb", 14,24, 0x2c3e, "1F2B", 4, "", DEF_MODEC,DEF_MODEL }, - { "truncfw", 14,24, 0x2d3e, "1F2W", 4, "", DEF_MODEC,DEF_MODEL }, - { "truncfd", 14,24, 0x2f3e, "1F2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "trunclb", 14,24, 0x283e, "1L2B", 8, "", DEF_MODEC,DEF_MODEL }, - { "trunclw", 14,24, 0x293e, "1L2W", 8, "", DEF_MODEC,DEF_MODEL }, - { "truncld", 14,24, 0x2b3e, "1L2D", 8, "", DEF_MODEC,DEF_MODEL }, - { "wait", 8,8, 0xb2, "", 0, "", DEF_MODEC,DEF_MODEL }, - { "wrval", 19,24, 0x0071e,"1A", 0, "", DEF_MODEC,DEF_MODEL }, - { "xorb", 6,16, 0x38, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "xorw", 6,16, 0x39, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "xord", 6,16, 0x3b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, -#if defined(NS32381) /* I'm not too sure of these */ - { "dotf", 14,24, 0x0dfe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "dotl", 14,24, 0x0cfe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "logbf", 14,24, 0x15fe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "logbl", 14,24, 0x14fe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "polyf", 14,24, 0x09fe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "polyl", 14,24, 0x08fe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "scalbf", 14,24, 0x11fe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "scalbl", 14,24, 0x10fe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, -#endif -}; - -int numopcodes=sizeof(ns32k_opcodes)/sizeof(ns32k_opcodes[0]); - -struct ns32k_opcode *endop = ns32k_opcodes+sizeof(ns32k_opcodes)/sizeof(ns32k_opcodes[0]); - -#define MAX_ARGS 4 -#define ARG_LEN 50 - diff --git a/gnu/usr.bin/gas/config/ns32k.c b/gnu/usr.bin/gas/config/ns32k.c deleted file mode 100644 index 700ff0606bed..000000000000 --- a/gnu/usr.bin/gas/config/ns32k.c +++ /dev/null @@ -1,1772 +0,0 @@ -/* ns32k.c -- Assemble on the National Semiconductor 32k series - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: ns32k.c,v 1.2 1993/08/02 17:27:16 mycroft Exp $"; -#endif /* not lint */ - -#define NS32K -/*#define SHOW_NUM 1*/ /* uncomment for debugging */ - -#include -#include -#ifdef USG -#include -#else -#include -#endif -#include "ns32k-opcode.h" -#include "as.h" -#include "obstack.h" -#include "frags.h" -#include "struc-symbol.h" -#include "flonum.h" -#include "expr.h" -#include "md.h" -#include "hash.h" -#include "write.h" -#include "symbols.h" - -/* Macros */ -#define IIF_ENTRIES 13 /* number of entries in iif */ -#define PRIVATE_SIZE 256 /* size of my garbage memory */ -#define MAX_ARGS 4 -#define DEFAULT -1 /* addr_mode returns this value when plain constant or label is encountered */ - -#define IIF(ptr,a1,c1,e1,g1,i1,k1,m1,o1,q1,s1,u1) \ - iif.iifP[ptr].type= a1; \ - iif.iifP[ptr].size= c1; \ - iif.iifP[ptr].object= e1; \ - iif.iifP[ptr].object_adjust= g1; \ - iif.iifP[ptr].pcrel= i1; \ - iif.iifP[ptr].pcrel_adjust= k1; \ - iif.iifP[ptr].im_disp= m1; \ - iif.iifP[ptr].relax_substate= o1; \ - iif.iifP[ptr].bit_fixP= q1; \ - iif.iifP[ptr].addr_mode= s1; \ - iif.iifP[ptr].bsr= u1; - -#ifdef SEQUENT_COMPATABILITY -#define LINE_COMMENT_CHARS "|" -#define ABSOLUTE_PREFIX '@' -#define IMMEDIATE_PREFIX '#' -#endif - -#ifndef LINE_COMMENT_CHARS -#define LINE_COMMENT_CHARS "#" -#endif - -char comment_chars[] = "#"; -char line_comment_chars[] = LINE_COMMENT_CHARS; -#if !defined(ABSOLUTE_PREFIX) && !defined(IMMEDIATE_PREFIX) -#define ABSOLUTE_PREFIX '@' /* One or the other MUST be defined */ -#endif - -struct addr_mode { - char mode; /* addressing mode of operand (0-31) */ - char scaled_mode; /* mode combined with scaled mode */ - char scaled_reg; /* register used in scaled+1 (1-8) */ - char float_flag; /* set if R0..R7 was F0..F7 ie a floating-point-register */ - char am_size; /* estimated max size of general addr-mode parts*/ - char im_disp; /* if im_disp==1 we have a displacement */ - char pcrel; /* 1 if pcrel, this is really redundant info */ - char disp_suffix[2]; /* length of displacement(s), 0=undefined */ - char *disp[2]; /* pointer(s) at displacement(s) - or immediates(s) (ascii) */ - char index_byte; /* index byte */ -}; -typedef struct addr_mode addr_modeS; - - -char *freeptr,*freeptr_static; /* points at some number of free bytes */ -struct hash_control *inst_hash_handle; - -struct ns32k_opcode *desc; /* pointer at description of instruction */ -addr_modeS addr_modeP; -char EXP_CHARS[] = "eE"; -char FLT_CHARS[] = "fd"; /* we don't want to support lowercase, do we */ -long omagic = OMAGIC; -void md_number_to_disp(); -void md_number_to_imm(); -segT evaluate_expr(); -void fix_new_ns32k(); - -/* UPPERCASE denotes live names - * when an instruction is built, IIF is used as an intermidiate form to store - * the actual parts of the instruction. A ns32k machine instruction can - * be divided into a couple of sub PARTs. When an instruction is assembled - * the appropriate PART get an assignment. When an IIF has been completed it's - * converted to a FRAGment as specified in AS.H */ - -/* internal structs */ -struct option { - char *pattern; - unsigned long or; - unsigned long and; -}; - -typedef struct { - int type; /* how to interpret object */ - int size; /* Estimated max size of object */ - unsigned long object; /* binary data */ - int object_adjust; /* number added to object */ - int pcrel; /* True if object is pcrel */ - int pcrel_adjust; /* It's value reflects the length in bytes from the instruction start to the displacement */ - int im_disp; /* True if the object is a displacement */ - relax_substateT relax_substate; /* Initial relaxsubstate */ - bit_fixS *bit_fixP; /* Pointer at bit_fix struct */ - int addr_mode; /* What addrmode do we associate with this iif-entry */ - char bsr; /* Sequent hack */ -}iif_entryT; /* Internal Instruction Format */ -struct int_ins_form { - int instr_size; /* Max size of instruction in bytes. */ - iif_entryT iifP[IIF_ENTRIES+1]; -}; -struct int_ins_form iif; -expressionS exprP; -char *input_line_pointer; -/* description of the PARTs in IIF - *object[n]: - * 0 total length in bytes of entries in iif - * 1 opcode - * 2 index_byte_a - * 3 index_byte_b - * 4 disp_a_1 - * 5 disp_a_2 - * 6 disp_b_1 - * 7 disp_b_2 - * 8 imm_a - * 9 imm_b - * 10 implied1 - * 11 implied2 - * - * For every entry there is a datalength in bytes. This is stored in size[n]. - * 0, the objectlength is not explicitly given by the instruction - * and the operand is undefined. This is a case for relaxation. - * Reserve 4 bytes for the final object. - * - * 1, the entry contains one byte - * 2, the entry contains two bytes - * 3, the entry contains three bytes - * 4, the entry contains four bytes - * etc - * - * Furthermore, every entry has a data type identifier in type[n]. - * - * 0, the entry is void, ignore it. - * 1, the entry is a binary number. - * 2, the entry is a pointer at an expression. - * Where expression may be as simple as a single '1', - * and as complicated as foo-bar+12, - * foo and bar may be undefined but suffixed by :{b|w|d} to - * control the length of the object. - * - * 3, the entry is a pointer at a bignum struct - * - * - * The low-order-byte coresponds to low physical memory. - * Obviously a FRAGment must be created for each valid disp in PART whose - * datalength is undefined (to bad) . - * The case where just the expression is undefined is less severe and is - * handled by fix. Here the number of bytes in the objectfile is known. - * With this representation we simplify the assembly and separates the - * machine dependent/independent parts in a more clean way (said OE) - */ - -struct option opt1[]= /* restore, exit */ -{ - { "r0", 0x80, 0xff }, - { "r1", 0x40, 0xff }, - { "r2", 0x20, 0xff }, - { "r3", 0x10, 0xff }, - { "r4", 0x08, 0xff }, - { "r5", 0x04, 0xff }, - { "r6", 0x02, 0xff }, - { "r7", 0x01, 0xff }, - { 0 , 0x00, 0xff } -}; -struct option opt2[]= /* save, enter */ -{ - { "r0", 0x01, 0xff }, - { "r1", 0x02, 0xff }, - { "r2", 0x04, 0xff }, - { "r3", 0x08, 0xff }, - { "r4", 0x10, 0xff }, - { "r5", 0x20, 0xff }, - { "r6", 0x40, 0xff }, - { "r7", 0x80, 0xff }, - { 0 , 0x00, 0xff } -}; -struct option opt3[]= /* setcfg */ -{ - { "c", 0x8, 0xff }, - { "m", 0x4, 0xff }, - { "f", 0x2, 0xff }, - { "i", 0x1, 0xff }, - { 0 , 0x0, 0xff } -}; -struct option opt4[]= /* cinv */ -{ - { "a", 0x4, 0xff }, - { "i", 0x2, 0xff }, - { "d", 0x1, 0xff }, - { 0 , 0x0, 0xff } -}; -struct option opt5[]= /* string inst */ -{ - { "b", 0x2, 0xff }, - { "u", 0xc, 0xff }, - { "w", 0x4, 0xff }, - { 0 , 0x0, 0xff } -}; -struct option opt6[]= /* plain reg ext,cvtp etc */ -{ - { "r0", 0x00, 0xff }, - { "r1", 0x01, 0xff }, - { "r2", 0x02, 0xff }, - { "r3", 0x03, 0xff }, - { "r4", 0x04, 0xff }, - { "r5", 0x05, 0xff }, - { "r6", 0x06, 0xff }, - { "r7", 0x07, 0xff }, - { 0 , 0x00, 0xff } -}; - -#if !defined(NS32032) && !defined(NS32532) -#define NS32032 -#endif - -struct option cpureg_532[]= /* lpr spr */ -{ - { "us", 0x0, 0xff }, - { "dcr", 0x1, 0xff }, - { "bpc", 0x2, 0xff }, - { "dsr", 0x3, 0xff }, - { "car", 0x4, 0xff }, - { "fp", 0x8, 0xff }, - { "sp", 0x9, 0xff }, - { "sb", 0xa, 0xff }, - { "usp", 0xb, 0xff }, - { "cfg", 0xc, 0xff }, - { "psr", 0xd, 0xff }, - { "intbase", 0xe, 0xff }, - { "mod", 0xf, 0xff }, - { 0 , 0x00, 0xff } -}; -struct option mmureg_532[]= /* lmr smr */ -{ - { "mcr", 0x9, 0xff }, - { "msr", 0xa, 0xff }, - { "tear", 0xb, 0xff }, - { "ptb0", 0xc, 0xff }, - { "ptb1", 0xd, 0xff }, - { "ivar0", 0xe, 0xff }, - { "ivar1", 0xf, 0xff }, - { 0 , 0x0, 0xff } -}; - -struct option cpureg_032[]= /* lpr spr */ -{ - { "upsr", 0x0, 0xff }, - { "fp", 0x8, 0xff }, - { "sp", 0x9, 0xff }, - { "sb", 0xa, 0xff }, - { "psr", 0xd, 0xff }, - { "intbase", 0xe, 0xff }, - { "mod", 0xf, 0xff }, - { 0 , 0x0, 0xff } -}; -struct option mmureg_032[]= /* lmr smr */ -{ - { "bpr0", 0x0, 0xff }, - { "bpr1", 0x1, 0xff }, - { "pf0", 0x4, 0xff }, - { "pf1", 0x5, 0xff }, - { "sc", 0x8, 0xff }, - { "msr", 0xa, 0xff }, - { "bcnt", 0xb, 0xff }, - { "ptb0", 0xc, 0xff }, - { "ptb1", 0xd, 0xff }, - { "eia", 0xf, 0xff }, - { 0 , 0x0, 0xff } -}; - -#if defined(NS32532) -struct option *cpureg = cpureg_532; -struct option *mmureg = mmureg_532; -#else -struct option *cpureg = cpureg_032; -struct option *mmureg = mmureg_032; -#endif - - -const pseudo_typeS md_pseudo_table[]={ /* so far empty */ - { 0, 0, 0 } -}; - -#define IND(x,y) (((x)<<2)+(y)) - -/* those are index's to relax groups in md_relax_table - ie it must be multiplied by 4 to point at a group start. Viz IND(x,y) - Se function relax_segment in write.c for more info */ - -#define BRANCH 1 -#define PCREL 2 - -/* those are index's to entries in a relax group */ - -#define BYTE 0 -#define WORD 1 -#define DOUBLE 2 -#define UNDEF 3 -/* Those limits are calculated from the displacement start in memory. - The ns32k uses the begining of the instruction as displacement base. - This type of displacements could be handled here by moving the limit window - up or down. I choose to use an internal displacement base-adjust as there - are other routines that must consider this. Also, as we have two various - offset-adjusts in the ns32k (acb versus br/brs/jsr/bcond), two set of limits - would have had to be used. - Now we dont have to think about that. */ - - -const relax_typeS md_relax_table[]={ - { 1, 1, 0, 0 }, - { 1, 1, 0, 0 }, - { 1, 1, 0, 0 }, - { 1, 1, 0, 0 }, - - { (63), (-64), 1, IND(BRANCH,WORD) }, - { (8192), (-8192), 2, IND(BRANCH,DOUBLE) }, - { 0, 0, 4, 0 }, - { 1, 1, 0, 0 } -}; - -/* Array used to test if mode contains displacements. - Value is true if mode contains displacement. */ - -char disp_test[]={ 0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1, - 1,1,1,0,0,1,1,0, - 1,1,1,1,1,1,1,1 }; - -/* Array used to calculate max size of displacements */ - -char disp_size[]={ 4,1,2,0,4 }; - -/* Parses a general operand into an addressingmode struct - - in: pointer at operand in ascii form - pointer at addr_mode struct for result - the level of recursion. (always 0 or 1) - - out: data in addr_mode struct - */ -int addr_mode(operand,addr_modeP,recursive_level) - char *operand; - register addr_modeS *addr_modeP; -int recursive_level; -{ - register char *str; - register int i; - register int strl; - register int mode; - int j; - mode = DEFAULT; /* default */ - addr_modeP->scaled_mode=0; /* why not */ - addr_modeP->scaled_reg=0; /* if 0, not scaled index */ - addr_modeP->float_flag=0; - addr_modeP->am_size=0; - addr_modeP->im_disp=0; - addr_modeP->pcrel=0; /* not set in this function */ - addr_modeP->disp_suffix[0]=0; - addr_modeP->disp_suffix[1]=0; - addr_modeP->disp[0]=NULL; - addr_modeP->disp[1]=NULL; - str=operand; - if (str[0]==0) {return (0);} /* we don't want this */ - strl=strlen(str); - switch (str[0]) { - /* the following three case statements controls the mode-chars - this is the place to ed if you want to change them */ -#ifdef ABSOLUTE_PREFIX - case ABSOLUTE_PREFIX: - if (str[strl-1]==']') break; - addr_modeP->mode=21; /* absolute */ - addr_modeP->disp[0]=str+1; - return (-1); -#endif -#ifdef IMMEDIATE_PREFIX - case IMMEDIATE_PREFIX: - if (str[strl-1]==']') break; - addr_modeP->mode=20; /* immediate */ - addr_modeP->disp[0]=str+1; - return (-1); -#endif - case '.': - if (str[strl-1]!=']') { - switch (str[1]) { - case'-':case'+': - if (str[2]!='\000') { - addr_modeP->mode=27; /* pc-relativ */ - addr_modeP->disp[0]=str+2; - return (-1); - } - default: - as_warn("Invalid syntax in PC-relative addressing mode"); - return(0); - } - } - break; - case'e': - if (str[strl-1]!=']') { - if((!strncmp(str,"ext(",4)) && strl>7) { /* external */ - addr_modeP->disp[0]=str+4; - i=0; - j=2; - do { /* disp[0]'s termination point */ - j+=1; - if (str[j]=='(') i++; - if (str[j]==')') i--; - } while (jdisp[1]=str+j+2; - addr_modeP->mode=22; - return (-1); - } - } - break; - default:; - } - strl=strlen(str); - switch(strl) { - case 2: - switch (str[0]) { - case'f':addr_modeP->float_flag=1; - case'r': - if (str[1]>='0' && str[1]<'8') { - addr_modeP->mode=str[1]-'0'; - return (-1); - } - } - case 3: - if (!strncmp(str,"tos",3)) { - addr_modeP->mode=23; /* TopOfStack */ - return (-1); - } - default:; - } - if (strl>4) { - if (str[strl-1]==')') { - if (str[strl-2]==')') { - if (!strncmp(&str[strl-5],"(fp",3)) { - mode=16; /* Memory Relative */ - } - if (!strncmp(&str[strl-5],"(sp",3)) { - mode=17; - } - if (!strncmp(&str[strl-5],"(sb",3)) { - mode=18; - } - if (mode!=DEFAULT) { /* memory relative */ - addr_modeP->mode=mode; - j=strl-5; /* temp for end of disp[0] */ - i=0; - do { - strl-=1; - if (str[strl]==')') i++; - if (str[strl]=='(') i--; - } while (strl>-1 && i!=0); - if (i!=0) { - as_warn("Invalid syntax in Memory Relative addressing mode"); - return(0); - } - addr_modeP->disp[1]=str; - addr_modeP->disp[0]=str+strl+1; - str[j]='\000'; /* null terminate disp[0] */ - str[strl]='\000'; /* null terminate disp[1] */ - return (-1); - } - } - switch (str[strl-3]) { - case'r':case'R': - if (str[strl-2]>='0' && str[strl-2]<'8' && str[strl-4]=='(') { - addr_modeP->mode=str[strl-2]-'0'+8; - addr_modeP->disp[0]=str; - str[strl-4]=0; - return (-1); /* reg rel */ - } - default: - if (!strncmp(&str[strl-4],"(fp",3)) { - mode=24; - } - if (!strncmp(&str[strl-4],"(sp",3)) { - mode=25; - } - if (!strncmp(&str[strl-4],"(sb",3)) { - mode=26; - } - if (!strncmp(&str[strl-4],"(pc",3)) { - mode=27; - } - if (mode!=DEFAULT) { - addr_modeP->mode=mode; - addr_modeP->disp[0]=str; - str[strl-4]='\0'; - return (-1); /* memory space */ - } - } - } - /* no trailing ')' do we have a ']' ? */ - if (str[strl-1]==']') { - switch (str[strl-2]) { - case'b':mode=28;break; - case'w':mode=29;break; - case'd':mode=30;break; - case'q':mode=31;break; - default:; - as_warn("Invalid scaled-indexed mode, use (b,w,d,q)"); - if (str[strl-3]!=':' || str[strl-6]!='[' || - str[strl-5]=='r' || str[strl-4]<'0' || str[strl-4]>'7') { - as_warn("Syntax in scaled-indexed mode, use [Rn:m] where n=[0..7] m={b,w,d,q}"); - } - } /* scaled index */ - { - if (recursive_level>0) { - as_warn("Scaled-indexed addressing mode combined with scaled-index"); - return(0); - } - addr_modeP->am_size+=1; /* scaled index byte */ - j=str[strl-4]-'0'; /* store temporary */ - str[strl-6]='\000'; /* nullterminate for recursive call */ - i=addr_mode(str,addr_modeP,1); - if (!i || addr_modeP->mode==20) { - as_warn("Invalid or illegal addressing mode combined with scaled-index"); - return(0); - } - addr_modeP->scaled_mode=addr_modeP->mode; /* store the inferior mode */ - addr_modeP->mode=mode; - addr_modeP->scaled_reg=j+1; - return (-1); - } - } - } - addr_modeP->mode = DEFAULT; /* default to whatever */ - addr_modeP->disp[0]=str; - return (-1); -} - -/* ptr points at string - addr_modeP points at struct with result - This routine calls addr_mode to determine the general addr.mode of - the operand. When this is ready it parses the displacements for size - specifying suffixes and determines size of immediate mode via ns32k-opcode. - Also builds index bytes if needed. - */ -int get_addr_mode(ptr,addr_modeP) - char *ptr; - addr_modeS *addr_modeP; -{ - int tmp; - addr_mode(ptr,addr_modeP,0); - if (addr_modeP->mode == DEFAULT || addr_modeP->scaled_mode == -1) { - /* resolve ambigious operands, this shouldn't - be necessary if one uses standard NSC operand - syntax. But the sequent compiler doesn't!!! - This finds a proper addressinging mode if it - is implicitly stated. See ns32k-opcode.h */ - (void)evaluate_expr(&exprP,ptr); /* this call takes time Sigh! */ - if (addr_modeP->mode == DEFAULT) { - if (exprP.X_add_symbol || exprP.X_subtract_symbol) { - addr_modeP->mode=desc->default_model; /* we have a label */ - } else { - addr_modeP->mode=desc->default_modec; /* we have a constant */ - } - } else { - if (exprP.X_add_symbol || exprP.X_subtract_symbol) { - addr_modeP->scaled_mode=desc->default_model; - } else { - addr_modeP->scaled_mode=desc->default_modec; - } - } - /* must put this mess down in addr_mode to handle the scaled case better */ - } - /* It appears as the sequent compiler wants an absolute when we have a - label without @. Constants becomes immediates besides the addr case. - Think it does so with local labels too, not optimum, pcrel is better. - When I have time I will make gas check this and select pcrel when possible - Actually that is trivial. - */ - if (tmp=addr_modeP->scaled_reg) { /* build indexbyte */ - tmp--; /* remember regnumber comes incremented for flagpurpose */ - tmp|=addr_modeP->scaled_mode<<3; - addr_modeP->index_byte=(char)tmp; - addr_modeP->am_size+=1; - } - if (disp_test[addr_modeP->mode]) { /* there was a displacement, probe for length specifying suffix*/ - { - register char c; - register char suffix; - register char suffix_sub; - register int i; - register char *toP; - register char *fromP; - - addr_modeP->pcrel=0; - if (disp_test[addr_modeP->mode]) { /* there is a displacement */ - if (addr_modeP->mode==27 || addr_modeP->scaled_mode==27) { /* do we have pcrel. mode */ - addr_modeP->pcrel=1; - } - addr_modeP->im_disp=1; - for(i=0;i<2;i++) { - suffix_sub=suffix=0; - if (toP=addr_modeP->disp[i]) { /* suffix of expression, the largest size rules */ - fromP=toP; - while (c = *fromP++) { - *toP++=c; - if (c==':') { - switch (*fromP) { - case '\0': - as_warn("Premature end of suffix--Defaulting to d"); - suffix=4; - continue; - case 'b':suffix_sub=1;break; - case 'w':suffix_sub=2;break; - case 'd':suffix_sub=4;break; - default: - as_warn("Bad suffix after ':' use {b|w|d} Defaulting to d"); - suffix=4; - } - fromP++; - toP--; /* So we write over the ':' */ - if (suffixdisp_suffix[i]=suffix; - addr_modeP->am_size+=suffix ? suffix : 4; - } - } - } - } - } else { - if (addr_modeP->mode==20) { /* look in ns32k_opcode for size */ - addr_modeP->disp_suffix[0]=addr_modeP->am_size=desc->im_size; - addr_modeP->im_disp=0; - } - } - return addr_modeP->mode; -} - - -/* read an optionlist */ -void optlist(str,optionP,default_map) - char *str; /* the string to extract options from */ - struct option *optionP; /* how to search the string */ - unsigned long *default_map; /* default pattern and output */ -{ - register int i,j,k,strlen1,strlen2; - register char *patternP,*strP; - strlen1=strlen(str); - if (strlen1<1) { - as_fatal("Very short instr to option, ie you can't do it on a NULLstr"); - } - for (i=0;optionP[i].pattern!=0;i++) { - strlen2=strlen(optionP[i].pattern); - for (j=0;j3) as_fatal("Internal error check ns32k-opcode.h"); - pcrel=0; - pcrel_adjust=0; - tmp=0; - switch (operandsP[(loop<<1)+1]) { - case 'f': /* operand of sfsr turns out to be a nasty specialcase */ - opcode_bit_ptr-=5; - case 'F': /* 32 bit float general form */ - case 'L': /* 64 bit float */ - case 'Q': /* quad-word */ - case 'B': /* byte */ - case 'W': /* word */ - case 'D': /* double-word */ - case 'A': /* double-word gen-address-form ie no regs allowed */ - get_addr_mode(argv[i],&addr_modeP); - iif.instr_size+=addr_modeP.am_size; - if (opcode_bit_ptr==desc->opcode_size) b=4; else b=6; - for (j=b;j<(b+2);j++) { - if (addr_modeP.disp[j-b]) { - IIF(j, - 2, - addr_modeP.disp_suffix[j-b], - (unsigned long)addr_modeP.disp[j-b], - 0, - addr_modeP.pcrel, - iif.instr_size-addr_modeP.am_size, /* this aint used (now) */ - addr_modeP.im_disp, - IND(BRANCH,BYTE), - NULL, - addr_modeP.scaled_reg ? addr_modeP.scaled_mode:addr_modeP.mode, - 0); - } - } - opcode_bit_ptr-=5; - iif.iifP[1].object|=((long)addr_modeP.mode)<im_size); - argv[i]=freeptr; - freeptr=(char*)tmp; - pcrel-=1; /* make pcrel 0 inspite of what case 'p': wants */ - /* fall thru */ - case 'p': /* displacement - pc relative addressing */ - pcrel+=1; - /* fall thru */ - case 'd': /* displacement */ - iif.instr_size+=suffixP[i] ? suffixP[i] : 4; - IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0, - pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,0); - break; - case 'H': /* sequent-hack: the linker wants a bit set when bsr */ - pcrel=1; - iif.instr_size+=suffixP[i] ? suffixP[i] : 4; - IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0, - pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,1);break; - case 'q': /* quick */ - opcode_bit_ptr-=4; - IIF(11,2,42,(unsigned long)argv[i],0,0,0,0,0, - bit_fix_new(4,opcode_bit_ptr,-8,7,0,1,0),-1,0); - break; - case 'r': /* register number (3 bits) */ - list_search(argv[i],opt6,&tmp); - opcode_bit_ptr-=3; - iif.iifP[1].object|=tmp<operands) { - if (*lineptr++!='\0') { - sqr='['; - sep=','; - while (*lineptr!='\0') { - if (desc->operands[argc<<1]) { - suffix[argc]=0; - arg_type=desc->operands[(argc<<1)+1]; - switch (arg_type) { - case 'd': case 'b': case 'p': case 'H': /* the operand is supposed to be a displacement */ - /* Hackwarning: do not forget to update the 4 cases above when editing ns32k-opcode.h */ - suffix_separator=':'; - break; - default: - suffix_separator='\255'; /* if this char occurs we loose */ - } - suffix[argc]=0; /* 0 when no ':' is encountered */ - argv[argc]=freeptr; - *freeptr='\0'; - while ((c = *lineptr)!='\0' && c!=sep) { - if (c==sqr) { - if (sqr=='[') { - sqr=']';sep='\0'; - } else { - sqr='[';sep=','; - } - } - if (c==suffix_separator) { /* ':' - label/suffix separator */ - switch (lineptr[1]) { - case 'b':suffix[argc]=1;break; - case 'w':suffix[argc]=2;break; - case 'd':suffix[argc]=4;break; - default: as_warn("Bad suffix, defaulting to d"); - suffix[argc]=4; - if (lineptr[1]=='\0' || lineptr[1]==sep) { - lineptr+=1; - continue; - } - } - lineptr+=2; - continue; - } - *freeptr++=c; - lineptr++; - } - *freeptr++='\0'; - argc+=1; - if (*lineptr=='\0') continue; - lineptr+=1; - } else { - as_fatal("Too many operands passed to instruction"); - } - } - } - } - if (argc!=strlen(desc->operands)/2) { - if (strlen(desc->default_args)) { /* we can apply default, dont goof */ - if (parse(desc->default_args,1)!=1) { /* check error in default */ - as_fatal("Wrong numbers of operands in default, check ns32k-opcodes.h"); - } - } else { - as_fatal("Wrong number of operands"); - } - - } - for (i=0;iopcode_size/8; - IIF(1,1,iif.instr_size,desc->opcode_seed,0,0,0,0,0,0,-1,0); - - /* this call encodes operands to iif format */ - if (argc) { - encode_operand(argc, - argv, - &desc->operands[0], - &suffix[0], - desc->im_size, - desc->opcode_size); - } - return recursive_level; -} - - - /* Convert iif to fragments. - From this point we start to dribble with functions in other files than - this one.(Except hash.c) So, if it's possible to make an iif for an other - CPU, you don't need to know what frags, relax, obstacks, etc is in order - to port this assembler. You only need to know if it's possible to reduce - your cpu-instruction to iif-format (takes some work) and adopt the other - md_? parts according to given instructions - Note that iif was invented for the clean ns32k`s architecure. - */ -convert_iif() -{ - register int i,j; - fragS *inst_frag; - char *inst_offset,*inst_opcode; - char *memP; - segT segment; - int l,k; - register int rem_size; /* count the remaining bytes of instruction */ - register char type; - register char size = 0; - int size_so_far=0; /* used to calculate pcrel_adjust */ - - rem_size=iif.instr_size; - memP=frag_more(iif.instr_size); /* make sure we have enough bytes for instruction */ - inst_opcode=memP; - inst_offset=(char*)(memP-frag_now->fr_literal); - inst_frag=frag_now; - for (i=0;ifx_bit_base) { /* expand fx_bit_base to point at opcode */ - iif.iifP[i].bit_fixP->fx_bit_base=(long)inst_opcode; - } - case 8: /* bignum or doublefloat */ - bzero (memP,8); - case 1:case 2:case 3:case 4:/* the final size in objectmemory is known */ - j=(unsigned long)iif.iifP[i].bit_fixP; - switch (type) { - case 1: /* the object is pure binary */ - if (j || iif.iifP[i].pcrel) { - fix_new_ns32k(frag_now, - (long)(memP-frag_now->fr_literal), - size, - 0, - 0, - iif.iifP[i].object, - iif.iifP[i].pcrel, - (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ - iif.iifP[i].im_disp, - j, - iif.iifP[i].bsr); /* sequent hack */ - } else { /* good, just put them bytes out */ - switch (iif.iifP[i].im_disp) { - case 0: - md_number_to_chars(memP,iif.iifP[i].object,size);break; - case 1: - md_number_to_disp(memP,iif.iifP[i].object,size);break; - default: as_fatal("iif convert internal pcrel/binary"); - } - } - memP+=size; - rem_size-=size; - break; - case 2: /* the object is a pointer at an expression, so unpack - it, note that bignums may result from the expression - */ - if ((segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object))==SEG_BIG || size==8) { - if ((k=exprP.X_add_number)>0) { /* we have a bignum ie a quad */ - /* this can only happens in a long suffixed instruction */ - bzero(memP,size); /* size normally is 8 */ - if (k*2>size) as_warn("Bignum too big for long"); - if (k==3) memP+=2; - for (l=0;k>0;k--,l+=2) { - md_number_to_chars(memP+l,generic_bignum[l>>1],sizeof(LITTLENUM_TYPE)); - } - } else { /* flonum */ - LITTLENUM_TYPE words[4]; - - switch(size) { - case 4: - gen_to_words(words,2,8); - md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+sizeof(LITTLENUM_TYPE),(long)words[1],sizeof(LITTLENUM_TYPE)); - break; - case 8: - gen_to_words(words,4,11); - md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+sizeof(LITTLENUM_TYPE) ,(long)words[1],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+2*sizeof(LITTLENUM_TYPE),(long)words[2],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+3*sizeof(LITTLENUM_TYPE),(long)words[3],sizeof(LITTLENUM_TYPE)); - break; - } - } - memP+=size; - rem_size-=size; - break; - } - if (j || - exprP.X_add_symbol || - exprP.X_subtract_symbol || - iif.iifP[i].pcrel) { /* fixit */ - /* the expression was undefined due to an undefined label */ - /* create a fix so we can fix the object later */ - exprP.X_add_number+=iif.iifP[i].object_adjust; - fix_new_ns32k(frag_now, - (long)(memP-frag_now->fr_literal), - size, - exprP.X_add_symbol, - exprP.X_subtract_symbol, - exprP.X_add_number, - iif.iifP[i].pcrel, - (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ - iif.iifP[i].im_disp, - j, - iif.iifP[i].bsr); /* sequent hack */ - - } else { /* good, just put them bytes out */ - switch (iif.iifP[i].im_disp) { - case 0: - md_number_to_imm(memP,exprP.X_add_number,size);break; - case 1: - md_number_to_disp(memP,exprP.X_add_number,size);break; - default: as_fatal("iif convert internal pcrel/pointer"); - } - } - memP+=size; - rem_size-=size; - break; - default: as_fatal("Internal logic error in iif.iifP[n].type"); - } - break; - case 0: /* To bad, the object may be undefined as far as its final - nsize in object memory is concerned. The size of the object - in objectmemory is not explicitly given. - If the object is defined its length can be determined and - a fix can replace the frag. - */ - { - int temp; - segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object); - if ((exprP.X_add_symbol || exprP.X_subtract_symbol) && - !iif.iifP[i].pcrel) { /* OVE: hack, clamp to 4 bytes */ - size=4; /* we dont wan't to frag this, use 4 so it reaches */ - fix_new_ns32k(frag_now, - (long)(memP-frag_now->fr_literal), - size, - exprP.X_add_symbol, - exprP.X_subtract_symbol, - exprP.X_add_number, - 0, /* never iif.iifP[i].pcrel, */ - (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ - 1, /* always iif.iifP[i].im_disp, */ - 0,0); - memP+=size; - rem_size-=4; - break; /* exit this absolute hack */ - } - - if (exprP.X_add_symbol || exprP.X_subtract_symbol) { /* frag it */ - if (exprP.X_subtract_symbol) { /* We cant relax this case */ - as_fatal("Can't relax difference"); - } - else { - /* at this stage we must undo some of the effect caused - by frag_more, ie we must make sure that frag_var causes - frag_new to creat a valid fix-size in the frag it`s closing - */ - temp = -(rem_size-4); - obstack_blank_fast(&frags,temp); - /* we rewind none, some or all of the requested size we - requested by the first frag_more for this iif chunk. - Note: that we allocate 4 bytes to an object we NOT YET - know the size of, thus rem_size-4. - */ - (void)frag_variant(rs_machine_dependent, - 4, - 0, - IND(BRANCH,UNDEF), /* expecting the worst */ - exprP.X_add_symbol, - exprP.X_add_number, - (char*)inst_opcode, - (char)size_so_far, /*iif.iifP[i].pcrel_adjust);*/ - iif.iifP[i].bsr); /* sequent linker hack */ - rem_size-=4; - if (rem_size>0) { - memP=frag_more(rem_size); - } - } - } - else {/* Double work, this is done in md_number_to_disp */ - exprP.X_add_number; - if (-64<=exprP.X_add_number && exprP.X_add_number<=63) { - size=1; - } else { - if (-8192<=exprP.X_add_number && exprP.X_add_number<=8191) { - size=2; - } else { - if (-0x1f000000<=exprP.X_add_number && - exprP.X_add_number<=0x1fffffff) - /* if (-0x40000000<=exprP.X_add_number && - exprP.X_add_number<=0x3fffffff) */ - { - size=4; - } else { - as_warn("Displacement to large for :d"); - size=4; - } - } - } - /* rewind the bytes not used */ - temp = -(4-size); - md_number_to_disp(memP,exprP.X_add_number,size); - obstack_blank_fast(&frags,temp); - memP+=size; - rem_size-=4; /* we allocated this amount */ - } - } - break; - default: - as_fatal("Internal logic error in iif.iifP[].type"); - } - size_so_far+=size; - size=0; - } - } -} - -void md_assemble(line) -char *line; -{ - freeptr=freeptr_static; - parse(line,0); /* explode line to more fix form in iif */ - convert_iif(); /* convert iif to frags, fix's etc */ -#ifdef SHOW_NUM - printf(" \t\t\t%s\n",line); -#endif -} - - -void md_begin() -{ - /* build a hashtable of the instructions */ - register struct ns32k_opcode *ptr; - register char *stat; - inst_hash_handle=hash_new(); - for (ptr=ns32k_opcodes;ptrname,(char*)ptr))) { - as_fatal("Can't hash %s: %s",ptr->name,stat); /*fatal*/ - exit(0); - } - } - freeptr_static=(char*)malloc(PRIVATE_SIZE); /* some private space please! */ -} - - -void -md_end() -{ - free(freeptr_static); -} - -/* Must be equal to MAX_PRECISON in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -/* Turn the string pointed to by litP into a floating point constant of type - type, and emit the appropriate bytes. The number of LITTLENUMS emitted - is stored in *sizeP . An error message is returned, or NULL on OK. - */ -char * -md_atof(type,litP,sizeP) -char type; -char *litP; -int *sizeP; -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - char *atof_ieee(); - - switch(type) { - case 'f': - prec = 2; - break; - - case 'd': - prec = 4; - break; - default: - *sizeP=0; - return "Bad call to MD_ATOF()"; - } - t=atof_ieee(input_line_pointer,type,words); - if(t) - input_line_pointer=t; - - *sizeP=prec * sizeof(LITTLENUM_TYPE); - for(wordP=words+prec;prec--;) { - md_number_to_chars(litP,(long)(*--wordP),sizeof(LITTLENUM_TYPE)); - litP+=sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ -} - -/* Convert number to chars in correct order */ - -void -md_number_to_chars (buf, value, nbytes) - char *buf; - long int value; - int nbytes; -{ - while (nbytes--) - { -#ifdef SHOW_NUM - printf("%x ",value & 0xff); -#endif - *buf++ = value; /* Lint wants & MASK_CHAR. */ - value >>= BITS_PER_CHAR; - } -} -/* Convert number to chars in correct order */ - - - -/* This is a variant of md_numbers_to_chars. The reason for its' existence - is the fact that ns32k uses Huffman coded displacements. This implies - that the bit order is reversed in displacements and that they are prefixed - with a size-tag. - - binary: msb -> lsb 0xxxxxxx byte - 10xxxxxx xxxxxxxx word - 11xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx double word - - This must be taken care of and we do it here! - */ -void md_number_to_disp(buf,val,n) - char *buf; - long val; - char n; -{ - switch(n) { - case 1: - if (val < -64 || val > 63) - as_warn("Byte displacement out of range. line number not valid"); - val&=0x7f; -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - case 2: - if (val < -8192 || val > 8191) - as_warn("Word displacement out of range. line number not valid"); - val&=0x3fff; - val|=0x8000; -#ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); -#endif - *buf++=(val>>8); -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - case 4: - if (val < -0x1f000000 || val >= 0x20000000) - /* if (val < -0x20000000 || val >= 0x20000000) */ - as_warn("Double word displacement out of range"); - val|=0xc0000000; -#ifdef SHOW_NUM - printf("%x ",val>>24 & 0xff); -#endif - *buf++=(val>>24); -#ifdef SHOW_NUM - printf("%x ",val>>16 & 0xff); -#endif - *buf++=(val>>16); -#ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); -#endif - *buf++=(val>>8); -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - default: - as_fatal("Internal logic error"); - } -} -void md_number_to_imm(buf,val,n) - char *buf; - long val; - char n; -{ - switch(n) { - case 1: -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - case 2: -#ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); -#endif - *buf++=(val>>8); -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - case 4: -#ifdef SHOW_NUM - printf("%x ",val>>24 & 0xff); -#endif - *buf++=(val>>24); -#ifdef SHOW_NUM - printf("%x ",val>>16 & 0xff); -#endif - *buf++=(val>>16); -#ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); -#endif - *buf++=(val>>8); -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - default: - as_fatal("Internal logic error"); - } -} -/* the bit-field entries in the relocation_info struct plays hell - with the byte-order problems of cross-assembly. So as a hack, - I added this mach. dependent ri twiddler. Ugly, but it gets - you there. -KWK */ -/* OVE: on a ns32k the twiddling continues at an even deeper level - here we have to distinguish between displacements and immediates. - - The sequent has a bit for this. It also has a bit for relocobjects that - points at the target for a bsr (BranchSubRoutine) !?!?!?! - - Using [] is importable but fast!! still, its rather funny :-) - This md_ri.... is tailored for sequent. - */ - -void md_ri_to_chars(ri_p, ri) - struct relocation_info *ri_p, ri; -{ - if (ri.r_bsr) {ri.r_pcrel=0;} /* sequent seems to want this */ - md_number_to_chars((char*)ri_p, ri.r_address, sizeof(ri.r_address)); - md_number_to_chars((char*)ri_p+4, - (long)(ri.r_symbolnum ) | - (long)(ri.r_pcrel << 24 ) | - (long)(ri.r_length << 25 ) | - (long)(ri.r_extern << 27 ) | - (long)(ri.r_bsr << 28 ) | - (long)(ri.r_disp << 29 ), - 4); - /* the first and second md_number_to_chars never overlaps (32bit cpu case) */ -} - -/* fast bitfiddling support */ -/* mask used to zero bitfield before oring in the true field */ - -static unsigned long l_mask[]={ 0xffffffff, 0xfffffffe, 0xfffffffc, 0xfffffff8, - 0xfffffff0, 0xffffffe0, 0xffffffc0, 0xffffff80, - 0xffffff00, 0xfffffe00, 0xfffffc00, 0xfffff800, - 0xfffff000, 0xffffe000, 0xffffc000, 0xffff8000, - 0xffff0000, 0xfffe0000, 0xfffc0000, 0xfff80000, - 0xfff00000, 0xffe00000, 0xffc00000, 0xff800000, - 0xff000000, 0xfe000000, 0xfc000000, 0xf8000000, - 0xf0000000, 0xe0000000, 0xc0000000, 0x80000000, - }; -static unsigned long r_mask[]={ 0x00000000, 0x00000001, 0x00000003, 0x00000007, - 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, - 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, - 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, - 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, - 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, - 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, - 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, - }; -#define MASK_BITS 31 -/* Insert bitfield described by field_ptr and val at buf - This routine is written for modification of the first 4 bytes pointed - to by buf, to yield speed. - The ifdef stuff is for selection between a ns32k-dependent routine - and a general version. (My advice: use the general version!) - */ - -void md_number_to_field(buf,val,field_ptr) - register char *buf; - register long val; - register bit_fixS *field_ptr; -{ - register unsigned long object; - register unsigned long mask; -/* define ENDIAN on a ns32k machine */ -#ifdef ENDIAN - register unsigned long *mem_ptr; -#else - register char *mem_ptr; -#endif - if (field_ptr->fx_bit_min<=val && val<=field_ptr->fx_bit_max) { -#ifdef ENDIAN - if (field_ptr->fx_bit_base) { /* override buf */ - mem_ptr=(unsigned long*)field_ptr->fx_bit_base; - } else { - mem_ptr=(unsigned long*)buf; - } -#else - if (field_ptr->fx_bit_base) { /* override buf */ - mem_ptr=(char*)field_ptr->fx_bit_base; - } else { - mem_ptr=buf; - } -#endif - mem_ptr+=field_ptr->fx_bit_base_adj; -#ifdef ENDIAN /* we have a nice ns32k machine with lowbyte at low-physical mem */ - object = *mem_ptr; /* get some bytes */ -#else /* OVE Goof! the machine is a m68k or dito */ - /* That takes more byte fiddling */ - object=0; - object|=mem_ptr[3] & 0xff; - object<<=8; - object|=mem_ptr[2] & 0xff; - object<<=8; - object|=mem_ptr[1] & 0xff; - object<<=8; - object|=mem_ptr[0] & 0xff; -#endif - mask=0; - mask|=(r_mask[field_ptr->fx_bit_offset]); - mask|=(l_mask[field_ptr->fx_bit_offset+field_ptr->fx_bit_size]); - object&=mask; - val+=field_ptr->fx_bit_add; - object|=((val<fx_bit_offset) & (mask ^ 0xffffffff)); -#ifdef ENDIAN - *mem_ptr=object; -#else - mem_ptr[0]=(char)object; - object>>=8; - mem_ptr[1]=(char)object; - object>>=8; - mem_ptr[2]=(char)object; - object>>=8; - mem_ptr[3]=(char)object; -#endif - } else { - as_warn("Bit field out of range"); - } -} - -/* Convert a relaxed displacement to dito in final output */ - -void - md_convert_frag(fragP) -register fragS *fragP; -{ - long disp; - long ext; - - /* Address in gas core of the place to store the displacement. */ - register char *buffer_address = fragP -> fr_fix + fragP -> fr_literal; - /* Address in object code of the displacement. */ - register int object_address = fragP -> fr_fix + fragP -> fr_address; - - know(fragP->fr_symbol); - - /* The displacement of the address, from current location. */ - disp = (fragP->fr_symbol->sy_value + fragP->fr_offset) - object_address; - disp+= fragP->fr_pcrel_adjust; - - switch(fragP->fr_subtype) { - case IND(BRANCH,BYTE): - ext=1; - break; - case IND(BRANCH,WORD): - ext=2; - break; - case IND(BRANCH,DOUBLE): - ext=4; - break; - } - if(ext) { - md_number_to_disp(buffer_address,(long)disp,(int)ext); - fragP->fr_fix+=ext; - } -} - - - -/* This function returns the estimated size a variable object will occupy, - one can say that we tries to guess the size of the objects before we - actually know it */ - -md_estimate_size_before_relax(fragP,segtype) - register fragS *fragP; -{ - int old_fix; - old_fix=fragP->fr_fix; - switch(fragP->fr_subtype) { - case IND(BRANCH,UNDEF): - if((fragP->fr_symbol->sy_type&N_TYPE)==segtype) { - /* the symbol has been assigned a value */ - fragP->fr_subtype=IND(BRANCH,BYTE); - } else { - /* we don't relax symbols defined in an other segment - the thing to do is to assume the object will occupy 4 bytes */ - fix_new_ns32k(fragP, - (int)(fragP->fr_fix), - 4, - fragP->fr_symbol, - (symbolS *)0, - fragP->fr_offset, - 1, - fragP->fr_pcrel_adjust, - 1, - 0, - fragP->fr_bsr); /*sequent hack */ - fragP->fr_fix+=4; - /* fragP->fr_opcode[1]=0xff; */ - frag_wane(fragP); - break; - } - case IND(BRANCH,BYTE): - fragP->fr_var+=1; - break; - default: - break; - } - return fragP->fr_var + fragP->fr_fix - old_fix; -} - -int md_short_jump_size = 3; -int md_long_jump_size = 5; - -void -md_create_short_jump(ptr,from_addr,to_addr,frag,to_symbol) -char *ptr; -long from_addr, - to_addr; -fragS *frag; -symbolS *to_symbol; -{ - long offset; - - offset = to_addr - from_addr; - md_number_to_chars(ptr, (long)0xEA ,1); - md_number_to_disp(ptr+1,(long)offset,2); -} - -void -md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol) -char *ptr; -long from_addr, - to_addr; -fragS *frag; -symbolS *to_symbol; -{ - long offset; - - offset= to_addr - from_addr; - md_number_to_chars(ptr, (long)0xEA, 2); - md_number_to_disp(ptr+2,(long)offset,4); -} - -/* JF this is a new function to parse machine-dep options */ -int -md_parse_option(argP,cntP,vecP) -char **argP; -int *cntP; -char ***vecP; -{ - switch(**argP) { - case 'm': - (*argP)++; - - if(!strcmp(*argP,"32032")) { - cpureg = cpureg_032; - mmureg = mmureg_032; - } else if(!strcmp(*argP, "32532")) { - cpureg = cpureg_532; - mmureg = mmureg_532; - } else - as_warn("Unknown -m option ignored"); - - while(**argP) - (*argP)++; - break; - - default: - return 0; - } - return 1; -} - -/* - * bit_fix_new() - * - * Create a bit_fixS in obstack 'notes'. - * This struct is used to profile the normal fix. If the bit_fixP is a - * valid pointer (not NULL) the bit_fix data will be used to format the fix. - */ -bit_fixS * -bit_fix_new (size,offset,min,max,add,base_type,base_adj) - char size; /* Length of bitfield */ - char offset; /* Bit offset to bitfield */ - long base_type; /* 0 or 1, if 1 it's exploded to opcode ptr */ - long base_adj; - long min; /* Signextended min for bitfield */ - long max; /* Signextended max for bitfield */ - long add; /* Add mask, used for huffman prefix */ -{ - register bit_fixS * bit_fixP; - - bit_fixP = (bit_fixS *)obstack_alloc(¬es,sizeof(bit_fixS)); - - bit_fixP -> fx_bit_size = size; - bit_fixP -> fx_bit_offset = offset; - bit_fixP -> fx_bit_base = base_type; - bit_fixP -> fx_bit_base_adj = base_adj; - bit_fixP -> fx_bit_max = max; - bit_fixP -> fx_bit_min = min; - bit_fixP -> fx_bit_add = add; - - return bit_fixP; -} - -void -fix_new_ns32k (frag, where, size, add_symbol, sub_symbol, offset, pcrel, - pcrel_adjust, im_disp, bit_fixP, bsr) - fragS * frag; /* Which frag? */ - int where; /* Where in that frag? */ - short int size; /* 1, 2 or 4 usually. */ - symbolS * add_symbol; /* X_add_symbol. */ - symbolS * sub_symbol; /* X_subtract_symbol. */ - long int offset; /* X_add_number. */ - int pcrel; /* TRUE if PC-relative relocation. */ - char pcrel_adjust; /* not zero if adjustment of pcrel offset is needed */ - char im_disp; /* true if the value to write is a displacement */ - bit_fixS *bit_fixP; /* pointer at struct of bit_fix's, ignored if NULL */ - char bsr; /* sequent-linker-hack: 1 when relocobject is a bsr */ - -{ - register fixS * fixP; - - fixP = (fixS *)obstack_alloc(¬es,sizeof(fixS)); - fixP -> fx_frag = frag; - fixP -> fx_where = where; - fixP -> fx_size = size; - fixP -> fx_addsy = add_symbol; - fixP -> fx_subsy = sub_symbol; - fixP -> fx_offset = offset; - fixP -> fx_pcrel = pcrel; - fixP -> fx_pcrel_adjust = pcrel_adjust; - fixP -> fx_im_disp = im_disp; - fixP -> fx_bit_fixP = bit_fixP; - fixP -> fx_bsr = bsr; - fixP -> fx_next = * seg_fix_rootP; - - * seg_fix_rootP = fixP; -} diff --git a/gnu/usr.bin/gas/config/sparc-opcode.h b/gnu/usr.bin/gas/config/sparc-opcode.h deleted file mode 100644 index bac52e71e064..000000000000 --- a/gnu/usr.bin/gas/config/sparc-opcode.h +++ /dev/null @@ -1,639 +0,0 @@ -/* Table of opcodes for the sparc. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler, and GDB, the GNU disassembler. - -GAS/GDB 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. - -GAS/GDB 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 GAS or GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: sparc-opcode.h,v 1.2 1993/08/02 17:27:19 mycroft Exp $ -*/ - -#if !defined(__STDC__) && !defined(const) -#define const -#endif - -/* - * Structure of an opcode table entry. - */ -struct sparc_opcode -{ - const char *name; - unsigned long int match; /* Bits that must be set. */ - unsigned long int lose; /* Bits that must not be set. */ - const char *args; - /* Nonzero if this is a delayed branch instruction. */ - char delayed; -}; - -/* - All sparc opcodes are 32 bits, except for the `set' instruction (really - a macro), which is 64 bits. It is handled as a special case. - - The match component is a mask saying which bits must match a - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing one character - for each operand of the instruction. - -Kinds of operands: - # Number used by optimizer. It is ignored. - 1 rs1 register. - 2 rs2 register. - d rd register. - e frs1 floating point register. - f frs2 floating point register. - g frsd floating point register. - b crs1 coprocessor register - c crs2 coprocessor register - D crsd coprocessor register - h 22 high bits. - i 13 bit Immediate. - l 22 bit PC relative immediate. - L 30 bit PC relative immediate. - a Annul. The annul bit is set. - A Alternate address space. Stored as 8 bits. - C Coprocessor state register. - F floating point state register. - p Processor state register. - q Floating point queue. - r Single register that is both rs1 and rsd. - Q Coprocessor queue. - S Special case. - t Trap base register. - w Window invalid mask register. - y Y register. - -*/ - -/* The order of the opcodes in this table is significant: - - * The assembler requires that all instances of the same mnemonic must be - consecutive. If they aren't, the assembler will bomb at runtime. - - * The disassembler should not care about the order of the opcodes. */ - -static struct sparc_opcode sparc_opcodes[] = -{ - -{ "ldd", 0xc1980000, 0x0060201f, "[1],D", 0 }, /* ldd [rs1+%g0],d */ -{ "ldd", 0xc1982000, 0x00601fff, "[1],D", 0 }, /* ldd [rs1+0],d */ -{ "ldd", 0xc1982000, 0x00600000, "[1+i],D", 0 }, -{ "ldd", 0xc1982000, 0x00600000, "[i+1],D", 0 }, -{ "ldd", 0xc1980000, 0x00602000, "[1+2],D", 0 }, -{ "ldd", 0xc1180000, 0x00e0201f, "[1],g", 0 }, /* ldd [rs1+%g0],d */ -{ "ldd", 0xc1182000, 0x00e01fff, "[1],g", 0 }, /* ldd [rs1+0],d */ -{ "ldd", 0xc1182000, 0x00e00000, "[1+i],g", 0 }, -{ "ldd", 0xc1182000, 0x00e00000, "[i+1],g", 0 }, -{ "ldd", 0xc1180000, 0x00e02000, "[1+2],g", 0 }, -{ "ldd", 0xc0180000, 0x01e0201f, "[1],d", 0 }, /* ldd [rs1+%g0],d */ -{ "ldd", 0xc0182000, 0x01e01fff, "[1],d", 0 }, /* ldd [rs1+0],d */ -{ "ldd", 0xc0182000, 0x01e00000, "[1+i],d", 0 }, -{ "ldd", 0xc0182000, 0x01e00000, "[i+1],d", 0 }, -{ "ldd", 0xc0180000, 0x01e02000, "[1+2],d", 0 }, -{ "ld", 0xc1880000, 0x0070201f, "[1],C", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1882000, 0x00701fff, "[1],C", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1882000, 0x00700000, "[1+i],C", 0 }, -{ "ld", 0xc1882000, 0x00700000, "[i+1],C", 0 }, -{ "ld", 0xc1880000, 0x00702000, "[1+2],C", 0 }, -{ "ld", 0xc1800000, 0x0078201f, "[1],D", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1802000, 0x00781fff, "[1],D", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1802000, 0x00780000, "[1+i],D", 0 }, -{ "ld", 0xc1802000, 0x00780000, "[i+1],D", 0 }, -{ "ld", 0xc1800000, 0x00782000, "[1+2],D", 0 }, -{ "ld", 0xc1080000, 0x00f0201f, "[1],F", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1082000, 0x00f01fff, "[1],F", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1082000, 0x00f00000, "[1+i],F", 0 }, -{ "ld", 0xc1082000, 0x00f00000, "[i+1],F", 0 }, -{ "ld", 0xc1080000, 0x00f02000, "[1+2],F", 0 }, -{ "ld", 0xc1000000, 0x00f8201f, "[1],g", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1002000, 0x00f81fff, "[1],g", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1002000, 0x00f80000, "[1+i],g", 0 }, -{ "ld", 0xc1002000, 0x00f80000, "[i+1],g", 0 }, -{ "ld", 0xc1000000, 0x00f82000, "[1+2],g", 0 }, -{ "ld", 0xc0000000, 0x01f8201f, "[1],d", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc0002000, 0x01f81fff, "[1],d", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc0002000, 0x01f80000, "[1+i],d", 0 }, -{ "ld", 0xc0002000, 0x01f80000, "[i+1],d", 0 }, -{ "ld", 0xc0000000, 0x01f82000, "[1+2],d", 0 }, -{ "ldstuba", 0xc0d80000, 0x0100201f, "[1]A,d", 0 }, /* ldstuba [rs1+%g0],d */ -{ "ldstuba", 0xc0d80000, 0x01002000, "[1+2]A,d", 0 }, -{ "ldsha", 0xc0d00000, 0x0128201f, "[1]A,d", 0 }, /* ldsha [rs1+%g0],d */ -{ "ldsha", 0xc0d00000, 0x01282000, "[1+2]A,d", 0 }, -{ "ldsba", 0xc0c80000, 0x0130201f, "[1]A,d", 0 }, /* ldsba [rs1+%g0],d */ -{ "ldsba", 0xc0c80000, 0x01302000, "[1+2]A,d", 0 }, -{ "ldda", 0xc0980000, 0x0160201f, "[1]A,d", 0 }, /* ldda [rs1+%g0],d */ -{ "ldda", 0xc0980000, 0x01602000, "[1+2]A,d", 0 }, -{ "lduha", 0xc0900000, 0x0168201f, "[1]A,d", 0 }, /* lduha [rs1+%g0],d */ -{ "lduha", 0xc0900000, 0x01682000, "[1+2]A,d", 0 }, -{ "ldstub", 0xc0680000, 0x0190201f, "[1],d", 0 }, /* ldstub [rs1+%g0],d */ -{ "ldstub", 0xc0682000, 0x01900000, "[1+i],d", 0 }, -{ "ldstub", 0xc0682000, 0x01900000, "[i+1],d", 0 }, -{ "ldstub", 0xc0680000, 0x01902000, "[1+2],d", 0 }, -{ "lda", 0xc0800000, 0x0178201f, "[1]A,d", 0 }, /* lda [rs1+%g0],d */ -{ "lda", 0xc0800000, 0x01782000, "[1+2]A,d", 0 }, -{ "ldsh", 0xc0500000, 0x0000000d, "[1],d", 0 }, /* ldsh [rs1+%g0],d */ -{ "ldsh", 0xc0502000, 0x01a81fff, "[1],d", 0 }, /* ldsh [rs1+0],d */ -{ "ldsh", 0xc0502000, 0x01a80000, "[1+i],d", 0 }, -{ "ldsh", 0xc0502000, 0x01a80000, "[i+1],d", 0 }, -{ "ldsh", 0xc0500000, 0x01a82000, "[1+2],d", 0 }, -{ "ldsb", 0xc0480000, 0x01b0201f, "[1],d", 0 }, /* ldsb [rs1+%g0],d */ -{ "ldsb", 0xc0482000, 0x01b01fff, "[1],d", 0 }, /* ldsb [rs1+0],d */ -{ "ldsb", 0xc0482000, 0x01b00000, "[1+i],d", 0 }, -{ "ldsb", 0xc0482000, 0x01b00000, "[i+1],d", 0 }, -{ "ldsb", 0xc0480000, 0x01b02000, "[1+2],d", 0 }, -{ "ldub", 0xc0080000, 0x01f0201f, "[1],d", 0 }, /* ldub [rs1+%g0],d */ -{ "ldub", 0xc0082000, 0x01f01fff, "[1],d", 0 }, /* ldub [rs1+0],d */ -{ "ldub", 0xc0082000, 0x01f00000, "[1+i],d", 0 }, -{ "ldub", 0xc0082000, 0x01f00000, "[i+1],d", 0 }, -{ "ldub", 0xc0080000, 0x01f02000, "[1+2],d", 0 }, -{ "lduba", 0xc0880000, 0x0170201f, "[1]A,d", 0 }, /* lduba [rs1+%g0],d */ -{ "lduba", 0xc0880000, 0x01702000, "[1+2]A,d", 0 }, -{ "lduh", 0xc0102000, 0x01e80000, "[1+i],d", 0 }, -{ "lduh", 0xc0102000, 0x01e80000, "[i+1],d", 0 }, -{ "lduh", 0xc0100000, 0x01e8201f, "[1],d", 0 }, /* lduh [rs1+%g0],d */ -{ "lduh", 0xc0102000, 0x01e81fff, "[1],d", 0 }, /* lduh [rs1+0],d */ -{ "lduh", 0xc0100000, 0x01e82000, "[1+2],d", 0 }, - -{ "st", 0xc0200000, 0x01d8201f, "d,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc0202000, 0x01d81fff, "d,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc0202000, 0x01d80000, "d,[1+i]", 0 }, -{ "st", 0xc0202000, 0x01d80000, "d,[i+1]", 0 }, -{ "st", 0xc0200000, 0x01d82000, "d,[1+2]", 0 }, -{ "st", 0xc1200000, 0x00d8201f, "g,[1]", 0 }, /* st d[rs1+%g0] */ -{ "st", 0xc1202000, 0x00d81fff, "g,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1202000, 0x00d80000, "g,[1+i]", 0 }, -{ "st", 0xc1202000, 0x00d80000, "g,[i+1]", 0 }, -{ "st", 0xc1200000, 0x00d82000, "g,[1+2]", 0 }, -{ "st", 0xc1280000, 0x00c0d01f, "F,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc1282000, 0x00c0dfff, "F,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1282000, 0x00c0d000, "F,[1+i]", 0 }, -{ "st", 0xc1282000, 0x00c0d000, "F,[i+1]", 0 }, -{ "st", 0xc1280000, 0x00c0d000, "F,[1+2]", 0 }, -{ "st", 0xc1a00000, 0x0058201f, "D,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc1a02000, 0x00581fff, "D,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1a02000, 0x00580000, "D,[1+i]", 0 }, -{ "st", 0xc1a02000, 0x00580000, "D,[i+1]", 0 }, -{ "st", 0xc1a00000, 0x00582000, "D,[1+2]", 0 }, -{ "st", 0xc1a80000, 0x0050201f, "C,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc1a82000, 0x00501fff, "C,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1a82000, 0x00500000, "C,[1+i]", 0 }, -{ "st", 0xc1a82000, 0x00500000, "C,[i+1]", 0 }, -{ "st", 0xc1a80000, 0x00502000, "C,[1+2]", 0 }, -{ "sta", 0xc0a00000, 0x0108201f, "d,[1]A", 0 }, /* sta d,[rs1+%g0] */ -{ "sta", 0xc0a00000, 0x01082000, "d,[1+2]A", 0 }, - -{ "stb", 0xc0280000, 0x01d0201f, "d,[1]", 0 }, /* stb d,[rs1+%g0] */ -{ "stb", 0xc0282000, 0x01d01fff, "d,[1]", 0 }, /* stb d,[rs1+0] */ -{ "stb", 0xc0282000, 0x01d00000, "d,[1+i]", 0 }, -{ "stb", 0xc0282000, 0x01d00000, "d,[i+1]", 0 }, -{ "stb", 0xc0280000, 0x01d02000, "d,[1+2]", 0 }, -{ "stba", 0xc0a80000, 0x01002000, "d,[1+2]A", 0 }, -{ "stba", 0xc0a80000, 0x0100201f, "d,[1]A", 0 }, /* stba d,[rs1+%g0] */ - -{ "std", 0xc0380000, 0x01c0201f, "d,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc0382000, 0x01c01fff, "d,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc0382000, 0x01c00000, "d,[1+i]", 0 }, -{ "std", 0xc0382000, 0x01c00000, "d,[i+1]", 0 }, -{ "std", 0xc0380000, 0x01c02000, "d,[1+2]", 0 }, -{ "std", 0xc1380000, 0x00c0201f, "g,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1382000, 0x00c01fff, "g,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1382000, 0x00c00000, "g,[1+i]", 0 }, -{ "std", 0xc1382000, 0x00c00000, "g,[i+1]", 0 }, -{ "std", 0xc1380000, 0x00c02000, "g,[1+2]", 0 }, -{ "std", 0xc1300000, 0x00c8201f, "q,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1302000, 0x00c81fff, "q,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1302000, 0x00c80000, "q,[1+i]", 0 }, -{ "std", 0xc1302000, 0x00c80000, "q,[i+1]", 0 }, -{ "std", 0xc1300000, 0x00c82000, "q,[1+2]", 0 }, -{ "std", 0xc1b80000, 0x0040201f, "D,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1b82000, 0x00401fff, "D,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1b82000, 0x00400000, "D,[1+i]", 0 }, -{ "std", 0xc1b82000, 0x00400000, "D,[i+1]", 0 }, -{ "std", 0xc1b80000, 0x00402000, "D,[1+2]", 0 }, -{ "std", 0xc1b00000, 0x0048201f, "Q,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1b02000, 0x00481fff, "Q,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1b02000, 0x00480000, "Q,[1+i]", 0 }, -{ "std", 0xc1b02000, 0x00480000, "Q,[i+1]", 0 }, -{ "std", 0xc1b00000, 0x00482000, "Q,[1+2]", 0 }, -{ "stda", 0xc0b80000, 0x01402000, "d,[1+2]A", 0 }, -{ "stda", 0xc0b80000, 0x0140201f, "d,[1]A", 0 }, /* stda d,[rs1+%g0] */ - -{ "sth", 0xc0300000, 0x01c8201f, "d,[1]", 0 }, /* sth d,[rs1+%g0] */ -{ "sth", 0xc0302000, 0x01c81fff, "d,[1]", 0 }, /* sth d,[rs1+0] */ -{ "sth", 0xc0300000, 0x01c82000, "d,[1+2]", 0 }, -{ "sth", 0xc0302000, 0x01c80000, "d,[1+i]", 0 }, -{ "sth", 0xc0302000, 0x01c80000, "d,[i+1]", 0 }, -{ "stha", 0xc0b00000, 0x0148201f, "d,[1]A", 0 }, /* stha d,[rs1+%g0] */ -{ "stha", 0xc0b00000, 0x01482000, "d,[1+2]A", 0 }, - -{ "swap", 0xc0780000, 0x0180201f, "[1],d", 0 }, /* swap [rs1+%g0],d */ -{ "swap", 0xc0782000, 0x01801fff, "[1],d", 0 }, /* swap [rs1+0],d */ -{ "swap", 0xc0782000, 0x01800000, "[1+i],d", 0 }, -{ "swap", 0xc0782000, 0x01800000, "[i+1],d", 0 }, -{ "swap", 0xc0780000, 0x01802000, "[1+2],d", 0 }, -{ "swapa", 0xc0f80000, 0x01002000, "[1+2]A,d", 0 }, -{ "swapa", 0xc0f80000, 0x0100201f, "[1]A,d", 0 }, /* swapa [rs1+%g0],d */ - -{ "restore", 0x81e80000, 0x7e17e01f, "", 0 }, /* restore %g0,%g0,%g0 */ -{ "restore", 0x81e82000, 0x7e14dfff, "", 0 }, /* restore %g0,0,%g0 */ -{ "restore", 0x81e82000, 0x00000000, "1,i,d", 0 }, -{ "restore", 0x81e80000, 0x00000000, "1,2,d", 0 }, -{ "rett", 0x81c82000, 0x40300000, "1+i", 1 }, -{ "rett", 0x81c82000, 0x40300000, "i+1", 1 }, -{ "rett", 0x81c80000, 0x40302000, "1+2", 1 }, -{ "rett", 0x81c82000, 0x40300000, "1", 1}, -{ "save", 0x81e02000, 0x40180000, "1,i,d", 0 }, -{ "save", 0x81e00000, 0x40180000, "1,2,d", 0 }, - -{ "ret", 0x81c7e008, 0x00001ff7, "", 1 }, /* jmpl %i7+8,%g0 */ -{ "retl", 0x81c3e008, 0x00001ff7, "", 1 }, /* jmpl %o7+8,%g0 */ - -{ "jmpl", 0x81c00000, 0x4038201f, "1,d", 1 }, /* jmpl rs1+%g0,d */ -{ "jmpl", 0x81c02000, 0x4037c000, "i,d", 1 }, /* jmpl %g0+i,d */ -{ "jmpl", 0x81c02000, 0x40380000, "1+i,d", 1 }, -{ "jmpl", 0x81c02000, 0x40380000, "i+1,d", 1 }, -{ "jmpl", 0x81c00000, 0x40382000, "1+2,d", 1 }, -{ "wr", 0x81982000, 0x40600000, "1,i,t", 0 }, -{ "wr", 0x81980000, 0x40600000, "1,2,t", 0 }, -{ "wr", 0x81902000, 0x40680000, "1,i,w", 0 }, -{ "wr", 0x81900000, 0x40680000, "1,2,w", 0 }, -{ "wr", 0x81882000, 0x40700000, "1,i,p", 0 }, -{ "wr", 0x81880000, 0x40700000, "1,2,p", 0 }, -{ "wr", 0x81802000, 0x40780000, "1,i,y", 0 }, -{ "wr", 0x81800000, 0x40780000, "1,2,y", 0 }, - -{ "rd", 0x81580000, 0x40a00000, "t,d", 0 }, -{ "rd", 0x81500000, 0x40a80000, "w,d", 0 }, -{ "rd", 0x81480000, 0x40b00000, "p,d", 0 }, -{ "rd", 0x81400000, 0x40b80000, "y,d", 0 }, - -{ "sra", 0x81382000, 0x00000000, "1,i,d", 0 }, -{ "sra", 0x81380000, 0x00000000, "1,2,d", 0 }, -{ "srl", 0x81302000, 0x40c80000, "1,i,d", 0 }, -{ "srl", 0x81300000, 0x40c80000, "1,2,d", 0 }, -{ "sll", 0x81282000, 0x40d00000, "1,i,d", 0 }, -{ "sll", 0x81280000, 0x40d00000, "1,2,d", 0 }, - -{ "mulscc", 0x81202000, 0x40d80000, "1,i,d", 0 }, -{ "mulscc", 0x81200000, 0x40d80000, "1,2,d", 0 }, - -{ "clr", 0x80100000, 0x4e87e01f, "d", 0 }, /* or %g0,%g0,d */ -{ "clr", 0x80102000, 0x41efdfff, "d", 0 }, /* or %g0,0,d */ - -{ "orncc", 0x80b02000, 0x04048000, "1,i,d", 0 }, -{ "orncc", 0x80b02000, 0x04048000, "i,1,d", 0 }, -{ "orncc", 0x80b00000, 0x04048000, "1,2,d", 0 }, - -{ "tst", 0x80900000, 0x7f6fe000, "2", 0 }, /* orcc %g0, rs2, %g0 */ -{ "tst", 0x80900000, 0x7f68201f, "1", 0 }, /* orcc rs1, %g0, %g0 */ -{ "tst", 0x80902000, 0x7f681fff, "1", 0 }, /* orcc rs1, 0, %g0 */ - -{ "orcc", 0x80902000, 0x41680000, "1,i,d", 0 }, -{ "orcc", 0x80902000, 0x41680000, "i,1,d", 0 }, -{ "orcc", 0x80900000, 0x41680000, "1,2,d", 0 }, -{ "orn", 0x80302000, 0x41c80000, "1,i,d", 0 }, -{ "orn", 0x80302000, 0x41c80000, "i,1,d", 0 }, -{ "orn", 0x80300000, 0x41c80000, "1,2,d", 0 }, - -{ "mov", 0x81800000, 0x4078201f, "1,y", 0 }, /* wr rs1,%g0,%y */ -{ "mov", 0x81802000, 0x40781fff, "1,y", 0 }, /* wr rs1,0,%y */ -{ "mov", 0x81400000, 0x40b80000, "y,d", 0 }, /* rd %y,d */ -{ "mov", 0x81980000, 0x4060201f, "1,t", 0 }, /* wr rs1,%g0,%tbr */ -{ "mov", 0x81982000, 0x40601fff, "1,t", 0 }, /* wr rs1,0,%tbr */ -{ "mov", 0x81580000, 0x40a00000, "t,d", 0 }, /* rd %tbr,d */ -{ "mov", 0x81900000, 0x4068201f, "1,w", 0 }, /* wr rs1,%g0,%wim */ -{ "mov", 0x81902000, 0x40681fff, "1,w", 0 }, /* wr rs1,0,%wim */ -{ "mov", 0x81500000, 0x40a80000, "w,d", 0 }, /* rd %wim,d */ -{ "mov", 0x81880000, 0x4070201f, "1,p", 0 }, /* wr rs1,%g0,%psr */ -{ "mov", 0x81882000, 0x40701fff, "1,p", 0 }, /* wr rs1,0,%psr */ -{ "mov", 0x81480000, 0x40b00000, "p,d", 0 }, /* rd %psr,d */ - -{ "mov", 0x80102000, 0x41efc000, "i,d", 0 }, /* or %g0,i,d */ -{ "mov", 0x80100000, 0x41efe000, "2,d", 0 }, /* or %g0,rs2,d */ - -{ "or", 0x80102000, 0x40800000, "1,i,d", 0 }, -{ "or", 0x80102000, 0x40800000, "i,1,d", 0 }, -{ "or", 0x80100000, 0x40800000, "1,2,d", 0 }, - -{ "andncc", 0x80a82000, 0x41500000, "1,i,d", 0 }, -{ "andncc", 0x80a82000, 0x41500000, "i,1,d", 0 }, -{ "andncc", 0x80a80000, 0x41500000, "1,2,d", 0 }, -{ "andn", 0x80282000, 0x41d00000, "1,i,d", 0 }, -{ "andn", 0x80282000, 0x41d00000, "i,1,d", 0 }, -{ "andn", 0x80280000, 0x41d00000, "1,2,d", 0 }, - -{ "cmp", 0x80a02000, 0x7d580000, "1,i", 0 }, /* subcc rs1,i,%g0 */ -{ "cmp", 0x80a00000, 0x7d580000, "1,2", 0 }, /* subcc rs1,rs2,%g0 */ - -{ "subcc", 0x80a02000, 0x41580000, "1,i,d", 0 }, -{ "subcc", 0x80a00000, 0x41580000, "1,2,d", 0 }, -{ "sub", 0x80202000, 0x41d80000, "1,i,d", 0 }, -{ "sub", 0x80200000, 0x41d80000, "1,2,d", 0 }, -{ "subx", 0x80602000, 0x41980000, "1,i,d", 0 }, -{ "subx", 0x80600000, 0x41980000, "1,2,d", 0 }, -{ "subxcc", 0x80e02000, 0x41180000, "1,i,d", 0 }, -{ "subxcc", 0x80e00000, 0x41180000, "1,2,d", 0 }, - -{ "andcc", 0x80882000, 0x41700000, "1,i,d", 0 }, -{ "andcc", 0x80882000, 0x41700000, "i,1,d", 0 }, -{ "andcc", 0x80880000, 0x41700000, "1,2,d", 0 }, -{ "and", 0x80082000, 0x41f00000, "1,i,d", 0 }, -{ "and", 0x80082000, 0x41f00000, "i,1,d", 0 }, -{ "and", 0x80080000, 0x41f00000, "1,2,d", 0 }, - -{ "inc", 0x80002001, 0x41f81ffe, "r", 0 }, /* add rs1,1,rsd */ - -{ "addxcc", 0x80c02000, 0x41380000, "1,i,d", 0 }, -{ "addxcc", 0x80c02000, 0x41380000, "i,1,d", 0 }, -{ "addxcc", 0x80c00000, 0x41380000, "1,2,d", 0 }, -{ "addcc", 0x80802000, 0x41780000, "1,i,d", 0 }, -{ "addcc", 0x80802000, 0x41780000, "i,1,d", 0 }, -{ "addcc", 0x80800000, 0x41780000, "1,2,d", 0 }, -{ "addx", 0x80402000, 0x41b80000, "1,i,d", 0 }, -{ "addx", 0x80402000, 0x41b80000, "i,1,d", 0 }, -{ "addx", 0x80400000, 0x41b80000, "1,2,d", 0 }, -{ "add", 0x80002000, 0x41f80000, "1,i,d", 0 }, -{ "add", 0x80002000, 0x41f80000, "i,1,d", 0 }, -{ "add", 0x80000000, 0x41f80000, "1,2,d", 0 }, - -{ "call", 0x9fc00000, 0x4038201f, "1", 1 }, /* jmpl rs1+%g0, %o7 */ -{ "call", 0x9fc00000, 0x4038201f, "1,#", 1 }, -{ "call", 0x40000000, 0x80000000, "L", 1 }, -{ "call", 0x40000000, 0x80000000, "L,#", 1 }, - -{ "bvc", 0x3e800000, 0xc1400000, ",al", 1 }, -{ "bvc", 0x1e800000, 0xc1400000, "l", 1 }, -{ "bvs", 0x2e800000, 0xc1400000, ",al", 1 }, -{ "bvs", 0x0e800000, 0xc1400000, "l", 1 }, -{ "bpos", 0x3c800000, 0xc1400000, ",al", 1 }, -{ "bpos", 0x1c800000, 0xc1400000, "l", 1 }, -{ "bneg", 0x2c800000, 0xc1400000, ",al", 1 }, -{ "bneg", 0x0c800000, 0xc1400000, "l", 1 }, -{ "bcc", 0x3a800000, 0xc1400000, ",al", 1 }, -{ "bcc", 0x1a800000, 0xc1400000, "l", 1 }, -{ "bcs", 0x2a800000, 0xc1400000, ",al", 1 }, -{ "bcs", 0x0a800000, 0xc1400000, "l", 1 }, -{ "blu", 0x2a800000, 0xc1400000, ",al", 1 }, -{ "blu", 0x0a800000, 0xc1400000, "l", 1 }, /* same as bcs */ -{ "bgeu", 0x3a800000, 0xc1400000, ",al", 1 }, -{ "bgeu", 0x1a800000, 0xc1400000, "l", 1 }, /* same as bcc */ -{ "bgu", 0x38800000, 0xc1400000, ",al", 1 }, -{ "bgu", 0x18800000, 0xc1400000, "l", 1 }, -{ "bleu", 0x28800000, 0xc1400000, ",al", 1 }, -{ "bleu", 0x08800000, 0xc1400000, "l", 1 }, -{ "bge", 0x36800000, 0xc1400000, ",al", 1 }, -{ "bge", 0x16800000, 0xc1400000, "l", 1 }, -{ "bl", 0x26800000, 0xc1400000, ",al", 1 }, -{ "bl", 0x06800000, 0xc1400000, "l", 1 }, -{ "bg", 0x34800000, 0xc1400000, ",al", 1 }, -{ "bg", 0x14800000, 0xc1400000, "l", 1 }, -{ "ble", 0x24800000, 0xc1400000, ",al", 1 }, -{ "ble", 0x04800000, 0xc1400000, "l", 1 }, -{ "be", 0x22800000, 0xc1400000, ",al", 1 }, -{ "be", 0x02800000, 0xc1400000, "l", 1 }, -{ "bne", 0x32800000, 0xc1400000, ",al", 1 }, -{ "bne", 0x12800000, 0xc1400000, "l", 1 }, -{ "b", 0x30800000, 0xc1400000, ",al", 1 }, -{ "b", 0x10800000, 0xc1400000, "l", 1 }, -{ "ba", 0x30800000, 0xc1400000, ",al", 1 }, -{ "ba", 0x10800000, 0xc1400000, "l", 1 }, -{ "bn", 0x20800000, 0xc1400000, ",al", 1 }, -{ "bn", 0x00800000, 0xc1400000, "l", 1 }, - -{ "jmp", 0x81c00000, 0x7e38201f, "1", 1 }, /* jmpl rs1+%g0,%g0 */ -{ "jmp", 0x81c02000, 0x7e3fc000, "i", 1 }, /* jmpl %g0+i,%g0 */ -{ "jmp", 0x81c00000, 0x7e382000, "1+2", 1 }, /* jmpl rs1+rs2,%g0 */ -{ "jmp", 0x81c02000, 0x7e380000, "1+i", 1 }, /* jmpl rs1+i,%g0 */ -{ "jmp", 0x81c02000, 0x7e380000, "i+1", 1 }, /* jmpl i+rs1,%g0 */ - -{ "nop", 0x01000000, 0xfe3fffff, "", 0 }, /* sethi 0, %g0 */ - -{ "set", 0x01000000, 0xc0c00000, "Sh,d", 0 }, - -{ "sethi", 0x01000000, 0xc0c00000, "h,d", 0 }, - -{ "taddcctv", 0x81102000, 0x40e00000, "1,i,d", 0 }, -{ "taddcctv", 0x81100000, 0x40e00000, "1,2,d", 0 }, -{ "taddcc", 0x81002000, 0x40f80000, "1,i,d", 0 }, -{ "taddcc", 0x81000000, 0x40f80000, "1,2,d", 0 }, - -{ "tvc", 0x9fd02000, 0x402fc000, "i", 0 }, /* tvc %g0+i */ -{ "tvc", 0x9fd02000, 0x40280000, "1+i", 0 }, -{ "tvc", 0x9fd00000, 0x40282000, "1+2", 0 }, -{ "tvc", 0x9fd00000, 0x4028201f, "1", 0 }, /* tvc rs1+%g0 */ -{ "tpos", 0x9dd02000, 0x402fc000, "i", 0 }, /* tpos %g0+i */ -{ "tpos", 0x9dd02000, 0x40280000, "1+i", 0 }, -{ "tpos", 0x9dd00000, 0x40282000, "1+2", 0 }, -{ "tpos", 0x9dd00000, 0x4028201f, "1", 0 }, /* tpos rs1+%g0 */ -{ "tcc", 0x9bd02000, 0x402fc000, "i", 0 }, /* tcc %g0+i */ -{ "tcc", 0x9bd02000, 0x40280000, "1+i", 0 }, -{ "tcc", 0x9bd00000, 0x40282000, "1+2", 0 }, -{ "tcc", 0x9bd00000, 0x4028201f, "1", 0 }, /* tcc rs1+%g0 */ -{ "tgu", 0x99d02000, 0x402fc000, "i", 0 }, /* tgu %g0+i */ -{ "tgu", 0x99d02000, 0x40280000, "1+i", 0 }, -{ "tgu", 0x99d00000, 0x40282000, "1+2", 0 }, -{ "tgu", 0x99d00000, 0x4028201f, "1", 0 }, /* tgu rs1+%g0 */ -{ "tge", 0x97d02000, 0x402fc000, "i", 0 }, /* tge %g0+i */ -{ "tge", 0x97d02000, 0x40280000, "1+i", 0 }, -{ "tge", 0x97d00000, 0x40282000, "1+2", 0 }, -{ "tge", 0x97d00000, 0x4028201f, "1", 0 }, /* tge rs1+%g0 */ -{ "tg", 0x95d02000, 0x402fc000, "i", 0 }, /* tg %g0+i */ -{ "tg", 0x95d02000, 0x40280000, "1+i", 0 }, -{ "tg", 0x95d00000, 0x40282000, "1+2", 0 }, -{ "tg", 0x95d00000, 0x4028201f, "1", 0 }, /* tg rs1+%g0 */ -{ "tne", 0x93d02000, 0x402fc000, "i", 0 }, /* tne %g0+i */ -{ "tne", 0x93d02000, 0x40280000, "1+i", 0 }, -{ "tne", 0x93d00000, 0x40282000, "1+2", 0 }, -{ "tne", 0x93d00000, 0x4028201f, "1", 0 }, /* tne rs1+%g0 */ -{ "tleu", 0x8bd02000, 0x502fc000, "i", 0 }, /* tleu %g0+i */ -{ "tleu", 0x8bd02000, 0x50280000, "1+i", 0 }, -{ "tleu", 0x8bd00000, 0x50282000, "1+2", 0 }, -{ "tleu", 0x8bd00000, 0x5028201f, "1", 0 }, /* tleu rs1+%g0 */ -{ "ta", 0x91d02000, 0x402fc000, "i", 0 }, /* ta %g0+i */ -{ "ta", 0x91d02000, 0x402d0000, "1+i", 0 }, -{ "ta", 0x91d00000, 0x40282000, "1+2", 0 }, -{ "ta", 0x91d00000, 0x4028201f, "1", 0 }, /* ta rs1+%g0 */ -{ "tvs", 0x8fd02000, 0x502fc000, "i", 0 }, /* tvs %g0+i */ -{ "tvs", 0x8fd02000, 0x50280000, "1+i", 0 }, -{ "tvs", 0x8fd00000, 0x50282000, "1+2", 0 }, -{ "tvs", 0x8fd00000, 0x5028201f, "1", 0 }, /* tvs rs1+%g0 */ -{ "tneg", 0x8dd02000, 0x502fc000, "i", 0 }, /* tneg %g0+i */ -{ "tneg", 0x8dd02000, 0x50280000, "1+i", 0 }, -{ "tneg", 0x8dd00000, 0x50282000, "1+2", 0 }, -{ "tneg", 0x8dd00000, 0x5028201f, "1", 0 }, /* tneg rs1+%g0 */ -{ "tcs", 0x8bd02000, 0x502fc000, "i", 0 }, /* tcs %g0+i */ -{ "tcs", 0x8bd02000, 0x50280000, "1+i", 0 }, -{ "tcs", 0x8bd00000, 0x50282000, "1+2", 0 }, -{ "tcs", 0x8bd00000, 0x5028201f, "1", 0 }, /* tcs rs1+%g0 */ -{ "tl", 0x87d02000, 0x502fc000, "i", 0 }, /* tl %g0+i */ -{ "tl", 0x87d02000, 0x50280000, "1+i", 0 }, -{ "tl", 0x87d00000, 0x50282000, "1+2", 0 }, -{ "tl", 0x87d00000, 0x5028201f, "1", 0 }, /* tl rs1+%g0 */ -{ "tle", 0x85d02000, 0x502fc000, "i", 0 }, /* tle %g0+i */ -{ "tle", 0x85d02000, 0x50280000, "1+i", 0 }, -{ "tle", 0x85d00000, 0x50282000, "1+2", 0 }, -{ "tle", 0x85d00000, 0x5028201f, "1", 0 }, /* tle rs1+%g0 */ -{ "te", 0x83d02000, 0x502fc000, "i", 0 }, /* te %g0+i */ -{ "te", 0x83d02000, 0x50280000, "1+i", 0 }, -{ "te", 0x83d00000, 0x50282000, "1+2", 0 }, -{ "te", 0x83d00000, 0x5028201f, "1", 0 }, /* te rs1+%g0 */ -{ "tn", 0x81d02000, 0x502fc000, "i", 0 }, /* tn %g0+i */ -{ "tn", 0x81d02000, 0x50280000, "1+i", 0 }, -{ "tn", 0x81d00000, 0x50282000, "1+2", 0 }, -{ "tn", 0x81d00000, 0x5028201f, "1", 0 }, /* tn rs1+%g0 */ - -{ "tsubcc", 0x81080000, 0x40f00000, "1,2,d", 0 }, -{ "tsubcc", 0x81082000, 0x40f00000, "1,i,d", 0 }, -{ "tsubcctv", 0x80580000, 0x40a00000, "1,2,d", 0 }, -{ "tsubcctv", 0x80582000, 0x40a00000, "1,i,d", 0 }, - -{ "unimp", 0x00000000, 0x00000000, "l", 0 }, - -{ "iflush", 0x81d80000, 0x40202000, "1+2", 0 }, -{ "iflush", 0x81d82000, 0x40200000, "1+i", 0 }, - -{ "xnorcc", 0x80b80000, 0x41400000, "1,2,d", 0 }, -{ "xnorcc", 0x80b82000, 0x41400000, "1,i,d", 0 }, -{ "xnorcc", 0x80b82000, 0x41400000, "i,1,d", 0 }, -{ "xorcc", 0x80980000, 0x41600000, "1,2,d", 0 }, -{ "xorcc", 0x80982000, 0x41600000, "1,i,d", 0 }, -{ "xorcc", 0x80982000, 0x41600000, "i,1,d", 0 }, -{ "xnor", 0x80380000, 0x41c00000, "1,2,d", 0 }, -{ "xnor", 0x80382000, 0x41c00000, "1,i,d", 0 }, -{ "xnor", 0x80382000, 0x41c00000, "i,1,d", 0 }, -{ "xor", 0x80180000, 0x41e00000, "1,2,d", 0 }, -{ "xor", 0x80182000, 0x41e00000, "1,i,d", 0 }, -{ "xor", 0x80182000, 0x41e00000, "i,1,d", 0 }, - -{ "fpop1", 0x81a00000, 0x40580000, "[1+2],d", 0 }, -{ "fpop2", 0x81a80000, 0x40500000, "[1+2],d", 0 }, - -{ "fb", 0x31800000, 0xc0400000, ",al", 1 }, -{ "fb", 0x11800000, 0xc0400000, "l", 1 }, -{ "fba", 0x31800000, 0xc0400000, ",al", 1 }, -{ "fba", 0x11800000, 0xc0400000, "l", 1 }, -{ "fbn", 0x21800000, 0xc0400000, ",al", 1 }, -{ "fbn", 0x01800000, 0xc0400000, "l", 1 }, -{ "fbu", 0x2f800000, 0xc0400000, ",al", 1 }, -{ "fbu", 0x0f800000, 0xc0400000, "l", 1 }, -{ "fbg", 0x2d800000, 0xc0400000, ",al", 1 }, -{ "fbg", 0x0d800000, 0xc0400000, "l", 1 }, -{ "fbug", 0x2b800000, 0xc0400000, ",al", 1 }, -{ "fbug", 0x0b800000, 0xc0400000, "l", 1 }, -{ "fbl", 0x29800000, 0xc0400000, ",al", 1 }, -{ "fbl", 0x09800000, 0xc0400000, "l", 1 }, -{ "fbul", 0x27800000, 0xc0400000, ",al", 1 }, -{ "fbul", 0x07800000, 0xc0400000, "l", 1 }, -{ "fblg", 0x25800000, 0xc0400000, ",al", 1 }, -{ "fblg", 0x05800000, 0xc0400000, "l", 1 }, -{ "fbne", 0x23800000, 0xc0400000, ",al", 1 }, -{ "fbne", 0x03800000, 0xc0400000, "l", 1 }, -{ "fbe", 0x33800000, 0xc0400000, ",al", 1 }, -{ "fbe", 0x13800000, 0xc0400000, "l", 1 }, -{ "fbue", 0x35800000, 0xc0400000, ",al", 1 }, -{ "fbue", 0x15800000, 0xc0400000, "l", 1 }, -{ "fbge", 0x37800000, 0xc0400000, ",al", 1 }, -{ "fbge", 0x17800000, 0xc0400000, "l", 1 }, -{ "fbuge", 0x39800000, 0xc0400000, ",al", 1 }, -{ "fbuge", 0x19800000, 0xc0400000, "l", 1 }, -{ "fble", 0x3b800000, 0xc0400000, ",al", 1 }, -{ "fble", 0x1b800000, 0xc0400000, "l", 1 }, -{ "fbule", 0x3d800000, 0xc0400000, ",al", 1 }, -{ "fbule", 0x1d800000, 0xc0400000, "l", 1 }, -{ "fbo", 0x3f800000, 0xc0400000, ",al", 1 }, -{ "fbo", 0x1f800000, 0xc0400000, "l", 1 }, - -{ "cba", 0x31c00000, 0xce000000, ",al", 1 }, -{ "cba", 0x11c00000, 0xce000000, "l", 1 }, -{ "cbn", 0x21c00000, 0xde000000, ",al", 1 }, -{ "cbn", 0x01c00000, 0xde000000, "l", 1 }, -{ "cb3", 0x2fc00000, 0xc0000000, ",al", 1 }, -{ "cb3", 0x0fc00000, 0xc0000000, "l", 1 }, -{ "cb2", 0x2dc00000, 0xc0000000, ",al", 1 }, -{ "cb2", 0x0dc00000, 0xc0000000, "l", 1 }, -{ "cb23", 0x2bc00000, 0xc0000000, ",al", 1 }, -{ "cb23", 0x0bc00000, 0xc0000000, "l", 1 }, -{ "cb1", 0x29c00000, 0xc0000000, ",al", 1 }, -{ "cb1", 0x09c00000, 0xc0000000, "l", 1 }, -{ "cb13", 0x27c00000, 0xc0000000, ",al", 1 }, -{ "cb13", 0x07c00000, 0xc0000000, "l", 1 }, -{ "cb12", 0x25c00000, 0xc0000000, ",al", 1 }, -{ "cb12", 0x05c00000, 0xc0000000, "l", 1 }, -{ "cb123", 0x23c00000, 0xc0000000, ",al", 1 }, -{ "cb123", 0x03c00000, 0xc0000000, "l", 1 }, -{ "cb0", 0x33c00000, 0xc0000000, ",al", 1 }, -{ "cb0", 0x13c00000, 0xc0000000, "l", 1 }, -{ "cb03", 0x35c00000, 0xc0000000, ",al", 1 }, -{ "cb03", 0x15c00000, 0xc0000000, "l", 1 }, -{ "cb02", 0x37c00000, 0xc0000000, ",al", 1 }, -{ "cb02", 0x17c00000, 0xc0000000, "l", 1 }, -{ "cb023", 0x39c00000, 0xc0000000, ",al", 1 }, -{ "cb023", 0x19c00000, 0xc0000000, "l", 1 }, -{ "cb013", 0x3dc00000, 0xc0000000, ",al", 1 }, -{ "cb013", 0x1dc00000, 0xc0000000, "l", 1 }, -{ "cb012", 0x3fc00000, 0xc0000000, ",al", 1 }, -{ "cb012", 0x1fc00000, 0xc0000000, "l", 1 }, - -{ "fstoi", 0x81a01a20, 0x400025c0, "f,g", 0 }, -{ "fdtoi", 0x81a01a40, 0x400025a0, "f,g", 0 }, -{ "fxtoi", 0x81a01a60, 0x40002580, "f,g", 0 }, - -{ "fitox", 0x81a01980, 0x40002660, "f,g", 0 }, -{ "fitod", 0x81a01900, 0x400026e0, "f,g", 0 }, -{ "fitos", 0x81a01880, 0x40002660, "f,g", 0 }, - -{ "fstod", 0x81a01920, 0x400026c0, "f,g", 0 }, -{ "fstox", 0x81a019a0, 0x40002640, "f,g", 0 }, -{ "fdtos", 0x81a018c0, 0x40002720, "f,g", 0 }, -{ "fdtox", 0x81a019c0, 0x40002620, "f,g", 0 }, -{ "fxtos", 0x81a018e0, 0x40002700, "f,g", 0 }, -{ "fxtod", 0x81a01960, 0x40002680, "f,g", 0 }, - -{ "fdivx", 0x81a009e0, 0x40083600, "e,f,g", 0 }, -{ "fdivd", 0x81a009c0, 0x40003620, "e,f,g", 0 }, -{ "fdivs", 0x81a009a0, 0x40003640, "e,f,g", 0 }, -{ "fmuls", 0x81a00920, 0x400036c0, "e,f,g", 0 }, -{ "fmuld", 0x81a00940, 0x400036a0, "e,f,g", 0 }, -{ "fmulx", 0x81a00960, 0x40003680, "e,f,g", 0 }, - -{ "fsqrts", 0x81a00520, 0x40003ac0, "f,g", 0 }, -{ "fsqrtd", 0x81a00540, 0x40003aa8, "f,g", 0 }, -{ "fsqrtx", 0x81a00560, 0x40003a80, "f,g", 0 }, - -{ "fabss", 0x81a00120, 0x40003ec0, "f,g", 0 }, -{ "fnegs", 0x81a000a0, 0x40003f40, "f,g", 0 }, -{ "fmovs", 0x81a00020, 0x40003fc0, "f,g", 0 }, - -{ "fsubx", 0x81a008e0, 0x40003700, "e,f,g", 0 }, -{ "fsubd", 0x81a008c0, 0x40003720, "e,f,g", 0 }, -{ "fsubs", 0x81a008a0, 0x40003740, "e,f,g", 0 }, -{ "faddx", 0x81a00860, 0x40003780, "e,f,g", 0 }, -{ "faddd", 0x81a00840, 0x400037a0, "e,f,g", 0 }, -{ "fadds", 0x81a00820, 0x400037c0, "e,f,g", 0 }, - -{ "fcmpex", 0x81a80ae0, 0x40003500, "e,f", 0 }, -{ "fcmped", 0x81a80ac0, 0x40003520, "e,f", 0 }, -{ "fcmpes", 0x81a80aa0, 0x40003540, "e,f", 0 }, -{ "fcmpx", 0x81a80a60, 0x40003580, "e,f", 0 }, -{ "fcmpd", 0x81a80a40, 0x400035a0, "e,f", 0 }, -{ "fcmps", 0x81a80a20, 0x400035c0, "e,f", 0 }, - -{ "cpop1", 0x81b00000, 0x40480000, "[1+2],d", 0 }, -{ "cpop2", 0x81b80000, 0x40400000, "[1+2],d", 0 }, -}; - -#define NUMOPCODES ((sizeof sparc_opcodes)/(sizeof sparc_opcodes[0])) - diff --git a/gnu/usr.bin/gas/config/sparc.c b/gnu/usr.bin/gas/config/sparc.c deleted file mode 100644 index 340d5a00f699..000000000000 --- a/gnu/usr.bin/gas/config/sparc.c +++ /dev/null @@ -1,1288 +0,0 @@ -/* sparc.c -- Assemble for the SPARC - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: sparc.c,v 1.2 1993/08/02 17:27:22 mycroft Exp $"; -#endif /* not lint */ - -#include -#include - -#include "sparc-opcode.h" -#include "as.h" -#include "frags.h" -#include "struc-symbol.h" -#include "flonum.h" -#include "expr.h" -#include "hash.h" -#include "md.h" -#include "sparc.h" -#include "write.h" -#include "read.h" -#include "symbols.h" - -void md_begin(); -void md_end(); -void md_number_to_chars(); -void md_assemble(); -char *md_atof(); -void md_convert_frag(); -void md_create_short_jump(); -void md_create_long_jump(); -int md_estimate_size_before_relax(); -void md_number_to_imm(); -void md_number_to_disp(); -void md_number_to_field(); -void md_ri_to_chars(); -void emit_relocations(); -static void sparc_ip(); - -const relax_typeS md_relax_table[] = { 0 }; - -/* handle of the OPCODE hash table */ -static struct hash_control *op_hash = NULL; - -static void s_seg(), s_proc(), s_data1(), s_reserve(), s_common(); -extern void s_globl(), s_long(), s_short(), s_space(), cons(); - -const pseudo_typeS -md_pseudo_table[] = { - { "common", s_common, 0 }, - { "global", s_globl, 0 }, - { "half", cons, 2 }, - { "proc", s_proc, 0 }, - { "reserve", s_reserve, 0 }, - { "seg", s_seg, 0 }, - { "skip", s_space, 0 }, - { "word", cons, 4 }, - { NULL, 0, 0 }, -}; - -int md_short_jump_size = 4; -int md_long_jump_size = 4; -int omagic = (0x103 << 16) | OMAGIC; /* Magic number for header */ - -/* This array holds the chars that always start a comment. If the - pre-processor is disabled, these aren't very useful */ -char comment_chars[] = "!"; /* JF removed '|' from comment_chars */ - -/* This array holds the chars that only start a comment at the beginning of - a line. If the line seems to have the form '# 123 filename' - .line and .file directives will appear in the pre-processed output */ -/* Note that input_file.c hand checks for '#' at the beginning of the - first line of the input file. This is because the compiler outputs - #NO_APP at the beginning of its output. */ -/* Also note that '/*' will always start a comment */ -char line_comment_chars[] = "#"; - -/* Chars that can be used to separate mant from exp in floating point nums */ -char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* As in 0f12.456 */ -/* or 0d1.2345e12 */ -char FLT_CHARS[] = "rRsSfFdDxXpP"; - -/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be - changed in read.c . Ideally it shouldn't have to know about it at all, - but nothing is ideal around here. - */ -int size_reloc_info = sizeof(struct reloc_info_sparc); - -static unsigned char octal[256]; -#define isoctal(c) octal[c] -static unsigned char toHex[256]; - -/* - * anull bit - causes the branch delay slot instructions to not be executed - */ -#define ANNUL (1 << 29) - -struct sparc_it { - char *error; - unsigned long opcode; - struct nlist *nlistp; - expressionS exp; - int pcrel; - enum reloc_type reloc; -} the_insn, set_insn; - -#ifdef __STDC__ -#if 0 -static void print_insn(struct sparc_it *insn); -#endif -static int getExpression(char *str); -#else -#if 0 -static void print_insn(); -#endif -static int getExpression(); -#endif -static char *expr_end; -static int special_case; - -#define SPECIAL_CASE_SET 1 - -/* - * sort of like s_lcomm - * - */ -static void -s_reserve() -{ - char *name; - char c; - char *p; - int temp; - symbolS *symbolP; - - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - *p = c; - SKIP_WHITESPACE(); - if ( * input_line_pointer != ',' ) { - as_warn("Expected comma after name"); - ignore_rest_of_line(); - return; - } - input_line_pointer ++; - if ((temp = get_absolute_expression()) < 0) { - as_warn("BSS length (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } - *p = 0; - symbolP = symbol_find_or_make(name); - *p = c; - if (strncmp(input_line_pointer, ",\"bss\"", 6) != 0) { - as_warn("bad .reserve segment: `%s'", input_line_pointer); - return; - } - input_line_pointer += 6; - if (symbolP->sy_other == 0 - && symbolP->sy_desc == 0 - && ((symbolP->sy_type == N_BSS - && symbolP->sy_value == local_bss_counter) - || ((symbolP->sy_type & N_TYPE) == N_UNDF - && symbolP->sy_value == 0))) { - symbolP->sy_value = local_bss_counter; - symbolP->sy_type = N_BSS; - symbolP->sy_frag = & bss_address_frag; - local_bss_counter += temp; - } else { - as_warn( "Ignoring attempt to re-define symbol from %d. to %d.", - symbolP->sy_value, local_bss_counter ); - } - demand_empty_rest_of_line(); - return; -} - -static void -s_common() -{ - register char *name; - register char c; - register char *p; - register int temp; - register symbolS * symbolP; - - name = input_line_pointer; - c = get_symbol_end(); - /* just after name is now '\0' */ - p = input_line_pointer; - *p = c; - SKIP_WHITESPACE(); - if ( * input_line_pointer != ',' ) { - as_warn("Expected comma after symbol-name"); - ignore_rest_of_line(); - return; - } - input_line_pointer ++; /* skip ',' */ - if ( (temp = get_absolute_expression ()) < 0 ) { - as_warn(".COMMon length (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } - *p = 0; - symbolP = symbol_find_or_make (name); - *p = c; - if ( (symbolP->sy_type & N_TYPE) != N_UNDF || - symbolP->sy_other != 0 || symbolP->sy_desc != 0) { - as_warn( "Ignoring attempt to re-define symbol"); - ignore_rest_of_line(); - return; - } - if (symbolP->sy_value) { - if (symbolP->sy_value != temp) { - as_warn( "Length of .comm \"%s\" is already %d. Not changed to %d.", - symbolP->sy_name, symbolP->sy_value, temp); - } - } else { - symbolP->sy_value = temp; - symbolP->sy_type |= N_EXT; - } - know(symbolP->sy_frag == &zero_address_frag); - if (strncmp(input_line_pointer, ",\"bss\"", 6) != 0) { - p=input_line_pointer; - while(*p && *p!='\n') - p++; - c= *p; - *p='\0'; - as_warn("bad .common segment: `%s'", input_line_pointer); - *p=c; - return; - } - input_line_pointer += 6; - demand_empty_rest_of_line(); - return; -} - -static void -s_seg() -{ - - if (strncmp(input_line_pointer, "\"text\"", 6) == 0) { - input_line_pointer += 6; - s_text(); - return; - } - if (strncmp(input_line_pointer, "\"data\"", 6) == 0) { - input_line_pointer += 6; - s_data(); - return; - } - if (strncmp(input_line_pointer, "\"data1\"", 7) == 0) { - input_line_pointer += 7; - s_data1(); - return; - } - as_warn("Unknown segment type"); - demand_empty_rest_of_line(); - return; -} - -static void -s_data1() -{ - subseg_new(SEG_DATA, 1); - demand_empty_rest_of_line(); - return; -} - -static void -s_proc() -{ - extern char is_end_of_line[]; - - while (!is_end_of_line[*input_line_pointer]) { - ++input_line_pointer; - } - ++input_line_pointer; - return; -} - -/* This function is called once, at assembler startup time. It should - set up all the tables, etc. that the MD part of the assembler will need. */ -void -md_begin() -{ - register char *retval = NULL; - int lose = 0; - register unsigned int i = 0; - - op_hash = hash_new(); - if (op_hash == NULL) - as_fatal("Virtual memory exhausted"); - - while (i < NUMOPCODES) - { - const char *name = sparc_opcodes[i].name; - retval = hash_insert(op_hash, name, &sparc_opcodes[i]); - if(retval != NULL && *retval != '\0') - { - fprintf (stderr, "internal error: can't hash `%s': %s\n", - sparc_opcodes[i].name, retval); - lose = 1; - } - do - { - if (sparc_opcodes[i].match & sparc_opcodes[i].lose) - { - fprintf (stderr, "internal error: losing opcode: `%s' \"%s\"\n", - sparc_opcodes[i].name, sparc_opcodes[i].args); - lose = 1; - } - ++i; - } while (i < NUMOPCODES - && !strcmp(sparc_opcodes[i].name, name)); - } - - if (lose) - as_fatal ("Broken assembler. No assembly attempted."); - - for (i = '0'; i < '8'; ++i) - octal[i] = 1; - for (i = '0'; i <= '9'; ++i) - toHex[i] = i - '0'; - for (i = 'a'; i <= 'f'; ++i) - toHex[i] = i + 10 - 'a'; - for (i = 'A'; i <= 'F'; ++i) - toHex[i] = i + 10 - 'A'; -} - -void -md_end() -{ - return; -} - -void -md_assemble(str) - char *str; -{ - char *toP; - int rsd; - - assert(str); - sparc_ip(str); - toP = frag_more(4); - /* put out the opcode */ - md_number_to_chars(toP, the_insn.opcode, 4); - - /* put out the symbol-dependent stuff */ - if (the_insn.reloc != NO_RELOC) { - fix_new( - frag_now, /* which frag */ - (toP - frag_now->fr_literal), /* where */ - 4, /* size */ - the_insn.exp.X_add_symbol, - the_insn.exp.X_subtract_symbol, - the_insn.exp.X_add_number, - the_insn.pcrel, - the_insn.reloc - ); - } - switch (special_case) { - - case SPECIAL_CASE_SET: - special_case = 0; - assert(the_insn.reloc == RELOC_HI22); - toP = frag_more(4); - rsd = (the_insn.opcode >> 25) & 0x1f; - the_insn.opcode = 0x80102000 | (rsd << 25) | (rsd << 14); - md_number_to_chars(toP, the_insn.opcode, 4); - fix_new( - frag_now, /* which frag */ - (toP - frag_now->fr_literal), /* where */ - 4, /* size */ - the_insn.exp.X_add_symbol, - the_insn.exp.X_subtract_symbol, - the_insn.exp.X_add_number, - the_insn.pcrel, - RELOC_LO10 - ); - return; - - case 0: - return; - - default: - abort(); - } -} - -static void -sparc_ip(str) - char *str; -{ - char *s; - const char *args; - char c; - unsigned long i; - struct sparc_opcode *insn; - char *argsStart; - unsigned long opcode; - unsigned int mask; - int match = FALSE; - int comma = 0; - - for (s = str; islower(*s) || (*s >= '0' && *s <= '3'); ++s) - ; - switch (*s) { - - case '\0': - break; - - case ',': - comma = 1; - - /*FALLTHROUGH*/ - - case ' ': - *s++ = '\0'; - break; - - default: - as_warn("Unknown opcode: `%s'", str); - exit(1); - } - if ((insn = (struct sparc_opcode *) hash_find(op_hash, str)) == NULL) { - as_warn("Unknown opcode: `%s'", str); - return; - } - if (comma) { - *--s = ','; - } - argsStart = s; - for (;;) { - opcode = insn->match; - bzero(&the_insn, sizeof(the_insn)); - the_insn.reloc = NO_RELOC; - - /* - * Build the opcode, checking as we go to make - * sure that the operands match - */ - for (args = insn->args; ; ++args) { - switch (*args) { - - case '\0': /* end of args */ - if (*s == '\0') { - match = TRUE; - } - break; - - case '+': - if (*s == '+') { - ++s; - continue; - } - if (*s == '-') { - continue; - } - break; - - case '[': /* these must match exactly */ - case ']': - case ',': - case ' ': - if (*s++ == *args) - continue; - break; - - case '#': /* must be at least one digit */ - if (isdigit(*s++)) { - while (isdigit(*s)) { - ++s; - } - continue; - } - break; - - case 'C': /* coprocessor state register */ - if (strncmp(s, "%csr", 4) == 0) { - s += 4; - continue; - } - break; - - case 'b': /* next operand is a coprocessor register */ - case 'c': - case 'D': - if (*s++ == '%' && *s++ == 'c' && isdigit(*s)) { - mask = *s++; - if (isdigit(*s)) { - mask = 10 * (mask - '0') + (*s++ - '0'); - if (mask >= 32) { - break; - } - } else { - mask -= '0'; - } - switch (*args) { - - case 'b': - opcode |= mask << 14; - continue; - - case 'c': - opcode |= mask; - continue; - - case 'D': - opcode |= mask << 25; - continue; - } - } - break; - - case 'r': /* next operand must be a register */ - case '1': - case '2': - case 'd': - if (*s++ == '%') { - switch (c = *s++) { - - case 'f': /* frame pointer */ - if (*s++ == 'p') { - mask = 0x1e; - break; - } - goto error; - - case 'g': /* global register */ - if (isoctal(c = *s++)) { - mask = c - '0'; - break; - } - goto error; - - case 'i': /* in register */ - if (isoctal(c = *s++)) { - mask = c - '0' + 24; - break; - } - goto error; - - case 'l': /* local register */ - if (isoctal(c = *s++)) { - mask= (c - '0' + 16) ; - break; - } - goto error; - - case 'o': /* out register */ - if (isoctal(c = *s++)) { - mask= (c - '0' + 8) ; - break; - } - goto error; - - case 's': /* stack pointer */ - if (*s++ == 'p') { - mask= 0xe; - break; - } - goto error; - - case 'r': /* any register */ - if (!isdigit(c = *s++)) { - goto error; - } - /* FALLTHROUGH */ - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - if (isdigit(*s)) { - if ((c = 10 * (c - '0') + (*s++ - '0')) >= 32) { - goto error; - } - } else { - c -= '0'; - } - mask= c; - break; - - default: - goto error; - } - /* - * Got the register, now figure out where - * it goes in the opcode. - */ - switch (*args) { - - case '1': - opcode |= mask << 14; - continue; - - case '2': - opcode |= mask; - continue; - - case 'd': - opcode |= mask << 25; - continue; - - case 'r': - opcode |= (mask << 25) | (mask << 14); - continue; - } - } - break; - - case 'e': /* next operand is a floating point register */ - case 'f': - case 'g': - if (*s++ == '%' && *s++ == 'f' && isdigit(*s)) { - mask = *s++; - if (isdigit(*s)) { - mask = 10 * (mask - '0') + (*s++ - '0'); - if (mask >= 32) { - break; - } - } else { - mask -= '0'; - } - switch (*args) { - - case 'e': - opcode |= mask << 14; - continue; - - case 'f': - opcode |= mask; - continue; - - case 'g': - opcode |= mask << 25; - continue; - } - } - break; - - case 'F': - if (strncmp(s, "%fsr", 4) == 0) { - s += 4; - continue; - } - break; - - case 'h': /* high 22 bits */ - the_insn.reloc = RELOC_HI22; - goto immediate; - - case 'l': /* 22 bit PC relative immediate */ - the_insn.reloc = RELOC_WDISP22; - the_insn.pcrel = 1; - goto immediate; - - case 'L': /* 30 bit immediate */ - the_insn.reloc = RELOC_WDISP30; - the_insn.pcrel = 1; - goto immediate; - - case 'i': /* 13 bit immediate */ - the_insn.reloc = RELOC_BASE13; - - /*FALLTHROUGH*/ - - immediate: - if(*s==' ') - s++; - if (*s == '%') { - if ((c = s[1]) == 'h' && s[2] == 'i') { - the_insn.reloc = RELOC_HI22; - s+=3; - } else if (c == 'l' && s[2] == 'o') { - the_insn.reloc = RELOC_LO10; - s+=3; - } else - break; - } - /* Note that if the getExpression() fails, we will still have - created U entries in the symbol table for the 'symbols' - in the input string. Try not to create U symbols for - registers, etc. */ - { - /* This stuff checks to see if the expression ends - in +%reg If it does, it removes the register from - the expression, and re-sets 's' to point to the - right place */ - - char *s1; - - for(s1=s;*s1 && *s1!=','&& *s1!=']';s1++) - ; - - if(s1!=s && isdigit(s1[-1])) { - if(s1[-2]=='%' && s1[-3]=='+') { - s1-=3; - *s1='\0'; - (void)getExpression(s); - *s1='+'; - s=s1; - continue; - } else if(index("goli0123456789",s1[-2]) && s1[-3]=='%' && s1[-4]=='+') { - s1-=4; - *s1='\0'; - (void)getExpression(s); - *s1='+'; - s=s1; - continue; - } - } - } - (void)getExpression(s); - s = expr_end; - continue; - - case 'a': - if (*s++ == 'a') { - opcode |= ANNUL; - continue; - } - break; - - case 'A': /* alternate space */ - if (isdigit(*s)) { - long num; - - num=0; - while (isdigit(*s)) { - num= num*10 + *s-'0'; - ++s; - } - opcode |= num<<5; - continue; - } - break; - /* abort(); */ - - case 'p': - if (strncmp(s, "%psr", 4) == 0) { - s += 4; - continue; - } - break; - - case 'q': /* floating point queue */ - if (strncmp(s, "%fq", 3) == 0) { - s += 3; - continue; - } - break; - - case 'Q': /* coprocessor queue */ - if (strncmp(s, "%cq", 3) == 0) { - s += 3; - continue; - } - break; - - case 'S': - if (strcmp(str, "set") == 0) { - special_case = SPECIAL_CASE_SET; - continue; - } - break; - - case 't': - if (strncmp(s, "%tbr", 4) != 0) - break; - s += 4; - continue; - - case 'w': - if (strncmp(s, "%wim", 4) != 0) - break; - s += 4; - continue; - - case 'y': - if (strncmp(s, "%y", 2) != 0) - break; - s += 2; - continue; - - default: - abort(); - } - break; - } - error: - if (match == FALSE) - { - /* Args don't match. */ - if (&insn[1] - sparc_opcodes < NUMOPCODES - && !strcmp(insn->name, insn[1].name)) - { - ++insn; - s = argsStart; - continue; - } - else - { - as_warn("Illegal operands"); - return; - } - } - break; - } - - the_insn.opcode = opcode; - return; -} - -static int -getExpression(str) - char *str; -{ - char *save_in; - segT seg; - - save_in = input_line_pointer; - input_line_pointer = str; - switch (seg = expression(&the_insn.exp)) { - - case SEG_ABSOLUTE: - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_UNKNOWN: - case SEG_DIFFERENCE: - case SEG_BIG: - case SEG_NONE: - break; - - default: - the_insn.error = "bad segment"; - expr_end = input_line_pointer; - input_line_pointer=save_in; - return 1; - } - expr_end = input_line_pointer; - input_line_pointer = save_in; - return 0; -} - - -/* - This is identical to the md_atof in m68k.c. I think this is right, - but I'm not sure. - - Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. - */ - -/* Equal to MAX_PRECISION in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -char * -md_atof(type,litP,sizeP) - char type; - char *litP; - int *sizeP; -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - char *atof_ieee(); - - switch(type) { - - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; - - case 'p': - case 'P': - prec = 6; - break; - - default: - *sizeP=0; - return "Bad call to MD_ATOF()"; - } - t=atof_ieee(input_line_pointer,type,words); - if(t) - input_line_pointer=t; - *sizeP=prec * sizeof(LITTLENUM_TYPE); - for(wordP=words;prec--;) { - md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE)); - litP+=sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ -} - -/* - * Write out big-endian. - */ -void -md_number_to_chars(buf,val,n) - char *buf; - long val; - int n; -{ - - switch(n) { - - case 4: - *buf++ = val >> 24; - *buf++ = val >> 16; - case 2: - *buf++ = val >> 8; - case 1: - *buf = val; - break; - - default: - abort(); - } - return; -} - -void -md_number_to_imm(buf,val,n, fixP, seg_type) - char *buf; - long val; - int n; - fixS *fixP; - int seg_type; -{ - /* if (seg_type != N_TEXT || fixP->fx_r_type == NO_RELOC) { */ - if ( (seg_type != N_TEXT && fixP->fx_r_type > RELOC_DISP32 ) - || fixP->fx_r_type == NO_RELOC) { - /* should never get here for current relocs ... */ - - switch (n) { - case 1: - *buf = val; - break; - case 2: - *buf++ = (val>>8); - *buf = val; - break; - case 4: - *buf++ = (val>>24); - *buf++ = (val>>16); - *buf++ = (val>>8); - *buf = val; - break; - default: - abort(); - } - return; - } - - assert(n == 4); - assert(fixP->fx_r_type < NO_RELOC); - - /* - * This is a hack. There should be a better way to - * handle this. - */ - if (fixP->fx_r_type == RELOC_WDISP30 && fixP->fx_addsy) { - val += fixP->fx_where + fixP->fx_frag->fr_address; - } - - switch (fixP->fx_r_type) { - - case RELOC_32: - buf[0] = 0; /* val >> 24; */ - buf[1] = 0; /* val >> 16; */ - buf[2] = 0; /* val >> 8; */ - buf[3] = 0; /* val; */ - break; - -#if 0 - case RELOC_8: /* These don't seem to ever be needed. */ - case RELOC_16: - case RELOC_DISP8: - case RELOC_DISP16: - case RELOC_DISP32: -#endif - case RELOC_WDISP30: - val = (val >>= 2) + 1; - buf[0] |= (val >> 24) & 0x3f; - buf[1]= (val >> 16); - buf[2] = val >> 8; - buf[3] = val; - break; - - case RELOC_HI22: - if(!fixP->fx_addsy) { - buf[1] |= (val >> 26) & 0x3f; - buf[2] = val >> 18; - buf[3] = val >> 10; - } else { - buf[2]=0; - buf[3]=0; - } - break; -#if 0 - case RELOC_22: - case RELOC_13: -#endif - case RELOC_LO10: - if(!fixP->fx_addsy) { - buf[2] |= (val >> 8) & 0x03; - buf[3] = val; - } else - buf[3]=0; - break; -#if 0 - case RELOC_SFA_BASE: - case RELOC_SFA_OFF13: - case RELOC_BASE10: -#endif - case RELOC_BASE13: - buf[2] |= (val >> 8) & 0x1f; - buf[3] = val; - break; - - case RELOC_WDISP22: - val = (val >>= 2) + 1; - /* FALLTHROUGH */ - case RELOC_BASE22: - buf[1] |= (val >> 16) & 0x3f; - buf[2] = val >> 8; - buf[3] = val; - break; - -#if 0 - case RELOC_PC10: - case RELOC_PC22: - case RELOC_JMP_TBL: - case RELOC_SEGOFF16: - case RELOC_GLOB_DAT: - case RELOC_JMP_SLOT: - case RELOC_RELATIVE: -#endif - - case NO_RELOC: - default: - as_warn("bad relocation type: 0x%02x", fixP->fx_r_type); - break; - } - return; -} - -/* should never be called for sparc */ -void -md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, to_addr; -{ - fprintf(stderr, "sparc_create_short_jmp\n"); - abort(); -} - -/* should never be called for sparc */ -void -md_number_to_disp(buf,val,n) - char *buf; - long val; -{ - fprintf(stderr, "md_number_to_disp\n"); - abort(); -} - -/* should never be called for sparc */ -void -md_number_to_field(buf,val,fix) - char *buf; - long val; - void *fix; -{ - fprintf(stderr, "sparc_number_to_field\n"); - abort(); -} - -/* the bit-field entries in the relocation_info struct plays hell - with the byte-order problems of cross-assembly. So as a hack, - I added this mach. dependent ri twiddler. Ugly, but it gets - you there. -KWK */ -/* on sparc: first 4 bytes are normal unsigned long address, next three - bytes are index, most sig. byte first. Byte 7 is broken up with - bit 7 as external, bits 6 & 5 unused, and the lower - five bits as relocation type. Next 4 bytes are long int addend. */ -/* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com */ -void -md_ri_to_chars(ri_p, ri) - struct reloc_info_sparc *ri_p, ri; -{ - unsigned char the_bytes[sizeof(*ri_p)]; - - /* this is easy */ - md_number_to_chars(the_bytes, ri.r_address, sizeof(ri.r_address)); - /* now the fun stuff */ - the_bytes[4] = (ri.r_index >> 16) & 0x0ff; - the_bytes[5] = (ri.r_index >> 8) & 0x0ff; - the_bytes[6] = ri.r_index & 0x0ff; - the_bytes[7] = ((ri.r_extern << 7) & 0x80) | (0 & 0x60) | (ri.r_type & 0x1F); - /* Also easy */ - md_number_to_chars(&the_bytes[8], ri.r_addend, sizeof(ri.r_addend)); - /* now put it back where you found it, Junior... */ - bcopy (the_bytes, (char *)ri_p, sizeof(*ri_p)); -} - -/* should never be called for sparc */ -void -md_convert_frag(fragP) - register fragS *fragP; -{ - fprintf(stderr, "sparc_convert_frag\n"); - abort(); -} - -/* should never be called for sparc */ -void -md_create_long_jump(ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, - to_addr; - fragS *frag; - symbolS *to_symbol; -{ - fprintf(stderr, "sparc_create_long_jump\n"); - abort(); -} - -/* should never be called for sparc */ -int -md_estimate_size_before_relax(fragP, segtype) - register fragS *fragP; -{ - fprintf(stderr, "sparc_estimate_size_before_relax\n"); - abort(); - return 0; -} - -#if 0 -/* for debugging only */ -static void -print_insn(insn) - struct sparc_it *insn; -{ - char *Reloc[] = { - "RELOC_8", - "RELOC_16", - "RELOC_32", - "RELOC_DISP8", - "RELOC_DISP16", - "RELOC_DISP32", - "RELOC_WDISP30", - "RELOC_WDISP22", - "RELOC_HI22", - "RELOC_22", - "RELOC_13", - "RELOC_LO10", - "RELOC_SFA_BASE", - "RELOC_SFA_OFF13", - "RELOC_BASE10", - "RELOC_BASE13", - "RELOC_BASE22", - "RELOC_PC10", - "RELOC_PC22", - "RELOC_JMP_TBL", - "RELOC_SEGOFF16", - "RELOC_GLOB_DAT", - "RELOC_JMP_SLOT", - "RELOC_RELATIVE", - "NO_RELOC" - }; - - if (insn->error) { - fprintf(stderr, "ERROR: %s\n"); - } - fprintf(stderr, "opcode=0x%08x\n", insn->opcode); - fprintf(stderr, "reloc = %s\n", Reloc[insn->reloc]); - fprintf(stderr, "exp = {\n"); - fprintf(stderr, "\t\tX_add_symbol = %s\n", - insn->exp.X_add_symbol ? - (insn->exp.X_add_symbol->sy_name ? - insn->exp.X_add_symbol->sy_name : "???") : "0"); - fprintf(stderr, "\t\tX_sub_symbol = %s\n", - insn->exp.X_subtract_symbol ? - (insn->exp.X_subtract_symbol->sy_name ? - insn->exp.X_subtract_symbol->sy_name : "???") : "0"); - fprintf(stderr, "\t\tX_add_number = %d\n", - insn->exp.X_add_number); - fprintf(stderr, "}\n"); - return; -} -#endif - -/* - * Sparc relocations are completely different, so it needs - * this machine dependent routine to emit them. - */ -void -emit_relocations(fixP, segment_address_in_file) - register fixS *fixP; - relax_addressT segment_address_in_file; -{ - struct reloc_info_sparc ri; - register symbolS *symbolP; - extern char *next_object_file_charP; - long add_number; - - bzero((char *) &ri, sizeof(ri)); - for (; fixP; fixP = fixP->fx_next) { - - if (fixP->fx_r_type >= NO_RELOC) { - fprintf(stderr, "fixP->fx_r_type = %d\n", fixP->fx_r_type); - abort(); - } - - if ((symbolP = fixP->fx_addsy) != NULL) { - ri.r_address = fixP->fx_frag->fr_address + - fixP->fx_where - segment_address_in_file; - if ((symbolP->sy_type & N_TYPE) == N_UNDF) { - ri.r_extern = 1; - ri.r_index = symbolP->sy_number; - } else { - ri.r_extern = 0; - ri.r_index = symbolP->sy_type & N_TYPE; - } - if (symbolP && symbolP->sy_frag) { - ri.r_addend = symbolP->sy_frag->fr_address; - } - ri.r_type = fixP->fx_r_type; - if (fixP->fx_pcrel) { -/* ri.r_addend -= fixP->fx_where; */ - ri.r_addend -= ri.r_address; - } else { - ri.r_addend = fixP->fx_addnumber; - } - -/* md_ri_to_chars((char *) &ri, ri); */ - append(&next_object_file_charP, (char *)& ri, sizeof(ri)); - } - } - return; -} - -int -md_parse_option(argP,cntP,vecP) - char **argP; - int *cntP; - char ***vecP; -{ - return 1; -} - diff --git a/gnu/usr.bin/gas/config/sparc.h b/gnu/usr.bin/gas/config/sparc.h deleted file mode 100644 index e61122772800..000000000000 --- a/gnu/usr.bin/gas/config/sparc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* sparc.h -- Header file for the SPARC - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: sparc.h,v 1.2 1993/08/02 17:27:25 mycroft Exp $ -*/ - -/* - * The following enum and struct were borrowed from - * sunOS /usr/include/sun4/a.out.h - * - */ - -enum reloc_type -{ - RELOC_8, RELOC_16, RELOC_32, RELOC_DISP8, - RELOC_DISP16, RELOC_DISP32, RELOC_WDISP30, RELOC_WDISP22, - RELOC_HI22, RELOC_22, RELOC_13, RELOC_LO10, - RELOC_SFA_BASE, RELOC_SFA_OFF13, RELOC_BASE10, RELOC_BASE13, - RELOC_BASE22, RELOC_PC10, RELOC_PC22, RELOC_JMP_TBL, - RELOC_SEGOFF16, RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE, - - NO_RELOC -}; - -struct reloc_info_sparc -{ - unsigned long int r_address; -/* - * Using bit fields here is a bad idea because the order is not portable. :-( - */ - unsigned int r_index : 24; - unsigned int r_extern : 1; - unsigned int unused : 2; - enum reloc_type r_type : 5; - long int r_addend; -}; - -#define relocation_info reloc_info_sparc - diff --git a/gnu/usr.bin/gas/config/vax-opcode.h b/gnu/usr.bin/gas/config/vax-opcode.h deleted file mode 100644 index fc1f84ccbbac..000000000000 --- a/gnu/usr.bin/gas/config/vax-opcode.h +++ /dev/null @@ -1,385 +0,0 @@ -/* Vax opcde list. - Copyright (C) 1989, Free Software Foundation, Inc. - -This file is part of GDB and GAS. - -GDB and GAS are 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. - -GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: vax-opcode.h,v 1.2 1993/08/02 17:27:29 mycroft Exp $ -*/ - -#ifndef vax_opcodeT -#define vax_opcodeT int -#endif /* no vax_opcodeT */ - -struct vot_wot /* vax opcode table: wot to do with this */ - /* particular opcode */ -{ - char * args; /* how to compile said opcode */ - vax_opcodeT code; /* op-code (may be > 8 bits!) */ -}; - -struct vot /* vax opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct vot_wot detail; /* rest of opcode table [datum] */ -}; - -#define vot_how args -#define vot_code code -#define vot_detail detail -#define vot_name name - -static const struct vot -votstrs[] = -{ -{ "halt", {"", 0x00 } }, -{ "nop", {"", 0x01 } }, -{ "rei", {"", 0x02 } }, -{ "bpt", {"", 0x03 } }, -{ "ret", {"", 0x04 } }, -{ "rsb", {"", 0x05 } }, -{ "ldpctx", {"", 0x06 } }, -{ "svpctx", {"", 0x07 } }, -{ "cvtps", {"rwabrwab", 0x08 } }, -{ "cvtsp", {"rwabrwab", 0x09 } }, -{ "index", {"rlrlrlrlrlwl", 0x0a } }, -{ "crc", {"abrlrwab", 0x0b } }, -{ "prober", {"rbrwab", 0x0c } }, -{ "probew", {"rbrwab", 0x0d } }, -{ "insque", {"abab", 0x0e } }, -{ "remque", {"abwl", 0x0f } }, -{ "bsbb", {"bb", 0x10 } }, -{ "brb", {"bb", 0x11 } }, -{ "bneq", {"bb", 0x12 } }, -{ "bnequ", {"bb", 0x12 } }, -{ "beql", {"bb", 0x13 } }, -{ "beqlu", {"bb", 0x13 } }, -{ "bgtr", {"bb", 0x14 } }, -{ "bleq", {"bb", 0x15 } }, -{ "jsb", {"ab", 0x16 } }, -{ "jmp", {"ab", 0x17 } }, -{ "bgeq", {"bb", 0x18 } }, -{ "blss", {"bb", 0x19 } }, -{ "bgtru", {"bb", 0x1a } }, -{ "blequ", {"bb", 0x1b } }, -{ "bvc", {"bb", 0x1c } }, -{ "bvs", {"bb", 0x1d } }, -{ "bcc", {"bb", 0x1e } }, -{ "bgequ", {"bb", 0x1e } }, -{ "blssu", {"bb", 0x1f } }, -{ "bcs", {"bb", 0x1f } }, -{ "addp4", {"rwabrwab", 0x20 } }, -{ "addp6", {"rwabrwabrwab", 0x21 } }, -{ "subp4", {"rwabrwab", 0x22 } }, -{ "subp6", {"rwabrwabrwab", 0x23 } }, -{ "cvtpt", {"rwababrwab", 0x24 } }, -{ "mulp", {"rwabrwabrwab", 0x25 } }, -{ "cvttp", {"rwababrwab", 0x26 } }, -{ "divp", {"rwabrwabrwab", 0x27 } }, -{ "movc3", {"rwabab", 0x28 } }, -{ "cmpc3", {"rwabab", 0x29 } }, -{ "scanc", {"rwababrb", 0x2a } }, -{ "spanc", {"rwababrb", 0x2b } }, -{ "movc5", {"rwabrbrwab", 0x2c } }, -{ "cmpc5", {"rwabrbrwab", 0x2d } }, -{ "movtc", {"rwabrbabrwab", 0x2e } }, -{ "movtuc", {"rwabrbabrwab", 0x2f } }, -{ "bsbw", {"bw", 0x30 } }, -{ "brw", {"bw", 0x31 } }, -{ "cvtwl", {"rwwl", 0x32 } }, -{ "cvtwb", {"rwwb", 0x33 } }, -{ "movp", {"rwabab", 0x34 } }, -{ "cmpp3", {"rwabab", 0x35 } }, -{ "cvtpl", {"rwabwl", 0x36 } }, -{ "cmpp4", {"rwabrwab", 0x37 } }, -{ "editpc", {"rwababab", 0x38 } }, -{ "matchc", {"rwabrwab", 0x39 } }, -{ "locc", {"rbrwab", 0x3a } }, -{ "skpc", {"rbrwab", 0x3b } }, -{ "movzwl", {"rwwl", 0x3c } }, -{ "acbw", {"rwrwmwbw", 0x3d } }, -{ "movaw", {"awwl", 0x3e } }, -{ "pushaw", {"aw", 0x3f } }, -{ "addf2", {"rfmf", 0x40 } }, -{ "addf3", {"rfrfwf", 0x41 } }, -{ "subf2", {"rfmf", 0x42 } }, -{ "subf3", {"rfrfwf", 0x43 } }, -{ "mulf2", {"rfmf", 0x44 } }, -{ "mulf3", {"rfrfwf", 0x45 } }, -{ "divf2", {"rfmf", 0x46 } }, -{ "divf3", {"rfrfwf", 0x47 } }, -{ "cvtfb", {"rfwb", 0x48 } }, -{ "cvtfw", {"rfww", 0x49 } }, -{ "cvtfl", {"rfwl", 0x4a } }, -{ "cvtrfl", {"rfwl", 0x4b } }, -{ "cvtbf", {"rbwf", 0x4c } }, -{ "cvtwf", {"rwwf", 0x4d } }, -{ "cvtlf", {"rlwf", 0x4e } }, -{ "acbf", {"rfrfmfbw", 0x4f } }, -{ "movf", {"rfwf", 0x50 } }, -{ "cmpf", {"rfrf", 0x51 } }, -{ "mnegf", {"rfwf", 0x52 } }, -{ "tstf", {"rf", 0x53 } }, -{ "emodf", {"rfrbrfwlwf", 0x54 } }, -{ "polyf", {"rfrwab", 0x55 } }, -{ "cvtfd", {"rfwd", 0x56 } }, - /* opcode 57 is not defined yet */ -{ "adawi", {"rwmw", 0x58 } }, - /* opcode 59 is not defined yet */ - /* opcode 5a is not defined yet */ - /* opcode 5b is not defined yet */ -{ "insqhi", {"abaq", 0x5c } }, -{ "insqti", {"abaq", 0x5d } }, -{ "remqhi", {"aqwl", 0x5e } }, -{ "remqti", {"aqwl", 0x5f } }, -{ "addd2", {"rdmd", 0x60 } }, -{ "addd3", {"rdrdwd", 0x61 } }, -{ "subd2", {"rdmd", 0x62 } }, -{ "subd3", {"rdrdwd", 0x63 } }, -{ "muld2", {"rdmd", 0x64 } }, -{ "muld3", {"rdrdwd", 0x65 } }, -{ "divd2", {"rdmd", 0x66 } }, -{ "divd3", {"rdrdwd", 0x67 } }, -{ "cvtdb", {"rdwb", 0x68 } }, -{ "cvtdw", {"rdww", 0x69 } }, -{ "cvtdl", {"rdwl", 0x6a } }, -{ "cvtrdl", {"rdwl", 0x6b } }, -{ "cvtbd", {"rbwd", 0x6c } }, -{ "cvtwd", {"rwwd", 0x6d } }, -{ "cvtld", {"rlwd", 0x6e } }, -{ "acbd", {"rdrdmdbw", 0x6f } }, -{ "movd", {"rdwd", 0x70 } }, -{ "cmpd", {"rdrd", 0x71 } }, -{ "mnegd", {"rdwd", 0x72 } }, -{ "tstd", {"rd", 0x73 } }, -{ "emodd", {"rdrbrdwlwd", 0x74 } }, -{ "polyd", {"rdrwab", 0x75 } }, -{ "cvtdf", {"rdwf", 0x76 } }, - /* opcode 77 is not defined yet */ -{ "ashl", {"rbrlwl", 0x78 } }, -{ "ashq", {"rbrqwq", 0x79 } }, -{ "emul", {"rlrlrlwq", 0x7a } }, -{ "ediv", {"rlrqwlwl", 0x7b } }, -{ "clrd", {"wd", 0x7c } }, -{ "clrg", {"wg", 0x7c } }, -{ "clrq", {"wd", 0x7c } }, -{ "movq", {"rqwq", 0x7d } }, -{ "movaq", {"aqwl", 0x7e } }, -{ "movad", {"adwl", 0x7e } }, -{ "pushaq", {"aq", 0x7f } }, -{ "pushad", {"ad", 0x7f } }, -{ "addb2", {"rbmb", 0x80 } }, -{ "addb3", {"rbrbwb", 0x81 } }, -{ "subb2", {"rbmb", 0x82 } }, -{ "subb3", {"rbrbwb", 0x83 } }, -{ "mulb2", {"rbmb", 0x84 } }, -{ "mulb3", {"rbrbwb", 0x85 } }, -{ "divb2", {"rbmb", 0x86 } }, -{ "divb3", {"rbrbwb", 0x87 } }, -{ "bisb2", {"rbmb", 0x88 } }, -{ "bisb3", {"rbrbwb", 0x89 } }, -{ "bicb2", {"rbmb", 0x8a } }, -{ "bicb3", {"rbrbwb", 0x8b } }, -{ "xorb2", {"rbmb", 0x8c } }, -{ "xorb3", {"rbrbwb", 0x8d } }, -{ "mnegb", {"rbwb", 0x8e } }, -{ "caseb", {"rbrbrb", 0x8f } }, -{ "movb", {"rbwb", 0x90 } }, -{ "cmpb", {"rbrb", 0x91 } }, -{ "mcomb", {"rbwb", 0x92 } }, -{ "bitb", {"rbrb", 0x93 } }, -{ "clrb", {"wb", 0x94 } }, -{ "tstb", {"rb", 0x95 } }, -{ "incb", {"mb", 0x96 } }, -{ "decb", {"mb", 0x97 } }, -{ "cvtbl", {"rbwl", 0x98 } }, -{ "cvtbw", {"rbww", 0x99 } }, -{ "movzbl", {"rbwl", 0x9a } }, -{ "movzbw", {"rbww", 0x9b } }, -{ "rotl", {"rbrlwl", 0x9c } }, -{ "acbb", {"rbrbmbbw", 0x9d } }, -{ "movab", {"abwl", 0x9e } }, -{ "pushab", {"ab", 0x9f } }, -{ "addw2", {"rwmw", 0xa0 } }, -{ "addw3", {"rwrwww", 0xa1 } }, -{ "subw2", {"rwmw", 0xa2 } }, -{ "subw3", {"rwrwww", 0xa3 } }, -{ "mulw2", {"rwmw", 0xa4 } }, -{ "mulw3", {"rwrwww", 0xa5 } }, -{ "divw2", {"rwmw", 0xa6 } }, -{ "divw3", {"rwrwww", 0xa7 } }, -{ "bisw2", {"rwmw", 0xa8 } }, -{ "bisw3", {"rwrwww", 0xa9 } }, -{ "bicw2", {"rwmw", 0xaa } }, -{ "bicw3", {"rwrwww", 0xab } }, -{ "xorw2", {"rwmw", 0xac } }, -{ "xorw3", {"rwrwww", 0xad } }, -{ "mnegw", {"rwww", 0xae } }, -{ "casew", {"rwrwrw", 0xaf } }, -{ "movw", {"rwww", 0xb0 } }, -{ "cmpw", {"rwrw", 0xb1 } }, -{ "mcomw", {"rwww", 0xb2 } }, -{ "bitw", {"rwrw", 0xb3 } }, -{ "clrw", {"ww", 0xb4 } }, -{ "tstw", {"rw", 0xb5 } }, -{ "incw", {"mw", 0xb6 } }, -{ "decw", {"mw", 0xb7 } }, -{ "bispsw", {"rw", 0xb8 } }, -{ "bicpsw", {"rw", 0xb9 } }, -{ "popr", {"rw", 0xba } }, -{ "pushr", {"rw", 0xbb } }, -{ "chmk", {"rw", 0xbc } }, -{ "chme", {"rw", 0xbd } }, -{ "chms", {"rw", 0xbe } }, -{ "chmu", {"rw", 0xbf } }, -{ "addl2", {"rlml", 0xc0 } }, -{ "addl3", {"rlrlwl", 0xc1 } }, -{ "subl2", {"rlml", 0xc2 } }, -{ "subl3", {"rlrlwl", 0xc3 } }, -{ "mull2", {"rlml", 0xc4 } }, -{ "mull3", {"rlrlwl", 0xc5 } }, -{ "divl2", {"rlml", 0xc6 } }, -{ "divl3", {"rlrlwl", 0xc7 } }, -{ "bisl2", {"rlml", 0xc8 } }, -{ "bisl3", {"rlrlwl", 0xc9 } }, -{ "bicl2", {"rlml", 0xca } }, -{ "bicl3", {"rlrlwl", 0xcb } }, -{ "xorl2", {"rlml", 0xcc } }, -{ "xorl3", {"rlrlwl", 0xcd } }, -{ "mnegl", {"rlwl", 0xce } }, -{ "casel", {"rlrlrl", 0xcf } }, -{ "movl", {"rlwl", 0xd0 } }, -{ "cmpl", {"rlrl", 0xd1 } }, -{ "mcoml", {"rlwl", 0xd2 } }, -{ "bitl", {"rlrl", 0xd3 } }, -{ "clrf", {"wf", 0xd4 } }, -{ "clrl", {"wl", 0xd4 } }, -{ "tstl", {"rl", 0xd5 } }, -{ "incl", {"ml", 0xd6 } }, -{ "decl", {"ml", 0xd7 } }, -{ "adwc", {"rlml", 0xd8 } }, -{ "sbwc", {"rlml", 0xd9 } }, -{ "mtpr", {"rlrl", 0xda } }, -{ "mfpr", {"rlwl", 0xdb } }, -{ "movpsl", {"wl", 0xdc } }, -{ "pushl", {"rl", 0xdd } }, -{ "moval", {"alwl", 0xde } }, -{ "movaf", {"afwl", 0xde } }, -{ "pushal", {"al", 0xdf } }, -{ "pushaf", {"af", 0xdf } }, -{ "bbs", {"rlabbb", 0xe0 } }, -{ "bbc", {"rlabbb", 0xe1 } }, -{ "bbss", {"rlabbb", 0xe2 } }, -{ "bbcs", {"rlabbb", 0xe3 } }, -{ "bbsc", {"rlabbb", 0xe4 } }, -{ "bbcc", {"rlabbb", 0xe5 } }, -{ "bbssi", {"rlabbb", 0xe6 } }, -{ "bbcci", {"rlabbb", 0xe7 } }, -{ "blbs", {"rlbb", 0xe8 } }, -{ "blbc", {"rlbb", 0xe9 } }, -{ "ffs", {"rlrbvbwl", 0xea } }, -{ "ffc", {"rlrbvbwl", 0xeb } }, -{ "cmpv", {"rlrbvbrl", 0xec } }, -{ "cmpzv", {"rlrbvbrl", 0xed } }, -{ "extv", {"rlrbvbwl", 0xee } }, -{ "extzv", {"rlrbvbwl", 0xef } }, -{ "insv", {"rlrlrbvb", 0xf0 } }, -{ "acbl", {"rlrlmlbw", 0xf1 } }, -{ "aoblss", {"rlmlbb", 0xf2 } }, -{ "aobleq", {"rlmlbb", 0xf3 } }, -{ "sobgeq", {"mlbb", 0xf4 } }, -{ "sobgtr", {"mlbb", 0xf5 } }, -{ "cvtlb", {"rlwb", 0xf6 } }, -{ "cvtlw", {"rlww", 0xf7 } }, -{ "ashp", {"rbrwabrbrwab", 0xf8 } }, -{ "cvtlp", {"rlrwab", 0xf9 } }, -{ "callg", {"abab", 0xfa } }, -{ "calls", {"rlab", 0xfb } }, -{ "xfc", {"", 0xfc } }, - /* undefined opcodes here */ -{ "cvtdh", {"rdwh", 0x32fd } }, -{ "cvtgf", {"rgwh", 0x33fd } }, -{ "addg2", {"rgmg", 0x40fd } }, -{ "addg3", {"rgrgwg", 0x41fd } }, -{ "subg2", {"rgmg", 0x42fd } }, -{ "subg3", {"rgrgwg", 0x43fd } }, -{ "mulg2", {"rgmg", 0x44fd } }, -{ "mulg3", {"rgrgwg", 0x45fd } }, -{ "divg2", {"rgmg", 0x46fd } }, -{ "divg3", {"rgrgwg", 0x47fd } }, -{ "cvtgb", {"rgwb", 0x48fd } }, -{ "cvtgw", {"rgww", 0x49fd } }, -{ "cvtgl", {"rgwl", 0x4afd } }, -{ "cvtrgl", {"rgwl", 0x4bfd } }, -{ "cvtbg", {"rbwg", 0x4cfd } }, -{ "cvtwg", {"rwwg", 0x4dfd } }, -{ "cvtlg", {"rlwg", 0x4efd } }, -{ "acbg", {"rgrgmgbw", 0x4ffd } }, -{ "movg", {"rgwg", 0x50fd } }, -{ "cmpg", {"rgrg", 0x51fd } }, -{ "mnegg", {"rgwg", 0x52fd } }, -{ "tstg", {"rg", 0x53fd } }, -{ "emodg", {"rgrwrgwlwg", 0x54fd } }, -{ "polyg", {"rgrwab", 0x55fd } }, -{ "cvtgh", {"rgwh", 0x56fd } }, - /* undefined opcodes here */ -{ "addh2", {"rhmh", 0x60fd } }, -{ "addh3", {"rhrhwh", 0x61fd } }, -{ "subh2", {"rhmh", 0x62fd } }, -{ "subh3", {"rhrhwh", 0x63fd } }, -{ "mulh2", {"rhmh", 0x64fd } }, -{ "mulh3", {"rhrhwh", 0x65fd } }, -{ "divh2", {"rhmh", 0x66fd } }, -{ "divh3", {"rhrhwh", 0x67fd } }, -{ "cvthb", {"rhwb", 0x68fd } }, -{ "cvthw", {"rhww", 0x69fd } }, -{ "cvthl", {"rhwl", 0x6afd } }, -{ "cvtrhl", {"rhwl", 0x6bfd } }, -{ "cvtbh", {"rbwh", 0x6cfd } }, -{ "cvtwh", {"rwwh", 0x6dfd } }, -{ "cvtlh", {"rlwh", 0x6efd } }, -{ "acbh", {"rhrhmhbw", 0x6ffd } }, -{ "movh", {"rhwh", 0x70fd } }, -{ "cmph", {"rhrh", 0x71fd } }, -{ "mnegh", {"rhwh", 0x72fd } }, -{ "tsth", {"rh", 0x73fd } }, -{ "emodh", {"rhrwrhwlwh", 0x74fd } }, -{ "polyh", {"rhrwab", 0x75fd } }, -{ "cvthg", {"rhwg", 0x76fd } }, - /* undefined opcodes here */ -{ "clrh", {"wh", 0x7cfd } }, -{ "clro", {"wo", 0x7cfd } }, -{ "movo", {"rowo", 0x7dfd } }, -{ "movah", {"ahwl", 0x7efd } }, -{ "movao", {"aowl", 0x7efd } }, -{ "pushah", {"ah", 0x7ffd } }, -{ "pushao", {"ao", 0x7ffd } }, - /* undefined opcodes here */ -{ "cvtfh", {"rfwh", 0x98fd } }, -{ "cvtfg", {"rfwg", 0x99fd } }, - /* undefined opcodes here */ -{ "cvthf", {"rhwf", 0xf6fd } }, -{ "cvthd", {"rhwd", 0xf7fd } }, - /* undefined opcodes here */ -{ "bugl", {"rl", 0xfdff } }, -{ "bugw", {"rw", 0xfeff } }, - /* undefined opcodes here */ - -{ "" , "" } /* empty is end sentinel */ - -}; /* votstrs */ - -/* end: vax.opcode.h */ diff --git a/gnu/usr.bin/gas/config/vax.c b/gnu/usr.bin/gas/config/vax.c deleted file mode 100644 index f478d372273c..000000000000 --- a/gnu/usr.bin/gas/config/vax.c +++ /dev/null @@ -1,3368 +0,0 @@ -/* vax.c - vax-specific - - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: vax.c,v 1.2 1993/08/02 17:27:32 mycroft Exp $"; -#endif /* not lint */ - -/* JF I moved almost all the vax specific stuff into this one file 'cuz RMS - seems to think its a good idea. I hope I managed to get all the VAX-isms */ - - -#include "as.h" -#include "read.h" -#include "flonum.h" -#include "vax-inst.h" -#include "md.h" -#include "obstack.h" /* For FRAG_APPEND_1_CHAR macro in "frags.h" */ -#include "frags.h" -#include "struc-symbol.h" -#include "expr.h" -#include "symbols.h" - -/* This is the number to put at the beginning of the a.out file */ -long omagic = OMAGIC; - -/* These chars start a comment anywhere in a source file (except inside - another comment */ -const char comment_chars[] = "#"; - -/* These chars only start a comment at the beginning of a line. */ -/* Note that for the VAX the are the same as comment_chars above. */ -const char line_comment_chars[] = "#"; - -/* Chars that can be used to separate mant from exp in floating point nums */ -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* as in 0f123.456 */ -/* or 0H1.234E-12 (see exp chars above) */ -const char FLT_CHARS[] = "dDfFgGhH"; - -/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be - changed in read.c . Ideally it shouldn't have to know about it at all, - but nothing is ideal around here. - */ - -static expressionS /* Hold details of an operand expression */ - exp_of_operand[VIT_MAX_OPERANDS]; - -static struct vit - v; /* A vax instruction after decoding. */ - -LITTLENUM_TYPE big_operand_bits[VIT_MAX_OPERANDS][SIZE_OF_LARGE_NUMBER]; - /* Hold details of big operands. */ -FLONUM_TYPE float_operand[VIT_MAX_OPERANDS]; - /* Above is made to point into */ - /* big_operand_bits by md_begin(). */ - -/* - * For VAX, relative addresses of "just the right length" are easy. - * The branch displacement is always the last operand, even in - * synthetic instructions. - * For VAX, we encode the relax_substateTs (in e.g. fr_substate) as: - * - * 4 3 2 1 0 bit number - * ---/ /--+-------+-------+-------+-------+-------+ - * | what state ? | how long ? | - * ---/ /--+-------+-------+-------+-------+-------+ - * - * The "how long" bits are 00=byte, 01=word, 10=long. - * This is a Un*x convention. - * Not all lengths are legit for a given value of (what state). - * The "how long" refers merely to the displacement length. - * The address usually has some constant bytes in it as well. - * - -groups for VAX address relaxing. - -1. "foo" pc-relative. - length of byte, word, long - -2a. J where is a simple flag test. - length of byte, word, long. - VAX opcodes are: (Hex) - bneq/bnequ 12 - beql/beqlu 13 - bgtr 14 - bleq 15 - bgeq 18 - blss 19 - bgtru 1a - blequ 1b - bvc 1c - bvs 1d - bgequ/bcc 1e - blssu/bcs 1f - Always, you complement 0th bit to reverse condition. - Always, 1-byte opcode, then 1-byte displacement. - -2b. J where cond tests a memory bit. - length of byte, word, long. - Vax opcodes are: (Hex) - bbs e0 - bbc e1 - bbss e2 - bbcs e3 - bbsc e4 - bbcc e5 - bbssi e6 - bbcci e7 - Always, you complement 0th bit to reverse condition. - Always, 1-byte opcde, longword-address, byte-address, 1-byte-displacement - -2c. J where cond tests low-order memory bit - length of byte,word,long. - Vax opcodes are: (Hex) - blbs e8 - blbc e9 - Always, you complement 0th bit to reverse condition. - Always, 1-byte opcode, longword-address, 1-byte displacement. - -3. Jbs/Jbr. - length of byte,word,long. - Vax opcodes are: (Hex) - bsbb 10 - brb 11 - These are like (2) but there is no condition to reverse. - Always, 1 byte opcode, then displacement/absolute. - -4a. JacbX - length of word, long. - Vax opcodes are: (Hex) - acbw 3d - acbf 4f - acbd 6f - abcb 9d - acbl f1 - acbg 4ffd - acbh 6ffd - Always, we cannot reverse the sense of the branch; we have a word - displacement. - The double-byte op-codes don't hurt: we never want to modify the - opcode, so we don't care how many bytes are between the opcode and - the operand. - -4b. JXobXXX - length of long, long, byte. - Vax opcodes are: (Hex) - aoblss f2 - aobleq f3 - sobgeq f4 - sobgtr f5 - Always, we cannot reverse the sense of the branch; we have a byte - displacement. - -The only time we need to modify the opcode is for class 2 instructions. -After relax() we may complement the lowest order bit of such instruction -to reverse sense of branch. - -For class 2 instructions, we store context of "where is the opcode literal". -We can change an opcode's lowest order bit without breaking anything else. - -We sometimes store context in the operand literal. This way we can figure out -after relax() what the original addressing mode was. -*/ - - /* These displacements are relative to */ - /* the start address of the displacement. */ - /* The first letter is Byte, Word. */ - /* 2nd letter is Forward, Backward. */ -#define BF (1+ 127) -#define BB (1+-128) -#define WF (2+ 32767) -#define WB (2+-32768) - /* Dont need LF, LB because they always */ - /* reach. [They are coded as 0.] */ - - -#define C(a,b) ENCODE_RELAX(a,b) - /* This macro has no side-effects. */ -#define ENCODE_RELAX(what,length) (((what) << 2) + (length)) - -const relax_typeS -md_relax_table[] = -{ - { - 1, 1, 0, 0 - }, /* error sentinel 0,0 */ - { - 1, 1, 0, 0 - }, /* unused 0,1 */ - { - 1, 1, 0, 0 - }, /* unused 0,2 */ - { - 1, 1, 0, 0 - }, /* unused 0,3 */ - { - BF + 1, BB + 1, 2, C (1, 1) - }, /* B^"foo" 1,0 */ - { - WF + 1, WB + 1, 3, C (1, 2) - }, /* W^"foo" 1,1 */ - { - 0, 0, 5, 0 - }, /* L^"foo" 1,2 */ - { - 1, 1, 0, 0 - }, /* unused 1,3 */ - { - BF, BB, 1, C (2, 1) - }, /* b B^"foo" 2,0 */ - { - WF + 2, WB + 2, 4, C (2, 2) - }, /* br.+? brw X 2,1 */ - { - 0, 0, 7, 0 - }, /* br.+? jmp X 2,2 */ - { - 1, 1, 0, 0 - }, /* unused 2,3 */ - { - BF, BB, 1, C (3, 1) - }, /* brb B^foo 3,0 */ - { - WF, WB, 2, C (3, 2) - }, /* brw W^foo 3,1 */ - { - 0, 0, 5, 0 - }, /* Jmp L^foo 3,2 */ - { - 1, 1, 0, 0 - }, /* unused 3,3 */ - { - 1, 1, 0, 0 - }, /* unused 4,0 */ - { - WF, WB, 2, C (4, 2) - }, /* acb_ ^Wfoo 4,1 */ - { - 0, 0, 10, 0 - }, /* acb_,br,jmp L^foo4,2 */ - { - 1, 1, 0, 0 - }, /* unused 4,3 */ - { - BF, BB, 1, C (5, 1) - }, /* Xob___,,foo 5,0 */ - { - WF + 4, WB + 4, 6, C (5, 2) - }, /* Xob.+2,brb.+3,brw5,1 */ - { - 0, 0, 9, 0 - }, /* Xob.+2,brb.+6,jmp5,2 */ -}; - -#undef C -#undef BF -#undef BB -#undef WF -#undef WB - -void float_cons (); - -const pseudo_typeS md_pseudo_table[] = -{ - {"dfloat", float_cons, 'd'}, - {"ffloat", float_cons, 'f'}, - {"gfloat", float_cons, 'g'}, - {"hfloat", float_cons, 'h'}, - {0} -}; - -#define STATE_PC_RELATIVE (1) -#define STATE_CONDITIONAL_BRANCH (2) -#define STATE_ALWAYS_BRANCH (3) /* includes BSB... */ -#define STATE_COMPLEX_BRANCH (4) -#define STATE_COMPLEX_HOP (5) - -#define STATE_BYTE (0) -#define STATE_WORD (1) -#define STATE_LONG (2) -#define STATE_UNDF (3) /* Symbol undefined in pass1 */ - - -#define min(a, b) ((a) < (b) ? (a) : (b)) - - -void -md_begin () -{ - char *vip_begin (); - char *errtxt; - FLONUM_TYPE *fP; - int i; - - if (*(errtxt = vip_begin (TRUE, "$", "*", "`"))) - { - as_fatal ("VIP_BEGIN error:%s", errtxt); - } - - for (i = 0, fP = float_operand; - fP < float_operand + VIT_MAX_OPERANDS; - i++, fP++) - { - fP->low = &big_operand_bits[i][0]; - fP->high = &big_operand_bits[i][SIZE_OF_LARGE_NUMBER - 1]; - } -} - -void -md_end () -{ - vip_end (); -} - -void /* Knows about order of bytes in address. */ -md_number_to_chars (con, value, nbytes) - char con[]; /* Return 'nbytes' of chars here. */ - long int value; /* The value of the bits. */ - int nbytes; /* Number of bytes in the output. */ -{ - int n; - long v; - - n = nbytes; - v = value; - while (nbytes--) - { - *con++ = value; /* Lint wants & MASK_CHAR. */ - value >>= BITS_PER_CHAR; - } - /* XXX line number probably botched for this warning message. */ - if (value != 0 && value != -1) - as_warn ("Displacement (%ld) long for instruction field length (%d).", v, n); -} - -void /* Knows about order of bytes in address. */ -md_number_to_imm (con, value, nbytes) - char con[]; /* Return 'nbytes' of chars here. */ - long int value; /* The value of the bits. */ - int nbytes; /* Number of bytes in the output. */ -{ - int n; - long v; - - n = nbytes; - v = value; - while (nbytes--) - { - *con++ = value; /* Lint wants & MASK_CHAR. */ - value >>= BITS_PER_CHAR; - } - /* XXX line number probably botched for this warning message. */ - if (value != 0 && value != -1) - as_warn ("Displacement (%ld) too long for instruction field length (%d).", v, n); -} - -void /* Knows about order of bytes in address. */ -md_number_to_disp (con, value, nbytes) - char con[]; /* Return 'nbytes' of chars here. */ - long int value; /* The value of the bits. */ - int nbytes; /* Number of bytes in the output. */ -{ - abort (); - while (nbytes--) - { - *con++ = value; /* Lint wants & MASK_CHAR. */ - value >>= BITS_PER_CHAR; - } - /* XXX line number probably botched for this warning message. */ - if (value != 0 && value != -1) - as_warn ("Displacement too long for instruction field length."); -} - -void /* Knows about order of bytes in address. */ -md_number_to_field (con, value, nbytes) - char con[]; /* Return 'nbytes' of chars here. */ - long int value; /* The value of the bits. */ - int nbytes; /* Number of bytes in the output. */ -{ - abort (); - while (nbytes--) - { - *con++ = value; /* Lint wants & MASK_CHAR. */ - value >>= BITS_PER_CHAR; - } - /* XXX line number probably botched for this warning message. */ - if (value != 0 && value != -1) - as_warn ("Displacement too long for instruction field length."); -} - -long int /* Knows about the byte order in a word. */ -md_chars_to_number (con, nbytes) - unsigned char con[]; /* Low order byte 1st. */ - int nbytes; /* Number of bytes in the input. */ -{ - long int retval; - for (retval = 0, con += nbytes - 1; nbytes--; con--) - { - retval <<= BITS_PER_CHAR; - retval |= *con; - } - return retval; -} - -/* vax:md_assemble() emit frags for 1 instruction */ - -void -md_assemble (instruction_string) - char *instruction_string; /* A string: assemble 1 instruction. */ -{ - char *p; - register struct vop *operandP;/* An operand. Scans all operands. */ - char *save_input_line_pointer; - char c_save; /* What used to live after an expression. */ - struct frag *fragP; /* Fragment of code we just made. */ - register int goofed; /* TRUE: instruction_string bad for all passes. */ - register struct vop *end_operandP; /* -> slot just after last operand */ - /* Limit of the for (each operand). */ - register expressionS *expP; /* -> expression values for this operand */ - - /* These refer to an instruction operand expression. */ - segT to_seg; /* Target segment of the address. */ - register valueT this_add_number; - register struct symbol *this_add_symbol; /* +ve (minuend) symbol. */ - register struct symbol *this_subtract_symbol; /* -ve(subtrahend) symbol. */ - - long int opcode_as_number; /* As a number. */ - char *opcode_as_chars; /* Least significant byte 1st. */ - /* As an array of characters. */ - char *opcode_low_byteP; /* Least significant byte 1st */ - struct details *detP; /* The details of an ADxxx frag. */ - int length; /* length (bytes) meant by vop_short. */ - int at; /* 0, or 1 if '@' is in addressing mode. */ - int nbytes; /* From vop_nbytes: vax_operand_width (in bytes) */ - FLONUM_TYPE *floatP; - char *vip (); - LITTLENUM_TYPE literal_float[8]; - /* Big enough for any floating point literal. */ - - if (*(p = vip (&v, instruction_string))) - { - as_fatal ("vax_assemble\"%s\" in=\"%s\"", p, instruction_string); - } - /* - * Now we try to find as many as_warn()s as we can. If we do any as_warn()s - * then goofed=TRUE. Notice that we don't make any frags yet. - * Should goofed be TRUE, then this instruction will wedge in any pass, - * and we can safely flush it, without causing interpass symbol phase - * errors. That is, without changing label values in different passes. - */ - if (goofed = (*v.vit_error)) - { - as_warn ("Ignoring statement due to \"%s\"", v.vit_error); - } - /* - * We need to use expression() and friends, which require us to diddle - * input_line_pointer. So we save it and restore it later. - */ - save_input_line_pointer = input_line_pointer; - for (operandP = v.vit_operand, - expP = exp_of_operand, - floatP = float_operand, - end_operandP = v.vit_operand + v.vit_operands; - - operandP < end_operandP; - - operandP++, - expP++, - floatP++ - ) /* for each operand */ - { - if (*(operandP->vop_error)) - { - as_warn ("Ignoring statement because \"%s\"", (operandP->vop_error)); - goofed = TRUE; - } - else - { /* statement has no syntax goofs: lets sniff the expression */ - int can_be_short; /* TRUE if a bignum can be reduced to a short literal. */ - - input_line_pointer = operandP->vop_expr_begin; - c_save = operandP->vop_expr_end[1]; - operandP->vop_expr_end[1] = '\0'; - /* If to_seg == SEG_PASS1, expression() will have set need_pass_2 = TRUE. */ - switch (to_seg = expression (expP)) - { - case SEG_NONE: - /* for BSD4.2 compatibility, missing expression is absolute 0 */ - to_seg = expP->X_seg = SEG_ABSOLUTE; - expP->X_add_number = 0; - /* for SEG_ABSOLUTE, we shouldnt need to set X_subtract_symbol, X_add_symbol to any particular value. */ - /* But, we will program defensively. Since this situation occurs */ - /* rarely so it costs us little to do, and stops Dean */ - /* worrying about the origin of random bits in expressionS's. */ - expP->X_add_symbol = NULL; - expP->X_subtract_symbol = NULL; - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_ABSOLUTE: - case SEG_UNKNOWN: - break; - - case SEG_DIFFERENCE: - case SEG_PASS1: - /* - * Major bug. We can't handle the case of a - * SEG_DIFFERENCE expression in a VIT_OPCODE_SYNTHETIC - * variable-length instruction. - * We don't have a frag type that is smart enough to - * relax a SEG_DIFFERENCE, and so we just force all - * SEG_DIFFERENCEs to behave like SEG_PASS1s. - * Clearly, if there is a demand we can invent a new or - * modified frag type and then coding up a frag for this - * case will be easy. SEG_DIFFERENCE was invented for the - * .words after a CASE opcode, and was never intended for - * instruction operands. - */ - need_pass_2 = TRUE; - as_warn("Can't relocate expression"); - break; - - case SEG_BIG: - /* Preserve the bits. */ - if (expP->X_add_number > 0) - { - bignum_copy (generic_bignum, expP->X_add_number, - floatP->low, SIZE_OF_LARGE_NUMBER); - } - else - { - know (expP->X_add_number < 0); - flonum_copy (&generic_floating_point_number, - floatP); - if (index ("s i", operandP->vop_short)) - { /* Could possibly become S^# */ - flonum_gen2vax (-expP->X_add_number, floatP, literal_float); - switch (-expP->X_add_number) - { - case 'f': - can_be_short = - (literal_float[0] & 0xFC0F) == 0x4000 - && literal_float[1] == 0; - break; - - case 'd': - can_be_short = - (literal_float[0] & 0xFC0F) == 0x4000 - && literal_float[1] == 0 - && literal_float[2] == 0 - && literal_float[3] == 0; - break; - - case 'g': - can_be_short = - (literal_float[0] & 0xFF81) == 0x4000 - && literal_float[1] == 0 - && literal_float[2] == 0 - && literal_float[3] == 0; - break; - - case 'h': - can_be_short = - (literal_float[0] & 0xFFF8) == 0x4000 - && (literal_float[1] & 0xE000) == 0 - && literal_float[2] == 0 - && literal_float[3] == 0 - && literal_float[4] == 0 - && literal_float[5] == 0 - && literal_float[6] == 0 - && literal_float[7] == 0; - break; - - default: - BAD_CASE (-expP->X_add_number); - break; - } /* switch (float type) */ - } /* if (could want to become S^#...) */ - } /* bignum or flonum ? */ - - if (operandP->vop_short == 's' - || operandP->vop_short == 'i' - || (operandP->vop_short == ' ' - && operandP->vop_reg == 0xF - && (operandP->vop_mode & 0xE) == 0x8)) - { - /* Saw a '#'. */ - if (operandP->vop_short == ' ') - { /* We must chose S^ or I^. */ - if (expP->X_add_number > 0) - { /* Bignum: Short literal impossible. */ - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; /* VAX PC. */ - } - else - { /* Flonum: Try to do it. */ - if (can_be_short) - { - operandP->vop_short = 's'; - operandP->vop_mode = 0; - operandP->vop_ndx = -1; - operandP->vop_reg = -1; - /* JF hope this is the right thing */ - expP->X_seg = SEG_ABSOLUTE; - } - else - { - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; /* VAX PC */ - } - } /* bignum or flonum ? */ - } /* if #, but no S^ or I^ seen. */ - /* No more ' ' case: either 's' or 'i'. */ - if (operandP->vop_short == 's') - { - /* Wants to be a short literal. */ - if (expP->X_add_number > 0) - { - as_warn ("Bignum not permitted in short literal. Immediate mode assumed."); - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; /* VAX PC. */ - } - else - { - if (!can_be_short) - { - as_warn ("Can't do flonum short literal: immediate mode used."); - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; /* VAX PC. */ - } - else - { /* Encode short literal now. */ - register int temp; - - switch (-expP->X_add_number) - { - case 'f': - case 'd': - temp = literal_float[0] >> 4; - break; - - case 'g': - temp = literal_float[0] >> 1; - break; - - case 'h': - temp = ((literal_float[0] << 3) & 070) - | ((literal_float[1] >> 13) & 07); - break; - - default: - BAD_CASE (-expP->X_add_number); - break; - } - - floatP->low[0] = temp & 077; - floatP->low[1] = 0; - } /* if can be short literal float */ - } /* flonum or bignum ? */ - } - else - { /* I^# seen: set it up if float. */ - if (expP->X_add_number < 0) - { - bcopy (literal_float, floatP->low, sizeof (literal_float)); - } - } /* if S^# seen. */ - } - else - { - as_warn ("A bignum/flonum may not be a displacement: 0x%x used", - expP->X_add_number = 0x80000000); - /* Chosen so luser gets the most offset bits to patch later. */ - } - expP->X_add_number = floatP->low[0] - | ((LITTLENUM_MASK & (floatP->low[1])) << LITTLENUM_NUMBER_OF_BITS); -/* - * For the SEG_BIG case we have: - * If vop_short == 's' then a short floating literal is in the - * lowest 6 bits of floatP -> low [0], which is - * big_operand_bits [---] [0]. - * If vop_short == 'i' then the appropriate number of elements - * of big_operand_bits [---] [...] are set up with the correct - * bits. - * Also, just in case width is byte word or long, we copy the lowest - * 32 bits of the number to X_add_number. - */ - break; - - default: - BAD_CASE (to_seg); - break; - } - if (input_line_pointer != operandP->vop_expr_end + 1) - { - as_warn ("Junk at end of expression \"%s\"", input_line_pointer); - goofed = TRUE; - } - operandP->vop_expr_end[1] = c_save; - } - } /* for(each operand) */ - input_line_pointer = save_input_line_pointer; - - if (!need_pass_2 && !goofed) - { - /* We saw no errors in any operands - try to make frag(s) */ - int is_undefined; /* True if operand expression's */ - /* segment not known yet. */ - int length_code; - - /* Emit op-code. */ - /* Remember where it is, in case we want to modify the op-code later. */ - opcode_low_byteP = frag_more (v.vit_opcode_nbytes); - bcopy (v.vit_opcode, opcode_low_byteP, v.vit_opcode_nbytes); - opcode_as_number = md_chars_to_number (opcode_as_chars = v.vit_opcode, 4); - for (operandP = v.vit_operand, - expP = exp_of_operand, - floatP = float_operand, - end_operandP = v.vit_operand + v.vit_operands; - - operandP < end_operandP; - - operandP++, - floatP++, - expP++ - ) /* for each operand */ - { - if (operandP->vop_ndx >= 0) - { - /* indexed addressing byte */ - /* Legality of indexed mode already checked: it is OK */ - FRAG_APPEND_1_CHAR (0x40 + operandP->vop_ndx); - } /* if(vop_ndx>=0) */ - - /* Here to make main operand frag(s). */ - this_add_number = expP->X_add_number; - this_add_symbol = expP->X_add_symbol; - this_subtract_symbol = expP->X_subtract_symbol; - to_seg = expP->X_seg; - is_undefined = (to_seg == SEG_UNKNOWN); - know (to_seg == SEG_UNKNOWN \ - ||to_seg == SEG_ABSOLUTE \ - ||to_seg == SEG_DATA \ - ||to_seg == SEG_TEXT \ - ||to_seg == SEG_BSS \ - ||to_seg == SEG_BIG \ - ); - at = operandP->vop_mode & 1; - length = operandP->vop_short == 'b' ? 1 : operandP->vop_short == 'w' ? 2 : operandP->vop_short == 'l' ? 4 : 0; - nbytes = operandP->vop_nbytes; - if (operandP->vop_access == 'b') - { - if (to_seg == now_seg || is_undefined) - { /* If is_undefined, then it might BECOME now_seg. */ - if (nbytes) - { - p = frag_more (nbytes); - fix_new (frag_now, p - frag_now->fr_literal, nbytes, - this_add_symbol, 0, this_add_number, 1); - } - else - { /* to_seg==now_seg || to_seg == SEG_UNKNOWN */ - /* nbytes==0 */ - length_code = is_undefined ? STATE_UNDF : STATE_BYTE; - if (opcode_as_number & VIT_OPCODE_SPECIAL) - { - if (operandP->vop_width == VAX_WIDTH_UNCONDITIONAL_JUMP) - { - /* br or jsb */ - frag_var (rs_machine_dependent, 5, 1, - ENCODE_RELAX (STATE_ALWAYS_BRANCH, length_code), - this_add_symbol, this_add_number, - opcode_low_byteP); - } - else - { - if (operandP->vop_width == VAX_WIDTH_WORD_JUMP) - { - length_code = STATE_WORD; /* JF: There is no state_byte for this one! */ - frag_var (rs_machine_dependent, 10, 2, - ENCODE_RELAX (STATE_COMPLEX_BRANCH, length_code), - this_add_symbol, this_add_number, - opcode_low_byteP); - } - else - { - know (operandP->vop_width == VAX_WIDTH_BYTE_JUMP); - frag_var (rs_machine_dependent, 9, 1, - ENCODE_RELAX (STATE_COMPLEX_HOP, length_code), - this_add_symbol, this_add_number, - opcode_low_byteP); - } - } - } - else - { - know (operandP->vop_width == VAX_WIDTH_CONDITIONAL_JUMP); - frag_var (rs_machine_dependent, 7, 1, - ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, length_code), - this_add_symbol, this_add_number, - opcode_low_byteP); - } - } - } - else - { /* to_seg != now_seg && to_seg != SEG_UNKNOWN */ -/* - * --- SEG FLOAT MAY APPEAR HERE ---- - */ - if (to_seg == SEG_ABSOLUTE) - { - if (nbytes) - { - know (!(opcode_as_number & VIT_OPCODE_SYNTHETIC)); - p = frag_more (nbytes); - /* Conventional relocation. */ - fix_new (frag_now, p - frag_now->fr_literal, - nbytes, &abs_symbol, 0, this_add_number, 1); - } - else - { - know (opcode_as_number & VIT_OPCODE_SYNTHETIC); - if (opcode_as_number & VIT_OPCODE_SPECIAL) - { - if (operandP->vop_width == VAX_WIDTH_UNCONDITIONAL_JUMP) - { - /* br or jsb */ - *opcode_low_byteP = opcode_as_chars[0] + VAX_WIDEN_LONG; - know (opcode_as_chars[1] == 0); - p = frag_more (5); - p[0] = VAX_ABSOLUTE_MODE; /* @#... */ - md_number_to_chars (p + 1, this_add_number, 4); - /* Now (eg) JMP @#foo or JSB @#foo. */ - } - else - { - if (operandP->vop_width == VAX_WIDTH_WORD_JUMP) - { - p = frag_more (10); - p[0] = 2; - p[1] = 0; - p[2] = VAX_BRB; - p[3] = 6; - p[4] = VAX_JMP; - p[5] = VAX_ABSOLUTE_MODE; /* @#... */ - md_number_to_chars (p + 6, this_add_number, 4); - /* - * Now (eg) ACBx 1f - * BRB 2f - * 1: JMP @#foo - * 2: - */ - } - else - { - know (operandP->vop_width == VAX_WIDTH_BYTE_JUMP); - p = frag_more (9); - p[0] = 2; - p[1] = VAX_BRB; - p[2] = 6; - p[3] = VAX_JMP; - p[4] = VAX_PC_RELATIVE_MODE + 1; /* @#... */ - md_number_to_chars (p + 5, this_add_number, 4); - /* - * Now (eg) xOBxxx 1f - * BRB 2f - * 1: JMP @#foo - * 2: - */ - } - } - } - else - { - /* b */ - *opcode_low_byteP ^= 1; /* To reverse the condition in a VAX branch, complement the lowest order bit. */ - p = frag_more (7); - p[0] = 6; - p[1] = VAX_JMP; - p[2] = VAX_ABSOLUTE_MODE; /* @#... */ - md_number_to_chars (p + 3, this_add_number, 4); - /* - * Now (eg) BLEQ 1f - * JMP @#foo - * 1: - */ - } - } - } - else - { /* to_seg != now_seg && to_seg != SEG_UNKNOWN && to_Seg != SEG_ABSOLUTE */ - if (nbytes > 0) - { - /* Pc-relative. Conventional relocation. */ - know (!(opcode_as_number & VIT_OPCODE_SYNTHETIC)); - p = frag_more (nbytes); - fix_new (frag_now, p - frag_now->fr_literal, - nbytes, &abs_symbol, 0, this_add_number, 1); - } - else - { - know (opcode_as_number & VIT_OPCODE_SYNTHETIC); - if (opcode_as_number & VIT_OPCODE_SPECIAL) - { - if (operandP->vop_width == VAX_WIDTH_UNCONDITIONAL_JUMP) - { - /* br or jsb */ - know (opcode_as_chars[1] == 0); - *opcode_low_byteP = opcode_as_chars[0] + VAX_WIDEN_LONG; - p = frag_more (5); - p[0] = VAX_PC_RELATIVE_MODE; - fix_new (frag_now, - p + 1 - frag_now->fr_literal, 4, - this_add_symbol, 0, - this_add_number, 1); - /* Now eg JMP foo or JSB foo. */ - } - else - { - if (operandP->vop_width == VAX_WIDTH_WORD_JUMP) - { - p = frag_more (10); - p[0] = 0; - p[1] = 2; - p[2] = VAX_BRB; - p[3] = 6; - p[4] = VAX_JMP; - p[5] = VAX_PC_RELATIVE_MODE; - fix_new (frag_now, - p + 6 - frag_now->fr_literal, 4, - this_add_symbol, 0, - this_add_number, 1); - /* - * Now (eg) ACBx 1f - * BRB 2f - * 1: JMP foo - * 2: - */ - } - else - { - know (operandP->vop_width == VAX_WIDTH_BYTE_JUMP); - p = frag_more (10); - p[0] = 2; - p[1] = VAX_BRB; - p[2] = 6; - p[3] = VAX_JMP; - p[4] = VAX_PC_RELATIVE_MODE; - fix_new (frag_now, - p + 5 - frag_now->fr_literal, - 4, this_add_symbol, 0, - this_add_number, 1); - /* - * Now (eg) xOBxxx 1f - * BRB 2f - * 1: JMP foo - * 2: - */ - } - } - } - else - { - know (operandP->vop_width == VAX_WIDTH_CONDITIONAL_JUMP); - *opcode_low_byteP ^= 1; /* Reverse branch condition. */ - p = frag_more (7); - p[0] = 6; - p[1] = VAX_JMP; - p[2] = VAX_PC_RELATIVE_MODE; - fix_new (frag_now, p + 3 - frag_now->fr_literal, - 4, this_add_symbol, 0, - this_add_number, 1); - } - } - } - } - } - else - { - know (operandP->vop_access != 'b'); /* So it is ordinary operand. */ - know (operandP->vop_access != ' '); /* ' ' target-independent: elsewhere. */ - know (operandP->vop_access == 'a' || operandP->vop_access == 'm' || operandP->vop_access == 'r' || operandP->vop_access == 'v' || operandP->vop_access == 'w'); - if (operandP->vop_short == 's') - { - if (to_seg == SEG_ABSOLUTE) - { - if (this_add_number < 0 || this_add_number >= 64) - { - as_warn ("Short literal overflow(%d.), immediate mode assumed.", this_add_number); - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; - } - } - else - { - as_warn ("Forced short literal to immediate mode. now_seg=%s to_seg=%s", seg_name[(int) now_seg], seg_name[(int) to_seg]); - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; - } - } - if (operandP->vop_reg >= 0 && (operandP->vop_mode < 8 || (operandP->vop_reg != 0xF && operandP->vop_mode < 10))) - { /* One byte operand. */ - know (operandP->vop_mode > 3); - FRAG_APPEND_1_CHAR (operandP->vop_mode << 4 | operandP->vop_reg); - /* All 1-bytes except S^# happen here. */ - } - else - { /* {@}{q^}foo{(Rn)} or S^#foo */ - if (operandP->vop_reg == -1 && operandP->vop_short != 's') - { /* "{@}{q^}foo" */ - if (to_seg == now_seg) - { - if (length == 0) - { - know (operandP->vop_short == ' '); - p = frag_var (rs_machine_dependent, 10, 2, - ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE), - this_add_symbol, this_add_number, - opcode_low_byteP); - know (operandP->vop_mode == 10 + at); - *p = at << 4; - /* At is the only context we need to carry to */ - /* other side of relax() process. */ - /* Must be in the correct bit position of VAX */ - /* operand spec. byte. */ - } - else - { - know (length); - know (operandP->vop_short != ' '); - p = frag_more (length + 1); - /* JF is this array stuff really going to work? */ - p[0] = 0xF | ((at + "?\12\14?\16"[length]) << 4); - fix_new (frag_now, p + 1 - frag_now->fr_literal, - length, this_add_symbol, 0, - this_add_number, 1); - } - } - else - { /* to_seg != now_seg */ - if (this_add_symbol == NULL) - { - know (to_seg == SEG_ABSOLUTE); - /* Do @#foo: simpler relocation than foo-.(pc) anyway. */ - p = frag_more (5); - p[0] = VAX_ABSOLUTE_MODE; /* @#... */ - md_number_to_chars (p + 1, this_add_number, 4); - if (length && length != 4) - { - as_warn ("Length specification ignored. Address mode 9F used"); - } - } - else - { - /* {@}{q^}other_seg */ - know ((length == 0 && operandP->vop_short == ' ') \ - ||(length > 0 && operandP->vop_short != ' ')); - if (is_undefined) - { - /* - * We have a SEG_UNKNOWN symbol. It might - * turn out to be in the same segment as - * the instruction, permitting relaxation. - */ - p = frag_var (rs_machine_dependent, 5, 2, - ENCODE_RELAX (STATE_PC_RELATIVE, STATE_UNDF), - this_add_symbol, this_add_number, - 0); - p[0] = at << 4; - } - else - { - if (length == 0) - { - know (operandP->vop_short == ' '); - length = 4; /* Longest possible. */ - } - p = frag_more (length + 1); - p[0] = 0xF | ((at + "?\12\14?\16"[length]) << 4); - md_number_to_chars (p + 1, this_add_number, length); - fix_new (frag_now, - p + 1 - frag_now->fr_literal, - length, this_add_symbol, 0, - this_add_number, 1); - } - } - } - } - else - { /* {@}{q^}foo(Rn) or S^# or I^# or # */ - if (operandP->vop_mode < 0xA) - { /* # or S^# or I^# */ - /* know( (length == 0 && operandP->vop_short == ' ') \ - || (length > 0 && operandP->vop_short != ' ')); */ - if (length == 0 - && to_seg == SEG_ABSOLUTE - && operandP->vop_mode == 8 /* No '@'. */ - && this_add_number < 64 - && this_add_number >= 0) - { - operandP->vop_short = 's'; - } - if (operandP->vop_short == 's') - { - FRAG_APPEND_1_CHAR (this_add_number); - } - else - { /* I^#... */ - know (nbytes); - p = frag_more (nbytes + 1); - know (operandP->vop_reg == 0xF); - p[0] = (operandP->vop_mode << 4) | 0xF; - if (to_seg == SEG_ABSOLUTE) - { -/* - * If nbytes > 4, then we are scrod. We don't know if the - * high order bytes are to be 0xFF or 0x00. - * BSD4.2 & RMS say use 0x00. OK --- but this - * assembler needs ANOTHER rewrite to - * cope properly with this bug. - */ - md_number_to_chars (p + 1, this_add_number, min (4, nbytes)); - if (nbytes > 4) - { - bzero (p + 5, nbytes - 4); - } - } - else - { - if (to_seg == SEG_BIG) - { -/* - * Problem here is to get the bytes in the right order. - * We stored our constant as LITTLENUMs, not bytes. - */ - LITTLENUM_TYPE *lP; - - lP = floatP->low; - if (nbytes & 1) - { - know (nbytes == 1); - p[1] = *lP; - } - else - { - for (p++; nbytes; nbytes -= 2, p += 2, lP++) - { - md_number_to_chars (p, *lP, 2); - } - } - } - else - { - fix_new (frag_now, p + 1 - frag_now->fr_literal, - nbytes, this_add_symbol, 0, - this_add_number, 0); - } - } - } - } - else - { /* {@}{q^}foo(Rn) */ - know ((length == 0 && operandP->vop_short == ' ') \ - ||(length > 0 && operandP->vop_short != ' ')); - if (length == 0) - { - if (to_seg == SEG_ABSOLUTE) - { - register long int test; - - test = this_add_number; - - if (test < 0) - test = ~test; - - length = test & 0xffff8000 ? 4 - : test & 0xffffff80 ? 2 - : 1; - } - else - { - length = 4; - } - } - p = frag_more (1 + length); - know (operandP->vop_reg >= 0); - p[0] = operandP->vop_reg - | ((at | "?\12\14?\16"[length]) << 4); - if (to_seg == SEG_ABSOLUTE) - { - md_number_to_chars (p + 1, this_add_number, length); - } - else - { - fix_new (frag_now, p + 1 - frag_now->fr_literal, - length, this_add_symbol, 0, - this_add_number, 0); - } - } - } - } /* if(single-byte-operand) */ - } - } /* for(operandP) */ - } /* if(!need_pass_2&&!goofed) */ -} /* vax_assemble() */ - -/* - * md_estimate_size_before_relax() - * - * Called just before relax(). - * Any symbol that is now undefined will not become defined. - * Return the correct fr_subtype in the frag. - * Return the initial "guess for fr_var" to caller. - * The guess for fr_var is ACTUALLY the growth beyond fr_fix. - * Whatever we do to grow fr_fix or fr_var contributes to our returned value. - * Although it may not be explicit in the frag, pretend fr_var starts with a - * 0 value. - */ -int -md_estimate_size_before_relax (fragP, segment_type) - register fragS *fragP; - register int segment_type; /* N_DATA or N_TEXT. */ -{ - register char *p; - register int old_fr_fix; - - old_fr_fix = fragP->fr_fix; - switch (fragP->fr_subtype) - { - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_UNDF): - if ((fragP->fr_symbol->sy_type & N_TYPE) == segment_type) - { /* A relaxable case. */ - fragP->fr_subtype = ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE); - } - else - { - p = fragP->fr_literal + old_fr_fix; - p[0] |= VAX_PC_RELATIVE_MODE; /* Preserve @ bit. */ - fragP->fr_fix += 1 + 4; - fix_new (fragP, old_fr_fix + 1, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 1); - frag_wane (fragP); - } - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF): - if ((fragP->fr_symbol->sy_type & N_TYPE) == segment_type) - { - fragP->fr_subtype = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE); - } - else - { - p = fragP->fr_literal + old_fr_fix; - *fragP->fr_opcode ^= 1; /* Reverse sense of branch. */ - p[0] = 6; - p[1] = VAX_JMP; - p[2] = VAX_PC_RELATIVE_MODE; /* ...(PC) */ - fragP->fr_fix += 1 + 1 + 1 + 4; - fix_new (fragP, old_fr_fix + 3, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 1); - frag_wane (fragP); - } - break; - - case ENCODE_RELAX (STATE_COMPLEX_BRANCH, STATE_UNDF): - if ((fragP->fr_symbol->sy_type & N_TYPE) == segment_type) - { - fragP->fr_subtype = ENCODE_RELAX (STATE_COMPLEX_BRANCH, STATE_WORD); - } - else - { - p = fragP->fr_literal + old_fr_fix; - p[0] = 2; - p[1] = 0; - p[2] = VAX_BRB; - p[3] = 6; - p[4] = VAX_JMP; - p[5] = VAX_PC_RELATIVE_MODE; /* ...(pc) */ - fragP->fr_fix += 2 + 2 + 1 + 1 + 4; - fix_new (fragP, old_fr_fix + 6, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 1); - frag_wane (fragP); - } - break; - - case ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_UNDF): - if ((fragP->fr_symbol->sy_type & N_TYPE) == segment_type) - { - fragP->fr_subtype = ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_BYTE); - } - else - { - p = fragP->fr_literal + old_fr_fix; - p[0] = 2; - p[1] = VAX_BRB; - p[2] = 6; - p[3] = VAX_JMP; - p[4] = VAX_PC_RELATIVE_MODE; /* ...(pc) */ - fragP->fr_fix += 1 + 2 + 1 + 1 + 4; - fix_new (fragP, old_fr_fix + 5, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 1); - frag_wane (fragP); - } - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_UNDF): - if ((fragP->fr_symbol->sy_type & N_TYPE) == segment_type) - { - fragP->fr_subtype = ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE); - } - else - { - p = fragP->fr_literal + old_fr_fix; - *fragP->fr_opcode += VAX_WIDEN_LONG; - p[0] = VAX_PC_RELATIVE_MODE; /* ...(PC) */ - fragP->fr_fix += 1 + 4; - fix_new (fragP, old_fr_fix + 1, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 1); - frag_wane (fragP); - } - break; - - default: - break; - } - return (fragP->fr_var + fragP->fr_fix - old_fr_fix); -} /* md_estimate_size_before_relax() */ - -/* - * md_convert_frag(); - * - * Called after relax() is finished. - * In: Address of frag. - * fr_type == rs_machine_dependent. - * fr_subtype is what the address relaxed to. - * - * Out: Any fixSs and constants are set up. - * Caller will turn frag into a ".space 0". - */ -void -md_convert_frag (fragP) - register fragS *fragP; -{ - register char *addressP; /* -> _var to change. */ - register char *opcodeP; /* -> opcode char(s) to change. */ - register short int length_code; /* 2=long 1=word 0=byte */ - register short int extension; /* Size of relaxed address. */ - /* Added to fr_fix: incl. ALL var chars. */ - register symbolS *symbolP; - register long int where; - register long int address_of_var; - /* Where, in file space, is _var of *fragP? */ - register long int target_address; - /* Where, in file space, does addr point? */ - - know (fragP->fr_type == rs_machine_dependent); - length_code = fragP->fr_subtype & 3; /* depends on ENCODE_RELAX() */ - know (length_code >= 0 && length_code < 3); - where = fragP->fr_fix; - addressP = fragP->fr_literal + where; - opcodeP = fragP->fr_opcode; - symbolP = fragP->fr_symbol; - know (symbolP); - target_address = symbolP->sy_value + fragP->fr_offset; - address_of_var = fragP->fr_address + where; - switch (fragP->fr_subtype) - { - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE): - know (*addressP == 0 || *addressP == 0x10); /* '@' bit. */ - addressP[0] |= 0xAF; /* Byte displacement. */ - addressP[1] = target_address - (address_of_var + 2); - extension = 2; - break; - - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_WORD): - know (*addressP == 0 || *addressP == 0x10); /* '@' bit. */ - addressP[0] |= 0xCF; /* Word displacement. */ - md_number_to_chars (addressP + 1, target_address - (address_of_var + 3), 2); - extension = 3; - break; - - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_LONG): - know (*addressP == 0 || *addressP == 0x10); /* '@' bit. */ - addressP[0] |= 0xEF; /* Long word displacement. */ - md_number_to_chars (addressP + 1, target_address - (address_of_var + 5), 4); - extension = 5; - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE): - addressP[0] = target_address - (address_of_var + 1); - extension = 1; - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_WORD): - opcodeP[0] ^= 1; /* Reverse sense of test. */ - addressP[0] = 3; - addressP[1] = VAX_BRB + VAX_WIDEN_WORD; - md_number_to_chars (addressP + 2, target_address - (address_of_var + 4), 2); - extension = 4; - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_LONG): - opcodeP[0] ^= 1; /* Reverse sense of test. */ - addressP[0] = 6; - addressP[1] = VAX_JMP; - addressP[2] = VAX_PC_RELATIVE_MODE; - md_number_to_chars (addressP + 3, target_address, 4); - extension = 7; - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE): - addressP[0] = target_address - (address_of_var + 1); - extension = 1; - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_WORD): - opcodeP[0] += VAX_WIDEN_WORD; /* brb -> brw, bsbb -> bsbw */ - md_number_to_chars (addressP, target_address - (address_of_var + 2), 2); - extension = 2; - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_LONG): - opcodeP[0] += VAX_WIDEN_LONG; /* brb -> jmp, bsbb -> jsb */ - addressP[0] = VAX_PC_RELATIVE_MODE; - md_number_to_chars (addressP + 1, target_address - (address_of_var + 5), 4); - extension = 5; - break; - - case ENCODE_RELAX (STATE_COMPLEX_BRANCH, STATE_WORD): - md_number_to_chars (addressP, target_address - (address_of_var + 2), 2); - extension = 2; - break; - - case ENCODE_RELAX (STATE_COMPLEX_BRANCH, STATE_LONG): - addressP[0] = 2; - addressP[1] = 0; - addressP[2] = VAX_BRB; - addressP[3] = 6; - addressP[4] = VAX_JMP; - addressP[5] = VAX_PC_RELATIVE_MODE; - md_number_to_chars (addressP + 6, target_address, 4); - extension = 10; - break; - - case ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_BYTE): - addressP[0] = target_address - (address_of_var + 1); - extension = 1; - break; - - case ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_WORD): - addressP[0] = 2; - addressP[1] = VAX_BRB; - addressP[2] = 3; - addressP[3] = VAX_BRW; - md_number_to_chars (addressP + 4, target_address - (address_of_var + 6), 2); - extension = 6; - break; - - case ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_LONG): - addressP[0] = 2; - addressP[1] = VAX_BRB; - addressP[2] = 6; - addressP[3] = VAX_JMP; - addressP[4] = VAX_PC_RELATIVE_MODE; - md_number_to_chars (addressP + 5, target_address, 4); - extension = 9; - break; - - default: - BAD_CASE (fragP->fr_subtype); - break; - } - fragP->fr_fix += extension; -} - -/* the bit-field entries in the relocation_info struct plays hell - with the byte-order problems of cross-assembly. So as a hack, - I added this mach. dependent ri twiddler. Ugly, but it gets - you there. -KWK */ -/* on vax: first 4 bytes are normal unsigned long, next three bytes - are symbolnum, least sig. byte first. Last byte is broken up with - the upper nibble as nuthin, bit 3 as extern, bits 2 & 1 as length, and - bit 0 as pcrel. */ -void -md_ri_to_chars (ri_p, ri) - struct relocation_info *ri_p, ri; -{ - unsigned char the_bytes[8]; - - /* this is easy */ - md_number_to_chars (the_bytes, ri.r_address, sizeof (ri.r_address)); - /* now the fun stuff */ - the_bytes[6] = (ri.r_symbolnum >> 16) & 0x0ff; - the_bytes[5] = (ri.r_symbolnum >> 8) & 0x0ff; - the_bytes[4] = ri.r_symbolnum & 0x0ff; - the_bytes[7] = (((ri.r_extern << 3) & 0x08) | ((ri.r_length << 1) & 0x06) | - ((ri.r_pcrel << 0) & 0x01)) & 0x0F; - /* now put it back where you found it */ - bcopy (the_bytes, (char *) ri_p, sizeof (struct relocation_info)); -} - - - - /* JF this used to be a separate file */ -/* vax_ins_parse.c - a part for a VAX assembler */ - -/* Copyright (C) 1987 Free Software Foundtation, Inc */ - -/* - * BUGS, GRIPES, APOLOGIA, etc. - * - * The opcode table 'votstrs' needs to be sorted on opcode frequency. - * That is, AFTER we hash it with hash_...(), we want most-used opcodes - * to come out of the hash table faster. - * - * I am sorry to inflict - * yet another VAX assembler on the world, but RMS says we must - * do everything from scratch, to prevent pin-heads restricting - * this software. - */ - -/* - * This is a vaguely modular set of routines in C to parse VAX - * assembly code using DEC mnemonics. It is NOT un*x specific. - * - * The idea here is that the assembler has taken care of all: - * labels - * macros - * listing - * pseudo-ops - * line continuation - * comments - * condensing any whitespace down to exactly one space - * and all we have to do is parse 1 line into a vax instruction - * partially formed. We will accept a line, and deliver: - * an error message (hopefully empty) - * a skeleton VAX instruction (tree structure) - * textual pointers to all the operand expressions - * a warning message that notes a silly operand (hopefully empty) - */ - -/* - * E D I T H I S T O R Y - * - * 17may86 Dean Elsner. Bug if line ends immediately after opcode. - * 30apr86 Dean Elsner. New vip_op() uses arg block so change call. - * 6jan86 Dean Elsner. Crock vip_begin() to call vip_op_defaults(). - * 2jan86 Dean Elsner. Invent synthetic opcodes. - * Widen vax_opcodeT to 32 bits. Use a bit for VIT_OPCODE_SYNTHETIC, - * which means this is not a real opcode, it is like a macro; it will - * be relax()ed into 1 or more instructions. - * Use another bit for VIT_OPCODE_SPECIAL if the op-code is not optimised - * like a regular branch instruction. Option added to vip_begin(): - * exclude synthetic opcodes. Invent synthetic_votstrs[]. - * 31dec85 Dean Elsner. Invent vit_opcode_nbytes. - * Also make vit_opcode into a char[]. We now have n-byte vax opcodes, - * so caller's don't have to know the difference between a 1-byte & a - * 2-byte op-code. Still need vax_opcodeT concept, so we know how - * big an object must be to hold an op.code. - * 30dec85 Dean Elsner. Widen typedef vax_opcodeT in "vax-inst.h" - * because vax opcodes may be 16 bits. Our crufty C compiler was - * happily initialising 8-bit vot_codes with 16-bit numbers! - * (Wouldn't the 'phone company like to compress data so easily!) - * 29dec85 Dean Elsner. New static table vax_operand_width_size[]. - * Invented so we know hw many bytes a "I^#42" needs in its immediate - * operand. Revised struct vop in "vax-inst.h": explicitly include - * byte length of each operand, and it's letter-code datum type. - * 17nov85 Dean Elsner. Name Change. - * Due to ar(1) truncating names, we learned the hard way that - * "vax-inst-parse.c" -> "vax-inst-parse." dropping the "o" off - * the archived object name. SO... we shortened the name of this - * source file, and changed the makefile. - */ - -/* #include JF for one big happy file */ - -/* JF #include "vax-inst.h" /* define the tree we parse it into */ - - -static char *op_hash = NULL; /* handle of the OPCODE hash table */ - /* NULL means any use before vip_begin() */ - /* will crash */ - -/* - * In: 1 character, from "bdfghloqpw" being the data-type of an operand - * of a vax instruction. - * - * Out: the length of an operand of that type, in bytes. - * Special branch operands types "-?!" have length 0. - */ - -static const short int vax_operand_width_size[256] = -{ - -#define _ 0 - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, 1, _, 8, _, 4, 8, 16, _, _, _, 4, _, _, 16, /* ..b.d.fgh...l..o */ - _, 8, _, _, _, _, _, 2, _, _, _, _, _, _, _, _, /* .q.....w........ */ - _, _, 1, _, 8, _, 4, 8, 16, _, _, _, 4, _, _, 16, /* ..b.d.fgh...l..o */ - _, 8, _, _, _, _, _, 2, _, _, _, _, _, _, _, _, /* .q.....w........ */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}; -#undef _ - -/* - * This perversion encodes all the vax opcodes as a bunch of strings. - * RMS says we should build our hash-table at run-time. Hmm. - * Please would someone arrange these in decreasing frequency of opcode? - * Because of the way hash_...() works, the most frequently used opcode - * should be textually first and so on. - * - * Input for this table was 'vax.opcodes', awk(1)ed by 'vax.opcodes.c.awk' . - * So change 'vax.opcodes', then re-generate this table. - */ - -#include "vax-opcode.h" - -/* - * This is a table of optional op-codes. All of them represent - * 'synthetic' instructions that seem popular. - * - * Here we make some pseudo op-codes. Every code has a bit set to say - * it is synthetic. This lets you catch them if you want to - * ban these opcodes. They are mnemonics for "elastic" instructions - * that are supposed to assemble into the fewest bytes needed to do a - * branch, or to do a conditional branch, or whatever. - * - * The opcode is in the usual place [low-order n*8 bits]. This means - * that if you mask off the bucky bits, the usual rules apply about - * how long the opcode is. - * - * All VAX branch displacements come at the end of the instruction. - * For simple branches (1-byte opcode + 1-byte displacement) the last - * operand is coded 'b?' where the "data type" '?' is a clue that we - * may reverse the sense of the branch (complement lowest order bit) - * and branch around a jump. This is by far the most common case. - * That is why the VIT_OPCODE_SYNTHETIC bit is set: it says this is - * a 0-byte op-code followed by 2 or more bytes of operand address. - * - * If the op-code has VIT_OPCODE_SPECIAL set, then we have a more unusual - * case. - * - * For JBSB & JBR the treatment is the similar, except (1) we have a 'bw' - * option before (2) we can directly JSB/JMP because there is no condition. - * These operands have 'b-' as their access/data type. - * - * That leaves a bunch of random opcodes: JACBx, JxOBxxx. In these - * cases, we do the same idea. JACBxxx are all marked with a 'b!' - * JAOBxxx & JSOBxxx are marked with a 'b:'. - * - */ -#if (VIT_OPCODE_SYNTHETIC != 0x80000000) -You have just broken the encoding below, which assumes the sign bit - means 'I am an imaginary instruction'. -#endif - -#if (VIT_OPCODE_SPECIAL != 0x40000000) - You have just broken the encoding below, which assumes the 0x40 M bit means - 'I am not to be "optimised" the way normal branches are'. -#endif - -static const struct vot - synthetic_votstrs[] = -{ - {"jbsb", - {"b-", 0xC0000010}}, /* BSD 4.2 */ - /* jsb used already */ - {"jbr", - {"b-", 0xC0000011}}, /* BSD 4.2 */ - {"jr", - {"b-", 0xC0000011}}, /* consistent */ - {"jneq", - {"b?", 0x80000012}}, - {"jnequ", - {"b?", 0x80000012}}, - {"jeql", - {"b?", 0x80000013}}, - {"jeqlu", - {"b?", 0x80000013}}, - {"jgtr", - {"b?", 0x80000014}}, - {"jleq", - {"b?", 0x80000015}}, - /* un-used opcodes here */ - {"jgeq", - {"b?", 0x80000018}}, - {"jlss", - {"b?", 0x80000019}}, - {"jgtru", - {"b?", 0x8000001a}}, - {"jlequ", - {"b?", 0x8000001b}}, - {"jvc", - {"b?", 0x8000001c}}, - {"jvs", - {"b?", 0x8000001d}}, - {"jgequ", - {"b?", 0x8000001e}}, - {"jcc", - {"b?", 0x8000001e}}, - {"jlssu", - {"b?", 0x8000001f}}, - {"jcs", - {"b?", 0x8000001f}}, - - {"jacbw", - {"rwrwmwb!", 0xC000003d}}, - {"jacbf", - {"rfrfmfb!", 0xC000004f}}, - {"jacbd", - {"rdrdmdb!", 0xC000006f}}, - {"jacbb", - {"rbrbmbb!", 0xC000009d}}, - {"jacbl", - {"rlrlmlb!", 0xC00000f1}}, - {"jacbg", - {"rgrgmgb!", 0xC0004ffd}}, - {"jacbh", - {"rhrhmhb!", 0xC0006ffd}}, - - {"jbs", - {"rlvbb?", 0x800000e0}}, - {"jbc", - {"rlvbb?", 0x800000e1}}, - {"jbss", - {"rlvbb?", 0x800000e2}}, - {"jbcs", - {"rlvbb?", 0x800000e3}}, - {"jbsc", - {"rlvbb?", 0x800000e4}}, - {"jbcc", - {"rlvbb?", 0x800000e5}}, - {"jbssi", - {"rlvbb?", 0x800000e6}}, - {"jbcci", - {"rlvbb?", 0x800000e7}}, - {"jlbs", - {"rlb?", 0x800000e8}}, /* JF changed from rlvbb? */ - {"jlbc", - {"rlb?", 0x800000e9}}, /* JF changed from rlvbb? */ - - {"jaoblss", - {"rlmlb:", 0xC00000f2}}, - {"jaobleq", - {"rlmlb:", 0xC00000f3}}, - {"jsobgeq", - {"mlb:", 0xC00000f4}}, /* JF was rlmlb: */ - {"jsobgtr", - {"mlb:", 0xC00000f5}}, /* JF was rlmlb: */ - -/* CASEx has no branch addresses in our conception of it. */ -/* You should use ".word ..." statements after the "case ...". */ - - {"", ""} /* empty is end sentinel */ - -}; /* synthetic_votstrs */ - -/* - * v i p _ b e g i n ( ) - * - * Call me once before you decode any lines. - * I decode votstrs into a hash table at op_hash (which I create). - * I return an error text: hopefully "". - * If you want, I will include the 'synthetic' jXXX instructions in the - * instruction table. - * You must nominate metacharacters for eg DEC's "#", "@", "^". - */ - -char * -vip_begin (synthetic_too, immediate, indirect, displen) - int synthetic_too; /* TRUE means include jXXX op-codes. */ - char *immediate, *indirect, *displen; -{ - register const struct vot *vP; /* scan votstrs */ - register char *retval; /* error text */ - - char *hash_insert (); /* */ - char *hash_new (); /* lies */ - - if ((op_hash = hash_new ())) - { - retval = ""; /* OK so far */ - for (vP = votstrs; *vP->vot_name && !*retval; vP++) - { - retval = hash_insert (op_hash, vP->vot_name, &vP->vot_detail); - } - if (synthetic_too) - { - for (vP = synthetic_votstrs; *vP->vot_name && !*retval; vP++) - { - retval = hash_insert (op_hash, vP->vot_name, &vP->vot_detail); - } - } - } - else - { - retval = "virtual memory exceeded"; - } -#ifndef CONST_TABLE - vip_op_defaults (immediate, indirect, displen); -#endif - - return (retval); -} - - -/* - * v i p _ e n d ( ) - * - * Call me once after you have decoded all lines. - * I do any cleaning-up needed. - * - * We don't have to do any cleanup ourselves: all of our operand - * symbol table is static, and free()ing it is naughty. - */ -vip_end () -{ -} - -/* - * v i p ( ) - * - * This converts a string into a vax instruction. - * The string must be a bare single instruction in dec-vax (with BSD4 frobs) - * format. - * It provides some error messages: at most one fatal error message (which - * stops the scan) and at most one warning message for each operand. - * The vax instruction is returned in exploded form, since we have no - * knowledge of how you parse (or evaluate) your expressions. - * We do however strip off and decode addressing modes and operation - * mnemonic. - * - * The exploded instruction is returned to a struct vit of your choice. - * #include "vax-inst.h" to know what a struct vit is. - * - * This function's value is a string. If it is not "" then an internal - * logic error was found: read this code to assign meaning to the string. - * No argument string should generate such an error string: - * it means a bug in our code, not in the user's text. - * - * You MUST have called vip_begin() once and vip_end() never before using - * this function. - */ - -char * /* "" or bug string */ -vip (vitP, instring) - struct vit *vitP; /* We build an exploded instruction here. */ - char *instring; /* Text of a vax instruction: we modify. */ -{ - register struct vot_wot *vwP; /* How to bit-encode this opcode. */ - register char *p; /* 1/skip whitespace.2/scan vot_how */ - register char *q; /* */ - register char *bug; /* "" or program logic error */ - register unsigned char count; /* counts number of operands seen */ - register struct vop *operandp;/* scan operands in struct vit */ - register char *alloperr; /* error over all operands */ - register char c; /* Remember char, (we clobber it */ - /* with '\0' temporarily). */ - register vax_opcodeT oc; /* Op-code of this instruction. */ - - struct vot_wot *hash_find (); - char *vip_op (); - - bug = ""; - if (*instring == ' ') - ++instring; /* Skip leading whitespace. */ - for (p = instring; *p && *p != ' '; p++) - ; /* MUST end in end-of-string or exactly 1 space. */ - /* Scanned up to end of operation-code. */ - /* Operation-code is ended with whitespace. */ - if (p - instring == 0) - { - vitP->vit_error = "No operator"; - count = 0; - bzero (vitP->vit_opcode, sizeof (vitP->vit_opcode)); - } - else - { - c = *p; - *p = '\0'; - /* - * Here with instring pointing to what better be an op-name, and p - * pointing to character just past that. - * We trust instring points to an op-name, with no whitespace. - */ - vwP = hash_find (op_hash, instring); - *p = c; /* Restore char after op-code. */ - if (vwP == 0) - { - vitP->vit_error = "Unknown operator"; - count = 0; - bzero (vitP->vit_opcode, sizeof (vitP->vit_opcode)); - } - else - { - /* - * We found a match! So lets pick up as many operands as the - * instruction wants, and even gripe if there are too many. - * We expect comma to seperate each operand. - * We let instring track the text, while p tracks a part of the - * struct vot. - */ - /* - * The lines below know about 2-byte opcodes starting FD,FE or FF. - * They also understand synthetic opcodes. Note: - * we return 32 bits of opcode, including bucky bits, BUT - * an opcode length is either 8 or 16 bits for vit_opcode_nbytes. - */ - oc = vwP->vot_code; /* The op-code. */ - vitP->vit_opcode_nbytes = (oc & 0xFF) >= 0xFD ? 2 : 1; - md_number_to_chars (vitP->vit_opcode, oc, 4); - count = 0; /* no operands seen yet */ - instring = p; /* point just past operation code */ - alloperr = ""; - for (p = vwP->vot_how, operandp = vitP->vit_operand; - !*alloperr && !*bug && *p; - operandp++, p += 2 - ) - { - /* - * Here to parse one operand. Leave instring pointing just - * past any one ',' that marks the end of this operand. - */ - if (!p[1]) - bug = "p"; /* ODD(!!) number of bytes in vot_how?? */ - else if (*instring) - { - for (q = instring; (c = *q) && c != ','; q++) - ; - /* - * Q points to ',' or '\0' that ends argument. C is that - * character. - */ - *q = 0; - operandp->vop_width = p[1]; - operandp->vop_nbytes = vax_operand_width_size[p[1]]; - operandp->vop_access = p[0]; - bug = vip_op (instring, operandp); - *q = c; /* Restore input text. */ - if (*(operandp->vop_error)) - alloperr = "Bad operand"; - instring = q + (c ? 1 : 0); /* next operand (if any) */ - count++; /* won another argument, may have an operr */ - } - else - alloperr = "Not enough operands"; - } - if (!*alloperr) - { - if (*instring == ' ') - instring++; /* Skip whitespace. */ - if (*instring) - alloperr = "Too many operands"; - } - vitP->vit_error = alloperr; - } - } - vitP->vit_operands = count; - return (bug); -} - -#ifdef test - -/* - * Test program for above. - */ - -struct vit myvit; /* build an exploded vax instruction here */ -char answer[100]; /* human types a line of vax assembler here */ -char *mybug; /* "" or an internal logic diagnostic */ -int mycount; /* number of operands */ -struct vop *myvop; /* scan operands from myvit */ -int mysynth; /* TRUE means want synthetic opcodes. */ -char my_immediate[200]; -char my_indirect[200]; -char my_displen[200]; - -char *vip (); - -main () -{ - char *p; - char *vip_begin (); - - printf ("0 means no synthetic instructions. "); - printf ("Value for vip_begin? "); - gets (answer); - sscanf (answer, "%d", &mysynth); - printf ("Synthetic opcodes %s be included.\n", mysynth ? "will" : "will not"); - printf ("enter immediate symbols eg enter # "); - gets (my_immediate); - printf ("enter indirect symbols eg enter @ "); - gets (my_indirect); - printf ("enter displen symbols eg enter ^ "); - gets (my_displen); - if (*(p = vip_begin (mysynth, my_immediate, my_indirect, my_displen))) - { - error ("vip_begin=%s", p); - } - printf ("An empty input line will quit you from the vax instruction parser\n"); - for (;;) - { - printf ("vax instruction: "); - fflush (stdout); - gets (answer); - if (!*answer) - { - break; /* out of for each input text loop */ - } - mybug = vip (&myvit, answer); - if (*mybug) - { - printf ("BUG:\"%s\"\n", mybug); - } - if (*myvit.vit_error) - { - printf ("ERR:\"%s\"\n", myvit.vit_error); - } - printf ("opcode="); - for (mycount = myvit.vit_opcode_nbytes, p = myvit.vit_opcode; - mycount; - mycount--, p++ - ) - { - printf ("%02x ", *p & 0xFF); - } - printf (" operand count=%d.\n", mycount = myvit.vit_operands); - for (myvop = myvit.vit_operand; mycount; mycount--, myvop++) - { - printf ("mode=%xx reg=%xx ndx=%xx len='%c'=%c%c%d. expr=\"", - myvop->vop_mode, myvop->vop_reg, myvop->vop_ndx, - myvop->vop_short, myvop->vop_access, myvop->vop_width, - myvop->vop_nbytes); - for (p = myvop->vop_expr_begin; p <= myvop->vop_expr_end; p++) - { - putchar (*p); - } - printf ("\"\n"); - if (*myvop->vop_error) - { - printf (" err:\"%s\"\n", myvop->vop_error); - } - if (*myvop->vop_warn) - { - printf (" wrn:\"%s\"\n", myvop->vop_warn); - } - } - } - vip_end (); - exit (); -} - -#endif /* #ifdef test */ - -/* end of vax_ins_parse.c */ - - /* JF this used to be a separate file also */ -/* vax_reg_parse.c - convert a VAX register name to a number */ - -/* Copyright (C) 1987 Free Software Foundation, Inc. A part of GNU. */ - -/* - * v a x _ r e g _ p a r s e ( ) - * - * Take 3 char.s, the last of which may be `\0` (non-existent) - * and return the VAX register number that they represent. - * - * Return -1 if they don't form a register name. Good names return - * a number from 0:15 inclusive. - * - * Case is not important in a name. - * - * Register names understood are: - * - * R0 - * R1 - * R2 - * R3 - * R4 - * R5 - * R6 - * R7 - * R8 - * R9 - * R10 - * R11 - * R12 AP - * R13 FP - * R14 SP - * R15 PC - * - */ - -#include -#define AP (12) -#define FP (13) -#define SP (14) -#define PC (15) - -int /* return -1 or 0:15 */ -vax_reg_parse (c1, c2, c3) /* 3 chars of register name */ - char c1, c2, c3; /* c3 == 0 if 2-character reg name */ -{ - register int retval; /* return -1:15 */ - - retval = -1; - - if (isupper (c1)) - c1 = tolower (c1); - if (isupper (c2)) - c2 = tolower (c2); - if (isdigit (c2) && c1 == 'r') - { - retval = c2 - '0'; - if (isdigit (c3)) - { - retval = retval * 10 + c3 - '0'; - retval = (retval > 15) ? -1 : retval; - /* clamp the register value to 1 hex digit */ - } - else if (c3) - retval = -1; /* c3 must be '\0' or a digit */ - } - else if (c3) /* There are no three letter regs */ - retval = -1; - else if (c2 == 'p') - { - switch (c1) - { - case 's': - retval = SP; - break; - case 'f': - retval = FP; - break; - case 'a': - retval = AP; - break; - default: - retval = -1; - } - } - else if (c1 == 'p' && c2 == 'c') - retval = PC; - else - retval = -1; - return (retval); -} - -/* end: vax_reg_parse.c */ - - /* JF this was another separate prog */ -/* vip_op.c - parse 1 VAX instr's operand.(C)1986 Free Software Foundation. */ - -/* JF #include */ -/* #include "vax_inst.h" */ - -/* - * v i p _ o p ( ) - * - * Parse a vax operand in DEC assembler notation. - * For speed, expect a string of whitespace to be reduced to a single ' '. - * This is the case for GNU AS, and is easy for other DEC-compatible - * assemblers. - * - * Knowledge about DEC VAX assembler operand notation lives here. - * This doesn't even know what a register name is, except it believes - * all register names are 2 or 3 characters, and lets vax_reg_parse() say - * what number each name represents. - * It does, however, know that PC, SP etc are special registers so it can - * detect addressing modes that are silly for those registers. - * - * Where possible, it delivers 1 fatal or 1 warning message if the operand - * is suspect. Exactly what we test for is still evolving. - */ - -/* - * B u g s - * - * Arg block. - * - * There were a number of 'mismatched argument type' bugs to vip_op. - * The most general solution is to typedef each (of many) arguments. - * We used instead a typedef'd argument block. This is less modular - * than using seperate return pointers for each result, but runs faster - * on most engines, and seems to keep programmers happy. It will have - * to be done properly if we ever want to use vip_op as a general-purpose - * module (it was designed to be). - * - * G^ - * - * Doesn't support DEC "G^" format operands. These always take 5 bytes - * to express, and code as modes 8F or 9F. Reason: "G^" deprives you of - * optimising to (say) a "B^" if you are lucky in the way you link. - * When someone builds a linker smart enough to convert "G^" to "B^", "W^" - * whenever possible, then we should implement it. - * If there is some other use for "G^", feel free to code it in! - * - * - * speed - * - * If I nested if()s more, I could avoid testing (*err) which would save - * time, space and page faults. I didn't nest all those if()s for clarity - * and because I think the mode testing can be re-arranged 1st to test the - * commoner constructs 1st. Does anybody have statistics on this? - * - * - * - * error messages - * - * In future, we should be able to 'compose' error messages in a scratch area - * and give the user MUCH more informative error messages. Although this takes - * a little more code at run-time, it will make this module much more self- - * documenting. As an example of what sucks now: most error messages have - * hardwired into them the DEC VAX metacharacters "#^@" which are nothing like - * the Un*x characters "$`*", that most users will expect from this AS. - */ - -/* - * The input is a string, ending with '\0'. - * - * We also require a 'hint' of what kind of operand is expected: so - * we can remind caller not to write into literals for instance. - * - * The output is a skeletal instruction. - * - * The algorithm has two parts. - * 1. extract the syntactic features (parse off all the @^#-()+[] mode crud); - * 2. express the @^#-()+[] as some parameters suited to further analysis. - * - * 2nd step is where we detect the googles of possible invalid combinations - * a human (or compiler) might write. Note that if we do a half-way - * decent assembler, we don't know how long to make (eg) displacement - * fields when we first meet them (because they may not have defined values). - * So we must wait until we know how many bits are needed for each address, - * then we can know both length and opcodes of instructions. - * For reason(s) above, we will pass to our caller a 'broken' instruction - * of these major components, from which our caller can generate instructions: - * - displacement length I^ S^ L^ B^ W^ unspecified - * - mode (many) - * - register R0-R15 or absent - * - index register R0-R15 or absent - * - expression text what we don't parse - * - error text(s) why we couldn't understand the operand - */ - -/* - * To decode output of this, test errtxt. If errtxt[0] == '\0', then - * we had no errors that prevented parsing. Also, if we ever report - * an internal bug, errtxt[0] is set non-zero. So one test tells you - * if the other outputs are to be taken seriously. - */ - - - /* vax registers we need to know */ -/* JF #define SP (14) -/* JF for one big happy file #define PC (15) */ - - /* useful ideas */ -/* #define TRUE (1) */ -/* #define FALSE (0) */ - -/* - * Because this module is useful for both VMS and UN*X style assemblers - * and because of the variety of UN*X assemblers we must recognise - * the different conventions for assembler operand notation. For example - * VMS says "#42" for immediate mode, while most UN*X say "$42". - * We permit arbitrary sets of (single) characters to represent the - * 3 concepts that DEC writes '#', '@', '^'. - */ - - /* character tests */ -#define VIP_IMMEDIATE 01 /* Character is like DEC # */ -#define VIP_INDIRECT 02 /* Char is like DEC @ */ -#define VIP_DISPLEN 04 /* Char is like DEC ^ */ - -#define IMMEDIATEP(c) (vip_metacharacters [(c)&0xff]&VIP_IMMEDIATE) -#define INDIRECTP(c) (vip_metacharacters [(c)&0xff]&VIP_INDIRECT) -#define DISPLENP(c) (vip_metacharacters [(c)&0xff]&VIP_DISPLEN) - -/* We assume 8 bits per byte. Use vip_op_defaults() to set these up BEFORE we - * are ever called. - */ - -#if defined(CONST_TABLE) -#define _ 0, -#define I VIP_IMMEDIATE, -#define S VIP_INDIRECT, -#define D VIP_DISPLEN, -static const char -vip_metacharacters[256] = { -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O*/ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_*/ -_ _ _ _ I _ _ _ _ _ S _ _ _ _ _/*sp ! " # $ % & ' ( ) * + , - . /*/ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*0 1 2 3 4 5 6 7 8 9 : ; < = > ?*/ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*@ A B C D E F G H I J K L M N O*/ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*P Q R S T U V W X Y Z [ \ ] ^ _*/ -D _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*` a b c d e f g h i j k l m n o*/ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*p q r s t u v w x y z { | } ~ ^?*/ - -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -}; -#undef _ -#undef I -#undef S -#undef D -#else -static char vip_metacharacters[256]; - -/* Macro is faster under GCC; The constant table is faster yet, but only works with ASCII */ -#if 0 -static -#ifdef __GNUC__ -inline -#endif -static void -vip_op_1(bit,syms) -int bit; -char *syms; -{ - unsigned char t; - - while(t= *syms++) - vip_metacharacters[t]|=bit; -} -#else -#define vip_op_1(bit,syms) { \ - unsigned char t; \ - char *table=vip_metacharacters; \ - while(t= *syms++) \ - table[t]|=bit; \ - } -#endif - -vip_op_defaults (immediate, indirect, displen) /* can be called any time */ - char *immediate, /* Strings of characters for each job. */ - *indirect, *displen; /* more arguments may appear in future! */ -{ - vip_op_1 (VIP_IMMEDIATE, immediate); - vip_op_1 (VIP_INDIRECT, indirect); - vip_op_1 (VIP_DISPLEN, displen); -} -#endif - - -/* - * Dec defines the semantics of address modes (and values) - * by a two-letter code, explained here. - * - * letter 1: access type - * - * a address calculation - no data access, registers forbidden - * b branch displacement - * m read - let go of bus - write back "modify" - * r read - * v bit field address: like 'a' but registers are OK - * w write - * space no operator (eg ".long foo") [our convention] - * - * letter 2: data type (i.e. width, alignment) - * - * b byte - * d double precision floating point (D format) - * f single precision floating point (F format) - * g G format floating - * h H format floating - * l longword - * o octaword - * q quadword - * w word - * ? simple synthetic branch operand - * - unconditional synthetic JSB/JSR operand - * ! complex synthetic branch operand - * - * The '-?!' letter 2's are not for external consumption. They are used - * for various assemblers. Generally, all unknown widths are assumed 0. - * We don't limit your choice of width character. - * - * DEC operands are hard work to parse. For example, '@' as the first - * character means indirect (deferred) mode but elswhere it is a shift - * operator. - * The long-winded explanation of how this is supposed to work is - * cancelled. Read a DEC vax manual. - * We try hard not to parse anything that MIGHT be part of the expression - * buried in that syntax. For example if we see @...(Rn) we don't check - * for '-' before the '(' because mode @-(Rn) does not exist. - * - * After parsing we have: - * - * at TRUE if leading '@' (or Un*x '*') - * len takes one value from " bilsw". eg B^ -> 'b'. - * hash TRUE if leading '#' (or Un*x '$') - * expr_begin, expr_end the expression we did not parse - * even though we don't interpret it, we make use - * of its presence or absence. - * sign -1: -(Rn) 0: absent +1: (Rn)+ - * paren TRUE if () are around register - * reg major register number 0:15 -1 means absent - * ndx index register number 0:15 -1 means absent - * - * Again, I dare not explain it: just trace ALL the code! - */ - -char * /* (code here) bug message, "" = OK */ - /* our code bug, NOT bad assembly language */ -vip_op (optext, vopP) - char *optext; /* user's input string e.g.: */ - /* "@B^foo@bar(AP)[FP]:" */ - struct vop *vopP; /* In: vop_access, vop_width. */ - /* Out: _ndx, _reg, _mode, _short, _warn, */ - /* _error _expr_begin, _expr_end, _nbytes. */ - /* vop_nbytes : number of bytes in a datum. */ -{ - char *p; /* track operand text forward */ - char *q; /* track operand text backward */ - int at; /* TRUE if leading '@' ('*') seen */ - char len; /* one of " bilsw" */ - int hash; /* TRUE if leading '#' ('$') seen */ - int sign; /* -1, 0 or +1 */ - int paren; /* TRUE if () surround register */ - int reg; /* register number, -1:absent */ - int ndx; /* index register number -1:absent */ - char *bug; /* report any logic error in here, ""==OK */ - char *err; /* report illegal operand, ""==OK */ - /* " " is a FAKE error: means we won */ - /* ANY err that begins with ' ' is a fake. */ - /* " " is converted to "" before return */ - char *wrn; /* warn about weird modes pf address */ - char *oldq; /* preserve q in case we backup */ - int mode; /* build up 4-bit operand mode here */ - /* note: index mode is in ndx, this is */ - /* the major mode of operand address */ -/* - * Notice how we move wrong-arg-type bugs INSIDE this module: if we - * get the types wrong below, we lose at compile time rather than at - * lint or run time. - */ - char access; /* vop_access. */ - char width; /* vop_width. */ - - int vax_reg_parse (); /* returns 0:15 or -1 if not a register */ - - access = vopP->vop_access; - width = vopP->vop_width; - bug = /* none of our code bugs (yet) */ - err = /* no user text errors */ - wrn = ""; /* no warnings even */ - - p = optext; - - if (*p == ' ') /* Expect all whitespace reduced to ' '. */ - p++; /* skip over whitespace */ - - if (at = INDIRECTP (*p)) - { /* TRUE if *p=='@'(or '*' for Un*x) */ - p++; /* at is determined */ - if (*p == ' ') /* Expect all whitespace reduced to ' '. */ - p++; /* skip over whitespace */ - } - - /* - * This code is subtle. It tries to detect all legal (letter)'^' - * but it doesn't waste time explicitly testing for premature '\0' because - * this case is rejected as a mismatch against either (letter) or '^'. - */ - { - register char c; - - c = *p; - if (isupper (c)) - c = tolower (c); - if (DISPLENP (p[1]) && index ("bilws", len = c)) - p += 2; /* skip (letter) '^' */ - else /* no (letter) '^' seen */ - len = ' '; /* len is determined */ - } - - if (*p == ' ') /* Expect all whitespace reduced to ' '. */ - p++; /* skip over whitespace */ - - if (hash = IMMEDIATEP (*p)) /* TRUE if *p=='#' ('$' for Un*x) */ - p++; /* hash is determined */ - - /* - * p points to what may be the beginning of an expression. - * We have peeled off the front all that is peelable. - * We know at, len, hash. - * - * Lets point q at the end of the text and parse that (backwards). - */ - - for (q = p; *q; q++) - ; - q--; /* now q points at last char of text */ - - if (*q == ' ' && q >= p) /* Expect all whitespace reduced to ' '. */ - q--; - /* reverse over whitespace, but don't */ - /* run back over *p */ - - /* - * As a matter of policy here, we look for [Rn], although both Rn and S^# - * forbid [Rn]. This is because it is easy, and because only a sick - * cyborg would have [...] trailing an expression in a VAX-like assembler. - * A meticulous parser would first check for Rn followed by '(' or '[' - * and not parse a trailing ']' if it found another. We just ban expressions - * ending in ']'. - */ - if (*q == ']') - { - while (q >= p && *q != '[') - q--; - /* either q

= p) /* Expect all whitespace reduced to ' '. */ - q--; - /* reverse over whitespace, but don't */ - /* run back over *p */ - if (!*err) - { - sign = 0; /* no ()+ or -() seen yet */ - - if (q > p + 3 && *q == '+' && q[-1] == ')') - { - sign = 1; /* we saw a ")+" */ - q--; /* q points to ')' */ - } - - if (*q == ')' && q > p + 2) - { - paren = TRUE; /* assume we have "(...)" */ - while (q >= p && *q != '(') - q--; - /* either q

= 0 then we saw (Rn). - */ - } - /* - * If err == "..." then we lost. - * Otherwise paren==TRUE and reg = register in "()". - */ - } - else - paren = FALSE; - /* - * If err == "..." then we lost. - * Otherwise, q points just before "(Rn)", if any. - * If there was a "(...)" then paren==TRUE, and reg is the register. - */ - - /* - * We should only seek '-' of "-(...)" if: - * we saw "(...)" paren == TRUE - * we have no errors so far ! *err - * we did not see '+' of "(...)+" sign < 1 - * We don't check len. We want a specific error message later if - * user tries "x^...-(Rn)". This is a feature not a bug. - */ - if (!*err) - { - if (paren && sign < 1)/* !sign is adequate test */ - { - if (*q == '-') - { - sign = -1; - q--; - } - } - /* - * We have back-tracked over most - * of the crud at the end of an operand. - * Unless err, we know: sign, paren. If paren, we know reg. - * The last case is of an expression "Rn". - * This is worth hunting for if !err, !paren. - * We wouldn't be here if err. - * We remember to save q, in case we didn't want "Rn" anyway. - */ - if (!paren) - { - if (*q == ' ' && q >= p) /* Expect all whitespace reduced to ' '. */ - q--; - /* reverse over whitespace, but don't */ - /* run back over *p */ - if (q > p && q < p + 3) /* room for Rn or Rnn exactly? */ - reg = vax_reg_parse (p[0], p[1], q < p + 2 ? 0 : p[2]); - else - reg = -1; /* always comes here if no register at all */ - /* - * Here with a definitive reg value. - */ - if (reg >= 0) - { - oldq = q; - q = p - 1; - } - } - } - } - /* - * have reg. -1:absent; else 0:15 - */ - - /* - * We have: err, at, len, hash, ndx, sign, paren, reg. - * Also, any remaining expression is from *p through *q inclusive. - * Should there be no expression, q==p-1. So expression length = q-p+1. - * This completes the first part: parsing the operand text. - */ - - /* - * We now want to boil the data down, checking consistency on the way. - * We want: len, mode, reg, ndx, err, p, q, wrn, bug. - * We will deliver a 4-bit reg, and a 4-bit mode. - */ - - /* - * Case of branch operand. Different. No L^B^W^I^S^ allowed for instance. - * - * in: at ? - * len ? - * hash ? - * p:q ? - * sign ? - * paren ? - * reg ? - * ndx ? - * - * out: mode 0 - * reg -1 - * len ' ' - * p:q whatever was input - * ndx -1 - * err " " or error message, and other outputs trashed - */ - /* branch operands have restricted forms */ - if (!*err && access == 'b') - { - if (at || hash || sign || paren || ndx >= 0 || reg >= 0 || len != ' ') - err = "invalid branch operand"; - else - err = " "; - } - -/* Since nobody seems to use it: comment this 'feature'(?) out for now. */ -#ifdef NEVER - /* - * Case of stand-alone operand. e.g. ".long foo" - * - * in: at ? - * len ? - * hash ? - * p:q ? - * sign ? - * paren ? - * reg ? - * ndx ? - * - * out: mode 0 - * reg -1 - * len ' ' - * p:q whatever was input - * ndx -1 - * err " " or error message, and other outputs trashed - */ - if (!*err) - { - if (access == ' ') - { /* addresses have restricted forms */ - if (at) - err = "address prohibits @"; - else - { - if (hash) - err = "address prohibits #"; - else - { - if (sign) - { - if (sign < 0) - err = "address prohibits -()"; - else - err = "address prohibits ()+"; - } - else - { - if (paren) - err = "address prohibits ()"; - else - { - if (ndx >= 0) - err = "address prohibits []"; - else - { - if (reg >= 0) - err = "address prohibits register"; - else - { - if (len != ' ') - err = "address prohibits displacement length specifier"; - else - { - err = " "; /* succeed */ - mode = 0; - } - } - } - } - } - } - } - } - } -#endif /*#Ifdef NEVER*/ - - /* - * Case of S^#. - * - * in: at FALSE - * len 's' definition - * hash TRUE demand - * p:q demand not empty - * sign 0 by paren==FALSE - * paren FALSE by "()" scan logic because "S^" seen - * reg -1 or nn by mistake - * ndx -1 - * - * out: mode 0 - * reg -1 - * len 's' - * exp - * ndx -1 - */ - if (!*err && len == 's') - { - if (!hash || paren || at || ndx >= 0) - err = "invalid operand of S^#"; - else - { - if (reg >= 0) - { - /* - * SHIT! we saw S^#Rnn ! put the Rnn back in - * expression. KLUDGE! Use oldq so we don't - * need to know exact length of reg name. - */ - q = oldq; - reg = 0; - } - /* - * We have all the expression we will ever get. - */ - if (p > q) - err = "S^# needs expression"; - else if (access == 'r') - { - err = " "; /* WIN! */ - mode = 0; - } - else - err = "S^# may only read-access"; - } - } - - /* - * Case of -(Rn), which is weird case. - * - * in: at FALSE - * len ' - * hash FALSE - * p:q q

q) - { - at = TRUE; - paren = FALSE; - } - - /* - * Case of (Rn)+, which is slightly different. - * - * in: at - * len ' ' - * hash FALSE - * p:q q

0) - { - if (len != ' ' || hash || p <= q) - err = "invalid operand of ()+"; - else - { - err = " "; /* win */ - mode = 8 + (at ? 1 : 0); - if (reg == PC) - wrn = "(PC)+ unpredictable"; - else if (reg == ndx) - wrn = "[]index same as ()+register: unpredictable"; - } - } - - /* - * Case of #, without S^. - * - * in: at - * len ' ' or 'i' - * hash TRUE by definition - * p:q - * sign 0 - * paren FALSE - * reg absent - * ndx optional - * - * out: mode 8+@ - * reg PC - * len ' ' or 'i' - * exp - * ndx optional - */ - if (!*err && hash) - { - if (len != 'i' && len != ' ') - err = "# conflicts length"; - else if (paren) - err = "# bars register"; - else - { - if (reg >= 0) - { - /* - * SHIT! we saw #Rnn! Put the Rnn back into the expression. - * By using oldq, we don't need to know how long Rnn was. - * KLUDGE! - */ - q = oldq; - reg = -1; /* no register any more */ - } - err = " "; /* win */ - - /* JF a bugfix, I think! */ - if(at && access=='a') - vopP->vop_nbytes=4; - - mode = (at ? 9 : 8); - reg = PC; - if ((access == 'm' || access == 'w') && !at) - wrn = "writing or modifying # is unpredictable"; - } - } - /* - * If !*err, then sign == 0 - * hash == FALSE - */ - - /* - * Case of Rn. We seperate this one because it has a few special - * errors the remaining modes lack. - * - * in: at optional - * len ' ' - * hash FALSE by program logic - * p:q empty - * sign 0 by program logic - * paren FALSE by definition - * reg present by definition - * ndx optional - * - * out: mode 5+@ - * reg present - * len ' ' enforce no length - * exp "" enforce empty expression - * ndx optional warn if same as reg - */ - if (!*err && !paren && reg >= 0) - { - if (len != ' ') - err = "length not needed"; - else if (at) - { - err = " "; /* win */ - mode = 6; /* @Rn */ - } - else if (ndx >= 0) - err = "can't []index a register, because it has no address"; - else if (access == 'a') - err = "a register has no address"; - else - { - /* - * Idea here is to detect from length of datum - * and from register number if we will touch PC. - * Warn if we do. - * vop_nbytes is number of bytes in operand. - * Compute highest byte affected, compare to PC0. - */ - if ((vopP->vop_nbytes + reg * 4) > 60) - wrn = "PC part of operand unpredictable"; - err = " "; /* win */ - mode = 5; /* Rn */ - } - } - /* - * If !*err, sign == 0 - * hash == FALSE - * paren == TRUE OR reg==-1 - */ - - /* - * Rest of cases fit into one bunch. - * - * in: at optional - * len ' ' or 'b' or 'w' or 'l' - * hash FALSE by program logic - * p:q expected (empty is not an error) - * sign 0 by program logic - * paren optional - * reg optional - * ndx optional - * - * out: mode 10 + @ + len - * reg optional - * len ' ' or 'b' or 'w' or 'l' - * exp maybe empty - * ndx optional warn if same as reg - */ - if (!*err) - { - err = " "; /* win (always) */ - mode = 10 + (at ? 1 : 0); - switch (len) - { - case 'l': - mode += 2; - case 'w': - mode += 2; - case ' ': /* assumed B^ until our caller changes it */ - case 'b': - break; - } - } - - /* - * here with completely specified mode - * len - * reg - * expression p,q - * ndx - */ - - if (*err == ' ') - err = ""; /* " " is no longer an error */ - - vopP->vop_mode = mode; - vopP->vop_reg = reg; - vopP->vop_short = len; - vopP->vop_expr_begin = p; - vopP->vop_expr_end = q; - vopP->vop_ndx = ndx; - vopP->vop_error = err; - vopP->vop_warn = wrn; - return (bug); - -} /* vip_op() */ - -/* - -Summary of vip_op outputs. - - mode reg len ndx -(Rn) => @Rn -{@}Rn 5+@ n ' ' optional -branch operand 0 -1 ' ' -1 -S^#foo 0 -1 's' -1 --(Rn) 7 n ' ' optional -{@}(Rn)+ 8+@ n ' ' optional -{@}#foo, no S^ 8+@ PC " i" optional -{@}{q^}{(Rn)} 10+@+q option " bwl" optional - -*/ - -#ifdef TEST /* #Define to use this testbed. */ - -/* - * Follows a test program for this function. - * We declare arrays non-local in case some of our tiny-minded machines - * default to small stacks. Also, helps with some debuggers. - */ - -#include - -char answer[100]; /* human types into here */ -char *p; /* */ -char *myerr; -char *mywrn; -char *mybug; -char myaccess; -char mywidth; -char mymode; -char myreg; -char mylen; -char *myleft; -char *myright; -char myndx; -int my_operand_length; -char my_immediate[200]; -char my_indirect[200]; -char my_displen[200]; - -main () -{ - char *vip_op (); /* make cc happy */ - - printf ("enter immediate symbols eg enter # "); - gets (my_immediate); - printf ("enter indirect symbols eg enter @ "); - gets (my_indirect); - printf ("enter displen symbols eg enter ^ "); - gets (my_displen); - vip_op_defaults (my_immediate, my_indirect, my_displen); - for (;;) - { - printf ("access,width (eg 'ab' or 'wh') [empty line to quit] : "); - fflush (stdout); - gets (answer); - if (!answer[0]) - exit (0); - myaccess = answer[0]; - mywidth = answer[1]; - switch (mywidth) - { - case 'b': - my_operand_length = 1; - break; - case 'd': - my_operand_length = 8; - break; - case 'f': - my_operand_length = 4; - break; - case 'g': - my_operand_length = 16; - break; - case 'h': - my_operand_length = 32; - break; - case 'l': - my_operand_length = 4; - break; - case 'o': - my_operand_length = 16; - break; - case 'q': - my_operand_length = 8; - break; - case 'w': - my_operand_length = 2; - break; - case '!': - case '?': - case '-': - my_operand_length = 0; - break; - - default: - my_operand_length = 2; - printf ("I dn't understand access width %c\n", mywidth); - break; - } - printf ("VAX assembler instruction operand: "); - fflush (stdout); - gets (answer); - mybug = vip_op (answer, myaccess, mywidth, my_operand_length, - &mymode, &myreg, &mylen, &myleft, &myright, &myndx, - &myerr, &mywrn); - if (*myerr) - { - printf ("error: \"%s\"\n", myerr); - if (*mybug) - printf (" bug: \"%s\"\n", mybug); - } - else - { - if (*mywrn) - printf ("warning: \"%s\"\n", mywrn); - mumble ("mode", mymode); - mumble ("register", myreg); - mumble ("index", myndx); - printf ("width:'%c' ", mylen); - printf ("expression: \""); - while (myleft <= myright) - putchar (*myleft++); - printf ("\"\n"); - } - } -} - -mumble (text, value) - char *text; - int value; -{ - printf ("%s:", text); - if (value >= 0) - printf ("%xx", value); - else - printf ("ABSENT"); - printf (" "); -} - -#endif /* ifdef TEST */ - -/* end: vip_op.c */ - -/* end: vax.c */ - -/* JF: new routines */ - -const int md_short_jump_size = 3; - -const int md_long_jump_size = 6; - -void -md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, to_addr; - fragS *frag; - symbolS *to_symbol; -{ - long offset; - - offset = to_addr - (from_addr + 1); - *ptr++ = 0x31; - md_number_to_chars (ptr, offset, 2); -} - -void -md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, to_addr; - fragS *frag; - symbolS *to_symbol; -{ - long offset; - - offset = to_addr - to_symbol->sy_value; - *ptr++ = 0x17; - *ptr++ = 0x9F; - md_number_to_chars (ptr, offset, 4); - fix_new (frag, ptr - frag->fr_literal, 4, to_symbol, (symbolS *) 0, (long int) 0, 0); -} - -int -md_parse_option (argP, cntP, vecP) - char **argP; - int *cntP; - char ***vecP; -{ - char *temp_name; /* name for -t or -d options */ - char opt; - - switch (**argP) - { - case 'J': - /* as_warn ("I can do better than -J!"); */ - break; - - case 'S': - as_warn ("SYMBOL TABLE not implemented"); - break; /* SYMBOL TABLE not implemented */ - - case 'T': - as_warn ("TOKEN TRACE not implemented"); - break; /* TOKEN TRACE not implemented */ - - case 'd': - case 't': - opt= **argP; - if (**argP) - { /* Rest of argument is filename. */ - temp_name = *argP; - while (**argP) - (*argP)++; - } - else if (*cntP) - { - while (**argP) - (*argP)++; - --(*cntP); - temp_name = *++(*vecP); - **vecP = NULL; /* Remember this is not a file-name. */ - } - else - { - as_warn ("I expected a filename after -%c.",opt); - temp_name = "{absent}"; - } - - if(opt=='d') - as_warn ("Displacement length %s ignored!", temp_name); - else - as_warn ("I don't need or use temp. file \"%s\".", temp_name); - break; - - case 'V': - as_warn ("I don't use an interpass file! -V ignored"); - break; - -#ifdef VMS - case '+': /* For g++ */ - break; - - case 'h': /* No hashing of mixed-case names */ - break; - - case 'H': /* Show new symbol after hash truncation */ - break; -#endif - - default: - return 0; - - } - return 1; -} diff --git a/gnu/usr.bin/gas/md.h b/gnu/usr.bin/gas/md.h deleted file mode 100644 index f5bb75e034ee..000000000000 --- a/gnu/usr.bin/gas/md.h +++ /dev/null @@ -1,60 +0,0 @@ -/* md.h -machine dependent- */ - -/* Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of Gas, the GNU Assembler. - -The GNU assembler is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU Assembler General -Public License for full details. - -Everyone is granted permission to copy, modify and redistribute -the GNU Assembler, but only under the conditions described in the -GNU Assembler General Public License. A copy of this license is -supposed to have been given to you along with the GNU Assembler -so you can know your rights and responsibilities. It should be -in a file named COPYING. Among other things, the copyright -notice and this notice must be preserved on all copies. - - $Id: md.h,v 1.2 1993/08/02 17:28:28 mycroft Exp $ -*/ - -/* In theory (mine, at least!) the machine dependent part of the assembler - should only have to include one file. This one. -- JF */ - -/* JF added this here */ -typedef struct { - char * poc_name; /* assembler mnemonic, lower case, no '.' */ - void (*poc_handler)(); /* Do the work */ - int poc_val; /* Value to pass to handler */ -} -pseudo_typeS; -extern const pseudo_typeS md_pseudo_table[]; - -/* JF moved this here from as.h under the theory that nobody except MACHINE.c - and write.c care about it anyway. */ - -typedef struct -{ - long rlx_forward; /* Forward reach. Signed number. > 0. */ - long rlx_backward; /* Backward reach. Signed number. < 0. */ - unsigned char rlx_length; /* Bytes length of this address. */ - relax_substateT rlx_more; /* Next longer relax-state. */ - /* 0 means there is no 'next' relax-state. */ -} -relax_typeS; - -extern const relax_typeS md_relax_table[]; /* Define it in MACHINE.c */ - -char * md_atof(); -void md_assemble(); -void md_begin(); -void md_convert_frag(); -void md_end(); -int md_estimate_size_before_relax(); -void md_number_to_chars(); - -/* end: md.h */ diff --git a/gnu/usr.bin/gas/objrecdef.h b/gnu/usr.bin/gas/objrecdef.h deleted file mode 100644 index b851b4529422..000000000000 --- a/gnu/usr.bin/gas/objrecdef.h +++ /dev/null @@ -1,257 +0,0 @@ -/* - * - * $OBJRECDEF - * Generated automatically by "vms_struct Version 1.00" - * Created from VMS definition file "objrecdef.mar" - * Mon Oct 14 14:01:29 1985 - * - * $Id: objrecdef.h,v 1.2 1993/08/02 17:28:30 mycroft Exp $ - * - */ -struct OBJREC { - unsigned char obj$b_rectyp; - unsigned char obj$b_subtyp; - unsigned char obj$b_mhd_strlv; - unsigned char obj$b_mhd_recsz[2]; - unsigned char obj$t_mhd_name[1]; - }; - -#define OBJ$C_HDR 0 -#define OBJ$C_HDR_MHD 0 -#define OBJ$C_HDR_LNM 1 -#define OBJ$C_HDR_SRC 2 -#define OBJ$C_HDR_TTL 3 -#define OBJ$C_HDR_CPR 4 -#define OBJ$C_HDR_MTC 5 -#define OBJ$C_HDR_GTX 6 -#define OBJ$C_GSD 1 -#define OBJ$C_GSD_PSC 0 -#define OBJ$C_GSD_SYM 1 -#define OBJ$C_GSD_EPM 2 -#define OBJ$C_GSD_PRO 3 -#define OBJ$C_GSD_SYMW 4 -#define OBJ$C_GSD_EPMW 5 -#define OBJ$C_GSD_PROW 6 -#define OBJ$C_GSD_IDC 7 -#define OBJ$C_GSD_ENV 8 -#define OBJ$C_GSD_LSY 9 -#define OBJ$C_GSD_LEPM 10 -#define OBJ$C_GSD_LPRO 11 -#define OBJ$C_GSD_SPSC 12 -#define OBJ$C_TIR 2 -#define OBJ$C_EOM 3 -#define OBJ$C_DBG 4 -#define OBJ$C_TBT 5 -#define OBJ$C_LNK 6 -#define OBJ$C_EOMW 7 -#define OBJ$C_MAXRECTYP 7 -#define OBJ$K_SUBTYP 1 -#define OBJ$C_SUBTYP 1 -#define OBJ$C_MAXRECSIZ 2048 -#define OBJ$C_STRLVL 0 -#define OBJ$C_SYMSIZ 31 -#define OBJ$C_STOREPLIM -1 -#define OBJ$C_PSCALILIM 9 - -#define MHD$C_MHD 0 -#define MHD$C_LNM 1 -#define MHD$C_SRC 2 -#define MHD$C_TTL 3 -#define MHD$C_CPR 4 -#define MHD$C_MTC 5 -#define MHD$C_GTX 6 -#define MHD$C_MAXHDRTYP 6 - -#define GSD$K_ENTRIES 1 -#define GSD$C_ENTRIES 1 -#define GSD$C_PSC 0 -#define GSD$C_SYM 1 -#define GSD$C_EPM 2 -#define GSD$C_PRO 3 -#define GSD$C_SYMW 4 -#define GSD$C_EPMW 5 -#define GSD$C_PROW 6 -#define GSD$C_IDC 7 -#define GSD$C_ENV 8 -#define GSD$C_LSY 9 -#define GSD$C_LEPM 10 -#define GSD$C_LPRO 11 -#define GSD$C_SPSC 12 -#define GSD$C_SYMV 13 -#define GSD$C_EPMV 14 -#define GSD$C_PROV 15 -#define GSD$C_MAXRECTYP 15 - -#define GSY$M_WEAK 1 -#define GSY$M_DEF 2 -#define GSY$M_UNI 4 -#define GSY$M_REL 8 - -#define GPS$M_PIC 1 -#define GPS$M_LIB 2 -#define GPS$M_OVR 4 -#define GPS$M_REL 8 -#define GPS$M_GBL 16 -#define GPS$M_SHR 32 -#define GPS$M_EXE 64 -#define GPS$M_RD 128 -#define GPS$M_WRT 256 -#define GPS$M_VEC 512 -#define GPS$K_NAME 9 -#define GPS$C_NAME 9 - -#define TIR$C_STA_GBL 0 -#define TIR$C_STA_SB 1 -#define TIR$C_STA_SW 2 -#define TIR$C_STA_LW 3 -#define TIR$C_STA_PB 4 -#define TIR$C_STA_PW 5 -#define TIR$C_STA_PL 6 -#define TIR$C_STA_UB 7 -#define TIR$C_STA_UW 8 -#define TIR$C_STA_BFI 9 -#define TIR$C_STA_WFI 10 -#define TIR$C_STA_LFI 11 -#define TIR$C_STA_EPM 12 -#define TIR$C_STA_CKARG 13 -#define TIR$C_STA_WPB 14 -#define TIR$C_STA_WPW 15 -#define TIR$C_STA_WPL 16 -#define TIR$C_STA_LSY 17 -#define TIR$C_STA_LIT 18 -#define TIR$C_STA_LEPM 19 -#define TIR$C_MAXSTACOD 19 -#define TIR$C_MINSTOCOD 20 -#define TIR$C_STO_SB 20 -#define TIR$C_STO_SW 21 -#define TIR$C_STO_L 22 -#define TIR$C_STO_BD 23 -#define TIR$C_STO_WD 24 -#define TIR$C_STO_LD 25 -#define TIR$C_STO_LI 26 -#define TIR$C_STO_PIDR 27 -#define TIR$C_STO_PICR 28 -#define TIR$C_STO_RSB 29 -#define TIR$C_STO_RSW 30 -#define TIR$C_STO_RL 31 -#define TIR$C_STO_VPS 32 -#define TIR$C_STO_USB 33 -#define TIR$C_STO_USW 34 -#define TIR$C_STO_RUB 35 -#define TIR$C_STO_RUW 36 -#define TIR$C_STO_B 37 -#define TIR$C_STO_W 38 -#define TIR$C_STO_RB 39 -#define TIR$C_STO_RW 40 -#define TIR$C_STO_RIVB 41 -#define TIR$C_STO_PIRR 42 -#define TIR$C_MAXSTOCOD 42 -#define TIR$C_MINOPRCOD 50 -#define TIR$C_OPR_NOP 50 -#define TIR$C_OPR_ADD 51 -#define TIR$C_OPR_SUB 52 -#define TIR$C_OPR_MUL 53 -#define TIR$C_OPR_DIV 54 -#define TIR$C_OPR_AND 55 -#define TIR$C_OPR_IOR 56 -#define TIR$C_OPR_EOR 57 -#define TIR$C_OPR_NEG 58 -#define TIR$C_OPR_COM 59 -#define TIR$C_OPR_INSV 60 -#define TIR$C_OPR_ASH 61 -#define TIR$C_OPR_USH 62 -#define TIR$C_OPR_ROT 63 -#define TIR$C_OPR_SEL 64 -#define TIR$C_OPR_REDEF 65 -#define TIR$C_OPR_DFLIT 66 -#define TIR$C_MAXOPRCOD 66 -#define TIR$C_MINCTLCOD 80 -#define TIR$C_CTL_SETRB 80 -#define TIR$C_CTL_AUGRB 81 -#define TIR$C_CTL_DFLOC 82 -#define TIR$C_CTL_STLOC 83 -#define TIR$C_CTL_STKDL 84 -#define TIR$C_MAXCTLCOD 84 - -/* - * Debugger symbol definitions: These are done by hand, as no - * machine-readable version seems - * to be available. - */ -#define DST$C_C 7 /* Language == "C" */ -#define DST$C_VERSION 153 -#define DST$C_SOURCE 155 /* Source file */ -#define DST$C_PROLOG 162 -#define DST$C_BLKBEG 176 /* Beginning of block */ -#define DST$C_BLKEND 177 /* End of block */ -#define DST$C_ENTRY 181 -#define DST$C_PSECT 184 -#define DST$C_LINE_NUM 185 /* Line Number */ -#define DST$C_LBLORLIT 186 -#define DST$C_LABEL 187 -#define DST$C_MODBEG 188 /* Beginning of module */ -#define DST$C_MODEND 189 /* End of module */ -#define DST$C_RTNBEG 190 /* Beginning of routine */ -#define DST$C_RTNEND 191 /* End of routine */ -#define DST$C_DELTA_PC_W 1 /* Incr PC */ -#define DST$C_INCR_LINUM 2 /* Incr Line # */ -#define DST$C_INCR_LINUM_W 3 /* Incr Line # */ -#define DST$C_SET_LINUM_INCR 4 -#define DST$C_SET_LINUM_INCR_W 5 -#define DST$C_RESET_LINUM_INCR 6 -#define DST$C_BEG_STMT_MODE 7 -#define DST$C_END_STMT_MODE 8 -#define DST$C_SET_LINE_NUM 9 /* Set Line # */ -#define DST$C_SET_PC 10 -#define DST$C_SET_PC_W 11 -#define DST$C_SET_PC_L 12 -#define DST$C_SET_STMTNUM 13 -#define DST$C_TERM 14 /* End of lines */ -#define DST$C_TERM_W 15 /* End of lines */ -#define DST$C_SET_ABS_PC 16 /* Set PC */ -#define DST$C_DELTA_PC_L 17 /* Incr PC */ -#define DST$C_INCR_LINUM_L 18 /* Incr Line # */ -#define DST$C_SET_LINUM_B 19 /* Set Line # */ -#define DST$C_SET_LINUM_L 20 /* Set Line # */ -#define DST$C_TERM_L 21 /* End of lines */ -/* these are used with DST$C_SOURCE */ -#define DST$C_SRC_FORMFEED 16 /* ^L counts */ -#define DST$C_SRC_DECLFILE 1 /* Declare file */ -#define DST$C_SRC_SETFILE 2 /* Set file */ -#define DST$C_SRC_SETREC_L 3 /* Set record */ -#define DST$C_SRC_DEFLINES_W 10 /* # of line */ -/* the following are the codes for the various data types. Anything not on - * the list is included under 'advanced_type' - */ -#define DBG$C_UCHAR 0x02 -#define DBG$C_USINT 0x03 -#define DBG$C_ULINT 0x04 -#define DBG$C_SCHAR 0x06 -#define DBG$C_SSINT 0x07 -#define DBG$C_SLINT 0x08 -#define DBG$C_REAL4 0x0a -#define DBG$C_REAL8 0x0b -#define DBG$C_FUNCTION_ADDR 0x17 -#define DBG$C_ADVANCED_TYPE 0xa3 -/* These are the codes that are used to generate the definitions of struct - * union and enum records - */ -#define DBG$C_ENUM_ITEM 0xa4 -#define DBG$C_ENUM_START 0xa5 -#define DBG$C_ENUM_END 0xa6 -#define DBG$C_STRUCT_START 0xab -#define DBG$C_STRUCT_ITEM 0xff -#define DBG$C_STRUCT_END 0xac -/* These are the codes that are used in the suffix records to determine the - * actual data type - */ -#define DBG$C_BASIC 0x01 -#define DBG$C_BASIC_ARRAY 0x02 -#define DBG$C_STRUCT 0x03 -#define DBG$C_POINTER 0x04 -#define DBG$C_VOID 0x05 -#define DBG$C_COMPLEX_ARRAY 0x07 -/* These codes are used in the generation of the symbol definition records - */ -#define DBG$C_FUNCTION_PARAMETER 0xc9 -#define DBG$C_LOCAL_SYM 0xd9 diff --git a/gnu/usr.bin/gawk-2.15.2/POSIX b/gnu/usr.bin/gawk-2.15.2/POSIX deleted file mode 100644 index f2405420aedf..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/POSIX +++ /dev/null @@ -1,95 +0,0 @@ -Right now, the numeric vs. string comparisons are screwed up in draft -11.2. What prompted me to check it out was the note in gnu.bug.utils -which observed that gawk was doing the comparison $1 == "000" -numerically. I think that we can agree that intuitively, this should -be done as a string comparison. Version 2.13.2 of gawk follows the -current POSIX draft. Following is how I (now) think this -stuff should be done. - -1. A numeric literal or the result of a numeric operation has the NUMERIC - attribute. - -2. A string literal or the result of a string operation has the STRING - attribute. - -3. Fields, getline input, FILENAME, ARGV elements, ENVIRON elements and the - elements of an array created by split() that are numeric strings - have the STRNUM attribute. Otherwise, they have the STRING attribute. - Uninitialized variables also have the STRNUM attribute. - -4. Attributes propagate across assignments, but are not changed by - any use. (Although a use may cause the entity to acquire an additional - value such that it has both a numeric and string value -- this leaves the - attribute unchanged.) - -When two operands are compared, either string comparison or numeric comparison -may be used, depending on the attributes of the operands, according to the -following (symmetric) matrix: - - +---------------------------------------------- - | STRING NUMERIC STRNUM ---------+---------------------------------------------- - | -STRING | string string string - | -NUMERIC | string numeric numeric - | -STRNUM | string numeric numeric ---------+---------------------------------------------- - -So, the following program should print all OKs. - -echo '0e2 0a 0 0b -0e2 0a 0 0b' | -$AWK ' -NR == 1 { - num = 0 - str = "0e2" - - print ++test ": " ( (str == "0e2") ? "OK" : "OOPS" ) - print ++test ": " ( ("0e2" != 0) ? "OK" : "OOPS" ) - print ++test ": " ( ("0" != $2) ? "OK" : "OOPS" ) - print ++test ": " ( ("0e2" == $1) ? "OK" : "OOPS" ) - - print ++test ": " ( (0 == "0") ? "OK" : "OOPS" ) - print ++test ": " ( (0 == num) ? "OK" : "OOPS" ) - print ++test ": " ( (0 != $2) ? "OK" : "OOPS" ) - print ++test ": " ( (0 == $1) ? "OK" : "OOPS" ) - - print ++test ": " ( ($1 != "0") ? "OK" : "OOPS" ) - print ++test ": " ( ($1 == num) ? "OK" : "OOPS" ) - print ++test ": " ( ($2 != 0) ? "OK" : "OOPS" ) - print ++test ": " ( ($2 != $1) ? "OK" : "OOPS" ) - print ++test ": " ( ($3 == 0) ? "OK" : "OOPS" ) - print ++test ": " ( ($3 == $1) ? "OK" : "OOPS" ) - print ++test ": " ( ($2 != $4) ? "OK" : "OOPS" ) # 15 -} -{ - a = "+2" - b = 2 - if (NR % 2) - c = a + b - print ++test ": " ( (a != b) ? "OK" : "OOPS" ) # 16 and 22 - - d = "2a" - b = 2 - if (NR % 2) - c = d + b - print ++test ": " ( (d != b) ? "OK" : "OOPS" ) - - print ++test ": " ( (d + 0 == b) ? "OK" : "OOPS" ) - - e = "2" - print ++test ": " ( (e == b "") ? "OK" : "OOPS" ) - - a = "2.13" - print ++test ": " ( (a == 2.13) ? "OK" : "OOPS" ) - - a = "2.130000" - print ++test ": " ( (a != 2.13) ? "OK" : "OOPS" ) - - if (NR == 2) { - CONVFMT = "%.6f" - print ++test ": " ( (a == 2.13) ? "OK" : "OOPS" ) - } -}' diff --git a/gnu/usr.bin/gawk-2.15.2/PROBLEMS b/gnu/usr.bin/gawk-2.15.2/PROBLEMS deleted file mode 100644 index 3b7c5148bd8e..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/PROBLEMS +++ /dev/null @@ -1,6 +0,0 @@ -This is a list of known problems in gawk 2.15. -Hopefully they will all be fixed in the next major release of gawk. - -Please keep in mind that the code is still undergoing significant evolution. - -1. Gawk's printf is probably still not POSIX compliant. diff --git a/gnu/usr.bin/gawk-2.15.2/README b/gnu/usr.bin/gawk-2.15.2/README deleted file mode 100644 index f4bd3df806c8..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/README +++ /dev/null @@ -1,116 +0,0 @@ -README: - -This is GNU Awk 2.15. It should be upwardly compatible with the -System V Release 4 awk. It is almost completely compliant with draft 11.3 -of POSIX 1003.2. - -This release adds new features -- see NEWS for details. - -See the installation instructions, below. - -Known problems are given in the PROBLEMS file. Work to be done is -described briefly in the FUTURES file. Verified ports are listed in -the PORTS file. Changes in this version are summarized in the CHANGES file. -Please read the LIMITATIONS and ACKNOWLEDGMENT files. - -Read the file POSIX for a discussion of how the standard says comparisons -should be done vs. how they really should be done and how gawk does them. - -To format the documentation with TeX, you must use texinfo.tex 2.53 -or later. Otherwise footnotes look unacceptable. - -If you wish to remake the Info files, you should use makeinfo. The 2.15 -version of makeinfo works with no errors. - -The man page is up to date. - -INSTALLATION: - -Check whether there is a system-specific README file for your system. - -Makefile.in may need some tailoring. The only changes necessary should -be to change installation targets or to change compiler flags. -The changes to make in Makefile.in are commented and should be obvious. - -All other changes should be made in a config file. Samples for -various systems are included in the config directory. Starting with -2.11, our intent has been to make the code conform to standards (ANSI, -POSIX, SVID, in that order) whenever possible, and to not penalize -standard conforming systems. We have included substitute versions of -routines not universally available. Simply add the appropriate define -for the missing feature(s) on your system. - -If you have neither bison nor yacc, use the awktab.c file here. It was -generated with bison, and should have no AT&T code in it. (Note that -modifying awk.y without bison or yacc will be difficult, at best. You might -want to get a copy of bison from the FSF too.) - -If no config file is included for your system, start by copying one -for a similar system. One way of determining the defines needed is to -try to load gawk with nothing defined and see what routines are -unresolved by the loader. This should give you a good idea of how to -proceed. - -The next release will use the FSF autoconfig program, so we are no longer -soliciting new config files. - -If you have an MS-DOS system, use the stuff in the pc directory. -For an Atari there is an atari directory and similarly one for VMS. - -Chapter 16 of The GAWK Manual discusses configuration in detail. - -After successful compilation, do 'make test' to run a small test -suite. There should be no output from the 'cmp' invocations except in -the cases where there are small differences in floating point values. -If there are other differences, please investigate and report the -problem. - -PRINTING THE MANUAL - -The 'support' directory contains texinfo.tex 2.65, which will be necessary -for printing the manual, and the texindex.c program from the texinfo -distribution which is also necessary. See the makefile for the steps needed -to get a DVI file from the manual. - -CAVEATS - -The existence of a patchlevel.h file does *N*O*T* imply a commitment on -our part to issue bug fixes or patches. It is there in case we should -decide to do so. - -BUG REPORTS AND FIXES (Un*x systems): - -Please coordinate changes through David Trueman and/or Arnold Robbins. - -David Trueman -Department of Mathematics, Statistics and Computing Science, -Dalhousie University, Halifax, Nova Scotia, Canada - -UUCP: {uunet utai watmath}!dalcs!david -INTERNET: david@cs.dal.ca - -Arnold Robbins -1736 Reindeer Drive -Atlanta, GA, 30329, USA - -INTERNET: arnold@skeeve.atl.ga.us -UUCP: { gatech, emory, emoryu1 }!skeeve!arnold - -BUG REPORTS AND FIXES (non-Unix ports): - -MS-DOS: - Scott Deifik - AMGEN Inc. - Amgen Center, Bldg.17-Dept.393 - Thousand Oaks, CA 91320-1789 - Tel-805-499-5725 ext.4677 - Fax-805-498-0358 - scottd@amgen.com - -VMS: - Pat Rankin - rankin@eql.caltech.edu (e-mail only) - -Atari ST: - Michal Jaegermann - NTOMCZAK@vm.ucs.UAlberta.CA (e-mail only) diff --git a/gnu/usr.bin/gawk-2.15.2/array.c b/gnu/usr.bin/gawk-2.15.2/array.c deleted file mode 100644 index 59be340c04df..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/array.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * array.c - routines for associative arrays. - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "awk.h" - -static NODE *assoc_find P((NODE *symbol, NODE *subs, int hash1)); - -NODE * -concat_exp(tree) -register NODE *tree; -{ - register NODE *r; - char *str; - char *s; - unsigned len; - int offset; - int subseplen; - char *subsep; - - if (tree->type != Node_expression_list) - return force_string(tree_eval(tree)); - r = force_string(tree_eval(tree->lnode)); - if (tree->rnode == NULL) - return r; - subseplen = SUBSEP_node->lnode->stlen; - subsep = SUBSEP_node->lnode->stptr; - len = r->stlen + subseplen + 2; - emalloc(str, char *, len, "concat_exp"); - memcpy(str, r->stptr, r->stlen+1); - s = str + r->stlen; - free_temp(r); - tree = tree->rnode; - while (tree) { - if (subseplen == 1) - *s++ = *subsep; - else { - memcpy(s, subsep, subseplen+1); - s += subseplen; - } - r = force_string(tree_eval(tree->lnode)); - len += r->stlen + subseplen; - offset = s - str; - erealloc(str, char *, len, "concat_exp"); - s = str + offset; - memcpy(s, r->stptr, r->stlen+1); - s += r->stlen; - free_temp(r); - tree = tree->rnode; - } - r = make_str_node(str, s - str, ALREADY_MALLOCED); - r->flags |= TEMP; - return r; -} - -/* Flush all the values in symbol[] before doing a split() */ -void -assoc_clear(symbol) -NODE *symbol; -{ - int i; - NODE *bucket, *next; - - if (symbol->var_array == 0) - return; - for (i = 0; i < HASHSIZE; i++) { - for (bucket = symbol->var_array[i]; bucket; bucket = next) { - next = bucket->ahnext; - unref(bucket->ahname); - unref(bucket->ahvalue); - freenode(bucket); - } - symbol->var_array[i] = 0; - } -} - -/* - * calculate the hash function of the string in subs - */ -unsigned int -hash(s, len) -register char *s; -register int len; -{ - register unsigned long h = 0, g; - - while (len--) { - h = (h << 4) + *s++; - g = (h & 0xf0000000); - if (g) { - h = h ^ (g >> 24); - h = h ^ g; - } - } - if (h < HASHSIZE) - return h; - else - return h%HASHSIZE; -} - -/* - * locate symbol[subs] - */ -static NODE * /* NULL if not found */ -assoc_find(symbol, subs, hash1) -NODE *symbol; -register NODE *subs; -int hash1; -{ - register NODE *bucket, *prev = 0; - - for (bucket = symbol->var_array[hash1]; bucket; bucket = bucket->ahnext) { - if (cmp_nodes(bucket->ahname, subs) == 0) { - if (prev) { /* move found to front of chain */ - prev->ahnext = bucket->ahnext; - bucket->ahnext = symbol->var_array[hash1]; - symbol->var_array[hash1] = bucket; - } - return bucket; - } else - prev = bucket; /* save previous list entry */ - } - return NULL; -} - -/* - * test whether the array element symbol[subs] exists or not - */ -int -in_array(symbol, subs) -NODE *symbol, *subs; -{ - register int hash1; - - if (symbol->type == Node_param_list) - symbol = stack_ptr[symbol->param_cnt]; - if (symbol->var_array == 0) - return 0; - subs = concat_exp(subs); /* concat_exp returns a string node */ - hash1 = hash(subs->stptr, subs->stlen); - if (assoc_find(symbol, subs, hash1) == NULL) { - free_temp(subs); - return 0; - } else { - free_temp(subs); - return 1; - } -} - -/* - * SYMBOL is the address of the node (or other pointer) being dereferenced. - * SUBS is a number or string used as the subscript. - * - * Find SYMBOL[SUBS] in the assoc array. Install it with value "" if it - * isn't there. Returns a pointer ala get_lhs to where its value is stored - */ -NODE ** -assoc_lookup(symbol, subs) -NODE *symbol, *subs; -{ - register int hash1; - register NODE *bucket; - - (void) force_string(subs); - hash1 = hash(subs->stptr, subs->stlen); - - if (symbol->var_array == 0) { /* this table really should grow - * dynamically */ - unsigned size; - - size = sizeof(NODE *) * HASHSIZE; - emalloc(symbol->var_array, NODE **, size, "assoc_lookup"); - memset((char *)symbol->var_array, 0, size); - symbol->type = Node_var_array; - } else { - bucket = assoc_find(symbol, subs, hash1); - if (bucket != NULL) { - free_temp(subs); - return &(bucket->ahvalue); - } - } - - /* It's not there, install it. */ - if (do_lint && subs->stlen == 0) - warning("subscript of array `%s' is null string", - symbol->vname); - getnode(bucket); - bucket->type = Node_ahash; - if (subs->flags & TEMP) - bucket->ahname = dupnode(subs); - else { - unsigned int saveflags = subs->flags; - - subs->flags &= ~MALLOC; - bucket->ahname = dupnode(subs); - subs->flags = saveflags; - } - free_temp(subs); - - /* array subscripts are strings */ - bucket->ahname->flags &= ~NUMBER; - bucket->ahname->flags |= STRING; - bucket->ahvalue = Nnull_string; - bucket->ahnext = symbol->var_array[hash1]; - symbol->var_array[hash1] = bucket; - return &(bucket->ahvalue); -} - -void -do_delete(symbol, tree) -NODE *symbol, *tree; -{ - register int hash1; - register NODE *bucket, *last; - NODE *subs; - - if (symbol->type == Node_param_list) - symbol = stack_ptr[symbol->param_cnt]; - if (symbol->var_array == 0) - return; - subs = concat_exp(tree); /* concat_exp returns string node */ - hash1 = hash(subs->stptr, subs->stlen); - - last = NULL; - for (bucket = symbol->var_array[hash1]; bucket; last = bucket, bucket = bucket->ahnext) - if (cmp_nodes(bucket->ahname, subs) == 0) - break; - free_temp(subs); - if (bucket == NULL) - return; - if (last) - last->ahnext = bucket->ahnext; - else - symbol->var_array[hash1] = bucket->ahnext; - unref(bucket->ahname); - unref(bucket->ahvalue); - freenode(bucket); -} - -void -assoc_scan(symbol, lookat) -NODE *symbol; -struct search *lookat; -{ - if (!symbol->var_array) { - lookat->retval = NULL; - return; - } - lookat->arr_ptr = symbol->var_array; - lookat->arr_end = lookat->arr_ptr + HASHSIZE; /* added */ - lookat->bucket = symbol->var_array[0]; - assoc_next(lookat); -} - -void -assoc_next(lookat) -struct search *lookat; -{ - while (lookat->arr_ptr < lookat->arr_end) { - if (lookat->bucket != 0) { - lookat->retval = lookat->bucket->ahname; - lookat->bucket = lookat->bucket->ahnext; - return; - } - lookat->arr_ptr++; - if (lookat->arr_ptr < lookat->arr_end) - lookat->bucket = *(lookat->arr_ptr); - else - lookat->retval = NULL; - } - return; -} diff --git a/gnu/usr.bin/gawk-2.15.2/awk.1 b/gnu/usr.bin/gawk-2.15.2/awk.1 deleted file mode 100644 index 0338485e8db8..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/awk.1 +++ /dev/null @@ -1,1873 +0,0 @@ -.ds PX \s-1POSIX\s+1 -.ds UX \s-1UNIX\s+1 -.ds AN \s-1ANSI\s+1 -.TH GAWK 1 "Apr 15 1993" "Free Software Foundation" "Utility Commands" -.SH NAME -gawk \- pattern scanning and processing language -.SH SYNOPSIS -.B gawk -[ POSIX or GNU style options ] -.B \-f -.I program-file -[ -.B \-\^\- -] file .\^.\^. -.br -.B gawk -[ POSIX or GNU style options ] -[ -.B \-\^\- -] -.I program-text -file .\^.\^. -.SH DESCRIPTION -.I Gawk -is the GNU Project's implementation of the AWK programming language. -It conforms to the definition of the language in -the \*(PX 1003.2 Command Language And Utilities Standard. -This version in turn is based on the description in -.IR "The AWK Programming Language" , -by Aho, Kernighan, and Weinberger, -with the additional features defined in the System V Release 4 version -of \*(UX -.IR awk . -.I Gawk -also provides some GNU-specific extensions. -.PP -The command line consists of options to -.I gawk -itself, the AWK program text (if not supplied via the -.B \-f -or -.B \-\^\-file -options), and values to be made -available in the -.B ARGC -and -.B ARGV -pre-defined AWK variables. -.SH OPTIONS -.PP -.I Gawk -options may be either the traditional \*(PX one letter options, -or the GNU style long options. \*(PX style options start with a single ``\-'', -while GNU long options start with ``\-\^\-''. -GNU style long options are provided for both GNU-specific features and -for \*(PX mandated features. Other implementations of the AWK language -are likely to only accept the traditional one letter options. -.PP -Following the \*(PX standard, -.IR gawk -specific -options are supplied via arguments to the -.B \-W -option. Multiple -.B \-W -options may be supplied, or multiple arguments may be supplied together -if they are separated by commas, or enclosed in quotes and separated -by white space. -Case is ignored in arguments to the -.B \-W -option. -Each -.B \-W -option has a corresponding GNU style long option, as detailed below. -.PP -.I Gawk -accepts the following options. -.TP -.PD 0 -.BI \-F " fs" -.TP -.PD -.BI \-\^\-field-separator= fs -Use -.I fs -for the input field separator (the value of the -.B FS -predefined -variable). -.TP -.PD 0 -\fB\-v\fI var\fB\^=\^\fIval\fR -.TP -.PD -\fB\-\^\-assign=\fIvar\fB\^=\^\fIval\fR -Assign the value -.IR val , -to the variable -.IR var , -before execution of the program begins. -Such variable values are available to the -.B BEGIN -block of an AWK program. -.TP -.PD 0 -.BI \-f " program-file" -.TP -.PD -.BI \-\^\-file= program-file -Read the AWK program source from the file -.IR program-file , -instead of from the first command line argument. -Multiple -.B \-f -(or -.BR \-\^\-file ) -options may be used. -.TP \w'\fB\-\^\-copyright\fR'u+1n -.PD 0 -.B "\-W compat" -.TP -.PD -.B \-\^\-compat -Run in -.I compatibility -mode. In compatibility mode, -.I gawk -behaves identically to \*(UX -.IR awk ; -none of the GNU-specific extensions are recognized. -See -.BR "GNU EXTENSIONS" , -below, for more information. -.TP -.PD 0 -.B "\-W copyleft" -.TP -.PD 0 -.B "\-W copyright" -.TP -.PD 0 -.B \-\^\-copyleft -.TP -.PD -.B \-\^\-copyright -Print the short version of the GNU copyright information message on -the error output. -.TP -.PD 0 -.B "\-W help" -.TP -.PD 0 -.B "\-W usage" -.TP -.PD 0 -.B \-\^\-help -.TP -.PD -.B \-\^\-usage -Print a relatively short summary of the available options on -the error output. -.TP -.PD 0 -.B "\-W lint" -.TP -.PD 0 -.B \-\^\-lint -Provide warnings about constructs that are -dubious or non-portable to other AWK implementations. -.ig -.\" This option is left undocumented, on purpose. -.TP -.PD 0 -.B "\-W nostalgia" -.TP -.PD -.B \-\^\-nostalgia -Provide a moment of nostalgia for long time -.I awk -users. -.. -.TP -.PD 0 -.B "\-W posix" -.TP -.PD -.B \-\^\-posix -This turns on -.I compatibility -mode, with the following additional restrictions: -.RS -.TP \w'\(bu'u+1n -\(bu -.B \ex -escape sequences are not recognized. -.TP -\(bu -The synonym -.B func -for the keyword -.B function -is not recognized. -.TP -\(bu -The operators -.B ** -and -.B **= -cannot be used in place of -.B ^ -and -.BR ^= . -.RE -.TP -.PD 0 -.BI "\-W source=" program-text -.TP -.PD -.BI \-\^\-source= program-text -Use -.I program-text -as AWK program source code. -This option allows the easy intermixing of library functions (used via the -.B \-f -and -.B \-\^\-file -options) with source code entered on the command line. -It is intended primarily for medium to large size AWK programs used -in shell scripts. -.sp .5 -The -.B "\-W source=" -form of this option uses the rest of the command line argument for -.IR program-text ; -no other options to -.B \-W -will be recognized in the same argument. -.TP -.PD 0 -.B "\-W version" -.TP -.PD -.B \-\^\-version -Print version information for this particular copy of -.I gawk -on the error output. -This is useful mainly for knowing if the current copy of -.I gawk -on your system -is up to date with respect to whatever the Free Software Foundation -is distributing. -.TP -.B \-\^\- -Signal the end of options. This is useful to allow further arguments to the -AWK program itself to start with a ``\-''. -This is mainly for consistency with the argument parsing convention used -by most other \*(PX programs. -.PP -Any other options are flagged as illegal, but are otherwise ignored. -.SH AWK PROGRAM EXECUTION -.PP -An AWK program consists of a sequence of pattern-action statements -and optional function definitions. -.RS -.PP -\fIpattern\fB { \fIaction statements\fB }\fR -.br -\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements\fB }\fR -.RE -.PP -.I Gawk -first reads the program source from the -.IR program-file (s) -if specified, or from the first non-option argument on the command line. -The -.B \-f -option may be used multiple times on the command line. -.I Gawk -will read the program text as if all the -.IR program-file s -had been concatenated together. This is useful for building libraries -of AWK functions, without having to include them in each new AWK -program that uses them. To use a library function in a file from a -program typed in on the command line, specify -.B /dev/tty -as one of the -.IR program-file s, -type your program, and end it with a -.B ^D -(control-d). -.PP -The environment variable -.B AWKPATH -specifies a search path to use when finding source files named with -the -.B \-f -option. If this variable does not exist, the default path is -\fB".:/usr/lib/awk:/usr/local/lib/awk"\fR. -If a file name given to the -.B \-f -option contains a ``/'' character, no path search is performed. -.PP -.I Gawk -executes AWK programs in the following order. -First, -.I gawk -compiles the program into an internal form. -Next, all variable assignments specified via the -.B \-v -option are performed. Then, -.I gawk -executes the code in the -.B BEGIN -block(s) (if any), -and then proceeds to read -each file named in the -.B ARGV -array. -If there are no files named on the command line, -.I gawk -reads the standard input. -.PP -If a filename on the command line has the form -.IB var = val -it is treated as a variable assignment. The variable -.I var -will be assigned the value -.IR val . -(This happens after any -.B BEGIN -block(s) have been run.) -Command line variable assignment -is most useful for dynamically assigning values to the variables -AWK uses to control how input is broken into fields and records. It -is also useful for controlling state if multiple passes are needed over -a single data file. -.PP -If the value of a particular element of -.B ARGV -is empty (\fB""\fR), -.I gawk -skips over it. -.PP -For each line in the input, -.I gawk -tests to see if it matches any -.I pattern -in the AWK program. -For each pattern that the line matches, the associated -.I action -is executed. -The patterns are tested in the order they occur in the program. -.PP -Finally, after all the input is exhausted, -.I gawk -executes the code in the -.B END -block(s) (if any). -.SH VARIABLES AND FIELDS -AWK variables are dynamic; they come into existence when they are -first used. Their values are either floating-point numbers or strings, -or both, -depending upon how they are used. AWK also has one dimension -arrays; multiply dimensioned arrays may be simulated. -Several pre-defined variables are set as a program -runs; these will be described as needed and summarized below. -.SS Fields -.PP -As each input line is read, -.I gawk -splits the line into -.IR fields , -using the value of the -.B FS -variable as the field separator. -If -.B FS -is a single character, fields are separated by that character. -Otherwise, -.B FS -is expected to be a full regular expression. -In the special case that -.B FS -is a single blank, fields are separated -by runs of blanks and/or tabs. -Note that the value of -.B IGNORECASE -(see below) will also affect how fields are split when -.B FS -is a regular expression. -.PP -If the -.B FIELDWIDTHS -variable is set to a space separated list of numbers, each field is -expected to have fixed width, and -.I gawk -will split up the record using the specified widths. The value of -.B FS -is ignored. -Assigning a new value to -.B FS -overrides the use of -.BR FIELDWIDTHS , -and restores the default behavior. -.PP -Each field in the input line may be referenced by its position, -.BR $1 , -.BR $2 , -and so on. -.B $0 -is the whole line. The value of a field may be assigned to as well. -Fields need not be referenced by constants: -.RS -.PP -.ft B -n = 5 -.br -print $n -.ft R -.RE -.PP -prints the fifth field in the input line. -The variable -.B NF -is set to the total number of fields in the input line. -.PP -References to non-existent fields (i.e. fields after -.BR $NF ) -produce the null-string. However, assigning to a non-existent field -(e.g., -.BR "$(NF+2) = 5" ) -will increase the value of -.BR NF , -create any intervening fields with the null string as their value, and -cause the value of -.B $0 -to be recomputed, with the fields being separated by the value of -.BR OFS . -.SS Built-in Variables -.PP -AWK's built-in variables are: -.PP -.TP \w'\fBFIELDWIDTHS\fR'u+1n -.B ARGC -The number of command line arguments (does not include options to -.IR gawk , -or the program source). -.TP -.B ARGIND -The index in -.B ARGV -of the current file being processed. -.TP -.B ARGV -Array of command line arguments. The array is indexed from -0 to -.B ARGC -\- 1. -Dynamically changing the contents of -.B ARGV -can control the files used for data. -.TP -.B CONVFMT -The conversion format for numbers, \fB"%.6g"\fR, by default. -.TP -.B ENVIRON -An array containing the values of the current environment. -The array is indexed by the environment variables, each element being -the value of that variable (e.g., \fBENVIRON["HOME"]\fP might be -.BR /u/arnold ). -Changing this array does not affect the environment seen by programs which -.I gawk -spawns via redirection or the -.B system() -function. -(This may change in a future version of -.IR gawk .) -.\" but don't hold your breath... -.TP -.B ERRNO -If a system error occurs either doing a redirection for -.BR getline , -during a read for -.BR getline , -or during a -.BR close , -then -.B ERRNO -will contain -a string describing the error. -.TP -.B FIELDWIDTHS -A white-space separated list of fieldwidths. When set, -.I gawk -parses the input into fields of fixed width, instead of using the -value of the -.B FS -variable as the field separator. -The fixed field width facility is still experimental; expect the -semantics to change as -.I gawk -evolves over time. -.TP -.B FILENAME -The name of the current input file. -If no files are specified on the command line, the value of -.B FILENAME -is ``\-''. -.TP -.B FNR -The input record number in the current input file. -.TP -.B FS -The input field separator, a blank by default. -.TP -.B IGNORECASE -Controls the case-sensitivity of all regular expression operations. If -.B IGNORECASE -has a non-zero value, then pattern matching in rules, -field splitting with -.BR FS , -regular expression -matching with -.B ~ -and -.BR !~ , -and the -.BR gsub() , -.BR index() , -.BR match() , -.BR split() , -and -.B sub() -pre-defined functions will all ignore case when doing regular expression -operations. Thus, if -.B IGNORECASE -is not equal to zero, -.B /aB/ -matches all of the strings \fB"ab"\fP, \fB"aB"\fP, \fB"Ab"\fP, -and \fB"AB"\fP. -As with all AWK variables, the initial value of -.B IGNORECASE -is zero, so all regular expression operations are normally case-sensitive. -.TP -.B NF -The number of fields in the current input record. -.TP -.B NR -The total number of input records seen so far. -.TP -.B OFMT -The output format for numbers, \fB"%.6g"\fR, by default. -.TP -.B OFS -The output field separator, a blank by default. -.TP -.B ORS -The output record separator, by default a newline. -.TP -.B RS -The input record separator, by default a newline. -.B RS -is exceptional in that only the first character of its string -value is used for separating records. -(This will probably change in a future release of -.IR gawk .) -If -.B RS -is set to the null string, then records are separated by -blank lines. -When -.B RS -is set to the null string, then the newline character always acts as -a field separator, in addition to whatever value -.B FS -may have. -.TP -.B RSTART -The index of the first character matched by -.BR match() ; -0 if no match. -.TP -.B RLENGTH -The length of the string matched by -.BR match() ; -\-1 if no match. -.TP -.B SUBSEP -The character used to separate multiple subscripts in array -elements, by default \fB"\e034"\fR. -.SS Arrays -.PP -Arrays are subscripted with an expression between square brackets -.RB ( [ " and " ] ). -If the expression is an expression list -.RI ( expr ", " expr " ...)" -then the array subscript is a string consisting of the -concatenation of the (string) value of each expression, -separated by the value of the -.B SUBSEP -variable. -This facility is used to simulate multiply dimensioned -arrays. For example: -.PP -.RS -.ft B -i = "A" ;\^ j = "B" ;\^ k = "C" -.br -x[i, j, k] = "hello, world\en" -.ft R -.RE -.PP -assigns the string \fB"hello, world\en"\fR to the element of the array -.B x -which is indexed by the string \fB"A\e034B\e034C"\fR. All arrays in AWK -are associative, i.e. indexed by string values. -.PP -The special operator -.B in -may be used in an -.B if -or -.B while -statement to see if an array has an index consisting of a particular -value. -.PP -.RS -.ft B -.nf -if (val in array) - print array[val] -.fi -.ft -.RE -.PP -If the array has multiple subscripts, use -.BR "(i, j) in array" . -.PP -The -.B in -construct may also be used in a -.B for -loop to iterate over all the elements of an array. -.PP -An element may be deleted from an array using the -.B delete -statement. -.SS Variable Typing And Conversion -.PP -Variables and fields -may be (floating point) numbers, or strings, or both. How the -value of a variable is interpreted depends upon its context. If used in -a numeric expression, it will be treated as a number, if used as a string -it will be treated as a string. -.PP -To force a variable to be treated as a number, add 0 to it; to force it -to be treated as a string, concatenate it with the null string. -.PP -When a string must be converted to a number, the conversion is accomplished -using -.IR atof (3). -A number is converted to a string by using the value of -.B CONVFMT -as a format string for -.IR sprintf (3), -with the numeric value of the variable as the argument. -However, even though all numbers in AWK are floating-point, -integral values are -.I always -converted as integers. Thus, given -.PP -.RS -.ft B -.nf -CONVFMT = "%2.2f" -a = 12 -b = a "" -.fi -.ft R -.RE -.PP -the variable -.B b -has a value of \fB"12"\fR and not \fB"12.00"\fR. -.PP -.I Gawk -performs comparisons as follows: -If two variables are numeric, they are compared numerically. -If one value is numeric and the other has a string value that is a -``numeric string,'' then comparisons are also done numerically. -Otherwise, the numeric value is converted to a string and a string -comparison is performed. -Two strings are compared, of course, as strings. -According to the \*(PX standard, even if two strings are -numeric strings, a numeric comparison is performed. However, this is -clearly incorrect, and -.I gawk -does not do this. -.PP -Uninitialized variables have the numeric value 0 and the string value "" -(the null, or empty, string). -.SH PATTERNS AND ACTIONS -AWK is a line oriented language. The pattern comes first, and then the -action. Action statements are enclosed in -.B { -and -.BR } . -Either the pattern may be missing, or the action may be missing, but, -of course, not both. If the pattern is missing, the action will be -executed for every single line of input. -A missing action is equivalent to -.RS -.PP -.B "{ print }" -.RE -.PP -which prints the entire line. -.PP -Comments begin with the ``#'' character, and continue until the -end of the line. -Blank lines may be used to separate statements. -Normally, a statement ends with a newline, however, this is not the -case for lines ending in -a ``,'', ``{'', ``?'', ``:'', ``&&'', or ``||''. -Lines ending in -.B do -or -.B else -also have their statements automatically continued on the following line. -In other cases, a line can be continued by ending it with a ``\e'', -in which case the newline will be ignored. -.PP -Multiple statements may -be put on one line by separating them with a ``;''. -This applies to both the statements within the action part of a -pattern-action pair (the usual case), -and to the pattern-action statements themselves. -.SS Patterns -AWK patterns may be one of the following: -.PP -.RS -.nf -.B BEGIN -.B END -.BI / "regular expression" / -.I "relational expression" -.IB pattern " && " pattern -.IB pattern " || " pattern -.IB pattern " ? " pattern " : " pattern -.BI ( pattern ) -.BI ! " pattern" -.IB pattern1 ", " pattern2 -.fi -.RE -.PP -.B BEGIN -and -.B END -are two special kinds of patterns which are not tested against -the input. -The action parts of all -.B BEGIN -patterns are merged as if all the statements had -been written in a single -.B BEGIN -block. They are executed before any -of the input is read. Similarly, all the -.B END -blocks are merged, -and executed when all the input is exhausted (or when an -.B exit -statement is executed). -.B BEGIN -and -.B END -patterns cannot be combined with other patterns in pattern expressions. -.B BEGIN -and -.B END -patterns cannot have missing action parts. -.PP -For -.BI / "regular expression" / -patterns, the associated statement is executed for each input line that matches -the regular expression. -Regular expressions are the same as those in -.IR egrep (1), -and are summarized below. -.PP -A -.I "relational expression" -may use any of the operators defined below in the section on actions. -These generally test whether certain fields match certain regular expressions. -.PP -The -.BR && , -.BR || , -and -.B ! -operators are logical AND, logical OR, and logical NOT, respectively, as in C. -They do short-circuit evaluation, also as in C, and are used for combining -more primitive pattern expressions. As in most languages, parentheses -may be used to change the order of evaluation. -.PP -The -.B ?\^: -operator is like the same operator in C. If the first pattern is true -then the pattern used for testing is the second pattern, otherwise it is -the third. Only one of the second and third patterns is evaluated. -.PP -The -.IB pattern1 ", " pattern2 -form of an expression is called a range pattern. -It matches all input records starting with a line that matches -.IR pattern1 , -and continuing until a record that matches -.IR pattern2 , -inclusive. It does not combine with any other sort of pattern expression. -.SS Regular Expressions -Regular expressions are the extended kind found in -.IR egrep . -They are composed of characters as follows: -.TP \w'\fB[^\fIabc...\fB]\fR'u+2n -.I c -matches the non-metacharacter -.IR c . -.TP -.I \ec -matches the literal character -.IR c . -.TP -.B . -matches any character except newline. -.TP -.B ^ -matches the beginning of a line or a string. -.TP -.B $ -matches the end of a line or a string. -.TP -.BI [ abc... ] -character class, matches any of the characters -.IR abc... . -.TP -.BI [^ abc... ] -negated character class, matches any character except -.I abc... -and newline. -.TP -.IB r1 | r2 -alternation: matches either -.I r1 -or -.IR r2 . -.TP -.I r1r2 -concatenation: matches -.IR r1 , -and then -.IR r2 . -.TP -.IB r + -matches one or more -.IR r 's. -.TP -.IB r * -matches zero or more -.IR r 's. -.TP -.IB r ? -matches zero or one -.IR r 's. -.TP -.BI ( r ) -grouping: matches -.IR r . -.PP -The escape sequences that are valid in string constants (see below) -are also legal in regular expressions. -.SS Actions -Action statements are enclosed in braces, -.B { -and -.BR } . -Action statements consist of the usual assignment, conditional, and looping -statements found in most languages. The operators, control statements, -and input/output statements -available are patterned after those in C. -.SS Operators -.PP -The operators in AWK, in order of increasing precedence, are -.PP -.TP "\w'\fB*= /= %= ^=\fR'u+1n" -.PD 0 -.B "= += \-=" -.TP -.PD -.B "*= /= %= ^=" -Assignment. Both absolute assignment -.BI ( var " = " value ) -and operator-assignment (the other forms) are supported. -.TP -.B ?: -The C conditional expression. This has the form -.IB expr1 " ? " expr2 " : " expr3\c -\&. If -.I expr1 -is true, the value of the expression is -.IR expr2 , -otherwise it is -.IR expr3 . -Only one of -.I expr2 -and -.I expr3 -is evaluated. -.TP -.B || -Logical OR. -.TP -.B && -Logical AND. -.TP -.B "~ !~" -Regular expression match, negated match. -.B NOTE: -Do not use a constant regular expression -.RB ( /foo/ ) -on the left-hand side of a -.B ~ -or -.BR !~ . -Only use one on the right-hand side. The expression -.BI "/foo/ ~ " exp -has the same meaning as \fB(($0 ~ /foo/) ~ \fIexp\fB)\fR. -This is usually -.I not -what was intended. -.TP -.PD 0 -.B "< >" -.TP -.PD 0 -.B "<= >=" -.TP -.PD -.B "!= ==" -The regular relational operators. -.TP -.I blank -String concatenation. -.TP -.B "+ \-" -Addition and subtraction. -.TP -.B "* / %" -Multiplication, division, and modulus. -.TP -.B "+ \- !" -Unary plus, unary minus, and logical negation. -.TP -.B ^ -Exponentiation (\fB**\fR may also be used, and \fB**=\fR for -the assignment operator). -.TP -.B "++ \-\^\-" -Increment and decrement, both prefix and postfix. -.TP -.B $ -Field reference. -.SS Control Statements -.PP -The control statements are -as follows: -.PP -.RS -.nf -\fBif (\fIcondition\fB) \fIstatement\fR [ \fBelse\fI statement \fR] -\fBwhile (\fIcondition\fB) \fIstatement \fR -\fBdo \fIstatement \fBwhile (\fIcondition\fB)\fR -\fBfor (\fIexpr1\fB; \fIexpr2\fB; \fIexpr3\fB) \fIstatement\fR -\fBfor (\fIvar \fBin\fI array\fB) \fIstatement\fR -\fBbreak\fR -\fBcontinue\fR -\fBdelete \fIarray\^\fB[\^\fIindex\^\fB]\fR -\fBexit\fR [ \fIexpression\fR ] -\fB{ \fIstatements \fB} -.fi -.RE -.SS "I/O Statements" -.PP -The input/output statements are as follows: -.PP -.TP "\w'\fBprintf \fIfmt, expr-list\fR'u+1n" -.BI close( filename ) -Close file (or pipe, see below). -.TP -.B getline -Set -.B $0 -from next input record; set -.BR NF , -.BR NR , -.BR FNR . -.TP -.BI "getline <" file -Set -.B $0 -from next record of -.IR file ; -set -.BR NF . -.TP -.BI getline " var" -Set -.I var -from next input record; set -.BR NF , -.BR FNR . -.TP -.BI getline " var" " <" file -Set -.I var -from next record of -.IR file . -.TP -.B next -Stop processing the current input record. The next input record -is read and processing starts over with the first pattern in the -AWK program. If the end of the input data is reached, the -.B END -block(s), if any, are executed. -.TP -.B "next file" -Stop processing the current input file. The next input record read -comes from the next input file. -.B FILENAME -is updated, -.B FNR -is reset to 1, and processing starts over with the first pattern in the -AWK program. If the end of the input data is reached, the -.B END -block(s), if any, are executed. -.TP -.B print -Prints the current record. -.TP -.BI print " expr-list" -Prints expressions. -.TP -.BI print " expr-list" " >" file -Prints expressions on -.IR file . -.TP -.BI printf " fmt, expr-list" -Format and print. -.TP -.BI printf " fmt, expr-list" " >" file -Format and print on -.IR file . -.TP -.BI system( cmd-line ) -Execute the command -.IR cmd-line , -and return the exit status. -(This may not be available on non-\*(PX systems.) -.PP -Other input/output redirections are also allowed. For -.B print -and -.BR printf , -.BI >> file -appends output to the -.IR file , -while -.BI | " command" -writes on a pipe. -In a similar fashion, -.IB command " | getline" -pipes into -.BR getline . -.BR Getline -will return 0 on end of file, and \-1 on an error. -.SS The \fIprintf\fP\^ Statement -.PP -The AWK versions of the -.B printf -statement and -.B sprintf() -function -(see below) -accept the following conversion specification formats: -.TP -.B %c -An \s-1ASCII\s+1 character. -If the argument used for -.B %c -is numeric, it is treated as a character and printed. -Otherwise, the argument is assumed to be a string, and the only first -character of that string is printed. -.TP -.B %d -A decimal number (the integer part). -.TP -.B %i -Just like -.BR %d . -.TP -.B %e -A floating point number of the form -.BR [\-]d.ddddddE[+\^\-]dd . -.TP -.B %f -A floating point number of the form -.BR [\-]ddd.dddddd . -.TP -.B %g -Use -.B e -or -.B f -conversion, whichever is shorter, with nonsignificant zeros suppressed. -.TP -.B %o -An unsigned octal number (again, an integer). -.TP -.B %s -A character string. -.TP -.B %x -An unsigned hexadecimal number (an integer). -.TP -.B %X -Like -.BR %x , -but using -.B ABCDEF -instead of -.BR abcdef . -.TP -.B %% -A single -.B % -character; no argument is converted. -.PP -There are optional, additional parameters that may lie between the -.B % -and the control letter: -.TP -.B \- -The expression should be left-justified within its field. -.TP -.I width -The field should be padded to this width. If the number has a leading -zero, then the field will be padded with zeros. -Otherwise it is padded with blanks. -.TP -.BI . prec -A number indicating the maximum width of strings or digits to the right -of the decimal point. -.PP -The dynamic -.I width -and -.I prec -capabilities of the \*(AN C -.B printf() -routines are supported. -A -.B * -in place of either the -.B width -or -.B prec -specifications will cause their values to be taken from -the argument list to -.B printf -or -.BR sprintf() . -.SS Special File Names -.PP -When doing I/O redirection from either -.B print -or -.B printf -into a file, -or via -.B getline -from a file, -.I gawk -recognizes certain special filenames internally. These filenames -allow access to open file descriptors inherited from -.IR gawk 's -parent process (usually the shell). -Other special filenames provide access information about the running -.B gawk -process. -The filenames are: -.TP \w'\fB/dev/stdout\fR'u+1n -.B /dev/pid -Reading this file returns the process ID of the current process, -in decimal, terminated with a newline. -.TP -.B /dev/ppid -Reading this file returns the parent process ID of the current process, -in decimal, terminated with a newline. -.TP -.B /dev/pgrpid -Reading this file returns the process group ID of the current process, -in decimal, terminated with a newline. -.TP -.B /dev/user -Reading this file returns a single record terminated with a newline. -The fields are separated with blanks. -.B $1 -is the value of the -.IR getuid (2) -system call, -.B $2 -is the value of the -.IR geteuid (2) -system call, -.B $3 -is the value of the -.IR getgid (2) -system call, and -.B $4 -is the value of the -.IR getegid (2) -system call. -If there are any additional fields, they are the group IDs returned by -.IR getgroups (2). -(Multiple groups may not be supported on all systems.) -.TP -.B /dev/stdin -The standard input. -.TP -.B /dev/stdout -The standard output. -.TP -.B /dev/stderr -The standard error output. -.TP -.BI /dev/fd/\^ n -The file associated with the open file descriptor -.IR n . -.PP -These are particularly useful for error messages. For example: -.PP -.RS -.ft B -print "You blew it!" > "/dev/stderr" -.ft R -.RE -.PP -whereas you would otherwise have to use -.PP -.RS -.ft B -print "You blew it!" | "cat 1>&2" -.ft R -.RE -.PP -These file names may also be used on the command line to name data files. -.SS Numeric Functions -.PP -AWK has the following pre-defined arithmetic functions: -.PP -.TP \w'\fBsrand(\^\fIexpr\^\fB)\fR'u+1n -.BI atan2( y , " x" ) -returns the arctangent of -.I y/x -in radians. -.TP -.BI cos( expr ) -returns the cosine in radians. -.TP -.BI exp( expr ) -the exponential function. -.TP -.BI int( expr ) -truncates to integer. -.TP -.BI log( expr ) -the natural logarithm function. -.TP -.B rand() -returns a random number between 0 and 1. -.TP -.BI sin( expr ) -returns the sine in radians. -.TP -.BI sqrt( expr ) -the square root function. -.TP -.BI srand( expr ) -use -.I expr -as a new seed for the random number generator. If no -.I expr -is provided, the time of day will be used. -The return value is the previous seed for the random -number generator. -.SS String Functions -.PP -AWK has the following pre-defined string functions: -.PP -.TP "\w'\fBsprintf(\^\fIfmt\fB\^, \fIexpr-list\^\fB)\fR'u+1n" -\fBgsub(\fIr\fB, \fIs\fB, \fIt\fB)\fR -for each substring matching the regular expression -.I r -in the string -.IR t , -substitute the string -.IR s , -and return the number of substitutions. -If -.I t -is not supplied, use -.BR $0 . -.TP -.BI index( s , " t" ) -returns the index of the string -.I t -in the string -.IR s , -or 0 if -.I t -is not present. -.TP -.BI length( s ) -returns the length of the string -.IR s , -or the length of -.B $0 -if -.I s -is not supplied. -.TP -.BI match( s , " r" ) -returns the position in -.I s -where the regular expression -.I r -occurs, or 0 if -.I r -is not present, and sets the values of -.B RSTART -and -.BR RLENGTH . -.TP -\fBsplit(\fIs\fB, \fIa\fB, \fIr\fB)\fR -splits the string -.I s -into the array -.I a -on the regular expression -.IR r , -and returns the number of fields. If -.I r -is omitted, -.B FS -is used instead. -.TP -.BI sprintf( fmt , " expr-list" ) -prints -.I expr-list -according to -.IR fmt , -and returns the resulting string. -.TP -\fBsub(\fIr\fB, \fIs\fB, \fIt\fB)\fR -just like -.BR gsub() , -but only the first matching substring is replaced. -.TP -\fBsubstr(\fIs\fB, \fIi\fB, \fIn\fB)\fR -returns the -.IR n -character -substring of -.I s -starting at -.IR i . -If -.I n -is omitted, the rest of -.I s -is used. -.TP -.BI tolower( str ) -returns a copy of the string -.IR str , -with all the upper-case characters in -.I str -translated to their corresponding lower-case counterparts. -Non-alphabetic characters are left unchanged. -.TP -.BI toupper( str ) -returns a copy of the string -.IR str , -with all the lower-case characters in -.I str -translated to their corresponding upper-case counterparts. -Non-alphabetic characters are left unchanged. -.SS Time Functions -.PP -Since one of the primary uses of AWK programs is processing log files -that contain time stamp information, -.I gawk -provides the following two functions for obtaining time stamps and -formatting them. -.PP -.TP "\w'\fBsystime()\fR'u+1n" -.B systime() -returns the current time of day as the number of seconds since the Epoch -(Midnight UTC, January 1, 1970 on \*(PX systems). -.TP -\fBstrftime(\fIformat\fR, \fItimestamp\fB)\fR -formats -.I timestamp -according to the specification in -.IR format. -The -.I timestamp -should be of the same form as returned by -.BR systime() . -If -.I timestamp -is missing, the current time of day is used. -See the specification for the -.B strftime() -function in \*(AN C for the format conversions that are -guaranteed to be available. -A public-domain version of -.IR strftime (3) -and a man page for it are shipped with -.IR gawk ; -if that version was used to build -.IR gawk , -then all of the conversions described in that man page are available to -.IR gawk. -.SS String Constants -.PP -String constants in AWK are sequences of characters enclosed -between double quotes (\fB"\fR). Within strings, certain -.I "escape sequences" -are recognized, as in C. These are: -.PP -.TP \w'\fB\e\^\fIddd\fR'u+1n -.B \e\e -A literal backslash. -.TP -.B \ea -The ``alert'' character; usually the \s-1ASCII\s+1 \s-1BEL\s+1 character. -.TP -.B \eb -backspace. -.TP -.B \ef -form-feed. -.TP -.B \en -new line. -.TP -.B \er -carriage return. -.TP -.B \et -horizontal tab. -.TP -.B \ev -vertical tab. -.TP -.BI \ex "\^hex digits" -The character represented by the string of hexadecimal digits following -the -.BR \ex . -As in \*(AN C, all following hexadecimal digits are considered part of -the escape sequence. -(This feature should tell us something about language design by committee.) -E.g., "\ex1B" is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character. -.TP -.BI \e ddd -The character represented by the 1-, 2-, or 3-digit sequence of octal -digits. E.g. "\e033" is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character. -.TP -.BI \e c -The literal character -.IR c\^ . -.PP -The escape sequences may also be used inside constant regular expressions -(e.g., -.B "/[\ \et\ef\en\er\ev]/" -matches whitespace characters). -.SH FUNCTIONS -Functions in AWK are defined as follows: -.PP -.RS -\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements \fB}\fR -.RE -.PP -Functions are executed when called from within the action parts of regular -pattern-action statements. Actual parameters supplied in the function -call are used to instantiate the formal parameters declared in the function. -Arrays are passed by reference, other variables are passed by value. -.PP -Since functions were not originally part of the AWK language, the provision -for local variables is rather clumsy: They are declared as extra parameters -in the parameter list. The convention is to separate local variables from -real parameters by extra spaces in the parameter list. For example: -.PP -.RS -.ft B -.nf -function f(p, q, a, b) { # a & b are local - ..... } - -/abc/ { ... ; f(1, 2) ; ... } -.fi -.ft R -.RE -.PP -The left parenthesis in a function call is required -to immediately follow the function name, -without any intervening white space. -This is to avoid a syntactic ambiguity with the concatenation operator. -This restriction does not apply to the built-in functions listed above. -.PP -Functions may call each other and may be recursive. -Function parameters used as local variables are initialized -to the null string and the number zero upon function invocation. -.PP -The word -.B func -may be used in place of -.BR function . -.SH EXAMPLES -.nf -Print and sort the login names of all users: - -.ft B - BEGIN { FS = ":" } - { print $1 | "sort" } - -.ft R -Count lines in a file: - -.ft B - { nlines++ } - END { print nlines } - -.ft R -Precede each line by its number in the file: - -.ft B - { print FNR, $0 } - -.ft R -Concatenate and line number (a variation on a theme): - -.ft B - { print NR, $0 } -.ft R -.fi -.SH SEE ALSO -.IR egrep (1) -.PP -.IR "The AWK Programming Language" , -Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger, -Addison-Wesley, 1988. ISBN 0-201-07981-X. -.PP -.IR "The GAWK Manual" , -Edition 0.15, published by the Free Software Foundation, 1993. -.SH POSIX COMPATIBILITY -A primary goal for -.I gawk -is compatibility with the \*(PX standard, as well as with the -latest version of \*(UX -.IR awk . -To this end, -.I gawk -incorporates the following user visible -features which are not described in the AWK book, -but are part of -.I awk -in System V Release 4, and are in the \*(PX standard. -.PP -The -.B \-v -option for assigning variables before program execution starts is new. -The book indicates that command line variable assignment happens when -.I awk -would otherwise open the argument as a file, which is after the -.B BEGIN -block is executed. However, in earlier implementations, when such an -assignment appeared before any file names, the assignment would happen -.I before -the -.B BEGIN -block was run. Applications came to depend on this ``feature.'' -When -.I awk -was changed to match its documentation, this option was added to -accomodate applications that depended upon the old behavior. -(This feature was agreed upon by both the AT&T and GNU developers.) -.PP -The -.B \-W -option for implementation specific features is from the \*(PX standard. -.PP -When processing arguments, -.I gawk -uses the special option ``\fB\-\^\-\fP'' to signal the end of -arguments, and warns about, but otherwise ignores, undefined options. -.PP -The AWK book does not define the return value of -.BR srand() . -The System V Release 4 version of \*(UX -.I awk -(and the \*(PX standard) -has it return the seed it was using, to allow keeping track -of random number sequences. Therefore -.B srand() -in -.I gawk -also returns its current seed. -.PP -Other new features are: -The use of multiple -.B \-f -options (from MKS -.IR awk ); -the -.B ENVIRON -array; the -.BR \ea , -and -.BR \ev -escape sequences (done originally in -.I gawk -and fed back into AT&T's); the -.B tolower() -and -.B toupper() -built-in functions (from AT&T); and the \*(AN C conversion specifications in -.B printf -(done first in AT&T's version). -.SH GNU EXTENSIONS -.I Gawk -has some extensions to \*(PX -.IR awk . -They are described in this section. All the extensions described here -can be disabled by -invoking -.I gawk -with the -.B "\-W compat" -option. -.PP -The following features of -.I gawk -are not available in -\*(PX -.IR awk . -.RS -.TP \w'\(bu'u+1n -\(bu -The -.B \ex -escape sequence. -.TP -\(bu -The -.B systime() -and -.B strftime() -functions. -.TP -\(bu -The special file names available for I/O redirection are not recognized. -.TP -\(bu -The -.B ARGIND -and -.B ERRNO -variables are not special. -.TP -\(bu -The -.B IGNORECASE -variable and its side-effects are not available. -.TP -\(bu -The -.B FIELDWIDTHS -variable and fixed width field splitting. -.TP -\(bu -No path search is performed for files named via the -.B \-f -option. Therefore the -.B AWKPATH -environment variable is not special. -.TP -\(bu -The use of -.B "next file" -to abandon processing of the current input file. -.RE -.PP -The AWK book does not define the return value of the -.B close() -function. -.IR Gawk\^ 's -.B close() -returns the value from -.IR fclose (3), -or -.IR pclose (3), -when closing a file or pipe, respectively. -.PP -When -.I gawk -is invoked with the -.B "\-W compat" -option, -if the -.I fs -argument to the -.B \-F -option is ``t'', then -.B FS -will be set to the tab character. -Since this is a rather ugly special case, it is not the default behavior. -This behavior also does not occur if -.B \-Wposix -has been specified. -.ig -.PP -If -.I gawk -was compiled for debugging, it will -accept the following additional options: -.TP -.PD 0 -.B \-Wparsedebug -.TP -.PD -.B \-\^\-parsedebug -Turn on -.IR yacc (1) -or -.IR bison (1) -debugging output during program parsing. -This option should only be of interest to the -.I gawk -maintainers, and may not even be compiled into -.IR gawk . -.. -.SH HISTORICAL FEATURES -There are two features of historical AWK implementations that -.I gawk -supports. -First, it is possible to call the -.B length() -built-in function not only with no argument, but even without parentheses! -Thus, -.RS -.PP -.ft B -a = length -.ft R -.RE -.PP -is the same as either of -.RS -.PP -.ft B -a = length() -.br -a = length($0) -.ft R -.RE -.PP -This feature is marked as ``deprecated'' in the \*(PX standard, and -.I gawk -will issue a warning about its use if -.B \-Wlint -is specified on the command line. -.PP -The other feature is the use of the -.B continue -statement outside the body of a -.BR while , -.BR for , -or -.B do -loop. Traditional AWK implementations have treated such usage as -equivalent to the -.B next -statement. -.I Gawk -will support this usage if -.B \-Wposix -has not been specified. -.SH BUGS -The -.B \-F -option is not necessary given the command line variable assignment feature; -it remains only for backwards compatibility. -.PP -If your system actually has support for -.B /dev/fd -and the associated -.BR /dev/stdin , -.BR /dev/stdout , -and -.B /dev/stderr -files, you may get different output from -.I gawk -than you would get on a system without those files. When -.I gawk -interprets these files internally, it synchronizes output to the standard -output with output to -.BR /dev/stdout , -while on a system with those files, the output is actually to different -open files. -Caveat Emptor. -.SH VERSION INFORMATION -This man page documents -.IR gawk , -version 2.15. -.PP -Starting with the 2.15 version of -.IR gawk , -the -.BR \-c , -.BR \-V , -.BR \-C , -.ig -.BR \-D , -.. -.BR \-a , -and -.B \-e -options of the 2.11 version are no longer recognized. -.SH AUTHORS -The original version of \*(UX -.I awk -was designed and implemented by Alfred Aho, -Peter Weinberger, and Brian Kernighan of AT&T Bell Labs. Brian Kernighan -continues to maintain and enhance it. -.PP -Paul Rubin and Jay Fenlason, -of the Free Software Foundation, wrote -.IR gawk , -to be compatible with the original version of -.I awk -distributed in Seventh Edition \*(UX. -John Woods contributed a number of bug fixes. -David Trueman, with contributions -from Arnold Robbins, made -.I gawk -compatible with the new version of \*(UX -.IR awk . -.PP -The initial DOS port was done by Conrad Kwok and Scott Garfinkle. -Scott Deifik is the current DOS maintainer. Pat Rankin did the -port to VMS, and Michal Jaegermann did the port to the Atari ST. -.SH ACKNOWLEDGEMENTS -Brian Kernighan of Bell Labs -provided valuable assistance during testing and debugging. -We thank him. diff --git a/gnu/usr.bin/gawk-2.15.2/awk.h b/gnu/usr.bin/gawk-2.15.2/awk.h deleted file mode 100644 index ca3997f11d4b..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/awk.h +++ /dev/null @@ -1,763 +0,0 @@ -/* - * awk.h -- Definitions for gawk. - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* ------------------------------ Includes ------------------------------ */ -#include -#include -#include -#include -#include -#include -#include -#if !defined(errno) && !defined(MSDOS) -extern int errno; -#endif -#ifdef __GNU_LIBRARY__ -#ifndef linux -#include -#endif -#endif - -/* ----------------- System dependencies (with more includes) -----------*/ - -#if !defined(VMS) || (!defined(VAXC) && !defined(__DECC)) -#include -#include -#else /* VMS w/ VAXC or DECC */ -#include -#include -#include /* avoid in io.c */ -#endif - -#include - -#include "config.h" - -#ifdef __STDC__ -#define P(s) s -#define MALLOC_ARG_T size_t -#else -#define P(s) () -#define MALLOC_ARG_T unsigned -#define volatile -#define const -#endif - -#ifndef SIGTYPE -#define SIGTYPE void -#endif - -#ifdef SIZE_T_MISSING -typedef unsigned int size_t; -#endif - -#ifndef SZTC -#define SZTC -#define INTC -#endif - -#ifdef STDC_HEADERS -#include -#include -#ifdef NeXT -#include -#undef atof -#else -#if defined(atarist) || defined(VMS) -#include -#else /* atarist || VMS */ -#ifndef MSDOS -#include -#endif /* MSDOS */ -#endif /* atarist || VMS */ -#endif /* Next */ -#else /* STDC_HEADERS */ -#include "protos.h" -#endif /* STDC_HEADERS */ - -#if defined(ultrix) && !defined(Ultrix41) -extern char * getenv P((char *name)); -extern double atof P((char *s)); -#endif - -#ifndef __GNUC__ -#ifdef sparc -/* nasty nasty SunOS-ism */ -#include -#ifdef lint -extern char *alloca(); -#endif -#else /* not sparc */ -#if !defined(alloca) && !defined(ALLOCA_PROTO) -extern char *alloca(); -#endif -#endif /* sparc */ -#endif /* __GNUC__ */ - -#ifdef HAVE_UNDERSCORE_SETJMP -/* nasty nasty berkelixm */ -#define setjmp _setjmp -#define longjmp _longjmp -#endif - -/* - * if you don't have vprintf, try this and cross your fingers. - */ -#if defined(VPRINTF_MISSING) -#define vfprintf(fp,fmt,arg) _doprnt((fmt), (arg), (fp)) -#endif - -#ifdef VMS -/* some macros to redirect to code in vms/vms_misc.c */ -#define exit vms_exit -#define open vms_open -#define strerror vms_strerror -#define strdup vms_strdup -extern void exit P((int)); -extern int open P((const char *,int,...)); -extern char *strerror P((int)); -extern char *strdup P((const char *str)); -extern int vms_devopen P((const char *,int)); -# ifndef NO_TTY_FWRITE -#define fwrite tty_fwrite -#define fclose tty_fclose -extern size_t fwrite P((const void *,size_t,size_t,FILE *)); -extern int fclose P((FILE *)); -# endif -extern FILE *popen P((const char *,const char *)); -extern int pclose P((FILE *)); -extern void vms_arg_fixup P((int *,char ***)); -/* some things not in STDC_HEADERS */ -extern int gnu_strftime P((char *,size_t,const char *,const struct tm *)); -extern int unlink P((const char *)); -extern int getopt P((int,char **,char *)); -extern int isatty P((int)); -#ifndef fileno -extern int fileno P((FILE *)); -#endif -extern int close(), dup(), dup2(), fstat(), read(), stat(); -#endif /*VMS*/ - -#ifdef MSDOS -#include -extern FILE *popen P((char *, char *)); -extern int pclose P((FILE *)); -#endif - -#define GNU_REGEX -#ifdef GNU_REGEX -#include "regex.h" -#include "dfa.h" -typedef struct Regexp { - struct re_pattern_buffer pat; - struct re_registers regs; - struct regexp dfareg; - int dfa; -} Regexp; -#define RESTART(rp,s) (rp)->regs.start[0] -#define REEND(rp,s) (rp)->regs.end[0] -#else /* GNU_REGEX */ -#endif /* GNU_REGEX */ - -#ifdef atarist -#define read _text_read /* we do not want all these CR's to mess our input */ -extern int _text_read (int, char *, int); -#endif - -#ifndef DEFPATH -#define DEFPATH ".:/usr/local/lib/awk:/usr/lib/awk" -#endif - -#ifndef ENVSEP -#define ENVSEP ':' -#endif - -/* ------------------ Constants, Structures, Typedefs ------------------ */ -#define AWKNUM double - -typedef enum { - /* illegal entry == 0 */ - Node_illegal, - - /* binary operators lnode and rnode are the expressions to work on */ - Node_times, - Node_quotient, - Node_mod, - Node_plus, - Node_minus, - Node_cond_pair, /* conditional pair (see Node_line_range) */ - Node_subscript, - Node_concat, - Node_exp, - - /* unary operators subnode is the expression to work on */ -/*10*/ Node_preincrement, - Node_predecrement, - Node_postincrement, - Node_postdecrement, - Node_unary_minus, - Node_field_spec, - - /* assignments lnode is the var to assign to, rnode is the exp */ - Node_assign, - Node_assign_times, - Node_assign_quotient, - Node_assign_mod, -/*20*/ Node_assign_plus, - Node_assign_minus, - Node_assign_exp, - - /* boolean binaries lnode and rnode are expressions */ - Node_and, - Node_or, - - /* binary relationals compares lnode and rnode */ - Node_equal, - Node_notequal, - Node_less, - Node_greater, - Node_leq, -/*30*/ Node_geq, - Node_match, - Node_nomatch, - - /* unary relationals works on subnode */ - Node_not, - - /* program structures */ - Node_rule_list, /* lnode is a rule, rnode is rest of list */ - Node_rule_node, /* lnode is pattern, rnode is statement */ - Node_statement_list, /* lnode is statement, rnode is more list */ - Node_if_branches, /* lnode is to run on true, rnode on false */ - Node_expression_list, /* lnode is an exp, rnode is more list */ - Node_param_list, /* lnode is a variable, rnode is more list */ - - /* keywords */ -/*40*/ Node_K_if, /* lnode is conditonal, rnode is if_branches */ - Node_K_while, /* lnode is condtional, rnode is stuff to run */ - Node_K_for, /* lnode is for_struct, rnode is stuff to run */ - Node_K_arrayfor, /* lnode is for_struct, rnode is stuff to run */ - Node_K_break, /* no subs */ - Node_K_continue, /* no stuff */ - Node_K_print, /* lnode is exp_list, rnode is redirect */ - Node_K_printf, /* lnode is exp_list, rnode is redirect */ - Node_K_next, /* no subs */ - Node_K_exit, /* subnode is return value, or NULL */ -/*50*/ Node_K_do, /* lnode is conditional, rnode stuff to run */ - Node_K_return, - Node_K_delete, - Node_K_getline, - Node_K_function, /* lnode is statement list, rnode is params */ - - /* I/O redirection for print statements */ - Node_redirect_output, /* subnode is where to redirect */ - Node_redirect_append, /* subnode is where to redirect */ - Node_redirect_pipe, /* subnode is where to redirect */ - Node_redirect_pipein, /* subnode is where to redirect */ - Node_redirect_input, /* subnode is where to redirect */ - - /* Variables */ -/*60*/ Node_var, /* rnode is value, lnode is array stuff */ - Node_var_array, /* array is ptr to elements, asize num of - * eles */ - Node_val, /* node is a value - type in flags */ - - /* Builtins subnode is explist to work on, proc is func to call */ - Node_builtin, - - /* - * pattern: conditional ',' conditional ; lnode of Node_line_range - * is the two conditionals (Node_cond_pair), other word (rnode place) - * is a flag indicating whether or not this range has been entered. - */ - Node_line_range, - - /* - * boolean test of membership in array lnode is string-valued - * expression rnode is array name - */ - Node_in_array, - - Node_func, /* lnode is param. list, rnode is body */ - Node_func_call, /* lnode is name, rnode is argument list */ - - Node_cond_exp, /* lnode is conditonal, rnode is if_branches */ - Node_regex, -/*70*/ Node_hashnode, - Node_ahash, - Node_NF, - Node_NR, - Node_FNR, - Node_FS, - Node_RS, - Node_FIELDWIDTHS, - Node_IGNORECASE, - Node_OFS, - Node_ORS, - Node_OFMT, - Node_CONVFMT, - Node_K_nextfile -} NODETYPE; - -/* - * NOTE - this struct is a rather kludgey -- it is packed to minimize - * space usage, at the expense of cleanliness. Alter at own risk. - */ -typedef struct exp_node { - union { - struct { - union { - struct exp_node *lptr; - char *param_name; - } l; - union { - struct exp_node *rptr; - struct exp_node *(*pptr) (); - Regexp *preg; - struct for_loop_header *hd; - struct exp_node **av; - int r_ent; /* range entered */ - } r; - union { - char *name; - struct exp_node *extra; - } x; - short number; - unsigned char reflags; -# define CASE 1 -# define CONST 2 -# define FS_DFLT 4 - } nodep; - struct { - AWKNUM fltnum; /* this is here for optimal packing of - * the structure on many machines - */ - char *sp; - size_t slen; - unsigned char sref; - char idx; - } val; - struct { - struct exp_node *next; - char *name; - int length; - struct exp_node *value; - } hash; -#define hnext sub.hash.next -#define hname sub.hash.name -#define hlength sub.hash.length -#define hvalue sub.hash.value - struct { - struct exp_node *next; - struct exp_node *name; - struct exp_node *value; - } ahash; -#define ahnext sub.ahash.next -#define ahname sub.ahash.name -#define ahvalue sub.ahash.value - } sub; - NODETYPE type; - unsigned short flags; -# define MALLOC 1 /* can be free'd */ -# define TEMP 2 /* should be free'd */ -# define PERM 4 /* can't be free'd */ -# define STRING 8 /* assigned as string */ -# define STR 16 /* string value is current */ -# define NUM 32 /* numeric value is current */ -# define NUMBER 64 /* assigned as number */ -# define MAYBE_NUM 128 /* user input: if NUMERIC then - * a NUMBER - */ - char *vname; /* variable's name */ -} NODE; - -#define lnode sub.nodep.l.lptr -#define nextp sub.nodep.l.lptr -#define rnode sub.nodep.r.rptr -#define source_file sub.nodep.x.name -#define source_line sub.nodep.number -#define param_cnt sub.nodep.number -#define param sub.nodep.l.param_name - -#define subnode lnode -#define proc sub.nodep.r.pptr - -#define re_reg sub.nodep.r.preg -#define re_flags sub.nodep.reflags -#define re_text lnode -#define re_exp sub.nodep.x.extra -#define re_cnt sub.nodep.number - -#define forsub lnode -#define forloop rnode->sub.nodep.r.hd - -#define stptr sub.val.sp -#define stlen sub.val.slen -#define stref sub.val.sref -#define stfmt sub.val.idx - -#define numbr sub.val.fltnum - -#define var_value lnode -#define var_array sub.nodep.r.av - -#define condpair lnode -#define triggered sub.nodep.r.r_ent - -#ifdef DONTDEF -int primes[] = {31, 61, 127, 257, 509, 1021, 2053, 4099, 8191, 16381}; -#endif -/* a quick profile suggests that the following is a good value */ -#define HASHSIZE 127 - -typedef struct for_loop_header { - NODE *init; - NODE *cond; - NODE *incr; -} FOR_LOOP_HEADER; - -/* for "for(iggy in foo) {" */ -struct search { - NODE **arr_ptr; - NODE **arr_end; - NODE *bucket; - NODE *retval; -}; - -/* for faster input, bypass stdio */ -typedef struct iobuf { - int fd; - char *buf; - char *off; - char *end; - size_t size; /* this will be determined by an fstat() call */ - int cnt; - long secsiz; - int flag; -# define IOP_IS_TTY 1 -# define IOP_IS_INTERNAL 2 -# define IOP_NO_FREE 4 -} IOBUF; - -typedef void (*Func_ptr)(); - -/* - * structure used to dynamically maintain a linked-list of open files/pipes - */ -struct redirect { - unsigned int flag; -# define RED_FILE 1 -# define RED_PIPE 2 -# define RED_READ 4 -# define RED_WRITE 8 -# define RED_APPEND 16 -# define RED_NOBUF 32 -# define RED_USED 64 -# define RED_EOF 128 - char *value; - FILE *fp; - IOBUF *iop; - int pid; - int status; - struct redirect *prev; - struct redirect *next; -}; - -/* structure for our source, either a command line string or a source file */ -struct src { - enum srctype { CMDLINE = 1, SOURCEFILE } stype; - char *val; -}; - -/* longjmp return codes, must be nonzero */ -/* Continue means either for loop/while continue, or next input record */ -#define TAG_CONTINUE 1 -/* Break means either for/while break, or stop reading input */ -#define TAG_BREAK 2 -/* Return means return from a function call; leave value in ret_node */ -#define TAG_RETURN 3 - -#define HUGE INT_MAX - -/* -------------------------- External variables -------------------------- */ -/* gawk builtin variables */ -extern int NF; -extern int NR; -extern int FNR; -extern int IGNORECASE; -extern char *RS; -extern char *OFS; -extern int OFSlen; -extern char *ORS; -extern int ORSlen; -extern char *OFMT; -extern char *CONVFMT; -extern int CONVFMTidx; -extern int OFMTidx; -extern NODE *FS_node, *NF_node, *RS_node, *NR_node; -extern NODE *FILENAME_node, *OFS_node, *ORS_node, *OFMT_node; -extern NODE *CONVFMT_node; -extern NODE *FNR_node, *RLENGTH_node, *RSTART_node, *SUBSEP_node; -extern NODE *IGNORECASE_node; -extern NODE *FIELDWIDTHS_node; - -extern NODE **stack_ptr; -extern NODE *Nnull_string; -extern NODE **fields_arr; -extern int sourceline; -extern char *source; -extern NODE *expression_value; - -extern NODE *_t; /* used as temporary in tree_eval */ - -extern const char *myname; - -extern NODE *nextfree; -extern int field0_valid; -extern int do_unix; -extern int do_posix; -extern int do_lint; -extern int in_begin_rule; -extern int in_end_rule; - -/* ------------------------- Pseudo-functions ------------------------- */ - -#define is_identchar(c) (isalnum(c) || (c) == '_') - - -#ifndef MPROF -#define getnode(n) if (nextfree) n = nextfree, nextfree = nextfree->nextp;\ - else n = more_nodes() -#define freenode(n) ((n)->nextp = nextfree, nextfree = (n)) -#else -#define getnode(n) emalloc(n, NODE *, sizeof(NODE), "getnode") -#define freenode(n) free(n) -#endif - -#ifdef DEBUG -#define tree_eval(t) r_tree_eval(t) -#else -#define tree_eval(t) (_t = (t),(_t) == NULL ? Nnull_string : \ - ((_t)->type == Node_val ? (_t) : \ - ((_t)->type == Node_var ? (_t)->var_value : \ - ((_t)->type == Node_param_list ? \ - (stack_ptr[(_t)->param_cnt])->var_value : \ - r_tree_eval((_t)))))) -#endif - -#define make_number(x) mk_number((x), (MALLOC|NUM|NUMBER)) -#define tmp_number(x) mk_number((x), (MALLOC|TEMP|NUM|NUMBER)) - -#define free_temp(n) do {if ((n)->flags&TEMP) { unref(n); }} while (0) -#define make_string(s,l) make_str_node((s), SZTC (l),0) -#define SCAN 1 -#define ALREADY_MALLOCED 2 - -#define cant_happen() fatal("internal error line %d, file: %s", \ - __LINE__, __FILE__); - -#if defined(__STDC__) && !defined(NO_TOKEN_PASTING) -#define emalloc(var,ty,x,str) (void)((var=(ty)malloc((MALLOC_ARG_T)(x))) ||\ - (fatal("%s: %s: can't allocate memory (%s)",\ - (str), #var, strerror(errno)),0)) -#define erealloc(var,ty,x,str) (void)((var=(ty)realloc((char *)var,\ - (MALLOC_ARG_T)(x))) ||\ - (fatal("%s: %s: can't allocate memory (%s)",\ - (str), #var, strerror(errno)),0)) -#else /* __STDC__ */ -#define emalloc(var,ty,x,str) (void)((var=(ty)malloc((MALLOC_ARG_T)(x))) ||\ - (fatal("%s: %s: can't allocate memory (%s)",\ - (str), "var", strerror(errno)),0)) -#define erealloc(var,ty,x,str) (void)((var=(ty)realloc((char *)var,\ - (MALLOC_ARG_T)(x))) ||\ - (fatal("%s: %s: can't allocate memory (%s)",\ - (str), "var", strerror(errno)),0)) -#endif /* __STDC__ */ - -#ifdef DEBUG -#define force_number r_force_number -#define force_string r_force_string -#else /* not DEBUG */ -#ifdef lint -extern AWKNUM force_number(); -#endif -#ifdef MSDOS -extern double _msc51bug; -#define force_number(n) (_msc51bug=(_t = (n),(_t->flags & NUM) ? _t->numbr : r_force_number(_t))) -#else /* not MSDOS */ -#define force_number(n) (_t = (n),(_t->flags & NUM) ? _t->numbr : r_force_number(_t)) -#endif /* MSDOS */ -#define force_string(s) (_t = (s),(_t->flags & STR) ? _t : r_force_string(_t)) -#endif /* not DEBUG */ - -#define STREQ(a,b) (*(a) == *(b) && strcmp((a), (b)) == 0) -#define STREQN(a,b,n) ((n)&& *(a)== *(b) && strncmp((a), (b), SZTC (n)) == 0) - -/* ------------- Function prototypes or defs (as appropriate) ------------- */ - -/* array.c */ -extern NODE *concat_exp P((NODE *tree)); -extern void assoc_clear P((NODE *symbol)); -extern unsigned int hash P((char *s, int len)); -extern int in_array P((NODE *symbol, NODE *subs)); -extern NODE **assoc_lookup P((NODE *symbol, NODE *subs)); -extern void do_delete P((NODE *symbol, NODE *tree)); -extern void assoc_scan P((NODE *symbol, struct search *lookat)); -extern void assoc_next P((struct search *lookat)); -/* awk.tab.c */ -extern char *tokexpand P((void)); -extern char nextc P((void)); -extern NODE *node P((NODE *left, NODETYPE op, NODE *right)); -extern NODE *install P((char *name, NODE *value)); -extern NODE *lookup P((char *name)); -extern NODE *variable P((char *name, int can_free)); -extern int yyparse P((void)); -/* builtin.c */ -extern NODE *do_exp P((NODE *tree)); -extern NODE *do_index P((NODE *tree)); -extern NODE *do_int P((NODE *tree)); -extern NODE *do_length P((NODE *tree)); -extern NODE *do_log P((NODE *tree)); -extern NODE *do_sprintf P((NODE *tree)); -extern void do_printf P((NODE *tree)); -extern void print_simple P((NODE *tree, FILE *fp)); -extern NODE *do_sqrt P((NODE *tree)); -extern NODE *do_substr P((NODE *tree)); -extern NODE *do_strftime P((NODE *tree)); -extern NODE *do_systime P((NODE *tree)); -extern NODE *do_system P((NODE *tree)); -extern void do_print P((NODE *tree)); -extern NODE *do_tolower P((NODE *tree)); -extern NODE *do_toupper P((NODE *tree)); -extern NODE *do_atan2 P((NODE *tree)); -extern NODE *do_sin P((NODE *tree)); -extern NODE *do_cos P((NODE *tree)); -extern NODE *do_rand P((NODE *tree)); -extern NODE *do_srand P((NODE *tree)); -extern NODE *do_match P((NODE *tree)); -extern NODE *do_gsub P((NODE *tree)); -extern NODE *do_sub P((NODE *tree)); -/* eval.c */ -extern int interpret P((NODE *volatile tree)); -extern NODE *r_tree_eval P((NODE *tree)); -extern int cmp_nodes P((NODE *t1, NODE *t2)); -extern NODE **get_lhs P((NODE *ptr, Func_ptr *assign)); -extern void set_IGNORECASE P((void)); -void set_OFS P((void)); -void set_ORS P((void)); -void set_OFMT P((void)); -void set_CONVFMT P((void)); -/* field.c */ -extern void init_fields P((void)); -extern void set_record P((char *buf, int cnt, int freeold)); -extern void reset_record P((void)); -extern void set_NF P((void)); -extern NODE **get_field P((int num, Func_ptr *assign)); -extern NODE *do_split P((NODE *tree)); -extern void set_FS P((void)); -extern void set_RS P((void)); -extern void set_FIELDWIDTHS P((void)); -/* io.c */ -extern void set_FNR P((void)); -extern void set_NR P((void)); -extern void do_input P((void)); -extern struct redirect *redirect P((NODE *tree, int *errflg)); -extern NODE *do_close P((NODE *tree)); -extern int flush_io P((void)); -extern int close_io P((void)); -extern int devopen P((char *name, char *mode)); -extern int pathopen P((char *file)); -extern NODE *do_getline P((NODE *tree)); -extern void do_nextfile P((void)); -/* iop.c */ -extern int optimal_bufsize P((int fd)); -extern IOBUF *iop_alloc P((int fd)); -extern int get_a_record P((char **out, IOBUF *iop, int rs, int *errcode)); -/* main.c */ -extern int main P((int argc, char **argv)); -extern Regexp *mk_re_parse P((char *s, int ignorecase)); -extern void load_environ P((void)); -extern char *arg_assign P((char *arg)); -extern SIGTYPE catchsig P((int sig, int code)); -/* msg.c */ -#ifdef MSDOS -extern void err P((char *s, char *emsg, char *va_list, ...)); -extern void msg P((char *va_alist, ...)); -extern void warning P((char *va_alist, ...)); -extern void fatal P((char *va_alist, ...)); -#else -extern void err (); -extern void msg (); -extern void warning (); -extern void fatal (); -#endif -/* node.c */ -extern AWKNUM r_force_number P((NODE *n)); -extern NODE *r_force_string P((NODE *s)); -extern NODE *dupnode P((NODE *n)); -extern NODE *mk_number P((AWKNUM x, unsigned int flags)); -extern NODE *make_str_node P((char *s, size_t len, int scan )); -extern NODE *tmp_string P((char *s, size_t len )); -extern NODE *more_nodes P((void)); -#ifdef DEBUG -extern void freenode P((NODE *it)); -#endif -extern void unref P((NODE *tmp)); -extern int parse_escape P((char **string_ptr)); -/* re.c */ -extern Regexp *make_regexp P((char *s, int len, int ignorecase, int dfa)); -extern int research P((Regexp *rp, char *str, int start, int len, int need_start)); -extern void refree P((Regexp *rp)); -extern void reg_error P((const char *s)); -extern Regexp *re_update P((NODE *t)); -extern void resyntax P((int syntax)); -extern void resetup P((void)); - -/* strcase.c */ -extern int strcasecmp P((const char *s1, const char *s2)); -extern int strncasecmp P((const char *s1, const char *s2, register size_t n)); - -#ifdef atarist -/* atari/tmpnam.c */ -extern char *tmpnam P((char *buf)); -extern char *tempnam P((const char *path, const char *base)); -#endif - -/* Figure out what '\a' really is. */ -#ifdef __STDC__ -#define BELL '\a' /* sure makes life easy, don't it? */ -#else -# if 'z' - 'a' == 25 /* ascii */ -# if 'a' != 97 /* machine is dumb enough to use mark parity */ -# define BELL '\207' -# else -# define BELL '\07' -# endif -# else -# define BELL '\057' -# endif -#endif - -extern char casetable[]; /* for case-independent regexp matching */ diff --git a/gnu/usr.bin/gawk-2.15.2/awk.y b/gnu/usr.bin/gawk-2.15.2/awk.y deleted file mode 100644 index 6e87f1c449cc..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/awk.y +++ /dev/null @@ -1,1804 +0,0 @@ -/* - * awk.y --- yacc/bison parser - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -%{ -#ifdef DEBUG -#define YYDEBUG 12 -#endif - -#include "awk.h" - -static void yyerror (); /* va_alist */ -static char *get_src_buf P((void)); -static int yylex P((void)); -static NODE *node_common P((NODETYPE op)); -static NODE *snode P((NODE *subn, NODETYPE op, int sindex)); -static NODE *mkrangenode P((NODE *cpair)); -static NODE *make_for_loop P((NODE *init, NODE *cond, NODE *incr)); -static NODE *append_right P((NODE *list, NODE *new)); -static void func_install P((NODE *params, NODE *def)); -static void pop_var P((NODE *np, int freeit)); -static void pop_params P((NODE *params)); -static NODE *make_param P((char *name)); -static NODE *mk_rexp P((NODE *exp)); - -static int want_assign; /* lexical scanning kludge */ -static int want_regexp; /* lexical scanning kludge */ -static int can_return; /* lexical scanning kludge */ -static int io_allowed = 1; /* lexical scanning kludge */ -static char *lexptr; /* pointer to next char during parsing */ -static char *lexend; -static char *lexptr_begin; /* keep track of where we were for error msgs */ -static char *lexeme; /* beginning of lexeme for debugging */ -static char *thisline = NULL; -#define YYDEBUG_LEXER_TEXT (lexeme) -static int param_counter; -static char *tokstart = NULL; -static char *token = NULL; -static char *tokend; - -NODE *variables[HASHSIZE]; - -extern char *source; -extern int sourceline; -extern struct src *srcfiles; -extern int numfiles; -extern int errcount; -extern NODE *begin_block; -extern NODE *end_block; -%} - -%union { - long lval; - AWKNUM fval; - NODE *nodeval; - NODETYPE nodetypeval; - char *sval; - NODE *(*ptrval)(); -} - -%type function_prologue function_body -%type rexp exp start program rule simp_exp -%type non_post_simp_exp -%type pattern -%type action variable param_list -%type rexpression_list opt_rexpression_list -%type expression_list opt_expression_list -%type statements statement if_statement opt_param_list -%type opt_exp opt_variable regexp -%type input_redir output_redir -%type print -%type func_name -%type lex_builtin - -%token FUNC_CALL NAME REGEXP -%token ERROR -%token YNUMBER YSTRING -%token RELOP APPEND_OP -%token ASSIGNOP MATCHOP NEWLINE CONCAT_OP -%token LEX_BEGIN LEX_END LEX_IF LEX_ELSE LEX_RETURN LEX_DELETE -%token LEX_WHILE LEX_DO LEX_FOR LEX_BREAK LEX_CONTINUE -%token LEX_PRINT LEX_PRINTF LEX_NEXT LEX_EXIT LEX_FUNCTION -%token LEX_GETLINE -%token LEX_IN -%token LEX_AND LEX_OR INCREMENT DECREMENT -%token LEX_BUILTIN LEX_LENGTH - -/* these are just yylval numbers */ - -/* Lowest to highest */ -%right ASSIGNOP -%right '?' ':' -%left LEX_OR -%left LEX_AND -%left LEX_GETLINE -%nonassoc LEX_IN -%left FUNC_CALL LEX_BUILTIN LEX_LENGTH -%nonassoc MATCHOP -%nonassoc RELOP '<' '>' '|' APPEND_OP -%left CONCAT_OP -%left YSTRING YNUMBER -%left '+' '-' -%left '*' '/' '%' -%right '!' UNARY -%right '^' -%left INCREMENT DECREMENT -%left '$' -%left '(' ')' -%% - -start - : opt_nls program opt_nls - { expression_value = $2; } - ; - -program - : rule - { - if ($1 != NULL) - $$ = $1; - else - $$ = NULL; - yyerrok; - } - | program rule - /* add the rule to the tail of list */ - { - if ($2 == NULL) - $$ = $1; - else if ($1 == NULL) - $$ = $2; - else { - if ($1->type != Node_rule_list) - $1 = node($1, Node_rule_list, - (NODE*)NULL); - $$ = append_right ($1, - node($2, Node_rule_list,(NODE *) NULL)); - } - yyerrok; - } - | error { $$ = NULL; } - | program error { $$ = NULL; } - ; - -rule - : LEX_BEGIN { io_allowed = 0; } - action - { - if (begin_block) { - if (begin_block->type != Node_rule_list) - begin_block = node(begin_block, Node_rule_list, - (NODE *)NULL); - (void) append_right (begin_block, node( - node((NODE *)NULL, Node_rule_node, $3), - Node_rule_list, (NODE *)NULL) ); - } else - begin_block = node((NODE *)NULL, Node_rule_node, $3); - $$ = NULL; - io_allowed = 1; - yyerrok; - } - | LEX_END { io_allowed = 0; } - action - { - if (end_block) { - if (end_block->type != Node_rule_list) - end_block = node(end_block, Node_rule_list, - (NODE *)NULL); - (void) append_right (end_block, node( - node((NODE *)NULL, Node_rule_node, $3), - Node_rule_list, (NODE *)NULL)); - } else - end_block = node((NODE *)NULL, Node_rule_node, $3); - $$ = NULL; - io_allowed = 1; - yyerrok; - } - | LEX_BEGIN statement_term - { - warning("BEGIN blocks must have an action part"); - errcount++; - yyerrok; - } - | LEX_END statement_term - { - warning("END blocks must have an action part"); - errcount++; - yyerrok; - } - | pattern action - { $$ = node ($1, Node_rule_node, $2); yyerrok; } - | action - { $$ = node ((NODE *)NULL, Node_rule_node, $1); yyerrok; } - | pattern statement_term - { - $$ = node ($1, - Node_rule_node, - node(node(node(make_number(0.0), - Node_field_spec, - (NODE *) NULL), - Node_expression_list, - (NODE *) NULL), - Node_K_print, - (NODE *) NULL)); - yyerrok; - } - | function_prologue function_body - { - func_install($1, $2); - $$ = NULL; - yyerrok; - } - ; - -func_name - : NAME - { $$ = $1; } - | FUNC_CALL - { $$ = $1; } - | lex_builtin - { - yyerror("%s() is a built-in function, it cannot be redefined", - tokstart); - errcount++; - /* yyerrok; */ - } - ; - -lex_builtin - : LEX_BUILTIN - | LEX_LENGTH - ; - -function_prologue - : LEX_FUNCTION - { - param_counter = 0; - } - func_name '(' opt_param_list r_paren opt_nls - { - $$ = append_right(make_param($3), $5); - can_return = 1; - } - ; - -function_body - : l_brace statements r_brace opt_semi - { - $$ = $2; - can_return = 0; - } - ; - - -pattern - : exp - { $$ = $1; } - | exp comma exp - { $$ = mkrangenode ( node($1, Node_cond_pair, $3) ); } - ; - -regexp - /* - * In this rule, want_regexp tells yylex that the next thing - * is a regexp so it should read up to the closing slash. - */ - : '/' - { ++want_regexp; } - REGEXP '/' - { - NODE *n; - int len; - - getnode(n); - n->type = Node_regex; - len = strlen($3); - n->re_exp = make_string($3, len); - n->re_reg = make_regexp($3, len, 0, 1); - n->re_text = NULL; - n->re_flags = CONST; - n->re_cnt = 1; - $$ = n; - } - ; - -action - : l_brace statements r_brace opt_semi opt_nls - { $$ = $2 ; } - | l_brace r_brace opt_semi opt_nls - { $$ = NULL; } - ; - -statements - : statement - { $$ = $1; } - | statements statement - { - if ($1 == NULL || $1->type != Node_statement_list) - $1 = node($1, Node_statement_list,(NODE *)NULL); - $$ = append_right($1, - node( $2, Node_statement_list, (NODE *)NULL)); - yyerrok; - } - | error - { $$ = NULL; } - | statements error - { $$ = NULL; } - ; - -statement_term - : nls - | semi opt_nls - ; - -statement - : semi opt_nls - { $$ = NULL; } - | l_brace r_brace - { $$ = NULL; } - | l_brace statements r_brace - { $$ = $2; } - | if_statement - { $$ = $1; } - | LEX_WHILE '(' exp r_paren opt_nls statement - { $$ = node ($3, Node_K_while, $6); } - | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls - { $$ = node ($6, Node_K_do, $3); } - | LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement - { - $$ = node ($8, Node_K_arrayfor, make_for_loop(variable($3,1), - (NODE *)NULL, variable($5,1))); - } - | LEX_FOR '(' opt_exp semi exp semi opt_exp r_paren opt_nls statement - { - $$ = node($10, Node_K_for, (NODE *)make_for_loop($3, $5, $7)); - } - | LEX_FOR '(' opt_exp semi semi opt_exp r_paren opt_nls statement - { - $$ = node ($9, Node_K_for, - (NODE *)make_for_loop($3, (NODE *)NULL, $6)); - } - | LEX_BREAK statement_term - /* for break, maybe we'll have to remember where to break to */ - { $$ = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); } - | LEX_CONTINUE statement_term - /* similarly */ - { $$ = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); } - | print '(' expression_list r_paren output_redir statement_term - { $$ = node ($3, $1, $5); } - | print opt_rexpression_list output_redir statement_term - { - if ($1 == Node_K_print && $2 == NULL) - $2 = node(node(make_number(0.0), - Node_field_spec, - (NODE *) NULL), - Node_expression_list, - (NODE *) NULL); - - $$ = node ($2, $1, $3); - } - | LEX_NEXT opt_exp statement_term - { NODETYPE type; - - if ($2 && $2 == lookup("file")) { - if (do_lint) - warning("`next file' is a gawk extension"); - else if (do_unix || do_posix) - yyerror("`next file' is a gawk extension"); - else if (! io_allowed) - yyerror("`next file' used in BEGIN or END action"); - type = Node_K_nextfile; - } else { - if (! io_allowed) - yyerror("next used in BEGIN or END action"); - type = Node_K_next; - } - $$ = node ((NODE *)NULL, type, (NODE *)NULL); - } - | LEX_EXIT opt_exp statement_term - { $$ = node ($2, Node_K_exit, (NODE *)NULL); } - | LEX_RETURN - { if (! can_return) yyerror("return used outside function context"); } - opt_exp statement_term - { $$ = node ($3, Node_K_return, (NODE *)NULL); } - | LEX_DELETE NAME '[' expression_list ']' statement_term - { $$ = node (variable($2,1), Node_K_delete, $4); } - | exp statement_term - { $$ = $1; } - ; - -print - : LEX_PRINT - { $$ = $1; } - | LEX_PRINTF - { $$ = $1; } - ; - -if_statement - : LEX_IF '(' exp r_paren opt_nls statement - { - $$ = node($3, Node_K_if, - node($6, Node_if_branches, (NODE *)NULL)); - } - | LEX_IF '(' exp r_paren opt_nls statement - LEX_ELSE opt_nls statement - { $$ = node ($3, Node_K_if, - node ($6, Node_if_branches, $9)); } - ; - -nls - : NEWLINE - { want_assign = 0; } - | nls NEWLINE - ; - -opt_nls - : /* empty */ - | nls - ; - -input_redir - : /* empty */ - { $$ = NULL; } - | '<' simp_exp - { $$ = node ($2, Node_redirect_input, (NODE *)NULL); } - ; - -output_redir - : /* empty */ - { $$ = NULL; } - | '>' exp - { $$ = node ($2, Node_redirect_output, (NODE *)NULL); } - | APPEND_OP exp - { $$ = node ($2, Node_redirect_append, (NODE *)NULL); } - | '|' exp - { $$ = node ($2, Node_redirect_pipe, (NODE *)NULL); } - ; - -opt_param_list - : /* empty */ - { $$ = NULL; } - | param_list - { $$ = $1; } - ; - -param_list - : NAME - { $$ = make_param($1); } - | param_list comma NAME - { $$ = append_right($1, make_param($3)); yyerrok; } - | error - { $$ = NULL; } - | param_list error - { $$ = NULL; } - | param_list comma error - { $$ = NULL; } - ; - -/* optional expression, as in for loop */ -opt_exp - : /* empty */ - { $$ = NULL; } - | exp - { $$ = $1; } - ; - -opt_rexpression_list - : /* empty */ - { $$ = NULL; } - | rexpression_list - { $$ = $1; } - ; - -rexpression_list - : rexp - { $$ = node ($1, Node_expression_list, (NODE *)NULL); } - | rexpression_list comma rexp - { - $$ = append_right($1, - node( $3, Node_expression_list, (NODE *)NULL)); - yyerrok; - } - | error - { $$ = NULL; } - | rexpression_list error - { $$ = NULL; } - | rexpression_list error rexp - { $$ = NULL; } - | rexpression_list comma error - { $$ = NULL; } - ; - -opt_expression_list - : /* empty */ - { $$ = NULL; } - | expression_list - { $$ = $1; } - ; - -expression_list - : exp - { $$ = node ($1, Node_expression_list, (NODE *)NULL); } - | expression_list comma exp - { - $$ = append_right($1, - node( $3, Node_expression_list, (NODE *)NULL)); - yyerrok; - } - | error - { $$ = NULL; } - | expression_list error - { $$ = NULL; } - | expression_list error exp - { $$ = NULL; } - | expression_list comma error - { $$ = NULL; } - ; - -/* Expressions, not including the comma operator. */ -exp : variable ASSIGNOP - { want_assign = 0; } - exp - { - if (do_lint && $4->type == Node_regex) - warning("Regular expression on left of assignment."); - $$ = node ($1, $2, $4); - } - | '(' expression_list r_paren LEX_IN NAME - { $$ = node (variable($5,1), Node_in_array, $2); } - | exp '|' LEX_GETLINE opt_variable - { - $$ = node ($4, Node_K_getline, - node ($1, Node_redirect_pipein, (NODE *)NULL)); - } - | LEX_GETLINE opt_variable input_redir - { - if (do_lint && ! io_allowed && $3 == NULL) - warning("non-redirected getline undefined inside BEGIN or END action"); - $$ = node ($2, Node_K_getline, $3); - } - | exp LEX_AND exp - { $$ = node ($1, Node_and, $3); } - | exp LEX_OR exp - { $$ = node ($1, Node_or, $3); } - | exp MATCHOP exp - { - if ($1->type == Node_regex) - warning("Regular expression on left of MATCH operator."); - $$ = node ($1, $2, mk_rexp($3)); - } - | regexp - { $$ = $1; } - | '!' regexp %prec UNARY - { - $$ = node(node(make_number(0.0), - Node_field_spec, - (NODE *) NULL), - Node_nomatch, - $2); - } - | exp LEX_IN NAME - { $$ = node (variable($3,1), Node_in_array, $1); } - | exp RELOP exp - { - if (do_lint && $3->type == Node_regex) - warning("Regular expression on left of comparison."); - $$ = node ($1, $2, $3); - } - | exp '<' exp - { $$ = node ($1, Node_less, $3); } - | exp '>' exp - { $$ = node ($1, Node_greater, $3); } - | exp '?' exp ':' exp - { $$ = node($1, Node_cond_exp, node($3, Node_if_branches, $5));} - | simp_exp - { $$ = $1; } - | exp simp_exp %prec CONCAT_OP - { $$ = node ($1, Node_concat, $2); } - ; - -rexp - : variable ASSIGNOP - { want_assign = 0; } - rexp - { $$ = node ($1, $2, $4); } - | rexp LEX_AND rexp - { $$ = node ($1, Node_and, $3); } - | rexp LEX_OR rexp - { $$ = node ($1, Node_or, $3); } - | LEX_GETLINE opt_variable input_redir - { - if (do_lint && ! io_allowed && $3 == NULL) - warning("non-redirected getline undefined inside BEGIN or END action"); - $$ = node ($2, Node_K_getline, $3); - } - | regexp - { $$ = $1; } - | '!' regexp %prec UNARY - { $$ = node((NODE *) NULL, Node_nomatch, $2); } - | rexp MATCHOP rexp - { $$ = node ($1, $2, mk_rexp($3)); } - | rexp LEX_IN NAME - { $$ = node (variable($3,1), Node_in_array, $1); } - | rexp RELOP rexp - { $$ = node ($1, $2, $3); } - | rexp '?' rexp ':' rexp - { $$ = node($1, Node_cond_exp, node($3, Node_if_branches, $5));} - | simp_exp - { $$ = $1; } - | rexp simp_exp %prec CONCAT_OP - { $$ = node ($1, Node_concat, $2); } - ; - -simp_exp - : non_post_simp_exp - /* Binary operators in order of decreasing precedence. */ - | simp_exp '^' simp_exp - { $$ = node ($1, Node_exp, $3); } - | simp_exp '*' simp_exp - { $$ = node ($1, Node_times, $3); } - | simp_exp '/' simp_exp - { $$ = node ($1, Node_quotient, $3); } - | simp_exp '%' simp_exp - { $$ = node ($1, Node_mod, $3); } - | simp_exp '+' simp_exp - { $$ = node ($1, Node_plus, $3); } - | simp_exp '-' simp_exp - { $$ = node ($1, Node_minus, $3); } - | variable INCREMENT - { $$ = node ($1, Node_postincrement, (NODE *)NULL); } - | variable DECREMENT - { $$ = node ($1, Node_postdecrement, (NODE *)NULL); } - ; - -non_post_simp_exp - : '!' simp_exp %prec UNARY - { $$ = node ($2, Node_not,(NODE *) NULL); } - | '(' exp r_paren - { $$ = $2; } - | LEX_BUILTIN - '(' opt_expression_list r_paren - { $$ = snode ($3, Node_builtin, (int) $1); } - | LEX_LENGTH '(' opt_expression_list r_paren - { $$ = snode ($3, Node_builtin, (int) $1); } - | LEX_LENGTH - { - if (do_lint) - warning("call of `length' without parentheses is not portable"); - $$ = snode ((NODE *)NULL, Node_builtin, (int) $1); - if (do_posix) - warning( "call of `length' without parentheses is deprecated by POSIX"); - } - | FUNC_CALL '(' opt_expression_list r_paren - { - $$ = node ($3, Node_func_call, make_string($1, strlen($1))); - } - | variable - | INCREMENT variable - { $$ = node ($2, Node_preincrement, (NODE *)NULL); } - | DECREMENT variable - { $$ = node ($2, Node_predecrement, (NODE *)NULL); } - | YNUMBER - { $$ = $1; } - | YSTRING - { $$ = $1; } - - | '-' simp_exp %prec UNARY - { if ($2->type == Node_val) { - $2->numbr = -(force_number($2)); - $$ = $2; - } else - $$ = node ($2, Node_unary_minus, (NODE *)NULL); - } - | '+' simp_exp %prec UNARY - { $$ = $2; } - ; - -opt_variable - : /* empty */ - { $$ = NULL; } - | variable - { $$ = $1; } - ; - -variable - : NAME - { $$ = variable($1,1); } - | NAME '[' expression_list ']' - { - if ($3->rnode == NULL) { - $$ = node (variable($1,1), Node_subscript, $3->lnode); - freenode($3); - } else - $$ = node (variable($1,1), Node_subscript, $3); - } - | '$' non_post_simp_exp - { $$ = node ($2, Node_field_spec, (NODE *)NULL); } - ; - -l_brace - : '{' opt_nls - ; - -r_brace - : '}' opt_nls { yyerrok; } - ; - -r_paren - : ')' { yyerrok; } - ; - -opt_semi - : /* empty */ - | semi - ; - -semi - : ';' { yyerrok; want_assign = 0; } - ; - -comma : ',' opt_nls { yyerrok; } - ; - -%% - -struct token { - char *operator; /* text to match */ - NODETYPE value; /* node type */ - int class; /* lexical class */ - unsigned flags; /* # of args. allowed and compatability */ -# define ARGS 0xFF /* 0, 1, 2, 3 args allowed (any combination */ -# define A(n) (1<<(n)) -# define VERSION 0xFF00 /* old awk is zero */ -# define NOT_OLD 0x0100 /* feature not in old awk */ -# define NOT_POSIX 0x0200 /* feature not in POSIX */ -# define GAWKX 0x0400 /* gawk extension */ - NODE *(*ptr) (); /* function that implements this keyword */ -}; - -extern NODE - *do_exp(), *do_getline(), *do_index(), *do_length(), - *do_sqrt(), *do_log(), *do_sprintf(), *do_substr(), - *do_split(), *do_system(), *do_int(), *do_close(), - *do_atan2(), *do_sin(), *do_cos(), *do_rand(), - *do_srand(), *do_match(), *do_tolower(), *do_toupper(), - *do_sub(), *do_gsub(), *do_strftime(), *do_systime(); - -/* Tokentab is sorted ascii ascending order, so it can be binary searched. */ - -static struct token tokentab[] = { -{"BEGIN", Node_illegal, LEX_BEGIN, 0, 0}, -{"END", Node_illegal, LEX_END, 0, 0}, -{"atan2", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2}, -{"break", Node_K_break, LEX_BREAK, 0, 0}, -{"close", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_close}, -{"continue", Node_K_continue, LEX_CONTINUE, 0, 0}, -{"cos", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_cos}, -{"delete", Node_K_delete, LEX_DELETE, NOT_OLD, 0}, -{"do", Node_K_do, LEX_DO, NOT_OLD, 0}, -{"else", Node_illegal, LEX_ELSE, 0, 0}, -{"exit", Node_K_exit, LEX_EXIT, 0, 0}, -{"exp", Node_builtin, LEX_BUILTIN, A(1), do_exp}, -{"for", Node_K_for, LEX_FOR, 0, 0}, -{"func", Node_K_function, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0}, -{"function", Node_K_function, LEX_FUNCTION, NOT_OLD, 0}, -{"getline", Node_K_getline, LEX_GETLINE, NOT_OLD, 0}, -{"gsub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_gsub}, -{"if", Node_K_if, LEX_IF, 0, 0}, -{"in", Node_illegal, LEX_IN, 0, 0}, -{"index", Node_builtin, LEX_BUILTIN, A(2), do_index}, -{"int", Node_builtin, LEX_BUILTIN, A(1), do_int}, -{"length", Node_builtin, LEX_LENGTH, A(0)|A(1), do_length}, -{"log", Node_builtin, LEX_BUILTIN, A(1), do_log}, -{"match", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_match}, -{"next", Node_K_next, LEX_NEXT, 0, 0}, -{"print", Node_K_print, LEX_PRINT, 0, 0}, -{"printf", Node_K_printf, LEX_PRINTF, 0, 0}, -{"rand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0), do_rand}, -{"return", Node_K_return, LEX_RETURN, NOT_OLD, 0}, -{"sin", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_sin}, -{"split", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_split}, -{"sprintf", Node_builtin, LEX_BUILTIN, 0, do_sprintf}, -{"sqrt", Node_builtin, LEX_BUILTIN, A(1), do_sqrt}, -{"srand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand}, -{"strftime", Node_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_strftime}, -{"sub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_sub}, -{"substr", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_substr}, -{"system", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_system}, -{"systime", Node_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime}, -{"tolower", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower}, -{"toupper", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper}, -{"while", Node_K_while, LEX_WHILE, 0, 0}, -}; - -/* VARARGS0 */ -static void -yyerror(va_alist) -va_dcl -{ - va_list args; - char *mesg = NULL; - register char *bp, *cp; - char *scan; - char buf[120]; - - errcount++; - /* Find the current line in the input file */ - if (lexptr) { - if (!thisline) { - cp = lexeme; - if (*cp == '\n') { - cp--; - mesg = "unexpected newline"; - } - for ( ; cp != lexptr_begin && *cp != '\n'; --cp) - ; - if (*cp == '\n') - cp++; - thisline = cp; - } - /* NL isn't guaranteed */ - bp = lexeme; - while (bp < lexend && *bp && *bp != '\n') - bp++; - } else { - thisline = "(END OF FILE)"; - bp = thisline + 13; - } - msg("%.*s", (int) (bp - thisline), thisline); - bp = buf; - cp = buf + sizeof(buf) - 24; /* 24 more than longest msg. input */ - if (lexptr) { - scan = thisline; - while (bp < cp && scan < lexeme) - if (*scan++ == '\t') - *bp++ = '\t'; - else - *bp++ = ' '; - *bp++ = '^'; - *bp++ = ' '; - } - va_start(args); - if (mesg == NULL) - mesg = va_arg(args, char *); - strcpy(bp, mesg); - err("", buf, args); - va_end(args); - exit(2); -} - -static char * -get_src_buf() -{ - static int samefile = 0; - static int nextfile = 0; - static char *buf = NULL; - static int fd; - int n; - register char *scan; - static int len = 0; - static int did_newline = 0; -# define SLOP 128 /* enough space to hold most source lines */ - - if (nextfile > numfiles) - return NULL; - - if (srcfiles[nextfile].stype == CMDLINE) { - if (len == 0) { - len = strlen(srcfiles[nextfile].val); - sourceline = 1; - lexptr = lexptr_begin = srcfiles[nextfile].val; - lexend = lexptr + len; - } else if (!did_newline && *(lexptr-1) != '\n') { - /* - * The following goop is to ensure that the source - * ends with a newline and that the entire current - * line is available for error messages. - */ - int offset; - - did_newline = 1; - offset = lexptr - lexeme; - for (scan = lexeme; scan > lexptr_begin; scan--) - if (*scan == '\n') { - scan++; - break; - } - len = lexptr - scan; - emalloc(buf, char *, len+1, "get_src_buf"); - memcpy(buf, scan, len); - thisline = buf; - lexptr = buf + len; - *lexptr = '\n'; - lexeme = lexptr - offset; - lexptr_begin = buf; - lexend = lexptr + 1; - } else { - len = 0; - lexeme = lexptr = lexptr_begin = NULL; - } - if (lexptr == NULL && ++nextfile <= numfiles) - return get_src_buf(); - return lexptr; - } - if (!samefile) { - source = srcfiles[nextfile].val; - if (source == NULL) { - if (buf) { - free(buf); - buf = NULL; - } - len = 0; - return lexeme = lexptr = lexptr_begin = NULL; - } - fd = pathopen(source); - if (fd == -1) - fatal("can't open source file \"%s\" for reading (%s)", - source, strerror(errno)); - len = optimal_bufsize(fd); - if (buf) - free(buf); - emalloc(buf, char *, len + SLOP, "get_src_buf"); - lexptr_begin = buf + SLOP; - samefile = 1; - sourceline = 1; - } else { - /* - * Here, we retain the current source line (up to length SLOP) - * in the beginning of the buffer that was overallocated above - */ - int offset; - int linelen; - - offset = lexptr - lexeme; - for (scan = lexeme; scan > lexptr_begin; scan--) - if (*scan == '\n') { - scan++; - break; - } - linelen = lexptr - scan; - if (linelen > SLOP) - linelen = SLOP; - thisline = buf + SLOP - linelen; - memcpy(thisline, scan, linelen); - lexeme = buf + SLOP - offset; - lexptr_begin = thisline; - } - n = read(fd, buf + SLOP, len); - if (n == -1) - fatal("can't read sourcefile \"%s\" (%s)", - source, strerror(errno)); - if (n == 0) { - samefile = 0; - nextfile++; - len = 0; - return get_src_buf(); - } - lexptr = buf + SLOP; - lexend = lexptr + n; - return buf; -} - -#define tokadd(x) (*token++ = (x), token == tokend ? tokexpand() : token) - -char * -tokexpand() -{ - static int toksize = 60; - int tokoffset; - - tokoffset = token - tokstart; - toksize *= 2; - if (tokstart) - erealloc(tokstart, char *, toksize, "tokexpand"); - else - emalloc(tokstart, char *, toksize, "tokexpand"); - tokend = tokstart + toksize; - token = tokstart + tokoffset; - return token; -} - -#if DEBUG -char -nextc() { - if (lexptr && lexptr < lexend) - return *lexptr++; - else if (get_src_buf()) - return *lexptr++; - else - return '\0'; -} -#else -#define nextc() ((lexptr && lexptr < lexend) ? \ - *lexptr++ : \ - (get_src_buf() ? *lexptr++ : '\0') \ - ) -#endif -#define pushback() (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr) - -/* - * Read the input and turn it into tokens. - */ - -static int -yylex() -{ - register int c; - int seen_e = 0; /* These are for numbers */ - int seen_point = 0; - int esc_seen; /* for literal strings */ - int low, mid, high; - static int did_newline = 0; - char *tokkey; - - if (!nextc()) - return 0; - pushback(); - lexeme = lexptr; - thisline = NULL; - if (want_regexp) { - int in_brack = 0; - - want_regexp = 0; - token = tokstart; - while ((c = nextc()) != 0) { - switch (c) { - case '[': - in_brack = 1; - break; - case ']': - in_brack = 0; - break; - case '\\': - if ((c = nextc()) == '\0') { - yyerror("unterminated regexp ends with \\ at end of file"); - } else if (c == '\n') { - sourceline++; - continue; - } else - tokadd('\\'); - break; - case '/': /* end of the regexp */ - if (in_brack) - break; - - pushback(); - tokadd('\0'); - yylval.sval = tokstart; - return REGEXP; - case '\n': - pushback(); - yyerror("unterminated regexp"); - case '\0': - yyerror("unterminated regexp at end of file"); - } - tokadd(c); - } - } -retry: - while ((c = nextc()) == ' ' || c == '\t') - ; - - lexeme = lexptr ? lexptr - 1 : lexptr; - thisline = NULL; - token = tokstart; - yylval.nodetypeval = Node_illegal; - - switch (c) { - case 0: - return 0; - - case '\n': - sourceline++; - return NEWLINE; - - case '#': /* it's a comment */ - while ((c = nextc()) != '\n') { - if (c == '\0') - return 0; - } - sourceline++; - return NEWLINE; - - case '\\': -#ifdef RELAXED_CONTINUATION - if (!do_unix) { /* strip trailing white-space and/or comment */ - while ((c = nextc()) == ' ' || c == '\t') continue; - if (c == '#') - while ((c = nextc()) != '\n') if (!c) break; - pushback(); - } -#endif /*RELAXED_CONTINUATION*/ - if (nextc() == '\n') { - sourceline++; - goto retry; - } else - yyerror("inappropriate use of backslash"); - break; - - case '$': - want_assign = 1; - return '$'; - - case ')': - case ']': - case '(': - case '[': - case ';': - case ':': - case '?': - case '{': - case ',': - return c; - - case '*': - if ((c = nextc()) == '=') { - yylval.nodetypeval = Node_assign_times; - return ASSIGNOP; - } else if (do_posix) { - pushback(); - return '*'; - } else if (c == '*') { - /* make ** and **= aliases for ^ and ^= */ - static int did_warn_op = 0, did_warn_assgn = 0; - - if (nextc() == '=') { - if (do_lint && ! did_warn_assgn) { - did_warn_assgn = 1; - warning("**= is not allowed by POSIX"); - } - yylval.nodetypeval = Node_assign_exp; - return ASSIGNOP; - } else { - pushback(); - if (do_lint && ! did_warn_op) { - did_warn_op = 1; - warning("** is not allowed by POSIX"); - } - return '^'; - } - } - pushback(); - return '*'; - - case '/': - if (want_assign) { - if (nextc() == '=') { - yylval.nodetypeval = Node_assign_quotient; - return ASSIGNOP; - } - pushback(); - } - return '/'; - - case '%': - if (nextc() == '=') { - yylval.nodetypeval = Node_assign_mod; - return ASSIGNOP; - } - pushback(); - return '%'; - - case '^': - { - static int did_warn_op = 0, did_warn_assgn = 0; - - if (nextc() == '=') { - - if (do_lint && ! did_warn_assgn) { - did_warn_assgn = 1; - warning("operator `^=' is not supported in old awk"); - } - yylval.nodetypeval = Node_assign_exp; - return ASSIGNOP; - } - pushback(); - if (do_lint && ! did_warn_op) { - did_warn_op = 1; - warning("operator `^' is not supported in old awk"); - } - return '^'; - } - - case '+': - if ((c = nextc()) == '=') { - yylval.nodetypeval = Node_assign_plus; - return ASSIGNOP; - } - if (c == '+') - return INCREMENT; - pushback(); - return '+'; - - case '!': - if ((c = nextc()) == '=') { - yylval.nodetypeval = Node_notequal; - return RELOP; - } - if (c == '~') { - yylval.nodetypeval = Node_nomatch; - want_assign = 0; - return MATCHOP; - } - pushback(); - return '!'; - - case '<': - if (nextc() == '=') { - yylval.nodetypeval = Node_leq; - return RELOP; - } - yylval.nodetypeval = Node_less; - pushback(); - return '<'; - - case '=': - if (nextc() == '=') { - yylval.nodetypeval = Node_equal; - return RELOP; - } - yylval.nodetypeval = Node_assign; - pushback(); - return ASSIGNOP; - - case '>': - if ((c = nextc()) == '=') { - yylval.nodetypeval = Node_geq; - return RELOP; - } else if (c == '>') { - yylval.nodetypeval = Node_redirect_append; - return APPEND_OP; - } - yylval.nodetypeval = Node_greater; - pushback(); - return '>'; - - case '~': - yylval.nodetypeval = Node_match; - want_assign = 0; - return MATCHOP; - - case '}': - /* - * Added did newline stuff. Easier than - * hacking the grammar - */ - if (did_newline) { - did_newline = 0; - return c; - } - did_newline++; - --lexptr; /* pick up } next time */ - return NEWLINE; - - case '"': - esc_seen = 0; - while ((c = nextc()) != '"') { - if (c == '\n') { - pushback(); - yyerror("unterminated string"); - } - if (c == '\\') { - c = nextc(); - if (c == '\n') { - sourceline++; - continue; - } - esc_seen = 1; - tokadd('\\'); - } - if (c == '\0') { - pushback(); - yyerror("unterminated string"); - } - tokadd(c); - } - yylval.nodeval = make_str_node(tokstart, - token - tokstart, esc_seen ? SCAN : 0); - yylval.nodeval->flags |= PERM; - return YSTRING; - - case '-': - if ((c = nextc()) == '=') { - yylval.nodetypeval = Node_assign_minus; - return ASSIGNOP; - } - if (c == '-') - return DECREMENT; - pushback(); - return '-'; - - case '.': - c = nextc(); - pushback(); - if (!isdigit(c)) - return '.'; - else - c = '.'; /* FALL THROUGH */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - /* It's a number */ - for (;;) { - int gotnumber = 0; - - tokadd(c); - switch (c) { - case '.': - if (seen_point) { - gotnumber++; - break; - } - ++seen_point; - break; - case 'e': - case 'E': - if (seen_e) { - gotnumber++; - break; - } - ++seen_e; - if ((c = nextc()) == '-' || c == '+') - tokadd(c); - else - pushback(); - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - break; - default: - gotnumber++; - } - if (gotnumber) - break; - c = nextc(); - } - pushback(); - yylval.nodeval = make_number(atof(tokstart)); - yylval.nodeval->flags |= PERM; - return YNUMBER; - - case '&': - if ((c = nextc()) == '&') { - yylval.nodetypeval = Node_and; - for (;;) { - c = nextc(); - if (c == '\0') - break; - if (c == '#') { - while ((c = nextc()) != '\n' && c != '\0') - ; - if (c == '\0') - break; - } - if (c == '\n') - sourceline++; - if (! isspace(c)) { - pushback(); - break; - } - } - want_assign = 0; - return LEX_AND; - } - pushback(); - return '&'; - - case '|': - if ((c = nextc()) == '|') { - yylval.nodetypeval = Node_or; - for (;;) { - c = nextc(); - if (c == '\0') - break; - if (c == '#') { - while ((c = nextc()) != '\n' && c != '\0') - ; - if (c == '\0') - break; - } - if (c == '\n') - sourceline++; - if (! isspace(c)) { - pushback(); - break; - } - } - want_assign = 0; - return LEX_OR; - } - pushback(); - return '|'; - } - - if (c != '_' && ! isalpha(c)) - yyerror("Invalid char '%c' in expression\n", c); - - /* it's some type of name-type-thing. Find its length */ - token = tokstart; - while (is_identchar(c)) { - tokadd(c); - c = nextc(); - } - tokadd('\0'); - emalloc(tokkey, char *, token - tokstart, "yylex"); - memcpy(tokkey, tokstart, token - tokstart); - pushback(); - - /* See if it is a special token. */ - low = 0; - high = (sizeof (tokentab) / sizeof (tokentab[0])) - 1; - while (low <= high) { - int i/* , c */; - - mid = (low + high) / 2; - c = *tokstart - tokentab[mid].operator[0]; - i = c ? c : strcmp (tokstart, tokentab[mid].operator); - - if (i < 0) { /* token < mid */ - high = mid - 1; - } else if (i > 0) { /* token > mid */ - low = mid + 1; - } else { - if (do_lint) { - if (tokentab[mid].flags & GAWKX) - warning("%s() is a gawk extension", - tokentab[mid].operator); - if (tokentab[mid].flags & NOT_POSIX) - warning("POSIX does not allow %s", - tokentab[mid].operator); - if (tokentab[mid].flags & NOT_OLD) - warning("%s is not supported in old awk", - tokentab[mid].operator); - } - if ((do_unix && (tokentab[mid].flags & GAWKX)) - || (do_posix && (tokentab[mid].flags & NOT_POSIX))) - break; - if (tokentab[mid].class == LEX_BUILTIN - || tokentab[mid].class == LEX_LENGTH - ) - yylval.lval = mid; - else - yylval.nodetypeval = tokentab[mid].value; - - return tokentab[mid].class; - } - } - - yylval.sval = tokkey; - if (*lexptr == '(') - return FUNC_CALL; - else { - want_assign = 1; - return NAME; - } -} - -static NODE * -node_common(op) -NODETYPE op; -{ - register NODE *r; - - getnode(r); - r->type = op; - r->flags = MALLOC; - /* if lookahead is NL, lineno is 1 too high */ - if (lexeme && *lexeme == '\n') - r->source_line = sourceline - 1; - else - r->source_line = sourceline; - r->source_file = source; - return r; -} - -/* - * This allocates a node with defined lnode and rnode. - */ -NODE * -node(left, op, right) -NODE *left, *right; -NODETYPE op; -{ - register NODE *r; - - r = node_common(op); - r->lnode = left; - r->rnode = right; - return r; -} - -/* - * This allocates a node with defined subnode and proc for builtin functions - * Checks for arg. count and supplies defaults where possible. - */ -static NODE * -snode(subn, op, idx) -NODETYPE op; -int idx; -NODE *subn; -{ - register NODE *r; - register NODE *n; - int nexp = 0; - int args_allowed; - - r = node_common(op); - - /* traverse expression list to see how many args. given */ - for (n= subn; n; n= n->rnode) { - nexp++; - if (nexp > 3) - break; - } - - /* check against how many args. are allowed for this builtin */ - args_allowed = tokentab[idx].flags & ARGS; - if (args_allowed && !(args_allowed & A(nexp))) - fatal("%s() cannot have %d argument%c", - tokentab[idx].operator, nexp, nexp == 1 ? ' ' : 's'); - - r->proc = tokentab[idx].ptr; - - /* special case processing for a few builtins */ - if (nexp == 0 && r->proc == do_length) { - subn = node(node(make_number(0.0),Node_field_spec,(NODE *)NULL), - Node_expression_list, - (NODE *) NULL); - } else if (r->proc == do_match) { - if (subn->rnode->lnode->type != Node_regex) - subn->rnode->lnode = mk_rexp(subn->rnode->lnode); - } else if (r->proc == do_sub || r->proc == do_gsub) { - if (subn->lnode->type != Node_regex) - subn->lnode = mk_rexp(subn->lnode); - if (nexp == 2) - append_right(subn, node(node(make_number(0.0), - Node_field_spec, - (NODE *) NULL), - Node_expression_list, - (NODE *) NULL)); - else if (do_lint && subn->rnode->rnode->lnode->type == Node_val) - warning("string literal as last arg of substitute"); - } else if (r->proc == do_split) { - if (nexp == 2) - append_right(subn, - node(FS_node, Node_expression_list, (NODE *) NULL)); - n = subn->rnode->rnode->lnode; - if (n->type != Node_regex) - subn->rnode->rnode->lnode = mk_rexp(n); - if (nexp == 2) - subn->rnode->rnode->lnode->re_flags |= FS_DFLT; - } - - r->subnode = subn; - return r; -} - -/* - * This allocates a Node_line_range node with defined condpair and - * zeroes the trigger word to avoid the temptation of assuming that calling - * 'node( foo, Node_line_range, 0)' will properly initialize 'triggered'. - */ -/* Otherwise like node() */ -static NODE * -mkrangenode(cpair) -NODE *cpair; -{ - register NODE *r; - - getnode(r); - r->type = Node_line_range; - r->condpair = cpair; - r->triggered = 0; - return r; -} - -/* Build a for loop */ -static NODE * -make_for_loop(init, cond, incr) -NODE *init, *cond, *incr; -{ - register FOR_LOOP_HEADER *r; - NODE *n; - - emalloc(r, FOR_LOOP_HEADER *, sizeof(FOR_LOOP_HEADER), "make_for_loop"); - getnode(n); - n->type = Node_illegal; - r->init = init; - r->cond = cond; - r->incr = incr; - n->sub.nodep.r.hd = r; - return n; -} - -/* - * Install a name in the symbol table, even if it is already there. - * Caller must check against redefinition if that is desired. - */ -NODE * -install(name, value) -char *name; -NODE *value; -{ - register NODE *hp; - register int len, bucket; - - len = strlen(name); - bucket = hash(name, len); - getnode(hp); - hp->type = Node_hashnode; - hp->hnext = variables[bucket]; - variables[bucket] = hp; - hp->hlength = len; - hp->hvalue = value; - hp->hname = name; - hp->hvalue->vname = name; - return hp->hvalue; -} - -/* find the most recent hash node for name installed by install */ -NODE * -lookup(name) -char *name; -{ - register NODE *bucket; - register int len; - - len = strlen(name); - bucket = variables[hash(name, len)]; - while (bucket) { - if (bucket->hlength == len && STREQN(bucket->hname, name, len)) - return bucket->hvalue; - bucket = bucket->hnext; - } - return NULL; -} - -/* - * Add new to the rightmost branch of LIST. This uses n^2 time, so we make - * a simple attempt at optimizing it. - */ -static NODE * -append_right(list, new) -NODE *list, *new; -{ - register NODE *oldlist; - static NODE *savefront = NULL, *savetail = NULL; - - oldlist = list; - if (savefront == oldlist) { - savetail = savetail->rnode = new; - return oldlist; - } else - savefront = oldlist; - while (list->rnode != NULL) - list = list->rnode; - savetail = list->rnode = new; - return oldlist; -} - -/* - * check if name is already installed; if so, it had better have Null value, - * in which case def is added as the value. Otherwise, install name with def - * as value. - */ -static void -func_install(params, def) -NODE *params; -NODE *def; -{ - NODE *r; - - pop_params(params->rnode); - pop_var(params, 0); - r = lookup(params->param); - if (r != NULL) { - fatal("function name `%s' previously defined", params->param); - } else - (void) install(params->param, node(params, Node_func, def)); -} - -static void -pop_var(np, freeit) -NODE *np; -int freeit; -{ - register NODE *bucket, **save; - register int len; - char *name; - - name = np->param; - len = strlen(name); - save = &(variables[hash(name, len)]); - for (bucket = *save; bucket; bucket = bucket->hnext) { - if (len == bucket->hlength && STREQN(bucket->hname, name, len)) { - *save = bucket->hnext; - freenode(bucket); - if (freeit) - free(np->param); - return; - } - save = &(bucket->hnext); - } -} - -static void -pop_params(params) -NODE *params; -{ - register NODE *np; - - for (np = params; np != NULL; np = np->rnode) - pop_var(np, 1); -} - -static NODE * -make_param(name) -char *name; -{ - NODE *r; - - getnode(r); - r->type = Node_param_list; - r->rnode = NULL; - r->param = name; - r->param_cnt = param_counter++; - return (install(name, r)); -} - -/* Name points to a variable name. Make sure its in the symbol table */ -NODE * -variable(name, can_free) -char *name; -int can_free; -{ - register NODE *r; - static int env_loaded = 0; - - if (!env_loaded && STREQ(name, "ENVIRON")) { - load_environ(); - env_loaded = 1; - } - if ((r = lookup(name)) == NULL) - r = install(name, node(Nnull_string, Node_var, (NODE *) NULL)); - else if (can_free) - free(name); - return r; -} - -static NODE * -mk_rexp(exp) -NODE *exp; -{ - if (exp->type == Node_regex) - return exp; - else { - NODE *n; - - getnode(n); - n->type = Node_regex; - n->re_exp = exp; - n->re_text = NULL; - n->re_reg = NULL; - n->re_flags = 0; - n->re_cnt = 1; - return n; - } -} diff --git a/gnu/usr.bin/gawk-2.15.2/builtin.c b/gnu/usr.bin/gawk-2.15.2/builtin.c deleted file mode 100644 index 9d5e3b302fde..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/builtin.c +++ /dev/null @@ -1,1133 +0,0 @@ -/* - * builtin.c - Builtin functions and various utility procedures - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -#include "awk.h" - - -#ifndef SRANDOM_PROTO -extern void srandom P((int seed)); -#endif -#ifndef linux -extern char *initstate P((unsigned seed, char *state, int n)); -extern char *setstate P((char *state)); -extern long random P((void)); -#endif - -extern NODE **fields_arr; -extern int output_is_tty; - -static NODE *sub_common P((NODE *tree, int global)); - -#ifdef GFMT_WORKAROUND -char *gfmt P((double g, int prec, char *buf)); -#endif - -#ifdef _CRAY -/* Work around a problem in conversion of doubles to exact integers. */ -#include -#define Floor(n) floor((n) * (1.0 + DBL_EPSILON)) -#define Ceil(n) ceil((n) * (1.0 + DBL_EPSILON)) - -/* Force the standard C compiler to use the library math functions. */ -extern double exp(double); -double (*Exp)() = exp; -#define exp(x) (*Exp)(x) -extern double log(double); -double (*Log)() = log; -#define log(x) (*Log)(x) -#else -#define Floor(n) floor(n) -#define Ceil(n) ceil(n) -#endif - -static void -efwrite(ptr, size, count, fp, from, rp, flush) -void *ptr; -unsigned size, count; -FILE *fp; -char *from; -struct redirect *rp; -int flush; -{ - errno = 0; - if (fwrite(ptr, size, count, fp) != count) - goto wrerror; - if (flush - && ((fp == stdout && output_is_tty) - || (rp && (rp->flag & RED_NOBUF)))) { - fflush(fp); - if (ferror(fp)) - goto wrerror; - } - return; - - wrerror: - fatal("%s to \"%s\" failed (%s)", from, - rp ? rp->value : "standard output", - errno ? strerror(errno) : "reason unknown"); -} - -/* Builtin functions */ -NODE * -do_exp(tree) -NODE *tree; -{ - NODE *tmp; - double d, res; -#ifndef exp - double exp P((double)); -#endif - - tmp= tree_eval(tree->lnode); - d = force_number(tmp); - free_temp(tmp); - errno = 0; - res = exp(d); - if (errno == ERANGE) - warning("exp argument %g is out of range", d); - return tmp_number((AWKNUM) res); -} - -NODE * -do_index(tree) -NODE *tree; -{ - NODE *s1, *s2; - register char *p1, *p2; - register int l1, l2; - long ret; - - - s1 = tree_eval(tree->lnode); - s2 = tree_eval(tree->rnode->lnode); - force_string(s1); - force_string(s2); - p1 = s1->stptr; - p2 = s2->stptr; - l1 = s1->stlen; - l2 = s2->stlen; - ret = 0; - if (IGNORECASE) { - while (l1) { - if (l2 > l1) - break; - if (casetable[(int)*p1] == casetable[(int)*p2] - && (l2 == 1 || strncasecmp(p1, p2, l2) == 0)) { - ret = 1 + s1->stlen - l1; - break; - } - l1--; - p1++; - } - } else { - while (l1) { - if (l2 > l1) - break; - if (*p1 == *p2 - && (l2 == 1 || STREQN(p1, p2, l2))) { - ret = 1 + s1->stlen - l1; - break; - } - l1--; - p1++; - } - } - free_temp(s1); - free_temp(s2); - return tmp_number((AWKNUM) ret); -} - -NODE * -do_int(tree) -NODE *tree; -{ - NODE *tmp; - double floor P((double)); - double ceil P((double)); - double d; - - tmp = tree_eval(tree->lnode); - d = force_number(tmp); - if (d >= 0) - d = Floor(d); - else - d = Ceil(d); - free_temp(tmp); - return tmp_number((AWKNUM) d); -} - -NODE * -do_length(tree) -NODE *tree; -{ - NODE *tmp; - int len; - - tmp = tree_eval(tree->lnode); - len = force_string(tmp)->stlen; - free_temp(tmp); - return tmp_number((AWKNUM) len); -} - -NODE * -do_log(tree) -NODE *tree; -{ - NODE *tmp; -#ifndef log - double log P((double)); -#endif - double d, arg; - - tmp = tree_eval(tree->lnode); - arg = (double) force_number(tmp); - if (arg < 0.0) - warning("log called with negative argument %g", arg); - d = log(arg); - free_temp(tmp); - return tmp_number((AWKNUM) d); -} - -/* %e and %f formats are not properly implemented. Someone should fix them */ -/* Actually, this whole thing should be reimplemented. */ - -NODE * -do_sprintf(tree) -NODE *tree; -{ -#define bchunk(s,l) if(l) {\ - while((l)>ofre) {\ - erealloc(obuf, char *, osiz*2, "do_sprintf");\ - ofre+=osiz;\ - osiz*=2;\ - }\ - memcpy(obuf+olen,s,(l));\ - olen+=(l);\ - ofre-=(l);\ - } - - /* Is there space for something L big in the buffer? */ -#define chksize(l) if((l)>ofre) {\ - erealloc(obuf, char *, osiz*2, "do_sprintf");\ - ofre+=osiz;\ - osiz*=2;\ - } - - /* - * Get the next arg to be formatted. If we've run out of args, - * return "" (Null string) - */ -#define parse_next_arg() {\ - if(!carg) { toofew = 1; break; }\ - else {\ - arg=tree_eval(carg->lnode);\ - carg=carg->rnode;\ - }\ - } - - NODE *r; - int toofew = 0; - char *obuf; - int osiz, ofre, olen; - static char chbuf[] = "0123456789abcdef"; - static char sp[] = " "; - char *s0, *s1; - int n0; - NODE *sfmt, *arg; - register NODE *carg; - long fw, prec, lj, alt, big; - long *cur; - long val; -#ifdef sun386 /* Can't cast unsigned (int/long) from ptr->value */ - long tmp_uval; /* on 386i 4.0.1 C compiler -- it just hangs */ -#endif - unsigned long uval; - int sgn; - int base; - char cpbuf[30]; /* if we have numbers bigger than 30 */ - char *cend = &cpbuf[30];/* chars, we lose, but seems unlikely */ - char *cp; - char *fill; - double tmpval; - char *pr_str; - int ucasehex = 0; - char signchar = 0; - int len; - - - emalloc(obuf, char *, 120, "do_sprintf"); - osiz = 120; - ofre = osiz - 1; - olen = 0; - sfmt = tree_eval(tree->lnode); - sfmt = force_string(sfmt); - carg = tree->rnode; - for (s0 = s1 = sfmt->stptr, n0 = sfmt->stlen; n0-- > 0;) { - if (*s1 != '%') { - s1++; - continue; - } - bchunk(s0, s1 - s0); - s0 = s1; - cur = &fw; - fw = 0; - prec = 0; - lj = alt = big = 0; - fill = sp; - cp = cend; - s1++; - -retry: - --n0; - switch (*s1++) { - case '%': - bchunk("%", 1); - s0 = s1; - break; - - case '0': - if (fill != sp || lj) - goto lose; - if (cur == &fw) - fill = "0"; /* FALL through */ - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (cur == 0) - goto lose; - *cur = s1[-1] - '0'; - while (n0 > 0 && *s1 >= '0' && *s1 <= '9') { - --n0; - *cur = *cur * 10 + *s1++ - '0'; - } - goto retry; - case '*': - if (cur == 0) - goto lose; - parse_next_arg(); - *cur = force_number(arg); - free_temp(arg); - goto retry; - case ' ': /* print ' ' or '-' */ - case '+': /* print '+' or '-' */ - signchar = *(s1-1); - goto retry; - case '-': - if (lj || fill != sp) - goto lose; - lj++; - goto retry; - case '.': - if (cur != &fw) - goto lose; - cur = ≺ - goto retry; - case '#': - if (alt) - goto lose; - alt++; - goto retry; - case 'l': - if (big) - goto lose; - big++; - goto retry; - case 'c': - parse_next_arg(); - if (arg->flags & NUMBER) { -#ifdef sun386 - tmp_uval = arg->numbr; - uval= (unsigned long) tmp_uval; -#else - uval = (unsigned long) arg->numbr; -#endif - cpbuf[0] = uval; - prec = 1; - pr_str = cpbuf; - goto dopr_string; - } - if (! prec) - prec = 1; - else if (prec > arg->stlen) - prec = arg->stlen; - pr_str = arg->stptr; - goto dopr_string; - case 's': - parse_next_arg(); - arg = force_string(arg); - if (!prec || prec > arg->stlen) - prec = arg->stlen; - pr_str = arg->stptr; - - dopr_string: - if (fw > prec && !lj) { - while (fw > prec) { - bchunk(sp, 1); - fw--; - } - } - bchunk(pr_str, (int) prec); - if (fw > prec) { - while (fw > prec) { - bchunk(sp, 1); - fw--; - } - } - s0 = s1; - free_temp(arg); - break; - case 'd': - case 'i': - parse_next_arg(); - val = (long) force_number(arg); - free_temp(arg); - if (val < 0) { - sgn = 1; - val = -val; - } else - sgn = 0; - do { - *--cp = '0' + val % 10; - val /= 10; - } while (val); - if (sgn) - *--cp = '-'; - else if (signchar) - *--cp = signchar; - if (prec > fw) - fw = prec; - prec = cend - cp; - if (fw > prec && !lj) { - if (fill != sp && (*cp == '-' || signchar)) { - bchunk(cp, 1); - cp++; - prec--; - fw--; - } - while (fw > prec) { - bchunk(fill, 1); - fw--; - } - } - bchunk(cp, (int) prec); - if (fw > prec) { - while (fw > prec) { - bchunk(fill, 1); - fw--; - } - } - s0 = s1; - break; - case 'u': - base = 10; - goto pr_unsigned; - case 'o': - base = 8; - goto pr_unsigned; - case 'X': - ucasehex = 1; - case 'x': - base = 16; - goto pr_unsigned; - pr_unsigned: - parse_next_arg(); - uval = (unsigned long) force_number(arg); - free_temp(arg); - do { - *--cp = chbuf[uval % base]; - if (ucasehex && isalpha(*cp)) - *cp = toupper(*cp); - uval /= base; - } while (uval); - if (alt && (base == 8 || base == 16)) { - if (base == 16) { - if (ucasehex) - *--cp = 'X'; - else - *--cp = 'x'; - } - *--cp = '0'; - } - prec = cend - cp; - if (fw > prec && !lj) { - while (fw > prec) { - bchunk(fill, 1); - fw--; - } - } - bchunk(cp, (int) prec); - if (fw > prec) { - while (fw > prec) { - bchunk(fill, 1); - fw--; - } - } - s0 = s1; - break; - case 'g': - parse_next_arg(); - tmpval = force_number(arg); - free_temp(arg); - chksize(fw + prec + 9); /* 9==slop */ - - cp = cpbuf; - *cp++ = '%'; - if (lj) - *cp++ = '-'; - if (fill != sp) - *cp++ = '0'; -#ifndef GFMT_WORKAROUND - if (cur != &fw) { - (void) strcpy(cp, "*.*g"); - (void) sprintf(obuf + olen, cpbuf, (int) fw, (int) prec, (double) tmpval); - } else { - (void) strcpy(cp, "*g"); - (void) sprintf(obuf + olen, cpbuf, (int) fw, (double) tmpval); - } -#else /* GFMT_WORKAROUND */ - { - char *gptr, gbuf[120]; -#define DEFAULT_G_PRECISION 6 - if (fw + prec + 9 > sizeof gbuf) { /* 9==slop */ - emalloc(gptr, char *, fw+prec+9, "do_sprintf(gfmt)"); - } else - gptr = gbuf; - (void) gfmt((double) tmpval, cur != &fw ? - (int) prec : DEFAULT_G_PRECISION, gptr); - *cp++ = '*', *cp++ = 's', *cp = '\0'; - (void) sprintf(obuf + olen, cpbuf, (int) fw, gptr); - if (fill != sp && *gptr == ' ') { - char *p = gptr; - do { *p++ = '0'; } while (*p == ' '); - } - if (gptr != gbuf) free(gptr); - } -#endif /* GFMT_WORKAROUND */ - len = strlen(obuf + olen); - ofre -= len; - olen += len; - s0 = s1; - break; - - case 'f': - parse_next_arg(); - tmpval = force_number(arg); - free_temp(arg); - chksize(fw + prec + 9); /* 9==slop */ - - cp = cpbuf; - *cp++ = '%'; - if (lj) - *cp++ = '-'; - if (fill != sp) - *cp++ = '0'; - if (cur != &fw) { - (void) strcpy(cp, "*.*f"); - (void) sprintf(obuf + olen, cpbuf, (int) fw, (int) prec, (double) tmpval); - } else { - (void) strcpy(cp, "*f"); - (void) sprintf(obuf + olen, cpbuf, (int) fw, (double) tmpval); - } - len = strlen(obuf + olen); - ofre -= len; - olen += len; - s0 = s1; - break; - case 'e': - parse_next_arg(); - tmpval = force_number(arg); - free_temp(arg); - chksize(fw + prec + 9); /* 9==slop */ - cp = cpbuf; - *cp++ = '%'; - if (lj) - *cp++ = '-'; - if (fill != sp) - *cp++ = '0'; - if (cur != &fw) { - (void) strcpy(cp, "*.*e"); - (void) sprintf(obuf + olen, cpbuf, (int) fw, (int) prec, (double) tmpval); - } else { - (void) strcpy(cp, "*e"); - (void) sprintf(obuf + olen, cpbuf, (int) fw, (double) tmpval); - } - len = strlen(obuf + olen); - ofre -= len; - olen += len; - s0 = s1; - break; - - default: - lose: - break; - } - if (toofew) - fatal("%s\n\t%s\n\t%*s%s", - "not enough arguments to satisfy format string", - sfmt->stptr, s1 - sfmt->stptr - 2, "", - "^ ran out for this one" - ); - } - if (do_lint && carg != NULL) - warning("too many arguments supplied for format string"); - bchunk(s0, s1 - s0); - free_temp(sfmt); - r = make_str_node(obuf, olen, ALREADY_MALLOCED); - r->flags |= TEMP; - return r; -} - -void -do_printf(tree) -register NODE *tree; -{ - struct redirect *rp = NULL; - register FILE *fp; - - if (tree->rnode) { - int errflg; /* not used, sigh */ - - rp = redirect(tree->rnode, &errflg); - if (rp) { - fp = rp->fp; - if (!fp) - return; - } else - return; - } else - fp = stdout; - tree = do_sprintf(tree->lnode); - efwrite(tree->stptr, sizeof(char), tree->stlen, fp, "printf", rp , 1); - free_temp(tree); -} - -NODE * -do_sqrt(tree) -NODE *tree; -{ - NODE *tmp; - double arg; - extern double sqrt P((double)); - - tmp = tree_eval(tree->lnode); - arg = (double) force_number(tmp); - free_temp(tmp); - if (arg < 0.0) - warning("sqrt called with negative argument %g", arg); - return tmp_number((AWKNUM) sqrt(arg)); -} - -NODE * -do_substr(tree) -NODE *tree; -{ - NODE *t1, *t2, *t3; - NODE *r; - register int indx; - size_t length; - - t1 = tree_eval(tree->lnode); - t2 = tree_eval(tree->rnode->lnode); - if (tree->rnode->rnode == NULL) /* third arg. missing */ - length = t1->stlen; - else { - t3 = tree_eval(tree->rnode->rnode->lnode); - length = (size_t) force_number(t3); - free_temp(t3); - } - indx = (int) force_number(t2) - 1; - free_temp(t2); - t1 = force_string(t1); - if (indx < 0) - indx = 0; - if (indx >= t1->stlen || length <= 0) { - free_temp(t1); - return Nnull_string; - } - if (indx + length > t1->stlen || LONG_MAX - indx < length) - length = t1->stlen - indx; - r = tmp_string(t1->stptr + indx, length); - free_temp(t1); - return r; -} - -NODE * -do_strftime(tree) -NODE *tree; -{ - NODE *t1, *t2; - struct tm *tm; - time_t fclock; - char buf[100]; - int ret; - - t1 = force_string(tree_eval(tree->lnode)); - - if (tree->rnode == NULL) /* second arg. missing, default */ - (void) time(&fclock); - else { - t2 = tree_eval(tree->rnode->lnode); - fclock = (time_t) force_number(t2); - free_temp(t2); - } - tm = localtime(&fclock); - - ret = strftime(buf, 100, t1->stptr, tm); - - return tmp_string(buf, ret); -} - -NODE * -do_systime(tree) -NODE *tree; -{ - time_t lclock; - - (void) time(&lclock); - return tmp_number((AWKNUM) lclock); -} - -NODE * -do_system(tree) -NODE *tree; -{ - NODE *tmp; - int ret = 0; - char *cmd; - - (void) flush_io (); /* so output is synchronous with gawk's */ - tmp = tree_eval(tree->lnode); - cmd = force_string(tmp)->stptr; - if (cmd && *cmd) { - ret = system(cmd); - ret = (ret >> 8) & 0xff; - } - free_temp(tmp); - return tmp_number((AWKNUM) ret); -} - -void -do_print(tree) -register NODE *tree; -{ - register NODE *t1; - struct redirect *rp = NULL; - register FILE *fp; - register char *s; - - if (tree->rnode) { - int errflg; /* not used, sigh */ - - rp = redirect(tree->rnode, &errflg); - if (rp) { - fp = rp->fp; - if (!fp) - return; - } else - return; - } else - fp = stdout; - tree = tree->lnode; - while (tree) { - t1 = tree_eval(tree->lnode); - if (t1->flags & NUMBER) { - if (OFMTidx == CONVFMTidx) - (void) force_string(t1); - else { - char buf[100]; - - sprintf(buf, OFMT, t1->numbr); - t1 = tmp_string(buf, strlen(buf)); - } - } - efwrite(t1->stptr, sizeof(char), t1->stlen, fp, "print", rp, 0); - free_temp(t1); - tree = tree->rnode; - if (tree) { - s = OFS; - if (OFSlen) - efwrite(s, sizeof(char), OFSlen, fp, "print", rp, 0); - } - } - s = ORS; - if (ORSlen) - efwrite(s, sizeof(char), ORSlen, fp, "print", rp, 1); -} - -NODE * -do_tolower(tree) -NODE *tree; -{ - NODE *t1, *t2; - register char *cp, *cp2; - - t1 = tree_eval(tree->lnode); - t1 = force_string(t1); - t2 = tmp_string(t1->stptr, t1->stlen); - for (cp = t2->stptr, cp2 = t2->stptr + t2->stlen; cp < cp2; cp++) - if (isupper(*cp)) - *cp = tolower(*cp); - free_temp(t1); - return t2; -} - -NODE * -do_toupper(tree) -NODE *tree; -{ - NODE *t1, *t2; - register char *cp; - - t1 = tree_eval(tree->lnode); - t1 = force_string(t1); - t2 = tmp_string(t1->stptr, t1->stlen); - for (cp = t2->stptr; cp < t2->stptr + t2->stlen; cp++) - if (islower(*cp)) - *cp = toupper(*cp); - free_temp(t1); - return t2; -} - -NODE * -do_atan2(tree) -NODE *tree; -{ - NODE *t1, *t2; - extern double atan2 P((double, double)); - double d1, d2; - - t1 = tree_eval(tree->lnode); - t2 = tree_eval(tree->rnode->lnode); - d1 = force_number(t1); - d2 = force_number(t2); - free_temp(t1); - free_temp(t2); - return tmp_number((AWKNUM) atan2(d1, d2)); -} - -NODE * -do_sin(tree) -NODE *tree; -{ - NODE *tmp; - extern double sin P((double)); - double d; - - tmp = tree_eval(tree->lnode); - d = sin((double)force_number(tmp)); - free_temp(tmp); - return tmp_number((AWKNUM) d); -} - -NODE * -do_cos(tree) -NODE *tree; -{ - NODE *tmp; - extern double cos P((double)); - double d; - - tmp = tree_eval(tree->lnode); - d = cos((double)force_number(tmp)); - free_temp(tmp); - return tmp_number((AWKNUM) d); -} - -static int firstrand = 1; -static char state[256]; - -/* ARGSUSED */ -NODE * -do_rand(tree) -NODE *tree; -{ - if (firstrand) { - (void) initstate((unsigned) 1, state, sizeof state); - srandom(1); - firstrand = 0; - } - return tmp_number((AWKNUM) random() / LONG_MAX); -} - -NODE * -do_srand(tree) -NODE *tree; -{ - NODE *tmp; - static long save_seed = 0; - long ret = save_seed; /* SVR4 awk srand returns previous seed */ - - if (firstrand) - (void) initstate((unsigned) 1, state, sizeof state); - else - (void) setstate(state); - - if (!tree) - srandom((int) (save_seed = (long) time((time_t *) 0))); - else { - tmp = tree_eval(tree->lnode); - srandom((int) (save_seed = (long) force_number(tmp))); - free_temp(tmp); - } - firstrand = 0; - return tmp_number((AWKNUM) ret); -} - -NODE * -do_match(tree) -NODE *tree; -{ - NODE *t1; - int rstart; - AWKNUM rlength; - Regexp *rp; - - t1 = force_string(tree_eval(tree->lnode)); - tree = tree->rnode->lnode; - rp = re_update(tree); - rstart = research(rp, t1->stptr, 0, t1->stlen, 1); - if (rstart >= 0) { /* match succeded */ - rstart++; /* 1-based indexing */ - rlength = REEND(rp, t1->stptr) - RESTART(rp, t1->stptr); - } else { /* match failed */ - rstart = 0; - rlength = -1.0; - } - free_temp(t1); - unref(RSTART_node->var_value); - RSTART_node->var_value = make_number((AWKNUM) rstart); - unref(RLENGTH_node->var_value); - RLENGTH_node->var_value = make_number(rlength); - return tmp_number((AWKNUM) rstart); -} - -static NODE * -sub_common(tree, global) -NODE *tree; -int global; -{ - register char *scan; - register char *bp, *cp; - char *buf; - int buflen; - register char *matchend; - register int len; - char *matchstart; - char *text; - int textlen; - char *repl; - char *replend; - int repllen; - int sofar; - int ampersands; - int matches = 0; - Regexp *rp; - NODE *s; /* subst. pattern */ - NODE *t; /* string to make sub. in; $0 if none given */ - NODE *tmp; - NODE **lhs = &tree; /* value not used -- just different from NULL */ - int priv = 0; - Func_ptr after_assign = NULL; - - tmp = tree->lnode; - rp = re_update(tmp); - - tree = tree->rnode; - s = tree->lnode; - - tree = tree->rnode; - tmp = tree->lnode; - t = force_string(tree_eval(tmp)); - - /* do the search early to avoid work on non-match */ - if (research(rp, t->stptr, 0, t->stlen, 1) == -1 || - (RESTART(rp, t->stptr) > t->stlen) && (matches = 1)) { - free_temp(t); - return tmp_number((AWKNUM) matches); - } - - if (tmp->type == Node_val) - lhs = NULL; - else - lhs = get_lhs(tmp, &after_assign); - t->flags |= STRING; - /* - * create a private copy of the string - */ - if (t->stref > 1 || (t->flags & PERM)) { - unsigned int saveflags; - - saveflags = t->flags; - t->flags &= ~MALLOC; - tmp = dupnode(t); - t->flags = saveflags; - t = tmp; - priv = 1; - } - text = t->stptr; - textlen = t->stlen; - buflen = textlen + 2; - - s = force_string(tree_eval(s)); - repl = s->stptr; - replend = repl + s->stlen; - repllen = replend - repl; - emalloc(buf, char *, buflen, "do_sub"); - ampersands = 0; - for (scan = repl; scan < replend; scan++) { - if (*scan == '&') { - repllen--; - ampersands++; - } else if (*scan == '\\' && (*(scan+1) == '&' || *(scan+1) == '\\')) { - repllen--; - scan++; - } - } - - bp = buf; - for (;;) { - matches++; - matchstart = t->stptr + RESTART(rp, t->stptr); - matchend = t->stptr + REEND(rp, t->stptr); - - /* - * create the result, copying in parts of the original - * string - */ - len = matchstart - text + repllen - + ampersands * (matchend - matchstart); - sofar = bp - buf; - while (buflen - sofar - len - 1 < 0) { - buflen *= 2; - erealloc(buf, char *, buflen, "do_sub"); - bp = buf + sofar; - } - for (scan = text; scan < matchstart; scan++) - *bp++ = *scan; - for (scan = repl; scan < replend; scan++) - if (*scan == '&') - for (cp = matchstart; cp < matchend; cp++) - *bp++ = *cp; - else if (*scan == '\\' && (*(scan+1) == '&' || *(scan+1) == '\\')) { - scan++; - *bp++ = *scan; - } else - *bp++ = *scan; - if (global && matchstart == matchend && matchend < text + textlen) { - *bp++ = *matchend; - matchend++; - } - textlen = text + textlen - matchend; - text = matchend; - if (!global || textlen <= 0 || - research(rp, t->stptr, text-t->stptr, textlen, 1) == -1) - break; - } - sofar = bp - buf; - if (buflen - sofar - textlen - 1) { - buflen = sofar + textlen + 2; - erealloc(buf, char *, buflen, "do_sub"); - bp = buf + sofar; - } - for (scan = matchend; scan < text + textlen; scan++) - *bp++ = *scan; - textlen = bp - buf; - free(t->stptr); - t->stptr = buf; - t->stlen = textlen; - - free_temp(s); - if (matches > 0 && lhs) { - if (priv) { - unref(*lhs); - *lhs = t; - } - if (after_assign) - (*after_assign)(); - t->flags &= ~(NUM|NUMBER); - } - return tmp_number((AWKNUM) matches); -} - -NODE * -do_gsub(tree) -NODE *tree; -{ - return sub_common(tree, 1); -} - -NODE * -do_sub(tree) -NODE *tree; -{ - return sub_common(tree, 0); -} - -#ifdef GFMT_WORKAROUND - /* - * printf's %g format [can't rely on gcvt()] - * caveat: don't use as argument to *printf()! - */ -char * -gfmt(g, prec, buf) -double g; /* value to format */ -int prec; /* indicates desired significant digits, not decimal places */ -char *buf; /* return buffer; assumed big enough to hold result */ -{ - if (g == 0.0) { - (void) strcpy(buf, "0"); /* easy special case */ - } else { - register char *d, *e, *p; - - /* start with 'e' format (it'll provide nice exponent) */ - if (prec < 1) prec = 1; /* at least 1 significant digit */ - (void) sprintf(buf, "%.*e", prec - 1, g); - if ((e = strchr(buf, 'e')) != 0) { /* find exponent */ - int exp = atoi(e+1); /* fetch exponent */ - if (exp >= -4 && exp < prec) { /* per K&R2, B1.2 */ - /* switch to 'f' format and re-do */ - prec -= (exp + 1); /* decimal precision */ - (void) sprintf(buf, "%.*f", prec, g); - e = buf + strlen(buf); - } - if ((d = strchr(buf, '.')) != 0) { - /* remove trailing zeroes and decimal point */ - for (p = e; p > d && *--p == '0'; ) continue; - if (*p == '.') --p; - if (++p < e) /* copy exponent and NUL */ - while ((*p++ = *e++) != '\0') continue; - } - } - } - return buf; -} -#endif /* GFMT_WORKAROUND */ diff --git a/gnu/usr.bin/gawk-2.15.2/config.h b/gnu/usr.bin/gawk-2.15.2/config.h deleted file mode 100644 index 8c20953ed531..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/config.h +++ /dev/null @@ -1,272 +0,0 @@ -/* - * config.h -- configuration definitions for gawk. - * - * For generic 4.4 alpha - */ - -/* - * Copyright (C) 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* - * This file isolates configuration dependencies for gnu awk. - * You should know something about your system, perhaps by having - * a manual handy, when you edit this file. You should copy config.h-dist - * to config.h, and edit config.h. Do not modify config.h-dist, so that - * it will be easy to apply any patches that may be distributed. - * - * The general idea is that systems conforming to the various standards - * should need to do the least amount of changing. Definining the various - * items in ths file usually means that your system is missing that - * particular feature. - * - * The order of preference in standard conformance is ANSI C, POSIX, - * and the SVID. - * - * If you have no clue as to what's going on with your system, try - * compiling gawk without editing this file and see what shows up - * missing in the link stage. From there, you can probably figure out - * which defines to turn on. - */ - -/**************************/ -/* Miscellanious features */ -/**************************/ - -/* - * BLKSIZE_MISSING - * - * Check your /usr/include/sys/stat.h file. If the stat structure - * does not have a member named st_blksize, define this. (This will - * most likely be the case on most System V systems prior to V.4.) - */ -/* #define BLKSIZE_MISSING 1 */ - -/* - * SIGTYPE - * - * The return type of the routines passed to the signal function. - * Modern systems use `void', older systems use `int'. - * If left undefined, it will default to void. - */ -/* #define SIGTYPE int */ - -/* - * SIZE_T_MISSING - * - * If your system has no typedef for size_t, define this to get a default - */ -/* #define SIZE_T_MISSING 1 */ - -/* - * CHAR_UNSIGNED - * - * If your machine uses unsigned characters (IBM RT and RS/6000 and others) - * then define this for use in regex.c - */ -/* #define CHAR_UNSIGNED 1 */ - -/* - * HAVE_UNDERSCORE_SETJMP - * - * Check in your /usr/include/setjmp.h file. If there are routines - * there named _setjmp and _longjmp, then you should define this. - * Typically only systems derived from Berkeley Unix have this. - */ -#define HAVE_UNDERSCORE_SETJMP 1 - -/***********************************************/ -/* Missing library subroutines or system calls */ -/***********************************************/ - -/* - * MEMCMP_MISSING - * MEMCPY_MISSING - * MEMSET_MISSING - * - * These three routines are for manipulating blocks of memory. Most - * likely they will either all three be present or all three be missing, - * so they're grouped together. - */ -/* #define MEMCMP_MISSING 1 */ -/* #define MEMCPY_MISSING 1 */ -/* #define MEMSET_MISSING 1 */ - -/* - * RANDOM_MISSING - * - * Your system does not have the random(3) suite of random number - * generating routines. These are different than the old rand(3) - * routines! - */ -/* #define RANDOM_MISSING 1 */ - -/* - * STRCASE_MISSING - * - * Your system does not have the strcasemp() and strncasecmp() - * routines that originated in Berkeley Unix. - */ -/* #define STRCASE_MISSING 1 */ - -/* - * STRCHR_MISSING - * - * Your system does not have the strchr() and strrchr() functions. - */ -/* #define STRCHR_MISSING 1 */ - -/* - * STRERROR_MISSING - * - * Your system lacks the ANSI C strerror() routine for returning the - * strings associated with errno values. - */ -/* #define STRERROR_MISSING 1 */ - -/* - * STRTOD_MISSING - * - * Your system does not have the strtod() routine for converting - * strings to double precision floating point values. - */ -/* #define STRTOD_MISSING 1 */ - -/* - * STRFTIME_MISSING - * - * Your system lacks the ANSI C strftime() routine for formatting - * broken down time values. - */ -/* #define STRFTIME_MISSING 1 */ - -/* - * TZSET_MISSING - * - * If you have a 4.2 BSD vintage system, then the strftime() routine - * supplied in the missing directory won't be enough, because it relies on the - * tzset() routine from System V / Posix. Fortunately, there is an - * emulation for tzset() too that should do the trick. If you don't - * have tzset(), define this. - */ -/* #define TZSET_MISSING 1 */ - -/* - * TZNAME_MISSING - * - * Some systems do not support the external variables tzname and daylight. - * If this is the case *and* strftime() is missing, define this. - */ -/* #define TZNAME_MISSING 1 */ - -/* - * STDC_HEADERS - * - * If your system does have ANSI compliant header files that - * provide prototypes for library routines, then define this. - */ -#define STDC_HEADERS 1 - -/* - * NO_TOKEN_PASTING - * - * If your compiler define's __STDC__ but does not support token - * pasting (tok##tok), then define this. - */ -/* #define NO_TOKEN_PASTING 1 */ - -/*****************************************************************/ -/* Stuff related to the Standard I/O Library. */ -/*****************************************************************/ -/* Much of this is (still, unfortunately) black magic in nature. */ -/* You may have to use some or all of these together to get gawk */ -/* to work correctly. */ -/*****************************************************************/ - -/* - * NON_STD_SPRINTF - * - * Look in your /usr/include/stdio.h file. If the return type of the - * sprintf() function is NOT `int', define this. - */ -/* #define NON_STD_SPRINTF 1 */ - -/* - * VPRINTF_MISSING - * - * Define this if your system lacks vprintf() and the other routines - * that go with it. This will trigger an attempt to use _doprnt(). - * If you don't have that, this attempt will fail and you are on your own. - */ -/* #define VPRINTF_MISSING 1 */ - -/* - * Casts from size_t to int and back. These will become unnecessary - * at some point in the future, but for now are required where the - * two types are a different representation. - */ -/* #define SZTC */ -/* #define INTC */ - -/* - * SYSTEM_MISSING - * - * Define this if your library does not provide a system function - * or you are not entirely happy with it and would rather use - * a provided replacement (atari only). - */ -/* #define SYSTEM_MISSING 1 */ - -/* - * FMOD_MISSING - * - * Define this if your system lacks the fmod() function and modf() will - * be used instead. - */ -/* #define FMOD_MISSING 1 */ - - -/*******************************/ -/* Gawk configuration options. */ -/*******************************/ - -/* - * DEFPATH - * - * The default search path for the -f option of gawk. It is used - * if the AWKPATH environment variable is undefined. The default - * definition is provided here. Most likely you should not change - * this. - */ - -/* #define DEFPATH ".:/usr/lib/awk:/usr/local/lib/awk" */ -/* #define ENVSEP ':' */ - -/* - * alloca already has a prototype defined - don't redefine it - */ -#define ALLOCA_PROTO 1 - -/* - * srandom already has a prototype defined - don't redefine it - */ -#define SRANDOM_PROTO 1 - -/* anything that follows is for system-specific short-term kludges */ diff --git a/gnu/usr.bin/gawk-2.15.2/dfa.c b/gnu/usr.bin/gawk-2.15.2/dfa.c deleted file mode 100644 index 5293c755871d..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/dfa.c +++ /dev/null @@ -1,2291 +0,0 @@ -/* dfa.c - determinisitic extended regexp routines for GNU - Copyright (C) 1988 Free Software Foundation, Inc. - Written June, 1988 by Mike Haertel - Modified July, 1988 by Arthur David Olson - to assist BMG speedups - - NO WARRANTY - - BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY -NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT -WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, -RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS 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. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. -STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY -WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE -LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR -OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR -DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR -A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS -PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. - - GENERAL PUBLIC LICENSE TO COPY - - 1. You may copy and distribute verbatim copies of this source file -as you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy a valid copyright notice "Copyright - (C) 1988 Free Software Foundation, Inc."; and include following the -copyright notice a verbatim copy of the above disclaimer of warranty -and of this License. You may charge a distribution fee for the -physical act of transferring a copy. - - 2. You may modify your copy or copies of this source file or -any portion of it, and copy and distribute such modifications under -the terms of Paragraph 1 above, provided that you also do the following: - - a) cause the modified files to carry prominent notices stating - that you changed the files and the date of any change; and - - b) cause the whole of any work that you distribute or publish, - that in whole or in part contains or is a derivative of this - program or any part thereof, to be licensed at no charge to all - third parties on terms identical to those contained in this - License Agreement (except that you may choose to grant more extensive - warranty protection to some or all third parties, at your option). - - c) You may charge a distribution fee for the physical act of - transferring a copy, and you may at your option offer warranty - protection in exchange for a fee. - -Mere aggregation of another unrelated program with this program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other program under the scope of these terms. - - 3. You may copy and distribute this program or any portion of it in -compiled, executable or object code form under the terms of Paragraphs -1 and 2 above provided that you do the following: - - a) accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of - Paragraphs 1 and 2 above; or, - - b) accompany it with a written offer, valid for at least three - years, to give any third party free (except for a nominal - shipping charge) a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of - Paragraphs 1 and 2 above; or, - - c) accompany it with the information you received as to where the - corresponding source code may be obtained. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form alone.) - -For an executable file, complete source code means all the source code for -all modules it contains; but, as a special exception, it need not include -source code for modules which are standard libraries that accompany the -operating system on which the executable file runs. - - 4. You may not copy, sublicense, distribute or transfer this program -except as expressly provided under this License Agreement. Any attempt -otherwise to copy, sublicense, distribute or transfer this program is void and -your rights to use the program under this License agreement shall be -automatically terminated. However, parties who have received computer -software programs from you with this License Agreement will not have -their licenses terminated so long as such parties remain in full compliance. - - 5. If you wish to incorporate parts of this program into other free -programs whose distribution conditions are different, write to the Free -Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet -worked out a simple rule that can be stated here, but we will often permit -this. We will be guided by the two goals of preserving the free status of -all derivatives our free software and of promoting the sharing and reuse of -software. - - -In other words, you are welcome to use, share and improve this program. -You are forbidden to forbid anyone else to use, share and improve -what you give them. Help stamp out software-hoarding! */ - -#include "awk.h" -#include - -#ifdef setbit /* surprise - setbit and clrbit are macros on NeXT */ -#undef setbit -#endif -#ifdef clrbit -#undef clrbit -#endif - -#ifdef __STDC__ -typedef void *ptr_t; -#else -typedef char *ptr_t; -#endif - -typedef struct { - char ** in; - char * left; - char * right; - char * is; -} must; - -static ptr_t xcalloc P((int n, size_t s)); -static ptr_t xmalloc P((size_t n)); -static ptr_t xrealloc P((ptr_t p, size_t n)); -static int tstbit P((int b, _charset c)); -static void setbit P((int b, _charset c)); -static void clrbit P((int b, _charset c)); -static void copyset P((const _charset src, _charset dst)); -static void zeroset P((_charset s)); -static void notset P((_charset s)); -static int equal P((const _charset s1, const _charset s2)); -static int charset_index P((const _charset s)); -static _token lex P((void)); -static void addtok P((_token t)); -static void atom P((void)); -static void closure P((void)); -static void branch P((void)); -static void regexp P((void)); -static void copy P((const _position_set *src, _position_set *dst)); -static void insert P((_position p, _position_set *s)); -static void merge P((_position_set *s1, _position_set *s2, _position_set *m)); -static void delete P((_position p, _position_set *s)); -static int state_index P((struct regexp *r, _position_set *s, - int newline, int letter)); -static void epsclosure P((_position_set *s, struct regexp *r)); -static void build_state P((int s, struct regexp *r)); -static void build_state_zero P((struct regexp *r)); -static char *icatalloc P((char *old, const char *new)); -static char *icpyalloc P((const char *string)); -static char *istrstr P((char *lookin, char *lookfor)); -static void ifree P((char *cp)); -static void freelist P((char **cpp)); -static char **enlist P((char **cpp, char *new, size_t len)); -static char **comsubs P((char *left, char *right)); -static char **addlists P((char **old, char **new)); -static char **inboth P((char **left, char **right)); -static void resetmust P((must *mp)); -static void regmust P((struct regexp *r)); - -#undef P - -static ptr_t -xcalloc(n, s) - int n; - size_t s; -{ - ptr_t r = calloc(n, s); - - if (NULL == r) - reg_error("Memory exhausted"); /* reg_error does not return */ - return r; -} - -static ptr_t -xmalloc(n) - size_t n; -{ - ptr_t r = malloc(n); - - assert(n != 0); - if (NULL == r) - reg_error("Memory exhausted"); - return r; -} - -static ptr_t -xrealloc(p, n) - ptr_t p; - size_t n; -{ - ptr_t r = realloc(p, n); - - assert(n != 0); - if (NULL == r) - reg_error("Memory exhausted"); - return r; -} - -#define CALLOC(p, t, n) ((p) = (t *) xcalloc((n), sizeof (t))) -#undef MALLOC -#define MALLOC(p, t, n) ((p) = (t *) xmalloc((n) * sizeof (t))) -#define REALLOC(p, t, n) ((p) = (t *) xrealloc((ptr_t) (p), (n) * sizeof (t))) - -/* Reallocate an array of type t if nalloc is too small for index. */ -#define REALLOC_IF_NECESSARY(p, t, nalloc, index) \ - if ((index) >= (nalloc)) \ - { \ - while ((index) >= (nalloc)) \ - (nalloc) *= 2; \ - REALLOC(p, t, nalloc); \ - } - -/* Stuff pertaining to charsets. */ - -static int -tstbit(b, c) - int b; - _charset c; -{ - return c[b / INTBITS] & 1 << b % INTBITS; -} - -static void -setbit(b, c) - int b; - _charset c; -{ - c[b / INTBITS] |= 1 << b % INTBITS; -} - -static void -clrbit(b, c) - int b; - _charset c; -{ - c[b / INTBITS] &= ~(1 << b % INTBITS); -} - -static void -copyset(src, dst) - const _charset src; - _charset dst; -{ - int i; - - for (i = 0; i < _CHARSET_INTS; ++i) - dst[i] = src[i]; -} - -static void -zeroset(s) - _charset s; -{ - int i; - - for (i = 0; i < _CHARSET_INTS; ++i) - s[i] = 0; -} - -static void -notset(s) - _charset s; -{ - int i; - - for (i = 0; i < _CHARSET_INTS; ++i) - s[i] = ~s[i]; -} - -static int -equal(s1, s2) - const _charset s1; - const _charset s2; -{ - int i; - - for (i = 0; i < _CHARSET_INTS; ++i) - if (s1[i] != s2[i]) - return 0; - return 1; -} - -/* A pointer to the current regexp is kept here during parsing. */ -static struct regexp *reg; - -/* Find the index of charset s in reg->charsets, or allocate a new charset. */ -static int -charset_index(s) - const _charset s; -{ - int i; - - for (i = 0; i < reg->cindex; ++i) - if (equal(s, reg->charsets[i])) - return i; - REALLOC_IF_NECESSARY(reg->charsets, _charset, reg->calloc, reg->cindex); - ++reg->cindex; - copyset(s, reg->charsets[i]); - return i; -} - -/* Syntax bits controlling the behavior of the lexical analyzer. */ -static syntax_bits, syntax_bits_set; - -/* Flag for case-folding letters into sets. */ -static case_fold; - -/* Entry point to set syntax options. */ -void -regsyntax(bits, fold) - long bits; - int fold; -{ - syntax_bits_set = 1; - syntax_bits = bits; - case_fold = fold; -} - -/* Lexical analyzer. */ -static const char *lexstart; /* Pointer to beginning of input string. */ -static const char *lexptr; /* Pointer to next input character. */ -static lexleft; /* Number of characters remaining. */ -static caret_allowed; /* True if backward context allows ^ - (meaningful only if RE_CONTEXT_INDEP_OPS - is turned off). */ -static closure_allowed; /* True if backward context allows closures - (meaningful only if RE_CONTEXT_INDEP_OPS - is turned off). */ - -/* Note that characters become unsigned here. */ -#define FETCH(c, eoferr) \ - { \ - if (! lexleft) \ - if (eoferr != NULL) \ - reg_error(eoferr); \ - else \ - return _END; \ - (c) = (unsigned char) *lexptr++; \ - --lexleft; \ - } - -static _token -lex() -{ - _token c, c2; - int invert; - _charset cset; - - FETCH(c, (char *) 0); - switch (c) - { - case '^': - if (! (syntax_bits & RE_CONTEXT_INDEP_OPS) - && (!caret_allowed || - ((syntax_bits & RE_TIGHT_VBAR) && lexptr - 1 != lexstart))) - goto normal_char; - caret_allowed = 0; - return syntax_bits & RE_TIGHT_VBAR ? _ALLBEGLINE : _BEGLINE; - - case '$': - if (syntax_bits & RE_CONTEXT_INDEP_OPS || !lexleft - || (! (syntax_bits & RE_TIGHT_VBAR) - && ((syntax_bits & RE_NO_BK_PARENS - ? lexleft > 0 && *lexptr == ')' - : lexleft > 1 && *lexptr == '\\' && lexptr[1] == ')') - || (syntax_bits & RE_NO_BK_VBAR - ? lexleft > 0 && *lexptr == '|' - : lexleft > 1 && *lexptr == '\\' && lexptr[1] == '|')))) - return syntax_bits & RE_TIGHT_VBAR ? _ALLENDLINE : _ENDLINE; - goto normal_char; - - case '\\': - FETCH(c, "Unfinished \\ quote"); - switch (c) - { - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - caret_allowed = 0; - closure_allowed = 1; - return _BACKREF; - - case '<': - caret_allowed = 0; - return _BEGWORD; - - case '>': - caret_allowed = 0; - return _ENDWORD; - - case 'b': - caret_allowed = 0; - return _LIMWORD; - - case 'B': - caret_allowed = 0; - return _NOTLIMWORD; - - case 'w': - case 'W': - zeroset(cset); - for (c2 = 0; c2 < _NOTCHAR; ++c2) - if (ISALNUM(c2)) - setbit(c2, cset); - if (c == 'W') - notset(cset); - caret_allowed = 0; - closure_allowed = 1; - return _SET + charset_index(cset); - - case '?': - if (syntax_bits & RE_BK_PLUS_QM) - goto qmark; - goto normal_char; - - case '+': - if (syntax_bits & RE_BK_PLUS_QM) - goto plus; - goto normal_char; - - case '|': - if (! (syntax_bits & RE_NO_BK_VBAR)) - goto or; - goto normal_char; - - case '(': - if (! (syntax_bits & RE_NO_BK_PARENS)) - goto lparen; - goto normal_char; - - case ')': - if (! (syntax_bits & RE_NO_BK_PARENS)) - goto rparen; - goto normal_char; - - default: - goto normal_char; - } - - case '?': - if (syntax_bits & RE_BK_PLUS_QM) - goto normal_char; - qmark: - if (! (syntax_bits & RE_CONTEXT_INDEP_OPS) && !closure_allowed) - goto normal_char; - return _QMARK; - - case '*': - if (! (syntax_bits & RE_CONTEXT_INDEP_OPS) && !closure_allowed) - goto normal_char; - return _STAR; - - case '+': - if (syntax_bits & RE_BK_PLUS_QM) - goto normal_char; - plus: - if (! (syntax_bits & RE_CONTEXT_INDEP_OPS) && !closure_allowed) - goto normal_char; - return _PLUS; - - case '|': - if (! (syntax_bits & RE_NO_BK_VBAR)) - goto normal_char; - or: - caret_allowed = 1; - closure_allowed = 0; - return _OR; - - case '\n': - if (! (syntax_bits & RE_NEWLINE_OR)) - goto normal_char; - goto or; - - case '(': - if (! (syntax_bits & RE_NO_BK_PARENS)) - goto normal_char; - lparen: - caret_allowed = 1; - closure_allowed = 0; - return _LPAREN; - - case ')': - if (! (syntax_bits & RE_NO_BK_PARENS)) - goto normal_char; - rparen: - caret_allowed = 0; - closure_allowed = 1; - return _RPAREN; - - case '.': - zeroset(cset); - notset(cset); - clrbit('\n', cset); - caret_allowed = 0; - closure_allowed = 1; - return _SET + charset_index(cset); - - case '[': - zeroset(cset); - FETCH(c, "Unbalanced ["); - if (c == '^') - { - FETCH(c, "Unbalanced ["); - invert = 1; - } - else - invert = 0; - do - { - FETCH(c2, "Unbalanced ["); - if ((syntax_bits & RE_AWK_CLASS_HACK) && c == '\\') - { - c = c2; - FETCH(c2, "Unbalanced ["); - } - if (c2 == '-') - { - FETCH(c2, "Unbalanced ["); - if (c2 == ']' && (syntax_bits & RE_AWK_CLASS_HACK)) - { - setbit(c, cset); - setbit('-', cset); - break; - } - while (c <= c2) - setbit(c++, cset); - FETCH(c, "Unbalanced ["); - } - else - { - setbit(c, cset); - c = c2; - } - } - while (c != ']'); - if (invert) - notset(cset); - caret_allowed = 0; - closure_allowed = 1; - return _SET + charset_index(cset); - - default: - normal_char: - caret_allowed = 0; - closure_allowed = 1; - if (case_fold && ISALPHA(c)) - { - zeroset(cset); - if (isupper(c)) - c = tolower(c); - setbit(c, cset); - setbit(toupper(c), cset); - return _SET + charset_index(cset); - } - return c; - } -} - -/* Recursive descent parser for regular expressions. */ - -static _token tok; /* Lookahead token. */ -static depth; /* Current depth of a hypothetical stack - holding deferred productions. This is - used to determine the depth that will be - required of the real stack later on in - reganalyze(). */ - -/* Add the given token to the parse tree, maintaining the depth count and - updating the maximum depth if necessary. */ -static void -addtok(t) - _token t; -{ - REALLOC_IF_NECESSARY(reg->tokens, _token, reg->talloc, reg->tindex); - reg->tokens[reg->tindex++] = t; - - switch (t) - { - case _QMARK: - case _STAR: - case _PLUS: - break; - - case _CAT: - case _OR: - --depth; - break; - - default: - ++reg->nleaves; - case _EMPTY: - ++depth; - break; - } - if (depth > reg->depth) - reg->depth = depth; -} - -/* The grammar understood by the parser is as follows. - - start: - regexp - _ALLBEGLINE regexp - regexp _ALLENDLINE - _ALLBEGLINE regexp _ALLENDLINE - - regexp: - regexp _OR branch - branch - - branch: - branch closure - closure - - closure: - closure _QMARK - closure _STAR - closure _PLUS - atom - - atom: - - _SET - _BACKREF - _BEGLINE - _ENDLINE - _BEGWORD - _ENDWORD - _LIMWORD - _NOTLIMWORD - - - The parser builds a parse tree in postfix form in an array of tokens. */ - -#ifdef __STDC__ -static void regexp(void); -#else -static void regexp(); -#endif - -static void -atom() -{ - if (tok >= 0 && (tok < _NOTCHAR || tok >= _SET || tok == _BACKREF - || tok == _BEGLINE || tok == _ENDLINE || tok == _BEGWORD - || tok == _ENDWORD || tok == _LIMWORD || tok == _NOTLIMWORD)) - { - addtok(tok); - tok = lex(); - } - else if (tok == _LPAREN) - { - tok = lex(); - regexp(); - if (tok != _RPAREN) - reg_error("Unbalanced ("); - tok = lex(); - } - else - addtok(_EMPTY); -} - -static void -closure() -{ - atom(); - while (tok == _QMARK || tok == _STAR || tok == _PLUS) - { - addtok(tok); - tok = lex(); - } -} - -static void -branch() -{ - closure(); - while (tok != _RPAREN && tok != _OR && tok != _ALLENDLINE && tok >= 0) - { - closure(); - addtok(_CAT); - } -} - -static void -regexp() -{ - branch(); - while (tok == _OR) - { - tok = lex(); - branch(); - addtok(_OR); - } -} - -/* Main entry point for the parser. S is a string to be parsed, len is the - length of the string, so s can include NUL characters. R is a pointer to - the struct regexp to parse into. */ -void -regparse(s, len, r) - const char *s; - size_t len; - struct regexp *r; -{ - reg = r; - lexstart = lexptr = s; - lexleft = len; - caret_allowed = 1; - closure_allowed = 0; - - if (! syntax_bits_set) - reg_error("No syntax specified"); - - tok = lex(); - depth = r->depth; - - if (tok == _ALLBEGLINE) - { - addtok(_BEGLINE); - tok = lex(); - regexp(); - addtok(_CAT); - } - else - regexp(); - - if (tok == _ALLENDLINE) - { - addtok(_ENDLINE); - addtok(_CAT); - tok = lex(); - } - - if (tok != _END) - reg_error("Unbalanced )"); - - addtok(_END - r->nregexps); - addtok(_CAT); - - if (r->nregexps) - addtok(_OR); - - ++r->nregexps; -} - -/* Some primitives for operating on sets of positions. */ - -/* Copy one set to another; the destination must be large enough. */ -static void -copy(src, dst) - const _position_set *src; - _position_set *dst; -{ - int i; - - for (i = 0; i < src->nelem; ++i) - dst->elems[i] = src->elems[i]; - dst->nelem = src->nelem; -} - -/* Insert a position in a set. Position sets are maintained in sorted - order according to index. If position already exists in the set with - the same index then their constraints are logically or'd together. - S->elems must point to an array large enough to hold the resulting set. */ -static void -insert(p, s) - _position p; - _position_set *s; -{ - int i; - _position t1, t2; - - for (i = 0; i < s->nelem && p.index < s->elems[i].index; ++i) - ; - if (i < s->nelem && p.index == s->elems[i].index) - s->elems[i].constraint |= p.constraint; - else - { - t1 = p; - ++s->nelem; - while (i < s->nelem) - { - t2 = s->elems[i]; - s->elems[i++] = t1; - t1 = t2; - } - } -} - -/* Merge two sets of positions into a third. The result is exactly as if - the positions of both sets were inserted into an initially empty set. */ -static void -merge(s1, s2, m) - _position_set *s1; - _position_set *s2; - _position_set *m; -{ - int i = 0, j = 0; - - m->nelem = 0; - while (i < s1->nelem && j < s2->nelem) - if (s1->elems[i].index > s2->elems[j].index) - m->elems[m->nelem++] = s1->elems[i++]; - else if (s1->elems[i].index < s2->elems[j].index) - m->elems[m->nelem++] = s2->elems[j++]; - else - { - m->elems[m->nelem] = s1->elems[i++]; - m->elems[m->nelem++].constraint |= s2->elems[j++].constraint; - } - while (i < s1->nelem) - m->elems[m->nelem++] = s1->elems[i++]; - while (j < s2->nelem) - m->elems[m->nelem++] = s2->elems[j++]; -} - -/* Delete a position from a set. */ -static void -delete(p, s) - _position p; - _position_set *s; -{ - int i; - - for (i = 0; i < s->nelem; ++i) - if (p.index == s->elems[i].index) - break; - if (i < s->nelem) - for (--s->nelem; i < s->nelem; ++i) - s->elems[i] = s->elems[i + 1]; -} - -/* Find the index of the state corresponding to the given position set with - the given preceding context, or create a new state if there is no such - state. Newline and letter tell whether we got here on a newline or - letter, respectively. */ -static int -state_index(r, s, newline, letter) - struct regexp *r; - _position_set *s; - int newline; - int letter; -{ - int lhash = 0; - int constraint; - int i, j; - - newline = newline ? 1 : 0; - letter = letter ? 1 : 0; - - for (i = 0; i < s->nelem; ++i) - lhash ^= s->elems[i].index + s->elems[i].constraint; - - /* Try to find a state that exactly matches the proposed one. */ - for (i = 0; i < r->sindex; ++i) - { - if (lhash != r->states[i].hash || s->nelem != r->states[i].elems.nelem - || newline != r->states[i].newline || letter != r->states[i].letter) - continue; - for (j = 0; j < s->nelem; ++j) - if (s->elems[j].constraint - != r->states[i].elems.elems[j].constraint - || s->elems[j].index != r->states[i].elems.elems[j].index) - break; - if (j == s->nelem) - return i; - } - - /* We'll have to create a new state. */ - REALLOC_IF_NECESSARY(r->states, _dfa_state, r->salloc, r->sindex); - r->states[i].hash = lhash; - MALLOC(r->states[i].elems.elems, _position, s->nelem); - copy(s, &r->states[i].elems); - r->states[i].newline = newline; - r->states[i].letter = letter; - r->states[i].backref = 0; - r->states[i].constraint = 0; - r->states[i].first_end = 0; - for (j = 0; j < s->nelem; ++j) - if (r->tokens[s->elems[j].index] < 0) - { - constraint = s->elems[j].constraint; - if (_SUCCEEDS_IN_CONTEXT(constraint, newline, 0, letter, 0) - || _SUCCEEDS_IN_CONTEXT(constraint, newline, 0, letter, 1) - || _SUCCEEDS_IN_CONTEXT(constraint, newline, 1, letter, 0) - || _SUCCEEDS_IN_CONTEXT(constraint, newline, 1, letter, 1)) - r->states[i].constraint |= constraint; - if (! r->states[i].first_end) - r->states[i].first_end = r->tokens[s->elems[j].index]; - } - else if (r->tokens[s->elems[j].index] == _BACKREF) - { - r->states[i].constraint = _NO_CONSTRAINT; - r->states[i].backref = 1; - } - - ++r->sindex; - - return i; -} - -/* Find the epsilon closure of a set of positions. If any position of the set - contains a symbol that matches the empty string in some context, replace - that position with the elements of its follow labeled with an appropriate - constraint. Repeat exhaustively until no funny positions are left. - S->elems must be large enough to hold the result. */ -static void -epsclosure(s, r) - _position_set *s; - struct regexp *r; -{ - int i, j; - int *visited; - _position p, old; - - MALLOC(visited, int, r->tindex); - for (i = 0; i < r->tindex; ++i) - visited[i] = 0; - - for (i = 0; i < s->nelem; ++i) - if (r->tokens[s->elems[i].index] >= _NOTCHAR - && r->tokens[s->elems[i].index] != _BACKREF - && r->tokens[s->elems[i].index] < _SET) - { - old = s->elems[i]; - p.constraint = old.constraint; - delete(s->elems[i], s); - if (visited[old.index]) - { - --i; - continue; - } - visited[old.index] = 1; - switch (r->tokens[old.index]) - { - case _BEGLINE: - p.constraint &= _BEGLINE_CONSTRAINT; - break; - case _ENDLINE: - p.constraint &= _ENDLINE_CONSTRAINT; - break; - case _BEGWORD: - p.constraint &= _BEGWORD_CONSTRAINT; - break; - case _ENDWORD: - p.constraint &= _ENDWORD_CONSTRAINT; - break; - case _LIMWORD: - p.constraint &= _ENDWORD_CONSTRAINT; - break; - case _NOTLIMWORD: - p.constraint &= _NOTLIMWORD_CONSTRAINT; - break; - default: - break; - } - for (j = 0; j < r->follows[old.index].nelem; ++j) - { - p.index = r->follows[old.index].elems[j].index; - insert(p, s); - } - /* Force rescan to start at the beginning. */ - i = -1; - } - - free(visited); -} - -/* Perform bottom-up analysis on the parse tree, computing various functions. - Note that at this point, we're pretending constructs like \< are real - characters rather than constraints on what can follow them. - - Nullable: A node is nullable if it is at the root of a regexp that can - match the empty string. - * _EMPTY leaves are nullable. - * No other leaf is nullable. - * A _QMARK or _STAR node is nullable. - * A _PLUS node is nullable if its argument is nullable. - * A _CAT node is nullable if both its arguments are nullable. - * An _OR node is nullable if either argument is nullable. - - Firstpos: The firstpos of a node is the set of positions (nonempty leaves) - that could correspond to the first character of a string matching the - regexp rooted at the given node. - * _EMPTY leaves have empty firstpos. - * The firstpos of a nonempty leaf is that leaf itself. - * The firstpos of a _QMARK, _STAR, or _PLUS node is the firstpos of its - argument. - * The firstpos of a _CAT node is the firstpos of the left argument, union - the firstpos of the right if the left argument is nullable. - * The firstpos of an _OR node is the union of firstpos of each argument. - - Lastpos: The lastpos of a node is the set of positions that could - correspond to the last character of a string matching the regexp at - the given node. - * _EMPTY leaves have empty lastpos. - * The lastpos of a nonempty leaf is that leaf itself. - * The lastpos of a _QMARK, _STAR, or _PLUS node is the lastpos of its - argument. - * The lastpos of a _CAT node is the lastpos of its right argument, union - the lastpos of the left if the right argument is nullable. - * The lastpos of an _OR node is the union of the lastpos of each argument. - - Follow: The follow of a position is the set of positions that could - correspond to the character following a character matching the node in - a string matching the regexp. At this point we consider special symbols - that match the empty string in some context to be just normal characters. - Later, if we find that a special symbol is in a follow set, we will - replace it with the elements of its follow, labeled with an appropriate - constraint. - * Every node in the firstpos of the argument of a _STAR or _PLUS node is in - the follow of every node in the lastpos. - * Every node in the firstpos of the second argument of a _CAT node is in - the follow of every node in the lastpos of the first argument. - - Because of the postfix representation of the parse tree, the depth-first - analysis is conveniently done by a linear scan with the aid of a stack. - Sets are stored as arrays of the elements, obeying a stack-like allocation - scheme; the number of elements in each set deeper in the stack can be - used to determine the address of a particular set's array. */ -void -reganalyze(r, searchflag) - struct regexp *r; - int searchflag; -{ - int *nullable; /* Nullable stack. */ - int *nfirstpos; /* Element count stack for firstpos sets. */ - _position *firstpos; /* Array where firstpos elements are stored. */ - int *nlastpos; /* Element count stack for lastpos sets. */ - _position *lastpos; /* Array where lastpos elements are stored. */ - int *nalloc; /* Sizes of arrays allocated to follow sets. */ - _position_set tmp; /* Temporary set for merging sets. */ - _position_set merged; /* Result of merging sets. */ - int wants_newline; /* True if some position wants newline info. */ - int *o_nullable; - int *o_nfirst, *o_nlast; - _position *o_firstpos, *o_lastpos; - int i, j; - _position *pos; - - r->searchflag = searchflag; - - MALLOC(nullable, int, r->depth); - o_nullable = nullable; - MALLOC(nfirstpos, int, r->depth); - o_nfirst = nfirstpos; - MALLOC(firstpos, _position, r->nleaves); - o_firstpos = firstpos, firstpos += r->nleaves; - MALLOC(nlastpos, int, r->depth); - o_nlast = nlastpos; - MALLOC(lastpos, _position, r->nleaves); - o_lastpos = lastpos, lastpos += r->nleaves; - MALLOC(nalloc, int, r->tindex); - for (i = 0; i < r->tindex; ++i) - nalloc[i] = 0; - MALLOC(merged.elems, _position, r->nleaves); - - CALLOC(r->follows, _position_set, r->tindex); - - for (i = 0; i < r->tindex; ++i) - switch (r->tokens[i]) - { - case _EMPTY: - /* The empty set is nullable. */ - *nullable++ = 1; - - /* The firstpos and lastpos of the empty leaf are both empty. */ - *nfirstpos++ = *nlastpos++ = 0; - break; - - case _STAR: - case _PLUS: - /* Every element in the firstpos of the argument is in the follow - of every element in the lastpos. */ - tmp.nelem = nfirstpos[-1]; - tmp.elems = firstpos; - pos = lastpos; - for (j = 0; j < nlastpos[-1]; ++j) - { - merge(&tmp, &r->follows[pos[j].index], &merged); - REALLOC_IF_NECESSARY(r->follows[pos[j].index].elems, _position, - nalloc[pos[j].index], merged.nelem - 1); - copy(&merged, &r->follows[pos[j].index]); - } - - case _QMARK: - /* A _QMARK or _STAR node is automatically nullable. */ - if (r->tokens[i] != _PLUS) - nullable[-1] = 1; - break; - - case _CAT: - /* Every element in the firstpos of the second argument is in the - follow of every element in the lastpos of the first argument. */ - tmp.nelem = nfirstpos[-1]; - tmp.elems = firstpos; - pos = lastpos + nlastpos[-1]; - for (j = 0; j < nlastpos[-2]; ++j) - { - merge(&tmp, &r->follows[pos[j].index], &merged); - REALLOC_IF_NECESSARY(r->follows[pos[j].index].elems, _position, - nalloc[pos[j].index], merged.nelem - 1); - copy(&merged, &r->follows[pos[j].index]); - } - - /* The firstpos of a _CAT node is the firstpos of the first argument, - union that of the second argument if the first is nullable. */ - if (nullable[-2]) - nfirstpos[-2] += nfirstpos[-1]; - else - firstpos += nfirstpos[-1]; - --nfirstpos; - - /* The lastpos of a _CAT node is the lastpos of the second argument, - union that of the first argument if the second is nullable. */ - if (nullable[-1]) - nlastpos[-2] += nlastpos[-1]; - else - { - pos = lastpos + nlastpos[-2]; - for (j = nlastpos[-1] - 1; j >= 0; --j) - pos[j] = lastpos[j]; - lastpos += nlastpos[-2]; - nlastpos[-2] = nlastpos[-1]; - } - --nlastpos; - - /* A _CAT node is nullable if both arguments are nullable. */ - nullable[-2] = nullable[-1] && nullable[-2]; - --nullable; - break; - - case _OR: - /* The firstpos is the union of the firstpos of each argument. */ - nfirstpos[-2] += nfirstpos[-1]; - --nfirstpos; - - /* The lastpos is the union of the lastpos of each argument. */ - nlastpos[-2] += nlastpos[-1]; - --nlastpos; - - /* An _OR node is nullable if either argument is nullable. */ - nullable[-2] = nullable[-1] || nullable[-2]; - --nullable; - break; - - default: - /* Anything else is a nonempty position. (Note that special - constructs like \< are treated as nonempty strings here; - an "epsilon closure" effectively makes them nullable later. - Backreferences have to get a real position so we can detect - transitions on them later. But they are nullable. */ - *nullable++ = r->tokens[i] == _BACKREF; - - /* This position is in its own firstpos and lastpos. */ - *nfirstpos++ = *nlastpos++ = 1; - --firstpos, --lastpos; - firstpos->index = lastpos->index = i; - firstpos->constraint = lastpos->constraint = _NO_CONSTRAINT; - - /* Allocate the follow set for this position. */ - nalloc[i] = 1; - MALLOC(r->follows[i].elems, _position, nalloc[i]); - break; - } - - /* For each follow set that is the follow set of a real position, replace - it with its epsilon closure. */ - for (i = 0; i < r->tindex; ++i) - if (r->tokens[i] < _NOTCHAR || r->tokens[i] == _BACKREF - || r->tokens[i] >= _SET) - { - copy(&r->follows[i], &merged); - epsclosure(&merged, r); - if (r->follows[i].nelem < merged.nelem) - REALLOC(r->follows[i].elems, _position, merged.nelem); - copy(&merged, &r->follows[i]); - } - - /* Get the epsilon closure of the firstpos of the regexp. The result will - be the set of positions of state 0. */ - merged.nelem = 0; - for (i = 0; i < nfirstpos[-1]; ++i) - insert(firstpos[i], &merged); - epsclosure(&merged, r); - - /* Check if any of the positions of state 0 will want newline context. */ - wants_newline = 0; - for (i = 0; i < merged.nelem; ++i) - if (_PREV_NEWLINE_DEPENDENT(merged.elems[i].constraint)) - wants_newline = 1; - - /* Build the initial state. */ - r->salloc = 1; - r->sindex = 0; - MALLOC(r->states, _dfa_state, r->salloc); - state_index(r, &merged, wants_newline, 0); - - free(o_nullable); - free(o_nfirst); - free(o_firstpos); - free(o_nlast); - free(o_lastpos); - free(nalloc); - free(merged.elems); -} - -/* Find, for each character, the transition out of state s of r, and store - it in the appropriate slot of trans. - - We divide the positions of s into groups (positions can appear in more - than one group). Each group is labeled with a set of characters that - every position in the group matches (taking into account, if necessary, - preceding context information of s). For each group, find the union - of the its elements' follows. This set is the set of positions of the - new state. For each character in the group's label, set the transition - on this character to be to a state corresponding to the set's positions, - and its associated backward context information, if necessary. - - If we are building a searching matcher, we include the positions of state - 0 in every state. - - The collection of groups is constructed by building an equivalence-class - partition of the positions of s. - - For each position, find the set of characters C that it matches. Eliminate - any characters from C that fail on grounds of backward context. - - Search through the groups, looking for a group whose label L has nonempty - intersection with C. If L - C is nonempty, create a new group labeled - L - C and having the same positions as the current group, and set L to - the intersection of L and C. Insert the position in this group, set - C = C - L, and resume scanning. - - If after comparing with every group there are characters remaining in C, - create a new group labeled with the characters of C and insert this - position in that group. */ -void -regstate(s, r, trans) - int s; - struct regexp *r; - int trans[]; -{ - _position_set grps[_NOTCHAR]; /* As many as will ever be needed. */ - _charset labels[_NOTCHAR]; /* Labels corresponding to the groups. */ - int ngrps = 0; /* Number of groups actually used. */ - _position pos; /* Current position being considered. */ - _charset matches; /* Set of matching characters. */ - int matchesf; /* True if matches is nonempty. */ - _charset intersect; /* Intersection with some label set. */ - int intersectf; /* True if intersect is nonempty. */ - _charset leftovers; /* Stuff in the label that didn't match. */ - int leftoversf; /* True if leftovers is nonempty. */ - static _charset letters; /* Set of characters considered letters. */ - static _charset newline; /* Set of characters that aren't newline. */ - _position_set follows; /* Union of the follows of some group. */ - _position_set tmp; /* Temporary space for merging sets. */ - int state; /* New state. */ - int wants_newline; /* New state wants to know newline context. */ - int state_newline; /* New state on a newline transition. */ - int wants_letter; /* New state wants to know letter context. */ - int state_letter; /* New state on a letter transition. */ - static initialized; /* Flag for static initialization. */ - int i, j, k; - - /* Initialize the set of letters, if necessary. */ - if (! initialized) - { - initialized = 1; - for (i = 0; i < _NOTCHAR; ++i) - if (ISALNUM(i)) - setbit(i, letters); - setbit('\n', newline); - } - - zeroset(matches); - - for (i = 0; i < r->states[s].elems.nelem; ++i) - { - pos = r->states[s].elems.elems[i]; - if (r->tokens[pos.index] >= 0 && r->tokens[pos.index] < _NOTCHAR) - setbit(r->tokens[pos.index], matches); - else if (r->tokens[pos.index] >= _SET) - copyset(r->charsets[r->tokens[pos.index] - _SET], matches); - else - continue; - - /* Some characters may need to be climinated from matches because - they fail in the current context. */ - if (pos.constraint != 0xff) - { - if (! _MATCHES_NEWLINE_CONTEXT(pos.constraint, - r->states[s].newline, 1)) - clrbit('\n', matches); - if (! _MATCHES_NEWLINE_CONTEXT(pos.constraint, - r->states[s].newline, 0)) - for (j = 0; j < _CHARSET_INTS; ++j) - matches[j] &= newline[j]; - if (! _MATCHES_LETTER_CONTEXT(pos.constraint, - r->states[s].letter, 1)) - for (j = 0; j < _CHARSET_INTS; ++j) - matches[j] &= ~letters[j]; - if (! _MATCHES_LETTER_CONTEXT(pos.constraint, - r->states[s].letter, 0)) - for (j = 0; j < _CHARSET_INTS; ++j) - matches[j] &= letters[j]; - - /* If there are no characters left, there's no point in going on. */ - for (j = 0; j < _CHARSET_INTS && !matches[j]; ++j) - ; - if (j == _CHARSET_INTS) - continue; - } - - for (j = 0; j < ngrps; ++j) - { - /* If matches contains a single character only, and the current - group's label doesn't contain that character, go on to the - next group. */ - if (r->tokens[pos.index] >= 0 && r->tokens[pos.index] < _NOTCHAR - && !tstbit(r->tokens[pos.index], labels[j])) - continue; - - /* Check if this group's label has a nonempty intersection with - matches. */ - intersectf = 0; - for (k = 0; k < _CHARSET_INTS; ++k) - (intersect[k] = matches[k] & labels[j][k]) ? intersectf = 1 : 0; - if (! intersectf) - continue; - - /* It does; now find the set differences both ways. */ - leftoversf = matchesf = 0; - for (k = 0; k < _CHARSET_INTS; ++k) - { - /* Even an optimizing compiler can't know this for sure. */ - int match = matches[k], label = labels[j][k]; - - (leftovers[k] = ~match & label) ? leftoversf = 1 : 0; - (matches[k] = match & ~label) ? matchesf = 1 : 0; - } - - /* If there were leftovers, create a new group labeled with them. */ - if (leftoversf) - { - copyset(leftovers, labels[ngrps]); - copyset(intersect, labels[j]); - MALLOC(grps[ngrps].elems, _position, r->nleaves); - copy(&grps[j], &grps[ngrps]); - ++ngrps; - } - - /* Put the position in the current group. Note that there is no - reason to call insert() here. */ - grps[j].elems[grps[j].nelem++] = pos; - - /* If every character matching the current position has been - accounted for, we're done. */ - if (! matchesf) - break; - } - - /* If we've passed the last group, and there are still characters - unaccounted for, then we'll have to create a new group. */ - if (j == ngrps) - { - copyset(matches, labels[ngrps]); - zeroset(matches); - MALLOC(grps[ngrps].elems, _position, r->nleaves); - grps[ngrps].nelem = 1; - grps[ngrps].elems[0] = pos; - ++ngrps; - } - } - - MALLOC(follows.elems, _position, r->nleaves); - MALLOC(tmp.elems, _position, r->nleaves); - - /* If we are a searching matcher, the default transition is to a state - containing the positions of state 0, otherwise the default transition - is to fail miserably. */ - if (r->searchflag) - { - wants_newline = 0; - wants_letter = 0; - for (i = 0; i < r->states[0].elems.nelem; ++i) - { - if (_PREV_NEWLINE_DEPENDENT(r->states[0].elems.elems[i].constraint)) - wants_newline = 1; - if (_PREV_LETTER_DEPENDENT(r->states[0].elems.elems[i].constraint)) - wants_letter = 1; - } - copy(&r->states[0].elems, &follows); - state = state_index(r, &follows, 0, 0); - if (wants_newline) - state_newline = state_index(r, &follows, 1, 0); - else - state_newline = state; - if (wants_letter) - state_letter = state_index(r, &follows, 0, 1); - else - state_letter = state; - for (i = 0; i < _NOTCHAR; ++i) - trans[i] = (ISALNUM(i)) ? state_letter : state ; - trans['\n'] = state_newline; - } - else - for (i = 0; i < _NOTCHAR; ++i) - trans[i] = -1; - - for (i = 0; i < ngrps; ++i) - { - follows.nelem = 0; - - /* Find the union of the follows of the positions of the group. - This is a hideously inefficient loop. Fix it someday. */ - for (j = 0; j < grps[i].nelem; ++j) - for (k = 0; k < r->follows[grps[i].elems[j].index].nelem; ++k) - insert(r->follows[grps[i].elems[j].index].elems[k], &follows); - - /* If we are building a searching matcher, throw in the positions - of state 0 as well. */ - if (r->searchflag) - for (j = 0; j < r->states[0].elems.nelem; ++j) - insert(r->states[0].elems.elems[j], &follows); - - /* Find out if the new state will want any context information. */ - wants_newline = 0; - if (tstbit('\n', labels[i])) - for (j = 0; j < follows.nelem; ++j) - if (_PREV_NEWLINE_DEPENDENT(follows.elems[j].constraint)) - wants_newline = 1; - - wants_letter = 0; - for (j = 0; j < _CHARSET_INTS; ++j) - if (labels[i][j] & letters[j]) - break; - if (j < _CHARSET_INTS) - for (j = 0; j < follows.nelem; ++j) - if (_PREV_LETTER_DEPENDENT(follows.elems[j].constraint)) - wants_letter = 1; - - /* Find the state(s) corresponding to the union of the follows. */ - state = state_index(r, &follows, 0, 0); - if (wants_newline) - state_newline = state_index(r, &follows, 1, 0); - else - state_newline = state; - if (wants_letter) - state_letter = state_index(r, &follows, 0, 1); - else - state_letter = state; - - /* Set the transitions for each character in the current label. */ - for (j = 0; j < _CHARSET_INTS; ++j) - for (k = 0; k < INTBITS; ++k) - if (labels[i][j] & 1 << k) - { - int c = j * INTBITS + k; - - if (c == '\n') - trans[c] = state_newline; - else if (ISALNUM(c)) - trans[c] = state_letter; - else if (c < _NOTCHAR) - trans[c] = state; - } - } - - for (i = 0; i < ngrps; ++i) - free(grps[i].elems); - free(follows.elems); - free(tmp.elems); -} - -/* Some routines for manipulating a compiled regexp's transition tables. - Each state may or may not have a transition table; if it does, and it - is a non-accepting state, then r->trans[state] points to its table. - If it is an accepting state then r->fails[state] points to its table. - If it has no table at all, then r->trans[state] is NULL. - TODO: Improve this comment, get rid of the unnecessary redundancy. */ - -static void -build_state(s, r) - int s; - struct regexp *r; -{ - int *trans; /* The new transition table. */ - int i; - - /* Set an upper limit on the number of transition tables that will ever - exist at once. 1024 is arbitrary. The idea is that the frequently - used transition tables will be quickly rebuilt, whereas the ones that - were only needed once or twice will be cleared away. */ - if (r->trcount >= 1024) - { - for (i = 0; i < r->tralloc; ++i) - if (r->trans[i]) - { - free((ptr_t) r->trans[i]); - r->trans[i] = NULL; - } - else if (r->fails[i]) - { - free((ptr_t) r->fails[i]); - r->fails[i] = NULL; - } - r->trcount = 0; - } - - ++r->trcount; - - /* Set up the success bits for this state. */ - r->success[s] = 0; - if (ACCEPTS_IN_CONTEXT(r->states[s].newline, 1, r->states[s].letter, 0, - s, *r)) - r->success[s] |= 4; - if (ACCEPTS_IN_CONTEXT(r->states[s].newline, 0, r->states[s].letter, 1, - s, *r)) - r->success[s] |= 2; - if (ACCEPTS_IN_CONTEXT(r->states[s].newline, 0, r->states[s].letter, 0, - s, *r)) - r->success[s] |= 1; - - MALLOC(trans, int, _NOTCHAR); - regstate(s, r, trans); - - /* Now go through the new transition table, and make sure that the trans - and fail arrays are allocated large enough to hold a pointer for the - largest state mentioned in the table. */ - for (i = 0; i < _NOTCHAR; ++i) - if (trans[i] >= r->tralloc) - { - int oldalloc = r->tralloc; - - while (trans[i] >= r->tralloc) - r->tralloc *= 2; - REALLOC(r->realtrans, int *, r->tralloc + 1); - r->trans = r->realtrans + 1; - REALLOC(r->fails, int *, r->tralloc); - REALLOC(r->success, int, r->tralloc); - REALLOC(r->newlines, int, r->tralloc); - while (oldalloc < r->tralloc) - { - r->trans[oldalloc] = NULL; - r->fails[oldalloc++] = NULL; - } - } - - /* Keep the newline transition in a special place so we can use it as - a sentinel. */ - r->newlines[s] = trans['\n']; - trans['\n'] = -1; - - if (ACCEPTING(s, *r)) - r->fails[s] = trans; - else - r->trans[s] = trans; -} - -static void -build_state_zero(r) - struct regexp *r; -{ - r->tralloc = 1; - r->trcount = 0; - CALLOC(r->realtrans, int *, r->tralloc + 1); - r->trans = r->realtrans + 1; - CALLOC(r->fails, int *, r->tralloc); - MALLOC(r->success, int, r->tralloc); - MALLOC(r->newlines, int, r->tralloc); - build_state(0, r); -} - -/* Search through a buffer looking for a match to the given struct regexp. - Find the first occurrence of a string matching the regexp in the buffer, - and the shortest possible version thereof. Return a pointer to the first - character after the match, or NULL if none is found. Begin points to - the beginning of the buffer, and end points to the first character after - its end. We store a newline in *end to act as a sentinel, so end had - better point somewhere valid. Newline is a flag indicating whether to - allow newlines to be in the matching string. If count is non- - NULL it points to a place we're supposed to increment every time we - see a newline. Finally, if backref is non-NULL it points to a place - where we're supposed to store a 1 if backreferencing happened and the - match needs to be verified by a backtracking matcher. Otherwise - we store a 0 in *backref. */ -char * -regexecute(r, begin, end, newline, count, backref) - struct regexp *r; - char *begin; - char *end; - int newline; - int *count; - int *backref; -{ - register s, s1, tmp; /* Current state. */ - register unsigned char *p; /* Current input character. */ - register **trans, *t; /* Copy of r->trans so it can be optimized - into a register. */ - static sbit[_NOTCHAR]; /* Table for anding with r->success. */ - static sbit_init; - - if (! sbit_init) - { - int i; - - sbit_init = 1; - for (i = 0; i < _NOTCHAR; ++i) - sbit[i] = (ISALNUM(i)) ? 2 : 1; - sbit['\n'] = 4; - } - - if (! r->tralloc) - build_state_zero(r); - - s = s1 = 0; - p = (unsigned char *) begin; - trans = r->trans; - *end = '\n'; - - for (;;) - { - while ((t = trans[s]) != 0) { /* hand-optimized loop */ - s1 = t[*p++]; - if ((t = trans[s1]) == 0) { - tmp = s ; s = s1 ; s1 = tmp ; /* swap */ - break; - } - s = t[*p++]; - } - - if (s >= 0 && p <= (unsigned char *) end && r->fails[s]) - { - if (r->success[s] & sbit[*p]) - { - if (backref) - *backref = (r->states[s].backref != 0); - return (char *) p; - } - - s1 = s; - s = r->fails[s][*p++]; - continue; - } - - /* If the previous character was a newline, count it. */ - if (count && (char *) p <= end && p[-1] == '\n') - ++*count; - - /* Check if we've run off the end of the buffer. */ - if ((char *) p >= end) - return NULL; - - if (s >= 0) - { - build_state(s, r); - trans = r->trans; - continue; - } - - if (p[-1] == '\n' && newline) - { - s = r->newlines[s1]; - continue; - } - - s = 0; - } -} - -/* Initialize the components of a regexp that the other routines don't - initialize for themselves. */ -void -reginit(r) - struct regexp *r; -{ - r->calloc = 1; - MALLOC(r->charsets, _charset, r->calloc); - r->cindex = 0; - - r->talloc = 1; - MALLOC(r->tokens, _token, r->talloc); - r->tindex = r->depth = r->nleaves = r->nregexps = 0; - - r->searchflag = 0; - r->tralloc = 0; -} - -/* Parse and analyze a single string of the given length. */ -void -regcompile(s, len, r, searchflag) - const char *s; - size_t len; - struct regexp *r; - int searchflag; -{ - if (case_fold) /* dummy folding in service of regmust() */ - { - char *regcopy; - int i; - - regcopy = malloc(len); - if (!regcopy) - reg_error("out of memory"); - - /* This is a complete kludge and could potentially break - \ escapes . . . */ - case_fold = 0; - for (i = 0; i < len; ++i) - if (ISUPPER(s[i])) - regcopy[i] = tolower(s[i]); - else - regcopy[i] = s[i]; - - reginit(r); - r->mustn = 0; - r->must[0] = '\0'; - regparse(regcopy, len, r); - free(regcopy); - regmust(r); - reganalyze(r, searchflag); - case_fold = 1; - reginit(r); - regparse(s, len, r); - reganalyze(r, searchflag); - } - else - { - reginit(r); - regparse(s, len, r); - regmust(r); - reganalyze(r, searchflag); - } -} - -/* Free the storage held by the components of a regexp. */ -void -reg_free(r) - struct regexp *r; -{ - int i; - - free((ptr_t) r->charsets); - free((ptr_t) r->tokens); - for (i = 0; i < r->sindex; ++i) - free((ptr_t) r->states[i].elems.elems); - free((ptr_t) r->states); - for (i = 0; i < r->tindex; ++i) - if (r->follows[i].elems) - free((ptr_t) r->follows[i].elems); - free((ptr_t) r->follows); - for (i = 0; i < r->tralloc; ++i) - if (r->trans[i]) - free((ptr_t) r->trans[i]); - else if (r->fails[i]) - free((ptr_t) r->fails[i]); - if (r->realtrans) - free((ptr_t) r->realtrans); - if (r->fails) - free((ptr_t) r->fails); - if (r->newlines) - free((ptr_t) r->newlines); -} - -/* -Having found the postfix representation of the regular expression, -try to find a long sequence of characters that must appear in any line -containing the r.e. -Finding a "longest" sequence is beyond the scope here; -we take an easy way out and hope for the best. -(Take "(ab|a)b"--please.) - -We do a bottom-up calculation of sequences of characters that must appear -in matches of r.e.'s represented by trees rooted at the nodes of the postfix -representation: - sequences that must appear at the left of the match ("left") - sequences that must appear at the right of the match ("right") - lists of sequences that must appear somewhere in the match ("in") - sequences that must constitute the match ("is") -When we get to the root of the tree, we use one of the longest of its -calculated "in" sequences as our answer. The sequence we find is returned in -r->must (where "r" is the single argument passed to "regmust"); -the length of the sequence is returned in r->mustn. - -The sequences calculated for the various types of node (in pseudo ANSI c) -are shown below. "p" is the operand of unary operators (and the left-hand -operand of binary operators); "q" is the right-hand operand of binary operators -. -"ZERO" means "a zero-length sequence" below. - -Type left right is in ----- ---- ----- -- -- -char c # c # c # c # c - -SET ZERO ZERO ZERO ZERO - -STAR ZERO ZERO ZERO ZERO - -QMARK ZERO ZERO ZERO ZERO - -PLUS p->left p->right ZERO p->in - -CAT (p->is==ZERO)? (q->is==ZERO)? (p->is!=ZERO && p->in plus - p->left : q->right : q->is!=ZERO) ? q->in plus - p->is##q->left p->right##q->is p->is##q->is : p->right##q->left - ZERO - -OR longest common longest common (do p->is and substrings common to - leading trailing q->is have same p->in and q->in - (sub)sequence (sub)sequence length and - of p->left of p->right content) ? - and q->left and q->right p->is : NULL - -If there's anything else we recognize in the tree, all four sequences get set -to zero-length sequences. If there's something we don't recognize in the tree, -we just return a zero-length sequence. - -Break ties in favor of infrequent letters (choosing 'zzz' in preference to -'aaa')? - -And. . .is it here or someplace that we might ponder "optimizations" such as - egrep 'psi|epsilon' -> egrep 'psi' - egrep 'pepsi|epsilon' -> egrep 'epsi' - (Yes, we now find "epsi" as a "string - that must occur", but we might also - simplify the *entire* r.e. being sought -) - grep '[c]' -> grep 'c' - grep '(ab|a)b' -> grep 'ab' - grep 'ab*' -> grep 'a' - grep 'a*b' -> grep 'b' -There are several issues: - Is optimization easy (enough)? - - Does optimization actually accomplish anything, - or is the automaton you get from "psi|epsilon" (for example) - the same as the one you get from "psi" (for example)? - - Are optimizable r.e.'s likely to be used in real-life situations - (something like 'ab*' is probably unlikely; something like is - 'psi|epsilon' is likelier)? -*/ - -static char * -icatalloc(old, new) -char * old; -const char * new; -{ - register char * result; - register int oldsize, newsize; - - newsize = (new == NULL) ? 0 : strlen(new); - if (old == NULL) - oldsize = 0; - else if (newsize == 0) - return old; - else oldsize = strlen(old); - if (old == NULL) - result = (char *) malloc(newsize + 1); - else result = (char *) realloc((void *) old, oldsize + newsize + 1); - if (result != NULL && new != NULL) - (void) strcpy(result + oldsize, new); - return result; -} - -static char * -icpyalloc(string) -const char * string; -{ - return icatalloc((char *) NULL, string); -} - -static char * -istrstr(lookin, lookfor) -char * lookin; -register char * lookfor; -{ - register char * cp; - register int len; - - len = strlen(lookfor); - for (cp = lookin; *cp != '\0'; ++cp) - if (strncmp(cp, lookfor, len) == 0) - return cp; - return NULL; -} - -static void -ifree(cp) -char * cp; -{ - if (cp != NULL) - free(cp); -} - -static void -freelist(cpp) -register char ** cpp; -{ - register int i; - - if (cpp == NULL) - return; - for (i = 0; cpp[i] != NULL; ++i) { - free(cpp[i]); - cpp[i] = NULL; - } -} - -static char ** -enlist(cpp, new, len) -register char ** cpp; -register char * new; -#ifdef __STDC__ -size_t len; -#else -int len; -#endif -{ - register int i, j; - - if (cpp == NULL) - return NULL; - if ((new = icpyalloc(new)) == NULL) { - freelist(cpp); - return NULL; - } - new[len] = '\0'; - /* - ** Is there already something in the list that's new (or longer)? - */ - for (i = 0; cpp[i] != NULL; ++i) - if (istrstr(cpp[i], new) != NULL) { - free(new); - return cpp; - } - /* - ** Eliminate any obsoleted strings. - */ - j = 0; - while (cpp[j] != NULL) - if (istrstr(new, cpp[j]) == NULL) - ++j; - else { - free(cpp[j]); - if (--i == j) - break; - cpp[j] = cpp[i]; - } - /* - ** Add the new string. - */ - cpp = (char **) realloc((char *) cpp, (i + 2) * sizeof *cpp); - if (cpp == NULL) - return NULL; - cpp[i] = new; - cpp[i + 1] = NULL; - return cpp; -} - -/* -** Given pointers to two strings, -** return a pointer to an allocated list of their distinct common substrings. -** Return NULL if something seems wild. -*/ - -static char ** -comsubs(left, right) -char * left; -char * right; -{ - register char ** cpp; - register char * lcp; - register char * rcp; - register int i, len; - - if (left == NULL || right == NULL) - return NULL; - cpp = (char **) malloc(sizeof *cpp); - if (cpp == NULL) - return NULL; - cpp[0] = NULL; - for (lcp = left; *lcp != '\0'; ++lcp) { - len = 0; - rcp = strchr(right, *lcp); - while (rcp != NULL) { - for (i = 1; lcp[i] != '\0' && lcp[i] == rcp[i]; ++i) - ; - if (i > len) - len = i; - rcp = strchr(rcp + 1, *lcp); - } - if (len == 0) - continue; -#ifdef __STDC__ - if ((cpp = enlist(cpp, lcp, (size_t)len)) == NULL) -#else - if ((cpp = enlist(cpp, lcp, len)) == NULL) -#endif - break; - } - return cpp; -} - -static char ** -addlists(old, new) -char ** old; -char ** new; -{ - register int i; - - if (old == NULL || new == NULL) - return NULL; - for (i = 0; new[i] != NULL; ++i) { - old = enlist(old, new[i], strlen(new[i])); - if (old == NULL) - break; - } - return old; -} - -/* -** Given two lists of substrings, -** return a new list giving substrings common to both. -*/ - -static char ** -inboth(left, right) -char ** left; -char ** right; -{ - register char ** both; - register char ** temp; - register int lnum, rnum; - - if (left == NULL || right == NULL) - return NULL; - both = (char **) malloc(sizeof *both); - if (both == NULL) - return NULL; - both[0] = NULL; - for (lnum = 0; left[lnum] != NULL; ++lnum) { - for (rnum = 0; right[rnum] != NULL; ++rnum) { - temp = comsubs(left[lnum], right[rnum]); - if (temp == NULL) { - freelist(both); - return NULL; - } - both = addlists(both, temp); - freelist(temp); - if (both == NULL) - return NULL; - } - } - return both; -} - -/* -typedef struct { - char ** in; - char * left; - char * right; - char * is; -} must; - */ -static void -resetmust(mp) -register must * mp; -{ - mp->left[0] = mp->right[0] = mp->is[0] = '\0'; - freelist(mp->in); -} - -static void -regmust(r) -register struct regexp * r; -{ - register must * musts; - register must * mp; - register char * result = ""; - register int ri; - register int i; - register _token t; - static must must0; - - reg->mustn = 0; - reg->must[0] = '\0'; - musts = (must *) malloc((reg->tindex + 1) * sizeof *musts); - if (musts == NULL) - return; - mp = musts; - for (i = 0; i <= reg->tindex; ++i) - mp[i] = must0; - for (i = 0; i <= reg->tindex; ++i) { - mp[i].in = (char **) malloc(sizeof *mp[i].in); - mp[i].left = malloc(2); - mp[i].right = malloc(2); - mp[i].is = malloc(2); - if (mp[i].in == NULL || mp[i].left == NULL || - mp[i].right == NULL || mp[i].is == NULL) - goto done; - mp[i].left[0] = mp[i].right[0] = mp[i].is[0] = '\0'; - mp[i].in[0] = NULL; - } - for (ri = 0; ri < reg->tindex; ++ri) { - switch (t = reg->tokens[ri]) { - case _ALLBEGLINE: - case _ALLENDLINE: - case _LPAREN: - case _RPAREN: - goto done; /* "cannot happen" */ - case _EMPTY: - case _BEGLINE: - case _ENDLINE: - case _BEGWORD: - case _ENDWORD: - case _LIMWORD: - case _NOTLIMWORD: - case _BACKREF: - resetmust(mp); - break; - case _STAR: - case _QMARK: - if (mp <= musts) - goto done; /* "cannot happen" */ - --mp; - resetmust(mp); - break; - case _OR: - if (mp < &musts[2]) - goto done; /* "cannot happen" */ - { - register char ** new; - register must * lmp; - register must * rmp; - register int j, ln, rn, n; - - rmp = --mp; - lmp = --mp; - /* Guaranteed to be. Unlikely, but. . . */ - if (strcmp(lmp->is, rmp->is) != 0) - lmp->is[0] = '\0'; - /* Left side--easy */ - i = 0; - while (lmp->left[i] != '\0' && - lmp->left[i] == rmp->left[i]) - ++i; - lmp->left[i] = '\0'; - /* Right side */ - ln = strlen(lmp->right); - rn = strlen(rmp->right); - n = ln; - if (n > rn) - n = rn; - for (i = 0; i < n; ++i) - if (lmp->right[ln - i - 1] != - rmp->right[rn - i - 1]) - break; - for (j = 0; j < i; ++j) - lmp->right[j] = - lmp->right[(ln - i) + j]; - lmp->right[j] = '\0'; - new = inboth(lmp->in, rmp->in); - if (new == NULL) - goto done; - freelist(lmp->in); - free((char *) lmp->in); - lmp->in = new; - } - break; - case _PLUS: - if (mp <= musts) - goto done; /* "cannot happen" */ - --mp; - mp->is[0] = '\0'; - break; - case _END: - if (mp != &musts[1]) - goto done; /* "cannot happen" */ - for (i = 0; musts[0].in[i] != NULL; ++i) - if (strlen(musts[0].in[i]) > strlen(result)) - result = musts[0].in[i]; - goto done; - case _CAT: - if (mp < &musts[2]) - goto done; /* "cannot happen" */ - { - register must * lmp; - register must * rmp; - - rmp = --mp; - lmp = --mp; - /* - ** In. Everything in left, plus everything in - ** right, plus catenation of - ** left's right and right's left. - */ - lmp->in = addlists(lmp->in, rmp->in); - if (lmp->in == NULL) - goto done; - if (lmp->right[0] != '\0' && - rmp->left[0] != '\0') { - register char * tp; - - tp = icpyalloc(lmp->right); - if (tp == NULL) - goto done; - tp = icatalloc(tp, rmp->left); - if (tp == NULL) - goto done; - lmp->in = enlist(lmp->in, tp, - strlen(tp)); - free(tp); - if (lmp->in == NULL) - goto done; - } - /* Left-hand */ - if (lmp->is[0] != '\0') { - lmp->left = icatalloc(lmp->left, - rmp->left); - if (lmp->left == NULL) - goto done; - } - /* Right-hand */ - if (rmp->is[0] == '\0') - lmp->right[0] = '\0'; - lmp->right = icatalloc(lmp->right, rmp->right); - if (lmp->right == NULL) - goto done; - /* Guaranteed to be */ - if (lmp->is[0] != '\0' && rmp->is[0] != '\0') { - lmp->is = icatalloc(lmp->is, rmp->is); - if (lmp->is == NULL) - goto done; - } - } - break; - default: - if (t < _END) { - /* "cannot happen" */ - goto done; - } else if (t == '\0') { - /* not on *my* shift */ - goto done; - } else if (t >= _SET) { - /* easy enough */ - resetmust(mp); - } else { - /* plain character */ - resetmust(mp); - mp->is[0] = mp->left[0] = mp->right[0] = t; - mp->is[1] = mp->left[1] = mp->right[1] = '\0'; - mp->in = enlist(mp->in, mp->is, 1); - if (mp->in == NULL) - goto done; - } - break; - } - ++mp; - } -done: - (void) strncpy(reg->must, result, MUST_MAX - 1); - reg->must[MUST_MAX - 1] = '\0'; - reg->mustn = strlen(reg->must); - mp = musts; - for (i = 0; i <= reg->tindex; ++i) { - freelist(mp[i].in); - ifree((char *) mp[i].in); - ifree(mp[i].left); - ifree(mp[i].right); - ifree(mp[i].is); - } - free((char *) mp); -} diff --git a/gnu/usr.bin/gawk-2.15.2/dfa.h b/gnu/usr.bin/gawk-2.15.2/dfa.h deleted file mode 100644 index 65fc49565a7c..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/dfa.h +++ /dev/null @@ -1,543 +0,0 @@ -/* dfa.h - declarations for GNU deterministic regexp compiler - Copyright (C) 1988 Free Software Foundation, Inc. - Written June, 1988 by Mike Haertel - - NO WARRANTY - - BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY -NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT -WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, -RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS 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. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. -STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY -WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE -LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR -OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR -DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR -A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS -PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. - - GENERAL PUBLIC LICENSE TO COPY - - 1. You may copy and distribute verbatim copies of this source file -as you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy a valid copyright notice "Copyright - (C) 1988 Free Software Foundation, Inc."; and include following the -copyright notice a verbatim copy of the above disclaimer of warranty -and of this License. You may charge a distribution fee for the -physical act of transferring a copy. - - 2. You may modify your copy or copies of this source file or -any portion of it, and copy and distribute such modifications under -the terms of Paragraph 1 above, provided that you also do the following: - - a) cause the modified files to carry prominent notices stating - that you changed the files and the date of any change; and - - b) cause the whole of any work that you distribute or publish, - that in whole or in part contains or is a derivative of this - program or any part thereof, to be licensed at no charge to all - third parties on terms identical to those contained in this - License Agreement (except that you may choose to grant more extensive - warranty protection to some or all third parties, at your option). - - c) You may charge a distribution fee for the physical act of - transferring a copy, and you may at your option offer warranty - protection in exchange for a fee. - -Mere aggregation of another unrelated program with this program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other program under the scope of these terms. - - 3. You may copy and distribute this program or any portion of it in -compiled, executable or object code form under the terms of Paragraphs -1 and 2 above provided that you do the following: - - a) accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of - Paragraphs 1 and 2 above; or, - - b) accompany it with a written offer, valid for at least three - years, to give any third party free (except for a nominal - shipping charge) a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of - Paragraphs 1 and 2 above; or, - - c) accompany it with the information you received as to where the - corresponding source code may be obtained. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form alone.) - -For an executable file, complete source code means all the source code for -all modules it contains; but, as a special exception, it need not include -source code for modules which are standard libraries that accompany the -operating system on which the executable file runs. - - 4. You may not copy, sublicense, distribute or transfer this program -except as expressly provided under this License Agreement. Any attempt -otherwise to copy, sublicense, distribute or transfer this program is void and -your rights to use the program under this License agreement shall be -automatically terminated. However, parties who have received computer -software programs from you with this License Agreement will not have -their licenses terminated so long as such parties remain in full compliance. - - 5. If you wish to incorporate parts of this program into other free -programs whose distribution conditions are different, write to the Free -Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet -worked out a simple rule that can be stated here, but we will often permit -this. We will be guided by the two goals of preserving the free status of -all derivatives our free software and of promoting the sharing and reuse of -software. - - -In other words, you are welcome to use, share and improve this program. -You are forbidden to forbid anyone else to use, share and improve -what you give them. Help stamp out software-hoarding! */ - -#ifdef __STDC__ - -#ifdef SOMEDAY -#define ISALNUM(c) isalnum(c) -#define ISALPHA(c) isalpha(c) -#define ISUPPER(c) isupper(c) -#else -#define ISALNUM(c) (isascii(c) && isalnum(c)) -#define ISALPHA(c) (isascii(c) && isalpha(c)) -#define ISUPPER(c) (isascii(c) && isupper(c)) -#endif - -#else /* ! __STDC__ */ - -#define const - -#define ISALNUM(c) (isascii(c) && isalnum(c)) -#define ISALPHA(c) (isascii(c) && isalpha(c)) -#define ISUPPER(c) (isascii(c) && isupper(c)) - -#endif /* ! __STDC__ */ - -/* 1 means plain parentheses serve as grouping, and backslash - parentheses are needed for literal searching. - 0 means backslash-parentheses are grouping, and plain parentheses - are for literal searching. */ -#define RE_NO_BK_PARENS 1L - -/* 1 means plain | serves as the "or"-operator, and \| is a literal. - 0 means \| serves as the "or"-operator, and | is a literal. */ -#define RE_NO_BK_VBAR (1L << 1) - -/* 0 means plain + or ? serves as an operator, and \+, \? are literals. - 1 means \+, \? are operators and plain +, ? are literals. */ -#define RE_BK_PLUS_QM (1L << 2) - -/* 1 means | binds tighter than ^ or $. - 0 means the contrary. */ -#define RE_TIGHT_VBAR (1L << 3) - -/* 1 means treat \n as an _OR operator - 0 means treat it as a normal character */ -#define RE_NEWLINE_OR (1L << 4) - -/* 0 means that a special characters (such as *, ^, and $) always have - their special meaning regardless of the surrounding context. - 1 means that 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 | */ -#define RE_CONTEXT_INDEP_OPS (1L << 5) - -/* 1 means that \ in a character class escapes the next character (typically - a hyphen. It also is overloaded to mean that hyphen at the end of the range - is allowable and means that the hyphen is to be taken literally. */ -#define RE_AWK_CLASS_HACK (1L << 6) - -/* Now define combinations of bits for the standard possibilities. */ -#ifdef notdef -#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS) -#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR) -#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR) -#define RE_SYNTAX_EMACS 0 -#endif - -/* The NULL pointer. */ -#ifndef NULL -#define NULL 0 -#endif - -/* Number of bits in an unsigned char. */ -#ifndef CHARBITS -#define CHARBITS 8 -#endif - -/* First integer value that is greater than any character code. */ -#define _NOTCHAR (1 << CHARBITS) - -/* INTBITS need not be exact, just a lower bound. */ -#ifndef INTBITS -#define INTBITS (CHARBITS * sizeof (int)) -#endif - -/* Number of ints required to hold a bit for every character. */ -#define _CHARSET_INTS ((_NOTCHAR + INTBITS - 1) / INTBITS) - -/* Sets of unsigned characters are stored as bit vectors in arrays of ints. */ -typedef int _charset[_CHARSET_INTS]; - -/* The regexp is parsed into an array of tokens in postfix form. Some tokens - are operators and others are terminal symbols. Most (but not all) of these - codes are returned by the lexical analyzer. */ -#ifdef __STDC__ - -typedef enum -{ - _END = -1, /* _END is a terminal symbol that matches the - end of input; any value of _END or less in - the parse tree is such a symbol. Accepting - states of the DFA are those that would have - a transition on _END. */ - - /* Ordinary character values are terminal symbols that match themselves. */ - - _EMPTY = _NOTCHAR, /* _EMPTY is a terminal symbol that matches - the empty string. */ - - _BACKREF, /* _BACKREF is generated by \; it - it not completely handled. If the scanner - detects a transition on backref, it returns - a kind of "semi-success" indicating that - the match will have to be verified with - a backtracking matcher. */ - - _BEGLINE, /* _BEGLINE is a terminal symbol that matches - the empty string if it is at the beginning - of a line. */ - - _ALLBEGLINE, /* _ALLBEGLINE is a terminal symbol that - matches the empty string if it is at the - beginning of a line; _ALLBEGLINE applies - to the entire regexp and can only occur - as the first token thereof. _ALLBEGLINE - never appears in the parse tree; a _BEGLINE - is prepended with _CAT to the entire - regexp instead. */ - - _ENDLINE, /* _ENDLINE is a terminal symbol that matches - the empty string if it is at the end of - a line. */ - - _ALLENDLINE, /* _ALLENDLINE is to _ENDLINE as _ALLBEGLINE - is to _BEGLINE. */ - - _BEGWORD, /* _BEGWORD is a terminal symbol that matches - the empty string if it is at the beginning - of a word. */ - - _ENDWORD, /* _ENDWORD is a terminal symbol that matches - the empty string if it is at the end of - a word. */ - - _LIMWORD, /* _LIMWORD is a terminal symbol that matches - the empty string if it is at the beginning - or the end of a word. */ - - _NOTLIMWORD, /* _NOTLIMWORD is a terminal symbol that - matches the empty string if it is not at - the beginning or end of a word. */ - - _QMARK, /* _QMARK is an operator of one argument that - matches zero or one occurences of its - argument. */ - - _STAR, /* _STAR is an operator of one argument that - matches the Kleene closure (zero or more - occurrences) of its argument. */ - - _PLUS, /* _PLUS is an operator of one argument that - matches the positive closure (one or more - occurrences) of its argument. */ - - _CAT, /* _CAT is an operator of two arguments that - matches the concatenation of its - arguments. _CAT is never returned by the - lexical analyzer. */ - - _OR, /* _OR is an operator of two arguments that - matches either of its arguments. */ - - _LPAREN, /* _LPAREN never appears in the parse tree, - it is only a lexeme. */ - - _RPAREN, /* _RPAREN never appears in the parse tree. */ - - _SET /* _SET and (and any value greater) is a - terminal symbol that matches any of a - class of characters. */ -} _token; - -#else /* ! __STDC__ */ - -typedef short _token; - -#define _END -1 -#define _EMPTY _NOTCHAR -#define _BACKREF (_EMPTY + 1) -#define _BEGLINE (_EMPTY + 2) -#define _ALLBEGLINE (_EMPTY + 3) -#define _ENDLINE (_EMPTY + 4) -#define _ALLENDLINE (_EMPTY + 5) -#define _BEGWORD (_EMPTY + 6) -#define _ENDWORD (_EMPTY + 7) -#define _LIMWORD (_EMPTY + 8) -#define _NOTLIMWORD (_EMPTY + 9) -#define _QMARK (_EMPTY + 10) -#define _STAR (_EMPTY + 11) -#define _PLUS (_EMPTY + 12) -#define _CAT (_EMPTY + 13) -#define _OR (_EMPTY + 14) -#define _LPAREN (_EMPTY + 15) -#define _RPAREN (_EMPTY + 16) -#define _SET (_EMPTY + 17) - -#endif /* ! __STDC__ */ - -/* Sets are stored in an array in the compiled regexp; the index of the - array corresponding to a given set token is given by _SET_INDEX(t). */ -#define _SET_INDEX(t) ((t) - _SET) - -/* Sometimes characters can only be matched depending on the surrounding - context. Such context decisions depend on what the previous character - was, and the value of the current (lookahead) character. Context - dependent constraints are encoded as 8 bit integers. Each bit that - is set indicates that the constraint succeeds in the corresponding - context. - - bit 7 - previous and current are newlines - bit 6 - previous was newline, current isn't - bit 5 - previous wasn't newline, current is - bit 4 - neither previous nor current is a newline - bit 3 - previous and current are word-constituents - bit 2 - previous was word-constituent, current isn't - bit 1 - previous wasn't word-constituent, current is - bit 0 - neither previous nor current is word-constituent - - Word-constituent characters are those that satisfy isalnum(). - - The macro _SUCCEEDS_IN_CONTEXT determines whether a a given constraint - succeeds in a particular context. Prevn is true if the previous character - was a newline, currn is true if the lookahead character is a newline. - Prevl and currl similarly depend upon whether the previous and current - characters are word-constituent letters. */ -#define _MATCHES_NEWLINE_CONTEXT(constraint, prevn, currn) \ - ((constraint) & (1 << (((prevn) ? 2 : 0) + ((currn) ? 1 : 0) + 4))) -#define _MATCHES_LETTER_CONTEXT(constraint, prevl, currl) \ - ((constraint) & (1 << (((prevl) ? 2 : 0) + ((currl) ? 1 : 0)))) -#define _SUCCEEDS_IN_CONTEXT(constraint, prevn, currn, prevl, currl) \ - (_MATCHES_NEWLINE_CONTEXT(constraint, prevn, currn) \ - && _MATCHES_LETTER_CONTEXT(constraint, prevl, currl)) - -/* The following macros give information about what a constraint depends on. */ -#define _PREV_NEWLINE_DEPENDENT(constraint) \ - (((constraint) & 0xc0) >> 2 != ((constraint) & 0x30)) -#define _PREV_LETTER_DEPENDENT(constraint) \ - (((constraint) & 0x0c) >> 2 != ((constraint) & 0x03)) - -/* Tokens that match the empty string subject to some constraint actually - work by applying that constraint to determine what may follow them, - taking into account what has gone before. The following values are - the constraints corresponding to the special tokens previously defined. */ -#define _NO_CONSTRAINT 0xff -#define _BEGLINE_CONSTRAINT 0xcf -#define _ENDLINE_CONSTRAINT 0xaf -#define _BEGWORD_CONSTRAINT 0xf2 -#define _ENDWORD_CONSTRAINT 0xf4 -#define _LIMWORD_CONSTRAINT 0xf6 -#define _NOTLIMWORD_CONSTRAINT 0xf9 - -/* States of the recognizer correspond to sets of positions in the parse - tree, together with the constraints under which they may be matched. - So a position is encoded as an index into the parse tree together with - a constraint. */ -typedef struct -{ - unsigned index; /* Index into the parse array. */ - unsigned constraint; /* Constraint for matching this position. */ -} _position; - -/* Sets of positions are stored as arrays. */ -typedef struct -{ - _position *elems; /* Elements of this position set. */ - int nelem; /* Number of elements in this set. */ -} _position_set; - -/* A state of the regexp consists of a set of positions, some flags, - and the token value of the lowest-numbered position of the state that - contains an _END token. */ -typedef struct -{ - int hash; /* Hash of the positions of this state. */ - _position_set elems; /* Positions this state could match. */ - char newline; /* True if previous state matched newline. */ - char letter; /* True if previous state matched a letter. */ - char backref; /* True if this state matches a \. */ - unsigned char constraint; /* Constraint for this state to accept. */ - int first_end; /* Token value of the first _END in elems. */ -} _dfa_state; - -/* If an r.e. is at most MUST_MAX characters long, we look for a string which - must appear in it; whatever's found is dropped into the struct reg. */ - -#define MUST_MAX 50 - -/* A compiled regular expression. */ -struct regexp -{ - /* Stuff built by the scanner. */ - _charset *charsets; /* Array of character sets for _SET tokens. */ - int cindex; /* Index for adding new charsets. */ - int calloc; /* Number of charsets currently allocated. */ - - /* Stuff built by the parser. */ - _token *tokens; /* Postfix parse array. */ - int tindex; /* Index for adding new tokens. */ - int talloc; /* Number of tokens currently allocated. */ - int depth; /* Depth required of an evaluation stack - used for depth-first traversal of the - parse tree. */ - int nleaves; /* Number of leaves on the parse tree. */ - int nregexps; /* Count of parallel regexps being built - with regparse(). */ - - /* Stuff owned by the state builder. */ - _dfa_state *states; /* States of the regexp. */ - int sindex; /* Index for adding new states. */ - int salloc; /* Number of states currently allocated. */ - - /* Stuff built by the structure analyzer. */ - _position_set *follows; /* Array of follow sets, indexed by position - index. The follow of a position is the set - of positions containing characters that - could conceivably follow a character - matching the given position in a string - matching the regexp. Allocated to the - maximum possible position index. */ - int searchflag; /* True if we are supposed to build a searching - as opposed to an exact matcher. A searching - matcher finds the first and shortest string - matching a regexp anywhere in the buffer, - whereas an exact matcher finds the longest - string matching, but anchored to the - beginning of the buffer. */ - - /* Stuff owned by the executor. */ - int tralloc; /* Number of transition tables that have - slots so far. */ - int trcount; /* Number of transition tables that have - actually been built. */ - int **trans; /* Transition tables for states that can - never accept. If the transitions for a - state have not yet been computed, or the - state could possibly accept, its entry in - this table is NULL. */ - int **realtrans; /* Trans always points to realtrans + 1; this - is so trans[-1] can contain NULL. */ - int **fails; /* Transition tables after failing to accept - on a state that potentially could do so. */ - int *success; /* Table of acceptance conditions used in - regexecute and computed in build_state. */ - int *newlines; /* Transitions on newlines. The entry for a - newline in any transition table is always - -1 so we can count lines without wasting - too many cycles. The transition for a - newline is stored separately and handled - as a special case. Newline is also used - as a sentinel at the end of the buffer. */ - char must[MUST_MAX]; - int mustn; -}; - -/* Some macros for user access to regexp internals. */ - -/* ACCEPTING returns true if s could possibly be an accepting state of r. */ -#define ACCEPTING(s, r) ((r).states[s].constraint) - -/* ACCEPTS_IN_CONTEXT returns true if the given state accepts in the - specified context. */ -#define ACCEPTS_IN_CONTEXT(prevn, currn, prevl, currl, state, reg) \ - _SUCCEEDS_IN_CONTEXT((reg).states[state].constraint, \ - prevn, currn, prevl, currl) - -/* FIRST_MATCHING_REGEXP returns the index number of the first of parallel - regexps that a given state could accept. Parallel regexps are numbered - starting at 1. */ -#define FIRST_MATCHING_REGEXP(state, reg) (-(reg).states[state].first_end) - -/* Entry points. */ - -#ifdef __STDC__ - -/* Regsyntax() takes two arguments; the first sets the syntax bits described - earlier in this file, and the second sets the case-folding flag. */ -extern void regsyntax(long, int); - -/* Compile the given string of the given length into the given struct regexp. - Final argument is a flag specifying whether to build a searching or an - exact matcher. */ -extern void regcompile(const char *, size_t, struct regexp *, int); - -/* Execute the given struct regexp on the buffer of characters. The - first char * points to the beginning, and the second points to the - first character after the end of the buffer, which must be a writable - place so a sentinel end-of-buffer marker can be stored there. The - second-to-last argument is a flag telling whether to allow newlines to - be part of a string matching the regexp. The next-to-last argument, - if non-NULL, points to a place to increment every time we see a - newline. The final argument, if non-NULL, points to a flag that will - be set if further examination by a backtracking matcher is needed in - order to verify backreferencing; otherwise the flag will be cleared. - Returns NULL if no match is found, or a pointer to the first - character after the first & shortest matching string in the buffer. */ -extern char *regexecute(struct regexp *, char *, char *, int, int *, int *); - -/* Free the storage held by the components of a struct regexp. */ -extern void reg_free(struct regexp *); - -/* Entry points for people who know what they're doing. */ - -/* Initialize the components of a struct regexp. */ -extern void reginit(struct regexp *); - -/* Incrementally parse a string of given length into a struct regexp. */ -extern void regparse(const char *, size_t, struct regexp *); - -/* Analyze a parsed regexp; second argument tells whether to build a searching - or an exact matcher. */ -extern void reganalyze(struct regexp *, int); - -/* Compute, for each possible character, the transitions out of a given - state, storing them in an array of integers. */ -extern void regstate(int, struct regexp *, int []); - -/* Error handling. */ - -/* Regerror() is called by the regexp routines whenever an error occurs. It - takes a single argument, a NUL-terminated string describing the error. - The default reg_error() prints the error message to stderr and exits. - The user can provide a different reg_free() if so desired. */ -extern void reg_error(const char *); - -#else /* ! __STDC__ */ -extern void regsyntax(), regcompile(), reg_free(), reginit(), regparse(); -extern void reganalyze(), regstate(), reg_error(); -extern char *regexecute(); -#endif diff --git a/gnu/usr.bin/gawk-2.15.2/eval.c b/gnu/usr.bin/gawk-2.15.2/eval.c deleted file mode 100644 index f640f3733ada..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/eval.c +++ /dev/null @@ -1,1225 +0,0 @@ -/* - * eval.c - gawk parse tree interpreter - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "awk.h" - -extern double pow P((double x, double y)); -extern double modf P((double x, double *yp)); -extern double fmod P((double x, double y)); - -static int eval_condition P((NODE *tree)); -static NODE *op_assign P((NODE *tree)); -static NODE *func_call P((NODE *name, NODE *arg_list)); -static NODE *match_op P((NODE *tree)); - -NODE *_t; /* used as a temporary in macros */ -#ifdef MSDOS -double _msc51bug; /* to get around a bug in MSC 5.1 */ -#endif -NODE *ret_node; -int OFSlen; -int ORSlen; -int OFMTidx; -int CONVFMTidx; - -/* Macros and variables to save and restore function and loop bindings */ -/* - * the val variable allows return/continue/break-out-of-context to be - * caught and diagnosed - */ -#define PUSH_BINDING(stack, x, val) (memcpy ((char *)(stack), (char *)(x), sizeof (jmp_buf)), val++) -#define RESTORE_BINDING(stack, x, val) (memcpy ((char *)(x), (char *)(stack), sizeof (jmp_buf)), val--) - -static jmp_buf loop_tag; /* always the current binding */ -static int loop_tag_valid = 0; /* nonzero when loop_tag valid */ -static int func_tag_valid = 0; -static jmp_buf func_tag; -extern int exiting, exit_val; - -/* - * This table is used by the regexp routines to do case independant - * matching. Basically, every ascii character maps to itself, except - * uppercase letters map to lower case ones. This table has 256 - * entries, which may be overkill. Note also that if the system this - * is compiled on doesn't use 7-bit ascii, casetable[] should not be - * defined to the linker, so gawk should not load. - * - * Do NOT make this array static, it is used in several spots, not - * just in this file. - */ -#if 'a' == 97 /* it's ascii */ -char casetable[] = { - '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', - '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', - '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', - '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', - /* ' ' '!' '"' '#' '$' '%' '&' ''' */ - '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', - /* '(' ')' '*' '+' ',' '-' '.' '/' */ - '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', - /* '0' '1' '2' '3' '4' '5' '6' '7' */ - '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', - /* '8' '9' ':' ';' '<' '=' '>' '?' */ - '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', - /* '@' 'A' 'B' 'C' 'D' 'E' 'F' 'G' */ - '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - /* 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' */ - '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - /* 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' */ - '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - /* 'X' 'Y' 'Z' '[' '\' ']' '^' '_' */ - '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', - /* '`' 'a' 'b' 'c' 'd' 'e' 'f' 'g' */ - '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - /* 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' */ - '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - /* 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' */ - '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - /* 'x' 'y' 'z' '{' '|' '}' '~' */ - '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', - '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', - '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', - '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', - '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', - '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', - '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', - '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', - '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', - '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', - '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', - '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', - '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', - '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', - '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', - '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', - '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', -}; -#else -#include "You lose. You will need a translation table for your character set." -#endif - -/* - * Tree is a bunch of rules to run. Returns zero if it hit an exit() - * statement - */ -int -interpret(tree) -register NODE *volatile tree; -{ - jmp_buf volatile loop_tag_stack; /* shallow binding stack for loop_tag */ - static jmp_buf rule_tag; /* tag the rule currently being run, for NEXT - * and EXIT statements. It is static because - * there are no nested rules */ - register NODE *volatile t = NULL; /* temporary */ - NODE **volatile lhs; /* lhs == Left Hand Side for assigns, etc */ - NODE *volatile stable_tree; - int volatile traverse = 1; /* True => loop thru tree (Node_rule_list) */ - - if (tree == NULL) - return 1; - sourceline = tree->source_line; - source = tree->source_file; - switch (tree->type) { - case Node_rule_node: - traverse = 0; /* False => one for-loop iteration only */ - /* FALL THROUGH */ - case Node_rule_list: - for (t = tree; t != NULL; t = t->rnode) { - if (traverse) - tree = t->lnode; - sourceline = tree->source_line; - source = tree->source_file; - switch (setjmp(rule_tag)) { - case 0: /* normal non-jump */ - /* test pattern, if any */ - if (tree->lnode == NULL || - eval_condition(tree->lnode)) - (void) interpret(tree->rnode); - break; - case TAG_CONTINUE: /* NEXT statement */ - return 1; - case TAG_BREAK: - return 0; - default: - cant_happen(); - } - if (!traverse) /* case Node_rule_node */ - break; /* don't loop */ - } - break; - - case Node_statement_list: - for (t = tree; t != NULL; t = t->rnode) - (void) interpret(t->lnode); - break; - - case Node_K_if: - if (eval_condition(tree->lnode)) { - (void) interpret(tree->rnode->lnode); - } else { - (void) interpret(tree->rnode->rnode); - } - break; - - case Node_K_while: - PUSH_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - - stable_tree = tree; - while (eval_condition(stable_tree->lnode)) { - switch (setjmp(loop_tag)) { - case 0: /* normal non-jump */ - (void) interpret(stable_tree->rnode); - break; - case TAG_CONTINUE: /* continue statement */ - break; - case TAG_BREAK: /* break statement */ - RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - return 1; - default: - cant_happen(); - } - } - RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - break; - - case Node_K_do: - PUSH_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - stable_tree = tree; - do { - switch (setjmp(loop_tag)) { - case 0: /* normal non-jump */ - (void) interpret(stable_tree->rnode); - break; - case TAG_CONTINUE: /* continue statement */ - break; - case TAG_BREAK: /* break statement */ - RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - return 1; - default: - cant_happen(); - } - } while (eval_condition(stable_tree->lnode)); - RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - break; - - case Node_K_for: - PUSH_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - (void) interpret(tree->forloop->init); - stable_tree = tree; - while (eval_condition(stable_tree->forloop->cond)) { - switch (setjmp(loop_tag)) { - case 0: /* normal non-jump */ - (void) interpret(stable_tree->lnode); - /* fall through */ - case TAG_CONTINUE: /* continue statement */ - (void) interpret(stable_tree->forloop->incr); - break; - case TAG_BREAK: /* break statement */ - RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - return 1; - default: - cant_happen(); - } - } - RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - break; - - case Node_K_arrayfor: - { - volatile struct search l; /* For array_for */ - Func_ptr after_assign = NULL; - -#define hakvar forloop->init -#define arrvar forloop->incr - PUSH_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - lhs = get_lhs(tree->hakvar, &after_assign); - t = tree->arrvar; - if (t->type == Node_param_list) - t = stack_ptr[t->param_cnt]; - stable_tree = tree; - for (assoc_scan(t, (struct search *)&l); - l.retval; - assoc_next((struct search *)&l)) { - unref(*((NODE **) lhs)); - *lhs = dupnode(l.retval); - if (after_assign) - (*after_assign)(); - switch (setjmp(loop_tag)) { - case 0: - (void) interpret(stable_tree->lnode); - case TAG_CONTINUE: - break; - - case TAG_BREAK: - RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - return 1; - default: - cant_happen(); - } - } - RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); - break; - } - - case Node_K_break: - if (loop_tag_valid == 0) - fatal("unexpected break"); - longjmp(loop_tag, TAG_BREAK); - break; - - case Node_K_continue: - if (loop_tag_valid == 0) { - /* - * AT&T nawk treats continue outside of loops like - * next. Allow it if not posix, and complain if - * lint. - */ - static int warned = 0; - - if (do_lint && ! warned) { - warning("use of `continue' outside of loop is not portable"); - warned = 1; - } - if (do_posix) - fatal("use of `continue' outside of loop is not allowed"); - longjmp(rule_tag, TAG_CONTINUE); - } else - longjmp(loop_tag, TAG_CONTINUE); - break; - - case Node_K_print: - do_print(tree); - break; - - case Node_K_printf: - do_printf(tree); - break; - - case Node_K_delete: - do_delete(tree->lnode, tree->rnode); - break; - - case Node_K_next: - longjmp(rule_tag, TAG_CONTINUE); - break; - - case Node_K_nextfile: - do_nextfile(); - break; - - case Node_K_exit: - /* - * In A,K,&W, p. 49, it says that an exit statement "... - * causes the program to behave as if the end of input had - * occurred; no more input is read, and the END actions, if - * any are executed." This implies that the rest of the rules - * are not done. So we immediately break out of the main loop. - */ - exiting = 1; - if (tree) { - t = tree_eval(tree->lnode); - exit_val = (int) force_number(t); - } - free_temp(t); - longjmp(rule_tag, TAG_BREAK); - break; - - case Node_K_return: - t = tree_eval(tree->lnode); - ret_node = dupnode(t); - free_temp(t); - longjmp(func_tag, TAG_RETURN); - break; - - default: - /* - * Appears to be an expression statement. Throw away the - * value. - */ - if (do_lint && tree->type == Node_var) - warning("statement has no effect"); - t = tree_eval(tree); - free_temp(t); - break; - } - return 1; -} - -/* evaluate a subtree */ - -NODE * -r_tree_eval(tree) -register NODE *tree; -{ - register NODE *r, *t1, *t2; /* return value & temporary subtrees */ - register NODE **lhs; - register int di; - AWKNUM x, x1, x2; - long lx; -#ifdef CRAY - long lx2; -#endif - -#ifdef DEBUG - if (tree == NULL) - return Nnull_string; - if (tree->type == Node_val) { - if (tree->stref <= 0) cant_happen(); - return tree; - } - if (tree->type == Node_var) { - if (tree->var_value->stref <= 0) cant_happen(); - return tree->var_value; - } - if (tree->type == Node_param_list) { - if (stack_ptr[tree->param_cnt] == NULL) - return Nnull_string; - else - return stack_ptr[tree->param_cnt]->var_value; - } -#endif - switch (tree->type) { - case Node_and: - return tmp_number((AWKNUM) (eval_condition(tree->lnode) - && eval_condition(tree->rnode))); - - case Node_or: - return tmp_number((AWKNUM) (eval_condition(tree->lnode) - || eval_condition(tree->rnode))); - - case Node_not: - return tmp_number((AWKNUM) ! eval_condition(tree->lnode)); - - /* Builtins */ - case Node_builtin: - return ((*tree->proc) (tree->subnode)); - - case Node_K_getline: - return (do_getline(tree)); - - case Node_in_array: - return tmp_number((AWKNUM) in_array(tree->lnode, tree->rnode)); - - case Node_func_call: - return func_call(tree->rnode, tree->lnode); - - /* unary operations */ - case Node_NR: - case Node_FNR: - case Node_NF: - case Node_FIELDWIDTHS: - case Node_FS: - case Node_RS: - case Node_field_spec: - case Node_subscript: - case Node_IGNORECASE: - case Node_OFS: - case Node_ORS: - case Node_OFMT: - case Node_CONVFMT: - lhs = get_lhs(tree, (Func_ptr *)0); - return *lhs; - - case Node_var_array: - fatal("attempt to use an array in a scalar context"); - - case Node_unary_minus: - t1 = tree_eval(tree->subnode); - x = -force_number(t1); - free_temp(t1); - return tmp_number(x); - - case Node_cond_exp: - if (eval_condition(tree->lnode)) - return tree_eval(tree->rnode->lnode); - return tree_eval(tree->rnode->rnode); - - case Node_match: - case Node_nomatch: - case Node_regex: - return match_op(tree); - - case Node_func: - fatal("function `%s' called with space between name and (,\n%s", - tree->lnode->param, - "or used in other expression context"); - - /* assignments */ - case Node_assign: - { - Func_ptr after_assign = NULL; - - r = tree_eval(tree->rnode); - lhs = get_lhs(tree->lnode, &after_assign); - if (r != *lhs) { - NODE *save; - - save = *lhs; - *lhs = dupnode(r); - unref(save); - } - free_temp(r); - if (after_assign) - (*after_assign)(); - return *lhs; - } - - case Node_concat: - { -#define STACKSIZE 10 - NODE *stack[STACKSIZE]; - register NODE **sp; - register int len; - char *str; - register char *dest; - - sp = stack; - len = 0; - while (tree->type == Node_concat) { - *sp = force_string(tree_eval(tree->lnode)); - tree = tree->rnode; - len += (*sp)->stlen; - if (++sp == &stack[STACKSIZE-2]) /* one more and NULL */ - break; - } - *sp = force_string(tree_eval(tree)); - len += (*sp)->stlen; - *++sp = NULL; - emalloc(str, char *, len+2, "tree_eval"); - dest = str; - sp = stack; - while (*sp) { - memcpy(dest, (*sp)->stptr, (*sp)->stlen); - dest += (*sp)->stlen; - free_temp(*sp); - sp++; - } - r = make_str_node(str, len, ALREADY_MALLOCED); - r->flags |= TEMP; - } - return r; - - /* other assignment types are easier because they are numeric */ - case Node_preincrement: - case Node_predecrement: - case Node_postincrement: - case Node_postdecrement: - case Node_assign_exp: - case Node_assign_times: - case Node_assign_quotient: - case Node_assign_mod: - case Node_assign_plus: - case Node_assign_minus: - return op_assign(tree); - default: - break; /* handled below */ - } - - /* evaluate subtrees in order to do binary operation, then keep going */ - t1 = tree_eval(tree->lnode); - t2 = tree_eval(tree->rnode); - - switch (tree->type) { - case Node_geq: - case Node_leq: - case Node_greater: - case Node_less: - case Node_notequal: - case Node_equal: - di = cmp_nodes(t1, t2); - free_temp(t1); - free_temp(t2); - switch (tree->type) { - case Node_equal: - return tmp_number((AWKNUM) (di == 0)); - case Node_notequal: - return tmp_number((AWKNUM) (di != 0)); - case Node_less: - return tmp_number((AWKNUM) (di < 0)); - case Node_greater: - return tmp_number((AWKNUM) (di > 0)); - case Node_leq: - return tmp_number((AWKNUM) (di <= 0)); - case Node_geq: - return tmp_number((AWKNUM) (di >= 0)); - default: - cant_happen(); - } - break; - default: - break; /* handled below */ - } - - x1 = force_number(t1); - free_temp(t1); - x2 = force_number(t2); - free_temp(t2); - switch (tree->type) { - case Node_exp: - if ((lx = x2) == x2 && lx >= 0) { /* integer exponent */ - if (lx == 0) - x = 1; - else if (lx == 1) - x = x1; - else { - /* doing it this way should be more precise */ - for (x = x1; --lx; ) - x *= x1; - } - } else - x = pow((double) x1, (double) x2); - return tmp_number(x); - - case Node_times: - return tmp_number(x1 * x2); - - case Node_quotient: - if (x2 == 0) - fatal("division by zero attempted"); -#ifdef _CRAY - /* - * special case for integer division, put in for Cray - */ - lx2 = x2; - if (lx2 == 0) - return tmp_number(x1 / x2); - lx = (long) x1 / lx2; - if (lx * x2 == x1) - return tmp_number((AWKNUM) lx); - else -#endif - return tmp_number(x1 / x2); - - case Node_mod: - if (x2 == 0) - fatal("division by zero attempted in mod"); -#ifndef FMOD_MISSING - return tmp_number(fmod (x1, x2)); -#else - (void) modf(x1 / x2, &x); - return tmp_number(x1 - x * x2); -#endif - - case Node_plus: - return tmp_number(x1 + x2); - - case Node_minus: - return tmp_number(x1 - x2); - - case Node_var_array: - fatal("attempt to use an array in a scalar context"); - - default: - fatal("illegal type (%d) in tree_eval", tree->type); - } - return 0; -} - -/* Is TREE true or false? Returns 0==false, non-zero==true */ -static int -eval_condition(tree) -register NODE *tree; -{ - register NODE *t1; - register int ret; - - if (tree == NULL) /* Null trees are the easiest kinds */ - return 1; - if (tree->type == Node_line_range) { - /* - * Node_line_range is kind of like Node_match, EXCEPT: the - * lnode field (more properly, the condpair field) is a node - * of a Node_cond_pair; whether we evaluate the lnode of that - * node or the rnode depends on the triggered word. More - * precisely: if we are not yet triggered, we tree_eval the - * lnode; if that returns true, we set the triggered word. - * If we are triggered (not ELSE IF, note), we tree_eval the - * rnode, clear triggered if it succeeds, and perform our - * action (regardless of success or failure). We want to be - * able to begin and end on a single input record, so this - * isn't an ELSE IF, as noted above. - */ - if (!tree->triggered) - if (!eval_condition(tree->condpair->lnode)) - return 0; - else - tree->triggered = 1; - /* Else we are triggered */ - if (eval_condition(tree->condpair->rnode)) - tree->triggered = 0; - return 1; - } - - /* - * Could just be J.random expression. in which case, null and 0 are - * false, anything else is true - */ - - t1 = tree_eval(tree); - if (t1->flags & MAYBE_NUM) - (void) force_number(t1); - if (t1->flags & NUMBER) - ret = t1->numbr != 0.0; - else - ret = t1->stlen != 0; - free_temp(t1); - return ret; -} - -/* - * compare two nodes, returning negative, 0, positive - */ -int -cmp_nodes(t1, t2) -register NODE *t1, *t2; -{ - register int ret; - register int len1, len2; - - if (t1 == t2) - return 0; - if (t1->flags & MAYBE_NUM) - (void) force_number(t1); - if (t2->flags & MAYBE_NUM) - (void) force_number(t2); - if ((t1->flags & NUMBER) && (t2->flags & NUMBER)) { - if (t1->numbr == t2->numbr) return 0; - else if (t1->numbr - t2->numbr < 0) return -1; - else return 1; - } - (void) force_string(t1); - (void) force_string(t2); - len1 = t1->stlen; - len2 = t2->stlen; - if (len1 == 0 || len2 == 0) - return len1 - len2; - ret = memcmp(t1->stptr, t2->stptr, len1 <= len2 ? len1 : len2); - return ret == 0 ? len1-len2 : ret; -} - -static NODE * -op_assign(tree) -register NODE *tree; -{ - AWKNUM rval, lval; - NODE **lhs; - AWKNUM t1, t2; - long ltemp; - NODE *tmp; - Func_ptr after_assign = NULL; - - lhs = get_lhs(tree->lnode, &after_assign); - lval = force_number(*lhs); - - /* - * Can't unref *lhs until we know the type; doing so - * too early breaks x += x sorts of things. - */ - switch(tree->type) { - case Node_preincrement: - case Node_predecrement: - unref(*lhs); - *lhs = make_number(lval + - (tree->type == Node_preincrement ? 1.0 : -1.0)); - if (after_assign) - (*after_assign)(); - return *lhs; - - case Node_postincrement: - case Node_postdecrement: - unref(*lhs); - *lhs = make_number(lval + - (tree->type == Node_postincrement ? 1.0 : -1.0)); - if (after_assign) - (*after_assign)(); - return tmp_number(lval); - default: - break; /* handled below */ - } - - tmp = tree_eval(tree->rnode); - rval = force_number(tmp); - free_temp(tmp); - unref(*lhs); - switch(tree->type) { - case Node_assign_exp: - if ((ltemp = rval) == rval) { /* integer exponent */ - if (ltemp == 0) - *lhs = make_number((AWKNUM) 1); - else if (ltemp == 1) - *lhs = make_number(lval); - else { - /* doing it this way should be more precise */ - for (t1 = t2 = lval; --ltemp; ) - t1 *= t2; - *lhs = make_number(t1); - } - } else - *lhs = make_number((AWKNUM) pow((double) lval, (double) rval)); - break; - - case Node_assign_times: - *lhs = make_number(lval * rval); - break; - - case Node_assign_quotient: - if (rval == (AWKNUM) 0) - fatal("division by zero attempted in /="); -#ifdef _CRAY - /* - * special case for integer division, put in for Cray - */ - ltemp = rval; - if (ltemp == 0) { - *lhs = make_number(lval / rval); - break; - } - ltemp = (long) lval / ltemp; - if (ltemp * lval == rval) - *lhs = make_number((AWKNUM) ltemp); - else -#endif - *lhs = make_number(lval / rval); - break; - - case Node_assign_mod: - if (rval == (AWKNUM) 0) - fatal("division by zero attempted in %="); -#ifndef FMOD_MISSING - *lhs = make_number(fmod(lval, rval)); -#else - (void) modf(lval / rval, &t1); - t2 = lval - rval * t1; - *lhs = make_number(t2); -#endif - break; - - case Node_assign_plus: - *lhs = make_number(lval + rval); - break; - - case Node_assign_minus: - *lhs = make_number(lval - rval); - break; - default: - cant_happen(); - } - if (after_assign) - (*after_assign)(); - return *lhs; -} - -NODE **stack_ptr; - -static NODE * -func_call(name, arg_list) -NODE *name; /* name is a Node_val giving function name */ -NODE *arg_list; /* Node_expression_list of calling args. */ -{ - register NODE *arg, *argp, *r; - NODE *n, *f; - jmp_buf volatile func_tag_stack; - jmp_buf volatile loop_tag_stack; - int volatile save_loop_tag_valid = 0; - NODE **volatile save_stack, *save_ret_node; - NODE **volatile local_stack = NULL, **sp; - int count; - extern NODE *ret_node; - - /* - * retrieve function definition node - */ - f = lookup(name->stptr); - if (!f || f->type != Node_func) - fatal("function `%s' not defined", name->stptr); -#ifdef FUNC_TRACE - fprintf(stderr, "function %s called\n", name->stptr); -#endif - count = f->lnode->param_cnt; - if (count) - emalloc(local_stack, NODE **, count*sizeof(NODE *), "func_call"); - sp = local_stack; - - /* - * for each calling arg. add NODE * on stack - */ - for (argp = arg_list; count && argp != NULL; argp = argp->rnode) { - arg = argp->lnode; - getnode(r); - r->type = Node_var; - /* - * call by reference for arrays; see below also - */ - if (arg->type == Node_param_list) - arg = stack_ptr[arg->param_cnt]; - if (arg->type == Node_var_array) - *r = *arg; - else { - n = tree_eval(arg); - r->lnode = dupnode(n); - r->rnode = (NODE *) NULL; - free_temp(n); - } - *sp++ = r; - count--; - } - if (argp != NULL) /* left over calling args. */ - warning( - "function `%s' called with more arguments than declared", - name->stptr); - /* - * add remaining params. on stack with null value - */ - while (count-- > 0) { - getnode(r); - r->type = Node_var; - r->lnode = Nnull_string; - r->rnode = (NODE *) NULL; - *sp++ = r; - } - - /* - * Execute function body, saving context, as a return statement - * will longjmp back here. - * - * Have to save and restore the loop_tag stuff so that a return - * inside a loop in a function body doesn't scrog any loops going - * on in the main program. We save the necessary info in variables - * local to this function so that function nesting works OK. - * We also only bother to save the loop stuff if we're in a loop - * when the function is called. - */ - if (loop_tag_valid) { - int junk = 0; - - save_loop_tag_valid = (volatile int) loop_tag_valid; - PUSH_BINDING(loop_tag_stack, loop_tag, junk); - loop_tag_valid = 0; - } - save_stack = stack_ptr; - stack_ptr = local_stack; - PUSH_BINDING(func_tag_stack, func_tag, func_tag_valid); - save_ret_node = ret_node; - ret_node = Nnull_string; /* default return value */ - if (setjmp(func_tag) == 0) - (void) interpret(f->rnode); - - r = ret_node; - ret_node = (NODE *) save_ret_node; - RESTORE_BINDING(func_tag_stack, func_tag, func_tag_valid); - stack_ptr = (NODE **) save_stack; - - /* - * here, we pop each parameter and check whether - * it was an array. If so, and if the arg. passed in was - * a simple variable, then the value should be copied back. - * This achieves "call-by-reference" for arrays. - */ - sp = local_stack; - count = f->lnode->param_cnt; - for (argp = arg_list; count > 0 && argp != NULL; argp = argp->rnode) { - arg = argp->lnode; - if (arg->type == Node_param_list) - arg = stack_ptr[arg->param_cnt]; - n = *sp++; - if (arg->type == Node_var && n->type == Node_var_array) { - /* should we free arg->var_value ? */ - arg->var_array = n->var_array; - arg->type = Node_var_array; - } - unref(n->lnode); - freenode(n); - count--; - } - while (count-- > 0) { - n = *sp++; - /* if n is an (local) array, all the elements should be freed */ - if (n->type == Node_var_array) { - assoc_clear(n); - free(n->var_array); - } - unref(n->lnode); - freenode(n); - } - if (local_stack) - free((char *) local_stack); - - /* Restore the loop_tag stuff if necessary. */ - if (save_loop_tag_valid) { - int junk = 0; - - loop_tag_valid = (int) save_loop_tag_valid; - RESTORE_BINDING(loop_tag_stack, loop_tag, junk); - } - - if (!(r->flags & PERM)) - r->flags |= TEMP; - return r; -} - -/* - * This returns a POINTER to a node pointer. get_lhs(ptr) is the current - * value of the var, or where to store the var's new value - */ - -NODE ** -get_lhs(ptr, assign) -register NODE *ptr; -Func_ptr *assign; -{ - register NODE **aptr = NULL; - register NODE *n; - - switch (ptr->type) { - case Node_var_array: - fatal("attempt to use an array in a scalar context"); - case Node_var: - aptr = &(ptr->var_value); -#ifdef DEBUG - if (ptr->var_value->stref <= 0) - cant_happen(); -#endif - break; - - case Node_FIELDWIDTHS: - aptr = &(FIELDWIDTHS_node->var_value); - if (assign) - *assign = set_FIELDWIDTHS; - break; - - case Node_RS: - aptr = &(RS_node->var_value); - if (assign) - *assign = set_RS; - break; - - case Node_FS: - aptr = &(FS_node->var_value); - if (assign) - *assign = set_FS; - break; - - case Node_FNR: - unref(FNR_node->var_value); - FNR_node->var_value = make_number((AWKNUM) FNR); - aptr = &(FNR_node->var_value); - if (assign) - *assign = set_FNR; - break; - - case Node_NR: - unref(NR_node->var_value); - NR_node->var_value = make_number((AWKNUM) NR); - aptr = &(NR_node->var_value); - if (assign) - *assign = set_NR; - break; - - case Node_NF: - if (NF == -1) - (void) get_field(HUGE-1, assign); /* parse record */ - unref(NF_node->var_value); - NF_node->var_value = make_number((AWKNUM) NF); - aptr = &(NF_node->var_value); - if (assign) - *assign = set_NF; - break; - - case Node_IGNORECASE: - unref(IGNORECASE_node->var_value); - IGNORECASE_node->var_value = make_number((AWKNUM) IGNORECASE); - aptr = &(IGNORECASE_node->var_value); - if (assign) - *assign = set_IGNORECASE; - break; - - case Node_OFMT: - aptr = &(OFMT_node->var_value); - if (assign) - *assign = set_OFMT; - break; - - case Node_CONVFMT: - aptr = &(CONVFMT_node->var_value); - if (assign) - *assign = set_CONVFMT; - break; - - case Node_ORS: - aptr = &(ORS_node->var_value); - if (assign) - *assign = set_ORS; - break; - - case Node_OFS: - aptr = &(OFS_node->var_value); - if (assign) - *assign = set_OFS; - break; - - case Node_param_list: - aptr = &(stack_ptr[ptr->param_cnt]->var_value); - break; - - case Node_field_spec: - { - int field_num; - - n = tree_eval(ptr->lnode); - field_num = (int) force_number(n); - free_temp(n); - if (field_num < 0) - fatal("attempt to access field %d", field_num); - if (field_num == 0 && field0_valid) { /* short circuit */ - aptr = &fields_arr[0]; - if (assign) - *assign = reset_record; - break; - } - aptr = get_field(field_num, assign); - break; - } - case Node_subscript: - n = ptr->lnode; - if (n->type == Node_param_list) - n = stack_ptr[n->param_cnt]; - aptr = assoc_lookup(n, concat_exp(ptr->rnode)); - break; - - case Node_func: - fatal ("`%s' is a function, assignment is not allowed", - ptr->lnode->param); - default: - cant_happen(); - } - return aptr; -} - -static NODE * -match_op(tree) -register NODE *tree; -{ - register NODE *t1; - register Regexp *rp; - int i; - int match = 1; - - if (tree->type == Node_nomatch) - match = 0; - if (tree->type == Node_regex) - t1 = *get_field(0, (Func_ptr *) 0); - else { - t1 = force_string(tree_eval(tree->lnode)); - tree = tree->rnode; - } - rp = re_update(tree); - i = research(rp, t1->stptr, 0, t1->stlen, 0); - i = (i == -1) ^ (match == 1); - free_temp(t1); - return tmp_number((AWKNUM) i); -} - -void -set_IGNORECASE() -{ - static int warned = 0; - - if ((do_lint || do_unix) && ! warned) { - warned = 1; - warning("IGNORECASE not supported in compatibility mode"); - } - IGNORECASE = (force_number(IGNORECASE_node->var_value) != 0.0); - set_FS(); -} - -void -set_OFS() -{ - OFS = force_string(OFS_node->var_value)->stptr; - OFSlen = OFS_node->var_value->stlen; - OFS[OFSlen] = '\0'; -} - -void -set_ORS() -{ - ORS = force_string(ORS_node->var_value)->stptr; - ORSlen = ORS_node->var_value->stlen; - ORS[ORSlen] = '\0'; -} - -static NODE **fmt_list = NULL; -static int fmt_ok P((NODE *n)); -static int fmt_index P((NODE *n)); - -static int -fmt_ok(n) -NODE *n; -{ - /* to be done later */ - return 1; -} - -static int -fmt_index(n) -NODE *n; -{ - register int ix = 0; - static int fmt_num = 4; - static int fmt_hiwater = 0; - - if (fmt_list == NULL) - emalloc(fmt_list, NODE **, fmt_num*sizeof(*fmt_list), "fmt_index"); - (void) force_string(n); - while (ix < fmt_hiwater) { - if (cmp_nodes(fmt_list[ix], n) == 0) - return ix; - ix++; - } - /* not found */ - n->stptr[n->stlen] = '\0'; - if (!fmt_ok(n)) - warning("bad FMT specification"); - if (fmt_hiwater >= fmt_num) { - fmt_num *= 2; - emalloc(fmt_list, NODE **, fmt_num, "fmt_index"); - } - fmt_list[fmt_hiwater] = dupnode(n); - return fmt_hiwater++; -} - -void -set_OFMT() -{ - OFMTidx = fmt_index(OFMT_node->var_value); - OFMT = fmt_list[OFMTidx]->stptr; -} - -void -set_CONVFMT() -{ - CONVFMTidx = fmt_index(CONVFMT_node->var_value); - CONVFMT = fmt_list[CONVFMTidx]->stptr; -} diff --git a/gnu/usr.bin/gawk-2.15.2/field.c b/gnu/usr.bin/gawk-2.15.2/field.c deleted file mode 100644 index d8f9a5455631..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/field.c +++ /dev/null @@ -1,645 +0,0 @@ -/* - * field.c - routines for dealing with fields and record parsing - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "awk.h" - -static int (*parse_field) P((int, char **, int, NODE *, - Regexp *, void (*)(), NODE *)); -static void rebuild_record P((void)); -static int re_parse_field P((int, char **, int, NODE *, - Regexp *, void (*)(), NODE *)); -static int def_parse_field P((int, char **, int, NODE *, - Regexp *, void (*)(), NODE *)); -static int sc_parse_field P((int, char **, int, NODE *, - Regexp *, void (*)(), NODE *)); -static int fw_parse_field P((int, char **, int, NODE *, - Regexp *, void (*)(), NODE *)); -static void set_element P((int, char *, int, NODE *)); -static void grow_fields_arr P((int num)); -static void set_field P((int num, char *str, int len, NODE *dummy)); - - -static Regexp *FS_regexp = NULL; -static char *parse_extent; /* marks where to restart parse of record */ -static int parse_high_water=0; /* field number that we have parsed so far */ -static int nf_high_water = 0; /* size of fields_arr */ -static int resave_fs; -static NODE *save_FS; /* save current value of FS when line is read, - * to be used in deferred parsing - */ - -NODE **fields_arr; /* array of pointers to the field nodes */ -int field0_valid; /* $(>0) has not been changed yet */ -int default_FS; -static NODE **nodes; /* permanent repository of field nodes */ -static int *FIELDWIDTHS = NULL; - -void -init_fields() -{ - NODE *n; - - emalloc(fields_arr, NODE **, sizeof(NODE *), "init_fields"); - emalloc(nodes, NODE **, sizeof(NODE *), "init_fields"); - getnode(n); - *n = *Nnull_string; - fields_arr[0] = nodes[0] = n; - parse_extent = fields_arr[0]->stptr; - save_FS = dupnode(FS_node->var_value); - field0_valid = 1; -} - - -static void -grow_fields_arr(num) -int num; -{ - register int t; - register NODE *n; - - erealloc(fields_arr, NODE **, (num + 1) * sizeof(NODE *), "set_field"); - erealloc(nodes, NODE **, (num+1) * sizeof(NODE *), "set_field"); - for (t = nf_high_water+1; t <= num; t++) { - getnode(n); - *n = *Nnull_string; - fields_arr[t] = nodes[t] = n; - } - nf_high_water = num; -} - -/*ARGSUSED*/ -static void -set_field(num, str, len, dummy) -int num; -char *str; -int len; -NODE *dummy; /* not used -- just to make interface same as set_element */ -{ - register NODE *n; - - if (num > nf_high_water) - grow_fields_arr(num); - n = nodes[num]; - n->stptr = str; - n->stlen = len; - n->flags = (PERM|STR|STRING|MAYBE_NUM); - fields_arr[num] = n; -} - -/* Someone assigned a value to $(something). Fix up $0 to be right */ -static void -rebuild_record() -{ - register int tlen; - register NODE *tmp; - NODE *ofs; - char *ops; - register char *cops; - register NODE **ptr; - register int ofslen; - - tlen = 0; - ofs = force_string(OFS_node->var_value); - ofslen = ofs->stlen; - ptr = &fields_arr[NF]; - while (ptr > &fields_arr[0]) { - tmp = force_string(*ptr); - tlen += tmp->stlen; - ptr--; - } - tlen += (NF - 1) * ofslen; - if (tlen < 0) - tlen = 0; - emalloc(ops, char *, tlen + 2, "fix_fields"); - cops = ops; - ops[0] = '\0'; - for (ptr = &fields_arr[1]; ptr <= &fields_arr[NF]; ptr++) { - tmp = *ptr; - if (tmp->stlen == 1) - *cops++ = tmp->stptr[0]; - else if (tmp->stlen != 0) { - memcpy(cops, tmp->stptr, tmp->stlen); - cops += tmp->stlen; - } - if (ptr != &fields_arr[NF]) { - if (ofslen == 1) - *cops++ = ofs->stptr[0]; - else if (ofslen != 0) { - memcpy(cops, ofs->stptr, ofslen); - cops += ofslen; - } - } - } - tmp = make_str_node(ops, tlen, ALREADY_MALLOCED); - unref(fields_arr[0]); - fields_arr[0] = tmp; - field0_valid = 1; -} - -/* - * setup $0, but defer parsing rest of line until reference is made to $(>0) - * or to NF. At that point, parse only as much as necessary. - */ -void -set_record(buf, cnt, freeold) -char *buf; -int cnt; -int freeold; -{ - register int i; - - NF = -1; - for (i = 1; i <= parse_high_water; i++) { - unref(fields_arr[i]); - } - parse_high_water = 0; - if (freeold) { - unref(fields_arr[0]); - if (resave_fs) { - resave_fs = 0; - unref(save_FS); - save_FS = dupnode(FS_node->var_value); - } - nodes[0]->stptr = buf; - nodes[0]->stlen = cnt; - nodes[0]->stref = 1; - nodes[0]->flags = (STRING|STR|PERM|MAYBE_NUM); - fields_arr[0] = nodes[0]; - } - fields_arr[0]->flags |= MAYBE_NUM; - field0_valid = 1; -} - -void -reset_record() -{ - (void) force_string(fields_arr[0]); - set_record(fields_arr[0]->stptr, fields_arr[0]->stlen, 0); -} - -void -set_NF() -{ - register int i; - - NF = (int) force_number(NF_node->var_value); - if (NF > nf_high_water) - grow_fields_arr(NF); - for (i = parse_high_water + 1; i <= NF; i++) { - unref(fields_arr[i]); - fields_arr[i] = Nnull_string; - } - field0_valid = 0; -} - -/* - * this is called both from get_field() and from do_split() - * via (*parse_field)(). This variation is for when FS is a regular - * expression -- either user-defined or because RS=="" and FS==" " - */ -static int -re_parse_field(up_to, buf, len, fs, rp, set, n) -int up_to; /* parse only up to this field number */ -char **buf; /* on input: string to parse; on output: point to start next */ -int len; -NODE *fs; -Regexp *rp; -void (*set) (); /* routine to set the value of the parsed field */ -NODE *n; -{ - register char *scan = *buf; - register int nf = parse_high_water; - register char *field; - register char *end = scan + len; - - if (up_to == HUGE) - nf = 0; - if (len == 0) - return nf; - - if (*RS == 0 && default_FS) - while (scan < end && isspace(*scan)) - scan++; - field = scan; - while (scan < end - && research(rp, scan, 0, (int)(end - scan), 1) != -1 - && nf < up_to) { - if (REEND(rp, scan) == RESTART(rp, scan)) { /* null match */ - scan++; - if (scan == end) { - (*set)(++nf, field, scan - field, n); - up_to = nf; - break; - } - continue; - } - (*set)(++nf, field, scan + RESTART(rp, scan) - field, n); - scan += REEND(rp, scan); - field = scan; - if (scan == end) /* FS at end of record */ - (*set)(++nf, field, 0, n); - } - if (nf != up_to && scan < end) { - (*set)(++nf, scan, (int)(end - scan), n); - scan = end; - } - *buf = scan; - return (nf); -} - -/* - * this is called both from get_field() and from do_split() - * via (*parse_field)(). This variation is for when FS is a single space - * character. - */ -static int -def_parse_field(up_to, buf, len, fs, rp, set, n) -int up_to; /* parse only up to this field number */ -char **buf; /* on input: string to parse; on output: point to start next */ -int len; -NODE *fs; -Regexp *rp; -void (*set) (); /* routine to set the value of the parsed field */ -NODE *n; -{ - register char *scan = *buf; - register int nf = parse_high_water; - register char *field; - register char *end = scan + len; - char sav; - - if (up_to == HUGE) - nf = 0; - if (len == 0) - return nf; - - /* before doing anything save the char at *end */ - sav = *end; - /* because it will be destroyed now: */ - - *end = ' '; /* sentinel character */ - for (; nf < up_to; scan++) { - /* - * special case: fs is single space, strip leading whitespace - */ - while (scan < end && (*scan == ' ' || *scan == '\t')) - scan++; - if (scan >= end) - break; - field = scan; - while (*scan != ' ' && *scan != '\t') - scan++; - (*set)(++nf, field, (int)(scan - field), n); - if (scan == end) - break; - } - - /* everything done, restore original char at *end */ - *end = sav; - - *buf = scan; - return nf; -} - -/* - * this is called both from get_field() and from do_split() - * via (*parse_field)(). This variation is for when FS is a single character - * other than space. - */ -static int -sc_parse_field(up_to, buf, len, fs, rp, set, n) -int up_to; /* parse only up to this field number */ -char **buf; /* on input: string to parse; on output: point to start next */ -int len; -NODE *fs; -Regexp *rp; -void (*set) (); /* routine to set the value of the parsed field */ -NODE *n; -{ - register char *scan = *buf; - register char fschar; - register int nf = parse_high_water; - register char *field; - register char *end = scan + len; - char sav; - - if (up_to == HUGE) - nf = 0; - if (len == 0) - return nf; - - if (*RS == 0 && fs->stlen == 0) - fschar = '\n'; - else - fschar = fs->stptr[0]; - - /* before doing anything save the char at *end */ - sav = *end; - /* because it will be destroyed now: */ - *end = fschar; /* sentinel character */ - - for (; nf < up_to; scan++) { - field = scan; - while (*scan++ != fschar) - ; - scan--; - (*set)(++nf, field, (int)(scan - field), n); - if (scan == end) - break; - } - - /* everything done, restore original char at *end */ - *end = sav; - - *buf = scan; - return nf; -} - -/* - * this is called both from get_field() and from do_split() - * via (*parse_field)(). This variation is for fields are fixed widths. - */ -static int -fw_parse_field(up_to, buf, len, fs, rp, set, n) -int up_to; /* parse only up to this field number */ -char **buf; /* on input: string to parse; on output: point to start next */ -int len; -NODE *fs; -Regexp *rp; -void (*set) (); /* routine to set the value of the parsed field */ -NODE *n; -{ - register char *scan = *buf; - register int nf = parse_high_water; - register char *end = scan + len; - - if (up_to == HUGE) - nf = 0; - if (len == 0) - return nf; - for (; nf < up_to && (len = FIELDWIDTHS[nf+1]) != -1; ) { - if (len > end - scan) - len = end - scan; - (*set)(++nf, scan, len, n); - scan += len; - } - if (len == -1) - *buf = end; - else - *buf = scan; - return nf; -} - -NODE ** -get_field(requested, assign) -register int requested; -Func_ptr *assign; /* this field is on the LHS of an assign */ -{ - /* - * if requesting whole line but some other field has been altered, - * then the whole line must be rebuilt - */ - if (requested == 0) { - if (!field0_valid) { - /* first, parse remainder of input record */ - if (NF == -1) { - NF = (*parse_field)(HUGE-1, &parse_extent, - fields_arr[0]->stlen - - (parse_extent - fields_arr[0]->stptr), - save_FS, FS_regexp, set_field, - (NODE *)NULL); - parse_high_water = NF; - } - rebuild_record(); - } - if (assign) - *assign = reset_record; - return &fields_arr[0]; - } - - /* assert(requested > 0); */ - - if (assign) - field0_valid = 0; /* $0 needs reconstruction */ - - if (requested <= parse_high_water) /* already parsed this field */ - return &fields_arr[requested]; - - if (NF == -1) { /* have not yet parsed to end of record */ - /* - * parse up to requested fields, calling set_field() for each, - * saving in parse_extent the point where the parse left off - */ - if (parse_high_water == 0) /* starting at the beginning */ - parse_extent = fields_arr[0]->stptr; - parse_high_water = (*parse_field)(requested, &parse_extent, - fields_arr[0]->stlen - (parse_extent-fields_arr[0]->stptr), - save_FS, FS_regexp, set_field, (NODE *)NULL); - - /* - * if we reached the end of the record, set NF to the number of - * fields so far. Note that requested might actually refer to - * a field that is beyond the end of the record, but we won't - * set NF to that value at this point, since this is only a - * reference to the field and NF only gets set if the field - * is assigned to -- this case is handled below - */ - if (parse_extent == fields_arr[0]->stptr + fields_arr[0]->stlen) - NF = parse_high_water; - if (requested == HUGE-1) /* HUGE-1 means set NF */ - requested = parse_high_water; - } - if (parse_high_water < requested) { /* requested beyond end of record */ - if (assign) { /* expand record */ - register int i; - - if (requested > nf_high_water) - grow_fields_arr(requested); - - /* fill in fields that don't exist */ - for (i = parse_high_water + 1; i <= requested; i++) - fields_arr[i] = Nnull_string; - - NF = requested; - parse_high_water = requested; - } else - return &Nnull_string; - } - - return &fields_arr[requested]; -} - -static void -set_element(num, s, len, n) -int num; -char *s; -int len; -NODE *n; -{ - register NODE *it; - - it = make_string(s, len); - it->flags |= MAYBE_NUM; - *assoc_lookup(n, tmp_number((AWKNUM) (num))) = it; -} - -NODE * -do_split(tree) -NODE *tree; -{ - NODE *t1, *t2, *t3, *tmp; - NODE *fs; - char *s; - int (*parseit)P((int, char **, int, NODE *, - Regexp *, void (*)(), NODE *)); - Regexp *rp = NULL; - - t1 = tree_eval(tree->lnode); - t2 = tree->rnode->lnode; - t3 = tree->rnode->rnode->lnode; - - (void) force_string(t1); - - if (t2->type == Node_param_list) - t2 = stack_ptr[t2->param_cnt]; - if (t2->type != Node_var && t2->type != Node_var_array) - fatal("second argument of split is not a variable"); - assoc_clear(t2); - - if (t3->re_flags & FS_DFLT) { - parseit = parse_field; - fs = force_string(FS_node->var_value); - rp = FS_regexp; - } else { - tmp = force_string(tree_eval(t3->re_exp)); - if (tmp->stlen == 1) { - if (tmp->stptr[0] == ' ') - parseit = def_parse_field; - else - parseit = sc_parse_field; - } else { - parseit = re_parse_field; - rp = re_update(t3); - } - fs = tmp; - } - - s = t1->stptr; - tmp = tmp_number((AWKNUM) (*parseit)(HUGE, &s, (int)t1->stlen, - fs, rp, set_element, t2)); - free_temp(t1); - free_temp(t3); - return tmp; -} - -void -set_FS() -{ - NODE *tmp = NULL; - char buf[10]; - NODE *fs; - - buf[0] = '\0'; - default_FS = 0; - if (FS_regexp) { - refree(FS_regexp); - FS_regexp = NULL; - } - fs = force_string(FS_node->var_value); - if (fs->stlen > 1) - parse_field = re_parse_field; - else if (*RS == 0) { - parse_field = sc_parse_field; - if (fs->stlen == 1) { - if (fs->stptr[0] == ' ') { - default_FS = 1; - strcpy(buf, "[ \t\n]+"); - } else if (fs->stptr[0] != '\n') - sprintf(buf, "[%c\n]", fs->stptr[0]); - } - } else { - parse_field = def_parse_field; - if (fs->stptr[0] == ' ' && fs->stlen == 1) - default_FS = 1; - else if (fs->stptr[0] != ' ' && fs->stlen == 1) { - if (IGNORECASE == 0) - parse_field = sc_parse_field; - else - sprintf(buf, "[%c]", fs->stptr[0]); - } - } - if (buf[0]) { - FS_regexp = make_regexp(buf, strlen(buf), IGNORECASE, 1); - parse_field = re_parse_field; - } else if (parse_field == re_parse_field) { - FS_regexp = make_regexp(fs->stptr, fs->stlen, IGNORECASE, 1); - } else - FS_regexp = NULL; - resave_fs = 1; -} - -void -set_RS() -{ - (void) force_string(RS_node->var_value); - RS = RS_node->var_value->stptr; - set_FS(); -} - -void -set_FIELDWIDTHS() -{ - register char *scan; - char *end; - register int i; - static int fw_alloc = 1; - static int warned = 0; - extern double strtod(); - - if (do_lint && ! warned) { - warned = 1; - warning("use of FIELDWIDTHS is a gawk extension"); - } - if (do_unix) /* quick and dirty, does the trick */ - return; - - parse_field = fw_parse_field; - scan = force_string(FIELDWIDTHS_node->var_value)->stptr; - end = scan + 1; - if (FIELDWIDTHS == NULL) - emalloc(FIELDWIDTHS, int *, fw_alloc * sizeof(int), "set_FIELDWIDTHS"); - FIELDWIDTHS[0] = 0; - for (i = 1; ; i++) { - if (i >= fw_alloc) { - fw_alloc *= 2; - erealloc(FIELDWIDTHS, int *, fw_alloc * sizeof(int), "set_FIELDWIDTHS"); - } - FIELDWIDTHS[i] = (int) strtod(scan, &end); - if (end == scan) - break; - scan = end; - } - FIELDWIDTHS[i] = -1; -} diff --git a/gnu/usr.bin/gawk-2.15.2/gawk.texi b/gnu/usr.bin/gawk-2.15.2/gawk.texi deleted file mode 100644 index b2802623136d..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/gawk.texi +++ /dev/null @@ -1,11270 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header (This is for running Texinfo on a region.) -@setfilename gawk.info -@settitle The GAWK Manual -@c @smallbook -@c %**end of header (This is for running Texinfo on a region.) - -@ifinfo -@synindex fn cp -@synindex vr cp -@end ifinfo -@iftex -@syncodeindex fn cp -@syncodeindex vr cp -@end iftex - -@c If "finalout" is commented out, the printed output will show -@c black boxes that mark lines that are too long. Thus, it is -@c unwise to comment it out when running a master in case there are -@c overfulls which are deemed okay. - -@iftex -@finalout -@end iftex - -@c ===> NOTE! <== -@c Determine the edition number in *four* places by hand: -@c 1. First ifinfo section 2. title page 3. copyright page 4. top node -@c To find the locations, search for !!set - -@ifinfo -This file documents @code{awk}, a program that you can use to select -particular records in a file and perform operations upon them. - -This is Edition 0.15 of @cite{The GAWK Manual}, @* -for the 2.15 version of the GNU implementation @* -of AWK. - -Copyright (C) 1989, 1991, 1992, 1993 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 - -@setchapternewpage odd - -@c !!set edition, date, version -@titlepage -@title The GAWK Manual -@subtitle Edition 0.15 -@subtitle April 1993 -@author Diane Barlow Close -@author Arnold D. Robbins -@author Paul H. Rubin -@author Richard Stallman - -@c Include the Distribution inside the titlepage environment so -@c that headings are turned off. Headings on and off do not work. - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1989, 1991, 1992, 1993 Free Software Foundation, Inc. -@sp 2 - -@c !!set edition, date, version -This is Edition 0.15 of @cite{The GAWK Manual}, @* -for the 2.15 version of the GNU implementation @* -of AWK. - -@sp 2 -Published by the Free Software Foundation @* -675 Massachusetts Avenue @* -Cambridge, MA 02139 USA @* -Printed copies are available for $20 each. - -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 - -@ifinfo -@node Top, Preface, (dir), (dir) -@comment node-name, next, previous, up -@top General Introduction -@c Preface or Licensing nodes should come right after the Top -@c node, in `unnumbered' sections, then the chapter, `What is gawk'. - -This file documents @code{awk}, a program that you can use to select -particular records in a file and perform operations upon them. - -@c !!set edition, date, version -This is Edition 0.15 of @cite{The GAWK Manual}, @* -for the 2.15 version of the GNU implementation @* -of AWK. - -@end ifinfo - -@menu -* Preface:: What you can do with @code{awk}; brief history - and acknowledgements. -* Copying:: Your right to copy and distribute @code{gawk}. -* This Manual:: Using this manual. - Includes sample input files that you can use. -* Getting Started:: A basic introduction to using @code{awk}. - How to run an @code{awk} program. - Command line syntax. -* Reading Files:: How to read files and manipulate fields. -* Printing:: How to print using @code{awk}. Describes the - @code{print} and @code{printf} statements. - Also describes redirection of output. -* One-liners:: Short, sample @code{awk} programs. -* Patterns:: The various types of patterns - explained in detail. -* Actions:: The various types of actions are - introduced here. Describes - expressions and the various operators in - detail. Also describes comparison expressions. -* Expressions:: Expressions are the basic building - blocks of statements. -* Statements:: The various control statements are - described in detail. -* Arrays:: The description and use of arrays. - Also includes array-oriented control - statements. -* Built-in:: The built-in functions are summarized here. -* User-defined:: User-defined functions are described in detail. -* Built-in Variables:: Built-in Variables -* Command Line:: How to run @code{gawk}. -* Language History:: The evolution of the @code{awk} language. -* Installation:: Installing @code{gawk} under - various operating systems. -* Gawk Summary:: @code{gawk} Options and Language Summary. -* Sample Program:: A sample @code{awk} program with a - complete explanation. -* Bugs:: Reporting Problems and Bugs. -* Notes:: Something about the - implementation of @code{gawk}. -* Glossary:: An explanation of some unfamiliar terms. -* Index:: -@end menu - -@node Preface, Copying, Top, Top -@comment node-name, next, previous, up -@unnumbered Preface - -@iftex -@cindex what is @code{awk} -@end iftex -If you are like many computer users, you would frequently like to make -changes in various text files wherever certain patterns appear, or -extract data from parts of certain lines while discarding the rest. To -write a program to do this in a language such as C or Pascal is a -time-consuming inconvenience that may take many lines of code. The job -may be easier with @code{awk}. - -The @code{awk} utility interprets a special-purpose programming language -that makes it possible to handle simple data-reformatting jobs easily -with just a few lines of code. - -The GNU implementation of @code{awk} is called @code{gawk}; it is fully -upward compatible with the System V Release 4 version of -@code{awk}. @code{gawk} is also upward compatible with the @sc{posix} -(draft) specification of the @code{awk} language. This means that all -properly written @code{awk} programs should work with @code{gawk}. -Thus, we usually don't distinguish between @code{gawk} and other @code{awk} -implementations in this manual.@refill - -@cindex uses of @code{awk} -This manual teaches you what @code{awk} does and how you can use -@code{awk} effectively. You should already be familiar with basic -system commands such as @code{ls}. Using @code{awk} you can: @refill - -@itemize @bullet -@item -manage small, personal databases - -@item -generate reports - -@item -validate data -@item -produce indexes, and perform other document preparation tasks - -@item -even experiment with algorithms that can be adapted later to other computer -languages -@end itemize - -@iftex -This manual has the difficult task of being both tutorial and reference. -If you are a novice, feel free to skip over details that seem too complex. -You should also ignore the many cross references; they are for the -expert user, and for the on-line Info version of the manual. -@end iftex - -@menu -* History:: The history of @code{gawk} and - @code{awk}. Acknowledgements. -@end menu - -@node History, , Preface, Preface -@comment node-name, next, previous, up -@unnumberedsec History of @code{awk} and @code{gawk} - -@cindex acronym -@cindex history of @code{awk} -The name @code{awk} comes from the initials of its designers: Alfred V. -Aho, Peter J. Weinberger, and Brian W. Kernighan. The original version of -@code{awk} was written in 1977. In 1985 a new version made the programming -language more powerful, introducing user-defined functions, multiple input -streams, and computed regular expressions. -This new version became generally available with System V Release 3.1. -The version in System V Release 4 added some new features and also cleaned -up the behavior in some of the ``dark corners'' of the language. -The specification for @code{awk} in the @sc{posix} Command Language -and Utilities standard further clarified the language based on feedback -from both the @code{gawk} designers, and the original @code{awk} -designers.@refill - -The GNU implementation, @code{gawk}, was written in 1986 by Paul Rubin -and Jay Fenlason, with advice from Richard Stallman. John Woods -contributed parts of the code as well. In 1988 and 1989, David Trueman, with -help from Arnold Robbins, thoroughly reworked @code{gawk} for compatibility -with the newer @code{awk}. Current development (1992) focuses on bug fixes, -performance improvements, and standards compliance. - -We need to thank many people for their assistance in producing this -manual. Jay Fenlason contributed many ideas and sample programs. Richard -Mlynarik and Robert J. Chassell gave helpful comments on early drafts of this -manual. The paper @cite{A Supplemental Document for @code{awk}} by John W. -Pierce of the Chemistry Department at UC San Diego, pinpointed several -issues relevant both to @code{awk} implementation and to this manual, that -would otherwise have escaped us. David Trueman, Pat Rankin, and Michal -Jaegermann also contributed sections of the manual.@refill - -The following people provided many helpful comments on this edition of -the manual: Rick Adams, Michael Brennan, Rich Burridge, Diane Close, -Christopher (``Topher'') Eliot, Michael Lijewski, Pat Rankin, Miriam Robbins, -and Michal Jaegermann. Robert J. Chassell provided much valuable advice on -the use of Texinfo. - -Finally, we would like to thank Brian Kernighan of Bell Labs for invaluable -assistance during the testing and debugging of @code{gawk}, and for -help in clarifying numerous points about the language.@refill - -@node Copying, This Manual, Preface, Top -@unnumbered GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 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. -@end display - -@c fakenode --- for prepinfo -@unnumberedsec 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. - -@iftex -@c fakenode --- for prepinfo -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -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. - -@item -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. - -@item -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: - -@enumerate a -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -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. - -@item -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.) -@end enumerate - -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. - -@item -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: - -@enumerate a -@item -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, - -@item -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, - -@item -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.) -@end enumerate - -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@iftex -@c fakenode --- for prepinfo -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -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. - -@item -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 enumerate - -@iftex -@c fakenode --- for prepinfo -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@c fakenode --- for prepinfo -@unnumberedsec 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. - -@smallexample -@var{one line to give the program's name and a brief idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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. -@end smallexample - -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: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{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. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{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: - -@smallexample -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end smallexample - -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. - -@node This Manual, Getting Started, Copying, Top -@chapter Using this Manual -@cindex manual, using this -@cindex using this manual -@cindex language, @code{awk} -@cindex program, @code{awk} -@cindex @code{awk} language -@cindex @code{awk} program - -The term @code{awk} refers to a particular program, and to the language you -use to tell this program what to do. When we need to be careful, we call -the program ``the @code{awk} utility'' and the language ``the @code{awk} -language.'' The term @code{gawk} refers to a version of @code{awk} developed -as part the GNU project. The purpose of this manual is to explain -both the -@code{awk} language and how to run the @code{awk} utility.@refill - -While concentrating on the features of @code{gawk}, the manual will also -attempt to describe important differences between @code{gawk} and other -@code{awk} implementations. In particular, any features that are not -in the @sc{posix} standard for @code{awk} will be noted. @refill - -The term @dfn{@code{awk} program} refers to a program written by you in -the @code{awk} programming language.@refill - -@xref{Getting Started, ,Getting Started with @code{awk}}, for the bare -essentials you need to know to start using @code{awk}. - -Some useful ``one-liners'' are included to give you a feel for the -@code{awk} language (@pxref{One-liners, ,Useful ``One-liners''}). - -@ignore -@strong{I deleted four paragraphs here because they would confuse the -beginner more than help him. They mention terms such as ``field,'' -``pattern,'' ``action,'' ``built-in function'' which the beginner -doesn't know.} - -@strong{If you can find a way to introduce several of these concepts here, -enough to give the reader a map of what is to follow, that might -be useful. I'm not sure that can be done without taking up more -space than ought to be used here. There may be no way to win.} - -@strong{ADR: I'd like to tackle this in phase 2 of my editing.} -@end ignore - -A sample @code{awk} program has been provided for you -(@pxref{Sample Program}).@refill - -If you find terms that you aren't familiar with, try looking them -up in the glossary (@pxref{Glossary}).@refill - -The entire @code{awk} language is summarized for quick reference in -@ref{Gawk Summary, ,@code{gawk} Summary}. Look there if you just need -to refresh your memory about a particular feature.@refill - -Most of the time complete @code{awk} programs are used as examples, but in -some of the more advanced sections, only the part of the @code{awk} program -that illustrates the concept being described is shown.@refill - -@menu -* Sample Data Files:: Sample data files for use in the @code{awk} - programs illustrated in this manual. -@end menu - -@node Sample Data Files, , This Manual, This Manual -@section Data Files for the Examples - -@cindex input file, sample -@cindex sample input file -@cindex @file{BBS-list} file -Many of the examples in this manual take their input from two sample -data files. The first, called @file{BBS-list}, represents a list of -computer bulletin board systems together with information about those systems. -The second data file, called @file{inventory-shipped}, contains -information about shipments on a monthly basis. Each line of these -files is one @dfn{record}. - -In the file @file{BBS-list}, each record contains the name of a computer -bulletin board, its phone number, the board's baud rate, and a code for -the number of hours it is operational. An @samp{A} in the last column -means the board operates 24 hours a day. A @samp{B} in the last -column means the board operates evening and weekend hours, only. A -@samp{C} means the board operates only on weekends. - -@example -aardvark 555-5553 1200/300 B -alpo-net 555-3412 2400/1200/300 A -barfly 555-7685 1200/300 A -bites 555-1675 2400/1200/300 A -camelot 555-0542 300 C -core 555-2912 1200/300 C -fooey 555-1234 2400/1200/300 B -foot 555-6699 1200/300 B -macfoo 555-6480 1200/300 A -sdace 555-3430 2400/1200/300 A -sabafoo 555-2127 1200/300 C -@end example - -@cindex @file{inventory-shipped} file -The second data file, called @file{inventory-shipped}, represents -information about shipments during the year. -Each record contains the month of the year, the number -of green crates shipped, the number of red boxes shipped, the number of -orange bags shipped, and the number of blue packages shipped, -respectively. There are 16 entries, covering the 12 months of one year -and 4 months of the next year.@refill - -@example -Jan 13 25 15 115 -Feb 15 32 24 226 -Mar 15 24 34 228 -Apr 31 52 63 420 -May 16 34 29 208 -Jun 31 42 75 492 -Jul 24 34 67 436 -Aug 15 34 47 316 -Sep 13 55 37 277 -Oct 29 54 68 525 -Nov 20 87 82 577 -Dec 17 35 61 401 - -Jan 21 36 64 620 -Feb 26 58 80 652 -Mar 24 75 70 495 -Apr 21 70 74 514 -@end example - -@ifinfo -If you are reading this in GNU Emacs using Info, you can copy the regions -of text showing these sample files into your own test files. This way you -can try out the examples shown in the remainder of this document. You do -this by using the command @kbd{M-x write-region} to copy text from the Info -file into a file for use with @code{awk} -(@xref{Misc File Ops, , , emacs, GNU Emacs Manual}, -for more information). Using this information, create your own -@file{BBS-list} and @file{inventory-shipped} files, and practice what you -learn in this manual. -@end ifinfo - -@node Getting Started, Reading Files, This Manual, Top -@chapter Getting Started with @code{awk} -@cindex script, definition of -@cindex rule, definition of -@cindex program, definition of -@cindex basic function of @code{gawk} - -The basic function of @code{awk} is to search files for lines (or other -units of text) that contain certain patterns. When a line matches one -of the patterns, @code{awk} performs specified actions on that line. -@code{awk} keeps processing input lines in this way until the end of the -input file is reached.@refill - -When you run @code{awk}, you specify an @code{awk} @dfn{program} which -tells @code{awk} what to do. The program consists of a series of -@dfn{rules}. (It may also contain @dfn{function definitions}, but that -is an advanced feature, so we will ignore it for now. -@xref{User-defined, ,User-defined Functions}.) Each rule specifies one -pattern to search for, and one action to perform when that pattern is found. - -Syntactically, a rule consists of a pattern followed by an action. The -action is enclosed in curly braces to separate it from the pattern. -Rules are usually separated by newlines. Therefore, an @code{awk} -program looks like this: - -@example -@var{pattern} @{ @var{action} @} -@var{pattern} @{ @var{action} @} -@dots{} -@end example - -@menu -* Very Simple:: A very simple example. -* Two Rules:: A less simple one-line example with two rules. -* More Complex:: A more complex example. -* Running gawk:: How to run @code{gawk} programs; - includes command line syntax. -* Comments:: Adding documentation to @code{gawk} programs. -* Statements/Lines:: Subdividing or combining statements into lines. -* When:: When to use @code{gawk} and - when to use other things. -@end menu - -@node Very Simple, Two Rules, Getting Started, Getting Started -@section A Very Simple Example - -@cindex @samp{print $0} -The following command runs a simple @code{awk} program that searches the -input file @file{BBS-list} for the string of characters: @samp{foo}. (A -string of characters is usually called, a @dfn{string}. -The term @dfn{string} is perhaps based on similar usage in English, such -as ``a string of pearls,'' or, ``a string of cars in a train.'') - -@example -awk '/foo/ @{ print $0 @}' BBS-list -@end example - -@noindent -When lines containing @samp{foo} are found, they are printed, because -@w{@samp{print $0}} means print the current line. (Just @samp{print} by -itself means the same thing, so we could have written that -instead.) - -You will notice that slashes, @samp{/}, surround the string @samp{foo} -in the actual @code{awk} program. The slashes indicate that @samp{foo} -is a pattern to search for. This type of pattern is called a -@dfn{regular expression}, and is covered in more detail later -(@pxref{Regexp, ,Regular Expressions as Patterns}). There are -single-quotes around the @code{awk} program so that the shell won't -interpret any of it as special shell characters.@refill - -Here is what this program prints: - -@example -@group -fooey 555-1234 2400/1200/300 B -foot 555-6699 1200/300 B -macfoo 555-6480 1200/300 A -sabafoo 555-2127 1200/300 C -@end group -@end example - -@cindex action, default -@cindex pattern, default -@cindex default action -@cindex default pattern -In an @code{awk} rule, either the pattern or the action can be omitted, -but not both. If the pattern is omitted, then the action is performed -for @emph{every} input line. If the action is omitted, the default -action is to print all lines that match the pattern. - -Thus, we could leave out the action (the @code{print} statement and the curly -braces) in the above example, and the result would be the same: all -lines matching the pattern @samp{foo} would be printed. By comparison, -omitting the @code{print} statement but retaining the curly braces makes an -empty action that does nothing; then no lines would be printed. - -@node Two Rules, More Complex, Very Simple, Getting Started -@section An Example with Two Rules -@cindex how @code{awk} works - -The @code{awk} utility reads the input files one line at a -time. For each line, @code{awk} tries the patterns of each of the rules. -If several patterns match then several actions are run, in the order in -which they appear in the @code{awk} program. If no patterns match, then -no actions are run. - -After processing all the rules (perhaps none) that match the line, -@code{awk} reads the next line (however, -@pxref{Next Statement, ,The @code{next} Statement}). This continues -until the end of the file is reached.@refill - -For example, the @code{awk} program: - -@example -/12/ @{ print $0 @} -/21/ @{ print $0 @} -@end example - -@noindent -contains two rules. The first rule has the string @samp{12} as the -pattern and @samp{print $0} as the action. The second rule has the -string @samp{21} as the pattern and also has @samp{print $0} as the -action. Each rule's action is enclosed in its own pair of braces. - -This @code{awk} program prints every line that contains the string -@samp{12} @emph{or} the string @samp{21}. If a line contains both -strings, it is printed twice, once by each rule. - -If we run this program on our two sample data files, @file{BBS-list} and -@file{inventory-shipped}, as shown here: - -@example -awk '/12/ @{ print $0 @} - /21/ @{ print $0 @}' BBS-list inventory-shipped -@end example - -@noindent -we get the following output: - -@example -aardvark 555-5553 1200/300 B -alpo-net 555-3412 2400/1200/300 A -barfly 555-7685 1200/300 A -bites 555-1675 2400/1200/300 A -core 555-2912 1200/300 C -fooey 555-1234 2400/1200/300 B -foot 555-6699 1200/300 B -macfoo 555-6480 1200/300 A -sdace 555-3430 2400/1200/300 A -sabafoo 555-2127 1200/300 C -sabafoo 555-2127 1200/300 C -Jan 21 36 64 620 -Apr 21 70 74 514 -@end example - -@noindent -Note how the line in @file{BBS-list} beginning with @samp{sabafoo} -was printed twice, once for each rule. - -@node More Complex, Running gawk, Two Rules, Getting Started -@comment node-name, next, previous, up -@section A More Complex Example - -Here is an example to give you an idea of what typical @code{awk} -programs do. This example shows how @code{awk} can be used to -summarize, select, and rearrange the output of another utility. It uses -features that haven't been covered yet, so don't worry if you don't -understand all the details. - -@example -ls -l | awk '$5 == "Nov" @{ sum += $4 @} - END @{ print sum @}' -@end example - -This command prints the total number of bytes in all the files in the -current directory that were last modified in November (of any year). -(In the C shell you would need to type a semicolon and then a backslash -at the end of the first line; in a @sc{posix}-compliant shell, such as the -Bourne shell or the Bourne-Again shell, you can type the example as shown.) - -The @w{@samp{ls -l}} part of this example is a command that gives you a -listing of the files in a directory, including file size and date. -Its output looks like this:@refill - -@example --rw-r--r-- 1 close 1933 Nov 7 13:05 Makefile --rw-r--r-- 1 close 10809 Nov 7 13:03 gawk.h --rw-r--r-- 1 close 983 Apr 13 12:14 gawk.tab.h --rw-r--r-- 1 close 31869 Jun 15 12:20 gawk.y --rw-r--r-- 1 close 22414 Nov 7 13:03 gawk1.c --rw-r--r-- 1 close 37455 Nov 7 13:03 gawk2.c --rw-r--r-- 1 close 27511 Dec 9 13:07 gawk3.c --rw-r--r-- 1 close 7989 Nov 7 13:03 gawk4.c -@end example - -@noindent -The first field contains read-write permissions, the second field contains -the number of links to the file, and the third field identifies the owner of -the file. The fourth field contains the size of the file in bytes. The -fifth, sixth, and seventh fields contain the month, day, and time, -respectively, that the file was last modified. Finally, the eighth field -contains the name of the file. - -The @code{$5 == "Nov"} in our @code{awk} program is an expression that -tests whether the fifth field of the output from @w{@samp{ls -l}} -matches the string @samp{Nov}. Each time a line has the string -@samp{Nov} in its fifth field, the action @samp{@{ sum += $4 @}} is -performed. This adds the fourth field (the file size) to the variable -@code{sum}. As a result, when @code{awk} has finished reading all the -input lines, @code{sum} is the sum of the sizes of files whose -lines matched the pattern. (This works because @code{awk} variables -are automatically initialized to zero.)@refill - -After the last line of output from @code{ls} has been processed, the -@code{END} rule is executed, and the value of @code{sum} is -printed. In this example, the value of @code{sum} would be 80600.@refill - -These more advanced @code{awk} techniques are covered in later sections -(@pxref{Actions, ,Overview of Actions}). Before you can move on to more -advanced @code{awk} programming, you have to know how @code{awk} interprets -your input and displays your output. By manipulating fields and using -@code{print} statements, you can produce some very useful and spectacular -looking reports.@refill - -@node Running gawk, Comments, More Complex, Getting Started -@section How to Run @code{awk} Programs - -@ignore -Date: Mon, 26 Aug 91 09:48:10 +0200 -From: gatech!vsoc07.cern.ch!matheys (Jean-Pol Matheys (CERN - ECP Division)) -To: uunet.UU.NET!skeeve!arnold -Subject: RE: status check - -The introduction of Chapter 2 (i.e. before 2.1) should include -the whole of section 2.4 - it's better to tell people how to run awk programs -before giving any examples - -ADR --- he's right. but for now, don't do this because the rest of the -chapter would need some rewriting. -@end ignore - -@cindex command line formats -@cindex running @code{awk} programs -There are several ways to run an @code{awk} program. If the program is -short, it is easiest to include it in the command that runs @code{awk}, -like this: - -@example -awk '@var{program}' @var{input-file1} @var{input-file2} @dots{} -@end example - -@noindent -where @var{program} consists of a series of patterns and actions, as -described earlier. - -When the program is long, it is usually more convenient to put it in a file -and run it with a command like this: - -@example -awk -f @var{program-file} @var{input-file1} @var{input-file2} @dots{} -@end example - -@menu -* One-shot:: Running a short throw-away @code{awk} program. -* Read Terminal:: Using no input files (input from - terminal instead). -* Long:: Putting permanent @code{awk} programs in files. -* Executable Scripts:: Making self-contained @code{awk} programs. -@end menu - -@node One-shot, Read Terminal, Running gawk, Running gawk -@subsection One-shot Throw-away @code{awk} Programs - -Once you are familiar with @code{awk}, you will often type simple -programs at the moment you want to use them. Then you can write the -program as the first argument of the @code{awk} command, like this: - -@example -awk '@var{program}' @var{input-file1} @var{input-file2} @dots{} -@end example - -@noindent -where @var{program} consists of a series of @var{patterns} and -@var{actions}, as described earlier. - -@cindex single quotes, why needed -This command format instructs the shell to start @code{awk} and use the -@var{program} to process records in the input file(s). There are single -quotes around @var{program} so that the shell doesn't interpret any -@code{awk} characters as special shell characters. They also cause the -shell to treat all of @var{program} as a single argument for -@code{awk} and allow @var{program} to be more than one line long.@refill - -This format is also useful for running short or medium-sized @code{awk} -programs from shell scripts, because it avoids the need for a separate -file for the @code{awk} program. A self-contained shell script is more -reliable since there are no other files to misplace. - -@node Read Terminal, Long, One-shot, Running gawk -@subsection Running @code{awk} without Input Files - -@cindex standard input -@cindex input, standard -You can also run @code{awk} without any input files. If you type the -command line:@refill - -@example -awk '@var{program}' -@end example - -@noindent -then @code{awk} applies the @var{program} to the @dfn{standard input}, -which usually means whatever you type on the terminal. This continues -until you indicate end-of-file by typing @kbd{Control-d}. - -For example, if you execute this command: - -@example -awk '/th/' -@end example - -@noindent -whatever you type next is taken as data for that @code{awk} -program. If you go on to type the following data: - -@example -Kathy -Ben -Tom -Beth -Seth -Karen -Thomas -@kbd{Control-d} -@end example - -@noindent -then @code{awk} prints this output: - -@example -Kathy -Beth -Seth -@end example - -@noindent -@cindex case sensitivity -@cindex pattern, case sensitive -as matching the pattern @samp{th}. Notice that it did not recognize -@samp{Thomas} as matching the pattern. The @code{awk} language is -@dfn{case sensitive}, and matches patterns exactly. (However, you can -override this with the variable @code{IGNORECASE}. -@xref{Case-sensitivity, ,Case-sensitivity in Matching}.) - -@node Long, Executable Scripts, Read Terminal, Running gawk -@subsection Running Long Programs - -@cindex running long programs -@cindex @samp{-f} option -@cindex program file -@cindex file, @code{awk} program -Sometimes your @code{awk} programs can be very long. In this case it is -more convenient to put the program into a separate file. To tell -@code{awk} to use that file for its program, you type:@refill - -@example -awk -f @var{source-file} @var{input-file1} @var{input-file2} @dots{} -@end example - -The @samp{-f} instructs the @code{awk} utility to get the @code{awk} program -from the file @var{source-file}. Any file name can be used for -@var{source-file}. For example, you could put the program:@refill - -@example -/th/ -@end example - -@noindent -into the file @file{th-prog}. Then this command: - -@example -awk -f th-prog -@end example - -@noindent -does the same thing as this one: - -@example -awk '/th/' -@end example - -@noindent -which was explained earlier (@pxref{Read Terminal, ,Running @code{awk} without Input Files}). -Note that you don't usually need single quotes around the file name that you -specify with @samp{-f}, because most file names don't contain any of the shell's -special characters. Notice that in @file{th-prog}, the @code{awk} -program did not have single quotes around it. The quotes are only needed -for programs that are provided on the @code{awk} command line. - -If you want to identify your @code{awk} program files clearly as such, -you can add the extension @file{.awk} to the file name. This doesn't -affect the execution of the @code{awk} program, but it does make -``housekeeping'' easier. - -@node Executable Scripts, , Long, Running gawk -@c node-name, next, previous, up -@subsection Executable @code{awk} Programs -@cindex executable scripts -@cindex scripts, executable -@cindex self contained programs -@cindex program, self contained -@cindex @samp{#!} - -Once you have learned @code{awk}, you may want to write self-contained -@code{awk} scripts, using the @samp{#!} script mechanism. You can do -this on many Unix systems @footnote{The @samp{#!} mechanism works on -Unix systems derived from Berkeley Unix, System V Release 4, and some System -V Release 3 systems.} (and someday on GNU).@refill - -For example, you could create a text file named @file{hello}, containing -the following (where @samp{BEGIN} is a feature we have not yet -discussed): - -@example -#! /bin/awk -f - -# a sample awk program -BEGIN @{ print "hello, world" @} -@end example - -@noindent -After making this file executable (with the @code{chmod} command), you -can simply type: - -@example -hello -@end example - -@noindent -at the shell, and the system will arrange to run @code{awk} @footnote{The -line beginning with @samp{#!} lists the full pathname of an interpreter -to be run, and an optional initial command line argument to pass to that -interpreter. The operating system then runs the interpreter with the given -argument and the full argument list of the executed program. The first argument -in the list is the full pathname of the @code{awk} program. The rest of the -argument list will either be options to @code{awk}, or data files, -or both.} as if you had typed:@refill - -@example -awk -f hello -@end example - -@noindent -Self-contained @code{awk} scripts are useful when you want to write a -program which users can invoke without knowing that the program is -written in @code{awk}. - -@cindex shell scripts -@cindex scripts, shell -If your system does not support the @samp{#!} mechanism, you can get a -similar effect using a regular shell script. It would look something -like this: - -@example -: The colon makes sure this script is executed by the Bourne shell. -awk '@var{program}' "$@@" -@end example - -Using this technique, it is @emph{vital} to enclose the @var{program} in -single quotes to protect it from interpretation by the shell. If you -omit the quotes, only a shell wizard can predict the results. - -The @samp{"$@@"} causes the shell to forward all the command line -arguments to the @code{awk} program, without interpretation. The first -line, which starts with a colon, is used so that this shell script will -work even if invoked by a user who uses the C shell. -@c Someday: (See @cite{The Bourne Again Shell}, by ??.) - -@node Comments, Statements/Lines, Running gawk, Getting Started -@section Comments in @code{awk} Programs -@cindex @samp{#} -@cindex comments -@cindex use of comments -@cindex documenting @code{awk} programs -@cindex programs, documenting - -A @dfn{comment} is some text that is included in a program for the sake -of human readers, and that is not really part of the program. Comments -can explain what the program does, and how it works. Nearly all -programming languages have provisions for comments, because programs are -typically hard to understand without their extra help. - -In the @code{awk} language, a comment starts with the sharp sign -character, @samp{#}, and continues to the end of the line. The -@code{awk} language ignores the rest of a line following a sharp sign. -For example, we could have put the following into @file{th-prog}:@refill - -@smallexample -# This program finds records containing the pattern @samp{th}. This is how -# you continue comments on additional lines. -/th/ -@end smallexample - -You can put comment lines into keyboard-composed throw-away @code{awk} -programs also, but this usually isn't very useful; the purpose of a -comment is to help you or another person understand the program at -a later time.@refill - -@node Statements/Lines, When, Comments, Getting Started -@section @code{awk} Statements versus Lines - -Most often, each line in an @code{awk} program is a separate statement or -separate rule, like this: - -@example -awk '/12/ @{ print $0 @} - /21/ @{ print $0 @}' BBS-list inventory-shipped -@end example - -But sometimes statements can be more than one line, and lines can -contain several statements. You can split a statement into multiple -lines by inserting a newline after any of the following:@refill - -@example -, @{ ? : || && do else -@end example - -@noindent -A newline at any other point is considered the end of the statement. -(Splitting lines after @samp{?} and @samp{:} is a minor @code{gawk} -extension. The @samp{?} and @samp{:} referred to here is the -three operand conditional expression described in -@ref{Conditional Exp, ,Conditional Expressions}.)@refill - -@cindex backslash continuation -@cindex continuation of lines -If you would like to split a single statement into two lines at a point -where a newline would terminate it, you can @dfn{continue} it by ending the -first line with a backslash character, @samp{\}. This is allowed -absolutely anywhere in the statement, even in the middle of a string or -regular expression. For example: - -@example -awk '/This program is too long, so continue it\ - on the next line/ @{ print $1 @}' -@end example - -@noindent -We have generally not used backslash continuation in the sample programs in -this manual. Since in @code{gawk} there is no limit on the length of a line, -it is never strictly necessary; it just makes programs prettier. We have -preferred to make them even more pretty by keeping the statements short. -Backslash continuation is most useful when your @code{awk} program is in a -separate source file, instead of typed in on the command line. You should -also note that many @code{awk} implementations are more picky about where -you may use backslash continuation. For maximal portability of your @code{awk} -programs, it is best not to split your lines in the middle of a regular -expression or a string.@refill - -@strong{Warning: backslash continuation does not work as described above -with the C shell.} Continuation with backslash works for @code{awk} -programs in files, and also for one-shot programs @emph{provided} you -are using a @sc{posix}-compliant shell, such as the Bourne shell or the -Bourne-again shell. But the C shell used on Berkeley Unix behaves -differently! There, you must use two backslashes in a row, followed by -a newline.@refill - -@cindex multiple statements on one line -When @code{awk} statements within one rule are short, you might want to put -more than one of them on a line. You do this by separating the statements -with a semicolon, @samp{;}. -This also applies to the rules themselves. -Thus, the previous program could have been written:@refill - -@example -/12/ @{ print $0 @} ; /21/ @{ print $0 @} -@end example - -@noindent -@strong{Note:} the requirement that rules on the same line must be -separated with a semicolon is a recent change in the @code{awk} -language; it was done for consistency with the treatment of statements -within an action. - -@node When, , Statements/Lines, Getting Started -@section When to Use @code{awk} - -@cindex when to use @code{awk} -@cindex applications of @code{awk} -You might wonder how @code{awk} might be useful for you. Using additional -utility programs, more advanced patterns, field separators, arithmetic -statements, and other selection criteria, you can produce much more -complex output. The @code{awk} language is very useful for producing -reports from large amounts of raw data, such as summarizing information -from the output of other utility programs like @code{ls}. -(@xref{More Complex, ,A More Complex Example}.) - -Programs written with @code{awk} are usually much smaller than they would -be in other languages. This makes @code{awk} programs easy to compose and -use. Often @code{awk} programs can be quickly composed at your terminal, -used once, and thrown away. Since @code{awk} programs are interpreted, you -can avoid the usually lengthy edit-compile-test-debug cycle of software -development. - -Complex programs have been written in @code{awk}, including a complete -retargetable assembler for 8-bit microprocessors (@pxref{Glossary}, for -more information) and a microcode assembler for a special purpose Prolog -computer. However, @code{awk}'s capabilities are strained by tasks of -such complexity. - -If you find yourself writing @code{awk} scripts of more than, say, a few -hundred lines, you might consider using a different programming -language. Emacs Lisp is a good choice if you need sophisticated string -or pattern matching capabilities. The shell is also good at string and -pattern matching; in addition, it allows powerful use of the system -utilities. More conventional languages, such as C, C++, and Lisp, offer -better facilities for system programming and for managing the complexity -of large programs. Programs in these languages may require more lines -of source code than the equivalent @code{awk} programs, but they are -easier to maintain and usually run more efficiently.@refill - -@node Reading Files, Printing, Getting Started, Top -@chapter Reading Input Files - -@cindex reading files -@cindex input -@cindex standard input -@vindex FILENAME -In the typical @code{awk} program, all input is read either from the -standard input (by default the keyboard, but often a pipe from another -command) or from files whose names you specify on the @code{awk} command -line. If you specify input files, @code{awk} reads them in order, reading -all the data from one before going on to the next. The name of the current -input file can be found in the built-in variable @code{FILENAME} -(@pxref{Built-in Variables}).@refill - -The input is read in units called records, and processed by the -rules one record at a time. By default, each record is one line. Each -record is split automatically into fields, to make it more -convenient for a rule to work on its parts. - -On rare occasions you will need to use the @code{getline} command, -which can do explicit input from any number of files -(@pxref{Getline, ,Explicit Input with @code{getline}}).@refill - -@menu -* Records:: Controlling how data is split into records. -* Fields:: An introduction to fields. -* Non-Constant Fields:: Non-constant Field Numbers. -* Changing Fields:: Changing the Contents of a Field. -* Field Separators:: The field separator and how to change it. -* Constant Size:: Reading constant width data. -* Multiple Line:: Reading multi-line records. -* Getline:: Reading files under explicit program control - using the @code{getline} function. -* Close Input:: Closing an input file (so you can read from - the beginning once more). -@end menu - -@node Records, Fields, Reading Files, Reading Files -@section How Input is Split into Records - -@cindex record separator -The @code{awk} language divides its input into records and fields. -Records are separated by a character called the @dfn{record separator}. -By default, the record separator is the newline character, defining -a record to be a single line of text.@refill - -@iftex -@cindex changing the record separator -@end iftex -@vindex RS -Sometimes you may want to use a different character to separate your -records. You can use a different character by changing the built-in -variable @code{RS}. The value of @code{RS} is a string that says how -to separate records; the default value is @code{"\n"}, the string containing -just a newline character. This is why records are, by default, single lines. - -@code{RS} can have any string as its value, but only the first character -of the string is used as the record separator. The other characters are -ignored. @code{RS} is exceptional in this regard; @code{awk} uses the -full value of all its other built-in variables.@refill - -@ignore -Someday this should be true! - -The value of @code{RS} is not limited to a one-character string. It can -be any regular expression (@pxref{Regexp, ,Regular Expressions as Patterns}). -In general, each record -ends at the next string that matches the regular expression; the next -record starts at the end of the matching string. This general rule is -actually at work in the usual case, where @code{RS} contains just a -newline: a record ends at the beginning of the next matching string (the -next newline in the input) and the following record starts just after -the end of this string (at the first character of the following line). -The newline, since it matches @code{RS}, is not part of either record.@refill -@end ignore - -You can change the value of @code{RS} in the @code{awk} program with the -assignment operator, @samp{=} (@pxref{Assignment Ops, ,Assignment Expressions}). -The new record-separator character should be enclosed in quotation marks to make -a string constant. Often the right time to do this is at the beginning -of execution, before any input has been processed, so that the very -first record will be read with the proper separator. To do this, use -the special @code{BEGIN} pattern -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}). For -example:@refill - -@example -awk 'BEGIN @{ RS = "/" @} ; @{ print $0 @}' BBS-list -@end example - -@noindent -changes the value of @code{RS} to @code{"/"}, before reading any input. -This is a string whose first character is a slash; as a result, records -are separated by slashes. Then the input file is read, and the second -rule in the @code{awk} program (the action with no pattern) prints each -record. Since each @code{print} statement adds a newline at the end of -its output, the effect of this @code{awk} program is to copy the input -with each slash changed to a newline. - -Another way to change the record separator is on the command line, -using the variable-assignment feature -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@example -awk '@{ print $0 @}' RS="/" BBS-list -@end example - -@noindent -This sets @code{RS} to @samp{/} before processing @file{BBS-list}. - -Reaching the end of an input file terminates the current input record, -even if the last character in the file is not the character in @code{RS}. - -@ignore -@c merge the preceding paragraph and this stuff into one paragraph -@c and put it in an `expert info' section. -This produces correct behavior in the vast majority of cases, although -the following (extreme) pipeline prints a surprising @samp{1}. (There -is one field, consisting of a newline.) - -@example -echo | awk 'BEGIN @{ RS = "a" @} ; @{ print NF @}' -@end example - -@end ignore - -The empty string, @code{""} (a string of no characters), has a special meaning -as the value of @code{RS}: it means that records are separated only -by blank lines. @xref{Multiple Line, ,Multiple-Line Records}, for more details. - -@cindex number of records, @code{NR} or @code{FNR} -@vindex NR -@vindex FNR -The @code{awk} utility keeps track of the number of records that have -been read so far from the current input file. This value is stored in a -built-in variable called @code{FNR}. It is reset to zero when a new -file is started. Another built-in variable, @code{NR}, is the total -number of input records read so far from all files. It starts at zero -but is never automatically reset to zero. - -If you change the value of @code{RS} in the middle of an @code{awk} run, -the new value is used to delimit subsequent records, but the record -currently being processed (and records already processed) are not -affected. - -@node Fields, Non-Constant Fields, Records, Reading Files -@section Examining Fields - -@cindex examining fields -@cindex fields -@cindex accessing fields -When @code{awk} reads an input record, the record is -automatically separated or @dfn{parsed} by the interpreter into chunks -called @dfn{fields}. By default, fields are separated by whitespace, -like words in a line. -Whitespace in @code{awk} means any string of one or more spaces and/or -tabs; other characters such as newline, formfeed, and so on, that are -considered whitespace by other languages are @emph{not} considered -whitespace by @code{awk}.@refill - -The purpose of fields is to make it more convenient for you to refer to -these pieces of the record. You don't have to use them---you can -operate on the whole record if you wish---but fields are what make -simple @code{awk} programs so powerful. - -@cindex @code{$} (field operator) -@cindex operators, @code{$} -To refer to a field in an @code{awk} program, you use a dollar-sign, -@samp{$}, followed by the number of the field you want. Thus, @code{$1} -refers to the first field, @code{$2} to the second, and so on. For -example, suppose the following is a line of input:@refill - -@example -This seems like a pretty nice example. -@end example - -@noindent -Here the first field, or @code{$1}, is @samp{This}; the second field, or -@code{$2}, is @samp{seems}; and so on. Note that the last field, -@code{$7}, is @samp{example.}. Because there is no space between the -@samp{e} and the @samp{.}, the period is considered part of the seventh -field.@refill - -No matter how many fields there are, the last field in a record can be -represented by @code{$NF}. So, in the example above, @code{$NF} would -be the same as @code{$7}, which is @samp{example.}. Why this works is -explained below (@pxref{Non-Constant Fields, ,Non-constant Field Numbers}). -If you try to refer to a field beyond the last one, such as @code{$8} -when the record has only 7 fields, you get the empty string.@refill - -@vindex NF -@cindex number of fields, @code{NF} -Plain @code{NF}, with no @samp{$}, is a built-in variable whose value -is the number of fields in the current record. - -@code{$0}, which looks like an attempt to refer to the zeroth field, is -a special case: it represents the whole input record. This is what you -would use if you weren't interested in fields. - -Here are some more examples: - -@example -awk '$1 ~ /foo/ @{ print $0 @}' BBS-list -@end example - -@noindent -This example prints each record in the file @file{BBS-list} whose first -field contains the string @samp{foo}. The operator @samp{~} is called a -@dfn{matching operator} (@pxref{Comparison Ops, ,Comparison Expressions}); -it tests whether a string (here, the field @code{$1}) matches a given regular -expression.@refill - -By contrast, the following example: - -@example -awk '/foo/ @{ print $1, $NF @}' BBS-list -@end example - -@noindent -looks for @samp{foo} in @emph{the entire record} and prints the first -field and the last field for each input record containing a -match.@refill - -@node Non-Constant Fields, Changing Fields, Fields, Reading Files -@section Non-constant Field Numbers - -The number of a field does not need to be a constant. Any expression in -the @code{awk} language can be used after a @samp{$} to refer to a -field. The value of the expression specifies the field number. If the -value is a string, rather than a number, it is converted to a number. -Consider this example:@refill - -@example -awk '@{ print $NR @}' -@end example - -@noindent -Recall that @code{NR} is the number of records read so far: 1 in the -first record, 2 in the second, etc. So this example prints the first -field of the first record, the second field of the second record, and so -on. For the twentieth record, field number 20 is printed; most likely, -the record has fewer than 20 fields, so this prints a blank line. - -Here is another example of using expressions as field numbers: - -@example -awk '@{ print $(2*2) @}' BBS-list -@end example - -The @code{awk} language must evaluate the expression @code{(2*2)} and use -its value as the number of the field to print. The @samp{*} sign -represents multiplication, so the expression @code{2*2} evaluates to 4. -The parentheses are used so that the multiplication is done before the -@samp{$} operation; they are necessary whenever there is a binary -operator in the field-number expression. This example, then, prints the -hours of operation (the fourth field) for every line of the file -@file{BBS-list}.@refill - -If the field number you compute is zero, you get the entire record. -Thus, @code{$(2-2)} has the same value as @code{$0}. Negative field -numbers are not allowed. - -The number of fields in the current record is stored in the built-in -variable @code{NF} (@pxref{Built-in Variables}). The expression -@code{$NF} is not a special feature: it is the direct consequence of -evaluating @code{NF} and using its value as a field number. - -@node Changing Fields, Field Separators, Non-Constant Fields, Reading Files -@section Changing the Contents of a Field - -@cindex field, changing contents of -@cindex changing contents of a field -@cindex assignment to fields -You can change the contents of a field as seen by @code{awk} within an -@code{awk} program; this changes what @code{awk} perceives as the -current input record. (The actual input is untouched: @code{awk} never -modifies the input file.) - -Consider this example: - -@smallexample -awk '@{ $3 = $2 - 10; print $2, $3 @}' inventory-shipped -@end smallexample - -@noindent -The @samp{-} sign represents subtraction, so this program reassigns -field three, @code{$3}, to be the value of field two minus ten, -@code{$2 - 10}. (@xref{Arithmetic Ops, ,Arithmetic Operators}.) -Then field two, and the new value for field three, are printed. - -In order for this to work, the text in field @code{$2} must make sense -as a number; the string of characters must be converted to a number in -order for the computer to do arithmetic on it. The number resulting -from the subtraction is converted back to a string of characters which -then becomes field three. -@xref{Conversion, ,Conversion of Strings and Numbers}.@refill - -When you change the value of a field (as perceived by @code{awk}), the -text of the input record is recalculated to contain the new field where -the old one was. Therefore, @code{$0} changes to reflect the altered -field. Thus, - -@smallexample -awk '@{ $2 = $2 - 10; print $0 @}' inventory-shipped -@end smallexample - -@noindent -prints a copy of the input file, with 10 subtracted from the second -field of each line. - -You can also assign contents to fields that are out of range. For -example: - -@smallexample -awk '@{ $6 = ($5 + $4 + $3 + $2) ; print $6 @}' inventory-shipped -@end smallexample - -@noindent -We've just created @code{$6}, whose value is the sum of fields -@code{$2}, @code{$3}, @code{$4}, and @code{$5}. The @samp{+} sign -represents addition. For the file @file{inventory-shipped}, @code{$6} -represents the total number of parcels shipped for a particular month. - -Creating a new field changes the internal @code{awk} copy of the current -input record---the value of @code{$0}. Thus, if you do @samp{print $0} -after adding a field, the record printed includes the new field, with -the appropriate number of field separators between it and the previously -existing fields. - -This recomputation affects and is affected by several features not yet -discussed, in particular, the @dfn{output field separator}, @code{OFS}, -which is used to separate the fields (@pxref{Output Separators}), and -@code{NF} (the number of fields; @pxref{Fields, ,Examining Fields}). -For example, the value of @code{NF} is set to the number of the highest -field you create.@refill - -Note, however, that merely @emph{referencing} an out-of-range field -does @emph{not} change the value of either @code{$0} or @code{NF}. -Referencing an out-of-range field merely produces a null string. For -example:@refill - -@smallexample -if ($(NF+1) != "") - print "can't happen" -else - print "everything is normal" -@end smallexample - -@noindent -should print @samp{everything is normal}, because @code{NF+1} is certain -to be out of range. (@xref{If Statement, ,The @code{if} Statement}, -for more information about @code{awk}'s @code{if-else} statements.)@refill - -It is important to note that assigning to a field will change the -value of @code{$0}, but will not change the value of @code{NF}, -even when you assign the null string to a field. For example: - -@smallexample -echo a b c d | awk '@{ OFS = ":"; $2 = "" ; print ; print NF @}' -@end smallexample - -@noindent -prints - -@smallexample -a::c:d -4 -@end smallexample - -@noindent -The field is still there, it just has an empty value. You can tell -because there are two colons in a row. - -@node Field Separators, Constant Size, Changing Fields, Reading Files -@section Specifying how Fields are Separated -@vindex FS -@cindex fields, separating -@cindex field separator, @code{FS} -@cindex @samp{-F} option - -(This section is rather long; it describes one of the most fundamental -operations in @code{awk}. If you are a novice with @code{awk}, we -recommend that you re-read this section after you have studied the -section on regular expressions, @ref{Regexp, ,Regular Expressions as Patterns}.) - -The way @code{awk} splits an input record into fields is controlled by -the @dfn{field separator}, which is a single character or a regular -expression. @code{awk} scans the input record for matches for the -separator; the fields themselves are the text between the matches. For -example, if the field separator is @samp{oo}, then the following line: - -@smallexample -moo goo gai pan -@end smallexample - -@noindent -would be split into three fields: @samp{m}, @samp{@ g} and @samp{@ gai@ -pan}. - -The field separator is represented by the built-in variable @code{FS}. -Shell programmers take note! @code{awk} does not use the name @code{IFS} -which is used by the shell.@refill - -You can change the value of @code{FS} in the @code{awk} program with the -assignment operator, @samp{=} (@pxref{Assignment Ops, ,Assignment Expressions}). -Often the right time to do this is at the beginning of execution, -before any input has been processed, so that the very first record -will be read with the proper separator. To do this, use the special -@code{BEGIN} pattern -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}). -For example, here we set the value of @code{FS} to the string -@code{","}:@refill - -@smallexample -awk 'BEGIN @{ FS = "," @} ; @{ print $2 @}' -@end smallexample - -@noindent -Given the input line, - -@smallexample -John Q. Smith, 29 Oak St., Walamazoo, MI 42139 -@end smallexample - -@noindent -this @code{awk} program extracts the string @samp{@ 29 Oak St.}. - -@cindex field separator, choice of -@cindex regular expressions as field separators -Sometimes your input data will contain separator characters that don't -separate fields the way you thought they would. For instance, the -person's name in the example we've been using might have a title or -suffix attached, such as @samp{John Q. Smith, LXIX}. From input -containing such a name: - -@smallexample -John Q. Smith, LXIX, 29 Oak St., Walamazoo, MI 42139 -@end smallexample - -@noindent -the previous sample program would extract @samp{@ LXIX}, instead of -@samp{@ 29 Oak St.}. If you were expecting the program to print the -address, you would be surprised. So choose your data layout and -separator characters carefully to prevent such problems. - -As you know, by default, fields are separated by whitespace sequences -(spaces and tabs), not by single spaces: two spaces in a row do not -delimit an empty field. The default value of the field separator is a -string @w{@code{" "}} containing a single space. If this value were -interpreted in the usual way, each space character would separate -fields, so two spaces in a row would make an empty field between them. -The reason this does not happen is that a single space as the value of -@code{FS} is a special case: it is taken to specify the default manner -of delimiting fields. - -If @code{FS} is any other single character, such as @code{","}, then -each occurrence of that character separates two fields. Two consecutive -occurrences delimit an empty field. If the character occurs at the -beginning or the end of the line, that too delimits an empty field. The -space character is the only single character which does not follow these -rules. - -More generally, the value of @code{FS} may be a string containing any -regular expression. Then each match in the record for the regular -expression separates fields. For example, the assignment:@refill - -@smallexample -FS = ", \t" -@end smallexample - -@noindent -makes every area of an input line that consists of a comma followed by a -space and a tab, into a field separator. (@samp{\t} stands for a -tab.)@refill - -For a less trivial example of a regular expression, suppose you want -single spaces to separate fields the way single commas were used above. -You can set @code{FS} to @w{@code{"[@ ]"}}. This regular expression -matches a single space and nothing else. - -@c the following index entry is an overfull hbox. --mew 30jan1992 -@cindex field separator: on command line -@cindex command line, setting @code{FS} on -@code{FS} can be set on the command line. You use the @samp{-F} argument to -do so. For example: - -@smallexample -awk -F, '@var{program}' @var{input-files} -@end smallexample - -@noindent -sets @code{FS} to be the @samp{,} character. Notice that the argument uses -a capital @samp{F}. Contrast this with @samp{-f}, which specifies a file -containing an @code{awk} program. Case is significant in command options: -the @samp{-F} and @samp{-f} options have nothing to do with each other. -You can use both options at the same time to set the @code{FS} argument -@emph{and} get an @code{awk} program from a file.@refill - -@c begin expert info -The value used for the argument to @samp{-F} is processed in exactly the -same way as assignments to the built-in variable @code{FS}. This means that -if the field separator contains special characters, they must be escaped -appropriately. For example, to use a @samp{\} as the field separator, you -would have to type: - -@smallexample -# same as FS = "\\" -awk -F\\\\ '@dots{}' files @dots{} -@end smallexample - -@noindent -Since @samp{\} is used for quoting in the shell, @code{awk} will see -@samp{-F\\}. Then @code{awk} processes the @samp{\\} for escape -characters (@pxref{Constants, ,Constant Expressions}), finally yielding -a single @samp{\} to be used for the field separator. -@c end expert info - -As a special case, in compatibility mode -(@pxref{Command Line, ,Invoking @code{awk}}), if the -argument to @samp{-F} is @samp{t}, then @code{FS} is set to the tab -character. (This is because if you type @samp{-F\t}, without the quotes, -at the shell, the @samp{\} gets deleted, so @code{awk} figures that you -really want your fields to be separated with tabs, and not @samp{t}s. -Use @samp{-v FS="t"} on the command line if you really do want to separate -your fields with @samp{t}s.)@refill - -For example, let's use an @code{awk} program file called @file{baud.awk} -that contains the pattern @code{/300/}, and the action @samp{print $1}. -Here is the program: - -@smallexample -/300/ @{ print $1 @} -@end smallexample - -Let's also set @code{FS} to be the @samp{-} character, and run the -program on the file @file{BBS-list}. The following command prints a -list of the names of the bulletin boards that operate at 300 baud and -the first three digits of their phone numbers:@refill - -@smallexample -awk -F- -f baud.awk BBS-list -@end smallexample - -@noindent -It produces this output: - -@smallexample -aardvark 555 -alpo -barfly 555 -bites 555 -camelot 555 -core 555 -fooey 555 -foot 555 -macfoo 555 -sdace 555 -sabafoo 555 -@end smallexample - -@noindent -Note the second line of output. If you check the original file, you will -see that the second line looked like this: - -@smallexample -alpo-net 555-3412 2400/1200/300 A -@end smallexample - -The @samp{-} as part of the system's name was used as the field -separator, instead of the @samp{-} in the phone number that was -originally intended. This demonstrates why you have to be careful in -choosing your field and record separators. - -The following program searches the system password file, and prints -the entries for users who have no password: - -@smallexample -awk -F: '$2 == ""' /etc/passwd -@end smallexample - -@noindent -Here we use the @samp{-F} option on the command line to set the field -separator. Note that fields in @file{/etc/passwd} are separated by -colons. The second field represents a user's encrypted password, but if -the field is empty, that user has no password. - -@c begin expert info -According to the @sc{posix} standard, @code{awk} is supposed to behave -as if each record is split into fields at the time that it is read. -In particular, this means that you can change the value of @code{FS} -after a record is read, but before any of the fields are referenced. -The value of the fields (i.e. how they were split) should reflect the -old value of @code{FS}, not the new one. - -However, many implementations of @code{awk} do not do this. Instead, -they defer splitting the fields until a field reference actually happens, -using the @emph{current} value of @code{FS}! This behavior can be difficult -to diagnose. The following example illustrates the results of the two methods. -(The @code{sed} command prints just the first line of @file{/etc/passwd}.) - -@smallexample -sed 1q /etc/passwd | awk '@{ FS = ":" ; print $1 @}' -@end smallexample - -@noindent -will usually print - -@smallexample -root -@end smallexample - -@noindent -on an incorrect implementation of @code{awk}, while @code{gawk} -will print something like - -@smallexample -root:nSijPlPhZZwgE:0:0:Root:/: -@end smallexample -@c end expert info - -@c begin expert info -There is an important difference between the two cases of @samp{FS = @w{" "}} -(a single blank) and @samp{FS = @w{"[ \t]+"}} (which is a regular expression -matching one or more blanks or tabs). For both values of @code{FS}, fields -are separated by runs of blanks and/or tabs. However, when the value of -@code{FS} is @code{" "}, @code{awk} will strip leading and trailing whitespace -from the record, and then decide where the fields are. - -For example, the following expression prints @samp{b}: - -@smallexample -echo ' a b c d ' | awk '@{ print $2 @}' -@end smallexample - -@noindent -However, the following prints @samp{a}: - -@smallexample -echo ' a b c d ' | awk 'BEGIN @{ FS = "[ \t]+" @} ; @{ print $2 @}' -@end smallexample - -@noindent -In this case, the first field is null. - -The stripping of leading and trailing whitespace also comes into -play whenever @code{$0} is recomputed. For instance, this pipeline - -@smallexample -echo ' a b c d' | awk '@{ print; $2 = $2; print @}' -@end smallexample - -@noindent -produces this output: - -@smallexample - a b c d -a b c d -@end smallexample - -@noindent -The first @code{print} statement prints the record as it was read, -with leading whitespace intact. The assignment to @code{$2} rebuilds -@code{$0} by concatenating @code{$1} through @code{$NF} together, -separated by the value of @code{OFS}. Since the leading whitespace -was ignored when finding @code{$1}, it is not part of the new @code{$0}. -Finally, the last @code{print} statement prints the new @code{$0}. -@c end expert info - -The following table summarizes how fields are split, based on the -value of @code{FS}. - -@table @code -@item FS == " " -Fields are separated by runs of whitespace. Leading and trailing -whitespace are ignored. This is the default. - -@item FS == @var{any single character} -Fields are separated by each occurrence of the character. Multiple -successive occurrences delimit empty fields, as do leading and -trailing occurrences. - -@item FS == @var{regexp} -Fields are separated by occurrences of characters that match @var{regexp}. -Leading and trailing matches of @var{regexp} delimit empty fields. -@end table - -@node Constant Size, Multiple Line, Field Separators, Reading Files -@section Reading Fixed-width Data - -(This section discusses an advanced, experimental feature. If you are -a novice @code{awk} user, you may wish to skip it on the first reading.) - -@code{gawk} 2.13 introduced a new facility for dealing with fixed-width fields -with no distinctive field separator. Data of this nature arises typically -in one of at least two ways: the input for old FORTRAN programs where -numbers are run together, and the output of programs that did not anticipate -the use of their output as input for other programs. - -An example of the latter is a table where all the columns are lined up by -the use of a variable number of spaces and @emph{empty fields are just -spaces}. Clearly, @code{awk}'s normal field splitting based on @code{FS} -will not work well in this case. (Although a portable @code{awk} program -can use a series of @code{substr} calls on @code{$0}, this is awkward and -inefficient for a large number of fields.)@refill - -The splitting of an input record into fixed-width fields is specified by -assigning a string containing space-separated numbers to the built-in -variable @code{FIELDWIDTHS}. Each number specifies the width of the field -@emph{including} columns between fields. If you want to ignore the columns -between fields, you can specify the width as a separate field that is -subsequently ignored. - -The following data is the output of the @code{w} utility. It is useful -to illustrate the use of @code{FIELDWIDTHS}. - -@smallexample - 10:06pm up 21 days, 14:04, 23 users -User tty login@ idle JCPU PCPU what -hzuo ttyV0 8:58pm 9 5 vi p24.tex -hzang ttyV3 6:37pm 50 -csh -eklye ttyV5 9:53pm 7 1 em thes.tex -dportein ttyV6 8:17pm 1:47 -csh -gierd ttyD3 10:00pm 1 elm -dave ttyD4 9:47pm 4 4 w -brent ttyp0 26Jun91 4:46 26:46 4:41 bash -dave ttyq4 26Jun9115days 46 46 wnewmail -@end smallexample - -The following program takes the above input, converts the idle time to -number of seconds and prints out the first two fields and the calculated -idle time. (This program uses a number of @code{awk} features that -haven't been introduced yet.)@refill - -@smallexample -BEGIN @{ FIELDWIDTHS = "9 6 10 6 7 7 35" @} -NR > 2 @{ - idle = $4 - sub(/^ */, "", idle) # strip leading spaces - if (idle == "") idle = 0 - if (idle ~ /:/) @{ split(idle, t, ":"); idle = t[1] * 60 + t[2] @} - if (idle ~ /days/) @{ idle *= 24 * 60 * 60 @} - - print $1, $2, idle -@} -@end smallexample - -Here is the result of running the program on the data: - -@smallexample -hzuo ttyV0 0 -hzang ttyV3 50 -eklye ttyV5 0 -dportein ttyV6 107 -gierd ttyD3 1 -dave ttyD4 0 -brent ttyp0 286 -dave ttyq4 1296000 -@end smallexample - -Another (possibly more practical) example of fixed-width input data -would be the input from a deck of balloting cards. In some parts of -the United States, voters make their choices by punching holes in computer -cards. These cards are then processed to count the votes for any particular -candidate or on any particular issue. Since a voter may choose not to -vote on some issue, any column on the card may be empty. An @code{awk} -program for processing such data could use the @code{FIELDWIDTHS} feature -to simplify reading the data.@refill - -@c of course, getting gawk to run on a system with card readers is -@c another story! - -This feature is still experimental, and will likely evolve over time. - -@node Multiple Line, Getline, Constant Size, Reading Files -@section Multiple-Line Records - -@cindex multiple line records -@cindex input, multiple line records -@cindex reading files, multiple line records -@cindex records, multiple line -In some data bases, a single line cannot conveniently hold all the -information in one entry. In such cases, you can use multi-line -records. - -The first step in doing this is to choose your data format: when records -are not defined as single lines, how do you want to define them? -What should separate records? - -One technique is to use an unusual character or string to separate -records. For example, you could use the formfeed character (written -@code{\f} in @code{awk}, as in C) to separate them, making each record -a page of the file. To do this, just set the variable @code{RS} to -@code{"\f"} (a string containing the formfeed character). Any -other character could equally well be used, as long as it won't be part -of the data in a record.@refill - -@ignore -Another technique is to have blank lines separate records. The string -@code{"^\n+"} is a regular expression that matches any sequence of -newlines starting at the beginning of a line---in other words, it -matches a sequence of blank lines. If you set @code{RS} to this string, -a record always ends at the first blank line encountered. In -addition, a regular expression always matches the longest possible -sequence when there is a choice. So the next record doesn't start until -the first nonblank line that follows---no matter how many blank lines -appear in a row, they are considered one record-separator. -@end ignore - -Another technique is to have blank lines separate records. By a special -dispensation, a null string as the value of @code{RS} indicates that -records are separated by one or more blank lines. If you set @code{RS} -to the null string, a record always ends at the first blank line -encountered. And the next record doesn't start until the first nonblank -line that follows---no matter how many blank lines appear in a row, they -are considered one record-separator. (End of file is also considered -a record separator.)@refill -@c !!! This use of `end of file' is confusing. Needs to be clarified. - -The second step is to separate the fields in the record. One way to do -this is to put each field on a separate line: to do this, just set the -variable @code{FS} to the string @code{"\n"}. (This simple regular -expression matches a single newline.) - -Another way to separate fields is to divide each of the lines into fields -in the normal manner. This happens by default as a result of a special -feature: when @code{RS} is set to the null string, the newline character -@emph{always} acts as a field separator. This is in addition to whatever -field separations result from @code{FS}. - -The original motivation for this special exception was probably so that -you get useful behavior in the default case (i.e., @w{@code{FS == " "}}). -This feature can be a problem if you really don't want the -newline character to separate fields, since there is no way to -prevent it. However, you can work around this by using the @code{split} -function to break up the record manually -(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill - -@ignore -Here are two ways to use records separated by blank lines and break each -line into fields normally: - -@example -awk 'BEGIN @{ RS = ""; FS = "[ \t\n]+" @} @{ print $1 @}' BBS-list - -@exdent @r{or} - -awk 'BEGIN @{ RS = "^\n+"; FS = "[ \t\n]+" @} @{ print $1 @}' BBS-list -@end example -@end ignore - -@ignore -Here is how to use records separated by blank lines and break each -line into fields normally: - -@example -awk 'BEGIN @{ RS = ""; FS = "[ \t\n]+" @} ; @{ print $1 @}' BBS-list -@end example -@end ignore - -@node Getline, Close Input, Multiple Line, Reading Files -@section Explicit Input with @code{getline} - -@findex getline -@cindex input, explicit -@cindex explicit input -@cindex input, @code{getline} command -@cindex reading files, @code{getline} command -So far we have been getting our input files from @code{awk}'s main -input stream---either the standard input (usually your terminal) or the -files specified on the command line. The @code{awk} language has a -special built-in command called @code{getline} that -can be used to read input under your explicit control.@refill - -This command is quite complex and should @emph{not} be used by -beginners. It is covered here because this is the chapter on input. -The examples that follow the explanation of the @code{getline} command -include material that has not been covered yet. Therefore, come back -and study the @code{getline} command @emph{after} you have reviewed the -rest of this manual and have a good knowledge of how @code{awk} works. - -@vindex ERRNO -@cindex differences: @code{gawk} and @code{awk} -@code{getline} returns 1 if it finds a record, and 0 if the end of the -file is encountered. If there is some error in getting a record, such -as a file that cannot be opened, then @code{getline} returns @minus{}1. -In this case, @code{gawk} sets the variable @code{ERRNO} to a string -describing the error that occurred. - -In the following examples, @var{command} stands for a string value that -represents a shell command. - -@table @code -@item getline -The @code{getline} command can be used without arguments to read input -from the current input file. All it does in this case is read the next -input record and split it up into fields. This is useful if you've -finished processing the current record, but you want to do some special -processing @emph{right now} on the next record. Here's an -example:@refill - -@example -awk '@{ - if (t = index($0, "/*")) @{ - if (t > 1) - tmp = substr($0, 1, t - 1) - else - tmp = "" - u = index(substr($0, t + 2), "*/") - while (u == 0) @{ - getline - t = -1 - u = index($0, "*/") - @} - if (u <= length($0) - 2) - $0 = tmp substr($0, t + u + 3) - else - $0 = tmp - @} - print $0 -@}' -@end example - -This @code{awk} program deletes all C-style comments, @samp{/* @dots{} -*/}, from the input. By replacing the @samp{print $0} with other -statements, you could perform more complicated processing on the -decommented input, like searching for matches of a regular -expression. (This program has a subtle problem---can you spot it?) - -@c the program to remove comments doesn't work if one -@c comment ends and another begins on the same line. (Your -@c idea for restart would be useful here). --- brennan@boeing.com - -This form of the @code{getline} command sets @code{NF} (the number of -fields; @pxref{Fields, ,Examining Fields}), @code{NR} (the number of -records read so far; @pxref{Records, ,How Input is Split into Records}), -@code{FNR} (the number of records read from this input file), and the -value of @code{$0}. - -@strong{Note:} the new value of @code{$0} is used in testing -the patterns of any subsequent rules. The original value -of @code{$0} that triggered the rule which executed @code{getline} -is lost. By contrast, the @code{next} statement reads a new record -but immediately begins processing it normally, starting with the first -rule in the program. @xref{Next Statement, ,The @code{next} Statement}. - -@item getline @var{var} -This form of @code{getline} reads a record into the variable @var{var}. -This is useful when you want your program to read the next record from -the current input file, but you don't want to subject the record to the -normal input processing. - -For example, suppose the next line is a comment, or a special string, -and you want to read it, but you must make certain that it won't trigger -any rules. This version of @code{getline} allows you to read that line -and store it in a variable so that the main -read-a-line-and-check-each-rule loop of @code{awk} never sees it. - -The following example swaps every two lines of input. For example, given: - -@example -wan -tew -free -phore -@end example - -@noindent -it outputs: - -@example -tew -wan -phore -free -@end example - -@noindent -Here's the program: - -@example -@group -awk '@{ - if ((getline tmp) > 0) @{ - print tmp - print $0 - @} else - print $0 -@}' -@end group -@end example - -The @code{getline} function used in this way sets only the variables -@code{NR} and @code{FNR} (and of course, @var{var}). The record is not -split into fields, so the values of the fields (including @code{$0}) and -the value of @code{NF} do not change.@refill - -@item getline < @var{file} -@cindex input redirection -@cindex redirection of input -This form of the @code{getline} function takes its input from the file -@var{file}. Here @var{file} is a string-valued expression that -specifies the file name. @samp{< @var{file}} is called a @dfn{redirection} -since it directs input to come from a different place. - -This form is useful if you want to read your input from a particular -file, instead of from the main input stream. For example, the following -program reads its input record from the file @file{foo.input} when it -encounters a first field with a value equal to 10 in the current input -file.@refill - -@example -awk '@{ - if ($1 == 10) @{ - getline < "foo.input" - print - @} else - print -@}' -@end example - -Since the main input stream is not used, the values of @code{NR} and -@code{FNR} are not changed. But the record read is split into fields in -the normal manner, so the values of @code{$0} and other fields are -changed. So is the value of @code{NF}. - -This does not cause the record to be tested against all the patterns -in the @code{awk} program, in the way that would happen if the record -were read normally by the main processing loop of @code{awk}. However -the new record is tested against any subsequent rules, just as when -@code{getline} is used without a redirection. - -@item getline @var{var} < @var{file} -This form of the @code{getline} function takes its input from the file -@var{file} and puts it in the variable @var{var}. As above, @var{file} -is a string-valued expression that specifies the file from which to read. - -In this version of @code{getline}, none of the built-in variables are -changed, and the record is not split into fields. The only variable -changed is @var{var}. - -For example, the following program copies all the input files to the -output, except for records that say @w{@samp{@@include @var{filename}}}. -Such a record is replaced by the contents of the file -@var{filename}.@refill - -@example -awk '@{ - if (NF == 2 && $1 == "@@include") @{ - while ((getline line < $2) > 0) - print line - close($2) - @} else - print -@}' -@end example - -Note here how the name of the extra input file is not built into -the program; it is taken from the data, from the second field on -the @samp{@@include} line.@refill - -The @code{close} function is called to ensure that if two identical -@samp{@@include} lines appear in the input, the entire specified file is -included twice. @xref{Close Input, ,Closing Input Files and Pipes}.@refill - -One deficiency of this program is that it does not process nested -@samp{@@include} statements the way a true macro preprocessor would. - -@item @var{command} | getline -You can @dfn{pipe} the output of a command into @code{getline}. A pipe is -simply a way to link the output of one program to the input of another. In -this case, the string @var{command} is run as a shell command and its output -is piped into @code{awk} to be used as input. This form of @code{getline} -reads one record from the pipe. - -For example, the following program copies input to output, except for lines -that begin with @samp{@@execute}, which are replaced by the output produced by -running the rest of the line as a shell command: - -@example -awk '@{ - if ($1 == "@@execute") @{ - tmp = substr($0, 10) - while ((tmp | getline) > 0) - print - close(tmp) - @} else - print -@}' -@end example - -@noindent -The @code{close} function is called to ensure that if two identical -@samp{@@execute} lines appear in the input, the command is run for -each one. @xref{Close Input, ,Closing Input Files and Pipes}. - -Given the input: - -@example -foo -bar -baz -@@execute who -bletch -@end example - -@noindent -the program might produce: - -@example -foo -bar -baz -hack ttyv0 Jul 13 14:22 -hack ttyp0 Jul 13 14:23 (gnu:0) -hack ttyp1 Jul 13 14:23 (gnu:0) -hack ttyp2 Jul 13 14:23 (gnu:0) -hack ttyp3 Jul 13 14:23 (gnu:0) -bletch -@end example - -@noindent -Notice that this program ran the command @code{who} and printed the result. -(If you try this program yourself, you will get different results, showing -you who is logged in on your system.) - -This variation of @code{getline} splits the record into fields, sets the -value of @code{NF} and recomputes the value of @code{$0}. The values of -@code{NR} and @code{FNR} are not changed. - -@item @var{command} | getline @var{var} -The output of the command @var{command} is sent through a pipe to -@code{getline} and into the variable @var{var}. For example, the -following program reads the current date and time into the variable -@code{current_time}, using the @code{date} utility, and then -prints it.@refill - -@example -awk 'BEGIN @{ - "date" | getline current_time - close("date") - print "Report printed on " current_time -@}' -@end example - -In this version of @code{getline}, none of the built-in variables are -changed, and the record is not split into fields. -@end table - -@node Close Input, , Getline, Reading Files -@section Closing Input Files and Pipes -@cindex closing input files and pipes -@findex close - -If the same file name or the same shell command is used with -@code{getline} more than once during the execution of an @code{awk} -program, the file is opened (or the command is executed) only the first time. -At that time, the first record of input is read from that file or command. -The next time the same file or command is used in @code{getline}, another -record is read from it, and so on. - -This implies that if you want to start reading the same file again from -the beginning, or if you want to rerun a shell command (rather than -reading more output from the command), you must take special steps. -What you must do is use the @code{close} function, as follows: - -@example -close(@var{filename}) -@end example - -@noindent -or - -@example -close(@var{command}) -@end example - -The argument @var{filename} or @var{command} can be any expression. Its -value must exactly equal the string that was used to open the file or -start the command---for example, if you open a pipe with this: - -@example -"sort -r names" | getline foo -@end example - -@noindent -then you must close it with this: - -@example -close("sort -r names") -@end example - -Once this function call is executed, the next @code{getline} from that -file or command will reopen the file or rerun the command. - -@iftex -@vindex ERRNO -@cindex differences: @code{gawk} and @code{awk} -@end iftex -@code{close} returns a value of zero if the close succeeded. -Otherwise, the value will be non-zero. -In this case, @code{gawk} sets the variable @code{ERRNO} to a string -describing the error that occurred. - -@node Printing, One-liners, Reading Files, Top -@chapter Printing Output - -@cindex printing -@cindex output -One of the most common things that actions do is to output or @dfn{print} -some or all of the input. For simple output, use the @code{print} -statement. For fancier formatting use the @code{printf} statement. -Both are described in this chapter. - -@menu -* Print:: The @code{print} statement. -* Print Examples:: Simple examples of @code{print} statements. -* Output Separators:: The output separators and how to change them. -* OFMT:: Controlling Numeric Output With @code{print}. -* Printf:: The @code{printf} statement. -* Redirection:: How to redirect output to multiple - files and pipes. -* Special Files:: File name interpretation in @code{gawk}. - @code{gawk} allows access to - inherited file descriptors. -@end menu - -@node Print, Print Examples, Printing, Printing -@section The @code{print} Statement -@cindex @code{print} statement - -The @code{print} statement does output with simple, standardized -formatting. You specify only the strings or numbers to be printed, in a -list separated by commas. They are output, separated by single spaces, -followed by a newline. The statement looks like this: - -@example -print @var{item1}, @var{item2}, @dots{} -@end example - -@noindent -The entire list of items may optionally be enclosed in parentheses. The -parentheses are necessary if any of the item expressions uses a -relational operator; otherwise it could be confused with a redirection -(@pxref{Redirection, ,Redirecting Output of @code{print} and @code{printf}}). -The relational operators are @samp{==}, -@samp{!=}, @samp{<}, @samp{>}, @samp{>=}, @samp{<=}, @samp{~} and -@samp{!~} (@pxref{Comparison Ops, ,Comparison Expressions}).@refill - -The items printed can be constant strings or numbers, fields of the -current record (such as @code{$1}), variables, or any @code{awk} -expressions. The @code{print} statement is completely general for -computing @emph{what} values to print. With two exceptions, -you cannot specify @emph{how} to print them---how many -columns, whether to use exponential notation or not, and so on. -(@xref{Output Separators}, and -@ref{OFMT, ,Controlling Numeric Output with @code{print}}.) -For that, you need the @code{printf} statement -(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}).@refill - -The simple statement @samp{print} with no items is equivalent to -@samp{print $0}: it prints the entire current record. To print a blank -line, use @samp{print ""}, where @code{""} is the null, or empty, -string. - -To print a fixed piece of text, use a string constant such as -@w{@code{"Hello there"}} as one item. If you forget to use the -double-quote characters, your text will be taken as an @code{awk} -expression, and you will probably get an error. Keep in mind that a -space is printed between any two items. - -Most often, each @code{print} statement makes one line of output. But it -isn't limited to one line. If an item value is a string that contains a -newline, the newline is output along with the rest of the string. A -single @code{print} can make any number of lines this way. - -@node Print Examples, Output Separators, Print, Printing -@section Examples of @code{print} Statements - -Here is an example of printing a string that contains embedded newlines: - -@example -awk 'BEGIN @{ print "line one\nline two\nline three" @}' -@end example - -@noindent -produces output like this: - -@example -line one -line two -line three -@end example - -Here is an example that prints the first two fields of each input record, -with a space between them: - -@example -awk '@{ print $1, $2 @}' inventory-shipped -@end example - -@noindent -Its output looks like this: - -@example -Jan 13 -Feb 15 -Mar 15 -@dots{} -@end example - -A common mistake in using the @code{print} statement is to omit the comma -between two items. This often has the effect of making the items run -together in the output, with no space. The reason for this is that -juxtaposing two string expressions in @code{awk} means to concatenate -them. For example, without the comma: - -@example -awk '@{ print $1 $2 @}' inventory-shipped -@end example - -@noindent -prints: - -@example -@group -Jan13 -Feb15 -Mar15 -@dots{} -@end group -@end example - -Neither example's output makes much sense to someone unfamiliar with the -file @file{inventory-shipped}. A heading line at the beginning would make -it clearer. Let's add some headings to our table of months (@code{$1}) and -green crates shipped (@code{$2}). We do this using the @code{BEGIN} pattern -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}) to force the headings to be printed only once: - -@example -awk 'BEGIN @{ print "Month Crates" - print "----- ------" @} - @{ print $1, $2 @}' inventory-shipped -@end example - -@noindent -Did you already guess what happens? This program prints the following: - -@example -@group -Month Crates ------ ------ -Jan 13 -Feb 15 -Mar 15 -@dots{} -@end group -@end example - -@noindent -The headings and the table data don't line up! We can fix this by printing -some spaces between the two fields: - -@example -awk 'BEGIN @{ print "Month Crates" - print "----- ------" @} - @{ print $1, " ", $2 @}' inventory-shipped -@end example - -You can imagine that this way of lining up columns can get pretty -complicated when you have many columns to fix. Counting spaces for two -or three columns can be simple, but more than this and you can get -``lost'' quite easily. This is why the @code{printf} statement was -created (@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}); -one of its specialties is lining up columns of data.@refill - -@node Output Separators, OFMT, Print Examples, Printing -@section Output Separators - -@cindex output field separator, @code{OFS} -@vindex OFS -@vindex ORS -@cindex output record separator, @code{ORS} -As mentioned previously, a @code{print} statement contains a list -of items, separated by commas. In the output, the items are normally -separated by single spaces. But they do not have to be spaces; a -single space is only the default. You can specify any string of -characters to use as the @dfn{output field separator} by setting the -built-in variable @code{OFS}. The initial value of this variable -is the string @w{@code{" "}}, that is, just a single space.@refill - -The output from an entire @code{print} statement is called an -@dfn{output record}. Each @code{print} statement outputs one output -record and then outputs a string called the @dfn{output record separator}. -The built-in variable @code{ORS} specifies this string. The initial -value of the variable is the string @code{"\n"} containing a newline -character; thus, normally each @code{print} statement makes a separate line. - -You can change how output fields and records are separated by assigning -new values to the variables @code{OFS} and/or @code{ORS}. The usual -place to do this is in the @code{BEGIN} rule -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}), so -that it happens before any input is processed. You may also do this -with assignments on the command line, before the names of your input -files.@refill - -The following example prints the first and second fields of each input -record separated by a semicolon, with a blank line added after each -line:@refill - -@example -@group -awk 'BEGIN @{ OFS = ";"; ORS = "\n\n" @} - @{ print $1, $2 @}' BBS-list -@end group -@end example - -If the value of @code{ORS} does not contain a newline, all your output -will be run together on a single line, unless you output newlines some -other way. - -@node OFMT, Printf, Output Separators, Printing -@section Controlling Numeric Output with @code{print} -@vindex OFMT -When you use the @code{print} statement to print numeric values, -@code{awk} internally converts the number to a string of characters, -and prints that string. @code{awk} uses the @code{sprintf} function -to do this conversion. For now, it suffices to say that the @code{sprintf} -function accepts a @dfn{format specification} that tells it how to format -numbers (or strings), and that there are a number of different ways that -numbers can be formatted. The different format specifications are discussed -more fully in -@ref{Printf, ,Using @code{printf} Statements for Fancier Printing}.@refill - -The built-in variable @code{OFMT} contains the default format specification -that @code{print} uses with @code{sprintf} when it wants to convert a -number to a string for printing. By supplying different format specifications -as the value of @code{OFMT}, you can change how @code{print} will print -your numbers. As a brief example: - -@example -@group -awk 'BEGIN @{ OFMT = "%d" # print numbers as integers - print 17.23 @}' -@end group -@end example - -@noindent -will print @samp{17}. - -@node Printf, Redirection, OFMT, Printing -@section Using @code{printf} Statements for Fancier Printing -@cindex formatted output -@cindex output, formatted - -If you want more precise control over the output format than -@code{print} gives you, use @code{printf}. With @code{printf} you can -specify the width to use for each item, and you can specify various -stylistic choices for numbers (such as what radix to use, whether to -print an exponent, whether to print a sign, and how many digits to print -after the decimal point). You do this by specifying a string, called -the @dfn{format string}, which controls how and where to print the other -arguments. - -@menu -* Basic Printf:: Syntax of the @code{printf} statement. -* Control Letters:: Format-control letters. -* Format Modifiers:: Format-specification modifiers. -* Printf Examples:: Several examples. -@end menu - -@node Basic Printf, Control Letters, Printf, Printf -@subsection Introduction to the @code{printf} Statement - -@cindex @code{printf} statement, syntax of -The @code{printf} statement looks like this:@refill - -@example -printf @var{format}, @var{item1}, @var{item2}, @dots{} -@end example - -@noindent -The entire list of arguments may optionally be enclosed in parentheses. The -parentheses are necessary if any of the item expressions uses a -relational operator; otherwise it could be confused with a redirection -(@pxref{Redirection, ,Redirecting Output of @code{print} and @code{printf}}). -The relational operators are @samp{==}, -@samp{!=}, @samp{<}, @samp{>}, @samp{>=}, @samp{<=}, @samp{~} and -@samp{!~} (@pxref{Comparison Ops, ,Comparison Expressions}).@refill - -@cindex format string -The difference between @code{printf} and @code{print} is the argument -@var{format}. This is an expression whose value is taken as a string; it -specifies how to output each of the other arguments. It is called -the @dfn{format string}. - -The format string is the same as in the @sc{ansi} C library function -@code{printf}. Most of @var{format} is text to be output verbatim. -Scattered among this text are @dfn{format specifiers}, one per item. -Each format specifier says to output the next item at that place in the -format.@refill - -The @code{printf} statement does not automatically append a newline to its -output. It outputs only what the format specifies. So if you want -a newline, you must include one in the format. The output separator -variables @code{OFS} and @code{ORS} have no effect on @code{printf} -statements.@refill - -@node Control Letters, Format Modifiers, Basic Printf, Printf -@subsection Format-Control Letters -@cindex @code{printf}, format-control characters -@cindex format specifier - -A format specifier starts with the character @samp{%} and ends with a -@dfn{format-control letter}; it tells the @code{printf} statement how -to output one item. (If you actually want to output a @samp{%}, write -@samp{%%}.) The format-control letter specifies what kind of value to -print. The rest of the format specifier is made up of optional -@dfn{modifiers} which are parameters such as the field width to use.@refill - -Here is a list of the format-control letters: - -@table @samp -@item c -This prints a number as an ASCII character. Thus, @samp{printf "%c", -65} outputs the letter @samp{A}. The output for a string value is -the first character of the string. - -@item d -This prints a decimal integer. - -@item i -This also prints a decimal integer. - -@item e -This prints a number in scientific (exponential) notation. -For example, - -@example -printf "%4.3e", 1950 -@end example - -@noindent -prints @samp{1.950e+03}, with a total of four significant figures of -which three follow the decimal point. The @samp{4.3} are @dfn{modifiers}, -discussed below. - -@item f -This prints a number in floating point notation. - -@item g -This prints a number in either scientific notation or floating point -notation, whichever uses fewer characters. -@ignore -From: gatech!ames!elroy!cit-vax!EQL.Caltech.Edu!rankin (Pat Rankin) - -In the description of printf formats (p.43), the information for %g -is incorrect (mainly, it's too much of an oversimplification). It's -wrong in the AWK book too, and in the gawk man page. I suggested to -David Trueman before 2.13 was released that the latter be revised, so -that it matched gawk's behavior (rather than trying to change gawk to -match the docs ;-). The documented description is nice and simple, but -it doesn't match the actual underlying behavior of %g in the various C -run-time libraries that gawk relies on. The precision value for g format -is different than for f and e formats, so it's inaccurate to say 'g' is -the shorter of 'e' or 'f'. For 'g', precision represents the number of -significant digits rather than the number of decimal places, and it has -special rules about how to format numbers with range between 10E-1 and -10E-4. All in all, it's pretty messy, and I had to add that clumsy -GFMT_WORKAROUND code because the VMS run-time library doesn't conform to -the ANSI-C specifications. -@end ignore - -@item o -This prints an unsigned octal integer. - -@item s -This prints a string. - -@item x -This prints an unsigned hexadecimal integer. - -@item X -This prints an unsigned hexadecimal integer. However, for the values 10 -through 15, it uses the letters @samp{A} through @samp{F} instead of -@samp{a} through @samp{f}. - -@item % -This isn't really a format-control letter, but it does have a meaning -when used after a @samp{%}: the sequence @samp{%%} outputs one -@samp{%}. It does not consume an argument. -@end table - -@node Format Modifiers, Printf Examples, Control Letters, Printf -@subsection Modifiers for @code{printf} Formats - -@cindex @code{printf}, modifiers -@cindex modifiers (in format specifiers) -A format specification can also include @dfn{modifiers} that can control -how much of the item's value is printed and how much space it gets. The -modifiers come between the @samp{%} and the format-control letter. Here -are the possible modifiers, in the order in which they may appear: - -@table @samp -@item - -The minus sign, used before the width modifier, says to left-justify -the argument within its specified width. Normally the argument -is printed right-justified in the specified width. Thus, - -@example -printf "%-4s", "foo" -@end example - -@noindent -prints @samp{foo }. - -@item @var{width} -This is a number representing the desired width of a field. Inserting any -number between the @samp{%} sign and the format control character forces the -field to be expanded to this width. The default way to do this is to -pad with spaces on the left. For example, - -@example -printf "%4s", "foo" -@end example - -@noindent -prints @samp{ foo}. - -The value of @var{width} is a minimum width, not a maximum. If the item -value requires more than @var{width} characters, it can be as wide as -necessary. Thus, - -@example -printf "%4s", "foobar" -@end example - -@noindent -prints @samp{foobar}. - -Preceding the @var{width} with a minus sign causes the output to be -padded with spaces on the right, instead of on the left. - -@item .@var{prec} -This is a number that specifies the precision to use when printing. -This specifies the number of digits you want printed to the right of the -decimal point. For a string, it specifies the maximum number of -characters from the string that should be printed. -@end table - -The C library @code{printf}'s dynamic @var{width} and @var{prec} -capability (for example, @code{"%*.*s"}) is supported. Instead of -supplying explicit @var{width} and/or @var{prec} values in the format -string, you pass them in the argument list. For example:@refill - -@example -w = 5 -p = 3 -s = "abcdefg" -printf "<%*.*s>\n", w, p, s -@end example - -@noindent -is exactly equivalent to - -@example -s = "abcdefg" -printf "<%5.3s>\n", s -@end example - -@noindent -Both programs output @samp{@w{<@bullet{}@bullet{}abc>}}. (We have -used the bullet symbol ``@bullet{}'' to represent a space, to clearly -show you that there are two spaces in the output.)@refill - -Earlier versions of @code{awk} did not support this capability. You may -simulate it by using concatenation to build up the format string, -like so:@refill - -@example -w = 5 -p = 3 -s = "abcdefg" -printf "<%" w "." p "s>\n", s -@end example - -@noindent -This is not particularly easy to read, however. - -@node Printf Examples, , Format Modifiers, Printf -@subsection Examples of Using @code{printf} - -Here is how to use @code{printf} to make an aligned table: - -@example -awk '@{ printf "%-10s %s\n", $1, $2 @}' BBS-list -@end example - -@noindent -prints the names of bulletin boards (@code{$1}) of the file -@file{BBS-list} as a string of 10 characters, left justified. It also -prints the phone numbers (@code{$2}) afterward on the line. This -produces an aligned two-column table of names and phone numbers:@refill - -@example -@group -aardvark 555-5553 -alpo-net 555-3412 -barfly 555-7685 -bites 555-1675 -camelot 555-0542 -core 555-2912 -fooey 555-1234 -foot 555-6699 -macfoo 555-6480 -sdace 555-3430 -sabafoo 555-2127 -@end group -@end example - -Did you notice that we did not specify that the phone numbers be printed -as numbers? They had to be printed as strings because the numbers are -separated by a dash. This dash would be interpreted as a minus sign if -we had tried to print the phone numbers as numbers. This would have led -to some pretty confusing results. - -We did not specify a width for the phone numbers because they are the -last things on their lines. We don't need to put spaces after them. - -We could make our table look even nicer by adding headings to the tops -of the columns. To do this, use the @code{BEGIN} pattern -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}) -to force the header to be printed only once, at the beginning of -the @code{awk} program:@refill - -@example -@group -awk 'BEGIN @{ print "Name Number" - print "---- ------" @} - @{ printf "%-10s %s\n", $1, $2 @}' BBS-list -@end group -@end example - -Did you notice that we mixed @code{print} and @code{printf} statements in -the above example? We could have used just @code{printf} statements to get -the same results: - -@example -@group -awk 'BEGIN @{ printf "%-10s %s\n", "Name", "Number" - printf "%-10s %s\n", "----", "------" @} - @{ printf "%-10s %s\n", $1, $2 @}' BBS-list -@end group -@end example - -@noindent -By outputting each column heading with the same format specification -used for the elements of the column, we have made sure that the headings -are aligned just like the columns. - -The fact that the same format specification is used three times can be -emphasized by storing it in a variable, like this: - -@example -awk 'BEGIN @{ format = "%-10s %s\n" - printf format, "Name", "Number" - printf format, "----", "------" @} - @{ printf format, $1, $2 @}' BBS-list -@end example - -See if you can use the @code{printf} statement to line up the headings and -table data for our @file{inventory-shipped} example covered earlier in the -section on the @code{print} statement -(@pxref{Print, ,The @code{print} Statement}).@refill - -@node Redirection, Special Files, Printf, Printing -@section Redirecting Output of @code{print} and @code{printf} - -@cindex output redirection -@cindex redirection of output -So far we have been dealing only with output that prints to the standard -output, usually your terminal. Both @code{print} and @code{printf} can -also send their output to other places. -This is called @dfn{redirection}.@refill - -A redirection appears after the @code{print} or @code{printf} statement. -Redirections in @code{awk} are written just like redirections in shell -commands, except that they are written inside the @code{awk} program. - -@menu -* File/Pipe Redirection:: Redirecting Output to Files and Pipes. -* Close Output:: How to close output files and pipes. -@end menu - -@node File/Pipe Redirection, Close Output, Redirection, Redirection -@subsection Redirecting Output to Files and Pipes - -Here are the three forms of output redirection. They are all shown for -the @code{print} statement, but they work identically for @code{printf} -also.@refill - -@table @code -@item print @var{items} > @var{output-file} -This type of redirection prints the items onto the output file -@var{output-file}. The file name @var{output-file} can be any -expression. Its value is changed to a string and then used as a -file name (@pxref{Expressions, ,Expressions as Action Statements}).@refill - -When this type of redirection is used, the @var{output-file} is erased -before the first output is written to it. Subsequent writes do not -erase @var{output-file}, but append to it. If @var{output-file} does -not exist, then it is created.@refill - -For example, here is how one @code{awk} program can write a list of -BBS names to a file @file{name-list} and a list of phone numbers to a -file @file{phone-list}. Each output file contains one name or number -per line. - -@smallexample -awk '@{ print $2 > "phone-list" - print $1 > "name-list" @}' BBS-list -@end smallexample - -@item print @var{items} >> @var{output-file} -This type of redirection prints the items onto the output file -@var{output-file}. The difference between this and the -single-@samp{>} redirection is that the old contents (if any) of -@var{output-file} are not erased. Instead, the @code{awk} output is -appended to the file. - -@cindex pipes for output -@cindex output, piping -@item print @var{items} | @var{command} -It is also possible to send output through a @dfn{pipe} instead of into a -file. This type of redirection opens a pipe to @var{command} and writes -the values of @var{items} through this pipe, to another process created -to execute @var{command}.@refill - -The redirection argument @var{command} is actually an @code{awk} -expression. Its value is converted to a string, whose contents give the -shell command to be run. - -For example, this produces two files, one unsorted list of BBS names -and one list sorted in reverse alphabetical order: - -@smallexample -awk '@{ print $1 > "names.unsorted" - print $1 | "sort -r > names.sorted" @}' BBS-list -@end smallexample - -Here the unsorted list is written with an ordinary redirection while -the sorted list is written by piping through the @code{sort} utility. - -Here is an example that uses redirection to mail a message to a mailing -list @samp{bug-system}. This might be useful when trouble is encountered -in an @code{awk} script run periodically for system maintenance. - -@smallexample -report = "mail bug-system" -print "Awk script failed:", $0 | report -print "at record number", FNR, "of", FILENAME | report -close(report) -@end smallexample - -We call the @code{close} function here because it's a good idea to close -the pipe as soon as all the intended output has been sent to it. -@xref{Close Output, ,Closing Output Files and Pipes}, for more information -on this. This example also illustrates the use of a variable to represent -a @var{file} or @var{command}: it is not necessary to always -use a string constant. Using a variable is generally a good idea, -since @code{awk} requires you to spell the string value identically -every time. -@end table - -Redirecting output using @samp{>}, @samp{>>}, or @samp{|} asks the system -to open a file or pipe only if the particular @var{file} or @var{command} -you've specified has not already been written to by your program, or if -it has been closed since it was last written to.@refill - -@node Close Output, , File/Pipe Redirection, Redirection -@subsection Closing Output Files and Pipes -@cindex closing output files and pipes -@findex close - -When a file or pipe is opened, the file name or command associated with -it is remembered by @code{awk} and subsequent writes to the same file or -command are appended to the previous writes. The file or pipe stays -open until @code{awk} exits. This is usually convenient. - -Sometimes there is a reason to close an output file or pipe earlier -than that. To do this, use the @code{close} function, as follows: - -@example -close(@var{filename}) -@end example - -@noindent -or - -@example -close(@var{command}) -@end example - -The argument @var{filename} or @var{command} can be any expression. -Its value must exactly equal the string used to open the file or pipe -to begin with---for example, if you open a pipe with this: - -@example -print $1 | "sort -r > names.sorted" -@end example - -@noindent -then you must close it with this: - -@example -close("sort -r > names.sorted") -@end example - -Here are some reasons why you might need to close an output file: - -@itemize @bullet -@item -To write a file and read it back later on in the same @code{awk} -program. Close the file when you are finished writing it; then -you can start reading it with @code{getline} -(@pxref{Getline, ,Explicit Input with @code{getline}}).@refill - -@item -To write numerous files, successively, in the same @code{awk} -program. If you don't close the files, eventually you may exceed a -system limit on the number of open files in one process. So close -each one when you are finished writing it. - -@item -To make a command finish. When you redirect output through a pipe, -the command reading the pipe normally continues to try to read input -as long as the pipe is open. Often this means the command cannot -really do its work until the pipe is closed. For example, if you -redirect output to the @code{mail} program, the message is not -actually sent until the pipe is closed. - -@item -To run the same program a second time, with the same arguments. -This is not the same thing as giving more input to the first run! - -For example, suppose you pipe output to the @code{mail} program. If you -output several lines redirected to this pipe without closing it, they make -a single message of several lines. By contrast, if you close the pipe -after each line of output, then each line makes a separate message. -@end itemize - -@iftex -@vindex ERRNO -@cindex differences: @code{gawk} and @code{awk} -@end iftex -@code{close} returns a value of zero if the close succeeded. -Otherwise, the value will be non-zero. -In this case, @code{gawk} sets the variable @code{ERRNO} to a string -describing the error that occurred. - -@node Special Files, , Redirection, Printing -@section Standard I/O Streams -@cindex standard input -@cindex standard output -@cindex standard error output -@cindex file descriptors - -Running programs conventionally have three input and output streams -already available to them for reading and writing. These are known as -the @dfn{standard input}, @dfn{standard output}, and @dfn{standard error -output}. These streams are, by default, terminal input and output, but -they are often redirected with the shell, via the @samp{<}, @samp{<<}, -@samp{>}, @samp{>>}, @samp{>&} and @samp{|} operators. Standard error -is used only for writing error messages; the reason we have two separate -streams, standard output and standard error, is so that they can be -redirected separately. - -@iftex -@cindex differences: @code{gawk} and @code{awk} -@end iftex -In other implementations of @code{awk}, the only way to write an error -message to standard error in an @code{awk} program is as follows: - -@smallexample -print "Serious error detected!\n" | "cat 1>&2" -@end smallexample - -@noindent -This works by opening a pipeline to a shell command which can access the -standard error stream which it inherits from the @code{awk} process. -This is far from elegant, and is also inefficient, since it requires a -separate process. So people writing @code{awk} programs have often -neglected to do this. Instead, they have sent the error messages to the -terminal, like this: - -@smallexample -@group -NF != 4 @{ - printf("line %d skipped: doesn't have 4 fields\n", FNR) > "/dev/tty" -@} -@end group -@end smallexample - -@noindent -This has the same effect most of the time, but not always: although the -standard error stream is usually the terminal, it can be redirected, and -when that happens, writing to the terminal is not correct. In fact, if -@code{awk} is run from a background job, it may not have a terminal at all. -Then opening @file{/dev/tty} will fail. - -@code{gawk} provides special file names for accessing the three standard -streams. When you redirect input or output in @code{gawk}, if the file name -matches one of these special names, then @code{gawk} directly uses the -stream it stands for. - -@cindex @file{/dev/stdin} -@cindex @file{/dev/stdout} -@cindex @file{/dev/stderr} -@cindex @file{/dev/fd/} -@table @file -@item /dev/stdin -The standard input (file descriptor 0). - -@item /dev/stdout -The standard output (file descriptor 1). - -@item /dev/stderr -The standard error output (file descriptor 2). - -@item /dev/fd/@var{N} -The file associated with file descriptor @var{N}. Such a file must have -been opened by the program initiating the @code{awk} execution (typically -the shell). Unless you take special pains, only descriptors 0, 1 and 2 -are available. -@end table - -The file names @file{/dev/stdin}, @file{/dev/stdout}, and @file{/dev/stderr} -are aliases for @file{/dev/fd/0}, @file{/dev/fd/1}, and @file{/dev/fd/2}, -respectively, but they are more self-explanatory. - -The proper way to write an error message in a @code{gawk} program -is to use @file{/dev/stderr}, like this: - -@smallexample -NF != 4 @{ - printf("line %d skipped: doesn't have 4 fields\n", FNR) > "/dev/stderr" -@} -@end smallexample - -@code{gawk} also provides special file names that give access to information -about the running @code{gawk} process. Each of these ``files'' provides -a single record of information. To read them more than once, you must -first close them with the @code{close} function -(@pxref{Close Input, ,Closing Input Files and Pipes}). -The filenames are: - -@cindex @file{/dev/pid} -@cindex @file{/dev/pgrpid} -@cindex @file{/dev/ppid} -@cindex @file{/dev/user} -@table @file -@item /dev/pid -Reading this file returns the process ID of the current process, -in decimal, terminated with a newline. - -@item /dev/ppid -Reading this file returns the parent process ID of the current process, -in decimal, terminated with a newline. - -@item /dev/pgrpid -Reading this file returns the process group ID of the current process, -in decimal, terminated with a newline. - -@item /dev/user -Reading this file returns a single record terminated with a newline. -The fields are separated with blanks. The fields represent the -following information: - -@table @code -@item $1 -The value of the @code{getuid} system call. - -@item $2 -The value of the @code{geteuid} system call. - -@item $3 -The value of the @code{getgid} system call. - -@item $4 -The value of the @code{getegid} system call. -@end table - -If there are any additional fields, they are the group IDs returned by -@code{getgroups} system call. -(Multiple groups may not be supported on all systems.)@refill -@end table - -These special file names may be used on the command line as data -files, as well as for I/O redirections within an @code{awk} program. -They may not be used as source files with the @samp{-f} option. - -Recognition of these special file names is disabled if @code{gawk} is in -compatibility mode (@pxref{Command Line, ,Invoking @code{awk}}). - -@quotation -@strong{Caution}: Unless your system actually has a @file{/dev/fd} directory -(or any of the other above listed special files), -the interpretation of these file names is done by @code{gawk} itself. -For example, using @samp{/dev/fd/4} for output will actually write on -file descriptor 4, and not on a new file descriptor that was @code{dup}'ed -from file descriptor 4. Most of the time this does not matter; however, it -is important to @emph{not} close any of the files related to file descriptors -0, 1, and 2. If you do close one of these files, unpredictable behavior -will result. -@end quotation - -@node One-liners, Patterns, Printing, Top -@chapter Useful ``One-liners'' - -@cindex one-liners -Useful @code{awk} programs are often short, just a line or two. Here is a -collection of useful, short programs to get you started. Some of these -programs contain constructs that haven't been covered yet. The description -of the program will give you a good idea of what is going on, but please -read the rest of the manual to become an @code{awk} expert! - -@c Per suggestions from Michal Jaegermann -@ifinfo -Since you are reading this in Info, each line of the example code is -enclosed in quotes, to represent text that you would type literally. -The examples themselves represent shell commands that use single quotes -to keep the shell from interpreting the contents of the program. -When reading the examples, focus on the text between the open and close -quotes. -@end ifinfo - -@table @code -@item awk '@{ if (NF > max) max = NF @} -@itemx @ @ @ @ @ END @{ print max @}' -This program prints the maximum number of fields on any input line. - -@item awk 'length($0) > 80' -This program prints every line longer than 80 characters. The sole -rule has a relational expression as its pattern, and has no action (so the -default action, printing the record, is used). - -@item awk 'NF > 0' -This program prints every line that has at least one field. This is an -easy way to delete blank lines from a file (or rather, to create a new -file similar to the old file but from which the blank lines have been -deleted). - -@item awk '@{ if (NF > 0) print @}' -This program also prints every line that has at least one field. Here we -allow the rule to match every line, then decide in the action whether -to print. - -@item awk@ 'BEGIN@ @{@ for (i = 1; i <= 7; i++) -@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ print int(101 * rand()) @}' -This program prints 7 random numbers from 0 to 100, inclusive. - -@item ls -l @var{files} | awk '@{ x += $4 @} ; END @{ print "total bytes: " x @}' -This program prints the total number of bytes used by @var{files}. - -@item expand@ @var{file}@ |@ awk@ '@{ if (x < length()) x = length() @} -@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ END @{ print "maximum line length is " x @}' -This program prints the maximum line length of @var{file}. The input -is piped through the @code{expand} program to change tabs into spaces, -so the widths compared are actually the right-margin columns. - -@item awk 'BEGIN @{ FS = ":" @} -@itemx @ @ @ @ @ @{ print $1 | "sort" @}' /etc/passwd -This program prints a sorted list of the login names of all users. - -@item awk '@{ nlines++ @} -@itemx @ @ @ @ @ END@ @{ print nlines @}' -This programs counts lines in a file. - -@item awk 'END @{ print NR @}' -This program also counts lines in a file, but lets @code{awk} do the work. - -@item awk '@{ print NR, $0 @}' -This program adds line numbers to all its input files, -similar to @samp{cat -n}. -@end table - -@node Patterns, Actions, One-liners, Top -@chapter Patterns -@cindex pattern, definition of - -Patterns in @code{awk} control the execution of rules: a rule is -executed when its pattern matches the current input record. This -chapter tells all about how to write patterns. - -@menu -* Kinds of Patterns:: A list of all kinds of patterns. - The following subsections describe - them in detail. -* Regexp:: Regular expressions such as @samp{/foo/}. -* Comparison Patterns:: Comparison expressions such as @code{$1 > 10}. -* Boolean Patterns:: Combining comparison expressions. -* Expression Patterns:: Any expression can be used as a pattern. -* Ranges:: Pairs of patterns specify record ranges. -* BEGIN/END:: Specifying initialization and cleanup rules. -* Empty:: The empty pattern, which matches every record. -@end menu - -@node Kinds of Patterns, Regexp, Patterns, Patterns -@section Kinds of Patterns -@cindex patterns, types of - -Here is a summary of the types of patterns supported in @code{awk}. -@c At the next rewrite, check to see that this order matches the -@c order in the text. It might not matter to a reader, but it's good -@c style. Also, it might be nice to mention all the topics of sections -@c that follow in this list; that way people can scan and know when to -@c expect a specific topic. Specifically please also make an entry -@c for Boolean operators as patterns in the right place. --mew - -@table @code -@item /@var{regular expression}/ -A regular expression as a pattern. It matches when the text of the -input record fits the regular expression. -(@xref{Regexp, ,Regular Expressions as Patterns}.)@refill - -@item @var{expression} -A single expression. It matches when its value, converted to a number, -is nonzero (if a number) or nonnull (if a string). -(@xref{Expression Patterns, ,Expressions as Patterns}.)@refill - -@item @var{pat1}, @var{pat2} -A pair of patterns separated by a comma, specifying a range of records. -(@xref{Ranges, ,Specifying Record Ranges with Patterns}.) - -@item BEGIN -@itemx END -Special patterns to supply start-up or clean-up information to -@code{awk}. (@xref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}.) - -@item @var{null} -The empty pattern matches every input record. -(@xref{Empty, ,The Empty Pattern}.)@refill -@end table - - -@node Regexp, Comparison Patterns, Kinds of Patterns, Patterns -@section Regular Expressions as Patterns -@cindex pattern, regular expressions -@cindex regexp -@cindex regular expressions as patterns - -A @dfn{regular expression}, or @dfn{regexp}, is a way of describing a -class of strings. A regular expression enclosed in slashes (@samp{/}) -is an @code{awk} pattern that matches every input record whose text -belongs to that class. - -The simplest regular expression is a sequence of letters, numbers, or -both. Such a regexp matches any string that contains that sequence. -Thus, the regexp @samp{foo} matches any string containing @samp{foo}. -Therefore, the pattern @code{/foo/} matches any input record containing -@samp{foo}. Other kinds of regexps let you specify more complicated -classes of strings. - -@menu -* Regexp Usage:: How to Use Regular Expressions -* Regexp Operators:: Regular Expression Operators -* Case-sensitivity:: How to do case-insensitive matching. -@end menu - -@node Regexp Usage, Regexp Operators, Regexp, Regexp -@subsection How to Use Regular Expressions - -A regular expression can be used as a pattern by enclosing it in -slashes. Then the regular expression is matched against the -entire text of each record. (Normally, it only needs -to match some part of the text in order to succeed.) For example, this -prints the second field of each record that contains @samp{foo} anywhere: - -@example -awk '/foo/ @{ print $2 @}' BBS-list -@end example - -@cindex regular expression matching operators -@cindex string-matching operators -@cindex operators, string-matching -@cindex operators, regexp matching -@cindex regexp search operators -Regular expressions can also be used in comparison expressions. Then -you can specify the string to match against; it need not be the entire -current input record. These comparison expressions can be used as -patterns or in @code{if}, @code{while}, @code{for}, and @code{do} statements. - -@table @code -@item @var{exp} ~ /@var{regexp}/ -This is true if the expression @var{exp} (taken as a character string) -is matched by @var{regexp}. The following example matches, or selects, -all input records with the upper-case letter @samp{J} somewhere in the -first field:@refill - -@example -awk '$1 ~ /J/' inventory-shipped -@end example - -So does this: - -@example -awk '@{ if ($1 ~ /J/) print @}' inventory-shipped -@end example - -@item @var{exp} !~ /@var{regexp}/ -This is true if the expression @var{exp} (taken as a character string) -is @emph{not} matched by @var{regexp}. The following example matches, -or selects, all input records whose first field @emph{does not} contain -the upper-case letter @samp{J}:@refill - -@example -awk '$1 !~ /J/' inventory-shipped -@end example -@end table - -@cindex computed regular expressions -@cindex regular expressions, computed -@cindex dynamic regular expressions -The right hand side of a @samp{~} or @samp{!~} operator need not be a -constant regexp (i.e., a string of characters between slashes). It may -be any expression. The expression is evaluated, and converted if -necessary to a string; the contents of the string are used as the -regexp. A regexp that is computed in this way is called a @dfn{dynamic -regexp}. For example: - -@example -identifier_regexp = "[A-Za-z_][A-Za-z_0-9]+" -$0 ~ identifier_regexp -@end example - -@noindent -sets @code{identifier_regexp} to a regexp that describes @code{awk} -variable names, and tests if the input record matches this regexp. - -@node Regexp Operators, Case-sensitivity, Regexp Usage, Regexp -@subsection Regular Expression Operators -@cindex metacharacters -@cindex regular expression metacharacters - -You can combine regular expressions with the following characters, -called @dfn{regular expression operators}, or @dfn{metacharacters}, to -increase the power and versatility of regular expressions. - -Here is a table of metacharacters. All characters not listed in the -table stand for themselves. - -@table @code -@item ^ -This matches the beginning of the string or the beginning of a line -within the string. For example: - -@example -^@@chapter -@end example - -@noindent -matches the @samp{@@chapter} at the beginning of a string, and can be used -to identify chapter beginnings in Texinfo source files. - -@item $ -This is similar to @samp{^}, but it matches only at the end of a string -or the end of a line within the string. For example: - -@example -p$ -@end example - -@noindent -matches a record that ends with a @samp{p}. - -@item . -This matches any single character except a newline. For example: - -@example -.P -@end example - -@noindent -matches any single character followed by a @samp{P} in a string. Using -concatenation we can make regular expressions like @samp{U.A}, which -matches any three-character sequence that begins with @samp{U} and ends -with @samp{A}. - -@item [@dots{}] -This is called a @dfn{character set}. It matches any one of the -characters that are enclosed in the square brackets. For example: - -@example -[MVX] -@end example - -@noindent -matches any one of the characters @samp{M}, @samp{V}, or @samp{X} in a -string.@refill - -Ranges of characters are indicated by using a hyphen between the beginning -and ending characters, and enclosing the whole thing in brackets. For -example:@refill - -@example -[0-9] -@end example - -@noindent -matches any digit. - -To include the character @samp{\}, @samp{]}, @samp{-} or @samp{^} in a -character set, put a @samp{\} in front of it. For example: - -@example -[d\]] -@end example - -@noindent -matches either @samp{d}, or @samp{]}.@refill - -This treatment of @samp{\} is compatible with other @code{awk} -implementations, and is also mandated by the @sc{posix} Command Language -and Utilities standard. The regular expressions in @code{awk} are a superset -of the @sc{posix} specification for Extended Regular Expressions (EREs). -@sc{posix} EREs are based on the regular expressions accepted by the -traditional @code{egrep} utility. - -In @code{egrep} syntax, backslash is not syntactically special within -square brackets. This means that special tricks have to be used to -represent the characters @samp{]}, @samp{-} and @samp{^} as members of a -character set. - -In @code{egrep} syntax, to match @samp{-}, write it as @samp{---}, -which is a range containing only @w{@samp{-}.} You may also give @samp{-} -as the first or last character in the set. To match @samp{^}, put it -anywhere except as the first character of a set. To match a @samp{]}, -make it the first character in the set. For example:@refill - -@example -[]d^] -@end example - -@noindent -matches either @samp{]}, @samp{d} or @samp{^}.@refill - -@item [^ @dots{}] -This is a @dfn{complemented character set}. The first character after -the @samp{[} @emph{must} be a @samp{^}. It matches any characters -@emph{except} those in the square brackets (or newline). For example: - -@example -[^0-9] -@end example - -@noindent -matches any character that is not a digit. - -@item | -This is the @dfn{alternation operator} and it is used to specify -alternatives. For example: - -@example -^P|[0-9] -@end example - -@noindent -matches any string that matches either @samp{^P} or @samp{[0-9]}. This -means it matches any string that contains a digit or starts with @samp{P}. - -The alternation applies to the largest possible regexps on either side. -@item (@dots{}) -Parentheses are used for grouping in regular expressions as in -arithmetic. They can be used to concatenate regular expressions -containing the alternation operator, @samp{|}. - -@item * -This symbol means that the preceding regular expression is to be -repeated as many times as possible to find a match. For example: - -@example -ph* -@end example - -@noindent -applies the @samp{*} symbol to the preceding @samp{h} and looks for matches -to one @samp{p} followed by any number of @samp{h}s. This will also match -just @samp{p} if no @samp{h}s are present. - -The @samp{*} repeats the @emph{smallest} possible preceding expression. -(Use parentheses if you wish to repeat a larger expression.) It finds -as many repetitions as possible. For example: - -@example -awk '/\(c[ad][ad]*r x\)/ @{ print @}' sample -@end example - -@noindent -prints every record in the input containing a string of the form -@samp{(car x)}, @samp{(cdr x)}, @samp{(cadr x)}, and so on.@refill - -@item + -This symbol is similar to @samp{*}, but the preceding expression must be -matched at least once. This means that: - -@example -wh+y -@end example - -@noindent -would match @samp{why} and @samp{whhy} but not @samp{wy}, whereas -@samp{wh*y} would match all three of these strings. This is a simpler -way of writing the last @samp{*} example: - -@example -awk '/\(c[ad]+r x\)/ @{ print @}' sample -@end example - -@item ? -This symbol is similar to @samp{*}, but the preceding expression can be -matched once or not at all. For example: - -@example -fe?d -@end example - -@noindent -will match @samp{fed} and @samp{fd}, but nothing else.@refill - -@item \ -This is used to suppress the special meaning of a character when -matching. For example: - -@example -\$ -@end example - -@noindent -matches the character @samp{$}. - -The escape sequences used for string constants -(@pxref{Constants, ,Constant Expressions}) are -valid in regular expressions as well; they are also introduced by a -@samp{\}.@refill -@end table - -In regular expressions, the @samp{*}, @samp{+}, and @samp{?} operators have -the highest precedence, followed by concatenation, and finally by @samp{|}. -As in arithmetic, parentheses can change how operators are grouped.@refill - -@node Case-sensitivity, , Regexp Operators, Regexp -@subsection Case-sensitivity in Matching - -Case is normally significant in regular expressions, both when matching -ordinary characters (i.e., not metacharacters), and inside character -sets. Thus a @samp{w} in a regular expression matches only a lower case -@samp{w} and not an upper case @samp{W}. - -The simplest way to do a case-independent match is to use a character -set: @samp{[Ww]}. However, this can be cumbersome if you need to use it -often; and it can make the regular expressions harder for humans to -read. There are two other alternatives that you might prefer. - -One way to do a case-insensitive match at a particular point in the -program is to convert the data to a single case, using the -@code{tolower} or @code{toupper} built-in string functions (which we -haven't discussed yet; -@pxref{String Functions, ,Built-in Functions for String Manipulation}). -For example:@refill - -@example -tolower($1) ~ /foo/ @{ @dots{} @} -@end example - -@noindent -converts the first field to lower case before matching against it. - -Another method is to set the variable @code{IGNORECASE} to a nonzero -value (@pxref{Built-in Variables}). When @code{IGNORECASE} is not zero, -@emph{all} regexp operations ignore case. Changing the value of -@code{IGNORECASE} dynamically controls the case sensitivity of your -program as it runs. Case is significant by default because -@code{IGNORECASE} (like most variables) is initialized to zero. - -@example -x = "aB" -if (x ~ /ab/) @dots{} # this test will fail - -IGNORECASE = 1 -if (x ~ /ab/) @dots{} # now it will succeed -@end example - -In general, you cannot use @code{IGNORECASE} to make certain rules -case-insensitive and other rules case-sensitive, because there is no way -to set @code{IGNORECASE} just for the pattern of a particular rule. To -do this, you must use character sets or @code{tolower}. However, one -thing you can do only with @code{IGNORECASE} is turn case-sensitivity on -or off dynamically for all the rules at once.@refill - -@code{IGNORECASE} can be set on the command line, or in a @code{BEGIN} -rule. Setting @code{IGNORECASE} from the command line is a way to make -a program case-insensitive without having to edit it. - -The value of @code{IGNORECASE} has no effect if @code{gawk} is in -compatibility mode (@pxref{Command Line, ,Invoking @code{awk}}). -Case is always significant in compatibility mode.@refill - -@node Comparison Patterns, Boolean Patterns, Regexp, Patterns -@section Comparison Expressions as Patterns -@cindex comparison expressions as patterns -@cindex pattern, comparison expressions -@cindex relational operators -@cindex operators, relational - -@dfn{Comparison patterns} test relationships such as equality between -two strings or numbers. They are a special case of expression patterns -(@pxref{Expression Patterns, ,Expressions as Patterns}). They are written -with @dfn{relational operators}, which are a superset of those in C. -Here is a table of them:@refill - -@table @code -@item @var{x} < @var{y} -True if @var{x} is less than @var{y}. - -@item @var{x} <= @var{y} -True if @var{x} is less than or equal to @var{y}. - -@item @var{x} > @var{y} -True if @var{x} is greater than @var{y}. - -@item @var{x} >= @var{y} -True if @var{x} is greater than or equal to @var{y}. - -@item @var{x} == @var{y} -True if @var{x} is equal to @var{y}. - -@item @var{x} != @var{y} -True if @var{x} is not equal to @var{y}. - -@item @var{x} ~ @var{y} -True if @var{x} matches the regular expression described by @var{y}. - -@item @var{x} !~ @var{y} -True if @var{x} does not match the regular expression described by @var{y}. -@end table - -The operands of a relational operator are compared as numbers if they -are both numbers. Otherwise they are converted to, and compared as, -strings (@pxref{Conversion, ,Conversion of Strings and Numbers}, -for the detailed rules). Strings are compared by comparing the first -character of each, then the second character of each, -and so on, until there is a difference. If the two strings are equal until -the shorter one runs out, the shorter one is considered to be less than the -longer one. Thus, @code{"10"} is less than @code{"9"}, and @code{"abc"} -is less than @code{"abcd"}.@refill - -The left operand of the @samp{~} and @samp{!~} operators is a string. -The right operand is either a constant regular expression enclosed in -slashes (@code{/@var{regexp}/}), or any expression, whose string value -is used as a dynamic regular expression -(@pxref{Regexp Usage, ,How to Use Regular Expressions}).@refill - -The following example prints the second field of each input record -whose first field is precisely @samp{foo}. - -@example -awk '$1 == "foo" @{ print $2 @}' BBS-list -@end example - -@noindent -Contrast this with the following regular expression match, which would -accept any record with a first field that contains @samp{foo}: - -@example -awk '$1 ~ "foo" @{ print $2 @}' BBS-list -@end example - -@noindent -or, equivalently, this one: - -@example -awk '$1 ~ /foo/ @{ print $2 @}' BBS-list -@end example - -@node Boolean Patterns, Expression Patterns, Comparison Patterns, Patterns -@section Boolean Operators and Patterns -@cindex patterns, boolean -@cindex boolean patterns - -A @dfn{boolean pattern} is an expression which combines other patterns -using the @dfn{boolean operators} ``or'' (@samp{||}), ``and'' -(@samp{&&}), and ``not'' (@samp{!}). Whether the boolean pattern -matches an input record depends on whether its subpatterns match. - -For example, the following command prints all records in the input file -@file{BBS-list} that contain both @samp{2400} and @samp{foo}.@refill - -@example -awk '/2400/ && /foo/' BBS-list -@end example - -The following command prints all records in the input file -@file{BBS-list} that contain @emph{either} @samp{2400} or @samp{foo}, or -both.@refill - -@example -awk '/2400/ || /foo/' BBS-list -@end example - -The following command prints all records in the input file -@file{BBS-list} that do @emph{not} contain the string @samp{foo}. - -@example -awk '! /foo/' BBS-list -@end example - -Note that boolean patterns are a special case of expression patterns -(@pxref{Expression Patterns, ,Expressions as Patterns}); they are -expressions that use the boolean operators. -@xref{Boolean Ops, ,Boolean Expressions}, for complete information -on the boolean operators.@refill - -The subpatterns of a boolean pattern can be constant regular -expressions, comparisons, or any other @code{awk} expressions. Range -patterns are not expressions, so they cannot appear inside boolean -patterns. Likewise, the special patterns @code{BEGIN} and @code{END}, -which never match any input record, are not expressions and cannot -appear inside boolean patterns. - -@node Expression Patterns, Ranges, Boolean Patterns, Patterns -@section Expressions as Patterns - -Any @code{awk} expression is also valid as an @code{awk} pattern. -Then the pattern ``matches'' if the expression's value is nonzero (if a -number) or nonnull (if a string). - -The expression is reevaluated each time the rule is tested against a new -input record. If the expression uses fields such as @code{$1}, the -value depends directly on the new input record's text; otherwise, it -depends only on what has happened so far in the execution of the -@code{awk} program, but that may still be useful. - -Comparison patterns are actually a special case of this. For -example, the expression @code{$5 == "foo"} has the value 1 when the -value of @code{$5} equals @code{"foo"}, and 0 otherwise; therefore, this -expression as a pattern matches when the two values are equal. - -Boolean patterns are also special cases of expression patterns. - -A constant regexp as a pattern is also a special case of an expression -pattern. @code{/foo/} as an expression has the value 1 if @samp{foo} -appears in the current input record; thus, as a pattern, @code{/foo/} -matches any record containing @samp{foo}. - -Other implementations of @code{awk} that are not yet @sc{posix} compliant -are less general than @code{gawk}: they allow comparison expressions, and -boolean combinations thereof (optionally with parentheses), but not -necessarily other kinds of expressions. - -@node Ranges, BEGIN/END, Expression Patterns, Patterns -@section Specifying Record Ranges with Patterns - -@cindex range pattern -@cindex patterns, range -A @dfn{range pattern} is made of two patterns separated by a comma, of -the form @code{@var{begpat}, @var{endpat}}. It matches ranges of -consecutive input records. The first pattern @var{begpat} controls -where the range begins, and the second one @var{endpat} controls where -it ends. For example,@refill - -@example -awk '$1 == "on", $1 == "off"' -@end example - -@noindent -prints every record between @samp{on}/@samp{off} pairs, inclusive. - -A range pattern starts out by matching @var{begpat} -against every input record; when a record matches @var{begpat}, the -range pattern becomes @dfn{turned on}. The range pattern matches this -record. As long as it stays turned on, it automatically matches every -input record read. It also matches @var{endpat} against -every input record; when that succeeds, the range pattern is turned -off again for the following record. Now it goes back to checking -@var{begpat} against each record. - -The record that turns on the range pattern and the one that turns it -off both match the range pattern. If you don't want to operate on -these records, you can write @code{if} statements in the rule's action -to distinguish them. - -It is possible for a pattern to be turned both on and off by the same -record, if both conditions are satisfied by that record. Then the action is -executed for just that record. - -@node BEGIN/END, Empty, Ranges, Patterns -@section @code{BEGIN} and @code{END} Special Patterns - -@cindex @code{BEGIN} special pattern -@cindex patterns, @code{BEGIN} -@cindex @code{END} special pattern -@cindex patterns, @code{END} -@code{BEGIN} and @code{END} are special patterns. They are not used to -match input records. Rather, they are used for supplying start-up or -clean-up information to your @code{awk} script. A @code{BEGIN} rule is -executed, once, before the first input record has been read. An @code{END} -rule is executed, once, after all the input has been read. For -example:@refill - -@example -awk 'BEGIN @{ print "Analysis of `foo'" @} - /foo/ @{ ++foobar @} - END @{ print "`foo' appears " foobar " times." @}' BBS-list -@end example - -This program finds the number of records in the input file @file{BBS-list} -that contain the string @samp{foo}. The @code{BEGIN} rule prints a title -for the report. There is no need to use the @code{BEGIN} rule to -initialize the counter @code{foobar} to zero, as @code{awk} does this -for us automatically (@pxref{Variables}). - -The second rule increments the variable @code{foobar} every time a -record containing the pattern @samp{foo} is read. The @code{END} rule -prints the value of @code{foobar} at the end of the run.@refill - -The special patterns @code{BEGIN} and @code{END} cannot be used in ranges -or with boolean operators (indeed, they cannot be used with any operators). - -An @code{awk} program may have multiple @code{BEGIN} and/or @code{END} -rules. They are executed in the order they appear, all the @code{BEGIN} -rules at start-up and all the @code{END} rules at termination. - -Multiple @code{BEGIN} and @code{END} sections are useful for writing -library functions, since each library can have its own @code{BEGIN} or -@code{END} rule to do its own initialization and/or cleanup. Note that -the order in which library functions are named on the command line -controls the order in which their @code{BEGIN} and @code{END} rules are -executed. Therefore you have to be careful to write such rules in -library files so that the order in which they are executed doesn't matter. -@xref{Command Line, ,Invoking @code{awk}}, for more information on -using library functions. - -If an @code{awk} program only has a @code{BEGIN} rule, and no other -rules, then the program exits after the @code{BEGIN} rule has been run. -(Older versions of @code{awk} used to keep reading and ignoring input -until end of file was seen.) However, if an @code{END} rule exists as -well, then the input will be read, even if there are no other rules in -the program. This is necessary in case the @code{END} rule checks the -@code{NR} variable. - -@code{BEGIN} and @code{END} rules must have actions; there is no default -action for these rules since there is no current record when they run. - -@node Empty, , BEGIN/END, Patterns -@comment node-name, next, previous, up -@section The Empty Pattern - -@cindex empty pattern -@cindex pattern, empty -An empty pattern is considered to match @emph{every} input record. For -example, the program:@refill - -@example -awk '@{ print $1 @}' BBS-list -@end example - -@noindent -prints the first field of every record. - -@node Actions, Expressions, Patterns, Top -@chapter Overview of Actions -@cindex action, definition of -@cindex curly braces -@cindex action, curly braces -@cindex action, separating statements - -An @code{awk} program or script consists of a series of -rules and function definitions, interspersed. (Functions are -described later. @xref{User-defined, ,User-defined Functions}.) - -A rule contains a pattern and an action, either of which may be -omitted. The purpose of the @dfn{action} is to tell @code{awk} what to do -once a match for the pattern is found. Thus, the entire program -looks somewhat like this: - -@example -@r{[}@var{pattern}@r{]} @r{[}@{ @var{action} @}@r{]} -@r{[}@var{pattern}@r{]} @r{[}@{ @var{action} @}@r{]} -@dots{} -function @var{name} (@var{args}) @{ @dots{} @} -@dots{} -@end example - -An action consists of one or more @code{awk} @dfn{statements}, enclosed -in curly braces (@samp{@{} and @samp{@}}). Each statement specifies one -thing to be done. The statements are separated by newlines or -semicolons. - -The curly braces around an action must be used even if the action -contains only one statement, or even if it contains no statements at -all. However, if you omit the action entirely, omit the curly braces as -well. (An omitted action is equivalent to @samp{@{ print $0 @}}.) - -Here are the kinds of statements supported in @code{awk}: - -@itemize @bullet -@item -Expressions, which can call functions or assign values to variables -(@pxref{Expressions, ,Expressions as Action Statements}). Executing -this kind of statement simply computes the value of the expression and -then ignores it. This is useful when the expression has side effects -(@pxref{Assignment Ops, ,Assignment Expressions}).@refill - -@item -Control statements, which specify the control flow of @code{awk} -programs. The @code{awk} language gives you C-like constructs -(@code{if}, @code{for}, @code{while}, and so on) as well as a few -special ones (@pxref{Statements, ,Control Statements in Actions}).@refill - -@item -Compound statements, which consist of one or more statements enclosed in -curly braces. A compound statement is used in order to put several -statements together in the body of an @code{if}, @code{while}, @code{do} -or @code{for} statement. - -@item -Input control, using the @code{getline} command -(@pxref{Getline, ,Explicit Input with @code{getline}}), and the @code{next} -statement (@pxref{Next Statement, ,The @code{next} Statement}). - -@item -Output statements, @code{print} and @code{printf}. -@xref{Printing, ,Printing Output}.@refill - -@item -Deletion statements, for deleting array elements. -@xref{Delete, ,The @code{delete} Statement}.@refill -@end itemize - -@iftex -The next two chapters cover in detail expressions and control -statements, respectively. We go on to treat arrays and built-in -functions, both of which are used in expressions. Then we proceed -to discuss how to define your own functions. -@end iftex - -@node Expressions, Statements, Actions, Top -@chapter Expressions as Action Statements -@cindex expression - -Expressions are the basic building block of @code{awk} actions. An -expression evaluates to a value, which you can print, test, store in a -variable or pass to a function. But beyond that, an expression can assign a new value to a variable -or a field, with an assignment operator. - -An expression can serve as a statement on its own. Most other kinds of -statements contain one or more expressions which specify data to be -operated on. As in other languages, expressions in @code{awk} include -variables, array references, constants, and function calls, as well as -combinations of these with various operators. - -@menu -* Constants:: String, numeric, and regexp constants. -* Variables:: Variables give names to values for later use. -* Arithmetic Ops:: Arithmetic operations (@samp{+}, @samp{-}, etc.) -* Concatenation:: Concatenating strings. -* Comparison Ops:: Comparison of numbers and strings - with @samp{<}, etc. -* Boolean Ops:: Combining comparison expressions - using boolean operators - @samp{||} (``or''), @samp{&&} (``and'') and @samp{!} (``not''). - -* Assignment Ops:: Changing the value of a variable or a field. -* Increment Ops:: Incrementing the numeric value of a variable. - -* Conversion:: The conversion of strings to numbers - and vice versa. -* Values:: The whole truth about numbers and strings. -* Conditional Exp:: Conditional expressions select - between two subexpressions under control - of a third subexpression. -* Function Calls:: A function call is an expression. -* Precedence:: How various operators nest. -@end menu - -@node Constants, Variables, Expressions, Expressions -@section Constant Expressions -@cindex constants, types of -@cindex string constants - -The simplest type of expression is the @dfn{constant}, which always has -the same value. There are three types of constants: numeric constants, -string constants, and regular expression constants. - -@cindex numeric constant -@cindex numeric value -A @dfn{numeric constant} stands for a number. This number can be an -integer, a decimal fraction, or a number in scientific (exponential) -notation. Note that all numeric values are represented within -@code{awk} in double-precision floating point. Here are some examples -of numeric constants, which all have the same value: - -@example -105 -1.05e+2 -1050e-1 -@end example - -A string constant consists of a sequence of characters enclosed in -double-quote marks. For example: - -@example -"parrot" -@end example - -@noindent -@iftex -@cindex differences between @code{gawk} and @code{awk} -@end iftex -represents the string whose contents are @samp{parrot}. Strings in -@code{gawk} can be of any length and they can contain all the possible -8-bit ASCII characters including ASCII NUL. Other @code{awk} -implementations may have difficulty with some character codes.@refill - -@cindex escape sequence notation -Some characters cannot be included literally in a string constant. You -represent them instead with @dfn{escape sequences}, which are character -sequences beginning with a backslash (@samp{\}). - -One use of an escape sequence is to include a double-quote character in -a string constant. Since a plain double-quote would end the string, you -must use @samp{\"} to represent a single double-quote character as a -part of the string. -The -backslash character itself is another character that cannot be -included normally; you write @samp{\\} to put one backslash in the -string. Thus, the string whose contents are the two characters -@samp{"\} must be written @code{"\"\\"}. - -Another use of backslash is to represent unprintable characters -such as newline. While there is nothing to stop you from writing most -of these characters directly in a string constant, they may look ugly. - -Here is a table of all the escape sequences used in @code{awk}: - -@table @code -@item \\ -Represents a literal backslash, @samp{\}. - -@item \a -Represents the ``alert'' character, control-g, ASCII code 7. - -@item \b -Represents a backspace, control-h, ASCII code 8. - -@item \f -Represents a formfeed, control-l, ASCII code 12. - -@item \n -Represents a newline, control-j, ASCII code 10. - -@item \r -Represents a carriage return, control-m, ASCII code 13. - -@item \t -Represents a horizontal tab, control-i, ASCII code 9. - -@item \v -Represents a vertical tab, control-k, ASCII code 11. - -@item \@var{nnn} -Represents the octal value @var{nnn}, where @var{nnn} are one to three -digits between 0 and 7. For example, the code for the ASCII ESC -(escape) character is @samp{\033}.@refill - -@item \x@var{hh}@dots{} -Represents the hexadecimal value @var{hh}, where @var{hh} are hexadecimal -digits (@samp{0} through @samp{9} and either @samp{A} through @samp{F} or -@samp{a} through @samp{f}). Like the same construct in @sc{ansi} C, the escape -sequence continues until the first non-hexadecimal digit is seen. However, -using more than two hexadecimal digits produces undefined results. (The -@samp{\x} escape sequence is not allowed in @sc{posix} @code{awk}.)@refill -@end table - -A @dfn{constant regexp} is a regular expression description enclosed in -slashes, such as @code{/^beginning and end$/}. Most regexps used in -@code{awk} programs are constant, but the @samp{~} and @samp{!~} -operators can also match computed or ``dynamic'' regexps -(@pxref{Regexp Usage, ,How to Use Regular Expressions}).@refill - -Constant regexps may be used like simple expressions. When a -constant regexp is not on the right hand side of the @samp{~} or -@samp{!~} operators, it has the same meaning as if it appeared -in a pattern, i.e. @samp{($0 ~ /foo/)} -(@pxref{Expression Patterns, ,Expressions as Patterns}). -This means that the two code segments,@refill - -@example -if ($0 ~ /barfly/ || $0 ~ /camelot/) - print "found" -@end example - -@noindent -and - -@example -if (/barfly/ || /camelot/) - print "found" -@end example - -@noindent -are exactly equivalent. One rather bizarre consequence of this rule is -that the following boolean expression is legal, but does not do what the user -intended:@refill - -@example -if (/foo/ ~ $1) print "found foo" -@end example - -This code is ``obviously'' testing @code{$1} for a match against the regexp -@code{/foo/}. But in fact, the expression @code{(/foo/ ~ $1)} actually means -@code{(($0 ~ /foo/) ~ $1)}. In other words, first match the input record -against the regexp @code{/foo/}. The result will be either a 0 or a 1, -depending upon the success or failure of the match. Then match that result -against the first field in the record.@refill - -Since it is unlikely that you would ever really wish to make this kind of -test, @code{gawk} will issue a warning when it sees this construct in -a program.@refill - -Another consequence of this rule is that the assignment statement - -@example -matches = /foo/ -@end example - -@noindent -will assign either 0 or 1 to the variable @code{matches}, depending -upon the contents of the current input record. - -Constant regular expressions are also used as the first argument for -the @code{sub} and @code{gsub} functions -(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill - -This feature of the language was never well documented until the -@sc{posix} specification. - -You may be wondering, when is - -@example -$1 ~ /foo/ @{ @dots{} @} -@end example - -@noindent -preferable to - -@example -$1 ~ "foo" @{ @dots{} @} -@end example - -Since the right-hand sides of both @samp{~} operators are constants, -it is more efficient to use the @samp{/foo/} form: @code{awk} can note -that you have supplied a regexp and store it internally in a form that -makes pattern matching more efficient. In the second form, @code{awk} -must first convert the string into this internal form, and then perform -the pattern matching. The first form is also better style; it shows -clearly that you intend a regexp match. - -@node Variables, Arithmetic Ops, Constants, Expressions -@section Variables -@cindex variables, user-defined -@cindex user-defined variables -@c there should be more than one subsection, ideally. Not a big deal. -@c But usually there are supposed to be at least two. One way to get -@c around this is to write the info in the subsection as the info in the -@c section itself and not have any subsections.. --mew - -Variables let you give names to values and refer to them later. You have -already seen variables in many of the examples. The name of a variable -must be a sequence of letters, digits and underscores, but it may not begin -with a digit. Case is significant in variable names; @code{a} and @code{A} -are distinct variables. - -A variable name is a valid expression by itself; it represents the -variable's current value. Variables are given new values with -@dfn{assignment operators} and @dfn{increment operators}. -@xref{Assignment Ops, ,Assignment Expressions}. - -A few variables have special built-in meanings, such as @code{FS}, the -field separator, and @code{NF}, the number of fields in the current -input record. @xref{Built-in Variables}, for a list of them. These -built-in variables can be used and assigned just like all other -variables, but their values are also used or changed automatically by -@code{awk}. Each built-in variable's name is made entirely of upper case -letters. - -Variables in @code{awk} can be assigned either numeric or string -values. By default, variables are initialized to the null string, which -is effectively zero if converted to a number. There is no need to -``initialize'' each variable explicitly in @code{awk}, the way you would in C or most other traditional languages. - -@menu -* Assignment Options:: Setting variables on the command line - and a summary of command line syntax. - This is an advanced method of input. -@end menu - -@node Assignment Options, , Variables, Variables -@subsection Assigning Variables on the Command Line - -You can set any @code{awk} variable by including a @dfn{variable assignment} -among the arguments on the command line when you invoke @code{awk} -(@pxref{Command Line, ,Invoking @code{awk}}). Such an assignment has -this form:@refill - -@example -@var{variable}=@var{text} -@end example - -@noindent -With it, you can set a variable either at the beginning of the -@code{awk} run or in between input files. - -If you precede the assignment with the @samp{-v} option, like this: - -@example --v @var{variable}=@var{text} -@end example - -@noindent -then the variable is set at the very beginning, before even the -@code{BEGIN} rules are run. The @samp{-v} option and its assignment -must precede all the file name arguments, as well as the program text. - -Otherwise, the variable assignment is performed at a time determined by -its position among the input file arguments: after the processing of the -preceding input file argument. For example: - -@example -awk '@{ print $n @}' n=4 inventory-shipped n=2 BBS-list -@end example - -@noindent -prints the value of field number @code{n} for all input records. Before -the first file is read, the command line sets the variable @code{n} -equal to 4. This causes the fourth field to be printed in lines from -the file @file{inventory-shipped}. After the first file has finished, -but before the second file is started, @code{n} is set to 2, so that the -second field is printed in lines from @file{BBS-list}. - -Command line arguments are made available for explicit examination by -the @code{awk} program in an array named @code{ARGV} -(@pxref{Built-in Variables}).@refill - -@code{awk} processes the values of command line assignments for escape -sequences (@pxref{Constants, ,Constant Expressions}). - -@node Arithmetic Ops, Concatenation, Variables, Expressions -@section Arithmetic Operators -@cindex arithmetic operators -@cindex operators, arithmetic -@cindex addition -@cindex subtraction -@cindex multiplication -@cindex division -@cindex remainder -@cindex quotient -@cindex exponentiation - -The @code{awk} language uses the common arithmetic operators when -evaluating expressions. All of these arithmetic operators follow normal -precedence rules, and work as you would expect them to. This example -divides field three by field four, adds field two, stores the result -into field one, and prints the resulting altered input record: - -@example -awk '@{ $1 = $2 + $3 / $4; print @}' inventory-shipped -@end example - -The arithmetic operators in @code{awk} are: - -@table @code -@item @var{x} + @var{y} -Addition. - -@item @var{x} - @var{y} -Subtraction. - -@item - @var{x} -Negation. - -@item + @var{x} -Unary plus. No real effect on the expression. - -@item @var{x} * @var{y} -Multiplication. - -@item @var{x} / @var{y} -Division. Since all numbers in @code{awk} are double-precision -floating point, the result is not rounded to an integer: @code{3 / 4} -has the value 0.75. - -@item @var{x} % @var{y} -@iftex -@cindex differences between @code{gawk} and @code{awk} -@end iftex -Remainder. The quotient is rounded toward zero to an integer, -multiplied by @var{y} and this result is subtracted from @var{x}. -This operation is sometimes known as ``trunc-mod.'' The following -relation always holds: - -@example -b * int(a / b) + (a % b) == a -@end example - -One possibly undesirable effect of this definition of remainder is that -@code{@var{x} % @var{y}} is negative if @var{x} is negative. Thus, - -@example --17 % 8 = -1 -@end example - -In other @code{awk} implementations, the signedness of the remainder -may be machine dependent. - -@item @var{x} ^ @var{y} -@itemx @var{x} ** @var{y} -Exponentiation: @var{x} raised to the @var{y} power. @code{2 ^ 3} has -the value 8. The character sequence @samp{**} is equivalent to -@samp{^}. (The @sc{posix} standard only specifies the use of @samp{^} -for exponentiation.) -@end table - -@node Concatenation, Comparison Ops, Arithmetic Ops, Expressions -@section String Concatenation - -@cindex string operators -@cindex operators, string -@cindex concatenation -There is only one string operation: concatenation. It does not have a -specific operator to represent it. Instead, concatenation is performed by -writing expressions next to one another, with no operator. For example: - -@example -awk '@{ print "Field number one: " $1 @}' BBS-list -@end example - -@noindent -produces, for the first record in @file{BBS-list}: - -@example -Field number one: aardvark -@end example - -Without the space in the string constant after the @samp{:}, the line -would run together. For example: - -@example -awk '@{ print "Field number one:" $1 @}' BBS-list -@end example - -@noindent -produces, for the first record in @file{BBS-list}: - -@example -Field number one:aardvark -@end example - -Since string concatenation does not have an explicit operator, it is -often necessary to insure that it happens where you want it to by -enclosing the items to be concatenated in parentheses. For example, the -following code fragment does not concatenate @code{file} and @code{name} -as you might expect: - -@example -file = "file" -name = "name" -print "something meaningful" > file name -@end example - -@noindent -It is necessary to use the following: - -@example -print "something meaningful" > (file name) -@end example - -We recommend you use parentheses around concatenation in all but the -most common contexts (such as in the right-hand operand of @samp{=}). - -@ignore -@code{gawk} actually now allows a concatenation on the right hand -side of a @code{>} redirection, but other @code{awk}s don't. So for -now we won't mention that fact. -@end ignore - -@node Comparison Ops, Boolean Ops, Concatenation, Expressions -@section Comparison Expressions -@cindex comparison expressions -@cindex expressions, comparison -@cindex relational operators -@cindex operators, relational -@cindex regexp operators - -@dfn{Comparison expressions} compare strings or numbers for -relationships such as equality. They are written using @dfn{relational -operators}, which are a superset of those in C. Here is a table of -them: - -@table @code -@item @var{x} < @var{y} -True if @var{x} is less than @var{y}. - -@item @var{x} <= @var{y} -True if @var{x} is less than or equal to @var{y}. - -@item @var{x} > @var{y} -True if @var{x} is greater than @var{y}. - -@item @var{x} >= @var{y} -True if @var{x} is greater than or equal to @var{y}. - -@item @var{x} == @var{y} -True if @var{x} is equal to @var{y}. - -@item @var{x} != @var{y} -True if @var{x} is not equal to @var{y}. - -@item @var{x} ~ @var{y} -True if the string @var{x} matches the regexp denoted by @var{y}. - -@item @var{x} !~ @var{y} -True if the string @var{x} does not match the regexp denoted by @var{y}. - -@item @var{subscript} in @var{array} -True if array @var{array} has an element with the subscript @var{subscript}. -@end table - -Comparison expressions have the value 1 if true and 0 if false. - -The rules @code{gawk} uses for performing comparisons are based on those -in draft 11.2 of the @sc{posix} standard. The @sc{posix} standard introduced -the concept of a @dfn{numeric string}, which is simply a string that looks -like a number, for example, @code{@w{" +2"}}. - -@vindex CONVFMT -When performing a relational operation, @code{gawk} considers the type of an -operand to be the type it received on its last @emph{assignment}, rather -than the type of its last @emph{use} -(@pxref{Values, ,Numeric and String Values}). -This type is @emph{unknown} when the operand is from an ``external'' source: -field variables, command line arguments, array elements resulting from a -@code{split} operation, and the value of an @code{ENVIRON} element. -In this case only, if the operand is a numeric string, then it is -considered to be of both string type and numeric type. If at least one -operand of a comparison is of string type only, then a string -comparison is performed. Any numeric operand will be converted to a -string using the value of @code{CONVFMT} -(@pxref{Conversion, ,Conversion of Strings and Numbers}). -If one operand of a comparison is numeric, and the other operand is -either numeric or both numeric and string, then @code{gawk} does a -numeric comparison. If both operands have both types, then the -comparison is numeric. Strings are compared -by comparing the first character of each, then the second character of each, -and so on. Thus @code{"10"} is less than @code{"9"}. If there are two -strings where one is a prefix of the other, the shorter string is less than -the longer one. Thus @code{"abc"} is less than @code{"abcd"}.@refill - -Here are some sample expressions, how @code{gawk} compares them, and what -the result of the comparison is. - -@table @code -@item 1.5 <= 2.0 -numeric comparison (true) - -@item "abc" >= "xyz" -string comparison (false) - -@item 1.5 != " +2" -string comparison (true) - -@item "1e2" < "3" -string comparison (true) - -@item a = 2; b = "2" -@itemx a == b -string comparison (true) -@end table - -@example -echo 1e2 3 | awk '@{ print ($1 < $2) ? "true" : "false" @}' -@end example - -@noindent -prints @samp{false} since both @code{$1} and @code{$2} are numeric -strings and thus have both string and numeric types, thus dictating -a numeric comparison. - -The purpose of the comparison rules and the use of numeric strings is -to attempt to produce the behavior that is ``least surprising,'' while -still ``doing the right thing.'' - -String comparisons and regular expression comparisons are very different. -For example, - -@example -$1 == "foo" -@end example - -@noindent -has the value of 1, or is true, if the first field of the current input -record is precisely @samp{foo}. By contrast, - -@example -$1 ~ /foo/ -@end example - -@noindent -has the value 1 if the first field contains @samp{foo}, such as @samp{foobar}. - -The right hand operand of the @samp{~} and @samp{!~} operators may be -either a constant regexp (@code{/@dots{}/}), or it may be an ordinary -expression, in which case the value of the expression as a string is a -dynamic regexp (@pxref{Regexp Usage, ,How to Use Regular Expressions}). - -@cindex regexp as expression -In very recent implementations of @code{awk}, a constant regular -expression in slashes by itself is also an expression. The regexp -@code{/@var{regexp}/} is an abbreviation for this comparison expression: - -@example -$0 ~ /@var{regexp}/ -@end example - -In some contexts it may be necessary to write parentheses around the -regexp to avoid confusing the @code{gawk} parser. For example, -@code{(/x/ - /y/) > threshold} is not allowed, but @code{((/x/) - (/y/)) -> threshold} parses properly. - -One special place where @code{/foo/} is @emph{not} an abbreviation for -@code{$0 ~ /foo/} is when it is the right-hand operand of @samp{~} or -@samp{!~}! @xref{Constants, ,Constant Expressions}, where this is -discussed in more detail. - -@node Boolean Ops, Assignment Ops, Comparison Ops, Expressions -@section Boolean Expressions -@cindex expressions, boolean -@cindex boolean expressions -@cindex operators, boolean -@cindex boolean operators -@cindex logical operations -@cindex and operator -@cindex or operator -@cindex not operator - -A @dfn{boolean expression} is a combination of comparison expressions or -matching expressions, using the boolean operators ``or'' -(@samp{||}), ``and'' (@samp{&&}), and ``not'' (@samp{!}), along with -parentheses to control nesting. The truth of the boolean expression is -computed by combining the truth values of the component expressions. - -Boolean expressions can be used wherever comparison and matching -expressions can be used. They can be used in @code{if}, @code{while} -@code{do} and @code{for} statements. They have numeric values (1 if true, -0 if false), which come into play if the result of the boolean expression -is stored in a variable, or used in arithmetic.@refill - -In addition, every boolean expression is also a valid boolean pattern, so -you can use it as a pattern to control the execution of rules. - -Here are descriptions of the three boolean operators, with an example of -each. It may be instructive to compare these examples with the -analogous examples of boolean patterns -(@pxref{Boolean Patterns, ,Boolean Operators and Patterns}), which -use the same boolean operators in patterns instead of expressions.@refill - -@table @code -@item @var{boolean1} && @var{boolean2} -True if both @var{boolean1} and @var{boolean2} are true. For example, -the following statement prints the current input record if it contains -both @samp{2400} and @samp{foo}.@refill - -@smallexample -if ($0 ~ /2400/ && $0 ~ /foo/) print -@end smallexample - -The subexpression @var{boolean2} is evaluated only if @var{boolean1} -is true. This can make a difference when @var{boolean2} contains -expressions that have side effects: in the case of @code{$0 ~ /foo/ && -($2 == bar++)}, the variable @code{bar} is not incremented if there is -no @samp{foo} in the record. - -@item @var{boolean1} || @var{boolean2} -True if at least one of @var{boolean1} or @var{boolean2} is true. -For example, the following command prints all records in the input -file @file{BBS-list} that contain @emph{either} @samp{2400} or -@samp{foo}, or both.@refill - -@smallexample -awk '@{ if ($0 ~ /2400/ || $0 ~ /foo/) print @}' BBS-list -@end smallexample - -The subexpression @var{boolean2} is evaluated only if @var{boolean1} -is false. This can make a difference when @var{boolean2} contains -expressions that have side effects. - -@item !@var{boolean} -True if @var{boolean} is false. For example, the following program prints -all records in the input file @file{BBS-list} that do @emph{not} contain the -string @samp{foo}. - -@smallexample -awk '@{ if (! ($0 ~ /foo/)) print @}' BBS-list -@end smallexample -@end table - -@node Assignment Ops, Increment Ops, Boolean Ops, Expressions -@section Assignment Expressions -@cindex assignment operators -@cindex operators, assignment -@cindex expressions, assignment - -An @dfn{assignment} is an expression that stores a new value into a -variable. For example, let's assign the value 1 to the variable -@code{z}:@refill - -@example -z = 1 -@end example - -After this expression is executed, the variable @code{z} has the value 1. -Whatever old value @code{z} had before the assignment is forgotten. - -Assignments can store string values also. For example, this would store -the value @code{"this food is good"} in the variable @code{message}: - -@example -thing = "food" -predicate = "good" -message = "this " thing " is " predicate -@end example - -@noindent -(This also illustrates concatenation of strings.) - -The @samp{=} sign is called an @dfn{assignment operator}. It is the -simplest assignment operator because the value of the right-hand -operand is stored unchanged. - -@cindex side effect -Most operators (addition, concatenation, and so on) have no effect -except to compute a value. If you ignore the value, you might as well -not use the operator. An assignment operator is different; it does -produce a value, but even if you ignore the value, the assignment still -makes itself felt through the alteration of the variable. We call this -a @dfn{side effect}. - -@cindex lvalue -The left-hand operand of an assignment need not be a variable -(@pxref{Variables}); it can also be a field -(@pxref{Changing Fields, ,Changing the Contents of a Field}) or -an array element (@pxref{Arrays, ,Arrays in @code{awk}}). -These are all called @dfn{lvalues}, -which means they can appear on the left-hand side of an assignment operator. -The right-hand operand may be any expression; it produces the new value -which the assignment stores in the specified variable, field or array -element.@refill - -It is important to note that variables do @emph{not} have permanent types. -The type of a variable is simply the type of whatever value it happens -to hold at the moment. In the following program fragment, the variable -@code{foo} has a numeric value at first, and a string value later on: - -@example -foo = 1 -print foo -foo = "bar" -print foo -@end example - -@noindent -When the second assignment gives @code{foo} a string value, the fact that -it previously had a numeric value is forgotten. - -An assignment is an expression, so it has a value: the same value that -is assigned. Thus, @code{z = 1} as an expression has the value 1. -One consequence of this is that you can write multiple assignments together: - -@example -x = y = z = 0 -@end example - -@noindent -stores the value 0 in all three variables. It does this because the -value of @code{z = 0}, which is 0, is stored into @code{y}, and then -the value of @code{y = z = 0}, which is 0, is stored into @code{x}. - -You can use an assignment anywhere an expression is called for. For -example, it is valid to write @code{x != (y = 1)} to set @code{y} to 1 -and then test whether @code{x} equals 1. But this style tends to make -programs hard to read; except in a one-shot program, you should -rewrite it to get rid of such nesting of assignments. This is never very -hard. - -Aside from @samp{=}, there are several other assignment operators that -do arithmetic with the old value of the variable. For example, the -operator @samp{+=} computes a new value by adding the right-hand value -to the old value of the variable. Thus, the following assignment adds -5 to the value of @code{foo}: - -@example -foo += 5 -@end example - -@noindent -This is precisely equivalent to the following: - -@example -foo = foo + 5 -@end example - -@noindent -Use whichever one makes the meaning of your program clearer. - -Here is a table of the arithmetic assignment operators. In each -case, the right-hand operand is an expression whose value is converted -to a number. - -@table @code -@item @var{lvalue} += @var{increment} -Adds @var{increment} to the value of @var{lvalue} to make the new value -of @var{lvalue}. - -@item @var{lvalue} -= @var{decrement} -Subtracts @var{decrement} from the value of @var{lvalue}. - -@item @var{lvalue} *= @var{coefficient} -Multiplies the value of @var{lvalue} by @var{coefficient}. - -@item @var{lvalue} /= @var{quotient} -Divides the value of @var{lvalue} by @var{quotient}. - -@item @var{lvalue} %= @var{modulus} -Sets @var{lvalue} to its remainder by @var{modulus}. - -@item @var{lvalue} ^= @var{power} -@itemx @var{lvalue} **= @var{power} -Raises @var{lvalue} to the power @var{power}. -(Only the @code{^=} operator is specified by @sc{posix}.) -@end table - -@ignore -From: gatech!ames!elroy!cit-vax!EQL.Caltech.Edu!rankin (Pat Rankin) - In the discussion of assignment operators, it states that -``foo += 5'' "is precisely equivalent to" ``foo = foo + 5'' (p.77). That -may be true for simple variables, but it's not true for expressions with -side effects, like array references. For proof, try - BEGIN { - foo[rand()] += 5; for (x in foo) print x, foo[x] - bar[rand()] = bar[rand()] + 5; for (x in bar) print x, bar[x] - } -I suspect that the original statement is simply untrue--that '+=' is more -efficient in all cases. - -ADR --- Try to add something about this here for the next go 'round. -@end ignore - -@node Increment Ops, Conversion, Assignment Ops, Expressions -@section Increment Operators - -@cindex increment operators -@cindex operators, increment -@dfn{Increment operators} increase or decrease the value of a variable -by 1. You could do the same thing with an assignment operator, so -the increment operators add no power to the @code{awk} language; but they -are convenient abbreviations for something very common. - -The operator to add 1 is written @samp{++}. It can be used to increment -a variable either before or after taking its value. - -To pre-increment a variable @var{v}, write @code{++@var{v}}. This adds -1 to the value of @var{v} and that new value is also the value of this -expression. The assignment expression @code{@var{v} += 1} is completely -equivalent. - -Writing the @samp{++} after the variable specifies post-increment. This -increments the variable value just the same; the difference is that the -value of the increment expression itself is the variable's @emph{old} -value. Thus, if @code{foo} has the value 4, then the expression @code{foo++} -has the value 4, but it changes the value of @code{foo} to 5. - -The post-increment @code{foo++} is nearly equivalent to writing @code{(foo -+= 1) - 1}. It is not perfectly equivalent because all numbers in -@code{awk} are floating point: in floating point, @code{foo + 1 - 1} does -not necessarily equal @code{foo}. But the difference is minute as -long as you stick to numbers that are fairly small (less than a trillion). - -Any lvalue can be incremented. Fields and array elements are incremented -just like variables. (Use @samp{$(i++)} when you wish to do a field reference -and a variable increment at the same time. The parentheses are necessary -because of the precedence of the field reference operator, @samp{$}.) -@c expert information in the last parenthetical remark - -The decrement operator @samp{--} works just like @samp{++} except that -it subtracts 1 instead of adding. Like @samp{++}, it can be used before -the lvalue to pre-decrement or after it to post-decrement. - -Here is a summary of increment and decrement expressions. - -@table @code -@item ++@var{lvalue} -This expression increments @var{lvalue} and the new value becomes the -value of this expression. - -@item @var{lvalue}++ -This expression causes the contents of @var{lvalue} to be incremented. -The value of the expression is the @emph{old} value of @var{lvalue}. - -@item --@var{lvalue} -Like @code{++@var{lvalue}}, but instead of adding, it subtracts. It -decrements @var{lvalue} and delivers the value that results. - -@item @var{lvalue}-- -Like @code{@var{lvalue}++}, but instead of adding, it subtracts. It -decrements @var{lvalue}. The value of the expression is the @emph{old} -value of @var{lvalue}. -@end table - -@node Conversion, Values, Increment Ops, Expressions -@section Conversion of Strings and Numbers - -@cindex conversion of strings and numbers -Strings are converted to numbers, and numbers to strings, if the context -of the @code{awk} program demands it. For example, if the value of -either @code{foo} or @code{bar} in the expression @code{foo + bar} -happens to be a string, it is converted to a number before the addition -is performed. If numeric values appear in string concatenation, they -are converted to strings. Consider this:@refill - -@example -two = 2; three = 3 -print (two three) + 4 -@end example - -@noindent -This eventually prints the (numeric) value 27. The numeric values of -the variables @code{two} and @code{three} are converted to strings and -concatenated together, and the resulting string is converted back to the -number 23, to which 4 is then added. - -If, for some reason, you need to force a number to be converted to a -string, concatenate the null string with that number. To force a string -to be converted to a number, add zero to that string. - -A string is converted to a number by interpreting a numeric prefix -of the string as numerals: -@code{"2.5"} converts to 2.5, @code{"1e3"} converts to 1000, and @code{"25fix"} -has a numeric value of 25. -Strings that can't be interpreted as valid numbers are converted to -zero. - -@vindex CONVFMT -The exact manner in which numbers are converted into strings is controlled -by the @code{awk} built-in variable @code{CONVFMT} (@pxref{Built-in Variables}). -Numbers are converted using a special version of the @code{sprintf} function -(@pxref{Built-in, ,Built-in Functions}) with @code{CONVFMT} as the format -specifier.@refill - -@code{CONVFMT}'s default value is @code{"%.6g"}, which prints a value with -at least six significant digits. For some applications you will want to -change it to specify more precision. Double precision on most modern -machines gives you 16 or 17 decimal digits of precision. - -Strange results can happen if you set @code{CONVFMT} to a string that doesn't -tell @code{sprintf} how to format floating point numbers in a useful way. -For example, if you forget the @samp{%} in the format, all numbers will be -converted to the same constant string.@refill - -As a special case, if a number is an integer, then the result of converting -it to a string is @emph{always} an integer, no matter what the value of -@code{CONVFMT} may be. Given the following code fragment: - -@example -CONVFMT = "%2.2f" -a = 12 -b = a "" -@end example - -@noindent -@code{b} has the value @code{"12"}, not @code{"12.00"}. - -@ignore -For the 2.14 version, describe the ``stickyness'' of conversions. Right now -the manual assumes everywhere that variables are either numbers or strings; -in fact both kinds of values may be valid. If both happen to be valid, a -conversion isn't necessary and isn't done. Revising the manual to be -consistent with this, though, is too big a job to tackle at the moment. - -7/92: This has sort of been done, only the section isn't completely right! - What to do? -7/92: Pretty much fixed, at least for the short term, thanks to text - from David. -@end ignore - -@vindex OFMT -Prior to the @sc{posix} standard, @code{awk} specified that the value -of @code{OFMT} was used for converting numbers to strings. @code{OFMT} -specifies the output format to use when printing numbers with @code{print}. -@code{CONVFMT} was introduced in order to separate the semantics of -conversions from the semantics of printing. Both @code{CONVFMT} and -@code{OFMT} have the same default value: @code{"%.6g"}. In the vast majority -of cases, old @code{awk} programs will not change their behavior. -However, this use of @code{OFMT} is something to keep in mind if you must -port your program to other implementations of @code{awk}; we recommend -that instead of changing your programs, you just port @code{gawk} itself!@refill - -@node Values, Conditional Exp, Conversion, Expressions -@section Numeric and String Values -@cindex conversion of strings and numbers - -Through most of this manual, we present @code{awk} values (such as constants, -fields, or variables) as @emph{either} numbers @emph{or} strings. This is -a convenient way to think about them, since typically they are used in only -one way, or the other. - -In truth though, @code{awk} values can be @emph{both} string and -numeric, at the same time. Internally, @code{awk} represents values -with a string, a (floating point) number, and an indication that one, -the other, or both representations of the value are valid. - -Keeping track of both kinds of values is important for execution -efficiency: a variable can acquire a string value the first time it -is used as a string, and then that string value can be used until the -variable is assigned a new value. Thus, if a variable with only a numeric -value is used in several concatenations in a row, it only has to be given -a string representation once. The numeric value remains valid, so that -no conversion back to a number is necessary if the variable is later used -in an arithmetic expression. - -Tracking both kinds of values is also important for precise numerical -calculations. Consider the following: - -@smallexample -a = 123.321 -CONVFMT = "%3.1f" -b = a " is a number" -c = a + 1.654 -@end smallexample - -@noindent -The variable @code{a} receives a string value in the concatenation and -assignment to @code{b}. The string value of @code{a} is @code{"123.3"}. -If the numeric value was lost when it was converted to a string, then the -numeric use of @code{a} in the last statement would lose information. -@code{c} would be assigned the value 124.954 instead of 124.975. -Such errors accumulate rapidly, and very adversely affect numeric -computations.@refill - -Once a numeric value acquires a corresponding string value, it stays valid -until a new assignment is made. If @code{CONVFMT} -(@pxref{Conversion, ,Conversion of Strings and Numbers}) changes in the -meantime, the old string value will still be used. For example:@refill - -@smallexample -BEGIN @{ - CONVFMT = "%2.2f" - a = 123.456 - b = a "" # force `a' to have string value too - printf "a = %s\n", a - CONVFMT = "%.6g" - printf "a = %s\n", a - a += 0 # make `a' numeric only again - printf "a = %s\n", a # use `a' as string -@} -@end smallexample - -@noindent -This program prints @samp{a = 123.46} twice, and then prints -@samp{a = 123.456}. - -@xref{Conversion, ,Conversion of Strings and Numbers}, for the rules that -specify how string values are made from numeric values. - -@node Conditional Exp, Function Calls, Values, Expressions -@section Conditional Expressions -@cindex conditional expression -@cindex expression, conditional - -A @dfn{conditional expression} is a special kind of expression with -three operands. It allows you to use one expression's value to select -one of two other expressions. - -The conditional expression looks the same as in the C language: - -@example -@var{selector} ? @var{if-true-exp} : @var{if-false-exp} -@end example - -@noindent -There are three subexpressions. The first, @var{selector}, is always -computed first. If it is ``true'' (not zero and not null) then -@var{if-true-exp} is computed next and its value becomes the value of -the whole expression. Otherwise, @var{if-false-exp} is computed next -and its value becomes the value of the whole expression.@refill - -For example, this expression produces the absolute value of @code{x}: - -@example -x > 0 ? x : -x -@end example - -Each time the conditional expression is computed, exactly one of -@var{if-true-exp} and @var{if-false-exp} is computed; the other is ignored. -This is important when the expressions contain side effects. For example, -this conditional expression examines element @code{i} of either array -@code{a} or array @code{b}, and increments @code{i}. - -@example -x == y ? a[i++] : b[i++] -@end example - -@noindent -This is guaranteed to increment @code{i} exactly once, because each time -one or the other of the two increment expressions is executed, -and the other is not. - -@node Function Calls, Precedence, Conditional Exp, Expressions -@section Function Calls -@cindex function call -@cindex calling a function - -A @dfn{function} is a name for a particular calculation. Because it has -a name, you can ask for it by name at any point in the program. For -example, the function @code{sqrt} computes the square root of a number. - -A fixed set of functions are @dfn{built-in}, which means they are -available in every @code{awk} program. The @code{sqrt} function is one -of these. @xref{Built-in, ,Built-in Functions}, for a list of built-in -functions and their descriptions. In addition, you can define your own -functions in the program for use elsewhere in the same program. -@xref{User-defined, ,User-defined Functions}, for how to do this.@refill - -@cindex arguments in function call -The way to use a function is with a @dfn{function call} expression, -which consists of the function name followed by a list of -@dfn{arguments} in parentheses. The arguments are expressions which -give the raw materials for the calculation that the function will do. -When there is more than one argument, they are separated by commas. If -there are no arguments, write just @samp{()} after the function name. -Here are some examples: - -@example -sqrt(x^2 + y^2) # @r{One argument} -atan2(y, x) # @r{Two arguments} -rand() # @r{No arguments} -@end example - -@strong{Do not put any space between the function name and the -open-parenthesis!} A user-defined function name looks just like the name of -a variable, and space would make the expression look like concatenation -of a variable with an expression inside parentheses. Space before the -parenthesis is harmless with built-in functions, but it is best not to get -into the habit of using space to avoid mistakes with user-defined -functions. - -Each function expects a particular number of arguments. For example, the -@code{sqrt} function must be called with a single argument, the number -to take the square root of: - -@example -sqrt(@var{argument}) -@end example - -Some of the built-in functions allow you to omit the final argument. -If you do so, they use a reasonable default. -@xref{Built-in, ,Built-in Functions}, for full details. If arguments -are omitted in calls to user-defined functions, then those arguments are -treated as local variables, initialized to the null string -(@pxref{User-defined, ,User-defined Functions}).@refill - -Like every other expression, the function call has a value, which is -computed by the function based on the arguments you give it. In this -example, the value of @code{sqrt(@var{argument})} is the square root of the -argument. A function can also have side effects, such as assigning the -values of certain variables or doing I/O. - -Here is a command to read numbers, one number per line, and print the -square root of each one: - -@example -awk '@{ print "The square root of", $1, "is", sqrt($1) @}' -@end example - -@node Precedence, , Function Calls, Expressions -@section Operator Precedence (How Operators Nest) -@cindex precedence -@cindex operator precedence - -@dfn{Operator precedence} determines how operators are grouped, when -different operators appear close by in one expression. For example, -@samp{*} has higher precedence than @samp{+}; thus, @code{a + b * c} -means to multiply @code{b} and @code{c}, and then add @code{a} to the -product (i.e., @code{a + (b * c)}). - -You can overrule the precedence of the operators by using parentheses. -You can think of the precedence rules as saying where the -parentheses are assumed if you do not write parentheses yourself. In -fact, it is wise to always use parentheses whenever you have an unusual -combination of operators, because other people who read the program may -not remember what the precedence is in this case. You might forget, -too; then you could make a mistake. Explicit parentheses will help prevent -any such mistake. - -When operators of equal precedence are used together, the leftmost -operator groups first, except for the assignment, conditional and -exponentiation operators, which group in the opposite order. -Thus, @code{a - b + c} groups as @code{(a - b) + c}; -@code{a = b = c} groups as @code{a = (b = c)}.@refill - -The precedence of prefix unary operators does not matter as long as only -unary operators are involved, because there is only one way to parse -them---innermost first. Thus, @code{$++i} means @code{$(++i)} and -@code{++$x} means @code{++($x)}. However, when another operator follows -the operand, then the precedence of the unary operators can matter. -Thus, @code{$x^2} means @code{($x)^2}, but @code{-x^2} means -@code{-(x^2)}, because @samp{-} has lower precedence than @samp{^} -while @samp{$} has higher precedence. - -Here is a table of the operators of @code{awk}, in order of increasing -precedence: - -@table @asis -@item assignment -@samp{=}, @samp{+=}, @samp{-=}, @samp{*=}, @samp{/=}, @samp{%=}, -@samp{^=}, @samp{**=}. These operators group right-to-left. -(The @samp{**=} operator is not specified by @sc{posix}.) - -@item conditional -@samp{?:}. This operator groups right-to-left. - -@item logical ``or''. -@samp{||}. - -@item logical ``and''. -@samp{&&}. - -@item array membership -@samp{in}. - -@item matching -@samp{~}, @samp{!~}. - -@item relational, and redirection -The relational operators and the redirections have the same precedence -level. Characters such as @samp{>} serve both as relationals and as -redirections; the context distinguishes between the two meanings. - -The relational operators are @samp{<}, @samp{<=}, @samp{==}, @samp{!=}, -@samp{>=} and @samp{>}. - -The I/O redirection operators are @samp{<}, @samp{>}, @samp{>>} and -@samp{|}. - -Note that I/O redirection operators in @code{print} and @code{printf} -statements belong to the statement level, not to expressions. The -redirection does not produce an expression which could be the operand of -another operator. As a result, it does not make sense to use a -redirection operator near another operator of lower precedence, without -parentheses. Such combinations, for example @samp{print foo > a ? b : -c}, result in syntax errors. - -@item concatenation -No special token is used to indicate concatenation. -The operands are simply written side by side. - -@item add, subtract -@samp{+}, @samp{-}. - -@item multiply, divide, mod -@samp{*}, @samp{/}, @samp{%}. - -@item unary plus, minus, ``not'' -@samp{+}, @samp{-}, @samp{!}. - -@item exponentiation -@samp{^}, @samp{**}. These operators group right-to-left. -(The @samp{**} operator is not specified by @sc{posix}.) - -@item increment, decrement -@samp{++}, @samp{--}. - -@item field -@samp{$}. -@end table - -@node Statements, Arrays, Expressions, Top -@chapter Control Statements in Actions -@cindex control statement - -@dfn{Control statements} such as @code{if}, @code{while}, and so on -control the flow of execution in @code{awk} programs. Most of the -control statements in @code{awk} are patterned on similar statements in -C. - -All the control statements start with special keywords such as @code{if} -and @code{while}, to distinguish them from simple expressions. - -Many control statements contain other statements; for example, the -@code{if} statement contains another statement which may or may not be -executed. The contained statement is called the @dfn{body}. If you -want to include more than one statement in the body, group them into a -single compound statement with curly braces, separating them with -newlines or semicolons. - -@menu -* If Statement:: Conditionally execute - some @code{awk} statements. -* While Statement:: Loop until some condition is satisfied. -* Do Statement:: Do specified action while looping until some - condition is satisfied. -* For Statement:: Another looping statement, that provides - initialization and increment clauses. -* Break Statement:: Immediately exit the innermost enclosing loop. -* Continue Statement:: Skip to the end of the innermost - enclosing loop. -* Next Statement:: Stop processing the current input record. -* Next File Statement:: Stop processing the current file. -* Exit Statement:: Stop execution of @code{awk}. -@end menu - -@node If Statement, While Statement, Statements, Statements -@section The @code{if} Statement - -@cindex @code{if} statement -The @code{if}-@code{else} statement is @code{awk}'s decision-making -statement. It looks like this:@refill - -@example -if (@var{condition}) @var{then-body} @r{[}else @var{else-body}@r{]} -@end example - -@noindent -@var{condition} is an expression that controls what the rest of the -statement will do. If @var{condition} is true, @var{then-body} is -executed; otherwise, @var{else-body} is executed (assuming that the -@code{else} clause is present). The @code{else} part of the statement is -optional. The condition is considered false if its value is zero or -the null string, and true otherwise.@refill - -Here is an example: - -@example -if (x % 2 == 0) - print "x is even" -else - print "x is odd" -@end example - -In this example, if the expression @code{x % 2 == 0} is true (that is, -the value of @code{x} is divisible by 2), then the first @code{print} -statement is executed, otherwise the second @code{print} statement is -performed.@refill - -If the @code{else} appears on the same line as @var{then-body}, and -@var{then-body} is not a compound statement (i.e., not surrounded by -curly braces), then a semicolon must separate @var{then-body} from -@code{else}. To illustrate this, let's rewrite the previous example: - -@example -awk '@{ if (x % 2 == 0) print "x is even"; else - print "x is odd" @}' -@end example - -@noindent -If you forget the @samp{;}, @code{awk} won't be able to parse the -statement, and you will get a syntax error. - -We would not actually write this example this way, because a human -reader might fail to see the @code{else} if it were not the first thing -on its line. - -@node While Statement, Do Statement, If Statement, Statements -@section The @code{while} Statement -@cindex @code{while} statement -@cindex loop -@cindex body of a loop - -In programming, a @dfn{loop} means a part of a program that is (or at least can -be) executed two or more times in succession. - -The @code{while} statement is the simplest looping statement in -@code{awk}. It repeatedly executes a statement as long as a condition is -true. It looks like this: - -@example -while (@var{condition}) - @var{body} -@end example - -@noindent -Here @var{body} is a statement that we call the @dfn{body} of the loop, -and @var{condition} is an expression that controls how long the loop -keeps running. - -The first thing the @code{while} statement does is test @var{condition}. -If @var{condition} is true, it executes the statement @var{body}. -(@var{condition} is true when the value -is not zero and not a null string.) After @var{body} has been executed, -@var{condition} is tested again, and if it is still true, @var{body} is -executed again. This process repeats until @var{condition} is no longer -true. If @var{condition} is initially false, the body of the loop is -never executed.@refill - -This example prints the first three fields of each record, one per line. - -@example -awk '@{ i = 1 - while (i <= 3) @{ - print $i - i++ - @} -@}' -@end example - -@noindent -Here the body of the loop is a compound statement enclosed in braces, -containing two statements. - -The loop works like this: first, the value of @code{i} is set to 1. -Then, the @code{while} tests whether @code{i} is less than or equal to -three. This is the case when @code{i} equals one, so the @code{i}-th -field is printed. Then the @code{i++} increments the value of @code{i} -and the loop repeats. The loop terminates when @code{i} reaches 4. - -As you can see, a newline is not required between the condition and the -body; but using one makes the program clearer unless the body is a -compound statement or is very simple. The newline after the open-brace -that begins the compound statement is not required either, but the -program would be hard to read without it. - -@node Do Statement, For Statement, While Statement, Statements -@section The @code{do}-@code{while} Statement - -The @code{do} loop is a variation of the @code{while} looping statement. -The @code{do} loop executes the @var{body} once, then repeats @var{body} -as long as @var{condition} is true. It looks like this: - -@example -do - @var{body} -while (@var{condition}) -@end example - -Even if @var{condition} is false at the start, @var{body} is executed at -least once (and only once, unless executing @var{body} makes -@var{condition} true). Contrast this with the corresponding -@code{while} statement: - -@example -while (@var{condition}) - @var{body} -@end example - -@noindent -This statement does not execute @var{body} even once if @var{condition} -is false to begin with. - -Here is an example of a @code{do} statement: - -@example -awk '@{ i = 1 - do @{ - print $0 - i++ - @} while (i <= 10) -@}' -@end example - -@noindent -prints each input record ten times. It isn't a very realistic example, -since in this case an ordinary @code{while} would do just as well. But -this reflects actual experience; there is only occasionally a real use -for a @code{do} statement.@refill - -@node For Statement, Break Statement, Do Statement, Statements -@section The @code{for} Statement -@cindex @code{for} statement - -The @code{for} statement makes it more convenient to count iterations of a -loop. The general form of the @code{for} statement looks like this:@refill - -@example -for (@var{initialization}; @var{condition}; @var{increment}) - @var{body} -@end example - -@noindent -This statement starts by executing @var{initialization}. Then, as long -as @var{condition} is true, it repeatedly executes @var{body} and then -@var{increment}. Typically @var{initialization} sets a variable to -either zero or one, @var{increment} adds 1 to it, and @var{condition} -compares it against the desired number of iterations. - -Here is an example of a @code{for} statement: - -@example -@group -awk '@{ for (i = 1; i <= 3; i++) - print $i -@}' -@end group -@end example - -@noindent -This prints the first three fields of each input record, one field per -line. - -In the @code{for} statement, @var{body} stands for any statement, but -@var{initialization}, @var{condition} and @var{increment} are just -expressions. You cannot set more than one variable in the -@var{initialization} part unless you use a multiple assignment statement -such as @code{x = y = 0}, which is possible only if all the initial values -are equal. (But you can initialize additional variables by writing -their assignments as separate statements preceding the @code{for} loop.) - -The same is true of the @var{increment} part; to increment additional -variables, you must write separate statements at the end of the loop. -The C compound expression, using C's comma operator, would be useful in -this context, but it is not supported in @code{awk}. - -Most often, @var{increment} is an increment expression, as in the -example above. But this is not required; it can be any expression -whatever. For example, this statement prints all the powers of 2 -between 1 and 100: - -@example -for (i = 1; i <= 100; i *= 2) - print i -@end example - -Any of the three expressions in the parentheses following the @code{for} may -be omitted if there is nothing to be done there. Thus, @w{@samp{for (;x -> 0;)}} is equivalent to @w{@samp{while (x > 0)}}. If the -@var{condition} is omitted, it is treated as @var{true}, effectively -yielding an @dfn{infinite loop} (i.e., a loop that will never -terminate).@refill - -In most cases, a @code{for} loop is an abbreviation for a @code{while} -loop, as shown here: - -@example -@var{initialization} -while (@var{condition}) @{ - @var{body} - @var{increment} -@} -@end example - -@noindent -The only exception is when the @code{continue} statement -(@pxref{Continue Statement, ,The @code{continue} Statement}) is used -inside the loop; changing a @code{for} statement to a @code{while} -statement in this way can change the effect of the @code{continue} -statement inside the loop.@refill - -There is an alternate version of the @code{for} loop, for iterating over -all the indices of an array: - -@example -for (i in array) - @var{do something with} array[i] -@end example - -@noindent -@xref{Arrays, ,Arrays in @code{awk}}, for more information on this -version of the @code{for} loop. - -The @code{awk} language has a @code{for} statement in addition to a -@code{while} statement because often a @code{for} loop is both less work to -type and more natural to think of. Counting the number of iterations is -very common in loops. It can be easier to think of this counting as part -of looping rather than as something to do inside the loop. - -The next section has more complicated examples of @code{for} loops. - -@node Break Statement, Continue Statement, For Statement, Statements -@section The @code{break} Statement -@cindex @code{break} statement -@cindex loops, exiting - -The @code{break} statement jumps out of the innermost @code{for}, -@code{while}, or @code{do}-@code{while} loop that encloses it. The -following example finds the smallest divisor of any integer, and also -identifies prime numbers:@refill - -@smallexample -awk '# find smallest divisor of num - @{ num = $1 - for (div = 2; div*div <= num; div++) - if (num % div == 0) - break - if (num % div == 0) - printf "Smallest divisor of %d is %d\n", num, div - else - printf "%d is prime\n", num @}' -@end smallexample - -When the remainder is zero in the first @code{if} statement, @code{awk} -immediately @dfn{breaks out} of the containing @code{for} loop. This means -that @code{awk} proceeds immediately to the statement following the loop -and continues processing. (This is very different from the @code{exit} -statement which stops the entire @code{awk} program. -@xref{Exit Statement, ,The @code{exit} Statement}.)@refill - -Here is another program equivalent to the previous one. It illustrates how -the @var{condition} of a @code{for} or @code{while} could just as well be -replaced with a @code{break} inside an @code{if}: - -@smallexample -@group -awk '# find smallest divisor of num - @{ num = $1 - for (div = 2; ; div++) @{ - if (num % div == 0) @{ - printf "Smallest divisor of %d is %d\n", num, div - break - @} - if (div*div > num) @{ - printf "%d is prime\n", num - break - @} - @} -@}' -@end group -@end smallexample - -@node Continue Statement, Next Statement, Break Statement, Statements -@section The @code{continue} Statement - -@cindex @code{continue} statement -The @code{continue} statement, like @code{break}, is used only inside -@code{for}, @code{while}, and @code{do}-@code{while} loops. It skips -over the rest of the loop body, causing the next cycle around the loop -to begin immediately. Contrast this with @code{break}, which jumps out -of the loop altogether. Here is an example:@refill - -@example -# print names that don't contain the string "ignore" - -# first, save the text of each line -@{ names[NR] = $0 @} - -# print what we're interested in -END @{ - for (x in names) @{ - if (names[x] ~ /ignore/) - continue - print names[x] - @} -@} -@end example - -If one of the input records contains the string @samp{ignore}, this -example skips the print statement for that record, and continues back to -the first statement in the loop. - -This is not a practical example of @code{continue}, since it would be -just as easy to write the loop like this: - -@example -for (x in names) - if (names[x] !~ /ignore/) - print names[x] -@end example - -@ignore -from brennan@boeing.com: - -page 90, section 9.6. The example is too artificial as -the one line program - - !/ignore/ - -does the same thing. -@end ignore -@c ADR --- he's right, but don't worry about this for now - -The @code{continue} statement in a @code{for} loop directs @code{awk} to -skip the rest of the body of the loop, and resume execution with the -increment-expression of the @code{for} statement. The following program -illustrates this fact:@refill - -@example -awk 'BEGIN @{ - for (x = 0; x <= 20; x++) @{ - if (x == 5) - continue - printf ("%d ", x) - @} - print "" -@}' -@end example - -@noindent -This program prints all the numbers from 0 to 20, except for 5, for -which the @code{printf} is skipped. Since the increment @code{x++} -is not skipped, @code{x} does not remain stuck at 5. Contrast the -@code{for} loop above with the @code{while} loop: - -@example -awk 'BEGIN @{ - x = 0 - while (x <= 20) @{ - if (x == 5) - continue - printf ("%d ", x) - x++ - @} - print "" -@}' -@end example - -@noindent -This program loops forever once @code{x} gets to 5. - -As described above, the @code{continue} statement has no meaning when -used outside the body of a loop. However, although it was never documented, -historical implementations of @code{awk} have treated the @code{continue} -statement outside of a loop as if it were a @code{next} statement -(@pxref{Next Statement, ,The @code{next} Statement}). -By default, @code{gawk} silently supports this usage. However, if -@samp{-W posix} has been specified on the command line -(@pxref{Command Line, ,Invoking @code{awk}}), -it will be treated as an error, since the @sc{posix} standard specifies -that @code{continue} should only be used inside the body of a loop.@refill - -@node Next Statement, Next File Statement, Continue Statement, Statements -@section The @code{next} Statement -@cindex @code{next} statement - -The @code{next} statement forces @code{awk} to immediately stop processing -the current record and go on to the next record. This means that no -further rules are executed for the current record. The rest of the -current rule's action is not executed either. - -Contrast this with the effect of the @code{getline} function -(@pxref{Getline, ,Explicit Input with @code{getline}}). That too causes -@code{awk} to read the next record immediately, but it does not alter the -flow of control in any way. So the rest of the current action executes -with a new input record. - -At the highest level, @code{awk} program execution is a loop that reads -an input record and then tests each rule's pattern against it. If you -think of this loop as a @code{for} statement whose body contains the -rules, then the @code{next} statement is analogous to a @code{continue} -statement: it skips to the end of the body of this implicit loop, and -executes the increment (which reads another record). - -For example, if your @code{awk} program works only on records with four -fields, and you don't want it to fail when given bad input, you might -use this rule near the beginning of the program: - -@smallexample -NF != 4 @{ - printf("line %d skipped: doesn't have 4 fields", FNR) > "/dev/stderr" - next -@} -@end smallexample - -@noindent -so that the following rules will not see the bad record. The error -message is redirected to the standard error output stream, as error -messages should be. @xref{Special Files, ,Standard I/O Streams}. - -According to the @sc{posix} standard, the behavior is undefined if -the @code{next} statement is used in a @code{BEGIN} or @code{END} rule. -@code{gawk} will treat it as a syntax error. - -If the @code{next} statement causes the end of the input to be reached, -then the code in the @code{END} rules, if any, will be executed. -@xref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}. - -@node Next File Statement, Exit Statement, Next Statement, Statements -@section The @code{next file} Statement - -@cindex @code{next file} statement -The @code{next file} statement is similar to the @code{next} statement. -However, instead of abandoning processing of the current record, the -@code{next file} statement instructs @code{awk} to stop processing the -current data file. - -Upon execution of the @code{next file} statement, @code{FILENAME} is -updated to the name of the next data file listed on the command line, -@code{FNR} is reset to 1, and processing starts over with the first -rule in the progam. @xref{Built-in Variables}. - -If the @code{next file} statement causes the end of the input to be reached, -then the code in the @code{END} rules, if any, will be executed. -@xref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}. - -The @code{next file} statement is a @code{gawk} extension; it is not -(currently) available in any other @code{awk} implementation. You can -simulate its behavior by creating a library file named @file{nextfile.awk}, -with the following contents. (This sample program uses user-defined -functions, a feature that has not been presented yet. -@xref{User-defined, ,User-defined Functions}, -for more information.)@refill - -@smallexample -# nextfile --- function to skip remaining records in current file - -# this should be read in before the "main" awk program - -function nextfile() @{ _abandon_ = FILENAME; next @} - -_abandon_ == FILENAME && FNR > 1 @{ next @} -_abandon_ == FILENAME && FNR == 1 @{ _abandon_ = "" @} -@end smallexample - -The @code{nextfile} function simply sets a ``private'' variable@footnote{Since -all variables in @code{awk} are global, this program uses the common -practice of prefixing the variable name with an underscore. In fact, it -also suffixes the variable name with an underscore, as extra insurance -against using a variable name that might be used in some other library -file.} to the name of the current data file, and then retrieves the next -record. Since this file is read before the main @code{awk} program, -the rules that follows the function definition will be executed before the -rules in the main program. The first rule continues to skip records as long as -the name of the input file has not changed, and this is not the first -record in the file. This rule is sufficient most of the time. But what if -the @emph{same} data file is named twice in a row on the command line? -This rule would not process the data file the second time. The second rule -catches this case: If the data file name is what was being skipped, but -@code{FNR} is 1, then this is the second time the file is being processed, -and it should not be skipped. - -The @code{next file} statement would be useful if you have many data -files to process, and due to the nature of the data, you expect that you -would not want to process every record in the file. In order to move on to -the next data file, you would have to continue scanning the unwanted -records (as described above). The @code{next file} statement accomplishes -this much more efficiently. - -@ignore -Would it make sense down the road to nuke `next file' in favor of -semantics that would make this work? - - function nextfile() { ARGIND++ ; next } -@end ignore - -@node Exit Statement, , Next File Statement, Statements -@section The @code{exit} Statement - -@cindex @code{exit} statement -The @code{exit} statement causes @code{awk} to immediately stop -executing the current rule and to stop processing input; any remaining input -is ignored.@refill - -If an @code{exit} statement is executed from a @code{BEGIN} rule the -program stops processing everything immediately. No input records are -read. However, if an @code{END} rule is present, it is executed -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}). - -If @code{exit} is used as part of an @code{END} rule, it causes -the program to stop immediately. - -An @code{exit} statement that is part of an ordinary rule (that is, not part -of a @code{BEGIN} or @code{END} rule) stops the execution of any further -automatic rules, but the @code{END} rule is executed if there is one. -If you do not want the @code{END} rule to do its job in this case, you -can set a variable to nonzero before the @code{exit} statement, and check -that variable in the @code{END} rule. - -If an argument is supplied to @code{exit}, its value is used as the exit -status code for the @code{awk} process. If no argument is supplied, -@code{exit} returns status zero (success).@refill - -For example, let's say you've discovered an error condition you really -don't know how to handle. Conventionally, programs report this by -exiting with a nonzero status. Your @code{awk} program can do this -using an @code{exit} statement with a nonzero argument. Here's an -example of this:@refill - -@example -@group -BEGIN @{ - if (("date" | getline date_now) < 0) @{ - print "Can't get system date" > "/dev/stderr" - exit 4 - @} -@} -@end group -@end example - -@node Arrays, Built-in, Statements, Top -@chapter Arrays in @code{awk} - -An @dfn{array} is a table of values, called @dfn{elements}. The -elements of an array are distinguished by their indices. @dfn{Indices} -may be either numbers or strings. Each array has a name, which looks -like a variable name, but must not be in use as a variable name in the -same @code{awk} program. - -@menu -* Array Intro:: Introduction to Arrays -* Reference to Elements:: How to examine one element of an array. -* Assigning Elements:: How to change an element of an array. -* Array Example:: Basic Example of an Array -* Scanning an Array:: A variation of the @code{for} statement. - It loops through the indices of - an array's existing elements. -* Delete:: The @code{delete} statement removes - an element from an array. -* Numeric Array Subscripts:: How to use numbers as subscripts in @code{awk}. -* Multi-dimensional:: Emulating multi-dimensional arrays in @code{awk}. -* Multi-scanning:: Scanning multi-dimensional arrays. -@end menu - -@node Array Intro, Reference to Elements, Arrays, Arrays -@section Introduction to Arrays - -@cindex arrays -The @code{awk} language has one-dimensional @dfn{arrays} for storing groups -of related strings or numbers. - -Every @code{awk} array must have a name. Array names have the same -syntax as variable names; any valid variable name would also be a valid -array name. But you cannot use one name in both ways (as an array and -as a variable) in one @code{awk} program. - -Arrays in @code{awk} superficially resemble arrays in other programming -languages; but there are fundamental differences. In @code{awk}, you -don't need to specify the size of an array before you start to use it. -Additionally, any number or string in @code{awk} may be used as an -array index. - -In most other languages, you have to @dfn{declare} an array and specify -how many elements or components it contains. In such languages, the -declaration causes a contiguous block of memory to be allocated for that -many elements. An index in the array must be a positive integer; for -example, the index 0 specifies the first element in the array, which is -actually stored at the beginning of the block of memory. Index 1 -specifies the second element, which is stored in memory right after the -first element, and so on. It is impossible to add more elements to the -array, because it has room for only as many elements as you declared. - -A contiguous array of four elements might look like this, -conceptually, if the element values are @code{8}, @code{"foo"}, -@code{""} and @code{30}:@refill - -@example -+---------+---------+--------+---------+ -| 8 | "foo" | "" | 30 | @r{value} -+---------+---------+--------+---------+ - 0 1 2 3 @r{index} -@end example - -@noindent -Only the values are stored; the indices are implicit from the order of -the values. @code{8} is the value at index 0, because @code{8} appears in the -position with 0 elements before it. - -@cindex arrays, definition of -@cindex associative arrays -Arrays in @code{awk} are different: they are @dfn{associative}. This means -that each array is a collection of pairs: an index, and its corresponding -array element value: - -@example -@r{Element} 4 @r{Value} 30 -@r{Element} 2 @r{Value} "foo" -@r{Element} 1 @r{Value} 8 -@r{Element} 3 @r{Value} "" -@end example - -@noindent -We have shown the pairs in jumbled order because their order is irrelevant. - -One advantage of an associative array is that new pairs can be added -at any time. For example, suppose we add to the above array a tenth element -whose value is @w{@code{"number ten"}}. The result is this: - -@example -@r{Element} 10 @r{Value} "number ten" -@r{Element} 4 @r{Value} 30 -@r{Element} 2 @r{Value} "foo" -@r{Element} 1 @r{Value} 8 -@r{Element} 3 @r{Value} "" -@end example - -@noindent -Now the array is @dfn{sparse} (i.e., some indices are missing): it has -elements 1--4 and 10, but doesn't have elements 5, 6, 7, 8, or 9.@refill - -Another consequence of associative arrays is that the indices don't -have to be positive integers. Any number, or even a string, can be -an index. For example, here is an array which translates words from -English into French: - -@example -@r{Element} "dog" @r{Value} "chien" -@r{Element} "cat" @r{Value} "chat" -@r{Element} "one" @r{Value} "un" -@r{Element} 1 @r{Value} "un" -@end example - -@noindent -Here we decided to translate the number 1 in both spelled-out and -numeric form---thus illustrating that a single array can have both -numbers and strings as indices. - -When @code{awk} creates an array for you, e.g., with the @code{split} -built-in function, -that array's indices are consecutive integers starting at 1. -(@xref{String Functions, ,Built-in Functions for String Manipulation}.) - -@node Reference to Elements, Assigning Elements, Array Intro, Arrays -@section Referring to an Array Element -@cindex array reference -@cindex element of array -@cindex reference to array - -The principal way of using an array is to refer to one of its elements. -An array reference is an expression which looks like this: - -@example -@var{array}[@var{index}] -@end example - -@noindent -Here, @var{array} is the name of an array. The expression @var{index} is -the index of the element of the array that you want. - -The value of the array reference is the current value of that array -element. For example, @code{foo[4.3]} is an expression for the element -of array @code{foo} at index 4.3. - -If you refer to an array element that has no recorded value, the value -of the reference is @code{""}, the null string. This includes elements -to which you have not assigned any value, and elements that have been -deleted (@pxref{Delete, ,The @code{delete} Statement}). Such a reference -automatically creates that array element, with the null string as its value. -(In some cases, this is unfortunate, because it might waste memory inside -@code{awk}). - -@cindex arrays, presence of elements -You can find out if an element exists in an array at a certain index with -the expression: - -@example -@var{index} in @var{array} -@end example - -@noindent -This expression tests whether or not the particular index exists, -without the side effect of creating that element if it is not present. -The expression has the value 1 (true) if @code{@var{array}[@var{index}]} -exists, and 0 (false) if it does not exist.@refill - -For example, to test whether the array @code{frequencies} contains the -index @code{"2"}, you could write this statement:@refill - -@smallexample -if ("2" in frequencies) print "Subscript \"2\" is present." -@end smallexample - -Note that this is @emph{not} a test of whether or not the array -@code{frequencies} contains an element whose @emph{value} is @code{"2"}. -(There is no way to do that except to scan all the elements.) Also, this -@emph{does not} create @code{frequencies["2"]}, while the following -(incorrect) alternative would do so:@refill - -@smallexample -if (frequencies["2"] != "") print "Subscript \"2\" is present." -@end smallexample - -@node Assigning Elements, Array Example, Reference to Elements, Arrays -@section Assigning Array Elements -@cindex array assignment -@cindex element assignment - -Array elements are lvalues: they can be assigned values just like -@code{awk} variables: - -@example -@var{array}[@var{subscript}] = @var{value} -@end example - -@noindent -Here @var{array} is the name of your array. The expression -@var{subscript} is the index of the element of the array that you want -to assign a value. The expression @var{value} is the value you are -assigning to that element of the array.@refill - -@node Array Example, Scanning an Array, Assigning Elements, Arrays -@section Basic Example of an Array - -The following program takes a list of lines, each beginning with a line -number, and prints them out in order of line number. The line numbers are -not in order, however, when they are first read: they are scrambled. This -program sorts the lines by making an array using the line numbers as -subscripts. It then prints out the lines in sorted order of their numbers. -It is a very simple program, and gets confused if it encounters repeated -numbers, gaps, or lines that don't begin with a number.@refill - -@example -@{ - if ($1 > max) - max = $1 - arr[$1] = $0 -@} - -END @{ - for (x = 1; x <= max; x++) - print arr[x] -@} -@end example - -The first rule keeps track of the largest line number seen so far; -it also stores each line into the array @code{arr}, at an index that -is the line's number. - -The second rule runs after all the input has been read, to print out -all the lines. - -When this program is run with the following input: - -@example -5 I am the Five man -2 Who are you? The new number two! -4 . . . And four on the floor -1 Who is number one? -3 I three you. -@end example - -@noindent -its output is this: - -@example -1 Who is number one? -2 Who are you? The new number two! -3 I three you. -4 . . . And four on the floor -5 I am the Five man -@end example - -If a line number is repeated, the last line with a given number overrides -the others. - -Gaps in the line numbers can be handled with an easy improvement to the -program's @code{END} rule: - -@example -END @{ - for (x = 1; x <= max; x++) - if (x in arr) - print arr[x] -@} -@end example - -@node Scanning an Array, Delete, Array Example, Arrays -@section Scanning all Elements of an Array -@cindex @code{for (x in @dots{})} -@cindex arrays, special @code{for} statement -@cindex scanning an array - -In programs that use arrays, often you need a loop that executes -once for each element of an array. In other languages, where arrays are -contiguous and indices are limited to positive integers, this is -easy: the largest index is one less than the length of the array, and you can -find all the valid indices by counting from zero up to that value. This -technique won't do the job in @code{awk}, since any number or string -may be an array index. So @code{awk} has a special kind of @code{for} -statement for scanning an array: - -@example -for (@var{var} in @var{array}) - @var{body} -@end example - -@noindent -This loop executes @var{body} once for each different value that your -program has previously used as an index in @var{array}, with the -variable @var{var} set to that index.@refill - -Here is a program that uses this form of the @code{for} statement. The -first rule scans the input records and notes which words appear (at -least once) in the input, by storing a 1 into the array @code{used} with -the word as index. The second rule scans the elements of @code{used} to -find all the distinct words that appear in the input. It prints each -word that is more than 10 characters long, and also prints the number of -such words. @xref{Built-in, ,Built-in Functions}, for more information -on the built-in function @code{length}. - -@smallexample -# Record a 1 for each word that is used at least once. -@{ - for (i = 1; i <= NF; i++) - used[$i] = 1 -@} - -# Find number of distinct words more than 10 characters long. -END @{ - for (x in used) - if (length(x) > 10) @{ - ++num_long_words - print x - @} - print num_long_words, "words longer than 10 characters" -@} -@end smallexample - -@noindent -@xref{Sample Program}, for a more detailed example of this type. - -The order in which elements of the array are accessed by this statement -is determined by the internal arrangement of the array elements within -@code{awk} and cannot be controlled or changed. This can lead to -problems if new elements are added to @var{array} by statements in -@var{body}; you cannot predict whether or not the @code{for} loop will -reach them. Similarly, changing @var{var} inside the loop can produce -strange results. It is best to avoid such things.@refill - -@node Delete, Numeric Array Subscripts, Scanning an Array, Arrays -@section The @code{delete} Statement -@cindex @code{delete} statement -@cindex deleting elements of arrays -@cindex removing elements of arrays -@cindex arrays, deleting an element - -You can remove an individual element of an array using the @code{delete} -statement: - -@example -delete @var{array}[@var{index}] -@end example - -You can not refer to an array element after it has been deleted; -it is as if you had never referred -to it and had never given it any value. You can no longer obtain any -value the element once had. - -Here is an example of deleting elements in an array: - -@example -for (i in frequencies) - delete frequencies[i] -@end example - -@noindent -This example removes all the elements from the array @code{frequencies}. - -If you delete an element, a subsequent @code{for} statement to scan the array -will not report that element, and the @code{in} operator to check for -the presence of that element will return 0: - -@example -delete foo[4] -if (4 in foo) - print "This will never be printed" -@end example - -It is not an error to delete an element which does not exist. - -@node Numeric Array Subscripts, Multi-dimensional, Delete, Arrays -@section Using Numbers to Subscript Arrays - -An important aspect of arrays to remember is that array subscripts -are @emph{always} strings. If you use a numeric value as a subscript, -it will be converted to a string value before it is used for subscripting -(@pxref{Conversion, ,Conversion of Strings and Numbers}). - -@cindex conversions, during subscripting -@cindex numbers, used as subscripts -@vindex CONVFMT -This means that the value of the @code{CONVFMT} can potentially -affect how your program accesses elements of an array. For example: - -@example -a = b = 12.153 -data[a] = 1 -CONVFMT = "%2.2f" -if (b in data) - printf "%s is in data", b -else - printf "%s is not in data", b -@end example - -@noindent -should print @samp{12.15 is not in data}. The first statement gives -both @code{a} and @code{b} the same numeric value. Assigning to -@code{data[a]} first gives @code{a} the string value @code{"12.153"} -(using the default conversion value of @code{CONVFMT}, @code{"%.6g"}), -and then assigns 1 to @code{data["12.153"]}. The program then changes -the value of @code{CONVFMT}. The test @samp{(b in data)} forces @code{b} -to be converted to a string, this time @code{"12.15"}, since the value of -@code{CONVFMT} only allows two significant digits. This test fails, -since @code{"12.15"} is a different string from @code{"12.153"}.@refill - -According to the rules for conversions -(@pxref{Conversion, ,Conversion of Strings and Numbers}), integer -values are always converted to strings as integers, no matter what the -value of @code{CONVFMT} may happen to be. So the usual case of@refill - -@example -for (i = 1; i <= maxsub; i++) - @i{do something with} array[i] -@end example - -@noindent -will work, no matter what the value of @code{CONVFMT}. - -Like many things in @code{awk}, the majority of the time things work -as you would expect them to work. But it is useful to have a precise -knowledge of the actual rules, since sometimes they can have a subtle -effect on your programs. - -@node Multi-dimensional, Multi-scanning, Numeric Array Subscripts, Arrays -@section Multi-dimensional Arrays - -@c the following index entry is an overfull hbox. --mew 30jan1992 -@cindex subscripts in arrays -@cindex arrays, multi-dimensional subscripts -@cindex multi-dimensional subscripts -A multi-dimensional array is an array in which an element is identified -by a sequence of indices, not a single index. For example, a -two-dimensional array requires two indices. The usual way (in most -languages, including @code{awk}) to refer to an element of a -two-dimensional array named @code{grid} is with -@code{grid[@var{x},@var{y}]}. - -@vindex SUBSEP -Multi-dimensional arrays are supported in @code{awk} through -concatenation of indices into one string. What happens is that -@code{awk} converts the indices into strings -(@pxref{Conversion, ,Conversion of Strings and Numbers}) and -concatenates them together, with a separator between them. This creates -a single string that describes the values of the separate indices. The -combined string is used as a single index into an ordinary, -one-dimensional array. The separator used is the value of the built-in -variable @code{SUBSEP}.@refill - -For example, suppose we evaluate the expression @code{foo[5,12]="value"} -when the value of @code{SUBSEP} is @code{"@@"}. The numbers 5 and 12 are -converted to strings and -concatenated with an @samp{@@} between them, yielding @code{"5@@12"}; thus, -the array element @code{foo["5@@12"]} is set to @code{"value"}.@refill - -Once the element's value is stored, @code{awk} has no record of whether -it was stored with a single index or a sequence of indices. The two -expressions @code{foo[5,12]} and @w{@code{foo[5 SUBSEP 12]}} always have -the same value. - -The default value of @code{SUBSEP} is the string @code{"\034"}, -which contains a nonprinting character that is unlikely to appear in an -@code{awk} program or in the input data. - -The usefulness of choosing an unlikely character comes from the fact -that index values that contain a string matching @code{SUBSEP} lead to -combined strings that are ambiguous. Suppose that @code{SUBSEP} were -@code{"@@"}; then @w{@code{foo["a@@b", "c"]}} and @w{@code{foo["a", -"b@@c"]}} would be indistinguishable because both would actually be -stored as @code{foo["a@@b@@c"]}. Because @code{SUBSEP} is -@code{"\034"}, such confusion can arise only when an index -contains the character with ASCII code 034, which is a rare -event.@refill - -You can test whether a particular index-sequence exists in a -``multi-dimensional'' array with the same operator @code{in} used for single -dimensional arrays. Instead of a single index as the left-hand operand, -write the whole sequence of indices, separated by commas, in -parentheses:@refill - -@example -(@var{subscript1}, @var{subscript2}, @dots{}) in @var{array} -@end example - -The following example treats its input as a two-dimensional array of -fields; it rotates this array 90 degrees clockwise and prints the -result. It assumes that all lines have the same number of -elements. - -@example -awk '@{ - if (max_nf < NF) - max_nf = NF - max_nr = NR - for (x = 1; x <= NF; x++) - vector[x, NR] = $x -@} - -END @{ - for (x = 1; x <= max_nf; x++) @{ - for (y = max_nr; y >= 1; --y) - printf("%s ", vector[x, y]) - printf("\n") - @} -@}' -@end example - -@noindent -When given the input: - -@example -@group -1 2 3 4 5 6 -2 3 4 5 6 1 -3 4 5 6 1 2 -4 5 6 1 2 3 -@end group -@end example - -@noindent -it produces: - -@example -@group -4 3 2 1 -5 4 3 2 -6 5 4 3 -1 6 5 4 -2 1 6 5 -3 2 1 6 -@end group -@end example - -@node Multi-scanning, , Multi-dimensional, Arrays -@section Scanning Multi-dimensional Arrays - -There is no special @code{for} statement for scanning a -``multi-dimensional'' array; there cannot be one, because in truth there -are no multi-dimensional arrays or elements; there is only a -multi-dimensional @emph{way of accessing} an array. - -However, if your program has an array that is always accessed as -multi-dimensional, you can get the effect of scanning it by combining -the scanning @code{for} statement -(@pxref{Scanning an Array, ,Scanning all Elements of an Array}) with the -@code{split} built-in function -(@pxref{String Functions, ,Built-in Functions for String Manipulation}). -It works like this:@refill - -@example -for (combined in @var{array}) @{ - split(combined, separate, SUBSEP) - @dots{} -@} -@end example - -@noindent -This finds each concatenated, combined index in the array, and splits it -into the individual indices by breaking it apart where the value of -@code{SUBSEP} appears. The split-out indices become the elements of -the array @code{separate}. - -Thus, suppose you have previously stored in @code{@var{array}[1, -"foo"]}; then an element with index @code{"1\034foo"} exists in -@var{array}. (Recall that the default value of @code{SUBSEP} contains -the character with code 034.) Sooner or later the @code{for} statement -will find that index and do an iteration with @code{combined} set to -@code{"1\034foo"}. Then the @code{split} function is called as -follows: - -@example -split("1\034foo", separate, "\034") -@end example - -@noindent -The result of this is to set @code{separate[1]} to 1 and @code{separate[2]} -to @code{"foo"}. Presto, the original sequence of separate indices has -been recovered. - -@node Built-in, User-defined, Arrays, Top -@chapter Built-in Functions - -@cindex built-in functions -@dfn{Built-in} functions are functions that are always available for -your @code{awk} program to call. This chapter defines all the built-in -functions in @code{awk}; some of them are mentioned in other sections, -but they are summarized here for your convenience. (You can also define -new functions yourself. @xref{User-defined, ,User-defined Functions}.) - -@menu -* Calling Built-in:: How to call built-in functions. -* Numeric Functions:: Functions that work with numbers, - including @code{int}, @code{sin} and @code{rand}. -* String Functions:: Functions for string manipulation, - such as @code{split}, @code{match}, and @code{sprintf}. -* I/O Functions:: Functions for files and shell commands. -* Time Functions:: Functions for dealing with time stamps. -@end menu - -@node Calling Built-in, Numeric Functions, Built-in, Built-in -@section Calling Built-in Functions - -To call a built-in function, write the name of the function followed -by arguments in parentheses. For example, @code{atan2(y + z, 1)} -is a call to the function @code{atan2}, with two arguments. - -Whitespace is ignored between the built-in function name and the -open-parenthesis, but we recommend that you avoid using whitespace -there. User-defined functions do not permit whitespace in this way, and -you will find it easier to avoid mistakes by following a simple -convention which always works: no whitespace after a function name. - -Each built-in function accepts a certain number of arguments. In most -cases, any extra arguments given to built-in functions are ignored. The -defaults for omitted arguments vary from function to function and are -described under the individual functions. - -When a function is called, expressions that create the function's actual -parameters are evaluated completely before the function call is performed. -For example, in the code fragment: - -@example -i = 4 -j = sqrt(i++) -@end example - -@noindent -the variable @code{i} is set to 5 before @code{sqrt} is called -with a value of 4 for its actual parameter. - -@node Numeric Functions, String Functions, Calling Built-in, Built-in -@section Numeric Built-in Functions -@c I didn't make all the examples small because a couple of them were -@c short already. --mew 29jan1992 - -Here is a full list of built-in functions that work with numbers: - -@table @code -@item int(@var{x}) -This gives you the integer part of @var{x}, truncated toward 0. This -produces the nearest integer to @var{x}, located between @var{x} and 0. - -For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)} -is @minus{}3, and @code{int(-3)} is @minus{}3 as well.@refill - -@item sqrt(@var{x}) -This gives you the positive square root of @var{x}. It reports an error -if @var{x} is negative. Thus, @code{sqrt(4)} is 2.@refill - -@item exp(@var{x}) -This gives you the exponential of @var{x}, or reports an error if -@var{x} is out of range. The range of values @var{x} can have depends -on your machine's floating point representation.@refill - -@item log(@var{x}) -This gives you the natural logarithm of @var{x}, if @var{x} is positive; -otherwise, it reports an error.@refill - -@item sin(@var{x}) -This gives you the sine of @var{x}, with @var{x} in radians. - -@item cos(@var{x}) -This gives you the cosine of @var{x}, with @var{x} in radians. - -@item atan2(@var{y}, @var{x}) -This gives you the arctangent of @code{@var{y} / @var{x}} in radians. - -@item rand() -This gives you a random number. The values of @code{rand} are -uniformly-distributed between 0 and 1. The value is never 0 and never -1. - -Often you want random integers instead. Here is a user-defined function -you can use to obtain a random nonnegative integer less than @var{n}: - -@example -function randint(n) @{ - return int(n * rand()) -@} -@end example - -@noindent -The multiplication produces a random real number greater than 0 and less -than @var{n}. We then make it an integer (using @code{int}) between 0 -and @code{@var{n} @minus{} 1}. - -Here is an example where a similar function is used to produce -random integers between 1 and @var{n}. Note that this program will -print a new random number for each input record. - -@smallexample -awk ' -# Function to roll a simulated die. -function roll(n) @{ return 1 + int(rand() * n) @} - -# Roll 3 six-sided dice and print total number of points. -@{ - printf("%d points\n", roll(6)+roll(6)+roll(6)) -@}' -@end smallexample - -@strong{Note:} @code{rand} starts generating numbers from the same -point, or @dfn{seed}, each time you run @code{awk}. This means that -a program will produce the same results each time you run it. -The numbers are random within one @code{awk} run, but predictable -from run to run. This is convenient for debugging, but if you want -a program to do different things each time it is used, you must change -the seed to a value that will be different in each run. To do this, -use @code{srand}. - -@item srand(@var{x}) -The function @code{srand} sets the starting point, or @dfn{seed}, -for generating random numbers to the value @var{x}. - -Each seed value leads to a particular sequence of ``random'' numbers. -Thus, if you set the seed to the same value a second time, you will get -the same sequence of ``random'' numbers again. - -If you omit the argument @var{x}, as in @code{srand()}, then the current -date and time of day are used for a seed. This is the way to get random -numbers that are truly unpredictable. - -The return value of @code{srand} is the previous seed. This makes it -easy to keep track of the seeds for use in consistently reproducing -sequences of random numbers. -@end table - -@node String Functions, I/O Functions, Numeric Functions, Built-in -@section Built-in Functions for String Manipulation - -The functions in this section look at or change the text of one or more -strings. - -@table @code -@item index(@var{in}, @var{find}) -@findex match -This searches the string @var{in} for the first occurrence of the string -@var{find}, and returns the position in characters where that occurrence -begins in the string @var{in}. For example:@refill - -@smallexample -awk 'BEGIN @{ print index("peanut", "an") @}' -@end smallexample - -@noindent -prints @samp{3}. If @var{find} is not found, @code{index} returns 0. -(Remember that string indices in @code{awk} start at 1.) - -@item length(@var{string}) -@findex length -This gives you the number of characters in @var{string}. If -@var{string} is a number, the length of the digit string representing -that number is returned. For example, @code{length("abcde")} is 5. By -contrast, @code{length(15 * 35)} works out to 3. How? Well, 15 * 35 = -525, and 525 is then converted to the string @samp{"525"}, which has -three characters. - -If no argument is supplied, @code{length} returns the length of @code{$0}. - -In older versions of @code{awk}, you could call the @code{length} function -without any parentheses. Doing so is marked as ``deprecated'' in the -@sc{posix} standard. This means that while you can do this in your -programs, it is a feature that can eventually be removed from a future -version of the standard. Therefore, for maximal portability of your -@code{awk} programs you should always supply the parentheses. - -@item match(@var{string}, @var{regexp}) -@findex match -The @code{match} function searches the string, @var{string}, for the -longest, leftmost substring matched by the regular expression, -@var{regexp}. It returns the character position, or @dfn{index}, of -where that substring begins (1, if it starts at the beginning of -@var{string}). If no match if found, it returns 0. - -@vindex RSTART -@vindex RLENGTH -The @code{match} function sets the built-in variable @code{RSTART} to -the index. It also sets the built-in variable @code{RLENGTH} to the -length in characters of the matched substring. If no match is found, -@code{RSTART} is set to 0, and @code{RLENGTH} to @minus{}1. - -For example: - -@smallexample -awk '@{ - if ($1 == "FIND") - regex = $2 - else @{ - where = match($0, regex) - if (where) - print "Match of", regex, "found at", where, "in", $0 - @} -@}' -@end smallexample - -@noindent -This program looks for lines that match the regular expression stored in -the variable @code{regex}. This regular expression can be changed. If the -first word on a line is @samp{FIND}, @code{regex} is changed to be the -second word on that line. Therefore, given: - -@smallexample -FIND fo*bar -My program was a foobar -But none of it would doobar -FIND Melvin -JF+KM -This line is property of The Reality Engineering Co. -This file created by Melvin. -@end smallexample - -@noindent -@code{awk} prints: - -@smallexample -Match of fo*bar found at 18 in My program was a foobar -Match of Melvin found at 26 in This file created by Melvin. -@end smallexample - -@item split(@var{string}, @var{array}, @var{fieldsep}) -@findex split -This divides @var{string} into pieces separated by @var{fieldsep}, -and stores the pieces in @var{array}. The first piece is stored in -@code{@var{array}[1]}, the second piece in @code{@var{array}[2]}, and so -forth. The string value of the third argument, @var{fieldsep}, is -a regexp describing where to split @var{string} (much as @code{FS} can -be a regexp describing where to split input records). If -the @var{fieldsep} is omitted, the value of @code{FS} is used. -@code{split} returns the number of elements created.@refill - -The @code{split} function, then, splits strings into pieces in a -manner similar to the way input lines are split into fields. For example: - -@smallexample -split("auto-da-fe", a, "-") -@end smallexample - -@noindent -splits the string @samp{auto-da-fe} into three fields using @samp{-} as the -separator. It sets the contents of the array @code{a} as follows: - -@smallexample -a[1] = "auto" -a[2] = "da" -a[3] = "fe" -@end smallexample - -@noindent -The value returned by this call to @code{split} is 3. - -As with input field-splitting, when the value of @var{fieldsep} is -@code{" "}, leading and trailing whitespace is ignored, and the elements -are separated by runs of whitespace. - -@item sprintf(@var{format}, @var{expression1},@dots{}) -@findex sprintf -This returns (without printing) the string that @code{printf} would -have printed out with the same arguments -(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}). -For example:@refill - -@smallexample -sprintf("pi = %.2f (approx.)", 22/7) -@end smallexample - -@noindent -returns the string @w{@code{"pi = 3.14 (approx.)"}}. - -@item sub(@var{regexp}, @var{replacement}, @var{target}) -@findex sub -The @code{sub} function alters the value of @var{target}. -It searches this value, which should be a string, for the -leftmost substring matched by the regular expression, @var{regexp}, -extending this match as far as possible. Then the entire string is -changed by replacing the matched text with @var{replacement}. -The modified string becomes the new value of @var{target}. - -This function is peculiar because @var{target} is not simply -used to compute a value, and not just any expression will do: it -must be a variable, field or array reference, so that @code{sub} can -store a modified value there. If this argument is omitted, then the -default is to use and alter @code{$0}. - -For example:@refill - -@smallexample -str = "water, water, everywhere" -sub(/at/, "ith", str) -@end smallexample - -@noindent -sets @code{str} to @w{@code{"wither, water, everywhere"}}, by replacing the -leftmost, longest occurrence of @samp{at} with @samp{ith}. - -The @code{sub} function returns the number of substitutions made (either -one or zero). - -If the special character @samp{&} appears in @var{replacement}, it -stands for the precise substring that was matched by @var{regexp}. (If -the regexp can match more than one string, then this precise substring -may vary.) For example:@refill - -@smallexample -awk '@{ sub(/candidate/, "& and his wife"); print @}' -@end smallexample - -@noindent -changes the first occurrence of @samp{candidate} to @samp{candidate -and his wife} on each input line. - -Here is another example: - -@smallexample -awk 'BEGIN @{ - str = "daabaaa" - sub(/a*/, "c&c", str) - print str -@}' -@end smallexample - -@noindent -prints @samp{dcaacbaaa}. This show how @samp{&} can represent a non-constant -string, and also illustrates the ``leftmost, longest'' rule. - -The effect of this special character (@samp{&}) can be turned off by putting a -backslash before it in the string. As usual, to insert one backslash in -the string, you must write two backslashes. Therefore, write @samp{\\&} -in a string constant to include a literal @samp{&} in the replacement. -For example, here is how to replace the first @samp{|} on each line with -an @samp{&}:@refill - -@smallexample -awk '@{ sub(/\|/, "\\&"); print @}' -@end smallexample - -@strong{Note:} as mentioned above, the third argument to @code{sub} must -be an lvalue. Some versions of @code{awk} allow the third argument to -be an expression which is not an lvalue. In such a case, @code{sub} -would still search for the pattern and return 0 or 1, but the result of -the substitution (if any) would be thrown away because there is no place -to put it. Such versions of @code{awk} accept expressions like -this:@refill - -@smallexample -sub(/USA/, "United States", "the USA and Canada") -@end smallexample - -@noindent -But that is considered erroneous in @code{gawk}. - -@item gsub(@var{regexp}, @var{replacement}, @var{target}) -@findex gsub -This is similar to the @code{sub} function, except @code{gsub} replaces -@emph{all} of the longest, leftmost, @emph{nonoverlapping} matching -substrings it can find. The @samp{g} in @code{gsub} stands for -``global,'' which means replace everywhere. For example:@refill - -@smallexample -awk '@{ gsub(/Britain/, "United Kingdom"); print @}' -@end smallexample - -@noindent -replaces all occurrences of the string @samp{Britain} with @samp{United -Kingdom} for all input records.@refill - -The @code{gsub} function returns the number of substitutions made. If -the variable to be searched and altered, @var{target}, is -omitted, then the entire input record, @code{$0}, is used.@refill - -As in @code{sub}, the characters @samp{&} and @samp{\} are special, and -the third argument must be an lvalue. - -@item substr(@var{string}, @var{start}, @var{length}) -@findex substr -This returns a @var{length}-character-long substring of @var{string}, -starting at character number @var{start}. The first character of a -string is character number one. For example, -@code{substr("washington", 5, 3)} returns @code{"ing"}.@refill - -If @var{length} is not present, this function returns the whole suffix of -@var{string} that begins at character number @var{start}. For example, -@code{substr("washington", 5)} returns @code{"ington"}. This is also -the case if @var{length} is greater than the number of characters remaining -in the string, counting from character number @var{start}. - -@item tolower(@var{string}) -@findex tolower -This returns a copy of @var{string}, with each upper-case character -in the string replaced with its corresponding lower-case character. -Nonalphabetic characters are left unchanged. For example, -@code{tolower("MiXeD cAsE 123")} returns @code{"mixed case 123"}. - -@item toupper(@var{string}) -@findex toupper -This returns a copy of @var{string}, with each lower-case character -in the string replaced with its corresponding upper-case character. -Nonalphabetic characters are left unchanged. For example, -@code{toupper("MiXeD cAsE 123")} returns @code{"MIXED CASE 123"}. -@end table - -@node I/O Functions, Time Functions, String Functions, Built-in -@section Built-in Functions for Input/Output - -@table @code -@item close(@var{filename}) -Close the file @var{filename}, for input or output. The argument may -alternatively be a shell command that was used for redirecting to or -from a pipe; then the pipe is closed. - -@xref{Close Input, ,Closing Input Files and Pipes}, regarding closing -input files and pipes. @xref{Close Output, ,Closing Output Files and Pipes}, -regarding closing output files and pipes.@refill - -@item system(@var{command}) -@findex system -@c the following index entry is an overfull hbox. --mew 30jan1992 -@cindex interaction, @code{awk} and other programs -The system function allows the user to execute operating system commands -and then return to the @code{awk} program. The @code{system} function -executes the command given by the string @var{command}. It returns, as -its value, the status returned by the command that was executed. - -For example, if the following fragment of code is put in your @code{awk} -program: - -@smallexample -END @{ - system("mail -s 'awk run done' operator < /dev/null") -@} -@end smallexample - -@noindent -the system operator will be sent mail when the @code{awk} program -finishes processing input and begins its end-of-input processing. - -Note that much the same result can be obtained by redirecting -@code{print} or @code{printf} into a pipe. However, if your @code{awk} -program is interactive, @code{system} is useful for cranking up large -self-contained programs, such as a shell or an editor.@refill - -Some operating systems cannot implement the @code{system} function. -@code{system} causes a fatal error if it is not supported. -@end table - -@c fakenode --- for prepinfo -@subheading Controlling Output Buffering with @code{system} -@cindex flushing buffers -@cindex buffers, flushing -@cindex buffering output -@cindex output, buffering - -Many utility programs will @dfn{buffer} their output; they save information -to be written to a disk file or terminal in memory, until there is enough -to be written in one operation. This is often more efficient than writing -every little bit of information as soon as it is ready. However, sometimes -it is necessary to force a program to @dfn{flush} its buffers; that is, -write the information to its destination, even if a buffer is not full. -You can do this from your @code{awk} program by calling @code{system} -with a null string as its argument: - -@example -system("") # flush output -@end example - -@noindent -@code{gawk} treats this use of the @code{system} function as a special -case, and is smart enough not to run a shell (or other command -interpreter) with the empty command. Therefore, with @code{gawk}, this -idiom is not only useful, it is efficient. While this idiom should work -with other @code{awk} implementations, it will not necessarily avoid -starting an unnecessary shell. -@ignore -Need a better explanation, perhaps in a separate paragraph. Explain that -for - -awk 'BEGIN { print "hi" - system("echo hello") - print "howdy" }' - -that the output had better be - - hi - hello - howdy - -and not - - hello - hi - howdy - -which it would be if awk did not flush its buffers before calling system. -@end ignore - -@node Time Functions, , I/O Functions, Built-in -@section Functions for Dealing with Time Stamps - -@cindex time stamps -@cindex time of day -A common use for @code{awk} programs is the processing of log files. -Log files often contain time stamp information, indicating when a -particular log record was written. Many programs log their time stamp -in the form returned by the @code{time} system call, which is the -number of seconds since a particular epoch. On @sc{posix} systems, -it is the number of seconds since Midnight, January 1, 1970, @sc{utc}. - -In order to make it easier to process such log files, and to easily produce -useful reports, @code{gawk} provides two functions for working with time -stamps. Both of these are @code{gawk} extensions; they are not specified -in the @sc{posix} standard, nor are they in any other known version -of @code{awk}. - -@table @code -@item systime() -@findex systime -This function returns the current time as the number of seconds since -the system epoch. On @sc{posix} systems, this is the number of seconds -since Midnight, January 1, 1970, @sc{utc}. It may be a different number on -other systems. - -@item strftime(@var{format}, @var{timestamp}) -@findex strftime -This function returns a string. It is similar to the function of the -same name in the @sc{ansi} C standard library. The time specified by -@var{timestamp} is used to produce a string, based on the contents -of the @var{format} string. -@end table - -The @code{systime} function allows you to compare a time stamp from a -log file with the current time of day. In particular, it is easy to -determine how long ago a particular record was logged. It also allows -you to produce log records using the ``seconds since the epoch'' format. - -The @code{strftime} function allows you to easily turn a time stamp -into human-readable information. It is similar in nature to the @code{sprintf} -function, copying non-format specification characters verbatim to the -returned string, and substituting date and time values for format -specifications in the @var{format} string. If no @var{timestamp} argument -is supplied, @code{gawk} will use the current time of day as the -time stamp.@refill - -@code{strftime} is guaranteed by the @sc{ansi} C standard to support -the following date format specifications: - -@table @code -@item %a -The locale's abbreviated weekday name. - -@item %A -The locale's full weekday name. - -@item %b -The locale's abbreviated month name. - -@item %B -The locale's full month name. - -@item %c -The locale's ``appropriate'' date and time representation. - -@item %d -The day of the month as a decimal number (01--31). - -@item %H -The hour (24-hour clock) as a decimal number (00--23). - -@item %I -The hour (12-hour clock) as a decimal number (01--12). - -@item %j -The day of the year as a decimal number (001--366). - -@item %m -The month as a decimal number (01--12). - -@item %M -The minute as a decimal number (00--59). - -@item %p -The locale's equivalent of the AM/PM designations associated -with a 12-hour clock. - -@item %S -The second as a decimal number (00--61). (Occasionally there are -minutes in a year with one or two leap seconds, which is why the -seconds can go from 0 all the way to 61.) - -@item %U -The week number of the year (the first Sunday as the first day of week 1) -as a decimal number (00--53). - -@item %w -The weekday as a decimal number (0--6). Sunday is day 0. - -@item %W -The week number of the year (the first Monday as the first day of week 1) -as a decimal number (00--53). - -@item %x -The locale's ``appropriate'' date representation. - -@item %X -The locale's ``appropriate'' time representation. - -@item %y -The year without century as a decimal number (00--99). - -@item %Y -The year with century as a decimal number. - -@item %Z -The time zone name or abbreviation, or no characters if -no time zone is determinable. - -@item %% -A literal @samp{%}. -@end table - -@c The parenthetical remark here should really be a footnote, but -@c it gave formatting problems at the FSF. So for now put it in -@c parentheses. -If a conversion specifier is not one of the above, the behavior is -undefined. (This is because the @sc{ansi} standard for C leaves the -behavior of the C version of @code{strftime} undefined, and @code{gawk} -will use the system's version of @code{strftime} if it's there. -Typically, the conversion specifier will either not appear in the -returned string, or it will appear literally.) - -Informally, a @dfn{locale} is the geographic place in which a program -is meant to run. For example, a common way to abbreviate the date -September 4, 1991 in the United States would be ``9/4/91''. -In many countries in Europe, however, it would be abbreviated ``4.9.91''. -Thus, the @samp{%x} specification in a @code{"US"} locale might produce -@samp{9/4/91}, while in a @code{"EUROPE"} locale, it might produce -@samp{4.9.91}. The @sc{ansi} C standard defines a default @code{"C"} -locale, which is an environment that is typical of what most C programmers -are used to. - -A public-domain C version of @code{strftime} is shipped with @code{gawk} -for systems that are not yet fully @sc{ansi}-compliant. If that version is -used to compile @code{gawk} (@pxref{Installation, ,Installing @code{gawk}}), -then the following additional format specifications are available:@refill - -@table @code -@item %D -Equivalent to specifying @samp{%m/%d/%y}. - -@item %e -The day of the month, padded with a blank if it is only one digit. - -@item %h -Equivalent to @samp{%b}, above. - -@item %n -A newline character (ASCII LF). - -@item %r -Equivalent to specifying @samp{%I:%M:%S %p}. - -@item %R -Equivalent to specifying @samp{%H:%M}. - -@item %T -Equivalent to specifying @samp{%H:%M:%S}. - -@item %t -A TAB character. - -@item %k -is replaced by the hour (24-hour clock) as a decimal number (0-23). -Single digit numbers are padded with a blank. - -@item %l -is replaced by the hour (12-hour clock) as a decimal number (1-12). -Single digit numbers are padded with a blank. - -@item %C -The century, as a number between 00 and 99. - -@item %u -is replaced by the weekday as a decimal number -[1 (Monday)--7]. - -@item %V -is replaced by the week number of the year (the first Monday as the first -day of week 1) as a decimal number (01--53). -The method for determining the week number is as specified by ISO 8601 -(to wit: if the week containing January 1 has four or more days in the -new year, then it is week 1, otherwise it is week 53 of the previous year -and the next week is week 1).@refill - -@item %Ec %EC %Ex %Ey %EY %Od %Oe %OH %OI -@itemx %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy -These are ``alternate representations'' for the specifications -that use only the second letter (@samp{%c}, @samp{%C}, and so on). -They are recognized, but their normal representations are used. -(These facilitate compliance with the @sc{posix} @code{date} -utility.)@refill - -@item %v -The date in VMS format (e.g. 20-JUN-1991). -@end table - -Here are two examples that use @code{strftime}. The first is an -@code{awk} version of the C @code{ctime} function. (This is a -user defined function, which we have not discussed yet. -@xref{User-defined, ,User-defined Functions}, for more information.) - -@smallexample -# ctime.awk -# -# awk version of C ctime(3) function - -function ctime(ts, format) -@{ - format = "%a %b %e %H:%M:%S %Z %Y" - if (ts == 0) - ts = systime() # use current time as default - return strftime(format, ts) -@} -@end smallexample - -This next example is an @code{awk} implementation of the @sc{posix} -@code{date} utility. Normally, the @code{date} utility prints the -current date and time of day in a well known format. However, if you -provide an argument to it that begins with a @samp{+}, @code{date} -will copy non-format specifier characters to the standard output, and -will interpret the current time according to the format specifiers in -the string. For example: - -@smallexample -date '+Today is %A, %B %d, %Y.' -@end smallexample - -@noindent -might print - -@smallexample -Today is Thursday, July 11, 1991. -@end smallexample - -Here is the @code{awk} version of the @code{date} utility. - -@smallexample -#! /usr/bin/gawk -f -# -# date --- implement the P1003.2 Draft 11 'date' command -# -# Bug: does not recognize the -u argument. - -BEGIN \ -@{ - format = "%a %b %e %H:%M:%S %Z %Y" - exitval = 0 - - if (ARGC > 2) - exitval = 1 - else if (ARGC == 2) @{ - format = ARGV[1] - if (format ~ /^\+/) - format = substr(format, 2) # remove leading + - @} - print strftime(format) - exit exitval -@} -@end smallexample - -@node User-defined, Built-in Variables, Built-in, Top -@chapter User-defined Functions - -@cindex user-defined functions -@cindex functions, user-defined -Complicated @code{awk} programs can often be simplified by defining -your own functions. User-defined functions can be called just like -built-in ones (@pxref{Function Calls}), but it is up to you to define -them---to tell @code{awk} what they should do. - -@menu -* Definition Syntax:: How to write definitions and what they mean. -* Function Example:: An example function definition and - what it does. -* Function Caveats:: Things to watch out for. -* Return Statement:: Specifying the value a function returns. -@end menu - -@node Definition Syntax, Function Example, User-defined, User-defined -@section Syntax of Function Definitions -@cindex defining functions -@cindex function definition - -Definitions of functions can appear anywhere between the rules of the -@code{awk} program. Thus, the general form of an @code{awk} program is -extended to include sequences of rules @emph{and} user-defined function -definitions. - -The definition of a function named @var{name} looks like this: - -@example -function @var{name} (@var{parameter-list}) @{ - @var{body-of-function} -@} -@end example - -@noindent -@var{name} is the name of the function to be defined. A valid function -name is like a valid variable name: a sequence of letters, digits and -underscores, not starting with a digit. Functions share the same pool -of names as variables and arrays. - -@var{parameter-list} is a list of the function's arguments and local -variable names, separated by commas. When the function is called, -the argument names are used to hold the argument values given in -the call. The local variables are initialized to the null string. - -The @var{body-of-function} consists of @code{awk} statements. It is the -most important part of the definition, because it says what the function -should actually @emph{do}. The argument names exist to give the body a -way to talk about the arguments; local variables, to give the body -places to keep temporary values. - -Argument names are not distinguished syntactically from local variable -names; instead, the number of arguments supplied when the function is -called determines how many argument variables there are. Thus, if three -argument values are given, the first three names in @var{parameter-list} -are arguments, and the rest are local variables. - -It follows that if the number of arguments is not the same in all calls -to the function, some of the names in @var{parameter-list} may be -arguments on some occasions and local variables on others. Another -way to think of this is that omitted arguments default to the -null string. - -Usually when you write a function you know how many names you intend to -use for arguments and how many you intend to use as locals. By -convention, you should write an extra space between the arguments and -the locals, so other people can follow how your function is -supposed to be used. - -During execution of the function body, the arguments and local variable -values hide or @dfn{shadow} any variables of the same names used in the -rest of the program. The shadowed variables are not accessible in the -function definition, because there is no way to name them while their -names have been taken away for the local variables. All other variables -used in the @code{awk} program can be referenced or set normally in the -function definition. - -The arguments and local variables last only as long as the function body -is executing. Once the body finishes, the shadowed variables come back. - -The function body can contain expressions which call functions. They -can even call this function, either directly or by way of another -function. When this happens, we say the function is @dfn{recursive}. - -There is no need in @code{awk} to put the definition of a function -before all uses of the function. This is because @code{awk} reads the -entire program before starting to execute any of it. - -In many @code{awk} implementations, the keyword @code{function} may be -abbreviated @code{func}. However, @sc{posix} only specifies the use of -the keyword @code{function}. This actually has some practical implications. -If @code{gawk} is in @sc{posix}-compatibility mode -(@pxref{Command Line, ,Invoking @code{awk}}), then the following -statement will @emph{not} define a function:@refill - -@example -func foo() @{ a = sqrt($1) ; print a @} -@end example - -@noindent -Instead it defines a rule that, for each record, concatenates the value -of the variable @samp{func} with the return value of the function @samp{foo}, -and based on the truth value of the result, executes the corresponding action. -This is probably not what was desired. (@code{awk} accepts this input as -syntactically valid, since functions may be used before they are defined -in @code{awk} programs.) - -@node Function Example, Function Caveats, Definition Syntax, User-defined -@section Function Definition Example - -Here is an example of a user-defined function, called @code{myprint}, that -takes a number and prints it in a specific format. - -@example -function myprint(num) -@{ - printf "%6.3g\n", num -@} -@end example - -@noindent -To illustrate, here is an @code{awk} rule which uses our @code{myprint} -function: - -@example -$3 > 0 @{ myprint($3) @} -@end example - -@noindent -This program prints, in our special format, all the third fields that -contain a positive number in our input. Therefore, when given: - -@example - 1.2 3.4 5.6 7.8 - 9.10 11.12 -13.14 15.16 -17.18 19.20 21.22 23.24 -@end example - -@noindent -this program, using our function to format the results, prints: - -@example - 5.6 - 21.2 -@end example - -Here is a rather contrived example of a recursive function. It prints a -string backwards: - -@example -function rev (str, len) @{ - if (len == 0) @{ - printf "\n" - return - @} - printf "%c", substr(str, len, 1) - rev(str, len - 1) -@} -@end example - -@node Function Caveats, Return Statement, Function Example, User-defined -@section Calling User-defined Functions - -@dfn{Calling a function} means causing the function to run and do its job. -A function call is an expression, and its value is the value returned by -the function. - -A function call consists of the function name followed by the arguments -in parentheses. What you write in the call for the arguments are -@code{awk} expressions; each time the call is executed, these -expressions are evaluated, and the values are the actual arguments. For -example, here is a call to @code{foo} with three arguments (the first -being a string concatenation): - -@example -foo(x y, "lose", 4 * z) -@end example - -@quotation -@strong{Caution:} whitespace characters (spaces and tabs) are not allowed -between the function name and the open-parenthesis of the argument list. -If you write whitespace by mistake, @code{awk} might think that you mean -to concatenate a variable with an expression in parentheses. However, it -notices that you used a function name and not a variable name, and reports -an error. -@end quotation - -@cindex call by value -When a function is called, it is given a @emph{copy} of the values of -its arguments. This is called @dfn{call by value}. The caller may use -a variable as the expression for the argument, but the called function -does not know this: it only knows what value the argument had. For -example, if you write this code: - -@example -foo = "bar" -z = myfunc(foo) -@end example - -@noindent -then you should not think of the argument to @code{myfunc} as being -``the variable @code{foo}.'' Instead, think of the argument as the -string value, @code{"bar"}. - -If the function @code{myfunc} alters the values of its local variables, -this has no effect on any other variables. In particular, if @code{myfunc} -does this: - -@example -function myfunc (win) @{ - print win - win = "zzz" - print win -@} -@end example - -@noindent -to change its first argument variable @code{win}, this @emph{does not} -change the value of @code{foo} in the caller. The role of @code{foo} in -calling @code{myfunc} ended when its value, @code{"bar"}, was computed. -If @code{win} also exists outside of @code{myfunc}, the function body -cannot alter this outer value, because it is shadowed during the -execution of @code{myfunc} and cannot be seen or changed from there. - -@cindex call by reference -However, when arrays are the parameters to functions, they are @emph{not} -copied. Instead, the array itself is made available for direct manipulation -by the function. This is usually called @dfn{call by reference}. -Changes made to an array parameter inside the body of a function @emph{are} -visible outside that function. -@ifinfo -This can be @strong{very} dangerous if you do not watch what you are -doing. For example:@refill -@end ifinfo -@iftex -@emph{This can be very dangerous if you do not watch what you are -doing.} For example:@refill -@end iftex - -@example -function changeit (array, ind, nvalue) @{ - array[ind] = nvalue -@} - -BEGIN @{ - a[1] = 1 ; a[2] = 2 ; a[3] = 3 - changeit(a, 2, "two") - printf "a[1] = %s, a[2] = %s, a[3] = %s\n", a[1], a[2], a[3] - @} -@end example - -@noindent -prints @samp{a[1] = 1, a[2] = two, a[3] = 3}, because calling -@code{changeit} stores @code{"two"} in the second element of @code{a}. - -@node Return Statement, , Function Caveats, User-defined -@section The @code{return} Statement -@cindex @code{return} statement - -The body of a user-defined function can contain a @code{return} statement. -This statement returns control to the rest of the @code{awk} program. It -can also be used to return a value for use in the rest of the @code{awk} -program. It looks like this:@refill - -@example -return @var{expression} -@end example - -The @var{expression} part is optional. If it is omitted, then the returned -value is undefined and, therefore, unpredictable. - -A @code{return} statement with no value expression is assumed at the end of -every function definition. So if control reaches the end of the function -body, then the function returns an unpredictable value. @code{awk} -will not warn you if you use the return value of such a function; you will -simply get unpredictable or unexpected results. - -Here is an example of a user-defined function that returns a value -for the largest number among the elements of an array:@refill - -@example -@group -function maxelt (vec, i, ret) @{ - for (i in vec) @{ - if (ret == "" || vec[i] > ret) - ret = vec[i] - @} - return ret -@} -@end group -@end example - -@noindent -You call @code{maxelt} with one argument, which is an array name. The local -variables @code{i} and @code{ret} are not intended to be arguments; -while there is nothing to stop you from passing two or three arguments -to @code{maxelt}, the results would be strange. The extra space before -@code{i} in the function parameter list is to indicate that @code{i} and -@code{ret} are not supposed to be arguments. This is a convention which -you should follow when you define functions. - -Here is a program that uses our @code{maxelt} function. It loads an -array, calls @code{maxelt}, and then reports the maximum number in that -array:@refill - -@example -@group -awk ' -function maxelt (vec, i, ret) @{ - for (i in vec) @{ - if (ret == "" || vec[i] > ret) - ret = vec[i] - @} - return ret -@} -@end group - -@group -# Load all fields of each record into nums. -@{ - for(i = 1; i <= NF; i++) - nums[NR, i] = $i -@} - -END @{ - print maxelt(nums) -@}' -@end group -@end example - -Given the following input: - -@example -@group - 1 5 23 8 16 -44 3 5 2 8 26 -256 291 1396 2962 100 --6 467 998 1101 -99385 11 0 225 -@end group -@end example - -@noindent -our program tells us (predictably) that: - -@example -99385 -@end example - -@noindent -is the largest number in our array. - -@node Built-in Variables, Command Line, User-defined, Top -@chapter Built-in Variables -@cindex built-in variables - -Most @code{awk} variables are available for you to use for your own -purposes; they never change except when your program assigns values to -them, and never affect anything except when your program examines them. - -A few variables have special built-in meanings. Some of them @code{awk} -examines automatically, so that they enable you to tell @code{awk} how -to do certain things. Others are set automatically by @code{awk}, so -that they carry information from the internal workings of @code{awk} to -your program. - -This chapter documents all the built-in variables of @code{gawk}. Most -of them are also documented in the chapters where their areas of -activity are described. - -@menu -* User-modified:: Built-in variables that you change - to control @code{awk}. -* Auto-set:: Built-in variables where @code{awk} - gives you information. -@end menu - -@node User-modified, Auto-set, Built-in Variables, Built-in Variables -@section Built-in Variables that Control @code{awk} -@cindex built-in variables, user modifiable - -This is a list of the variables which you can change to control how -@code{awk} does certain things. - -@table @code -@iftex -@vindex CONVFMT -@end iftex -@item CONVFMT -This string is used by @code{awk} to control conversion of numbers to -strings (@pxref{Conversion, ,Conversion of Strings and Numbers}). -It works by being passed, in effect, as the first argument to the -@code{sprintf} function. Its default value is @code{"%.6g"}. -@code{CONVFMT} was introduced by the @sc{posix} standard.@refill - -@iftex -@vindex FIELDWIDTHS -@end iftex -@item FIELDWIDTHS -This is a space separated list of columns that tells @code{gawk} -how to manage input with fixed, columnar boundaries. It is an -experimental feature that is still evolving. Assigning to @code{FIELDWIDTHS} -overrides the use of @code{FS} for field splitting. -@xref{Constant Size, ,Reading Fixed-width Data}, for more information.@refill - -If @code{gawk} is in compatibility mode -(@pxref{Command Line, ,Invoking @code{awk}}), then @code{FIELDWIDTHS} -has no special meaning, and field splitting operations are done based -exclusively on the value of @code{FS}.@refill - -@iftex -@vindex FS -@end iftex -@item FS -@code{FS} is the input field separator -(@pxref{Field Separators, ,Specifying how Fields are Separated}). -The value is a single-character string or a multi-character regular -expression that matches the separations between fields in an input -record.@refill - -The default value is @w{@code{" "}}, a string consisting of a single -space. As a special exception, this value actually means that any -sequence of spaces and tabs is a single separator. It also causes -spaces and tabs at the beginning or end of a line to be ignored. - -You can set the value of @code{FS} on the command line using the -@samp{-F} option: - -@example -awk -F, '@var{program}' @var{input-files} -@end example - -If @code{gawk} is using @code{FIELDWIDTHS} for field-splitting, -assigning a value to @code{FS} will cause @code{gawk} to return to -the normal, regexp-based, field splitting. - -@item IGNORECASE -@iftex -@vindex IGNORECASE -@end iftex -If @code{IGNORECASE} is nonzero, then @emph{all} regular expression -matching is done in a case-independent fashion. In particular, regexp -matching with @samp{~} and @samp{!~}, and the @code{gsub} @code{index}, -@code{match}, @code{split} and @code{sub} functions all ignore case when -doing their particular regexp operations. @strong{Note:} since field -splitting with the value of the @code{FS} variable is also a regular -expression operation, that too is done with case ignored. -@xref{Case-sensitivity, ,Case-sensitivity in Matching}. - -If @code{gawk} is in compatibility mode -(@pxref{Command Line, ,Invoking @code{awk}}), then @code{IGNORECASE} has -no special meaning, and regexp operations are always case-sensitive.@refill - -@item OFMT -@iftex -@vindex OFMT -@end iftex -This string is used by @code{awk} to control conversion of numbers to -strings (@pxref{Conversion, ,Conversion of Strings and Numbers}) for -printing with the @code{print} statement. -It works by being passed, in effect, as the first argument to the -@code{sprintf} function. Its default value is @code{"%.6g"}. -Earlier versions of @code{awk} also used @code{OFMT} to specify the -format for converting numbers to strings in general expressions; this -has been taken over by @code{CONVFMT}.@refill - -@item OFS -@iftex -@vindex OFS -@end iftex -This is the output field separator (@pxref{Output Separators}). It is -output between the fields output by a @code{print} statement. Its -default value is @w{@code{" "}}, a string consisting of a single space. - -@item ORS -@iftex -@vindex ORS -@end iftex -This is the output record separator. It is output at the end of every -@code{print} statement. Its default value is a string containing a -single newline character, which could be written as @code{"\n"}. -(@xref{Output Separators}.)@refill - -@item RS -@iftex -@vindex RS -@end iftex -This is @code{awk}'s input record separator. Its default value is a string -containing a single newline character, which means that an input record -consists of a single line of text. -(@xref{Records, ,How Input is Split into Records}.)@refill - -@item SUBSEP -@iftex -@vindex SUBSEP -@end iftex -@code{SUBSEP} is the subscript separator. It has the default value of -@code{"\034"}, and is used to separate the parts of the name of a -multi-dimensional array. Thus, if you access @code{foo[12,3]}, it -really accesses @code{foo["12\0343"]} -(@pxref{Multi-dimensional, ,Multi-dimensional Arrays}).@refill -@end table - -@node Auto-set, , User-modified, Built-in Variables -@section Built-in Variables that Convey Information - -This is a list of the variables that are set automatically by @code{awk} -on certain occasions so as to provide information to your program. - -@table @code -@item ARGC -@itemx ARGV -@iftex -@vindex ARGC -@vindex ARGV -@end iftex -The command-line arguments available to @code{awk} programs are stored in -an array called @code{ARGV}. @code{ARGC} is the number of command-line -arguments present. @xref{Command Line, ,Invoking @code{awk}}. -@code{ARGV} is indexed from zero to @w{@code{ARGC - 1}}. For example:@refill - -@example -awk 'BEGIN @{ - for (i = 0; i < ARGC; i++) - print ARGV[i] - @}' inventory-shipped BBS-list -@end example - -@noindent -In this example, @code{ARGV[0]} contains @code{"awk"}, @code{ARGV[1]} -contains @code{"inventory-shipped"}, and @code{ARGV[2]} contains -@code{"BBS-list"}. The value of @code{ARGC} is 3, one more than the -index of the last element in @code{ARGV} since the elements are numbered -from zero.@refill - -The names @code{ARGC} and @code{ARGV}, as well the convention of indexing -the array from 0 to @w{@code{ARGC - 1}}, are derived from the C language's -method of accessing command line arguments.@refill - -Notice that the @code{awk} program is not entered in @code{ARGV}. The -other special command line options, with their arguments, are also not -entered. But variable assignments on the command line @emph{are} -treated as arguments, and do show up in the @code{ARGV} array. - -Your program can alter @code{ARGC} and the elements of @code{ARGV}. -Each time @code{awk} reaches the end of an input file, it uses the next -element of @code{ARGV} as the name of the next input file. By storing a -different string there, your program can change which files are read. -You can use @code{"-"} to represent the standard input. By storing -additional elements and incrementing @code{ARGC} you can cause -additional files to be read. - -If you decrease the value of @code{ARGC}, that eliminates input files -from the end of the list. By recording the old value of @code{ARGC} -elsewhere, your program can treat the eliminated arguments as -something other than file names. - -To eliminate a file from the middle of the list, store the null string -(@code{""}) into @code{ARGV} in place of the file's name. As a -special feature, @code{awk} ignores file names that have been -replaced with the null string. - -@ignore -see getopt.awk in the examples... -@end ignore - -@item ARGIND -@vindex ARGIND -The index in @code{ARGV} of the current file being processed. -Every time @code{gawk} opens a new data file for processing, it sets -@code{ARGIND} to the index in @code{ARGV} of the file name. Thus, the -condition @samp{FILENAME == ARGV[ARGIND]} is always true. - -This variable is useful in file processing; it allows you to tell how far -along you are in the list of data files, and to distinguish between -multiple successive instances of the same filename on the command line. - -While you can change the value of @code{ARGIND} within your @code{awk} -program, @code{gawk} will automatically set it to a new value when the -next file is opened. - -This variable is a @code{gawk} extension; in other @code{awk} implementations -it is not special. - -@item ENVIRON -@vindex ENVIRON -This is an array that contains the values of the environment. The array -indices are the environment variable names; the values are the values of -the particular environment variables. For example, -@code{ENVIRON["HOME"]} might be @file{/u/close}. Changing this array -does not affect the environment passed on to any programs that -@code{awk} may spawn via redirection or the @code{system} function. -(In a future version of @code{gawk}, it may do so.) - -Some operating systems may not have environment variables. -On such systems, the array @code{ENVIRON} is empty. - -@item ERRNO -@iftex -@vindex ERRNO -@end iftex -If a system error occurs either doing a redirection for @code{getline}, -during a read for @code{getline}, or during a @code{close} operation, -then @code{ERRNO} will contain a string describing the error. - -This variable is a @code{gawk} extension; in other @code{awk} implementations -it is not special. - -@item FILENAME -@iftex -@vindex FILENAME -@end iftex -This is the name of the file that @code{awk} is currently reading. -If @code{awk} is reading from the standard input (in other words, -there are no files listed on the command line), -@code{FILENAME} is set to @code{"-"}. -@code{FILENAME} is changed each time a new file is read -(@pxref{Reading Files, ,Reading Input Files}).@refill - -@item FNR -@iftex -@vindex FNR -@end iftex -@code{FNR} is the current record number in the current file. @code{FNR} is -incremented each time a new record is read -(@pxref{Getline, ,Explicit Input with @code{getline}}). It is reinitialized -to 0 each time a new input file is started.@refill - -@item NF -@iftex -@vindex NF -@end iftex -@code{NF} is the number of fields in the current input record. -@code{NF} is set each time a new record is read, when a new field is -created, or when @code{$0} changes (@pxref{Fields, ,Examining Fields}).@refill - -@item NR -@iftex -@vindex NR -@end iftex -This is the number of input records @code{awk} has processed since -the beginning of the program's execution. -(@pxref{Records, ,How Input is Split into Records}). -@code{NR} is set each time a new record is read.@refill - -@item RLENGTH -@iftex -@vindex RLENGTH -@end iftex -@code{RLENGTH} is the length of the substring matched by the -@code{match} function -(@pxref{String Functions, ,Built-in Functions for String Manipulation}). -@code{RLENGTH} is set by invoking the @code{match} function. Its value -is the length of the matched string, or @minus{}1 if no match was found.@refill - -@item RSTART -@iftex -@vindex RSTART -@end iftex -@code{RSTART} is the start-index in characters of the substring matched by the -@code{match} function -(@pxref{String Functions, ,Built-in Functions for String Manipulation}). -@code{RSTART} is set by invoking the @code{match} function. Its value -is the position of the string where the matched substring starts, or 0 -if no match was found.@refill -@end table - -@node Command Line, Language History, Built-in Variables, Top -@c node-name, next, previous, up -@chapter Invoking @code{awk} -@cindex command line -@cindex invocation of @code{gawk} -@cindex arguments, command line -@cindex options, command line -@cindex long options -@cindex options, long - -There are two ways to run @code{awk}: with an explicit program, or with -one or more program files. Here are templates for both of them; items -enclosed in @samp{@r{[}@dots{}@r{]}} in these templates are optional. - -Besides traditional one-letter @sc{posix}-style options, @code{gawk} also -supports GNU long named options. - -@example -awk @r{[@var{POSIX or GNU style options}]} -f progfile @r{[@code{--}]} @var{file} @dots{} -awk @r{[@var{POSIX or GNU style options}]} @r{[@code{--}]} '@var{program}' @var{file} @dots{} -@end example - -@menu -* Options:: Command line options and their meanings. -* Other Arguments:: Input file names and variable assignments. -* AWKPATH Variable:: Searching directories for @code{awk} programs. -* Obsolete:: Obsolete Options and/or features. -* Undocumented:: Undocumented Options and Features. -@end menu - -@node Options, Other Arguments, Command Line, Command Line -@section Command Line Options - -Options begin with a minus sign, and consist of a single character. -GNU style long named options consist of two minus signs and -a keyword that can be abbreviated if the abbreviation allows the option -to be uniquely identified. If the option takes an argument, then the -keyword is immediately followed by an equals sign (@samp{=}) and the -argument's value. For brevity, the discussion below only refers to the -traditional short options; however the long and short options are -interchangeable in all contexts. - -Each long named option for @code{gawk} has a corresponding -@sc{posix}-style option. The options and their meanings are as follows: - -@table @code -@item -F @var{fs} -@itemx --field-separator=@var{fs} -@iftex -@cindex @code{-F} option -@end iftex -@cindex @code{--field-separator} option -Sets the @code{FS} variable to @var{fs} -(@pxref{Field Separators, ,Specifying how Fields are Separated}).@refill - -@item -f @var{source-file} -@itemx --file=@var{source-file} -@iftex -@cindex @code{-f} option -@end iftex -@cindex @code{--file} option -Indicates that the @code{awk} program is to be found in @var{source-file} -instead of in the first non-option argument. - -@item -v @var{var}=@var{val} -@itemx --assign=@var{var}=@var{val} -@cindex @samp{-v} option -@cindex @code{--assign} option -Sets the variable @var{var} to the value @var{val} @emph{before} -execution of the program begins. Such variable values are available -inside the @code{BEGIN} rule (see below for a fuller explanation). - -The @samp{-v} option can only set one variable, but you can use -it more than once, setting another variable each time, like this: -@samp{@w{-v foo=1} @w{-v bar=2}}. - -@item -W @var{gawk-opt} -@cindex @samp{-W} option -Following the @sc{posix} standard, options that are implementation -specific are supplied as arguments to the @samp{-W} option. With @code{gawk}, -these arguments may be separated by commas, or quoted and separated by -whitespace. Case is ignored when processing these options. These options -also have corresponding GNU style long named options. The following -@code{gawk}-specific options are available: - -@table @code -@item -W compat -@itemx --compat -@cindex @code{--compat} option -Specifies @dfn{compatibility mode}, in which the GNU extensions in -@code{gawk} are disabled, so that @code{gawk} behaves just like Unix -@code{awk}. -@xref{POSIX/GNU, ,Extensions in @code{gawk} not in POSIX @code{awk}}, -which summarizes the extensions. Also see -@ref{Compatibility Mode, ,Downward Compatibility and Debugging}.@refill - -@item -W copyleft -@itemx -W copyright -@itemx --copyleft -@itemx --copyright -@cindex @code{--copyleft} option -@cindex @code{--copyright} option -Print the short version of the General Public License. -This option may disappear in a future version of @code{gawk}. - -@item -W help -@itemx -W usage -@itemx --help -@itemx --usage -@cindex @code{--help} option -@cindex @code{--usage} option -Print a ``usage'' message summarizing the short and long style options -that @code{gawk} accepts, and then exit. - -@item -W lint -@itemx --lint -@cindex @code{--lint} option -Provide warnings about constructs that are dubious or non-portable to -other @code{awk} implementations. -Some warnings are issued when @code{gawk} first reads your program. Others -are issued at run-time, as your program executes. - -@item -W posix -@itemx --posix -@cindex @code{--posix} option -Operate in strict @sc{posix} mode. This disables all @code{gawk} -extensions (just like @code{-W compat}), and adds the following additional -restrictions: - -@itemize @bullet{} -@item -@code{\x} escape sequences are not recognized -(@pxref{Constants, ,Constant Expressions}).@refill - -@item -The synonym @code{func} for the keyword @code{function} is not -recognized (@pxref{Definition Syntax, ,Syntax of Function Definitions}). - -@item -The operators @samp{**} and @samp{**=} cannot be used in -place of @samp{^} and @samp{^=} (@pxref{Arithmetic Ops, ,Arithmetic Operators}, -and also @pxref{Assignment Ops, ,Assignment Expressions}).@refill - -@item -Specifying @samp{-Ft} on the command line does not set the value -of @code{FS} to be a single tab character -(@pxref{Field Separators, ,Specifying how Fields are Separated}).@refill -@end itemize - -Although you can supply both @samp{-W compat} and @samp{-W posix} on the -command line, @samp{-W posix} will take precedence. - -@item -W source=@var{program-text} -@itemx --source=@var{program-text} -@cindex @code{--source} option -Program source code is taken from the @var{program-text}. This option -allows you to mix @code{awk} source code in files with program source -code that you would enter on the command line. This is particularly useful -when you have library functions that you wish to use from your command line -programs (@pxref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}). - -@item -W version -@itemx --version -@cindex @code{--version} option -Prints version information for this particular copy of @code{gawk}. -This is so you can determine if your copy of @code{gawk} is up to date -with respect to whatever the Free Software Foundation is currently -distributing. This option may disappear in a future version of @code{gawk}. -@end table - -@item -- -Signals the end of the command line options. The following arguments -are not treated as options even if they begin with @samp{-}. This -interpretation of @samp{--} follows the @sc{posix} argument parsing -conventions. - -This is useful if you have file names that start with @samp{-}, -or in shell scripts, if you have file names that will be specified -by the user which could start with @samp{-}. -@end table - -Any other options are flagged as invalid with a warning message, but -are otherwise ignored. - -In compatibility mode, as a special case, if the value of @var{fs} supplied -to the @samp{-F} option is @samp{t}, then @code{FS} is set to the tab -character (@code{"\t"}). This is only true for @samp{-W compat}, and not -for @samp{-W posix} -(@pxref{Field Separators, ,Specifying how Fields are Separated}).@refill - -If the @samp{-f} option is @emph{not} used, then the first non-option -command line argument is expected to be the program text. - -The @samp{-f} option may be used more than once on the command line. -If it is, @code{awk} reads its program source from all of the named files, as -if they had been concatenated together into one big file. This is -useful for creating libraries of @code{awk} functions. Useful functions -can be written once, and then retrieved from a standard place, instead -of having to be included into each individual program. You can still -type in a program at the terminal and use library functions, by specifying -@samp{-f /dev/tty}. @code{awk} will read a file from the terminal -to use as part of the @code{awk} program. After typing your program, -type @kbd{Control-d} (the end-of-file character) to terminate it. -(You may also use @samp{-f -} to read program source from the standard -input, but then you will not be able to also use the standard input as a -source of data.) - -Because it is clumsy using the standard @code{awk} mechanisms to mix source -file and command line @code{awk} programs, @code{gawk} provides the -@samp{--source} option. This does not require you to pre-empt the standard -input for your source code, and allows you to easily mix command line -and library source code -(@pxref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}). - -If no @samp{-f} or @samp{--source} option is specified, then @code{gawk} -will use the first non-option command line argument as the text of the -program source code. - -@node Other Arguments, AWKPATH Variable, Options, Command Line -@section Other Command Line Arguments - -Any additional arguments on the command line are normally treated as -input files to be processed in the order specified. However, an -argument that has the form @code{@var{var}=@var{value}}, means to assign -the value @var{value} to the variable @var{var}---it does not specify a -file at all. - -@vindex ARGV -All these arguments are made available to your @code{awk} program in the -@code{ARGV} array (@pxref{Built-in Variables}). Command line options -and the program text (if present) are omitted from the @code{ARGV} -array. All other arguments, including variable assignments, are -included. - -The distinction between file name arguments and variable-assignment -arguments is made when @code{awk} is about to open the next input file. -At that point in execution, it checks the ``file name'' to see whether -it is really a variable assignment; if so, @code{awk} sets the variable -instead of reading a file. - -Therefore, the variables actually receive the specified values after all -previously specified files have been read. In particular, the values of -variables assigned in this fashion are @emph{not} available inside a -@code{BEGIN} rule -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}), -since such rules are run before @code{awk} begins scanning the argument list. -The values given on the command line are processed for escape sequences -(@pxref{Constants, ,Constant Expressions}).@refill - -In some earlier implementations of @code{awk}, when a variable assignment -occurred before any file names, the assignment would happen @emph{before} -the @code{BEGIN} rule was executed. Some applications came to depend -upon this ``feature.'' When @code{awk} was changed to be more consistent, -the @samp{-v} option was added to accommodate applications that depended -upon this old behavior. - -The variable assignment feature is most useful for assigning to variables -such as @code{RS}, @code{OFS}, and @code{ORS}, which control input and -output formats, before scanning the data files. It is also useful for -controlling state if multiple passes are needed over a data file. For -example:@refill - -@cindex multiple passes over data -@cindex passes, multiple -@smallexample -awk 'pass == 1 @{ @var{pass 1 stuff} @} - pass == 2 @{ @var{pass 2 stuff} @}' pass=1 datafile pass=2 datafile -@end smallexample - -Given the variable assignment feature, the @samp{-F} option is not -strictly necessary. It remains for historical compatibility. - -@node AWKPATH Variable, Obsolete, Other Arguments, Command Line -@section The @code{AWKPATH} Environment Variable -@cindex @code{AWKPATH} environment variable -@cindex search path -@cindex directory search -@cindex path, search -@iftex -@cindex differences between @code{gawk} and @code{awk} -@end iftex - -The previous section described how @code{awk} program files can be named -on the command line with the @samp{-f} option. In some @code{awk} -implementations, you must supply a precise path name for each program -file, unless the file is in the current directory. - -But in @code{gawk}, if the file name supplied in the @samp{-f} option -does not contain a @samp{/}, then @code{gawk} searches a list of -directories (called the @dfn{search path}), one by one, looking for a -file with the specified name. - -The search path is actually a string consisting of directory names -separated by colons. @code{gawk} gets its search path from the -@code{AWKPATH} environment variable. If that variable does not exist, -@code{gawk} uses the default path, which is -@samp{.:/usr/lib/awk:/usr/local/lib/awk}. (Programs written by -system administrators should use an @code{AWKPATH} variable that -does not include the current directory, @samp{.}.)@refill - -The search path feature is particularly useful for building up libraries -of useful @code{awk} functions. The library files can be placed in a -standard directory that is in the default path, and then specified on -the command line with a short file name. Otherwise, the full file name -would have to be typed for each file. - -By combining the @samp{--source} and @samp{-f} options, your command line -@code{awk} programs can use facilities in @code{awk} library files. - -Path searching is not done if @code{gawk} is in compatibility mode. -This is true for both @samp{-W compat} and @samp{-W posix}. -@xref{Options, ,Command Line Options}. - -@strong{Note:} if you want files in the current directory to be found, -you must include the current directory in the path, either by writing -@file{.} as an entry in the path, or by writing a null entry in the -path. (A null entry is indicated by starting or ending the path with a -colon, or by placing two colons next to each other (@samp{::}).) If the -current directory is not included in the path, then files cannot be -found in the current directory. This path search mechanism is identical -to the shell's. -@c someday, @cite{The Bourne Again Shell}.... - -@node Obsolete, Undocumented, AWKPATH Variable, Command Line -@section Obsolete Options and/or Features - -@cindex deprecated options -@cindex obsolete options -@cindex deprecated features -@cindex obsolete features -This section describes features and/or command line options from the -previous release of @code{gawk} that are either not available in the -current version, or that are still supported but deprecated (meaning that -they will @emph{not} be in the next release). - -@c update this section for each release! - -For version 2.15 of @code{gawk}, the following command line options -from version 2.11.1 are no longer recognized. - -@table @samp -@ignore -@item -nostalgia -Use @samp{-W nostalgia} instead. -@end ignore - -@item -c -Use @samp{-W compat} instead. - -@item -V -Use @samp{-W version} instead. - -@item -C -Use @samp{-W copyright} instead. - -@item -a -@itemx -e -These options produce an ``unrecognized option'' error message but have -no effect on the execution of @code{gawk}. The @sc{posix} standard now -specifies traditional @code{awk} regular expressions for the @code{awk} utility. -@end table - -The public-domain version of @code{strftime} that is distributed with -@code{gawk} changed for the 2.14 release. The @samp{%V} conversion specifier -that used to generate the date in VMS format was changed to @samp{%v}. -This is because the @sc{posix} standard for the @code{date} utility now -specifies a @samp{%V} conversion specifier. -@xref{Time Functions, ,Functions for Dealing with Time Stamps}, for details. - -@node Undocumented, , Obsolete, Command Line -@section Undocumented Options and Features - -This section intentionally left blank. - -@c Read The Source, Luke! - -@ignore -@c If these came out in the Info file or TeX manual, then they wouldn't -@c be undocumented, would they? - -@code{gawk} has one undocumented option: - -@table @samp -@item -W nostalgia -Print the message @code{"awk: bailing out near line 1"} and dump core. -This option was inspired by the common behavior of very early versions of -Unix @code{awk}, and by a t--shirt. -@end table - -Early versions of @code{awk} used to not require any separator (either -a newline or @samp{;}) between the rules in @code{awk} programs. Thus, -it was common to see one-line programs like: - -@example -awk '@{ sum += $1 @} END @{ print sum @}' -@end example - -@code{gawk} actually supports this, but it is purposely undocumented -since it is considered bad style. The correct way to write such a program -is either - -@example -awk '@{ sum += $1 @} ; END @{ print sum @}' -@end example - -@noindent -or - -@example -awk '@{ sum += $1 @} - END @{ print sum @}' data -@end example - -@noindent -@xref{Statements/Lines, ,@code{awk} Statements versus Lines}, for a fuller -explanation.@refill - -As an accident of the implementation of the original Unix @code{awk}, if -a built-in function used @code{$0} as its default argument, it was possible -to call that function without the parentheses. In particular, it was -common practice to use the @code{length} function in this fashion. -For example, the pipeline: - -@example -echo abcdef | awk '@{ print length @}' -@end example - -@noindent -would print @samp{6}. - -For backwards compatibility with old programs, @code{gawk} supports -this usage, but only for the @code{length} function. New programs should -@emph{not} call the @code{length} function this way. In particular, -this usage will not be portable to other @sc{posix} compliant versions -of @code{awk}. It is also poor style. - -@end ignore - -@node Language History, Installation, Command Line, Top -@chapter The Evolution of the @code{awk} Language - -This manual describes the GNU implementation of @code{awk}, which is patterned -after the @sc{posix} specification. Many @code{awk} users are only familiar -with the original @code{awk} implementation in Version 7 Unix, which is also -the basis for the version in Berkeley Unix (through 4.3--Reno). This chapter -briefly describes the evolution of the @code{awk} language. - -@menu -* V7/S5R3.1:: The major changes between V7 and - System V Release 3.1. -* S5R4:: Minor changes between System V - Releases 3.1 and 4. -* POSIX:: New features from the @sc{posix} standard. -* POSIX/GNU:: The extensions in @code{gawk} - not in @sc{posix} @code{awk}. -@end menu - -@node V7/S5R3.1, S5R4, Language History, Language History -@section Major Changes between V7 and S5R3.1 - -The @code{awk} language evolved considerably between the release of -Version 7 Unix (1978) and the new version first made widely available in -System V Release 3.1 (1987). This section summarizes the changes, with -cross-references to further details. - -@itemize @bullet -@item -The requirement for @samp{;} to separate rules on a line -(@pxref{Statements/Lines, ,@code{awk} Statements versus Lines}). - -@item -User-defined functions, and the @code{return} statement -(@pxref{User-defined, ,User-defined Functions}). - -@item -The @code{delete} statement (@pxref{Delete, ,The @code{delete} Statement}). - -@item -The @code{do}-@code{while} statement -(@pxref{Do Statement, ,The @code{do}-@code{while} Statement}).@refill - -@item -The built-in functions @code{atan2}, @code{cos}, @code{sin}, @code{rand} and -@code{srand} (@pxref{Numeric Functions, ,Numeric Built-in Functions}). - -@item -The built-in functions @code{gsub}, @code{sub}, and @code{match} -(@pxref{String Functions, ,Built-in Functions for String Manipulation}). - -@item -The built-in functions @code{close}, which closes an open file, and -@code{system}, which allows the user to execute operating system -commands (@pxref{I/O Functions, ,Built-in Functions for Input/Output}).@refill -@c Does the above verbiage prevents an overfull hbox? --mew, rjc 24jan1992 - -@item -The @code{ARGC}, @code{ARGV}, @code{FNR}, @code{RLENGTH}, @code{RSTART}, -and @code{SUBSEP} built-in variables (@pxref{Built-in Variables}). - -@item -The conditional expression using the operators @samp{?} and @samp{:} -(@pxref{Conditional Exp, ,Conditional Expressions}).@refill - -@item -The exponentiation operator @samp{^} -(@pxref{Arithmetic Ops, ,Arithmetic Operators}) and its assignment operator -form @samp{^=} (@pxref{Assignment Ops, ,Assignment Expressions}).@refill - -@item -C-compatible operator precedence, which breaks some old @code{awk} -programs (@pxref{Precedence, ,Operator Precedence (How Operators Nest)}). - -@item -Regexps as the value of @code{FS} -(@pxref{Field Separators, ,Specifying how Fields are Separated}), and as the -third argument to the @code{split} function -(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill - -@item -Dynamic regexps as operands of the @samp{~} and @samp{!~} operators -(@pxref{Regexp Usage, ,How to Use Regular Expressions}). - -@item -Escape sequences (@pxref{Constants, ,Constant Expressions}) in regexps.@refill - -@item -The escape sequences @samp{\b}, @samp{\f}, and @samp{\r} -(@pxref{Constants, ,Constant Expressions}). - -@item -Redirection of input for the @code{getline} function -(@pxref{Getline, ,Explicit Input with @code{getline}}).@refill - -@item -Multiple @code{BEGIN} and @code{END} rules -(@pxref{BEGIN/END, ,@code{BEGIN} and @code{END} Special Patterns}).@refill - -@item -Simulated multi-dimensional arrays -(@pxref{Multi-dimensional, ,Multi-dimensional Arrays}).@refill -@end itemize - -@node S5R4, POSIX, V7/S5R3.1, Language History -@section Changes between S5R3.1 and S5R4 - -The System V Release 4 version of Unix @code{awk} added these features -(some of which originated in @code{gawk}): - -@itemize @bullet -@item -The @code{ENVIRON} variable (@pxref{Built-in Variables}). - -@item -Multiple @samp{-f} options on the command line -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@item -The @samp{-v} option for assigning variables before program execution begins -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@item -The @samp{--} option for terminating command line options. - -@item -The @samp{\a}, @samp{\v}, and @samp{\x} escape sequences -(@pxref{Constants, ,Constant Expressions}).@refill - -@item -A defined return value for the @code{srand} built-in function -(@pxref{Numeric Functions, ,Numeric Built-in Functions}). - -@item -The @code{toupper} and @code{tolower} built-in string functions -for case translation -(@pxref{String Functions, ,Built-in Functions for String Manipulation}).@refill - -@item -A cleaner specification for the @samp{%c} format-control letter in the -@code{printf} function -(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}).@refill - -@item -The ability to dynamically pass the field width and precision (@code{"%*.*d"}) -in the argument list of the @code{printf} function -(@pxref{Printf, ,Using @code{printf} Statements for Fancier Printing}).@refill - -@item -The use of constant regexps such as @code{/foo/} as expressions, where -they are equivalent to use of the matching operator, as in @code{$0 ~ -/foo/} (@pxref{Constants, ,Constant Expressions}). -@end itemize - -@node POSIX, POSIX/GNU, S5R4, Language History -@section Changes between S5R4 and POSIX @code{awk} - -The @sc{posix} Command Language and Utilities standard for @code{awk} -introduced the following changes into the language: - -@itemize @bullet{} -@item -The use of @samp{-W} for implementation-specific options. - -@item -The use of @code{CONVFMT} for controlling the conversion of numbers -to strings (@pxref{Conversion, ,Conversion of Strings and Numbers}). - -@item -The concept of a numeric string, and tighter comparison rules to go -with it (@pxref{Comparison Ops, ,Comparison Expressions}). - -@item -More complete documentation of many of the previously undocumented -features of the language. -@end itemize - -@node POSIX/GNU, , POSIX, Language History -@section Extensions in @code{gawk} not in POSIX @code{awk} - -The GNU implementation, @code{gawk}, adds these features: - -@itemize @bullet -@item -The @code{AWKPATH} environment variable for specifying a path search for -the @samp{-f} command line option -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@item -The various @code{gawk} specific features available via the @samp{-W} -command line option (@pxref{Command Line, ,Invoking @code{awk}}). - -@item -The @code{ARGIND} variable, that tracks the movement of @code{FILENAME} -through @code{ARGV}. (@pxref{Built-in Variables}). - -@item -The @code{ERRNO} variable, that contains the system error message when -@code{getline} returns @minus{}1, or when @code{close} fails. -(@pxref{Built-in Variables}). - -@item -The @code{IGNORECASE} variable and its effects -(@pxref{Case-sensitivity, ,Case-sensitivity in Matching}).@refill - -@item -The @code{FIELDWIDTHS} variable and its effects -(@pxref{Constant Size, ,Reading Fixed-width Data}).@refill - -@item -The @code{next file} statement for skipping to the next data file -(@pxref{Next File Statement, ,The @code{next file} Statement}).@refill - -@item -The @code{systime} and @code{strftime} built-in functions for obtaining -and printing time stamps -(@pxref{Time Functions, ,Functions for Dealing with Time Stamps}).@refill - -@item -The @file{/dev/stdin}, @file{/dev/stdout}, @file{/dev/stderr}, and -@file{/dev/fd/@var{n}} file name interpretation -(@pxref{Special Files, ,Standard I/O Streams}).@refill - -@item -The @samp{-W compat} option to turn off these extensions -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@item -The @samp{-W posix} option for full @sc{posix} compliance -(@pxref{Command Line, ,Invoking @code{awk}}).@refill - -@end itemize - -@node Installation, Gawk Summary, Language History, Top -@chapter Installing @code{gawk} - -This chapter provides instructions for installing @code{gawk} on the -various platforms that are supported by the developers. The primary -developers support Unix (and one day, GNU), while the other ports were -contributed. The file @file{ACKNOWLEDGMENT} in the @code{gawk} -distribution lists the electronic mail addresses of the people who did -the respective ports.@refill - -@menu -* Gawk Distribution:: What is in the @code{gawk} distribution. -* Unix Installation:: Installing @code{gawk} under various versions - of Unix. -* VMS Installation:: Installing @code{gawk} on VMS. -* MS-DOS Installation:: Installing @code{gawk} on MS-DOS. -* Atari Installation:: Installing @code{gawk} on the Atari ST. -@end menu - -@node Gawk Distribution, Unix Installation, Installation, Installation -@section The @code{gawk} Distribution - -This section first describes how to get and extract the @code{gawk} -distribution, and then discusses what is in the various files and -subdirectories. - -@menu -* Extracting:: How to get and extract the distribution. -* Distribution contents:: What is in the distribution. -@end menu - -@node Extracting, Distribution contents, Gawk Distribution, Gawk Distribution -@subsection Getting the @code{gawk} Distribution - -@cindex getting gawk -@cindex anonymous ftp -@cindex anonymous uucp -@cindex ftp, anonymous -@cindex uucp, anonymous -@code{gawk} is distributed as a @code{tar} file compressed with the -GNU Zip program, @code{gzip}. You can -get it via anonymous @code{ftp} to the Internet host @code{prep.ai.mit.edu}. -Like all GNU software, it will be archived at other well known systems, -from which it will be possible to use some sort of anonymous @code{uucp} to -obtain the distribution as well. -You can also order @code{gawk} on tape or CD-ROM directly from the -Free Software Foundation. (The address is on the copyright page.) -Doing so directly contributes to the support of the foundation and to -the production of more free software. - -Once you have the distribution (for example, -@file{gawk-2.15.0.tar.z}), first use @code{gzip} to expand the -file, and then use @code{tar} to extract it. You can use the following -pipeline to produce the @code{gawk} distribution: - -@example -# Under System V, add 'o' to the tar flags -gzip -d -c gawk-2.15.0.tar.z | tar -xvpf - -@end example - -@noindent -This will create a directory named @file{gawk-2.15} in the current -directory. - -The distribution file name is of the form @file{gawk-2.15.@var{n}.tar.Z}. -The @var{n} represents a @dfn{patchlevel}, meaning that minor bugs have -been fixed in the major release. The current patchlevel is 0, but when -retrieving distributions, you should get the version with the highest -patchlevel.@refill - -If you are not on a Unix system, you will need to make other arrangements -for getting and extracting the @code{gawk} distribution. You should consult -a local expert. - -@node Distribution contents, , Extracting, Gawk Distribution -@subsection Contents of the @code{gawk} Distribution - -@code{gawk} has a number of C source files, documentation files, -subdirectories and files related to the configuration process -(@pxref{Unix Installation, ,Compiling and Installing @code{gawk} on Unix}), -and several subdirectories related to different, non-Unix, -operating systems.@refill - -@table @asis -@item various @samp{.c}, @samp{.y}, and @samp{.h} files - -The C and YACC source files are the actual @code{gawk} source code. -@end table - -@table @file -@item README -@itemx README.VMS -@itemx README.dos -@itemx README.rs6000 -@itemx README.ultrix -Descriptive files: @file{README} for @code{gawk} under Unix, and the -rest for the various hardware and software combinations. - -@item PORTS -A list of systems to which @code{gawk} has been ported, and which -have successfully run the test suite. - -@item ACKNOWLEDGMENT -A list of the people who contributed major parts of the code or documentation. - -@item NEWS -A list of changes to @code{gawk} since the last release or patch. - -@item COPYING -The GNU General Public License. - -@item FUTURES -A brief list of features and/or changes being contemplated for future -releases, with some indication of the time frame for the feature, based -on its difficulty. - -@item LIMITATIONS -A list of those factors that limit @code{gawk}'s performance. -Most of these depend on the hardware or operating system software, and -are not limits in @code{gawk} itself.@refill - -@item PROBLEMS -A file describing known problems with the current release. - -@item gawk.1 -The @code{troff} source for a manual page describing @code{gawk}. - -@item gawk.texinfo -@ifinfo -The @code{texinfo} source file for this Info file. -It should be processed with @TeX{} to produce a printed manual, and -with @code{makeinfo} to produce the Info file.@refill -@end ifinfo -@iftex -The @code{texinfo} source file for this manual. -It should be processed with @TeX{} to produce a printed manual, and -with @code{makeinfo} to produce the Info file.@refill -@end iftex - -@item Makefile.in -@itemx config -@itemx config.in -@itemx configure -@itemx missing -@itemx mungeconf -These files and subdirectories are used when configuring @code{gawk} -for various Unix systems. They are explained in detail in -@ref{Unix Installation, ,Compiling and Installing @code{gawk} on Unix}.@refill - -@item atari -Files needed for building @code{gawk} on an Atari ST. -@xref{Atari Installation, ,Installing @code{gawk} on the Atari ST}, for details. - -@item pc -Files needed for building @code{gawk} under MS-DOS. -@xref{MS-DOS Installation, ,Installing @code{gawk} on MS-DOS}, for details. - -@item vms -Files needed for building @code{gawk} under VMS. -@xref{VMS Installation, ,Compiling Installing and Running @code{gawk} on VMS}, for details. - -@item test -Many interesting @code{awk} programs, provided as a test suite for -@code{gawk}. You can use @samp{make test} from the top level @code{gawk} -directory to run your version of @code{gawk} against the test suite. -@c There are many programs here that are useful in their own right. -If @code{gawk} successfully passes @samp{make test} then you can -be confident of a successful port.@refill -@end table - -@node Unix Installation, VMS Installation, Gawk Distribution, Installation -@section Compiling and Installing @code{gawk} on Unix - -Often, you can compile and install @code{gawk} by typing only two -commands. However, if you do not use a supported system, you may need -to configure @code{gawk} for your system yourself. - -@menu -* Quick Installation:: Compiling @code{gawk} on a - supported Unix version. -* Configuration Philosophy:: How it's all supposed to work. -* New Configurations:: What to do if there is no supplied - configuration for your system. -@end menu - -@node Quick Installation, Configuration Philosophy, Unix Installation, Unix Installation -@subsection Compiling @code{gawk} for a Supported Unix Version - -@cindex installation, unix -After you have extracted the @code{gawk} distribution, @code{cd} -to @file{gawk-2.15}. Look in the @file{config} subdirectory for a -file that matches your hardware/software combination. In general, -only the software is relevant; for example @code{sunos41} is used -for SunOS 4.1, on both Sun 3 and Sun 4 hardware.@refill - -If you find such a file, run the command: - -@example -# assume you have SunOS 4.1 -./configure sunos41 -@end example - -This produces a @file{Makefile} and @file{config.h} tailored to your -system. You may wish to edit the @file{Makefile} to use a different -C compiler, such as @code{gcc}, the GNU C compiler, if you have it. -You may also wish to change the @code{CFLAGS} variable, which controls -the command line options that are passed to the C compiler (such as -optimization levels, or compiling for debugging).@refill - -After you have configured @file{Makefile} and @file{config.h}, type: - -@example -make -@end example - -@noindent -and shortly thereafter, you should have an executable version of @code{gawk}. -That's all there is to it! - -@node Configuration Philosophy, New Configurations, Quick Installation, Unix Installation -@subsection The Configuration Process - -(This section is of interest only if you know something about using the -C language and the Unix operating system.) - -The source code for @code{gawk} generally attempts to adhere to industry -standards wherever possible. This means that @code{gawk} uses library -routines that are specified by the @sc{ansi} C standard and by the @sc{posix} -operating system interface standard. When using an @sc{ansi} C compiler, -function prototypes are provided to help improve the compile-time checking. - -Many older Unix systems do not support all of either the @sc{ansi} or the -@sc{posix} standards. The @file{missing} subdirectory in the @code{gawk} -distribution contains replacement versions of those subroutines that are -most likely to be missing. - -The @file{config.h} file that is created by the @code{configure} program -contains definitions that describe features of the particular operating -system where you are attempting to compile @code{gawk}. For the most -part, it lists which standard subroutines are @emph{not} available. -For example, if your system lacks the @samp{getopt} routine, then -@samp{GETOPT_MISSING} would be defined. - -@file{config.h} also defines constants that describe facts about your -variant of Unix. For example, there may not be an @samp{st_blksize} -element in the @code{stat} structure. In this case @samp{BLKSIZE_MISSING} -would be defined. - -Based on the list in @file{config.h} of standard subroutines that are -missing, @file{missing.c} will do a @samp{#include} of the appropriate -file(s) from the @file{missing} subdirectory.@refill - -Conditionally compiled code in the other source files relies on the -other definitions in the @file{config.h} file. - -Besides creating @file{config.h}, @code{configure} produces a @file{Makefile} -from @file{Makefile.in}. There are a number of lines in @file{Makefile.in} -that are system or feature specific. For example, there is line that begins -with @samp{##MAKE_ALLOCA_C##}. This is normally a comment line, since -it starts with @samp{#}. If a configuration file has @samp{MAKE_ALLOCA_C} -in it, then @code{configure} will delete the @samp{##MAKE_ALLOCA_C##} -from the beginning of the line. This will enable the rules in the -@file{Makefile} that use a C version of @samp{alloca}. There are several -similar features that work in this fashion.@refill - -@node New Configurations, , Configuration Philosophy, Unix Installation -@subsection Configuring @code{gawk} for a New System - -(This section is of interest only if you know something about using the -C language and the Unix operating system, and if you have to install -@code{gawk} on a system that is not supported by the @code{gawk} distribution. -If you are a C or Unix novice, get help from a local expert.) - -If you need to configure @code{gawk} for a Unix system that is not -supported in the distribution, first see -@ref{Configuration Philosophy, ,The Configuration Process}. -Then, copy @file{config.in} to @file{config.h}, and copy -@file{Makefile.in} to @file{Makefile}.@refill - -Next, edit both files. Both files are liberally commented, and the -necessary changes should be straightforward. - -While editing @file{config.h}, you need to determine what library -routines you do or do not have by consulting your system documentation, or -by perusing your actual libraries using the @code{ar} or @code{nm} utilities. -In the worst case, simply do not define @emph{any} of the macros for missing -subroutines. When you compile @code{gawk}, the final link-editing step -will fail. The link editor will provide you with a list of unresolved external -references---these are the missing subroutines. Edit @file{config.h} again -and recompile, and you should be set.@refill - -Editing the @file{Makefile} should also be straightforward. Enable or -disable the lines that begin with @samp{##MAKE_@var{whatever}##}, as -appropriate. Select the correct C compiler and @code{CFLAGS} for it. -Then run @code{make}. - -Getting a correct configuration is likely to be an iterative process. -Do not be discouraged if it takes you several tries. If you have no -luck whatsoever, please report your system type, and the steps you took. -Once you do have a working configuration, please send it to the maintainers -so that support for your system can be added to the official release. - -@xref{Bugs, ,Reporting Problems and Bugs}, for information on how to report -problems in configuring @code{gawk}. You may also use the same mechanisms -for sending in new configurations.@refill - -@node VMS Installation, MS-DOS Installation, Unix Installation, Installation -@section Compiling, Installing, and Running @code{gawk} on VMS - -@c based on material from -@c Pat Rankin - -@cindex installation, vms -This section describes how to compile and install @code{gawk} under VMS. - -@menu -* VMS Compilation:: How to compile @code{gawk} under VMS. -* VMS Installation Details:: How to install @code{gawk} under VMS. -* VMS Running:: How to run @code{gawk} under VMS. -* VMS POSIX:: Alternate instructions for VMS POSIX. -@end menu - -@node VMS Compilation, VMS Installation Details, VMS Installation, VMS Installation -@subsection Compiling @code{gawk} under VMS - -To compile @code{gawk} under VMS, there is a @code{DCL} command procedure that -will issue all the necessary @code{CC} and @code{LINK} commands, and there is -also a @file{Makefile} for use with the @code{MMS} utility. From the source -directory, use either - -@smallexample -$ @@[.VMS]VMSBUILD.COM -@end smallexample - -@noindent -or - -@smallexample -$ MMS/DESCRIPTION=[.VMS]DECSRIP.MMS GAWK -@end smallexample - -Depending upon which C compiler you are using, follow one of the sets -of instructions in this table: - -@table @asis -@item VAX C V3.x -Use either @file{vmsbuild.com} or @file{descrip.mms} as is. These use -@code{CC/OPTIMIZE=NOLINE}, which is essential for Version 3.0. - -@item VAX C V2.x -You must have Version 2.3 or 2.4; older ones won't work. Edit either -@file{vmsbuild.com} or @file{descrip.mms} according to the comments in them. -For @file{vmsbuild.com}, this just entails removing two @samp{!} delimiters. -Also edit @file{config.h} (which is a copy of file @file{[.config]vms-conf.h}) -and comment out or delete the two lines @samp{#define __STDC__ 0} and -@samp{#define VAXC_BUILTINS} near the end.@refill - -@item GNU C -Edit @file{vmsbuild.com} or @file{descrip.mms}; the changes are different -from those for VAX C V2.x, but equally straightforward. No changes to -@file{config.h} should be needed. - -@item DEC C -Edit @file{vmsbuild.com} or @file{descrip.mms} according to their comments. -No changes to @file{config.h} should be needed. -@end table - -@code{gawk} 2.15 has been tested under VAX/VMS 5.5-1 using VAX C V3.2, -GNU C 1.40 and 2.3. It should work without modifications for VMS V4.6 and up. - -@node VMS Installation Details, VMS Running, VMS Compilation, VMS Installation -@subsection Installing @code{gawk} on VMS - -To install @code{gawk}, all you need is a ``foreign'' command, which is -a @code{DCL} symbol whose value begins with a dollar sign. - -@smallexample -$ GAWK :== $device:[directory]GAWK -@end smallexample - -@noindent -(Substitute the actual location of @code{gawk.exe} for -@samp{device:[directory]}.) The symbol should be placed in the -@file{login.com} of any user who wishes to run @code{gawk}, -so that it will be defined every time the user logs on. -Alternatively, the symbol may be placed in the system-wide -@file{sylogin.com} procedure, which will allow all users -to run @code{gawk}.@refill - -Optionally, the help entry can be loaded into a VMS help library: - -@smallexample -$ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP -@end smallexample - -@noindent -(You may want to substitute a site-specific help library rather than -the standard VMS library @samp{HELPLIB}.) After loading the help text, - -@c this is so tiny, but `should' be smallexample for consistency sake... -@c I didn't because it was so short. --mew 29jan1992 -@example -$ HELP GAWK -@end example - -@noindent -will provide information about both the @code{gawk} implementation and the -@code{awk} programming language. - -The logical name @samp{AWK_LIBRARY} can designate a default location -for @code{awk} program files. For the @samp{-f} option, if the specified -filename has no device or directory path information in it, @code{gawk} -will look in the current directory first, then in the directory specified -by the translation of @samp{AWK_LIBRARY} if the file was not found. -If after searching in both directories, the file still is not found, -then @code{gawk} appends the suffix @samp{.awk} to the filename and the -file search will be re-tried. If @samp{AWK_LIBRARY} is not defined, that -portion of the file search will fail benignly.@refill - -@node VMS Running, VMS POSIX, VMS Installation Details, VMS Installation -@subsection Running @code{gawk} on VMS - -Command line parsing and quoting conventions are significantly different -on VMS, so examples in this manual or from other sources often need minor -changes. They @emph{are} minor though, and all @code{awk} programs -should run correctly. - -Here are a couple of trivial tests: - -@smallexample -$ gawk -- "BEGIN @{print ""Hello, World!""@}" -$ gawk -"W" version ! could also be -"W version" or "-W version" -@end smallexample - -@noindent -Note that upper-case and mixed-case text must be quoted. - -The VMS port of @code{gawk} includes a @code{DCL}-style interface in addition -to the original shell-style interface (see the help entry for details). -One side-effect of dual command line parsing is that if there is only a -single parameter (as in the quoted string program above), the command -becomes ambiguous. To work around this, the normally optional @samp{--} -flag is required to force Unix style rather than @code{DCL} parsing. If any -other dash-type options (or multiple parameters such as data files to be -processed) are present, there is no ambiguity and @samp{--} can be omitted. - -The default search path when looking for @code{awk} program files specified -by the @samp{-f} option is @code{"SYS$DISK:[],AWK_LIBRARY:"}. The logical -name @samp{AWKPATH} can be used to override this default. The format -of @samp{AWKPATH} is a comma-separated list of directory specifications. -When defining it, the value should be quoted so that it retains a single -translation, and not a multi-translation @code{RMS} searchlist. - -@node VMS POSIX, , VMS Running, VMS Installation -@subsection Building and using @code{gawk} under VMS POSIX - -Ignore the instructions above, although @file{vms/gawk.hlp} should still -be made available in a help library. Make sure that the two scripts, -@file{configure} and @file{mungeconf}, are executable; use @samp{chmod +x} -on them if necessary. Then execute the following commands: - -@smallexample -$ POSIX -psx> configure vms-posix -psx> make awktab.c gawk -@end smallexample - -@noindent -The first command will construct files @file{config.h} and @file{Makefile} -out of templates. The second command will compile and link @code{gawk}. -Due to a @code{make} bug in VMS POSIX V1.0 and V1.1, -the file @file{awktab.c} must be given as an explicit target or it will -not be built and the final link step will fail. Ignore the warning -@samp{"Could not find lib m in lib list"}; it is harmless, caused by the -explicit use of @samp{-lm} as a linker option which is not needed -under VMS POSIX. Under V1.1 (but not V1.0) a problem with the @code{yacc} -skeleton @file{/etc/yyparse.c} will cause a compiler warning for -@file{awktab.c}, followed by a linker warning about compilation warnings -in the resulting object module. These warnings can be ignored.@refill - -Once built, @code{gawk} will work like any other shell utility. Unlike -the normal VMS port of @code{gawk}, no special command line manipulation is -needed in the VMS POSIX environment. - -@node MS-DOS Installation, Atari Installation, VMS Installation, Installation -@section Installing @code{gawk} on MS-DOS - -@cindex installation, ms-dos -The first step is to get all the files in the @code{gawk} distribution -onto your PC. Move all the files from the @file{pc} directory into -the main directory where the other files are. Edit the file -@file{make.bat} so that it will be an acceptable MS-DOS batch file. -This means making sure that all lines are terminated with the ASCII -carriage return and line feed characters. -restrictions. - -@code{gawk} has only been compiled with version 5.1 of the Microsoft -C compiler. The file @file{make.bat} from the @file{pc} directory -assumes that you have this compiler. - -Copy the file @file{setargv.obj} from the library directory where it -resides to the @code{gawk} source code directory. - -Run @file{make.bat}. This will compile @code{gawk} for you, and link it. -That's all there is to it! - -@node Atari Installation, , MS-DOS Installation, Installation -@section Installing @code{gawk} on the Atari ST - -@c based on material from -@c Michal Jaegermann - -@cindex installation, atari -This section assumes that you are running TOS. It applies to other Atari -models (STe, TT) as well. - -In order to use @code{gawk}, you need to have a shell, either text or -graphics, that does not map all the characters of a command line to -upper case. Maintaining case distinction in option flags is very -important (@pxref{Command Line, ,Invoking @code{awk}}). Popular shells -like @code{gulam} or @code{gemini} will work, as will newer versions of -@code{desktop}. Support for I/O redirection is necessary to make it easy -to import @code{awk} programs from other environments. Pipes are nice to have, -but not vital. - -If you have received an executable version of @code{gawk}, place it, -as usual, anywhere in your @code{PATH} where your shell will find it. - -While executing, @code{gawk} creates a number of temporary files. -@code{gawk} looks for either of the environment variables @code{TEMP} -or @code{TMPDIR}, in that order. If either one is found, its value -is assumed to be a directory for temporary files. This directory -must exist, and if you can spare the memory, it is a good idea to -put it on a @sc{ram} drive. If neither @code{TEMP} nor @code{TMPDIR} -are found, then @code{gawk} uses the current directory for its -temporary files. - -The ST version of @code{gawk} searches for its program files as -described in @ref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}. -On the ST, the default value for the @code{AWKPATH} variable is -@code{@w{".,c:\lib\awk,c:\gnu\lib\awk"}}. -The search path can be modified by explicitly setting @code{AWKPATH} to -whatever you wish. Note that colons cannot be used on the ST to separate -elements in the @code{AWKPATH} variable, since they have another, reserved, -meaning. Instead, you must use a comma to separate elements in the path. -If you are recompiling @code{gawk} on the ST, then you can choose a new -default search path, by setting the value of @samp{DEFPATH} in the file -@file{...\config\atari}. You may choose a different separator character -by setting the value of @samp{ENVSEP} in the same file. The new values will -be used when creating the header file @file{config.h}.@refill - -@ignore -As a last resort, small -adjustments can be made directly on the executable version of @code{gawk} -using a binary editor.@refill -@end ignore - -Although @code{awk} allows great flexibility in doing I/O redirections -from within a program, this facility should be used with care on the ST. -In some circumstances the OS routines for file handle pool processing -lose track of certain events, causing the computer to crash, and requiring -a reboot. Often a warm reboot is sufficient. Fortunately, this happens -infrequently, and in rather esoteric situations. In particular, avoid -having one part of an @code{awk} program using @code{print} -statements explicitly redirected to @code{"/dev/stdout"}, while other -@code{print} statements use the default standard output, and a -calling shell has redirected standard output to a file.@refill -@c whew! - -When @code{gawk} is compiled with the ST version of @code{gcc} and its -usual libraries, it will accept both @samp{/} and @samp{\} as path separators. -While this is convenient, it should be remembered that this removes one, -technically legal, character (@samp{/}) from your file names, and that -it may create problems for external programs, called via the @code{system()} -function, which may not support this convention. Whenever it is possible -that a file created by @code{gawk} will be used by some other program, -use only backslashes. Also remember that in @code{awk}, backslashes in -strings have to be doubled in order to get literal backslashes. - -The initial port of @code{gawk} to the ST was done with @code{gcc}. -If you wish to recompile @code{gawk} from scratch, you will need to use -a compiler that accepts @sc{ansi} standard C (such as @code{gcc}, Turbo C, -or Prospero C). If @code{sizeof(int) != @w{sizeof(int *)}}, the correctness -of the generated code depends heavily on the fact that all function calls -have function prototypes in the current scope. If your compiler does -not accept function prototypes, you will probably have to add a -number of casts to the code.@refill - -If you are using @code{gcc}, make sure that you have up-to-date libraries. -Older versions have problems with some library functions (@code{atan2()}, -@code{strftime()}, the @samp{%g} conversion in @code{sprintf()}) which -may affect the operation of @code{gawk}. - -In the @file{atari} subdirectory of the @code{gawk} distribution is -a version of the @code{system()} function that has been tested with -@code{gulam} and @code{msh}; it should work with other shells as well. -With @code{gulam}, it passes the string to be executed without spawning -an extra copy of a shell. It is possible to replace this version of -@code{system()} with a similar function from a library or from some other -source if that version would be a better choice for the shell you prefer. - -The files needed to recompile @code{gawk} on the ST can be found in -the @file{atari} directory. The provided files and instructions below -assume that you have the GNU C compiler (@code{gcc}), the @code{gulam} shell, -and an ST version of @code{sed}. The @file{Makefile} is set up to use -@file{byacc} as a @file{yacc} replacement. With a different set of tools some -adjustments and/or editing will be needed.@refill - -@code{cd} to the @file{atari} directory. Copy @file{Makefile.st} to -@file{makefile} in the source (parent) directory. Possibly adjust -@file{../config/atari} to suit your system. Execute the script @file{mkconf.g} -which will create the header file @file{../config.h}. Go back to the source -directory. If you are not using @code{gcc}, check the file @file{missing.c}. -It may be necessary to change forward slashes in the references to files -from the @file{atari} subdirectory into backslashes. Type @code{make} and -enjoy.@refill - -Compilation with @code{gcc} of some of the bigger modules, like -@file{awk_tab.c}, may require a full four megabytes of memory. On smaller -machines you would need to cut down on optimizations, or you would have to -switch to another, less memory hungry, compiler.@refill - -@node Gawk Summary, Sample Program, Installation, Top -@appendix @code{gawk} Summary - -This appendix provides a brief summary of the @code{gawk} command line and the -@code{awk} language. It is designed to serve as ``quick reference.'' It is -therefore terse, but complete. - -@menu -* Command Line Summary:: Recapitulation of the command line. -* Language Summary:: A terse review of the language. -* Variables/Fields:: Variables, fields, and arrays. -* Rules Summary:: Patterns and Actions, and their - component parts. -* Functions Summary:: Defining and calling functions. -* Historical Features:: Some undocumented but supported ``features''. -@end menu - -@node Command Line Summary, Language Summary, Gawk Summary, Gawk Summary -@appendixsec Command Line Options Summary - -The command line consists of options to @code{gawk} itself, the -@code{awk} program text (if not supplied via the @samp{-f} option), and -values to be made available in the @code{ARGC} and @code{ARGV} -predefined @code{awk} variables: - -@example -awk @r{[@var{POSIX or GNU style options}]} -f source-file @r{[@code{--}]} @var{file} @dots{} -awk @r{[@var{POSIX or GNU style options}]} @r{[@code{--}]} '@var{program}' @var{file} @dots{} -@end example - -The options that @code{gawk} accepts are: - -@table @code -@item -F @var{fs} -@itemx --field-separator=@var{fs} -Use @var{fs} for the input field separator (the value of the @code{FS} -predefined variable). - -@item -f @var{program-file} -@itemx --file=@var{program-file} -Read the @code{awk} program source from the file @var{program-file}, instead -of from the first command line argument. - -@item -v @var{var}=@var{val} -@itemx --assign=@var{var}=@var{val} -Assign the variable @var{var} the value @var{val} before program execution -begins. - -@item -W compat -@itemx --compat -Specifies compatibility mode, in which @code{gawk} extensions are turned -off. - -@item -W copyleft -@itemx -W copyright -@itemx --copyleft -@itemx --copyright -Print the short version of the General Public License on the error -output. This option may disappear in a future version of @code{gawk}. - -@item -W help -@itemx -W usage -@itemx --help -@itemx --usage -Print a relatively short summary of the available options on the error output. - -@item -W lint -@itemx --lint -Give warnings about dubious or non-portable @code{awk} constructs. - -@item -W posix -@itemx --posix -Specifies @sc{posix} compatibility mode, in which @code{gawk} extensions -are turned off and additional restrictions apply. - -@item -W source=@var{program-text} -@itemx --source=@var{program-text} -Use @var{program-text} as @code{awk} program source code. This option allows -mixing command line source code with source code from files, and is -particularly useful for mixing command line programs with library functions. - -@item -W version -@itemx --version -Print version information for this particular copy of @code{gawk} on the error -output. This option may disappear in a future version of @code{gawk}. - -@item -- -Signal the end of options. This is useful to allow further arguments to the -@code{awk} program itself to start with a @samp{-}. This is mainly for -consistency with the argument parsing conventions of @sc{posix}. -@end table - -Any other options are flagged as invalid, but are otherwise ignored. -@xref{Command Line, ,Invoking @code{awk}}, for more details. - -@node Language Summary, Variables/Fields, Command Line Summary, Gawk Summary -@appendixsec Language Summary - -An @code{awk} program consists of a sequence of pattern-action statements -and optional function definitions. - -@example -@var{pattern} @{ @var{action statements} @} - -function @var{name}(@var{parameter list}) @{ @var{action statements} @} -@end example - -@code{gawk} first reads the program source from the -@var{program-file}(s) if specified, or from the first non-option -argument on the command line. The @samp{-f} option may be used multiple -times on the command line. @code{gawk} reads the program text from all -the @var{program-file} files, effectively concatenating them in the -order they are specified. This is useful for building libraries of -@code{awk} functions, without having to include them in each new -@code{awk} program that uses them. To use a library function in a file -from a program typed in on the command line, specify @samp{-f /dev/tty}; -then type your program, and end it with a @kbd{Control-d}. -@xref{Command Line, ,Invoking @code{awk}}.@refill - -The environment variable @code{AWKPATH} specifies a search path to use -when finding source files named with the @samp{-f} option. The default -path, which is -@samp{.:/usr/lib/awk:/usr/local/lib/awk} is used if @code{AWKPATH} is not set. -If a file name given to the @samp{-f} option contains a @samp{/} character, -no path search is performed. -@xref{AWKPATH Variable, ,The @code{AWKPATH} Environment Variable}, -for a full description of the @code{AWKPATH} environment variable.@refill - -@code{gawk} compiles the program into an internal form, and then proceeds to -read each file named in the @code{ARGV} array. If there are no files named -on the command line, @code{gawk} reads the standard input. - -If a ``file'' named on the command line has the form -@samp{@var{var}=@var{val}}, it is treated as a variable assignment: the -variable @var{var} is assigned the value @var{val}. -If any of the files have a value that is the null string, that -element in the list is skipped.@refill - -For each line in the input, @code{gawk} tests to see if it matches any -@var{pattern} in the @code{awk} program. For each pattern that the line -matches, the associated @var{action} is executed. - -@node Variables/Fields, Rules Summary, Language Summary, Gawk Summary -@appendixsec Variables and Fields - -@code{awk} variables are dynamic; they come into existence when they are -first used. Their values are either floating-point numbers or strings. -@code{awk} also has one-dimension arrays; multiple-dimensional arrays -may be simulated. There are several predefined variables that -@code{awk} sets as a program runs; these are summarized below. - -@menu -* Fields Summary:: Input field splitting. -* Built-in Summary:: @code{awk}'s built-in variables. -* Arrays Summary:: Using arrays. -* Data Type Summary:: Values in @code{awk} are numbers or strings. -@end menu - -@node Fields Summary, Built-in Summary, Variables/Fields, Variables/Fields -@appendixsubsec Fields - -As each input line is read, @code{gawk} splits the line into -@var{fields}, using the value of the @code{FS} variable as the field -separator. If @code{FS} is a single character, fields are separated by -that character. Otherwise, @code{FS} is expected to be a full regular -expression. In the special case that @code{FS} is a single blank, -fields are separated by runs of blanks and/or tabs. Note that the value -of @code{IGNORECASE} (@pxref{Case-sensitivity, ,Case-sensitivity in Matching}) -also affects how fields are split when @code{FS} is a regular expression.@refill - -Each field in the input line may be referenced by its position, @code{$1}, -@code{$2}, and so on. @code{$0} is the whole line. The value of a field may -be assigned to as well. Field numbers need not be constants: - -@example -n = 5 -print $n -@end example - -@noindent -prints the fifth field in the input line. The variable @code{NF} is set to -the total number of fields in the input line. - -References to nonexistent fields (i.e., fields after @code{$NF}) return -the null-string. However, assigning to a nonexistent field (e.g., -@code{$(NF+2) = 5}) increases the value of @code{NF}, creates any -intervening fields with the null string as their value, and causes the -value of @code{$0} to be recomputed, with the fields being separated by -the value of @code{OFS}.@refill - -@xref{Reading Files, ,Reading Input Files}, for a full description of the -way @code{awk} defines and uses fields. - -@node Built-in Summary, Arrays Summary, Fields Summary, Variables/Fields -@appendixsubsec Built-in Variables - -@code{awk}'s built-in variables are: - -@table @code -@item ARGC -The number of command line arguments (not including options or the -@code{awk} program itself). - -@item ARGIND -The index in @code{ARGV} of the current file being processed. -It is always true that @samp{FILENAME == ARGV[ARGIND]}. - -@item ARGV -The array of command line arguments. The array is indexed from 0 to -@code{ARGC} @minus{} 1. Dynamically changing the contents of @code{ARGV} -can control the files used for data.@refill - -@item CONVFMT -The conversion format to use when converting numbers to strings. - -@item FIELDWIDTHS -A space separated list of numbers describing the fixed-width input data. - -@item ENVIRON -An array containing the values of the environment variables. The array -is indexed by variable name, each element being the value of that -variable. Thus, the environment variable @code{HOME} would be in -@code{ENVIRON["HOME"]}. Its value might be @file{/u/close}. - -Changing this array does not affect the environment seen by programs -which @code{gawk} spawns via redirection or the @code{system} function. -(This may change in a future version of @code{gawk}.) - -Some operating systems do not have environment variables. -The array @code{ENVIRON} is empty when running on these systems. - -@item ERRNO -The system error message when an error occurs using @code{getline} -or @code{close}. - -@item FILENAME -The name of the current input file. If no files are specified on the command -line, the value of @code{FILENAME} is @samp{-}. - -@item FNR -The input record number in the current input file. - -@item FS -The input field separator, a blank by default. - -@item IGNORECASE -The case-sensitivity flag for regular expression operations. If -@code{IGNORECASE} has a nonzero value, then pattern matching in rules, -field splitting with @code{FS}, regular expression matching with -@samp{~} and @samp{!~}, and the @code{gsub}, @code{index}, @code{match}, -@code{split} and @code{sub} predefined functions all ignore case -when doing regular expression operations.@refill - -@item NF -The number of fields in the current input record. - -@item NR -The total number of input records seen so far. - -@item OFMT -The output format for numbers for the @code{print} statement, -@code{"%.6g"} by default. - -@item OFS -The output field separator, a blank by default. - -@item ORS -The output record separator, by default a newline. - -@item RS -The input record separator, by default a newline. @code{RS} is exceptional -in that only the first character of its string value is used for separating -records. If @code{RS} is set to the null string, then records are separated by -blank lines. When @code{RS} is set to the null string, then the newline -character always acts as a field separator, in addition to whatever value -@code{FS} may have.@refill - -@item RSTART -The index of the first character matched by @code{match}; 0 if no match. - -@item RLENGTH -The length of the string matched by @code{match}; @minus{}1 if no match. - -@item SUBSEP -The string used to separate multiple subscripts in array elements, by -default @code{"\034"}. -@end table - -@xref{Built-in Variables}, for more information. - -@node Arrays Summary, Data Type Summary, Built-in Summary, Variables/Fields -@appendixsubsec Arrays - -Arrays are subscripted with an expression between square brackets -(@samp{[} and @samp{]}). Array subscripts are @emph{always} strings; -numbers are converted to strings as necessary, following the standard -conversion rules -(@pxref{Conversion, ,Conversion of Strings and Numbers}).@refill - -If you use multiple expressions separated by commas inside the square -brackets, then the array subscript is a string consisting of the -concatenation of the individual subscript values, converted to strings, -separated by the subscript separator (the value of @code{SUBSEP}). - -The special operator @code{in} may be used in an @code{if} or -@code{while} statement to see if an array has an index consisting of a -particular value. - -@example -if (val in array) - print array[val] -@end example - -If the array has multiple subscripts, use @code{(i, j, @dots{}) in array} -to test for existence of an element. - -The @code{in} construct may also be used in a @code{for} loop to iterate -over all the elements of an array. -@xref{Scanning an Array, ,Scanning all Elements of an Array}.@refill - -An element may be deleted from an array using the @code{delete} statement. - -@xref{Arrays, ,Arrays in @code{awk}}, for more detailed information. - -@node Data Type Summary, , Arrays Summary, Variables/Fields -@appendixsubsec Data Types - -The value of an @code{awk} expression is always either a number -or a string. - -Certain contexts (such as arithmetic operators) require numeric -values. They convert strings to numbers by interpreting the text -of the string as a numeral. If the string does not look like a -numeral, it converts to 0. - -Certain contexts (such as concatenation) require string values. -They convert numbers to strings by effectively printing them -with @code{sprintf}. -@xref{Conversion, ,Conversion of Strings and Numbers}, for the details.@refill - -To force conversion of a string value to a number, simply add 0 -to it. If the value you start with is already a number, this -does not change it. - -To force conversion of a numeric value to a string, concatenate it with -the null string. - -The @code{awk} language defines comparisons as being done numerically if -both operands are numeric, or if one is numeric and the other is a numeric -string. Otherwise one or both operands are converted to strings and a -string comparison is performed. - -Uninitialized variables have the string value @code{""} (the null, or -empty, string). In contexts where a number is required, this is -equivalent to 0. - -@xref{Variables}, for more information on variable naming and initialization; -@pxref{Conversion, ,Conversion of Strings and Numbers}, for more information -on how variable values are interpreted.@refill - -@node Rules Summary, Functions Summary, Variables/Fields, Gawk Summary -@appendixsec Patterns and Actions - -@menu -* Pattern Summary:: Quick overview of patterns. -* Regexp Summary:: Quick overview of regular expressions. -* Actions Summary:: Quick overview of actions. -@end menu - -An @code{awk} program is mostly composed of rules, each consisting of a -pattern followed by an action. The action is enclosed in @samp{@{} and -@samp{@}}. Either the pattern may be missing, or the action may be -missing, but, of course, not both. If the pattern is missing, the -action is executed for every single line of input. A missing action is -equivalent to this action, - -@example -@{ print @} -@end example - -@noindent -which prints the entire line. - -Comments begin with the @samp{#} character, and continue until the end of the -line. Blank lines may be used to separate statements. Normally, a statement -ends with a newline, however, this is not the case for lines ending in a -@samp{,}, @samp{@{}, @samp{?}, @samp{:}, @samp{&&}, or @samp{||}. Lines -ending in @code{do} or @code{else} also have their statements automatically -continued on the following line. In other cases, a line can be continued by -ending it with a @samp{\}, in which case the newline is ignored.@refill - -Multiple statements may be put on one line by separating them with a @samp{;}. -This applies to both the statements within the action part of a rule (the -usual case), and to the rule statements. - -@xref{Comments, ,Comments in @code{awk} Programs}, for information on -@code{awk}'s commenting convention; -@pxref{Statements/Lines, ,@code{awk} Statements versus Lines}, for a -description of the line continuation mechanism in @code{awk}.@refill - -@node Pattern Summary, Regexp Summary, Rules Summary, Rules Summary -@appendixsubsec Patterns - -@code{awk} patterns may be one of the following: - -@example -/@var{regular expression}/ -@var{relational expression} -@var{pattern} && @var{pattern} -@var{pattern} || @var{pattern} -@var{pattern} ? @var{pattern} : @var{pattern} -(@var{pattern}) -! @var{pattern} -@var{pattern1}, @var{pattern2} -BEGIN -END -@end example - -@code{BEGIN} and @code{END} are two special kinds of patterns that are not -tested against the input. The action parts of all @code{BEGIN} rules are -merged as if all the statements had been written in a single @code{BEGIN} -rule. They are executed before any of the input is read. Similarly, all the -@code{END} rules are merged, and executed when all the input is exhausted (or -when an @code{exit} statement is executed). @code{BEGIN} and @code{END} -patterns cannot be combined with other patterns in pattern expressions. -@code{BEGIN} and @code{END} rules cannot have missing action parts.@refill - -For @samp{/@var{regular-expression}/} patterns, the associated statement is -executed for each input line that matches the regular expression. Regular -expressions are extensions of those in @code{egrep}, and are summarized below. - -A @var{relational expression} may use any of the operators defined below in -the section on actions. These generally test whether certain fields match -certain regular expressions. - -The @samp{&&}, @samp{||}, and @samp{!} operators are logical ``and,'' -logical ``or,'' and logical ``not,'' respectively, as in C. They do -short-circuit evaluation, also as in C, and are used for combining more -primitive pattern expressions. As in most languages, parentheses may be -used to change the order of evaluation. - -The @samp{?:} operator is like the same operator in C. If the first -pattern matches, then the second pattern is matched against the input -record; otherwise, the third is matched. Only one of the second and -third patterns is matched. - -The @samp{@var{pattern1}, @var{pattern2}} form of a pattern is called a -range pattern. It matches all input lines starting with a line that -matches @var{pattern1}, and continuing until a line that matches -@var{pattern2}, inclusive. A range pattern cannot be used as an operand -to any of the pattern operators. - -@xref{Patterns}, for a full description of the pattern part of @code{awk} -rules. - -@node Regexp Summary, Actions Summary, Pattern Summary, Rules Summary -@appendixsubsec Regular Expressions - -Regular expressions are the extended kind found in @code{egrep}. -They are composed of characters as follows: - -@table @code -@item @var{c} -matches the character @var{c} (assuming @var{c} is a character with no -special meaning in regexps). - -@item \@var{c} -matches the literal character @var{c}. - -@item . -matches any character except newline. - -@item ^ -matches the beginning of a line or a string. - -@item $ -matches the end of a line or a string. - -@item [@var{abc}@dots{}] -matches any of the characters @var{abc}@dots{} (character class). - -@item [^@var{abc}@dots{}] -matches any character except @var{abc}@dots{} and newline (negated -character class). - -@item @var{r1}|@var{r2} -matches either @var{r1} or @var{r2} (alternation). - -@item @var{r1r2} -matches @var{r1}, and then @var{r2} (concatenation). - -@item @var{r}+ -matches one or more @var{r}'s. - -@item @var{r}* -matches zero or more @var{r}'s. - -@item @var{r}? -matches zero or one @var{r}'s. - -@item (@var{r}) -matches @var{r} (grouping). -@end table - -@xref{Regexp, ,Regular Expressions as Patterns}, for a more detailed -explanation of regular expressions. - -The escape sequences allowed in string constants are also valid in -regular expressions (@pxref{Constants, ,Constant Expressions}). - -@node Actions Summary, , Regexp Summary, Rules Summary -@appendixsubsec Actions - -Action statements are enclosed in braces, @samp{@{} and @samp{@}}. -Action statements consist of the usual assignment, conditional, and looping -statements found in most languages. The operators, control statements, -and input/output statements available are patterned after those in C. - -@menu -* Operator Summary:: @code{awk} operators. -* Control Flow Summary:: The control statements. -* I/O Summary:: The I/O statements. -* Printf Summary:: A summary of @code{printf}. -* Special File Summary:: Special file names interpreted internally. -* Numeric Functions Summary:: Built-in numeric functions. -* String Functions Summary:: Built-in string functions. -* Time Functions Summary:: Built-in time functions. -* String Constants Summary:: Escape sequences in strings. -@end menu - -@node Operator Summary, Control Flow Summary, Actions Summary, Actions Summary -@appendixsubsubsec Operators - -The operators in @code{awk}, in order of increasing precedence, are: - -@table @code -@item = += -= *= /= %= ^= -Assignment. Both absolute assignment (@code{@var{var}=@var{value}}) -and operator assignment (the other forms) are supported. - -@item ?: -A conditional expression, as in C. This has the form @code{@var{expr1} ? -@var{expr2} : @var{expr3}}. If @var{expr1} is true, the value of the -expression is @var{expr2}; otherwise it is @var{expr3}. Only one of -@var{expr2} and @var{expr3} is evaluated.@refill - -@item || -Logical ``or''. - -@item && -Logical ``and''. - -@item ~ !~ -Regular expression match, negated match. - -@item < <= > >= != == -The usual relational operators. - -@item @var{blank} -String concatenation. - -@item + - -Addition and subtraction. - -@item * / % -Multiplication, division, and modulus. - -@item + - ! -Unary plus, unary minus, and logical negation. - -@item ^ -Exponentiation (@samp{**} may also be used, and @samp{**=} for the assignment -operator, but they are not specified in the @sc{posix} standard). - -@item ++ -- -Increment and decrement, both prefix and postfix. - -@item $ -Field reference. -@end table - -@xref{Expressions, ,Expressions as Action Statements}, for a full -description of all the operators listed above. -@xref{Fields, ,Examining Fields}, for a description of the field -reference operator.@refill - -@node Control Flow Summary, I/O Summary, Operator Summary, Actions Summary -@appendixsubsubsec Control Statements - -The control statements are as follows: - -@example -if (@var{condition}) @var{statement} @r{[} else @var{statement} @r{]} -while (@var{condition}) @var{statement} -do @var{statement} while (@var{condition}) -for (@var{expr1}; @var{expr2}; @var{expr3}) @var{statement} -for (@var{var} in @var{array}) @var{statement} -break -continue -delete @var{array}[@var{index}] -exit @r{[} @var{expression} @r{]} -@{ @var{statements} @} -@end example - -@xref{Statements, ,Control Statements in Actions}, for a full description -of all the control statements listed above. - -@node I/O Summary, Printf Summary, Control Flow Summary, Actions Summary -@appendixsubsubsec I/O Statements - -The input/output statements are as follows: - -@table @code -@item getline -Set @code{$0} from next input record; set @code{NF}, @code{NR}, @code{FNR}. - -@item getline <@var{file} -Set @code{$0} from next record of @var{file}; set @code{NF}. - -@item getline @var{var} -Set @var{var} from next input record; set @code{NF}, @code{FNR}. - -@item getline @var{var} <@var{file} -Set @var{var} from next record of @var{file}. - -@item next -Stop processing the current input record. The next input record is read and -processing starts over with the first pattern in the @code{awk} program. -If the end of the input data is reached, the @code{END} rule(s), if any, -are executed. - -@item next file -Stop processing the current input file. The next input record read comes -from the next input file. @code{FILENAME} is updated, @code{FNR} is set to 1, -and processing starts over with the first pattern in the @code{awk} program. -If the end of the input data is reached, the @code{END} rule(s), if any, -are executed. - -@item print -Prints the current record. - -@item print @var{expr-list} -Prints expressions. - -@item print @var{expr-list} > @var{file} -Prints expressions on @var{file}. - -@item printf @var{fmt, expr-list} -Format and print. - -@item printf @var{fmt, expr-list} > file -Format and print on @var{file}. -@end table - -Other input/output redirections are also allowed. For @code{print} and -@code{printf}, @samp{>> @var{file}} appends output to the @var{file}, -and @samp{| @var{command}} writes on a pipe. In a similar fashion, -@samp{@var{command} | getline} pipes input into @code{getline}. -@code{getline} returns 0 on end of file, and @minus{}1 on an error.@refill - -@xref{Getline, ,Explicit Input with @code{getline}}, for a full description -of the @code{getline} statement. -@xref{Printing, ,Printing Output}, for a full description of @code{print} and -@code{printf}. Finally, @pxref{Next Statement, ,The @code{next} Statement}, -for a description of how the @code{next} statement works.@refill - -@node Printf Summary, Special File Summary, I/O Summary, Actions Summary -@appendixsubsubsec @code{printf} Summary - -The @code{awk} @code{printf} statement and @code{sprintf} function -accept the following conversion specification formats: - -@table @code -@item %c -An ASCII character. If the argument used for @samp{%c} is numeric, it is -treated as a character and printed. Otherwise, the argument is assumed to -be a string, and the only first character of that string is printed. - -@item %d -@itemx %i -A decimal number (the integer part). - -@item %e -A floating point number of the form -@samp{@r{[}-@r{]}d.ddddddE@r{[}+-@r{]}dd}.@refill - -@item %f -A floating point number of the form -@r{[}@code{-}@r{]}@code{ddd.dddddd}. - -@item %g -Use @samp{%e} or @samp{%f} conversion, whichever produces a shorter string, -with nonsignificant zeros suppressed. - -@item %o -An unsigned octal number (again, an integer). - -@item %s -A character string. - -@item %x -An unsigned hexadecimal number (an integer). - -@item %X -Like @samp{%x}, except use @samp{A} through @samp{F} instead of @samp{a} -through @samp{f} for decimal 10 through 15.@refill - -@item %% -A single @samp{%} character; no argument is converted. -@end table - -There are optional, additional parameters that may lie between the @samp{%} -and the control letter: - -@table @code -@item - -The expression should be left-justified within its field. - -@item @var{width} -The field should be padded to this width. If @var{width} has a leading zero, -then the field is padded with zeros. Otherwise it is padded with blanks. - -@item .@var{prec} -A number indicating the maximum width of strings or digits to the right -of the decimal point. -@end table - -Either or both of the @var{width} and @var{prec} values may be specified -as @samp{*}. In that case, the particular value is taken from the argument -list. - -@xref{Printf, ,Using @code{printf} Statements for Fancier Printing}, for -examples and for a more detailed description. - -@node Special File Summary, Numeric Functions Summary, Printf Summary, Actions Summary -@appendixsubsubsec Special File Names - -When doing I/O redirection from either @code{print} or @code{printf} into a -file, or via @code{getline} from a file, @code{gawk} recognizes certain special -file names internally. These file names allow access to open file descriptors -inherited from @code{gawk}'s parent process (usually the shell). The -file names are: - -@table @file -@item /dev/stdin -The standard input. - -@item /dev/stdout -The standard output. - -@item /dev/stderr -The standard error output. - -@item /dev/fd/@var{n} -The file denoted by the open file descriptor @var{n}. -@end table - -In addition the following files provide process related information -about the running @code{gawk} program. - -@table @file -@item /dev/pid -Reading this file returns the process ID of the current process, -in decimal, terminated with a newline. - -@item /dev/ppid -Reading this file returns the parent process ID of the current process, -in decimal, terminated with a newline. - -@item /dev/pgrpid -Reading this file returns the process group ID of the current process, -in decimal, terminated with a newline. - -@item /dev/user -Reading this file returns a single record terminated with a newline. -The fields are separated with blanks. The fields represent the -following information: - -@table @code -@item $1 -The value of the @code{getuid} system call. - -@item $2 -The value of the @code{geteuid} system call. - -@item $3 -The value of the @code{getgid} system call. - -@item $4 -The value of the @code{getegid} system call. -@end table - -If there are any additional fields, they are the group IDs returned by -@code{getgroups} system call. -(Multiple groups may not be supported on all systems.)@refill -@end table - -@noindent -These file names may also be used on the command line to name data files. -These file names are only recognized internally if you do not -actually have files by these names on your system. - -@xref{Special Files, ,Standard I/O Streams}, for a longer description that -provides the motivation for this feature. - -@node Numeric Functions Summary, String Functions Summary, Special File Summary, Actions Summary -@appendixsubsubsec Numeric Functions - -@code{awk} has the following predefined arithmetic functions: - -@table @code -@item atan2(@var{y}, @var{x}) -returns the arctangent of @var{y/x} in radians. - -@item cos(@var{expr}) -returns the cosine in radians. - -@item exp(@var{expr}) -the exponential function. - -@item int(@var{expr}) -truncates to integer. - -@item log(@var{expr}) -the natural logarithm function. - -@item rand() -returns a random number between 0 and 1. - -@item sin(@var{expr}) -returns the sine in radians. - -@item sqrt(@var{expr}) -the square root function. - -@item srand(@var{expr}) -use @var{expr} as a new seed for the random number generator. If no @var{expr} -is provided, the time of day is used. The return value is the previous -seed for the random number generator. -@end table - -@node String Functions Summary, Time Functions Summary, Numeric Functions Summary, Actions Summary -@appendixsubsubsec String Functions - -@code{awk} has the following predefined string functions: - -@table @code -@item gsub(@var{r}, @var{s}, @var{t}) -for each substring matching the regular expression @var{r} in the string -@var{t}, substitute the string @var{s}, and return the number of substitutions. -If @var{t} is not supplied, use @code{$0}. - -@item index(@var{s}, @var{t}) -returns the index of the string @var{t} in the string @var{s}, or 0 if -@var{t} is not present. - -@item length(@var{s}) -returns the length of the string @var{s}. The length of @code{$0} -is returned if no argument is supplied. - -@item match(@var{s}, @var{r}) -returns the position in @var{s} where the regular expression @var{r} -occurs, or 0 if @var{r} is not present, and sets the values of @code{RSTART} -and @code{RLENGTH}. - -@item split(@var{s}, @var{a}, @var{r}) -splits the string @var{s} into the array @var{a} on the regular expression -@var{r}, and returns the number of fields. If @var{r} is omitted, @code{FS} -is used instead. - -@item sprintf(@var{fmt}, @var{expr-list}) -prints @var{expr-list} according to @var{fmt}, and returns the resulting string. - -@item sub(@var{r}, @var{s}, @var{t}) -this is just like @code{gsub}, but only the first matching substring is -replaced. - -@item substr(@var{s}, @var{i}, @var{n}) -returns the @var{n}-character substring of @var{s} starting at @var{i}. -If @var{n} is omitted, the rest of @var{s} is used. - -@item tolower(@var{str}) -returns a copy of the string @var{str}, with all the upper-case characters in -@var{str} translated to their corresponding lower-case counterparts. -Nonalphabetic characters are left unchanged. - -@item toupper(@var{str}) -returns a copy of the string @var{str}, with all the lower-case characters in -@var{str} translated to their corresponding upper-case counterparts. -Nonalphabetic characters are left unchanged. - -@item system(@var{cmd-line}) -Execute the command @var{cmd-line}, and return the exit status. -@end table - -@node Time Functions Summary, String Constants Summary, String Functions Summary, Actions Summary -@appendixsubsubsec Built-in time functions - -The following two functions are available for getting the current -time of day, and for formatting time stamps. - -@table @code -@item systime() -returns the current time of day as the number of seconds since a particular -epoch (Midnight, January 1, 1970 @sc{utc}, on @sc{posix} systems). - -@item strftime(@var{format}, @var{timestamp}) -formats @var{timestamp} according to the specification in @var{format}. -The current time of day is used if no @var{timestamp} is supplied. -@xref{Time Functions, ,Functions for Dealing with Time Stamps}, for the -details on the conversion specifiers that @code{strftime} accepts.@refill -@end table - -@iftex -@xref{Built-in, ,Built-in Functions}, for a description of all of -@code{awk}'s built-in functions. -@end iftex - -@node String Constants Summary, , Time Functions Summary, Actions Summary -@appendixsubsubsec String Constants - -String constants in @code{awk} are sequences of characters enclosed -between double quotes (@code{"}). Within strings, certain @dfn{escape sequences} -are recognized, as in C. These are: - -@table @code -@item \\ -A literal backslash. - -@item \a -The ``alert'' character; usually the ASCII BEL character. - -@item \b -Backspace. - -@item \f -Formfeed. - -@item \n -Newline. - -@item \r -Carriage return. - -@item \t -Horizontal tab. - -@item \v -Vertical tab. - -@item \x@var{hex digits} -The character represented by the string of hexadecimal digits following -the @samp{\x}. As in @sc{ansi} C, all following hexadecimal digits are -considered part of the escape sequence. (This feature should tell us -something about language design by committee.) E.g., @code{"\x1B"} is a -string containing the ASCII ESC (escape) character. (The @samp{\x} -escape sequence is not in @sc{posix} @code{awk}.) - -@item \@var{ddd} -The character represented by the 1-, 2-, or 3-digit sequence of octal -digits. Thus, @code{"\033"} is also a string containing the ASCII ESC -(escape) character. - -@item \@var{c} -The literal character @var{c}. -@end table - -The escape sequences may also be used inside constant regular expressions -(e.g., the regexp @code{@w{/[@ \t\f\n\r\v]/}} matches whitespace -characters).@refill - -@xref{Constants, ,Constant Expressions}. - -@node Functions Summary, Historical Features, Rules Summary, Gawk Summary -@appendixsec Functions - -Functions in @code{awk} are defined as follows: - -@example -function @var{name}(@var{parameter list}) @{ @var{statements} @} -@end example - -Actual parameters supplied in the function call are used to instantiate -the formal parameters declared in the function. Arrays are passed by -reference, other variables are passed by value. - -If there are fewer arguments passed than there are names in @var{parameter-list}, -the extra names are given the null string as value. Extra names have the -effect of local variables. - -The open-parenthesis in a function call of a user-defined function must -immediately follow the function name, without any intervening white space. -This is to avoid a syntactic ambiguity with the concatenation operator. - -The word @code{func} may be used in place of @code{function} (but not in -@sc{posix} @code{awk}). - -Use the @code{return} statement to return a value from a function. - -@xref{User-defined, ,User-defined Functions}, for a more complete description. - -@node Historical Features, , Functions Summary, Gawk Summary -@appendixsec Historical Features - -There are two features of historical @code{awk} implementations that -@code{gawk} supports. First, it is possible to call the @code{length} -built-in function not only with no arguments, but even without parentheses! - -@example -a = length -@end example - -@noindent -is the same as either of - -@example -a = length() -a = length($0) -@end example - -@noindent -This feature is marked as ``deprecated'' in the @sc{posix} standard, and -@code{gawk} will issue a warning about its use if @samp{-W lint} is -specified on the command line. - -The other feature is the use of the @code{continue} statement outside the -body of a @code{while}, @code{for}, or @code{do} loop. Traditional -@code{awk} implementations have treated such usage as equivalent to the -@code{next} statement. @code{gawk} will support this usage if @samp{-W posix} -has not been specified. - -@node Sample Program, Bugs, Gawk Summary, Top -@appendix Sample Program - -The following example is a complete @code{awk} program, which prints -the number of occurrences of each word in its input. It illustrates the -associative nature of @code{awk} arrays by using strings as subscripts. It -also demonstrates the @samp{for @var{x} in @var{array}} construction. -Finally, it shows how @code{awk} can be used in conjunction with other -utility programs to do a useful task of some complexity with a minimum of -effort. Some explanations follow the program listing.@refill - -@example -awk ' -# Print list of word frequencies -@{ - for (i = 1; i <= NF; i++) - freq[$i]++ -@} - -END @{ - for (word in freq) - printf "%s\t%d\n", word, freq[word] -@}' -@end example - -The first thing to notice about this program is that it has two rules. The -first rule, because it has an empty pattern, is executed on every line of -the input. It uses @code{awk}'s field-accessing mechanism -(@pxref{Fields, ,Examining Fields}) to pick out the individual words from -the line, and the built-in variable @code{NF} (@pxref{Built-in Variables}) -to know how many fields are available.@refill - -For each input word, an element of the array @code{freq} is incremented to -reflect that the word has been seen an additional time.@refill - -The second rule, because it has the pattern @code{END}, is not executed -until the input has been exhausted. It prints out the contents of the -@code{freq} table that has been built up inside the first action.@refill - -Note that this program has several problems that would prevent it from being -useful by itself on real text files:@refill - -@itemize @bullet -@item -Words are detected using the @code{awk} convention that fields are -separated by whitespace and that other characters in the input (except -newlines) don't have any special meaning to @code{awk}. This means that -punctuation characters count as part of words.@refill - -@item -The @code{awk} language considers upper and lower case characters to be -distinct. Therefore, @samp{foo} and @samp{Foo} are not treated by this -program as the same word. This is undesirable since in normal text, words -are capitalized if they begin sentences, and a frequency analyzer should not -be sensitive to that.@refill - -@item -The output does not come out in any useful order. You're more likely to be -interested in which words occur most frequently, or having an alphabetized -table of how frequently each word occurs.@refill -@end itemize - -The way to solve these problems is to use some of the more advanced -features of the @code{awk} language. First, we use @code{tolower} to remove -case distinctions. Next, we use @code{gsub} to remove punctuation -characters. Finally, we use the system @code{sort} utility to process the -output of the @code{awk} script. First, here is the new version of -the program:@refill - -@example -awk ' -# Print list of word frequencies -@{ - $0 = tolower($0) # remove case distinctions - gsub(/[^a-z0-9_ \t]/, "", $0) # remove punctuation - for (i = 1; i <= NF; i++) - freq[$i]++ -@} - -END @{ - for (word in freq) - printf "%s\t%d\n", word, freq[word] -@}' -@end example - -Assuming we have saved this program in a file named @file{frequency.awk}, -and that the data is in @file{file1}, the following pipeline - -@example -awk -f frequency.awk file1 | sort +1 -nr -@end example - -@noindent -produces a table of the words appearing in @file{file1} in order of -decreasing frequency. - -The @code{awk} program suitably massages the data and produces a word -frequency table, which is not ordered. - -The @code{awk} script's output is then sorted by the @code{sort} command and -printed on the terminal. The options given to @code{sort} in this example -specify to sort using the second field of each input line (skipping one field), -that the sort keys should be treated as numeric quantities (otherwise -@samp{15} would come before @samp{5}), and that the sorting should be done -in descending (reverse) order.@refill - -We could have even done the @code{sort} from within the program, by -changing the @code{END} action to: - -@example -END @{ - sort = "sort +1 -nr" - for (word in freq) - printf "%s\t%d\n", word, freq[word] | sort - close(sort) -@}' -@end example - -See the general operating system documentation for more information on how -to use the @code{sort} command.@refill - -@ignore -@strong{ADR: I have some more substantial programs courtesy of Rick Adams -at UUNET. I am planning on incorporating those either in addition to or -instead of this program.} - -@strong{I would also like to incorporate the general @code{translate} -function that I have written.} - -@strong{I have a ton of other sample programs to include too.} -@end ignore - -@node Bugs, Notes, Sample Program, Top -@appendix Reporting Problems and Bugs - -@c This chapter stolen shamelessly from the GNU m4 manual. -@c This chapter has been unshamelessly altered to emulate changes made to -@c make.texi from whence it was originally shamelessly stolen! :-} --mew - -If you have problems with @code{gawk} or think that you have found a bug, -please report it to the developers; we cannot promise to do anything -but we might well want to fix it. - -Before reporting a bug, make sure you have actually found a real bug. -Carefully reread the documentation and see if it really says you can do -what you're trying to do. If it's not clear whether you should be able -to do something or not, report that too; it's a bug in the documentation! - -Before reporting a bug or trying to fix it yourself, try to isolate it -to the smallest possible @code{awk} program and input data file that -reproduces the problem. Then send us the program and data file, -some idea of what kind of Unix system you're using, and the exact results -@code{gawk} gave you. Also say what you expected to occur; this will help -us decide whether the problem was really in the documentation. - -Once you have a precise problem, send e-mail to (Internet) -@samp{bug-gnu-utils@@prep.ai.mit.edu} or (UUCP) -@samp{mit-eddie!prep.ai.mit.edu!bug-gnu-utils}. Please include the -version number of @code{gawk} you are using. You can get this information -with the command @samp{gawk -W version '@{@}' /dev/null}. -You should send carbon copies of your mail to David Trueman at -@samp{david@@cs.dal.ca}, and to Arnold Robbins, who can be reached at -@samp{arnold@@skeeve.atl.ga.us}. David is most likely to fix code -problems, while Arnold is most likely to fix documentation problems.@refill - -Non-bug suggestions are always welcome as well. If you have questions -about things that are unclear in the documentation or are just obscure -features, ask Arnold Robbins; he will try to help you out, although he -may not have the time to fix the problem. You can send him electronic mail at the Internet address -above. - -If you find bugs in one of the non-Unix ports of @code{gawk}, please send -an electronic mail message to the person who maintains that port. They -are listed below, and also in the @file{README} file in the @code{gawk} -distribution. Information in the @code{README} file should be considered -authoritative if it conflicts with this manual. - -The people maintaining the non-Unix ports of @code{gawk} are: - -@table @asis -@item MS-DOS -The port to MS-DOS is maintained by Scott Deifik. -His electronic mail address is @samp{scottd@@amgen.com}. - -@item VMS -The port to VAX VMS is maintained by Pat Rankin. -His electronic mail address is @samp{rankin@@eql.caltech.edu}. - -@item Atari ST -The port to the Atari ST is maintained by Michal Jaegermann. -His electronic mail address is @samp{ntomczak@@vm.ucs.ualberta.ca}. - -@end table - -If your bug is also reproducible under Unix, please send copies of your -report to the general GNU bug list, as well as to Arnold Robbins and David -Trueman, at the addresses listed above. - -@node Notes, Glossary, Bugs, Top -@appendix Implementation Notes - -This appendix contains information mainly of interest to implementors and -maintainers of @code{gawk}. Everything in it applies specifically to -@code{gawk}, and not to other implementations. - -@menu -* Compatibility Mode:: How to disable certain @code{gawk} extensions. -* Future Extensions:: New features we may implement soon. -* Improvements:: Suggestions for improvements by volunteers. -@end menu - -@node Compatibility Mode, Future Extensions, Notes, Notes -@appendixsec Downward Compatibility and Debugging - -@xref{POSIX/GNU, ,Extensions in @code{gawk} not in POSIX @code{awk}}, -for a summary of the GNU extensions to the @code{awk} language and program. -All of these features can be turned off by invoking @code{gawk} with the -@samp{-W compat} option, or with the @samp{-W posix} option.@refill - -If @code{gawk} is compiled for debugging with @samp{-DDEBUG}, then there -is one more option available on the command line: - -@table @samp -@item -W parsedebug -Print out the parse stack information as the program is being parsed. -@end table - -This option is intended only for serious @code{gawk} developers, -and not for the casual user. It probably has not even been compiled into -your version of @code{gawk}, since it slows down execution. - -@node Future Extensions, Improvements, Compatibility Mode, Notes -@appendixsec Probable Future Extensions - -This section briefly lists extensions that indicate the directions we are -currently considering for @code{gawk}. The file @file{FUTURES} in the -@code{gawk} distributions lists these extensions, as well as several others. - -@table @asis -@item @code{RS} as a regexp -The meaning of @code{RS} may be generalized along the lines of @code{FS}. - -@item Control of subprocess environment -Changes made in @code{gawk} to the array @code{ENVIRON} may be -propagated to subprocesses run by @code{gawk}. - -@item Databases -It may be possible to map a GDBM/NDBM/SDBM file into an @code{awk} array. - -@item Single-character fields -The null string, @code{""}, as a field separator, will cause field -splitting and the @code{split} function to separate individual characters. -Thus, @code{split(a, "abcd", "")} would yield @code{a[1] == "a"}, -@code{a[2] == "b"}, and so on. - -@item More @code{lint} warnings -There are more things that could be checked for portability. - -@item @code{RECLEN} variable for fixed length records -Along with @code{FIELDWIDTHS}, this would speed up the processing of -fixed-length records. - -@item @code{RT} variable to hold the record terminator -It is occasionally useful to have access to the actual string of -characters that matched the @code{RS} variable. The @code{RT} -variable would hold these characters. - -@item A @code{restart} keyword -After modifying @code{$0}, @code{restart} would restart the pattern -matching loop, without reading a new record from the input. - -@item A @samp{|&} redirection -The @samp{|&} redirection, in place of @samp{|}, would open a two-way -pipeline for communication with a sub-process (via @code{getline} and -@code{print} and @code{printf}). - -@item @code{IGNORECASE} affecting all comparisons -The effects of the @code{IGNORECASE} variable may be generalized to -all string comparisons, and not just regular expression operations. - -@item A way to mix command line source code and library files -There may be a new option that would make it possible to easily use library -functions from a program entered on the command line. -@c probably a @samp{-s} option... - -@item GNU-style long options -We will add GNU-style long options -to @code{gawk} for compatibility with other GNU programs. -(For example, @samp{--field-separator=:} would be equivalent to -@samp{-F:}.)@refill - -@c this is @emph{very} long term --- not worth including right now. -@ignore -@item The C Comma Operator -We may add the C comma operator, which takes the form -@code{@var{expr1},@var{expr2}}. The first expression is evaluated, and the -result is thrown away. The value of the full expression is the value of -@var{expr2}.@refill -@end ignore -@end table - -@node Improvements, , Future Extensions, Notes -@appendixsec Suggestions for Improvements - -Here are some projects that would-be @code{gawk} hackers might like to take -on. They vary in size from a few days to a few weeks of programming, -depending on which one you choose and how fast a programmer you are. Please -send any improvements you write to the maintainers at the GNU -project.@refill - -@enumerate -@item -Compilation of @code{awk} programs: @code{gawk} uses a Bison (YACC-like) -parser to convert the script given it into a syntax tree; the syntax -tree is then executed by a simple recursive evaluator. This method incurs -a lot of overhead, since the recursive evaluator performs many procedure -calls to do even the simplest things.@refill - -It should be possible for @code{gawk} to convert the script's parse tree -into a C program which the user would then compile, using the normal -C compiler and a special @code{gawk} library to provide all the needed -functions (regexps, fields, associative arrays, type coercion, and so -on).@refill - -An easier possibility might be for an intermediate phase of @code{awk} to -convert the parse tree into a linear byte code form like the one used -in GNU Emacs Lisp. The recursive evaluator would then be replaced by -a straight line byte code interpreter that would be intermediate in speed -between running a compiled program and doing what @code{gawk} does -now.@refill - -This may actually happen for the 3.0 version of @code{gawk}. - -@item -An error message section has not been included in this version of the -manual. Perhaps some nice beta testers will document some of the messages -for the future. - -@item -The programs in the test suite could use documenting in this manual. - -@item -The programs and data files in the manual should be available in -separate files to facilitate experimentation. - -@item -See the @file{FUTURES} file for more ideas. Contact us if you would -seriously like to tackle any of the items listed there. -@end enumerate - -@node Glossary, Index, Notes, Top -@appendix Glossary - -@table @asis -@item Action -A series of @code{awk} statements attached to a rule. If the rule's -pattern matches an input record, the @code{awk} language executes the -rule's action. Actions are always enclosed in curly braces. -@xref{Actions, ,Overview of Actions}.@refill - -@item Amazing @code{awk} Assembler -Henry Spencer at the University of Toronto wrote a retargetable assembler -completely as @code{awk} scripts. It is thousands of lines long, including -machine descriptions for several 8-bit microcomputers. -@c It is distributed with @code{gawk} (as part of the test suite) and -It is a good example of a -program that would have been better written in another language.@refill - -@item @sc{ansi} -The American National Standards Institute. This organization produces -many standards, among them the standard for the C programming language. - -@item Assignment -An @code{awk} expression that changes the value of some @code{awk} -variable or data object. An object that you can assign to is called an -@dfn{lvalue}. @xref{Assignment Ops, ,Assignment Expressions}.@refill - -@item @code{awk} Language -The language in which @code{awk} programs are written. - -@item @code{awk} Program -An @code{awk} program consists of a series of @dfn{patterns} and -@dfn{actions}, collectively known as @dfn{rules}. For each input record -given to the program, the program's rules are all processed in turn. -@code{awk} programs may also contain function definitions.@refill - -@item @code{awk} Script -Another name for an @code{awk} program. - -@item Built-in Function -The @code{awk} language provides built-in functions that perform various -numerical, time stamp related, and string computations. Examples are -@code{sqrt} (for the square root of a number) and @code{substr} (for a -substring of a string). @xref{Built-in, ,Built-in Functions}.@refill - -@item Built-in Variable -@code{ARGC}, @code{ARGIND}, @code{ARGV}, @code{CONVFMT}, @code{ENVIRON}, -@code{ERRNO}, @code{FIELDWIDTHS}, @code{FILENAME}, @code{FNR}, @code{FS}, -@code{IGNORECASE}, @code{NF}, @code{NR}, @code{OFMT}, @code{OFS}, @code{ORS}, -@code{RLENGTH}, @code{RSTART}, @code{RS}, and @code{SUBSEP}, -are the variables that have special -meaning to @code{awk}. Changing some of them affects @code{awk}'s running -environment. @xref{Built-in Variables}.@refill - -@item Braces -See ``Curly Braces.'' - -@item C -The system programming language that most GNU software is written in. The -@code{awk} programming language has C-like syntax, and this manual -points out similarities between @code{awk} and C when appropriate.@refill - -@item CHEM -A preprocessor for @code{pic} that reads descriptions of molecules -and produces @code{pic} input for drawing them. It was written by -Brian Kernighan, and is available from @code{netlib@@research.att.com}.@refill - -@item Compound Statement -A series of @code{awk} statements, enclosed in curly braces. Compound -statements may be nested. -@xref{Statements, ,Control Statements in Actions}.@refill - -@item Concatenation -Concatenating two strings means sticking them together, one after another, -giving a new string. For example, the string @samp{foo} concatenated with -the string @samp{bar} gives the string @samp{foobar}. -@xref{Concatenation, ,String Concatenation}.@refill - -@item Conditional Expression -An expression using the @samp{?:} ternary operator, such as -@code{@var{expr1} ? @var{expr2} : @var{expr3}}. The expression -@var{expr1} is evaluated; if the result is true, the value of the whole -expression is the value of @var{expr2} otherwise the value is -@var{expr3}. In either case, only one of @var{expr2} and @var{expr3} -is evaluated. @xref{Conditional Exp, ,Conditional Expressions}.@refill - -@item Constant Regular Expression -A constant regular expression is a regular expression written within -slashes, such as @samp{/foo/}. This regular expression is chosen -when you write the @code{awk} program, and cannot be changed doing -its execution. @xref{Regexp Usage, ,How to Use Regular Expressions}. - -@item Comparison Expression -A relation that is either true or false, such as @code{(a < b)}. -Comparison expressions are used in @code{if}, @code{while}, and @code{for} -statements, and in patterns to select which input records to process. -@xref{Comparison Ops, ,Comparison Expressions}.@refill - -@item Curly Braces -The characters @samp{@{} and @samp{@}}. Curly braces are used in -@code{awk} for delimiting actions, compound statements, and function -bodies.@refill - -@item Data Objects -These are numbers and strings of characters. Numbers are converted into -strings and vice versa, as needed. -@xref{Conversion, ,Conversion of Strings and Numbers}.@refill - -@item Dynamic Regular Expression -A dynamic regular expression is a regular expression written as an -ordinary expression. It could be a string constant, such as -@code{"foo"}, but it may also be an expression whose value may vary. -@xref{Regexp Usage, ,How to Use Regular Expressions}. - -@item Escape Sequences -A special sequence of characters used for describing nonprinting -characters, such as @samp{\n} for newline, or @samp{\033} for the ASCII -ESC (escape) character. @xref{Constants, ,Constant Expressions}. - -@item Field -When @code{awk} reads an input record, it splits the record into pieces -separated by whitespace (or by a separator regexp which you can -change by setting the built-in variable @code{FS}). Such pieces are -called fields. If the pieces are of fixed length, you can use the built-in -variable @code{FIELDWIDTHS} to describe their lengths. -@xref{Records, ,How Input is Split into Records}.@refill - -@item Format -Format strings are used to control the appearance of output in the -@code{printf} statement. Also, data conversions from numbers to strings -are controlled by the format string contained in the built-in variable -@code{CONVFMT}. @xref{Control Letters, ,Format-Control Letters}.@refill - -@item Function -A specialized group of statements often used to encapsulate general -or program-specific tasks. @code{awk} has a number of built-in -functions, and also allows you to define your own. -@xref{Built-in, ,Built-in Functions}. -Also, see @ref{User-defined, ,User-defined Functions}.@refill - -@item @code{gawk} -The GNU implementation of @code{awk}. - -@item GNU -``GNU's not Unix''. An on-going project of the Free Software Foundation -to create a complete, freely distributable, @sc{posix}-compliant computing -environment. - -@item Input Record -A single chunk of data read in by @code{awk}. Usually, an @code{awk} input -record consists of one line of text. -@xref{Records, ,How Input is Split into Records}.@refill - -@item Keyword -In the @code{awk} language, a keyword is a word that has special -meaning. Keywords are reserved and may not be used as variable names. - -@code{awk}'s keywords are: -@code{if}, -@code{else}, -@code{while}, -@code{do@dots{}while}, -@code{for}, -@code{for@dots{}in}, -@code{break}, -@code{continue}, -@code{delete}, -@code{next}, -@code{function}, -@code{func}, -and @code{exit}.@refill - -@item Lvalue -An expression that can appear on the left side of an assignment -operator. In most languages, lvalues can be variables or array -elements. In @code{awk}, a field designator can also be used as an -lvalue.@refill - -@item Number -A numeric valued data object. The @code{gawk} implementation uses double -precision floating point to represent numbers.@refill - -@item Pattern -Patterns tell @code{awk} which input records are interesting to which -rules. - -A pattern is an arbitrary conditional expression against which input is -tested. If the condition is satisfied, the pattern is said to @dfn{match} -the input record. A typical pattern might compare the input record against -a regular expression. @xref{Patterns}.@refill - -@item @sc{posix} -The name for a series of standards being developed by the @sc{ieee} -that specify a Portable Operating System interface. The ``IX'' denotes -the Unix heritage of these standards. The main standard of interest for -@code{awk} users is P1003.2, the Command Language and Utilities standard. - -@item Range (of input lines) -A sequence of consecutive lines from the input file. A pattern -can specify ranges of input lines for @code{awk} to process, or it can -specify single lines. @xref{Patterns}.@refill - -@item Recursion -When a function calls itself, either directly or indirectly. -If this isn't clear, refer to the entry for ``recursion.'' - -@item Redirection -Redirection means performing input from other than the standard input -stream, or output to other than the standard output stream. - -You can redirect the output of the @code{print} and @code{printf} statements -to a file or a system command, using the @samp{>}, @samp{>>}, and @samp{|} -operators. You can redirect input to the @code{getline} statement using -the @samp{<} and @samp{|} operators. -@xref{Redirection, ,Redirecting Output of @code{print} and @code{printf}}.@refill - -@item Regular Expression -See ``regexp.'' - -@item Regexp -Short for @dfn{regular expression}. A regexp is a pattern that denotes a -set of strings, possibly an infinite set. For example, the regexp -@samp{R.*xp} matches any string starting with the letter @samp{R} -and ending with the letters @samp{xp}. In @code{awk}, regexps are -used in patterns and in conditional expressions. Regexps may contain -escape sequences. @xref{Regexp, ,Regular Expressions as Patterns}.@refill - -@item Rule -A segment of an @code{awk} program, that specifies how to process single -input records. A rule consists of a @dfn{pattern} and an @dfn{action}. -@code{awk} reads an input record; then, for each rule, if the input record -satisfies the rule's pattern, @code{awk} executes the rule's action. -Otherwise, the rule does nothing for that input record.@refill - -@item Side Effect -A side effect occurs when an expression has an effect aside from merely -producing a value. Assignment expressions, increment expressions and -function calls have side effects. @xref{Assignment Ops, ,Assignment Expressions}. - -@item Special File -A file name interpreted internally by @code{gawk}, instead of being handed -directly to the underlying operating system. For example, @file{/dev/stdin}. -@xref{Special Files, ,Standard I/O Streams}. - -@item Stream Editor -A program that reads records from an input stream and processes them one -or more at a time. This is in contrast with batch programs, which may -expect to read their input files in entirety before starting to do -anything, and with interactive programs, which require input from the -user.@refill - -@item String -A datum consisting of a sequence of characters, such as @samp{I am a -string}. Constant strings are written with double-quotes in the -@code{awk} language, and may contain escape sequences. -@xref{Constants, ,Constant Expressions}. - -@item Whitespace -A sequence of blank or tab characters occurring inside an input record or a -string.@refill -@end table - -@node Index, , Glossary, Top -@unnumbered Index -@printindex cp - -@summarycontents -@contents -@bye - -Unresolved Issues: ------------------- -1. From: ntomczak@vm.ucs.ualberta.ca (Michal Jaegermann) - Examples of usage tend to suggest that /../ and ".." delimiters - can be used for regular expressions, even if definition is consistently - using /../. I am not sure what the real rules are and in particular - what of the following is a bug and what is a feature: - # This program matches everything - '"\(" { print }' - # This one complains about mismatched parenthesis - '$0 ~ "\(" { print }' - # This one behaves in an expected manner - '/\(/ { print }' - You may also try to use "\(" as an argument to match() to see what - will happen. - -2. From ADR. - - The posix (and original Unix!) notion of awk values as both number - and string values needs to be put into the manual. This involves - major and minor rewrites of most of the manual, but should help in - clarifying many of the weirder points of the language. - -3. From ADR. - - The manual should be reorganized. Expressions should be introduced - early, building up to regexps as expressions, and from there to their - use as patterns and then in actions. Built-in vars should come earlier - in the manual too. The 'expert info' sections marked with comments - should get their own sections or subsections with nodes and titles. - The manual should be gone over thoroughly for indexing. - -4. From ADR. - - Robert J. Chassell points out that awk programs should have some indication - of how to use them. It would be useful to perhaps have a "programming - style" section of the manual that would include this and other tips. - -5. From ADR in response to moraes@uunet.ca - (This would make the beginnings of a good "puzzles" section...) - - Date: Mon, 2 Dec 91 10:08:05 EST - From: gatech!cc!arnold (Arnold Robbins) - To: cs.dal.ca!david, uunet.ca!moraes - Subject: redirecting to /dev/stderr - Cc: skeeve!arnold, boeing.com!brennan, research.att.com!bwk - - In 2.13.3 the following program no longer dumps core: - - BEGIN { print "hello" > /dev/stderr ; exit(1) } - - Instead, it creates a file named `0' with the word `hello' in it. AWK - semantics strikes again. The meaning of the statement is - - print "hello" > (($0 ~ /dev/) stderr) - - /dev/ tests $0 for the pattern `dev'. This yields a 0. The variable stderr, - having never been used, has a null string in it. The concatenation yields - a string value of "0" which is used as the file name. Sigh. - - I think with some more time I can come up with a decent fix, but it will - probably only print a diagnostic with -Wlint. - - Arnold - diff --git a/gnu/usr.bin/gawk-2.15.2/getopt.c b/gnu/usr.bin/gawk-2.15.2/getopt.c deleted file mode 100644 index bbf345c33ca2..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/getopt.c +++ /dev/null @@ -1,662 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu - before changing it! - - Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc. - - This program 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, 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 Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef GAWK -#include "config.h" -#endif - -#include - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include -#include -#endif /* GNU C library. */ - - -#ifndef __STDC__ -#define const -#endif - -/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a - long-named option. Because this is not POSIX.2 compliant, it is - being phased out. */ -#define GETOPT_COMPAT - -/* 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 POSIXLY_CORRECT 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 "getopt.h" - -/* 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 - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the 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; - -#ifdef __GNU_LIBRARY__ -#include -#define my_index strchr -#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) -#else - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -char *getenv (); - -static char * -my_index (string, chr) - char *string; - int chr; -{ - while (*string) - { - if (*string == chr) - return string; - string++; - } - return 0; -} - -static void -my_bcopy (from, to, size) - char *from, *to; - int size; -{ - int i; - for (i = 0; i < size; i++) - to[i] = from[i]; -} -#endif /* GNU C library. */ - -/* 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 **) malloc (nonopts_size); - - /* Interchange the two blocks of data in ARGV. */ - - my_bcopy (&argv[first_nonopt], temp, nonopts_size); - my_bcopy (&argv[last_nonopt], &argv[first_nonopt], - (optind - last_nonopt) * sizeof (char *)); - my_bcopy (temp, &argv[first_nonopt + optind - last_nonopt], nonopts_size); - - free(temp); - - /* 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 - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - int option_index; - - 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 = NULL; - - /* 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 ("POSIXLY_CORRECT") != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - } - - 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 ((char **) 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') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - 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 ((char **) 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') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - { - 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 - + (longopts != NULL && argv[optind][1] == '-')); - } - - if (longopts != NULL - && ((argv[optind][0] == '-' - && (argv[optind][1] == '-' || long_only)) -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - )) - { - const struct option *p; - char *s = nextchar; - int exact = 0; - int ambig = 0; - const struct option *pfound = NULL; - int indfound = 0; - extern int strncmp(); - - while (*s && *s != '=') - s++; - - /* Test all options for either exact match or abbreviated matches. */ - for (p = longopts, 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 == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*s) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = s + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - else - /* +option or -option */ - 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 - { - if (opterr) - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, "%s: unrecognized option `--%s'\n", - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, "%s: unrecognized option `%c%s'\n", - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - return '?'; - } - } - - /* Look at and handle the next option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (opterr) - { - 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 = NULL; - } - 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) - 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 = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -#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/gnu/usr.bin/gawk-2.15.2/getopt.h b/gnu/usr.bin/gawk-2.15.2/getopt.h deleted file mode 100644 index de027434f7cb..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/getopt.h +++ /dev/null @@ -1,128 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. - - This program 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, 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 Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* 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. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, 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 -{ -#if __STDC__ - const char *name; -#else - char *name; -#endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -enum _argtype -{ - no_argument, - required_argument, - optional_argument -}; - -#if __STDC__ -#if defined(__GNU_LIBRARY__) -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ -extern int getopt (); -#endif /* not __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* not __STDC__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* _GETOPT_H */ diff --git a/gnu/usr.bin/gawk-2.15.2/getopt1.c b/gnu/usr.bin/gawk-2.15.2/getopt1.c deleted file mode 100644 index e2127cd58d42..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/getopt1.c +++ /dev/null @@ -1,160 +0,0 @@ -/* Getopt for GNU. - Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc. - -This file is part of the libiberty library. -Libiberty 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. - -Libiberty 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 libiberty; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#ifdef LIBC -/* For when compiled as part of the GNU C library. */ -#include -#endif - -#include "getopt.h" - -#ifndef __STDC__ -#define const -#endif - -#if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) || defined (LIBC) -#include -#else /* STDC_HEADERS or __GNU_LIBRARY__ */ -char *getenv (); -#endif /* STDC_HEADERS or __GNU_LIBRARY__ */ - -#if !defined (NULL) -#define NULL 0 -#endif - -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') 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 *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - -#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; - 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 'd': - printf ("option d 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/gnu/usr.bin/gawk-2.15.2/io.c b/gnu/usr.bin/gawk-2.15.2/io.c deleted file mode 100644 index 7004aedd519d..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/io.c +++ /dev/null @@ -1,1207 +0,0 @@ -/* - * io.c --- routines for dealing with input and output and records - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "awk.h" - -#ifndef O_RDONLY -#include -#endif - -#if !defined(S_ISDIR) && defined(S_IFDIR) -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#endif - -#ifndef atarist -#define INVALID_HANDLE (-1) -#else -#define INVALID_HANDLE (__SMALLEST_VALID_HANDLE - 1) -#endif - -#if defined(MSDOS) || defined(atarist) -#define PIPES_SIMULATED -#endif - -static IOBUF *nextfile P((int skipping)); -static int inrec P((IOBUF *iop)); -static int iop_close P((IOBUF *iop)); -struct redirect *redirect P((NODE *tree, int *errflg)); -static void close_one P((void)); -static int close_redir P((struct redirect *rp)); -#ifndef PIPES_SIMULATED -static int wait_any P((int interesting)); -#endif -static IOBUF *gawk_popen P((char *cmd, struct redirect *rp)); -static IOBUF *iop_open P((char *file, char *how)); -static int gawk_pclose P((struct redirect *rp)); -static int do_pathopen P((char *file)); - -extern FILE *fdopen(); -extern FILE *popen(); - -static struct redirect *red_head = NULL; - -extern int output_is_tty; -extern NODE *ARGC_node; -extern NODE *ARGV_node; -extern NODE *ARGIND_node; -extern NODE *ERRNO_node; -extern NODE **fields_arr; - -static jmp_buf filebuf; /* for do_nextfile() */ - -/* do_nextfile --- implement gawk "next file" extension */ - -void -do_nextfile() -{ - (void) nextfile(1); - longjmp(filebuf, 1); -} - -static IOBUF * -nextfile(skipping) -int skipping; -{ - static int i = 1; - static int files = 0; - NODE *arg; - int fd = INVALID_HANDLE; - static IOBUF *curfile = NULL; - - if (skipping) { - if (curfile != NULL) - iop_close(curfile); - curfile = NULL; - return NULL; - } - if (curfile != NULL) { - if (curfile->cnt == EOF) { - (void) iop_close(curfile); - curfile = NULL; - } else - return curfile; - } - for (; i < (int) (ARGC_node->lnode->numbr); i++) { - arg = *assoc_lookup(ARGV_node, tmp_number((AWKNUM) i)); - if (arg->stptr[0] == '\0') - continue; - arg->stptr[arg->stlen] = '\0'; - if (! do_unix) { - ARGIND_node->var_value->numbr = i; - ARGIND_node->var_value->flags = NUM|NUMBER; - } - if (!arg_assign(arg->stptr)) { - files++; - curfile = iop_open(arg->stptr, "r"); - if (curfile == NULL) - fatal("cannot open file `%s' for reading (%s)", - arg->stptr, strerror(errno)); - /* NOTREACHED */ - /* This is a kludge. */ - unref(FILENAME_node->var_value); - FILENAME_node->var_value = - dupnode(arg); - FNR = 0; - i++; - break; - } - } - if (files == 0) { - files++; - /* no args. -- use stdin */ - /* FILENAME is init'ed to "-" */ - /* FNR is init'ed to 0 */ - curfile = iop_alloc(fileno(stdin)); - } - return curfile; -} - -void -set_FNR() -{ - FNR = (int) FNR_node->var_value->numbr; -} - -void -set_NR() -{ - NR = (int) NR_node->var_value->numbr; -} - -/* - * This reads in a record from the input file - */ -static int -inrec(iop) -IOBUF *iop; -{ - char *begin; - register int cnt; - int retval = 0; - - cnt = get_a_record(&begin, iop, *RS, NULL); - if (cnt == EOF) { - cnt = 0; - retval = 1; - } else { - NR += 1; - FNR += 1; - } - set_record(begin, cnt, 1); - - return retval; -} - -static int -iop_close(iop) -IOBUF *iop; -{ - int ret; - - if (iop == NULL) - return 0; - errno = 0; - -#ifdef _CRAY - /* Work around bug in UNICOS popen */ - if (iop->fd < 3) - ret = 0; - else -#endif - /* save these for re-use; don't free the storage */ - if ((iop->flag & IOP_IS_INTERNAL) != 0) { - iop->off = iop->buf; - iop->end = iop->buf + strlen(iop->buf); - iop->cnt = 0; - iop->secsiz = 0; - return 0; - } - - /* Don't close standard files or else crufty code elsewhere will lose */ - if (iop->fd == fileno(stdin) || - iop->fd == fileno(stdout) || - iop->fd == fileno(stderr)) - ret = 0; - else - ret = close(iop->fd); - if (ret == -1) - warning("close of fd %d failed (%s)", iop->fd, strerror(errno)); - if ((iop->flag & IOP_NO_FREE) == 0) { - /* - * be careful -- $0 may still reference the buffer even though - * an explicit close is being done; in the future, maybe we - * can do this a bit better - */ - if (iop->buf) { - if ((fields_arr[0]->stptr >= iop->buf) - && (fields_arr[0]->stptr < iop->end)) { - NODE *t; - - t = make_string(fields_arr[0]->stptr, - fields_arr[0]->stlen); - unref(fields_arr[0]); - fields_arr [0] = t; - reset_record (); - } - free(iop->buf); - } - free((char *)iop); - } - return ret == -1 ? 1 : 0; -} - -void -do_input() -{ - IOBUF *iop; - extern int exiting; - - if (setjmp(filebuf) != 0) { - } - while ((iop = nextfile(0)) != NULL) { - if (inrec(iop) == 0) - while (interpret(expression_value) && inrec(iop) == 0) - ; - if (exiting) - break; - } -} - -/* Redirection for printf and print commands */ -struct redirect * -redirect(tree, errflg) -NODE *tree; -int *errflg; -{ - register NODE *tmp; - register struct redirect *rp; - register char *str; - int tflag = 0; - int outflag = 0; - char *direction = "to"; - char *mode; - int fd; - char *what = NULL; - - switch (tree->type) { - case Node_redirect_append: - tflag = RED_APPEND; - /* FALL THROUGH */ - case Node_redirect_output: - outflag = (RED_FILE|RED_WRITE); - tflag |= outflag; - if (tree->type == Node_redirect_output) - what = ">"; - else - what = ">>"; - break; - case Node_redirect_pipe: - tflag = (RED_PIPE|RED_WRITE); - what = "|"; - break; - case Node_redirect_pipein: - tflag = (RED_PIPE|RED_READ); - what = "|"; - break; - case Node_redirect_input: - tflag = (RED_FILE|RED_READ); - what = "<"; - break; - default: - fatal ("invalid tree type %d in redirect()", tree->type); - break; - } - tmp = tree_eval(tree->subnode); - if (do_lint && ! (tmp->flags & STR)) - warning("expression in `%s' redirection only has numeric value", - what); - tmp = force_string(tmp); - str = tmp->stptr; - if (str == NULL || *str == '\0') - fatal("expression for `%s' redirection has null string value", - what); - if (do_lint - && (STREQN(str, "0", tmp->stlen) || STREQN(str, "1", tmp->stlen))) - warning("filename `%s' for `%s' redirection may be result of logical expression", str, what); - for (rp = red_head; rp != NULL; rp = rp->next) - if (strlen(rp->value) == tmp->stlen - && STREQN(rp->value, str, tmp->stlen) - && ((rp->flag & ~(RED_NOBUF|RED_EOF)) == tflag - || (outflag - && (rp->flag & (RED_FILE|RED_WRITE)) == outflag))) - break; - if (rp == NULL) { - emalloc(rp, struct redirect *, sizeof(struct redirect), - "redirect"); - emalloc(str, char *, tmp->stlen+1, "redirect"); - memcpy(str, tmp->stptr, tmp->stlen); - str[tmp->stlen] = '\0'; - rp->value = str; - rp->flag = tflag; - rp->fp = NULL; - rp->iop = NULL; - rp->pid = 0; /* unlikely that we're worried about init */ - rp->status = 0; - /* maintain list in most-recently-used first order */ - if (red_head) - red_head->prev = rp; - rp->prev = NULL; - rp->next = red_head; - red_head = rp; - } - while (rp->fp == NULL && rp->iop == NULL) { - if (rp->flag & RED_EOF) - /* encountered EOF on file or pipe -- must be cleared - * by explicit close() before reading more - */ - return rp; - mode = NULL; - errno = 0; - switch (tree->type) { - case Node_redirect_output: - mode = "w"; - if (rp->flag & RED_USED) - mode = "a"; - break; - case Node_redirect_append: - mode = "a"; - break; - case Node_redirect_pipe: - if ((rp->fp = popen(str, "w")) == NULL) - fatal("can't open pipe (\"%s\") for output (%s)", - str, strerror(errno)); - rp->flag |= RED_NOBUF; - break; - case Node_redirect_pipein: - direction = "from"; - if (gawk_popen(str, rp) == NULL) - fatal("can't open pipe (\"%s\") for input (%s)", - str, strerror(errno)); - break; - case Node_redirect_input: - direction = "from"; - rp->iop = iop_open(str, "r"); - break; - default: - cant_happen(); - } - if (mode != NULL) { - fd = devopen(str, mode); - if (fd > INVALID_HANDLE) { - if (fd == fileno(stdin)) - rp->fp = stdin; - else if (fd == fileno(stdout)) - rp->fp = stdout; - else if (fd == fileno(stderr)) - rp->fp = stderr; - else - rp->fp = fdopen(fd, mode); - if (isatty(fd)) - rp->flag |= RED_NOBUF; - } - } - if (rp->fp == NULL && rp->iop == NULL) { - /* too many files open -- close one and try again */ - if (errno == EMFILE) - close_one(); - else { - /* - * Some other reason for failure. - * - * On redirection of input from a file, - * just return an error, so e.g. getline - * can return -1. For output to file, - * complain. The shell will complain on - * a bad command to a pipe. - */ - *errflg = errno; - if (tree->type == Node_redirect_output - || tree->type == Node_redirect_append) - fatal("can't redirect %s `%s' (%s)", - direction, str, strerror(errno)); - else { - free_temp(tmp); - return NULL; - } - } - } - } - free_temp(tmp); - return rp; -} - -static void -close_one() -{ - register struct redirect *rp; - register struct redirect *rplast = NULL; - - /* go to end of list first, to pick up least recently used entry */ - for (rp = red_head; rp != NULL; rp = rp->next) - rplast = rp; - /* now work back up through the list */ - for (rp = rplast; rp != NULL; rp = rp->prev) - if (rp->fp && (rp->flag & RED_FILE)) { - rp->flag |= RED_USED; - errno = 0; - if (fclose(rp->fp)) - warning("close of \"%s\" failed (%s).", - rp->value, strerror(errno)); - rp->fp = NULL; - break; - } - if (rp == NULL) - /* surely this is the only reason ??? */ - fatal("too many pipes or input files open"); -} - -NODE * -do_close(tree) -NODE *tree; -{ - NODE *tmp; - register struct redirect *rp; - - tmp = force_string(tree_eval(tree->subnode)); - for (rp = red_head; rp != NULL; rp = rp->next) { - if (strlen(rp->value) == tmp->stlen - && STREQN(rp->value, tmp->stptr, tmp->stlen)) - break; - } - free_temp(tmp); - if (rp == NULL) /* no match */ - return tmp_number((AWKNUM) 0.0); - fflush(stdout); /* synchronize regular output */ - tmp = tmp_number((AWKNUM)close_redir(rp)); - rp = NULL; - return tmp; -} - -static int -close_redir(rp) -register struct redirect *rp; -{ - int status = 0; - - if (rp == NULL) - return 0; - if (rp->fp == stdout || rp->fp == stderr) - return 0; - errno = 0; - if ((rp->flag & (RED_PIPE|RED_WRITE)) == (RED_PIPE|RED_WRITE)) - status = pclose(rp->fp); - else if (rp->fp) - status = fclose(rp->fp); - else if (rp->iop) { - if (rp->flag & RED_PIPE) - status = gawk_pclose(rp); - else { - status = iop_close(rp->iop); - rp->iop = NULL; - } - } - /* SVR4 awk checks and warns about status of close */ - if (status) { - char *s = strerror(errno); - - warning("failure status (%d) on %s close of \"%s\" (%s).", - status, - (rp->flag & RED_PIPE) ? "pipe" : - "file", rp->value, s); - - if (! do_unix) { - /* set ERRNO too so that program can get at it */ - unref(ERRNO_node->var_value); - ERRNO_node->var_value = make_string(s, strlen(s)); - } - } - if (rp->next) - rp->next->prev = rp->prev; - if (rp->prev) - rp->prev->next = rp->next; - else - red_head = rp->next; - free(rp->value); - free((char *)rp); - return status; -} - -int -flush_io () -{ - register struct redirect *rp; - int status = 0; - - errno = 0; - if (fflush(stdout)) { - warning("error writing standard output (%s).", strerror(errno)); - status++; - } - if (fflush(stderr)) { - warning("error writing standard error (%s).", strerror(errno)); - status++; - } - for (rp = red_head; rp != NULL; rp = rp->next) - /* flush both files and pipes, what the heck */ - if ((rp->flag & RED_WRITE) && rp->fp != NULL) { - if (fflush(rp->fp)) { - warning("%s flush of \"%s\" failed (%s).", - (rp->flag & RED_PIPE) ? "pipe" : - "file", rp->value, strerror(errno)); - status++; - } - } - return status; -} - -int -close_io () -{ - register struct redirect *rp; - register struct redirect *next; - int status = 0; - - errno = 0; - if (fclose(stdout)) { - warning("error writing standard output (%s).", strerror(errno)); - status++; - } - if (fclose(stderr)) { - warning("error writing standard error (%s).", strerror(errno)); - status++; - } - for (rp = red_head; rp != NULL; rp = next) { - next = rp->next; - if (close_redir(rp)) - status++; - rp = NULL; - } - return status; -} - -/* str2mode --- convert a string mode to an integer mode */ - -static int -str2mode(mode) -char *mode; -{ - int ret; - - switch(mode[0]) { - case 'r': - ret = O_RDONLY; - break; - - case 'w': - ret = O_WRONLY|O_CREAT|O_TRUNC; - break; - - case 'a': - ret = O_WRONLY|O_APPEND|O_CREAT; - break; - default: - cant_happen(); - } - return ret; -} - -/* devopen --- handle /dev/std{in,out,err}, /dev/fd/N, regular files */ - -/* - * This separate version is still needed for output, since file and pipe - * output is done with stdio. iop_open() handles input with IOBUFs of - * more "special" files. Those files are not handled here since it makes - * no sense to use them for output. - */ - -int -devopen(name, mode) -char *name, *mode; -{ - int openfd = INVALID_HANDLE; - char *cp, *ptr; - int flag = 0; - struct stat buf; - extern double strtod(); - - flag = str2mode(mode); - - if (do_unix) - goto strictopen; - -#ifdef VMS - if ((openfd = vms_devopen(name, flag)) >= 0) - return openfd; -#endif /* VMS */ - - if (STREQ(name, "-")) - openfd = fileno(stdin); - else if (STREQN(name, "/dev/", 5) && stat(name, &buf) == -1) { - cp = name + 5; - - if (STREQ(cp, "stdin") && (flag & O_RDONLY) == O_RDONLY) - openfd = fileno(stdin); - else if (STREQ(cp, "stdout") && (flag & O_WRONLY) == O_WRONLY) - openfd = fileno(stdout); - else if (STREQ(cp, "stderr") && (flag & O_WRONLY) == O_WRONLY) - openfd = fileno(stderr); - else if (STREQN(cp, "fd/", 3)) { - cp += 3; - openfd = (int)strtod(cp, &ptr); - if (openfd <= INVALID_HANDLE || ptr == cp) - openfd = INVALID_HANDLE; - } - } - -strictopen: - if (openfd == INVALID_HANDLE) - openfd = open(name, flag, 0666); - if (openfd != INVALID_HANDLE && fstat(openfd, &buf) > 0) - if (S_ISDIR(buf.st_mode)) - fatal("file `%s' is a directory", name); - return openfd; -} - - -/* spec_setup --- setup an IOBUF for a special internal file */ - -void -spec_setup(iop, len, allocate) -IOBUF *iop; -int len; -int allocate; -{ - char *cp; - - if (allocate) { - emalloc(cp, char *, len+2, "spec_setup"); - iop->buf = cp; - } else { - len = strlen(iop->buf); - iop->buf[len++] = '\n'; /* get_a_record clobbered it */ - iop->buf[len] = '\0'; /* just in case */ - } - iop->off = iop->buf; - iop->cnt = 0; - iop->secsiz = 0; - iop->size = len; - iop->end = iop->buf + len; - iop->fd = -1; - iop->flag = IOP_IS_INTERNAL; -} - -/* specfdopen --- open a fd special file */ - -int -specfdopen(iop, name, mode) -IOBUF *iop; -char *name, *mode; -{ - int fd; - IOBUF *tp; - - fd = devopen(name, mode); - if (fd == INVALID_HANDLE) - return INVALID_HANDLE; - tp = iop_alloc(fd); - if (tp == NULL) - return INVALID_HANDLE; - *iop = *tp; - iop->flag |= IOP_NO_FREE; - free(tp); - return 0; -} - -/* pidopen --- "open" /dev/pid, /dev/ppid, and /dev/pgrpid */ - -int -pidopen(iop, name, mode) -IOBUF *iop; -char *name, *mode; -{ - char tbuf[BUFSIZ]; - int i; - - if (name[6] == 'g') -/* following #if will improve in 2.16 */ -#if defined(__svr4__) || defined(i860) || defined(_AIX) || defined(BSD4_4) || defined(__386BSD__) - sprintf(tbuf, "%d\n", getpgrp()); -#else - sprintf(tbuf, "%d\n", getpgrp(getpid())); -#endif - else if (name[6] == 'i') - sprintf(tbuf, "%d\n", getpid()); - else - sprintf(tbuf, "%d\n", getppid()); - i = strlen(tbuf); - spec_setup(iop, i, 1); - strcpy(iop->buf, tbuf); - return 0; -} - -/* useropen --- "open" /dev/user */ - -/* - * /dev/user creates a record as follows: - * $1 = getuid() - * $2 = geteuid() - * $3 = getgid() - * $4 = getegid() - * If multiple groups are supported, the $5 through $NF are the - * supplementary group set. - */ - -int -useropen(iop, name, mode) -IOBUF *iop; -char *name, *mode; -{ - char tbuf[BUFSIZ], *cp; - int i; -#if defined(NGROUPS_MAX) && NGROUPS_MAX > 0 - int groupset[NGROUPS_MAX]; - int ngroups; -#endif - - sprintf(tbuf, "%d %d %d %d", getuid(), geteuid(), getgid(), getegid()); - - cp = tbuf + strlen(tbuf); -#if defined(NGROUPS_MAX) && NGROUPS_MAX > 0 - ngroups = getgroups(NGROUPS_MAX, groupset); - if (ngroups == -1) - fatal("could not find groups: %s", strerror(errno)); - - for (i = 0; i < ngroups; i++) { - *cp++ = ' '; - sprintf(cp, "%d", groupset[i]); - cp += strlen(cp); - } -#endif - *cp++ = '\n'; - *cp++ = '\0'; - - - i = strlen(tbuf); - spec_setup(iop, i, 1); - strcpy(iop->buf, tbuf); - return 0; -} - -/* iop_open --- handle special and regular files for input */ - -static IOBUF * -iop_open(name, mode) -char *name, *mode; -{ - int openfd = INVALID_HANDLE; - char *cp, *ptr; - int flag = 0; - int i; - struct stat buf; - IOBUF *iop; - static struct internal { - char *name; - int compare; - int (*fp)(); - IOBUF iob; - } table[] = { - { "/dev/fd/", 8, specfdopen }, - { "/dev/stdin", 10, specfdopen }, - { "/dev/stdout", 11, specfdopen }, - { "/dev/stderr", 11, specfdopen }, - { "/dev/pid", 8, pidopen }, - { "/dev/ppid", 9, pidopen }, - { "/dev/pgrpid", 11, pidopen }, - { "/dev/user", 9, useropen }, - }; - int devcount = sizeof(table) / sizeof(table[0]); - - flag = str2mode(mode); - - if (do_unix) - goto strictopen; - - if (STREQ(name, "-")) - openfd = fileno(stdin); - else if (STREQN(name, "/dev/", 5) && stat(name, &buf) == -1) { - int i; - - for (i = 0; i < devcount; i++) { - if (STREQN(name, table[i].name, table[i].compare)) { - IOBUF *iop = & table[i].iob; - - if (iop->buf != NULL) { - spec_setup(iop, 0, 0); - return iop; - } else if ((*table[i].fp)(iop, name, mode) == 0) - return iop; - else { - warning("could not open %s, mode `%s'", - name, mode); - return NULL; - } - } - } - } - -strictopen: - if (openfd == INVALID_HANDLE) - openfd = open(name, flag, 0666); - if (openfd != INVALID_HANDLE && fstat(openfd, &buf) > 0) - if ((buf.st_mode & S_IFMT) == S_IFDIR) - fatal("file `%s' is a directory", name); - iop = iop_alloc(openfd); - return iop; -} - -#ifndef PIPES_SIMULATED - /* real pipes */ -static int -wait_any(interesting) -int interesting; /* pid of interest, if any */ -{ - SIGTYPE (*hstat)(), (*istat)(), (*qstat)(); - int pid; - int status = 0; - struct redirect *redp; - extern int errno; - - hstat = signal(SIGHUP, SIG_IGN); - istat = signal(SIGINT, SIG_IGN); - qstat = signal(SIGQUIT, SIG_IGN); - for (;;) { -#ifdef NeXT - pid = wait((union wait *)&status); -#else - pid = wait(&status); -#endif /* NeXT */ - if (interesting && pid == interesting) { - break; - } else if (pid != -1) { - for (redp = red_head; redp != NULL; redp = redp->next) - if (pid == redp->pid) { - redp->pid = -1; - redp->status = status; - if (redp->fp) { - pclose(redp->fp); - redp->fp = 0; - } - if (redp->iop) { - (void) iop_close(redp->iop); - redp->iop = 0; - } - break; - } - } - if (pid == -1 && errno == ECHILD) - break; - } - signal(SIGHUP, hstat); - signal(SIGINT, istat); - signal(SIGQUIT, qstat); - return(status); -} - -static IOBUF * -gawk_popen(cmd, rp) -char *cmd; -struct redirect *rp; -{ - int p[2]; - register int pid; - - /* used to wait for any children to synchronize input and output, - * but this could cause gawk to hang when it is started in a pipeline - * and thus has a child process feeding it input (shell dependant) - */ - /*(void) wait_any(0);*/ /* wait for outstanding processes */ - - if (pipe(p) < 0) - fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno)); - if ((pid = fork()) == 0) { - if (close(1) == -1) - fatal("close of stdout in child failed (%s)", - strerror(errno)); - if (dup(p[1]) != 1) - fatal("dup of pipe failed (%s)", strerror(errno)); - if (close(p[0]) == -1 || close(p[1]) == -1) - fatal("close of pipe failed (%s)", strerror(errno)); - if (close(0) == -1) - fatal("close of stdin in child failed (%s)", - strerror(errno)); - execl("/bin/sh", "sh", "-c", cmd, 0); - _exit(127); - } - if (pid == -1) - fatal("cannot fork for \"%s\" (%s)", cmd, strerror(errno)); - rp->pid = pid; - if (close(p[1]) == -1) - fatal("close of pipe failed (%s)", strerror(errno)); - return (rp->iop = iop_alloc(p[0])); -} - -static int -gawk_pclose(rp) -struct redirect *rp; -{ - (void) iop_close(rp->iop); - rp->iop = NULL; - - /* process previously found, return stored status */ - if (rp->pid == -1) - return (rp->status >> 8) & 0xFF; - rp->status = wait_any(rp->pid); - rp->pid = -1; - return (rp->status >> 8) & 0xFF; -} - -#else /* PIPES_SIMULATED */ - /* use temporary file rather than pipe */ - -#ifdef VMS -static IOBUF * -gawk_popen(cmd, rp) -char *cmd; -struct redirect *rp; -{ - FILE *current; - - if ((current = popen(cmd, "r")) == NULL) - return NULL; - return (rp->iop = iop_alloc(fileno(current))); -} - -static int -gawk_pclose(rp) -struct redirect *rp; -{ - int rval, aval, fd = rp->iop->fd; - FILE *kludge = fdopen(fd, "r"); /* pclose needs FILE* w/ right fileno */ - - rp->iop->fd = dup(fd); /* kludge to allow close() + pclose() */ - rval = iop_close(rp->iop); - rp->iop = NULL; - aval = pclose(kludge); - return (rval < 0 ? rval : aval); -} -#else /* VMS */ - -static -struct { - char *command; - char *name; -} pipes[_NFILE]; - -static IOBUF * -gawk_popen(cmd, rp) -char *cmd; -struct redirect *rp; -{ - extern char *strdup(const char *); - int current; - char *name; - static char cmdbuf[256]; - - /* get a name to use. */ - if ((name = tempnam(".", "pip")) == NULL) - return NULL; - sprintf(cmdbuf,"%s > %s", cmd, name); - system(cmdbuf); - if ((current = open(name,O_RDONLY)) == INVALID_HANDLE) - return NULL; - pipes[current].name = name; - pipes[current].command = strdup(cmd); - rp->iop = iop_alloc(current); - return (rp->iop = iop_alloc(current)); -} - -static int -gawk_pclose(rp) -struct redirect *rp; -{ - int cur = rp->iop->fd; - int rval; - - rval = iop_close(rp->iop); - rp->iop = NULL; - - /* check for an open file */ - if (pipes[cur].name == NULL) - return -1; - unlink(pipes[cur].name); - free(pipes[cur].name); - pipes[cur].name = NULL; - free(pipes[cur].command); - return rval; -} -#endif /* VMS */ - -#endif /* PIPES_SIMULATED */ - -NODE * -do_getline(tree) -NODE *tree; -{ - struct redirect *rp = NULL; - IOBUF *iop; - int cnt = EOF; - char *s = NULL; - int errcode; - - while (cnt == EOF) { - if (tree->rnode == NULL) { /* no redirection */ - iop = nextfile(0); - if (iop == NULL) /* end of input */ - return tmp_number((AWKNUM) 0.0); - } else { - int redir_error = 0; - - rp = redirect(tree->rnode, &redir_error); - if (rp == NULL && redir_error) { /* failed redirect */ - if (! do_unix) { - char *s = strerror(redir_error); - - unref(ERRNO_node->var_value); - ERRNO_node->var_value = - make_string(s, strlen(s)); - } - return tmp_number((AWKNUM) -1.0); - } - iop = rp->iop; - if (iop == NULL) /* end of input */ - return tmp_number((AWKNUM) 0.0); - } - errcode = 0; - cnt = get_a_record(&s, iop, *RS, & errcode); - if (! do_unix && errcode != 0) { - char *s = strerror(errcode); - - unref(ERRNO_node->var_value); - ERRNO_node->var_value = make_string(s, strlen(s)); - return tmp_number((AWKNUM) -1.0); - } - if (cnt == EOF) { - if (rp) { - /* - * Don't do iop_close() here if we are - * reading from a pipe; otherwise - * gawk_pclose will not be called. - */ - if (!(rp->flag & RED_PIPE)) { - (void) iop_close(iop); - rp->iop = NULL; - } - rp->flag |= RED_EOF; /* sticky EOF */ - return tmp_number((AWKNUM) 0.0); - } else - continue; /* try another file */ - } - if (!rp) { - NR += 1; - FNR += 1; - } - if (tree->lnode == NULL) /* no optional var. */ - set_record(s, cnt, 1); - else { /* assignment to variable */ - Func_ptr after_assign = NULL; - NODE **lhs; - - lhs = get_lhs(tree->lnode, &after_assign); - unref(*lhs); - *lhs = make_string(s, strlen(s)); - (*lhs)->flags |= MAYBE_NUM; - /* we may have to regenerate $0 here! */ - if (after_assign) - (*after_assign)(); - } - } - return tmp_number((AWKNUM) 1.0); -} - -int -pathopen (file) -char *file; -{ - int fd = do_pathopen(file); - -#ifdef DEFAULT_FILETYPE - if (! do_unix && fd <= INVALID_HANDLE) { - char *file_awk; - int save = errno; -#ifdef VMS - int vms_save = vaxc$errno; -#endif - - /* append ".awk" and try again */ - emalloc(file_awk, char *, strlen(file) + - sizeof(DEFAULT_FILETYPE) + 1, "pathopen"); - sprintf(file_awk, "%s%s", file, DEFAULT_FILETYPE); - fd = do_pathopen(file_awk); - free(file_awk); - if (fd <= INVALID_HANDLE) { - errno = save; -#ifdef VMS - vaxc$errno = vms_save; -#endif - } - } -#endif /*DEFAULT_FILETYPE*/ - - return fd; -} - -static int -do_pathopen (file) -char *file; -{ - static char *savepath = DEFPATH; /* defined in config.h */ - static int first = 1; - char *awkpath, *cp; - char trypath[BUFSIZ]; - int fd; - - if (STREQ(file, "-")) - return (0); - - if (do_unix) - return (devopen(file, "r")); - - if (first) { - first = 0; - if ((awkpath = getenv ("AWKPATH")) != NULL && *awkpath) - savepath = awkpath; /* used for restarting */ - } - awkpath = savepath; - - /* some kind of path name, no search */ -#ifdef VMS /* (strchr not equal implies either or both not NULL) */ - if (strchr(file, ':') != strchr(file, ']') - || strchr(file, '>') != strchr(file, '/')) -#else /*!VMS*/ -#ifdef MSDOS - if (strchr(file, '/') != strchr(file, '\\') - || strchr(file, ':') != NULL) -#else - if (strchr(file, '/') != NULL) -#endif /*MSDOS*/ -#endif /*VMS*/ - return (devopen(file, "r")); - - do { - trypath[0] = '\0'; - /* this should take into account limits on size of trypath */ - for (cp = trypath; *awkpath && *awkpath != ENVSEP; ) - *cp++ = *awkpath++; - - if (cp != trypath) { /* nun-null element in path */ - /* add directory punctuation only if needed */ -#ifdef VMS - if (strchr(":]>/", *(cp-1)) == NULL) -#else -#ifdef MSDOS - if (strchr(":\\/", *(cp-1)) == NULL) -#else - if (*(cp-1) != '/') -#endif -#endif - *cp++ = '/'; - /* append filename */ - strcpy (cp, file); - } else - strcpy (trypath, file); - if ((fd = devopen(trypath, "r")) >= 0) - return (fd); - - /* no luck, keep going */ - if(*awkpath == ENVSEP && awkpath[1] != '\0') - awkpath++; /* skip colon */ - } while (*awkpath); - /* - * You might have one of the awk - * paths defined, WITHOUT the current working directory in it. - * Therefore try to open the file in the current directory. - */ - return (devopen(file, "r")); -} diff --git a/gnu/usr.bin/gawk-2.15.2/iop.c b/gnu/usr.bin/gawk-2.15.2/iop.c deleted file mode 100644 index 0d7af1213db6..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/iop.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * iop.c - do i/o related things. - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "awk.h" - -#ifndef atarist -#define INVALID_HANDLE (-1) -#else -#include -#include -#define INVALID_HANDLE (__SMALLEST_VALID_HANDLE - 1) -#endif /* atarist */ - - -#ifdef TEST -int bufsize = 8192; - -void -fatal(s) -char *s; -{ - printf("%s\n", s); - exit(1); -} -#endif - -int -optimal_bufsize(fd) -int fd; -{ - struct stat stb; - -#ifdef VMS - /* - * These values correspond with the RMS multi-block count used by - * vms_open() in vms/vms_misc.c. - */ - if (isatty(fd) > 0) - return BUFSIZ; - else if (fstat(fd, &stb) < 0) - return 8*512; /* conservative in case of DECnet access */ - else - return 24*512; - -#else - /* - * System V doesn't have the file system block size in the - * stat structure. So we have to make some sort of reasonable - * guess. We use stdio's BUFSIZ, since that is what it was - * meant for in the first place. - */ -#ifdef BLKSIZE_MISSING -#define DEFBLKSIZE BUFSIZ -#else -#define DEFBLKSIZE (stb.st_blksize ? stb.st_blksize : BUFSIZ) -#endif - -#ifdef TEST - return bufsize; -#else -#ifndef atarist - if (isatty(fd)) -#else - /* - * On ST redirected stdin does not have a name attached - * (this could be hard to do to) and fstat would fail - */ - if (0 == fd || isatty(fd)) -#endif /*atarist */ - return BUFSIZ; -#ifndef BLKSIZE_MISSING - /* VMS POSIX 1.0: st_blksize is never assigned a value, so zero it */ - stb.st_blksize = 0; -#endif - if (fstat(fd, &stb) == -1) - fatal("can't stat fd %d (%s)", fd, strerror(errno)); - if (lseek(fd, (off_t)0, 0) == -1) - return DEFBLKSIZE; - return ((int) (stb.st_size < DEFBLKSIZE ? stb.st_size : DEFBLKSIZE)); -#endif /*! TEST */ -#endif /*! VMS */ -} - -IOBUF * -iop_alloc(fd) -int fd; -{ - IOBUF *iop; - - if (fd == INVALID_HANDLE) - return NULL; - emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc"); - iop->flag = 0; - if (isatty(fd)) - iop->flag |= IOP_IS_TTY; - iop->size = optimal_bufsize(fd); - iop->secsiz = -2; - errno = 0; - iop->fd = fd; - iop->off = iop->buf = NULL; - iop->cnt = 0; - return iop; -} - -/* - * Get the next record. Uses a "split buffer" where the latter part is - * the normal read buffer and the head part is an "overflow" area that is used - * when a record spans the end of the normal buffer, in which case the first - * part of the record is copied into the overflow area just before the - * normal buffer. Thus, the eventual full record can be returned as a - * contiguous area of memory with a minimum of copying. The overflow area - * is expanded as needed, so that records are unlimited in length. - * We also mark both the end of the buffer and the end of the read() with - * a sentinel character (the current record separator) so that the inside - * loop can run as a single test. - */ -int -get_a_record(out, iop, grRS, errcode) -char **out; -IOBUF *iop; -register int grRS; -int *errcode; -{ - register char *bp = iop->off; - char *bufend; - char *start = iop->off; /* beginning of record */ - int saw_newline; - char rs; - int eat_whitespace; - - if (iop->cnt == EOF) /* previous read hit EOF */ - return EOF; - - if (grRS == 0) { /* special case: grRS == "" */ - rs = '\n'; - eat_whitespace = 0; - saw_newline = 0; - } else - rs = (char) grRS; - - /* set up sentinel */ - if (iop->buf) { - bufend = iop->buf + iop->size + iop->secsiz; - *bufend = rs; - } else - bufend = NULL; - - for (;;) { /* break on end of record, read error or EOF */ - - /* Following code is entered on the first call of this routine - * for a new iop, or when we scan to the end of the buffer. - * In the latter case, we copy the current partial record to - * the space preceding the normal read buffer. If necessary, - * we expand this space. This is done so that we can return - * the record as a contiguous area of memory. - */ - if ((iop->flag & IOP_IS_INTERNAL) == 0 && bp >= bufend) { - char *oldbuf = NULL; - char *oldsplit = iop->buf + iop->secsiz; - long len; /* record length so far */ - - if ((iop->flag & IOP_IS_INTERNAL) != 0) - cant_happen(); - - len = bp - start; - if (len > iop->secsiz) { - /* expand secondary buffer */ - if (iop->secsiz == -2) - iop->secsiz = 256; - while (len > iop->secsiz) - iop->secsiz *= 2; - oldbuf = iop->buf; - emalloc(iop->buf, char *, - iop->size+iop->secsiz+2, "get_a_record"); - bufend = iop->buf + iop->size + iop->secsiz; - *bufend = rs; - } - if (len > 0) { - char *newsplit = iop->buf + iop->secsiz; - - if (start < oldsplit) { - memcpy(newsplit - len, start, - oldsplit - start); - memcpy(newsplit - (bp - oldsplit), - oldsplit, bp - oldsplit); - } else - memcpy(newsplit - len, start, len); - } - bp = iop->end = iop->off = iop->buf + iop->secsiz; - start = bp - len; - if (oldbuf) { - free(oldbuf); - oldbuf = NULL; - } - } - /* Following code is entered whenever we have no more data to - * scan. In most cases this will read into the beginning of - * the main buffer, but in some cases (terminal, pipe etc.) - * we may be doing smallish reads into more advanced positions. - */ - if (bp >= iop->end) { - if ((iop->flag & IOP_IS_INTERNAL) != 0) { - iop->cnt = EOF; - break; - } - iop->cnt = read(iop->fd, iop->end, bufend - iop->end); - if (iop->cnt == -1) { - if (! do_unix && errcode != NULL) { - *errcode = errno; - iop->cnt = EOF; - break; - } else - fatal("error reading input: %s", - strerror(errno)); - } else if (iop->cnt == 0) { - iop->cnt = EOF; - break; - } - iop->end += iop->cnt; - *iop->end = rs; - } - if (grRS == 0) { - extern int default_FS; - - if (default_FS && (bp == start || eat_whitespace)) { - while (bp < iop->end && isspace(*bp)) - bp++; - if (bp == iop->end) { - eat_whitespace = 1; - continue; - } else - eat_whitespace = 0; - } - if (saw_newline && *bp == rs) { - bp++; - break; - } - saw_newline = 0; - } - - while (*bp++ != rs) - ; - - if (bp <= iop->end) { - if (grRS == 0) - saw_newline = 1; - else - break; - } else - bp--; - - if ((iop->flag & IOP_IS_INTERNAL) != 0) - iop->cnt = bp - start; - } - if (iop->cnt == EOF - && (((iop->flag & IOP_IS_INTERNAL) != 0) || start == bp)) - return EOF; - - iop->off = bp; - bp--; - if (*bp != rs) - bp++; - *bp = '\0'; - if (grRS == 0) { - if (*--bp == rs) - *bp = '\0'; - else - bp++; - } - - *out = start; - return bp - start; -} - -#ifdef TEST -main(argc, argv) -int argc; -char *argv[]; -{ - IOBUF *iop; - char *out; - int cnt; - char rs[2]; - - rs[0] = 0; - if (argc > 1) - bufsize = atoi(argv[1]); - if (argc > 2) - rs[0] = *argv[2]; - iop = iop_alloc(0); - while ((cnt = get_a_record(&out, iop, rs[0], NULL)) > 0) { - fwrite(out, 1, cnt, stdout); - fwrite(rs, 1, 1, stdout); - } -} -#endif diff --git a/gnu/usr.bin/gawk-2.15.2/main.c b/gnu/usr.bin/gawk-2.15.2/main.c deleted file mode 100644 index 77d0bf74e143..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/main.c +++ /dev/null @@ -1,731 +0,0 @@ -/* - * main.c -- Expression tree constructors and main program for gawk. - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "getopt.h" -#include "awk.h" -#include "patchlevel.h" - -static void usage P((int exitval)); -static void copyleft P((void)); -static void cmdline_fs P((char *str)); -static void init_args P((int argc0, int argc, char *argv0, char **argv)); -static void init_vars P((void)); -static void pre_assign P((char *v)); -SIGTYPE catchsig P((int sig, int code)); -static void gawk_option P((char *optstr)); -static void nostalgia P((void)); -static void version P((void)); -char *gawk_name P((char *filespec)); - -#ifdef MSDOS -extern int isatty P((int)); -#endif - -extern void resetup P((void)); - -/* These nodes store all the special variables AWK uses */ -NODE *FS_node, *NF_node, *RS_node, *NR_node; -NODE *FILENAME_node, *OFS_node, *ORS_node, *OFMT_node; -NODE *CONVFMT_node; -NODE *ERRNO_node; -NODE *FNR_node, *RLENGTH_node, *RSTART_node, *SUBSEP_node; -NODE *ENVIRON_node, *IGNORECASE_node; -NODE *ARGC_node, *ARGV_node, *ARGIND_node; -NODE *FIELDWIDTHS_node; - -int NF; -int NR; -int FNR; -int IGNORECASE; -char *RS; -char *OFS; -char *ORS; -char *OFMT; -char *CONVFMT; - -/* - * The parse tree and field nodes are stored here. Parse_end is a dummy item - * used to free up unneeded fields without freeing the program being run - */ -int errcount = 0; /* error counter, used by yyerror() */ - -/* The global null string */ -NODE *Nnull_string; - -/* The name the program was invoked under, for error messages */ -const char *myname; - -/* A block of AWK code to be run before running the program */ -NODE *begin_block = 0; - -/* A block of AWK code to be run after the last input file */ -NODE *end_block = 0; - -int exiting = 0; /* Was an "exit" statement executed? */ -int exit_val = 0; /* optional exit value */ - -#if defined(YYDEBUG) || defined(DEBUG) -extern int yydebug; -#endif - -struct src *srcfiles = NULL; /* source file name(s) */ -int numfiles = -1; /* how many source files */ - -int do_unix = 0; /* turn off gnu extensions */ -int do_posix = 0; /* turn off gnu and unix extensions */ -int do_lint = 0; /* provide warnings about questionable stuff */ -int do_nostalgia = 0; /* provide a blast from the past */ - -int in_begin_rule = 0; /* we're in a BEGIN rule */ -int in_end_rule = 0; /* we're in a END rule */ - -int output_is_tty = 0; /* control flushing of output */ - -extern char *version_string; /* current version, for printing */ - -NODE *expression_value; - -static struct option optab[] = { - { "compat", no_argument, & do_unix, 1 }, - { "lint", no_argument, & do_lint, 1 }, - { "posix", no_argument, & do_posix, 1 }, - { "nostalgia", no_argument, & do_nostalgia, 1 }, - { "copyleft", no_argument, NULL, 'C' }, - { "copyright", no_argument, NULL, 'C' }, - { "field-separator", required_argument, NULL, 'F' }, - { "file", required_argument, NULL, 'f' }, - { "assign", required_argument, NULL, 'v' }, - { "version", no_argument, NULL, 'V' }, - { "usage", no_argument, NULL, 'u' }, - { "help", no_argument, NULL, 'u' }, - { "source", required_argument, NULL, 's' }, -#ifdef DEBUG - { "parsedebug", no_argument, NULL, 'D' }, -#endif - { 0, 0, 0, 0 } -}; - -int -main(argc, argv) -int argc; -char **argv; -{ - int c; - char *scan; - extern int optind; - extern int opterr; - extern char *optarg; - int i; - - (void) signal(SIGFPE, (SIGTYPE (*) P((int))) catchsig); - (void) signal(SIGSEGV, (SIGTYPE (*) P((int))) catchsig); -#ifdef SIGBUS - (void) signal(SIGBUS, (SIGTYPE (*) P((int))) catchsig); -#endif - - myname = gawk_name(argv[0]); - argv[0] = (char *)myname; -#ifdef VMS - vms_arg_fixup(&argc, &argv); /* emulate redirection, expand wildcards */ -#endif - - /* remove sccs gunk */ - if (strncmp(version_string, "@(#)", 4) == 0) - version_string += 4; - - if (argc < 2) - usage(1); - - /* initialize the null string */ - Nnull_string = make_string("", 0); - Nnull_string->numbr = 0.0; - Nnull_string->type = Node_val; - Nnull_string->flags = (PERM|STR|STRING|NUM|NUMBER); - - /* Set up the special variables */ - - /* - * Note that this must be done BEFORE arg parsing else -F - * breaks horribly - */ - init_vars(); - - /* worst case */ - emalloc(srcfiles, struct src *, argc * sizeof(struct src), "main"); - memset(srcfiles, '\0', argc * sizeof(struct src)); - - /* Tell the regex routines how they should work. . . */ - resetup(); - - /* we do error messages ourselves on invalid options */ - opterr = 0; - - /* the + on the front tells GNU getopt not to rearrange argv */ - while ((c = getopt_long(argc, argv, "+F:f:v:W:", optab, NULL)) != EOF) { - if (do_posix) - opterr = 1; - switch (c) { - case 'F': - cmdline_fs(optarg); - break; - - case 'f': - /* - * a la MKS awk, allow multiple -f options. - * this makes function libraries real easy. - * most of the magic is in the scanner. - */ - /* The following is to allow for whitespace at the end - * of a #! /bin/gawk line in an executable file - */ - scan = optarg; - while (isspace(*scan)) - scan++; - ++numfiles; - srcfiles[numfiles].stype = SOURCEFILE; - if (*scan == '\0') - srcfiles[numfiles].val = argv[optind++]; - else - srcfiles[numfiles].val = optarg; - break; - - case 'v': - pre_assign(optarg); - break; - - case 'W': /* gawk specific options */ - gawk_option(optarg); - break; - - /* These can only come from long form options */ - case 'V': - version(); - break; - - case 'C': - copyleft(); - break; - - case 'u': - usage(0); - break; - - case 's': - if (strlen(optarg) == 0) - warning("empty argument to --source ignored"); - else { - srcfiles[++numfiles].stype = CMDLINE; - srcfiles[numfiles].val = optarg; - } - break; - -#ifdef DEBUG - case 'D': - yydebug = 2; - break; -#endif - - case '?': - default: - /* - * New behavior. If not posix, an unrecognized - * option stops argument processing so that it can - * go into ARGV for the awk program to see. This - * makes use of ``#! /bin/gawk -f'' easier. - */ - if (! do_posix) - goto out; - /* else - let getopt print error message for us */ - break; - } - } -out: - - if (do_nostalgia) - nostalgia(); - - /* POSIX compliance also implies no Unix extensions either */ - if (do_posix) - do_unix = 1; - -#ifdef DEBUG - setbuf(stdout, (char *) NULL); /* make debugging easier */ -#endif - if (isatty(fileno(stdout))) - output_is_tty = 1; - /* No -f or --source options, use next arg */ - if (numfiles == -1) { - if (optind > argc - 1) /* no args left */ - usage(1); - srcfiles[++numfiles].stype = CMDLINE; - srcfiles[numfiles].val = argv[optind]; - optind++; - } - init_args(optind, argc, (char *) myname, argv); - (void) tokexpand(); - - /* Read in the program */ - if (yyparse() || errcount) - exit(1); - - /* Set up the field variables */ - init_fields(); - - if (begin_block) { - in_begin_rule = 1; - (void) interpret(begin_block); - } - in_begin_rule = 0; - if (!exiting && (expression_value || end_block)) - do_input(); - if (end_block) { - in_end_rule = 1; - (void) interpret(end_block); - } - in_end_rule = 0; - if (close_io() != 0 && exit_val == 0) - exit_val = 1; - exit(exit_val); /* more portable */ - return exit_val; /* to suppress warnings */ -} - -/* usage --- print usage information and exit */ - -static void -usage(exitval) -int exitval; -{ - char *opt1 = " -f progfile [--]"; - char *opt2 = " [--] 'program'"; - char *regops = " [POSIX or GNU style options]"; - - version(); - fprintf(stderr, "usage: %s%s%s file ...\n %s%s%s file ...\n", - myname, regops, opt1, myname, regops, opt2); - - /* GNU long options info. Gack. */ - fputs("\nPOSIX options:\t\tGNU long options:\n", stderr); - fputs("\t-f progfile\t\t--file=progfile\n", stderr); - fputs("\t-F fs\t\t\t--field-separator=fs\n", stderr); - fputs("\t-v var=val\t\t--assign=var=val\n", stderr); - fputs("\t-W compat\t\t--compat\n", stderr); - fputs("\t-W copyleft\t\t--copyleft\n", stderr); - fputs("\t-W copyright\t\t--copyright\n", stderr); - fputs("\t-W help\t\t\t--help\n", stderr); - fputs("\t-W lint\t\t\t--lint\n", stderr); -#if 0 - fputs("\t-W nostalgia\t\t--nostalgia\n", stderr); -#endif -#ifdef DEBUG - fputs("\t-W parsedebug\t\t--parsedebug\n", stderr); -#endif - fputs("\t-W posix\t\t--posix\n", stderr); - fputs("\t-W source=program-text\t--source=program-text\n", stderr); - fputs("\t-W usage\t\t--usage\n", stderr); - fputs("\t-W version\t\t--version\n", stderr); - exit(exitval); -} - -static void -copyleft () -{ - static char blurb_part1[] = -"Copyright (C) 1989, 1991, 1992, Free Software Foundation.\n\ -\n\ -This program is free software; you can redistribute it and/or modify\n\ -it under the terms of the GNU General Public License as published by\n\ -the Free Software Foundation; either version 2 of the License, or\n\ -(at your option) any later version.\n\ -\n"; - static char blurb_part2[] = -"This program is distributed in the hope that it will be useful,\n\ -but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ -GNU General Public License for more details.\n\ -\n"; - static char blurb_part3[] = -"You should have received a copy of the GNU General Public License\n\ -along with this program; if not, write to the Free Software\n\ -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n"; - - version(); - fputs(blurb_part1, stderr); - fputs(blurb_part2, stderr); - fputs(blurb_part3, stderr); - fflush(stderr); -} - -static void -cmdline_fs(str) -char *str; -{ - register NODE **tmp; - int len = strlen(str); - - tmp = get_lhs(FS_node, (Func_ptr *) 0); - unref(*tmp); - /* - * Only if in full compatibility mode check for the stupid special - * case so -F\t works as documented in awk even though the shell - * hands us -Ft. Bleah! - * - * Thankfully, Posix didn't propogate this "feature". - */ - if (str[0] == 't' && str[1] == '\0') { - if (do_lint) - warning("-Ft does not set FS to tab in POSIX awk"); - if (do_unix && ! do_posix) - str[0] = '\t'; - } - *tmp = make_str_node(str, len, SCAN); /* do process escapes */ - set_FS(); -} - -static void -init_args(argc0, argc, argv0, argv) -int argc0, argc; -char *argv0; -char **argv; -{ - int i, j; - NODE **aptr; - - ARGV_node = install("ARGV", node(Nnull_string, Node_var, (NODE *)NULL)); - aptr = assoc_lookup(ARGV_node, tmp_number(0.0)); - *aptr = make_string(argv0, strlen(argv0)); - (*aptr)->flags |= MAYBE_NUM; - for (i = argc0, j = 1; i < argc; i++) { - aptr = assoc_lookup(ARGV_node, tmp_number((AWKNUM) j)); - *aptr = make_string(argv[i], strlen(argv[i])); - (*aptr)->flags |= MAYBE_NUM; - j++; - } - ARGC_node = install("ARGC", - node(make_number((AWKNUM) j), Node_var, (NODE *) NULL)); -} - -/* - * Set all the special variables to their initial values. - */ -struct varinit { - NODE **spec; - char *name; - NODETYPE type; - char *strval; - AWKNUM numval; - Func_ptr assign; -}; -static struct varinit varinit[] = { -{&NF_node, "NF", Node_NF, 0, -1, set_NF }, -{&FIELDWIDTHS_node, "FIELDWIDTHS", Node_FIELDWIDTHS, "", 0, 0 }, -{&NR_node, "NR", Node_NR, 0, 0, set_NR }, -{&FNR_node, "FNR", Node_FNR, 0, 0, set_FNR }, -{&FS_node, "FS", Node_FS, " ", 0, 0 }, -{&RS_node, "RS", Node_RS, "\n", 0, set_RS }, -{&IGNORECASE_node, "IGNORECASE", Node_IGNORECASE, 0, 0, set_IGNORECASE }, -{&FILENAME_node, "FILENAME", Node_var, "-", 0, 0 }, -{&OFS_node, "OFS", Node_OFS, " ", 0, set_OFS }, -{&ORS_node, "ORS", Node_ORS, "\n", 0, set_ORS }, -{&OFMT_node, "OFMT", Node_OFMT, "%.6g", 0, set_OFMT }, -{&CONVFMT_node, "CONVFMT", Node_CONVFMT, "%.6g", 0, set_CONVFMT }, -{&RLENGTH_node, "RLENGTH", Node_var, 0, 0, 0 }, -{&RSTART_node, "RSTART", Node_var, 0, 0, 0 }, -{&SUBSEP_node, "SUBSEP", Node_var, "\034", 0, 0 }, -{&ARGIND_node, "ARGIND", Node_var, 0, 0, 0 }, -{&ERRNO_node, "ERRNO", Node_var, 0, 0, 0 }, -{0, 0, Node_illegal, 0, 0, 0 }, -}; - -static void -init_vars() -{ - register struct varinit *vp; - - for (vp = varinit; vp->name; vp++) { - *(vp->spec) = install(vp->name, - node(vp->strval == 0 ? make_number(vp->numval) - : make_string(vp->strval, strlen(vp->strval)), - vp->type, (NODE *) NULL)); - if (vp->assign) - (*(vp->assign))(); - } -} - -void -load_environ() -{ -#if !defined(MSDOS) && !(defined(VMS) && defined(__DECC)) - extern char **environ; -#endif - register char *var, *val; - NODE **aptr; - register int i; - - ENVIRON_node = install("ENVIRON", - node(Nnull_string, Node_var, (NODE *) NULL)); - for (i = 0; environ[i]; i++) { - static char nullstr[] = ""; - - var = environ[i]; - val = strchr(var, '='); - if (val) - *val++ = '\0'; - else - val = nullstr; - aptr = assoc_lookup(ENVIRON_node, tmp_string(var, strlen (var))); - *aptr = make_string(val, strlen (val)); - (*aptr)->flags |= MAYBE_NUM; - - /* restore '=' so that system() gets a valid environment */ - if (val != nullstr) - *--val = '='; - } -} - -/* Process a command-line assignment */ -char * -arg_assign(arg) -char *arg; -{ - char *cp; - Func_ptr after_assign = NULL; - NODE *var; - NODE *it; - NODE **lhs; - - cp = strchr(arg, '='); - if (cp != NULL) { - *cp++ = '\0'; - /* - * Recent versions of nawk expand escapes inside assignments. - * This makes sense, so we do it too. - */ - it = make_str_node(cp, strlen(cp), SCAN); - it->flags |= MAYBE_NUM; - var = variable(arg, 0); - lhs = get_lhs(var, &after_assign); - unref(*lhs); - *lhs = it; - if (after_assign) - (*after_assign)(); - *--cp = '='; /* restore original text of ARGV */ - } - return cp; -} - -static void -pre_assign(v) -char *v; -{ - if (!arg_assign(v)) { - fprintf (stderr, - "%s: '%s' argument to -v not in 'var=value' form\n", - myname, v); - usage(1); - } -} - -SIGTYPE -catchsig(sig, code) -int sig, code; -{ -#ifdef lint - code = 0; sig = code; code = sig; -#endif - if (sig == SIGFPE) { - fatal("floating point exception"); - } else if (sig == SIGSEGV -#ifdef SIGBUS - || sig == SIGBUS -#endif - ) { - msg("fatal error: internal error"); - /* fatal won't abort() if not compiled for debugging */ - abort(); - } else - cant_happen(); - /* NOTREACHED */ -} - -/* gawk_option --- do gawk specific things */ - -static void -gawk_option(optstr) -char *optstr; -{ - char *cp; - - for (cp = optstr; *cp; cp++) { - switch (*cp) { - case ' ': - case '\t': - case ',': - break; - case 'v': - case 'V': - /* print version */ - if (strncasecmp(cp, "version", 7) != 0) - goto unknown; - else - cp += 6; - version(); - break; - case 'c': - case 'C': - if (strncasecmp(cp, "copyright", 9) == 0) { - cp += 8; - copyleft(); - } else if (strncasecmp(cp, "copyleft", 8) == 0) { - cp += 7; - copyleft(); - } else if (strncasecmp(cp, "compat", 6) == 0) { - cp += 5; - do_unix = 1; - } else - goto unknown; - break; - case 'n': - case 'N': - /* - * Undocumented feature, - * inspired by nostalgia, and a T-shirt - */ - if (strncasecmp(cp, "nostalgia", 9) != 0) - goto unknown; - nostalgia(); - break; - case 'p': - case 'P': -#ifdef DEBUG - if (strncasecmp(cp, "parsedebug", 10) == 0) { - cp += 9; - yydebug = 2; - break; - } -#endif - if (strncasecmp(cp, "posix", 5) != 0) - goto unknown; - cp += 4; - do_posix = do_unix = 1; - break; - case 'l': - case 'L': - if (strncasecmp(cp, "lint", 4) != 0) - goto unknown; - cp += 3; - do_lint = 1; - break; - case 'H': - case 'h': - if (strncasecmp(cp, "help", 4) != 0) - goto unknown; - cp += 3; - usage(0); - break; - case 'U': - case 'u': - if (strncasecmp(cp, "usage", 5) != 0) - goto unknown; - cp += 4; - usage(0); - break; - case 's': - case 'S': - if (strncasecmp(cp, "source=", 7) != 0) - goto unknown; - cp += 7; - if (strlen(cp) == 0) - warning("empty argument to -Wsource ignored"); - else { - srcfiles[++numfiles].stype = CMDLINE; - srcfiles[numfiles].val = cp; - return; - } - break; - default: - unknown: - fprintf(stderr, "'%c' -- unknown option, ignored\n", - *cp); - break; - } - } -} - -/* nostalgia --- print the famous error message and die */ - -static void -nostalgia() -{ - fprintf(stderr, "awk: bailing out near line 1\n"); - abort(); -} - -/* version --- print version message */ - -static void -version() -{ - fprintf(stderr, "%s, patchlevel %d\n", version_string, PATCHLEVEL); -} - -/* static */ -char * -gawk_name(filespec) -char *filespec; -{ - char *p; - -#ifdef VMS /* "device:[root.][directory.subdir]GAWK.EXE;n" -> "GAWK" */ - char *q; - - p = strrchr(filespec, ']'); /* directory punctuation */ - q = strrchr(filespec, '>'); /* alternate punct */ - - if (p == NULL || q > p) p = q; - p = strdup(p == NULL ? filespec : (p + 1)); - if ((q = strrchr(p, '.')) != NULL) *q = '\0'; /* strip .typ;vers */ - - return p; -#endif /*VMS*/ - -#if defined(MSDOS) || defined(atarist) - char *q; - - p = filespec; - - if (q = strrchr(p, '\\')) - p = q + 1; - if (q = strchr(p, '.')) - *q = '\0'; - strlwr(p); - - return (p == NULL ? filespec : p); -#endif /* MSDOS || atarist */ - - /* "path/name" -> "name" */ - p = strrchr(filespec, '/'); - return (p == NULL ? filespec : p + 1); -} diff --git a/gnu/usr.bin/gawk-2.15.2/msg.c b/gnu/usr.bin/gawk-2.15.2/msg.c deleted file mode 100644 index b60fe9d1e5e9..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/msg.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * msg.c - routines for error messages - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "awk.h" - -int sourceline = 0; -char *source = NULL; - -/* VARARGS2 */ -void -err(s, emsg, argp) -char *s; -char *emsg; -va_list argp; -{ - char *file; - - (void) fflush(stdout); - (void) fprintf(stderr, "%s: ", myname); - if (sourceline) { - if (source) - (void) fprintf(stderr, "%s:", source); - else - (void) fprintf(stderr, "cmd. line:"); - - (void) fprintf(stderr, "%d: ", sourceline); - } - if (FNR) { - file = FILENAME_node->var_value->stptr; - if (file) - (void) fprintf(stderr, "(FILENAME=%s ", file); - (void) fprintf(stderr, "FNR=%d) ", FNR); - } - (void) fprintf(stderr, s); - vfprintf(stderr, emsg, argp); - (void) fprintf(stderr, "\n"); - (void) fflush(stderr); -} - -/*VARARGS0*/ -void -msg(va_alist) -va_dcl -{ - va_list args; - char *mesg; - - va_start(args); - mesg = va_arg(args, char *); - err("", mesg, args); - va_end(args); -} - -/*VARARGS0*/ -void -warning(va_alist) -va_dcl -{ - va_list args; - char *mesg; - - va_start(args); - mesg = va_arg(args, char *); - err("warning: ", mesg, args); - va_end(args); -} - -/*VARARGS0*/ -void -fatal(va_alist) -va_dcl -{ - va_list args; - char *mesg; - - va_start(args); - mesg = va_arg(args, char *); - err("fatal: ", mesg, args); - va_end(args); -#ifdef DEBUG - abort(); -#endif - exit(2); -} diff --git a/gnu/usr.bin/gawk-2.15.2/node.c b/gnu/usr.bin/gawk-2.15.2/node.c deleted file mode 100644 index 65ecb0ed1723..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/node.c +++ /dev/null @@ -1,429 +0,0 @@ -/* - * node.c -- routines for node management - */ - -/* - * Copyright (C) 1986, 1988, 1989, 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "awk.h" - -extern double strtod(); - -AWKNUM -r_force_number(n) -register NODE *n; -{ - register char *cp; - register char *cpend; - char save; - char *ptr; - unsigned int newflags = 0; - -#ifdef DEBUG - if (n == NULL) - cant_happen(); - if (n->type != Node_val) - cant_happen(); - if(n->flags == 0) - cant_happen(); - if (n->flags & NUM) - return n->numbr; -#endif - - /* all the conditionals are an attempt to avoid the expensive strtod */ - - n->numbr = 0.0; - n->flags |= NUM; - - if (n->stlen == 0) - return 0.0; - - cp = n->stptr; - if (isalpha(*cp)) - return 0.0; - - cpend = cp + n->stlen; - while (cp < cpend && isspace(*cp)) - cp++; - if (cp == cpend || isalpha(*cp)) - return 0.0; - - if (n->flags & MAYBE_NUM) { - newflags = NUMBER; - n->flags &= ~MAYBE_NUM; - } - if (cpend - cp == 1) { - if (isdigit(*cp)) { - n->numbr = (AWKNUM)(*cp - '0'); - n->flags |= newflags; - } - return n->numbr; - } - - errno = 0; - save = *cpend; - *cpend = '\0'; - n->numbr = (AWKNUM) strtod((const char *)cp, &ptr); - - /* POSIX says trailing space is OK for NUMBER */ - while (isspace(*ptr)) - ptr++; - *cpend = save; - /* the >= should be ==, but for SunOS 3.5 strtod() */ - if (errno == 0 && ptr >= cpend) - n->flags |= newflags; - else - errno = 0; - - return n->numbr; -} - -/* - * the following lookup table is used as an optimization in force_string - * (more complicated) variations on this theme didn't seem to pay off, but - * systematic testing might be in order at some point - */ -static char *values[] = { - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", -}; -#define NVAL (sizeof(values)/sizeof(values[0])) - -NODE * -r_force_string(s) -register NODE *s; -{ - char buf[128]; - register char *sp = buf; - register long num = 0; - -#ifdef DEBUG - if (s == NULL) cant_happen(); - if (s->type != Node_val) cant_happen(); - if (s->flags & STR) return s; - if (!(s->flags & NUM)) cant_happen(); - if (s->stref != 0) ; /*cant_happen();*/ -#endif - - /* avoids floating point exception in DOS*/ - if ( s->numbr <= LONG_MAX && s->numbr >= -LONG_MAX) - num = (long)s->numbr; - if ((AWKNUM) num == s->numbr) { /* integral value */ - if (num < NVAL && num >= 0) { - sp = values[num]; - s->stlen = 1; - } else { - (void) sprintf(sp, "%ld", num); - s->stlen = strlen(sp); - } - s->stfmt = -1; - } else { - (void) sprintf(sp, CONVFMT, s->numbr); - s->stlen = strlen(sp); - s->stfmt = (char)CONVFMTidx; - } - s->stref = 1; - emalloc(s->stptr, char *, s->stlen + 2, "force_string"); - memcpy(s->stptr, sp, s->stlen+1); - s->flags |= STR; - return s; -} - -/* - * Duplicate a node. (For strings, "duplicate" means crank up the - * reference count.) - */ -NODE * -dupnode(n) -NODE *n; -{ - register NODE *r; - - if (n->flags & TEMP) { - n->flags &= ~TEMP; - n->flags |= MALLOC; - return n; - } - if ((n->flags & (MALLOC|STR)) == (MALLOC|STR)) { - if (n->stref < 255) - n->stref++; - return n; - } - getnode(r); - *r = *n; - r->flags &= ~(PERM|TEMP); - r->flags |= MALLOC; - if (n->type == Node_val && (n->flags & STR)) { - r->stref = 1; - emalloc(r->stptr, char *, r->stlen + 2, "dupnode"); - memcpy(r->stptr, n->stptr, r->stlen+1); - } - return r; -} - -/* this allocates a node with defined numbr */ -NODE * -mk_number(x, flags) -AWKNUM x; -unsigned int flags; -{ - register NODE *r; - - getnode(r); - r->type = Node_val; - r->numbr = x; - r->flags = flags; -#ifdef DEBUG - r->stref = 1; - r->stptr = 0; - r->stlen = 0; -#endif - return r; -} - -/* - * Make a string node. - */ -NODE * -make_str_node(s, len, flags) -char *s; -size_t len; -int flags; -{ - register NODE *r; - - getnode(r); - r->type = Node_val; - r->flags = (STRING|STR|MALLOC); - if (flags & ALREADY_MALLOCED) - r->stptr = s; - else { - emalloc(r->stptr, char *, len + 2, s); - memcpy(r->stptr, s, len); - } - r->stptr[len] = '\0'; - - if (flags & SCAN) { /* scan for escape sequences */ - char *pf; - register char *ptm; - register int c; - register char *end; - - end = &(r->stptr[len]); - for (pf = ptm = r->stptr; pf < end;) { - c = *pf++; - if (c == '\\') { - c = parse_escape(&pf); - if (c < 0) { - if (do_lint) - warning("backslash at end of string"); - c = '\\'; - } - *ptm++ = c; - } else - *ptm++ = c; - } - len = ptm - r->stptr; - erealloc(r->stptr, char *, len + 1, "make_str_node"); - r->stptr[len] = '\0'; - r->flags |= PERM; - } - r->stlen = len; - r->stref = 1; - r->stfmt = -1; - - return r; -} - -NODE * -tmp_string(s, len) -char *s; -size_t len; -{ - register NODE *r; - - r = make_string(s, len); - r->flags |= TEMP; - return r; -} - - -#define NODECHUNK 100 - -NODE *nextfree = NULL; - -NODE * -more_nodes() -{ - register NODE *np; - - /* get more nodes and initialize list */ - emalloc(nextfree, NODE *, NODECHUNK * sizeof(NODE), "newnode"); - for (np = nextfree; np < &nextfree[NODECHUNK - 1]; np++) - np->nextp = np + 1; - np->nextp = NULL; - np = nextfree; - nextfree = nextfree->nextp; - return np; -} - -#ifdef DEBUG -void -freenode(it) -NODE *it; -{ -#ifdef MPROF - it->stref = 0; - free((char *) it); -#else /* not MPROF */ - /* add it to head of freelist */ - it->nextp = nextfree; - nextfree = it; -#endif /* not MPROF */ -} -#endif /* DEBUG */ - -void -unref(tmp) -register NODE *tmp; -{ - if (tmp == NULL) - return; - if (tmp->flags & PERM) - return; - if (tmp->flags & (MALLOC|TEMP)) { - tmp->flags &= ~TEMP; - if (tmp->flags & STR) { - if (tmp->stref > 1) { - if (tmp->stref != 255) - tmp->stref--; - return; - } - free(tmp->stptr); - } - freenode(tmp); - } -} - -/* - * Parse a C escape sequence. STRING_PTR points to a variable containing a - * pointer to the string to parse. That pointer is updated past the - * characters we use. The value of the escape sequence is returned. - * - * A negative value means the sequence \ newline was seen, which is supposed to - * be equivalent to nothing at all. - * - * If \ is followed by a null character, we return a negative value and leave - * the string pointer pointing at the null character. - * - * If \ is followed by 000, we return 0 and leave the string pointer after the - * zeros. A value of 0 does not mean end of string. - * - * Posix doesn't allow \x. - */ - -int -parse_escape(string_ptr) -char **string_ptr; -{ - register int c = *(*string_ptr)++; - register int i; - register int count; - - switch (c) { - case 'a': - return BELL; - case 'b': - return '\b'; - case 'f': - return '\f'; - case 'n': - return '\n'; - case 'r': - return '\r'; - case 't': - return '\t'; - case 'v': - return '\v'; - case '\n': - return -2; - case 0: - (*string_ptr)--; - return -1; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - i = c - '0'; - count = 0; - while (++count < 3) { - if ((c = *(*string_ptr)++) >= '0' && c <= '7') { - i *= 8; - i += c - '0'; - } else { - (*string_ptr)--; - break; - } - } - return i; - case 'x': - if (do_lint) { - static int didwarn; - - if (! didwarn) { - didwarn = 1; - warning("Posix does not allow \"\\x\" escapes"); - } - } - if (do_posix) - return ('x'); - i = 0; - while (1) { - if (isxdigit((c = *(*string_ptr)++))) { - i *= 16; - if (isdigit(c)) - i += c - '0'; - else if (isupper(c)) - i += c - 'A' + 10; - else - i += c - 'a' + 10; - } else { - (*string_ptr)--; - break; - } - } - return i; - default: - return c; - } -} diff --git a/gnu/usr.bin/gawk-2.15.2/patchlevel.h b/gnu/usr.bin/gawk-2.15.2/patchlevel.h deleted file mode 100644 index c6161a1f274c..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/patchlevel.h +++ /dev/null @@ -1 +0,0 @@ -#define PATCHLEVEL 2 diff --git a/gnu/usr.bin/gawk-2.15.2/protos.h b/gnu/usr.bin/gawk-2.15.2/protos.h deleted file mode 100644 index 25af32165b02..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/protos.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * protos.h -- function prototypes for when the headers don't have them. - */ - -/* - * Copyright (C) 1991, 1992, the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifdef __STDC__ -#define aptr_t void * /* arbitrary pointer type */ -#else -#define aptr_t char * -#endif -extern aptr_t malloc P((MALLOC_ARG_T)); -extern aptr_t realloc P((aptr_t, MALLOC_ARG_T)); -extern aptr_t calloc P((MALLOC_ARG_T, MALLOC_ARG_T)); - -extern void free P((aptr_t)); -extern char *getenv P((char *)); - -extern char *strcpy P((char *, const char *)); -extern char *strcat P((char *, const char *)); -extern char *strncpy P((char *, const char *, int)); -extern int strcmp P((const char *, const char *)); -extern int strncmp P((const char *, const char *, int)); -#ifndef VMS -extern char *strerror P((int)); -#else -extern char *strerror P((int,...)); -#endif -extern char *strchr P((const char *, int)); -extern char *strrchr P((const char *, int)); -extern char *strstr P((const char *s1, const char *s2)); -extern int strlen P((const char *)); -extern long strtol P((const char *, char **, int)); -#if !defined(_MSC_VER) && !defined(__GNU_LIBRARY__) -extern int strftime P((char *, int, const char *, const struct tm *)); -#endif -extern time_t time P((time_t *)); -extern aptr_t memset P((aptr_t, int, size_t)); -extern aptr_t memcpy P((aptr_t, const aptr_t, size_t)); -extern aptr_t memmove P((aptr_t, const aptr_t, size_t)); -extern aptr_t memchr P((const aptr_t, int, size_t)); -extern int memcmp P((const aptr_t, const aptr_t, size_t)); - -/* extern int fprintf P((FILE *, char *, ...)); */ -extern int fprintf P(()); -#if !defined(MSDOS) && !defined(__GNU_LIBRARY__) -extern int fwrite P((const char *, int, int, FILE *)); -extern int fputs P((const char *, FILE *)); -extern int unlink P((const char *)); -#endif -extern int fflush P((FILE *)); -extern int fclose P((FILE *)); -extern FILE *popen P((const char *, const char *)); -extern int pclose P((FILE *)); -extern void abort P(()); -extern int isatty P((int)); -extern void exit P((int)); -extern int system P((const char *)); -extern int sscanf P((/* char *, char *, ... */)); -#ifndef toupper -extern int toupper P((int)); -#endif -#ifndef tolower -extern int tolower P((int)); -#endif - -extern double pow P((double x, double y)); -extern double atof P((char *)); -extern double strtod P((const char *, char **)); -extern int fstat P((int, struct stat *)); -extern int stat P((const char *, struct stat *)); -extern off_t lseek P((int, off_t, int)); -extern int fseek P((FILE *, long, int)); -extern int close P((int)); -extern int creat P(()); -extern int open P(()); -extern int pipe P((int *)); -extern int dup P((int)); -extern int dup2 P((int,int)); -extern int fork P(()); -extern int execl P((/* char *, char *, ... */)); -extern int read P((int, char *, int)); -extern int wait P((int *)); -extern void _exit P((int)); - -#ifndef __STDC__ -extern long time P((long *)); -#endif - -#ifdef NON_STD_SPRINTF -extern char *sprintf(); -#else -extern int sprintf(); -#endif /* SPRINTF_INT */ - -#undef aptr_t diff --git a/gnu/usr.bin/gawk-2.15.2/re.c b/gnu/usr.bin/gawk-2.15.2/re.c deleted file mode 100644 index 495b0963cadb..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/re.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * re.c - compile regular expressions. - */ - -/* - * Copyright (C) 1991, 1992 the Free Software Foundation, Inc. - * - * This file is part of GAWK, the GNU implementation of the - * AWK Progamming Language. - * - * GAWK 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. - * - * GAWK 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 GAWK; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "awk.h" - -/* Generate compiled regular expressions */ - -Regexp * -make_regexp(s, len, ignorecase, dfa) -char *s; -int len; -int ignorecase; -int dfa; -{ - Regexp *rp; - char *err; - char *src = s; - char *temp; - char *end = s + len; - register char *dest; - register int c; - - /* Handle escaped characters first. */ - - /* Build a copy of the string (in dest) with the - escaped characters translated, and generate the regex - from that. - */ - emalloc(dest, char *, len + 2, "make_regexp"); - temp = dest; - - while (src < end) { - if (*src == '\\') { - c = *++src; - switch (c) { - case 'a': - case 'b': - case 'f': - case 'n': - case 'r': - case 't': - case 'v': - case 'x': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - c = parse_escape(&src); - if (c < 0) - cant_happen(); - *dest++ = (char)c; - break; - default: - *dest++ = '\\'; - *dest++ = (char)c; - src++; - break; - } /* switch */ - } else { - *dest++ = *src++; /* not '\\' */ - } - } /* for */ - - *dest = '\0' ; /* Only necessary if we print dest ? */ - emalloc(rp, Regexp *, sizeof(*rp), "make_regexp"); - memset((char *) rp, 0, sizeof(*rp)); - emalloc(rp->pat.buffer, char *, 16, "make_regexp"); - rp->pat.allocated = 16; - emalloc(rp->pat.fastmap, char *, 256, "make_regexp"); - - if (ignorecase) - rp->pat.translate = casetable; - else - rp->pat.translate = NULL; - len = dest - temp; - if ((err = re_compile_pattern(temp, (size_t) len, &(rp->pat))) != NULL) - fatal("%s: /%s/", err, temp); - if (dfa && !ignorecase) { - regcompile(temp, len, &(rp->dfareg), 1); - rp->dfa = 1; - } else - rp->dfa = 0; - free(temp); - return rp; -} - -int -research(rp, str, start, len, need_start) -Regexp *rp; -register char *str; -int start; -register int len; -int need_start; -{ - char *ret = str; - - if (rp->dfa) { - char save1; - char save2; - int count = 0; - int try_backref; - - save1 = str[start+len]; - str[start+len] = '\n'; - save2 = str[start+len+1]; - ret = regexecute(&(rp->dfareg), str+start, str+start+len+1, 1, - &count, &try_backref); - str[start+len] = save1; - str[start+len+1] = save2; - } - if (ret) { - if (need_start || rp->dfa == 0) - return re_search(&(rp->pat), str, start+len, start, - len, &(rp->regs)); - else - return 1; - } else - return -1; -} - -void -refree(rp) -Regexp *rp; -{ - free(rp->pat.buffer); - free(rp->pat.fastmap); - if (rp->dfa) - reg_free(&(rp->dfareg)); - free(rp); -} - -void -reg_error(s) -const char *s; -{ - fatal(s); -} - -Regexp * -re_update(t) -NODE *t; -{ - NODE *t1; - -# define CASE 1 - if ((t->re_flags & CASE) == IGNORECASE) { - if (t->re_flags & CONST) - return t->re_reg; - t1 = force_string(tree_eval(t->re_exp)); - if (t->re_text) { - if (cmp_nodes(t->re_text, t1) == 0) { - free_temp(t1); - return t->re_reg; - } - unref(t->re_text); - } - t->re_text = dupnode(t1); - free_temp(t1); - } - if (t->re_reg) - refree(t->re_reg); - if (t->re_cnt) - t->re_cnt++; - if (t->re_cnt > 10) - t->re_cnt = 0; - if (!t->re_text) { - t1 = force_string(tree_eval(t->re_exp)); - t->re_text = dupnode(t1); - free_temp(t1); - } - t->re_reg = make_regexp(t->re_text->stptr, t->re_text->stlen, IGNORECASE, t->re_cnt); - t->re_flags &= ~CASE; - t->re_flags |= IGNORECASE; - return t->re_reg; -} - -void -resetup() -{ - (void) re_set_syntax(RE_SYNTAX_AWK); - regsyntax(RE_SYNTAX_AWK, 0); -} diff --git a/gnu/usr.bin/gawk-2.15.2/regex.c b/gnu/usr.bin/gawk-2.15.2/regex.c deleted file mode 100644 index f4dd4c2cd24d..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/regex.c +++ /dev/null @@ -1,2854 +0,0 @@ -/* Extended regular expression matching and search 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 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. */ - - -/* To test, compile with -Dtest. This Dtestable feature turns this into - a self-contained program which reads a pattern, describes how it - compiles, then reads a string and searches for it. - - On the other hand, if you compile with both -Dtest and -Dcanned you - can run some tests we've already thought of. */ - - -#ifdef emacs - -/* The `emacs' switch turns on certain special matching commands - that make sense only in emacs. */ - -#include "lisp.h" -#include "buffer.h" -#include "syntax.h" - -/* We write fatal error messages on standard error. */ -#include - -/* isalpha(3) etc. are used for the character classes. */ -#include - -#else /* not emacs */ - -#include "awk.h" - -#define NO_ALLOCA /* try it out for now */ -#ifndef NO_ALLOCA -/* Make alloca work the best possible way. */ -#ifdef __GNUC__ -#ifndef atarist -#ifndef alloca -#define alloca __builtin_alloca -#endif -#endif /* atarist */ -#else -#if defined(sparc) && !defined(__GNUC__) -#include -#else -char *alloca (); -#endif -#endif /* __GNUC__ */ - -#define FREE_AND_RETURN_VOID(stackb) return -#define FREE_AND_RETURN(stackb,val) return(val) -#define DOUBLE_STACK(stackx,stackb,len) \ - (stackx = (unsigned char **) alloca (2 * len \ - * sizeof (unsigned char *)),\ - /* Only copy what is in use. */ \ - (unsigned char **) memcpy (stackx, stackb, len * sizeof (char *))) -#else /* NO_ALLOCA defined */ -#define FREE_AND_RETURN_VOID(stackb) free(stackb);return -#define FREE_AND_RETURN(stackb,val) free(stackb);return(val) -#define DOUBLE_STACK(stackx,stackb,len) \ - (unsigned char **) realloc (stackb, 2 * len * sizeof (unsigned char *)) -#endif /* NO_ALLOCA */ - -static void store_jump P((char *, int, char *)); -static void insert_jump P((int, char *, char *, char *)); -static void store_jump_n P((char *, int, char *, unsigned)); -static void insert_jump_n P((int, char *, char *, char *, unsigned)); -static void insert_op_2 P((int, char *, char *, int, int )); -static int memcmp_translate P((unsigned char *, unsigned char *, - int, unsigned char *)); -long re_set_syntax P((long)); - -/* Define the syntax stuff, so we can do the \<, \>, etc. */ - -/* This must be nonzero for the wordchar and notwordchar pattern - commands in re_match_2. */ -#ifndef Sword -#define Sword 1 -#endif - -#define SYNTAX(c) re_syntax_table[c] - - -#ifdef SYNTAX_TABLE - -char *re_syntax_table; - -#else /* not SYNTAX_TABLE */ - -static char re_syntax_table[256]; -static void init_syntax_once P((void)); - - -static void -init_syntax_once () -{ - register int c; - static int done = 0; - - if (done) - return; - - memset (re_syntax_table, 0, sizeof re_syntax_table); - - for (c = 'a'; c <= 'z'; c++) - re_syntax_table[c] = Sword; - - for (c = 'A'; c <= 'Z'; c++) - re_syntax_table[c] = Sword; - - for (c = '0'; c <= '9'; c++) - re_syntax_table[c] = Sword; - - /* Add specific syntax for ISO Latin-1. */ - for (c = 0300; c <= 0377; c++) - re_syntax_table[c] = Sword; - re_syntax_table[0327] = 0; - re_syntax_table[0367] = 0; - - done = 1; -} - -#endif /* SYNTAX_TABLE */ -#undef P -#endif /* emacs */ - - -/* Sequents are missing isgraph. */ -#ifndef isgraph -#define isgraph(c) (isprint((c)) && !isspace((c))) -#endif - -/* Get the interface, including the syntax bits. */ -#include "regex.h" - - -/* These are the command codes that appear in compiled regular - expressions, one per byte. Some command codes are followed by - argument bytes. A command code can specify any interpretation - whatsoever for its arguments. Zero-bytes may appear in the compiled - regular expression. - - The value of `exactn' is needed in search.c (search_buffer) in emacs. - So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of - `exactn' we use here must also be 1. */ - -enum regexpcode - { - unused=0, - exactn=1, /* Followed by one byte giving n, then by n literal bytes. */ - begline, /* Fail unless at beginning of line. */ - endline, /* Fail unless at end of line. */ - jump, /* Followed by two bytes giving relative address to jump to. */ - on_failure_jump, /* Followed by two bytes giving relative address of - place to resume at in case of failure. */ - finalize_jump, /* Throw away latest failure point and then jump to - address. */ - maybe_finalize_jump, /* Like jump but finalize if safe to do so. - This is used to jump back to the beginning - of a repeat. If the command that follows - this jump is clearly incompatible with the - one at the beginning of the repeat, such that - we can be sure that there is no use backtracking - out of repetitions already completed, - then we finalize. */ - dummy_failure_jump, /* Jump, and push a dummy failure point. This - failure point will be thrown away if an attempt - is made to use it for a failure. A + construct - makes this before the first repeat. Also - use it as an intermediary kind of jump when - compiling an or construct. */ - succeed_n, /* Used like on_failure_jump except has to succeed n times; - then gets turned into an on_failure_jump. The relative - address following it is useless until then. The - address is followed by two bytes containing n. */ - jump_n, /* Similar to jump, but jump n times only; also the relative - address following is in turn followed by yet two more bytes - containing n. */ - set_number_at, /* Set the following relative location to the - subsequent number. */ - anychar, /* Matches any (more or less) one character. */ - charset, /* Matches any one char belonging to specified set. - First following byte is number of bitmap bytes. - Then come bytes for a bitmap saying which chars are in. - Bits in each byte are ordered low-bit-first. - A character is in the set if its bit is 1. - A character too large to have a bit in the map - is automatically not in the set. */ - charset_not, /* Same parameters as charset, but match any character - that is not one of those specified. */ - start_memory, /* Start remembering the text that is matched, for - storing in a memory register. Followed by one - byte containing the register number. Register numbers - must be in the range 0 through RE_NREGS. */ - stop_memory, /* Stop remembering the text that is matched - and store it in a memory register. Followed by - one byte containing the register number. Register - numbers must be in the range 0 through RE_NREGS. */ - duplicate, /* Match a duplicate of something remembered. - Followed by one byte containing the index of the memory - register. */ - before_dot, /* Succeeds if before point. */ - at_dot, /* Succeeds if at point. */ - after_dot, /* Succeeds if after point. */ - begbuf, /* Succeeds if at beginning of buffer. */ - endbuf, /* Succeeds if at end of buffer. */ - wordchar, /* Matches any word-constituent character. */ - notwordchar, /* Matches any char that is not a word-constituent. */ - wordbeg, /* Succeeds if at word beginning. */ - wordend, /* Succeeds if at word end. */ - wordbound, /* Succeeds if at a word boundary. */ - notwordbound,/* Succeeds if not at a word boundary. */ - syntaxspec, /* Matches any character whose syntax is specified. - followed by a byte which contains a syntax code, - e.g., Sword. */ - notsyntaxspec /* Matches any character whose syntax differs from - that specified. */ - }; - - -/* Number of failure points to allocate space for initially, - when matching. If this number is exceeded, more space is allocated, - so it is not a hard limit. */ - -#ifndef NFAILURES -#define NFAILURES 80 -#endif - -#ifdef CHAR_UNSIGNED -#define SIGN_EXTEND_CHAR(c) ((c)>(char)127?(c)-256:(c)) /* for IBM RT */ -#endif -#ifndef SIGN_EXTEND_CHAR -#define SIGN_EXTEND_CHAR(x) (x) -#endif - - -/* Store NUMBER in two contiguous bytes starting at DESTINATION. */ -#define STORE_NUMBER(destination, number) \ - { (destination)[0] = (number) & 0377; \ - (destination)[1] = (number) >> 8; } - -/* Same as STORE_NUMBER, except increment the destination pointer to - the byte after where the number is stored. Watch out that values for - DESTINATION such as p + 1 won't work, whereas p will. */ -#define STORE_NUMBER_AND_INCR(destination, number) \ - { STORE_NUMBER(destination, number); \ - (destination) += 2; } - - -/* Put into DESTINATION a number stored in two contingous bytes starting - at SOURCE. */ -#define EXTRACT_NUMBER(destination, source) \ - { (destination) = *(source) & 0377; \ - (destination) += SIGN_EXTEND_CHAR (*(char *)((source) + 1)) << 8; } - -/* Same as EXTRACT_NUMBER, except increment the pointer for source to - point to second byte of SOURCE. Note that SOURCE has to be a value - such as p, not, e.g., p + 1. */ -#define EXTRACT_NUMBER_AND_INCR(destination, source) \ - { EXTRACT_NUMBER (destination, source); \ - (source) += 2; } - - -/* Specify the precise syntax of regexps for compilation. This provides - for compatibility for various utilities which historically have - different, incompatible syntaxes. - - The argument SYNTAX is a bit-mask comprised of the various bits - defined in regex.h. */ - -long -re_set_syntax (syntax) - long syntax; -{ - long ret; - - ret = obscure_syntax; - obscure_syntax = syntax; - return ret; -} - -/* Set by re_set_syntax to the current regexp syntax to recognize. */ -long obscure_syntax = 0; - - - -/* Macros for re_compile_pattern, which is found below these definitions. */ - -#define CHAR_CLASS_MAX_LENGTH 6 - -/* Fetch the next character in the uncompiled pattern, translating it if - necessary. */ -#define PATFETCH(c) \ - {if (p == pend) goto end_of_pattern; \ - c = * (unsigned char *) p++; \ - if (translate) c = translate[c]; } - -/* Fetch the next character in the uncompiled pattern, with no - translation. */ -#define PATFETCH_RAW(c) \ - {if (p == pend) goto end_of_pattern; \ - c = * (unsigned char *) p++; } - -#define PATUNFETCH p-- - - -/* If the buffer isn't allocated when it comes in, use this. */ -#define INIT_BUF_SIZE 28 - -/* Make sure we have at least N more bytes of space in buffer. */ -#define GET_BUFFER_SPACE(n) \ - { \ - while (b - bufp->buffer + (n) >= bufp->allocated) \ - EXTEND_BUFFER; \ - } - -/* Make sure we have one more byte of buffer space and then add CH to it. */ -#define BUFPUSH(ch) \ - { \ - GET_BUFFER_SPACE (1); \ - *b++ = (char) (ch); \ - } - -/* Extend the buffer by twice its current size via reallociation and - reset the pointers that pointed into the old allocation to point to - the correct places in the new allocation. If extending the buffer - results in it being larger than 1 << 16, then flag memory exhausted. */ -#define EXTEND_BUFFER \ - { char *old_buffer = bufp->buffer; \ - if (bufp->allocated == (1L<<16)) goto too_big; \ - bufp->allocated *= 2; \ - if (bufp->allocated > (1L<<16)) bufp->allocated = (1L<<16); \ - bufp->buffer = (char *) realloc (bufp->buffer, bufp->allocated); \ - if (bufp->buffer == 0) \ - goto memory_exhausted; \ - b = (b - old_buffer) + bufp->buffer; \ - if (fixup_jump) \ - fixup_jump = (fixup_jump - old_buffer) + bufp->buffer; \ - if (laststart) \ - laststart = (laststart - old_buffer) + bufp->buffer; \ - begalt = (begalt - old_buffer) + bufp->buffer; \ - if (pending_exact) \ - pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ - } - -/* Set the bit for character C in a character set list. */ -#define SET_LIST_BIT(c) (b[(c) / BYTEWIDTH] |= 1 << ((c) % BYTEWIDTH)) - -/* Get the next unsigned number in the uncompiled pattern. */ -#define GET_UNSIGNED_NUMBER(num) \ - { if (p != pend) \ - { \ - PATFETCH (c); \ - while (isdigit (c)) \ - { \ - if (num < 0) \ - num = 0; \ - num = num * 10 + c - '0'; \ - if (p == pend) \ - break; \ - PATFETCH (c); \ - } \ - } \ - } - -/* Subroutines for re_compile_pattern. */ -/* static void store_jump (), insert_jump (), store_jump_n (), - insert_jump_n (), insert_op_2 (); */ - - -/* re_compile_pattern takes a regular-expression string - and converts it into a buffer full of byte commands for matching. - - PATTERN is the address of the pattern string - SIZE is the length of it. - BUFP is a struct re_pattern_buffer * which points to the info - on where to store the byte commands. - This structure contains a char * which points to the - actual space, which should have been obtained with malloc. - re_compile_pattern may use realloc to grow the buffer space. - - The number of bytes of commands can be found out by looking in - the `struct re_pattern_buffer' that bufp pointed to, after - re_compile_pattern returns. */ - -char * -re_compile_pattern (pattern, size, bufp) - char *pattern; - size_t size; - struct re_pattern_buffer *bufp; -{ - register char *b = bufp->buffer; - register char *p = pattern; - char *pend = pattern + size; - register unsigned c, c1; - char *p0; - unsigned char *translate = (unsigned char *) bufp->translate; - - /* Address of the count-byte of the most recently inserted `exactn' - command. This makes it possible to tell whether a new exact-match - character can be added to that command or requires a new `exactn' - command. */ - - char *pending_exact = 0; - - /* Address of the place where a forward-jump should go to the end of - the containing expression. Each alternative of an `or', except the - last, ends with a forward-jump of this sort. */ - - char *fixup_jump = 0; - - /* Address of start of the most recently finished expression. - This tells postfix * where to find the start of its operand. */ - - char *laststart = 0; - - /* In processing a repeat, 1 means zero matches is allowed. */ - - char zero_times_ok; - - /* In processing a repeat, 1 means many matches is allowed. */ - - char many_times_ok; - - /* Address of beginning of regexp, or inside of last \(. */ - - char *begalt = b; - - /* In processing an interval, at least this many matches must be made. */ - int lower_bound; - - /* In processing an interval, at most this many matches can be made. */ - int upper_bound; - - /* Place in pattern (i.e., the {) to which to go back if the interval - is invalid. */ - char *beg_interval = 0; - - /* Stack of information saved by \( and restored by \). - Four stack elements are pushed by each \(: - First, the value of b. - Second, the value of fixup_jump. - Third, the value of regnum. - Fourth, the value of begalt. */ - - int stackb[40]; - int *stackp = stackb; - int *stacke = stackb + 40; - int *stackt; - - /* Counts \('s as they are encountered. Remembered for the matching \), - where it becomes the register number to put in the stop_memory - command. */ - - int regnum = 1; - - bufp->fastmap_accurate = 0; - -#ifndef emacs -#ifndef SYNTAX_TABLE - /* Initialize the syntax table. */ - init_syntax_once(); -#endif -#endif - - if (bufp->allocated == 0) - { - bufp->allocated = INIT_BUF_SIZE; - if (bufp->buffer) - /* EXTEND_BUFFER loses when bufp->allocated is 0. */ - bufp->buffer = (char *) realloc (bufp->buffer, INIT_BUF_SIZE); - else - /* Caller did not allocate a buffer. Do it for them. */ - bufp->buffer = (char *) malloc (INIT_BUF_SIZE); - if (!bufp->buffer) goto memory_exhausted; - begalt = b = bufp->buffer; - } - - while (p != pend) - { - PATFETCH (c); - - switch (c) - { - case '$': - { - char *p1 = p; - /* When testing what follows the $, - look past the \-constructs that don't consume anything. */ - if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - while (p1 != pend) - { - if (*p1 == '\\' && p1 + 1 != pend - && (p1[1] == '<' || p1[1] == '>' - || p1[1] == '`' || p1[1] == '\'' -#ifdef emacs - || p1[1] == '=' -#endif - || p1[1] == 'b' || p1[1] == 'B')) - p1 += 2; - else - break; - } - if (obscure_syntax & RE_TIGHT_VBAR) - { - if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS) && p1 != pend) - goto normal_char; - /* Make operand of last vbar end before this `$'. */ - if (fixup_jump) - store_jump (fixup_jump, jump, b); - fixup_jump = 0; - BUFPUSH (endline); - break; - } - /* $ means succeed if at end of line, but only in special contexts. - If validly in the middle of a pattern, it is a normal character. */ - - if ((obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) && p1 != pend) - goto invalid_pattern; - if (p1 == pend || *p1 == '\n' - || (obscure_syntax & RE_CONTEXT_INDEP_OPS) - || (obscure_syntax & RE_NO_BK_PARENS - ? *p1 == ')' - : *p1 == '\\' && p1[1] == ')') - || (obscure_syntax & RE_NO_BK_VBAR - ? *p1 == '|' - : *p1 == '\\' && p1[1] == '|')) - { - BUFPUSH (endline); - break; - } - goto normal_char; - } - case '^': - /* ^ means succeed if at beg of line, but only if no preceding - pattern. */ - - if ((obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) && laststart) - goto invalid_pattern; - if (laststart && p - 2 >= pattern && p[-2] != '\n' - && !(obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - if (obscure_syntax & RE_TIGHT_VBAR) - { - if (p != pattern + 1 - && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - BUFPUSH (begline); - begalt = b; - } - else - BUFPUSH (begline); - break; - - case '+': - case '?': - if ((obscure_syntax & RE_BK_PLUS_QM) - || (obscure_syntax & RE_LIMITED_OPS)) - goto normal_char; - handle_plus: - case '*': - /* If there is no previous pattern, char not special. */ - if (!laststart) - { - if (obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) - goto invalid_pattern; - else if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - } - /* If there is a sequence of repetition chars, - collapse it down to just one. */ - zero_times_ok = 0; - many_times_ok = 0; - while (1) - { - zero_times_ok |= c != '+'; - many_times_ok |= c != '?'; - if (p == pend) - break; - PATFETCH (c); - if (c == '*') - ; - else if (!(obscure_syntax & RE_BK_PLUS_QM) - && (c == '+' || c == '?')) - ; - else if ((obscure_syntax & RE_BK_PLUS_QM) - && c == '\\') - { - /* int c1; */ - PATFETCH (c1); - if (!(c1 == '+' || c1 == '?')) - { - PATUNFETCH; - PATUNFETCH; - break; - } - c = c1; - } - else - { - PATUNFETCH; - break; - } - } - - /* Star, etc. applied to an empty pattern is equivalent - to an empty pattern. */ - if (!laststart) - break; - - /* Now we know whether or not zero matches is allowed - and also whether or not two or more matches is allowed. */ - if (many_times_ok) - { - /* If more than one repetition is allowed, put in at the - end a backward relative jump from b to before the next - jump we're going to put in below (which jumps from - laststart to after this jump). */ - GET_BUFFER_SPACE (3); - store_jump (b, maybe_finalize_jump, laststart - 3); - b += 3; /* Because store_jump put stuff here. */ - } - /* On failure, jump from laststart to b + 3, which will be the - end of the buffer after this jump is inserted. */ - GET_BUFFER_SPACE (3); - insert_jump (on_failure_jump, laststart, b + 3, b); - pending_exact = 0; - b += 3; - if (!zero_times_ok) - { - /* At least one repetition is required, so insert a - dummy-failure before the initial on-failure-jump - instruction of the loop. This effects a skip over that - instruction the first time we hit that loop. */ - GET_BUFFER_SPACE (6); - insert_jump (dummy_failure_jump, laststart, laststart + 6, b); - b += 3; - } - break; - - case '.': - laststart = b; - BUFPUSH (anychar); - break; - - case '[': - if (p == pend) - goto invalid_pattern; - while (b - bufp->buffer - > bufp->allocated - 3 - (1 << BYTEWIDTH) / BYTEWIDTH) - EXTEND_BUFFER; - - laststart = b; - if (*p == '^') - { - BUFPUSH (charset_not); - p++; - } - else - BUFPUSH (charset); - p0 = p; - - BUFPUSH ((1 << BYTEWIDTH) / BYTEWIDTH); - /* Clear the whole map */ - memset (b, 0, (1 << BYTEWIDTH) / BYTEWIDTH); - - if ((obscure_syntax & RE_HAT_NOT_NEWLINE) && b[-2] == charset_not) - SET_LIST_BIT ('\n'); - - - /* Read in characters and ranges, setting map bits. */ - while (1) - { - /* Don't translate while fetching, in case it's a range bound. - When we set the bit for the character, we translate it. */ - PATFETCH_RAW (c); - - /* If set, \ escapes characters when inside [...]. */ - if ((obscure_syntax & RE_AWK_CLASS_HACK) && c == '\\') - { - PATFETCH(c1); - SET_LIST_BIT (c1); - continue; - } - if (c == ']') - { - if (p == p0 + 1) - { - /* If this is an empty bracket expression. */ - if ((obscure_syntax & RE_NO_EMPTY_BRACKETS) - && p == pend) - goto invalid_pattern; - } - else - /* Stop if this isn't merely a ] inside a bracket - expression, but rather the end of a bracket - expression. */ - break; - } - /* Get a range. */ - if (p[0] == '-' && p[1] != ']') - { - PATFETCH (c1); - /* Don't translate the range bounds while fetching them. */ - PATFETCH_RAW (c1); - - if ((obscure_syntax & RE_NO_EMPTY_RANGES) && c > c1) - goto invalid_pattern; - - if ((obscure_syntax & RE_NO_HYPHEN_RANGE_END) - && c1 == '-' && *p != ']') - goto invalid_pattern; - - while (c <= c1) - { - /* Translate each char that's in the range. */ - if (translate) - SET_LIST_BIT (translate[c]); - else - SET_LIST_BIT (c); - c++; - } - } - else if ((obscure_syntax & RE_CHAR_CLASSES) - && c == '[' && p[0] == ':') - { - /* Longest valid character class word has six characters. */ - char str[CHAR_CLASS_MAX_LENGTH]; - PATFETCH (c); - c1 = 0; - /* If no ] at end. */ - if (p == pend) - goto invalid_pattern; - while (1) - { - /* Don't translate the ``character class'' characters. */ - PATFETCH_RAW (c); - if (c == ':' || c == ']' || p == pend - || c1 == CHAR_CLASS_MAX_LENGTH) - break; - str[c1++] = c; - } - str[c1] = '\0'; - if (p == pend - || c == ']' /* End of the bracket expression. */ - || p[0] != ']' - || p + 1 == pend - || (strcmp (str, "alpha") != 0 - && strcmp (str, "upper") != 0 - && strcmp (str, "lower") != 0 - && strcmp (str, "digit") != 0 - && strcmp (str, "alnum") != 0 - && strcmp (str, "xdigit") != 0 - && strcmp (str, "space") != 0 - && strcmp (str, "print") != 0 - && strcmp (str, "punct") != 0 - && strcmp (str, "graph") != 0 - && strcmp (str, "cntrl") != 0)) - { - /* Undo the ending character, the letters, and leave - the leading : and [ (but set bits for them). */ - c1++; - while (c1--) - PATUNFETCH; - SET_LIST_BIT ('['); - SET_LIST_BIT (':'); - } - else - { - /* The ] at the end of the character class. */ - PATFETCH (c); - if (c != ']') - goto invalid_pattern; - for (c = 0; c < (1 << BYTEWIDTH); c++) - { - if ((strcmp (str, "alpha") == 0 && isalpha (c)) - || (strcmp (str, "upper") == 0 && isupper (c)) - || (strcmp (str, "lower") == 0 && islower (c)) - || (strcmp (str, "digit") == 0 && isdigit (c)) - || (strcmp (str, "alnum") == 0 && isalnum (c)) - || (strcmp (str, "xdigit") == 0 && isxdigit (c)) - || (strcmp (str, "space") == 0 && isspace (c)) - || (strcmp (str, "print") == 0 && isprint (c)) - || (strcmp (str, "punct") == 0 && ispunct (c)) - || (strcmp (str, "graph") == 0 && isgraph (c)) - || (strcmp (str, "cntrl") == 0 && iscntrl (c))) - SET_LIST_BIT (c); - } - } - } - else if (translate) - SET_LIST_BIT (translate[c]); - else - SET_LIST_BIT (c); - } - - /* Discard any character set/class bitmap bytes that are all - 0 at the end of the map. Decrement the map-length byte too. */ - while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) - b[-1]--; - b += b[-1]; - break; - - case '(': - if (! (obscure_syntax & RE_NO_BK_PARENS)) - goto normal_char; - else - goto handle_open; - - case ')': - if (! (obscure_syntax & RE_NO_BK_PARENS)) - goto normal_char; - else - goto handle_close; - - case '\n': - if (! (obscure_syntax & RE_NEWLINE_OR)) - goto normal_char; - else - goto handle_bar; - - case '|': - if ((obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) - && (! laststart || p == pend)) - goto invalid_pattern; - else if (! (obscure_syntax & RE_NO_BK_VBAR)) - goto normal_char; - else - goto handle_bar; - - case '{': - if (! ((obscure_syntax & RE_NO_BK_CURLY_BRACES) - && (obscure_syntax & RE_INTERVALS))) - goto normal_char; - else - goto handle_interval; - - case '\\': - if (p == pend) goto invalid_pattern; - PATFETCH_RAW (c); - switch (c) - { - case '(': - if (obscure_syntax & RE_NO_BK_PARENS) - goto normal_backsl; - handle_open: - if (stackp == stacke) goto nesting_too_deep; - - /* Laststart should point to the start_memory that we are about - to push (unless the pattern has RE_NREGS or more ('s). */ - *stackp++ = b - bufp->buffer; - if (regnum < RE_NREGS) - { - BUFPUSH (start_memory); - BUFPUSH (regnum); - } - *stackp++ = fixup_jump ? fixup_jump - bufp->buffer + 1 : 0; - *stackp++ = regnum++; - *stackp++ = begalt - bufp->buffer; - fixup_jump = 0; - laststart = 0; - begalt = b; - break; - - case ')': - if (obscure_syntax & RE_NO_BK_PARENS) - goto normal_backsl; - handle_close: - if (stackp == stackb) goto unmatched_close; - begalt = *--stackp + bufp->buffer; - if (fixup_jump) - store_jump (fixup_jump, jump, b); - if (stackp[-1] < RE_NREGS) - { - BUFPUSH (stop_memory); - BUFPUSH (stackp[-1]); - } - stackp -= 2; - fixup_jump = *stackp ? *stackp + bufp->buffer - 1 : 0; - laststart = *--stackp + bufp->buffer; - break; - - case '|': - if ((obscure_syntax & RE_LIMITED_OPS) - || (obscure_syntax & RE_NO_BK_VBAR)) - goto normal_backsl; - handle_bar: - if (obscure_syntax & RE_LIMITED_OPS) - goto normal_char; - /* Insert before the previous alternative a jump which - jumps to this alternative if the former fails. */ - GET_BUFFER_SPACE (6); - insert_jump (on_failure_jump, begalt, b + 6, b); - pending_exact = 0; - b += 3; - /* The alternative before the previous alternative has a - jump after it which gets executed if it gets matched. - Adjust that jump so it will jump to the previous - alternative's analogous jump (put in below, which in - turn will jump to the next (if any) alternative's such - jump, etc.). The last such jump jumps to the correct - final destination. */ - if (fixup_jump) - store_jump (fixup_jump, jump, b); - - /* Leave space for a jump after previous alternative---to be - filled in later. */ - fixup_jump = b; - b += 3; - - laststart = 0; - begalt = b; - break; - - case '{': - if (! (obscure_syntax & RE_INTERVALS) - /* Let \{ be a literal. */ - || ((obscure_syntax & RE_INTERVALS) - && (obscure_syntax & RE_NO_BK_CURLY_BRACES)) - /* If it's the string "\{". */ - || (p - 2 == pattern && p == pend)) - goto normal_backsl; - handle_interval: - beg_interval = p - 1; /* The {. */ - /* If there is no previous pattern, this isn't an interval. */ - if (!laststart) - { - if (obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) - goto invalid_pattern; - else - goto normal_backsl; - } - /* It also isn't an interval if not preceded by an re - matching a single character or subexpression, or if - the current type of intervals can't handle back - references and the previous thing is a back reference. */ - if (! (*laststart == anychar - || *laststart == charset - || *laststart == charset_not - || *laststart == start_memory - || (*laststart == exactn && laststart[1] == 1) - || (! (obscure_syntax & RE_NO_BK_REFS) - && *laststart == duplicate))) - { - if (obscure_syntax & RE_NO_BK_CURLY_BRACES) - goto normal_char; - - /* Posix extended syntax is handled in previous - statement; this is for Posix basic syntax. */ - if (obscure_syntax & RE_INTERVALS) - goto invalid_pattern; - - goto normal_backsl; - } - lower_bound = -1; /* So can see if are set. */ - upper_bound = -1; - GET_UNSIGNED_NUMBER (lower_bound); - if (c == ',') - { - GET_UNSIGNED_NUMBER (upper_bound); - if (upper_bound < 0) - upper_bound = RE_DUP_MAX; - } - if (upper_bound < 0) - upper_bound = lower_bound; - if (! (obscure_syntax & RE_NO_BK_CURLY_BRACES)) - { - if (c != '\\') - goto invalid_pattern; - PATFETCH (c); - } - if (c != '}' || lower_bound < 0 || upper_bound > RE_DUP_MAX - || lower_bound > upper_bound - || ((obscure_syntax & RE_NO_BK_CURLY_BRACES) - && p != pend && *p == '{')) - { - if (obscure_syntax & RE_NO_BK_CURLY_BRACES) - goto unfetch_interval; - else - goto invalid_pattern; - } - - /* If upper_bound is zero, don't want to succeed at all; - jump from laststart to b + 3, which will be the end of - the buffer after this jump is inserted. */ - - if (upper_bound == 0) - { - GET_BUFFER_SPACE (3); - insert_jump (jump, laststart, b + 3, b); - b += 3; - } - - /* Otherwise, after lower_bound number of succeeds, jump - to after the jump_n which will be inserted at the end - of the buffer, and insert that jump_n. */ - else - { /* Set to 5 if only one repetition is allowed and - hence no jump_n is inserted at the current end of - the buffer; then only space for the succeed_n is - needed. Otherwise, need space for both the - succeed_n and the jump_n. */ - - unsigned slots_needed = upper_bound == 1 ? 5 : 10; - - GET_BUFFER_SPACE (slots_needed); - /* Initialize the succeed_n to n, even though it will - be set by its attendant set_number_at, because - re_compile_fastmap will need to know it. Jump to - what the end of buffer will be after inserting - this succeed_n and possibly appending a jump_n. */ - insert_jump_n (succeed_n, laststart, b + slots_needed, - b, lower_bound); - b += 5; /* Just increment for the succeed_n here. */ - - /* More than one repetition is allowed, so put in at - the end of the buffer a backward jump from b to the - succeed_n we put in above. By the time we've gotten - to this jump when matching, we'll have matched once - already, so jump back only upper_bound - 1 times. */ - - if (upper_bound > 1) - { - store_jump_n (b, jump_n, laststart, upper_bound - 1); - b += 5; - /* When hit this when matching, reset the - preceding jump_n's n to upper_bound - 1. */ - BUFPUSH (set_number_at); - GET_BUFFER_SPACE (2); - STORE_NUMBER_AND_INCR (b, -5); - STORE_NUMBER_AND_INCR (b, upper_bound - 1); - } - /* When hit this when matching, set the succeed_n's n. */ - GET_BUFFER_SPACE (5); - insert_op_2 (set_number_at, laststart, b, 5, lower_bound); - b += 5; - } - pending_exact = 0; - beg_interval = 0; - break; - - - unfetch_interval: - /* If an invalid interval, match the characters as literals. */ - if (beg_interval) - p = beg_interval; - else - { - fprintf (stderr, - "regex: no interval beginning to which to backtrack.\n"); - exit (1); - } - - beg_interval = 0; - PATFETCH (c); /* normal_char expects char in `c'. */ - goto normal_char; - break; - -#ifdef emacs - case '=': - BUFPUSH (at_dot); - break; - - case 's': - laststart = b; - BUFPUSH (syntaxspec); - PATFETCH (c); - BUFPUSH (syntax_spec_code[c]); - break; - - case 'S': - laststart = b; - BUFPUSH (notsyntaxspec); - PATFETCH (c); - BUFPUSH (syntax_spec_code[c]); - break; -#endif /* emacs */ - - case 'w': - laststart = b; - BUFPUSH (wordchar); - break; - - case 'W': - laststart = b; - BUFPUSH (notwordchar); - break; - - case '<': - BUFPUSH (wordbeg); - break; - - case '>': - BUFPUSH (wordend); - break; - - case 'b': - BUFPUSH (wordbound); - break; - - case 'B': - BUFPUSH (notwordbound); - break; - - case '`': - BUFPUSH (begbuf); - break; - - case '\'': - BUFPUSH (endbuf); - break; - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (obscure_syntax & RE_NO_BK_REFS) - goto normal_char; - c1 = c - '0'; - if (c1 >= regnum) - { - if (obscure_syntax & RE_NO_EMPTY_BK_REF) - goto invalid_pattern; - else - goto normal_char; - } - /* Can't back reference to a subexpression if inside of it. */ - for (stackt = stackp - 2; stackt > stackb; stackt -= 4) - if (*stackt == c1) - goto normal_char; - laststart = b; - BUFPUSH (duplicate); - BUFPUSH (c1); - break; - - case '+': - case '?': - if (obscure_syntax & RE_BK_PLUS_QM) - goto handle_plus; - else - goto normal_backsl; - break; - - default: - normal_backsl: - /* You might think it would be useful for \ to mean - not to translate; but if we don't translate it - it will never match anything. */ - if (translate) c = translate[c]; - goto normal_char; - } - break; - - default: - normal_char: /* Expects the character in `c'. */ - if (!pending_exact || pending_exact + *pending_exact + 1 != b - || *pending_exact == 0177 || *p == '*' || *p == '^' - || ((obscure_syntax & RE_BK_PLUS_QM) - ? *p == '\\' && (p[1] == '+' || p[1] == '?') - : (*p == '+' || *p == '?')) - || ((obscure_syntax & RE_INTERVALS) - && ((obscure_syntax & RE_NO_BK_CURLY_BRACES) - ? *p == '{' - : (p[0] == '\\' && p[1] == '{')))) - { - laststart = b; - BUFPUSH (exactn); - pending_exact = b; - BUFPUSH (0); - } - BUFPUSH (c); - (*pending_exact)++; - } - } - - if (fixup_jump) - store_jump (fixup_jump, jump, b); - - if (stackp != stackb) goto unmatched_open; - - bufp->used = b - bufp->buffer; - return 0; - - invalid_pattern: - return "Invalid regular expression"; - - unmatched_open: - return "Unmatched \\("; - - unmatched_close: - return "Unmatched \\)"; - - end_of_pattern: - return "Premature end of regular expression"; - - nesting_too_deep: - return "Nesting too deep"; - - too_big: - return "Regular expression too big"; - - memory_exhausted: - return "Memory exhausted"; -} - - -/* Store a jump of the form . - Store in the location FROM a jump operation to jump to relative - address FROM - TO. OPCODE is the opcode to store. */ - -static void -store_jump (from, opcode, to) - char *from, *to; - int opcode; -{ - from[0] = (char)opcode; - STORE_NUMBER(from + 1, to - (from + 3)); -} - - -/* Open up space before char FROM, and insert there a jump to TO. - CURRENT_END gives the end of the storage not in use, so we know - how much data to copy up. OP is the opcode of the jump to insert. - - If you call this function, you must zero out pending_exact. */ - -static void -insert_jump (op, from, to, current_end) - int op; - char *from, *to, *current_end; -{ - register char *pfrom = current_end; /* Copy from here... */ - register char *pto = current_end + 3; /* ...to here. */ - - while (pfrom != from) - *--pto = *--pfrom; - store_jump (from, op, to); -} - - -/* Store a jump of the form . - - Store in the location FROM a jump operation to jump to relative - address FROM - TO. OPCODE is the opcode to store, N is a number the - jump uses, say, to decide how many times to jump. - - If you call this function, you must zero out pending_exact. */ - -static void -store_jump_n (from, opcode, to, n) - char *from, *to; - int opcode; - unsigned n; -{ - from[0] = (char)opcode; - STORE_NUMBER (from + 1, to - (from + 3)); - STORE_NUMBER (from + 3, n); -} - - -/* Similar to insert_jump, but handles a jump which needs an extra - number to handle minimum and maximum cases. Open up space at - location FROM, and insert there a jump to TO. CURRENT_END gives the - end of the storage in use, so we know how much data to copy up. OP is - the opcode of the jump to insert. - - If you call this function, you must zero out pending_exact. */ - -static void -insert_jump_n (op, from, to, current_end, n) - int op; - char *from, *to, *current_end; - unsigned n; -{ - register char *pfrom = current_end; /* Copy from here... */ - register char *pto = current_end + 5; /* ...to here. */ - - while (pfrom != from) - *--pto = *--pfrom; - store_jump_n (from, op, to, n); -} - - -/* Open up space at location THERE, and insert operation OP followed by - NUM_1 and NUM_2. CURRENT_END gives the end of the storage in use, so - we know how much data to copy up. - - If you call this function, you must zero out pending_exact. */ - -static void -insert_op_2 (op, there, current_end, num_1, num_2) - int op; - char *there, *current_end; - int num_1, num_2; -{ - register char *pfrom = current_end; /* Copy from here... */ - register char *pto = current_end + 5; /* ...to here. */ - - while (pfrom != there) - *--pto = *--pfrom; - - there[0] = (char)op; - STORE_NUMBER (there + 1, num_1); - STORE_NUMBER (there + 3, num_2); -} - - - -/* Given a pattern, compute a fastmap from it. The fastmap records - which of the (1 << BYTEWIDTH) possible characters can start a string - that matches the pattern. This fastmap is used by re_search to skip - quickly over totally implausible text. - - The caller must supply the address of a (1 << BYTEWIDTH)-byte data - area as bufp->fastmap. - The other components of bufp describe the pattern to be used. */ - -void -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; -{ - unsigned char *pattern = (unsigned char *) bufp->buffer; - int size = bufp->used; - register char *fastmap = bufp->fastmap; - register unsigned char *p = pattern; - register unsigned char *pend = pattern + size; - register int j, k; - unsigned char *translate = (unsigned char *) bufp->translate; - unsigned is_a_succeed_n; - -#ifndef NO_ALLOCA - unsigned char *stackb[NFAILURES]; - unsigned char **stackp = stackb; - -#else - unsigned char **stackb; - unsigned char **stackp; - stackb = (unsigned char **) malloc (NFAILURES * sizeof (unsigned char *)); - stackp = stackb; - -#endif /* NO_ALLOCA */ - memset (fastmap, 0, (1 << BYTEWIDTH)); - bufp->fastmap_accurate = 1; - bufp->can_be_null = 0; - - while (p) - { - is_a_succeed_n = 0; - if (p == pend) - { - bufp->can_be_null = 1; - break; - } -#ifdef SWITCH_ENUM_BUG - switch ((int) ((enum regexpcode) *p++)) -#else - switch ((enum regexpcode) *p++) -#endif - { - case exactn: - if (translate) - fastmap[translate[p[1]]] = 1; - else - fastmap[p[1]] = 1; - break; - - case begline: - case before_dot: - case at_dot: - case after_dot: - case begbuf: - case endbuf: - case wordbound: - case notwordbound: - case wordbeg: - case wordend: - continue; - - case endline: - if (translate) - fastmap[translate['\n']] = 1; - else - fastmap['\n'] = 1; - - if (bufp->can_be_null != 1) - bufp->can_be_null = 2; - break; - - case jump_n: - case finalize_jump: - case maybe_finalize_jump: - case jump: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - if (j > 0) - continue; - /* Jump backward reached implies we just went through - the body of a loop and matched nothing. - Opcode jumped to should be an on_failure_jump. - Just treat it like an ordinary jump. - For a * loop, it has pushed its failure point already; - If so, discard that as redundant. */ - - if ((enum regexpcode) *p != on_failure_jump - && (enum regexpcode) *p != succeed_n) - continue; - p++; - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - if (stackp != stackb && *stackp == p) - stackp--; - continue; - - case on_failure_jump: - handle_on_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - *++stackp = p + j; - if (is_a_succeed_n) - EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ - continue; - - case succeed_n: - is_a_succeed_n = 1; - /* Get to the number of times to succeed. */ - p += 2; - /* Increment p past the n for when k != 0. */ - EXTRACT_NUMBER_AND_INCR (k, p); - if (k == 0) - { - p -= 4; - goto handle_on_failure_jump; - } - continue; - - case set_number_at: - p += 4; - continue; - - case start_memory: - case stop_memory: - p++; - continue; - - case duplicate: - bufp->can_be_null = 1; - fastmap['\n'] = 1; - case anychar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (j != '\n') - fastmap[j] = 1; - if (bufp->can_be_null) - { - FREE_AND_RETURN_VOID(stackb); - } - /* Don't return; check the alternative paths - so we can set can_be_null if appropriate. */ - break; - - case wordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == Sword) - fastmap[j] = 1; - break; - - case notwordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != Sword) - fastmap[j] = 1; - break; - -#ifdef emacs - case syntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == (enum syntaxcode) k) - fastmap[j] = 1; - break; - - case notsyntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != (enum syntaxcode) k) - fastmap[j] = 1; - break; - -#else /* not emacs */ - case syntaxspec: - case notsyntaxspec: - break; -#endif /* not emacs */ - - case charset: - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) - { - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - } - break; - - case charset_not: - /* Chars beyond end of map must be allowed */ - for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) - { - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - } - break; - - case unused: /* pacify gcc -Wall */ - break; - } - - /* Get here means we have successfully found the possible starting - characters of one path of the pattern. We need not follow this - path any farther. Instead, look at the next alternative - remembered in the stack. */ - if (stackp != stackb) - p = *stackp--; - else - break; - } - FREE_AND_RETURN_VOID(stackb); -} - - - -/* Like re_search_2, below, but only one string is specified, and - doesn't let you say where to stop matching. */ - -int -re_search (pbufp, string, size, startpos, range, regs) - struct re_pattern_buffer *pbufp; - char *string; - int size, startpos, range; - struct re_registers *regs; -{ - return re_search_2 (pbufp, (char *) 0, 0, string, size, startpos, range, - regs, size); -} - - -/* Using the compiled pattern in PBUFP->buffer, first tries to match the - virtual concatenation of STRING1 and STRING2, starting first at index - STARTPOS, then at STARTPOS + 1, and so on. RANGE is the number of - places to try before giving up. If RANGE is negative, it searches - backwards, i.e., the starting positions tried are STARTPOS, STARTPOS - - 1, etc. STRING1 and STRING2 are of SIZE1 and SIZE2, respectively. - In REGS, return the indices of the virtual concatenation of STRING1 - and STRING2 that matched the entire PBUFP->buffer and its contained - subexpressions. Do not consider matching one past the index MSTOP in - the virtual concatenation of STRING1 and STRING2. - - The value returned is the position in the strings at which the match - was found, or -1 if no match was found, or -2 if error (such as - failure stack overflow). */ - -int -re_search_2 (pbufp, string1, size1, string2, size2, startpos, range, - regs, mstop) - struct re_pattern_buffer *pbufp; - char *string1, *string2; - int size1, size2; - int startpos; - register int range; - struct re_registers *regs; - int mstop; -{ - register char *fastmap = pbufp->fastmap; - register unsigned char *translate = (unsigned char *) pbufp->translate; - int total_size = size1 + size2; - int endpos = startpos + range; - int val; - - /* Check for out-of-range starting position. */ - if (startpos < 0 || startpos > total_size) - return -1; - - /* Fix up range if it would eventually take startpos outside of the - virtual concatenation of string1 and string2. */ - if (endpos < -1) - range = -1 - startpos; - else if (endpos > total_size) - range = total_size - startpos; - - /* Update the fastmap now if not correct already. */ - if (fastmap && !pbufp->fastmap_accurate) - re_compile_fastmap (pbufp); - - /* If the search isn't to be a backwards one, don't waste time in a - long search for a pattern that says it is anchored. */ - if (pbufp->used > 0 && (enum regexpcode) pbufp->buffer[0] == begbuf - && range > 0) - { - if (startpos > 0) - return -1; - else - range = 1; - } - - while (1) - { - /* If a fastmap is supplied, skip quickly over characters that - cannot possibly be the start of a match. Note, however, that - if the pattern can possibly match the null string, we must - test it at each starting point so that we take the first null - string we get. */ - - if (fastmap && startpos < total_size && pbufp->can_be_null != 1) - { - if (range > 0) /* Searching forwards. */ - { - register int lim = 0; - register unsigned char *p; - int irange = range; - if (startpos < size1 && startpos + range >= size1) - lim = range - (size1 - startpos); - - p = ((unsigned char *) - &(startpos >= size1 ? string2 - size1 : string1)[startpos]); - - while (range > lim && !fastmap[translate - ? translate[*p++] - : *p++]) - range--; - startpos += irange - range; - } - else /* Searching backwards. */ - { - register unsigned char c; - - if (string1 == 0 || startpos >= size1) - c = string2[startpos - size1]; - else - c = string1[startpos]; - - c &= 0xff; - if (translate ? !fastmap[translate[c]] : !fastmap[c]) - goto advance; - } - } - - if (range >= 0 && startpos == total_size - && fastmap && pbufp->can_be_null == 0) - return -1; - - val = re_match_2 (pbufp, string1, size1, string2, size2, startpos, - regs, mstop); - if (val >= 0) - return startpos; - if (val == -2) - return -2; - -#ifndef NO_ALLOCA -#ifdef C_ALLOCA - alloca (0); -#endif /* C_ALLOCA */ - -#endif /* NO_ALLOCA */ - advance: - if (!range) - break; - else if (range > 0) - { - range--; - startpos++; - } - else - { - range++; - startpos--; - } - } - return -1; -} - - - -#ifndef emacs /* emacs never uses this. */ -int -re_match (pbufp, string, size, pos, regs) - struct re_pattern_buffer *pbufp; - char *string; - int size, pos; - struct re_registers *regs; -{ - return re_match_2 (pbufp, (char *) 0, 0, string, size, pos, regs, size); -} -#endif /* not emacs */ - - -/* The following are used for re_match_2, defined below: */ - -/* Roughly the maximum number of failure points on the stack. Would be - exactly that if always pushed MAX_NUM_FAILURE_ITEMS each time we failed. */ - -int re_max_failures = 2000; - -/* Routine used by re_match_2. */ -/* static int memcmp_translate (); *//* already declared */ - - -/* Structure and accessing macros used in re_match_2: */ - -struct register_info -{ - unsigned is_active : 1; - unsigned matched_something : 1; -}; - -#define IS_ACTIVE(R) ((R).is_active) -#define MATCHED_SOMETHING(R) ((R).matched_something) - - -/* Macros used by re_match_2: */ - - -/* I.e., regstart, regend, and reg_info. */ - -#define NUM_REG_ITEMS 3 - -/* We push at most this many things on the stack whenever we - fail. The `+ 2' refers to PATTERN_PLACE and STRING_PLACE, which are - arguments to the PUSH_FAILURE_POINT macro. */ - -#define MAX_NUM_FAILURE_ITEMS (RE_NREGS * NUM_REG_ITEMS + 2) - - -/* We push this many things on the stack whenever we fail. */ - -#define NUM_FAILURE_ITEMS (last_used_reg * NUM_REG_ITEMS + 2) - - -/* This pushes most of the information about the current state we will want - if we ever fail back to it. */ - -#define PUSH_FAILURE_POINT(pattern_place, string_place) \ - { \ - long last_used_reg, this_reg; \ - \ - /* Find out how many registers are active or have been matched. \ - (Aside from register zero, which is only set at the end.) */ \ - for (last_used_reg = RE_NREGS - 1; last_used_reg > 0; last_used_reg--)\ - if (regstart[last_used_reg] != (unsigned char *)(-1L)) \ - break; \ - \ - if (stacke - stackp < NUM_FAILURE_ITEMS) \ - { \ - unsigned char **stackx; \ - unsigned int len = stacke - stackb; \ - if (len > re_max_failures * MAX_NUM_FAILURE_ITEMS) \ - { \ - FREE_AND_RETURN(stackb,(-2)); \ - } \ - \ - /* Roughly double the size of the stack. */ \ - stackx = DOUBLE_STACK(stackx,stackb,len); \ - /* Rearrange the pointers. */ \ - stackp = stackx + (stackp - stackb); \ - stackb = stackx; \ - stacke = stackb + 2 * len; \ - } \ - \ - /* Now push the info for each of those registers. */ \ - for (this_reg = 1; this_reg <= last_used_reg; this_reg++) \ - { \ - *stackp++ = regstart[this_reg]; \ - *stackp++ = regend[this_reg]; \ - *stackp++ = (unsigned char *) ®_info[this_reg]; \ - } \ - \ - /* Push how many registers we saved. */ \ - *stackp++ = (unsigned char *) last_used_reg; \ - \ - *stackp++ = pattern_place; \ - *stackp++ = string_place; \ - } - - -/* This pops what PUSH_FAILURE_POINT pushes. */ - -#define POP_FAILURE_POINT() \ - { \ - int temp; \ - stackp -= 2; /* Remove failure points. */ \ - temp = (int) *--stackp; /* How many regs pushed. */ \ - temp *= NUM_REG_ITEMS; /* How much to take off the stack. */ \ - stackp -= temp; /* Remove the register info. */ \ - } - - -#define MATCHING_IN_FIRST_STRING (dend == end_match_1) - -/* Is true if there is a first string and if PTR is pointing anywhere - inside it or just past the end. */ - -#define IS_IN_FIRST_STRING(ptr) \ - (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) - -/* Call before fetching a character with *d. This switches over to - string2 if necessary. */ - -#define PREFETCH \ - while (d == dend) \ - { \ - /* end of string2 => fail. */ \ - if (dend == end_match_2) \ - goto fail; \ - /* end of string1 => advance to string2. */ \ - d = string2; \ - dend = end_match_2; \ - } - - -/* Call this when have matched something; it sets `matched' flags for the - registers corresponding to the subexpressions of which we currently - are inside. */ -#define SET_REGS_MATCHED \ - { unsigned this_reg; \ - for (this_reg = 0; this_reg < RE_NREGS; this_reg++) \ - { \ - if (IS_ACTIVE(reg_info[this_reg])) \ - MATCHED_SOMETHING(reg_info[this_reg]) = 1; \ - else \ - MATCHED_SOMETHING(reg_info[this_reg]) = 0; \ - } \ - } - -/* Test if at very beginning or at very end of the virtual concatenation - of string1 and string2. If there is only one string, we've put it in - string2. */ - -#define AT_STRINGS_BEG (d == (size1 ? string1 : string2) || !size2) -#define AT_STRINGS_END (d == end2) - -#define AT_WORD_BOUNDARY \ - (AT_STRINGS_BEG || AT_STRINGS_END || IS_A_LETTER (d - 1) != IS_A_LETTER (d)) - -/* We have two special cases to check for: - 1) if we're past the end of string1, we have to look at the first - character in string2; - 2) if we're before the beginning of string2, we have to look at the - last character in string1; we assume there is a string1, so use - this in conjunction with AT_STRINGS_BEG. */ -#define IS_A_LETTER(d) \ - (SYNTAX ((d) == end1 ? *string2 : (d) == string2 - 1 ? *(end1 - 1) : *(d))\ - == Sword) - - -/* Match the pattern described by PBUFP against the virtual - concatenation of STRING1 and STRING2, which are of SIZE1 and SIZE2, - respectively. Start the match at index POS in the virtual - concatenation of STRING1 and STRING2. In REGS, return the indices of - the virtual concatenation of STRING1 and STRING2 that matched the - entire PBUFP->buffer and its contained subexpressions. Do not - consider matching one past the index MSTOP in the virtual - concatenation of STRING1 and STRING2. - - If pbufp->fastmap is nonzero, then it had better be up to date. - - The reason that the data to match are specified as two components - which are to be regarded as concatenated is so this function can be - used directly on the contents of an Emacs buffer. - - -1 is returned if there is no match. -2 is returned if there is an - error (such as match stack overflow). Otherwise the value is the - length of the substring which was matched. */ - -int -re_match_2 (pbufp, string1_arg, size1, string2_arg, size2, pos, regs, mstop) - struct re_pattern_buffer *pbufp; - char *string1_arg, *string2_arg; - int size1, size2; - int pos; - struct re_registers *regs; - int mstop; -{ - register unsigned char *p = (unsigned char *) pbufp->buffer; - - /* Pointer to beyond end of buffer. */ - register unsigned char *pend = p + pbufp->used; - - unsigned char *string1 = (unsigned char *) string1_arg; - unsigned char *string2 = (unsigned char *) string2_arg; - unsigned char *end1; /* Just past end of first string. */ - unsigned char *end2; /* Just past end of second string. */ - - /* Pointers into string1 and string2, just past the last characters in - each to consider matching. */ - unsigned char *end_match_1, *end_match_2; - - register unsigned char *d, *dend; - register int mcnt; /* Multipurpose. */ - unsigned char *translate = (unsigned char *) pbufp->translate; - unsigned is_a_jump_n = 0; - - /* Failure point stack. Each place that can handle a failure further - down the line pushes a failure point on this stack. It consists of - restart, regend, and reg_info for all registers corresponding to the - subexpressions we're currently inside, plus the number of such - registers, and, finally, two char *'s. The first char * is where to - resume scanning the pattern; the second one is where to resume - scanning the strings. If the latter is zero, the failure point is a - ``dummy''; if a failure happens and the failure point is a dummy, it - gets discarded and the next next one is tried. */ - -#ifndef NO_ALLOCA - unsigned char *initial_stack[MAX_NUM_FAILURE_ITEMS * NFAILURES]; -#endif - unsigned char **stackb; - unsigned char **stackp; - unsigned char **stacke; - - - /* Information on the contents of registers. These are pointers into - the input strings; they record just what was matched (on this - attempt) by a subexpression part of the pattern, that is, the - regnum-th regstart pointer points to where in the pattern we began - matching and the regnum-th regend points to right after where we - stopped matching the regnum-th subexpression. (The zeroth register - keeps track of what the whole pattern matches.) */ - - unsigned char *regstart[RE_NREGS]; - unsigned char *regend[RE_NREGS]; - - /* The is_active field of reg_info helps us keep track of which (possibly - nested) subexpressions we are currently in. The matched_something - field of reg_info[reg_num] helps us tell whether or not we have - matched any of the pattern so far this time through the reg_num-th - subexpression. These two fields get reset each time through any - loop their register is in. */ - - struct register_info reg_info[RE_NREGS]; - - - /* The following record the register info as found in the above - variables when we find a match better than any we've seen before. - This happens as we backtrack through the failure points, which in - turn happens only if we have not yet matched the entire string. */ - - unsigned best_regs_set = 0; - unsigned char *best_regstart[RE_NREGS]; - unsigned char *best_regend[RE_NREGS]; - - /* Initialize the stack. */ -#ifdef NO_ALLOCA - stackb = (unsigned char **) malloc (MAX_NUM_FAILURE_ITEMS * NFAILURES * sizeof (char *)); -#else - stackb = initial_stack; -#endif - stackp = stackb; - stacke = &stackb[MAX_NUM_FAILURE_ITEMS * NFAILURES]; - -#ifdef DEBUG_REGEX - fprintf (stderr, "Entering re_match_2(%s%s)\n", string1_arg, string2_arg); -#endif - - /* Initialize subexpression text positions to -1 to mark ones that no - \( or ( and \) or ) has been seen for. Also set all registers to - inactive and mark them as not having matched anything or ever - failed. */ - for (mcnt = 0; mcnt < RE_NREGS; mcnt++) - { - regstart[mcnt] = regend[mcnt] = (unsigned char *) (-1L); - IS_ACTIVE (reg_info[mcnt]) = 0; - MATCHED_SOMETHING (reg_info[mcnt]) = 0; - } - - if (regs) - for (mcnt = 0; mcnt < RE_NREGS; mcnt++) - regs->start[mcnt] = regs->end[mcnt] = -1; - - /* Set up pointers to ends of strings. - Don't allow the second string to be empty unless both are empty. */ - if (size2 == 0) - { - string2 = string1; - size2 = size1; - string1 = 0; - size1 = 0; - } - end1 = string1 + size1; - end2 = string2 + size2; - - /* Compute where to stop matching, within the two strings. */ - if (mstop <= size1) - { - end_match_1 = string1 + mstop; - end_match_2 = string2; - } - else - { - end_match_1 = end1; - end_match_2 = string2 + mstop - size1; - } - - /* `p' scans through the pattern as `d' scans through the data. `dend' - is the end of the input string that `d' points within. `d' is - advanced into the following input string whenever necessary, but - this happens before fetching; therefore, at the beginning of the - loop, `d' can be pointing at the end of a string, but it cannot - equal string2. */ - - if (size1 != 0 && pos <= size1) - d = string1 + pos, dend = end_match_1; - else - d = string2 + pos - size1, dend = end_match_2; - - - /* This loops over pattern commands. It exits by returning from the - function if match is complete, or it drops through if match fails - at this starting point in the input data. */ - - while (1) - { -#ifdef DEBUG_REGEX - fprintf (stderr, - "regex loop(%d): matching 0x%02d\n", - p - (unsigned char *) pbufp->buffer, - *p); -#endif - is_a_jump_n = 0; - /* End of pattern means we might have succeeded. */ - if (p == pend) - { - /* If not end of string, try backtracking. Otherwise done. */ - if (d != end_match_2) - { - if (stackp != stackb) - { - /* More failure points to try. */ - - unsigned in_same_string = - IS_IN_FIRST_STRING (best_regend[0]) - == MATCHING_IN_FIRST_STRING; - - /* If exceeds best match so far, save it. */ - if (! best_regs_set - || (in_same_string && d > best_regend[0]) - || (! in_same_string && ! MATCHING_IN_FIRST_STRING)) - { - best_regs_set = 1; - best_regend[0] = d; /* Never use regstart[0]. */ - - for (mcnt = 1; mcnt < RE_NREGS; mcnt++) - { - best_regstart[mcnt] = regstart[mcnt]; - best_regend[mcnt] = regend[mcnt]; - } - } - goto fail; - } - /* If no failure points, don't restore garbage. */ - else if (best_regs_set) - { - restore_best_regs: - /* Restore best match. */ - d = best_regend[0]; - - for (mcnt = 0; mcnt < RE_NREGS; mcnt++) - { - regstart[mcnt] = best_regstart[mcnt]; - regend[mcnt] = best_regend[mcnt]; - } - } - } - - /* If caller wants register contents data back, convert it - to indices. */ - if (regs) - { - regs->start[0] = pos; - if (MATCHING_IN_FIRST_STRING) - regs->end[0] = d - string1; - else - regs->end[0] = d - string2 + size1; - for (mcnt = 1; mcnt < RE_NREGS; mcnt++) - { - if (regend[mcnt] == (unsigned char *)(-1L)) - { - regs->start[mcnt] = -1; - regs->end[mcnt] = -1; - continue; - } - if (IS_IN_FIRST_STRING (regstart[mcnt])) - regs->start[mcnt] = regstart[mcnt] - string1; - else - regs->start[mcnt] = regstart[mcnt] - string2 + size1; - - if (IS_IN_FIRST_STRING (regend[mcnt])) - regs->end[mcnt] = regend[mcnt] - string1; - else - regs->end[mcnt] = regend[mcnt] - string2 + size1; - } - } - FREE_AND_RETURN(stackb, - (d - pos - (MATCHING_IN_FIRST_STRING ? - string1 : - string2 - size1))); - } - - /* Otherwise match next pattern command. */ -#ifdef SWITCH_ENUM_BUG - switch ((int) ((enum regexpcode) *p++)) -#else - switch ((enum regexpcode) *p++) -#endif - { - - /* \( [or `(', as appropriate] is represented by start_memory, - \) by stop_memory. Both of those commands are followed by - a register number in the next byte. The text matched - within the \( and \) is recorded under that number. */ - case start_memory: - regstart[*p] = d; - IS_ACTIVE (reg_info[*p]) = 1; - MATCHED_SOMETHING (reg_info[*p]) = 0; - p++; - break; - - case stop_memory: - regend[*p] = d; - IS_ACTIVE (reg_info[*p]) = 0; - - /* If just failed to match something this time around with a sub- - expression that's in a loop, try to force exit from the loop. */ - if ((! MATCHED_SOMETHING (reg_info[*p]) - || (enum regexpcode) p[-3] == start_memory) - && (p + 1) != pend) - { - register unsigned char *p2 = p + 1; - mcnt = 0; - switch (*p2++) - { - case jump_n: - is_a_jump_n = 1; - case finalize_jump: - case maybe_finalize_jump: - case jump: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p2); - if (is_a_jump_n) - p2 += 2; - break; - } - p2 += mcnt; - - /* If the next operation is a jump backwards in the pattern - to an on_failure_jump, exit from the loop by forcing a - failure after pushing on the stack the on_failure_jump's - jump in the pattern, and d. */ - if (mcnt < 0 && (enum regexpcode) *p2++ == on_failure_jump) - { - EXTRACT_NUMBER_AND_INCR (mcnt, p2); - PUSH_FAILURE_POINT (p2 + mcnt, d); - goto fail; - } - } - p++; - break; - - /* \ has been turned into a `duplicate' command which is - followed by the numeric value of as the register number. */ - case duplicate: - { - int regno = *p++; /* Get which register to match against */ - register unsigned char *d2, *dend2; - - /* Where in input to try to start matching. */ - d2 = regstart[regno]; - - /* Where to stop matching; if both the place to start and - the place to stop matching are in the same string, then - set to the place to stop, otherwise, for now have to use - the end of the first string. */ - - dend2 = ((IS_IN_FIRST_STRING (regstart[regno]) - == IS_IN_FIRST_STRING (regend[regno])) - ? regend[regno] : end_match_1); - while (1) - { - /* If necessary, advance to next segment in register - contents. */ - while (d2 == dend2) - { - if (dend2 == end_match_2) break; - if (dend2 == regend[regno]) break; - d2 = string2, dend2 = regend[regno]; /* end of string1 => advance to string2. */ - } - /* At end of register contents => success */ - if (d2 == dend2) break; - - /* If necessary, advance to next segment in data. */ - PREFETCH; - - /* How many characters left in this segment to match. */ - mcnt = dend - d; - - /* Want how many consecutive characters we can match in - one shot, so, if necessary, adjust the count. */ - if (mcnt > dend2 - d2) - mcnt = dend2 - d2; - - /* Compare that many; failure if mismatch, else move - past them. */ - if (translate - ? memcmp_translate (d, d2, mcnt, translate) - : memcmp ((char *)d, (char *)d2, mcnt)) - goto fail; - d += mcnt, d2 += mcnt; - } - } - break; - - case anychar: - PREFETCH; /* Fetch a data character. */ - /* Match anything but a newline, maybe even a null. */ - if ((translate ? translate[*d] : *d) == '\n' - || ((obscure_syntax & RE_DOT_NOT_NULL) - && (translate ? translate[*d] : *d) == '\000')) - goto fail; - SET_REGS_MATCHED; - d++; - break; - - case charset: - case charset_not: - { - int not = 0; /* Nonzero for charset_not. */ - register int c; - if (*(p - 1) == (unsigned char) charset_not) - not = 1; - - PREFETCH; /* Fetch a data character. */ - - if (translate) - c = translate[*d]; - else - c = *d; - - if (c < *p * BYTEWIDTH - && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - p += 1 + *p; - - if (!not) goto fail; - SET_REGS_MATCHED; - d++; - break; - } - - case begline: - if ((size1 != 0 && d == string1) - || (size1 == 0 && size2 != 0 && d == string2) - || (d && d[-1] == '\n') - || (size1 == 0 && size2 == 0)) - break; - else - goto fail; - - case endline: - if (d == end2 - || (d == end1 ? (size2 == 0 || *string2 == '\n') : *d == '\n')) - break; - goto fail; - - /* `or' constructs are handled by starting each alternative with - an on_failure_jump that points to the start of the next - alternative. Each alternative except the last ends with a - jump to the joining point. (Actually, each jump except for - the last one really jumps to the following jump, because - tensioning the jumps is a hassle.) */ - - /* The start of a stupid repeat has an on_failure_jump that points - past the end of the repeat text. This makes a failure point so - that on failure to match a repetition, matching restarts past - as many repetitions have been found with no way to fail and - look for another one. */ - - /* A smart repeat is similar but loops back to the on_failure_jump - so that each repetition makes another failure point. */ - - case on_failure_jump: - on_failure: - EXTRACT_NUMBER_AND_INCR (mcnt, p); - PUSH_FAILURE_POINT (p + mcnt, d); - break; - - /* The end of a smart repeat has a maybe_finalize_jump back. - Change it either to a finalize_jump or an ordinary jump. */ - case maybe_finalize_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p); - { - register unsigned char *p2 = p; - /* Compare what follows with the beginning of the repeat. - If we can establish that there is nothing that they would - both match, we can change to finalize_jump. */ - while (p2 + 1 != pend - && (*p2 == (unsigned char) stop_memory - || *p2 == (unsigned char) start_memory)) - p2 += 2; /* Skip over reg number. */ - if (p2 == pend) - p[-3] = (unsigned char) finalize_jump; - else if (*p2 == (unsigned char) exactn - || *p2 == (unsigned char) endline) - { - register int c = *p2 == (unsigned char) endline ? '\n' : p2[2]; - register unsigned char *p1 = p + mcnt; - /* p1[0] ... p1[2] are an on_failure_jump. - Examine what follows that. */ - if (p1[3] == (unsigned char) exactn && p1[5] != c) - p[-3] = (unsigned char) finalize_jump; - else if (p1[3] == (unsigned char) charset - || p1[3] == (unsigned char) charset_not) - { - int not = p1[3] == (unsigned char) charset_not; - if (c < p1[4] * BYTEWIDTH - && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - /* `not' is 1 if c would match. */ - /* That means it is not safe to finalize. */ - if (!not) - p[-3] = (unsigned char) finalize_jump; - } - } - } - p -= 2; /* Point at relative address again. */ - if (p[-1] != (unsigned char) finalize_jump) - { - p[-1] = (unsigned char) jump; - goto nofinalize; - } - /* Note fall through. */ - - /* The end of a stupid repeat has a finalize_jump back to the - start, where another failure point will be made which will - point to after all the repetitions found so far. */ - - /* Take off failure points put on by matching on_failure_jump - because didn't fail. Also remove the register information - put on by the on_failure_jump. */ - case finalize_jump: - POP_FAILURE_POINT (); - /* Note fall through. */ - - /* Jump without taking off any failure points. */ - case jump: - nofinalize: - EXTRACT_NUMBER_AND_INCR (mcnt, p); - p += mcnt; - break; - - case dummy_failure_jump: - /* Normally, the on_failure_jump pushes a failure point, which - then gets popped at finalize_jump. We will end up at - finalize_jump, also, and with a pattern of, say, `a+', we - are skipping over the on_failure_jump, so we have to push - something meaningless for finalize_jump to pop. */ - PUSH_FAILURE_POINT (0, 0); - goto nofinalize; - - - /* Have to succeed matching what follows at least n times. Then - just handle like an on_failure_jump. */ - case succeed_n: - EXTRACT_NUMBER (mcnt, p + 2); - /* Originally, this is how many times we HAVE to succeed. */ - if (mcnt) - { - mcnt--; - p += 2; - STORE_NUMBER_AND_INCR (p, mcnt); - } - else if (mcnt == 0) - { - p[2] = unused; - p[3] = unused; - goto on_failure; - } - else - { - fprintf (stderr, "regex: the succeed_n's n is not set.\n"); - exit (1); - } - break; - - case jump_n: - EXTRACT_NUMBER (mcnt, p + 2); - /* Originally, this is how many times we CAN jump. */ - if (mcnt) - { - mcnt--; - STORE_NUMBER(p + 2, mcnt); - goto nofinalize; /* Do the jump without taking off - any failure points. */ - } - /* If don't have to jump any more, skip over the rest of command. */ - else - p += 4; - break; - - case set_number_at: - { - register unsigned char *p1; - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - p1 = p + mcnt; - EXTRACT_NUMBER_AND_INCR (mcnt, p); - STORE_NUMBER (p1, mcnt); - break; - } - - /* Ignore these. Used to ignore the n of succeed_n's which - currently have n == 0. */ - case unused: - break; - - case wordbound: - if (AT_WORD_BOUNDARY) - break; - goto fail; - - case notwordbound: - if (AT_WORD_BOUNDARY) - goto fail; - break; - - case wordbeg: - if (IS_A_LETTER (d) && (!IS_A_LETTER (d - 1) || AT_STRINGS_BEG)) - break; - goto fail; - - case wordend: - /* Have to check if AT_STRINGS_BEG before looking at d - 1. */ - if (!AT_STRINGS_BEG && IS_A_LETTER (d - 1) - && (!IS_A_LETTER (d) || AT_STRINGS_END)) - break; - goto fail; - -#ifdef emacs - case before_dot: - if (PTR_CHAR_POS (d) >= point) - goto fail; - break; - - case at_dot: - if (PTR_CHAR_POS (d) != point) - goto fail; - break; - - case after_dot: - if (PTR_CHAR_POS (d) <= point) - goto fail; - break; - - case wordchar: - mcnt = (int) Sword; - goto matchsyntax; - - case syntaxspec: - mcnt = *p++; - matchsyntax: - PREFETCH; - if (SYNTAX (*d++) != (enum syntaxcode) mcnt) goto fail; - SET_REGS_MATCHED; - break; - - case notwordchar: - mcnt = (int) Sword; - goto matchnotsyntax; - - case notsyntaxspec: - mcnt = *p++; - matchnotsyntax: - PREFETCH; - if (SYNTAX (*d++) == (enum syntaxcode) mcnt) goto fail; - SET_REGS_MATCHED; - break; - -#else /* not emacs */ - - case wordchar: - PREFETCH; - if (!IS_A_LETTER (d)) - goto fail; - SET_REGS_MATCHED; - break; - - case notwordchar: - PREFETCH; - if (IS_A_LETTER (d)) - goto fail; - SET_REGS_MATCHED; - break; - - case before_dot: - case at_dot: - case after_dot: - case syntaxspec: - case notsyntaxspec: - break; - -#endif /* not emacs */ - - case begbuf: - if (AT_STRINGS_BEG) - break; - goto fail; - - case endbuf: - if (AT_STRINGS_END) - break; - goto fail; - - case exactn: - /* Match the next few pattern characters exactly. - mcnt is how many characters to match. */ - mcnt = *p++; - /* This is written out as an if-else so we don't waste time - testing `translate' inside the loop. */ - if (translate) - { - do - { - PREFETCH; - if (translate[*d++] != *p++) goto fail; - } - while (--mcnt); - } - else - { - do - { - PREFETCH; - if (*d++ != *p++) goto fail; - } - while (--mcnt); - } - SET_REGS_MATCHED; - break; - } - continue; /* Successfully executed one pattern command; keep going. */ - - /* Jump here if any matching operation fails. */ - fail: - if (stackp != stackb) - /* A restart point is known. Restart there and pop it. */ - { - short last_used_reg, this_reg; - - /* If this failure point is from a dummy_failure_point, just - skip it. */ - if (!stackp[-2]) - { - POP_FAILURE_POINT (); - goto fail; - } - - d = *--stackp; - p = *--stackp; - if (d >= string1 && d <= end1) - dend = end_match_1; - /* Restore register info. */ - last_used_reg = (long) *--stackp; - - /* Make the ones that weren't saved -1 or 0 again. */ - for (this_reg = RE_NREGS - 1; this_reg > last_used_reg; this_reg--) - { - regend[this_reg] = (unsigned char *) (-1L); - regstart[this_reg] = (unsigned char *) (-1L); - IS_ACTIVE (reg_info[this_reg]) = 0; - MATCHED_SOMETHING (reg_info[this_reg]) = 0; - } - - /* And restore the rest from the stack. */ - for ( ; this_reg > 0; this_reg--) - { - reg_info[this_reg] = *(struct register_info *) *--stackp; - regend[this_reg] = *--stackp; - regstart[this_reg] = *--stackp; - } - } - else - break; /* Matching at this starting point really fails. */ - } - - if (best_regs_set) - goto restore_best_regs; - - FREE_AND_RETURN(stackb,(-1)); /* Failure to match. */ -} - - -static int -memcmp_translate (s1, s2, len, translate) - unsigned char *s1, *s2; - register int len; - unsigned char *translate; -{ - register unsigned char *p1 = s1, *p2 = s2; - while (len) - { - if (translate [*p1++] != translate [*p2++]) return 1; - len--; - } - return 0; -} - - - -/* Entry points compatible with 4.2 BSD regex library. */ - -#if !defined(emacs) && !defined(GAWK) - -static struct re_pattern_buffer re_comp_buf; - -char * -re_comp (s) - char *s; -{ - if (!s) - { - if (!re_comp_buf.buffer) - return "No previous regular expression"; - return 0; - } - - if (!re_comp_buf.buffer) - { - if (!(re_comp_buf.buffer = (char *) malloc (200))) - return "Memory exhausted"; - re_comp_buf.allocated = 200; - if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH))) - return "Memory exhausted"; - } - return re_compile_pattern (s, strlen (s), &re_comp_buf); -} - -int -re_exec (s) - char *s; -{ - int len = strlen (s); - return 0 <= re_search (&re_comp_buf, s, len, 0, len, - (struct re_registers *) 0); -} -#endif /* not emacs && not GAWK */ - - - -#ifdef test - -#ifdef atarist -long _stksize = 2L; /* reserve memory for stack */ -#endif -#include - -/* Indexed by a character, gives the upper case equivalent of the - character. */ - -char upcase[0400] = - { 000, 001, 002, 003, 004, 005, 006, 007, - 010, 011, 012, 013, 014, 015, 016, 017, - 020, 021, 022, 023, 024, 025, 026, 027, - 030, 031, 032, 033, 034, 035, 036, 037, - 040, 041, 042, 043, 044, 045, 046, 047, - 050, 051, 052, 053, 054, 055, 056, 057, - 060, 061, 062, 063, 064, 065, 066, 067, - 070, 071, 072, 073, 074, 075, 076, 077, - 0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137, - 0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177, - 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, - 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, - 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, - 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, - 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, - 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, - 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, - 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, - 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, - 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, - 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, - 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, - 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, - 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, - 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, - 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377 - }; - -#ifdef canned - -#include "tests.h" - -typedef enum { extended_test, basic_test } test_type; - -/* Use this to run the tests we've thought of. */ - -void -main () -{ - test_type t = extended_test; - - if (t == basic_test) - { - printf ("Running basic tests:\n\n"); - test_posix_basic (); - } - else if (t == extended_test) - { - printf ("Running extended tests:\n\n"); - test_posix_extended (); - } -} - -#else /* not canned */ - -/* Use this to run interactive tests. */ - -void -main (argc, argv) - int argc; - char **argv; -{ - char pat[80]; - struct re_pattern_buffer buf; - int i; - char c; - char fastmap[(1 << BYTEWIDTH)]; - - /* Allow a command argument to specify the style of syntax. */ - if (argc > 1) - obscure_syntax = atol (argv[1]); - - buf.allocated = 40; - buf.buffer = (char *) malloc (buf.allocated); - buf.fastmap = fastmap; - buf.translate = upcase; - - while (1) - { - gets (pat); - - if (*pat) - { - re_compile_pattern (pat, strlen(pat), &buf); - - for (i = 0; i < buf.used; i++) - printchar (buf.buffer[i]); - - putchar ('\n'); - - printf ("%d allocated, %d used.\n", buf.allocated, buf.used); - - re_compile_fastmap (&buf); - printf ("Allowed by fastmap: "); - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (fastmap[i]) printchar (i); - putchar ('\n'); - } - - gets (pat); /* Now read the string to match against */ - - i = re_match (&buf, pat, strlen (pat), 0, 0); - printf ("Match value %d.\n", i); - } -} - -#endif - - -#ifdef NOTDEF -print_buf (bufp) - struct re_pattern_buffer *bufp; -{ - int i; - - printf ("buf is :\n----------------\n"); - for (i = 0; i < bufp->used; i++) - printchar (bufp->buffer[i]); - - printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used); - - printf ("Allowed by fastmap: "); - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (bufp->fastmap[i]) - printchar (i); - printf ("\nAllowed by translate: "); - if (bufp->translate) - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (bufp->translate[i]) - printchar (i); - printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't"); - printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not"); -} -#endif /* NOTDEF */ - -printchar (c) - char c; -{ - if (c < 040 || c >= 0177) - { - putchar ('\\'); - putchar (((c >> 6) & 3) + '0'); - putchar (((c >> 3) & 7) + '0'); - putchar ((c & 7) + '0'); - } - else - putchar (c); -} - -error (string) - char *string; -{ - puts (string); - exit (1); -} -#endif /* test */ diff --git a/gnu/usr.bin/gawk-2.15.2/regex.h b/gnu/usr.bin/gawk-2.15.2/regex.h deleted file mode 100644 index fce11c3a97dd..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/regex.h +++ /dev/null @@ -1,260 +0,0 @@ -/* 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 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. */ - - -#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. */ -#ifndef RE_DUP_MAX -#define RE_DUP_MAX ((1 << 15) - 1) -#endif - - -/* This defines the various regexp syntaxes. */ -extern long 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 1L - -/* 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 (1L << 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 (1L << 2) - -/* If this bit is set, | binds tighter than ^ or $. - If not set, the contrary. */ -#define RE_TIGHT_VBAR (1L << 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 (1L << 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 (1L << 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 (1L << 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 (1L << 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 (1L << 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 (1L << 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 (1L << 10) - -/* If this bit is set, then [^...] doesn't match a newline. - If not set, it does. */ -#define RE_HAT_NOT_NEWLINE (1L << 11) - -/* If this bit is set, back references are recognized. - If not set, they aren't. */ -#define RE_NO_BK_REFS (1L << 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 (1L << 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 (1L << 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 (1L << 15) - -/* If this bit is set, then +, ? and | aren't recognized as operators. - If it's not, they are. */ -#define RE_LIMITED_OPS (1L << 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 (1L << 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 (1L << 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_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 *, size_t, 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); -extern long re_set_syntax (long syntax); - -#ifndef GAWK -/* 4.2 bsd compatibility. */ -extern char *re_comp (char *); -extern int re_exec (char *); -#endif - -#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 (); -extern long re_set_syntax(); - -#ifndef GAWK -/* 4.2 bsd compatibility. */ -extern char *re_comp (); -extern int re_exec (); -#endif - -#endif /* __STDC__ */ - - -#ifdef SYNTAX_TABLE -extern char *re_syntax_table; -#endif - -#endif /* !__REGEXP_LIBRARY */ diff --git a/gnu/usr.bin/gawk-2.15.2/version.c b/gnu/usr.bin/gawk-2.15.2/version.c deleted file mode 100644 index adea5fafacfb..000000000000 --- a/gnu/usr.bin/gawk-2.15.2/version.c +++ /dev/null @@ -1,46 +0,0 @@ -char *version_string = "@(#)Gnu Awk (gawk) 2.15"; - -/* 1.02 fixed /= += *= etc to return the new Left Hand Side instead - of the Right Hand Side */ - -/* 1.03 Fixed split() to treat strings of space and tab as FS if - the split char is ' '. - - Added -v option to print version number - - Fixed bug that caused rounding when printing large numbers */ - -/* 2.00beta Incorporated the functionality of the "new" awk as described - the book (reference not handy). Extensively tested, but no - doubt still buggy. Badly needs tuning and cleanup, in - particular in memory management which is currently almost - non-existent. */ - -/* 2.01 JF: Modified to compile under GCC, and fixed a few - bugs while I was at it. I hope I didn't add any more. - I modified parse.y to reduce the number of reduce/reduce - conflicts. There are still a few left. */ - -/* 2.02 Fixed JF's bugs; improved memory management, still needs - lots of work. */ - -/* 2.10 Major grammar rework and lots of bug fixes from David. - Major changes for performance enhancements from David. - A number of minor bug fixes and new features from Arnold. - Changes for MSDOS from Conrad Kwok and Scott Garfinkle. - The gawk.texinfo and info files included! */ - -/* 2.11 Bug fix release to 2.10. Lots of changes for portability, - speed, and configurability. */ - -/* 2.12 Lots of changes for portability, speed, and configurability. - Several bugs fixed. POSIX compliance. Removal of last set - of hard-wired limits. Atari and VMS ports added. */ - -/* 2.13 Public release of 2.12 */ - -/* 2.14 Mostly bug fixes. */ - -/* 2.15 Bug fixes plus intermixing of command-line source and files, - GNU long options, ARGIND, ERRNO and Plan 9 style /dev/ files. */ - diff --git a/gnu/usr.bin/gcc2/arch/da30/insn-attrtab.c b/gnu/usr.bin/gcc2/arch/da30/insn-attrtab.c deleted file mode 100644 index 0e86d1f4c35a..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/insn-attrtab.c +++ /dev/null @@ -1,14 +0,0 @@ -/* Generated automatically by the program `genattrtab' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "insn-config.h" -#include "recog.h" -#include "regs.h" -#include "real.h" -#include "output.h" -#include "insn-attr.h" - -#define operands recog_operand - diff --git a/gnu/usr.bin/gcc2/arch/da30/insn-codes.h b/gnu/usr.bin/gcc2/arch/da30/insn-codes.h deleted file mode 100644 index 35b48afb5612..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/insn-codes.h +++ /dev/null @@ -1,184 +0,0 @@ -/* Generated automatically by the program `gencodes' -from the machine description file `md'. */ - -#ifndef MAX_INSN_CODE - -enum insn_code { - CODE_FOR_tstsi = 2, - CODE_FOR_tsthi = 3, - CODE_FOR_tstqi = 4, - CODE_FOR_tstsf = 5, - CODE_FOR_tstsf_fpa = 6, - CODE_FOR_tstdf = 8, - CODE_FOR_tstdf_fpa = 9, - CODE_FOR_cmpsi = 11, - CODE_FOR_cmphi = 12, - CODE_FOR_cmpqi = 13, - CODE_FOR_cmpdf = 14, - CODE_FOR_cmpdf_fpa = 15, - CODE_FOR_cmpsf = 17, - CODE_FOR_cmpsf_fpa = 18, - CODE_FOR_movsi = 28, - CODE_FOR_movhi = 30, - CODE_FOR_movstricthi = 31, - CODE_FOR_movqi = 32, - CODE_FOR_movstrictqi = 33, - CODE_FOR_movsf = 34, - CODE_FOR_movdf = 35, - CODE_FOR_movxf = 36, - CODE_FOR_movdi = 39, - CODE_FOR_pushasi = 40, - CODE_FOR_truncsiqi2 = 41, - CODE_FOR_trunchiqi2 = 42, - CODE_FOR_truncsihi2 = 43, - CODE_FOR_zero_extendhisi2 = 44, - CODE_FOR_zero_extendqihi2 = 45, - CODE_FOR_zero_extendqisi2 = 46, - CODE_FOR_extendhisi2 = 50, - CODE_FOR_extendqihi2 = 51, - CODE_FOR_extendqisi2 = 52, - CODE_FOR_extendsfdf2 = 53, - CODE_FOR_truncdfsf2 = 56, - CODE_FOR_floatsisf2 = 60, - CODE_FOR_floatsidf2 = 63, - CODE_FOR_floathisf2 = 66, - CODE_FOR_floathidf2 = 67, - CODE_FOR_floatqisf2 = 68, - CODE_FOR_floatqidf2 = 69, - CODE_FOR_fix_truncdfsi2 = 70, - CODE_FOR_fix_truncdfhi2 = 71, - CODE_FOR_fix_truncdfqi2 = 72, - CODE_FOR_ftruncdf2 = 73, - CODE_FOR_ftruncsf2 = 74, - CODE_FOR_fixsfqi2 = 75, - CODE_FOR_fixsfhi2 = 76, - CODE_FOR_fixsfsi2 = 77, - CODE_FOR_fixdfqi2 = 78, - CODE_FOR_fixdfhi2 = 79, - CODE_FOR_fixdfsi2 = 80, - CODE_FOR_addsi3 = 83, - CODE_FOR_addhi3 = 85, - CODE_FOR_addqi3 = 88, - CODE_FOR_adddf3 = 91, - CODE_FOR_addsf3 = 94, - CODE_FOR_subsi3 = 97, - CODE_FOR_subhi3 = 99, - CODE_FOR_subqi3 = 101, - CODE_FOR_subdf3 = 103, - CODE_FOR_subsf3 = 106, - CODE_FOR_mulhi3 = 109, - CODE_FOR_mulhisi3 = 110, - CODE_FOR_mulsi3 = 112, - CODE_FOR_umulhisi3 = 113, - CODE_FOR_umulsidi3 = 115, - CODE_FOR_mulsidi3 = 118, - CODE_FOR_muldf3 = 121, - CODE_FOR_mulsf3 = 124, - CODE_FOR_divhi3 = 127, - CODE_FOR_divhisi3 = 128, - CODE_FOR_udivhi3 = 130, - CODE_FOR_udivhisi3 = 131, - CODE_FOR_divdf3 = 133, - CODE_FOR_divsf3 = 136, - CODE_FOR_modhi3 = 139, - CODE_FOR_modhisi3 = 140, - CODE_FOR_umodhi3 = 142, - CODE_FOR_umodhisi3 = 143, - CODE_FOR_divmodsi4 = 145, - CODE_FOR_udivmodsi4 = 146, - CODE_FOR_andsi3 = 147, - CODE_FOR_andhi3 = 148, - CODE_FOR_andqi3 = 151, - CODE_FOR_iorsi3 = 154, - CODE_FOR_iorhi3 = 155, - CODE_FOR_iorqi3 = 158, - CODE_FOR_xorsi3 = 161, - CODE_FOR_xorhi3 = 162, - CODE_FOR_xorqi3 = 165, - CODE_FOR_negsi2 = 168, - CODE_FOR_neghi2 = 169, - CODE_FOR_negqi2 = 171, - CODE_FOR_negsf2 = 173, - CODE_FOR_negdf2 = 176, - CODE_FOR_sqrtdf2 = 179, - CODE_FOR_abssf2 = 180, - CODE_FOR_absdf2 = 183, - CODE_FOR_one_cmplsi2 = 186, - CODE_FOR_one_cmplhi2 = 187, - CODE_FOR_one_cmplqi2 = 189, - CODE_FOR_ashlsi3 = 193, - CODE_FOR_ashlhi3 = 194, - CODE_FOR_ashlqi3 = 196, - CODE_FOR_ashrsi3 = 200, - CODE_FOR_ashrhi3 = 201, - CODE_FOR_ashrqi3 = 203, - CODE_FOR_lshlsi3 = 207, - CODE_FOR_lshlhi3 = 208, - CODE_FOR_lshlqi3 = 210, - CODE_FOR_lshrsi3 = 214, - CODE_FOR_lshrhi3 = 215, - CODE_FOR_lshrqi3 = 217, - CODE_FOR_rotlsi3 = 219, - CODE_FOR_rotlhi3 = 220, - CODE_FOR_rotlqi3 = 222, - CODE_FOR_rotrsi3 = 224, - CODE_FOR_rotrhi3 = 225, - CODE_FOR_rotrqi3 = 227, - CODE_FOR_extv = 235, - CODE_FOR_extzv = 236, - CODE_FOR_insv = 240, - CODE_FOR_seq = 248, - CODE_FOR_sne = 249, - CODE_FOR_sgt = 250, - CODE_FOR_sgtu = 251, - CODE_FOR_slt = 252, - CODE_FOR_sltu = 253, - CODE_FOR_sge = 254, - CODE_FOR_sgeu = 255, - CODE_FOR_sle = 256, - CODE_FOR_sleu = 257, - CODE_FOR_beq = 258, - CODE_FOR_bne = 259, - CODE_FOR_bgt = 260, - CODE_FOR_bgtu = 261, - CODE_FOR_blt = 262, - CODE_FOR_bltu = 263, - CODE_FOR_bge = 264, - CODE_FOR_bgeu = 265, - CODE_FOR_ble = 266, - CODE_FOR_bleu = 267, - CODE_FOR_jump = 278, - CODE_FOR_tablejump = 279, - CODE_FOR_decrement_and_branch_until_zero = 285, - CODE_FOR_call = 286, - CODE_FOR_call_value = 289, - CODE_FOR_untyped_call = 292, - CODE_FOR_blockage = 293, - CODE_FOR_nop = 294, - CODE_FOR_probe = 295, - CODE_FOR_return = 296, - CODE_FOR_indirect_jump = 297, - CODE_FOR_tstxf = 318, - CODE_FOR_cmpxf = 319, - CODE_FOR_extendsfxf2 = 321, - CODE_FOR_extenddfxf2 = 322, - CODE_FOR_truncxfdf2 = 323, - CODE_FOR_truncxfsf2 = 324, - CODE_FOR_floatsixf2 = 325, - CODE_FOR_floathixf2 = 326, - CODE_FOR_floatqixf2 = 327, - CODE_FOR_ftruncxf2 = 328, - CODE_FOR_fixxfqi2 = 329, - CODE_FOR_fixxfhi2 = 330, - CODE_FOR_fixxfsi2 = 331, - CODE_FOR_addxf3 = 332, - CODE_FOR_subxf3 = 334, - CODE_FOR_mulxf3 = 336, - CODE_FOR_divxf3 = 338, - CODE_FOR_negxf2 = 340, - CODE_FOR_absxf2 = 341, - CODE_FOR_sqrtxf2 = 342, - CODE_FOR_nothing }; - -#define MAX_INSN_CODE ((int) CODE_FOR_nothing) -#endif /* MAX_INSN_CODE */ diff --git a/gnu/usr.bin/gcc2/arch/da30/insn-config.h b/gnu/usr.bin/gcc2/arch/da30/insn-config.h deleted file mode 100644 index 7dba8866f62f..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/insn-config.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Generated automatically by the program `genconfig' -from the machine description file `md'. */ - - -#define MAX_RECOG_OPERANDS 10 - -#define MAX_DUP_OPERANDS 3 -#ifndef MAX_INSNS_PER_SPLIT -#define MAX_INSNS_PER_SPLIT 1 -#endif -#define REGISTER_CONSTRAINTS -#define HAVE_cc0 diff --git a/gnu/usr.bin/gcc2/arch/da30/insn-emit.c b/gnu/usr.bin/gcc2/arch/da30/insn-emit.c deleted file mode 100644 index 6b2694f69d5b..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/insn-emit.c +++ /dev/null @@ -1,1897 +0,0 @@ -/* Generated automatically by the program `genemit' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "expr.h" -#include "real.h" -#include "output.h" -#include "insn-config.h" - -#include "insn-flags.h" - -#include "insn-codes.h" - -extern char *insn_operand_constraint[][MAX_RECOG_OPERANDS]; - -extern rtx recog_operand[]; -#define operands emit_operand - -#define FAIL goto _fail - -#define DONE goto _done - -rtx -gen_tstsi (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tsthi (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tstqi (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tstsf (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_FPA) - { - emit_insn (gen_tstsf_fpa (operands[0])); - DONE; - } -} - operand0 = operands[0]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, operand0)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tstsf_fpa (operand0) - rtx operand0; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_tstdf (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_FPA) - { - emit_insn (gen_tstsf_fpa (operands[0])); - DONE; - } -} - operand0 = operands[0]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, operand0)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tstdf_fpa (operand0) - rtx operand0; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_cmpsi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmphi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmpqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmpdf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (TARGET_FPA) - { - emit_insn (gen_cmpdf_fpa (operands[0], operands[1])); - DONE; - } -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpdf_fpa (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_cmpsf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (TARGET_FPA) - { - emit_insn (gen_cmpsf_fpa (operands[0], operands[1])); - DONE; - } -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpsf_fpa (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_movsi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (flag_pic && symbolic_operand (operands[1], SImode)) - { - /* The source is an address which requires PIC relocation. - Call legitimize_pic_address with the source, mode, and a relocation - register (a new pseudo, or the final destination if reload_in_progress - is set). Then fall through normally */ - extern rtx legitimize_pic_address(); - rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode); - operands[1] = legitimize_pic_address (operands[1], SImode, temp); - } -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_movhi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movstricthi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand0), operand1); -} - -rtx -gen_movqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movstrictqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand0), operand1); -} - -rtx -gen_movsf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movdf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movxf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (CONSTANT_P (operands[1])) - { - operands[1] = force_const_mem (XFmode, operands[1]); - if (! memory_address_p (XFmode, XEXP (operands[1], 0)) - && ! reload_in_progress) - operands[1] = change_address (operands[1], XFmode, - XEXP (operands[1], 0)); - } -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_movdi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_pushasi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_truncsiqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, QImode, operand1)); -} - -rtx -gen_trunchiqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, QImode, operand1)); -} - -rtx -gen_truncsihi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, HImode, operand1)); -} - -rtx -gen_zero_extendhisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, HImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, HImode, operands[0], 0); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, const0_rtx)); - emit_insn (gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand2), operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_zero_extendqihi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, const0_rtx)); - emit_insn (gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand2), operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_zero_extendqisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, const0_rtx)); - emit_insn (gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand2), operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_extendhisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, SImode, operand1)); -} - -rtx -gen_extendqihi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, HImode, operand1)); -} - -rtx -gen_extendqisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, SImode, operand1)); -} - -rtx -gen_extendsfdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_EXTEND, DFmode, operand1)); -} - -rtx -gen_truncdfsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_TRUNCATE, SFmode, operand1)); -} - -rtx -gen_floatsisf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, SFmode, operand1)); -} - -rtx -gen_floatsidf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, DFmode, operand1)); -} - -rtx -gen_floathisf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, SFmode, operand1)); -} - -rtx -gen_floathidf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, DFmode, operand1)); -} - -rtx -gen_floatqisf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, SFmode, operand1)); -} - -rtx -gen_floatqidf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, DFmode, operand1)); -} - -rtx -gen_fix_truncdfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, gen_rtx (FIX, DFmode, operand1))), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_fix_truncdfhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, HImode, gen_rtx (FIX, DFmode, operand1))), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_fix_truncdfqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, QImode, gen_rtx (FIX, DFmode, operand1))), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_ftruncdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, DFmode, operand1)); -} - -rtx -gen_ftruncsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SFmode, operand1)); -} - -rtx -gen_fixsfqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, QImode, operand1)); -} - -rtx -gen_fixsfhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, HImode, operand1)); -} - -rtx -gen_fixsfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, operand1)); -} - -rtx -gen_fixdfqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, QImode, operand1)); -} - -rtx -gen_fixdfhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, HImode, operand1)); -} - -rtx -gen_fixdfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, operand1)); -} - -rtx -gen_addsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SImode, operand1, operand2)); -} - -rtx -gen_addhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, HImode, operand1, operand2)); -} - -rtx -gen_addqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, QImode, operand1, operand2)); -} - -rtx -gen_adddf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, DFmode, operand1, operand2)); -} - -rtx -gen_addsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SFmode, operand1, operand2)); -} - -rtx -gen_subsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, SImode, operand1, operand2)); -} - -rtx -gen_subhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, HImode, operand1, operand2)); -} - -rtx -gen_subqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, QImode, operand1, operand2)); -} - -rtx -gen_subdf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, DFmode, operand1, operand2)); -} - -rtx -gen_subsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, SFmode, operand1, operand2)); -} - -rtx -gen_mulhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, HImode, operand1, operand2)); -} - -rtx -gen_mulhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SImode, gen_rtx (SIGN_EXTEND, SImode, operand1), gen_rtx (SIGN_EXTEND, SImode, operand2))); -} - -rtx -gen_mulsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SImode, operand1, operand2)); -} - -rtx -gen_umulhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SImode, gen_rtx (ZERO_EXTEND, SImode, operand1), gen_rtx (ZERO_EXTEND, SImode, operand2))); -} - -rtx -gen_umulsidi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, gen_rtx (SUBREG, SImode, operand0, 1), gen_rtx (MULT, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, gen_rtx (SUBREG, SImode, operand0, 0), gen_rtx (TRUNCATE, SImode, gen_rtx (LSHIFTRT, DImode, gen_rtx (MULT, DImode, gen_rtx (ZERO_EXTEND, DImode, operand1), gen_rtx (ZERO_EXTEND, DImode, operand2)), GEN_INT (32)))))); -} - -rtx -gen_mulsidi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, gen_rtx (SUBREG, SImode, operand0, 1), gen_rtx (MULT, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, gen_rtx (SUBREG, SImode, operand0, 0), gen_rtx (TRUNCATE, SImode, gen_rtx (ASHIFT, DImode, gen_rtx (MULT, DImode, gen_rtx (SIGN_EXTEND, DImode, operand1), gen_rtx (SIGN_EXTEND, DImode, operand2)), GEN_INT (32)))))); -} - -rtx -gen_muldf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, DFmode, operand1, operand2)); -} - -rtx -gen_mulsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SFmode, operand1, operand2)); -} - -rtx -gen_divhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, HImode, operand1, operand2)); -} - -rtx -gen_divhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, HImode, gen_rtx (DIV, SImode, operand1, gen_rtx (SIGN_EXTEND, SImode, operand2)))); -} - -rtx -gen_udivhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UDIV, HImode, operand1, operand2)); -} - -rtx -gen_udivhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, HImode, gen_rtx (UDIV, SImode, operand1, gen_rtx (ZERO_EXTEND, SImode, operand2)))); -} - -rtx -gen_divdf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, DFmode, operand1, operand2)); -} - -rtx -gen_divsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, SFmode, operand1, operand2)); -} - -rtx -gen_modhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MOD, HImode, operand1, operand2)); -} - -rtx -gen_modhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, HImode, gen_rtx (MOD, SImode, operand1, gen_rtx (SIGN_EXTEND, SImode, operand2)))); -} - -rtx -gen_umodhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UMOD, HImode, operand1, operand2)); -} - -rtx -gen_umodhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, HImode, gen_rtx (UMOD, SImode, operand1, gen_rtx (ZERO_EXTEND, SImode, operand2)))); -} - -rtx -gen_divmodsi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (MOD, SImode, operand1, operand2)))); -} - -rtx -gen_udivmodsi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (UDIV, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (UMOD, SImode, operand1, operand2)))); -} - -rtx -gen_andsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, SImode, operand1, operand2)); -} - -rtx -gen_andhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, HImode, operand1, operand2)); -} - -rtx -gen_andqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, QImode, operand1, operand2)); -} - -rtx -gen_iorsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, SImode, operand1, operand2)); -} - -rtx -gen_iorhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, HImode, operand1, operand2)); -} - -rtx -gen_iorqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, QImode, operand1, operand2)); -} - -rtx -gen_xorsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, SImode, operand1, operand2)); -} - -rtx -gen_xorhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, HImode, operand1, operand2)); -} - -rtx -gen_xorqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, QImode, operand1, operand2)); -} - -rtx -gen_negsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, SImode, operand1)); -} - -rtx -gen_neghi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, HImode, operand1)); -} - -rtx -gen_negqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, QImode, operand1)); -} - -rtx -gen_negsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, SFmode, operand1)); -} - -rtx -gen_negdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, DFmode, operand1)); -} - -rtx -gen_sqrtdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SQRT, DFmode, operand1)); -} - -rtx -gen_abssf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ABS, SFmode, operand1)); -} - -rtx -gen_absdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ABS, DFmode, operand1)); -} - -rtx -gen_one_cmplsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, SImode, operand1)); -} - -rtx -gen_one_cmplhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, HImode, operand1)); -} - -rtx -gen_one_cmplqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, QImode, operand1)); -} - -rtx -gen_ashlsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, SImode, operand1, operand2)); -} - -rtx -gen_ashlhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, HImode, operand1, operand2)); -} - -rtx -gen_ashlqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, QImode, operand1, operand2)); -} - -rtx -gen_ashrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, SImode, operand1, operand2)); -} - -rtx -gen_ashrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, HImode, operand1, operand2)); -} - -rtx -gen_ashrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, QImode, operand1, operand2)); -} - -rtx -gen_lshlsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFT, SImode, operand1, operand2)); -} - -rtx -gen_lshlhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFT, HImode, operand1, operand2)); -} - -rtx -gen_lshlqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFT, QImode, operand1, operand2)); -} - -rtx -gen_lshrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, SImode, operand1, operand2)); -} - -rtx -gen_lshrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, HImode, operand1, operand2)); -} - -rtx -gen_lshrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, QImode, operand1, operand2)); -} - -rtx -gen_rotlsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, SImode, operand1, operand2)); -} - -rtx -gen_rotlhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, HImode, operand1, operand2)); -} - -rtx -gen_rotlqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, QImode, operand1, operand2)); -} - -rtx -gen_rotrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, SImode, operand1, operand2)); -} - -rtx -gen_rotrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, HImode, operand1, operand2)); -} - -rtx -gen_rotrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, QImode, operand1, operand2)); -} - -rtx -gen_extv (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTRACT, SImode, operand1, operand2, operand3)); -} - -rtx -gen_extzv (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ZERO_EXTRACT, SImode, operand1, operand2, operand3)); -} - -rtx -gen_insv (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (SET, VOIDmode, gen_rtx (ZERO_EXTRACT, SImode, operand0, operand1, operand2), operand3); -} - -rtx -gen_seq (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (EQ, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sne (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NE, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sgt (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (GT, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sgtu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (GTU, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_slt (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LT, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sltu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LTU, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sge (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (GE, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sgeu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (GEU, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sle (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LE, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sleu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LEU, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_beq (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (EQ, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bne (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (NE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bgt (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GT, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bgtu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GTU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_blt (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LT, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bltu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LTU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bge (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bgeu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GEU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_ble (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bleu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LEU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_jump (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (LABEL_REF, VOIDmode, operand0)); -} - -rtx -gen_tablejump (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ -#ifdef CASE_VECTOR_PC_RELATIVE - operands[0] = gen_rtx (PLUS, SImode, pc_rtx, operands[0]); -#endif -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_jump_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, pc_rtx, operand0), - gen_rtx (USE, VOIDmode, gen_rtx (LABEL_REF, VOIDmode, operand1))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_decrement_and_branch_until_zero (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GE, VOIDmode, gen_rtx (PLUS, SImode, operand0, constm1_rtx), const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand1), pc_rtx)), - gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SImode, operand0, constm1_rtx)))); -} - -rtx -gen_call (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF) - SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_call_insn (gen_rtx (CALL, VOIDmode, operand0, operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_call_value (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF) - SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_call_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (CALL, VOIDmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_untyped_call (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - int i; - - emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx)); - - for (i = 0; i < XVECLEN (operands[2], 0); i++) - { - rtx set = XVECEXP (operands[2], 0, i); - emit_move_insn (SET_DEST (set), SET_SRC (set)); - } - - /* The optimizer does not know that the call sets the function value - registers we stored in the result block. We avoid problems by - claiming that all hard registers are used and clobbered at this - point. */ - emit_insn (gen_blockage ()); - - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_call_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3, - gen_rtx (CALL, VOIDmode, operand0, const0_rtx), - operand1, - operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_blockage () -{ - return gen_rtx (UNSPEC_VOLATILE, VOIDmode, gen_rtvec (1, - const0_rtx), 0); -} - -rtx -gen_nop () -{ - return const0_rtx; -} - -rtx -gen_probe () -{ - return gen_rtx (REG, SImode, 15); -} - -rtx -gen_return () -{ - return gen_rtx (RETURN, VOIDmode); -} - -rtx -gen_indirect_jump (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, operand0); -} - -rtx -gen_tstxf (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_cmpxf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (CONSTANT_P (operands[0])) - operands[0] = force_const_mem (XFmode, operands[0]); - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_extendsfxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_EXTEND, XFmode, operand1)); -} - -rtx -gen_extenddfxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_EXTEND, XFmode, operand1)); -} - -rtx -gen_truncxfdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_TRUNCATE, DFmode, operand1)); -} - -rtx -gen_truncxfsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_TRUNCATE, SFmode, operand1)); -} - -rtx -gen_floatsixf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, XFmode, operand1)); -} - -rtx -gen_floathixf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, XFmode, operand1)); -} - -rtx -gen_floatqixf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, XFmode, operand1)); -} - -rtx -gen_ftruncxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, XFmode, operand1)); -} - -rtx -gen_fixxfqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, QImode, operand1)); -} - -rtx -gen_fixxfhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, HImode, operand1)); -} - -rtx -gen_fixxfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, operand1)); -} - -rtx -gen_addxf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, XFmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_subxf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, XFmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_mulxf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, XFmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_divxf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, XFmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_negxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, XFmode, operand1)); -} - -rtx -gen_absxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ABS, XFmode, operand1)); -} - -rtx -gen_sqrtxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SQRT, XFmode, operand1)); -} - - - -void -add_clobbers (pattern, insn_code_number) - rtx pattern; - int insn_code_number; -{ - int i; - - switch (insn_code_number) - { - case 72: - case 71: - case 70: - XVECEXP (pattern, 0, 1) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - XVECEXP (pattern, 0, 2) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - break; - - case 18: - case 15: - case 9: - case 6: - XVECEXP (pattern, 0, 1) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - break; - - default: - abort (); - } -} diff --git a/gnu/usr.bin/gcc2/arch/da30/insn-extract.c b/gnu/usr.bin/gcc2/arch/da30/insn-extract.c deleted file mode 100644 index 82338e52e321..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/insn-extract.c +++ /dev/null @@ -1,558 +0,0 @@ -/* Generated automatically by the program `genextract' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" - -static rtx junk; -extern rtx recog_operand[]; -extern rtx *recog_operand_loc[]; -extern rtx *recog_dup_loc[]; -extern char recog_dup_num[]; -extern -#ifdef __GNUC__ -__volatile__ -#endif -void fatal_insn_not_found (); - -void -insn_extract (insn) - rtx insn; -{ - register rtx *ro = recog_operand; - register rtx **ro_loc = recog_operand_loc; - rtx pat = PATTERN (insn); - switch (INSN_CODE (insn)) - { - case -1: - fatal_insn_not_found (insn); - - case 305: - case 304: - case 303: - case 302: - case 301: - case 300: - case 299: -#if __GNUC__ > 1 && !defined (bcopy) -#define bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#endif - bcopy (&XVECEXP (pat, 0, 0), ro, - sizeof (rtx) * XVECLEN (pat, 0)); - break; - - case 317: - case 315: - case 309: - case 308: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XEXP (XEXP (pat, 1), 1), 1)); - break; - - case 316: - case 314: - case 313: - case 312: - case 311: - case 310: - case 307: - case 306: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 0), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 296: - case 295: - case 294: - case 293: - break; - - case 285: - case 284: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 0; - recog_dup_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - recog_dup_num[1] = 0; - break; - - case 283: - case 282: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 0; - recog_dup_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - recog_dup_num[1] = 0; - break; - - case 281: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 0), 0)); - break; - - case 280: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 0), 0)); - break; - - case 278: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - break; - - case 277: - case 276: - case 275: - case 274: - case 273: - case 272: - case 271: - case 270: - case 269: - case 268: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (pat, 1), 2), 0)); - break; - - case 267: - case 266: - case 265: - case 264: - case 263: - case 262: - case 261: - case 260: - case 259: - case 258: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - break; - - case 247: - case 246: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 2)); - break; - - case 244: - case 243: - case 239: - case 238: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 0), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 0), 2)); - break; - - case 237: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 0), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 0), 2)); - ro[3] = *(ro_loc[3] = &XEXP (XEXP (pat, 1), 1)); - recog_dup_loc[0] = &XEXP (XEXP (XEXP (pat, 1), 0), 0); - recog_dup_num[0] = 0; - recog_dup_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 1); - recog_dup_num[1] = 1; - recog_dup_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 0), 2); - recog_dup_num[2] = 2; - break; - - case 242: - case 241: - case 236: - case 235: - case 234: - case 233: - case 232: - case 231: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XEXP (pat, 1), 2)); - break; - - case 245: - case 240: - case 230: - case 229: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 0), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 0), 2)); - ro[3] = *(ro_loc[3] = &XEXP (pat, 1)); - break; - - case 190: - case 188: - case 172: - case 170: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - recog_dup_loc[0] = &XEXP (XEXP (pat, 1), 0); - recog_dup_num[0] = 0; - break; - - case 146: - case 145: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - recog_dup_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1); - recog_dup_num[1] = 2; - break; - - case 144: - case 141: - case 132: - case 129: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 0), 1)); - break; - - case 143: - case 140: - case 131: - case 128: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (XEXP (pat, 1), 0), 1), 0)); - break; - - case 120: - case 117: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - recog_dup_loc[0] = &XEXP (XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0), 0), 0), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0), 0), 1); - recog_dup_num[1] = 2; - break; - - case 119: - case 116: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - recog_dup_loc[0] = &XEXP (XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0), 0), 0), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0), 0), 1), 0); - recog_dup_num[1] = 2; - break; - - case 114: - case 111: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 113: - case 110: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - break; - - case 167: - case 164: - case 160: - case 157: - case 153: - case 150: - case 90: - case 87: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - recog_dup_loc[0] = &XEXP (XEXP (pat, 1), 1); - recog_dup_num[0] = 0; - break; - - case 228: - case 226: - case 223: - case 221: - case 218: - case 216: - case 211: - case 209: - case 204: - case 202: - case 197: - case 195: - case 166: - case 163: - case 159: - case 156: - case 152: - case 149: - case 102: - case 100: - case 89: - case 86: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 1)); - recog_dup_loc[0] = &XEXP (XEXP (pat, 1), 0); - recog_dup_num[0] = 0; - break; - - case 98: - case 84: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - break; - - case 339: - case 337: - case 335: - case 333: - case 291: - case 290: - case 227: - case 225: - case 224: - case 222: - case 220: - case 219: - case 217: - case 215: - case 214: - case 213: - case 212: - case 210: - case 208: - case 207: - case 206: - case 205: - case 203: - case 201: - case 200: - case 199: - case 198: - case 196: - case 194: - case 193: - case 192: - case 191: - case 165: - case 162: - case 161: - case 158: - case 155: - case 154: - case 151: - case 148: - case 147: - case 142: - case 139: - case 138: - case 137: - case 135: - case 134: - case 130: - case 127: - case 126: - case 125: - case 123: - case 122: - case 112: - case 109: - case 108: - case 107: - case 105: - case 104: - case 101: - case 99: - case 97: - case 96: - case 95: - case 93: - case 92: - case 88: - case 85: - case 83: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 82: - case 81: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - break; - - case 72: - case 71: - case 70: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 2), 0)); - break; - - case 342: - case 341: - case 340: - case 331: - case 330: - case 329: - case 328: - case 327: - case 326: - case 325: - case 324: - case 323: - case 322: - case 321: - case 189: - case 187: - case 186: - case 185: - case 184: - case 182: - case 181: - case 179: - case 178: - case 177: - case 175: - case 174: - case 171: - case 169: - case 168: - case 80: - case 79: - case 78: - case 77: - case 76: - case 75: - case 74: - case 73: - case 69: - case 68: - case 67: - case 66: - case 65: - case 64: - case 62: - case 61: - case 59: - case 58: - case 57: - case 55: - case 54: - case 52: - case 51: - case 50: - case 49: - case 48: - case 47: - case 43: - case 42: - case 41: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - break; - - case 33: - case 31: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (pat, 1)); - break; - - case 257: - case 256: - case 255: - case 254: - case 253: - case 252: - case 251: - case 250: - case 249: - case 248: - case 27: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - break; - - case 25: - case 24: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 2)); - break; - - case 23: - case 22: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XEXP (pat, 1), 2), 1), 0)); - break; - - case 21: - case 20: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 2), 1)); - break; - - case 18: - case 15: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 320: - case 19: - case 16: - case 13: - case 12: - case 11: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 9: - case 6: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 318: - case 297: - case 10: - case 7: - case 4: - case 3: - case 2: - ro[0] = *(ro_loc[0] = &XEXP (pat, 1)); - break; - - case 298: - case 288: - case 287: - case 40: - case 39: - case 38: - case 37: - case 35: - case 34: - case 32: - case 30: - case 29: - case 26: - case 1: - case 0: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (pat, 1)); - break; - - default: - abort (); - } -} diff --git a/gnu/usr.bin/gcc2/arch/da30/insn-flags.h b/gnu/usr.bin/gcc2/arch/da30/insn-flags.h deleted file mode 100644 index 13cb48ec0612..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/insn-flags.h +++ /dev/null @@ -1,537 +0,0 @@ -/* Generated automatically by the program `genflags' -from the machine description file `md'. */ - -#define HAVE_tstsi 1 -#define HAVE_tsthi 1 -#define HAVE_tstqi 1 -#define HAVE_tstsf (TARGET_68881 || TARGET_FPA) -#define HAVE_tstsf_fpa (TARGET_FPA) -#define HAVE_tstdf (TARGET_68881 || TARGET_FPA) -#define HAVE_tstdf_fpa (TARGET_FPA) -#define HAVE_cmpsi 1 -#define HAVE_cmphi 1 -#define HAVE_cmpqi 1 -#define HAVE_cmpdf (TARGET_68881 || TARGET_FPA) -#define HAVE_cmpdf_fpa (TARGET_FPA) -#define HAVE_cmpsf (TARGET_68881 || TARGET_FPA) -#define HAVE_cmpsf_fpa (TARGET_FPA) -#define HAVE_movsi 1 -#define HAVE_movhi 1 -#define HAVE_movstricthi 1 -#define HAVE_movqi 1 -#define HAVE_movstrictqi 1 -#define HAVE_movsf 1 -#define HAVE_movdf 1 -#define HAVE_movxf 1 -#define HAVE_movdi 1 -#define HAVE_pushasi 1 -#define HAVE_truncsiqi2 1 -#define HAVE_trunchiqi2 1 -#define HAVE_truncsihi2 1 -#define HAVE_zero_extendhisi2 1 -#define HAVE_zero_extendqihi2 1 -#define HAVE_zero_extendqisi2 1 -#define HAVE_extendhisi2 1 -#define HAVE_extendqihi2 1 -#define HAVE_extendqisi2 (TARGET_68020) -#define HAVE_extendsfdf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_truncdfsf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_floatsisf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_floatsidf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_floathisf2 (TARGET_68881) -#define HAVE_floathidf2 (TARGET_68881) -#define HAVE_floatqisf2 (TARGET_68881) -#define HAVE_floatqidf2 (TARGET_68881) -#define HAVE_fix_truncdfsi2 (TARGET_68040) -#define HAVE_fix_truncdfhi2 (TARGET_68040) -#define HAVE_fix_truncdfqi2 (TARGET_68040) -#define HAVE_ftruncdf2 (TARGET_68881 && !TARGET_68040) -#define HAVE_ftruncsf2 (TARGET_68881 && !TARGET_68040) -#define HAVE_fixsfqi2 (TARGET_68881) -#define HAVE_fixsfhi2 (TARGET_68881) -#define HAVE_fixsfsi2 (TARGET_68881) -#define HAVE_fixdfqi2 (TARGET_68881) -#define HAVE_fixdfhi2 (TARGET_68881) -#define HAVE_fixdfsi2 (TARGET_68881) -#define HAVE_addsi3 1 -#define HAVE_addhi3 1 -#define HAVE_addqi3 1 -#define HAVE_adddf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_addsf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_subsi3 1 -#define HAVE_subhi3 1 -#define HAVE_subqi3 1 -#define HAVE_subdf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_subsf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_mulhi3 1 -#define HAVE_mulhisi3 1 -#define HAVE_mulsi3 (TARGET_68020) -#define HAVE_umulhisi3 1 -#define HAVE_umulsidi3 (TARGET_68020) -#define HAVE_mulsidi3 (TARGET_68020) -#define HAVE_muldf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_mulsf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_divhi3 1 -#define HAVE_divhisi3 1 -#define HAVE_udivhi3 1 -#define HAVE_udivhisi3 1 -#define HAVE_divdf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_divsf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_modhi3 1 -#define HAVE_modhisi3 1 -#define HAVE_umodhi3 1 -#define HAVE_umodhisi3 1 -#define HAVE_divmodsi4 (TARGET_68020) -#define HAVE_udivmodsi4 (TARGET_68020) -#define HAVE_andsi3 1 -#define HAVE_andhi3 1 -#define HAVE_andqi3 1 -#define HAVE_iorsi3 1 -#define HAVE_iorhi3 1 -#define HAVE_iorqi3 1 -#define HAVE_xorsi3 1 -#define HAVE_xorhi3 1 -#define HAVE_xorqi3 1 -#define HAVE_negsi2 1 -#define HAVE_neghi2 1 -#define HAVE_negqi2 1 -#define HAVE_negsf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_negdf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_sqrtdf2 (TARGET_68881) -#define HAVE_abssf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_absdf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_one_cmplsi2 1 -#define HAVE_one_cmplhi2 1 -#define HAVE_one_cmplqi2 1 -#define HAVE_ashlsi3 1 -#define HAVE_ashlhi3 1 -#define HAVE_ashlqi3 1 -#define HAVE_ashrsi3 1 -#define HAVE_ashrhi3 1 -#define HAVE_ashrqi3 1 -#define HAVE_lshlsi3 1 -#define HAVE_lshlhi3 1 -#define HAVE_lshlqi3 1 -#define HAVE_lshrsi3 1 -#define HAVE_lshrhi3 1 -#define HAVE_lshrqi3 1 -#define HAVE_rotlsi3 1 -#define HAVE_rotlhi3 1 -#define HAVE_rotlqi3 1 -#define HAVE_rotrsi3 1 -#define HAVE_rotrhi3 1 -#define HAVE_rotrqi3 1 -#define HAVE_extv (TARGET_68020 && TARGET_BITFIELD) -#define HAVE_extzv (TARGET_68020 && TARGET_BITFIELD) -#define HAVE_insv (TARGET_68020 && TARGET_BITFIELD) -#define HAVE_seq 1 -#define HAVE_sne 1 -#define HAVE_sgt 1 -#define HAVE_sgtu 1 -#define HAVE_slt 1 -#define HAVE_sltu 1 -#define HAVE_sge 1 -#define HAVE_sgeu 1 -#define HAVE_sle 1 -#define HAVE_sleu 1 -#define HAVE_beq 1 -#define HAVE_bne 1 -#define HAVE_bgt 1 -#define HAVE_bgtu 1 -#define HAVE_blt 1 -#define HAVE_bltu 1 -#define HAVE_bge 1 -#define HAVE_bgeu 1 -#define HAVE_ble 1 -#define HAVE_bleu 1 -#define HAVE_jump 1 -#define HAVE_tablejump 1 -#define HAVE_decrement_and_branch_until_zero (find_reg_note (insn, REG_NONNEG, 0)) -#define HAVE_call 1 -#define HAVE_call_value 1 -#define HAVE_untyped_call (NEEDS_UNTYPED_CALL) -#define HAVE_blockage 1 -#define HAVE_nop 1 -#define HAVE_probe (NEED_PROBE) -#define HAVE_return (USE_RETURN_INSN) -#define HAVE_indirect_jump 1 -#define HAVE_tstxf (TARGET_68881) -#define HAVE_cmpxf (TARGET_68881) -#define HAVE_extendsfxf2 (TARGET_68881) -#define HAVE_extenddfxf2 (TARGET_68881) -#define HAVE_truncxfdf2 (TARGET_68881) -#define HAVE_truncxfsf2 (TARGET_68881) -#define HAVE_floatsixf2 (TARGET_68881) -#define HAVE_floathixf2 (TARGET_68881) -#define HAVE_floatqixf2 (TARGET_68881) -#define HAVE_ftruncxf2 (TARGET_68881) -#define HAVE_fixxfqi2 (TARGET_68881) -#define HAVE_fixxfhi2 (TARGET_68881) -#define HAVE_fixxfsi2 (TARGET_68881) -#define HAVE_addxf3 (TARGET_68881) -#define HAVE_subxf3 (TARGET_68881) -#define HAVE_mulxf3 (TARGET_68881) -#define HAVE_divxf3 (TARGET_68881) -#define HAVE_negxf2 (TARGET_68881) -#define HAVE_absxf2 (TARGET_68881) -#define HAVE_sqrtxf2 (TARGET_68881) - -#ifndef NO_MD_PROTOTYPES -extern rtx gen_tstsi PROTO((rtx)); -extern rtx gen_tsthi PROTO((rtx)); -extern rtx gen_tstqi PROTO((rtx)); -extern rtx gen_tstsf PROTO((rtx)); -extern rtx gen_tstsf_fpa PROTO((rtx)); -extern rtx gen_tstdf PROTO((rtx)); -extern rtx gen_tstdf_fpa PROTO((rtx)); -extern rtx gen_cmpsi PROTO((rtx, rtx)); -extern rtx gen_cmphi PROTO((rtx, rtx)); -extern rtx gen_cmpqi PROTO((rtx, rtx)); -extern rtx gen_cmpdf PROTO((rtx, rtx)); -extern rtx gen_cmpdf_fpa PROTO((rtx, rtx)); -extern rtx gen_cmpsf PROTO((rtx, rtx)); -extern rtx gen_cmpsf_fpa PROTO((rtx, rtx)); -extern rtx gen_movsi PROTO((rtx, rtx)); -extern rtx gen_movhi PROTO((rtx, rtx)); -extern rtx gen_movstricthi PROTO((rtx, rtx)); -extern rtx gen_movqi PROTO((rtx, rtx)); -extern rtx gen_movstrictqi PROTO((rtx, rtx)); -extern rtx gen_movsf PROTO((rtx, rtx)); -extern rtx gen_movdf PROTO((rtx, rtx)); -extern rtx gen_movxf PROTO((rtx, rtx)); -extern rtx gen_movdi PROTO((rtx, rtx)); -extern rtx gen_pushasi PROTO((rtx, rtx)); -extern rtx gen_truncsiqi2 PROTO((rtx, rtx)); -extern rtx gen_trunchiqi2 PROTO((rtx, rtx)); -extern rtx gen_truncsihi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendhisi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendqihi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendqisi2 PROTO((rtx, rtx)); -extern rtx gen_extendhisi2 PROTO((rtx, rtx)); -extern rtx gen_extendqihi2 PROTO((rtx, rtx)); -extern rtx gen_extendqisi2 PROTO((rtx, rtx)); -extern rtx gen_extendsfdf2 PROTO((rtx, rtx)); -extern rtx gen_truncdfsf2 PROTO((rtx, rtx)); -extern rtx gen_floatsisf2 PROTO((rtx, rtx)); -extern rtx gen_floatsidf2 PROTO((rtx, rtx)); -extern rtx gen_floathisf2 PROTO((rtx, rtx)); -extern rtx gen_floathidf2 PROTO((rtx, rtx)); -extern rtx gen_floatqisf2 PROTO((rtx, rtx)); -extern rtx gen_floatqidf2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncdfsi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncdfhi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncdfqi2 PROTO((rtx, rtx)); -extern rtx gen_ftruncdf2 PROTO((rtx, rtx)); -extern rtx gen_ftruncsf2 PROTO((rtx, rtx)); -extern rtx gen_fixsfqi2 PROTO((rtx, rtx)); -extern rtx gen_fixsfhi2 PROTO((rtx, rtx)); -extern rtx gen_fixsfsi2 PROTO((rtx, rtx)); -extern rtx gen_fixdfqi2 PROTO((rtx, rtx)); -extern rtx gen_fixdfhi2 PROTO((rtx, rtx)); -extern rtx gen_fixdfsi2 PROTO((rtx, rtx)); -extern rtx gen_addsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_adddf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subdf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_umulhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_umulsidi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulsidi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_muldf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_udivhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_udivhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divdf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_modhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_modhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_umodhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_umodhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divmodsi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_udivmodsi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_andsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_andhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_andqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_negsi2 PROTO((rtx, rtx)); -extern rtx gen_neghi2 PROTO((rtx, rtx)); -extern rtx gen_negqi2 PROTO((rtx, rtx)); -extern rtx gen_negsf2 PROTO((rtx, rtx)); -extern rtx gen_negdf2 PROTO((rtx, rtx)); -extern rtx gen_sqrtdf2 PROTO((rtx, rtx)); -extern rtx gen_abssf2 PROTO((rtx, rtx)); -extern rtx gen_absdf2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplsi2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplhi2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplqi2 PROTO((rtx, rtx)); -extern rtx gen_ashlsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashlhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashlqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshlsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshlhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshlqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_extv PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_extzv PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_insv PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_seq PROTO((rtx)); -extern rtx gen_sne PROTO((rtx)); -extern rtx gen_sgt PROTO((rtx)); -extern rtx gen_sgtu PROTO((rtx)); -extern rtx gen_slt PROTO((rtx)); -extern rtx gen_sltu PROTO((rtx)); -extern rtx gen_sge PROTO((rtx)); -extern rtx gen_sgeu PROTO((rtx)); -extern rtx gen_sle PROTO((rtx)); -extern rtx gen_sleu PROTO((rtx)); -extern rtx gen_beq PROTO((rtx)); -extern rtx gen_bne PROTO((rtx)); -extern rtx gen_bgt PROTO((rtx)); -extern rtx gen_bgtu PROTO((rtx)); -extern rtx gen_blt PROTO((rtx)); -extern rtx gen_bltu PROTO((rtx)); -extern rtx gen_bge PROTO((rtx)); -extern rtx gen_bgeu PROTO((rtx)); -extern rtx gen_ble PROTO((rtx)); -extern rtx gen_bleu PROTO((rtx)); -extern rtx gen_jump PROTO((rtx)); -extern rtx gen_tablejump PROTO((rtx, rtx)); -extern rtx gen_decrement_and_branch_until_zero PROTO((rtx, rtx)); -extern rtx gen_untyped_call PROTO((rtx, rtx, rtx)); -extern rtx gen_blockage PROTO((void)); -extern rtx gen_nop PROTO((void)); -extern rtx gen_probe PROTO((void)); -extern rtx gen_return PROTO((void)); -extern rtx gen_indirect_jump PROTO((rtx)); -extern rtx gen_tstxf PROTO((rtx)); -extern rtx gen_cmpxf PROTO((rtx, rtx)); -extern rtx gen_extendsfxf2 PROTO((rtx, rtx)); -extern rtx gen_extenddfxf2 PROTO((rtx, rtx)); -extern rtx gen_truncxfdf2 PROTO((rtx, rtx)); -extern rtx gen_truncxfsf2 PROTO((rtx, rtx)); -extern rtx gen_floatsixf2 PROTO((rtx, rtx)); -extern rtx gen_floathixf2 PROTO((rtx, rtx)); -extern rtx gen_floatqixf2 PROTO((rtx, rtx)); -extern rtx gen_ftruncxf2 PROTO((rtx, rtx)); -extern rtx gen_fixxfqi2 PROTO((rtx, rtx)); -extern rtx gen_fixxfhi2 PROTO((rtx, rtx)); -extern rtx gen_fixxfsi2 PROTO((rtx, rtx)); -extern rtx gen_addxf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subxf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulxf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divxf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_negxf2 PROTO((rtx, rtx)); -extern rtx gen_absxf2 PROTO((rtx, rtx)); -extern rtx gen_sqrtxf2 PROTO((rtx, rtx)); - -#ifdef MD_CALL_PROTOTYPES -extern rtx gen_call PROTO((rtx, rtx)); -extern rtx gen_call_value PROTO((rtx, rtx, rtx)); - -#else /* !MD_CALL_PROTOTYPES */ -extern rtx gen_call (); -extern rtx gen_call_value (); -#endif /* !MD_CALL_PROTOTYPES */ - -#else /* NO_MD_PROTOTYPES */ -extern rtx gen_tstsi (); -extern rtx gen_tsthi (); -extern rtx gen_tstqi (); -extern rtx gen_tstsf (); -extern rtx gen_tstsf_fpa (); -extern rtx gen_tstdf (); -extern rtx gen_tstdf_fpa (); -extern rtx gen_cmpsi (); -extern rtx gen_cmphi (); -extern rtx gen_cmpqi (); -extern rtx gen_cmpdf (); -extern rtx gen_cmpdf_fpa (); -extern rtx gen_cmpsf (); -extern rtx gen_cmpsf_fpa (); -extern rtx gen_movsi (); -extern rtx gen_movhi (); -extern rtx gen_movstricthi (); -extern rtx gen_movqi (); -extern rtx gen_movstrictqi (); -extern rtx gen_movsf (); -extern rtx gen_movdf (); -extern rtx gen_movxf (); -extern rtx gen_movdi (); -extern rtx gen_pushasi (); -extern rtx gen_truncsiqi2 (); -extern rtx gen_trunchiqi2 (); -extern rtx gen_truncsihi2 (); -extern rtx gen_zero_extendhisi2 (); -extern rtx gen_zero_extendqihi2 (); -extern rtx gen_zero_extendqisi2 (); -extern rtx gen_extendhisi2 (); -extern rtx gen_extendqihi2 (); -extern rtx gen_extendqisi2 (); -extern rtx gen_extendsfdf2 (); -extern rtx gen_truncdfsf2 (); -extern rtx gen_floatsisf2 (); -extern rtx gen_floatsidf2 (); -extern rtx gen_floathisf2 (); -extern rtx gen_floathidf2 (); -extern rtx gen_floatqisf2 (); -extern rtx gen_floatqidf2 (); -extern rtx gen_fix_truncdfsi2 (); -extern rtx gen_fix_truncdfhi2 (); -extern rtx gen_fix_truncdfqi2 (); -extern rtx gen_ftruncdf2 (); -extern rtx gen_ftruncsf2 (); -extern rtx gen_fixsfqi2 (); -extern rtx gen_fixsfhi2 (); -extern rtx gen_fixsfsi2 (); -extern rtx gen_fixdfqi2 (); -extern rtx gen_fixdfhi2 (); -extern rtx gen_fixdfsi2 (); -extern rtx gen_addsi3 (); -extern rtx gen_addhi3 (); -extern rtx gen_addqi3 (); -extern rtx gen_adddf3 (); -extern rtx gen_addsf3 (); -extern rtx gen_subsi3 (); -extern rtx gen_subhi3 (); -extern rtx gen_subqi3 (); -extern rtx gen_subdf3 (); -extern rtx gen_subsf3 (); -extern rtx gen_mulhi3 (); -extern rtx gen_mulhisi3 (); -extern rtx gen_mulsi3 (); -extern rtx gen_umulhisi3 (); -extern rtx gen_umulsidi3 (); -extern rtx gen_mulsidi3 (); -extern rtx gen_muldf3 (); -extern rtx gen_mulsf3 (); -extern rtx gen_divhi3 (); -extern rtx gen_divhisi3 (); -extern rtx gen_udivhi3 (); -extern rtx gen_udivhisi3 (); -extern rtx gen_divdf3 (); -extern rtx gen_divsf3 (); -extern rtx gen_modhi3 (); -extern rtx gen_modhisi3 (); -extern rtx gen_umodhi3 (); -extern rtx gen_umodhisi3 (); -extern rtx gen_divmodsi4 (); -extern rtx gen_udivmodsi4 (); -extern rtx gen_andsi3 (); -extern rtx gen_andhi3 (); -extern rtx gen_andqi3 (); -extern rtx gen_iorsi3 (); -extern rtx gen_iorhi3 (); -extern rtx gen_iorqi3 (); -extern rtx gen_xorsi3 (); -extern rtx gen_xorhi3 (); -extern rtx gen_xorqi3 (); -extern rtx gen_negsi2 (); -extern rtx gen_neghi2 (); -extern rtx gen_negqi2 (); -extern rtx gen_negsf2 (); -extern rtx gen_negdf2 (); -extern rtx gen_sqrtdf2 (); -extern rtx gen_abssf2 (); -extern rtx gen_absdf2 (); -extern rtx gen_one_cmplsi2 (); -extern rtx gen_one_cmplhi2 (); -extern rtx gen_one_cmplqi2 (); -extern rtx gen_ashlsi3 (); -extern rtx gen_ashlhi3 (); -extern rtx gen_ashlqi3 (); -extern rtx gen_ashrsi3 (); -extern rtx gen_ashrhi3 (); -extern rtx gen_ashrqi3 (); -extern rtx gen_lshlsi3 (); -extern rtx gen_lshlhi3 (); -extern rtx gen_lshlqi3 (); -extern rtx gen_lshrsi3 (); -extern rtx gen_lshrhi3 (); -extern rtx gen_lshrqi3 (); -extern rtx gen_rotlsi3 (); -extern rtx gen_rotlhi3 (); -extern rtx gen_rotlqi3 (); -extern rtx gen_rotrsi3 (); -extern rtx gen_rotrhi3 (); -extern rtx gen_rotrqi3 (); -extern rtx gen_extv (); -extern rtx gen_extzv (); -extern rtx gen_insv (); -extern rtx gen_seq (); -extern rtx gen_sne (); -extern rtx gen_sgt (); -extern rtx gen_sgtu (); -extern rtx gen_slt (); -extern rtx gen_sltu (); -extern rtx gen_sge (); -extern rtx gen_sgeu (); -extern rtx gen_sle (); -extern rtx gen_sleu (); -extern rtx gen_beq (); -extern rtx gen_bne (); -extern rtx gen_bgt (); -extern rtx gen_bgtu (); -extern rtx gen_blt (); -extern rtx gen_bltu (); -extern rtx gen_bge (); -extern rtx gen_bgeu (); -extern rtx gen_ble (); -extern rtx gen_bleu (); -extern rtx gen_jump (); -extern rtx gen_tablejump (); -extern rtx gen_decrement_and_branch_until_zero (); -extern rtx gen_untyped_call (); -extern rtx gen_blockage (); -extern rtx gen_nop (); -extern rtx gen_probe (); -extern rtx gen_return (); -extern rtx gen_indirect_jump (); -extern rtx gen_tstxf (); -extern rtx gen_cmpxf (); -extern rtx gen_extendsfxf2 (); -extern rtx gen_extenddfxf2 (); -extern rtx gen_truncxfdf2 (); -extern rtx gen_truncxfsf2 (); -extern rtx gen_floatsixf2 (); -extern rtx gen_floathixf2 (); -extern rtx gen_floatqixf2 (); -extern rtx gen_ftruncxf2 (); -extern rtx gen_fixxfqi2 (); -extern rtx gen_fixxfhi2 (); -extern rtx gen_fixxfsi2 (); -extern rtx gen_addxf3 (); -extern rtx gen_subxf3 (); -extern rtx gen_mulxf3 (); -extern rtx gen_divxf3 (); -extern rtx gen_negxf2 (); -extern rtx gen_absxf2 (); -extern rtx gen_sqrtxf2 (); -extern rtx gen_call (); -extern rtx gen_call_value (); -#endif /* NO_MD_PROTOTYPES */ diff --git a/gnu/usr.bin/gcc2/arch/da30/insn-opinit.c b/gnu/usr.bin/gcc2/arch/da30/insn-opinit.c deleted file mode 100644 index 83f29384a2aa..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/insn-opinit.c +++ /dev/null @@ -1,221 +0,0 @@ -/* Generated automatically by the program `genopinit' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "flags.h" -#include "insn-flags.h" -#include "insn-codes.h" -#include "insn-config.h" -#include "recog.h" -#include "expr.h" -#include "reload.h" - -void -init_all_optabs () -{ - tst_optab->handlers[(int) SImode].insn_code = CODE_FOR_tstsi; - tst_optab->handlers[(int) HImode].insn_code = CODE_FOR_tsthi; - tst_optab->handlers[(int) QImode].insn_code = CODE_FOR_tstqi; - if (HAVE_tstsf) - tst_optab->handlers[(int) SFmode].insn_code = CODE_FOR_tstsf; - if (HAVE_tstdf) - tst_optab->handlers[(int) DFmode].insn_code = CODE_FOR_tstdf; - cmp_optab->handlers[(int) SImode].insn_code = CODE_FOR_cmpsi; - cmp_optab->handlers[(int) HImode].insn_code = CODE_FOR_cmphi; - cmp_optab->handlers[(int) QImode].insn_code = CODE_FOR_cmpqi; - if (HAVE_cmpdf) - cmp_optab->handlers[(int) DFmode].insn_code = CODE_FOR_cmpdf; - if (HAVE_cmpsf) - cmp_optab->handlers[(int) SFmode].insn_code = CODE_FOR_cmpsf; - mov_optab->handlers[(int) SImode].insn_code = CODE_FOR_movsi; - mov_optab->handlers[(int) HImode].insn_code = CODE_FOR_movhi; - movstrict_optab->handlers[(int) HImode].insn_code = CODE_FOR_movstricthi; - mov_optab->handlers[(int) QImode].insn_code = CODE_FOR_movqi; - movstrict_optab->handlers[(int) QImode].insn_code = CODE_FOR_movstrictqi; - mov_optab->handlers[(int) SFmode].insn_code = CODE_FOR_movsf; - mov_optab->handlers[(int) DFmode].insn_code = CODE_FOR_movdf; - mov_optab->handlers[(int) XFmode].insn_code = CODE_FOR_movxf; - mov_optab->handlers[(int) DImode].insn_code = CODE_FOR_movdi; - extendtab[(int) SImode][(int) HImode][1] = CODE_FOR_zero_extendhisi2; - extendtab[(int) HImode][(int) QImode][1] = CODE_FOR_zero_extendqihi2; - extendtab[(int) SImode][(int) QImode][1] = CODE_FOR_zero_extendqisi2; - extendtab[(int) SImode][(int) HImode][0] = CODE_FOR_extendhisi2; - extendtab[(int) HImode][(int) QImode][0] = CODE_FOR_extendqihi2; - if (HAVE_extendqisi2) - extendtab[(int) SImode][(int) QImode][0] = CODE_FOR_extendqisi2; - if (HAVE_extendsfdf2) - extendtab[(int) DFmode][(int) SFmode][0] = CODE_FOR_extendsfdf2; - if (HAVE_floatsisf2) - floattab[(int) SFmode][(int) SImode][0] = CODE_FOR_floatsisf2; - if (HAVE_floatsidf2) - floattab[(int) DFmode][(int) SImode][0] = CODE_FOR_floatsidf2; - if (HAVE_floathisf2) - floattab[(int) SFmode][(int) HImode][0] = CODE_FOR_floathisf2; - if (HAVE_floathidf2) - floattab[(int) DFmode][(int) HImode][0] = CODE_FOR_floathidf2; - if (HAVE_floatqisf2) - floattab[(int) SFmode][(int) QImode][0] = CODE_FOR_floatqisf2; - if (HAVE_floatqidf2) - floattab[(int) DFmode][(int) QImode][0] = CODE_FOR_floatqidf2; - if (HAVE_fix_truncdfsi2) - fixtrunctab[(int) DFmode][(int) SImode][0] = CODE_FOR_fix_truncdfsi2; - if (HAVE_fix_truncdfhi2) - fixtrunctab[(int) DFmode][(int) HImode][0] = CODE_FOR_fix_truncdfhi2; - if (HAVE_fix_truncdfqi2) - fixtrunctab[(int) DFmode][(int) QImode][0] = CODE_FOR_fix_truncdfqi2; - if (HAVE_ftruncdf2) - ftrunc_optab->handlers[(int) DFmode].insn_code = CODE_FOR_ftruncdf2; - if (HAVE_ftruncsf2) - ftrunc_optab->handlers[(int) SFmode].insn_code = CODE_FOR_ftruncsf2; - if (HAVE_fixsfqi2) - fixtab[(int) SFmode][(int) QImode][0] = CODE_FOR_fixsfqi2; - if (HAVE_fixsfhi2) - fixtab[(int) SFmode][(int) HImode][0] = CODE_FOR_fixsfhi2; - if (HAVE_fixsfsi2) - fixtab[(int) SFmode][(int) SImode][0] = CODE_FOR_fixsfsi2; - if (HAVE_fixdfqi2) - fixtab[(int) DFmode][(int) QImode][0] = CODE_FOR_fixdfqi2; - if (HAVE_fixdfhi2) - fixtab[(int) DFmode][(int) HImode][0] = CODE_FOR_fixdfhi2; - if (HAVE_fixdfsi2) - fixtab[(int) DFmode][(int) SImode][0] = CODE_FOR_fixdfsi2; - add_optab->handlers[(int) SImode].insn_code = CODE_FOR_addsi3; - add_optab->handlers[(int) HImode].insn_code = CODE_FOR_addhi3; - add_optab->handlers[(int) QImode].insn_code = CODE_FOR_addqi3; - if (HAVE_adddf3) - add_optab->handlers[(int) DFmode].insn_code = CODE_FOR_adddf3; - if (HAVE_addsf3) - add_optab->handlers[(int) SFmode].insn_code = CODE_FOR_addsf3; - sub_optab->handlers[(int) SImode].insn_code = CODE_FOR_subsi3; - sub_optab->handlers[(int) HImode].insn_code = CODE_FOR_subhi3; - sub_optab->handlers[(int) QImode].insn_code = CODE_FOR_subqi3; - if (HAVE_subdf3) - sub_optab->handlers[(int) DFmode].insn_code = CODE_FOR_subdf3; - if (HAVE_subsf3) - sub_optab->handlers[(int) SFmode].insn_code = CODE_FOR_subsf3; - smul_optab->handlers[(int) HImode].insn_code = CODE_FOR_mulhi3; - smul_widen_optab->handlers[(int) SImode].insn_code = CODE_FOR_mulhisi3; - if (HAVE_mulsi3) - smul_optab->handlers[(int) SImode].insn_code = CODE_FOR_mulsi3; - umul_widen_optab->handlers[(int) SImode].insn_code = CODE_FOR_umulhisi3; - if (HAVE_umulsidi3) - umul_widen_optab->handlers[(int) DImode].insn_code = CODE_FOR_umulsidi3; - if (HAVE_mulsidi3) - smul_widen_optab->handlers[(int) DImode].insn_code = CODE_FOR_mulsidi3; - if (HAVE_muldf3) - smul_optab->handlers[(int) DFmode].insn_code = CODE_FOR_muldf3; - if (HAVE_mulsf3) - smul_optab->handlers[(int) SFmode].insn_code = CODE_FOR_mulsf3; - sdiv_optab->handlers[(int) HImode].insn_code = CODE_FOR_divhi3; - udiv_optab->handlers[(int) HImode].insn_code = CODE_FOR_udivhi3; - if (HAVE_divdf3) - flodiv_optab->handlers[(int) DFmode].insn_code = CODE_FOR_divdf3; - if (HAVE_divsf3) - flodiv_optab->handlers[(int) SFmode].insn_code = CODE_FOR_divsf3; - smod_optab->handlers[(int) HImode].insn_code = CODE_FOR_modhi3; - umod_optab->handlers[(int) HImode].insn_code = CODE_FOR_umodhi3; - if (HAVE_divmodsi4) - sdivmod_optab->handlers[(int) SImode].insn_code = CODE_FOR_divmodsi4; - if (HAVE_udivmodsi4) - udivmod_optab->handlers[(int) SImode].insn_code = CODE_FOR_udivmodsi4; - and_optab->handlers[(int) SImode].insn_code = CODE_FOR_andsi3; - and_optab->handlers[(int) HImode].insn_code = CODE_FOR_andhi3; - and_optab->handlers[(int) QImode].insn_code = CODE_FOR_andqi3; - ior_optab->handlers[(int) SImode].insn_code = CODE_FOR_iorsi3; - ior_optab->handlers[(int) HImode].insn_code = CODE_FOR_iorhi3; - ior_optab->handlers[(int) QImode].insn_code = CODE_FOR_iorqi3; - xor_optab->handlers[(int) SImode].insn_code = CODE_FOR_xorsi3; - xor_optab->handlers[(int) HImode].insn_code = CODE_FOR_xorhi3; - xor_optab->handlers[(int) QImode].insn_code = CODE_FOR_xorqi3; - neg_optab->handlers[(int) SImode].insn_code = CODE_FOR_negsi2; - neg_optab->handlers[(int) HImode].insn_code = CODE_FOR_neghi2; - neg_optab->handlers[(int) QImode].insn_code = CODE_FOR_negqi2; - if (HAVE_negsf2) - neg_optab->handlers[(int) SFmode].insn_code = CODE_FOR_negsf2; - if (HAVE_negdf2) - neg_optab->handlers[(int) DFmode].insn_code = CODE_FOR_negdf2; - if (HAVE_sqrtdf2) - sqrt_optab->handlers[(int) DFmode].insn_code = CODE_FOR_sqrtdf2; - if (HAVE_abssf2) - abs_optab->handlers[(int) SFmode].insn_code = CODE_FOR_abssf2; - if (HAVE_absdf2) - abs_optab->handlers[(int) DFmode].insn_code = CODE_FOR_absdf2; - one_cmpl_optab->handlers[(int) SImode].insn_code = CODE_FOR_one_cmplsi2; - one_cmpl_optab->handlers[(int) HImode].insn_code = CODE_FOR_one_cmplhi2; - one_cmpl_optab->handlers[(int) QImode].insn_code = CODE_FOR_one_cmplqi2; - ashl_optab->handlers[(int) SImode].insn_code = CODE_FOR_ashlsi3; - ashl_optab->handlers[(int) HImode].insn_code = CODE_FOR_ashlhi3; - ashl_optab->handlers[(int) QImode].insn_code = CODE_FOR_ashlqi3; - ashr_optab->handlers[(int) SImode].insn_code = CODE_FOR_ashrsi3; - ashr_optab->handlers[(int) HImode].insn_code = CODE_FOR_ashrhi3; - ashr_optab->handlers[(int) QImode].insn_code = CODE_FOR_ashrqi3; - lshl_optab->handlers[(int) SImode].insn_code = CODE_FOR_lshlsi3; - lshl_optab->handlers[(int) HImode].insn_code = CODE_FOR_lshlhi3; - lshl_optab->handlers[(int) QImode].insn_code = CODE_FOR_lshlqi3; - lshr_optab->handlers[(int) SImode].insn_code = CODE_FOR_lshrsi3; - lshr_optab->handlers[(int) HImode].insn_code = CODE_FOR_lshrhi3; - lshr_optab->handlers[(int) QImode].insn_code = CODE_FOR_lshrqi3; - rotl_optab->handlers[(int) SImode].insn_code = CODE_FOR_rotlsi3; - rotl_optab->handlers[(int) HImode].insn_code = CODE_FOR_rotlhi3; - rotl_optab->handlers[(int) QImode].insn_code = CODE_FOR_rotlqi3; - rotr_optab->handlers[(int) SImode].insn_code = CODE_FOR_rotrsi3; - rotr_optab->handlers[(int) HImode].insn_code = CODE_FOR_rotrhi3; - rotr_optab->handlers[(int) QImode].insn_code = CODE_FOR_rotrqi3; - setcc_gen_code[(int) EQ] = CODE_FOR_seq; - setcc_gen_code[(int) NE] = CODE_FOR_sne; - setcc_gen_code[(int) GT] = CODE_FOR_sgt; - setcc_gen_code[(int) GTU] = CODE_FOR_sgtu; - setcc_gen_code[(int) LT] = CODE_FOR_slt; - setcc_gen_code[(int) LTU] = CODE_FOR_sltu; - setcc_gen_code[(int) GE] = CODE_FOR_sge; - setcc_gen_code[(int) GEU] = CODE_FOR_sgeu; - setcc_gen_code[(int) LE] = CODE_FOR_sle; - setcc_gen_code[(int) LEU] = CODE_FOR_sleu; - bcc_gen_fctn[(int) EQ] = gen_beq; - bcc_gen_fctn[(int) NE] = gen_bne; - bcc_gen_fctn[(int) GT] = gen_bgt; - bcc_gen_fctn[(int) GTU] = gen_bgtu; - bcc_gen_fctn[(int) LT] = gen_blt; - bcc_gen_fctn[(int) LTU] = gen_bltu; - bcc_gen_fctn[(int) GE] = gen_bge; - bcc_gen_fctn[(int) GEU] = gen_bgeu; - bcc_gen_fctn[(int) LE] = gen_ble; - bcc_gen_fctn[(int) LEU] = gen_bleu; - if (HAVE_tstxf) - tst_optab->handlers[(int) XFmode].insn_code = CODE_FOR_tstxf; - if (HAVE_cmpxf) - cmp_optab->handlers[(int) XFmode].insn_code = CODE_FOR_cmpxf; - if (HAVE_extendsfxf2) - extendtab[(int) XFmode][(int) SFmode][0] = CODE_FOR_extendsfxf2; - if (HAVE_extenddfxf2) - extendtab[(int) XFmode][(int) DFmode][0] = CODE_FOR_extenddfxf2; - if (HAVE_floatsixf2) - floattab[(int) XFmode][(int) SImode][0] = CODE_FOR_floatsixf2; - if (HAVE_floathixf2) - floattab[(int) XFmode][(int) HImode][0] = CODE_FOR_floathixf2; - if (HAVE_floatqixf2) - floattab[(int) XFmode][(int) QImode][0] = CODE_FOR_floatqixf2; - if (HAVE_ftruncxf2) - ftrunc_optab->handlers[(int) XFmode].insn_code = CODE_FOR_ftruncxf2; - if (HAVE_fixxfqi2) - fixtab[(int) XFmode][(int) QImode][0] = CODE_FOR_fixxfqi2; - if (HAVE_fixxfhi2) - fixtab[(int) XFmode][(int) HImode][0] = CODE_FOR_fixxfhi2; - if (HAVE_fixxfsi2) - fixtab[(int) XFmode][(int) SImode][0] = CODE_FOR_fixxfsi2; - if (HAVE_addxf3) - add_optab->handlers[(int) XFmode].insn_code = CODE_FOR_addxf3; - if (HAVE_subxf3) - sub_optab->handlers[(int) XFmode].insn_code = CODE_FOR_subxf3; - if (HAVE_mulxf3) - smul_optab->handlers[(int) XFmode].insn_code = CODE_FOR_mulxf3; - if (HAVE_divxf3) - flodiv_optab->handlers[(int) XFmode].insn_code = CODE_FOR_divxf3; - if (HAVE_negxf2) - neg_optab->handlers[(int) XFmode].insn_code = CODE_FOR_negxf2; - if (HAVE_absxf2) - abs_optab->handlers[(int) XFmode].insn_code = CODE_FOR_absxf2; - if (HAVE_sqrtxf2) - sqrt_optab->handlers[(int) XFmode].insn_code = CODE_FOR_sqrtxf2; -} diff --git a/gnu/usr.bin/gcc2/arch/da30/insn-output.c b/gnu/usr.bin/gcc2/arch/da30/insn-output.c deleted file mode 100644 index 84070236fff6..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/insn-output.c +++ /dev/null @@ -1,7826 +0,0 @@ -/* Generated automatically by the program `genoutput' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "regs.h" -#include "hard-reg-set.h" -#include "real.h" -#include "insn-config.h" - -#include "conditions.h" -#include "insn-flags.h" -#include "insn-attr.h" - -#include "insn-codes.h" - -#include "recog.h" - -#include -#include "output.h" - -static char * -output_0 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "fmove%.d %f1,%0"; - if (FPA_REG_P (operands[1])) - return "fpmove%.d %1, %x0"; - return output_move_double (operands); -} -} - -static char * -output_1 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return output_move_double (operands); -} -} - -static char * -output_2 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef ISI_OV - /* ISI's assembler fails to handle tstl a0. */ - if (! ADDRESS_REG_P (operands[0])) -#else - if (TARGET_68020 || ! ADDRESS_REG_P (operands[0])) -#endif - return "tst%.l %0"; - /* If you think that the 68020 does not support tstl a0, - reread page B-167 of the 68020 manual more carefully. */ - /* On an address reg, cmpw may replace cmpl. */ -#ifdef SGS_CMP_ORDER - return "cmp%.w %0,%#0"; -#else - return "cmp%.w %#0,%0"; -#endif -} -} - -static char * -output_7 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; - if (FP_REG_P (operands[0])) - return "ftst%.x %0"; - return "ftst%.s %0"; -} -} - -static char * -output_10 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; - if (FP_REG_P (operands[0])) - return "ftst%.x %0"; - return "ftst%.d %0"; -} -} - -static char * -output_11 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return "cmpm%.l %1,%0"; - if (REG_P (operands[1]) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return "cmp%.l %d1,%d0"; -#else - return "cmp%.l %d0,%d1"; -#endif - } -#ifdef SGS_CMP_ORDER - return "cmp%.l %d0,%d1"; -#else - return "cmp%.l %d1,%d0"; -#endif -} -} - -static char * -output_12 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return "cmpm%.w %1,%0"; - if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1])) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return "cmp%.w %d1,%d0"; -#else - return "cmp%.w %d0,%d1"; -#endif - } -#ifdef SGS_CMP_ORDER - return "cmp%.w %d0,%d1"; -#else - return "cmp%.w %d1,%d0"; -#endif -} -} - -static char * -output_13 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return "cmpm%.b %1,%0"; - if (REG_P (operands[1]) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return "cmp%.b %d1,%d0"; -#else - return "cmp%.b %d0,%d1"; -#endif - } -#ifdef SGS_CMP_ORDER - return "cmp%.b %d0,%d1"; -#else - return "cmp%.b %d1,%d0"; -#endif -} -} - -static char * -output_16 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return "fcmp%.x %0,%1"; - else - return "fcmp%.d %0,%f1"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.d %1,%f0"; -#else - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return "fcmp%.x %1,%0"; - else - return "fcmp%.d %f1,%0"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.d %f0,%1"; -#endif -} -} - -static char * -output_19 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fcmp%.x %0,%1"; - else - return "fcmp%.s %0,%f1"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.s %1,%f0"; -#else - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fcmp%.x %1,%0"; - else - return "fcmp%.s %f1,%0"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.s %f0,%1"; -#endif -} -} - -static char * -output_20 (operands, insn) - rtx *operands; - rtx insn; -{ - { return output_btst (operands, operands[1], operands[0], insn, 7); } -} - -static char * -output_21 (operands, insn) - rtx *operands; - rtx insn; -{ - { return output_btst (operands, operands[1], operands[0], insn, 31); } -} - -static char * -output_22 (operands, insn) - rtx *operands; - rtx insn; -{ - { return output_btst (operands, operands[1], operands[0], insn, 7); } -} - -static char * -output_23 (operands, insn) - rtx *operands; - rtx insn; -{ - { return output_btst (operands, operands[1], operands[0], insn, 31); } -} - -static char * -output_24 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[1] = gen_rtx (CONST_INT, VOIDmode, 7 - INTVAL (operands[1])); - return output_btst (operands, operands[1], operands[0], insn, 7); -} -} - -static char * -output_25 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM) - { - operands[0] = adj_offsettable_operand (operands[0], - INTVAL (operands[1]) / 8); - operands[1] = gen_rtx (CONST_INT, VOIDmode, - 7 - INTVAL (operands[1]) % 8); - return output_btst (operands, operands[1], operands[0], insn, 7); - } - operands[1] = gen_rtx (CONST_INT, VOIDmode, - 31 - INTVAL (operands[1])); - return output_btst (operands, operands[1], operands[0], insn, 31); -} -} - -static char * -output_26 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[1] == const0_rtx) - return "clr%.l %0"; - return "pea %a1"; -} -} - -static char * -output_27 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (ADDRESS_REG_P (operands[0])) - return "sub%.l %0,%0"; - /* moveq is faster on the 68000. */ - if (DATA_REG_P (operands[0]) && !TARGET_68020) -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %#0,%0"; -#else - return "moveq %#0,%0"; -#endif - return "clr%.l %0"; -} -} - -static char * -output_29 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (which_alternative == 3) - return "fpmove%.l %x1,fpa0\n\tfpmove%.l fpa0,%x0"; - if (FPA_REG_P (operands[1]) || FPA_REG_P (operands[0])) - return "fpmove%.l %x1,%x0"; - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return "clr%.l %0"; - else if (DATA_REG_P (operands[0]) - && INTVAL (operands[1]) < 128 - && INTVAL (operands[1]) >= -128) - { -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %1,%0"; -#else - return "moveq %1,%0"; -#endif - } -#ifndef NO_ADDSUB_Q - else if (DATA_REG_P (operands[0]) - /* Do this with a moveq #N-8, dreg; addq #8,dreg */ - && INTVAL (operands[1]) < 136 - && INTVAL (operands[1]) >= 128) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %1,%0\n\taddq%.w %#8,%0"; -#else - return "moveq %1,%0\n\taddq%.w %#8,%0"; -#endif - } - else if (DATA_REG_P (operands[0]) - /* Do this with a moveq #N+8, dreg; subq #8,dreg */ - && INTVAL (operands[1]) < -128 - && INTVAL (operands[1]) >= -136) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) + 8); -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %1,%0;subq%.w %#8,%0"; -#else - return "moveq %1,%0;subq%.w %#8,%0"; -#endif - } -#endif - else if (DATA_REG_P (operands[0]) - /* If N is in the right range and is even, then use - moveq #N/2, dreg; addl dreg,dreg */ - && INTVAL (operands[1]) > 127 - && INTVAL (operands[1]) <= 254 - && INTVAL (operands[1]) % 2 == 0) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) / 2); -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %1,%0\n\tadd%.w %0,%0"; -#else - return "moveq %1,%0\n\tadd%.w %0,%0"; -#endif - } - else if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return "move%.w %1,%0"; - else if (push_operand (operands[0], SImode) - && INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return "pea %a1"; - } - else if ((GET_CODE (operands[1]) == SYMBOL_REF - || GET_CODE (operands[1]) == CONST) - && push_operand (operands[0], SImode)) - return "pea %a1"; - else if ((GET_CODE (operands[1]) == SYMBOL_REF - || GET_CODE (operands[1]) == CONST) - && ADDRESS_REG_P (operands[0])) - return "lea %a1,%0"; - return "move%.l %1,%0"; -} -} - -static char * -output_30 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return "clr%.w %0"; - else if (DATA_REG_P (operands[0]) - && INTVAL (operands[1]) < 128 - && INTVAL (operands[1]) >= -128) - { -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %1,%0"; -#else - return "moveq %1,%0"; -#endif - } - else if (INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return "move%.w %1,%0"; - } - else if (CONSTANT_P (operands[1])) - return "move%.l %1,%0"; -#ifndef SGS_NO_LI - /* Recognize the insn before a tablejump, one that refers - to a table of offsets. Such an insn will need to refer - to a label on the insn. So output one. Use the label-number - of the table of offsets to generate this label. */ - if (GET_CODE (operands[1]) == MEM - && GET_CODE (XEXP (operands[1], 0)) == PLUS - && (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF - || GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == LABEL_REF) - && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) != PLUS - && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) != PLUS) - { - rtx labelref; - if (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF) - labelref = XEXP (XEXP (operands[1], 0), 0); - else - labelref = XEXP (XEXP (operands[1], 0), 1); -#if defined (MOTOROLA) && !defined (SGS_SWITCH_TABLES) -#ifdef SGS - asm_fprintf (asm_out_file, "\tset %LLI%d,.+2\n", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#else /* not SGS */ - asm_fprintf (asm_out_file, "\t.set %LLI%d,.+2\n", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#endif /* not SGS */ -#else /* SGS_SWITCH_TABLES or not MOTOROLA */ - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LI", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#ifdef SGS_SWITCH_TABLES - /* Set flag saying we need to define the symbol - LD%n (with value L%n-LI%n) at the end of the switch table. */ - switch_table_difference_label_flag = 1; -#endif /* SGS_SWITCH_TABLES */ -#endif /* SGS_SWITCH_TABLES or not MOTOROLA */ - } -#endif /* SGS_NO_LI */ - return "move%.w %1,%0"; -} -} - -static char * -output_31 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return "clr%.w %0"; - } - return "move%.w %1,%0"; -} -} - -static char * -output_32 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xoperands[4]; - - /* This is probably useless, since it loses for pushing a struct - of several bytes a byte at a time. */ - if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC - && XEXP (XEXP (operands[0], 0), 0) == stack_pointer_rtx) - { - xoperands[1] = operands[1]; - xoperands[2] - = gen_rtx (MEM, QImode, - gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, const1_rtx)); - /* Just pushing a byte puts it in the high byte of the halfword. */ - /* We must put it in the low-order, high-numbered byte. */ - output_asm_insn ("move%.b %1,%-\n\tmove%.b %@,%2", xoperands); - return ""; - } - - /* Moving a byte into an address register is not possible. */ - /* Use d0 as an intermediate, but don't clobber its contents. */ - if (ADDRESS_REG_P (operands[0]) && GET_CODE (operands[1]) == MEM) - { - /* ??? For 2.5, don't allow this choice and use secondary reloads - instead. - - See if the address register is used in the address. If it - is, we have to generate a more complex sequence than those below. */ - if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1, - operands[1], NULL_RTX)) - { - /* See if the stack pointer is used in the address. If it isn't, - we can push d0 or d1 (the insn can't use both of them) on - the stack, perform our move into d0/d1, copy the byte from d0/1, - and pop d0/1. */ - if (! reg_mentioned_p (stack_pointer_rtx, operands[1])) - { - if (refers_to_regno_p (0, 1, operands[1], NULL_RTX)) - return "move%.l %/d0,%-\n\tmove%.b %1,%/d0\n\tmove%.l %/d0,%0\n\tmove%.l %+,%/d0"; - else - return "move%.l %/d1,%-\n\tmove%.b %1,%/d1\n\tmove%.l %/d1,%0\n\tmove%.l %+,%/d1"; - } - else - { - /* Otherwise, we know that d0 cannot be used in the address - (since sp and one address register is). Assume that sp is - being used as a base register and replace the address - register that is our operand[0] with d0. */ - rtx reg_map[FIRST_PSEUDO_REGISTER]; - int i; - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - reg_map[i] = 0; - - reg_map[REGNO (operands[0])] = gen_rtx (REG, Pmode, 0); - operands[1] = copy_rtx (operands[1]); - replace_regs (operands[1], reg_map, FIRST_PSEUDO_REGISTER, 0); - return "exg %/d0,%0\n\tmove%.b %1,%/d0\n\texg %/d0,%0"; - } - } - - /* If the address of operand 1 uses d0, choose d1 as intermediate. */ - if (refers_to_regno_p (0, 1, operands[1], NULL_RTX)) - return "exg %/d1,%0\n\tmove%.b %1,%/d1\n\texg %/d1,%0"; - /* Otherwise d0 is usable. - (An effective address on the 68k can't use two d-regs.) */ - else - return "exg %/d0,%0\n\tmove%.b %1,%/d0\n\texg %/d0,%0"; - } - - /* Likewise for moving from an address reg. */ - if (ADDRESS_REG_P (operands[1]) && GET_CODE (operands[0]) == MEM) - { - /* ??? For 2.5, don't allow this choice and use secondary reloads - instead. - - See if the address register is used in the address. If it - is, we have to generate a more complex sequence than those below. */ - if (refers_to_regno_p (REGNO (operands[1]), REGNO (operands[1]) + 1, - operands[0], NULL_RTX)) - { - /* See if the stack pointer is used in the address. If it isn't, - we can push d0 or d1 (the insn can't use both of them) on - the stack, copy the byte to d0/1, perform our move from d0/d1, - and pop d0/1. */ - if (! reg_mentioned_p (stack_pointer_rtx, operands[0])) - { - if (refers_to_regno_p (0, 1, operands[0], NULL_RTX)) - return "move%.l %/d0,%-\n\tmove%.l %1,%/d0\n\tmove%.b %/d0,%0\n\tmove%.l %+,%/d0"; - else - return "move%.l %/d1,%-\n\tmove%.l %1,%/d1\n\tmove%.b %/d1,%0\n\tmove%.l %+,%/d1"; - } - else - { - /* Otherwise, we know that d0 cannot be used in the address - (since sp and one address register is). Assume that sp is - being used as a base register and replace the address - register that is our operand[1] with d0. */ - rtx reg_map[FIRST_PSEUDO_REGISTER]; - int i; - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - reg_map[i] = 0; - - reg_map[REGNO (operands[1])] = gen_rtx (REG, Pmode, 0); - operands[0] = copy_rtx (operands[0]); - replace_regs (operands[0], reg_map, FIRST_PSEUDO_REGISTER, 0); - return "exg %/d0,%1\n\tmove%.b %/d0,%0\n\texg %/d0,%1"; - } - } - - if (refers_to_regno_p (0, 1, operands[0], NULL_RTX)) - return "exg %/d1,%1\n\tmove%.b %/d1,%0\n\texg %/d1,%1"; - else - return "exg %/d0,%1\n\tmove%.b %/d0,%0\n\texg %/d0,%1"; - } - - /* clr and st insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - if (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - if (operands[1] == const0_rtx) - return "clr%.b %0"; - if (GET_CODE (operands[1]) == CONST_INT - && INTVAL (operands[1]) == -1) - { - CC_STATUS_INIT; - return "st %0"; - } - } - if (GET_CODE (operands[1]) != CONST_INT && CONSTANT_P (operands[1])) - return "move%.l %1,%0"; - if (ADDRESS_REG_P (operands[0]) || ADDRESS_REG_P (operands[1])) - return "move%.w %1,%0"; - return "move%.b %1,%0"; -} -} - -static char * -output_33 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[1] == const0_rtx - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))) - return "clr%.b %0"; - return "move%.b %1,%0"; -} -} - -static char * -output_34 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (which_alternative >= 4) - return "fpmove%.s %1,fpa0\n\tfpmove%.s fpa0,%0"; - if (FPA_REG_P (operands[0])) - { - if (FPA_REG_P (operands[1])) - return "fpmove%.s %x1,%x0"; - else if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_single (operands); - else if (FP_REG_P (operands[1])) - return "fmove%.s %1,sp@-\n\tfpmove%.d sp@+, %0"; - return "fpmove%.s %x1,%x0"; - } - if (FPA_REG_P (operands[1])) - { - if (FP_REG_P (operands[0])) - return "fpmove%.s %x1,sp@-\n\tfmove%.s sp@+,%0"; - else - return "fpmove%.s %x1,%x0"; - } - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "f%$move%.x %1,%0"; - else if (ADDRESS_REG_P (operands[1])) - return "move%.l %1,%-\n\tf%$move%.s %+,%0"; - else if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_single (operands); - return "f%$move%.s %f1,%0"; - } - if (FP_REG_P (operands[1])) - { - if (ADDRESS_REG_P (operands[0])) - return "fmove%.s %1,%-\n\tmove%.l %+,%0"; - return "fmove%.s %f1,%0"; - } - return "move%.l %1,%0"; -} -} - -static char * -output_35 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (which_alternative == 6) - return "fpmove%.d %x1,fpa0\n\tfpmove%.d fpa0,%x0"; - if (FPA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - if (FP_REG_P (operands[1])) - return "fmove%.d %1,sp@-\n\tfpmove%.d sp@+,%x0"; - return "fpmove%.d %x1,%x0"; - } - else if (FPA_REG_P (operands[1])) - { - if (FP_REG_P(operands[0])) - return "fpmove%.d %x1,sp@-\n\tfmoved sp@+,%0"; - else - return "fpmove%.d %x1,%x0"; - } - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "f%&move%.x %1,%0"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn ("move%.l %1,%-", xoperands); - output_asm_insn ("move%.l %1,%-", operands); - return "f%&move%.d %+,%0"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - return "f%&move%.d %f1,%0"; - } - else if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn ("fmove%.d %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - else - return "fmove%.d %f1,%0"; - } - return output_move_double (operands); -} - -} - -static char * -output_37 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fmove%.x %1,%0"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2); - output_asm_insn ("move%.l %1,%-", xoperands); - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn ("move%.l %1,%-", xoperands); - output_asm_insn ("move%.l %1,%-", operands); - return "fmove%.x %+,%0"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return "fmove%.x %1,%0"; - return "fmove%.x %f1,%0"; - } - if (REG_P (operands[0])) - { - output_asm_insn ("fmove%.x %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - output_asm_insn ("move%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - return "fmove%.x %f1,%0"; -} - -} - -static char * -output_38 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fmove%.x %1,%0"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2); - output_asm_insn ("move%.l %1,%-", xoperands); - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn ("move%.l %1,%-", xoperands); - output_asm_insn ("move%.l %1,%-", operands); - return "fmove%.x %+,%0"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return "fmove%.x %1,%0"; - return "fmove%.x %f1,%0"; - } - if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn ("fmove%.x %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - output_asm_insn ("move%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - else - return "fmove%.x %f1,%0"; - } - return output_move_double (operands); -} - -} - -static char * -output_39 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (which_alternative == 8) - return "fpmove%.d %x1,fpa0\n\tfpmove%.d fpa0,%x0"; - if (FPA_REG_P (operands[0]) || FPA_REG_P (operands[1])) - return "fpmove%.d %x1,%x0"; - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fmove%.x %1,%0"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn ("move%.l %1,%-", xoperands); - output_asm_insn ("move%.l %1,%-", operands); - return "fmove%.d %+,%0"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - return "fmove%.d %f1,%0"; - } - else if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn ("fmove%.d %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - else - return "fmove%.d %f1,%0"; - } - return output_move_double (operands); -} - -} - -static char * -output_41 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return "move%.l %1,%0"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 3); - return "move%.b %1,%0"; -} -} - -static char * -output_42 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == REG - && (GET_CODE (operands[1]) == MEM - || GET_CODE (operands[1]) == CONST_INT)) - { - /* Must clear condition codes, since the move.w bases them on - the entire 16 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return "move%.w %1,%0"; - } - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return "move%.l %1,%0"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 1); - return "move%.b %1,%0"; -} -} - -static char * -output_43 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return "move%.l %1,%0"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 2); - return "move%.w %1,%0"; -} -} - -static char * -output_47 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return "and%.l %#0xFFFF,%0"; - if (reg_mentioned_p (operands[0], operands[1])) - return "move%.w %1,%0\n\tand%.l %#0xFFFF,%0"; - return "clr%.l %0\n\tmove%.w %1,%0"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - return "move%.w %1,%0\n\tclr%.w %0"; - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - return "clr%.w %0\n\tmove%.w %1,%0"; - else - { - output_asm_insn ("clr%.w %0", operands); - operands[0] = adj_offsettable_operand (operands[0], 2); - return "move%.w %1,%0"; - } -} -} - -static char * -output_48 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return "and%.w %#0xFF,%0"; - if (reg_mentioned_p (operands[0], operands[1])) - return "move%.b %1,%0\n\tand%.w %#0xFF,%0"; - return "clr%.w %0\n\tmove%.b %1,%0"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - { - if (REGNO (XEXP (XEXP (operands[0], 0), 0)) - == STACK_POINTER_REGNUM) - { - output_asm_insn ("clr%.w %-", operands); - operands[0] = gen_rtx (MEM, GET_MODE (operands[0]), - plus_constant (stack_pointer_rtx, 1)); - return "move%.b %1,%0"; - } - else - return "move%.b %1,%0\n\tclr%.b %0"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - return "clr%.b %0\n\tmove%.b %1,%0"; - else - { - output_asm_insn ("clr%.b %0", operands); - operands[0] = adj_offsettable_operand (operands[0], 1); - return "move%.b %1,%0"; - } -} -} - -static char * -output_49 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return "and%.l %#0xFF,%0"; - if (reg_mentioned_p (operands[0], operands[1])) - return "move%.b %1,%0\n\tand%.l %#0xFF,%0"; - return "clr%.l %0\n\tmove%.b %1,%0"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - { - operands[0] = XEXP (XEXP (operands[0], 0), 0); -#ifdef MOTOROLA -#ifdef SGS - return "clr%.l -(%0)\n\tmove%.b %1,3(%0)"; -#else - return "clr%.l -(%0)\n\tmove%.b %1,(3,%0)"; -#endif -#else - return "clrl %0@-\n\tmoveb %1,%0@(3)"; -#endif - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - { - operands[0] = XEXP (XEXP (operands[0], 0), 0); -#ifdef MOTOROLA -#ifdef SGS - return "clr%.l (%0)+\n\tmove%.b %1,-1(%0)"; -#else - return "clr%.l (%0)+\n\tmove%.b %1,(-1,%0)"; -#endif -#else - return "clrl %0@+\n\tmoveb %1,%0@(-1)"; -#endif - } - else - { - output_asm_insn ("clr%.l %0", operands); - operands[0] = adj_offsettable_operand (operands[0], 3); - return "move%.b %1,%0"; - } -} -} - -static char * -output_50 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (ADDRESS_REG_P (operands[0])) - return "move%.w %1,%0"; - return "ext%.l %0"; -} -} - -static char * -output_55 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return ""; - } - return "f%&move%.x %1,%0"; - } - if (FP_REG_P (operands[0])) - return "f%&move%.s %f1,%0"; - if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - output_asm_insn ("fmove%.d %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - return "fmove%.d %f1,%0"; -} -} - -static char * -output_58 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "f%$move%.x %1,%0"; - return "f%$move%.d %f1,%0"; -} -} - -static char * -output_70 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "fmovem%.l %!,%2\n\tmoveq %#16,%3\n\tor%.l %2,%3\n\tand%.w %#-33,%3\n\tfmovem%.l %3,%!\n\tfmove%.l %1,%0\n\tfmovem%.l %2,%!"; -} -} - -static char * -output_71 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "fmovem%.l %!,%2\n\tmoveq %#16,%3\n\tor%.l %2,%3\n\tand%.w %#-33,%3\n\tfmovem%.l %3,%!\n\tfmove%.w %1,%0\n\tfmovem%.l %2,%!"; -} -} - -static char * -output_72 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "fmovem%.l %!,%2\n\tmoveq %#16,%3\n\tor%.l %2,%3\n\tand%.w %#-33,%3\n\tfmovem%.l %3,%!\n\tfmove%.b %1,%0\n\tfmovem%.l %2,%!"; -} -} - -static char * -output_73 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "fintrz%.x %f1,%0"; - return "fintrz%.d %f1,%0"; -} -} - -static char * -output_74 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "fintrz%.x %f1,%0"; - return "fintrz%.s %f1,%0"; -} -} - -static char * -output_83 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (! operands_match_p (operands[0], operands[1])) - { - if (!ADDRESS_REG_P (operands[1])) - { - rtx tmp = operands[1]; - - operands[1] = operands[2]; - operands[2] = tmp; - } - - /* These insns can result from reloads to access - stack slots over 64k from the frame pointer. */ - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) + 0x8000 >= (unsigned) 0x10000) - return "move%.l %2,%0\n\tadd%.l %1,%0"; -#ifdef SGS - if (GET_CODE (operands[2]) == REG) - return "lea 0(%1,%2.l),%0"; - else - return "lea %c2(%1),%0"; -#else /* not SGS */ -#ifdef MOTOROLA - if (GET_CODE (operands[2]) == REG) - return "lea (%1,%2.l),%0"; - else - return "lea (%c2,%1),%0"; -#else /* not MOTOROLA (MIT syntax) */ - if (GET_CODE (operands[2]) == REG) - return "lea %1@(0,%2:l),%0"; - else - return "lea %1@(%c2),%0"; -#endif /* not MOTOROLA */ -#endif /* not SGS */ - } - if (GET_CODE (operands[2]) == CONST_INT) - { -#ifndef NO_ADDSUB_Q - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return (ADDRESS_REG_P (operands[0]) - ? "addq%.w %2,%0" - : "addq%.l %2,%0"); - if (INTVAL (operands[2]) < 0 - && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2])); - return (ADDRESS_REG_P (operands[0]) - ? "subq%.w %2,%0" - : "subq%.l %2,%0"); - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw.*/ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return "addq%.w %#8,%0\n\taddq%.w %2,%0"; - } - if (INTVAL (operands[2]) < -8 - && INTVAL (operands[2]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2]) - 8); - return "subq%.w %#8,%0\n\tsubq%.w %2,%0"; - } -#endif - if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[2]) >= -0x8000 - && INTVAL (operands[2]) < 0x8000) - return "add%.w %2,%0"; - } - return "add%.l %2,%0"; -} -} - -static char * -output_85 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[2]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[2]) >= 32768) - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) - 65536); - - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return "addq%.w %2,%0"; - if (INTVAL (operands[2]) < 0 - && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2])); - return "subq%.w %2,%0"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return "addq%.w %#8,%0\n\taddq%.w %2,%0"; - } - if (INTVAL (operands[2]) < -8 - && INTVAL (operands[2]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2]) - 8); - return "subq%.w %#8,%0\n\tsubq%.w %2,%0"; - } - } -#endif - return "add%.w %2,%0"; -} -} - -static char * -output_86 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[1]) >= 32768) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 65536); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return "addq%.w %1,%0"; - if (INTVAL (operands[1]) < 0 - && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1])); - return "subq%.w %1,%0"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[1]) > 8 - && INTVAL (operands[1]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); - return "addq%.w %#8,%0\n\taddq%.w %1,%0"; - } - if (INTVAL (operands[1]) < -8 - && INTVAL (operands[1]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1]) - 8); - return "subq%.w %#8,%0\n\tsubq%.w %1,%0"; - } - } -#endif - return "add%.w %1,%0"; -} -} - -static char * -output_87 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[1]) >= 32768) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 65536); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return "addq%.w %1,%0"; - if (INTVAL (operands[1]) < 0 - && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1])); - return "subq%.w %1,%0"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[1]) > 8 - && INTVAL (operands[1]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); - return "addq%.w %#8,%0\n\taddq%.w %1,%0"; - } - if (INTVAL (operands[1]) < -8 - && INTVAL (operands[1]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1]) - 8); - return "subq%.w %#8,%0\n\tsubq%.w %1,%0"; - } - } -#endif - return "add%.w %1,%0"; -} -} - -static char * -output_88 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[2]) == CONST_INT) - { - if (INTVAL (operands[2]) >= 128) - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) - 256); - - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return "addq%.b %2,%0"; - if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2])); - return "subq%.b %2,%0"; - } - } -#endif - return "add%.b %2,%0"; -} -} - -static char * -output_89 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) >= 128) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 256); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return "addq%.b %1,%0"; - if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1])); - return "subq%.b %1,%0"; - } - } -#endif - return "add%.b %1,%0"; -} -} - -static char * -output_90 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) >= 128) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 256); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return "addq%.b %1,%0"; - if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1])); - return "subq%.b %1,%0"; - } - } -#endif - return "add%.b %1,%0"; -} -} - -static char * -output_92 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[1])) - return "fpadd%.d %y2,%0"; - if (rtx_equal_p (operands[0], operands[2])) - return "fpadd%.d %y1,%0"; - if (which_alternative == 0) - return "fpadd3%.d %w2,%w1,%0"; - return "fpadd3%.d %x2,%x1,%0"; -} -} - -static char * -output_93 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "f%&add%.x %2,%0"; - return "f%&add%.d %f2,%0"; -} -} - -static char * -output_95 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[1])) - return "fpadd%.s %w2,%0"; - if (rtx_equal_p (operands[0], operands[2])) - return "fpadd%.s %w1,%0"; - if (which_alternative == 0) - return "fpadd3%.s %w2,%w1,%0"; - return "fpadd3%.s %2,%1,%0"; -} -} - -static char * -output_96 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return "f%$add%.x %2,%0"; - return "f%$add%.s %f2,%0"; -} -} - -static char * -output_97 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (! operands_match_p (operands[0], operands[1])) - { - if (operands_match_p (operands[0], operands[2])) - { -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return "subq%.l %1,%0\n\tneg%.l %0"; - } -#endif - return "sub%.l %1,%0\n\tneg%.l %0"; - } - /* This case is matched by J, but negating -0x8000 - in an lea would give an invalid displacement. - So do this specially. */ - if (INTVAL (operands[2]) == -0x8000) - return "move%.l %1,%0\n\tsub%.l %2,%0"; -#ifdef SGS - return "lea %n2(%1),%0"; -#else -#ifdef MOTOROLA - return "lea (%n2,%1),%0"; -#else /* not MOTOROLA (MIT syntax) */ - return "lea %1@(%n2),%0"; -#endif /* not MOTOROLA */ -#endif /* not SGS */ - } - if (GET_CODE (operands[2]) == CONST_INT) - { -#ifndef NO_ADDSUB_Q - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return "subq%.l %2,%0"; - /* Using two subqw for 8 < N <= 16 being subtracted from an - address register is faster on all but 68000 */ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return "subq%.w %#8,%0\n\tsubq%.w %2,%0"; - } -#endif - if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[2]) >= -0x8000 - && INTVAL (operands[2]) < 0x8000) - return "sub%.w %2,%0"; - } - return "sub%.l %2,%0"; -} -} - -static char * -output_104 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[2])) - return "fprsub%.d %y1,%0"; - if (rtx_equal_p (operands[0], operands[1])) - return "fpsub%.d %y2,%0"; - if (which_alternative == 0) - return "fpsub3%.d %w2,%w1,%0"; - return "fpsub3%.d %x2,%x1,%0"; -} -} - -static char * -output_105 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "f%&sub%.x %2,%0"; - return "f%&sub%.d %f2,%0"; -} -} - -static char * -output_107 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[2])) - return "fprsub%.s %w1,%0"; - if (rtx_equal_p (operands[0], operands[1])) - return "fpsub%.s %w2,%0"; - if (which_alternative == 0) - return "fpsub3%.s %w2,%w1,%0"; - return "fpsub3%.s %2,%1,%0"; -} -} - -static char * -output_108 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return "f%$sub%.x %2,%0"; - return "f%$sub%.s %f2,%0"; -} -} - -static char * -output_109 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if defined(MOTOROLA) && !defined(CRDS) - return "muls%.w %2,%0"; -#else - return "muls %2,%0"; -#endif -} -} - -static char * -output_110 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if defined(MOTOROLA) && !defined(CRDS) - return "muls%.w %2,%0"; -#else - return "muls %2,%0"; -#endif -} -} - -static char * -output_111 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if defined(MOTOROLA) && !defined(CRDS) - return "muls%.w %2,%0"; -#else - return "muls %2,%0"; -#endif -} -} - -static char * -output_113 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if defined(MOTOROLA) && !defined(CRDS) - return "mulu%.w %2,%0"; -#else - return "mulu %2,%0"; -#endif -} -} - -static char * -output_114 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if defined(MOTOROLA) && !defined(CRDS) - return "mulu%.w %2,%0"; -#else - return "mulu %2,%0"; -#endif -} -} - -static char * -output_122 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[1], operands[2])) - return "fpsqr%.d %y1,%0"; - if (rtx_equal_p (operands[0], operands[1])) - return "fpmul%.d %y2,%0"; - if (rtx_equal_p (operands[0], operands[2])) - return "fpmul%.d %y1,%0"; - if (which_alternative == 0) - return "fpmul3%.d %w2,%w1,%0"; - return "fpmul3%.d %x2,%x1,%0"; -} -} - -static char * -output_123 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_DOUBLE - && floating_exact_log2 (operands[2]) && !TARGET_68040) - { - int i = floating_exact_log2 (operands[2]); - operands[2] = gen_rtx (CONST_INT, VOIDmode, i); - return "fscale%.l %2,%0"; - } - if (REG_P (operands[2])) - return "f%&mul%.x %2,%0"; - return "f%&mul%.d %f2,%0"; -} -} - -static char * -output_125 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[1], operands[2])) - return "fpsqr%.s %w1,%0"; - if (rtx_equal_p (operands[0], operands[1])) - return "fpmul%.s %w2,%0"; - if (rtx_equal_p (operands[0], operands[2])) - return "fpmul%.s %w1,%0"; - if (which_alternative == 0) - return "fpmul3%.s %w2,%w1,%0"; - return "fpmul3%.s %2,%1,%0"; -} -} - -static char * -output_126 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef FSGLMUL_USE_S - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? "fsmul%.s %2,%0" - : "fsglmul%.s %2,%0"); -#else - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? "fsmul%.x %2,%0" - : "fsglmul%.x %2,%0"); -#endif - return (TARGET_68040_ONLY - ? "fsmul%.s %f2,%0" - : "fsglmul%.s %f2,%0"); -} -} - -static char * -output_127 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "ext%.l %0\n\tdivs%.w %2,%0"; -#else - return "extl %0\n\tdivs %2,%0"; -#endif -} -} - -static char * -output_128 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "divs%.w %2,%0"; -#else - return "divs %2,%0"; -#endif -} -} - -static char * -output_129 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "divs%.w %2,%0"; -#else - return "divs %2,%0"; -#endif -} -} - -static char * -output_130 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "and%.l %#0xFFFF,%0\n\tdivu%.w %2,%0"; -#else - return "andl %#0xFFFF,%0\n\tdivu %2,%0"; -#endif -} -} - -static char * -output_131 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "divu%.w %2,%0"; -#else - return "divu %2,%0"; -#endif -} -} - -static char * -output_132 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "divu%.w %2,%0"; -#else - return "divu %2,%0"; -#endif -} -} - -static char * -output_134 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[2])) - return "fprdiv%.d %y1,%0"; - if (rtx_equal_p (operands[0], operands[1])) - return "fpdiv%.d %y2,%0"; - if (which_alternative == 0) - return "fpdiv3%.d %w2,%w1,%0"; - return "fpdiv3%.d %x2,%x1,%x0"; -} -} - -static char * -output_135 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "f%&div%.x %2,%0"; - return "f%&div%.d %f2,%0"; -} -} - -static char * -output_137 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[1])) - return "fpdiv%.s %w2,%0"; - if (rtx_equal_p (operands[0], operands[2])) - return "fprdiv%.s %w1,%0"; - if (which_alternative == 0) - return "fpdiv3%.s %w2,%w1,%0"; - return "fpdiv3%.s %2,%1,%0"; -} -} - -static char * -output_138 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef FSGLDIV_USE_S - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? "fsdiv%.s %2,%0" - : "fsgldiv%.s %2,%0"); -#else - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? "fsdiv%.x %2,%0" - : "fsgldiv%.x %2,%0"); -#endif - return (TARGET_68040_ONLY - ? "fsdiv%.s %f2,%0" - : "fsgldiv%.s %f2,%0"); -} -} - -static char * -output_139 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "ext%.l %0\n\tdivs%.w %2,%0\n\tswap %0"; -#else - return "extl %0\n\tdivs %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_140 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "divs%.w %2,%0\n\tswap %0"; -#else - return "divs %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_141 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "divs%.w %2,%0\n\tswap %0"; -#else - return "divs %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_142 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "and%.l %#0xFFFF,%0\n\tdivu%.w %2,%0\n\tswap %0"; -#else - return "andl %#0xFFFF,%0\n\tdivu %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_143 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "divu%.w %2,%0\n\tswap %0"; -#else - return "divu %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_144 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "divu%.w %2,%0\n\tswap %0"; -#else - return "divu %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_145 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (find_reg_note (insn, REG_UNUSED, operands[3])) - return "divs%.l %2,%0"; - else - return "divsl%.l %2,%3:%0"; -} -} - -static char * -output_146 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (find_reg_note (insn, REG_UNUSED, operands[3])) - return "divu%.l %2,%0"; - else - return "divul%.l %2,%3:%0"; -} -} - -static char * -output_147 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - int logval; - if (GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) | 0xffff) == 0xffffffff - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (GET_CODE (operands[0]) != REG) - operands[0] = adj_offsettable_operand (operands[0], 2); - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) & 0xffff); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - if (operands[2] == const0_rtx) - return "clr%.w %0"; - return "and%.w %2,%0"; - } - if (GET_CODE (operands[2]) == CONST_INT - && (logval = exact_log2 (~ INTVAL (operands[2]))) >= 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval); - } - else - { - operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8)); operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8); - } - /* This does not set condition codes in a standard way. */ - CC_STATUS_INIT; - return "bclr %1,%0"; - } - return "and%.l %2,%0"; -} -} - -static char * -output_154 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - register int logval; - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) >> 16 == 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (GET_CODE (operands[0]) != REG) - operands[0] = adj_offsettable_operand (operands[0], 2); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - return "or%.w %2,%0"; - } - if (GET_CODE (operands[2]) == CONST_INT - && (logval = exact_log2 (INTVAL (operands[2]))) >= 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval); - } - else - { - operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8)); - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8); - } - CC_STATUS_INIT; - return "bset %1,%0"; - } - return "or%.l %2,%0"; -} -} - -static char * -output_161 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) >> 16 == 0 - && (offsettable_memref_p (operands[0]) || DATA_REG_P (operands[0]))) - { - if (! DATA_REG_P (operands[0])) - operands[0] = adj_offsettable_operand (operands[0], 2); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - return "eor%.w %2,%0"; - } - return "eor%.l %2,%0"; -} -} - -static char * -output_175 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, 31); - return "bchg %1,%0"; - } - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "f%$neg%.x %1,%0"; - return "f%$neg%.s %f1,%0"; -} -} - -static char * -output_178 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, 31); - return "bchg %1,%0"; - } - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "f%&neg%.x %1,%0"; - return "f%&neg%.d %f1,%0"; -} -} - -static char * -output_179 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "fsqrt%.x %1,%0"; - else - return "fsqrt%.d %1,%0"; -} -} - -static char * -output_182 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "f%$abs%.x %1,%0"; - return "f%$abs%.s %f1,%0"; -} -} - -static char * -output_185 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "f%&abs%.x %1,%0"; - return "f%&abs%.d %f1,%0"; -} -} - -static char * -output_191 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "swap %0\n\tclr%.w %0"; -} -} - -static char * -output_192 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return "asl%.w %2,%0\n\tswap %0\n\tclr%.w %0"; -} -} - -static char * -output_193 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[2] == const1_rtx) - return "add%.l %0,%0"; - return "asl%.l %2,%0"; -} -} - -static char * -output_199 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return "swap %0\n\tasr%.w %2,%0\n\text%.l %0"; -} -} - -static char * -output_200 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return "asr%.l %2,%0"; -} -} - -static char * -output_205 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "swap %0\n\tclr%.w %0"; -} -} - -static char * -output_206 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return "lsl%.w %2,%0\n\tswap %0\n\tclr%.w %0"; -} -} - -static char * -output_207 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[2] == const1_rtx) - return "add%.l %0,%0"; - return "lsl%.l %2,%0"; -} -} - -static char * -output_212 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "clr%.w %0\n\tswap %0"; -} -} - -static char * -output_213 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* I think lsr%.w sets the CC properly. */ - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return "clr%.w %0\n\tswap %0\n\tlsr%.w %2,%0"; -} -} - -static char * -output_214 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return "lsr%.l %2,%0"; -} -} - -static char * -output_229 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[0] - = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8); - - return "move%.l %3,%0"; -} -} - -static char * -output_230 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0])) - { - if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32) - return "bfins %3,%0{%b2:%b1}"; - } - else - operands[0] - = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8); - - if (GET_CODE (operands[3]) == MEM) - operands[3] = adj_offsettable_operand (operands[3], - (32 - INTVAL (operands[1])) / 8); - if (INTVAL (operands[1]) == 8) - return "move%.b %3,%0"; - return "move%.w %3,%0"; -} -} - -static char * -output_231 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - return "move%.l %1,%0"; -} -} - -static char * -output_232 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags |= CC_NOT_NEGATIVE; - if (REG_P (operands[1])) - { - if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32) - return "bfextu %1{%b3:%b2},%0"; - } - else - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - output_asm_insn ("clr%.l %0", operands); - if (GET_CODE (operands[0]) == MEM) - operands[0] = adj_offsettable_operand (operands[0], - (32 - INTVAL (operands[1])) / 8); - if (INTVAL (operands[2]) == 8) - return "move%.b %1,%0"; - return "move%.w %1,%0"; -} -} - -static char * -output_233 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - return "move%.l %1,%0"; -} -} - -static char * -output_234 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[1])) - { - if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32) - return "bfexts %1{%b3:%b2},%0"; - } - else - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - if (INTVAL (operands[2]) == 8) - return "move%.b %1,%0\n\textb%.l %0"; - return "move%.w %1,%0\n\text%.l %0"; -} -} - -static char * -output_236 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags |= CC_NOT_NEGATIVE; - return "bfextu %1{%b3:%b2},%0"; -} -} - -static char * -output_237 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "bfchg %0{%b2:%b1}"; -} -} - -static char * -output_238 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "bfclr %0{%b2:%b1}"; -} -} - -static char * -output_239 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "bfset %0{%b2:%b1}"; -} -} - -static char * -output_242 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags |= CC_NOT_NEGATIVE; - return "bfextu %1{%b3:%b2},%0"; -} -} - -static char * -output_243 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "bfclr %0{%b2:%b1}"; -} -} - -static char * -output_244 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "bfset %0{%b2:%b1}"; -} -} - -static char * -output_245 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if 0 - /* These special cases are now recognized by a specific pattern. */ - if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16) - return "move%.w %3,%0"; - if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8) - return "move%.b %3,%0"; -#endif - return "bfins %3,%0{%b2:%b1}"; -} -} - -static char * -output_246 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[1] == const1_rtx - && GET_CODE (operands[2]) == CONST_INT) - { - int width = GET_CODE (operands[0]) == REG ? 31 : 7; - return output_btst (operands, - gen_rtx (CONST_INT, VOIDmode, - width - INTVAL (operands[2])), - operands[0], - insn, 1000); - /* Pass 1000 as SIGNPOS argument so that btst will - not think we are testing the sign bit for an `and' - and assume that nonzero implies a negative result. */ - } - if (INTVAL (operands[1]) != 32) - cc_status.flags = CC_NOT_NEGATIVE; - return "bftst %0{%b2:%b1}"; -} -} - -static char * -output_247 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[1] == const1_rtx - && GET_CODE (operands[2]) == CONST_INT) - { - int width = GET_CODE (operands[0]) == REG ? 31 : 7; - return output_btst (operands, - gen_rtx (CONST_INT, VOIDmode, - width - INTVAL (operands[2])), - operands[0], - insn, 1000); - /* Pass 1000 as SIGNPOS argument so that btst will - not think we are testing the sign bit for an `and' - and assume that nonzero implies a negative result. */ - } - if (INTVAL (operands[1]) != 32) - cc_status.flags = CC_NOT_NEGATIVE; - return "bftst %0{%b2:%b1}"; -} -} - -static char * -output_248 (operands, insn) - rtx *operands; - rtx insn; -{ - - cc_status = cc_prev_status; - OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0"); - -} - -static char * -output_249 (operands, insn) - rtx *operands; - rtx insn; -{ - - cc_status = cc_prev_status; - OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0"); - -} - -static char * -output_250 (operands, insn) - rtx *operands; - rtx insn; -{ - - cc_status = cc_prev_status; - OUTPUT_JUMP ("sgt %0", "fsgt %0", 0); - -} - -static char * -output_251 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - return "shi %0"; -} - -static char * -output_252 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0"); -} - -static char * -output_253 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - return "scs %0"; -} - -static char * -output_254 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0"); -} - -static char * -output_255 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - return "scc %0"; -} - -static char * -output_256 (operands, insn) - rtx *operands; - rtx insn; -{ - - cc_status = cc_prev_status; - OUTPUT_JUMP ("sle %0", "fsle %0", 0); - -} - -static char * -output_257 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - return "sls %0"; -} - -static char * -output_258 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0"); -#else - OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0"); -#endif -} -} - -static char * -output_259 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0"); -#else - OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0"); -#endif -} -} - -static char * -output_260 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jbgt %l0", "fbgt %l0", 0); -#else - OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0); -#endif - -} - -static char * -output_261 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbhi %l0"; -#else - return "jhi %l0"; -#endif - -} - -static char * -output_262 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jblt %l0", "fblt %l0", "jbmi %l0"); -#else - OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0"); -#endif - -} - -static char * -output_263 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbcs %l0"; -#else - return "jcs %l0"; -#endif - -} - -static char * -output_264 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jbge %l0", "fbge %l0", "jbpl %l0"); -#else - OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0"); -#endif - -} - -static char * -output_265 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbcc %l0"; -#else - return "jcc %l0"; -#endif - -} - -static char * -output_266 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jble %l0", "fble %l0", 0); -#else - OUTPUT_JUMP ("jle %l0", "fjle %l0", 0); -#endif - -} - -static char * -output_267 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbls %l0"; -#else - return "jls %l0"; -#endif - -} - -static char * -output_268 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0"); -#else - OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0"); -#endif -} -} - -static char * -output_269 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0"); -#else - OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0"); -#endif -} -} - -static char * -output_270 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jble %l0", "fbngt %l0", 0); -#else - OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0); -#endif - -} - -static char * -output_271 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbls %l0"; -#else - return "jls %l0"; -#endif - -} - -static char * -output_272 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jbge %l0", "fbnlt %l0", "jbpl %l0"); -#else - OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0"); -#endif - -} - -static char * -output_273 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbcc %l0"; -#else - return "jcc %l0"; -#endif - -} - -static char * -output_274 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jblt %l0", "fbnge %l0", "jbmi %l0"); -#else - OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0"); -#endif - -} - -static char * -output_275 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbcs %l0"; -#else - return "jcs %l0"; -#endif - -} - -static char * -output_276 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jbgt %l0", "fbnle %l0", 0); -#else - OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0); -#endif - -} - -static char * -output_277 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbhi %l0"; -#else - return "jhi %l0"; -#endif - -} - -static char * -output_278 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbra %l0"; -#else - return "jra %l0"; -#endif - -} - -static char * -output_280 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jmp (%0)"; -#else - return "jmp %0@"; -#endif - -} - -static char * -output_281 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef ASM_RETURN_CASE_JUMP - ASM_RETURN_CASE_JUMP; -#else -#ifdef SGS -#ifdef ASM_OUTPUT_CASE_LABEL - return "jmp 6(%%pc,%0.w)"; -#else -#ifdef CRDS - return "jmp 2(pc,%0.w)"; -#else - return "jmp 2(%%pc,%0.w)"; -#endif /* end !CRDS */ -#endif -#else /* not SGS */ -#ifdef MOTOROLA - return "jmp (2,pc,%0.w)"; -#else - return "jmp pc@(2,%0:w)"; -#endif -#endif -#endif - -} - -static char * -output_282 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1"; - if (GET_CODE (operands[0]) == MEM) - { -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - return "sub%.w %#1,%0\n\tjbcc %l1"; -#else - return "subq%.w %#1,%0\n\tjbcc %l1"; -#endif -#else /* not MOTOROLA */ - return "subqw %#1,%0\n\tjcc %l1"; -#endif - } -#ifdef MOTOROLA -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return "sub%.w %#1,%0\n\tcmp%.w %0,%#-1\n\tjbne %l1"; -#else - return "subq%.w %#1,%0\n\tcmp%.w %0,%#-1\n\tjbne %l1"; -#endif -#else /* not SGS_CMP_ORDER */ - return "subq%.w %#1,%0\n\tcmp%.w %#-1,%0\n\tjbne %l1"; -#endif -#else /* not MOTOROLA */ - return "subqw %#1,%0\n\tcmpw %#-1,%0\n\tjne %l1"; -#endif -} -} - -static char * -output_283 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsub%.l %#1,%0\n\tjbcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "sub%.l %#1,%0\n\tjbcc %l1"; -#else - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsubq%.l %#1,%0\n\tjbcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "subq%.l %#1,%0\n\tjbcc %l1"; -#endif /* NO_ADDSUB_Q */ -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return "sub.l %#1,%0\n\tcmp.l %0,%#-1\n\tjbne %l1"; -#else - return "subq.l %#1,%0\n\tcmp.l %0,%#-1\n\tjbne %l1"; -#endif -#else /* not SGS_CMP_ORDER */ - return "subq.l %#1,%0\n\tcmp.l %#-1,%0\n\tjbne %l1"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsubql %#1,%0\n\tjcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "subql %#1,%0\n\tjcc %l1"; - return "subql %#1,%0\n\tcmpl %#-1,%0\n\tjne %l1"; -#endif /* not MOTOROLA */ -} -} - -static char * -output_284 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1"; - if (GET_CODE (operands[0]) == MEM) - return "sub%.w %#1,%0\n\tjbcc %l1"; -#else - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1"; - if (GET_CODE (operands[0]) == MEM) - return "subq%.w %#1,%0\n\tjbcc %l1"; -#endif -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return "sub.w %#1,%0\n\tcmp.w %0,%#-1\n\tjbne %l1"; -#else - return "subq.w %#1,%0\n\tcmp.w %0,%#-1\n\tjbne %l1"; -#endif -#else /* not SGS_CMP_ORDER */ - return "subq.w %#1,%0\n\tcmp.w %#-1,%0\n\tjbne %l1"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1"; - if (GET_CODE (operands[0]) == MEM) - return "subqw %#1,%0\n\tjcc %l1"; - return "subqw %#1,%0\n\tcmpw %#-1,%0\n\tjne %l1"; -#endif /* not MOTOROLA */ -} -} - -static char * -output_285 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsub%.l %#1,%0\n\tjbcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "sub%.l %#1,%0\n\tjbcc %l1"; -#else - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsubq%.l %#1,%0\n\tjbcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "subq%.l %#1,%0\n\tjbcc %l1"; -#endif -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return "sub.l %#1,%0\n\tcmp.l %0,%#-1\n\tjbne %l1"; -#else - return "subq.l %#1,%0\n\tcmp.l %0,%#-1\n\tjbne %l1"; -#endif -#else /* not SGS_CMP_ORDER */ - return "subq.l %#1,%0\n\tcmp.l %#-1,%0\n\tjbne %l1"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsubql %#1,%0\n\tjcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "subql %#1,%0\n\tjcc %l1"; - return "subql %#1,%0\n\tcmpl %#-1,%0\n\tjne %l1"; -#endif /* not MOTOROLA */ -} -} - -static char * -output_287 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jsr %0"; -#else - return "jbsr %0"; -#endif - -} - -static char * -output_288 (operands, insn) - rtx *operands; - rtx insn; -{ - - if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF) -#ifdef MOTOROLA - return "bsr %0@PLTPC"; -#else - return "jbsr %0,a1"; -#endif - return "jsr %0"; - -} - -static char * -output_290 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jsr %1"; -#else - return "jbsr %1"; -#endif - -} - -static char * -output_291 (operands, insn) - rtx *operands; - rtx insn; -{ - - if (GET_CODE (operands[1]) == MEM - && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF) -#ifdef MOTOROLA - return "bsr %1@PLTPC"; -#else - return "jbsr %1,a1"; -#endif - return "jsr %1"; - -} - -static char * -output_295 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[0] = gen_rtx (PLUS, SImode, stack_pointer_rtx, - gen_rtx (CONST_INT, VOIDmode, NEED_PROBE)); - return "tstl %a0"; -} -} - -static char * -output_296 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (current_function_pops_args == 0) - return "rts"; - operands[0] = gen_rtx (CONST_INT, VOIDmode, current_function_pops_args); - return "rtd %0"; -} -} - -static char * -output_299 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn ("move%.l %1,%@", xoperands); - output_asm_insn ("move%.l %1,%-", operands); - return "fmove%.d %+,%0"; -} - -} - -static char * -output_300 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (INTVAL (operands[0]) > 4) - { - rtx xoperands[2]; - xoperands[0] = stack_pointer_rtx; - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4); -#ifndef NO_ADDSUB_Q - if (INTVAL (xoperands[1]) <= 8) - output_asm_insn ("addq%.w %1,%0", xoperands); - else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020) - { - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (xoperands[1]) - 8); - output_asm_insn ("addq%.w %#8,%0\n\taddq%.w %1,%0", xoperands); - } - else -#endif - if (INTVAL (xoperands[1]) <= 0x7FFF) - output_asm_insn ("add%.w %1,%0", xoperands); - else - output_asm_insn ("add%.l %1,%0", xoperands); - } - if (FP_REG_P (operands[2])) - return "fmove%.s %2,%@"; - return "move%.l %2,%@"; -} -} - -static char * -output_301 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (INTVAL (operands[0]) > 4) - { - rtx xoperands[2]; - xoperands[0] = stack_pointer_rtx; - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4); -#ifndef NO_ADDSUB_Q - if (INTVAL (xoperands[1]) <= 8) - output_asm_insn ("addq%.w %1,%0", xoperands); - else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020) - { - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (xoperands[1]) - 8); - output_asm_insn ("addq%.w %#8,%0\n\taddq%.w %1,%0", xoperands); - } - else -#endif - if (INTVAL (xoperands[1]) <= 0x7FFF) - output_asm_insn ("add%.w %1,%0", xoperands); - else - output_asm_insn ("add%.l %1,%0", xoperands); - } - if (operands[2] == const0_rtx) - return "clr%.l %@"; - return "move%.l %2,%@"; -} -} - -static char * -output_302 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xoperands[4]; - - if (GET_CODE (operands[1]) == REG) - return "move%.l %1,%-"; - - xoperands[1] = operands[1]; - xoperands[2] - = gen_rtx (MEM, QImode, - gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, - gen_rtx (CONST_INT, VOIDmode, 3))); - xoperands[3] = stack_pointer_rtx; - output_asm_insn ("subq%.w %#4,%3\n\tmove%.b %1,%2", xoperands); - return ""; -} -} - -static char * -output_303 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return "clr%.w %0"; - } - return "move%.w %1,%0"; -} -} - -static char * -output_304 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - output_dbcc_and_branch (operands); - return ""; -} -} - -static char * -output_305 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - output_dbcc_and_branch (operands); - return ""; -} -} - -static char * -output_306 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_306[] = { - "fpma%.d %1,%w2,%w3,%0", - "fpma%.d %x1,%x2,%x3,%0", - "fpma%.d %x1,%x2,%x3,%0", - }; - return strings_306[which_alternative]; -} - -static char * -output_307 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_307[] = { - "fpma%.s %1,%w2,%w3,%0", - "fpma%.s %1,%2,%3,%0", - "fpma%.s %1,%2,%3,%0", - }; - return strings_307[which_alternative]; -} - -static char * -output_308 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_308[] = { - "fpms%.d %3,%w2,%w1,%0", - "fpms%.d %x3,%2,%x1,%0", - "fpms%.d %x3,%2,%x1,%0", - }; - return strings_308[which_alternative]; -} - -static char * -output_309 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_309[] = { - "fpms%.s %3,%w2,%w1,%0", - "fpms%.s %3,%2,%1,%0", - "fpms%.s %3,%2,%1,%0", - }; - return strings_309[which_alternative]; -} - -static char * -output_310 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_310[] = { - "fpmr%.d %2,%w1,%w3,%0", - "fpmr%.d %x2,%1,%x3,%0", - "fpmr%.d %x2,%1,%x3,%0", - }; - return strings_310[which_alternative]; -} - -static char * -output_311 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_311[] = { - "fpmr%.s %2,%w1,%w3,%0", - "fpmr%.s %x2,%1,%x3,%0", - "fpmr%.s %x2,%1,%x3,%0", - }; - return strings_311[which_alternative]; -} - -static char * -output_312 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_312[] = { - "fpam%.d %2,%w1,%w3,%0", - "fpam%.d %x2,%1,%x3,%0", - "fpam%.d %x2,%1,%x3,%0", - }; - return strings_312[which_alternative]; -} - -static char * -output_313 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_313[] = { - "fpam%.s %2,%w1,%w3,%0", - "fpam%.s %x2,%1,%x3,%0", - "fpam%.s %x2,%1,%x3,%0", - }; - return strings_313[which_alternative]; -} - -static char * -output_314 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_314[] = { - "fpsm%.d %2,%w1,%w3,%0", - "fpsm%.d %x2,%1,%x3,%0", - "fpsm%.d %x2,%1,%x3,%0", - }; - return strings_314[which_alternative]; -} - -static char * -output_315 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_315[] = { - "fpsm%.d %3,%w2,%w1,%0", - "fpsm%.d %x3,%2,%x1,%0", - "fpsm%.d %x3,%2,%x1,%0", - }; - return strings_315[which_alternative]; -} - -static char * -output_316 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_316[] = { - "fpsm%.s %2,%w1,%w3,%0", - "fpsm%.s %x2,%1,%x3,%0", - "fpsm%.s %x2,%1,%x3,%0", - }; - return strings_316[which_alternative]; -} - -static char * -output_317 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_317[] = { - "fpsm%.s %3,%w2,%w1,%0", - "fpsm%.s %x3,%2,%x1,%0", - "fpsm%.s %x3,%2,%x1,%0", - }; - return strings_317[which_alternative]; -} - -static char * -output_318 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; - return "ftst%.x %0"; -} -} - -static char * -output_320 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return "fcmp%.x %0,%1"; - else - return "fcmp%.x %0,%f1"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.x %1,%f0"; -#else - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return "fcmp%.x %1,%0"; - else - return "fcmp%.x %f1,%0"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.x %f0,%1"; -#endif -} -} - -static char * -output_321 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return ""; - } - return "f%$move%.x %1,%0"; - } - if (FP_REG_P (operands[0])) - return "f%$move%.s %f1,%0"; - return "fmove%.x %f1,%0"; -} -} - -static char * -output_322 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return ""; - } - return "fmove%.x %1,%0"; - } - if (FP_REG_P (operands[0])) - return "f%&move%.d %f1,%0"; - return "fmove%.x %f1,%0"; -} -} - -static char * -output_323 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0])) - { - output_asm_insn ("fmove%.d %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - return "fmove%.d %f1,%0"; -} -} - -static char * -output_328 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "fintrz%.x %f1,%0"; - return "fintrz%.x %f1,%0"; -} -} - -static char * -output_333 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "fadd%.x %2,%0"; - return "fadd%.x %f2,%0"; -} -} - -static char * -output_335 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "fsub%.x %2,%0"; - return "fsub%.x %f2,%0"; -} -} - -static char * -output_337 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "fmul%.x %2,%0"; - return "fmul%.x %f2,%0"; -} -} - -static char * -output_339 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "fdiv%.x %2,%0"; - return "fdiv%.x %f2,%0"; -} -} - -static char * -output_340 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "fneg%.x %1,%0"; - return "fneg%.x %f1,%0"; -} -} - -static char * -output_341 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "fabs%.x %1,%0"; - return "fabs%.x %f1,%0"; -} -} - -static char * -output_342 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return "fsqrt%.x %1,%0"; -} -} - -char * const insn_template[] = - { - 0, - 0, - 0, - "tst%.w %0", - "tst%.b %0", - 0, - "fptst%.s %x0\n\tfpmove fpastatus,%1\n\tmovw %1,cc", - 0, - 0, - "fptst%.d %x0\n\tfpmove fpastatus,%1\n\tmovw %1,cc", - 0, - 0, - 0, - 0, - 0, - "fpcmp%.d %y1,%0\n\tfpmove fpastatus,%2\n\tmovw %2,cc", - 0, - 0, - "fpcmp%.s %w1,%x0\n\tfpmove fpastatus,%2\n\tmovw %2,cc", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "pea %a1", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "ext%.w %0", - "extb%.l %0", - 0, - "fpstod %w1,%0", - 0, - 0, - "fpdtos %y1,%0", - 0, - "fmove%.s %f1,%0", - 0, - "fpltos %1,%0", - "f%$move%.l %1,%0", - 0, - "fpltod %1,%0", - "f%&move%.l %1,%0", - "f%$move%.w %1,%0", - "fmove%.w %1,%0", - "fmove%.b %1,%0", - "f%&move%.b %1,%0", - 0, - 0, - 0, - 0, - 0, - "fmove%.b %1,%0", - "fmove%.w %1,%0", - "fmove%.l %1,%0", - "fmove%.b %1,%0", - "fmove%.w %1,%0", - "fmove%.l %1,%0", - "fpstol %w1,%0", - "fpdtol %y1,%0", - 0, - "add%.w %2,%0", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "sub%.w %2,%0", - "sub%.w %2,%0", - "sub%.w %1,%0", - "sub%.b %2,%0", - "sub%.b %1,%0", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "muls%.l %2,%0", - 0, - 0, - 0, - "mulu%.l %2,%3:%0", - "mulu%.l %2,%3:%0", - 0, - "muls%.l %2,%3:%0", - "muls%.l %2,%3:%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, - "and%.w %2,%0", - "and%.w %1,%0", - "and%.w %1,%0", - "and%.b %2,%0", - "and%.b %1,%0", - "and%.b %1,%0", - 0, - "or%.w %2,%0", - "or%.w %1,%0", - "or%.w %1,%0", - "or%.b %2,%0", - "or%.b %1,%0", - "or%.b %1,%0", - 0, - "eor%.w %2,%0", - "eor%.w %1,%0", - "eor%.w %1,%0", - "eor%.b %2,%0", - "eor%.b %1,%0", - "eor%.b %1,%0", - "neg%.l %0", - "neg%.w %0", - "neg%.w %0", - "neg%.b %0", - "neg%.b %0", - 0, - "fpneg%.s %w1,%0", - 0, - 0, - "fpneg%.d %y1, %0", - 0, - 0, - 0, - "fpabs%.s %y1,%0", - 0, - 0, - "fpabs%.d %y1,%0", - 0, - "not%.l %0", - "not%.w %0", - "not%.w %0", - "not%.b %0", - "not%.b %0", - 0, - 0, - 0, - "asl%.w %2,%0", - "asl%.w %1,%0", - "asl%.b %2,%0", - "asl%.b %1,%0", - "swap %0\n\text%.l %0", - 0, - 0, - "asr%.w %2,%0", - "asr%.w %1,%0", - "asr%.b %2,%0", - "asr%.b %1,%0", - 0, - 0, - 0, - "lsl%.w %2,%0", - "lsl%.w %1,%0", - "lsl%.b %2,%0", - "lsl%.b %1,%0", - 0, - 0, - 0, - "lsr%.w %2,%0", - "lsr%.w %1,%0", - "lsr%.b %2,%0", - "lsr%.b %1,%0", - "rol%.l %2,%0", - "rol%.w %2,%0", - "rol%.w %1,%0", - "rol%.b %2,%0", - "rol%.b %1,%0", - "ror%.l %2,%0", - "ror%.w %2,%0", - "ror%.w %1,%0", - "ror%.b %2,%0", - "ror%.b %1,%0", - 0, - 0, - 0, - 0, - 0, - 0, - "bfexts %1{%b3:%b2},%0", - 0, - 0, - 0, - 0, - "bfins %3,%0{%b2:%b1}", - "bfexts %1{%b3:%b2},%0", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "", - "nop", - 0, - 0, - "jmp %a0", - "lea %a1,%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, - "fmove%.s %f1,%0", - "fmove%.l %1,%0", - "fmove%.w %1,%0", - "fmove%.b %1,%0", - 0, - "fmove%.b %1,%0", - "fmove%.w %1,%0", - "fmove%.l %1,%0", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - }; - -char *(*const insn_outfun[])() = - { - output_0, - output_1, - output_2, - 0, - 0, - 0, - 0, - output_7, - 0, - 0, - output_10, - output_11, - output_12, - output_13, - 0, - 0, - output_16, - 0, - 0, - output_19, - output_20, - output_21, - output_22, - output_23, - output_24, - output_25, - output_26, - output_27, - 0, - output_29, - output_30, - output_31, - output_32, - output_33, - output_34, - output_35, - 0, - output_37, - output_38, - output_39, - 0, - output_41, - output_42, - output_43, - 0, - 0, - 0, - output_47, - output_48, - output_49, - output_50, - 0, - 0, - 0, - 0, - output_55, - 0, - 0, - output_58, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_70, - output_71, - output_72, - output_73, - output_74, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_83, - 0, - output_85, - output_86, - output_87, - output_88, - output_89, - output_90, - 0, - output_92, - output_93, - 0, - output_95, - output_96, - output_97, - 0, - 0, - 0, - 0, - 0, - 0, - output_104, - output_105, - 0, - output_107, - output_108, - output_109, - output_110, - output_111, - 0, - output_113, - output_114, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_122, - output_123, - 0, - output_125, - output_126, - output_127, - output_128, - output_129, - output_130, - output_131, - output_132, - 0, - output_134, - output_135, - 0, - output_137, - output_138, - output_139, - output_140, - output_141, - output_142, - output_143, - output_144, - output_145, - output_146, - output_147, - 0, - 0, - 0, - 0, - 0, - 0, - output_154, - 0, - 0, - 0, - 0, - 0, - 0, - output_161, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_175, - 0, - 0, - output_178, - output_179, - 0, - 0, - output_182, - 0, - 0, - output_185, - 0, - 0, - 0, - 0, - 0, - output_191, - output_192, - output_193, - 0, - 0, - 0, - 0, - 0, - output_199, - output_200, - 0, - 0, - 0, - 0, - output_205, - output_206, - output_207, - 0, - 0, - 0, - 0, - output_212, - output_213, - output_214, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_229, - output_230, - output_231, - output_232, - output_233, - output_234, - 0, - output_236, - output_237, - output_238, - output_239, - 0, - 0, - output_242, - output_243, - output_244, - output_245, - output_246, - output_247, - output_248, - output_249, - output_250, - output_251, - output_252, - output_253, - output_254, - output_255, - output_256, - output_257, - output_258, - output_259, - output_260, - output_261, - output_262, - output_263, - output_264, - output_265, - output_266, - output_267, - output_268, - output_269, - output_270, - output_271, - output_272, - output_273, - output_274, - output_275, - output_276, - output_277, - output_278, - 0, - output_280, - output_281, - output_282, - output_283, - output_284, - output_285, - 0, - output_287, - output_288, - 0, - output_290, - output_291, - 0, - 0, - 0, - output_295, - output_296, - 0, - 0, - output_299, - output_300, - output_301, - output_302, - output_303, - output_304, - output_305, - output_306, - output_307, - output_308, - output_309, - output_310, - output_311, - output_312, - output_313, - output_314, - output_315, - output_316, - output_317, - output_318, - 0, - output_320, - output_321, - output_322, - output_323, - 0, - 0, - 0, - 0, - output_328, - 0, - 0, - 0, - 0, - output_333, - 0, - output_335, - 0, - output_337, - 0, - output_339, - output_340, - output_341, - output_342, - }; - -rtx (*const insn_gen_function[]) () = - { - 0, - 0, - gen_tstsi, - gen_tsthi, - gen_tstqi, - gen_tstsf, - gen_tstsf_fpa, - 0, - gen_tstdf, - gen_tstdf_fpa, - 0, - gen_cmpsi, - gen_cmphi, - gen_cmpqi, - gen_cmpdf, - gen_cmpdf_fpa, - 0, - gen_cmpsf, - gen_cmpsf_fpa, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_movsi, - 0, - gen_movhi, - gen_movstricthi, - gen_movqi, - gen_movstrictqi, - gen_movsf, - gen_movdf, - gen_movxf, - 0, - 0, - gen_movdi, - gen_pushasi, - gen_truncsiqi2, - gen_trunchiqi2, - gen_truncsihi2, - gen_zero_extendhisi2, - gen_zero_extendqihi2, - gen_zero_extendqisi2, - 0, - 0, - 0, - gen_extendhisi2, - gen_extendqihi2, - gen_extendqisi2, - gen_extendsfdf2, - 0, - 0, - gen_truncdfsf2, - 0, - 0, - 0, - gen_floatsisf2, - 0, - 0, - gen_floatsidf2, - 0, - 0, - gen_floathisf2, - gen_floathidf2, - gen_floatqisf2, - gen_floatqidf2, - gen_fix_truncdfsi2, - gen_fix_truncdfhi2, - gen_fix_truncdfqi2, - gen_ftruncdf2, - gen_ftruncsf2, - gen_fixsfqi2, - gen_fixsfhi2, - gen_fixsfsi2, - gen_fixdfqi2, - gen_fixdfhi2, - gen_fixdfsi2, - 0, - 0, - gen_addsi3, - 0, - gen_addhi3, - 0, - 0, - gen_addqi3, - 0, - 0, - gen_adddf3, - 0, - 0, - gen_addsf3, - 0, - 0, - gen_subsi3, - 0, - gen_subhi3, - 0, - gen_subqi3, - 0, - gen_subdf3, - 0, - 0, - gen_subsf3, - 0, - 0, - gen_mulhi3, - gen_mulhisi3, - 0, - gen_mulsi3, - gen_umulhisi3, - 0, - gen_umulsidi3, - 0, - 0, - gen_mulsidi3, - 0, - 0, - gen_muldf3, - 0, - 0, - gen_mulsf3, - 0, - 0, - gen_divhi3, - gen_divhisi3, - 0, - gen_udivhi3, - gen_udivhisi3, - 0, - gen_divdf3, - 0, - 0, - gen_divsf3, - 0, - 0, - gen_modhi3, - gen_modhisi3, - 0, - gen_umodhi3, - gen_umodhisi3, - 0, - gen_divmodsi4, - gen_udivmodsi4, - gen_andsi3, - gen_andhi3, - 0, - 0, - gen_andqi3, - 0, - 0, - gen_iorsi3, - gen_iorhi3, - 0, - 0, - gen_iorqi3, - 0, - 0, - gen_xorsi3, - gen_xorhi3, - 0, - 0, - gen_xorqi3, - 0, - 0, - gen_negsi2, - gen_neghi2, - 0, - gen_negqi2, - 0, - gen_negsf2, - 0, - 0, - gen_negdf2, - 0, - 0, - gen_sqrtdf2, - gen_abssf2, - 0, - 0, - gen_absdf2, - 0, - 0, - gen_one_cmplsi2, - gen_one_cmplhi2, - 0, - gen_one_cmplqi2, - 0, - 0, - 0, - gen_ashlsi3, - gen_ashlhi3, - 0, - gen_ashlqi3, - 0, - 0, - 0, - gen_ashrsi3, - gen_ashrhi3, - 0, - gen_ashrqi3, - 0, - 0, - 0, - gen_lshlsi3, - gen_lshlhi3, - 0, - gen_lshlqi3, - 0, - 0, - 0, - gen_lshrsi3, - gen_lshrhi3, - 0, - gen_lshrqi3, - 0, - gen_rotlsi3, - gen_rotlhi3, - 0, - gen_rotlqi3, - 0, - gen_rotrsi3, - gen_rotrhi3, - 0, - gen_rotrqi3, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_extv, - gen_extzv, - 0, - 0, - 0, - gen_insv, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_seq, - gen_sne, - gen_sgt, - gen_sgtu, - gen_slt, - gen_sltu, - gen_sge, - gen_sgeu, - gen_sle, - gen_sleu, - gen_beq, - gen_bne, - gen_bgt, - gen_bgtu, - gen_blt, - gen_bltu, - gen_bge, - gen_bgeu, - gen_ble, - gen_bleu, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_jump, - gen_tablejump, - 0, - 0, - 0, - 0, - 0, - gen_decrement_and_branch_until_zero, - gen_call, - 0, - 0, - gen_call_value, - 0, - 0, - gen_untyped_call, - gen_blockage, - gen_nop, - gen_probe, - gen_return, - gen_indirect_jump, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_tstxf, - gen_cmpxf, - 0, - gen_extendsfxf2, - gen_extenddfxf2, - gen_truncxfdf2, - gen_truncxfsf2, - gen_floatsixf2, - gen_floathixf2, - gen_floatqixf2, - gen_ftruncxf2, - gen_fixxfqi2, - gen_fixxfhi2, - gen_fixxfsi2, - gen_addxf3, - 0, - gen_subxf3, - 0, - gen_mulxf3, - 0, - gen_divxf3, - 0, - gen_negxf2, - gen_absxf2, - gen_sqrtxf2, - }; - -char *insn_name[] = - { - "tstsi-1", - "tstsi-0", - "tstsi", - "tsthi", - "tstqi", - "tstsf", - "tstsf_fpa", - "tstsf_fpa+1", - "tstdf", - "tstdf_fpa", - "tstdf_fpa+1", - "cmpsi", - "cmphi", - "cmpqi", - "cmpdf", - "cmpdf_fpa", - "cmpdf_fpa+1", - "cmpsf", - "cmpsf_fpa", - "cmpsf_fpa+1", - "cmpsf_fpa+2", - "cmpsf_fpa+3", - "cmpsf_fpa+4", - "cmpsf_fpa+5", - "movsi-4", - "movsi-3", - "movsi-2", - "movsi-1", - "movsi", - "movsi+1", - "movhi", - "movstricthi", - "movqi", - "movstrictqi", - "movsf", - "movdf", - "movxf", - "movxf+1", - "movdi-1", - "movdi", - "pushasi", - "truncsiqi2", - "trunchiqi2", - "truncsihi2", - "zero_extendhisi2", - "zero_extendqihi2", - "zero_extendqisi2", - "zero_extendqisi2+1", - "zero_extendqisi2+2", - "extendhisi2-1", - "extendhisi2", - "extendqihi2", - "extendqisi2", - "extendsfdf2", - "extendsfdf2+1", - "truncdfsf2-1", - "truncdfsf2", - "truncdfsf2+1", - "truncdfsf2+2", - "floatsisf2-1", - "floatsisf2", - "floatsisf2+1", - "floatsidf2-1", - "floatsidf2", - "floatsidf2+1", - "floathisf2-1", - "floathisf2", - "floathidf2", - "floatqisf2", - "floatqidf2", - "fix_truncdfsi2", - "fix_truncdfhi2", - "fix_truncdfqi2", - "ftruncdf2", - "ftruncsf2", - "fixsfqi2", - "fixsfhi2", - "fixsfsi2", - "fixdfqi2", - "fixdfhi2", - "fixdfsi2", - "fixdfsi2+1", - "addsi3-1", - "addsi3", - "addsi3+1", - "addhi3", - "addhi3+1", - "addqi3-1", - "addqi3", - "addqi3+1", - "adddf3-1", - "adddf3", - "adddf3+1", - "addsf3-1", - "addsf3", - "addsf3+1", - "subsi3-1", - "subsi3", - "subsi3+1", - "subhi3", - "subhi3+1", - "subqi3", - "subqi3+1", - "subdf3", - "subdf3+1", - "subsf3-1", - "subsf3", - "subsf3+1", - "mulhi3-1", - "mulhi3", - "mulhisi3", - "mulhisi3+1", - "mulsi3", - "umulhisi3", - "umulhisi3+1", - "umulsidi3", - "umulsidi3+1", - "mulsidi3-1", - "mulsidi3", - "mulsidi3+1", - "muldf3-1", - "muldf3", - "muldf3+1", - "mulsf3-1", - "mulsf3", - "mulsf3+1", - "divhi3-1", - "divhi3", - "divhisi3", - "divhisi3+1", - "udivhi3", - "udivhisi3", - "udivhisi3+1", - "divdf3", - "divdf3+1", - "divsf3-1", - "divsf3", - "divsf3+1", - "modhi3-1", - "modhi3", - "modhisi3", - "modhisi3+1", - "umodhi3", - "umodhisi3", - "umodhisi3+1", - "divmodsi4", - "udivmodsi4", - "andsi3", - "andhi3", - "andhi3+1", - "andqi3-1", - "andqi3", - "andqi3+1", - "iorsi3-1", - "iorsi3", - "iorhi3", - "iorhi3+1", - "iorqi3-1", - "iorqi3", - "iorqi3+1", - "xorsi3-1", - "xorsi3", - "xorhi3", - "xorhi3+1", - "xorqi3-1", - "xorqi3", - "xorqi3+1", - "negsi2-1", - "negsi2", - "neghi2", - "neghi2+1", - "negqi2", - "negqi2+1", - "negsf2", - "negsf2+1", - "negdf2-1", - "negdf2", - "negdf2+1", - "sqrtdf2-1", - "sqrtdf2", - "abssf2", - "abssf2+1", - "absdf2-1", - "absdf2", - "absdf2+1", - "one_cmplsi2-1", - "one_cmplsi2", - "one_cmplhi2", - "one_cmplhi2+1", - "one_cmplqi2", - "one_cmplqi2+1", - "one_cmplqi2+2", - "ashlsi3-1", - "ashlsi3", - "ashlhi3", - "ashlhi3+1", - "ashlqi3", - "ashlqi3+1", - "ashlqi3+2", - "ashrsi3-1", - "ashrsi3", - "ashrhi3", - "ashrhi3+1", - "ashrqi3", - "ashrqi3+1", - "ashrqi3+2", - "lshlsi3-1", - "lshlsi3", - "lshlhi3", - "lshlhi3+1", - "lshlqi3", - "lshlqi3+1", - "lshlqi3+2", - "lshrsi3-1", - "lshrsi3", - "lshrhi3", - "lshrhi3+1", - "lshrqi3", - "lshrqi3+1", - "rotlsi3", - "rotlhi3", - "rotlhi3+1", - "rotlqi3", - "rotlqi3+1", - "rotrsi3", - "rotrhi3", - "rotrhi3+1", - "rotrqi3", - "rotrqi3+1", - "rotrqi3+2", - "rotrqi3+3", - "rotrqi3+4", - "extv-3", - "extv-2", - "extv-1", - "extv", - "extzv", - "extzv+1", - "extzv+2", - "insv-1", - "insv", - "insv+1", - "insv+2", - "insv+3", - "insv+4", - "seq-3", - "seq-2", - "seq-1", - "seq", - "sne", - "sgt", - "sgtu", - "slt", - "sltu", - "sge", - "sgeu", - "sle", - "sleu", - "beq", - "bne", - "bgt", - "bgtu", - "blt", - "bltu", - "bge", - "bgeu", - "ble", - "bleu", - "bleu+1", - "bleu+2", - "bleu+3", - "bleu+4", - "bleu+5", - "jump-5", - "jump-4", - "jump-3", - "jump-2", - "jump-1", - "jump", - "tablejump", - "tablejump+1", - "tablejump+2", - "tablejump+3", - "decrement_and_branch_until_zero-2", - "decrement_and_branch_until_zero-1", - "decrement_and_branch_until_zero", - "call", - "call+1", - "call_value-1", - "call_value", - "call_value+1", - "untyped_call-1", - "untyped_call", - "blockage", - "nop", - "probe", - "return", - "indirect_jump", - "indirect_jump+1", - "indirect_jump+2", - "indirect_jump+3", - "indirect_jump+4", - "indirect_jump+5", - "indirect_jump+6", - "indirect_jump+7", - "indirect_jump+8", - "indirect_jump+9", - "indirect_jump+10", - "tstxf-10", - "tstxf-9", - "tstxf-8", - "tstxf-7", - "tstxf-6", - "tstxf-5", - "tstxf-4", - "tstxf-3", - "tstxf-2", - "tstxf-1", - "tstxf", - "cmpxf", - "cmpxf+1", - "extendsfxf2", - "extenddfxf2", - "truncxfdf2", - "truncxfsf2", - "floatsixf2", - "floathixf2", - "floatqixf2", - "ftruncxf2", - "fixxfqi2", - "fixxfhi2", - "fixxfsi2", - "addxf3", - "addxf3+1", - "subxf3", - "subxf3+1", - "mulxf3", - "mulxf3+1", - "divxf3", - "divxf3+1", - "negxf2", - "absxf2", - "sqrtxf2", - }; -char **insn_name_ptr = insn_name; - -const int insn_n_operands[] = - { - 2, - 2, - 1, - 1, - 1, - 1, - 2, - 1, - 1, - 2, - 1, - 2, - 2, - 2, - 2, - 3, - 2, - 2, - 3, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 4, - 4, - 4, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 2, - 2, - 3, - 2, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 4, - 3, - 4, - 4, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 4, - 3, - 3, - 2, - 2, - 3, - 2, - 2, - 3, - 3, - 2, - 2, - 3, - 2, - 2, - 3, - 3, - 2, - 2, - 3, - 2, - 2, - 2, - 2, - 1, - 2, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 2, - 1, - 3, - 3, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 2, - 3, - 2, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 3, - 3, - 4, - 4, - 4, - 3, - 3, - 4, - 3, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 0, - 0, - 0, - 0, - 1, - 2, - 2, - 3, - 3, - 2, - 2, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 2, - 2, - 2, - }; - -const int insn_n_dups[] = - { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3, - 2, - 2, - 3, - 2, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 2, - 0, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 2, - 2, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - }; - -char *const insn_operand_constraint[][MAX_RECOG_OPERANDS] = - { - { "=m", "ro<>fyE", }, - { "=m", "ro<>Fy", }, - { "rm", }, - { "dm", }, - { "dm", }, - { "", }, - { "xmdF", "=d", }, - { "fdm", }, - { "", }, - { "xrmF", "=d", }, - { "fm", }, - { "rKs,mr,>", "mr,Ksr,>", }, - { "rnm,d,n,m", "d,rnm,m,n", }, - { "dn,md,>", "dm,nd,>", }, - { "", "", }, - { "x,y", "xH,rmF", "=d,d", }, - { "f,mG", "fmG,f", }, - { "", "", }, - { "x,y", "xH,rmF", "=d,d", }, - { "f,mdG", "fmdG,f", }, - { "do", "di", }, - { "d", "di", }, - { "do", "d", }, - { "d", "d", }, - { "md", "i", }, - { "do", "i", }, - { "=m", "J", }, - { "=g", }, - { "", "", }, - { "=g,da,y,!*x*r*m", "daymKs,i,g,*x*r*m", }, - { "=g", "g", }, - { "+dm", "rmn", }, - { "=d,*a,m,m,?*a", "dmi*a,d*a,dmi,?*a,m", }, - { "+dm", "dmn", }, - { "=rmf,x,y,rm,!x,!rm", "rmfF,xH,rmF,y,rm,x", }, - { "=rm,&rf,&rof<>,y,rm,x,!x,!rm", "rf,m,rofE<>,rmE,y,xH,rm,x", }, - { "", "", }, - { "=f,m,f,!r,!f", "m,f,f,f,r", }, - { "=rm,&rf,&rof<>", "rf,m,rof<>", }, - { "=rm,&r,&ro<>,y,rm,!*x,!rm", "rF,m,roi<>F,rmiF,y,rmF,*x", }, - { "=m", "p", }, - { "=dm,d", "doJ,i", }, - { "=dm,d", "doJ,i", }, - { "=dm,d", "roJ,i", }, - { "", "", }, - { "", "", }, - { "", "", }, - { "=do<>,d<", "r,m", }, - { "=do<>,d", "d,m", }, - { "=do<>,d", "d,m", }, - { "=*d,a", "0,rm", }, - { "=d", "0", }, - { "=d", "0", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=*fdm,f", "f,dmF", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=f", "fmG", }, - { "=dm", "f", }, - { "", "", }, - { "=y,x", "rmi,x", }, - { "=f", "dmi", }, - { "", "", }, - { "=y,x", "rmi,x", }, - { "=f", "dmi", }, - { "=f", "dmn", }, - { "=f", "dmn", }, - { "=f", "dmn", }, - { "=f", "dmn", }, - { "=dm", "f", "=d", "=d", }, - { "=dm", "f", "=d", "=d", }, - { "=dm", "f", "=d", "=d", }, - { "=f", "fFm", }, - { "=f", "dfFm", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=x,y", "xH,rmF", }, - { "=x,y", "xH,rmF", }, - { "=m,?a,?a,r", "%0,a,rJK,0", "dIKLs,rJK,a,mrIKLs", }, - { "=a", "0", "rm", }, - { "=m,r", "%0,0", "dn,rmn", }, - { "+m,d", "dn,rmn", }, - { "+m,d", "dn,rmn", }, - { "=m,d", "%0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "", "", "", }, - { "=x,y", "%xH,y", "xH,dmF", }, - { "=f", "%0", "fmG", }, - { "", "", "", }, - { "=x,y", "%xH,y", "xH,rmF", }, - { "=f", "%0", "fdmF", }, - { "=m,r,!a,?d", "0,0,a,mrIKs", "dIKs,mrIKs,J,0", }, - { "=a", "0", "rm", }, - { "=m,r", "0,0", "dn,rmn", }, - { "+m,d", "dn,rmn", }, - { "=m,d", "0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "", "", "", }, - { "=x,y,y", "xH,y,dmF", "xH,dmF,0", }, - { "=f", "0", "fmG", }, - { "", "", "", }, - { "=x,y,y", "xH,y,rmF", "xH,rmF,0", }, - { "=f", "0", "fdmF", }, - { "=d", "%0", "dmn", }, - { "=d", "%0", "dm", }, - { "=d", "%0", "n", }, - { "=d", "%0", "dmsK", }, - { "=d", "%0", "dm", }, - { "=d", "%0", "n", }, - { "", "", "", }, - { "=d", "%0", "dm", "=d", }, - { "=d", "%0", "n", "=d", }, - { "", "", "", }, - { "=d", "%0", "dm", "=d", }, - { "=d", "%0", "n", "=d", }, - { "", "", "", }, - { "=x,y", "%xH,y", "xH,rmF", }, - { "=f", "%0", "fmG", }, - { "", "", "", }, - { "=x,y", "%xH,y", "xH,rmF", }, - { "=f", "%0", "fdmF", }, - { "=d", "0", "dmn", }, - { "=d", "0", "dm", }, - { "=d", "0", "n", }, - { "=d", "0", "dmn", }, - { "=d", "0", "dm", }, - { "=d", "0", "n", }, - { "", "", "", }, - { "=x,y,y", "xH,y,rmF", "xH,rmF,0", }, - { "=f", "0", "fmG", }, - { "", "", "", }, - { "=x,y,y", "xH,y,rmF", "xH,rmF,0", }, - { "=f", "0", "fdmF", }, - { "=d", "0", "dmn", }, - { "=d", "0", "dm", }, - { "=d", "0", "n", }, - { "=d", "0", "dmn", }, - { "=d", "0", "dm", }, - { "=d", "0", "n", }, - { "=d", "0", "dmsK", "=d", }, - { "=d", "0", "dmsK", "=d", }, - { "=m,d", "%0,0", "dKs,dmKs", }, - { "=m,d", "%0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "=m,d", "%0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "=m,d", "%0,0", "dKs,dmKs", }, - { "=m,d", "%0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "=m,d", "%0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "=do,m", "%0,0", "di,dKs", }, - { "=dm", "%0", "dn", }, - { "+dm", "dn", }, - { "+dm", "dn", }, - { "=dm", "%0", "dn", }, - { "+dm", "dn", }, - { "+dm", "dn", }, - { "=dm", "0", }, - { "=dm", "0", }, - { "+dm", }, - { "=dm", "0", }, - { "+dm", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=f,d", "fdmF,0", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=f,d", "fmF,0", }, - { "=f", "fm", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=f", "fdmF", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=f", "fmF", }, - { "=dm", "0", }, - { "=dm", "0", }, - { "+dm", }, - { "=dm", "0", }, - { "+dm", }, - { "=d", "0", "i", }, - { "=d", "0", "i", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "i", }, - { "=d", "0", "i", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "i", }, - { "=d", "0", "i", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "i", }, - { "=d", "0", "i", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "+o", "i", "i", "rmi", }, - { "+do", "i", "i", "d", }, - { "=rm", "o", "i", "i", }, - { "=&d", "do", "i", "i", }, - { "=rm", "o", "i", "i", }, - { "=d", "do", "i", "i", }, - { "=d,d", "o,d", "di,di", "di,di", }, - { "=d,d", "o,d", "di,di", "di,di", }, - { "+o,d", "di,di", "di,di", "i,i", }, - { "+o,d", "di,di", "di,di", }, - { "+o,d", "di,di", "di,di", }, - { "+o,d", "di,di", "di,di", "d,d", }, - { "=d", "d", "di", "di", }, - { "=d", "d", "di", "di", }, - { "+d", "di", "di", }, - { "+d", "di", "di", }, - { "+d", "di", "di", "d", }, - { "o", "di", "di", }, - { "d", "di", "di", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { "", }, - { "a", }, - { "r", }, - { "+g", }, - { "+g", }, - { "+g", }, - { "+g", }, - { "", "", }, - { "o", "g", }, - { "o", "g", }, - { "", "", "", }, - { "=rf", "o", "g", }, - { "=rf", "o", "g", }, - { "", "", "", }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { "p", }, - { "=a", "p", }, - { "=f", "ad", }, - { "n", "=m", "rmfF", }, - { "n", "=m", "g", }, - { "", "dami", }, - { "=d", "rmn", }, - { "+d", "", "", "", }, - { "+d", "", "", "", }, - { "=x,y,y", "%x,dmF,y", "xH,y,y", "xH,y,dmF", }, - { "=x,y,y", "%x,ydmF,y", "xH,y,ydmF", "xH,ydmF,ydmF", }, - { "=x,y,y", "xH,rmF,y", "%xH,y,y", "x,y,rmF", }, - { "=x,y,y", "xH,rmF,yrmF", "%xH,rmF,y", "x,y,yrmF", }, - { "=x,y,y", "%xH,y,y", "x,y,rmF", "xH,rmF,y", }, - { "=x,y,y", "%xH,rmF,y", "x,y,yrmF", "xH,rmF,yrmF", }, - { "=x,y,y", "%xH,y,y", "x,y,rmF", "xH,rmF,y", }, - { "=x,y,y", "%xH,rmF,y", "x,y,yrmF", "xH,rmF,yrmF", }, - { "=x,y,y", "xH,y,y", "x,y,rmF", "xH,rmF,y", }, - { "=x,y,y", "xH,rmF,y", "xH,y,y", "x,y,rmF", }, - { "=x,y,y", "xH,rmF,y", "x,y,yrmF", "xH,rmF,yrmF", }, - { "=x,y,y", "xH,rmF,yrmF", "xH,rmF,y", "x,y,yrmF", }, - { "fm", }, - { "f,mG", "fmG,f", }, - { "f,mG", "fmG,f", }, - { "=fm,f", "f,m", }, - { "=fm,f", "f,m", }, - { "=m,!r", "f,f", }, - { "=dm", "f", }, - { "=f", "dmi", }, - { "=f", "dmn", }, - { "=f", "dmn", }, - { "=f", "fFm", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "", "", "", }, - { "=f", "%0", "fmG", }, - { "", "", "", }, - { "=f", "0", "fmG", }, - { "", "", "", }, - { "=f", "%0", "fmG", }, - { "", "", "", }, - { "=f", "0", "fmG", }, - { "=f", "fmF", }, - { "=f", "fmF", }, - { "=f", "fm", }, - }; - -const enum machine_mode insn_operand_mode[][MAX_RECOG_OPERANDS] = - { - { DFmode, DFmode, }, - { DImode, DImode, }, - { SImode, }, - { HImode, }, - { QImode, }, - { SFmode, }, - { SFmode, SImode, }, - { SFmode, }, - { DFmode, }, - { DFmode, SImode, }, - { DFmode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, SImode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, SImode, }, - { SFmode, SFmode, }, - { QImode, SImode, }, - { SImode, SImode, }, - { QImode, SImode, }, - { SImode, SImode, }, - { QImode, SImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { SImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { XFmode, XFmode, }, - { XFmode, XFmode, }, - { XFmode, XFmode, }, - { DImode, DImode, }, - { SImode, SImode, }, - { QImode, SImode, }, - { QImode, HImode, }, - { HImode, SImode, }, - { SImode, HImode, }, - { HImode, QImode, }, - { SImode, QImode, }, - { SImode, HImode, }, - { HImode, QImode, }, - { SImode, QImode, }, - { SImode, HImode, }, - { HImode, QImode, }, - { SImode, QImode, }, - { DFmode, SFmode, }, - { DFmode, SFmode, }, - { DFmode, SFmode, }, - { SFmode, DFmode, }, - { SFmode, DFmode, }, - { SFmode, DFmode, }, - { SFmode, DFmode, }, - { SFmode, SImode, }, - { SFmode, SImode, }, - { SFmode, SImode, }, - { DFmode, SImode, }, - { DFmode, SImode, }, - { DFmode, SImode, }, - { SFmode, HImode, }, - { DFmode, HImode, }, - { SFmode, QImode, }, - { DFmode, QImode, }, - { SImode, DFmode, SImode, SImode, }, - { HImode, DFmode, SImode, SImode, }, - { QImode, DFmode, SImode, SImode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { QImode, SFmode, }, - { HImode, SFmode, }, - { SImode, SFmode, }, - { QImode, DFmode, }, - { HImode, DFmode, }, - { SImode, DFmode, }, - { SImode, SFmode, }, - { SImode, DFmode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, HImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, HImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { HImode, HImode, HImode, }, - { SImode, HImode, HImode, }, - { SImode, HImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, HImode, HImode, }, - { SImode, HImode, SImode, }, - { DImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { DImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { HImode, HImode, HImode, }, - { HImode, SImode, HImode, }, - { HImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, SImode, HImode, }, - { HImode, SImode, SImode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { HImode, HImode, HImode, }, - { HImode, SImode, HImode, }, - { HImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, SImode, HImode, }, - { HImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { HImode, }, - { QImode, QImode, }, - { QImode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { HImode, }, - { QImode, QImode, }, - { QImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { QImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, QImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, QImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, QImode, SImode, SImode, }, - { SImode, QImode, SImode, SImode, }, - { QImode, SImode, SImode, VOIDmode, }, - { QImode, SImode, SImode, }, - { QImode, SImode, SImode, }, - { QImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { QImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode, }, - { SImode, }, - { HImode, }, - { HImode, }, - { SImode, }, - { HImode, }, - { SImode, }, - { QImode, SImode, }, - { QImode, SImode, }, - { QImode, SImode, }, - { VOIDmode, QImode, SImode, }, - { VOIDmode, QImode, SImode, }, - { VOIDmode, QImode, SImode, }, - { VOIDmode, VOIDmode, VOIDmode, }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { SImode, }, - { SImode, QImode, }, - { VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, VOIDmode, VOIDmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { XFmode, }, - { XFmode, XFmode, }, - { XFmode, XFmode, }, - { XFmode, SFmode, }, - { XFmode, DFmode, }, - { DFmode, XFmode, }, - { SFmode, XFmode, }, - { XFmode, SImode, }, - { XFmode, HImode, }, - { XFmode, QImode, }, - { XFmode, XFmode, }, - { QImode, XFmode, }, - { HImode, XFmode, }, - { SImode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, }, - { XFmode, XFmode, }, - { XFmode, DFmode, }, - }; - -const char insn_operand_strict_low[][MAX_RECOG_OPERANDS] = - { - { 0, 0, }, - { 0, 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, 0, }, - { 0, }, - { 0, }, - { 0, 0, }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 1, 0, }, - { 0, 0, }, - { 1, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 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, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, }, - { 0, 0, }, - { 1, }, - { 0, 0, }, - { 1, }, - { 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, }, - { 1, }, - { 0, 0, }, - { 1, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - }; - -extern int push_operand (); -extern int general_operand (); -extern int nonimmediate_operand (); -extern int scratch_operand (); -extern int address_operand (); -extern int register_operand (); -extern int const_int_operand (); -extern int not_sp_operand (); -extern int immediate_operand (); -extern int memory_operand (); - -int (*const insn_operand_predicate[][MAX_RECOG_OPERANDS])() = - { - { push_operand, general_operand, }, - { push_operand, general_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { general_operand, }, - { general_operand, scratch_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, scratch_operand, }, - { general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, scratch_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, scratch_operand, }, - { general_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, nonimmediate_operand, }, - { nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, }, - { push_operand, address_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, register_operand, scratch_operand, scratch_operand, }, - { general_operand, register_operand, scratch_operand, scratch_operand, }, - { general_operand, register_operand, scratch_operand, scratch_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, const_int_operand, }, - { register_operand, register_operand, nonimmediate_operand, }, - { register_operand, register_operand, nonimmediate_operand, register_operand, }, - { register_operand, register_operand, const_int_operand, register_operand, }, - { register_operand, register_operand, nonimmediate_operand, }, - { register_operand, register_operand, nonimmediate_operand, register_operand, }, - { register_operand, register_operand, const_int_operand, register_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, general_operand, }, - { not_sp_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, }, - { general_operand, general_operand, }, - { general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, }, - { general_operand, general_operand, }, - { general_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { nonimmediate_operand, immediate_operand, immediate_operand, general_operand, }, - { nonimmediate_operand, immediate_operand, immediate_operand, general_operand, }, - { general_operand, nonimmediate_operand, immediate_operand, immediate_operand, }, - { general_operand, nonimmediate_operand, immediate_operand, immediate_operand, }, - { general_operand, nonimmediate_operand, immediate_operand, immediate_operand, }, - { general_operand, nonimmediate_operand, immediate_operand, immediate_operand, }, - { general_operand, nonimmediate_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, immediate_operand, }, - { nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, general_operand, }, - { memory_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0, }, - { register_operand, }, - { register_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { memory_operand, general_operand, }, - { memory_operand, general_operand, }, - { memory_operand, general_operand, }, - { 0, memory_operand, general_operand, }, - { 0, memory_operand, general_operand, }, - { 0, memory_operand, general_operand, }, - { 0, 0, 0, }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { address_operand, }, - { general_operand, address_operand, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { nonimmediate_operand, }, - { general_operand, general_operand, }, - { nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - }; - -const int insn_n_alternatives[] = - { - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 3, - 4, - 3, - 0, - 2, - 2, - 0, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 4, - 1, - 1, - 5, - 1, - 6, - 8, - 0, - 5, - 3, - 7, - 1, - 2, - 2, - 2, - 0, - 0, - 0, - 2, - 2, - 2, - 2, - 1, - 1, - 0, - 2, - 2, - 0, - 2, - 1, - 1, - 0, - 2, - 1, - 0, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 4, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 0, - 2, - 1, - 0, - 2, - 1, - 4, - 1, - 2, - 2, - 2, - 2, - 0, - 3, - 1, - 0, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 2, - 1, - 0, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 3, - 1, - 0, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 2, - 2, - 0, - 2, - 2, - 1, - 0, - 2, - 1, - 0, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 1, - 2, - 2, - 2, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 1, - 1, - 1, - }; diff --git a/gnu/usr.bin/gcc2/arch/da30/insn-peep.c b/gnu/usr.bin/gcc2/arch/da30/insn-peep.c deleted file mode 100644 index ac2cb51fdd8e..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/insn-peep.c +++ /dev/null @@ -1,410 +0,0 @@ -/* Generated automatically by the program `genpeep' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "regs.h" -#include "output.h" -#include "real.h" - -extern rtx peep_operand[]; - -#define operands peep_operand - -rtx -peephole (ins1) - rtx ins1; -{ - rtx insn, x, pat; - int i; - - if (NEXT_INSN (ins1) - && GET_CODE (NEXT_INSN (ins1)) == BARRIER) - return 0; - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L299; - x = XEXP (pat, 0); - if (GET_CODE (x) != REG) goto L299; - if (GET_MODE (x) != SImode) goto L299; - if (XINT (x, 0) != 15) goto L299; - x = XEXP (pat, 1); - if (GET_CODE (x) != PLUS) goto L299; - if (GET_MODE (x) != SImode) goto L299; - x = XEXP (XEXP (pat, 1), 0); - if (GET_CODE (x) != REG) goto L299; - if (GET_MODE (x) != SImode) goto L299; - if (XINT (x, 0) != 15) goto L299; - x = XEXP (XEXP (pat, 1), 1); - if (GET_CODE (x) != CONST_INT) goto L299; - if (XWINT (x, 0) != 4) goto L299; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L299; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L299; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L299; - x = XEXP (pat, 0); - operands[0] = x; - if (! register_operand (x, DFmode)) goto L299; - x = XEXP (pat, 1); - operands[1] = x; - if (! register_operand (x, DFmode)) goto L299; - if (! (FP_REG_P (operands[0]) && ! FP_REG_P (operands[1]))) goto L299; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (2, operands)); - INSN_CODE (ins1) = 299; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L299: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L300; - x = XEXP (pat, 0); - if (GET_CODE (x) != REG) goto L300; - if (GET_MODE (x) != SImode) goto L300; - if (XINT (x, 0) != 15) goto L300; - x = XEXP (pat, 1); - if (GET_CODE (x) != PLUS) goto L300; - if (GET_MODE (x) != SImode) goto L300; - x = XEXP (XEXP (pat, 1), 0); - if (GET_CODE (x) != REG) goto L300; - if (GET_MODE (x) != SImode) goto L300; - if (XINT (x, 0) != 15) goto L300; - x = XEXP (XEXP (pat, 1), 1); - operands[0] = x; - if (! immediate_operand (x, SImode)) goto L300; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L300; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L300; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L300; - x = XEXP (pat, 0); - operands[1] = x; - if (! push_operand (x, SFmode)) goto L300; - x = XEXP (pat, 1); - operands[2] = x; - if (! general_operand (x, SFmode)) goto L300; - if (! (GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) >= 4 - && ! reg_mentioned_p (stack_pointer_rtx, operands[2]))) goto L300; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (3, operands)); - INSN_CODE (ins1) = 300; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L300: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L301; - x = XEXP (pat, 0); - if (GET_CODE (x) != REG) goto L301; - if (GET_MODE (x) != SImode) goto L301; - if (XINT (x, 0) != 15) goto L301; - x = XEXP (pat, 1); - if (GET_CODE (x) != PLUS) goto L301; - if (GET_MODE (x) != SImode) goto L301; - x = XEXP (XEXP (pat, 1), 0); - if (GET_CODE (x) != REG) goto L301; - if (GET_MODE (x) != SImode) goto L301; - if (XINT (x, 0) != 15) goto L301; - x = XEXP (XEXP (pat, 1), 1); - operands[0] = x; - if (! immediate_operand (x, SImode)) goto L301; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L301; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L301; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L301; - x = XEXP (pat, 0); - operands[1] = x; - if (! push_operand (x, SImode)) goto L301; - x = XEXP (pat, 1); - operands[2] = x; - if (! general_operand (x, SImode)) goto L301; - if (! (GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) >= 4 - && ! reg_mentioned_p (stack_pointer_rtx, operands[2]))) goto L301; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (3, operands)); - INSN_CODE (ins1) = 301; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L301: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L302; - x = XEXP (pat, 0); - if (GET_CODE (x) != MEM) goto L302; - if (GET_MODE (x) != QImode) goto L302; - x = XEXP (XEXP (pat, 0), 0); - if (GET_CODE (x) != PRE_DEC) goto L302; - if (GET_MODE (x) != SImode) goto L302; - x = XEXP (XEXP (XEXP (pat, 0), 0), 0); - if (GET_CODE (x) != REG) goto L302; - if (GET_MODE (x) != SImode) goto L302; - if (XINT (x, 0) != 15) goto L302; - x = XEXP (pat, 1); - operands[1] = x; - if (! general_operand (x, QImode)) goto L302; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L302; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L302; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L302; - x = XEXP (pat, 0); - if (GET_CODE (x) != REG) goto L302; - if (GET_MODE (x) != SImode) goto L302; - if (XINT (x, 0) != 15) goto L302; - x = XEXP (pat, 1); - if (GET_CODE (x) != MINUS) goto L302; - if (GET_MODE (x) != SImode) goto L302; - x = XEXP (XEXP (pat, 1), 0); - if (GET_CODE (x) != REG) goto L302; - if (GET_MODE (x) != SImode) goto L302; - if (XINT (x, 0) != 15) goto L302; - x = XEXP (XEXP (pat, 1), 1); - if (GET_CODE (x) != CONST_INT) goto L302; - if (XWINT (x, 0) != 2) goto L302; - if (! (! reg_mentioned_p (stack_pointer_rtx, operands[1]))) goto L302; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (2, operands)); - INSN_CODE (ins1) = 302; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L302: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L303; - x = XEXP (pat, 0); - operands[0] = x; - if (! register_operand (x, SImode)) goto L303; - x = XEXP (pat, 1); - if (GET_CODE (x) != CONST_INT) goto L303; - if (XWINT (x, 0) != 0) goto L303; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L303; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L303; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L303; - x = XEXP (pat, 0); - if (GET_CODE (x) != STRICT_LOW_PART) goto L303; - x = XEXP (XEXP (pat, 0), 0); - if (GET_CODE (x) != SUBREG) goto L303; - if (GET_MODE (x) != HImode) goto L303; - x = XEXP (XEXP (XEXP (pat, 0), 0), 0); - if (!rtx_equal_p (operands[0], x)) goto L303; - x = XEXP (XEXP (pat, 0), 0); - if (XINT (x, 1) != 0) goto L303; - x = XEXP (pat, 1); - operands[1] = x; - if (! general_operand (x, HImode)) goto L303; - if (! (strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0]))) goto L303; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (2, operands)); - INSN_CODE (ins1) = 303; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L303: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L304; - x = XEXP (pat, 0); - if (GET_CODE (x) != PC) goto L304; - x = XEXP (pat, 1); - if (GET_CODE (x) != IF_THEN_ELSE) goto L304; - x = XEXP (XEXP (pat, 1), 0); - operands[3] = x; - if (! valid_dbcc_comparison_p (x, VOIDmode)) goto L304; - x = XEXP (XEXP (XEXP (pat, 1), 0), 0); - if (GET_CODE (x) != CC0) goto L304; - x = XEXP (XEXP (XEXP (pat, 1), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L304; - if (XWINT (x, 0) != 0) goto L304; - x = XEXP (XEXP (pat, 1), 1); - if (GET_CODE (x) != LABEL_REF) goto L304; - x = XEXP (XEXP (XEXP (pat, 1), 1), 0); - operands[2] = x; - x = XEXP (XEXP (pat, 1), 2); - if (GET_CODE (x) != PC) goto L304; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L304; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L304; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != PARALLEL) goto L304; - if (XVECLEN (x, 0) != 2) goto L304; - x = XVECEXP (pat, 0, 0); - if (GET_CODE (x) != SET) goto L304; - x = XEXP (XVECEXP (pat, 0, 0), 0); - if (GET_CODE (x) != PC) goto L304; - x = XEXP (XVECEXP (pat, 0, 0), 1); - if (GET_CODE (x) != IF_THEN_ELSE) goto L304; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0); - if (GET_CODE (x) != GE) goto L304; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0); - if (GET_CODE (x) != PLUS) goto L304; - if (GET_MODE (x) != HImode) goto L304; - x = XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0), 0); - operands[0] = x; - if (! register_operand (x, HImode)) goto L304; - x = XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L304; - if (XWINT (x, 0) != -1) goto L304; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L304; - if (XWINT (x, 0) != 0) goto L304; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1); - if (GET_CODE (x) != LABEL_REF) goto L304; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0); - operands[1] = x; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 2); - if (GET_CODE (x) != PC) goto L304; - x = XVECEXP (pat, 0, 1); - if (GET_CODE (x) != SET) goto L304; - x = XEXP (XVECEXP (pat, 0, 1), 0); - if (!rtx_equal_p (operands[0], x)) goto L304; - x = XEXP (XVECEXP (pat, 0, 1), 1); - if (GET_CODE (x) != PLUS) goto L304; - if (GET_MODE (x) != HImode) goto L304; - x = XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - if (!rtx_equal_p (operands[0], x)) goto L304; - x = XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1); - if (GET_CODE (x) != CONST_INT) goto L304; - if (XWINT (x, 0) != -1) goto L304; - if (! (DATA_REG_P (operands[0]))) goto L304; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (4, operands)); - INSN_CODE (ins1) = 304; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L304: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L305; - x = XEXP (pat, 0); - if (GET_CODE (x) != PC) goto L305; - x = XEXP (pat, 1); - if (GET_CODE (x) != IF_THEN_ELSE) goto L305; - x = XEXP (XEXP (pat, 1), 0); - operands[3] = x; - if (! valid_dbcc_comparison_p (x, VOIDmode)) goto L305; - x = XEXP (XEXP (XEXP (pat, 1), 0), 0); - if (GET_CODE (x) != CC0) goto L305; - x = XEXP (XEXP (XEXP (pat, 1), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L305; - if (XWINT (x, 0) != 0) goto L305; - x = XEXP (XEXP (pat, 1), 1); - if (GET_CODE (x) != LABEL_REF) goto L305; - x = XEXP (XEXP (XEXP (pat, 1), 1), 0); - operands[2] = x; - x = XEXP (XEXP (pat, 1), 2); - if (GET_CODE (x) != PC) goto L305; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L305; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L305; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != PARALLEL) goto L305; - if (XVECLEN (x, 0) != 2) goto L305; - x = XVECEXP (pat, 0, 0); - if (GET_CODE (x) != SET) goto L305; - x = XEXP (XVECEXP (pat, 0, 0), 0); - if (GET_CODE (x) != PC) goto L305; - x = XEXP (XVECEXP (pat, 0, 0), 1); - if (GET_CODE (x) != IF_THEN_ELSE) goto L305; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0); - if (GET_CODE (x) != GE) goto L305; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0); - if (GET_CODE (x) != PLUS) goto L305; - if (GET_MODE (x) != SImode) goto L305; - x = XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0), 0); - operands[0] = x; - if (! register_operand (x, SImode)) goto L305; - x = XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L305; - if (XWINT (x, 0) != -1) goto L305; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L305; - if (XWINT (x, 0) != 0) goto L305; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1); - if (GET_CODE (x) != LABEL_REF) goto L305; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0); - operands[1] = x; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 2); - if (GET_CODE (x) != PC) goto L305; - x = XVECEXP (pat, 0, 1); - if (GET_CODE (x) != SET) goto L305; - x = XEXP (XVECEXP (pat, 0, 1), 0); - if (!rtx_equal_p (operands[0], x)) goto L305; - x = XEXP (XVECEXP (pat, 0, 1), 1); - if (GET_CODE (x) != PLUS) goto L305; - if (GET_MODE (x) != SImode) goto L305; - x = XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - if (!rtx_equal_p (operands[0], x)) goto L305; - x = XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1); - if (GET_CODE (x) != CONST_INT) goto L305; - if (XWINT (x, 0) != -1) goto L305; - if (! (DATA_REG_P (operands[0]))) goto L305; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (4, operands)); - INSN_CODE (ins1) = 305; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L305: - - return 0; -} - -rtx peep_operand[4]; diff --git a/gnu/usr.bin/gcc2/arch/da30/insn-recog.c b/gnu/usr.bin/gcc2/arch/da30/insn-recog.c deleted file mode 100644 index 1aea9785e4b5..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/insn-recog.c +++ /dev/null @@ -1,6589 +0,0 @@ -/* Generated automatically by the program `genrecog' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "insn-config.h" -#include "recog.h" -#include "real.h" -#include "output.h" -#include "flags.h" - - -/* `recog' contains a decision tree - that recognizes whether the rtx X0 is a valid instruction. - - recog returns -1 if the rtx is not valid. - If the rtx is valid, recog returns a nonnegative number - which is the insn code number for the pattern that matched. - This is the same as the order in the machine description of - the entry that matched. This number can be used as an index into - entry that matched. This number can be used as an index into various - insn_* tables, such as insn_templates, insn_outfun, and insn_n_operands - (found in insn-output.c). - - The third argument to recog is an optional pointer to an int. - If present, recog will accept a pattern if it matches except for - missing CLOBBER expressions at the end. In that case, the value - pointed to by the optional pointer will be set to the number of - CLOBBERs that need to be added (it should be initialized to zero by - the caller). If it is set nonzero, the caller should allocate a - PARALLEL of the appropriate size, copy the initial entries, and call - add_clobbers (found in insn-emit.c) to fill in the CLOBBERs.*/ - -rtx recog_operand[MAX_RECOG_OPERANDS]; - -rtx *recog_operand_loc[MAX_RECOG_OPERANDS]; - -rtx *recog_dup_loc[MAX_DUP_OPERANDS]; - -char recog_dup_num[MAX_DUP_OPERANDS]; - -#define operands recog_operand - -int -recog_1 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case HImode: - switch (GET_CODE (x1)) - { - case TRUNCATE: - goto L628; - case ZERO_EXTEND: - goto L208; - case SIGN_EXTEND: - goto L220; - case FIX: - goto L313; - case PLUS: - goto L386; - case MINUS: - goto L455; - case MULT: - goto L501; - case DIV: - goto L623; - case UDIV: - goto L641; - case MOD: - goto L683; - case UMOD: - goto L701; - case AND: - goto L746; - case IOR: - goto L785; - case XOR: - goto L824; - case NEG: - goto L862; - case NOT: - goto L928; - } - } - if (general_operand (x1, HImode)) - { - ro[1] = x1; - return 30; - } - goto ret0; - - L628: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - switch (GET_CODE (x2)) - { - case DIV: - goto L629; - case UDIV: - goto L647; - case MOD: - goto L689; - case UMOD: - goto L707; - } - } - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 43; - } - goto ret0; - - L629: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L630; - } - goto ret0; - - L630: - x3 = XEXP (x2, 1); - switch (GET_CODE (x3)) - { - case SIGN_EXTEND: - if (GET_MODE (x3) == SImode && 1) - goto L631; - break; - case CONST_INT: - ro[2] = x3; - return 129; - } - goto ret0; - - L631: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, HImode)) - { - ro[2] = x4; - return 128; - } - goto ret0; - - L647: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L648; - } - goto ret0; - - L648: - x3 = XEXP (x2, 1); - switch (GET_CODE (x3)) - { - case ZERO_EXTEND: - if (GET_MODE (x3) == SImode && 1) - goto L649; - break; - case CONST_INT: - ro[2] = x3; - return 132; - } - goto ret0; - - L649: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, HImode)) - { - ro[2] = x4; - return 131; - } - goto ret0; - - L689: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L690; - } - goto ret0; - - L690: - x3 = XEXP (x2, 1); - switch (GET_CODE (x3)) - { - case SIGN_EXTEND: - if (GET_MODE (x3) == SImode && 1) - goto L691; - break; - case CONST_INT: - ro[2] = x3; - return 141; - } - goto ret0; - - L691: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, HImode)) - { - ro[2] = x4; - return 140; - } - goto ret0; - - L707: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L708; - } - goto ret0; - - L708: - x3 = XEXP (x2, 1); - switch (GET_CODE (x3)) - { - case ZERO_EXTEND: - if (GET_MODE (x3) == SImode && 1) - goto L709; - break; - case CONST_INT: - ro[2] = x3; - return 144; - } - goto ret0; - - L709: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, HImode)) - { - ro[2] = x4; - return 143; - } - goto ret0; - - L208: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 48; - } - goto ret0; - - L220: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - return 51; - } - goto ret0; - - L313: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == FIX && 1) - goto L314; - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 76; - } - L357: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 79; - } - goto ret0; - - L314: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && register_operand (x3, DFmode)) - { - ro[1] = x3; - if (TARGET_68040) - { - *pnum_clobbers = 2; - return 71; - } - } - goto ret0; - - L386: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L387; - } - goto ret0; - - L387: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 85; - } - goto ret0; - - L455: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L456; - } - goto ret0; - - L456: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 99; - } - goto ret0; - - L501: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L502; - } - goto ret0; - - L502: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 109; - } - goto ret0; - - L623: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L624; - } - goto ret0; - - L624: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 127; - } - goto ret0; - - L641: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L642; - } - goto ret0; - - L642: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 130; - } - goto ret0; - - L683: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L684; - } - goto ret0; - - L684: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 139; - } - goto ret0; - - L701: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L702; - } - goto ret0; - - L702: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 142; - } - goto ret0; - - L746: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L747; - } - goto ret0; - - L747: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 148; - } - goto ret0; - - L785: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L786; - } - goto ret0; - - L786: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 155; - } - goto ret0; - - L824: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L825; - } - goto ret0; - - L825: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 162; - } - goto ret0; - - L862: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 169; - } - goto ret0; - - L928: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 187; - } - goto ret0; - ret0: return -1; -} - -int -recog_2 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case QImode: - switch (GET_CODE (x1)) - { - case TRUNCATE: - goto L192; - case FIX: - goto L328; - case PLUS: - goto L403; - case MINUS: - goto L466; - case AND: - goto L763; - case IOR: - goto L802; - case XOR: - goto L841; - case NEG: - goto L871; - case NOT: - goto L937; - case EQ: - goto L1275; - case NE: - goto L1280; - case GT: - goto L1285; - case GTU: - goto L1290; - case LT: - goto L1295; - case LTU: - goto L1300; - case GE: - goto L1305; - case GEU: - goto L1310; - case LE: - goto L1315; - case LEU: - goto L1320; - } - } - if (general_operand (x1, QImode)) - { - ro[1] = x1; - return 32; - } - goto ret0; - - L192: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 41; - } - L196: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 42; - } - goto ret0; - - L328: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == FIX && 1) - goto L329; - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 75; - } - L353: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 78; - } - goto ret0; - - L329: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && register_operand (x3, DFmode)) - { - ro[1] = x3; - if (TARGET_68040) - { - *pnum_clobbers = 2; - return 72; - } - } - goto ret0; - - L403: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L404; - } - goto ret0; - - L404: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 88; - } - goto ret0; - - L466: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L467; - } - goto ret0; - - L467: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 101; - } - goto ret0; - - L763: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L764; - } - goto ret0; - - L764: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 151; - } - goto ret0; - - L802: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L803; - } - goto ret0; - - L803: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 158; - } - goto ret0; - - L841: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L842; - } - goto ret0; - - L842: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 165; - } - goto ret0; - - L871: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 171; - } - goto ret0; - - L937: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 189; - } - goto ret0; - - L1275: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1276; - goto ret0; - - L1276: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 248; - goto ret0; - - L1280: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1281; - goto ret0; - - L1281: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 249; - goto ret0; - - L1285: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1286; - goto ret0; - - L1286: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 250; - goto ret0; - - L1290: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1291; - goto ret0; - - L1291: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 251; - goto ret0; - - L1295: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1296; - goto ret0; - - L1296: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 252; - goto ret0; - - L1300: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1301; - goto ret0; - - L1301: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 253; - goto ret0; - - L1305: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1306; - goto ret0; - - L1306: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 254; - goto ret0; - - L1310: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1311; - goto ret0; - - L1311: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 255; - goto ret0; - - L1315: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1316; - goto ret0; - - L1316: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 256; - goto ret0; - - L1320: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1321; - goto ret0; - - L1321: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 257; - goto ret0; - ret0: return -1; -} - -int -recog_3 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != SImode) - goto ret0; - switch (GET_CODE (x1)) - { - case PLUS: - goto L375; - case MINUS: - goto L444; - case MULT: - goto L506; - case IOR: - goto L780; - case XOR: - goto L819; - case NEG: - goto L858; - case NOT: - goto L924; - case ZERO_EXTRACT: - goto L1168; - case SIGN_EXTRACT: - goto L1180; - } - goto ret0; - - L375: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L381; - } - goto ret0; - - L381: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == SIGN_EXTEND && 1) - goto L382; - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 83; - } - goto ret0; - - L382: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[2] = x3; - return 84; - } - goto ret0; - - L444: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L450; - } - goto ret0; - - L450: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == SIGN_EXTEND && 1) - goto L451; - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 97; - } - goto ret0; - - L451: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[2] = x3; - return 98; - } - goto ret0; - - L506: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - switch (GET_CODE (x2)) - { - case SIGN_EXTEND: - goto L507; - case ZERO_EXTEND: - goto L525; - } - } - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L520; - } - goto ret0; - - L507: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[1] = x3; - goto L508; - } - goto ret0; - - L508: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case SIGN_EXTEND: - if (GET_MODE (x2) == SImode && 1) - goto L509; - break; - case CONST_INT: - ro[2] = x2; - if (INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff) - return 111; - } - goto ret0; - - L509: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[2] = x3; - return 110; - } - goto ret0; - - L525: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[1] = x3; - goto L526; - } - goto ret0; - - L526: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case ZERO_EXTEND: - if (GET_MODE (x2) == SImode && 1) - goto L527; - break; - case CONST_INT: - ro[2] = x2; - if (INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff) - return 114; - } - goto ret0; - - L527: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[2] = x3; - return 113; - } - goto ret0; - - L520: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - if (TARGET_68020) - return 112; - } - goto ret0; - - L780: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L781; - } - goto ret0; - - L781: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 154; - } - goto ret0; - - L819: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L820; - } - goto ret0; - - L820: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 161; - } - goto ret0; - - L858: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 168; - } - goto ret0; - - L924: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 186; - } - goto ret0; - - L1168: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - goto L1169; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[1] = x2; - goto L1175; - } - } - goto ret0; - - L1169: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1170; - } - L1199: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1200; - } - goto ret0; - - L1170: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 32) - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[1], 0))) - return 231; - } - x2 = XEXP (x1, 1); - goto L1199; - - L1200: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD) - return 236; - } - goto ret0; - - L1175: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1176; - } - L1240: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1241; - } - goto ret0; - - L1176: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16) - && GET_CODE (operands[3]) == CONST_INT - && INTVAL (operands[3]) % INTVAL (operands[2]) == 0 - && (GET_CODE (operands[1]) == REG - || ! mode_dependent_address_p (XEXP (operands[1], 0)))) - return 232; - } - x2 = XEXP (x1, 1); - goto L1240; - - L1241: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD) - return 242; - } - goto ret0; - - L1180: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - goto L1181; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[1] = x2; - goto L1187; - } - } - goto ret0; - - L1181: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1182; - } - L1193: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1194; - } - goto ret0; - - L1182: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 32) - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[1], 0))) - return 233; - } - x2 = XEXP (x1, 1); - goto L1193; - - L1194: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD) - return 235; - } - goto ret0; - - L1187: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1188; - } - L1234: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1235; - } - goto ret0; - - L1188: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16) - && GET_CODE (operands[3]) == CONST_INT - && INTVAL (operands[3]) % INTVAL (operands[2]) == 0 - && (GET_CODE (operands[1]) == REG - || ! mode_dependent_address_p (XEXP (operands[1], 0)))) - return 234; - } - x2 = XEXP (x1, 1); - goto L1234; - - L1235: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD) - return 241; - } - goto ret0; - ret0: return -1; -} - -int -recog_4 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (general_operand (x2, HImode)) - { - ro[0] = x2; - goto L391; - } - L967: - if (register_operand (x2, HImode)) - { - ro[0] = x2; - goto L968; - } - break; - case QImode: - if (general_operand (x2, QImode)) - { - ro[0] = x2; - goto L408; - } - L978: - if (register_operand (x2, QImode)) - { - ro[0] = x2; - goto L979; - } - } - goto ret0; - - L391: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case HImode: - switch (GET_CODE (x1)) - { - case PLUS: - goto L392; - case MINUS: - goto L461; - case AND: - goto L752; - case IOR: - goto L791; - case XOR: - goto L830; - case NEG: - goto L867; - case NOT: - goto L933; - } - } - if (general_operand (x1, HImode)) - { - ro[1] = x1; - return 31; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L392: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L393; - L398: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L399; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L393: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 86; - } - x2 = XEXP (x1, 0); - goto L398; - - L399: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 87; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L461: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L462; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L462: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 100; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L752: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L753; - L758: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L759; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L753: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 149; - } - x2 = XEXP (x1, 0); - goto L758; - - L759: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 150; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L791: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L792; - L797: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L798; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L792: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 156; - } - x2 = XEXP (x1, 0); - goto L797; - - L798: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 157; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L830: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L831; - L836: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L837; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L831: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 163; - } - x2 = XEXP (x1, 0); - goto L836; - - L837: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 164; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L867: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - return 170; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L933: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - return 188; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L968: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != HImode) - goto ret0; - switch (GET_CODE (x1)) - { - case ASHIFT: - goto L969; - case ASHIFTRT: - goto L1008; - case LSHIFT: - goto L1047; - case LSHIFTRT: - goto L1086; - case ROTATE: - goto L1113; - case ROTATERT: - goto L1140; - } - goto ret0; - - L969: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L970; - goto ret0; - - L970: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 195; - } - goto ret0; - - L1008: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1009; - goto ret0; - - L1009: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 202; - } - goto ret0; - - L1047: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1048; - goto ret0; - - L1048: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 209; - } - goto ret0; - - L1086: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1087; - goto ret0; - - L1087: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 216; - } - goto ret0; - - L1113: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1114; - goto ret0; - - L1114: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 221; - } - goto ret0; - - L1140: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1141; - goto ret0; - - L1141: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 226; - } - goto ret0; - - L408: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case QImode: - switch (GET_CODE (x1)) - { - case PLUS: - goto L409; - case MINUS: - goto L472; - case AND: - goto L769; - case IOR: - goto L808; - case XOR: - goto L847; - case NEG: - goto L876; - case NOT: - goto L942; - } - } - if (general_operand (x1, QImode)) - { - ro[1] = x1; - return 33; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L409: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L410; - L415: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L416; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L410: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 89; - } - x2 = XEXP (x1, 0); - goto L415; - - L416: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 90; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L472: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L473; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L473: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 102; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L769: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L770; - L775: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L776; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L770: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 152; - } - x2 = XEXP (x1, 0); - goto L775; - - L776: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 153; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L808: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L809; - L814: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L815; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L809: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 159; - } - x2 = XEXP (x1, 0); - goto L814; - - L815: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 160; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L847: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L848; - L853: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L854; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L848: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 166; - } - x2 = XEXP (x1, 0); - goto L853; - - L854: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 167; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L876: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - return 172; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L942: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - return 190; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L979: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != QImode) - goto ret0; - switch (GET_CODE (x1)) - { - case ASHIFT: - goto L980; - case ASHIFTRT: - goto L1019; - case LSHIFT: - goto L1058; - case LSHIFTRT: - goto L1097; - case ROTATE: - goto L1124; - case ROTATERT: - goto L1151; - } - goto ret0; - - L980: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L981; - goto ret0; - - L981: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 197; - } - goto ret0; - - L1019: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1020; - goto ret0; - - L1020: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 204; - } - goto ret0; - - L1058: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1059; - goto ret0; - - L1059: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 211; - } - goto ret0; - - L1097: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1098; - goto ret0; - - L1098: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 218; - } - goto ret0; - - L1124: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1125; - goto ret0; - - L1125: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 223; - } - goto ret0; - - L1151: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1152; - goto ret0; - - L1152: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 228; - } - goto ret0; - ret0: return -1; -} - -int -recog_5 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - x2 = XEXP (x1, 0); - switch (GET_CODE (x2)) - { - case EQ: - goto L1326; - case NE: - goto L1335; - case GT: - goto L1344; - case GTU: - goto L1353; - case LT: - goto L1362; - case LTU: - goto L1371; - case GE: - goto L1380; - case GEU: - goto L1389; - case LE: - goto L1398; - case LEU: - goto L1407; - } - goto ret0; - - L1326: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1327; - goto ret0; - - L1327: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1328; - goto ret0; - - L1328: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1329; - case PC: - goto L1419; - } - goto ret0; - - L1329: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1330; - - L1330: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 258; - goto ret0; - - L1419: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1420; - goto ret0; - - L1420: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 268; - - L1335: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1336; - goto ret0; - - L1336: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1337; - goto ret0; - - L1337: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1338; - case PC: - goto L1428; - } - goto ret0; - - L1338: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1339; - - L1339: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 259; - goto ret0; - - L1428: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1429; - goto ret0; - - L1429: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 269; - - L1344: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1345; - goto ret0; - - L1345: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1346; - goto ret0; - - L1346: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1347; - case PC: - goto L1437; - } - goto ret0; - - L1347: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1348; - - L1348: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 260; - goto ret0; - - L1437: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1438; - goto ret0; - - L1438: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 270; - - L1353: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1354; - goto ret0; - - L1354: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1355; - goto ret0; - - L1355: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1356; - case PC: - goto L1446; - } - goto ret0; - - L1356: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1357; - - L1357: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 261; - goto ret0; - - L1446: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1447; - goto ret0; - - L1447: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 271; - - L1362: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1363; - goto ret0; - - L1363: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1364; - goto ret0; - - L1364: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1365; - case PC: - goto L1455; - } - goto ret0; - - L1365: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1366; - - L1366: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 262; - goto ret0; - - L1455: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1456; - goto ret0; - - L1456: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 272; - - L1371: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1372; - goto ret0; - - L1372: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1373; - goto ret0; - - L1373: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1374; - case PC: - goto L1464; - } - goto ret0; - - L1374: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1375; - - L1375: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 263; - goto ret0; - - L1464: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1465; - goto ret0; - - L1465: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 273; - - L1380: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1381; - goto ret0; - - L1381: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1382; - goto ret0; - - L1382: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1383; - case PC: - goto L1473; - } - goto ret0; - - L1383: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1384; - - L1384: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 264; - goto ret0; - - L1473: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1474; - goto ret0; - - L1474: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 274; - - L1389: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1390; - goto ret0; - - L1390: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1391; - goto ret0; - - L1391: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1392; - case PC: - goto L1482; - } - goto ret0; - - L1392: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1393; - - L1393: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 265; - goto ret0; - - L1482: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1483; - goto ret0; - - L1483: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 275; - - L1398: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1399; - goto ret0; - - L1399: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1400; - goto ret0; - - L1400: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1401; - case PC: - goto L1491; - } - goto ret0; - - L1401: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1402; - - L1402: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 266; - goto ret0; - - L1491: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1492; - goto ret0; - - L1492: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 276; - - L1407: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1408; - goto ret0; - - L1408: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1409; - goto ret0; - - L1409: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1410; - case PC: - goto L1500; - } - goto ret0; - - L1410: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1411; - - L1411: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 267; - goto ret0; - - L1500: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1501; - goto ret0; - - L1501: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 277; - ret0: return -1; -} - -int -recog_6 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 0); - switch (GET_MODE (x1)) - { - case DFmode: - if (GET_CODE (x1) == MEM && push_operand (x1, DFmode)) - { - ro[0] = x1; - goto L2; - } - L173: - if (general_operand (x1, DFmode)) - { - ro[0] = x1; - goto L227; - } - break; - case DImode: - if (GET_CODE (x1) == MEM && push_operand (x1, DImode)) - { - ro[0] = x1; - goto L5; - } - L184: - if (general_operand (x1, DImode)) - { - ro[0] = x1; - goto L185; - } - break; - case SImode: - if (GET_CODE (x1) == MEM && push_operand (x1, SImode)) - { - ro[0] = x1; - goto L148; - } - L150: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - goto L203; - } - break; - case HImode: - if (general_operand (x1, HImode)) - { - ro[0] = x1; - goto L199; - } - L961: - if (register_operand (x1, HImode)) - { - ro[0] = x1; - goto L962; - } - break; - case QImode: - if (general_operand (x1, QImode)) - { - ro[0] = x1; - goto L191; - } - L972: - if (register_operand (x1, QImode)) - { - ro[0] = x1; - goto L973; - } - break; - case SFmode: - if (general_operand (x1, SFmode)) - { - ro[0] = x1; - goto L237; - } - break; - case XFmode: - if (nonimmediate_operand (x1, XFmode)) - { - ro[0] = x1; - goto L177; - } - } - L187: - switch (GET_MODE (x1)) - { - case SImode: - switch (GET_CODE (x1)) - { - case MEM: - if (push_operand (x1, SImode)) - { - ro[0] = x1; - goto L188; - } - break; - case ZERO_EXTRACT: - goto L1155; - } - L373: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - goto L374; - } - L739: - if (not_sp_operand (x1, SImode)) - { - ro[0] = x1; - goto L740; - } - L944: - if (register_operand (x1, SImode)) - { - ro[0] = x1; - goto L945; - } - } - switch (GET_CODE (x1)) - { - case CC0: - goto L8; - case STRICT_LOW_PART: - goto L160; - case PC: - goto L1324; - } - L1595: - ro[0] = x1; - goto L1596; - L1612: - switch (GET_CODE (x1)) - { - case PC: - goto L1613; - case CC0: - goto L1703; - } - switch (GET_MODE (x1)) - { - case SImode: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - goto L1751; - } - break; - case DFmode: - if (register_operand (x1, DFmode)) - { - ro[0] = x1; - goto L1619; - } - L1718: - if (general_operand (x1, DFmode)) - { - ro[0] = x1; - goto L1719; - } - break; - case SFmode: - if (register_operand (x1, SFmode)) - { - ro[0] = x1; - goto L1626; - } - L1722: - if (general_operand (x1, SFmode)) - { - ro[0] = x1; - goto L1723; - } - break; - case XFmode: - if (general_operand (x1, XFmode)) - { - ro[0] = x1; - goto L1711; - } - break; - case QImode: - if (general_operand (x1, QImode)) - { - ro[0] = x1; - goto L1743; - } - break; - case HImode: - if (general_operand (x1, HImode)) - { - ro[0] = x1; - goto L1747; - } - } - goto ret0; - - L2: - x1 = XEXP (x0, 1); - if (general_operand (x1, DFmode)) - { - ro[1] = x1; - return 0; - } - x1 = XEXP (x0, 0); - goto L173; - - L227: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case DFmode: - switch (GET_CODE (x1)) - { - case FLOAT_EXTEND: - goto L228; - case FLOAT: - goto L262; - case FIX: - goto L333; - case PLUS: - goto L420; - case MINUS: - goto L477; - case MULT: - goto L599; - case DIV: - goto L659; - case NEG: - goto L890; - case SQRT: - goto L900; - case ABS: - goto L914; - } - } - if (general_operand (x1, DFmode)) - { - ro[1] = x1; - return 35; - } - x1 = XEXP (x0, 0); - goto L1595; - - L228: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - goto L233; - x1 = XEXP (x0, 0); - goto L1595; - - L233: - ro[1] = x2; - if (TARGET_FPA) - return 54; - L234: - ro[1] = x2; - if (TARGET_68881) - return 55; - x1 = XEXP (x0, 0); - goto L1595; - - L262: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - goto L267; - L276: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 67; - } - L284: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 69; - } - x1 = XEXP (x0, 0); - goto L1595; - - L267: - ro[1] = x2; - if (TARGET_FPA) - return 64; - L268: - ro[1] = x2; - if (TARGET_68881) - return 65; - goto L276; - - L333: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881 && !TARGET_68040) - return 73; - } - x1 = XEXP (x0, 0); - goto L1595; - - L420: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L421; - } - x1 = XEXP (x0, 0); - goto L1595; - - L421: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - goto L427; - x1 = XEXP (x0, 0); - goto L1595; - - L427: - ro[2] = x2; - if (TARGET_FPA) - return 92; - L428: - ro[2] = x2; - if (TARGET_68881) - return 93; - x1 = XEXP (x0, 0); - goto L1595; - - L477: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L478; - } - x1 = XEXP (x0, 0); - goto L1595; - - L478: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - goto L484; - x1 = XEXP (x0, 0); - goto L1595; - - L484: - ro[2] = x2; - if (TARGET_FPA) - return 104; - L485: - ro[2] = x2; - if (TARGET_68881) - return 105; - x1 = XEXP (x0, 0); - goto L1595; - - L599: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L600; - } - x1 = XEXP (x0, 0); - goto L1595; - - L600: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - goto L606; - x1 = XEXP (x0, 0); - goto L1595; - - L606: - ro[2] = x2; - if (TARGET_FPA) - return 122; - L607: - ro[2] = x2; - if (TARGET_68881) - return 123; - x1 = XEXP (x0, 0); - goto L1595; - - L659: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L660; - } - x1 = XEXP (x0, 0); - goto L1595; - - L660: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - goto L666; - x1 = XEXP (x0, 0); - goto L1595; - - L666: - ro[2] = x2; - if (TARGET_FPA) - return 134; - L667: - ro[2] = x2; - if (TARGET_68881) - return 135; - x1 = XEXP (x0, 0); - goto L1595; - - L890: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - goto L895; - x1 = XEXP (x0, 0); - goto L1595; - - L895: - ro[1] = x2; - if (TARGET_FPA) - return 177; - L896: - ro[1] = x2; - if (TARGET_68881) - return 178; - x1 = XEXP (x0, 0); - goto L1595; - - L900: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 179; - } - x1 = XEXP (x0, 0); - goto L1595; - - L914: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - goto L919; - x1 = XEXP (x0, 0); - goto L1595; - - L919: - ro[1] = x2; - if (TARGET_FPA) - return 184; - L920: - ro[1] = x2; - if (TARGET_68881) - return 185; - x1 = XEXP (x0, 0); - goto L1595; - - L5: - x1 = XEXP (x0, 1); - if (general_operand (x1, DImode)) - { - ro[1] = x1; - return 1; - } - x1 = XEXP (x0, 0); - goto L184; - - L185: - x1 = XEXP (x0, 1); - if (general_operand (x1, DImode)) - { - ro[1] = x1; - return 39; - } - x1 = XEXP (x0, 0); - goto L1595; - - L148: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - { - ro[1] = x1; - if (GET_CODE (operands[1]) == CONST_INT - && INTVAL (operands[1]) >= -0x8000 - && INTVAL (operands[1]) < 0x8000) - return 26; - } - x1 = XEXP (x0, 0); - goto L150; - - L203: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case SImode: - switch (GET_CODE (x1)) - { - case ZERO_EXTEND: - goto L204; - case SIGN_EXTEND: - goto L216; - case FIX: - goto L298; - } - } - if (GET_CODE (x1) == CONST_INT && XWINT (x1, 0) == 0 && 1) - if ((TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))) - return 27; - L154: - if (general_operand (x1, SImode)) - { - ro[1] = x1; - return 29; - } - x1 = XEXP (x0, 0); - goto L187; - - L204: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 47; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 49; - } - } - x1 = XEXP (x0, 0); - goto L187; - - L216: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[1] = x2; - return 50; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - if (TARGET_68020) - return 52; - } - } - x1 = XEXP (x0, 0); - goto L187; - - L298: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - switch (GET_CODE (x2)) - { - case FIX: - goto L299; - } - break; - case SFmode: - if (GET_CODE (x2) == FIX && 1) - goto L366; - } - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 77; - } - L361: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 80; - } - x1 = XEXP (x0, 0); - goto L187; - - L299: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && register_operand (x3, DFmode)) - { - ro[1] = x3; - if (TARGET_68040) - { - *pnum_clobbers = 2; - return 70; - } - } - L371: - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - if (TARGET_FPA) - return 82; - } - x1 = XEXP (x0, 0); - goto L187; - - L366: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_FPA) - return 81; - } - x1 = XEXP (x0, 0); - goto L187; - L199: - tem = recog_1 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L961; - - L962: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != HImode) - { - x1 = XEXP (x0, 0); - goto L1595; - } - switch (GET_CODE (x1)) - { - case ASHIFT: - goto L963; - case ASHIFTRT: - goto L1002; - case LSHIFT: - goto L1041; - case LSHIFTRT: - goto L1080; - case ROTATE: - goto L1107; - case ROTATERT: - goto L1134; - } - x1 = XEXP (x0, 0); - goto L1595; - - L963: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L964; - } - x1 = XEXP (x0, 0); - goto L1595; - - L964: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 194; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1002: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L1003; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1003: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 201; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1041: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L1042; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1042: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 208; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1080: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L1081; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1081: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 215; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1107: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L1108; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1108: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 220; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1134: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L1135; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1135: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 225; - } - x1 = XEXP (x0, 0); - goto L1595; - L191: - tem = recog_2 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L972; - - L973: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != QImode) - { - x1 = XEXP (x0, 0); - goto L1595; - } - switch (GET_CODE (x1)) - { - case ASHIFT: - goto L974; - case ASHIFTRT: - goto L1013; - case LSHIFT: - goto L1052; - case LSHIFTRT: - goto L1091; - case ROTATE: - goto L1118; - case ROTATERT: - goto L1145; - } - x1 = XEXP (x0, 0); - goto L1595; - - L974: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L975; - } - x1 = XEXP (x0, 0); - goto L1595; - - L975: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 196; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1013: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L1014; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1014: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 203; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1052: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L1053; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1053: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 210; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1091: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L1092; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1092: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 217; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1118: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L1119; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1119: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 222; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1145: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L1146; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1146: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 227; - } - x1 = XEXP (x0, 0); - goto L1595; - - L237: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case SFmode: - switch (GET_CODE (x1)) - { - case FLOAT_TRUNCATE: - goto L238; - case FLOAT: - goto L252; - case FIX: - goto L337; - case PLUS: - goto L432; - case MINUS: - goto L489; - case MULT: - goto L611; - case DIV: - goto L671; - case NEG: - goto L880; - case ABS: - goto L904; - } - } - if (general_operand (x1, SFmode)) - { - ro[1] = x1; - return 34; - } - x1 = XEXP (x0, 0); - goto L1595; - - L238: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - goto L243; - L248: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 59; - } - x1 = XEXP (x0, 0); - goto L1595; - - L243: - ro[1] = x2; - if (TARGET_FPA) - return 57; - L244: - ro[1] = x2; - if (TARGET_68040_ONLY) - return 58; - goto L248; - - L252: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - goto L257; - L272: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 66; - } - L280: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 68; - } - x1 = XEXP (x0, 0); - goto L1595; - - L257: - ro[1] = x2; - if (TARGET_FPA) - return 61; - L258: - ro[1] = x2; - if (TARGET_68881) - return 62; - goto L272; - - L337: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_68881 && !TARGET_68040) - return 74; - } - x1 = XEXP (x0, 0); - goto L1595; - - L432: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L433; - } - x1 = XEXP (x0, 0); - goto L1595; - - L433: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - goto L439; - x1 = XEXP (x0, 0); - goto L1595; - - L439: - ro[2] = x2; - if (TARGET_FPA) - return 95; - L440: - ro[2] = x2; - if (TARGET_68881) - return 96; - x1 = XEXP (x0, 0); - goto L1595; - - L489: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L490; - } - x1 = XEXP (x0, 0); - goto L1595; - - L490: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - goto L496; - x1 = XEXP (x0, 0); - goto L1595; - - L496: - ro[2] = x2; - if (TARGET_FPA) - return 107; - L497: - ro[2] = x2; - if (TARGET_68881) - return 108; - x1 = XEXP (x0, 0); - goto L1595; - - L611: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L612; - } - x1 = XEXP (x0, 0); - goto L1595; - - L612: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - goto L618; - x1 = XEXP (x0, 0); - goto L1595; - - L618: - ro[2] = x2; - if (TARGET_FPA) - return 125; - L619: - ro[2] = x2; - if (TARGET_68881) - return 126; - x1 = XEXP (x0, 0); - goto L1595; - - L671: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L672; - } - x1 = XEXP (x0, 0); - goto L1595; - - L672: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - goto L678; - x1 = XEXP (x0, 0); - goto L1595; - - L678: - ro[2] = x2; - if (TARGET_FPA) - return 137; - L679: - ro[2] = x2; - if (TARGET_68881) - return 138; - x1 = XEXP (x0, 0); - goto L1595; - - L880: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - goto L885; - x1 = XEXP (x0, 0); - goto L1595; - - L885: - ro[1] = x2; - if (TARGET_FPA) - return 174; - L886: - ro[1] = x2; - if (TARGET_68881) - return 175; - x1 = XEXP (x0, 0); - goto L1595; - - L904: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - goto L909; - x1 = XEXP (x0, 0); - goto L1595; - - L909: - ro[1] = x2; - if (TARGET_FPA) - return 181; - L910: - ro[1] = x2; - if (TARGET_68881) - return 182; - x1 = XEXP (x0, 0); - goto L1595; - - L177: - x1 = XEXP (x0, 1); - if (nonimmediate_operand (x1, XFmode)) - goto L181; - x1 = XEXP (x0, 0); - goto L1595; - - L181: - ro[1] = x1; - if (TARGET_68881) - return 37; - L182: - ro[1] = x1; - if (! TARGET_68881) - return 38; - x1 = XEXP (x0, 0); - goto L1595; - - L188: - x1 = XEXP (x0, 1); - if (address_operand (x1, SImode)) - { - ro[1] = x1; - return 40; - } - x1 = XEXP (x0, 0); - goto L373; - - L1155: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[0] = x2; - goto L1156; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[0] = x2; - goto L1162; - } - } - goto L739; - - L1156: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[1] = x2; - goto L1157; - } - L1204: - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1205; - } - goto L739; - - L1157: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1158; - } - x2 = XEXP (x1, 1); - goto L1204; - - L1158: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - { - ro[3] = x1; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT - && (INTVAL (operands[1]) == 32) - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[0], 0))) - return 229; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 1); - goto L1204; - - L1205: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1206; - } - goto L739; - - L1206: - x1 = XEXP (x0, 1); - switch (GET_CODE (x1)) - { - case XOR: - if (GET_MODE (x1) == SImode && 1) - goto L1207; - break; - case CONST_INT: - if (XWINT (x1, 0) == 0 && 1) - if (TARGET_68020 && TARGET_BITFIELD) - return 238; - if (XWINT (x1, 0) == -1 && 1) - if (TARGET_68020 && TARGET_BITFIELD) - return 239; - } - L1229: - if (general_operand (x1, SImode)) - { - ro[3] = x1; - if (TARGET_68020 && TARGET_BITFIELD) - return 240; - } - x1 = XEXP (x0, 0); - goto L739; - - L1207: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == ZERO_EXTRACT && 1) - goto L1208; - x1 = XEXP (x0, 0); - goto L739; - - L1208: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[0]) && 1) - goto L1209; - x1 = XEXP (x0, 0); - goto L739; - - L1209: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L1210; - x1 = XEXP (x0, 0); - goto L739; - - L1210: - x3 = XEXP (x2, 2); - if (rtx_equal_p (x3, ro[2]) && 1) - goto L1211; - x1 = XEXP (x0, 0); - goto L739; - - L1211: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, VOIDmode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) == -1 - || (GET_CODE (operands[1]) == CONST_INT - && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))) - return 237; - } - x1 = XEXP (x0, 0); - goto L739; - - L1162: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[1] = x2; - goto L1163; - } - L1245: - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1246; - } - goto L739; - - L1163: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1164; - } - x2 = XEXP (x1, 1); - goto L1245; - - L1164: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - { - ro[3] = x1; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT - && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16) - && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) % INTVAL (operands[1]) == 0 - && (GET_CODE (operands[0]) == REG - || ! mode_dependent_address_p (XEXP (operands[0], 0)))) - return 230; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 1); - goto L1245; - - L1246: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1247; - } - goto L739; - - L1247: - x1 = XEXP (x0, 1); - switch (GET_CODE (x1)) - { - case CONST_INT: - if (XWINT (x1, 0) == 0 && 1) - if (TARGET_68020 && TARGET_BITFIELD) - return 243; - if (XWINT (x1, 0) == -1 && 1) - if (TARGET_68020 && TARGET_BITFIELD) - return 244; - } - L1259: - if (general_operand (x1, SImode)) - { - ro[3] = x1; - if (TARGET_68020 && TARGET_BITFIELD) - return 245; - } - x1 = XEXP (x0, 0); - goto L739; - L374: - tem = recog_3 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L739; - - L740: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == SImode && GET_CODE (x1) == AND && 1) - goto L741; - x1 = XEXP (x0, 0); - goto L944; - - L741: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L742; - } - x1 = XEXP (x0, 0); - goto L944; - - L742: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 147; - } - x1 = XEXP (x0, 0); - goto L944; - - L945: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != SImode) - { - x1 = XEXP (x0, 0); - goto L1595; - } - switch (GET_CODE (x1)) - { - case ASHIFT: - goto L946; - case ASHIFTRT: - goto L985; - case LSHIFT: - goto L1024; - case LSHIFTRT: - goto L1063; - case ROTATE: - goto L1102; - case ROTATERT: - goto L1129; - } - x1 = XEXP (x0, 0); - goto L1595; - - L946: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L947; - } - x1 = XEXP (x0, 0); - goto L1595; - - L947: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - goto L953; - L959: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 193; - } - x1 = XEXP (x0, 0); - goto L1595; - - L953: - ro[2] = x2; - if ((GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)) - return 191; - L954: - ro[2] = x2; - if ((! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)) - return 192; - goto L959; - - L985: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L986; - } - x1 = XEXP (x0, 0); - goto L1595; - - L986: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - goto L992; - L998: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 200; - } - x1 = XEXP (x0, 0); - goto L1595; - - L992: - ro[2] = x2; - if ((GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)) - return 198; - L993: - ro[2] = x2; - if ((! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)) - return 199; - goto L998; - - L1024: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L1025; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1025: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - goto L1031; - L1037: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 207; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1031: - ro[2] = x2; - if ((GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)) - return 205; - L1032: - ro[2] = x2; - if ((! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)) - return 206; - goto L1037; - - L1063: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L1064; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1064: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - goto L1070; - L1076: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 214; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1070: - ro[2] = x2; - if ((GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)) - return 212; - L1071: - ro[2] = x2; - if ((! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)) - return 213; - goto L1076; - - L1102: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L1103; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1103: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 219; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1129: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L1130; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1130: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 224; - } - x1 = XEXP (x0, 0); - goto L1595; - - L8: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case SImode: - if (nonimmediate_operand (x1, SImode)) - { - ro[0] = x1; - return 2; - } - break; - case HImode: - if (nonimmediate_operand (x1, HImode)) - { - ro[0] = x1; - return 3; - } - break; - case QImode: - if (nonimmediate_operand (x1, QImode)) - { - ro[0] = x1; - return 4; - } - } - switch (GET_CODE (x1)) - { - case COMPARE: - goto L46; - case ZERO_EXTRACT: - goto L101; - case CONST_INT: - case CONST_DOUBLE: - case CONST: - case SYMBOL_REF: - case LABEL_REF: - case SUBREG: - case REG: - case MEM: - L23: - if (general_operand (x1, SFmode)) - goto L27; - } - L37: - if (general_operand (x1, DFmode)) - goto L41; - L1262: - if (GET_MODE (x1) == SImode && GET_CODE (x1) == ZERO_EXTRACT && 1) - goto L1263; - x1 = XEXP (x0, 0); - goto L1595; - - L46: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[0] = x2; - goto L47; - } - break; - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[0] = x2; - goto L52; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[0] = x2; - goto L57; - } - break; - case DFmode: - if (general_operand (x2, DFmode)) - { - ro[0] = x2; - goto L70; - } - break; - case SFmode: - if (general_operand (x2, SFmode)) - { - ro[0] = x2; - goto L90; - } - } - x1 = XEXP (x0, 0); - goto L1595; - - L47: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 11; - } - x1 = XEXP (x0, 0); - goto L1595; - - L52: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 12; - } - x1 = XEXP (x0, 0); - goto L1595; - - L57: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 13; - } - x1 = XEXP (x0, 0); - goto L1595; - - L70: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - goto L76; - x1 = XEXP (x0, 0); - goto L1595; - - L76: - if (pnum_clobbers != 0 && 1) - { - ro[1] = x2; - if (TARGET_FPA) - { - *pnum_clobbers = 1; - return 15; - } - } - L77: - ro[1] = x2; - if (TARGET_68881) - return 16; - x1 = XEXP (x0, 0); - goto L1595; - - L90: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - goto L96; - x1 = XEXP (x0, 0); - goto L1595; - - L96: - if (pnum_clobbers != 0 && 1) - { - ro[1] = x2; - if (TARGET_FPA) - { - *pnum_clobbers = 1; - return 18; - } - } - L97: - ro[1] = x2; - if (TARGET_68881) - return 19; - x1 = XEXP (x0, 0); - goto L1595; - - L101: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[0] = x2; - goto L102; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[0] = x2; - goto L110; - } - } - goto L1262; - - L102: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 1 && 1) - goto L103; - goto L1262; - - L103: - x2 = XEXP (x1, 2); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MINUS && 1) - goto L104; - if (general_operand (x2, SImode)) - { - ro[1] = x2; - if (GET_CODE (operands[1]) == CONST_INT - && (unsigned) INTVAL (operands[1]) < 8) - return 24; - } - goto L1262; - - L104: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 7 && 1) - goto L121; - goto L1262; - - L121: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == AND && 1) - goto L122; - if (general_operand (x3, SImode)) - { - ro[1] = x3; - return 20; - } - goto L1262; - - L122: - x4 = XEXP (x3, 0); - if (general_operand (x4, SImode)) - { - ro[1] = x4; - goto L123; - } - goto L1262; - - L123: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 7 && 1) - return 22; - goto L1262; - - L110: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 1 && 1) - goto L111; - goto L1262; - - L111: - x2 = XEXP (x1, 2); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MINUS && 1) - goto L112; - if (general_operand (x2, SImode)) - { - ro[1] = x2; - if (GET_CODE (operands[1]) == CONST_INT) - return 25; - } - goto L1262; - - L112: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 31 && 1) - goto L131; - goto L1262; - - L131: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == AND && 1) - goto L132; - if (general_operand (x3, SImode)) - { - ro[1] = x3; - return 21; - } - goto L1262; - - L132: - x4 = XEXP (x3, 0); - if (general_operand (x4, SImode)) - { - ro[1] = x4; - goto L133; - } - goto L1262; - - L133: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 31 && 1) - return 23; - goto L1262; - - L27: - if (pnum_clobbers != 0 && 1) - { - ro[0] = x1; - if (TARGET_FPA) - { - *pnum_clobbers = 1; - return 6; - } - } - L28: - ro[0] = x1; - if (TARGET_68881) - return 7; - goto L37; - - L41: - if (pnum_clobbers != 0 && 1) - { - ro[0] = x1; - if (TARGET_FPA) - { - *pnum_clobbers = 1; - return 9; - } - } - L42: - ro[0] = x1; - if (TARGET_68881) - return 10; - x1 = XEXP (x0, 0); - goto L1595; - - L1263: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case QImode: - if (memory_operand (x2, QImode)) - { - ro[0] = x2; - goto L1264; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[0] = x2; - goto L1270; - } - } - x1 = XEXP (x0, 0); - goto L1595; - - L1264: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1265; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1265: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT) - return 246; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1270: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1271; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1271: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT) - return 247; - } - x1 = XEXP (x0, 0); - goto L1595; - L160: - tem = recog_4 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - goto L1595; - - L1324: - x1 = XEXP (x0, 1); - switch (GET_CODE (x1)) - { - case IF_THEN_ELSE: - goto L1325; - case LABEL_REF: - goto L1505; - } - x1 = XEXP (x0, 0); - goto L1595; - L1325: - tem = recog_5 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L1595; - - L1505: - x2 = XEXP (x1, 0); - ro[0] = x2; - return 278; - - L1596: - x1 = XEXP (x0, 1); - if (GET_CODE (x1) == CALL && 1) - goto L1597; - x1 = XEXP (x0, 0); - goto L1612; - - L1597: - x2 = XEXP (x1, 0); - if (memory_operand (x2, QImode)) - { - ro[1] = x2; - goto L1598; - } - x1 = XEXP (x0, 0); - goto L1612; - - L1598: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - goto L1604; - x1 = XEXP (x0, 0); - goto L1612; - - L1604: - ro[2] = x2; - if (! flag_pic) - return 290; - L1605: - ro[2] = x2; - if (flag_pic) - return 291; - x1 = XEXP (x0, 0); - goto L1612; - - L1613: - x1 = XEXP (x0, 1); - if (address_operand (x1, SImode)) - { - ro[0] = x1; - return 297; - } - goto ret0; - - L1703: - x1 = XEXP (x0, 1); - if (nonimmediate_operand (x1, XFmode)) - { - ro[0] = x1; - if (TARGET_68881) - return 318; - } - if (GET_CODE (x1) == COMPARE && 1) - goto L1707; - goto ret0; - - L1707: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[0] = x2; - goto L1708; - } - goto ret0; - - L1708: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 320; - } - goto ret0; - - L1751: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == SImode && GET_CODE (x1) == FIX && 1) - goto L1752; - if (address_operand (x1, QImode)) - { - ro[1] = x1; - return 298; - } - goto ret0; - - L1752: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 331; - } - goto ret0; - - L1619: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != DFmode) - { - x1 = XEXP (x0, 0); - goto L1718; - } - switch (GET_CODE (x1)) - { - case PLUS: - goto L1620; - case MINUS: - goto L1648; - case MULT: - goto L1662; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1620: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == MULT && 1) - goto L1621; - x1 = XEXP (x0, 0); - goto L1718; - - L1621: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - goto L1622; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1622: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1623; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1623: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 306; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1648: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == MULT && 1) - goto L1649; - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L1635; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1649: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - goto L1650; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1650: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1651; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1651: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 310; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1635: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == MULT && 1) - goto L1636; - x1 = XEXP (x0, 0); - goto L1718; - - L1636: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1637; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1637: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[3] = x3; - if (TARGET_FPA) - return 308; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1662: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - switch (GET_CODE (x2)) - { - case PLUS: - goto L1663; - case MINUS: - goto L1677; - } - } - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L1684; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1663: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - goto L1664; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1664: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1665; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1665: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 312; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1677: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - goto L1678; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1678: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1679; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1679: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 314; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1684: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == MINUS && 1) - goto L1685; - x1 = XEXP (x0, 0); - goto L1718; - - L1685: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1686; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1686: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[3] = x3; - if (TARGET_FPA) - return 315; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1719: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == DFmode && GET_CODE (x1) == FLOAT_TRUNCATE && 1) - goto L1720; - goto ret0; - - L1720: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 323; - } - goto ret0; - - L1626: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != SFmode) - { - x1 = XEXP (x0, 0); - goto L1722; - } - switch (GET_CODE (x1)) - { - case PLUS: - goto L1627; - case MINUS: - goto L1655; - case MULT: - goto L1669; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1627: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == MULT && 1) - goto L1628; - x1 = XEXP (x0, 0); - goto L1722; - - L1628: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L1629; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1629: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1630; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1630: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 307; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1655: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == MULT && 1) - goto L1656; - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L1642; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1656: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L1657; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1657: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1658; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1658: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 311; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1642: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == MULT && 1) - goto L1643; - x1 = XEXP (x0, 0); - goto L1722; - - L1643: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1644; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1644: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[3] = x3; - if (TARGET_FPA) - return 309; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1669: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SFmode: - switch (GET_CODE (x2)) - { - case PLUS: - goto L1670; - case MINUS: - goto L1691; - } - } - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L1698; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1670: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L1671; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1671: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1672; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1672: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 313; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1691: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L1692; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1692: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1693; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1693: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 316; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1698: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == MINUS && 1) - goto L1699; - x1 = XEXP (x0, 0); - goto L1722; - - L1699: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1700; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1700: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[3] = x3; - if (TARGET_FPA) - return 317; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1723: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == SFmode && GET_CODE (x1) == FLOAT_TRUNCATE && 1) - goto L1724; - goto ret0; - - L1724: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 324; - } - goto ret0; - - L1711: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != XFmode) - goto ret0; - switch (GET_CODE (x1)) - { - case FLOAT_EXTEND: - goto L1712; - case FLOAT: - goto L1728; - case FIX: - goto L1740; - case PLUS: - goto L1756; - case MINUS: - goto L1761; - case MULT: - goto L1766; - case DIV: - goto L1771; - case NEG: - goto L1776; - case ABS: - goto L1780; - case SQRT: - goto L1784; - } - goto ret0; - - L1712: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 321; - } - L1716: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 322; - } - goto ret0; - - L1728: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 325; - } - L1732: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 326; - } - L1736: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 327; - } - goto ret0; - - L1740: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 328; - } - goto ret0; - - L1756: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - goto L1757; - } - goto ret0; - - L1757: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, XFmode)) - { - ro[2] = x2; - if (TARGET_68881) - return 333; - } - goto ret0; - - L1761: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - goto L1762; - } - goto ret0; - - L1762: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, XFmode)) - { - ro[2] = x2; - if (TARGET_68881) - return 335; - } - goto ret0; - - L1766: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - goto L1767; - } - goto ret0; - - L1767: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, XFmode)) - { - ro[2] = x2; - if (TARGET_68881) - return 337; - } - goto ret0; - - L1771: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - goto L1772; - } - goto ret0; - - L1772: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, XFmode)) - { - ro[2] = x2; - if (TARGET_68881) - return 339; - } - goto ret0; - - L1776: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 340; - } - goto ret0; - - L1780: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 341; - } - goto ret0; - - L1784: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 342; - } - goto ret0; - - L1743: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == QImode && GET_CODE (x1) == FIX && 1) - goto L1744; - goto ret0; - - L1744: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 329; - } - goto ret0; - - L1747: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == HImode && GET_CODE (x1) == FIX && 1) - goto L1748; - goto ret0; - - L1748: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 330; - } - goto ret0; - ret0: return -1; -} - -int -recog_7 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - switch (GET_MODE (x2)) - { - case SImode: - if (GET_CODE (x2) == PLUS && 1) - goto L1517; - if (register_operand (x2, SImode)) - { - ro[0] = x2; - goto L1510; - } - } - if (GET_CODE (x2) == IF_THEN_ELSE && 1) - goto L1526; - goto ret0; - - L1517: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == PC && 1) - goto L1518; - goto ret0; - - L1518: - x3 = XEXP (x2, 1); - if (register_operand (x3, HImode)) - { - ro[0] = x3; - goto L1519; - } - goto ret0; - - L1519: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1520; - goto ret0; - - L1520: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1521; - goto ret0; - - L1521: - x3 = XEXP (x2, 0); - ro[1] = x3; - return 281; - - L1510: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1511; - goto ret0; - - L1511: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1512; - goto ret0; - - L1512: - x3 = XEXP (x2, 0); - ro[1] = x3; - return 280; - - L1526: - x3 = XEXP (x2, 0); - switch (GET_CODE (x3)) - { - case NE: - goto L1527; - case GE: - goto L1557; - } - goto ret0; - - L1527: - x4 = XEXP (x3, 0); - switch (GET_MODE (x4)) - { - case HImode: - if (general_operand (x4, HImode)) - { - ro[0] = x4; - goto L1528; - } - break; - case SImode: - if (general_operand (x4, SImode)) - { - ro[0] = x4; - goto L1543; - } - } - goto ret0; - - L1528: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 0 && 1) - goto L1529; - goto ret0; - - L1529: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == LABEL_REF && 1) - goto L1530; - goto ret0; - - L1530: - x4 = XEXP (x3, 0); - ro[1] = x4; - goto L1531; - - L1531: - x3 = XEXP (x2, 2); - if (GET_CODE (x3) == PC && 1) - goto L1532; - goto ret0; - - L1532: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1533; - goto ret0; - - L1533: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1534; - goto ret0; - - L1534: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == PLUS && 1) - goto L1535; - goto ret0; - - L1535: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[0]) && 1) - goto L1536; - goto ret0; - - L1536: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - return 282; - goto ret0; - - L1543: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 0 && 1) - goto L1544; - goto ret0; - - L1544: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == LABEL_REF && 1) - goto L1545; - goto ret0; - - L1545: - x4 = XEXP (x3, 0); - ro[1] = x4; - goto L1546; - - L1546: - x3 = XEXP (x2, 2); - if (GET_CODE (x3) == PC && 1) - goto L1547; - goto ret0; - - L1547: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1548; - goto ret0; - - L1548: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1549; - goto ret0; - - L1549: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1550; - goto ret0; - - L1550: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[0]) && 1) - goto L1551; - goto ret0; - - L1551: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - return 283; - goto ret0; - - L1557: - x4 = XEXP (x3, 0); - if (GET_CODE (x4) != PLUS) - goto ret0; - switch (GET_MODE (x4)) - { - case HImode: - goto L1558; - case SImode: - goto L1575; - } - goto ret0; - - L1558: - x5 = XEXP (x4, 0); - if (general_operand (x5, HImode)) - { - ro[0] = x5; - goto L1559; - } - goto ret0; - - L1559: - x5 = XEXP (x4, 1); - if (GET_CODE (x5) == CONST_INT && XWINT (x5, 0) == -1 && 1) - goto L1560; - goto ret0; - - L1560: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 0 && 1) - goto L1561; - goto ret0; - - L1561: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == LABEL_REF && 1) - goto L1562; - goto ret0; - - L1562: - x4 = XEXP (x3, 0); - ro[1] = x4; - goto L1563; - - L1563: - x3 = XEXP (x2, 2); - if (GET_CODE (x3) == PC && 1) - goto L1564; - goto ret0; - - L1564: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1565; - goto ret0; - - L1565: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1566; - goto ret0; - - L1566: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == PLUS && 1) - goto L1567; - goto ret0; - - L1567: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[0]) && 1) - goto L1568; - goto ret0; - - L1568: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - if (find_reg_note (insn, REG_NONNEG, 0)) - return 284; - goto ret0; - - L1575: - x5 = XEXP (x4, 0); - if (general_operand (x5, SImode)) - { - ro[0] = x5; - goto L1576; - } - goto ret0; - - L1576: - x5 = XEXP (x4, 1); - if (GET_CODE (x5) == CONST_INT && XWINT (x5, 0) == -1 && 1) - goto L1577; - goto ret0; - - L1577: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 0 && 1) - goto L1578; - goto ret0; - - L1578: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == LABEL_REF && 1) - goto L1579; - goto ret0; - - L1579: - x4 = XEXP (x3, 0); - ro[1] = x4; - goto L1580; - - L1580: - x3 = XEXP (x2, 2); - if (GET_CODE (x3) == PC && 1) - goto L1581; - goto ret0; - - L1581: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1582; - goto ret0; - - L1582: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1583; - goto ret0; - - L1583: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1584; - goto ret0; - - L1584: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[0]) && 1) - goto L1585; - goto ret0; - - L1585: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - if (find_reg_note (insn, REG_NONNEG, 0)) - return 285; - goto ret0; - ret0: return -1; -} - -int -recog_8 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - if (register_operand (x2, SImode)) - { - ro[0] = x2; - goto L537; - } - L718: - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L719; - } - } - switch (GET_CODE (x2)) - { - case CC0: - goto L18; - case PC: - goto L1516; - } - goto ret0; - - L537: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MULT && 1) - goto L538; - x2 = XEXP (x1, 0); - goto L718; - - L538: - x3 = XEXP (x2, 0); - if (register_operand (x3, SImode)) - { - ro[1] = x3; - goto L539; - } - x2 = XEXP (x1, 0); - goto L718; - - L539: - x3 = XEXP (x2, 1); - if (nonimmediate_operand (x3, SImode)) - { - ro[2] = x3; - goto L540; - } - if (GET_CODE (x3) == CONST_INT && 1) - { - ro[2] = x3; - goto L556; - } - x2 = XEXP (x1, 0); - goto L718; - - L540: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L541; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L541: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[3] = x2; - goto L542; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L542: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == TRUNCATE && 1) - goto L543; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L543: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) != DImode) - { - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - } - switch (GET_CODE (x3)) - { - case LSHIFTRT: - goto L544; - case ASHIFT: - goto L575; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L544: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == DImode && GET_CODE (x4) == MULT && 1) - goto L545; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L545: - x5 = XEXP (x4, 0); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == ZERO_EXTEND && 1) - goto L546; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L546: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[1]) && 1) - goto L547; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L547: - x5 = XEXP (x4, 1); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == ZERO_EXTEND && 1) - goto L548; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L548: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[2]) && 1) - goto L549; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L549: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 32 && 1) - if (TARGET_68020) - return 116; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L575: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == DImode && GET_CODE (x4) == MULT && 1) - goto L576; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L576: - x5 = XEXP (x4, 0); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == SIGN_EXTEND && 1) - goto L577; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L577: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[1]) && 1) - goto L578; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L578: - x5 = XEXP (x4, 1); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == SIGN_EXTEND && 1) - goto L579; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L579: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[2]) && 1) - goto L580; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L580: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 32 && 1) - if (TARGET_68020) - return 119; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L556: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L557; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L557: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[3] = x2; - goto L558; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L558: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == TRUNCATE && 1) - goto L559; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L559: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) != DImode) - { - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - } - switch (GET_CODE (x3)) - { - case LSHIFTRT: - goto L560; - case ASHIFT: - goto L591; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L560: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == DImode && GET_CODE (x4) == MULT && 1) - goto L561; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L561: - x5 = XEXP (x4, 0); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == ZERO_EXTEND && 1) - goto L562; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L562: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[1]) && 1) - goto L563; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L563: - x5 = XEXP (x4, 1); - if (rtx_equal_p (x5, ro[2]) && 1) - goto L564; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L564: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 32 && 1) - if (TARGET_68020 - && (unsigned) INTVAL (operands[2]) <= 0x7fffffff) - return 117; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L591: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == DImode && GET_CODE (x4) == MULT && 1) - goto L592; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L592: - x5 = XEXP (x4, 0); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == SIGN_EXTEND && 1) - goto L593; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L593: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[1]) && 1) - goto L594; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L594: - x5 = XEXP (x4, 1); - if (rtx_equal_p (x5, ro[2]) && 1) - goto L595; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L595: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 32 && 1) - if (TARGET_68020 - /* This test is a noop on 32 bit machines, - but important for a cross-compiler hosted on 64-bit machines. */ - && INTVAL (operands[2]) <= 0x7fffffff - && INTVAL (operands[2]) >= -0x80000000) - return 120; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L719: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != SImode) - goto ret0; - switch (GET_CODE (x2)) - { - case DIV: - goto L720; - case UDIV: - goto L731; - } - goto ret0; - - L720: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L721; - } - goto ret0; - - L721: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L722; - } - goto ret0; - - L722: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L723; - goto ret0; - - L723: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && general_operand (x2, SImode)) - { - ro[3] = x2; - goto L724; - } - goto ret0; - - L724: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MOD && 1) - goto L725; - goto ret0; - - L725: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L726; - goto ret0; - - L726: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - if (TARGET_68020) - return 145; - goto ret0; - - L731: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L732; - } - goto ret0; - - L732: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L733; - } - goto ret0; - - L733: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L734; - goto ret0; - - L734: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && general_operand (x2, SImode)) - { - ro[3] = x2; - goto L735; - } - goto ret0; - - L735: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == UMOD && 1) - goto L736; - goto ret0; - - L736: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L737; - goto ret0; - - L737: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - if (TARGET_68020) - return 146; - goto ret0; - - L18: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[0] = x2; - goto L19; - } - L32: - if (general_operand (x2, DFmode)) - { - ro[0] = x2; - goto L33; - } - if (GET_CODE (x2) == COMPARE && 1) - goto L62; - goto ret0; - - L19: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L20; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L32; - - L20: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[1] = x2; - if (TARGET_FPA) - return 6; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L32; - - L33: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L34; - goto ret0; - - L34: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[1] = x2; - if (TARGET_FPA) - return 9; - } - goto ret0; - - L62: - x3 = XEXP (x2, 0); - switch (GET_MODE (x3)) - { - case DFmode: - if (general_operand (x3, DFmode)) - { - ro[0] = x3; - goto L63; - } - break; - case SFmode: - if (general_operand (x3, SFmode)) - { - ro[0] = x3; - goto L83; - } - } - goto ret0; - - L63: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - goto L64; - } - goto ret0; - - L64: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L65; - goto ret0; - - L65: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - if (TARGET_FPA) - return 15; - } - goto ret0; - - L83: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L84; - } - goto ret0; - - L84: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L85; - goto ret0; - - L85: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - if (TARGET_FPA) - return 18; - } - goto ret0; - L1516: - return recog_7 (x0, insn, pnum_clobbers); - ret0: return -1; -} - -int -recog (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - L1609: - switch (GET_CODE (x0)) - { - case REG: - if (GET_MODE (x0) == SImode && XINT (x0, 0) == 15 && 1) - if (NEED_PROBE) - return 295; - break; - case SET: - goto L1; - case PARALLEL: - if (XVECLEN (x0, 0) == 2 && 1) - goto L16; - if (XVECLEN (x0, 0) == 3 && 1) - goto L286; - break; - case CALL: - goto L1587; - case UNSPEC_VOLATILE: - if (XINT (x0, 1) == 0 && XVECLEN (x0, 0) == 1 && 1) - goto L1607; - break; - case CONST_INT: - if (XWINT (x0, 0) == 0 && 1) - return 294; - break; - case RETURN: - if (USE_RETURN_INSN) - return 296; - } - goto ret0; - L1: - return recog_6 (x0, insn, pnum_clobbers); - - L16: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == SET && 1) - goto L536; - goto ret0; - L536: - return recog_8 (x0, insn, pnum_clobbers); - - L286: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == SET && 1) - goto L287; - goto ret0; - - L287: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L288; - } - break; - case HImode: - if (general_operand (x2, HImode)) - { - ro[0] = x2; - goto L303; - } - break; - case QImode: - if (general_operand (x2, QImode)) - { - ro[0] = x2; - goto L318; - } - } - goto ret0; - - L288: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == FIX && 1) - goto L289; - goto ret0; - - L289: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == DFmode && GET_CODE (x3) == FIX && 1) - goto L290; - goto ret0; - - L290: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L291; - } - goto ret0; - - L291: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L292; - goto ret0; - - L292: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - goto L293; - } - goto ret0; - - L293: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L294; - goto ret0; - - L294: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68040) - return 70; - } - goto ret0; - - L303: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == FIX && 1) - goto L304; - goto ret0; - - L304: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == DFmode && GET_CODE (x3) == FIX && 1) - goto L305; - goto ret0; - - L305: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L306; - } - goto ret0; - - L306: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L307; - goto ret0; - - L307: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - goto L308; - } - goto ret0; - - L308: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L309; - goto ret0; - - L309: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68040) - return 71; - } - goto ret0; - - L318: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == QImode && GET_CODE (x2) == FIX && 1) - goto L319; - goto ret0; - - L319: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == DFmode && GET_CODE (x3) == FIX && 1) - goto L320; - goto ret0; - - L320: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L321; - } - goto ret0; - - L321: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L322; - goto ret0; - - L322: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - goto L323; - } - goto ret0; - - L323: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L324; - goto ret0; - - L324: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68040) - return 72; - } - goto ret0; - - L1587: - x1 = XEXP (x0, 0); - if (memory_operand (x1, QImode)) - { - ro[0] = x1; - goto L1588; - } - goto ret0; - - L1588: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - goto L1592; - goto ret0; - - L1592: - ro[1] = x1; - if (! flag_pic) - return 287; - L1593: - ro[1] = x1; - if (flag_pic) - return 288; - goto ret0; - - L1607: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == CONST_INT && XWINT (x1, 0) == 0 && 1) - return 293; - goto ret0; - ret0: return -1; -} - -rtx -split_insns (x0, insn) - register rtx x0; - rtx insn; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - rtx tem; - - goto ret0; - ret0: return 0; -} - diff --git a/gnu/usr.bin/gcc2/arch/da30/m68k.h b/gnu/usr.bin/gcc2/arch/da30/m68k.h deleted file mode 100644 index 513fff461517..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/m68k.h +++ /dev/null @@ -1,1796 +0,0 @@ -/* Definitions of target machine for GNU compiler. Sun 68000/68020 version. - Copyright (C) 1987, 1988, 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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. - -GNU CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m68k.h,v 1.1 1993/11/23 06:09:13 paulus Exp $ -*/ - - -/* Note that some other tm.h files include this one and then override - many of the definitions that relate to assembler syntax. */ - - -/* Names to predefine in the preprocessor for this target machine. */ - -/* See sun3.h, sun2.h, isi.h for different CPP_PREDEFINES. */ - -/* Print subsidiary information on the compiler version in use. */ -#ifdef MOTOROLA -#define TARGET_VERSION fprintf (stderr, " (68k, Motorola syntax)"); -#else -#define TARGET_VERSION fprintf (stderr, " (68k, MIT syntax)"); -#endif - -/* Define SUPPORT_SUN_FPA to include support for generating code for - the Sun Floating Point Accelerator, an optional product for Sun 3 - machines. By default, it is not defined. Avoid defining it unless - you need to output code for the Sun3+FPA architecture, as it has the - effect of slowing down the register set operations in hard-reg-set.h - (total number of registers will exceed number of bits in a long, - if defined, causing the set operations to expand to loops). - SUPPORT_SUN_FPA is typically defined in sun3.h. */ - -/* Run-time compilation parameters selecting different hardware subsets. */ - -extern int target_flags; - -/* Macros used in the machine description to test the flags. */ - -/* Compile for a 68020 (not a 68000 or 68010). */ -#define TARGET_68020 (target_flags & 1) - -/* Compile 68881 insns for floating point (not library calls). */ -#define TARGET_68881 (target_flags & 2) - -/* Compile using 68020 bitfield insns. */ -#define TARGET_BITFIELD (target_flags & 4) - -/* Compile using rtd insn calling sequence. - This will not work unless you use prototypes at least - for all functions that can take varying numbers of args. */ -#define TARGET_RTD (target_flags & 8) - -/* Compile passing first two args in regs 0 and 1. - This exists only to test compiler features that will - be needed for RISC chips. It is not usable - and is not intended to be usable on this cpu. */ -#define TARGET_REGPARM (target_flags & 020) - -/* Compile with 16-bit `int'. */ -#define TARGET_SHORT (target_flags & 040) - -/* Compile with special insns for Sun FPA. */ -#ifdef SUPPORT_SUN_FPA -#define TARGET_FPA (target_flags & 0100) -#else -#define TARGET_FPA 0 -#endif - -/* Compile (actually, link) for Sun SKY board. */ -#define TARGET_SKY (target_flags & 0200) - -/* Optimize for 68040, but still allow execution on 68020 - (-m68020-40 or -m68040). - The 68040 will execute all 68030 and 68881/2 instructions, but some - of them must be emulated in software by the OS. When TARGET_68040 is - turned on, these instructions won't be used. This code will still - run on a 68030 and 68881/2. */ -#define TARGET_68040 (target_flags & 01400) - -/* Use the 68040-only fp instructions (-m68040). */ -#define TARGET_68040_ONLY (target_flags & 01000) - -/* Macro to define tables used to set the flags. - This is a list in braces of pairs in braces, - each pair being { "NAME", VALUE } - where VALUE is the bits to set or minus the bits to clear. - An empty string NAME is used to identify the default VALUE. */ - -#define TARGET_SWITCHES \ - { { "68020", -01400}, \ - { "c68020", -01400}, \ - { "68020", 5}, \ - { "c68020", 5}, \ - { "68881", 2}, \ - { "bitfield", 4}, \ - { "68000", -01405}, \ - { "c68000", -01405}, \ - { "soft-float", -01102}, \ - { "nobitfield", -4}, \ - { "rtd", 8}, \ - { "nortd", -8}, \ - { "short", 040}, \ - { "noshort", -040}, \ - { "fpa", 0100}, \ - { "nofpa", -0100}, \ - { "sky", 0200}, \ - { "nosky", -0200}, \ - { "68020-40", 0407}, \ - { "68030", -01400}, \ - { "68030", 5}, \ - { "68040", 01007}, \ - { "", TARGET_DEFAULT}} -/* TARGET_DEFAULT is defined in sun*.h and isi.h, etc. */ - -/* For PIC, function CSE is undesirable since it causes all function - calls to go via the GOT rather than the PLT. */ -#ifdef SUPPORT_SUN_FPA -/* Blow away 68881 flag silently on TARGET_FPA (since we can't clear - any bits in TARGET_SWITCHES above) */ -#define OVERRIDE_OPTIONS \ -{ \ - if (TARGET_FPA) target_flags &= ~2; \ - if (! TARGET_68020 && flag_pic == 2) \ - error("-fPIC is not currently supported on the 68000 or 68010\n"); \ - if (flag_pic) \ - flag_no_function_cse = 1; \ -} -#else -#define OVERRIDE_OPTIONS \ -{ \ - if (! TARGET_68020 && flag_pic == 2) \ - error("-fPIC is not currently supported on the 68000 or 68010\n"); \ - if (flag_pic) \ - flag_no_function_cse = 1; \ -} -#endif /* defined SUPPORT_SUN_FPA */ - -/* target machine storage layout */ - -/* Define for XFmode extended real floating point support. - This will automatically cause REAL_ARITHMETIC to be defined. */ -#define LONG_DOUBLE_TYPE_SIZE 96 - -/* Define if you don't want extended real, but do want to use the - software floating point emulator for REAL_ARITHMETIC and - decimal <-> binary conversion. */ -/* #define REAL_ARITHMETIC */ - -/* Define this if most significant bit is lowest numbered - in instructions that operate on numbered bit-fields. - This is true for 68020 insns such as bfins and bfexts. - We make it true always by avoiding using the single-bit insns - except in special cases with constant bit numbers. */ -#define BITS_BIG_ENDIAN 1 - -/* Define this if most significant byte of a word is the lowest numbered. */ -/* That is true on the 68000. */ -#define BYTES_BIG_ENDIAN 1 - -/* Define this if most significant word of a multiword number is the lowest - numbered. */ -/* For 68000 we can decide arbitrarily - since there are no machine instructions for them. - So let's be consistent. */ -#define WORDS_BIG_ENDIAN 1 - -/* number of bits in an addressable storage unit */ -#define BITS_PER_UNIT 8 - -/* Width in bits of a "word", which is the contents of a machine register. - Note that this is not necessarily the width of data type `int'; - if using 16-bit ints on a 68000, this would still be 32. - But on a machine with 16-bit registers, this would be 16. */ -#define BITS_PER_WORD 32 - -/* Width of a word, in units (bytes). */ -#define UNITS_PER_WORD 4 - -/* Width in bits of a pointer. - See also the macro `Pmode' defined below. */ -#define POINTER_SIZE 32 - -/* Allocation boundary (in *bits*) for storing arguments in argument list. */ -#define PARM_BOUNDARY (TARGET_SHORT ? 16 : 32) - -/* Boundary (in *bits*) on which stack pointer should be aligned. */ -#define STACK_BOUNDARY 16 - -/* Allocation boundary (in *bits*) for the code of a function. */ -#define FUNCTION_BOUNDARY 16 - -/* Alignment of field after `int : 0' in a structure. */ -#define EMPTY_FIELD_BOUNDARY 16 - -/* No data type wants to be aligned rounder than this. */ -#define BIGGEST_ALIGNMENT 16 - -/* Set this nonzero if move instructions will actually fail to work - when given unaligned data. */ -#define STRICT_ALIGNMENT 1 - -#define SELECT_RTX_SECTION(MODE, X) \ -{ \ - if (!flag_pic) \ - readonly_data_section(); \ - else if (LEGITIMATE_PIC_OPERAND_P (X)) \ - readonly_data_section(); \ - else \ - data_section(); \ -} - -/* Define number of bits in most basic integer type. - (If undefined, default is BITS_PER_WORD). */ - -#define INT_TYPE_SIZE (TARGET_SHORT ? 16 : 32) - -/* Define these to avoid dependence on meaning of `int'. - Note that WCHAR_TYPE_SIZE is used in cexp.y, - where TARGET_SHORT is not available. */ - -#define WCHAR_TYPE "long int" -#define WCHAR_TYPE_SIZE 32 - -/* Standard register usage. */ - -/* Number of actual hardware registers. - The hardware registers are assigned numbers for the compiler - from 0 to just below FIRST_PSEUDO_REGISTER. - All registers that the compiler knows about must be given numbers, - even those that are not normally considered general registers. - For the 68000, we give the data registers numbers 0-7, - the address registers numbers 010-017, - and the 68881 floating point registers numbers 020-027. */ -#ifndef SUPPORT_SUN_FPA -#define FIRST_PSEUDO_REGISTER 24 -#else -#define FIRST_PSEUDO_REGISTER 56 -#endif - -/* This defines the register which is used to hold the offset table for PIC. */ -#define PIC_OFFSET_TABLE_REGNUM 13 - -/* Used to output a (use pic_offset_table_rtx) so that we - always save/restore a5 in functions that use PIC relocation - at *any* time during the compilation process. */ -#define FINALIZE_PIC finalize_pic() - -#ifndef SUPPORT_SUN_FPA - -/* 1 for registers that have pervasive standard uses - and are not available for the register allocator. - On the 68000, only the stack pointer is such. */ - -#define FIXED_REGISTERS \ - {/* Data registers. */ \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - \ - /* Address registers. */ \ - 0, 0, 0, 0, 0, 0, 0, 1, \ - \ - /* Floating point registers \ - (if available). */ \ - 0, 0, 0, 0, 0, 0, 0, 0 } - -/* 1 for registers not available across function calls. - These must include the FIXED_REGISTERS and also any - registers that can be used without being saved. - The latter must include the registers where values are returned - and the register where structure-value addresses are passed. - Aside from that, you can include as many other registers as you like. */ -#define CALL_USED_REGISTERS \ - {1, 1, 0, 0, 0, 0, 0, 0, \ - 1, 1, 0, 0, 0, 0, 0, 1, \ - 1, 1, 0, 0, 0, 0, 0, 0 } - -#else /* SUPPORT_SUN_FPA */ - -/* 1 for registers that have pervasive standard uses - and are not available for the register allocator. - On the 68000, only the stack pointer is such. */ - -/* fpa0 is also reserved so that it can be used to move shit back and - forth between high fpa regs and everything else. */ - -#define FIXED_REGISTERS \ - {/* Data registers. */ \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - \ - /* Address registers. */ \ - 0, 0, 0, 0, 0, 0, 0, 1, \ - \ - /* Floating point registers \ - (if available). */ \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - \ - /* Sun3 FPA registers. */ \ - 1, 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 } - -/* 1 for registers not available across function calls. - These must include the FIXED_REGISTERS and also any - registers that can be used without being saved. - The latter must include the registers where values are returned - and the register where structure-value addresses are passed. - Aside from that, you can include as many other registers as you like. */ -#define CALL_USED_REGISTERS \ - {1, 1, 0, 0, 0, 0, 0, 0, \ - 1, 1, 0, 0, 0, 0, 0, 1, \ - 1, 1, 0, 0, 0, 0, 0, 0, \ - /* FPA registers. */ \ - 1, 1, 1, 1, 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 } - -#endif /* defined SUPPORT_SUN_FPA */ - - -/* Make sure everything's fine if we *don't* have a given processor. - This assumes that putting a register in fixed_regs will keep the - compiler's mitts completely off it. We don't bother to zero it out - of register classes. If neither TARGET_FPA or TARGET_68881 is set, - the compiler won't touch since no instructions that use these - registers will be valid. - - Reserve PIC_OFFSET_TABLE_REGNUM (a5) for doing PIC relocation if - position independent code is being generated by making it a - fixed register */ - -#ifndef SUPPORT_SUN_FPA - -#define CONDITIONAL_REGISTER_USAGE \ -{ \ - if (flag_pic) \ - fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ -} - -#else /* defined SUPPORT_SUN_FPA */ - -#define CONDITIONAL_REGISTER_USAGE \ -{ \ - int i; \ - HARD_REG_SET x; \ - if (!TARGET_FPA) \ - { \ - COPY_HARD_REG_SET (x, reg_class_contents[(int)FPA_REGS]); \ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ - if (TEST_HARD_REG_BIT (x, i)) \ - fixed_regs[i] = call_used_regs[i] = 1; \ - } \ - if (TARGET_FPA) \ - { \ - COPY_HARD_REG_SET (x, reg_class_contents[(int)FP_REGS]); \ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ - if (TEST_HARD_REG_BIT (x, i)) \ - fixed_regs[i] = call_used_regs[i] = 1; \ - } \ - if (flag_pic) \ - fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ -} - -#endif /* defined SUPPORT_SUN_FPA */ - -/* Return number of consecutive hard regs needed starting at reg REGNO - to hold something of mode MODE. - This is ordinarily the length in words of a value of mode MODE - but can be less for certain modes in special long registers. - - On the 68000, ordinary registers hold 32 bits worth; - for the 68881 registers, a single register is always enough for - anything that can be stored in them at all. */ -#define HARD_REGNO_NREGS(REGNO, MODE) \ - ((REGNO) >= 16 ? GET_MODE_NUNITS (MODE) \ - : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) - -#ifndef SUPPORT_SUN_FPA - -/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. - On the 68000, the cpu registers can hold any mode but the 68881 registers - can hold only SFmode or DFmode. The 68881 registers can't hold anything - if 68881 use is disabled. */ - -#define HARD_REGNO_MODE_OK(REGNO, MODE) \ - (((REGNO) < 16) \ - || ((REGNO) < 24 \ - && TARGET_68881 \ - && (GET_MODE_CLASS (MODE) == MODE_FLOAT \ - || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT))) - -#else /* defined SUPPORT_SUN_FPA */ - -/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. - On the 68000, the cpu registers can hold any mode but the 68881 registers - can hold only SFmode or DFmode. And the 68881 registers can't hold anything - if 68881 use is disabled. However, the Sun FPA register can - (apparently) hold whatever you feel like putting in them. - If using the fpa, don't put a double in d7/a0. */ - -#define HARD_REGNO_MODE_OK(REGNO, MODE) \ -(((REGNO) < 16 \ - && !(TARGET_FPA \ - && GET_MODE_CLASS ((MODE)) != MODE_INT \ - && GET_MODE_UNIT_SIZE ((MODE)) > 4 \ - && (REGNO) < 8 && (REGNO) + GET_MODE_SIZE ((MODE)) / 4 > 8 \ - && (REGNO) % (GET_MODE_UNIT_SIZE ((MODE)) / 4) != 0)) \ - || ((REGNO) < 24 \ - ? TARGET_68881 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \ - || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \ - : ((REGNO) < 56 ? TARGET_FPA : 0))) - -#endif /* defined SUPPORT_SUN_FPA */ - -/* Value is 1 if it is a good idea to tie two pseudo registers - when one has mode MODE1 and one has mode MODE2. - If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2, - for any hard reg, then this must be 0 for correct output. */ -#define MODES_TIEABLE_P(MODE1, MODE2) \ - (! TARGET_68881 \ - || ((GET_MODE_CLASS (MODE1) == MODE_FLOAT \ - || GET_MODE_CLASS (MODE1) == MODE_COMPLEX_FLOAT) \ - == (GET_MODE_CLASS (MODE2) == MODE_FLOAT \ - || GET_MODE_CLASS (MODE2) == MODE_COMPLEX_FLOAT))) - -/* Specify the registers used for certain standard purposes. - The values of these macros are register numbers. */ - -/* m68000 pc isn't overloaded on a register. */ -/* #define PC_REGNUM */ - -/* Register to use for pushing function arguments. */ -#define STACK_POINTER_REGNUM 15 - -/* Base register for access to local variables of the function. */ -#define FRAME_POINTER_REGNUM 14 - -/* Value should be nonzero if functions must have frame pointers. - Zero means the frame pointer need not be set up (and parms - may be accessed via the stack pointer) in functions that seem suitable. - This is computed in `reload', in reload1.c. */ -#define FRAME_POINTER_REQUIRED 0 - -/* Base register for access to arguments of the function. */ -#define ARG_POINTER_REGNUM 14 - -/* Register in which static-chain is passed to a function. */ -#define STATIC_CHAIN_REGNUM 8 - -/* Register in which address to store a structure value - is passed to a function. */ -#define STRUCT_VALUE_REGNUM 9 - -/* Define the classes of registers for register constraints in the - machine description. Also define ranges of constants. - - One of the classes must always be named ALL_REGS and include all hard regs. - If there is more than one class, another class must be named NO_REGS - and contain no registers. - - The name GENERAL_REGS must be the name of a class (or an alias for - another name such as ALL_REGS). This is the class of registers - that is allowed by "g" or "r" in a register constraint. - Also, registers outside this class are allocated only when - instructions express preferences for them. - - The classes must be numbered in nondecreasing order; that is, - a larger-numbered class must never be contained completely - in a smaller-numbered class. - - For any two classes, it is very desirable that there be another - class that represents their union. */ - -/* The 68000 has three kinds of registers, so eight classes would be - a complete set. One of them is not needed. */ - -#ifndef SUPPORT_SUN_FPA - -enum reg_class { - NO_REGS, DATA_REGS, - ADDR_REGS, FP_REGS, - GENERAL_REGS, DATA_OR_FP_REGS, - ADDR_OR_FP_REGS, ALL_REGS, - LIM_REG_CLASSES }; - -#define N_REG_CLASSES (int) LIM_REG_CLASSES - -/* Give names of register classes as strings for dump file. */ - -#define REG_CLASS_NAMES \ - { "NO_REGS", "DATA_REGS", \ - "ADDR_REGS", "FP_REGS", \ - "GENERAL_REGS", "DATA_OR_FP_REGS", \ - "ADDR_OR_FP_REGS", "ALL_REGS" } - -/* Define which registers fit in which classes. - This is an initializer for a vector of HARD_REG_SET - of length N_REG_CLASSES. */ - -#define REG_CLASS_CONTENTS \ -{ \ - 0x00000000, /* NO_REGS */ \ - 0x000000ff, /* DATA_REGS */ \ - 0x0000ff00, /* ADDR_REGS */ \ - 0x00ff0000, /* FP_REGS */ \ - 0x0000ffff, /* GENERAL_REGS */ \ - 0x00ff00ff, /* DATA_OR_FP_REGS */ \ - 0x00ffff00, /* ADDR_OR_FP_REGS */ \ - 0x00ffffff, /* ALL_REGS */ \ -} - -/* The same information, inverted: - Return the class number of the smallest class containing - reg number REGNO. This could be a conditional expression - or could index an array. */ - -#define REGNO_REG_CLASS(REGNO) (((REGNO)>>3)+1) - -#else /* defined SUPPORT_SUN_FPA */ - -/* - * Notes on final choices: - * - * 1) Didn't feel any need to union-ize LOW_FPA_REGS with anything - * else. - * 2) Removed all unions that involve address registers with - * floating point registers (left in unions of address and data with - * floating point). - * 3) Defined GENERAL_REGS as ADDR_OR_DATA_REGS. - * 4) Defined ALL_REGS as FPA_OR_FP_OR_GENERAL_REGS. - * 4) Left in everything else. - */ -enum reg_class { NO_REGS, LO_FPA_REGS, FPA_REGS, FP_REGS, - FP_OR_FPA_REGS, DATA_REGS, DATA_OR_FPA_REGS, DATA_OR_FP_REGS, - DATA_OR_FP_OR_FPA_REGS, ADDR_REGS, GENERAL_REGS, - GENERAL_OR_FPA_REGS, GENERAL_OR_FP_REGS, ALL_REGS, - LIM_REG_CLASSES }; - -#define N_REG_CLASSES (int) LIM_REG_CLASSES - -/* Give names of register classes as strings for dump file. */ - -#define REG_CLASS_NAMES \ - { "NO_REGS", "LO_FPA_REGS", "FPA_REGS", "FP_REGS", \ - "FP_OR_FPA_REGS", "DATA_REGS", "DATA_OR_FPA_REGS", "DATA_OR_FP_REGS", \ - "DATA_OR_FP_OR_FPA_REGS", "ADDR_REGS", "GENERAL_REGS", \ - "GENERAL_OR_FPA_REGS", "GENERAL_OR_FP_REGS", "ALL_REGS" } - -/* Define which registers fit in which classes. - This is an initializer for a vector of HARD_REG_SET - of length N_REG_CLASSES. */ - -#define REG_CLASS_CONTENTS \ -{ \ - {0, 0}, /* NO_REGS */ \ - {0xff000000, 0x000000ff}, /* LO_FPA_REGS */ \ - {0xff000000, 0x00ffffff}, /* FPA_REGS */ \ - {0x00ff0000, 0x00000000}, /* FP_REGS */ \ - {0xffff0000, 0x00ffffff}, /* FP_OR_FPA_REGS */ \ - {0x000000ff, 0x00000000}, /* DATA_REGS */ \ - {0xff0000ff, 0x00ffffff}, /* DATA_OR_FPA_REGS */ \ - {0x00ff00ff, 0x00000000}, /* DATA_OR_FP_REGS */ \ - {0xffff00ff, 0x00ffffff}, /* DATA_OR_FP_OR_FPA_REGS */\ - {0x0000ff00, 0x00000000}, /* ADDR_REGS */ \ - {0x0000ffff, 0x00000000}, /* GENERAL_REGS */ \ - {0xff00ffff, 0x00ffffff}, /* GENERAL_OR_FPA_REGS */\ - {0x00ffffff, 0x00000000}, /* GENERAL_OR_FP_REGS */\ - {0xffffffff, 0x00ffffff}, /* ALL_REGS */ \ -} - -/* The same information, inverted: - Return the class number of the smallest class containing - reg number REGNO. This could be a conditional expression - or could index an array. */ - -extern enum reg_class regno_reg_class[]; -#define REGNO_REG_CLASS(REGNO) (regno_reg_class[(REGNO)>>3]) - -#endif /* SUPPORT_SUN_FPA */ - -/* The class value for index registers, and the one for base regs. */ - -#define INDEX_REG_CLASS GENERAL_REGS -#define BASE_REG_CLASS ADDR_REGS - -/* Get reg_class from a letter such as appears in the machine description. - We do a trick here to modify the effective constraints on the - machine description; we zorch the constraint letters that aren't - appropriate for a specific target. This allows us to guarantee - that a specific kind of register will not be used for a given target - without fiddling with the register classes above. */ - -#ifndef SUPPORT_SUN_FPA - -#define REG_CLASS_FROM_LETTER(C) \ - ((C) == 'a' ? ADDR_REGS : \ - ((C) == 'd' ? DATA_REGS : \ - ((C) == 'f' ? (TARGET_68881 ? FP_REGS : \ - NO_REGS) : \ - NO_REGS))) - -#else /* defined SUPPORT_SUN_FPA */ - -#define REG_CLASS_FROM_LETTER(C) \ - ((C) == 'a' ? ADDR_REGS : \ - ((C) == 'd' ? DATA_REGS : \ - ((C) == 'f' ? (TARGET_68881 ? FP_REGS : \ - NO_REGS) : \ - ((C) == 'x' ? (TARGET_FPA ? FPA_REGS : \ - NO_REGS) : \ - ((C) == 'y' ? (TARGET_FPA ? LO_FPA_REGS : \ - NO_REGS) : \ - NO_REGS))))) - -#endif /* defined SUPPORT_SUN_FPA */ - -/* The letters I, J, K, L and M in a register constraint string - can be used to stand for particular ranges of immediate operands. - This macro defines what the ranges are. - C is the letter, and VALUE is a constant value. - Return 1 if VALUE is in the range specified by C. - - For the 68000, `I' is used for the range 1 to 8 - allowed as immediate shift counts and in addq. - `J' is used for the range of signed numbers that fit in 16 bits. - `K' is for numbers that moveq can't handle. - `L' is for range -8 to -1, range of values that can be added with subq. */ - -#define CONST_OK_FOR_LETTER_P(VALUE, C) \ - ((C) == 'I' ? (VALUE) > 0 && (VALUE) <= 8 : \ - (C) == 'J' ? (VALUE) >= -0x8000 && (VALUE) <= 0x7FFF : \ - (C) == 'K' ? (VALUE) < -0x80 || (VALUE) >= 0x80 : \ - (C) == 'L' ? (VALUE) < 0 && (VALUE) >= -8 : 0) - -/* - * A small bit of explanation: - * "G" defines all of the floating constants that are *NOT* 68881 - * constants. this is so 68881 constants get reloaded and the - * fpmovecr is used. "H" defines *only* the class of constants that - * the fpa can use, because these can be gotten at in any fpa - * instruction and there is no need to force reloads. - */ -#ifndef SUPPORT_SUN_FPA -#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ - ((C) == 'G' ? ! (TARGET_68881 && standard_68881_constant_p (VALUE)) : 0 ) -#else /* defined SUPPORT_SUN_FPA */ -#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ - ((C) == 'G' ? ! (TARGET_68881 && standard_68881_constant_p (VALUE)) : \ - (C) == 'H' ? (TARGET_FPA && standard_sun_fpa_constant_p (VALUE)) : 0) -#endif /* defined SUPPORT_SUN_FPA */ - -/* Given an rtx X being reloaded into a reg required to be - in class CLASS, return the class of reg to actually use. - In general this is just CLASS; but on some machines - in some cases it is preferable to use a more restrictive class. - On the 68000 series, use a data reg if possible when the - value is a constant in the range where moveq could be used - and we ensure that QImodes are reloaded into data regs. - Also, if a floating constant needs reloading, put it in memory - if possible. */ - -#define PREFERRED_RELOAD_CLASS(X,CLASS) \ - ((GET_CODE (X) == CONST_INT \ - && (unsigned) (INTVAL (X) + 0x80) < 0x100 \ - && (CLASS) != ADDR_REGS) \ - ? DATA_REGS \ - : (GET_MODE (X) == QImode && (CLASS) != ADDR_REGS) \ - ? DATA_REGS \ - : (GET_CODE (X) == CONST_DOUBLE \ - && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \ - ? NO_REGS \ - : (CLASS)) - -/* Return the maximum number of consecutive registers - needed to represent mode MODE in a register of class CLASS. */ -/* On the 68000, this is the size of MODE in words, - except in the FP regs, where a single reg is always enough. */ -#ifndef SUPPORT_SUN_FPA - -#define CLASS_MAX_NREGS(CLASS, MODE) \ - ((CLASS) == FP_REGS ? 1 \ - : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) - -/* Moves between fp regs and other regs are two insns. */ -#define REGISTER_MOVE_COST(CLASS1, CLASS2) \ - (((CLASS1) == FP_REGS && (CLASS2) != FP_REGS) \ - || ((CLASS2) == FP_REGS && (CLASS1) != FP_REGS) \ - ? 4 : 2) - -#else /* defined SUPPORT_SUN_FPA */ - -#define CLASS_MAX_NREGS(CLASS, MODE) \ - ((CLASS) == FP_REGS || (CLASS) == FPA_REGS || (CLASS) == LO_FPA_REGS ? 1 \ - : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) - -/* Moves between fp regs and other regs are two insns. */ -/* Likewise for high fpa regs and other regs. */ -#define REGISTER_MOVE_COST(CLASS1, CLASS2) \ - ((((CLASS1) == FP_REGS && (CLASS2) != FP_REGS) \ - || ((CLASS2) == FP_REGS && (CLASS1) != FP_REGS) \ - || ((CLASS1) == FPA_REGS && (CLASS2) != FPA_REGS) \ - || ((CLASS2) == FPA_REGS && (CLASS1) != FPA_REGS)) \ - ? 4 : 2) - -#endif /* define SUPPORT_SUN_FPA */ - -/* Stack layout; function entry, exit and calling. */ - -/* Define this if pushing a word on the stack - makes the stack pointer a smaller address. */ -#define STACK_GROWS_DOWNWARD - -/* Nonzero if we need to generate stack-probe insns. - On most systems they are not needed. - When they are needed, define this as the stack offset to probe at. */ -#define NEED_PROBE 0 - -/* Define this if the nominal address of the stack frame - is at the high-address end of the local variables; - that is, each additional local variable allocated - goes at a more negative offset in the frame. */ -#define FRAME_GROWS_DOWNWARD - -/* Offset within stack frame to start allocating local variables at. - If FRAME_GROWS_DOWNWARD, this is the offset to the END of the - first local allocated. Otherwise, it is the offset to the BEGINNING - of the first local allocated. */ -#define STARTING_FRAME_OFFSET 0 - -/* If we generate an insn to push BYTES bytes, - this says how many the stack pointer really advances by. - On the 68000, sp@- in a byte insn really pushes a word. */ -#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1) - -/* Offset of first parameter from the argument pointer register value. */ -#define FIRST_PARM_OFFSET(FNDECL) 8 - -/* Value is the number of byte of arguments automatically - popped when returning from a subroutine call. - FUNTYPE is the data type of the function (as a tree), - or for a library call it is an identifier node for the subroutine name. - SIZE is the number of bytes of arguments passed on the stack. - - On the 68000, the RTS insn cannot pop anything. - On the 68010, the RTD insn may be used to pop them if the number - of args is fixed, but if the number is variable then the caller - must pop them all. RTD can't be used for library calls now - because the library is compiled with the Unix compiler. - Use of RTD is a selectable option, since it is incompatible with - standard Unix calling sequences. If the option is not selected, - the caller must always pop the args. */ - -#define RETURN_POPS_ARGS(FUNTYPE,SIZE) \ - ((TARGET_RTD && TREE_CODE (FUNTYPE) != IDENTIFIER_NODE \ - && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ - || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ - == void_type_node))) \ - ? (SIZE) : 0) - -/* Define how to find the value returned by a function. - VALTYPE is the data type of the value (as a tree). - If the precise function being called is known, FUNC is its FUNCTION_DECL; - otherwise, FUNC is 0. */ - -/* On the 68000 the return value is in D0 regardless. */ - -#define FUNCTION_VALUE(VALTYPE, FUNC) \ - gen_rtx (REG, TYPE_MODE (VALTYPE), 0) - -/* Define how to find the value returned by a library function - assuming the value has mode MODE. */ - -/* On the 68000 the return value is in D0 regardless. */ - -#define LIBCALL_VALUE(MODE) gen_rtx (REG, MODE, 0) - -/* 1 if N is a possible register number for a function value. - On the 68000, d0 is the only register thus used. */ - -#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0) - -/* Define this to be true when FUNCTION_VALUE_REGNO_P is true for - more than one register. */ - -#define NEEDS_UNTYPED_CALL 0 - -/* Define this if PCC uses the nonreentrant convention for returning - structure and union values. */ - -#define PCC_STATIC_STRUCT_RETURN - -/* 1 if N is a possible register number for function argument passing. - On the 68000, no registers are used in this way. */ - -#define FUNCTION_ARG_REGNO_P(N) 0 - -/* Define a data type for recording info about an argument list - during the scan of that argument list. This data type should - hold all necessary information about the function itself - and about the args processed so far, enough to enable macros - such as FUNCTION_ARG to determine where the next arg should go. - - On the m68k, this is a single integer, which is a number of bytes - of arguments scanned so far. */ - -#define CUMULATIVE_ARGS int - -/* Initialize a variable CUM of type CUMULATIVE_ARGS - for a call to a function whose data type is FNTYPE. - For a library call, FNTYPE is 0. - - On the m68k, the offset starts at 0. */ - -#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) \ - ((CUM) = 0) - -/* Update the data in CUM to advance over an argument - of mode MODE and data type TYPE. - (TYPE is null for libcalls where that information may not be available.) */ - -#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ - ((CUM) += ((MODE) != BLKmode \ - ? (GET_MODE_SIZE (MODE) + 3) & ~3 \ - : (int_size_in_bytes (TYPE) + 3) & ~3)) - -/* Define where to put the arguments to a function. - Value is zero to push the argument on the stack, - or a hard register in which to store the argument. - - MODE is the argument's machine mode. - TYPE is the data type of the argument (as a tree). - This is null for libcalls where that information may - not be available. - CUM is a variable of type CUMULATIVE_ARGS which gives info about - the preceding args and about the function being called. - NAMED is nonzero if this argument is a named parameter - (otherwise it is an extra parameter matching an ellipsis). */ - -/* On the 68000 all args are pushed, except if -mregparm is specified - then the first two words of arguments are passed in d0, d1. - *NOTE* -mregparm does not work. - It exists only to test register calling conventions. */ - -#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ -((TARGET_REGPARM && (CUM) < 8) ? gen_rtx (REG, (MODE), (CUM) / 4) : 0) - -/* For an arg passed partly in registers and partly in memory, - this is the number of registers used. - For args passed entirely in registers or entirely in memory, zero. */ - -#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \ -((TARGET_REGPARM && (CUM) < 8 \ - && 8 < ((CUM) + ((MODE) == BLKmode \ - ? int_size_in_bytes (TYPE) \ - : GET_MODE_SIZE (MODE)))) \ - ? 2 - (CUM) / 4 : 0) - -/* Generate the assembly code for function entry. */ -#define FUNCTION_PROLOGUE(FILE, SIZE) output_function_prologue(FILE, SIZE) - -/* Output assembler code to FILE to increment profiler label # LABELNO - for profiling a function entry. */ - -#define FUNCTION_PROFILER(FILE, LABELNO) \ - asm_fprintf (FILE, "\tlea %LLP%d,%Ra0\n\tjsr mcount\n", (LABELNO)) - -/* Output assembler code to FILE to initialize this source file's - basic block profiling info, if that has not already been done. */ - -#define FUNCTION_BLOCK_PROFILER(FILE, LABELNO) \ - asm_fprintf (FILE, "\ttstl %LLPBX0\n\tbne %LLPI%d\n\tpea %LLPBX0\n\tjsr %U__bb_init_func\n\taddql %I4,%Rsp\n%LLPI%d:\n", \ - LABELNO, LABELNO); - -/* Output assembler code to FILE to increment the entry-count for - the BLOCKNO'th basic block in this source file. */ - -#define BLOCK_PROFILER(FILE, BLOCKNO) \ - asm_fprintf (FILE, "\taddql %I1,%LLPBX2+%d\n", 4 * BLOCKNO) - -/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, - the stack pointer does not matter. The value is tested only in - functions that have frame pointers. - No definition is equivalent to always zero. */ - -#define EXIT_IGNORE_STACK 1 - -/* Generate the assembly code for function exit. */ -#define FUNCTION_EPILOGUE(FILE, SIZE) output_function_epilogue (FILE, SIZE) - -/* This is a hook for other tm files to change. */ -/* #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) */ - -/* Determine if the epilogue should be output as RTL. - You should override this if you define FUNCTION_EXTRA_EPILOGUE. */ -#define USE_RETURN_INSN use_return_insn () - -/* Store in the variable DEPTH the initial difference between the - frame pointer reg contents and the stack pointer reg contents, - as of the start of the function body. This depends on the layout - of the fixed parts of the stack frame and on how registers are saved. - - On the 68k, if we have a frame, we must add one word to its length - to allow for the place that a6 is stored when we do have a frame pointer. - Otherwise, we would need to compute the offset from the frame pointer - of a local variable as a function of frame_pointer_needed, which - is hard. */ - -#define INITIAL_FRAME_POINTER_OFFSET(DEPTH) \ -{ int regno; \ - int offset = -4; \ - for (regno = 16; regno < FIRST_PSEUDO_REGISTER; regno++) \ - if (regs_ever_live[regno] && ! call_used_regs[regno]) \ - offset += 12; \ - for (regno = 0; regno < 16; regno++) \ - if (regs_ever_live[regno] && ! call_used_regs[regno]) \ - offset += 4; \ - (DEPTH) = (offset + ((get_frame_size () + 3) & -4) \ - + (get_frame_size () == 0 ? 0 : 4)); \ -} - -/* Output assembler code for a block containing the constant parts - of a trampoline, leaving space for the variable parts. */ - -/* On the 68k, the trampoline looks like this: - mov @#.,a0 - jsr @#___trampoline - jsr @#___trampoline - .long STATIC - .long FUNCTION -The reason for having three jsr insns is so that an entire line -of the instruction cache is filled in a predictable way -that will always be the same. - -We always use the assembler label ___trampoline -regardless of whether the system adds underscores. */ - -#define TRAMPOLINE_TEMPLATE(FILE) \ -{ \ - ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x207c)); \ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ - ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x4eb9)); \ - ASM_OUTPUT_INT (FILE, gen_rtx (SYMBOL_REF, SImode, "*___trampoline"));\ - ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x4eb9)); \ - ASM_OUTPUT_INT (FILE, gen_rtx (SYMBOL_REF, SImode, "*___trampoline"));\ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ -} - -/* Length in units of the trampoline for entering a nested function. */ - -#define TRAMPOLINE_SIZE 26 - -/* Alignment required for a trampoline. 16 is used to find the - beginning of a line in the instruction cache. */ - -#define TRAMPOLINE_ALIGN 16 - -/* Emit RTL insns to initialize the variable parts of a trampoline. - FNADDR is an RTX for the address of the function's pure code. - CXT is an RTX for the static chain value for the function. */ - -#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \ -{ \ - emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 2)), TRAMP); \ - emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 18)), CXT); \ - emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 22)), FNADDR); \ -} - -/* This is the library routine that is used - to transfer control from the trampoline - to the actual nested function. */ - -/* A colon is used with no explicit operands - to cause the template string to be scanned for %-constructs. */ -/* The function name __transfer_from_trampoline is not actually used. - The function definition just permits use of "asm with operands" - (though the operand list is empty). */ -#define TRANSFER_FROM_TRAMPOLINE \ -void \ -__transfer_from_trampoline () \ -{ \ - register char *a0 asm ("%a0"); \ - asm (GLOBAL_ASM_OP " ___trampoline"); \ - asm ("___trampoline:"); \ - asm volatile ("move%.l %0,%@" : : "m" (a0[22])); \ - asm volatile ("move%.l %1,%0" : "=a" (a0) : "m" (a0[18])); \ - asm ("rts":); \ -} - -/* Addressing modes, and classification of registers for them. */ - -#define HAVE_POST_INCREMENT -/* #define HAVE_POST_DECREMENT */ - -#define HAVE_PRE_DECREMENT -/* #define HAVE_PRE_INCREMENT */ - -/* Macros to check register numbers against specific register classes. */ - -/* These assume that REGNO is a hard or pseudo reg number. - They give nonzero only if REGNO is a hard reg of the suitable class - or a pseudo reg currently allocated to a suitable hard reg. - Since they use reg_renumber, they are safe only once reg_renumber - has been allocated, which happens in local-alloc.c. */ - -#define REGNO_OK_FOR_INDEX_P(REGNO) \ -((REGNO) < 16 || (unsigned) reg_renumber[REGNO] < 16) -#define REGNO_OK_FOR_BASE_P(REGNO) \ -(((REGNO) ^ 010) < 8 || (unsigned) (reg_renumber[REGNO] ^ 010) < 8) -#define REGNO_OK_FOR_DATA_P(REGNO) \ -((REGNO) < 8 || (unsigned) reg_renumber[REGNO] < 8) -#define REGNO_OK_FOR_FP_P(REGNO) \ -(((REGNO) ^ 020) < 8 || (unsigned) (reg_renumber[REGNO] ^ 020) < 8) -#ifdef SUPPORT_SUN_FPA -#define REGNO_OK_FOR_FPA_P(REGNO) \ -(((REGNO) >= 24 && (REGNO) < 56) || (reg_renumber[REGNO] >= 24 && reg_renumber[REGNO] < 56)) -#endif - -/* Now macros that check whether X is a register and also, - strictly, whether it is in a specified class. - - These macros are specific to the 68000, and may be used only - in code for printing assembler insns and in conditions for - define_optimization. */ - -/* 1 if X is a data register. */ - -#define DATA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_DATA_P (REGNO (X))) - -/* 1 if X is an fp register. */ - -#define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X))) - -/* 1 if X is an address register */ - -#define ADDRESS_REG_P(X) (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X))) - -#ifdef SUPPORT_SUN_FPA -/* 1 if X is a register in the Sun FPA. */ -#define FPA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FPA_P (REGNO (X))) -#else -/* Answer must be no if we don't have an FPA. */ -#define FPA_REG_P(X) 0 -#endif - -/* Maximum number of registers that can appear in a valid memory address. */ - -#define MAX_REGS_PER_ADDRESS 2 - -/* Recognize any constant value that is a valid address. */ - -#define CONSTANT_ADDRESS_P(X) \ - (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ - || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \ - || GET_CODE (X) == HIGH) - -/* Nonzero if the constant value X is a legitimate general operand. - It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ - -#define LEGITIMATE_CONSTANT_P(X) 1 - -/* Nonzero if the constant value X is a legitimate general operand - when generating PIC code. It is given that flag_pic is on and - that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ - -#define LEGITIMATE_PIC_OPERAND_P(X) \ - (! symbolic_operand (X, VOIDmode) \ - || ((GET_CODE(X) == SYMBOL_REF) && SYMBOL_REF_FLAG(X))) - -/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx - and check its validity for a certain class. - We have two alternate definitions for each of them. - The usual definition accepts all pseudo regs; the other rejects - them unless they have been allocated suitable hard regs. - The symbol REG_OK_STRICT causes the latter definition to be used. - - Most source files want to accept pseudo regs in the hope that - they will get allocated to the class that the insn wants them to be in. - Source files for reload pass need to be strict. - After reload, it makes no difference, since pseudo regs have - been eliminated by then. */ - -#ifndef REG_OK_STRICT - -/* Nonzero if X is a hard reg that can be used as an index - or if it is a pseudo reg. */ -#define REG_OK_FOR_INDEX_P(X) ((REGNO (X) ^ 020) >= 8) -/* Nonzero if X is a hard reg that can be used as a base reg - or if it is a pseudo reg. */ -#define REG_OK_FOR_BASE_P(X) ((REGNO (X) & ~027) != 0) - -#else - -/* Nonzero if X is a hard reg that can be used as an index. */ -#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X)) -/* Nonzero if X is a hard reg that can be used as a base reg. */ -#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) - -#endif - -/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression - that is a valid memory address for an instruction. - The MODE argument is the machine mode for the MEM expression - that wants to use this address. - - When generating PIC, an address involving a SYMBOL_REF is legitimate - if and only if it is the sum of pic_offset_table_rtx and the SYMBOL_REF. - We use LEGITIMATE_PIC_OPERAND_P to throw out the illegitimate addresses, - and we explicitly check for the sum of pic_offset_table_rtx and a SYMBOL_REF. - - Likewise for a LABEL_REF when generating PIC. - - The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */ - -#define INDIRECTABLE_1_ADDRESS_P(X) \ - ((CONSTANT_ADDRESS_P (X) && (!flag_pic || LEGITIMATE_PIC_OPERAND_P (X))) \ - || (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \ - || ((GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_INC) \ - && REG_P (XEXP (X, 0)) \ - && REG_OK_FOR_BASE_P (XEXP (X, 0))) \ - || (GET_CODE (X) == PLUS \ - && REG_P (XEXP (X, 0)) && REG_OK_FOR_BASE_P (XEXP (X, 0)) \ - && GET_CODE (XEXP (X, 1)) == CONST_INT \ - && ((unsigned) INTVAL (XEXP (X, 1)) + 0x8000) < 0x10000) \ - || (GET_CODE (X) == PLUS && XEXP (X, 0) == pic_offset_table_rtx \ - && flag_pic && GET_CODE (XEXP (X, 1)) == SYMBOL_REF) \ - || (GET_CODE (X) == PLUS && XEXP (X, 0) == pic_offset_table_rtx \ - && flag_pic && GET_CODE (XEXP (X, 1)) == LABEL_REF)) \ - -#if 0 -/* This should replace the last two (non-pic) lines - except that Sun's assembler does not seem to handle such operands. */ - && (TARGET_68020 ? CONSTANT_ADDRESS_P (XEXP (X, 1)) \ - : (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && ((unsigned) INTVAL (XEXP (X, 1)) + 0x8000) < 0x10000)))) -#endif - - -#define GO_IF_NONINDEXED_ADDRESS(X, ADDR) \ -{ if (INDIRECTABLE_1_ADDRESS_P (X)) goto ADDR; } - -/* Only labels on dispatch tables are valid for indexing from. */ -#define GO_IF_INDEXABLE_BASE(X, ADDR) \ -{ rtx temp; \ - if (GET_CODE (X) == LABEL_REF \ - && (temp = next_nonnote_insn (XEXP (X, 0))) != 0 \ - && GET_CODE (temp) == JUMP_INSN \ - && (GET_CODE (PATTERN (temp)) == ADDR_VEC \ - || GET_CODE (PATTERN (temp)) == ADDR_DIFF_VEC)) \ - goto ADDR; \ - if (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) goto ADDR; } - -#define GO_IF_INDEXING(X, ADDR) \ -{ if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 0))) \ - { GO_IF_INDEXABLE_BASE (XEXP (X, 1), ADDR); } \ - if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 1))) \ - { GO_IF_INDEXABLE_BASE (XEXP (X, 0), ADDR); } } - -#define GO_IF_INDEXED_ADDRESS(X, ADDR) \ -{ GO_IF_INDEXING (X, ADDR); \ - if (GET_CODE (X) == PLUS) \ - { if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && (unsigned) INTVAL (XEXP (X, 1)) + 0x80 < 0x100) \ - { rtx go_temp = XEXP (X, 0); GO_IF_INDEXING (go_temp, ADDR); } \ - if (GET_CODE (XEXP (X, 0)) == CONST_INT \ - && (unsigned) INTVAL (XEXP (X, 0)) + 0x80 < 0x100) \ - { rtx go_temp = XEXP (X, 1); GO_IF_INDEXING (go_temp, ADDR); } } } - -#define LEGITIMATE_INDEX_REG_P(X) \ - ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \ - || (GET_CODE (X) == SIGN_EXTEND \ - && GET_CODE (XEXP (X, 0)) == REG \ - && GET_MODE (XEXP (X, 0)) == HImode \ - && REG_OK_FOR_INDEX_P (XEXP (X, 0)))) - -#define LEGITIMATE_INDEX_P(X) \ - (LEGITIMATE_INDEX_REG_P (X) \ - || (TARGET_68020 && GET_CODE (X) == MULT \ - && LEGITIMATE_INDEX_REG_P (XEXP (X, 0)) \ - && GET_CODE (XEXP (X, 1)) == CONST_INT \ - && (INTVAL (XEXP (X, 1)) == 2 \ - || INTVAL (XEXP (X, 1)) == 4 \ - || INTVAL (XEXP (X, 1)) == 8))) - -#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ -{ GO_IF_NONINDEXED_ADDRESS (X, ADDR); \ - GO_IF_INDEXED_ADDRESS (X, ADDR); } - -/* Try machine-dependent ways of modifying an illegitimate address - to be legitimate. If we find one, return the new, valid address. - This macro is used in only one place: `memory_address' in explow.c. - - OLDX is the address as it was before break_out_memory_refs was called. - In some cases it is useful to look at this to decide what needs to be done. - - MODE and WIN are passed so that this macro can use - GO_IF_LEGITIMATE_ADDRESS. - - It is always safe for this macro to do nothing. It exists to recognize - opportunities to optimize the output. - - For the 68000, we handle X+REG by loading X into a register R and - using R+REG. R will go in an address reg and indexing will be used. - However, if REG is a broken-out memory address or multiplication, - nothing needs to be done because REG can certainly go in an address reg. */ - -#define COPY_ONCE(Y) if (!copied) { Y = copy_rtx (Y); copied = ch = 1; } -#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \ -{ register int ch = (X) != (OLDX); \ - if (GET_CODE (X) == PLUS) \ - { int copied = 0; \ - if (GET_CODE (XEXP (X, 0)) == MULT) \ - { COPY_ONCE (X); XEXP (X, 0) = force_operand (XEXP (X, 0), 0);} \ - if (GET_CODE (XEXP (X, 1)) == MULT) \ - { COPY_ONCE (X); XEXP (X, 1) = force_operand (XEXP (X, 1), 0);} \ - if (ch && GET_CODE (XEXP (X, 1)) == REG \ - && GET_CODE (XEXP (X, 0)) == REG) \ - goto WIN; \ - if (ch) { GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN); } \ - if (GET_CODE (XEXP (X, 0)) == REG \ - || (GET_CODE (XEXP (X, 0)) == SIGN_EXTEND \ - && GET_CODE (XEXP (XEXP (X, 0), 0)) == REG \ - && GET_MODE (XEXP (XEXP (X, 0), 0)) == HImode)) \ - { register rtx temp = gen_reg_rtx (Pmode); \ - register rtx val = force_operand (XEXP (X, 1), 0); \ - emit_move_insn (temp, val); \ - COPY_ONCE (X); \ - XEXP (X, 1) = temp; \ - goto WIN; } \ - else if (GET_CODE (XEXP (X, 1)) == REG \ - || (GET_CODE (XEXP (X, 1)) == SIGN_EXTEND \ - && GET_CODE (XEXP (XEXP (X, 1), 0)) == REG \ - && GET_MODE (XEXP (XEXP (X, 1), 0)) == HImode)) \ - { register rtx temp = gen_reg_rtx (Pmode); \ - register rtx val = force_operand (XEXP (X, 0), 0); \ - emit_move_insn (temp, val); \ - COPY_ONCE (X); \ - XEXP (X, 0) = temp; \ - goto WIN; }}} - -/* Go to LABEL if ADDR (a legitimate address expression) - has an effect that depends on the machine mode it is used for. - On the 68000, only predecrement and postincrement address depend thus - (the amount of decrement or increment being the length of the operand). */ - -#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \ - if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == PRE_DEC) goto LABEL - -/* Specify the machine mode that this machine uses - for the index in the tablejump instruction. */ -#define CASE_VECTOR_MODE HImode - -/* Define this if the tablejump instruction expects the table - to contain offsets from the address of the table. - Do not define this if the table should contain absolute addresses. */ -#define CASE_VECTOR_PC_RELATIVE - -/* Specify the tree operation to be used to convert reals to integers. */ -#define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR - -/* This is the kind of divide that is easiest to do in the general case. */ -#define EASY_DIV_EXPR TRUNC_DIV_EXPR - -/* Define this as 1 if `char' should by default be signed; else as 0. */ -#define DEFAULT_SIGNED_CHAR 1 - -/* Don't cse the address of the function being compiled. */ -#define NO_RECURSIVE_FUNCTION_CSE - -/* Max number of bytes we can move from memory to memory - in one reasonably fast instruction. */ -#define MOVE_MAX 4 - -/* Define this if zero-extension is slow (more than one real instruction). */ -#define SLOW_ZERO_EXTEND - -/* Nonzero if access to memory by bytes is slow and undesirable. */ -#define SLOW_BYTE_ACCESS 0 - -/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits - is done just by pretending it is already truncated. */ -#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 - -/* We assume that the store-condition-codes instructions store 0 for false - and some other value for true. This is the value stored for true. */ - -#define STORE_FLAG_VALUE -1 - -/* When a prototype says `char' or `short', really pass an `int'. */ -#define PROMOTE_PROTOTYPES - -/* Specify the machine mode that pointers have. - After generation of rtl, the compiler makes no further distinction - between pointers and any other objects of this machine mode. */ -#define Pmode SImode - -/* A function address in a call instruction - is a byte address (for indexing purposes) - so give the MEM rtx a byte's mode. */ -#define FUNCTION_MODE QImode - -/* Compute the cost of computing a constant rtl expression RTX - whose rtx-code is CODE. The body of this macro is a portion - of a switch statement. If the code is computed here, - return it with a return statement. Otherwise, break from the switch. */ - -#define CONST_COSTS(RTX,CODE,OUTER_CODE) \ - case CONST_INT: \ - /* Constant zero is super cheap due to clr instruction. */ \ - if (RTX == const0_rtx) return 0; \ - /* Constants between -128 and 127 are cheap due to moveq */ \ - if (INTVAL (RTX) >= -128 && INTVAL (RTX) <= 127) return 1; \ - /* Constants between -136 and 254 are easily generated */ \ - /* by intelligent uses of moveq, add[q], and subq */ \ - if ((OUTER_CODE) == SET && INTVAL (RTX) >= -136 \ - && INTVAL (RTX) <= 254) return 2; \ - case CONST: \ - case LABEL_REF: \ - case SYMBOL_REF: \ - return 3; \ - case CONST_DOUBLE: \ - return 5; - -/* Compute the cost of various arithmetic operations. - These are vaguely right for a 68020. */ -/* The costs for long multiply have been adjusted to - work properly in synth_mult on the 68020, - relative to an average of the time for add and the time for shift, - taking away a little more because sometimes move insns are needed. */ -#define MULL_COST (TARGET_68040 ? 5 : 13) -#define MULW_COST (TARGET_68040 ? 3 : 8) - -#define RTX_COSTS(X,CODE,OUTER_CODE) \ - case PLUS: \ - /* An lea costs about three times as much as a simple add. */ \ - if (GET_MODE (X) == SImode \ - && GET_CODE (XEXP (X, 0)) == REG \ - && GET_CODE (XEXP (X, 1)) == MULT \ - && GET_CODE (XEXP (XEXP (X, 1), 0)) == REG \ - && GET_CODE (XEXP (XEXP (X, 1), 1)) == CONST_INT \ - && (INTVAL (XEXP (XEXP (X, 1), 1)) == 2 \ - || INTVAL (XEXP (XEXP (X, 1), 1)) == 4 \ - || INTVAL (XEXP (XEXP (X, 1), 1)) == 8)) \ - return COSTS_N_INSNS (3); /* lea an@(dx:l:i),am */ \ - break; \ - case ASHIFT: \ - case ASHIFTRT: \ - case LSHIFT: \ - case LSHIFTRT: \ - /* A shift by a big integer takes an extra instruction. */ \ - if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && (INTVAL (XEXP (X, 1)) == 16)) \ - return COSTS_N_INSNS (2); /* clrw;swap */ \ - if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && !(INTVAL (XEXP (X, 1)) > 0 \ - && INTVAL (XEXP (X, 1)) <= 8)) \ - return COSTS_N_INSNS (3); /* lsr #i,dn */ \ - break; \ - case MULT: \ - if (GET_CODE (XEXP (x, 1)) == CONST_INT \ - && exact_log2 (INTVAL (XEXP (x, 1))) >= 0) \ - { \ - /* A shift by a big integer takes an extra instruction. */ \ - if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && (INTVAL (XEXP (X, 1)) == (1 << 16))) \ - return COSTS_N_INSNS (2); /* clrw;swap */ \ - if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && !(INTVAL (XEXP (X, 1)) > 1 \ - && INTVAL (XEXP (X, 1)) <= 256)) \ - return COSTS_N_INSNS (3); /* lsr #i,dn */ \ - break; \ - } \ - else if (GET_MODE (X) == QImode || GET_MODE (X) == HImode) \ - return COSTS_N_INSNS (MULW_COST); \ - else \ - return COSTS_N_INSNS (MULL_COST); \ - break; \ - case DIV: \ - case UDIV: \ - case MOD: \ - case UMOD: \ - if (GET_MODE (X) == QImode || GET_MODE (X) == HImode) \ - return COSTS_N_INSNS (27); /* div.w */ \ - return COSTS_N_INSNS (43); /* div.l */ - -/* Tell final.c how to eliminate redundant test instructions. */ - -/* Here we define machine-dependent flags and fields in cc_status - (see `conditions.h'). */ - -/* Set if the cc value is actually in the 68881, so a floating point - conditional branch must be output. */ -#define CC_IN_68881 04000 - -/* Store in cc_status the expressions that the condition codes will - describe after execution of an instruction whose pattern is EXP. - Do not alter them if the instruction would not alter the cc's. */ - -/* On the 68000, all the insns to store in an address register fail to - set the cc's. However, in some cases these instructions can make it - possibly invalid to use the saved cc's. In those cases we clear out - some or all of the saved cc's so they won't be used. */ - -#define NOTICE_UPDATE_CC(EXP,INSN) notice_update_cc (EXP, INSN) - -#define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \ -{ if (cc_prev_status.flags & CC_IN_68881) \ - return FLOAT; \ - if (cc_prev_status.flags & CC_NO_OVERFLOW) \ - return NO_OV; \ - return NORMAL; } - -/* Control the assembler format that we output. */ - -/* Output at beginning of assembler file. */ - -#define ASM_FILE_START(FILE) \ - fprintf (FILE, "#NO_APP\n"); - -/* Output to assembler file text saying following lines - may contain character constants, extra white space, comments, etc. */ - -#define ASM_APP_ON "#APP\n" - -/* Output to assembler file text saying following lines - no longer contain unusual constructs. */ - -#define ASM_APP_OFF "#NO_APP\n" - -/* Output before read-only data. */ - -#define TEXT_SECTION_ASM_OP ".text" - -/* Output before writable data. */ - -#define DATA_SECTION_ASM_OP ".data" - -/* Here are four prefixes that are used by asm_fprintf to - facilitate customization for alternate assembler syntaxes. - Machines with no likelihood of an alternate syntax need not - define these and need not use asm_fprintf. */ - -/* The prefix for register names. Note that REGISTER_NAMES - is supposed to include this prefix. */ - -#define REGISTER_PREFIX "" - -/* The prefix for local labels. You should be able to define this as - an empty string, or any arbitrary string (such as ".", ".L%", etc) - without having to make any other changes to account for the specific - definition. Note it is a string literal, not interpreted by printf - and friends. */ - -#define LOCAL_LABEL_PREFIX "" - -/* The prefix to add to user-visible assembler symbols. */ - -#define USER_LABEL_PREFIX "_" - -/* The prefix for immediate operands. */ - -#define IMMEDIATE_PREFIX "#" - -/* How to refer to registers in assembler output. - This sequence is indexed by compiler's hard-register-number (see above). */ - -#ifndef SUPPORT_SUN_FPA - -#define REGISTER_NAMES \ -{"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7" } - -#else /* SUPPORTED_SUN_FPA */ - -#define REGISTER_NAMES \ -{"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fpa0", "fpa1", "fpa2", "fpa3", "fpa4", "fpa5", "fpa6", "fpa7", \ - "fpa8", "fpa9", "fpa10", "fpa11", "fpa12", "fpa13", "fpa14", "fpa15", \ - "fpa16", "fpa17", "fpa18", "fpa19", "fpa20", "fpa21", "fpa22", "fpa23", \ - "fpa24", "fpa25", "fpa26", "fpa27", "fpa28", "fpa29", "fpa30", "fpa31" } - -#endif /* defined SUPPORT_SUN_FPA */ - -/* How to renumber registers for dbx and gdb. - On the Sun-3, the floating point registers have numbers - 18 to 25, not 16 to 23 as they do in the compiler. */ - -#define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2) - -/* This is how to output the definition of a user-level label named NAME, - such as the label on a static function or variable NAME. */ - -#define ASM_OUTPUT_LABEL(FILE,NAME) \ - do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0) - -/* This is how to output a command to make the user-level label named NAME - defined for reference from other files. */ - -#define GLOBAL_ASM_OP ".globl" -#define ASM_GLOBALIZE_LABEL(FILE,NAME) \ - do { fprintf (FILE, "%s ", GLOBAL_ASM_OP); \ - assemble_name (FILE, NAME); \ - fputs ("\n", FILE);} while (0) - -/* This is how to output a reference to a user-level label named NAME. - `assemble_name' uses this. */ - -#define ASM_OUTPUT_LABELREF(FILE,NAME) \ - asm_fprintf (FILE, "%0U%s", NAME) - -/* This is how to output an internal numbered label where - PREFIX is the class of label and NUM is the number within the class. */ - -#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ - asm_fprintf (FILE, "%0L%s%d:\n", PREFIX, NUM) - -/* This is how to store into the string LABEL - the symbol_ref name of an internal numbered label where - PREFIX is the class of label and NUM is the number within the class. - This is suitable for output with `assemble_name'. */ - -#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ - sprintf (LABEL, "*%s%s%d", LOCAL_LABEL_PREFIX, PREFIX, NUM) - -/* This is how to output a `long double' extended real constant. */ - -#define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \ -do { long l[3]; \ - REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \ - if (sizeof (int) == sizeof (long)) \ - fprintf (FILE, "\t.long 0x%x,0x%x,0x%x\n", l[0], l[1], l[2]); \ - else \ - fprintf (FILE, "\t.long 0x%lx,0x%lx,0x%lx\n", l[0], l[1], l[2]); \ - } while (0) - -/* This is how to output an assembler line defining a `double' constant. */ - -#define ASM_OUTPUT_DOUBLE(FILE,VALUE) \ - do { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ - fprintf (FILE, "\t.double 0r%s\n", dstr); \ - } while (0) - -/* This is how to output an assembler line defining a `float' constant. */ - -#define ASM_OUTPUT_FLOAT(FILE,VALUE) \ -do { long l; \ - REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \ - if (sizeof (int) == sizeof (long)) \ - fprintf (FILE, "\t.long 0x%x\n", l); \ - else \ - fprintf (FILE, "\t.long 0x%lx\n", l); \ - } while (0) - -/* This is how to output an assembler line defining an `int' constant. */ - -#define ASM_OUTPUT_INT(FILE,VALUE) \ -( fprintf (FILE, "\t.long "), \ - output_addr_const (FILE, (VALUE)), \ - fprintf (FILE, "\n")) - -/* Likewise for `char' and `short' constants. */ - -#define ASM_OUTPUT_SHORT(FILE,VALUE) \ -( fprintf (FILE, "\t.word "), \ - output_addr_const (FILE, (VALUE)), \ - fprintf (FILE, "\n")) - -#define ASM_OUTPUT_CHAR(FILE,VALUE) \ -( fprintf (FILE, "\t.byte "), \ - output_addr_const (FILE, (VALUE)), \ - fprintf (FILE, "\n")) - -/* This is how to output an assembler line for a numeric constant byte. */ - -#define ASM_OUTPUT_BYTE(FILE,VALUE) \ - fprintf (FILE, "\t.byte 0x%x\n", (VALUE)) - -/* This is how to output an insn to push a register on the stack. - It need not be very fast code. */ - -#define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \ - asm_fprintf (FILE, "\tmovel %s,%Rsp@-\n", reg_names[REGNO]) - -/* This is how to output an insn to pop a register from the stack. - It need not be very fast code. */ - -#define ASM_OUTPUT_REG_POP(FILE,REGNO) \ - asm_fprintf (FILE, "\tmovel %Rsp@+,%s\n", reg_names[REGNO]) - -/* This is how to output an element of a case-vector that is absolute. - (The 68000 does not use such vectors, - but we must define this macro anyway.) */ - -#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ - asm_fprintf (FILE, "\t.long %LL%d\n", VALUE) - -/* This is how to output an element of a case-vector that is relative. */ - -#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ - asm_fprintf (FILE, "\t.word %LL%d-%LL%d\n", VALUE, REL) - -/* This is how to output an assembler line - that says to advance the location counter - to a multiple of 2**LOG bytes. */ - -/* We don't have a way to align to more than a two-byte boundary, so do the - best we can and don't complain. */ -#define ASM_OUTPUT_ALIGN(FILE,LOG) \ - if ((LOG) >= 1) \ - fprintf (FILE, "\t.even\n"); - -#define ASM_OUTPUT_SKIP(FILE,SIZE) \ - fprintf (FILE, "\t.skip %u\n", (SIZE)) - -/* This says how to output an assembler line - to define a global common symbol. */ - -#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ -( fputs (".comm ", (FILE)), \ - assemble_name ((FILE), (NAME)), \ - fprintf ((FILE), ",%u\n", (ROUNDED))) - -/* This says how to output an assembler line - to define a local common symbol. */ - -#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ -( fputs (".lcomm ", (FILE)), \ - assemble_name ((FILE), (NAME)), \ - fprintf ((FILE), ",%u\n", (ROUNDED))) - -/* Store in OUTPUT a string (made with alloca) containing - an assembler-name for a local static variable named NAME. - LABELNO is an integer which is different for each call. */ - -#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ -( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \ - sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO))) - -/* Define the parentheses used to group arithmetic operations - in assembler code. */ - -#define ASM_OPEN_PAREN "(" -#define ASM_CLOSE_PAREN ")" - -/* Define results of standard character escape sequences. */ -#define TARGET_BELL 007 -#define TARGET_BS 010 -#define TARGET_TAB 011 -#define TARGET_NEWLINE 012 -#define TARGET_VT 013 -#define TARGET_FF 014 -#define TARGET_CR 015 - -/* Output a float value (represented as a C double) as an immediate operand. - This macro is a 68k-specific macro. */ - -#define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE) \ - do { \ - if (CODE == 'f') \ - { \ - char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.9g", dstr); \ - asm_fprintf ((FILE), "%I0r%s", dstr); \ - } \ - else \ - { \ - long l; \ - REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \ - if (sizeof (int) == sizeof (long)) \ - asm_fprintf ((FILE), "%I0x%x", l); \ - else \ - asm_fprintf ((FILE), "%I0x%lx", l); \ - } \ - } while (0) - -/* Output a double value (represented as a C double) as an immediate operand. - This macro is a 68k-specific macro. */ -#define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \ - do { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ - asm_fprintf (FILE, "%I0r%s", dstr); \ - } while (0) - -/* Note, long double immediate operands are not actually - generated by m68k.md. */ -#define ASM_OUTPUT_LONG_DOUBLE_OPERAND(FILE,VALUE) \ - do { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ - asm_fprintf (FILE, "%I0r%s", dstr); \ - } while (0) - -/* Print operand X (an rtx) in assembler syntax to file FILE. - CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. - For `%' followed by punctuation, CODE is the punctuation and X is null. - - On the 68000, we use several CODE characters: - '.' for dot needed in Motorola-style opcode names. - '-' for an operand pushing on the stack: - sp@-, -(sp) or -(%sp) depending on the style of syntax. - '+' for an operand pushing on the stack: - sp@+, (sp)+ or (%sp)+ depending on the style of syntax. - '@' for a reference to the top word on the stack: - sp@, (sp) or (%sp) depending on the style of syntax. - '#' for an immediate operand prefix (# in MIT and Motorola syntax - but & in SGS syntax). - '!' for the fpcr register (used in some float-to-fixed conversions). - '$' for the letter `s' in an op code, but only on the 68040. - '&' for the letter `d' in an op code, but only on the 68040. - '/' for register prefix needed by longlong.h. - - 'b' for byte insn (no effect, on the Sun; this is for the ISI). - 'd' to force memory addressing to be absolute, not relative. - 'f' for float insn (print a CONST_DOUBLE as a float rather than in hex) - 'w' for FPA insn (print a CONST_DOUBLE as a SunFPA constant rather - than directly). Second part of 'y' below. - 'x' for float insn (print a CONST_DOUBLE as a float rather than in hex), - or print pair of registers as rx:ry. - 'y' for a FPA insn (print pair of registers as rx:ry). This also outputs - CONST_DOUBLE's as SunFPA constant RAM registers if - possible, so it should not be used except for the SunFPA. */ - -#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \ - ((CODE) == '.' || (CODE) == '#' || (CODE) == '-' \ - || (CODE) == '+' || (CODE) == '@' || (CODE) == '!' \ - || (CODE) == '$' || (CODE) == '&' || (CODE) == '/') - -/* A C compound statement to output to stdio stream STREAM the - assembler syntax for an instruction operand X. X is an RTL - expression. - - CODE is a value that can be used to specify one of several ways - of printing the operand. It is used when identical operands - must be printed differently depending on the context. CODE - comes from the `%' specification that was used to request - printing of the operand. If the specification was just `%DIGIT' - then CODE is 0; if the specification was `%LTR DIGIT' then CODE - is the ASCII code for LTR. - - If X is a register, this macro should print the register's name. - The names can be found in an array `reg_names' whose type is - `char *[]'. `reg_names' is initialized from `REGISTER_NAMES'. - - When the machine description has a specification `%PUNCT' (a `%' - followed by a punctuation character), this macro is called with - a null pointer for X and the punctuation character for CODE. - - See m68k.c for the m68k specific codes. */ - -#define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE) - -/* A C compound statement to output to stdio stream STREAM the - assembler syntax for an instruction operand that is a memory - reference whose address is ADDR. ADDR is an RTL expression. - - On some machines, the syntax for a symbolic address depends on - the section that the address refers to. On these machines, - define the macro `ENCODE_SECTION_INFO' to store the information - into the `symbol_ref', and then check for it here. */ - -#define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR) - - -/* Define functions defined in aux-output.c and used in templates. */ - -extern char *output_move_double (); -extern char *output_move_const_single (); -extern char *output_move_const_double (); -extern char *output_btst (); - -/* -Local variables: -version-control: t -End: -*/ diff --git a/gnu/usr.bin/gcc2/arch/da30/md b/gnu/usr.bin/gcc2/arch/da30/md deleted file mode 100644 index fb61577c6768..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/md +++ /dev/null @@ -1,5628 +0,0 @@ -;;- Machine description for GNU compiler -;;- Motorola 68000 Version -;; Copyright (C) 1987, 1988, 1993 Free Software Foundation, Inc. - -;; This file is part of GNU CC. - -;; GNU CC 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. - -;; GNU CC 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 CC; see the file COPYING. If not, write to -;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -;; $Id: md,v 1.1 1993/11/23 06:09:26 paulus Exp $ - - -;;- instruction definitions - -;;- @@The original PO technology requires these to be ordered by speed, -;;- @@ so that assigner will pick the fastest. - -;;- See file "rtl.def" for documentation on define_insn, match_*, et. al. - -;;- When naming insn's (operand 0 of define_insn) be careful about using -;;- names from other targets machine descriptions. - -;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code -;;- updates for most instructions. - -;;- Operand classes for the register allocator: -;;- 'a' one of the address registers can be used. -;;- 'd' one of the data registers can be used. -;;- 'f' one of the m68881 registers can be used -;;- 'r' either a data or an address register can be used. -;;- 'x' if one of the Sun FPA registers -;;- 'y' if one of the Low Sun FPA registers (fpa0-fpa15). - -;;- Immediate Floating point operator constraints -;;- 'G' a floating point constant that is *NOT* one of the standard -;; 68881 constant values (to force calling output_move_const_double -;; to get it from rom if it is a 68881 constant). -;;- 'H' one of the standard FPA constant values -;; -;; See the functions standard_XXX_constant_p in output-m68k.c for more -;; info. - -;;- Immediate integer operand constraints: -;;- 'I' 1 .. 8 -;;- 'J' -32768 .. 32767 -;;- 'K' all integers EXCEPT -128 .. 127 -;;- 'L' -8 .. -1 - -;;- Assembler specs: -;;- "%." size separator ("." or "") move%.l d0,d1 -;;- "%#" immediate separator ("#" or "") move%.l %#0,d0 -;;- "%-" push operand "sp@-" move%.l d0,%- -;;- "%+" pop operand "sp@+" move%.l d0,%+ -;;- "%@" top of stack "sp@" move%.l d0,%@ -;;- "%!" fpcr register -;;- "%$" single-precision fp specifier ("s" or "") f%$add.x fp0,fp1 -;;- "%&" double-precision fp specifier ("d" or "") f%&add.x fp0,fp1 - -;;- Information about 68040 port. - -;;- The 68040 executes all 68030 and 68881/2 instructions, but some must -;;- be emulated in software by the OS. It is faster to avoid these -;;- instructions and issue a library call rather than trapping into -;;- the kernel. The affected instructions are fintrz and fscale. The -;;- TARGET_68040 flag turns the use of the opcodes off. - -;;- The '040 also implements a set of new floating-point instructions -;;- which specify the rounding precision in the opcode. This finally -;;- permit the 68k series to be truly IEEE compliant, and solves all -;;- issues of excess precision accumulating in the extended registers. -;;- By default, GCC does not use these instructions, since such code will -;;- not run on an '030. To use these instructions, use the -m68040-only -;;- switch. By changing TARGET_DEFAULT to include TARGET_68040_ONLY, -;;- you can make these instructions the default. - -;;- These new instructions aren't directly in the md. They are brought -;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather -;;- than "". - - -;;- FPA port explanation: - -;;- Usage of the Sun FPA and the 68881 together - -;;- The current port of gcc to the sun fpa disallows use of the m68881 -;;- instructions completely if code is targeted for the fpa. This is -;;- for the following reasons: - -;;- 1) Expressing the preference hierarchy (ie. use the fpa if you -;;- can, the 68881 otherwise, and data registers only if you are -;;- forced to it) is a bitch with the current constraint scheme, -;;- especially since it would have to work for any combination of -;;- -mfpa, -m68881. - -;;- 2) There are no instructions to move between the two types of -;;- registers; the stack must be used as an intermediary. - -;;- It could indeed be done; I think the best way would be to have -;;- separate patterns for TARGET_FPA (which implies a 68881), -;;- TARGET_68881, and no floating point co-processor. Use -;;- define_expands for all of the named instruction patterns, and -;;- include code in the FPA instruction to deal with the 68881 with -;;- preferences specifically set to favor the fpa. Some of this has -;;- already been done: -;;- -;;- 1) Separation of most of the patterns out into a TARGET_FPA -;;- case and a TARGET_68881 case (the exceptions are the patterns -;;- which would need one define_expand and three define_insn's under -;;- it (with a lot of duplicate code between them) to replace the -;;- current single define_insn. These are mov{[ds]f,[ds]i} and the -;;- first two patterns in the md. -;;- -;;- Some would still have to be done: -;;- -;;- 1) Add code to the fpa patterns which correspond to 68881 -;;- patterns to deal with the 68881 case (including preferences!). -;;- What you might actually do here is combine the fpa and 68881 code -;;- back together into one pattern for those instructions where it's -;;- absolutely necessary and save yourself some duplicate code. I'm -;;- not completely sure as to whether you could get away with doing -;;- this only for the mov* insns, or if you'd have to do it for all -;;- named insns. -;;- 2) Add code to the mov{[ds]f,[ds]i} instructions to handle -;;- moving between fpa regs and 68881 regs. - -;;- Since the fpa is more powerful than the 68881 and also has more -;;- registers, and since I think the resultant md would be medium ugly -;;- (lot's of duplicate code, ugly constraint strings), I elected not -;;- to do this change. - -;;- Another reason why someone *might* want to do the change is to -;;- control which register classes are accessed in a slightly cleaner -;;- way than I have. See the blurb on CONDITIONAL_REGISTER_USAGE in -;;- the internals manual. - -;;- Yet another reason why someone might want to do this change is to -;;- allow use of some of the 68881 insns which have no equivalent on -;;- the fpa. The sqrt instruction comes fairly quickly to mind. - -;;- If this is ever done, don't forget to change sun3.h so that -;;- it *will* define __HAVE_68881__ when the FPA is in use. - -;;- Condition code hack - -;;- When a floating point compare is done in the fpa, the resulting -;;- condition codes are left in the fpastatus register. The values in -;;- this register must be moved into the 68000 cc register before any -;;- jump is executed. Once this has been done, regular jump -;;- instructions are fine (ie. floating point jumps are not necessary. -;;- They are only done if the cc is in the 68881). - -;;- The instructions that move the fpastatus register to the 68000 -;;- register clobber a data register (the move cannot be done direct). -;;- These instructions might be bundled either with the compare -;;- instruction, or the branch instruction. If we were using both the -;;- fpa and the 68881 together, we would wish to only mark the -;;- register clobbered if we were doing the compare in the fpa, but I -;;- think that that decision (whether to clobber the register or not) -;;- must be done before register allocation (makes sense) and hence we -;;- can't know if the floating point compare will be done in the fpa -;;- or the fp. So whenever we are asked for code that uses the fpa, -;;- we will mark a data register as clobbered. This is reasonable, as -;;- almost all floating point compare operations done with fpa code -;;- enabled will be done in the fpa. It's even more reasonable since -;;- we decided to make the 68881 and the fpa mutually exclusive. - -;;- We place to code to move the fpastatus register inside of a -;;- define_expand so that we can do it conditionally based on whether -;;- we are targeting an fpa or not. - -;;- This still leaves us with the question of where we wish to put the -;;- code to move the fpastatus reg. If we put it in the compare -;;- instruction, we can restrict the clobbering of the register to -;;- floating point compares, but we can't take advantage of floating -;;- point subtracts & etc. that alter the fpastatus register. If we -;;- put it in the branch instruction, all branches compiled with fpa -;;- code enabled will clobber a data register, but we will be able to -;;- take advantage of fpa subtracts. This balance favors putting the -;;- code in with the compare instruction. - -;;- Note that if some enterprising hacker should decide to switch -;;- this, he'll need to modify the code in NOTICE_UPDATE_CC. - -;;- Usage of the top 16 fpa registers - -;;- The only locations which we may transfer fpa registers 16-31 from -;;- or to are the fpa registers 0-15. (68000 registers and memory -;;- locations are impossible). This causes problems in gcc, which -;;- assumes that mov?? instructions require no additional registers -;;- (see section 11.7) and since floating point moves *must* be -;;- supported into general registers (see section 12.3 under -;;- HARD_REGNO_OK_FOR_MODE_P) from anywhere. - -;;- My solution was to reserve fpa0 for moves into or out of these top -;;- 16 registers and to disparage the choice to reload into or out of -;;- these registers as much as I could. That alternative is always -;;- last in the list, so it will not be used unless all else fails. I -;;- will note that according to my current information, sun's compiler -;;- doesn't use these top 16 registers at all. - -;;- There is another possible way to do it. I *believe* that if you -;;- make absolutely sure that the code will not be executed in the -;;- reload pass, you can support the mov?? names with define_expands -;;- which require new registers. This may be possible by the -;;- appropriate juggling of constraints. I may come back to this later. - -;;- Usage of constant RAM - -;;- This has been handled correctly (I believe) but the way I've done -;;- it could use a little explanation. The constant RAM can only be -;;- accessed when the instruction is in "command register" mode. -;;- "command register" mode means that no accessing of memory or the -;;- 68000 registers is being done. This can be expressed easily in -;;- constraints, so generally the mode of the instruction is -;;- determined by a branch off of which_alternative. In outputting -;;- instructions, a 'w' means to output an access to the constant ram -;;- (if the arg is CONST_DOUBLE and is one of the available -;;- constants), and 'x' means to output a register pair (if the arg is -;;- a 68000 register) and a 'y' is the combination of the above two -;;- processes. You use a 'y' in two operand DF instructions where you -;;- *know* the other operand is an fpa register, you use an 'x' in DF -;;- instructions where the arg might be a 68000 register and the -;;- instruction is *not* in "command register" mode, and you use a 'w' -;;- in two situations: 1) The instruction *is* in command register -;;- mode (and hence won't be accessing 68000 registers), or 2) The -;;- instruction is a two operand SF instruction where you know the -;;- other operand is an fpa register. - -;;- Optimization issues - -;;- I actually think that I've included all of the fpa instructions -;;- that should be included. Note that if someone is interested in -;;- doing serious floating point work on the sun fpa, I would advise -;;- the use of the "asm" instruction in gcc to allow you to use the -;;- sin, cos, and exponential functions on the fpa board. - -;;- END FPA Explanation Section. - - -;;- Some of these insn's are composites of several m68000 op codes. -;;- The assembler (or final @@??) insures that the appropriate one is -;;- selected. - -(define_insn "" - [(set (match_operand:DF 0 "push_operand" "=m") - (match_operand:DF 1 "general_operand" "ro<>fyE"))] - "" - "* -{ - if (FP_REG_P (operands[1])) - return \"fmove%.d %f1,%0\"; - if (FPA_REG_P (operands[1])) - return \"fpmove%.d %1, %x0\"; - return output_move_double (operands); -}") - -(define_insn "" - [(set (match_operand:DI 0 "push_operand" "=m") - (match_operand:DI 1 "general_operand" "ro<>Fy"))] - "" - "* -{ - return output_move_double (operands); -}") - -;; We don't want to allow a constant operand for test insns because -;; (set (cc0) (const_int foo)) has no mode information. Such insns will -;; be folded while optimizing anyway. -(define_insn "tstsi" - [(set (cc0) - (match_operand:SI 0 "nonimmediate_operand" "rm"))] - "" - "* -{ -#ifdef ISI_OV - /* ISI's assembler fails to handle tstl a0. */ - if (! ADDRESS_REG_P (operands[0])) -#else - if (TARGET_68020 || ! ADDRESS_REG_P (operands[0])) -#endif - return \"tst%.l %0\"; - /* If you think that the 68020 does not support tstl a0, - reread page B-167 of the 68020 manual more carefully. */ - /* On an address reg, cmpw may replace cmpl. */ -#ifdef SGS_CMP_ORDER - return \"cmp%.w %0,%#0\"; -#else - return \"cmp%.w %#0,%0\"; -#endif -}") - -;; This can't use an address register, because comparisons -;; with address registers as second operand always test the whole word. -(define_insn "tsthi" - [(set (cc0) - (match_operand:HI 0 "nonimmediate_operand" "dm"))] - "" - "tst%.w %0") - -(define_insn "tstqi" - [(set (cc0) - (match_operand:QI 0 "nonimmediate_operand" "dm"))] - "" - "tst%.b %0") - -(define_expand "tstsf" - [(set (cc0) - (match_operand:SF 0 "general_operand" ""))] - "TARGET_68881 || TARGET_FPA" - " -{ - if (TARGET_FPA) - { - emit_insn (gen_tstsf_fpa (operands[0])); - DONE; - } -}") - -(define_insn "tstsf_fpa" - [(set (cc0) - (match_operand:SF 0 "general_operand" "xmdF")) - (clobber (match_scratch:SI 1 "=d"))] - "TARGET_FPA" - "fptst%.s %x0\;fpmove fpastatus,%1\;movw %1,cc") - -(define_insn "" - [(set (cc0) - (match_operand:SF 0 "general_operand" "fdm"))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; - if (FP_REG_P (operands[0])) - return \"ftst%.x %0\"; - return \"ftst%.s %0\"; -}") - -(define_expand "tstdf" - [(set (cc0) - (match_operand:DF 0 "general_operand" ""))] - "TARGET_68881 || TARGET_FPA" - " -{ - if (TARGET_FPA) - { - emit_insn (gen_tstsf_fpa (operands[0])); - DONE; - } -}") - -(define_insn "tstdf_fpa" - [(set (cc0) - (match_operand:DF 0 "general_operand" "xrmF")) - (clobber (match_scratch:SI 1 "=d"))] - "TARGET_FPA" - "fptst%.d %x0\;fpmove fpastatus,%1\;movw %1,cc") - -(define_insn "" - [(set (cc0) - (match_operand:DF 0 "general_operand" "fm"))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; - if (FP_REG_P (operands[0])) - return \"ftst%.x %0\"; - return \"ftst%.d %0\"; -}") - -;; compare instructions. - -;; A composite of the cmp, cmpa, & cmpi m68000 op codes. -(define_insn "cmpsi" - [(set (cc0) - (compare (match_operand:SI 0 "nonimmediate_operand" "rKs,mr,>") - (match_operand:SI 1 "general_operand" "mr,Ksr,>")))] - "" - "* -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return \"cmpm%.l %1,%0\"; - if (REG_P (operands[1]) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return \"cmp%.l %d1,%d0\"; -#else - return \"cmp%.l %d0,%d1\"; -#endif - } -#ifdef SGS_CMP_ORDER - return \"cmp%.l %d0,%d1\"; -#else - return \"cmp%.l %d1,%d0\"; -#endif -}") - -(define_insn "cmphi" - [(set (cc0) - (compare (match_operand:HI 0 "nonimmediate_operand" "rnm,d,n,m") - (match_operand:HI 1 "general_operand" "d,rnm,m,n")))] - "" - "* -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return \"cmpm%.w %1,%0\"; - if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1])) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return \"cmp%.w %d1,%d0\"; -#else - return \"cmp%.w %d0,%d1\"; -#endif - } -#ifdef SGS_CMP_ORDER - return \"cmp%.w %d0,%d1\"; -#else - return \"cmp%.w %d1,%d0\"; -#endif -}") - -(define_insn "cmpqi" - [(set (cc0) - (compare (match_operand:QI 0 "nonimmediate_operand" "dn,md,>") - (match_operand:QI 1 "general_operand" "dm,nd,>")))] - "" - "* -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return \"cmpm%.b %1,%0\"; - if (REG_P (operands[1]) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return \"cmp%.b %d1,%d0\"; -#else - return \"cmp%.b %d0,%d1\"; -#endif - } -#ifdef SGS_CMP_ORDER - return \"cmp%.b %d0,%d1\"; -#else - return \"cmp%.b %d1,%d0\"; -#endif -}") - -(define_expand "cmpdf" - [(set (cc0) - (compare (match_operand:DF 0 "general_operand" "") - (match_operand:DF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - " -{ - if (TARGET_FPA) - { - emit_insn (gen_cmpdf_fpa (operands[0], operands[1])); - DONE; - } -}") - -(define_insn "cmpdf_fpa" - [(set (cc0) - (compare (match_operand:DF 0 "general_operand" "x,y") - (match_operand:DF 1 "general_operand" "xH,rmF"))) - (clobber (match_scratch:SI 2 "=d,d"))] - "TARGET_FPA" - "fpcmp%.d %y1,%0\;fpmove fpastatus,%2\;movw %2,cc") - -(define_insn "" - [(set (cc0) - (compare (match_operand:DF 0 "general_operand" "f,mG") - (match_operand:DF 1 "general_operand" "fmG,f")))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return \"fcmp%.x %0,%1\"; - else - return \"fcmp%.d %0,%f1\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.d %1,%f0\"; -#else - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return \"fcmp%.x %1,%0\"; - else - return \"fcmp%.d %f1,%0\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.d %f0,%1\"; -#endif -}") - -(define_expand "cmpsf" - [(set (cc0) - (compare (match_operand:SF 0 "general_operand" "") - (match_operand:SF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - " -{ - if (TARGET_FPA) - { - emit_insn (gen_cmpsf_fpa (operands[0], operands[1])); - DONE; - } -}") - -(define_insn "cmpsf_fpa" - [(set (cc0) - (compare (match_operand:SF 0 "general_operand" "x,y") - (match_operand:SF 1 "general_operand" "xH,rmF"))) - (clobber (match_scratch:SI 2 "=d,d"))] - "TARGET_FPA" - "fpcmp%.s %w1,%x0\;fpmove fpastatus,%2\;movw %2,cc") - -(define_insn "" - [(set (cc0) - (compare (match_operand:SF 0 "general_operand" "f,mdG") - (match_operand:SF 1 "general_operand" "fmdG,f")))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"fcmp%.x %0,%1\"; - else - return \"fcmp%.s %0,%f1\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.s %1,%f0\"; -#else - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"fcmp%.x %1,%0\"; - else - return \"fcmp%.s %f1,%0\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.s %f0,%1\"; -#endif -}") - -;; Recognizers for btst instructions. - -(define_insn "" - [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "do") - (const_int 1) - (minus:SI (const_int 7) - (match_operand:SI 1 "general_operand" "di"))))] - "" - "* { return output_btst (operands, operands[1], operands[0], insn, 7); }") - -(define_insn "" - [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "d") - (const_int 1) - (minus:SI (const_int 31) - (match_operand:SI 1 "general_operand" "di"))))] - "" - "* { return output_btst (operands, operands[1], operands[0], insn, 31); }") - -;; The following two patterns are like the previous two -;; except that they use the fact that bit-number operands -;; are automatically masked to 3 or 5 bits. - -(define_insn "" - [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "do") - (const_int 1) - (minus:SI (const_int 7) - (and:SI - (match_operand:SI 1 "general_operand" "d") - (const_int 7)))))] - "" - "* { return output_btst (operands, operands[1], operands[0], insn, 7); }") - -(define_insn "" - [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "d") - (const_int 1) - (minus:SI (const_int 31) - (and:SI - (match_operand:SI 1 "general_operand" "d") - (const_int 31)))))] - "" - "* { return output_btst (operands, operands[1], operands[0], insn, 31); }") - -;; Nonoffsettable mem refs are ok in this one pattern -;; since we don't try to adjust them. -(define_insn "" - [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "md") - (const_int 1) - (match_operand:SI 1 "general_operand" "i")))] - "GET_CODE (operands[1]) == CONST_INT - && (unsigned) INTVAL (operands[1]) < 8" - "* -{ - operands[1] = gen_rtx (CONST_INT, VOIDmode, 7 - INTVAL (operands[1])); - return output_btst (operands, operands[1], operands[0], insn, 7); -}") - -(define_insn "" - [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "do") - (const_int 1) - (match_operand:SI 1 "general_operand" "i")))] - "GET_CODE (operands[1]) == CONST_INT" - "* -{ - if (GET_CODE (operands[0]) == MEM) - { - operands[0] = adj_offsettable_operand (operands[0], - INTVAL (operands[1]) / 8); - operands[1] = gen_rtx (CONST_INT, VOIDmode, - 7 - INTVAL (operands[1]) % 8); - return output_btst (operands, operands[1], operands[0], insn, 7); - } - operands[1] = gen_rtx (CONST_INT, VOIDmode, - 31 - INTVAL (operands[1])); - return output_btst (operands, operands[1], operands[0], insn, 31); -}") - - -;; move instructions - -;; A special case in which it is not desirable -;; to reload the constant into a data register. -(define_insn "" - [(set (match_operand:SI 0 "push_operand" "=m") - (match_operand:SI 1 "general_operand" "J"))] - "GET_CODE (operands[1]) == CONST_INT - && INTVAL (operands[1]) >= -0x8000 - && INTVAL (operands[1]) < 0x8000" - "* -{ - if (operands[1] == const0_rtx) - return \"clr%.l %0\"; - return \"pea %a1\"; -}") - -;This is never used. -;(define_insn "swapsi" -; [(set (match_operand:SI 0 "general_operand" "+r") -; (match_operand:SI 1 "general_operand" "+r")) -; (set (match_dup 1) (match_dup 0))] -; "" -; "exg %1,%0") - -;; Special case of fullword move when source is zero. -;; The reason this is special is to avoid loading a zero -;; into a data reg with moveq in order to store it elsewhere. - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=g") - (const_int 0))] - ;; clr insns on 68000 read before writing. - ;; This isn't so on the 68010, but we have no alternative for it. - "(TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))" - "* -{ - if (ADDRESS_REG_P (operands[0])) - return \"sub%.l %0,%0\"; - /* moveq is faster on the 68000. */ - if (DATA_REG_P (operands[0]) && !TARGET_68020) -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %#0,%0\"; -#else - return \"moveq %#0,%0\"; -#endif - return \"clr%.l %0\"; -}") - -;; General case of fullword move. -;; -;; This is the main "hook" for PIC code. When generating -;; PIC, movsi is responsible for determining when the source address -;; needs PIC relocation and appropriately calling legitimize_pic_address -;; to perform the actual relocation. -;; -;; In both the PIC and non-PIC cases the patterns generated will -;; matched by the next define_insn. -(define_expand "movsi" - [(set (match_operand:SI 0 "general_operand" "") - (match_operand:SI 1 "general_operand" ""))] - "" - " -{ - if (flag_pic && symbolic_operand (operands[1], SImode)) - { - /* The source is an address which requires PIC relocation. - Call legitimize_pic_address with the source, mode, and a relocation - register (a new pseudo, or the final destination if reload_in_progress - is set). Then fall through normally */ - extern rtx legitimize_pic_address(); - rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode); - operands[1] = legitimize_pic_address (operands[1], SImode, temp); - } -}") - -;; General case of fullword move. The register constraints -;; force integer constants in range for a moveq to be reloaded -;; if they are headed for memory. -(define_insn "" - ;; Notes: make sure no alternative allows g vs g. - ;; We don't allow f-regs since fixed point cannot go in them. - ;; We do allow y and x regs since fixed point is allowed in them. - [(set (match_operand:SI 0 "general_operand" "=g,da,y,!*x*r*m") - (match_operand:SI 1 "general_operand" "daymKs,i,g,*x*r*m"))] - "" - "* -{ - if (which_alternative == 3) - return \"fpmove%.l %x1,fpa0\;fpmove%.l fpa0,%x0\"; - if (FPA_REG_P (operands[1]) || FPA_REG_P (operands[0])) - return \"fpmove%.l %x1,%x0\"; - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return \"clr%.l %0\"; - else if (DATA_REG_P (operands[0]) - && INTVAL (operands[1]) < 128 - && INTVAL (operands[1]) >= -128) - { -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %1,%0\"; -#else - return \"moveq %1,%0\"; -#endif - } -#ifndef NO_ADDSUB_Q - else if (DATA_REG_P (operands[0]) - /* Do this with a moveq #N-8, dreg; addq #8,dreg */ - && INTVAL (operands[1]) < 136 - && INTVAL (operands[1]) >= 128) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %1,%0\;addq%.w %#8,%0\"; -#else - return \"moveq %1,%0\;addq%.w %#8,%0\"; -#endif - } - else if (DATA_REG_P (operands[0]) - /* Do this with a moveq #N+8, dreg; subq #8,dreg */ - && INTVAL (operands[1]) < -128 - && INTVAL (operands[1]) >= -136) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) + 8); -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %1,%0;subq%.w %#8,%0\"; -#else - return \"moveq %1,%0;subq%.w %#8,%0\"; -#endif - } -#endif - else if (DATA_REG_P (operands[0]) - /* If N is in the right range and is even, then use - moveq #N/2, dreg; addl dreg,dreg */ - && INTVAL (operands[1]) > 127 - && INTVAL (operands[1]) <= 254 - && INTVAL (operands[1]) % 2 == 0) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) / 2); -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %1,%0\;add%.w %0,%0\"; -#else - return \"moveq %1,%0\;add%.w %0,%0\"; -#endif - } - else if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return \"move%.w %1,%0\"; - else if (push_operand (operands[0], SImode) - && INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return \"pea %a1\"; - } - else if ((GET_CODE (operands[1]) == SYMBOL_REF - || GET_CODE (operands[1]) == CONST) - && push_operand (operands[0], SImode)) - return \"pea %a1\"; - else if ((GET_CODE (operands[1]) == SYMBOL_REF - || GET_CODE (operands[1]) == CONST) - && ADDRESS_REG_P (operands[0])) - return \"lea %a1,%0\"; - return \"move%.l %1,%0\"; -}") - -(define_insn "movhi" - [(set (match_operand:HI 0 "general_operand" "=g") - (match_operand:HI 1 "general_operand" "g"))] - "" - "* -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return \"clr%.w %0\"; - else if (DATA_REG_P (operands[0]) - && INTVAL (operands[1]) < 128 - && INTVAL (operands[1]) >= -128) - { -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %1,%0\"; -#else - return \"moveq %1,%0\"; -#endif - } - else if (INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return \"move%.w %1,%0\"; - } - else if (CONSTANT_P (operands[1])) - return \"move%.l %1,%0\"; -#ifndef SGS_NO_LI - /* Recognize the insn before a tablejump, one that refers - to a table of offsets. Such an insn will need to refer - to a label on the insn. So output one. Use the label-number - of the table of offsets to generate this label. */ - if (GET_CODE (operands[1]) == MEM - && GET_CODE (XEXP (operands[1], 0)) == PLUS - && (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF - || GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == LABEL_REF) - && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) != PLUS - && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) != PLUS) - { - rtx labelref; - if (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF) - labelref = XEXP (XEXP (operands[1], 0), 0); - else - labelref = XEXP (XEXP (operands[1], 0), 1); -#if defined (MOTOROLA) && !defined (SGS_SWITCH_TABLES) -#ifdef SGS - asm_fprintf (asm_out_file, \"\\tset %LLI%d,.+2\\n\", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#else /* not SGS */ - asm_fprintf (asm_out_file, \"\\t.set %LLI%d,.+2\\n\", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#endif /* not SGS */ -#else /* SGS_SWITCH_TABLES or not MOTOROLA */ - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"LI\", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#ifdef SGS_SWITCH_TABLES - /* Set flag saying we need to define the symbol - LD%n (with value L%n-LI%n) at the end of the switch table. */ - switch_table_difference_label_flag = 1; -#endif /* SGS_SWITCH_TABLES */ -#endif /* SGS_SWITCH_TABLES or not MOTOROLA */ - } -#endif /* SGS_NO_LI */ - return \"move%.w %1,%0\"; -}") - -(define_insn "movstricthi" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm")) - (match_operand:HI 1 "general_operand" "rmn"))] - "" - "* -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return \"clr%.w %0\"; - } - return \"move%.w %1,%0\"; -}") - -(define_insn "movqi" - [(set (match_operand:QI 0 "general_operand" "=d,*a,m,m,?*a") - (match_operand:QI 1 "general_operand" "dmi*a,d*a,dmi,?*a,m"))] - "" - "* -{ - rtx xoperands[4]; - - /* This is probably useless, since it loses for pushing a struct - of several bytes a byte at a time. */ - if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC - && XEXP (XEXP (operands[0], 0), 0) == stack_pointer_rtx) - { - xoperands[1] = operands[1]; - xoperands[2] - = gen_rtx (MEM, QImode, - gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, const1_rtx)); - /* Just pushing a byte puts it in the high byte of the halfword. */ - /* We must put it in the low-order, high-numbered byte. */ - output_asm_insn (\"move%.b %1,%-\;move%.b %@,%2\", xoperands); - return \"\"; - } - - /* Moving a byte into an address register is not possible. */ - /* Use d0 as an intermediate, but don't clobber its contents. */ - if (ADDRESS_REG_P (operands[0]) && GET_CODE (operands[1]) == MEM) - { - /* ??? For 2.5, don't allow this choice and use secondary reloads - instead. - - See if the address register is used in the address. If it - is, we have to generate a more complex sequence than those below. */ - if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1, - operands[1], NULL_RTX)) - { - /* See if the stack pointer is used in the address. If it isn't, - we can push d0 or d1 (the insn can't use both of them) on - the stack, perform our move into d0/d1, copy the byte from d0/1, - and pop d0/1. */ - if (! reg_mentioned_p (stack_pointer_rtx, operands[1])) - { - if (refers_to_regno_p (0, 1, operands[1], NULL_RTX)) - return \"move%.l %/d0,%-\;move%.b %1,%/d0\;move%.l %/d0,%0\;move%.l %+,%/d0\"; - else - return \"move%.l %/d1,%-\;move%.b %1,%/d1\;move%.l %/d1,%0\;move%.l %+,%/d1\"; - } - else - { - /* Otherwise, we know that d0 cannot be used in the address - (since sp and one address register is). Assume that sp is - being used as a base register and replace the address - register that is our operand[0] with d0. */ - rtx reg_map[FIRST_PSEUDO_REGISTER]; - int i; - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - reg_map[i] = 0; - - reg_map[REGNO (operands[0])] = gen_rtx (REG, Pmode, 0); - operands[1] = copy_rtx (operands[1]); - replace_regs (operands[1], reg_map, FIRST_PSEUDO_REGISTER, 0); - return \"exg %/d0,%0\;move%.b %1,%/d0\;exg %/d0,%0\"; - } - } - - /* If the address of operand 1 uses d0, choose d1 as intermediate. */ - if (refers_to_regno_p (0, 1, operands[1], NULL_RTX)) - return \"exg %/d1,%0\;move%.b %1,%/d1\;exg %/d1,%0\"; - /* Otherwise d0 is usable. - (An effective address on the 68k can't use two d-regs.) */ - else - return \"exg %/d0,%0\;move%.b %1,%/d0\;exg %/d0,%0\"; - } - - /* Likewise for moving from an address reg. */ - if (ADDRESS_REG_P (operands[1]) && GET_CODE (operands[0]) == MEM) - { - /* ??? For 2.5, don't allow this choice and use secondary reloads - instead. - - See if the address register is used in the address. If it - is, we have to generate a more complex sequence than those below. */ - if (refers_to_regno_p (REGNO (operands[1]), REGNO (operands[1]) + 1, - operands[0], NULL_RTX)) - { - /* See if the stack pointer is used in the address. If it isn't, - we can push d0 or d1 (the insn can't use both of them) on - the stack, copy the byte to d0/1, perform our move from d0/d1, - and pop d0/1. */ - if (! reg_mentioned_p (stack_pointer_rtx, operands[0])) - { - if (refers_to_regno_p (0, 1, operands[0], NULL_RTX)) - return \"move%.l %/d0,%-\;move%.l %1,%/d0\;move%.b %/d0,%0\;move%.l %+,%/d0\"; - else - return \"move%.l %/d1,%-\;move%.l %1,%/d1\;move%.b %/d1,%0\;move%.l %+,%/d1\"; - } - else - { - /* Otherwise, we know that d0 cannot be used in the address - (since sp and one address register is). Assume that sp is - being used as a base register and replace the address - register that is our operand[1] with d0. */ - rtx reg_map[FIRST_PSEUDO_REGISTER]; - int i; - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - reg_map[i] = 0; - - reg_map[REGNO (operands[1])] = gen_rtx (REG, Pmode, 0); - operands[0] = copy_rtx (operands[0]); - replace_regs (operands[0], reg_map, FIRST_PSEUDO_REGISTER, 0); - return \"exg %/d0,%1\;move%.b %/d0,%0\;exg %/d0,%1\"; - } - } - - if (refers_to_regno_p (0, 1, operands[0], NULL_RTX)) - return \"exg %/d1,%1\;move%.b %/d1,%0\;exg %/d1,%1\"; - else - return \"exg %/d0,%1\;move%.b %/d0,%0\;exg %/d0,%1\"; - } - - /* clr and st insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - if (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - if (operands[1] == const0_rtx) - return \"clr%.b %0\"; - if (GET_CODE (operands[1]) == CONST_INT - && INTVAL (operands[1]) == -1) - { - CC_STATUS_INIT; - return \"st %0\"; - } - } - if (GET_CODE (operands[1]) != CONST_INT && CONSTANT_P (operands[1])) - return \"move%.l %1,%0\"; - if (ADDRESS_REG_P (operands[0]) || ADDRESS_REG_P (operands[1])) - return \"move%.w %1,%0\"; - return \"move%.b %1,%0\"; -}") - -(define_insn "movstrictqi" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm")) - (match_operand:QI 1 "general_operand" "dmn"))] - "" - "* -{ - if (operands[1] == const0_rtx - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))) - return \"clr%.b %0\"; - return \"move%.b %1,%0\"; -}") - -(define_insn "movsf" - [(set (match_operand:SF 0 "general_operand" "=rmf,x,y,rm,!x,!rm") - (match_operand:SF 1 "general_operand" "rmfF,xH,rmF,y,rm,x"))] -; [(set (match_operand:SF 0 "general_operand" "=rmf") -; (match_operand:SF 1 "general_operand" "rmfF"))] - "" - "* -{ - if (which_alternative >= 4) - return \"fpmove%.s %1,fpa0\;fpmove%.s fpa0,%0\"; - if (FPA_REG_P (operands[0])) - { - if (FPA_REG_P (operands[1])) - return \"fpmove%.s %x1,%x0\"; - else if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_single (operands); - else if (FP_REG_P (operands[1])) - return \"fmove%.s %1,sp@-\;fpmove%.d sp@+, %0\"; - return \"fpmove%.s %x1,%x0\"; - } - if (FPA_REG_P (operands[1])) - { - if (FP_REG_P (operands[0])) - return \"fpmove%.s %x1,sp@-\;fmove%.s sp@+,%0\"; - else - return \"fpmove%.s %x1,%x0\"; - } - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"f%$move%.x %1,%0\"; - else if (ADDRESS_REG_P (operands[1])) - return \"move%.l %1,%-\;f%$move%.s %+,%0\"; - else if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_single (operands); - return \"f%$move%.s %f1,%0\"; - } - if (FP_REG_P (operands[1])) - { - if (ADDRESS_REG_P (operands[0])) - return \"fmove%.s %1,%-\;move%.l %+,%0\"; - return \"fmove%.s %f1,%0\"; - } - return \"move%.l %1,%0\"; -}") - -(define_insn "movdf" - [(set (match_operand:DF 0 "general_operand" "=rm,&rf,&rof<>,y,rm,x,!x,!rm") - (match_operand:DF 1 "general_operand" "rf,m,rofE<>,rmE,y,xH,rm,x"))] -; [(set (match_operand:DF 0 "general_operand" "=rm,&rf,&rof<>") -; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))] - "" - "* -{ - if (which_alternative == 6) - return \"fpmove%.d %x1,fpa0\;fpmove%.d fpa0,%x0\"; - if (FPA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - if (FP_REG_P (operands[1])) - return \"fmove%.d %1,sp@-\;fpmove%.d sp@+,%x0\"; - return \"fpmove%.d %x1,%x0\"; - } - else if (FPA_REG_P (operands[1])) - { - if (FP_REG_P(operands[0])) - return \"fpmove%.d %x1,sp@-\;fmoved sp@+,%0\"; - else - return \"fpmove%.d %x1,%x0\"; - } - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"f%&move%.x %1,%0\"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn (\"move%.l %1,%-\", xoperands); - output_asm_insn (\"move%.l %1,%-\", operands); - return \"f%&move%.d %+,%0\"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - return \"f%&move%.d %f1,%0\"; - } - else if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - else - return \"fmove%.d %f1,%0\"; - } - return output_move_double (operands); -} -") - -(define_expand "movxf" - [(set (match_operand:XF 0 "nonimmediate_operand" "") - (match_operand:XF 1 "general_operand" ""))] - "" - " -{ - if (CONSTANT_P (operands[1])) - { - operands[1] = force_const_mem (XFmode, operands[1]); - if (! memory_address_p (XFmode, XEXP (operands[1], 0)) - && ! reload_in_progress) - operands[1] = change_address (operands[1], XFmode, - XEXP (operands[1], 0)); - } -}") - -(define_insn "" - [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f") - (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r"))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"fmove%.x %1,%0\"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2); - output_asm_insn (\"move%.l %1,%-\", xoperands); - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn (\"move%.l %1,%-\", xoperands); - output_asm_insn (\"move%.l %1,%-\", operands); - return \"fmove%.x %+,%0\"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return \"fmove%.x %1,%0\"; - return \"fmove%.x %f1,%0\"; - } - if (REG_P (operands[0])) - { - output_asm_insn (\"fmove%.x %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - output_asm_insn (\"move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - return \"fmove%.x %f1,%0\"; -} -") - -(define_insn "" - [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,&rf,&rof<>") - (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))] - "! TARGET_68881" - "* -{ - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"fmove%.x %1,%0\"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2); - output_asm_insn (\"move%.l %1,%-\", xoperands); - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn (\"move%.l %1,%-\", xoperands); - output_asm_insn (\"move%.l %1,%-\", operands); - return \"fmove%.x %+,%0\"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return \"fmove%.x %1,%0\"; - return \"fmove%.x %f1,%0\"; - } - if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn (\"fmove%.x %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - output_asm_insn (\"move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - else - return \"fmove%.x %f1,%0\"; - } - return output_move_double (operands); -} -") - -;; movdi can apply to fp regs in some cases -(define_insn "movdi" - ;; Let's see if it really still needs to handle fp regs, and, if so, why. - [(set (match_operand:DI 0 "general_operand" "=rm,&r,&ro<>,y,rm,!*x,!rm") - (match_operand:DI 1 "general_operand" "rF,m,roi<>F,rmiF,y,rmF,*x"))] -; [(set (match_operand:DI 0 "general_operand" "=rm,&r,&ro<>,!&rm,!&f,y,rm,x,!x,!rm") -; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfmF,rmi,y,rm,x"))] -; [(set (match_operand:DI 0 "general_operand" "=rm,&rf,&ro<>,!&rm,!&f") -; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))] - "" - "* -{ - if (which_alternative == 8) - return \"fpmove%.d %x1,fpa0\;fpmove%.d fpa0,%x0\"; - if (FPA_REG_P (operands[0]) || FPA_REG_P (operands[1])) - return \"fpmove%.d %x1,%x0\"; - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"fmove%.x %1,%0\"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn (\"move%.l %1,%-\", xoperands); - output_asm_insn (\"move%.l %1,%-\", operands); - return \"fmove%.d %+,%0\"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - return \"fmove%.d %f1,%0\"; - } - else if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - else - return \"fmove%.d %f1,%0\"; - } - return output_move_double (operands); -} -") - -;; Thus goes after the move instructions -;; because the move instructions are better (require no spilling) -;; when they can apply. It goes before the add/sub insns -;; so we will prefer it to them. - -(define_insn "pushasi" - [(set (match_operand:SI 0 "push_operand" "=m") - (match_operand:SI 1 "address_operand" "p"))] - "" - "pea %a1") - -;; truncation instructions -(define_insn "truncsiqi2" - [(set (match_operand:QI 0 "general_operand" "=dm,d") - (truncate:QI - (match_operand:SI 1 "general_operand" "doJ,i")))] - "" - "* -{ - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return \"move%.l %1,%0\"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 3); - return \"move%.b %1,%0\"; -}") - -(define_insn "trunchiqi2" - [(set (match_operand:QI 0 "general_operand" "=dm,d") - (truncate:QI - (match_operand:HI 1 "general_operand" "doJ,i")))] - "" - "* -{ - if (GET_CODE (operands[0]) == REG - && (GET_CODE (operands[1]) == MEM - || GET_CODE (operands[1]) == CONST_INT)) - { - /* Must clear condition codes, since the move.w bases them on - the entire 16 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return \"move%.w %1,%0\"; - } - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return \"move%.l %1,%0\"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 1); - return \"move%.b %1,%0\"; -}") - -(define_insn "truncsihi2" - [(set (match_operand:HI 0 "general_operand" "=dm,d") - (truncate:HI - (match_operand:SI 1 "general_operand" "roJ,i")))] - "" - "* -{ - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return \"move%.l %1,%0\"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 2); - return \"move%.w %1,%0\"; -}") - -;; zero extension instructions - -(define_expand "zero_extendhisi2" - [(set (match_operand:SI 0 "register_operand" "") - (const_int 0)) - (set (strict_low_part (match_dup 2)) - (match_operand:HI 1 "general_operand" ""))] - "" - " -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, HImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, HImode, operands[0], 0); -}") - -(define_expand "zero_extendqihi2" - [(set (match_operand:HI 0 "register_operand" "") - (const_int 0)) - (set (strict_low_part (match_dup 2)) - (match_operand:QI 1 "general_operand" ""))] - "" - " -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0); -}") - -(define_expand "zero_extendqisi2" - [(set (match_operand:SI 0 "register_operand" "") - (const_int 0)) - (set (strict_low_part (match_dup 2)) - (match_operand:QI 1 "general_operand" ""))] - "" - " -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0); -}") - -;; Patterns to recognize zero-extend insns produced by the combiner. -;; We don't allow both operands in memory, because of aliasing problems. -;; Explicitly disallow two memory operands via the condition since reloading -;; of this case will result in worse code than the uncombined patterns. - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=do<>,d<") - (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))] - "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" - "* -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return \"and%.l %#0xFFFF,%0\"; - if (reg_mentioned_p (operands[0], operands[1])) - return \"move%.w %1,%0\;and%.l %#0xFFFF,%0\"; - return \"clr%.l %0\;move%.w %1,%0\"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - return \"move%.w %1,%0\;clr%.w %0\"; - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - return \"clr%.w %0\;move%.w %1,%0\"; - else - { - output_asm_insn (\"clr%.w %0\", operands); - operands[0] = adj_offsettable_operand (operands[0], 2); - return \"move%.w %1,%0\"; - } -}") - -(define_insn "" - [(set (match_operand:HI 0 "general_operand" "=do<>,d") - (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))] - "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" - "* -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return \"and%.w %#0xFF,%0\"; - if (reg_mentioned_p (operands[0], operands[1])) - return \"move%.b %1,%0\;and%.w %#0xFF,%0\"; - return \"clr%.w %0\;move%.b %1,%0\"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - { - if (REGNO (XEXP (XEXP (operands[0], 0), 0)) - == STACK_POINTER_REGNUM) - { - output_asm_insn (\"clr%.w %-\", operands); - operands[0] = gen_rtx (MEM, GET_MODE (operands[0]), - plus_constant (stack_pointer_rtx, 1)); - return \"move%.b %1,%0\"; - } - else - return \"move%.b %1,%0\;clr%.b %0\"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - return \"clr%.b %0\;move%.b %1,%0\"; - else - { - output_asm_insn (\"clr%.b %0\", operands); - operands[0] = adj_offsettable_operand (operands[0], 1); - return \"move%.b %1,%0\"; - } -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=do<>,d") - (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,m")))] - "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" - "* -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return \"and%.l %#0xFF,%0\"; - if (reg_mentioned_p (operands[0], operands[1])) - return \"move%.b %1,%0\;and%.l %#0xFF,%0\"; - return \"clr%.l %0\;move%.b %1,%0\"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - { - operands[0] = XEXP (XEXP (operands[0], 0), 0); -#ifdef MOTOROLA -#ifdef SGS - return \"clr%.l -(%0)\;move%.b %1,3(%0)\"; -#else - return \"clr%.l -(%0)\;move%.b %1,(3,%0)\"; -#endif -#else - return \"clrl %0@-\;moveb %1,%0@(3)\"; -#endif - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - { - operands[0] = XEXP (XEXP (operands[0], 0), 0); -#ifdef MOTOROLA -#ifdef SGS - return \"clr%.l (%0)+\;move%.b %1,-1(%0)\"; -#else - return \"clr%.l (%0)+\;move%.b %1,(-1,%0)\"; -#endif -#else - return \"clrl %0@+\;moveb %1,%0@(-1)\"; -#endif - } - else - { - output_asm_insn (\"clr%.l %0\", operands); - operands[0] = adj_offsettable_operand (operands[0], 3); - return \"move%.b %1,%0\"; - } -}") - -;; sign extension instructions - -(define_insn "extendhisi2" - [(set (match_operand:SI 0 "general_operand" "=*d,a") - (sign_extend:SI - (match_operand:HI 1 "nonimmediate_operand" "0,rm")))] - "" - "* -{ - if (ADDRESS_REG_P (operands[0])) - return \"move%.w %1,%0\"; - return \"ext%.l %0\"; -}") - -(define_insn "extendqihi2" - [(set (match_operand:HI 0 "general_operand" "=d") - (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))] - "" - "ext%.w %0") - -(define_insn "extendqisi2" - [(set (match_operand:SI 0 "general_operand" "=d") - (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))] - "TARGET_68020" - "extb%.l %0") - -;; Conversions between float and double. - -(define_expand "extendsfdf2" - [(set (match_operand:DF 0 "general_operand" "") - (float_extend:DF - (match_operand:SF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y") - (float_extend:DF - (match_operand:SF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpstod %w1,%0") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=*fdm,f") - (float_extend:DF - (match_operand:SF 1 "general_operand" "f,dmF")))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return \"\"; - } - return \"f%&move%.x %1,%0\"; - } - if (FP_REG_P (operands[0])) - return \"f%&move%.s %f1,%0\"; - if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - return \"fmove%.d %f1,%0\"; -}") - -;; This cannot output into an f-reg because there is no way to be -;; sure of truncating in that case. -;; But on the Sun FPA, we can be sure. -(define_expand "truncdfsf2" - [(set (match_operand:SF 0 "general_operand" "") - (float_truncate:SF - (match_operand:DF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y") - (float_truncate:SF - (match_operand:DF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpdtos %y1,%0") - -;; On the '040 we can truncate in a register accurately and easily. -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (float_truncate:SF - (match_operand:DF 1 "general_operand" "fmG")))] - "TARGET_68040_ONLY" - "* -{ - if (FP_REG_P (operands[1])) - return \"f%$move%.x %1,%0\"; - return \"f%$move%.d %f1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=dm") - (float_truncate:SF - (match_operand:DF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.s %f1,%0") - -;; Conversion between fixed point and floating point. -;; Note that among the fix-to-float insns -;; the ones that start with SImode come first. -;; That is so that an operand that is a CONST_INT -;; (and therefore lacks a specific machine mode). -;; will be recognized as SImode (which is always valid) -;; rather than as QImode or HImode. - -(define_expand "floatsisf2" - [(set (match_operand:SF 0 "general_operand" "") - (float:SF (match_operand:SI 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=y,x") - (float:SF (match_operand:SI 1 "general_operand" "rmi,x")))] - "TARGET_FPA" - "fpltos %1,%0") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (float:SF (match_operand:SI 1 "general_operand" "dmi")))] - "TARGET_68881" - "f%$move%.l %1,%0") - -(define_expand "floatsidf2" - [(set (match_operand:DF 0 "general_operand" "") - (float:DF (match_operand:SI 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=y,x") - (float:DF (match_operand:SI 1 "general_operand" "rmi,x")))] - "TARGET_FPA" - "fpltod %1,%0") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (float:DF (match_operand:SI 1 "general_operand" "dmi")))] - "TARGET_68881" - "f%&move%.l %1,%0") - -(define_insn "floathisf2" - [(set (match_operand:SF 0 "general_operand" "=f") - (float:SF (match_operand:HI 1 "general_operand" "dmn")))] - "TARGET_68881" - "f%$move%.w %1,%0") - -(define_insn "floathidf2" - [(set (match_operand:DF 0 "general_operand" "=f") - (float:DF (match_operand:HI 1 "general_operand" "dmn")))] - "TARGET_68881" - "fmove%.w %1,%0") - -(define_insn "floatqisf2" - [(set (match_operand:SF 0 "general_operand" "=f") - (float:SF (match_operand:QI 1 "general_operand" "dmn")))] - "TARGET_68881" - "fmove%.b %1,%0") - -(define_insn "floatqidf2" - [(set (match_operand:DF 0 "general_operand" "=f") - (float:DF (match_operand:QI 1 "general_operand" "dmn")))] - "TARGET_68881" - "f%&move%.b %1,%0") - -;; New routines to convert floating-point values to integers -;; to be used on the '040. These should be faster than trapping -;; into the kernel to emulate fintrz. They should also be faster -;; than calling the subroutines fixsfsi or fixdfsi. - -(define_insn "fix_truncdfsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f")))) - (clobber (match_scratch:SI 2 "=d")) - (clobber (match_scratch:SI 3 "=d"))] - "TARGET_68040" - "* -{ - CC_STATUS_INIT; - return \"fmovem%.l %!,%2\;moveq %#16,%3\;or%.l %2,%3\;and%.w %#-33,%3\;fmovem%.l %3,%!\;fmove%.l %1,%0\;fmovem%.l %2,%!\"; -}") - -(define_insn "fix_truncdfhi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f")))) - (clobber (match_scratch:SI 2 "=d")) - (clobber (match_scratch:SI 3 "=d"))] - "TARGET_68040" - "* -{ - CC_STATUS_INIT; - return \"fmovem%.l %!,%2\;moveq %#16,%3\;or%.l %2,%3\;and%.w %#-33,%3\;fmovem%.l %3,%!\;fmove%.w %1,%0\;fmovem%.l %2,%!\"; -}") - -(define_insn "fix_truncdfqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f")))) - (clobber (match_scratch:SI 2 "=d")) - (clobber (match_scratch:SI 3 "=d"))] - "TARGET_68040" - "* -{ - CC_STATUS_INIT; - return \"fmovem%.l %!,%2\;moveq %#16,%3\;or%.l %2,%3\;and%.w %#-33,%3\;fmovem%.l %3,%!\;fmove%.b %1,%0\;fmovem%.l %2,%!\"; -}") - -;; Convert a float to a float whose value is an integer. -;; This is the first stage of converting it to an integer type. - -(define_insn "ftruncdf2" - [(set (match_operand:DF 0 "general_operand" "=f") - (fix:DF (match_operand:DF 1 "general_operand" "fFm")))] - "TARGET_68881 && !TARGET_68040" - "* -{ - if (FP_REG_P (operands[1])) - return \"fintrz%.x %f1,%0\"; - return \"fintrz%.d %f1,%0\"; -}") - -(define_insn "ftruncsf2" - [(set (match_operand:SF 0 "general_operand" "=f") - (fix:SF (match_operand:SF 1 "general_operand" "dfFm")))] - "TARGET_68881 && !TARGET_68040" - "* -{ - if (FP_REG_P (operands[1])) - return \"fintrz%.x %f1,%0\"; - return \"fintrz%.s %f1,%0\"; -}") - -;; Convert a float whose value is an integer -;; to an actual integer. Second stage of converting float to integer type. -(define_insn "fixsfqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (fix:QI (match_operand:SF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.b %1,%0") - -(define_insn "fixsfhi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (fix:HI (match_operand:SF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.w %1,%0") - -(define_insn "fixsfsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (fix:SI (match_operand:SF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.l %1,%0") - -(define_insn "fixdfqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (fix:QI (match_operand:DF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.b %1,%0") - -(define_insn "fixdfhi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (fix:HI (match_operand:DF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.w %1,%0") - -(define_insn "fixdfsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (fix:SI (match_operand:DF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.l %1,%0") - -;; Convert a float to an integer. -;; On the Sun FPA, this is done in one step. - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=x,y") - (fix:SI (fix:SF (match_operand:SF 1 "general_operand" "xH,rmF"))))] - "TARGET_FPA" - "fpstol %w1,%0") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=x,y") - (fix:SI (fix:DF (match_operand:DF 1 "general_operand" "xH,rmF"))))] - "TARGET_FPA" - "fpdtol %y1,%0") - -;; add instructions - -;; Note that the middle two alternatives are near-duplicates -;; in order to handle insns generated by reload. -;; This is needed since they are not themselves reloaded, -;; so commutativity won't apply to them. -(define_insn "addsi3" - [(set (match_operand:SI 0 "general_operand" "=m,?a,?a,r") - (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0") - (match_operand:SI 2 "general_operand" "dIKLs,rJK,a,mrIKLs")))] - "" - "* -{ - if (! operands_match_p (operands[0], operands[1])) - { - if (!ADDRESS_REG_P (operands[1])) - { - rtx tmp = operands[1]; - - operands[1] = operands[2]; - operands[2] = tmp; - } - - /* These insns can result from reloads to access - stack slots over 64k from the frame pointer. */ - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) + 0x8000 >= (unsigned) 0x10000) - return \"move%.l %2,%0\;add%.l %1,%0\"; -#ifdef SGS - if (GET_CODE (operands[2]) == REG) - return \"lea 0(%1,%2.l),%0\"; - else - return \"lea %c2(%1),%0\"; -#else /* not SGS */ -#ifdef MOTOROLA - if (GET_CODE (operands[2]) == REG) - return \"lea (%1,%2.l),%0\"; - else - return \"lea (%c2,%1),%0\"; -#else /* not MOTOROLA (MIT syntax) */ - if (GET_CODE (operands[2]) == REG) - return \"lea %1@(0,%2:l),%0\"; - else - return \"lea %1@(%c2),%0\"; -#endif /* not MOTOROLA */ -#endif /* not SGS */ - } - if (GET_CODE (operands[2]) == CONST_INT) - { -#ifndef NO_ADDSUB_Q - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return (ADDRESS_REG_P (operands[0]) - ? \"addq%.w %2,%0\" - : \"addq%.l %2,%0\"); - if (INTVAL (operands[2]) < 0 - && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2])); - return (ADDRESS_REG_P (operands[0]) - ? \"subq%.w %2,%0\" - : \"subq%.l %2,%0\"); - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw.*/ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return \"addq%.w %#8,%0\;addq%.w %2,%0\"; - } - if (INTVAL (operands[2]) < -8 - && INTVAL (operands[2]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2]) - 8); - return \"subq%.w %#8,%0\;subq%.w %2,%0\"; - } -#endif - if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[2]) >= -0x8000 - && INTVAL (operands[2]) < 0x8000) - return \"add%.w %2,%0\"; - } - return \"add%.l %2,%0\"; -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=a") - (plus:SI (match_operand:SI 1 "general_operand" "0") - (sign_extend:SI - (match_operand:HI 2 "nonimmediate_operand" "rm"))))] - "" - "add%.w %2,%0") - -(define_insn "addhi3" - [(set (match_operand:HI 0 "general_operand" "=m,r") - (plus:HI (match_operand:HI 1 "general_operand" "%0,0") - (match_operand:HI 2 "general_operand" "dn,rmn")))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[2]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[2]) >= 32768) - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) - 65536); - - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return \"addq%.w %2,%0\"; - if (INTVAL (operands[2]) < 0 - && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2])); - return \"subq%.w %2,%0\"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return \"addq%.w %#8,%0\;addq%.w %2,%0\"; - } - if (INTVAL (operands[2]) < -8 - && INTVAL (operands[2]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2]) - 8); - return \"subq%.w %#8,%0\;subq%.w %2,%0\"; - } - } -#endif - return \"add%.w %2,%0\"; -}") - -;; These insns must use MATCH_DUP instead of the more expected -;; use of a matching constraint because the "output" here is also -;; an input, so you can't use the matching constraint. That also means -;; that you can't use the "%", so you need patterns with the matched -;; operand in both positions. - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (plus:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dn,rmn")))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[1]) >= 32768) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 65536); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return \"addq%.w %1,%0\"; - if (INTVAL (operands[1]) < 0 - && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1])); - return \"subq%.w %1,%0\"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[1]) > 8 - && INTVAL (operands[1]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); - return \"addq%.w %#8,%0\;addq%.w %1,%0\"; - } - if (INTVAL (operands[1]) < -8 - && INTVAL (operands[1]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1]) - 8); - return \"subq%.w %#8,%0\;subq%.w %1,%0\"; - } - } -#endif - return \"add%.w %1,%0\"; -}") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (plus:HI (match_operand:HI 1 "general_operand" "dn,rmn") - (match_dup 0)))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[1]) >= 32768) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 65536); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return \"addq%.w %1,%0\"; - if (INTVAL (operands[1]) < 0 - && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1])); - return \"subq%.w %1,%0\"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[1]) > 8 - && INTVAL (operands[1]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); - return \"addq%.w %#8,%0\;addq%.w %1,%0\"; - } - if (INTVAL (operands[1]) < -8 - && INTVAL (operands[1]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1]) - 8); - return \"subq%.w %#8,%0\;subq%.w %1,%0\"; - } - } -#endif - return \"add%.w %1,%0\"; -}") - -(define_insn "addqi3" - [(set (match_operand:QI 0 "general_operand" "=m,d") - (plus:QI (match_operand:QI 1 "general_operand" "%0,0") - (match_operand:QI 2 "general_operand" "dn,dmn")))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[2]) == CONST_INT) - { - if (INTVAL (operands[2]) >= 128) - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) - 256); - - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return \"addq%.b %2,%0\"; - if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2])); - return \"subq%.b %2,%0\"; - } - } -#endif - return \"add%.b %2,%0\"; -}") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (plus:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dn,dmn")))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) >= 128) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 256); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return \"addq%.b %1,%0\"; - if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1])); - return \"subq%.b %1,%0\"; - } - } -#endif - return \"add%.b %1,%0\"; -}") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (plus:QI (match_operand:QI 1 "general_operand" "dn,dmn") - (match_dup 0)))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) >= 128) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 256); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return \"addq%.b %1,%0\"; - if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1])); - return \"subq%.b %1,%0\"; - } - } -#endif - return \"add%.b %1,%0\"; -}") - -(define_expand "adddf3" - [(set (match_operand:DF 0 "general_operand" "") - (plus:DF (match_operand:DF 1 "general_operand" "") - (match_operand:DF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y") - (plus:DF (match_operand:DF 1 "general_operand" "%xH,y") - (match_operand:DF 2 "general_operand" "xH,dmF")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[1])) - return \"fpadd%.d %y2,%0\"; - if (rtx_equal_p (operands[0], operands[2])) - return \"fpadd%.d %y1,%0\"; - if (which_alternative == 0) - return \"fpadd3%.d %w2,%w1,%0\"; - return \"fpadd3%.d %x2,%x1,%0\"; -}") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (plus:DF (match_operand:DF 1 "general_operand" "%0") - (match_operand:DF 2 "general_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"f%&add%.x %2,%0\"; - return \"f%&add%.d %f2,%0\"; -}") - -(define_expand "addsf3" - [(set (match_operand:SF 0 "general_operand" "") - (plus:SF (match_operand:SF 1 "general_operand" "") - (match_operand:SF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y") - (plus:SF (match_operand:SF 1 "general_operand" "%xH,y") - (match_operand:SF 2 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[1])) - return \"fpadd%.s %w2,%0\"; - if (rtx_equal_p (operands[0], operands[2])) - return \"fpadd%.s %w1,%0\"; - if (which_alternative == 0) - return \"fpadd3%.s %w2,%w1,%0\"; - return \"fpadd3%.s %2,%1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (plus:SF (match_operand:SF 1 "general_operand" "%0") - (match_operand:SF 2 "general_operand" "fdmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return \"f%$add%.x %2,%0\"; - return \"f%$add%.s %f2,%0\"; -}") - -;; subtract instructions - -(define_insn "subsi3" - [(set (match_operand:SI 0 "general_operand" "=m,r,!a,?d") - (minus:SI (match_operand:SI 1 "general_operand" "0,0,a,mrIKs") - (match_operand:SI 2 "general_operand" "dIKs,mrIKs,J,0")))] - "" - "* -{ - if (! operands_match_p (operands[0], operands[1])) - { - if (operands_match_p (operands[0], operands[2])) - { -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return \"subq%.l %1,%0\;neg%.l %0\"; - } -#endif - return \"sub%.l %1,%0\;neg%.l %0\"; - } - /* This case is matched by J, but negating -0x8000 - in an lea would give an invalid displacement. - So do this specially. */ - if (INTVAL (operands[2]) == -0x8000) - return \"move%.l %1,%0\;sub%.l %2,%0\"; -#ifdef SGS - return \"lea %n2(%1),%0\"; -#else -#ifdef MOTOROLA - return \"lea (%n2,%1),%0\"; -#else /* not MOTOROLA (MIT syntax) */ - return \"lea %1@(%n2),%0\"; -#endif /* not MOTOROLA */ -#endif /* not SGS */ - } - if (GET_CODE (operands[2]) == CONST_INT) - { -#ifndef NO_ADDSUB_Q - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return \"subq%.l %2,%0\"; - /* Using two subqw for 8 < N <= 16 being subtracted from an - address register is faster on all but 68000 */ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return \"subq%.w %#8,%0\;subq%.w %2,%0\"; - } -#endif - if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[2]) >= -0x8000 - && INTVAL (operands[2]) < 0x8000) - return \"sub%.w %2,%0\"; - } - return \"sub%.l %2,%0\"; -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=a") - (minus:SI (match_operand:SI 1 "general_operand" "0") - (sign_extend:SI - (match_operand:HI 2 "nonimmediate_operand" "rm"))))] - "" - "sub%.w %2,%0") - -(define_insn "subhi3" - [(set (match_operand:HI 0 "general_operand" "=m,r") - (minus:HI (match_operand:HI 1 "general_operand" "0,0") - (match_operand:HI 2 "general_operand" "dn,rmn")))] - "" - "sub%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (minus:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dn,rmn")))] - "" - "sub%.w %1,%0") - -(define_insn "subqi3" - [(set (match_operand:QI 0 "general_operand" "=m,d") - (minus:QI (match_operand:QI 1 "general_operand" "0,0") - (match_operand:QI 2 "general_operand" "dn,dmn")))] - "" - "sub%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (minus:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dn,dmn")))] - "" - "sub%.b %1,%0") - -(define_expand "subdf3" - [(set (match_operand:DF 0 "general_operand" "") - (minus:DF (match_operand:DF 1 "general_operand" "") - (match_operand:DF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y,y") - (minus:DF (match_operand:DF 1 "general_operand" "xH,y,dmF") - (match_operand:DF 2 "general_operand" "xH,dmF,0")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[2])) - return \"fprsub%.d %y1,%0\"; - if (rtx_equal_p (operands[0], operands[1])) - return \"fpsub%.d %y2,%0\"; - if (which_alternative == 0) - return \"fpsub3%.d %w2,%w1,%0\"; - return \"fpsub3%.d %x2,%x1,%0\"; -}") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (minus:DF (match_operand:DF 1 "general_operand" "0") - (match_operand:DF 2 "general_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"f%&sub%.x %2,%0\"; - return \"f%&sub%.d %f2,%0\"; -}") - -(define_expand "subsf3" - [(set (match_operand:SF 0 "general_operand" "") - (minus:SF (match_operand:SF 1 "general_operand" "") - (match_operand:SF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y,y") - (minus:SF (match_operand:SF 1 "general_operand" "xH,y,rmF") - (match_operand:SF 2 "general_operand" "xH,rmF,0")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[2])) - return \"fprsub%.s %w1,%0\"; - if (rtx_equal_p (operands[0], operands[1])) - return \"fpsub%.s %w2,%0\"; - if (which_alternative == 0) - return \"fpsub3%.s %w2,%w1,%0\"; - return \"fpsub3%.s %2,%1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (minus:SF (match_operand:SF 1 "general_operand" "0") - (match_operand:SF 2 "general_operand" "fdmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return \"f%$sub%.x %2,%0\"; - return \"f%$sub%.s %f2,%0\"; -}") - -;; multiply instructions - -(define_insn "mulhi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (mult:HI (match_operand:HI 1 "general_operand" "%0") - (match_operand:HI 2 "general_operand" "dmn")))] - "" - "* -{ -#if defined(MOTOROLA) && !defined(CRDS) - return \"muls%.w %2,%0\"; -#else - return \"muls %2,%0\"; -#endif -}") - -(define_insn "mulhisi3" - [(set (match_operand:SI 0 "general_operand" "=d") - (mult:SI (sign_extend:SI - (match_operand:HI 1 "nonimmediate_operand" "%0")) - (sign_extend:SI - (match_operand:HI 2 "nonimmediate_operand" "dm"))))] - "" - "* -{ -#if defined(MOTOROLA) && !defined(CRDS) - return \"muls%.w %2,%0\"; -#else - return \"muls %2,%0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=d") - (mult:SI (sign_extend:SI - (match_operand:HI 1 "nonimmediate_operand" "%0")) - (match_operand:SI 2 "const_int_operand" "n")))] - "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff" - "* -{ -#if defined(MOTOROLA) && !defined(CRDS) - return \"muls%.w %2,%0\"; -#else - return \"muls %2,%0\"; -#endif -}") - -(define_insn "mulsi3" - [(set (match_operand:SI 0 "general_operand" "=d") - (mult:SI (match_operand:SI 1 "general_operand" "%0") - (match_operand:SI 2 "general_operand" "dmsK")))] - "TARGET_68020" - "muls%.l %2,%0") - -(define_insn "umulhisi3" - [(set (match_operand:SI 0 "general_operand" "=d") - (mult:SI (zero_extend:SI - (match_operand:HI 1 "nonimmediate_operand" "%0")) - (zero_extend:SI - (match_operand:HI 2 "nonimmediate_operand" "dm"))))] - "" - "* -{ -#if defined(MOTOROLA) && !defined(CRDS) - return \"mulu%.w %2,%0\"; -#else - return \"mulu %2,%0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=d") - (mult:SI (zero_extend:SI - (match_operand:HI 1 "nonimmediate_operand" "%0")) - (match_operand:SI 2 "const_int_operand" "n")))] - "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff" - "* -{ -#if defined(MOTOROLA) && !defined(CRDS) - return \"mulu%.w %2,%0\"; -#else - return \"mulu %2,%0\"; -#endif -}") - -;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the -;; proper matching constraint. This is because the matching is between -;; the high-numbered word of the DImode operand[0] and operand[1]. -(define_expand "umulsidi3" - [(parallel - [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 1) - (mult:SI (match_operand:SI 1 "register_operand" "") - (match_operand:SI 2 "nonimmediate_operand" ""))) - (set (subreg:SI (match_dup 0) 0) - (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1)) - (zero_extend:DI (match_dup 2))) - (const_int 32))))])] - "TARGET_68020" - "") - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (mult:SI (match_operand:SI 1 "register_operand" "%0") - (match_operand:SI 2 "nonimmediate_operand" "dm"))) - (set (match_operand:SI 3 "register_operand" "=d") - (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1)) - (zero_extend:DI (match_dup 2))) - (const_int 32))))] - "TARGET_68020" - "mulu%.l %2,%3:%0") - -; Match immediate case. For 2.4 only match things < 2^31. -; It's tricky with larger values in these patterns since we need to match -; values between the two parallel multiplies, between a CONST_DOUBLE and -; a CONST_INT. -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (mult:SI (match_operand:SI 1 "register_operand" "%0") - (match_operand:SI 2 "const_int_operand" "n"))) - (set (match_operand:SI 3 "register_operand" "=d") - (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1)) - (match_dup 2)) - (const_int 32))))] - "TARGET_68020 - && (unsigned) INTVAL (operands[2]) <= 0x7fffffff" - "mulu%.l %2,%3:%0") - -(define_expand "mulsidi3" - [(parallel - [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 1) - (mult:SI (match_operand:SI 1 "register_operand" "") - (match_operand:SI 2 "nonimmediate_operand" ""))) - (set (subreg:SI (match_dup 0) 0) - (truncate:SI (ashift:DI (mult:DI (sign_extend:DI (match_dup 1)) - (sign_extend:DI (match_dup 2))) - (const_int 32))))])] - "TARGET_68020" - "") - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (mult:SI (match_operand:SI 1 "register_operand" "%0") - (match_operand:SI 2 "nonimmediate_operand" "dm"))) - (set (match_operand:SI 3 "register_operand" "=d") - (truncate:SI (ashift:DI (mult:DI (sign_extend:DI (match_dup 1)) - (sign_extend:DI (match_dup 2))) - (const_int 32))))] - "TARGET_68020" - "muls%.l %2,%3:%0") - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (mult:SI (match_operand:SI 1 "register_operand" "%0") - (match_operand:SI 2 "const_int_operand" "n"))) - (set (match_operand:SI 3 "register_operand" "=d") - (truncate:SI (ashift:DI (mult:DI (sign_extend:DI (match_dup 1)) - (match_dup 2)) - (const_int 32))))] - "TARGET_68020 - /* This test is a noop on 32 bit machines, - but important for a cross-compiler hosted on 64-bit machines. */ - && INTVAL (operands[2]) <= 0x7fffffff - && INTVAL (operands[2]) >= -0x80000000" - "muls%.l %2,%3:%0") - -(define_expand "muldf3" - [(set (match_operand:DF 0 "general_operand" "") - (mult:DF (match_operand:DF 1 "general_operand" "") - (match_operand:DF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y") - (mult:DF (match_operand:DF 1 "general_operand" "%xH,y") - (match_operand:DF 2 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[1], operands[2])) - return \"fpsqr%.d %y1,%0\"; - if (rtx_equal_p (operands[0], operands[1])) - return \"fpmul%.d %y2,%0\"; - if (rtx_equal_p (operands[0], operands[2])) - return \"fpmul%.d %y1,%0\"; - if (which_alternative == 0) - return \"fpmul3%.d %w2,%w1,%0\"; - return \"fpmul3%.d %x2,%x1,%0\"; -}") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (mult:DF (match_operand:DF 1 "general_operand" "%0") - (match_operand:DF 2 "general_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (GET_CODE (operands[2]) == CONST_DOUBLE - && floating_exact_log2 (operands[2]) && !TARGET_68040) - { - int i = floating_exact_log2 (operands[2]); - operands[2] = gen_rtx (CONST_INT, VOIDmode, i); - return \"fscale%.l %2,%0\"; - } - if (REG_P (operands[2])) - return \"f%&mul%.x %2,%0\"; - return \"f%&mul%.d %f2,%0\"; -}") - -(define_expand "mulsf3" - [(set (match_operand:SF 0 "general_operand" "") - (mult:SF (match_operand:SF 1 "general_operand" "") - (match_operand:SF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y") - (mult:SF (match_operand:SF 1 "general_operand" "%xH,y") - (match_operand:SF 2 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[1], operands[2])) - return \"fpsqr%.s %w1,%0\"; - if (rtx_equal_p (operands[0], operands[1])) - return \"fpmul%.s %w2,%0\"; - if (rtx_equal_p (operands[0], operands[2])) - return \"fpmul%.s %w1,%0\"; - if (which_alternative == 0) - return \"fpmul3%.s %w2,%w1,%0\"; - return \"fpmul3%.s %2,%1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (mult:SF (match_operand:SF 1 "general_operand" "%0") - (match_operand:SF 2 "general_operand" "fdmF")))] - "TARGET_68881" - "* -{ -#ifdef FSGLMUL_USE_S - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? \"fsmul%.s %2,%0\" - : \"fsglmul%.s %2,%0\"); -#else - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? \"fsmul%.x %2,%0\" - : \"fsglmul%.x %2,%0\"); -#endif - return (TARGET_68040_ONLY - ? \"fsmul%.s %f2,%0\" - : \"fsglmul%.s %f2,%0\"); -}") - -;; divide instructions - -(define_insn "divhi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (div:HI (match_operand:HI 1 "general_operand" "0") - (match_operand:HI 2 "general_operand" "dmn")))] - "" - "* -{ -#ifdef MOTOROLA - return \"ext%.l %0\;divs%.w %2,%0\"; -#else - return \"extl %0\;divs %2,%0\"; -#endif -}") - -(define_insn "divhisi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI - (div:SI - (match_operand:SI 1 "general_operand" "0") - (sign_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))] - "" - "* -{ -#ifdef MOTOROLA - return \"divs%.w %2,%0\"; -#else - return \"divs %2,%0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI (div:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "const_int_operand" "n"))))] - "" - "* -{ -#ifdef MOTOROLA - return \"divs%.w %2,%0\"; -#else - return \"divs %2,%0\"; -#endif -}") - -(define_insn "udivhi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (udiv:HI (match_operand:HI 1 "general_operand" "0") - (match_operand:HI 2 "general_operand" "dmn")))] - "" - "* -{ -#ifdef MOTOROLA - return \"and%.l %#0xFFFF,%0\;divu%.w %2,%0\"; -#else - return \"andl %#0xFFFF,%0\;divu %2,%0\"; -#endif -}") - -(define_insn "udivhisi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI - (udiv:SI - (match_operand:SI 1 "general_operand" "0") - (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))] - "" - "* -{ -#ifdef MOTOROLA - return \"divu%.w %2,%0\"; -#else - return \"divu %2,%0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI (udiv:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "const_int_operand" "n"))))] - "" - "* -{ -#ifdef MOTOROLA - return \"divu%.w %2,%0\"; -#else - return \"divu %2,%0\"; -#endif -}") - -(define_expand "divdf3" - [(set (match_operand:DF 0 "general_operand" "") - (div:DF (match_operand:DF 1 "general_operand" "") - (match_operand:DF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y,y") - (div:DF (match_operand:DF 1 "general_operand" "xH,y,rmF") - (match_operand:DF 2 "general_operand" "xH,rmF,0")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[2])) - return \"fprdiv%.d %y1,%0\"; - if (rtx_equal_p (operands[0], operands[1])) - return \"fpdiv%.d %y2,%0\"; - if (which_alternative == 0) - return \"fpdiv3%.d %w2,%w1,%0\"; - return \"fpdiv3%.d %x2,%x1,%x0\"; -}") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (div:DF (match_operand:DF 1 "general_operand" "0") - (match_operand:DF 2 "general_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"f%&div%.x %2,%0\"; - return \"f%&div%.d %f2,%0\"; -}") - -(define_expand "divsf3" - [(set (match_operand:SF 0 "general_operand" "") - (div:SF (match_operand:SF 1 "general_operand" "") - (match_operand:SF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y,y") - (div:SF (match_operand:SF 1 "general_operand" "xH,y,rmF") - (match_operand:SF 2 "general_operand" "xH,rmF,0")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[1])) - return \"fpdiv%.s %w2,%0\"; - if (rtx_equal_p (operands[0], operands[2])) - return \"fprdiv%.s %w1,%0\"; - if (which_alternative == 0) - return \"fpdiv3%.s %w2,%w1,%0\"; - return \"fpdiv3%.s %2,%1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (div:SF (match_operand:SF 1 "general_operand" "0") - (match_operand:SF 2 "general_operand" "fdmF")))] - "TARGET_68881" - "* -{ -#ifdef FSGLDIV_USE_S - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? \"fsdiv%.s %2,%0\" - : \"fsgldiv%.s %2,%0\"); -#else - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? \"fsdiv%.x %2,%0\" - : \"fsgldiv%.x %2,%0\"); -#endif - return (TARGET_68040_ONLY - ? \"fsdiv%.s %f2,%0\" - : \"fsgldiv%.s %f2,%0\"); -}") - -;; Remainder instructions. - -(define_insn "modhi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (mod:HI (match_operand:HI 1 "general_operand" "0") - (match_operand:HI 2 "general_operand" "dmn")))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"ext%.l %0\;divs%.w %2,%0\;swap %0\"; -#else - return \"extl %0\;divs %2,%0\;swap %0\"; -#endif -}") - -(define_insn "modhisi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI - (mod:SI - (match_operand:SI 1 "general_operand" "0") - (sign_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"divs%.w %2,%0\;swap %0\"; -#else - return \"divs %2,%0\;swap %0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI (mod:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "const_int_operand" "n"))))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"divs%.w %2,%0\;swap %0\"; -#else - return \"divs %2,%0\;swap %0\"; -#endif -}") - -(define_insn "umodhi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (umod:HI (match_operand:HI 1 "general_operand" "0") - (match_operand:HI 2 "general_operand" "dmn")))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"and%.l %#0xFFFF,%0\;divu%.w %2,%0\;swap %0\"; -#else - return \"andl %#0xFFFF,%0\;divu %2,%0\;swap %0\"; -#endif -}") - -(define_insn "umodhisi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI - (umod:SI - (match_operand:SI 1 "general_operand" "0") - (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"divu%.w %2,%0\;swap %0\"; -#else - return \"divu %2,%0\;swap %0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI (umod:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "const_int_operand" "n"))))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"divu%.w %2,%0\;swap %0\"; -#else - return \"divu %2,%0\;swap %0\"; -#endif -}") - -(define_insn "divmodsi4" - [(set (match_operand:SI 0 "general_operand" "=d") - (div:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "general_operand" "dmsK"))) - (set (match_operand:SI 3 "general_operand" "=d") - (mod:SI (match_dup 1) (match_dup 2)))] - "TARGET_68020" - "* -{ - if (find_reg_note (insn, REG_UNUSED, operands[3])) - return \"divs%.l %2,%0\"; - else - return \"divsl%.l %2,%3:%0\"; -}") - -(define_insn "udivmodsi4" - [(set (match_operand:SI 0 "general_operand" "=d") - (udiv:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "general_operand" "dmsK"))) - (set (match_operand:SI 3 "general_operand" "=d") - (umod:SI (match_dup 1) (match_dup 2)))] - "TARGET_68020" - "* -{ - if (find_reg_note (insn, REG_UNUSED, operands[3])) - return \"divu%.l %2,%0\"; - else - return \"divul%.l %2,%3:%0\"; -}") - -;; logical-and instructions - -;; Prevent AND from being made with sp. This doesn't exist in the machine -;; and reload will cause inefficient code. Since sp is a FIXED_REG, we -;; can't allocate pseudos into it. -(define_insn "andsi3" - [(set (match_operand:SI 0 "not_sp_operand" "=m,d") - (and:SI (match_operand:SI 1 "general_operand" "%0,0") - (match_operand:SI 2 "general_operand" "dKs,dmKs")))] - "" - "* -{ - int logval; - if (GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) | 0xffff) == 0xffffffff - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (GET_CODE (operands[0]) != REG) - operands[0] = adj_offsettable_operand (operands[0], 2); - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) & 0xffff); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - if (operands[2] == const0_rtx) - return \"clr%.w %0\"; - return \"and%.w %2,%0\"; - } - if (GET_CODE (operands[2]) == CONST_INT - && (logval = exact_log2 (~ INTVAL (operands[2]))) >= 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval); - } - else - { - operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8)); operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8); - } - /* This does not set condition codes in a standard way. */ - CC_STATUS_INIT; - return \"bclr %1,%0\"; - } - return \"and%.l %2,%0\"; -}") - -(define_insn "andhi3" - [(set (match_operand:HI 0 "general_operand" "=m,d") - (and:HI (match_operand:HI 1 "general_operand" "%0,0") - (match_operand:HI 2 "general_operand" "dn,dmn")))] - "" - "and%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (and:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dn,dmn")))] - "" - "and%.w %1,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (and:HI (match_operand:HI 1 "general_operand" "dn,dmn") - (match_dup 0)))] - "" - "and%.w %1,%0") - -(define_insn "andqi3" - [(set (match_operand:QI 0 "general_operand" "=m,d") - (and:QI (match_operand:QI 1 "general_operand" "%0,0") - (match_operand:QI 2 "general_operand" "dn,dmn")))] - "" - "and%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (and:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dn,dmn")))] - "" - "and%.b %1,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (and:QI (match_operand:QI 1 "general_operand" "dn,dmn") - (match_dup 0)))] - "" - "and%.b %1,%0") - -;; inclusive-or instructions - -(define_insn "iorsi3" - [(set (match_operand:SI 0 "general_operand" "=m,d") - (ior:SI (match_operand:SI 1 "general_operand" "%0,0") - (match_operand:SI 2 "general_operand" "dKs,dmKs")))] - "" - "* -{ - register int logval; - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) >> 16 == 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (GET_CODE (operands[0]) != REG) - operands[0] = adj_offsettable_operand (operands[0], 2); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - return \"or%.w %2,%0\"; - } - if (GET_CODE (operands[2]) == CONST_INT - && (logval = exact_log2 (INTVAL (operands[2]))) >= 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval); - } - else - { - operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8)); - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8); - } - CC_STATUS_INIT; - return \"bset %1,%0\"; - } - return \"or%.l %2,%0\"; -}") - -(define_insn "iorhi3" - [(set (match_operand:HI 0 "general_operand" "=m,d") - (ior:HI (match_operand:HI 1 "general_operand" "%0,0") - (match_operand:HI 2 "general_operand" "dn,dmn")))] - "" - "or%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (ior:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dn,dmn")))] - "" - "or%.w %1,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (ior:HI (match_operand:HI 1 "general_operand" "dn,dmn") - (match_dup 0)))] - "" - "or%.w %1,%0") - -(define_insn "iorqi3" - [(set (match_operand:QI 0 "general_operand" "=m,d") - (ior:QI (match_operand:QI 1 "general_operand" "%0,0") - (match_operand:QI 2 "general_operand" "dn,dmn")))] - "" - "or%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (ior:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dn,dmn")))] - "" - "or%.b %1,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (ior:QI (match_operand:QI 1 "general_operand" "dn,dmn") - (match_dup 0)))] - "" - "or%.b %1,%0") - -;; xor instructions - -(define_insn "xorsi3" - [(set (match_operand:SI 0 "general_operand" "=do,m") - (xor:SI (match_operand:SI 1 "general_operand" "%0,0") - (match_operand:SI 2 "general_operand" "di,dKs")))] - "" - "* -{ - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) >> 16 == 0 - && (offsettable_memref_p (operands[0]) || DATA_REG_P (operands[0]))) - { - if (! DATA_REG_P (operands[0])) - operands[0] = adj_offsettable_operand (operands[0], 2); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - return \"eor%.w %2,%0\"; - } - return \"eor%.l %2,%0\"; -}") - -(define_insn "xorhi3" - [(set (match_operand:HI 0 "general_operand" "=dm") - (xor:HI (match_operand:HI 1 "general_operand" "%0") - (match_operand:HI 2 "general_operand" "dn")))] - "" - "eor%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm")) - (xor:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dn")))] - "" - "eor%.w %1,%0") - - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm")) - (xor:HI (match_operand:HI 1 "general_operand" "dn") - (match_dup 0)))] - "" - "eor%.w %1,%0") - -(define_insn "xorqi3" - [(set (match_operand:QI 0 "general_operand" "=dm") - (xor:QI (match_operand:QI 1 "general_operand" "%0") - (match_operand:QI 2 "general_operand" "dn")))] - "" - "eor%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm")) - (xor:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dn")))] - "" - "eor%.b %1,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm")) - (xor:QI (match_operand:QI 1 "general_operand" "dn") - (match_dup 0)))] - "" - "eor%.b %1,%0") - -;; negation instructions - -(define_insn "negsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (neg:SI (match_operand:SI 1 "general_operand" "0")))] - "" - "neg%.l %0") - -(define_insn "neghi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (neg:HI (match_operand:HI 1 "general_operand" "0")))] - "" - "neg%.w %0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm")) - (neg:HI (match_dup 0)))] - "" - "neg%.w %0") - -(define_insn "negqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (neg:QI (match_operand:QI 1 "general_operand" "0")))] - "" - "neg%.b %0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm")) - (neg:QI (match_dup 0)))] - "" - "neg%.b %0") - -(define_expand "negsf2" - [(set (match_operand:SF 0 "general_operand" "") - (neg:SF (match_operand:SF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y") - (neg:SF (match_operand:SF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpneg%.s %w1,%0") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f,d") - (neg:SF (match_operand:SF 1 "general_operand" "fdmF,0")))] - "TARGET_68881" - "* -{ - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, 31); - return \"bchg %1,%0\"; - } - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"f%$neg%.x %1,%0\"; - return \"f%$neg%.s %f1,%0\"; -}") - -(define_expand "negdf2" - [(set (match_operand:DF 0 "general_operand" "") - (neg:DF (match_operand:DF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y") - (neg:DF (match_operand:DF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpneg%.d %y1, %0") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f,d") - (neg:DF (match_operand:DF 1 "general_operand" "fmF,0")))] - "TARGET_68881" - "* -{ - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, 31); - return \"bchg %1,%0\"; - } - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"f%&neg%.x %1,%0\"; - return \"f%&neg%.d %f1,%0\"; -}") - -;; Sqrt instruction for the 68881 - -(define_insn "sqrtdf2" - [(set (match_operand:DF 0 "general_operand" "=f") - (sqrt:DF (match_operand:DF 1 "general_operand" "fm")))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[1])) - return \"fsqrt%.x %1,%0\"; - else - return \"fsqrt%.d %1,%0\"; -}") - -;; Absolute value instructions - -(define_expand "abssf2" - [(set (match_operand:SF 0 "general_operand" "") - (abs:SF (match_operand:SF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y") - (abs:SF (match_operand:SF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpabs%.s %y1,%0") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (abs:SF (match_operand:SF 1 "general_operand" "fdmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"f%$abs%.x %1,%0\"; - return \"f%$abs%.s %f1,%0\"; -}") - -(define_expand "absdf2" - [(set (match_operand:DF 0 "general_operand" "") - (abs:DF (match_operand:DF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y") - (abs:DF (match_operand:DF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpabs%.d %y1,%0") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (abs:DF (match_operand:DF 1 "general_operand" "fmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"f%&abs%.x %1,%0\"; - return \"f%&abs%.d %f1,%0\"; -}") - -;; one complement instructions - -(define_insn "one_cmplsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (not:SI (match_operand:SI 1 "general_operand" "0")))] - "" - "not%.l %0") - -(define_insn "one_cmplhi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (not:HI (match_operand:HI 1 "general_operand" "0")))] - "" - "not%.w %0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm")) - (not:HI (match_dup 0)))] - "" - "not%.w %0") - -(define_insn "one_cmplqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (not:QI (match_operand:QI 1 "general_operand" "0")))] - "" - "not%.b %0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm")) - (not:QI (match_dup 0)))] - "" - "not%.b %0") - -;; arithmetic shift instructions -;; We don't need the shift memory by 1 bit instruction - -;; On all 68k models, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)" - "* -{ - CC_STATUS_INIT; - return \"swap %0\;clr%.w %0\"; -}") - -;; On the 68000, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)" - "* -{ - CC_STATUS_INIT; - - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return \"asl%.w %2,%0\;swap %0\;clr%.w %0\"; -}") - -(define_insn "ashlsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "* -{ - if (operands[2] == const1_rtx) - return \"add%.l %0,%0\"; - return \"asl%.l %2,%0\"; -}") - -(define_insn "ashlhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (ashift:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "asl%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (ashift:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "asl%.w %1,%0") - -(define_insn "ashlqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (ashift:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "asl%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (ashift:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "asl%.b %1,%0") - -;; On all 68k models, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)" - "swap %0\;ext%.l %0") - -;; On the 68000, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)" - "* -{ - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return \"swap %0\;asr%.w %2,%0\;ext%.l %0\"; -}") - -(define_insn "ashrsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "* -{ - return \"asr%.l %2,%0\"; -}") - -(define_insn "ashrhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (ashiftrt:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "asr%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (ashiftrt:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "asr%.w %1,%0") - -(define_insn "ashrqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (ashiftrt:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "asr%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (ashiftrt:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "asr%.b %1,%0") - -;; logical shift instructions - -;; On all 68k models, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)" - "* -{ - CC_STATUS_INIT; - return \"swap %0\;clr%.w %0\"; -}") - -;; On the 68000, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)" - "* -{ - CC_STATUS_INIT; - - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return \"lsl%.w %2,%0\;swap %0\;clr%.w %0\"; -}") - -(define_insn "lshlsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "* -{ - if (operands[2] == const1_rtx) - return \"add%.l %0,%0\"; - return \"lsl%.l %2,%0\"; -}") - -(define_insn "lshlhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (lshift:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "lsl%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (lshift:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "lsl%.w %1,%0") - -(define_insn "lshlqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (lshift:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "lsl%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (lshift:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "lsl%.b %1,%0") - -;; On all 68k models, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)" - "* -{ - CC_STATUS_INIT; - return \"clr%.w %0\;swap %0\"; -}") - -;; On the 68000, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)" - "* -{ - /* I think lsr%.w sets the CC properly. */ - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return \"clr%.w %0\;swap %0\;lsr%.w %2,%0\"; -}") - -(define_insn "lshrsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "* -{ - return \"lsr%.l %2,%0\"; -}") - -(define_insn "lshrhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (lshiftrt:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "lsr%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (lshiftrt:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "lsr%.w %1,%0") - -(define_insn "lshrqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (lshiftrt:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "lsr%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (lshiftrt:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "lsr%.b %1,%0") - -;; rotate instructions - -(define_insn "rotlsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (rotate:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "rol%.l %2,%0") - -(define_insn "rotlhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (rotate:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "rol%.w %2,%0") - - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (rotate:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "rol%.w %1,%0") - -(define_insn "rotlqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (rotate:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "rol%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (rotate:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "rol%.b %1,%0") - -(define_insn "rotrsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (rotatert:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "ror%.l %2,%0") - -(define_insn "rotrhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (rotatert:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "ror%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (rotatert:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "ror%.w %1,%0") - -(define_insn "rotrqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (rotatert:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "ror%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (rotatert:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "ror%.b %1,%0") - -;; Special cases of bit-field insns which we should -;; recognize in preference to the general case. -;; These handle aligned 8-bit and 16-bit fields, -;; which can usually be done with move instructions. - -; -; Special case for 32-bit field in memory. This only occurs when 32-bit -; alignment of structure members is specified. -; -; The move is allowed to be odd byte aligned, because that's still faster -; than an odd byte aligned bit field instruction. -; -(define_insn "" - [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o") - (match_operand:SI 1 "immediate_operand" "i") - (match_operand:SI 2 "immediate_operand" "i")) - (match_operand:SI 3 "general_operand" "rmi"))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT - && (INTVAL (operands[1]) == 32) - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[0], 0))" - "* -{ - operands[0] - = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8); - - return \"move%.l %3,%0\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+do") - (match_operand:SI 1 "immediate_operand" "i") - (match_operand:SI 2 "immediate_operand" "i")) - (match_operand:SI 3 "general_operand" "d"))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT - && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16) - && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) % INTVAL (operands[1]) == 0 - && (GET_CODE (operands[0]) == REG - || ! mode_dependent_address_p (XEXP (operands[0], 0)))" - "* -{ - if (REG_P (operands[0])) - { - if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32) - return \"bfins %3,%0{%b2:%b1}\"; - } - else - operands[0] - = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8); - - if (GET_CODE (operands[3]) == MEM) - operands[3] = adj_offsettable_operand (operands[3], - (32 - INTVAL (operands[1])) / 8); - if (INTVAL (operands[1]) == 8) - return \"move%.b %3,%0\"; - return \"move%.w %3,%0\"; -}") - - -; -; Special case for 32-bit field in memory. This only occurs when 32-bit -; alignment of structure members is specified. -; -; The move is allowed to be odd byte aligned, because that's still faster -; than an odd byte aligned bit field instruction. -; -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=rm") - (zero_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o") - (match_operand:SI 2 "immediate_operand" "i") - (match_operand:SI 3 "immediate_operand" "i")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 32) - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[1], 0))" - "* -{ - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - return \"move%.l %1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=&d") - (zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do") - (match_operand:SI 2 "immediate_operand" "i") - (match_operand:SI 3 "immediate_operand" "i")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16) - && GET_CODE (operands[3]) == CONST_INT - && INTVAL (operands[3]) % INTVAL (operands[2]) == 0 - && (GET_CODE (operands[1]) == REG - || ! mode_dependent_address_p (XEXP (operands[1], 0)))" - "* -{ - cc_status.flags |= CC_NOT_NEGATIVE; - if (REG_P (operands[1])) - { - if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32) - return \"bfextu %1{%b3:%b2},%0\"; - } - else - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - output_asm_insn (\"clr%.l %0\", operands); - if (GET_CODE (operands[0]) == MEM) - operands[0] = adj_offsettable_operand (operands[0], - (32 - INTVAL (operands[1])) / 8); - if (INTVAL (operands[2]) == 8) - return \"move%.b %1,%0\"; - return \"move%.w %1,%0\"; -}") - -; -; Special case for 32-bit field in memory. This only occurs when 32-bit -; alignment of structure members is specified. -; -; The move is allowed to be odd byte aligned, because that's still faster -; than an odd byte aligned bit field instruction. -; -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=rm") - (sign_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o") - (match_operand:SI 2 "immediate_operand" "i") - (match_operand:SI 3 "immediate_operand" "i")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 32) - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[1], 0))" - "* -{ - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - return \"move%.l %1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=d") - (sign_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do") - (match_operand:SI 2 "immediate_operand" "i") - (match_operand:SI 3 "immediate_operand" "i")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16) - && GET_CODE (operands[3]) == CONST_INT - && INTVAL (operands[3]) % INTVAL (operands[2]) == 0 - && (GET_CODE (operands[1]) == REG - || ! mode_dependent_address_p (XEXP (operands[1], 0)))" - "* -{ - if (REG_P (operands[1])) - { - if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32) - return \"bfexts %1{%b3:%b2},%0\"; - } - else - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - if (INTVAL (operands[2]) == 8) - return \"move%.b %1,%0\;extb%.l %0\"; - return \"move%.w %1,%0\;ext%.l %0\"; -}") - -;; Bit field instructions, general cases. -;; "o,d" constraint causes a nonoffsettable memref to match the "o" -;; so that its address is reloaded. - -(define_insn "extv" - [(set (match_operand:SI 0 "general_operand" "=d,d") - (sign_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o,d") - (match_operand:SI 2 "general_operand" "di,di") - (match_operand:SI 3 "general_operand" "di,di")))] - "TARGET_68020 && TARGET_BITFIELD" - "bfexts %1{%b3:%b2},%0") - -(define_insn "extzv" - [(set (match_operand:SI 0 "general_operand" "=d,d") - (zero_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o,d") - (match_operand:SI 2 "general_operand" "di,di") - (match_operand:SI 3 "general_operand" "di,di")))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - cc_status.flags |= CC_NOT_NEGATIVE; - return \"bfextu %1{%b3:%b2},%0\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d") - (match_operand:SI 1 "general_operand" "di,di") - (match_operand:SI 2 "general_operand" "di,di")) - (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2)) - (match_operand 3 "immediate_operand" "i,i")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) == -1 - || (GET_CODE (operands[1]) == CONST_INT - && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))" - "* -{ - CC_STATUS_INIT; - return \"bfchg %0{%b2:%b1}\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d") - (match_operand:SI 1 "general_operand" "di,di") - (match_operand:SI 2 "general_operand" "di,di")) - (const_int 0))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - CC_STATUS_INIT; - return \"bfclr %0{%b2:%b1}\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d") - (match_operand:SI 1 "general_operand" "di,di") - (match_operand:SI 2 "general_operand" "di,di")) - (const_int -1))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - CC_STATUS_INIT; - return \"bfset %0{%b2:%b1}\"; -}") - -(define_insn "insv" - [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d") - (match_operand:SI 1 "general_operand" "di,di") - (match_operand:SI 2 "general_operand" "di,di")) - (match_operand:SI 3 "general_operand" "d,d"))] - "TARGET_68020 && TARGET_BITFIELD" - "bfins %3,%0{%b2:%b1}") - -;; Now recognize bit field insns that operate on registers -;; (or at least were intended to do so). - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=d") - (sign_extract:SI (match_operand:SI 1 "nonimmediate_operand" "d") - (match_operand:SI 2 "general_operand" "di") - (match_operand:SI 3 "general_operand" "di")))] - "TARGET_68020 && TARGET_BITFIELD" - "bfexts %1{%b3:%b2},%0") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=d") - (zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "d") - (match_operand:SI 2 "general_operand" "di") - (match_operand:SI 3 "general_operand" "di")))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - cc_status.flags |= CC_NOT_NEGATIVE; - return \"bfextu %1{%b3:%b2},%0\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d") - (match_operand:SI 1 "general_operand" "di") - (match_operand:SI 2 "general_operand" "di")) - (const_int 0))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - CC_STATUS_INIT; - return \"bfclr %0{%b2:%b1}\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d") - (match_operand:SI 1 "general_operand" "di") - (match_operand:SI 2 "general_operand" "di")) - (const_int -1))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - CC_STATUS_INIT; - return \"bfset %0{%b2:%b1}\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d") - (match_operand:SI 1 "general_operand" "di") - (match_operand:SI 2 "general_operand" "di")) - (match_operand:SI 3 "general_operand" "d"))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ -#if 0 - /* These special cases are now recognized by a specific pattern. */ - if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16) - return \"move%.w %3,%0\"; - if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8) - return \"move%.b %3,%0\"; -#endif - return \"bfins %3,%0{%b2:%b1}\"; -}") - -;; Special patterns for optimizing bit-field instructions. - -(define_insn "" - [(set (cc0) - (zero_extract:SI (match_operand:QI 0 "memory_operand" "o") - (match_operand:SI 1 "general_operand" "di") - (match_operand:SI 2 "general_operand" "di")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT" - "* -{ - if (operands[1] == const1_rtx - && GET_CODE (operands[2]) == CONST_INT) - { - int width = GET_CODE (operands[0]) == REG ? 31 : 7; - return output_btst (operands, - gen_rtx (CONST_INT, VOIDmode, - width - INTVAL (operands[2])), - operands[0], - insn, 1000); - /* Pass 1000 as SIGNPOS argument so that btst will - not think we are testing the sign bit for an `and' - and assume that nonzero implies a negative result. */ - } - if (INTVAL (operands[1]) != 32) - cc_status.flags = CC_NOT_NEGATIVE; - return \"bftst %0{%b2:%b1}\"; -}") - - -;;; now handle the register cases -(define_insn "" - [(set (cc0) - (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "d") - (match_operand:SI 1 "general_operand" "di") - (match_operand:SI 2 "general_operand" "di")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT" - "* -{ - if (operands[1] == const1_rtx - && GET_CODE (operands[2]) == CONST_INT) - { - int width = GET_CODE (operands[0]) == REG ? 31 : 7; - return output_btst (operands, - gen_rtx (CONST_INT, VOIDmode, - width - INTVAL (operands[2])), - operands[0], - insn, 1000); - /* Pass 1000 as SIGNPOS argument so that btst will - not think we are testing the sign bit for an `and' - and assume that nonzero implies a negative result. */ - } - if (INTVAL (operands[1]) != 32) - cc_status.flags = CC_NOT_NEGATIVE; - return \"bftst %0{%b2:%b1}\"; -}") - -(define_insn "seq" - [(set (match_operand:QI 0 "general_operand" "=d") - (eq:QI (cc0) (const_int 0)))] - "" - "* - cc_status = cc_prev_status; - OUTPUT_JUMP (\"seq %0\", \"fseq %0\", \"seq %0\"); -") - -(define_insn "sne" - [(set (match_operand:QI 0 "general_operand" "=d") - (ne:QI (cc0) (const_int 0)))] - "" - "* - cc_status = cc_prev_status; - OUTPUT_JUMP (\"sne %0\", \"fsne %0\", \"sne %0\"); -") - -(define_insn "sgt" - [(set (match_operand:QI 0 "general_operand" "=d") - (gt:QI (cc0) (const_int 0)))] - "" - "* - cc_status = cc_prev_status; - OUTPUT_JUMP (\"sgt %0\", \"fsgt %0\", 0); -") - -(define_insn "sgtu" - [(set (match_operand:QI 0 "general_operand" "=d") - (gtu:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - return \"shi %0\"; ") - -(define_insn "slt" - [(set (match_operand:QI 0 "general_operand" "=d") - (lt:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - OUTPUT_JUMP (\"slt %0\", \"fslt %0\", \"smi %0\"); ") - -(define_insn "sltu" - [(set (match_operand:QI 0 "general_operand" "=d") - (ltu:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - return \"scs %0\"; ") - -(define_insn "sge" - [(set (match_operand:QI 0 "general_operand" "=d") - (ge:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - OUTPUT_JUMP (\"sge %0\", \"fsge %0\", \"spl %0\"); ") - -(define_insn "sgeu" - [(set (match_operand:QI 0 "general_operand" "=d") - (geu:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - return \"scc %0\"; ") - -(define_insn "sle" - [(set (match_operand:QI 0 "general_operand" "=d") - (le:QI (cc0) (const_int 0)))] - "" - "* - cc_status = cc_prev_status; - OUTPUT_JUMP (\"sle %0\", \"fsle %0\", 0); -") - -(define_insn "sleu" - [(set (match_operand:QI 0 "general_operand" "=d") - (leu:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - return \"sls %0\"; ") - -;; Basic conditional jump instructions. - -(define_insn "beq" - [(set (pc) - (if_then_else (eq (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -{ -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbeq %l0\", \"fbeq %l0\", \"jbeq %l0\"); -#else - OUTPUT_JUMP (\"jeq %l0\", \"fjeq %l0\", \"jeq %l0\"); -#endif -}") - -(define_insn "bne" - [(set (pc) - (if_then_else (ne (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -{ -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbne %l0\", \"fbne %l0\", \"jbne %l0\"); -#else - OUTPUT_JUMP (\"jne %l0\", \"fjne %l0\", \"jne %l0\"); -#endif -}") - -(define_insn "bgt" - [(set (pc) - (if_then_else (gt (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbgt %l0\", \"fbgt %l0\", 0); -#else - OUTPUT_JUMP (\"jgt %l0\", \"fjgt %l0\", 0); -#endif -") - -(define_insn "bgtu" - [(set (pc) - (if_then_else (gtu (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - return \"jbhi %l0\"; -#else - return \"jhi %l0\"; -#endif -") - -(define_insn "blt" - [(set (pc) - (if_then_else (lt (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jblt %l0\", \"fblt %l0\", \"jbmi %l0\"); -#else - OUTPUT_JUMP (\"jlt %l0\", \"fjlt %l0\", \"jmi %l0\"); -#endif -") - -(define_insn "bltu" - [(set (pc) - (if_then_else (ltu (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - return \"jbcs %l0\"; -#else - return \"jcs %l0\"; -#endif -") - -(define_insn "bge" - [(set (pc) - (if_then_else (ge (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbge %l0\", \"fbge %l0\", \"jbpl %l0\"); -#else - OUTPUT_JUMP (\"jge %l0\", \"fjge %l0\", \"jpl %l0\"); -#endif -") - -(define_insn "bgeu" - [(set (pc) - (if_then_else (geu (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - return \"jbcc %l0\"; -#else - return \"jcc %l0\"; -#endif -") - -(define_insn "ble" - [(set (pc) - (if_then_else (le (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jble %l0\", \"fble %l0\", 0); -#else - OUTPUT_JUMP (\"jle %l0\", \"fjle %l0\", 0); -#endif -") - -(define_insn "bleu" - [(set (pc) - (if_then_else (leu (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - return \"jbls %l0\"; -#else - return \"jls %l0\"; -#endif -") - -;; Negated conditional jump instructions. - -(define_insn "" - [(set (pc) - (if_then_else (eq (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -{ -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbne %l0\", \"fbne %l0\", \"jbne %l0\"); -#else - OUTPUT_JUMP (\"jne %l0\", \"fjne %l0\", \"jne %l0\"); -#endif -}") - -(define_insn "" - [(set (pc) - (if_then_else (ne (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -{ -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbeq %l0\", \"fbeq %l0\", \"jbeq %l0\"); -#else - OUTPUT_JUMP (\"jeq %l0\", \"fjeq %l0\", \"jeq %l0\"); -#endif -}") - -(define_insn "" - [(set (pc) - (if_then_else (gt (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jble %l0\", \"fbngt %l0\", 0); -#else - OUTPUT_JUMP (\"jle %l0\", \"fjngt %l0\", 0); -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (gtu (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - return \"jbls %l0\"; -#else - return \"jls %l0\"; -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (lt (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbge %l0\", \"fbnlt %l0\", \"jbpl %l0\"); -#else - OUTPUT_JUMP (\"jge %l0\", \"fjnlt %l0\", \"jpl %l0\"); -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (ltu (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - return \"jbcc %l0\"; -#else - return \"jcc %l0\"; -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (ge (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jblt %l0\", \"fbnge %l0\", \"jbmi %l0\"); -#else - OUTPUT_JUMP (\"jlt %l0\", \"fjnge %l0\", \"jmi %l0\"); -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (geu (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - return \"jbcs %l0\"; -#else - return \"jcs %l0\"; -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (le (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbgt %l0\", \"fbnle %l0\", 0); -#else - OUTPUT_JUMP (\"jgt %l0\", \"fjnle %l0\", 0); -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (leu (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - return \"jbhi %l0\"; -#else - return \"jhi %l0\"; -#endif -") - -;; Unconditional and other jump instructions -(define_insn "jump" - [(set (pc) - (label_ref (match_operand 0 "" "")))] - "" - "* -#ifdef MOTOROLA - return \"jbra %l0\"; -#else - return \"jra %l0\"; -#endif -") - -;; We support two different ways of handling dispatch tables. -;; The NeXT uses absolute tables, and other machines use relative. -;; This define_expand can generate either kind. -(define_expand "tablejump" - [(parallel [(set (pc) (match_operand 0 "" "")) - (use (label_ref (match_operand 1 "" "")))])] - "" - " -{ -#ifdef CASE_VECTOR_PC_RELATIVE - operands[0] = gen_rtx (PLUS, SImode, pc_rtx, operands[0]); -#endif -}") - -;; Jump to variable address from dispatch table of absolute addresses. -(define_insn "" - [(set (pc) (match_operand:SI 0 "register_operand" "a")) - (use (label_ref (match_operand 1 "" "")))] - "" - "* -#ifdef MOTOROLA - return \"jmp (%0)\"; -#else - return \"jmp %0@\"; -#endif -") - -;; Jump to variable address from dispatch table of relative addresses. -(define_insn "" - [(set (pc) - (plus:SI (pc) (match_operand:HI 0 "register_operand" "r"))) - (use (label_ref (match_operand 1 "" "")))] - "" - "* -#ifdef ASM_RETURN_CASE_JUMP - ASM_RETURN_CASE_JUMP; -#else -#ifdef SGS -#ifdef ASM_OUTPUT_CASE_LABEL - return \"jmp 6(%%pc,%0.w)\"; -#else -#ifdef CRDS - return \"jmp 2(pc,%0.w)\"; -#else - return \"jmp 2(%%pc,%0.w)\"; -#endif /* end !CRDS */ -#endif -#else /* not SGS */ -#ifdef MOTOROLA - return \"jmp (2,pc,%0.w)\"; -#else - return \"jmp pc@(2,%0:w)\"; -#endif -#endif -#endif -") - -;; Decrement-and-branch insns. -(define_insn "" - [(set (pc) - (if_then_else - (ne (match_operand:HI 0 "general_operand" "+g") - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:HI (match_dup 0) - (const_int -1)))] - "" - "* -{ - CC_STATUS_INIT; - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\"; - if (GET_CODE (operands[0]) == MEM) - { -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - return \"sub%.w %#1,%0\;jbcc %l1\"; -#else - return \"subq%.w %#1,%0\;jbcc %l1\"; -#endif -#else /* not MOTOROLA */ - return \"subqw %#1,%0\;jcc %l1\"; -#endif - } -#ifdef MOTOROLA -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return \"sub%.w %#1,%0\;cmp%.w %0,%#-1\;jbne %l1\"; -#else - return \"subq%.w %#1,%0\;cmp%.w %0,%#-1\;jbne %l1\"; -#endif -#else /* not SGS_CMP_ORDER */ - return \"subq%.w %#1,%0\;cmp%.w %#-1,%0\;jbne %l1\"; -#endif -#else /* not MOTOROLA */ - return \"subqw %#1,%0\;cmpw %#-1,%0\;jne %l1\"; -#endif -}") - -(define_insn "" - [(set (pc) - (if_then_else - (ne (match_operand:SI 0 "general_operand" "+g") - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:SI (match_dup 0) - (const_int -1)))] - "" - "* -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;sub%.l %#1,%0\;jbcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"sub%.l %#1,%0\;jbcc %l1\"; -#else - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;subq%.l %#1,%0\;jbcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subq%.l %#1,%0\;jbcc %l1\"; -#endif /* NO_ADDSUB_Q */ -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return \"sub.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\"; -#else - return \"subq.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\"; -#endif -#else /* not SGS_CMP_ORDER */ - return \"subq.l %#1,%0\;cmp.l %#-1,%0\;jbne %l1\"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;subql %#1,%0\;jcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subql %#1,%0\;jcc %l1\"; - return \"subql %#1,%0\;cmpl %#-1,%0\;jne %l1\"; -#endif /* not MOTOROLA */ -}") - -;; Two dbra patterns that use REG_NOTES info generated by strength_reduce. - -(define_insn "" - [(set (pc) - (if_then_else - (ge (plus:HI (match_operand:HI 0 "general_operand" "+g") - (const_int -1)) - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:HI (match_dup 0) - (const_int -1)))] - "find_reg_note (insn, REG_NONNEG, 0)" - "* -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"sub%.w %#1,%0\;jbcc %l1\"; -#else - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subq%.w %#1,%0\;jbcc %l1\"; -#endif -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return \"sub.w %#1,%0\;cmp.w %0,%#-1\;jbne %l1\"; -#else - return \"subq.w %#1,%0\;cmp.w %0,%#-1\;jbne %l1\"; -#endif -#else /* not SGS_CMP_ORDER */ - return \"subq.w %#1,%0\;cmp.w %#-1,%0\;jbne %l1\"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subqw %#1,%0\;jcc %l1\"; - return \"subqw %#1,%0\;cmpw %#-1,%0\;jne %l1\"; -#endif /* not MOTOROLA */ -}") - -(define_insn "decrement_and_branch_until_zero" - [(set (pc) - (if_then_else - (ge (plus:SI (match_operand:SI 0 "general_operand" "+g") - (const_int -1)) - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:SI (match_dup 0) - (const_int -1)))] - "find_reg_note (insn, REG_NONNEG, 0)" - "* -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;sub%.l %#1,%0\;jbcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"sub%.l %#1,%0\;jbcc %l1\"; -#else - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;subq%.l %#1,%0\;jbcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subq%.l %#1,%0\;jbcc %l1\"; -#endif -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return \"sub.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\"; -#else - return \"subq.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\"; -#endif -#else /* not SGS_CMP_ORDER */ - return \"subq.l %#1,%0\;cmp.l %#-1,%0\;jbne %l1\"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;subql %#1,%0\;jcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subql %#1,%0\;jcc %l1\"; - return \"subql %#1,%0\;cmpl %#-1,%0\;jne %l1\"; -#endif /* not MOTOROLA */ -}") - - -;; For PIC calls, in order to be able to support -;; dynamic linker LAZY BINDING, all the procedure calls need to go -;; through the PLT (Procedure Linkage Table) section in PIC mode. -;; -;; When outputting MIT syntax (e.g. on Suns), we add a bogus extra -;; operand to the jbsr statement to indicate that this call should -;; go through the PLT (why? because this is the way that Sun does it). -;; -;; The svr4 m68k assembler recognizes this syntax: `bsr FUNC@PLTPC' and it -;; will create the correct relocation entry (R_68K_PLT32) for `FUNC', -;; that tells the linker editor to create an entry for `FUNC' in PLT -;; section at link time. However, all global objects reference are still -;; done by using `OBJ@GOT'. So, the goal here is to output the function -;; call operand as `FUNC@PLTPC', but output object operand as `OBJ@GOT'. -;; We need to have a way to differentiate these two different operands. -;; -;; The strategy I use here is to use SYMBOL_REF_FLAG to differentiate -;; these two different operands. The macro LEGITIMATE_PIC_OPERAND_P needs -;; to be changed to recognize function calls symbol_ref operand as a legal -;; PIC operand (by checking whether SYMBOL_REF_FLAG is set). This will -;; avoid the compiler to load this symbol_ref operand into a register. -;; Remember, the operand "foo@PLTPC" cannot be called via jsr directly -;; since the value is a PC relative offset, not a real address. -;; -;; All global objects are treated in the similar way as in SUN3. The only -;; difference is: on m68k svr4, the reference of such global object needs -;; to end with a suffix "@GOT" so the assembler and linker know to create -;; an entry for it in GOT (Global Offset Table) section. This is done in -;; m68k.c. - -;; Call subroutine with no return value. -(define_expand "call" - [(call (match_operand:QI 0 "memory_operand" "") - (match_operand:SI 1 "general_operand" ""))] - ;; Operand 1 not really used on the m68000. - - "" - " -{ - if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF) - SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1; -}") - -;; This is a normal call sequence. -(define_insn "" - [(call (match_operand:QI 0 "memory_operand" "o") - (match_operand:SI 1 "general_operand" "g"))] - ;; Operand 1 not really used on the m68000. - - "! flag_pic" - "* -#ifdef MOTOROLA - return \"jsr %0\"; -#else - return \"jbsr %0\"; -#endif -") - -;; This is a PIC call sequence. -(define_insn "" - [(call (match_operand:QI 0 "memory_operand" "o") - (match_operand:SI 1 "general_operand" "g"))] - ;; Operand 1 not really used on the m68000. - - "flag_pic" - "* - if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF) -#ifdef MOTOROLA - return \"bsr %0@PLTPC\"; -#else - return \"jbsr %0,a1\"; -#endif - return \"jsr %0\"; -") - -;; Call subroutine, returning value in operand 0 -;; (which must be a hard register). -;; See comments before "call" regarding PIC calls. -(define_expand "call_value" - [(set (match_operand 0 "" "") - (call (match_operand:QI 1 "memory_operand" "") - (match_operand:SI 2 "general_operand" "")))] - ;; Operand 2 not really used on the m68000. - "" - " -{ - if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF) - SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1; -}") - -;; This is a normal call_value -(define_insn "" - [(set (match_operand 0 "" "=rf") - (call (match_operand:QI 1 "memory_operand" "o") - (match_operand:SI 2 "general_operand" "g")))] - ;; Operand 2 not really used on the m68000. - "! flag_pic" - "* -#ifdef MOTOROLA - return \"jsr %1\"; -#else - return \"jbsr %1\"; -#endif -") - -;; This is a PIC call_value -(define_insn "" - [(set (match_operand 0 "" "=rf") - (call (match_operand:QI 1 "memory_operand" "o") - (match_operand:SI 2 "general_operand" "g")))] - ;; Operand 2 not really used on the m68000. - "flag_pic" - "* - if (GET_CODE (operands[1]) == MEM - && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF) -#ifdef MOTOROLA - return \"bsr %1@PLTPC\"; -#else - return \"jbsr %1,a1\"; -#endif - return \"jsr %1\"; -") - -;; Call subroutine returning any type. - -(define_expand "untyped_call" - [(parallel [(call (match_operand 0 "" "") - (const_int 0)) - (match_operand 1 "" "") - (match_operand 2 "" "")])] - "NEEDS_UNTYPED_CALL" - " -{ - int i; - - emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx)); - - for (i = 0; i < XVECLEN (operands[2], 0); i++) - { - rtx set = XVECEXP (operands[2], 0, i); - emit_move_insn (SET_DEST (set), SET_SRC (set)); - } - - /* The optimizer does not know that the call sets the function value - registers we stored in the result block. We avoid problems by - claiming that all hard registers are used and clobbered at this - point. */ - emit_insn (gen_blockage ()); - - DONE; -}") - -;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and -;; all of memory. This blocks insns from being moved across this point. - -(define_insn "blockage" - [(unspec_volatile [(const_int 0)] 0)] - "" - "") - -(define_insn "nop" - [(const_int 0)] - "" - "nop") - -(define_insn "probe" - [(reg:SI 15)] - "NEED_PROBE" - "* -{ - operands[0] = gen_rtx (PLUS, SImode, stack_pointer_rtx, - gen_rtx (CONST_INT, VOIDmode, NEED_PROBE)); - return \"tstl %a0\"; -}") - -;; Used for frameless functions which save no regs and allocate no locals. -(define_insn "return" - [(return)] - "USE_RETURN_INSN" - "* -{ - if (current_function_pops_args == 0) - return \"rts\"; - operands[0] = gen_rtx (CONST_INT, VOIDmode, current_function_pops_args); - return \"rtd %0\"; -}") - -(define_insn "indirect_jump" - [(set (pc) (match_operand:SI 0 "address_operand" "p"))] - "" - "jmp %a0") - -;; This should not be used unless the add/sub insns can't be. - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=a") - (match_operand:QI 1 "address_operand" "p"))] - "" - "lea %a1,%0") - -;; This is the first machine-dependent peephole optimization. -;; It is useful when a floating value is returned from a function call -;; and then is moved into an FP register. -;; But it is mainly intended to test the support for these optimizations. - -(define_peephole - [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4))) - (set (match_operand:DF 0 "register_operand" "=f") - (match_operand:DF 1 "register_operand" "ad"))] - "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])" - "* -{ - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn (\"move%.l %1,%@\", xoperands); - output_asm_insn (\"move%.l %1,%-\", operands); - return \"fmove%.d %+,%0\"; -} -") - -;; Optimize a stack-adjust followed by a push of an argument. -;; This is said to happen frequently with -msoft-float -;; when there are consecutive library calls. - -(define_peephole - [(set (reg:SI 15) (plus:SI (reg:SI 15) - (match_operand:SI 0 "immediate_operand" "n"))) - (set (match_operand:SF 1 "push_operand" "=m") - (match_operand:SF 2 "general_operand" "rmfF"))] - "GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) >= 4 - && ! reg_mentioned_p (stack_pointer_rtx, operands[2])" - "* -{ - if (INTVAL (operands[0]) > 4) - { - rtx xoperands[2]; - xoperands[0] = stack_pointer_rtx; - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4); -#ifndef NO_ADDSUB_Q - if (INTVAL (xoperands[1]) <= 8) - output_asm_insn (\"addq%.w %1,%0\", xoperands); - else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020) - { - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (xoperands[1]) - 8); - output_asm_insn (\"addq%.w %#8,%0\;addq%.w %1,%0\", xoperands); - } - else -#endif - if (INTVAL (xoperands[1]) <= 0x7FFF) - output_asm_insn (\"add%.w %1,%0\", xoperands); - else - output_asm_insn (\"add%.l %1,%0\", xoperands); - } - if (FP_REG_P (operands[2])) - return \"fmove%.s %2,%@\"; - return \"move%.l %2,%@\"; -}") - -;; Speed up stack adjust followed by a fullword fixedpoint push. - -(define_peephole - [(set (reg:SI 15) (plus:SI (reg:SI 15) - (match_operand:SI 0 "immediate_operand" "n"))) - (set (match_operand:SI 1 "push_operand" "=m") - (match_operand:SI 2 "general_operand" "g"))] - "GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) >= 4 - && ! reg_mentioned_p (stack_pointer_rtx, operands[2])" - "* -{ - if (INTVAL (operands[0]) > 4) - { - rtx xoperands[2]; - xoperands[0] = stack_pointer_rtx; - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4); -#ifndef NO_ADDSUB_Q - if (INTVAL (xoperands[1]) <= 8) - output_asm_insn (\"addq%.w %1,%0\", xoperands); - else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020) - { - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (xoperands[1]) - 8); - output_asm_insn (\"addq%.w %#8,%0\;addq%.w %1,%0\", xoperands); - } - else -#endif - if (INTVAL (xoperands[1]) <= 0x7FFF) - output_asm_insn (\"add%.w %1,%0\", xoperands); - else - output_asm_insn (\"add%.l %1,%0\", xoperands); - } - if (operands[2] == const0_rtx) - return \"clr%.l %@\"; - return \"move%.l %2,%@\"; -}") - -;; Speed up pushing a single byte but leaving four bytes of space. - -(define_peephole - [(set (mem:QI (pre_dec:SI (reg:SI 15))) - (match_operand:QI 1 "general_operand" "dami")) - (set (reg:SI 15) (minus:SI (reg:SI 15) (const_int 2)))] - "! reg_mentioned_p (stack_pointer_rtx, operands[1])" - "* -{ - rtx xoperands[4]; - - if (GET_CODE (operands[1]) == REG) - return \"move%.l %1,%-\"; - - xoperands[1] = operands[1]; - xoperands[2] - = gen_rtx (MEM, QImode, - gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, - gen_rtx (CONST_INT, VOIDmode, 3))); - xoperands[3] = stack_pointer_rtx; - output_asm_insn (\"subq%.w %#4,%3\;move%.b %1,%2\", xoperands); - return \"\"; -}") - -(define_peephole - [(set (match_operand:SI 0 "register_operand" "=d") - (const_int 0)) - (set (strict_low_part (subreg:HI (match_dup 0) 0)) - (match_operand:HI 1 "general_operand" "rmn"))] - "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])" - "* -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return \"clr%.w %0\"; - } - return \"move%.w %1,%0\"; -}") - -;; dbCC peepholes -;; -;; Turns -;; loop: -;; [ ... ] -;; jCC label ; abnormal loop termination -;; dbra dN, loop ; normal loop termination -;; -;; Into -;; loop: -;; [ ... ] -;; dbCC dN, loop -;; jCC label -;; -;; Which moves the jCC condition outside the inner loop for free. -;; -(define_peephole - [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p" - [(cc0) (const_int 0)]) - (label_ref (match_operand 2 "" "")) - (pc))) - (parallel - [(set (pc) - (if_then_else - (ge (plus:HI (match_operand:HI 0 "register_operand" "+d") - (const_int -1)) - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:HI (match_dup 0) - (const_int -1)))])] - "DATA_REG_P (operands[0])" - "* -{ - CC_STATUS_INIT; - output_dbcc_and_branch (operands); - return \"\"; -}") - -(define_peephole - [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p" - [(cc0) (const_int 0)]) - (label_ref (match_operand 2 "" "")) - (pc))) - (parallel - [(set (pc) - (if_then_else - (ge (plus:SI (match_operand:SI 0 "register_operand" "+d") - (const_int -1)) - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:SI (match_dup 0) - (const_int -1)))])] - "DATA_REG_P (operands[0])" - "* -{ - CC_STATUS_INIT; - output_dbcc_and_branch (operands); - return \"\"; -}") - - -;; FPA multiply and add. -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (plus:DF (mult:DF (match_operand:DF 1 "general_operand" "%x,dmF,y") - (match_operand:DF 2 "general_operand" "xH,y,y")) - (match_operand:DF 3 "general_operand" "xH,y,dmF")))] - "TARGET_FPA" - "@ - fpma%.d %1,%w2,%w3,%0 - fpma%.d %x1,%x2,%x3,%0 - fpma%.d %x1,%x2,%x3,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (plus:SF (mult:SF (match_operand:SF 1 "general_operand" "%x,ydmF,y") - (match_operand:SF 2 "general_operand" "xH,y,ydmF")) - (match_operand:SF 3 "general_operand" "xH,ydmF,ydmF")))] - "TARGET_FPA" - "@ - fpma%.s %1,%w2,%w3,%0 - fpma%.s %1,%2,%3,%0 - fpma%.s %1,%2,%3,%0") - -;; FPA Multiply and subtract -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (minus:DF (match_operand:DF 1 "general_operand" "xH,rmF,y") - (mult:DF (match_operand:DF 2 "general_operand" "%xH,y,y") - (match_operand:DF 3 "general_operand" "x,y,rmF"))))] - "TARGET_FPA" - "@ - fpms%.d %3,%w2,%w1,%0 - fpms%.d %x3,%2,%x1,%0 - fpms%.d %x3,%2,%x1,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (minus:SF (match_operand:SF 1 "general_operand" "xH,rmF,yrmF") - (mult:SF (match_operand:SF 2 "general_operand" "%xH,rmF,y") - (match_operand:SF 3 "general_operand" "x,y,yrmF"))))] - "TARGET_FPA" - "@ - fpms%.s %3,%w2,%w1,%0 - fpms%.s %3,%2,%1,%0 - fpms%.s %3,%2,%1,%0") - -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (minus:DF (mult:DF (match_operand:DF 1 "general_operand" "%xH,y,y") - (match_operand:DF 2 "general_operand" "x,y,rmF")) - (match_operand:DF 3 "general_operand" "xH,rmF,y")))] - "TARGET_FPA" - "@ - fpmr%.d %2,%w1,%w3,%0 - fpmr%.d %x2,%1,%x3,%0 - fpmr%.d %x2,%1,%x3,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (minus:SF (mult:SF (match_operand:SF 1 "general_operand" "%xH,rmF,y") - (match_operand:SF 2 "general_operand" "x,y,yrmF")) - (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))] - "TARGET_FPA" - "@ - fpmr%.s %2,%w1,%w3,%0 - fpmr%.s %x2,%1,%x3,%0 - fpmr%.s %x2,%1,%x3,%0") - -;; FPA Add and multiply -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (mult:DF (plus:DF (match_operand:DF 1 "general_operand" "%xH,y,y") - (match_operand:DF 2 "general_operand" "x,y,rmF")) - (match_operand:DF 3 "general_operand" "xH,rmF,y")))] - "TARGET_FPA" - "@ - fpam%.d %2,%w1,%w3,%0 - fpam%.d %x2,%1,%x3,%0 - fpam%.d %x2,%1,%x3,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (mult:SF (plus:SF (match_operand:SF 1 "general_operand" "%xH,rmF,y") - (match_operand:SF 2 "general_operand" "x,y,yrmF")) - (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))] - "TARGET_FPA" - "@ - fpam%.s %2,%w1,%w3,%0 - fpam%.s %x2,%1,%x3,%0 - fpam%.s %x2,%1,%x3,%0") - -;;FPA Subtract and multiply -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (mult:DF (minus:DF (match_operand:DF 1 "general_operand" "xH,y,y") - (match_operand:DF 2 "general_operand" "x,y,rmF")) - (match_operand:DF 3 "general_operand" "xH,rmF,y")))] - "TARGET_FPA" - "@ - fpsm%.d %2,%w1,%w3,%0 - fpsm%.d %x2,%1,%x3,%0 - fpsm%.d %x2,%1,%x3,%0") - -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (mult:DF (match_operand:DF 1 "general_operand" "xH,rmF,y") - (minus:DF (match_operand:DF 2 "general_operand" "xH,y,y") - (match_operand:DF 3 "general_operand" "x,y,rmF"))))] - "TARGET_FPA" - "@ - fpsm%.d %3,%w2,%w1,%0 - fpsm%.d %x3,%2,%x1,%0 - fpsm%.d %x3,%2,%x1,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (mult:SF (minus:SF (match_operand:SF 1 "general_operand" "xH,rmF,y") - (match_operand:SF 2 "general_operand" "x,y,yrmF")) - (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))] - "TARGET_FPA" - "@ - fpsm%.s %2,%w1,%w3,%0 - fpsm%.s %x2,%1,%x3,%0 - fpsm%.s %x2,%1,%x3,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (mult:SF (match_operand:SF 1 "general_operand" "xH,rmF,yrmF") - (minus:SF (match_operand:SF 2 "general_operand" "xH,rmF,y") - (match_operand:SF 3 "general_operand" "x,y,yrmF"))))] - "TARGET_FPA" - "@ - fpsm%.s %3,%w2,%w1,%0 - fpsm%.s %x3,%2,%x1,%0 - fpsm%.s %x3,%2,%x1,%0") - -(define_insn "tstxf" - [(set (cc0) - (match_operand:XF 0 "nonimmediate_operand" "fm"))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; - return \"ftst%.x %0\"; -}") - - -(define_expand "cmpxf" - [(set (cc0) - (compare (match_operand:XF 0 "general_operand" "f,mG") - (match_operand:XF 1 "general_operand" "fmG,f")))] - "TARGET_68881" - " -{ - if (CONSTANT_P (operands[0])) - operands[0] = force_const_mem (XFmode, operands[0]); - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); -}") - -(define_insn "" - [(set (cc0) - (compare (match_operand:XF 0 "nonimmediate_operand" "f,mG") - (match_operand:XF 1 "nonimmediate_operand" "fmG,f")))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return \"fcmp%.x %0,%1\"; - else - return \"fcmp%.x %0,%f1\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.x %1,%f0\"; -#else - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return \"fcmp%.x %1,%0\"; - else - return \"fcmp%.x %f1,%0\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.x %f0,%1\"; -#endif -}") - -(define_insn "extendsfxf2" - [(set (match_operand:XF 0 "general_operand" "=fm,f") - (float_extend:XF (match_operand:SF 1 "general_operand" "f,m")))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return \"\"; - } - return \"f%$move%.x %1,%0\"; - } - if (FP_REG_P (operands[0])) - return \"f%$move%.s %f1,%0\"; - return \"fmove%.x %f1,%0\"; -}") - - -(define_insn "extenddfxf2" - [(set (match_operand:XF 0 "general_operand" "=fm,f") - (float_extend:XF - (match_operand:DF 1 "general_operand" "f,m")))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return \"\"; - } - return \"fmove%.x %1,%0\"; - } - if (FP_REG_P (operands[0])) - return \"f%&move%.d %f1,%0\"; - return \"fmove%.x %f1,%0\"; -}") - -(define_insn "truncxfdf2" - [(set (match_operand:DF 0 "general_operand" "=m,!r") - (float_truncate:DF - (match_operand:XF 1 "general_operand" "f,f")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[0])) - { - output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - return \"fmove%.d %f1,%0\"; -}") - -(define_insn "truncxfsf2" - [(set (match_operand:SF 0 "general_operand" "=dm") - (float_truncate:SF - (match_operand:XF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.s %f1,%0") - -(define_insn "floatsixf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (float:XF (match_operand:SI 1 "general_operand" "dmi")))] - "TARGET_68881" - "fmove%.l %1,%0") - -(define_insn "floathixf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (float:XF (match_operand:HI 1 "general_operand" "dmn")))] - "TARGET_68881" - "fmove%.w %1,%0") - -(define_insn "floatqixf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (float:XF (match_operand:QI 1 "general_operand" "dmn")))] - "TARGET_68881" - "fmove%.b %1,%0") - -(define_insn "ftruncxf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (fix:XF (match_operand:XF 1 "general_operand" "fFm")))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[1])) - return \"fintrz%.x %f1,%0\"; - return \"fintrz%.x %f1,%0\"; -}") - -(define_insn "fixxfqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (fix:QI (match_operand:XF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.b %1,%0") - -(define_insn "fixxfhi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (fix:HI (match_operand:XF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.w %1,%0") - -(define_insn "fixxfsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (fix:SI (match_operand:XF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.l %1,%0") - -(define_expand "addxf3" - [(set (match_operand:XF 0 "general_operand" "") - (plus:XF (match_operand:XF 1 "general_operand" "") - (match_operand:XF 2 "general_operand" "")))] - "TARGET_68881" - " -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -}") - -(define_insn "" - [(set (match_operand:XF 0 "general_operand" "=f") - (plus:XF (match_operand:XF 1 "nonimmediate_operand" "%0") - (match_operand:XF 2 "nonimmediate_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"fadd%.x %2,%0\"; - return \"fadd%.x %f2,%0\"; -}") - -(define_expand "subxf3" - [(set (match_operand:XF 0 "general_operand" "") - (minus:XF (match_operand:XF 1 "general_operand" "") - (match_operand:XF 2 "general_operand" "")))] - "TARGET_68881" - " -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -}") - -(define_insn "" - [(set (match_operand:XF 0 "general_operand" "=f") - (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0") - (match_operand:XF 2 "nonimmediate_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"fsub%.x %2,%0\"; - return \"fsub%.x %f2,%0\"; -}") - -(define_expand "mulxf3" - [(set (match_operand:XF 0 "general_operand" "") - (mult:XF (match_operand:XF 1 "general_operand" "") - (match_operand:XF 2 "general_operand" "")))] - "TARGET_68881" - " -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -}") - -(define_insn "" - [(set (match_operand:XF 0 "general_operand" "=f") - (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0") - (match_operand:XF 2 "nonimmediate_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"fmul%.x %2,%0\"; - return \"fmul%.x %f2,%0\"; -}") - -(define_expand "divxf3" - [(set (match_operand:XF 0 "general_operand" "") - (div:XF (match_operand:XF 1 "general_operand" "") - (match_operand:XF 2 "general_operand" "")))] - "TARGET_68881" - " -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -}") - -(define_insn "" - [(set (match_operand:XF 0 "general_operand" "=f") - (div:XF (match_operand:XF 1 "nonimmediate_operand" "0") - (match_operand:XF 2 "nonimmediate_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"fdiv%.x %2,%0\"; - return \"fdiv%.x %f2,%0\"; -}") - -(define_insn "negxf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (neg:XF (match_operand:XF 1 "nonimmediate_operand" "fmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"fneg%.x %1,%0\"; - return \"fneg%.x %f1,%0\"; -}") - -(define_insn "absxf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (abs:XF (match_operand:XF 1 "nonimmediate_operand" "fmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"fabs%.x %1,%0\"; - return \"fabs%.x %f1,%0\"; -}") - -(define_insn "sqrtxf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (sqrt:XF (match_operand:DF 1 "nonimmediate_operand" "fm")))] - "TARGET_68881" - "* -{ - return \"fsqrt%.x %1,%0\"; -}") diff --git a/gnu/usr.bin/gcc2/arch/da30/tconfig.h b/gnu/usr.bin/gcc2/arch/da30/tconfig.h deleted file mode 100644 index 9f0d01e0c0c1..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/tconfig.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Configuration for GNU C-compiler for Motorola 68000 family. - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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. - -GNU CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: tconfig.h,v 1.1 1993/11/23 06:09:38 paulus Exp $ -*/ - - -/* #defines that need visibility everywhere. */ -#define FALSE 0 -#define TRUE 1 - -/* This describes the machine the compiler is hosted on. */ -#define HOST_BITS_PER_CHAR 8 -#define HOST_BITS_PER_SHORT 16 -#define HOST_BITS_PER_INT 32 -#define HOST_BITS_PER_LONG 32 -#define HOST_BITS_PER_LONGLONG 64 - -#define HOST_WORDS_BIG_ENDIAN - -/* target machine dependencies. - tm.h is a symbolic link to the actual target specific file. */ -#include "tm.h" - -/* Arguments to use with `exit'. */ -#define SUCCESS_EXIT_CODE 0 -#define FATAL_EXIT_CODE 33 - -/* If compiled with GNU C, use the built-in alloca */ -#ifdef __GNUC__ -/* Use an arg in this macro because that's what some other - system does--let's avoid conflict. */ -#define alloca(x) __builtin_alloca(x) -#endif diff --git a/gnu/usr.bin/gcc2/arch/da30/tm.h b/gnu/usr.bin/gcc2/arch/da30/tm.h deleted file mode 100644 index 12942006e14e..000000000000 --- a/gnu/usr.bin/gcc2/arch/da30/tm.h +++ /dev/null @@ -1,92 +0,0 @@ -/* $Id: tm.h,v 1.1 1993/11/23 06:09:42 paulus Exp $ */ - -#include -#include "da30/m68k.h" - -/* See m68k.h. 7 means 68020 with 68881. */ - -#define TARGET_DEFAULT 7 - -/* Define __HAVE_68881__ in preprocessor, unless -msoft-float is specified. - This will control the use of inline 68881 insns in certain macros. */ - -#define CPP_SPEC "%{!msoft-float:-D__HAVE_68881__ -D__HAVE_FPU__} %{posix:-D_POSIX_SOURCE}" - -/* Names to predefine in the preprocessor for this target machine. */ - -#define CPP_PREDEFINES "-Dmc68000 -Dmc68020 -Dunix -D__BSD_NET2__ -D__NetBSD__ -Dda30" - -/* Specify -k to assembler for PIC code generation. */ - -#define ASM_SPEC "%{fpic:-k} %{fPIC:-k}" - -/* Support -static, -symbolic and -shared options (at least minimally). - Also use -dp when doing dynamic linking. Don't include a startup - file when linking a shared library. */ - -#define LINK_SPEC \ - "%{static:-Bstatic} %{shared:-Bshareable} %{symbolic:-Bsymbolic} \ - %{!static:%{!shared:-dp}}" - -#define STARTFILE_SPEC \ - "%{!shared:%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}" - -/* No more libg.a; no libraries if making shared object */ - -#define LIB_SPEC "%{!shared:%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}" - -/* Make gcc agree with */ - -#undef WCHAR_TYPE -#define WCHAR_TYPE "short unsigned int" -#define WCHAR_UNSIGNED 1 -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE 16 - -/* NetBSD does have atexit. */ - -#define HAVE_ATEXIT - -/* Every structure or union's size must be a multiple of 2 bytes. */ - -#define STRUCTURE_SIZE_BOUNDARY 16 - -/* This is BSD, so it wants DBX format. */ - -#define DBX_DEBUGGING_INFO - -/* Do not break .stabs pseudos into continuations. */ - -#define DBX_CONTIN_LENGTH 0 - -/* This is the char to use for continuation (in case we need to turn - continuation back on). */ - -#define DBX_CONTIN_CHAR '?' - -/* Don't use the `xsfoo;' construct in DBX output; this system - doesn't support it. */ - -#define DBX_NO_XREFS - -/* Don't default to pcc-struct-return, because gcc is the only compiler, and - we want to retain compatibility with older gcc versions. */ -#define DEFAULT_PCC_STRUCT_RETURN 0 - -/* - * Some imports from svr4.h in support of shared libraries. - * Currently, we need the DECLARE_OBJECT_SIZE stuff. - */ - -#define SIZE_ASM_OP ".size" - -#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ - do { \ - if (!flag_inhibit_size_directive) \ - { \ - fprintf (FILE, "\t%s ", SIZE_ASM_OP); \ - assemble_name (FILE, NAME); \ - fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (decl))); \ - } \ - ASM_OUTPUT_LABEL(FILE, NAME); \ - } while (0) diff --git a/gnu/usr.bin/gcc2/arch/hp300/insn-codes.h b/gnu/usr.bin/gcc2/arch/hp300/insn-codes.h deleted file mode 100644 index 35b48afb5612..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/insn-codes.h +++ /dev/null @@ -1,184 +0,0 @@ -/* Generated automatically by the program `gencodes' -from the machine description file `md'. */ - -#ifndef MAX_INSN_CODE - -enum insn_code { - CODE_FOR_tstsi = 2, - CODE_FOR_tsthi = 3, - CODE_FOR_tstqi = 4, - CODE_FOR_tstsf = 5, - CODE_FOR_tstsf_fpa = 6, - CODE_FOR_tstdf = 8, - CODE_FOR_tstdf_fpa = 9, - CODE_FOR_cmpsi = 11, - CODE_FOR_cmphi = 12, - CODE_FOR_cmpqi = 13, - CODE_FOR_cmpdf = 14, - CODE_FOR_cmpdf_fpa = 15, - CODE_FOR_cmpsf = 17, - CODE_FOR_cmpsf_fpa = 18, - CODE_FOR_movsi = 28, - CODE_FOR_movhi = 30, - CODE_FOR_movstricthi = 31, - CODE_FOR_movqi = 32, - CODE_FOR_movstrictqi = 33, - CODE_FOR_movsf = 34, - CODE_FOR_movdf = 35, - CODE_FOR_movxf = 36, - CODE_FOR_movdi = 39, - CODE_FOR_pushasi = 40, - CODE_FOR_truncsiqi2 = 41, - CODE_FOR_trunchiqi2 = 42, - CODE_FOR_truncsihi2 = 43, - CODE_FOR_zero_extendhisi2 = 44, - CODE_FOR_zero_extendqihi2 = 45, - CODE_FOR_zero_extendqisi2 = 46, - CODE_FOR_extendhisi2 = 50, - CODE_FOR_extendqihi2 = 51, - CODE_FOR_extendqisi2 = 52, - CODE_FOR_extendsfdf2 = 53, - CODE_FOR_truncdfsf2 = 56, - CODE_FOR_floatsisf2 = 60, - CODE_FOR_floatsidf2 = 63, - CODE_FOR_floathisf2 = 66, - CODE_FOR_floathidf2 = 67, - CODE_FOR_floatqisf2 = 68, - CODE_FOR_floatqidf2 = 69, - CODE_FOR_fix_truncdfsi2 = 70, - CODE_FOR_fix_truncdfhi2 = 71, - CODE_FOR_fix_truncdfqi2 = 72, - CODE_FOR_ftruncdf2 = 73, - CODE_FOR_ftruncsf2 = 74, - CODE_FOR_fixsfqi2 = 75, - CODE_FOR_fixsfhi2 = 76, - CODE_FOR_fixsfsi2 = 77, - CODE_FOR_fixdfqi2 = 78, - CODE_FOR_fixdfhi2 = 79, - CODE_FOR_fixdfsi2 = 80, - CODE_FOR_addsi3 = 83, - CODE_FOR_addhi3 = 85, - CODE_FOR_addqi3 = 88, - CODE_FOR_adddf3 = 91, - CODE_FOR_addsf3 = 94, - CODE_FOR_subsi3 = 97, - CODE_FOR_subhi3 = 99, - CODE_FOR_subqi3 = 101, - CODE_FOR_subdf3 = 103, - CODE_FOR_subsf3 = 106, - CODE_FOR_mulhi3 = 109, - CODE_FOR_mulhisi3 = 110, - CODE_FOR_mulsi3 = 112, - CODE_FOR_umulhisi3 = 113, - CODE_FOR_umulsidi3 = 115, - CODE_FOR_mulsidi3 = 118, - CODE_FOR_muldf3 = 121, - CODE_FOR_mulsf3 = 124, - CODE_FOR_divhi3 = 127, - CODE_FOR_divhisi3 = 128, - CODE_FOR_udivhi3 = 130, - CODE_FOR_udivhisi3 = 131, - CODE_FOR_divdf3 = 133, - CODE_FOR_divsf3 = 136, - CODE_FOR_modhi3 = 139, - CODE_FOR_modhisi3 = 140, - CODE_FOR_umodhi3 = 142, - CODE_FOR_umodhisi3 = 143, - CODE_FOR_divmodsi4 = 145, - CODE_FOR_udivmodsi4 = 146, - CODE_FOR_andsi3 = 147, - CODE_FOR_andhi3 = 148, - CODE_FOR_andqi3 = 151, - CODE_FOR_iorsi3 = 154, - CODE_FOR_iorhi3 = 155, - CODE_FOR_iorqi3 = 158, - CODE_FOR_xorsi3 = 161, - CODE_FOR_xorhi3 = 162, - CODE_FOR_xorqi3 = 165, - CODE_FOR_negsi2 = 168, - CODE_FOR_neghi2 = 169, - CODE_FOR_negqi2 = 171, - CODE_FOR_negsf2 = 173, - CODE_FOR_negdf2 = 176, - CODE_FOR_sqrtdf2 = 179, - CODE_FOR_abssf2 = 180, - CODE_FOR_absdf2 = 183, - CODE_FOR_one_cmplsi2 = 186, - CODE_FOR_one_cmplhi2 = 187, - CODE_FOR_one_cmplqi2 = 189, - CODE_FOR_ashlsi3 = 193, - CODE_FOR_ashlhi3 = 194, - CODE_FOR_ashlqi3 = 196, - CODE_FOR_ashrsi3 = 200, - CODE_FOR_ashrhi3 = 201, - CODE_FOR_ashrqi3 = 203, - CODE_FOR_lshlsi3 = 207, - CODE_FOR_lshlhi3 = 208, - CODE_FOR_lshlqi3 = 210, - CODE_FOR_lshrsi3 = 214, - CODE_FOR_lshrhi3 = 215, - CODE_FOR_lshrqi3 = 217, - CODE_FOR_rotlsi3 = 219, - CODE_FOR_rotlhi3 = 220, - CODE_FOR_rotlqi3 = 222, - CODE_FOR_rotrsi3 = 224, - CODE_FOR_rotrhi3 = 225, - CODE_FOR_rotrqi3 = 227, - CODE_FOR_extv = 235, - CODE_FOR_extzv = 236, - CODE_FOR_insv = 240, - CODE_FOR_seq = 248, - CODE_FOR_sne = 249, - CODE_FOR_sgt = 250, - CODE_FOR_sgtu = 251, - CODE_FOR_slt = 252, - CODE_FOR_sltu = 253, - CODE_FOR_sge = 254, - CODE_FOR_sgeu = 255, - CODE_FOR_sle = 256, - CODE_FOR_sleu = 257, - CODE_FOR_beq = 258, - CODE_FOR_bne = 259, - CODE_FOR_bgt = 260, - CODE_FOR_bgtu = 261, - CODE_FOR_blt = 262, - CODE_FOR_bltu = 263, - CODE_FOR_bge = 264, - CODE_FOR_bgeu = 265, - CODE_FOR_ble = 266, - CODE_FOR_bleu = 267, - CODE_FOR_jump = 278, - CODE_FOR_tablejump = 279, - CODE_FOR_decrement_and_branch_until_zero = 285, - CODE_FOR_call = 286, - CODE_FOR_call_value = 289, - CODE_FOR_untyped_call = 292, - CODE_FOR_blockage = 293, - CODE_FOR_nop = 294, - CODE_FOR_probe = 295, - CODE_FOR_return = 296, - CODE_FOR_indirect_jump = 297, - CODE_FOR_tstxf = 318, - CODE_FOR_cmpxf = 319, - CODE_FOR_extendsfxf2 = 321, - CODE_FOR_extenddfxf2 = 322, - CODE_FOR_truncxfdf2 = 323, - CODE_FOR_truncxfsf2 = 324, - CODE_FOR_floatsixf2 = 325, - CODE_FOR_floathixf2 = 326, - CODE_FOR_floatqixf2 = 327, - CODE_FOR_ftruncxf2 = 328, - CODE_FOR_fixxfqi2 = 329, - CODE_FOR_fixxfhi2 = 330, - CODE_FOR_fixxfsi2 = 331, - CODE_FOR_addxf3 = 332, - CODE_FOR_subxf3 = 334, - CODE_FOR_mulxf3 = 336, - CODE_FOR_divxf3 = 338, - CODE_FOR_negxf2 = 340, - CODE_FOR_absxf2 = 341, - CODE_FOR_sqrtxf2 = 342, - CODE_FOR_nothing }; - -#define MAX_INSN_CODE ((int) CODE_FOR_nothing) -#endif /* MAX_INSN_CODE */ diff --git a/gnu/usr.bin/gcc2/arch/hp300/insn-config.h b/gnu/usr.bin/gcc2/arch/hp300/insn-config.h deleted file mode 100644 index 7dba8866f62f..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/insn-config.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Generated automatically by the program `genconfig' -from the machine description file `md'. */ - - -#define MAX_RECOG_OPERANDS 10 - -#define MAX_DUP_OPERANDS 3 -#ifndef MAX_INSNS_PER_SPLIT -#define MAX_INSNS_PER_SPLIT 1 -#endif -#define REGISTER_CONSTRAINTS -#define HAVE_cc0 diff --git a/gnu/usr.bin/gcc2/arch/hp300/insn-emit.c b/gnu/usr.bin/gcc2/arch/hp300/insn-emit.c deleted file mode 100644 index afc4f2a5f2bc..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/insn-emit.c +++ /dev/null @@ -1,1907 +0,0 @@ -/* Generated automatically by the program `genemit' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "expr.h" -#include "real.h" -#include "output.h" -#include "insn-config.h" - -#include "insn-flags.h" - -#include "insn-codes.h" - -extern char *insn_operand_constraint[][MAX_RECOG_OPERANDS]; - -extern rtx recog_operand[]; -#define operands emit_operand - -#define FAIL goto _fail - -#define DONE goto _done - -rtx -gen_tstsi (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tsthi (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tstqi (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tstsf (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_FPA) - { - emit_insn (gen_tstsf_fpa (operands[0])); - DONE; - } -} - operand0 = operands[0]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, operand0)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tstsf_fpa (operand0) - rtx operand0; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_tstdf (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_FPA) - { - emit_insn (gen_tstsf_fpa (operands[0])); - DONE; - } -} - operand0 = operands[0]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, operand0)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tstdf_fpa (operand0) - rtx operand0; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_cmpsi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmphi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmpqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmpdf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (TARGET_FPA) - { - emit_insn (gen_cmpdf_fpa (operands[0], operands[1])); - DONE; - } -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpdf_fpa (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_cmpsf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (TARGET_FPA) - { - emit_insn (gen_cmpsf_fpa (operands[0], operands[1])); - DONE; - } -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpsf_fpa (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_movsi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (flag_pic && symbolic_operand (operands[1], SImode)) - { - /* The source is an address which requires PIC relocation. - Call legitimize_pic_address with the source, mode, and a relocation - register (a new pseudo, or the final destination if reload_in_progress - is set). Then fall through normally */ - extern rtx legitimize_pic_address(); - rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode); - operands[1] = legitimize_pic_address (operands[1], SImode, temp); - } -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_movhi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movstricthi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand0), operand1); -} - -rtx -gen_movqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movstrictqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand0), operand1); -} - -rtx -gen_movsf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movdf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movxf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (CONSTANT_P (operands[1])) - { - operands[1] = force_const_mem (XFmode, operands[1]); - if (! memory_address_p (XFmode, XEXP (operands[1], 0)) - && ! reload_in_progress) - operands[1] = change_address (operands[1], XFmode, - XEXP (operands[1], 0)); - } -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_movdi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_pushasi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_truncsiqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, QImode, operand1)); -} - -rtx -gen_trunchiqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, QImode, operand1)); -} - -rtx -gen_truncsihi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, HImode, operand1)); -} - -rtx -gen_zero_extendhisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, HImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, HImode, operands[0], 0); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, const0_rtx)); - emit_insn (gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand2), operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_zero_extendqihi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, const0_rtx)); - emit_insn (gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand2), operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_zero_extendqisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, const0_rtx)); - emit_insn (gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand2), operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_extendhisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, SImode, operand1)); -} - -rtx -gen_extendqihi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, HImode, operand1)); -} - -rtx -gen_extendqisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, SImode, operand1)); -} - -rtx -gen_extendsfdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_EXTEND, DFmode, operand1)); -} - -rtx -gen_truncdfsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_TRUNCATE, SFmode, operand1)); -} - -rtx -gen_floatsisf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, SFmode, operand1)); -} - -rtx -gen_floatsidf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, DFmode, operand1)); -} - -rtx -gen_floathisf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, SFmode, operand1)); -} - -rtx -gen_floathidf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, DFmode, operand1)); -} - -rtx -gen_floatqisf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, SFmode, operand1)); -} - -rtx -gen_floatqidf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, DFmode, operand1)); -} - -rtx -gen_fix_truncdfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, gen_rtx (FIX, DFmode, operand1))), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_fix_truncdfhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, HImode, gen_rtx (FIX, DFmode, operand1))), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_fix_truncdfqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, QImode, gen_rtx (FIX, DFmode, operand1))), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)))); -} - -rtx -gen_ftruncdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, DFmode, operand1)); -} - -rtx -gen_ftruncsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SFmode, operand1)); -} - -rtx -gen_fixsfqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, QImode, operand1)); -} - -rtx -gen_fixsfhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, HImode, operand1)); -} - -rtx -gen_fixsfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, operand1)); -} - -rtx -gen_fixdfqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, QImode, operand1)); -} - -rtx -gen_fixdfhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, HImode, operand1)); -} - -rtx -gen_fixdfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, operand1)); -} - -rtx -gen_addsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SImode, operand1, operand2)); -} - -rtx -gen_addhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, HImode, operand1, operand2)); -} - -rtx -gen_addqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, QImode, operand1, operand2)); -} - -rtx -gen_adddf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, DFmode, operand1, operand2)); -} - -rtx -gen_addsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SFmode, operand1, operand2)); -} - -rtx -gen_subsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, SImode, operand1, operand2)); -} - -rtx -gen_subhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, HImode, operand1, operand2)); -} - -rtx -gen_subqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, QImode, operand1, operand2)); -} - -rtx -gen_subdf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, DFmode, operand1, operand2)); -} - -rtx -gen_subsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, SFmode, operand1, operand2)); -} - -rtx -gen_mulhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, HImode, operand1, operand2)); -} - -rtx -gen_mulhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SImode, gen_rtx (SIGN_EXTEND, SImode, operand1), gen_rtx (SIGN_EXTEND, SImode, operand2))); -} - -rtx -gen_mulsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SImode, operand1, operand2)); -} - -rtx -gen_umulhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SImode, gen_rtx (ZERO_EXTEND, SImode, operand1), gen_rtx (ZERO_EXTEND, SImode, operand2))); -} - -rtx -gen_umulsidi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, gen_rtx (SUBREG, SImode, operand0, 1), gen_rtx (MULT, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, gen_rtx (SUBREG, SImode, operand0, 0), gen_rtx (TRUNCATE, SImode, gen_rtx (LSHIFTRT, DImode, gen_rtx (MULT, DImode, gen_rtx (ZERO_EXTEND, DImode, operand1), gen_rtx (ZERO_EXTEND, DImode, operand2)), GEN_INT (32)))))); -} - -rtx -gen_mulsidi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, gen_rtx (SUBREG, SImode, operand0, 1), gen_rtx (MULT, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, gen_rtx (SUBREG, SImode, operand0, 0), gen_rtx (TRUNCATE, SImode, gen_rtx (ASHIFT, DImode, gen_rtx (MULT, DImode, gen_rtx (SIGN_EXTEND, DImode, operand1), gen_rtx (SIGN_EXTEND, DImode, operand2)), GEN_INT (32)))))); -} - -rtx -gen_muldf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, DFmode, operand1, operand2)); -} - -rtx -gen_mulsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SFmode, operand1, operand2)); -} - -rtx -gen_divhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, HImode, operand1, operand2)); -} - -rtx -gen_divhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, HImode, gen_rtx (DIV, SImode, operand1, gen_rtx (SIGN_EXTEND, SImode, operand2)))); -} - -rtx -gen_udivhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UDIV, HImode, operand1, operand2)); -} - -rtx -gen_udivhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, HImode, gen_rtx (UDIV, SImode, operand1, gen_rtx (ZERO_EXTEND, SImode, operand2)))); -} - -rtx -gen_divdf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, DFmode, operand1, operand2)); -} - -rtx -gen_divsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, SFmode, operand1, operand2)); -} - -rtx -gen_modhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MOD, HImode, operand1, operand2)); -} - -rtx -gen_modhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, HImode, gen_rtx (MOD, SImode, operand1, gen_rtx (SIGN_EXTEND, SImode, operand2)))); -} - -rtx -gen_umodhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UMOD, HImode, operand1, operand2)); -} - -rtx -gen_umodhisi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (TRUNCATE, HImode, gen_rtx (UMOD, SImode, operand1, gen_rtx (ZERO_EXTEND, SImode, operand2)))); -} - -rtx -gen_divmodsi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (MOD, SImode, operand1, operand2)))); -} - -rtx -gen_udivmodsi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (UDIV, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (UMOD, SImode, operand1, operand2)))); -} - -rtx -gen_andsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, SImode, operand1, operand2)); -} - -rtx -gen_andhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, HImode, operand1, operand2)); -} - -rtx -gen_andqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, QImode, operand1, operand2)); -} - -rtx -gen_iorsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, SImode, operand1, operand2)); -} - -rtx -gen_iorhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, HImode, operand1, operand2)); -} - -rtx -gen_iorqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, QImode, operand1, operand2)); -} - -rtx -gen_xorsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, SImode, operand1, operand2)); -} - -rtx -gen_xorhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, HImode, operand1, operand2)); -} - -rtx -gen_xorqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, QImode, operand1, operand2)); -} - -rtx -gen_negsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, SImode, operand1)); -} - -rtx -gen_neghi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, HImode, operand1)); -} - -rtx -gen_negqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, QImode, operand1)); -} - -rtx -gen_negsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, SFmode, operand1)); -} - -rtx -gen_negdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, DFmode, operand1)); -} - -rtx -gen_sqrtdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SQRT, DFmode, operand1)); -} - -rtx -gen_abssf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ABS, SFmode, operand1)); -} - -rtx -gen_absdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ABS, DFmode, operand1)); -} - -rtx -gen_one_cmplsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, SImode, operand1)); -} - -rtx -gen_one_cmplhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, HImode, operand1)); -} - -rtx -gen_one_cmplqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, QImode, operand1)); -} - -rtx -gen_ashlsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, SImode, operand1, operand2)); -} - -rtx -gen_ashlhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, HImode, operand1, operand2)); -} - -rtx -gen_ashlqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, QImode, operand1, operand2)); -} - -rtx -gen_ashrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, SImode, operand1, operand2)); -} - -rtx -gen_ashrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, HImode, operand1, operand2)); -} - -rtx -gen_ashrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, QImode, operand1, operand2)); -} - -rtx -gen_lshlsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFT, SImode, operand1, operand2)); -} - -rtx -gen_lshlhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFT, HImode, operand1, operand2)); -} - -rtx -gen_lshlqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFT, QImode, operand1, operand2)); -} - -rtx -gen_lshrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, SImode, operand1, operand2)); -} - -rtx -gen_lshrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, HImode, operand1, operand2)); -} - -rtx -gen_lshrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, QImode, operand1, operand2)); -} - -rtx -gen_rotlsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, SImode, operand1, operand2)); -} - -rtx -gen_rotlhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, HImode, operand1, operand2)); -} - -rtx -gen_rotlqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, QImode, operand1, operand2)); -} - -rtx -gen_rotrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, SImode, operand1, operand2)); -} - -rtx -gen_rotrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, HImode, operand1, operand2)); -} - -rtx -gen_rotrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, QImode, operand1, operand2)); -} - -rtx -gen_extv (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTRACT, SImode, operand1, operand2, operand3)); -} - -rtx -gen_extzv (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ZERO_EXTRACT, SImode, operand1, operand2, operand3)); -} - -rtx -gen_insv (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (SET, VOIDmode, gen_rtx (ZERO_EXTRACT, SImode, operand0, operand1, operand2), operand3); -} - -rtx -gen_seq (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (EQ, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sne (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NE, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sgt (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (GT, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sgtu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (GTU, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_slt (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LT, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sltu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LTU, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sge (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (GE, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sgeu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (GEU, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sle (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LE, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_sleu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LEU, QImode, cc0_rtx, const0_rtx)); -} - -rtx -gen_beq (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (EQ, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bne (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (NE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bgt (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GT, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bgtu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GTU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_blt (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LT, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bltu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LTU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bge (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bgeu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GEU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_ble (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_bleu (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LEU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx)); -} - -rtx -gen_jump (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (LABEL_REF, VOIDmode, operand0)); -} - -rtx -gen_tablejump (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ -#ifdef CASE_VECTOR_PC_RELATIVE - operands[0] = gen_rtx (PLUS, SImode, pc_rtx, operands[0]); -#endif -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_jump_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, pc_rtx, operand0), - gen_rtx (USE, VOIDmode, gen_rtx (LABEL_REF, VOIDmode, operand1))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_decrement_and_branch_until_zero (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GE, VOIDmode, gen_rtx (PLUS, SImode, operand0, constm1_rtx), const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand1), pc_rtx)), - gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SImode, operand0, constm1_rtx)))); -} - -rtx -gen_call (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF) -#ifdef MOTOROLA - SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1; -#else - operands[0] = gen_rtx (MEM, GET_MODE (operands[0]), - force_reg (Pmode, XEXP (operands[0], 0))); -#endif -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_call_insn (gen_rtx (CALL, VOIDmode, operand0, operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_call_value (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF) -#ifdef MOTOROLA - SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1; -#else - operands[1] = gen_rtx (MEM, GET_MODE (operands[1]), - force_reg (Pmode, XEXP (operands[1], 0))); -#endif -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_call_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (CALL, VOIDmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_untyped_call (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - int i; - - emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx)); - - for (i = 0; i < XVECLEN (operands[2], 0); i++) - { - rtx set = XVECEXP (operands[2], 0, i); - emit_move_insn (SET_DEST (set), SET_SRC (set)); - } - - /* The optimizer does not know that the call sets the function value - registers we stored in the result block. We avoid problems by - claiming that all hard registers are used and clobbered at this - point. */ - emit_insn (gen_blockage ()); - - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_call_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3, - gen_rtx (CALL, VOIDmode, operand0, const0_rtx), - operand1, - operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_blockage () -{ - return gen_rtx (UNSPEC_VOLATILE, VOIDmode, gen_rtvec (1, - const0_rtx), 0); -} - -rtx -gen_nop () -{ - return const0_rtx; -} - -rtx -gen_probe () -{ - return gen_rtx (REG, SImode, 15); -} - -rtx -gen_return () -{ - return gen_rtx (RETURN, VOIDmode); -} - -rtx -gen_indirect_jump (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, operand0); -} - -rtx -gen_tstxf (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_cmpxf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (CONSTANT_P (operands[0])) - operands[0] = force_const_mem (XFmode, operands[0]); - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_extendsfxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_EXTEND, XFmode, operand1)); -} - -rtx -gen_extenddfxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_EXTEND, XFmode, operand1)); -} - -rtx -gen_truncxfdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_TRUNCATE, DFmode, operand1)); -} - -rtx -gen_truncxfsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_TRUNCATE, SFmode, operand1)); -} - -rtx -gen_floatsixf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, XFmode, operand1)); -} - -rtx -gen_floathixf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, XFmode, operand1)); -} - -rtx -gen_floatqixf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, XFmode, operand1)); -} - -rtx -gen_ftruncxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, XFmode, operand1)); -} - -rtx -gen_fixxfqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, QImode, operand1)); -} - -rtx -gen_fixxfhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, HImode, operand1)); -} - -rtx -gen_fixxfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, operand1)); -} - -rtx -gen_addxf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, XFmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_subxf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, XFmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_mulxf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, XFmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_divxf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, XFmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_negxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, XFmode, operand1)); -} - -rtx -gen_absxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ABS, XFmode, operand1)); -} - -rtx -gen_sqrtxf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SQRT, XFmode, operand1)); -} - - - -void -add_clobbers (pattern, insn_code_number) - rtx pattern; - int insn_code_number; -{ - int i; - - switch (insn_code_number) - { - case 72: - case 71: - case 70: - XVECEXP (pattern, 0, 1) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - XVECEXP (pattern, 0, 2) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - break; - - case 18: - case 15: - case 9: - case 6: - XVECEXP (pattern, 0, 1) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - break; - - default: - abort (); - } -} diff --git a/gnu/usr.bin/gcc2/arch/hp300/insn-extract.c b/gnu/usr.bin/gcc2/arch/hp300/insn-extract.c deleted file mode 100644 index 82338e52e321..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/insn-extract.c +++ /dev/null @@ -1,558 +0,0 @@ -/* Generated automatically by the program `genextract' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" - -static rtx junk; -extern rtx recog_operand[]; -extern rtx *recog_operand_loc[]; -extern rtx *recog_dup_loc[]; -extern char recog_dup_num[]; -extern -#ifdef __GNUC__ -__volatile__ -#endif -void fatal_insn_not_found (); - -void -insn_extract (insn) - rtx insn; -{ - register rtx *ro = recog_operand; - register rtx **ro_loc = recog_operand_loc; - rtx pat = PATTERN (insn); - switch (INSN_CODE (insn)) - { - case -1: - fatal_insn_not_found (insn); - - case 305: - case 304: - case 303: - case 302: - case 301: - case 300: - case 299: -#if __GNUC__ > 1 && !defined (bcopy) -#define bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#endif - bcopy (&XVECEXP (pat, 0, 0), ro, - sizeof (rtx) * XVECLEN (pat, 0)); - break; - - case 317: - case 315: - case 309: - case 308: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XEXP (XEXP (pat, 1), 1), 1)); - break; - - case 316: - case 314: - case 313: - case 312: - case 311: - case 310: - case 307: - case 306: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 0), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 296: - case 295: - case 294: - case 293: - break; - - case 285: - case 284: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 0; - recog_dup_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - recog_dup_num[1] = 0; - break; - - case 283: - case 282: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 0; - recog_dup_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - recog_dup_num[1] = 0; - break; - - case 281: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 0), 0)); - break; - - case 280: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 0), 0)); - break; - - case 278: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - break; - - case 277: - case 276: - case 275: - case 274: - case 273: - case 272: - case 271: - case 270: - case 269: - case 268: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (pat, 1), 2), 0)); - break; - - case 267: - case 266: - case 265: - case 264: - case 263: - case 262: - case 261: - case 260: - case 259: - case 258: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - break; - - case 247: - case 246: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 2)); - break; - - case 244: - case 243: - case 239: - case 238: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 0), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 0), 2)); - break; - - case 237: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 0), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 0), 2)); - ro[3] = *(ro_loc[3] = &XEXP (XEXP (pat, 1), 1)); - recog_dup_loc[0] = &XEXP (XEXP (XEXP (pat, 1), 0), 0); - recog_dup_num[0] = 0; - recog_dup_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 1); - recog_dup_num[1] = 1; - recog_dup_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 0), 2); - recog_dup_num[2] = 2; - break; - - case 242: - case 241: - case 236: - case 235: - case 234: - case 233: - case 232: - case 231: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XEXP (pat, 1), 2)); - break; - - case 245: - case 240: - case 230: - case 229: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 0), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 0), 2)); - ro[3] = *(ro_loc[3] = &XEXP (pat, 1)); - break; - - case 190: - case 188: - case 172: - case 170: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - recog_dup_loc[0] = &XEXP (XEXP (pat, 1), 0); - recog_dup_num[0] = 0; - break; - - case 146: - case 145: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - recog_dup_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1); - recog_dup_num[1] = 2; - break; - - case 144: - case 141: - case 132: - case 129: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 0), 1)); - break; - - case 143: - case 140: - case 131: - case 128: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (XEXP (pat, 1), 0), 1), 0)); - break; - - case 120: - case 117: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - recog_dup_loc[0] = &XEXP (XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0), 0), 0), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0), 0), 1); - recog_dup_num[1] = 2; - break; - - case 119: - case 116: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - recog_dup_loc[0] = &XEXP (XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0), 0), 0), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0), 0), 1), 0); - recog_dup_num[1] = 2; - break; - - case 114: - case 111: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 113: - case 110: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - break; - - case 167: - case 164: - case 160: - case 157: - case 153: - case 150: - case 90: - case 87: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - recog_dup_loc[0] = &XEXP (XEXP (pat, 1), 1); - recog_dup_num[0] = 0; - break; - - case 228: - case 226: - case 223: - case 221: - case 218: - case 216: - case 211: - case 209: - case 204: - case 202: - case 197: - case 195: - case 166: - case 163: - case 159: - case 156: - case 152: - case 149: - case 102: - case 100: - case 89: - case 86: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 1)); - recog_dup_loc[0] = &XEXP (XEXP (pat, 1), 0); - recog_dup_num[0] = 0; - break; - - case 98: - case 84: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - break; - - case 339: - case 337: - case 335: - case 333: - case 291: - case 290: - case 227: - case 225: - case 224: - case 222: - case 220: - case 219: - case 217: - case 215: - case 214: - case 213: - case 212: - case 210: - case 208: - case 207: - case 206: - case 205: - case 203: - case 201: - case 200: - case 199: - case 198: - case 196: - case 194: - case 193: - case 192: - case 191: - case 165: - case 162: - case 161: - case 158: - case 155: - case 154: - case 151: - case 148: - case 147: - case 142: - case 139: - case 138: - case 137: - case 135: - case 134: - case 130: - case 127: - case 126: - case 125: - case 123: - case 122: - case 112: - case 109: - case 108: - case 107: - case 105: - case 104: - case 101: - case 99: - case 97: - case 96: - case 95: - case 93: - case 92: - case 88: - case 85: - case 83: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 82: - case 81: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - break; - - case 72: - case 71: - case 70: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 2), 0)); - break; - - case 342: - case 341: - case 340: - case 331: - case 330: - case 329: - case 328: - case 327: - case 326: - case 325: - case 324: - case 323: - case 322: - case 321: - case 189: - case 187: - case 186: - case 185: - case 184: - case 182: - case 181: - case 179: - case 178: - case 177: - case 175: - case 174: - case 171: - case 169: - case 168: - case 80: - case 79: - case 78: - case 77: - case 76: - case 75: - case 74: - case 73: - case 69: - case 68: - case 67: - case 66: - case 65: - case 64: - case 62: - case 61: - case 59: - case 58: - case 57: - case 55: - case 54: - case 52: - case 51: - case 50: - case 49: - case 48: - case 47: - case 43: - case 42: - case 41: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - break; - - case 33: - case 31: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (pat, 1)); - break; - - case 257: - case 256: - case 255: - case 254: - case 253: - case 252: - case 251: - case 250: - case 249: - case 248: - case 27: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - break; - - case 25: - case 24: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 2)); - break; - - case 23: - case 22: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XEXP (pat, 1), 2), 1), 0)); - break; - - case 21: - case 20: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 2), 1)); - break; - - case 18: - case 15: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 320: - case 19: - case 16: - case 13: - case 12: - case 11: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 9: - case 6: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 318: - case 297: - case 10: - case 7: - case 4: - case 3: - case 2: - ro[0] = *(ro_loc[0] = &XEXP (pat, 1)); - break; - - case 298: - case 288: - case 287: - case 40: - case 39: - case 38: - case 37: - case 35: - case 34: - case 32: - case 30: - case 29: - case 26: - case 1: - case 0: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (pat, 1)); - break; - - default: - abort (); - } -} diff --git a/gnu/usr.bin/gcc2/arch/hp300/insn-flags.h b/gnu/usr.bin/gcc2/arch/hp300/insn-flags.h deleted file mode 100644 index 13cb48ec0612..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/insn-flags.h +++ /dev/null @@ -1,537 +0,0 @@ -/* Generated automatically by the program `genflags' -from the machine description file `md'. */ - -#define HAVE_tstsi 1 -#define HAVE_tsthi 1 -#define HAVE_tstqi 1 -#define HAVE_tstsf (TARGET_68881 || TARGET_FPA) -#define HAVE_tstsf_fpa (TARGET_FPA) -#define HAVE_tstdf (TARGET_68881 || TARGET_FPA) -#define HAVE_tstdf_fpa (TARGET_FPA) -#define HAVE_cmpsi 1 -#define HAVE_cmphi 1 -#define HAVE_cmpqi 1 -#define HAVE_cmpdf (TARGET_68881 || TARGET_FPA) -#define HAVE_cmpdf_fpa (TARGET_FPA) -#define HAVE_cmpsf (TARGET_68881 || TARGET_FPA) -#define HAVE_cmpsf_fpa (TARGET_FPA) -#define HAVE_movsi 1 -#define HAVE_movhi 1 -#define HAVE_movstricthi 1 -#define HAVE_movqi 1 -#define HAVE_movstrictqi 1 -#define HAVE_movsf 1 -#define HAVE_movdf 1 -#define HAVE_movxf 1 -#define HAVE_movdi 1 -#define HAVE_pushasi 1 -#define HAVE_truncsiqi2 1 -#define HAVE_trunchiqi2 1 -#define HAVE_truncsihi2 1 -#define HAVE_zero_extendhisi2 1 -#define HAVE_zero_extendqihi2 1 -#define HAVE_zero_extendqisi2 1 -#define HAVE_extendhisi2 1 -#define HAVE_extendqihi2 1 -#define HAVE_extendqisi2 (TARGET_68020) -#define HAVE_extendsfdf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_truncdfsf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_floatsisf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_floatsidf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_floathisf2 (TARGET_68881) -#define HAVE_floathidf2 (TARGET_68881) -#define HAVE_floatqisf2 (TARGET_68881) -#define HAVE_floatqidf2 (TARGET_68881) -#define HAVE_fix_truncdfsi2 (TARGET_68040) -#define HAVE_fix_truncdfhi2 (TARGET_68040) -#define HAVE_fix_truncdfqi2 (TARGET_68040) -#define HAVE_ftruncdf2 (TARGET_68881 && !TARGET_68040) -#define HAVE_ftruncsf2 (TARGET_68881 && !TARGET_68040) -#define HAVE_fixsfqi2 (TARGET_68881) -#define HAVE_fixsfhi2 (TARGET_68881) -#define HAVE_fixsfsi2 (TARGET_68881) -#define HAVE_fixdfqi2 (TARGET_68881) -#define HAVE_fixdfhi2 (TARGET_68881) -#define HAVE_fixdfsi2 (TARGET_68881) -#define HAVE_addsi3 1 -#define HAVE_addhi3 1 -#define HAVE_addqi3 1 -#define HAVE_adddf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_addsf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_subsi3 1 -#define HAVE_subhi3 1 -#define HAVE_subqi3 1 -#define HAVE_subdf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_subsf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_mulhi3 1 -#define HAVE_mulhisi3 1 -#define HAVE_mulsi3 (TARGET_68020) -#define HAVE_umulhisi3 1 -#define HAVE_umulsidi3 (TARGET_68020) -#define HAVE_mulsidi3 (TARGET_68020) -#define HAVE_muldf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_mulsf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_divhi3 1 -#define HAVE_divhisi3 1 -#define HAVE_udivhi3 1 -#define HAVE_udivhisi3 1 -#define HAVE_divdf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_divsf3 (TARGET_68881 || TARGET_FPA) -#define HAVE_modhi3 1 -#define HAVE_modhisi3 1 -#define HAVE_umodhi3 1 -#define HAVE_umodhisi3 1 -#define HAVE_divmodsi4 (TARGET_68020) -#define HAVE_udivmodsi4 (TARGET_68020) -#define HAVE_andsi3 1 -#define HAVE_andhi3 1 -#define HAVE_andqi3 1 -#define HAVE_iorsi3 1 -#define HAVE_iorhi3 1 -#define HAVE_iorqi3 1 -#define HAVE_xorsi3 1 -#define HAVE_xorhi3 1 -#define HAVE_xorqi3 1 -#define HAVE_negsi2 1 -#define HAVE_neghi2 1 -#define HAVE_negqi2 1 -#define HAVE_negsf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_negdf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_sqrtdf2 (TARGET_68881) -#define HAVE_abssf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_absdf2 (TARGET_68881 || TARGET_FPA) -#define HAVE_one_cmplsi2 1 -#define HAVE_one_cmplhi2 1 -#define HAVE_one_cmplqi2 1 -#define HAVE_ashlsi3 1 -#define HAVE_ashlhi3 1 -#define HAVE_ashlqi3 1 -#define HAVE_ashrsi3 1 -#define HAVE_ashrhi3 1 -#define HAVE_ashrqi3 1 -#define HAVE_lshlsi3 1 -#define HAVE_lshlhi3 1 -#define HAVE_lshlqi3 1 -#define HAVE_lshrsi3 1 -#define HAVE_lshrhi3 1 -#define HAVE_lshrqi3 1 -#define HAVE_rotlsi3 1 -#define HAVE_rotlhi3 1 -#define HAVE_rotlqi3 1 -#define HAVE_rotrsi3 1 -#define HAVE_rotrhi3 1 -#define HAVE_rotrqi3 1 -#define HAVE_extv (TARGET_68020 && TARGET_BITFIELD) -#define HAVE_extzv (TARGET_68020 && TARGET_BITFIELD) -#define HAVE_insv (TARGET_68020 && TARGET_BITFIELD) -#define HAVE_seq 1 -#define HAVE_sne 1 -#define HAVE_sgt 1 -#define HAVE_sgtu 1 -#define HAVE_slt 1 -#define HAVE_sltu 1 -#define HAVE_sge 1 -#define HAVE_sgeu 1 -#define HAVE_sle 1 -#define HAVE_sleu 1 -#define HAVE_beq 1 -#define HAVE_bne 1 -#define HAVE_bgt 1 -#define HAVE_bgtu 1 -#define HAVE_blt 1 -#define HAVE_bltu 1 -#define HAVE_bge 1 -#define HAVE_bgeu 1 -#define HAVE_ble 1 -#define HAVE_bleu 1 -#define HAVE_jump 1 -#define HAVE_tablejump 1 -#define HAVE_decrement_and_branch_until_zero (find_reg_note (insn, REG_NONNEG, 0)) -#define HAVE_call 1 -#define HAVE_call_value 1 -#define HAVE_untyped_call (NEEDS_UNTYPED_CALL) -#define HAVE_blockage 1 -#define HAVE_nop 1 -#define HAVE_probe (NEED_PROBE) -#define HAVE_return (USE_RETURN_INSN) -#define HAVE_indirect_jump 1 -#define HAVE_tstxf (TARGET_68881) -#define HAVE_cmpxf (TARGET_68881) -#define HAVE_extendsfxf2 (TARGET_68881) -#define HAVE_extenddfxf2 (TARGET_68881) -#define HAVE_truncxfdf2 (TARGET_68881) -#define HAVE_truncxfsf2 (TARGET_68881) -#define HAVE_floatsixf2 (TARGET_68881) -#define HAVE_floathixf2 (TARGET_68881) -#define HAVE_floatqixf2 (TARGET_68881) -#define HAVE_ftruncxf2 (TARGET_68881) -#define HAVE_fixxfqi2 (TARGET_68881) -#define HAVE_fixxfhi2 (TARGET_68881) -#define HAVE_fixxfsi2 (TARGET_68881) -#define HAVE_addxf3 (TARGET_68881) -#define HAVE_subxf3 (TARGET_68881) -#define HAVE_mulxf3 (TARGET_68881) -#define HAVE_divxf3 (TARGET_68881) -#define HAVE_negxf2 (TARGET_68881) -#define HAVE_absxf2 (TARGET_68881) -#define HAVE_sqrtxf2 (TARGET_68881) - -#ifndef NO_MD_PROTOTYPES -extern rtx gen_tstsi PROTO((rtx)); -extern rtx gen_tsthi PROTO((rtx)); -extern rtx gen_tstqi PROTO((rtx)); -extern rtx gen_tstsf PROTO((rtx)); -extern rtx gen_tstsf_fpa PROTO((rtx)); -extern rtx gen_tstdf PROTO((rtx)); -extern rtx gen_tstdf_fpa PROTO((rtx)); -extern rtx gen_cmpsi PROTO((rtx, rtx)); -extern rtx gen_cmphi PROTO((rtx, rtx)); -extern rtx gen_cmpqi PROTO((rtx, rtx)); -extern rtx gen_cmpdf PROTO((rtx, rtx)); -extern rtx gen_cmpdf_fpa PROTO((rtx, rtx)); -extern rtx gen_cmpsf PROTO((rtx, rtx)); -extern rtx gen_cmpsf_fpa PROTO((rtx, rtx)); -extern rtx gen_movsi PROTO((rtx, rtx)); -extern rtx gen_movhi PROTO((rtx, rtx)); -extern rtx gen_movstricthi PROTO((rtx, rtx)); -extern rtx gen_movqi PROTO((rtx, rtx)); -extern rtx gen_movstrictqi PROTO((rtx, rtx)); -extern rtx gen_movsf PROTO((rtx, rtx)); -extern rtx gen_movdf PROTO((rtx, rtx)); -extern rtx gen_movxf PROTO((rtx, rtx)); -extern rtx gen_movdi PROTO((rtx, rtx)); -extern rtx gen_pushasi PROTO((rtx, rtx)); -extern rtx gen_truncsiqi2 PROTO((rtx, rtx)); -extern rtx gen_trunchiqi2 PROTO((rtx, rtx)); -extern rtx gen_truncsihi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendhisi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendqihi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendqisi2 PROTO((rtx, rtx)); -extern rtx gen_extendhisi2 PROTO((rtx, rtx)); -extern rtx gen_extendqihi2 PROTO((rtx, rtx)); -extern rtx gen_extendqisi2 PROTO((rtx, rtx)); -extern rtx gen_extendsfdf2 PROTO((rtx, rtx)); -extern rtx gen_truncdfsf2 PROTO((rtx, rtx)); -extern rtx gen_floatsisf2 PROTO((rtx, rtx)); -extern rtx gen_floatsidf2 PROTO((rtx, rtx)); -extern rtx gen_floathisf2 PROTO((rtx, rtx)); -extern rtx gen_floathidf2 PROTO((rtx, rtx)); -extern rtx gen_floatqisf2 PROTO((rtx, rtx)); -extern rtx gen_floatqidf2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncdfsi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncdfhi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncdfqi2 PROTO((rtx, rtx)); -extern rtx gen_ftruncdf2 PROTO((rtx, rtx)); -extern rtx gen_ftruncsf2 PROTO((rtx, rtx)); -extern rtx gen_fixsfqi2 PROTO((rtx, rtx)); -extern rtx gen_fixsfhi2 PROTO((rtx, rtx)); -extern rtx gen_fixsfsi2 PROTO((rtx, rtx)); -extern rtx gen_fixdfqi2 PROTO((rtx, rtx)); -extern rtx gen_fixdfhi2 PROTO((rtx, rtx)); -extern rtx gen_fixdfsi2 PROTO((rtx, rtx)); -extern rtx gen_addsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_adddf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subdf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_umulhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_umulsidi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulsidi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_muldf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_udivhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_udivhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divdf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_modhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_modhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_umodhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_umodhisi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divmodsi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_udivmodsi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_andsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_andhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_andqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_negsi2 PROTO((rtx, rtx)); -extern rtx gen_neghi2 PROTO((rtx, rtx)); -extern rtx gen_negqi2 PROTO((rtx, rtx)); -extern rtx gen_negsf2 PROTO((rtx, rtx)); -extern rtx gen_negdf2 PROTO((rtx, rtx)); -extern rtx gen_sqrtdf2 PROTO((rtx, rtx)); -extern rtx gen_abssf2 PROTO((rtx, rtx)); -extern rtx gen_absdf2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplsi2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplhi2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplqi2 PROTO((rtx, rtx)); -extern rtx gen_ashlsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashlhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashlqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshlsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshlhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshlqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_extv PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_extzv PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_insv PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_seq PROTO((rtx)); -extern rtx gen_sne PROTO((rtx)); -extern rtx gen_sgt PROTO((rtx)); -extern rtx gen_sgtu PROTO((rtx)); -extern rtx gen_slt PROTO((rtx)); -extern rtx gen_sltu PROTO((rtx)); -extern rtx gen_sge PROTO((rtx)); -extern rtx gen_sgeu PROTO((rtx)); -extern rtx gen_sle PROTO((rtx)); -extern rtx gen_sleu PROTO((rtx)); -extern rtx gen_beq PROTO((rtx)); -extern rtx gen_bne PROTO((rtx)); -extern rtx gen_bgt PROTO((rtx)); -extern rtx gen_bgtu PROTO((rtx)); -extern rtx gen_blt PROTO((rtx)); -extern rtx gen_bltu PROTO((rtx)); -extern rtx gen_bge PROTO((rtx)); -extern rtx gen_bgeu PROTO((rtx)); -extern rtx gen_ble PROTO((rtx)); -extern rtx gen_bleu PROTO((rtx)); -extern rtx gen_jump PROTO((rtx)); -extern rtx gen_tablejump PROTO((rtx, rtx)); -extern rtx gen_decrement_and_branch_until_zero PROTO((rtx, rtx)); -extern rtx gen_untyped_call PROTO((rtx, rtx, rtx)); -extern rtx gen_blockage PROTO((void)); -extern rtx gen_nop PROTO((void)); -extern rtx gen_probe PROTO((void)); -extern rtx gen_return PROTO((void)); -extern rtx gen_indirect_jump PROTO((rtx)); -extern rtx gen_tstxf PROTO((rtx)); -extern rtx gen_cmpxf PROTO((rtx, rtx)); -extern rtx gen_extendsfxf2 PROTO((rtx, rtx)); -extern rtx gen_extenddfxf2 PROTO((rtx, rtx)); -extern rtx gen_truncxfdf2 PROTO((rtx, rtx)); -extern rtx gen_truncxfsf2 PROTO((rtx, rtx)); -extern rtx gen_floatsixf2 PROTO((rtx, rtx)); -extern rtx gen_floathixf2 PROTO((rtx, rtx)); -extern rtx gen_floatqixf2 PROTO((rtx, rtx)); -extern rtx gen_ftruncxf2 PROTO((rtx, rtx)); -extern rtx gen_fixxfqi2 PROTO((rtx, rtx)); -extern rtx gen_fixxfhi2 PROTO((rtx, rtx)); -extern rtx gen_fixxfsi2 PROTO((rtx, rtx)); -extern rtx gen_addxf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subxf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulxf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divxf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_negxf2 PROTO((rtx, rtx)); -extern rtx gen_absxf2 PROTO((rtx, rtx)); -extern rtx gen_sqrtxf2 PROTO((rtx, rtx)); - -#ifdef MD_CALL_PROTOTYPES -extern rtx gen_call PROTO((rtx, rtx)); -extern rtx gen_call_value PROTO((rtx, rtx, rtx)); - -#else /* !MD_CALL_PROTOTYPES */ -extern rtx gen_call (); -extern rtx gen_call_value (); -#endif /* !MD_CALL_PROTOTYPES */ - -#else /* NO_MD_PROTOTYPES */ -extern rtx gen_tstsi (); -extern rtx gen_tsthi (); -extern rtx gen_tstqi (); -extern rtx gen_tstsf (); -extern rtx gen_tstsf_fpa (); -extern rtx gen_tstdf (); -extern rtx gen_tstdf_fpa (); -extern rtx gen_cmpsi (); -extern rtx gen_cmphi (); -extern rtx gen_cmpqi (); -extern rtx gen_cmpdf (); -extern rtx gen_cmpdf_fpa (); -extern rtx gen_cmpsf (); -extern rtx gen_cmpsf_fpa (); -extern rtx gen_movsi (); -extern rtx gen_movhi (); -extern rtx gen_movstricthi (); -extern rtx gen_movqi (); -extern rtx gen_movstrictqi (); -extern rtx gen_movsf (); -extern rtx gen_movdf (); -extern rtx gen_movxf (); -extern rtx gen_movdi (); -extern rtx gen_pushasi (); -extern rtx gen_truncsiqi2 (); -extern rtx gen_trunchiqi2 (); -extern rtx gen_truncsihi2 (); -extern rtx gen_zero_extendhisi2 (); -extern rtx gen_zero_extendqihi2 (); -extern rtx gen_zero_extendqisi2 (); -extern rtx gen_extendhisi2 (); -extern rtx gen_extendqihi2 (); -extern rtx gen_extendqisi2 (); -extern rtx gen_extendsfdf2 (); -extern rtx gen_truncdfsf2 (); -extern rtx gen_floatsisf2 (); -extern rtx gen_floatsidf2 (); -extern rtx gen_floathisf2 (); -extern rtx gen_floathidf2 (); -extern rtx gen_floatqisf2 (); -extern rtx gen_floatqidf2 (); -extern rtx gen_fix_truncdfsi2 (); -extern rtx gen_fix_truncdfhi2 (); -extern rtx gen_fix_truncdfqi2 (); -extern rtx gen_ftruncdf2 (); -extern rtx gen_ftruncsf2 (); -extern rtx gen_fixsfqi2 (); -extern rtx gen_fixsfhi2 (); -extern rtx gen_fixsfsi2 (); -extern rtx gen_fixdfqi2 (); -extern rtx gen_fixdfhi2 (); -extern rtx gen_fixdfsi2 (); -extern rtx gen_addsi3 (); -extern rtx gen_addhi3 (); -extern rtx gen_addqi3 (); -extern rtx gen_adddf3 (); -extern rtx gen_addsf3 (); -extern rtx gen_subsi3 (); -extern rtx gen_subhi3 (); -extern rtx gen_subqi3 (); -extern rtx gen_subdf3 (); -extern rtx gen_subsf3 (); -extern rtx gen_mulhi3 (); -extern rtx gen_mulhisi3 (); -extern rtx gen_mulsi3 (); -extern rtx gen_umulhisi3 (); -extern rtx gen_umulsidi3 (); -extern rtx gen_mulsidi3 (); -extern rtx gen_muldf3 (); -extern rtx gen_mulsf3 (); -extern rtx gen_divhi3 (); -extern rtx gen_divhisi3 (); -extern rtx gen_udivhi3 (); -extern rtx gen_udivhisi3 (); -extern rtx gen_divdf3 (); -extern rtx gen_divsf3 (); -extern rtx gen_modhi3 (); -extern rtx gen_modhisi3 (); -extern rtx gen_umodhi3 (); -extern rtx gen_umodhisi3 (); -extern rtx gen_divmodsi4 (); -extern rtx gen_udivmodsi4 (); -extern rtx gen_andsi3 (); -extern rtx gen_andhi3 (); -extern rtx gen_andqi3 (); -extern rtx gen_iorsi3 (); -extern rtx gen_iorhi3 (); -extern rtx gen_iorqi3 (); -extern rtx gen_xorsi3 (); -extern rtx gen_xorhi3 (); -extern rtx gen_xorqi3 (); -extern rtx gen_negsi2 (); -extern rtx gen_neghi2 (); -extern rtx gen_negqi2 (); -extern rtx gen_negsf2 (); -extern rtx gen_negdf2 (); -extern rtx gen_sqrtdf2 (); -extern rtx gen_abssf2 (); -extern rtx gen_absdf2 (); -extern rtx gen_one_cmplsi2 (); -extern rtx gen_one_cmplhi2 (); -extern rtx gen_one_cmplqi2 (); -extern rtx gen_ashlsi3 (); -extern rtx gen_ashlhi3 (); -extern rtx gen_ashlqi3 (); -extern rtx gen_ashrsi3 (); -extern rtx gen_ashrhi3 (); -extern rtx gen_ashrqi3 (); -extern rtx gen_lshlsi3 (); -extern rtx gen_lshlhi3 (); -extern rtx gen_lshlqi3 (); -extern rtx gen_lshrsi3 (); -extern rtx gen_lshrhi3 (); -extern rtx gen_lshrqi3 (); -extern rtx gen_rotlsi3 (); -extern rtx gen_rotlhi3 (); -extern rtx gen_rotlqi3 (); -extern rtx gen_rotrsi3 (); -extern rtx gen_rotrhi3 (); -extern rtx gen_rotrqi3 (); -extern rtx gen_extv (); -extern rtx gen_extzv (); -extern rtx gen_insv (); -extern rtx gen_seq (); -extern rtx gen_sne (); -extern rtx gen_sgt (); -extern rtx gen_sgtu (); -extern rtx gen_slt (); -extern rtx gen_sltu (); -extern rtx gen_sge (); -extern rtx gen_sgeu (); -extern rtx gen_sle (); -extern rtx gen_sleu (); -extern rtx gen_beq (); -extern rtx gen_bne (); -extern rtx gen_bgt (); -extern rtx gen_bgtu (); -extern rtx gen_blt (); -extern rtx gen_bltu (); -extern rtx gen_bge (); -extern rtx gen_bgeu (); -extern rtx gen_ble (); -extern rtx gen_bleu (); -extern rtx gen_jump (); -extern rtx gen_tablejump (); -extern rtx gen_decrement_and_branch_until_zero (); -extern rtx gen_untyped_call (); -extern rtx gen_blockage (); -extern rtx gen_nop (); -extern rtx gen_probe (); -extern rtx gen_return (); -extern rtx gen_indirect_jump (); -extern rtx gen_tstxf (); -extern rtx gen_cmpxf (); -extern rtx gen_extendsfxf2 (); -extern rtx gen_extenddfxf2 (); -extern rtx gen_truncxfdf2 (); -extern rtx gen_truncxfsf2 (); -extern rtx gen_floatsixf2 (); -extern rtx gen_floathixf2 (); -extern rtx gen_floatqixf2 (); -extern rtx gen_ftruncxf2 (); -extern rtx gen_fixxfqi2 (); -extern rtx gen_fixxfhi2 (); -extern rtx gen_fixxfsi2 (); -extern rtx gen_addxf3 (); -extern rtx gen_subxf3 (); -extern rtx gen_mulxf3 (); -extern rtx gen_divxf3 (); -extern rtx gen_negxf2 (); -extern rtx gen_absxf2 (); -extern rtx gen_sqrtxf2 (); -extern rtx gen_call (); -extern rtx gen_call_value (); -#endif /* NO_MD_PROTOTYPES */ diff --git a/gnu/usr.bin/gcc2/arch/hp300/insn-opinit.c b/gnu/usr.bin/gcc2/arch/hp300/insn-opinit.c deleted file mode 100644 index 83f29384a2aa..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/insn-opinit.c +++ /dev/null @@ -1,221 +0,0 @@ -/* Generated automatically by the program `genopinit' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "flags.h" -#include "insn-flags.h" -#include "insn-codes.h" -#include "insn-config.h" -#include "recog.h" -#include "expr.h" -#include "reload.h" - -void -init_all_optabs () -{ - tst_optab->handlers[(int) SImode].insn_code = CODE_FOR_tstsi; - tst_optab->handlers[(int) HImode].insn_code = CODE_FOR_tsthi; - tst_optab->handlers[(int) QImode].insn_code = CODE_FOR_tstqi; - if (HAVE_tstsf) - tst_optab->handlers[(int) SFmode].insn_code = CODE_FOR_tstsf; - if (HAVE_tstdf) - tst_optab->handlers[(int) DFmode].insn_code = CODE_FOR_tstdf; - cmp_optab->handlers[(int) SImode].insn_code = CODE_FOR_cmpsi; - cmp_optab->handlers[(int) HImode].insn_code = CODE_FOR_cmphi; - cmp_optab->handlers[(int) QImode].insn_code = CODE_FOR_cmpqi; - if (HAVE_cmpdf) - cmp_optab->handlers[(int) DFmode].insn_code = CODE_FOR_cmpdf; - if (HAVE_cmpsf) - cmp_optab->handlers[(int) SFmode].insn_code = CODE_FOR_cmpsf; - mov_optab->handlers[(int) SImode].insn_code = CODE_FOR_movsi; - mov_optab->handlers[(int) HImode].insn_code = CODE_FOR_movhi; - movstrict_optab->handlers[(int) HImode].insn_code = CODE_FOR_movstricthi; - mov_optab->handlers[(int) QImode].insn_code = CODE_FOR_movqi; - movstrict_optab->handlers[(int) QImode].insn_code = CODE_FOR_movstrictqi; - mov_optab->handlers[(int) SFmode].insn_code = CODE_FOR_movsf; - mov_optab->handlers[(int) DFmode].insn_code = CODE_FOR_movdf; - mov_optab->handlers[(int) XFmode].insn_code = CODE_FOR_movxf; - mov_optab->handlers[(int) DImode].insn_code = CODE_FOR_movdi; - extendtab[(int) SImode][(int) HImode][1] = CODE_FOR_zero_extendhisi2; - extendtab[(int) HImode][(int) QImode][1] = CODE_FOR_zero_extendqihi2; - extendtab[(int) SImode][(int) QImode][1] = CODE_FOR_zero_extendqisi2; - extendtab[(int) SImode][(int) HImode][0] = CODE_FOR_extendhisi2; - extendtab[(int) HImode][(int) QImode][0] = CODE_FOR_extendqihi2; - if (HAVE_extendqisi2) - extendtab[(int) SImode][(int) QImode][0] = CODE_FOR_extendqisi2; - if (HAVE_extendsfdf2) - extendtab[(int) DFmode][(int) SFmode][0] = CODE_FOR_extendsfdf2; - if (HAVE_floatsisf2) - floattab[(int) SFmode][(int) SImode][0] = CODE_FOR_floatsisf2; - if (HAVE_floatsidf2) - floattab[(int) DFmode][(int) SImode][0] = CODE_FOR_floatsidf2; - if (HAVE_floathisf2) - floattab[(int) SFmode][(int) HImode][0] = CODE_FOR_floathisf2; - if (HAVE_floathidf2) - floattab[(int) DFmode][(int) HImode][0] = CODE_FOR_floathidf2; - if (HAVE_floatqisf2) - floattab[(int) SFmode][(int) QImode][0] = CODE_FOR_floatqisf2; - if (HAVE_floatqidf2) - floattab[(int) DFmode][(int) QImode][0] = CODE_FOR_floatqidf2; - if (HAVE_fix_truncdfsi2) - fixtrunctab[(int) DFmode][(int) SImode][0] = CODE_FOR_fix_truncdfsi2; - if (HAVE_fix_truncdfhi2) - fixtrunctab[(int) DFmode][(int) HImode][0] = CODE_FOR_fix_truncdfhi2; - if (HAVE_fix_truncdfqi2) - fixtrunctab[(int) DFmode][(int) QImode][0] = CODE_FOR_fix_truncdfqi2; - if (HAVE_ftruncdf2) - ftrunc_optab->handlers[(int) DFmode].insn_code = CODE_FOR_ftruncdf2; - if (HAVE_ftruncsf2) - ftrunc_optab->handlers[(int) SFmode].insn_code = CODE_FOR_ftruncsf2; - if (HAVE_fixsfqi2) - fixtab[(int) SFmode][(int) QImode][0] = CODE_FOR_fixsfqi2; - if (HAVE_fixsfhi2) - fixtab[(int) SFmode][(int) HImode][0] = CODE_FOR_fixsfhi2; - if (HAVE_fixsfsi2) - fixtab[(int) SFmode][(int) SImode][0] = CODE_FOR_fixsfsi2; - if (HAVE_fixdfqi2) - fixtab[(int) DFmode][(int) QImode][0] = CODE_FOR_fixdfqi2; - if (HAVE_fixdfhi2) - fixtab[(int) DFmode][(int) HImode][0] = CODE_FOR_fixdfhi2; - if (HAVE_fixdfsi2) - fixtab[(int) DFmode][(int) SImode][0] = CODE_FOR_fixdfsi2; - add_optab->handlers[(int) SImode].insn_code = CODE_FOR_addsi3; - add_optab->handlers[(int) HImode].insn_code = CODE_FOR_addhi3; - add_optab->handlers[(int) QImode].insn_code = CODE_FOR_addqi3; - if (HAVE_adddf3) - add_optab->handlers[(int) DFmode].insn_code = CODE_FOR_adddf3; - if (HAVE_addsf3) - add_optab->handlers[(int) SFmode].insn_code = CODE_FOR_addsf3; - sub_optab->handlers[(int) SImode].insn_code = CODE_FOR_subsi3; - sub_optab->handlers[(int) HImode].insn_code = CODE_FOR_subhi3; - sub_optab->handlers[(int) QImode].insn_code = CODE_FOR_subqi3; - if (HAVE_subdf3) - sub_optab->handlers[(int) DFmode].insn_code = CODE_FOR_subdf3; - if (HAVE_subsf3) - sub_optab->handlers[(int) SFmode].insn_code = CODE_FOR_subsf3; - smul_optab->handlers[(int) HImode].insn_code = CODE_FOR_mulhi3; - smul_widen_optab->handlers[(int) SImode].insn_code = CODE_FOR_mulhisi3; - if (HAVE_mulsi3) - smul_optab->handlers[(int) SImode].insn_code = CODE_FOR_mulsi3; - umul_widen_optab->handlers[(int) SImode].insn_code = CODE_FOR_umulhisi3; - if (HAVE_umulsidi3) - umul_widen_optab->handlers[(int) DImode].insn_code = CODE_FOR_umulsidi3; - if (HAVE_mulsidi3) - smul_widen_optab->handlers[(int) DImode].insn_code = CODE_FOR_mulsidi3; - if (HAVE_muldf3) - smul_optab->handlers[(int) DFmode].insn_code = CODE_FOR_muldf3; - if (HAVE_mulsf3) - smul_optab->handlers[(int) SFmode].insn_code = CODE_FOR_mulsf3; - sdiv_optab->handlers[(int) HImode].insn_code = CODE_FOR_divhi3; - udiv_optab->handlers[(int) HImode].insn_code = CODE_FOR_udivhi3; - if (HAVE_divdf3) - flodiv_optab->handlers[(int) DFmode].insn_code = CODE_FOR_divdf3; - if (HAVE_divsf3) - flodiv_optab->handlers[(int) SFmode].insn_code = CODE_FOR_divsf3; - smod_optab->handlers[(int) HImode].insn_code = CODE_FOR_modhi3; - umod_optab->handlers[(int) HImode].insn_code = CODE_FOR_umodhi3; - if (HAVE_divmodsi4) - sdivmod_optab->handlers[(int) SImode].insn_code = CODE_FOR_divmodsi4; - if (HAVE_udivmodsi4) - udivmod_optab->handlers[(int) SImode].insn_code = CODE_FOR_udivmodsi4; - and_optab->handlers[(int) SImode].insn_code = CODE_FOR_andsi3; - and_optab->handlers[(int) HImode].insn_code = CODE_FOR_andhi3; - and_optab->handlers[(int) QImode].insn_code = CODE_FOR_andqi3; - ior_optab->handlers[(int) SImode].insn_code = CODE_FOR_iorsi3; - ior_optab->handlers[(int) HImode].insn_code = CODE_FOR_iorhi3; - ior_optab->handlers[(int) QImode].insn_code = CODE_FOR_iorqi3; - xor_optab->handlers[(int) SImode].insn_code = CODE_FOR_xorsi3; - xor_optab->handlers[(int) HImode].insn_code = CODE_FOR_xorhi3; - xor_optab->handlers[(int) QImode].insn_code = CODE_FOR_xorqi3; - neg_optab->handlers[(int) SImode].insn_code = CODE_FOR_negsi2; - neg_optab->handlers[(int) HImode].insn_code = CODE_FOR_neghi2; - neg_optab->handlers[(int) QImode].insn_code = CODE_FOR_negqi2; - if (HAVE_negsf2) - neg_optab->handlers[(int) SFmode].insn_code = CODE_FOR_negsf2; - if (HAVE_negdf2) - neg_optab->handlers[(int) DFmode].insn_code = CODE_FOR_negdf2; - if (HAVE_sqrtdf2) - sqrt_optab->handlers[(int) DFmode].insn_code = CODE_FOR_sqrtdf2; - if (HAVE_abssf2) - abs_optab->handlers[(int) SFmode].insn_code = CODE_FOR_abssf2; - if (HAVE_absdf2) - abs_optab->handlers[(int) DFmode].insn_code = CODE_FOR_absdf2; - one_cmpl_optab->handlers[(int) SImode].insn_code = CODE_FOR_one_cmplsi2; - one_cmpl_optab->handlers[(int) HImode].insn_code = CODE_FOR_one_cmplhi2; - one_cmpl_optab->handlers[(int) QImode].insn_code = CODE_FOR_one_cmplqi2; - ashl_optab->handlers[(int) SImode].insn_code = CODE_FOR_ashlsi3; - ashl_optab->handlers[(int) HImode].insn_code = CODE_FOR_ashlhi3; - ashl_optab->handlers[(int) QImode].insn_code = CODE_FOR_ashlqi3; - ashr_optab->handlers[(int) SImode].insn_code = CODE_FOR_ashrsi3; - ashr_optab->handlers[(int) HImode].insn_code = CODE_FOR_ashrhi3; - ashr_optab->handlers[(int) QImode].insn_code = CODE_FOR_ashrqi3; - lshl_optab->handlers[(int) SImode].insn_code = CODE_FOR_lshlsi3; - lshl_optab->handlers[(int) HImode].insn_code = CODE_FOR_lshlhi3; - lshl_optab->handlers[(int) QImode].insn_code = CODE_FOR_lshlqi3; - lshr_optab->handlers[(int) SImode].insn_code = CODE_FOR_lshrsi3; - lshr_optab->handlers[(int) HImode].insn_code = CODE_FOR_lshrhi3; - lshr_optab->handlers[(int) QImode].insn_code = CODE_FOR_lshrqi3; - rotl_optab->handlers[(int) SImode].insn_code = CODE_FOR_rotlsi3; - rotl_optab->handlers[(int) HImode].insn_code = CODE_FOR_rotlhi3; - rotl_optab->handlers[(int) QImode].insn_code = CODE_FOR_rotlqi3; - rotr_optab->handlers[(int) SImode].insn_code = CODE_FOR_rotrsi3; - rotr_optab->handlers[(int) HImode].insn_code = CODE_FOR_rotrhi3; - rotr_optab->handlers[(int) QImode].insn_code = CODE_FOR_rotrqi3; - setcc_gen_code[(int) EQ] = CODE_FOR_seq; - setcc_gen_code[(int) NE] = CODE_FOR_sne; - setcc_gen_code[(int) GT] = CODE_FOR_sgt; - setcc_gen_code[(int) GTU] = CODE_FOR_sgtu; - setcc_gen_code[(int) LT] = CODE_FOR_slt; - setcc_gen_code[(int) LTU] = CODE_FOR_sltu; - setcc_gen_code[(int) GE] = CODE_FOR_sge; - setcc_gen_code[(int) GEU] = CODE_FOR_sgeu; - setcc_gen_code[(int) LE] = CODE_FOR_sle; - setcc_gen_code[(int) LEU] = CODE_FOR_sleu; - bcc_gen_fctn[(int) EQ] = gen_beq; - bcc_gen_fctn[(int) NE] = gen_bne; - bcc_gen_fctn[(int) GT] = gen_bgt; - bcc_gen_fctn[(int) GTU] = gen_bgtu; - bcc_gen_fctn[(int) LT] = gen_blt; - bcc_gen_fctn[(int) LTU] = gen_bltu; - bcc_gen_fctn[(int) GE] = gen_bge; - bcc_gen_fctn[(int) GEU] = gen_bgeu; - bcc_gen_fctn[(int) LE] = gen_ble; - bcc_gen_fctn[(int) LEU] = gen_bleu; - if (HAVE_tstxf) - tst_optab->handlers[(int) XFmode].insn_code = CODE_FOR_tstxf; - if (HAVE_cmpxf) - cmp_optab->handlers[(int) XFmode].insn_code = CODE_FOR_cmpxf; - if (HAVE_extendsfxf2) - extendtab[(int) XFmode][(int) SFmode][0] = CODE_FOR_extendsfxf2; - if (HAVE_extenddfxf2) - extendtab[(int) XFmode][(int) DFmode][0] = CODE_FOR_extenddfxf2; - if (HAVE_floatsixf2) - floattab[(int) XFmode][(int) SImode][0] = CODE_FOR_floatsixf2; - if (HAVE_floathixf2) - floattab[(int) XFmode][(int) HImode][0] = CODE_FOR_floathixf2; - if (HAVE_floatqixf2) - floattab[(int) XFmode][(int) QImode][0] = CODE_FOR_floatqixf2; - if (HAVE_ftruncxf2) - ftrunc_optab->handlers[(int) XFmode].insn_code = CODE_FOR_ftruncxf2; - if (HAVE_fixxfqi2) - fixtab[(int) XFmode][(int) QImode][0] = CODE_FOR_fixxfqi2; - if (HAVE_fixxfhi2) - fixtab[(int) XFmode][(int) HImode][0] = CODE_FOR_fixxfhi2; - if (HAVE_fixxfsi2) - fixtab[(int) XFmode][(int) SImode][0] = CODE_FOR_fixxfsi2; - if (HAVE_addxf3) - add_optab->handlers[(int) XFmode].insn_code = CODE_FOR_addxf3; - if (HAVE_subxf3) - sub_optab->handlers[(int) XFmode].insn_code = CODE_FOR_subxf3; - if (HAVE_mulxf3) - smul_optab->handlers[(int) XFmode].insn_code = CODE_FOR_mulxf3; - if (HAVE_divxf3) - flodiv_optab->handlers[(int) XFmode].insn_code = CODE_FOR_divxf3; - if (HAVE_negxf2) - neg_optab->handlers[(int) XFmode].insn_code = CODE_FOR_negxf2; - if (HAVE_absxf2) - abs_optab->handlers[(int) XFmode].insn_code = CODE_FOR_absxf2; - if (HAVE_sqrtxf2) - sqrt_optab->handlers[(int) XFmode].insn_code = CODE_FOR_sqrtxf2; -} diff --git a/gnu/usr.bin/gcc2/arch/hp300/insn-output.c b/gnu/usr.bin/gcc2/arch/hp300/insn-output.c deleted file mode 100644 index 9e245d2e27fd..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/insn-output.c +++ /dev/null @@ -1,7822 +0,0 @@ -/* Generated automatically by the program `genoutput' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "regs.h" -#include "hard-reg-set.h" -#include "real.h" -#include "insn-config.h" - -#include "conditions.h" -#include "insn-flags.h" -#include "insn-attr.h" - -#include "insn-codes.h" - -#include "recog.h" - -#include -#include "output.h" - -static char * -output_0 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "fmove%.d %f1,%0"; - if (FPA_REG_P (operands[1])) - return "fpmove%.d %1, %x0"; - return output_move_double (operands); -} -} - -static char * -output_1 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return output_move_double (operands); -} -} - -static char * -output_2 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef ISI_OV - /* ISI's assembler fails to handle tstl a0. */ - if (! ADDRESS_REG_P (operands[0])) -#else - if (TARGET_68020 || ! ADDRESS_REG_P (operands[0])) -#endif - return "tst%.l %0"; - /* If you think that the 68020 does not support tstl a0, - reread page B-167 of the 68020 manual more carefully. */ - /* On an address reg, cmpw may replace cmpl. */ -#ifdef SGS_CMP_ORDER - return "cmp%.w %0,%#0"; -#else - return "cmp%.w %#0,%0"; -#endif -} -} - -static char * -output_7 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; - if (FP_REG_P (operands[0])) - return "ftst%.x %0"; - return "ftst%.s %0"; -} -} - -static char * -output_10 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; - if (FP_REG_P (operands[0])) - return "ftst%.x %0"; - return "ftst%.d %0"; -} -} - -static char * -output_11 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return "cmpm%.l %1,%0"; - if (REG_P (operands[1]) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return "cmp%.l %d1,%d0"; -#else - return "cmp%.l %d0,%d1"; -#endif - } -#ifdef SGS_CMP_ORDER - return "cmp%.l %d0,%d1"; -#else - return "cmp%.l %d1,%d0"; -#endif -} -} - -static char * -output_12 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return "cmpm%.w %1,%0"; - if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1])) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return "cmp%.w %d1,%d0"; -#else - return "cmp%.w %d0,%d1"; -#endif - } -#ifdef SGS_CMP_ORDER - return "cmp%.w %d0,%d1"; -#else - return "cmp%.w %d1,%d0"; -#endif -} -} - -static char * -output_13 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return "cmpm%.b %1,%0"; - if (REG_P (operands[1]) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return "cmp%.b %d1,%d0"; -#else - return "cmp%.b %d0,%d1"; -#endif - } -#ifdef SGS_CMP_ORDER - return "cmp%.b %d0,%d1"; -#else - return "cmp%.b %d1,%d0"; -#endif -} -} - -static char * -output_16 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return "fcmp%.x %0,%1"; - else - return "fcmp%.d %0,%f1"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.d %1,%f0"; -#else - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return "fcmp%.x %1,%0"; - else - return "fcmp%.d %f1,%0"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.d %f0,%1"; -#endif -} -} - -static char * -output_19 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fcmp%.x %0,%1"; - else - return "fcmp%.s %0,%f1"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.s %1,%f0"; -#else - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fcmp%.x %1,%0"; - else - return "fcmp%.s %f1,%0"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.s %f0,%1"; -#endif -} -} - -static char * -output_20 (operands, insn) - rtx *operands; - rtx insn; -{ - { return output_btst (operands, operands[1], operands[0], insn, 7); } -} - -static char * -output_21 (operands, insn) - rtx *operands; - rtx insn; -{ - { return output_btst (operands, operands[1], operands[0], insn, 31); } -} - -static char * -output_22 (operands, insn) - rtx *operands; - rtx insn; -{ - { return output_btst (operands, operands[1], operands[0], insn, 7); } -} - -static char * -output_23 (operands, insn) - rtx *operands; - rtx insn; -{ - { return output_btst (operands, operands[1], operands[0], insn, 31); } -} - -static char * -output_24 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[1] = gen_rtx (CONST_INT, VOIDmode, 7 - INTVAL (operands[1])); - return output_btst (operands, operands[1], operands[0], insn, 7); -} -} - -static char * -output_25 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM) - { - operands[0] = adj_offsettable_operand (operands[0], - INTVAL (operands[1]) / 8); - operands[1] = gen_rtx (CONST_INT, VOIDmode, - 7 - INTVAL (operands[1]) % 8); - return output_btst (operands, operands[1], operands[0], insn, 7); - } - operands[1] = gen_rtx (CONST_INT, VOIDmode, - 31 - INTVAL (operands[1])); - return output_btst (operands, operands[1], operands[0], insn, 31); -} -} - -static char * -output_26 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[1] == const0_rtx) - return "clr%.l %0"; - return "pea %a1"; -} -} - -static char * -output_27 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (ADDRESS_REG_P (operands[0])) - return "sub%.l %0,%0"; - /* moveq is faster on the 68000. */ - if (DATA_REG_P (operands[0]) && !TARGET_68020) -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %#0,%0"; -#else - return "moveq %#0,%0"; -#endif - return "clr%.l %0"; -} -} - -static char * -output_29 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (which_alternative == 3) - return "fpmove%.l %x1,fpa0\n\tfpmove%.l fpa0,%x0"; - if (FPA_REG_P (operands[1]) || FPA_REG_P (operands[0])) - return "fpmove%.l %x1,%x0"; - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return "clr%.l %0"; - else if (DATA_REG_P (operands[0]) - && INTVAL (operands[1]) < 128 - && INTVAL (operands[1]) >= -128) - { -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %1,%0"; -#else - return "moveq %1,%0"; -#endif - } -#ifndef NO_ADDSUB_Q - else if (DATA_REG_P (operands[0]) - /* Do this with a moveq #N-8, dreg; addq #8,dreg */ - && INTVAL (operands[1]) < 136 - && INTVAL (operands[1]) >= 128) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %1,%0\n\taddq%.w %#8,%0"; -#else - return "moveq %1,%0\n\taddq%.w %#8,%0"; -#endif - } - else if (DATA_REG_P (operands[0]) - /* Do this with a moveq #N+8, dreg; subq #8,dreg */ - && INTVAL (operands[1]) < -128 - && INTVAL (operands[1]) >= -136) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) + 8); -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %1,%0;subq%.w %#8,%0"; -#else - return "moveq %1,%0;subq%.w %#8,%0"; -#endif - } -#endif - else if (DATA_REG_P (operands[0]) - /* If N is in the right range and is even, then use - moveq #N/2, dreg; addl dreg,dreg */ - && INTVAL (operands[1]) > 127 - && INTVAL (operands[1]) <= 254 - && INTVAL (operands[1]) % 2 == 0) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) / 2); -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %1,%0\n\tadd%.w %0,%0"; -#else - return "moveq %1,%0\n\tadd%.w %0,%0"; -#endif - } - else if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return "move%.w %1,%0"; - else if (push_operand (operands[0], SImode) - && INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return "pea %a1"; - } - else if ((GET_CODE (operands[1]) == SYMBOL_REF - || GET_CODE (operands[1]) == CONST) - && push_operand (operands[0], SImode)) - return "pea %a1"; - else if ((GET_CODE (operands[1]) == SYMBOL_REF - || GET_CODE (operands[1]) == CONST) - && ADDRESS_REG_P (operands[0])) - return "lea %a1,%0"; - return "move%.l %1,%0"; -} -} - -static char * -output_30 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return "clr%.w %0"; - else if (DATA_REG_P (operands[0]) - && INTVAL (operands[1]) < 128 - && INTVAL (operands[1]) >= -128) - { -#if defined(MOTOROLA) && !defined(CRDS) - return "moveq%.l %1,%0"; -#else - return "moveq %1,%0"; -#endif - } - else if (INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return "move%.w %1,%0"; - } - else if (CONSTANT_P (operands[1])) - return "move%.l %1,%0"; -#ifndef SGS_NO_LI - /* Recognize the insn before a tablejump, one that refers - to a table of offsets. Such an insn will need to refer - to a label on the insn. So output one. Use the label-number - of the table of offsets to generate this label. */ - if (GET_CODE (operands[1]) == MEM - && GET_CODE (XEXP (operands[1], 0)) == PLUS - && (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF - || GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == LABEL_REF) - && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) != PLUS - && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) != PLUS) - { - rtx labelref; - if (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF) - labelref = XEXP (XEXP (operands[1], 0), 0); - else - labelref = XEXP (XEXP (operands[1], 0), 1); -#if defined (MOTOROLA) && !defined (SGS_SWITCH_TABLES) -#ifdef SGS - asm_fprintf (asm_out_file, "\tset %LLI%d,.+2\n", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#else /* not SGS */ - asm_fprintf (asm_out_file, "\t.set %LLI%d,.+2\n", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#endif /* not SGS */ -#else /* SGS_SWITCH_TABLES or not MOTOROLA */ - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LI", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#ifdef SGS_SWITCH_TABLES - /* Set flag saying we need to define the symbol - LD%n (with value L%n-LI%n) at the end of the switch table. */ - switch_table_difference_label_flag = 1; -#endif /* SGS_SWITCH_TABLES */ -#endif /* SGS_SWITCH_TABLES or not MOTOROLA */ - } -#endif /* SGS_NO_LI */ - return "move%.w %1,%0"; -} -} - -static char * -output_31 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return "clr%.w %0"; - } - return "move%.w %1,%0"; -} -} - -static char * -output_32 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xoperands[4]; - - /* This is probably useless, since it loses for pushing a struct - of several bytes a byte at a time. */ - if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC - && XEXP (XEXP (operands[0], 0), 0) == stack_pointer_rtx) - { - xoperands[1] = operands[1]; - xoperands[2] - = gen_rtx (MEM, QImode, - gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, const1_rtx)); - /* Just pushing a byte puts it in the high byte of the halfword. */ - /* We must put it in the low-order, high-numbered byte. */ - output_asm_insn ("move%.b %1,%-\n\tmove%.b %@,%2", xoperands); - return ""; - } - - /* Moving a byte into an address register is not possible. */ - /* Use d0 as an intermediate, but don't clobber its contents. */ - if (ADDRESS_REG_P (operands[0]) && GET_CODE (operands[1]) == MEM) - { - /* ??? For 2.5, don't allow this choice and use secondary reloads - instead. - - See if the address register is used in the address. If it - is, we have to generate a more complex sequence than those below. */ - if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1, - operands[1], NULL_RTX)) - { - /* See if the stack pointer is used in the address. If it isn't, - we can push d0 or d1 (the insn can't use both of them) on - the stack, perform our move into d0/d1, copy the byte from d0/1, - and pop d0/1. */ - if (! reg_mentioned_p (stack_pointer_rtx, operands[1])) - { - if (refers_to_regno_p (0, 1, operands[1], NULL_RTX)) - return "move%.l %/d0,%-\n\tmove%.b %1,%/d0\n\tmove%.l %/d0,%0\n\tmove%.l %+,%/d0"; - else - return "move%.l %/d1,%-\n\tmove%.b %1,%/d1\n\tmove%.l %/d1,%0\n\tmove%.l %+,%/d1"; - } - else - { - /* Otherwise, we know that d0 cannot be used in the address - (since sp and one address register is). Assume that sp is - being used as a base register and replace the address - register that is our operand[0] with d0. */ - rtx reg_map[FIRST_PSEUDO_REGISTER]; - int i; - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - reg_map[i] = 0; - - reg_map[REGNO (operands[0])] = gen_rtx (REG, Pmode, 0); - operands[1] = copy_rtx (operands[1]); - replace_regs (operands[1], reg_map, FIRST_PSEUDO_REGISTER, 0); - return "exg %/d0,%0\n\tmove%.b %1,%/d0\n\texg %/d0,%0"; - } - } - - /* If the address of operand 1 uses d0, choose d1 as intermediate. */ - if (refers_to_regno_p (0, 1, operands[1], NULL_RTX)) - return "exg %/d1,%0\n\tmove%.b %1,%/d1\n\texg %/d1,%0"; - /* Otherwise d0 is usable. - (An effective address on the 68k can't use two d-regs.) */ - else - return "exg %/d0,%0\n\tmove%.b %1,%/d0\n\texg %/d0,%0"; - } - - /* Likewise for moving from an address reg. */ - if (ADDRESS_REG_P (operands[1]) && GET_CODE (operands[0]) == MEM) - { - /* ??? For 2.5, don't allow this choice and use secondary reloads - instead. - - See if the address register is used in the address. If it - is, we have to generate a more complex sequence than those below. */ - if (refers_to_regno_p (REGNO (operands[1]), REGNO (operands[1]) + 1, - operands[0], NULL_RTX)) - { - /* See if the stack pointer is used in the address. If it isn't, - we can push d0 or d1 (the insn can't use both of them) on - the stack, copy the byte to d0/1, perform our move from d0/d1, - and pop d0/1. */ - if (! reg_mentioned_p (stack_pointer_rtx, operands[0])) - { - if (refers_to_regno_p (0, 1, operands[0], NULL_RTX)) - return "move%.l %/d0,%-\n\tmove%.l %1,%/d0\n\tmove%.b %/d0,%0\n\tmove%.l %+,%/d0"; - else - return "move%.l %/d1,%-\n\tmove%.l %1,%/d1\n\tmove%.b %/d1,%0\n\tmove%.l %+,%/d1"; - } - else - { - /* Otherwise, we know that d0 cannot be used in the address - (since sp and one address register is). Assume that sp is - being used as a base register and replace the address - register that is our operand[1] with d0. */ - rtx reg_map[FIRST_PSEUDO_REGISTER]; - int i; - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - reg_map[i] = 0; - - reg_map[REGNO (operands[1])] = gen_rtx (REG, Pmode, 0); - operands[0] = copy_rtx (operands[0]); - replace_regs (operands[0], reg_map, FIRST_PSEUDO_REGISTER, 0); - return "exg %/d0,%1\n\tmove%.b %/d0,%0\n\texg %/d0,%1"; - } - } - - if (refers_to_regno_p (0, 1, operands[0], NULL_RTX)) - return "exg %/d1,%1\n\tmove%.b %/d1,%0\n\texg %/d1,%1"; - else - return "exg %/d0,%1\n\tmove%.b %/d0,%0\n\texg %/d0,%1"; - } - - /* clr and st insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - if (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - if (operands[1] == const0_rtx) - return "clr%.b %0"; - if (GET_CODE (operands[1]) == CONST_INT - && INTVAL (operands[1]) == -1) - { - CC_STATUS_INIT; - return "st %0"; - } - } - if (GET_CODE (operands[1]) != CONST_INT && CONSTANT_P (operands[1])) - return "move%.l %1,%0"; - if (ADDRESS_REG_P (operands[0]) || ADDRESS_REG_P (operands[1])) - return "move%.w %1,%0"; - return "move%.b %1,%0"; -} -} - -static char * -output_33 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[1] == const0_rtx - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))) - return "clr%.b %0"; - return "move%.b %1,%0"; -} -} - -static char * -output_34 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (which_alternative >= 4) - return "fpmove%.s %1,fpa0\n\tfpmove%.s fpa0,%0"; - if (FPA_REG_P (operands[0])) - { - if (FPA_REG_P (operands[1])) - return "fpmove%.s %x1,%x0"; - else if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_single (operands); - else if (FP_REG_P (operands[1])) - return "fmove%.s %1,sp@-\n\tfpmove%.d sp@+, %0"; - return "fpmove%.s %x1,%x0"; - } - if (FPA_REG_P (operands[1])) - { - if (FP_REG_P (operands[0])) - return "fpmove%.s %x1,sp@-\n\tfmove%.s sp@+,%0"; - else - return "fpmove%.s %x1,%x0"; - } - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "f%$move%.x %1,%0"; - else if (ADDRESS_REG_P (operands[1])) - return "move%.l %1,%-\n\tf%$move%.s %+,%0"; - else if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_single (operands); - return "f%$move%.s %f1,%0"; - } - if (FP_REG_P (operands[1])) - { - if (ADDRESS_REG_P (operands[0])) - return "fmove%.s %1,%-\n\tmove%.l %+,%0"; - return "fmove%.s %f1,%0"; - } - return "move%.l %1,%0"; -} -} - -static char * -output_35 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (which_alternative == 6) - return "fpmove%.d %x1,fpa0\n\tfpmove%.d fpa0,%x0"; - if (FPA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - if (FP_REG_P (operands[1])) - return "fmove%.d %1,sp@-\n\tfpmove%.d sp@+,%x0"; - return "fpmove%.d %x1,%x0"; - } - else if (FPA_REG_P (operands[1])) - { - if (FP_REG_P(operands[0])) - return "fpmove%.d %x1,sp@-\n\tfmoved sp@+,%0"; - else - return "fpmove%.d %x1,%x0"; - } - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "f%&move%.x %1,%0"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn ("move%.l %1,%-", xoperands); - output_asm_insn ("move%.l %1,%-", operands); - return "f%&move%.d %+,%0"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - return "f%&move%.d %f1,%0"; - } - else if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn ("fmove%.d %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - else - return "fmove%.d %f1,%0"; - } - return output_move_double (operands); -} - -} - -static char * -output_37 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fmove%.x %1,%0"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2); - output_asm_insn ("move%.l %1,%-", xoperands); - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn ("move%.l %1,%-", xoperands); - output_asm_insn ("move%.l %1,%-", operands); - return "fmove%.x %+,%0"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return "fmove%.x %1,%0"; - return "fmove%.x %f1,%0"; - } - if (REG_P (operands[0])) - { - output_asm_insn ("fmove%.x %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - output_asm_insn ("move%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - return "fmove%.x %f1,%0"; -} - -} - -static char * -output_38 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fmove%.x %1,%0"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2); - output_asm_insn ("move%.l %1,%-", xoperands); - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn ("move%.l %1,%-", xoperands); - output_asm_insn ("move%.l %1,%-", operands); - return "fmove%.x %+,%0"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return "fmove%.x %1,%0"; - return "fmove%.x %f1,%0"; - } - if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn ("fmove%.x %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - output_asm_insn ("move%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - else - return "fmove%.x %f1,%0"; - } - return output_move_double (operands); -} - -} - -static char * -output_39 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (which_alternative == 8) - return "fpmove%.d %x1,fpa0\n\tfpmove%.d fpa0,%x0"; - if (FPA_REG_P (operands[0]) || FPA_REG_P (operands[1])) - return "fpmove%.d %x1,%x0"; - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return "fmove%.x %1,%0"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn ("move%.l %1,%-", xoperands); - output_asm_insn ("move%.l %1,%-", operands); - return "fmove%.d %+,%0"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - return "fmove%.d %f1,%0"; - } - else if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn ("fmove%.d %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - else - return "fmove%.d %f1,%0"; - } - return output_move_double (operands); -} - -} - -static char * -output_41 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return "move%.l %1,%0"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 3); - return "move%.b %1,%0"; -} -} - -static char * -output_42 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == REG - && (GET_CODE (operands[1]) == MEM - || GET_CODE (operands[1]) == CONST_INT)) - { - /* Must clear condition codes, since the move.w bases them on - the entire 16 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return "move%.w %1,%0"; - } - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return "move%.l %1,%0"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 1); - return "move%.b %1,%0"; -} -} - -static char * -output_43 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return "move%.l %1,%0"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 2); - return "move%.w %1,%0"; -} -} - -static char * -output_47 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return "and%.l %#0xFFFF,%0"; - if (reg_mentioned_p (operands[0], operands[1])) - return "move%.w %1,%0\n\tand%.l %#0xFFFF,%0"; - return "clr%.l %0\n\tmove%.w %1,%0"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - return "move%.w %1,%0\n\tclr%.w %0"; - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - return "clr%.w %0\n\tmove%.w %1,%0"; - else - { - output_asm_insn ("clr%.w %0", operands); - operands[0] = adj_offsettable_operand (operands[0], 2); - return "move%.w %1,%0"; - } -} -} - -static char * -output_48 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return "and%.w %#0xFF,%0"; - if (reg_mentioned_p (operands[0], operands[1])) - return "move%.b %1,%0\n\tand%.w %#0xFF,%0"; - return "clr%.w %0\n\tmove%.b %1,%0"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - { - if (REGNO (XEXP (XEXP (operands[0], 0), 0)) - == STACK_POINTER_REGNUM) - { - output_asm_insn ("clr%.w %-", operands); - operands[0] = gen_rtx (MEM, GET_MODE (operands[0]), - plus_constant (stack_pointer_rtx, 1)); - return "move%.b %1,%0"; - } - else - return "move%.b %1,%0\n\tclr%.b %0"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - return "clr%.b %0\n\tmove%.b %1,%0"; - else - { - output_asm_insn ("clr%.b %0", operands); - operands[0] = adj_offsettable_operand (operands[0], 1); - return "move%.b %1,%0"; - } -} -} - -static char * -output_49 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return "and%.l %#0xFF,%0"; - if (reg_mentioned_p (operands[0], operands[1])) - return "move%.b %1,%0\n\tand%.l %#0xFF,%0"; - return "clr%.l %0\n\tmove%.b %1,%0"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - { - operands[0] = XEXP (XEXP (operands[0], 0), 0); -#ifdef MOTOROLA -#ifdef SGS - return "clr%.l -(%0)\n\tmove%.b %1,3(%0)"; -#else - return "clr%.l -(%0)\n\tmove%.b %1,(3,%0)"; -#endif -#else - return "clrl %0@-\n\tmoveb %1,%0@(3)"; -#endif - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - { - operands[0] = XEXP (XEXP (operands[0], 0), 0); -#ifdef MOTOROLA -#ifdef SGS - return "clr%.l (%0)+\n\tmove%.b %1,-1(%0)"; -#else - return "clr%.l (%0)+\n\tmove%.b %1,(-1,%0)"; -#endif -#else - return "clrl %0@+\n\tmoveb %1,%0@(-1)"; -#endif - } - else - { - output_asm_insn ("clr%.l %0", operands); - operands[0] = adj_offsettable_operand (operands[0], 3); - return "move%.b %1,%0"; - } -} -} - -static char * -output_50 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (ADDRESS_REG_P (operands[0])) - return "move%.w %1,%0"; - return "ext%.l %0"; -} -} - -static char * -output_55 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return ""; - } - return "f%&move%.x %1,%0"; - } - if (FP_REG_P (operands[0])) - return "f%&move%.s %f1,%0"; - if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - output_asm_insn ("fmove%.d %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - return "fmove%.d %f1,%0"; -} -} - -static char * -output_58 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "f%$move%.x %1,%0"; - return "f%$move%.d %f1,%0"; -} -} - -static char * -output_70 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "fmovem%.l %!,%2\n\tmoveq %#16,%3\n\tor%.l %2,%3\n\tand%.w %#-33,%3\n\tfmovem%.l %3,%!\n\tfmove%.l %1,%0\n\tfmovem%.l %2,%!"; -} -} - -static char * -output_71 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "fmovem%.l %!,%2\n\tmoveq %#16,%3\n\tor%.l %2,%3\n\tand%.w %#-33,%3\n\tfmovem%.l %3,%!\n\tfmove%.w %1,%0\n\tfmovem%.l %2,%!"; -} -} - -static char * -output_72 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "fmovem%.l %!,%2\n\tmoveq %#16,%3\n\tor%.l %2,%3\n\tand%.w %#-33,%3\n\tfmovem%.l %3,%!\n\tfmove%.b %1,%0\n\tfmovem%.l %2,%!"; -} -} - -static char * -output_73 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "fintrz%.x %f1,%0"; - return "fintrz%.d %f1,%0"; -} -} - -static char * -output_74 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "fintrz%.x %f1,%0"; - return "fintrz%.s %f1,%0"; -} -} - -static char * -output_83 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (! operands_match_p (operands[0], operands[1])) - { - if (!ADDRESS_REG_P (operands[1])) - { - rtx tmp = operands[1]; - - operands[1] = operands[2]; - operands[2] = tmp; - } - - /* These insns can result from reloads to access - stack slots over 64k from the frame pointer. */ - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) + 0x8000 >= (unsigned) 0x10000) - return "move%.l %2,%0\n\tadd%.l %1,%0"; -#ifdef SGS - if (GET_CODE (operands[2]) == REG) - return "lea 0(%1,%2.l),%0"; - else - return "lea %c2(%1),%0"; -#else /* not SGS */ -#ifdef MOTOROLA - if (GET_CODE (operands[2]) == REG) - return "lea (%1,%2.l),%0"; - else - return "lea (%c2,%1),%0"; -#else /* not MOTOROLA (MIT syntax) */ - if (GET_CODE (operands[2]) == REG) - return "lea %1@(0,%2:l),%0"; - else - return "lea %1@(%c2),%0"; -#endif /* not MOTOROLA */ -#endif /* not SGS */ - } - if (GET_CODE (operands[2]) == CONST_INT) - { -#ifndef NO_ADDSUB_Q - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return (ADDRESS_REG_P (operands[0]) - ? "addq%.w %2,%0" - : "addq%.l %2,%0"); - if (INTVAL (operands[2]) < 0 - && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2])); - return (ADDRESS_REG_P (operands[0]) - ? "subq%.w %2,%0" - : "subq%.l %2,%0"); - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw.*/ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return "addq%.w %#8,%0\n\taddq%.w %2,%0"; - } - if (INTVAL (operands[2]) < -8 - && INTVAL (operands[2]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2]) - 8); - return "subq%.w %#8,%0\n\tsubq%.w %2,%0"; - } -#endif - if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[2]) >= -0x8000 - && INTVAL (operands[2]) < 0x8000) - return "add%.w %2,%0"; - } - return "add%.l %2,%0"; -} -} - -static char * -output_85 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[2]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[2]) >= 32768) - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) - 65536); - - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return "addq%.w %2,%0"; - if (INTVAL (operands[2]) < 0 - && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2])); - return "subq%.w %2,%0"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return "addq%.w %#8,%0\n\taddq%.w %2,%0"; - } - if (INTVAL (operands[2]) < -8 - && INTVAL (operands[2]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2]) - 8); - return "subq%.w %#8,%0\n\tsubq%.w %2,%0"; - } - } -#endif - return "add%.w %2,%0"; -} -} - -static char * -output_86 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[1]) >= 32768) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 65536); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return "addq%.w %1,%0"; - if (INTVAL (operands[1]) < 0 - && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1])); - return "subq%.w %1,%0"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[1]) > 8 - && INTVAL (operands[1]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); - return "addq%.w %#8,%0\n\taddq%.w %1,%0"; - } - if (INTVAL (operands[1]) < -8 - && INTVAL (operands[1]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1]) - 8); - return "subq%.w %#8,%0\n\tsubq%.w %1,%0"; - } - } -#endif - return "add%.w %1,%0"; -} -} - -static char * -output_87 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[1]) >= 32768) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 65536); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return "addq%.w %1,%0"; - if (INTVAL (operands[1]) < 0 - && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1])); - return "subq%.w %1,%0"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[1]) > 8 - && INTVAL (operands[1]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); - return "addq%.w %#8,%0\n\taddq%.w %1,%0"; - } - if (INTVAL (operands[1]) < -8 - && INTVAL (operands[1]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1]) - 8); - return "subq%.w %#8,%0\n\tsubq%.w %1,%0"; - } - } -#endif - return "add%.w %1,%0"; -} -} - -static char * -output_88 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[2]) == CONST_INT) - { - if (INTVAL (operands[2]) >= 128) - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) - 256); - - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return "addq%.b %2,%0"; - if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2])); - return "subq%.b %2,%0"; - } - } -#endif - return "add%.b %2,%0"; -} -} - -static char * -output_89 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) >= 128) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 256); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return "addq%.b %1,%0"; - if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1])); - return "subq%.b %1,%0"; - } - } -#endif - return "add%.b %1,%0"; -} -} - -static char * -output_90 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) >= 128) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 256); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return "addq%.b %1,%0"; - if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1])); - return "subq%.b %1,%0"; - } - } -#endif - return "add%.b %1,%0"; -} -} - -static char * -output_92 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[1])) - return "fpadd%.d %y2,%0"; - if (rtx_equal_p (operands[0], operands[2])) - return "fpadd%.d %y1,%0"; - if (which_alternative == 0) - return "fpadd3%.d %w2,%w1,%0"; - return "fpadd3%.d %x2,%x1,%0"; -} -} - -static char * -output_93 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "f%&add%.x %2,%0"; - return "f%&add%.d %f2,%0"; -} -} - -static char * -output_95 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[1])) - return "fpadd%.s %w2,%0"; - if (rtx_equal_p (operands[0], operands[2])) - return "fpadd%.s %w1,%0"; - if (which_alternative == 0) - return "fpadd3%.s %w2,%w1,%0"; - return "fpadd3%.s %2,%1,%0"; -} -} - -static char * -output_96 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return "f%$add%.x %2,%0"; - return "f%$add%.s %f2,%0"; -} -} - -static char * -output_97 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (! operands_match_p (operands[0], operands[1])) - { - if (operands_match_p (operands[0], operands[2])) - { -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return "subq%.l %1,%0\n\tneg%.l %0"; - } -#endif - return "sub%.l %1,%0\n\tneg%.l %0"; - } - /* This case is matched by J, but negating -0x8000 - in an lea would give an invalid displacement. - So do this specially. */ - if (INTVAL (operands[2]) == -0x8000) - return "move%.l %1,%0\n\tsub%.l %2,%0"; -#ifdef SGS - return "lea %n2(%1),%0"; -#else -#ifdef MOTOROLA - return "lea (%n2,%1),%0"; -#else /* not MOTOROLA (MIT syntax) */ - return "lea %1@(%n2),%0"; -#endif /* not MOTOROLA */ -#endif /* not SGS */ - } - if (GET_CODE (operands[2]) == CONST_INT) - { -#ifndef NO_ADDSUB_Q - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return "subq%.l %2,%0"; - /* Using two subqw for 8 < N <= 16 being subtracted from an - address register is faster on all but 68000 */ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return "subq%.w %#8,%0\n\tsubq%.w %2,%0"; - } -#endif - if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[2]) >= -0x8000 - && INTVAL (operands[2]) < 0x8000) - return "sub%.w %2,%0"; - } - return "sub%.l %2,%0"; -} -} - -static char * -output_104 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[2])) - return "fprsub%.d %y1,%0"; - if (rtx_equal_p (operands[0], operands[1])) - return "fpsub%.d %y2,%0"; - if (which_alternative == 0) - return "fpsub3%.d %w2,%w1,%0"; - return "fpsub3%.d %x2,%x1,%0"; -} -} - -static char * -output_105 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "f%&sub%.x %2,%0"; - return "f%&sub%.d %f2,%0"; -} -} - -static char * -output_107 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[2])) - return "fprsub%.s %w1,%0"; - if (rtx_equal_p (operands[0], operands[1])) - return "fpsub%.s %w2,%0"; - if (which_alternative == 0) - return "fpsub3%.s %w2,%w1,%0"; - return "fpsub3%.s %2,%1,%0"; -} -} - -static char * -output_108 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return "f%$sub%.x %2,%0"; - return "f%$sub%.s %f2,%0"; -} -} - -static char * -output_109 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if defined(MOTOROLA) && !defined(CRDS) - return "muls%.w %2,%0"; -#else - return "muls %2,%0"; -#endif -} -} - -static char * -output_110 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if defined(MOTOROLA) && !defined(CRDS) - return "muls%.w %2,%0"; -#else - return "muls %2,%0"; -#endif -} -} - -static char * -output_111 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if defined(MOTOROLA) && !defined(CRDS) - return "muls%.w %2,%0"; -#else - return "muls %2,%0"; -#endif -} -} - -static char * -output_113 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if defined(MOTOROLA) && !defined(CRDS) - return "mulu%.w %2,%0"; -#else - return "mulu %2,%0"; -#endif -} -} - -static char * -output_114 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if defined(MOTOROLA) && !defined(CRDS) - return "mulu%.w %2,%0"; -#else - return "mulu %2,%0"; -#endif -} -} - -static char * -output_122 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[1], operands[2])) - return "fpsqr%.d %y1,%0"; - if (rtx_equal_p (operands[0], operands[1])) - return "fpmul%.d %y2,%0"; - if (rtx_equal_p (operands[0], operands[2])) - return "fpmul%.d %y1,%0"; - if (which_alternative == 0) - return "fpmul3%.d %w2,%w1,%0"; - return "fpmul3%.d %x2,%x1,%0"; -} -} - -static char * -output_123 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_DOUBLE - && floating_exact_log2 (operands[2]) && !TARGET_68040) - { - int i = floating_exact_log2 (operands[2]); - operands[2] = gen_rtx (CONST_INT, VOIDmode, i); - return "fscale%.l %2,%0"; - } - if (REG_P (operands[2])) - return "f%&mul%.x %2,%0"; - return "f%&mul%.d %f2,%0"; -} -} - -static char * -output_125 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[1], operands[2])) - return "fpsqr%.s %w1,%0"; - if (rtx_equal_p (operands[0], operands[1])) - return "fpmul%.s %w2,%0"; - if (rtx_equal_p (operands[0], operands[2])) - return "fpmul%.s %w1,%0"; - if (which_alternative == 0) - return "fpmul3%.s %w2,%w1,%0"; - return "fpmul3%.s %2,%1,%0"; -} -} - -static char * -output_126 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef FSGLMUL_USE_S - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? "fsmul%.s %2,%0" - : "fsglmul%.s %2,%0"); -#else - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? "fsmul%.x %2,%0" - : "fsglmul%.x %2,%0"); -#endif - return (TARGET_68040_ONLY - ? "fsmul%.s %f2,%0" - : "fsglmul%.s %f2,%0"); -} -} - -static char * -output_127 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "ext%.l %0\n\tdivs%.w %2,%0"; -#else - return "extl %0\n\tdivs %2,%0"; -#endif -} -} - -static char * -output_128 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "divs%.w %2,%0"; -#else - return "divs %2,%0"; -#endif -} -} - -static char * -output_129 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "divs%.w %2,%0"; -#else - return "divs %2,%0"; -#endif -} -} - -static char * -output_130 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "and%.l %#0xFFFF,%0\n\tdivu%.w %2,%0"; -#else - return "andl %#0xFFFF,%0\n\tdivu %2,%0"; -#endif -} -} - -static char * -output_131 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "divu%.w %2,%0"; -#else - return "divu %2,%0"; -#endif -} -} - -static char * -output_132 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - return "divu%.w %2,%0"; -#else - return "divu %2,%0"; -#endif -} -} - -static char * -output_134 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[2])) - return "fprdiv%.d %y1,%0"; - if (rtx_equal_p (operands[0], operands[1])) - return "fpdiv%.d %y2,%0"; - if (which_alternative == 0) - return "fpdiv3%.d %w2,%w1,%0"; - return "fpdiv3%.d %x2,%x1,%x0"; -} -} - -static char * -output_135 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "f%&div%.x %2,%0"; - return "f%&div%.d %f2,%0"; -} -} - -static char * -output_137 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (rtx_equal_p (operands[0], operands[1])) - return "fpdiv%.s %w2,%0"; - if (rtx_equal_p (operands[0], operands[2])) - return "fprdiv%.s %w1,%0"; - if (which_alternative == 0) - return "fpdiv3%.s %w2,%w1,%0"; - return "fpdiv3%.s %2,%1,%0"; -} -} - -static char * -output_138 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef FSGLDIV_USE_S - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? "fsdiv%.s %2,%0" - : "fsgldiv%.s %2,%0"); -#else - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? "fsdiv%.x %2,%0" - : "fsgldiv%.x %2,%0"); -#endif - return (TARGET_68040_ONLY - ? "fsdiv%.s %f2,%0" - : "fsgldiv%.s %f2,%0"); -} -} - -static char * -output_139 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "ext%.l %0\n\tdivs%.w %2,%0\n\tswap %0"; -#else - return "extl %0\n\tdivs %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_140 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "divs%.w %2,%0\n\tswap %0"; -#else - return "divs %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_141 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "divs%.w %2,%0\n\tswap %0"; -#else - return "divs %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_142 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "and%.l %#0xFFFF,%0\n\tdivu%.w %2,%0\n\tswap %0"; -#else - return "andl %#0xFFFF,%0\n\tdivu %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_143 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "divu%.w %2,%0\n\tswap %0"; -#else - return "divu %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_144 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return "divu%.w %2,%0\n\tswap %0"; -#else - return "divu %2,%0\n\tswap %0"; -#endif -} -} - -static char * -output_145 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (find_reg_note (insn, REG_UNUSED, operands[3])) - return "divs%.l %2,%0"; - else - return "divsl%.l %2,%3:%0"; -} -} - -static char * -output_146 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (find_reg_note (insn, REG_UNUSED, operands[3])) - return "divu%.l %2,%0"; - else - return "divul%.l %2,%3:%0"; -} -} - -static char * -output_147 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - int logval; - if (GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) | 0xffff) == 0xffffffff - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (GET_CODE (operands[0]) != REG) - operands[0] = adj_offsettable_operand (operands[0], 2); - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) & 0xffff); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - if (operands[2] == const0_rtx) - return "clr%.w %0"; - return "and%.w %2,%0"; - } - if (GET_CODE (operands[2]) == CONST_INT - && (logval = exact_log2 (~ INTVAL (operands[2]))) >= 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval); - } - else - { - operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8)); operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8); - } - /* This does not set condition codes in a standard way. */ - CC_STATUS_INIT; - return "bclr %1,%0"; - } - return "and%.l %2,%0"; -} -} - -static char * -output_154 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - register int logval; - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) >> 16 == 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (GET_CODE (operands[0]) != REG) - operands[0] = adj_offsettable_operand (operands[0], 2); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - return "or%.w %2,%0"; - } - if (GET_CODE (operands[2]) == CONST_INT - && (logval = exact_log2 (INTVAL (operands[2]))) >= 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval); - } - else - { - operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8)); - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8); - } - CC_STATUS_INIT; - return "bset %1,%0"; - } - return "or%.l %2,%0"; -} -} - -static char * -output_161 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) >> 16 == 0 - && (offsettable_memref_p (operands[0]) || DATA_REG_P (operands[0]))) - { - if (! DATA_REG_P (operands[0])) - operands[0] = adj_offsettable_operand (operands[0], 2); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - return "eor%.w %2,%0"; - } - return "eor%.l %2,%0"; -} -} - -static char * -output_175 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, 31); - return "bchg %1,%0"; - } - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "f%$neg%.x %1,%0"; - return "f%$neg%.s %f1,%0"; -} -} - -static char * -output_178 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, 31); - return "bchg %1,%0"; - } - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "f%&neg%.x %1,%0"; - return "f%&neg%.d %f1,%0"; -} -} - -static char * -output_179 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "fsqrt%.x %1,%0"; - else - return "fsqrt%.d %1,%0"; -} -} - -static char * -output_182 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "f%$abs%.x %1,%0"; - return "f%$abs%.s %f1,%0"; -} -} - -static char * -output_185 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "f%&abs%.x %1,%0"; - return "f%&abs%.d %f1,%0"; -} -} - -static char * -output_191 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "swap %0\n\tclr%.w %0"; -} -} - -static char * -output_192 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return "asl%.w %2,%0\n\tswap %0\n\tclr%.w %0"; -} -} - -static char * -output_193 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[2] == const1_rtx) - return "add%.l %0,%0"; - return "asl%.l %2,%0"; -} -} - -static char * -output_199 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return "swap %0\n\tasr%.w %2,%0\n\text%.l %0"; -} -} - -static char * -output_200 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return "asr%.l %2,%0"; -} -} - -static char * -output_205 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "swap %0\n\tclr%.w %0"; -} -} - -static char * -output_206 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return "lsl%.w %2,%0\n\tswap %0\n\tclr%.w %0"; -} -} - -static char * -output_207 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[2] == const1_rtx) - return "add%.l %0,%0"; - return "lsl%.l %2,%0"; -} -} - -static char * -output_212 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "clr%.w %0\n\tswap %0"; -} -} - -static char * -output_213 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* I think lsr%.w sets the CC properly. */ - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return "clr%.w %0\n\tswap %0\n\tlsr%.w %2,%0"; -} -} - -static char * -output_214 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return "lsr%.l %2,%0"; -} -} - -static char * -output_229 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[0] - = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8); - - return "move%.l %3,%0"; -} -} - -static char * -output_230 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0])) - { - if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32) - return "bfins %3,%0{%b2:%b1}"; - } - else - operands[0] - = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8); - - if (GET_CODE (operands[3]) == MEM) - operands[3] = adj_offsettable_operand (operands[3], - (32 - INTVAL (operands[1])) / 8); - if (INTVAL (operands[1]) == 8) - return "move%.b %3,%0"; - return "move%.w %3,%0"; -} -} - -static char * -output_231 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - return "move%.l %1,%0"; -} -} - -static char * -output_232 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags |= CC_NOT_NEGATIVE; - if (REG_P (operands[1])) - { - if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32) - return "bfextu %1{%b3:%b2},%0"; - } - else - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - output_asm_insn ("clr%.l %0", operands); - if (GET_CODE (operands[0]) == MEM) - operands[0] = adj_offsettable_operand (operands[0], - (32 - INTVAL (operands[1])) / 8); - if (INTVAL (operands[2]) == 8) - return "move%.b %1,%0"; - return "move%.w %1,%0"; -} -} - -static char * -output_233 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - return "move%.l %1,%0"; -} -} - -static char * -output_234 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[1])) - { - if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32) - return "bfexts %1{%b3:%b2},%0"; - } - else - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - if (INTVAL (operands[2]) == 8) - return "move%.b %1,%0\n\textb%.l %0"; - return "move%.w %1,%0\n\text%.l %0"; -} -} - -static char * -output_236 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags |= CC_NOT_NEGATIVE; - return "bfextu %1{%b3:%b2},%0"; -} -} - -static char * -output_237 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "bfchg %0{%b2:%b1}"; -} -} - -static char * -output_238 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "bfclr %0{%b2:%b1}"; -} -} - -static char * -output_239 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "bfset %0{%b2:%b1}"; -} -} - -static char * -output_242 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags |= CC_NOT_NEGATIVE; - return "bfextu %1{%b3:%b2},%0"; -} -} - -static char * -output_243 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "bfclr %0{%b2:%b1}"; -} -} - -static char * -output_244 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - return "bfset %0{%b2:%b1}"; -} -} - -static char * -output_245 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#if 0 - /* These special cases are now recognized by a specific pattern. */ - if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16) - return "move%.w %3,%0"; - if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8) - return "move%.b %3,%0"; -#endif - return "bfins %3,%0{%b2:%b1}"; -} -} - -static char * -output_246 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[1] == const1_rtx - && GET_CODE (operands[2]) == CONST_INT) - { - int width = GET_CODE (operands[0]) == REG ? 31 : 7; - return output_btst (operands, - gen_rtx (CONST_INT, VOIDmode, - width - INTVAL (operands[2])), - operands[0], - insn, 1000); - /* Pass 1000 as SIGNPOS argument so that btst will - not think we are testing the sign bit for an `and' - and assume that nonzero implies a negative result. */ - } - if (INTVAL (operands[1]) != 32) - cc_status.flags = CC_NOT_NEGATIVE; - return "bftst %0{%b2:%b1}"; -} -} - -static char * -output_247 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[1] == const1_rtx - && GET_CODE (operands[2]) == CONST_INT) - { - int width = GET_CODE (operands[0]) == REG ? 31 : 7; - return output_btst (operands, - gen_rtx (CONST_INT, VOIDmode, - width - INTVAL (operands[2])), - operands[0], - insn, 1000); - /* Pass 1000 as SIGNPOS argument so that btst will - not think we are testing the sign bit for an `and' - and assume that nonzero implies a negative result. */ - } - if (INTVAL (operands[1]) != 32) - cc_status.flags = CC_NOT_NEGATIVE; - return "bftst %0{%b2:%b1}"; -} -} - -static char * -output_248 (operands, insn) - rtx *operands; - rtx insn; -{ - - cc_status = cc_prev_status; - OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0"); - -} - -static char * -output_249 (operands, insn) - rtx *operands; - rtx insn; -{ - - cc_status = cc_prev_status; - OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0"); - -} - -static char * -output_250 (operands, insn) - rtx *operands; - rtx insn; -{ - - cc_status = cc_prev_status; - OUTPUT_JUMP ("sgt %0", "fsgt %0", 0); - -} - -static char * -output_251 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - return "shi %0"; -} - -static char * -output_252 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0"); -} - -static char * -output_253 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - return "scs %0"; -} - -static char * -output_254 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0"); -} - -static char * -output_255 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - return "scc %0"; -} - -static char * -output_256 (operands, insn) - rtx *operands; - rtx insn; -{ - - cc_status = cc_prev_status; - OUTPUT_JUMP ("sle %0", "fsle %0", 0); - -} - -static char * -output_257 (operands, insn) - rtx *operands; - rtx insn; -{ - cc_status = cc_prev_status; - return "sls %0"; -} - -static char * -output_258 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0"); -#else - OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0"); -#endif -} -} - -static char * -output_259 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0"); -#else - OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0"); -#endif -} -} - -static char * -output_260 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jbgt %l0", "fbgt %l0", 0); -#else - OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0); -#endif - -} - -static char * -output_261 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbhi %l0"; -#else - return "jhi %l0"; -#endif - -} - -static char * -output_262 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jblt %l0", "fblt %l0", "jbmi %l0"); -#else - OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0"); -#endif - -} - -static char * -output_263 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbcs %l0"; -#else - return "jcs %l0"; -#endif - -} - -static char * -output_264 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jbge %l0", "fbge %l0", "jbpl %l0"); -#else - OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0"); -#endif - -} - -static char * -output_265 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbcc %l0"; -#else - return "jcc %l0"; -#endif - -} - -static char * -output_266 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jble %l0", "fble %l0", 0); -#else - OUTPUT_JUMP ("jle %l0", "fjle %l0", 0); -#endif - -} - -static char * -output_267 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbls %l0"; -#else - return "jls %l0"; -#endif - -} - -static char * -output_268 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0"); -#else - OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0"); -#endif -} -} - -static char * -output_269 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef MOTOROLA - OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0"); -#else - OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0"); -#endif -} -} - -static char * -output_270 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jble %l0", "fbngt %l0", 0); -#else - OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0); -#endif - -} - -static char * -output_271 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbls %l0"; -#else - return "jls %l0"; -#endif - -} - -static char * -output_272 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jbge %l0", "fbnlt %l0", "jbpl %l0"); -#else - OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0"); -#endif - -} - -static char * -output_273 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbcc %l0"; -#else - return "jcc %l0"; -#endif - -} - -static char * -output_274 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jblt %l0", "fbnge %l0", "jbmi %l0"); -#else - OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0"); -#endif - -} - -static char * -output_275 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbcs %l0"; -#else - return "jcs %l0"; -#endif - -} - -static char * -output_276 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - OUTPUT_JUMP ("jbgt %l0", "fbnle %l0", 0); -#else - OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0); -#endif - -} - -static char * -output_277 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbhi %l0"; -#else - return "jhi %l0"; -#endif - -} - -static char * -output_278 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jbra %l0"; -#else - return "jra %l0"; -#endif - -} - -static char * -output_280 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jmp (%0)"; -#else - return "jmp %0@"; -#endif - -} - -static char * -output_281 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef ASM_RETURN_CASE_JUMP - ASM_RETURN_CASE_JUMP; -#else -#ifdef SGS -#ifdef ASM_OUTPUT_CASE_LABEL - return "jmp 6(%%pc,%0.w)"; -#else -#ifdef CRDS - return "jmp 2(pc,%0.w)"; -#else - return "jmp 2(%%pc,%0.w)"; -#endif /* end !CRDS */ -#endif -#else /* not SGS */ -#ifdef MOTOROLA - return "jmp (2,pc,%0.w)"; -#else - return "jmp pc@(2,%0:w)"; -#endif -#endif -#endif - -} - -static char * -output_282 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1"; - if (GET_CODE (operands[0]) == MEM) - { -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - return "sub%.w %#1,%0\n\tjbcc %l1"; -#else - return "subq%.w %#1,%0\n\tjbcc %l1"; -#endif -#else /* not MOTOROLA */ - return "subqw %#1,%0\n\tjcc %l1"; -#endif - } -#ifdef MOTOROLA -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return "sub%.w %#1,%0\n\tcmp%.w %0,%#-1\n\tjbne %l1"; -#else - return "subq%.w %#1,%0\n\tcmp%.w %0,%#-1\n\tjbne %l1"; -#endif -#else /* not SGS_CMP_ORDER */ - return "subq%.w %#1,%0\n\tcmp%.w %#-1,%0\n\tjbne %l1"; -#endif -#else /* not MOTOROLA */ - return "subqw %#1,%0\n\tcmpw %#-1,%0\n\tjne %l1"; -#endif -} -} - -static char * -output_283 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsub%.l %#1,%0\n\tjbcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "sub%.l %#1,%0\n\tjbcc %l1"; -#else - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsubq%.l %#1,%0\n\tjbcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "subq%.l %#1,%0\n\tjbcc %l1"; -#endif /* NO_ADDSUB_Q */ -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return "sub.l %#1,%0\n\tcmp.l %0,%#-1\n\tjbne %l1"; -#else - return "subq.l %#1,%0\n\tcmp.l %0,%#-1\n\tjbne %l1"; -#endif -#else /* not SGS_CMP_ORDER */ - return "subq.l %#1,%0\n\tcmp.l %#-1,%0\n\tjbne %l1"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsubql %#1,%0\n\tjcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "subql %#1,%0\n\tjcc %l1"; - return "subql %#1,%0\n\tcmpl %#-1,%0\n\tjne %l1"; -#endif /* not MOTOROLA */ -} -} - -static char * -output_284 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1"; - if (GET_CODE (operands[0]) == MEM) - return "sub%.w %#1,%0\n\tjbcc %l1"; -#else - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1"; - if (GET_CODE (operands[0]) == MEM) - return "subq%.w %#1,%0\n\tjbcc %l1"; -#endif -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return "sub.w %#1,%0\n\tcmp.w %0,%#-1\n\tjbne %l1"; -#else - return "subq.w %#1,%0\n\tcmp.w %0,%#-1\n\tjbne %l1"; -#endif -#else /* not SGS_CMP_ORDER */ - return "subq.w %#1,%0\n\tcmp.w %#-1,%0\n\tjbne %l1"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1"; - if (GET_CODE (operands[0]) == MEM) - return "subqw %#1,%0\n\tjcc %l1"; - return "subqw %#1,%0\n\tcmpw %#-1,%0\n\tjne %l1"; -#endif /* not MOTOROLA */ -} -} - -static char * -output_285 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsub%.l %#1,%0\n\tjbcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "sub%.l %#1,%0\n\tjbcc %l1"; -#else - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsubq%.l %#1,%0\n\tjbcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "subq%.l %#1,%0\n\tjbcc %l1"; -#endif -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return "sub.l %#1,%0\n\tcmp.l %0,%#-1\n\tjbne %l1"; -#else - return "subq.l %#1,%0\n\tcmp.l %0,%#-1\n\tjbne %l1"; -#endif -#else /* not SGS_CMP_ORDER */ - return "subq.l %#1,%0\n\tcmp.l %#-1,%0\n\tjbne %l1"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return "dbra %0,%l1\n\tclr%.w %0\n\tsubql %#1,%0\n\tjcc %l1"; - if (GET_CODE (operands[0]) == MEM) - return "subql %#1,%0\n\tjcc %l1"; - return "subql %#1,%0\n\tcmpl %#-1,%0\n\tjne %l1"; -#endif /* not MOTOROLA */ -} -} - -static char * -output_287 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jsr %0"; -#else - return "jbsr %0"; -#endif - -} - -static char * -output_288 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF) - return "bsr %0@PLTPC"; -#endif - return "jsr %0"; - -} - -static char * -output_290 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - return "jsr %1"; -#else - return "jbsr %1"; -#endif - -} - -static char * -output_291 (operands, insn) - rtx *operands; - rtx insn; -{ - -#ifdef MOTOROLA - if (GET_CODE (operands[1]) == MEM - && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF) - return "bsr %1@PLTPC"; -#endif - return "jsr %1"; - -} - -static char * -output_295 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[0] = gen_rtx (PLUS, SImode, stack_pointer_rtx, - gen_rtx (CONST_INT, VOIDmode, NEED_PROBE)); - return "tstl %a0"; -} -} - -static char * -output_296 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (current_function_pops_args == 0) - return "rts"; - operands[0] = gen_rtx (CONST_INT, VOIDmode, current_function_pops_args); - return "rtd %0"; -} -} - -static char * -output_299 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn ("move%.l %1,%@", xoperands); - output_asm_insn ("move%.l %1,%-", operands); - return "fmove%.d %+,%0"; -} - -} - -static char * -output_300 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (INTVAL (operands[0]) > 4) - { - rtx xoperands[2]; - xoperands[0] = stack_pointer_rtx; - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4); -#ifndef NO_ADDSUB_Q - if (INTVAL (xoperands[1]) <= 8) - output_asm_insn ("addq%.w %1,%0", xoperands); - else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020) - { - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (xoperands[1]) - 8); - output_asm_insn ("addq%.w %#8,%0\n\taddq%.w %1,%0", xoperands); - } - else -#endif - if (INTVAL (xoperands[1]) <= 0x7FFF) - output_asm_insn ("add%.w %1,%0", xoperands); - else - output_asm_insn ("add%.l %1,%0", xoperands); - } - if (FP_REG_P (operands[2])) - return "fmove%.s %2,%@"; - return "move%.l %2,%@"; -} -} - -static char * -output_301 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (INTVAL (operands[0]) > 4) - { - rtx xoperands[2]; - xoperands[0] = stack_pointer_rtx; - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4); -#ifndef NO_ADDSUB_Q - if (INTVAL (xoperands[1]) <= 8) - output_asm_insn ("addq%.w %1,%0", xoperands); - else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020) - { - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (xoperands[1]) - 8); - output_asm_insn ("addq%.w %#8,%0\n\taddq%.w %1,%0", xoperands); - } - else -#endif - if (INTVAL (xoperands[1]) <= 0x7FFF) - output_asm_insn ("add%.w %1,%0", xoperands); - else - output_asm_insn ("add%.l %1,%0", xoperands); - } - if (operands[2] == const0_rtx) - return "clr%.l %@"; - return "move%.l %2,%@"; -} -} - -static char * -output_302 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xoperands[4]; - - if (GET_CODE (operands[1]) == REG) - return "move%.l %1,%-"; - - xoperands[1] = operands[1]; - xoperands[2] - = gen_rtx (MEM, QImode, - gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, - gen_rtx (CONST_INT, VOIDmode, 3))); - xoperands[3] = stack_pointer_rtx; - output_asm_insn ("subq%.w %#4,%3\n\tmove%.b %1,%2", xoperands); - return ""; -} -} - -static char * -output_303 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return "clr%.w %0"; - } - return "move%.w %1,%0"; -} -} - -static char * -output_304 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - output_dbcc_and_branch (operands); - return ""; -} -} - -static char * -output_305 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - output_dbcc_and_branch (operands); - return ""; -} -} - -static char * -output_306 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_306[] = { - "fpma%.d %1,%w2,%w3,%0", - "fpma%.d %x1,%x2,%x3,%0", - "fpma%.d %x1,%x2,%x3,%0", - }; - return strings_306[which_alternative]; -} - -static char * -output_307 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_307[] = { - "fpma%.s %1,%w2,%w3,%0", - "fpma%.s %1,%2,%3,%0", - "fpma%.s %1,%2,%3,%0", - }; - return strings_307[which_alternative]; -} - -static char * -output_308 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_308[] = { - "fpms%.d %3,%w2,%w1,%0", - "fpms%.d %x3,%2,%x1,%0", - "fpms%.d %x3,%2,%x1,%0", - }; - return strings_308[which_alternative]; -} - -static char * -output_309 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_309[] = { - "fpms%.s %3,%w2,%w1,%0", - "fpms%.s %3,%2,%1,%0", - "fpms%.s %3,%2,%1,%0", - }; - return strings_309[which_alternative]; -} - -static char * -output_310 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_310[] = { - "fpmr%.d %2,%w1,%w3,%0", - "fpmr%.d %x2,%1,%x3,%0", - "fpmr%.d %x2,%1,%x3,%0", - }; - return strings_310[which_alternative]; -} - -static char * -output_311 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_311[] = { - "fpmr%.s %2,%w1,%w3,%0", - "fpmr%.s %x2,%1,%x3,%0", - "fpmr%.s %x2,%1,%x3,%0", - }; - return strings_311[which_alternative]; -} - -static char * -output_312 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_312[] = { - "fpam%.d %2,%w1,%w3,%0", - "fpam%.d %x2,%1,%x3,%0", - "fpam%.d %x2,%1,%x3,%0", - }; - return strings_312[which_alternative]; -} - -static char * -output_313 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_313[] = { - "fpam%.s %2,%w1,%w3,%0", - "fpam%.s %x2,%1,%x3,%0", - "fpam%.s %x2,%1,%x3,%0", - }; - return strings_313[which_alternative]; -} - -static char * -output_314 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_314[] = { - "fpsm%.d %2,%w1,%w3,%0", - "fpsm%.d %x2,%1,%x3,%0", - "fpsm%.d %x2,%1,%x3,%0", - }; - return strings_314[which_alternative]; -} - -static char * -output_315 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_315[] = { - "fpsm%.d %3,%w2,%w1,%0", - "fpsm%.d %x3,%2,%x1,%0", - "fpsm%.d %x3,%2,%x1,%0", - }; - return strings_315[which_alternative]; -} - -static char * -output_316 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_316[] = { - "fpsm%.s %2,%w1,%w3,%0", - "fpsm%.s %x2,%1,%x3,%0", - "fpsm%.s %x2,%1,%x3,%0", - }; - return strings_316[which_alternative]; -} - -static char * -output_317 (operands, insn) - rtx *operands; - rtx insn; -{ - static /*const*/ char *const strings_317[] = { - "fpsm%.s %3,%w2,%w1,%0", - "fpsm%.s %x3,%2,%x1,%0", - "fpsm%.s %x3,%2,%x1,%0", - }; - return strings_317[which_alternative]; -} - -static char * -output_318 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; - return "ftst%.x %0"; -} -} - -static char * -output_320 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return "fcmp%.x %0,%1"; - else - return "fcmp%.x %0,%f1"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.x %1,%f0"; -#else - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return "fcmp%.x %1,%0"; - else - return "fcmp%.x %f1,%0"; - } - cc_status.flags |= CC_REVERSED; - return "fcmp%.x %f0,%1"; -#endif -} -} - -static char * -output_321 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return ""; - } - return "f%$move%.x %1,%0"; - } - if (FP_REG_P (operands[0])) - return "f%$move%.s %f1,%0"; - return "fmove%.x %f1,%0"; -} -} - -static char * -output_322 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return ""; - } - return "fmove%.x %1,%0"; - } - if (FP_REG_P (operands[0])) - return "f%&move%.d %f1,%0"; - return "fmove%.x %f1,%0"; -} -} - -static char * -output_323 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0])) - { - output_asm_insn ("fmove%.d %f1,%-\n\tmove%.l %+,%0", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return "move%.l %+,%0"; - } - return "fmove%.d %f1,%0"; -} -} - -static char * -output_328 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (FP_REG_P (operands[1])) - return "fintrz%.x %f1,%0"; - return "fintrz%.x %f1,%0"; -} -} - -static char * -output_333 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "fadd%.x %2,%0"; - return "fadd%.x %f2,%0"; -} -} - -static char * -output_335 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "fsub%.x %2,%0"; - return "fsub%.x %f2,%0"; -} -} - -static char * -output_337 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "fmul%.x %2,%0"; - return "fmul%.x %f2,%0"; -} -} - -static char * -output_339 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return "fdiv%.x %2,%0"; - return "fdiv%.x %f2,%0"; -} -} - -static char * -output_340 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "fneg%.x %1,%0"; - return "fneg%.x %f1,%0"; -} -} - -static char * -output_341 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return "fabs%.x %1,%0"; - return "fabs%.x %f1,%0"; -} -} - -static char * -output_342 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return "fsqrt%.x %1,%0"; -} -} - -char * const insn_template[] = - { - 0, - 0, - 0, - "tst%.w %0", - "tst%.b %0", - 0, - "fptst%.s %x0\n\tfpmove fpastatus,%1\n\tmovw %1,cc", - 0, - 0, - "fptst%.d %x0\n\tfpmove fpastatus,%1\n\tmovw %1,cc", - 0, - 0, - 0, - 0, - 0, - "fpcmp%.d %y1,%0\n\tfpmove fpastatus,%2\n\tmovw %2,cc", - 0, - 0, - "fpcmp%.s %w1,%x0\n\tfpmove fpastatus,%2\n\tmovw %2,cc", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "pea %a1", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "ext%.w %0", - "extb%.l %0", - 0, - "fpstod %w1,%0", - 0, - 0, - "fpdtos %y1,%0", - 0, - "fmove%.s %f1,%0", - 0, - "fpltos %1,%0", - "f%$move%.l %1,%0", - 0, - "fpltod %1,%0", - "f%&move%.l %1,%0", - "f%$move%.w %1,%0", - "fmove%.w %1,%0", - "fmove%.b %1,%0", - "f%&move%.b %1,%0", - 0, - 0, - 0, - 0, - 0, - "fmove%.b %1,%0", - "fmove%.w %1,%0", - "fmove%.l %1,%0", - "fmove%.b %1,%0", - "fmove%.w %1,%0", - "fmove%.l %1,%0", - "fpstol %w1,%0", - "fpdtol %y1,%0", - 0, - "add%.w %2,%0", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "sub%.w %2,%0", - "sub%.w %2,%0", - "sub%.w %1,%0", - "sub%.b %2,%0", - "sub%.b %1,%0", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "muls%.l %2,%0", - 0, - 0, - 0, - "mulu%.l %2,%3:%0", - "mulu%.l %2,%3:%0", - 0, - "muls%.l %2,%3:%0", - "muls%.l %2,%3:%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, - "and%.w %2,%0", - "and%.w %1,%0", - "and%.w %1,%0", - "and%.b %2,%0", - "and%.b %1,%0", - "and%.b %1,%0", - 0, - "or%.w %2,%0", - "or%.w %1,%0", - "or%.w %1,%0", - "or%.b %2,%0", - "or%.b %1,%0", - "or%.b %1,%0", - 0, - "eor%.w %2,%0", - "eor%.w %1,%0", - "eor%.w %1,%0", - "eor%.b %2,%0", - "eor%.b %1,%0", - "eor%.b %1,%0", - "neg%.l %0", - "neg%.w %0", - "neg%.w %0", - "neg%.b %0", - "neg%.b %0", - 0, - "fpneg%.s %w1,%0", - 0, - 0, - "fpneg%.d %y1, %0", - 0, - 0, - 0, - "fpabs%.s %y1,%0", - 0, - 0, - "fpabs%.d %y1,%0", - 0, - "not%.l %0", - "not%.w %0", - "not%.w %0", - "not%.b %0", - "not%.b %0", - 0, - 0, - 0, - "asl%.w %2,%0", - "asl%.w %1,%0", - "asl%.b %2,%0", - "asl%.b %1,%0", - "swap %0\n\text%.l %0", - 0, - 0, - "asr%.w %2,%0", - "asr%.w %1,%0", - "asr%.b %2,%0", - "asr%.b %1,%0", - 0, - 0, - 0, - "lsl%.w %2,%0", - "lsl%.w %1,%0", - "lsl%.b %2,%0", - "lsl%.b %1,%0", - 0, - 0, - 0, - "lsr%.w %2,%0", - "lsr%.w %1,%0", - "lsr%.b %2,%0", - "lsr%.b %1,%0", - "rol%.l %2,%0", - "rol%.w %2,%0", - "rol%.w %1,%0", - "rol%.b %2,%0", - "rol%.b %1,%0", - "ror%.l %2,%0", - "ror%.w %2,%0", - "ror%.w %1,%0", - "ror%.b %2,%0", - "ror%.b %1,%0", - 0, - 0, - 0, - 0, - 0, - 0, - "bfexts %1{%b3:%b2},%0", - 0, - 0, - 0, - 0, - "bfins %3,%0{%b2:%b1}", - "bfexts %1{%b3:%b2},%0", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "", - "nop", - 0, - 0, - "jmp %a0", - "lea %a1,%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, - "fmove%.s %f1,%0", - "fmove%.l %1,%0", - "fmove%.w %1,%0", - "fmove%.b %1,%0", - 0, - "fmove%.b %1,%0", - "fmove%.w %1,%0", - "fmove%.l %1,%0", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - }; - -char *(*const insn_outfun[])() = - { - output_0, - output_1, - output_2, - 0, - 0, - 0, - 0, - output_7, - 0, - 0, - output_10, - output_11, - output_12, - output_13, - 0, - 0, - output_16, - 0, - 0, - output_19, - output_20, - output_21, - output_22, - output_23, - output_24, - output_25, - output_26, - output_27, - 0, - output_29, - output_30, - output_31, - output_32, - output_33, - output_34, - output_35, - 0, - output_37, - output_38, - output_39, - 0, - output_41, - output_42, - output_43, - 0, - 0, - 0, - output_47, - output_48, - output_49, - output_50, - 0, - 0, - 0, - 0, - output_55, - 0, - 0, - output_58, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_70, - output_71, - output_72, - output_73, - output_74, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_83, - 0, - output_85, - output_86, - output_87, - output_88, - output_89, - output_90, - 0, - output_92, - output_93, - 0, - output_95, - output_96, - output_97, - 0, - 0, - 0, - 0, - 0, - 0, - output_104, - output_105, - 0, - output_107, - output_108, - output_109, - output_110, - output_111, - 0, - output_113, - output_114, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_122, - output_123, - 0, - output_125, - output_126, - output_127, - output_128, - output_129, - output_130, - output_131, - output_132, - 0, - output_134, - output_135, - 0, - output_137, - output_138, - output_139, - output_140, - output_141, - output_142, - output_143, - output_144, - output_145, - output_146, - output_147, - 0, - 0, - 0, - 0, - 0, - 0, - output_154, - 0, - 0, - 0, - 0, - 0, - 0, - output_161, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_175, - 0, - 0, - output_178, - output_179, - 0, - 0, - output_182, - 0, - 0, - output_185, - 0, - 0, - 0, - 0, - 0, - output_191, - output_192, - output_193, - 0, - 0, - 0, - 0, - 0, - output_199, - output_200, - 0, - 0, - 0, - 0, - output_205, - output_206, - output_207, - 0, - 0, - 0, - 0, - output_212, - output_213, - output_214, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_229, - output_230, - output_231, - output_232, - output_233, - output_234, - 0, - output_236, - output_237, - output_238, - output_239, - 0, - 0, - output_242, - output_243, - output_244, - output_245, - output_246, - output_247, - output_248, - output_249, - output_250, - output_251, - output_252, - output_253, - output_254, - output_255, - output_256, - output_257, - output_258, - output_259, - output_260, - output_261, - output_262, - output_263, - output_264, - output_265, - output_266, - output_267, - output_268, - output_269, - output_270, - output_271, - output_272, - output_273, - output_274, - output_275, - output_276, - output_277, - output_278, - 0, - output_280, - output_281, - output_282, - output_283, - output_284, - output_285, - 0, - output_287, - output_288, - 0, - output_290, - output_291, - 0, - 0, - 0, - output_295, - output_296, - 0, - 0, - output_299, - output_300, - output_301, - output_302, - output_303, - output_304, - output_305, - output_306, - output_307, - output_308, - output_309, - output_310, - output_311, - output_312, - output_313, - output_314, - output_315, - output_316, - output_317, - output_318, - 0, - output_320, - output_321, - output_322, - output_323, - 0, - 0, - 0, - 0, - output_328, - 0, - 0, - 0, - 0, - output_333, - 0, - output_335, - 0, - output_337, - 0, - output_339, - output_340, - output_341, - output_342, - }; - -rtx (*const insn_gen_function[]) () = - { - 0, - 0, - gen_tstsi, - gen_tsthi, - gen_tstqi, - gen_tstsf, - gen_tstsf_fpa, - 0, - gen_tstdf, - gen_tstdf_fpa, - 0, - gen_cmpsi, - gen_cmphi, - gen_cmpqi, - gen_cmpdf, - gen_cmpdf_fpa, - 0, - gen_cmpsf, - gen_cmpsf_fpa, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_movsi, - 0, - gen_movhi, - gen_movstricthi, - gen_movqi, - gen_movstrictqi, - gen_movsf, - gen_movdf, - gen_movxf, - 0, - 0, - gen_movdi, - gen_pushasi, - gen_truncsiqi2, - gen_trunchiqi2, - gen_truncsihi2, - gen_zero_extendhisi2, - gen_zero_extendqihi2, - gen_zero_extendqisi2, - 0, - 0, - 0, - gen_extendhisi2, - gen_extendqihi2, - gen_extendqisi2, - gen_extendsfdf2, - 0, - 0, - gen_truncdfsf2, - 0, - 0, - 0, - gen_floatsisf2, - 0, - 0, - gen_floatsidf2, - 0, - 0, - gen_floathisf2, - gen_floathidf2, - gen_floatqisf2, - gen_floatqidf2, - gen_fix_truncdfsi2, - gen_fix_truncdfhi2, - gen_fix_truncdfqi2, - gen_ftruncdf2, - gen_ftruncsf2, - gen_fixsfqi2, - gen_fixsfhi2, - gen_fixsfsi2, - gen_fixdfqi2, - gen_fixdfhi2, - gen_fixdfsi2, - 0, - 0, - gen_addsi3, - 0, - gen_addhi3, - 0, - 0, - gen_addqi3, - 0, - 0, - gen_adddf3, - 0, - 0, - gen_addsf3, - 0, - 0, - gen_subsi3, - 0, - gen_subhi3, - 0, - gen_subqi3, - 0, - gen_subdf3, - 0, - 0, - gen_subsf3, - 0, - 0, - gen_mulhi3, - gen_mulhisi3, - 0, - gen_mulsi3, - gen_umulhisi3, - 0, - gen_umulsidi3, - 0, - 0, - gen_mulsidi3, - 0, - 0, - gen_muldf3, - 0, - 0, - gen_mulsf3, - 0, - 0, - gen_divhi3, - gen_divhisi3, - 0, - gen_udivhi3, - gen_udivhisi3, - 0, - gen_divdf3, - 0, - 0, - gen_divsf3, - 0, - 0, - gen_modhi3, - gen_modhisi3, - 0, - gen_umodhi3, - gen_umodhisi3, - 0, - gen_divmodsi4, - gen_udivmodsi4, - gen_andsi3, - gen_andhi3, - 0, - 0, - gen_andqi3, - 0, - 0, - gen_iorsi3, - gen_iorhi3, - 0, - 0, - gen_iorqi3, - 0, - 0, - gen_xorsi3, - gen_xorhi3, - 0, - 0, - gen_xorqi3, - 0, - 0, - gen_negsi2, - gen_neghi2, - 0, - gen_negqi2, - 0, - gen_negsf2, - 0, - 0, - gen_negdf2, - 0, - 0, - gen_sqrtdf2, - gen_abssf2, - 0, - 0, - gen_absdf2, - 0, - 0, - gen_one_cmplsi2, - gen_one_cmplhi2, - 0, - gen_one_cmplqi2, - 0, - 0, - 0, - gen_ashlsi3, - gen_ashlhi3, - 0, - gen_ashlqi3, - 0, - 0, - 0, - gen_ashrsi3, - gen_ashrhi3, - 0, - gen_ashrqi3, - 0, - 0, - 0, - gen_lshlsi3, - gen_lshlhi3, - 0, - gen_lshlqi3, - 0, - 0, - 0, - gen_lshrsi3, - gen_lshrhi3, - 0, - gen_lshrqi3, - 0, - gen_rotlsi3, - gen_rotlhi3, - 0, - gen_rotlqi3, - 0, - gen_rotrsi3, - gen_rotrhi3, - 0, - gen_rotrqi3, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_extv, - gen_extzv, - 0, - 0, - 0, - gen_insv, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_seq, - gen_sne, - gen_sgt, - gen_sgtu, - gen_slt, - gen_sltu, - gen_sge, - gen_sgeu, - gen_sle, - gen_sleu, - gen_beq, - gen_bne, - gen_bgt, - gen_bgtu, - gen_blt, - gen_bltu, - gen_bge, - gen_bgeu, - gen_ble, - gen_bleu, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_jump, - gen_tablejump, - 0, - 0, - 0, - 0, - 0, - gen_decrement_and_branch_until_zero, - gen_call, - 0, - 0, - gen_call_value, - 0, - 0, - gen_untyped_call, - gen_blockage, - gen_nop, - gen_probe, - gen_return, - gen_indirect_jump, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_tstxf, - gen_cmpxf, - 0, - gen_extendsfxf2, - gen_extenddfxf2, - gen_truncxfdf2, - gen_truncxfsf2, - gen_floatsixf2, - gen_floathixf2, - gen_floatqixf2, - gen_ftruncxf2, - gen_fixxfqi2, - gen_fixxfhi2, - gen_fixxfsi2, - gen_addxf3, - 0, - gen_subxf3, - 0, - gen_mulxf3, - 0, - gen_divxf3, - 0, - gen_negxf2, - gen_absxf2, - gen_sqrtxf2, - }; - -char *insn_name[] = - { - "tstsi-1", - "tstsi-0", - "tstsi", - "tsthi", - "tstqi", - "tstsf", - "tstsf_fpa", - "tstsf_fpa+1", - "tstdf", - "tstdf_fpa", - "tstdf_fpa+1", - "cmpsi", - "cmphi", - "cmpqi", - "cmpdf", - "cmpdf_fpa", - "cmpdf_fpa+1", - "cmpsf", - "cmpsf_fpa", - "cmpsf_fpa+1", - "cmpsf_fpa+2", - "cmpsf_fpa+3", - "cmpsf_fpa+4", - "cmpsf_fpa+5", - "movsi-4", - "movsi-3", - "movsi-2", - "movsi-1", - "movsi", - "movsi+1", - "movhi", - "movstricthi", - "movqi", - "movstrictqi", - "movsf", - "movdf", - "movxf", - "movxf+1", - "movdi-1", - "movdi", - "pushasi", - "truncsiqi2", - "trunchiqi2", - "truncsihi2", - "zero_extendhisi2", - "zero_extendqihi2", - "zero_extendqisi2", - "zero_extendqisi2+1", - "zero_extendqisi2+2", - "extendhisi2-1", - "extendhisi2", - "extendqihi2", - "extendqisi2", - "extendsfdf2", - "extendsfdf2+1", - "truncdfsf2-1", - "truncdfsf2", - "truncdfsf2+1", - "truncdfsf2+2", - "floatsisf2-1", - "floatsisf2", - "floatsisf2+1", - "floatsidf2-1", - "floatsidf2", - "floatsidf2+1", - "floathisf2-1", - "floathisf2", - "floathidf2", - "floatqisf2", - "floatqidf2", - "fix_truncdfsi2", - "fix_truncdfhi2", - "fix_truncdfqi2", - "ftruncdf2", - "ftruncsf2", - "fixsfqi2", - "fixsfhi2", - "fixsfsi2", - "fixdfqi2", - "fixdfhi2", - "fixdfsi2", - "fixdfsi2+1", - "addsi3-1", - "addsi3", - "addsi3+1", - "addhi3", - "addhi3+1", - "addqi3-1", - "addqi3", - "addqi3+1", - "adddf3-1", - "adddf3", - "adddf3+1", - "addsf3-1", - "addsf3", - "addsf3+1", - "subsi3-1", - "subsi3", - "subsi3+1", - "subhi3", - "subhi3+1", - "subqi3", - "subqi3+1", - "subdf3", - "subdf3+1", - "subsf3-1", - "subsf3", - "subsf3+1", - "mulhi3-1", - "mulhi3", - "mulhisi3", - "mulhisi3+1", - "mulsi3", - "umulhisi3", - "umulhisi3+1", - "umulsidi3", - "umulsidi3+1", - "mulsidi3-1", - "mulsidi3", - "mulsidi3+1", - "muldf3-1", - "muldf3", - "muldf3+1", - "mulsf3-1", - "mulsf3", - "mulsf3+1", - "divhi3-1", - "divhi3", - "divhisi3", - "divhisi3+1", - "udivhi3", - "udivhisi3", - "udivhisi3+1", - "divdf3", - "divdf3+1", - "divsf3-1", - "divsf3", - "divsf3+1", - "modhi3-1", - "modhi3", - "modhisi3", - "modhisi3+1", - "umodhi3", - "umodhisi3", - "umodhisi3+1", - "divmodsi4", - "udivmodsi4", - "andsi3", - "andhi3", - "andhi3+1", - "andqi3-1", - "andqi3", - "andqi3+1", - "iorsi3-1", - "iorsi3", - "iorhi3", - "iorhi3+1", - "iorqi3-1", - "iorqi3", - "iorqi3+1", - "xorsi3-1", - "xorsi3", - "xorhi3", - "xorhi3+1", - "xorqi3-1", - "xorqi3", - "xorqi3+1", - "negsi2-1", - "negsi2", - "neghi2", - "neghi2+1", - "negqi2", - "negqi2+1", - "negsf2", - "negsf2+1", - "negdf2-1", - "negdf2", - "negdf2+1", - "sqrtdf2-1", - "sqrtdf2", - "abssf2", - "abssf2+1", - "absdf2-1", - "absdf2", - "absdf2+1", - "one_cmplsi2-1", - "one_cmplsi2", - "one_cmplhi2", - "one_cmplhi2+1", - "one_cmplqi2", - "one_cmplqi2+1", - "one_cmplqi2+2", - "ashlsi3-1", - "ashlsi3", - "ashlhi3", - "ashlhi3+1", - "ashlqi3", - "ashlqi3+1", - "ashlqi3+2", - "ashrsi3-1", - "ashrsi3", - "ashrhi3", - "ashrhi3+1", - "ashrqi3", - "ashrqi3+1", - "ashrqi3+2", - "lshlsi3-1", - "lshlsi3", - "lshlhi3", - "lshlhi3+1", - "lshlqi3", - "lshlqi3+1", - "lshlqi3+2", - "lshrsi3-1", - "lshrsi3", - "lshrhi3", - "lshrhi3+1", - "lshrqi3", - "lshrqi3+1", - "rotlsi3", - "rotlhi3", - "rotlhi3+1", - "rotlqi3", - "rotlqi3+1", - "rotrsi3", - "rotrhi3", - "rotrhi3+1", - "rotrqi3", - "rotrqi3+1", - "rotrqi3+2", - "rotrqi3+3", - "rotrqi3+4", - "extv-3", - "extv-2", - "extv-1", - "extv", - "extzv", - "extzv+1", - "extzv+2", - "insv-1", - "insv", - "insv+1", - "insv+2", - "insv+3", - "insv+4", - "seq-3", - "seq-2", - "seq-1", - "seq", - "sne", - "sgt", - "sgtu", - "slt", - "sltu", - "sge", - "sgeu", - "sle", - "sleu", - "beq", - "bne", - "bgt", - "bgtu", - "blt", - "bltu", - "bge", - "bgeu", - "ble", - "bleu", - "bleu+1", - "bleu+2", - "bleu+3", - "bleu+4", - "bleu+5", - "jump-5", - "jump-4", - "jump-3", - "jump-2", - "jump-1", - "jump", - "tablejump", - "tablejump+1", - "tablejump+2", - "tablejump+3", - "decrement_and_branch_until_zero-2", - "decrement_and_branch_until_zero-1", - "decrement_and_branch_until_zero", - "call", - "call+1", - "call_value-1", - "call_value", - "call_value+1", - "untyped_call-1", - "untyped_call", - "blockage", - "nop", - "probe", - "return", - "indirect_jump", - "indirect_jump+1", - "indirect_jump+2", - "indirect_jump+3", - "indirect_jump+4", - "indirect_jump+5", - "indirect_jump+6", - "indirect_jump+7", - "indirect_jump+8", - "indirect_jump+9", - "indirect_jump+10", - "tstxf-10", - "tstxf-9", - "tstxf-8", - "tstxf-7", - "tstxf-6", - "tstxf-5", - "tstxf-4", - "tstxf-3", - "tstxf-2", - "tstxf-1", - "tstxf", - "cmpxf", - "cmpxf+1", - "extendsfxf2", - "extenddfxf2", - "truncxfdf2", - "truncxfsf2", - "floatsixf2", - "floathixf2", - "floatqixf2", - "ftruncxf2", - "fixxfqi2", - "fixxfhi2", - "fixxfsi2", - "addxf3", - "addxf3+1", - "subxf3", - "subxf3+1", - "mulxf3", - "mulxf3+1", - "divxf3", - "divxf3+1", - "negxf2", - "absxf2", - "sqrtxf2", - }; -char **insn_name_ptr = insn_name; - -const int insn_n_operands[] = - { - 2, - 2, - 1, - 1, - 1, - 1, - 2, - 1, - 1, - 2, - 1, - 2, - 2, - 2, - 2, - 3, - 2, - 2, - 3, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 4, - 4, - 4, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 2, - 2, - 3, - 2, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 4, - 3, - 4, - 4, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 4, - 3, - 3, - 2, - 2, - 3, - 2, - 2, - 3, - 3, - 2, - 2, - 3, - 2, - 2, - 3, - 3, - 2, - 2, - 3, - 2, - 2, - 2, - 2, - 1, - 2, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 2, - 1, - 3, - 3, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 2, - 3, - 2, - 3, - 3, - 2, - 3, - 2, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 3, - 3, - 4, - 4, - 4, - 3, - 3, - 4, - 3, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 0, - 0, - 0, - 0, - 1, - 2, - 2, - 3, - 3, - 2, - 2, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 2, - 2, - 2, - }; - -const int insn_n_dups[] = - { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3, - 2, - 2, - 3, - 2, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 2, - 0, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 2, - 2, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - }; - -char *const insn_operand_constraint[][MAX_RECOG_OPERANDS] = - { - { "=m", "ro<>fyE", }, - { "=m", "ro<>Fy", }, - { "rm", }, - { "dm", }, - { "dm", }, - { "", }, - { "xmdF", "=d", }, - { "fdm", }, - { "", }, - { "xrmF", "=d", }, - { "fm", }, - { "rKs,mr,>", "mr,Ksr,>", }, - { "rnm,d,n,m", "d,rnm,m,n", }, - { "dn,md,>", "dm,nd,>", }, - { "", "", }, - { "x,y", "xH,rmF", "=d,d", }, - { "f,mG", "fmG,f", }, - { "", "", }, - { "x,y", "xH,rmF", "=d,d", }, - { "f,mdG", "fmdG,f", }, - { "do", "di", }, - { "d", "di", }, - { "do", "d", }, - { "d", "d", }, - { "md", "i", }, - { "do", "i", }, - { "=m", "J", }, - { "=g", }, - { "", "", }, - { "=g,da,y,!*x*r*m", "daymKs,i,g,*x*r*m", }, - { "=g", "g", }, - { "+dm", "rmn", }, - { "=d,*a,m,m,?*a", "dmi*a,d*a,dmi,?*a,m", }, - { "+dm", "dmn", }, - { "=rmf,x,y,rm,!x,!rm", "rmfF,xH,rmF,y,rm,x", }, - { "=rm,&rf,&rof<>,y,rm,x,!x,!rm", "rf,m,rofE<>,rmE,y,xH,rm,x", }, - { "", "", }, - { "=f,m,f,!r,!f", "m,f,f,f,r", }, - { "=rm,&rf,&rof<>", "rf,m,rof<>", }, - { "=rm,&r,&ro<>,y,rm,!*x,!rm", "rF,m,roi<>F,rmiF,y,rmF,*x", }, - { "=m", "p", }, - { "=dm,d", "doJ,i", }, - { "=dm,d", "doJ,i", }, - { "=dm,d", "roJ,i", }, - { "", "", }, - { "", "", }, - { "", "", }, - { "=do<>,d<", "r,m", }, - { "=do<>,d", "d,m", }, - { "=do<>,d", "d,m", }, - { "=*d,a", "0,rm", }, - { "=d", "0", }, - { "=d", "0", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=*fdm,f", "f,dmF", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=f", "fmG", }, - { "=dm", "f", }, - { "", "", }, - { "=y,x", "rmi,x", }, - { "=f", "dmi", }, - { "", "", }, - { "=y,x", "rmi,x", }, - { "=f", "dmi", }, - { "=f", "dmn", }, - { "=f", "dmn", }, - { "=f", "dmn", }, - { "=f", "dmn", }, - { "=dm", "f", "=d", "=d", }, - { "=dm", "f", "=d", "=d", }, - { "=dm", "f", "=d", "=d", }, - { "=f", "fFm", }, - { "=f", "dfFm", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=x,y", "xH,rmF", }, - { "=x,y", "xH,rmF", }, - { "=m,?a,?a,r", "%0,a,rJK,0", "dIKLs,rJK,a,mrIKLs", }, - { "=a", "0", "rm", }, - { "=m,r", "%0,0", "dn,rmn", }, - { "+m,d", "dn,rmn", }, - { "+m,d", "dn,rmn", }, - { "=m,d", "%0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "", "", "", }, - { "=x,y", "%xH,y", "xH,dmF", }, - { "=f", "%0", "fmG", }, - { "", "", "", }, - { "=x,y", "%xH,y", "xH,rmF", }, - { "=f", "%0", "fdmF", }, - { "=m,r,!a,?d", "0,0,a,mrIKs", "dIKs,mrIKs,J,0", }, - { "=a", "0", "rm", }, - { "=m,r", "0,0", "dn,rmn", }, - { "+m,d", "dn,rmn", }, - { "=m,d", "0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "", "", "", }, - { "=x,y,y", "xH,y,dmF", "xH,dmF,0", }, - { "=f", "0", "fmG", }, - { "", "", "", }, - { "=x,y,y", "xH,y,rmF", "xH,rmF,0", }, - { "=f", "0", "fdmF", }, - { "=d", "%0", "dmn", }, - { "=d", "%0", "dm", }, - { "=d", "%0", "n", }, - { "=d", "%0", "dmsK", }, - { "=d", "%0", "dm", }, - { "=d", "%0", "n", }, - { "", "", "", }, - { "=d", "%0", "dm", "=d", }, - { "=d", "%0", "n", "=d", }, - { "", "", "", }, - { "=d", "%0", "dm", "=d", }, - { "=d", "%0", "n", "=d", }, - { "", "", "", }, - { "=x,y", "%xH,y", "xH,rmF", }, - { "=f", "%0", "fmG", }, - { "", "", "", }, - { "=x,y", "%xH,y", "xH,rmF", }, - { "=f", "%0", "fdmF", }, - { "=d", "0", "dmn", }, - { "=d", "0", "dm", }, - { "=d", "0", "n", }, - { "=d", "0", "dmn", }, - { "=d", "0", "dm", }, - { "=d", "0", "n", }, - { "", "", "", }, - { "=x,y,y", "xH,y,rmF", "xH,rmF,0", }, - { "=f", "0", "fmG", }, - { "", "", "", }, - { "=x,y,y", "xH,y,rmF", "xH,rmF,0", }, - { "=f", "0", "fdmF", }, - { "=d", "0", "dmn", }, - { "=d", "0", "dm", }, - { "=d", "0", "n", }, - { "=d", "0", "dmn", }, - { "=d", "0", "dm", }, - { "=d", "0", "n", }, - { "=d", "0", "dmsK", "=d", }, - { "=d", "0", "dmsK", "=d", }, - { "=m,d", "%0,0", "dKs,dmKs", }, - { "=m,d", "%0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "=m,d", "%0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "=m,d", "%0,0", "dKs,dmKs", }, - { "=m,d", "%0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "=m,d", "%0,0", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "+m,d", "dn,dmn", }, - { "=do,m", "%0,0", "di,dKs", }, - { "=dm", "%0", "dn", }, - { "+dm", "dn", }, - { "+dm", "dn", }, - { "=dm", "%0", "dn", }, - { "+dm", "dn", }, - { "+dm", "dn", }, - { "=dm", "0", }, - { "=dm", "0", }, - { "+dm", }, - { "=dm", "0", }, - { "+dm", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=f,d", "fdmF,0", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=f,d", "fmF,0", }, - { "=f", "fm", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=f", "fdmF", }, - { "", "", }, - { "=x,y", "xH,rmF", }, - { "=f", "fmF", }, - { "=dm", "0", }, - { "=dm", "0", }, - { "+dm", }, - { "=dm", "0", }, - { "+dm", }, - { "=d", "0", "i", }, - { "=d", "0", "i", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "i", }, - { "=d", "0", "i", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "i", }, - { "=d", "0", "i", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "i", }, - { "=d", "0", "i", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "=d", "0", "dI", }, - { "+d", "dI", }, - { "+o", "i", "i", "rmi", }, - { "+do", "i", "i", "d", }, - { "=rm", "o", "i", "i", }, - { "=&d", "do", "i", "i", }, - { "=rm", "o", "i", "i", }, - { "=d", "do", "i", "i", }, - { "=d,d", "o,d", "di,di", "di,di", }, - { "=d,d", "o,d", "di,di", "di,di", }, - { "+o,d", "di,di", "di,di", "i,i", }, - { "+o,d", "di,di", "di,di", }, - { "+o,d", "di,di", "di,di", }, - { "+o,d", "di,di", "di,di", "d,d", }, - { "=d", "d", "di", "di", }, - { "=d", "d", "di", "di", }, - { "+d", "di", "di", }, - { "+d", "di", "di", }, - { "+d", "di", "di", "d", }, - { "o", "di", "di", }, - { "d", "di", "di", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { "=d", }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { "", }, - { "a", }, - { "r", }, - { "+g", }, - { "+g", }, - { "+g", }, - { "+g", }, - { "", "", }, - { "o", "g", }, - { "o", "g", }, - { "", "", "", }, - { "=rf", "o", "g", }, - { "=rf", "o", "g", }, - { "", "", "", }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { "p", }, - { "=a", "p", }, - { "=f", "ad", }, - { "n", "=m", "rmfF", }, - { "n", "=m", "g", }, - { "", "dami", }, - { "=d", "rmn", }, - { "+d", "", "", "", }, - { "+d", "", "", "", }, - { "=x,y,y", "%x,dmF,y", "xH,y,y", "xH,y,dmF", }, - { "=x,y,y", "%x,ydmF,y", "xH,y,ydmF", "xH,ydmF,ydmF", }, - { "=x,y,y", "xH,rmF,y", "%xH,y,y", "x,y,rmF", }, - { "=x,y,y", "xH,rmF,yrmF", "%xH,rmF,y", "x,y,yrmF", }, - { "=x,y,y", "%xH,y,y", "x,y,rmF", "xH,rmF,y", }, - { "=x,y,y", "%xH,rmF,y", "x,y,yrmF", "xH,rmF,yrmF", }, - { "=x,y,y", "%xH,y,y", "x,y,rmF", "xH,rmF,y", }, - { "=x,y,y", "%xH,rmF,y", "x,y,yrmF", "xH,rmF,yrmF", }, - { "=x,y,y", "xH,y,y", "x,y,rmF", "xH,rmF,y", }, - { "=x,y,y", "xH,rmF,y", "xH,y,y", "x,y,rmF", }, - { "=x,y,y", "xH,rmF,y", "x,y,yrmF", "xH,rmF,yrmF", }, - { "=x,y,y", "xH,rmF,yrmF", "xH,rmF,y", "x,y,yrmF", }, - { "fm", }, - { "f,mG", "fmG,f", }, - { "f,mG", "fmG,f", }, - { "=fm,f", "f,m", }, - { "=fm,f", "f,m", }, - { "=m,!r", "f,f", }, - { "=dm", "f", }, - { "=f", "dmi", }, - { "=f", "dmn", }, - { "=f", "dmn", }, - { "=f", "fFm", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "=dm", "f", }, - { "", "", "", }, - { "=f", "%0", "fmG", }, - { "", "", "", }, - { "=f", "0", "fmG", }, - { "", "", "", }, - { "=f", "%0", "fmG", }, - { "", "", "", }, - { "=f", "0", "fmG", }, - { "=f", "fmF", }, - { "=f", "fmF", }, - { "=f", "fm", }, - }; - -const enum machine_mode insn_operand_mode[][MAX_RECOG_OPERANDS] = - { - { DFmode, DFmode, }, - { DImode, DImode, }, - { SImode, }, - { HImode, }, - { QImode, }, - { SFmode, }, - { SFmode, SImode, }, - { SFmode, }, - { DFmode, }, - { DFmode, SImode, }, - { DFmode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, SImode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, SImode, }, - { SFmode, SFmode, }, - { QImode, SImode, }, - { SImode, SImode, }, - { QImode, SImode, }, - { SImode, SImode, }, - { QImode, SImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { SImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { XFmode, XFmode, }, - { XFmode, XFmode, }, - { XFmode, XFmode, }, - { DImode, DImode, }, - { SImode, SImode, }, - { QImode, SImode, }, - { QImode, HImode, }, - { HImode, SImode, }, - { SImode, HImode, }, - { HImode, QImode, }, - { SImode, QImode, }, - { SImode, HImode, }, - { HImode, QImode, }, - { SImode, QImode, }, - { SImode, HImode, }, - { HImode, QImode, }, - { SImode, QImode, }, - { DFmode, SFmode, }, - { DFmode, SFmode, }, - { DFmode, SFmode, }, - { SFmode, DFmode, }, - { SFmode, DFmode, }, - { SFmode, DFmode, }, - { SFmode, DFmode, }, - { SFmode, SImode, }, - { SFmode, SImode, }, - { SFmode, SImode, }, - { DFmode, SImode, }, - { DFmode, SImode, }, - { DFmode, SImode, }, - { SFmode, HImode, }, - { DFmode, HImode, }, - { SFmode, QImode, }, - { DFmode, QImode, }, - { SImode, DFmode, SImode, SImode, }, - { HImode, DFmode, SImode, SImode, }, - { QImode, DFmode, SImode, SImode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { QImode, SFmode, }, - { HImode, SFmode, }, - { SImode, SFmode, }, - { QImode, DFmode, }, - { HImode, DFmode, }, - { SImode, DFmode, }, - { SImode, SFmode, }, - { SImode, DFmode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, HImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, HImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { HImode, HImode, HImode, }, - { SImode, HImode, HImode, }, - { SImode, HImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, HImode, HImode, }, - { SImode, HImode, SImode, }, - { DImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { DImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { HImode, HImode, HImode, }, - { HImode, SImode, HImode, }, - { HImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, SImode, HImode, }, - { HImode, SImode, SImode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, }, - { HImode, HImode, HImode, }, - { HImode, SImode, HImode, }, - { HImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, SImode, HImode, }, - { HImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { HImode, }, - { QImode, QImode, }, - { QImode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { HImode, }, - { QImode, QImode, }, - { QImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, QImode, }, - { QImode, QImode, }, - { QImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, QImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, QImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, QImode, SImode, SImode, }, - { SImode, QImode, SImode, SImode, }, - { QImode, SImode, SImode, VOIDmode, }, - { QImode, SImode, SImode, }, - { QImode, SImode, SImode, }, - { QImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { QImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode, }, - { SImode, }, - { HImode, }, - { HImode, }, - { SImode, }, - { HImode, }, - { SImode, }, - { QImode, SImode, }, - { QImode, SImode, }, - { QImode, SImode, }, - { VOIDmode, QImode, SImode, }, - { VOIDmode, QImode, SImode, }, - { VOIDmode, QImode, SImode, }, - { VOIDmode, VOIDmode, VOIDmode, }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { SImode, }, - { SImode, QImode, }, - { VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, VOIDmode, VOIDmode, }, - { VOIDmode, VOIDmode, VOIDmode, VOIDmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { XFmode, }, - { XFmode, XFmode, }, - { XFmode, XFmode, }, - { XFmode, SFmode, }, - { XFmode, DFmode, }, - { DFmode, XFmode, }, - { SFmode, XFmode, }, - { XFmode, SImode, }, - { XFmode, HImode, }, - { XFmode, QImode, }, - { XFmode, XFmode, }, - { QImode, XFmode, }, - { HImode, XFmode, }, - { SImode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, XFmode, }, - { XFmode, XFmode, }, - { XFmode, XFmode, }, - { XFmode, DFmode, }, - }; - -const char insn_operand_strict_low[][MAX_RECOG_OPERANDS] = - { - { 0, 0, }, - { 0, 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, 0, }, - { 0, }, - { 0, }, - { 0, 0, }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 1, 0, }, - { 0, 0, }, - { 1, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 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, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 1, 0, }, - { 0, 0, }, - { 0, 0, }, - { 1, }, - { 0, 0, }, - { 1, }, - { 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, }, - { 1, }, - { 0, 0, }, - { 1, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, }, - { 1, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - }; - -extern int push_operand (); -extern int general_operand (); -extern int nonimmediate_operand (); -extern int scratch_operand (); -extern int address_operand (); -extern int register_operand (); -extern int const_int_operand (); -extern int not_sp_operand (); -extern int immediate_operand (); -extern int memory_operand (); - -int (*const insn_operand_predicate[][MAX_RECOG_OPERANDS])() = - { - { push_operand, general_operand, }, - { push_operand, general_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { general_operand, }, - { general_operand, scratch_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, scratch_operand, }, - { general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, scratch_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, scratch_operand, }, - { general_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, nonimmediate_operand, }, - { nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, }, - { push_operand, address_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, register_operand, scratch_operand, scratch_operand, }, - { general_operand, register_operand, scratch_operand, scratch_operand, }, - { general_operand, register_operand, scratch_operand, scratch_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, const_int_operand, }, - { register_operand, register_operand, nonimmediate_operand, }, - { register_operand, register_operand, nonimmediate_operand, register_operand, }, - { register_operand, register_operand, const_int_operand, register_operand, }, - { register_operand, register_operand, nonimmediate_operand, }, - { register_operand, register_operand, nonimmediate_operand, register_operand, }, - { register_operand, register_operand, const_int_operand, register_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, nonimmediate_operand, }, - { general_operand, general_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, general_operand, }, - { not_sp_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, }, - { general_operand, general_operand, }, - { general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, }, - { general_operand, general_operand, }, - { general_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, immediate_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, general_operand, }, - { register_operand, general_operand, }, - { nonimmediate_operand, immediate_operand, immediate_operand, general_operand, }, - { nonimmediate_operand, immediate_operand, immediate_operand, general_operand, }, - { general_operand, nonimmediate_operand, immediate_operand, immediate_operand, }, - { general_operand, nonimmediate_operand, immediate_operand, immediate_operand, }, - { general_operand, nonimmediate_operand, immediate_operand, immediate_operand, }, - { general_operand, nonimmediate_operand, immediate_operand, immediate_operand, }, - { general_operand, nonimmediate_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, immediate_operand, }, - { nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, general_operand, }, - { memory_operand, general_operand, general_operand, }, - { nonimmediate_operand, general_operand, general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0, }, - { register_operand, }, - { register_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { general_operand, }, - { memory_operand, general_operand, }, - { memory_operand, general_operand, }, - { memory_operand, general_operand, }, - { 0, memory_operand, general_operand, }, - { 0, memory_operand, general_operand, }, - { 0, memory_operand, general_operand, }, - { 0, 0, 0, }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { address_operand, }, - { general_operand, address_operand, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { register_operand, general_operand, general_operand, general_operand, }, - { nonimmediate_operand, }, - { general_operand, general_operand, }, - { nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - }; - -const int insn_n_alternatives[] = - { - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 3, - 4, - 3, - 0, - 2, - 2, - 0, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 4, - 1, - 1, - 5, - 1, - 6, - 8, - 0, - 5, - 3, - 7, - 1, - 2, - 2, - 2, - 0, - 0, - 0, - 2, - 2, - 2, - 2, - 1, - 1, - 0, - 2, - 2, - 0, - 2, - 1, - 1, - 0, - 2, - 1, - 0, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 4, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 0, - 2, - 1, - 0, - 2, - 1, - 4, - 1, - 2, - 2, - 2, - 2, - 0, - 3, - 1, - 0, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 2, - 1, - 0, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 3, - 1, - 0, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 2, - 2, - 0, - 2, - 2, - 1, - 0, - 2, - 1, - 0, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 1, - 2, - 2, - 2, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 1, - 1, - 1, - }; diff --git a/gnu/usr.bin/gcc2/arch/hp300/insn-peep.c b/gnu/usr.bin/gcc2/arch/hp300/insn-peep.c deleted file mode 100644 index ac2cb51fdd8e..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/insn-peep.c +++ /dev/null @@ -1,410 +0,0 @@ -/* Generated automatically by the program `genpeep' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "regs.h" -#include "output.h" -#include "real.h" - -extern rtx peep_operand[]; - -#define operands peep_operand - -rtx -peephole (ins1) - rtx ins1; -{ - rtx insn, x, pat; - int i; - - if (NEXT_INSN (ins1) - && GET_CODE (NEXT_INSN (ins1)) == BARRIER) - return 0; - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L299; - x = XEXP (pat, 0); - if (GET_CODE (x) != REG) goto L299; - if (GET_MODE (x) != SImode) goto L299; - if (XINT (x, 0) != 15) goto L299; - x = XEXP (pat, 1); - if (GET_CODE (x) != PLUS) goto L299; - if (GET_MODE (x) != SImode) goto L299; - x = XEXP (XEXP (pat, 1), 0); - if (GET_CODE (x) != REG) goto L299; - if (GET_MODE (x) != SImode) goto L299; - if (XINT (x, 0) != 15) goto L299; - x = XEXP (XEXP (pat, 1), 1); - if (GET_CODE (x) != CONST_INT) goto L299; - if (XWINT (x, 0) != 4) goto L299; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L299; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L299; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L299; - x = XEXP (pat, 0); - operands[0] = x; - if (! register_operand (x, DFmode)) goto L299; - x = XEXP (pat, 1); - operands[1] = x; - if (! register_operand (x, DFmode)) goto L299; - if (! (FP_REG_P (operands[0]) && ! FP_REG_P (operands[1]))) goto L299; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (2, operands)); - INSN_CODE (ins1) = 299; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L299: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L300; - x = XEXP (pat, 0); - if (GET_CODE (x) != REG) goto L300; - if (GET_MODE (x) != SImode) goto L300; - if (XINT (x, 0) != 15) goto L300; - x = XEXP (pat, 1); - if (GET_CODE (x) != PLUS) goto L300; - if (GET_MODE (x) != SImode) goto L300; - x = XEXP (XEXP (pat, 1), 0); - if (GET_CODE (x) != REG) goto L300; - if (GET_MODE (x) != SImode) goto L300; - if (XINT (x, 0) != 15) goto L300; - x = XEXP (XEXP (pat, 1), 1); - operands[0] = x; - if (! immediate_operand (x, SImode)) goto L300; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L300; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L300; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L300; - x = XEXP (pat, 0); - operands[1] = x; - if (! push_operand (x, SFmode)) goto L300; - x = XEXP (pat, 1); - operands[2] = x; - if (! general_operand (x, SFmode)) goto L300; - if (! (GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) >= 4 - && ! reg_mentioned_p (stack_pointer_rtx, operands[2]))) goto L300; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (3, operands)); - INSN_CODE (ins1) = 300; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L300: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L301; - x = XEXP (pat, 0); - if (GET_CODE (x) != REG) goto L301; - if (GET_MODE (x) != SImode) goto L301; - if (XINT (x, 0) != 15) goto L301; - x = XEXP (pat, 1); - if (GET_CODE (x) != PLUS) goto L301; - if (GET_MODE (x) != SImode) goto L301; - x = XEXP (XEXP (pat, 1), 0); - if (GET_CODE (x) != REG) goto L301; - if (GET_MODE (x) != SImode) goto L301; - if (XINT (x, 0) != 15) goto L301; - x = XEXP (XEXP (pat, 1), 1); - operands[0] = x; - if (! immediate_operand (x, SImode)) goto L301; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L301; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L301; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L301; - x = XEXP (pat, 0); - operands[1] = x; - if (! push_operand (x, SImode)) goto L301; - x = XEXP (pat, 1); - operands[2] = x; - if (! general_operand (x, SImode)) goto L301; - if (! (GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) >= 4 - && ! reg_mentioned_p (stack_pointer_rtx, operands[2]))) goto L301; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (3, operands)); - INSN_CODE (ins1) = 301; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L301: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L302; - x = XEXP (pat, 0); - if (GET_CODE (x) != MEM) goto L302; - if (GET_MODE (x) != QImode) goto L302; - x = XEXP (XEXP (pat, 0), 0); - if (GET_CODE (x) != PRE_DEC) goto L302; - if (GET_MODE (x) != SImode) goto L302; - x = XEXP (XEXP (XEXP (pat, 0), 0), 0); - if (GET_CODE (x) != REG) goto L302; - if (GET_MODE (x) != SImode) goto L302; - if (XINT (x, 0) != 15) goto L302; - x = XEXP (pat, 1); - operands[1] = x; - if (! general_operand (x, QImode)) goto L302; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L302; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L302; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L302; - x = XEXP (pat, 0); - if (GET_CODE (x) != REG) goto L302; - if (GET_MODE (x) != SImode) goto L302; - if (XINT (x, 0) != 15) goto L302; - x = XEXP (pat, 1); - if (GET_CODE (x) != MINUS) goto L302; - if (GET_MODE (x) != SImode) goto L302; - x = XEXP (XEXP (pat, 1), 0); - if (GET_CODE (x) != REG) goto L302; - if (GET_MODE (x) != SImode) goto L302; - if (XINT (x, 0) != 15) goto L302; - x = XEXP (XEXP (pat, 1), 1); - if (GET_CODE (x) != CONST_INT) goto L302; - if (XWINT (x, 0) != 2) goto L302; - if (! (! reg_mentioned_p (stack_pointer_rtx, operands[1]))) goto L302; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (2, operands)); - INSN_CODE (ins1) = 302; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L302: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L303; - x = XEXP (pat, 0); - operands[0] = x; - if (! register_operand (x, SImode)) goto L303; - x = XEXP (pat, 1); - if (GET_CODE (x) != CONST_INT) goto L303; - if (XWINT (x, 0) != 0) goto L303; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L303; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L303; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L303; - x = XEXP (pat, 0); - if (GET_CODE (x) != STRICT_LOW_PART) goto L303; - x = XEXP (XEXP (pat, 0), 0); - if (GET_CODE (x) != SUBREG) goto L303; - if (GET_MODE (x) != HImode) goto L303; - x = XEXP (XEXP (XEXP (pat, 0), 0), 0); - if (!rtx_equal_p (operands[0], x)) goto L303; - x = XEXP (XEXP (pat, 0), 0); - if (XINT (x, 1) != 0) goto L303; - x = XEXP (pat, 1); - operands[1] = x; - if (! general_operand (x, HImode)) goto L303; - if (! (strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0]))) goto L303; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (2, operands)); - INSN_CODE (ins1) = 303; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L303: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L304; - x = XEXP (pat, 0); - if (GET_CODE (x) != PC) goto L304; - x = XEXP (pat, 1); - if (GET_CODE (x) != IF_THEN_ELSE) goto L304; - x = XEXP (XEXP (pat, 1), 0); - operands[3] = x; - if (! valid_dbcc_comparison_p (x, VOIDmode)) goto L304; - x = XEXP (XEXP (XEXP (pat, 1), 0), 0); - if (GET_CODE (x) != CC0) goto L304; - x = XEXP (XEXP (XEXP (pat, 1), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L304; - if (XWINT (x, 0) != 0) goto L304; - x = XEXP (XEXP (pat, 1), 1); - if (GET_CODE (x) != LABEL_REF) goto L304; - x = XEXP (XEXP (XEXP (pat, 1), 1), 0); - operands[2] = x; - x = XEXP (XEXP (pat, 1), 2); - if (GET_CODE (x) != PC) goto L304; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L304; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L304; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != PARALLEL) goto L304; - if (XVECLEN (x, 0) != 2) goto L304; - x = XVECEXP (pat, 0, 0); - if (GET_CODE (x) != SET) goto L304; - x = XEXP (XVECEXP (pat, 0, 0), 0); - if (GET_CODE (x) != PC) goto L304; - x = XEXP (XVECEXP (pat, 0, 0), 1); - if (GET_CODE (x) != IF_THEN_ELSE) goto L304; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0); - if (GET_CODE (x) != GE) goto L304; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0); - if (GET_CODE (x) != PLUS) goto L304; - if (GET_MODE (x) != HImode) goto L304; - x = XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0), 0); - operands[0] = x; - if (! register_operand (x, HImode)) goto L304; - x = XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L304; - if (XWINT (x, 0) != -1) goto L304; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L304; - if (XWINT (x, 0) != 0) goto L304; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1); - if (GET_CODE (x) != LABEL_REF) goto L304; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0); - operands[1] = x; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 2); - if (GET_CODE (x) != PC) goto L304; - x = XVECEXP (pat, 0, 1); - if (GET_CODE (x) != SET) goto L304; - x = XEXP (XVECEXP (pat, 0, 1), 0); - if (!rtx_equal_p (operands[0], x)) goto L304; - x = XEXP (XVECEXP (pat, 0, 1), 1); - if (GET_CODE (x) != PLUS) goto L304; - if (GET_MODE (x) != HImode) goto L304; - x = XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - if (!rtx_equal_p (operands[0], x)) goto L304; - x = XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1); - if (GET_CODE (x) != CONST_INT) goto L304; - if (XWINT (x, 0) != -1) goto L304; - if (! (DATA_REG_P (operands[0]))) goto L304; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (4, operands)); - INSN_CODE (ins1) = 304; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L304: - - insn = ins1; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != SET) goto L305; - x = XEXP (pat, 0); - if (GET_CODE (x) != PC) goto L305; - x = XEXP (pat, 1); - if (GET_CODE (x) != IF_THEN_ELSE) goto L305; - x = XEXP (XEXP (pat, 1), 0); - operands[3] = x; - if (! valid_dbcc_comparison_p (x, VOIDmode)) goto L305; - x = XEXP (XEXP (XEXP (pat, 1), 0), 0); - if (GET_CODE (x) != CC0) goto L305; - x = XEXP (XEXP (XEXP (pat, 1), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L305; - if (XWINT (x, 0) != 0) goto L305; - x = XEXP (XEXP (pat, 1), 1); - if (GET_CODE (x) != LABEL_REF) goto L305; - x = XEXP (XEXP (XEXP (pat, 1), 1), 0); - operands[2] = x; - x = XEXP (XEXP (pat, 1), 2); - if (GET_CODE (x) != PC) goto L305; - do { insn = NEXT_INSN (insn); - if (insn == 0) goto L305; } - while (GET_CODE (insn) == NOTE - || (GET_CODE (insn) == INSN - && (GET_CODE (PATTERN (insn)) == USE - || GET_CODE (PATTERN (insn)) == CLOBBER))); - if (GET_CODE (insn) == CODE_LABEL - || GET_CODE (insn) == BARRIER) - goto L305; - pat = PATTERN (insn); - x = pat; - if (GET_CODE (x) != PARALLEL) goto L305; - if (XVECLEN (x, 0) != 2) goto L305; - x = XVECEXP (pat, 0, 0); - if (GET_CODE (x) != SET) goto L305; - x = XEXP (XVECEXP (pat, 0, 0), 0); - if (GET_CODE (x) != PC) goto L305; - x = XEXP (XVECEXP (pat, 0, 0), 1); - if (GET_CODE (x) != IF_THEN_ELSE) goto L305; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0); - if (GET_CODE (x) != GE) goto L305; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0); - if (GET_CODE (x) != PLUS) goto L305; - if (GET_MODE (x) != SImode) goto L305; - x = XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0), 0); - operands[0] = x; - if (! register_operand (x, SImode)) goto L305; - x = XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L305; - if (XWINT (x, 0) != -1) goto L305; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 1); - if (GET_CODE (x) != CONST_INT) goto L305; - if (XWINT (x, 0) != 0) goto L305; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1); - if (GET_CODE (x) != LABEL_REF) goto L305; - x = XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0); - operands[1] = x; - x = XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 2); - if (GET_CODE (x) != PC) goto L305; - x = XVECEXP (pat, 0, 1); - if (GET_CODE (x) != SET) goto L305; - x = XEXP (XVECEXP (pat, 0, 1), 0); - if (!rtx_equal_p (operands[0], x)) goto L305; - x = XEXP (XVECEXP (pat, 0, 1), 1); - if (GET_CODE (x) != PLUS) goto L305; - if (GET_MODE (x) != SImode) goto L305; - x = XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - if (!rtx_equal_p (operands[0], x)) goto L305; - x = XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1); - if (GET_CODE (x) != CONST_INT) goto L305; - if (XWINT (x, 0) != -1) goto L305; - if (! (DATA_REG_P (operands[0]))) goto L305; - PATTERN (ins1) = gen_rtx (PARALLEL, VOIDmode, gen_rtvec_v (4, operands)); - INSN_CODE (ins1) = 305; - delete_for_peephole (NEXT_INSN (ins1), insn); - return NEXT_INSN (insn); - L305: - - return 0; -} - -rtx peep_operand[4]; diff --git a/gnu/usr.bin/gcc2/arch/hp300/insn-recog.c b/gnu/usr.bin/gcc2/arch/hp300/insn-recog.c deleted file mode 100644 index 1aea9785e4b5..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/insn-recog.c +++ /dev/null @@ -1,6589 +0,0 @@ -/* Generated automatically by the program `genrecog' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "insn-config.h" -#include "recog.h" -#include "real.h" -#include "output.h" -#include "flags.h" - - -/* `recog' contains a decision tree - that recognizes whether the rtx X0 is a valid instruction. - - recog returns -1 if the rtx is not valid. - If the rtx is valid, recog returns a nonnegative number - which is the insn code number for the pattern that matched. - This is the same as the order in the machine description of - the entry that matched. This number can be used as an index into - entry that matched. This number can be used as an index into various - insn_* tables, such as insn_templates, insn_outfun, and insn_n_operands - (found in insn-output.c). - - The third argument to recog is an optional pointer to an int. - If present, recog will accept a pattern if it matches except for - missing CLOBBER expressions at the end. In that case, the value - pointed to by the optional pointer will be set to the number of - CLOBBERs that need to be added (it should be initialized to zero by - the caller). If it is set nonzero, the caller should allocate a - PARALLEL of the appropriate size, copy the initial entries, and call - add_clobbers (found in insn-emit.c) to fill in the CLOBBERs.*/ - -rtx recog_operand[MAX_RECOG_OPERANDS]; - -rtx *recog_operand_loc[MAX_RECOG_OPERANDS]; - -rtx *recog_dup_loc[MAX_DUP_OPERANDS]; - -char recog_dup_num[MAX_DUP_OPERANDS]; - -#define operands recog_operand - -int -recog_1 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case HImode: - switch (GET_CODE (x1)) - { - case TRUNCATE: - goto L628; - case ZERO_EXTEND: - goto L208; - case SIGN_EXTEND: - goto L220; - case FIX: - goto L313; - case PLUS: - goto L386; - case MINUS: - goto L455; - case MULT: - goto L501; - case DIV: - goto L623; - case UDIV: - goto L641; - case MOD: - goto L683; - case UMOD: - goto L701; - case AND: - goto L746; - case IOR: - goto L785; - case XOR: - goto L824; - case NEG: - goto L862; - case NOT: - goto L928; - } - } - if (general_operand (x1, HImode)) - { - ro[1] = x1; - return 30; - } - goto ret0; - - L628: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - switch (GET_CODE (x2)) - { - case DIV: - goto L629; - case UDIV: - goto L647; - case MOD: - goto L689; - case UMOD: - goto L707; - } - } - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 43; - } - goto ret0; - - L629: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L630; - } - goto ret0; - - L630: - x3 = XEXP (x2, 1); - switch (GET_CODE (x3)) - { - case SIGN_EXTEND: - if (GET_MODE (x3) == SImode && 1) - goto L631; - break; - case CONST_INT: - ro[2] = x3; - return 129; - } - goto ret0; - - L631: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, HImode)) - { - ro[2] = x4; - return 128; - } - goto ret0; - - L647: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L648; - } - goto ret0; - - L648: - x3 = XEXP (x2, 1); - switch (GET_CODE (x3)) - { - case ZERO_EXTEND: - if (GET_MODE (x3) == SImode && 1) - goto L649; - break; - case CONST_INT: - ro[2] = x3; - return 132; - } - goto ret0; - - L649: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, HImode)) - { - ro[2] = x4; - return 131; - } - goto ret0; - - L689: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L690; - } - goto ret0; - - L690: - x3 = XEXP (x2, 1); - switch (GET_CODE (x3)) - { - case SIGN_EXTEND: - if (GET_MODE (x3) == SImode && 1) - goto L691; - break; - case CONST_INT: - ro[2] = x3; - return 141; - } - goto ret0; - - L691: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, HImode)) - { - ro[2] = x4; - return 140; - } - goto ret0; - - L707: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L708; - } - goto ret0; - - L708: - x3 = XEXP (x2, 1); - switch (GET_CODE (x3)) - { - case ZERO_EXTEND: - if (GET_MODE (x3) == SImode && 1) - goto L709; - break; - case CONST_INT: - ro[2] = x3; - return 144; - } - goto ret0; - - L709: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, HImode)) - { - ro[2] = x4; - return 143; - } - goto ret0; - - L208: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 48; - } - goto ret0; - - L220: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - return 51; - } - goto ret0; - - L313: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == FIX && 1) - goto L314; - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 76; - } - L357: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 79; - } - goto ret0; - - L314: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && register_operand (x3, DFmode)) - { - ro[1] = x3; - if (TARGET_68040) - { - *pnum_clobbers = 2; - return 71; - } - } - goto ret0; - - L386: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L387; - } - goto ret0; - - L387: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 85; - } - goto ret0; - - L455: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L456; - } - goto ret0; - - L456: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 99; - } - goto ret0; - - L501: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L502; - } - goto ret0; - - L502: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 109; - } - goto ret0; - - L623: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L624; - } - goto ret0; - - L624: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 127; - } - goto ret0; - - L641: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L642; - } - goto ret0; - - L642: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 130; - } - goto ret0; - - L683: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L684; - } - goto ret0; - - L684: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 139; - } - goto ret0; - - L701: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L702; - } - goto ret0; - - L702: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 142; - } - goto ret0; - - L746: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L747; - } - goto ret0; - - L747: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 148; - } - goto ret0; - - L785: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L786; - } - goto ret0; - - L786: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 155; - } - goto ret0; - - L824: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L825; - } - goto ret0; - - L825: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 162; - } - goto ret0; - - L862: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 169; - } - goto ret0; - - L928: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 187; - } - goto ret0; - ret0: return -1; -} - -int -recog_2 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case QImode: - switch (GET_CODE (x1)) - { - case TRUNCATE: - goto L192; - case FIX: - goto L328; - case PLUS: - goto L403; - case MINUS: - goto L466; - case AND: - goto L763; - case IOR: - goto L802; - case XOR: - goto L841; - case NEG: - goto L871; - case NOT: - goto L937; - case EQ: - goto L1275; - case NE: - goto L1280; - case GT: - goto L1285; - case GTU: - goto L1290; - case LT: - goto L1295; - case LTU: - goto L1300; - case GE: - goto L1305; - case GEU: - goto L1310; - case LE: - goto L1315; - case LEU: - goto L1320; - } - } - if (general_operand (x1, QImode)) - { - ro[1] = x1; - return 32; - } - goto ret0; - - L192: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 41; - } - L196: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 42; - } - goto ret0; - - L328: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == FIX && 1) - goto L329; - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 75; - } - L353: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 78; - } - goto ret0; - - L329: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && register_operand (x3, DFmode)) - { - ro[1] = x3; - if (TARGET_68040) - { - *pnum_clobbers = 2; - return 72; - } - } - goto ret0; - - L403: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L404; - } - goto ret0; - - L404: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 88; - } - goto ret0; - - L466: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L467; - } - goto ret0; - - L467: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 101; - } - goto ret0; - - L763: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L764; - } - goto ret0; - - L764: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 151; - } - goto ret0; - - L802: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L803; - } - goto ret0; - - L803: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 158; - } - goto ret0; - - L841: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L842; - } - goto ret0; - - L842: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 165; - } - goto ret0; - - L871: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 171; - } - goto ret0; - - L937: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 189; - } - goto ret0; - - L1275: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1276; - goto ret0; - - L1276: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 248; - goto ret0; - - L1280: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1281; - goto ret0; - - L1281: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 249; - goto ret0; - - L1285: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1286; - goto ret0; - - L1286: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 250; - goto ret0; - - L1290: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1291; - goto ret0; - - L1291: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 251; - goto ret0; - - L1295: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1296; - goto ret0; - - L1296: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 252; - goto ret0; - - L1300: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1301; - goto ret0; - - L1301: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 253; - goto ret0; - - L1305: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1306; - goto ret0; - - L1306: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 254; - goto ret0; - - L1310: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1311; - goto ret0; - - L1311: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 255; - goto ret0; - - L1315: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1316; - goto ret0; - - L1316: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 256; - goto ret0; - - L1320: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L1321; - goto ret0; - - L1321: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 257; - goto ret0; - ret0: return -1; -} - -int -recog_3 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != SImode) - goto ret0; - switch (GET_CODE (x1)) - { - case PLUS: - goto L375; - case MINUS: - goto L444; - case MULT: - goto L506; - case IOR: - goto L780; - case XOR: - goto L819; - case NEG: - goto L858; - case NOT: - goto L924; - case ZERO_EXTRACT: - goto L1168; - case SIGN_EXTRACT: - goto L1180; - } - goto ret0; - - L375: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L381; - } - goto ret0; - - L381: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == SIGN_EXTEND && 1) - goto L382; - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 83; - } - goto ret0; - - L382: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[2] = x3; - return 84; - } - goto ret0; - - L444: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L450; - } - goto ret0; - - L450: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == SIGN_EXTEND && 1) - goto L451; - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 97; - } - goto ret0; - - L451: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[2] = x3; - return 98; - } - goto ret0; - - L506: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - switch (GET_CODE (x2)) - { - case SIGN_EXTEND: - goto L507; - case ZERO_EXTEND: - goto L525; - } - } - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L520; - } - goto ret0; - - L507: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[1] = x3; - goto L508; - } - goto ret0; - - L508: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case SIGN_EXTEND: - if (GET_MODE (x2) == SImode && 1) - goto L509; - break; - case CONST_INT: - ro[2] = x2; - if (INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff) - return 111; - } - goto ret0; - - L509: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[2] = x3; - return 110; - } - goto ret0; - - L525: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[1] = x3; - goto L526; - } - goto ret0; - - L526: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case ZERO_EXTEND: - if (GET_MODE (x2) == SImode && 1) - goto L527; - break; - case CONST_INT: - ro[2] = x2; - if (INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff) - return 114; - } - goto ret0; - - L527: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, HImode)) - { - ro[2] = x3; - return 113; - } - goto ret0; - - L520: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - if (TARGET_68020) - return 112; - } - goto ret0; - - L780: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L781; - } - goto ret0; - - L781: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 154; - } - goto ret0; - - L819: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L820; - } - goto ret0; - - L820: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 161; - } - goto ret0; - - L858: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 168; - } - goto ret0; - - L924: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 186; - } - goto ret0; - - L1168: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - goto L1169; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[1] = x2; - goto L1175; - } - } - goto ret0; - - L1169: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1170; - } - L1199: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1200; - } - goto ret0; - - L1170: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 32) - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[1], 0))) - return 231; - } - x2 = XEXP (x1, 1); - goto L1199; - - L1200: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD) - return 236; - } - goto ret0; - - L1175: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1176; - } - L1240: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1241; - } - goto ret0; - - L1176: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16) - && GET_CODE (operands[3]) == CONST_INT - && INTVAL (operands[3]) % INTVAL (operands[2]) == 0 - && (GET_CODE (operands[1]) == REG - || ! mode_dependent_address_p (XEXP (operands[1], 0)))) - return 232; - } - x2 = XEXP (x1, 1); - goto L1240; - - L1241: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD) - return 242; - } - goto ret0; - - L1180: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - goto L1181; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[1] = x2; - goto L1187; - } - } - goto ret0; - - L1181: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1182; - } - L1193: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1194; - } - goto ret0; - - L1182: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 32) - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[1], 0))) - return 233; - } - x2 = XEXP (x1, 1); - goto L1193; - - L1194: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD) - return 235; - } - goto ret0; - - L1187: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1188; - } - L1234: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1235; - } - goto ret0; - - L1188: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16) - && GET_CODE (operands[3]) == CONST_INT - && INTVAL (operands[3]) % INTVAL (operands[2]) == 0 - && (GET_CODE (operands[1]) == REG - || ! mode_dependent_address_p (XEXP (operands[1], 0)))) - return 234; - } - x2 = XEXP (x1, 1); - goto L1234; - - L1235: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD) - return 241; - } - goto ret0; - ret0: return -1; -} - -int -recog_4 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (general_operand (x2, HImode)) - { - ro[0] = x2; - goto L391; - } - L967: - if (register_operand (x2, HImode)) - { - ro[0] = x2; - goto L968; - } - break; - case QImode: - if (general_operand (x2, QImode)) - { - ro[0] = x2; - goto L408; - } - L978: - if (register_operand (x2, QImode)) - { - ro[0] = x2; - goto L979; - } - } - goto ret0; - - L391: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case HImode: - switch (GET_CODE (x1)) - { - case PLUS: - goto L392; - case MINUS: - goto L461; - case AND: - goto L752; - case IOR: - goto L791; - case XOR: - goto L830; - case NEG: - goto L867; - case NOT: - goto L933; - } - } - if (general_operand (x1, HImode)) - { - ro[1] = x1; - return 31; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L392: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L393; - L398: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L399; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L393: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 86; - } - x2 = XEXP (x1, 0); - goto L398; - - L399: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 87; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L461: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L462; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L462: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 100; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L752: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L753; - L758: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L759; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L753: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 149; - } - x2 = XEXP (x1, 0); - goto L758; - - L759: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 150; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L791: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L792; - L797: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L798; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L792: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 156; - } - x2 = XEXP (x1, 0); - goto L797; - - L798: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 157; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L830: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L831; - L836: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L837; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L831: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 163; - } - x2 = XEXP (x1, 0); - goto L836; - - L837: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 164; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L867: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - return 170; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L933: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - return 188; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L967; - - L968: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != HImode) - goto ret0; - switch (GET_CODE (x1)) - { - case ASHIFT: - goto L969; - case ASHIFTRT: - goto L1008; - case LSHIFT: - goto L1047; - case LSHIFTRT: - goto L1086; - case ROTATE: - goto L1113; - case ROTATERT: - goto L1140; - } - goto ret0; - - L969: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L970; - goto ret0; - - L970: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 195; - } - goto ret0; - - L1008: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1009; - goto ret0; - - L1009: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 202; - } - goto ret0; - - L1047: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1048; - goto ret0; - - L1048: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 209; - } - goto ret0; - - L1086: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1087; - goto ret0; - - L1087: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 216; - } - goto ret0; - - L1113: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1114; - goto ret0; - - L1114: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 221; - } - goto ret0; - - L1140: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1141; - goto ret0; - - L1141: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 226; - } - goto ret0; - - L408: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case QImode: - switch (GET_CODE (x1)) - { - case PLUS: - goto L409; - case MINUS: - goto L472; - case AND: - goto L769; - case IOR: - goto L808; - case XOR: - goto L847; - case NEG: - goto L876; - case NOT: - goto L942; - } - } - if (general_operand (x1, QImode)) - { - ro[1] = x1; - return 33; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L409: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L410; - L415: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L416; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L410: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 89; - } - x2 = XEXP (x1, 0); - goto L415; - - L416: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 90; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L472: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L473; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L473: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 102; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L769: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L770; - L775: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L776; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L770: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 152; - } - x2 = XEXP (x1, 0); - goto L775; - - L776: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 153; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L808: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L809; - L814: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L815; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L809: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 159; - } - x2 = XEXP (x1, 0); - goto L814; - - L815: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 160; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L847: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L848; - L853: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L854; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L848: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 166; - } - x2 = XEXP (x1, 0); - goto L853; - - L854: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 167; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L876: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - return 172; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L942: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - return 190; - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 0); - goto L978; - - L979: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != QImode) - goto ret0; - switch (GET_CODE (x1)) - { - case ASHIFT: - goto L980; - case ASHIFTRT: - goto L1019; - case LSHIFT: - goto L1058; - case LSHIFTRT: - goto L1097; - case ROTATE: - goto L1124; - case ROTATERT: - goto L1151; - } - goto ret0; - - L980: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L981; - goto ret0; - - L981: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 197; - } - goto ret0; - - L1019: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1020; - goto ret0; - - L1020: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 204; - } - goto ret0; - - L1058: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1059; - goto ret0; - - L1059: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 211; - } - goto ret0; - - L1097: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1098; - goto ret0; - - L1098: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 218; - } - goto ret0; - - L1124: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1125; - goto ret0; - - L1125: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 223; - } - goto ret0; - - L1151: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1152; - goto ret0; - - L1152: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 228; - } - goto ret0; - ret0: return -1; -} - -int -recog_5 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - x2 = XEXP (x1, 0); - switch (GET_CODE (x2)) - { - case EQ: - goto L1326; - case NE: - goto L1335; - case GT: - goto L1344; - case GTU: - goto L1353; - case LT: - goto L1362; - case LTU: - goto L1371; - case GE: - goto L1380; - case GEU: - goto L1389; - case LE: - goto L1398; - case LEU: - goto L1407; - } - goto ret0; - - L1326: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1327; - goto ret0; - - L1327: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1328; - goto ret0; - - L1328: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1329; - case PC: - goto L1419; - } - goto ret0; - - L1329: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1330; - - L1330: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 258; - goto ret0; - - L1419: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1420; - goto ret0; - - L1420: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 268; - - L1335: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1336; - goto ret0; - - L1336: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1337; - goto ret0; - - L1337: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1338; - case PC: - goto L1428; - } - goto ret0; - - L1338: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1339; - - L1339: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 259; - goto ret0; - - L1428: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1429; - goto ret0; - - L1429: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 269; - - L1344: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1345; - goto ret0; - - L1345: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1346; - goto ret0; - - L1346: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1347; - case PC: - goto L1437; - } - goto ret0; - - L1347: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1348; - - L1348: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 260; - goto ret0; - - L1437: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1438; - goto ret0; - - L1438: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 270; - - L1353: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1354; - goto ret0; - - L1354: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1355; - goto ret0; - - L1355: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1356; - case PC: - goto L1446; - } - goto ret0; - - L1356: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1357; - - L1357: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 261; - goto ret0; - - L1446: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1447; - goto ret0; - - L1447: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 271; - - L1362: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1363; - goto ret0; - - L1363: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1364; - goto ret0; - - L1364: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1365; - case PC: - goto L1455; - } - goto ret0; - - L1365: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1366; - - L1366: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 262; - goto ret0; - - L1455: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1456; - goto ret0; - - L1456: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 272; - - L1371: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1372; - goto ret0; - - L1372: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1373; - goto ret0; - - L1373: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1374; - case PC: - goto L1464; - } - goto ret0; - - L1374: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1375; - - L1375: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 263; - goto ret0; - - L1464: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1465; - goto ret0; - - L1465: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 273; - - L1380: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1381; - goto ret0; - - L1381: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1382; - goto ret0; - - L1382: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1383; - case PC: - goto L1473; - } - goto ret0; - - L1383: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1384; - - L1384: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 264; - goto ret0; - - L1473: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1474; - goto ret0; - - L1474: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 274; - - L1389: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1390; - goto ret0; - - L1390: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1391; - goto ret0; - - L1391: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1392; - case PC: - goto L1482; - } - goto ret0; - - L1392: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1393; - - L1393: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 265; - goto ret0; - - L1482: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1483; - goto ret0; - - L1483: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 275; - - L1398: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1399; - goto ret0; - - L1399: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1400; - goto ret0; - - L1400: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1401; - case PC: - goto L1491; - } - goto ret0; - - L1401: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1402; - - L1402: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 266; - goto ret0; - - L1491: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1492; - goto ret0; - - L1492: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 276; - - L1407: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L1408; - goto ret0; - - L1408: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L1409; - goto ret0; - - L1409: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L1410; - case PC: - goto L1500; - } - goto ret0; - - L1410: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L1411; - - L1411: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 267; - goto ret0; - - L1500: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1501; - goto ret0; - - L1501: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 277; - ret0: return -1; -} - -int -recog_6 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 0); - switch (GET_MODE (x1)) - { - case DFmode: - if (GET_CODE (x1) == MEM && push_operand (x1, DFmode)) - { - ro[0] = x1; - goto L2; - } - L173: - if (general_operand (x1, DFmode)) - { - ro[0] = x1; - goto L227; - } - break; - case DImode: - if (GET_CODE (x1) == MEM && push_operand (x1, DImode)) - { - ro[0] = x1; - goto L5; - } - L184: - if (general_operand (x1, DImode)) - { - ro[0] = x1; - goto L185; - } - break; - case SImode: - if (GET_CODE (x1) == MEM && push_operand (x1, SImode)) - { - ro[0] = x1; - goto L148; - } - L150: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - goto L203; - } - break; - case HImode: - if (general_operand (x1, HImode)) - { - ro[0] = x1; - goto L199; - } - L961: - if (register_operand (x1, HImode)) - { - ro[0] = x1; - goto L962; - } - break; - case QImode: - if (general_operand (x1, QImode)) - { - ro[0] = x1; - goto L191; - } - L972: - if (register_operand (x1, QImode)) - { - ro[0] = x1; - goto L973; - } - break; - case SFmode: - if (general_operand (x1, SFmode)) - { - ro[0] = x1; - goto L237; - } - break; - case XFmode: - if (nonimmediate_operand (x1, XFmode)) - { - ro[0] = x1; - goto L177; - } - } - L187: - switch (GET_MODE (x1)) - { - case SImode: - switch (GET_CODE (x1)) - { - case MEM: - if (push_operand (x1, SImode)) - { - ro[0] = x1; - goto L188; - } - break; - case ZERO_EXTRACT: - goto L1155; - } - L373: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - goto L374; - } - L739: - if (not_sp_operand (x1, SImode)) - { - ro[0] = x1; - goto L740; - } - L944: - if (register_operand (x1, SImode)) - { - ro[0] = x1; - goto L945; - } - } - switch (GET_CODE (x1)) - { - case CC0: - goto L8; - case STRICT_LOW_PART: - goto L160; - case PC: - goto L1324; - } - L1595: - ro[0] = x1; - goto L1596; - L1612: - switch (GET_CODE (x1)) - { - case PC: - goto L1613; - case CC0: - goto L1703; - } - switch (GET_MODE (x1)) - { - case SImode: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - goto L1751; - } - break; - case DFmode: - if (register_operand (x1, DFmode)) - { - ro[0] = x1; - goto L1619; - } - L1718: - if (general_operand (x1, DFmode)) - { - ro[0] = x1; - goto L1719; - } - break; - case SFmode: - if (register_operand (x1, SFmode)) - { - ro[0] = x1; - goto L1626; - } - L1722: - if (general_operand (x1, SFmode)) - { - ro[0] = x1; - goto L1723; - } - break; - case XFmode: - if (general_operand (x1, XFmode)) - { - ro[0] = x1; - goto L1711; - } - break; - case QImode: - if (general_operand (x1, QImode)) - { - ro[0] = x1; - goto L1743; - } - break; - case HImode: - if (general_operand (x1, HImode)) - { - ro[0] = x1; - goto L1747; - } - } - goto ret0; - - L2: - x1 = XEXP (x0, 1); - if (general_operand (x1, DFmode)) - { - ro[1] = x1; - return 0; - } - x1 = XEXP (x0, 0); - goto L173; - - L227: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case DFmode: - switch (GET_CODE (x1)) - { - case FLOAT_EXTEND: - goto L228; - case FLOAT: - goto L262; - case FIX: - goto L333; - case PLUS: - goto L420; - case MINUS: - goto L477; - case MULT: - goto L599; - case DIV: - goto L659; - case NEG: - goto L890; - case SQRT: - goto L900; - case ABS: - goto L914; - } - } - if (general_operand (x1, DFmode)) - { - ro[1] = x1; - return 35; - } - x1 = XEXP (x0, 0); - goto L1595; - - L228: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - goto L233; - x1 = XEXP (x0, 0); - goto L1595; - - L233: - ro[1] = x2; - if (TARGET_FPA) - return 54; - L234: - ro[1] = x2; - if (TARGET_68881) - return 55; - x1 = XEXP (x0, 0); - goto L1595; - - L262: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - goto L267; - L276: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 67; - } - L284: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 69; - } - x1 = XEXP (x0, 0); - goto L1595; - - L267: - ro[1] = x2; - if (TARGET_FPA) - return 64; - L268: - ro[1] = x2; - if (TARGET_68881) - return 65; - goto L276; - - L333: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881 && !TARGET_68040) - return 73; - } - x1 = XEXP (x0, 0); - goto L1595; - - L420: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L421; - } - x1 = XEXP (x0, 0); - goto L1595; - - L421: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - goto L427; - x1 = XEXP (x0, 0); - goto L1595; - - L427: - ro[2] = x2; - if (TARGET_FPA) - return 92; - L428: - ro[2] = x2; - if (TARGET_68881) - return 93; - x1 = XEXP (x0, 0); - goto L1595; - - L477: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L478; - } - x1 = XEXP (x0, 0); - goto L1595; - - L478: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - goto L484; - x1 = XEXP (x0, 0); - goto L1595; - - L484: - ro[2] = x2; - if (TARGET_FPA) - return 104; - L485: - ro[2] = x2; - if (TARGET_68881) - return 105; - x1 = XEXP (x0, 0); - goto L1595; - - L599: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L600; - } - x1 = XEXP (x0, 0); - goto L1595; - - L600: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - goto L606; - x1 = XEXP (x0, 0); - goto L1595; - - L606: - ro[2] = x2; - if (TARGET_FPA) - return 122; - L607: - ro[2] = x2; - if (TARGET_68881) - return 123; - x1 = XEXP (x0, 0); - goto L1595; - - L659: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L660; - } - x1 = XEXP (x0, 0); - goto L1595; - - L660: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - goto L666; - x1 = XEXP (x0, 0); - goto L1595; - - L666: - ro[2] = x2; - if (TARGET_FPA) - return 134; - L667: - ro[2] = x2; - if (TARGET_68881) - return 135; - x1 = XEXP (x0, 0); - goto L1595; - - L890: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - goto L895; - x1 = XEXP (x0, 0); - goto L1595; - - L895: - ro[1] = x2; - if (TARGET_FPA) - return 177; - L896: - ro[1] = x2; - if (TARGET_68881) - return 178; - x1 = XEXP (x0, 0); - goto L1595; - - L900: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 179; - } - x1 = XEXP (x0, 0); - goto L1595; - - L914: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - goto L919; - x1 = XEXP (x0, 0); - goto L1595; - - L919: - ro[1] = x2; - if (TARGET_FPA) - return 184; - L920: - ro[1] = x2; - if (TARGET_68881) - return 185; - x1 = XEXP (x0, 0); - goto L1595; - - L5: - x1 = XEXP (x0, 1); - if (general_operand (x1, DImode)) - { - ro[1] = x1; - return 1; - } - x1 = XEXP (x0, 0); - goto L184; - - L185: - x1 = XEXP (x0, 1); - if (general_operand (x1, DImode)) - { - ro[1] = x1; - return 39; - } - x1 = XEXP (x0, 0); - goto L1595; - - L148: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - { - ro[1] = x1; - if (GET_CODE (operands[1]) == CONST_INT - && INTVAL (operands[1]) >= -0x8000 - && INTVAL (operands[1]) < 0x8000) - return 26; - } - x1 = XEXP (x0, 0); - goto L150; - - L203: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case SImode: - switch (GET_CODE (x1)) - { - case ZERO_EXTEND: - goto L204; - case SIGN_EXTEND: - goto L216; - case FIX: - goto L298; - } - } - if (GET_CODE (x1) == CONST_INT && XWINT (x1, 0) == 0 && 1) - if ((TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))) - return 27; - L154: - if (general_operand (x1, SImode)) - { - ro[1] = x1; - return 29; - } - x1 = XEXP (x0, 0); - goto L187; - - L204: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 47; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 49; - } - } - x1 = XEXP (x0, 0); - goto L187; - - L216: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[1] = x2; - return 50; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - if (TARGET_68020) - return 52; - } - } - x1 = XEXP (x0, 0); - goto L187; - - L298: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - switch (GET_CODE (x2)) - { - case FIX: - goto L299; - } - break; - case SFmode: - if (GET_CODE (x2) == FIX && 1) - goto L366; - } - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 77; - } - L361: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 80; - } - x1 = XEXP (x0, 0); - goto L187; - - L299: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && register_operand (x3, DFmode)) - { - ro[1] = x3; - if (TARGET_68040) - { - *pnum_clobbers = 2; - return 70; - } - } - L371: - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - if (TARGET_FPA) - return 82; - } - x1 = XEXP (x0, 0); - goto L187; - - L366: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_FPA) - return 81; - } - x1 = XEXP (x0, 0); - goto L187; - L199: - tem = recog_1 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L961; - - L962: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != HImode) - { - x1 = XEXP (x0, 0); - goto L1595; - } - switch (GET_CODE (x1)) - { - case ASHIFT: - goto L963; - case ASHIFTRT: - goto L1002; - case LSHIFT: - goto L1041; - case LSHIFTRT: - goto L1080; - case ROTATE: - goto L1107; - case ROTATERT: - goto L1134; - } - x1 = XEXP (x0, 0); - goto L1595; - - L963: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L964; - } - x1 = XEXP (x0, 0); - goto L1595; - - L964: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 194; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1002: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L1003; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1003: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 201; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1041: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L1042; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1042: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 208; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1080: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L1081; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1081: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 215; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1107: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L1108; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1108: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 220; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1134: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[1] = x2; - goto L1135; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1135: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 225; - } - x1 = XEXP (x0, 0); - goto L1595; - L191: - tem = recog_2 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L972; - - L973: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != QImode) - { - x1 = XEXP (x0, 0); - goto L1595; - } - switch (GET_CODE (x1)) - { - case ASHIFT: - goto L974; - case ASHIFTRT: - goto L1013; - case LSHIFT: - goto L1052; - case LSHIFTRT: - goto L1091; - case ROTATE: - goto L1118; - case ROTATERT: - goto L1145; - } - x1 = XEXP (x0, 0); - goto L1595; - - L974: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L975; - } - x1 = XEXP (x0, 0); - goto L1595; - - L975: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 196; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1013: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L1014; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1014: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 203; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1052: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L1053; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1053: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 210; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1091: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L1092; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1092: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 217; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1118: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L1119; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1119: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 222; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1145: - x2 = XEXP (x1, 0); - if (register_operand (x2, QImode)) - { - ro[1] = x2; - goto L1146; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1146: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 227; - } - x1 = XEXP (x0, 0); - goto L1595; - - L237: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case SFmode: - switch (GET_CODE (x1)) - { - case FLOAT_TRUNCATE: - goto L238; - case FLOAT: - goto L252; - case FIX: - goto L337; - case PLUS: - goto L432; - case MINUS: - goto L489; - case MULT: - goto L611; - case DIV: - goto L671; - case NEG: - goto L880; - case ABS: - goto L904; - } - } - if (general_operand (x1, SFmode)) - { - ro[1] = x1; - return 34; - } - x1 = XEXP (x0, 0); - goto L1595; - - L238: - x2 = XEXP (x1, 0); - if (general_operand (x2, DFmode)) - goto L243; - L248: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 59; - } - x1 = XEXP (x0, 0); - goto L1595; - - L243: - ro[1] = x2; - if (TARGET_FPA) - return 57; - L244: - ro[1] = x2; - if (TARGET_68040_ONLY) - return 58; - goto L248; - - L252: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - goto L257; - L272: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 66; - } - L280: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 68; - } - x1 = XEXP (x0, 0); - goto L1595; - - L257: - ro[1] = x2; - if (TARGET_FPA) - return 61; - L258: - ro[1] = x2; - if (TARGET_68881) - return 62; - goto L272; - - L337: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_68881 && !TARGET_68040) - return 74; - } - x1 = XEXP (x0, 0); - goto L1595; - - L432: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L433; - } - x1 = XEXP (x0, 0); - goto L1595; - - L433: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - goto L439; - x1 = XEXP (x0, 0); - goto L1595; - - L439: - ro[2] = x2; - if (TARGET_FPA) - return 95; - L440: - ro[2] = x2; - if (TARGET_68881) - return 96; - x1 = XEXP (x0, 0); - goto L1595; - - L489: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L490; - } - x1 = XEXP (x0, 0); - goto L1595; - - L490: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - goto L496; - x1 = XEXP (x0, 0); - goto L1595; - - L496: - ro[2] = x2; - if (TARGET_FPA) - return 107; - L497: - ro[2] = x2; - if (TARGET_68881) - return 108; - x1 = XEXP (x0, 0); - goto L1595; - - L611: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L612; - } - x1 = XEXP (x0, 0); - goto L1595; - - L612: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - goto L618; - x1 = XEXP (x0, 0); - goto L1595; - - L618: - ro[2] = x2; - if (TARGET_FPA) - return 125; - L619: - ro[2] = x2; - if (TARGET_68881) - return 126; - x1 = XEXP (x0, 0); - goto L1595; - - L671: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L672; - } - x1 = XEXP (x0, 0); - goto L1595; - - L672: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - goto L678; - x1 = XEXP (x0, 0); - goto L1595; - - L678: - ro[2] = x2; - if (TARGET_FPA) - return 137; - L679: - ro[2] = x2; - if (TARGET_68881) - return 138; - x1 = XEXP (x0, 0); - goto L1595; - - L880: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - goto L885; - x1 = XEXP (x0, 0); - goto L1595; - - L885: - ro[1] = x2; - if (TARGET_FPA) - return 174; - L886: - ro[1] = x2; - if (TARGET_68881) - return 175; - x1 = XEXP (x0, 0); - goto L1595; - - L904: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - goto L909; - x1 = XEXP (x0, 0); - goto L1595; - - L909: - ro[1] = x2; - if (TARGET_FPA) - return 181; - L910: - ro[1] = x2; - if (TARGET_68881) - return 182; - x1 = XEXP (x0, 0); - goto L1595; - - L177: - x1 = XEXP (x0, 1); - if (nonimmediate_operand (x1, XFmode)) - goto L181; - x1 = XEXP (x0, 0); - goto L1595; - - L181: - ro[1] = x1; - if (TARGET_68881) - return 37; - L182: - ro[1] = x1; - if (! TARGET_68881) - return 38; - x1 = XEXP (x0, 0); - goto L1595; - - L188: - x1 = XEXP (x0, 1); - if (address_operand (x1, SImode)) - { - ro[1] = x1; - return 40; - } - x1 = XEXP (x0, 0); - goto L373; - - L1155: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[0] = x2; - goto L1156; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[0] = x2; - goto L1162; - } - } - goto L739; - - L1156: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[1] = x2; - goto L1157; - } - L1204: - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1205; - } - goto L739; - - L1157: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1158; - } - x2 = XEXP (x1, 1); - goto L1204; - - L1158: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - { - ro[3] = x1; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT - && (INTVAL (operands[1]) == 32) - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[0], 0))) - return 229; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 1); - goto L1204; - - L1205: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1206; - } - goto L739; - - L1206: - x1 = XEXP (x0, 1); - switch (GET_CODE (x1)) - { - case XOR: - if (GET_MODE (x1) == SImode && 1) - goto L1207; - break; - case CONST_INT: - if (XWINT (x1, 0) == 0 && 1) - if (TARGET_68020 && TARGET_BITFIELD) - return 238; - if (XWINT (x1, 0) == -1 && 1) - if (TARGET_68020 && TARGET_BITFIELD) - return 239; - } - L1229: - if (general_operand (x1, SImode)) - { - ro[3] = x1; - if (TARGET_68020 && TARGET_BITFIELD) - return 240; - } - x1 = XEXP (x0, 0); - goto L739; - - L1207: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == ZERO_EXTRACT && 1) - goto L1208; - x1 = XEXP (x0, 0); - goto L739; - - L1208: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[0]) && 1) - goto L1209; - x1 = XEXP (x0, 0); - goto L739; - - L1209: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L1210; - x1 = XEXP (x0, 0); - goto L739; - - L1210: - x3 = XEXP (x2, 2); - if (rtx_equal_p (x3, ro[2]) && 1) - goto L1211; - x1 = XEXP (x0, 0); - goto L739; - - L1211: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, VOIDmode)) - { - ro[3] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) == -1 - || (GET_CODE (operands[1]) == CONST_INT - && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))) - return 237; - } - x1 = XEXP (x0, 0); - goto L739; - - L1162: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - { - ro[1] = x2; - goto L1163; - } - L1245: - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1246; - } - goto L739; - - L1163: - x2 = XEXP (x1, 2); - if (immediate_operand (x2, SImode)) - { - ro[2] = x2; - goto L1164; - } - x2 = XEXP (x1, 1); - goto L1245; - - L1164: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - { - ro[3] = x1; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT - && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16) - && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) % INTVAL (operands[1]) == 0 - && (GET_CODE (operands[0]) == REG - || ! mode_dependent_address_p (XEXP (operands[0], 0)))) - return 230; - } - x1 = XEXP (x0, 0); - x2 = XEXP (x1, 1); - goto L1245; - - L1246: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L1247; - } - goto L739; - - L1247: - x1 = XEXP (x0, 1); - switch (GET_CODE (x1)) - { - case CONST_INT: - if (XWINT (x1, 0) == 0 && 1) - if (TARGET_68020 && TARGET_BITFIELD) - return 243; - if (XWINT (x1, 0) == -1 && 1) - if (TARGET_68020 && TARGET_BITFIELD) - return 244; - } - L1259: - if (general_operand (x1, SImode)) - { - ro[3] = x1; - if (TARGET_68020 && TARGET_BITFIELD) - return 245; - } - x1 = XEXP (x0, 0); - goto L739; - L374: - tem = recog_3 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L739; - - L740: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == SImode && GET_CODE (x1) == AND && 1) - goto L741; - x1 = XEXP (x0, 0); - goto L944; - - L741: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L742; - } - x1 = XEXP (x0, 0); - goto L944; - - L742: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 147; - } - x1 = XEXP (x0, 0); - goto L944; - - L945: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != SImode) - { - x1 = XEXP (x0, 0); - goto L1595; - } - switch (GET_CODE (x1)) - { - case ASHIFT: - goto L946; - case ASHIFTRT: - goto L985; - case LSHIFT: - goto L1024; - case LSHIFTRT: - goto L1063; - case ROTATE: - goto L1102; - case ROTATERT: - goto L1129; - } - x1 = XEXP (x0, 0); - goto L1595; - - L946: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L947; - } - x1 = XEXP (x0, 0); - goto L1595; - - L947: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - goto L953; - L959: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 193; - } - x1 = XEXP (x0, 0); - goto L1595; - - L953: - ro[2] = x2; - if ((GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)) - return 191; - L954: - ro[2] = x2; - if ((! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)) - return 192; - goto L959; - - L985: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L986; - } - x1 = XEXP (x0, 0); - goto L1595; - - L986: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - goto L992; - L998: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 200; - } - x1 = XEXP (x0, 0); - goto L1595; - - L992: - ro[2] = x2; - if ((GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)) - return 198; - L993: - ro[2] = x2; - if ((! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)) - return 199; - goto L998; - - L1024: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L1025; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1025: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - goto L1031; - L1037: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 207; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1031: - ro[2] = x2; - if ((GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)) - return 205; - L1032: - ro[2] = x2; - if ((! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)) - return 206; - goto L1037; - - L1063: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L1064; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1064: - x2 = XEXP (x1, 1); - if (immediate_operand (x2, SImode)) - goto L1070; - L1076: - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 214; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1070: - ro[2] = x2; - if ((GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)) - return 212; - L1071: - ro[2] = x2; - if ((! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)) - return 213; - goto L1076; - - L1102: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L1103; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1103: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 219; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1129: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - goto L1130; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1130: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 224; - } - x1 = XEXP (x0, 0); - goto L1595; - - L8: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case SImode: - if (nonimmediate_operand (x1, SImode)) - { - ro[0] = x1; - return 2; - } - break; - case HImode: - if (nonimmediate_operand (x1, HImode)) - { - ro[0] = x1; - return 3; - } - break; - case QImode: - if (nonimmediate_operand (x1, QImode)) - { - ro[0] = x1; - return 4; - } - } - switch (GET_CODE (x1)) - { - case COMPARE: - goto L46; - case ZERO_EXTRACT: - goto L101; - case CONST_INT: - case CONST_DOUBLE: - case CONST: - case SYMBOL_REF: - case LABEL_REF: - case SUBREG: - case REG: - case MEM: - L23: - if (general_operand (x1, SFmode)) - goto L27; - } - L37: - if (general_operand (x1, DFmode)) - goto L41; - L1262: - if (GET_MODE (x1) == SImode && GET_CODE (x1) == ZERO_EXTRACT && 1) - goto L1263; - x1 = XEXP (x0, 0); - goto L1595; - - L46: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[0] = x2; - goto L47; - } - break; - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[0] = x2; - goto L52; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[0] = x2; - goto L57; - } - break; - case DFmode: - if (general_operand (x2, DFmode)) - { - ro[0] = x2; - goto L70; - } - break; - case SFmode: - if (general_operand (x2, SFmode)) - { - ro[0] = x2; - goto L90; - } - } - x1 = XEXP (x0, 0); - goto L1595; - - L47: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 11; - } - x1 = XEXP (x0, 0); - goto L1595; - - L52: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 12; - } - x1 = XEXP (x0, 0); - goto L1595; - - L57: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 13; - } - x1 = XEXP (x0, 0); - goto L1595; - - L70: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - goto L76; - x1 = XEXP (x0, 0); - goto L1595; - - L76: - if (pnum_clobbers != 0 && 1) - { - ro[1] = x2; - if (TARGET_FPA) - { - *pnum_clobbers = 1; - return 15; - } - } - L77: - ro[1] = x2; - if (TARGET_68881) - return 16; - x1 = XEXP (x0, 0); - goto L1595; - - L90: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - goto L96; - x1 = XEXP (x0, 0); - goto L1595; - - L96: - if (pnum_clobbers != 0 && 1) - { - ro[1] = x2; - if (TARGET_FPA) - { - *pnum_clobbers = 1; - return 18; - } - } - L97: - ro[1] = x2; - if (TARGET_68881) - return 19; - x1 = XEXP (x0, 0); - goto L1595; - - L101: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[0] = x2; - goto L102; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[0] = x2; - goto L110; - } - } - goto L1262; - - L102: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 1 && 1) - goto L103; - goto L1262; - - L103: - x2 = XEXP (x1, 2); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MINUS && 1) - goto L104; - if (general_operand (x2, SImode)) - { - ro[1] = x2; - if (GET_CODE (operands[1]) == CONST_INT - && (unsigned) INTVAL (operands[1]) < 8) - return 24; - } - goto L1262; - - L104: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 7 && 1) - goto L121; - goto L1262; - - L121: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == AND && 1) - goto L122; - if (general_operand (x3, SImode)) - { - ro[1] = x3; - return 20; - } - goto L1262; - - L122: - x4 = XEXP (x3, 0); - if (general_operand (x4, SImode)) - { - ro[1] = x4; - goto L123; - } - goto L1262; - - L123: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 7 && 1) - return 22; - goto L1262; - - L110: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 1 && 1) - goto L111; - goto L1262; - - L111: - x2 = XEXP (x1, 2); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MINUS && 1) - goto L112; - if (general_operand (x2, SImode)) - { - ro[1] = x2; - if (GET_CODE (operands[1]) == CONST_INT) - return 25; - } - goto L1262; - - L112: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 31 && 1) - goto L131; - goto L1262; - - L131: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == AND && 1) - goto L132; - if (general_operand (x3, SImode)) - { - ro[1] = x3; - return 21; - } - goto L1262; - - L132: - x4 = XEXP (x3, 0); - if (general_operand (x4, SImode)) - { - ro[1] = x4; - goto L133; - } - goto L1262; - - L133: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 31 && 1) - return 23; - goto L1262; - - L27: - if (pnum_clobbers != 0 && 1) - { - ro[0] = x1; - if (TARGET_FPA) - { - *pnum_clobbers = 1; - return 6; - } - } - L28: - ro[0] = x1; - if (TARGET_68881) - return 7; - goto L37; - - L41: - if (pnum_clobbers != 0 && 1) - { - ro[0] = x1; - if (TARGET_FPA) - { - *pnum_clobbers = 1; - return 9; - } - } - L42: - ro[0] = x1; - if (TARGET_68881) - return 10; - x1 = XEXP (x0, 0); - goto L1595; - - L1263: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case QImode: - if (memory_operand (x2, QImode)) - { - ro[0] = x2; - goto L1264; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[0] = x2; - goto L1270; - } - } - x1 = XEXP (x0, 0); - goto L1595; - - L1264: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1265; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1265: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT) - return 246; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1270: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1271; - } - x1 = XEXP (x0, 0); - goto L1595; - - L1271: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - if (TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT) - return 247; - } - x1 = XEXP (x0, 0); - goto L1595; - L160: - tem = recog_4 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - goto L1595; - - L1324: - x1 = XEXP (x0, 1); - switch (GET_CODE (x1)) - { - case IF_THEN_ELSE: - goto L1325; - case LABEL_REF: - goto L1505; - } - x1 = XEXP (x0, 0); - goto L1595; - L1325: - tem = recog_5 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L1595; - - L1505: - x2 = XEXP (x1, 0); - ro[0] = x2; - return 278; - - L1596: - x1 = XEXP (x0, 1); - if (GET_CODE (x1) == CALL && 1) - goto L1597; - x1 = XEXP (x0, 0); - goto L1612; - - L1597: - x2 = XEXP (x1, 0); - if (memory_operand (x2, QImode)) - { - ro[1] = x2; - goto L1598; - } - x1 = XEXP (x0, 0); - goto L1612; - - L1598: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - goto L1604; - x1 = XEXP (x0, 0); - goto L1612; - - L1604: - ro[2] = x2; - if (! flag_pic) - return 290; - L1605: - ro[2] = x2; - if (flag_pic) - return 291; - x1 = XEXP (x0, 0); - goto L1612; - - L1613: - x1 = XEXP (x0, 1); - if (address_operand (x1, SImode)) - { - ro[0] = x1; - return 297; - } - goto ret0; - - L1703: - x1 = XEXP (x0, 1); - if (nonimmediate_operand (x1, XFmode)) - { - ro[0] = x1; - if (TARGET_68881) - return 318; - } - if (GET_CODE (x1) == COMPARE && 1) - goto L1707; - goto ret0; - - L1707: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[0] = x2; - goto L1708; - } - goto ret0; - - L1708: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 320; - } - goto ret0; - - L1751: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == SImode && GET_CODE (x1) == FIX && 1) - goto L1752; - if (address_operand (x1, QImode)) - { - ro[1] = x1; - return 298; - } - goto ret0; - - L1752: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 331; - } - goto ret0; - - L1619: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != DFmode) - { - x1 = XEXP (x0, 0); - goto L1718; - } - switch (GET_CODE (x1)) - { - case PLUS: - goto L1620; - case MINUS: - goto L1648; - case MULT: - goto L1662; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1620: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == MULT && 1) - goto L1621; - x1 = XEXP (x0, 0); - goto L1718; - - L1621: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - goto L1622; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1622: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1623; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1623: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 306; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1648: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == MULT && 1) - goto L1649; - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L1635; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1649: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - goto L1650; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1650: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1651; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1651: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 310; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1635: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == MULT && 1) - goto L1636; - x1 = XEXP (x0, 0); - goto L1718; - - L1636: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1637; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1637: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[3] = x3; - if (TARGET_FPA) - return 308; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1662: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - switch (GET_CODE (x2)) - { - case PLUS: - goto L1663; - case MINUS: - goto L1677; - } - } - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L1684; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1663: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - goto L1664; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1664: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1665; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1665: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 312; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1677: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - goto L1678; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1678: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1679; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1679: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 314; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1684: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == MINUS && 1) - goto L1685; - x1 = XEXP (x0, 0); - goto L1718; - - L1685: - x3 = XEXP (x2, 0); - if (general_operand (x3, DFmode)) - { - ro[2] = x3; - goto L1686; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1686: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[3] = x3; - if (TARGET_FPA) - return 315; - } - x1 = XEXP (x0, 0); - goto L1718; - - L1719: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == DFmode && GET_CODE (x1) == FLOAT_TRUNCATE && 1) - goto L1720; - goto ret0; - - L1720: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 323; - } - goto ret0; - - L1626: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != SFmode) - { - x1 = XEXP (x0, 0); - goto L1722; - } - switch (GET_CODE (x1)) - { - case PLUS: - goto L1627; - case MINUS: - goto L1655; - case MULT: - goto L1669; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1627: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == MULT && 1) - goto L1628; - x1 = XEXP (x0, 0); - goto L1722; - - L1628: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L1629; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1629: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1630; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1630: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 307; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1655: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == MULT && 1) - goto L1656; - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L1642; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1656: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L1657; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1657: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1658; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1658: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 311; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1642: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == MULT && 1) - goto L1643; - x1 = XEXP (x0, 0); - goto L1722; - - L1643: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1644; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1644: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[3] = x3; - if (TARGET_FPA) - return 309; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1669: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SFmode: - switch (GET_CODE (x2)) - { - case PLUS: - goto L1670; - case MINUS: - goto L1691; - } - } - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L1698; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1670: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L1671; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1671: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1672; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1672: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 313; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1691: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L1692; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1692: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1693; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1693: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[3] = x2; - if (TARGET_FPA) - return 316; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1698: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == MINUS && 1) - goto L1699; - x1 = XEXP (x0, 0); - goto L1722; - - L1699: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - goto L1700; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1700: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[3] = x3; - if (TARGET_FPA) - return 317; - } - x1 = XEXP (x0, 0); - goto L1722; - - L1723: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == SFmode && GET_CODE (x1) == FLOAT_TRUNCATE && 1) - goto L1724; - goto ret0; - - L1724: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 324; - } - goto ret0; - - L1711: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != XFmode) - goto ret0; - switch (GET_CODE (x1)) - { - case FLOAT_EXTEND: - goto L1712; - case FLOAT: - goto L1728; - case FIX: - goto L1740; - case PLUS: - goto L1756; - case MINUS: - goto L1761; - case MULT: - goto L1766; - case DIV: - goto L1771; - case NEG: - goto L1776; - case ABS: - goto L1780; - case SQRT: - goto L1784; - } - goto ret0; - - L1712: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 321; - } - L1716: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 322; - } - goto ret0; - - L1728: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 325; - } - L1732: - if (general_operand (x2, HImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 326; - } - L1736: - if (general_operand (x2, QImode)) - { - ro[1] = x2; - if (TARGET_68881) - return 327; - } - goto ret0; - - L1740: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 328; - } - goto ret0; - - L1756: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - goto L1757; - } - goto ret0; - - L1757: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, XFmode)) - { - ro[2] = x2; - if (TARGET_68881) - return 333; - } - goto ret0; - - L1761: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - goto L1762; - } - goto ret0; - - L1762: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, XFmode)) - { - ro[2] = x2; - if (TARGET_68881) - return 335; - } - goto ret0; - - L1766: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - goto L1767; - } - goto ret0; - - L1767: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, XFmode)) - { - ro[2] = x2; - if (TARGET_68881) - return 337; - } - goto ret0; - - L1771: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - goto L1772; - } - goto ret0; - - L1772: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, XFmode)) - { - ro[2] = x2; - if (TARGET_68881) - return 339; - } - goto ret0; - - L1776: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 340; - } - goto ret0; - - L1780: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 341; - } - goto ret0; - - L1784: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 342; - } - goto ret0; - - L1743: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == QImode && GET_CODE (x1) == FIX && 1) - goto L1744; - goto ret0; - - L1744: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 329; - } - goto ret0; - - L1747: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == HImode && GET_CODE (x1) == FIX && 1) - goto L1748; - goto ret0; - - L1748: - x2 = XEXP (x1, 0); - if (general_operand (x2, XFmode)) - { - ro[1] = x2; - if (TARGET_68881) - return 330; - } - goto ret0; - ret0: return -1; -} - -int -recog_7 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - switch (GET_MODE (x2)) - { - case SImode: - if (GET_CODE (x2) == PLUS && 1) - goto L1517; - if (register_operand (x2, SImode)) - { - ro[0] = x2; - goto L1510; - } - } - if (GET_CODE (x2) == IF_THEN_ELSE && 1) - goto L1526; - goto ret0; - - L1517: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == PC && 1) - goto L1518; - goto ret0; - - L1518: - x3 = XEXP (x2, 1); - if (register_operand (x3, HImode)) - { - ro[0] = x3; - goto L1519; - } - goto ret0; - - L1519: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1520; - goto ret0; - - L1520: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1521; - goto ret0; - - L1521: - x3 = XEXP (x2, 0); - ro[1] = x3; - return 281; - - L1510: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1511; - goto ret0; - - L1511: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1512; - goto ret0; - - L1512: - x3 = XEXP (x2, 0); - ro[1] = x3; - return 280; - - L1526: - x3 = XEXP (x2, 0); - switch (GET_CODE (x3)) - { - case NE: - goto L1527; - case GE: - goto L1557; - } - goto ret0; - - L1527: - x4 = XEXP (x3, 0); - switch (GET_MODE (x4)) - { - case HImode: - if (general_operand (x4, HImode)) - { - ro[0] = x4; - goto L1528; - } - break; - case SImode: - if (general_operand (x4, SImode)) - { - ro[0] = x4; - goto L1543; - } - } - goto ret0; - - L1528: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 0 && 1) - goto L1529; - goto ret0; - - L1529: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == LABEL_REF && 1) - goto L1530; - goto ret0; - - L1530: - x4 = XEXP (x3, 0); - ro[1] = x4; - goto L1531; - - L1531: - x3 = XEXP (x2, 2); - if (GET_CODE (x3) == PC && 1) - goto L1532; - goto ret0; - - L1532: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1533; - goto ret0; - - L1533: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1534; - goto ret0; - - L1534: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == PLUS && 1) - goto L1535; - goto ret0; - - L1535: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[0]) && 1) - goto L1536; - goto ret0; - - L1536: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - return 282; - goto ret0; - - L1543: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 0 && 1) - goto L1544; - goto ret0; - - L1544: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == LABEL_REF && 1) - goto L1545; - goto ret0; - - L1545: - x4 = XEXP (x3, 0); - ro[1] = x4; - goto L1546; - - L1546: - x3 = XEXP (x2, 2); - if (GET_CODE (x3) == PC && 1) - goto L1547; - goto ret0; - - L1547: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1548; - goto ret0; - - L1548: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1549; - goto ret0; - - L1549: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1550; - goto ret0; - - L1550: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[0]) && 1) - goto L1551; - goto ret0; - - L1551: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - return 283; - goto ret0; - - L1557: - x4 = XEXP (x3, 0); - if (GET_CODE (x4) != PLUS) - goto ret0; - switch (GET_MODE (x4)) - { - case HImode: - goto L1558; - case SImode: - goto L1575; - } - goto ret0; - - L1558: - x5 = XEXP (x4, 0); - if (general_operand (x5, HImode)) - { - ro[0] = x5; - goto L1559; - } - goto ret0; - - L1559: - x5 = XEXP (x4, 1); - if (GET_CODE (x5) == CONST_INT && XWINT (x5, 0) == -1 && 1) - goto L1560; - goto ret0; - - L1560: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 0 && 1) - goto L1561; - goto ret0; - - L1561: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == LABEL_REF && 1) - goto L1562; - goto ret0; - - L1562: - x4 = XEXP (x3, 0); - ro[1] = x4; - goto L1563; - - L1563: - x3 = XEXP (x2, 2); - if (GET_CODE (x3) == PC && 1) - goto L1564; - goto ret0; - - L1564: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1565; - goto ret0; - - L1565: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1566; - goto ret0; - - L1566: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == PLUS && 1) - goto L1567; - goto ret0; - - L1567: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[0]) && 1) - goto L1568; - goto ret0; - - L1568: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - if (find_reg_note (insn, REG_NONNEG, 0)) - return 284; - goto ret0; - - L1575: - x5 = XEXP (x4, 0); - if (general_operand (x5, SImode)) - { - ro[0] = x5; - goto L1576; - } - goto ret0; - - L1576: - x5 = XEXP (x4, 1); - if (GET_CODE (x5) == CONST_INT && XWINT (x5, 0) == -1 && 1) - goto L1577; - goto ret0; - - L1577: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 0 && 1) - goto L1578; - goto ret0; - - L1578: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == LABEL_REF && 1) - goto L1579; - goto ret0; - - L1579: - x4 = XEXP (x3, 0); - ro[1] = x4; - goto L1580; - - L1580: - x3 = XEXP (x2, 2); - if (GET_CODE (x3) == PC && 1) - goto L1581; - goto ret0; - - L1581: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1582; - goto ret0; - - L1582: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1583; - goto ret0; - - L1583: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1584; - goto ret0; - - L1584: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[0]) && 1) - goto L1585; - goto ret0; - - L1585: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - if (find_reg_note (insn, REG_NONNEG, 0)) - return 285; - goto ret0; - ret0: return -1; -} - -int -recog_8 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - if (register_operand (x2, SImode)) - { - ro[0] = x2; - goto L537; - } - L718: - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L719; - } - } - switch (GET_CODE (x2)) - { - case CC0: - goto L18; - case PC: - goto L1516; - } - goto ret0; - - L537: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MULT && 1) - goto L538; - x2 = XEXP (x1, 0); - goto L718; - - L538: - x3 = XEXP (x2, 0); - if (register_operand (x3, SImode)) - { - ro[1] = x3; - goto L539; - } - x2 = XEXP (x1, 0); - goto L718; - - L539: - x3 = XEXP (x2, 1); - if (nonimmediate_operand (x3, SImode)) - { - ro[2] = x3; - goto L540; - } - if (GET_CODE (x3) == CONST_INT && 1) - { - ro[2] = x3; - goto L556; - } - x2 = XEXP (x1, 0); - goto L718; - - L540: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L541; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L541: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[3] = x2; - goto L542; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L542: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == TRUNCATE && 1) - goto L543; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L543: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) != DImode) - { - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - } - switch (GET_CODE (x3)) - { - case LSHIFTRT: - goto L544; - case ASHIFT: - goto L575; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L544: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == DImode && GET_CODE (x4) == MULT && 1) - goto L545; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L545: - x5 = XEXP (x4, 0); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == ZERO_EXTEND && 1) - goto L546; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L546: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[1]) && 1) - goto L547; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L547: - x5 = XEXP (x4, 1); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == ZERO_EXTEND && 1) - goto L548; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L548: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[2]) && 1) - goto L549; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L549: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 32 && 1) - if (TARGET_68020) - return 116; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L575: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == DImode && GET_CODE (x4) == MULT && 1) - goto L576; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L576: - x5 = XEXP (x4, 0); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == SIGN_EXTEND && 1) - goto L577; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L577: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[1]) && 1) - goto L578; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L578: - x5 = XEXP (x4, 1); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == SIGN_EXTEND && 1) - goto L579; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L579: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[2]) && 1) - goto L580; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L580: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 32 && 1) - if (TARGET_68020) - return 119; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L556: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L557; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L557: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[3] = x2; - goto L558; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L558: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == TRUNCATE && 1) - goto L559; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L559: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) != DImode) - { - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - } - switch (GET_CODE (x3)) - { - case LSHIFTRT: - goto L560; - case ASHIFT: - goto L591; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L560: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == DImode && GET_CODE (x4) == MULT && 1) - goto L561; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L561: - x5 = XEXP (x4, 0); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == ZERO_EXTEND && 1) - goto L562; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L562: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[1]) && 1) - goto L563; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L563: - x5 = XEXP (x4, 1); - if (rtx_equal_p (x5, ro[2]) && 1) - goto L564; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L564: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 32 && 1) - if (TARGET_68020 - && (unsigned) INTVAL (operands[2]) <= 0x7fffffff) - return 117; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L591: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == DImode && GET_CODE (x4) == MULT && 1) - goto L592; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L592: - x5 = XEXP (x4, 0); - if (GET_MODE (x5) == DImode && GET_CODE (x5) == SIGN_EXTEND && 1) - goto L593; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L593: - x6 = XEXP (x5, 0); - if (rtx_equal_p (x6, ro[1]) && 1) - goto L594; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L594: - x5 = XEXP (x4, 1); - if (rtx_equal_p (x5, ro[2]) && 1) - goto L595; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L595: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == CONST_INT && XWINT (x4, 0) == 32 && 1) - if (TARGET_68020 - /* This test is a noop on 32 bit machines, - but important for a cross-compiler hosted on 64-bit machines. */ - && INTVAL (operands[2]) <= 0x7fffffff - && INTVAL (operands[2]) >= -0x80000000) - return 120; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L718; - - L719: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != SImode) - goto ret0; - switch (GET_CODE (x2)) - { - case DIV: - goto L720; - case UDIV: - goto L731; - } - goto ret0; - - L720: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L721; - } - goto ret0; - - L721: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L722; - } - goto ret0; - - L722: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L723; - goto ret0; - - L723: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && general_operand (x2, SImode)) - { - ro[3] = x2; - goto L724; - } - goto ret0; - - L724: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MOD && 1) - goto L725; - goto ret0; - - L725: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L726; - goto ret0; - - L726: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - if (TARGET_68020) - return 145; - goto ret0; - - L731: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L732; - } - goto ret0; - - L732: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L733; - } - goto ret0; - - L733: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L734; - goto ret0; - - L734: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && general_operand (x2, SImode)) - { - ro[3] = x2; - goto L735; - } - goto ret0; - - L735: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == UMOD && 1) - goto L736; - goto ret0; - - L736: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L737; - goto ret0; - - L737: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - if (TARGET_68020) - return 146; - goto ret0; - - L18: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[0] = x2; - goto L19; - } - L32: - if (general_operand (x2, DFmode)) - { - ro[0] = x2; - goto L33; - } - if (GET_CODE (x2) == COMPARE && 1) - goto L62; - goto ret0; - - L19: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L20; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L32; - - L20: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[1] = x2; - if (TARGET_FPA) - return 6; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L32; - - L33: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L34; - goto ret0; - - L34: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[1] = x2; - if (TARGET_FPA) - return 9; - } - goto ret0; - - L62: - x3 = XEXP (x2, 0); - switch (GET_MODE (x3)) - { - case DFmode: - if (general_operand (x3, DFmode)) - { - ro[0] = x3; - goto L63; - } - break; - case SFmode: - if (general_operand (x3, SFmode)) - { - ro[0] = x3; - goto L83; - } - } - goto ret0; - - L63: - x3 = XEXP (x2, 1); - if (general_operand (x3, DFmode)) - { - ro[1] = x3; - goto L64; - } - goto ret0; - - L64: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L65; - goto ret0; - - L65: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - if (TARGET_FPA) - return 15; - } - goto ret0; - - L83: - x3 = XEXP (x2, 1); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L84; - } - goto ret0; - - L84: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L85; - goto ret0; - - L85: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - if (TARGET_FPA) - return 18; - } - goto ret0; - L1516: - return recog_7 (x0, insn, pnum_clobbers); - ret0: return -1; -} - -int -recog (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - L1609: - switch (GET_CODE (x0)) - { - case REG: - if (GET_MODE (x0) == SImode && XINT (x0, 0) == 15 && 1) - if (NEED_PROBE) - return 295; - break; - case SET: - goto L1; - case PARALLEL: - if (XVECLEN (x0, 0) == 2 && 1) - goto L16; - if (XVECLEN (x0, 0) == 3 && 1) - goto L286; - break; - case CALL: - goto L1587; - case UNSPEC_VOLATILE: - if (XINT (x0, 1) == 0 && XVECLEN (x0, 0) == 1 && 1) - goto L1607; - break; - case CONST_INT: - if (XWINT (x0, 0) == 0 && 1) - return 294; - break; - case RETURN: - if (USE_RETURN_INSN) - return 296; - } - goto ret0; - L1: - return recog_6 (x0, insn, pnum_clobbers); - - L16: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == SET && 1) - goto L536; - goto ret0; - L536: - return recog_8 (x0, insn, pnum_clobbers); - - L286: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == SET && 1) - goto L287; - goto ret0; - - L287: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L288; - } - break; - case HImode: - if (general_operand (x2, HImode)) - { - ro[0] = x2; - goto L303; - } - break; - case QImode: - if (general_operand (x2, QImode)) - { - ro[0] = x2; - goto L318; - } - } - goto ret0; - - L288: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == FIX && 1) - goto L289; - goto ret0; - - L289: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == DFmode && GET_CODE (x3) == FIX && 1) - goto L290; - goto ret0; - - L290: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L291; - } - goto ret0; - - L291: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L292; - goto ret0; - - L292: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - goto L293; - } - goto ret0; - - L293: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L294; - goto ret0; - - L294: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68040) - return 70; - } - goto ret0; - - L303: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == FIX && 1) - goto L304; - goto ret0; - - L304: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == DFmode && GET_CODE (x3) == FIX && 1) - goto L305; - goto ret0; - - L305: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L306; - } - goto ret0; - - L306: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L307; - goto ret0; - - L307: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - goto L308; - } - goto ret0; - - L308: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L309; - goto ret0; - - L309: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68040) - return 71; - } - goto ret0; - - L318: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == QImode && GET_CODE (x2) == FIX && 1) - goto L319; - goto ret0; - - L319: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == DFmode && GET_CODE (x3) == FIX && 1) - goto L320; - goto ret0; - - L320: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L321; - } - goto ret0; - - L321: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L322; - goto ret0; - - L322: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - goto L323; - } - goto ret0; - - L323: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L324; - goto ret0; - - L324: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_68040) - return 72; - } - goto ret0; - - L1587: - x1 = XEXP (x0, 0); - if (memory_operand (x1, QImode)) - { - ro[0] = x1; - goto L1588; - } - goto ret0; - - L1588: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - goto L1592; - goto ret0; - - L1592: - ro[1] = x1; - if (! flag_pic) - return 287; - L1593: - ro[1] = x1; - if (flag_pic) - return 288; - goto ret0; - - L1607: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == CONST_INT && XWINT (x1, 0) == 0 && 1) - return 293; - goto ret0; - ret0: return -1; -} - -rtx -split_insns (x0, insn) - register rtx x0; - rtx insn; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - rtx tem; - - goto ret0; - ret0: return 0; -} - diff --git a/gnu/usr.bin/gcc2/arch/hp300/m68k.h b/gnu/usr.bin/gcc2/arch/hp300/m68k.h deleted file mode 100644 index e7fe5c554096..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/m68k.h +++ /dev/null @@ -1,1789 +0,0 @@ -/* Definitions of target machine for GNU compiler. Sun 68000/68020 version. - Copyright (C) 1987, 1988, 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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. - -GNU CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m68k.h,v 1.1 1993/08/23 09:21:27 cgd Exp $ -*/ - - -/* Note that some other tm.h files include this one and then override - many of the definitions that relate to assembler syntax. */ - - -/* Names to predefine in the preprocessor for this target machine. */ - -/* See sun3.h, sun2.h, isi.h for different CPP_PREDEFINES. */ - -/* Print subsidiary information on the compiler version in use. */ -#ifdef MOTOROLA -#define TARGET_VERSION fprintf (stderr, " (68k, Motorola syntax)"); -#else -#define TARGET_VERSION fprintf (stderr, " (68k, MIT syntax)"); -#endif - -/* Define SUPPORT_SUN_FPA to include support for generating code for - the Sun Floating Point Accelerator, an optional product for Sun 3 - machines. By default, it is not defined. Avoid defining it unless - you need to output code for the Sun3+FPA architecture, as it has the - effect of slowing down the register set operations in hard-reg-set.h - (total number of registers will exceed number of bits in a long, - if defined, causing the set operations to expand to loops). - SUPPORT_SUN_FPA is typically defined in sun3.h. */ - -/* Run-time compilation parameters selecting different hardware subsets. */ - -extern int target_flags; - -/* Macros used in the machine description to test the flags. */ - -/* Compile for a 68020 (not a 68000 or 68010). */ -#define TARGET_68020 (target_flags & 1) - -/* Compile 68881 insns for floating point (not library calls). */ -#define TARGET_68881 (target_flags & 2) - -/* Compile using 68020 bitfield insns. */ -#define TARGET_BITFIELD (target_flags & 4) - -/* Compile using rtd insn calling sequence. - This will not work unless you use prototypes at least - for all functions that can take varying numbers of args. */ -#define TARGET_RTD (target_flags & 8) - -/* Compile passing first two args in regs 0 and 1. - This exists only to test compiler features that will - be needed for RISC chips. It is not usable - and is not intended to be usable on this cpu. */ -#define TARGET_REGPARM (target_flags & 020) - -/* Compile with 16-bit `int'. */ -#define TARGET_SHORT (target_flags & 040) - -/* Compile with special insns for Sun FPA. */ -#ifdef SUPPORT_SUN_FPA -#define TARGET_FPA (target_flags & 0100) -#else -#define TARGET_FPA 0 -#endif - -/* Compile (actually, link) for Sun SKY board. */ -#define TARGET_SKY (target_flags & 0200) - -/* Optimize for 68040, but still allow execution on 68020 - (-m68020-40 or -m68040). - The 68040 will execute all 68030 and 68881/2 instructions, but some - of them must be emulated in software by the OS. When TARGET_68040 is - turned on, these instructions won't be used. This code will still - run on a 68030 and 68881/2. */ -#define TARGET_68040 (target_flags & 01400) - -/* Use the 68040-only fp instructions (-m68040). */ -#define TARGET_68040_ONLY (target_flags & 01000) - -/* Macro to define tables used to set the flags. - This is a list in braces of pairs in braces, - each pair being { "NAME", VALUE } - where VALUE is the bits to set or minus the bits to clear. - An empty string NAME is used to identify the default VALUE. */ - -#define TARGET_SWITCHES \ - { { "68020", -01400}, \ - { "c68020", -01400}, \ - { "68020", 5}, \ - { "c68020", 5}, \ - { "68881", 2}, \ - { "bitfield", 4}, \ - { "68000", -01405}, \ - { "c68000", -01405}, \ - { "soft-float", -01102}, \ - { "nobitfield", -4}, \ - { "rtd", 8}, \ - { "nortd", -8}, \ - { "short", 040}, \ - { "noshort", -040}, \ - { "fpa", 0100}, \ - { "nofpa", -0100}, \ - { "sky", 0200}, \ - { "nosky", -0200}, \ - { "68020-40", 0407}, \ - { "68030", -01400}, \ - { "68030", 5}, \ - { "68040", 01007}, \ - { "", TARGET_DEFAULT}} -/* TARGET_DEFAULT is defined in sun*.h and isi.h, etc. */ - -#ifdef SUPPORT_SUN_FPA -/* Blow away 68881 flag silently on TARGET_FPA (since we can't clear - any bits in TARGET_SWITCHES above) */ -#define OVERRIDE_OPTIONS \ -{ \ - if (TARGET_FPA) target_flags &= ~2; \ - if (! TARGET_68020 && flag_pic == 2) \ - error("-fPIC is not currently supported on the 68000 or 68010\n"); \ -} -#else -#define OVERRIDE_OPTIONS \ -{ \ - if (! TARGET_68020 && flag_pic == 2) \ - error("-fPIC is not currently supported on the 68000 or 68010\n"); \ -} -#endif /* defined SUPPORT_SUN_FPA */ - -/* target machine storage layout */ - -/* Define for XFmode extended real floating point support. - This will automatically cause REAL_ARITHMETIC to be defined. */ -#define LONG_DOUBLE_TYPE_SIZE 96 - -/* Define if you don't want extended real, but do want to use the - software floating point emulator for REAL_ARITHMETIC and - decimal <-> binary conversion. */ -/* #define REAL_ARITHMETIC */ - -/* Define this if most significant bit is lowest numbered - in instructions that operate on numbered bit-fields. - This is true for 68020 insns such as bfins and bfexts. - We make it true always by avoiding using the single-bit insns - except in special cases with constant bit numbers. */ -#define BITS_BIG_ENDIAN 1 - -/* Define this if most significant byte of a word is the lowest numbered. */ -/* That is true on the 68000. */ -#define BYTES_BIG_ENDIAN 1 - -/* Define this if most significant word of a multiword number is the lowest - numbered. */ -/* For 68000 we can decide arbitrarily - since there are no machine instructions for them. - So let's be consistent. */ -#define WORDS_BIG_ENDIAN 1 - -/* number of bits in an addressable storage unit */ -#define BITS_PER_UNIT 8 - -/* Width in bits of a "word", which is the contents of a machine register. - Note that this is not necessarily the width of data type `int'; - if using 16-bit ints on a 68000, this would still be 32. - But on a machine with 16-bit registers, this would be 16. */ -#define BITS_PER_WORD 32 - -/* Width of a word, in units (bytes). */ -#define UNITS_PER_WORD 4 - -/* Width in bits of a pointer. - See also the macro `Pmode' defined below. */ -#define POINTER_SIZE 32 - -/* Allocation boundary (in *bits*) for storing arguments in argument list. */ -#define PARM_BOUNDARY (TARGET_SHORT ? 16 : 32) - -/* Boundary (in *bits*) on which stack pointer should be aligned. */ -#define STACK_BOUNDARY 16 - -/* Allocation boundary (in *bits*) for the code of a function. */ -#define FUNCTION_BOUNDARY 16 - -/* Alignment of field after `int : 0' in a structure. */ -#define EMPTY_FIELD_BOUNDARY 16 - -/* No data type wants to be aligned rounder than this. */ -#define BIGGEST_ALIGNMENT 16 - -/* Set this nonzero if move instructions will actually fail to work - when given unaligned data. */ -#define STRICT_ALIGNMENT 1 - -#define SELECT_RTX_SECTION(MODE, X) \ -{ \ - if (!flag_pic) \ - readonly_data_section(); \ - else if (LEGITIMATE_PIC_OPERAND_P (X)) \ - readonly_data_section(); \ - else \ - data_section(); \ -} - -/* Define number of bits in most basic integer type. - (If undefined, default is BITS_PER_WORD). */ - -#define INT_TYPE_SIZE (TARGET_SHORT ? 16 : 32) - -/* Define these to avoid dependence on meaning of `int'. - Note that WCHAR_TYPE_SIZE is used in cexp.y, - where TARGET_SHORT is not available. */ - -#define WCHAR_TYPE "long int" -#define WCHAR_TYPE_SIZE 32 - -/* Standard register usage. */ - -/* Number of actual hardware registers. - The hardware registers are assigned numbers for the compiler - from 0 to just below FIRST_PSEUDO_REGISTER. - All registers that the compiler knows about must be given numbers, - even those that are not normally considered general registers. - For the 68000, we give the data registers numbers 0-7, - the address registers numbers 010-017, - and the 68881 floating point registers numbers 020-027. */ -#ifndef SUPPORT_SUN_FPA -#define FIRST_PSEUDO_REGISTER 24 -#else -#define FIRST_PSEUDO_REGISTER 56 -#endif - -/* This defines the register which is used to hold the offset table for PIC. */ -#define PIC_OFFSET_TABLE_REGNUM 13 - -/* Used to output a (use pic_offset_table_rtx) so that we - always save/restore a5 in functions that use PIC relocation - at *any* time during the compilation process. */ -#define FINALIZE_PIC finalize_pic() - -#ifndef SUPPORT_SUN_FPA - -/* 1 for registers that have pervasive standard uses - and are not available for the register allocator. - On the 68000, only the stack pointer is such. */ - -#define FIXED_REGISTERS \ - {/* Data registers. */ \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - \ - /* Address registers. */ \ - 0, 0, 0, 0, 0, 0, 0, 1, \ - \ - /* Floating point registers \ - (if available). */ \ - 0, 0, 0, 0, 0, 0, 0, 0 } - -/* 1 for registers not available across function calls. - These must include the FIXED_REGISTERS and also any - registers that can be used without being saved. - The latter must include the registers where values are returned - and the register where structure-value addresses are passed. - Aside from that, you can include as many other registers as you like. */ -#define CALL_USED_REGISTERS \ - {1, 1, 0, 0, 0, 0, 0, 0, \ - 1, 1, 0, 0, 0, 0, 0, 1, \ - 1, 1, 0, 0, 0, 0, 0, 0 } - -#else /* SUPPORT_SUN_FPA */ - -/* 1 for registers that have pervasive standard uses - and are not available for the register allocator. - On the 68000, only the stack pointer is such. */ - -/* fpa0 is also reserved so that it can be used to move shit back and - forth between high fpa regs and everything else. */ - -#define FIXED_REGISTERS \ - {/* Data registers. */ \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - \ - /* Address registers. */ \ - 0, 0, 0, 0, 0, 0, 0, 1, \ - \ - /* Floating point registers \ - (if available). */ \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - \ - /* Sun3 FPA registers. */ \ - 1, 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 } - -/* 1 for registers not available across function calls. - These must include the FIXED_REGISTERS and also any - registers that can be used without being saved. - The latter must include the registers where values are returned - and the register where structure-value addresses are passed. - Aside from that, you can include as many other registers as you like. */ -#define CALL_USED_REGISTERS \ - {1, 1, 0, 0, 0, 0, 0, 0, \ - 1, 1, 0, 0, 0, 0, 0, 1, \ - 1, 1, 0, 0, 0, 0, 0, 0, \ - /* FPA registers. */ \ - 1, 1, 1, 1, 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 } - -#endif /* defined SUPPORT_SUN_FPA */ - - -/* Make sure everything's fine if we *don't* have a given processor. - This assumes that putting a register in fixed_regs will keep the - compiler's mitts completely off it. We don't bother to zero it out - of register classes. If neither TARGET_FPA or TARGET_68881 is set, - the compiler won't touch since no instructions that use these - registers will be valid. - - Reserve PIC_OFFSET_TABLE_REGNUM (a5) for doing PIC relocation if - position independent code is being generated by making it a - fixed register */ - -#ifndef SUPPORT_SUN_FPA - -#define CONDITIONAL_REGISTER_USAGE \ -{ \ - if (flag_pic) \ - fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ -} - -#else /* defined SUPPORT_SUN_FPA */ - -#define CONDITIONAL_REGISTER_USAGE \ -{ \ - int i; \ - HARD_REG_SET x; \ - if (!TARGET_FPA) \ - { \ - COPY_HARD_REG_SET (x, reg_class_contents[(int)FPA_REGS]); \ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ - if (TEST_HARD_REG_BIT (x, i)) \ - fixed_regs[i] = call_used_regs[i] = 1; \ - } \ - if (TARGET_FPA) \ - { \ - COPY_HARD_REG_SET (x, reg_class_contents[(int)FP_REGS]); \ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ - if (TEST_HARD_REG_BIT (x, i)) \ - fixed_regs[i] = call_used_regs[i] = 1; \ - } \ - if (flag_pic) \ - fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ -} - -#endif /* defined SUPPORT_SUN_FPA */ - -/* Return number of consecutive hard regs needed starting at reg REGNO - to hold something of mode MODE. - This is ordinarily the length in words of a value of mode MODE - but can be less for certain modes in special long registers. - - On the 68000, ordinary registers hold 32 bits worth; - for the 68881 registers, a single register is always enough for - anything that can be stored in them at all. */ -#define HARD_REGNO_NREGS(REGNO, MODE) \ - ((REGNO) >= 16 ? GET_MODE_NUNITS (MODE) \ - : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) - -#ifndef SUPPORT_SUN_FPA - -/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. - On the 68000, the cpu registers can hold any mode but the 68881 registers - can hold only SFmode or DFmode. The 68881 registers can't hold anything - if 68881 use is disabled. */ - -#define HARD_REGNO_MODE_OK(REGNO, MODE) \ - (((REGNO) < 16) \ - || ((REGNO) < 24 \ - && TARGET_68881 \ - && (GET_MODE_CLASS (MODE) == MODE_FLOAT \ - || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT))) - -#else /* defined SUPPORT_SUN_FPA */ - -/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. - On the 68000, the cpu registers can hold any mode but the 68881 registers - can hold only SFmode or DFmode. And the 68881 registers can't hold anything - if 68881 use is disabled. However, the Sun FPA register can - (apparently) hold whatever you feel like putting in them. - If using the fpa, don't put a double in d7/a0. */ - -#define HARD_REGNO_MODE_OK(REGNO, MODE) \ -(((REGNO) < 16 \ - && !(TARGET_FPA \ - && GET_MODE_CLASS ((MODE)) != MODE_INT \ - && GET_MODE_UNIT_SIZE ((MODE)) > 4 \ - && (REGNO) < 8 && (REGNO) + GET_MODE_SIZE ((MODE)) / 4 > 8 \ - && (REGNO) % (GET_MODE_UNIT_SIZE ((MODE)) / 4) != 0)) \ - || ((REGNO) < 24 \ - ? TARGET_68881 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \ - || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \ - : ((REGNO) < 56 ? TARGET_FPA : 0))) - -#endif /* defined SUPPORT_SUN_FPA */ - -/* Value is 1 if it is a good idea to tie two pseudo registers - when one has mode MODE1 and one has mode MODE2. - If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2, - for any hard reg, then this must be 0 for correct output. */ -#define MODES_TIEABLE_P(MODE1, MODE2) \ - (! TARGET_68881 \ - || ((GET_MODE_CLASS (MODE1) == MODE_FLOAT \ - || GET_MODE_CLASS (MODE1) == MODE_COMPLEX_FLOAT) \ - == (GET_MODE_CLASS (MODE2) == MODE_FLOAT \ - || GET_MODE_CLASS (MODE2) == MODE_COMPLEX_FLOAT))) - -/* Specify the registers used for certain standard purposes. - The values of these macros are register numbers. */ - -/* m68000 pc isn't overloaded on a register. */ -/* #define PC_REGNUM */ - -/* Register to use for pushing function arguments. */ -#define STACK_POINTER_REGNUM 15 - -/* Base register for access to local variables of the function. */ -#define FRAME_POINTER_REGNUM 14 - -/* Value should be nonzero if functions must have frame pointers. - Zero means the frame pointer need not be set up (and parms - may be accessed via the stack pointer) in functions that seem suitable. - This is computed in `reload', in reload1.c. */ -#define FRAME_POINTER_REQUIRED 0 - -/* Base register for access to arguments of the function. */ -#define ARG_POINTER_REGNUM 14 - -/* Register in which static-chain is passed to a function. */ -#define STATIC_CHAIN_REGNUM 8 - -/* Register in which address to store a structure value - is passed to a function. */ -#define STRUCT_VALUE_REGNUM 9 - -/* Define the classes of registers for register constraints in the - machine description. Also define ranges of constants. - - One of the classes must always be named ALL_REGS and include all hard regs. - If there is more than one class, another class must be named NO_REGS - and contain no registers. - - The name GENERAL_REGS must be the name of a class (or an alias for - another name such as ALL_REGS). This is the class of registers - that is allowed by "g" or "r" in a register constraint. - Also, registers outside this class are allocated only when - instructions express preferences for them. - - The classes must be numbered in nondecreasing order; that is, - a larger-numbered class must never be contained completely - in a smaller-numbered class. - - For any two classes, it is very desirable that there be another - class that represents their union. */ - -/* The 68000 has three kinds of registers, so eight classes would be - a complete set. One of them is not needed. */ - -#ifndef SUPPORT_SUN_FPA - -enum reg_class { - NO_REGS, DATA_REGS, - ADDR_REGS, FP_REGS, - GENERAL_REGS, DATA_OR_FP_REGS, - ADDR_OR_FP_REGS, ALL_REGS, - LIM_REG_CLASSES }; - -#define N_REG_CLASSES (int) LIM_REG_CLASSES - -/* Give names of register classes as strings for dump file. */ - -#define REG_CLASS_NAMES \ - { "NO_REGS", "DATA_REGS", \ - "ADDR_REGS", "FP_REGS", \ - "GENERAL_REGS", "DATA_OR_FP_REGS", \ - "ADDR_OR_FP_REGS", "ALL_REGS" } - -/* Define which registers fit in which classes. - This is an initializer for a vector of HARD_REG_SET - of length N_REG_CLASSES. */ - -#define REG_CLASS_CONTENTS \ -{ \ - 0x00000000, /* NO_REGS */ \ - 0x000000ff, /* DATA_REGS */ \ - 0x0000ff00, /* ADDR_REGS */ \ - 0x00ff0000, /* FP_REGS */ \ - 0x0000ffff, /* GENERAL_REGS */ \ - 0x00ff00ff, /* DATA_OR_FP_REGS */ \ - 0x00ffff00, /* ADDR_OR_FP_REGS */ \ - 0x00ffffff, /* ALL_REGS */ \ -} - -/* The same information, inverted: - Return the class number of the smallest class containing - reg number REGNO. This could be a conditional expression - or could index an array. */ - -#define REGNO_REG_CLASS(REGNO) (((REGNO)>>3)+1) - -#else /* defined SUPPORT_SUN_FPA */ - -/* - * Notes on final choices: - * - * 1) Didn't feel any need to union-ize LOW_FPA_REGS with anything - * else. - * 2) Removed all unions that involve address registers with - * floating point registers (left in unions of address and data with - * floating point). - * 3) Defined GENERAL_REGS as ADDR_OR_DATA_REGS. - * 4) Defined ALL_REGS as FPA_OR_FP_OR_GENERAL_REGS. - * 4) Left in everything else. - */ -enum reg_class { NO_REGS, LO_FPA_REGS, FPA_REGS, FP_REGS, - FP_OR_FPA_REGS, DATA_REGS, DATA_OR_FPA_REGS, DATA_OR_FP_REGS, - DATA_OR_FP_OR_FPA_REGS, ADDR_REGS, GENERAL_REGS, - GENERAL_OR_FPA_REGS, GENERAL_OR_FP_REGS, ALL_REGS, - LIM_REG_CLASSES }; - -#define N_REG_CLASSES (int) LIM_REG_CLASSES - -/* Give names of register classes as strings for dump file. */ - -#define REG_CLASS_NAMES \ - { "NO_REGS", "LO_FPA_REGS", "FPA_REGS", "FP_REGS", \ - "FP_OR_FPA_REGS", "DATA_REGS", "DATA_OR_FPA_REGS", "DATA_OR_FP_REGS", \ - "DATA_OR_FP_OR_FPA_REGS", "ADDR_REGS", "GENERAL_REGS", \ - "GENERAL_OR_FPA_REGS", "GENERAL_OR_FP_REGS", "ALL_REGS" } - -/* Define which registers fit in which classes. - This is an initializer for a vector of HARD_REG_SET - of length N_REG_CLASSES. */ - -#define REG_CLASS_CONTENTS \ -{ \ - {0, 0}, /* NO_REGS */ \ - {0xff000000, 0x000000ff}, /* LO_FPA_REGS */ \ - {0xff000000, 0x00ffffff}, /* FPA_REGS */ \ - {0x00ff0000, 0x00000000}, /* FP_REGS */ \ - {0xffff0000, 0x00ffffff}, /* FP_OR_FPA_REGS */ \ - {0x000000ff, 0x00000000}, /* DATA_REGS */ \ - {0xff0000ff, 0x00ffffff}, /* DATA_OR_FPA_REGS */ \ - {0x00ff00ff, 0x00000000}, /* DATA_OR_FP_REGS */ \ - {0xffff00ff, 0x00ffffff}, /* DATA_OR_FP_OR_FPA_REGS */\ - {0x0000ff00, 0x00000000}, /* ADDR_REGS */ \ - {0x0000ffff, 0x00000000}, /* GENERAL_REGS */ \ - {0xff00ffff, 0x00ffffff}, /* GENERAL_OR_FPA_REGS */\ - {0x00ffffff, 0x00000000}, /* GENERAL_OR_FP_REGS */\ - {0xffffffff, 0x00ffffff}, /* ALL_REGS */ \ -} - -/* The same information, inverted: - Return the class number of the smallest class containing - reg number REGNO. This could be a conditional expression - or could index an array. */ - -extern enum reg_class regno_reg_class[]; -#define REGNO_REG_CLASS(REGNO) (regno_reg_class[(REGNO)>>3]) - -#endif /* SUPPORT_SUN_FPA */ - -/* The class value for index registers, and the one for base regs. */ - -#define INDEX_REG_CLASS GENERAL_REGS -#define BASE_REG_CLASS ADDR_REGS - -/* Get reg_class from a letter such as appears in the machine description. - We do a trick here to modify the effective constraints on the - machine description; we zorch the constraint letters that aren't - appropriate for a specific target. This allows us to guarantee - that a specific kind of register will not be used for a given target - without fiddling with the register classes above. */ - -#ifndef SUPPORT_SUN_FPA - -#define REG_CLASS_FROM_LETTER(C) \ - ((C) == 'a' ? ADDR_REGS : \ - ((C) == 'd' ? DATA_REGS : \ - ((C) == 'f' ? (TARGET_68881 ? FP_REGS : \ - NO_REGS) : \ - NO_REGS))) - -#else /* defined SUPPORT_SUN_FPA */ - -#define REG_CLASS_FROM_LETTER(C) \ - ((C) == 'a' ? ADDR_REGS : \ - ((C) == 'd' ? DATA_REGS : \ - ((C) == 'f' ? (TARGET_68881 ? FP_REGS : \ - NO_REGS) : \ - ((C) == 'x' ? (TARGET_FPA ? FPA_REGS : \ - NO_REGS) : \ - ((C) == 'y' ? (TARGET_FPA ? LO_FPA_REGS : \ - NO_REGS) : \ - NO_REGS))))) - -#endif /* defined SUPPORT_SUN_FPA */ - -/* The letters I, J, K, L and M in a register constraint string - can be used to stand for particular ranges of immediate operands. - This macro defines what the ranges are. - C is the letter, and VALUE is a constant value. - Return 1 if VALUE is in the range specified by C. - - For the 68000, `I' is used for the range 1 to 8 - allowed as immediate shift counts and in addq. - `J' is used for the range of signed numbers that fit in 16 bits. - `K' is for numbers that moveq can't handle. - `L' is for range -8 to -1, range of values that can be added with subq. */ - -#define CONST_OK_FOR_LETTER_P(VALUE, C) \ - ((C) == 'I' ? (VALUE) > 0 && (VALUE) <= 8 : \ - (C) == 'J' ? (VALUE) >= -0x8000 && (VALUE) <= 0x7FFF : \ - (C) == 'K' ? (VALUE) < -0x80 || (VALUE) >= 0x80 : \ - (C) == 'L' ? (VALUE) < 0 && (VALUE) >= -8 : 0) - -/* - * A small bit of explanation: - * "G" defines all of the floating constants that are *NOT* 68881 - * constants. this is so 68881 constants get reloaded and the - * fpmovecr is used. "H" defines *only* the class of constants that - * the fpa can use, because these can be gotten at in any fpa - * instruction and there is no need to force reloads. - */ -#ifndef SUPPORT_SUN_FPA -#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ - ((C) == 'G' ? ! (TARGET_68881 && standard_68881_constant_p (VALUE)) : 0 ) -#else /* defined SUPPORT_SUN_FPA */ -#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ - ((C) == 'G' ? ! (TARGET_68881 && standard_68881_constant_p (VALUE)) : \ - (C) == 'H' ? (TARGET_FPA && standard_sun_fpa_constant_p (VALUE)) : 0) -#endif /* defined SUPPORT_SUN_FPA */ - -/* Given an rtx X being reloaded into a reg required to be - in class CLASS, return the class of reg to actually use. - In general this is just CLASS; but on some machines - in some cases it is preferable to use a more restrictive class. - On the 68000 series, use a data reg if possible when the - value is a constant in the range where moveq could be used - and we ensure that QImodes are reloaded into data regs. - Also, if a floating constant needs reloading, put it in memory - if possible. */ - -#define PREFERRED_RELOAD_CLASS(X,CLASS) \ - ((GET_CODE (X) == CONST_INT \ - && (unsigned) (INTVAL (X) + 0x80) < 0x100 \ - && (CLASS) != ADDR_REGS) \ - ? DATA_REGS \ - : (GET_MODE (X) == QImode && (CLASS) != ADDR_REGS) \ - ? DATA_REGS \ - : (GET_CODE (X) == CONST_DOUBLE \ - && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \ - ? NO_REGS \ - : (CLASS)) - -/* Return the maximum number of consecutive registers - needed to represent mode MODE in a register of class CLASS. */ -/* On the 68000, this is the size of MODE in words, - except in the FP regs, where a single reg is always enough. */ -#ifndef SUPPORT_SUN_FPA - -#define CLASS_MAX_NREGS(CLASS, MODE) \ - ((CLASS) == FP_REGS ? 1 \ - : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) - -/* Moves between fp regs and other regs are two insns. */ -#define REGISTER_MOVE_COST(CLASS1, CLASS2) \ - (((CLASS1) == FP_REGS && (CLASS2) != FP_REGS) \ - || ((CLASS2) == FP_REGS && (CLASS1) != FP_REGS) \ - ? 4 : 2) - -#else /* defined SUPPORT_SUN_FPA */ - -#define CLASS_MAX_NREGS(CLASS, MODE) \ - ((CLASS) == FP_REGS || (CLASS) == FPA_REGS || (CLASS) == LO_FPA_REGS ? 1 \ - : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) - -/* Moves between fp regs and other regs are two insns. */ -/* Likewise for high fpa regs and other regs. */ -#define REGISTER_MOVE_COST(CLASS1, CLASS2) \ - ((((CLASS1) == FP_REGS && (CLASS2) != FP_REGS) \ - || ((CLASS2) == FP_REGS && (CLASS1) != FP_REGS) \ - || ((CLASS1) == FPA_REGS && (CLASS2) != FPA_REGS) \ - || ((CLASS2) == FPA_REGS && (CLASS1) != FPA_REGS)) \ - ? 4 : 2) - -#endif /* define SUPPORT_SUN_FPA */ - -/* Stack layout; function entry, exit and calling. */ - -/* Define this if pushing a word on the stack - makes the stack pointer a smaller address. */ -#define STACK_GROWS_DOWNWARD - -/* Nonzero if we need to generate stack-probe insns. - On most systems they are not needed. - When they are needed, define this as the stack offset to probe at. */ -#define NEED_PROBE 0 - -/* Define this if the nominal address of the stack frame - is at the high-address end of the local variables; - that is, each additional local variable allocated - goes at a more negative offset in the frame. */ -#define FRAME_GROWS_DOWNWARD - -/* Offset within stack frame to start allocating local variables at. - If FRAME_GROWS_DOWNWARD, this is the offset to the END of the - first local allocated. Otherwise, it is the offset to the BEGINNING - of the first local allocated. */ -#define STARTING_FRAME_OFFSET 0 - -/* If we generate an insn to push BYTES bytes, - this says how many the stack pointer really advances by. - On the 68000, sp@- in a byte insn really pushes a word. */ -#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1) - -/* Offset of first parameter from the argument pointer register value. */ -#define FIRST_PARM_OFFSET(FNDECL) 8 - -/* Value is the number of byte of arguments automatically - popped when returning from a subroutine call. - FUNTYPE is the data type of the function (as a tree), - or for a library call it is an identifier node for the subroutine name. - SIZE is the number of bytes of arguments passed on the stack. - - On the 68000, the RTS insn cannot pop anything. - On the 68010, the RTD insn may be used to pop them if the number - of args is fixed, but if the number is variable then the caller - must pop them all. RTD can't be used for library calls now - because the library is compiled with the Unix compiler. - Use of RTD is a selectable option, since it is incompatible with - standard Unix calling sequences. If the option is not selected, - the caller must always pop the args. */ - -#define RETURN_POPS_ARGS(FUNTYPE,SIZE) \ - ((TARGET_RTD && TREE_CODE (FUNTYPE) != IDENTIFIER_NODE \ - && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ - || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ - == void_type_node))) \ - ? (SIZE) : 0) - -/* Define how to find the value returned by a function. - VALTYPE is the data type of the value (as a tree). - If the precise function being called is known, FUNC is its FUNCTION_DECL; - otherwise, FUNC is 0. */ - -/* On the 68000 the return value is in D0 regardless. */ - -#define FUNCTION_VALUE(VALTYPE, FUNC) \ - gen_rtx (REG, TYPE_MODE (VALTYPE), 0) - -/* Define how to find the value returned by a library function - assuming the value has mode MODE. */ - -/* On the 68000 the return value is in D0 regardless. */ - -#define LIBCALL_VALUE(MODE) gen_rtx (REG, MODE, 0) - -/* 1 if N is a possible register number for a function value. - On the 68000, d0 is the only register thus used. */ - -#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0) - -/* Define this to be true when FUNCTION_VALUE_REGNO_P is true for - more than one register. */ - -#define NEEDS_UNTYPED_CALL 0 - -/* Define this if PCC uses the nonreentrant convention for returning - structure and union values. */ - -#define PCC_STATIC_STRUCT_RETURN - -/* 1 if N is a possible register number for function argument passing. - On the 68000, no registers are used in this way. */ - -#define FUNCTION_ARG_REGNO_P(N) 0 - -/* Define a data type for recording info about an argument list - during the scan of that argument list. This data type should - hold all necessary information about the function itself - and about the args processed so far, enough to enable macros - such as FUNCTION_ARG to determine where the next arg should go. - - On the m68k, this is a single integer, which is a number of bytes - of arguments scanned so far. */ - -#define CUMULATIVE_ARGS int - -/* Initialize a variable CUM of type CUMULATIVE_ARGS - for a call to a function whose data type is FNTYPE. - For a library call, FNTYPE is 0. - - On the m68k, the offset starts at 0. */ - -#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) \ - ((CUM) = 0) - -/* Update the data in CUM to advance over an argument - of mode MODE and data type TYPE. - (TYPE is null for libcalls where that information may not be available.) */ - -#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ - ((CUM) += ((MODE) != BLKmode \ - ? (GET_MODE_SIZE (MODE) + 3) & ~3 \ - : (int_size_in_bytes (TYPE) + 3) & ~3)) - -/* Define where to put the arguments to a function. - Value is zero to push the argument on the stack, - or a hard register in which to store the argument. - - MODE is the argument's machine mode. - TYPE is the data type of the argument (as a tree). - This is null for libcalls where that information may - not be available. - CUM is a variable of type CUMULATIVE_ARGS which gives info about - the preceding args and about the function being called. - NAMED is nonzero if this argument is a named parameter - (otherwise it is an extra parameter matching an ellipsis). */ - -/* On the 68000 all args are pushed, except if -mregparm is specified - then the first two words of arguments are passed in d0, d1. - *NOTE* -mregparm does not work. - It exists only to test register calling conventions. */ - -#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ -((TARGET_REGPARM && (CUM) < 8) ? gen_rtx (REG, (MODE), (CUM) / 4) : 0) - -/* For an arg passed partly in registers and partly in memory, - this is the number of registers used. - For args passed entirely in registers or entirely in memory, zero. */ - -#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \ -((TARGET_REGPARM && (CUM) < 8 \ - && 8 < ((CUM) + ((MODE) == BLKmode \ - ? int_size_in_bytes (TYPE) \ - : GET_MODE_SIZE (MODE)))) \ - ? 2 - (CUM) / 4 : 0) - -/* Generate the assembly code for function entry. */ -#define FUNCTION_PROLOGUE(FILE, SIZE) output_function_prologue(FILE, SIZE) - -/* Output assembler code to FILE to increment profiler label # LABELNO - for profiling a function entry. */ - -#define FUNCTION_PROFILER(FILE, LABELNO) \ - asm_fprintf (FILE, "\tlea %LLP%d,%Ra0\n\tjsr mcount\n", (LABELNO)) - -/* Output assembler code to FILE to initialize this source file's - basic block profiling info, if that has not already been done. */ - -#define FUNCTION_BLOCK_PROFILER(FILE, LABELNO) \ - asm_fprintf (FILE, "\ttstl %LLPBX0\n\tbne %LLPI%d\n\tpea %LLPBX0\n\tjsr %U__bb_init_func\n\taddql %I4,%Rsp\n%LLPI%d:\n", \ - LABELNO, LABELNO); - -/* Output assembler code to FILE to increment the entry-count for - the BLOCKNO'th basic block in this source file. */ - -#define BLOCK_PROFILER(FILE, BLOCKNO) \ - asm_fprintf (FILE, "\taddql %I1,%LLPBX2+%d\n", 4 * BLOCKNO) - -/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, - the stack pointer does not matter. The value is tested only in - functions that have frame pointers. - No definition is equivalent to always zero. */ - -#define EXIT_IGNORE_STACK 1 - -/* Generate the assembly code for function exit. */ -#define FUNCTION_EPILOGUE(FILE, SIZE) output_function_epilogue (FILE, SIZE) - -/* This is a hook for other tm files to change. */ -/* #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) */ - -/* Determine if the epilogue should be output as RTL. - You should override this if you define FUNCTION_EXTRA_EPILOGUE. */ -#define USE_RETURN_INSN use_return_insn () - -/* Store in the variable DEPTH the initial difference between the - frame pointer reg contents and the stack pointer reg contents, - as of the start of the function body. This depends on the layout - of the fixed parts of the stack frame and on how registers are saved. - - On the 68k, if we have a frame, we must add one word to its length - to allow for the place that a6 is stored when we do have a frame pointer. - Otherwise, we would need to compute the offset from the frame pointer - of a local variable as a function of frame_pointer_needed, which - is hard. */ - -#define INITIAL_FRAME_POINTER_OFFSET(DEPTH) \ -{ int regno; \ - int offset = -4; \ - for (regno = 16; regno < FIRST_PSEUDO_REGISTER; regno++) \ - if (regs_ever_live[regno] && ! call_used_regs[regno]) \ - offset += 12; \ - for (regno = 0; regno < 16; regno++) \ - if (regs_ever_live[regno] && ! call_used_regs[regno]) \ - offset += 4; \ - (DEPTH) = (offset + ((get_frame_size () + 3) & -4) \ - + (get_frame_size () == 0 ? 0 : 4)); \ -} - -/* Output assembler code for a block containing the constant parts - of a trampoline, leaving space for the variable parts. */ - -/* On the 68k, the trampoline looks like this: - mov @#.,a0 - jsr @#___trampoline - jsr @#___trampoline - .long STATIC - .long FUNCTION -The reason for having three jsr insns is so that an entire line -of the instruction cache is filled in a predictable way -that will always be the same. - -We always use the assembler label ___trampoline -regardless of whether the system adds underscores. */ - -#define TRAMPOLINE_TEMPLATE(FILE) \ -{ \ - ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x207c)); \ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ - ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x4eb9)); \ - ASM_OUTPUT_INT (FILE, gen_rtx (SYMBOL_REF, SImode, "*___trampoline"));\ - ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x4eb9)); \ - ASM_OUTPUT_INT (FILE, gen_rtx (SYMBOL_REF, SImode, "*___trampoline"));\ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ - ASM_OUTPUT_SHORT (FILE, const0_rtx); \ -} - -/* Length in units of the trampoline for entering a nested function. */ - -#define TRAMPOLINE_SIZE 26 - -/* Alignment required for a trampoline. 16 is used to find the - beginning of a line in the instruction cache. */ - -#define TRAMPOLINE_ALIGN 16 - -/* Emit RTL insns to initialize the variable parts of a trampoline. - FNADDR is an RTX for the address of the function's pure code. - CXT is an RTX for the static chain value for the function. */ - -#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \ -{ \ - emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 2)), TRAMP); \ - emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 18)), CXT); \ - emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 22)), FNADDR); \ -} - -/* This is the library routine that is used - to transfer control from the trampoline - to the actual nested function. */ - -/* A colon is used with no explicit operands - to cause the template string to be scanned for %-constructs. */ -/* The function name __transfer_from_trampoline is not actually used. - The function definition just permits use of "asm with operands" - (though the operand list is empty). */ -#define TRANSFER_FROM_TRAMPOLINE \ -void \ -__transfer_from_trampoline () \ -{ \ - register char *a0 asm ("%a0"); \ - asm (GLOBAL_ASM_OP " ___trampoline"); \ - asm ("___trampoline:"); \ - asm volatile ("move%.l %0,%@" : : "m" (a0[22])); \ - asm volatile ("move%.l %1,%0" : "=a" (a0) : "m" (a0[18])); \ - asm ("rts":); \ -} - -/* Addressing modes, and classification of registers for them. */ - -#define HAVE_POST_INCREMENT -/* #define HAVE_POST_DECREMENT */ - -#define HAVE_PRE_DECREMENT -/* #define HAVE_PRE_INCREMENT */ - -/* Macros to check register numbers against specific register classes. */ - -/* These assume that REGNO is a hard or pseudo reg number. - They give nonzero only if REGNO is a hard reg of the suitable class - or a pseudo reg currently allocated to a suitable hard reg. - Since they use reg_renumber, they are safe only once reg_renumber - has been allocated, which happens in local-alloc.c. */ - -#define REGNO_OK_FOR_INDEX_P(REGNO) \ -((REGNO) < 16 || (unsigned) reg_renumber[REGNO] < 16) -#define REGNO_OK_FOR_BASE_P(REGNO) \ -(((REGNO) ^ 010) < 8 || (unsigned) (reg_renumber[REGNO] ^ 010) < 8) -#define REGNO_OK_FOR_DATA_P(REGNO) \ -((REGNO) < 8 || (unsigned) reg_renumber[REGNO] < 8) -#define REGNO_OK_FOR_FP_P(REGNO) \ -(((REGNO) ^ 020) < 8 || (unsigned) (reg_renumber[REGNO] ^ 020) < 8) -#ifdef SUPPORT_SUN_FPA -#define REGNO_OK_FOR_FPA_P(REGNO) \ -(((REGNO) >= 24 && (REGNO) < 56) || (reg_renumber[REGNO] >= 24 && reg_renumber[REGNO] < 56)) -#endif - -/* Now macros that check whether X is a register and also, - strictly, whether it is in a specified class. - - These macros are specific to the 68000, and may be used only - in code for printing assembler insns and in conditions for - define_optimization. */ - -/* 1 if X is a data register. */ - -#define DATA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_DATA_P (REGNO (X))) - -/* 1 if X is an fp register. */ - -#define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X))) - -/* 1 if X is an address register */ - -#define ADDRESS_REG_P(X) (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X))) - -#ifdef SUPPORT_SUN_FPA -/* 1 if X is a register in the Sun FPA. */ -#define FPA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FPA_P (REGNO (X))) -#else -/* Answer must be no if we don't have an FPA. */ -#define FPA_REG_P(X) 0 -#endif - -/* Maximum number of registers that can appear in a valid memory address. */ - -#define MAX_REGS_PER_ADDRESS 2 - -/* Recognize any constant value that is a valid address. */ - -#define CONSTANT_ADDRESS_P(X) \ - (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ - || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \ - || GET_CODE (X) == HIGH) - -/* Nonzero if the constant value X is a legitimate general operand. - It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ - -#define LEGITIMATE_CONSTANT_P(X) 1 - -/* Nonzero if the constant value X is a legitimate general operand - when generating PIC code. It is given that flag_pic is on and - that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ - -#define LEGITIMATE_PIC_OPERAND_P(X) \ - (! symbolic_operand (X, VOIDmode)) - -/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx - and check its validity for a certain class. - We have two alternate definitions for each of them. - The usual definition accepts all pseudo regs; the other rejects - them unless they have been allocated suitable hard regs. - The symbol REG_OK_STRICT causes the latter definition to be used. - - Most source files want to accept pseudo regs in the hope that - they will get allocated to the class that the insn wants them to be in. - Source files for reload pass need to be strict. - After reload, it makes no difference, since pseudo regs have - been eliminated by then. */ - -#ifndef REG_OK_STRICT - -/* Nonzero if X is a hard reg that can be used as an index - or if it is a pseudo reg. */ -#define REG_OK_FOR_INDEX_P(X) ((REGNO (X) ^ 020) >= 8) -/* Nonzero if X is a hard reg that can be used as a base reg - or if it is a pseudo reg. */ -#define REG_OK_FOR_BASE_P(X) ((REGNO (X) & ~027) != 0) - -#else - -/* Nonzero if X is a hard reg that can be used as an index. */ -#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X)) -/* Nonzero if X is a hard reg that can be used as a base reg. */ -#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) - -#endif - -/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression - that is a valid memory address for an instruction. - The MODE argument is the machine mode for the MEM expression - that wants to use this address. - - When generating PIC, an address involving a SYMBOL_REF is legitimate - if and only if it is the sum of pic_offset_table_rtx and the SYMBOL_REF. - We use LEGITIMATE_PIC_OPERAND_P to throw out the illegitimate addresses, - and we explicitly check for the sum of pic_offset_table_rtx and a SYMBOL_REF. - - Likewise for a LABEL_REF when generating PIC. - - The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */ - -#define INDIRECTABLE_1_ADDRESS_P(X) \ - ((CONSTANT_ADDRESS_P (X) && (!flag_pic || LEGITIMATE_PIC_OPERAND_P (X))) \ - || (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \ - || ((GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_INC) \ - && REG_P (XEXP (X, 0)) \ - && REG_OK_FOR_BASE_P (XEXP (X, 0))) \ - || (GET_CODE (X) == PLUS \ - && REG_P (XEXP (X, 0)) && REG_OK_FOR_BASE_P (XEXP (X, 0)) \ - && GET_CODE (XEXP (X, 1)) == CONST_INT \ - && ((unsigned) INTVAL (XEXP (X, 1)) + 0x8000) < 0x10000) \ - || (GET_CODE (X) == PLUS && XEXP (X, 0) == pic_offset_table_rtx \ - && flag_pic && GET_CODE (XEXP (X, 1)) == SYMBOL_REF) \ - || (GET_CODE (X) == PLUS && XEXP (X, 0) == pic_offset_table_rtx \ - && flag_pic && GET_CODE (XEXP (X, 1)) == LABEL_REF)) \ - -#if 0 -/* This should replace the last two (non-pic) lines - except that Sun's assembler does not seem to handle such operands. */ - && (TARGET_68020 ? CONSTANT_ADDRESS_P (XEXP (X, 1)) \ - : (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && ((unsigned) INTVAL (XEXP (X, 1)) + 0x8000) < 0x10000)))) -#endif - - -#define GO_IF_NONINDEXED_ADDRESS(X, ADDR) \ -{ if (INDIRECTABLE_1_ADDRESS_P (X)) goto ADDR; } - -/* Only labels on dispatch tables are valid for indexing from. */ -#define GO_IF_INDEXABLE_BASE(X, ADDR) \ -{ rtx temp; \ - if (GET_CODE (X) == LABEL_REF \ - && (temp = next_nonnote_insn (XEXP (X, 0))) != 0 \ - && GET_CODE (temp) == JUMP_INSN \ - && (GET_CODE (PATTERN (temp)) == ADDR_VEC \ - || GET_CODE (PATTERN (temp)) == ADDR_DIFF_VEC)) \ - goto ADDR; \ - if (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) goto ADDR; } - -#define GO_IF_INDEXING(X, ADDR) \ -{ if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 0))) \ - { GO_IF_INDEXABLE_BASE (XEXP (X, 1), ADDR); } \ - if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 1))) \ - { GO_IF_INDEXABLE_BASE (XEXP (X, 0), ADDR); } } - -#define GO_IF_INDEXED_ADDRESS(X, ADDR) \ -{ GO_IF_INDEXING (X, ADDR); \ - if (GET_CODE (X) == PLUS) \ - { if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && (unsigned) INTVAL (XEXP (X, 1)) + 0x80 < 0x100) \ - { rtx go_temp = XEXP (X, 0); GO_IF_INDEXING (go_temp, ADDR); } \ - if (GET_CODE (XEXP (X, 0)) == CONST_INT \ - && (unsigned) INTVAL (XEXP (X, 0)) + 0x80 < 0x100) \ - { rtx go_temp = XEXP (X, 1); GO_IF_INDEXING (go_temp, ADDR); } } } - -#define LEGITIMATE_INDEX_REG_P(X) \ - ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \ - || (GET_CODE (X) == SIGN_EXTEND \ - && GET_CODE (XEXP (X, 0)) == REG \ - && GET_MODE (XEXP (X, 0)) == HImode \ - && REG_OK_FOR_INDEX_P (XEXP (X, 0)))) - -#define LEGITIMATE_INDEX_P(X) \ - (LEGITIMATE_INDEX_REG_P (X) \ - || (TARGET_68020 && GET_CODE (X) == MULT \ - && LEGITIMATE_INDEX_REG_P (XEXP (X, 0)) \ - && GET_CODE (XEXP (X, 1)) == CONST_INT \ - && (INTVAL (XEXP (X, 1)) == 2 \ - || INTVAL (XEXP (X, 1)) == 4 \ - || INTVAL (XEXP (X, 1)) == 8))) - -#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ -{ GO_IF_NONINDEXED_ADDRESS (X, ADDR); \ - GO_IF_INDEXED_ADDRESS (X, ADDR); } - -/* Try machine-dependent ways of modifying an illegitimate address - to be legitimate. If we find one, return the new, valid address. - This macro is used in only one place: `memory_address' in explow.c. - - OLDX is the address as it was before break_out_memory_refs was called. - In some cases it is useful to look at this to decide what needs to be done. - - MODE and WIN are passed so that this macro can use - GO_IF_LEGITIMATE_ADDRESS. - - It is always safe for this macro to do nothing. It exists to recognize - opportunities to optimize the output. - - For the 68000, we handle X+REG by loading X into a register R and - using R+REG. R will go in an address reg and indexing will be used. - However, if REG is a broken-out memory address or multiplication, - nothing needs to be done because REG can certainly go in an address reg. */ - -#define COPY_ONCE(Y) if (!copied) { Y = copy_rtx (Y); copied = ch = 1; } -#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \ -{ register int ch = (X) != (OLDX); \ - if (GET_CODE (X) == PLUS) \ - { int copied = 0; \ - if (GET_CODE (XEXP (X, 0)) == MULT) \ - { COPY_ONCE (X); XEXP (X, 0) = force_operand (XEXP (X, 0), 0);} \ - if (GET_CODE (XEXP (X, 1)) == MULT) \ - { COPY_ONCE (X); XEXP (X, 1) = force_operand (XEXP (X, 1), 0);} \ - if (ch && GET_CODE (XEXP (X, 1)) == REG \ - && GET_CODE (XEXP (X, 0)) == REG) \ - goto WIN; \ - if (ch) { GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN); } \ - if (GET_CODE (XEXP (X, 0)) == REG \ - || (GET_CODE (XEXP (X, 0)) == SIGN_EXTEND \ - && GET_CODE (XEXP (XEXP (X, 0), 0)) == REG \ - && GET_MODE (XEXP (XEXP (X, 0), 0)) == HImode)) \ - { register rtx temp = gen_reg_rtx (Pmode); \ - register rtx val = force_operand (XEXP (X, 1), 0); \ - emit_move_insn (temp, val); \ - COPY_ONCE (X); \ - XEXP (X, 1) = temp; \ - goto WIN; } \ - else if (GET_CODE (XEXP (X, 1)) == REG \ - || (GET_CODE (XEXP (X, 1)) == SIGN_EXTEND \ - && GET_CODE (XEXP (XEXP (X, 1), 0)) == REG \ - && GET_MODE (XEXP (XEXP (X, 1), 0)) == HImode)) \ - { register rtx temp = gen_reg_rtx (Pmode); \ - register rtx val = force_operand (XEXP (X, 0), 0); \ - emit_move_insn (temp, val); \ - COPY_ONCE (X); \ - XEXP (X, 0) = temp; \ - goto WIN; }}} - -/* Go to LABEL if ADDR (a legitimate address expression) - has an effect that depends on the machine mode it is used for. - On the 68000, only predecrement and postincrement address depend thus - (the amount of decrement or increment being the length of the operand). */ - -#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \ - if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == PRE_DEC) goto LABEL - -/* Specify the machine mode that this machine uses - for the index in the tablejump instruction. */ -#define CASE_VECTOR_MODE HImode - -/* Define this if the tablejump instruction expects the table - to contain offsets from the address of the table. - Do not define this if the table should contain absolute addresses. */ -#define CASE_VECTOR_PC_RELATIVE - -/* Specify the tree operation to be used to convert reals to integers. */ -#define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR - -/* This is the kind of divide that is easiest to do in the general case. */ -#define EASY_DIV_EXPR TRUNC_DIV_EXPR - -/* Define this as 1 if `char' should by default be signed; else as 0. */ -#define DEFAULT_SIGNED_CHAR 1 - -/* Don't cse the address of the function being compiled. */ -#define NO_RECURSIVE_FUNCTION_CSE - -/* Max number of bytes we can move from memory to memory - in one reasonably fast instruction. */ -#define MOVE_MAX 4 - -/* Define this if zero-extension is slow (more than one real instruction). */ -#define SLOW_ZERO_EXTEND - -/* Nonzero if access to memory by bytes is slow and undesirable. */ -#define SLOW_BYTE_ACCESS 0 - -/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits - is done just by pretending it is already truncated. */ -#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 - -/* We assume that the store-condition-codes instructions store 0 for false - and some other value for true. This is the value stored for true. */ - -#define STORE_FLAG_VALUE -1 - -/* When a prototype says `char' or `short', really pass an `int'. */ -#define PROMOTE_PROTOTYPES - -/* Specify the machine mode that pointers have. - After generation of rtl, the compiler makes no further distinction - between pointers and any other objects of this machine mode. */ -#define Pmode SImode - -/* A function address in a call instruction - is a byte address (for indexing purposes) - so give the MEM rtx a byte's mode. */ -#define FUNCTION_MODE QImode - -/* Compute the cost of computing a constant rtl expression RTX - whose rtx-code is CODE. The body of this macro is a portion - of a switch statement. If the code is computed here, - return it with a return statement. Otherwise, break from the switch. */ - -#define CONST_COSTS(RTX,CODE,OUTER_CODE) \ - case CONST_INT: \ - /* Constant zero is super cheap due to clr instruction. */ \ - if (RTX == const0_rtx) return 0; \ - /* Constants between -128 and 127 are cheap due to moveq */ \ - if (INTVAL (RTX) >= -128 && INTVAL (RTX) <= 127) return 1; \ - /* Constants between -136 and 254 are easily generated */ \ - /* by intelligent uses of moveq, add[q], and subq */ \ - if ((OUTER_CODE) == SET && INTVAL (RTX) >= -136 \ - && INTVAL (RTX) <= 254) return 2; \ - case CONST: \ - case LABEL_REF: \ - case SYMBOL_REF: \ - return 3; \ - case CONST_DOUBLE: \ - return 5; - -/* Compute the cost of various arithmetic operations. - These are vaguely right for a 68020. */ -/* The costs for long multiply have been adjusted to - work properly in synth_mult on the 68020, - relative to an average of the time for add and the time for shift, - taking away a little more because sometimes move insns are needed. */ -#define MULL_COST (TARGET_68040 ? 5 : 13) -#define MULW_COST (TARGET_68040 ? 3 : 8) - -#define RTX_COSTS(X,CODE,OUTER_CODE) \ - case PLUS: \ - /* An lea costs about three times as much as a simple add. */ \ - if (GET_MODE (X) == SImode \ - && GET_CODE (XEXP (X, 0)) == REG \ - && GET_CODE (XEXP (X, 1)) == MULT \ - && GET_CODE (XEXP (XEXP (X, 1), 0)) == REG \ - && GET_CODE (XEXP (XEXP (X, 1), 1)) == CONST_INT \ - && (INTVAL (XEXP (XEXP (X, 1), 1)) == 2 \ - || INTVAL (XEXP (XEXP (X, 1), 1)) == 4 \ - || INTVAL (XEXP (XEXP (X, 1), 1)) == 8)) \ - return COSTS_N_INSNS (3); /* lea an@(dx:l:i),am */ \ - break; \ - case ASHIFT: \ - case ASHIFTRT: \ - case LSHIFT: \ - case LSHIFTRT: \ - /* A shift by a big integer takes an extra instruction. */ \ - if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && (INTVAL (XEXP (X, 1)) == 16)) \ - return COSTS_N_INSNS (2); /* clrw;swap */ \ - if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && !(INTVAL (XEXP (X, 1)) > 0 \ - && INTVAL (XEXP (X, 1)) <= 8)) \ - return COSTS_N_INSNS (3); /* lsr #i,dn */ \ - break; \ - case MULT: \ - if (GET_CODE (XEXP (x, 1)) == CONST_INT \ - && exact_log2 (INTVAL (XEXP (x, 1))) >= 0) \ - { \ - /* A shift by a big integer takes an extra instruction. */ \ - if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && (INTVAL (XEXP (X, 1)) == (1 << 16))) \ - return COSTS_N_INSNS (2); /* clrw;swap */ \ - if (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && !(INTVAL (XEXP (X, 1)) > 1 \ - && INTVAL (XEXP (X, 1)) <= 256)) \ - return COSTS_N_INSNS (3); /* lsr #i,dn */ \ - break; \ - } \ - else if (GET_MODE (X) == QImode || GET_MODE (X) == HImode) \ - return COSTS_N_INSNS (MULW_COST); \ - else \ - return COSTS_N_INSNS (MULL_COST); \ - break; \ - case DIV: \ - case UDIV: \ - case MOD: \ - case UMOD: \ - if (GET_MODE (X) == QImode || GET_MODE (X) == HImode) \ - return COSTS_N_INSNS (27); /* div.w */ \ - return COSTS_N_INSNS (43); /* div.l */ - -/* Tell final.c how to eliminate redundant test instructions. */ - -/* Here we define machine-dependent flags and fields in cc_status - (see `conditions.h'). */ - -/* Set if the cc value is actually in the 68881, so a floating point - conditional branch must be output. */ -#define CC_IN_68881 04000 - -/* Store in cc_status the expressions that the condition codes will - describe after execution of an instruction whose pattern is EXP. - Do not alter them if the instruction would not alter the cc's. */ - -/* On the 68000, all the insns to store in an address register fail to - set the cc's. However, in some cases these instructions can make it - possibly invalid to use the saved cc's. In those cases we clear out - some or all of the saved cc's so they won't be used. */ - -#define NOTICE_UPDATE_CC(EXP,INSN) notice_update_cc (EXP, INSN) - -#define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \ -{ if (cc_prev_status.flags & CC_IN_68881) \ - return FLOAT; \ - if (cc_prev_status.flags & CC_NO_OVERFLOW) \ - return NO_OV; \ - return NORMAL; } - -/* Control the assembler format that we output. */ - -/* Output at beginning of assembler file. */ - -#define ASM_FILE_START(FILE) \ - fprintf (FILE, "#NO_APP\n"); - -/* Output to assembler file text saying following lines - may contain character constants, extra white space, comments, etc. */ - -#define ASM_APP_ON "#APP\n" - -/* Output to assembler file text saying following lines - no longer contain unusual constructs. */ - -#define ASM_APP_OFF "#NO_APP\n" - -/* Output before read-only data. */ - -#define TEXT_SECTION_ASM_OP ".text" - -/* Output before writable data. */ - -#define DATA_SECTION_ASM_OP ".data" - -/* Here are four prefixes that are used by asm_fprintf to - facilitate customization for alternate assembler syntaxes. - Machines with no likelihood of an alternate syntax need not - define these and need not use asm_fprintf. */ - -/* The prefix for register names. Note that REGISTER_NAMES - is supposed to include this prefix. */ - -#define REGISTER_PREFIX "" - -/* The prefix for local labels. You should be able to define this as - an empty string, or any arbitrary string (such as ".", ".L%", etc) - without having to make any other changes to account for the specific - definition. Note it is a string literal, not interpreted by printf - and friends. */ - -#define LOCAL_LABEL_PREFIX "" - -/* The prefix to add to user-visible assembler symbols. */ - -#define USER_LABEL_PREFIX "_" - -/* The prefix for immediate operands. */ - -#define IMMEDIATE_PREFIX "#" - -/* How to refer to registers in assembler output. - This sequence is indexed by compiler's hard-register-number (see above). */ - -#ifndef SUPPORT_SUN_FPA - -#define REGISTER_NAMES \ -{"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7" } - -#else /* SUPPORTED_SUN_FPA */ - -#define REGISTER_NAMES \ -{"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fpa0", "fpa1", "fpa2", "fpa3", "fpa4", "fpa5", "fpa6", "fpa7", \ - "fpa8", "fpa9", "fpa10", "fpa11", "fpa12", "fpa13", "fpa14", "fpa15", \ - "fpa16", "fpa17", "fpa18", "fpa19", "fpa20", "fpa21", "fpa22", "fpa23", \ - "fpa24", "fpa25", "fpa26", "fpa27", "fpa28", "fpa29", "fpa30", "fpa31" } - -#endif /* defined SUPPORT_SUN_FPA */ - -/* How to renumber registers for dbx and gdb. - On the Sun-3, the floating point registers have numbers - 18 to 25, not 16 to 23 as they do in the compiler. */ - -#define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2) - -/* This is how to output the definition of a user-level label named NAME, - such as the label on a static function or variable NAME. */ - -#define ASM_OUTPUT_LABEL(FILE,NAME) \ - do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0) - -/* This is how to output a command to make the user-level label named NAME - defined for reference from other files. */ - -#define GLOBAL_ASM_OP ".globl" -#define ASM_GLOBALIZE_LABEL(FILE,NAME) \ - do { fprintf (FILE, "%s ", GLOBAL_ASM_OP); \ - assemble_name (FILE, NAME); \ - fputs ("\n", FILE);} while (0) - -/* This is how to output a reference to a user-level label named NAME. - `assemble_name' uses this. */ - -#define ASM_OUTPUT_LABELREF(FILE,NAME) \ - asm_fprintf (FILE, "%0U%s", NAME) - -/* This is how to output an internal numbered label where - PREFIX is the class of label and NUM is the number within the class. */ - -#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ - asm_fprintf (FILE, "%0L%s%d:\n", PREFIX, NUM) - -/* This is how to store into the string LABEL - the symbol_ref name of an internal numbered label where - PREFIX is the class of label and NUM is the number within the class. - This is suitable for output with `assemble_name'. */ - -#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ - sprintf (LABEL, "*%s%s%d", LOCAL_LABEL_PREFIX, PREFIX, NUM) - -/* This is how to output a `long double' extended real constant. */ - -#define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \ -do { long l[3]; \ - REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \ - if (sizeof (int) == sizeof (long)) \ - fprintf (FILE, "\t.long 0x%x,0x%x,0x%x\n", l[0], l[1], l[2]); \ - else \ - fprintf (FILE, "\t.long 0x%lx,0x%lx,0x%lx\n", l[0], l[1], l[2]); \ - } while (0) - -/* This is how to output an assembler line defining a `double' constant. */ - -#define ASM_OUTPUT_DOUBLE(FILE,VALUE) \ - do { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ - fprintf (FILE, "\t.double 0r%s\n", dstr); \ - } while (0) - -/* This is how to output an assembler line defining a `float' constant. */ - -#define ASM_OUTPUT_FLOAT(FILE,VALUE) \ -do { long l; \ - REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \ - if (sizeof (int) == sizeof (long)) \ - fprintf (FILE, "\t.long 0x%x\n", l); \ - else \ - fprintf (FILE, "\t.long 0x%lx\n", l); \ - } while (0) - -/* This is how to output an assembler line defining an `int' constant. */ - -#define ASM_OUTPUT_INT(FILE,VALUE) \ -( fprintf (FILE, "\t.long "), \ - output_addr_const (FILE, (VALUE)), \ - fprintf (FILE, "\n")) - -/* Likewise for `char' and `short' constants. */ - -#define ASM_OUTPUT_SHORT(FILE,VALUE) \ -( fprintf (FILE, "\t.word "), \ - output_addr_const (FILE, (VALUE)), \ - fprintf (FILE, "\n")) - -#define ASM_OUTPUT_CHAR(FILE,VALUE) \ -( fprintf (FILE, "\t.byte "), \ - output_addr_const (FILE, (VALUE)), \ - fprintf (FILE, "\n")) - -/* This is how to output an assembler line for a numeric constant byte. */ - -#define ASM_OUTPUT_BYTE(FILE,VALUE) \ - fprintf (FILE, "\t.byte 0x%x\n", (VALUE)) - -/* This is how to output an insn to push a register on the stack. - It need not be very fast code. */ - -#define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \ - asm_fprintf (FILE, "\tmovel %s,%Rsp@-\n", reg_names[REGNO]) - -/* This is how to output an insn to pop a register from the stack. - It need not be very fast code. */ - -#define ASM_OUTPUT_REG_POP(FILE,REGNO) \ - asm_fprintf (FILE, "\tmovel %Rsp@+,%s\n", reg_names[REGNO]) - -/* This is how to output an element of a case-vector that is absolute. - (The 68000 does not use such vectors, - but we must define this macro anyway.) */ - -#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ - asm_fprintf (FILE, "\t.long %LL%d\n", VALUE) - -/* This is how to output an element of a case-vector that is relative. */ - -#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ - asm_fprintf (FILE, "\t.word %LL%d-%LL%d\n", VALUE, REL) - -/* This is how to output an assembler line - that says to advance the location counter - to a multiple of 2**LOG bytes. */ - -/* We don't have a way to align to more than a two-byte boundary, so do the - best we can and don't complain. */ -#define ASM_OUTPUT_ALIGN(FILE,LOG) \ - if ((LOG) >= 1) \ - fprintf (FILE, "\t.even\n"); - -#define ASM_OUTPUT_SKIP(FILE,SIZE) \ - fprintf (FILE, "\t.skip %u\n", (SIZE)) - -/* This says how to output an assembler line - to define a global common symbol. */ - -#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ -( fputs (".comm ", (FILE)), \ - assemble_name ((FILE), (NAME)), \ - fprintf ((FILE), ",%u\n", (ROUNDED))) - -/* This says how to output an assembler line - to define a local common symbol. */ - -#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ -( fputs (".lcomm ", (FILE)), \ - assemble_name ((FILE), (NAME)), \ - fprintf ((FILE), ",%u\n", (ROUNDED))) - -/* Store in OUTPUT a string (made with alloca) containing - an assembler-name for a local static variable named NAME. - LABELNO is an integer which is different for each call. */ - -#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ -( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \ - sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO))) - -/* Define the parentheses used to group arithmetic operations - in assembler code. */ - -#define ASM_OPEN_PAREN "(" -#define ASM_CLOSE_PAREN ")" - -/* Define results of standard character escape sequences. */ -#define TARGET_BELL 007 -#define TARGET_BS 010 -#define TARGET_TAB 011 -#define TARGET_NEWLINE 012 -#define TARGET_VT 013 -#define TARGET_FF 014 -#define TARGET_CR 015 - -/* Output a float value (represented as a C double) as an immediate operand. - This macro is a 68k-specific macro. */ - -#define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE) \ - do { \ - if (CODE == 'f') \ - { \ - char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.9g", dstr); \ - asm_fprintf ((FILE), "%I0r%s", dstr); \ - } \ - else \ - { \ - long l; \ - REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \ - if (sizeof (int) == sizeof (long)) \ - asm_fprintf ((FILE), "%I0x%x", l); \ - else \ - asm_fprintf ((FILE), "%I0x%lx", l); \ - } \ - } while (0) - -/* Output a double value (represented as a C double) as an immediate operand. - This macro is a 68k-specific macro. */ -#define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \ - do { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ - asm_fprintf (FILE, "%I0r%s", dstr); \ - } while (0) - -/* Note, long double immediate operands are not actually - generated by m68k.md. */ -#define ASM_OUTPUT_LONG_DOUBLE_OPERAND(FILE,VALUE) \ - do { char dstr[30]; \ - REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \ - asm_fprintf (FILE, "%I0r%s", dstr); \ - } while (0) - -/* Print operand X (an rtx) in assembler syntax to file FILE. - CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. - For `%' followed by punctuation, CODE is the punctuation and X is null. - - On the 68000, we use several CODE characters: - '.' for dot needed in Motorola-style opcode names. - '-' for an operand pushing on the stack: - sp@-, -(sp) or -(%sp) depending on the style of syntax. - '+' for an operand pushing on the stack: - sp@+, (sp)+ or (%sp)+ depending on the style of syntax. - '@' for a reference to the top word on the stack: - sp@, (sp) or (%sp) depending on the style of syntax. - '#' for an immediate operand prefix (# in MIT and Motorola syntax - but & in SGS syntax). - '!' for the fpcr register (used in some float-to-fixed conversions). - '$' for the letter `s' in an op code, but only on the 68040. - '&' for the letter `d' in an op code, but only on the 68040. - '/' for register prefix needed by longlong.h. - - 'b' for byte insn (no effect, on the Sun; this is for the ISI). - 'd' to force memory addressing to be absolute, not relative. - 'f' for float insn (print a CONST_DOUBLE as a float rather than in hex) - 'w' for FPA insn (print a CONST_DOUBLE as a SunFPA constant rather - than directly). Second part of 'y' below. - 'x' for float insn (print a CONST_DOUBLE as a float rather than in hex), - or print pair of registers as rx:ry. - 'y' for a FPA insn (print pair of registers as rx:ry). This also outputs - CONST_DOUBLE's as SunFPA constant RAM registers if - possible, so it should not be used except for the SunFPA. */ - -#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \ - ((CODE) == '.' || (CODE) == '#' || (CODE) == '-' \ - || (CODE) == '+' || (CODE) == '@' || (CODE) == '!' \ - || (CODE) == '$' || (CODE) == '&' || (CODE) == '/') - -/* A C compound statement to output to stdio stream STREAM the - assembler syntax for an instruction operand X. X is an RTL - expression. - - CODE is a value that can be used to specify one of several ways - of printing the operand. It is used when identical operands - must be printed differently depending on the context. CODE - comes from the `%' specification that was used to request - printing of the operand. If the specification was just `%DIGIT' - then CODE is 0; if the specification was `%LTR DIGIT' then CODE - is the ASCII code for LTR. - - If X is a register, this macro should print the register's name. - The names can be found in an array `reg_names' whose type is - `char *[]'. `reg_names' is initialized from `REGISTER_NAMES'. - - When the machine description has a specification `%PUNCT' (a `%' - followed by a punctuation character), this macro is called with - a null pointer for X and the punctuation character for CODE. - - See m68k.c for the m68k specific codes. */ - -#define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE) - -/* A C compound statement to output to stdio stream STREAM the - assembler syntax for an instruction operand that is a memory - reference whose address is ADDR. ADDR is an RTL expression. - - On some machines, the syntax for a symbolic address depends on - the section that the address refers to. On these machines, - define the macro `ENCODE_SECTION_INFO' to store the information - into the `symbol_ref', and then check for it here. */ - -#define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR) - - -/* Define functions defined in aux-output.c and used in templates. */ - -extern char *output_move_double (); -extern char *output_move_const_single (); -extern char *output_move_const_double (); -extern char *output_btst (); - -/* -Local variables: -version-control: t -End: -*/ diff --git a/gnu/usr.bin/gcc2/arch/hp300/md b/gnu/usr.bin/gcc2/arch/hp300/md deleted file mode 100644 index 986f19d1a795..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/md +++ /dev/null @@ -1,5642 +0,0 @@ -;;- Machine description for GNU compiler -;;- Motorola 68000 Version -;; Copyright (C) 1987, 1988, 1993 Free Software Foundation, Inc. - -;; This file is part of GNU CC. - -;; GNU CC 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. - -;; GNU CC 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 CC; see the file COPYING. If not, write to -;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -;; $Id: md,v 1.1 1993/08/23 09:21:30 cgd Exp $ - - -;;- instruction definitions - -;;- @@The original PO technology requires these to be ordered by speed, -;;- @@ so that assigner will pick the fastest. - -;;- See file "rtl.def" for documentation on define_insn, match_*, et. al. - -;;- When naming insn's (operand 0 of define_insn) be careful about using -;;- names from other targets machine descriptions. - -;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code -;;- updates for most instructions. - -;;- Operand classes for the register allocator: -;;- 'a' one of the address registers can be used. -;;- 'd' one of the data registers can be used. -;;- 'f' one of the m68881 registers can be used -;;- 'r' either a data or an address register can be used. -;;- 'x' if one of the Sun FPA registers -;;- 'y' if one of the Low Sun FPA registers (fpa0-fpa15). - -;;- Immediate Floating point operator constraints -;;- 'G' a floating point constant that is *NOT* one of the standard -;; 68881 constant values (to force calling output_move_const_double -;; to get it from rom if it is a 68881 constant). -;;- 'H' one of the standard FPA constant values -;; -;; See the functions standard_XXX_constant_p in output-m68k.c for more -;; info. - -;;- Immediate integer operand constraints: -;;- 'I' 1 .. 8 -;;- 'J' -32768 .. 32767 -;;- 'K' all integers EXCEPT -128 .. 127 -;;- 'L' -8 .. -1 - -;;- Assembler specs: -;;- "%." size separator ("." or "") move%.l d0,d1 -;;- "%#" immediate separator ("#" or "") move%.l %#0,d0 -;;- "%-" push operand "sp@-" move%.l d0,%- -;;- "%+" pop operand "sp@+" move%.l d0,%+ -;;- "%@" top of stack "sp@" move%.l d0,%@ -;;- "%!" fpcr register -;;- "%$" single-precision fp specifier ("s" or "") f%$add.x fp0,fp1 -;;- "%&" double-precision fp specifier ("d" or "") f%&add.x fp0,fp1 - -;;- Information about 68040 port. - -;;- The 68040 executes all 68030 and 68881/2 instructions, but some must -;;- be emulated in software by the OS. It is faster to avoid these -;;- instructions and issue a library call rather than trapping into -;;- the kernel. The affected instructions are fintrz and fscale. The -;;- TARGET_68040 flag turns the use of the opcodes off. - -;;- The '040 also implements a set of new floating-point instructions -;;- which specify the rounding precision in the opcode. This finally -;;- permit the 68k series to be truly IEEE compliant, and solves all -;;- issues of excess precision accumulating in the extended registers. -;;- By default, GCC does not use these instructions, since such code will -;;- not run on an '030. To use these instructions, use the -m68040-only -;;- switch. By changing TARGET_DEFAULT to include TARGET_68040_ONLY, -;;- you can make these instructions the default. - -;;- These new instructions aren't directly in the md. They are brought -;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather -;;- than "". - - -;;- FPA port explanation: - -;;- Usage of the Sun FPA and the 68881 together - -;;- The current port of gcc to the sun fpa disallows use of the m68881 -;;- instructions completely if code is targeted for the fpa. This is -;;- for the following reasons: - -;;- 1) Expressing the preference hierarchy (ie. use the fpa if you -;;- can, the 68881 otherwise, and data registers only if you are -;;- forced to it) is a bitch with the current constraint scheme, -;;- especially since it would have to work for any combination of -;;- -mfpa, -m68881. - -;;- 2) There are no instructions to move between the two types of -;;- registers; the stack must be used as an intermediary. - -;;- It could indeed be done; I think the best way would be to have -;;- separate patterns for TARGET_FPA (which implies a 68881), -;;- TARGET_68881, and no floating point co-processor. Use -;;- define_expands for all of the named instruction patterns, and -;;- include code in the FPA instruction to deal with the 68881 with -;;- preferences specifically set to favor the fpa. Some of this has -;;- already been done: -;;- -;;- 1) Separation of most of the patterns out into a TARGET_FPA -;;- case and a TARGET_68881 case (the exceptions are the patterns -;;- which would need one define_expand and three define_insn's under -;;- it (with a lot of duplicate code between them) to replace the -;;- current single define_insn. These are mov{[ds]f,[ds]i} and the -;;- first two patterns in the md. -;;- -;;- Some would still have to be done: -;;- -;;- 1) Add code to the fpa patterns which correspond to 68881 -;;- patterns to deal with the 68881 case (including preferences!). -;;- What you might actually do here is combine the fpa and 68881 code -;;- back together into one pattern for those instructions where it's -;;- absolutely necessary and save yourself some duplicate code. I'm -;;- not completely sure as to whether you could get away with doing -;;- this only for the mov* insns, or if you'd have to do it for all -;;- named insns. -;;- 2) Add code to the mov{[ds]f,[ds]i} instructions to handle -;;- moving between fpa regs and 68881 regs. - -;;- Since the fpa is more powerful than the 68881 and also has more -;;- registers, and since I think the resultant md would be medium ugly -;;- (lot's of duplicate code, ugly constraint strings), I elected not -;;- to do this change. - -;;- Another reason why someone *might* want to do the change is to -;;- control which register classes are accessed in a slightly cleaner -;;- way than I have. See the blurb on CONDITIONAL_REGISTER_USAGE in -;;- the internals manual. - -;;- Yet another reason why someone might want to do this change is to -;;- allow use of some of the 68881 insns which have no equivalent on -;;- the fpa. The sqrt instruction comes fairly quickly to mind. - -;;- If this is ever done, don't forget to change sun3.h so that -;;- it *will* define __HAVE_68881__ when the FPA is in use. - -;;- Condition code hack - -;;- When a floating point compare is done in the fpa, the resulting -;;- condition codes are left in the fpastatus register. The values in -;;- this register must be moved into the 68000 cc register before any -;;- jump is executed. Once this has been done, regular jump -;;- instructions are fine (ie. floating point jumps are not necessary. -;;- They are only done if the cc is in the 68881). - -;;- The instructions that move the fpastatus register to the 68000 -;;- register clobber a data register (the move cannot be done direct). -;;- These instructions might be bundled either with the compare -;;- instruction, or the branch instruction. If we were using both the -;;- fpa and the 68881 together, we would wish to only mark the -;;- register clobbered if we were doing the compare in the fpa, but I -;;- think that that decision (whether to clobber the register or not) -;;- must be done before register allocation (makes sense) and hence we -;;- can't know if the floating point compare will be done in the fpa -;;- or the fp. So whenever we are asked for code that uses the fpa, -;;- we will mark a data register as clobbered. This is reasonable, as -;;- almost all floating point compare operations done with fpa code -;;- enabled will be done in the fpa. It's even more reasonable since -;;- we decided to make the 68881 and the fpa mutually exclusive. - -;;- We place to code to move the fpastatus register inside of a -;;- define_expand so that we can do it conditionally based on whether -;;- we are targeting an fpa or not. - -;;- This still leaves us with the question of where we wish to put the -;;- code to move the fpastatus reg. If we put it in the compare -;;- instruction, we can restrict the clobbering of the register to -;;- floating point compares, but we can't take advantage of floating -;;- point subtracts & etc. that alter the fpastatus register. If we -;;- put it in the branch instruction, all branches compiled with fpa -;;- code enabled will clobber a data register, but we will be able to -;;- take advantage of fpa subtracts. This balance favors putting the -;;- code in with the compare instruction. - -;;- Note that if some enterprising hacker should decide to switch -;;- this, he'll need to modify the code in NOTICE_UPDATE_CC. - -;;- Usage of the top 16 fpa registers - -;;- The only locations which we may transfer fpa registers 16-31 from -;;- or to are the fpa registers 0-15. (68000 registers and memory -;;- locations are impossible). This causes problems in gcc, which -;;- assumes that mov?? instructions require no additional registers -;;- (see section 11.7) and since floating point moves *must* be -;;- supported into general registers (see section 12.3 under -;;- HARD_REGNO_OK_FOR_MODE_P) from anywhere. - -;;- My solution was to reserve fpa0 for moves into or out of these top -;;- 16 registers and to disparage the choice to reload into or out of -;;- these registers as much as I could. That alternative is always -;;- last in the list, so it will not be used unless all else fails. I -;;- will note that according to my current information, sun's compiler -;;- doesn't use these top 16 registers at all. - -;;- There is another possible way to do it. I *believe* that if you -;;- make absolutely sure that the code will not be executed in the -;;- reload pass, you can support the mov?? names with define_expands -;;- which require new registers. This may be possible by the -;;- appropriate juggling of constraints. I may come back to this later. - -;;- Usage of constant RAM - -;;- This has been handled correctly (I believe) but the way I've done -;;- it could use a little explanation. The constant RAM can only be -;;- accessed when the instruction is in "command register" mode. -;;- "command register" mode means that no accessing of memory or the -;;- 68000 registers is being done. This can be expressed easily in -;;- constraints, so generally the mode of the instruction is -;;- determined by a branch off of which_alternative. In outputting -;;- instructions, a 'w' means to output an access to the constant ram -;;- (if the arg is CONST_DOUBLE and is one of the available -;;- constants), and 'x' means to output a register pair (if the arg is -;;- a 68000 register) and a 'y' is the combination of the above two -;;- processes. You use a 'y' in two operand DF instructions where you -;;- *know* the other operand is an fpa register, you use an 'x' in DF -;;- instructions where the arg might be a 68000 register and the -;;- instruction is *not* in "command register" mode, and you use a 'w' -;;- in two situations: 1) The instruction *is* in command register -;;- mode (and hence won't be accessing 68000 registers), or 2) The -;;- instruction is a two operand SF instruction where you know the -;;- other operand is an fpa register. - -;;- Optimization issues - -;;- I actually think that I've included all of the fpa instructions -;;- that should be included. Note that if someone is interested in -;;- doing serious floating point work on the sun fpa, I would advise -;;- the use of the "asm" instruction in gcc to allow you to use the -;;- sin, cos, and exponential functions on the fpa board. - -;;- END FPA Explanation Section. - - -;;- Some of these insn's are composites of several m68000 op codes. -;;- The assembler (or final @@??) insures that the appropriate one is -;;- selected. - -(define_insn "" - [(set (match_operand:DF 0 "push_operand" "=m") - (match_operand:DF 1 "general_operand" "ro<>fyE"))] - "" - "* -{ - if (FP_REG_P (operands[1])) - return \"fmove%.d %f1,%0\"; - if (FPA_REG_P (operands[1])) - return \"fpmove%.d %1, %x0\"; - return output_move_double (operands); -}") - -(define_insn "" - [(set (match_operand:DI 0 "push_operand" "=m") - (match_operand:DI 1 "general_operand" "ro<>Fy"))] - "" - "* -{ - return output_move_double (operands); -}") - -;; We don't want to allow a constant operand for test insns because -;; (set (cc0) (const_int foo)) has no mode information. Such insns will -;; be folded while optimizing anyway. -(define_insn "tstsi" - [(set (cc0) - (match_operand:SI 0 "nonimmediate_operand" "rm"))] - "" - "* -{ -#ifdef ISI_OV - /* ISI's assembler fails to handle tstl a0. */ - if (! ADDRESS_REG_P (operands[0])) -#else - if (TARGET_68020 || ! ADDRESS_REG_P (operands[0])) -#endif - return \"tst%.l %0\"; - /* If you think that the 68020 does not support tstl a0, - reread page B-167 of the 68020 manual more carefully. */ - /* On an address reg, cmpw may replace cmpl. */ -#ifdef SGS_CMP_ORDER - return \"cmp%.w %0,%#0\"; -#else - return \"cmp%.w %#0,%0\"; -#endif -}") - -;; This can't use an address register, because comparisons -;; with address registers as second operand always test the whole word. -(define_insn "tsthi" - [(set (cc0) - (match_operand:HI 0 "nonimmediate_operand" "dm"))] - "" - "tst%.w %0") - -(define_insn "tstqi" - [(set (cc0) - (match_operand:QI 0 "nonimmediate_operand" "dm"))] - "" - "tst%.b %0") - -(define_expand "tstsf" - [(set (cc0) - (match_operand:SF 0 "general_operand" ""))] - "TARGET_68881 || TARGET_FPA" - " -{ - if (TARGET_FPA) - { - emit_insn (gen_tstsf_fpa (operands[0])); - DONE; - } -}") - -(define_insn "tstsf_fpa" - [(set (cc0) - (match_operand:SF 0 "general_operand" "xmdF")) - (clobber (match_scratch:SI 1 "=d"))] - "TARGET_FPA" - "fptst%.s %x0\;fpmove fpastatus,%1\;movw %1,cc") - -(define_insn "" - [(set (cc0) - (match_operand:SF 0 "general_operand" "fdm"))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; - if (FP_REG_P (operands[0])) - return \"ftst%.x %0\"; - return \"ftst%.s %0\"; -}") - -(define_expand "tstdf" - [(set (cc0) - (match_operand:DF 0 "general_operand" ""))] - "TARGET_68881 || TARGET_FPA" - " -{ - if (TARGET_FPA) - { - emit_insn (gen_tstsf_fpa (operands[0])); - DONE; - } -}") - -(define_insn "tstdf_fpa" - [(set (cc0) - (match_operand:DF 0 "general_operand" "xrmF")) - (clobber (match_scratch:SI 1 "=d"))] - "TARGET_FPA" - "fptst%.d %x0\;fpmove fpastatus,%1\;movw %1,cc") - -(define_insn "" - [(set (cc0) - (match_operand:DF 0 "general_operand" "fm"))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; - if (FP_REG_P (operands[0])) - return \"ftst%.x %0\"; - return \"ftst%.d %0\"; -}") - -;; compare instructions. - -;; A composite of the cmp, cmpa, & cmpi m68000 op codes. -(define_insn "cmpsi" - [(set (cc0) - (compare (match_operand:SI 0 "nonimmediate_operand" "rKs,mr,>") - (match_operand:SI 1 "general_operand" "mr,Ksr,>")))] - "" - "* -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return \"cmpm%.l %1,%0\"; - if (REG_P (operands[1]) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return \"cmp%.l %d1,%d0\"; -#else - return \"cmp%.l %d0,%d1\"; -#endif - } -#ifdef SGS_CMP_ORDER - return \"cmp%.l %d0,%d1\"; -#else - return \"cmp%.l %d1,%d0\"; -#endif -}") - -(define_insn "cmphi" - [(set (cc0) - (compare (match_operand:HI 0 "nonimmediate_operand" "rnm,d,n,m") - (match_operand:HI 1 "general_operand" "d,rnm,m,n")))] - "" - "* -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return \"cmpm%.w %1,%0\"; - if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1])) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return \"cmp%.w %d1,%d0\"; -#else - return \"cmp%.w %d0,%d1\"; -#endif - } -#ifdef SGS_CMP_ORDER - return \"cmp%.w %d0,%d1\"; -#else - return \"cmp%.w %d1,%d0\"; -#endif -}") - -(define_insn "cmpqi" - [(set (cc0) - (compare (match_operand:QI 0 "nonimmediate_operand" "dn,md,>") - (match_operand:QI 1 "general_operand" "dm,nd,>")))] - "" - "* -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - return \"cmpm%.b %1,%0\"; - if (REG_P (operands[1]) - || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM)) - { cc_status.flags |= CC_REVERSED; -#ifdef SGS_CMP_ORDER - return \"cmp%.b %d1,%d0\"; -#else - return \"cmp%.b %d0,%d1\"; -#endif - } -#ifdef SGS_CMP_ORDER - return \"cmp%.b %d0,%d1\"; -#else - return \"cmp%.b %d1,%d0\"; -#endif -}") - -(define_expand "cmpdf" - [(set (cc0) - (compare (match_operand:DF 0 "general_operand" "") - (match_operand:DF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - " -{ - if (TARGET_FPA) - { - emit_insn (gen_cmpdf_fpa (operands[0], operands[1])); - DONE; - } -}") - -(define_insn "cmpdf_fpa" - [(set (cc0) - (compare (match_operand:DF 0 "general_operand" "x,y") - (match_operand:DF 1 "general_operand" "xH,rmF"))) - (clobber (match_scratch:SI 2 "=d,d"))] - "TARGET_FPA" - "fpcmp%.d %y1,%0\;fpmove fpastatus,%2\;movw %2,cc") - -(define_insn "" - [(set (cc0) - (compare (match_operand:DF 0 "general_operand" "f,mG") - (match_operand:DF 1 "general_operand" "fmG,f")))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return \"fcmp%.x %0,%1\"; - else - return \"fcmp%.d %0,%f1\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.d %1,%f0\"; -#else - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return \"fcmp%.x %1,%0\"; - else - return \"fcmp%.d %f1,%0\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.d %f0,%1\"; -#endif -}") - -(define_expand "cmpsf" - [(set (cc0) - (compare (match_operand:SF 0 "general_operand" "") - (match_operand:SF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - " -{ - if (TARGET_FPA) - { - emit_insn (gen_cmpsf_fpa (operands[0], operands[1])); - DONE; - } -}") - -(define_insn "cmpsf_fpa" - [(set (cc0) - (compare (match_operand:SF 0 "general_operand" "x,y") - (match_operand:SF 1 "general_operand" "xH,rmF"))) - (clobber (match_scratch:SI 2 "=d,d"))] - "TARGET_FPA" - "fpcmp%.s %w1,%x0\;fpmove fpastatus,%2\;movw %2,cc") - -(define_insn "" - [(set (cc0) - (compare (match_operand:SF 0 "general_operand" "f,mdG") - (match_operand:SF 1 "general_operand" "fmdG,f")))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"fcmp%.x %0,%1\"; - else - return \"fcmp%.s %0,%f1\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.s %1,%f0\"; -#else - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"fcmp%.x %1,%0\"; - else - return \"fcmp%.s %f1,%0\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.s %f0,%1\"; -#endif -}") - -;; Recognizers for btst instructions. - -(define_insn "" - [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "do") - (const_int 1) - (minus:SI (const_int 7) - (match_operand:SI 1 "general_operand" "di"))))] - "" - "* { return output_btst (operands, operands[1], operands[0], insn, 7); }") - -(define_insn "" - [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "d") - (const_int 1) - (minus:SI (const_int 31) - (match_operand:SI 1 "general_operand" "di"))))] - "" - "* { return output_btst (operands, operands[1], operands[0], insn, 31); }") - -;; The following two patterns are like the previous two -;; except that they use the fact that bit-number operands -;; are automatically masked to 3 or 5 bits. - -(define_insn "" - [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "do") - (const_int 1) - (minus:SI (const_int 7) - (and:SI - (match_operand:SI 1 "general_operand" "d") - (const_int 7)))))] - "" - "* { return output_btst (operands, operands[1], operands[0], insn, 7); }") - -(define_insn "" - [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "d") - (const_int 1) - (minus:SI (const_int 31) - (and:SI - (match_operand:SI 1 "general_operand" "d") - (const_int 31)))))] - "" - "* { return output_btst (operands, operands[1], operands[0], insn, 31); }") - -;; Nonoffsettable mem refs are ok in this one pattern -;; since we don't try to adjust them. -(define_insn "" - [(set (cc0) (zero_extract (match_operand:QI 0 "nonimmediate_operand" "md") - (const_int 1) - (match_operand:SI 1 "general_operand" "i")))] - "GET_CODE (operands[1]) == CONST_INT - && (unsigned) INTVAL (operands[1]) < 8" - "* -{ - operands[1] = gen_rtx (CONST_INT, VOIDmode, 7 - INTVAL (operands[1])); - return output_btst (operands, operands[1], operands[0], insn, 7); -}") - -(define_insn "" - [(set (cc0) (zero_extract (match_operand:SI 0 "nonimmediate_operand" "do") - (const_int 1) - (match_operand:SI 1 "general_operand" "i")))] - "GET_CODE (operands[1]) == CONST_INT" - "* -{ - if (GET_CODE (operands[0]) == MEM) - { - operands[0] = adj_offsettable_operand (operands[0], - INTVAL (operands[1]) / 8); - operands[1] = gen_rtx (CONST_INT, VOIDmode, - 7 - INTVAL (operands[1]) % 8); - return output_btst (operands, operands[1], operands[0], insn, 7); - } - operands[1] = gen_rtx (CONST_INT, VOIDmode, - 31 - INTVAL (operands[1])); - return output_btst (operands, operands[1], operands[0], insn, 31); -}") - - -;; move instructions - -;; A special case in which it is not desirable -;; to reload the constant into a data register. -(define_insn "" - [(set (match_operand:SI 0 "push_operand" "=m") - (match_operand:SI 1 "general_operand" "J"))] - "GET_CODE (operands[1]) == CONST_INT - && INTVAL (operands[1]) >= -0x8000 - && INTVAL (operands[1]) < 0x8000" - "* -{ - if (operands[1] == const0_rtx) - return \"clr%.l %0\"; - return \"pea %a1\"; -}") - -;This is never used. -;(define_insn "swapsi" -; [(set (match_operand:SI 0 "general_operand" "+r") -; (match_operand:SI 1 "general_operand" "+r")) -; (set (match_dup 1) (match_dup 0))] -; "" -; "exg %1,%0") - -;; Special case of fullword move when source is zero. -;; The reason this is special is to avoid loading a zero -;; into a data reg with moveq in order to store it elsewhere. - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=g") - (const_int 0))] - ;; clr insns on 68000 read before writing. - ;; This isn't so on the 68010, but we have no alternative for it. - "(TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))" - "* -{ - if (ADDRESS_REG_P (operands[0])) - return \"sub%.l %0,%0\"; - /* moveq is faster on the 68000. */ - if (DATA_REG_P (operands[0]) && !TARGET_68020) -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %#0,%0\"; -#else - return \"moveq %#0,%0\"; -#endif - return \"clr%.l %0\"; -}") - -;; General case of fullword move. -;; -;; This is the main "hook" for PIC code. When generating -;; PIC, movsi is responsible for determining when the source address -;; needs PIC relocation and appropriately calling legitimize_pic_address -;; to perform the actual relocation. -;; -;; In both the PIC and non-PIC cases the patterns generated will -;; matched by the next define_insn. -(define_expand "movsi" - [(set (match_operand:SI 0 "general_operand" "") - (match_operand:SI 1 "general_operand" ""))] - "" - " -{ - if (flag_pic && symbolic_operand (operands[1], SImode)) - { - /* The source is an address which requires PIC relocation. - Call legitimize_pic_address with the source, mode, and a relocation - register (a new pseudo, or the final destination if reload_in_progress - is set). Then fall through normally */ - extern rtx legitimize_pic_address(); - rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode); - operands[1] = legitimize_pic_address (operands[1], SImode, temp); - } -}") - -;; General case of fullword move. The register constraints -;; force integer constants in range for a moveq to be reloaded -;; if they are headed for memory. -(define_insn "" - ;; Notes: make sure no alternative allows g vs g. - ;; We don't allow f-regs since fixed point cannot go in them. - ;; We do allow y and x regs since fixed point is allowed in them. - [(set (match_operand:SI 0 "general_operand" "=g,da,y,!*x*r*m") - (match_operand:SI 1 "general_operand" "daymKs,i,g,*x*r*m"))] - "" - "* -{ - if (which_alternative == 3) - return \"fpmove%.l %x1,fpa0\;fpmove%.l fpa0,%x0\"; - if (FPA_REG_P (operands[1]) || FPA_REG_P (operands[0])) - return \"fpmove%.l %x1,%x0\"; - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return \"clr%.l %0\"; - else if (DATA_REG_P (operands[0]) - && INTVAL (operands[1]) < 128 - && INTVAL (operands[1]) >= -128) - { -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %1,%0\"; -#else - return \"moveq %1,%0\"; -#endif - } -#ifndef NO_ADDSUB_Q - else if (DATA_REG_P (operands[0]) - /* Do this with a moveq #N-8, dreg; addq #8,dreg */ - && INTVAL (operands[1]) < 136 - && INTVAL (operands[1]) >= 128) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %1,%0\;addq%.w %#8,%0\"; -#else - return \"moveq %1,%0\;addq%.w %#8,%0\"; -#endif - } - else if (DATA_REG_P (operands[0]) - /* Do this with a moveq #N+8, dreg; subq #8,dreg */ - && INTVAL (operands[1]) < -128 - && INTVAL (operands[1]) >= -136) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) + 8); -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %1,%0;subq%.w %#8,%0\"; -#else - return \"moveq %1,%0;subq%.w %#8,%0\"; -#endif - } -#endif - else if (DATA_REG_P (operands[0]) - /* If N is in the right range and is even, then use - moveq #N/2, dreg; addl dreg,dreg */ - && INTVAL (operands[1]) > 127 - && INTVAL (operands[1]) <= 254 - && INTVAL (operands[1]) % 2 == 0) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) / 2); -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %1,%0\;add%.w %0,%0\"; -#else - return \"moveq %1,%0\;add%.w %0,%0\"; -#endif - } - else if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return \"move%.w %1,%0\"; - else if (push_operand (operands[0], SImode) - && INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return \"pea %a1\"; - } - else if ((GET_CODE (operands[1]) == SYMBOL_REF - || GET_CODE (operands[1]) == CONST) - && push_operand (operands[0], SImode)) - return \"pea %a1\"; - else if ((GET_CODE (operands[1]) == SYMBOL_REF - || GET_CODE (operands[1]) == CONST) - && ADDRESS_REG_P (operands[0])) - return \"lea %a1,%0\"; - return \"move%.l %1,%0\"; -}") - -(define_insn "movhi" - [(set (match_operand:HI 0 "general_operand" "=g") - (match_operand:HI 1 "general_operand" "g"))] - "" - "* -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return \"clr%.w %0\"; - else if (DATA_REG_P (operands[0]) - && INTVAL (operands[1]) < 128 - && INTVAL (operands[1]) >= -128) - { -#if defined(MOTOROLA) && !defined(CRDS) - return \"moveq%.l %1,%0\"; -#else - return \"moveq %1,%0\"; -#endif - } - else if (INTVAL (operands[1]) < 0x8000 - && INTVAL (operands[1]) >= -0x8000) - return \"move%.w %1,%0\"; - } - else if (CONSTANT_P (operands[1])) - return \"move%.l %1,%0\"; -#ifndef SGS_NO_LI - /* Recognize the insn before a tablejump, one that refers - to a table of offsets. Such an insn will need to refer - to a label on the insn. So output one. Use the label-number - of the table of offsets to generate this label. */ - if (GET_CODE (operands[1]) == MEM - && GET_CODE (XEXP (operands[1], 0)) == PLUS - && (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF - || GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == LABEL_REF) - && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) != PLUS - && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) != PLUS) - { - rtx labelref; - if (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF) - labelref = XEXP (XEXP (operands[1], 0), 0); - else - labelref = XEXP (XEXP (operands[1], 0), 1); -#if defined (MOTOROLA) && !defined (SGS_SWITCH_TABLES) -#ifdef SGS - asm_fprintf (asm_out_file, \"\\tset %LLI%d,.+2\\n\", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#else /* not SGS */ - asm_fprintf (asm_out_file, \"\\t.set %LLI%d,.+2\\n\", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#endif /* not SGS */ -#else /* SGS_SWITCH_TABLES or not MOTOROLA */ - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"LI\", - CODE_LABEL_NUMBER (XEXP (labelref, 0))); -#ifdef SGS_SWITCH_TABLES - /* Set flag saying we need to define the symbol - LD%n (with value L%n-LI%n) at the end of the switch table. */ - switch_table_difference_label_flag = 1; -#endif /* SGS_SWITCH_TABLES */ -#endif /* SGS_SWITCH_TABLES or not MOTOROLA */ - } -#endif /* SGS_NO_LI */ - return \"move%.w %1,%0\"; -}") - -(define_insn "movstricthi" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm")) - (match_operand:HI 1 "general_operand" "rmn"))] - "" - "* -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return \"clr%.w %0\"; - } - return \"move%.w %1,%0\"; -}") - -(define_insn "movqi" - [(set (match_operand:QI 0 "general_operand" "=d,*a,m,m,?*a") - (match_operand:QI 1 "general_operand" "dmi*a,d*a,dmi,?*a,m"))] - "" - "* -{ - rtx xoperands[4]; - - /* This is probably useless, since it loses for pushing a struct - of several bytes a byte at a time. */ - if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC - && XEXP (XEXP (operands[0], 0), 0) == stack_pointer_rtx) - { - xoperands[1] = operands[1]; - xoperands[2] - = gen_rtx (MEM, QImode, - gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, const1_rtx)); - /* Just pushing a byte puts it in the high byte of the halfword. */ - /* We must put it in the low-order, high-numbered byte. */ - output_asm_insn (\"move%.b %1,%-\;move%.b %@,%2\", xoperands); - return \"\"; - } - - /* Moving a byte into an address register is not possible. */ - /* Use d0 as an intermediate, but don't clobber its contents. */ - if (ADDRESS_REG_P (operands[0]) && GET_CODE (operands[1]) == MEM) - { - /* ??? For 2.5, don't allow this choice and use secondary reloads - instead. - - See if the address register is used in the address. If it - is, we have to generate a more complex sequence than those below. */ - if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1, - operands[1], NULL_RTX)) - { - /* See if the stack pointer is used in the address. If it isn't, - we can push d0 or d1 (the insn can't use both of them) on - the stack, perform our move into d0/d1, copy the byte from d0/1, - and pop d0/1. */ - if (! reg_mentioned_p (stack_pointer_rtx, operands[1])) - { - if (refers_to_regno_p (0, 1, operands[1], NULL_RTX)) - return \"move%.l %/d0,%-\;move%.b %1,%/d0\;move%.l %/d0,%0\;move%.l %+,%/d0\"; - else - return \"move%.l %/d1,%-\;move%.b %1,%/d1\;move%.l %/d1,%0\;move%.l %+,%/d1\"; - } - else - { - /* Otherwise, we know that d0 cannot be used in the address - (since sp and one address register is). Assume that sp is - being used as a base register and replace the address - register that is our operand[0] with d0. */ - rtx reg_map[FIRST_PSEUDO_REGISTER]; - int i; - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - reg_map[i] = 0; - - reg_map[REGNO (operands[0])] = gen_rtx (REG, Pmode, 0); - operands[1] = copy_rtx (operands[1]); - replace_regs (operands[1], reg_map, FIRST_PSEUDO_REGISTER, 0); - return \"exg %/d0,%0\;move%.b %1,%/d0\;exg %/d0,%0\"; - } - } - - /* If the address of operand 1 uses d0, choose d1 as intermediate. */ - if (refers_to_regno_p (0, 1, operands[1], NULL_RTX)) - return \"exg %/d1,%0\;move%.b %1,%/d1\;exg %/d1,%0\"; - /* Otherwise d0 is usable. - (An effective address on the 68k can't use two d-regs.) */ - else - return \"exg %/d0,%0\;move%.b %1,%/d0\;exg %/d0,%0\"; - } - - /* Likewise for moving from an address reg. */ - if (ADDRESS_REG_P (operands[1]) && GET_CODE (operands[0]) == MEM) - { - /* ??? For 2.5, don't allow this choice and use secondary reloads - instead. - - See if the address register is used in the address. If it - is, we have to generate a more complex sequence than those below. */ - if (refers_to_regno_p (REGNO (operands[1]), REGNO (operands[1]) + 1, - operands[0], NULL_RTX)) - { - /* See if the stack pointer is used in the address. If it isn't, - we can push d0 or d1 (the insn can't use both of them) on - the stack, copy the byte to d0/1, perform our move from d0/d1, - and pop d0/1. */ - if (! reg_mentioned_p (stack_pointer_rtx, operands[0])) - { - if (refers_to_regno_p (0, 1, operands[0], NULL_RTX)) - return \"move%.l %/d0,%-\;move%.l %1,%/d0\;move%.b %/d0,%0\;move%.l %+,%/d0\"; - else - return \"move%.l %/d1,%-\;move%.l %1,%/d1\;move%.b %/d1,%0\;move%.l %+,%/d1\"; - } - else - { - /* Otherwise, we know that d0 cannot be used in the address - (since sp and one address register is). Assume that sp is - being used as a base register and replace the address - register that is our operand[1] with d0. */ - rtx reg_map[FIRST_PSEUDO_REGISTER]; - int i; - - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - reg_map[i] = 0; - - reg_map[REGNO (operands[1])] = gen_rtx (REG, Pmode, 0); - operands[0] = copy_rtx (operands[0]); - replace_regs (operands[0], reg_map, FIRST_PSEUDO_REGISTER, 0); - return \"exg %/d0,%1\;move%.b %/d0,%0\;exg %/d0,%1\"; - } - } - - if (refers_to_regno_p (0, 1, operands[0], NULL_RTX)) - return \"exg %/d1,%1\;move%.b %/d1,%0\;exg %/d1,%1\"; - else - return \"exg %/d0,%1\;move%.b %/d0,%0\;exg %/d0,%1\"; - } - - /* clr and st insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - if (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - if (operands[1] == const0_rtx) - return \"clr%.b %0\"; - if (GET_CODE (operands[1]) == CONST_INT - && INTVAL (operands[1]) == -1) - { - CC_STATUS_INIT; - return \"st %0\"; - } - } - if (GET_CODE (operands[1]) != CONST_INT && CONSTANT_P (operands[1])) - return \"move%.l %1,%0\"; - if (ADDRESS_REG_P (operands[0]) || ADDRESS_REG_P (operands[1])) - return \"move%.w %1,%0\"; - return \"move%.b %1,%0\"; -}") - -(define_insn "movstrictqi" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm")) - (match_operand:QI 1 "general_operand" "dmn"))] - "" - "* -{ - if (operands[1] == const0_rtx - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))) - return \"clr%.b %0\"; - return \"move%.b %1,%0\"; -}") - -(define_insn "movsf" - [(set (match_operand:SF 0 "general_operand" "=rmf,x,y,rm,!x,!rm") - (match_operand:SF 1 "general_operand" "rmfF,xH,rmF,y,rm,x"))] -; [(set (match_operand:SF 0 "general_operand" "=rmf") -; (match_operand:SF 1 "general_operand" "rmfF"))] - "" - "* -{ - if (which_alternative >= 4) - return \"fpmove%.s %1,fpa0\;fpmove%.s fpa0,%0\"; - if (FPA_REG_P (operands[0])) - { - if (FPA_REG_P (operands[1])) - return \"fpmove%.s %x1,%x0\"; - else if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_single (operands); - else if (FP_REG_P (operands[1])) - return \"fmove%.s %1,sp@-\;fpmove%.d sp@+, %0\"; - return \"fpmove%.s %x1,%x0\"; - } - if (FPA_REG_P (operands[1])) - { - if (FP_REG_P (operands[0])) - return \"fpmove%.s %x1,sp@-\;fmove%.s sp@+,%0\"; - else - return \"fpmove%.s %x1,%x0\"; - } - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"f%$move%.x %1,%0\"; - else if (ADDRESS_REG_P (operands[1])) - return \"move%.l %1,%-\;f%$move%.s %+,%0\"; - else if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_single (operands); - return \"f%$move%.s %f1,%0\"; - } - if (FP_REG_P (operands[1])) - { - if (ADDRESS_REG_P (operands[0])) - return \"fmove%.s %1,%-\;move%.l %+,%0\"; - return \"fmove%.s %f1,%0\"; - } - return \"move%.l %1,%0\"; -}") - -(define_insn "movdf" - [(set (match_operand:DF 0 "general_operand" "=rm,&rf,&rof<>,y,rm,x,!x,!rm") - (match_operand:DF 1 "general_operand" "rf,m,rofE<>,rmE,y,xH,rm,x"))] -; [(set (match_operand:DF 0 "general_operand" "=rm,&rf,&rof<>") -; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))] - "" - "* -{ - if (which_alternative == 6) - return \"fpmove%.d %x1,fpa0\;fpmove%.d fpa0,%x0\"; - if (FPA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - if (FP_REG_P (operands[1])) - return \"fmove%.d %1,sp@-\;fpmove%.d sp@+,%x0\"; - return \"fpmove%.d %x1,%x0\"; - } - else if (FPA_REG_P (operands[1])) - { - if (FP_REG_P(operands[0])) - return \"fpmove%.d %x1,sp@-\;fmoved sp@+,%0\"; - else - return \"fpmove%.d %x1,%x0\"; - } - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"f%&move%.x %1,%0\"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn (\"move%.l %1,%-\", xoperands); - output_asm_insn (\"move%.l %1,%-\", operands); - return \"f%&move%.d %+,%0\"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - return \"f%&move%.d %f1,%0\"; - } - else if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - else - return \"fmove%.d %f1,%0\"; - } - return output_move_double (operands); -} -") - -(define_expand "movxf" - [(set (match_operand:XF 0 "nonimmediate_operand" "") - (match_operand:XF 1 "general_operand" ""))] - "" - " -{ - if (CONSTANT_P (operands[1])) - { - operands[1] = force_const_mem (XFmode, operands[1]); - if (! memory_address_p (XFmode, XEXP (operands[1], 0)) - && ! reload_in_progress) - operands[1] = change_address (operands[1], XFmode, - XEXP (operands[1], 0)); - } -}") - -(define_insn "" - [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f") - (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r"))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"fmove%.x %1,%0\"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2); - output_asm_insn (\"move%.l %1,%-\", xoperands); - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn (\"move%.l %1,%-\", xoperands); - output_asm_insn (\"move%.l %1,%-\", operands); - return \"fmove%.x %+,%0\"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return \"fmove%.x %1,%0\"; - return \"fmove%.x %f1,%0\"; - } - if (REG_P (operands[0])) - { - output_asm_insn (\"fmove%.x %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - output_asm_insn (\"move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - return \"fmove%.x %f1,%0\"; -} -") - -(define_insn "" - [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,&rf,&rof<>") - (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))] - "! TARGET_68881" - "* -{ - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"fmove%.x %1,%0\"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2); - output_asm_insn (\"move%.l %1,%-\", xoperands); - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn (\"move%.l %1,%-\", xoperands); - output_asm_insn (\"move%.l %1,%-\", operands); - return \"fmove%.x %+,%0\"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return \"fmove%.x %1,%0\"; - return \"fmove%.x %f1,%0\"; - } - if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn (\"fmove%.x %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - output_asm_insn (\"move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - else - return \"fmove%.x %f1,%0\"; - } - return output_move_double (operands); -} -") - -;; movdi can apply to fp regs in some cases -(define_insn "movdi" - ;; Let's see if it really still needs to handle fp regs, and, if so, why. - [(set (match_operand:DI 0 "general_operand" "=rm,&r,&ro<>,y,rm,!*x,!rm") - (match_operand:DI 1 "general_operand" "rF,m,roi<>F,rmiF,y,rmF,*x"))] -; [(set (match_operand:DI 0 "general_operand" "=rm,&r,&ro<>,!&rm,!&f,y,rm,x,!x,!rm") -; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfmF,rmi,y,rm,x"))] -; [(set (match_operand:DI 0 "general_operand" "=rm,&rf,&ro<>,!&rm,!&f") -; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))] - "" - "* -{ - if (which_alternative == 8) - return \"fpmove%.d %x1,fpa0\;fpmove%.d fpa0,%x0\"; - if (FPA_REG_P (operands[0]) || FPA_REG_P (operands[1])) - return \"fpmove%.d %x1,%x0\"; - if (FP_REG_P (operands[0])) - { - if (FP_REG_P (operands[1])) - return \"fmove%.x %1,%0\"; - if (REG_P (operands[1])) - { - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn (\"move%.l %1,%-\", xoperands); - output_asm_insn (\"move%.l %1,%-\", operands); - return \"fmove%.d %+,%0\"; - } - if (GET_CODE (operands[1]) == CONST_DOUBLE) - return output_move_const_double (operands); - return \"fmove%.d %f1,%0\"; - } - else if (FP_REG_P (operands[1])) - { - if (REG_P (operands[0])) - { - output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - else - return \"fmove%.d %f1,%0\"; - } - return output_move_double (operands); -} -") - -;; Thus goes after the move instructions -;; because the move instructions are better (require no spilling) -;; when they can apply. It goes before the add/sub insns -;; so we will prefer it to them. - -(define_insn "pushasi" - [(set (match_operand:SI 0 "push_operand" "=m") - (match_operand:SI 1 "address_operand" "p"))] - "" - "pea %a1") - -;; truncation instructions -(define_insn "truncsiqi2" - [(set (match_operand:QI 0 "general_operand" "=dm,d") - (truncate:QI - (match_operand:SI 1 "general_operand" "doJ,i")))] - "" - "* -{ - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return \"move%.l %1,%0\"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 3); - return \"move%.b %1,%0\"; -}") - -(define_insn "trunchiqi2" - [(set (match_operand:QI 0 "general_operand" "=dm,d") - (truncate:QI - (match_operand:HI 1 "general_operand" "doJ,i")))] - "" - "* -{ - if (GET_CODE (operands[0]) == REG - && (GET_CODE (operands[1]) == MEM - || GET_CODE (operands[1]) == CONST_INT)) - { - /* Must clear condition codes, since the move.w bases them on - the entire 16 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return \"move%.w %1,%0\"; - } - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return \"move%.l %1,%0\"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 1); - return \"move%.b %1,%0\"; -}") - -(define_insn "truncsihi2" - [(set (match_operand:HI 0 "general_operand" "=dm,d") - (truncate:HI - (match_operand:SI 1 "general_operand" "roJ,i")))] - "" - "* -{ - if (GET_CODE (operands[0]) == REG) - { - /* Must clear condition codes, since the move.l bases them on - the entire 32 bits, not just the desired 8 bits. */ - CC_STATUS_INIT; - return \"move%.l %1,%0\"; - } - if (GET_CODE (operands[1]) == MEM) - operands[1] = adj_offsettable_operand (operands[1], 2); - return \"move%.w %1,%0\"; -}") - -;; zero extension instructions - -(define_expand "zero_extendhisi2" - [(set (match_operand:SI 0 "register_operand" "") - (const_int 0)) - (set (strict_low_part (match_dup 2)) - (match_operand:HI 1 "general_operand" ""))] - "" - " -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, HImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, HImode, operands[0], 0); -}") - -(define_expand "zero_extendqihi2" - [(set (match_operand:HI 0 "register_operand" "") - (const_int 0)) - (set (strict_low_part (match_dup 2)) - (match_operand:QI 1 "general_operand" ""))] - "" - " -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0); -}") - -(define_expand "zero_extendqisi2" - [(set (match_operand:SI 0 "register_operand" "") - (const_int 0)) - (set (strict_low_part (match_dup 2)) - (match_operand:QI 1 "general_operand" ""))] - "" - " -{ - operands[1] = make_safe_from (operands[1], operands[0]); - if (GET_CODE (operands[0]) == SUBREG) - operands[2] = gen_rtx (SUBREG, QImode, SUBREG_REG (operands[0]), - SUBREG_WORD (operands[0])); - else - operands[2] = gen_rtx (SUBREG, QImode, operands[0], 0); -}") - -;; Patterns to recognize zero-extend insns produced by the combiner. -;; We don't allow both operands in memory, because of aliasing problems. -;; Explicitly disallow two memory operands via the condition since reloading -;; of this case will result in worse code than the uncombined patterns. - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=do<>,d<") - (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))] - "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" - "* -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return \"and%.l %#0xFFFF,%0\"; - if (reg_mentioned_p (operands[0], operands[1])) - return \"move%.w %1,%0\;and%.l %#0xFFFF,%0\"; - return \"clr%.l %0\;move%.w %1,%0\"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - return \"move%.w %1,%0\;clr%.w %0\"; - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - return \"clr%.w %0\;move%.w %1,%0\"; - else - { - output_asm_insn (\"clr%.w %0\", operands); - operands[0] = adj_offsettable_operand (operands[0], 2); - return \"move%.w %1,%0\"; - } -}") - -(define_insn "" - [(set (match_operand:HI 0 "general_operand" "=do<>,d") - (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "d,m")))] - "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" - "* -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return \"and%.w %#0xFF,%0\"; - if (reg_mentioned_p (operands[0], operands[1])) - return \"move%.b %1,%0\;and%.w %#0xFF,%0\"; - return \"clr%.w %0\;move%.b %1,%0\"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - { - if (REGNO (XEXP (XEXP (operands[0], 0), 0)) - == STACK_POINTER_REGNUM) - { - output_asm_insn (\"clr%.w %-\", operands); - operands[0] = gen_rtx (MEM, GET_MODE (operands[0]), - plus_constant (stack_pointer_rtx, 1)); - return \"move%.b %1,%0\"; - } - else - return \"move%.b %1,%0\;clr%.b %0\"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - return \"clr%.b %0\;move%.b %1,%0\"; - else - { - output_asm_insn (\"clr%.b %0\", operands); - operands[0] = adj_offsettable_operand (operands[0], 1); - return \"move%.b %1,%0\"; - } -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=do<>,d") - (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "d,m")))] - "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM" - "* -{ - if (DATA_REG_P (operands[0])) - { - if (GET_CODE (operands[1]) == REG - && REGNO (operands[0]) == REGNO (operands[1])) - return \"and%.l %#0xFF,%0\"; - if (reg_mentioned_p (operands[0], operands[1])) - return \"move%.b %1,%0\;and%.l %#0xFF,%0\"; - return \"clr%.l %0\;move%.b %1,%0\"; - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) - { - operands[0] = XEXP (XEXP (operands[0], 0), 0); -#ifdef MOTOROLA -#ifdef SGS - return \"clr%.l -(%0)\;move%.b %1,3(%0)\"; -#else - return \"clr%.l -(%0)\;move%.b %1,(3,%0)\"; -#endif -#else - return \"clrl %0@-\;moveb %1,%0@(3)\"; -#endif - } - else if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == POST_INC) - { - operands[0] = XEXP (XEXP (operands[0], 0), 0); -#ifdef MOTOROLA -#ifdef SGS - return \"clr%.l (%0)+\;move%.b %1,-1(%0)\"; -#else - return \"clr%.l (%0)+\;move%.b %1,(-1,%0)\"; -#endif -#else - return \"clrl %0@+\;moveb %1,%0@(-1)\"; -#endif - } - else - { - output_asm_insn (\"clr%.l %0\", operands); - operands[0] = adj_offsettable_operand (operands[0], 3); - return \"move%.b %1,%0\"; - } -}") - -;; sign extension instructions - -(define_insn "extendhisi2" - [(set (match_operand:SI 0 "general_operand" "=*d,a") - (sign_extend:SI - (match_operand:HI 1 "nonimmediate_operand" "0,rm")))] - "" - "* -{ - if (ADDRESS_REG_P (operands[0])) - return \"move%.w %1,%0\"; - return \"ext%.l %0\"; -}") - -(define_insn "extendqihi2" - [(set (match_operand:HI 0 "general_operand" "=d") - (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))] - "" - "ext%.w %0") - -(define_insn "extendqisi2" - [(set (match_operand:SI 0 "general_operand" "=d") - (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))] - "TARGET_68020" - "extb%.l %0") - -;; Conversions between float and double. - -(define_expand "extendsfdf2" - [(set (match_operand:DF 0 "general_operand" "") - (float_extend:DF - (match_operand:SF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y") - (float_extend:DF - (match_operand:SF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpstod %w1,%0") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=*fdm,f") - (float_extend:DF - (match_operand:SF 1 "general_operand" "f,dmF")))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return \"\"; - } - return \"f%&move%.x %1,%0\"; - } - if (FP_REG_P (operands[0])) - return \"f%&move%.s %f1,%0\"; - if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - return \"fmove%.d %f1,%0\"; -}") - -;; This cannot output into an f-reg because there is no way to be -;; sure of truncating in that case. -;; But on the Sun FPA, we can be sure. -(define_expand "truncdfsf2" - [(set (match_operand:SF 0 "general_operand" "") - (float_truncate:SF - (match_operand:DF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y") - (float_truncate:SF - (match_operand:DF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpdtos %y1,%0") - -;; On the '040 we can truncate in a register accurately and easily. -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (float_truncate:SF - (match_operand:DF 1 "general_operand" "fmG")))] - "TARGET_68040_ONLY" - "* -{ - if (FP_REG_P (operands[1])) - return \"f%$move%.x %1,%0\"; - return \"f%$move%.d %f1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=dm") - (float_truncate:SF - (match_operand:DF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.s %f1,%0") - -;; Conversion between fixed point and floating point. -;; Note that among the fix-to-float insns -;; the ones that start with SImode come first. -;; That is so that an operand that is a CONST_INT -;; (and therefore lacks a specific machine mode). -;; will be recognized as SImode (which is always valid) -;; rather than as QImode or HImode. - -(define_expand "floatsisf2" - [(set (match_operand:SF 0 "general_operand" "") - (float:SF (match_operand:SI 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=y,x") - (float:SF (match_operand:SI 1 "general_operand" "rmi,x")))] - "TARGET_FPA" - "fpltos %1,%0") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (float:SF (match_operand:SI 1 "general_operand" "dmi")))] - "TARGET_68881" - "f%$move%.l %1,%0") - -(define_expand "floatsidf2" - [(set (match_operand:DF 0 "general_operand" "") - (float:DF (match_operand:SI 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=y,x") - (float:DF (match_operand:SI 1 "general_operand" "rmi,x")))] - "TARGET_FPA" - "fpltod %1,%0") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (float:DF (match_operand:SI 1 "general_operand" "dmi")))] - "TARGET_68881" - "f%&move%.l %1,%0") - -(define_insn "floathisf2" - [(set (match_operand:SF 0 "general_operand" "=f") - (float:SF (match_operand:HI 1 "general_operand" "dmn")))] - "TARGET_68881" - "f%$move%.w %1,%0") - -(define_insn "floathidf2" - [(set (match_operand:DF 0 "general_operand" "=f") - (float:DF (match_operand:HI 1 "general_operand" "dmn")))] - "TARGET_68881" - "fmove%.w %1,%0") - -(define_insn "floatqisf2" - [(set (match_operand:SF 0 "general_operand" "=f") - (float:SF (match_operand:QI 1 "general_operand" "dmn")))] - "TARGET_68881" - "fmove%.b %1,%0") - -(define_insn "floatqidf2" - [(set (match_operand:DF 0 "general_operand" "=f") - (float:DF (match_operand:QI 1 "general_operand" "dmn")))] - "TARGET_68881" - "f%&move%.b %1,%0") - -;; New routines to convert floating-point values to integers -;; to be used on the '040. These should be faster than trapping -;; into the kernel to emulate fintrz. They should also be faster -;; than calling the subroutines fixsfsi or fixdfsi. - -(define_insn "fix_truncdfsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f")))) - (clobber (match_scratch:SI 2 "=d")) - (clobber (match_scratch:SI 3 "=d"))] - "TARGET_68040" - "* -{ - CC_STATUS_INIT; - return \"fmovem%.l %!,%2\;moveq %#16,%3\;or%.l %2,%3\;and%.w %#-33,%3\;fmovem%.l %3,%!\;fmove%.l %1,%0\;fmovem%.l %2,%!\"; -}") - -(define_insn "fix_truncdfhi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f")))) - (clobber (match_scratch:SI 2 "=d")) - (clobber (match_scratch:SI 3 "=d"))] - "TARGET_68040" - "* -{ - CC_STATUS_INIT; - return \"fmovem%.l %!,%2\;moveq %#16,%3\;or%.l %2,%3\;and%.w %#-33,%3\;fmovem%.l %3,%!\;fmove%.w %1,%0\;fmovem%.l %2,%!\"; -}") - -(define_insn "fix_truncdfqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f")))) - (clobber (match_scratch:SI 2 "=d")) - (clobber (match_scratch:SI 3 "=d"))] - "TARGET_68040" - "* -{ - CC_STATUS_INIT; - return \"fmovem%.l %!,%2\;moveq %#16,%3\;or%.l %2,%3\;and%.w %#-33,%3\;fmovem%.l %3,%!\;fmove%.b %1,%0\;fmovem%.l %2,%!\"; -}") - -;; Convert a float to a float whose value is an integer. -;; This is the first stage of converting it to an integer type. - -(define_insn "ftruncdf2" - [(set (match_operand:DF 0 "general_operand" "=f") - (fix:DF (match_operand:DF 1 "general_operand" "fFm")))] - "TARGET_68881 && !TARGET_68040" - "* -{ - if (FP_REG_P (operands[1])) - return \"fintrz%.x %f1,%0\"; - return \"fintrz%.d %f1,%0\"; -}") - -(define_insn "ftruncsf2" - [(set (match_operand:SF 0 "general_operand" "=f") - (fix:SF (match_operand:SF 1 "general_operand" "dfFm")))] - "TARGET_68881 && !TARGET_68040" - "* -{ - if (FP_REG_P (operands[1])) - return \"fintrz%.x %f1,%0\"; - return \"fintrz%.s %f1,%0\"; -}") - -;; Convert a float whose value is an integer -;; to an actual integer. Second stage of converting float to integer type. -(define_insn "fixsfqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (fix:QI (match_operand:SF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.b %1,%0") - -(define_insn "fixsfhi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (fix:HI (match_operand:SF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.w %1,%0") - -(define_insn "fixsfsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (fix:SI (match_operand:SF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.l %1,%0") - -(define_insn "fixdfqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (fix:QI (match_operand:DF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.b %1,%0") - -(define_insn "fixdfhi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (fix:HI (match_operand:DF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.w %1,%0") - -(define_insn "fixdfsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (fix:SI (match_operand:DF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.l %1,%0") - -;; Convert a float to an integer. -;; On the Sun FPA, this is done in one step. - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=x,y") - (fix:SI (fix:SF (match_operand:SF 1 "general_operand" "xH,rmF"))))] - "TARGET_FPA" - "fpstol %w1,%0") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=x,y") - (fix:SI (fix:DF (match_operand:DF 1 "general_operand" "xH,rmF"))))] - "TARGET_FPA" - "fpdtol %y1,%0") - -;; add instructions - -;; Note that the middle two alternatives are near-duplicates -;; in order to handle insns generated by reload. -;; This is needed since they are not themselves reloaded, -;; so commutativity won't apply to them. -(define_insn "addsi3" - [(set (match_operand:SI 0 "general_operand" "=m,?a,?a,r") - (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0") - (match_operand:SI 2 "general_operand" "dIKLs,rJK,a,mrIKLs")))] - "" - "* -{ - if (! operands_match_p (operands[0], operands[1])) - { - if (!ADDRESS_REG_P (operands[1])) - { - rtx tmp = operands[1]; - - operands[1] = operands[2]; - operands[2] = tmp; - } - - /* These insns can result from reloads to access - stack slots over 64k from the frame pointer. */ - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) + 0x8000 >= (unsigned) 0x10000) - return \"move%.l %2,%0\;add%.l %1,%0\"; -#ifdef SGS - if (GET_CODE (operands[2]) == REG) - return \"lea 0(%1,%2.l),%0\"; - else - return \"lea %c2(%1),%0\"; -#else /* not SGS */ -#ifdef MOTOROLA - if (GET_CODE (operands[2]) == REG) - return \"lea (%1,%2.l),%0\"; - else - return \"lea (%c2,%1),%0\"; -#else /* not MOTOROLA (MIT syntax) */ - if (GET_CODE (operands[2]) == REG) - return \"lea %1@(0,%2:l),%0\"; - else - return \"lea %1@(%c2),%0\"; -#endif /* not MOTOROLA */ -#endif /* not SGS */ - } - if (GET_CODE (operands[2]) == CONST_INT) - { -#ifndef NO_ADDSUB_Q - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return (ADDRESS_REG_P (operands[0]) - ? \"addq%.w %2,%0\" - : \"addq%.l %2,%0\"); - if (INTVAL (operands[2]) < 0 - && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2])); - return (ADDRESS_REG_P (operands[0]) - ? \"subq%.w %2,%0\" - : \"subq%.l %2,%0\"); - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw.*/ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return \"addq%.w %#8,%0\;addq%.w %2,%0\"; - } - if (INTVAL (operands[2]) < -8 - && INTVAL (operands[2]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2]) - 8); - return \"subq%.w %#8,%0\;subq%.w %2,%0\"; - } -#endif - if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[2]) >= -0x8000 - && INTVAL (operands[2]) < 0x8000) - return \"add%.w %2,%0\"; - } - return \"add%.l %2,%0\"; -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=a") - (plus:SI (match_operand:SI 1 "general_operand" "0") - (sign_extend:SI - (match_operand:HI 2 "nonimmediate_operand" "rm"))))] - "" - "add%.w %2,%0") - -(define_insn "addhi3" - [(set (match_operand:HI 0 "general_operand" "=m,r") - (plus:HI (match_operand:HI 1 "general_operand" "%0,0") - (match_operand:HI 2 "general_operand" "dn,rmn")))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[2]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[2]) >= 32768) - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) - 65536); - - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return \"addq%.w %2,%0\"; - if (INTVAL (operands[2]) < 0 - && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2])); - return \"subq%.w %2,%0\"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return \"addq%.w %#8,%0\;addq%.w %2,%0\"; - } - if (INTVAL (operands[2]) < -8 - && INTVAL (operands[2]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[2]) - 8); - return \"subq%.w %#8,%0\;subq%.w %2,%0\"; - } - } -#endif - return \"add%.w %2,%0\"; -}") - -;; These insns must use MATCH_DUP instead of the more expected -;; use of a matching constraint because the "output" here is also -;; an input, so you can't use the matching constraint. That also means -;; that you can't use the "%", so you need patterns with the matched -;; operand in both positions. - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (plus:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dn,rmn")))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[1]) >= 32768) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 65536); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return \"addq%.w %1,%0\"; - if (INTVAL (operands[1]) < 0 - && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1])); - return \"subq%.w %1,%0\"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[1]) > 8 - && INTVAL (operands[1]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); - return \"addq%.w %#8,%0\;addq%.w %1,%0\"; - } - if (INTVAL (operands[1]) < -8 - && INTVAL (operands[1]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1]) - 8); - return \"subq%.w %#8,%0\;subq%.w %1,%0\"; - } - } -#endif - return \"add%.w %1,%0\"; -}") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (plus:HI (match_operand:HI 1 "general_operand" "dn,rmn") - (match_dup 0)))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - /* If the constant would be a negative number when interpreted as - HImode, make it negative. This is usually, but not always, done - elsewhere in the compiler. First check for constants out of range, - which could confuse us. */ - - if (INTVAL (operands[1]) >= 32768) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 65536); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return \"addq%.w %1,%0\"; - if (INTVAL (operands[1]) < 0 - && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1])); - return \"subq%.w %1,%0\"; - } - /* On everything except the 68000 it is faster to use two - addqw instructions to add a small integer (8 < N <= 16) - to an address register. Likewise for subqw. */ - if (INTVAL (operands[1]) > 8 - && INTVAL (operands[1]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) - 8); - return \"addq%.w %#8,%0\;addq%.w %1,%0\"; - } - if (INTVAL (operands[1]) < -8 - && INTVAL (operands[1]) >= -16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - - INTVAL (operands[1]) - 8); - return \"subq%.w %#8,%0\;subq%.w %1,%0\"; - } - } -#endif - return \"add%.w %1,%0\"; -}") - -(define_insn "addqi3" - [(set (match_operand:QI 0 "general_operand" "=m,d") - (plus:QI (match_operand:QI 1 "general_operand" "%0,0") - (match_operand:QI 2 "general_operand" "dn,dmn")))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[2]) == CONST_INT) - { - if (INTVAL (operands[2]) >= 128) - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) - 256); - - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return \"addq%.b %2,%0\"; - if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2])); - return \"subq%.b %2,%0\"; - } - } -#endif - return \"add%.b %2,%0\"; -}") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (plus:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dn,dmn")))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) >= 128) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 256); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return \"addq%.b %1,%0\"; - if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1])); - return \"subq%.b %1,%0\"; - } - } -#endif - return \"add%.b %1,%0\"; -}") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (plus:QI (match_operand:QI 1 "general_operand" "dn,dmn") - (match_dup 0)))] - "" - "* -{ -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) >= 128) - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1]) - 256); - - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return \"addq%.b %1,%0\"; - if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[1])); - return \"subq%.b %1,%0\"; - } - } -#endif - return \"add%.b %1,%0\"; -}") - -(define_expand "adddf3" - [(set (match_operand:DF 0 "general_operand" "") - (plus:DF (match_operand:DF 1 "general_operand" "") - (match_operand:DF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y") - (plus:DF (match_operand:DF 1 "general_operand" "%xH,y") - (match_operand:DF 2 "general_operand" "xH,dmF")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[1])) - return \"fpadd%.d %y2,%0\"; - if (rtx_equal_p (operands[0], operands[2])) - return \"fpadd%.d %y1,%0\"; - if (which_alternative == 0) - return \"fpadd3%.d %w2,%w1,%0\"; - return \"fpadd3%.d %x2,%x1,%0\"; -}") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (plus:DF (match_operand:DF 1 "general_operand" "%0") - (match_operand:DF 2 "general_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"f%&add%.x %2,%0\"; - return \"f%&add%.d %f2,%0\"; -}") - -(define_expand "addsf3" - [(set (match_operand:SF 0 "general_operand" "") - (plus:SF (match_operand:SF 1 "general_operand" "") - (match_operand:SF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y") - (plus:SF (match_operand:SF 1 "general_operand" "%xH,y") - (match_operand:SF 2 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[1])) - return \"fpadd%.s %w2,%0\"; - if (rtx_equal_p (operands[0], operands[2])) - return \"fpadd%.s %w1,%0\"; - if (which_alternative == 0) - return \"fpadd3%.s %w2,%w1,%0\"; - return \"fpadd3%.s %2,%1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (plus:SF (match_operand:SF 1 "general_operand" "%0") - (match_operand:SF 2 "general_operand" "fdmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return \"f%$add%.x %2,%0\"; - return \"f%$add%.s %f2,%0\"; -}") - -;; subtract instructions - -(define_insn "subsi3" - [(set (match_operand:SI 0 "general_operand" "=m,r,!a,?d") - (minus:SI (match_operand:SI 1 "general_operand" "0,0,a,mrIKs") - (match_operand:SI 2 "general_operand" "dIKs,mrIKs,J,0")))] - "" - "* -{ - if (! operands_match_p (operands[0], operands[1])) - { - if (operands_match_p (operands[0], operands[2])) - { -#ifndef NO_ADDSUB_Q - if (GET_CODE (operands[1]) == CONST_INT) - { - if (INTVAL (operands[1]) > 0 - && INTVAL (operands[1]) <= 8) - return \"subq%.l %1,%0\;neg%.l %0\"; - } -#endif - return \"sub%.l %1,%0\;neg%.l %0\"; - } - /* This case is matched by J, but negating -0x8000 - in an lea would give an invalid displacement. - So do this specially. */ - if (INTVAL (operands[2]) == -0x8000) - return \"move%.l %1,%0\;sub%.l %2,%0\"; -#ifdef SGS - return \"lea %n2(%1),%0\"; -#else -#ifdef MOTOROLA - return \"lea (%n2,%1),%0\"; -#else /* not MOTOROLA (MIT syntax) */ - return \"lea %1@(%n2),%0\"; -#endif /* not MOTOROLA */ -#endif /* not SGS */ - } - if (GET_CODE (operands[2]) == CONST_INT) - { -#ifndef NO_ADDSUB_Q - if (INTVAL (operands[2]) > 0 - && INTVAL (operands[2]) <= 8) - return \"subq%.l %2,%0\"; - /* Using two subqw for 8 < N <= 16 being subtracted from an - address register is faster on all but 68000 */ - if (INTVAL (operands[2]) > 8 - && INTVAL (operands[2]) <= 16 - && ADDRESS_REG_P (operands[0]) - && TARGET_68020) - { - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 8); - return \"subq%.w %#8,%0\;subq%.w %2,%0\"; - } -#endif - if (ADDRESS_REG_P (operands[0]) - && INTVAL (operands[2]) >= -0x8000 - && INTVAL (operands[2]) < 0x8000) - return \"sub%.w %2,%0\"; - } - return \"sub%.l %2,%0\"; -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=a") - (minus:SI (match_operand:SI 1 "general_operand" "0") - (sign_extend:SI - (match_operand:HI 2 "nonimmediate_operand" "rm"))))] - "" - "sub%.w %2,%0") - -(define_insn "subhi3" - [(set (match_operand:HI 0 "general_operand" "=m,r") - (minus:HI (match_operand:HI 1 "general_operand" "0,0") - (match_operand:HI 2 "general_operand" "dn,rmn")))] - "" - "sub%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (minus:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dn,rmn")))] - "" - "sub%.w %1,%0") - -(define_insn "subqi3" - [(set (match_operand:QI 0 "general_operand" "=m,d") - (minus:QI (match_operand:QI 1 "general_operand" "0,0") - (match_operand:QI 2 "general_operand" "dn,dmn")))] - "" - "sub%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (minus:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dn,dmn")))] - "" - "sub%.b %1,%0") - -(define_expand "subdf3" - [(set (match_operand:DF 0 "general_operand" "") - (minus:DF (match_operand:DF 1 "general_operand" "") - (match_operand:DF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y,y") - (minus:DF (match_operand:DF 1 "general_operand" "xH,y,dmF") - (match_operand:DF 2 "general_operand" "xH,dmF,0")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[2])) - return \"fprsub%.d %y1,%0\"; - if (rtx_equal_p (operands[0], operands[1])) - return \"fpsub%.d %y2,%0\"; - if (which_alternative == 0) - return \"fpsub3%.d %w2,%w1,%0\"; - return \"fpsub3%.d %x2,%x1,%0\"; -}") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (minus:DF (match_operand:DF 1 "general_operand" "0") - (match_operand:DF 2 "general_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"f%&sub%.x %2,%0\"; - return \"f%&sub%.d %f2,%0\"; -}") - -(define_expand "subsf3" - [(set (match_operand:SF 0 "general_operand" "") - (minus:SF (match_operand:SF 1 "general_operand" "") - (match_operand:SF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y,y") - (minus:SF (match_operand:SF 1 "general_operand" "xH,y,rmF") - (match_operand:SF 2 "general_operand" "xH,rmF,0")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[2])) - return \"fprsub%.s %w1,%0\"; - if (rtx_equal_p (operands[0], operands[1])) - return \"fpsub%.s %w2,%0\"; - if (which_alternative == 0) - return \"fpsub3%.s %w2,%w1,%0\"; - return \"fpsub3%.s %2,%1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (minus:SF (match_operand:SF 1 "general_operand" "0") - (match_operand:SF 2 "general_operand" "fdmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return \"f%$sub%.x %2,%0\"; - return \"f%$sub%.s %f2,%0\"; -}") - -;; multiply instructions - -(define_insn "mulhi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (mult:HI (match_operand:HI 1 "general_operand" "%0") - (match_operand:HI 2 "general_operand" "dmn")))] - "" - "* -{ -#if defined(MOTOROLA) && !defined(CRDS) - return \"muls%.w %2,%0\"; -#else - return \"muls %2,%0\"; -#endif -}") - -(define_insn "mulhisi3" - [(set (match_operand:SI 0 "general_operand" "=d") - (mult:SI (sign_extend:SI - (match_operand:HI 1 "nonimmediate_operand" "%0")) - (sign_extend:SI - (match_operand:HI 2 "nonimmediate_operand" "dm"))))] - "" - "* -{ -#if defined(MOTOROLA) && !defined(CRDS) - return \"muls%.w %2,%0\"; -#else - return \"muls %2,%0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=d") - (mult:SI (sign_extend:SI - (match_operand:HI 1 "nonimmediate_operand" "%0")) - (match_operand:SI 2 "const_int_operand" "n")))] - "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff" - "* -{ -#if defined(MOTOROLA) && !defined(CRDS) - return \"muls%.w %2,%0\"; -#else - return \"muls %2,%0\"; -#endif -}") - -(define_insn "mulsi3" - [(set (match_operand:SI 0 "general_operand" "=d") - (mult:SI (match_operand:SI 1 "general_operand" "%0") - (match_operand:SI 2 "general_operand" "dmsK")))] - "TARGET_68020" - "muls%.l %2,%0") - -(define_insn "umulhisi3" - [(set (match_operand:SI 0 "general_operand" "=d") - (mult:SI (zero_extend:SI - (match_operand:HI 1 "nonimmediate_operand" "%0")) - (zero_extend:SI - (match_operand:HI 2 "nonimmediate_operand" "dm"))))] - "" - "* -{ -#if defined(MOTOROLA) && !defined(CRDS) - return \"mulu%.w %2,%0\"; -#else - return \"mulu %2,%0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=d") - (mult:SI (zero_extend:SI - (match_operand:HI 1 "nonimmediate_operand" "%0")) - (match_operand:SI 2 "const_int_operand" "n")))] - "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff" - "* -{ -#if defined(MOTOROLA) && !defined(CRDS) - return \"mulu%.w %2,%0\"; -#else - return \"mulu %2,%0\"; -#endif -}") - -;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the -;; proper matching constraint. This is because the matching is between -;; the high-numbered word of the DImode operand[0] and operand[1]. -(define_expand "umulsidi3" - [(parallel - [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 1) - (mult:SI (match_operand:SI 1 "register_operand" "") - (match_operand:SI 2 "nonimmediate_operand" ""))) - (set (subreg:SI (match_dup 0) 0) - (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1)) - (zero_extend:DI (match_dup 2))) - (const_int 32))))])] - "TARGET_68020" - "") - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (mult:SI (match_operand:SI 1 "register_operand" "%0") - (match_operand:SI 2 "nonimmediate_operand" "dm"))) - (set (match_operand:SI 3 "register_operand" "=d") - (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1)) - (zero_extend:DI (match_dup 2))) - (const_int 32))))] - "TARGET_68020" - "mulu%.l %2,%3:%0") - -; Match immediate case. For 2.4 only match things < 2^31. -; It's tricky with larger values in these patterns since we need to match -; values between the two parallel multiplies, between a CONST_DOUBLE and -; a CONST_INT. -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (mult:SI (match_operand:SI 1 "register_operand" "%0") - (match_operand:SI 2 "const_int_operand" "n"))) - (set (match_operand:SI 3 "register_operand" "=d") - (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1)) - (match_dup 2)) - (const_int 32))))] - "TARGET_68020 - && (unsigned) INTVAL (operands[2]) <= 0x7fffffff" - "mulu%.l %2,%3:%0") - -(define_expand "mulsidi3" - [(parallel - [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 1) - (mult:SI (match_operand:SI 1 "register_operand" "") - (match_operand:SI 2 "nonimmediate_operand" ""))) - (set (subreg:SI (match_dup 0) 0) - (truncate:SI (ashift:DI (mult:DI (sign_extend:DI (match_dup 1)) - (sign_extend:DI (match_dup 2))) - (const_int 32))))])] - "TARGET_68020" - "") - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (mult:SI (match_operand:SI 1 "register_operand" "%0") - (match_operand:SI 2 "nonimmediate_operand" "dm"))) - (set (match_operand:SI 3 "register_operand" "=d") - (truncate:SI (ashift:DI (mult:DI (sign_extend:DI (match_dup 1)) - (sign_extend:DI (match_dup 2))) - (const_int 32))))] - "TARGET_68020" - "muls%.l %2,%3:%0") - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (mult:SI (match_operand:SI 1 "register_operand" "%0") - (match_operand:SI 2 "const_int_operand" "n"))) - (set (match_operand:SI 3 "register_operand" "=d") - (truncate:SI (ashift:DI (mult:DI (sign_extend:DI (match_dup 1)) - (match_dup 2)) - (const_int 32))))] - "TARGET_68020 - /* This test is a noop on 32 bit machines, - but important for a cross-compiler hosted on 64-bit machines. */ - && INTVAL (operands[2]) <= 0x7fffffff - && INTVAL (operands[2]) >= -0x80000000" - "muls%.l %2,%3:%0") - -(define_expand "muldf3" - [(set (match_operand:DF 0 "general_operand" "") - (mult:DF (match_operand:DF 1 "general_operand" "") - (match_operand:DF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y") - (mult:DF (match_operand:DF 1 "general_operand" "%xH,y") - (match_operand:DF 2 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[1], operands[2])) - return \"fpsqr%.d %y1,%0\"; - if (rtx_equal_p (operands[0], operands[1])) - return \"fpmul%.d %y2,%0\"; - if (rtx_equal_p (operands[0], operands[2])) - return \"fpmul%.d %y1,%0\"; - if (which_alternative == 0) - return \"fpmul3%.d %w2,%w1,%0\"; - return \"fpmul3%.d %x2,%x1,%0\"; -}") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (mult:DF (match_operand:DF 1 "general_operand" "%0") - (match_operand:DF 2 "general_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (GET_CODE (operands[2]) == CONST_DOUBLE - && floating_exact_log2 (operands[2]) && !TARGET_68040) - { - int i = floating_exact_log2 (operands[2]); - operands[2] = gen_rtx (CONST_INT, VOIDmode, i); - return \"fscale%.l %2,%0\"; - } - if (REG_P (operands[2])) - return \"f%&mul%.x %2,%0\"; - return \"f%&mul%.d %f2,%0\"; -}") - -(define_expand "mulsf3" - [(set (match_operand:SF 0 "general_operand" "") - (mult:SF (match_operand:SF 1 "general_operand" "") - (match_operand:SF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y") - (mult:SF (match_operand:SF 1 "general_operand" "%xH,y") - (match_operand:SF 2 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[1], operands[2])) - return \"fpsqr%.s %w1,%0\"; - if (rtx_equal_p (operands[0], operands[1])) - return \"fpmul%.s %w2,%0\"; - if (rtx_equal_p (operands[0], operands[2])) - return \"fpmul%.s %w1,%0\"; - if (which_alternative == 0) - return \"fpmul3%.s %w2,%w1,%0\"; - return \"fpmul3%.s %2,%1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (mult:SF (match_operand:SF 1 "general_operand" "%0") - (match_operand:SF 2 "general_operand" "fdmF")))] - "TARGET_68881" - "* -{ -#ifdef FSGLMUL_USE_S - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? \"fsmul%.s %2,%0\" - : \"fsglmul%.s %2,%0\"); -#else - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? \"fsmul%.x %2,%0\" - : \"fsglmul%.x %2,%0\"); -#endif - return (TARGET_68040_ONLY - ? \"fsmul%.s %f2,%0\" - : \"fsglmul%.s %f2,%0\"); -}") - -;; divide instructions - -(define_insn "divhi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (div:HI (match_operand:HI 1 "general_operand" "0") - (match_operand:HI 2 "general_operand" "dmn")))] - "" - "* -{ -#ifdef MOTOROLA - return \"ext%.l %0\;divs%.w %2,%0\"; -#else - return \"extl %0\;divs %2,%0\"; -#endif -}") - -(define_insn "divhisi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI - (div:SI - (match_operand:SI 1 "general_operand" "0") - (sign_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))] - "" - "* -{ -#ifdef MOTOROLA - return \"divs%.w %2,%0\"; -#else - return \"divs %2,%0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI (div:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "const_int_operand" "n"))))] - "" - "* -{ -#ifdef MOTOROLA - return \"divs%.w %2,%0\"; -#else - return \"divs %2,%0\"; -#endif -}") - -(define_insn "udivhi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (udiv:HI (match_operand:HI 1 "general_operand" "0") - (match_operand:HI 2 "general_operand" "dmn")))] - "" - "* -{ -#ifdef MOTOROLA - return \"and%.l %#0xFFFF,%0\;divu%.w %2,%0\"; -#else - return \"andl %#0xFFFF,%0\;divu %2,%0\"; -#endif -}") - -(define_insn "udivhisi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI - (udiv:SI - (match_operand:SI 1 "general_operand" "0") - (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))] - "" - "* -{ -#ifdef MOTOROLA - return \"divu%.w %2,%0\"; -#else - return \"divu %2,%0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI (udiv:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "const_int_operand" "n"))))] - "" - "* -{ -#ifdef MOTOROLA - return \"divu%.w %2,%0\"; -#else - return \"divu %2,%0\"; -#endif -}") - -(define_expand "divdf3" - [(set (match_operand:DF 0 "general_operand" "") - (div:DF (match_operand:DF 1 "general_operand" "") - (match_operand:DF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y,y") - (div:DF (match_operand:DF 1 "general_operand" "xH,y,rmF") - (match_operand:DF 2 "general_operand" "xH,rmF,0")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[2])) - return \"fprdiv%.d %y1,%0\"; - if (rtx_equal_p (operands[0], operands[1])) - return \"fpdiv%.d %y2,%0\"; - if (which_alternative == 0) - return \"fpdiv3%.d %w2,%w1,%0\"; - return \"fpdiv3%.d %x2,%x1,%x0\"; -}") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (div:DF (match_operand:DF 1 "general_operand" "0") - (match_operand:DF 2 "general_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"f%&div%.x %2,%0\"; - return \"f%&div%.d %f2,%0\"; -}") - -(define_expand "divsf3" - [(set (match_operand:SF 0 "general_operand" "") - (div:SF (match_operand:SF 1 "general_operand" "") - (match_operand:SF 2 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y,y") - (div:SF (match_operand:SF 1 "general_operand" "xH,y,rmF") - (match_operand:SF 2 "general_operand" "xH,rmF,0")))] - "TARGET_FPA" - "* -{ - if (rtx_equal_p (operands[0], operands[1])) - return \"fpdiv%.s %w2,%0\"; - if (rtx_equal_p (operands[0], operands[2])) - return \"fprdiv%.s %w1,%0\"; - if (which_alternative == 0) - return \"fpdiv3%.s %w2,%w1,%0\"; - return \"fpdiv3%.s %2,%1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (div:SF (match_operand:SF 1 "general_operand" "0") - (match_operand:SF 2 "general_operand" "fdmF")))] - "TARGET_68881" - "* -{ -#ifdef FSGLDIV_USE_S - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? \"fsdiv%.s %2,%0\" - : \"fsgldiv%.s %2,%0\"); -#else - if (REG_P (operands[2]) && ! DATA_REG_P (operands[2])) - return (TARGET_68040_ONLY - ? \"fsdiv%.x %2,%0\" - : \"fsgldiv%.x %2,%0\"); -#endif - return (TARGET_68040_ONLY - ? \"fsdiv%.s %f2,%0\" - : \"fsgldiv%.s %f2,%0\"); -}") - -;; Remainder instructions. - -(define_insn "modhi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (mod:HI (match_operand:HI 1 "general_operand" "0") - (match_operand:HI 2 "general_operand" "dmn")))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"ext%.l %0\;divs%.w %2,%0\;swap %0\"; -#else - return \"extl %0\;divs %2,%0\;swap %0\"; -#endif -}") - -(define_insn "modhisi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI - (mod:SI - (match_operand:SI 1 "general_operand" "0") - (sign_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"divs%.w %2,%0\;swap %0\"; -#else - return \"divs %2,%0\;swap %0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI (mod:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "const_int_operand" "n"))))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"divs%.w %2,%0\;swap %0\"; -#else - return \"divs %2,%0\;swap %0\"; -#endif -}") - -(define_insn "umodhi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (umod:HI (match_operand:HI 1 "general_operand" "0") - (match_operand:HI 2 "general_operand" "dmn")))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"and%.l %#0xFFFF,%0\;divu%.w %2,%0\;swap %0\"; -#else - return \"andl %#0xFFFF,%0\;divu %2,%0\;swap %0\"; -#endif -}") - -(define_insn "umodhisi3" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI - (umod:SI - (match_operand:SI 1 "general_operand" "0") - (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "dm")))))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"divu%.w %2,%0\;swap %0\"; -#else - return \"divu %2,%0\;swap %0\"; -#endif -}") - -(define_insn "" - [(set (match_operand:HI 0 "general_operand" "=d") - (truncate:HI (umod:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "const_int_operand" "n"))))] - "" - "* -{ - /* The swap insn produces cc's that don't correspond to the result. */ - CC_STATUS_INIT; -#ifdef MOTOROLA - return \"divu%.w %2,%0\;swap %0\"; -#else - return \"divu %2,%0\;swap %0\"; -#endif -}") - -(define_insn "divmodsi4" - [(set (match_operand:SI 0 "general_operand" "=d") - (div:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "general_operand" "dmsK"))) - (set (match_operand:SI 3 "general_operand" "=d") - (mod:SI (match_dup 1) (match_dup 2)))] - "TARGET_68020" - "* -{ - if (find_reg_note (insn, REG_UNUSED, operands[3])) - return \"divs%.l %2,%0\"; - else - return \"divsl%.l %2,%3:%0\"; -}") - -(define_insn "udivmodsi4" - [(set (match_operand:SI 0 "general_operand" "=d") - (udiv:SI (match_operand:SI 1 "general_operand" "0") - (match_operand:SI 2 "general_operand" "dmsK"))) - (set (match_operand:SI 3 "general_operand" "=d") - (umod:SI (match_dup 1) (match_dup 2)))] - "TARGET_68020" - "* -{ - if (find_reg_note (insn, REG_UNUSED, operands[3])) - return \"divu%.l %2,%0\"; - else - return \"divul%.l %2,%3:%0\"; -}") - -;; logical-and instructions - -;; Prevent AND from being made with sp. This doesn't exist in the machine -;; and reload will cause inefficient code. Since sp is a FIXED_REG, we -;; can't allocate pseudos into it. -(define_insn "andsi3" - [(set (match_operand:SI 0 "not_sp_operand" "=m,d") - (and:SI (match_operand:SI 1 "general_operand" "%0,0") - (match_operand:SI 2 "general_operand" "dKs,dmKs")))] - "" - "* -{ - int logval; - if (GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) | 0xffff) == 0xffffffff - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (GET_CODE (operands[0]) != REG) - operands[0] = adj_offsettable_operand (operands[0], 2); - operands[2] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (operands[2]) & 0xffff); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - if (operands[2] == const0_rtx) - return \"clr%.w %0\"; - return \"and%.w %2,%0\"; - } - if (GET_CODE (operands[2]) == CONST_INT - && (logval = exact_log2 (~ INTVAL (operands[2]))) >= 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval); - } - else - { - operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8)); operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8); - } - /* This does not set condition codes in a standard way. */ - CC_STATUS_INIT; - return \"bclr %1,%0\"; - } - return \"and%.l %2,%0\"; -}") - -(define_insn "andhi3" - [(set (match_operand:HI 0 "general_operand" "=m,d") - (and:HI (match_operand:HI 1 "general_operand" "%0,0") - (match_operand:HI 2 "general_operand" "dn,dmn")))] - "" - "and%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (and:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dn,dmn")))] - "" - "and%.w %1,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (and:HI (match_operand:HI 1 "general_operand" "dn,dmn") - (match_dup 0)))] - "" - "and%.w %1,%0") - -(define_insn "andqi3" - [(set (match_operand:QI 0 "general_operand" "=m,d") - (and:QI (match_operand:QI 1 "general_operand" "%0,0") - (match_operand:QI 2 "general_operand" "dn,dmn")))] - "" - "and%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (and:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dn,dmn")))] - "" - "and%.b %1,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (and:QI (match_operand:QI 1 "general_operand" "dn,dmn") - (match_dup 0)))] - "" - "and%.b %1,%0") - -;; inclusive-or instructions - -(define_insn "iorsi3" - [(set (match_operand:SI 0 "general_operand" "=m,d") - (ior:SI (match_operand:SI 1 "general_operand" "%0,0") - (match_operand:SI 2 "general_operand" "dKs,dmKs")))] - "" - "* -{ - register int logval; - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) >> 16 == 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (GET_CODE (operands[0]) != REG) - operands[0] = adj_offsettable_operand (operands[0], 2); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - return \"or%.w %2,%0\"; - } - if (GET_CODE (operands[2]) == CONST_INT - && (logval = exact_log2 (INTVAL (operands[2]))) >= 0 - && (DATA_REG_P (operands[0]) - || offsettable_memref_p (operands[0]))) - { - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval); - } - else - { - operands[0] = adj_offsettable_operand (operands[0], 3 - (logval / 8)); - operands[1] = gen_rtx (CONST_INT, VOIDmode, logval % 8); - } - CC_STATUS_INIT; - return \"bset %1,%0\"; - } - return \"or%.l %2,%0\"; -}") - -(define_insn "iorhi3" - [(set (match_operand:HI 0 "general_operand" "=m,d") - (ior:HI (match_operand:HI 1 "general_operand" "%0,0") - (match_operand:HI 2 "general_operand" "dn,dmn")))] - "" - "or%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (ior:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dn,dmn")))] - "" - "or%.w %1,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+m,d")) - (ior:HI (match_operand:HI 1 "general_operand" "dn,dmn") - (match_dup 0)))] - "" - "or%.w %1,%0") - -(define_insn "iorqi3" - [(set (match_operand:QI 0 "general_operand" "=m,d") - (ior:QI (match_operand:QI 1 "general_operand" "%0,0") - (match_operand:QI 2 "general_operand" "dn,dmn")))] - "" - "or%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (ior:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dn,dmn")))] - "" - "or%.b %1,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+m,d")) - (ior:QI (match_operand:QI 1 "general_operand" "dn,dmn") - (match_dup 0)))] - "" - "or%.b %1,%0") - -;; xor instructions - -(define_insn "xorsi3" - [(set (match_operand:SI 0 "general_operand" "=do,m") - (xor:SI (match_operand:SI 1 "general_operand" "%0,0") - (match_operand:SI 2 "general_operand" "di,dKs")))] - "" - "* -{ - if (GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) >> 16 == 0 - && (offsettable_memref_p (operands[0]) || DATA_REG_P (operands[0]))) - { - if (! DATA_REG_P (operands[0])) - operands[0] = adj_offsettable_operand (operands[0], 2); - /* Do not delete a following tstl %0 insn; that would be incorrect. */ - CC_STATUS_INIT; - return \"eor%.w %2,%0\"; - } - return \"eor%.l %2,%0\"; -}") - -(define_insn "xorhi3" - [(set (match_operand:HI 0 "general_operand" "=dm") - (xor:HI (match_operand:HI 1 "general_operand" "%0") - (match_operand:HI 2 "general_operand" "dn")))] - "" - "eor%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm")) - (xor:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dn")))] - "" - "eor%.w %1,%0") - - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm")) - (xor:HI (match_operand:HI 1 "general_operand" "dn") - (match_dup 0)))] - "" - "eor%.w %1,%0") - -(define_insn "xorqi3" - [(set (match_operand:QI 0 "general_operand" "=dm") - (xor:QI (match_operand:QI 1 "general_operand" "%0") - (match_operand:QI 2 "general_operand" "dn")))] - "" - "eor%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm")) - (xor:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dn")))] - "" - "eor%.b %1,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm")) - (xor:QI (match_operand:QI 1 "general_operand" "dn") - (match_dup 0)))] - "" - "eor%.b %1,%0") - -;; negation instructions - -(define_insn "negsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (neg:SI (match_operand:SI 1 "general_operand" "0")))] - "" - "neg%.l %0") - -(define_insn "neghi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (neg:HI (match_operand:HI 1 "general_operand" "0")))] - "" - "neg%.w %0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm")) - (neg:HI (match_dup 0)))] - "" - "neg%.w %0") - -(define_insn "negqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (neg:QI (match_operand:QI 1 "general_operand" "0")))] - "" - "neg%.b %0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm")) - (neg:QI (match_dup 0)))] - "" - "neg%.b %0") - -(define_expand "negsf2" - [(set (match_operand:SF 0 "general_operand" "") - (neg:SF (match_operand:SF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y") - (neg:SF (match_operand:SF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpneg%.s %w1,%0") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f,d") - (neg:SF (match_operand:SF 1 "general_operand" "fdmF,0")))] - "TARGET_68881" - "* -{ - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, 31); - return \"bchg %1,%0\"; - } - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"f%$neg%.x %1,%0\"; - return \"f%$neg%.s %f1,%0\"; -}") - -(define_expand "negdf2" - [(set (match_operand:DF 0 "general_operand" "") - (neg:DF (match_operand:DF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y") - (neg:DF (match_operand:DF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpneg%.d %y1, %0") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f,d") - (neg:DF (match_operand:DF 1 "general_operand" "fmF,0")))] - "TARGET_68881" - "* -{ - if (DATA_REG_P (operands[0])) - { - operands[1] = gen_rtx (CONST_INT, VOIDmode, 31); - return \"bchg %1,%0\"; - } - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"f%&neg%.x %1,%0\"; - return \"f%&neg%.d %f1,%0\"; -}") - -;; Sqrt instruction for the 68881 - -(define_insn "sqrtdf2" - [(set (match_operand:DF 0 "general_operand" "=f") - (sqrt:DF (match_operand:DF 1 "general_operand" "fm")))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[1])) - return \"fsqrt%.x %1,%0\"; - else - return \"fsqrt%.d %1,%0\"; -}") - -;; Absolute value instructions - -(define_expand "abssf2" - [(set (match_operand:SF 0 "general_operand" "") - (abs:SF (match_operand:SF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=x,y") - (abs:SF (match_operand:SF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpabs%.s %y1,%0") - -(define_insn "" - [(set (match_operand:SF 0 "general_operand" "=f") - (abs:SF (match_operand:SF 1 "general_operand" "fdmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"f%$abs%.x %1,%0\"; - return \"f%$abs%.s %f1,%0\"; -}") - -(define_expand "absdf2" - [(set (match_operand:DF 0 "general_operand" "") - (abs:DF (match_operand:DF 1 "general_operand" "")))] - "TARGET_68881 || TARGET_FPA" - "") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=x,y") - (abs:DF (match_operand:DF 1 "general_operand" "xH,rmF")))] - "TARGET_FPA" - "fpabs%.d %y1,%0") - -(define_insn "" - [(set (match_operand:DF 0 "general_operand" "=f") - (abs:DF (match_operand:DF 1 "general_operand" "fmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"f%&abs%.x %1,%0\"; - return \"f%&abs%.d %f1,%0\"; -}") - -;; one complement instructions - -(define_insn "one_cmplsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (not:SI (match_operand:SI 1 "general_operand" "0")))] - "" - "not%.l %0") - -(define_insn "one_cmplhi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (not:HI (match_operand:HI 1 "general_operand" "0")))] - "" - "not%.w %0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm")) - (not:HI (match_dup 0)))] - "" - "not%.w %0") - -(define_insn "one_cmplqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (not:QI (match_operand:QI 1 "general_operand" "0")))] - "" - "not%.b %0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "general_operand" "+dm")) - (not:QI (match_dup 0)))] - "" - "not%.b %0") - -;; arithmetic shift instructions -;; We don't need the shift memory by 1 bit instruction - -;; On all 68k models, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)" - "* -{ - CC_STATUS_INIT; - return \"swap %0\;clr%.w %0\"; -}") - -;; On the 68000, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)" - "* -{ - CC_STATUS_INIT; - - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return \"asl%.w %2,%0\;swap %0\;clr%.w %0\"; -}") - -(define_insn "ashlsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "* -{ - if (operands[2] == const1_rtx) - return \"add%.l %0,%0\"; - return \"asl%.l %2,%0\"; -}") - -(define_insn "ashlhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (ashift:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "asl%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (ashift:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "asl%.w %1,%0") - -(define_insn "ashlqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (ashift:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "asl%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (ashift:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "asl%.b %1,%0") - -;; On all 68k models, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)" - "swap %0\;ext%.l %0") - -;; On the 68000, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)" - "* -{ - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return \"swap %0\;asr%.w %2,%0\;ext%.l %0\"; -}") - -(define_insn "ashrsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (ashiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "* -{ - return \"asr%.l %2,%0\"; -}") - -(define_insn "ashrhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (ashiftrt:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "asr%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (ashiftrt:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "asr%.w %1,%0") - -(define_insn "ashrqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (ashiftrt:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "asr%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (ashiftrt:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "asr%.b %1,%0") - -;; logical shift instructions - -;; On all 68k models, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)" - "* -{ - CC_STATUS_INIT; - return \"swap %0\;clr%.w %0\"; -}") - -;; On the 68000, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)" - "* -{ - CC_STATUS_INIT; - - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return \"lsl%.w %2,%0\;swap %0\;clr%.w %0\"; -}") - -(define_insn "lshlsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshift:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "* -{ - if (operands[2] == const1_rtx) - return \"add%.l %0,%0\"; - return \"lsl%.l %2,%0\"; -}") - -(define_insn "lshlhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (lshift:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "lsl%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (lshift:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "lsl%.w %1,%0") - -(define_insn "lshlqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (lshift:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "lsl%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (lshift:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "lsl%.b %1,%0") - -;; On all 68k models, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)" - "* -{ - CC_STATUS_INIT; - return \"clr%.w %0\;swap %0\"; -}") - -;; On the 68000, this makes faster code in a special case. - -(define_insn "" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "immediate_operand" "i")))] - "(! TARGET_68020 && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)" - "* -{ - /* I think lsr%.w sets the CC properly. */ - operands[2] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) - 16); - return \"clr%.w %0\;swap %0\;lsr%.w %2,%0\"; -}") - -(define_insn "lshrsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (lshiftrt:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "* -{ - return \"lsr%.l %2,%0\"; -}") - -(define_insn "lshrhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (lshiftrt:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "lsr%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (lshiftrt:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "lsr%.w %1,%0") - -(define_insn "lshrqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (lshiftrt:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "lsr%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (lshiftrt:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "lsr%.b %1,%0") - -;; rotate instructions - -(define_insn "rotlsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (rotate:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "rol%.l %2,%0") - -(define_insn "rotlhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (rotate:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "rol%.w %2,%0") - - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (rotate:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "rol%.w %1,%0") - -(define_insn "rotlqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (rotate:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "rol%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (rotate:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "rol%.b %1,%0") - -(define_insn "rotrsi3" - [(set (match_operand:SI 0 "register_operand" "=d") - (rotatert:SI (match_operand:SI 1 "register_operand" "0") - (match_operand:SI 2 "general_operand" "dI")))] - "" - "ror%.l %2,%0") - -(define_insn "rotrhi3" - [(set (match_operand:HI 0 "register_operand" "=d") - (rotatert:HI (match_operand:HI 1 "register_operand" "0") - (match_operand:HI 2 "general_operand" "dI")))] - "" - "ror%.w %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d")) - (rotatert:HI (match_dup 0) - (match_operand:HI 1 "general_operand" "dI")))] - "" - "ror%.w %1,%0") - -(define_insn "rotrqi3" - [(set (match_operand:QI 0 "register_operand" "=d") - (rotatert:QI (match_operand:QI 1 "register_operand" "0") - (match_operand:QI 2 "general_operand" "dI")))] - "" - "ror%.b %2,%0") - -(define_insn "" - [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d")) - (rotatert:QI (match_dup 0) - (match_operand:QI 1 "general_operand" "dI")))] - "" - "ror%.b %1,%0") - -;; Special cases of bit-field insns which we should -;; recognize in preference to the general case. -;; These handle aligned 8-bit and 16-bit fields, -;; which can usually be done with move instructions. - -; -; Special case for 32-bit field in memory. This only occurs when 32-bit -; alignment of structure members is specified. -; -; The move is allowed to be odd byte aligned, because that's still faster -; than an odd byte aligned bit field instruction. -; -(define_insn "" - [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o") - (match_operand:SI 1 "immediate_operand" "i") - (match_operand:SI 2 "immediate_operand" "i")) - (match_operand:SI 3 "general_operand" "rmi"))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT - && (INTVAL (operands[1]) == 32) - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[0], 0))" - "* -{ - operands[0] - = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8); - - return \"move%.l %3,%0\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+do") - (match_operand:SI 1 "immediate_operand" "i") - (match_operand:SI 2 "immediate_operand" "i")) - (match_operand:SI 3 "general_operand" "d"))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT - && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16) - && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[2]) % INTVAL (operands[1]) == 0 - && (GET_CODE (operands[0]) == REG - || ! mode_dependent_address_p (XEXP (operands[0], 0)))" - "* -{ - if (REG_P (operands[0])) - { - if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32) - return \"bfins %3,%0{%b2:%b1}\"; - } - else - operands[0] - = adj_offsettable_operand (operands[0], INTVAL (operands[2]) / 8); - - if (GET_CODE (operands[3]) == MEM) - operands[3] = adj_offsettable_operand (operands[3], - (32 - INTVAL (operands[1])) / 8); - if (INTVAL (operands[1]) == 8) - return \"move%.b %3,%0\"; - return \"move%.w %3,%0\"; -}") - - -; -; Special case for 32-bit field in memory. This only occurs when 32-bit -; alignment of structure members is specified. -; -; The move is allowed to be odd byte aligned, because that's still faster -; than an odd byte aligned bit field instruction. -; -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=rm") - (zero_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o") - (match_operand:SI 2 "immediate_operand" "i") - (match_operand:SI 3 "immediate_operand" "i")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 32) - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[1], 0))" - "* -{ - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - return \"move%.l %1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=&d") - (zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do") - (match_operand:SI 2 "immediate_operand" "i") - (match_operand:SI 3 "immediate_operand" "i")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16) - && GET_CODE (operands[3]) == CONST_INT - && INTVAL (operands[3]) % INTVAL (operands[2]) == 0 - && (GET_CODE (operands[1]) == REG - || ! mode_dependent_address_p (XEXP (operands[1], 0)))" - "* -{ - cc_status.flags |= CC_NOT_NEGATIVE; - if (REG_P (operands[1])) - { - if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32) - return \"bfextu %1{%b3:%b2},%0\"; - } - else - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - output_asm_insn (\"clr%.l %0\", operands); - if (GET_CODE (operands[0]) == MEM) - operands[0] = adj_offsettable_operand (operands[0], - (32 - INTVAL (operands[1])) / 8); - if (INTVAL (operands[2]) == 8) - return \"move%.b %1,%0\"; - return \"move%.w %1,%0\"; -}") - -; -; Special case for 32-bit field in memory. This only occurs when 32-bit -; alignment of structure members is specified. -; -; The move is allowed to be odd byte aligned, because that's still faster -; than an odd byte aligned bit field instruction. -; -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=rm") - (sign_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o") - (match_operand:SI 2 "immediate_operand" "i") - (match_operand:SI 3 "immediate_operand" "i")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 32) - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) % 8) == 0 - && ! mode_dependent_address_p (XEXP (operands[1], 0))" - "* -{ - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - return \"move%.l %1,%0\"; -}") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=d") - (sign_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do") - (match_operand:SI 2 "immediate_operand" "i") - (match_operand:SI 3 "immediate_operand" "i")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[2]) == CONST_INT - && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16) - && GET_CODE (operands[3]) == CONST_INT - && INTVAL (operands[3]) % INTVAL (operands[2]) == 0 - && (GET_CODE (operands[1]) == REG - || ! mode_dependent_address_p (XEXP (operands[1], 0)))" - "* -{ - if (REG_P (operands[1])) - { - if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32) - return \"bfexts %1{%b3:%b2},%0\"; - } - else - operands[1] - = adj_offsettable_operand (operands[1], INTVAL (operands[3]) / 8); - - if (INTVAL (operands[2]) == 8) - return \"move%.b %1,%0\;extb%.l %0\"; - return \"move%.w %1,%0\;ext%.l %0\"; -}") - -;; Bit field instructions, general cases. -;; "o,d" constraint causes a nonoffsettable memref to match the "o" -;; so that its address is reloaded. - -(define_insn "extv" - [(set (match_operand:SI 0 "general_operand" "=d,d") - (sign_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o,d") - (match_operand:SI 2 "general_operand" "di,di") - (match_operand:SI 3 "general_operand" "di,di")))] - "TARGET_68020 && TARGET_BITFIELD" - "bfexts %1{%b3:%b2},%0") - -(define_insn "extzv" - [(set (match_operand:SI 0 "general_operand" "=d,d") - (zero_extract:SI (match_operand:QI 1 "nonimmediate_operand" "o,d") - (match_operand:SI 2 "general_operand" "di,di") - (match_operand:SI 3 "general_operand" "di,di")))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - cc_status.flags |= CC_NOT_NEGATIVE; - return \"bfextu %1{%b3:%b2},%0\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d") - (match_operand:SI 1 "general_operand" "di,di") - (match_operand:SI 2 "general_operand" "di,di")) - (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2)) - (match_operand 3 "immediate_operand" "i,i")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[3]) == CONST_INT - && (INTVAL (operands[3]) == -1 - || (GET_CODE (operands[1]) == CONST_INT - && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))" - "* -{ - CC_STATUS_INIT; - return \"bfchg %0{%b2:%b1}\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d") - (match_operand:SI 1 "general_operand" "di,di") - (match_operand:SI 2 "general_operand" "di,di")) - (const_int 0))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - CC_STATUS_INIT; - return \"bfclr %0{%b2:%b1}\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d") - (match_operand:SI 1 "general_operand" "di,di") - (match_operand:SI 2 "general_operand" "di,di")) - (const_int -1))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - CC_STATUS_INIT; - return \"bfset %0{%b2:%b1}\"; -}") - -(define_insn "insv" - [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d") - (match_operand:SI 1 "general_operand" "di,di") - (match_operand:SI 2 "general_operand" "di,di")) - (match_operand:SI 3 "general_operand" "d,d"))] - "TARGET_68020 && TARGET_BITFIELD" - "bfins %3,%0{%b2:%b1}") - -;; Now recognize bit field insns that operate on registers -;; (or at least were intended to do so). - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=d") - (sign_extract:SI (match_operand:SI 1 "nonimmediate_operand" "d") - (match_operand:SI 2 "general_operand" "di") - (match_operand:SI 3 "general_operand" "di")))] - "TARGET_68020 && TARGET_BITFIELD" - "bfexts %1{%b3:%b2},%0") - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=d") - (zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "d") - (match_operand:SI 2 "general_operand" "di") - (match_operand:SI 3 "general_operand" "di")))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - cc_status.flags |= CC_NOT_NEGATIVE; - return \"bfextu %1{%b3:%b2},%0\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d") - (match_operand:SI 1 "general_operand" "di") - (match_operand:SI 2 "general_operand" "di")) - (const_int 0))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - CC_STATUS_INIT; - return \"bfclr %0{%b2:%b1}\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d") - (match_operand:SI 1 "general_operand" "di") - (match_operand:SI 2 "general_operand" "di")) - (const_int -1))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ - CC_STATUS_INIT; - return \"bfset %0{%b2:%b1}\"; -}") - -(define_insn "" - [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d") - (match_operand:SI 1 "general_operand" "di") - (match_operand:SI 2 "general_operand" "di")) - (match_operand:SI 3 "general_operand" "d"))] - "TARGET_68020 && TARGET_BITFIELD" - "* -{ -#if 0 - /* These special cases are now recognized by a specific pattern. */ - if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16) - return \"move%.w %3,%0\"; - if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT - && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8) - return \"move%.b %3,%0\"; -#endif - return \"bfins %3,%0{%b2:%b1}\"; -}") - -;; Special patterns for optimizing bit-field instructions. - -(define_insn "" - [(set (cc0) - (zero_extract:SI (match_operand:QI 0 "memory_operand" "o") - (match_operand:SI 1 "general_operand" "di") - (match_operand:SI 2 "general_operand" "di")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT" - "* -{ - if (operands[1] == const1_rtx - && GET_CODE (operands[2]) == CONST_INT) - { - int width = GET_CODE (operands[0]) == REG ? 31 : 7; - return output_btst (operands, - gen_rtx (CONST_INT, VOIDmode, - width - INTVAL (operands[2])), - operands[0], - insn, 1000); - /* Pass 1000 as SIGNPOS argument so that btst will - not think we are testing the sign bit for an `and' - and assume that nonzero implies a negative result. */ - } - if (INTVAL (operands[1]) != 32) - cc_status.flags = CC_NOT_NEGATIVE; - return \"bftst %0{%b2:%b1}\"; -}") - - -;;; now handle the register cases -(define_insn "" - [(set (cc0) - (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "d") - (match_operand:SI 1 "general_operand" "di") - (match_operand:SI 2 "general_operand" "di")))] - "TARGET_68020 && TARGET_BITFIELD - && GET_CODE (operands[1]) == CONST_INT" - "* -{ - if (operands[1] == const1_rtx - && GET_CODE (operands[2]) == CONST_INT) - { - int width = GET_CODE (operands[0]) == REG ? 31 : 7; - return output_btst (operands, - gen_rtx (CONST_INT, VOIDmode, - width - INTVAL (operands[2])), - operands[0], - insn, 1000); - /* Pass 1000 as SIGNPOS argument so that btst will - not think we are testing the sign bit for an `and' - and assume that nonzero implies a negative result. */ - } - if (INTVAL (operands[1]) != 32) - cc_status.flags = CC_NOT_NEGATIVE; - return \"bftst %0{%b2:%b1}\"; -}") - -(define_insn "seq" - [(set (match_operand:QI 0 "general_operand" "=d") - (eq:QI (cc0) (const_int 0)))] - "" - "* - cc_status = cc_prev_status; - OUTPUT_JUMP (\"seq %0\", \"fseq %0\", \"seq %0\"); -") - -(define_insn "sne" - [(set (match_operand:QI 0 "general_operand" "=d") - (ne:QI (cc0) (const_int 0)))] - "" - "* - cc_status = cc_prev_status; - OUTPUT_JUMP (\"sne %0\", \"fsne %0\", \"sne %0\"); -") - -(define_insn "sgt" - [(set (match_operand:QI 0 "general_operand" "=d") - (gt:QI (cc0) (const_int 0)))] - "" - "* - cc_status = cc_prev_status; - OUTPUT_JUMP (\"sgt %0\", \"fsgt %0\", 0); -") - -(define_insn "sgtu" - [(set (match_operand:QI 0 "general_operand" "=d") - (gtu:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - return \"shi %0\"; ") - -(define_insn "slt" - [(set (match_operand:QI 0 "general_operand" "=d") - (lt:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - OUTPUT_JUMP (\"slt %0\", \"fslt %0\", \"smi %0\"); ") - -(define_insn "sltu" - [(set (match_operand:QI 0 "general_operand" "=d") - (ltu:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - return \"scs %0\"; ") - -(define_insn "sge" - [(set (match_operand:QI 0 "general_operand" "=d") - (ge:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - OUTPUT_JUMP (\"sge %0\", \"fsge %0\", \"spl %0\"); ") - -(define_insn "sgeu" - [(set (match_operand:QI 0 "general_operand" "=d") - (geu:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - return \"scc %0\"; ") - -(define_insn "sle" - [(set (match_operand:QI 0 "general_operand" "=d") - (le:QI (cc0) (const_int 0)))] - "" - "* - cc_status = cc_prev_status; - OUTPUT_JUMP (\"sle %0\", \"fsle %0\", 0); -") - -(define_insn "sleu" - [(set (match_operand:QI 0 "general_operand" "=d") - (leu:QI (cc0) (const_int 0)))] - "" - "* cc_status = cc_prev_status; - return \"sls %0\"; ") - -;; Basic conditional jump instructions. - -(define_insn "beq" - [(set (pc) - (if_then_else (eq (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -{ -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbeq %l0\", \"fbeq %l0\", \"jbeq %l0\"); -#else - OUTPUT_JUMP (\"jeq %l0\", \"fjeq %l0\", \"jeq %l0\"); -#endif -}") - -(define_insn "bne" - [(set (pc) - (if_then_else (ne (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -{ -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbne %l0\", \"fbne %l0\", \"jbne %l0\"); -#else - OUTPUT_JUMP (\"jne %l0\", \"fjne %l0\", \"jne %l0\"); -#endif -}") - -(define_insn "bgt" - [(set (pc) - (if_then_else (gt (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbgt %l0\", \"fbgt %l0\", 0); -#else - OUTPUT_JUMP (\"jgt %l0\", \"fjgt %l0\", 0); -#endif -") - -(define_insn "bgtu" - [(set (pc) - (if_then_else (gtu (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - return \"jbhi %l0\"; -#else - return \"jhi %l0\"; -#endif -") - -(define_insn "blt" - [(set (pc) - (if_then_else (lt (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jblt %l0\", \"fblt %l0\", \"jbmi %l0\"); -#else - OUTPUT_JUMP (\"jlt %l0\", \"fjlt %l0\", \"jmi %l0\"); -#endif -") - -(define_insn "bltu" - [(set (pc) - (if_then_else (ltu (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - return \"jbcs %l0\"; -#else - return \"jcs %l0\"; -#endif -") - -(define_insn "bge" - [(set (pc) - (if_then_else (ge (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbge %l0\", \"fbge %l0\", \"jbpl %l0\"); -#else - OUTPUT_JUMP (\"jge %l0\", \"fjge %l0\", \"jpl %l0\"); -#endif -") - -(define_insn "bgeu" - [(set (pc) - (if_then_else (geu (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - return \"jbcc %l0\"; -#else - return \"jcc %l0\"; -#endif -") - -(define_insn "ble" - [(set (pc) - (if_then_else (le (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jble %l0\", \"fble %l0\", 0); -#else - OUTPUT_JUMP (\"jle %l0\", \"fjle %l0\", 0); -#endif -") - -(define_insn "bleu" - [(set (pc) - (if_then_else (leu (cc0) - (const_int 0)) - (label_ref (match_operand 0 "" "")) - (pc)))] - "" - "* -#ifdef MOTOROLA - return \"jbls %l0\"; -#else - return \"jls %l0\"; -#endif -") - -;; Negated conditional jump instructions. - -(define_insn "" - [(set (pc) - (if_then_else (eq (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -{ -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbne %l0\", \"fbne %l0\", \"jbne %l0\"); -#else - OUTPUT_JUMP (\"jne %l0\", \"fjne %l0\", \"jne %l0\"); -#endif -}") - -(define_insn "" - [(set (pc) - (if_then_else (ne (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -{ -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbeq %l0\", \"fbeq %l0\", \"jbeq %l0\"); -#else - OUTPUT_JUMP (\"jeq %l0\", \"fjeq %l0\", \"jeq %l0\"); -#endif -}") - -(define_insn "" - [(set (pc) - (if_then_else (gt (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jble %l0\", \"fbngt %l0\", 0); -#else - OUTPUT_JUMP (\"jle %l0\", \"fjngt %l0\", 0); -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (gtu (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - return \"jbls %l0\"; -#else - return \"jls %l0\"; -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (lt (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbge %l0\", \"fbnlt %l0\", \"jbpl %l0\"); -#else - OUTPUT_JUMP (\"jge %l0\", \"fjnlt %l0\", \"jpl %l0\"); -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (ltu (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - return \"jbcc %l0\"; -#else - return \"jcc %l0\"; -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (ge (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jblt %l0\", \"fbnge %l0\", \"jbmi %l0\"); -#else - OUTPUT_JUMP (\"jlt %l0\", \"fjnge %l0\", \"jmi %l0\"); -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (geu (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - return \"jbcs %l0\"; -#else - return \"jcs %l0\"; -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (le (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - OUTPUT_JUMP (\"jbgt %l0\", \"fbnle %l0\", 0); -#else - OUTPUT_JUMP (\"jgt %l0\", \"fjnle %l0\", 0); -#endif -") - -(define_insn "" - [(set (pc) - (if_then_else (leu (cc0) - (const_int 0)) - (pc) - (label_ref (match_operand 0 "" ""))))] - "" - "* -#ifdef MOTOROLA - return \"jbhi %l0\"; -#else - return \"jhi %l0\"; -#endif -") - -;; Unconditional and other jump instructions -(define_insn "jump" - [(set (pc) - (label_ref (match_operand 0 "" "")))] - "" - "* -#ifdef MOTOROLA - return \"jbra %l0\"; -#else - return \"jra %l0\"; -#endif -") - -;; We support two different ways of handling dispatch tables. -;; The NeXT uses absolute tables, and other machines use relative. -;; This define_expand can generate either kind. -(define_expand "tablejump" - [(parallel [(set (pc) (match_operand 0 "" "")) - (use (label_ref (match_operand 1 "" "")))])] - "" - " -{ -#ifdef CASE_VECTOR_PC_RELATIVE - operands[0] = gen_rtx (PLUS, SImode, pc_rtx, operands[0]); -#endif -}") - -;; Jump to variable address from dispatch table of absolute addresses. -(define_insn "" - [(set (pc) (match_operand:SI 0 "register_operand" "a")) - (use (label_ref (match_operand 1 "" "")))] - "" - "* -#ifdef MOTOROLA - return \"jmp (%0)\"; -#else - return \"jmp %0@\"; -#endif -") - -;; Jump to variable address from dispatch table of relative addresses. -(define_insn "" - [(set (pc) - (plus:SI (pc) (match_operand:HI 0 "register_operand" "r"))) - (use (label_ref (match_operand 1 "" "")))] - "" - "* -#ifdef ASM_RETURN_CASE_JUMP - ASM_RETURN_CASE_JUMP; -#else -#ifdef SGS -#ifdef ASM_OUTPUT_CASE_LABEL - return \"jmp 6(%%pc,%0.w)\"; -#else -#ifdef CRDS - return \"jmp 2(pc,%0.w)\"; -#else - return \"jmp 2(%%pc,%0.w)\"; -#endif /* end !CRDS */ -#endif -#else /* not SGS */ -#ifdef MOTOROLA - return \"jmp (2,pc,%0.w)\"; -#else - return \"jmp pc@(2,%0:w)\"; -#endif -#endif -#endif -") - -;; Decrement-and-branch insns. -(define_insn "" - [(set (pc) - (if_then_else - (ne (match_operand:HI 0 "general_operand" "+g") - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:HI (match_dup 0) - (const_int -1)))] - "" - "* -{ - CC_STATUS_INIT; - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\"; - if (GET_CODE (operands[0]) == MEM) - { -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - return \"sub%.w %#1,%0\;jbcc %l1\"; -#else - return \"subq%.w %#1,%0\;jbcc %l1\"; -#endif -#else /* not MOTOROLA */ - return \"subqw %#1,%0\;jcc %l1\"; -#endif - } -#ifdef MOTOROLA -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return \"sub%.w %#1,%0\;cmp%.w %0,%#-1\;jbne %l1\"; -#else - return \"subq%.w %#1,%0\;cmp%.w %0,%#-1\;jbne %l1\"; -#endif -#else /* not SGS_CMP_ORDER */ - return \"subq%.w %#1,%0\;cmp%.w %#-1,%0\;jbne %l1\"; -#endif -#else /* not MOTOROLA */ - return \"subqw %#1,%0\;cmpw %#-1,%0\;jne %l1\"; -#endif -}") - -(define_insn "" - [(set (pc) - (if_then_else - (ne (match_operand:SI 0 "general_operand" "+g") - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:SI (match_dup 0) - (const_int -1)))] - "" - "* -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;sub%.l %#1,%0\;jbcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"sub%.l %#1,%0\;jbcc %l1\"; -#else - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;subq%.l %#1,%0\;jbcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subq%.l %#1,%0\;jbcc %l1\"; -#endif /* NO_ADDSUB_Q */ -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return \"sub.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\"; -#else - return \"subq.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\"; -#endif -#else /* not SGS_CMP_ORDER */ - return \"subq.l %#1,%0\;cmp.l %#-1,%0\;jbne %l1\"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;subql %#1,%0\;jcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subql %#1,%0\;jcc %l1\"; - return \"subql %#1,%0\;cmpl %#-1,%0\;jne %l1\"; -#endif /* not MOTOROLA */ -}") - -;; Two dbra patterns that use REG_NOTES info generated by strength_reduce. - -(define_insn "" - [(set (pc) - (if_then_else - (ge (plus:HI (match_operand:HI 0 "general_operand" "+g") - (const_int -1)) - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:HI (match_dup 0) - (const_int -1)))] - "find_reg_note (insn, REG_NONNEG, 0)" - "* -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"sub%.w %#1,%0\;jbcc %l1\"; -#else - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subq%.w %#1,%0\;jbcc %l1\"; -#endif -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return \"sub.w %#1,%0\;cmp.w %0,%#-1\;jbne %l1\"; -#else - return \"subq.w %#1,%0\;cmp.w %0,%#-1\;jbne %l1\"; -#endif -#else /* not SGS_CMP_ORDER */ - return \"subq.w %#1,%0\;cmp.w %#-1,%0\;jbne %l1\"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subqw %#1,%0\;jcc %l1\"; - return \"subqw %#1,%0\;cmpw %#-1,%0\;jne %l1\"; -#endif /* not MOTOROLA */ -}") - -(define_insn "decrement_and_branch_until_zero" - [(set (pc) - (if_then_else - (ge (plus:SI (match_operand:SI 0 "general_operand" "+g") - (const_int -1)) - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:SI (match_dup 0) - (const_int -1)))] - "find_reg_note (insn, REG_NONNEG, 0)" - "* -{ - CC_STATUS_INIT; -#ifdef MOTOROLA -#ifdef NO_ADDSUB_Q - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;sub%.l %#1,%0\;jbcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"sub%.l %#1,%0\;jbcc %l1\"; -#else - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;subq%.l %#1,%0\;jbcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subq%.l %#1,%0\;jbcc %l1\"; -#endif -#ifdef SGS_CMP_ORDER -#ifdef NO_ADDSUB_Q - return \"sub.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\"; -#else - return \"subq.l %#1,%0\;cmp.l %0,%#-1\;jbne %l1\"; -#endif -#else /* not SGS_CMP_ORDER */ - return \"subq.l %#1,%0\;cmp.l %#-1,%0\;jbne %l1\"; -#endif /* not SGS_CMP_ORDER */ -#else /* not MOTOROLA */ - if (DATA_REG_P (operands[0])) - return \"dbra %0,%l1\;clr%.w %0\;subql %#1,%0\;jcc %l1\"; - if (GET_CODE (operands[0]) == MEM) - return \"subql %#1,%0\;jcc %l1\"; - return \"subql %#1,%0\;cmpl %#-1,%0\;jne %l1\"; -#endif /* not MOTOROLA */ -}") - - -;; PIC calls are handled by loading the address of the function into a -;; register (via movsi), then emitting a register indirect call using -;; the "jsr" function call syntax. -;; -;; It is important to note that the "jsr" syntax is always used for -;; PIC calls, even on machines in which GCC normally uses the "jbsr" -;; syntax for non-PIC calls. This keeps at least 1 assembler (Sun) -;; from emitting incorrect code for a PIC call. -;; -;; We have different patterns for PIC calls and non-PIC calls. The -;; different patterns are only used to choose the right syntax -;; ("jsr" vs "jbsr"). -;; -;; On svr4 m68k, PIC stuff is done differently. To be able to support -;; dynamic linker LAZY BINDING, all the procedure calls need to go -;; through the PLT (Procedure Linkage Table) section in PIC mode. The -;; svr4 m68k assembler recognizes this syntax: `bsr FUNC@PLTPC' and it -;; will create the correct relocation entry (R_68K_PLT32) for `FUNC', -;; that tells the linker editor to create an entry for `FUNC' in PLT -;; section at link time. However, all global objects reference are still -;; done by using `OBJ@GOT'. So, the goal here is to output the function -;; call operand as `FUNC@PLTPC', but output object operand as `OBJ@GOT'. -;; We need to have a way to differentiate these two different operands. -;; -;; The strategy I use here is to use SYMBOL_REF_FLAG to differentiate -;; these two different operands. The macro LEGITIMATE_PIC_OPERAND_P needs -;; to be changed to recognize function calls symbol_ref operand as a legal -;; PIC operand (by checking whether SYMBOL_REF_FLAG is set). This will -;; avoid the compiler to load this symbol_ref operand into a register. -;; Remember, the operand "foo@PLTPC" cannot be called via jsr directly -;; since the value is a PC relative offset, not a real address. -;; -;; All global objects are treated in the similar way as in SUN3. The only -;; difference is: on m68k svr4, the reference of such global object needs -;; to end with a suffix "@GOT" so the assembler and linker know to create -;; an entry for it in GOT (Global Offset Table) section. This is done in -;; m68k.c. - -;; Call subroutine with no return value. -(define_expand "call" - [(call (match_operand:QI 0 "memory_operand" "") - (match_operand:SI 1 "general_operand" ""))] - ;; Operand 1 not really used on the m68000. - - "" - " -{ - if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF) -#ifdef MOTOROLA - SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1; -#else - operands[0] = gen_rtx (MEM, GET_MODE (operands[0]), - force_reg (Pmode, XEXP (operands[0], 0))); -#endif -}") - -;; This is a normal call sequence. -(define_insn "" - [(call (match_operand:QI 0 "memory_operand" "o") - (match_operand:SI 1 "general_operand" "g"))] - ;; Operand 1 not really used on the m68000. - - "! flag_pic" - "* -#ifdef MOTOROLA - return \"jsr %0\"; -#else - return \"jbsr %0\"; -#endif -") - -;; This is a PIC call sequence. -(define_insn "" - [(call (match_operand:QI 0 "memory_operand" "o") - (match_operand:SI 1 "general_operand" "g"))] - ;; Operand 1 not really used on the m68000. - - "flag_pic" - "* -#ifdef MOTOROLA - if (GET_CODE (operands[0]) == MEM - && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF) - return \"bsr %0@PLTPC\"; -#endif - return \"jsr %0\"; -") - -;; Call subroutine, returning value in operand 0 -;; (which must be a hard register). -;; See comments before "call" regarding PIC calls. -(define_expand "call_value" - [(set (match_operand 0 "" "") - (call (match_operand:QI 1 "memory_operand" "") - (match_operand:SI 2 "general_operand" "")))] - ;; Operand 2 not really used on the m68000. - "" - " -{ - if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF) -#ifdef MOTOROLA - SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1; -#else - operands[1] = gen_rtx (MEM, GET_MODE (operands[1]), - force_reg (Pmode, XEXP (operands[1], 0))); -#endif -}") - -;; This is a normal call_value -(define_insn "" - [(set (match_operand 0 "" "=rf") - (call (match_operand:QI 1 "memory_operand" "o") - (match_operand:SI 2 "general_operand" "g")))] - ;; Operand 2 not really used on the m68000. - "! flag_pic" - "* -#ifdef MOTOROLA - return \"jsr %1\"; -#else - return \"jbsr %1\"; -#endif -") - -;; This is a PIC call_value -(define_insn "" - [(set (match_operand 0 "" "=rf") - (call (match_operand:QI 1 "memory_operand" "o") - (match_operand:SI 2 "general_operand" "g")))] - ;; Operand 2 not really used on the m68000. - "flag_pic" - "* -#ifdef MOTOROLA - if (GET_CODE (operands[1]) == MEM - && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF) - return \"bsr %1@PLTPC\"; -#endif - return \"jsr %1\"; -") - -;; Call subroutine returning any type. - -(define_expand "untyped_call" - [(parallel [(call (match_operand 0 "" "") - (const_int 0)) - (match_operand 1 "" "") - (match_operand 2 "" "")])] - "NEEDS_UNTYPED_CALL" - " -{ - int i; - - emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx)); - - for (i = 0; i < XVECLEN (operands[2], 0); i++) - { - rtx set = XVECEXP (operands[2], 0, i); - emit_move_insn (SET_DEST (set), SET_SRC (set)); - } - - /* The optimizer does not know that the call sets the function value - registers we stored in the result block. We avoid problems by - claiming that all hard registers are used and clobbered at this - point. */ - emit_insn (gen_blockage ()); - - DONE; -}") - -;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and -;; all of memory. This blocks insns from being moved across this point. - -(define_insn "blockage" - [(unspec_volatile [(const_int 0)] 0)] - "" - "") - -(define_insn "nop" - [(const_int 0)] - "" - "nop") - -(define_insn "probe" - [(reg:SI 15)] - "NEED_PROBE" - "* -{ - operands[0] = gen_rtx (PLUS, SImode, stack_pointer_rtx, - gen_rtx (CONST_INT, VOIDmode, NEED_PROBE)); - return \"tstl %a0\"; -}") - -;; Used for frameless functions which save no regs and allocate no locals. -(define_insn "return" - [(return)] - "USE_RETURN_INSN" - "* -{ - if (current_function_pops_args == 0) - return \"rts\"; - operands[0] = gen_rtx (CONST_INT, VOIDmode, current_function_pops_args); - return \"rtd %0\"; -}") - -(define_insn "indirect_jump" - [(set (pc) (match_operand:SI 0 "address_operand" "p"))] - "" - "jmp %a0") - -;; This should not be used unless the add/sub insns can't be. - -(define_insn "" - [(set (match_operand:SI 0 "general_operand" "=a") - (match_operand:QI 1 "address_operand" "p"))] - "" - "lea %a1,%0") - -;; This is the first machine-dependent peephole optimization. -;; It is useful when a floating value is returned from a function call -;; and then is moved into an FP register. -;; But it is mainly intended to test the support for these optimizations. - -(define_peephole - [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4))) - (set (match_operand:DF 0 "register_operand" "=f") - (match_operand:DF 1 "register_operand" "ad"))] - "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])" - "* -{ - rtx xoperands[2]; - xoperands[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1); - output_asm_insn (\"move%.l %1,%@\", xoperands); - output_asm_insn (\"move%.l %1,%-\", operands); - return \"fmove%.d %+,%0\"; -} -") - -;; Optimize a stack-adjust followed by a push of an argument. -;; This is said to happen frequently with -msoft-float -;; when there are consecutive library calls. - -(define_peephole - [(set (reg:SI 15) (plus:SI (reg:SI 15) - (match_operand:SI 0 "immediate_operand" "n"))) - (set (match_operand:SF 1 "push_operand" "=m") - (match_operand:SF 2 "general_operand" "rmfF"))] - "GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) >= 4 - && ! reg_mentioned_p (stack_pointer_rtx, operands[2])" - "* -{ - if (INTVAL (operands[0]) > 4) - { - rtx xoperands[2]; - xoperands[0] = stack_pointer_rtx; - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4); -#ifndef NO_ADDSUB_Q - if (INTVAL (xoperands[1]) <= 8) - output_asm_insn (\"addq%.w %1,%0\", xoperands); - else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020) - { - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (xoperands[1]) - 8); - output_asm_insn (\"addq%.w %#8,%0\;addq%.w %1,%0\", xoperands); - } - else -#endif - if (INTVAL (xoperands[1]) <= 0x7FFF) - output_asm_insn (\"add%.w %1,%0\", xoperands); - else - output_asm_insn (\"add%.l %1,%0\", xoperands); - } - if (FP_REG_P (operands[2])) - return \"fmove%.s %2,%@\"; - return \"move%.l %2,%@\"; -}") - -;; Speed up stack adjust followed by a fullword fixedpoint push. - -(define_peephole - [(set (reg:SI 15) (plus:SI (reg:SI 15) - (match_operand:SI 0 "immediate_operand" "n"))) - (set (match_operand:SI 1 "push_operand" "=m") - (match_operand:SI 2 "general_operand" "g"))] - "GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) >= 4 - && ! reg_mentioned_p (stack_pointer_rtx, operands[2])" - "* -{ - if (INTVAL (operands[0]) > 4) - { - rtx xoperands[2]; - xoperands[0] = stack_pointer_rtx; - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[0]) - 4); -#ifndef NO_ADDSUB_Q - if (INTVAL (xoperands[1]) <= 8) - output_asm_insn (\"addq%.w %1,%0\", xoperands); - else if (INTVAL (xoperands[1]) <= 16 && TARGET_68020) - { - xoperands[1] = gen_rtx (CONST_INT, VOIDmode, - INTVAL (xoperands[1]) - 8); - output_asm_insn (\"addq%.w %#8,%0\;addq%.w %1,%0\", xoperands); - } - else -#endif - if (INTVAL (xoperands[1]) <= 0x7FFF) - output_asm_insn (\"add%.w %1,%0\", xoperands); - else - output_asm_insn (\"add%.l %1,%0\", xoperands); - } - if (operands[2] == const0_rtx) - return \"clr%.l %@\"; - return \"move%.l %2,%@\"; -}") - -;; Speed up pushing a single byte but leaving four bytes of space. - -(define_peephole - [(set (mem:QI (pre_dec:SI (reg:SI 15))) - (match_operand:QI 1 "general_operand" "dami")) - (set (reg:SI 15) (minus:SI (reg:SI 15) (const_int 2)))] - "! reg_mentioned_p (stack_pointer_rtx, operands[1])" - "* -{ - rtx xoperands[4]; - - if (GET_CODE (operands[1]) == REG) - return \"move%.l %1,%-\"; - - xoperands[1] = operands[1]; - xoperands[2] - = gen_rtx (MEM, QImode, - gen_rtx (PLUS, VOIDmode, stack_pointer_rtx, - gen_rtx (CONST_INT, VOIDmode, 3))); - xoperands[3] = stack_pointer_rtx; - output_asm_insn (\"subq%.w %#4,%3\;move%.b %1,%2\", xoperands); - return \"\"; -}") - -(define_peephole - [(set (match_operand:SI 0 "register_operand" "=d") - (const_int 0)) - (set (strict_low_part (subreg:HI (match_dup 0) 0)) - (match_operand:HI 1 "general_operand" "rmn"))] - "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])" - "* -{ - if (GET_CODE (operands[1]) == CONST_INT) - { - if (operands[1] == const0_rtx - && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM) - /* clr insns on 68000 read before writing. - This isn't so on the 68010, but we have no alternative for it. */ - && (TARGET_68020 - || !(GET_CODE (operands[0]) == MEM - && MEM_VOLATILE_P (operands[0])))) - return \"clr%.w %0\"; - } - return \"move%.w %1,%0\"; -}") - -;; dbCC peepholes -;; -;; Turns -;; loop: -;; [ ... ] -;; jCC label ; abnormal loop termination -;; dbra dN, loop ; normal loop termination -;; -;; Into -;; loop: -;; [ ... ] -;; dbCC dN, loop -;; jCC label -;; -;; Which moves the jCC condition outside the inner loop for free. -;; -(define_peephole - [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p" - [(cc0) (const_int 0)]) - (label_ref (match_operand 2 "" "")) - (pc))) - (parallel - [(set (pc) - (if_then_else - (ge (plus:HI (match_operand:HI 0 "register_operand" "+d") - (const_int -1)) - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:HI (match_dup 0) - (const_int -1)))])] - "DATA_REG_P (operands[0])" - "* -{ - CC_STATUS_INIT; - output_dbcc_and_branch (operands); - return \"\"; -}") - -(define_peephole - [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p" - [(cc0) (const_int 0)]) - (label_ref (match_operand 2 "" "")) - (pc))) - (parallel - [(set (pc) - (if_then_else - (ge (plus:SI (match_operand:SI 0 "register_operand" "+d") - (const_int -1)) - (const_int 0)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_dup 0) - (plus:SI (match_dup 0) - (const_int -1)))])] - "DATA_REG_P (operands[0])" - "* -{ - CC_STATUS_INIT; - output_dbcc_and_branch (operands); - return \"\"; -}") - - -;; FPA multiply and add. -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (plus:DF (mult:DF (match_operand:DF 1 "general_operand" "%x,dmF,y") - (match_operand:DF 2 "general_operand" "xH,y,y")) - (match_operand:DF 3 "general_operand" "xH,y,dmF")))] - "TARGET_FPA" - "@ - fpma%.d %1,%w2,%w3,%0 - fpma%.d %x1,%x2,%x3,%0 - fpma%.d %x1,%x2,%x3,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (plus:SF (mult:SF (match_operand:SF 1 "general_operand" "%x,ydmF,y") - (match_operand:SF 2 "general_operand" "xH,y,ydmF")) - (match_operand:SF 3 "general_operand" "xH,ydmF,ydmF")))] - "TARGET_FPA" - "@ - fpma%.s %1,%w2,%w3,%0 - fpma%.s %1,%2,%3,%0 - fpma%.s %1,%2,%3,%0") - -;; FPA Multiply and subtract -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (minus:DF (match_operand:DF 1 "general_operand" "xH,rmF,y") - (mult:DF (match_operand:DF 2 "general_operand" "%xH,y,y") - (match_operand:DF 3 "general_operand" "x,y,rmF"))))] - "TARGET_FPA" - "@ - fpms%.d %3,%w2,%w1,%0 - fpms%.d %x3,%2,%x1,%0 - fpms%.d %x3,%2,%x1,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (minus:SF (match_operand:SF 1 "general_operand" "xH,rmF,yrmF") - (mult:SF (match_operand:SF 2 "general_operand" "%xH,rmF,y") - (match_operand:SF 3 "general_operand" "x,y,yrmF"))))] - "TARGET_FPA" - "@ - fpms%.s %3,%w2,%w1,%0 - fpms%.s %3,%2,%1,%0 - fpms%.s %3,%2,%1,%0") - -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (minus:DF (mult:DF (match_operand:DF 1 "general_operand" "%xH,y,y") - (match_operand:DF 2 "general_operand" "x,y,rmF")) - (match_operand:DF 3 "general_operand" "xH,rmF,y")))] - "TARGET_FPA" - "@ - fpmr%.d %2,%w1,%w3,%0 - fpmr%.d %x2,%1,%x3,%0 - fpmr%.d %x2,%1,%x3,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (minus:SF (mult:SF (match_operand:SF 1 "general_operand" "%xH,rmF,y") - (match_operand:SF 2 "general_operand" "x,y,yrmF")) - (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))] - "TARGET_FPA" - "@ - fpmr%.s %2,%w1,%w3,%0 - fpmr%.s %x2,%1,%x3,%0 - fpmr%.s %x2,%1,%x3,%0") - -;; FPA Add and multiply -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (mult:DF (plus:DF (match_operand:DF 1 "general_operand" "%xH,y,y") - (match_operand:DF 2 "general_operand" "x,y,rmF")) - (match_operand:DF 3 "general_operand" "xH,rmF,y")))] - "TARGET_FPA" - "@ - fpam%.d %2,%w1,%w3,%0 - fpam%.d %x2,%1,%x3,%0 - fpam%.d %x2,%1,%x3,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (mult:SF (plus:SF (match_operand:SF 1 "general_operand" "%xH,rmF,y") - (match_operand:SF 2 "general_operand" "x,y,yrmF")) - (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))] - "TARGET_FPA" - "@ - fpam%.s %2,%w1,%w3,%0 - fpam%.s %x2,%1,%x3,%0 - fpam%.s %x2,%1,%x3,%0") - -;;FPA Subtract and multiply -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (mult:DF (minus:DF (match_operand:DF 1 "general_operand" "xH,y,y") - (match_operand:DF 2 "general_operand" "x,y,rmF")) - (match_operand:DF 3 "general_operand" "xH,rmF,y")))] - "TARGET_FPA" - "@ - fpsm%.d %2,%w1,%w3,%0 - fpsm%.d %x2,%1,%x3,%0 - fpsm%.d %x2,%1,%x3,%0") - -(define_insn "" - [(set (match_operand:DF 0 "register_operand" "=x,y,y") - (mult:DF (match_operand:DF 1 "general_operand" "xH,rmF,y") - (minus:DF (match_operand:DF 2 "general_operand" "xH,y,y") - (match_operand:DF 3 "general_operand" "x,y,rmF"))))] - "TARGET_FPA" - "@ - fpsm%.d %3,%w2,%w1,%0 - fpsm%.d %x3,%2,%x1,%0 - fpsm%.d %x3,%2,%x1,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (mult:SF (minus:SF (match_operand:SF 1 "general_operand" "xH,rmF,y") - (match_operand:SF 2 "general_operand" "x,y,yrmF")) - (match_operand:SF 3 "general_operand" "xH,rmF,yrmF")))] - "TARGET_FPA" - "@ - fpsm%.s %2,%w1,%w3,%0 - fpsm%.s %x2,%1,%x3,%0 - fpsm%.s %x2,%1,%x3,%0") - -(define_insn "" - [(set (match_operand:SF 0 "register_operand" "=x,y,y") - (mult:SF (match_operand:SF 1 "general_operand" "xH,rmF,yrmF") - (minus:SF (match_operand:SF 2 "general_operand" "xH,rmF,y") - (match_operand:SF 3 "general_operand" "x,y,yrmF"))))] - "TARGET_FPA" - "@ - fpsm%.s %3,%w2,%w1,%0 - fpsm%.s %x3,%2,%x1,%0 - fpsm%.s %x3,%2,%x1,%0") - -(define_insn "tstxf" - [(set (cc0) - (match_operand:XF 0 "nonimmediate_operand" "fm"))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; - return \"ftst%.x %0\"; -}") - - -(define_expand "cmpxf" - [(set (cc0) - (compare (match_operand:XF 0 "general_operand" "f,mG") - (match_operand:XF 1 "general_operand" "fmG,f")))] - "TARGET_68881" - " -{ - if (CONSTANT_P (operands[0])) - operands[0] = force_const_mem (XFmode, operands[0]); - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); -}") - -(define_insn "" - [(set (cc0) - (compare (match_operand:XF 0 "nonimmediate_operand" "f,mG") - (match_operand:XF 1 "nonimmediate_operand" "fmG,f")))] - "TARGET_68881" - "* -{ - cc_status.flags = CC_IN_68881; -#ifdef SGS_CMP_ORDER - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return \"fcmp%.x %0,%1\"; - else - return \"fcmp%.x %0,%f1\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.x %1,%f0\"; -#else - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return \"fcmp%.x %1,%0\"; - else - return \"fcmp%.x %f1,%0\"; - } - cc_status.flags |= CC_REVERSED; - return \"fcmp%.x %f0,%1\"; -#endif -}") - -(define_insn "extendsfxf2" - [(set (match_operand:XF 0 "general_operand" "=fm,f") - (float_extend:XF (match_operand:SF 1 "general_operand" "f,m")))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return \"\"; - } - return \"f%$move%.x %1,%0\"; - } - if (FP_REG_P (operands[0])) - return \"f%$move%.s %f1,%0\"; - return \"fmove%.x %f1,%0\"; -}") - - -(define_insn "extenddfxf2" - [(set (match_operand:XF 0 "general_operand" "=fm,f") - (float_extend:XF - (match_operand:DF 1 "general_operand" "f,m")))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[0]) && FP_REG_P (operands[1])) - { - if (REGNO (operands[0]) == REGNO (operands[1])) - { - /* Extending float to double in an fp-reg is a no-op. - NOTICE_UPDATE_CC has already assumed that the - cc will be set. So cancel what it did. */ - cc_status = cc_prev_status; - return \"\"; - } - return \"fmove%.x %1,%0\"; - } - if (FP_REG_P (operands[0])) - return \"f%&move%.d %f1,%0\"; - return \"fmove%.x %f1,%0\"; -}") - -(define_insn "truncxfdf2" - [(set (match_operand:DF 0 "general_operand" "=m,!r") - (float_truncate:DF - (match_operand:XF 1 "general_operand" "f,f")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[0])) - { - output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands); - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return \"move%.l %+,%0\"; - } - return \"fmove%.d %f1,%0\"; -}") - -(define_insn "truncxfsf2" - [(set (match_operand:SF 0 "general_operand" "=dm") - (float_truncate:SF - (match_operand:XF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.s %f1,%0") - -(define_insn "floatsixf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (float:XF (match_operand:SI 1 "general_operand" "dmi")))] - "TARGET_68881" - "fmove%.l %1,%0") - -(define_insn "floathixf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (float:XF (match_operand:HI 1 "general_operand" "dmn")))] - "TARGET_68881" - "fmove%.w %1,%0") - -(define_insn "floatqixf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (float:XF (match_operand:QI 1 "general_operand" "dmn")))] - "TARGET_68881" - "fmove%.b %1,%0") - -(define_insn "ftruncxf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (fix:XF (match_operand:XF 1 "general_operand" "fFm")))] - "TARGET_68881" - "* -{ - if (FP_REG_P (operands[1])) - return \"fintrz%.x %f1,%0\"; - return \"fintrz%.x %f1,%0\"; -}") - -(define_insn "fixxfqi2" - [(set (match_operand:QI 0 "general_operand" "=dm") - (fix:QI (match_operand:XF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.b %1,%0") - -(define_insn "fixxfhi2" - [(set (match_operand:HI 0 "general_operand" "=dm") - (fix:HI (match_operand:XF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.w %1,%0") - -(define_insn "fixxfsi2" - [(set (match_operand:SI 0 "general_operand" "=dm") - (fix:SI (match_operand:XF 1 "general_operand" "f")))] - "TARGET_68881" - "fmove%.l %1,%0") - -(define_expand "addxf3" - [(set (match_operand:XF 0 "general_operand" "") - (plus:XF (match_operand:XF 1 "general_operand" "") - (match_operand:XF 2 "general_operand" "")))] - "TARGET_68881" - " -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -}") - -(define_insn "" - [(set (match_operand:XF 0 "general_operand" "=f") - (plus:XF (match_operand:XF 1 "nonimmediate_operand" "%0") - (match_operand:XF 2 "nonimmediate_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"fadd%.x %2,%0\"; - return \"fadd%.x %f2,%0\"; -}") - -(define_expand "subxf3" - [(set (match_operand:XF 0 "general_operand" "") - (minus:XF (match_operand:XF 1 "general_operand" "") - (match_operand:XF 2 "general_operand" "")))] - "TARGET_68881" - " -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -}") - -(define_insn "" - [(set (match_operand:XF 0 "general_operand" "=f") - (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0") - (match_operand:XF 2 "nonimmediate_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"fsub%.x %2,%0\"; - return \"fsub%.x %f2,%0\"; -}") - -(define_expand "mulxf3" - [(set (match_operand:XF 0 "general_operand" "") - (mult:XF (match_operand:XF 1 "general_operand" "") - (match_operand:XF 2 "general_operand" "")))] - "TARGET_68881" - " -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -}") - -(define_insn "" - [(set (match_operand:XF 0 "general_operand" "=f") - (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0") - (match_operand:XF 2 "nonimmediate_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"fmul%.x %2,%0\"; - return \"fmul%.x %f2,%0\"; -}") - -(define_expand "divxf3" - [(set (match_operand:XF 0 "general_operand" "") - (div:XF (match_operand:XF 1 "general_operand" "") - (match_operand:XF 2 "general_operand" "")))] - "TARGET_68881" - " -{ - if (CONSTANT_P (operands[1])) - operands[1] = force_const_mem (XFmode, operands[1]); - if (CONSTANT_P (operands[2])) - operands[2] = force_const_mem (XFmode, operands[2]); -}") - -(define_insn "" - [(set (match_operand:XF 0 "general_operand" "=f") - (div:XF (match_operand:XF 1 "nonimmediate_operand" "0") - (match_operand:XF 2 "nonimmediate_operand" "fmG")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[2])) - return \"fdiv%.x %2,%0\"; - return \"fdiv%.x %f2,%0\"; -}") - -(define_insn "negxf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (neg:XF (match_operand:XF 1 "nonimmediate_operand" "fmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"fneg%.x %1,%0\"; - return \"fneg%.x %f1,%0\"; -}") - -(define_insn "absxf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (abs:XF (match_operand:XF 1 "nonimmediate_operand" "fmF")))] - "TARGET_68881" - "* -{ - if (REG_P (operands[1]) && ! DATA_REG_P (operands[1])) - return \"fabs%.x %1,%0\"; - return \"fabs%.x %f1,%0\"; -}") - -(define_insn "sqrtxf2" - [(set (match_operand:XF 0 "general_operand" "=f") - (sqrt:XF (match_operand:DF 1 "nonimmediate_operand" "fm")))] - "TARGET_68881" - "* -{ - return \"fsqrt%.x %1,%0\"; -}") diff --git a/gnu/usr.bin/gcc2/arch/hp300/tconfig.h b/gnu/usr.bin/gcc2/arch/hp300/tconfig.h deleted file mode 100644 index aca6f305096c..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/tconfig.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Configuration for GNU C-compiler for Motorola 68000 family. - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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. - -GNU CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: tconfig.h,v 1.1 1993/08/23 09:21:33 cgd Exp $ -*/ - - -/* #defines that need visibility everywhere. */ -#define FALSE 0 -#define TRUE 1 - -/* This describes the machine the compiler is hosted on. */ -#define HOST_BITS_PER_CHAR 8 -#define HOST_BITS_PER_SHORT 16 -#define HOST_BITS_PER_INT 32 -#define HOST_BITS_PER_LONG 32 -#define HOST_BITS_PER_LONGLONG 64 - -#define HOST_WORDS_BIG_ENDIAN - -/* target machine dependencies. - tm.h is a symbolic link to the actual target specific file. */ -#include "tm.h" - -/* Arguments to use with `exit'. */ -#define SUCCESS_EXIT_CODE 0 -#define FATAL_EXIT_CODE 33 - -/* If compiled with GNU C, use the built-in alloca */ -#ifdef __GNUC__ -/* Use an arg in this macro because that's what some other - system does--let's avoid conflict. */ -#define alloca(x) __builtin_alloca(x) -#endif diff --git a/gnu/usr.bin/gcc2/arch/hp300/tm.h b/gnu/usr.bin/gcc2/arch/hp300/tm.h deleted file mode 100644 index 4d3901bc3547..000000000000 --- a/gnu/usr.bin/gcc2/arch/hp300/tm.h +++ /dev/null @@ -1,56 +0,0 @@ -/* $Id: tm.h,v 1.1 1993/08/23 09:21:34 cgd Exp $ */ - -#include -#include "hp300/m68k.h" - -/* See m68k.h. 7 means 68020 with 68881. */ - -#define TARGET_DEFAULT 7 - -/* Define __HAVE_68881__ in preprocessor, unless -msoft-float is specified. - This will control the use of inline 68881 insns in certain macros. */ - -#define CPP_SPEC "%{!msoft-float:-D__HAVE_68881__ -D__HAVE_FPU__} %{posix:-D_POSIX_SOURCE}" - -/* Names to predefine in the preprocessor for this target machine. */ - -#define CPP_PREDEFINES "-Dmc68000 -Dmc68020 -Dhp300 -Dhp9000 -Dunix -D__BSD_NET2__ -D__NetBSD__" - -/* No more libg.a */ - -#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" - -/* Make gcc agree with */ - -#define SIZE_TYPE "unsigned int" -#define PTRDIFF_TYPE "int" -#undef WCHAR_TYPE -#define WCHAR_TYPE "short unsigned int" -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE 16 - -/* Every structure or union's size must be a multiple of 2 bytes. */ - -#define STRUCTURE_SIZE_BOUNDARY 16 - -/* This is BSD, so it wants DBX format. */ - -#define DBX_DEBUGGING_INFO - -/* Do not break .stabs pseudos into continuations. */ - -#define DBX_CONTIN_LENGTH 0 - -/* This is the char to use for continuation (in case we need to turn - continuation back on). */ - -#define DBX_CONTIN_CHAR '?' - -/* Don't use the `xsfoo;' construct in DBX output; this system - doesn't support it. */ - -#define DBX_NO_XREFS - -/* Don't default to pcc-struct-return, because gcc is the only compiler, and - we want to retain compatibility with older gcc versions. */ -#define DEFAULT_PCC_STRUCT_RETURN 0 diff --git a/gnu/usr.bin/gcc2/common/insn-config.h b/gnu/usr.bin/gcc2/common/insn-config.h deleted file mode 100644 index 7dba8866f62f..000000000000 --- a/gnu/usr.bin/gcc2/common/insn-config.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Generated automatically by the program `genconfig' -from the machine description file `md'. */ - - -#define MAX_RECOG_OPERANDS 10 - -#define MAX_DUP_OPERANDS 3 -#ifndef MAX_INSNS_PER_SPLIT -#define MAX_INSNS_PER_SPLIT 1 -#endif -#define REGISTER_CONSTRAINTS -#define HAVE_cc0 diff --git a/gnu/usr.bin/gcc2/common/insn-emit.c b/gnu/usr.bin/gcc2/common/insn-emit.c deleted file mode 100644 index 8a8d9bd4f80b..000000000000 --- a/gnu/usr.bin/gcc2/common/insn-emit.c +++ /dev/null @@ -1,2708 +0,0 @@ -/* Generated automatically by the program `genemit' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "expr.h" -#include "real.h" -#include "output.h" -#include "insn-config.h" - -#include "insn-flags.h" - -#include "insn-codes.h" - -extern char *insn_operand_constraint[][MAX_RECOG_OPERANDS]; - -extern rtx recog_operand[]; -#define operands emit_operand - -#define FAIL goto _fail - -#define DONE goto _done - -rtx -gen_tstsi_1 (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tstsi (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - i386_compare_gen = gen_tstsi_1; - i386_compare_op0 = operands[0]; - DONE; -} - operand0 = operands[0]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, operand0)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tsthi_1 (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tsthi (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - i386_compare_gen = gen_tsthi_1; - i386_compare_op0 = operands[0]; - DONE; -} - operand0 = operands[0]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, operand0)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tstqi_1 (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tstqi (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - i386_compare_gen = gen_tstqi_1; - i386_compare_op0 = operands[0]; - DONE; -} - operand0 = operands[0]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, operand0)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tstsf_cc (operand0) - rtx operand0; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)))); -} - -rtx -gen_tstsf (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - i386_compare_gen = gen_tstsf_cc; - i386_compare_op0 = operands[0]; - DONE; -} - operand0 = operands[0]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tstdf_cc (operand0) - rtx operand0; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)))); -} - -rtx -gen_tstdf (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - i386_compare_gen = gen_tstdf_cc; - i386_compare_op0 = operands[0]; - DONE; -} - operand0 = operands[0]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpsi_1 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmpsi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - operands[0] = force_reg (SImode, operands[0]); - - i386_compare_gen = gen_cmpsi_1; - i386_compare_op0 = operands[0]; - i386_compare_op1 = operands[1]; - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmphi_1 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmphi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - operands[0] = force_reg (HImode, operands[0]); - - i386_compare_gen = gen_cmphi_1; - i386_compare_op0 = operands[0]; - i386_compare_op1 = operands[1]; - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpqi_1 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmpqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - operands[0] = force_reg (QImode, operands[0]); - - i386_compare_gen = gen_cmpqi_1; - i386_compare_op0 = operands[0]; - i386_compare_op1 = operands[1]; - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpsf_cc_1 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (GET_CODE (operand2), VOIDmode, - operand0, - operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)))); -} - -rtx -gen_cmpdf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - i386_compare_gen = gen_cmpdf_cc; - i386_compare_gen_eq = gen_cmpdf_ccfpeq; - i386_compare_op0 = operands[0]; - i386_compare_op1 = operands[1]; - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpsf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - i386_compare_gen = gen_cmpsf_cc; - i386_compare_gen_eq = gen_cmpsf_ccfpeq; - i386_compare_op0 = operands[0]; - i386_compare_op1 = operands[1]; - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpdf_cc (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)))); -} - -rtx -gen_cmpdf_ccfpeq (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (! register_operand (operands[1], DFmode)) - operands[1] = copy_to_mode_reg (DFmode, operands[1]); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, CCFPEQmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpsf_cc (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)))); -} - -rtx -gen_cmpsf_ccfpeq (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (! register_operand (operands[1], SFmode)) - operands[1] = copy_to_mode_reg (SFmode, operands[1]); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, CCFPEQmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_movsi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - extern int flag_pic; - - if (flag_pic && SYMBOLIC_CONST (operands[1])) - emit_pic_move (operands, SImode); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_movhi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movstricthi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand0), operand1); -} - -rtx -gen_movqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movstrictqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand0), operand1); -} - -rtx -gen_movsf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_swapdf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, operand1), - gen_rtx (SET, VOIDmode, operand1, operand0))); -} - -rtx -gen_movdf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movdi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_zero_extendhisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ZERO_EXTEND, SImode, operand1)); -} - -rtx -gen_zero_extendqihi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ZERO_EXTEND, HImode, operand1)); -} - -rtx -gen_zero_extendqisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ZERO_EXTEND, SImode, operand1)); -} - -rtx -gen_zero_extendsidi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ZERO_EXTEND, DImode, operand1)); -} - -rtx -gen_extendsidi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, DImode, operand1)); -} - -rtx -gen_extendhisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, SImode, operand1)); -} - -rtx -gen_extendqihi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, HImode, operand1)); -} - -rtx -gen_extendqisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, SImode, operand1)); -} - -rtx -gen_extendsfdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_EXTEND, DFmode, operand1)); -} - -rtx -gen_truncdfsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[2] = (rtx) assign_386_stack_local (SFmode, 0); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_TRUNCATE, SFmode, operand1)), - gen_rtx (CLOBBER, VOIDmode, operand2)))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fixuns_truncdfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operand4; - rtx operand5; - rtx operand6; - rtx operands[7]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[2] = gen_reg_rtx (DImode); - operands[3] = gen_lowpart (SImode, operands[2]); - operands[4] = gen_reg_rtx (DFmode); - operands[5] = (rtx) assign_386_stack_local (SImode, 0); - operands[6] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - operand6 = operands[6]; - emit_insn (gen_rtx (SET, VOIDmode, operand4, operand1)); - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (5, - gen_rtx (SET, VOIDmode, operand2, gen_rtx (FIX, DImode, gen_rtx (FIX, DFmode, operand4))), - gen_rtx (CLOBBER, VOIDmode, operand4), - gen_rtx (CLOBBER, VOIDmode, operand5), - gen_rtx (CLOBBER, VOIDmode, operand6), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - emit_insn (gen_rtx (SET, VOIDmode, operand0, operand3)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fixuns_truncsfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operand4; - rtx operand5; - rtx operand6; - rtx operands[7]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[2] = gen_reg_rtx (DImode); - operands[3] = gen_lowpart (SImode, operands[2]); - operands[4] = gen_reg_rtx (SFmode); - operands[5] = (rtx) assign_386_stack_local (SImode, 0); - operands[6] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - operand6 = operands[6]; - emit_insn (gen_rtx (SET, VOIDmode, operand4, operand1)); - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (5, - gen_rtx (SET, VOIDmode, operand2, gen_rtx (FIX, DImode, gen_rtx (FIX, SFmode, operand4))), - gen_rtx (CLOBBER, VOIDmode, operand4), - gen_rtx (CLOBBER, VOIDmode, operand5), - gen_rtx (CLOBBER, VOIDmode, operand6), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - emit_insn (gen_rtx (SET, VOIDmode, operand0, operand3)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fix_truncdfdi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operand4; - rtx operands[5]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[1] = copy_to_mode_reg (DFmode, operands[1]); - operands[2] = gen_reg_rtx (DFmode); - operands[3] = (rtx) assign_386_stack_local (SImode, 0); - operands[4] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - emit_insn (gen_rtx (SET, VOIDmode, operand2, operand1)); - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (5, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, DImode, gen_rtx (FIX, DFmode, operand2))), - gen_rtx (CLOBBER, VOIDmode, operand2), - gen_rtx (CLOBBER, VOIDmode, operand3), - gen_rtx (CLOBBER, VOIDmode, operand4), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fix_truncsfdi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operand4; - rtx operands[5]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[1] = copy_to_mode_reg (SFmode, operands[1]); - operands[2] = gen_reg_rtx (SFmode); - operands[3] = (rtx) assign_386_stack_local (SImode, 0); - operands[4] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - emit_insn (gen_rtx (SET, VOIDmode, operand2, operand1)); - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (5, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, DImode, gen_rtx (FIX, SFmode, operand2))), - gen_rtx (CLOBBER, VOIDmode, operand2), - gen_rtx (CLOBBER, VOIDmode, operand3), - gen_rtx (CLOBBER, VOIDmode, operand4), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fix_truncdfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operands[4]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[2] = (rtx) assign_386_stack_local (SImode, 0); - operands[3] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (4, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, gen_rtx (FIX, DFmode, operand1))), - gen_rtx (CLOBBER, VOIDmode, operand2), - gen_rtx (CLOBBER, VOIDmode, operand3), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fix_truncsfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operands[4]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[2] = (rtx) assign_386_stack_local (SImode, 0); - operands[3] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (4, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, gen_rtx (FIX, SFmode, operand1))), - gen_rtx (CLOBBER, VOIDmode, operand2), - gen_rtx (CLOBBER, VOIDmode, operand3), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_floatsisf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, SFmode, operand1)); -} - -rtx -gen_floatdisf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, SFmode, operand1)); -} - -rtx -gen_floatsidf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, DFmode, operand1)); -} - -rtx -gen_floatdidf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, DFmode, operand1)); -} - -rtx -gen_adddi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, DImode, operand1, operand2)); -} - -rtx -gen_addsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SImode, operand1, operand2)); -} - -rtx -gen_addhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, HImode, operand1, operand2)); -} - -rtx -gen_addqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, QImode, operand1, operand2)); -} - -rtx -gen_adddf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, DFmode, operand1, operand2)); -} - -rtx -gen_addsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SFmode, operand1, operand2)); -} - -rtx -gen_subdi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, DImode, operand1, operand2)); -} - -rtx -gen_subsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, SImode, operand1, operand2)); -} - -rtx -gen_subhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, HImode, operand1, operand2)); -} - -rtx -gen_subqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, QImode, operand1, operand2)); -} - -rtx -gen_subdf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, DFmode, operand1, operand2)); -} - -rtx -gen_subsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, SFmode, operand1, operand2)); -} - -rtx -gen_mulhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SImode, operand1, operand2)); -} - -rtx -gen_mulsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SImode, operand1, operand2)); -} - -rtx -gen_muldf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, DFmode, operand1, operand2)); -} - -rtx -gen_mulsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SFmode, operand1, operand2)); -} - -rtx -gen_divqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, QImode, operand1, operand2)); -} - -rtx -gen_udivqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UDIV, QImode, operand1, operand2)); -} - -rtx -gen_divdf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, DFmode, operand1, operand2)); -} - -rtx -gen_divsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, SFmode, operand1, operand2)); -} - -rtx -gen_divmodsi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (MOD, SImode, operand1, operand2)))); -} - -rtx -gen_divmodhi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, HImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (MOD, HImode, operand1, operand2)))); -} - -rtx -gen_udivmodsi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (UDIV, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (UMOD, SImode, operand1, operand2)))); -} - -rtx -gen_udivmodhi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (UDIV, HImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (UMOD, HImode, operand1, operand2)))); -} - -rtx -gen_andsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, SImode, operand1, operand2)); -} - -rtx -gen_andhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, HImode, operand1, operand2)); -} - -rtx -gen_andqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, QImode, operand1, operand2)); -} - -rtx -gen_iorsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, SImode, operand1, operand2)); -} - -rtx -gen_iorhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, HImode, operand1, operand2)); -} - -rtx -gen_iorqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, QImode, operand1, operand2)); -} - -rtx -gen_xorsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, SImode, operand1, operand2)); -} - -rtx -gen_xorhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, HImode, operand1, operand2)); -} - -rtx -gen_xorqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, QImode, operand1, operand2)); -} - -rtx -gen_negdi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, DImode, operand1)); -} - -rtx -gen_negsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, SImode, operand1)); -} - -rtx -gen_neghi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, HImode, operand1)); -} - -rtx -gen_negqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, QImode, operand1)); -} - -rtx -gen_negsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, SFmode, operand1)); -} - -rtx -gen_negdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, DFmode, operand1)); -} - -rtx -gen_abssf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ABS, SFmode, operand1)); -} - -rtx -gen_absdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ABS, DFmode, operand1)); -} - -rtx -gen_sqrtsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SQRT, SFmode, operand1)); -} - -rtx -gen_sqrtdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SQRT, DFmode, operand1)); -} - -rtx -gen_sindf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UNSPEC, DFmode, gen_rtvec (1, - operand1), 1)); -} - -rtx -gen_sinsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UNSPEC, SFmode, gen_rtvec (1, - operand1), 1)); -} - -rtx -gen_cosdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UNSPEC, DFmode, gen_rtvec (1, - operand1), 2)); -} - -rtx -gen_cossf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UNSPEC, SFmode, gen_rtvec (1, - operand1), 2)); -} - -rtx -gen_one_cmplsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, SImode, operand1)); -} - -rtx -gen_one_cmplhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, HImode, operand1)); -} - -rtx -gen_one_cmplqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, QImode, operand1)); -} - -rtx -gen_ashldi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (GET_CODE (operands[2]) != CONST_INT - || ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')) - { - operands[2] = copy_to_mode_reg (QImode, operands[2]); - emit_insn (gen_ashldi3_non_const_int (operands[0], operands[1], - operands[2])); - } - else - emit_insn (gen_ashldi3_const_int (operands[0], operands[1], operands[2])); - - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, DImode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_ashldi3_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, DImode, operand1, operand2)); -} - -rtx -gen_ashldi3_non_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, DImode, operand1, operand2)), - gen_rtx (CLOBBER, VOIDmode, operand2))); -} - -rtx -gen_ashlsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, SImode, operand1, operand2)); -} - -rtx -gen_ashlhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, HImode, operand1, operand2)); -} - -rtx -gen_ashlqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, QImode, operand1, operand2)); -} - -rtx -gen_ashrdi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (GET_CODE (operands[2]) != CONST_INT - || ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')) - { - operands[2] = copy_to_mode_reg (QImode, operands[2]); - emit_insn (gen_ashrdi3_non_const_int (operands[0], operands[1], - operands[2])); - } - else - emit_insn (gen_ashrdi3_const_int (operands[0], operands[1], operands[2])); - - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, DImode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_ashrdi3_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, DImode, operand1, operand2)); -} - -rtx -gen_ashrdi3_non_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, DImode, operand1, operand2)), - gen_rtx (CLOBBER, VOIDmode, operand2))); -} - -rtx -gen_ashrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, SImode, operand1, operand2)); -} - -rtx -gen_ashrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, HImode, operand1, operand2)); -} - -rtx -gen_ashrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, QImode, operand1, operand2)); -} - -rtx -gen_lshrdi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (GET_CODE (operands[2]) != CONST_INT - || ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')) - { - operands[2] = copy_to_mode_reg (QImode, operands[2]); - emit_insn (gen_lshrdi3_non_const_int (operands[0], operands[1], - operands[2])); - } - else - emit_insn (gen_lshrdi3_const_int (operands[0], operands[1], operands[2])); - - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, DImode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_lshrdi3_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, DImode, operand1, operand2)); -} - -rtx -gen_lshrdi3_non_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, DImode, operand1, operand2)), - gen_rtx (CLOBBER, VOIDmode, operand2))); -} - -rtx -gen_lshrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, SImode, operand1, operand2)); -} - -rtx -gen_lshrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, HImode, operand1, operand2)); -} - -rtx -gen_lshrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, QImode, operand1, operand2)); -} - -rtx -gen_rotlsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, SImode, operand1, operand2)); -} - -rtx -gen_rotlhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, HImode, operand1, operand2)); -} - -rtx -gen_rotlqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, QImode, operand1, operand2)); -} - -rtx -gen_rotrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, SImode, operand1, operand2)); -} - -rtx -gen_rotrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, HImode, operand1, operand2)); -} - -rtx -gen_rotrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, QImode, operand1, operand2)); -} - -rtx -gen_seq (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_IEEE_FP - && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) - operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); - else - operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (EQ, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sne (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_IEEE_FP - && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) - operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); - else - operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (NE, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sgt (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (GT, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sgtu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (GTU, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_slt (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (LT, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sltu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (LTU, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sge (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (GE, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sgeu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (GEU, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sle (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (LE, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sleu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (LEU, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_beq (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_IEEE_FP - && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) - operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); - else - operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (EQ, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bne (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_IEEE_FP - && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) - operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); - else - operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (NE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bgt (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GT, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bgtu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GTU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_blt (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LT, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bltu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LTU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bge (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bgeu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GEU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_ble (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bleu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LEU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_jump (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (LABEL_REF, VOIDmode, operand0)); -} - -rtx -gen_indirect_jump (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, operand0); -} - -rtx -gen_casesi (operand0, operand1, operand2, operand3, operand4) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; - rtx operand4; -{ - rtx operand5; - rtx operands[6]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - operands[4] = operand4; - -{ - operands[5] = gen_reg_rtx (SImode); - current_function_uses_pic_offset_table = 1; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - emit_insn (gen_rtx (SET, VOIDmode, operand5, gen_rtx (MINUS, SImode, operand0, operand1))); - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, CCmode, operand5, operand2))); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GTU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand4), pc_rtx))); - emit_jump_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (MINUS, SImode, gen_rtx (REG, SImode, 3), gen_rtx (MEM, SImode, gen_rtx (PLUS, SImode, gen_rtx (MULT, SImode, operand5, GEN_INT (4)), gen_rtx (LABEL_REF, VOIDmode, operand3))))), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tablejump (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, pc_rtx, operand0), - gen_rtx (USE, VOIDmode, gen_rtx (LABEL_REF, VOIDmode, operand1)))); -} - -rtx -gen_call_pop (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - rtx operands[4]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - -{ - rtx addr; - - if (flag_pic) - current_function_uses_pic_offset_table = 1; - - /* With half-pic, force the address into a register. */ - addr = XEXP (operands[0], 0); - if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) - XEXP (operands[0], 0) = force_reg (Pmode, addr); - - if (! expander_call_insn_operand (operands[0], QImode)) - operands[0] - = change_address (operands[0], VOIDmode, - copy_to_mode_reg (Pmode, XEXP (operands[0], 0))); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - emit_call_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (CALL, VOIDmode, operand0, operand1), - gen_rtx (SET, VOIDmode, gen_rtx (REG, SImode, 7), gen_rtx (PLUS, SImode, gen_rtx (REG, SImode, 7), operand3))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_call (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - rtx addr; - - if (flag_pic) - current_function_uses_pic_offset_table = 1; - - /* With half-pic, force the address into a register. */ - addr = XEXP (operands[0], 0); - if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) - XEXP (operands[0], 0) = force_reg (Pmode, addr); - - if (! expander_call_insn_operand (operands[0], QImode)) - operands[0] - = change_address (operands[0], VOIDmode, - copy_to_mode_reg (Pmode, XEXP (operands[0], 0))); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_call_insn (gen_rtx (CALL, VOIDmode, operand0, operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_call_value_pop (operand0, operand1, operand2, operand3, operand4) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; - rtx operand4; -{ - rtx operands[5]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - operands[4] = operand4; - -{ - rtx addr; - - if (flag_pic) - current_function_uses_pic_offset_table = 1; - - /* With half-pic, force the address into a register. */ - addr = XEXP (operands[1], 0); - if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) - XEXP (operands[1], 0) = force_reg (Pmode, addr); - - if (! expander_call_insn_operand (operands[1], QImode)) - operands[1] - = change_address (operands[1], VOIDmode, - copy_to_mode_reg (Pmode, XEXP (operands[1], 0))); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - emit_call_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (CALL, VOIDmode, operand1, operand2)), - gen_rtx (SET, VOIDmode, gen_rtx (REG, SImode, 7), gen_rtx (PLUS, SImode, gen_rtx (REG, SImode, 7), operand4))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_call_value (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - rtx addr; - - if (flag_pic) - current_function_uses_pic_offset_table = 1; - - /* With half-pic, force the address into a register. */ - addr = XEXP (operands[1], 0); - if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) - XEXP (operands[1], 0) = force_reg (Pmode, addr); - - if (! expander_call_insn_operand (operands[1], QImode)) - operands[1] - = change_address (operands[1], VOIDmode, - copy_to_mode_reg (Pmode, XEXP (operands[1], 0))); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_call_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (CALL, VOIDmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_untyped_call (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - rtx addr; - - if (flag_pic) - current_function_uses_pic_offset_table = 1; - - /* With half-pic, force the address into a register. */ - addr = XEXP (operands[0], 0); - if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) - XEXP (operands[0], 0) = force_reg (Pmode, addr); - - operands[1] = change_address (operands[1], DImode, XEXP (operands[1], 0)); - if (! expander_call_insn_operand (operands[1], QImode)) - operands[1] - = change_address (operands[1], VOIDmode, - copy_to_mode_reg (Pmode, XEXP (operands[1], 0))); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_call_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3, - gen_rtx (CALL, VOIDmode, operand0, const0_rtx), - operand1, - operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_untyped_return (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - rtx valreg1 = gen_rtx (REG, SImode, 0); - rtx valreg2 = gen_rtx (REG, SImode, 1); - rtx result = operands[0]; - - /* Restore the FPU state. */ - emit_insn (gen_update_return (change_address (result, SImode, - plus_constant (XEXP (result, 0), - 8)))); - - /* Reload the function value registers. */ - emit_move_insn (valreg1, change_address (result, SImode, XEXP (result, 0))); - emit_move_insn (valreg2, - change_address (result, SImode, - plus_constant (XEXP (result, 0), 4))); - - /* Put USE insns before the return. */ - emit_insn (gen_rtx (USE, VOIDmode, valreg1)); - emit_insn (gen_rtx (USE, VOIDmode, valreg2)); - - /* Construct the return. */ - expand_null_return (); - - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand0); - emit (operand1); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_update_return (operand0) - rtx operand0; -{ - return gen_rtx (UNSPEC, SImode, gen_rtvec (1, - operand0), 0); -} - -rtx -gen_return () -{ - return gen_rtx (RETURN, VOIDmode); -} - -rtx -gen_nop () -{ - return const0_rtx; -} - -rtx -gen_movstrsi (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - rtx operand4; - rtx operand5; - rtx operand6; - rtx operands[7]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - -{ - rtx addr0, addr1; - - if (GET_CODE (operands[2]) != CONST_INT) - FAIL; - - addr0 = copy_to_mode_reg (Pmode, XEXP (operands[0], 0)); - addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0)); - - operands[5] = addr0; - operands[6] = addr1; - - operands[0] = gen_rtx (MEM, BLKmode, addr0); - operands[1] = gen_rtx (MEM, BLKmode, addr1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - operand6 = operands[6]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (6, - gen_rtx (SET, VOIDmode, operand0, operand1), - gen_rtx (USE, VOIDmode, operand2), - gen_rtx (USE, VOIDmode, operand3), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)), - gen_rtx (CLOBBER, VOIDmode, operand5), - gen_rtx (CLOBBER, VOIDmode, operand6)))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpstrsi (operand0, operand1, operand2, operand3, operand4) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; - rtx operand4; -{ - rtx operand5; - rtx operand6; - rtx operands[7]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - operands[4] = operand4; - -{ - rtx addr1, addr2; - - addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0)); - addr2 = copy_to_mode_reg (Pmode, XEXP (operands[2], 0)); - operands[3] = copy_to_mode_reg (SImode, operands[3]); - - operands[5] = addr1; - operands[6] = addr2; - - operands[1] = gen_rtx (MEM, BLKmode, addr1); - operands[2] = gen_rtx (MEM, BLKmode, addr2); - -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - operand6 = operands[6]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (6, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (COMPARE, SImode, operand1, operand2)), - gen_rtx (USE, VOIDmode, operand3), - gen_rtx (USE, VOIDmode, operand4), - gen_rtx (CLOBBER, VOIDmode, operand5), - gen_rtx (CLOBBER, VOIDmode, operand6), - gen_rtx (CLOBBER, VOIDmode, operand3)))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_ffssi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operands[4]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; -operands[3] = gen_reg_rtx (SImode); - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand3, gen_rtx (PLUS, SImode, gen_rtx (FFS, SImode, operand1), constm1_rtx)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SImode, operand3, const1_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_ffshi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operands[4]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; -operands[3] = gen_reg_rtx (HImode); - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand3, gen_rtx (PLUS, HImode, gen_rtx (FFS, HImode, operand1), constm1_rtx)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0))))); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, HImode, operand3, const1_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_strlensi (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - rtx operand4; - rtx operand5; - rtx operands[6]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - -{ - operands[1] = copy_to_mode_reg (SImode, XEXP (operands[1], 0)); - operands[4] = gen_reg_rtx (SImode); - operands[5] = gen_reg_rtx (SImode); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand4, gen_rtx (UNSPEC, SImode, gen_rtvec (3, - gen_rtx (MEM, BLKmode, operand1), - operand2, - operand3), 0)), - gen_rtx (CLOBBER, VOIDmode, operand1)))); - emit_insn (gen_rtx (SET, VOIDmode, operand5, gen_rtx (NOT, SImode, operand4))); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, SImode, operand5, const1_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - - - -void -add_clobbers (pattern, insn_code_number) - rtx pattern; - int insn_code_number; -{ - int i; - - switch (insn_code_number) - { - case 250: - case 223: - XVECEXP (pattern, 0, 1) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - break; - - case 72: - case 71: - XVECEXP (pattern, 0, 3) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - break; - - case 68: - case 67: - XVECEXP (pattern, 0, 4) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - break; - - case 252: - case 25: - case 24: - case 23: - case 22: - case 21: - case 20: - case 19: - case 18: - case 17: - case 16: - case 8: - case 6: - XVECEXP (pattern, 0, 1) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)); - break; - - default: - abort (); - } -} - -void -init_mov_optab () -{ -#ifdef HAVE_movccfpeq - if (HAVE_movccfpeq) - mov_optab->handlers[(int) CCFPEQmode].insn_code = CODE_FOR_movccfpeq; -#endif -} diff --git a/gnu/usr.bin/gcc2/common/insn-extract.c b/gnu/usr.bin/gcc2/common/insn-extract.c deleted file mode 100644 index f645b830af87..000000000000 --- a/gnu/usr.bin/gcc2/common/insn-extract.c +++ /dev/null @@ -1,505 +0,0 @@ -/* Generated automatically by the program `genextract' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" - -static rtx junk; -extern rtx recog_operand[]; -extern rtx *recog_operand_loc[]; -extern rtx *recog_dup_loc[]; -extern char recog_dup_num[]; -extern -#ifdef __GNUC__ -__volatile__ -#endif -void fatal_insn_not_found (); - -void -insn_extract (insn) - rtx insn; -{ - register rtx *ro = recog_operand; - register rtx **ro_loc = recog_operand_loc; - rtx pat = PATTERN (insn); - switch (INSN_CODE (insn)) - { - case -1: - fatal_insn_not_found (insn); - - case 262: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0, 0), 0)); - ro[2] = *(ro_loc[2] = &XVECEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0, 1)); - ro[3] = *(ro_loc[3] = &XVECEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0, 2)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 1; - break; - - case 260: - case 257: - case 256: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (pat, 1)); - break; - - case 259: - case 255: - case 254: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (pat, 1)); - break; - - case 258: - case 253: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (pat, 1)); - break; - - case 252: - case 250: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 248: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 2), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 5), 0); - recog_dup_num[0] = 2; - recog_dup_loc[1] = &XEXP (XVECEXP (pat, 0, 4), 0); - recog_dup_num[1] = 1; - recog_dup_loc[2] = &XEXP (XVECEXP (pat, 0, 3), 0); - recog_dup_num[2] = 0; - break; - - case 247: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - ro[4] = *(ro_loc[4] = &XEXP (XVECEXP (pat, 0, 2), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 5), 0); - recog_dup_num[0] = 3; - recog_dup_loc[1] = &XEXP (XVECEXP (pat, 0, 4), 0); - recog_dup_num[1] = 2; - recog_dup_loc[2] = &XEXP (XVECEXP (pat, 0, 3), 0); - recog_dup_num[2] = 1; - break; - - case 245: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 2), 0)); - ro[4] = *(ro_loc[4] = &XEXP (XVECEXP (pat, 0, 3), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 5), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XVECEXP (pat, 0, 4), 0); - recog_dup_num[1] = 0; - break; - - case 243: - case 242: - break; - - case 241: - ro[0] = *(ro_loc[0] = &XVECEXP (pat, 0, 0)); - break; - - case 239: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 0), 0)); - ro[1] = *(ro_loc[1] = &XVECEXP (pat, 0, 1)); - ro[2] = *(ro_loc[2] = &XVECEXP (pat, 0, 2)); - break; - - case 238: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XVECEXP (pat, 0, 1)); - ro[2] = *(ro_loc[2] = &XVECEXP (pat, 0, 2)); - break; - - case 236: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 233: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = const0_rtx; - ro_loc[3] = &junk; - ro[4] = *(ro_loc[4] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1)); - break; - - case 232: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = const0_rtx; - ro_loc[3] = &junk; - ro[4] = *(ro_loc[4] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1)); - break; - - case 227: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[2] = const0_rtx; - ro_loc[2] = &junk; - ro[3] = *(ro_loc[3] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1)); - break; - - case 226: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[2] = const0_rtx; - ro_loc[2] = &junk; - ro[3] = *(ro_loc[3] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1)); - break; - - case 224: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 0), 0)); - break; - - case 223: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 220: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - break; - - case 219: - case 218: - case 217: - case 216: - case 215: - case 214: - case 213: - case 212: - case 211: - case 210: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (pat, 1), 2), 0)); - break; - - case 209: - case 207: - case 205: - case 203: - case 201: - case 199: - case 197: - case 195: - case 193: - case 191: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - break; - - case 189: - case 187: - case 185: - case 183: - case 181: - case 179: - case 177: - case 175: - case 173: - case 171: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - break; - - case 169: - case 168: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 2)); - break; - - case 167: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 2)); - break; - - case 166: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 1)); - break; - - case 165: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 164: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = const0_rtx; - ro_loc[1] = &junk; - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 0), 2)); - ro[3] = *(ro_loc[3] = &XEXP (pat, 1)); - break; - - case 154: - case 148: - case 142: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 2; - break; - - case 136: - case 133: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (XEXP (pat, 1), 0, 0), 0)); - break; - - case 135: - case 134: - case 132: - case 131: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XVECEXP (XEXP (pat, 1), 0, 0)); - break; - - case 130: - case 127: - case 124: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - break; - - case 108: - case 107: - case 106: - case 105: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - recog_dup_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1); - recog_dup_num[1] = 2; - break; - - case 98: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - break; - - case 235: - case 163: - case 162: - case 161: - case 160: - case 159: - case 158: - case 157: - case 156: - case 155: - case 153: - case 151: - case 150: - case 149: - case 147: - case 145: - case 144: - case 143: - case 141: - case 117: - case 116: - case 115: - case 114: - case 113: - case 112: - case 111: - case 110: - case 109: - case 102: - case 101: - case 97: - case 96: - case 95: - case 94: - case 91: - case 90: - case 89: - case 88: - case 84: - case 83: - case 82: - case 81: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 72: - case 71: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 2), 0)); - ro[4] = *(ro_loc[4] = &XEXP (XVECEXP (pat, 0, 3), 0)); - break; - - case 68: - case 67: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 2), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 3), 0)); - ro[4] = *(ro_loc[4] = &XEXP (XVECEXP (pat, 0, 4), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 1; - break; - - case 62: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 139: - case 138: - case 137: - case 129: - case 128: - case 126: - case 125: - case 123: - case 122: - case 121: - case 120: - case 119: - case 118: - case 80: - case 79: - case 78: - case 77: - case 60: - case 59: - case 58: - case 57: - case 56: - case 55: - case 54: - case 53: - case 52: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - break; - - case 48: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (pat, 0, 0), 1)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XVECEXP (pat, 0, 1), 1); - recog_dup_num[1] = 0; - break; - - case 230: - case 44: - case 41: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (pat, 1)); - break; - - case 229: - case 85: - case 51: - case 50: - case 49: - case 47: - case 46: - case 45: - case 43: - case 42: - case 40: - case 39: - case 38: - case 36: - case 35: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (pat, 1)); - break; - - case 25: - case 21: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 24: - case 20: - case 18: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 23: - case 19: - case 17: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 22: - case 16: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 34: - case 33: - case 32: - case 14: - case 12: - case 10: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 8: - case 6: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 221: - case 4: - case 2: - case 0: - ro[0] = *(ro_loc[0] = &XEXP (pat, 1)); - break; - - default: - abort (); - } -} diff --git a/gnu/usr.bin/gcc2/common/insn-flags.h b/gnu/usr.bin/gcc2/common/insn-flags.h deleted file mode 100644 index 9070b93d11e8..000000000000 --- a/gnu/usr.bin/gcc2/common/insn-flags.h +++ /dev/null @@ -1,510 +0,0 @@ -/* Generated automatically by the program `genflags' -from the machine description file `md'. */ - -#define HAVE_tstsi_1 1 -#define HAVE_tstsi 1 -#define HAVE_tsthi_1 1 -#define HAVE_tsthi 1 -#define HAVE_tstqi_1 1 -#define HAVE_tstqi 1 -#define HAVE_tstsf_cc (TARGET_80387 && ! TARGET_IEEE_FP) -#define HAVE_tstsf (TARGET_80387 && ! TARGET_IEEE_FP) -#define HAVE_tstdf_cc (TARGET_80387 && ! TARGET_IEEE_FP) -#define HAVE_tstdf (TARGET_80387 && ! TARGET_IEEE_FP) -#define HAVE_cmpsi_1 (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) -#define HAVE_cmpsi 1 -#define HAVE_cmphi_1 (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) -#define HAVE_cmphi 1 -#define HAVE_cmpqi_1 (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) -#define HAVE_cmpqi 1 -#define HAVE_cmpsf_cc_1 (TARGET_80387 \ - && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)) -#define HAVE_cmpdf (TARGET_80387) -#define HAVE_cmpsf (TARGET_80387) -#define HAVE_cmpdf_cc (TARGET_80387) -#define HAVE_cmpdf_ccfpeq (TARGET_80387) -#define HAVE_cmpsf_cc (TARGET_80387) -#define HAVE_cmpsf_ccfpeq (TARGET_80387) -#define HAVE_movsi 1 -#define HAVE_movhi 1 -#define HAVE_movstricthi 1 -#define HAVE_movqi 1 -#define HAVE_movstrictqi 1 -#define HAVE_movsf 1 -#define HAVE_swapdf 1 -#define HAVE_movdf 1 -#define HAVE_movdi 1 -#define HAVE_zero_extendhisi2 1 -#define HAVE_zero_extendqihi2 1 -#define HAVE_zero_extendqisi2 1 -#define HAVE_zero_extendsidi2 1 -#define HAVE_extendsidi2 1 -#define HAVE_extendhisi2 1 -#define HAVE_extendqihi2 1 -#define HAVE_extendqisi2 1 -#define HAVE_extendsfdf2 (TARGET_80387) -#define HAVE_truncdfsf2 (TARGET_80387) -#define HAVE_fixuns_truncdfsi2 (TARGET_80387) -#define HAVE_fixuns_truncsfsi2 (TARGET_80387) -#define HAVE_fix_truncdfdi2 (TARGET_80387) -#define HAVE_fix_truncsfdi2 (TARGET_80387) -#define HAVE_fix_truncdfsi2 (TARGET_80387) -#define HAVE_fix_truncsfsi2 (TARGET_80387) -#define HAVE_floatsisf2 (TARGET_80387) -#define HAVE_floatdisf2 (TARGET_80387) -#define HAVE_floatsidf2 (TARGET_80387) -#define HAVE_floatdidf2 (TARGET_80387) -#define HAVE_adddi3 1 -#define HAVE_addsi3 1 -#define HAVE_addhi3 1 -#define HAVE_addqi3 1 -#define HAVE_adddf3 (TARGET_80387) -#define HAVE_addsf3 (TARGET_80387) -#define HAVE_subdi3 1 -#define HAVE_subsi3 1 -#define HAVE_subhi3 1 -#define HAVE_subqi3 1 -#define HAVE_subdf3 (TARGET_80387) -#define HAVE_subsf3 (TARGET_80387) -#define HAVE_mulhi3 1 -#define HAVE_mulsi3 1 -#define HAVE_muldf3 (TARGET_80387) -#define HAVE_mulsf3 (TARGET_80387) -#define HAVE_divqi3 1 -#define HAVE_udivqi3 1 -#define HAVE_divdf3 (TARGET_80387) -#define HAVE_divsf3 (TARGET_80387) -#define HAVE_divmodsi4 1 -#define HAVE_divmodhi4 1 -#define HAVE_udivmodsi4 1 -#define HAVE_udivmodhi4 1 -#define HAVE_andsi3 1 -#define HAVE_andhi3 1 -#define HAVE_andqi3 1 -#define HAVE_iorsi3 1 -#define HAVE_iorhi3 1 -#define HAVE_iorqi3 1 -#define HAVE_xorsi3 1 -#define HAVE_xorhi3 1 -#define HAVE_xorqi3 1 -#define HAVE_negdi2 1 -#define HAVE_negsi2 1 -#define HAVE_neghi2 1 -#define HAVE_negqi2 1 -#define HAVE_negsf2 (TARGET_80387) -#define HAVE_negdf2 (TARGET_80387) -#define HAVE_abssf2 (TARGET_80387) -#define HAVE_absdf2 (TARGET_80387) -#define HAVE_sqrtsf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) -#define HAVE_sqrtdf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) -#define HAVE_sindf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) -#define HAVE_sinsf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) -#define HAVE_cosdf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) -#define HAVE_cossf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) -#define HAVE_one_cmplsi2 1 -#define HAVE_one_cmplhi2 1 -#define HAVE_one_cmplqi2 1 -#define HAVE_ashldi3 1 -#define HAVE_ashldi3_const_int 1 -#define HAVE_ashldi3_non_const_int 1 -#define HAVE_ashlsi3 1 -#define HAVE_ashlhi3 1 -#define HAVE_ashlqi3 1 -#define HAVE_ashrdi3 1 -#define HAVE_ashrdi3_const_int 1 -#define HAVE_ashrdi3_non_const_int 1 -#define HAVE_ashrsi3 1 -#define HAVE_ashrhi3 1 -#define HAVE_ashrqi3 1 -#define HAVE_lshrdi3 1 -#define HAVE_lshrdi3_const_int 1 -#define HAVE_lshrdi3_non_const_int 1 -#define HAVE_lshrsi3 1 -#define HAVE_lshrhi3 1 -#define HAVE_lshrqi3 1 -#define HAVE_rotlsi3 1 -#define HAVE_rotlhi3 1 -#define HAVE_rotlqi3 1 -#define HAVE_rotrsi3 1 -#define HAVE_rotrhi3 1 -#define HAVE_rotrqi3 1 -#define HAVE_seq 1 -#define HAVE_sne 1 -#define HAVE_sgt 1 -#define HAVE_sgtu 1 -#define HAVE_slt 1 -#define HAVE_sltu 1 -#define HAVE_sge 1 -#define HAVE_sgeu 1 -#define HAVE_sle 1 -#define HAVE_sleu 1 -#define HAVE_beq 1 -#define HAVE_bne 1 -#define HAVE_bgt 1 -#define HAVE_bgtu 1 -#define HAVE_blt 1 -#define HAVE_bltu 1 -#define HAVE_bge 1 -#define HAVE_bgeu 1 -#define HAVE_ble 1 -#define HAVE_bleu 1 -#define HAVE_jump 1 -#define HAVE_indirect_jump 1 -#define HAVE_casesi (flag_pic) -#define HAVE_tablejump 1 -#define HAVE_call_pop 1 -#define HAVE_call 1 -#define HAVE_call_value_pop 1 -#define HAVE_call_value 1 -#define HAVE_untyped_call 1 -#define HAVE_untyped_return 1 -#define HAVE_update_return 1 -#define HAVE_return (simple_386_epilogue ()) -#define HAVE_nop 1 -#define HAVE_movstrsi 1 -#define HAVE_cmpstrsi 1 -#define HAVE_ffssi2 1 -#define HAVE_ffshi2 1 -#define HAVE_strlensi 1 - -#ifndef NO_MD_PROTOTYPES -extern rtx gen_tstsi_1 PROTO((rtx)); -extern rtx gen_tstsi PROTO((rtx)); -extern rtx gen_tsthi_1 PROTO((rtx)); -extern rtx gen_tsthi PROTO((rtx)); -extern rtx gen_tstqi_1 PROTO((rtx)); -extern rtx gen_tstqi PROTO((rtx)); -extern rtx gen_tstsf_cc PROTO((rtx)); -extern rtx gen_tstsf PROTO((rtx)); -extern rtx gen_tstdf_cc PROTO((rtx)); -extern rtx gen_tstdf PROTO((rtx)); -extern rtx gen_cmpsi_1 PROTO((rtx, rtx)); -extern rtx gen_cmpsi PROTO((rtx, rtx)); -extern rtx gen_cmphi_1 PROTO((rtx, rtx)); -extern rtx gen_cmphi PROTO((rtx, rtx)); -extern rtx gen_cmpqi_1 PROTO((rtx, rtx)); -extern rtx gen_cmpqi PROTO((rtx, rtx)); -extern rtx gen_cmpsf_cc_1 PROTO((rtx, rtx, rtx)); -extern rtx gen_cmpdf PROTO((rtx, rtx)); -extern rtx gen_cmpsf PROTO((rtx, rtx)); -extern rtx gen_cmpdf_cc PROTO((rtx, rtx)); -extern rtx gen_cmpdf_ccfpeq PROTO((rtx, rtx)); -extern rtx gen_cmpsf_cc PROTO((rtx, rtx)); -extern rtx gen_cmpsf_ccfpeq PROTO((rtx, rtx)); -extern rtx gen_movsi PROTO((rtx, rtx)); -extern rtx gen_movhi PROTO((rtx, rtx)); -extern rtx gen_movstricthi PROTO((rtx, rtx)); -extern rtx gen_movqi PROTO((rtx, rtx)); -extern rtx gen_movstrictqi PROTO((rtx, rtx)); -extern rtx gen_movsf PROTO((rtx, rtx)); -extern rtx gen_swapdf PROTO((rtx, rtx)); -extern rtx gen_movdf PROTO((rtx, rtx)); -extern rtx gen_movdi PROTO((rtx, rtx)); -extern rtx gen_zero_extendhisi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendqihi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendqisi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendsidi2 PROTO((rtx, rtx)); -extern rtx gen_extendsidi2 PROTO((rtx, rtx)); -extern rtx gen_extendhisi2 PROTO((rtx, rtx)); -extern rtx gen_extendqihi2 PROTO((rtx, rtx)); -extern rtx gen_extendqisi2 PROTO((rtx, rtx)); -extern rtx gen_extendsfdf2 PROTO((rtx, rtx)); -extern rtx gen_truncdfsf2 PROTO((rtx, rtx)); -extern rtx gen_fixuns_truncdfsi2 PROTO((rtx, rtx)); -extern rtx gen_fixuns_truncsfsi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncdfdi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncsfdi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncdfsi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncsfsi2 PROTO((rtx, rtx)); -extern rtx gen_floatsisf2 PROTO((rtx, rtx)); -extern rtx gen_floatdisf2 PROTO((rtx, rtx)); -extern rtx gen_floatsidf2 PROTO((rtx, rtx)); -extern rtx gen_floatdidf2 PROTO((rtx, rtx)); -extern rtx gen_adddi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_adddf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subdi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subdf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_muldf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_udivqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divdf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divmodsi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_divmodhi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_udivmodsi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_udivmodhi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_andsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_andhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_andqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_negdi2 PROTO((rtx, rtx)); -extern rtx gen_negsi2 PROTO((rtx, rtx)); -extern rtx gen_neghi2 PROTO((rtx, rtx)); -extern rtx gen_negqi2 PROTO((rtx, rtx)); -extern rtx gen_negsf2 PROTO((rtx, rtx)); -extern rtx gen_negdf2 PROTO((rtx, rtx)); -extern rtx gen_abssf2 PROTO((rtx, rtx)); -extern rtx gen_absdf2 PROTO((rtx, rtx)); -extern rtx gen_sqrtsf2 PROTO((rtx, rtx)); -extern rtx gen_sqrtdf2 PROTO((rtx, rtx)); -extern rtx gen_sindf2 PROTO((rtx, rtx)); -extern rtx gen_sinsf2 PROTO((rtx, rtx)); -extern rtx gen_cosdf2 PROTO((rtx, rtx)); -extern rtx gen_cossf2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplsi2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplhi2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplqi2 PROTO((rtx, rtx)); -extern rtx gen_ashldi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashldi3_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_ashldi3_non_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_ashlsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashlhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashlqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrdi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrdi3_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrdi3_non_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrdi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrdi3_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrdi3_non_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_seq PROTO((rtx)); -extern rtx gen_sne PROTO((rtx)); -extern rtx gen_sgt PROTO((rtx)); -extern rtx gen_sgtu PROTO((rtx)); -extern rtx gen_slt PROTO((rtx)); -extern rtx gen_sltu PROTO((rtx)); -extern rtx gen_sge PROTO((rtx)); -extern rtx gen_sgeu PROTO((rtx)); -extern rtx gen_sle PROTO((rtx)); -extern rtx gen_sleu PROTO((rtx)); -extern rtx gen_beq PROTO((rtx)); -extern rtx gen_bne PROTO((rtx)); -extern rtx gen_bgt PROTO((rtx)); -extern rtx gen_bgtu PROTO((rtx)); -extern rtx gen_blt PROTO((rtx)); -extern rtx gen_bltu PROTO((rtx)); -extern rtx gen_bge PROTO((rtx)); -extern rtx gen_bgeu PROTO((rtx)); -extern rtx gen_ble PROTO((rtx)); -extern rtx gen_bleu PROTO((rtx)); -extern rtx gen_jump PROTO((rtx)); -extern rtx gen_indirect_jump PROTO((rtx)); -extern rtx gen_casesi PROTO((rtx, rtx, rtx, rtx, rtx)); -extern rtx gen_tablejump PROTO((rtx, rtx)); -extern rtx gen_untyped_call PROTO((rtx, rtx, rtx)); -extern rtx gen_untyped_return PROTO((rtx, rtx)); -extern rtx gen_update_return PROTO((rtx)); -extern rtx gen_return PROTO((void)); -extern rtx gen_nop PROTO((void)); -extern rtx gen_movstrsi PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_cmpstrsi PROTO((rtx, rtx, rtx, rtx, rtx)); -extern rtx gen_ffssi2 PROTO((rtx, rtx)); -extern rtx gen_ffshi2 PROTO((rtx, rtx)); -extern rtx gen_strlensi PROTO((rtx, rtx, rtx, rtx)); - -#ifdef MD_CALL_PROTOTYPES -extern rtx gen_call_pop PROTO((rtx, rtx, rtx)); -extern rtx gen_call PROTO((rtx, rtx)); -extern rtx gen_call_value_pop PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_call_value PROTO((rtx, rtx, rtx)); - -#else /* !MD_CALL_PROTOTYPES */ -extern rtx gen_call_pop (); -extern rtx gen_call (); -extern rtx gen_call_value_pop (); -extern rtx gen_call_value (); -#endif /* !MD_CALL_PROTOTYPES */ - -#else /* NO_MD_PROTOTYPES */ -extern rtx gen_tstsi_1 (); -extern rtx gen_tstsi (); -extern rtx gen_tsthi_1 (); -extern rtx gen_tsthi (); -extern rtx gen_tstqi_1 (); -extern rtx gen_tstqi (); -extern rtx gen_tstsf_cc (); -extern rtx gen_tstsf (); -extern rtx gen_tstdf_cc (); -extern rtx gen_tstdf (); -extern rtx gen_cmpsi_1 (); -extern rtx gen_cmpsi (); -extern rtx gen_cmphi_1 (); -extern rtx gen_cmphi (); -extern rtx gen_cmpqi_1 (); -extern rtx gen_cmpqi (); -extern rtx gen_cmpsf_cc_1 (); -extern rtx gen_cmpdf (); -extern rtx gen_cmpsf (); -extern rtx gen_cmpdf_cc (); -extern rtx gen_cmpdf_ccfpeq (); -extern rtx gen_cmpsf_cc (); -extern rtx gen_cmpsf_ccfpeq (); -extern rtx gen_movsi (); -extern rtx gen_movhi (); -extern rtx gen_movstricthi (); -extern rtx gen_movqi (); -extern rtx gen_movstrictqi (); -extern rtx gen_movsf (); -extern rtx gen_swapdf (); -extern rtx gen_movdf (); -extern rtx gen_movdi (); -extern rtx gen_zero_extendhisi2 (); -extern rtx gen_zero_extendqihi2 (); -extern rtx gen_zero_extendqisi2 (); -extern rtx gen_zero_extendsidi2 (); -extern rtx gen_extendsidi2 (); -extern rtx gen_extendhisi2 (); -extern rtx gen_extendqihi2 (); -extern rtx gen_extendqisi2 (); -extern rtx gen_extendsfdf2 (); -extern rtx gen_truncdfsf2 (); -extern rtx gen_fixuns_truncdfsi2 (); -extern rtx gen_fixuns_truncsfsi2 (); -extern rtx gen_fix_truncdfdi2 (); -extern rtx gen_fix_truncsfdi2 (); -extern rtx gen_fix_truncdfsi2 (); -extern rtx gen_fix_truncsfsi2 (); -extern rtx gen_floatsisf2 (); -extern rtx gen_floatdisf2 (); -extern rtx gen_floatsidf2 (); -extern rtx gen_floatdidf2 (); -extern rtx gen_adddi3 (); -extern rtx gen_addsi3 (); -extern rtx gen_addhi3 (); -extern rtx gen_addqi3 (); -extern rtx gen_adddf3 (); -extern rtx gen_addsf3 (); -extern rtx gen_subdi3 (); -extern rtx gen_subsi3 (); -extern rtx gen_subhi3 (); -extern rtx gen_subqi3 (); -extern rtx gen_subdf3 (); -extern rtx gen_subsf3 (); -extern rtx gen_mulhi3 (); -extern rtx gen_mulsi3 (); -extern rtx gen_muldf3 (); -extern rtx gen_mulsf3 (); -extern rtx gen_divqi3 (); -extern rtx gen_udivqi3 (); -extern rtx gen_divdf3 (); -extern rtx gen_divsf3 (); -extern rtx gen_divmodsi4 (); -extern rtx gen_divmodhi4 (); -extern rtx gen_udivmodsi4 (); -extern rtx gen_udivmodhi4 (); -extern rtx gen_andsi3 (); -extern rtx gen_andhi3 (); -extern rtx gen_andqi3 (); -extern rtx gen_iorsi3 (); -extern rtx gen_iorhi3 (); -extern rtx gen_iorqi3 (); -extern rtx gen_xorsi3 (); -extern rtx gen_xorhi3 (); -extern rtx gen_xorqi3 (); -extern rtx gen_negdi2 (); -extern rtx gen_negsi2 (); -extern rtx gen_neghi2 (); -extern rtx gen_negqi2 (); -extern rtx gen_negsf2 (); -extern rtx gen_negdf2 (); -extern rtx gen_abssf2 (); -extern rtx gen_absdf2 (); -extern rtx gen_sqrtsf2 (); -extern rtx gen_sqrtdf2 (); -extern rtx gen_sindf2 (); -extern rtx gen_sinsf2 (); -extern rtx gen_cosdf2 (); -extern rtx gen_cossf2 (); -extern rtx gen_one_cmplsi2 (); -extern rtx gen_one_cmplhi2 (); -extern rtx gen_one_cmplqi2 (); -extern rtx gen_ashldi3 (); -extern rtx gen_ashldi3_const_int (); -extern rtx gen_ashldi3_non_const_int (); -extern rtx gen_ashlsi3 (); -extern rtx gen_ashlhi3 (); -extern rtx gen_ashlqi3 (); -extern rtx gen_ashrdi3 (); -extern rtx gen_ashrdi3_const_int (); -extern rtx gen_ashrdi3_non_const_int (); -extern rtx gen_ashrsi3 (); -extern rtx gen_ashrhi3 (); -extern rtx gen_ashrqi3 (); -extern rtx gen_lshrdi3 (); -extern rtx gen_lshrdi3_const_int (); -extern rtx gen_lshrdi3_non_const_int (); -extern rtx gen_lshrsi3 (); -extern rtx gen_lshrhi3 (); -extern rtx gen_lshrqi3 (); -extern rtx gen_rotlsi3 (); -extern rtx gen_rotlhi3 (); -extern rtx gen_rotlqi3 (); -extern rtx gen_rotrsi3 (); -extern rtx gen_rotrhi3 (); -extern rtx gen_rotrqi3 (); -extern rtx gen_seq (); -extern rtx gen_sne (); -extern rtx gen_sgt (); -extern rtx gen_sgtu (); -extern rtx gen_slt (); -extern rtx gen_sltu (); -extern rtx gen_sge (); -extern rtx gen_sgeu (); -extern rtx gen_sle (); -extern rtx gen_sleu (); -extern rtx gen_beq (); -extern rtx gen_bne (); -extern rtx gen_bgt (); -extern rtx gen_bgtu (); -extern rtx gen_blt (); -extern rtx gen_bltu (); -extern rtx gen_bge (); -extern rtx gen_bgeu (); -extern rtx gen_ble (); -extern rtx gen_bleu (); -extern rtx gen_jump (); -extern rtx gen_indirect_jump (); -extern rtx gen_casesi (); -extern rtx gen_tablejump (); -extern rtx gen_untyped_call (); -extern rtx gen_untyped_return (); -extern rtx gen_update_return (); -extern rtx gen_return (); -extern rtx gen_nop (); -extern rtx gen_movstrsi (); -extern rtx gen_cmpstrsi (); -extern rtx gen_ffssi2 (); -extern rtx gen_ffshi2 (); -extern rtx gen_strlensi (); -extern rtx gen_call_pop (); -extern rtx gen_call (); -extern rtx gen_call_value_pop (); -extern rtx gen_call_value (); -#endif /* NO_MD_PROTOTYPES */ diff --git a/gnu/usr.bin/gcc2/common/insn-opinit.c b/gnu/usr.bin/gcc2/common/insn-opinit.c deleted file mode 100644 index 7959ae5fb1c9..000000000000 --- a/gnu/usr.bin/gcc2/common/insn-opinit.c +++ /dev/null @@ -1,179 +0,0 @@ -/* Generated automatically by the program `genopinit' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "flags.h" -#include "insn-flags.h" -#include "insn-codes.h" -#include "insn-config.h" -#include "recog.h" -#include "expr.h" -#include "reload.h" - -void -init_all_optabs () -{ - tst_optab->handlers[(int) SImode].insn_code = CODE_FOR_tstsi; - tst_optab->handlers[(int) HImode].insn_code = CODE_FOR_tsthi; - tst_optab->handlers[(int) QImode].insn_code = CODE_FOR_tstqi; - if (HAVE_tstsf) - tst_optab->handlers[(int) SFmode].insn_code = CODE_FOR_tstsf; - if (HAVE_tstdf) - tst_optab->handlers[(int) DFmode].insn_code = CODE_FOR_tstdf; - cmp_optab->handlers[(int) SImode].insn_code = CODE_FOR_cmpsi; - cmp_optab->handlers[(int) HImode].insn_code = CODE_FOR_cmphi; - cmp_optab->handlers[(int) QImode].insn_code = CODE_FOR_cmpqi; - if (HAVE_cmpdf) - cmp_optab->handlers[(int) DFmode].insn_code = CODE_FOR_cmpdf; - if (HAVE_cmpsf) - cmp_optab->handlers[(int) SFmode].insn_code = CODE_FOR_cmpsf; - mov_optab->handlers[(int) SImode].insn_code = CODE_FOR_movsi; - mov_optab->handlers[(int) HImode].insn_code = CODE_FOR_movhi; - movstrict_optab->handlers[(int) HImode].insn_code = CODE_FOR_movstricthi; - mov_optab->handlers[(int) QImode].insn_code = CODE_FOR_movqi; - movstrict_optab->handlers[(int) QImode].insn_code = CODE_FOR_movstrictqi; - mov_optab->handlers[(int) SFmode].insn_code = CODE_FOR_movsf; - mov_optab->handlers[(int) DFmode].insn_code = CODE_FOR_movdf; - mov_optab->handlers[(int) DImode].insn_code = CODE_FOR_movdi; - extendtab[(int) SImode][(int) HImode][1] = CODE_FOR_zero_extendhisi2; - extendtab[(int) HImode][(int) QImode][1] = CODE_FOR_zero_extendqihi2; - extendtab[(int) SImode][(int) QImode][1] = CODE_FOR_zero_extendqisi2; - extendtab[(int) DImode][(int) SImode][1] = CODE_FOR_zero_extendsidi2; - extendtab[(int) DImode][(int) SImode][0] = CODE_FOR_extendsidi2; - extendtab[(int) SImode][(int) HImode][0] = CODE_FOR_extendhisi2; - extendtab[(int) HImode][(int) QImode][0] = CODE_FOR_extendqihi2; - extendtab[(int) SImode][(int) QImode][0] = CODE_FOR_extendqisi2; - if (HAVE_extendsfdf2) - extendtab[(int) DFmode][(int) SFmode][0] = CODE_FOR_extendsfdf2; - if (HAVE_fixuns_truncdfsi2) - fixtrunctab[(int) DFmode][(int) SImode][1] = CODE_FOR_fixuns_truncdfsi2; - if (HAVE_fixuns_truncsfsi2) - fixtrunctab[(int) SFmode][(int) SImode][1] = CODE_FOR_fixuns_truncsfsi2; - if (HAVE_fix_truncdfdi2) - fixtrunctab[(int) DFmode][(int) DImode][0] = CODE_FOR_fix_truncdfdi2; - if (HAVE_fix_truncsfdi2) - fixtrunctab[(int) SFmode][(int) DImode][0] = CODE_FOR_fix_truncsfdi2; - if (HAVE_fix_truncdfsi2) - fixtrunctab[(int) DFmode][(int) SImode][0] = CODE_FOR_fix_truncdfsi2; - if (HAVE_fix_truncsfsi2) - fixtrunctab[(int) SFmode][(int) SImode][0] = CODE_FOR_fix_truncsfsi2; - if (HAVE_floatsisf2) - floattab[(int) SFmode][(int) SImode][0] = CODE_FOR_floatsisf2; - if (HAVE_floatdisf2) - floattab[(int) SFmode][(int) DImode][0] = CODE_FOR_floatdisf2; - if (HAVE_floatsidf2) - floattab[(int) DFmode][(int) SImode][0] = CODE_FOR_floatsidf2; - if (HAVE_floatdidf2) - floattab[(int) DFmode][(int) DImode][0] = CODE_FOR_floatdidf2; - add_optab->handlers[(int) DImode].insn_code = CODE_FOR_adddi3; - add_optab->handlers[(int) SImode].insn_code = CODE_FOR_addsi3; - add_optab->handlers[(int) HImode].insn_code = CODE_FOR_addhi3; - add_optab->handlers[(int) QImode].insn_code = CODE_FOR_addqi3; - if (HAVE_adddf3) - add_optab->handlers[(int) DFmode].insn_code = CODE_FOR_adddf3; - if (HAVE_addsf3) - add_optab->handlers[(int) SFmode].insn_code = CODE_FOR_addsf3; - sub_optab->handlers[(int) DImode].insn_code = CODE_FOR_subdi3; - sub_optab->handlers[(int) SImode].insn_code = CODE_FOR_subsi3; - sub_optab->handlers[(int) HImode].insn_code = CODE_FOR_subhi3; - sub_optab->handlers[(int) QImode].insn_code = CODE_FOR_subqi3; - if (HAVE_subdf3) - sub_optab->handlers[(int) DFmode].insn_code = CODE_FOR_subdf3; - if (HAVE_subsf3) - sub_optab->handlers[(int) SFmode].insn_code = CODE_FOR_subsf3; - smul_optab->handlers[(int) HImode].insn_code = CODE_FOR_mulhi3; - smul_optab->handlers[(int) SImode].insn_code = CODE_FOR_mulsi3; - if (HAVE_muldf3) - smul_optab->handlers[(int) DFmode].insn_code = CODE_FOR_muldf3; - if (HAVE_mulsf3) - smul_optab->handlers[(int) SFmode].insn_code = CODE_FOR_mulsf3; - sdiv_optab->handlers[(int) QImode].insn_code = CODE_FOR_divqi3; - udiv_optab->handlers[(int) QImode].insn_code = CODE_FOR_udivqi3; - if (HAVE_divdf3) - flodiv_optab->handlers[(int) DFmode].insn_code = CODE_FOR_divdf3; - if (HAVE_divsf3) - flodiv_optab->handlers[(int) SFmode].insn_code = CODE_FOR_divsf3; - sdivmod_optab->handlers[(int) SImode].insn_code = CODE_FOR_divmodsi4; - sdivmod_optab->handlers[(int) HImode].insn_code = CODE_FOR_divmodhi4; - udivmod_optab->handlers[(int) SImode].insn_code = CODE_FOR_udivmodsi4; - udivmod_optab->handlers[(int) HImode].insn_code = CODE_FOR_udivmodhi4; - and_optab->handlers[(int) SImode].insn_code = CODE_FOR_andsi3; - and_optab->handlers[(int) HImode].insn_code = CODE_FOR_andhi3; - and_optab->handlers[(int) QImode].insn_code = CODE_FOR_andqi3; - ior_optab->handlers[(int) SImode].insn_code = CODE_FOR_iorsi3; - ior_optab->handlers[(int) HImode].insn_code = CODE_FOR_iorhi3; - ior_optab->handlers[(int) QImode].insn_code = CODE_FOR_iorqi3; - xor_optab->handlers[(int) SImode].insn_code = CODE_FOR_xorsi3; - xor_optab->handlers[(int) HImode].insn_code = CODE_FOR_xorhi3; - xor_optab->handlers[(int) QImode].insn_code = CODE_FOR_xorqi3; - neg_optab->handlers[(int) DImode].insn_code = CODE_FOR_negdi2; - neg_optab->handlers[(int) SImode].insn_code = CODE_FOR_negsi2; - neg_optab->handlers[(int) HImode].insn_code = CODE_FOR_neghi2; - neg_optab->handlers[(int) QImode].insn_code = CODE_FOR_negqi2; - if (HAVE_negsf2) - neg_optab->handlers[(int) SFmode].insn_code = CODE_FOR_negsf2; - if (HAVE_negdf2) - neg_optab->handlers[(int) DFmode].insn_code = CODE_FOR_negdf2; - if (HAVE_abssf2) - abs_optab->handlers[(int) SFmode].insn_code = CODE_FOR_abssf2; - if (HAVE_absdf2) - abs_optab->handlers[(int) DFmode].insn_code = CODE_FOR_absdf2; - if (HAVE_sqrtsf2) - sqrt_optab->handlers[(int) SFmode].insn_code = CODE_FOR_sqrtsf2; - if (HAVE_sqrtdf2) - sqrt_optab->handlers[(int) DFmode].insn_code = CODE_FOR_sqrtdf2; - if (HAVE_sindf2) - sin_optab->handlers[(int) DFmode].insn_code = CODE_FOR_sindf2; - if (HAVE_sinsf2) - sin_optab->handlers[(int) SFmode].insn_code = CODE_FOR_sinsf2; - if (HAVE_cosdf2) - cos_optab->handlers[(int) DFmode].insn_code = CODE_FOR_cosdf2; - if (HAVE_cossf2) - cos_optab->handlers[(int) SFmode].insn_code = CODE_FOR_cossf2; - one_cmpl_optab->handlers[(int) SImode].insn_code = CODE_FOR_one_cmplsi2; - one_cmpl_optab->handlers[(int) HImode].insn_code = CODE_FOR_one_cmplhi2; - one_cmpl_optab->handlers[(int) QImode].insn_code = CODE_FOR_one_cmplqi2; - ashl_optab->handlers[(int) DImode].insn_code = CODE_FOR_ashldi3; - ashl_optab->handlers[(int) SImode].insn_code = CODE_FOR_ashlsi3; - ashl_optab->handlers[(int) HImode].insn_code = CODE_FOR_ashlhi3; - ashl_optab->handlers[(int) QImode].insn_code = CODE_FOR_ashlqi3; - ashr_optab->handlers[(int) DImode].insn_code = CODE_FOR_ashrdi3; - ashr_optab->handlers[(int) SImode].insn_code = CODE_FOR_ashrsi3; - ashr_optab->handlers[(int) HImode].insn_code = CODE_FOR_ashrhi3; - ashr_optab->handlers[(int) QImode].insn_code = CODE_FOR_ashrqi3; - lshr_optab->handlers[(int) DImode].insn_code = CODE_FOR_lshrdi3; - lshr_optab->handlers[(int) SImode].insn_code = CODE_FOR_lshrsi3; - lshr_optab->handlers[(int) HImode].insn_code = CODE_FOR_lshrhi3; - lshr_optab->handlers[(int) QImode].insn_code = CODE_FOR_lshrqi3; - rotl_optab->handlers[(int) SImode].insn_code = CODE_FOR_rotlsi3; - rotl_optab->handlers[(int) HImode].insn_code = CODE_FOR_rotlhi3; - rotl_optab->handlers[(int) QImode].insn_code = CODE_FOR_rotlqi3; - rotr_optab->handlers[(int) SImode].insn_code = CODE_FOR_rotrsi3; - rotr_optab->handlers[(int) HImode].insn_code = CODE_FOR_rotrhi3; - rotr_optab->handlers[(int) QImode].insn_code = CODE_FOR_rotrqi3; - setcc_gen_code[(int) EQ] = CODE_FOR_seq; - setcc_gen_code[(int) NE] = CODE_FOR_sne; - setcc_gen_code[(int) GT] = CODE_FOR_sgt; - setcc_gen_code[(int) GTU] = CODE_FOR_sgtu; - setcc_gen_code[(int) LT] = CODE_FOR_slt; - setcc_gen_code[(int) LTU] = CODE_FOR_sltu; - setcc_gen_code[(int) GE] = CODE_FOR_sge; - setcc_gen_code[(int) GEU] = CODE_FOR_sgeu; - setcc_gen_code[(int) LE] = CODE_FOR_sle; - setcc_gen_code[(int) LEU] = CODE_FOR_sleu; - bcc_gen_fctn[(int) EQ] = gen_beq; - bcc_gen_fctn[(int) NE] = gen_bne; - bcc_gen_fctn[(int) GT] = gen_bgt; - bcc_gen_fctn[(int) GTU] = gen_bgtu; - bcc_gen_fctn[(int) LT] = gen_blt; - bcc_gen_fctn[(int) LTU] = gen_bltu; - bcc_gen_fctn[(int) GE] = gen_bge; - bcc_gen_fctn[(int) GEU] = gen_bgeu; - bcc_gen_fctn[(int) LE] = gen_ble; - bcc_gen_fctn[(int) LEU] = gen_bleu; - movstr_optab[(int) SImode] = CODE_FOR_movstrsi; - ffs_optab->handlers[(int) SImode].insn_code = CODE_FOR_ffssi2; - ffs_optab->handlers[(int) HImode].insn_code = CODE_FOR_ffshi2; - strlen_optab->handlers[(int) SImode].insn_code = CODE_FOR_strlensi; -} diff --git a/gnu/usr.bin/gcc2/common/insn-output.c b/gnu/usr.bin/gcc2/common/insn-output.c deleted file mode 100644 index c39c4ffcc106..000000000000 --- a/gnu/usr.bin/gcc2/common/insn-output.c +++ /dev/null @@ -1,5899 +0,0 @@ -/* Generated automatically by the program `genoutput' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "regs.h" -#include "hard-reg-set.h" -#include "real.h" -#include "insn-config.h" - -#include "conditions.h" -#include "insn-flags.h" -#include "insn-attr.h" - -#include "insn-codes.h" - -#include "recog.h" - -#include -#include "output.h" - -static char * -output_0 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0])) - return AS2 (test%L0,%0,%0); - - operands[1] = const0_rtx; - return AS2 (cmp%L0,%1,%0); -} -} - -static char * -output_2 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0])) - return AS2 (test%W0,%0,%0); - - operands[1] = const0_rtx; - return AS2 (cmp%W0,%1,%0); -} -} - -static char * -output_4 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0])) - return AS2 (test%B0,%0,%0); - - operands[1] = const0_rtx; - return AS2 (cmp%B0,%1,%0); -} -} - -static char * -output_6 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (! STACK_TOP_P (operands[0])) - abort (); - - output_asm_insn ("ftst", operands); - - if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) - output_asm_insn (AS1 (fstp,%y0), operands); - - return (char *) output_fp_cc0_set (insn); -} -} - -static char * -output_8 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (! STACK_TOP_P (operands[0])) - abort (); - - output_asm_insn ("ftst", operands); - - if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) - output_asm_insn (AS1 (fstp,%y0), operands); - - return (char *) output_fp_cc0_set (insn); -} -} - -static char * -output_10 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (CONSTANT_P (operands[0]) || GET_CODE (operands[1]) == MEM) - { - cc_status.flags |= CC_REVERSED; - return AS2 (cmp%L0,%0,%1); - } - return AS2 (cmp%L0,%1,%0); -} -} - -static char * -output_12 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (CONSTANT_P (operands[0]) || GET_CODE (operands[1]) == MEM) - { - cc_status.flags |= CC_REVERSED; - return AS2 (cmp%W0,%0,%1); - } - return AS2 (cmp%W0,%1,%0); -} -} - -static char * -output_14 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (CONSTANT_P (operands[0]) || GET_CODE (operands[1]) == MEM) - { - cc_status.flags |= CC_REVERSED; - return AS2 (cmp%B0,%0,%1); - } - return AS2 (cmp%B0,%1,%0); -} -} - -static char * -output_16 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_17 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_18 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_19 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_20 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_21 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_22 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_23 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_24 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_25 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_32 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* For small integers, we may actually use testb. */ - if (GET_CODE (operands[1]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])) - && (! REG_P (operands[0]) || QI_REG_P (operands[0]))) - { - /* We may set the sign bit spuriously. */ - - if ((INTVAL (operands[1]) & ~0xff) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - return AS2 (test%B0,%1,%b0); - } - - if ((INTVAL (operands[1]) & ~0xff00) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (INTVAL (operands[1]) >> 8); - - if (QI_REG_P (operands[0])) - return AS2 (test%B0,%1,%h0); - else - { - operands[0] = adj_offsettable_operand (operands[0], 1); - return AS2 (test%B0,%1,%b0); - } - } - - if (GET_CODE (operands[0]) == MEM - && (INTVAL (operands[1]) & ~0xff0000) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (INTVAL (operands[1]) >> 16); - operands[0] = adj_offsettable_operand (operands[0], 2); - return AS2 (test%B0,%1,%b0); - } - - if (GET_CODE (operands[0]) == MEM - && (INTVAL (operands[1]) & ~0xff000000) == 0) - { - operands[1] = GEN_INT ((INTVAL (operands[1]) >> 24) & 0xff); - operands[0] = adj_offsettable_operand (operands[0], 3); - return AS2 (test%B0,%1,%b0); - } - } - - if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) - return AS2 (test%L0,%1,%0); - - return AS2 (test%L1,%0,%1); -} -} - -static char * -output_33 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])) - && (! REG_P (operands[0]) || QI_REG_P (operands[0]))) - { - if ((INTVAL (operands[1]) & 0xff00) == 0) - { - /* ??? This might not be necessary. */ - if (INTVAL (operands[1]) & 0xffff0000) - operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff); - - /* We may set the sign bit spuriously. */ - cc_status.flags |= CC_NOT_NEGATIVE; - return AS2 (test%B0,%1,%b0); - } - - if ((INTVAL (operands[1]) & 0xff) == 0) - { - operands[1] = GEN_INT ((INTVAL (operands[1]) >> 8) & 0xff); - - if (QI_REG_P (operands[0])) - return AS2 (test%B0,%1,%h0); - else - { - operands[0] = adj_offsettable_operand (operands[0], 1); - return AS2 (test%B0,%1,%b0); - } - } - } - - if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) - return AS2 (test%W0,%1,%0); - - return AS2 (test%W1,%0,%1); -} -} - -static char * -output_34 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) - return AS2 (test%B0,%1,%0); - - return AS2 (test%B1,%0,%1); -} -} - -static char * -output_38 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx link; - if (operands[1] == const0_rtx && REG_P (operands[0])) - return AS2 (xor%L0,%0,%0); - - if (operands[1] == const1_rtx - && (link = find_reg_note (insn, REG_WAS_0, 0)) - /* Make sure the insn that stored the 0 is still present. */ - && ! INSN_DELETED_P (XEXP (link, 0)) - && GET_CODE (XEXP (link, 0)) != NOTE - /* Make sure cross jumping didn't happen here. */ - && no_labels_between_p (XEXP (link, 0), insn) - /* Make sure the reg hasn't been clobbered. */ - && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) - /* Fastest way to change a 0 to a 1. */ - return AS1 (inc%L0,%0); - - return AS2 (mov%L0,%1,%0); -} -} - -static char * -output_40 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx link; - if (REG_P (operands[0]) && operands[1] == const0_rtx) - return AS2 (xor%L0,%k0,%k0); - - if (REG_P (operands[0]) && operands[1] == const1_rtx - && (link = find_reg_note (insn, REG_WAS_0, 0)) - /* Make sure the insn that stored the 0 is still present. */ - && ! INSN_DELETED_P (XEXP (link, 0)) - && GET_CODE (XEXP (link, 0)) != NOTE - /* Make sure cross jumping didn't happen here. */ - && no_labels_between_p (XEXP (link, 0), insn) - /* Make sure the reg hasn't been clobbered. */ - && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) - /* Fastest way to change a 0 to a 1. */ - return AS1 (inc%L0,%k0); - - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return AS2 (mov%L0,%k1,%k0); - else if (CONSTANT_P (operands[1])) - return AS2 (mov%L0,%1,%k0); - } - - return AS2 (mov%W0,%1,%0); -} -} - -static char * -output_41 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx link; - if (operands[1] == const0_rtx && REG_P (operands[0])) - return AS2 (xor%W0,%0,%0); - - if (operands[1] == const1_rtx - && (link = find_reg_note (insn, REG_WAS_0, 0)) - /* Make sure the insn that stored the 0 is still present. */ - && ! INSN_DELETED_P (XEXP (link, 0)) - && GET_CODE (XEXP (link, 0)) != NOTE - /* Make sure cross jumping didn't happen here. */ - && no_labels_between_p (XEXP (link, 0), insn) - /* Make sure the reg hasn't been clobbered. */ - && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) - /* Fastest way to change a 0 to a 1. */ - return AS1 (inc%W0,%0); - - return AS2 (mov%W0,%1,%0); -} -} - -static char * -output_42 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[1] = gen_rtx (REG, HImode, REGNO (operands[1])); - return AS1 (push%W0,%1); -} -} - -static char * -output_43 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx link; - if (operands[1] == const0_rtx && REG_P (operands[0])) - return AS2 (xor%B0,%0,%0); - - if (operands[1] == const1_rtx - && (link = find_reg_note (insn, REG_WAS_0, 0)) - /* Make sure the insn that stored the 0 is still present. */ - && ! INSN_DELETED_P (XEXP (link, 0)) - && GET_CODE (XEXP (link, 0)) != NOTE - /* Make sure cross jumping didn't happen here. */ - && no_labels_between_p (XEXP (link, 0), insn) - /* Make sure the reg hasn't been clobbered. */ - && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) - /* Fastest way to change a 0 to a 1. */ - return AS1 (inc%B0,%0); - - /* If mov%B0 isn't allowed for one of these regs, use mov%L0. */ - if (NON_QI_REG_P (operands[0]) || NON_QI_REG_P (operands[1])) - return (AS2 (mov%L0,%k1,%k0)); - - return (AS2 (mov%B0,%1,%0)); -} -} - -static char * -output_44 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx link; - if (operands[1] == const0_rtx && REG_P (operands[0])) - return AS2 (xor%B0,%0,%0); - - if (operands[1] == const1_rtx - && (link = find_reg_note (insn, REG_WAS_0, 0)) - /* Make sure the insn that stored the 0 is still present. */ - && ! INSN_DELETED_P (XEXP (link, 0)) - && GET_CODE (XEXP (link, 0)) != NOTE - /* Make sure cross jumping didn't happen here. */ - && no_labels_between_p (XEXP (link, 0), insn) - /* Make sure the reg hasn't been clobbered. */ - && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) - /* Fastest way to change a 0 to a 1. */ - return AS1 (inc%B0,%0); - - /* If mov%B0 isn't allowed for one of these regs, use mov%W0. */ - if (NON_QI_REG_P (operands[0]) || NON_QI_REG_P (operands[1])) - { - abort (); - return (AS2 (mov%L0,%k1,%k0)); - } - - return AS2 (mov%B0,%1,%0); -} -} - -static char * -output_45 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (STACK_REG_P (operands[1])) - { - rtx xops[3]; - - if (! STACK_TOP_P (operands[1])) - abort (); - - xops[0] = AT_SP (SFmode); - xops[1] = GEN_INT (4); - xops[2] = stack_pointer_rtx; - - output_asm_insn (AS2 (sub%L2,%1,%2), xops); - - if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) - output_asm_insn (AS1 (fstp%S0,%0), xops); - else - output_asm_insn (AS1 (fst%S0,%0), xops); - RET; - } - return AS1 (push%L1,%1); -} -} - -static char * -output_46 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; - - /* First handle a `pop' insn or a `fld %st(0)' */ - - if (STACK_TOP_P (operands[0]) && STACK_TOP_P (operands[1])) - { - if (stack_top_dies) - return AS1 (fstp,%y0); - else - return AS1 (fld,%y0); - } - - /* Handle a transfer between the 387 and a 386 register */ - - if (STACK_TOP_P (operands[0]) && NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); - RET; - } - - if (STACK_TOP_P (operands[1]) && NON_STACK_REG_P (operands[0])) - { - output_to_reg (operands[0], stack_top_dies); - RET; - } - - /* Handle other kinds of writes from the 387 */ - - if (STACK_TOP_P (operands[1])) - { - if (stack_top_dies) - return AS1 (fstp%z0,%y0); - else - return AS1 (fst%z0,%y0); - } - - /* Handle other kinds of reads to the 387 */ - - if (STACK_TOP_P (operands[0]) && GET_CODE (operands[1]) == CONST_DOUBLE) - return (char *) output_move_const_single (operands); - - if (STACK_TOP_P (operands[0])) - return AS1 (fld%z1,%y1); - - /* Handle all SFmode moves not involving the 387 */ - - return (char *) singlemove_string (operands); -} -} - -static char * -output_47 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (STACK_REG_P (operands[1])) - { - rtx xops[3]; - - xops[0] = AT_SP (SFmode); - xops[1] = GEN_INT (8); - xops[2] = stack_pointer_rtx; - - output_asm_insn (AS2 (sub%L2,%1,%2), xops); - - if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) - output_asm_insn (AS1 (fstp%Q0,%0), xops); - else - output_asm_insn (AS1 (fst%Q0,%0), xops); - - RET; - } - else - return (char *) output_move_double (operands); -} -} - -static char * -output_48 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (STACK_TOP_P (operands[0])) - return AS1 (fxch,%1); - else - return AS1 (fxch,%0); -} -} - -static char * -output_49 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; - - /* First handle a `pop' insn or a `fld %st(0)' */ - - if (STACK_TOP_P (operands[0]) && STACK_TOP_P (operands[1])) - { - if (stack_top_dies) - return AS1 (fstp,%y0); - else - return AS1 (fld,%y0); - } - - /* Handle a transfer between the 387 and a 386 register */ - - if (STACK_TOP_P (operands[0]) && NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); - RET; - } - - if (STACK_TOP_P (operands[1]) && NON_STACK_REG_P (operands[0])) - { - output_to_reg (operands[0], stack_top_dies); - RET; - } - - /* Handle other kinds of writes from the 387 */ - - if (STACK_TOP_P (operands[1])) - { - if (stack_top_dies) - return AS1 (fstp%z0,%y0); - else - return AS1 (fst%z0,%y0); - } - - /* Handle other kinds of reads to the 387 */ - - if (STACK_TOP_P (operands[0]) && GET_CODE (operands[1]) == CONST_DOUBLE) - return (char *) output_move_const_single (operands); - - if (STACK_TOP_P (operands[0])) - return AS1 (fld%z1,%y1); - - /* Handle all DFmode moves not involving the 387 */ - - return (char *) output_move_double (operands); -} -} - -static char * -output_50 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return (char *) output_move_double (operands); -} -} - -static char * -output_51 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return (char *) output_move_double (operands); -} -} - -static char * -output_52 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if ((TARGET_486 || REGNO (operands[0]) == 0) - && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])) - { - rtx xops[2]; - xops[0] = operands[0]; - xops[1] = GEN_INT (0xffff); - output_asm_insn (AS2 (and%L0,%1,%k0), xops); - RET; - } - -#ifdef INTEL_SYNTAX - return AS2 (movzx,%1,%0); -#else - return AS2 (movz%W0%L0,%1,%0); -#endif -} -} - -static char * -output_53 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if ((TARGET_486 || REGNO (operands[0]) == 0) - && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])) - { - rtx xops[2]; - xops[0] = operands[0]; - xops[1] = GEN_INT (0xff); - output_asm_insn (AS2 (and%L0,%1,%k0), xops); - RET; - } - -#ifdef INTEL_SYNTAX - return AS2 (movzx,%1,%0); -#else - return AS2 (movz%B0%W0,%1,%0); -#endif -} -} - -static char * -output_54 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if ((TARGET_486 || REGNO (operands[0]) == 0) - && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])) - { - rtx xops[2]; - xops[0] = operands[0]; - xops[1] = GEN_INT (0xff); - output_asm_insn (AS2 (and%L0,%1,%k0), xops); - RET; - } - -#ifdef INTEL_SYNTAX - return AS2 (movzx,%1,%0); -#else - return AS2 (movz%B0%L0,%1,%0); -#endif -} -} - -static char * -output_55 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return AS2 (xor%L0,%0,%0); -} -} - -static char * -output_56 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REGNO (operands[0]) == 0) - { - /* This used to be cwtl, but that extends HI to SI somehow. */ -#ifdef INTEL_SYNTAX - return "cdq"; -#else - return "cltd"; -#endif - } - - operands[1] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - output_asm_insn (AS2 (mov%L0,%0,%1), operands); - - operands[0] = GEN_INT (31); - return AS2 (sar%L1,%0,%1); -} -} - -static char * -output_57 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REGNO (operands[0]) == 0 - && REG_P (operands[1]) && REGNO (operands[1]) == 0) -#ifdef INTEL_SYNTAX - return "cwde"; -#else - return "cwtl"; -#endif - -#ifdef INTEL_SYNTAX - return AS2 (movsx,%1,%0); -#else - return AS2 (movs%W0%L0,%1,%0); -#endif -} -} - -static char * -output_58 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REGNO (operands[0]) == 0 - && REG_P (operands[1]) && REGNO (operands[1]) == 0) - return "cbtw"; - -#ifdef INTEL_SYNTAX - return AS2 (movsx,%1,%0); -#else - return AS2 (movs%B0%W0,%1,%0); -#endif -} -} - -static char * -output_59 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef INTEL_SYNTAX - return AS2 (movsx,%1,%0); -#else - return AS2 (movs%B0%L0,%1,%0); -#endif -} -} - -static char * -output_60 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; - - if (NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); - RET; - } - - if (NON_STACK_REG_P (operands[0])) - { - output_to_reg (operands[0], stack_top_dies); - RET; - } - - if (STACK_TOP_P (operands[0])) - return AS1 (fld%z1,%y1); - - if (GET_CODE (operands[0]) == MEM) - { - if (stack_top_dies) - return AS1 (fstp%z0,%y0); - else - return AS1 (fst%z0,%y0); - } - - abort (); -} -} - -static char * -output_62 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; - - if (GET_CODE (operands[0]) == MEM) - { - if (stack_top_dies) - return AS1 (fstp%z0,%0); - else - return AS1 (fst%z0,%0); - } - else if (STACK_TOP_P (operands[0])) - { - output_asm_insn (AS1 (fstp%z2,%y2), operands); - return AS1 (fld%z2,%y2); - } - else - abort (); -} -} - -static char * -output_67 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_fix_trunc (insn, operands); -} - -static char * -output_68 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_fix_trunc (insn, operands); -} - -static char * -output_71 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_fix_trunc (insn, operands); -} - -static char * -output_72 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_fix_trunc (insn, operands); -} - -static char * -output_77 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fild%z0,%1)); - RET; - } - else if (GET_CODE (operands[1]) == MEM) - return AS1 (fild%z1,%1); - else - abort (); -} -} - -static char * -output_78 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fild%z0,%1)); - RET; - } - else if (GET_CODE (operands[1]) == MEM) - return AS1 (fild%z1,%1); - else - abort (); -} -} - -static char * -output_79 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fild%z0,%1)); - RET; - } - else if (GET_CODE (operands[1]) == MEM) - return AS1 (fild%z1,%1); - else - abort (); -} -} - -static char * -output_80 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fild%z0,%1)); - RET; - } - else if (GET_CODE (operands[1]) == MEM) - return AS1 (fild%z1,%1); - else - abort (); -} -} - -static char * -output_81 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx low[3], high[3]; - - CC_STATUS_INIT; - - split_di (operands, 3, low, high); - - if (GET_CODE (low[2]) != CONST_INT || INTVAL (low[2]) != 0) - { - output_asm_insn (AS2 (add%L0,%2,%0), low); - output_asm_insn (AS2 (adc%L0,%2,%0), high); - } - else - output_asm_insn (AS2 (add%L0,%2,%0), high); - RET; -} -} - -static char * -output_82 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0]) && REGNO (operands[0]) != REGNO (operands[1])) - { - if (REG_P (operands[2]) && REGNO (operands[0]) == REGNO (operands[2])) - return AS2 (add%L0,%1,%0); - - if (! TARGET_486 || ! REG_P (operands[2])) - { - CC_STATUS_INIT; - - if (operands[2] == stack_pointer_rtx) - { - rtx temp; - - temp = operands[1]; - operands[1] = operands[2]; - operands[2] = temp; - } - if (operands[2] != stack_pointer_rtx) - { - operands[1] = SET_SRC (PATTERN (insn)); - return AS2 (lea%L0,%a1,%0); - } - } - - output_asm_insn (AS2 (mov%L0,%1,%0), operands); - } - - if (operands[2] == const1_rtx) - return AS1 (inc%L0,%0); - - if (operands[2] == constm1_rtx) - return AS1 (dec%L0,%0); - - return AS2 (add%L0,%2,%0); -} -} - -static char * -output_83 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[2] == const1_rtx) - return AS1 (inc%W0,%0); - - if (operands[2] == constm1_rtx) - return AS1 (dec%W0,%0); - - return AS2 (add%W0,%2,%0); -} -} - -static char * -output_84 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[2] == const1_rtx) - return AS1 (inc%B0,%0); - - if (operands[2] == constm1_rtx) - return AS1 (dec%B0,%0); - - return AS2 (add%B0,%2,%0); -} -} - -static char * -output_85 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - /* Adding a constant to a register is faster with an add. */ - /* ??? can this ever happen? */ - if (GET_CODE (operands[1]) == PLUS - && GET_CODE (XEXP (operands[1], 1)) == CONST_INT - && rtx_equal_p (operands[0], XEXP (operands[1], 0))) - { - operands[1] = XEXP (operands[1], 1); - - if (operands[1] == const1_rtx) - return AS1 (inc%L0,%0); - - if (operands[1] == constm1_rtx) - return AS1 (dec%L0,%0); - - return AS2 (add%L0,%1,%0); - } - return AS2 (lea%L0,%a1,%0); -} -} - -static char * -output_88 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx low[3], high[3]; - - CC_STATUS_INIT; - - split_di (operands, 3, low, high); - - if (GET_CODE (low[2]) != CONST_INT || INTVAL (low[2]) != 0) - { - output_asm_insn (AS2 (sub%L0,%2,%0), low); - output_asm_insn (AS2 (sbb%L0,%2,%0), high); - } - else - output_asm_insn (AS2 (sub%L0,%2,%0), high); - - RET; -} -} - -static char * -output_89 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (sub%L0,%2,%0); -} - -static char * -output_90 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (sub%W0,%2,%0); -} - -static char * -output_91 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (sub%B0,%2,%0); -} - -static char * -output_94 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (imul%W0,%2,%0); -} - -static char * -output_95 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == REG - && REGNO (operands[1]) == REGNO (operands[0]) - && (GET_CODE (operands[2]) == MEM || GET_CODE (operands[2]) == REG)) - /* Assembler has weird restrictions. */ - return AS2 (imul%W0,%2,%0); - return AS3 (imul%W0,%2,%1,%0); -} -} - -static char * -output_96 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (imul%L0,%2,%0); -} - -static char * -output_97 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == REG - && REGNO (operands[1]) == REGNO (operands[0]) - && (GET_CODE (operands[2]) == MEM || GET_CODE (operands[2]) == REG)) - /* Assembler has weird restrictions. */ - return AS2 (imul%L0,%2,%0); - return AS3 (imul%L0,%2,%1,%0); -} -} - -static char * -output_105 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef INTEL_SYNTAX - output_asm_insn ("cdq", operands); -#else - output_asm_insn ("cltd", operands); -#endif - return AS1 (idiv%L0,%2); -} -} - -static char * -output_107 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - output_asm_insn (AS2 (xor%L3,%3,%3), operands); - return AS1 (div%L0,%2); -} -} - -static char * -output_108 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - output_asm_insn (AS2 (xor%W0,%3,%3), operands); - return AS1 (div%W0,%2); -} -} - -static char * -output_109 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - if (INTVAL (operands[2]) == 0xffff && REG_P (operands[0]) - && (! REG_P (operands[1]) - || REGNO (operands[0]) != 0 || REGNO (operands[1]) != 0) - && (! TARGET_486 || ! rtx_equal_p (operands[0], operands[1]))) - { - /* ??? tege: Should forget CC_STATUS only if we clobber a - remembered operand. Fix that later. */ - CC_STATUS_INIT; -#ifdef INTEL_SYNTAX - return AS2 (movzx,%w1,%0); -#else - return AS2 (movz%W0%L0,%w1,%0); -#endif - } - - if (INTVAL (operands[2]) == 0xff && REG_P (operands[0]) - && !(REG_P (operands[1]) && NON_QI_REG_P (operands[1])) - && (! REG_P (operands[1]) - || REGNO (operands[0]) != 0 || REGNO (operands[1]) != 0) - && (! TARGET_486 || ! rtx_equal_p (operands[0], operands[1]))) - { - /* ??? tege: Should forget CC_STATUS only if we clobber a - remembered operand. Fix that later. */ - CC_STATUS_INIT; -#ifdef INTEL_SYNTAX - return AS2 (movzx,%b1,%0); -#else - return AS2 (movz%B0%L0,%b1,%0); -#endif - } - - if (QI_REG_P (operands[0]) && ~(INTVAL (operands[2]) | 0xff) == 0) - { - CC_STATUS_INIT; - - if (INTVAL (operands[2]) == 0xffffff00) - { - operands[2] = const0_rtx; - return AS2 (mov%B0,%2,%b0); - } - - operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff); - return AS2 (and%B0,%2,%b0); - } - - if (QI_REG_P (operands[0]) && ~(INTVAL (operands[2]) | 0xff00) == 0) - { - CC_STATUS_INIT; - - if (INTVAL (operands[2]) == 0xffff00ff) - { - operands[2] = const0_rtx; - return AS2 (mov%B0,%2,%h0); - } - - operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); - return AS2 (and%B0,%2,%h0); - } - - if (GET_CODE (operands[0]) == MEM && INTVAL (operands[2]) == 0xffff0000) - { - operands[2] = const0_rtx; - return AS2 (mov%W0,%2,%w0); - } - } - - return AS2 (and%L0,%2,%0); -} -} - -static char * -output_110 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - /* Can we ignore the upper byte? */ - if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) - && (INTVAL (operands[2]) & 0xff00) == 0xff00) - { - CC_STATUS_INIT; - - if ((INTVAL (operands[2]) & 0xff) == 0) - { - operands[2] = const0_rtx; - return AS2 (mov%B0,%2,%b0); - } - - operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff); - return AS2 (and%B0,%2,%b0); - } - - /* Can we ignore the lower byte? */ - /* ??? what about offsettable memory references? */ - if (QI_REG_P (operands[0]) && (INTVAL (operands[2]) & 0xff) == 0xff) - { - CC_STATUS_INIT; - - if ((INTVAL (operands[2]) & 0xff00) == 0) - { - operands[2] = const0_rtx; - return AS2 (mov%B0,%2,%h0); - } - - operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); - return AS2 (and%B0,%2,%h0); - } - } - - return AS2 (and%W0,%2,%0); -} -} - -static char * -output_111 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (and%B0,%2,%0); -} - -static char * -output_112 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) - && (INTVAL (operands[2]) & ~0xff) == 0) - { - CC_STATUS_INIT; - - if (INTVAL (operands[2]) == 0xff) - return AS2 (mov%B0,%2,%b0); - - return AS2 (or%B0,%2,%b0); - } - - if (QI_REG_P (operands[0]) && (INTVAL (operands[2]) & ~0xff00) == 0) - { - CC_STATUS_INIT; - operands[2] = GEN_INT (INTVAL (operands[2]) >> 8); - - if (INTVAL (operands[2]) == 0xff) - return AS2 (mov%B0,%2,%h0); - - return AS2 (or%B0,%2,%h0); - } - } - - return AS2 (or%L0,%2,%0); -} -} - -static char * -output_113 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - /* Can we ignore the upper byte? */ - if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) - && (INTVAL (operands[2]) & 0xff00) == 0) - { - CC_STATUS_INIT; - if (INTVAL (operands[2]) & 0xffff0000) - operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffff); - - if (INTVAL (operands[2]) == 0xff) - return AS2 (mov%B0,%2,%b0); - - return AS2 (or%B0,%2,%b0); - } - - /* Can we ignore the lower byte? */ - /* ??? what about offsettable memory references? */ - if (QI_REG_P (operands[0]) - && (INTVAL (operands[2]) & 0xff) == 0) - { - CC_STATUS_INIT; - operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); - - if (INTVAL (operands[2]) == 0xff) - return AS2 (mov%B0,%2,%h0); - - return AS2 (or%B0,%2,%h0); - } - } - - return AS2 (or%W0,%2,%0); -} -} - -static char * -output_114 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (or%B0,%2,%0); -} - -static char * -output_115 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) - && (INTVAL (operands[2]) & ~0xff) == 0) - { - CC_STATUS_INIT; - - if (INTVAL (operands[2]) == 0xff) - return AS1 (not%B0,%b0); - - return AS2 (xor%B0,%2,%b0); - } - - if (QI_REG_P (operands[0]) && (INTVAL (operands[2]) & ~0xff00) == 0) - { - CC_STATUS_INIT; - operands[2] = GEN_INT (INTVAL (operands[2]) >> 8); - - if (INTVAL (operands[2]) == 0xff) - return AS1 (not%B0,%h0); - - return AS2 (xor%B0,%2,%h0); - } - } - - return AS2 (xor%L0,%2,%0); -} -} - -static char * -output_116 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - /* Can we ignore the upper byte? */ - if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) - && (INTVAL (operands[2]) & 0xff00) == 0) - { - CC_STATUS_INIT; - if (INTVAL (operands[2]) & 0xffff0000) - operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffff); - - if (INTVAL (operands[2]) == 0xff) - return AS1 (not%B0,%b0); - - return AS2 (xor%B0,%2,%b0); - } - - /* Can we ignore the lower byte? */ - /* ??? what about offsettable memory references? */ - if (QI_REG_P (operands[0]) - && (INTVAL (operands[2]) & 0xff) == 0) - { - CC_STATUS_INIT; - operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); - - if (INTVAL (operands[2]) == 0xff) - return AS1 (not%B0,%h0); - - return AS2 (xor%B0,%2,%h0); - } - } - - return AS2 (xor%W0,%2,%0); -} -} - -static char * -output_117 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (xor%B0,%2,%0); -} - -static char * -output_118 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = const0_rtx; - xops[1] = high[0]; - - output_asm_insn (AS1 (neg%L0,%0), low); - output_asm_insn (AS2 (adc%L1,%0,%1), xops); - output_asm_insn (AS1 (neg%L0,%0), high); - RET; -} -} - -static char * -output_141 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - if (INTVAL (xops[0]) > 31) - { - output_asm_insn (AS2 (mov%L3,%2,%3), xops); /* Fast shift by 32 */ - output_asm_insn (AS2 (xor%L2,%2,%2), xops); - - if (INTVAL (xops[0]) > 32) - { - xops[0] = GEN_INT (INTVAL (xops[0]) - 32); - output_asm_insn (AS2 (sal%L3,%0,%3), xops); /* Remaining shift */ - } - } - else - { - output_asm_insn (AS3 (shld%L3,%0,%2,%3), xops); - output_asm_insn (AS2 (sal%L2,%0,%2), xops); - } - RET; -} -} - -static char * -output_142 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - output_asm_insn (AS2 (ror%B0,%1,%0), xops); /* shift count / 2 */ - - output_asm_insn (AS3_SHIFT_DOUBLE (shld%L3,%0,%2,%3), xops); - output_asm_insn (AS2 (sal%L2,%0,%2), xops); - output_asm_insn (AS3_SHIFT_DOUBLE (shld%L3,%0,%2,%3), xops); - output_asm_insn (AS2 (sal%L2,%0,%2), xops); - - xops[1] = GEN_INT (7); /* shift count & 1 */ - - output_asm_insn (AS2 (shr%B0,%1,%0), xops); - - output_asm_insn (AS3_SHIFT_DOUBLE (shld%L3,%0,%2,%3), xops); - output_asm_insn (AS2 (sal%L2,%0,%2), xops); - - RET; -} -} - -static char * -output_143 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0]) && REGNO (operands[0]) != REGNO (operands[1])) - { - if (TARGET_486 && INTVAL (operands[2]) == 1) - { - output_asm_insn (AS2 (mov%L0,%1,%0), operands); - return AS2 (add%L0,%1,%0); - } - else - { - CC_STATUS_INIT; - - if (operands[1] == stack_pointer_rtx) - { - output_asm_insn (AS2 (mov%L0,%1,%0), operands); - operands[1] = operands[0]; - } - operands[1] = gen_rtx (MULT, SImode, operands[1], - GEN_INT (1 << INTVAL (operands[2]))); - return AS2 (lea%L0,%a1,%0); - } - } - - if (REG_P (operands[2])) - return AS2 (sal%L0,%b2,%0); - - if (REG_P (operands[0]) && operands[2] == const1_rtx) - return AS2 (add%L0,%0,%0); - - return AS2 (sal%L0,%2,%0); -} -} - -static char * -output_144 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (sal%W0,%b2,%0); - - if (REG_P (operands[0]) && operands[2] == const1_rtx) - return AS2 (add%W0,%0,%0); - - return AS2 (sal%W0,%2,%0); -} -} - -static char * -output_145 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (sal%B0,%b2,%0); - - if (REG_P (operands[0]) && operands[2] == const1_rtx) - return AS2 (add%B0,%0,%0); - - return AS2 (sal%B0,%2,%0); -} -} - -static char * -output_147 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - if (INTVAL (xops[0]) > 31) - { - xops[1] = GEN_INT (31); - output_asm_insn (AS2 (mov%L2,%3,%2), xops); - output_asm_insn (AS2 (sar%L3,%1,%3), xops); /* shift by 32 */ - - if (INTVAL (xops[0]) > 32) - { - xops[0] = GEN_INT (INTVAL (xops[0]) - 32); - output_asm_insn (AS2 (sar%L2,%0,%2), xops); /* Remaining shift */ - } - } - else - { - output_asm_insn (AS3 (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (sar%L3,%0,%3), xops); - } - - RET; -} -} - -static char * -output_148 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - output_asm_insn (AS2 (ror%B0,%1,%0), xops); /* shift count / 2 */ - - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (sar%L3,%0,%3), xops); - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (sar%L3,%0,%3), xops); - - xops[1] = GEN_INT (7); /* shift count & 1 */ - - output_asm_insn (AS2 (shr%B0,%1,%0), xops); - - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (sar%L3,%0,%3), xops); - - RET; -} -} - -static char * -output_149 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (sar%L0,%b2,%0); - else - return AS2 (sar%L0,%2,%0); -} -} - -static char * -output_150 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (sar%W0,%b2,%0); - else - return AS2 (sar%W0,%2,%0); -} -} - -static char * -output_151 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (sar%B0,%b2,%0); - else - return AS2 (sar%B0,%2,%0); -} -} - -static char * -output_153 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - if (INTVAL (xops[0]) > 31) - { - output_asm_insn (AS2 (mov%L2,%3,%2), xops); /* Fast shift by 32 */ - output_asm_insn (AS2 (xor%L3,%3,%3), xops); - - if (INTVAL (xops[0]) > 32) - { - xops[0] = GEN_INT (INTVAL (xops[0]) - 32); - output_asm_insn (AS2 (shr%L2,%0,%2), xops); /* Remaining shift */ - } - } - else - { - output_asm_insn (AS3 (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (shr%L3,%0,%3), xops); - } - - RET; -} -} - -static char * -output_154 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - output_asm_insn (AS2 (ror%B0,%1,%0), xops); /* shift count / 2 */ - - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (shr%L3,%0,%3), xops); - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (shr%L3,%0,%3), xops); - - xops[1] = GEN_INT (7); /* shift count & 1 */ - - output_asm_insn (AS2 (shr%B0,%1,%0), xops); - - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (shr%L3,%0,%3), xops); - - RET; -} -} - -static char * -output_155 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (shr%L0,%b2,%0); - else - return AS2 (shr%L0,%2,%1); -} -} - -static char * -output_156 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (shr%W0,%b2,%0); - else - return AS2 (shr%W0,%2,%0); -} -} - -static char * -output_157 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (shr%B0,%b2,%0); - else - return AS2 (shr%B0,%2,%0); -} -} - -static char * -output_158 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (rol%L0,%b2,%0); - else - return AS2 (rol%L0,%2,%0); -} -} - -static char * -output_159 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (rol%W0,%b2,%0); - else - return AS2 (rol%W0,%2,%0); -} -} - -static char * -output_160 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (rol%B0,%b2,%0); - else - return AS2 (rol%B0,%2,%0); -} -} - -static char * -output_161 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (ror%L0,%b2,%0); - else - return AS2 (ror%L0,%2,%0); -} -} - -static char * -output_162 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (ror%W0,%b2,%0); - else - return AS2 (ror%W0,%2,%0); -} -} - -static char * -output_163 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (ror%B0,%b2,%0); - else - return AS2 (ror%B0,%2,%0); -} -} - -static char * -output_164 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - if (INTVAL (operands[3]) == 1) - return AS2 (bts%L0,%2,%0); - else - return AS2 (btr%L0,%2,%0); -} -} - -static char * -output_165 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - return AS2 (btc%L0,%1,%0); -} -} - -static char * -output_166 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - return AS2 (btc%L0,%2,%0); -} -} - -static char * -output_167 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags |= CC_Z_IN_NOT_C; - return AS2 (bt%L0,%1,%0); -} -} - -static char * -output_168 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - unsigned int mask; - - mask = ((1 << INTVAL (operands[1])) - 1) << INTVAL (operands[2]); - operands[1] = GEN_INT (mask); - - if (QI_REG_P (operands[0])) - { - if ((mask & ~0xff) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - return AS2 (test%B0,%1,%b0); - } - - if ((mask & ~0xff00) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (mask >> 8); - return AS2 (test%B0,%1,%h0); - } - } - - return AS2 (test%L0,%1,%0); -} -} - -static char * -output_169 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - unsigned int mask; - - mask = ((1 << INTVAL (operands[1])) - 1) << INTVAL (operands[2]); - operands[1] = GEN_INT (mask); - - if (! REG_P (operands[0]) || QI_REG_P (operands[0])) - { - if ((mask & ~0xff) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - return AS2 (test%B0,%1,%b0); - } - - if ((mask & ~0xff00) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (mask >> 8); - - if (QI_REG_P (operands[0])) - return AS2 (test%B0,%1,%h0); - else - { - operands[0] = adj_offsettable_operand (operands[0], 1); - return AS2 (test%B0,%1,%b0); - } - } - - if (GET_CODE (operands[0]) == MEM && (mask & ~0xff0000) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (mask >> 16); - operands[0] = adj_offsettable_operand (operands[0], 2); - return AS2 (test%B0,%1,%b0); - } - - if (GET_CODE (operands[0]) == MEM && (mask & ~0xff000000) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (mask >> 24); - operands[0] = adj_offsettable_operand (operands[0], 3); - return AS2 (test%B0,%1,%b0); - } - } - - if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) - return AS2 (test%L0,%1,%0); - - return AS2 (test%L1,%0,%1); -} -} - -static char * -output_171 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return AS1 (setnb,%0); - else - return AS1 (sete,%0); -} -} - -static char * -output_173 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return AS1 (setb,%0); - else - return AS1 (setne,%0); -} - -} - -static char * -output_175 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (sete,%0); - - OUTPUT_JUMP ("setg %0", "seta %0", NULL_PTR); -} -} - -static char * -output_177 (operands, insn) - rtx *operands; - rtx insn; -{ - return "seta %0"; -} - -static char * -output_179 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (sete,%0); - - OUTPUT_JUMP ("setl %0", "setb %0", "sets %0"); -} -} - -static char * -output_181 (operands, insn) - rtx *operands; - rtx insn; -{ - return "setb %0"; -} - -static char * -output_183 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (sete,%0); - - OUTPUT_JUMP ("setge %0", "setae %0", "setns %0"); -} -} - -static char * -output_185 (operands, insn) - rtx *operands; - rtx insn; -{ - return "setae %0"; -} - -static char * -output_187 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (setb,%0); - - OUTPUT_JUMP ("setle %0", "setbe %0", NULL_PTR); -} -} - -static char * -output_189 (operands, insn) - rtx *operands; - rtx insn; -{ - return "setbe %0"; -} - -static char * -output_191 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return "jnc %l0"; - else - return "je %l0"; -} -} - -static char * -output_193 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return "jc %l0"; - else - return "jne %l0"; -} -} - -static char * -output_195 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (je,%l0); - - OUTPUT_JUMP ("jg %l0", "ja %l0", NULL_PTR); -} -} - -static char * -output_199 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (je,%l0); - - OUTPUT_JUMP ("jl %l0", "jb %l0", "js %l0"); -} -} - -static char * -output_203 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (je,%l0); - - OUTPUT_JUMP ("jge %l0", "jae %l0", "jns %l0"); -} -} - -static char * -output_207 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (jb,%l0); - - OUTPUT_JUMP ("jle %l0", "jbe %l0", NULL_PTR); -} -} - -static char * -output_210 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return "jc %l0"; - else - return "jne %l0"; -} -} - -static char * -output_211 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return "jnc %l0"; - else - return "je %l0"; -} -} - -static char * -output_212 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (jne,%l0); - - OUTPUT_JUMP ("jle %l0", "jbe %l0", NULL_PTR); -} -} - -static char * -output_214 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (jne,%l0); - - OUTPUT_JUMP ("jge %l0", "jae %l0", "jns %l0"); -} -} - -static char * -output_216 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (jne,%l0); - - OUTPUT_JUMP ("jl %l0", "jb %l0", "js %l0"); -} -} - -static char * -output_218 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (jae,%l0); - - OUTPUT_JUMP ("jg %l0", "ja %l0", NULL_PTR); -} -} - -static char * -output_221 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - return AS1 (jmp,%*%0); -} -} - -static char * -output_223 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4]; - - xops[0] = operands[0]; - xops[1] = operands[1]; - xops[2] = operands[2]; - xops[3] = pic_offset_table_rtx; - - output_asm_insn (AS2 (mov%L2,%3,%2), xops); - output_asm_insn ("sub%L2 %l1@GOTOFF(%3,%0,4),%2", xops); - output_asm_insn (AS1 (jmp,%*%2), xops); - ASM_OUTPUT_ALIGN_CODE (asm_out_file); - RET; -} -} - -static char * -output_224 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - return AS1 (jmp,%*%0); -} -} - -static char * -output_226 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM - && ! CONSTANT_ADDRESS_P (XEXP (operands[0], 0))) - { - operands[0] = XEXP (operands[0], 0); - return AS1 (call,%*%0); - } - else - return AS1 (call,%P0); -} -} - -static char * -output_229 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM - && ! CONSTANT_ADDRESS_P (XEXP (operands[0], 0))) - { - operands[0] = XEXP (operands[0], 0); - return AS1 (call,%*%0); - } - else - return AS1 (call,%P0); -} -} - -static char * -output_232 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == MEM - && ! CONSTANT_ADDRESS_P (XEXP (operands[1], 0))) - { - operands[1] = XEXP (operands[1], 0); - output_asm_insn (AS1 (call,%*%1), operands); - } - else - output_asm_insn (AS1 (call,%P1), operands); - - RET; -} -} - -static char * -output_235 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == MEM - && ! CONSTANT_ADDRESS_P (XEXP (operands[1], 0))) - { - operands[1] = XEXP (operands[1], 0); - output_asm_insn (AS1 (call,%*%1), operands); - } - else - output_asm_insn (AS1 (call,%P1), operands); - - RET; -} -} - -static char * -output_238 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx addr = operands[1]; - - if (GET_CODE (operands[0]) == MEM - && ! CONSTANT_ADDRESS_P (XEXP (operands[0], 0))) - { - operands[0] = XEXP (operands[0], 0); - output_asm_insn (AS1 (call,%*%0), operands); - } - else - output_asm_insn (AS1 (call,%P0), operands); - - operands[2] = gen_rtx (REG, SImode, 0); - output_asm_insn (AS2 (mov%L2,%2,%1), operands); - - operands[2] = gen_rtx (REG, SImode, 1); - operands[1] = adj_offsettable_operand (addr, 4); - output_asm_insn (AS2 (mov%L2,%2,%1), operands); - - operands[1] = adj_offsettable_operand (addr, 8); - return AS1 (fnsave,%1); -} -} - -static char * -output_239 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx addr = operands[1]; - - output_asm_insn (AS1 (call,%P0), operands); - - operands[2] = gen_rtx (REG, SImode, 0); - output_asm_insn (AS2 (mov%L2,%2,%1), operands); - - operands[2] = gen_rtx (REG, SImode, 1); - operands[1] = adj_offsettable_operand (addr, 4); - output_asm_insn (AS2 (mov%L2,%2,%1), operands); - - operands[1] = adj_offsettable_operand (addr, 8); - return AS1 (fnsave,%1); -} -} - -static char * -output_242 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - function_epilogue (asm_out_file, get_frame_size ()); - RET; -} -} - -static char * -output_245 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2]; - - output_asm_insn ("cld", operands); - if (GET_CODE (operands[2]) == CONST_INT) - { - if (INTVAL (operands[2]) & ~0x03) - { - xops[0] = GEN_INT ((INTVAL (operands[2]) >> 2) & 0x3fffffff); - xops[1] = operands[4]; - - output_asm_insn (AS2 (mov%L1,%0,%1), xops); -#ifdef INTEL_SYNTAX - output_asm_insn ("rep movsd", xops); -#else - output_asm_insn ("rep\n\tmovsl", xops); -#endif - } - if (INTVAL (operands[2]) & 0x02) - output_asm_insn ("movsw", operands); - if (INTVAL (operands[2]) & 0x01) - output_asm_insn ("movsb", operands); - } - else - abort (); - RET; -} -} - -static char * -output_247 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], label; - - label = gen_label_rtx (); - - output_asm_insn ("cld", operands); - output_asm_insn (AS2 (xor%L0,%0,%0), operands); - output_asm_insn ("repz\n\tcmps%B2", operands); - output_asm_insn ("je %l0", &label); - - xops[0] = operands[0]; - xops[1] = gen_rtx (MEM, QImode, - gen_rtx (PLUS, SImode, operands[1], constm1_rtx)); - xops[2] = gen_rtx (MEM, QImode, - gen_rtx (PLUS, SImode, operands[2], constm1_rtx)); - xops[3] = operands[3]; - - output_asm_insn (AS2 (movz%B1%L0,%1,%0), xops); - output_asm_insn (AS2 (movz%B2%L3,%2,%3), xops); - - output_asm_insn (AS2 (sub%L0,%3,%0), xops); - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (label)); - RET; -} -} - -static char * -output_248 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2]; - - cc_status.flags |= CC_NOT_SIGNED; - - xops[0] = gen_rtx (REG, QImode, 0); - xops[1] = CONST0_RTX (QImode); - - output_asm_insn ("cld", operands); - output_asm_insn (AS2 (test%B0,%1,%0), xops); - return "repz\n\tcmps%B2"; -} -} - -static char * -output_250 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2]; - - xops[0] = const1_rtx; - xops[1] = operands[1]; - output_asm_insn (AS2 (bsf%L1,%1,%0), operands); - output_asm_insn (AS2 (cmp%L1,%0,%1), xops); - output_asm_insn (AS2 (sbb%L0,%2,%2), operands); - output_asm_insn (AS2 (or%L0,%2,%0), operands); - return ""; -} -} - -static char * -output_252 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2]; - - xops[0] = const1_rtx; - xops[1] = operands[1]; - output_asm_insn (AS2 (bsf%W1,%1,%0), operands); - output_asm_insn (AS2 (cmp%W1,%0,%1), xops); - output_asm_insn (AS2 (sbb%W0,%2,%2), operands); - output_asm_insn (AS2 (or%W0,%2,%0), operands); - return ""; -} -} - -static char * -output_253 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_254 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_255 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_256 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_257 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_258 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_259 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_260 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_262 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2]; - - xops[0] = operands[0]; - xops[1] = constm1_rtx; - output_asm_insn ("cld", operands); - output_asm_insn (AS2 (mov%L0,%1,%0), xops); - return "repnz\n\tscas%B2"; -} -} - -char * const insn_template[] = - { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "push%L0 %1", - "push%L0 %1", - 0, - 0, - "push%W0 %1", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "mul%B0 %2", - 0, - 0, - "idiv%B0 %2", - "div%B0 %2", - 0, - 0, - 0, - "cwtd\n\tidiv%W0 %2", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "neg%L0 %0", - "neg%W0 %0", - "neg%B0 %0", - "fchs", - "fchs", - "fchs", - "fabs", - "fabs", - "fabs", - "fsqrt", - "fsqrt", - "fsqrt", - "fsin", - "fsin", - "fsin", - "fcos", - "fcos", - "fcos", - "not%L0 %0", - "not%W0 %0", - "not%B0 %0", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "ja %l0", - 0, - 0, - 0, - "jb %l0", - 0, - 0, - 0, - "jae %l0", - 0, - 0, - 0, - "jbe %l0", - 0, - 0, - 0, - "jbe %l0", - 0, - "jae %l0", - 0, - "jb %l0", - 0, - "ja %l0", - "jmp %l0", - 0, - 0, - 0, - 0, - 0, - 0, - "call %P0", - 0, - 0, - "call %P0", - 0, - 0, - "call %P1", - 0, - 0, - "call %P1", - 0, - 0, - 0, - 0, - "frstor %0", - 0, - "nop", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - }; - -char *(*const insn_outfun[])() = - { - output_0, - 0, - output_2, - 0, - output_4, - 0, - output_6, - 0, - output_8, - 0, - output_10, - 0, - output_12, - 0, - output_14, - 0, - output_16, - output_17, - output_18, - output_19, - output_20, - output_21, - output_22, - output_23, - output_24, - output_25, - 0, - 0, - 0, - 0, - 0, - 0, - output_32, - output_33, - output_34, - 0, - 0, - 0, - output_38, - 0, - output_40, - output_41, - output_42, - output_43, - output_44, - output_45, - output_46, - output_47, - output_48, - output_49, - output_50, - output_51, - output_52, - output_53, - output_54, - output_55, - output_56, - output_57, - output_58, - output_59, - output_60, - 0, - output_62, - 0, - 0, - 0, - 0, - output_67, - output_68, - 0, - 0, - output_71, - output_72, - 0, - 0, - 0, - 0, - output_77, - output_78, - output_79, - output_80, - output_81, - output_82, - output_83, - output_84, - output_85, - 0, - 0, - output_88, - output_89, - output_90, - output_91, - 0, - 0, - output_94, - output_95, - output_96, - output_97, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_105, - 0, - output_107, - output_108, - output_109, - output_110, - output_111, - output_112, - output_113, - output_114, - output_115, - output_116, - output_117, - output_118, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_141, - output_142, - output_143, - output_144, - output_145, - 0, - output_147, - output_148, - output_149, - output_150, - output_151, - 0, - output_153, - output_154, - output_155, - output_156, - output_157, - output_158, - output_159, - output_160, - output_161, - output_162, - output_163, - output_164, - output_165, - output_166, - output_167, - output_168, - output_169, - 0, - output_171, - 0, - output_173, - 0, - output_175, - 0, - output_177, - 0, - output_179, - 0, - output_181, - 0, - output_183, - 0, - output_185, - 0, - output_187, - 0, - output_189, - 0, - output_191, - 0, - output_193, - 0, - output_195, - 0, - 0, - 0, - output_199, - 0, - 0, - 0, - output_203, - 0, - 0, - 0, - output_207, - 0, - 0, - output_210, - output_211, - output_212, - 0, - output_214, - 0, - output_216, - 0, - output_218, - 0, - 0, - output_221, - 0, - output_223, - output_224, - 0, - output_226, - 0, - 0, - output_229, - 0, - 0, - output_232, - 0, - 0, - output_235, - 0, - 0, - output_238, - output_239, - 0, - 0, - output_242, - 0, - 0, - output_245, - 0, - output_247, - output_248, - 0, - output_250, - 0, - output_252, - output_253, - output_254, - output_255, - output_256, - output_257, - output_258, - output_259, - output_260, - 0, - output_262, - }; - -rtx (*const insn_gen_function[]) () = - { - gen_tstsi_1, - gen_tstsi, - gen_tsthi_1, - gen_tsthi, - gen_tstqi_1, - gen_tstqi, - gen_tstsf_cc, - gen_tstsf, - gen_tstdf_cc, - gen_tstdf, - gen_cmpsi_1, - gen_cmpsi, - gen_cmphi_1, - gen_cmphi, - gen_cmpqi_1, - gen_cmpqi, - 0, - 0, - 0, - 0, - 0, - 0, - gen_cmpsf_cc_1, - 0, - 0, - 0, - gen_cmpdf, - gen_cmpsf, - gen_cmpdf_cc, - gen_cmpdf_ccfpeq, - gen_cmpsf_cc, - gen_cmpsf_ccfpeq, - 0, - 0, - 0, - 0, - 0, - gen_movsi, - 0, - 0, - gen_movhi, - gen_movstricthi, - 0, - gen_movqi, - gen_movstrictqi, - 0, - gen_movsf, - 0, - gen_swapdf, - gen_movdf, - 0, - gen_movdi, - gen_zero_extendhisi2, - gen_zero_extendqihi2, - gen_zero_extendqisi2, - gen_zero_extendsidi2, - gen_extendsidi2, - gen_extendhisi2, - gen_extendqihi2, - gen_extendqisi2, - gen_extendsfdf2, - gen_truncdfsf2, - 0, - gen_fixuns_truncdfsi2, - gen_fixuns_truncsfsi2, - gen_fix_truncdfdi2, - gen_fix_truncsfdi2, - 0, - 0, - gen_fix_truncdfsi2, - gen_fix_truncsfsi2, - 0, - 0, - gen_floatsisf2, - gen_floatdisf2, - gen_floatsidf2, - gen_floatdidf2, - 0, - 0, - 0, - 0, - gen_adddi3, - gen_addsi3, - gen_addhi3, - gen_addqi3, - 0, - gen_adddf3, - gen_addsf3, - gen_subdi3, - gen_subsi3, - gen_subhi3, - gen_subqi3, - gen_subdf3, - gen_subsf3, - 0, - gen_mulhi3, - 0, - gen_mulsi3, - 0, - gen_muldf3, - gen_mulsf3, - gen_divqi3, - gen_udivqi3, - gen_divdf3, - gen_divsf3, - gen_divmodsi4, - gen_divmodhi4, - gen_udivmodsi4, - gen_udivmodhi4, - gen_andsi3, - gen_andhi3, - gen_andqi3, - gen_iorsi3, - gen_iorhi3, - gen_iorqi3, - gen_xorsi3, - gen_xorhi3, - gen_xorqi3, - gen_negdi2, - gen_negsi2, - gen_neghi2, - gen_negqi2, - gen_negsf2, - gen_negdf2, - 0, - gen_abssf2, - gen_absdf2, - 0, - gen_sqrtsf2, - gen_sqrtdf2, - 0, - gen_sindf2, - gen_sinsf2, - 0, - gen_cosdf2, - gen_cossf2, - 0, - gen_one_cmplsi2, - gen_one_cmplhi2, - gen_one_cmplqi2, - gen_ashldi3, - gen_ashldi3_const_int, - gen_ashldi3_non_const_int, - gen_ashlsi3, - gen_ashlhi3, - gen_ashlqi3, - gen_ashrdi3, - gen_ashrdi3_const_int, - gen_ashrdi3_non_const_int, - gen_ashrsi3, - gen_ashrhi3, - gen_ashrqi3, - gen_lshrdi3, - gen_lshrdi3_const_int, - gen_lshrdi3_non_const_int, - gen_lshrsi3, - gen_lshrhi3, - gen_lshrqi3, - gen_rotlsi3, - gen_rotlhi3, - gen_rotlqi3, - gen_rotrsi3, - gen_rotrhi3, - gen_rotrqi3, - 0, - 0, - 0, - 0, - 0, - 0, - gen_seq, - 0, - gen_sne, - 0, - gen_sgt, - 0, - gen_sgtu, - 0, - gen_slt, - 0, - gen_sltu, - 0, - gen_sge, - 0, - gen_sgeu, - 0, - gen_sle, - 0, - gen_sleu, - 0, - gen_beq, - 0, - gen_bne, - 0, - gen_bgt, - 0, - gen_bgtu, - 0, - gen_blt, - 0, - gen_bltu, - 0, - gen_bge, - 0, - gen_bgeu, - 0, - gen_ble, - 0, - gen_bleu, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_jump, - gen_indirect_jump, - gen_casesi, - 0, - gen_tablejump, - gen_call_pop, - 0, - 0, - gen_call, - 0, - 0, - gen_call_value_pop, - 0, - 0, - gen_call_value, - 0, - 0, - gen_untyped_call, - 0, - 0, - gen_untyped_return, - gen_update_return, - gen_return, - gen_nop, - gen_movstrsi, - 0, - gen_cmpstrsi, - 0, - 0, - gen_ffssi2, - 0, - gen_ffshi2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_strlensi, - 0, - }; - -char *insn_name[] = - { - "tstsi_1", - "tstsi", - "tsthi_1", - "tsthi", - "tstqi_1", - "tstqi", - "tstsf_cc", - "tstsf", - "tstdf_cc", - "tstdf", - "cmpsi_1", - "cmpsi", - "cmphi_1", - "cmphi", - "cmpqi_1", - "cmpqi", - "cmpqi+1", - "cmpqi+2", - "cmpqi+3", - "cmpsf_cc_1-3", - "cmpsf_cc_1-2", - "cmpsf_cc_1-1", - "cmpsf_cc_1", - "cmpsf_cc_1+1", - "cmpsf_cc_1+2", - "cmpdf-1", - "cmpdf", - "cmpsf", - "cmpdf_cc", - "cmpdf_ccfpeq", - "cmpsf_cc", - "cmpsf_ccfpeq", - "cmpsf_ccfpeq+1", - "cmpsf_ccfpeq+2", - "cmpsf_ccfpeq+3", - "movsi-2", - "movsi-1", - "movsi", - "movsi+1", - "movhi-1", - "movhi", - "movstricthi", - "movstricthi+1", - "movqi", - "movstrictqi", - "movstrictqi+1", - "movsf", - "movsf+1", - "swapdf", - "movdf", - "movdf+1", - "movdi", - "zero_extendhisi2", - "zero_extendqihi2", - "zero_extendqisi2", - "zero_extendsidi2", - "extendsidi2", - "extendhisi2", - "extendqihi2", - "extendqisi2", - "extendsfdf2", - "truncdfsf2", - "truncdfsf2+1", - "fixuns_truncdfsi2", - "fixuns_truncsfsi2", - "fix_truncdfdi2", - "fix_truncsfdi2", - "fix_truncsfdi2+1", - "fix_truncdfsi2-1", - "fix_truncdfsi2", - "fix_truncsfsi2", - "fix_truncsfsi2+1", - "floatsisf2-1", - "floatsisf2", - "floatdisf2", - "floatsidf2", - "floatdidf2", - "floatdidf2+1", - "floatdidf2+2", - "adddi3-2", - "adddi3-1", - "adddi3", - "addsi3", - "addhi3", - "addqi3", - "addqi3+1", - "adddf3", - "addsf3", - "subdi3", - "subsi3", - "subhi3", - "subqi3", - "subdf3", - "subsf3", - "subsf3+1", - "mulhi3", - "mulhi3+1", - "mulsi3", - "mulsi3+1", - "muldf3", - "mulsf3", - "divqi3", - "udivqi3", - "divdf3", - "divsf3", - "divmodsi4", - "divmodhi4", - "udivmodsi4", - "udivmodhi4", - "andsi3", - "andhi3", - "andqi3", - "iorsi3", - "iorhi3", - "iorqi3", - "xorsi3", - "xorhi3", - "xorqi3", - "negdi2", - "negsi2", - "neghi2", - "negqi2", - "negsf2", - "negdf2", - "negdf2+1", - "abssf2", - "absdf2", - "absdf2+1", - "sqrtsf2", - "sqrtdf2", - "sqrtdf2+1", - "sindf2", - "sinsf2", - "sinsf2+1", - "cosdf2", - "cossf2", - "cossf2+1", - "one_cmplsi2", - "one_cmplhi2", - "one_cmplqi2", - "ashldi3", - "ashldi3_const_int", - "ashldi3_non_const_int", - "ashlsi3", - "ashlhi3", - "ashlqi3", - "ashrdi3", - "ashrdi3_const_int", - "ashrdi3_non_const_int", - "ashrsi3", - "ashrhi3", - "ashrqi3", - "lshrdi3", - "lshrdi3_const_int", - "lshrdi3_non_const_int", - "lshrsi3", - "lshrhi3", - "lshrqi3", - "rotlsi3", - "rotlhi3", - "rotlqi3", - "rotrsi3", - "rotrhi3", - "rotrqi3", - "rotrqi3+1", - "rotrqi3+2", - "rotrqi3+3", - "seq-3", - "seq-2", - "seq-1", - "seq", - "seq+1", - "sne", - "sne+1", - "sgt", - "sgt+1", - "sgtu", - "sgtu+1", - "slt", - "slt+1", - "sltu", - "sltu+1", - "sge", - "sge+1", - "sgeu", - "sgeu+1", - "sle", - "sle+1", - "sleu", - "sleu+1", - "beq", - "beq+1", - "bne", - "bne+1", - "bgt", - "bgt+1", - "bgtu", - "bgtu+1", - "blt", - "blt+1", - "bltu", - "bltu+1", - "bge", - "bge+1", - "bgeu", - "bgeu+1", - "ble", - "ble+1", - "bleu", - "bleu+1", - "bleu+2", - "bleu+3", - "bleu+4", - "bleu+5", - "bleu+6", - "jump-5", - "jump-4", - "jump-3", - "jump-2", - "jump-1", - "jump", - "indirect_jump", - "casesi", - "casesi+1", - "tablejump", - "call_pop", - "call_pop+1", - "call-1", - "call", - "call+1", - "call_value_pop-1", - "call_value_pop", - "call_value_pop+1", - "call_value-1", - "call_value", - "call_value+1", - "untyped_call-1", - "untyped_call", - "untyped_call+1", - "untyped_return-1", - "untyped_return", - "update_return", - "return", - "nop", - "movstrsi", - "movstrsi+1", - "cmpstrsi", - "cmpstrsi+1", - "ffssi2-1", - "ffssi2", - "ffssi2+1", - "ffshi2", - "ffshi2+1", - "ffshi2+2", - "ffshi2+3", - "ffshi2+4", - "ffshi2+5", - "strlensi-4", - "strlensi-3", - "strlensi-2", - "strlensi-1", - "strlensi", - "strlensi+1", - }; -char **insn_name_ptr = insn_name; - -const int insn_n_operands[] = - { - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 4, - 4, - 4, - 4, - 4, - 3, - 4, - 4, - 4, - 3, - 2, - 2, - 3, - 3, - 3, - 3, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 8, - 8, - 6, - 6, - 5, - 5, - 5, - 5, - 5, - 5, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 4, - 4, - 4, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 3, - 3, - 2, - 3, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 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, - 1, - 7, - 3, - 1, - 4, - 4, - 4, - 2, - 2, - 2, - 5, - 5, - 5, - 3, - 3, - 3, - 3, - 3, - 3, - 2, - 1, - 0, - 0, - 5, - 5, - 5, - 5, - 4, - 3, - 3, - 3, - 3, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - }; - -const int insn_n_dups[] = - { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 7, - 7, - 5, - 5, - 1, - 1, - 2, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 2, - 2, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 2, - 3, - 3, - 3, - 2, - 0, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 5, - 1, - }; - -char *const insn_operand_constraint[][MAX_RECOG_OPERANDS] = - { - { "rm", }, - { "", }, - { "rm", }, - { "", }, - { "qm", }, - { "", }, - { "f", "=a", }, - { "", "", }, - { "f", "=a", }, - { "", "", }, - { "mr,r", "ri,mr", }, - { "", "", }, - { "mr,r", "ri,mr", }, - { "", "", }, - { "q,mq", "qm,nq", }, - { "", "", }, - { "f,fm", "fm,f", "", "=a,a", }, - { "f", "rm", "", "=a", }, - { "rm", "f", "", "=a", }, - { "f", "fm", "", "=a", }, - { "fm", "f", "", "=a", }, - { "f", "f", "=a", }, - { "f,fm", "fm,f", "", "=a,a", }, - { "f", "rm", "", "=a", }, - { "rm", "f", "", "=a", }, - { "f", "f", "=a", }, - { "", "", }, - { "", "", }, - { "", "", "", }, - { "", "", "", }, - { "", "", "", }, - { "", "", "", }, - { "%ro", "ri", }, - { "%ro", "ri", }, - { "%qm", "qi", }, - { "=<", "g", }, - { "=<", "ri", }, - { "", "", }, - { "=g,r", "ri,m", }, - { "=<", "g", }, - { "=g,r", "ri,m", }, - { "+g,r", "ri,m", }, - { "=<", "q", }, - { "=q,*r,qm", "*g,q,qn", }, - { "+q,qm", "*g,qn", }, - { "=<,<", "gF,f", }, - { "=*rfm,*rf,f,!*rm", "*rf,*rfm,fG,fF", }, - { "=<,<", "gF,f", }, - { "f", "f", }, - { "=*rfm,*rf,f,!*rm", "*rf,*rfm,fG,fF", }, - { "=<", "roiF", }, - { "=r,rm", "m,riF", }, - { "=r", "rm", }, - { "=r", "qm", }, - { "=r", "qm", }, - { "=r", "0", }, - { "=r", "0", }, - { "=r", "rm", }, - { "=r", "qm", }, - { "=r", "qm", }, - { "=fm,f", "f,fm", }, - { "", "", }, - { "=f,m", "0,f", "m,m", }, - { "", "", "", "", "", "", "", "", }, - { "", "", "", "", "", "", "", "", }, - { "", "", "", "", "", "", }, - { "", "", "", "", "", "", }, - { "=rm", "f", "m", "m", "=&q", }, - { "=rm", "f", "m", "m", "=&q", }, - { "", "", "", "", "", }, - { "", "", "", "", "", }, - { "=rm", "f", "m", "m", "=&q", }, - { "=rm", "f", "m", "m", "=&q", }, - { "", "", }, - { "", "", }, - { "", "", }, - { "", "", }, - { "=f", "rm", }, - { "=f", "rm", }, - { "=f", "rm", }, - { "=f", "rm", }, - { "=&r,ro", "%0,0", "o,riF", }, - { "=?r,rm,r", "%r,0,0", "ri,ri,rm", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=qm,q", "%0,0", "qn,qmn", }, - { "=r", "p", }, - { "", "", "", }, - { "", "", "", }, - { "=&r,ro", "0,0", "o,riF", }, - { "=rm,r", "0,0", "ri,rm", }, - { "=rm,r", "0,0", "ri,rm", }, - { "=qm,q", "0,0", "qn,qmn", }, - { "", "", "", }, - { "", "", "", }, - { "=r", "%0", "r", }, - { "=r,r", "%0,rm", "g,i", }, - { "=r", "%0", "r", }, - { "=r,r", "%0,rm", "g,i", }, - { "=a", "%0", "qm", }, - { "", "", "", }, - { "", "", "", }, - { "=a", "0", "qm", }, - { "=a", "0", "qm", }, - { "", "", "", }, - { "", "", "", }, - { "=a", "0", "rm", "=&d", }, - { "=a", "0", "rm", "=&d", }, - { "=a", "0", "rm", "=&d", }, - { "=a", "0", "rm", "=&d", }, - { "=r,r,rm,r", "%rm,qm,0,0", "L,K,ri,rm", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=qm,q", "%0,0", "qn,qmn", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=qm,q", "%0,0", "qn,qmn", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=qm,q", "%0,0", "qn,qm", }, - { "=&ro", "0", }, - { "=rm", "0", }, - { "=rm", "0", }, - { "=qm", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=rm", "0", }, - { "=rm", "0", }, - { "=qm", "0", }, - { "", "", "", }, - { "=&r", "0", "J", }, - { "=&r", "0", "c", }, - { "=r,rm", "r,0", "M,cI", }, - { "=rm", "0", "cI", }, - { "=qm", "0", "cI", }, - { "", "", "", }, - { "=&r", "0", "J", }, - { "=&r", "0", "c", }, - { "=rm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=qm", "0", "cI", }, - { "", "", "", }, - { "=&r", "0", "J", }, - { "=&r", "0", "c", }, - { "=rm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=qm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=qm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=qm", "0", "cI", }, - { "+rm", "", "r", "n", }, - { "=rm", "r", "0", }, - { "=rm", "0", "r", }, - { "r", "r", }, - { "r", "n", "n", }, - { "rm", "n", "n", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { 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 }, - { "rm", }, - { "", "", "", "", "", "", "", }, - { "r", "", "=&r", }, - { "rm", }, - { "", "", "", "", }, - { "m", "g", "", "i", }, - { "", "g", "", "i", }, - { "", "", }, - { "m", "g", }, - { "", "g", }, - { "", "", "", "", "", }, - { "=rf", "m", "g", "", "i", }, - { "=rf", "", "g", "", "i", }, - { "", "", "", }, - { "=rf", "m", "g", }, - { "=rf", "", "g", }, - { "", "", "", }, - { "m", "o", "", }, - { "", "o", "", }, - { "", "", }, - { "m", }, - { 0 }, - { 0 }, - { "", "", "", "", "", }, - { "D", "S", "n", "i", "=&c", }, - { "", "", "", "", "", }, - { "=&r", "S", "D", "c", "i", }, - { "S", "D", "c", "i", }, - { "", "", "", }, - { "=&r", "rm", "=r", }, - { "", "", "", }, - { "=&r", "rm", "=r", }, - { "=f,f", "0,fm", "fm,0", "", }, - { "=f", "rm", "0", "", }, - { "=f,f", "fm,0", "0,f", "", }, - { "=f", "0", "rm", "", }, - { "=f,f", "0,f", "fm,0", "", }, - { "=f,f", "0,fm", "fm,0", "", }, - { "=f", "rm", "0", "", }, - { "=f", "0", "rm", "", }, - { "", "", "", "", }, - { "=&c", "D", "a", "i", }, - }; - -const enum machine_mode insn_operand_mode[][MAX_RECOG_OPERANDS] = - { - { SImode, }, - { SImode, }, - { HImode, }, - { HImode, }, - { QImode, }, - { QImode, }, - { SFmode, HImode, }, - { SFmode, HImode, }, - { DFmode, HImode, }, - { DFmode, HImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { DFmode, DFmode, VOIDmode, HImode, }, - { DFmode, SImode, VOIDmode, HImode, }, - { SImode, DFmode, VOIDmode, HImode, }, - { DFmode, SFmode, VOIDmode, HImode, }, - { SFmode, DFmode, VOIDmode, HImode, }, - { DFmode, DFmode, HImode, }, - { SFmode, SFmode, VOIDmode, HImode, }, - { SFmode, SImode, VOIDmode, HImode, }, - { SImode, SFmode, VOIDmode, HImode, }, - { SFmode, SFmode, HImode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, HImode, }, - { DFmode, DFmode, HImode, }, - { SFmode, SFmode, HImode, }, - { SFmode, SFmode, HImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { DImode, DImode, }, - { DImode, DImode, }, - { SImode, HImode, }, - { HImode, QImode, }, - { SImode, QImode, }, - { DImode, SImode, }, - { DImode, SImode, }, - { SImode, HImode, }, - { HImode, QImode, }, - { SImode, QImode, }, - { DFmode, SFmode, }, - { SFmode, DFmode, }, - { SFmode, DFmode, SFmode, }, - { SImode, DFmode, VOIDmode, VOIDmode, VOIDmode, VOIDmode, VOIDmode, SImode, }, - { SImode, SFmode, VOIDmode, VOIDmode, VOIDmode, VOIDmode, VOIDmode, SImode, }, - { DImode, DFmode, VOIDmode, VOIDmode, VOIDmode, SImode, }, - { DImode, SFmode, VOIDmode, VOIDmode, VOIDmode, SImode, }, - { DImode, DFmode, SImode, SImode, SImode, }, - { DImode, SFmode, SImode, SImode, SImode, }, - { SImode, DFmode, VOIDmode, VOIDmode, SImode, }, - { SImode, SFmode, VOIDmode, VOIDmode, SImode, }, - { SImode, DFmode, SImode, SImode, SImode, }, - { SImode, SFmode, SImode, SImode, SImode, }, - { SFmode, SImode, }, - { SFmode, DImode, }, - { DFmode, SImode, }, - { DFmode, DImode, }, - { DFmode, DImode, }, - { SFmode, DImode, }, - { DFmode, SImode, }, - { SFmode, SImode, }, - { DImode, DImode, DImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { DImode, DImode, DImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, HImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, QImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { QImode, HImode, QImode, }, - { QImode, HImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { SImode, SImode, SImode, SImode, }, - { HImode, HImode, HImode, HImode, }, - { SImode, SImode, SImode, SImode, }, - { HImode, HImode, HImode, HImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { DImode, DImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, SFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, SFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, SFmode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { DFmode, SFmode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { DFmode, SFmode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, VOIDmode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, }, - { SImode, SImode, SImode, }, - { QImode, SImode, SImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { SImode, }, - { SImode, SImode, SImode, VOIDmode, VOIDmode, VOIDmode, SImode, }, - { SImode, VOIDmode, SImode, }, - { SImode, }, - { QImode, SImode, VOIDmode, SImode, }, - { QImode, SImode, VOIDmode, SImode, }, - { SImode, SImode, VOIDmode, SImode, }, - { QImode, SImode, }, - { QImode, SImode, }, - { SImode, SImode, }, - { VOIDmode, QImode, SImode, VOIDmode, SImode, }, - { VOIDmode, QImode, SImode, VOIDmode, SImode, }, - { VOIDmode, SImode, SImode, VOIDmode, SImode, }, - { VOIDmode, QImode, SImode, }, - { VOIDmode, QImode, SImode, }, - { VOIDmode, SImode, SImode, }, - { QImode, BLKmode, VOIDmode, }, - { QImode, DImode, VOIDmode, }, - { SImode, DImode, VOIDmode, }, - { BLKmode, VOIDmode, }, - { SImode, }, - { VOIDmode }, - { VOIDmode }, - { BLKmode, BLKmode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, SImode, }, - { SImode, BLKmode, BLKmode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, HImode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { DFmode, SImode, DFmode, DFmode, }, - { DFmode, SFmode, DFmode, DFmode, }, - { DFmode, DFmode, SImode, DFmode, }, - { DFmode, DFmode, SFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { SFmode, SImode, SFmode, SFmode, }, - { SFmode, SFmode, SImode, SFmode, }, - { SImode, BLKmode, QImode, SImode, }, - { SImode, SImode, QImode, SImode, }, - }; - -const char insn_operand_strict_low[][MAX_RECOG_OPERANDS] = - { - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 1, 0, }, - { 0, 0, }, - { 0, 0, }, - { 1, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0, }, - { 0, 0, 0, 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, }, - { 0 }, - { 0 }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - }; - -extern int nonimmediate_operand (); -extern int register_operand (); -extern int scratch_operand (); -extern int general_operand (); -extern int VOIDmode_compare_op (); -extern int push_operand (); -extern int memory_operand (); -extern int address_operand (); -extern int nonmemory_operand (); -extern int const_int_operand (); -extern int indirect_operand (); -extern int immediate_operand (); -extern int call_insn_operand (); -extern int symbolic_operand (); -extern int binary_387_op (); - -int (*const insn_operand_predicate[][MAX_RECOG_OPERANDS])() = - { - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { register_operand, scratch_operand, }, - { register_operand, scratch_operand, }, - { register_operand, scratch_operand, }, - { register_operand, scratch_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, nonimmediate_operand, VOIDmode_compare_op, scratch_operand, }, - { register_operand, nonimmediate_operand, VOIDmode_compare_op, scratch_operand, }, - { nonimmediate_operand, register_operand, VOIDmode_compare_op, scratch_operand, }, - { register_operand, nonimmediate_operand, VOIDmode_compare_op, scratch_operand, }, - { nonimmediate_operand, register_operand, VOIDmode_compare_op, scratch_operand, }, - { register_operand, register_operand, scratch_operand, }, - { nonimmediate_operand, nonimmediate_operand, VOIDmode_compare_op, scratch_operand, }, - { register_operand, nonimmediate_operand, VOIDmode_compare_op, scratch_operand, }, - { nonimmediate_operand, register_operand, VOIDmode_compare_op, scratch_operand, }, - { register_operand, register_operand, scratch_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, register_operand, scratch_operand, }, - { register_operand, register_operand, scratch_operand, }, - { register_operand, register_operand, scratch_operand, }, - { register_operand, register_operand, scratch_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { register_operand, register_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, general_operand, }, - { nonimmediate_operand, register_operand, }, - { nonimmediate_operand, register_operand, memory_operand, }, - { general_operand, register_operand, 0, 0, 0, 0, 0, scratch_operand, }, - { general_operand, register_operand, 0, 0, 0, 0, 0, scratch_operand, }, - { general_operand, register_operand, 0, 0, 0, scratch_operand, }, - { general_operand, register_operand, 0, 0, 0, scratch_operand, }, - { general_operand, register_operand, memory_operand, memory_operand, scratch_operand, }, - { general_operand, register_operand, memory_operand, memory_operand, scratch_operand, }, - { general_operand, register_operand, 0, 0, scratch_operand, }, - { general_operand, register_operand, 0, 0, scratch_operand, }, - { general_operand, register_operand, memory_operand, memory_operand, scratch_operand, }, - { general_operand, register_operand, memory_operand, memory_operand, scratch_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { register_operand, address_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, register_operand, general_operand, register_operand, }, - { register_operand, register_operand, general_operand, register_operand, }, - { register_operand, register_operand, general_operand, register_operand, }, - { register_operand, register_operand, general_operand, register_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { register_operand, register_operand, nonmemory_operand, }, - { register_operand, register_operand, const_int_operand, }, - { register_operand, register_operand, register_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { register_operand, register_operand, nonmemory_operand, }, - { register_operand, register_operand, const_int_operand, }, - { register_operand, register_operand, register_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { register_operand, register_operand, nonmemory_operand, }, - { register_operand, register_operand, const_int_operand, }, - { register_operand, register_operand, register_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, 0, general_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, const_int_operand, const_int_operand, }, - { general_operand, const_int_operand, const_int_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { 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 }, - { general_operand, }, - { general_operand, general_operand, general_operand, 0, 0, 0, scratch_operand, }, - { register_operand, 0, scratch_operand, }, - { general_operand, }, - { indirect_operand, general_operand, 0, immediate_operand, }, - { call_insn_operand, general_operand, 0, immediate_operand, }, - { symbolic_operand, general_operand, 0, immediate_operand, }, - { indirect_operand, general_operand, }, - { call_insn_operand, general_operand, }, - { symbolic_operand, general_operand, }, - { 0, indirect_operand, general_operand, 0, immediate_operand, }, - { 0, call_insn_operand, general_operand, 0, immediate_operand, }, - { 0, symbolic_operand, general_operand, 0, immediate_operand, }, - { 0, indirect_operand, general_operand, }, - { 0, call_insn_operand, general_operand, }, - { 0, symbolic_operand, general_operand, }, - { indirect_operand, memory_operand, 0, }, - { call_insn_operand, memory_operand, 0, }, - { symbolic_operand, memory_operand, 0, }, - { memory_operand, 0, }, - { memory_operand, }, - { 0 }, - { 0 }, - { memory_operand, memory_operand, const_int_operand, const_int_operand, scratch_operand, }, - { address_operand, address_operand, const_int_operand, immediate_operand, scratch_operand, }, - { general_operand, general_operand, general_operand, general_operand, immediate_operand, }, - { general_operand, address_operand, address_operand, register_operand, immediate_operand, }, - { address_operand, address_operand, register_operand, immediate_operand, }, - { general_operand, general_operand, scratch_operand, }, - { register_operand, general_operand, scratch_operand, }, - { general_operand, general_operand, scratch_operand, }, - { register_operand, general_operand, scratch_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, general_operand, register_operand, immediate_operand, }, - { register_operand, address_operand, register_operand, immediate_operand, }, - }; - -const int insn_n_alternatives[] = - { - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 2, - 0, - 2, - 0, - 2, - 0, - 2, - 1, - 1, - 1, - 1, - 1, - 2, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 0, - 2, - 1, - 2, - 2, - 1, - 3, - 2, - 2, - 4, - 2, - 1, - 4, - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 0, - 2, - 0, - 0, - 0, - 0, - 1, - 1, - 0, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 2, - 3, - 2, - 2, - 1, - 0, - 0, - 2, - 2, - 2, - 2, - 0, - 0, - 1, - 2, - 1, - 2, - 1, - 0, - 0, - 1, - 1, - 0, - 0, - 1, - 1, - 1, - 1, - 4, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 2, - 1, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 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, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 0, - 0, - 0, - 1, - 0, - 1, - 1, - 0, - 1, - 0, - 1, - 2, - 1, - 2, - 1, - 2, - 2, - 1, - 1, - 0, - 1, - }; diff --git a/gnu/usr.bin/gcc2/common/insn-peep.c b/gnu/usr.bin/gcc2/common/insn-peep.c deleted file mode 100644 index 37136c4333d0..000000000000 --- a/gnu/usr.bin/gcc2/common/insn-peep.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Generated automatically by the program `genpeep' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "regs.h" -#include "output.h" -#include "real.h" - -extern rtx peep_operand[]; - -#define operands peep_operand - -rtx -peephole (ins1) - rtx ins1; -{ - rtx insn, x, pat; - int i; - - if (NEXT_INSN (ins1) - && GET_CODE (NEXT_INSN (ins1)) == BARRIER) - return 0; - - return 0; -} - -rtx peep_operand[2]; diff --git a/gnu/usr.bin/gcc2/common/insn-recog.c b/gnu/usr.bin/gcc2/common/insn-recog.c deleted file mode 100644 index bca21b305fe8..000000000000 --- a/gnu/usr.bin/gcc2/common/insn-recog.c +++ /dev/null @@ -1,6158 +0,0 @@ -/* Generated automatically by the program `genrecog' -from the machine description file `md'. */ - -#include "config.h" -#include "rtl.h" -#include "insn-config.h" -#include "recog.h" -#include "real.h" -#include "output.h" -#include "flags.h" - - -/* `recog' contains a decision tree - that recognizes whether the rtx X0 is a valid instruction. - - recog returns -1 if the rtx is not valid. - If the rtx is valid, recog returns a nonnegative number - which is the insn code number for the pattern that matched. - This is the same as the order in the machine description of - the entry that matched. This number can be used as an index into - entry that matched. This number can be used as an index into various - insn_* tables, such as insn_templates, insn_outfun, and insn_n_operands - (found in insn-output.c). - - The third argument to recog is an optional pointer to an int. - If present, recog will accept a pattern if it matches except for - missing CLOBBER expressions at the end. In that case, the value - pointed to by the optional pointer will be set to the number of - CLOBBERs that need to be added (it should be initialized to zero by - the caller). If it is set nonzero, the caller should allocate a - PARALLEL of the appropriate size, copy the initial entries, and call - add_clobbers (found in insn-emit.c) to fill in the CLOBBERs.*/ - -rtx recog_operand[MAX_RECOG_OPERANDS]; - -rtx *recog_operand_loc[MAX_RECOG_OPERANDS]; - -rtx *recog_dup_loc[MAX_DUP_OPERANDS]; - -char recog_dup_num[MAX_DUP_OPERANDS]; - -#define operands recog_operand - -int -recog_1 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case SImode: - if (nonimmediate_operand (x1, SImode)) - { - ro[0] = x1; - return 0; - } - break; - case HImode: - if (nonimmediate_operand (x1, HImode)) - { - ro[0] = x1; - return 2; - } - break; - case QImode: - if (nonimmediate_operand (x1, QImode)) - { - ro[0] = x1; - return 4; - } - break; - case SFmode: - if (pnum_clobbers != 0 && register_operand (x1, SFmode)) - { - ro[0] = x1; - if (TARGET_80387 && ! TARGET_IEEE_FP) - { - *pnum_clobbers = 1; - return 6; - } - } - break; - case DFmode: - if (pnum_clobbers != 0 && register_operand (x1, DFmode)) - { - ro[0] = x1; - if (TARGET_80387 && ! TARGET_IEEE_FP) - { - *pnum_clobbers = 1; - return 8; - } - } - } - switch (GET_CODE (x1)) - { - case COMPARE: - goto L30; - case ZERO_EXTRACT: - goto L813; - } - L52: - if (VOIDmode_compare_op (x1, VOIDmode)) - { - ro[2] = x1; - goto L82; - } - L125: - switch (GET_MODE (x1)) - { - case CCFPEQmode: - switch (GET_CODE (x1)) - { - case COMPARE: - goto L126; - } - break; - case SImode: - switch (GET_CODE (x1)) - { - case AND: - goto L187; - } - break; - case HImode: - switch (GET_CODE (x1)) - { - case AND: - goto L192; - } - break; - case QImode: - if (GET_CODE (x1) == AND && 1) - goto L197; - } - goto ret0; - - L30: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[0] = x2; - goto L31; - } - break; - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[0] = x2; - goto L36; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[0] = x2; - goto L41; - } - } - goto L52; - - L31: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 10; - } - goto L52; - - L36: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 12; - } - goto L52; - - L41: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 14; - } - goto L52; - - L813: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - if (register_operand (x2, SImode)) - { - ro[0] = x2; - goto L814; - } - break; - case QImode: - if (general_operand (x2, QImode)) - { - ro[0] = x2; - goto L826; - } - } - goto L52; - - L814: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) != CONST_INT) - { - goto L52; - } - if (XWINT (x2, 0) == 1 && 1) - goto L815; - L820: - ro[1] = x2; - goto L821; - - L815: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - if (GET_CODE (operands[1]) != CONST_INT) - return 167; - } - x2 = XEXP (x1, 1); - goto L820; - - L821: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - return 168; - } - goto L52; - - L826: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[1] = x2; - goto L827; - } - goto L52; - - L827: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - if (GET_CODE (operands[0]) != MEM || ! MEM_VOLATILE_P (operands[0])) - return 169; - } - goto L52; - - L82: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - switch (GET_CODE (x2)) - { - case FLOAT: - goto L83; - case FLOAT_EXTEND: - goto L113; - case SUBREG: - case REG: - case MEM: - if (nonimmediate_operand (x2, DFmode)) - { - ro[0] = x2; - goto L54; - } - } - L67: - if (register_operand (x2, DFmode)) - { - ro[0] = x2; - goto L68; - } - break; - case SFmode: - if (GET_CODE (x2) == FLOAT && 1) - goto L169; - if (nonimmediate_operand (x2, SFmode)) - { - ro[0] = x2; - goto L140; - } - L153: - if (register_operand (x2, SFmode)) - { - ro[0] = x2; - goto L154; - } - } - goto L125; - - L83: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, SImode)) - { - ro[0] = x3; - goto L84; - } - goto L125; - - L84: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && register_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 18; - } - } - goto L125; - - L113: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, SFmode)) - { - ro[0] = x3; - goto L114; - } - goto L125; - - L114: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && register_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 20; - } - } - goto L125; - - L54: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && nonimmediate_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387 - && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)) - { - *pnum_clobbers = 1; - return 16; - } - } - x2 = XEXP (x1, 0); - goto L67; - - L68: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != DFmode) - { - goto L125; - } - switch (GET_CODE (x2)) - { - case FLOAT: - goto L69; - case FLOAT_EXTEND: - goto L99; - } - goto L125; - - L69: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && nonimmediate_operand (x3, SImode)) - { - ro[1] = x3; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 17; - } - } - goto L125; - - L99: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && nonimmediate_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 19; - } - } - goto L125; - - L169: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, SImode)) - { - ro[0] = x3; - goto L170; - } - goto L125; - - L170: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && register_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 24; - } - } - goto L125; - - L140: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && nonimmediate_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387 - && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)) - { - *pnum_clobbers = 1; - return 22; - } - } - x2 = XEXP (x1, 0); - goto L153; - - L154: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == FLOAT && 1) - goto L155; - goto L125; - - L155: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && nonimmediate_operand (x3, SImode)) - { - ro[1] = x3; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 23; - } - } - goto L125; - - L126: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - if (register_operand (x2, DFmode)) - { - ro[0] = x2; - goto L127; - } - break; - case SFmode: - if (register_operand (x2, SFmode)) - { - ro[0] = x2; - goto L183; - } - } - goto ret0; - - L127: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && register_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 21; - } - } - goto ret0; - - L183: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && register_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 25; - } - } - goto ret0; - - L187: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L188; - } - goto ret0; - - L188: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 32; - } - goto ret0; - - L192: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[0] = x2; - goto L193; - } - goto ret0; - - L193: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 33; - } - goto ret0; - - L197: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[0] = x2; - goto L198; - } - goto ret0; - - L198: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 34; - } - goto ret0; - ret0: return -1; -} - -int -recog_2 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - x2 = XEXP (x1, 0); - switch (GET_CODE (x2)) - { - case EQ: - goto L882; - case NE: - goto L891; - case GT: - goto L900; - case GTU: - goto L909; - case LT: - goto L918; - case LTU: - goto L927; - case GE: - goto L936; - case GEU: - goto L945; - case LE: - goto L954; - case LEU: - goto L963; - } - goto ret0; - - L882: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L883; - goto ret0; - - L883: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L884; - goto ret0; - - L884: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L885; - case PC: - goto L975; - } - goto ret0; - - L885: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L886; - - L886: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 191; - goto ret0; - - L975: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L976; - goto ret0; - - L976: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 210; - - L891: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L892; - goto ret0; - - L892: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L893; - goto ret0; - - L893: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L894; - case PC: - goto L984; - } - goto ret0; - - L894: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L895; - - L895: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 193; - goto ret0; - - L984: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L985; - goto ret0; - - L985: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 211; - - L900: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L901; - goto ret0; - - L901: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L902; - goto ret0; - - L902: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L903; - case PC: - goto L993; - } - goto ret0; - - L903: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L904; - - L904: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 195; - goto ret0; - - L993: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L994; - goto ret0; - - L994: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 212; - - L909: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L910; - goto ret0; - - L910: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L911; - goto ret0; - - L911: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L912; - case PC: - goto L1002; - } - goto ret0; - - L912: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L913; - - L913: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 197; - goto ret0; - - L1002: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1003; - goto ret0; - - L1003: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 213; - - L918: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L919; - goto ret0; - - L919: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L920; - goto ret0; - - L920: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L921; - case PC: - goto L1011; - } - goto ret0; - - L921: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L922; - - L922: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 199; - goto ret0; - - L1011: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1012; - goto ret0; - - L1012: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 214; - - L927: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L928; - goto ret0; - - L928: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L929; - goto ret0; - - L929: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L930; - case PC: - goto L1020; - } - goto ret0; - - L930: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L931; - - L931: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 201; - goto ret0; - - L1020: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1021; - goto ret0; - - L1021: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 215; - - L936: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L937; - goto ret0; - - L937: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L938; - goto ret0; - - L938: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L939; - case PC: - goto L1029; - } - goto ret0; - - L939: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L940; - - L940: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 203; - goto ret0; - - L1029: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1030; - goto ret0; - - L1030: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 216; - - L945: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L946; - goto ret0; - - L946: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L947; - goto ret0; - - L947: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L948; - case PC: - goto L1038; - } - goto ret0; - - L948: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L949; - - L949: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 205; - goto ret0; - - L1038: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1039; - goto ret0; - - L1039: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 217; - - L954: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L955; - goto ret0; - - L955: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L956; - goto ret0; - - L956: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L957; - case PC: - goto L1047; - } - goto ret0; - - L957: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L958; - - L958: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 207; - goto ret0; - - L1047: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1048; - goto ret0; - - L1048: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 218; - - L963: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L964; - goto ret0; - - L964: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L965; - goto ret0; - - L965: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L966; - case PC: - goto L1056; - } - goto ret0; - - L966: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L967; - - L967: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 209; - goto ret0; - - L1056: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1057; - goto ret0; - - L1057: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 219; - ret0: return -1; -} - -int -recog_3 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 0); - switch (GET_MODE (x1)) - { - case SImode: - switch (GET_CODE (x1)) - { - case MEM: - if (push_operand (x1, SImode)) - { - ro[0] = x1; - goto L201; - } - break; - case ZERO_EXTRACT: - goto L792; - } - L208: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - goto L257; - } - L431: - if (register_operand (x1, SImode)) - { - ro[0] = x1; - goto L432; - } - L439: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - goto L440; - } - break; - case HImode: - if (GET_CODE (x1) == MEM && push_operand (x1, HImode)) - { - ro[0] = x1; - goto L212; - } - L214: - if (general_operand (x1, HImode)) - { - ro[0] = x1; - goto L261; - } - break; - case QImode: - if (GET_CODE (x1) == MEM && push_operand (x1, QImode)) - { - ro[0] = x1; - goto L222; - } - L224: - if (general_operand (x1, QImode)) - { - ro[0] = x1; - goto L427; - } - L829: - if (register_operand (x1, QImode)) - { - ro[0] = x1; - goto L830; - } - break; - case SFmode: - if (GET_CODE (x1) == MEM && push_operand (x1, SFmode)) - { - ro[0] = x1; - goto L232; - } - L234: - if (general_operand (x1, SFmode)) - { - ro[0] = x1; - goto L235; - } - L399: - if (register_operand (x1, SFmode)) - { - ro[0] = x1; - goto L400; - } - break; - case DFmode: - if (GET_CODE (x1) == MEM && push_operand (x1, DFmode)) - { - ro[0] = x1; - goto L238; - } - L247: - if (general_operand (x1, DFmode)) - { - ro[0] = x1; - goto L289; - } - L395: - if (register_operand (x1, DFmode)) - { - ro[0] = x1; - goto L396; - } - break; - case DImode: - if (GET_CODE (x1) == MEM && push_operand (x1, DImode)) - { - ro[0] = x1; - goto L251; - } - L253: - if (general_operand (x1, DImode)) - { - ro[0] = x1; - goto L412; - } - L268: - if (register_operand (x1, DImode)) - { - ro[0] = x1; - goto L269; - } - } - switch (GET_CODE (x1)) - { - case CC0: - goto L2; - case STRICT_LOW_PART: - goto L218; - case PC: - goto L1081; - } - L1147: - ro[0] = x1; - goto L1148; - L1236: - switch (GET_MODE (x1)) - { - case SImode: - if (register_operand (x1, SImode)) - { - ro[0] = x1; - goto L1237; - } - break; - case HImode: - if (register_operand (x1, HImode)) - { - ro[0] = x1; - goto L1252; - } - break; - case DFmode: - if (register_operand (x1, DFmode)) - { - ro[0] = x1; - goto L1258; - } - break; - case SFmode: - if (register_operand (x1, SFmode)) - { - ro[0] = x1; - goto L1287; - } - } - goto ret0; - - L201: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - goto L205; - x1 = XEXP (x0, 0); - goto L208; - - L205: - ro[1] = x1; - if (! TARGET_486) - return 35; - L206: - ro[1] = x1; - if (TARGET_486) - return 36; - x1 = XEXP (x0, 0); - goto L208; - - L792: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && general_operand (x2, SImode)) - { - ro[0] = x2; - goto L793; - } - goto L1147; - - L793: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 1 && 1) - goto L794; - goto L1147; - - L794: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L795; - } - goto L1147; - - L795: - x1 = XEXP (x0, 1); - if (GET_CODE (x1) == CONST_INT && 1) - { - ro[3] = x1; - if (! TARGET_486 && GET_CODE (operands[2]) != CONST_INT) - return 164; - } - x1 = XEXP (x0, 0); - goto L1147; - - L257: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case SImode: - switch (GET_CODE (x1)) - { - case ZERO_EXTEND: - goto L258; - case SIGN_EXTEND: - goto L278; - case PLUS: - goto L418; - } - } - if (general_operand (x1, SImode)) - { - ro[1] = x1; - return 38; - } - x1 = XEXP (x0, 0); - goto L431; - - L258: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[1] = x2; - return 52; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - return 54; - } - } - x1 = XEXP (x0, 0); - goto L431; - - L278: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[1] = x2; - return 57; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - return 59; - } - } - x1 = XEXP (x0, 0); - goto L431; - - L418: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L419; - } - x1 = XEXP (x0, 0); - goto L431; - - L419: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 82; - } - x1 = XEXP (x0, 0); - goto L431; - - L432: - x1 = XEXP (x0, 1); - if (address_operand (x1, QImode)) - { - ro[1] = x1; - return 85; - } - x1 = XEXP (x0, 0); - goto L439; - - L440: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != SImode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - switch (GET_CODE (x1)) - { - case MINUS: - goto L441; - case MULT: - goto L468; - case AND: - goto L541; - case IOR: - goto L556; - case XOR: - goto L799; - case NEG: - goto L590; - case NOT: - goto L667; - case ASHIFT: - goto L692; - case ASHIFTRT: - goto L720; - case LSHIFTRT: - goto L748; - case ROTATE: - goto L763; - case ROTATERT: - goto L778; - } - x1 = XEXP (x0, 0); - goto L1147; - - L441: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L442; - } - x1 = XEXP (x0, 0); - goto L1147; - - L442: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 89; - } - x1 = XEXP (x0, 0); - goto L1147; - - L468: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L469; - } - x1 = XEXP (x0, 0); - goto L1147; - - L469: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - goto L475; - x1 = XEXP (x0, 0); - goto L1147; - - L475: - ro[2] = x2; - if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x80) - return 96; - L476: - ro[2] = x2; - return 97; - - L541: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L542; - } - x1 = XEXP (x0, 0); - goto L1147; - - L542: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 109; - } - x1 = XEXP (x0, 0); - goto L1147; - - L556: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L557; - } - x1 = XEXP (x0, 0); - goto L1147; - - L557: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 112; - } - x1 = XEXP (x0, 0); - goto L1147; - - L799: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == ASHIFT && 1) - goto L800; - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L807; - } - x1 = XEXP (x0, 0); - goto L1147; - - L800: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 1 && 1) - goto L801; - x1 = XEXP (x0, 0); - goto L1147; - - L801: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L802; - } - x1 = XEXP (x0, 0); - goto L1147; - - L802: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - if (! TARGET_486 && GET_CODE (operands[1]) != CONST_INT) - return 165; - } - x1 = XEXP (x0, 0); - goto L1147; - - L807: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == ASHIFT && 1) - goto L808; - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 115; - } - x1 = XEXP (x0, 0); - goto L1147; - - L808: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 1 && 1) - goto L809; - x1 = XEXP (x0, 0); - goto L1147; - - L809: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - if (! TARGET_486 && GET_CODE (operands[2]) != CONST_INT) - return 166; - } - x1 = XEXP (x0, 0); - goto L1147; - - L590: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 119; - } - x1 = XEXP (x0, 0); - goto L1147; - - L667: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 137; - } - x1 = XEXP (x0, 0); - goto L1147; - - L692: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L693; - } - x1 = XEXP (x0, 0); - goto L1147; - - L693: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, SImode)) - { - ro[2] = x2; - return 143; - } - x1 = XEXP (x0, 0); - goto L1147; - - L720: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L721; - } - x1 = XEXP (x0, 0); - goto L1147; - - L721: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, SImode)) - { - ro[2] = x2; - return 149; - } - x1 = XEXP (x0, 0); - goto L1147; - - L748: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L749; - } - x1 = XEXP (x0, 0); - goto L1147; - - L749: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, SImode)) - { - ro[2] = x2; - return 155; - } - x1 = XEXP (x0, 0); - goto L1147; - - L763: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L764; - } - x1 = XEXP (x0, 0); - goto L1147; - - L764: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, SImode)) - { - ro[2] = x2; - return 158; - } - x1 = XEXP (x0, 0); - goto L1147; - - L778: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L779; - } - x1 = XEXP (x0, 0); - goto L1147; - - L779: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, SImode)) - { - ro[2] = x2; - return 161; - } - x1 = XEXP (x0, 0); - goto L1147; - - L212: - x1 = XEXP (x0, 1); - if (general_operand (x1, HImode)) - { - ro[1] = x1; - return 39; - } - x1 = XEXP (x0, 0); - goto L214; - - L261: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case HImode: - switch (GET_CODE (x1)) - { - case ZERO_EXTEND: - goto L262; - case SIGN_EXTEND: - goto L282; - case PLUS: - goto L423; - case MINUS: - goto L446; - case AND: - goto L546; - case IOR: - goto L561; - case XOR: - goto L576; - case NEG: - goto L594; - case NOT: - goto L671; - case ASHIFT: - goto L697; - case ASHIFTRT: - goto L725; - case LSHIFTRT: - goto L753; - case ROTATE: - goto L768; - case ROTATERT: - goto L783; - } - break; - case SImode: - if (GET_CODE (x1) == MULT && 1) - goto L480; - } - if (general_operand (x1, HImode)) - { - ro[1] = x1; - return 40; - } - x1 = XEXP (x0, 0); - goto L1147; - - L262: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - return 53; - } - x1 = XEXP (x0, 0); - goto L1147; - - L282: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - return 58; - } - x1 = XEXP (x0, 0); - goto L1147; - - L423: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L424; - } - x1 = XEXP (x0, 0); - goto L1147; - - L424: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 83; - } - x1 = XEXP (x0, 0); - goto L1147; - - L446: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L447; - } - x1 = XEXP (x0, 0); - goto L1147; - - L447: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 90; - } - x1 = XEXP (x0, 0); - goto L1147; - - L546: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L547; - } - x1 = XEXP (x0, 0); - goto L1147; - - L547: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 110; - } - x1 = XEXP (x0, 0); - goto L1147; - - L561: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L562; - } - x1 = XEXP (x0, 0); - goto L1147; - - L562: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 113; - } - x1 = XEXP (x0, 0); - goto L1147; - - L576: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L577; - } - x1 = XEXP (x0, 0); - goto L1147; - - L577: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 116; - } - x1 = XEXP (x0, 0); - goto L1147; - - L594: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 120; - } - x1 = XEXP (x0, 0); - goto L1147; - - L671: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 138; - } - x1 = XEXP (x0, 0); - goto L1147; - - L697: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L698; - } - x1 = XEXP (x0, 0); - goto L1147; - - L698: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, HImode)) - { - ro[2] = x2; - return 144; - } - x1 = XEXP (x0, 0); - goto L1147; - - L725: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L726; - } - x1 = XEXP (x0, 0); - goto L1147; - - L726: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, HImode)) - { - ro[2] = x2; - return 150; - } - x1 = XEXP (x0, 0); - goto L1147; - - L753: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L754; - } - x1 = XEXP (x0, 0); - goto L1147; - - L754: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, HImode)) - { - ro[2] = x2; - return 156; - } - x1 = XEXP (x0, 0); - goto L1147; - - L768: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L769; - } - x1 = XEXP (x0, 0); - goto L1147; - - L769: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, HImode)) - { - ro[2] = x2; - return 159; - } - x1 = XEXP (x0, 0); - goto L1147; - - L783: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L784; - } - x1 = XEXP (x0, 0); - goto L1147; - - L784: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, HImode)) - { - ro[2] = x2; - return 162; - } - x1 = XEXP (x0, 0); - goto L1147; - - L480: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == ZERO_EXTEND && 1) - goto L481; - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L457; - } - x1 = XEXP (x0, 0); - goto L1147; - - L481: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, QImode)) - { - ro[1] = x3; - goto L482; - } - x1 = XEXP (x0, 0); - goto L1147; - - L482: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == ZERO_EXTEND && 1) - goto L483; - x1 = XEXP (x0, 0); - goto L1147; - - L483: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, QImode)) - { - ro[2] = x3; - return 98; - } - x1 = XEXP (x0, 0); - goto L1147; - - L457: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - goto L463; - x1 = XEXP (x0, 0); - goto L1147; - - L463: - ro[2] = x2; - if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x80) - return 94; - L464: - ro[2] = x2; - return 95; - - L222: - x1 = XEXP (x0, 1); - if (general_operand (x1, QImode)) - { - ro[1] = x1; - return 42; - } - x1 = XEXP (x0, 0); - goto L224; - - L427: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case QImode: - switch (GET_CODE (x1)) - { - case PLUS: - goto L428; - case MINUS: - goto L451; - case DIV: - goto L487; - case UDIV: - goto L492; - case AND: - goto L551; - case IOR: - goto L566; - case XOR: - goto L581; - case NEG: - goto L598; - case NOT: - goto L675; - case ASHIFT: - goto L702; - case ASHIFTRT: - goto L730; - case LSHIFTRT: - goto L758; - case ROTATE: - goto L773; - case ROTATERT: - goto L788; - } - } - if (general_operand (x1, QImode)) - { - ro[1] = x1; - return 43; - } - x1 = XEXP (x0, 0); - goto L829; - - L428: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L429; - } - x1 = XEXP (x0, 0); - goto L829; - - L429: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 84; - } - x1 = XEXP (x0, 0); - goto L829; - - L451: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L452; - } - x1 = XEXP (x0, 0); - goto L829; - - L452: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 91; - } - x1 = XEXP (x0, 0); - goto L829; - - L487: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L488; - } - x1 = XEXP (x0, 0); - goto L829; - - L488: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 101; - } - x1 = XEXP (x0, 0); - goto L829; - - L492: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L493; - } - x1 = XEXP (x0, 0); - goto L829; - - L493: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 102; - } - x1 = XEXP (x0, 0); - goto L829; - - L551: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L552; - } - x1 = XEXP (x0, 0); - goto L829; - - L552: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 111; - } - x1 = XEXP (x0, 0); - goto L829; - - L566: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L567; - } - x1 = XEXP (x0, 0); - goto L829; - - L567: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 114; - } - x1 = XEXP (x0, 0); - goto L829; - - L581: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L582; - } - x1 = XEXP (x0, 0); - goto L829; - - L582: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 117; - } - x1 = XEXP (x0, 0); - goto L829; - - L598: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 121; - } - x1 = XEXP (x0, 0); - goto L829; - - L675: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 139; - } - x1 = XEXP (x0, 0); - goto L829; - - L702: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L703; - } - x1 = XEXP (x0, 0); - goto L829; - - L703: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, QImode)) - { - ro[2] = x2; - return 145; - } - x1 = XEXP (x0, 0); - goto L829; - - L730: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L731; - } - x1 = XEXP (x0, 0); - goto L829; - - L731: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, QImode)) - { - ro[2] = x2; - return 151; - } - x1 = XEXP (x0, 0); - goto L829; - - L758: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L759; - } - x1 = XEXP (x0, 0); - goto L829; - - L759: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, QImode)) - { - ro[2] = x2; - return 157; - } - x1 = XEXP (x0, 0); - goto L829; - - L773: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L774; - } - x1 = XEXP (x0, 0); - goto L829; - - L774: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, QImode)) - { - ro[2] = x2; - return 160; - } - x1 = XEXP (x0, 0); - goto L829; - - L788: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L789; - } - x1 = XEXP (x0, 0); - goto L829; - - L789: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, QImode)) - { - ro[2] = x2; - return 163; - } - x1 = XEXP (x0, 0); - goto L829; - - L830: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != QImode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - switch (GET_CODE (x1)) - { - case EQ: - goto L831; - case NE: - goto L836; - case GT: - goto L841; - case GTU: - goto L846; - case LT: - goto L851; - case LTU: - goto L856; - case GE: - goto L861; - case GEU: - goto L866; - case LE: - goto L871; - case LEU: - goto L876; - } - x1 = XEXP (x0, 0); - goto L1147; - - L831: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L832; - x1 = XEXP (x0, 0); - goto L1147; - - L832: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 171; - x1 = XEXP (x0, 0); - goto L1147; - - L836: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L837; - x1 = XEXP (x0, 0); - goto L1147; - - L837: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 173; - x1 = XEXP (x0, 0); - goto L1147; - - L841: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L842; - x1 = XEXP (x0, 0); - goto L1147; - - L842: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 175; - x1 = XEXP (x0, 0); - goto L1147; - - L846: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L847; - x1 = XEXP (x0, 0); - goto L1147; - - L847: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 177; - x1 = XEXP (x0, 0); - goto L1147; - - L851: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L852; - x1 = XEXP (x0, 0); - goto L1147; - - L852: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 179; - x1 = XEXP (x0, 0); - goto L1147; - - L856: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L857; - x1 = XEXP (x0, 0); - goto L1147; - - L857: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 181; - x1 = XEXP (x0, 0); - goto L1147; - - L861: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L862; - x1 = XEXP (x0, 0); - goto L1147; - - L862: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 183; - x1 = XEXP (x0, 0); - goto L1147; - - L866: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L867; - x1 = XEXP (x0, 0); - goto L1147; - - L867: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 185; - x1 = XEXP (x0, 0); - goto L1147; - - L871: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L872; - x1 = XEXP (x0, 0); - goto L1147; - - L872: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 187; - x1 = XEXP (x0, 0); - goto L1147; - - L876: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L877; - x1 = XEXP (x0, 0); - goto L1147; - - L877: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 189; - x1 = XEXP (x0, 0); - goto L1147; - - L232: - x1 = XEXP (x0, 1); - if (general_operand (x1, SFmode)) - { - ro[1] = x1; - return 45; - } - x1 = XEXP (x0, 0); - goto L234; - - L235: - x1 = XEXP (x0, 1); - if (general_operand (x1, SFmode)) - { - ro[1] = x1; - return 46; - } - x1 = XEXP (x0, 0); - goto L399; - - L400: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != SFmode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - switch (GET_CODE (x1)) - { - case FLOAT: - goto L401; - case NEG: - goto L602; - case ABS: - goto L615; - case SQRT: - goto L628; - case UNSPEC: - if (XINT (x1, 1) == 1 && XVECLEN (x1, 0) == 1 && 1) - goto L645; - if (XINT (x1, 1) == 2 && XVECLEN (x1, 0) == 1 && 1) - goto L658; - } - x1 = XEXP (x0, 0); - goto L1147; - - L401: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DImode: - if (nonimmediate_operand (x2, DImode)) - { - ro[1] = x2; - if (TARGET_80387) - return 78; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[1] = x2; - if (TARGET_80387) - return 80; - } - } - x1 = XEXP (x0, 0); - goto L1147; - - L602: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387) - return 122; - } - x1 = XEXP (x0, 0); - goto L1147; - - L615: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387) - return 125; - } - x1 = XEXP (x0, 0); - goto L1147; - - L628: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 128; - } - x1 = XEXP (x0, 0); - goto L1147; - - L645: - x2 = XVECEXP (x1, 0, 0); - if (register_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 132; - } - x1 = XEXP (x0, 0); - goto L1147; - - L658: - x2 = XVECEXP (x1, 0, 0); - if (register_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 135; - } - x1 = XEXP (x0, 0); - goto L1147; - - L238: - x1 = XEXP (x0, 1); - if (general_operand (x1, DFmode)) - { - ro[1] = x1; - return 47; - } - x1 = XEXP (x0, 0); - goto L247; - - L289: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == DFmode && GET_CODE (x1) == FLOAT_EXTEND && 1) - goto L290; - if (general_operand (x1, DFmode)) - { - ro[1] = x1; - return 49; - } - x1 = XEXP (x0, 0); - goto L395; - - L290: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387) - return 60; - } - x1 = XEXP (x0, 0); - goto L395; - - L396: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != DFmode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - switch (GET_CODE (x1)) - { - case FLOAT: - goto L397; - case NEG: - goto L610; - case ABS: - goto L623; - case SQRT: - goto L636; - case UNSPEC: - if (XINT (x1, 1) == 1 && XVECLEN (x1, 0) == 1 && 1) - goto L649; - if (XINT (x1, 1) == 2 && XVECLEN (x1, 0) == 1 && 1) - goto L662; - } - x1 = XEXP (x0, 0); - goto L1147; - - L397: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DImode: - if (nonimmediate_operand (x2, DImode)) - { - ro[1] = x2; - if (TARGET_80387) - return 77; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[1] = x2; - if (TARGET_80387) - return 79; - } - } - x1 = XEXP (x0, 0); - goto L1147; - - L610: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == FLOAT_EXTEND && 1) - goto L611; - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387) - return 123; - } - x1 = XEXP (x0, 0); - goto L1147; - - L611: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387) - return 124; - } - x1 = XEXP (x0, 0); - goto L1147; - - L623: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == FLOAT_EXTEND && 1) - goto L624; - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387) - return 126; - } - x1 = XEXP (x0, 0); - goto L1147; - - L624: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387) - return 127; - } - x1 = XEXP (x0, 0); - goto L1147; - - L636: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == FLOAT_EXTEND && 1) - goto L637; - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 129; - } - x1 = XEXP (x0, 0); - goto L1147; - - L637: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 130; - } - x1 = XEXP (x0, 0); - goto L1147; - - L649: - x2 = XVECEXP (x1, 0, 0); - if (GET_MODE (x2) != DFmode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - if (GET_CODE (x2) == FLOAT_EXTEND && 1) - goto L650; - if (register_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 131; - } - x1 = XEXP (x0, 0); - goto L1147; - - L650: - x3 = XEXP (x2, 0); - if (register_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 133; - } - x1 = XEXP (x0, 0); - goto L1147; - - L662: - x2 = XVECEXP (x1, 0, 0); - if (GET_MODE (x2) != DFmode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - if (GET_CODE (x2) == FLOAT_EXTEND && 1) - goto L663; - if (register_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 134; - } - x1 = XEXP (x0, 0); - goto L1147; - - L663: - x3 = XEXP (x2, 0); - if (register_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 136; - } - x1 = XEXP (x0, 0); - goto L1147; - - L251: - x1 = XEXP (x0, 1); - if (general_operand (x1, DImode)) - { - ro[1] = x1; - return 50; - } - x1 = XEXP (x0, 0); - goto L253; - - L412: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case DImode: - switch (GET_CODE (x1)) - { - case PLUS: - goto L413; - case MINUS: - goto L436; - case NEG: - goto L586; - } - } - if (general_operand (x1, DImode)) - { - ro[1] = x1; - return 51; - } - x1 = XEXP (x0, 0); - goto L268; - - L413: - x2 = XEXP (x1, 0); - if (general_operand (x2, DImode)) - { - ro[1] = x2; - goto L414; - } - x1 = XEXP (x0, 0); - goto L268; - - L414: - x2 = XEXP (x1, 1); - if (general_operand (x2, DImode)) - { - ro[2] = x2; - return 81; - } - x1 = XEXP (x0, 0); - goto L268; - - L436: - x2 = XEXP (x1, 0); - if (general_operand (x2, DImode)) - { - ro[1] = x2; - goto L437; - } - x1 = XEXP (x0, 0); - goto L268; - - L437: - x2 = XEXP (x1, 1); - if (general_operand (x2, DImode)) - { - ro[2] = x2; - return 88; - } - x1 = XEXP (x0, 0); - goto L268; - - L586: - x2 = XEXP (x1, 0); - if (general_operand (x2, DImode)) - { - ro[1] = x2; - return 118; - } - x1 = XEXP (x0, 0); - goto L268; - - L269: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != DImode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - switch (GET_CODE (x1)) - { - case ZERO_EXTEND: - goto L270; - case SIGN_EXTEND: - goto L274; - case ASHIFT: - goto L679; - case ASHIFTRT: - goto L707; - case LSHIFTRT: - goto L735; - } - x1 = XEXP (x0, 0); - goto L1147; - - L270: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - return 55; - } - x1 = XEXP (x0, 0); - goto L1147; - - L274: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - return 56; - } - x1 = XEXP (x0, 0); - goto L1147; - - L679: - x2 = XEXP (x1, 0); - if (register_operand (x2, DImode)) - { - ro[1] = x2; - goto L680; - } - x1 = XEXP (x0, 0); - goto L1147; - - L680: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - return 141; - } - x1 = XEXP (x0, 0); - goto L1147; - - L707: - x2 = XEXP (x1, 0); - if (register_operand (x2, DImode)) - { - ro[1] = x2; - goto L708; - } - x1 = XEXP (x0, 0); - goto L1147; - - L708: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - return 147; - } - x1 = XEXP (x0, 0); - goto L1147; - - L735: - x2 = XEXP (x1, 0); - if (register_operand (x2, DImode)) - { - ro[1] = x2; - goto L736; - } - x1 = XEXP (x0, 0); - goto L1147; - - L736: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - return 153; - } - x1 = XEXP (x0, 0); - goto L1147; - L2: - tem = recog_1 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L1147; - - L218: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (general_operand (x2, HImode)) - { - ro[0] = x2; - goto L219; - } - break; - case QImode: - if (general_operand (x2, QImode)) - { - ro[0] = x2; - goto L229; - } - } - goto L1147; - - L219: - x1 = XEXP (x0, 1); - if (general_operand (x1, HImode)) - { - ro[1] = x1; - return 41; - } - x1 = XEXP (x0, 0); - goto L1147; - - L229: - x1 = XEXP (x0, 1); - if (general_operand (x1, QImode)) - { - ro[1] = x1; - return 44; - } - x1 = XEXP (x0, 0); - goto L1147; - - L1081: - x1 = XEXP (x0, 1); - switch (GET_CODE (x1)) - { - case MINUS: - if (GET_MODE (x1) == SImode && 1) - goto L1082; - break; - case IF_THEN_ELSE: - goto L881; - case LABEL_REF: - goto L1061; - } - L1064: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - return 221; - } - x1 = XEXP (x0, 0); - goto L1147; - - L1082: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == REG && XINT (x2, 0) == 3 && 1) - goto L1083; - x1 = XEXP (x0, 0); - goto L1147; - - L1083: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MEM && 1) - goto L1084; - x1 = XEXP (x0, 0); - goto L1147; - - L1084: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == PLUS && 1) - goto L1085; - x1 = XEXP (x0, 0); - goto L1147; - - L1085: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == SImode && GET_CODE (x4) == MULT && 1) - goto L1086; - x1 = XEXP (x0, 0); - goto L1147; - - L1086: - x5 = XEXP (x4, 0); - if (register_operand (x5, SImode)) - { - ro[0] = x5; - goto L1087; - } - x1 = XEXP (x0, 0); - goto L1147; - - L1087: - x5 = XEXP (x4, 1); - if (GET_CODE (x5) == CONST_INT && XWINT (x5, 0) == 4 && 1) - goto L1088; - x1 = XEXP (x0, 0); - goto L1147; - - L1088: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == LABEL_REF && 1) - goto L1089; - x1 = XEXP (x0, 0); - goto L1147; - - L1089: - x5 = XEXP (x4, 0); - if (pnum_clobbers != 0 && 1) - { - ro[1] = x5; - *pnum_clobbers = 1; - return 223; - } - x1 = XEXP (x0, 0); - goto L1147; - L881: - tem = recog_2 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L1147; - - L1061: - x2 = XEXP (x1, 0); - ro[0] = x2; - return 220; - - L1148: - x1 = XEXP (x0, 1); - if (GET_CODE (x1) == CALL && 1) - goto L1149; - x1 = XEXP (x0, 0); - goto L1236; - - L1149: - x2 = XEXP (x1, 0); - if (call_insn_operand (x2, QImode)) - { - ro[1] = x2; - goto L1150; - } - L1154: - if (GET_MODE (x2) == QImode && GET_CODE (x2) == MEM && 1) - goto L1155; - x1 = XEXP (x0, 0); - goto L1236; - - L1150: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 235; - } - x2 = XEXP (x1, 0); - goto L1154; - - L1155: - x3 = XEXP (x2, 0); - if (symbolic_operand (x3, SImode)) - { - ro[1] = x3; - goto L1156; - } - x1 = XEXP (x0, 0); - goto L1236; - - L1156: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - if (!HALF_PIC_P ()) - return 236; - } - x1 = XEXP (x0, 0); - goto L1236; - - L1237: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == SImode && GET_CODE (x1) == PLUS && 1) - goto L1238; - goto ret0; - - L1238: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == FFS && 1) - goto L1239; - goto ret0; - - L1239: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L1240; - } - goto ret0; - - L1240: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == -1 && pnum_clobbers != 0 && 1) - { - *pnum_clobbers = 1; - return 250; - } - goto ret0; - - L1252: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == HImode && GET_CODE (x1) == PLUS && 1) - goto L1253; - goto ret0; - - L1253: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == FFS && 1) - goto L1254; - goto ret0; - - L1254: - x3 = XEXP (x2, 0); - if (general_operand (x3, HImode)) - { - ro[1] = x3; - goto L1255; - } - goto ret0; - - L1255: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == -1 && pnum_clobbers != 0 && 1) - { - *pnum_clobbers = 1; - return 252; - } - goto ret0; - - L1258: - x1 = XEXP (x0, 1); - if (binary_387_op (x1, DFmode)) - { - ro[3] = x1; - goto L1264; - } - goto ret0; - - L1264: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - switch (GET_CODE (x2)) - { - case FLOAT: - goto L1265; - case FLOAT_EXTEND: - goto L1271; - case SUBREG: - case REG: - case MEM: - if (nonimmediate_operand (x2, DFmode)) - { - ro[1] = x2; - goto L1260; - } - } - } - L1276: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L1277; - } - goto ret0; - - L1265: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L1266; - } - goto ret0; - - L1266: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 254; - } - goto ret0; - - L1271: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L1272; - } - goto ret0; - - L1272: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 255; - } - goto ret0; - - L1260: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, DFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 253; - } - x2 = XEXP (x1, 0); - goto L1276; - - L1277: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != DFmode) - goto ret0; - switch (GET_CODE (x2)) - { - case FLOAT: - goto L1278; - case FLOAT_EXTEND: - goto L1284; - } - goto ret0; - - L1278: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - if (TARGET_80387) - return 256; - } - goto ret0; - - L1284: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - if (TARGET_80387) - return 257; - } - goto ret0; - - L1287: - x1 = XEXP (x0, 1); - if (binary_387_op (x1, SFmode)) - { - ro[3] = x1; - goto L1293; - } - goto ret0; - - L1293: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SFmode: - if (GET_CODE (x2) == FLOAT && 1) - goto L1294; - if (nonimmediate_operand (x2, SFmode)) - { - ro[1] = x2; - goto L1289; - } - } - L1299: - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L1300; - } - goto ret0; - - L1294: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L1295; - } - goto ret0; - - L1295: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 259; - } - goto ret0; - - L1289: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, SFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 258; - } - x2 = XEXP (x1, 0); - goto L1299; - - L1300: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == FLOAT && 1) - goto L1301; - goto ret0; - - L1301: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - if (TARGET_80387) - return 260; - } - goto ret0; - ret0: return -1; -} - -int -recog_4 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - switch (GET_MODE (x2)) - { - case SFmode: - if (register_operand (x2, SFmode)) - { - ro[0] = x2; - goto L13; - } - break; - case DFmode: - if (register_operand (x2, DFmode)) - { - ro[0] = x2; - goto L22; - } - } - L45: - if (VOIDmode_compare_op (x2, VOIDmode)) - { - ro[2] = x2; - goto L74; - } - L118: - if (GET_MODE (x2) == CCFPEQmode && GET_CODE (x2) == COMPARE && 1) - goto L119; - goto ret0; - - L13: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L14; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L45; - - L14: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[1] = x2; - if (TARGET_80387 && ! TARGET_IEEE_FP) - return 6; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L45; - - L22: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L23; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L45; - - L23: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[1] = x2; - if (TARGET_80387 && ! TARGET_IEEE_FP) - return 8; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L45; - - L74: - x3 = XEXP (x2, 0); - switch (GET_MODE (x3)) - { - case DFmode: - switch (GET_CODE (x3)) - { - case FLOAT: - goto L75; - case FLOAT_EXTEND: - goto L105; - case SUBREG: - case REG: - case MEM: - if (nonimmediate_operand (x3, DFmode)) - { - ro[0] = x3; - goto L47; - } - } - L59: - if (register_operand (x3, DFmode)) - { - ro[0] = x3; - goto L60; - } - break; - case SFmode: - if (GET_CODE (x3) == FLOAT && 1) - goto L161; - if (nonimmediate_operand (x3, SFmode)) - { - ro[0] = x3; - goto L133; - } - L145: - if (register_operand (x3, SFmode)) - { - ro[0] = x3; - goto L146; - } - } - goto L118; - - L75: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SImode)) - { - ro[0] = x4; - goto L76; - } - goto L118; - - L76: - x3 = XEXP (x2, 1); - if (register_operand (x3, DFmode)) - { - ro[1] = x3; - goto L77; - } - goto L118; - - L77: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L78; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L78: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 18; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L105: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SFmode)) - { - ro[0] = x4; - goto L106; - } - goto L118; - - L106: - x3 = XEXP (x2, 1); - if (register_operand (x3, DFmode)) - { - ro[1] = x3; - goto L107; - } - goto L118; - - L107: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L108; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L108: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 20; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L47: - x3 = XEXP (x2, 1); - if (nonimmediate_operand (x3, DFmode)) - { - ro[1] = x3; - goto L48; - } - x3 = XEXP (x2, 0); - goto L59; - - L48: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L49; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L59; - - L49: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387 - && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)) - return 16; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L59; - - L60: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) != DFmode) - { - goto L118; - } - switch (GET_CODE (x3)) - { - case FLOAT: - goto L61; - case FLOAT_EXTEND: - goto L91; - } - goto L118; - - L61: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SImode)) - { - ro[1] = x4; - goto L62; - } - goto L118; - - L62: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L63; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L63: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 17; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L91: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SFmode)) - { - ro[1] = x4; - goto L92; - } - goto L118; - - L92: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L93; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L93: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 19; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L161: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SImode)) - { - ro[0] = x4; - goto L162; - } - goto L118; - - L162: - x3 = XEXP (x2, 1); - if (register_operand (x3, SFmode)) - { - ro[1] = x3; - goto L163; - } - goto L118; - - L163: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L164; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L164: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 24; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L133: - x3 = XEXP (x2, 1); - if (nonimmediate_operand (x3, SFmode)) - { - ro[1] = x3; - goto L134; - } - x3 = XEXP (x2, 0); - goto L145; - - L134: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L135; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L145; - - L135: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387 - && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)) - return 22; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L145; - - L146: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == SFmode && GET_CODE (x3) == FLOAT && 1) - goto L147; - goto L118; - - L147: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SImode)) - { - ro[1] = x4; - goto L148; - } - goto L118; - - L148: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L149; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L149: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 23; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L119: - x3 = XEXP (x2, 0); - switch (GET_MODE (x3)) - { - case DFmode: - if (register_operand (x3, DFmode)) - { - ro[0] = x3; - goto L120; - } - break; - case SFmode: - if (register_operand (x3, SFmode)) - { - ro[0] = x3; - goto L176; - } - } - goto ret0; - - L120: - x3 = XEXP (x2, 1); - if (register_operand (x3, DFmode)) - { - ro[1] = x3; - goto L121; - } - goto ret0; - - L121: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L122; - goto ret0; - - L122: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[2] = x2; - if (TARGET_80387) - return 21; - } - goto ret0; - - L176: - x3 = XEXP (x2, 1); - if (register_operand (x3, SFmode)) - { - ro[1] = x3; - goto L177; - } - goto ret0; - - L177: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L178; - goto ret0; - - L178: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[2] = x2; - if (TARGET_80387) - return 25; - } - goto ret0; - ret0: return -1; -} - -int -recog_5 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - if (register_operand (x2, DFmode)) - { - ro[0] = x2; - goto L242; - } - break; - case SFmode: - if (nonimmediate_operand (x2, SFmode)) - { - ro[0] = x2; - goto L294; - } - break; - case SImode: - if (register_operand (x2, SImode)) - { - ro[0] = x2; - goto L497; - } - break; - case HImode: - if (register_operand (x2, HImode)) - { - ro[0] = x2; - goto L508; - } - break; - case DImode: - if (register_operand (x2, DImode)) - { - ro[0] = x2; - goto L684; - } - } - switch (GET_CODE (x2)) - { - case CC0: - goto L12; - case PC: - goto L1068; - } - L1125: - ro[0] = x2; - goto L1126; - L1228: - switch (GET_MODE (x2)) - { - case SImode: - if (register_operand (x2, SImode)) - { - ro[0] = x2; - goto L1229; - } - break; - case HImode: - if (register_operand (x2, HImode)) - { - ro[0] = x2; - goto L1244; - } - } - goto ret0; - - L242: - x2 = XEXP (x1, 1); - if (register_operand (x2, DFmode)) - { - ro[1] = x2; - goto L243; - } - x2 = XEXP (x1, 0); - goto L1125; - - L243: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L244; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L244: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L245; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L245: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 48; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L294: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == FLOAT_TRUNCATE && 1) - goto L295; - x2 = XEXP (x1, 0); - goto L1125; - - L295: - x3 = XEXP (x2, 0); - if (register_operand (x3, DFmode)) - { - ro[1] = x3; - goto L296; - } - x2 = XEXP (x1, 0); - goto L1125; - - L296: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L297; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L297: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 62; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L497: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != SImode) - { - x2 = XEXP (x1, 0); - goto L1125; - } - switch (GET_CODE (x2)) - { - case DIV: - goto L498; - case UDIV: - goto L520; - } - x2 = XEXP (x1, 0); - goto L1125; - - L498: - x3 = XEXP (x2, 0); - if (register_operand (x3, SImode)) - { - ro[1] = x3; - goto L499; - } - x2 = XEXP (x1, 0); - goto L1125; - - L499: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L500; - } - x2 = XEXP (x1, 0); - goto L1125; - - L500: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L501; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L501: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[3] = x2; - goto L502; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L502: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MOD && 1) - goto L503; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L503: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L504; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L504: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - return 105; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L520: - x3 = XEXP (x2, 0); - if (register_operand (x3, SImode)) - { - ro[1] = x3; - goto L521; - } - x2 = XEXP (x1, 0); - goto L1125; - - L521: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L522; - } - x2 = XEXP (x1, 0); - goto L1125; - - L522: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L523; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L523: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[3] = x2; - goto L524; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L524: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == UMOD && 1) - goto L525; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L525: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L526; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L526: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - return 107; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L508: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != HImode) - { - x2 = XEXP (x1, 0); - goto L1125; - } - switch (GET_CODE (x2)) - { - case DIV: - goto L509; - case UDIV: - goto L531; - } - x2 = XEXP (x1, 0); - goto L1125; - - L509: - x3 = XEXP (x2, 0); - if (register_operand (x3, HImode)) - { - ro[1] = x3; - goto L510; - } - x2 = XEXP (x1, 0); - goto L1125; - - L510: - x3 = XEXP (x2, 1); - if (general_operand (x3, HImode)) - { - ro[2] = x3; - goto L511; - } - x2 = XEXP (x1, 0); - goto L1125; - - L511: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L512; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L512: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[3] = x2; - goto L513; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L513: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == MOD && 1) - goto L514; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L514: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L515; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L515: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - return 106; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L531: - x3 = XEXP (x2, 0); - if (register_operand (x3, HImode)) - { - ro[1] = x3; - goto L532; - } - x2 = XEXP (x1, 0); - goto L1125; - - L532: - x3 = XEXP (x2, 1); - if (general_operand (x3, HImode)) - { - ro[2] = x3; - goto L533; - } - x2 = XEXP (x1, 0); - goto L1125; - - L533: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L534; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L534: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[3] = x2; - goto L535; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L535: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == UMOD && 1) - goto L536; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L536: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L537; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L537: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - return 108; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L684: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != DImode) - { - x2 = XEXP (x1, 0); - goto L1125; - } - switch (GET_CODE (x2)) - { - case ASHIFT: - goto L685; - case ASHIFTRT: - goto L713; - case LSHIFTRT: - goto L741; - } - x2 = XEXP (x1, 0); - goto L1125; - - L685: - x3 = XEXP (x2, 0); - if (register_operand (x3, DImode)) - { - ro[1] = x3; - goto L686; - } - x2 = XEXP (x1, 0); - goto L1125; - - L686: - x3 = XEXP (x2, 1); - if (register_operand (x3, QImode)) - { - ro[2] = x3; - goto L687; - } - x2 = XEXP (x1, 0); - goto L1125; - - L687: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L688; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L688: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[2]) && 1) - return 142; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L713: - x3 = XEXP (x2, 0); - if (register_operand (x3, DImode)) - { - ro[1] = x3; - goto L714; - } - x2 = XEXP (x1, 0); - goto L1125; - - L714: - x3 = XEXP (x2, 1); - if (register_operand (x3, QImode)) - { - ro[2] = x3; - goto L715; - } - x2 = XEXP (x1, 0); - goto L1125; - - L715: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L716; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L716: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[2]) && 1) - return 148; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L741: - x3 = XEXP (x2, 0); - if (register_operand (x3, DImode)) - { - ro[1] = x3; - goto L742; - } - x2 = XEXP (x1, 0); - goto L1125; - - L742: - x3 = XEXP (x2, 1); - if (register_operand (x3, QImode)) - { - ro[2] = x3; - goto L743; - } - x2 = XEXP (x1, 0); - goto L1125; - - L743: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L744; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L744: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[2]) && 1) - return 154; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - L12: - tem = recog_4 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x2 = XEXP (x1, 0); - goto L1125; - - L1068: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MINUS && 1) - goto L1069; - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L1094; - } - x2 = XEXP (x1, 0); - goto L1125; - - L1069: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == REG && XINT (x3, 0) == 3 && 1) - goto L1070; - x2 = XEXP (x1, 0); - goto L1125; - - L1070: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == MEM && 1) - goto L1071; - x2 = XEXP (x1, 0); - goto L1125; - - L1071: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == SImode && GET_CODE (x4) == PLUS && 1) - goto L1072; - x2 = XEXP (x1, 0); - goto L1125; - - L1072: - x5 = XEXP (x4, 0); - if (GET_MODE (x5) == SImode && GET_CODE (x5) == MULT && 1) - goto L1073; - x2 = XEXP (x1, 0); - goto L1125; - - L1073: - x6 = XEXP (x5, 0); - if (register_operand (x6, SImode)) - { - ro[0] = x6; - goto L1074; - } - x2 = XEXP (x1, 0); - goto L1125; - - L1074: - x6 = XEXP (x5, 1); - if (GET_CODE (x6) == CONST_INT && XWINT (x6, 0) == 4 && 1) - goto L1075; - x2 = XEXP (x1, 0); - goto L1125; - - L1075: - x5 = XEXP (x4, 1); - if (GET_CODE (x5) == LABEL_REF && 1) - goto L1076; - x2 = XEXP (x1, 0); - goto L1125; - - L1076: - x6 = XEXP (x5, 0); - ro[1] = x6; - goto L1077; - - L1077: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1078; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L1078: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - return 223; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L1094: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1095; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L1095: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1096; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L1096: - x3 = XEXP (x2, 0); - ro[1] = x3; - return 224; - - L1126: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CALL && 1) - goto L1138; - x2 = XEXP (x1, 0); - goto L1228; - - L1138: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == QImode && GET_CODE (x3) == MEM && 1) - goto L1139; - L1127: - if (call_insn_operand (x3, QImode)) - { - ro[1] = x3; - goto L1128; - } - x2 = XEXP (x1, 0); - goto L1228; - - L1139: - x4 = XEXP (x3, 0); - if (symbolic_operand (x4, SImode)) - { - ro[1] = x4; - goto L1140; - } - goto L1127; - - L1140: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L1141; - } - x3 = XEXP (x2, 0); - goto L1127; - - L1141: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1142; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L1127; - - L1142: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == REG && XINT (x2, 0) == 7 && 1) - goto L1143; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L1127; - - L1143: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1144; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L1127; - - L1144: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == REG && XINT (x3, 0) == 7 && 1) - goto L1145; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L1127; - - L1145: - x3 = XEXP (x2, 1); - if (immediate_operand (x3, SImode)) - { - ro[4] = x3; - if (!HALF_PIC_P ()) - return 233; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L1127; - - L1128: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L1129; - } - x2 = XEXP (x1, 0); - goto L1228; - - L1129: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1130; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1228; - - L1130: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == REG && XINT (x2, 0) == 7 && 1) - goto L1131; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1228; - - L1131: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1132; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1228; - - L1132: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == REG && XINT (x3, 0) == 7 && 1) - goto L1133; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1228; - - L1133: - x3 = XEXP (x2, 1); - if (immediate_operand (x3, SImode)) - { - ro[4] = x3; - return 232; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1228; - - L1229: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != SImode) - goto ret0; - switch (GET_CODE (x2)) - { - case PLUS: - goto L1230; - case UNSPEC: - if (XINT (x2, 1) == 0 && XVECLEN (x2, 0) == 3 && 1) - goto L1306; - } - goto ret0; - - L1230: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == FFS && 1) - goto L1231; - goto ret0; - - L1231: - x4 = XEXP (x3, 0); - if (general_operand (x4, SImode)) - { - ro[1] = x4; - goto L1232; - } - goto ret0; - - L1232: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - goto L1233; - goto ret0; - - L1233: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1234; - goto ret0; - - L1234: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - return 250; - } - goto ret0; - - L1306: - x3 = XVECEXP (x2, 0, 0); - if (GET_MODE (x3) == BLKmode && GET_CODE (x3) == MEM && 1) - goto L1307; - goto ret0; - - L1307: - x4 = XEXP (x3, 0); - if (address_operand (x4, SImode)) - { - ro[1] = x4; - goto L1308; - } - goto ret0; - - L1308: - x3 = XVECEXP (x2, 0, 1); - if (register_operand (x3, QImode)) - { - ro[2] = x3; - goto L1309; - } - goto ret0; - - L1309: - x3 = XVECEXP (x2, 0, 2); - if (immediate_operand (x3, SImode)) - { - ro[3] = x3; - goto L1310; - } - goto ret0; - - L1310: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1311; - goto ret0; - - L1311: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - return 262; - goto ret0; - - L1244: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == PLUS && 1) - goto L1245; - goto ret0; - - L1245: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == HImode && GET_CODE (x3) == FFS && 1) - goto L1246; - goto ret0; - - L1246: - x4 = XEXP (x3, 0); - if (general_operand (x4, HImode)) - { - ro[1] = x4; - goto L1247; - } - goto ret0; - - L1247: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - goto L1248; - goto ret0; - - L1248: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1249; - goto ret0; - - L1249: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[2] = x2; - return 252; - } - goto ret0; - ret0: return -1; -} - -int -recog (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - L1170: - switch (GET_CODE (x0)) - { - case UNSPEC: - if (GET_MODE (x0) == SImode && XINT (x0, 1) == 0 && XVECLEN (x0, 0) == 1 && 1) - goto L1171; - break; - case SET: - goto L200; - case PARALLEL: - if (XVECLEN (x0, 0) == 2 && 1) - goto L10; - if (XVECLEN (x0, 0) == 5 && 1) - goto L299; - if (XVECLEN (x0, 0) == 4 && 1) - goto L313; - if (XVECLEN (x0, 0) == 3 && 1) - goto L363; - if (XVECLEN (x0, 0) == 6 && 1) - goto L1175; - break; - case CALL: - goto L1117; - case RETURN: - if (simple_386_epilogue ()) - return 242; - break; - case CONST_INT: - if (XWINT (x0, 0) == 0 && 1) - return 243; - } - goto ret0; - - L1171: - x1 = XVECEXP (x0, 0, 0); - if (memory_operand (x1, SImode)) - { - ro[0] = x1; - return 241; - } - goto ret0; - L200: - return recog_3 (x0, insn, pnum_clobbers); - - L10: - x1 = XVECEXP (x0, 0, 0); - switch (GET_CODE (x1)) - { - case SET: - goto L241; - case CALL: - goto L1108; - } - goto ret0; - L241: - return recog_5 (x0, insn, pnum_clobbers); - - L1108: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == QImode && GET_CODE (x2) == MEM && 1) - goto L1109; - L1099: - if (call_insn_operand (x2, QImode)) - { - ro[0] = x2; - goto L1100; - } - goto ret0; - - L1109: - x3 = XEXP (x2, 0); - if (symbolic_operand (x3, SImode)) - { - ro[0] = x3; - goto L1110; - } - goto L1099; - - L1110: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1111; - } - x2 = XEXP (x1, 0); - goto L1099; - - L1111: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1112; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1099; - - L1112: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == REG && XINT (x2, 0) == 7 && 1) - goto L1113; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1099; - - L1113: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1114; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1099; - - L1114: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == REG && XINT (x3, 0) == 7 && 1) - goto L1115; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1099; - - L1115: - x3 = XEXP (x2, 1); - if (immediate_operand (x3, SImode)) - { - ro[3] = x3; - if (!HALF_PIC_P ()) - return 227; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1099; - - L1100: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1101; - } - goto ret0; - - L1101: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1102; - goto ret0; - - L1102: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == REG && XINT (x2, 0) == 7 && 1) - goto L1103; - goto ret0; - - L1103: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1104; - goto ret0; - - L1104: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == REG && XINT (x3, 0) == 7 && 1) - goto L1105; - goto ret0; - - L1105: - x3 = XEXP (x2, 1); - if (immediate_operand (x3, SImode)) - { - ro[3] = x3; - return 226; - } - goto ret0; - - L299: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == SET && 1) - goto L300; - goto ret0; - - L300: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DImode && general_operand (x2, DImode)) - { - ro[0] = x2; - goto L301; - } - goto ret0; - - L301: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == DImode && GET_CODE (x2) == FIX && 1) - goto L302; - goto ret0; - - L302: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) != FIX) - goto ret0; - switch (GET_MODE (x3)) - { - case DFmode: - goto L303; - case SFmode: - goto L329; - } - goto ret0; - - L303: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L304; - } - goto ret0; - - L304: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L305; - goto ret0; - - L305: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L306; - goto ret0; - - L306: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L307; - goto ret0; - - L307: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L308; - } - goto ret0; - - L308: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L309; - goto ret0; - - L309: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[3] = x2; - goto L310; - } - goto ret0; - - L310: - x1 = XVECEXP (x0, 0, 4); - if (GET_CODE (x1) == CLOBBER && 1) - goto L311; - goto ret0; - - L311: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[4] = x2; - if (TARGET_80387) - return 67; - } - goto ret0; - - L329: - x4 = XEXP (x3, 0); - if (register_operand (x4, SFmode)) - { - ro[1] = x4; - goto L330; - } - goto ret0; - - L330: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L331; - goto ret0; - - L331: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L332; - goto ret0; - - L332: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L333; - goto ret0; - - L333: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L334; - } - goto ret0; - - L334: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L335; - goto ret0; - - L335: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[3] = x2; - goto L336; - } - goto ret0; - - L336: - x1 = XVECEXP (x0, 0, 4); - if (GET_CODE (x1) == CLOBBER && 1) - goto L337; - goto ret0; - - L337: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[4] = x2; - if (TARGET_80387) - return 68; - } - goto ret0; - - L313: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == SET && 1) - goto L314; - goto ret0; - - L314: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DImode: - if (general_operand (x2, DImode)) - { - ro[0] = x2; - goto L315; - } - break; - case SImode: - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L353; - } - } - goto ret0; - - L315: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == DImode && GET_CODE (x2) == FIX && 1) - goto L316; - goto ret0; - - L316: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) != FIX) - goto ret0; - switch (GET_MODE (x3)) - { - case DFmode: - goto L317; - case SFmode: - goto L343; - } - goto ret0; - - L317: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L318; - } - goto ret0; - - L318: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L319; - goto ret0; - - L319: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L320; - goto ret0; - - L320: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L321; - goto ret0; - - L321: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L322; - } - goto ret0; - - L322: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L323; - goto ret0; - - L323: - x2 = XEXP (x1, 0); - if (pnum_clobbers != 0 && memory_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 67; - } - } - goto ret0; - - L343: - x4 = XEXP (x3, 0); - if (register_operand (x4, SFmode)) - { - ro[1] = x4; - goto L344; - } - goto ret0; - - L344: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L345; - goto ret0; - - L345: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L346; - goto ret0; - - L346: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L347; - goto ret0; - - L347: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L348; - } - goto ret0; - - L348: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L349; - goto ret0; - - L349: - x2 = XEXP (x1, 0); - if (pnum_clobbers != 0 && memory_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 68; - } - } - goto ret0; - - L353: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == FIX && 1) - goto L354; - goto ret0; - - L354: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) != FIX) - goto ret0; - switch (GET_MODE (x3)) - { - case DFmode: - goto L355; - case SFmode: - goto L377; - } - goto ret0; - - L355: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L356; - } - goto ret0; - - L356: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L357; - goto ret0; - - L357: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L358; - } - goto ret0; - - L358: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L359; - goto ret0; - - L359: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[3] = x2; - goto L360; - } - goto ret0; - - L360: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L361; - goto ret0; - - L361: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[4] = x2; - if (TARGET_80387) - return 71; - } - goto ret0; - - L377: - x4 = XEXP (x3, 0); - if (register_operand (x4, SFmode)) - { - ro[1] = x4; - goto L378; - } - goto ret0; - - L378: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L379; - goto ret0; - - L379: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L380; - } - goto ret0; - - L380: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L381; - goto ret0; - - L381: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[3] = x2; - goto L382; - } - goto ret0; - - L382: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L383; - goto ret0; - - L383: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[4] = x2; - if (TARGET_80387) - return 72; - } - goto ret0; - - L363: - x1 = XVECEXP (x0, 0, 0); - switch (GET_CODE (x1)) - { - case SET: - goto L364; - case CALL: - goto L1165; - } - goto ret0; - - L364: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && general_operand (x2, SImode)) - { - ro[0] = x2; - goto L365; - } - goto ret0; - - L365: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == FIX && 1) - goto L366; - goto ret0; - - L366: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) != FIX) - goto ret0; - switch (GET_MODE (x3)) - { - case DFmode: - goto L367; - case SFmode: - goto L389; - } - goto ret0; - - L367: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L368; - } - goto ret0; - - L368: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L369; - goto ret0; - - L369: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L370; - } - goto ret0; - - L370: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L371; - goto ret0; - - L371: - x2 = XEXP (x1, 0); - if (pnum_clobbers != 0 && memory_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 71; - } - } - goto ret0; - - L389: - x4 = XEXP (x3, 0); - if (register_operand (x4, SFmode)) - { - ro[1] = x4; - goto L390; - } - goto ret0; - - L390: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L391; - goto ret0; - - L391: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L392; - } - goto ret0; - - L392: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L393; - goto ret0; - - L393: - x2 = XEXP (x1, 0); - if (pnum_clobbers != 0 && memory_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 72; - } - } - goto ret0; - - L1165: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == QImode && GET_CODE (x2) == MEM && 1) - goto L1166; - L1159: - if (call_insn_operand (x2, QImode)) - { - ro[0] = x2; - goto L1160; - } - goto ret0; - - L1166: - x3 = XEXP (x2, 0); - if (symbolic_operand (x3, SImode)) - { - ro[0] = x3; - goto L1167; - } - goto L1159; - - L1167: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - goto L1168; - x2 = XEXP (x1, 0); - goto L1159; - - L1168: - x1 = XVECEXP (x0, 0, 1); - if (memory_operand (x1, DImode)) - { - ro[1] = x1; - goto L1169; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1159; - - L1169: - x1 = XVECEXP (x0, 0, 2); - ro[2] = x1; - if (!HALF_PIC_P ()) - return 239; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1159; - - L1160: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - goto L1161; - goto ret0; - - L1161: - x1 = XVECEXP (x0, 0, 1); - if (memory_operand (x1, DImode)) - { - ro[1] = x1; - goto L1162; - } - goto ret0; - - L1162: - x1 = XVECEXP (x0, 0, 2); - ro[2] = x1; - return 238; - - L1175: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == SET && 1) - goto L1176; - goto ret0; - - L1176: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case BLKmode: - if (GET_CODE (x2) == MEM && 1) - goto L1177; - break; - case SImode: - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L1193; - } - } - if (GET_CODE (x2) == CC0 && 1) - goto L1211; - goto ret0; - - L1177: - x3 = XEXP (x2, 0); - if (address_operand (x3, SImode)) - { - ro[0] = x3; - goto L1178; - } - goto ret0; - - L1178: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == BLKmode && GET_CODE (x2) == MEM && 1) - goto L1179; - goto ret0; - - L1179: - x3 = XEXP (x2, 0); - if (address_operand (x3, SImode)) - { - ro[1] = x3; - goto L1180; - } - goto ret0; - - L1180: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1181; - goto ret0; - - L1181: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - goto L1182; - } - goto ret0; - - L1182: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == USE && 1) - goto L1183; - goto ret0; - - L1183: - x2 = XEXP (x1, 0); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - goto L1184; - } - goto ret0; - - L1184: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1185; - goto ret0; - - L1185: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[4] = x2; - goto L1186; - } - goto ret0; - - L1186: - x1 = XVECEXP (x0, 0, 4); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1187; - goto ret0; - - L1187: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1188; - goto ret0; - - L1188: - x1 = XVECEXP (x0, 0, 5); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1189; - goto ret0; - - L1189: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - return 245; - goto ret0; - - L1193: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == COMPARE && 1) - goto L1194; - goto ret0; - - L1194: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == BLKmode && GET_CODE (x3) == MEM && 1) - goto L1195; - goto ret0; - - L1195: - x4 = XEXP (x3, 0); - if (address_operand (x4, SImode)) - { - ro[1] = x4; - goto L1196; - } - goto ret0; - - L1196: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == BLKmode && GET_CODE (x3) == MEM && 1) - goto L1197; - goto ret0; - - L1197: - x4 = XEXP (x3, 0); - if (address_operand (x4, SImode)) - { - ro[2] = x4; - goto L1198; - } - goto ret0; - - L1198: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1199; - goto ret0; - - L1199: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[3] = x2; - goto L1200; - } - goto ret0; - - L1200: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == USE && 1) - goto L1201; - goto ret0; - - L1201: - x2 = XEXP (x1, 0); - if (immediate_operand (x2, SImode)) - { - ro[4] = x2; - goto L1202; - } - goto ret0; - - L1202: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1203; - goto ret0; - - L1203: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L1204; - goto ret0; - - L1204: - x1 = XVECEXP (x0, 0, 4); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1205; - goto ret0; - - L1205: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[2]) && 1) - goto L1206; - goto ret0; - - L1206: - x1 = XVECEXP (x0, 0, 5); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1207; - goto ret0; - - L1207: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[3]) && 1) - return 247; - goto ret0; - - L1211: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == COMPARE && 1) - goto L1212; - goto ret0; - - L1212: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == BLKmode && GET_CODE (x3) == MEM && 1) - goto L1213; - goto ret0; - - L1213: - x4 = XEXP (x3, 0); - if (address_operand (x4, SImode)) - { - ro[0] = x4; - goto L1214; - } - goto ret0; - - L1214: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == BLKmode && GET_CODE (x3) == MEM && 1) - goto L1215; - goto ret0; - - L1215: - x4 = XEXP (x3, 0); - if (address_operand (x4, SImode)) - { - ro[1] = x4; - goto L1216; - } - goto ret0; - - L1216: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1217; - goto ret0; - - L1217: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[2] = x2; - goto L1218; - } - goto ret0; - - L1218: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == USE && 1) - goto L1219; - goto ret0; - - L1219: - x2 = XEXP (x1, 0); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - goto L1220; - } - goto ret0; - - L1220: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1221; - goto ret0; - - L1221: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1222; - goto ret0; - - L1222: - x1 = XVECEXP (x0, 0, 4); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1223; - goto ret0; - - L1223: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L1224; - goto ret0; - - L1224: - x1 = XVECEXP (x0, 0, 5); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1225; - goto ret0; - - L1225: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[2]) && 1) - return 248; - goto ret0; - - L1117: - x1 = XEXP (x0, 0); - if (call_insn_operand (x1, QImode)) - { - ro[0] = x1; - goto L1118; - } - L1120: - if (GET_MODE (x1) == QImode && GET_CODE (x1) == MEM && 1) - goto L1121; - goto ret0; - - L1118: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - { - ro[1] = x1; - return 229; - } - x1 = XEXP (x0, 0); - goto L1120; - - L1121: - x2 = XEXP (x1, 0); - if (symbolic_operand (x2, SImode)) - { - ro[0] = x2; - goto L1122; - } - goto ret0; - - L1122: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - { - ro[1] = x1; - if (!HALF_PIC_P ()) - return 230; - } - goto ret0; - ret0: return -1; -} - -rtx -split_insns (x0, insn) - register rtx x0; - rtx insn; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - rtx tem; - - goto ret0; - ret0: return 0; -} - diff --git a/gnu/usr.bin/gcc2/common/tconfig.h b/gnu/usr.bin/gcc2/common/tconfig.h deleted file mode 100644 index eb90681006fd..000000000000 --- a/gnu/usr.bin/gcc2/common/tconfig.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Configuration for GNU C-compiler for Intel 80386. - Copyright (C) 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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. - -GNU CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef i386 -#define i386 -#endif - -/* #defines that need visibility everywhere. */ -#define FALSE 0 -#define TRUE 1 - -/* This describes the machine the compiler is hosted on. */ -#define HOST_BITS_PER_CHAR 8 -#define HOST_BITS_PER_SHORT 16 -#define HOST_BITS_PER_INT 32 -#define HOST_BITS_PER_LONG 32 -#define HOST_BITS_PER_LONGLONG 64 - -/* Arguments to use with `exit'. */ -#define SUCCESS_EXIT_CODE 0 -#define FATAL_EXIT_CODE 33 - -/* If compiled with GNU C, use the built-in alloca */ -#ifdef __GNUC__ -#undef alloca -#define alloca __builtin_alloca -#endif - -/* target machine dependencies. - tm.h is a symbolic link to the actual target specific file. */ - -#include "tm.h" diff --git a/gnu/usr.bin/gcc2/common/tm.h b/gnu/usr.bin/gcc2/common/tm.h deleted file mode 100644 index f7fbac12425a..000000000000 --- a/gnu/usr.bin/gcc2/common/tm.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Configuration for an i386 running 386BSD as the target machine. */ - -/* This is tested by i386gas.h. */ -#define YES_UNDERSCORES - -#include "i386/gstabs.h" - -/* Get perform_* macros to build libgcc.a. */ -#include "i386/perform.h" - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-Dunix -Di386 -D____386BSD____ -D__386BSD__ -DBSD_NET2" - -/* Like the default, except no -lg. */ -#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" - -#undef SIZE_TYPE -#define SIZE_TYPE "unsigned int" - -#undef PTRDIFF_TYPE -#define PTRDIFF_TYPE "int" - -#undef WCHAR_TYPE -#define WCHAR_TYPE "short unsigned int" - -#define WCHAR_UNSIGNED 1 - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE 16 - -/* 386BSD does have atexit. */ - -#define HAVE_ATEXIT - -/* Redefine this to use %eax instead of %edx. */ -#undef FUNCTION_PROFILER -#define FUNCTION_PROFILER(FILE, LABELNO) \ -{ \ - if (flag_pic) \ - { \ - fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n", \ - LPREFIX, (LABELNO)); \ - fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ - } \ - else \ - { \ - fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO)); \ - fprintf (FILE, "\tcall mcount\n"); \ - } \ -} - -/* There are conflicting reports about whether this system uses - a different assembler syntax. wilson@cygnus.com says # is right. */ -#undef COMMENT_BEGIN -#define COMMENT_BEGIN "#" - -#undef ASM_APP_ON -#define ASM_APP_ON "#APP\n" - -#undef ASM_APP_OFF -#define ASM_APP_OFF "#NO_APP\n" - -/* The following macros are stolen from i386v4.h */ -/* These have to be defined to get PIC code correct */ - -/* This is how to output an element of a case-vector that is relative. - This is only used for PIC code. See comments by the `casesi' insn in - i386.md for an explanation of the expression this outputs. */ - -#undef ASM_OUTPUT_ADDR_DIFF_ELT -#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ - fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) - -/* Indicate that jump tables go in the text section. This is - necessary when compiling PIC code. */ - -#define JUMP_TABLES_IN_TEXT_SECTION - -/* Don't default to pcc-struct-return, because gcc is the only compiler, and - we want to retain compatibility with older gcc versions. */ -#define DEFAULT_PCC_STRUCT_RETURN 0 diff --git a/gnu/usr.bin/gcc2/i386/insn-attr.h b/gnu/usr.bin/gcc2/i386/insn-attr.h deleted file mode 100644 index 845aaa068685..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-attr.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Generated automatically by the program `genattr' -from the machine description file `md'. - - $Id: insn-attr.h,v 1.2 1993/08/02 17:36:56 mycroft Exp $ -*/ - -#ifndef PROTO -#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) -#define PROTO(ARGS) ARGS -#else -#define PROTO(ARGS) () -#endif -#endif -#define HAVE_ATTR_alternative -#define get_attr_alternative(insn) which_alternative - -#define ATTR_FLAG_forward 0x1 -#define ATTR_FLAG_backward 0x2 -#define ATTR_FLAG_likely 0x4 -#define ATTR_FLAG_very_likely 0x8 -#define ATTR_FLAG_unlikely 0x10 -#define ATTR_FLAG_very_unlikely 0x20 diff --git a/gnu/usr.bin/gcc2/i386/insn-attrtab.c b/gnu/usr.bin/gcc2/i386/insn-attrtab.c deleted file mode 100644 index 3150adf15e17..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-attrtab.c +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated automatically by the program `genattrtab' -from the machine description file `md'. */ - -#ifndef lint -static char rcsid[] = "$Id: insn-attrtab.c,v 1.2 1993/08/02 17:36:57 mycroft Exp $"; -#endif /* not lint */ - -#include "config.h" -#include "rtl.h" -#include "insn-config.h" -#include "recog.h" -#include "regs.h" -#include "real.h" -#include "output.h" -#include "insn-attr.h" - -#define operands recog_operand - diff --git a/gnu/usr.bin/gcc2/i386/insn-codes.h b/gnu/usr.bin/gcc2/i386/insn-codes.h deleted file mode 100644 index 7302b83f5bb2..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-codes.h +++ /dev/null @@ -1,177 +0,0 @@ -/* Generated automatically by the program `gencodes' -from the machine description file `md'. - - $Id: insn-codes.h,v 1.2 1993/08/02 17:36:57 mycroft Exp $ -*/ - -#ifndef MAX_INSN_CODE - -enum insn_code { - CODE_FOR_tstsi_1 = 0, - CODE_FOR_tstsi = 1, - CODE_FOR_tsthi_1 = 2, - CODE_FOR_tsthi = 3, - CODE_FOR_tstqi_1 = 4, - CODE_FOR_tstqi = 5, - CODE_FOR_tstsf_cc = 6, - CODE_FOR_tstsf = 7, - CODE_FOR_tstdf_cc = 8, - CODE_FOR_tstdf = 9, - CODE_FOR_cmpsi_1 = 10, - CODE_FOR_cmpsi = 11, - CODE_FOR_cmphi_1 = 12, - CODE_FOR_cmphi = 13, - CODE_FOR_cmpqi_1 = 14, - CODE_FOR_cmpqi = 15, - CODE_FOR_cmpsf_cc_1 = 22, - CODE_FOR_cmpdf = 26, - CODE_FOR_cmpsf = 27, - CODE_FOR_cmpdf_cc = 28, - CODE_FOR_cmpdf_ccfpeq = 29, - CODE_FOR_cmpsf_cc = 30, - CODE_FOR_cmpsf_ccfpeq = 31, - CODE_FOR_movsi = 37, - CODE_FOR_movhi = 40, - CODE_FOR_movstricthi = 41, - CODE_FOR_movqi = 43, - CODE_FOR_movstrictqi = 44, - CODE_FOR_movsf = 46, - CODE_FOR_swapdf = 48, - CODE_FOR_movdf = 49, - CODE_FOR_movdi = 51, - CODE_FOR_zero_extendhisi2 = 52, - CODE_FOR_zero_extendqihi2 = 53, - CODE_FOR_zero_extendqisi2 = 54, - CODE_FOR_zero_extendsidi2 = 55, - CODE_FOR_extendsidi2 = 56, - CODE_FOR_extendhisi2 = 57, - CODE_FOR_extendqihi2 = 58, - CODE_FOR_extendqisi2 = 59, - CODE_FOR_extendsfdf2 = 60, - CODE_FOR_truncdfsf2 = 61, - CODE_FOR_fixuns_truncdfsi2 = 63, - CODE_FOR_fixuns_truncsfsi2 = 64, - CODE_FOR_fix_truncdfdi2 = 65, - CODE_FOR_fix_truncsfdi2 = 66, - CODE_FOR_fix_truncdfsi2 = 69, - CODE_FOR_fix_truncsfsi2 = 70, - CODE_FOR_floatsisf2 = 73, - CODE_FOR_floatdisf2 = 74, - CODE_FOR_floatsidf2 = 75, - CODE_FOR_floatdidf2 = 76, - CODE_FOR_adddi3 = 81, - CODE_FOR_addsi3 = 82, - CODE_FOR_addhi3 = 83, - CODE_FOR_addqi3 = 84, - CODE_FOR_adddf3 = 86, - CODE_FOR_addsf3 = 87, - CODE_FOR_subdi3 = 88, - CODE_FOR_subsi3 = 89, - CODE_FOR_subhi3 = 90, - CODE_FOR_subqi3 = 91, - CODE_FOR_subdf3 = 92, - CODE_FOR_subsf3 = 93, - CODE_FOR_mulhi3 = 95, - CODE_FOR_mulsi3 = 97, - CODE_FOR_muldf3 = 99, - CODE_FOR_mulsf3 = 100, - CODE_FOR_divqi3 = 101, - CODE_FOR_udivqi3 = 102, - CODE_FOR_divdf3 = 103, - CODE_FOR_divsf3 = 104, - CODE_FOR_divmodsi4 = 105, - CODE_FOR_divmodhi4 = 106, - CODE_FOR_udivmodsi4 = 107, - CODE_FOR_udivmodhi4 = 108, - CODE_FOR_andsi3 = 109, - CODE_FOR_andhi3 = 110, - CODE_FOR_andqi3 = 111, - CODE_FOR_iorsi3 = 112, - CODE_FOR_iorhi3 = 113, - CODE_FOR_iorqi3 = 114, - CODE_FOR_xorsi3 = 115, - CODE_FOR_xorhi3 = 116, - CODE_FOR_xorqi3 = 117, - CODE_FOR_negdi2 = 118, - CODE_FOR_negsi2 = 119, - CODE_FOR_neghi2 = 120, - CODE_FOR_negqi2 = 121, - CODE_FOR_negsf2 = 122, - CODE_FOR_negdf2 = 123, - CODE_FOR_abssf2 = 125, - CODE_FOR_absdf2 = 126, - CODE_FOR_sqrtsf2 = 128, - CODE_FOR_sqrtdf2 = 129, - CODE_FOR_sindf2 = 131, - CODE_FOR_sinsf2 = 132, - CODE_FOR_cosdf2 = 134, - CODE_FOR_cossf2 = 135, - CODE_FOR_one_cmplsi2 = 137, - CODE_FOR_one_cmplhi2 = 138, - CODE_FOR_one_cmplqi2 = 139, - CODE_FOR_ashldi3 = 140, - CODE_FOR_ashldi3_const_int = 141, - CODE_FOR_ashldi3_non_const_int = 142, - CODE_FOR_ashlsi3 = 143, - CODE_FOR_ashlhi3 = 144, - CODE_FOR_ashlqi3 = 145, - CODE_FOR_ashrdi3 = 146, - CODE_FOR_ashrdi3_const_int = 147, - CODE_FOR_ashrdi3_non_const_int = 148, - CODE_FOR_ashrsi3 = 149, - CODE_FOR_ashrhi3 = 150, - CODE_FOR_ashrqi3 = 151, - CODE_FOR_lshrdi3 = 152, - CODE_FOR_lshrdi3_const_int = 153, - CODE_FOR_lshrdi3_non_const_int = 154, - CODE_FOR_lshrsi3 = 155, - CODE_FOR_lshrhi3 = 156, - CODE_FOR_lshrqi3 = 157, - CODE_FOR_rotlsi3 = 158, - CODE_FOR_rotlhi3 = 159, - CODE_FOR_rotlqi3 = 160, - CODE_FOR_rotrsi3 = 161, - CODE_FOR_rotrhi3 = 162, - CODE_FOR_rotrqi3 = 163, - CODE_FOR_seq = 170, - CODE_FOR_sne = 172, - CODE_FOR_sgt = 174, - CODE_FOR_sgtu = 176, - CODE_FOR_slt = 178, - CODE_FOR_sltu = 180, - CODE_FOR_sge = 182, - CODE_FOR_sgeu = 184, - CODE_FOR_sle = 186, - CODE_FOR_sleu = 188, - CODE_FOR_beq = 190, - CODE_FOR_bne = 192, - CODE_FOR_bgt = 194, - CODE_FOR_bgtu = 196, - CODE_FOR_blt = 198, - CODE_FOR_bltu = 200, - CODE_FOR_bge = 202, - CODE_FOR_bgeu = 204, - CODE_FOR_ble = 206, - CODE_FOR_bleu = 208, - CODE_FOR_jump = 220, - CODE_FOR_indirect_jump = 221, - CODE_FOR_casesi = 222, - CODE_FOR_tablejump = 224, - CODE_FOR_call_pop = 225, - CODE_FOR_call = 228, - CODE_FOR_call_value_pop = 231, - CODE_FOR_call_value = 234, - CODE_FOR_untyped_call = 237, - CODE_FOR_untyped_return = 240, - CODE_FOR_update_return = 241, - CODE_FOR_return = 242, - CODE_FOR_nop = 243, - CODE_FOR_movstrsi = 244, - CODE_FOR_cmpstrsi = 246, - CODE_FOR_ffssi2 = 249, - CODE_FOR_ffshi2 = 251, - CODE_FOR_strlensi = 261, - CODE_FOR_nothing }; - -#define MAX_INSN_CODE ((int) CODE_FOR_nothing) -#endif /* MAX_INSN_CODE */ diff --git a/gnu/usr.bin/gcc2/i386/insn-config.h b/gnu/usr.bin/gcc2/i386/insn-config.h deleted file mode 100644 index 4fd48c09ab82..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-config.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Generated automatically by the program `genconfig' -from the machine description file `md'. - - $Id: insn-config.h,v 1.2 1993/08/02 17:36:58 mycroft Exp $ -*/ - - -#define MAX_RECOG_OPERANDS 10 - -#define MAX_DUP_OPERANDS 3 -#ifndef MAX_INSNS_PER_SPLIT -#define MAX_INSNS_PER_SPLIT 1 -#endif -#define REGISTER_CONSTRAINTS -#define HAVE_cc0 diff --git a/gnu/usr.bin/gcc2/i386/insn-emit.c b/gnu/usr.bin/gcc2/i386/insn-emit.c deleted file mode 100644 index 87227c599d94..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-emit.c +++ /dev/null @@ -1,2712 +0,0 @@ -/* Generated automatically by the program `genemit' -from the machine description file `md'. */ - -#ifndef lint -static char rcsid[] = "$Id: insn-emit.c,v 1.2 1993/08/02 17:36:59 mycroft Exp $"; -#endif /* not lint */ - -#include "config.h" -#include "rtl.h" -#include "expr.h" -#include "real.h" -#include "output.h" -#include "insn-config.h" - -#include "insn-flags.h" - -#include "insn-codes.h" - -extern char *insn_operand_constraint[][MAX_RECOG_OPERANDS]; - -extern rtx recog_operand[]; -#define operands emit_operand - -#define FAIL goto _fail - -#define DONE goto _done - -rtx -gen_tstsi_1 (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tstsi (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - i386_compare_gen = gen_tstsi_1; - i386_compare_op0 = operands[0]; - DONE; -} - operand0 = operands[0]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, operand0)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tsthi_1 (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tsthi (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - i386_compare_gen = gen_tsthi_1; - i386_compare_op0 = operands[0]; - DONE; -} - operand0 = operands[0]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, operand0)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tstqi_1 (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, operand0); -} - -rtx -gen_tstqi (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - i386_compare_gen = gen_tstqi_1; - i386_compare_op0 = operands[0]; - DONE; -} - operand0 = operands[0]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, operand0)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tstsf_cc (operand0) - rtx operand0; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)))); -} - -rtx -gen_tstsf (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - i386_compare_gen = gen_tstsf_cc; - i386_compare_op0 = operands[0]; - DONE; -} - operand0 = operands[0]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tstdf_cc (operand0) - rtx operand0; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)))); -} - -rtx -gen_tstdf (operand0) - rtx operand0; -{ - rtx operands[1]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - i386_compare_gen = gen_tstdf_cc; - i386_compare_op0 = operands[0]; - DONE; -} - operand0 = operands[0]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, operand0), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpsi_1 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmpsi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - operands[0] = force_reg (SImode, operands[0]); - - i386_compare_gen = gen_cmpsi_1; - i386_compare_op0 = operands[0]; - i386_compare_op1 = operands[1]; - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmphi_1 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmphi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - operands[0] = force_reg (HImode, operands[0]); - - i386_compare_gen = gen_cmphi_1; - i386_compare_op0 = operands[0]; - i386_compare_op1 = operands[1]; - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpqi_1 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)); -} - -rtx -gen_cmpqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) - operands[0] = force_reg (QImode, operands[0]); - - i386_compare_gen = gen_cmpqi_1; - i386_compare_op0 = operands[0]; - i386_compare_op1 = operands[1]; - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpsf_cc_1 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (GET_CODE (operand2), VOIDmode, - operand0, - operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)))); -} - -rtx -gen_cmpdf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - i386_compare_gen = gen_cmpdf_cc; - i386_compare_gen_eq = gen_cmpdf_ccfpeq; - i386_compare_op0 = operands[0]; - i386_compare_op1 = operands[1]; - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpsf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - i386_compare_gen = gen_cmpsf_cc; - i386_compare_gen_eq = gen_cmpsf_ccfpeq; - i386_compare_op0 = operands[0]; - i386_compare_op1 = operands[1]; - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpdf_cc (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)))); -} - -rtx -gen_cmpdf_ccfpeq (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (! register_operand (operands[1], DFmode)) - operands[1] = copy_to_mode_reg (DFmode, operands[1]); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, CCFPEQmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpsf_cc (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, VOIDmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)))); -} - -rtx -gen_cmpsf_ccfpeq (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - if (! register_operand (operands[1], SFmode)) - operands[1] = copy_to_mode_reg (SFmode, operands[1]); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, CCFPEQmode, operand0, operand1)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_movsi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - extern int flag_pic; - - if (flag_pic && SYMBOLIC_CONST (operands[1])) - emit_pic_move (operands, SImode); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_movhi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movstricthi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand0), operand1); -} - -rtx -gen_movqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movstrictqi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, gen_rtx (STRICT_LOW_PART, VOIDmode, operand0), operand1); -} - -rtx -gen_movsf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_swapdf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, operand1), - gen_rtx (SET, VOIDmode, operand1, operand0))); -} - -rtx -gen_movdf (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_movdi (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, operand1); -} - -rtx -gen_zero_extendhisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ZERO_EXTEND, SImode, operand1)); -} - -rtx -gen_zero_extendqihi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ZERO_EXTEND, HImode, operand1)); -} - -rtx -gen_zero_extendqisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ZERO_EXTEND, SImode, operand1)); -} - -rtx -gen_zero_extendsidi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ZERO_EXTEND, DImode, operand1)); -} - -rtx -gen_extendsidi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, DImode, operand1)); -} - -rtx -gen_extendhisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, SImode, operand1)); -} - -rtx -gen_extendqihi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, HImode, operand1)); -} - -rtx -gen_extendqisi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SIGN_EXTEND, SImode, operand1)); -} - -rtx -gen_extendsfdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_EXTEND, DFmode, operand1)); -} - -rtx -gen_truncdfsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[2] = (rtx) assign_386_stack_local (SFmode, 0); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT_TRUNCATE, SFmode, operand1)), - gen_rtx (CLOBBER, VOIDmode, operand2)))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fixuns_truncdfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operand4; - rtx operand5; - rtx operand6; - rtx operands[7]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[2] = gen_reg_rtx (DImode); - operands[3] = gen_lowpart (SImode, operands[2]); - operands[4] = gen_reg_rtx (DFmode); - operands[5] = (rtx) assign_386_stack_local (SImode, 0); - operands[6] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - operand6 = operands[6]; - emit_insn (gen_rtx (SET, VOIDmode, operand4, operand1)); - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (5, - gen_rtx (SET, VOIDmode, operand2, gen_rtx (FIX, DImode, gen_rtx (FIX, DFmode, operand4))), - gen_rtx (CLOBBER, VOIDmode, operand4), - gen_rtx (CLOBBER, VOIDmode, operand5), - gen_rtx (CLOBBER, VOIDmode, operand6), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - emit_insn (gen_rtx (SET, VOIDmode, operand0, operand3)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fixuns_truncsfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operand4; - rtx operand5; - rtx operand6; - rtx operands[7]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[2] = gen_reg_rtx (DImode); - operands[3] = gen_lowpart (SImode, operands[2]); - operands[4] = gen_reg_rtx (SFmode); - operands[5] = (rtx) assign_386_stack_local (SImode, 0); - operands[6] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - operand6 = operands[6]; - emit_insn (gen_rtx (SET, VOIDmode, operand4, operand1)); - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (5, - gen_rtx (SET, VOIDmode, operand2, gen_rtx (FIX, DImode, gen_rtx (FIX, SFmode, operand4))), - gen_rtx (CLOBBER, VOIDmode, operand4), - gen_rtx (CLOBBER, VOIDmode, operand5), - gen_rtx (CLOBBER, VOIDmode, operand6), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - emit_insn (gen_rtx (SET, VOIDmode, operand0, operand3)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fix_truncdfdi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operand4; - rtx operands[5]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[1] = copy_to_mode_reg (DFmode, operands[1]); - operands[2] = gen_reg_rtx (DFmode); - operands[3] = (rtx) assign_386_stack_local (SImode, 0); - operands[4] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - emit_insn (gen_rtx (SET, VOIDmode, operand2, operand1)); - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (5, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, DImode, gen_rtx (FIX, DFmode, operand2))), - gen_rtx (CLOBBER, VOIDmode, operand2), - gen_rtx (CLOBBER, VOIDmode, operand3), - gen_rtx (CLOBBER, VOIDmode, operand4), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fix_truncsfdi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operand4; - rtx operands[5]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[1] = copy_to_mode_reg (SFmode, operands[1]); - operands[2] = gen_reg_rtx (SFmode); - operands[3] = (rtx) assign_386_stack_local (SImode, 0); - operands[4] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - emit_insn (gen_rtx (SET, VOIDmode, operand2, operand1)); - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (5, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, DImode, gen_rtx (FIX, SFmode, operand2))), - gen_rtx (CLOBBER, VOIDmode, operand2), - gen_rtx (CLOBBER, VOIDmode, operand3), - gen_rtx (CLOBBER, VOIDmode, operand4), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fix_truncdfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operands[4]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[2] = (rtx) assign_386_stack_local (SImode, 0); - operands[3] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (4, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, gen_rtx (FIX, DFmode, operand1))), - gen_rtx (CLOBBER, VOIDmode, operand2), - gen_rtx (CLOBBER, VOIDmode, operand3), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_fix_truncsfsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operands[4]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - operands[2] = (rtx) assign_386_stack_local (SImode, 0); - operands[3] = (rtx) assign_386_stack_local (SImode, 1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (4, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (FIX, SImode, gen_rtx (FIX, SFmode, operand1))), - gen_rtx (CLOBBER, VOIDmode, operand2), - gen_rtx (CLOBBER, VOIDmode, operand3), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_floatsisf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, SFmode, operand1)); -} - -rtx -gen_floatdisf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, SFmode, operand1)); -} - -rtx -gen_floatsidf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, DFmode, operand1)); -} - -rtx -gen_floatdidf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (FLOAT, DFmode, operand1)); -} - -rtx -gen_adddi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, DImode, operand1, operand2)); -} - -rtx -gen_addsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SImode, operand1, operand2)); -} - -rtx -gen_addhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, HImode, operand1, operand2)); -} - -rtx -gen_addqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, QImode, operand1, operand2)); -} - -rtx -gen_adddf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, DFmode, operand1, operand2)); -} - -rtx -gen_addsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SFmode, operand1, operand2)); -} - -rtx -gen_subdi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, DImode, operand1, operand2)); -} - -rtx -gen_subsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, SImode, operand1, operand2)); -} - -rtx -gen_subhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, HImode, operand1, operand2)); -} - -rtx -gen_subqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, QImode, operand1, operand2)); -} - -rtx -gen_subdf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, DFmode, operand1, operand2)); -} - -rtx -gen_subsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, SFmode, operand1, operand2)); -} - -rtx -gen_mulhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SImode, operand1, operand2)); -} - -rtx -gen_mulsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SImode, operand1, operand2)); -} - -rtx -gen_muldf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, DFmode, operand1, operand2)); -} - -rtx -gen_mulsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (MULT, SFmode, operand1, operand2)); -} - -rtx -gen_divqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, QImode, operand1, operand2)); -} - -rtx -gen_udivqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UDIV, QImode, operand1, operand2)); -} - -rtx -gen_divdf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, DFmode, operand1, operand2)); -} - -rtx -gen_divsf3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, SFmode, operand1, operand2)); -} - -rtx -gen_divmodsi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (MOD, SImode, operand1, operand2)))); -} - -rtx -gen_divmodhi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (DIV, HImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (MOD, HImode, operand1, operand2)))); -} - -rtx -gen_udivmodsi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (UDIV, SImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (UMOD, SImode, operand1, operand2)))); -} - -rtx -gen_udivmodhi4 (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (UDIV, HImode, operand1, operand2)), - gen_rtx (SET, VOIDmode, operand3, gen_rtx (UMOD, HImode, operand1, operand2)))); -} - -rtx -gen_andsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, SImode, operand1, operand2)); -} - -rtx -gen_andhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, HImode, operand1, operand2)); -} - -rtx -gen_andqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (AND, QImode, operand1, operand2)); -} - -rtx -gen_iorsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, SImode, operand1, operand2)); -} - -rtx -gen_iorhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, HImode, operand1, operand2)); -} - -rtx -gen_iorqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (IOR, QImode, operand1, operand2)); -} - -rtx -gen_xorsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, SImode, operand1, operand2)); -} - -rtx -gen_xorhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, HImode, operand1, operand2)); -} - -rtx -gen_xorqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (XOR, QImode, operand1, operand2)); -} - -rtx -gen_negdi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, DImode, operand1)); -} - -rtx -gen_negsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, SImode, operand1)); -} - -rtx -gen_neghi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, HImode, operand1)); -} - -rtx -gen_negqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, QImode, operand1)); -} - -rtx -gen_negsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, SFmode, operand1)); -} - -rtx -gen_negdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NEG, DFmode, operand1)); -} - -rtx -gen_abssf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ABS, SFmode, operand1)); -} - -rtx -gen_absdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ABS, DFmode, operand1)); -} - -rtx -gen_sqrtsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SQRT, SFmode, operand1)); -} - -rtx -gen_sqrtdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (SQRT, DFmode, operand1)); -} - -rtx -gen_sindf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UNSPEC, DFmode, gen_rtvec (1, - operand1), 1)); -} - -rtx -gen_sinsf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UNSPEC, SFmode, gen_rtvec (1, - operand1), 1)); -} - -rtx -gen_cosdf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UNSPEC, DFmode, gen_rtvec (1, - operand1), 2)); -} - -rtx -gen_cossf2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (UNSPEC, SFmode, gen_rtvec (1, - operand1), 2)); -} - -rtx -gen_one_cmplsi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, SImode, operand1)); -} - -rtx -gen_one_cmplhi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, HImode, operand1)); -} - -rtx -gen_one_cmplqi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (NOT, QImode, operand1)); -} - -rtx -gen_ashldi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (GET_CODE (operands[2]) != CONST_INT - || ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')) - { - operands[2] = copy_to_mode_reg (QImode, operands[2]); - emit_insn (gen_ashldi3_non_const_int (operands[0], operands[1], - operands[2])); - } - else - emit_insn (gen_ashldi3_const_int (operands[0], operands[1], operands[2])); - - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, DImode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_ashldi3_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, DImode, operand1, operand2)); -} - -rtx -gen_ashldi3_non_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, DImode, operand1, operand2)), - gen_rtx (CLOBBER, VOIDmode, operand2))); -} - -rtx -gen_ashlsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, SImode, operand1, operand2)); -} - -rtx -gen_ashlhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, HImode, operand1, operand2)); -} - -rtx -gen_ashlqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFT, QImode, operand1, operand2)); -} - -rtx -gen_ashrdi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (GET_CODE (operands[2]) != CONST_INT - || ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')) - { - operands[2] = copy_to_mode_reg (QImode, operands[2]); - emit_insn (gen_ashrdi3_non_const_int (operands[0], operands[1], - operands[2])); - } - else - emit_insn (gen_ashrdi3_const_int (operands[0], operands[1], operands[2])); - - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, DImode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_ashrdi3_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, DImode, operand1, operand2)); -} - -rtx -gen_ashrdi3_non_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, DImode, operand1, operand2)), - gen_rtx (CLOBBER, VOIDmode, operand2))); -} - -rtx -gen_ashrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, SImode, operand1, operand2)); -} - -rtx -gen_ashrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, HImode, operand1, operand2)); -} - -rtx -gen_ashrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ASHIFTRT, QImode, operand1, operand2)); -} - -rtx -gen_lshrdi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - if (GET_CODE (operands[2]) != CONST_INT - || ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')) - { - operands[2] = copy_to_mode_reg (QImode, operands[2]); - emit_insn (gen_lshrdi3_non_const_int (operands[0], operands[1], - operands[2])); - } - else - emit_insn (gen_lshrdi3_const_int (operands[0], operands[1], operands[2])); - - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, DImode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_lshrdi3_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, DImode, operand1, operand2)); -} - -rtx -gen_lshrdi3_non_const_int (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, DImode, operand1, operand2)), - gen_rtx (CLOBBER, VOIDmode, operand2))); -} - -rtx -gen_lshrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, SImode, operand1, operand2)); -} - -rtx -gen_lshrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, HImode, operand1, operand2)); -} - -rtx -gen_lshrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (LSHIFTRT, QImode, operand1, operand2)); -} - -rtx -gen_rotlsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, SImode, operand1, operand2)); -} - -rtx -gen_rotlhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, HImode, operand1, operand2)); -} - -rtx -gen_rotlqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATE, QImode, operand1, operand2)); -} - -rtx -gen_rotrsi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, SImode, operand1, operand2)); -} - -rtx -gen_rotrhi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, HImode, operand1, operand2)); -} - -rtx -gen_rotrqi3 (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - return gen_rtx (SET, VOIDmode, operand0, gen_rtx (ROTATERT, QImode, operand1, operand2)); -} - -rtx -gen_seq (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_IEEE_FP - && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) - operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); - else - operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (EQ, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sne (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_IEEE_FP - && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) - operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); - else - operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (NE, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sgt (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (GT, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sgtu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (GTU, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_slt (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (LT, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sltu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (LTU, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sge (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (GE, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sgeu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (GEU, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sle (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (LE, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_sleu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (LEU, QImode, cc0_rtx, const0_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_beq (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_IEEE_FP - && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) - operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); - else - operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (EQ, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bne (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - -{ - if (TARGET_IEEE_FP - && GET_MODE_CLASS (GET_MODE (i386_compare_op0)) == MODE_FLOAT) - operands[1] = (*i386_compare_gen_eq)(i386_compare_op0, i386_compare_op1); - else - operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (NE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bgt (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GT, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bgtu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GTU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_blt (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LT, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bltu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LTU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bge (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bgeu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GEU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_ble (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LE, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_bleu (operand0) - rtx operand0; -{ - rtx operand1; - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; -operands[1] = (*i386_compare_gen)(i386_compare_op0, i386_compare_op1); - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand1); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (LEU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand0), pc_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_jump (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (LABEL_REF, VOIDmode, operand0)); -} - -rtx -gen_indirect_jump (operand0) - rtx operand0; -{ - return gen_rtx (SET, VOIDmode, pc_rtx, operand0); -} - -rtx -gen_casesi (operand0, operand1, operand2, operand3, operand4) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; - rtx operand4; -{ - rtx operand5; - rtx operands[6]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - operands[4] = operand4; - -{ - operands[5] = gen_reg_rtx (SImode); - current_function_uses_pic_offset_table = 1; -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - emit_insn (gen_rtx (SET, VOIDmode, operand5, gen_rtx (MINUS, SImode, operand0, operand1))); - emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, gen_rtx (COMPARE, CCmode, operand5, operand2))); - emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (IF_THEN_ELSE, VOIDmode, gen_rtx (GTU, VOIDmode, cc0_rtx, const0_rtx), gen_rtx (LABEL_REF, VOIDmode, operand4), pc_rtx))); - emit_jump_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, pc_rtx, gen_rtx (MINUS, SImode, gen_rtx (REG, SImode, 3), gen_rtx (MEM, SImode, gen_rtx (PLUS, SImode, gen_rtx (MULT, SImode, operand5, GEN_INT (4)), gen_rtx (LABEL_REF, VOIDmode, operand3))))), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_tablejump (operand0, operand1) - rtx operand0; - rtx operand1; -{ - return gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, pc_rtx, operand0), - gen_rtx (USE, VOIDmode, gen_rtx (LABEL_REF, VOIDmode, operand1)))); -} - -rtx -gen_call_pop (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - rtx operands[4]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - -{ - rtx addr; - - if (flag_pic) - current_function_uses_pic_offset_table = 1; - - /* With half-pic, force the address into a register. */ - addr = XEXP (operands[0], 0); - if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) - XEXP (operands[0], 0) = force_reg (Pmode, addr); - - if (! expander_call_insn_operand (operands[0], QImode)) - operands[0] - = change_address (operands[0], VOIDmode, - copy_to_mode_reg (Pmode, XEXP (operands[0], 0))); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - emit_call_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (CALL, VOIDmode, operand0, operand1), - gen_rtx (SET, VOIDmode, gen_rtx (REG, SImode, 7), gen_rtx (PLUS, SImode, gen_rtx (REG, SImode, 7), operand3))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_call (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - rtx addr; - - if (flag_pic) - current_function_uses_pic_offset_table = 1; - - /* With half-pic, force the address into a register. */ - addr = XEXP (operands[0], 0); - if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) - XEXP (operands[0], 0) = force_reg (Pmode, addr); - - if (! expander_call_insn_operand (operands[0], QImode)) - operands[0] - = change_address (operands[0], VOIDmode, - copy_to_mode_reg (Pmode, XEXP (operands[0], 0))); -} - operand0 = operands[0]; - operand1 = operands[1]; - emit_call_insn (gen_rtx (CALL, VOIDmode, operand0, operand1)); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_call_value_pop (operand0, operand1, operand2, operand3, operand4) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; - rtx operand4; -{ - rtx operands[5]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - operands[4] = operand4; - -{ - rtx addr; - - if (flag_pic) - current_function_uses_pic_offset_table = 1; - - /* With half-pic, force the address into a register. */ - addr = XEXP (operands[1], 0); - if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) - XEXP (operands[1], 0) = force_reg (Pmode, addr); - - if (! expander_call_insn_operand (operands[1], QImode)) - operands[1] - = change_address (operands[1], VOIDmode, - copy_to_mode_reg (Pmode, XEXP (operands[1], 0))); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - emit_call_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (CALL, VOIDmode, operand1, operand2)), - gen_rtx (SET, VOIDmode, gen_rtx (REG, SImode, 7), gen_rtx (PLUS, SImode, gen_rtx (REG, SImode, 7), operand4))))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_call_value (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - rtx addr; - - if (flag_pic) - current_function_uses_pic_offset_table = 1; - - /* With half-pic, force the address into a register. */ - addr = XEXP (operands[1], 0); - if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) - XEXP (operands[1], 0) = force_reg (Pmode, addr); - - if (! expander_call_insn_operand (operands[1], QImode)) - operands[1] - = change_address (operands[1], VOIDmode, - copy_to_mode_reg (Pmode, XEXP (operands[1], 0))); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_call_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (CALL, VOIDmode, operand1, operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_untyped_call (operand0, operand1, operand2) - rtx operand0; - rtx operand1; - rtx operand2; -{ - rtx operands[3]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - -{ - rtx addr; - - if (flag_pic) - current_function_uses_pic_offset_table = 1; - - /* With half-pic, force the address into a register. */ - addr = XEXP (operands[0], 0); - if (GET_CODE (addr) != REG && HALF_PIC_P () && !CONSTANT_ADDRESS_P (addr)) - XEXP (operands[0], 0) = force_reg (Pmode, addr); - - operands[1] = change_address (operands[1], DImode, XEXP (operands[1], 0)); - if (! expander_call_insn_operand (operands[1], QImode)) - operands[1] - = change_address (operands[1], VOIDmode, - copy_to_mode_reg (Pmode, XEXP (operands[1], 0))); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - emit_call_insn (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (3, - gen_rtx (CALL, VOIDmode, operand0, const0_rtx), - operand1, - operand2))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_untyped_return (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operands[2]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - -{ - rtx valreg1 = gen_rtx (REG, SImode, 0); - rtx valreg2 = gen_rtx (REG, SImode, 1); - rtx result = operands[0]; - - /* Restore the FPU state. */ - emit_insn (gen_update_return (change_address (result, SImode, - plus_constant (XEXP (result, 0), - 8)))); - - /* Reload the function value registers. */ - emit_move_insn (valreg1, change_address (result, SImode, XEXP (result, 0))); - emit_move_insn (valreg2, - change_address (result, SImode, - plus_constant (XEXP (result, 0), 4))); - - /* Put USE insns before the return. */ - emit_insn (gen_rtx (USE, VOIDmode, valreg1)); - emit_insn (gen_rtx (USE, VOIDmode, valreg2)); - - /* Construct the return. */ - expand_null_return (); - - DONE; -} - operand0 = operands[0]; - operand1 = operands[1]; - emit (operand0); - emit (operand1); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_update_return (operand0) - rtx operand0; -{ - return gen_rtx (UNSPEC, SImode, gen_rtvec (1, - operand0), 0); -} - -rtx -gen_return () -{ - return gen_rtx (RETURN, VOIDmode); -} - -rtx -gen_nop () -{ - return const0_rtx; -} - -rtx -gen_movstrsi (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - rtx operand4; - rtx operand5; - rtx operand6; - rtx operands[7]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - -{ - rtx addr0, addr1; - - if (GET_CODE (operands[2]) != CONST_INT) - FAIL; - - addr0 = copy_to_mode_reg (Pmode, XEXP (operands[0], 0)); - addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0)); - - operands[5] = addr0; - operands[6] = addr1; - - operands[0] = gen_rtx (MEM, BLKmode, addr0); - operands[1] = gen_rtx (MEM, BLKmode, addr1); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - operand6 = operands[6]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (6, - gen_rtx (SET, VOIDmode, operand0, operand1), - gen_rtx (USE, VOIDmode, operand2), - gen_rtx (USE, VOIDmode, operand3), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)), - gen_rtx (CLOBBER, VOIDmode, operand5), - gen_rtx (CLOBBER, VOIDmode, operand6)))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_cmpstrsi (operand0, operand1, operand2, operand3, operand4) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; - rtx operand4; -{ - rtx operand5; - rtx operand6; - rtx operands[7]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - operands[4] = operand4; - -{ - rtx addr1, addr2; - - addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0)); - addr2 = copy_to_mode_reg (Pmode, XEXP (operands[2], 0)); - operands[3] = copy_to_mode_reg (SImode, operands[3]); - - operands[5] = addr1; - operands[6] = addr2; - - operands[1] = gen_rtx (MEM, BLKmode, addr1); - operands[2] = gen_rtx (MEM, BLKmode, addr2); - -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - operand6 = operands[6]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (6, - gen_rtx (SET, VOIDmode, operand0, gen_rtx (COMPARE, SImode, operand1, operand2)), - gen_rtx (USE, VOIDmode, operand3), - gen_rtx (USE, VOIDmode, operand4), - gen_rtx (CLOBBER, VOIDmode, operand5), - gen_rtx (CLOBBER, VOIDmode, operand6), - gen_rtx (CLOBBER, VOIDmode, operand3)))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_ffssi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operands[4]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; -operands[3] = gen_reg_rtx (SImode); - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand3, gen_rtx (PLUS, SImode, gen_rtx (FFS, SImode, operand1), constm1_rtx)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0))))); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, SImode, operand3, const1_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_ffshi2 (operand0, operand1) - rtx operand0; - rtx operand1; -{ - rtx operand2; - rtx operand3; - rtx operands[4]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; -operands[3] = gen_reg_rtx (HImode); - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand3, gen_rtx (PLUS, HImode, gen_rtx (FFS, HImode, operand1), constm1_rtx)), - gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0))))); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (PLUS, HImode, operand3, const1_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - -rtx -gen_strlensi (operand0, operand1, operand2, operand3) - rtx operand0; - rtx operand1; - rtx operand2; - rtx operand3; -{ - rtx operand4; - rtx operand5; - rtx operands[6]; - rtx _val = 0; - start_sequence (); - operands[0] = operand0; - operands[1] = operand1; - operands[2] = operand2; - operands[3] = operand3; - -{ - operands[1] = copy_to_mode_reg (SImode, XEXP (operands[1], 0)); - operands[4] = gen_reg_rtx (SImode); - operands[5] = gen_reg_rtx (SImode); -} - operand0 = operands[0]; - operand1 = operands[1]; - operand2 = operands[2]; - operand3 = operands[3]; - operand4 = operands[4]; - operand5 = operands[5]; - emit (gen_rtx (PARALLEL, VOIDmode, gen_rtvec (2, - gen_rtx (SET, VOIDmode, operand4, gen_rtx (UNSPEC, SImode, gen_rtvec (3, - gen_rtx (MEM, BLKmode, operand1), - operand2, - operand3), 0)), - gen_rtx (CLOBBER, VOIDmode, operand1)))); - emit_insn (gen_rtx (SET, VOIDmode, operand5, gen_rtx (NOT, SImode, operand4))); - emit_insn (gen_rtx (SET, VOIDmode, operand0, gen_rtx (MINUS, SImode, operand5, const1_rtx))); - _done: - _val = gen_sequence (); - _fail: - end_sequence (); - return _val; -} - - - -void -add_clobbers (pattern, insn_code_number) - rtx pattern; - int insn_code_number; -{ - int i; - - switch (insn_code_number) - { - case 250: - case 223: - XVECEXP (pattern, 0, 1) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - break; - - case 72: - case 71: - XVECEXP (pattern, 0, 3) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - break; - - case 68: - case 67: - XVECEXP (pattern, 0, 4) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, SImode, 0)); - break; - - case 252: - case 25: - case 24: - case 23: - case 22: - case 21: - case 20: - case 19: - case 18: - case 17: - case 16: - case 8: - case 6: - XVECEXP (pattern, 0, 1) = gen_rtx (CLOBBER, VOIDmode, gen_rtx (SCRATCH, HImode, 0)); - break; - - default: - abort (); - } -} - -void -init_mov_optab () -{ -#ifdef HAVE_movccfpeq - if (HAVE_movccfpeq) - mov_optab->handlers[(int) CCFPEQmode].insn_code = CODE_FOR_movccfpeq; -#endif -} diff --git a/gnu/usr.bin/gcc2/i386/insn-extract.c b/gnu/usr.bin/gcc2/i386/insn-extract.c deleted file mode 100644 index 64fbf42c177f..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-extract.c +++ /dev/null @@ -1,509 +0,0 @@ -/* Generated automatically by the program `genextract' -from the machine description file `md'. */ - -#ifndef lint -static char rcsid[] = "$Id: insn-extract.c,v 1.2 1993/08/02 17:37:01 mycroft Exp $"; -#endif /* not lint */ - -#include "config.h" -#include "rtl.h" - -static rtx junk; -extern rtx recog_operand[]; -extern rtx *recog_operand_loc[]; -extern rtx *recog_dup_loc[]; -extern char recog_dup_num[]; -extern -#ifdef __GNUC__ -__volatile__ -#endif -void fatal_insn_not_found (); - -void -insn_extract (insn) - rtx insn; -{ - register rtx *ro = recog_operand; - register rtx **ro_loc = recog_operand_loc; - rtx pat = PATTERN (insn); - switch (INSN_CODE (insn)) - { - case -1: - fatal_insn_not_found (insn); - - case 262: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0, 0), 0)); - ro[2] = *(ro_loc[2] = &XVECEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0, 1)); - ro[3] = *(ro_loc[3] = &XVECEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0, 2)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 1; - break; - - case 260: - case 257: - case 256: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (pat, 1)); - break; - - case 259: - case 255: - case 254: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (pat, 1)); - break; - - case 258: - case 253: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (pat, 1)); - break; - - case 252: - case 250: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 248: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 2), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 5), 0); - recog_dup_num[0] = 2; - recog_dup_loc[1] = &XEXP (XVECEXP (pat, 0, 4), 0); - recog_dup_num[1] = 1; - recog_dup_loc[2] = &XEXP (XVECEXP (pat, 0, 3), 0); - recog_dup_num[2] = 0; - break; - - case 247: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - ro[4] = *(ro_loc[4] = &XEXP (XVECEXP (pat, 0, 2), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 5), 0); - recog_dup_num[0] = 3; - recog_dup_loc[1] = &XEXP (XVECEXP (pat, 0, 4), 0); - recog_dup_num[1] = 2; - recog_dup_loc[2] = &XEXP (XVECEXP (pat, 0, 3), 0); - recog_dup_num[2] = 1; - break; - - case 245: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 2), 0)); - ro[4] = *(ro_loc[4] = &XEXP (XVECEXP (pat, 0, 3), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 5), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XVECEXP (pat, 0, 4), 0); - recog_dup_num[1] = 0; - break; - - case 243: - case 242: - break; - - case 241: - ro[0] = *(ro_loc[0] = &XVECEXP (pat, 0, 0)); - break; - - case 239: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 0), 0)); - ro[1] = *(ro_loc[1] = &XVECEXP (pat, 0, 1)); - ro[2] = *(ro_loc[2] = &XVECEXP (pat, 0, 2)); - break; - - case 238: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XVECEXP (pat, 0, 1)); - ro[2] = *(ro_loc[2] = &XVECEXP (pat, 0, 2)); - break; - - case 236: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 233: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = const0_rtx; - ro_loc[3] = &junk; - ro[4] = *(ro_loc[4] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1)); - break; - - case 232: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = const0_rtx; - ro_loc[3] = &junk; - ro[4] = *(ro_loc[4] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1)); - break; - - case 227: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[2] = const0_rtx; - ro_loc[2] = &junk; - ro[3] = *(ro_loc[3] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1)); - break; - - case 226: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[2] = const0_rtx; - ro_loc[2] = &junk; - ro[3] = *(ro_loc[3] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1)); - break; - - case 224: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 0), 0)); - break; - - case 223: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 220: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - break; - - case 219: - case 218: - case 217: - case 216: - case 215: - case 214: - case 213: - case 212: - case 211: - case 210: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (pat, 1), 2), 0)); - break; - - case 209: - case 207: - case 205: - case 203: - case 201: - case 199: - case 197: - case 195: - case 193: - case 191: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - break; - - case 189: - case 187: - case 185: - case 183: - case 181: - case 179: - case 177: - case 175: - case 173: - case 171: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - break; - - case 169: - case 168: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 2)); - break; - - case 167: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 2)); - break; - - case 166: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 1)); - break; - - case 165: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 164: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = const0_rtx; - ro_loc[1] = &junk; - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 0), 2)); - ro[3] = *(ro_loc[3] = &XEXP (pat, 1)); - break; - - case 154: - case 148: - case 142: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 2; - break; - - case 136: - case 133: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (XEXP (pat, 1), 0, 0), 0)); - break; - - case 135: - case 134: - case 132: - case 131: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XVECEXP (XEXP (pat, 1), 0, 0)); - break; - - case 130: - case 127: - case 124: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - break; - - case 108: - case 107: - case 106: - case 105: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - recog_dup_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 1), 1), 1); - recog_dup_num[1] = 2; - break; - - case 98: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (pat, 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (XEXP (pat, 1), 1), 0)); - break; - - case 235: - case 163: - case 162: - case 161: - case 160: - case 159: - case 158: - case 157: - case 156: - case 155: - case 153: - case 151: - case 150: - case 149: - case 147: - case 145: - case 144: - case 143: - case 141: - case 117: - case 116: - case 115: - case 114: - case 113: - case 112: - case 111: - case 110: - case 109: - case 102: - case 101: - case 97: - case 96: - case 95: - case 94: - case 91: - case 90: - case 89: - case 88: - case 84: - case 83: - case 82: - case 81: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 72: - case 71: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 2), 0)); - ro[4] = *(ro_loc[4] = &XEXP (XVECEXP (pat, 0, 3), 0)); - break; - - case 68: - case 67: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 2), 0)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 3), 0)); - ro[4] = *(ro_loc[4] = &XEXP (XVECEXP (pat, 0, 4), 0)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 1; - break; - - case 62: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 139: - case 138: - case 137: - case 129: - case 128: - case 126: - case 125: - case 123: - case 122: - case 121: - case 120: - case 119: - case 118: - case 80: - case 79: - case 78: - case 77: - case 60: - case 59: - case 58: - case 57: - case 56: - case 55: - case 54: - case 53: - case 52: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 0)); - break; - - case 48: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (pat, 0, 0), 1)); - recog_dup_loc[0] = &XEXP (XVECEXP (pat, 0, 1), 0); - recog_dup_num[0] = 1; - recog_dup_loc[1] = &XEXP (XVECEXP (pat, 0, 1), 1); - recog_dup_num[1] = 0; - break; - - case 230: - case 44: - case 41: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (pat, 1)); - break; - - case 229: - case 85: - case 51: - case 50: - case 49: - case 47: - case 46: - case 45: - case 43: - case 42: - case 40: - case 39: - case 38: - case 36: - case 35: - ro[0] = *(ro_loc[0] = &XEXP (pat, 0)); - ro[1] = *(ro_loc[1] = &XEXP (pat, 1)); - break; - - case 25: - case 21: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 24: - case 20: - case 18: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 23: - case 19: - case 17: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1), 0)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 22: - case 16: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (XVECEXP (pat, 0, 0), 1), 1)); - ro[2] = *(ro_loc[2] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[3] = *(ro_loc[3] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 34: - case 33: - case 32: - case 14: - case 12: - case 10: - ro[0] = *(ro_loc[0] = &XEXP (XEXP (pat, 1), 0)); - ro[1] = *(ro_loc[1] = &XEXP (XEXP (pat, 1), 1)); - break; - - case 8: - case 6: - ro[0] = *(ro_loc[0] = &XEXP (XVECEXP (pat, 0, 0), 1)); - ro[1] = *(ro_loc[1] = &XEXP (XVECEXP (pat, 0, 1), 0)); - break; - - case 221: - case 4: - case 2: - case 0: - ro[0] = *(ro_loc[0] = &XEXP (pat, 1)); - break; - - default: - abort (); - } -} diff --git a/gnu/usr.bin/gcc2/i386/insn-flags.h b/gnu/usr.bin/gcc2/i386/insn-flags.h deleted file mode 100644 index 2372355e218c..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-flags.h +++ /dev/null @@ -1,513 +0,0 @@ -/* Generated automatically by the program `genflags' -from the machine description file `md'. - - $Id: insn-flags.h,v 1.3 1993/08/23 05:00:18 cgd Exp $ -*/ - -#define HAVE_tstsi_1 1 -#define HAVE_tstsi 1 -#define HAVE_tsthi_1 1 -#define HAVE_tsthi 1 -#define HAVE_tstqi_1 1 -#define HAVE_tstqi 1 -#define HAVE_tstsf_cc (TARGET_80387 && ! TARGET_IEEE_FP) -#define HAVE_tstsf (TARGET_80387 && ! TARGET_IEEE_FP) -#define HAVE_tstdf_cc (TARGET_80387 && ! TARGET_IEEE_FP) -#define HAVE_tstdf (TARGET_80387 && ! TARGET_IEEE_FP) -#define HAVE_cmpsi_1 (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) -#define HAVE_cmpsi 1 -#define HAVE_cmphi_1 (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) -#define HAVE_cmphi 1 -#define HAVE_cmpqi_1 (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) -#define HAVE_cmpqi 1 -#define HAVE_cmpsf_cc_1 (TARGET_80387 \ - && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)) -#define HAVE_cmpdf (TARGET_80387) -#define HAVE_cmpsf (TARGET_80387) -#define HAVE_cmpdf_cc (TARGET_80387) -#define HAVE_cmpdf_ccfpeq (TARGET_80387) -#define HAVE_cmpsf_cc (TARGET_80387) -#define HAVE_cmpsf_ccfpeq (TARGET_80387) -#define HAVE_movsi 1 -#define HAVE_movhi 1 -#define HAVE_movstricthi 1 -#define HAVE_movqi 1 -#define HAVE_movstrictqi 1 -#define HAVE_movsf 1 -#define HAVE_swapdf 1 -#define HAVE_movdf 1 -#define HAVE_movdi 1 -#define HAVE_zero_extendhisi2 1 -#define HAVE_zero_extendqihi2 1 -#define HAVE_zero_extendqisi2 1 -#define HAVE_zero_extendsidi2 1 -#define HAVE_extendsidi2 1 -#define HAVE_extendhisi2 1 -#define HAVE_extendqihi2 1 -#define HAVE_extendqisi2 1 -#define HAVE_extendsfdf2 (TARGET_80387) -#define HAVE_truncdfsf2 (TARGET_80387) -#define HAVE_fixuns_truncdfsi2 (TARGET_80387) -#define HAVE_fixuns_truncsfsi2 (TARGET_80387) -#define HAVE_fix_truncdfdi2 (TARGET_80387) -#define HAVE_fix_truncsfdi2 (TARGET_80387) -#define HAVE_fix_truncdfsi2 (TARGET_80387) -#define HAVE_fix_truncsfsi2 (TARGET_80387) -#define HAVE_floatsisf2 (TARGET_80387) -#define HAVE_floatdisf2 (TARGET_80387) -#define HAVE_floatsidf2 (TARGET_80387) -#define HAVE_floatdidf2 (TARGET_80387) -#define HAVE_adddi3 1 -#define HAVE_addsi3 1 -#define HAVE_addhi3 1 -#define HAVE_addqi3 1 -#define HAVE_adddf3 (TARGET_80387) -#define HAVE_addsf3 (TARGET_80387) -#define HAVE_subdi3 1 -#define HAVE_subsi3 1 -#define HAVE_subhi3 1 -#define HAVE_subqi3 1 -#define HAVE_subdf3 (TARGET_80387) -#define HAVE_subsf3 (TARGET_80387) -#define HAVE_mulhi3 1 -#define HAVE_mulsi3 1 -#define HAVE_muldf3 (TARGET_80387) -#define HAVE_mulsf3 (TARGET_80387) -#define HAVE_divqi3 1 -#define HAVE_udivqi3 1 -#define HAVE_divdf3 (TARGET_80387) -#define HAVE_divsf3 (TARGET_80387) -#define HAVE_divmodsi4 1 -#define HAVE_divmodhi4 1 -#define HAVE_udivmodsi4 1 -#define HAVE_udivmodhi4 1 -#define HAVE_andsi3 1 -#define HAVE_andhi3 1 -#define HAVE_andqi3 1 -#define HAVE_iorsi3 1 -#define HAVE_iorhi3 1 -#define HAVE_iorqi3 1 -#define HAVE_xorsi3 1 -#define HAVE_xorhi3 1 -#define HAVE_xorqi3 1 -#define HAVE_negdi2 1 -#define HAVE_negsi2 1 -#define HAVE_neghi2 1 -#define HAVE_negqi2 1 -#define HAVE_negsf2 (TARGET_80387) -#define HAVE_negdf2 (TARGET_80387) -#define HAVE_abssf2 (TARGET_80387) -#define HAVE_absdf2 (TARGET_80387) -#define HAVE_sqrtsf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math) && WORKING_FPE) -#define HAVE_sqrtdf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math) && WORKING_FPE) -#define HAVE_sindf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math) && WORKING_FPE) -#define HAVE_sinsf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math) && WORKING_FPE) -#define HAVE_cosdf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math) && WORKING_FPE) -#define HAVE_cossf2 (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math) && WORKING_FPE) -#define HAVE_one_cmplsi2 1 -#define HAVE_one_cmplhi2 1 -#define HAVE_one_cmplqi2 1 -#define HAVE_ashldi3 1 -#define HAVE_ashldi3_const_int 1 -#define HAVE_ashldi3_non_const_int 1 -#define HAVE_ashlsi3 1 -#define HAVE_ashlhi3 1 -#define HAVE_ashlqi3 1 -#define HAVE_ashrdi3 1 -#define HAVE_ashrdi3_const_int 1 -#define HAVE_ashrdi3_non_const_int 1 -#define HAVE_ashrsi3 1 -#define HAVE_ashrhi3 1 -#define HAVE_ashrqi3 1 -#define HAVE_lshrdi3 1 -#define HAVE_lshrdi3_const_int 1 -#define HAVE_lshrdi3_non_const_int 1 -#define HAVE_lshrsi3 1 -#define HAVE_lshrhi3 1 -#define HAVE_lshrqi3 1 -#define HAVE_rotlsi3 1 -#define HAVE_rotlhi3 1 -#define HAVE_rotlqi3 1 -#define HAVE_rotrsi3 1 -#define HAVE_rotrhi3 1 -#define HAVE_rotrqi3 1 -#define HAVE_seq 1 -#define HAVE_sne 1 -#define HAVE_sgt 1 -#define HAVE_sgtu 1 -#define HAVE_slt 1 -#define HAVE_sltu 1 -#define HAVE_sge 1 -#define HAVE_sgeu 1 -#define HAVE_sle 1 -#define HAVE_sleu 1 -#define HAVE_beq 1 -#define HAVE_bne 1 -#define HAVE_bgt 1 -#define HAVE_bgtu 1 -#define HAVE_blt 1 -#define HAVE_bltu 1 -#define HAVE_bge 1 -#define HAVE_bgeu 1 -#define HAVE_ble 1 -#define HAVE_bleu 1 -#define HAVE_jump 1 -#define HAVE_indirect_jump 1 -#define HAVE_casesi (flag_pic) -#define HAVE_tablejump 1 -#define HAVE_call_pop 1 -#define HAVE_call 1 -#define HAVE_call_value_pop 1 -#define HAVE_call_value 1 -#define HAVE_untyped_call 1 -#define HAVE_untyped_return 1 -#define HAVE_update_return 1 -#define HAVE_return (simple_386_epilogue ()) -#define HAVE_nop 1 -#define HAVE_movstrsi 1 -#define HAVE_cmpstrsi 1 -#define HAVE_ffssi2 1 -#define HAVE_ffshi2 1 -#define HAVE_strlensi 1 - -#ifndef NO_MD_PROTOTYPES -extern rtx gen_tstsi_1 PROTO((rtx)); -extern rtx gen_tstsi PROTO((rtx)); -extern rtx gen_tsthi_1 PROTO((rtx)); -extern rtx gen_tsthi PROTO((rtx)); -extern rtx gen_tstqi_1 PROTO((rtx)); -extern rtx gen_tstqi PROTO((rtx)); -extern rtx gen_tstsf_cc PROTO((rtx)); -extern rtx gen_tstsf PROTO((rtx)); -extern rtx gen_tstdf_cc PROTO((rtx)); -extern rtx gen_tstdf PROTO((rtx)); -extern rtx gen_cmpsi_1 PROTO((rtx, rtx)); -extern rtx gen_cmpsi PROTO((rtx, rtx)); -extern rtx gen_cmphi_1 PROTO((rtx, rtx)); -extern rtx gen_cmphi PROTO((rtx, rtx)); -extern rtx gen_cmpqi_1 PROTO((rtx, rtx)); -extern rtx gen_cmpqi PROTO((rtx, rtx)); -extern rtx gen_cmpsf_cc_1 PROTO((rtx, rtx, rtx)); -extern rtx gen_cmpdf PROTO((rtx, rtx)); -extern rtx gen_cmpsf PROTO((rtx, rtx)); -extern rtx gen_cmpdf_cc PROTO((rtx, rtx)); -extern rtx gen_cmpdf_ccfpeq PROTO((rtx, rtx)); -extern rtx gen_cmpsf_cc PROTO((rtx, rtx)); -extern rtx gen_cmpsf_ccfpeq PROTO((rtx, rtx)); -extern rtx gen_movsi PROTO((rtx, rtx)); -extern rtx gen_movhi PROTO((rtx, rtx)); -extern rtx gen_movstricthi PROTO((rtx, rtx)); -extern rtx gen_movqi PROTO((rtx, rtx)); -extern rtx gen_movstrictqi PROTO((rtx, rtx)); -extern rtx gen_movsf PROTO((rtx, rtx)); -extern rtx gen_swapdf PROTO((rtx, rtx)); -extern rtx gen_movdf PROTO((rtx, rtx)); -extern rtx gen_movdi PROTO((rtx, rtx)); -extern rtx gen_zero_extendhisi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendqihi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendqisi2 PROTO((rtx, rtx)); -extern rtx gen_zero_extendsidi2 PROTO((rtx, rtx)); -extern rtx gen_extendsidi2 PROTO((rtx, rtx)); -extern rtx gen_extendhisi2 PROTO((rtx, rtx)); -extern rtx gen_extendqihi2 PROTO((rtx, rtx)); -extern rtx gen_extendqisi2 PROTO((rtx, rtx)); -extern rtx gen_extendsfdf2 PROTO((rtx, rtx)); -extern rtx gen_truncdfsf2 PROTO((rtx, rtx)); -extern rtx gen_fixuns_truncdfsi2 PROTO((rtx, rtx)); -extern rtx gen_fixuns_truncsfsi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncdfdi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncsfdi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncdfsi2 PROTO((rtx, rtx)); -extern rtx gen_fix_truncsfsi2 PROTO((rtx, rtx)); -extern rtx gen_floatsisf2 PROTO((rtx, rtx)); -extern rtx gen_floatdisf2 PROTO((rtx, rtx)); -extern rtx gen_floatsidf2 PROTO((rtx, rtx)); -extern rtx gen_floatdidf2 PROTO((rtx, rtx)); -extern rtx gen_adddi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_adddf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_addsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subdi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subdf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_subsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_muldf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_mulsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_udivqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divdf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divsf3 PROTO((rtx, rtx, rtx)); -extern rtx gen_divmodsi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_divmodhi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_udivmodsi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_udivmodhi4 PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_andsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_andhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_andqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_iorqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_xorqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_negdi2 PROTO((rtx, rtx)); -extern rtx gen_negsi2 PROTO((rtx, rtx)); -extern rtx gen_neghi2 PROTO((rtx, rtx)); -extern rtx gen_negqi2 PROTO((rtx, rtx)); -extern rtx gen_negsf2 PROTO((rtx, rtx)); -extern rtx gen_negdf2 PROTO((rtx, rtx)); -extern rtx gen_abssf2 PROTO((rtx, rtx)); -extern rtx gen_absdf2 PROTO((rtx, rtx)); -extern rtx gen_sqrtsf2 PROTO((rtx, rtx)); -extern rtx gen_sqrtdf2 PROTO((rtx, rtx)); -extern rtx gen_sindf2 PROTO((rtx, rtx)); -extern rtx gen_sinsf2 PROTO((rtx, rtx)); -extern rtx gen_cosdf2 PROTO((rtx, rtx)); -extern rtx gen_cossf2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplsi2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplhi2 PROTO((rtx, rtx)); -extern rtx gen_one_cmplqi2 PROTO((rtx, rtx)); -extern rtx gen_ashldi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashldi3_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_ashldi3_non_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_ashlsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashlhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashlqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrdi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrdi3_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrdi3_non_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_ashrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrdi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrdi3_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrdi3_non_const_int PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_lshrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotlqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrsi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrhi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_rotrqi3 PROTO((rtx, rtx, rtx)); -extern rtx gen_seq PROTO((rtx)); -extern rtx gen_sne PROTO((rtx)); -extern rtx gen_sgt PROTO((rtx)); -extern rtx gen_sgtu PROTO((rtx)); -extern rtx gen_slt PROTO((rtx)); -extern rtx gen_sltu PROTO((rtx)); -extern rtx gen_sge PROTO((rtx)); -extern rtx gen_sgeu PROTO((rtx)); -extern rtx gen_sle PROTO((rtx)); -extern rtx gen_sleu PROTO((rtx)); -extern rtx gen_beq PROTO((rtx)); -extern rtx gen_bne PROTO((rtx)); -extern rtx gen_bgt PROTO((rtx)); -extern rtx gen_bgtu PROTO((rtx)); -extern rtx gen_blt PROTO((rtx)); -extern rtx gen_bltu PROTO((rtx)); -extern rtx gen_bge PROTO((rtx)); -extern rtx gen_bgeu PROTO((rtx)); -extern rtx gen_ble PROTO((rtx)); -extern rtx gen_bleu PROTO((rtx)); -extern rtx gen_jump PROTO((rtx)); -extern rtx gen_indirect_jump PROTO((rtx)); -extern rtx gen_casesi PROTO((rtx, rtx, rtx, rtx, rtx)); -extern rtx gen_tablejump PROTO((rtx, rtx)); -extern rtx gen_untyped_call PROTO((rtx, rtx, rtx)); -extern rtx gen_untyped_return PROTO((rtx, rtx)); -extern rtx gen_update_return PROTO((rtx)); -extern rtx gen_return PROTO((void)); -extern rtx gen_nop PROTO((void)); -extern rtx gen_movstrsi PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_cmpstrsi PROTO((rtx, rtx, rtx, rtx, rtx)); -extern rtx gen_ffssi2 PROTO((rtx, rtx)); -extern rtx gen_ffshi2 PROTO((rtx, rtx)); -extern rtx gen_strlensi PROTO((rtx, rtx, rtx, rtx)); - -#ifdef MD_CALL_PROTOTYPES -extern rtx gen_call_pop PROTO((rtx, rtx, rtx)); -extern rtx gen_call PROTO((rtx, rtx)); -extern rtx gen_call_value_pop PROTO((rtx, rtx, rtx, rtx)); -extern rtx gen_call_value PROTO((rtx, rtx, rtx)); - -#else /* !MD_CALL_PROTOTYPES */ -extern rtx gen_call_pop (); -extern rtx gen_call (); -extern rtx gen_call_value_pop (); -extern rtx gen_call_value (); -#endif /* !MD_CALL_PROTOTYPES */ - -#else /* NO_MD_PROTOTYPES */ -extern rtx gen_tstsi_1 (); -extern rtx gen_tstsi (); -extern rtx gen_tsthi_1 (); -extern rtx gen_tsthi (); -extern rtx gen_tstqi_1 (); -extern rtx gen_tstqi (); -extern rtx gen_tstsf_cc (); -extern rtx gen_tstsf (); -extern rtx gen_tstdf_cc (); -extern rtx gen_tstdf (); -extern rtx gen_cmpsi_1 (); -extern rtx gen_cmpsi (); -extern rtx gen_cmphi_1 (); -extern rtx gen_cmphi (); -extern rtx gen_cmpqi_1 (); -extern rtx gen_cmpqi (); -extern rtx gen_cmpsf_cc_1 (); -extern rtx gen_cmpdf (); -extern rtx gen_cmpsf (); -extern rtx gen_cmpdf_cc (); -extern rtx gen_cmpdf_ccfpeq (); -extern rtx gen_cmpsf_cc (); -extern rtx gen_cmpsf_ccfpeq (); -extern rtx gen_movsi (); -extern rtx gen_movhi (); -extern rtx gen_movstricthi (); -extern rtx gen_movqi (); -extern rtx gen_movstrictqi (); -extern rtx gen_movsf (); -extern rtx gen_swapdf (); -extern rtx gen_movdf (); -extern rtx gen_movdi (); -extern rtx gen_zero_extendhisi2 (); -extern rtx gen_zero_extendqihi2 (); -extern rtx gen_zero_extendqisi2 (); -extern rtx gen_zero_extendsidi2 (); -extern rtx gen_extendsidi2 (); -extern rtx gen_extendhisi2 (); -extern rtx gen_extendqihi2 (); -extern rtx gen_extendqisi2 (); -extern rtx gen_extendsfdf2 (); -extern rtx gen_truncdfsf2 (); -extern rtx gen_fixuns_truncdfsi2 (); -extern rtx gen_fixuns_truncsfsi2 (); -extern rtx gen_fix_truncdfdi2 (); -extern rtx gen_fix_truncsfdi2 (); -extern rtx gen_fix_truncdfsi2 (); -extern rtx gen_fix_truncsfsi2 (); -extern rtx gen_floatsisf2 (); -extern rtx gen_floatdisf2 (); -extern rtx gen_floatsidf2 (); -extern rtx gen_floatdidf2 (); -extern rtx gen_adddi3 (); -extern rtx gen_addsi3 (); -extern rtx gen_addhi3 (); -extern rtx gen_addqi3 (); -extern rtx gen_adddf3 (); -extern rtx gen_addsf3 (); -extern rtx gen_subdi3 (); -extern rtx gen_subsi3 (); -extern rtx gen_subhi3 (); -extern rtx gen_subqi3 (); -extern rtx gen_subdf3 (); -extern rtx gen_subsf3 (); -extern rtx gen_mulhi3 (); -extern rtx gen_mulsi3 (); -extern rtx gen_muldf3 (); -extern rtx gen_mulsf3 (); -extern rtx gen_divqi3 (); -extern rtx gen_udivqi3 (); -extern rtx gen_divdf3 (); -extern rtx gen_divsf3 (); -extern rtx gen_divmodsi4 (); -extern rtx gen_divmodhi4 (); -extern rtx gen_udivmodsi4 (); -extern rtx gen_udivmodhi4 (); -extern rtx gen_andsi3 (); -extern rtx gen_andhi3 (); -extern rtx gen_andqi3 (); -extern rtx gen_iorsi3 (); -extern rtx gen_iorhi3 (); -extern rtx gen_iorqi3 (); -extern rtx gen_xorsi3 (); -extern rtx gen_xorhi3 (); -extern rtx gen_xorqi3 (); -extern rtx gen_negdi2 (); -extern rtx gen_negsi2 (); -extern rtx gen_neghi2 (); -extern rtx gen_negqi2 (); -extern rtx gen_negsf2 (); -extern rtx gen_negdf2 (); -extern rtx gen_abssf2 (); -extern rtx gen_absdf2 (); -extern rtx gen_sqrtsf2 (); -extern rtx gen_sqrtdf2 (); -extern rtx gen_sindf2 (); -extern rtx gen_sinsf2 (); -extern rtx gen_cosdf2 (); -extern rtx gen_cossf2 (); -extern rtx gen_one_cmplsi2 (); -extern rtx gen_one_cmplhi2 (); -extern rtx gen_one_cmplqi2 (); -extern rtx gen_ashldi3 (); -extern rtx gen_ashldi3_const_int (); -extern rtx gen_ashldi3_non_const_int (); -extern rtx gen_ashlsi3 (); -extern rtx gen_ashlhi3 (); -extern rtx gen_ashlqi3 (); -extern rtx gen_ashrdi3 (); -extern rtx gen_ashrdi3_const_int (); -extern rtx gen_ashrdi3_non_const_int (); -extern rtx gen_ashrsi3 (); -extern rtx gen_ashrhi3 (); -extern rtx gen_ashrqi3 (); -extern rtx gen_lshrdi3 (); -extern rtx gen_lshrdi3_const_int (); -extern rtx gen_lshrdi3_non_const_int (); -extern rtx gen_lshrsi3 (); -extern rtx gen_lshrhi3 (); -extern rtx gen_lshrqi3 (); -extern rtx gen_rotlsi3 (); -extern rtx gen_rotlhi3 (); -extern rtx gen_rotlqi3 (); -extern rtx gen_rotrsi3 (); -extern rtx gen_rotrhi3 (); -extern rtx gen_rotrqi3 (); -extern rtx gen_seq (); -extern rtx gen_sne (); -extern rtx gen_sgt (); -extern rtx gen_sgtu (); -extern rtx gen_slt (); -extern rtx gen_sltu (); -extern rtx gen_sge (); -extern rtx gen_sgeu (); -extern rtx gen_sle (); -extern rtx gen_sleu (); -extern rtx gen_beq (); -extern rtx gen_bne (); -extern rtx gen_bgt (); -extern rtx gen_bgtu (); -extern rtx gen_blt (); -extern rtx gen_bltu (); -extern rtx gen_bge (); -extern rtx gen_bgeu (); -extern rtx gen_ble (); -extern rtx gen_bleu (); -extern rtx gen_jump (); -extern rtx gen_indirect_jump (); -extern rtx gen_casesi (); -extern rtx gen_tablejump (); -extern rtx gen_untyped_call (); -extern rtx gen_untyped_return (); -extern rtx gen_update_return (); -extern rtx gen_return (); -extern rtx gen_nop (); -extern rtx gen_movstrsi (); -extern rtx gen_cmpstrsi (); -extern rtx gen_ffssi2 (); -extern rtx gen_ffshi2 (); -extern rtx gen_strlensi (); -extern rtx gen_call_pop (); -extern rtx gen_call (); -extern rtx gen_call_value_pop (); -extern rtx gen_call_value (); -#endif /* NO_MD_PROTOTYPES */ diff --git a/gnu/usr.bin/gcc2/i386/insn-opinit.c b/gnu/usr.bin/gcc2/i386/insn-opinit.c deleted file mode 100644 index c33c4576ed08..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-opinit.c +++ /dev/null @@ -1,183 +0,0 @@ -/* Generated automatically by the program `genopinit' -from the machine description file `md'. */ - -#ifndef lint -static char rcsid[] = "$Id: insn-opinit.c,v 1.2 1993/08/02 17:37:03 mycroft Exp $"; -#endif /* not lint */ - -#include "config.h" -#include "rtl.h" -#include "flags.h" -#include "insn-flags.h" -#include "insn-codes.h" -#include "insn-config.h" -#include "recog.h" -#include "expr.h" -#include "reload.h" - -void -init_all_optabs () -{ - tst_optab->handlers[(int) SImode].insn_code = CODE_FOR_tstsi; - tst_optab->handlers[(int) HImode].insn_code = CODE_FOR_tsthi; - tst_optab->handlers[(int) QImode].insn_code = CODE_FOR_tstqi; - if (HAVE_tstsf) - tst_optab->handlers[(int) SFmode].insn_code = CODE_FOR_tstsf; - if (HAVE_tstdf) - tst_optab->handlers[(int) DFmode].insn_code = CODE_FOR_tstdf; - cmp_optab->handlers[(int) SImode].insn_code = CODE_FOR_cmpsi; - cmp_optab->handlers[(int) HImode].insn_code = CODE_FOR_cmphi; - cmp_optab->handlers[(int) QImode].insn_code = CODE_FOR_cmpqi; - if (HAVE_cmpdf) - cmp_optab->handlers[(int) DFmode].insn_code = CODE_FOR_cmpdf; - if (HAVE_cmpsf) - cmp_optab->handlers[(int) SFmode].insn_code = CODE_FOR_cmpsf; - mov_optab->handlers[(int) SImode].insn_code = CODE_FOR_movsi; - mov_optab->handlers[(int) HImode].insn_code = CODE_FOR_movhi; - movstrict_optab->handlers[(int) HImode].insn_code = CODE_FOR_movstricthi; - mov_optab->handlers[(int) QImode].insn_code = CODE_FOR_movqi; - movstrict_optab->handlers[(int) QImode].insn_code = CODE_FOR_movstrictqi; - mov_optab->handlers[(int) SFmode].insn_code = CODE_FOR_movsf; - mov_optab->handlers[(int) DFmode].insn_code = CODE_FOR_movdf; - mov_optab->handlers[(int) DImode].insn_code = CODE_FOR_movdi; - extendtab[(int) SImode][(int) HImode][1] = CODE_FOR_zero_extendhisi2; - extendtab[(int) HImode][(int) QImode][1] = CODE_FOR_zero_extendqihi2; - extendtab[(int) SImode][(int) QImode][1] = CODE_FOR_zero_extendqisi2; - extendtab[(int) DImode][(int) SImode][1] = CODE_FOR_zero_extendsidi2; - extendtab[(int) DImode][(int) SImode][0] = CODE_FOR_extendsidi2; - extendtab[(int) SImode][(int) HImode][0] = CODE_FOR_extendhisi2; - extendtab[(int) HImode][(int) QImode][0] = CODE_FOR_extendqihi2; - extendtab[(int) SImode][(int) QImode][0] = CODE_FOR_extendqisi2; - if (HAVE_extendsfdf2) - extendtab[(int) DFmode][(int) SFmode][0] = CODE_FOR_extendsfdf2; - if (HAVE_fixuns_truncdfsi2) - fixtrunctab[(int) DFmode][(int) SImode][1] = CODE_FOR_fixuns_truncdfsi2; - if (HAVE_fixuns_truncsfsi2) - fixtrunctab[(int) SFmode][(int) SImode][1] = CODE_FOR_fixuns_truncsfsi2; - if (HAVE_fix_truncdfdi2) - fixtrunctab[(int) DFmode][(int) DImode][0] = CODE_FOR_fix_truncdfdi2; - if (HAVE_fix_truncsfdi2) - fixtrunctab[(int) SFmode][(int) DImode][0] = CODE_FOR_fix_truncsfdi2; - if (HAVE_fix_truncdfsi2) - fixtrunctab[(int) DFmode][(int) SImode][0] = CODE_FOR_fix_truncdfsi2; - if (HAVE_fix_truncsfsi2) - fixtrunctab[(int) SFmode][(int) SImode][0] = CODE_FOR_fix_truncsfsi2; - if (HAVE_floatsisf2) - floattab[(int) SFmode][(int) SImode][0] = CODE_FOR_floatsisf2; - if (HAVE_floatdisf2) - floattab[(int) SFmode][(int) DImode][0] = CODE_FOR_floatdisf2; - if (HAVE_floatsidf2) - floattab[(int) DFmode][(int) SImode][0] = CODE_FOR_floatsidf2; - if (HAVE_floatdidf2) - floattab[(int) DFmode][(int) DImode][0] = CODE_FOR_floatdidf2; - add_optab->handlers[(int) DImode].insn_code = CODE_FOR_adddi3; - add_optab->handlers[(int) SImode].insn_code = CODE_FOR_addsi3; - add_optab->handlers[(int) HImode].insn_code = CODE_FOR_addhi3; - add_optab->handlers[(int) QImode].insn_code = CODE_FOR_addqi3; - if (HAVE_adddf3) - add_optab->handlers[(int) DFmode].insn_code = CODE_FOR_adddf3; - if (HAVE_addsf3) - add_optab->handlers[(int) SFmode].insn_code = CODE_FOR_addsf3; - sub_optab->handlers[(int) DImode].insn_code = CODE_FOR_subdi3; - sub_optab->handlers[(int) SImode].insn_code = CODE_FOR_subsi3; - sub_optab->handlers[(int) HImode].insn_code = CODE_FOR_subhi3; - sub_optab->handlers[(int) QImode].insn_code = CODE_FOR_subqi3; - if (HAVE_subdf3) - sub_optab->handlers[(int) DFmode].insn_code = CODE_FOR_subdf3; - if (HAVE_subsf3) - sub_optab->handlers[(int) SFmode].insn_code = CODE_FOR_subsf3; - smul_optab->handlers[(int) HImode].insn_code = CODE_FOR_mulhi3; - smul_optab->handlers[(int) SImode].insn_code = CODE_FOR_mulsi3; - if (HAVE_muldf3) - smul_optab->handlers[(int) DFmode].insn_code = CODE_FOR_muldf3; - if (HAVE_mulsf3) - smul_optab->handlers[(int) SFmode].insn_code = CODE_FOR_mulsf3; - sdiv_optab->handlers[(int) QImode].insn_code = CODE_FOR_divqi3; - udiv_optab->handlers[(int) QImode].insn_code = CODE_FOR_udivqi3; - if (HAVE_divdf3) - flodiv_optab->handlers[(int) DFmode].insn_code = CODE_FOR_divdf3; - if (HAVE_divsf3) - flodiv_optab->handlers[(int) SFmode].insn_code = CODE_FOR_divsf3; - sdivmod_optab->handlers[(int) SImode].insn_code = CODE_FOR_divmodsi4; - sdivmod_optab->handlers[(int) HImode].insn_code = CODE_FOR_divmodhi4; - udivmod_optab->handlers[(int) SImode].insn_code = CODE_FOR_udivmodsi4; - udivmod_optab->handlers[(int) HImode].insn_code = CODE_FOR_udivmodhi4; - and_optab->handlers[(int) SImode].insn_code = CODE_FOR_andsi3; - and_optab->handlers[(int) HImode].insn_code = CODE_FOR_andhi3; - and_optab->handlers[(int) QImode].insn_code = CODE_FOR_andqi3; - ior_optab->handlers[(int) SImode].insn_code = CODE_FOR_iorsi3; - ior_optab->handlers[(int) HImode].insn_code = CODE_FOR_iorhi3; - ior_optab->handlers[(int) QImode].insn_code = CODE_FOR_iorqi3; - xor_optab->handlers[(int) SImode].insn_code = CODE_FOR_xorsi3; - xor_optab->handlers[(int) HImode].insn_code = CODE_FOR_xorhi3; - xor_optab->handlers[(int) QImode].insn_code = CODE_FOR_xorqi3; - neg_optab->handlers[(int) DImode].insn_code = CODE_FOR_negdi2; - neg_optab->handlers[(int) SImode].insn_code = CODE_FOR_negsi2; - neg_optab->handlers[(int) HImode].insn_code = CODE_FOR_neghi2; - neg_optab->handlers[(int) QImode].insn_code = CODE_FOR_negqi2; - if (HAVE_negsf2) - neg_optab->handlers[(int) SFmode].insn_code = CODE_FOR_negsf2; - if (HAVE_negdf2) - neg_optab->handlers[(int) DFmode].insn_code = CODE_FOR_negdf2; - if (HAVE_abssf2) - abs_optab->handlers[(int) SFmode].insn_code = CODE_FOR_abssf2; - if (HAVE_absdf2) - abs_optab->handlers[(int) DFmode].insn_code = CODE_FOR_absdf2; - if (HAVE_sqrtsf2) - sqrt_optab->handlers[(int) SFmode].insn_code = CODE_FOR_sqrtsf2; - if (HAVE_sqrtdf2) - sqrt_optab->handlers[(int) DFmode].insn_code = CODE_FOR_sqrtdf2; - if (HAVE_sindf2) - sin_optab->handlers[(int) DFmode].insn_code = CODE_FOR_sindf2; - if (HAVE_sinsf2) - sin_optab->handlers[(int) SFmode].insn_code = CODE_FOR_sinsf2; - if (HAVE_cosdf2) - cos_optab->handlers[(int) DFmode].insn_code = CODE_FOR_cosdf2; - if (HAVE_cossf2) - cos_optab->handlers[(int) SFmode].insn_code = CODE_FOR_cossf2; - one_cmpl_optab->handlers[(int) SImode].insn_code = CODE_FOR_one_cmplsi2; - one_cmpl_optab->handlers[(int) HImode].insn_code = CODE_FOR_one_cmplhi2; - one_cmpl_optab->handlers[(int) QImode].insn_code = CODE_FOR_one_cmplqi2; - ashl_optab->handlers[(int) DImode].insn_code = CODE_FOR_ashldi3; - ashl_optab->handlers[(int) SImode].insn_code = CODE_FOR_ashlsi3; - ashl_optab->handlers[(int) HImode].insn_code = CODE_FOR_ashlhi3; - ashl_optab->handlers[(int) QImode].insn_code = CODE_FOR_ashlqi3; - ashr_optab->handlers[(int) DImode].insn_code = CODE_FOR_ashrdi3; - ashr_optab->handlers[(int) SImode].insn_code = CODE_FOR_ashrsi3; - ashr_optab->handlers[(int) HImode].insn_code = CODE_FOR_ashrhi3; - ashr_optab->handlers[(int) QImode].insn_code = CODE_FOR_ashrqi3; - lshr_optab->handlers[(int) DImode].insn_code = CODE_FOR_lshrdi3; - lshr_optab->handlers[(int) SImode].insn_code = CODE_FOR_lshrsi3; - lshr_optab->handlers[(int) HImode].insn_code = CODE_FOR_lshrhi3; - lshr_optab->handlers[(int) QImode].insn_code = CODE_FOR_lshrqi3; - rotl_optab->handlers[(int) SImode].insn_code = CODE_FOR_rotlsi3; - rotl_optab->handlers[(int) HImode].insn_code = CODE_FOR_rotlhi3; - rotl_optab->handlers[(int) QImode].insn_code = CODE_FOR_rotlqi3; - rotr_optab->handlers[(int) SImode].insn_code = CODE_FOR_rotrsi3; - rotr_optab->handlers[(int) HImode].insn_code = CODE_FOR_rotrhi3; - rotr_optab->handlers[(int) QImode].insn_code = CODE_FOR_rotrqi3; - setcc_gen_code[(int) EQ] = CODE_FOR_seq; - setcc_gen_code[(int) NE] = CODE_FOR_sne; - setcc_gen_code[(int) GT] = CODE_FOR_sgt; - setcc_gen_code[(int) GTU] = CODE_FOR_sgtu; - setcc_gen_code[(int) LT] = CODE_FOR_slt; - setcc_gen_code[(int) LTU] = CODE_FOR_sltu; - setcc_gen_code[(int) GE] = CODE_FOR_sge; - setcc_gen_code[(int) GEU] = CODE_FOR_sgeu; - setcc_gen_code[(int) LE] = CODE_FOR_sle; - setcc_gen_code[(int) LEU] = CODE_FOR_sleu; - bcc_gen_fctn[(int) EQ] = gen_beq; - bcc_gen_fctn[(int) NE] = gen_bne; - bcc_gen_fctn[(int) GT] = gen_bgt; - bcc_gen_fctn[(int) GTU] = gen_bgtu; - bcc_gen_fctn[(int) LT] = gen_blt; - bcc_gen_fctn[(int) LTU] = gen_bltu; - bcc_gen_fctn[(int) GE] = gen_bge; - bcc_gen_fctn[(int) GEU] = gen_bgeu; - bcc_gen_fctn[(int) LE] = gen_ble; - bcc_gen_fctn[(int) LEU] = gen_bleu; - movstr_optab[(int) SImode] = CODE_FOR_movstrsi; - ffs_optab->handlers[(int) SImode].insn_code = CODE_FOR_ffssi2; - ffs_optab->handlers[(int) HImode].insn_code = CODE_FOR_ffshi2; - strlen_optab->handlers[(int) SImode].insn_code = CODE_FOR_strlensi; -} diff --git a/gnu/usr.bin/gcc2/i386/insn-output.c b/gnu/usr.bin/gcc2/i386/insn-output.c deleted file mode 100644 index 403bc5634957..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-output.c +++ /dev/null @@ -1,5903 +0,0 @@ -/* Generated automatically by the program `genoutput' -from the machine description file `md'. */ - -#ifndef lint -static char rcsid[] = "$Id: insn-output.c,v 1.2 1993/08/02 17:37:04 mycroft Exp $"; -#endif /* not lint */ - -#include "config.h" -#include "rtl.h" -#include "regs.h" -#include "hard-reg-set.h" -#include "real.h" -#include "insn-config.h" - -#include "conditions.h" -#include "insn-flags.h" -#include "insn-attr.h" - -#include "insn-codes.h" - -#include "recog.h" - -#include -#include "output.h" - -static char * -output_0 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0])) - return AS2 (test%L0,%0,%0); - - operands[1] = const0_rtx; - return AS2 (cmp%L0,%1,%0); -} -} - -static char * -output_2 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0])) - return AS2 (test%W0,%0,%0); - - operands[1] = const0_rtx; - return AS2 (cmp%W0,%1,%0); -} -} - -static char * -output_4 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0])) - return AS2 (test%B0,%0,%0); - - operands[1] = const0_rtx; - return AS2 (cmp%B0,%1,%0); -} -} - -static char * -output_6 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (! STACK_TOP_P (operands[0])) - abort (); - - output_asm_insn ("ftst", operands); - - if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) - output_asm_insn (AS1 (fstp,%y0), operands); - - return (char *) output_fp_cc0_set (insn); -} -} - -static char * -output_8 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (! STACK_TOP_P (operands[0])) - abort (); - - output_asm_insn ("ftst", operands); - - if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) - output_asm_insn (AS1 (fstp,%y0), operands); - - return (char *) output_fp_cc0_set (insn); -} -} - -static char * -output_10 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (CONSTANT_P (operands[0]) || GET_CODE (operands[1]) == MEM) - { - cc_status.flags |= CC_REVERSED; - return AS2 (cmp%L0,%0,%1); - } - return AS2 (cmp%L0,%1,%0); -} -} - -static char * -output_12 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (CONSTANT_P (operands[0]) || GET_CODE (operands[1]) == MEM) - { - cc_status.flags |= CC_REVERSED; - return AS2 (cmp%W0,%0,%1); - } - return AS2 (cmp%W0,%1,%0); -} -} - -static char * -output_14 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (CONSTANT_P (operands[0]) || GET_CODE (operands[1]) == MEM) - { - cc_status.flags |= CC_REVERSED; - return AS2 (cmp%B0,%0,%1); - } - return AS2 (cmp%B0,%1,%0); -} -} - -static char * -output_16 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_17 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_18 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_19 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_20 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_21 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_22 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_23 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_24 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_25 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_float_compare (insn, operands); -} - -static char * -output_32 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - /* For small integers, we may actually use testb. */ - if (GET_CODE (operands[1]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])) - && (! REG_P (operands[0]) || QI_REG_P (operands[0]))) - { - /* We may set the sign bit spuriously. */ - - if ((INTVAL (operands[1]) & ~0xff) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - return AS2 (test%B0,%1,%b0); - } - - if ((INTVAL (operands[1]) & ~0xff00) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (INTVAL (operands[1]) >> 8); - - if (QI_REG_P (operands[0])) - return AS2 (test%B0,%1,%h0); - else - { - operands[0] = adj_offsettable_operand (operands[0], 1); - return AS2 (test%B0,%1,%b0); - } - } - - if (GET_CODE (operands[0]) == MEM - && (INTVAL (operands[1]) & ~0xff0000) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (INTVAL (operands[1]) >> 16); - operands[0] = adj_offsettable_operand (operands[0], 2); - return AS2 (test%B0,%1,%b0); - } - - if (GET_CODE (operands[0]) == MEM - && (INTVAL (operands[1]) & ~0xff000000) == 0) - { - operands[1] = GEN_INT ((INTVAL (operands[1]) >> 24) & 0xff); - operands[0] = adj_offsettable_operand (operands[0], 3); - return AS2 (test%B0,%1,%b0); - } - } - - if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) - return AS2 (test%L0,%1,%0); - - return AS2 (test%L1,%0,%1); -} -} - -static char * -output_33 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])) - && (! REG_P (operands[0]) || QI_REG_P (operands[0]))) - { - if ((INTVAL (operands[1]) & 0xff00) == 0) - { - /* ??? This might not be necessary. */ - if (INTVAL (operands[1]) & 0xffff0000) - operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff); - - /* We may set the sign bit spuriously. */ - cc_status.flags |= CC_NOT_NEGATIVE; - return AS2 (test%B0,%1,%b0); - } - - if ((INTVAL (operands[1]) & 0xff) == 0) - { - operands[1] = GEN_INT ((INTVAL (operands[1]) >> 8) & 0xff); - - if (QI_REG_P (operands[0])) - return AS2 (test%B0,%1,%h0); - else - { - operands[0] = adj_offsettable_operand (operands[0], 1); - return AS2 (test%B0,%1,%b0); - } - } - } - - if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) - return AS2 (test%W0,%1,%0); - - return AS2 (test%W1,%0,%1); -} -} - -static char * -output_34 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) - return AS2 (test%B0,%1,%0); - - return AS2 (test%B1,%0,%1); -} -} - -static char * -output_38 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx link; - if (operands[1] == const0_rtx && REG_P (operands[0])) - return AS2 (xor%L0,%0,%0); - - if (operands[1] == const1_rtx - && (link = find_reg_note (insn, REG_WAS_0, 0)) - /* Make sure the insn that stored the 0 is still present. */ - && ! INSN_DELETED_P (XEXP (link, 0)) - && GET_CODE (XEXP (link, 0)) != NOTE - /* Make sure cross jumping didn't happen here. */ - && no_labels_between_p (XEXP (link, 0), insn) - /* Make sure the reg hasn't been clobbered. */ - && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) - /* Fastest way to change a 0 to a 1. */ - return AS1 (inc%L0,%0); - - return AS2 (mov%L0,%1,%0); -} -} - -static char * -output_40 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx link; - if (REG_P (operands[0]) && operands[1] == const0_rtx) - return AS2 (xor%L0,%k0,%k0); - - if (REG_P (operands[0]) && operands[1] == const1_rtx - && (link = find_reg_note (insn, REG_WAS_0, 0)) - /* Make sure the insn that stored the 0 is still present. */ - && ! INSN_DELETED_P (XEXP (link, 0)) - && GET_CODE (XEXP (link, 0)) != NOTE - /* Make sure cross jumping didn't happen here. */ - && no_labels_between_p (XEXP (link, 0), insn) - /* Make sure the reg hasn't been clobbered. */ - && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) - /* Fastest way to change a 0 to a 1. */ - return AS1 (inc%L0,%k0); - - if (REG_P (operands[0])) - { - if (REG_P (operands[1])) - return AS2 (mov%L0,%k1,%k0); - else if (CONSTANT_P (operands[1])) - return AS2 (mov%L0,%1,%k0); - } - - return AS2 (mov%W0,%1,%0); -} -} - -static char * -output_41 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx link; - if (operands[1] == const0_rtx && REG_P (operands[0])) - return AS2 (xor%W0,%0,%0); - - if (operands[1] == const1_rtx - && (link = find_reg_note (insn, REG_WAS_0, 0)) - /* Make sure the insn that stored the 0 is still present. */ - && ! INSN_DELETED_P (XEXP (link, 0)) - && GET_CODE (XEXP (link, 0)) != NOTE - /* Make sure cross jumping didn't happen here. */ - && no_labels_between_p (XEXP (link, 0), insn) - /* Make sure the reg hasn't been clobbered. */ - && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) - /* Fastest way to change a 0 to a 1. */ - return AS1 (inc%W0,%0); - - return AS2 (mov%W0,%1,%0); -} -} - -static char * -output_42 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[1] = gen_rtx (REG, HImode, REGNO (operands[1])); - return AS1 (push%W0,%1); -} -} - -static char * -output_43 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx link; - if (operands[1] == const0_rtx && REG_P (operands[0])) - return AS2 (xor%B0,%0,%0); - - if (operands[1] == const1_rtx - && (link = find_reg_note (insn, REG_WAS_0, 0)) - /* Make sure the insn that stored the 0 is still present. */ - && ! INSN_DELETED_P (XEXP (link, 0)) - && GET_CODE (XEXP (link, 0)) != NOTE - /* Make sure cross jumping didn't happen here. */ - && no_labels_between_p (XEXP (link, 0), insn) - /* Make sure the reg hasn't been clobbered. */ - && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) - /* Fastest way to change a 0 to a 1. */ - return AS1 (inc%B0,%0); - - /* If mov%B0 isn't allowed for one of these regs, use mov%L0. */ - if (NON_QI_REG_P (operands[0]) || NON_QI_REG_P (operands[1])) - return (AS2 (mov%L0,%k1,%k0)); - - return (AS2 (mov%B0,%1,%0)); -} -} - -static char * -output_44 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx link; - if (operands[1] == const0_rtx && REG_P (operands[0])) - return AS2 (xor%B0,%0,%0); - - if (operands[1] == const1_rtx - && (link = find_reg_note (insn, REG_WAS_0, 0)) - /* Make sure the insn that stored the 0 is still present. */ - && ! INSN_DELETED_P (XEXP (link, 0)) - && GET_CODE (XEXP (link, 0)) != NOTE - /* Make sure cross jumping didn't happen here. */ - && no_labels_between_p (XEXP (link, 0), insn) - /* Make sure the reg hasn't been clobbered. */ - && ! reg_set_between_p (operands[0], XEXP (link, 0), insn)) - /* Fastest way to change a 0 to a 1. */ - return AS1 (inc%B0,%0); - - /* If mov%B0 isn't allowed for one of these regs, use mov%W0. */ - if (NON_QI_REG_P (operands[0]) || NON_QI_REG_P (operands[1])) - { - abort (); - return (AS2 (mov%L0,%k1,%k0)); - } - - return AS2 (mov%B0,%1,%0); -} -} - -static char * -output_45 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (STACK_REG_P (operands[1])) - { - rtx xops[3]; - - if (! STACK_TOP_P (operands[1])) - abort (); - - xops[0] = AT_SP (SFmode); - xops[1] = GEN_INT (4); - xops[2] = stack_pointer_rtx; - - output_asm_insn (AS2 (sub%L2,%1,%2), xops); - - if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) - output_asm_insn (AS1 (fstp%S0,%0), xops); - else - output_asm_insn (AS1 (fst%S0,%0), xops); - RET; - } - return AS1 (push%L1,%1); -} -} - -static char * -output_46 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; - - /* First handle a `pop' insn or a `fld %st(0)' */ - - if (STACK_TOP_P (operands[0]) && STACK_TOP_P (operands[1])) - { - if (stack_top_dies) - return AS1 (fstp,%y0); - else - return AS1 (fld,%y0); - } - - /* Handle a transfer between the 387 and a 386 register */ - - if (STACK_TOP_P (operands[0]) && NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); - RET; - } - - if (STACK_TOP_P (operands[1]) && NON_STACK_REG_P (operands[0])) - { - output_to_reg (operands[0], stack_top_dies); - RET; - } - - /* Handle other kinds of writes from the 387 */ - - if (STACK_TOP_P (operands[1])) - { - if (stack_top_dies) - return AS1 (fstp%z0,%y0); - else - return AS1 (fst%z0,%y0); - } - - /* Handle other kinds of reads to the 387 */ - - if (STACK_TOP_P (operands[0]) && GET_CODE (operands[1]) == CONST_DOUBLE) - return (char *) output_move_const_single (operands); - - if (STACK_TOP_P (operands[0])) - return AS1 (fld%z1,%y1); - - /* Handle all SFmode moves not involving the 387 */ - - return (char *) singlemove_string (operands); -} -} - -static char * -output_47 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (STACK_REG_P (operands[1])) - { - rtx xops[3]; - - xops[0] = AT_SP (SFmode); - xops[1] = GEN_INT (8); - xops[2] = stack_pointer_rtx; - - output_asm_insn (AS2 (sub%L2,%1,%2), xops); - - if (find_regno_note (insn, REG_DEAD, FIRST_STACK_REG)) - output_asm_insn (AS1 (fstp%Q0,%0), xops); - else - output_asm_insn (AS1 (fst%Q0,%0), xops); - - RET; - } - else - return (char *) output_move_double (operands); -} -} - -static char * -output_48 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (STACK_TOP_P (operands[0])) - return AS1 (fxch,%1); - else - return AS1 (fxch,%0); -} -} - -static char * -output_49 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; - - /* First handle a `pop' insn or a `fld %st(0)' */ - - if (STACK_TOP_P (operands[0]) && STACK_TOP_P (operands[1])) - { - if (stack_top_dies) - return AS1 (fstp,%y0); - else - return AS1 (fld,%y0); - } - - /* Handle a transfer between the 387 and a 386 register */ - - if (STACK_TOP_P (operands[0]) && NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); - RET; - } - - if (STACK_TOP_P (operands[1]) && NON_STACK_REG_P (operands[0])) - { - output_to_reg (operands[0], stack_top_dies); - RET; - } - - /* Handle other kinds of writes from the 387 */ - - if (STACK_TOP_P (operands[1])) - { - if (stack_top_dies) - return AS1 (fstp%z0,%y0); - else - return AS1 (fst%z0,%y0); - } - - /* Handle other kinds of reads to the 387 */ - - if (STACK_TOP_P (operands[0]) && GET_CODE (operands[1]) == CONST_DOUBLE) - return (char *) output_move_const_single (operands); - - if (STACK_TOP_P (operands[0])) - return AS1 (fld%z1,%y1); - - /* Handle all DFmode moves not involving the 387 */ - - return (char *) output_move_double (operands); -} -} - -static char * -output_50 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return (char *) output_move_double (operands); -} -} - -static char * -output_51 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - return (char *) output_move_double (operands); -} -} - -static char * -output_52 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if ((TARGET_486 || REGNO (operands[0]) == 0) - && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])) - { - rtx xops[2]; - xops[0] = operands[0]; - xops[1] = GEN_INT (0xffff); - output_asm_insn (AS2 (and%L0,%1,%k0), xops); - RET; - } - -#ifdef INTEL_SYNTAX - return AS2 (movzx,%1,%0); -#else - return AS2 (movz%W0%L0,%1,%0); -#endif -} -} - -static char * -output_53 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if ((TARGET_486 || REGNO (operands[0]) == 0) - && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])) - { - rtx xops[2]; - xops[0] = operands[0]; - xops[1] = GEN_INT (0xff); - output_asm_insn (AS2 (and%L0,%1,%k0), xops); - RET; - } - -#ifdef INTEL_SYNTAX - return AS2 (movzx,%1,%0); -#else - return AS2 (movz%B0%W0,%1,%0); -#endif -} -} - -static char * -output_54 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if ((TARGET_486 || REGNO (operands[0]) == 0) - && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])) - { - rtx xops[2]; - xops[0] = operands[0]; - xops[1] = GEN_INT (0xff); - output_asm_insn (AS2 (and%L0,%1,%k0), xops); - RET; - } - -#ifdef INTEL_SYNTAX - return AS2 (movzx,%1,%0); -#else - return AS2 (movz%B0%L0,%1,%0); -#endif -} -} - -static char * -output_55 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - operands[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - return AS2 (xor%L0,%0,%0); -} -} - -static char * -output_56 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REGNO (operands[0]) == 0) - { - /* This used to be cwtl, but that extends HI to SI somehow. */ -#ifdef INTEL_SYNTAX - return "cdq"; -#else - return "cltd"; -#endif - } - - operands[1] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1); - output_asm_insn (AS2 (mov%L0,%0,%1), operands); - - operands[0] = GEN_INT (31); - return AS2 (sar%L1,%0,%1); -} -} - -static char * -output_57 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REGNO (operands[0]) == 0 - && REG_P (operands[1]) && REGNO (operands[1]) == 0) -#ifdef INTEL_SYNTAX - return "cwde"; -#else - return "cwtl"; -#endif - -#ifdef INTEL_SYNTAX - return AS2 (movsx,%1,%0); -#else - return AS2 (movs%W0%L0,%1,%0); -#endif -} -} - -static char * -output_58 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REGNO (operands[0]) == 0 - && REG_P (operands[1]) && REGNO (operands[1]) == 0) - return "cbtw"; - -#ifdef INTEL_SYNTAX - return AS2 (movsx,%1,%0); -#else - return AS2 (movs%B0%W0,%1,%0); -#endif -} -} - -static char * -output_59 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef INTEL_SYNTAX - return AS2 (movsx,%1,%0); -#else - return AS2 (movs%B0%L0,%1,%0); -#endif -} -} - -static char * -output_60 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; - - if (NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fld%z0,%y1)); - RET; - } - - if (NON_STACK_REG_P (operands[0])) - { - output_to_reg (operands[0], stack_top_dies); - RET; - } - - if (STACK_TOP_P (operands[0])) - return AS1 (fld%z1,%y1); - - if (GET_CODE (operands[0]) == MEM) - { - if (stack_top_dies) - return AS1 (fstp%z0,%y0); - else - return AS1 (fst%z0,%y0); - } - - abort (); -} -} - -static char * -output_62 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - int stack_top_dies = find_regno_note (insn, REG_DEAD, FIRST_STACK_REG) != 0; - - if (GET_CODE (operands[0]) == MEM) - { - if (stack_top_dies) - return AS1 (fstp%z0,%0); - else - return AS1 (fst%z0,%0); - } - else if (STACK_TOP_P (operands[0])) - { - output_asm_insn (AS1 (fstp%z2,%y2), operands); - return AS1 (fld%z2,%y2); - } - else - abort (); -} -} - -static char * -output_67 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_fix_trunc (insn, operands); -} - -static char * -output_68 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_fix_trunc (insn, operands); -} - -static char * -output_71 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_fix_trunc (insn, operands); -} - -static char * -output_72 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_fix_trunc (insn, operands); -} - -static char * -output_77 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fild%z0,%1)); - RET; - } - else if (GET_CODE (operands[1]) == MEM) - return AS1 (fild%z1,%1); - else - abort (); -} -} - -static char * -output_78 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fild%z0,%1)); - RET; - } - else if (GET_CODE (operands[1]) == MEM) - return AS1 (fild%z1,%1); - else - abort (); -} -} - -static char * -output_79 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fild%z0,%1)); - RET; - } - else if (GET_CODE (operands[1]) == MEM) - return AS1 (fild%z1,%1); - else - abort (); -} -} - -static char * -output_80 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (NON_STACK_REG_P (operands[1])) - { - output_op_from_reg (operands[1], AS1 (fild%z0,%1)); - RET; - } - else if (GET_CODE (operands[1]) == MEM) - return AS1 (fild%z1,%1); - else - abort (); -} -} - -static char * -output_81 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx low[3], high[3]; - - CC_STATUS_INIT; - - split_di (operands, 3, low, high); - - if (GET_CODE (low[2]) != CONST_INT || INTVAL (low[2]) != 0) - { - output_asm_insn (AS2 (add%L0,%2,%0), low); - output_asm_insn (AS2 (adc%L0,%2,%0), high); - } - else - output_asm_insn (AS2 (add%L0,%2,%0), high); - RET; -} -} - -static char * -output_82 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0]) && REGNO (operands[0]) != REGNO (operands[1])) - { - if (REG_P (operands[2]) && REGNO (operands[0]) == REGNO (operands[2])) - return AS2 (add%L0,%1,%0); - - if (! TARGET_486 || ! REG_P (operands[2])) - { - CC_STATUS_INIT; - - if (operands[2] == stack_pointer_rtx) - { - rtx temp; - - temp = operands[1]; - operands[1] = operands[2]; - operands[2] = temp; - } - if (operands[2] != stack_pointer_rtx) - { - operands[1] = SET_SRC (PATTERN (insn)); - return AS2 (lea%L0,%a1,%0); - } - } - - output_asm_insn (AS2 (mov%L0,%1,%0), operands); - } - - if (operands[2] == const1_rtx) - return AS1 (inc%L0,%0); - - if (operands[2] == constm1_rtx) - return AS1 (dec%L0,%0); - - return AS2 (add%L0,%2,%0); -} -} - -static char * -output_83 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[2] == const1_rtx) - return AS1 (inc%W0,%0); - - if (operands[2] == constm1_rtx) - return AS1 (dec%W0,%0); - - return AS2 (add%W0,%2,%0); -} -} - -static char * -output_84 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (operands[2] == const1_rtx) - return AS1 (inc%B0,%0); - - if (operands[2] == constm1_rtx) - return AS1 (dec%B0,%0); - - return AS2 (add%B0,%2,%0); -} -} - -static char * -output_85 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - /* Adding a constant to a register is faster with an add. */ - /* ??? can this ever happen? */ - if (GET_CODE (operands[1]) == PLUS - && GET_CODE (XEXP (operands[1], 1)) == CONST_INT - && rtx_equal_p (operands[0], XEXP (operands[1], 0))) - { - operands[1] = XEXP (operands[1], 1); - - if (operands[1] == const1_rtx) - return AS1 (inc%L0,%0); - - if (operands[1] == constm1_rtx) - return AS1 (dec%L0,%0); - - return AS2 (add%L0,%1,%0); - } - return AS2 (lea%L0,%a1,%0); -} -} - -static char * -output_88 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx low[3], high[3]; - - CC_STATUS_INIT; - - split_di (operands, 3, low, high); - - if (GET_CODE (low[2]) != CONST_INT || INTVAL (low[2]) != 0) - { - output_asm_insn (AS2 (sub%L0,%2,%0), low); - output_asm_insn (AS2 (sbb%L0,%2,%0), high); - } - else - output_asm_insn (AS2 (sub%L0,%2,%0), high); - - RET; -} -} - -static char * -output_89 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (sub%L0,%2,%0); -} - -static char * -output_90 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (sub%W0,%2,%0); -} - -static char * -output_91 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (sub%B0,%2,%0); -} - -static char * -output_94 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (imul%W0,%2,%0); -} - -static char * -output_95 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == REG - && REGNO (operands[1]) == REGNO (operands[0]) - && (GET_CODE (operands[2]) == MEM || GET_CODE (operands[2]) == REG)) - /* Assembler has weird restrictions. */ - return AS2 (imul%W0,%2,%0); - return AS3 (imul%W0,%2,%1,%0); -} -} - -static char * -output_96 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (imul%L0,%2,%0); -} - -static char * -output_97 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == REG - && REGNO (operands[1]) == REGNO (operands[0]) - && (GET_CODE (operands[2]) == MEM || GET_CODE (operands[2]) == REG)) - /* Assembler has weird restrictions. */ - return AS2 (imul%L0,%2,%0); - return AS3 (imul%L0,%2,%1,%0); -} -} - -static char * -output_105 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ -#ifdef INTEL_SYNTAX - output_asm_insn ("cdq", operands); -#else - output_asm_insn ("cltd", operands); -#endif - return AS1 (idiv%L0,%2); -} -} - -static char * -output_107 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - output_asm_insn (AS2 (xor%L3,%3,%3), operands); - return AS1 (div%L0,%2); -} -} - -static char * -output_108 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - output_asm_insn (AS2 (xor%W0,%3,%3), operands); - return AS1 (div%W0,%2); -} -} - -static char * -output_109 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - if (INTVAL (operands[2]) == 0xffff && REG_P (operands[0]) - && (! REG_P (operands[1]) - || REGNO (operands[0]) != 0 || REGNO (operands[1]) != 0) - && (! TARGET_486 || ! rtx_equal_p (operands[0], operands[1]))) - { - /* ??? tege: Should forget CC_STATUS only if we clobber a - remembered operand. Fix that later. */ - CC_STATUS_INIT; -#ifdef INTEL_SYNTAX - return AS2 (movzx,%w1,%0); -#else - return AS2 (movz%W0%L0,%w1,%0); -#endif - } - - if (INTVAL (operands[2]) == 0xff && REG_P (operands[0]) - && !(REG_P (operands[1]) && NON_QI_REG_P (operands[1])) - && (! REG_P (operands[1]) - || REGNO (operands[0]) != 0 || REGNO (operands[1]) != 0) - && (! TARGET_486 || ! rtx_equal_p (operands[0], operands[1]))) - { - /* ??? tege: Should forget CC_STATUS only if we clobber a - remembered operand. Fix that later. */ - CC_STATUS_INIT; -#ifdef INTEL_SYNTAX - return AS2 (movzx,%b1,%0); -#else - return AS2 (movz%B0%L0,%b1,%0); -#endif - } - - if (QI_REG_P (operands[0]) && ~(INTVAL (operands[2]) | 0xff) == 0) - { - CC_STATUS_INIT; - - if (INTVAL (operands[2]) == 0xffffff00) - { - operands[2] = const0_rtx; - return AS2 (mov%B0,%2,%b0); - } - - operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff); - return AS2 (and%B0,%2,%b0); - } - - if (QI_REG_P (operands[0]) && ~(INTVAL (operands[2]) | 0xff00) == 0) - { - CC_STATUS_INIT; - - if (INTVAL (operands[2]) == 0xffff00ff) - { - operands[2] = const0_rtx; - return AS2 (mov%B0,%2,%h0); - } - - operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); - return AS2 (and%B0,%2,%h0); - } - - if (GET_CODE (operands[0]) == MEM && INTVAL (operands[2]) == 0xffff0000) - { - operands[2] = const0_rtx; - return AS2 (mov%W0,%2,%w0); - } - } - - return AS2 (and%L0,%2,%0); -} -} - -static char * -output_110 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - /* Can we ignore the upper byte? */ - if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) - && (INTVAL (operands[2]) & 0xff00) == 0xff00) - { - CC_STATUS_INIT; - - if ((INTVAL (operands[2]) & 0xff) == 0) - { - operands[2] = const0_rtx; - return AS2 (mov%B0,%2,%b0); - } - - operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff); - return AS2 (and%B0,%2,%b0); - } - - /* Can we ignore the lower byte? */ - /* ??? what about offsettable memory references? */ - if (QI_REG_P (operands[0]) && (INTVAL (operands[2]) & 0xff) == 0xff) - { - CC_STATUS_INIT; - - if ((INTVAL (operands[2]) & 0xff00) == 0) - { - operands[2] = const0_rtx; - return AS2 (mov%B0,%2,%h0); - } - - operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); - return AS2 (and%B0,%2,%h0); - } - } - - return AS2 (and%W0,%2,%0); -} -} - -static char * -output_111 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (and%B0,%2,%0); -} - -static char * -output_112 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) - && (INTVAL (operands[2]) & ~0xff) == 0) - { - CC_STATUS_INIT; - - if (INTVAL (operands[2]) == 0xff) - return AS2 (mov%B0,%2,%b0); - - return AS2 (or%B0,%2,%b0); - } - - if (QI_REG_P (operands[0]) && (INTVAL (operands[2]) & ~0xff00) == 0) - { - CC_STATUS_INIT; - operands[2] = GEN_INT (INTVAL (operands[2]) >> 8); - - if (INTVAL (operands[2]) == 0xff) - return AS2 (mov%B0,%2,%h0); - - return AS2 (or%B0,%2,%h0); - } - } - - return AS2 (or%L0,%2,%0); -} -} - -static char * -output_113 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - /* Can we ignore the upper byte? */ - if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) - && (INTVAL (operands[2]) & 0xff00) == 0) - { - CC_STATUS_INIT; - if (INTVAL (operands[2]) & 0xffff0000) - operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffff); - - if (INTVAL (operands[2]) == 0xff) - return AS2 (mov%B0,%2,%b0); - - return AS2 (or%B0,%2,%b0); - } - - /* Can we ignore the lower byte? */ - /* ??? what about offsettable memory references? */ - if (QI_REG_P (operands[0]) - && (INTVAL (operands[2]) & 0xff) == 0) - { - CC_STATUS_INIT; - operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); - - if (INTVAL (operands[2]) == 0xff) - return AS2 (mov%B0,%2,%h0); - - return AS2 (or%B0,%2,%h0); - } - } - - return AS2 (or%W0,%2,%0); -} -} - -static char * -output_114 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (or%B0,%2,%0); -} - -static char * -output_115 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) - && (INTVAL (operands[2]) & ~0xff) == 0) - { - CC_STATUS_INIT; - - if (INTVAL (operands[2]) == 0xff) - return AS1 (not%B0,%b0); - - return AS2 (xor%B0,%2,%b0); - } - - if (QI_REG_P (operands[0]) && (INTVAL (operands[2]) & ~0xff00) == 0) - { - CC_STATUS_INIT; - operands[2] = GEN_INT (INTVAL (operands[2]) >> 8); - - if (INTVAL (operands[2]) == 0xff) - return AS1 (not%B0,%h0); - - return AS2 (xor%B0,%2,%h0); - } - } - - return AS2 (xor%L0,%2,%0); -} -} - -static char * -output_116 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[2]) == CONST_INT - && ! (GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) - { - /* Can we ignore the upper byte? */ - if ((! REG_P (operands[0]) || QI_REG_P (operands[0])) - && (INTVAL (operands[2]) & 0xff00) == 0) - { - CC_STATUS_INIT; - if (INTVAL (operands[2]) & 0xffff0000) - operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffff); - - if (INTVAL (operands[2]) == 0xff) - return AS1 (not%B0,%b0); - - return AS2 (xor%B0,%2,%b0); - } - - /* Can we ignore the lower byte? */ - /* ??? what about offsettable memory references? */ - if (QI_REG_P (operands[0]) - && (INTVAL (operands[2]) & 0xff) == 0) - { - CC_STATUS_INIT; - operands[2] = GEN_INT ((INTVAL (operands[2]) >> 8) & 0xff); - - if (INTVAL (operands[2]) == 0xff) - return AS1 (not%B0,%h0); - - return AS2 (xor%B0,%2,%h0); - } - } - - return AS2 (xor%W0,%2,%0); -} -} - -static char * -output_117 (operands, insn) - rtx *operands; - rtx insn; -{ - return AS2 (xor%B0,%2,%0); -} - -static char * -output_118 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = const0_rtx; - xops[1] = high[0]; - - output_asm_insn (AS1 (neg%L0,%0), low); - output_asm_insn (AS2 (adc%L1,%0,%1), xops); - output_asm_insn (AS1 (neg%L0,%0), high); - RET; -} -} - -static char * -output_141 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - if (INTVAL (xops[0]) > 31) - { - output_asm_insn (AS2 (mov%L3,%2,%3), xops); /* Fast shift by 32 */ - output_asm_insn (AS2 (xor%L2,%2,%2), xops); - - if (INTVAL (xops[0]) > 32) - { - xops[0] = GEN_INT (INTVAL (xops[0]) - 32); - output_asm_insn (AS2 (sal%L3,%0,%3), xops); /* Remaining shift */ - } - } - else - { - output_asm_insn (AS3 (shld%L3,%0,%2,%3), xops); - output_asm_insn (AS2 (sal%L2,%0,%2), xops); - } - RET; -} -} - -static char * -output_142 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - output_asm_insn (AS2 (ror%B0,%1,%0), xops); /* shift count / 2 */ - - output_asm_insn (AS3_SHIFT_DOUBLE (shld%L3,%0,%2,%3), xops); - output_asm_insn (AS2 (sal%L2,%0,%2), xops); - output_asm_insn (AS3_SHIFT_DOUBLE (shld%L3,%0,%2,%3), xops); - output_asm_insn (AS2 (sal%L2,%0,%2), xops); - - xops[1] = GEN_INT (7); /* shift count & 1 */ - - output_asm_insn (AS2 (shr%B0,%1,%0), xops); - - output_asm_insn (AS3_SHIFT_DOUBLE (shld%L3,%0,%2,%3), xops); - output_asm_insn (AS2 (sal%L2,%0,%2), xops); - - RET; -} -} - -static char * -output_143 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[0]) && REGNO (operands[0]) != REGNO (operands[1])) - { - if (TARGET_486 && INTVAL (operands[2]) == 1) - { - output_asm_insn (AS2 (mov%L0,%1,%0), operands); - return AS2 (add%L0,%1,%0); - } - else - { - CC_STATUS_INIT; - - if (operands[1] == stack_pointer_rtx) - { - output_asm_insn (AS2 (mov%L0,%1,%0), operands); - operands[1] = operands[0]; - } - operands[1] = gen_rtx (MULT, SImode, operands[1], - GEN_INT (1 << INTVAL (operands[2]))); - return AS2 (lea%L0,%a1,%0); - } - } - - if (REG_P (operands[2])) - return AS2 (sal%L0,%b2,%0); - - if (REG_P (operands[0]) && operands[2] == const1_rtx) - return AS2 (add%L0,%0,%0); - - return AS2 (sal%L0,%2,%0); -} -} - -static char * -output_144 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (sal%W0,%b2,%0); - - if (REG_P (operands[0]) && operands[2] == const1_rtx) - return AS2 (add%W0,%0,%0); - - return AS2 (sal%W0,%2,%0); -} -} - -static char * -output_145 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (sal%B0,%b2,%0); - - if (REG_P (operands[0]) && operands[2] == const1_rtx) - return AS2 (add%B0,%0,%0); - - return AS2 (sal%B0,%2,%0); -} -} - -static char * -output_147 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - if (INTVAL (xops[0]) > 31) - { - xops[1] = GEN_INT (31); - output_asm_insn (AS2 (mov%L2,%3,%2), xops); - output_asm_insn (AS2 (sar%L3,%1,%3), xops); /* shift by 32 */ - - if (INTVAL (xops[0]) > 32) - { - xops[0] = GEN_INT (INTVAL (xops[0]) - 32); - output_asm_insn (AS2 (sar%L2,%0,%2), xops); /* Remaining shift */ - } - } - else - { - output_asm_insn (AS3 (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (sar%L3,%0,%3), xops); - } - - RET; -} -} - -static char * -output_148 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - output_asm_insn (AS2 (ror%B0,%1,%0), xops); /* shift count / 2 */ - - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (sar%L3,%0,%3), xops); - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (sar%L3,%0,%3), xops); - - xops[1] = GEN_INT (7); /* shift count & 1 */ - - output_asm_insn (AS2 (shr%B0,%1,%0), xops); - - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (sar%L3,%0,%3), xops); - - RET; -} -} - -static char * -output_149 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (sar%L0,%b2,%0); - else - return AS2 (sar%L0,%2,%0); -} -} - -static char * -output_150 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (sar%W0,%b2,%0); - else - return AS2 (sar%W0,%2,%0); -} -} - -static char * -output_151 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (sar%B0,%b2,%0); - else - return AS2 (sar%B0,%2,%0); -} -} - -static char * -output_153 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - if (INTVAL (xops[0]) > 31) - { - output_asm_insn (AS2 (mov%L2,%3,%2), xops); /* Fast shift by 32 */ - output_asm_insn (AS2 (xor%L3,%3,%3), xops); - - if (INTVAL (xops[0]) > 32) - { - xops[0] = GEN_INT (INTVAL (xops[0]) - 32); - output_asm_insn (AS2 (shr%L2,%0,%2), xops); /* Remaining shift */ - } - } - else - { - output_asm_insn (AS3 (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (shr%L3,%0,%3), xops); - } - - RET; -} -} - -static char * -output_154 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], low[1], high[1]; - - CC_STATUS_INIT; - - split_di (operands, 1, low, high); - xops[0] = operands[2]; - xops[1] = const1_rtx; - xops[2] = low[0]; - xops[3] = high[0]; - - output_asm_insn (AS2 (ror%B0,%1,%0), xops); /* shift count / 2 */ - - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (shr%L3,%0,%3), xops); - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (shr%L3,%0,%3), xops); - - xops[1] = GEN_INT (7); /* shift count & 1 */ - - output_asm_insn (AS2 (shr%B0,%1,%0), xops); - - output_asm_insn (AS3_SHIFT_DOUBLE (shrd%L2,%0,%3,%2), xops); - output_asm_insn (AS2 (shr%L3,%0,%3), xops); - - RET; -} -} - -static char * -output_155 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (shr%L0,%b2,%0); - else - return AS2 (shr%L0,%2,%1); -} -} - -static char * -output_156 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (shr%W0,%b2,%0); - else - return AS2 (shr%W0,%2,%0); -} -} - -static char * -output_157 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (shr%B0,%b2,%0); - else - return AS2 (shr%B0,%2,%0); -} -} - -static char * -output_158 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (rol%L0,%b2,%0); - else - return AS2 (rol%L0,%2,%0); -} -} - -static char * -output_159 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (rol%W0,%b2,%0); - else - return AS2 (rol%W0,%2,%0); -} -} - -static char * -output_160 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (rol%B0,%b2,%0); - else - return AS2 (rol%B0,%2,%0); -} -} - -static char * -output_161 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (ror%L0,%b2,%0); - else - return AS2 (ror%L0,%2,%0); -} -} - -static char * -output_162 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (ror%W0,%b2,%0); - else - return AS2 (ror%W0,%2,%0); -} -} - -static char * -output_163 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (REG_P (operands[2])) - return AS2 (ror%B0,%b2,%0); - else - return AS2 (ror%B0,%2,%0); -} -} - -static char * -output_164 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - if (INTVAL (operands[3]) == 1) - return AS2 (bts%L0,%2,%0); - else - return AS2 (btr%L0,%2,%0); -} -} - -static char * -output_165 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - return AS2 (btc%L0,%1,%0); -} -} - -static char * -output_166 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - return AS2 (btc%L0,%2,%0); -} -} - -static char * -output_167 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - cc_status.flags |= CC_Z_IN_NOT_C; - return AS2 (bt%L0,%1,%0); -} -} - -static char * -output_168 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - unsigned int mask; - - mask = ((1 << INTVAL (operands[1])) - 1) << INTVAL (operands[2]); - operands[1] = GEN_INT (mask); - - if (QI_REG_P (operands[0])) - { - if ((mask & ~0xff) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - return AS2 (test%B0,%1,%b0); - } - - if ((mask & ~0xff00) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (mask >> 8); - return AS2 (test%B0,%1,%h0); - } - } - - return AS2 (test%L0,%1,%0); -} -} - -static char * -output_169 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - unsigned int mask; - - mask = ((1 << INTVAL (operands[1])) - 1) << INTVAL (operands[2]); - operands[1] = GEN_INT (mask); - - if (! REG_P (operands[0]) || QI_REG_P (operands[0])) - { - if ((mask & ~0xff) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - return AS2 (test%B0,%1,%b0); - } - - if ((mask & ~0xff00) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (mask >> 8); - - if (QI_REG_P (operands[0])) - return AS2 (test%B0,%1,%h0); - else - { - operands[0] = adj_offsettable_operand (operands[0], 1); - return AS2 (test%B0,%1,%b0); - } - } - - if (GET_CODE (operands[0]) == MEM && (mask & ~0xff0000) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (mask >> 16); - operands[0] = adj_offsettable_operand (operands[0], 2); - return AS2 (test%B0,%1,%b0); - } - - if (GET_CODE (operands[0]) == MEM && (mask & ~0xff000000) == 0) - { - cc_status.flags |= CC_NOT_NEGATIVE; - operands[1] = GEN_INT (mask >> 24); - operands[0] = adj_offsettable_operand (operands[0], 3); - return AS2 (test%B0,%1,%b0); - } - } - - if (CONSTANT_P (operands[1]) || GET_CODE (operands[0]) == MEM) - return AS2 (test%L0,%1,%0); - - return AS2 (test%L1,%0,%1); -} -} - -static char * -output_171 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return AS1 (setnb,%0); - else - return AS1 (sete,%0); -} -} - -static char * -output_173 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return AS1 (setb,%0); - else - return AS1 (setne,%0); -} - -} - -static char * -output_175 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (sete,%0); - - OUTPUT_JUMP ("setg %0", "seta %0", NULL_PTR); -} -} - -static char * -output_177 (operands, insn) - rtx *operands; - rtx insn; -{ - return "seta %0"; -} - -static char * -output_179 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (sete,%0); - - OUTPUT_JUMP ("setl %0", "setb %0", "sets %0"); -} -} - -static char * -output_181 (operands, insn) - rtx *operands; - rtx insn; -{ - return "setb %0"; -} - -static char * -output_183 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (sete,%0); - - OUTPUT_JUMP ("setge %0", "setae %0", "setns %0"); -} -} - -static char * -output_185 (operands, insn) - rtx *operands; - rtx insn; -{ - return "setae %0"; -} - -static char * -output_187 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (setb,%0); - - OUTPUT_JUMP ("setle %0", "setbe %0", NULL_PTR); -} -} - -static char * -output_189 (operands, insn) - rtx *operands; - rtx insn; -{ - return "setbe %0"; -} - -static char * -output_191 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return "jnc %l0"; - else - return "je %l0"; -} -} - -static char * -output_193 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return "jc %l0"; - else - return "jne %l0"; -} -} - -static char * -output_195 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (je,%l0); - - OUTPUT_JUMP ("jg %l0", "ja %l0", NULL_PTR); -} -} - -static char * -output_199 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (je,%l0); - - OUTPUT_JUMP ("jl %l0", "jb %l0", "js %l0"); -} -} - -static char * -output_203 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (je,%l0); - - OUTPUT_JUMP ("jge %l0", "jae %l0", "jns %l0"); -} -} - -static char * -output_207 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (jb,%l0); - - OUTPUT_JUMP ("jle %l0", "jbe %l0", NULL_PTR); -} -} - -static char * -output_210 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return "jc %l0"; - else - return "jne %l0"; -} -} - -static char * -output_211 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (cc_prev_status.flags & CC_Z_IN_NOT_C) - return "jnc %l0"; - else - return "je %l0"; -} -} - -static char * -output_212 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (jne,%l0); - - OUTPUT_JUMP ("jle %l0", "jbe %l0", NULL_PTR); -} -} - -static char * -output_214 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (jne,%l0); - - OUTPUT_JUMP ("jge %l0", "jae %l0", "jns %l0"); -} -} - -static char * -output_216 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (jne,%l0); - - OUTPUT_JUMP ("jl %l0", "jb %l0", "js %l0"); -} -} - -static char * -output_218 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (TARGET_IEEE_FP && (cc_prev_status.flags & CC_IN_80387)) - return AS1 (jae,%l0); - - OUTPUT_JUMP ("jg %l0", "ja %l0", NULL_PTR); -} -} - -static char * -output_221 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - return AS1 (jmp,%*%0); -} -} - -static char * -output_223 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4]; - - xops[0] = operands[0]; - xops[1] = operands[1]; - xops[2] = operands[2]; - xops[3] = pic_offset_table_rtx; - - output_asm_insn (AS2 (mov%L2,%3,%2), xops); - output_asm_insn ("sub%L2 %l1@GOTOFF(%3,%0,4),%2", xops); - output_asm_insn (AS1 (jmp,%*%2), xops); - ASM_OUTPUT_ALIGN_CODE (asm_out_file); - RET; -} -} - -static char * -output_224 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - CC_STATUS_INIT; - - return AS1 (jmp,%*%0); -} -} - -static char * -output_226 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM - && ! CONSTANT_ADDRESS_P (XEXP (operands[0], 0))) - { - operands[0] = XEXP (operands[0], 0); - return AS1 (call,%*%0); - } - else - return AS1 (call,%P0); -} -} - -static char * -output_229 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[0]) == MEM - && ! CONSTANT_ADDRESS_P (XEXP (operands[0], 0))) - { - operands[0] = XEXP (operands[0], 0); - return AS1 (call,%*%0); - } - else - return AS1 (call,%P0); -} -} - -static char * -output_232 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == MEM - && ! CONSTANT_ADDRESS_P (XEXP (operands[1], 0))) - { - operands[1] = XEXP (operands[1], 0); - output_asm_insn (AS1 (call,%*%1), operands); - } - else - output_asm_insn (AS1 (call,%P1), operands); - - RET; -} -} - -static char * -output_235 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - if (GET_CODE (operands[1]) == MEM - && ! CONSTANT_ADDRESS_P (XEXP (operands[1], 0))) - { - operands[1] = XEXP (operands[1], 0); - output_asm_insn (AS1 (call,%*%1), operands); - } - else - output_asm_insn (AS1 (call,%P1), operands); - - RET; -} -} - -static char * -output_238 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx addr = operands[1]; - - if (GET_CODE (operands[0]) == MEM - && ! CONSTANT_ADDRESS_P (XEXP (operands[0], 0))) - { - operands[0] = XEXP (operands[0], 0); - output_asm_insn (AS1 (call,%*%0), operands); - } - else - output_asm_insn (AS1 (call,%P0), operands); - - operands[2] = gen_rtx (REG, SImode, 0); - output_asm_insn (AS2 (mov%L2,%2,%1), operands); - - operands[2] = gen_rtx (REG, SImode, 1); - operands[1] = adj_offsettable_operand (addr, 4); - output_asm_insn (AS2 (mov%L2,%2,%1), operands); - - operands[1] = adj_offsettable_operand (addr, 8); - return AS1 (fnsave,%1); -} -} - -static char * -output_239 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx addr = operands[1]; - - output_asm_insn (AS1 (call,%P0), operands); - - operands[2] = gen_rtx (REG, SImode, 0); - output_asm_insn (AS2 (mov%L2,%2,%1), operands); - - operands[2] = gen_rtx (REG, SImode, 1); - operands[1] = adj_offsettable_operand (addr, 4); - output_asm_insn (AS2 (mov%L2,%2,%1), operands); - - operands[1] = adj_offsettable_operand (addr, 8); - return AS1 (fnsave,%1); -} -} - -static char * -output_242 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - function_epilogue (asm_out_file, get_frame_size ()); - RET; -} -} - -static char * -output_245 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2]; - - output_asm_insn ("cld", operands); - if (GET_CODE (operands[2]) == CONST_INT) - { - if (INTVAL (operands[2]) & ~0x03) - { - xops[0] = GEN_INT ((INTVAL (operands[2]) >> 2) & 0x3fffffff); - xops[1] = operands[4]; - - output_asm_insn (AS2 (mov%L1,%0,%1), xops); -#ifdef INTEL_SYNTAX - output_asm_insn ("rep movsd", xops); -#else - output_asm_insn ("rep\n\tmovsl", xops); -#endif - } - if (INTVAL (operands[2]) & 0x02) - output_asm_insn ("movsw", operands); - if (INTVAL (operands[2]) & 0x01) - output_asm_insn ("movsb", operands); - } - else - abort (); - RET; -} -} - -static char * -output_247 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[4], label; - - label = gen_label_rtx (); - - output_asm_insn ("cld", operands); - output_asm_insn (AS2 (xor%L0,%0,%0), operands); - output_asm_insn ("repz\n\tcmps%B2", operands); - output_asm_insn ("je %l0", &label); - - xops[0] = operands[0]; - xops[1] = gen_rtx (MEM, QImode, - gen_rtx (PLUS, SImode, operands[1], constm1_rtx)); - xops[2] = gen_rtx (MEM, QImode, - gen_rtx (PLUS, SImode, operands[2], constm1_rtx)); - xops[3] = operands[3]; - - output_asm_insn (AS2 (movz%B1%L0,%1,%0), xops); - output_asm_insn (AS2 (movz%B2%L3,%2,%3), xops); - - output_asm_insn (AS2 (sub%L0,%3,%0), xops); - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (label)); - RET; -} -} - -static char * -output_248 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2]; - - cc_status.flags |= CC_NOT_SIGNED; - - xops[0] = gen_rtx (REG, QImode, 0); - xops[1] = CONST0_RTX (QImode); - - output_asm_insn ("cld", operands); - output_asm_insn (AS2 (test%B0,%1,%0), xops); - return "repz\n\tcmps%B2"; -} -} - -static char * -output_250 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2]; - - xops[0] = const1_rtx; - xops[1] = operands[1]; - output_asm_insn (AS2 (bsf%L1,%1,%0), operands); - output_asm_insn (AS2 (cmp%L1,%0,%1), xops); - output_asm_insn (AS2 (sbb%L0,%2,%2), operands); - output_asm_insn (AS2 (or%L0,%2,%0), operands); - return ""; -} -} - -static char * -output_252 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2]; - - xops[0] = const1_rtx; - xops[1] = operands[1]; - output_asm_insn (AS2 (bsf%W1,%1,%0), operands); - output_asm_insn (AS2 (cmp%W1,%0,%1), xops); - output_asm_insn (AS2 (sbb%W0,%2,%2), operands); - output_asm_insn (AS2 (or%W0,%2,%0), operands); - return ""; -} -} - -static char * -output_253 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_254 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_255 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_256 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_257 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_258 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_259 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_260 (operands, insn) - rtx *operands; - rtx insn; -{ - return (char *) output_387_binary_op (insn, operands); -} - -static char * -output_262 (operands, insn) - rtx *operands; - rtx insn; -{ - -{ - rtx xops[2]; - - xops[0] = operands[0]; - xops[1] = constm1_rtx; - output_asm_insn ("cld", operands); - output_asm_insn (AS2 (mov%L0,%1,%0), xops); - return "repnz\n\tscas%B2"; -} -} - -char * const insn_template[] = - { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "push%L0 %1", - "push%L0 %1", - 0, - 0, - "push%W0 %1", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "mul%B0 %2", - 0, - 0, - "idiv%B0 %2", - "div%B0 %2", - 0, - 0, - 0, - "cwtd\n\tidiv%W0 %2", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "neg%L0 %0", - "neg%W0 %0", - "neg%B0 %0", - "fchs", - "fchs", - "fchs", - "fabs", - "fabs", - "fabs", - "fsqrt", - "fsqrt", - "fsqrt", - "fsin", - "fsin", - "fsin", - "fcos", - "fcos", - "fcos", - "not%L0 %0", - "not%W0 %0", - "not%B0 %0", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - "ja %l0", - 0, - 0, - 0, - "jb %l0", - 0, - 0, - 0, - "jae %l0", - 0, - 0, - 0, - "jbe %l0", - 0, - 0, - 0, - "jbe %l0", - 0, - "jae %l0", - 0, - "jb %l0", - 0, - "ja %l0", - "jmp %l0", - 0, - 0, - 0, - 0, - 0, - 0, - "call %P0", - 0, - 0, - "call %P0", - 0, - 0, - "call %P1", - 0, - 0, - "call %P1", - 0, - 0, - 0, - 0, - "frstor %0", - 0, - "nop", - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - }; - -char *(*const insn_outfun[])() = - { - output_0, - 0, - output_2, - 0, - output_4, - 0, - output_6, - 0, - output_8, - 0, - output_10, - 0, - output_12, - 0, - output_14, - 0, - output_16, - output_17, - output_18, - output_19, - output_20, - output_21, - output_22, - output_23, - output_24, - output_25, - 0, - 0, - 0, - 0, - 0, - 0, - output_32, - output_33, - output_34, - 0, - 0, - 0, - output_38, - 0, - output_40, - output_41, - output_42, - output_43, - output_44, - output_45, - output_46, - output_47, - output_48, - output_49, - output_50, - output_51, - output_52, - output_53, - output_54, - output_55, - output_56, - output_57, - output_58, - output_59, - output_60, - 0, - output_62, - 0, - 0, - 0, - 0, - output_67, - output_68, - 0, - 0, - output_71, - output_72, - 0, - 0, - 0, - 0, - output_77, - output_78, - output_79, - output_80, - output_81, - output_82, - output_83, - output_84, - output_85, - 0, - 0, - output_88, - output_89, - output_90, - output_91, - 0, - 0, - output_94, - output_95, - output_96, - output_97, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_105, - 0, - output_107, - output_108, - output_109, - output_110, - output_111, - output_112, - output_113, - output_114, - output_115, - output_116, - output_117, - output_118, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - output_141, - output_142, - output_143, - output_144, - output_145, - 0, - output_147, - output_148, - output_149, - output_150, - output_151, - 0, - output_153, - output_154, - output_155, - output_156, - output_157, - output_158, - output_159, - output_160, - output_161, - output_162, - output_163, - output_164, - output_165, - output_166, - output_167, - output_168, - output_169, - 0, - output_171, - 0, - output_173, - 0, - output_175, - 0, - output_177, - 0, - output_179, - 0, - output_181, - 0, - output_183, - 0, - output_185, - 0, - output_187, - 0, - output_189, - 0, - output_191, - 0, - output_193, - 0, - output_195, - 0, - 0, - 0, - output_199, - 0, - 0, - 0, - output_203, - 0, - 0, - 0, - output_207, - 0, - 0, - output_210, - output_211, - output_212, - 0, - output_214, - 0, - output_216, - 0, - output_218, - 0, - 0, - output_221, - 0, - output_223, - output_224, - 0, - output_226, - 0, - 0, - output_229, - 0, - 0, - output_232, - 0, - 0, - output_235, - 0, - 0, - output_238, - output_239, - 0, - 0, - output_242, - 0, - 0, - output_245, - 0, - output_247, - output_248, - 0, - output_250, - 0, - output_252, - output_253, - output_254, - output_255, - output_256, - output_257, - output_258, - output_259, - output_260, - 0, - output_262, - }; - -rtx (*const insn_gen_function[]) () = - { - gen_tstsi_1, - gen_tstsi, - gen_tsthi_1, - gen_tsthi, - gen_tstqi_1, - gen_tstqi, - gen_tstsf_cc, - gen_tstsf, - gen_tstdf_cc, - gen_tstdf, - gen_cmpsi_1, - gen_cmpsi, - gen_cmphi_1, - gen_cmphi, - gen_cmpqi_1, - gen_cmpqi, - 0, - 0, - 0, - 0, - 0, - 0, - gen_cmpsf_cc_1, - 0, - 0, - 0, - gen_cmpdf, - gen_cmpsf, - gen_cmpdf_cc, - gen_cmpdf_ccfpeq, - gen_cmpsf_cc, - gen_cmpsf_ccfpeq, - 0, - 0, - 0, - 0, - 0, - gen_movsi, - 0, - 0, - gen_movhi, - gen_movstricthi, - 0, - gen_movqi, - gen_movstrictqi, - 0, - gen_movsf, - 0, - gen_swapdf, - gen_movdf, - 0, - gen_movdi, - gen_zero_extendhisi2, - gen_zero_extendqihi2, - gen_zero_extendqisi2, - gen_zero_extendsidi2, - gen_extendsidi2, - gen_extendhisi2, - gen_extendqihi2, - gen_extendqisi2, - gen_extendsfdf2, - gen_truncdfsf2, - 0, - gen_fixuns_truncdfsi2, - gen_fixuns_truncsfsi2, - gen_fix_truncdfdi2, - gen_fix_truncsfdi2, - 0, - 0, - gen_fix_truncdfsi2, - gen_fix_truncsfsi2, - 0, - 0, - gen_floatsisf2, - gen_floatdisf2, - gen_floatsidf2, - gen_floatdidf2, - 0, - 0, - 0, - 0, - gen_adddi3, - gen_addsi3, - gen_addhi3, - gen_addqi3, - 0, - gen_adddf3, - gen_addsf3, - gen_subdi3, - gen_subsi3, - gen_subhi3, - gen_subqi3, - gen_subdf3, - gen_subsf3, - 0, - gen_mulhi3, - 0, - gen_mulsi3, - 0, - gen_muldf3, - gen_mulsf3, - gen_divqi3, - gen_udivqi3, - gen_divdf3, - gen_divsf3, - gen_divmodsi4, - gen_divmodhi4, - gen_udivmodsi4, - gen_udivmodhi4, - gen_andsi3, - gen_andhi3, - gen_andqi3, - gen_iorsi3, - gen_iorhi3, - gen_iorqi3, - gen_xorsi3, - gen_xorhi3, - gen_xorqi3, - gen_negdi2, - gen_negsi2, - gen_neghi2, - gen_negqi2, - gen_negsf2, - gen_negdf2, - 0, - gen_abssf2, - gen_absdf2, - 0, - gen_sqrtsf2, - gen_sqrtdf2, - 0, - gen_sindf2, - gen_sinsf2, - 0, - gen_cosdf2, - gen_cossf2, - 0, - gen_one_cmplsi2, - gen_one_cmplhi2, - gen_one_cmplqi2, - gen_ashldi3, - gen_ashldi3_const_int, - gen_ashldi3_non_const_int, - gen_ashlsi3, - gen_ashlhi3, - gen_ashlqi3, - gen_ashrdi3, - gen_ashrdi3_const_int, - gen_ashrdi3_non_const_int, - gen_ashrsi3, - gen_ashrhi3, - gen_ashrqi3, - gen_lshrdi3, - gen_lshrdi3_const_int, - gen_lshrdi3_non_const_int, - gen_lshrsi3, - gen_lshrhi3, - gen_lshrqi3, - gen_rotlsi3, - gen_rotlhi3, - gen_rotlqi3, - gen_rotrsi3, - gen_rotrhi3, - gen_rotrqi3, - 0, - 0, - 0, - 0, - 0, - 0, - gen_seq, - 0, - gen_sne, - 0, - gen_sgt, - 0, - gen_sgtu, - 0, - gen_slt, - 0, - gen_sltu, - 0, - gen_sge, - 0, - gen_sgeu, - 0, - gen_sle, - 0, - gen_sleu, - 0, - gen_beq, - 0, - gen_bne, - 0, - gen_bgt, - 0, - gen_bgtu, - 0, - gen_blt, - 0, - gen_bltu, - 0, - gen_bge, - 0, - gen_bgeu, - 0, - gen_ble, - 0, - gen_bleu, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_jump, - gen_indirect_jump, - gen_casesi, - 0, - gen_tablejump, - gen_call_pop, - 0, - 0, - gen_call, - 0, - 0, - gen_call_value_pop, - 0, - 0, - gen_call_value, - 0, - 0, - gen_untyped_call, - 0, - 0, - gen_untyped_return, - gen_update_return, - gen_return, - gen_nop, - gen_movstrsi, - 0, - gen_cmpstrsi, - 0, - 0, - gen_ffssi2, - 0, - gen_ffshi2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - gen_strlensi, - 0, - }; - -char *insn_name[] = - { - "tstsi_1", - "tstsi", - "tsthi_1", - "tsthi", - "tstqi_1", - "tstqi", - "tstsf_cc", - "tstsf", - "tstdf_cc", - "tstdf", - "cmpsi_1", - "cmpsi", - "cmphi_1", - "cmphi", - "cmpqi_1", - "cmpqi", - "cmpqi+1", - "cmpqi+2", - "cmpqi+3", - "cmpsf_cc_1-3", - "cmpsf_cc_1-2", - "cmpsf_cc_1-1", - "cmpsf_cc_1", - "cmpsf_cc_1+1", - "cmpsf_cc_1+2", - "cmpdf-1", - "cmpdf", - "cmpsf", - "cmpdf_cc", - "cmpdf_ccfpeq", - "cmpsf_cc", - "cmpsf_ccfpeq", - "cmpsf_ccfpeq+1", - "cmpsf_ccfpeq+2", - "cmpsf_ccfpeq+3", - "movsi-2", - "movsi-1", - "movsi", - "movsi+1", - "movhi-1", - "movhi", - "movstricthi", - "movstricthi+1", - "movqi", - "movstrictqi", - "movstrictqi+1", - "movsf", - "movsf+1", - "swapdf", - "movdf", - "movdf+1", - "movdi", - "zero_extendhisi2", - "zero_extendqihi2", - "zero_extendqisi2", - "zero_extendsidi2", - "extendsidi2", - "extendhisi2", - "extendqihi2", - "extendqisi2", - "extendsfdf2", - "truncdfsf2", - "truncdfsf2+1", - "fixuns_truncdfsi2", - "fixuns_truncsfsi2", - "fix_truncdfdi2", - "fix_truncsfdi2", - "fix_truncsfdi2+1", - "fix_truncdfsi2-1", - "fix_truncdfsi2", - "fix_truncsfsi2", - "fix_truncsfsi2+1", - "floatsisf2-1", - "floatsisf2", - "floatdisf2", - "floatsidf2", - "floatdidf2", - "floatdidf2+1", - "floatdidf2+2", - "adddi3-2", - "adddi3-1", - "adddi3", - "addsi3", - "addhi3", - "addqi3", - "addqi3+1", - "adddf3", - "addsf3", - "subdi3", - "subsi3", - "subhi3", - "subqi3", - "subdf3", - "subsf3", - "subsf3+1", - "mulhi3", - "mulhi3+1", - "mulsi3", - "mulsi3+1", - "muldf3", - "mulsf3", - "divqi3", - "udivqi3", - "divdf3", - "divsf3", - "divmodsi4", - "divmodhi4", - "udivmodsi4", - "udivmodhi4", - "andsi3", - "andhi3", - "andqi3", - "iorsi3", - "iorhi3", - "iorqi3", - "xorsi3", - "xorhi3", - "xorqi3", - "negdi2", - "negsi2", - "neghi2", - "negqi2", - "negsf2", - "negdf2", - "negdf2+1", - "abssf2", - "absdf2", - "absdf2+1", - "sqrtsf2", - "sqrtdf2", - "sqrtdf2+1", - "sindf2", - "sinsf2", - "sinsf2+1", - "cosdf2", - "cossf2", - "cossf2+1", - "one_cmplsi2", - "one_cmplhi2", - "one_cmplqi2", - "ashldi3", - "ashldi3_const_int", - "ashldi3_non_const_int", - "ashlsi3", - "ashlhi3", - "ashlqi3", - "ashrdi3", - "ashrdi3_const_int", - "ashrdi3_non_const_int", - "ashrsi3", - "ashrhi3", - "ashrqi3", - "lshrdi3", - "lshrdi3_const_int", - "lshrdi3_non_const_int", - "lshrsi3", - "lshrhi3", - "lshrqi3", - "rotlsi3", - "rotlhi3", - "rotlqi3", - "rotrsi3", - "rotrhi3", - "rotrqi3", - "rotrqi3+1", - "rotrqi3+2", - "rotrqi3+3", - "seq-3", - "seq-2", - "seq-1", - "seq", - "seq+1", - "sne", - "sne+1", - "sgt", - "sgt+1", - "sgtu", - "sgtu+1", - "slt", - "slt+1", - "sltu", - "sltu+1", - "sge", - "sge+1", - "sgeu", - "sgeu+1", - "sle", - "sle+1", - "sleu", - "sleu+1", - "beq", - "beq+1", - "bne", - "bne+1", - "bgt", - "bgt+1", - "bgtu", - "bgtu+1", - "blt", - "blt+1", - "bltu", - "bltu+1", - "bge", - "bge+1", - "bgeu", - "bgeu+1", - "ble", - "ble+1", - "bleu", - "bleu+1", - "bleu+2", - "bleu+3", - "bleu+4", - "bleu+5", - "bleu+6", - "jump-5", - "jump-4", - "jump-3", - "jump-2", - "jump-1", - "jump", - "indirect_jump", - "casesi", - "casesi+1", - "tablejump", - "call_pop", - "call_pop+1", - "call-1", - "call", - "call+1", - "call_value_pop-1", - "call_value_pop", - "call_value_pop+1", - "call_value-1", - "call_value", - "call_value+1", - "untyped_call-1", - "untyped_call", - "untyped_call+1", - "untyped_return-1", - "untyped_return", - "update_return", - "return", - "nop", - "movstrsi", - "movstrsi+1", - "cmpstrsi", - "cmpstrsi+1", - "ffssi2-1", - "ffssi2", - "ffssi2+1", - "ffshi2", - "ffshi2+1", - "ffshi2+2", - "ffshi2+3", - "ffshi2+4", - "ffshi2+5", - "strlensi-4", - "strlensi-3", - "strlensi-2", - "strlensi-1", - "strlensi", - "strlensi+1", - }; -char **insn_name_ptr = insn_name; - -const int insn_n_operands[] = - { - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 4, - 4, - 4, - 4, - 4, - 3, - 4, - 4, - 4, - 3, - 2, - 2, - 3, - 3, - 3, - 3, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 8, - 8, - 6, - 6, - 5, - 5, - 5, - 5, - 5, - 5, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 4, - 4, - 4, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 3, - 3, - 2, - 3, - 3, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 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, - 1, - 7, - 3, - 1, - 4, - 4, - 4, - 2, - 2, - 2, - 5, - 5, - 5, - 3, - 3, - 3, - 3, - 3, - 3, - 2, - 1, - 0, - 0, - 5, - 5, - 5, - 5, - 4, - 3, - 3, - 3, - 3, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - }; - -const int insn_n_dups[] = - { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 7, - 7, - 5, - 5, - 1, - 1, - 2, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 2, - 2, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 2, - 3, - 3, - 3, - 2, - 0, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 5, - 1, - }; - -char *const insn_operand_constraint[][MAX_RECOG_OPERANDS] = - { - { "rm", }, - { "", }, - { "rm", }, - { "", }, - { "qm", }, - { "", }, - { "f", "=a", }, - { "", "", }, - { "f", "=a", }, - { "", "", }, - { "mr,r", "ri,mr", }, - { "", "", }, - { "mr,r", "ri,mr", }, - { "", "", }, - { "q,mq", "qm,nq", }, - { "", "", }, - { "f,fm", "fm,f", "", "=a,a", }, - { "f", "rm", "", "=a", }, - { "rm", "f", "", "=a", }, - { "f", "fm", "", "=a", }, - { "fm", "f", "", "=a", }, - { "f", "f", "=a", }, - { "f,fm", "fm,f", "", "=a,a", }, - { "f", "rm", "", "=a", }, - { "rm", "f", "", "=a", }, - { "f", "f", "=a", }, - { "", "", }, - { "", "", }, - { "", "", "", }, - { "", "", "", }, - { "", "", "", }, - { "", "", "", }, - { "%ro", "ri", }, - { "%ro", "ri", }, - { "%qm", "qi", }, - { "=<", "g", }, - { "=<", "ri", }, - { "", "", }, - { "=g,r", "ri,m", }, - { "=<", "g", }, - { "=g,r", "ri,m", }, - { "+g,r", "ri,m", }, - { "=<", "q", }, - { "=q,*r,qm", "*g,q,qn", }, - { "+q,qm", "*g,qn", }, - { "=<,<", "gF,f", }, - { "=*rfm,*rf,f,!*rm", "*rf,*rfm,fG,fF", }, - { "=<,<", "gF,f", }, - { "f", "f", }, - { "=*rfm,*rf,f,!*rm", "*rf,*rfm,fG,fF", }, - { "=<", "roiF", }, - { "=r,rm", "m,riF", }, - { "=r", "rm", }, - { "=r", "qm", }, - { "=r", "qm", }, - { "=r", "0", }, - { "=r", "0", }, - { "=r", "rm", }, - { "=r", "qm", }, - { "=r", "qm", }, - { "=fm,f", "f,fm", }, - { "", "", }, - { "=f,m", "0,f", "m,m", }, - { "", "", "", "", "", "", "", "", }, - { "", "", "", "", "", "", "", "", }, - { "", "", "", "", "", "", }, - { "", "", "", "", "", "", }, - { "=rm", "f", "m", "m", "=&q", }, - { "=rm", "f", "m", "m", "=&q", }, - { "", "", "", "", "", }, - { "", "", "", "", "", }, - { "=rm", "f", "m", "m", "=&q", }, - { "=rm", "f", "m", "m", "=&q", }, - { "", "", }, - { "", "", }, - { "", "", }, - { "", "", }, - { "=f", "rm", }, - { "=f", "rm", }, - { "=f", "rm", }, - { "=f", "rm", }, - { "=&r,ro", "%0,0", "o,riF", }, - { "=?r,rm,r", "%r,0,0", "ri,ri,rm", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=qm,q", "%0,0", "qn,qmn", }, - { "=r", "p", }, - { "", "", "", }, - { "", "", "", }, - { "=&r,ro", "0,0", "o,riF", }, - { "=rm,r", "0,0", "ri,rm", }, - { "=rm,r", "0,0", "ri,rm", }, - { "=qm,q", "0,0", "qn,qmn", }, - { "", "", "", }, - { "", "", "", }, - { "=r", "%0", "r", }, - { "=r,r", "%0,rm", "g,i", }, - { "=r", "%0", "r", }, - { "=r,r", "%0,rm", "g,i", }, - { "=a", "%0", "qm", }, - { "", "", "", }, - { "", "", "", }, - { "=a", "0", "qm", }, - { "=a", "0", "qm", }, - { "", "", "", }, - { "", "", "", }, - { "=a", "0", "rm", "=&d", }, - { "=a", "0", "rm", "=&d", }, - { "=a", "0", "rm", "=&d", }, - { "=a", "0", "rm", "=&d", }, - { "=r,r,rm,r", "%rm,qm,0,0", "L,K,ri,rm", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=qm,q", "%0,0", "qn,qmn", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=qm,q", "%0,0", "qn,qmn", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=rm,r", "%0,0", "ri,rm", }, - { "=qm,q", "%0,0", "qn,qm", }, - { "=&ro", "0", }, - { "=rm", "0", }, - { "=rm", "0", }, - { "=qm", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=f", "0", }, - { "=rm", "0", }, - { "=rm", "0", }, - { "=qm", "0", }, - { "", "", "", }, - { "=&r", "0", "J", }, - { "=&r", "0", "c", }, - { "=r,rm", "r,0", "M,cI", }, - { "=rm", "0", "cI", }, - { "=qm", "0", "cI", }, - { "", "", "", }, - { "=&r", "0", "J", }, - { "=&r", "0", "c", }, - { "=rm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=qm", "0", "cI", }, - { "", "", "", }, - { "=&r", "0", "J", }, - { "=&r", "0", "c", }, - { "=rm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=qm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=qm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=rm", "0", "cI", }, - { "=qm", "0", "cI", }, - { "+rm", "", "r", "n", }, - { "=rm", "r", "0", }, - { "=rm", "0", "r", }, - { "r", "r", }, - { "r", "n", "n", }, - { "rm", "n", "n", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { "", }, - { "=q", }, - { 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 }, - { "rm", }, - { "", "", "", "", "", "", "", }, - { "r", "", "=&r", }, - { "rm", }, - { "", "", "", "", }, - { "m", "g", "", "i", }, - { "", "g", "", "i", }, - { "", "", }, - { "m", "g", }, - { "", "g", }, - { "", "", "", "", "", }, - { "=rf", "m", "g", "", "i", }, - { "=rf", "", "g", "", "i", }, - { "", "", "", }, - { "=rf", "m", "g", }, - { "=rf", "", "g", }, - { "", "", "", }, - { "m", "o", "", }, - { "", "o", "", }, - { "", "", }, - { "m", }, - { 0 }, - { 0 }, - { "", "", "", "", "", }, - { "D", "S", "n", "i", "=&c", }, - { "", "", "", "", "", }, - { "=&r", "S", "D", "c", "i", }, - { "S", "D", "c", "i", }, - { "", "", "", }, - { "=&r", "rm", "=r", }, - { "", "", "", }, - { "=&r", "rm", "=r", }, - { "=f,f", "0,fm", "fm,0", "", }, - { "=f", "rm", "0", "", }, - { "=f,f", "fm,0", "0,f", "", }, - { "=f", "0", "rm", "", }, - { "=f,f", "0,f", "fm,0", "", }, - { "=f,f", "0,fm", "fm,0", "", }, - { "=f", "rm", "0", "", }, - { "=f", "0", "rm", "", }, - { "", "", "", "", }, - { "=&c", "D", "a", "i", }, - }; - -const enum machine_mode insn_operand_mode[][MAX_RECOG_OPERANDS] = - { - { SImode, }, - { SImode, }, - { HImode, }, - { HImode, }, - { QImode, }, - { QImode, }, - { SFmode, HImode, }, - { SFmode, HImode, }, - { DFmode, HImode, }, - { DFmode, HImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { DFmode, DFmode, VOIDmode, HImode, }, - { DFmode, SImode, VOIDmode, HImode, }, - { SImode, DFmode, VOIDmode, HImode, }, - { DFmode, SFmode, VOIDmode, HImode, }, - { SFmode, DFmode, VOIDmode, HImode, }, - { DFmode, DFmode, HImode, }, - { SFmode, SFmode, VOIDmode, HImode, }, - { SFmode, SImode, VOIDmode, HImode, }, - { SImode, SFmode, VOIDmode, HImode, }, - { SFmode, SFmode, HImode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, HImode, }, - { DFmode, DFmode, HImode, }, - { SFmode, SFmode, HImode, }, - { SFmode, SFmode, HImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { QImode, QImode, }, - { SFmode, SFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { DFmode, DFmode, }, - { DImode, DImode, }, - { DImode, DImode, }, - { SImode, HImode, }, - { HImode, QImode, }, - { SImode, QImode, }, - { DImode, SImode, }, - { DImode, SImode, }, - { SImode, HImode, }, - { HImode, QImode, }, - { SImode, QImode, }, - { DFmode, SFmode, }, - { SFmode, DFmode, }, - { SFmode, DFmode, SFmode, }, - { SImode, DFmode, VOIDmode, VOIDmode, VOIDmode, VOIDmode, VOIDmode, SImode, }, - { SImode, SFmode, VOIDmode, VOIDmode, VOIDmode, VOIDmode, VOIDmode, SImode, }, - { DImode, DFmode, VOIDmode, VOIDmode, VOIDmode, SImode, }, - { DImode, SFmode, VOIDmode, VOIDmode, VOIDmode, SImode, }, - { DImode, DFmode, SImode, SImode, SImode, }, - { DImode, SFmode, SImode, SImode, SImode, }, - { SImode, DFmode, VOIDmode, VOIDmode, SImode, }, - { SImode, SFmode, VOIDmode, VOIDmode, SImode, }, - { SImode, DFmode, SImode, SImode, SImode, }, - { SImode, SFmode, SImode, SImode, SImode, }, - { SFmode, SImode, }, - { SFmode, DImode, }, - { DFmode, SImode, }, - { DFmode, DImode, }, - { DFmode, DImode, }, - { SFmode, DImode, }, - { DFmode, SImode, }, - { SFmode, SImode, }, - { DImode, DImode, DImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { DImode, DImode, DImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, HImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, QImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { QImode, HImode, QImode, }, - { QImode, HImode, QImode, }, - { DFmode, DFmode, DFmode, }, - { SFmode, SFmode, SFmode, }, - { SImode, SImode, SImode, SImode, }, - { HImode, HImode, HImode, HImode, }, - { SImode, SImode, SImode, SImode, }, - { HImode, HImode, HImode, HImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { DImode, DImode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, SFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, SFmode, }, - { SFmode, SFmode, }, - { DFmode, DFmode, }, - { DFmode, SFmode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { DFmode, SFmode, }, - { DFmode, DFmode, }, - { SFmode, SFmode, }, - { DFmode, SFmode, }, - { SImode, SImode, }, - { HImode, HImode, }, - { QImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { DImode, DImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { QImode, QImode, QImode, }, - { SImode, VOIDmode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, }, - { SImode, SImode, SImode, }, - { QImode, SImode, SImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { QImode, }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { VOIDmode }, - { SImode, }, - { SImode, SImode, SImode, VOIDmode, VOIDmode, VOIDmode, SImode, }, - { SImode, VOIDmode, SImode, }, - { SImode, }, - { QImode, SImode, VOIDmode, SImode, }, - { QImode, SImode, VOIDmode, SImode, }, - { SImode, SImode, VOIDmode, SImode, }, - { QImode, SImode, }, - { QImode, SImode, }, - { SImode, SImode, }, - { VOIDmode, QImode, SImode, VOIDmode, SImode, }, - { VOIDmode, QImode, SImode, VOIDmode, SImode, }, - { VOIDmode, SImode, SImode, VOIDmode, SImode, }, - { VOIDmode, QImode, SImode, }, - { VOIDmode, QImode, SImode, }, - { VOIDmode, SImode, SImode, }, - { QImode, BLKmode, VOIDmode, }, - { QImode, DImode, VOIDmode, }, - { SImode, DImode, VOIDmode, }, - { BLKmode, VOIDmode, }, - { SImode, }, - { VOIDmode }, - { VOIDmode }, - { BLKmode, BLKmode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, SImode, }, - { SImode, BLKmode, BLKmode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { SImode, SImode, SImode, }, - { HImode, HImode, HImode, }, - { HImode, HImode, HImode, }, - { DFmode, DFmode, DFmode, DFmode, }, - { DFmode, SImode, DFmode, DFmode, }, - { DFmode, SFmode, DFmode, DFmode, }, - { DFmode, DFmode, SImode, DFmode, }, - { DFmode, DFmode, SFmode, DFmode, }, - { SFmode, SFmode, SFmode, SFmode, }, - { SFmode, SImode, SFmode, SFmode, }, - { SFmode, SFmode, SImode, SFmode, }, - { SImode, BLKmode, QImode, SImode, }, - { SImode, SImode, QImode, SImode, }, - }; - -const char insn_operand_strict_low[][MAX_RECOG_OPERANDS] = - { - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 1, 0, }, - { 0, 0, }, - { 0, 0, }, - { 1, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0, }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0 }, - { 0, }, - { 0, 0, 0, 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, }, - { 0, }, - { 0 }, - { 0 }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - { 0, 0, 0, 0, }, - }; - -extern int nonimmediate_operand (); -extern int register_operand (); -extern int scratch_operand (); -extern int general_operand (); -extern int VOIDmode_compare_op (); -extern int push_operand (); -extern int memory_operand (); -extern int address_operand (); -extern int nonmemory_operand (); -extern int const_int_operand (); -extern int indirect_operand (); -extern int immediate_operand (); -extern int call_insn_operand (); -extern int symbolic_operand (); -extern int binary_387_op (); - -int (*const insn_operand_predicate[][MAX_RECOG_OPERANDS])() = - { - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { nonimmediate_operand, }, - { register_operand, scratch_operand, }, - { register_operand, scratch_operand, }, - { register_operand, scratch_operand, }, - { register_operand, scratch_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, general_operand, }, - { nonimmediate_operand, nonimmediate_operand, VOIDmode_compare_op, scratch_operand, }, - { register_operand, nonimmediate_operand, VOIDmode_compare_op, scratch_operand, }, - { nonimmediate_operand, register_operand, VOIDmode_compare_op, scratch_operand, }, - { register_operand, nonimmediate_operand, VOIDmode_compare_op, scratch_operand, }, - { nonimmediate_operand, register_operand, VOIDmode_compare_op, scratch_operand, }, - { register_operand, register_operand, scratch_operand, }, - { nonimmediate_operand, nonimmediate_operand, VOIDmode_compare_op, scratch_operand, }, - { register_operand, nonimmediate_operand, VOIDmode_compare_op, scratch_operand, }, - { nonimmediate_operand, register_operand, VOIDmode_compare_op, scratch_operand, }, - { register_operand, register_operand, scratch_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, register_operand, scratch_operand, }, - { register_operand, register_operand, scratch_operand, }, - { register_operand, register_operand, scratch_operand, }, - { register_operand, register_operand, scratch_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { register_operand, register_operand, }, - { general_operand, general_operand, }, - { push_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, nonimmediate_operand, }, - { general_operand, general_operand, }, - { nonimmediate_operand, register_operand, }, - { nonimmediate_operand, register_operand, memory_operand, }, - { general_operand, register_operand, 0, 0, 0, 0, 0, scratch_operand, }, - { general_operand, register_operand, 0, 0, 0, 0, 0, scratch_operand, }, - { general_operand, register_operand, 0, 0, 0, scratch_operand, }, - { general_operand, register_operand, 0, 0, 0, scratch_operand, }, - { general_operand, register_operand, memory_operand, memory_operand, scratch_operand, }, - { general_operand, register_operand, memory_operand, memory_operand, scratch_operand, }, - { general_operand, register_operand, 0, 0, scratch_operand, }, - { general_operand, register_operand, 0, 0, scratch_operand, }, - { general_operand, register_operand, memory_operand, memory_operand, scratch_operand, }, - { general_operand, register_operand, memory_operand, memory_operand, scratch_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { register_operand, address_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, }, - { register_operand, register_operand, general_operand, register_operand, }, - { register_operand, register_operand, general_operand, register_operand, }, - { register_operand, register_operand, general_operand, register_operand, }, - { register_operand, register_operand, general_operand, register_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { register_operand, register_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { general_operand, general_operand, }, - { register_operand, register_operand, nonmemory_operand, }, - { register_operand, register_operand, const_int_operand, }, - { register_operand, register_operand, register_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { register_operand, register_operand, nonmemory_operand, }, - { register_operand, register_operand, const_int_operand, }, - { register_operand, register_operand, register_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { register_operand, register_operand, nonmemory_operand, }, - { register_operand, register_operand, const_int_operand, }, - { register_operand, register_operand, register_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, general_operand, nonmemory_operand, }, - { general_operand, 0, general_operand, const_int_operand, }, - { general_operand, general_operand, general_operand, }, - { general_operand, general_operand, general_operand, }, - { register_operand, general_operand, }, - { register_operand, const_int_operand, const_int_operand, }, - { general_operand, const_int_operand, const_int_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { register_operand, }, - { 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 }, - { general_operand, }, - { general_operand, general_operand, general_operand, 0, 0, 0, scratch_operand, }, - { register_operand, 0, scratch_operand, }, - { general_operand, }, - { indirect_operand, general_operand, 0, immediate_operand, }, - { call_insn_operand, general_operand, 0, immediate_operand, }, - { symbolic_operand, general_operand, 0, immediate_operand, }, - { indirect_operand, general_operand, }, - { call_insn_operand, general_operand, }, - { symbolic_operand, general_operand, }, - { 0, indirect_operand, general_operand, 0, immediate_operand, }, - { 0, call_insn_operand, general_operand, 0, immediate_operand, }, - { 0, symbolic_operand, general_operand, 0, immediate_operand, }, - { 0, indirect_operand, general_operand, }, - { 0, call_insn_operand, general_operand, }, - { 0, symbolic_operand, general_operand, }, - { indirect_operand, memory_operand, 0, }, - { call_insn_operand, memory_operand, 0, }, - { symbolic_operand, memory_operand, 0, }, - { memory_operand, 0, }, - { memory_operand, }, - { 0 }, - { 0 }, - { memory_operand, memory_operand, const_int_operand, const_int_operand, scratch_operand, }, - { address_operand, address_operand, const_int_operand, immediate_operand, scratch_operand, }, - { general_operand, general_operand, general_operand, general_operand, immediate_operand, }, - { general_operand, address_operand, address_operand, register_operand, immediate_operand, }, - { address_operand, address_operand, register_operand, immediate_operand, }, - { general_operand, general_operand, scratch_operand, }, - { register_operand, general_operand, scratch_operand, }, - { general_operand, general_operand, scratch_operand, }, - { register_operand, general_operand, scratch_operand, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, nonimmediate_operand, nonimmediate_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, general_operand, general_operand, binary_387_op, }, - { register_operand, general_operand, register_operand, immediate_operand, }, - { register_operand, address_operand, register_operand, immediate_operand, }, - }; - -const int insn_n_alternatives[] = - { - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 2, - 0, - 2, - 0, - 2, - 0, - 2, - 1, - 1, - 1, - 1, - 1, - 2, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 0, - 2, - 1, - 2, - 2, - 1, - 3, - 2, - 2, - 4, - 2, - 1, - 4, - 1, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 0, - 2, - 0, - 0, - 0, - 0, - 1, - 1, - 0, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - 1, - 1, - 1, - 1, - 2, - 3, - 2, - 2, - 1, - 0, - 0, - 2, - 2, - 2, - 2, - 0, - 0, - 1, - 2, - 1, - 2, - 1, - 0, - 0, - 1, - 1, - 0, - 0, - 1, - 1, - 1, - 1, - 4, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 2, - 1, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 0, - 1, - 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, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 1, - 0, - 1, - 0, - 0, - 0, - 1, - 0, - 1, - 1, - 0, - 1, - 0, - 1, - 2, - 1, - 2, - 1, - 2, - 2, - 1, - 1, - 0, - 1, - }; diff --git a/gnu/usr.bin/gcc2/i386/insn-peep.c b/gnu/usr.bin/gcc2/i386/insn-peep.c deleted file mode 100644 index 357e104b89bd..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-peep.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Generated automatically by the program `genpeep' -from the machine description file `md'. */ - -#ifndef lint -static char rcsid[] = "$Id: insn-peep.c,v 1.2 1993/08/02 17:37:06 mycroft Exp $"; -#endif /* not lint */ - -#include "config.h" -#include "rtl.h" -#include "regs.h" -#include "output.h" -#include "real.h" - -extern rtx peep_operand[]; - -#define operands peep_operand - -rtx -peephole (ins1) - rtx ins1; -{ - rtx insn, x, pat; - int i; - - if (NEXT_INSN (ins1) - && GET_CODE (NEXT_INSN (ins1)) == BARRIER) - return 0; - - return 0; -} - -rtx peep_operand[2]; diff --git a/gnu/usr.bin/gcc2/i386/insn-recog.c b/gnu/usr.bin/gcc2/i386/insn-recog.c deleted file mode 100644 index 45f4e937d134..000000000000 --- a/gnu/usr.bin/gcc2/i386/insn-recog.c +++ /dev/null @@ -1,6162 +0,0 @@ -/* Generated automatically by the program `genrecog' -from the machine description file `md'. */ - -#ifndef lint -static char rcsid[] = "$Id: insn-recog.c,v 1.2 1993/08/02 17:37:08 mycroft Exp $"; -#endif /* not lint */ - -#include "config.h" -#include "rtl.h" -#include "insn-config.h" -#include "recog.h" -#include "real.h" -#include "output.h" -#include "flags.h" - - -/* `recog' contains a decision tree - that recognizes whether the rtx X0 is a valid instruction. - - recog returns -1 if the rtx is not valid. - If the rtx is valid, recog returns a nonnegative number - which is the insn code number for the pattern that matched. - This is the same as the order in the machine description of - the entry that matched. This number can be used as an index into - entry that matched. This number can be used as an index into various - insn_* tables, such as insn_templates, insn_outfun, and insn_n_operands - (found in insn-output.c). - - The third argument to recog is an optional pointer to an int. - If present, recog will accept a pattern if it matches except for - missing CLOBBER expressions at the end. In that case, the value - pointed to by the optional pointer will be set to the number of - CLOBBERs that need to be added (it should be initialized to zero by - the caller). If it is set nonzero, the caller should allocate a - PARALLEL of the appropriate size, copy the initial entries, and call - add_clobbers (found in insn-emit.c) to fill in the CLOBBERs.*/ - -rtx recog_operand[MAX_RECOG_OPERANDS]; - -rtx *recog_operand_loc[MAX_RECOG_OPERANDS]; - -rtx *recog_dup_loc[MAX_DUP_OPERANDS]; - -char recog_dup_num[MAX_DUP_OPERANDS]; - -#define operands recog_operand - -int -recog_1 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case SImode: - if (nonimmediate_operand (x1, SImode)) - { - ro[0] = x1; - return 0; - } - break; - case HImode: - if (nonimmediate_operand (x1, HImode)) - { - ro[0] = x1; - return 2; - } - break; - case QImode: - if (nonimmediate_operand (x1, QImode)) - { - ro[0] = x1; - return 4; - } - break; - case SFmode: - if (pnum_clobbers != 0 && register_operand (x1, SFmode)) - { - ro[0] = x1; - if (TARGET_80387 && ! TARGET_IEEE_FP) - { - *pnum_clobbers = 1; - return 6; - } - } - break; - case DFmode: - if (pnum_clobbers != 0 && register_operand (x1, DFmode)) - { - ro[0] = x1; - if (TARGET_80387 && ! TARGET_IEEE_FP) - { - *pnum_clobbers = 1; - return 8; - } - } - } - switch (GET_CODE (x1)) - { - case COMPARE: - goto L30; - case ZERO_EXTRACT: - goto L813; - } - L52: - if (VOIDmode_compare_op (x1, VOIDmode)) - { - ro[2] = x1; - goto L82; - } - L125: - switch (GET_MODE (x1)) - { - case CCFPEQmode: - switch (GET_CODE (x1)) - { - case COMPARE: - goto L126; - } - break; - case SImode: - switch (GET_CODE (x1)) - { - case AND: - goto L187; - } - break; - case HImode: - switch (GET_CODE (x1)) - { - case AND: - goto L192; - } - break; - case QImode: - if (GET_CODE (x1) == AND && 1) - goto L197; - } - goto ret0; - - L30: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[0] = x2; - goto L31; - } - break; - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[0] = x2; - goto L36; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[0] = x2; - goto L41; - } - } - goto L52; - - L31: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 10; - } - goto L52; - - L36: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 12; - } - goto L52; - - L41: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM) - return 14; - } - goto L52; - - L813: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SImode: - if (register_operand (x2, SImode)) - { - ro[0] = x2; - goto L814; - } - break; - case QImode: - if (general_operand (x2, QImode)) - { - ro[0] = x2; - goto L826; - } - } - goto L52; - - L814: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) != CONST_INT) - { - goto L52; - } - if (XWINT (x2, 0) == 1 && 1) - goto L815; - L820: - ro[1] = x2; - goto L821; - - L815: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - if (GET_CODE (operands[1]) != CONST_INT) - return 167; - } - x2 = XEXP (x1, 1); - goto L820; - - L821: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - return 168; - } - goto L52; - - L826: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[1] = x2; - goto L827; - } - goto L52; - - L827: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - if (GET_CODE (operands[0]) != MEM || ! MEM_VOLATILE_P (operands[0])) - return 169; - } - goto L52; - - L82: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - switch (GET_CODE (x2)) - { - case FLOAT: - goto L83; - case FLOAT_EXTEND: - goto L113; - case SUBREG: - case REG: - case MEM: - if (nonimmediate_operand (x2, DFmode)) - { - ro[0] = x2; - goto L54; - } - } - L67: - if (register_operand (x2, DFmode)) - { - ro[0] = x2; - goto L68; - } - break; - case SFmode: - if (GET_CODE (x2) == FLOAT && 1) - goto L169; - if (nonimmediate_operand (x2, SFmode)) - { - ro[0] = x2; - goto L140; - } - L153: - if (register_operand (x2, SFmode)) - { - ro[0] = x2; - goto L154; - } - } - goto L125; - - L83: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, SImode)) - { - ro[0] = x3; - goto L84; - } - goto L125; - - L84: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && register_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 18; - } - } - goto L125; - - L113: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, SFmode)) - { - ro[0] = x3; - goto L114; - } - goto L125; - - L114: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && register_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 20; - } - } - goto L125; - - L54: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && nonimmediate_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387 - && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)) - { - *pnum_clobbers = 1; - return 16; - } - } - x2 = XEXP (x1, 0); - goto L67; - - L68: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != DFmode) - { - goto L125; - } - switch (GET_CODE (x2)) - { - case FLOAT: - goto L69; - case FLOAT_EXTEND: - goto L99; - } - goto L125; - - L69: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && nonimmediate_operand (x3, SImode)) - { - ro[1] = x3; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 17; - } - } - goto L125; - - L99: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && nonimmediate_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 19; - } - } - goto L125; - - L169: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, SImode)) - { - ro[0] = x3; - goto L170; - } - goto L125; - - L170: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && register_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 24; - } - } - goto L125; - - L140: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && nonimmediate_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387 - && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)) - { - *pnum_clobbers = 1; - return 22; - } - } - x2 = XEXP (x1, 0); - goto L153; - - L154: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == FLOAT && 1) - goto L155; - goto L125; - - L155: - x3 = XEXP (x2, 0); - if (pnum_clobbers != 0 && nonimmediate_operand (x3, SImode)) - { - ro[1] = x3; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 23; - } - } - goto L125; - - L126: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - if (register_operand (x2, DFmode)) - { - ro[0] = x2; - goto L127; - } - break; - case SFmode: - if (register_operand (x2, SFmode)) - { - ro[0] = x2; - goto L183; - } - } - goto ret0; - - L127: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && register_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 21; - } - } - goto ret0; - - L183: - x2 = XEXP (x1, 1); - if (pnum_clobbers != 0 && register_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 25; - } - } - goto ret0; - - L187: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L188; - } - goto ret0; - - L188: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 32; - } - goto ret0; - - L192: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[0] = x2; - goto L193; - } - goto ret0; - - L193: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 33; - } - goto ret0; - - L197: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[0] = x2; - goto L198; - } - goto ret0; - - L198: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 34; - } - goto ret0; - ret0: return -1; -} - -int -recog_2 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 1); - x2 = XEXP (x1, 0); - switch (GET_CODE (x2)) - { - case EQ: - goto L882; - case NE: - goto L891; - case GT: - goto L900; - case GTU: - goto L909; - case LT: - goto L918; - case LTU: - goto L927; - case GE: - goto L936; - case GEU: - goto L945; - case LE: - goto L954; - case LEU: - goto L963; - } - goto ret0; - - L882: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L883; - goto ret0; - - L883: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L884; - goto ret0; - - L884: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L885; - case PC: - goto L975; - } - goto ret0; - - L885: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L886; - - L886: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 191; - goto ret0; - - L975: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L976; - goto ret0; - - L976: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 210; - - L891: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L892; - goto ret0; - - L892: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L893; - goto ret0; - - L893: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L894; - case PC: - goto L984; - } - goto ret0; - - L894: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L895; - - L895: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 193; - goto ret0; - - L984: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L985; - goto ret0; - - L985: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 211; - - L900: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L901; - goto ret0; - - L901: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L902; - goto ret0; - - L902: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L903; - case PC: - goto L993; - } - goto ret0; - - L903: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L904; - - L904: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 195; - goto ret0; - - L993: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L994; - goto ret0; - - L994: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 212; - - L909: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L910; - goto ret0; - - L910: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L911; - goto ret0; - - L911: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L912; - case PC: - goto L1002; - } - goto ret0; - - L912: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L913; - - L913: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 197; - goto ret0; - - L1002: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1003; - goto ret0; - - L1003: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 213; - - L918: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L919; - goto ret0; - - L919: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L920; - goto ret0; - - L920: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L921; - case PC: - goto L1011; - } - goto ret0; - - L921: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L922; - - L922: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 199; - goto ret0; - - L1011: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1012; - goto ret0; - - L1012: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 214; - - L927: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L928; - goto ret0; - - L928: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L929; - goto ret0; - - L929: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L930; - case PC: - goto L1020; - } - goto ret0; - - L930: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L931; - - L931: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 201; - goto ret0; - - L1020: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1021; - goto ret0; - - L1021: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 215; - - L936: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L937; - goto ret0; - - L937: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L938; - goto ret0; - - L938: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L939; - case PC: - goto L1029; - } - goto ret0; - - L939: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L940; - - L940: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 203; - goto ret0; - - L1029: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1030; - goto ret0; - - L1030: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 216; - - L945: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L946; - goto ret0; - - L946: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L947; - goto ret0; - - L947: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L948; - case PC: - goto L1038; - } - goto ret0; - - L948: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L949; - - L949: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 205; - goto ret0; - - L1038: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1039; - goto ret0; - - L1039: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 217; - - L954: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L955; - goto ret0; - - L955: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L956; - goto ret0; - - L956: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L957; - case PC: - goto L1047; - } - goto ret0; - - L957: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L958; - - L958: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 207; - goto ret0; - - L1047: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1048; - goto ret0; - - L1048: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 218; - - L963: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CC0 && 1) - goto L964; - goto ret0; - - L964: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 0 && 1) - goto L965; - goto ret0; - - L965: - x2 = XEXP (x1, 1); - switch (GET_CODE (x2)) - { - case LABEL_REF: - goto L966; - case PC: - goto L1056; - } - goto ret0; - - L966: - x3 = XEXP (x2, 0); - ro[0] = x3; - goto L967; - - L967: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == PC && 1) - return 209; - goto ret0; - - L1056: - x2 = XEXP (x1, 2); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1057; - goto ret0; - - L1057: - x3 = XEXP (x2, 0); - ro[0] = x3; - return 219; - ret0: return -1; -} - -int -recog_3 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XEXP (x0, 0); - switch (GET_MODE (x1)) - { - case SImode: - switch (GET_CODE (x1)) - { - case MEM: - if (push_operand (x1, SImode)) - { - ro[0] = x1; - goto L201; - } - break; - case ZERO_EXTRACT: - goto L792; - } - L208: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - goto L257; - } - L431: - if (register_operand (x1, SImode)) - { - ro[0] = x1; - goto L432; - } - L439: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - goto L440; - } - break; - case HImode: - if (GET_CODE (x1) == MEM && push_operand (x1, HImode)) - { - ro[0] = x1; - goto L212; - } - L214: - if (general_operand (x1, HImode)) - { - ro[0] = x1; - goto L261; - } - break; - case QImode: - if (GET_CODE (x1) == MEM && push_operand (x1, QImode)) - { - ro[0] = x1; - goto L222; - } - L224: - if (general_operand (x1, QImode)) - { - ro[0] = x1; - goto L427; - } - L829: - if (register_operand (x1, QImode)) - { - ro[0] = x1; - goto L830; - } - break; - case SFmode: - if (GET_CODE (x1) == MEM && push_operand (x1, SFmode)) - { - ro[0] = x1; - goto L232; - } - L234: - if (general_operand (x1, SFmode)) - { - ro[0] = x1; - goto L235; - } - L399: - if (register_operand (x1, SFmode)) - { - ro[0] = x1; - goto L400; - } - break; - case DFmode: - if (GET_CODE (x1) == MEM && push_operand (x1, DFmode)) - { - ro[0] = x1; - goto L238; - } - L247: - if (general_operand (x1, DFmode)) - { - ro[0] = x1; - goto L289; - } - L395: - if (register_operand (x1, DFmode)) - { - ro[0] = x1; - goto L396; - } - break; - case DImode: - if (GET_CODE (x1) == MEM && push_operand (x1, DImode)) - { - ro[0] = x1; - goto L251; - } - L253: - if (general_operand (x1, DImode)) - { - ro[0] = x1; - goto L412; - } - L268: - if (register_operand (x1, DImode)) - { - ro[0] = x1; - goto L269; - } - } - switch (GET_CODE (x1)) - { - case CC0: - goto L2; - case STRICT_LOW_PART: - goto L218; - case PC: - goto L1081; - } - L1147: - ro[0] = x1; - goto L1148; - L1236: - switch (GET_MODE (x1)) - { - case SImode: - if (register_operand (x1, SImode)) - { - ro[0] = x1; - goto L1237; - } - break; - case HImode: - if (register_operand (x1, HImode)) - { - ro[0] = x1; - goto L1252; - } - break; - case DFmode: - if (register_operand (x1, DFmode)) - { - ro[0] = x1; - goto L1258; - } - break; - case SFmode: - if (register_operand (x1, SFmode)) - { - ro[0] = x1; - goto L1287; - } - } - goto ret0; - - L201: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - goto L205; - x1 = XEXP (x0, 0); - goto L208; - - L205: - ro[1] = x1; - if (! TARGET_486) - return 35; - L206: - ro[1] = x1; - if (TARGET_486) - return 36; - x1 = XEXP (x0, 0); - goto L208; - - L792: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && general_operand (x2, SImode)) - { - ro[0] = x2; - goto L793; - } - goto L1147; - - L793: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 1 && 1) - goto L794; - goto L1147; - - L794: - x2 = XEXP (x1, 2); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - goto L795; - } - goto L1147; - - L795: - x1 = XEXP (x0, 1); - if (GET_CODE (x1) == CONST_INT && 1) - { - ro[3] = x1; - if (! TARGET_486 && GET_CODE (operands[2]) != CONST_INT) - return 164; - } - x1 = XEXP (x0, 0); - goto L1147; - - L257: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case SImode: - switch (GET_CODE (x1)) - { - case ZERO_EXTEND: - goto L258; - case SIGN_EXTEND: - goto L278; - case PLUS: - goto L418; - } - } - if (general_operand (x1, SImode)) - { - ro[1] = x1; - return 38; - } - x1 = XEXP (x0, 0); - goto L431; - - L258: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[1] = x2; - return 52; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - return 54; - } - } - x1 = XEXP (x0, 0); - goto L431; - - L278: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (nonimmediate_operand (x2, HImode)) - { - ro[1] = x2; - return 57; - } - break; - case QImode: - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - return 59; - } - } - x1 = XEXP (x0, 0); - goto L431; - - L418: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L419; - } - x1 = XEXP (x0, 0); - goto L431; - - L419: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 82; - } - x1 = XEXP (x0, 0); - goto L431; - - L432: - x1 = XEXP (x0, 1); - if (address_operand (x1, QImode)) - { - ro[1] = x1; - return 85; - } - x1 = XEXP (x0, 0); - goto L439; - - L440: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != SImode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - switch (GET_CODE (x1)) - { - case MINUS: - goto L441; - case MULT: - goto L468; - case AND: - goto L541; - case IOR: - goto L556; - case XOR: - goto L799; - case NEG: - goto L590; - case NOT: - goto L667; - case ASHIFT: - goto L692; - case ASHIFTRT: - goto L720; - case LSHIFTRT: - goto L748; - case ROTATE: - goto L763; - case ROTATERT: - goto L778; - } - x1 = XEXP (x0, 0); - goto L1147; - - L441: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L442; - } - x1 = XEXP (x0, 0); - goto L1147; - - L442: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 89; - } - x1 = XEXP (x0, 0); - goto L1147; - - L468: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L469; - } - x1 = XEXP (x0, 0); - goto L1147; - - L469: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - goto L475; - x1 = XEXP (x0, 0); - goto L1147; - - L475: - ro[2] = x2; - if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x80) - return 96; - L476: - ro[2] = x2; - return 97; - - L541: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L542; - } - x1 = XEXP (x0, 0); - goto L1147; - - L542: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 109; - } - x1 = XEXP (x0, 0); - goto L1147; - - L556: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L557; - } - x1 = XEXP (x0, 0); - goto L1147; - - L557: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 112; - } - x1 = XEXP (x0, 0); - goto L1147; - - L799: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == ASHIFT && 1) - goto L800; - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L807; - } - x1 = XEXP (x0, 0); - goto L1147; - - L800: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 1 && 1) - goto L801; - x1 = XEXP (x0, 0); - goto L1147; - - L801: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L802; - } - x1 = XEXP (x0, 0); - goto L1147; - - L802: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - if (! TARGET_486 && GET_CODE (operands[1]) != CONST_INT) - return 165; - } - x1 = XEXP (x0, 0); - goto L1147; - - L807: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == ASHIFT && 1) - goto L808; - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 115; - } - x1 = XEXP (x0, 0); - goto L1147; - - L808: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == 1 && 1) - goto L809; - x1 = XEXP (x0, 0); - goto L1147; - - L809: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - if (! TARGET_486 && GET_CODE (operands[2]) != CONST_INT) - return 166; - } - x1 = XEXP (x0, 0); - goto L1147; - - L590: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 119; - } - x1 = XEXP (x0, 0); - goto L1147; - - L667: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - return 137; - } - x1 = XEXP (x0, 0); - goto L1147; - - L692: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L693; - } - x1 = XEXP (x0, 0); - goto L1147; - - L693: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, SImode)) - { - ro[2] = x2; - return 143; - } - x1 = XEXP (x0, 0); - goto L1147; - - L720: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L721; - } - x1 = XEXP (x0, 0); - goto L1147; - - L721: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, SImode)) - { - ro[2] = x2; - return 149; - } - x1 = XEXP (x0, 0); - goto L1147; - - L748: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L749; - } - x1 = XEXP (x0, 0); - goto L1147; - - L749: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, SImode)) - { - ro[2] = x2; - return 155; - } - x1 = XEXP (x0, 0); - goto L1147; - - L763: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L764; - } - x1 = XEXP (x0, 0); - goto L1147; - - L764: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, SImode)) - { - ro[2] = x2; - return 158; - } - x1 = XEXP (x0, 0); - goto L1147; - - L778: - x2 = XEXP (x1, 0); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L779; - } - x1 = XEXP (x0, 0); - goto L1147; - - L779: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, SImode)) - { - ro[2] = x2; - return 161; - } - x1 = XEXP (x0, 0); - goto L1147; - - L212: - x1 = XEXP (x0, 1); - if (general_operand (x1, HImode)) - { - ro[1] = x1; - return 39; - } - x1 = XEXP (x0, 0); - goto L214; - - L261: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case HImode: - switch (GET_CODE (x1)) - { - case ZERO_EXTEND: - goto L262; - case SIGN_EXTEND: - goto L282; - case PLUS: - goto L423; - case MINUS: - goto L446; - case AND: - goto L546; - case IOR: - goto L561; - case XOR: - goto L576; - case NEG: - goto L594; - case NOT: - goto L671; - case ASHIFT: - goto L697; - case ASHIFTRT: - goto L725; - case LSHIFTRT: - goto L753; - case ROTATE: - goto L768; - case ROTATERT: - goto L783; - } - break; - case SImode: - if (GET_CODE (x1) == MULT && 1) - goto L480; - } - if (general_operand (x1, HImode)) - { - ro[1] = x1; - return 40; - } - x1 = XEXP (x0, 0); - goto L1147; - - L262: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - return 53; - } - x1 = XEXP (x0, 0); - goto L1147; - - L282: - x2 = XEXP (x1, 0); - if (nonimmediate_operand (x2, QImode)) - { - ro[1] = x2; - return 58; - } - x1 = XEXP (x0, 0); - goto L1147; - - L423: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L424; - } - x1 = XEXP (x0, 0); - goto L1147; - - L424: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 83; - } - x1 = XEXP (x0, 0); - goto L1147; - - L446: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L447; - } - x1 = XEXP (x0, 0); - goto L1147; - - L447: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 90; - } - x1 = XEXP (x0, 0); - goto L1147; - - L546: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L547; - } - x1 = XEXP (x0, 0); - goto L1147; - - L547: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 110; - } - x1 = XEXP (x0, 0); - goto L1147; - - L561: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L562; - } - x1 = XEXP (x0, 0); - goto L1147; - - L562: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 113; - } - x1 = XEXP (x0, 0); - goto L1147; - - L576: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L577; - } - x1 = XEXP (x0, 0); - goto L1147; - - L577: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - { - ro[2] = x2; - return 116; - } - x1 = XEXP (x0, 0); - goto L1147; - - L594: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 120; - } - x1 = XEXP (x0, 0); - goto L1147; - - L671: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - return 138; - } - x1 = XEXP (x0, 0); - goto L1147; - - L697: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L698; - } - x1 = XEXP (x0, 0); - goto L1147; - - L698: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, HImode)) - { - ro[2] = x2; - return 144; - } - x1 = XEXP (x0, 0); - goto L1147; - - L725: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L726; - } - x1 = XEXP (x0, 0); - goto L1147; - - L726: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, HImode)) - { - ro[2] = x2; - return 150; - } - x1 = XEXP (x0, 0); - goto L1147; - - L753: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L754; - } - x1 = XEXP (x0, 0); - goto L1147; - - L754: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, HImode)) - { - ro[2] = x2; - return 156; - } - x1 = XEXP (x0, 0); - goto L1147; - - L768: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L769; - } - x1 = XEXP (x0, 0); - goto L1147; - - L769: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, HImode)) - { - ro[2] = x2; - return 159; - } - x1 = XEXP (x0, 0); - goto L1147; - - L783: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L784; - } - x1 = XEXP (x0, 0); - goto L1147; - - L784: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, HImode)) - { - ro[2] = x2; - return 162; - } - x1 = XEXP (x0, 0); - goto L1147; - - L480: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == ZERO_EXTEND && 1) - goto L481; - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L457; - } - x1 = XEXP (x0, 0); - goto L1147; - - L481: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, QImode)) - { - ro[1] = x3; - goto L482; - } - x1 = XEXP (x0, 0); - goto L1147; - - L482: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == ZERO_EXTEND && 1) - goto L483; - x1 = XEXP (x0, 0); - goto L1147; - - L483: - x3 = XEXP (x2, 0); - if (nonimmediate_operand (x3, QImode)) - { - ro[2] = x3; - return 98; - } - x1 = XEXP (x0, 0); - goto L1147; - - L457: - x2 = XEXP (x1, 1); - if (general_operand (x2, HImode)) - goto L463; - x1 = XEXP (x0, 0); - goto L1147; - - L463: - ro[2] = x2; - if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x80) - return 94; - L464: - ro[2] = x2; - return 95; - - L222: - x1 = XEXP (x0, 1); - if (general_operand (x1, QImode)) - { - ro[1] = x1; - return 42; - } - x1 = XEXP (x0, 0); - goto L224; - - L427: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case QImode: - switch (GET_CODE (x1)) - { - case PLUS: - goto L428; - case MINUS: - goto L451; - case DIV: - goto L487; - case UDIV: - goto L492; - case AND: - goto L551; - case IOR: - goto L566; - case XOR: - goto L581; - case NEG: - goto L598; - case NOT: - goto L675; - case ASHIFT: - goto L702; - case ASHIFTRT: - goto L730; - case LSHIFTRT: - goto L758; - case ROTATE: - goto L773; - case ROTATERT: - goto L788; - } - } - if (general_operand (x1, QImode)) - { - ro[1] = x1; - return 43; - } - x1 = XEXP (x0, 0); - goto L829; - - L428: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L429; - } - x1 = XEXP (x0, 0); - goto L829; - - L429: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 84; - } - x1 = XEXP (x0, 0); - goto L829; - - L451: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L452; - } - x1 = XEXP (x0, 0); - goto L829; - - L452: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 91; - } - x1 = XEXP (x0, 0); - goto L829; - - L487: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L488; - } - x1 = XEXP (x0, 0); - goto L829; - - L488: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 101; - } - x1 = XEXP (x0, 0); - goto L829; - - L492: - x2 = XEXP (x1, 0); - if (general_operand (x2, HImode)) - { - ro[1] = x2; - goto L493; - } - x1 = XEXP (x0, 0); - goto L829; - - L493: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 102; - } - x1 = XEXP (x0, 0); - goto L829; - - L551: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L552; - } - x1 = XEXP (x0, 0); - goto L829; - - L552: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 111; - } - x1 = XEXP (x0, 0); - goto L829; - - L566: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L567; - } - x1 = XEXP (x0, 0); - goto L829; - - L567: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 114; - } - x1 = XEXP (x0, 0); - goto L829; - - L581: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L582; - } - x1 = XEXP (x0, 0); - goto L829; - - L582: - x2 = XEXP (x1, 1); - if (general_operand (x2, QImode)) - { - ro[2] = x2; - return 117; - } - x1 = XEXP (x0, 0); - goto L829; - - L598: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 121; - } - x1 = XEXP (x0, 0); - goto L829; - - L675: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - return 139; - } - x1 = XEXP (x0, 0); - goto L829; - - L702: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L703; - } - x1 = XEXP (x0, 0); - goto L829; - - L703: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, QImode)) - { - ro[2] = x2; - return 145; - } - x1 = XEXP (x0, 0); - goto L829; - - L730: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L731; - } - x1 = XEXP (x0, 0); - goto L829; - - L731: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, QImode)) - { - ro[2] = x2; - return 151; - } - x1 = XEXP (x0, 0); - goto L829; - - L758: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L759; - } - x1 = XEXP (x0, 0); - goto L829; - - L759: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, QImode)) - { - ro[2] = x2; - return 157; - } - x1 = XEXP (x0, 0); - goto L829; - - L773: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L774; - } - x1 = XEXP (x0, 0); - goto L829; - - L774: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, QImode)) - { - ro[2] = x2; - return 160; - } - x1 = XEXP (x0, 0); - goto L829; - - L788: - x2 = XEXP (x1, 0); - if (general_operand (x2, QImode)) - { - ro[1] = x2; - goto L789; - } - x1 = XEXP (x0, 0); - goto L829; - - L789: - x2 = XEXP (x1, 1); - if (nonmemory_operand (x2, QImode)) - { - ro[2] = x2; - return 163; - } - x1 = XEXP (x0, 0); - goto L829; - - L830: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != QImode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - switch (GET_CODE (x1)) - { - case EQ: - goto L831; - case NE: - goto L836; - case GT: - goto L841; - case GTU: - goto L846; - case LT: - goto L851; - case LTU: - goto L856; - case GE: - goto L861; - case GEU: - goto L866; - case LE: - goto L871; - case LEU: - goto L876; - } - x1 = XEXP (x0, 0); - goto L1147; - - L831: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L832; - x1 = XEXP (x0, 0); - goto L1147; - - L832: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 171; - x1 = XEXP (x0, 0); - goto L1147; - - L836: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L837; - x1 = XEXP (x0, 0); - goto L1147; - - L837: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 173; - x1 = XEXP (x0, 0); - goto L1147; - - L841: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L842; - x1 = XEXP (x0, 0); - goto L1147; - - L842: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 175; - x1 = XEXP (x0, 0); - goto L1147; - - L846: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L847; - x1 = XEXP (x0, 0); - goto L1147; - - L847: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 177; - x1 = XEXP (x0, 0); - goto L1147; - - L851: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L852; - x1 = XEXP (x0, 0); - goto L1147; - - L852: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 179; - x1 = XEXP (x0, 0); - goto L1147; - - L856: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L857; - x1 = XEXP (x0, 0); - goto L1147; - - L857: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 181; - x1 = XEXP (x0, 0); - goto L1147; - - L861: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L862; - x1 = XEXP (x0, 0); - goto L1147; - - L862: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 183; - x1 = XEXP (x0, 0); - goto L1147; - - L866: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L867; - x1 = XEXP (x0, 0); - goto L1147; - - L867: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 185; - x1 = XEXP (x0, 0); - goto L1147; - - L871: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L872; - x1 = XEXP (x0, 0); - goto L1147; - - L872: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 187; - x1 = XEXP (x0, 0); - goto L1147; - - L876: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CC0 && 1) - goto L877; - x1 = XEXP (x0, 0); - goto L1147; - - L877: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - return 189; - x1 = XEXP (x0, 0); - goto L1147; - - L232: - x1 = XEXP (x0, 1); - if (general_operand (x1, SFmode)) - { - ro[1] = x1; - return 45; - } - x1 = XEXP (x0, 0); - goto L234; - - L235: - x1 = XEXP (x0, 1); - if (general_operand (x1, SFmode)) - { - ro[1] = x1; - return 46; - } - x1 = XEXP (x0, 0); - goto L399; - - L400: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != SFmode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - switch (GET_CODE (x1)) - { - case FLOAT: - goto L401; - case NEG: - goto L602; - case ABS: - goto L615; - case SQRT: - goto L628; - case UNSPEC: - if (XINT (x1, 1) == 1 && XVECLEN (x1, 0) == 1 && 1) - goto L645; - if (XINT (x1, 1) == 2 && XVECLEN (x1, 0) == 1 && 1) - goto L658; - } - x1 = XEXP (x0, 0); - goto L1147; - - L401: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DImode: - if (nonimmediate_operand (x2, DImode)) - { - ro[1] = x2; - if (TARGET_80387) - return 78; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[1] = x2; - if (TARGET_80387) - return 80; - } - } - x1 = XEXP (x0, 0); - goto L1147; - - L602: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387) - return 122; - } - x1 = XEXP (x0, 0); - goto L1147; - - L615: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387) - return 125; - } - x1 = XEXP (x0, 0); - goto L1147; - - L628: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 128; - } - x1 = XEXP (x0, 0); - goto L1147; - - L645: - x2 = XVECEXP (x1, 0, 0); - if (register_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 132; - } - x1 = XEXP (x0, 0); - goto L1147; - - L658: - x2 = XVECEXP (x1, 0, 0); - if (register_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 135; - } - x1 = XEXP (x0, 0); - goto L1147; - - L238: - x1 = XEXP (x0, 1); - if (general_operand (x1, DFmode)) - { - ro[1] = x1; - return 47; - } - x1 = XEXP (x0, 0); - goto L247; - - L289: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == DFmode && GET_CODE (x1) == FLOAT_EXTEND && 1) - goto L290; - if (general_operand (x1, DFmode)) - { - ro[1] = x1; - return 49; - } - x1 = XEXP (x0, 0); - goto L395; - - L290: - x2 = XEXP (x1, 0); - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - if (TARGET_80387) - return 60; - } - x1 = XEXP (x0, 0); - goto L395; - - L396: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != DFmode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - switch (GET_CODE (x1)) - { - case FLOAT: - goto L397; - case NEG: - goto L610; - case ABS: - goto L623; - case SQRT: - goto L636; - case UNSPEC: - if (XINT (x1, 1) == 1 && XVECLEN (x1, 0) == 1 && 1) - goto L649; - if (XINT (x1, 1) == 2 && XVECLEN (x1, 0) == 1 && 1) - goto L662; - } - x1 = XEXP (x0, 0); - goto L1147; - - L397: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DImode: - if (nonimmediate_operand (x2, DImode)) - { - ro[1] = x2; - if (TARGET_80387) - return 77; - } - break; - case SImode: - if (nonimmediate_operand (x2, SImode)) - { - ro[1] = x2; - if (TARGET_80387) - return 79; - } - } - x1 = XEXP (x0, 0); - goto L1147; - - L610: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == FLOAT_EXTEND && 1) - goto L611; - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387) - return 123; - } - x1 = XEXP (x0, 0); - goto L1147; - - L611: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387) - return 124; - } - x1 = XEXP (x0, 0); - goto L1147; - - L623: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == FLOAT_EXTEND && 1) - goto L624; - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387) - return 126; - } - x1 = XEXP (x0, 0); - goto L1147; - - L624: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387) - return 127; - } - x1 = XEXP (x0, 0); - goto L1147; - - L636: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DFmode && GET_CODE (x2) == FLOAT_EXTEND && 1) - goto L637; - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 129; - } - x1 = XEXP (x0, 0); - goto L1147; - - L637: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 130; - } - x1 = XEXP (x0, 0); - goto L1147; - - L649: - x2 = XVECEXP (x1, 0, 0); - if (GET_MODE (x2) != DFmode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - if (GET_CODE (x2) == FLOAT_EXTEND && 1) - goto L650; - if (register_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 131; - } - x1 = XEXP (x0, 0); - goto L1147; - - L650: - x3 = XEXP (x2, 0); - if (register_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 133; - } - x1 = XEXP (x0, 0); - goto L1147; - - L662: - x2 = XVECEXP (x1, 0, 0); - if (GET_MODE (x2) != DFmode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - if (GET_CODE (x2) == FLOAT_EXTEND && 1) - goto L663; - if (register_operand (x2, DFmode)) - { - ro[1] = x2; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 134; - } - x1 = XEXP (x0, 0); - goto L1147; - - L663: - x3 = XEXP (x2, 0); - if (register_operand (x3, SFmode)) - { - ro[1] = x3; - if (TARGET_80387 && (TARGET_IEEE_FP || flag_fast_math)) - return 136; - } - x1 = XEXP (x0, 0); - goto L1147; - - L251: - x1 = XEXP (x0, 1); - if (general_operand (x1, DImode)) - { - ro[1] = x1; - return 50; - } - x1 = XEXP (x0, 0); - goto L253; - - L412: - x1 = XEXP (x0, 1); - switch (GET_MODE (x1)) - { - case DImode: - switch (GET_CODE (x1)) - { - case PLUS: - goto L413; - case MINUS: - goto L436; - case NEG: - goto L586; - } - } - if (general_operand (x1, DImode)) - { - ro[1] = x1; - return 51; - } - x1 = XEXP (x0, 0); - goto L268; - - L413: - x2 = XEXP (x1, 0); - if (general_operand (x2, DImode)) - { - ro[1] = x2; - goto L414; - } - x1 = XEXP (x0, 0); - goto L268; - - L414: - x2 = XEXP (x1, 1); - if (general_operand (x2, DImode)) - { - ro[2] = x2; - return 81; - } - x1 = XEXP (x0, 0); - goto L268; - - L436: - x2 = XEXP (x1, 0); - if (general_operand (x2, DImode)) - { - ro[1] = x2; - goto L437; - } - x1 = XEXP (x0, 0); - goto L268; - - L437: - x2 = XEXP (x1, 1); - if (general_operand (x2, DImode)) - { - ro[2] = x2; - return 88; - } - x1 = XEXP (x0, 0); - goto L268; - - L586: - x2 = XEXP (x1, 0); - if (general_operand (x2, DImode)) - { - ro[1] = x2; - return 118; - } - x1 = XEXP (x0, 0); - goto L268; - - L269: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) != DImode) - { - x1 = XEXP (x0, 0); - goto L1147; - } - switch (GET_CODE (x1)) - { - case ZERO_EXTEND: - goto L270; - case SIGN_EXTEND: - goto L274; - case ASHIFT: - goto L679; - case ASHIFTRT: - goto L707; - case LSHIFTRT: - goto L735; - } - x1 = XEXP (x0, 0); - goto L1147; - - L270: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - return 55; - } - x1 = XEXP (x0, 0); - goto L1147; - - L274: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[1] = x2; - return 56; - } - x1 = XEXP (x0, 0); - goto L1147; - - L679: - x2 = XEXP (x1, 0); - if (register_operand (x2, DImode)) - { - ro[1] = x2; - goto L680; - } - x1 = XEXP (x0, 0); - goto L1147; - - L680: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - return 141; - } - x1 = XEXP (x0, 0); - goto L1147; - - L707: - x2 = XEXP (x1, 0); - if (register_operand (x2, DImode)) - { - ro[1] = x2; - goto L708; - } - x1 = XEXP (x0, 0); - goto L1147; - - L708: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - return 147; - } - x1 = XEXP (x0, 0); - goto L1147; - - L735: - x2 = XEXP (x1, 0); - if (register_operand (x2, DImode)) - { - ro[1] = x2; - goto L736; - } - x1 = XEXP (x0, 0); - goto L1147; - - L736: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - return 153; - } - x1 = XEXP (x0, 0); - goto L1147; - L2: - tem = recog_1 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L1147; - - L218: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case HImode: - if (general_operand (x2, HImode)) - { - ro[0] = x2; - goto L219; - } - break; - case QImode: - if (general_operand (x2, QImode)) - { - ro[0] = x2; - goto L229; - } - } - goto L1147; - - L219: - x1 = XEXP (x0, 1); - if (general_operand (x1, HImode)) - { - ro[1] = x1; - return 41; - } - x1 = XEXP (x0, 0); - goto L1147; - - L229: - x1 = XEXP (x0, 1); - if (general_operand (x1, QImode)) - { - ro[1] = x1; - return 44; - } - x1 = XEXP (x0, 0); - goto L1147; - - L1081: - x1 = XEXP (x0, 1); - switch (GET_CODE (x1)) - { - case MINUS: - if (GET_MODE (x1) == SImode && 1) - goto L1082; - break; - case IF_THEN_ELSE: - goto L881; - case LABEL_REF: - goto L1061; - } - L1064: - if (general_operand (x1, SImode)) - { - ro[0] = x1; - return 221; - } - x1 = XEXP (x0, 0); - goto L1147; - - L1082: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == REG && XINT (x2, 0) == 3 && 1) - goto L1083; - x1 = XEXP (x0, 0); - goto L1147; - - L1083: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MEM && 1) - goto L1084; - x1 = XEXP (x0, 0); - goto L1147; - - L1084: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == PLUS && 1) - goto L1085; - x1 = XEXP (x0, 0); - goto L1147; - - L1085: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == SImode && GET_CODE (x4) == MULT && 1) - goto L1086; - x1 = XEXP (x0, 0); - goto L1147; - - L1086: - x5 = XEXP (x4, 0); - if (register_operand (x5, SImode)) - { - ro[0] = x5; - goto L1087; - } - x1 = XEXP (x0, 0); - goto L1147; - - L1087: - x5 = XEXP (x4, 1); - if (GET_CODE (x5) == CONST_INT && XWINT (x5, 0) == 4 && 1) - goto L1088; - x1 = XEXP (x0, 0); - goto L1147; - - L1088: - x4 = XEXP (x3, 1); - if (GET_CODE (x4) == LABEL_REF && 1) - goto L1089; - x1 = XEXP (x0, 0); - goto L1147; - - L1089: - x5 = XEXP (x4, 0); - if (pnum_clobbers != 0 && 1) - { - ro[1] = x5; - *pnum_clobbers = 1; - return 223; - } - x1 = XEXP (x0, 0); - goto L1147; - L881: - tem = recog_2 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x1 = XEXP (x0, 0); - goto L1147; - - L1061: - x2 = XEXP (x1, 0); - ro[0] = x2; - return 220; - - L1148: - x1 = XEXP (x0, 1); - if (GET_CODE (x1) == CALL && 1) - goto L1149; - x1 = XEXP (x0, 0); - goto L1236; - - L1149: - x2 = XEXP (x1, 0); - if (call_insn_operand (x2, QImode)) - { - ro[1] = x2; - goto L1150; - } - L1154: - if (GET_MODE (x2) == QImode && GET_CODE (x2) == MEM && 1) - goto L1155; - x1 = XEXP (x0, 0); - goto L1236; - - L1150: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - return 235; - } - x2 = XEXP (x1, 0); - goto L1154; - - L1155: - x3 = XEXP (x2, 0); - if (symbolic_operand (x3, SImode)) - { - ro[1] = x3; - goto L1156; - } - x1 = XEXP (x0, 0); - goto L1236; - - L1156: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[2] = x2; - if (!HALF_PIC_P ()) - return 236; - } - x1 = XEXP (x0, 0); - goto L1236; - - L1237: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == SImode && GET_CODE (x1) == PLUS && 1) - goto L1238; - goto ret0; - - L1238: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == FFS && 1) - goto L1239; - goto ret0; - - L1239: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L1240; - } - goto ret0; - - L1240: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == -1 && pnum_clobbers != 0 && 1) - { - *pnum_clobbers = 1; - return 250; - } - goto ret0; - - L1252: - x1 = XEXP (x0, 1); - if (GET_MODE (x1) == HImode && GET_CODE (x1) == PLUS && 1) - goto L1253; - goto ret0; - - L1253: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == FFS && 1) - goto L1254; - goto ret0; - - L1254: - x3 = XEXP (x2, 0); - if (general_operand (x3, HImode)) - { - ro[1] = x3; - goto L1255; - } - goto ret0; - - L1255: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == -1 && pnum_clobbers != 0 && 1) - { - *pnum_clobbers = 1; - return 252; - } - goto ret0; - - L1258: - x1 = XEXP (x0, 1); - if (binary_387_op (x1, DFmode)) - { - ro[3] = x1; - goto L1264; - } - goto ret0; - - L1264: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - switch (GET_CODE (x2)) - { - case FLOAT: - goto L1265; - case FLOAT_EXTEND: - goto L1271; - case SUBREG: - case REG: - case MEM: - if (nonimmediate_operand (x2, DFmode)) - { - ro[1] = x2; - goto L1260; - } - } - } - L1276: - if (general_operand (x2, DFmode)) - { - ro[1] = x2; - goto L1277; - } - goto ret0; - - L1265: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L1266; - } - goto ret0; - - L1266: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 254; - } - goto ret0; - - L1271: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[1] = x3; - goto L1272; - } - goto ret0; - - L1272: - x2 = XEXP (x1, 1); - if (general_operand (x2, DFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 255; - } - goto ret0; - - L1260: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, DFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 253; - } - x2 = XEXP (x1, 0); - goto L1276; - - L1277: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != DFmode) - goto ret0; - switch (GET_CODE (x2)) - { - case FLOAT: - goto L1278; - case FLOAT_EXTEND: - goto L1284; - } - goto ret0; - - L1278: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - if (TARGET_80387) - return 256; - } - goto ret0; - - L1284: - x3 = XEXP (x2, 0); - if (general_operand (x3, SFmode)) - { - ro[2] = x3; - if (TARGET_80387) - return 257; - } - goto ret0; - - L1287: - x1 = XEXP (x0, 1); - if (binary_387_op (x1, SFmode)) - { - ro[3] = x1; - goto L1293; - } - goto ret0; - - L1293: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case SFmode: - if (GET_CODE (x2) == FLOAT && 1) - goto L1294; - if (nonimmediate_operand (x2, SFmode)) - { - ro[1] = x2; - goto L1289; - } - } - L1299: - if (general_operand (x2, SFmode)) - { - ro[1] = x2; - goto L1300; - } - goto ret0; - - L1294: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[1] = x3; - goto L1295; - } - goto ret0; - - L1295: - x2 = XEXP (x1, 1); - if (general_operand (x2, SFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 259; - } - goto ret0; - - L1289: - x2 = XEXP (x1, 1); - if (nonimmediate_operand (x2, SFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 258; - } - x2 = XEXP (x1, 0); - goto L1299; - - L1300: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == FLOAT && 1) - goto L1301; - goto ret0; - - L1301: - x3 = XEXP (x2, 0); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - if (TARGET_80387) - return 260; - } - goto ret0; - ret0: return -1; -} - -int -recog_4 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - switch (GET_MODE (x2)) - { - case SFmode: - if (register_operand (x2, SFmode)) - { - ro[0] = x2; - goto L13; - } - break; - case DFmode: - if (register_operand (x2, DFmode)) - { - ro[0] = x2; - goto L22; - } - } - L45: - if (VOIDmode_compare_op (x2, VOIDmode)) - { - ro[2] = x2; - goto L74; - } - L118: - if (GET_MODE (x2) == CCFPEQmode && GET_CODE (x2) == COMPARE && 1) - goto L119; - goto ret0; - - L13: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L14; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L45; - - L14: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[1] = x2; - if (TARGET_80387 && ! TARGET_IEEE_FP) - return 6; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L45; - - L22: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L23; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L45; - - L23: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[1] = x2; - if (TARGET_80387 && ! TARGET_IEEE_FP) - return 8; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L45; - - L74: - x3 = XEXP (x2, 0); - switch (GET_MODE (x3)) - { - case DFmode: - switch (GET_CODE (x3)) - { - case FLOAT: - goto L75; - case FLOAT_EXTEND: - goto L105; - case SUBREG: - case REG: - case MEM: - if (nonimmediate_operand (x3, DFmode)) - { - ro[0] = x3; - goto L47; - } - } - L59: - if (register_operand (x3, DFmode)) - { - ro[0] = x3; - goto L60; - } - break; - case SFmode: - if (GET_CODE (x3) == FLOAT && 1) - goto L161; - if (nonimmediate_operand (x3, SFmode)) - { - ro[0] = x3; - goto L133; - } - L145: - if (register_operand (x3, SFmode)) - { - ro[0] = x3; - goto L146; - } - } - goto L118; - - L75: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SImode)) - { - ro[0] = x4; - goto L76; - } - goto L118; - - L76: - x3 = XEXP (x2, 1); - if (register_operand (x3, DFmode)) - { - ro[1] = x3; - goto L77; - } - goto L118; - - L77: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L78; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L78: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 18; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L105: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SFmode)) - { - ro[0] = x4; - goto L106; - } - goto L118; - - L106: - x3 = XEXP (x2, 1); - if (register_operand (x3, DFmode)) - { - ro[1] = x3; - goto L107; - } - goto L118; - - L107: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L108; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L108: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 20; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L47: - x3 = XEXP (x2, 1); - if (nonimmediate_operand (x3, DFmode)) - { - ro[1] = x3; - goto L48; - } - x3 = XEXP (x2, 0); - goto L59; - - L48: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L49; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L59; - - L49: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387 - && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)) - return 16; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L59; - - L60: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) != DFmode) - { - goto L118; - } - switch (GET_CODE (x3)) - { - case FLOAT: - goto L61; - case FLOAT_EXTEND: - goto L91; - } - goto L118; - - L61: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SImode)) - { - ro[1] = x4; - goto L62; - } - goto L118; - - L62: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L63; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L63: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 17; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L91: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SFmode)) - { - ro[1] = x4; - goto L92; - } - goto L118; - - L92: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L93; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L93: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 19; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L161: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SImode)) - { - ro[0] = x4; - goto L162; - } - goto L118; - - L162: - x3 = XEXP (x2, 1); - if (register_operand (x3, SFmode)) - { - ro[1] = x3; - goto L163; - } - goto L118; - - L163: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L164; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L164: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 24; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L133: - x3 = XEXP (x2, 1); - if (nonimmediate_operand (x3, SFmode)) - { - ro[1] = x3; - goto L134; - } - x3 = XEXP (x2, 0); - goto L145; - - L134: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L135; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L145; - - L135: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387 - && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)) - return 22; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L145; - - L146: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == SFmode && GET_CODE (x3) == FLOAT && 1) - goto L147; - goto L118; - - L147: - x4 = XEXP (x3, 0); - if (nonimmediate_operand (x4, SImode)) - { - ro[1] = x4; - goto L148; - } - goto L118; - - L148: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L149; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L149: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[3] = x2; - if (TARGET_80387) - return 23; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - goto L118; - - L119: - x3 = XEXP (x2, 0); - switch (GET_MODE (x3)) - { - case DFmode: - if (register_operand (x3, DFmode)) - { - ro[0] = x3; - goto L120; - } - break; - case SFmode: - if (register_operand (x3, SFmode)) - { - ro[0] = x3; - goto L176; - } - } - goto ret0; - - L120: - x3 = XEXP (x2, 1); - if (register_operand (x3, DFmode)) - { - ro[1] = x3; - goto L121; - } - goto ret0; - - L121: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L122; - goto ret0; - - L122: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[2] = x2; - if (TARGET_80387) - return 21; - } - goto ret0; - - L176: - x3 = XEXP (x2, 1); - if (register_operand (x3, SFmode)) - { - ro[1] = x3; - goto L177; - } - goto ret0; - - L177: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L178; - goto ret0; - - L178: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[2] = x2; - if (TARGET_80387) - return 25; - } - goto ret0; - ret0: return -1; -} - -int -recog_5 (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DFmode: - if (register_operand (x2, DFmode)) - { - ro[0] = x2; - goto L242; - } - break; - case SFmode: - if (nonimmediate_operand (x2, SFmode)) - { - ro[0] = x2; - goto L294; - } - break; - case SImode: - if (register_operand (x2, SImode)) - { - ro[0] = x2; - goto L497; - } - break; - case HImode: - if (register_operand (x2, HImode)) - { - ro[0] = x2; - goto L508; - } - break; - case DImode: - if (register_operand (x2, DImode)) - { - ro[0] = x2; - goto L684; - } - } - switch (GET_CODE (x2)) - { - case CC0: - goto L12; - case PC: - goto L1068; - } - L1125: - ro[0] = x2; - goto L1126; - L1228: - switch (GET_MODE (x2)) - { - case SImode: - if (register_operand (x2, SImode)) - { - ro[0] = x2; - goto L1229; - } - break; - case HImode: - if (register_operand (x2, HImode)) - { - ro[0] = x2; - goto L1244; - } - } - goto ret0; - - L242: - x2 = XEXP (x1, 1); - if (register_operand (x2, DFmode)) - { - ro[1] = x2; - goto L243; - } - x2 = XEXP (x1, 0); - goto L1125; - - L243: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L244; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L244: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L245; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L245: - x2 = XEXP (x1, 1); - if (rtx_equal_p (x2, ro[0]) && 1) - return 48; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L294: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SFmode && GET_CODE (x2) == FLOAT_TRUNCATE && 1) - goto L295; - x2 = XEXP (x1, 0); - goto L1125; - - L295: - x3 = XEXP (x2, 0); - if (register_operand (x3, DFmode)) - { - ro[1] = x3; - goto L296; - } - x2 = XEXP (x1, 0); - goto L1125; - - L296: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L297; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L297: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SFmode)) - { - ro[2] = x2; - if (TARGET_80387) - return 62; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L497: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != SImode) - { - x2 = XEXP (x1, 0); - goto L1125; - } - switch (GET_CODE (x2)) - { - case DIV: - goto L498; - case UDIV: - goto L520; - } - x2 = XEXP (x1, 0); - goto L1125; - - L498: - x3 = XEXP (x2, 0); - if (register_operand (x3, SImode)) - { - ro[1] = x3; - goto L499; - } - x2 = XEXP (x1, 0); - goto L1125; - - L499: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L500; - } - x2 = XEXP (x1, 0); - goto L1125; - - L500: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L501; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L501: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[3] = x2; - goto L502; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L502: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MOD && 1) - goto L503; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L503: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L504; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L504: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - return 105; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L520: - x3 = XEXP (x2, 0); - if (register_operand (x3, SImode)) - { - ro[1] = x3; - goto L521; - } - x2 = XEXP (x1, 0); - goto L1125; - - L521: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L522; - } - x2 = XEXP (x1, 0); - goto L1125; - - L522: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L523; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L523: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[3] = x2; - goto L524; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L524: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == UMOD && 1) - goto L525; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L525: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L526; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L526: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - return 107; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L508: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != HImode) - { - x2 = XEXP (x1, 0); - goto L1125; - } - switch (GET_CODE (x2)) - { - case DIV: - goto L509; - case UDIV: - goto L531; - } - x2 = XEXP (x1, 0); - goto L1125; - - L509: - x3 = XEXP (x2, 0); - if (register_operand (x3, HImode)) - { - ro[1] = x3; - goto L510; - } - x2 = XEXP (x1, 0); - goto L1125; - - L510: - x3 = XEXP (x2, 1); - if (general_operand (x3, HImode)) - { - ro[2] = x3; - goto L511; - } - x2 = XEXP (x1, 0); - goto L1125; - - L511: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L512; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L512: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[3] = x2; - goto L513; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L513: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == MOD && 1) - goto L514; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L514: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L515; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L515: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - return 106; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L531: - x3 = XEXP (x2, 0); - if (register_operand (x3, HImode)) - { - ro[1] = x3; - goto L532; - } - x2 = XEXP (x1, 0); - goto L1125; - - L532: - x3 = XEXP (x2, 1); - if (general_operand (x3, HImode)) - { - ro[2] = x3; - goto L533; - } - x2 = XEXP (x1, 0); - goto L1125; - - L533: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L534; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L534: - x2 = XEXP (x1, 0); - if (register_operand (x2, HImode)) - { - ro[3] = x2; - goto L535; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L535: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == UMOD && 1) - goto L536; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L536: - x3 = XEXP (x2, 0); - if (rtx_equal_p (x3, ro[1]) && 1) - goto L537; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L537: - x3 = XEXP (x2, 1); - if (rtx_equal_p (x3, ro[2]) && 1) - return 108; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L684: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != DImode) - { - x2 = XEXP (x1, 0); - goto L1125; - } - switch (GET_CODE (x2)) - { - case ASHIFT: - goto L685; - case ASHIFTRT: - goto L713; - case LSHIFTRT: - goto L741; - } - x2 = XEXP (x1, 0); - goto L1125; - - L685: - x3 = XEXP (x2, 0); - if (register_operand (x3, DImode)) - { - ro[1] = x3; - goto L686; - } - x2 = XEXP (x1, 0); - goto L1125; - - L686: - x3 = XEXP (x2, 1); - if (register_operand (x3, QImode)) - { - ro[2] = x3; - goto L687; - } - x2 = XEXP (x1, 0); - goto L1125; - - L687: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L688; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L688: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[2]) && 1) - return 142; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L713: - x3 = XEXP (x2, 0); - if (register_operand (x3, DImode)) - { - ro[1] = x3; - goto L714; - } - x2 = XEXP (x1, 0); - goto L1125; - - L714: - x3 = XEXP (x2, 1); - if (register_operand (x3, QImode)) - { - ro[2] = x3; - goto L715; - } - x2 = XEXP (x1, 0); - goto L1125; - - L715: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L716; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L716: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[2]) && 1) - return 148; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L741: - x3 = XEXP (x2, 0); - if (register_operand (x3, DImode)) - { - ro[1] = x3; - goto L742; - } - x2 = XEXP (x1, 0); - goto L1125; - - L742: - x3 = XEXP (x2, 1); - if (register_operand (x3, QImode)) - { - ro[2] = x3; - goto L743; - } - x2 = XEXP (x1, 0); - goto L1125; - - L743: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L744; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L744: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[2]) && 1) - return 154; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - L12: - tem = recog_4 (x0, insn, pnum_clobbers); - if (tem >= 0) return tem; - x2 = XEXP (x1, 0); - goto L1125; - - L1068: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == MINUS && 1) - goto L1069; - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L1094; - } - x2 = XEXP (x1, 0); - goto L1125; - - L1069: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == REG && XINT (x3, 0) == 3 && 1) - goto L1070; - x2 = XEXP (x1, 0); - goto L1125; - - L1070: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == MEM && 1) - goto L1071; - x2 = XEXP (x1, 0); - goto L1125; - - L1071: - x4 = XEXP (x3, 0); - if (GET_MODE (x4) == SImode && GET_CODE (x4) == PLUS && 1) - goto L1072; - x2 = XEXP (x1, 0); - goto L1125; - - L1072: - x5 = XEXP (x4, 0); - if (GET_MODE (x5) == SImode && GET_CODE (x5) == MULT && 1) - goto L1073; - x2 = XEXP (x1, 0); - goto L1125; - - L1073: - x6 = XEXP (x5, 0); - if (register_operand (x6, SImode)) - { - ro[0] = x6; - goto L1074; - } - x2 = XEXP (x1, 0); - goto L1125; - - L1074: - x6 = XEXP (x5, 1); - if (GET_CODE (x6) == CONST_INT && XWINT (x6, 0) == 4 && 1) - goto L1075; - x2 = XEXP (x1, 0); - goto L1125; - - L1075: - x5 = XEXP (x4, 1); - if (GET_CODE (x5) == LABEL_REF && 1) - goto L1076; - x2 = XEXP (x1, 0); - goto L1125; - - L1076: - x6 = XEXP (x5, 0); - ro[1] = x6; - goto L1077; - - L1077: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1078; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L1078: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - return 223; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L1094: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1095; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L1095: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == LABEL_REF && 1) - goto L1096; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1125; - - L1096: - x3 = XEXP (x2, 0); - ro[1] = x3; - return 224; - - L1126: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CALL && 1) - goto L1138; - x2 = XEXP (x1, 0); - goto L1228; - - L1138: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == QImode && GET_CODE (x3) == MEM && 1) - goto L1139; - L1127: - if (call_insn_operand (x3, QImode)) - { - ro[1] = x3; - goto L1128; - } - x2 = XEXP (x1, 0); - goto L1228; - - L1139: - x4 = XEXP (x3, 0); - if (symbolic_operand (x4, SImode)) - { - ro[1] = x4; - goto L1140; - } - goto L1127; - - L1140: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L1141; - } - x3 = XEXP (x2, 0); - goto L1127; - - L1141: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1142; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L1127; - - L1142: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == REG && XINT (x2, 0) == 7 && 1) - goto L1143; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L1127; - - L1143: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1144; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L1127; - - L1144: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == REG && XINT (x3, 0) == 7 && 1) - goto L1145; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L1127; - - L1145: - x3 = XEXP (x2, 1); - if (immediate_operand (x3, SImode)) - { - ro[4] = x3; - if (!HALF_PIC_P ()) - return 233; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 1); - x3 = XEXP (x2, 0); - goto L1127; - - L1128: - x3 = XEXP (x2, 1); - if (general_operand (x3, SImode)) - { - ro[2] = x3; - goto L1129; - } - x2 = XEXP (x1, 0); - goto L1228; - - L1129: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1130; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1228; - - L1130: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == REG && XINT (x2, 0) == 7 && 1) - goto L1131; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1228; - - L1131: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1132; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1228; - - L1132: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == REG && XINT (x3, 0) == 7 && 1) - goto L1133; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1228; - - L1133: - x3 = XEXP (x2, 1); - if (immediate_operand (x3, SImode)) - { - ro[4] = x3; - return 232; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1228; - - L1229: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) != SImode) - goto ret0; - switch (GET_CODE (x2)) - { - case PLUS: - goto L1230; - case UNSPEC: - if (XINT (x2, 1) == 0 && XVECLEN (x2, 0) == 3 && 1) - goto L1306; - } - goto ret0; - - L1230: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == FFS && 1) - goto L1231; - goto ret0; - - L1231: - x4 = XEXP (x3, 0); - if (general_operand (x4, SImode)) - { - ro[1] = x4; - goto L1232; - } - goto ret0; - - L1232: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - goto L1233; - goto ret0; - - L1233: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1234; - goto ret0; - - L1234: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[2] = x2; - return 250; - } - goto ret0; - - L1306: - x3 = XVECEXP (x2, 0, 0); - if (GET_MODE (x3) == BLKmode && GET_CODE (x3) == MEM && 1) - goto L1307; - goto ret0; - - L1307: - x4 = XEXP (x3, 0); - if (address_operand (x4, SImode)) - { - ro[1] = x4; - goto L1308; - } - goto ret0; - - L1308: - x3 = XVECEXP (x2, 0, 1); - if (register_operand (x3, QImode)) - { - ro[2] = x3; - goto L1309; - } - goto ret0; - - L1309: - x3 = XVECEXP (x2, 0, 2); - if (immediate_operand (x3, SImode)) - { - ro[3] = x3; - goto L1310; - } - goto ret0; - - L1310: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1311; - goto ret0; - - L1311: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - return 262; - goto ret0; - - L1244: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == HImode && GET_CODE (x2) == PLUS && 1) - goto L1245; - goto ret0; - - L1245: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == HImode && GET_CODE (x3) == FFS && 1) - goto L1246; - goto ret0; - - L1246: - x4 = XEXP (x3, 0); - if (general_operand (x4, HImode)) - { - ro[1] = x4; - goto L1247; - } - goto ret0; - - L1247: - x3 = XEXP (x2, 1); - if (GET_CODE (x3) == CONST_INT && XWINT (x3, 0) == -1 && 1) - goto L1248; - goto ret0; - - L1248: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1249; - goto ret0; - - L1249: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, HImode)) - { - ro[2] = x2; - return 252; - } - goto ret0; - ret0: return -1; -} - -int -recog (x0, insn, pnum_clobbers) - register rtx x0; - rtx insn; - int *pnum_clobbers; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - int tem; - - L1170: - switch (GET_CODE (x0)) - { - case UNSPEC: - if (GET_MODE (x0) == SImode && XINT (x0, 1) == 0 && XVECLEN (x0, 0) == 1 && 1) - goto L1171; - break; - case SET: - goto L200; - case PARALLEL: - if (XVECLEN (x0, 0) == 2 && 1) - goto L10; - if (XVECLEN (x0, 0) == 5 && 1) - goto L299; - if (XVECLEN (x0, 0) == 4 && 1) - goto L313; - if (XVECLEN (x0, 0) == 3 && 1) - goto L363; - if (XVECLEN (x0, 0) == 6 && 1) - goto L1175; - break; - case CALL: - goto L1117; - case RETURN: - if (simple_386_epilogue ()) - return 242; - break; - case CONST_INT: - if (XWINT (x0, 0) == 0 && 1) - return 243; - } - goto ret0; - - L1171: - x1 = XVECEXP (x0, 0, 0); - if (memory_operand (x1, SImode)) - { - ro[0] = x1; - return 241; - } - goto ret0; - L200: - return recog_3 (x0, insn, pnum_clobbers); - - L10: - x1 = XVECEXP (x0, 0, 0); - switch (GET_CODE (x1)) - { - case SET: - goto L241; - case CALL: - goto L1108; - } - goto ret0; - L241: - return recog_5 (x0, insn, pnum_clobbers); - - L1108: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == QImode && GET_CODE (x2) == MEM && 1) - goto L1109; - L1099: - if (call_insn_operand (x2, QImode)) - { - ro[0] = x2; - goto L1100; - } - goto ret0; - - L1109: - x3 = XEXP (x2, 0); - if (symbolic_operand (x3, SImode)) - { - ro[0] = x3; - goto L1110; - } - goto L1099; - - L1110: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1111; - } - x2 = XEXP (x1, 0); - goto L1099; - - L1111: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1112; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1099; - - L1112: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == REG && XINT (x2, 0) == 7 && 1) - goto L1113; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1099; - - L1113: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1114; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1099; - - L1114: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == REG && XINT (x3, 0) == 7 && 1) - goto L1115; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1099; - - L1115: - x3 = XEXP (x2, 1); - if (immediate_operand (x3, SImode)) - { - ro[3] = x3; - if (!HALF_PIC_P ()) - return 227; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1099; - - L1100: - x2 = XEXP (x1, 1); - if (general_operand (x2, SImode)) - { - ro[1] = x2; - goto L1101; - } - goto ret0; - - L1101: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == SET && 1) - goto L1102; - goto ret0; - - L1102: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == REG && XINT (x2, 0) == 7 && 1) - goto L1103; - goto ret0; - - L1103: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == PLUS && 1) - goto L1104; - goto ret0; - - L1104: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == SImode && GET_CODE (x3) == REG && XINT (x3, 0) == 7 && 1) - goto L1105; - goto ret0; - - L1105: - x3 = XEXP (x2, 1); - if (immediate_operand (x3, SImode)) - { - ro[3] = x3; - return 226; - } - goto ret0; - - L299: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == SET && 1) - goto L300; - goto ret0; - - L300: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == DImode && general_operand (x2, DImode)) - { - ro[0] = x2; - goto L301; - } - goto ret0; - - L301: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == DImode && GET_CODE (x2) == FIX && 1) - goto L302; - goto ret0; - - L302: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) != FIX) - goto ret0; - switch (GET_MODE (x3)) - { - case DFmode: - goto L303; - case SFmode: - goto L329; - } - goto ret0; - - L303: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L304; - } - goto ret0; - - L304: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L305; - goto ret0; - - L305: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L306; - goto ret0; - - L306: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L307; - goto ret0; - - L307: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L308; - } - goto ret0; - - L308: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L309; - goto ret0; - - L309: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[3] = x2; - goto L310; - } - goto ret0; - - L310: - x1 = XVECEXP (x0, 0, 4); - if (GET_CODE (x1) == CLOBBER && 1) - goto L311; - goto ret0; - - L311: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[4] = x2; - if (TARGET_80387) - return 67; - } - goto ret0; - - L329: - x4 = XEXP (x3, 0); - if (register_operand (x4, SFmode)) - { - ro[1] = x4; - goto L330; - } - goto ret0; - - L330: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L331; - goto ret0; - - L331: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L332; - goto ret0; - - L332: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L333; - goto ret0; - - L333: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L334; - } - goto ret0; - - L334: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L335; - goto ret0; - - L335: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[3] = x2; - goto L336; - } - goto ret0; - - L336: - x1 = XVECEXP (x0, 0, 4); - if (GET_CODE (x1) == CLOBBER && 1) - goto L337; - goto ret0; - - L337: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[4] = x2; - if (TARGET_80387) - return 68; - } - goto ret0; - - L313: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == SET && 1) - goto L314; - goto ret0; - - L314: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case DImode: - if (general_operand (x2, DImode)) - { - ro[0] = x2; - goto L315; - } - break; - case SImode: - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L353; - } - } - goto ret0; - - L315: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == DImode && GET_CODE (x2) == FIX && 1) - goto L316; - goto ret0; - - L316: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) != FIX) - goto ret0; - switch (GET_MODE (x3)) - { - case DFmode: - goto L317; - case SFmode: - goto L343; - } - goto ret0; - - L317: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L318; - } - goto ret0; - - L318: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L319; - goto ret0; - - L319: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L320; - goto ret0; - - L320: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L321; - goto ret0; - - L321: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L322; - } - goto ret0; - - L322: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L323; - goto ret0; - - L323: - x2 = XEXP (x1, 0); - if (pnum_clobbers != 0 && memory_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 67; - } - } - goto ret0; - - L343: - x4 = XEXP (x3, 0); - if (register_operand (x4, SFmode)) - { - ro[1] = x4; - goto L344; - } - goto ret0; - - L344: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L345; - goto ret0; - - L345: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L346; - goto ret0; - - L346: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L347; - goto ret0; - - L347: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L348; - } - goto ret0; - - L348: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L349; - goto ret0; - - L349: - x2 = XEXP (x1, 0); - if (pnum_clobbers != 0 && memory_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 68; - } - } - goto ret0; - - L353: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == FIX && 1) - goto L354; - goto ret0; - - L354: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) != FIX) - goto ret0; - switch (GET_MODE (x3)) - { - case DFmode: - goto L355; - case SFmode: - goto L377; - } - goto ret0; - - L355: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L356; - } - goto ret0; - - L356: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L357; - goto ret0; - - L357: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L358; - } - goto ret0; - - L358: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L359; - goto ret0; - - L359: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[3] = x2; - goto L360; - } - goto ret0; - - L360: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L361; - goto ret0; - - L361: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[4] = x2; - if (TARGET_80387) - return 71; - } - goto ret0; - - L377: - x4 = XEXP (x3, 0); - if (register_operand (x4, SFmode)) - { - ro[1] = x4; - goto L378; - } - goto ret0; - - L378: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L379; - goto ret0; - - L379: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L380; - } - goto ret0; - - L380: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L381; - goto ret0; - - L381: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[3] = x2; - goto L382; - } - goto ret0; - - L382: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L383; - goto ret0; - - L383: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[4] = x2; - if (TARGET_80387) - return 72; - } - goto ret0; - - L363: - x1 = XVECEXP (x0, 0, 0); - switch (GET_CODE (x1)) - { - case SET: - goto L364; - case CALL: - goto L1165; - } - goto ret0; - - L364: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == SImode && general_operand (x2, SImode)) - { - ro[0] = x2; - goto L365; - } - goto ret0; - - L365: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == FIX && 1) - goto L366; - goto ret0; - - L366: - x3 = XEXP (x2, 0); - if (GET_CODE (x3) != FIX) - goto ret0; - switch (GET_MODE (x3)) - { - case DFmode: - goto L367; - case SFmode: - goto L389; - } - goto ret0; - - L367: - x4 = XEXP (x3, 0); - if (register_operand (x4, DFmode)) - { - ro[1] = x4; - goto L368; - } - goto ret0; - - L368: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L369; - goto ret0; - - L369: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L370; - } - goto ret0; - - L370: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L371; - goto ret0; - - L371: - x2 = XEXP (x1, 0); - if (pnum_clobbers != 0 && memory_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 71; - } - } - goto ret0; - - L389: - x4 = XEXP (x3, 0); - if (register_operand (x4, SFmode)) - { - ro[1] = x4; - goto L390; - } - goto ret0; - - L390: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == CLOBBER && 1) - goto L391; - goto ret0; - - L391: - x2 = XEXP (x1, 0); - if (memory_operand (x2, SImode)) - { - ro[2] = x2; - goto L392; - } - goto ret0; - - L392: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == CLOBBER && 1) - goto L393; - goto ret0; - - L393: - x2 = XEXP (x1, 0); - if (pnum_clobbers != 0 && memory_operand (x2, SImode)) - { - ro[3] = x2; - if (TARGET_80387) - { - *pnum_clobbers = 1; - return 72; - } - } - goto ret0; - - L1165: - x2 = XEXP (x1, 0); - if (GET_MODE (x2) == QImode && GET_CODE (x2) == MEM && 1) - goto L1166; - L1159: - if (call_insn_operand (x2, QImode)) - { - ro[0] = x2; - goto L1160; - } - goto ret0; - - L1166: - x3 = XEXP (x2, 0); - if (symbolic_operand (x3, SImode)) - { - ro[0] = x3; - goto L1167; - } - goto L1159; - - L1167: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - goto L1168; - x2 = XEXP (x1, 0); - goto L1159; - - L1168: - x1 = XVECEXP (x0, 0, 1); - if (memory_operand (x1, DImode)) - { - ro[1] = x1; - goto L1169; - } - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1159; - - L1169: - x1 = XVECEXP (x0, 0, 2); - ro[2] = x1; - if (!HALF_PIC_P ()) - return 239; - x1 = XVECEXP (x0, 0, 0); - x2 = XEXP (x1, 0); - goto L1159; - - L1160: - x2 = XEXP (x1, 1); - if (GET_CODE (x2) == CONST_INT && XWINT (x2, 0) == 0 && 1) - goto L1161; - goto ret0; - - L1161: - x1 = XVECEXP (x0, 0, 1); - if (memory_operand (x1, DImode)) - { - ro[1] = x1; - goto L1162; - } - goto ret0; - - L1162: - x1 = XVECEXP (x0, 0, 2); - ro[2] = x1; - return 238; - - L1175: - x1 = XVECEXP (x0, 0, 0); - if (GET_CODE (x1) == SET && 1) - goto L1176; - goto ret0; - - L1176: - x2 = XEXP (x1, 0); - switch (GET_MODE (x2)) - { - case BLKmode: - if (GET_CODE (x2) == MEM && 1) - goto L1177; - break; - case SImode: - if (general_operand (x2, SImode)) - { - ro[0] = x2; - goto L1193; - } - } - if (GET_CODE (x2) == CC0 && 1) - goto L1211; - goto ret0; - - L1177: - x3 = XEXP (x2, 0); - if (address_operand (x3, SImode)) - { - ro[0] = x3; - goto L1178; - } - goto ret0; - - L1178: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == BLKmode && GET_CODE (x2) == MEM && 1) - goto L1179; - goto ret0; - - L1179: - x3 = XEXP (x2, 0); - if (address_operand (x3, SImode)) - { - ro[1] = x3; - goto L1180; - } - goto ret0; - - L1180: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1181; - goto ret0; - - L1181: - x2 = XEXP (x1, 0); - if (GET_CODE (x2) == CONST_INT && 1) - { - ro[2] = x2; - goto L1182; - } - goto ret0; - - L1182: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == USE && 1) - goto L1183; - goto ret0; - - L1183: - x2 = XEXP (x1, 0); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - goto L1184; - } - goto ret0; - - L1184: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1185; - goto ret0; - - L1185: - x2 = XEXP (x1, 0); - if (scratch_operand (x2, SImode)) - { - ro[4] = x2; - goto L1186; - } - goto ret0; - - L1186: - x1 = XVECEXP (x0, 0, 4); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1187; - goto ret0; - - L1187: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1188; - goto ret0; - - L1188: - x1 = XVECEXP (x0, 0, 5); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1189; - goto ret0; - - L1189: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - return 245; - goto ret0; - - L1193: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == COMPARE && 1) - goto L1194; - goto ret0; - - L1194: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == BLKmode && GET_CODE (x3) == MEM && 1) - goto L1195; - goto ret0; - - L1195: - x4 = XEXP (x3, 0); - if (address_operand (x4, SImode)) - { - ro[1] = x4; - goto L1196; - } - goto ret0; - - L1196: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == BLKmode && GET_CODE (x3) == MEM && 1) - goto L1197; - goto ret0; - - L1197: - x4 = XEXP (x3, 0); - if (address_operand (x4, SImode)) - { - ro[2] = x4; - goto L1198; - } - goto ret0; - - L1198: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1199; - goto ret0; - - L1199: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[3] = x2; - goto L1200; - } - goto ret0; - - L1200: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == USE && 1) - goto L1201; - goto ret0; - - L1201: - x2 = XEXP (x1, 0); - if (immediate_operand (x2, SImode)) - { - ro[4] = x2; - goto L1202; - } - goto ret0; - - L1202: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1203; - goto ret0; - - L1203: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L1204; - goto ret0; - - L1204: - x1 = XVECEXP (x0, 0, 4); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1205; - goto ret0; - - L1205: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[2]) && 1) - goto L1206; - goto ret0; - - L1206: - x1 = XVECEXP (x0, 0, 5); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1207; - goto ret0; - - L1207: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[3]) && 1) - return 247; - goto ret0; - - L1211: - x2 = XEXP (x1, 1); - if (GET_MODE (x2) == SImode && GET_CODE (x2) == COMPARE && 1) - goto L1212; - goto ret0; - - L1212: - x3 = XEXP (x2, 0); - if (GET_MODE (x3) == BLKmode && GET_CODE (x3) == MEM && 1) - goto L1213; - goto ret0; - - L1213: - x4 = XEXP (x3, 0); - if (address_operand (x4, SImode)) - { - ro[0] = x4; - goto L1214; - } - goto ret0; - - L1214: - x3 = XEXP (x2, 1); - if (GET_MODE (x3) == BLKmode && GET_CODE (x3) == MEM && 1) - goto L1215; - goto ret0; - - L1215: - x4 = XEXP (x3, 0); - if (address_operand (x4, SImode)) - { - ro[1] = x4; - goto L1216; - } - goto ret0; - - L1216: - x1 = XVECEXP (x0, 0, 1); - if (GET_CODE (x1) == USE && 1) - goto L1217; - goto ret0; - - L1217: - x2 = XEXP (x1, 0); - if (register_operand (x2, SImode)) - { - ro[2] = x2; - goto L1218; - } - goto ret0; - - L1218: - x1 = XVECEXP (x0, 0, 2); - if (GET_CODE (x1) == USE && 1) - goto L1219; - goto ret0; - - L1219: - x2 = XEXP (x1, 0); - if (immediate_operand (x2, SImode)) - { - ro[3] = x2; - goto L1220; - } - goto ret0; - - L1220: - x1 = XVECEXP (x0, 0, 3); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1221; - goto ret0; - - L1221: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[0]) && 1) - goto L1222; - goto ret0; - - L1222: - x1 = XVECEXP (x0, 0, 4); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1223; - goto ret0; - - L1223: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[1]) && 1) - goto L1224; - goto ret0; - - L1224: - x1 = XVECEXP (x0, 0, 5); - if (GET_CODE (x1) == CLOBBER && 1) - goto L1225; - goto ret0; - - L1225: - x2 = XEXP (x1, 0); - if (rtx_equal_p (x2, ro[2]) && 1) - return 248; - goto ret0; - - L1117: - x1 = XEXP (x0, 0); - if (call_insn_operand (x1, QImode)) - { - ro[0] = x1; - goto L1118; - } - L1120: - if (GET_MODE (x1) == QImode && GET_CODE (x1) == MEM && 1) - goto L1121; - goto ret0; - - L1118: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - { - ro[1] = x1; - return 229; - } - x1 = XEXP (x0, 0); - goto L1120; - - L1121: - x2 = XEXP (x1, 0); - if (symbolic_operand (x2, SImode)) - { - ro[0] = x2; - goto L1122; - } - goto ret0; - - L1122: - x1 = XEXP (x0, 1); - if (general_operand (x1, SImode)) - { - ro[1] = x1; - if (!HALF_PIC_P ()) - return 230; - } - goto ret0; - ret0: return -1; -} - -rtx -split_insns (x0, insn) - register rtx x0; - rtx insn; -{ - register rtx *ro = &recog_operand[0]; - register rtx x1, x2, x3, x4, x5, x6; - rtx tem; - - goto ret0; - ret0: return 0; -} - diff --git a/gnu/usr.bin/gcc2/i386/perform.h b/gnu/usr.bin/gcc2/i386/perform.h deleted file mode 100644 index 53e6240e2572..000000000000 --- a/gnu/usr.bin/gcc2/i386/perform.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Definitions for AT&T assembler syntax for the Intel 80386. - Copyright (C) 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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. - -GNU CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: perform.h,v 1.2 1993/08/02 17:37:10 mycroft Exp $ -*/ - -/* Defines to be able to build libgcc.a with GCC. */ - -/* It might seem that these are not important, since gcc 2 will never - call libgcc for these functions. But programs might be linked with - code compiled by gcc 1, and then these will be used. */ - -/* The arg names used to be a and b, but `a' appears inside strings - and that confuses non-ANSI cpp. */ - -#define perform_udivsi3(arg0,arg1) \ -{ \ - register int dx asm("dx"); \ - register int ax asm("ax"); \ - \ - dx = 0; \ - ax = arg0; \ - asm ("divl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (arg1), "d" (dx)); \ - return ax; \ -} - -#define perform_divsi3(arg0,arg1) \ -{ \ - register int dx asm("dx"); \ - register int ax asm("ax"); \ - \ - ax = arg0; \ - asm ("cltd\n\tidivl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (arg1)); \ - return ax; \ -} - -#define perform_umodsi3(arg0,arg1) \ -{ \ - register int dx asm("dx"); \ - register int ax asm("ax"); \ - \ - dx = 0; \ - ax = arg0; \ - asm ("divl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (arg1), "d" (dx)); \ - return dx; \ -} - -#define perform_modsi3(arg0,arg1) \ -{ \ - register int dx asm("dx"); \ - register int ax asm("ax"); \ - \ - ax = arg0; \ - asm ("cltd\n\tidivl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" (arg1)); \ - return dx; \ -} - -#define perform_fixdfsi(arg0) \ -{ \ - auto unsigned short ostatus; \ - auto unsigned short nstatus; \ - auto int ret; \ - auto double tmp; \ - \ - &ostatus; /* guarantee these land in memory */ \ - &nstatus; \ - &ret; \ - &tmp; \ - \ - asm volatile ("fnstcw %0" : "=m" (ostatus)); \ - nstatus = ostatus | 0x0c00; \ - asm volatile ("fldcw %0" : /* no outputs */ : "m" (nstatus)); \ - tmp = arg0; \ - asm volatile ("fldl %0" : /* no outputs */ : "m" (tmp)); \ - asm volatile ("fistpl %0" : "=m" (ret)); \ - asm volatile ("fldcw %0" : /* no outputs */ : "m" (ostatus)); \ - \ - return ret; \ -} - diff --git a/gnu/usr.bin/gcc2/i386/tconfig.h b/gnu/usr.bin/gcc2/i386/tconfig.h deleted file mode 100644 index fcbefa9c8b38..000000000000 --- a/gnu/usr.bin/gcc2/i386/tconfig.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Configuration for GNU C-compiler for Intel 80386. - Copyright (C) 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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. - -GNU CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: tconfig.h,v 1.2 1993/08/02 17:37:11 mycroft Exp $ -*/ - -#ifndef i386 -#define i386 -#endif - -/* #defines that need visibility everywhere. */ -#define FALSE 0 -#define TRUE 1 - -/* This describes the machine the compiler is hosted on. */ -#define HOST_BITS_PER_CHAR 8 -#define HOST_BITS_PER_SHORT 16 -#define HOST_BITS_PER_INT 32 -#define HOST_BITS_PER_LONG 32 -#define HOST_BITS_PER_LONGLONG 64 - -/* Arguments to use with `exit'. */ -#define SUCCESS_EXIT_CODE 0 -#define FATAL_EXIT_CODE 33 - -/* If compiled with GNU C, use the built-in alloca */ -#ifdef __GNUC__ -#undef alloca -#define alloca __builtin_alloca -#endif - -/* target machine dependencies. - tm.h is a symbolic link to the actual target specific file. */ - -#include "tm.h" diff --git a/gnu/usr.bin/gcc2/i386/tm.h b/gnu/usr.bin/gcc2/i386/tm.h deleted file mode 100644 index cc2255b90735..000000000000 --- a/gnu/usr.bin/gcc2/i386/tm.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Configuration for an i386 running NetBSD as the target machine. - - $Id: tm.h,v 1.3 1993/08/07 07:42:27 cgd Exp $ -*/ - -/* This is tested by i386gas.h. */ -#define YES_UNDERSCORES - -#include "i386/gstabs.h" - -/* Get perform_* macros to build libgcc.a. */ -#include "i386/perform.h" - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-Dunix -Di386 -D____NetBSD____ -D__NetBSD__ -D____386BSD____ -D__386BSD__ -DBSD_NET2" - -/* Like the default, except no -lg. */ -#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" - -#undef SIZE_TYPE -#define SIZE_TYPE "unsigned int" - -#undef PTRDIFF_TYPE -#define PTRDIFF_TYPE "int" - -#undef WCHAR_TYPE -#define WCHAR_TYPE "short unsigned int" - -#define WCHAR_UNSIGNED 1 - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE 16 - -/* NetBSD does have atexit. */ - -#define HAVE_ATEXIT - -/* Redefine this to use %eax instead of %edx. */ -#undef FUNCTION_PROFILER -#define FUNCTION_PROFILER(FILE, LABELNO) \ -{ \ - if (flag_pic) \ - { \ - fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n", \ - LPREFIX, (LABELNO)); \ - fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ - } \ - else \ - { \ - fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO)); \ - fprintf (FILE, "\tcall mcount\n"); \ - } \ -} - -/* There are conflicting reports about whether this system uses - a different assembler syntax. wilson@cygnus.com says # is right. */ -#undef COMMENT_BEGIN -#define COMMENT_BEGIN "#" - -#undef ASM_APP_ON -#define ASM_APP_ON "#APP\n" - -#undef ASM_APP_OFF -#define ASM_APP_OFF "#NO_APP\n" - -/* The following macros are stolen from i386v4.h */ -/* These have to be defined to get PIC code correct */ - -/* This is how to output an element of a case-vector that is relative. - This is only used for PIC code. See comments by the `casesi' insn in - i386.md for an explanation of the expression this outputs. */ - -#undef ASM_OUTPUT_ADDR_DIFF_ELT -#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ - fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) - -/* Indicate that jump tables go in the text section. This is - necessary when compiling PIC code. */ - -#define JUMP_TABLES_IN_TEXT_SECTION - -/* Don't default to pcc-struct-return, because gcc is the only compiler, and - we want to retain compatibility with older gcc versions. */ -#define DEFAULT_PCC_STRUCT_RETURN 0 diff --git a/gnu/usr.bin/gcc2/i386/unix.h b/gnu/usr.bin/gcc2/i386/unix.h deleted file mode 100644 index 2da09124f7f1..000000000000 --- a/gnu/usr.bin/gcc2/i386/unix.h +++ /dev/null @@ -1,148 +0,0 @@ -/* Definitions for Unix assembler syntax for the Intel 80386. - Copyright (C) 1988 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC 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. - -GNU CC 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 CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: unix.h,v 1.2 1993/08/02 17:37:12 mycroft Exp $ -*/ - -/* This file defines the aspects of assembler syntax - that are the same for all the i386 Unix systems - (though they may differ in non-Unix systems). */ - -/* Define some concatenation macros to concatenate an opcode - and one, two or three operands. In other assembler syntaxes - they may alter the order of ther operands. */ - -/* Note that the other files fail to use these - in some of the places where they should. */ - -#ifdef __STDC__ -#define AS2(a,b,c) #a " " #b "," #c -#define AS3(a,b,c,d) #a " " #b "," #c "," #d -#define AS1(a,b) #a " " #b -#else -#define AS1(a,b) "a b" -#define AS2(a,b,c) "a b,c" -#define AS3(a,b,c,d) "a b,c,d" -#endif - -/* Define macro used to output shift-double opcodes when the shift - count is in %cl. Some assemblers require %cl as an argument; - some don't. This macro controls what to do: by default, don't - print %cl. */ -#define AS3_SHIFT_DOUBLE(a,b,c,d) AS2 (a,c,d) - -/* Output the size-letter for an opcode. - CODE is the letter used in an operand spec (L, B, W, S or Q). - CH is the corresponding lower case letter - (except if CODE is `Q' then CH is `l', unless GAS_MNEMONICS). */ -#define PUT_OP_SIZE(CODE,CH,FILE) putc (CH,(FILE)) - -/* Opcode suffix for fullword insn. */ -#define L_SIZE "l" - -/* Prefix for register names in this syntax. */ -#define RP "%" - -/* Prefix for immediate operands in this syntax. */ -#define IP "$" - -/* Indirect call instructions should use `*'. */ -#define USE_STAR 1 - -/* Prefix for a memory-operand X. */ -#define PRINT_PTR(X, FILE) - -/* Delimiters that surround base reg and index reg. */ -#define ADDR_BEG(FILE) putc('(', (FILE)) -#define ADDR_END(FILE) putc(')', (FILE)) - -/* Print an index register (whose rtx is IREG). */ -#define PRINT_IREG(FILE,IREG) \ - do \ - { fputs (",", (FILE)); PRINT_REG ((IREG), 0, (FILE)); } \ - while (0) - -/* Print an index scale factor SCALE. */ -#define PRINT_SCALE(FILE,SCALE) \ - if ((SCALE) != 1) fprintf ((FILE), ",%d", (SCALE)) - -/* Print a base/index combination. - BREG is the base reg rtx, IREG is the index reg rtx, - and SCALE is the index scale factor (an integer). */ - -#define PRINT_B_I_S(BREG,IREG,SCALE,FILE) \ - { ADDR_BEG (FILE); \ - if (BREG) PRINT_REG ((BREG), 0, (FILE)); \ - if ((IREG) != 0) \ - { PRINT_IREG ((FILE), (IREG)); \ - PRINT_SCALE ((FILE), (SCALE)); } \ - ADDR_END (FILE); } - -/* Define the syntax of pseudo-ops, labels and comments. */ - -/* String containing the assembler's comment-starter. */ - -#define ASM_COMMENT_START "/" -#define COMMENT_BEGIN "/" - -/* Output to assembler file text saying following lines - may contain character constants, extra white space, comments, etc. */ - -#define ASM_APP_ON "/APP\n" - -/* Output to assembler file text saying following lines - no longer contain unusual constructs. */ - -#define ASM_APP_OFF "/NO_APP\n" - -/* Output before read-only data. */ - -#define TEXT_SECTION_ASM_OP ".text" - -/* Output before writable (initialized) data. */ - -#define DATA_SECTION_ASM_OP ".data" - -/* Output before writable (uninitialized) data. */ - -#define BSS_SECTION_ASM_OP ".bss" - -/* This is how to output a command to make the user-level label named NAME - defined for reference from other files. */ - -#define ASM_GLOBALIZE_LABEL(FILE,NAME) \ - (fputs (".globl ", FILE), assemble_name (FILE, NAME), fputs ("\n", FILE)) - -/* By default, target has a 80387, uses IEEE compatible arithmetic, - and returns float values in the 387, ie, - (TARGET_80387 | TARGET_IEEE_FP | TARGET_FLOAT_RETURNS_IN_80387) */ - -#define TARGET_DEFAULT 0301 - -/* Floating-point return values come in the FP register. */ - -#define VALUE_REGNO(MODE) \ - (GET_MODE_CLASS (MODE) == MODE_FLOAT \ - && TARGET_FLOAT_RETURNS_IN_80387 ? FIRST_FLOAT_REG : 0) - -/* 1 if N is a possible register number for a function value. */ - -#define FUNCTION_VALUE_REGNO_P(N) \ - ((N) == 0 || ((N)== FIRST_FLOAT_REG && TARGET_FLOAT_RETURNS_IN_80387)) - diff --git a/gnu/usr.bin/gcc2/libgcc/_ashlsi3.c b/gnu/usr.bin/gcc2/libgcc/_ashlsi3.c deleted file mode 100644 index becd3e1bef47..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_ashlsi3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _ashlsi3.c,v 1.2 1993/08/02 17:37:38 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__ashlsi3 (a, b) - long int a, b; -{ - return a << b ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_ashrdi3.c b/gnu/usr.bin/gcc2/libgcc/_ashrdi3.c deleted file mode 100644 index 2acbe29b80e7..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_ashrdi3.c +++ /dev/null @@ -1,112 +0,0 @@ -/* $Id: _ashrdi3.c,v 1.2 1993/08/02 17:37:40 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DItype -__ashrdi3 (u, b) - DItype u; - SItype b; -{ - DIunion w; - SItype bm; - DIunion uu; - if (b == 0) - return u; - uu.ll = u; - bm = (sizeof (SItype) * 8 ) - b; - if (bm <= 0) - { - - w.s.high = uu.s.high >> (sizeof (SItype) * 8 - 1); - w.s.low = uu.s.high >> -bm; - } - else - { - USItype carries = (USItype)uu.s.high << bm; - w.s.high = uu.s.high >> b; - w.s.low = ((USItype)uu.s.low >> b) | carries; - } - return w.ll; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_ashrsi3.c b/gnu/usr.bin/gcc2/libgcc/_ashrsi3.c deleted file mode 100644 index edea6d7574fb..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_ashrsi3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _ashrsi3.c,v 1.2 1993/08/02 17:37:41 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__ashrsi3 (a, b) - long int a, b; -{ - return a >> b ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_bb.c b/gnu/usr.bin/gcc2/libgcc/_bb.c deleted file mode 100644 index b64b230a9b7c..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_bb.c +++ /dev/null @@ -1,89 +0,0 @@ -/* $Id: _bb.c,v 1.2 1993/08/02 17:37:42 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -void -__bb_avoid_warning () -{} diff --git a/gnu/usr.bin/gcc2/libgcc/_clear_cache.c b/gnu/usr.bin/gcc2/libgcc/_clear_cache.c deleted file mode 100644 index a5c58818a349..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_clear_cache.c +++ /dev/null @@ -1,91 +0,0 @@ -/* $Id: _clear_cache.c,v 1.2 1993/08/02 17:37:43 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -void -__clear_cache (beg, end) - char *beg, *end; -{ -} diff --git a/gnu/usr.bin/gcc2/libgcc/_cmpdi2.c b/gnu/usr.bin/gcc2/libgcc/_cmpdi2.c deleted file mode 100644 index 08fc70763b59..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_cmpdi2.c +++ /dev/null @@ -1,102 +0,0 @@ -/* $Id: _cmpdi2.c,v 1.2 1993/08/02 17:37:44 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -word_type -__cmpdi2 (a, b) - DItype a, b; -{ - DIunion au, bu; - au.ll = a, bu.ll = b; - if (au.s.high < bu.s.high) - return 0; - else if (au.s.high > bu.s.high) - return 2; - if ((USItype) au.s.low < (USItype) bu.s.low) - return 0; - else if ((USItype) au.s.low > (USItype) bu.s.low) - return 2; - return 1; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_ctors.c b/gnu/usr.bin/gcc2/libgcc/_ctors.c deleted file mode 100644 index 730fb0a76830..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_ctors.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $Id: _ctors.c,v 1.2 1993/08/02 17:37:45 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -extern void atexit (void (*) (void)); -typedef void (*func_ptr) (void); -extern func_ptr __CTOR_LIST__[]; -extern func_ptr __DTOR_LIST__[]; -extern void __do_global_dtors (); -func_ptr __CTOR_LIST__[2]; -func_ptr __DTOR_LIST__[2]; diff --git a/gnu/usr.bin/gcc2/libgcc/_divdf3.c b/gnu/usr.bin/gcc2/libgcc/_divdf3.c deleted file mode 100644 index 156287a1b843..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_divdf3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _divdf3.c,v 1.2 1993/08/02 17:37:46 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -double -__divdf3 (a, b) - double a, b; -{ - return a / b ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_divdi3.c b/gnu/usr.bin/gcc2/libgcc/_divdi3.c deleted file mode 100644 index 533f6fecb8b5..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_divdi3.c +++ /dev/null @@ -1,119 +0,0 @@ -/* $Id: _divdi3.c,v 1.2 1993/08/02 17:37:46 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -static inline -DItype -__negdi2 (u) - DItype u; -{ - DIunion w; - DIunion uu; - uu.ll = u; - w.s.low = -uu.s.low; - w.s.high = -uu.s.high - ((USItype) w.s.low > 0); - return w.ll; -} -UDItype __udivmoddi4 (); -DItype -__divdi3 (u, v) - DItype u, v; -{ - SItype c = 0; - DIunion uu, vv; - DItype w; - uu.ll = u; - vv.ll = v; - if (uu.s.high < 0) - c = ~c, - uu.ll = __negdi2 (uu.ll); - if (vv.s.high < 0) - c = ~c, - vv.ll = __negdi2 (vv.ll); - w = __udivmoddi4 (uu.ll, vv.ll, (UDItype *) 0); - if (c) - w = __negdi2 (w); - return w; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_divsf3.c b/gnu/usr.bin/gcc2/libgcc/_divsf3.c deleted file mode 100644 index 55e77644abe3..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_divsf3.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _divsf3.c,v 1.2 1993/08/02 17:37:47 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -float -__divsf3 (a, b) - union flt_or_int a, b; -{ - union flt_or_value intify; - return (( a ).f) / (( b ).f) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_divsi3.c b/gnu/usr.bin/gcc2/libgcc/_divsi3.c deleted file mode 100644 index c004f35aa73b..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_divsi3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _divsi3.c,v 1.2 1993/08/02 17:37:48 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__divsi3 (a, b) - long int a, b; -{ - { register int dx asm("dx"); register int ax asm("ax"); ax = a ; asm ("cltd\n\tidivl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" ( b )); return ax; } ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_eprintf.c b/gnu/usr.bin/gcc2/libgcc/_eprintf.c deleted file mode 100644 index 4f6c9beb51af..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_eprintf.c +++ /dev/null @@ -1,205 +0,0 @@ -/* $Id: _eprintf.c,v 1.2 1993/08/02 17:37:49 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -typedef size_t; -typedef long fpos_t; -struct __sbuf { - unsigned char *_base; - int _size; -}; -typedef struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - void *_cookie; - int (*_close) (void *) ; - int (*_read) (void *, char *, int) ; - fpos_t (*_seek) (void *, fpos_t, int) ; - int (*_write) (void *, const char *, int) ; - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - struct __sbuf _lb; - - int _blksize; - int _offset; -} FILE; -extern FILE __sF[]; - -void clearerr (FILE *) ; -int fclose (FILE *) ; -int feof (FILE *) ; -int ferror (FILE *) ; -int fflush (FILE *) ; -int fgetc (FILE *) ; -int fgetpos (FILE *, fpos_t *) ; -char *fgets (char *, size_t, FILE *) ; -FILE *fopen (const char *, const char *) ; -int fprintf (FILE *, const char *, ...) ; -int fputc (int, FILE *) ; -int fputs (const char *, FILE *) ; -int fread (void *, size_t, size_t, FILE *) ; -FILE *freopen (const char *, const char *, FILE *) ; -int fscanf (FILE *, const char *, ...) ; -int fseek (FILE *, long, int) ; -int fsetpos (FILE *, const fpos_t *) ; -long ftell (const FILE *) ; -int fwrite (const void *, size_t, size_t, FILE *) ; -int getc (FILE *) ; -int getchar (void) ; -char *gets (char *) ; -extern int sys_nerr; -extern char *sys_errlist[]; -void perror (const char *) ; -int printf (const char *, ...) ; -int putc (int, FILE *) ; -int putchar (int) ; -int puts (const char *) ; -int remove (const char *) ; -int rename (const char *, const char *) ; -void rewind (FILE *) ; -int scanf (const char *, ...) ; -void setbuf (FILE *, char *) ; -int setvbuf (FILE *, char *, int, size_t) ; -int sprintf (char *, const char *, ...) ; -int sscanf (char *, const char *, ...) ; -FILE *tmpfile (void) ; -char *tmpnam (char *) ; -int ungetc (int, FILE *) ; -int vfprintf (FILE *, const char *, char * ) ; -int vprintf (const char *, char * ) ; -int vsprintf (char *, const char *, char * ) ; -char *ctermid (char *) ; -FILE *fdopen (int, const char *) ; -int fileno (FILE *) ; -char *fgetline (FILE *, size_t *) ; -int fpurge (FILE *) ; -int getw (FILE *) ; -int pclose (FILE *) ; -FILE *popen (const char *, const char *) ; -int putw (int, FILE *) ; -void setbuffer (FILE *, char *, int) ; -int setlinebuf (FILE *) ; -char *tempnam (const char *, const char *) ; -int snprintf (char *, size_t, const char *, ...) ; -int vsnprintf (char *, size_t, const char *, char * ) ; -int vscanf (const char *, char * ) ; -int vsscanf (const char *, const char *, char * ) ; -FILE *funopen (const void *, - int (*)(void *, char *, int), - int (*)(void *, const char *, int), - fpos_t (*)(void *, fpos_t, int), - int (*)(void *)) ; -int __srget (FILE *) ; -int __svfscanf (FILE *, const char *, char * ) ; -int __swbuf (int, FILE *) ; -static inline int __sputc(int _c, FILE *_p) { - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf(_c, _p)); -} -void -__eprintf (string, expression, line, filename) - const char *string; - const char *expression; - int line; - const char *filename; -{ - fprintf ((&__sF[2]) , string, expression, line, filename); - fflush ((&__sF[2]) ); - abort (); -} diff --git a/gnu/usr.bin/gcc2/libgcc/_eqdf2.c b/gnu/usr.bin/gcc2/libgcc/_eqdf2.c deleted file mode 100644 index ca706e2c2495..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_eqdf2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _eqdf2.c,v 1.2 1993/08/02 17:37:50 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__eqdf2 (a, b) - double a, b; -{ - - return !( a == b ) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_eqsf2.c b/gnu/usr.bin/gcc2/libgcc/_eqsf2.c deleted file mode 100644 index 7f383cde0416..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_eqsf2.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Id: _eqsf2.c,v 1.2 1993/08/02 17:37:51 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__eqsf2 (a, b) - union flt_or_int a, b; -{ - union flt_or_int intify; - - return !( (( a ).f) == (( b ).f) ) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_exit.c b/gnu/usr.bin/gcc2/libgcc/_exit.c deleted file mode 100644 index bd58d904fa12..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_exit.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $Id: _exit.c,v 1.2 1993/08/02 17:37:52 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -extern void atexit (void (*) (void)); -typedef void (*func_ptr) (void); -extern func_ptr __CTOR_LIST__[]; -extern func_ptr __DTOR_LIST__[]; -extern void __do_global_dtors (); -int _exit_dummy_decl = 0; diff --git a/gnu/usr.bin/gcc2/libgcc/_extendsfdf2.c b/gnu/usr.bin/gcc2/libgcc/_extendsfdf2.c deleted file mode 100644 index 335d7b4e60ca..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_extendsfdf2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _extendsfdf2.c,v 1.2 1993/08/02 17:37:53 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -double -__extendsfdf2 (a) - union flt_or_int a; -{ - union flt_or_value intify; - return (( a ).f) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_ffsdi2.c b/gnu/usr.bin/gcc2/libgcc/_ffsdi2.c deleted file mode 100644 index cc71f80a4976..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_ffsdi2.c +++ /dev/null @@ -1,104 +0,0 @@ -/* $Id: _ffsdi2.c,v 1.2 1993/08/02 17:37:53 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DItype -__ffsdi2 (u) - DItype u; -{ - DIunion uu, w; - uu.ll = u; - w.s.high = 0; - w.s.low = ffs (uu.s.low); - if (w.s.low != 0) - return w.ll; - w.s.low = ffs (uu.s.high); - if (w.s.low != 0) - { - w.s.low += 8 * sizeof (SItype); - return w.ll; - } - return w.ll; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_fixdfdi.c b/gnu/usr.bin/gcc2/libgcc/_fixdfdi.c deleted file mode 100644 index 53286d523534..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixdfdi.c +++ /dev/null @@ -1,94 +0,0 @@ -/* $Id: _fixdfdi.c,v 1.2 1993/08/02 17:37:54 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DItype -__fixdfdi (a) - DFtype a; -{ - if (a < 0) - return - __fixunsdfdi (-a); - return __fixunsdfdi (a); -} diff --git a/gnu/usr.bin/gcc2/libgcc/_fixdfsi.c b/gnu/usr.bin/gcc2/libgcc/_fixdfsi.c deleted file mode 100644 index 19a750735357..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixdfsi.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _fixdfsi.c,v 1.2 1993/08/02 17:37:55 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__fixdfsi (a) - double a; -{ - { auto unsigned short ostatus; auto unsigned short nstatus; auto int ret; auto double tmp; &ostatus; &nstatus; &ret; &tmp; asm volatile ("fnstcw %0" : "=m" (ostatus)); nstatus = ostatus | 0x0c00; asm volatile ("fldcw %0" : : "m" (nstatus)); tmp = a ; asm volatile ("fldl %0" : : "m" (tmp)); asm volatile ("fistpl %0" : "=m" (ret)); asm volatile ("fldcw %0" : : "m" (ostatus)); return ret; } ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_fixsfdi.c b/gnu/usr.bin/gcc2/libgcc/_fixsfdi.c deleted file mode 100644 index 1f10a1359d66..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixsfdi.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $Id: _fixsfdi.c,v 1.2 1993/08/02 17:37:56 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DItype -__fixsfdi (SFtype a) -{ - if (a < 0) - return - __fixunssfdi (-a); - return __fixunssfdi (a); -} diff --git a/gnu/usr.bin/gcc2/libgcc/_fixsfsi.c b/gnu/usr.bin/gcc2/libgcc/_fixsfsi.c deleted file mode 100644 index c298dd795dce..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixsfsi.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _fixsfsi.c,v 1.2 1993/08/02 17:37:57 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__fixsfsi (a) - union flt_or_int a; -{ - union flt_or_value intify; - return (long int ) (( a ).f) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_fixunsdfdi.c b/gnu/usr.bin/gcc2/libgcc/_fixunsdfdi.c deleted file mode 100644 index b7cd59986d33..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixunsdfdi.c +++ /dev/null @@ -1,107 +0,0 @@ -/* $Id: _fixunsdfdi.c,v 1.2 1993/08/02 17:37:58 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DItype -__fixunsdfdi (DFtype a) -{ - DFtype b; - UDItype v; - if (a < 0) - return 0; - - b = (a / (((UDItype) 1) << (sizeof (SItype) * 8 ) ) ); - - v = (USItype) b; - v <<= (sizeof (SItype) * 8 ) ; - - a -= (DFtype)v; - - if (a < 0) - v -= (USItype) (- a); - else - v += (USItype) a; - return v; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_fixunsdfsi.c b/gnu/usr.bin/gcc2/libgcc/_fixunsdfsi.c deleted file mode 100644 index b4686f117f0d..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixunsdfsi.c +++ /dev/null @@ -1,94 +0,0 @@ -/* $Id: _fixunsdfsi.c,v 1.2 1993/08/02 17:37:59 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -USItype -__fixunsdfsi (a) - DFtype a; -{ - if (a >= - (DFtype) (- 2147483647L -1) ) - return (SItype) (a + (- 2147483647L -1) ) - (- 2147483647L -1) ; - return (SItype) a; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_fixunssfdi.c b/gnu/usr.bin/gcc2/libgcc/_fixunssfdi.c deleted file mode 100644 index 682d03b2c474..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixunssfdi.c +++ /dev/null @@ -1,109 +0,0 @@ -/* $Id: _fixunssfdi.c,v 1.2 1993/08/02 17:38:00 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DItype -__fixunssfdi (SFtype original_a) -{ - - DFtype a = original_a; - DFtype b; - UDItype v; - if (a < 0) - return 0; - - b = (a / (((UDItype) 1) << (sizeof (SItype) * 8 ) ) ); - - v = (USItype) b; - v <<= (sizeof (SItype) * 8 ) ; - - a -= (DFtype)v; - - if (a < 0) - v -= (USItype) (- a); - else - v += (USItype) a; - return v; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_fixunssfsi.c b/gnu/usr.bin/gcc2/libgcc/_fixunssfsi.c deleted file mode 100644 index 4df43602dae6..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixunssfsi.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $Id: _fixunssfsi.c,v 1.2 1993/08/02 17:38:01 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -USItype -__fixunssfsi (SFtype a) -{ - if (a >= - (SFtype) (- 2147483647L -1) ) - return (SItype) (a + (- 2147483647L -1) ) - (- 2147483647L -1) ; - return (SItype) a; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_fixunsxfdi.c b/gnu/usr.bin/gcc2/libgcc/_fixunsxfdi.c deleted file mode 100644 index 7a3670c81025..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixunsxfdi.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $Id: _fixunsxfdi.c,v 1.2 1993/08/02 17:38:01 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); diff --git a/gnu/usr.bin/gcc2/libgcc/_fixunsxfsi.c b/gnu/usr.bin/gcc2/libgcc/_fixunsxfsi.c deleted file mode 100644 index b5df0ed30281..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixunsxfsi.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $Id: _fixunsxfsi.c,v 1.2 1993/08/02 17:38:02 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); diff --git a/gnu/usr.bin/gcc2/libgcc/_fixxfdi.c b/gnu/usr.bin/gcc2/libgcc/_fixxfdi.c deleted file mode 100644 index 03ed1dcc5d29..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_fixxfdi.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $Id: _fixxfdi.c,v 1.2 1993/08/02 17:38:03 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); diff --git a/gnu/usr.bin/gcc2/libgcc/_floatdidf.c b/gnu/usr.bin/gcc2/libgcc/_floatdidf.c deleted file mode 100644 index 88b47e2eeec2..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_floatdidf.c +++ /dev/null @@ -1,100 +0,0 @@ -/* $Id: _floatdidf.c,v 1.2 1993/08/02 17:38:04 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DFtype -__floatdidf (u) - DItype u; -{ - DFtype d; - SItype negate = 0; - if (u < 0) - u = -u, negate = 1; - d = (USItype) (u >> (sizeof (SItype) * 8 ) ); - d *= (((UDItype) 1) << ((sizeof (SItype) * 8 ) / 2)) ; - d *= (((UDItype) 1) << ((sizeof (SItype) * 8 ) / 2)) ; - d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8 ) ) - 1)); - return (negate ? -d : d); -} diff --git a/gnu/usr.bin/gcc2/libgcc/_floatdisf.c b/gnu/usr.bin/gcc2/libgcc/_floatdisf.c deleted file mode 100644 index f0362f359dd6..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_floatdisf.c +++ /dev/null @@ -1,101 +0,0 @@ -/* $Id: _floatdisf.c,v 1.2 1993/08/02 17:38:05 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -SFtype -__floatdisf (u) - DItype u; -{ - - DFtype f; - SItype negate = 0; - if (u < 0) - u = -u, negate = 1; - f = (USItype) (u >> (sizeof (SItype) * 8 ) ); - f *= (((UDItype) 1) << ((sizeof (SItype) * 8 ) / 2)) ; - f *= (((UDItype) 1) << ((sizeof (SItype) * 8 ) / 2)) ; - f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8 ) ) - 1)); - return (SFtype) (negate ? -f : f); -} diff --git a/gnu/usr.bin/gcc2/libgcc/_floatdixf.c b/gnu/usr.bin/gcc2/libgcc/_floatdixf.c deleted file mode 100644 index dd829a2af60a..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_floatdixf.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $Id: _floatdixf.c,v 1.2 1993/08/02 17:38:06 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); diff --git a/gnu/usr.bin/gcc2/libgcc/_floatsidf.c b/gnu/usr.bin/gcc2/libgcc/_floatsidf.c deleted file mode 100644 index db7486cc8949..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_floatsidf.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _floatsidf.c,v 1.2 1993/08/02 17:38:07 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -double -__floatsidf (a) - long int a; -{ - return (double) a ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_floatsisf.c b/gnu/usr.bin/gcc2/libgcc/_floatsisf.c deleted file mode 100644 index 677d3afbd2fc..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_floatsisf.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _floatsisf.c,v 1.2 1993/08/02 17:38:08 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -float -__floatsisf (a) - long int a; -{ - union flt_or_value intify; - return (float) a ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_gedf2.c b/gnu/usr.bin/gcc2/libgcc/_gedf2.c deleted file mode 100644 index 3846a68df386..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_gedf2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _gedf2.c,v 1.2 1993/08/02 17:38:08 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__gedf2 (a, b) - double a, b; -{ - - return ( a >= b ) - 1 ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_gesf2.c b/gnu/usr.bin/gcc2/libgcc/_gesf2.c deleted file mode 100644 index 04d362c8122b..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_gesf2.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Id: _gesf2.c,v 1.2 1993/08/02 17:38:10 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__gesf2 (a, b) - union flt_or_int a, b; -{ - union flt_or_int intify; - - return ( (( a ).f) >= (( b ).f) ) - 1 ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_gtdf2.c b/gnu/usr.bin/gcc2/libgcc/_gtdf2.c deleted file mode 100644 index 66b239c9c65f..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_gtdf2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _gtdf2.c,v 1.2 1993/08/02 17:38:11 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__gtdf2 (a, b) - double a, b; -{ - - return a > b ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_gtsf2.c b/gnu/usr.bin/gcc2/libgcc/_gtsf2.c deleted file mode 100644 index 28b14965c72e..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_gtsf2.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Id: _gtsf2.c,v 1.2 1993/08/02 17:38:11 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__gtsf2 (a, b) - union flt_or_int a, b; -{ - union flt_or_int intify; - - return (( a ).f) > (( b ).f) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_ledf2.c b/gnu/usr.bin/gcc2/libgcc/_ledf2.c deleted file mode 100644 index 6bfa63d15927..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_ledf2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _ledf2.c,v 1.2 1993/08/02 17:38:12 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__ledf2 (a, b) - double a, b; -{ - - return 1 - ( a <= b ) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_lesf2.c b/gnu/usr.bin/gcc2/libgcc/_lesf2.c deleted file mode 100644 index 68ad587fd8a3..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_lesf2.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Id: _lesf2.c,v 1.2 1993/08/02 17:38:13 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__lesf2 (a, b) - union flt_or_int a, b; -{ - union flt_or_int intify; - - return 1 - ( (( a ).f) <= (( b ).f) ); ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_lshldi3.c b/gnu/usr.bin/gcc2/libgcc/_lshldi3.c deleted file mode 100644 index d40ff1fe9053..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_lshldi3.c +++ /dev/null @@ -1,111 +0,0 @@ -/* $Id: _lshldi3.c,v 1.2 1993/08/02 17:38:14 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DItype -__lshldi3 (u, b) - DItype u; - SItype b; -{ - DIunion w; - SItype bm; - DIunion uu; - if (b == 0) - return u; - uu.ll = u; - bm = (sizeof (SItype) * 8 ) - b; - if (bm <= 0) - { - w.s.low = 0; - w.s.high = (USItype)uu.s.low << -bm; - } - else - { - USItype carries = (USItype)uu.s.low >> bm; - w.s.low = (USItype)uu.s.low << b; - w.s.high = ((USItype)uu.s.high << b) | carries; - } - return w.ll; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_lshlsi3.c b/gnu/usr.bin/gcc2/libgcc/_lshlsi3.c deleted file mode 100644 index 1be47c4f43e8..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_lshlsi3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _lshlsi3.c,v 1.2 1993/08/02 17:38:15 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__lshlsi3 (a, b) - unsigned long int a, b; -{ - return a << b ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_lshrdi3.c b/gnu/usr.bin/gcc2/libgcc/_lshrdi3.c deleted file mode 100644 index 1a442b3d8363..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_lshrdi3.c +++ /dev/null @@ -1,111 +0,0 @@ -/* $Id: _lshrdi3.c,v 1.2 1993/08/02 17:38:16 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DItype -__lshrdi3 (u, b) - DItype u; - SItype b; -{ - DIunion w; - SItype bm; - DIunion uu; - if (b == 0) - return u; - uu.ll = u; - bm = (sizeof (SItype) * 8 ) - b; - if (bm <= 0) - { - w.s.high = 0; - w.s.low = (USItype)uu.s.high >> -bm; - } - else - { - USItype carries = (USItype)uu.s.high << bm; - w.s.high = (USItype)uu.s.high >> b; - w.s.low = ((USItype)uu.s.low >> b) | carries; - } - return w.ll; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_lshrsi3.c b/gnu/usr.bin/gcc2/libgcc/_lshrsi3.c deleted file mode 100644 index b685eb093d05..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_lshrsi3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _lshrsi3.c,v 1.2 1993/08/02 17:38:17 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__lshrsi3 (a, b) - unsigned long int a, b; -{ - return a >> b ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_ltdf2.c b/gnu/usr.bin/gcc2/libgcc/_ltdf2.c deleted file mode 100644 index f6480e17be9d..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_ltdf2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _ltdf2.c,v 1.2 1993/08/02 17:38:18 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__ltdf2 (a, b) - double a, b; -{ - - return -( a < b ) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_ltsf2.c b/gnu/usr.bin/gcc2/libgcc/_ltsf2.c deleted file mode 100644 index 691e4b044c85..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_ltsf2.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Id: _ltsf2.c,v 1.2 1993/08/02 17:38:19 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__ltsf2 (a, b) - union flt_or_int a, b; -{ - union flt_or_int intify; - - return -( (( a ).f) < (( b ).f) ) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_moddi3.c b/gnu/usr.bin/gcc2/libgcc/_moddi3.c deleted file mode 100644 index 0c330593efb2..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_moddi3.c +++ /dev/null @@ -1,118 +0,0 @@ -/* $Id: _moddi3.c,v 1.2 1993/08/02 17:38:20 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -static inline -DItype -__negdi2 (u) - DItype u; -{ - DIunion w; - DIunion uu; - uu.ll = u; - w.s.low = -uu.s.low; - w.s.high = -uu.s.high - ((USItype) w.s.low > 0); - return w.ll; -} -UDItype __udivmoddi4 (); -DItype -__moddi3 (u, v) - DItype u, v; -{ - SItype c = 0; - DIunion uu, vv; - DItype w; - uu.ll = u; - vv.ll = v; - if (uu.s.high < 0) - c = ~c, - uu.ll = __negdi2 (uu.ll); - if (vv.s.high < 0) - vv.ll = __negdi2 (vv.ll); - (void) __udivmoddi4 (uu.ll, vv.ll, &w); - if (c) - w = __negdi2 (w); - return w; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_modsi3.c b/gnu/usr.bin/gcc2/libgcc/_modsi3.c deleted file mode 100644 index f52ed60be58e..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_modsi3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _modsi3.c,v 1.2 1993/08/02 17:38:21 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__modsi3 (a, b) - long int a, b; -{ - { register int dx asm("dx"); register int ax asm("ax"); ax = a ; asm ("cltd\n\tidivl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" ( b )); return dx; } ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_muldf3.c b/gnu/usr.bin/gcc2/libgcc/_muldf3.c deleted file mode 100644 index 4f051b31d449..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_muldf3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _muldf3.c,v 1.2 1993/08/02 17:38:22 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -double -__muldf3 (a, b) - double a, b; -{ - return a * b ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_muldi3.c b/gnu/usr.bin/gcc2/libgcc/_muldi3.c deleted file mode 100644 index 7dd25502efe3..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_muldi3.c +++ /dev/null @@ -1,99 +0,0 @@ -/* $Id: _muldi3.c,v 1.2 1993/08/02 17:38:23 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DItype -__muldi3 (u, v) - DItype u, v; -{ - DIunion w; - DIunion uu, vv; - uu.ll = u, - vv.ll = v; - w.ll = ({DIunion __w; __asm__ ("mull %3" : "=a" ((USItype)( __w.s.low )), "=d" ((USItype)( __w.s.high )) : "%0" ((USItype)( uu.s.low )), "rm" ((USItype)( vv.s.low ))) ; __w.ll; }) ; - w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high - + (USItype) uu.s.high * (USItype) vv.s.low); - return w.ll; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_mulsf3.c b/gnu/usr.bin/gcc2/libgcc/_mulsf3.c deleted file mode 100644 index c2d784c2b351..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_mulsf3.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _mulsf3.c,v 1.2 1993/08/02 17:38:24 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -float -__mulsf3 (a, b) - union flt_or_int a, b; -{ - union flt_or_value intify; - return (( a ).f) * (( b ).f) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_mulsi3.c b/gnu/usr.bin/gcc2/libgcc/_mulsi3.c deleted file mode 100644 index c372e3a685b4..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_mulsi3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _mulsi3.c,v 1.2 1993/08/02 17:38:25 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__mulsi3 (a, b) - long int a, b; -{ - return a * b ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_nedf2.c b/gnu/usr.bin/gcc2/libgcc/_nedf2.c deleted file mode 100644 index 3bd1e0369a18..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_nedf2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _nedf2.c,v 1.2 1993/08/02 17:38:26 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__nedf2 (a, b) - double a, b; -{ - - return a != b ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_negdf2.c b/gnu/usr.bin/gcc2/libgcc/_negdf2.c deleted file mode 100644 index e728234265ef..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_negdf2.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _negdf2.c,v 1.2 1993/08/02 17:38:27 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -double -__negdf2 (a) - double a; -{ - return - a ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_negdi2.c b/gnu/usr.bin/gcc2/libgcc/_negdi2.c deleted file mode 100644 index ab3ccc3f0acd..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_negdi2.c +++ /dev/null @@ -1,97 +0,0 @@ -/* $Id: _negdi2.c,v 1.2 1993/08/02 17:38:27 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -DItype -__negdi2 (u) - DItype u; -{ - DIunion w; - DIunion uu; - uu.ll = u; - w.s.low = -uu.s.low; - w.s.high = -uu.s.high - ((USItype) w.s.low > 0); - return w.ll; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_negsf2.c b/gnu/usr.bin/gcc2/libgcc/_negsf2.c deleted file mode 100644 index 366217f89bba..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_negsf2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _negsf2.c,v 1.2 1993/08/02 17:38:28 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -float -__negsf2 (a) - union flt_or_int a; -{ - union flt_or_value intify; - return - (( a ).f) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_nesf2.c b/gnu/usr.bin/gcc2/libgcc/_nesf2.c deleted file mode 100644 index f5bc958fb829..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_nesf2.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Id: _nesf2.c,v 1.2 1993/08/02 17:38:29 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__nesf2 (a, b) - union flt_or_int a, b; -{ - union flt_or_int intify; - - return (( a ).f) != (( b ).f) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_new_handler.c b/gnu/usr.bin/gcc2/libgcc/_new_handler.c deleted file mode 100644 index 3fcbb49a8bac..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_new_handler.c +++ /dev/null @@ -1,223 +0,0 @@ -/* $Id: _new_handler.c,v 1.2 1993/08/02 17:38:30 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -typedef size_t; -typedef long fpos_t; -struct __sbuf { - unsigned char *_base; - int _size; -}; -typedef struct __sFILE { - unsigned char *_p; - int _r; - int _w; - short _flags; - short _file; - struct __sbuf _bf; - int _lbfsize; - - void *_cookie; - int (*_close) (void *) ; - int (*_read) (void *, char *, int) ; - fpos_t (*_seek) (void *, fpos_t, int) ; - int (*_write) (void *, const char *, int) ; - - struct __sbuf _ub; - unsigned char *_up; - int _ur; - - unsigned char _ubuf[3]; - unsigned char _nbuf[1]; - - struct __sbuf _lb; - - int _blksize; - int _offset; -} FILE; -extern FILE __sF[]; - -void clearerr (FILE *) ; -int fclose (FILE *) ; -int feof (FILE *) ; -int ferror (FILE *) ; -int fflush (FILE *) ; -int fgetc (FILE *) ; -int fgetpos (FILE *, fpos_t *) ; -char *fgets (char *, size_t, FILE *) ; -FILE *fopen (const char *, const char *) ; -int fprintf (FILE *, const char *, ...) ; -int fputc (int, FILE *) ; -int fputs (const char *, FILE *) ; -int fread (void *, size_t, size_t, FILE *) ; -FILE *freopen (const char *, const char *, FILE *) ; -int fscanf (FILE *, const char *, ...) ; -int fseek (FILE *, long, int) ; -int fsetpos (FILE *, const fpos_t *) ; -long ftell (const FILE *) ; -int fwrite (const void *, size_t, size_t, FILE *) ; -int getc (FILE *) ; -int getchar (void) ; -char *gets (char *) ; -extern int sys_nerr; -extern char *sys_errlist[]; -void perror (const char *) ; -int printf (const char *, ...) ; -int putc (int, FILE *) ; -int putchar (int) ; -int puts (const char *) ; -int remove (const char *) ; -int rename (const char *, const char *) ; -void rewind (FILE *) ; -int scanf (const char *, ...) ; -void setbuf (FILE *, char *) ; -int setvbuf (FILE *, char *, int, size_t) ; -int sprintf (char *, const char *, ...) ; -int sscanf (char *, const char *, ...) ; -FILE *tmpfile (void) ; -char *tmpnam (char *) ; -int ungetc (int, FILE *) ; -int vfprintf (FILE *, const char *, char * ) ; -int vprintf (const char *, char * ) ; -int vsprintf (char *, const char *, char * ) ; -char *ctermid (char *) ; -FILE *fdopen (int, const char *) ; -int fileno (FILE *) ; -char *fgetline (FILE *, size_t *) ; -int fpurge (FILE *) ; -int getw (FILE *) ; -int pclose (FILE *) ; -FILE *popen (const char *, const char *) ; -int putw (int, FILE *) ; -void setbuffer (FILE *, char *, int) ; -int setlinebuf (FILE *) ; -char *tempnam (const char *, const char *) ; -int snprintf (char *, size_t, const char *, ...) ; -int vsnprintf (char *, size_t, const char *, char * ) ; -int vscanf (const char *, char * ) ; -int vsscanf (const char *, const char *, char * ) ; -FILE *funopen (const void *, - int (*)(void *, char *, int), - int (*)(void *, const char *, int), - fpos_t (*)(void *, fpos_t, int), - int (*)(void *)) ; -int __srget (FILE *) ; -int __svfscanf (FILE *, const char *, char * ) ; -int __swbuf (int, FILE *) ; -static inline int __sputc(int _c, FILE *_p) { - if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) - return (*_p->_p++ = _c); - else - return (__swbuf(_c, _p)); -} -typedef void (*vfp)(void); -extern void *__builtin_new (size_t); -static void default_new_handler (void); -vfp __new_handler = default_new_handler; -vfp -__set_new_handler (handler) - vfp handler; -{ - vfp prev_handler; - prev_handler = __new_handler; - if (handler == 0) handler = default_new_handler; - __new_handler = handler; - return prev_handler; -} -vfp -set_new_handler (handler) - vfp handler; -{ - return __set_new_handler (handler); -} -static void -default_new_handler () -{ - - - write (2, "Virtual memory exceeded in `new'\n" , sizeof ("Virtual memory exceeded in `new'\n" )); - - _exit (-1); -} diff --git a/gnu/usr.bin/gcc2/libgcc/_op_delete.c b/gnu/usr.bin/gcc2/libgcc/_op_delete.c deleted file mode 100644 index 9e73cc6a5f84..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_op_delete.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $Id: _op_delete.c,v 1.2 1993/08/02 17:38:31 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -void -__builtin_delete (void *ptr) -{ - if (ptr) - free (ptr); -} diff --git a/gnu/usr.bin/gcc2/libgcc/_op_new.c b/gnu/usr.bin/gcc2/libgcc/_op_new.c deleted file mode 100644 index 23623ae705e3..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_op_new.c +++ /dev/null @@ -1,100 +0,0 @@ -/* $Id: _op_new.c,v 1.2 1993/08/02 17:38:32 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -typedef void (*vfp)(void); -extern vfp __new_handler; -void * -__builtin_new (size_t sz) -{ - void *p; - - if (sz == 0) - sz = 1; - p = (void *) malloc (sz); - if (p == 0) - (*__new_handler) (); - return p; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_shtab.c b/gnu/usr.bin/gcc2/libgcc/_shtab.c deleted file mode 100644 index afdedbbccdab..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_shtab.c +++ /dev/null @@ -1,96 +0,0 @@ -/* $Id: _shtab.c,v 1.2 1993/08/02 17:38:33 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -unsigned int __shtab[] = { - 0x00000001, 0x00000002, 0x00000004, 0x00000008, - 0x00000010, 0x00000020, 0x00000040, 0x00000080, - 0x00000100, 0x00000200, 0x00000400, 0x00000800, - 0x00001000, 0x00002000, 0x00004000, 0x00008000, - 0x00010000, 0x00020000, 0x00040000, 0x00080000, - 0x00100000, 0x00200000, 0x00400000, 0x00800000, - 0x01000000, 0x02000000, 0x04000000, 0x08000000, - 0x10000000, 0x20000000, 0x40000000, 0x80000000 - }; diff --git a/gnu/usr.bin/gcc2/libgcc/_subdf3.c b/gnu/usr.bin/gcc2/libgcc/_subdf3.c deleted file mode 100644 index 3bd734d43ef4..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_subdf3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _subdf3.c,v 1.2 1993/08/02 17:38:34 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -double -__subdf3 (a, b) - double a, b; -{ - return a - b ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_subsf3.c b/gnu/usr.bin/gcc2/libgcc/_subsf3.c deleted file mode 100644 index 122a0d91bada..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_subsf3.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _subsf3.c,v 1.2 1993/08/02 17:38:35 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -float -__subsf3 (a, b) - union flt_or_int a, b; -{ - union flt_or_value intify; - return (( a ).f) - (( b ).f) ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_trampoline.c b/gnu/usr.bin/gcc2/libgcc/_trampoline.c deleted file mode 100644 index 6d2624f8cb66..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_trampoline.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $Id: _trampoline.c,v 1.2 1993/08/02 17:38:37 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); diff --git a/gnu/usr.bin/gcc2/libgcc/_truncdfsf2.c b/gnu/usr.bin/gcc2/libgcc/_truncdfsf2.c deleted file mode 100644 index 82b368109bde..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_truncdfsf2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Id: _truncdfsf2.c,v 1.2 1993/08/02 17:38:37 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -float -__truncdfsf2 (a) - double a; -{ - union flt_or_value intify; - return a ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_ucmpdi2.c b/gnu/usr.bin/gcc2/libgcc/_ucmpdi2.c deleted file mode 100644 index 57a12b825085..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_ucmpdi2.c +++ /dev/null @@ -1,102 +0,0 @@ -/* $Id: _ucmpdi2.c,v 1.2 1993/08/02 17:38:38 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -word_type -__ucmpdi2 (a, b) - DItype a, b; -{ - DIunion au, bu; - au.ll = a, bu.ll = b; - if ((USItype) au.s.high < (USItype) bu.s.high) - return 0; - else if ((USItype) au.s.high > (USItype) bu.s.high) - return 2; - if ((USItype) au.s.low < (USItype) bu.s.low) - return 0; - else if ((USItype) au.s.low > (USItype) bu.s.low) - return 2; - return 1; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_udiv_w_sdiv.c b/gnu/usr.bin/gcc2/libgcc/_udiv_w_sdiv.c deleted file mode 100644 index 9f94961c9540..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_udiv_w_sdiv.c +++ /dev/null @@ -1,176 +0,0 @@ -/* $Id: _udiv_w_sdiv.c,v 1.2 1993/08/02 17:38:40 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -USItype -__udiv_w_sdiv (rp, a1, a0, d) - USItype *rp, a1, a0, d; -{ - USItype q, r; - USItype c0, c1, b1; - if ((SItype) d >= 0) - { - if (a1 < d - a1 - (a0 >> ((sizeof (SItype) * 8 ) - 1))) - { - - sdiv_qrnnd (q, r, a1, a0, d); - } - else - { - - __asm__ ("subl %5,%1 - sbbl %3,%0" : "=r" ((USItype)( c1 )), "=&r" ((USItype)( c0 )) : "0" ((USItype)( a1 )), "g" ((USItype)( d >> 1 )), "1" ((USItype)( a0 )), "g" ((USItype)( d << ((sizeof (SItype) * 8 ) - 1) ))) ; - - sdiv_qrnnd (q, r, c1, c0, d); - - q += (USItype) 1 << ((sizeof (SItype) * 8 ) - 1); - } - } - else - { - b1 = d >> 1; - c1 = a1 >> 1; - c0 = (a1 << ((sizeof (SItype) * 8 ) - 1)) + (a0 >> 1); - if (a1 < b1) - { - sdiv_qrnnd (q, r, c1, c0, b1); - r = 2*r + (a0 & 1); - if ((d & 1) != 0) - { - if (r >= q) - r = r - q; - else if (q - r <= d) - { - r = r - q + d; - q--; - } - else - { - r = r - q + 2*d; - q -= 2; - } - } - } - else if (c1 < b1) - { - c1 = (b1 - 1) - c1; - c0 = ~c0; - sdiv_qrnnd (q, r, c1, c0, b1); - q = ~q; - r = (b1 - 1) - r; - r = 2*r + (a0 & 1); - if ((d & 1) != 0) - { - if (r >= q) - r = r - q; - else if (q - r <= d) - { - r = r - q + d; - q--; - } - else - { - r = r - q + 2*d; - q -= 2; - } - } - } - else - { - if (a0 >= -d) - { - q = -1; - r = a0 + d; - } - else - { - q = -2; - r = a0 + 2*d; - } - } - } - *rp = r; - return q; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_udivdi3.c b/gnu/usr.bin/gcc2/libgcc/_udivdi3.c deleted file mode 100644 index 440e54dd4877..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_udivdi3.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $Id: _udivdi3.c,v 1.2 1993/08/02 17:38:41 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -UDItype __udivmoddi4 (); -UDItype -__udivdi3 (n, d) - UDItype n, d; -{ - return __udivmoddi4 (n, d, (UDItype *) 0); -} diff --git a/gnu/usr.bin/gcc2/libgcc/_udivmoddi4.c b/gnu/usr.bin/gcc2/libgcc/_udivmoddi4.c deleted file mode 100644 index d802d6a3f157..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_udivmoddi4.c +++ /dev/null @@ -1,213 +0,0 @@ -/* $Id: _udivmoddi4.c,v 1.2 1993/08/02 17:38:42 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -static const UQItype __clz_tab[] = -{ - 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, -}; -UDItype -__udivmoddi4 (n, d, rp) - UDItype n, d; - UDItype *rp; -{ - DIunion ww; - DIunion nn, dd; - DIunion rr; - USItype d0, d1, n0, n1, n2; - USItype q0, q1; - USItype b, bm; - nn.ll = n; - dd.ll = d; - d0 = dd.s.low; - d1 = dd.s.high; - n0 = nn.s.low; - n1 = nn.s.high; - if (d1 == 0) - { - if (d0 > n1) - { - - __asm__ ("divl %4" : "=a" ((USItype)( q0 )), "=d" ((USItype)( n0 )) : "0" ((USItype)( n0 )), "1" ((USItype)( n1 )), "rm" ((USItype)( d0 ))) ; - q1 = 0; - - } - else - { - - if (d0 == 0) - d0 = 1 / d0; - __asm__ ("divl %4" : "=a" ((USItype)( q1 )), "=d" ((USItype)( n1 )) : "0" ((USItype)( n1 )), "1" ((USItype)( 0 )), "rm" ((USItype)( d0 ))) ; - __asm__ ("divl %4" : "=a" ((USItype)( q0 )), "=d" ((USItype)( n0 )) : "0" ((USItype)( n0 )), "1" ((USItype)( n1 )), "rm" ((USItype)( d0 ))) ; - - } - if (rp != 0) - { - rr.s.low = n0; - rr.s.high = 0; - *rp = rr.ll; - } - } - else - { - if (d1 > n1) - { - - q0 = 0; - q1 = 0; - - if (rp != 0) - { - rr.s.low = n0; - rr.s.high = n1; - *rp = rr.ll; - } - } - else - { - - do { USItype __cbtmp; __asm__ ("bsrl %1,%0" : "=r" (__cbtmp) : "rm" ((USItype)( d1 ))); ( bm ) = __cbtmp ^ 31; } while (0) ; - if (bm == 0) - { - - - if (n1 > d1 || n0 >= d0) - { - q0 = 1; - __asm__ ("subl %5,%1 - sbbl %3,%0" : "=r" ((USItype)( n1 )), "=&r" ((USItype)( n0 )) : "0" ((USItype)( n1 )), "g" ((USItype)( d1 )), "1" ((USItype)( n0 )), "g" ((USItype)( d0 ))) ; - } - else - q0 = 0; - q1 = 0; - if (rp != 0) - { - rr.s.low = n0; - rr.s.high = n1; - *rp = rr.ll; - } - } - else - { - USItype m1, m0; - - b = (sizeof (SItype) * 8 ) - bm; - d1 = (d1 << bm) | (d0 >> b); - d0 = d0 << bm; - n2 = n1 >> b; - n1 = (n1 << bm) | (n0 >> b); - n0 = n0 << bm; - __asm__ ("divl %4" : "=a" ((USItype)( q0 )), "=d" ((USItype)( n1 )) : "0" ((USItype)( n1 )), "1" ((USItype)( n2 )), "rm" ((USItype)( d1 ))) ; - __asm__ ("mull %3" : "=a" ((USItype)( m0 )), "=d" ((USItype)( m1 )) : "%0" ((USItype)( q0 )), "rm" ((USItype)( d0 ))) ; - if (m1 > n1 || (m1 == n1 && m0 > n0)) - { - q0--; - __asm__ ("subl %5,%1 - sbbl %3,%0" : "=r" ((USItype)( m1 )), "=&r" ((USItype)( m0 )) : "0" ((USItype)( m1 )), "g" ((USItype)( d1 )), "1" ((USItype)( m0 )), "g" ((USItype)( d0 ))) ; - } - q1 = 0; - - if (rp != 0) - { - __asm__ ("subl %5,%1 - sbbl %3,%0" : "=r" ((USItype)( n1 )), "=&r" ((USItype)( n0 )) : "0" ((USItype)( n1 )), "g" ((USItype)( m1 )), "1" ((USItype)( n0 )), "g" ((USItype)( m0 ))) ; - rr.s.low = (n1 << b) | (n0 >> bm); - rr.s.high = n1 >> bm; - *rp = rr.ll; - } - } - } - } - ww.s.low = q0; - ww.s.high = q1; - return ww.ll; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_udivsi3.c b/gnu/usr.bin/gcc2/libgcc/_udivsi3.c deleted file mode 100644 index 3beb605abca7..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_udivsi3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _udivsi3.c,v 1.2 1993/08/02 17:38:43 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__udivsi3 (a, b) - unsigned long int a, b; -{ - { register int dx asm("dx"); register int ax asm("ax"); dx = 0; ax = a ; asm ("divl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" ( b ), "d" (dx)); return ax; } ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_umoddi3.c b/gnu/usr.bin/gcc2/libgcc/_umoddi3.c deleted file mode 100644 index 79edbf355013..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_umoddi3.c +++ /dev/null @@ -1,95 +0,0 @@ -/* $Id: _umoddi3.c,v 1.2 1993/08/02 17:38:44 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -UDItype __udivmoddi4 (); -UDItype -__umoddi3 (u, v) - UDItype u, v; -{ - DItype w; - (void) __udivmoddi4 (u, v, &w); - return w; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_umodsi3.c b/gnu/usr.bin/gcc2/libgcc/_umodsi3.c deleted file mode 100644 index 86d6bbaa5f2e..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_umodsi3.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Id: _umodsi3.c,v 1.2 1993/08/02 17:38:45 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -union flt_or_value { float i; float f; }; -union flt_or_int { int i; float f; }; -long int -__umodsi3 (a, b) - unsigned long int a, b; -{ - { register int dx asm("dx"); register int ax asm("ax"); dx = 0; ax = a ; asm ("divl %3" : "=a" (ax), "=d" (dx) : "a" (ax), "g" ( b ), "d" (dx)); return dx; } ; -} diff --git a/gnu/usr.bin/gcc2/libgcc/_varargs.c b/gnu/usr.bin/gcc2/libgcc/_varargs.c deleted file mode 100644 index 82c72c858506..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/_varargs.c +++ /dev/null @@ -1,90 +0,0 @@ -/* $Id: _varargs.c,v 1.2 1993/08/02 17:38:45 mycroft Exp $ */ - -extern int target_flags; - -enum reg_class -{ - NO_REGS, - AREG, DREG, CREG, BREG, - Q_REGS, - SIREG, DIREG, - INDEX_REGS, - GENERAL_REGS, - FP_TOP_REG, FP_SECOND_REG, - FLOAT_REGS, - ALL_REGS, LIM_REG_CLASSES -}; -extern enum reg_class regclass_map[17 ]; - - -extern struct rtx_def *i386_compare_op0, *i386_compare_op1; -extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); -extern char *hi_reg_name[]; -extern char *qi_reg_name[]; -extern char *qi_high_reg_name[]; - -enum machine_mode { - VOIDmode , - QImode , - HImode , - PSImode , - SImode , - PDImode , - DImode , - TImode , - OImode , - QFmode , - HFmode , - SFmode , - DFmode , - XFmode , - TFmode , - SCmode , - DCmode , - XCmode , - TCmode , - CQImode , - CHImode , - CSImode , - CDImode , - CTImode , - COImode , - BLKmode , - CCmode , - CCFPEQmode , -MAX_MACHINE_MODE }; -extern char *mode_name[]; -enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, - MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; -extern enum mode_class mode_class[]; -extern int mode_size[]; -extern int mode_unit_size[]; -extern enum machine_mode mode_wider_mode[]; -extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ; -extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ; -extern enum machine_mode class_narrowest_mode[]; -extern enum machine_mode byte_mode; -extern enum machine_mode word_mode; -typedef int ptrdiff_t; -typedef unsigned int size_t; -typedef short unsigned int wchar_t; -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -typedef float SFtype __attribute__ ((mode (SF))); -typedef float DFtype __attribute__ ((mode (DF))); -typedef int word_type __attribute__ ((mode (SI))); - struct DIstruct {SItype low, high;}; -typedef union -{ - struct DIstruct s; - DItype ll; -} DIunion; -extern DItype __fixunssfdi (SFtype a); -extern DItype __fixunsdfdi (DFtype a); -__builtin_saveregs () -{ - abort (); -} diff --git a/gnu/usr.bin/gcc2/libgcc/clean.sed b/gnu/usr.bin/gcc2/libgcc/clean.sed deleted file mode 100644 index c660c69a32ee..000000000000 --- a/gnu/usr.bin/gcc2/libgcc/clean.sed +++ /dev/null @@ -1,4 +0,0 @@ -/^#/d -/^ /d -/^$/d -/^ $/d diff --git a/gnu/usr.bin/gdb/Xgdb.ad b/gnu/usr.bin/gdb/Xgdb.ad deleted file mode 100644 index 5f9fe9920b49..000000000000 --- a/gnu/usr.bin/gdb/Xgdb.ad +++ /dev/null @@ -1,8 +0,0 @@ -Xgdb*geometry: 580x874-0+28 -Xgdb*src*scrollVertical: whenneeded -Xgdb*src*scrollHorizontal: whenneeded -Xgdb*src*wrap: never -Xgdb*src*editType: read -Xgdb*frame.buttons.allowResize: true -Xgdb*frame.buttons.skipAdjust: true -Xgdb*frame*showGrip: false diff --git a/gnu/usr.bin/gdb/blockframe.c b/gnu/usr.bin/gdb/blockframe.c deleted file mode 100644 index f1bc313f6c26..000000000000 --- a/gnu/usr.bin/gdb/blockframe.c +++ /dev/null @@ -1,623 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)blockframe.c 6.4 (Berkeley) 5/11/91";*/ -static char rcsid[] = "$Id: blockframe.c,v 1.2 1993/08/01 18:47:25 mycroft Exp $"; -#endif /* not lint */ - -/* Get info from stack frames; - convert between frames, blocks, functions and pc values. - Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" - -#include - -#if defined(NEWVM) && defined(KERNELDEBUG) -#include /* XXX for FRAME_CHAIN_VALID */ -#endif - -/* Start and end of object file containing the entry point. - STARTUP_FILE_END is the first address of the next file. - This file is assumed to be a startup file - and frames with pc's inside it - are treated as nonexistent. - - Setting these variables is necessary so that backtraces do not fly off - the bottom of the stack. */ -CORE_ADDR startup_file_start; -CORE_ADDR startup_file_end; - -/* Is ADDR outside the startup file? */ -int -outside_startup_file (addr) - CORE_ADDR addr; -{ - return !(addr >= startup_file_start && addr < startup_file_end); -} - -/* Address of innermost stack frame (contents of FP register) */ - -static FRAME current_frame; - -struct block *block_for_pc (); -CORE_ADDR get_pc_function_start (); - -/* - * Cache for frame addresses already read by gdb. Valid only while - * inferior is stopped. Control variables for the frame cache should - * be local to this module. - */ -struct obstack frame_cache_obstack; - -/* Return the innermost (currently executing) stack frame. */ - -FRAME -get_current_frame () -{ - /* We assume its address is kept in a general register; - param.h says which register. */ - - return current_frame; -} - -void -set_current_frame (frame) - FRAME frame; -{ - current_frame = frame; -} - -FRAME -create_new_frame (addr, pc) - FRAME_ADDR addr; - CORE_ADDR pc; -{ - struct frame_info *fci; /* Same type as FRAME */ - - fci = (struct frame_info *) - obstack_alloc (&frame_cache_obstack, - sizeof (struct frame_info)); - - /* Arbitrary frame */ - fci->next = (struct frame_info *) 0; - fci->prev = (struct frame_info *) 0; - fci->frame = addr; - fci->next_frame = 0; /* Since arbitrary */ - fci->pc = pc; - -#ifdef INIT_EXTRA_FRAME_INFO - INIT_EXTRA_FRAME_INFO (fci); -#endif - - return fci; -} - -/* Return the frame that called FRAME. - If FRAME is the original frame (it has no caller), return 0. */ - -FRAME -get_prev_frame (frame) - FRAME frame; -{ - /* We're allowed to know that FRAME and "struct frame_info *" are - the same */ - return get_prev_frame_info (frame); -} - -/* Return the frame that FRAME calls (0 if FRAME is the innermost - frame). */ - -FRAME -get_next_frame (frame) - FRAME frame; -{ - /* We're allowed to know that FRAME and "struct frame_info *" are - the same */ - return frame->next; -} - -/* - * Flush the entire frame cache. - */ -void -flush_cached_frames () -{ - /* Since we can't really be sure what the first object allocated was */ - obstack_free (&frame_cache_obstack, 0); - obstack_init (&frame_cache_obstack); - - current_frame = (struct frame_info *) 0; /* Invalidate cache */ -} - -/* Return a structure containing various interesting information - about a specified stack frame. */ -/* How do I justify including this function? Well, the FRAME - identifier format has gone through several changes recently, and - it's not completely inconceivable that it could happen again. If - it does, have this routine around will help */ - -struct frame_info * -get_frame_info (frame) - FRAME frame; -{ - return frame; -} - -/* If a machine allows frameless functions, it should define a macro - FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) in param.h. FI is the struct - frame_info for the frame, and FRAMELESS should be set to nonzero - if it represents a frameless function invocation. */ - -/* Many machines which allow frameless functions can detect them using - this macro. Such machines should define FRAMELESS_FUNCTION_INVOCATION - to just call this macro. */ -#define FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) \ -{ \ - CORE_ADDR func_start, after_prologue; \ - func_start = (get_pc_function_start ((FI)->pc) + \ - FUNCTION_START_OFFSET); \ - if (func_start) \ - { \ - after_prologue = func_start; \ - SKIP_PROLOGUE (after_prologue); \ - (FRAMELESS) = (after_prologue == func_start); \ - } \ - else \ - /* If we can't find the start of the function, we don't really */ \ - /* know whether the function is frameless, but we should be */ \ - /* able to get a reasonable (i.e. best we can do under the */ \ - /* circumstances) backtrace by saying that it isn't. */ \ - (FRAMELESS) = 0; \ -} - -/* Return a structure containing various interesting information - about the frame that called NEXT_FRAME. Returns NULL - if there is no such frame. */ - -struct frame_info * -get_prev_frame_info (next_frame) - FRAME next_frame; -{ - FRAME_ADDR address; - struct frame_info *prev; - int fromleaf = 0; - - /* If the requested entry is in the cache, return it. - Otherwise, figure out what the address should be for the entry - we're about to add to the cache. */ - - if (!next_frame) - { - if (!current_frame) - { - if (!have_inferior_p () && !have_core_file_p ()) - fatal ("get_prev_frame_info: Called before cache primed. \"Shouldn't happen.\""); - else - error ("No inferior or core file."); - } - - return current_frame; - } - - /* If we have the prev one, return it */ - if (next_frame->prev) - return next_frame->prev; - - /* On some machines it is possible to call a function without - setting up a stack frame for it. On these machines, we - define this macro to take two args; a frameinfo pointer - identifying a frame and a variable to set or clear if it is - or isn't leafless. */ -#ifdef FRAMELESS_FUNCTION_INVOCATION - /* Still don't want to worry about this except on the innermost - frame. This macro will set FROMLEAF if NEXT_FRAME is a - frameless function invocation. */ - if (!(next_frame->next)) - { - FRAMELESS_FUNCTION_INVOCATION (next_frame, fromleaf); - if (fromleaf) - address = next_frame->frame; - } -#endif - - if (!fromleaf) - { - /* Two macros defined in param.h specify the machine-dependent - actions to be performed here. - First, get the frame's chain-pointer. - If that is zero, the frame is the outermost frame or a leaf - called by the outermost frame. This means that if start - calls main without a frame, we'll return 0 (which is fine - anyway). - - Nope; there's a problem. This also returns when the current - routine is a leaf of main. This is unacceptable. We move - this to after the ffi test; I'd rather have backtraces from - start go curfluy than have an abort called from main not show - main. */ - address = FRAME_CHAIN (next_frame); - if (!FRAME_CHAIN_VALID (address, next_frame)) - return 0; - /* If this frame is a leaf, this will be superceeded by the - code below. */ - address = FRAME_CHAIN_COMBINE (address, next_frame); - } - if (address == 0) - return 0; - - prev = (struct frame_info *) - obstack_alloc (&frame_cache_obstack, - sizeof (struct frame_info)); - - if (next_frame) - next_frame->prev = prev; - prev->next = next_frame; - prev->prev = (struct frame_info *) 0; - prev->frame = address; - prev->next_frame = prev->next ? prev->next->frame : 0; - -#ifdef INIT_EXTRA_FRAME_INFO - INIT_EXTRA_FRAME_INFO(prev); -#endif - - /* This entry is in the frame queue now, which is good since - FRAME_SAVED_PC may use that queue to figure out it's value - (see m-sparc.h). We want the pc saved in the inferior frame. */ - prev->pc = (fromleaf ? SAVED_PC_AFTER_CALL (next_frame) : - next_frame ? FRAME_SAVED_PC (next_frame) : read_pc ()); - - return prev; -} - -CORE_ADDR -get_frame_pc (frame) - FRAME frame; -{ - struct frame_info *fi; - fi = get_frame_info (frame); - return fi->pc; -} - -/* Find the addresses in which registers are saved in FRAME. */ - -void -get_frame_saved_regs (frame_info_addr, saved_regs_addr) - struct frame_info *frame_info_addr; - struct frame_saved_regs *saved_regs_addr; -{ - FRAME_FIND_SAVED_REGS (frame_info_addr, *saved_regs_addr); -} - -/* Return the innermost lexical block in execution - in a specified stack frame. The frame address is assumed valid. */ - -struct block * -get_frame_block (frame) - FRAME frame; -{ - struct frame_info *fi; - CORE_ADDR pc; - - fi = get_frame_info (frame); - - pc = fi->pc; - if (fi->next_frame != 0) - /* We are not in the innermost frame. We need to subtract one to - get the correct block, in case the call instruction was the - last instruction of the block. If there are any machines on - which the saved pc does not point to after the call insn, we - probably want to make fi->pc point after the call insn anyway. */ - --pc; - return block_for_pc (pc); -} - -struct block * -get_current_block () -{ - return block_for_pc (read_pc ()); -} - -CORE_ADDR -get_pc_function_start (pc) - CORE_ADDR pc; -{ - register struct block *bl = block_for_pc (pc); - register struct symbol *symbol; - if (bl == 0 || (symbol = block_function (bl)) == 0) - { - register int misc_index = find_pc_misc_function (pc); - if (misc_index >= 0) - return misc_function_vector[misc_index].address; - return 0; - } - bl = SYMBOL_BLOCK_VALUE (symbol); - return BLOCK_START (bl); -} - -/* Return the symbol for the function executing in frame FRAME. */ - -struct symbol * -get_frame_function (frame) - FRAME frame; -{ - register struct block *bl = get_frame_block (frame); - if (bl == 0) - return 0; - return block_function (bl); -} - -/* Return the innermost lexical block containing the specified pc value, - or 0 if there is none. */ - -extern struct symtab *psymtab_to_symtab (); - -struct block * -block_for_pc (pc) - register CORE_ADDR pc; -{ - register struct block *b; - register int bot, top, half; - register struct symtab *s; - register struct partial_symtab *ps; - struct blockvector *bl; - - /* First search all symtabs for one whose file contains our pc */ - - for (s = symtab_list; s; s = s->next) - { - bl = BLOCKVECTOR (s); - b = BLOCKVECTOR_BLOCK (bl, 0); - if (BLOCK_START (b) <= pc - && BLOCK_END (b) > pc) - break; - } - - if (s == 0) - for (ps = partial_symtab_list; ps; ps = ps->next) - { - if (ps->textlow <= pc - && ps->texthigh > pc) - { - if (ps->readin) - fatal ("Internal error: pc found in readin psymtab and not in any symtab."); - s = psymtab_to_symtab (ps); - bl = BLOCKVECTOR (s); - b = BLOCKVECTOR_BLOCK (bl, 0); - break; - } - } - - if (s == 0) - return 0; - - /* Then search that symtab for the smallest block that wins. */ - /* Use binary search to find the last block that starts before PC. */ - - bot = 0; - top = BLOCKVECTOR_NBLOCKS (bl); - - while (top - bot > 1) - { - half = (top - bot + 1) >> 1; - b = BLOCKVECTOR_BLOCK (bl, bot + half); - if (BLOCK_START (b) <= pc) - bot += half; - else - top = bot + half; - } - - /* Now search backward for a block that ends after PC. */ - - while (bot >= 0) - { - b = BLOCKVECTOR_BLOCK (bl, bot); - if (BLOCK_END (b) > pc) - return b; - bot--; - } - - return 0; -} - -/* Return the function containing pc value PC. - Returns 0 if function is not known. */ - -struct symbol * -find_pc_function (pc) - CORE_ADDR pc; -{ - register struct block *b = block_for_pc (pc); - if (b == 0) - return 0; - return block_function (b); -} - -/* Finds the "function" (text symbol) that is smaller than PC - but greatest of all of the potential text symbols. Sets - *NAME and/or *ADDRESS conditionally if that pointer is non-zero. - Returns 0 if it couldn't find anything, 1 if it did. On a zero - return, *NAME and *ADDRESS are always set to zero. On a 1 return, - *NAME and *ADDRESS contain real information. */ - -int -find_pc_partial_function (pc, name, address) - CORE_ADDR pc; - char **name; - CORE_ADDR *address; -{ - struct partial_symtab *pst = find_pc_psymtab (pc); - struct symbol *f; - int miscfunc; - struct partial_symbol *psb; - - if (pst) - { - if (pst->readin) - { - /* The information we want has already been read in. - We can go to the already readin symbols and we'll get - the best possible answer. */ - f = find_pc_function (pc); - if (!f) - { - return_error: - /* No availible symbol. */ - if (name != 0) - *name = 0; - if (address != 0) - *address = 0; - return 0; - } - - if (name) - *name = SYMBOL_NAME (f); - if (address) - *address = BLOCK_START (SYMBOL_BLOCK_VALUE (f)); - return 1; - } - - /* Get the information from a combination of the pst - (static symbols), and the misc function vector (extern - symbols). */ - miscfunc = find_pc_misc_function (pc); - psb = find_pc_psymbol (pst, pc); - - if (!psb && miscfunc == -1) - { - goto return_error; - } - if (!psb - || (miscfunc != -1 - && (SYMBOL_VALUE(psb) - < misc_function_vector[miscfunc].address))) - { - if (address) - *address = misc_function_vector[miscfunc].address; - if (name) - *name = misc_function_vector[miscfunc].name; - return 1; - } - else - { - if (address) - *address = SYMBOL_VALUE (psb); - if (name) - *name = SYMBOL_NAME (psb); - return 1; - } - } - else - /* Must be in the misc function stuff. */ - { - miscfunc = find_pc_misc_function (pc); - if (miscfunc == -1) - goto return_error; - if (address) - *address = misc_function_vector[miscfunc].address; - if (name) - *name = misc_function_vector[miscfunc].name; - return 1; - } -} - -/* Find the misc function whose address is the largest - while being less than PC. Return its index in misc_function_vector. - Returns -1 if PC is not in suitable range. */ - -int -find_pc_misc_function (pc) - register CORE_ADDR pc; -{ - register int lo = 0; - register int hi = misc_function_count-1; - register int new; - register int distance; - - /* Note that the last thing in the vector is always _etext. */ - /* Actually, "end", now that non-functions - go on the misc_function_vector. */ - - /* Above statement is not *always* true - fix for case where there are */ - /* no misc functions at all (ie no symbol table has been read). */ - if (hi < 0) return -1; /* no misc functions recorded */ - - /* trivial reject range test */ - if (pc < misc_function_vector[0].address || - pc > misc_function_vector[hi].address) - return -1; - - /* Note that the following search will not return hi if - pc == misc_function_vector[hi].address. If "end" points to the - first unused location, this is correct and the above test - simply needs to be changed to - "pc >= misc_function_vector[hi].address". */ - do { - new = (lo + hi) >> 1; - distance = misc_function_vector[new].address - pc; - if (distance == 0) - return new; /* an exact match */ - else if (distance > 0) - hi = new; - else - lo = new; - } while (hi-lo != 1); - - /* if here, we had no exact match, so return the lower choice */ - return lo; -} - -/* Return the innermost stack frame executing inside of the specified block, - or zero if there is no such frame. */ - -FRAME -block_innermost_frame (block) - struct block *block; -{ - struct frame_info *fi; - register FRAME frame; - register CORE_ADDR start = BLOCK_START (block); - register CORE_ADDR end = BLOCK_END (block); - - frame = 0; - while (1) - { - frame = get_prev_frame (frame); - if (frame == 0) - return 0; - fi = get_frame_info (frame); - if (fi->pc >= start && fi->pc < end) - return frame; - } -} - -void -_initialize_blockframe () -{ - obstack_init (&frame_cache_obstack); -} diff --git a/gnu/usr.bin/gdb/breakpoint.c b/gnu/usr.bin/gdb/breakpoint.c deleted file mode 100644 index a62361ad5e5b..000000000000 --- a/gnu/usr.bin/gdb/breakpoint.c +++ /dev/null @@ -1,1384 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)breakpoint.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: breakpoint.c,v 1.2 1993/08/01 18:47:24 mycroft Exp $"; -#endif /* not lint */ - -/* Everything about breakpoints, for GDB. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" - -/* This is the sequence of bytes we insert for a breakpoint. */ - -static char break_insn[] = BREAKPOINT; - -/* States of enablement of breakpoint. - `temporary' means disable when hit. - `delete' means delete when hit. */ - -enum enable { disabled, enabled, temporary, delete}; - -/* Not that the ->silent field is not currently used by any commands - (though the code is in there if it was to be and set_raw_breakpoint - does set it to 0). I implemented it because I thought it would be - useful for a hack I had to put in; I'm going to leave it in because - I can see how there might be times when it would indeed be useful */ - -struct breakpoint -{ - struct breakpoint *next; - /* Number assigned to distinguish breakpoints. */ - int number; - /* Address to break at. */ - CORE_ADDR address; - /* Line number of this address. Redundant. */ - int line_number; - /* Symtab of file of this address. Redundant. */ - struct symtab *symtab; - /* Zero means disabled; remember the info but don't break here. */ - enum enable enable; - /* Non-zero means a silent breakpoint (don't print frame info - if we stop here). */ - unsigned char silent; - /* Number of stops at this breakpoint that should - be continued automatically before really stopping. */ - int ignore_count; - /* "Real" contents of byte where breakpoint has been inserted. - Valid only when breakpoints are in the program. */ - char shadow_contents[sizeof break_insn]; - /* Nonzero if this breakpoint is now inserted. */ - char inserted; - /* Nonzero if this is not the first breakpoint in the list - for the given address. */ - char duplicate; - /* Chain of command lines to execute when this breakpoint is hit. */ - struct command_line *commands; - /* Stack depth (address of frame). If nonzero, break only if fp - equals this. */ - FRAME_ADDR frame; - /* Conditional. Break only if this expression's value is nonzero. */ - struct expression *cond; -}; - -#define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next) - -/* Chain of all breakpoints defined. */ - -struct breakpoint *breakpoint_chain; - -/* Number of last breakpoint made. */ - -static int breakpoint_count; - -/* Default address, symtab and line to put a breakpoint at - for "break" command with no arg. - if default_breakpoint_valid is zero, the other three are - not valid, and "break" with no arg is an error. - - This set by print_stack_frame, which calls set_default_breakpoint. */ - -int default_breakpoint_valid; -CORE_ADDR default_breakpoint_address; -struct symtab *default_breakpoint_symtab; -int default_breakpoint_line; - -/* Remaining commands (not yet executed) - of last breakpoint hit. */ - -struct command_line *breakpoint_commands; - -static void delete_breakpoint (); -void clear_momentary_breakpoints (); -void breakpoint_auto_delete (); - -/* Flag indicating extra verbosity for xgdb. */ -extern int xgdb_verbose; - -/* condition N EXP -- set break condition of breakpoint N to EXP. */ - -static void -condition_command (arg, from_tty) - char *arg; - int from_tty; -{ - register struct breakpoint *b; - register char *p; - register int bnum; - register struct expression *expr; - - if (arg == 0) - error_no_arg ("breakpoint number"); - - p = arg; - while (*p >= '0' && *p <= '9') p++; - if (p == arg) - /* There is no number here. (e.g. "cond a == b"). */ - error_no_arg ("breakpoint number"); - bnum = atoi (arg); - - ALL_BREAKPOINTS (b) - if (b->number == bnum) - { - if (b->cond) - { - free (b->cond); - b->cond = 0; /* parse_c_1 can leave this unchanged. */ - } - if (*p == 0) - { - b->cond = 0; - if (from_tty) - printf ("Breakpoint %d now unconditional.\n", bnum); - } - else - { - if (*p != ' ' && *p != '\t') - error ("Arguments must be an integer (breakpoint number) and an expression."); - - /* Find start of expression */ - while (*p == ' ' || *p == '\t') p++; - - arg = p; - b->cond = (struct expression *) parse_c_1 (&arg, block_for_pc (b->address), 0); - if (*arg) - error ("Junk at end of expression"); - } - return; - } - - error ("No breakpoint number %d.", bnum); -} - -static void -commands_command (arg, from_tty) - char *arg; - int from_tty; -{ - register struct breakpoint *b; - register char *p, *p1; - register int bnum; - struct command_line *l; - - /* If we allowed this, we would have problems with when to - free the storage, if we change the commands currently - being read from. */ - - if (breakpoint_commands) - error ("Can't use the \"commands\" command among a breakpoint's commands."); - - /* Allow commands by itself to refer to the last breakpoint. */ - if (arg == 0) - bnum = breakpoint_count; - else - { - p = arg; - if (! (*p >= '0' && *p <= '9')) - error ("Argument must be integer (a breakpoint number)."); - - while (*p >= '0' && *p <= '9') p++; - if (*p) - error ("Unexpected extra arguments following breakpoint number."); - - bnum = atoi (arg); - } - - ALL_BREAKPOINTS (b) - if (b->number == bnum) - { - if (from_tty && input_from_terminal_p ()) - { - printf ("Type commands for when breakpoint %d is hit, one per line.\n\ -End with a line saying just \"end\".\n", bnum); - fflush (stdout); - } - l = read_command_lines (from_tty); - free_command_lines (b->commands); - b->commands = l; - return; - } - error ("No breakpoint number %d.", bnum); -} - -/* Called from command loop to execute the commands - associated with the breakpoint we just stopped at. */ - -void -do_breakpoint_commands () -{ - struct command_line *cmd; - - while (cmd = breakpoint_commands) - { - breakpoint_commands = 0; - execute_command_lines(cmd); - /* If command was "cont", breakpoint_commands is now 0, - of if we stopped at yet another breakpoint which has commands, - it is now the commands for the new breakpoint. */ - } - clear_momentary_breakpoints (); -} - -/* Used when the program is proceeded, to eliminate any remaining - commands attached to the previous breakpoint we stopped at. */ - -void -clear_breakpoint_commands () -{ - breakpoint_commands = 0; - breakpoint_auto_delete (0); -} - -/* Functions to get and set the current list of pending - breakpoint commands. These are used by run_stack_dummy - to preserve the commands around a function call. */ - -struct command_line * -get_breakpoint_commands () -{ - return breakpoint_commands; -} - -void -set_breakpoint_commands (cmds) - struct command_line *cmds; -{ - breakpoint_commands = cmds; -} - -/* insert_breakpoints is used when starting or continuing the program. - remove_breakpoints is used when the program stops. - Both return zero if successful, - or an `errno' value if could not write the inferior. */ - -int -insert_breakpoints () -{ - register struct breakpoint *b; - int val; - -#ifdef BREAKPOINT_DEBUG - printf ("Inserting breakpoints.\n"); -#endif /* BREAKPOINT_DEBUG */ - - ALL_BREAKPOINTS (b) - if (b->enable != disabled && ! b->inserted && ! b->duplicate) - { - read_memory (b->address, b->shadow_contents, sizeof break_insn); - val = write_memory (b->address, break_insn, sizeof break_insn); - if (val) - return val; -#ifdef BREAKPOINT_DEBUG - printf ("Inserted breakpoint at 0x%x, shadow 0x%x, 0x%x.\n", - b->address, b->shadow_contents[0], b->shadow_contents[1]); -#endif /* BREAKPOINT_DEBUG */ - b->inserted = 1; - } - return 0; -} - -int -remove_breakpoints () -{ - register struct breakpoint *b; - int val; - -#ifdef BREAKPOINT_DEBUG - printf ("Removing breakpoints.\n"); -#endif /* BREAKPOINT_DEBUG */ - - ALL_BREAKPOINTS (b) - if (b->inserted) - { - val = write_memory (b->address, b->shadow_contents, sizeof break_insn); - if (val) - return val; - b->inserted = 0; -#ifdef BREAKPOINT_DEBUG - printf ("Removed breakpoint at 0x%x, shadow 0x%x, 0x%x.\n", - b->address, b->shadow_contents[0], b->shadow_contents[1]); -#endif /* BREAKPOINT_DEBUG */ - } - - return 0; -} - -/* Clear the "inserted" flag in all breakpoints. - This is done when the inferior is loaded. */ - -void -mark_breakpoints_out () -{ - register struct breakpoint *b; - - ALL_BREAKPOINTS (b) - b->inserted = 0; -} - -/* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC. - When continuing from a location with a breakpoint, - we actually single step once before calling insert_breakpoints. */ - -int -breakpoint_here_p (pc) - CORE_ADDR pc; -{ - register struct breakpoint *b; - - ALL_BREAKPOINTS (b) - if (b->enable != disabled && b->address == pc) - return 1; - - return 0; -} - -/* Evaluate the expression EXP and return 1 if value is zero. - This is used inside a catch_errors to evaluate the breakpoint condition. */ - -int -breakpoint_cond_eval (exp) - struct expression *exp; -{ - return value_zerop (evaluate_expression (exp)); -} - -/* Return 0 if PC is not the address just after a breakpoint, - or -1 if breakpoint says do not stop now, - or -2 if breakpoint says it has deleted itself and don't stop, - or -3 if hit a breakpoint number -3 (delete when program stops), - or else the number of the breakpoint, - with 0x1000000 added (or subtracted, for a negative return value) for - a silent breakpoint. */ - -int -breakpoint_stop_status (pc, frame_address) - CORE_ADDR pc; - FRAME_ADDR frame_address; -{ - register struct breakpoint *b; - register int cont = 0; - - /* Get the address where the breakpoint would have been. */ - pc -= DECR_PC_AFTER_BREAK; - - ALL_BREAKPOINTS (b) - if (b->enable != disabled && b->address == pc) - { - if (b->frame && b->frame != frame_address) - cont = -1; - else - { - int value_zero; - if (b->cond) - { - /* Need to select the frame, with all that implies - so that the conditions will have the right context. */ - select_frame (get_current_frame (), 0); - value_zero - = catch_errors (breakpoint_cond_eval, b->cond, - "Error occurred in testing breakpoint condition."); - free_all_values (); - } - if (b->cond && value_zero) - { - cont = -1; - } - else if (b->ignore_count > 0) - { - b->ignore_count--; - cont = -1; - } - else - { - if (b->enable == temporary) - b->enable = disabled; - breakpoint_commands = b->commands; - if (b->silent - || (breakpoint_commands - && !strcmp ("silent", breakpoint_commands->line))) - { - if (breakpoint_commands) - breakpoint_commands = breakpoint_commands->next; - return (b->number > 0 ? - 0x1000000 + b->number : - b->number - 0x1000000); - } - return b->number; - } - } - } - - return cont; -} - -static void -breakpoint_1 (bnum) - int bnum; -{ - register struct breakpoint *b; - register struct command_line *l; - register struct symbol *sym; - CORE_ADDR last_addr = (CORE_ADDR)-1; - - ALL_BREAKPOINTS (b) - if (bnum == -1 || bnum == b->number) - { - printf_filtered ("#%-3d %c 0x%08x", b->number, - "nyod"[(int) b->enable], - b->address); - last_addr = b->address; - if (b->symtab) - { - sym = find_pc_function (b->address); - if (sym) - { - fputs_filtered (" in ", stdout); - fputs_demangled (SYMBOL_NAME (sym), stdout, 1); - fputs_filtered (" (", stdout); - } - fputs_filtered (b->symtab->filename, stdout); - printf_filtered (" line %d", b->line_number); - if (sym) fputs_filtered(")", stdout); - } - else - print_address_symbolic (b->address, stdout); - - printf_filtered ("\n"); - - if (b->ignore_count) - printf_filtered ("\tignore next %d hits\n", b->ignore_count); - if (b->frame) - printf_filtered ("\tstop only in stack frame at 0x%x\n", b->frame); - if (b->cond) - { - printf_filtered ("\tbreak only if "); - print_expression (b->cond, stdout); - printf_filtered ("\n"); - } - if (l = b->commands) - while (l) - { - printf_filtered ("\t%s\n", l->line); - l = l->next; - } - } - - /* Compare against (CORE_ADDR)-1 in case some compiler decides - that a comparison of an unsigned with -1 is always false. */ - if (last_addr != (CORE_ADDR)-1) - set_next_address (last_addr); -} - -static void -breakpoints_info (bnum_exp) - char *bnum_exp; -{ - int bnum = -1; - - if (bnum_exp) - bnum = parse_and_eval_address (bnum_exp); - else if (breakpoint_chain == 0) - printf_filtered ("No breakpoints.\n"); - else - printf_filtered ("Breakpoints:\n\ -Num Enb Address Where\n"); - - breakpoint_1 (bnum); -} - -/* Print a message describing any breakpoints set at PC. */ - -static void -describe_other_breakpoints (pc) - register CORE_ADDR pc; -{ - register int others = 0; - register struct breakpoint *b; - - ALL_BREAKPOINTS (b) - if (b->address == pc) - others++; - if (others > 0) - { - printf ("Note: breakpoint%s ", (others > 1) ? "s" : ""); - ALL_BREAKPOINTS (b) - if (b->address == pc) - { - others--; - printf ("%d%s%s ", - b->number, - (b->enable == disabled) ? " (disabled)" : "", - (others > 1) ? "," : ((others == 1) ? " and" : "")); - } - printf ("also set at pc 0x%x.\n", pc); - } -} - -/* Set the default place to put a breakpoint - for the `break' command with no arguments. */ - -void -set_default_breakpoint (valid, addr, symtab, line) - int valid; - CORE_ADDR addr; - struct symtab *symtab; - int line; -{ - default_breakpoint_valid = valid; - default_breakpoint_address = addr; - default_breakpoint_symtab = symtab; - default_breakpoint_line = line; -} - -/* Rescan breakpoints at address ADDRESS, - marking the first one as "first" and any others as "duplicates". - This is so that the bpt instruction is only inserted once. */ - -static void -check_duplicates (address) - CORE_ADDR address; -{ - register struct breakpoint *b; - register int count = 0; - - ALL_BREAKPOINTS (b) - if (b->enable != disabled && b->address == address) - { - count++; - b->duplicate = count > 1; - } -} - -/* Low level routine to set a breakpoint. - Takes as args the three things that every breakpoint must have. - Returns the breakpoint object so caller can set other things. - Does not set the breakpoint number! - Does not print anything. */ - -static struct breakpoint * -set_raw_breakpoint (sal) - struct symtab_and_line sal; -{ - register struct breakpoint *b, *b1; - - b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint)); - bzero (b, sizeof *b); - b->address = sal.pc; - b->symtab = sal.symtab; - b->line_number = sal.line; - b->enable = enabled; - b->next = 0; - b->silent = 0; - - /* Add this breakpoint to the end of the chain - so that a list of breakpoints will come out in order - of increasing numbers. */ - - b1 = breakpoint_chain; - if (b1 == 0) - breakpoint_chain = b; - else - { - while (b1->next) - b1 = b1->next; - b1->next = b; - } - - check_duplicates (sal.pc); - - return b; -} - -/* Set a breakpoint that will evaporate an end of command - at address specified by SAL. - Restrict it to frame FRAME if FRAME is nonzero. */ - -void -set_momentary_breakpoint (sal, frame) - struct symtab_and_line sal; - FRAME frame; -{ - register struct breakpoint *b; - b = set_raw_breakpoint (sal); - b->number = -3; - b->enable = delete; - b->frame = (frame ? FRAME_FP (frame) : 0); -} - -void -clear_momentary_breakpoints () -{ - register struct breakpoint *b; - ALL_BREAKPOINTS (b) - if (b->number == -3) - { - delete_breakpoint (b); - break; - } -} - -/* Set a breakpoint from a symtab and line. - If TEMPFLAG is nonzero, it is a temporary breakpoint. - Print the same confirmation messages that the breakpoint command prints. */ - -void -set_breakpoint (s, line, tempflag) - struct symtab *s; - int line; - int tempflag; -{ - register struct breakpoint *b; - struct symtab_and_line sal; - - sal.symtab = s; - sal.line = line; - sal.pc = find_line_pc (sal.symtab, sal.line); - if (sal.pc == 0) - error ("No line %d in file \"%s\".\n", sal.line, sal.symtab->filename); - else - { - describe_other_breakpoints (sal.pc); - - b = set_raw_breakpoint (sal); - b->number = ++breakpoint_count; - b->cond = 0; - if (tempflag) - b->enable = temporary; - - printf ("Breakpoint %d at 0x%x", b->number, b->address); - if (b->symtab) - printf (": file %s, line %d.", b->symtab->filename, b->line_number); - printf ("\n"); - } -} - -/* Set a breakpoint according to ARG (function, linenum or *address) - and make it temporary if TEMPFLAG is nonzero. */ - -static void -break_command_1 (arg, tempflag, from_tty) - char *arg; - int tempflag, from_tty; -{ - struct symtabs_and_lines sals; - struct symtab_and_line sal; - register struct expression *cond = 0; - register struct breakpoint *b; - char *save_arg; - int i; - CORE_ADDR pc; - - sals.sals = NULL; - sals.nelts = 0; - - sal.line = sal.pc = sal.end = 0; - sal.symtab = 0; - - /* If no arg given, or if first arg is 'if ', use the default breakpoint. */ - - if (!arg || (arg[0] == 'i' && arg[1] == 'f' - && (arg[2] == ' ' || arg[2] == '\t'))) - { - if (default_breakpoint_valid) - { - sals.sals = (struct symtab_and_line *) - malloc (sizeof (struct symtab_and_line)); - sal.pc = default_breakpoint_address; - sal.line = default_breakpoint_line; - sal.symtab = default_breakpoint_symtab; - sals.sals[0] = sal; - sals.nelts = 1; - } - else - error ("No default breakpoint address now."); - } - else - /* Force almost all breakpoints to be in terms of the - current_source_symtab (which is decode_line_1's default). This - should produce the results we want almost all of the time while - leaving default_breakpoint_* alone. */ - if (default_breakpoint_valid - && (!current_source_symtab - || (arg && (*arg == '+' || *arg == '-')))) - sals = decode_line_1 (&arg, 1, default_breakpoint_symtab, - default_breakpoint_line); - else - sals = decode_line_1 (&arg, 1, 0, 0); - - if (! sals.nelts) - return; - - save_arg = arg; - for (i = 0; i < sals.nelts; i++) - { - sal = sals.sals[i]; - if (sal.pc == 0 && sal.symtab != 0) - { - pc = find_line_pc (sal.symtab, sal.line); - if (pc == 0) - error ("No line %d in file \"%s\".", - sal.line, sal.symtab->filename); - } - else - pc = sal.pc; - - while (arg && *arg) - { - if (arg[0] == 'i' && arg[1] == 'f' - && (arg[2] == ' ' || arg[2] == '\t')) - cond = (struct expression *) parse_c_1 ((arg += 2, &arg), - block_for_pc (pc), 0); - else - error ("Junk at end of arguments."); - } - arg = save_arg; - sals.sals[i].pc = pc; - } - - for (i = 0; i < sals.nelts; i++) - { - sal = sals.sals[i]; - - if (from_tty) - describe_other_breakpoints (sal.pc); - - b = set_raw_breakpoint (sal); - b->number = ++breakpoint_count; - b->cond = cond; - if (tempflag) - b->enable = temporary; - - printf ("Breakpoint %d at 0x%x", b->number, b->address); - if (b->symtab) - printf (": file %s, line %d.", b->symtab->filename, b->line_number); - printf ("\n"); - } - - if (sals.nelts > 1) - { - printf ("Multiple breakpoints were set.\n"); - printf ("Use the \"delete\" command to delete unwanted breakpoints.\n"); - } - free (sals.sals); -} - -static void -break_command (arg, from_tty) - char *arg; - int from_tty; -{ - break_command_1 (arg, 0, from_tty); -} - -static void -tbreak_command (arg, from_tty) - char *arg; - int from_tty; -{ - break_command_1 (arg, 1, from_tty); -} - -/* - * Helper routine for the until_command routine in infcmd.c. Here - * because it uses the mechanisms of breakpoints. - */ -void -until_break_command (arg, from_tty) - char *arg; - int from_tty; -{ - struct symtabs_and_lines sals; - struct symtab_and_line sal; - FRAME prev_frame = get_prev_frame (selected_frame); - - clear_proceed_status (); - - /* Set a breakpoint where the user wants it and at return from - this function */ - - if (default_breakpoint_valid) - sals = decode_line_1 (&arg, 1, default_breakpoint_symtab, - default_breakpoint_line); - else - sals = decode_line_1 (&arg, 1, 0, 0); - - if (sals.nelts != 1) - error ("Couldn't get information on specified line."); - - sal = sals.sals[0]; - free (sals.sals); /* malloc'd, so freed */ - - if (*arg) - error ("Junk at end of arguments."); - - if (sal.pc == 0 && sal.symtab != 0) - sal.pc = find_line_pc (sal.symtab, sal.line); - - if (sal.pc == 0) - error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename); - - set_momentary_breakpoint (sal, selected_frame); - - /* Keep within the current frame */ - - if (prev_frame) - { - struct frame_info *fi; - - fi = get_frame_info (prev_frame); - sal = find_pc_line (fi->pc, 0); - sal.pc = fi->pc; - set_momentary_breakpoint (sal, prev_frame); - } - - proceed (-1, -1, 0); -} - -static void -clear_command (arg, from_tty) - char *arg; - int from_tty; -{ - register struct breakpoint *b, *b1; - struct symtabs_and_lines sals; - struct symtab_and_line sal; - register struct breakpoint *found; - int i; - - if (arg) - { - sals = decode_line_spec (arg, 1); - } - else - { - sals.sals = (struct symtab_and_line *) malloc (sizeof (struct symtab_and_line)); - sal.line = default_breakpoint_line; - sal.symtab = default_breakpoint_symtab; - sal.pc = 0; - if (sal.symtab == 0) - error ("No source file specified."); - - sals.sals[0] = sal; - sals.nelts = 1; - } - - for (i = 0; i < sals.nelts; i++) - { - /* If exact pc given, clear bpts at that pc. - But if sal.pc is zero, clear all bpts on specified line. */ - sal = sals.sals[i]; - found = (struct breakpoint *) 0; - while (breakpoint_chain - && (sal.pc ? breakpoint_chain->address == sal.pc - : (breakpoint_chain->symtab == sal.symtab - && breakpoint_chain->line_number == sal.line))) - { - b1 = breakpoint_chain; - breakpoint_chain = b1->next; - b1->next = found; - found = b1; - } - - ALL_BREAKPOINTS (b) - while (b->next - && (sal.pc ? b->next->address == sal.pc - : (b->next->symtab == sal.symtab - && b->next->line_number == sal.line))) - { - b1 = b->next; - b->next = b1->next; - b1->next = found; - found = b1; - } - - if (found == 0) - error ("No breakpoint at %s.", arg); - - if (found->next) from_tty = 1; /* Always report if deleted more than one */ - if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : ""); - while (found) - { - if (from_tty) printf ("%d ", found->number); - b1 = found->next; - delete_breakpoint (found); - found = b1; - } - if (from_tty) putchar ('\n'); - } - free (sals.sals); -} - -/* Delete breakpoint number BNUM if it is a `delete' breakpoint. - This is called after breakpoint BNUM has been hit. - Also delete any breakpoint numbered -3 unless there are breakpoint - commands to be executed. */ - -void -breakpoint_auto_delete (bnum) - int bnum; -{ - register struct breakpoint *b; - if (bnum != 0) - ALL_BREAKPOINTS (b) - if (b->number == bnum) - { - if (b->enable == delete) - delete_breakpoint (b); - break; - } - if (breakpoint_commands == 0) - clear_momentary_breakpoints (); -} - -static void -delete_breakpoint (bpt) - struct breakpoint *bpt; -{ - register struct breakpoint *b; - - if (bpt->inserted) - write_memory (bpt->address, bpt->shadow_contents, sizeof break_insn); - - if (breakpoint_chain == bpt) - breakpoint_chain = bpt->next; - - ALL_BREAKPOINTS (b) - if (b->next == bpt) - { - b->next = bpt->next; - break; - } - - check_duplicates (bpt->address); - - free_command_lines (bpt->commands); - if (bpt->cond) - free (bpt->cond); - - if (xgdb_verbose && bpt->number >=0) - printf ("breakpoint #%d deleted\n", bpt->number); - - free (bpt); -} - -static void map_breakpoint_numbers (); - -static void -delete_command (arg, from_tty) - char *arg; - int from_tty; -{ - register struct breakpoint *b, *b1; - - if (arg == 0) - { - /* Ask user only if there are some breakpoints to delete. */ - if (!from_tty - || breakpoint_chain && query ("Delete all breakpoints? ")) - { - /* No arg; clear all breakpoints. */ - while (breakpoint_chain) - delete_breakpoint (breakpoint_chain); - } - } - else - map_breakpoint_numbers (arg, delete_breakpoint); -} - -/* Delete all breakpoints. - Done when new symtabs are loaded, since the break condition expressions - may become invalid, and the breakpoints are probably wrong anyway. */ - -void -clear_breakpoints () -{ - delete_command (0, 0); -} - -/* Set ignore-count of breakpoint number BPTNUM to COUNT. - If from_tty is nonzero, it prints a message to that effect, - which ends with a period (no newline). */ - -void -set_ignore_count (bptnum, count, from_tty) - int bptnum, count, from_tty; -{ - register struct breakpoint *b; - - if (count < 0) - count = 0; - - ALL_BREAKPOINTS (b) - if (b->number == bptnum) - { - b->ignore_count = count; - if (!from_tty) - return; - else if (count == 0) - printf ("Will stop next time breakpoint %d is reached.", bptnum); - else if (count == 1) - printf ("Will ignore next crossing of breakpoint %d.", bptnum); - else - printf ("Will ignore next %d crossings of breakpoint %d.", - count, bptnum); - return; - } - - error ("No breakpoint number %d.", bptnum); -} - -/* Clear the ignore counts of all breakpoints. */ -void -breakpoint_clear_ignore_counts () -{ - struct breakpoint *b; - - ALL_BREAKPOINTS (b) - b->ignore_count = 0; -} - -/* Command to set ignore-count of breakpoint N to COUNT. */ - -static void -ignore_command (args, from_tty) - char *args; - int from_tty; -{ - register char *p = args; - register int num; - - if (p == 0) - error_no_arg ("a breakpoint number"); - - while (*p >= '0' && *p <= '9') p++; - if (*p && *p != ' ' && *p != '\t') - error ("First argument must be a breakpoint number."); - - num = atoi (args); - - if (*p == 0) - error ("Second argument (specified ignore-count) is missing."); - - set_ignore_count (num, parse_and_eval_address (p), from_tty); - printf ("\n"); -} - -/* Call FUNCTION on each of the breakpoints - whose numbers are given in ARGS. */ - -static void -map_breakpoint_numbers (args, function) - char *args; - void (*function) (); -{ - register char *p = args; - register char *p1; - register int num; - register struct breakpoint *b; - - if (p == 0) - error_no_arg ("one or more breakpoint numbers"); - - while (*p) - { - p1 = p; - while (*p1 >= '0' && *p1 <= '9') p1++; - if (*p1 && *p1 != ' ' && *p1 != '\t') - error ("Arguments must be breakpoint numbers."); - - num = atoi (p); - - ALL_BREAKPOINTS (b) - if (b->number == num) - { - function (b); - goto win; - } - printf ("No breakpoint number %d.\n", num); - win: - p = p1; - while (*p == ' ' || *p == '\t') p++; - } -} - -static void -enable_breakpoint (bpt) - struct breakpoint *bpt; -{ - bpt->enable = enabled; - - if (xgdb_verbose && bpt->number >= 0) - printf ("breakpoint #%d enabled\n", bpt->number); - - check_duplicates (bpt->address); -} - -static void -enable_command (args) - char *args; -{ - struct breakpoint *bpt; - if (args == 0) - ALL_BREAKPOINTS (bpt) - enable_breakpoint (bpt); - else - map_breakpoint_numbers (args, enable_breakpoint); -} - -static void -disable_breakpoint (bpt) - struct breakpoint *bpt; -{ - bpt->enable = disabled; - - if (xgdb_verbose && bpt->number >= 0) - printf ("breakpoint #%d disabled\n", bpt->number); - - check_duplicates (bpt->address); -} - -static void -disable_command (args) - char *args; -{ - register struct breakpoint *bpt; - if (args == 0) - ALL_BREAKPOINTS (bpt) - disable_breakpoint (bpt); - else - map_breakpoint_numbers (args, disable_breakpoint); -} - -static void -enable_once_breakpoint (bpt) - struct breakpoint *bpt; -{ - bpt->enable = temporary; - - check_duplicates (bpt->address); -} - -static void -enable_once_command (args) - char *args; -{ - map_breakpoint_numbers (args, enable_once_breakpoint); -} - -static void -enable_delete_breakpoint (bpt) - struct breakpoint *bpt; -{ - bpt->enable = delete; - - check_duplicates (bpt->address); -} - -static void -enable_delete_command (args) - char *args; -{ - map_breakpoint_numbers (args, enable_delete_breakpoint); -} - -/* - * Use default_breakpoint_'s, or nothing if they aren't valid. - */ -struct symtabs_and_lines -decode_line_spec_1 (string, funfirstline) - char *string; - int funfirstline; -{ - struct symtabs_and_lines sals; - if (string == 0) - error ("Empty line specification."); - if (default_breakpoint_valid) - sals = decode_line_1 (&string, funfirstline, - default_breakpoint_symtab, default_breakpoint_line); - else - sals = decode_line_1 (&string, funfirstline, 0, 0); - if (*string) - error ("Junk at end of line specification: %s", string); - return sals; -} - - -/* Chain containing all defined enable commands. */ - -extern struct cmd_list_element - *enablelist, *disablelist, - *deletelist, *enablebreaklist; - -extern struct cmd_list_element *cmdlist; - -void -_initialize_breakpoint () -{ - breakpoint_chain = 0; - breakpoint_count = 0; - - add_com ("ignore", class_breakpoint, ignore_command, - "Set ignore-count of breakpoint number N to COUNT."); - - add_com ("commands", class_breakpoint, commands_command, - "Set commands to be executed when a breakpoint is hit.\n\ -Give breakpoint number as argument after \"commands\".\n\ -With no argument, the targeted breakpoint is the last one set.\n\ -The commands themselves follow starting on the next line.\n\ -Type a line containing \"end\" to indicate the end of them.\n\ -Give \"silent\" as the first line to make the breakpoint silent;\n\ -then no output is printed when it is hit, except what the commands print."); - - add_com ("condition", class_breakpoint, condition_command, - "Specify breakpoint number N to break only if COND is true.\n\ -N is an integer; COND is a C expression to be evaluated whenever\n\ -breakpoint N is reached. Actually break only when COND is nonzero."); - - add_com ("tbreak", class_breakpoint, tbreak_command, - "Set a temporary breakpoint. Args like \"break\" command.\n\ -Like \"break\" except the breakpoint is only enabled temporarily,\n\ -so it will be disabled when hit. Equivalent to \"break\" followed\n\ -by using \"enable once\" on the breakpoint number."); - - add_prefix_cmd ("enable", class_breakpoint, enable_command, - "Enable some breakpoints or auto-display expressions.\n\ -Give breakpoint numbers (separated by spaces) as arguments.\n\ -With no subcommand, breakpoints are enabled until you command otherwise.\n\ -This is used to cancel the effect of the \"disable\" command.\n\ -With a subcommand you can enable temporarily.\n\ -\n\ -The \"display\" subcommand applies to auto-displays instead of breakpoints.", - &enablelist, "enable ", 1, &cmdlist); - - add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command, - "Enable some breakpoints or auto-display expressions.\n\ -Give breakpoint numbers (separated by spaces) as arguments.\n\ -With no subcommand, breakpoints are enabled until you command otherwise.\n\ -This is used to cancel the effect of the \"disable\" command.\n\ -May be abbreviates to simply \"enable\".\n\ -With a subcommand you can enable temporarily.", - &enablebreaklist, "enable breakpoints ", 1, &enablelist); - - add_cmd ("once", no_class, enable_once_command, - "Enable breakpoints for one hit. Give breakpoint numbers.\n\ -If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\ -See the \"tbreak\" command which sets a breakpoint and enables it once.", - &enablebreaklist); - - add_cmd ("delete", no_class, enable_delete_command, - "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\ -If a breakpoint is hit while enabled in this fashion, it is deleted.", - &enablebreaklist); - - add_cmd ("delete", no_class, enable_delete_command, - "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\ -If a breakpoint is hit while enabled in this fashion, it is deleted.", - &enablelist); - - add_cmd ("once", no_class, enable_once_command, - "Enable breakpoints for one hit. Give breakpoint numbers.\n\ -If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\ -See the \"tbreak\" command which sets a breakpoint and enables it once.", - &enablelist); - - add_prefix_cmd ("disable", class_breakpoint, disable_command, - "Disable some breakpoints or auto-display expressions.\n\ -Arguments are breakpoint numbers with spaces in between.\n\ -To disable all breakpoints, give no argument.\n\ -A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\ -\n\ -The \"display\" subcommand applies to auto-displays instead of breakpoints.", - &disablelist, "disable ", 1, &cmdlist); - add_com_alias ("dis", "disable", class_breakpoint, 1); - add_com_alias ("disa", "disable", class_breakpoint, 1); - - add_abbrev_cmd ("breakpoints", class_breakpoint, disable_command, - "Disable some breakpoints or auto-display expressions.\n\ -Arguments are breakpoint numbers with spaces in between.\n\ -To disable all breakpoints, give no argument.\n\ -A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\ -This command may be abbreviated \"disable\".", - &disablelist); - - add_prefix_cmd ("delete", class_breakpoint, delete_command, - "Delete some breakpoints or auto-display expressions.\n\ -Arguments are breakpoint numbers with spaces in between.\n\ -To delete all breakpoints, give no argument.\n\ -\n\ -Also a prefix command for deletion of other GDB objects.\n\ -The \"unset\" command is also an alias for \"delete\".", - &deletelist, "delete ", 1, &cmdlist); - add_com_alias ("d", "delete", class_breakpoint, 1); - add_com_alias ("unset", "delete", class_alias, 1); - - add_cmd ("breakpoints", class_alias, delete_command, - "Delete some breakpoints or auto-display expressions.\n\ -Arguments are breakpoint numbers with spaces in between.\n\ -To delete all breakpoints, give no argument.\n\ -This command may be abbreviated \"delete\".", - &deletelist); - - add_com ("clear", class_breakpoint, clear_command, - "Clear breakpoint at specified line or function.\n\ -Argument may be line number, function name, or \"*\" and an address.\n\ -If line number is specified, all breakpoints in that line are cleared.\n\ -If function is specified, breakpoints at beginning of function are cleared.\n\ -If an address is specified, breakpoints at that address are cleared.\n\n\ -With no argument, clears all breakpoints in the line that the selected frame\n\ -is executing in.\n\ -\n\ -See also the \"delete\" command which clears breakpoints by number."); - - add_com ("break", class_breakpoint, break_command, - "Set breakpoint at specified line or function.\n\ -Argument may be line number, function name, or \"*\" and an address.\n\ -If line number is specified, break at start of code for that line.\n\ -If function is specified, break at start of code for that function.\n\ -If an address is specified, break at that exact address.\n\ -With no arg, uses current execution address of selected stack frame.\n\ -This is useful for breaking on return to a stack frame.\n\ -\n\ -Multiple breakpoints at one place are permitted, and useful if conditional.\n\ -\n\ -Do \"help breakpoints\" for info on other commands dealing with breakpoints."); - add_com_alias ("b", "break", class_run, 1); - add_com_alias ("br", "break", class_run, 1); - add_com_alias ("bre", "break", class_run, 1); - add_com_alias ("brea", "break", class_run, 1); - - add_info ("breakpoints", breakpoints_info, - "Status of all breakpoints, or breakpoint number NUMBER.\n\ -Second column is \"y\" for enabled breakpoint, \"n\" for disabled,\n\ -\"o\" for enabled once (disable when hit), \"d\" for enable but delete when hit.\n\ -Then come the address and the file/line number.\n\n\ -Convenience variable \"$_\" and default examine address for \"x\"\n\ -are set to the address of the last breakpoint listed."); -} - diff --git a/gnu/usr.bin/gdb/command.c b/gnu/usr.bin/gdb/command.c deleted file mode 100644 index 86f9498af54b..000000000000 --- a/gnu/usr.bin/gdb/command.c +++ /dev/null @@ -1,860 +0,0 @@ -/* Library for reading command lines and decoding commands. - Copyright (C) 1986, 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 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. */ - -#ifndef lint -static char rcsid[] = "$Id: command.c,v 1.2 1993/08/02 17:40:52 mycroft Exp $"; -#endif /* not lint */ - -#include "command.h" -#include "defs.h" -#include -#include - -extern char *xmalloc (); - -/* Add element named NAME to command list *LIST. - FUN should be the function to execute the command; - it will get a character string as argument, with leading - and trailing blanks already eliminated. - - DOC is a documentation string for the command. - Its first line should be a complete sentence. - It should start with ? for a command that is an abbreviation - or with * for a command that most users don't need to know about. */ - -struct cmd_list_element * -add_cmd (name, class, fun, doc, list) - char *name; - int class; - void (*fun) (); - char *doc; - struct cmd_list_element **list; -{ - register struct cmd_list_element *c - = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element)); - - delete_cmd (name, list); - c->next = *list; - c->name = savestring (name, strlen (name)); - c->class = class; - c->function = fun; - c->doc = doc; - c->prefixlist = 0; - c->allow_unknown = 0; - c->abbrev_flag = 0; - c->aux = 0; - *list = c; - return c; -} - -/* Same as above, except that the abbrev_flag is set. */ - -struct cmd_list_element * -add_abbrev_cmd (name, class, fun, doc, list) - char *name; - int class; - void (*fun) (); - char *doc; - struct cmd_list_element **list; -{ - register struct cmd_list_element *c - = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element)); - - delete_cmd (name, list); - c->next = *list; - c->name = savestring (name, strlen (name)); - c->class = class; - c->function = fun; - c->doc = doc; - c->prefixlist = 0; - c->allow_unknown = 0; - c->abbrev_flag = 1; - c->aux = 0; - *list = c; - return c; -} - -struct cmd_list_element * -add_alias_cmd (name, oldname, class, abbrev_flag, list) - char *name; - char *oldname; - int class; - int abbrev_flag; - struct cmd_list_element **list; -{ - /* Must do this since lookup_cmd tries to side-effect its first arg */ - char *copied_name; - register struct cmd_list_element *old; - register struct cmd_list_element *c; - copied_name = (char *) alloca (strlen (oldname) + 1); - strcpy (copied_name, oldname); - old = lookup_cmd (&copied_name, *list, 0, 1, 1); - - if (old == 0) - { - delete_cmd (name, list); - return 0; - } - - c = add_cmd (name, class, old->function, old->doc, list); - c->prefixlist = old->prefixlist; - c->prefixname = old->prefixname; - c->allow_unknown = old->allow_unknown; - c->abbrev_flag = abbrev_flag; - c->aux = old->aux; - return c; -} - -/* Like add_cmd but adds an element for a command prefix: - a name that should be followed by a subcommand to be looked up - in another command list. PREFIXLIST should be the address - of the variable containing that list. */ - -struct cmd_list_element * -add_prefix_cmd (name, class, fun, doc, prefixlist, prefixname, - allow_unknown, list) - char *name; - int class; - void (*fun) (); - char *doc; - struct cmd_list_element **prefixlist; - char *prefixname; - int allow_unknown; - struct cmd_list_element **list; -{ - register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list); - c->prefixlist = prefixlist; - c->prefixname = prefixname; - c->allow_unknown = allow_unknown; - return c; -} - -/* Like add_prefix_cmd butsets the abbrev_flag on the new command. */ - -struct cmd_list_element * -add_abbrev_prefix_cmd (name, class, fun, doc, prefixlist, prefixname, - allow_unknown, list) - char *name; - int class; - void (*fun) (); - char *doc; - struct cmd_list_element **prefixlist; - char *prefixname; - int allow_unknown; - struct cmd_list_element **list; -{ - register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list); - c->prefixlist = prefixlist; - c->prefixname = prefixname; - c->allow_unknown = allow_unknown; - c->abbrev_flag = 1; - return c; -} - -/* Remove the command named NAME from the command list. */ - -void -delete_cmd (name, list) - char *name; - struct cmd_list_element **list; -{ - register struct cmd_list_element *c; - - while (*list && !strcmp ((*list)->name, name)) - { - *list = (*list)->next; - } - - if (*list) - for (c = *list; c->next;) - { - if (!strcmp (c->next->name, name)) - c->next = c->next->next; - else - c = c->next; - } -} - -void help_cmd (), help_list (), help_cmd_list (); - -/* This command really has to deal with two things: - * 1) I want documentation on *this string* (usually called by - * "help commandname"). - * 2) I want documentation on *this list* (usually called by - * giving a command that requires subcommands. Also called by saying - * just "help".) - * - * I am going to split this into two seperate comamnds, help_cmd and - * help_list. - */ - -void -help_cmd (command, stream) - char *command; - FILE *stream; -{ - struct cmd_list_element *c; - extern struct cmd_list_element *cmdlist; - - if (!command) - { - help_list (cmdlist, "", -2, stream); - return; - } - - c = lookup_cmd (&command, cmdlist, "", 0, 0); - - if (c == 0) - return; - - /* There are three cases here. - If c->prefixlist is nonzer, we have a prefix command. - Print its documentation, then list its subcommands. - - If c->function is nonzero, we really have a command. - Print its documentation and return. - - If c->function is zero, we have a class name. - Print its documentation (as if it were a command) - and then set class to he number of this class - so that the commands in the class will be listed. */ - - fputs_filtered (c->doc, stream); - fputs_filtered ("\n", stream); - - if (c->prefixlist == 0 && c->function != 0) - return; - fprintf_filtered (stream, "\n"); - - /* If this is a prefix command, print it's subcommands */ - if (c->prefixlist) - help_list (*c->prefixlist, c->prefixname, -1, stream); - - /* If this is a class name, print all of the commands in the class */ - if (c->function == 0) - help_list (cmdlist, "", c->class, stream); -} - -/* - * Get a specific kind of help on a command list. - * - * LIST is the list. - * CMDTYPE is the prefix to use in the title string. - * CLASS is the class with which to list the nodes of this list (see - * documentation for help_cmd_list below), As usual, -1 for - * everything, -2 for just classes, and non-negative for only things - * in a specific class. - * and STREAM is the output stream on which to print things. - * If you call this routine with a class >= 0, it recurses. - */ -void -help_list (list, cmdtype, class, stream) - struct cmd_list_element *list; - char *cmdtype; - int class; - FILE *stream; -{ - int len; - char *cmdtype1, *cmdtype2; - - /* If CMDTYPE is "foo ", CMDTYPE1 gets " foo" and CMDTYPE2 gets "foo sub" */ - len = strlen (cmdtype); - cmdtype1 = (char *) alloca (len + 1); - cmdtype1[0] = 0; - cmdtype2 = (char *) alloca (len + 4); - cmdtype2[0] = 0; - if (len) - { - cmdtype1[0] = ' '; - strncpy (cmdtype1 + 1, cmdtype, len - 1); - cmdtype1[len] = 0; - strncpy (cmdtype2, cmdtype, len - 1); - strcpy (cmdtype2 + len - 1, " sub"); - } - - if (class == -2) - fprintf_filtered (stream, "List of classes of %scommands:\n\n", cmdtype2); - else - fprintf_filtered (stream, "List of %scommands:\n\n", cmdtype2); - - help_cmd_list (list, class, cmdtype, (class >= 0), stream); - - if (class == -2) - fprintf_filtered (stream, "\n\ -Type \"help%s\" followed by a class name for a list of commands in that class.", - cmdtype1); - - fprintf_filtered (stream, "\n\ -Type \"help%s\" followed by %scommand name for full documentation.\n\ -Command name abbreviations are allowed if unambiguous.\n", - cmdtype1, cmdtype2); -} - - -/* - * Implement a help command on command list LIST. - * RECURSE should be non-zero if this should be done recursively on - * all sublists of LIST. - * PREFIX is the prefix to print before each command name. - * STREAM is the stream upon which the output should be written. - * CLASS should be: - * A non-negative class number to list only commands in that - * class. - * -1 to list all commands in list. - * -2 to list all classes in list. - * - * Note that RECURSE will be active on *all* sublists, not just the - * ones seclected by the criteria above (ie. the selection mechanism - * is at the low level, not the high-level). - */ -void -help_cmd_list (list, class, prefix, recurse, stream) - struct cmd_list_element *list; - int class; - char *prefix; - int recurse; - FILE *stream; -{ - register struct cmd_list_element *c; - register char *p; - static char *line_buffer = 0; - static int line_size; - - if (!line_buffer) - { - line_size = 80; - line_buffer = (char *) xmalloc (line_size); - } - - for (c = list; c; c = c->next) - { - if (c->abbrev_flag == 0 && - (class == -1 - || (class == -2 && c->function == 0) - || (class == c->class && c->function != 0))) - { - fprintf_filtered (stream, "%s%s -- ", prefix, c->name); - /* Print just the first line */ - p = c->doc; - while (*p && *p != '\n') p++; - if (p - c->doc > line_size - 1) - { - line_size = p - c->doc + 1; - free (line_buffer); - line_buffer = (char *) xmalloc (line_size); - } - strncpy (line_buffer, c->doc, p - c->doc); - line_buffer[p - c->doc] = '\0'; - fputs_filtered (line_buffer, stream); - fputs_filtered ("\n", stream); - } - if (recurse - && c->prefixlist != 0 - && c->abbrev_flag == 0) - help_cmd_list (*c->prefixlist, class, c->prefixname, 1, stream); - } -} - -/* This routine takes a line of TEXT and a CLIST in which to - start the lookup. When it returns it will have incremented the text - pointer past the section of text it matched, set *RESULT_LIST to - the list in which the last word was matched, and will return the - cmd list element which the text matches. It will return 0 if no - match at all was possible. It will return -1 if ambigous matches are - possible; in this case *RESULT_LIST will be set to the list in which - there are ambiguous choices (and text will be set to the ambiguous - text string). - - It does no error reporting whatsoever; control will always return - to the superior routine. - - In the case of an ambiguous return (-1), *RESULT_LIST will be set to - point at the prefix_command (ie. the best match) *or* (special - case) will be 0 if no prefix command was ever found. For example, - in the case of "info a", "info" matches without ambiguity, but "a" - could be "args" or "address", so *RESULT_LIST is set to - the cmd_list_element for "info". So in this case - result list should not be interpeted as a pointer to the beginning - of a list; it simply points to a specific command. - - This routine does *not* modify the text pointed to by TEXT. - - If INGNORE_HELP_CLASSES is nonzero, ignore any command list - elements which are actually help classes rather than commands (i.e. - the function field of the struct cmd_list_element is 0). */ - -struct cmd_list_element * -lookup_cmd_1 (text, clist, result_list, ignore_help_classes) - char **text; - struct cmd_list_element *clist, **result_list; - int ignore_help_classes; -{ - char *p, *command; - int len, tmp, nfound; - struct cmd_list_element *found, *c; - - while (**text == ' ' || **text == '\t') - (*text)++; - - /* Treating underscores as part of command words is important - so that "set args_foo()" doesn't get interpreted as - "set args _foo()". */ - for (p = *text; - *p && (isalnum(*p) || *p == '-' || *p == '_'); - p++) - ; - - /* If nothing but whitespace, return 0. */ - if (p == *text) - return 0; - - len = p - *text; - - /* *text and p now bracket the first command word to lookup (and - it's length is len). We copy this into a local temporary, - converting to lower case as we go. */ - - command = (char *) alloca (len + 1); - for (tmp = 0; tmp < len; tmp++) - { - char x = (*text)[tmp]; - command[tmp] = (x >= 'A' && x <= 'Z') ? x - 'A' + 'a' : x; - } - command[len] = '\0'; - - /* Look it up. */ - found = 0; - nfound = 0; - for (c = clist; c; c = c->next) - if (!strncmp (command, c->name, len) - && (!ignore_help_classes || c->function)) - { - found = c; - nfound++; - if (c->name[len] == '\0') - { - nfound = 1; - break; - } - } - - /* If nothing matches, we have a simple failure. */ - if (nfound == 0) - return 0; - - if (nfound > 1) - { - *result_list = 0; /* Will be modified in calling routine - if we know what the prefix command is. - */ - return (struct cmd_list_element *) -1; /* Ambiguous. */ - } - - /* We've matched something on this list. Move text pointer forward. */ - - *text = p; - if (found->prefixlist) - { - c = lookup_cmd_1 (text, *found->prefixlist, result_list, - ignore_help_classes); - if (!c) - { - /* Didn't find anything; this is as far as we got. */ - *result_list = clist; - return found; - } - else if (c == (struct cmd_list_element *) -1) - { - /* We've gotten this far properley, but the next step - is ambiguous. We need to set the result list to the best - we've found (if an inferior hasn't already set it). */ - if (!*result_list) - /* This used to say *result_list = *found->prefixlist - If that was correct, need to modify the documentation - at the top of this function to clarify what is supposed - to be going on. */ - *result_list = found; - return c; - } - else - { - /* We matched! */ - return c; - } - } - else - { - *result_list = clist; - return found; - } -} - -/* Look up the contents of *LINE as a command in the command list LIST. - LIST is a chain of struct cmd_list_element's. - If it is found, return the struct cmd_list_element for that command - and update *LINE to point after the command name, at the first argument. - If not found, call error if ALLOW_UNKNOWN is zero - otherwise (or if error returns) return zero. - Call error if specified command is ambiguous, - unless ALLOW_UNKNOWN is negative. - CMDTYPE precedes the word "command" in the error message. - - If INGNORE_HELP_CLASSES is nonzero, ignore any command list - elements which are actually help classes rather than commands (i.e. - the function field of the struct cmd_list_element is 0). */ - -struct cmd_list_element * -lookup_cmd (line, list, cmdtype, allow_unknown, ignore_help_classes) - char **line; - struct cmd_list_element *list; - char *cmdtype; - int allow_unknown; - int ignore_help_classes; -{ - struct cmd_list_element *last_list = 0; - struct cmd_list_element *c = - lookup_cmd_1 (line, list, &last_list, ignore_help_classes); - char *ptr = (*line) + strlen (*line) - 1; - - /* Clear off trailing whitespace. */ - while (ptr >= *line && (*ptr == ' ' || *ptr == '\t')) - ptr--; - *(ptr + 1) = '\0'; - - if (!c) - { - if (!allow_unknown) - { - if (!*line) - error ("Lack of needed %scommand", cmdtype); - else - { - char *p = *line, *q; - - while (isalnum(*p) || *p == '-') - p++; - - q = (char *) alloca (p - *line + 1); - strncpy (q, *line, p - *line); - q[p-*line] = '\0'; - - error ("Undefined %scommand: \"%s\".", cmdtype, q); - } - } - else - return 0; - } - else if (c == (struct cmd_list_element *) -1) - { - /* Ambigous. Local values should be off prefixlist or called - values. */ - int local_allow_unknown = (last_list ? last_list->allow_unknown : - allow_unknown); - char *local_cmdtype = last_list ? last_list->prefixname : cmdtype; - struct cmd_list_element *local_list = - (last_list ? *(last_list->prefixlist) : list); - - if (local_allow_unknown < 0) - { - if (last_list) - return last_list; /* Found something. */ - else - return 0; /* Found nothing. */ - } - else - { - /* Report as error. */ - int amb_len; - char ambbuf[100]; - - for (amb_len = 0; - ((*line)[amb_len] && (*line)[amb_len] != ' ' - && (*line)[amb_len] != '\t'); - amb_len++) - ; - - ambbuf[0] = 0; - for (c = local_list; c; c = c->next) - if (!strncmp (*line, c->name, amb_len)) - { - if (strlen (ambbuf) + strlen (c->name) + 6 < sizeof ambbuf) - { - if (strlen (ambbuf)) - strcat (ambbuf, ", "); - strcat (ambbuf, c->name); - } - else - { - strcat (ambbuf, ".."); - break; - } - } - error ("Ambiguous %scommand \"%s\": %s.", local_cmdtype, - *line, ambbuf); - } - } - else - { - /* We've got something. It may still not be what the caller - wants (if this command *needs* a subcommand). */ - while (**line == ' ' || **line == '\t') - (*line)++; - - if (c->prefixlist && **line && !c->allow_unknown) - error ("Undefined %scommand: \"%s\".", c->prefixname, *line); - - /* Seems to be what he wants. Return it. */ - return c; - } -} - -#if 0 -/* Look up the contents of *LINE as a command in the command list LIST. - LIST is a chain of struct cmd_list_element's. - If it is found, return the struct cmd_list_element for that command - and update *LINE to point after the command name, at the first argument. - If not found, call error if ALLOW_UNKNOWN is zero - otherwise (or if error returns) return zero. - Call error if specified command is ambiguous, - unless ALLOW_UNKNOWN is negative. - CMDTYPE precedes the word "command" in the error message. */ - -struct cmd_list_element * -lookup_cmd (line, list, cmdtype, allow_unknown) - char **line; - struct cmd_list_element *list; - char *cmdtype; - int allow_unknown; -{ - register char *p; - register struct cmd_list_element *c, *found; - int nfound; - char ambbuf[100]; - char *processed_cmd; - int i, cmd_len; - - /* Skip leading whitespace. */ - - while (**line == ' ' || **line == '\t') - (*line)++; - - /* Clear out trailing whitespace. */ - - p = *line + strlen (*line); - while (p != *line && (p[-1] == ' ' || p[-1] == '\t')) - p--; - *p = 0; - - /* Find end of command name. */ - - p = *line; - while (*p == '-' - || (*p >= 'a' && *p <= 'z') - || (*p >= 'A' && *p <= 'Z') - || (*p >= '0' && *p <= '9')) - p++; - - /* Look up the command name. - If exact match, keep that. - Otherwise, take command abbreviated, if unique. Note that (in my - opinion) a null string does *not* indicate ambiguity; simply the - end of the argument. */ - - if (p == *line) - { - if (!allow_unknown) - error ("Lack of needed %scommand", cmdtype); - return 0; - } - - /* Copy over to a local buffer, converting to lowercase on the way. - This is in case the command being parsed is a subcommand which - doesn't match anything, and that's ok. We want the original - untouched for the routine of the original command. */ - - processed_cmd = (char *) alloca (p - *line + 1); - for (cmd_len = 0; cmd_len < p - *line; cmd_len++) - { - char x = (*line)[cmd_len]; - if (x >= 'A' && x <= 'Z') - processed_cmd[cmd_len] = x - 'A' + 'a'; - else - processed_cmd[cmd_len] = x; - } - processed_cmd[cmd_len] = '\0'; - - /* Check all possibilities in the current command list. */ - found = 0; - nfound = 0; - for (c = list; c; c = c->next) - { - if (!strncmp (processed_cmd, c->name, cmd_len)) - { - found = c; - nfound++; - if (c->name[cmd_len] == 0) - { - nfound = 1; - break; - } - } - } - - /* Report error for undefined command name. */ - - if (nfound != 1) - { - if (nfound > 1 && allow_unknown >= 0) - { - ambbuf[0] = 0; - for (c = list; c; c = c->next) - if (!strncmp (processed_cmd, c->name, cmd_len)) - { - if (strlen (ambbuf) + strlen (c->name) + 6 < sizeof ambbuf) - { - if (strlen (ambbuf)) - strcat (ambbuf, ", "); - strcat (ambbuf, c->name); - } - else - { - strcat (ambbuf, ".."); - break; - } - } - error ("Ambiguous %scommand \"%s\": %s.", cmdtype, - processed_cmd, ambbuf); - } - else if (!allow_unknown) - error ("Undefined %scommand: \"%s\".", cmdtype, processed_cmd); - return 0; - } - - /* Skip whitespace before the argument. */ - - while (*p == ' ' || *p == '\t') p++; - *line = p; - - if (found->prefixlist && *p) - { - c = lookup_cmd (line, *found->prefixlist, found->prefixname, - found->allow_unknown); - if (c) - return c; - } - - return found; -} -#endif - -/* Helper function for SYMBOL_COMPLETION_FUNCTION. */ - -/* Return a vector of char pointers which point to the different - possible completions in LIST of TEXT. */ - -char ** -complete_on_cmdlist (list, text) - struct cmd_list_element *list; - char *text; -{ - struct cmd_list_element *ptr; - char **matchlist; - int sizeof_matchlist; - int matches; - int textlen = strlen (text); - - sizeof_matchlist = 10; - matchlist = (char **) xmalloc (sizeof_matchlist * sizeof (char *)); - matches = 0; - - for (ptr = list; ptr; ptr = ptr->next) - if (!strncmp (ptr->name, text, textlen) - && !ptr->abbrev_flag - && (ptr->function - || ptr->prefixlist)) - { - if (matches == sizeof_matchlist) - { - sizeof_matchlist *= 2; - matchlist = (char **) xrealloc (matchlist, - (sizeof_matchlist - * sizeof (char *))); - } - - matchlist[matches] = (char *) - xmalloc (strlen (ptr->name) + 1); - strcpy (matchlist[matches++], ptr->name); - } - - if (matches == 0) - { - free (matchlist); - matchlist = 0; - } - else - { - matchlist = (char **) xrealloc (matchlist, ((matches + 1) - * sizeof (char *))); - matchlist[matches] = (char *) 0; - } - - return matchlist; -} - -static void -shell_escape (arg, from_tty) - char *arg; - int from_tty; -{ - int rc, status, pid; - char *p, *user_shell; - extern char *rindex (); - - if ((user_shell = (char *) getenv ("SHELL")) == NULL) - user_shell = "/bin/sh"; - - /* Get the name of the shell for arg0 */ - if ((p = rindex (user_shell, '/')) == NULL) - p = user_shell; - else - p++; /* Get past '/' */ - - if ((pid = fork()) == 0) - { - if (!arg) - execl (user_shell, p, 0); - else - execl (user_shell, p, "-c", arg, 0); - - fprintf (stderr, "Exec of shell failed\n"); - exit (0); - } - - if (pid != -1) - while ((rc = wait (&status)) != pid && rc != -1) - ; - else - error ("Fork failed"); -} - -void -_initialize_command () -{ - add_com ("shell", class_support, shell_escape, - "Execute the rest of the line as a shell command. \n\ -With no arguments, run an inferior shell."); -} diff --git a/gnu/usr.bin/gdb/command.h b/gnu/usr.bin/gdb/command.h deleted file mode 100644 index 54b557e679ae..000000000000 --- a/gnu/usr.bin/gdb/command.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Header file for command-reading library command.c. - Copyright (C) 1986, 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 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. - - $Id: command.h,v 1.2 1993/08/02 17:40:54 mycroft Exp $ -*/ - -/* This structure records one command'd definition. */ - -struct cmd_list_element - { - /* Points to next command in this list. */ - struct cmd_list_element *next; - - /* Name of this command. */ - char *name; - - /* Command class; class values are chosen by application program. */ - int class; - - /* Function definition of this command. - Zero for command class names and for help topics that - are not really commands. */ - void (*function) (); - - /* Documentation of this command (or help topic). - First line is brief documentation; remaining lines form, with it, - the full documentation. First line should end with a period. - Entire string should also end with a period, not a newline. */ - char *doc; - - /* Auxiliary information. - It is up to the calling program to decide what this means. */ - char *aux; - - /* Nonzero identifies a prefix command. For them, the address - of the variable containing the list of subcommands. */ - struct cmd_list_element **prefixlist; - - /* For prefix commands only: - String containing prefix commands to get here: this one - plus any others needed to get to it. Should end in a space. - It is used before the word "command" in describing the - commands reached through this prefix. */ - char *prefixname; - - /* For prefix commands only: - nonzero means do not get an error if subcommand is not - recognized; call the prefix's own function in that case. */ - char allow_unknown; - - /* Nonzero says this is an abbreviation, and should not - be mentioned in lists of commands. - This allows "br" to complete to "break", which it - otherwise wouldn't. */ - char abbrev_flag; - }; - -/* Forward-declarations of the entry-points of command.c. */ - -extern struct cmd_list_element *add_cmd (); -extern struct cmd_list_element *add_alias_cmd (); -extern struct cmd_list_element *add_prefix_cmd (); -extern struct cmd_list_element *lookup_cmd (), *lookup_cmd_1 (); -extern char **complete_on_cmdlist (); -extern void delete_cmd (); -extern void help_cmd (); diff --git a/gnu/usr.bin/gdb/config/altos-dep.c b/gnu/usr.bin/gdb/config/altos-dep.c deleted file mode 100644 index afb916015474..000000000000 --- a/gnu/usr.bin/gdb/config/altos-dep.c +++ /dev/null @@ -1,589 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under m68k SVR2 Unix - on Altos 3068. Report bugs to Jyrki Kuoppala - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: altos-dep.c,v 1.2 1993/08/02 17:39:38 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -#include -#ifdef USG -#include -#ifdef ALTOS -#include -#include -#endif -#endif - -#ifdef COFF_ENCAPSULATE -#include "a.out.encap.h" -#else -#include -#endif -#ifndef N_SET_MAGIC -#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val)) -#endif - -#include /* After a.out.h */ -#include -#include - -extern int errno; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -void -fetch_inferior_registers () -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - struct user u; - unsigned int offset = (char *) &u.u_state - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - struct user u; - unsigned int offset = (char *) &u.u_state - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - if (regno >= 0) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - else for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing all regs, number %d", regno); - perror_with_name (buf); - } - } -} - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - buffer[0] = remote_fetch_word (addr); - else - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - if (remote_debugging) - buffer[count - 1] - = remote_fetch_word (addr + (count - 1) * sizeof (int)); - else - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - remote_store_word (addr, buffer[i]); - else - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - - unsigned int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name ("Not a core file: reading upage"); - if (val != sizeof u) - error ("Not a core file: could only read %d bytes", val); - data_start = exec_data_start; - -#define NBPG NBPP -#define UPAGES USIZE - - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES + exec_data_start % NBPG /* Not sure about this //jkp */; - stack_offset = NBPG * (UPAGES + u.u_dsize); - - /* Some machines put an absolute address in here and some put - the offset in the upage of the regs. */ - reg_offset = (int) u.u_state; - if (reg_offset > NBPG * UPAGES) - reg_offset -= KERNEL_U_ADDR; - - bcopy (&u.u_exdata, &core_aouthdr, sizeof (AOUTHDR)); - printf ("Core file is from \"%s\".\n", u.u_comm); - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - N_SET_MAGIC (core_aouthdr, 0); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0 - || (val = myread (corechan, buf, sizeof buf)) < 0) - { - char * buffer = (char *) alloca (strlen (reg_names[regno]) - + 30); - strcpy (buffer, "Reading register "); - strcat (buffer, reg_names[regno]); - - perror_with_name (buffer); - } - - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - -#ifdef HEADER_SEEK_FD - HEADER_SEEK_FD (execchan); -#endif - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_TXTADDR (exec_aouthdr); - exec_data_start = N_DATADDR (exec_aouthdr); - - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - diff --git a/gnu/usr.bin/gdb/config/convex-dep.c b/gnu/usr.bin/gdb/config/convex-dep.c deleted file mode 100644 index 47ab583d6c0a..000000000000 --- a/gnu/usr.bin/gdb/config/convex-dep.c +++ /dev/null @@ -1,1952 +0,0 @@ -/* Convex stuff for GDB. - Copyright (C) 1990 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: convex-dep.c,v 1.2 1993/08/02 17:39:40 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "param.h" -#include "command.h" -#include "symtab.h" -#include "value.h" -#include "frame.h" -#include "inferior.h" -#include "wait.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -/* Per-thread data, read from the inferior at each stop and written - back at each resume. */ - -/* Number of active threads. - Tables are valid for thread numbers less than this. */ - -static int n_threads; - -#define MAXTHREADS 8 - -/* Thread state. The remaining data is valid only if this is PI_TALIVE. */ - -static int thread_state[MAXTHREADS]; - -/* Stop pc, signal, signal subcode */ - -static int thread_pc[MAXTHREADS]; -static int thread_signal[MAXTHREADS]; -static int thread_sigcode[MAXTHREADS]; - -/* Thread registers. - If thread is selected, the regs are in registers[] instead. */ - -static char thread_regs[MAXTHREADS][REGISTER_BYTES]; - -/* 1 if the top frame on the thread's stack was a context frame, - meaning that the kernel is up to something and we should not - touch the thread at all except to resume it. */ - -static char thread_is_in_kernel[MAXTHREADS]; - -/* The currently selected thread's number. */ - -static int inferior_thread; - -/* Inferior process's file handle and a process control block - to feed args to ioctl with. */ - -static int inferior_fd; -static struct pcntl ps; - -/* SOFF file headers for exec or core file. */ - -static FILEHDR filehdr; -static OPTHDR opthdr; -static SCNHDR scnhdr; - -/* Address maps constructed from section headers of exec and core files. - Defines process address -> file address translation. */ - -struct pmap -{ - long mem_addr; /* process start address */ - long mem_end; /* process end+1 address */ - long file_addr; /* file start address */ - long thread; /* -1 shared; 0,1,... thread-local */ - long type; /* S_TEXT S_DATA S_BSS S_TBSS etc */ - long which; /* used to sort map for info files */ -}; - -static int n_exec, n_core; -static struct pmap exec_map[100]; -static struct pmap core_map[100]; - -/* Offsets in the core file of core_context and core_tcontext blocks. */ - -static int context_offset; -static int tcontext_offset[MAXTHREADS]; - -/* Core file control blocks. */ - -static struct core_context_v70 c; -static struct core_tcontext_v70 tc; -static struct user u; -static thread_t th; -static proc_t pr; - -/* The registers of the currently selected thread. */ - -extern char registers[REGISTER_BYTES]; - -/* Vector and communication registers from core dump or from inferior. - These are read on demand, ie, not normally valid. */ - -static struct vecst vector_registers; -static struct creg_ctx comm_registers; - -/* Flag, set on a vanilla CONT command and cleared when the inferior - is continued. */ - -static int all_continue; - -/* Flag, set when the inferior is continued by a vanilla CONT command, - cleared if it is continued for any other purpose. */ - -static int thread_switch_ok; - -/* Stack of signals recieved from threads but not yet delivered to gdb. */ - -struct threadpid -{ - int pid; - int thread; - int signo; - int subsig; - int pc; -}; - -static struct threadpid signal_stack_bot[100]; -static struct threadpid *signal_stack = signal_stack_bot; - -/* How to detect empty stack -- bottom frame is all zero. */ - -#define signal_stack_is_empty() (signal_stack->pid == 0) - -/* Mode controlled by SET PIPE command, controls the psw SEQ bit - which forces each instruction to complete before the next one starts. */ - -static int sequential = 0; - -/* Mode controlled by the SET PARALLEL command. Values are: - 0 concurrency limit 1 thread, dynamic scheduling - 1 no concurrency limit, dynamic scheduling - 2 no concurrency limit, fixed scheduling */ - -static int parallel = 1; - -/* Mode controlled by SET BASE command, output radix for unformatted - integer typeout, as in argument lists, aggregates, and so on. - Zero means guess whether it's an address (hex) or not (decimal). */ - -static int output_radix = 0; - -/* Signal subcode at last thread stop. */ - -static int stop_sigcode; - -/* Hack, see wait() below. */ - -static int exec_trap_timer; - -/* Chain containing all defined commands. */ - -extern struct cmd_list_element *cmdlist; - -/* Chain containing all defined set subcommands */ - -extern struct cmd_list_element *setlist; - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. - NB: These variables are set to plausible but useless values on convex. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - NB: Only text_start and text_end have meaningful values on convex. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -/* a.out header saved in core file. */ - -extern struct exec core_aouthdr; - -/* a.out header of exec file. */ - -extern struct exec exec_aouthdr; - -/* Routine to check for exec-core mismatch. */ - -extern void validate_files (); - -/* Nonzero if we are debugging an attached outside process - rather than an inferior. */ - -extern int attach_flag; - - - -static struct type *vector_type (); -static long *read_vector_register (); -static long *read_vector_register_1 (); -static void write_vector_register (); -static REGISTER_TYPE read_comm_register (); -static void write_comm_register (); -static void convex_cont_command (); -static void thread_continue (); -static void select_thread (); -static void scan_stack (); -static void set_fixed_scheduling (); -static char *subsig_name (); -static void psw_info (); -static sig_noop (); -static ptr_cmp (); - -extern char *sys_siglist[]; -extern int errno; - -/* Execute ptrace. Convex V7 replaced ptrace with pattach. - Allow ptrace (0) as a no-op. */ - -int -call_ptrace (request, pid, procaddr, buf) - int request, pid, procaddr, buf; -{ - if (request == 0) - return; - error ("no ptrace"); -} - -/* Replacement for system execle routine. - Convert it to an equivalent exect, which pattach insists on. */ - -execle (name, argv) - char *name, *argv; -{ - char ***envp = (char ***) &argv; - while (*envp++) ; - - signal (SIGTRAP, sig_noop); - exect (name, &argv, *envp); -} - -/* Stupid handler for stupid trace trap that otherwise causes - startup to stupidly hang. */ - -static sig_noop () -{} - -/* Read registers from inferior into registers[] array. - For convex, they are already there, read in when the inferior stops. */ - -void -fetch_inferior_registers () -{ -} - -/* Store our register values back into the inferior. - For Convex, do this only once, right before resuming inferior. */ - -store_inferior_registers (regno) - int regno; -{ -} - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - errno = 0; - while (len > 0) - { - /* little-known undocumented max request size */ - int i = (len < 12288) ? len : 12288; - - lseek (inferior_fd, memaddr, 0); - read (inferior_fd, myaddr, i); - - memaddr += i; - myaddr += i; - len -= i; - } - if (errno) - bzero (myaddr, len); - return errno; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - Returns errno on failure (cannot write the inferior) */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - errno = 0; - lseek (inferior_fd, memaddr, 0); - write (inferior_fd, myaddr, len); - return errno; -} - -/* Here from create_inferior when the inferior process has been created - and started up. We must do a pattach to grab it for debugging. - - Also, intercept the CONT command by altering its dispatch address. */ - -create_inferior_hook (pid) - int pid; -{ - static char cont[] = "cont"; - static char cont1[] = "c"; - char *linep = cont; - char *linep1 = cont1; - char **line = &linep; - char **line1 = &linep1; - struct cmd_list_element *c; - - c = lookup_cmd (line, cmdlist, "", 0); - c->function = convex_cont_command; - c = lookup_cmd (line1, cmdlist, "", 0); - c->function = convex_cont_command; - - inferior_fd = pattach (pid, O_EXCL); - if (inferior_fd < 0) - perror_with_name ("pattach"); - inferior_thread = 0; - set_fixed_scheduling (pid, parallel == 2); -} - -/* Attach process PID for debugging. */ - -attach (pid) - int pid; -{ - int fd = pattach (pid, O_EXCL); - if (fd < 0) - perror_with_name ("pattach"); - attach_flag = 1; - /* wait for strange kernel reverberations to go away */ - sleep (1); - - setpgrp (pid, pid); - - inferior_fd = fd; - inferior_thread = 0; - return pid; -} - -/* Stop debugging the process whose number is PID - and continue it with signal number SIGNAL. - SIGNAL = 0 means just continue it. */ - -void -detach (signal) - int signal; -{ - signal_stack = signal_stack_bot; - thread_continue (-1, 0, signal); - ioctl (inferior_fd, PIXDETACH, &ps); - close (inferior_fd); - inferior_fd = 0; - attach_flag = 0; -} - -/* Kill off the inferior process. */ - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ioctl (inferior_fd, PIXTERMINATE, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ioctl (inferior_fd, PIXTERMINATE, 0); - wait (0); -} - -/* Read vector register REG, and return a pointer to the value. */ - -static long * -read_vector_register (reg) - int reg; -{ - if (have_inferior_p ()) - { - errno = 0; - ps.pi_buffer = (char *) &vector_registers; - ps.pi_nbytes = sizeof vector_registers; - ps.pi_offset = 0; - ps.pi_thread = inferior_thread; - ioctl (inferior_fd, PIXRDVREGS, &ps); - if (errno) - bzero (&vector_registers, sizeof vector_registers); - } - else if (corechan >= 0) - { - lseek (corechan, tcontext_offset[inferior_thread], 0); - if (myread (corechan, &tc, sizeof tc) < 0) - perror_with_name (corefile); - lseek (corechan, tc.core_thread_p, 0); - if (myread (corechan, &th, sizeof th) < 0) - perror_with_name (corefile); - lseek (corechan, tc.core_vregs_p, 0); - if (myread (corechan, &vector_registers, 16*128) < 0) - perror_with_name (corefile); - vector_registers.vm[0] = th.t_vect_ctx.vc_vm[0]; - vector_registers.vm[1] = th.t_vect_ctx.vc_vm[1]; - vector_registers.vls = th.t_vect_ctx.vc_vls; - } - - return read_vector_register_1 (reg); -} - -/* Return a pointer to vector register REG, which must already have been - fetched from the inferior or core file. */ - -static long * -read_vector_register_1 (reg) - int reg; -{ - switch (reg) - { - case VM_REGNUM: - return (long *) vector_registers.vm; - case VS_REGNUM: - return (long *) &vector_registers.vls; - case VL_REGNUM: - return 1 + (long *) &vector_registers.vls; - default: - return (long *) &vector_registers.vr[reg]; - } -} - -/* Write vector register REG, element ELEMENT, new value VAL. - NB: must use read-modify-write on the entire vector state, - since pattach does not do offsetted writes correctly. */ - -static void -write_vector_register (reg, element, val) - int reg, element; - REGISTER_TYPE val; -{ - if (have_inferior_p ()) - { - errno = 0; - ps.pi_thread = inferior_thread; - ps.pi_offset = 0; - ps.pi_buffer = (char *) &vector_registers; - ps.pi_nbytes = sizeof vector_registers; - - ioctl (inferior_fd, PIXRDVREGS, &ps); - - switch (reg) - { - case VL_REGNUM: - vector_registers.vls = - (vector_registers.vls & 0xffffffff00000000LL) - + (unsigned long) val; - break; - - case VS_REGNUM: - vector_registers.vls = - (val << 32) + (unsigned long) vector_registers.vls; - break; - - default: - vector_registers.vr[reg].el[element] = val; - break; - } - - ioctl (inferior_fd, PIXWRVREGS, &ps); - - if (errno) - perror_with_name ("writing vector register"); - } -} - -/* Return the contents of communication register NUM. */ - -static REGISTER_TYPE -read_comm_register (num) - int num; -{ - if (have_inferior_p ()) - { - ps.pi_buffer = (char *) &comm_registers; - ps.pi_nbytes = sizeof comm_registers; - ps.pi_offset = 0; - ps.pi_thread = inferior_thread; - ioctl (inferior_fd, PIXRDCREGS, &ps); - } - return comm_registers.crreg.r4[num]; -} - -/* Store a new value VAL into communication register NUM. - NB: Must use read-modify-write on the whole comm register set - since pattach does not do offsetted writes correctly. */ - -static void -write_comm_register (num, val) - int num; - REGISTER_TYPE val; -{ - if (have_inferior_p ()) - { - ps.pi_buffer = (char *) &comm_registers; - ps.pi_nbytes = sizeof comm_registers; - ps.pi_offset = 0; - ps.pi_thread = inferior_thread; - ioctl (inferior_fd, PIXRDCREGS, &ps); - comm_registers.crreg.r4[num] = val; - ioctl (inferior_fd, PIXWRCREGS, &ps); - } -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - if (step || signal) - thread_continue (inferior_thread, step, signal); - else - thread_continue (-1, 0, 0); -} - -/* Maybe resume some threads. - THREAD is which thread to resume, or -1 to resume them all. - STEP and SIGNAL are as in resume. - - Global variable ALL_CONTINUE is set when we are here to do a - `cont' command; otherwise we may be doing `finish' or a call or - something else that will not tolerate an automatic thread switch. - - If there are stopped threads waiting to deliver signals, and - ALL_CONTINUE, do not actually resume anything. gdb will do a wait - and see one of the stopped threads in the queue. */ - -static void -thread_continue (thread, step, signal) - int thread, step, signal; -{ - int n; - - /* If we are to continue all threads, but not for the CONTINUE command, - pay no attention and continue only the selected thread. */ - - if (thread < 0 && ! all_continue) - thread = inferior_thread; - - /* If we are not stepping, we have now executed the continue part - of a CONTINUE command. */ - - if (! step) - all_continue = 0; - - /* Allow wait() to switch threads if this is an all-out continue. */ - - thread_switch_ok = thread < 0; - - /* If there are threads queued up, don't resume. */ - - if (thread_switch_ok && ! signal_stack_is_empty ()) - return; - - /* OK, do it. */ - - for (n = 0; n < n_threads; n++) - if (thread_state[n] == PI_TALIVE) - { - select_thread (n); - - if ((thread < 0 || n == thread) && ! thread_is_in_kernel[n]) - { - /* Blam the trace bits in the stack's saved psws to match - the desired step mode. This is required so that - single-stepping a return doesn't restore a psw with a - clear trace bit and fly away, and conversely, - proceeding through a return in a routine that was - stepped into doesn't cause a phantom break by restoring - a psw with the trace bit set. */ - scan_stack (PSW_T_BIT, step); - scan_stack (PSW_S_BIT, sequential); - } - - ps.pi_buffer = registers; - ps.pi_nbytes = REGISTER_BYTES; - ps.pi_offset = 0; - ps.pi_thread = n; - if (! thread_is_in_kernel[n]) - if (ioctl (inferior_fd, PIXWRREGS, &ps)) - perror_with_name ("PIXWRREGS"); - - if (thread < 0 || n == thread) - { - ps.pi_pc = 1; - ps.pi_signo = signal; - if (ioctl (inferior_fd, step ? PIXSTEP : PIXCONTINUE, &ps) < 0) - perror_with_name ("PIXCONTINUE"); - } - } - - if (ioctl (inferior_fd, PIXRUN, &ps) < 0) - perror_with_name ("PIXRUN"); -} - -/* Replacement for system wait routine. - - The system wait returns with one or more threads stopped by - signals. Put stopped threads on a stack and return them one by - one, so that it appears that wait returns one thread at a time. - - Global variable THREAD_SWITCH_OK is set when gdb can tolerate wait - returning a new thread. If it is false, then only one thread is - running; we will do a real wait, the thread will do something, and - we will return that. */ - -pid_t -wait (w) - union wait *w; -{ - int pid; - - if (!w) - return wait3 (0, 0, 0); - - /* Do a real wait if we were told to, or if there are no queued threads. */ - - if (! thread_switch_ok || signal_stack_is_empty ()) - { - int thread; - - pid = wait3 (w, 0, 0); - - if (!WIFSTOPPED (*w) || pid != inferior_pid) - return pid; - - /* The inferior has done something and stopped. Read in all the - threads' registers, and queue up any signals that happened. */ - - if (ioctl (inferior_fd, PIXGETTHCOUNT, &ps) < 0) - perror_with_name ("PIXGETTHCOUNT"); - - n_threads = ps.pi_othdcnt; - for (thread = 0; thread < n_threads; thread++) - { - ps.pi_thread = thread; - if (ioctl (inferior_fd, PIXGETSUBCODE, &ps) < 0) - perror_with_name ("PIXGETSUBCODE"); - thread_state[thread] = ps.pi_otstate; - - if (ps.pi_otstate == PI_TALIVE) - { - select_thread (thread); - ps.pi_buffer = registers; - ps.pi_nbytes = REGISTER_BYTES; - ps.pi_offset = 0; - ps.pi_thread = thread; - if (ioctl (inferior_fd, PIXRDREGS, &ps) < 0) - perror_with_name ("PIXRDREGS"); - - thread_pc[thread] = read_pc (); - thread_signal[thread] = ps.pi_osigno; - thread_sigcode[thread] = ps.pi_osigcode; - - /* If the thread's stack has a context frame - on top, something fucked is going on. I do not - know what, but do I know this: the only thing you - can do with such a thread is continue it. */ - - thread_is_in_kernel[thread] = - ((read_register (PS_REGNUM) >> 25) & 3) == 0; - - /* Signals push an extended frame and then fault - with a ridiculous pc. Pop the frame. */ - - if (thread_pc[thread] > STACK_END_ADDR) - { - POP_FRAME; - if (is_break_pc (thread_pc[thread])) - thread_pc[thread] = read_pc () - 2; - else - thread_pc[thread] = read_pc (); - write_register (PC_REGNUM, thread_pc[thread]); - } - - if (ps.pi_osigno || ps.pi_osigcode) - { - signal_stack++; - signal_stack->pid = pid; - signal_stack->thread = thread; - signal_stack->signo = thread_signal[thread]; - signal_stack->subsig = thread_sigcode[thread]; - signal_stack->pc = thread_pc[thread]; - } - - /* The following hackery is caused by a unix 7.1 feature: - the inferior's fixed scheduling mode is cleared when - it execs the shell (since the shell is not a parallel - program). So, note the 5.4 trap we get when - the shell does its exec, then catch the 5.0 trap - that occurs when the debuggee starts, and set fixed - scheduling mode properly. */ - - if (ps.pi_osigno == 5 && ps.pi_osigcode == 4) - exec_trap_timer = 1; - else - exec_trap_timer--; - - if (ps.pi_osigno == 5 && exec_trap_timer == 0) - set_fixed_scheduling (pid, parallel == 2); - } - } - - if (signal_stack_is_empty ()) - error ("no active threads?!"); - } - - /* Select the thread that stopped, and return *w saying why. */ - - select_thread (signal_stack->thread); - - stop_signal = signal_stack->signo; - stop_sigcode = signal_stack->subsig; - - WSETSTOP (*w, signal_stack->signo); - w->w_thread = signal_stack->thread; - return (signal_stack--)->pid; -} - -/* Select thread THREAD -- its registers, stack, per-thread memory. - This is the only routine that may assign to inferior_thread - or thread_regs[]. */ - -static void -select_thread (thread) - int thread; -{ - if (thread == inferior_thread) - return; - - bcopy (registers, thread_regs[inferior_thread], REGISTER_BYTES); - ps.pi_thread = inferior_thread = thread; - if (have_inferior_p ()) - ioctl (inferior_fd, PISETRWTID, &ps); - bcopy (thread_regs[thread], registers, REGISTER_BYTES); -} - -/* Routine to set or clear a psw bit in the psw and also all psws - saved on the stack. Quits when we get to a frame in which the - saved psw is correct. */ - -static void -scan_stack (bit, val) - long bit, val; -{ - long ps = read_register (PS_REGNUM); - long fp; - if (val ? !(ps & bit) : (ps & bit)) - { - ps ^= bit; - write_register (PS_REGNUM, ps); - - fp = read_register (FP_REGNUM); - while (fp & 0x80000000) - { - ps = read_memory_integer (fp + 4, 4); - if (val ? (ps & bit) : !(ps & bit)) - break; - ps ^= bit; - write_memory (fp + 4, &ps, 4); - fp = read_memory_integer (fp + 8, 4); - } - } -} - -/* Set fixed scheduling (alliant mode) of process PID to ARG (0 or 1). */ - -static void -set_fixed_scheduling (pid, arg) - int arg; -{ - struct pattributes pattr; - getpattr (pid, &pattr); - pattr.pattr_pfixed = arg; - setpattr (pid, &pattr); -} - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int n; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - n_core = 0; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - - if (myread (corechan, &filehdr, sizeof filehdr) < 0) - perror_with_name (filename); - - if (!IS_CORE_SOFF_MAGIC (filehdr.h_magic)) - error ("%s: not a core file.\n", filename); - - if (myread (corechan, &opthdr, filehdr.h_opthdr) < 0) - perror_with_name (filename); - - /* Read through the section headers. - For text, data, etc, record an entry in the core file map. - For context and tcontext, record the file address of - the context blocks. */ - - lseek (corechan, (long) filehdr.h_scnptr, 0); - - n_threads = 0; - for (n = 0; n < filehdr.h_nscns; n++) - { - if (myread (corechan, &scnhdr, sizeof scnhdr) < 0) - perror_with_name (filename); - if ((scnhdr.s_flags & S_TYPMASK) >= S_TEXT - && (scnhdr.s_flags & S_TYPMASK) <= S_COMON) - { - core_map[n_core].mem_addr = scnhdr.s_vaddr; - core_map[n_core].mem_end = scnhdr.s_vaddr + scnhdr.s_size; - core_map[n_core].file_addr = scnhdr.s_scnptr; - core_map[n_core].type = scnhdr.s_flags & S_TYPMASK; - if (core_map[n_core].type != S_TBSS - && core_map[n_core].type != S_TDATA - && core_map[n_core].type != S_TTEXT) - core_map[n_core].thread = -1; - else if (n_core == 0 - || core_map[n_core-1].mem_addr != scnhdr.s_vaddr) - core_map[n_core].thread = 0; - else - core_map[n_core].thread = core_map[n_core-1].thread + 1; - n_core++; - } - else if ((scnhdr.s_flags & S_TYPMASK) == S_CONTEXT) - context_offset = scnhdr.s_scnptr; - else if ((scnhdr.s_flags & S_TYPMASK) == S_TCONTEXT) - tcontext_offset[n_threads++] = scnhdr.s_scnptr; - } - - /* Read the context block, struct user, struct proc, - and the comm regs. */ - - lseek (corechan, context_offset, 0); - if (myread (corechan, &c, sizeof c) < 0) - perror_with_name (filename); - lseek (corechan, c.core_user_p, 0); - if (myread (corechan, &u, sizeof u) < 0) - perror_with_name (filename); - lseek (corechan, c.core_proc_p, 0); - if (myread (corechan, &pr, sizeof pr) < 0) - perror_with_name (filename); - comm_registers = pr.p_creg; - - /* Core file apparently is really there. Make it really exist - for xfer_core_file so we can do read_memory on it. */ - - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - corefile = concat (current_directory, "/", filename); - - printf_filtered ("Program %s ", u.u_comm); - - /* Read the thread registers and fill in the thread_xxx[] data. */ - - for (n = 0; n < n_threads; n++) - { - select_thread (n); - - lseek (corechan, tcontext_offset[n], 0); - if (myread (corechan, &tc, sizeof tc) < 0) - perror_with_name (corefile); - lseek (corechan, tc.core_thread_p, 0); - if (myread (corechan, &th, sizeof th) < 0) - perror_with_name (corefile); - - lseek (corechan, tc.core_syscall_context_p, 0); - if (myread (corechan, registers, REGISTER_BYTES) < 0) - perror_with_name (corefile); - - thread_signal[n] = th.t_cursig; - thread_sigcode[n] = th.t_code; - thread_state[n] = th.t_state; - thread_pc[n] = read_pc (); - - if (thread_pc[n] > STACK_END_ADDR) - { - POP_FRAME; - if (is_break_pc (thread_pc[n])) - thread_pc[n] = read_pc () - 2; - else - thread_pc[n] = read_pc (); - write_register (PC_REGNUM, thread_pc[n]); - } - - printf_filtered ("thread %d received signal %d, %s\n", - n, thread_signal[n], - thread_signal[n] < NSIG - ? sys_siglist[thread_signal[n]] - : "(undocumented)"); - } - - /* Select an interesting thread -- also-rans died with SIGKILL, - so find one that didn't. */ - - for (n = 0; n < n_threads; n++) - if (thread_signal[n] != 0 && thread_signal[n] != SIGKILL) - { - select_thread (n); - stop_signal = thread_signal[n]; - stop_sigcode = thread_sigcode[n]; - break; - } - - core_aouthdr.a_magic = 0; - - flush_cached_frames (); - set_current_frame (create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - - print_sel_frame (1); - } - else if (from_tty) - printf_filtered ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - int n; - struct stat st_exec; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end = 0; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - n_exec = 0; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - - if (myread (execchan, &filehdr, sizeof filehdr) < 0) - perror_with_name (filename); - - if (! IS_SOFF_MAGIC (filehdr.h_magic)) - error ("%s: not an executable file.", filename); - - if (myread (execchan, &opthdr, filehdr.h_opthdr) <= 0) - perror_with_name (filename); - - /* Read through the section headers. - For text, data, etc, record an entry in the exec file map. - Record text_start and text_end. */ - - lseek (execchan, (long) filehdr.h_scnptr, 0); - - for (n = 0; n < filehdr.h_nscns; n++) - { - if (myread (execchan, &scnhdr, sizeof scnhdr) < 0) - perror_with_name (filename); - - if ((scnhdr.s_flags & S_TYPMASK) >= S_TEXT - && (scnhdr.s_flags & S_TYPMASK) <= S_COMON) - { - exec_map[n_exec].mem_addr = scnhdr.s_vaddr; - exec_map[n_exec].mem_end = scnhdr.s_vaddr + scnhdr.s_size; - exec_map[n_exec].file_addr = scnhdr.s_scnptr; - exec_map[n_exec].type = scnhdr.s_flags & S_TYPMASK; - n_exec++; - - if ((scnhdr.s_flags & S_TYPMASK) == S_TEXT) - { - text_start = scnhdr.s_vaddr; - text_end = scnhdr.s_vaddr + scnhdr.s_size; - } - } - } - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - - validate_files (); - } - else if (from_tty) - printf_filtered ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -/* Read data from SOFF exec or core file. - Return 0 on success, 1 if address could not be read. */ - -int -xfer_core_file (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - register int n; - register int val; - int xferchan; - char **xferfile; - int fileptr; - int returnval = 0; - - while (len > 0) - { - xferfile = 0; - xferchan = 0; - - /* Determine which file the next bunch of addresses reside in, - and where in the file. Set the file's read/write pointer - to point at the proper place for the desired address - and set xferfile and xferchan for the correct file. - If desired address is nonexistent, leave them zero. - i is set to the number of bytes that can be handled - along with the next address. */ - - i = len; - - for (n = 0; n < n_core; n++) - { - if (memaddr >= core_map[n].mem_addr && memaddr < core_map[n].mem_end - && (core_map[n].thread == -1 - || core_map[n].thread == inferior_thread)) - { - i = min (len, core_map[n].mem_end - memaddr); - fileptr = core_map[n].file_addr + memaddr - core_map[n].mem_addr; - if (core_map[n].file_addr) - { - xferfile = &corefile; - xferchan = corechan; - } - break; - } - else if (core_map[n].mem_addr >= memaddr - && core_map[n].mem_addr < memaddr + i) - i = core_map[n].mem_addr - memaddr; - } - - if (!xferfile) - for (n = 0; n < n_exec; n++) - { - if (memaddr >= exec_map[n].mem_addr - && memaddr < exec_map[n].mem_end) - { - i = min (len, exec_map[n].mem_end - memaddr); - fileptr = exec_map[n].file_addr + memaddr - - exec_map[n].mem_addr; - if (exec_map[n].file_addr) - { - xferfile = &execfile; - xferchan = execchan; - } - break; - } - else if (exec_map[n].mem_addr >= memaddr - && exec_map[n].mem_addr < memaddr + i) - i = exec_map[n].mem_addr - memaddr; - } - - /* Now we know which file to use. - Set up its pointer and transfer the data. */ - if (xferfile) - { - if (*xferfile == 0) - if (xferfile == &execfile) - error ("No program file to examine."); - else - error ("No core dump file or running program to examine."); - val = lseek (xferchan, fileptr, 0); - if (val < 0) - perror_with_name (*xferfile); - val = myread (xferchan, myaddr, i); - if (val < 0) - perror_with_name (*xferfile); - } - /* If this address is for nonexistent memory, - read zeros if reading, or do nothing if writing. */ - else - { - bzero (myaddr, i); - returnval = 1; - } - - memaddr += i; - myaddr += i; - len -= i; - } - return returnval; -} - - -/* Here from info files command to print an address map. */ - -print_maps () -{ - struct pmap ptrs[200]; - int n; - - /* ID strings for core and executable file sections */ - - static char *idstr[] = - { - "0", "text", "data", "tdata", "bss", "tbss", - "common", "ttext", "ctx", "tctx", "10", "11", "12", - }; - - for (n = 0; n < n_core; n++) - { - core_map[n].which = 0; - ptrs[n] = core_map[n]; - } - for (n = 0; n < n_exec; n++) - { - exec_map[n].which = 1; - ptrs[n_core+n] = exec_map[n]; - } - - qsort (ptrs, n_core + n_exec, sizeof *ptrs, ptr_cmp); - - for (n = 0; n < n_core + n_exec; n++) - { - struct pmap *p = &ptrs[n]; - if (n > 0) - { - if (p->mem_addr < ptrs[n-1].mem_end) - p->mem_addr = ptrs[n-1].mem_end; - if (p->mem_addr >= p->mem_end) - continue; - } - printf_filtered ("%08x .. %08x %-6s %s\n", - p->mem_addr, p->mem_end, idstr[p->type], - p->which ? execfile : corefile); - } -} - -/* Compare routine to put file sections in order. - Sort into increasing order on address, and put core file sections - before exec file sections if both files contain the same addresses. */ - -static ptr_cmp (a, b) - struct pmap *a, *b; -{ - if (a->mem_addr != b->mem_addr) return a->mem_addr - b->mem_addr; - return a->which - b->which; -} - -/* Trapped internal variables are used to handle special registers. - A trapped i.v. calls a hook here every time it is dereferenced, - to provide a new value for the variable, and it calls a hook here - when a new value is assigned, to do something with the value. - - The vector registers are $vl, $vs, $vm, $vN, $VN (N in 0..7). - The communication registers are $cN, $CN (N in 0..63). - They not handled as regular registers because it's expensive to - read them, and their size varies, and they have too many names. */ - - -/* Return 1 if NAME is a trapped internal variable, else 0. */ - -int -is_trapped_internalvar (name) - char *name; -{ - if ((name[0] == 'c' || name[0] == 'C') - && name[1] >= '0' && name[1] <= '9' - && (name[2] == '\0' - || (name[2] >= '0' && name[2] <= '9' - && name[3] == '\0' && name[1] != '0')) - && atoi (&name[1]) < 64) return 1; - - if ((name[0] == 'v' || name[0] == 'V') - && (((name[1] & -8) == '0' && name[2] == '\0') - || !strcmp (name, "vl") - || !strcmp (name, "vs") - || !strcmp (name, "vm"))) - return 1; - else return 0; -} - -/* Return the value of trapped internal variable VAR */ - -value -value_of_trapped_internalvar (var) - struct internalvar *var; -{ - char *name = var->name; - value val; - struct type *type; - long len = *read_vector_register (VL_REGNUM); - if (len <= 0 || len > 128) len = 128; - - if (!strcmp (name, "vl")) - { - val = value_from_long (builtin_type_int, - (LONGEST) *read_vector_register_1 (VL_REGNUM)); - } - else if (!strcmp (name, "vs")) - { - val = value_from_long (builtin_type_int, - (LONGEST) *read_vector_register_1 (VS_REGNUM)); - } - else if (!strcmp (name, "vm")) - { - long vm[4]; - long i, *p; - bcopy (read_vector_register_1 (VM_REGNUM), vm, sizeof vm); - type = vector_type (builtin_type_int, len); - val = allocate_value (type); - p = (long *) VALUE_CONTENTS (val); - for (i = 0; i < len; i++) - *p++ = !! (vm[3 - (i >> 5)] & (1 << (i & 037))); - } - else if (name[0] == 'V') - { - type = vector_type (builtin_type_long_long, len); - val = allocate_value (type); - bcopy (read_vector_register_1 (name[1] - '0'), - VALUE_CONTENTS (val), TYPE_LENGTH (type)); - } - else if (name[0] == 'v') - { - long *p1, *p2; - type = vector_type (builtin_type_long, len); - val = allocate_value (type); - p1 = read_vector_register_1 (name[1] - '0'); - p2 = (long *) VALUE_CONTENTS (val); - while (--len >= 0) {p1++; *p2++ = *p1++;} - } - - else if (name[0] == 'c') - val = value_from_long (builtin_type_int, - read_comm_register (atoi (&name[1]))); - else if (name[0] == 'C') - val = value_from_long (builtin_type_long_long, - read_comm_register (atoi (&name[1]))); - - VALUE_LVAL (val) = lval_internalvar; - VALUE_INTERNALVAR (val) = var; - return val; -} - -/* Construct the type for a vector register's value -- - array[LENGTH] of ELEMENT_TYPE. */ - -static struct type * -vector_type (element_type, length) - struct type *element_type; - long length; -{ - struct type *type = (struct type *) xmalloc (sizeof (struct type)); - bzero (type, sizeof type); - TYPE_CODE (type) = TYPE_CODE_ARRAY; - TYPE_TARGET_TYPE (type) = element_type; - TYPE_LENGTH (type) = length * TYPE_LENGTH (TYPE_TARGET_TYPE (type)); - return type; -} - -/* Handle a new value assigned to a trapped internal variable */ - -void -set_trapped_internalvar (var, val, bitpos, bitsize, offset) - struct internalvar *var; - value val; - int bitpos, bitsize, offset; -{ - char *name = var->name; - long long newval = value_as_long (val); - - if (!strcmp (name, "vl")) - write_vector_register (VL_REGNUM, 0, newval); - else if (!strcmp (name, "vs")) - write_vector_register (VS_REGNUM, 0, newval); - else if (name[0] == 'c' || name[0] == 'C') - write_comm_register (atoi (&name[1]), newval); - else if (!strcmp (name, "vm")) - error ("can't assign to $vm"); - else - { - offset /= bitsize / 8; - write_vector_register (name[1] - '0', offset, newval); - } -} - -/* Print an integer value when no format was specified. gdb normally - prints these values in decimal, but the the leading 0x80000000 of - pointers produces intolerable 10-digit negative numbers. - If it looks like an address, print it in hex instead. */ - -decout (stream, type, val) - FILE *stream; - struct type *type; - LONGEST val; -{ - long lv = val; - - switch (output_radix) - { - case 0: - if ((lv == val || (unsigned) lv == val) - && ((lv & 0xf0000000) == 0x80000000 - || ((lv & 0xf0000000) == 0xf0000000 && lv < STACK_END_ADDR))) - { - fprintf_filtered (stream, "%#x", lv); - return; - } - - case 10: - fprintf_filtered (stream, TYPE_UNSIGNED (type) ? "%llu" : "%lld", val); - return; - - case 8: - if (TYPE_LENGTH (type) <= sizeof lv) - fprintf_filtered (stream, "%#o", lv); - else - fprintf_filtered (stream, "%#llo", val); - return; - - case 16: - if (TYPE_LENGTH (type) <= sizeof lv) - fprintf_filtered (stream, "%#x", lv); - else - fprintf_filtered (stream, "%#llx", val); - return; - } -} - -/* Change the default output radix to 10 or 16, or set it to 0 (heuristic). - This command is mostly obsolete now that the print command allows - formats to apply to aggregates, but is still handy occasionally. */ - -static void -set_base_command (arg) - char *arg; -{ - int new_radix; - - if (!arg) - output_radix = 0; - else - { - new_radix = atoi (arg); - if (new_radix != 10 && new_radix != 16 && new_radix != 8) - error ("base must be 8, 10 or 16, or null"); - else output_radix = new_radix; - } -} - -/* Turn pipelining on or off in the inferior. */ - -static void -set_pipelining_command (arg) - char *arg; -{ - if (!arg) - { - sequential = !sequential; - printf_filtered ("%s\n", sequential ? "off" : "on"); - } - else if (!strcmp (arg, "on")) - sequential = 0; - else if (!strcmp (arg, "off")) - sequential = 1; - else error ("valid args are `on', to allow instructions to overlap, or\n\ -`off', to prevent it and thereby pinpoint exceptions."); -} - -/* Enable, disable, or force parallel execution in the inferior. */ - -static void -set_parallel_command (arg) - char *arg; -{ - struct rlimit rl; - int prevparallel = parallel; - - if (!strncmp (arg, "fixed", strlen (arg))) - parallel = 2; - else if (!strcmp (arg, "on")) - parallel = 1; - else if (!strcmp (arg, "off")) - parallel = 0; - else error ("valid args are `on', to allow multiple threads, or\n\ -`fixed', to force multiple threads, or\n\ -`off', to run with one thread only."); - - if ((prevparallel == 0) != (parallel == 0) && inferior_pid) - printf_filtered ("will take effect at next run.\n"); - - getrlimit (RLIMIT_CONCUR, &rl); - rl.rlim_cur = parallel ? rl.rlim_max : 1; - setrlimit (RLIMIT_CONCUR, &rl); - - if (inferior_pid) - set_fixed_scheduling (inferior_pid, parallel == 2); -} - -/* Add a new name for an existing command. */ - -static void -alias_command (arg) - char *arg; -{ - static char *aliaserr = "usage is `alias NEW OLD', no args allowed"; - char *newname = arg; - struct cmd_list_element *new, *old; - - if (!arg) - error_no_arg ("newname oldname"); - - new = lookup_cmd (&arg, cmdlist, "", -1); - if (new && !strncmp (newname, new->name, strlen (new->name))) - { - newname = new->name; - if (!(*arg == '-' - || (*arg >= 'a' && *arg <= 'z') - || (*arg >= 'A' && *arg <= 'Z') - || (*arg >= '0' && *arg <= '9'))) - error (aliaserr); - } - else - { - arg = newname; - while (*arg == '-' - || (*arg >= 'a' && *arg <= 'z') - || (*arg >= 'A' && *arg <= 'Z') - || (*arg >= '0' && *arg <= '9')) - arg++; - if (*arg != ' ' && *arg != '\t') - error (aliaserr); - *arg = '\0'; - arg++; - } - - old = lookup_cmd (&arg, cmdlist, "", 0); - - if (*arg != '\0') - error (aliaserr); - - if (new && !strncmp (newname, new->name, strlen (new->name))) - { - char *tem; - if (new->class == (int) class_user || new->class == (int) class_alias) - tem = "Redefine command \"%s\"? "; - else - tem = "Really redefine built-in command \"%s\"? "; - if (!query (tem, new->name)) - error ("Command \"%s\" not redefined.", new->name); - } - - add_com (newname, class_alias, old->function, old->doc); -} - - - -/* Print the current thread number, and any threads with signals in the - queue. */ - -thread_info () -{ - struct threadpid *p; - - if (have_inferior_p ()) - { - ps.pi_buffer = (char *) &comm_registers; - ps.pi_nbytes = sizeof comm_registers; - ps.pi_offset = 0; - ps.pi_thread = inferior_thread; - ioctl (inferior_fd, PIXRDCREGS, &ps); - } - - printf_filtered ("Current thread %d stopped with signal %d.%d (%s).\n", - inferior_thread, stop_signal, stop_sigcode, - subsig_name (stop_signal, stop_sigcode)); - - for (p = signal_stack; p->pid; p--) - printf_filtered ("Thread %d stopped with signal %d.%d (%s).\n", - p->thread, p->signo, p->subsig, - subsig_name (p->signo, p->subsig)); - - if (iscrlbit (comm_registers.crctl.lbits.cc, 64+13)) - printf_filtered ("New thread start pc %#x\n", - (long) (comm_registers.crreg.pcpsw >> 32)); -} - -/* Return string describing a signal.subcode number */ - -static char * -subsig_name (signo, subcode) - int signo, subcode; -{ - static char *subsig4[] = { - "error exit", "privileged instruction", "unknown", - "unknown", "undefined opcode", - 0}; - static char *subsig5[] = {0, - "breakpoint", "single step", "fork trap", "exec trap", "pfork trap", - "join trap", "idle trap", "last thread", "wfork trap", - "process breakpoint", "trap instruction", - 0}; - static char *subsig8[] = {0, - "int overflow", "int divide check", "float overflow", - "float divide check", "float underflow", "reserved operand", - "sqrt error", "exp error", "ln error", "sin error", "cos error", - 0}; - static char *subsig10[] = {0, - "invalid inward ring address", "invalid outward ring call", - "invalid inward ring return", "invalid syscall gate", - "invalid rtn frame length", "invalid comm reg address", - "invalid trap gate", - 0}; - static char *subsig11[] = {0, - "read access denied", "write access denied", "execute access denied", - "segment descriptor fault", "page table fault", "data reference fault", - "i/o access denied", "levt pte invalid", - 0}; - - static char **subsig_list[] = - {0, 0, 0, 0, subsig4, subsig5, 0, 0, subsig8, 0, subsig10, subsig11, 0}; - - int i; - char *p = signo < NSIG ? sys_siglist[signo] : "unknown"; - - if (signo >= (sizeof subsig_list / sizeof *subsig_list) - || !subsig_list[signo]) - return p; - for (i = 1; subsig_list[signo][i]; i++) - if (i == subcode) - return subsig_list[signo][subcode]; - return p; -} - - -/* Print a compact display of thread status, essentially x/i $pc - for all active threads. */ - -static void -threadstat () -{ - int t; - - for (t = 0; t < n_threads; t++) - if (thread_state[t] == PI_TALIVE) - { - printf_filtered ("%d%c %08x%c %d.%d ", t, - (t == inferior_thread ? '*' : ' '), thread_pc[t], - (thread_is_in_kernel[t] ? '#' : ' '), - thread_signal[t], thread_sigcode[t]); - print_insn (thread_pc[t], stdout); - printf_filtered ("\n"); - } -} - -/* Change the current thread to ARG. */ - -set_thread_command (arg) - char *arg; -{ - int thread; - - if (!arg) - { - threadstat (); - return; - } - - thread = parse_and_eval_address (arg); - - if (thread < 0 || thread > n_threads || thread_state[thread] != PI_TALIVE) - error ("no such thread."); - - select_thread (thread); - - stop_pc = read_pc (); - flush_cached_frames (); - set_current_frame (create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - print_sel_frame (1); -} - -/* Here on CONT command; gdb's dispatch address is changed to come here. - Set global variable ALL_CONTINUE to tell resume() that it should - start up all threads, and that a thread switch will not blow gdb's - mind. */ - -static void -convex_cont_command (proc_count_exp, from_tty) - char *proc_count_exp; - int from_tty; -{ - all_continue = 1; - cont_command (proc_count_exp, from_tty); -} - -/* Here on 1CONT command. Resume only the current thread. */ - -one_cont_command (proc_count_exp, from_tty) - char *proc_count_exp; - int from_tty; -{ - cont_command (proc_count_exp, from_tty); -} - -/* Print the contents and lock bits of all communication registers, - or just register ARG if ARG is a communication register, - or the 3-word resource structure in memory at address ARG. */ - -comm_registers_info (arg) - char *arg; -{ - int i, regnum; - - if (arg) - { - if (sscanf (arg, "0x%x", ®num) == 1 - || sscanf (argc, "%d", ®num) == 1) - { - if (regnum > 0) - regnum &= ~0x8000; - } - else if (sscanf (arg, "$c%d", ®num) == 1) - ; - else if (sscanf (arg, "$C%d", ®num) == 1) - ; - else - regnum = parse_and_eval_address (arg); - - if (regnum >= 64) - error ("%s: invalid register name.", arg); - - /* if we got a (user) address, examine the resource struct there */ - - if (regnum < 0) - { - static int buf[3]; - read_memory (regnum, buf, sizeof buf); - printf_filtered ("%08x %08x%08x%s\n", regnum, buf[1], buf[2], - buf[0] & 0xff ? " locked" : ""); - return; - } - } - - ps.pi_buffer = (char *) &comm_registers; - ps.pi_nbytes = sizeof comm_registers; - ps.pi_offset = 0; - ps.pi_thread = inferior_thread; - ioctl (inferior_fd, PIXRDCREGS, &ps); - - for (i = 0; i < 64; i++) - if (!arg || i == regnum) - printf_filtered ("%2d 0x8%03x %016llx%s\n", i, i, - comm_registers.crreg.r4[i], - (iscrlbit (comm_registers.crctl.lbits.cc, i) - ? " locked" : "")); -} - -/* Print the psw */ - -static void -psw_info (arg) - char *arg; -{ - struct pswbit - { - int bit; - int pos; - char *text; - }; - - static struct pswbit pswbit[] = - { - { 0x80000000, -1, "A carry" }, - { 0x40000000, -1, "A integer overflow" }, - { 0x20000000, -1, "A zero divide" }, - { 0x10000000, -1, "Integer overflow enable" }, - { 0x08000000, -1, "Trace" }, - { 0x06000000, 25, "Frame length" }, - { 0x01000000, -1, "Sequential" }, - { 0x00800000, -1, "S carry" }, - { 0x00400000, -1, "S integer overflow" }, - { 0x00200000, -1, "S zero divide" }, - { 0x00100000, -1, "Zero divide enable" }, - { 0x00080000, -1, "Floating underflow" }, - { 0x00040000, -1, "Floating overflow" }, - { 0x00020000, -1, "Floating reserved operand" }, - { 0x00010000, -1, "Floating zero divide" }, - { 0x00008000, -1, "Floating error enable" }, - { 0x00004000, -1, "Floating underflow enable" }, - { 0x00002000, -1, "IEEE" }, - { 0x00001000, -1, "Sequential stores" }, - { 0x00000800, -1, "Intrinsic error" }, - { 0x00000400, -1, "Intrinsic error enable" }, - { 0x00000200, -1, "Trace thread creates" }, - { 0x00000100, -1, "Thread init trap" }, - { 0x000000e0, 5, "Reserved" }, - { 0x0000001f, 0, "Intrinsic error code" }, - {0, 0, 0}, - }; - - long psw; - struct pswbit *p; - - if (arg) - psw = parse_and_eval_address (arg); - else - psw = read_register (PS_REGNUM); - - for (p = pswbit; p->bit; p++) - { - if (p->pos < 0) - printf_filtered ("%08x %s %s\n", p->bit, - (psw & p->bit) ? "yes" : "no ", p->text); - else - printf_filtered ("%08x %3d %s\n", p->bit, - (psw & p->bit) >> p->pos, p->text); - } -} - -_initialize_convex_dep () -{ - add_com ("alias", class_support, alias_command, - "Add a new name for an existing command."); - - add_cmd ("base", class_vars, set_base_command, - "Change the integer output radix to 8, 10 or 16\n\ -or use just `set base' with no args to return to the ad-hoc default,\n\ -which is 16 for integers that look like addresses, 10 otherwise.", - &setlist); - - add_cmd ("pipeline", class_run, set_pipelining_command, - "Enable or disable overlapped execution of instructions.\n\ -With `set pipe off', exceptions are reported with\n\ -$pc pointing at the instruction after the faulting one.\n\ -The default is `set pipe on', which runs faster.", - &setlist); - - add_cmd ("parallel", class_run, set_parallel_command, - "Enable or disable multi-threaded execution of parallel code.\n\ -`set parallel off' means run the program on a single CPU.\n\ -`set parallel fixed' means run the program with all CPUs assigned to it.\n\ -`set parallel on' means run the program on any CPUs that are available.", - &setlist); - - add_com ("1cont", class_run, one_cont_command, - "Continue the program, activating only the current thread.\n\ -Args are the same as the `cont' command."); - - add_com ("thread", class_run, set_thread_command, - "Change the current thread, the one under scrutiny and control.\n\ -With no arg, show the active threads, the current one marked with *."); - - add_info ("threads", thread_info, - "List status of active threads."); - - add_info ("comm-registers", comm_registers_info, - "List communication registers and their contents.\n\ -A communication register name as argument means describe only that register.\n\ -An address as argument means describe the resource structure at that address.\n\ -`Locked' means that the register has been sent to but not yet received from."); - - add_info ("psw", psw_info, - "Display $ps, the processor status word, bit by bit.\n\ -An argument means display that value's interpretation as a psw."); - - add_cmd ("convex", no_class, 0, "Convex-specific commands.\n\ -32-bit registers $pc $ps $sp $ap $fp $a1-5 $s0-7 $v0-7 $vl $vs $vm $c0-63\n\ -64-bit registers $S0-7 $V0-7 $C0-63\n\ -\n\ -info threads display info on stopped threads waiting to signal\n\ -thread display list of active threads\n\ -thread N select thread N (its registers, stack, memory, etc.)\n\ -step, next, etc step selected thread only\n\ -1cont continue selected thread only\n\ -cont continue all threads\n\ -info comm-registers display contents of comm register(s) or a resource struct\n\ -info psw display processor status word $ps\n\ -set base N change integer radix used by `print' without a format\n\ -set pipeline off exceptions are precise, $pc points after the faulting insn\n\ -set pipeline on normal mode, $pc is somewhere ahead of faulting insn\n\ -set parallel off program runs on a single CPU\n\ -set parallel fixed all CPUs are assigned to the program\n\ -set parallel on normal mode, parallel execution on random available CPUs\n\ -", - &cmdlist); - -} diff --git a/gnu/usr.bin/gdb/config/convex-opcode.h b/gnu/usr.bin/gdb/config/convex-opcode.h deleted file mode 100644 index c98ff84c264a..000000000000 --- a/gnu/usr.bin/gdb/config/convex-opcode.h +++ /dev/null @@ -1,1677 +0,0 @@ -/* Include information for instruction dissasembly on the Convex. - Copyright (C) 1989, Free Software Foundation. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: convex-opcode.h,v 1.2 1993/08/02 17:39:42 mycroft Exp $ -*/ - -#define xxx 0 -#define rrr 1 -#define rr 2 -#define rxr 3 -#define r 4 -#define nops 5 -#define nr 6 -#define pcrel 7 -#define lr 8 -#define rxl 9 -#define rlr 10 -#define rrl 11 -#define iml 12 -#define imr 13 -#define a1r 14 -#define a1l 15 -#define a2r 16 -#define a2l 17 -#define a3 18 -#define a4 19 -#define a5 20 -#define V 1 -#define S 2 -#define VM 3 -#define A 4 -#define VL 5 -#define VS 6 -#define VLS 7 -#define PSW 8 -#define PC 9 -#define ITR 10 -#define VV 11 -#define ITSR 12 -#define TOC 13 -#define CIR 14 -#define TTR 15 -#define VMU 16 -#define VML 17 -#define ICR 18 -#define TCPU 19 -#define CPUID 20 -#define TID 21 -char *op[] = { - "", - "v0\0v1\0v2\0v3\0v4\0v5\0v6\0v7", - "s0\0s1\0s2\0s3\0s4\0s5\0s6\0s7", - "vm", - "sp\0a1\0a2\0a3\0a4\0a5\0ap\0fp", - "vl", - "vs", - "vls", - "psw", - "pc", - "itr", - "vv", - "itsr", - "toc", - "cir", - "ttr", - "vmu", - "vml", - "icr", - "tcpu", - "cpuid", - "tid", -}; -struct formstr format0[] = { - {0,0,rrr,V,S,S}, /* mov */ - {0,0,rrr,S,S,V}, /* mov */ - {1,1,rrr,V,V,V}, /* merg.t */ - {2,1,rrr,V,V,V}, /* mask.t */ - {1,2,rrr,V,S,V}, /* merg.f */ - {2,2,rrr,V,S,V}, /* mask.f */ - {1,1,rrr,V,S,V}, /* merg.t */ - {2,1,rrr,V,S,V}, /* mask.t */ - {3,3,rrr,V,V,V}, /* mul.s */ - {3,4,rrr,V,V,V}, /* mul.d */ - {4,3,rrr,V,V,V}, /* div.s */ - {4,4,rrr,V,V,V}, /* div.d */ - {3,3,rrr,V,S,V}, /* mul.s */ - {3,4,rrr,V,S,V}, /* mul.d */ - {4,3,rrr,V,S,V}, /* div.s */ - {4,4,rrr,V,S,V}, /* div.d */ - {5,0,rrr,V,V,V}, /* and */ - {6,0,rrr,V,V,V}, /* or */ - {7,0,rrr,V,V,V}, /* xor */ - {8,0,rrr,V,V,V}, /* shf */ - {5,0,rrr,V,S,V}, /* and */ - {6,0,rrr,V,S,V}, /* or */ - {7,0,rrr,V,S,V}, /* xor */ - {8,0,rrr,V,S,V}, /* shf */ - {9,3,rrr,V,V,V}, /* add.s */ - {9,4,rrr,V,V,V}, /* add.d */ - {10,3,rrr,V,V,V}, /* sub.s */ - {10,4,rrr,V,V,V}, /* sub.d */ - {9,3,rrr,V,S,V}, /* add.s */ - {9,4,rrr,V,S,V}, /* add.d */ - {10,3,rrr,V,S,V}, /* sub.s */ - {10,4,rrr,V,S,V}, /* sub.d */ - {9,5,rrr,V,V,V}, /* add.b */ - {9,6,rrr,V,V,V}, /* add.h */ - {9,7,rrr,V,V,V}, /* add.w */ - {9,8,rrr,V,V,V}, /* add.l */ - {9,5,rrr,V,S,V}, /* add.b */ - {9,6,rrr,V,S,V}, /* add.h */ - {9,7,rrr,V,S,V}, /* add.w */ - {9,8,rrr,V,S,V}, /* add.l */ - {10,5,rrr,V,V,V}, /* sub.b */ - {10,6,rrr,V,V,V}, /* sub.h */ - {10,7,rrr,V,V,V}, /* sub.w */ - {10,8,rrr,V,V,V}, /* sub.l */ - {10,5,rrr,V,S,V}, /* sub.b */ - {10,6,rrr,V,S,V}, /* sub.h */ - {10,7,rrr,V,S,V}, /* sub.w */ - {10,8,rrr,V,S,V}, /* sub.l */ - {3,5,rrr,V,V,V}, /* mul.b */ - {3,6,rrr,V,V,V}, /* mul.h */ - {3,7,rrr,V,V,V}, /* mul.w */ - {3,8,rrr,V,V,V}, /* mul.l */ - {3,5,rrr,V,S,V}, /* mul.b */ - {3,6,rrr,V,S,V}, /* mul.h */ - {3,7,rrr,V,S,V}, /* mul.w */ - {3,8,rrr,V,S,V}, /* mul.l */ - {4,5,rrr,V,V,V}, /* div.b */ - {4,6,rrr,V,V,V}, /* div.h */ - {4,7,rrr,V,V,V}, /* div.w */ - {4,8,rrr,V,V,V}, /* div.l */ - {4,5,rrr,V,S,V}, /* div.b */ - {4,6,rrr,V,S,V}, /* div.h */ - {4,7,rrr,V,S,V}, /* div.w */ - {4,8,rrr,V,S,V}, /* div.l */ -}; -struct formstr format1[] = { - {11,0,xxx,0,0,0}, /* exit */ - {12,0,a3,0,0,0}, /* jmp */ - {13,2,a3,0,0,0}, /* jmpi.f */ - {13,1,a3,0,0,0}, /* jmpi.t */ - {14,2,a3,0,0,0}, /* jmpa.f */ - {14,1,a3,0,0,0}, /* jmpa.t */ - {15,2,a3,0,0,0}, /* jmps.f */ - {15,1,a3,0,0,0}, /* jmps.t */ - {16,0,a3,0,0,0}, /* tac */ - {17,0,a1r,A,0,0}, /* ldea */ - {18,8,a1l,VLS,0,0}, /* ld.l */ - {18,9,a1l,VM,0,0}, /* ld.x */ - {19,0,a3,0,0,0}, /* tas */ - {20,0,a3,0,0,0}, /* pshea */ - {21,8,a2l,VLS,0,0}, /* st.l */ - {21,9,a2l,VM,0,0}, /* st.x */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {22,0,a3,0,0,0}, /* call */ - {23,0,a3,0,0,0}, /* calls */ - {24,0,a3,0,0,0}, /* callq */ - {25,0,a1r,A,0,0}, /* pfork */ - {26,5,a2r,S,0,0}, /* ste.b */ - {26,6,a2r,S,0,0}, /* ste.h */ - {26,7,a2r,S,0,0}, /* ste.w */ - {26,8,a2r,S,0,0}, /* ste.l */ - {18,5,a1r,A,0,0}, /* ld.b */ - {18,6,a1r,A,0,0}, /* ld.h */ - {18,7,a1r,A,0,0}, /* ld.w */ - {27,7,a1r,A,0,0}, /* incr.w */ - {21,5,a2r,A,0,0}, /* st.b */ - {21,6,a2r,A,0,0}, /* st.h */ - {21,7,a2r,A,0,0}, /* st.w */ - {27,8,a1r,S,0,0}, /* incr.l */ - {18,5,a1r,S,0,0}, /* ld.b */ - {18,6,a1r,S,0,0}, /* ld.h */ - {18,7,a1r,S,0,0}, /* ld.w */ - {18,8,a1r,S,0,0}, /* ld.l */ - {21,5,a2r,S,0,0}, /* st.b */ - {21,6,a2r,S,0,0}, /* st.h */ - {21,7,a2r,S,0,0}, /* st.w */ - {21,8,a2r,S,0,0}, /* st.l */ - {18,5,a1r,V,0,0}, /* ld.b */ - {18,6,a1r,V,0,0}, /* ld.h */ - {18,7,a1r,V,0,0}, /* ld.w */ - {18,8,a1r,V,0,0}, /* ld.l */ - {21,5,a2r,V,0,0}, /* st.b */ - {21,6,a2r,V,0,0}, /* st.h */ - {21,7,a2r,V,0,0}, /* st.w */ - {21,8,a2r,V,0,0}, /* st.l */ -}; -struct formstr format2[] = { - {28,5,rr,A,A,0}, /* cvtw.b */ - {28,6,rr,A,A,0}, /* cvtw.h */ - {29,7,rr,A,A,0}, /* cvtb.w */ - {30,7,rr,A,A,0}, /* cvth.w */ - {28,5,rr,S,S,0}, /* cvtw.b */ - {28,6,rr,S,S,0}, /* cvtw.h */ - {29,7,rr,S,S,0}, /* cvtb.w */ - {30,7,rr,S,S,0}, /* cvth.w */ - {28,3,rr,S,S,0}, /* cvtw.s */ - {31,7,rr,S,S,0}, /* cvts.w */ - {32,3,rr,S,S,0}, /* cvtd.s */ - {31,4,rr,S,S,0}, /* cvts.d */ - {31,8,rr,S,S,0}, /* cvts.l */ - {32,8,rr,S,S,0}, /* cvtd.l */ - {33,3,rr,S,S,0}, /* cvtl.s */ - {33,4,rr,S,S,0}, /* cvtl.d */ - {34,0,rr,A,A,0}, /* ldpa */ - {8,0,nr,A,0,0}, /* shf */ - {18,6,nr,A,0,0}, /* ld.h */ - {18,7,nr,A,0,0}, /* ld.w */ - {33,7,rr,S,S,0}, /* cvtl.w */ - {28,8,rr,S,S,0}, /* cvtw.l */ - {35,1,rr,S,S,0}, /* plc.t */ - {36,0,rr,S,S,0}, /* tzc */ - {37,6,rr,A,A,0}, /* eq.h */ - {37,7,rr,A,A,0}, /* eq.w */ - {37,6,nr,A,0,0}, /* eq.h */ - {37,7,nr,A,0,0}, /* eq.w */ - {37,5,rr,S,S,0}, /* eq.b */ - {37,6,rr,S,S,0}, /* eq.h */ - {37,7,rr,S,S,0}, /* eq.w */ - {37,8,rr,S,S,0}, /* eq.l */ - {38,6,rr,A,A,0}, /* leu.h */ - {38,7,rr,A,A,0}, /* leu.w */ - {38,6,nr,A,0,0}, /* leu.h */ - {38,7,nr,A,0,0}, /* leu.w */ - {38,5,rr,S,S,0}, /* leu.b */ - {38,6,rr,S,S,0}, /* leu.h */ - {38,7,rr,S,S,0}, /* leu.w */ - {38,8,rr,S,S,0}, /* leu.l */ - {39,6,rr,A,A,0}, /* ltu.h */ - {39,7,rr,A,A,0}, /* ltu.w */ - {39,6,nr,A,0,0}, /* ltu.h */ - {39,7,nr,A,0,0}, /* ltu.w */ - {39,5,rr,S,S,0}, /* ltu.b */ - {39,6,rr,S,S,0}, /* ltu.h */ - {39,7,rr,S,S,0}, /* ltu.w */ - {39,8,rr,S,S,0}, /* ltu.l */ - {40,6,rr,A,A,0}, /* le.h */ - {40,7,rr,A,A,0}, /* le.w */ - {40,6,nr,A,0,0}, /* le.h */ - {40,7,nr,A,0,0}, /* le.w */ - {40,5,rr,S,S,0}, /* le.b */ - {40,6,rr,S,S,0}, /* le.h */ - {40,7,rr,S,S,0}, /* le.w */ - {40,8,rr,S,S,0}, /* le.l */ - {41,6,rr,A,A,0}, /* lt.h */ - {41,7,rr,A,A,0}, /* lt.w */ - {41,6,nr,A,0,0}, /* lt.h */ - {41,7,nr,A,0,0}, /* lt.w */ - {41,5,rr,S,S,0}, /* lt.b */ - {41,6,rr,S,S,0}, /* lt.h */ - {41,7,rr,S,S,0}, /* lt.w */ - {41,8,rr,S,S,0}, /* lt.l */ - {9,7,rr,S,A,0}, /* add.w */ - {8,0,rr,A,A,0}, /* shf */ - {0,0,rr,A,A,0}, /* mov */ - {0,0,rr,S,A,0}, /* mov */ - {0,7,rr,S,S,0}, /* mov.w */ - {8,0,rr,S,S,0}, /* shf */ - {0,0,rr,S,S,0}, /* mov */ - {0,0,rr,A,S,0}, /* mov */ - {5,0,rr,A,A,0}, /* and */ - {6,0,rr,A,A,0}, /* or */ - {7,0,rr,A,A,0}, /* xor */ - {42,0,rr,A,A,0}, /* not */ - {5,0,rr,S,S,0}, /* and */ - {6,0,rr,S,S,0}, /* or */ - {7,0,rr,S,S,0}, /* xor */ - {42,0,rr,S,S,0}, /* not */ - {40,3,rr,S,S,0}, /* le.s */ - {40,4,rr,S,S,0}, /* le.d */ - {41,3,rr,S,S,0}, /* lt.s */ - {41,4,rr,S,S,0}, /* lt.d */ - {9,3,rr,S,S,0}, /* add.s */ - {9,4,rr,S,S,0}, /* add.d */ - {10,3,rr,S,S,0}, /* sub.s */ - {10,4,rr,S,S,0}, /* sub.d */ - {37,3,rr,S,S,0}, /* eq.s */ - {37,4,rr,S,S,0}, /* eq.d */ - {43,6,rr,A,A,0}, /* neg.h */ - {43,7,rr,A,A,0}, /* neg.w */ - {3,3,rr,S,S,0}, /* mul.s */ - {3,4,rr,S,S,0}, /* mul.d */ - {4,3,rr,S,S,0}, /* div.s */ - {4,4,rr,S,S,0}, /* div.d */ - {9,6,rr,A,A,0}, /* add.h */ - {9,7,rr,A,A,0}, /* add.w */ - {9,6,nr,A,0,0}, /* add.h */ - {9,7,nr,A,0,0}, /* add.w */ - {9,5,rr,S,S,0}, /* add.b */ - {9,6,rr,S,S,0}, /* add.h */ - {9,7,rr,S,S,0}, /* add.w */ - {9,8,rr,S,S,0}, /* add.l */ - {10,6,rr,A,A,0}, /* sub.h */ - {10,7,rr,A,A,0}, /* sub.w */ - {10,6,nr,A,0,0}, /* sub.h */ - {10,7,nr,A,0,0}, /* sub.w */ - {10,5,rr,S,S,0}, /* sub.b */ - {10,6,rr,S,S,0}, /* sub.h */ - {10,7,rr,S,S,0}, /* sub.w */ - {10,8,rr,S,S,0}, /* sub.l */ - {3,6,rr,A,A,0}, /* mul.h */ - {3,7,rr,A,A,0}, /* mul.w */ - {3,6,nr,A,0,0}, /* mul.h */ - {3,7,nr,A,0,0}, /* mul.w */ - {3,5,rr,S,S,0}, /* mul.b */ - {3,6,rr,S,S,0}, /* mul.h */ - {3,7,rr,S,S,0}, /* mul.w */ - {3,8,rr,S,S,0}, /* mul.l */ - {4,6,rr,A,A,0}, /* div.h */ - {4,7,rr,A,A,0}, /* div.w */ - {4,6,nr,A,0,0}, /* div.h */ - {4,7,nr,A,0,0}, /* div.w */ - {4,5,rr,S,S,0}, /* div.b */ - {4,6,rr,S,S,0}, /* div.h */ - {4,7,rr,S,S,0}, /* div.w */ - {4,8,rr,S,S,0}, /* div.l */ -}; -struct formstr format3[] = { - {32,3,rr,V,V,0}, /* cvtd.s */ - {31,4,rr,V,V,0}, /* cvts.d */ - {33,4,rr,V,V,0}, /* cvtl.d */ - {32,8,rr,V,V,0}, /* cvtd.l */ - {0,0,rrl,S,S,VM}, /* mov */ - {0,0,rlr,S,VM,S}, /* mov */ - {0,0,0,0,0,0}, - {44,0,rr,S,S,0}, /* lop */ - {36,0,rr,V,V,0}, /* tzc */ - {44,0,rr,V,V,0}, /* lop */ - {0,0,0,0,0,0}, - {42,0,rr,V,V,0}, /* not */ - {8,0,rr,S,V,0}, /* shf */ - {35,1,rr,V,V,0}, /* plc.t */ - {45,2,rr,V,V,0}, /* cprs.f */ - {45,1,rr,V,V,0}, /* cprs.t */ - {37,3,rr,V,V,0}, /* eq.s */ - {37,4,rr,V,V,0}, /* eq.d */ - {43,3,rr,V,V,0}, /* neg.s */ - {43,4,rr,V,V,0}, /* neg.d */ - {37,3,rr,S,V,0}, /* eq.s */ - {37,4,rr,S,V,0}, /* eq.d */ - {43,3,rr,S,S,0}, /* neg.s */ - {43,4,rr,S,S,0}, /* neg.d */ - {40,3,rr,V,V,0}, /* le.s */ - {40,4,rr,V,V,0}, /* le.d */ - {41,3,rr,V,V,0}, /* lt.s */ - {41,4,rr,V,V,0}, /* lt.d */ - {40,3,rr,S,V,0}, /* le.s */ - {40,4,rr,S,V,0}, /* le.d */ - {41,3,rr,S,V,0}, /* lt.s */ - {41,4,rr,S,V,0}, /* lt.d */ - {37,5,rr,V,V,0}, /* eq.b */ - {37,6,rr,V,V,0}, /* eq.h */ - {37,7,rr,V,V,0}, /* eq.w */ - {37,8,rr,V,V,0}, /* eq.l */ - {37,5,rr,S,V,0}, /* eq.b */ - {37,6,rr,S,V,0}, /* eq.h */ - {37,7,rr,S,V,0}, /* eq.w */ - {37,8,rr,S,V,0}, /* eq.l */ - {40,5,rr,V,V,0}, /* le.b */ - {40,6,rr,V,V,0}, /* le.h */ - {40,7,rr,V,V,0}, /* le.w */ - {40,8,rr,V,V,0}, /* le.l */ - {40,5,rr,S,V,0}, /* le.b */ - {40,6,rr,S,V,0}, /* le.h */ - {40,7,rr,S,V,0}, /* le.w */ - {40,8,rr,S,V,0}, /* le.l */ - {41,5,rr,V,V,0}, /* lt.b */ - {41,6,rr,V,V,0}, /* lt.h */ - {41,7,rr,V,V,0}, /* lt.w */ - {41,8,rr,V,V,0}, /* lt.l */ - {41,5,rr,S,V,0}, /* lt.b */ - {41,6,rr,S,V,0}, /* lt.h */ - {41,7,rr,S,V,0}, /* lt.w */ - {41,8,rr,S,V,0}, /* lt.l */ - {43,5,rr,V,V,0}, /* neg.b */ - {43,6,rr,V,V,0}, /* neg.h */ - {43,7,rr,V,V,0}, /* neg.w */ - {43,8,rr,V,V,0}, /* neg.l */ - {43,5,rr,S,S,0}, /* neg.b */ - {43,6,rr,S,S,0}, /* neg.h */ - {43,7,rr,S,S,0}, /* neg.w */ - {43,8,rr,S,S,0}, /* neg.l */ -}; -struct formstr format4[] = { - {46,0,nops,0,0,0}, /* nop */ - {47,0,pcrel,0,0,0}, /* br */ - {48,2,pcrel,0,0,0}, /* bri.f */ - {48,1,pcrel,0,0,0}, /* bri.t */ - {49,2,pcrel,0,0,0}, /* bra.f */ - {49,1,pcrel,0,0,0}, /* bra.t */ - {50,2,pcrel,0,0,0}, /* brs.f */ - {50,1,pcrel,0,0,0}, /* brs.t */ -}; -struct formstr format5[] = { - {51,5,rr,V,V,0}, /* ldvi.b */ - {51,6,rr,V,V,0}, /* ldvi.h */ - {51,7,rr,V,V,0}, /* ldvi.w */ - {51,8,rr,V,V,0}, /* ldvi.l */ - {28,3,rr,V,V,0}, /* cvtw.s */ - {31,7,rr,V,V,0}, /* cvts.w */ - {28,8,rr,V,V,0}, /* cvtw.l */ - {33,7,rr,V,V,0}, /* cvtl.w */ - {52,5,rxr,V,V,0}, /* stvi.b */ - {52,6,rxr,V,V,0}, /* stvi.h */ - {52,7,rxr,V,V,0}, /* stvi.w */ - {52,8,rxr,V,V,0}, /* stvi.l */ - {52,5,rxr,S,V,0}, /* stvi.b */ - {52,6,rxr,S,V,0}, /* stvi.h */ - {52,7,rxr,S,V,0}, /* stvi.w */ - {52,8,rxr,S,V,0}, /* stvi.l */ -}; -struct formstr format6[] = { - {53,0,r,A,0,0}, /* ldsdr */ - {54,0,r,A,0,0}, /* ldkdr */ - {55,3,r,S,0,0}, /* ln.s */ - {55,4,r,S,0,0}, /* ln.d */ - {56,0,nops,0,0,0}, /* patu */ - {57,0,r,A,0,0}, /* pate */ - {58,0,nops,0,0,0}, /* pich */ - {59,0,nops,0,0,0}, /* plch */ - {0,0,lr,PSW,A,0}, /* mov */ - {0,0,rxl,A,PSW,0}, /* mov */ - {0,0,lr,PC,A,0}, /* mov */ - {60,0,r,S,0,0}, /* idle */ - {0,0,lr,ITR,S,0}, /* mov */ - {0,0,rxl,S,ITR,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,rxl,S,ITSR,0}, /* mov */ - {61,0,nops,0,0,0}, /* rtnq */ - {62,0,nops,0,0,0}, /* cfork */ - {63,0,nops,0,0,0}, /* rtn */ - {64,0,nops,0,0,0}, /* wfork */ - {65,0,nops,0,0,0}, /* join */ - {66,0,nops,0,0,0}, /* rtnc */ - {67,3,r,S,0,0}, /* exp.s */ - {67,4,r,S,0,0}, /* exp.d */ - {68,3,r,S,0,0}, /* sin.s */ - {68,4,r,S,0,0}, /* sin.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {69,3,r,S,0,0}, /* cos.s */ - {69,4,r,S,0,0}, /* cos.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {70,7,r,A,0,0}, /* psh.w */ - {0,0,0,0,0,0}, - {71,7,r,A,0,0}, /* pop.w */ - {0,0,0,0,0,0}, - {70,7,r,S,0,0}, /* psh.w */ - {70,8,r,S,0,0}, /* psh.l */ - {71,7,r,S,0,0}, /* pop.w */ - {71,8,r,S,0,0}, /* pop.l */ - {72,0,nops,0,0,0}, /* eni */ - {73,0,nops,0,0,0}, /* dsi */ - {74,0,nops,0,0,0}, /* bkpt */ - {75,0,nops,0,0,0}, /* msync */ - {76,0,r,S,0,0}, /* mski */ - {77,0,r,S,0,0}, /* xmti */ - {0,0,rxl,S,VV,0}, /* mov */ - {78,0,nops,0,0,0}, /* tstvv */ - {0,0,lr,VS,A,0}, /* mov */ - {0,0,rxl,A,VS,0}, /* mov */ - {0,0,lr,VL,A,0}, /* mov */ - {0,0,rxl,A,VL,0}, /* mov */ - {0,7,lr,VS,S,0}, /* mov.w */ - {0,7,rxl,S,VS,0}, /* mov.w */ - {0,7,lr,VL,S,0}, /* mov.w */ - {0,7,rxl,S,VL,0}, /* mov.w */ - {79,0,r,A,0,0}, /* diag */ - {80,0,nops,0,0,0}, /* pbkpt */ - {81,3,r,S,0,0}, /* sqrt.s */ - {81,4,r,S,0,0}, /* sqrt.d */ - {82,0,nops,0,0,0}, /* casr */ - {0,0,0,0,0,0}, - {83,3,r,S,0,0}, /* atan.s */ - {83,4,r,S,0,0}, /* atan.d */ -}; -struct formstr format7[] = { - {84,5,r,V,0,0}, /* sum.b */ - {84,6,r,V,0,0}, /* sum.h */ - {84,7,r,V,0,0}, /* sum.w */ - {84,8,r,V,0,0}, /* sum.l */ - {85,0,r,V,0,0}, /* all */ - {86,0,r,V,0,0}, /* any */ - {87,0,r,V,0,0}, /* parity */ - {0,0,0,0,0,0}, - {88,5,r,V,0,0}, /* max.b */ - {88,6,r,V,0,0}, /* max.h */ - {88,7,r,V,0,0}, /* max.w */ - {88,8,r,V,0,0}, /* max.l */ - {89,5,r,V,0,0}, /* min.b */ - {89,6,r,V,0,0}, /* min.h */ - {89,7,r,V,0,0}, /* min.w */ - {89,8,r,V,0,0}, /* min.l */ - {84,3,r,V,0,0}, /* sum.s */ - {84,4,r,V,0,0}, /* sum.d */ - {90,3,r,V,0,0}, /* prod.s */ - {90,4,r,V,0,0}, /* prod.d */ - {88,3,r,V,0,0}, /* max.s */ - {88,4,r,V,0,0}, /* max.d */ - {89,3,r,V,0,0}, /* min.s */ - {89,4,r,V,0,0}, /* min.d */ - {90,5,r,V,0,0}, /* prod.b */ - {90,6,r,V,0,0}, /* prod.h */ - {90,7,r,V,0,0}, /* prod.w */ - {90,8,r,V,0,0}, /* prod.l */ - {35,2,lr,VM,S,0}, /* plc.f */ - {35,1,lr,VM,S,0}, /* plc.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr formatx[] = { - {0,0,0,0,0,0}, -}; -struct formstr format1a[] = { - {91,0,imr,A,0,0}, /* halt */ - {92,0,a4,0,0,0}, /* sysc */ - {18,6,imr,A,0,0}, /* ld.h */ - {18,7,imr,A,0,0}, /* ld.w */ - {5,0,imr,A,0,0}, /* and */ - {6,0,imr,A,0,0}, /* or */ - {7,0,imr,A,0,0}, /* xor */ - {8,0,imr,A,0,0}, /* shf */ - {9,6,imr,A,0,0}, /* add.h */ - {9,7,imr,A,0,0}, /* add.w */ - {10,6,imr,A,0,0}, /* sub.h */ - {10,7,imr,A,0,0}, /* sub.w */ - {3,6,imr,A,0,0}, /* mul.h */ - {3,7,imr,A,0,0}, /* mul.w */ - {4,6,imr,A,0,0}, /* div.h */ - {4,7,imr,A,0,0}, /* div.w */ - {18,7,iml,VL,0,0}, /* ld.w */ - {18,7,iml,VS,0,0}, /* ld.w */ - {0,0,0,0,0,0}, - {8,7,imr,S,0,0}, /* shf.w */ - {93,0,a5,0,0,0}, /* trap */ - {0,0,0,0,0,0}, - {37,6,imr,A,0,0}, /* eq.h */ - {37,7,imr,A,0,0}, /* eq.w */ - {38,6,imr,A,0,0}, /* leu.h */ - {38,7,imr,A,0,0}, /* leu.w */ - {39,6,imr,A,0,0}, /* ltu.h */ - {39,7,imr,A,0,0}, /* ltu.w */ - {40,6,imr,A,0,0}, /* le.h */ - {40,7,imr,A,0,0}, /* le.w */ - {41,6,imr,A,0,0}, /* lt.h */ - {41,7,imr,A,0,0}, /* lt.w */ -}; -struct formstr format1b[] = { - {18,4,imr,S,0,0}, /* ld.d */ - {18,10,imr,S,0,0}, /* ld.u */ - {18,8,imr,S,0,0}, /* ld.l */ - {18,7,imr,S,0,0}, /* ld.w */ - {5,0,imr,S,0,0}, /* and */ - {6,0,imr,S,0,0}, /* or */ - {7,0,imr,S,0,0}, /* xor */ - {8,0,imr,S,0,0}, /* shf */ - {9,6,imr,S,0,0}, /* add.h */ - {9,7,imr,S,0,0}, /* add.w */ - {10,6,imr,S,0,0}, /* sub.h */ - {10,7,imr,S,0,0}, /* sub.w */ - {3,6,imr,S,0,0}, /* mul.h */ - {3,7,imr,S,0,0}, /* mul.w */ - {4,6,imr,S,0,0}, /* div.h */ - {4,7,imr,S,0,0}, /* div.w */ - {9,3,imr,S,0,0}, /* add.s */ - {10,3,imr,S,0,0}, /* sub.s */ - {3,3,imr,S,0,0}, /* mul.s */ - {4,3,imr,S,0,0}, /* div.s */ - {40,3,imr,S,0,0}, /* le.s */ - {41,3,imr,S,0,0}, /* lt.s */ - {37,6,imr,S,0,0}, /* eq.h */ - {37,7,imr,S,0,0}, /* eq.w */ - {38,6,imr,S,0,0}, /* leu.h */ - {38,7,imr,S,0,0}, /* leu.w */ - {39,6,imr,S,0,0}, /* ltu.h */ - {39,7,imr,S,0,0}, /* ltu.w */ - {40,6,imr,S,0,0}, /* le.h */ - {40,7,imr,S,0,0}, /* le.w */ - {41,6,imr,S,0,0}, /* lt.h */ - {41,7,imr,S,0,0}, /* lt.w */ -}; -struct formstr e0_format0[] = { - {10,3,rrr,S,V,V}, /* sub.s */ - {10,4,rrr,S,V,V}, /* sub.d */ - {4,3,rrr,S,V,V}, /* div.s */ - {4,4,rrr,S,V,V}, /* div.d */ - {10,11,rrr,S,V,V}, /* sub.s.f */ - {10,12,rrr,S,V,V}, /* sub.d.f */ - {4,11,rrr,S,V,V}, /* div.s.f */ - {4,12,rrr,S,V,V}, /* div.d.f */ - {3,11,rrr,V,V,V}, /* mul.s.f */ - {3,12,rrr,V,V,V}, /* mul.d.f */ - {4,11,rrr,V,V,V}, /* div.s.f */ - {4,12,rrr,V,V,V}, /* div.d.f */ - {3,11,rrr,V,S,V}, /* mul.s.f */ - {3,12,rrr,V,S,V}, /* mul.d.f */ - {4,11,rrr,V,S,V}, /* div.s.f */ - {4,12,rrr,V,S,V}, /* div.d.f */ - {5,2,rrr,V,V,V}, /* and.f */ - {6,2,rrr,V,V,V}, /* or.f */ - {7,2,rrr,V,V,V}, /* xor.f */ - {8,2,rrr,V,V,V}, /* shf.f */ - {5,2,rrr,V,S,V}, /* and.f */ - {6,2,rrr,V,S,V}, /* or.f */ - {7,2,rrr,V,S,V}, /* xor.f */ - {8,2,rrr,V,S,V}, /* shf.f */ - {9,11,rrr,V,V,V}, /* add.s.f */ - {9,12,rrr,V,V,V}, /* add.d.f */ - {10,11,rrr,V,V,V}, /* sub.s.f */ - {10,12,rrr,V,V,V}, /* sub.d.f */ - {9,11,rrr,V,S,V}, /* add.s.f */ - {9,12,rrr,V,S,V}, /* add.d.f */ - {10,11,rrr,V,S,V}, /* sub.s.f */ - {10,12,rrr,V,S,V}, /* sub.d.f */ - {9,13,rrr,V,V,V}, /* add.b.f */ - {9,14,rrr,V,V,V}, /* add.h.f */ - {9,15,rrr,V,V,V}, /* add.w.f */ - {9,16,rrr,V,V,V}, /* add.l.f */ - {9,13,rrr,V,S,V}, /* add.b.f */ - {9,14,rrr,V,S,V}, /* add.h.f */ - {9,15,rrr,V,S,V}, /* add.w.f */ - {9,16,rrr,V,S,V}, /* add.l.f */ - {10,13,rrr,V,V,V}, /* sub.b.f */ - {10,14,rrr,V,V,V}, /* sub.h.f */ - {10,15,rrr,V,V,V}, /* sub.w.f */ - {10,16,rrr,V,V,V}, /* sub.l.f */ - {10,13,rrr,V,S,V}, /* sub.b.f */ - {10,14,rrr,V,S,V}, /* sub.h.f */ - {10,15,rrr,V,S,V}, /* sub.w.f */ - {10,16,rrr,V,S,V}, /* sub.l.f */ - {3,13,rrr,V,V,V}, /* mul.b.f */ - {3,14,rrr,V,V,V}, /* mul.h.f */ - {3,15,rrr,V,V,V}, /* mul.w.f */ - {3,16,rrr,V,V,V}, /* mul.l.f */ - {3,13,rrr,V,S,V}, /* mul.b.f */ - {3,14,rrr,V,S,V}, /* mul.h.f */ - {3,15,rrr,V,S,V}, /* mul.w.f */ - {3,16,rrr,V,S,V}, /* mul.l.f */ - {4,13,rrr,V,V,V}, /* div.b.f */ - {4,14,rrr,V,V,V}, /* div.h.f */ - {4,15,rrr,V,V,V}, /* div.w.f */ - {4,16,rrr,V,V,V}, /* div.l.f */ - {4,13,rrr,V,S,V}, /* div.b.f */ - {4,14,rrr,V,S,V}, /* div.h.f */ - {4,15,rrr,V,S,V}, /* div.w.f */ - {4,16,rrr,V,S,V}, /* div.l.f */ -}; -struct formstr e0_format1[] = { - {0,0,0,0,0,0}, - {94,0,a3,0,0,0}, /* tst */ - {95,0,a3,0,0,0}, /* lck */ - {96,0,a3,0,0,0}, /* ulk */ - {17,0,a1r,S,0,0}, /* ldea */ - {97,0,a1r,A,0,0}, /* spawn */ - {98,0,a1r,A,0,0}, /* ldcmr */ - {99,0,a2r,A,0,0}, /* stcmr */ - {100,0,a1r,A,0,0}, /* popr */ - {101,0,a2r,A,0,0}, /* pshr */ - {102,7,a1r,A,0,0}, /* rcvr.w */ - {103,7,a2r,A,0,0}, /* matm.w */ - {104,7,a2r,A,0,0}, /* sndr.w */ - {104,8,a2r,S,0,0}, /* sndr.l */ - {102,8,a1r,S,0,0}, /* rcvr.l */ - {103,8,a2r,S,0,0}, /* matm.l */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {105,7,a2r,A,0,0}, /* putr.w */ - {105,8,a2r,S,0,0}, /* putr.l */ - {106,7,a1r,A,0,0}, /* getr.w */ - {106,8,a1r,S,0,0}, /* getr.l */ - {26,13,a2r,S,0,0}, /* ste.b.f */ - {26,14,a2r,S,0,0}, /* ste.h.f */ - {26,15,a2r,S,0,0}, /* ste.w.f */ - {26,16,a2r,S,0,0}, /* ste.l.f */ - {107,7,a2r,A,0,0}, /* matr.w */ - {108,7,a2r,A,0,0}, /* mat.w */ - {109,7,a1r,A,0,0}, /* get.w */ - {110,7,a1r,A,0,0}, /* rcv.w */ - {0,0,0,0,0,0}, - {111,7,a1r,A,0,0}, /* inc.w */ - {112,7,a2r,A,0,0}, /* put.w */ - {113,7,a2r,A,0,0}, /* snd.w */ - {107,8,a2r,S,0,0}, /* matr.l */ - {108,8,a2r,S,0,0}, /* mat.l */ - {109,8,a1r,S,0,0}, /* get.l */ - {110,8,a1r,S,0,0}, /* rcv.l */ - {0,0,0,0,0,0}, - {111,8,a1r,S,0,0}, /* inc.l */ - {112,8,a2r,S,0,0}, /* put.l */ - {113,8,a2r,S,0,0}, /* snd.l */ - {18,13,a1r,V,0,0}, /* ld.b.f */ - {18,14,a1r,V,0,0}, /* ld.h.f */ - {18,15,a1r,V,0,0}, /* ld.w.f */ - {18,16,a1r,V,0,0}, /* ld.l.f */ - {21,13,a2r,V,0,0}, /* st.b.f */ - {21,14,a2r,V,0,0}, /* st.h.f */ - {21,15,a2r,V,0,0}, /* st.w.f */ - {21,16,a2r,V,0,0}, /* st.l.f */ -}; -struct formstr e0_format2[] = { - {28,5,rr,V,V,0}, /* cvtw.b */ - {28,6,rr,V,V,0}, /* cvtw.h */ - {29,7,rr,V,V,0}, /* cvtb.w */ - {30,7,rr,V,V,0}, /* cvth.w */ - {28,13,rr,V,V,0}, /* cvtw.b.f */ - {28,14,rr,V,V,0}, /* cvtw.h.f */ - {29,15,rr,V,V,0}, /* cvtb.w.f */ - {30,15,rr,V,V,0}, /* cvth.w.f */ - {31,8,rr,V,V,0}, /* cvts.l */ - {32,7,rr,V,V,0}, /* cvtd.w */ - {33,3,rr,V,V,0}, /* cvtl.s */ - {28,4,rr,V,V,0}, /* cvtw.d */ - {31,16,rr,V,V,0}, /* cvts.l.f */ - {32,15,rr,V,V,0}, /* cvtd.w.f */ - {33,11,rr,V,V,0}, /* cvtl.s.f */ - {28,12,rr,V,V,0}, /* cvtw.d.f */ - {114,0,rr,S,S,0}, /* enal */ - {8,7,rr,S,S,0}, /* shf.w */ - {115,0,rr,S,S,0}, /* enag */ - {0,0,0,0,0,0}, - {28,4,rr,S,S,0}, /* cvtw.d */ - {32,7,rr,S,S,0}, /* cvtd.w */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,3,rr,S,S,0}, /* frint.s */ - {116,4,rr,S,S,0}, /* frint.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,3,rr,V,V,0}, /* frint.s */ - {116,4,rr,V,V,0}, /* frint.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,11,rr,V,V,0}, /* frint.s.f */ - {116,12,rr,V,V,0}, /* frint.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,3,rr,V,V,0}, /* sqrt.s */ - {81,4,rr,V,V,0}, /* sqrt.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,11,rr,V,V,0}, /* sqrt.s.f */ - {81,12,rr,V,V,0}, /* sqrt.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format3[] = { - {32,11,rr,V,V,0}, /* cvtd.s.f */ - {31,12,rr,V,V,0}, /* cvts.d.f */ - {33,12,rr,V,V,0}, /* cvtl.d.f */ - {32,16,rr,V,V,0}, /* cvtd.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {36,2,rr,V,V,0}, /* tzc.f */ - {44,2,rr,V,V,0}, /* lop.f */ - {117,2,rr,V,V,0}, /* xpnd.f */ - {42,2,rr,V,V,0}, /* not.f */ - {8,2,rr,S,V,0}, /* shf.f */ - {35,17,rr,V,V,0}, /* plc.t.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {37,11,rr,V,V,0}, /* eq.s.f */ - {37,12,rr,V,V,0}, /* eq.d.f */ - {43,11,rr,V,V,0}, /* neg.s.f */ - {43,12,rr,V,V,0}, /* neg.d.f */ - {37,11,rr,S,V,0}, /* eq.s.f */ - {37,12,rr,S,V,0}, /* eq.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {40,11,rr,V,V,0}, /* le.s.f */ - {40,12,rr,V,V,0}, /* le.d.f */ - {41,11,rr,V,V,0}, /* lt.s.f */ - {41,12,rr,V,V,0}, /* lt.d.f */ - {40,11,rr,S,V,0}, /* le.s.f */ - {40,12,rr,S,V,0}, /* le.d.f */ - {41,11,rr,S,V,0}, /* lt.s.f */ - {41,12,rr,S,V,0}, /* lt.d.f */ - {37,13,rr,V,V,0}, /* eq.b.f */ - {37,14,rr,V,V,0}, /* eq.h.f */ - {37,15,rr,V,V,0}, /* eq.w.f */ - {37,16,rr,V,V,0}, /* eq.l.f */ - {37,13,rr,S,V,0}, /* eq.b.f */ - {37,14,rr,S,V,0}, /* eq.h.f */ - {37,15,rr,S,V,0}, /* eq.w.f */ - {37,16,rr,S,V,0}, /* eq.l.f */ - {40,13,rr,V,V,0}, /* le.b.f */ - {40,14,rr,V,V,0}, /* le.h.f */ - {40,15,rr,V,V,0}, /* le.w.f */ - {40,16,rr,V,V,0}, /* le.l.f */ - {40,13,rr,S,V,0}, /* le.b.f */ - {40,14,rr,S,V,0}, /* le.h.f */ - {40,15,rr,S,V,0}, /* le.w.f */ - {40,16,rr,S,V,0}, /* le.l.f */ - {41,13,rr,V,V,0}, /* lt.b.f */ - {41,14,rr,V,V,0}, /* lt.h.f */ - {41,15,rr,V,V,0}, /* lt.w.f */ - {41,16,rr,V,V,0}, /* lt.l.f */ - {41,13,rr,S,V,0}, /* lt.b.f */ - {41,14,rr,S,V,0}, /* lt.h.f */ - {41,15,rr,S,V,0}, /* lt.w.f */ - {41,16,rr,S,V,0}, /* lt.l.f */ - {43,13,rr,V,V,0}, /* neg.b.f */ - {43,14,rr,V,V,0}, /* neg.h.f */ - {43,15,rr,V,V,0}, /* neg.w.f */ - {43,16,rr,V,V,0}, /* neg.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format4[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format5[] = { - {51,13,rr,V,V,0}, /* ldvi.b.f */ - {51,14,rr,V,V,0}, /* ldvi.h.f */ - {51,15,rr,V,V,0}, /* ldvi.w.f */ - {51,16,rr,V,V,0}, /* ldvi.l.f */ - {28,11,rr,V,V,0}, /* cvtw.s.f */ - {31,15,rr,V,V,0}, /* cvts.w.f */ - {28,16,rr,V,V,0}, /* cvtw.l.f */ - {33,15,rr,V,V,0}, /* cvtl.w.f */ - {52,13,rxr,V,V,0}, /* stvi.b.f */ - {52,14,rxr,V,V,0}, /* stvi.h.f */ - {52,15,rxr,V,V,0}, /* stvi.w.f */ - {52,16,rxr,V,V,0}, /* stvi.l.f */ - {52,13,rxr,S,V,0}, /* stvi.b.f */ - {52,14,rxr,S,V,0}, /* stvi.h.f */ - {52,15,rxr,S,V,0}, /* stvi.w.f */ - {52,16,rxr,S,V,0}, /* stvi.l.f */ -}; -struct formstr e0_format6[] = { - {0,0,rxl,S,CIR,0}, /* mov */ - {0,0,lr,CIR,S,0}, /* mov */ - {0,0,lr,TOC,S,0}, /* mov */ - {0,0,lr,CPUID,S,0}, /* mov */ - {0,0,rxl,S,TTR,0}, /* mov */ - {0,0,lr,TTR,S,0}, /* mov */ - {118,0,nops,0,0,0}, /* ctrsl */ - {119,0,nops,0,0,0}, /* ctrsg */ - {0,0,rxl,S,VMU,0}, /* mov */ - {0,0,lr,VMU,S,0}, /* mov */ - {0,0,rxl,S,VML,0}, /* mov */ - {0,0,lr,VML,S,0}, /* mov */ - {0,0,rxl,S,ICR,0}, /* mov */ - {0,0,lr,ICR,S,0}, /* mov */ - {0,0,rxl,S,TCPU,0}, /* mov */ - {0,0,lr,TCPU,S,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {120,0,nops,0,0,0}, /* stop */ - {0,0,0,0,0,0}, - {0,0,rxl,S,TID,0}, /* mov */ - {0,0,lr,TID,S,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format7[] = { - {84,13,r,V,0,0}, /* sum.b.f */ - {84,14,r,V,0,0}, /* sum.h.f */ - {84,15,r,V,0,0}, /* sum.w.f */ - {84,16,r,V,0,0}, /* sum.l.f */ - {85,2,r,V,0,0}, /* all.f */ - {86,2,r,V,0,0}, /* any.f */ - {87,2,r,V,0,0}, /* parity.f */ - {0,0,0,0,0,0}, - {88,13,r,V,0,0}, /* max.b.f */ - {88,14,r,V,0,0}, /* max.h.f */ - {88,15,r,V,0,0}, /* max.w.f */ - {88,16,r,V,0,0}, /* max.l.f */ - {89,13,r,V,0,0}, /* min.b.f */ - {89,14,r,V,0,0}, /* min.h.f */ - {89,15,r,V,0,0}, /* min.w.f */ - {89,16,r,V,0,0}, /* min.l.f */ - {84,11,r,V,0,0}, /* sum.s.f */ - {84,12,r,V,0,0}, /* sum.d.f */ - {90,11,r,V,0,0}, /* prod.s.f */ - {90,12,r,V,0,0}, /* prod.d.f */ - {88,11,r,V,0,0}, /* max.s.f */ - {88,12,r,V,0,0}, /* max.d.f */ - {89,11,r,V,0,0}, /* min.s.f */ - {89,12,r,V,0,0}, /* min.d.f */ - {90,13,r,V,0,0}, /* prod.b.f */ - {90,14,r,V,0,0}, /* prod.h.f */ - {90,15,r,V,0,0}, /* prod.w.f */ - {90,16,r,V,0,0}, /* prod.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format0[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {10,18,rrr,S,V,V}, /* sub.s.t */ - {10,19,rrr,S,V,V}, /* sub.d.t */ - {4,18,rrr,S,V,V}, /* div.s.t */ - {4,19,rrr,S,V,V}, /* div.d.t */ - {3,18,rrr,V,V,V}, /* mul.s.t */ - {3,19,rrr,V,V,V}, /* mul.d.t */ - {4,18,rrr,V,V,V}, /* div.s.t */ - {4,19,rrr,V,V,V}, /* div.d.t */ - {3,18,rrr,V,S,V}, /* mul.s.t */ - {3,19,rrr,V,S,V}, /* mul.d.t */ - {4,18,rrr,V,S,V}, /* div.s.t */ - {4,19,rrr,V,S,V}, /* div.d.t */ - {5,1,rrr,V,V,V}, /* and.t */ - {6,1,rrr,V,V,V}, /* or.t */ - {7,1,rrr,V,V,V}, /* xor.t */ - {8,1,rrr,V,V,V}, /* shf.t */ - {5,1,rrr,V,S,V}, /* and.t */ - {6,1,rrr,V,S,V}, /* or.t */ - {7,1,rrr,V,S,V}, /* xor.t */ - {8,1,rrr,V,S,V}, /* shf.t */ - {9,18,rrr,V,V,V}, /* add.s.t */ - {9,19,rrr,V,V,V}, /* add.d.t */ - {10,18,rrr,V,V,V}, /* sub.s.t */ - {10,19,rrr,V,V,V}, /* sub.d.t */ - {9,18,rrr,V,S,V}, /* add.s.t */ - {9,19,rrr,V,S,V}, /* add.d.t */ - {10,18,rrr,V,S,V}, /* sub.s.t */ - {10,19,rrr,V,S,V}, /* sub.d.t */ - {9,20,rrr,V,V,V}, /* add.b.t */ - {9,21,rrr,V,V,V}, /* add.h.t */ - {9,22,rrr,V,V,V}, /* add.w.t */ - {9,23,rrr,V,V,V}, /* add.l.t */ - {9,20,rrr,V,S,V}, /* add.b.t */ - {9,21,rrr,V,S,V}, /* add.h.t */ - {9,22,rrr,V,S,V}, /* add.w.t */ - {9,23,rrr,V,S,V}, /* add.l.t */ - {10,20,rrr,V,V,V}, /* sub.b.t */ - {10,21,rrr,V,V,V}, /* sub.h.t */ - {10,22,rrr,V,V,V}, /* sub.w.t */ - {10,23,rrr,V,V,V}, /* sub.l.t */ - {10,20,rrr,V,S,V}, /* sub.b.t */ - {10,21,rrr,V,S,V}, /* sub.h.t */ - {10,22,rrr,V,S,V}, /* sub.w.t */ - {10,23,rrr,V,S,V}, /* sub.l.t */ - {3,20,rrr,V,V,V}, /* mul.b.t */ - {3,21,rrr,V,V,V}, /* mul.h.t */ - {3,22,rrr,V,V,V}, /* mul.w.t */ - {3,23,rrr,V,V,V}, /* mul.l.t */ - {3,20,rrr,V,S,V}, /* mul.b.t */ - {3,21,rrr,V,S,V}, /* mul.h.t */ - {3,22,rrr,V,S,V}, /* mul.w.t */ - {3,23,rrr,V,S,V}, /* mul.l.t */ - {4,20,rrr,V,V,V}, /* div.b.t */ - {4,21,rrr,V,V,V}, /* div.h.t */ - {4,22,rrr,V,V,V}, /* div.w.t */ - {4,23,rrr,V,V,V}, /* div.l.t */ - {4,20,rrr,V,S,V}, /* div.b.t */ - {4,21,rrr,V,S,V}, /* div.h.t */ - {4,22,rrr,V,S,V}, /* div.w.t */ - {4,23,rrr,V,S,V}, /* div.l.t */ -}; -struct formstr e1_format1[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {26,20,a2r,S,0,0}, /* ste.b.t */ - {26,21,a2r,S,0,0}, /* ste.h.t */ - {26,22,a2r,S,0,0}, /* ste.w.t */ - {26,23,a2r,S,0,0}, /* ste.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {18,20,a1r,V,0,0}, /* ld.b.t */ - {18,21,a1r,V,0,0}, /* ld.h.t */ - {18,22,a1r,V,0,0}, /* ld.w.t */ - {18,23,a1r,V,0,0}, /* ld.l.t */ - {21,20,a2r,V,0,0}, /* st.b.t */ - {21,21,a2r,V,0,0}, /* st.h.t */ - {21,22,a2r,V,0,0}, /* st.w.t */ - {21,23,a2r,V,0,0}, /* st.l.t */ -}; -struct formstr e1_format2[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {28,20,rr,V,V,0}, /* cvtw.b.t */ - {28,21,rr,V,V,0}, /* cvtw.h.t */ - {29,22,rr,V,V,0}, /* cvtb.w.t */ - {30,22,rr,V,V,0}, /* cvth.w.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {31,23,rr,V,V,0}, /* cvts.l.t */ - {32,22,rr,V,V,0}, /* cvtd.w.t */ - {33,18,rr,V,V,0}, /* cvtl.s.t */ - {28,19,rr,V,V,0}, /* cvtw.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,18,rr,V,V,0}, /* frint.s.t */ - {116,19,rr,V,V,0}, /* frint.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,18,rr,V,V,0}, /* sqrt.s.t */ - {81,19,rr,V,V,0}, /* sqrt.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format3[] = { - {32,18,rr,V,V,0}, /* cvtd.s.t */ - {31,19,rr,V,V,0}, /* cvts.d.t */ - {33,19,rr,V,V,0}, /* cvtl.d.t */ - {32,23,rr,V,V,0}, /* cvtd.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {36,1,rr,V,V,0}, /* tzc.t */ - {44,1,rr,V,V,0}, /* lop.t */ - {117,1,rr,V,V,0}, /* xpnd.t */ - {42,1,rr,V,V,0}, /* not.t */ - {8,1,rr,S,V,0}, /* shf.t */ - {35,24,rr,V,V,0}, /* plc.t.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {37,18,rr,V,V,0}, /* eq.s.t */ - {37,19,rr,V,V,0}, /* eq.d.t */ - {43,18,rr,V,V,0}, /* neg.s.t */ - {43,19,rr,V,V,0}, /* neg.d.t */ - {37,18,rr,S,V,0}, /* eq.s.t */ - {37,19,rr,S,V,0}, /* eq.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {40,18,rr,V,V,0}, /* le.s.t */ - {40,19,rr,V,V,0}, /* le.d.t */ - {41,18,rr,V,V,0}, /* lt.s.t */ - {41,19,rr,V,V,0}, /* lt.d.t */ - {40,18,rr,S,V,0}, /* le.s.t */ - {40,19,rr,S,V,0}, /* le.d.t */ - {41,18,rr,S,V,0}, /* lt.s.t */ - {41,19,rr,S,V,0}, /* lt.d.t */ - {37,20,rr,V,V,0}, /* eq.b.t */ - {37,21,rr,V,V,0}, /* eq.h.t */ - {37,22,rr,V,V,0}, /* eq.w.t */ - {37,23,rr,V,V,0}, /* eq.l.t */ - {37,20,rr,S,V,0}, /* eq.b.t */ - {37,21,rr,S,V,0}, /* eq.h.t */ - {37,22,rr,S,V,0}, /* eq.w.t */ - {37,23,rr,S,V,0}, /* eq.l.t */ - {40,20,rr,V,V,0}, /* le.b.t */ - {40,21,rr,V,V,0}, /* le.h.t */ - {40,22,rr,V,V,0}, /* le.w.t */ - {40,23,rr,V,V,0}, /* le.l.t */ - {40,20,rr,S,V,0}, /* le.b.t */ - {40,21,rr,S,V,0}, /* le.h.t */ - {40,22,rr,S,V,0}, /* le.w.t */ - {40,23,rr,S,V,0}, /* le.l.t */ - {41,20,rr,V,V,0}, /* lt.b.t */ - {41,21,rr,V,V,0}, /* lt.h.t */ - {41,22,rr,V,V,0}, /* lt.w.t */ - {41,23,rr,V,V,0}, /* lt.l.t */ - {41,20,rr,S,V,0}, /* lt.b.t */ - {41,21,rr,S,V,0}, /* lt.h.t */ - {41,22,rr,S,V,0}, /* lt.w.t */ - {41,23,rr,S,V,0}, /* lt.l.t */ - {43,20,rr,V,V,0}, /* neg.b.t */ - {43,21,rr,V,V,0}, /* neg.h.t */ - {43,22,rr,V,V,0}, /* neg.w.t */ - {43,23,rr,V,V,0}, /* neg.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format4[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format5[] = { - {51,20,rr,V,V,0}, /* ldvi.b.t */ - {51,21,rr,V,V,0}, /* ldvi.h.t */ - {51,22,rr,V,V,0}, /* ldvi.w.t */ - {51,23,rr,V,V,0}, /* ldvi.l.t */ - {28,18,rr,V,V,0}, /* cvtw.s.t */ - {31,22,rr,V,V,0}, /* cvts.w.t */ - {28,23,rr,V,V,0}, /* cvtw.l.t */ - {33,22,rr,V,V,0}, /* cvtl.w.t */ - {52,20,rxr,V,V,0}, /* stvi.b.t */ - {52,21,rxr,V,V,0}, /* stvi.h.t */ - {52,22,rxr,V,V,0}, /* stvi.w.t */ - {52,23,rxr,V,V,0}, /* stvi.l.t */ - {52,20,rxr,S,V,0}, /* stvi.b.t */ - {52,21,rxr,S,V,0}, /* stvi.h.t */ - {52,22,rxr,S,V,0}, /* stvi.w.t */ - {52,23,rxr,S,V,0}, /* stvi.l.t */ -}; -struct formstr e1_format6[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format7[] = { - {84,20,r,V,0,0}, /* sum.b.t */ - {84,21,r,V,0,0}, /* sum.h.t */ - {84,22,r,V,0,0}, /* sum.w.t */ - {84,23,r,V,0,0}, /* sum.l.t */ - {85,1,r,V,0,0}, /* all.t */ - {86,1,r,V,0,0}, /* any.t */ - {87,1,r,V,0,0}, /* parity.t */ - {0,0,0,0,0,0}, - {88,20,r,V,0,0}, /* max.b.t */ - {88,21,r,V,0,0}, /* max.h.t */ - {88,22,r,V,0,0}, /* max.w.t */ - {88,23,r,V,0,0}, /* max.l.t */ - {89,20,r,V,0,0}, /* min.b.t */ - {89,21,r,V,0,0}, /* min.h.t */ - {89,22,r,V,0,0}, /* min.w.t */ - {89,23,r,V,0,0}, /* min.l.t */ - {84,18,r,V,0,0}, /* sum.s.t */ - {84,19,r,V,0,0}, /* sum.d.t */ - {90,18,r,V,0,0}, /* prod.s.t */ - {90,19,r,V,0,0}, /* prod.d.t */ - {88,18,r,V,0,0}, /* max.s.t */ - {88,19,r,V,0,0}, /* max.d.t */ - {89,18,r,V,0,0}, /* min.s.t */ - {89,19,r,V,0,0}, /* min.d.t */ - {90,20,r,V,0,0}, /* prod.b.t */ - {90,21,r,V,0,0}, /* prod.h.t */ - {90,22,r,V,0,0}, /* prod.w.t */ - {90,23,r,V,0,0}, /* prod.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -char *lop[] = { - "mov", /* 0 */ - "merg", /* 1 */ - "mask", /* 2 */ - "mul", /* 3 */ - "div", /* 4 */ - "and", /* 5 */ - "or", /* 6 */ - "xor", /* 7 */ - "shf", /* 8 */ - "add", /* 9 */ - "sub", /* 10 */ - "exit", /* 11 */ - "jmp", /* 12 */ - "jmpi", /* 13 */ - "jmpa", /* 14 */ - "jmps", /* 15 */ - "tac", /* 16 */ - "ldea", /* 17 */ - "ld", /* 18 */ - "tas", /* 19 */ - "pshea", /* 20 */ - "st", /* 21 */ - "call", /* 22 */ - "calls", /* 23 */ - "callq", /* 24 */ - "pfork", /* 25 */ - "ste", /* 26 */ - "incr", /* 27 */ - "cvtw", /* 28 */ - "cvtb", /* 29 */ - "cvth", /* 30 */ - "cvts", /* 31 */ - "cvtd", /* 32 */ - "cvtl", /* 33 */ - "ldpa", /* 34 */ - "plc", /* 35 */ - "tzc", /* 36 */ - "eq", /* 37 */ - "leu", /* 38 */ - "ltu", /* 39 */ - "le", /* 40 */ - "lt", /* 41 */ - "not", /* 42 */ - "neg", /* 43 */ - "lop", /* 44 */ - "cprs", /* 45 */ - "nop", /* 46 */ - "br", /* 47 */ - "bri", /* 48 */ - "bra", /* 49 */ - "brs", /* 50 */ - "ldvi", /* 51 */ - "stvi", /* 52 */ - "ldsdr", /* 53 */ - "ldkdr", /* 54 */ - "ln", /* 55 */ - "patu", /* 56 */ - "pate", /* 57 */ - "pich", /* 58 */ - "plch", /* 59 */ - "idle", /* 60 */ - "rtnq", /* 61 */ - "cfork", /* 62 */ - "rtn", /* 63 */ - "wfork", /* 64 */ - "join", /* 65 */ - "rtnc", /* 66 */ - "exp", /* 67 */ - "sin", /* 68 */ - "cos", /* 69 */ - "psh", /* 70 */ - "pop", /* 71 */ - "eni", /* 72 */ - "dsi", /* 73 */ - "bkpt", /* 74 */ - "msync", /* 75 */ - "mski", /* 76 */ - "xmti", /* 77 */ - "tstvv", /* 78 */ - "diag", /* 79 */ - "pbkpt", /* 80 */ - "sqrt", /* 81 */ - "casr", /* 82 */ - "atan", /* 83 */ - "sum", /* 84 */ - "all", /* 85 */ - "any", /* 86 */ - "parity", /* 87 */ - "max", /* 88 */ - "min", /* 89 */ - "prod", /* 90 */ - "halt", /* 91 */ - "sysc", /* 92 */ - "trap", /* 93 */ - "tst", /* 94 */ - "lck", /* 95 */ - "ulk", /* 96 */ - "spawn", /* 97 */ - "ldcmr", /* 98 */ - "stcmr", /* 99 */ - "popr", /* 100 */ - "pshr", /* 101 */ - "rcvr", /* 102 */ - "matm", /* 103 */ - "sndr", /* 104 */ - "putr", /* 105 */ - "getr", /* 106 */ - "matr", /* 107 */ - "mat", /* 108 */ - "get", /* 109 */ - "rcv", /* 110 */ - "inc", /* 111 */ - "put", /* 112 */ - "snd", /* 113 */ - "enal", /* 114 */ - "enag", /* 115 */ - "frint", /* 116 */ - "xpnd", /* 117 */ - "ctrsl", /* 118 */ - "ctrsg", /* 119 */ - "stop", /* 120 */ -}; -char *rop[] = { - "", /* 0 */ - ".t", /* 1 */ - ".f", /* 2 */ - ".s", /* 3 */ - ".d", /* 4 */ - ".b", /* 5 */ - ".h", /* 6 */ - ".w", /* 7 */ - ".l", /* 8 */ - ".x", /* 9 */ - ".u", /* 10 */ - ".s.f", /* 11 */ - ".d.f", /* 12 */ - ".b.f", /* 13 */ - ".h.f", /* 14 */ - ".w.f", /* 15 */ - ".l.f", /* 16 */ - ".t.f", /* 17 */ - ".s.t", /* 18 */ - ".d.t", /* 19 */ - ".b.t", /* 20 */ - ".h.t", /* 21 */ - ".w.t", /* 22 */ - ".l.t", /* 23 */ - ".t.t", /* 24 */ -}; diff --git a/gnu/usr.bin/gdb/config/convex-pinsn.c b/gnu/usr.bin/gdb/config/convex-pinsn.c deleted file mode 100644 index b0b4e29d41b3..000000000000 --- a/gnu/usr.bin/gdb/config/convex-pinsn.c +++ /dev/null @@ -1,318 +0,0 @@ -/* Print Convex instructions for GDB, the GNU debugger. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: convex-pinsn.c,v 1.2 1993/08/02 17:39:43 mycroft Exp $"; -#endif /* not lint */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" - -/* reg (fmt_field, inst_field) -- - the {first,second,third} operand of instruction as fmt_field = [ijk] - gets the value of the field from the [ijk] position of the instruction */ - -#define reg(a,b) ((char (*)[3])(op[fmt->a]))[inst.f0.b] - -/* lit (fmt_field) -- field [ijk] is a literal (PSW, VL, eg) */ - -#define lit(i) op[fmt->i] - -/* aj[j] -- name for A register j */ - -#define aj ((char (*)[3])(op[A])) - -union inst { - struct { - unsigned : 7; - unsigned i : 3; - unsigned j : 3; - unsigned k : 3; - unsigned : 16; - unsigned : 32; - } f0; - struct { - unsigned : 8; - unsigned indir : 1; - unsigned len : 1; - unsigned j : 3; - unsigned k : 3; - unsigned : 16; - unsigned : 32; - } f1; - unsigned char byte[8]; - unsigned short half[4]; - char signed_byte[8]; - short signed_half[4]; -}; - -struct opform { - int mask; /* opcode mask */ - int shift; /* opcode align */ - struct formstr *formstr[3]; /* ST, E0, E1 */ -}; - -struct formstr { - unsigned lop:8, rop:5; /* opcode */ - unsigned fmt:5; /* inst format */ - unsigned i:5, j:5, k:2; /* operand formats */ -}; - -#include "convex-opcode.h" - -unsigned char formdecode [] = { - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, - 4,4,4,4,4,4,4,4,5,5,5,5,6,6,7,8, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -}; - -struct opform opdecode[] = { - 0x7e00, 9, format0, e0_format0, e1_format0, - 0x3f00, 8, format1, e0_format1, e1_format1, - 0x1fc0, 6, format2, e0_format2, e1_format2, - 0x0fc0, 6, format3, e0_format3, e1_format3, - 0x0700, 8, format4, e0_format4, e1_format4, - 0x03c0, 6, format5, e0_format5, e1_format5, - 0x01f8, 3, format6, e0_format6, e1_format6, - 0x00f8, 3, format7, e0_format7, e1_format7, - 0x0000, 0, formatx, formatx, formatx, - 0x0f80, 7, formatx, formatx, formatx, - 0x0f80, 7, formatx, formatx, formatx, -}; - -/* Print the instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - union inst inst; - struct formstr *fmt; - register int format, op1, pfx; - int l; - - read_memory (memaddr, &inst, sizeof inst); - - /* Remove and note prefix, if present */ - - pfx = inst.half[0]; - if ((pfx & 0xfff0) == 0x7ef0) - { - pfx = ((pfx >> 3) & 1) + 1; - *(long long *) &inst = *(long long *) &inst.half[1]; - } - else pfx = 0; - - /* Split opcode into format.op1 and look up in appropriate table */ - - format = formdecode[inst.byte[0]]; - op1 = (inst.half[0] & opdecode[format].mask) >> opdecode[format].shift; - if (format == 9) - { - if (pfx) - fmt = formatx; - else if (inst.f1.j == 0) - fmt = &format1a[op1]; - else if (inst.f1.j == 1) - fmt = &format1b[op1]; - else - fmt = formatx; - } - else - fmt = &opdecode[format].formstr[pfx][op1]; - - /* Print it */ - - if (fmt->fmt == xxx) - { - /* noninstruction */ - fprintf (stream, "0x%04x", pfx ? pfx : inst.half[0]); - return 2; - } - - if (pfx) - pfx = 2; - - fprintf (stream, "%s%s%s", lop[fmt->lop], rop[fmt->rop], - &" "[strlen(lop[fmt->lop]) + strlen(rop[fmt->rop])]); - - switch (fmt->fmt) - { - case rrr: /* three register */ - fprintf (stream, "%s,%s,%s", reg(i,i), reg(j,j), reg(k,k)); - return pfx + 2; - - case rr: /* two register */ - fprintf (stream, "%s,%s", reg(i,j), reg(j,k)); - return pfx + 2; - - case rxr: /* two register, reversed i and j fields */ - fprintf (stream, "%s,%s", reg(i,k), reg(j,j)); - return pfx + 2; - - case r: /* one register */ - fprintf (stream, "%s", reg(i,k)); - return pfx + 2; - - case nops: /* no operands */ - return pfx + 2; - - case nr: /* short immediate, one register */ - fprintf (stream, "#%d,%s", inst.f0.j, reg(i,k)); - return pfx + 2; - - case pcrel: /* pc relative */ - print_address (memaddr + 2 * inst.signed_byte[1], stream); - return pfx + 2; - - case lr: /* literal, one register */ - fprintf (stream, "%s,%s", lit(i), reg(j,k)); - return pfx + 2; - - case rxl: /* one register, literal */ - fprintf (stream, "%s,%s", reg(i,k), lit(j)); - return pfx + 2; - - case rlr: /* register, literal, register */ - fprintf (stream, "%s,%s,%s", reg(i,j), lit(j), reg(k,k)); - return pfx + 2; - - case rrl: /* register, register, literal */ - fprintf (stream, "%s,%s,%s", reg(i,j), reg(j,k), lit(k)); - return pfx + 2; - - case iml: /* immediate, literal */ - if (inst.f1.len) - { - fprintf (stream, "#%#x,%s", - (inst.signed_half[1] << 16) + inst.half[2], lit(i)); - return pfx + 6; - } - else - { - fprintf (stream, "#%d,%s", inst.signed_half[1], lit(i)); - return pfx + 4; - } - - case imr: /* immediate, register */ - if (inst.f1.len) - { - fprintf (stream, "#%#x,%s", - (inst.signed_half[1] << 16) + inst.half[2], reg(i,k)); - return pfx + 6; - } - else - { - fprintf (stream, "#%d,%s", inst.signed_half[1], reg(i,k)); - return pfx + 4; - } - - case a1r: /* memory, register */ - l = print_effa (inst, stream); - fprintf (stream, ",%s", reg(i,k)); - return pfx + l; - - case a1l: /* memory, literal */ - l = print_effa (inst, stream); - fprintf (stream, ",%s", lit(i)); - return pfx + l; - - case a2r: /* register, memory */ - fprintf (stream, "%s,", reg(i,k)); - return pfx + print_effa (inst, stream); - - case a2l: /* literal, memory */ - fprintf (stream, "%s,", lit(i)); - return pfx + print_effa (inst, stream); - - case a3: /* memory */ - return pfx + print_effa (inst, stream); - - case a4: /* system call */ - l = 29; goto a4a5; - case a5: /* trap */ - l = 27; - a4a5: - if (inst.f1.len) - { - unsigned int m = (inst.signed_half[1] << 16) + inst.half[2]; - fprintf (stream, "#%d,#%d", m >> l, m & (-1 >> (32-l))); - return pfx + 6; - } - else - { - unsigned int m = inst.signed_half[1]; - fprintf (stream, "#%d,#%d", m >> l, m & (-1 >> (32-l))); - return pfx + 4; - } - } -} - - -/* print effective address @nnn(aj), return instruction length */ - -int print_effa (inst, stream) - union inst inst; - FILE *stream; -{ - int n, l; - - if (inst.f1.len) - { - n = (inst.signed_half[1] << 16) + inst.half[2]; - l = 6; - } - else - { - n = inst.signed_half[1]; - l = 4; - } - - if (inst.f1.indir) - printf ("@"); - - if (!inst.f1.j) - { - print_address (n, stream); - return l; - } - - fprintf (stream, (n & 0xf0000000) == 0x80000000 ? "%#x(%s)" : "%d(%s)", - n, aj[inst.f1.j]); - - return l; -} diff --git a/gnu/usr.bin/gdb/config/default-dep.c b/gnu/usr.bin/gdb/config/default-dep.c deleted file mode 100644 index 74496e4a4caa..000000000000 --- a/gnu/usr.bin/gdb/config/default-dep.c +++ /dev/null @@ -1,586 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)default-dep.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: default-dep.c,v 1.2 1993/08/01 18:48:27 mycroft Exp $"; -#endif /* not lint */ - -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -/* #include Can we live without this? */ - -#ifdef COFF_ENCAPSULATE -#include "a.out.encap.h" -#else -#include -#endif -#ifndef N_SET_MAGIC -#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val)) -#endif - -#include /* After a.out.h */ -#include -#include - -extern int errno; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -void -fetch_inferior_registers () -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - struct user u; - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - struct user u; - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - if (regno >= 0) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - else for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing all regs, number %d", regno); - perror_with_name (buf); - } - } -} - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; -#if 0 - /* This is now done by read_memory, because when this function did it, - reading a byte or short int hardware port read whole longs, causing - serious side effects - such as bus errors and unexpected hardware operation. This would - also be a problem with ptrace if the inferior process could read - or write hardware registers, but that's not usually the case. */ - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else -#endif - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - return (remote_write_inferior_memory(memaddr, myaddr, len)); - - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - buffer[count - 1] = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - - unsigned int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name ("Not a core file: reading upage"); - if (val != sizeof u) - error ("Not a core file: could only read %d bytes", val); - - /* We are depending on exec_file_command having been called - previously to set exec_data_start. Since the executable - and the core file share the same text segment, the address - of the data segment will be the same in both. */ - data_start = exec_data_start; - - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - - /* Some machines put an absolute address in here and some put - the offset in the upage of the regs. */ - reg_offset = (int) u.u_ar0; - if (reg_offset > NBPG * UPAGES) - reg_offset -= KERNEL_U_ADDR; - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - N_SET_MAGIC (core_aouthdr, 0); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0 - || (val = myread (corechan, buf, sizeof buf)) < 0) - { - char * buffer = (char *) alloca (strlen (reg_names[regno]) - + 30); - strcpy (buffer, "Reading register "); - strcat (buffer, reg_names[regno]); - - perror_with_name (buffer); - } - - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - -#ifdef HEADER_SEEK_FD - HEADER_SEEK_FD (execchan); -#endif - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_TXTADDR (exec_aouthdr); - exec_data_start = N_DATADDR (exec_aouthdr); - - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - if (fstat (execchan, &st_exec) < 0) - perror_with_name (filename); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} diff --git a/gnu/usr.bin/gdb/config/gld-pinsn.c b/gnu/usr.bin/gdb/config/gld-pinsn.c deleted file mode 100644 index e14de9041e53..000000000000 --- a/gnu/usr.bin/gdb/config/gld-pinsn.c +++ /dev/null @@ -1,294 +0,0 @@ -/* Print GOULD RISC instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: gld-pinsn.c,v 1.2 1993/08/02 17:39:44 mycroft Exp $"; -#endif /* not lint */ - -#include -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "opcode.h" - -/* GOULD RISC instructions are never longer than this many bytes. */ -#define MAXLEN 4 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof gld_opcodes / sizeof gld_opcodes[0]) - - -/* Print the GOULD instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register char *d; - register int bestmask; - unsigned best; - int temp, index, bestlen; - - read_memory (memaddr, buffer, MAXLEN); - - bestmask = 0; - index = -1; - best = 0xffffffff; - for (i = 0; i < NOPCODES; i++) - { - register unsigned int opcode = gld_opcodes[i].opcode; - register unsigned int mask = gld_opcodes[i].mask; - register unsigned int len = gld_opcodes[i].length; - register unsigned int test; - - /* Get possible opcode bytes into integer */ - test = buffer[0] << 24; - test |= buffer[1] << 16; - test |= buffer[2] << 8; - test |= buffer[3]; - - /* Mask with opcode and see if match */ - if ((opcode & mask) == (test & mask)) - { - /* See if second or third match */ - if (index >= 0) - { - /* Take new one if it looks good */ - if (bestlen == MAXLEN && len == MAXLEN) - { - /* See if lower bits matched */ - if (((bestmask & 3) == 0) && - ((mask & 3) != 0)) - { - bestmask = mask; - bestlen = len; - best = test; - index = i; - } - } - } - else - { - /* First match, save it */ - bestmask = mask; - bestlen = len; - best = test; - index = i; - } - } - } - - /* Handle undefined instructions. */ - if (index < 0) - { - fprintf (stream, "undefined 0%o",(buffer[0]<<8)+buffer[1]); - return 2; - } - - /* Print instruction name */ - fprintf (stream, "%-12s", gld_opcodes[index].name); - - /* Adjust if short instruction */ - if (gld_opcodes[index].length < 4) - { - best >>= 16; - i = 0; - } - else - { - i = 16; - } - - /* Dump out instruction arguments */ - for (d = gld_opcodes[index].args; *d; ++d) - { - switch (*d) - { - case 'f': - fprintf (stream, "%d", (best >> (7 + i)) & 7); - break; - case 'r': - fprintf (stream, "r%d", (best >> (7 + i)) & 7); - break; - case 'R': - fprintf (stream, "r%d", (best >> (4 + i)) & 7); - break; - case 'b': - fprintf (stream, "b%d", (best >> (7 + i)) & 7); - break; - case 'B': - fprintf (stream, "b%d", (best >> (4 + i)) & 7); - break; - case 'v': - fprintf (stream, "b%d", (best >> (7 + i)) & 7); - break; - case 'V': - fprintf (stream, "b%d", (best >> (4 + i)) & 7); - break; - case 'X': - temp = (best >> 20) & 7; - if (temp) - fprintf (stream, "r%d", temp); - else - putc ('0', stream); - break; - case 'A': - temp = (best >> 16) & 7; - if (temp) - fprintf (stream, "(b%d)", temp); - break; - case 'S': - fprintf (stream, "#%d", best & 0x1f); - break; - case 'I': - fprintf (stream, "#%x", best & 0xffff); - break; - case 'O': - fprintf (stream, "%x", best & 0xffff); - break; - case 'h': - fprintf (stream, "%d", best & 0xfffe); - break; - case 'd': - fprintf (stream, "%d", best & 0xfffc); - break; - case 'T': - fprintf (stream, "%d", (best >> 8) & 0xff); - break; - case 'N': - fprintf (stream, "%d", best & 0xff); - break; - default: - putc (*d, stream); - break; - } - } - - /* Return length of instruction */ - return (gld_opcodes[index].length); -} - -/* - * Find the number of arguments to a function. - */ -findarg(frame) - struct frame_info *frame; -{ - register struct symbol *func; - register unsigned pc; - -#ifdef notdef - /* find starting address of frame function */ - pc = get_pc_function_start (frame->pc); - - /* find function symbol info */ - func = find_pc_function (pc); - - /* call blockframe code to look for match */ - if (func != NULL) - return (func->value.block->nsyms / sizeof(int)); -#endif - - return (-1); -} - -/* - * In the case of the NPL, the frame's norminal address is Br2 and the - * previous routines frame is up the stack X bytes. Finding out what - * 'X' is can be tricky. - * - * 1.) stored in the code function header xA(Br1). - * 2.) must be careful of recurssion. - */ -FRAME_ADDR -findframe(thisframe) - FRAME thisframe; -{ - register FRAME_ADDR pointer; -#if 0 - struct frame_info *frame; - FRAME_ADDR framechain(); - - /* Setup toplevel frame structure */ - frame->pc = read_pc(); - frame->next_frame = 0; - frame->frame = read_register (SP_REGNUM); /* Br2 */ - - /* Search for this frame (start at current Br2) */ - do - { - pointer = framechain(frame); - frame->next_frame = frame->frame; - frame->frame = pointer; - frame->pc = FRAME_SAVED_PC(frame); - } - while (frame->next_frame != thisframe); -#endif - - pointer = framechain (thisframe); - - /* stop gap for now, end at __base3 */ - if (thisframe->pc == 0) - return 0; - - return pointer; -} - -/* - * Gdb front-end and internal framechain routine. - * Go back up stack one level. Tricky... - */ -FRAME_ADDR -framechain(frame) - register struct frame_info *frame; -{ - register CORE_ADDR func, prevsp; - register unsigned value; - - /* Get real function start address from internal frame address */ - func = get_pc_function_start(frame->pc); - - /* If no stack given, read register Br1 "(sp)" */ - if (!frame->frame) - prevsp = read_register (SP_REGNUM); - else - prevsp = frame->frame; - - /* Check function header, case #2 */ - value = read_memory_integer (func, 4); - if (value) - { - /* 32bit call push value stored in function header */ - prevsp += value; - } - else - { - /* read half-word from suabr at start of function */ - prevsp += read_memory_integer (func + 10, 2); - } - - return (prevsp); -} diff --git a/gnu/usr.bin/gdb/config/gould-dep.c b/gnu/usr.bin/gdb/config/gould-dep.c deleted file mode 100644 index 524b14cebc17..000000000000 --- a/gnu/usr.bin/gdb/config/gould-dep.c +++ /dev/null @@ -1,564 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: gould-dep.c,v 1.2 1993/08/02 17:39:45 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -extern int errno; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -void -fetch_inferior_registers () -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - struct user u; - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - struct user u; - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - if (regno >= 0) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - else for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } -} - -/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory - in the NEW_SUN_PTRACE case. - It ought to be straightforward. But it appears that writing did - not write the data that I specified. I cannot understand where - it got the data that it actually did write. */ - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - buffer[0] = remote_fetch_word (addr); - else - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - if (remote_debugging) - buffer[count - 1] - = remote_fetch_word (addr + (count - 1) * sizeof (int)); - else - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - remote_store_word (addr, buffer[i]); - else - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -/* This should probably be deleted. */ -/* Recognize COFF format systems because a.out.h defines AOUTHDR. */ -#ifdef AOUTHDR -#define COFF_FORMAT -#endif - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - core_aouthdr.a_magic = 0; - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - - FILHDR exec_coffhdr; - - val = myread (execchan, &exec_coffhdr, sizeof exec_coffhdr); - if (val < 0) - perror_with_name (filename); - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_TXTADDR (exec_aouthdr); - exec_data_start = N_DATADDR (exec_aouthdr); - - text_offset = N_TXTOFF (exec_coffhdr, exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_coffhdr, exec_aouthdr) - + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} diff --git a/gnu/usr.bin/gdb/config/hp300bsd-dep.c b/gnu/usr.bin/gdb/config/hp300bsd-dep.c deleted file mode 100644 index 1832773dc252..000000000000 --- a/gnu/usr.bin/gdb/config/hp300bsd-dep.c +++ /dev/null @@ -1,1160 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)hp300bsd-dep.c 6.10 (Berkeley) 5/12/91";*/ -static char rcsid[] = "$Id: hp300bsd-dep.c,v 1.3 1993/08/10 00:12:42 mycroft Exp $"; -#endif /* not lint */ - -/* - * Machine-dependent code for a Hewlett-Packard 9000/300, running bsd. - * Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - * - * This file is part of GDB. - * - * GDB 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. - * - * GDB 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 - * GDB; see the file COPYING. If not, write to the Free Software Foundation, - * 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "value.h" - - -#include -#include -#include -#include -/* #include Can we live without this? */ - -#include -#ifndef N_SET_MAGIC -#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val)) -#endif - -#ifdef NEWVM -#include -#endif - -#include -#include -#include -#include /* After a.out.h */ -#include -#include -#include - -CORE_ADDR kernel_u_addr; - -#ifdef KERNELDEBUG -#ifndef NEWVM -#include -#include -#endif -#include -#include -#include -#include "symtab.h" /* XXX */ - -extern int kernel_debugging; - -#define KERNOFF ((unsigned)KERNBASE) -#define LOWRAM ((unsigned)0xfffffdce) -/* actually you can't really distinguish user and kernel by address */ -#define INKERNEL(x) ((x) >= KERNOFF && (x) < KERNOFF + ctob(slr)) -#define INUDOT(x) \ - ((x) >= KERNEL_U_ADDR && (x) < KERNEL_U_ADDR + ctob(UPAGES)) - -#define PT_ADDR_ANY ((caddr_t) 1) - -/* - * Convert from sysmap pte index to system virtual address & vice-versa. - * (why aren't these in one of the system vm macro files???) - */ -#define smxtob(a) (sbr + (a) * sizeof(pte)) -#define btosmx(b) (((b) - sbr) / sizeof(pte)) - -static int ok_to_cache(); -#ifdef NEWVM -static int found_pcb; -static CORE_ADDR curpcb; -static CORE_ADDR kstack; -#endif -#endif - -extern int errno; - -/* - * This function simply calls ptrace with the given arguments. It exists so - * that all calls to ptrace are isolated in this machine-dependent file. - */ -int -call_ptrace(request, pid, arg3, arg4) - int request; - pid_t pid; - caddr_t arg3; - int arg4; -{ - return(ptrace(request, pid, arg3, arg4)); -} - -kill_inferior() -{ - if (remote_debugging) { -#ifdef KERNELDEBUG - if (kernel_debugging) - /* - * It's a very, very bad idea to go away leaving - * breakpoints in a remote kernel or to leave it - * stopped at a breakpoint. - */ - clear_breakpoints(); -#endif - remote_close(0); - inferior_died(); - } else if (inferior_pid != 0) { - ptrace(PT_KILL, inferior_pid, 0, 0); - wait(0); - inferior_died(); - } -} - -/* - * This is used when GDB is exiting. It gives less chance of error. - */ -kill_inferior_fast() -{ - if (remote_debugging) { -#ifdef KERNELDEBUG - if (kernel_debugging) - clear_breakpoints(); -#endif - remote_close(0); - return; - } - if (inferior_pid == 0) - return; - - ptrace(PT_KILL, inferior_pid, 0, 0); - wait(0); -} - -/* - * Resume execution of the inferior process. If STEP is nonzero, single-step - * it. If SIGNAL is nonzero, give it that signal. - */ -void -resume(step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume(step, signal); - else { - ptrace(step ? PT_STEP : PT_CONTINUE, inferior_pid, - PT_ADDR_ANY, signal); - if (errno) - perror_with_name("ptrace"); - } -} - -#ifdef ATTACH_DETACH -extern int attach_flag; - -/* - * Start debugging the process whose number is PID. - */ -attach(pid) - int pid; -{ - errno = 0; - ptrace(PT_ATTACH, pid, 0, 0); - if (errno) - perror_with_name("ptrace"); - attach_flag = 1; - return pid; -} - -/* - * Stop debugging the process whose number is PID and continue it - * with signal number SIGNAL. SIGNAL = 0 means just continue it. - */ -void -detach(signal) - int signal; -{ - errno = 0; - ptrace(PT_DETACH, inferior_pid, PT_ADDR_ANY, signal); - if (errno) - perror_with_name("ptrace"); - attach_flag = 0; -} -#endif /* ATTACH_DETACH */ - -static unsigned int -get_register_offset() -{ - unsigned int offset; - struct user u; /* XXX */ - -#ifdef NEWVM - offset = (char *) &u.u_kproc.kp_proc.p_regs - (char *) &u; - offset = ptrace(PT_READ_U, inferior_pid, (caddr_t)offset, 0) - - USRSTACK; -#else - offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace(PT_READ_U, inferior_pid, (caddr_t)offset, 0) - - KERNEL_U_ADDR; -#endif - return offset; -} - -void -fetch_inferior_registers() -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - unsigned int offset; - - if (remote_debugging) { - extern char registers[]; - - remote_fetch_registers(registers); - return; - } - - offset = get_register_offset(); - - for (regno = 0; regno < NUM_REGS; regno++) { - regaddr = register_addr(regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE(regno); i += sizeof(int)) { - *(int *)&buf[i] = ptrace(PT_READ_U, inferior_pid, - (caddr_t)regaddr, 0); - regaddr += sizeof(int); - } - supply_register(regno, buf); - } -} - -/* - * Store our register values back into the inferior. If REGNO is -1, do this - * for all registers. Otherwise, REGNO specifies which register (so we can - * save time). - */ -store_inferior_registers(regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - extern char registers[]; - register int i; - unsigned int offset; - - if (remote_debugging) { - extern char registers[]; - - remote_store_registers(registers); - return; - } - - offset = get_register_offset(); - - if (regno >= 0) { - regaddr = register_addr(regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE(regno); i += sizeof(int)) { - errno = 0; - ptrace(PT_WRITE_U, inferior_pid, (caddr_t)regaddr, - *(int *) ®isters[REGISTER_BYTE(regno) + i]); - if (errno != 0) { - sprintf(buf, "writing register number %d(%d)", - regno, i); - perror_with_name(buf); - } - regaddr += sizeof(int); - } - } else - for (regno = 0; regno < NUM_REGS; regno++) { - regaddr = register_addr(regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE(regno); - i += sizeof(int)) { - errno = 0; - ptrace(PT_WRITE_U, inferior_pid, - (caddr_t)regaddr, - *(int *) ®isters[REGISTER_BYTE(regno) + i]); - if (errno != 0) { - sprintf(buf, - "writing register number %d(%d)", - regno, i); - perror_with_name(buf); - } - regaddr += sizeof(int); - } - } -} - -/* - * Copy LEN bytes from inferior's memory starting at MEMADDR to debugger - * memory starting at MYADDR. On failure (cannot read from inferior, usually - * because address is out of bounds) returns the value of errno. - */ -int -read_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & -sizeof(int); - /* Round ending address up; get number of longwords that makes. */ - register int count = (((memaddr + len) - addr) + sizeof(int) - 1) / - sizeof(int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca(count * sizeof(int)); - extern int errno; - - if (remote_debugging) - return (remote_read_inferior_memory(memaddr, myaddr, len)); - - /* Read all the longwords */ - errno = 0; - for (i = 0; i < count && errno == 0; i++, addr += sizeof(int)) - buffer[i] = ptrace(PT_READ_I, inferior_pid, (caddr_t)addr, 0); - - /* Copy appropriate bytes out of the buffer. */ - bcopy((char *) buffer + (memaddr & (sizeof(int) - 1)), myaddr, len); - return(errno); -} - -/* - * Copy LEN bytes of data from debugger memory at MYADDR to inferior's memory - * at MEMADDR. On failure (cannot write the inferior) returns the value of - * errno. - */ - -int -write_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & -sizeof(int); - /* Round ending address up; get number of longwords that makes. */ - register int count = (((memaddr + len) - addr) + sizeof(int) - 1) / - sizeof(int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca(count * sizeof(int)); - extern int errno; - - /* - * Fill start and end extra bytes of buffer with existing memory - * data. - */ - if (remote_debugging) - return (remote_write_inferior_memory(memaddr, myaddr, len)); - - /* - * Fill start and end extra bytes of buffer with existing memory - * data. - */ - buffer[0] = ptrace(PT_READ_I, inferior_pid, (caddr_t)addr, 0); - - if (count > 1) - buffer[count - 1] = ptrace(PT_READ_I, inferior_pid, - (caddr_t)addr + (count - 1) * sizeof(int), 0); - - /* Copy data to be written over corresponding part of buffer */ - - bcopy(myaddr, (char *) buffer + (memaddr & (sizeof(int) - 1)), len); - - /* Write the entire buffer. */ - - errno = 0; - for (i = 0; i < count && errno == 0; i++, addr += sizeof(int)) - ptrace(PT_WRITE_I, inferior_pid, (caddr_t)addr, buffer[i]); - - return(errno); -} - - -/* - * Work with core dump and executable files, for GDB. - * This code would be in core.c if it weren't machine-dependent. - */ - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* - * Make COFF and non-COFF names for things a little more compatible to reduce - * conditionals later. - */ - - -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files(); - - -extern int (*core_file_hook)(); - -#ifdef KERNELDEBUG -/* - * Kernel debugging routines. - */ - -static CORE_ADDR file_offset; -static CORE_ADDR lowram; -static CORE_ADDR sbr; -static CORE_ADDR slr; -static struct pcb pcb; -static CORE_ADDR kernel_udot_va; - -#ifndef CFSIZE -#include -#endif - -static CORE_ADDR -ksym_lookup(name) - char *name; -{ - struct symbol *sym; - int i; - - if ((i = lookup_misc_func(name)) < 0) - error("kernel symbol `%s' not found.", name); - - return (misc_function_vector[i].address); -} - -/* - * return true if 'len' bytes starting at 'addr' can be read out as - * longwords and/or locally cached (this is mostly for memory mapped - * i/o register access when debugging remote kernels). - */ -static int -ok_to_cache(addr, len) -{ -#ifdef NEWVM - static CORE_ADDR intiobase, extiobase; - - if (! intiobase) { - intiobase = ksym_lookup("intiobase"); - (void)remote_read_inferior_memory(intiobase, &intiobase, - sizeof(intiobase)); - extiobase = ksym_lookup("extiobase"); - (void)remote_read_inferior_memory(extiobase, &extiobase, - sizeof(extiobase)); - } - - if (addr >= intiobase && addr < intiobase + ctob(IIOMAPSIZE)) - return (0); - if (addr >= extiobase && addr < extiobase + ctob(EIOMAPSIZE)) - return (0); -#else - static CORE_ADDR IObase; - - if (! IObase) - IObase = ksym_lookup("IObase"); - - if (addr >= IObase && addr < IObase + (IOTOP - IOBASE)) - return (0); -#endif - - return (1); -} - -static -physrd(addr, dat, len) - u_int addr; - char *dat; -{ - if (lseek(corechan, addr - file_offset, L_SET) == -1) - return (-1); - if (read(corechan, dat, len) != len) - return (-1); - - return (0); -} - -/* - * When looking at kernel data space through /dev/mem or with a core file, do - * virtual memory mapping. - */ -#ifdef NEWVM -static CORE_ADDR -vtophys(addr) - CORE_ADDR addr; -{ - CORE_ADDR v; - struct pte pte; - CORE_ADDR stp; - CORE_ADDR oldaddr = addr; - static CORE_ADDR curstp = -1; - - /* - * If we're looking at the kernel stack, - * munge the address to refer to the user space mapping instead; - * that way we get the requested process's kstack, not the running one. - */ - if (addr >= kstack && addr < kstack + ctob(UPAGES)) - addr = (addr - kstack) + curpcb; - - /* - * Identify the current segment table. - * Since the given VA could come from either kernel - * or user space, the following heuristics don't always work. - */ - if (INKERNEL(addr)) - stp = sbr; - else if (found_pcb == 0) { - /* We have a pcb address, but haven't read it yet. Cheat. */ - if (curstp == -1) { - v = vtophys((CORE_ADDR)&((struct pcb *)curpcb)->pcb_ustp); - physrd(v, &curstp, sizeof curstp); - } - stp = curstp; - } else - stp = pcb.pcb_ustp; - - /* - * Read the current segment table. - */ - v = stp + ((addr >> SG_ISHIFT) * sizeof pte); - if (physrd(v, (char *)&pte, sizeof(pte))) - return (~0); - if (*(int *)&pte == SG_NV) - return (~0); - v = hp300_btop(addr & SG_PMASK); - addr = (CORE_ADDR)(hp300_ptob(pte.pg_pfnum) + v*sizeof pte); - - /* - * Addr is now address of the pte of the page we are interested in; - * get the pte and paste up the physical address. - */ - if (physrd(addr, (char *) &pte, sizeof(pte))) - return (~0); - if (pte.pg_v == 0 && pte.pg_pfnum == 0) - return (~0); - addr = (CORE_ADDR)hp300_ptob(pte.pg_pfnum) + (oldaddr & PGOFSET); -#if 0 - printf("vtophys(%x) -> %x\n", oldaddr, addr); -#endif - return (addr); -} -#else -static CORE_ADDR -vtophys(addr) - CORE_ADDR addr; -{ - CORE_ADDR v; - struct pte pte; - CORE_ADDR oldaddr = addr; - - /* permit direct reference to physical memory */ - if (addr >= lowram) - return (addr); - - if (kernel_udot_va && INUDOT(addr)) { - addr -= KERNEL_U_ADDR; - addr = kernel_udot_va + btop(addr) * sizeof (struct pte); - addr = vtophys(addr); - } else if (INKERNEL(addr)) { - /* - * In system space get system pte. If valid or reclaimable - * then physical address is combination of its page number - * and the page offset of the original address. - */ - v = smxtob(btop(addr - KERNOFF)); - addr = v + lowram; - } else { - /* In p0 space must not be off end of region. */ - v = btop(addr); - if (v >= pcb.pcb_p0lr) - /* address out of segment */ - return (~0); - - addr = (CORE_ADDR)(pcb.pcb_p0br + v); - /* - * For p0/p1 address, user-level page table should be in - * kernel vm. Do second-level indirect by recursing. - */ - if (!INKERNEL(addr)) - return (~0); - - addr = vtophys(addr); - } - /* - * Addr is now address of the pte of the page we are interested in; - * get the pte and paste up the physical address. - */ - if (physrd(addr, (char *) &pte, sizeof(pte))) - return (~0); - - if (pte.pg_v == 0 && (pte.pg_fod || pte.pg_pfnum == 0)) - return (~0); - - addr = (CORE_ADDR)ptob(pte.pg_pfnum) + (oldaddr & PGOFSET); -#if 0 - printf("vtophys(%x) -> %x\n", oldaddr, addr); -#endif - return (addr); -} -#endif - -static -kvread(addr) - CORE_ADDR addr; -{ - CORE_ADDR paddr = vtophys(addr); - - if (paddr != ~0) - if (physrd(paddr, (char *)&addr, sizeof(addr)) == 0); - return (addr); - - return (~0); -} - -static void -read_pcb(uaddr) - u_int uaddr; -{ - int i; - -#ifdef NEWVM - if (physrd(uaddr, (char *)&pcb, sizeof pcb)) - error("cannot read pcb at %x\n", uaddr); - printf("current pcb at %x\n", uaddr); -#else - if (physrd (uaddr, (char *)&pcb, sizeof pcb)) - error ("cannot read pcb at %x.\n", uaddr); - printf("p0br %x p0lr %x p1br %x p1lr %x\n", - pcb.pcb_p0br, pcb.pcb_p0lr, pcb.pcb_p1br, pcb.pcb_p1lr); - - kernel_udot_va = (CORE_ADDR) (pcb.pcb_p1br + BTOPUSRSTACK); -#endif - - /* - * get the register values out of the sys pcb and - * store them where `read_register' will find them. - */ - for (i = 2; i < 8; ++i) - supply_register(i, &pcb.pcb_regs[i-2]); - for (i = 10; i < 16; ++i) - supply_register(i, &pcb.pcb_regs[i-4]); - - /* fake 'scratch' regs d0, d1, a0, a1 */ - i = 0; - supply_register(0, &i); supply_register(1, &i); - supply_register(8, &i); supply_register(9, &i); - - i = kvread(pcb.pcb_regs[10] + 4); - if (i != -1) - supply_register(PC_REGNUM, &i); - - supply_register(PS_REGNUM, &pcb.pcb_ps); - - for (i = FP0_REGNUM; i < NUM_REGS; ++i) { - int fpreg; - - REGISTER_U_ADDR(fpreg, 0, i); - supply_register(i, ((char *)&pcb) + fpreg); - } -} - -static void -setup_kernel_debugging() -{ - struct stat stb; - int devmem = 0; - CORE_ADDR addr; - - fstat(corechan, &stb); - if ((stb.st_mode & S_IFMT) == S_IFCHR && stb.st_rdev == makedev(2, 0)) - devmem = 1; - - /* - * Must get value of lowram before we can read PCB. - */ - if (devmem) - /* /dev/mem == physical memory */ - (void)physrd(LOWRAM, (char *)&lowram, sizeof(lowram)); - else - /* normal file -- use standard offset */ - (void)physrd(ksym_lookup("lowram"), (char *)&lowram, - sizeof(lowram)); - lowram = roundup(lowram, NBPG); - if (! devmem) - file_offset = lowram; - - /* - * Get system mapping information. - */ -#ifdef NEWVM - sbr = ksym_lookup("Sysseg") + lowram; - (void)physrd(sbr, (char *)&sbr, sizeof(sbr)); - sbr += lowram; /* sbr is a physical address for NEWVM */ - slr = NPTEPG * (NPTEPG-1); - curpcb = ksym_lookup("curpcb") + lowram; - physrd(curpcb, &curpcb, sizeof curpcb); - kstack = ksym_lookup("kstack"); -#else - sbr = ksym_lookup("Sysmap"); - slr = ksym_lookup("Syssize"); -#endif - printf("sbr %x slr %x\n", sbr, slr); - - /* - * pcb where "panic" saved registers in first thing in current - * u area. - */ -#ifdef NEWVM - read_pcb(vtophys(kstack)); - found_pcb = 1; -#else - read_pcb(vtophys(ksym_lookup("u"))); -#endif - if (!devmem) { - /* find stack frame */ - CORE_ADDR panicstr; - char buf[256]; - register char *cp; - - panicstr = kvread(ksym_lookup("panicstr")); - if (panicstr == ~0) - return; - (void) kernel_core_file_hook(panicstr, buf, sizeof(buf)); - for (cp = buf; cp < &buf[sizeof(buf)] && *cp; cp++) - if (!isascii(*cp) || (!isprint(*cp) && !isspace(*cp))) - *cp = '?'; - if (*cp) - *cp = '\0'; - printf("panic: %s\n", buf); - } - - stack_start = USRSTACK; - stack_end = USRSTACK + ctob(UPAGES); -} - -set_paddr_command(arg) - char *arg; -{ - u_int uaddr; - - if (!arg) - error_no_arg("ps-style address for new current process"); - if (!kernel_debugging) - error("not debugging kernel"); - if (lowram == 0) - error("need kernel core file"); - uaddr = (u_int) parse_and_eval_address(arg); -#ifndef NEWVM - read_pcb(ctob(uaddr)); -#else - /* p_addr is now a pcb virtual address */ - read_pcb(vtophys(uaddr)); - curpcb = uaddr; -#endif - - flush_cached_frames(); - set_current_frame(create_new_frame(read_register(FP_REGNUM), read_pc())); - select_frame(get_current_frame(), 0); -} - -/* - * read len bytes from kernel virtual address 'addr' into local - * buffer 'buf'. Return 0 if read ok, 1 otherwise. On read - * errors, portion of buffer not read is zeroed. - */ -kernel_core_file_hook(addr, buf, len) - CORE_ADDR addr; - char *buf; - int len; -{ - int i; - CORE_ADDR paddr; - - while (len > 0) { - paddr = vtophys(addr); - if (paddr == ~0) { - bzero(buf, len); - return (1); - } - /* we can't read across a page boundary */ - i = min(len, NBPG - (addr & PGOFSET)); - if (physrd(paddr, buf, i)) { - bzero(buf, len); - return (1); - } - buf += i; - addr += i; - len -= i; - } - return (0); -} -#endif - -core_file_command(filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - unsigned int reg_offset; -#ifdef KERNELDEBUG - struct stat stb; -#endif - struct user u; - - /* - * Discard all vestiges of any previous core file and mark data and - * stack spaces as empty. - */ - if (corefile) - free(corefile); - corefile = 0; - core_file_hook = 0; - - if (corechan >= 0) - close(corechan); - corechan = -1; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename == 0) { - if (from_tty) - printf("No core file now.\n"); - return; - } - filename = tilde_expand(filename); - make_cleanup(free, filename); - if (have_inferior_p()) - error("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open(filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name(filename); - -#ifdef KERNELDEBUG - fstat(corechan, &stb); - - if (kernel_debugging) { - setup_kernel_debugging(); - core_file_hook = kernel_core_file_hook; - } else if ((stb.st_mode & S_IFMT) == S_IFCHR && - stb.st_rdev == makedev(2, 1)) { - /* looking at /dev/kmem */ - data_offset = data_start = KERNOFF; - data_end = ~0; /* XXX */ - stack_end = stack_start = data_end; - } else -#endif - { - val = myread(corechan, &u, sizeof u); - if (val < 0) - perror_with_name("Not a core file: reading upage"); - if (val != sizeof u) - error("Not a core file: could only read %d bytes", val); - - /* - * We are depending on exec_file_command having been - * called previously to set exec_data_start. Since - * the executable and the core file share the same - * text segment, the address of the data segment will - * be the same in both. - */ - data_start = exec_data_start; - -#ifndef NEWVM - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - - /* - * Some machines put an absolute address in here and - * some put the offset in the upage of the regs. - */ - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; -#else - data_end = data_start + - NBPG * u.u_kproc.kp_eproc.e_vm.vm_dsize; - stack_start = stack_end - - NBPG * u.u_kproc.kp_eproc.e_vm.vm_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * - (UPAGES + u.u_kproc.kp_eproc.e_vm.vm_dsize); - - reg_offset = (int) u.u_kproc.kp_proc.p_regs - USRSTACK; -#endif - - /* - * I don't know where to find this info. So, for now, - * mark it as not available. - */ - /* N_SET_MAGIC(core_aouthdr, 0); */ - bzero ((char *) &core_aouthdr, sizeof core_aouthdr); - - /* - * Read the register values out of the core file and - * store them where `read_register' will find them. - */ - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek(corechan, register_addr(regno, reg_offset), 0); - if (val < 0 - || (val = myread(corechan, buf, sizeof buf)) < 0) { - char *buffer = (char *) alloca(strlen(reg_names[regno]) + 30); - strcpy(buffer, "Reading register "); - strcat(buffer, reg_names[regno]); - perror_with_name(buffer); - } - supply_register(regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring(filename, strlen(filename)); - else - corefile = concat(current_directory, "/", filename); - - set_current_frame(create_new_frame(read_register(FP_REGNUM), - read_pc())); - select_frame(get_current_frame(), 0); - validate_files(); -} - - -exec_file_command(filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* - * Eliminate all traces of old exec file. Mark text segment as empty. - */ - - if (execfile) - free(execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close(execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) { - filename = tilde_expand(filename); - make_cleanup(free, filename); - - execchan = openp(getenv("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name(filename); - - { - struct stat st_exec; - -#ifdef HEADER_SEEK_FD - HEADER_SEEK_FD(execchan); -#endif - - val = myread(execchan, &exec_aouthdr, sizeof(AOUTHDR)); - - if (val < 0) - perror_with_name(filename); - - text_start = N_TXTADDR(exec_aouthdr); - exec_data_start = N_DATADDR(exec_aouthdr); - - text_offset = N_TXTOFF(exec_aouthdr); - exec_data_offset = N_TXTOFF(exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat(execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } - - validate_files(); - } else if (from_tty) - printf("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -int dummy_code[] = { - 0x4e714eb9, /* nop, jsr @#32323232 */ - 0x32323232, -#define DUMMY_CALL_INDEX 1 - 0x4e424e71, /* trap 2, nop */ -}; - -/* - * Build `dummy' call instructions on inferior's stack to cause - * it to call a subroutine. - * - * N.B. - code in wait_for_inferior requires that sp < pc < fp when - * we take the trap 2 above so it will recognize that we stopped - * at a `dummy' call. So, after the call sp is *not* decremented - * to clean the arguments, code & other stuff we lay on the stack. - * Since the regs are restored to saved values at the breakpoint, - * sp will get reset correctly. Also, this restore means we don't - * have to construct frame linkage info to save pc & fp. The lack - * of frame linkage means we can't do a backtrace, etc., if the - * called function gets a fault or hits a breakpoint but code in - * run_stack_dummy makes this impossible anyway. - */ -CORE_ADDR -setup_dummy(sp, funaddr, nargs, args, struct_return_bytes, pushfn) - CORE_ADDR sp; - CORE_ADDR funaddr; - int nargs; - value *args; - int struct_return_bytes; - CORE_ADDR (*pushfn)(); -{ - int padding, i; - CORE_ADDR top = sp, struct_addr, pc; - - i = arg_stacklen(nargs, args) + struct_return_bytes - + sizeof(dummy_code); - if (i & 3) - padding = 4 - (i & 3); - else - padding = 0; - pc = sp - sizeof(dummy_code); - sp = pc - padding - struct_return_bytes; - struct_addr = sp; - while (--nargs >= 0) - sp = (*pushfn)(sp, *args++); - if (struct_return_bytes) - STORE_STRUCT_RETURN(struct_addr, sp); - write_register(SP_REGNUM, sp); - - dummy_code[DUMMY_CALL_INDEX] = (int)funaddr; - write_memory(pc, (char *)dummy_code, sizeof(dummy_code)); - - return pc; -} - -void -_initialize_hp300bsd_dep() -{ -#ifdef KERNELDEBUG - add_com ("process-address", class_obscure, set_paddr_command, - "The process identified by (ps-style) ADDR becomes the\n\ -\"current\" process context for kernel debugging."); - add_com_alias ("paddr", "process-address", class_obscure, 0); -#endif -} diff --git a/gnu/usr.bin/gdb/config/hp9k320-dep.c b/gnu/usr.bin/gdb/config/hp9k320-dep.c deleted file mode 100644 index dd43d2cbabd3..000000000000 --- a/gnu/usr.bin/gdb/config/hp9k320-dep.c +++ /dev/null @@ -1,702 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: hp9k320-dep.c,v 1.2 1993/08/02 17:39:46 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#define WOPR -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -extern int errno; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int - call_ptrace (request, pid, arg3, arg4) -int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -#ifdef ATTACH_DETACH - -extern int attach_flag ; - -/* Start debugging the process whose number is PID. */ - -attach (pid) - int pid; -{ - errno = 0; - ptrace (PT_ATTACH, pid, 0, 0); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 1; - return pid; -} - -/* Stop debugging the process whose number is PID - and continue it with signal number SIGNAL. - SIGNAL = 0 means just continue it. */ - -void -detach (signal) - int signal; -{ - errno = 0; - ptrace (PT_DETACH, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 0; -} -#endif /* ATTACH_DETACH */ - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void - resume (step, signal) -int step; -int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -#define INFERIOR_AR0(u) \ - ((ptrace \ - (PT_RUAREA, inferior_pid, ((char *) &u.u_ar0 - (char *) &u), 0)) \ - - KERNEL_U_ADDR) - -static void - fetch_inferior_register (regno, regaddr) -register int regno; -register unsigned int regaddr; -{ -#ifndef HPUX_VERSION_5 - if (regno == PS_REGNUM) - { - union { int i; short s[2]; } ps_val; - int regval; - - ps_val.i = (ptrace (PT_RUAREA, inferior_pid, regaddr, 0)); - regval = ps_val.s[0]; - supply_register (regno, ®val); - } - else -#endif /* not HPUX_VERSION_5 */ - { - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (PT_RUAREA, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } - return; -} - -static void - store_inferior_register_1 (regno, regaddr, value) -int regno; -unsigned int regaddr; -int value; -{ - errno = 0; - ptrace (PT_WUAREA, inferior_pid, regaddr, value); -#if 0 - /* HP-UX randomly sets errno to non-zero for regno == 25. - However, the value is correctly written, so ignore errno. */ - if (errno != 0) - { - char string_buf[64]; - - sprintf (string_buf, "writing register number %d", regno); - perror_with_name (string_buf); - } -#endif - return; -} - -static void - store_inferior_register (regno, regaddr) -register int regno; -register unsigned int regaddr; -{ -#ifndef HPUX_VERSION_5 - if (regno == PS_REGNUM) - { - union { int i; short s[2]; } ps_val; - - ps_val.i = (ptrace (PT_RUAREA, inferior_pid, regaddr, 0)); - ps_val.s[0] = (read_register (regno)); - store_inferior_register_1 (regno, regaddr, ps_val.i); - } - else -#endif /* not HPUX_VERSION_5 */ - { - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - extern char registers[]; - - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - store_inferior_register_1 - (regno, regaddr, - (*(int *) ®isters[(REGISTER_BYTE (regno)) + i])); - regaddr += sizeof (int); - } - } - return; -} - -void - fetch_inferior_registers () -{ - struct user u; - register int regno; - register unsigned int ar0_offset; - extern char registers[]; - - if (remote_debugging) - remote_fetch_registers (registers); - else - { - ar0_offset = (INFERIOR_AR0 (u)); - for (regno = 0; (regno < FP0_REGNUM); regno++) - fetch_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno))); - for (; (regno < NUM_REGS); regno++) - fetch_inferior_register (regno, (FP_REGISTER_ADDR (u, regno))); - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - register int regno; -{ - struct user u; - register unsigned int ar0_offset; - extern char registers[]; - - if (remote_debugging) - remote_store_registers (registers); - else - { - if (regno >= FP0_REGNUM) - { - store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno))); - return; - } - - ar0_offset = (INFERIOR_AR0 (u)); - if (regno >= 0) - { - store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno))); - return; - } - - for (regno = 0; (regno < FP0_REGNUM); regno++) - store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno))); - for (; (regno < NUM_REGS); regno++) - store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno))); - } - return; -} - - -/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory - in the NEW_SUN_PTRACE case. - It ought to be straightforward. But it appears that writing did - not write the data that I specified. I cannot understand where - it got the data that it actually did write. */ - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - buffer[0] = remote_fetch_word (addr); - else - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - if (remote_debugging) - buffer[count - 1] - = remote_fetch_word (addr + (count - 1) * sizeof (int)); - else - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - remote_store_word (addr, buffer[i]); - else - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -/* This should probably be deleted. */ -/* Recognize COFF format systems because a.out.h defines AOUTHDR. */ -#ifdef AOUTHDR -#define COFF_FORMAT -#endif - -#ifdef HPUX_VERSION_5 -#define e_PS e_regs[PS] -#define e_PC e_regs[PC] -#endif /* HPUX_VERSION_5 */ - - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - core_aouthdr.a_magic = 0; - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - struct exception_stack es; - int val; - - val = lseek (corechan, (REGISTER_ADDR (reg_offset, 0)), 0); - if (val < 0) - perror_with_name (filename); - val = myread (corechan, es, - ((char *) &es.e_offset - (char *) &es.e_regs[R0])); - if (val < 0) - perror_with_name (filename); - for (regno = 0; (regno < PS_REGNUM); regno++) - supply_register (regno, &es.e_regs[regno + R0]); - val = es.e_PS; - supply_register (regno++, &val); - supply_register (regno++, &es.e_PC); - for (; (regno < NUM_REGS); regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, (FP_REGISTER_ADDR (u, regno)), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_TXTADDR (exec_aouthdr); - exec_data_start = N_DATADDR (exec_aouthdr); - - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - diff --git a/gnu/usr.bin/gdb/config/i386-dep.c b/gnu/usr.bin/gdb/config/i386-dep.c deleted file mode 100644 index b3edbd70ea4c..000000000000 --- a/gnu/usr.bin/gdb/config/i386-dep.c +++ /dev/null @@ -1,1279 +0,0 @@ -/* Low level interface to ptrace, for GDB when running on the Intel 386. - Copyright (C) 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: i386-dep.c,v 1.2 1993/08/02 17:39:47 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -#include -#include - -#ifdef COFF_ENCAPSULATE -#include "a.out.encap.h" -#else -#include -#endif - -#ifndef N_SET_MAGIC -#ifdef COFF_FORMAT -#define N_SET_MAGIC(exec, val) ((exec).magic = (val)) -#else -#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val)) -#endif -#endif - -#include -#include - -#include - -extern int errno; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -void -fetch_inferior_registers () -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - struct user u; - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - struct user u; - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - if (regno >= 0) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - else for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } -} - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - buffer[0] = remote_fetch_word (addr); - else - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - if (remote_debugging) - buffer[count - 1] - = remote_fetch_word (addr + (count - 1) * sizeof (int)); - else - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - remote_store_word (addr, buffer[i]); - else - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; - - /* I don't know where to find this info. - So, for now, mark it as not available. */ -/* N_SET_MAGIC (core_aouthdr, 0); */ - bzero ((char *) &core_aouthdr, sizeof core_aouthdr); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - -#ifdef HEADER_SEEK_FD - HEADER_SEEK_FD (execchan); -#endif - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_TXTADDR (exec_aouthdr); - exec_data_start = N_DATADDR (exec_aouthdr); - - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -/* helper functions for m-i386.h */ - -/* stdio style buffering to minimize calls to ptrace */ -static CORE_ADDR codestream_next_addr; -static CORE_ADDR codestream_addr; -static unsigned char codestream_buf[sizeof (int)]; -static int codestream_off; -static int codestream_cnt; - -#define codestream_tell() (codestream_addr + codestream_off) -#define codestream_peek() (codestream_cnt == 0 ? \ - codestream_fill(1): codestream_buf[codestream_off]) -#define codestream_get() (codestream_cnt-- == 0 ? \ - codestream_fill(0) : codestream_buf[codestream_off++]) - -static unsigned char -codestream_fill (peek_flag) -{ - codestream_addr = codestream_next_addr; - codestream_next_addr += sizeof (int); - codestream_off = 0; - codestream_cnt = sizeof (int); - read_memory (codestream_addr, - (unsigned char *)codestream_buf, - sizeof (int)); - - if (peek_flag) - return (codestream_peek()); - else - return (codestream_get()); -} - -static void -codestream_seek (place) -{ - codestream_next_addr = place & -sizeof (int); - codestream_cnt = 0; - codestream_fill (1); - while (codestream_tell() != place) - codestream_get (); -} - -static void -codestream_read (buf, count) - unsigned char *buf; -{ - unsigned char *p; - int i; - p = buf; - for (i = 0; i < count; i++) - *p++ = codestream_get (); -} - -/* next instruction is a jump, move to target */ -static -i386_follow_jump () -{ - int long_delta; - short short_delta; - char byte_delta; - int data16; - int pos; - - pos = codestream_tell (); - - data16 = 0; - if (codestream_peek () == 0x66) - { - codestream_get (); - data16 = 1; - } - - switch (codestream_get ()) - { - case 0xe9: - /* relative jump: if data16 == 0, disp32, else disp16 */ - if (data16) - { - codestream_read ((unsigned char *)&short_delta, 2); - pos += short_delta + 3; /* include size of jmp inst */ - } - else - { - codestream_read ((unsigned char *)&long_delta, 4); - pos += long_delta + 5; - } - break; - case 0xeb: - /* relative jump, disp8 (ignore data16) */ - codestream_read ((unsigned char *)&byte_delta, 1); - pos += byte_delta + 2; - break; - } - codestream_seek (pos + data16); -} - -/* - * find & return amound a local space allocated, and advance codestream to - * first register push (if any) - * - * if entry sequence doesn't make sense, return -1, and leave - * codestream pointer random - */ -static long -i386_get_frame_setup (pc) -{ - unsigned char op; - - codestream_seek (pc); - - i386_follow_jump (); - - op = codestream_get (); - - if (op == 0x58) /* popl %eax */ - { - /* - * this function must start with - * - * popl %eax 0x58 - * xchgl %eax, (%esp) 0x87 0x04 0x24 - * or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00 - * - * (the system 5 compiler puts out the second xchg - * inst, and the assembler doesn't try to optimize it, - * so the 'sib' form gets generated) - * - * this sequence is used to get the address of the return - * buffer for a function that returns a structure - */ - int pos; - unsigned char buf[4]; - static unsigned char proto1[3] = { 0x87,0x04,0x24 }; - static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 }; - pos = codestream_tell (); - codestream_read (buf, 4); - if (bcmp (buf, proto1, 3) == 0) - pos += 3; - else if (bcmp (buf, proto2, 4) == 0) - pos += 4; - - codestream_seek (pos); - op = codestream_get (); /* update next opcode */ - } - - if (op == 0x55) /* pushl %esp */ - { - /* check for movl %esp, %ebp - can be written two ways */ - switch (codestream_get ()) - { - case 0x8b: - if (codestream_get () != 0xec) - return (-1); - break; - case 0x89: - if (codestream_get () != 0xe5) - return (-1); - break; - default: - return (-1); - } - /* check for stack adjustment - * - * subl $XXX, %esp - * - * note: you can't subtract a 16 bit immediate - * from a 32 bit reg, so we don't have to worry - * about a data16 prefix - */ - op = codestream_peek (); - if (op == 0x83) - { - /* subl with 8 bit immed */ - codestream_get (); - if (codestream_get () != 0xec) - return (-1); - /* subl with signed byte immediate - * (though it wouldn't make sense to be negative) - */ - return (codestream_get()); - } - else if (op == 0x81) - { - /* subl with 32 bit immed */ - int locals; - codestream_get(); - if (codestream_get () != 0xec) - return (-1); - /* subl with 32 bit immediate */ - codestream_read ((unsigned char *)&locals, 4); - return (locals); - } - else - { - return (0); - } - } - else if (op == 0xc8) - { - /* enter instruction: arg is 16 bit unsigned immed */ - unsigned short slocals; - codestream_read ((unsigned char *)&slocals, 2); - codestream_get (); /* flush final byte of enter instruction */ - return (slocals); - } - return (-1); -} - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -/* on the 386, the instruction following the call could be: - * popl %ecx - one arg - * addl $imm, %esp - imm/4 args; imm may be 8 or 32 bits - * anything else - zero args - */ - -int -i386_frame_num_args (fi) - struct frame_info fi; -{ - int retpc; - unsigned char op; - struct frame_info *pfi; - - pfi = get_prev_frame_info ((fi)); - if (pfi == 0) - { - /* Note: this can happen if we are looking at the frame for - main, because FRAME_CHAIN_VALID won't let us go into - start. If we have debugging symbols, that's not really - a big deal; it just means it will only show as many arguments - to main as are declared. */ - return -1; - } - else - { - retpc = pfi->pc; - op = read_memory_integer (retpc, 1); - if (op == 0x59) - /* pop %ecx */ - return 1; - else if (op == 0x83) - { - op = read_memory_integer (retpc+1, 1); - if (op == 0xc4) - /* addl $, %esp */ - return (read_memory_integer (retpc+2,1)&0xff)/4; - else - return 0; - } - else if (op == 0x81) - { /* add with 32 bit immediate */ - op = read_memory_integer (retpc+1, 1); - if (op == 0xc4) - /* addl $, %esp */ - return read_memory_integer (retpc+2, 4) / 4; - else - return 0; - } - else - { - return 0; - } - } -} - -/* - * parse the first few instructions of the function to see - * what registers were stored. - * - * We handle these cases: - * - * The startup sequence can be at the start of the function, - * or the function can start with a branch to startup code at the end. - * - * %ebp can be set up with either the 'enter' instruction, or - * 'pushl %ebp, movl %esp, %ebp' (enter is too slow to be useful, - * but was once used in the sys5 compiler) - * - * Local space is allocated just below the saved %ebp by either the - * 'enter' instruction, or by 'subl $, %esp'. 'enter' has - * a 16 bit unsigned argument for space to allocate, and the - * 'addl' instruction could have either a signed byte, or - * 32 bit immediate. - * - * Next, the registers used by this function are pushed. In - * the sys5 compiler they will always be in the order: %edi, %esi, %ebx - * (and sometimes a harmless bug causes it to also save but not restore %eax); - * however, the code below is willing to see the pushes in any order, - * and will handle up to 8 of them. - * - * If the setup sequence is at the end of the function, then the - * next instruction will be a branch back to the start. - */ - -i386_frame_find_saved_regs (fip, fsrp) - struct frame_info *fip; - struct frame_saved_regs *fsrp; -{ - unsigned long locals; - unsigned char *p; - unsigned char op; - CORE_ADDR dummy_bottom; - CORE_ADDR adr; - int i; - - bzero (fsrp, sizeof *fsrp); - - /* if frame is the end of a dummy, compute where the - * beginning would be - */ - dummy_bottom = fip->frame - 4 - NUM_REGS*4 - CALL_DUMMY_LENGTH; - - /* check if the PC is in the stack, in a dummy frame */ - if (dummy_bottom <= fip->pc && fip->pc <= fip->frame) - { - /* all regs were saved by push_call_dummy () */ - adr = fip->frame - 4; - for (i = 0; i < NUM_REGS; i++) - { - fsrp->regs[i] = adr; - adr -= 4; - } - return; - } - - locals = i386_get_frame_setup (get_pc_function_start (fip->pc)); - - if (locals >= 0) - { - adr = fip->frame - 4 - locals; - for (i = 0; i < 8; i++) - { - op = codestream_get (); - if (op < 0x50 || op > 0x57) - break; - fsrp->regs[op - 0x50] = adr; - adr -= 4; - } - } - - fsrp->regs[PC_REGNUM] = fip->frame + 4; - fsrp->regs[FP_REGNUM] = fip->frame; -} - -/* return pc of first real instruction */ -i386_skip_prologue (pc) -{ - unsigned char op; - int i; - - if (i386_get_frame_setup (pc) < 0) - return (pc); - - /* found valid frame setup - codestream now points to - * start of push instructions for saving registers - */ - - /* skip over register saves */ - for (i = 0; i < 8; i++) - { - op = codestream_peek (); - /* break if not pushl inst */ - if (op < 0x50 || op > 0x57) - break; - codestream_get (); - } - - i386_follow_jump (); - - return (codestream_tell ()); -} - -i386_push_dummy_frame () -{ - CORE_ADDR sp = read_register (SP_REGNUM); - int regnum; - - sp = push_word (sp, read_register (PC_REGNUM)); - sp = push_word (sp, read_register (FP_REGNUM)); - write_register (FP_REGNUM, sp); - for (regnum = 0; regnum < NUM_REGS; regnum++) - sp = push_word (sp, read_register (regnum)); - write_register (SP_REGNUM, sp); -} - -i386_pop_frame () -{ - FRAME frame = get_current_frame (); - CORE_ADDR fp; - int regnum; - struct frame_saved_regs fsr; - struct frame_info *fi; - - fi = get_frame_info (frame); - fp = fi->frame; - get_frame_saved_regs (fi, &fsr); - for (regnum = 0; regnum < NUM_REGS; regnum++) - { - CORE_ADDR adr; - adr = fsr.regs[regnum]; - if (adr) - write_register (regnum, read_memory_integer (adr, 4)); - } - write_register (FP_REGNUM, read_memory_integer (fp, 4)); - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); - write_register (SP_REGNUM, fp + 8); - flush_cached_frames (); - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); -} - -/* this table must line up with REGISTER_NAMES in m-i386.h */ -/* symbols like 'EAX' come from */ -static int regmap[] = -{ - EAX, ECX, EDX, EBX, - UESP, EBP, ESI, EDI, - EIP, EFL, CS, SS, - DS, ES, FS, GS, -}; - -/* blockend is the value of u.u_ar0, and points to the - * place where GS is stored - */ -i386_register_u_addr (blockend, regnum) -{ -#if 0 - /* this will be needed if fp registers are reinstated */ - /* for now, you can look at them with 'info float' - * sys5 wont let you change them with ptrace anyway - */ - if (regnum >= FP0_REGNUM && regnum <= FP7_REGNUM) - { - int ubase, fpstate; - struct user u; - ubase = blockend + 4 * (SS + 1) - KSTKSZ; - fpstate = ubase + ((char *)&u.u_fpstate - (char *)&u); - return (fpstate + 0x1c + 10 * (regnum - FP0_REGNUM)); - } - else -#endif - return (blockend + 4 * regmap[regnum]); - -} - -i387_to_double (from, to) - char *from; - char *to; -{ - long *lp; - /* push extended mode on 387 stack, then pop in double mode - * - * first, set exception masks so no error is generated - - * number will be rounded to inf or 0, if necessary - */ - asm ("pushl %eax"); /* grab a stack slot */ - asm ("fstcw (%esp)"); /* get 387 control word */ - asm ("movl (%esp),%eax"); /* save old value */ - asm ("orl $0x3f,%eax"); /* mask all exceptions */ - asm ("pushl %eax"); - asm ("fldcw (%esp)"); /* load new value into 387 */ - - asm ("movl 8(%ebp),%eax"); - asm ("fldt (%eax)"); /* push extended number on 387 stack */ - asm ("fwait"); - asm ("movl 12(%ebp),%eax"); - asm ("fstpl (%eax)"); /* pop double */ - asm ("fwait"); - - asm ("popl %eax"); /* flush modified control word */ - asm ("fnclex"); /* clear exceptions */ - asm ("fldcw (%esp)"); /* restore original control word */ - asm ("popl %eax"); /* flush saved copy */ -} - -double_to_i387 (from, to) - char *from; - char *to; -{ - /* push double mode on 387 stack, then pop in extended mode - * no errors are possible because every 64-bit pattern - * can be converted to an extended - */ - asm ("movl 8(%ebp),%eax"); - asm ("fldl (%eax)"); - asm ("fwait"); - asm ("movl 12(%ebp),%eax"); - asm ("fstpt (%eax)"); - asm ("fwait"); -} - -struct env387 -{ - unsigned short control; - unsigned short r0; - unsigned short status; - unsigned short r1; - unsigned short tag; - unsigned short r2; - unsigned long eip; - unsigned short code_seg; - unsigned short opcode; - unsigned long operand; - unsigned short operand_seg; - unsigned short r3; - unsigned char regs[8][10]; -}; - -static -print_387_control_word (control) -unsigned short control; -{ - printf ("control 0x%04x: ", control); - printf ("compute to "); - switch ((control >> 8) & 3) - { - case 0: printf ("24 bits; "); break; - case 1: printf ("(bad); "); break; - case 2: printf ("53 bits; "); break; - case 3: printf ("64 bits; "); break; - } - printf ("round "); - switch ((control >> 10) & 3) - { - case 0: printf ("NEAREST; "); break; - case 1: printf ("DOWN; "); break; - case 2: printf ("UP; "); break; - case 3: printf ("CHOP; "); break; - } - if (control & 0x3f) - { - printf ("mask:"); - if (control & 0x0001) printf (" INVALID"); - if (control & 0x0002) printf (" DENORM"); - if (control & 0x0004) printf (" DIVZ"); - if (control & 0x0008) printf (" OVERF"); - if (control & 0x0010) printf (" UNDERF"); - if (control & 0x0020) printf (" LOS"); - printf (";"); - } - printf ("\n"); - if (control & 0xe080) printf ("warning: reserved bits on 0x%x\n", - control & 0xe080); -} - -static -print_387_status_word (status) - unsigned short status; -{ - printf ("status 0x%04x: ", status); - if (status & 0xff) - { - printf ("exceptions:"); - if (status & 0x0001) printf (" INVALID"); - if (status & 0x0002) printf (" DENORM"); - if (status & 0x0004) printf (" DIVZ"); - if (status & 0x0008) printf (" OVERF"); - if (status & 0x0010) printf (" UNDERF"); - if (status & 0x0020) printf (" LOS"); - if (status & 0x0040) printf (" FPSTACK"); - printf ("; "); - } - printf ("flags: %d%d%d%d; ", - (status & 0x4000) != 0, - (status & 0x0400) != 0, - (status & 0x0200) != 0, - (status & 0x0100) != 0); - - printf ("top %d\n", (status >> 11) & 7); -} - -static -print_387_status (status, ep) - unsigned short status; - struct env387 *ep; -{ - int i; - int bothstatus; - int top; - int fpreg; - unsigned char *p; - - bothstatus = ((status != 0) && (ep->status != 0)); - if (status != 0) - { - if (bothstatus) - printf ("u: "); - print_387_status_word (status); - } - - if (ep->status != 0) - { - if (bothstatus) - printf ("e: "); - print_387_status_word (ep->status); - } - - print_387_control_word (ep->control); - printf ("last exception: "); - printf ("opcode 0x%x; ", ep->opcode); - printf ("pc 0x%x:0x%x; ", ep->code_seg, ep->eip); - printf ("operand 0x%x:0x%x\n", ep->operand_seg, ep->operand); - - top = (ep->status >> 11) & 7; - - printf ("regno tag msb lsb value\n"); - for (fpreg = 7; fpreg >= 0; fpreg--) - { - double val; - - printf ("%s %d: ", fpreg == top ? "=>" : " ", fpreg); - - switch ((ep->tag >> (fpreg * 2)) & 3) - { - case 0: printf ("valid "); break; - case 1: printf ("zero "); break; - case 2: printf ("trap "); break; - case 3: printf ("empty "); break; - } - for (i = 9; i >= 0; i--) - printf ("%02x", ep->regs[fpreg][i]); - - i387_to_double (ep->regs[fpreg], (char *)&val); - printf (" %g\n", val); - } - if (ep->r0) - printf ("warning: reserved0 is 0x%x\n", ep->r0); - if (ep->r1) - printf ("warning: reserved1 is 0x%x\n", ep->r1); - if (ep->r2) - printf ("warning: reserved2 is 0x%x\n", ep->r2); - if (ep->r3) - printf ("warning: reserved3 is 0x%x\n", ep->r3); -} - -#ifndef U_FPSTATE -#define U_FPSTATE(u) u.u_fpstate -#endif - -i386_float_info () -{ - struct user u; /* just for address computations */ - int i; - /* fpstate defined in */ - struct fpstate *fpstatep; - char buf[sizeof (struct fpstate) + 2 * sizeof (int)]; - unsigned int uaddr; - char fpvalid; - unsigned int rounded_addr; - unsigned int rounded_size; - extern int corechan; - int skip; - - uaddr = (char *)&u.u_fpvalid - (char *)&u; - if (have_inferior_p()) - { - unsigned int data; - unsigned int mask; - - rounded_addr = uaddr & -sizeof (int); - data = ptrace (3, inferior_pid, rounded_addr, 0); - mask = 0xff << ((uaddr - rounded_addr) * 8); - - fpvalid = ((data & mask) != 0); - } - else - { - if (lseek (corechan, uaddr, 0) < 0) - perror ("seek on core file"); - if (myread (corechan, &fpvalid, 1) < 0) - perror ("read on core file"); - - } - - if (fpvalid == 0) - { - printf ("no floating point status saved\n"); - return; - } - - uaddr = (char *)&U_FPSTATE(u) - (char *)&u; - if (have_inferior_p ()) - { - int *ip; - - rounded_addr = uaddr & -sizeof (int); - rounded_size = (((uaddr + sizeof (struct fpstate)) - uaddr) + - sizeof (int) - 1) / sizeof (int); - skip = uaddr - rounded_addr; - - ip = (int *)buf; - for (i = 0; i < rounded_size; i++) - { - *ip++ = ptrace (3, inferior_pid, rounded_addr, 0); - rounded_addr += sizeof (int); - } - } - else - { - if (lseek (corechan, uaddr, 0) < 0) - perror_with_name ("seek on core file"); - if (myread (corechan, buf, sizeof (struct fpstate)) < 0) - perror_with_name ("read from core file"); - skip = 0; - } - - fpstatep = (struct fpstate *)(buf + skip); - print_387_status (fpstatep->status, (struct env387 *)fpstatep->state); -} - diff --git a/gnu/usr.bin/gdb/config/i386-pinsn.c b/gnu/usr.bin/gdb/config/i386-pinsn.c deleted file mode 100644 index c5baa6183d0e..000000000000 --- a/gnu/usr.bin/gdb/config/i386-pinsn.c +++ /dev/null @@ -1,1816 +0,0 @@ -/* Print i386 instructions for GDB, the GNU debugger. - Copyright (C) 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: i386-pinsn.c,v 1.2 1993/08/02 17:39:49 mycroft Exp $"; -#endif /* not lint */ - -/* - * 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu) - * July 1988 - */ - -/* - * The main tables describing the instructions is essentially a copy - * of the "Opcode Map" chapter (Appendix A) of the Intel 80386 - * Programmers Manual. Usually, there is a capital letter, followed - * by a small letter. The capital letter tell the addressing mode, - * and the small letter tells about the operand size. Refer to - * the Intel manual for details. - */ - -#include -#include - -#define Eb OP_E, b_mode -#define indirEb OP_indirE, b_mode -#define Gb OP_G, b_mode -#define Ev OP_E, v_mode -#define indirEv OP_indirE, v_mode -#define Ew OP_E, w_mode -#define Ma OP_E, v_mode -#define M OP_E, 0 -#define Mp OP_E, 0 /* ? */ -#define Gv OP_G, v_mode -#define Gw OP_G, w_mode -#define Rw OP_rm, w_mode -#define Rd OP_rm, d_mode -#define Ib OP_I, b_mode -#define sIb OP_sI, b_mode /* sign extened byte */ -#define Iv OP_I, v_mode -#define Iw OP_I, w_mode -#define Jb OP_J, b_mode -#define Jv OP_J, v_mode -#define ONE OP_ONE, 0 -#define Cd OP_C, d_mode -#define Dd OP_D, d_mode -#define Td OP_T, d_mode - -#define eAX OP_REG, eAX_reg -#define eBX OP_REG, eBX_reg -#define eCX OP_REG, eCX_reg -#define eDX OP_REG, eDX_reg -#define eSP OP_REG, eSP_reg -#define eBP OP_REG, eBP_reg -#define eSI OP_REG, eSI_reg -#define eDI OP_REG, eDI_reg -#define AL OP_REG, al_reg -#define CL OP_REG, cl_reg -#define DL OP_REG, dl_reg -#define BL OP_REG, bl_reg -#define AH OP_REG, ah_reg -#define CH OP_REG, ch_reg -#define DH OP_REG, dh_reg -#define BH OP_REG, bh_reg -#define AX OP_REG, ax_reg -#define DX OP_REG, dx_reg -#define indirDX OP_REG, indir_dx_reg - -#define Sw OP_SEG, w_mode -#define Ap OP_DIR, lptr -#define Av OP_DIR, v_mode -#define Ob OP_OFF, b_mode -#define Ov OP_OFF, v_mode -#define Xb OP_DSSI, b_mode -#define Xv OP_DSSI, v_mode -#define Yb OP_ESDI, b_mode -#define Yv OP_ESDI, v_mode - -#define es OP_REG, es_reg -#define ss OP_REG, ss_reg -#define cs OP_REG, cs_reg -#define ds OP_REG, ds_reg -#define fs OP_REG, fs_reg -#define gs OP_REG, gs_reg - -int OP_E(), OP_indirE(), OP_G(), OP_I(), OP_sI(), OP_REG(); -int OP_J(), OP_SEG(); -int OP_DIR(), OP_OFF(), OP_DSSI(), OP_ESDI(), OP_ONE(), OP_C(); -int OP_D(), OP_T(), OP_rm(); - - -#define b_mode 1 -#define v_mode 2 -#define w_mode 3 -#define d_mode 4 - -#define es_reg 100 -#define cs_reg 101 -#define ss_reg 102 -#define ds_reg 103 -#define fs_reg 104 -#define gs_reg 105 -#define eAX_reg 107 -#define eCX_reg 108 -#define eDX_reg 109 -#define eBX_reg 110 -#define eSP_reg 111 -#define eBP_reg 112 -#define eSI_reg 113 -#define eDI_reg 114 - -#define lptr 115 - -#define al_reg 116 -#define cl_reg 117 -#define dl_reg 118 -#define bl_reg 119 -#define ah_reg 120 -#define ch_reg 121 -#define dh_reg 122 -#define bh_reg 123 - -#define ax_reg 124 -#define cx_reg 125 -#define dx_reg 126 -#define bx_reg 127 -#define sp_reg 128 -#define bp_reg 129 -#define si_reg 130 -#define di_reg 131 - -#define indir_dx_reg 150 - -#define GRP1b NULL, NULL, 0 -#define GRP1S NULL, NULL, 1 -#define GRP1Ss NULL, NULL, 2 -#define GRP2b NULL, NULL, 3 -#define GRP2S NULL, NULL, 4 -#define GRP2b_one NULL, NULL, 5 -#define GRP2S_one NULL, NULL, 6 -#define GRP2b_cl NULL, NULL, 7 -#define GRP2S_cl NULL, NULL, 8 -#define GRP3b NULL, NULL, 9 -#define GRP3S NULL, NULL, 10 -#define GRP4 NULL, NULL, 11 -#define GRP5 NULL, NULL, 12 -#define GRP6 NULL, NULL, 13 -#define GRP7 NULL, NULL, 14 -#define GRP8 NULL, NULL, 15 - -#define FLOATCODE 50 -#define FLOAT NULL, NULL, FLOATCODE - -struct dis386 { - char *name; - int (*op1)(); - int bytemode1; - int (*op2)(); - int bytemode2; - int (*op3)(); - int bytemode3; -}; - -struct dis386 dis386[] = { - /* 00 */ - { "addb", Eb, Gb }, - { "addS", Ev, Gv }, - { "addb", Gb, Eb }, - { "addS", Gv, Ev }, - { "addb", AL, Ib }, - { "addS", eAX, Iv }, - { "pushl", es }, - { "popl", es }, - /* 08 */ - { "orb", Eb, Gb }, - { "orS", Ev, Gv }, - { "orb", Gb, Eb }, - { "orS", Gv, Ev }, - { "orb", AL, Ib }, - { "orS", eAX, Iv }, - { "pushl", cs }, - { "(bad)" }, /* 0x0f extended opcode escape */ - /* 10 */ - { "adcb", Eb, Gb }, - { "adcS", Ev, Gv }, - { "adcb", Gb, Eb }, - { "adcS", Gv, Ev }, - { "adcb", AL, Ib }, - { "adcS", eAX, Iv }, - { "pushl", ss }, - { "popl", ss }, - /* 18 */ - { "sbbb", Eb, Gb }, - { "sbbS", Ev, Gv }, - { "sbbb", Gb, Eb }, - { "sbbS", Gv, Ev }, - { "sbbb", AL, Ib }, - { "sbbS", eAX, Iv }, - { "pushl", ds }, - { "popl", ds }, - /* 20 */ - { "andb", Eb, Gb }, - { "andS", Ev, Gv }, - { "andb", Gb, Eb }, - { "andS", Gv, Ev }, - { "andb", AL, Ib }, - { "andS", eAX, Iv }, - { "(bad)" }, /* SEG ES prefix */ - { "daa" }, - /* 28 */ - { "subb", Eb, Gb }, - { "subS", Ev, Gv }, - { "subb", Gb, Eb }, - { "subS", Gv, Ev }, - { "subb", AL, Ib }, - { "subS", eAX, Iv }, - { "(bad)" }, /* SEG CS prefix */ - { "das" }, - /* 30 */ - { "xorb", Eb, Gb }, - { "xorS", Ev, Gv }, - { "xorb", Gb, Eb }, - { "xorS", Gv, Ev }, - { "xorb", AL, Ib }, - { "xorS", eAX, Iv }, - { "(bad)" }, /* SEG SS prefix */ - { "aaa" }, - /* 38 */ - { "cmpb", Eb, Gb }, - { "cmpS", Ev, Gv }, - { "cmpb", Gb, Eb }, - { "cmpS", Gv, Ev }, - { "cmpb", AL, Ib }, - { "cmpS", eAX, Iv }, - { "(bad)" }, /* SEG DS prefix */ - { "aas" }, - /* 40 */ - { "incS", eAX }, - { "incS", eCX }, - { "incS", eDX }, - { "incS", eBX }, - { "incS", eSP }, - { "incS", eBP }, - { "incS", eSI }, - { "incS", eDI }, - /* 48 */ - { "decS", eAX }, - { "decS", eCX }, - { "decS", eDX }, - { "decS", eBX }, - { "decS", eSP }, - { "decS", eBP }, - { "decS", eSI }, - { "decS", eDI }, - /* 50 */ - { "pushS", eAX }, - { "pushS", eCX }, - { "pushS", eDX }, - { "pushS", eBX }, - { "pushS", eSP }, - { "pushS", eBP }, - { "pushS", eSI }, - { "pushS", eDI }, - /* 58 */ - { "popS", eAX }, - { "popS", eCX }, - { "popS", eDX }, - { "popS", eBX }, - { "popS", eSP }, - { "popS", eBP }, - { "popS", eSI }, - { "popS", eDI }, - /* 60 */ - { "pusha" }, - { "popa" }, - { "boundS", Gv, Ma }, - { "arpl", Ew, Gw }, - { "(bad)" }, /* seg fs */ - { "(bad)" }, /* seg gs */ - { "(bad)" }, /* op size prefix */ - { "(bad)" }, /* adr size prefix */ - /* 68 */ - { "pushS", Iv }, /* 386 book wrong */ - { "imulS", Gv, Ev, Iv }, - { "pushl", sIb }, /* push of byte really pushes 4 bytes */ - { "imulS", Gv, Ev, Ib }, - { "insb", Yb, indirDX }, - { "insS", Yv, indirDX }, - { "outsb", indirDX, Xb }, - { "outsS", indirDX, Xv }, - /* 70 */ - { "jo", Jb }, - { "jno", Jb }, - { "jb", Jb }, - { "jae", Jb }, - { "je", Jb }, - { "jne", Jb }, - { "jbe", Jb }, - { "ja", Jb }, - /* 78 */ - { "js", Jb }, - { "jns", Jb }, - { "jp", Jb }, - { "jnp", Jb }, - { "jl", Jb }, - { "jnl", Jb }, - { "jle", Jb }, - { "jg", Jb }, - /* 80 */ - { GRP1b }, - { GRP1S }, - { "(bad)" }, - { GRP1Ss }, - { "testb", Eb, Gb }, - { "testS", Ev, Gv }, - { "xchgb", Eb, Gb }, - { "xchgS", Ev, Gv }, - /* 88 */ - { "movb", Eb, Gb }, - { "movS", Ev, Gv }, - { "movb", Gb, Eb }, - { "movS", Gv, Ev }, - { "movw", Ew, Sw }, - { "leaS", Gv, M }, - { "movw", Sw, Ew }, - { "popS", Ev }, - /* 90 */ - { "nop" }, - { "xchgS", eCX, eAX }, - { "xchgS", eDX, eAX }, - { "xchgS", eBX, eAX }, - { "xchgS", eSP, eAX }, - { "xchgS", eBP, eAX }, - { "xchgS", eSI, eAX }, - { "xchgS", eDI, eAX }, - /* 98 */ - { "cwtl" }, - { "cltd" }, - { "lcall", Ap }, - { "(bad)" }, /* fwait */ - { "pushf" }, - { "popf" }, - { "sahf" }, - { "lahf" }, - /* a0 */ - { "movb", AL, Ob }, - { "movS", eAX, Ov }, - { "movb", Ob, AL }, - { "movS", Ov, eAX }, - { "movsb", Yb, Xb }, - { "movsS", Yv, Xv }, - { "cmpsb", Yb, Xb }, - { "cmpsS", Yv, Xv }, - /* a8 */ - { "testb", AL, Ib }, - { "testS", eAX, Iv }, - { "stosb", Yb, AL }, - { "stosS", Yv, eAX }, - { "lodsb", AL, Xb }, - { "lodsS", eAX, Xv }, - { "scasb", AL, Xb }, - { "scasS", eAX, Xv }, - /* b0 */ - { "movb", AL, Ib }, - { "movb", CL, Ib }, - { "movb", DL, Ib }, - { "movb", BL, Ib }, - { "movb", AH, Ib }, - { "movb", CH, Ib }, - { "movb", DH, Ib }, - { "movb", BH, Ib }, - /* b8 */ - { "movS", eAX, Iv }, - { "movS", eCX, Iv }, - { "movS", eDX, Iv }, - { "movS", eBX, Iv }, - { "movS", eSP, Iv }, - { "movS", eBP, Iv }, - { "movS", eSI, Iv }, - { "movS", eDI, Iv }, - /* c0 */ - { GRP2b }, - { GRP2S }, - { "ret", Iw }, - { "ret" }, - { "lesS", Gv, Mp }, - { "ldsS", Gv, Mp }, - { "movb", Eb, Ib }, - { "movS", Ev, Iv }, - /* c8 */ - { "enter", Iw, Ib }, - { "leave" }, - { "lret", Iw }, - { "lret" }, - { "int3" }, - { "int", Ib }, - { "into" }, - { "iret" }, - /* d0 */ - { GRP2b_one }, - { GRP2S_one }, - { GRP2b_cl }, - { GRP2S_cl }, - { "aam", Ib }, - { "aad", Ib }, - { "(bad)" }, - { "xlat" }, - /* d8 */ - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - /* e0 */ - { "loopne", Jb }, - { "loope", Jb }, - { "loop", Jb }, - { "jCcxz", Jb }, - { "inb", AL, Ib }, - { "inS", eAX, Ib }, - { "outb", Ib, AL }, - { "outS", Ib, eAX }, - /* e8 */ - { "call", Av }, - { "jmp", Jv }, - { "ljmp", Ap }, - { "jmp", Jb }, - { "inb", AL, indirDX }, - { "inS", eAX, indirDX }, - { "outb", indirDX, AL }, - { "outS", indirDX, eAX }, - /* f0 */ - { "(bad)" }, /* lock prefix */ - { "(bad)" }, - { "(bad)" }, /* repne */ - { "(bad)" }, /* repz */ - { "hlt" }, - { "cmc" }, - { GRP3b }, - { GRP3S }, - /* f8 */ - { "clc" }, - { "stc" }, - { "cli" }, - { "sti" }, - { "cld" }, - { "std" }, - { GRP4 }, - { GRP5 }, -}; - -struct dis386 dis386_twobyte[] = { - /* 00 */ - { GRP6 }, - { GRP7 }, - { "larS", Gv, Ew }, - { "lslS", Gv, Ew }, - { "(bad)" }, - { "(bad)" }, - { "clts" }, - { "(bad)" }, - /* 08 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 10 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 18 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 20 */ - /* these are all backward in appendix A of the intel book */ - { "movl", Rd, Cd }, - { "movl", Rd, Dd }, - { "movl", Cd, Rd }, - { "movl", Dd, Rd }, - { "movl", Rd, Td }, - { "(bad)" }, - { "movl", Td, Rd }, - { "(bad)" }, - /* 28 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 30 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 38 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 40 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 48 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 50 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 58 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 60 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 68 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 70 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 78 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 80 */ - { "jo", Jv }, - { "jno", Jv }, - { "jb", Jv }, - { "jae", Jv }, - { "je", Jv }, - { "jne", Jv }, - { "jbe", Jv }, - { "ja", Jv }, - /* 88 */ - { "js", Jv }, - { "jns", Jv }, - { "jp", Jv }, - { "jnp", Jv }, - { "jl", Jv }, - { "jge", Jv }, - { "jle", Jv }, - { "jg", Jv }, - /* 90 */ - { "seto", Eb }, - { "setno", Eb }, - { "setb", Eb }, - { "setae", Eb }, - { "sete", Eb }, - { "setne", Eb }, - { "setbe", Eb }, - { "seta", Eb }, - /* 98 */ - { "sets", Eb }, - { "setns", Eb }, - { "setp", Eb }, - { "setnp", Eb }, - { "setl", Eb }, - { "setge", Eb }, - { "setle", Eb }, - { "setg", Eb }, - /* a0 */ - { "pushl", fs }, - { "popl", fs }, - { "(bad)" }, - { "btS", Ev, Gv }, - { "shldS", Ev, Gv, Ib }, - { "shldS", Ev, Gv, CL }, - { "(bad)" }, - { "(bad)" }, - /* a8 */ - { "pushl", gs }, - { "popl", gs }, - { "(bad)" }, - { "btsS", Ev, Gv }, - { "shrdS", Ev, Gv, Ib }, - { "shrdS", Ev, Gv, CL }, - { "(bad)" }, - { "imulS", Gv, Ev }, - /* b0 */ - { "(bad)" }, - { "(bad)" }, - { "lssS", Gv, Mp }, /* 386 lists only Mp */ - { "btrS", Ev, Gv }, - { "lfsS", Gv, Mp }, /* 386 lists only Mp */ - { "lgsS", Gv, Mp }, /* 386 lists only Mp */ - { "movzbS", Gv, Eb }, - { "movzwS", Gv, Ew }, - /* b8 */ - { "(bad)" }, - { "(bad)" }, - { GRP8 }, - { "btcS", Ev, Gv }, - { "bsfS", Gv, Ev }, - { "bsrS", Gv, Ev }, - { "movsbS", Gv, Eb }, - { "movswS", Gv, Ew }, - /* c0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* c8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* d0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* d8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* e0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* e8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* f0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* f8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, -}; - -static char obuf[100]; -static char *obufp; -static char scratchbuf[100]; -static unsigned char *start_codep; -static unsigned char *codep; -static int mod; -static int rm; -static int reg; - -static char *names32[]={ - "%eax","%ecx","%edx","%ebx", "%esp","%ebp","%esi","%edi", -}; -static char *names16[] = { - "%ax","%cx","%dx","%bx","%sp","%bp","%si","%di", -}; -static char *names8[] = { - "%al","%cl","%dl","%bl","%ah","%ch","%dh","%bh", -}; -static char *names_seg[] = { - "%es","%cs","%ss","%ds","%fs","%gs","%?","%?", -}; - -struct dis386 grps[][8] = { - /* GRP1b */ - { - { "addb", Eb, Ib }, - { "orb", Eb, Ib }, - { "adcb", Eb, Ib }, - { "sbbb", Eb, Ib }, - { "andb", Eb, Ib }, - { "subb", Eb, Ib }, - { "xorb", Eb, Ib }, - { "cmpb", Eb, Ib } - }, - /* GRP1S */ - { - { "addS", Ev, Iv }, - { "orS", Ev, Iv }, - { "adcS", Ev, Iv }, - { "sbbS", Ev, Iv }, - { "andS", Ev, Iv }, - { "subS", Ev, Iv }, - { "xorS", Ev, Iv }, - { "cmpS", Ev, Iv } - }, - /* GRP1Ss */ - { - { "addS", Ev, sIb }, - { "orS", Ev, sIb }, - { "adcS", Ev, sIb }, - { "sbbS", Ev, sIb }, - { "andS", Ev, sIb }, - { "subS", Ev, sIb }, - { "xorS", Ev, sIb }, - { "cmpS", Ev, sIb } - }, - /* GRP2b */ - { - { "rolb", Eb, Ib }, - { "rorb", Eb, Ib }, - { "rclb", Eb, Ib }, - { "rcrb", Eb, Ib }, - { "shlb", Eb, Ib }, - { "shrb", Eb, Ib }, - { "(bad)" }, - { "sarb", Eb, Ib }, - }, - /* GRP2S */ - { - { "rolS", Ev, Ib }, - { "rorS", Ev, Ib }, - { "rclS", Ev, Ib }, - { "rcrS", Ev, Ib }, - { "shlS", Ev, Ib }, - { "shrS", Ev, Ib }, - { "(bad)" }, - { "sarS", Ev, Ib }, - }, - /* GRP2b_one */ - { - { "rolb", Eb }, - { "rorb", Eb }, - { "rclb", Eb }, - { "rcrb", Eb }, - { "shlb", Eb }, - { "shrb", Eb }, - { "(bad)" }, - { "sarb", Eb }, - }, - /* GRP2S_one */ - { - { "rolS", Ev }, - { "rorS", Ev }, - { "rclS", Ev }, - { "rcrS", Ev }, - { "shlS", Ev }, - { "shrS", Ev }, - { "(bad)" }, - { "sarS", Ev }, - }, - /* GRP2b_cl */ - { - { "rolb", Eb, CL }, - { "rorb", Eb, CL }, - { "rclb", Eb, CL }, - { "rcrb", Eb, CL }, - { "shlb", Eb, CL }, - { "shrb", Eb, CL }, - { "(bad)" }, - { "sarb", Eb, CL }, - }, - /* GRP2S_cl */ - { - { "rolS", Ev, CL }, - { "rorS", Ev, CL }, - { "rclS", Ev, CL }, - { "rcrS", Ev, CL }, - { "shlS", Ev, CL }, - { "shrS", Ev, CL }, - { "(bad)" }, - { "sarS", Ev, CL } - }, - /* GRP3b */ - { - { "testb", Eb, Ib }, - { "(bad)", Eb }, - { "notb", Eb }, - { "negb", Eb }, - { "mulb", AL, Eb }, - { "imulb", AL, Eb }, - { "divb", AL, Eb }, - { "idivb", AL, Eb } - }, - /* GRP3S */ - { - { "testS", Ev, Iv }, - { "(bad)" }, - { "notS", Ev }, - { "negS", Ev }, - { "mulS", eAX, Ev }, - { "imulS", eAX, Ev }, - { "divS", eAX, Ev }, - { "idivS", eAX, Ev }, - }, - /* GRP4 */ - { - { "incb", Eb }, - { "decb", Eb }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, - /* GRP5 */ - { - { "incS", Ev }, - { "decS", Ev }, - { "call", indirEv }, - { "lcall", indirEv }, - { "jmp", indirEv }, - { "ljmp", indirEv }, - { "pushS", Ev }, - { "(bad)" }, - }, - /* GRP6 */ - { - { "sldt", Ew }, - { "str", Ew }, - { "lldt", Ew }, - { "ltr", Ew }, - { "verr", Ew }, - { "verw", Ew }, - { "(bad)" }, - { "(bad)" } - }, - /* GRP7 */ - { - { "sgdt", Ew }, - { "sidt", Ew }, - { "lgdt", Ew }, - { "lidt", Ew }, - { "smsw", Ew }, - { "(bad)" }, - { "lmsw", Ew }, - { "(bad)" }, - }, - /* GRP8 */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "btS", Ev, Ib }, - { "btsS", Ev, Ib }, - { "btrS", Ev, Ib }, - { "btcS", Ev, Ib }, - } -}; - -#define PREFIX_REPZ 1 -#define PREFIX_REPNZ 2 -#define PREFIX_LOCK 4 -#define PREFIX_CS 8 -#define PREFIX_SS 0x10 -#define PREFIX_DS 0x20 -#define PREFIX_ES 0x40 -#define PREFIX_FS 0x80 -#define PREFIX_GS 0x100 -#define PREFIX_DATA 0x200 -#define PREFIX_ADR 0x400 -#define PREFIX_FWAIT 0x800 - -static int prefixes; - -ckprefix () -{ - prefixes = 0; - while (1) - { - switch (*codep) - { - case 0xf3: - prefixes |= PREFIX_REPZ; - break; - case 0xf2: - prefixes |= PREFIX_REPNZ; - break; - case 0xf0: - prefixes |= PREFIX_LOCK; - break; - case 0x2e: - prefixes |= PREFIX_CS; - break; - case 0x36: - prefixes |= PREFIX_SS; - break; - case 0x3e: - prefixes |= PREFIX_DS; - break; - case 0x26: - prefixes |= PREFIX_ES; - break; - case 0x64: - prefixes |= PREFIX_FS; - break; - case 0x65: - prefixes |= PREFIX_GS; - break; - case 0x66: - prefixes |= PREFIX_DATA; - break; - case 0x67: - prefixes |= PREFIX_ADR; - break; - case 0x9b: - prefixes |= PREFIX_FWAIT; - break; - default: - return; - } - codep++; - } -} - -static int dflag; -static int aflag; - -static char op1out[100], op2out[100], op3out[100]; -static int start_pc; - -/* - * disassemble the first instruction in 'inbuf'. You have to make - * sure all of the bytes of the instruction are filled in. - * On the 386's of 1988, the maximum length of an instruction is 15 bytes. - * (see topic "Redundant prefixes" in the "Differences from 8086" - * section of the "Virtual 8086 Mode" chapter.) - * 'pc' should be the address of this instruction, it will - * be used to print the target address if this is a relative jump or call - * 'outbuf' gets filled in with the disassembled instruction. it should - * be long enough to hold the longest disassembled instruction. - * 100 bytes is certainly enough, unless symbol printing is added later - * The function returns the length of this instruction in bytes. - */ -i386dis (pc, inbuf, outbuf) - int pc; - unsigned char *inbuf; - char *outbuf; -{ - struct dis386 *dp; - char *p; - int i; - int enter_instruction; - char *first, *second, *third; - int needcomma; - - obuf[0] = 0; - op1out[0] = 0; - op2out[0] = 0; - op3out[0] = 0; - - start_pc = pc; - start_codep = inbuf; - codep = inbuf; - - ckprefix (); - - if (*codep == 0xc8) - enter_instruction = 1; - else - enter_instruction = 0; - - obufp = obuf; - - if (prefixes & PREFIX_REPZ) - oappend ("repz "); - if (prefixes & PREFIX_REPNZ) - oappend ("repnz "); - if (prefixes & PREFIX_LOCK) - oappend ("lock "); - - if ((prefixes & PREFIX_FWAIT) - && ((*codep < 0xd8) || (*codep > 0xdf))) - { - /* fwait not followed by floating point instruction */ - oappend ("fwait"); - strcpy (outbuf, obuf); - return (1); - } - - /* these would be initialized to 0 if disassembling for 8086 or 286 */ - dflag = 1; - aflag = 1; - - if (prefixes & PREFIX_DATA) - dflag ^= 1; - - if (prefixes & PREFIX_ADR) - { - aflag ^= 1; - oappend ("addr16 "); - } - - if (*codep == 0x0f) - dp = &dis386_twobyte[*++codep]; - else - dp = &dis386[*codep]; - codep++; - mod = (*codep >> 6) & 3; - reg = (*codep >> 3) & 7; - rm = *codep & 7; - - if (dp->name == NULL && dp->bytemode1 == FLOATCODE) - { - dofloat (); - } - else - { - if (dp->name == NULL) - dp = &grps[dp->bytemode1][reg]; - - putop (dp->name); - - obufp = op1out; - if (dp->op1) - (*dp->op1)(dp->bytemode1); - - obufp = op2out; - if (dp->op2) - (*dp->op2)(dp->bytemode2); - - obufp = op3out; - if (dp->op3) - (*dp->op3)(dp->bytemode3); - } - - obufp = obuf + strlen (obuf); - for (i = strlen (obuf); i < 6; i++) - oappend (" "); - oappend (" "); - - /* enter instruction is printed with operands in the - * same order as the intel book; everything else - * is printed in reverse order - */ - if (enter_instruction) - { - first = op1out; - second = op2out; - third = op3out; - } - else - { - first = op3out; - second = op2out; - third = op1out; - } - needcomma = 0; - if (*first) - { - oappend (first); - needcomma = 1; - } - if (*second) - { - if (needcomma) - oappend (","); - oappend (second); - needcomma = 1; - } - if (*third) - { - if (needcomma) - oappend (","); - oappend (third); - } - strcpy (outbuf, obuf); - return (codep - inbuf); -} - -char *float_mem[] = { - /* d8 */ - "fadds", - "fmuls", - "fcoms", - "fcomps", - "fsubs", - "fsubrs", - "fdivs", - "fdivrs", - /* d9 */ - "flds", - "(bad)", - "fsts", - "fstps", - "fldenv", - "fldcw", - "fNstenv", - "fNstcw", - /* da */ - "fiaddl", - "fimull", - "ficoml", - "ficompl", - "fisubl", - "fisubrl", - "fidivl", - "fidivrl", - /* db */ - "fildl", - "(bad)", - "fistl", - "fistpl", - "(bad)", - "fldt", - "(bad)", - "fstpt", - /* dc */ - "faddl", - "fmull", - "fcoml", - "fcompl", - "fsubl", - "fsubrl", - "fdivl", - "fdivrl", - /* dd */ - "fldl", - "(bad)", - "fstl", - "fstpl", - "frstor", - "(bad)", - "fNsave", - "fNstsw", - /* de */ - "fiadd", - "fimul", - "ficom", - "ficomp", - "fisub", - "fisubr", - "fidiv", - "fidivr", - /* df */ - "fild", - "(bad)", - "fist", - "fistp", - "fbld", - "fildll", - "fbstp", - "fistpll", -}; - -#define ST OP_ST, 0 -#define STi OP_STi, 0 -int OP_ST(), OP_STi(); - -#define FGRPd9_2 NULL, NULL, 0 -#define FGRPd9_4 NULL, NULL, 1 -#define FGRPd9_5 NULL, NULL, 2 -#define FGRPd9_6 NULL, NULL, 3 -#define FGRPd9_7 NULL, NULL, 4 -#define FGRPda_5 NULL, NULL, 5 -#define FGRPdb_4 NULL, NULL, 6 -#define FGRPde_3 NULL, NULL, 7 -#define FGRPdf_4 NULL, NULL, 8 - -struct dis386 float_reg[][8] = { - /* d8 */ - { - { "fadd", ST, STi }, - { "fmul", ST, STi }, - { "fcom", STi }, - { "fcomp", STi }, - { "fsub", ST, STi }, - { "fsubr", ST, STi }, - { "fdiv", ST, STi }, - { "fdivr", ST, STi }, - }, - /* d9 */ - { - { "fld", STi }, - { "fxch", STi }, - { FGRPd9_2 }, - { "(bad)" }, - { FGRPd9_4 }, - { FGRPd9_5 }, - { FGRPd9_6 }, - { FGRPd9_7 }, - }, - /* da */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPda_5 }, - { "(bad)" }, - { "(bad)" }, - }, - /* db */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPdb_4 }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, - /* dc */ - { - { "fadd", STi, ST }, - { "fmul", STi, ST }, - { "(bad)" }, - { "(bad)" }, - { "fsub", STi, ST }, - { "fsubr", STi, ST }, - { "fdiv", STi, ST }, - { "fdivr", STi, ST }, - }, - /* dd */ - { - { "ffree", STi }, - { "(bad)" }, - { "fst", STi }, - { "fstp", STi }, - { "fucom", STi }, - { "fucomp", STi }, - { "(bad)" }, - { "(bad)" }, - }, - /* de */ - { - { "faddp", STi, ST }, - { "fmulp", STi, ST }, - { "(bad)" }, - { FGRPde_3 }, - { "fsubp", STi, ST }, - { "fsubrp", STi, ST }, - { "fdivp", STi, ST }, - { "fdivrp", STi, ST }, - }, - /* df */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPdf_4 }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, -}; - - -char *fgrps[][8] = { - /* d9_2 0 */ - { - "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* d9_4 1 */ - { - "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)", - }, - - /* d9_5 2 */ - { - "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)", - }, - - /* d9_6 3 */ - { - "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp", - }, - - /* d9_7 4 */ - { - "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos", - }, - - /* da_5 5 */ - { - "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* db_4 6 */ - { - "feni(287 only)","fdisi(287 only)","fNclex","fNinit", - "fNsetpm(287 only)","(bad)","(bad)","(bad)", - }, - - /* de_3 7 */ - { - "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* df_4 8 */ - { - "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, -}; - - -dofloat () -{ - struct dis386 *dp; - unsigned char floatop; - - floatop = codep[-1]; - - if (mod != 3) - { - putop (float_mem[(floatop - 0xd8) * 8 + reg]); - obufp = op1out; - OP_E (v_mode); - return; - } - codep++; - - dp = &float_reg[floatop - 0xd8][reg]; - if (dp->name == NULL) - { - putop (fgrps[dp->bytemode1][rm]); - /* instruction fnstsw is only one with strange arg */ - if (floatop == 0xdf && *codep == 0xe0) - strcpy (op1out, "%eax"); - } - else - { - putop (dp->name); - obufp = op1out; - if (dp->op1) - (*dp->op1)(dp->bytemode1); - obufp = op2out; - if (dp->op2) - (*dp->op2)(dp->bytemode2); - } -} - -/* ARGSUSED */ -OP_ST (ignore) -{ - oappend ("%st"); -} - -/* ARGSUSED */ -OP_STi (ignore) -{ - sprintf (scratchbuf, "%%st(%d)", rm); - oappend (scratchbuf); -} - - -/* capital letters in template are macros */ -putop (template) - char *template; -{ - char *p; - - for (p = template; *p; p++) - { - switch (*p) - { - default: - *obufp++ = *p; - break; - case 'C': /* For jcxz/jecxz */ - if (aflag == 0) - *obufp++ = 'e'; - break; - case 'N': - if ((prefixes & PREFIX_FWAIT) == 0) - *obufp++ = 'n'; - break; - case 'S': - /* operand size flag */ - if (dflag) - *obufp++ = 'l'; - else - *obufp++ = 'w'; - break; - } - } - *obufp = 0; -} - -oappend (s) -char *s; -{ - strcpy (obufp, s); - obufp += strlen (s); - *obufp = 0; -} - -append_prefix () -{ - if (prefixes & PREFIX_CS) - oappend ("%cs:"); - if (prefixes & PREFIX_DS) - oappend ("%ds:"); - if (prefixes & PREFIX_SS) - oappend ("%ss:"); - if (prefixes & PREFIX_ES) - oappend ("%es:"); - if (prefixes & PREFIX_FS) - oappend ("%fs:"); - if (prefixes & PREFIX_GS) - oappend ("%gs:"); -} - -OP_indirE (bytemode) -{ - oappend ("*"); - OP_E (bytemode); -} - -OP_E (bytemode) -{ - int disp; - int havesib; - int didoutput = 0; - int base; - int index; - int scale; - int havebase; - - /* skip mod/rm byte */ - codep++; - - havesib = 0; - havebase = 0; - disp = 0; - - if (mod == 3) - { - switch (bytemode) - { - case b_mode: - oappend (names8[rm]); - break; - case w_mode: - oappend (names16[rm]); - break; - case v_mode: - if (dflag) - oappend (names32[rm]); - else - oappend (names16[rm]); - break; - default: - oappend (""); - break; - } - return; - } - - append_prefix (); - if (rm == 4) - { - havesib = 1; - havebase = 1; - scale = (*codep >> 6) & 3; - index = (*codep >> 3) & 7; - base = *codep & 7; - codep++; - } - - switch (mod) - { - case 0: - switch (rm) - { - case 4: - /* implies havesib and havebase */ - if (base == 5) { - havebase = 0; - disp = get32 (); - } - break; - case 5: - disp = get32 (); - break; - default: - havebase = 1; - base = rm; - break; - } - break; - case 1: - disp = *(char *)codep++; - if (rm != 4) - { - havebase = 1; - base = rm; - } - break; - case 2: - disp = get32 (); - if (rm != 4) - { - havebase = 1; - base = rm; - } - break; - } - - if (mod != 0 || rm == 5 || (havesib && base == 5)) - { - sprintf (scratchbuf, "%d", disp); - oappend (scratchbuf); - } - - if (havebase || havesib) - { - oappend ("("); - if (havebase) - oappend (names32[base]); - if (havesib) - { - if (index != 4) - { - sprintf (scratchbuf, ",%s", names32[index]); - oappend (scratchbuf); - } - sprintf (scratchbuf, ",%d", 1 << scale); - oappend (scratchbuf); - } - oappend (")"); - } -} - -OP_G (bytemode) -{ - switch (bytemode) - { - case b_mode: - oappend (names8[reg]); - break; - case w_mode: - oappend (names16[reg]); - break; - case d_mode: - oappend (names32[reg]); - break; - case v_mode: - if (dflag) - oappend (names32[reg]); - else - oappend (names16[reg]); - break; - default: - oappend (""); - break; - } -} - -get32 () -{ - int x = 0; - - x = *codep++ & 0xff; - x |= (*codep++ & 0xff) << 8; - x |= (*codep++ & 0xff) << 16; - x |= (*codep++ & 0xff) << 24; - return (x); -} - -get16 () -{ - int x = 0; - - x = *codep++ & 0xff; - x |= (*codep++ & 0xff) << 8; - return (x); -} - -OP_REG (code) -{ - char *s; - - switch (code) - { - case indir_dx_reg: s = "(%dx)"; break; - case ax_reg: case cx_reg: case dx_reg: case bx_reg: - case sp_reg: case bp_reg: case si_reg: case di_reg: - s = names16[code - ax_reg]; - break; - case es_reg: case ss_reg: case cs_reg: - case ds_reg: case fs_reg: case gs_reg: - s = names_seg[code - es_reg]; - break; - case al_reg: case ah_reg: case cl_reg: case ch_reg: - case dl_reg: case dh_reg: case bl_reg: case bh_reg: - s = names8[code - al_reg]; - break; - case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg: - case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg: - if (dflag) - s = names32[code - eAX_reg]; - else - s = names16[code - eAX_reg]; - break; - default: - s = ""; - break; - } - oappend (s); -} - -OP_I (bytemode) -{ - int op; - - switch (bytemode) - { - case b_mode: - op = *codep++ & 0xff; - break; - case v_mode: - if (dflag) - op = get32 (); - else - op = get16 (); - break; - case w_mode: - op = get16 (); - break; - default: - oappend (""); - return; - } - sprintf (scratchbuf, "$0x%x", op); - oappend (scratchbuf); -} - -OP_sI (bytemode) -{ - int op; - - switch (bytemode) - { - case b_mode: - op = *(char *)codep++; - break; - case v_mode: - if (dflag) - op = get32 (); - else - op = (short)get16(); - break; - case w_mode: - op = (short)get16 (); - break; - default: - oappend (""); - return; - } - sprintf (scratchbuf, "$0x%x", op); - oappend (scratchbuf); -} - -OP_J (bytemode) -{ - int disp; - int mask = -1; - - switch (bytemode) - { - case b_mode: - disp = *(char *)codep++; - break; - case v_mode: - if (dflag) - disp = get32 (); - else - { - disp = (short)get16 (); - /* for some reason, a data16 prefix on a jump instruction - means that the pc is masked to 16 bits after the - displacement is added! */ - mask = 0xffff; - } - break; - default: - oappend (""); - return; - } - - sprintf (scratchbuf, "0x%x", - (start_pc + codep - start_codep + disp) & mask); - oappend (scratchbuf); -} - -/* ARGSUSED */ -OP_SEG (dummy) -{ - static char *sreg[] = { - "%es","%cs","%ss","%ds","%fs","%gs","%?","%?", - }; - - oappend (sreg[reg]); -} - -OP_DIR (size) -{ - int seg, offset; - - switch (size) - { - case lptr: - if (aflag) - { - offset = get32 (); - seg = get16 (); - } - else - { - offset = get16 (); - seg = get16 (); - } - sprintf (scratchbuf, "0x%x,0x%x", seg, offset); - oappend (scratchbuf); - break; - case v_mode: - if (aflag) - offset = get32 (); - else - offset = (short)get16 (); - - sprintf (scratchbuf, "0x%x", - start_pc + codep - start_codep + offset); - oappend (scratchbuf); - break; - default: - oappend (""); - break; - } -} - -/* ARGSUSED */ -OP_OFF (bytemode) -{ - int off; - - if (aflag) - off = get32 (); - else - off = get16 (); - - sprintf (scratchbuf, "0x%x", off); - oappend (scratchbuf); -} - -/* ARGSUSED */ -OP_ESDI (dummy) -{ - oappend ("%es:("); - oappend (aflag ? "%edi" : "%di"); - oappend (")"); -} - -/* ARGSUSED */ -OP_DSSI (dummy) -{ - oappend ("%ds:("); - oappend (aflag ? "%esi" : "%si"); - oappend (")"); -} - -/* ARGSUSED */ -OP_ONE (dummy) -{ - oappend ("1"); -} - -/* ARGSUSED */ -OP_C (dummy) -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%cr%d", reg); - oappend (scratchbuf); -} - -/* ARGSUSED */ -OP_D (dummy) -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%db%d", reg); - oappend (scratchbuf); -} - -/* ARGSUSED */ -OP_T (dummy) -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%tr%d", reg); - oappend (scratchbuf); -} - -OP_rm (bytemode) -{ - switch (bytemode) - { - case d_mode: - oappend (names32[rm]); - break; - case w_mode: - oappend (names16[rm]); - break; - } -} - -/* GDB interface */ -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "inferior.h" - -#define MAXLEN 20 -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - /* should be expanded if disassembler prints symbol names */ - char outbuf[100]; - int n; - - read_memory (memaddr, buffer, MAXLEN); - - n = i386dis ((int)memaddr, buffer, outbuf); - - fputs (outbuf, stream); - - return (n); -} - diff --git a/gnu/usr.bin/gdb/config/i386bsd-dep.c b/gnu/usr.bin/gdb/config/i386bsd-dep.c deleted file mode 100644 index 0825e7515543..000000000000 --- a/gnu/usr.bin/gdb/config/i386bsd-dep.c +++ /dev/null @@ -1,1868 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)i386bsd-dep.c 6.10 (Berkeley) 6/26/91";*/ -static char rcsid[] = "$Id: i386bsd-dep.c,v 1.6 1994/01/28 02:12:24 mycroft Exp $"; -#endif /* not lint */ - -/* Low level interface to ptrace, for GDB when running on the Intel 386. - Copyright (C) 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "value.h" - -#include -#include -#include -#include -#include - -#include - -#ifndef N_SET_MAGIC -#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val)) -#endif - -#include -#include -#include -#define curpcb Xcurpcb /* XXX avoid leaking declaration from pcb.h */ -#include -#undef curpcb -#include -#include -#include - -#include - -#ifdef KERNELDEBUG -#ifndef NEWVM -#include -#include -#else -#include /* for curproc */ -#endif -#include -#include -#include -#include "symtab.h" /* XXX */ - -#undef vtophys /* XXX */ - -extern int kernel_debugging; - -#define KERNOFF ((unsigned)KERNBASE) -#ifndef NEWVM -#define INKERNEL(x) ((x) >= KERNOFF && (x) < KERNOFF + ctob(slr)) -#define INUPAGE(x) \ - ((x) >= KERNEL_U_ADDR && (x) < KERNEL_U_ADDR + NBPG) -#else -#define INKERNEL(x) ((x) >= KERNOFF) -#endif - -#define PT_ADDR_ANY ((caddr_t) 1) - -/* - * Convert from sysmap pte index to system virtual address & vice-versa. - * (why aren't these in one of the system vm macro files???) - */ -#define smxtob(a) (sbr + (a) * sizeof(pte)) -#define btosmx(b) (((b) - sbr) / sizeof(pte)) - -static int ok_to_cache(); -static int found_pcb; -#ifdef NEWVM -static CORE_ADDR curpcb; -static CORE_ADDR kstack; -#endif - -static void setregmap(); - -extern int errno; - -/* - * This function simply calls ptrace with the given arguments. It exists so - * that all calls to ptrace are isolated in this machine-dependent file. - */ -int -call_ptrace(request, pid, arg3, arg4) - int request; - pid_t pid; - caddr_t arg3; - int arg4; -{ - return(ptrace(request, pid, arg3, arg4)); -} - -kill_inferior() -{ - if (remote_debugging) { -#ifdef KERNELDEBUG - if (kernel_debugging) - /* - * It's a very, very bad idea to go away leaving - * breakpoints in a remote kernel or to leave it - * stopped at a breakpoint. - */ - clear_breakpoints(); -#endif - remote_close(0); - inferior_died(); - } else if (inferior_pid != 0) { - ptrace(PT_KILL, inferior_pid, 0, 0); - wait(0); - inferior_died(); - } -} - -/* - * This is used when GDB is exiting. It gives less chance of error. - */ -kill_inferior_fast() -{ - if (remote_debugging) { -#ifdef KERNELDEBUG - if (kernel_debugging) - clear_breakpoints(); -#endif - remote_close(0); - return; - } - if (inferior_pid == 0) - return; - - ptrace(PT_KILL, inferior_pid, 0, 0); - wait(0); -} - -/* - * Resume execution of the inferior process. If STEP is nonzero, single-step - * it. If SIGNAL is nonzero, give it that signal. - */ -void -resume(step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume(step, signal); - else { - ptrace(step ? PT_STEP : PT_CONTINUE, inferior_pid, - PT_ADDR_ANY, signal); - if (errno) - perror_with_name("ptrace"); - } -} - -#ifdef ATTACH_DETACH -extern int attach_flag; - -/* - * Start debugging the process whose number is PID. - */ -attach(pid) - int pid; -{ - errno = 0; - ptrace(PT_ATTACH, pid, 0, 0); - if (errno) - perror_with_name("ptrace"); - attach_flag = 1; - return pid; -} - -/* - * Stop debugging the process whose number is PID and continue it - * with signal number SIGNAL. SIGNAL = 0 means just continue it. - */ -void -detach(signal) - int signal; -{ - errno = 0; - ptrace(PT_DETACH, inferior_pid, PT_ADDR_ANY, signal); - if (errno) - perror_with_name("ptrace"); - attach_flag = 0; -} -#endif /* ATTACH_DETACH */ - -static unsigned int -get_register_offset() -{ - unsigned int offset; - struct user u; /* XXX */ - unsigned int flags = (char *) &u.u_pcb.pcb_flags - (char *) &u; - - setregmap(ptrace(PT_READ_U, inferior_pid, (caddr_t)flags, 0)); - -#ifdef NEWVM - offset = (char *) &u.u_kproc.kp_proc.p_regs - (char *) &u; - offset = ptrace(PT_READ_U, inferior_pid, (caddr_t)offset, 0) - - USRSTACK; -#else - offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace(PT_READ_U, inferior_pid, (caddr_t)offset, 0) - - KERNEL_U_ADDR; -#endif - - return offset; -} - -void -fetch_inferior_registers() -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - unsigned int offset; - - if (remote_debugging) { - extern char registers[]; - - remote_fetch_registers(registers); - return; - } - - offset = get_register_offset(); - - for (regno = 0; regno < NUM_REGS; regno++) { - regaddr = register_addr(regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE(regno); i += sizeof(int)) { - *(int *)&buf[i] = ptrace(PT_READ_U, inferior_pid, - (caddr_t)regaddr, 0); - regaddr += sizeof(int); - } - supply_register(regno, buf); - } -} - -/* - * Store our register values back into the inferior. If REGNO is -1, do this - * for all registers. Otherwise, REGNO specifies which register (so we can - * save time). - */ -store_inferior_registers(regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - extern char registers[]; - register int i; - unsigned int offset; - - if (remote_debugging) { - extern char registers[]; - - remote_store_registers(registers); - return; - } - - offset = get_register_offset(); - - if (regno >= 0) { - regaddr = register_addr(regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE(regno); i += sizeof(int)) { - errno = 0; - ptrace(PT_WRITE_U, inferior_pid, (caddr_t)regaddr, - *(int *) ®isters[REGISTER_BYTE(regno) + i]); - if (errno != 0) { - sprintf(buf, "writing register number %d(%d)", - regno, i); - perror_with_name(buf); - } - regaddr += sizeof(int); - } - } else - for (regno = 0; regno < NUM_REGS; regno++) { - regaddr = register_addr(regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE(regno); - i += sizeof(int)) { - errno = 0; - ptrace(PT_WRITE_U, inferior_pid, - (caddr_t)regaddr, - *(int *) ®isters[REGISTER_BYTE(regno) + i]); - if (errno != 0) { - sprintf(buf, - "writing register number %d(%d)", - regno, i); - perror_with_name(buf); - } - regaddr += sizeof(int); - } - } -} - -/* - * Copy LEN bytes from inferior's memory starting at MEMADDR to debugger - * memory starting at MYADDR. On failure (cannot read from inferior, usually - * because address is out of bounds) returns the value of errno. - */ -int -read_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & -sizeof(int); - /* Round ending address up; get number of longwords that makes. */ - register int count = (((memaddr + len) - addr) + sizeof(int) - 1) / - sizeof(int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca(count * sizeof(int)); - extern int errno; - - if (remote_debugging) - return (remote_read_inferior_memory(memaddr, myaddr, len)); - - /* Read all the longwords */ - errno = 0; - for (i = 0; i < count && errno == 0; i++, addr += sizeof(int)) - buffer[i] = ptrace(PT_READ_I, inferior_pid, (caddr_t)addr, 0); - - /* Copy appropriate bytes out of the buffer. */ - bcopy((char *) buffer + (memaddr & (sizeof(int) - 1)), myaddr, len); - return(errno); -} - -/* - * Copy LEN bytes of data from debugger memory at MYADDR to inferior's memory - * at MEMADDR. On failure (cannot write the inferior) returns the value of - * errno. - */ - -int -write_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & -sizeof(int); - /* Round ending address up; get number of longwords that makes. */ - register int count = (((memaddr + len) - addr) + sizeof(int) - 1) / - sizeof(int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca(count * sizeof(int)); - extern int errno; - - /* - * Fill start and end extra bytes of buffer with existing memory - * data. - */ - if (remote_debugging) - return (remote_write_inferior_memory(memaddr, myaddr, len)); - - /* - * Fill start and end extra bytes of buffer with existing memory - * data. - */ - buffer[0] = ptrace(PT_READ_I, inferior_pid, (caddr_t)addr, 0); - - if (count > 1) - buffer[count - 1] = ptrace(PT_READ_I, inferior_pid, - (caddr_t)addr + (count - 1) * sizeof(int), 0); - - /* Copy data to be written over corresponding part of buffer */ - - bcopy(myaddr, (char *) buffer + (memaddr & (sizeof(int) - 1)), len); - - /* Write the entire buffer. */ - - errno = 0; - for (i = 0; i < count && errno == 0; i++, addr += sizeof(int)) - ptrace(PT_WRITE_I, inferior_pid, (caddr_t)addr, buffer[i]); - - return(errno); -} - - -/* - * Work with core dump and executable files, for GDB. - * This code would be in core.c if it weren't machine-dependent. - */ - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* - * Make COFF and non-COFF names for things a little more compatible to reduce - * conditionals later. - */ - -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -extern int (*core_file_hook)(); - -#ifdef KERNELDEBUG -/* - * Kernel debugging routines. - */ - -#define IOTOP 0x100000 /* XXX should get this from include file */ -#define IOBASE 0xa0000 /* XXX should get this from include file */ - -static CORE_ADDR file_offset; -static CORE_ADDR lowram; -static CORE_ADDR sbr; -static CORE_ADDR slr; -static struct pcb pcb; - -static CORE_ADDR -ksym_lookup(name) - char *name; -{ - struct symbol *sym; - int i; - - if ((i = lookup_misc_func(name)) < 0) - error("kernel symbol `%s' not found.", name); - - return (misc_function_vector[i].address); -} - -/* - * return true if 'len' bytes starting at 'addr' can be read out as - * longwords and/or locally cached (this is mostly for memory mapped - * i/o register access when debugging remote kernels). - * - * XXX the HP code does this differently with NEWVM - */ -static int -ok_to_cache(addr, len) -{ - static CORE_ADDR atdevbase; - - if (! atdevbase) - atdevbase = ksym_lookup("atdevbase"); - - if (addr >= atdevbase && addr < atdevbase + (IOTOP - IOBASE)) - return (0); - - return (1); -} - -static -physrd(addr, dat, len) - u_int addr; - char *dat; -{ - if (lseek(corechan, addr - file_offset, L_SET) == -1) - return (-1); - if (read(corechan, dat, len) != len) - return (-1); - - return (0); -} - -/* - * When looking at kernel data space through /dev/mem or with a core file, do - * virtual memory mapping. - */ -#ifdef NEWVM -static CORE_ADDR -vtophys(addr) - CORE_ADDR addr; -{ - CORE_ADDR v; - struct pte pte; - static CORE_ADDR PTD = -1; - CORE_ADDR current_ptd; - - /* - * If we're looking at the kernel stack, - * munge the address to refer to the user space mapping instead; - * that way we get the requested process's kstack, not the running one. - */ - if (addr >= kstack && addr < kstack + ctob(UPAGES)) - addr = (addr - kstack) + curpcb; - - /* - * We may no longer have a linear system page table... - * - * Here's the scoop. IdlePTD contains the physical address - * of a page table directory that always maps the kernel. - * IdlePTD is in memory that is mapped 1-to-1, so we can - * find it easily given its 'virtual' address from ksym_lookup(). - * For hysterical reasons, the value of IdlePTD is stored in sbr. - * - * To look up a kernel address, we first convert it to a 1st-level - * address and look it up in IdlePTD. This gives us the physical - * address of a page table page; we extract the 2nd-level part of - * VA and read the 2nd-level pte. Finally, we add the offset part - * of the VA into the physical address from the pte and return it. - * - * User addresses are a little more complicated. If we don't have - * a current PCB from read_pcb(), we use PTD, which is the (fixed) - * virtual address of the current ptd. Since it's NOT in 1-to-1 - * kernel space, we must look it up using IdlePTD. If we do have - * a pcb, we get the ptd from pcb_ptd. - */ - - if (INKERNEL(addr)) - current_ptd = sbr; - else if (found_pcb == 0) { - if (PTD == -1) - PTD = vtophys(ksym_lookup("PTD")); - current_ptd = PTD; - } else - current_ptd = pcb.pcb_ptd; - - /* - * Read the first-level page table (ptd). - */ - v = current_ptd + ((unsigned)addr >> PDSHIFT) * sizeof pte; - if (physrd(v, (char *)&pte, sizeof pte) || pte.pg_v == 0) - return (~0); - - /* - * Read the second-level page table. - */ - v = i386_ptob(pte.pg_pfnum) + ((addr&PT_MASK) >> PGSHIFT) * sizeof pte; - if (physrd(v, (char *) &pte, sizeof(pte)) || pte.pg_v == 0) - return (~0); - - addr = i386_ptob(pte.pg_pfnum) + (addr & PGOFSET); -#if 0 - printf("vtophys(%x) -> %x\n", oldaddr, addr); -#endif - return (addr); -} -#else -static CORE_ADDR -vtophys(addr) - CORE_ADDR addr; -{ - CORE_ADDR v; - struct pte pte; - CORE_ADDR oldaddr = addr; - - if (found_pcb == 0 && INUPAGE(addr)) { - static CORE_ADDR pSwtchmap; - - if (pSwtchmap == 0) - pSwtchmap = vtophys(ksym_lookup("Swtchmap")); - addr = pSwtchmap; - } else if (INKERNEL(addr)) { - /* - * In system space get system pte. If valid or reclaimable - * then physical address is combination of its page number - * and the page offset of the original address. - */ - addr = smxtob(btop(addr - KERNOFF)) - KERNOFF; - } else { - v = btop(addr); - if (v < pcb.pcb_p0lr) - addr = (CORE_ADDR) pcb.pcb_p0br + - v * sizeof (struct pte); - else if (v >= pcb.pcb_p1lr && v < P1PAGES) - addr = (CORE_ADDR) pcb.pcb_p0br + - ((pcb.pcb_szpt * NPTEPG - HIGHPAGES) - - (BTOPUSRSTACK - v)) * sizeof (struct pte); - else - return (~0); - - /* - * For p0/p1 address, user-level page table should be in - * kernel vm. Do second-level indirect by recursing. - */ - if (!INKERNEL(addr)) - return (~0); - - addr = vtophys(addr); - } - /* - * Addr is now address of the pte of the page we are interested in; - * get the pte and paste up the physical address. - */ - if (physrd(addr, (char *) &pte, sizeof(pte))) - return (~0); - - if (pte.pg_v == 0 && (pte.pg_fod || pte.pg_pfnum == 0)) - return (~0); - - addr = (CORE_ADDR)ptob(pte.pg_pfnum) + (oldaddr & PGOFSET); -#if 0 - printf("vtophys(%x) -> %x\n", oldaddr, addr); -#endif - return (addr); -} - -#endif - -static -kvread(addr) - CORE_ADDR addr; -{ - CORE_ADDR paddr = vtophys(addr); - - if (paddr != ~0) - if (physrd(paddr, (char *)&addr, sizeof(addr)) == 0); - return (addr); - - return (~0); -} - -static void -read_pcb(uaddr) - u_int uaddr; -{ - int i; - int *pcb_regs = (int *)&pcb; - -#ifdef NEWVM - if (physrd(uaddr, (char *)&pcb, sizeof pcb)) - error("cannot read pcb at %x\n", uaddr); - printf("current pcb at %x\n", uaddr); -#else - if (physrd(uaddr, (char *)&pcb, sizeof pcb)) - error("cannot read pcb at %x\n", uaddr); - printf("p0br %x p0lr %x p1br %x p1lr %x\n", - pcb.pcb_p0br, pcb.pcb_p0lr, pcb.pcb_p1br, pcb.pcb_p1lr); -#endif - - /* - * get the register values out of the sys pcb and - * store them where `read_register' will find them. - */ - for (i = 0; i < 8; ++i) - supply_register(i, &pcb_regs[i+10]); - supply_register(8, &pcb_regs[8]); /* eip */ - supply_register(9, &pcb_regs[9]); /* eflags */ - for (i = 10; i < 13; ++i) /* cs, ss, ds */ - supply_register(i, &pcb_regs[i+9]); - supply_register(13, &pcb_regs[18]); /* es */ - for (i = 14; i < 16; ++i) /* fs, gs */ - supply_register(i, &pcb_regs[i+8]); - - /* XXX 80387 registers? */ -} - -static void -setup_kernel_debugging() -{ - struct stat stb; - int devmem = 0; - CORE_ADDR addr; - - fstat(corechan, &stb); - if ((stb.st_mode & S_IFMT) == S_IFCHR && stb.st_rdev == makedev(2, 0)) - devmem = 1; - -#ifdef NEWVM - physrd(ksym_lookup("IdlePTD") - KERNOFF, &sbr, sizeof sbr); - slr = 2 * NPTEPG; /* XXX temporary */ - printf("IdlePTD %x\n", sbr); - curpcb = ksym_lookup("curpcb") - KERNOFF; - physrd(curpcb, &curpcb, sizeof curpcb); - kstack = ksym_lookup("kstack"); -#else - sbr = ksym_lookup("Sysmap"); - slr = ksym_lookup("Syssize"); - printf("sbr %x slr %x\n", sbr, slr); -#endif - - /* - * pcb where "panic" saved registers in first thing in current - * u area. - */ -#ifndef NEWVM - read_pcb(vtophys(ksym_lookup("u"))); -#endif - found_pcb = 1; - if (!devmem) { - /* find stack frame */ - CORE_ADDR panicstr; - char buf[256]; - register char *cp; - - panicstr = kvread(ksym_lookup("panicstr")); - if (panicstr == ~0) - return; - (void) kernel_core_file_hook(panicstr, buf, sizeof(buf)); - for (cp = buf; cp < &buf[sizeof(buf)] && *cp; cp++) - if (!isascii(*cp) || (!isprint(*cp) && !isspace(*cp))) - *cp = '?'; - if (*cp) - *cp = '\0'; - printf("panic: %s\n", buf); - read_pcb(ksym_lookup("dumppcb") - KERNOFF); - } -#ifdef NEWVM - else - read_pcb(vtophys(kstack)); -#endif - - stack_start = USRSTACK; - stack_end = USRSTACK + ctob(UPAGES); -} - -set_paddr_command(arg) - char *arg; -{ - u_int uaddr; - - if (!arg) - error_no_arg("ps-style address for new current process"); - if (!kernel_debugging) - error("not debugging kernel"); - uaddr = (u_int) parse_and_eval_address(arg); -#ifndef NEWVM - read_pcb(ctob(uaddr)); -#else - /* p_addr is now a pcb virtual address */ - read_pcb(vtophys(uaddr)); - curpcb = uaddr; -#endif - - flush_cached_frames(); - set_current_frame(create_new_frame(read_register(FP_REGNUM), read_pc())); - select_frame(get_current_frame(), 0); -} - -/* - * read len bytes from kernel virtual address 'addr' into local - * buffer 'buf'. Return 0 if read ok, 1 otherwise. On read - * errors, portion of buffer not read is zeroed. - */ -kernel_core_file_hook(addr, buf, len) - CORE_ADDR addr; - char *buf; - int len; -{ - int i; - CORE_ADDR paddr; - - while (len > 0) { - paddr = vtophys(addr); - if (paddr == ~0) { - bzero(buf, len); - return (1); - } - /* we can't read across a page boundary */ - i = min(len, NBPG - (addr & PGOFSET)); - if (physrd(paddr, buf, i)) { - bzero(buf, len); - return (1); - } - buf += i; - addr += i; - len -= i; - } - return (0); -} -#endif - -core_file_command(filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; -#ifdef KERNELDEBUG - struct stat stb; -#endif - - /* - * Discard all vestiges of any previous core file and mark data and - * stack spaces as empty. - */ - if (corefile) - free(corefile); - corefile = 0; - core_file_hook = 0; - - if (corechan >= 0) - close(corechan); - corechan = -1; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename == 0) { - if (from_tty) - printf("No core file now.\n"); - return; - } - filename = tilde_expand(filename); - make_cleanup(free, filename); - if (have_inferior_p()) - error("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open(filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name(filename); - -#ifdef KERNELDEBUG - fstat(corechan, &stb); - - if (kernel_debugging) { - setup_kernel_debugging(); - core_file_hook = kernel_core_file_hook; - } else if ((stb.st_mode & S_IFMT) == S_IFCHR && - stb.st_rdev == makedev(2, 1)) { - /* looking at /dev/kmem */ - data_offset = data_start = KERNOFF; - data_end = ~0; /* XXX */ - stack_end = stack_start = data_end; - } else -#endif - { - /* - * 4.2-style core dump file. - */ - struct user u; - unsigned int reg_offset; - - val = myread(corechan, &u, sizeof u); - if (val < 0) - perror_with_name("Not a core file: reading upage"); - if (val != sizeof u) - error("Not a core file: could only read %d bytes", val); - - /* - * We are depending on exec_file_command having been - * called previously to set exec_data_start. Since - * the executable and the core file share the same - * text segment, the address of the data segment will - * be the same in both. - */ - data_start = exec_data_start; - -#ifndef NEWVM - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - - /* - * Some machines put an absolute address in here and - * some put the offset in the upage of the regs. - */ - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; -#else - data_end = data_start + - NBPG * u.u_kproc.kp_eproc.e_vm.vm_dsize; - stack_start = stack_end - - NBPG * u.u_kproc.kp_eproc.e_vm.vm_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * - (UPAGES + u.u_kproc.kp_eproc.e_vm.vm_dsize); - - reg_offset = (int) u.u_kproc.kp_proc.p_regs - USRSTACK; -#endif - - setregmap(u.u_pcb.pcb_flags); - - /* - * I don't know where to find this info. So, for now, - * mark it as not available. - */ - /* N_SET_MAGIC (core_aouthdr, 0); */ - bzero ((char *) &core_aouthdr, sizeof core_aouthdr); - - /* - * Read the register values out of the core file and - * store them where `read_register' will find them. - */ - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek(corechan, register_addr(regno, reg_offset), 0); - if (val < 0 - || (val = myread(corechan, buf, sizeof buf)) < 0) { - char *buffer = (char *) alloca(strlen(reg_names[regno]) + 30); - strcpy(buffer, "Reading register "); - strcat(buffer, reg_names[regno]); - perror_with_name(buffer); - } - supply_register(regno, buf); - } - } - } -#endif - if (filename[0] == '/') - corefile = savestring(filename, strlen(filename)); - else - corefile = concat(current_directory, "/", filename); - - set_current_frame(create_new_frame(read_register(FP_REGNUM), - read_pc())); - select_frame(get_current_frame(), 0); - validate_files(); -} - -exec_file_command(filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* - * Eliminate all traces of old exec file. Mark text segment as empty. - */ - - if (execfile) - free(execfile); - execfile = 0; - data_start = 0; - data_end = 0; - stack_start = 0; - stack_end = 0; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close(execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) { - filename = tilde_expand(filename); - make_cleanup(free, filename); - - execchan = openp(getenv("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name(filename); - - { - struct stat st_exec; - -#ifdef HEADER_SEEK_FD - HEADER_SEEK_FD(execchan); -#endif - - val = myread(execchan, &exec_aouthdr, sizeof(AOUTHDR)); - - if (val < 0) - perror_with_name(filename); - -#ifdef KERNELDEBUG - if (kernel_debugging) { - /* Gross and disgusting XXX */ - text_start = KERNTEXT_BASE; - exec_data_start = KERNTEXT_BASE + - (exec_aouthdr.a_text + 4095) & ~ 4095; - } else { -#endif - text_start = N_TXTADDR(exec_aouthdr); - exec_data_start = N_DATADDR(exec_aouthdr); -#ifdef KERNELDEBUG - } -#endif - - text_offset = N_TXTOFF(exec_aouthdr); - exec_data_offset = N_TXTOFF(exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - - fstat(execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } - - validate_files(); - } else if (from_tty) - printf("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -int dummy_code[] = { - 0xb8909090, /* nop; nop; nop; movl $0x32323232,%eax */ - 0x32323232, -#define DUMMY_CALL_INDEX 1 - 0x90ccd0ff, /* call %eax; int3; nop */ -}; - -/* - * Build `dummy' call instructions on inferior's stack to cause - * it to call a subroutine. - * - * N.B. - code in wait_for_inferior requires that sp < pc < fp when - * we take the trap 2 above so it will recognize that we stopped - * at a `dummy' call. So, after the call sp is *not* decremented - * to clean the arguments, code & other stuff we lay on the stack. - * Since the regs are restored to saved values at the breakpoint, - * sp will get reset correctly. Also, this restore means we don't - * have to construct frame linkage info to save pc & fp. The lack - * of frame linkage means we can't do a backtrace, etc., if the - * called function gets a fault or hits a breakpoint but code in - * run_stack_dummy makes this impossible anyway. - */ -CORE_ADDR -setup_dummy(sp, funaddr, nargs, args, struct_return_bytes, pushfn) - CORE_ADDR sp; - CORE_ADDR funaddr; - int nargs; - value *args; - int struct_return_bytes; - CORE_ADDR (*pushfn)(); -{ - int padding, i; - CORE_ADDR top = sp, struct_addr, pc; - - i = arg_stacklen(nargs, args) + struct_return_bytes - + sizeof(dummy_code); - if (i & 3) - padding = 4 - (i & 3); - else - padding = 0; - pc = sp - sizeof(dummy_code); - sp = pc - padding - struct_return_bytes; - struct_addr = sp; - while (--nargs >= 0) - sp = (*pushfn)(sp, *args++); - if (struct_return_bytes) - STORE_STRUCT_RETURN(struct_addr, sp); - write_register(SP_REGNUM, sp); - - dummy_code[DUMMY_CALL_INDEX] = (int)funaddr; - write_memory(pc, (char *)dummy_code, sizeof(dummy_code)); - - return pc; -} - -/* helper functions for m-i386.h */ - -/* stdio style buffering to minimize calls to ptrace */ -static CORE_ADDR codestream_next_addr; -static CORE_ADDR codestream_addr; -static unsigned char codestream_buf[sizeof (int)]; -static int codestream_off; -static int codestream_cnt; - -#define codestream_tell() (codestream_addr + codestream_off) -#define codestream_peek() (codestream_cnt == 0 ? \ - codestream_fill(1): codestream_buf[codestream_off]) -#define codestream_get() (codestream_cnt-- == 0 ? \ - codestream_fill(0) : codestream_buf[codestream_off++]) - -static unsigned char -codestream_fill (peek_flag) -{ - codestream_addr = codestream_next_addr; - codestream_next_addr += sizeof (int); - codestream_off = 0; - codestream_cnt = sizeof (int); - read_memory (codestream_addr, - (unsigned char *)codestream_buf, - sizeof (int)); - - if (peek_flag) - return (codestream_peek()); - else - return (codestream_get()); -} - -static void -codestream_seek (place) -{ - codestream_next_addr = place & -sizeof (int); - codestream_cnt = 0; - codestream_fill (1); - while (codestream_tell() != place) - codestream_get (); -} - -static void -codestream_read (buf, count) - unsigned char *buf; -{ - unsigned char *p; - int i; - p = buf; - for (i = 0; i < count; i++) - *p++ = codestream_get (); -} - -/* next instruction is a jump, move to target */ -static -i386_follow_jump () -{ - int long_delta; - short short_delta; - char byte_delta; - int data16; - int pos; - - pos = codestream_tell (); - - data16 = 0; - if (codestream_peek () == 0x66) - { - codestream_get (); - data16 = 1; - } - - switch (codestream_get ()) - { - case 0xe9: - /* relative jump: if data16 == 0, disp32, else disp16 */ - if (data16) - { - codestream_read ((unsigned char *)&short_delta, 2); - pos += short_delta + 3; /* include size of jmp inst */ - } - else - { - codestream_read ((unsigned char *)&long_delta, 4); - pos += long_delta + 5; - } - break; - case 0xeb: - /* relative jump, disp8 (ignore data16) */ - codestream_read ((unsigned char *)&byte_delta, 1); - pos += byte_delta + 2; - break; - } - codestream_seek (pos + data16); -} - -/* - * find & return amound a local space allocated, and advance codestream to - * first register push (if any) - * - * if entry sequence doesn't make sense, return -1, and leave - * codestream pointer random - */ -static long -i386_get_frame_setup (pc) -{ - unsigned char op; - - codestream_seek (pc); - - i386_follow_jump (); - - op = codestream_get (); - - if (op == 0x58) /* popl %eax */ - { - /* - * this function must start with - * - * popl %eax 0x58 - * xchgl %eax, (%esp) 0x87 0x04 0x24 - * or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00 - * - * (the system 5 compiler puts out the second xchg - * inst, and the assembler doesn't try to optimize it, - * so the 'sib' form gets generated) - * - * this sequence is used to get the address of the return - * buffer for a function that returns a structure - */ - int pos; - unsigned char buf[4]; - static unsigned char proto1[3] = { 0x87,0x04,0x24 }; - static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 }; - pos = codestream_tell (); - codestream_read (buf, 4); - if (bcmp (buf, proto1, 3) == 0) - pos += 3; - else if (bcmp (buf, proto2, 4) == 0) - pos += 4; - - codestream_seek (pos); - op = codestream_get (); /* update next opcode */ - } - - if (op == 0x55) /* pushl %esp */ - { - /* check for movl %esp, %ebp - can be written two ways */ - switch (codestream_get ()) - { - case 0x8b: - if (codestream_get () != 0xec) - return (-1); - break; - case 0x89: - if (codestream_get () != 0xe5) - return (-1); - break; - default: - return (-1); - } - /* check for stack adjustment - * - * subl $XXX, %esp - * - * note: you can't subtract a 16 bit immediate - * from a 32 bit reg, so we don't have to worry - * about a data16 prefix - */ - op = codestream_peek (); - if (op == 0x83) - { - /* subl with 8 bit immed */ - codestream_get (); - if (codestream_get () != 0xec) - return (-1); - /* subl with signed byte immediate - * (though it wouldn't make sense to be negative) - */ - return (codestream_get()); - } - else if (op == 0x81) - { - /* subl with 32 bit immed */ - int locals; - codestream_get(); - if (codestream_get () != 0xec) - return (-1); - /* subl with 32 bit immediate */ - codestream_read ((unsigned char *)&locals, 4); - return (locals); - } - else - { - return (0); - } - } - else if (op == 0xc8) - { - /* enter instruction: arg is 16 bit unsigned immed */ - unsigned short slocals; - codestream_read ((unsigned char *)&slocals, 2); - codestream_get (); /* flush final byte of enter instruction */ - return (slocals); - } - return (-1); -} - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -/* on the 386, the instruction following the call could be: - * popl %ecx - one arg - * addl $imm, %esp - imm/4 args; imm may be 8 or 32 bits - * anything else - zero args - */ - -int -i386_frame_num_args (fi) - struct frame_info fi; -{ - int retpc; - unsigned char op; - struct frame_info *pfi; - - pfi = get_prev_frame_info ((fi)); - if (pfi == 0) - { - /* Note: this can happen if we are looking at the frame for - main, because FRAME_CHAIN_VALID won't let us go into - start. If we have debugging symbols, that's not really - a big deal; it just means it will only show as many arguments - to main as are declared. */ - return -1; - } - else - { - retpc = pfi->pc; - op = read_memory_integer (retpc, 1); - if (op == 0x59) - /* pop %ecx */ - return 1; - else if (op == 0x83) - { - op = read_memory_integer (retpc+1, 1); - if (op == 0xc4) - /* addl $, %esp */ - return (read_memory_integer (retpc+2,1)&0xff)/4; - else - return 0; - } - else if (op == 0x81) - { /* add with 32 bit immediate */ - op = read_memory_integer (retpc+1, 1); - if (op == 0xc4) - /* addl $, %esp */ - return read_memory_integer (retpc+2, 4) / 4; - else - return 0; - } - else - { - return 0; - } - } -} - -/* - * parse the first few instructions of the function to see - * what registers were stored. - * - * We handle these cases: - * - * The startup sequence can be at the start of the function, - * or the function can start with a branch to startup code at the end. - * - * %ebp can be set up with either the 'enter' instruction, or - * 'pushl %ebp, movl %esp, %ebp' (enter is too slow to be useful, - * but was once used in the sys5 compiler) - * - * Local space is allocated just below the saved %ebp by either the - * 'enter' instruction, or by 'subl $, %esp'. 'enter' has - * a 16 bit unsigned argument for space to allocate, and the - * 'addl' instruction could have either a signed byte, or - * 32 bit immediate. - * - * Next, the registers used by this function are pushed. In - * the sys5 compiler they will always be in the order: %edi, %esi, %ebx - * (and sometimes a harmless bug causes it to also save but not restore %eax); - * however, the code below is willing to see the pushes in any order, - * and will handle up to 8 of them. - * - * If the setup sequence is at the end of the function, then the - * next instruction will be a branch back to the start. - */ - -i386_frame_find_saved_regs (fip, fsrp) - struct frame_info *fip; - struct frame_saved_regs *fsrp; -{ - unsigned long locals; - unsigned char *p; - unsigned char op; - CORE_ADDR dummy_bottom; - CORE_ADDR adr; - int i; - - bzero (fsrp, sizeof *fsrp); - -#if 0 - /* if frame is the end of a dummy, compute where the - * beginning would be - */ - dummy_bottom = fip->frame - 4 - NUM_REGS*4 - CALL_DUMMY_LENGTH; - - /* check if the PC is in the stack, in a dummy frame */ - if (dummy_bottom <= fip->pc && fip->pc <= fip->frame) - { - /* all regs were saved by push_call_dummy () */ - adr = fip->frame - 4; - for (i = 0; i < NUM_REGS; i++) - { - fsrp->regs[i] = adr; - adr -= 4; - } - return; - } -#endif - - locals = i386_get_frame_setup (get_pc_function_start (fip->pc)); - - if (locals >= 0) - { - adr = fip->frame - 4 - locals; - for (i = 0; i < 8; i++) - { - op = codestream_get (); - if (op < 0x50 || op > 0x57) - break; - fsrp->regs[op - 0x50] = adr; - adr -= 4; - } - } - - fsrp->regs[PC_REGNUM] = fip->frame + 4; - fsrp->regs[FP_REGNUM] = fip->frame; -} - -/* return pc of first real instruction */ -i386_skip_prologue (pc) -{ - unsigned char op; - int i; - - if (i386_get_frame_setup (pc) < 0) - return (pc); - - /* found valid frame setup - codestream now points to - * start of push instructions for saving registers - */ - - /* skip over register saves */ - for (i = 0; i < 8; i++) - { - op = codestream_peek (); - /* break if not pushl inst */ - if (op < 0x50 || op > 0x57) - break; - codestream_get (); - } - - i386_follow_jump (); - - return (codestream_tell ()); -} - -i386_pop_frame () -{ - FRAME frame = get_current_frame (); - CORE_ADDR fp; - int regnum; - struct frame_saved_regs fsr; - struct frame_info *fi; - - fi = get_frame_info (frame); - fp = fi->frame; - get_frame_saved_regs (fi, &fsr); - for (regnum = 0; regnum < NUM_REGS; regnum++) - { - CORE_ADDR adr; - adr = fsr.regs[regnum]; - if (adr) - write_register (regnum, read_memory_integer (adr, 4)); - } - write_register (FP_REGNUM, read_memory_integer (fp, 4)); - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); - write_register (SP_REGNUM, fp + 8); - flush_cached_frames (); - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); -} - -/* this table must line up with REGISTER_NAMES in m-i386.h */ -/* symbols like 'EAX' come from */ -static int trapmap[] = -{ - tEAX, tECX, tEDX, tEBX, - tESP, tEBP, tESI, tEDI, - tEIP, tEFLAGS, tCS, tSS, - tDS, tES, tES, tES /* lies: no fs or gs */ -}; -#ifdef FM_TRAP -static int syscallmap[] = -{ - sEAX, sECX, sEDX, sEBX, - sESP, sEBP, sESI, sEDI, - sEIP, sEFLAGS, sCS, sSS, - sCS, sCS, sCS, sCS /* lies: no ds, es, fs or gs */ -}; -#endif -static int *regmap; - -static void -setregmap(flags) - int flags; -{ -#ifdef FM_TRAP - regmap = flags & FM_TRAP ? trapmap: syscallmap; -#elif EX_TRAPSTK - regmap = flags & EX_TRAPSTK ? trapmap : syscallmap; -#else - regmap = trapmap; /* the lesser evil */ -#endif -} - -/* blockend is the value of u.u_ar0, and points to the - * place where GS is stored - */ -i386_register_u_addr (blockend, regnum) -{ -#if 0 - /* this will be needed if fp registers are reinstated */ - /* for now, you can look at them with 'info float' - * sys5 wont let you change them with ptrace anyway - */ - if (regnum >= FP0_REGNUM && regnum <= FP7_REGNUM) - { - int ubase, fpstate; - struct user u; - ubase = blockend + 4 * (SS + 1) - KSTKSZ; - fpstate = ubase + ((char *)&u.u_fpstate - (char *)&u); - return (fpstate + 0x1c + 10 * (regnum - FP0_REGNUM)); - } - else -#endif - return (blockend + 4 * regmap[regnum]); -} - -i387_to_double (from, to) - char *from; - char *to; -{ - long *lp; - /* push extended mode on 387 stack, then pop in double mode - * - * first, set exception masks so no error is generated - - * number will be rounded to inf or 0, if necessary - */ - asm ("pushl %eax"); /* grab a stack slot */ - asm ("fstcw (%esp)"); /* get 387 control word */ - asm ("movl (%esp),%eax"); /* save old value */ - asm ("orl $0x3f,%eax"); /* mask all exceptions */ - asm ("pushl %eax"); - asm ("fldcw (%esp)"); /* load new value into 387 */ - - asm ("movl 8(%ebp),%eax"); - asm ("fldt (%eax)"); /* push extended number on 387 stack */ - asm ("fwait"); - asm ("movl 12(%ebp),%eax"); - asm ("fstpl (%eax)"); /* pop double */ - asm ("fwait"); - - asm ("popl %eax"); /* flush modified control word */ - asm ("fnclex"); /* clear exceptions */ - asm ("fldcw (%esp)"); /* restore original control word */ - asm ("popl %eax"); /* flush saved copy */ -} - -double_to_i387 (from, to) - char *from; - char *to; -{ - /* push double mode on 387 stack, then pop in extended mode - * no errors are possible because every 64-bit pattern - * can be converted to an extended - */ - asm ("movl 8(%ebp),%eax"); - asm ("fldl (%eax)"); - asm ("fwait"); - asm ("movl 12(%ebp),%eax"); - asm ("fstpt (%eax)"); - asm ("fwait"); -} - -struct env387 -{ - unsigned short control; - unsigned short r0; - unsigned short status; - unsigned short r1; - unsigned short tag; - unsigned short r2; - unsigned long eip; - unsigned short code_seg; - unsigned short opcode; - unsigned long operand; - unsigned short operand_seg; - unsigned short r3; - unsigned char regs[8][10]; -}; - -static -print_387_control_word (control) -unsigned short control; -{ - printf ("control 0x%04x: ", control); - printf ("compute to "); - switch ((control >> 8) & 3) - { - case 0: printf ("24 bits; "); break; - case 1: printf ("(bad); "); break; - case 2: printf ("53 bits; "); break; - case 3: printf ("64 bits; "); break; - } - printf ("round "); - switch ((control >> 10) & 3) - { - case 0: printf ("NEAREST; "); break; - case 1: printf ("DOWN; "); break; - case 2: printf ("UP; "); break; - case 3: printf ("CHOP; "); break; - } - if (control & 0x3f) - { - printf ("mask:"); - if (control & 0x0001) printf (" INVALID"); - if (control & 0x0002) printf (" DENORM"); - if (control & 0x0004) printf (" DIVZ"); - if (control & 0x0008) printf (" OVERF"); - if (control & 0x0010) printf (" UNDERF"); - if (control & 0x0020) printf (" LOS"); - printf (";"); - } - printf ("\n"); - if (control & 0xe080) printf ("warning: reserved bits on 0x%x\n", - control & 0xe080); -} - -static -print_387_status_word (status) - unsigned short status; -{ - printf ("status 0x%04x: ", status); - if (status & 0xff) - { - printf ("exceptions:"); - if (status & 0x0001) printf (" INVALID"); - if (status & 0x0002) printf (" DENORM"); - if (status & 0x0004) printf (" DIVZ"); - if (status & 0x0008) printf (" OVERF"); - if (status & 0x0010) printf (" UNDERF"); - if (status & 0x0020) printf (" LOS"); - if (status & 0x0040) printf (" FPSTACK"); - printf ("; "); - } - printf ("flags: %d%d%d%d; ", - (status & 0x4000) != 0, - (status & 0x0400) != 0, - (status & 0x0200) != 0, - (status & 0x0100) != 0); - - printf ("top %d\n", (status >> 11) & 7); -} - -static -print_387_status (status, ep) - unsigned short status; - struct env387 *ep; -{ - int i; - int bothstatus; - int top; - int fpreg; - unsigned char *p; - - bothstatus = ((status != 0) && (ep->status != 0)); - if (status != 0) - { - if (bothstatus) - printf ("u: "); - print_387_status_word (status); - } - - if (ep->status != 0) - { - if (bothstatus) - printf ("e: "); - print_387_status_word (ep->status); - } - - print_387_control_word (ep->control); - printf ("last exception: "); - printf ("opcode 0x%x; ", ep->opcode); - printf ("pc 0x%x:0x%x; ", ep->code_seg, ep->eip); - printf ("operand 0x%x:0x%x\n", ep->operand_seg, ep->operand); - - top = (ep->status >> 11) & 7; - - printf ("regno tag msb lsb value\n"); - for (fpreg = 7; fpreg >= 0; fpreg--) - { - double val; - - printf ("%s %d: ", fpreg == top ? "=>" : " ", fpreg); - - switch ((ep->tag >> (fpreg * 2)) & 3) - { - case 0: printf ("valid "); break; - case 1: printf ("zero "); break; - case 2: printf ("trap "); break; - case 3: printf ("empty "); break; - } - for (i = 9; i >= 0; i--) - printf ("%02x", ep->regs[fpreg][i]); - - i387_to_double (ep->regs[fpreg], (char *)&val); - printf (" %g\n", val); - } - if (ep->r0) - printf ("warning: reserved0 is 0x%x\n", ep->r0); - if (ep->r1) - printf ("warning: reserved1 is 0x%x\n", ep->r1); - if (ep->r2) - printf ("warning: reserved2 is 0x%x\n", ep->r2); - if (ep->r3) - printf ("warning: reserved3 is 0x%x\n", ep->r3); -} - -#ifndef U_FPSTATE -#define U_FPSTATE(u) u.u_fpstate -#endif - -i386_float_info () -{ - struct user u; /* just for address computations */ - int i; -#ifndef __NetBSD__ - /* fpstate defined in */ - struct fpstate *fpstatep; - char buf[sizeof (struct fpstate) + 2 * sizeof (int)]; - unsigned int uaddr; - char fpvalid; - unsigned int rounded_addr; - unsigned int rounded_size; - extern int corechan; - int skip; - - uaddr = (char *)&u.u_fpvalid - (char *)&u; - if (have_inferior_p()) - { - unsigned int data; - unsigned int mask; - - rounded_addr = uaddr & -sizeof (int); - data = ptrace (3, inferior_pid, rounded_addr, 0); - mask = 0xff << ((uaddr - rounded_addr) * 8); - - fpvalid = ((data & mask) != 0); - } - else - { - if (lseek (corechan, uaddr, 0) < 0) - perror ("seek on core file"); - if (myread (corechan, &fpvalid, 1) < 0) - perror ("read on core file"); - - } - - if (fpvalid == 0) - { - printf ("no floating point status saved\n"); - return; - } - - uaddr = (char *)&U_FPSTATE(u) - (char *)&u; - if (have_inferior_p ()) - { - int *ip; - - rounded_addr = uaddr & -sizeof (int); - rounded_size = (((uaddr + sizeof (struct fpstate)) - uaddr) + - sizeof (int) - 1) / sizeof (int); - skip = uaddr - rounded_addr; - - ip = (int *)buf; - for (i = 0; i < rounded_size; i++) - { - *ip++ = ptrace (3, inferior_pid, rounded_addr, 0); - rounded_addr += sizeof (int); - } - } - else - { - if (lseek (corechan, uaddr, 0) < 0) - perror_with_name ("seek on core file"); - if (myread (corechan, buf, sizeof (struct fpstate)) < 0) - perror_with_name ("read from core file"); - skip = 0; - } - - fpstatep = (struct fpstate *)(buf + skip); - print_387_status (fpstatep->status, (struct env387 *)fpstatep->state); -#endif -} - -void -_initialize_i386bsd_dep() -{ -#ifdef KERNELDEBUG - add_com ("process-address", class_obscure, set_paddr_command, - "The process identified by (ps-style) ADDR becomes the\n\ -\"current\" process context for kernel debugging."); - add_com_alias ("paddr", "process-address", class_obscure, 0); -#endif -} diff --git a/gnu/usr.bin/gdb/config/isi-dep.c b/gnu/usr.bin/gdb/config/isi-dep.c deleted file mode 100644 index 7cda5588ff5c..000000000000 --- a/gnu/usr.bin/gdb/config/isi-dep.c +++ /dev/null @@ -1,630 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1988 Free Software Foundation, Inc. - -GDB is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY. No author or distributor accepts responsibility to anyone -for the consequences of using it or for whether it serves any -particular purpose or works at all, unless he says so in writing. -Refer to the GDB General Public License for full details. - -Everyone is granted permission to copy, modify and redistribute GDB, -but only under the conditions described in the GDB General Public -License. A copy of this license is supposed to have been given to you -along with GDB so you can know your rights and responsibilities. It -should be in a file named COPYING. Among other things, the copyright -notice and this notice must be preserved on all copies. - -In other words, go ahead and share GDB, but don't try to stop -anyone else from sharing it farther. Help stamp out software hoarding! -*/ - -#ifndef lint -static char rcsid[] = "$Id: isi-dep.c,v 1.2 1993/08/02 17:39:50 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -#include -#include - -#ifdef COFF_ENCAPSULATE -#include "a.out.encap.h" -#else -#include -#endif -#ifndef N_SET_MAGIC -#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val)) -#endif -#include -#include - -#include -#ifdef ATTACH_DETACH -static int oldParent; -extern int attach_flag; -#endif /* ATTACH_DETACH */ - -/* - * Mapping of register numbers to their position in the stack - */ -#include -int rloc[] = { - R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, FP, SP, PS, PC -}; - -extern int errno; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -#ifdef ATTACH_DETACH -/* Start debugging the process whose number is PID. */ - -attach (pid) - int pid; -{ - errno = 0; - oldParent = ptrace (PT_ATTACH, pid, 0, 0); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 1; - return pid; -} - -/* Stop debugging the process whose number is PID - and continue it with signal number SIGNAL. - SIGNAL = 0 means just continue it. */ - -void -detach (signal) - int signal; -{ - errno = 0; - ptrace (PT_DETACH, inferior_pid, signal, oldParent); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 0; -} - -#endif /* ATTACH_DETACH */ - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - -#ifdef ATTACH_DETACH - if (attach_flag) { - /* - * Need to detach so the old parent gets notified of the death. - */ - detach(SIGKILL); - } else { -#endif /* ATTACH_DETACH */ - ptrace (PT_KILL, inferior_pid, 0, 0); - wait (0); -#ifdef ATTACH_DETACH - } -#endif /* ATTACH_DETACH */ - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; -#ifdef ATTACH_DETACH - if (attach_flag) { - detach(SIGKILL); - } else { -#endif /* ATTACH_DETACH */ - ptrace (PT_KILL, inferior_pid, 0, 0); - wait (0); -#ifdef ATTACH_DETACH - } -#endif /* ATTACH_DETACH */ -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? PT_STEP : PT_CONTINUE, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -void -fetch_inferior_registers () -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - struct user u; - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - struct user u; - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - if (regno >= 0) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - else for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } -} - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - buffer[0] = remote_fetch_word (addr); - else - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - if (remote_debugging) - buffer[count - 1] - = remote_fetch_word (addr + (count - 1) * sizeof (int)); - else - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - remote_store_word (addr, buffer[i]); - else - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -/* Recognize COFF format systems because a.out.h defines AOUTHDR. */ -#ifdef AOUTHDR -#define COFF_FORMAT -#endif - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#define AOUTHDR struct exec -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - N_SET_MAGIC (core_aouthdr, 0); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - -#ifdef HEADER_SEEK_FD - HEADER_SEEK_FD (execchan); -#endif - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_TXTADDR (exec_aouthdr); - exec_data_start = N_DATADDR (exec_aouthdr); - - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} diff --git a/gnu/usr.bin/gdb/config/m-altos.h b/gnu/usr.bin/gdb/config/m-altos.h deleted file mode 100644 index 4954e37b947a..000000000000 --- a/gnu/usr.bin/gdb/config/m-altos.h +++ /dev/null @@ -1,804 +0,0 @@ -/* Definitions to make GDB run on an Altos 3068 (m68k running SVR2) - Copyright (C) 1987,1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-altos.h,v 1.2 1993/08/02 17:39:51 mycroft Exp $ -*/ - -/* The altos support would make a good base for a port to other USGR2 systems - (like the 3b1 and the Convergent miniframe). */ - -/* This is only needed in one file, but it's cleaner to put it here than - putting in more #ifdef's. */ -#include -#include - -#ifndef ALTOS -#define ALTOS -#endif - -#define USG - -/* Define the bit, byte, and word ordering of the machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* Get rid of any system-imposed stack limit if possible. */ - -/*#define SET_STACK_LIMIT_HUGE*/ - -#define HAVE_TERMIO - -#define CBREAK XTABS /* It takes all kinds... */ - -/* - * #define FLOATING_POINT if you have 68881 - * This hasn't been tested - */ - -/*#define FLOATING_POINT*/ -/*#undef FLOATING_POINT*/ - -#ifndef __GNUC__ -#undef USE_GAS -#define ALTOS_AS -#else -#define USE_GAS -#endif - -#ifndef R_OK -#define R_OK 4 -#define W_OK 2 -#define X_OK 1 -#define F_OK 0 -#endif - -#ifndef MAXPATHLEN -#define MAXPATHLEN (1024) -#endif - -/* Motorola assembly format */ -#if !defined(USE_GAS) && !defined(ALTOS) -#define MOTOROLA -#endif - -/* Get sys/wait.h ie. from a Sun and edit it a little (mc68000 to m68k) */ -#define HAVE_WAIT_STRUCT - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#undef NAMES_HAVE_UNDERSCORE - -/* Exec files and symbol tables are in COFF format */ - -#define COFF_FORMAT -#define COFF_NO_LONG_FILE_NAMES -#define vfork fork - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = read_memory_integer (pc, 2); \ - if (op == 0047126) \ - pc += 4; /* Skip link #word */ \ - else if (op == 0044016) \ - pc += 6; /* Skip link #long */ \ - else if (op == 0060000) \ - pc += 4; /* Skip bra #word */ \ - else if (op == 00600377) \ - pc += 6; /* skip bra #long */ \ - else if ((op & 0177400) == 0060000) \ - pc += 2; /* skip bra #char */ \ -} - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ -read_memory_integer (read_register (SP_REGNUM), 4) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR 0x1fbf000 - -/* Address of end of stack space. */ - -/*#define STACK_END_ADDR (0xffffff)*/ -#define STACK_END_ADDR (0x1000000) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x4e, 0x4e} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. - On the Altos, the kernel resets the pc to the trap instr */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e75) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) (*((int *) (p)) == -1) /* Just a first guess; not checked */ - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#ifdef FLOATING_POINT -#define NUM_REGS 31 -#else -#define NUM_REGS 18 -#endif - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#ifdef FLOATING_POINT -#define REGISTER_NAMES \ - {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \ - "ps", "pc", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fpcontrol", "fpstatus", "fpiaddr", "fpcode", "fpflags" \ - } -#else -#define REGISTER_NAMES \ - {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \ - "ps", "pc", \ - } -#endif - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP_REGNUM 14 /* Contains address of executing stack frame */ -#define SP_REGNUM 15 /* Contains address of top of stack */ -#define PS_REGNUM 16 /* Contains processor status */ -#define PC_REGNUM 17 /* Contains program counter */ -#define FP0_REGNUM 18 /* Floating point register 0 */ -#define FPC_REGNUM 26 /* 68881 control register */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (16*4+8*12+8+20) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) \ - ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \ - : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \ - : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 12 bytes. */ -/* Note that the unsigned cast here forces the result of the - subtractiion to very high positive values if N < FP0_REGNUM */ - -#define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 8-byte doubles. */ - -#define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4) - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ if (regno <= SP_REGNUM) \ - addr = blockend + regno * 4; \ - else if (regno == PS_REGNUM) \ - addr = blockend + regno * 4 + 4; \ - else if (regno == PC_REGNUM) \ - addr = blockend + regno * 4 + 2; \ -} - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 12 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 8 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_from_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_to_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (9, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -#define REGISTER_ADDR(u_ar0, regno) \ - (((regno) < PS_REGNUM) \ - ? (&((struct exception_stack *) (u_ar0))->e_regs[(regno + R0)]) \ - : (((regno) == PS_REGNUM) \ - ? ((int *) (&((struct exception_stack *) (u_ar0))->e_PS)) \ - : (&((struct exception_stack *) (u_ar0))->e_PC))) - -#define FP_REGISTER_ADDR(u, regno) \ - (((char *) \ - (((regno) < FPC_REGNUM) \ - ? (&u.u_pcb.pcb_mc68881[FMC68881_R0 + (((regno) - FP0_REGNUM) * 3)]) \ - : (&u.u_pcb.pcb_mc68881[FMC68881_C + ((regno) - FPC_REGNUM)]))) \ - - ((char *) (& u))) - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the Altos, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -/* We can't tell how many args there are - now that the (gnu) C compiler delays popping them. - Perhaps we could tell if we use the Altos cc, but I'm not sure - COFF_FORMAT is the right conditional */ - -#ifdef COFF_FORMAT - -#define FRAME_NUM_ARGS(val, fi) (val = -1) -#if 0 -#define FRAME_NUM_ARGS(val, fi) \ -{ register CORE_ADDR pc = FRAME_SAVED_PC (fi.frame); \ - register int insn = 0177777 & read_memory_integer (pc, 2); \ - val = 0; \ - if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \ - val = read_memory_integer (pc + 2, 2); \ - else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \ - || (insn & 0170777) == 0050117) /* addqw */ \ - { val = (insn >> 9) & 7; if (val == 0) val = 8; } \ - else if (insn == 0157774) /* addal #WW, sp */ \ - val = read_memory_integer (pc + 2, 4); \ - val >>= 2; } -#endif - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - int nextinsn; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ - && (frame_info)->pc <= (frame_info)->frame) \ - { next_addr = (frame_info)->frame; \ - pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info)->pc); \ - /* Verify we have a link a6 instruction next; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ - if (044016 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ - else if (047126 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ - else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - regmask = read_memory_integer (pc + 2, 2); \ - /* But before that can come an fmovem. Check for it. */ \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf227 == nextinsn \ - && (regmask & 0xff00) == 0xe000) \ - { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 12); \ - regmask = read_memory_integer (pc + 2, 2); } \ - if (0044327 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ - else if (0044347 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - else if (0x2f00 == (0xfff0 & read_memory_integer (pc, 2))) \ - { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* fmovemx to index of sp may follow. */ \ - regmask = read_memory_integer (pc + 2, 2); \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf236 == nextinsn \ - && (regmask & 0xff00) == 0xf000) \ - { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \ - regmask = read_memory_integer (pc + 2, 2); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (0x426742e7 == read_memory_integer (pc, 4)) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ -} - -#if 0 -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - int nextinsn; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info).pc >= (frame_info).frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ - && (frame_info).pc <= (frame_info).frame) \ - { next_addr = (frame_info).frame; \ - pc = (frame_info).frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info).pc); \ - /* Verify we have a link a6 instruction next; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ - if (044016 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info).frame + read_memory_integer (pc += 2, 4), pc+=4; \ - else if (047126 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info).frame + read_memory_integer (pc += 2, 2), pc+=2; \ - else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - regmask = read_memory_integer (pc + 2, 2); \ - /* But before that can come an fmovem. Check for it. */ \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf227 == nextinsn \ - && (regmask & 0xff00) == 0xe000) \ - { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 12); \ - regmask = read_memory_integer (pc + 2, 2); } \ - if (0044327 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ - else if (0044347 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - else if (0x2f00 == 0xfff0 & read_memory_integer (pc, 2)) \ - { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* fmovemx to index of sp may follow. */ \ - regmask = read_memory_integer (pc + 2, 2); \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf236 == nextinsn \ - && (regmask & 0xff00) == 0xf000) \ - { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \ - regmask = read_memory_integer (pc + 2, 2); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (0x426742e7 == read_memory_integer (pc, 4)) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info).frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info).frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info).frame + 4; \ -} -#endif -#if 0 -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - register int insn; \ - register int offset; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info).pc >= (frame_info).frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ - && (frame_info).pc <= (frame_info).frame) \ - { next_addr = (frame_info).frame; \ - pc = (frame_info).frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info).pc); \ - /* Verify we have a link a6 instruction next, \ - or a branch followed by a link a6 instruction; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ -retry: \ - insn = read_memory_integer (pc, 2); \ - if (insn == 044016) \ - next_addr = (frame_info).frame - read_memory_integer (pc += 2, 4), pc+=4; \ - else if (insn == 047126) \ - next_addr = (frame_info).frame - read_memory_integer (pc += 2, 2), pc+=2; \ - else if ((insn & 0177400) == 060000) /* bra insn */ \ - { offset = insn & 0377; \ - pc += 2; /* advance past bra */ \ - if (offset == 0) /* bra #word */ \ - offset = read_memory_integer (pc, 2), pc += 2; \ - else if (offset == 0377) /* bra #long */ \ - offset = read_memory_integer (pc, 4), pc += 4; \ - pc += offset; \ - goto retry; \ - } else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - insn = read_memory_integer (pc, 2), pc += 2; \ - regmask = read_memory_integer (pc, 2); \ - if ((insn & 0177760) == 022700) /* movl rn, (sp) */ \ - (frame_saved_regs).regs[(insn&7) + ((insn&010)?8:0)] = next_addr; \ - else if ((insn & 0177760) == 024700) /* movl rn, -(sp) */ \ - (frame_saved_regs).regs[(insn&7) + ((insn&010)?8:0)] = next_addr-=4; \ - else if (insn == 0044327) /* moveml mask, (sp) */ \ - { pc += 2; \ - /* Regmask's low bit is for register 0, the first written */ \ - next_addr -= 4; \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4); \ - } else if (insn == 0044347) /* moveml mask, -(sp) */ \ - { pc += 2; \ - /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (read_memory_integer (pc, 2) == 041147 \ - && read_memory_integer (pc+2, 2) == 042347) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info).frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info).frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info).frame + 4; \ -} -#endif -#else -#define FRAME_NUM_ARGS(val, fi) (val = -1) -#endif - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ - char raw_buffer[12]; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - { read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); \ - sp = push_bytes (sp, raw_buffer, 12); } \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - char raw_buffer[12]; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - if (fsr.regs[regnum]) \ - { read_memory (fsr.regs[regnum], raw_buffer, 12); \ - write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); }\ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); } - -/* This sequence of words is the instructions - fmovem 0xff,-(sp) - moveml 0xfffc,-(sp) - clrw -(sp) - movew ccr,-(sp) - /..* The arguments are pushed at this point by GDB; - no code is needed in the dummy for this. - The CALL_DUMMY_START_OFFSET gives the position of - the following jsr instruction. *../ - jsr @#32323232 - addl #69696969,sp - bpt - nop -Note this is 28 bytes. -We actually start executing at the jsr, since the pushing of the -registers is done by PUSH_DUMMY_FRAME. If this were real code, -the arguments for the function called by the jsr would be pushed -between the moveml and the jsr, and we could allow it to execute through. -But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done, -and we cannot allow the moveml to push the registers again lest they be -taken for the arguments. */ - -#define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4e4e71} - -#define CALL_DUMMY_LENGTH 28 - -#define CALL_DUMMY_START_OFFSET 12 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *(int *)((char *) dummyname + 20) = nargs * 4; \ - *(int *)((char *) dummyname + 14) = fun; } - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#ifdef MOTOROLA -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("move.l $ end, sp"); \ - asm ("clr.l fp"); } -#else -#ifdef ALTOS_AS -#define INIT_STACK(beg, end) \ -{ asm ("global end"); \ - asm ("mov.l &end,%sp"); \ - asm ("clr.l %fp"); } -#else -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } -#endif -#endif - -/* Push the frame pointer register on the stack. */ -#ifdef MOTOROLA -#define PUSH_FRAME_PTR \ - asm ("move.l fp, -(sp)"); -#else -#ifdef ALTOS_AS -#define PUSH_FRAME_PTR \ - asm ("mov.l %fp, -(%sp)"); -#else -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); -#endif -#endif - -/* Copy the top-of-stack to the frame pointer register. */ -#ifdef MOTOROLA -#define POP_FRAME_PTR \ - asm ("move.l (sp), fp"); -#else -#ifdef ALTOS_AS -#define POP_FRAME_PTR \ - asm ("mov.l (%sp), %fp"); -#else -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); -#endif -#endif - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#ifdef MOTOROLA -#define PUSH_REGISTERS \ -{ asm ("clr.w -(sp)"); \ - asm ("pea (10,sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } -#else -#ifdef ALTOS_AS -#define PUSH_REGISTERS \ -{ asm ("clr.w -(%sp)"); \ - asm ("pea (10,%sp)"); \ - asm ("movm.l &0xfffe,-(%sp)"); } -#else -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } -#endif -#endif - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#ifdef MOTOROLA -#define POP_REGISTERS \ -{ asm ("subi.l $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } -#else -#ifdef ALTOS_AS -#define POP_REGISTERS \ -{ asm ("sub.l &8,28(%sp)"); \ - asm ("movem (%sp),&0xffff"); \ - asm ("rte"); } -#else -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } -#endif -#endif - diff --git a/gnu/usr.bin/gdb/config/m-convex.h b/gnu/usr.bin/gdb/config/m-convex.h deleted file mode 100644 index 58b27b788afd..000000000000 --- a/gnu/usr.bin/gdb/config/m-convex.h +++ /dev/null @@ -1,612 +0,0 @@ -/* Definitions to make GDB run on Convex Unix (4bsd) - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-convex.h,v 1.2 1993/08/02 17:39:52 mycroft Exp $ -*/ - -/* Describe the endian nature of this machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* Include certain files for dbxread.c */ -#include -#include -#include -#include - -#define LONG_LONG -#define ATTACH_DETACH -#define HAVE_WAIT_STRUCT -#define NO_SIGINTERRUPT - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* There is come problem with the debugging symbols generated by the - compiler such that the debugging symbol for the first line of a - function overlap with the function prologue. */ -#define PROLOGUE_FIRSTLINE_OVERLAP - -/* When convex pcc says CHAR or SHORT, it provides the correct address. */ - -#define BELIEVE_PCC_PROMOTION 1 - -/* Symbol types to ignore. */ -/* 0xc4 is N_MONPT. Use the numeric value for the benefit of people - with (rather) old OS's. */ -#define IGNORE_SYMBOL(TYPE) \ - (((TYPE) & ~N_EXT) == N_TBSS \ - || ((TYPE) & ~N_EXT) == N_TDATA \ - || ((TYPE) & ~N_EXT) == 0xc4) - -/* Use SIGCONT rather than SIGTSTP because convex Unix occasionally - turkeys SIGTSTP. I think. */ - -#define STOP_SIGNAL SIGCONT - -/* Convex ld sometimes omits _etext. - Get text segment end from a.out header in this case. */ - -extern unsigned text_end; -#define END_OF_TEXT_DEFAULT text_end - -/* Use csh to do argument expansion so we get ~ and such. */ - -/* Doesn't work. */ -/* #define SHELL_FILE "/bin/csh" */ - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. - Convex prolog is: - [sub.w #-,sp] in one of 3 possible sizes - [mov psw,- fc/vc main program prolog - and #-,- (skip it because the "mov psw" saves the - mov -,psw] T bit, so continue gets a surprise trap) - [and #-,sp] fc/vc O2 main program prolog - [ld.- -(ap),-] pcc/gcc register arg loads -*/ - -#define SKIP_PROLOGUE(pc) \ -{ int op, ix; \ - op = read_memory_integer (pc, 2); \ - if ((op & 0xffc7) == 0x5ac0) pc += 2; \ - else if (op == 0x1580) pc += 4; \ - else if (op == 0x15c0) pc += 6; \ - if ((read_memory_integer (pc, 2) & 0xfff8) == 0x7c40 \ - && (read_memory_integer (pc + 2, 2) & 0xfff8) == 0x1240 \ - && (read_memory_integer (pc + 8, 2) & 0xfff8) == 0x7c48) \ - pc += 10; \ - if (read_memory_integer (pc, 2) == 0x1240) pc += 6; \ - for (;;) { \ - op = read_memory_integer (pc, 2); \ - ix = (op >> 3) & 7; \ - if (ix != 6) break; \ - if ((op & 0xfcc0) == 0x3000) pc += 4; \ - else if ((op & 0xfcc0) == 0x3040) pc += 6; \ - else if ((op & 0xfcc0) == 0x2800) pc += 4; \ - else if ((op & 0xfcc0) == 0x2840) pc += 6; \ - else break;}} - -/* Immediately after a function call, return the saved pc. - (ignore frame and return *$sp so we can handle both calls and callq) */ - -#define SAVED_PC_AFTER_CALL(frame) \ - read_memory_integer (read_register (SP_REGNUM), 4) - -/* Address of end of stack space. - This is ((USRSTACK + 0xfff) & -0x1000)) from but - that expression depends on the kernel version; instead, fetch a - page-zero pointer and get it from that. This will be invalid if - they ever change the way bkpt signals are delivered. */ - -#define STACK_END_ADDR (0xfffff000 & *(unsigned *) 0x80000050) - -/* User-mode traps push an extended rtn block, - then fault with one of the following PCs */ - -#define is_trace_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000040)) <= 4) -#define is_arith_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000044)) <= 4) -#define is_break_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000050)) <= 4) - -/* We need to manipulate trap bits in the psw */ - -#define PSW_TRAP_FLAGS 0x69670000 -#define PSW_T_BIT 0x08000000 -#define PSW_S_BIT 0x01000000 - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. (bkpt) */ - -#define BREAKPOINT {0x7d,0x50} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT but not always. - (The break PC needs to be decremented by 2, but we do it when the - break frame is recognized and popped. That way gdb can tell breaks - from trace traps with certainty.) */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. (rtn or rtnq) */ - -#define ABOUT_TO_RETURN(pc) \ - ((read_memory_integer (pc, 2) & 0xffe0) == 0x7c80) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p,len) 0 - -/* Largest integer type */ - -#define LONGEST long long - -/* Name of the builtin type for the LONGEST type above. */ - -#undef BUILTIN_TYPE_LONGEST -#define BUILTIN_TYPE_LONGEST builtin_type_long_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long long - -/* Number of machine registers */ - -#define NUM_REGS 26 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES {"pc","psw","fp","ap","a5","a4","a3","a2","a1","sp",\ - "s7","s6","s5","s4","s3","s2","s1","s0",\ - "S7","S6","S5","S4","S3","S2","S1","S0"} - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define S0_REGNUM 25 /* the real S regs */ -#define S7_REGNUM 18 -#define s0_REGNUM 17 /* low-order halves of S regs */ -#define s7_REGNUM 10 -#define SP_REGNUM 9 /* A regs */ -#define A1_REGNUM 8 -#define A5_REGNUM 4 -#define AP_REGNUM 3 -#define FP_REGNUM 2 /* Contains address of executing stack frame */ -#define PS_REGNUM 1 /* Contains processor status */ -#define PC_REGNUM 0 /* Contains program counter */ - -/* convert dbx stab register number (from `r' declaration) to a gdb REGNUM */ - -#define STAB_REG_TO_REGNUM(value) \ - ((value) < 8 ? S0_REGNUM - (value) : SP_REGNUM - ((value) - 8)) - -/* Vector register numbers, not handled as ordinary regs. - They are treated as convenience variables whose values are read - from the inferior when needed. */ - -#define V0_REGNUM 0 -#define V7_REGNUM 7 -#define VM_REGNUM 8 -#define VS_REGNUM 9 -#define VL_REGNUM 10 - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (4*10 + 8*8) - -/* Index within `registers' of the first byte of the space for - register N. - NB: must match structure of struct syscall_context for correct operation */ - -#define REGISTER_BYTE(N) ((N) < s7_REGNUM ? 4*(N) : \ - (N) < S7_REGNUM ? 44 + 8 * ((N)-s7_REGNUM) : \ - 40 + 8 * ((N)-S7_REGNUM)) - -/* Number of bytes of storage in the actual machine representation - for register N. */ - -#define REGISTER_RAW_SIZE(N) ((N) < S7_REGNUM ? 4 : 8) - -/* Number of bytes of storage in the program's representation - for register N. */ - -#define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 8 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 8 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM)); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - ((N) < S7_REGNUM ? builtin_type_int : builtin_type_long_long) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (A1_REGNUM, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (&((char *) REGBUF) [REGISTER_BYTE (S0_REGNUM) + \ - 8 - TYPE_LENGTH (TYPE)],\ - VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (REGISTER_BYTE (S0_REGNUM), VALBUF, 8) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \ - (*(int *) & ((char *) REGBUF) [REGISTER_BYTE (s0_REGNUM)]) - -/* Compensate for lack of `vprintf' function. */ -#ifndef HAVE_VPRINTF -#define vprintf(format, ap) _doprnt (format, ap, stdout) -#endif /* not HAVE_VPRINTF */ - -/* Define trapped internal variable hooks to read and write - vector and communication registers. */ - -#define IS_TRAPPED_INTERNALVAR is_trapped_internalvar -#define VALUE_OF_TRAPPED_INTERNALVAR value_of_trapped_internalvar -#define SET_TRAPPED_INTERNALVAR set_trapped_internalvar - -extern struct value *value_of_trapped_internalvar (); - -/* Hooks to read data from soff exec and core files, - and to describe the files. */ - -#define XFER_CORE_FILE -#define FILES_INFO_HOOK print_maps - -/* Hook to call after creating inferior process. */ - -#define CREATE_INFERIOR_HOOK create_inferior_hook - -/* Hook to call to print a typeless integer value, normally printed in decimal. - For convex, use hex instead if the number looks like an address. */ - -#define PRINT_TYPELESS_INTEGER decout - -/* For the native compiler, variables for a particular lexical context - are listed after the beginning LBRAC instead of before in the - executables list of symbols. Using "gcc_compiled." to distinguish - between GCC and native compiler doesn't work on Convex because the - linker sorts the symbols to put "gcc_compiled." in the wrong place. - desc is nonzero for native, zero for gcc. */ -#define VARIABLES_INSIDE_BLOCK(desc) (desc != 0) - -/* Pcc occaisionally puts an SO where there should be an SOL. */ -#define PCC_SOL_BROKEN - -/* Cannot execute with pc on the stack. */ -#define CANNOT_EXECUTE_STACK - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame_info with a frame's nominal address in fi->frame, - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* (caller fp is saved at 8(fp)) */ - -#define FRAME_CHAIN(fi) (read_memory_integer ((fi)->frame + 8, 4)) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. - On convex, check at the return address for `callq' -- if so, frameless, - otherwise, not. */ - -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ -{ \ - extern CORE_ADDR text_start, text_end; \ - CORE_ADDR call_addr = SAVED_PC_AFTER_CALL (FI); \ - (FRAMELESS) = (call_addr >= text_start && call_addr < text_end \ - && read_memory_integer (call_addr - 6, 1) == 0x22); \ -} - -#define FRAME_SAVED_PC(fi) (read_memory_integer ((fi)->frame, 4)) - -#define FRAME_ARGS_ADDRESS(fi) (read_memory_integer ((fi)->frame + 12, 4)) - -#define FRAME_LOCALS_ADDRESS(fi) (fi)->frame - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ numargs = read_memory_integer (FRAME_ARGS_ADDRESS (fi) - 4, 4); \ - if (numargs < 0 || numargs >= 256) numargs = -1;} - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 0 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -/* Normal (short) frames save only PC, FP, (callee's) AP. To reasonably - handle gcc and pcc register variables, scan the code following the - call for the instructions the compiler inserts to reload register - variables from stack slots and record the stack slots as the saved - locations of those registers. This will occasionally identify some - random load as a saved register; this is harmless. vc does not - declare its register allocation actions in the stabs. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int frame_length = /* 3 short, 2 long, 1 extended, 0 context */\ - (read_memory_integer ((frame_info)->frame + 4, 4) >> 25) & 3; \ - register CORE_ADDR frame_fp = \ - read_memory_integer ((frame_info)->frame + 8, 4); \ - register CORE_ADDR next_addr; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 0; \ - (frame_saved_regs).regs[PS_REGNUM] = (frame_info)->frame + 4; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[AP_REGNUM] = frame_fp + 12; \ - next_addr = (frame_info)->frame + 12; \ - if (frame_length < 3) \ - for (regnum = A5_REGNUM; regnum < SP_REGNUM; ++regnum) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4); \ - if (frame_length < 2) \ - (frame_saved_regs).regs[SP_REGNUM] = (next_addr += 4); \ - next_addr -= 4; \ - if (frame_length < 3) \ - for (regnum = S7_REGNUM; regnum < S0_REGNUM; ++regnum) \ - (frame_saved_regs).regs[regnum] = (next_addr += 8); \ - if (frame_length < 2) \ - (frame_saved_regs).regs[S0_REGNUM] = (next_addr += 8); \ - else \ - (frame_saved_regs).regs[SP_REGNUM] = next_addr + 8; \ - if (frame_length == 3) { \ - CORE_ADDR pc = read_memory_integer ((frame_info)->frame, 4); \ - int op, ix, disp; \ - op = read_memory_integer (pc, 2); \ - if ((op & 0xffc7) == 0x1480) pc += 4; /* add.w #-,sp */ \ - else if ((op & 0xffc7) == 0x58c0) pc += 2; /* add.w #-,sp */ \ - op = read_memory_integer (pc, 2); \ - if ((op & 0xffc7) == 0x2a06) pc += 4; /* ld.w -,ap */ \ - for (;;) { \ - op = read_memory_integer (pc, 2); \ - ix = (op >> 3) & 7; \ - if ((op & 0xfcc0) == 0x2800) { /* ld.- -,ak */ \ - regnum = SP_REGNUM - (op & 7); \ - disp = read_memory_integer (pc + 2, 2); \ - pc += 4;} \ - else if ((op & 0xfcc0) == 0x2840) { /* ld.- -,ak */ \ - regnum = SP_REGNUM - (op & 7); \ - disp = read_memory_integer (pc + 2, 4); \ - pc += 6;} \ - if ((op & 0xfcc0) == 0x3000) { /* ld.- -,sk */ \ - regnum = S0_REGNUM - (op & 7); \ - disp = read_memory_integer (pc + 2, 2); \ - pc += 4;} \ - else if ((op & 0xfcc0) == 0x3040) { /* ld.- -,sk */ \ - regnum = S0_REGNUM - (op & 7); \ - disp = read_memory_integer (pc + 2, 4); \ - pc += 6;} \ - else if ((op & 0xff00) == 0x7100) { /* br crossjump */ \ - pc += 2 * (char) op; \ - continue;} \ - else if (op == 0x0140) { /* jmp crossjump */ \ - pc = read_memory_integer (pc + 2, 4); \ - continue;} \ - else break; \ - if ((frame_saved_regs).regs[regnum]) \ - break; \ - if (ix == 7) disp += frame_fp; \ - else if (ix == 6) disp += read_memory_integer (frame_fp + 12, 4); \ - else if (ix != 0) break; \ - (frame_saved_regs).regs[regnum] = \ - disp - 8 + (1 << ((op >> 8) & 3)); \ - if (regnum >= S7_REGNUM) \ - (frame_saved_regs).regs[regnum - S0_REGNUM + s0_REGNUM] = \ - disp - 4 + (1 << ((op >> 8) & 3)); \ - } \ - } \ -} - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ - char buf[8]; \ - long word; \ - for (regnum = S0_REGNUM; regnum >= S7_REGNUM; --regnum) { \ - read_register_bytes (REGISTER_BYTE (regnum), buf, 8); \ - sp = push_bytes (sp, buf, 8);} \ - for (regnum = SP_REGNUM; regnum >= FP_REGNUM; --regnum) { \ - word = read_register (regnum); \ - sp = push_bytes (sp, &word, 4);} \ - word = (read_register (PS_REGNUM) &~ (3<<25)) | (1<<25); \ - sp = push_bytes (sp, &word, 4); \ - word = read_register (PC_REGNUM); \ - sp = push_bytes (sp, &word, 4); \ - write_register (SP_REGNUM, sp); \ - write_register (FP_REGNUM, sp); \ - write_register (AP_REGNUM, sp);} - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME do {\ - register CORE_ADDR fp = read_register (FP_REGNUM); \ - register int regnum; \ - register int frame_length = /* 3 short, 2 long, 1 extended, 0 context */ \ - (read_memory_integer (fp + 4, 4) >> 25) & 3; \ - char buf[8]; \ - write_register (PC_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PS_REGNUM, read_memory_integer (fp += 4, 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp += 4, 4)); \ - write_register (AP_REGNUM, read_memory_integer (fp += 4, 4)); \ - if (frame_length < 3) \ - for (regnum = A5_REGNUM; regnum < SP_REGNUM; ++regnum) \ - write_register (regnum, read_memory_integer (fp += 4, 4)); \ - if (frame_length < 2) \ - write_register (SP_REGNUM, read_memory_integer (fp += 4, 4)); \ - fp -= 4; \ - if (frame_length < 3) \ - for (regnum = S7_REGNUM; regnum < S0_REGNUM; ++regnum) { \ - read_memory (fp += 8, buf, 8); \ - write_register_bytes (REGISTER_BYTE (regnum), buf, 8);} \ - if (frame_length < 2) { \ - read_memory (fp += 8, buf, 8); \ - write_register_bytes (REGISTER_BYTE (regnum), buf, 8);} \ - else write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); \ -} while (0) - -/* This sequence of words is the instructions - mov sp,ap - pshea 69696969 - calls 32323232 - bkpt - Note this is 16 bytes. */ - -#define CALL_DUMMY {0x50860d4069696969LL,0x2140323232327d50LL} - -#define CALL_DUMMY_START_OFFSET 0 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *(int *)((char *) dummyname + 4) = nargs; \ - *(int *)((char *) dummyname + 10) = fun; } - -/* Defs to read soff symbol tables, see dbxread.c */ - -#define NUMBER_OF_SYMBOLS ((long) opthdr.o_nsyms) -#define STRING_TABLE_OFFSET ((long) filehdr.h_strptr) -#define SYMBOL_TABLE_OFFSET ((long) opthdr.o_symptr) -#define STRING_TABLE_SIZE ((long) filehdr.h_strsiz) -#define SIZE_OF_TEXT_SEGMENT ((long) txthdr.s_size) -#define ENTRY_POINT ((long) opthdr.o_entry) - -#define READ_STRING_TABLE_SIZE(BUFFER) \ - (BUFFER = STRING_TABLE_SIZE) - -#define DECLARE_FILE_HEADERS \ - FILEHDR filehdr; \ - OPTHDR opthdr; \ - SCNHDR txthdr - -#define READ_FILE_HEADERS(DESC,NAME) \ -{ \ - int n; \ - val = myread (DESC, &filehdr, sizeof filehdr); \ - if (val < 0) \ - perror_with_name (NAME); \ - if (! IS_SOFF_MAGIC (filehdr.h_magic)) \ - error ("%s: not an executable file.", NAME); \ - lseek (DESC, 0L, 0); \ - if (myread (DESC, &filehdr, sizeof filehdr) < 0) \ - perror_with_name (NAME); \ - if (myread (DESC, &opthdr, filehdr.h_opthdr) <= 0) \ - perror_with_name (NAME); \ - for (n = 0; n < filehdr.h_nscns; n++) \ - { \ - if (myread (DESC, &txthdr, sizeof txthdr) < 0) \ - perror_with_name (NAME); \ - if ((txthdr.s_flags & S_TYPMASK) == S_TEXT) \ - break; \ - } \ -} - -/* Interface definitions for kernel debugger KDB. */ - -/* (no kdb) */ diff --git a/gnu/usr.bin/gdb/config/m-hp9k320.h b/gnu/usr.bin/gdb/config/m-hp9k320.h deleted file mode 100644 index 152978797794..000000000000 --- a/gnu/usr.bin/gdb/config/m-hp9k320.h +++ /dev/null @@ -1,583 +0,0 @@ -/* Parameters for execution on an HP 9000 model 320, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-hp9k320.h,v 1.2 1993/08/02 17:39:53 mycroft Exp $ -*/ - -/* Define the bit, byte, and word ordering of the machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -#ifndef HP9K320 -#define HP9K320 -#endif - -/* Define this to indicate problems with traps after continuing. */ -#define HP_OS_BUG - -/* Set flag to indicate whether HP's assembler is in use. */ -#ifdef __GNUC__ -#ifdef __HPUX_ASM__ -#define HPUX_ASM -#endif -#else -#define HPUX_ASM -#endif - -/* Define this for versions of hp-ux older than 6.0 */ -/* #define HPUX_VERSION_5 */ - -/* define USG if you are using sys5 /usr/include's */ -#define USG - -#define HAVE_TERMIO - -/* Get rid of any system-imposed stack limit if possible. */ -/* The hp9k320.h doesn't seem to have this feature. */ -/* #define SET_STACK_LIMIT_HUGE */ -/* So we'll just have to avoid big alloca's. */ -#define BROKEN_LARGE_ALLOCA - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = read_memory_integer (pc, 2); \ - if (op == 0047126) \ - pc += 4; /* Skip link #word */ \ - else if (op == 0044016) \ - pc += 6; /* Skip link #long */ \ -} - -/* Immediately after a function call, return the saved pc. - Can't go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ -read_memory_integer (read_register (SP_REGNUM), 4) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#ifdef HPUX_VERSION_5 -#define KERNEL_U_ADDR 0x00979000 -#else -#define KERNEL_U_ADDR 0x00C01000 -#endif - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0xFFF00000 - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x4e, 0x41} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 2 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e75) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 29 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ - {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \ - "ps", "pc", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fpcontrol", "fpstatus", "fpiaddr" } - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP_REGNUM 14 /* Contains address of executing stack frame */ -#define SP_REGNUM 15 /* Contains address of top of stack */ -#define PS_REGNUM 16 /* Contains processor status */ -#define PC_REGNUM 17 /* Contains program counter */ -#define FP0_REGNUM 18 /* Floating point register 0 */ -#define FPC_REGNUM 26 /* 68881 control register */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (16*4+8*12+8+12) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) \ - ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \ - : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \ - : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 12 bytes. */ - -#define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 8-byte doubles. */ - -#define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 12 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 8 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_from_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_to_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (9, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -#define REGISTER_ADDR(u_ar0, regno) \ - (((regno) < PS_REGNUM) \ - ? (&((struct exception_stack *) (u_ar0))->e_regs[(regno + R0)]) \ - : (((regno) == PS_REGNUM) \ - ? ((int *) (&((struct exception_stack *) (u_ar0))->e_PS)) \ - : (&((struct exception_stack *) (u_ar0))->e_PC))) - -#define FP_REGISTER_ADDR(u, regno) \ - (((char *) \ - (((regno) < FPC_REGNUM) \ - ? (&u.u_pcb.pcb_mc68881[FMC68881_R0 + (((regno) - FP0_REGNUM) * 3)]) \ - : (&u.u_pcb.pcb_mc68881[FMC68881_C + ((regno) - FPC_REGNUM)]))) \ - - ((char *) (& u))) - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the Sun, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) : \ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can't tell how many args there are - now that the C compiler delays popping them. */ -#define FRAME_NUM_ARGS(val,fi) (val = -1) - -#if 0 -#define FRAME_NUM_ARGS(val, fi) \ -{ register CORE_ADDR pc = FRAME_SAVED_PC (fi); \ - register int insn = 0177777 & read_memory_integer (pc, 2); \ - val = 0; \ - if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \ - val = read_memory_integer (pc + 2, 2); \ - else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \ - || (insn & 0170777) == 0050117) /* addqw */ \ - { val = (insn >> 9) & 7; if (val == 0) val = 8; } \ - else if (insn == 0157774) /* addal #WW, sp */ \ - val = read_memory_integer (pc + 2, 4); \ - val >>= 2; } -#endif - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - int nextinsn; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ - && (frame_info)->pc <= (frame_info)->frame) \ - { next_addr = (frame_info)->frame; \ - pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info)->pc); \ - /* Verify we have a link a6 instruction next; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ - if (044016 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ - else if (047126 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ - else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - regmask = read_memory_integer (pc + 2, 2); \ - /* But before that can come an fmovem. Check for it. */ \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf227 == nextinsn \ - && (regmask & 0xff00) == 0xe000) \ - { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 12); \ - regmask = read_memory_integer (pc + 2, 2); } \ - if (0044327 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ - else if (0044347 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - else if (0x2f00 == 0xfff0 & read_memory_integer (pc, 2)) \ - { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* fmovemx to index of sp may follow. */ \ - regmask = read_memory_integer (pc + 2, 2); \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf236 == nextinsn \ - && (regmask & 0xff00) == 0xf000) \ - { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \ - regmask = read_memory_integer (pc + 2, 2); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (0x426742e7 == read_memory_integer (pc, 4)) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ -} - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ - char raw_buffer[12]; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - { read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); \ - sp = push_bytes (sp, raw_buffer, 12); } \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - char raw_buffer[12]; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - if (fsr.regs[regnum]) \ - { read_memory (fsr.regs[regnum], raw_buffer, 12); \ - write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); }\ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM),\ - read_pc ()));} - -/* This sequence of words is the instructions - fmovem 0xff,-(sp) - moveml 0xfffc,-(sp) - clrw -(sp) - movew ccr,-(sp) - /..* The arguments are pushed at this point by GDB; - no code is needed in the dummy for this. - The CALL_DUMMY_START_OFFSET gives the position of - the following jsr instruction. *../ - jsr @#32323232 - addl #69696969,sp - bpt - nop -Note this is 28 bytes. -We actually start executing at the jsr, since the pushing of the -registers is done by PUSH_DUMMY_FRAME. If this were real code, -the arguments for the function called by the jsr would be pushed -between the moveml and the jsr, and we could allow it to execute through. -But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done, -and we cannot allow the moveml to push the registers again lest they be -taken for the arguments. */ - -#define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e414e71} - -#define CALL_DUMMY_LENGTH 28 - -#define CALL_DUMMY_START_OFFSET 12 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *(int *)((char *) dummyname + 20) = nargs * 4; \ - *(int *)((char *) dummyname + 14) = fun; } - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -#ifndef HPUX_ASM - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } - -#else /* HPUX_ASM */ - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm ("global end"); \ - asm ("mov.l &end,%sp"); \ - asm ("clr.l %a6"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("mov.l %fp,-(%sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("mov.l (%sp),%fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clr.w -(%sp)"); \ - asm ("pea 10(%sp)"); \ - asm ("movm.l &0xfffe,-(%sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subi.l &8,28(%sp)"); \ - asm ("mov.m (%sp),&0xffff"); \ - asm ("rte"); } - -#endif /* HPUX_ASM */ diff --git a/gnu/usr.bin/gdb/config/m-i386-sv32.h b/gnu/usr.bin/gdb/config/m-i386-sv32.h deleted file mode 100644 index c89e85fc7825..000000000000 --- a/gnu/usr.bin/gdb/config/m-i386-sv32.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Macro defintions for i386, running System V 3.2. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-i386-sv32.h,v 1.2 1993/08/02 17:39:55 mycroft Exp $ -*/ - -#include "m-i386.h" - -/* Apparently there is inconsistency among various System V's about what - the name of this field is. */ -#define U_FPSTATE(u) u.u_fps.u_fpstate - -/* TIOCGETC is defined in System V 3.2 termio.h, but struct tchars - is not. This makes problems for inflow.c. */ -#define TIOCGETC_BROKEN diff --git a/gnu/usr.bin/gdb/config/m-i386.h b/gnu/usr.bin/gdb/config/m-i386.h deleted file mode 100644 index 1d4aac166bf1..000000000000 --- a/gnu/usr.bin/gdb/config/m-i386.h +++ /dev/null @@ -1,397 +0,0 @@ -/* Macro defintions for i386. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-i386.h,v 1.2 1993/08/02 17:39:56 mycroft Exp $ -*/ - -/* Define the bit, byte, and word ordering of the machine. */ -/* #define BITS_BIG_ENDIAN */ -/* #define BYTES_BIG_ENDIAN */ -/* #define WORDS_BIG_ENDIAN */ - -/* - * Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu) - * July 1988 - */ - - -#ifndef i386 -#define i386 -#endif - -/* I'm running gdb 3.4 under 386/ix 2.0.2, which is a derivative of AT&T's -Sys V/386 3.2. - -On some machines, gdb crashes when it's starting up while calling the -vendor's termio tgetent() routine. It always works when run under -itself (actually, under 3.2, it's not an infinitely recursive bug.) -After some poking around, it appears that depending on the environment -size, or whether you're running YP, or the phase of the moon or something, -the stack is not always long-aligned when main() is called, and tgetent() -takes strong offense at that. On some machines this bug never appears, but -on those where it does, it occurs quite reliably. */ -#define ALIGN_STACK_ON_STARTUP - -/* define USG if you are using sys5 /usr/include's */ -#define USG - -/* USG systems need these */ -#define vfork() fork() -#define MAXPATHLEN 500 - -/* define this if you don't have the extension to coff that allows - * file names to appear in the string table - * (aux.x_file.x_foff) - */ -#define COFF_NO_LONG_FILE_NAMES - -/* turn this on when rest of gdb is ready */ -/* #define IEEE_FLOAT */ - -#define NBPG NBPC -#define UPAGES USIZE - -#define HAVE_TERMIO - -/* Get rid of any system-imposed stack limit if possible. */ - -/* #define SET_STACK_LIMIT_HUGE not in sys5 */ - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -/* #define NAMES_HAVE_UNDERSCORE */ - -/* Specify debugger information format. */ - -/* #define READ_DBX_FORMAT */ -#define COFF_FORMAT - -/* number of traps that happen between exec'ing the shell - * to run an inferior, and when we finally get to - * the inferior code. This is 2 on most implementations. - */ -#define START_INFERIOR_TRAPS_EXPECTED 4 - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));} - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ - (read_memory_integer (read_register (SP_REGNUM), 4)) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR 0xe0000000 - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0x80000000 - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xcc} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 1 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc3) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes -- not relevant on the 386. */ - -#define INVALID_FLOAT(p, len) (0) - -/* code to execute to print interesting information about the - * floating point processor (if any) - * No need to define if there is nothing to do. - */ -#define FLOAT_INFO { i386_float_info (); } - - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 16 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -/* the order of the first 8 registers must match the compiler's - * numbering scheme (which is the same as the 386 scheme) - * also, this table must match regmap in i386-pinsn.c. - */ -#define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \ - "esp", "ebp", "esi", "edi", \ - "eip", "ps", "cs", "ss", \ - "ds", "es", "fs", "gs", \ - } - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP_REGNUM 5 /* Contains address of executing stack frame */ -#define SP_REGNUM 4 /* Contains address of top of stack */ - -#define PC_REGNUM 8 -#define PS_REGNUM 9 - -#define REGISTER_U_ADDR(addr, blockend, regno) \ - (addr) = i386_register_u_addr ((blockend),(regno)); - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (NUM_REGS * 4) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N)*4) - -/* Number of bytes of storage in the actual machine representation - for register N. */ - -#define REGISTER_RAW_SIZE(N) (4) - -/* Number of bytes of storage in the program's representation - for register N. */ - -#define REGISTER_VIRTUAL_SIZE(N) (4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 4 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 4 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);} - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);} - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { (SP) -= sizeof (ADDR); \ - write_memory ((SP), &(ADDR), sizeof (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) (numargs) = i386_frame_num_args(fi) - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); } - - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME { i386_push_dummy_frame (); } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME { i386_pop_frame (); } - -/* this is - * call 11223344 (32 bit relative) - * int3 - */ - -#define CALL_DUMMY { 0x223344e8, 0xcc11 } - -#define CALL_DUMMY_LENGTH 8 - -#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ \ - int from, to, delta, loc; \ - loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \ - from = loc + 5; \ - to = (int)(fun); \ - delta = to - from; \ - *(int *)((char *)(dummyname) + 1) = delta; \ -} - - -#if 0 -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) {} - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR {} - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR {} - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS {} - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS {} -#endif diff --git a/gnu/usr.bin/gdb/config/m-i386bsd.h b/gnu/usr.bin/gdb/config/m-i386bsd.h deleted file mode 100644 index e29abd4efc3f..000000000000 --- a/gnu/usr.bin/gdb/config/m-i386bsd.h +++ /dev/null @@ -1,374 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1991 by William Jolitz at UUNET Technologies, Inc. - * - * from: @(#)m-i386bsd.h 6.7 (Berkeley) 5/8/91 - * $Id: m-i386bsd.h,v 1.4 1994/01/09 23:45:26 cgd Exp $ - */ - -/* Macro definitions for i386. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Define the bit, byte, and word ordering of the machine. */ -/* #define BITS_BIG_ENDIAN */ -/* #define BYTES_BIG_ENDIAN */ -/* #define WORDS_BIG_ENDIAN */ - -/* - * Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu) - * July 1988 - * [ MODIFIED FOR 386BSD W. Jolitz ] - */ - -#ifndef i386 -#define i386 1 -#define i386b 1 -#endif - -#define IEEE_FLOAT -#define LONG_LONG - -/* Library stuff: POSIX tty (not supported yet), V7 tty (sigh), vprintf. */ - -#define HAVE_TERMIOS 1 -#define USE_OLD_TTY 1 -#define HAVE_VPRINTF 1 - -/* We support local and remote kernel debugging. */ - -#define KERNELDEBUG 1 - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Specify debugger information format. */ - -#define READ_DBX_FORMAT - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));} - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ - (read_memory_integer (read_register (SP_REGNUM), 4)) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#ifdef NEWVM -#include -#define KERNEL_U_ADDR USRSTACK -#else -#define KERNEL_U_ADDR 0xfdffd000 -#endif - -/* Address of end of stack space. */ - -#define STACK_END_ADDR KERNEL_U_ADDR - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xcc} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 1 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) \ - strchr("\302\303\312\313\317", read_memory_integer(pc, 1)) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes -- not relevant on the 386. */ - -#define INVALID_FLOAT(p, len) (0) - -/* code to execute to print interesting information about the - * floating point processor (if any) - * No need to define if there is nothing to do. - */ -#define FLOAT_INFO { i386_float_info (); } - - -/* Largest integer type */ -#define LONGEST long long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 16 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -/* the order of the first 8 registers must match the compiler's - * numbering scheme (which is the same as the 386 scheme) - * also, this table must match regmap in i386-pinsn.c. - */ -#define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \ - "esp", "ebp", "esi", "edi", \ - "eip", "ps", "cs", "ss", \ - "ds", "es", "fs", "gs", \ - } - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP_REGNUM 5 /* Contains address of executing stack frame */ -#define SP_REGNUM 4 /* Contains address of top of stack */ - -#define PC_REGNUM 8 -#define PS_REGNUM 9 - -#define REGISTER_U_ADDR(addr, blockend, regno) \ - (addr) = i386_register_u_addr ((blockend),(regno)); - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (NUM_REGS * 4) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N)*4) - -/* Number of bytes of storage in the actual machine representation - for register N. */ - -#define REGISTER_RAW_SIZE(N) (4) - -/* Number of bytes of storage in the program's representation - for register N. */ - -#define REGISTER_VIRTUAL_SIZE(N) (4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 4 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 4 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);} - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);} - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { (SP) -= sizeof (ADDR); \ - write_memory ((SP), &(ADDR), sizeof (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#ifdef KERNELDEBUG -#define KERNTEXT_BASE 0xfe000000 -#ifdef NEWVM -#define KERNSTACK_TOP (read_register(SP_REGNUM) + 0x2000) /* approximate */ -#else -/* #define KERNSTACK_TOP (P1PAGES << PGSHIFT) */ -#define KERNSTACK_TOP 0xfe000000 -#endif -extern int kernel_debugging; -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && \ - !kernel_debugging ? outside_startup_file(FRAME_SAVED_PC(thisframe)) :\ - (chain >= read_register(SP_REGNUM) && chain < KERNSTACK_TOP)) -#else -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) -#endif - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) (numargs) = i386_frame_num_args(fi) - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); } - - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME { i386_pop_frame (); } - -#define NEW_CALL_FUNCTION - -#if 0 -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) {} - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR {} - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR {} - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS {} - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS {} -#endif diff --git a/gnu/usr.bin/gdb/config/m-i386g-sv32.h b/gnu/usr.bin/gdb/config/m-i386g-sv32.h deleted file mode 100644 index 542b5c3ab976..000000000000 --- a/gnu/usr.bin/gdb/config/m-i386g-sv32.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Macro defintions for i386, running System V 3.2. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-i386g-sv32.h,v 1.2 1993/08/02 17:39:57 mycroft Exp $ -*/ - -#include "m-i386gas.h" - -/* Apparently there is inconsistency among various System V's about what - the name of this field is. */ -#define U_FPSTATE(u) u.u_fps.u_fpstate - -/* TIOCGETC is defined in System V 3.2 termio.h, but struct tchars - is not. This makes problems for inflow.c. */ -#define TIOCGETC_BROKEN diff --git a/gnu/usr.bin/gdb/config/m-i386gas.h b/gnu/usr.bin/gdb/config/m-i386gas.h deleted file mode 100644 index 56f2be0ab170..000000000000 --- a/gnu/usr.bin/gdb/config/m-i386gas.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Macro definitions for i386 using the GNU object file format. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-i386gas.h,v 1.2 1993/08/02 17:39:58 mycroft Exp $ -*/ - -/* - * Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu) - * July 1988 - * - * i386gnu: COFF_ENCAPSULATE - */ - - -#define COFF_ENCAPSULATE - -#include "m-i386.h" - - -#define NAMES_HAVE_UNDERSCORE - -#undef COFF_FORMAT -#define READ_DBX_FORMAT - diff --git a/gnu/usr.bin/gdb/config/m-isi.h b/gnu/usr.bin/gdb/config/m-isi.h deleted file mode 100644 index 91825d744513..000000000000 --- a/gnu/usr.bin/gdb/config/m-isi.h +++ /dev/null @@ -1,525 +0,0 @@ -/* Definitions to make GDB run on an ISI Optimum V (3.05) under 4.3bsd. - Copyright (C) 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-isi.h,v 1.2 1993/08/02 17:39:58 mycroft Exp $ -*/ - -/* This has not been tested on ISI's running BSD 4.2, but it will probably - work. */ - -/* Identify this machine */ -#ifndef ISI68K -#define ISI68K -#endif - -/* Define the bit, byte, and word ordering of the machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = read_memory_integer (pc, 2); \ - if (op == 0047126) \ - pc += 4; /* Skip link #word */ \ - else if (op == 0044016) \ - pc += 6; /* Skip link #long */ \ - else if (op == 0060000) \ - pc += 4; /* Skip bra #word */ \ - else if (op == 00600377) \ - pc += 6; /* skip bra #long */ \ - else if ((op & 0177400) == 0060000) \ - pc += 2; /* skip bra #char */ \ -} - - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ -read_memory_integer (read_register (SP_REGNUM), 4) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -/*#define KERNEL_U_ADDR 0x10800000*/ -#define KERNEL_U_ADDR 0 - -/* Address of end of stack space. */ - -/*#define STACK_END_ADDR 0x10000000*/ -#define STACK_END_ADDR 0xfffe000 - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x4e, 0x4f} - -/* Data segment starts at etext rounded up to DATAROUND in {N,Z}MAGIC files */ - -#define DATAROUND 0x20000 -#define N_DATADDR(hdr) (hdr.a_magic != OMAGIC ? \ - (hdr.a_text + DATAROUND) & ~(DATAROUND-1) : hdr.a_text) - -/* Text segment starts at sizeof (struct exec) in {N,Z}MAGIC files */ - -#define N_TXTADDR(hdr) (hdr.a_magic != OMAGIC ? sizeof (struct exec) : 0) - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. - On the ISI, the kernel resets the pc to the trap instr */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e75) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ -#define NUM_REGS 29 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ - {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \ - "ps", "pc", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fpcontrol", "fpstatus", "fpiaddr" } - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP_REGNUM 14 /* Contains address of executing stack frame */ -#define SP_REGNUM 15 /* Contains address of top of stack */ -#define PS_REGNUM 16 /* Contains processor status */ -#define PC_REGNUM 17 /* Contains program counter */ -#define FP0_REGNUM 18 /* Floating point register 0 */ -#define FPC_REGNUM 26 /* 68881 control register */ - -/* expects blockend to be u.u_ar0 */ -extern int rloc[]; /* Defined in isi-dep.c */ -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ blockend &= UPAGES*NBPG - 1; \ - if (regno < 18) addr = (int)blockend + rloc[regno]*4; \ - else if (regno < 26) addr = (int) &((struct user *)0)->u_68881_regs \ - + (regno - 18) * 12; \ - else if (regno < 29) addr = (int) &((struct user *)0)->u_68881_regs \ - + 8 * 12 + (regno - 26) * 4; \ -} - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (16*4+8*12+8+20) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) \ - ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \ - : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \ - : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 12 bytes. */ - -#define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 8-byte doubles. */ - -#define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 12 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 8 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_from_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_to_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (9, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the ISI, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && outside_startup_file (FRAME_SAVED_PC (thisframe))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(val, fi) \ -{ register CORE_ADDR pc = FRAME_SAVED_PC (fi); \ - register int insn = 0177777 & read_memory_integer (pc, 2); \ - val = 0; \ - if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \ - val = read_memory_integer (pc + 2, 2); \ - else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \ - || (insn & 0170777) == 0050117) /* addqw */ \ - { val = (insn >> 9) & 7; if (val == 0) val = 8; } \ - else if (insn == 0157774) /* addal #WW, sp */ \ - val = read_memory_integer (pc + 2, 4); \ - val >>= 2; } - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - register int insn; \ - register int offset; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ - && (frame_info)->pc <= (frame_info)->frame) \ - { next_addr = (frame_info)->frame; \ - pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info)->pc); \ - /* Verify we have a link a6 instruction next, \ - or a branch followed by a link a6 instruction; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ -retry: \ - insn = read_memory_integer (pc, 2); \ - if (insn == 044016) \ - next_addr = (frame_info)->frame - read_memory_integer (pc += 2, 4), pc+=4; \ - else if (insn == 047126) \ - next_addr = (frame_info)->frame - read_memory_integer (pc += 2, 2), pc+=2; \ - else if ((insn & 0177400) == 060000) /* bra insn */ \ - { offset = insn & 0377; \ - pc += 2; /* advance past bra */ \ - if (offset == 0) /* bra #word */ \ - offset = read_memory_integer (pc, 2), pc += 2; \ - else if (offset == 0377) /* bra #long */ \ - offset = read_memory_integer (pc, 4), pc += 4; \ - pc += offset; \ - goto retry; \ - } else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - insn = read_memory_integer (pc, 2), pc += 2; \ - regmask = read_memory_integer (pc, 2); \ - if ((insn & 0177760) == 022700) /* movl rn, (sp) */ \ - (frame_saved_regs).regs[(insn&7) + ((insn&010)?8:0)] = next_addr; \ - else if ((insn & 0177760) == 024700) /* movl rn, -(sp) */ \ - (frame_saved_regs).regs[(insn&7) + ((insn&010)?8:0)] = next_addr-=4; \ - else if (insn == 0044327) /* moveml mask, (sp) */ \ - { pc += 2; \ - /* Regmask's low bit is for register 0, the first written */ \ - next_addr -= 4; \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4); \ - } else if (insn == 0044347) /* moveml mask, -(sp) */ \ - { pc += 2; \ - /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (read_memory_integer (pc, 2) == 041147 \ - && read_memory_integer (pc+2, 2) == 042347) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ -} - -/* Compensate for lack of `vprintf' function. */ -#ifndef HAVE_VPRINTF -#define vprintf(format, ap) _doprnt (format, ap, stdout) -#endif - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ - char raw_buffer[12]; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - { read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); \ - sp = push_bytes (sp, raw_buffer, 12); } \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - char raw_buffer[12]; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - if (fsr.regs[regnum]) \ - { read_memory (fsr.regs[regnum], raw_buffer, 12); \ - write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); }\ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame ( create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); } - -/* This sequence of words is the instructions - fmovem #,-(sp) - moveml 0xfffc,-(sp) - clrw -(sp) - movew ccr,-(sp) - /..* The arguments are pushed at this point by GDB; - no code is needed in the dummy for this. - The CALL_DUMMY_START_OFFSET gives the position of - the following jsr instruction. *../ - jsr @#32323232 - addl #69696969,sp - bpt - nop -Note this is 24 bytes. -We actually start executing at the jsr, since the pushing of the -registers is done by PUSH_DUMMY_FRAME. If this were real code, -the arguments for the function called by the jsr would be pushed -between the moveml and the jsr, and we could allow it to execute through. -But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done, -and we cannot allow the moveml to push the registers again lest they be -taken for the arguments. */ - -#define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71} - -#define CALL_DUMMY_LENGTH 28 - -#define CALL_DUMMY_START_OFFSET 12 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *(int *)((char *) dummyname + 20) = nargs * 4; \ - *(int *)((char *) dummyname + 14) = fun; } - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } diff --git a/gnu/usr.bin/gdb/config/m-m68kbsd.h b/gnu/usr.bin/gdb/config/m-m68kbsd.h deleted file mode 100644 index af20bcb0424c..000000000000 --- a/gnu/usr.bin/gdb/config/m-m68kbsd.h +++ /dev/null @@ -1,543 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - * - * from: @(#)m-hp300bsd.h 6.8 (Berkeley) 5/8/91 - * $Id: m-m68kbsd.h,v 1.2 1994/01/10 00:04:08 cgd Exp $ - */ - -/* Parameters for execution on a Hewlett-Packard 9000/300, running bsd. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Describe the endian nature of this machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* - * Configuration file for HP9000/300 series machine running - * University of Utah's 4.3bsd port. This is NOT for HP-UX. - * Problems to hpbsd-bugs@cs.utah.edu - */ - -#ifndef hp300 -#define hp300 -#endif - -/* Library stuff: POSIX tty (not supported yet), V7 tty (sigh), vprintf. */ - -#define HAVE_TERMIOS 1 -#define USE_OLD_TTY 1 -#define HAVE_VPRINTF 1 - -/* We support local and remote kernel debugging. */ - -#define KERNELDEBUG 1 - -/* Watch out for NaNs */ - -#define IEEE_FLOAT - -/* We do long longs. */ - -#define LONG_LONG - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = read_memory_integer (pc, 2); \ - if (op == 0047126) \ - pc += 4; /* Skip link #word */ \ - else if (op == 0044016) \ - pc += 6; /* Skip link #long */ \ -} - -/* Immediately after a function call, return the saved pc. - Can't go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ -read_memory_integer (read_register (SP_REGNUM), 4) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#ifndef NEWVM -#define KERNEL_U_ADDR 0x00816000 -#define STACK_END_ADDR 0xfff00000 -#else -#include -#define KERNEL_U_ADDR USRSTACK -#define SZ_SIGTRAMP 20 -#define STACK_END_ADDR (USRSTACK - SZ_SIGTRAMP) -#endif - -/* Same as offsetof macro from stddef.h (which 4.3BSD doesn't have). */ -#define my_offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER) - -#ifndef NEWVM -/* On the HP300, sigtramp is in the u area. Gak! User struct is not - mapped to the same virtual address in user/kernel address space - (hence STACK_END_ADDR as opposed to KERNEL_U_ADDR). */ -#define IN_SIGTRAMP(pc, name) \ - ((pc) >= STACK_END_ADDR + my_offsetof (struct user, u_pcb.pcb_sigc[0]) \ - && (pc) < STACK_END_ADDR + my_offsetof (struct user, u_pcb.pcb_sigc[12]) \ - ) -#else -#define IN_SIGTRAMP(pc, name) ((pc) >= STACK_END_ADDR && (pc) < USRSTACK) -#endif - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x4e, 0x42} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 2 - -/* Nonzero if instruction at PC is a return instruction. */ - -/* Allow any of the return instructions, including a trapv and a return - from interupt. */ -#define ABOUT_TO_RETURN(pc) ((read_memory_integer (pc, 2) & ~3) == 0x4e74) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Largest integer type */ -#define LONGEST long long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 29 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ - {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp", \ - "ps", "pc", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fpcontrol", "fpstatus", "fpiaddr" } - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP_REGNUM 14 /* Contains address of executing stack frame */ -#define SP_REGNUM 15 /* Contains address of top of stack */ -#define PS_REGNUM 16 /* Contains processor status */ -#define PC_REGNUM 17 /* Contains program counter */ -#define FP0_REGNUM 18 /* Floating point register 0 */ -#define FPC_REGNUM 26 /* 68881 control register */ -#define FPS_REGNUM 27 /* 68881 status register */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (16*4+8*12+8+12) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) \ - ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \ - : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \ - : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 12 bytes. */ -/* Note that the unsigned cast here forces the result of the - subtractiion to very high positive values if N < FP0_REGNUM */ - -#define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 8-byte doubles. */ - -#define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 12 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 8 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_from_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_to_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (9, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy ((char *)(REGBUF) + \ - (TYPE_LENGTH (TYPE) < 4 ? 4 - TYPE_LENGTH (TYPE) : 0), \ - VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* This is a piece of magic that is given a register number REGNO - and as BLOCKEND the address in the system of the end of the user structure - and stores in ADDR the address in the kernel or core dump - of that register. */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ \ - if (regno < PS_REGNUM) \ - addr = (int) &((struct frame *)(blockend))->f_regs[regno]; \ - else if (regno == PS_REGNUM) \ - addr = (int) &((struct frame *)(blockend))->f_stackadj; \ - else if (regno == PC_REGNUM) \ - addr = (int) &((struct frame *)(blockend))->f_pc; \ - else if (regno < FPC_REGNUM) \ - addr = (int) \ - &((struct user *)0)->u_pcb.pcb_fpregs.fpf_regs[((regno)-FP0_REGNUM)*3];\ - else if (regno == FPC_REGNUM) \ - addr = (int) &((struct user *)0)->u_pcb.pcb_fpregs.fpf_fpcr; \ - else if (regno == FPS_REGNUM) \ - addr = (int) &((struct user *)0)->u_pcb.pcb_fpregs.fpf_fpsr; \ - else \ - addr = (int) &((struct user *)0)->u_pcb.pcb_fpregs.fpf_fpiar; \ -} - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the Sun, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#ifdef KERNELDEBUG -#ifdef NEWVM -#define KERNSTACK_TOP ((unsigned long)KERNEL_U_ADDR + UPAGES*NBPG) -#else -#define KERNSTACK_TOP (KERNEL_U_ADDR + 0x3000) /* UPAGES * NBPG */ -#endif -extern int kernel_debugging; -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && \ - !kernel_debugging ? outside_startup_file(FRAME_SAVED_PC(thisframe)) :\ - (chain >= read_register(SP_REGNUM) && chain < KERNSTACK_TOP)) -#else -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) -#endif - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* Note that we may not be able to tell how many args there are - now that the C compiler delays popping them. */ - -#define FRAME_NUM_ARGS(val, fi) \ -{ register CORE_ADDR pc = FRAME_SAVED_PC (fi); \ - register int insn = 0177777 & read_memory_integer (pc, 2); \ - if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \ - val = read_memory_integer (pc + 2, 2); \ - else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \ - || (insn & 0170777) == 0050117) /* addqw */ \ - { val = (insn >> 9) & 7; if (val == 0) val = 8; } \ - else if (insn == 0157774) /* addal #WW, sp */ \ - val = read_memory_integer (pc + 2, 4); \ - else \ - val = -1; \ - val >>= 2; } - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - int nextinsn; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info)->next \ - && (frame_info)->next->frame < (frame_info)->pc \ - && (frame_info)->pc < (frame_info)->frame) \ - { goto lose; } \ - else \ - { pc = get_pc_function_start ((frame_info)->pc); \ - /* Verify we have a link a6 instruction next; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ - if (044016 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ - else if (047126 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ - else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - regmask = read_memory_integer (pc + 2, 2); \ - /* But before that can come an fmovem. Check for it. */ \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf227 == nextinsn \ - && (regmask & 0xff00) == 0xe000) \ - { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 12); \ - regmask = read_memory_integer (pc + 2, 2); } \ - if (0044327 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ - else if (0044347 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - else if (0x2f00 == (0xfff0 & read_memory_integer (pc, 2))) \ - { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* fmovemx to index of sp may follow. */ \ - regmask = read_memory_integer (pc + 2, 2); \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf236 == nextinsn \ - && (regmask & 0xff00) == 0xf000) \ - { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \ - regmask = read_memory_integer (pc + 2, 2); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (0x426742e7 == read_memory_integer (pc, 4)) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ -} - - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - char raw_buffer[12]; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - if (fsr.regs[regnum]) \ - { read_memory (fsr.regs[regnum], raw_buffer, 12); \ - write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); }\ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); } - -#define NEW_CALL_FUNCTION - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel #end, sp"); \ - asm ("movel #0,a6"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel a6,sp@-"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl sp@,a6"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea sp@(10)"); \ - asm ("movem #0xfffe,sp@-"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil #8,sp@(28)"); \ - asm ("movem sp@,#0xffff"); \ - asm ("rte"); } diff --git a/gnu/usr.bin/gdb/config/m-merlin.h b/gnu/usr.bin/gdb/config/m-merlin.h deleted file mode 100644 index db6d985774a8..000000000000 --- a/gnu/usr.bin/gdb/config/m-merlin.h +++ /dev/null @@ -1,479 +0,0 @@ -/* Definitions to make GDB run on a merlin under utek 2.1 - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-merlin.h,v 1.2 1993/08/02 17:39:59 mycroft Exp $ -*/ - -#ifndef ns16000 -#define ns16000 -#endif - -/* This machine doesn't have the siginterrupt call. */ -#define NO_SIGINTERRUPT - -/* Under Utek, a ptrace'd process can be the only active process for - an executable. Therefore instead of /bin/sh use gdb-sh (which should - just be a copy of /bin/sh which is world readable and writeable). */ -#define SHELL_FILE "/usr/local/lib/gdb-sh" - -/* Define the bit, byte, and word ordering of the machine. */ -/* #define BITS_BIG_ENDIAN */ -/* #define BYTES_BIG_ENDIAN */ -/* #define WORDS_BIG_ENDIAN */ - -# include - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = read_memory_integer (pc, 1); \ - if (op == 0x82) \ - { op = read_memory_integer (pc+2,1); \ - if ((op & 0x80) == 0) pc += 3; \ - else if ((op & 0xc0) == 0x80) pc += 4; \ - else pc += 6; \ - }} - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ - read_memory_integer (read_register (SP_REGNUM), 4) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0xfef000) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0x800000) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xf2} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x12) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 - -/* Define this to say that the "svc" insn is followed by - codes in memory saying which kind of system call it is. */ - -#define NS32K_SVC_IMMED_OPERANDS - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 25 - -#define NUM_GENERAL_REGS 8 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ - "pc", "sp", "fp", "ps", \ - "fsr", \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ - "l0", "l1", "l2", "l3", "l4", \ - } - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define AP_REGNUM FP_REGNUM -#define FP_REGNUM 10 /* Contains address of executing stack frame */ -#define SP_REGNUM 9 /* Contains address of top of stack */ -#define PC_REGNUM 8 /* Contains program counter */ -#define PS_REGNUM 11 /* Contains processor status */ -#define FPS_REGNUM 12 /* Floating point status register */ -#define FP0_REGNUM 13 /* Floating point register 0 */ -#define LP0_REGNUM 21 /* Double register 0 (same as FP0) */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ \ - switch (regno) { \ - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: \ - addr = blockend + (R0 - regno) * sizeof (int); break; \ - case PC_REGNUM: \ - addr = blockend + PC * sizeof (int); break; \ - case SP_REGNUM: \ - addr = blockend + SP * sizeof (int); break; \ - case FP_REGNUM: \ - addr = blockend + FP * sizeof (int); break; \ - case PS_REGNUM: \ - addr = blockend + 12 * sizeof (int); break; \ - case FPS_REGNUM: \ - addr = 108; break; \ - case FP0_REGNUM + 0: case FP0_REGNUM + 1: \ - case FP0_REGNUM + 2: case FP0_REGNUM + 3: \ - case FP0_REGNUM + 4: case FP0_REGNUM + 5: \ - case FP0_REGNUM + 6: case FP0_REGNUM + 7: \ - addr = 76 + (regno - FP0_REGNUM) * sizeof (float); break; \ - case LP0_REGNUM + 0: case LP0_REGNUM + 1: \ - case LP0_REGNUM + 2: case LP0_REGNUM + 3: \ - addr = 76 + (regno - LP0_REGNUM) * sizeof (double); break; \ - default: \ - printf ("bad argument to REGISTER_U_ADDR %d\n", regno); \ - abort (); \ - } \ -} - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double)) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \ - LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 32000, all regs are 4 bytes - except for the doubled floating registers. */ - -#define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 32000, all regs are 4 bytes - except for the doubled floating registers. */ - -#define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 8 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 8 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - ((N) >= FP0_REGNUM ? \ - ((N) >= LP0_REGNUM ? \ - builtin_type_double \ - : builtin_type_float) \ - : builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. - - On this machine this is a no-op, as gcc doesn't run on it yet. - This calling convention is not used. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the Merlin, the frame's nominal address is the FP value, - and at that address is saved previous FP value as a 4-byte word. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -/* compute base of arguments */ -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ CORE_ADDR pc; \ - int insn; \ - int addr_mode; \ - int width; \ - \ - pc = FRAME_SAVED_PC (fi); \ - insn = read_memory_integer (pc,2); \ - addr_mode = (insn >> 11) & 0x1f; \ - insn = insn & 0x7ff; \ - if ((insn & 0x7fc) == 0x57c \ - && addr_mode == 0x14) /* immediate */ \ - { if (insn == 0x57c) /* adjspb */ \ - width = 1; \ - else if (insn == 0x57d) /* adjspw */ \ - width = 2; \ - else if (insn == 0x57f) /* adjspd */ \ - width = 4; \ - numargs = read_memory_integer (pc+2,width); \ - if (width > 1) \ - flip_bytes (&numargs, width); \ - numargs = - sign_extend (numargs, width*8) / 4; } \ - else numargs = -1; \ -} - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ int regmask,regnum; \ - int localcount; \ - CORE_ADDR enter_addr; \ - CORE_ADDR next_addr; \ - \ - enter_addr = get_pc_function_start ((frame_info)->pc); \ - regmask = read_memory_integer (enter_addr+1, 1); \ - localcount = ns32k_localcount (enter_addr); \ - next_addr = (frame_info)->frame + localcount; \ - for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \ - (frame_saved_regs).regs[regnum] \ - = (regmask & 1) ? (next_addr -= 4) : 0; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ - (frame_saved_regs).regs[FP_REGNUM] \ - = read_memory_integer ((frame_info)->frame, 4); } - -/* Compensate for lack of `vprintf' function. */ -#ifndef HAVE_VPRINTF -#define vprintf(format, ap) _doprnt (format, ap, stdout) -#endif /* not HAVE_VPRINTF */ - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = 0; regnum < 8; regnum++) \ - sp = push_word (sp, read_register (regnum)); \ - write_register (SP_REGNUM, sp); \ -} - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = 0; regnum < 8; regnum++) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); \ -} - -/* This sequence of words is the instructions - enter 0xff,0 82 ff 00 - jsr @0x00010203 7f ae c0 01 02 03 - adjspd 0x69696969 7f a5 01 02 03 04 - bpt f2 - Note this is 16 bytes. */ - -#define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 } - -#define CALL_DUMMY_START_OFFSET 3 -#define CALL_DUMMY_LENGTH 16 -#define CALL_DUMMY_ADDR 5 -#define CALL_DUMMY_NARGS 11 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ int flipped = fun | 0xc0000000; \ - flip_bytes (&flipped, 4); \ - *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \ - flipped = - nargs * 4; \ - flip_bytes (&flipped, 4); \ - *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \ -} - -#ifdef notdef -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ - 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("pushl fp"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("pushl 8(sp)"); \ - asm ("pushl 8(sp)"); \ - asm ("pushal 0x14(sp)"); \ - asm ("pushr $037777"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("popr $037777"); \ - asm ("subl2 $8,(sp)"); \ - asm ("movl (sp),sp"); \ - asm ("rei"); } -#endif diff --git a/gnu/usr.bin/gdb/config/m-news.h b/gnu/usr.bin/gdb/config/m-news.h deleted file mode 100644 index 3f81039af4b2..000000000000 --- a/gnu/usr.bin/gdb/config/m-news.h +++ /dev/null @@ -1,600 +0,0 @@ -/* Parameters for execution on a Sony/NEWS, for GDB, the GNU debugger. - Copyright (C) 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-news.h,v 1.2 1993/08/02 17:40:00 mycroft Exp $ -*/ - -/* See following cpu type determination macro to get the machine type. - -Here is an m-news.h file for gdb. It supports the 68881 registers. - by hikichi@srava.sra.junet - -* Support Sun assembly format instead of Motorola one. -* Ptrace for handling floating register has a bug(before NEWS OS version 2.2), -* After NEWS OS version 3.2, some of ptrace's bug is fixed. - But we cannot change the floating register(see adb(1) in OS 3.2) yet. - -Here is an m-news800.h file for gdb version 2.6. It supports the 68881 -registers. - -/* Identify this machine */ -#ifndef sony_news -#define sony_news -#endif - -/* determine the cpu type from machine type. */ -#if defined(news1500)||defined(news1700)||defined(news1800)||defined(news1900) -# ifndef mc68020 -# define mc68020 -# endif /* not def mc68020 */ -# ifndef mc68030 -# define mc68030 -# endif /* not def mc68030 */ -#else /* 1000 Series */ -# if defined(news700)||defined(news800)||defined(news900) -# ifndef mc68020 -# define mc68020 -# endif -# else /* 800 Series */ -/* unkown model ? */ -# endif /* 800 Series */ -#endif /* 1000 Series */ - -/* Define the bit, byte, and word ordering of the machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* Use GNU assembler instead of standard assembler */ -#define USE_GAS - -/* Motorola assembly format */ -#ifndef USE_GAS -#define MOTOROLA -#endif - -/* Doesn't have siginterrupt. */ -#define NO_SIGINTERRUPT - -#define HAVE_WAIT_STRUCT - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Symbols on this machine are in DBX format. */ -#define READ_DBX_FORMAT - -/* We can't use "isatty" or "fileno" on this machine. This isn't good, - but it will have to do. */ -#define ISATTY(FP) ((FP) == stdin || (FP) == stdout) - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = read_memory_integer (pc, 2); \ - if (op == 0047126) \ - pc += 4; /* Skip link #word */ \ - else if (op == 0044016) \ - pc += 6; /* Skip link #long */ \ -} - - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ -read_memory_integer (read_register (SP_REGNUM), 4) - -/* THis is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR UADDR - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0x80000000 - (UPAGES+CLSIZE)*NBPG) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x4e, 0x4f} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 2 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e75) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 29 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ - {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \ - "pc", "ps", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fpcontrol", "fpstatus", "fpiaddr" } - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP_REGNUM 14 /* Contains address of executing stack frame */ -#define SP_REGNUM 15 /* Contains address of top of stack */ -#define PC_REGNUM 16 /* Contains program counter */ -#define PS_REGNUM 17 /* Contains processor status */ -#define FP0_REGNUM 18 /* Floating point register 0 */ -#define FPC_REGNUM 26 /* 68881 control register */ - -/* before NEWSOS version 2.2 or more. If you have a new OS, - redefine this macro in 'see m-newsos3.h'. */ -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ if (regno <= FP_REGNUM) \ - addr = blockend + 4 + regno * 4; \ - else if (regno == SP_REGNUM) \ - addr = blockend - 4 * 4; \ - else if (regno <= PS_REGNUM) \ - addr = blockend + (regno - PS_REGNUM) * 4; \ - else if (regno < FPC_REGNUM) \ - addr = blockend + 4 + 4 * 14 + 4 * 4 + (regno - FP0_REGNUM) * 12; \ - else \ - addr = blockend + 4 + 4 * 16 + (regno - FPC_REGNUM) * 4; \ -} - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (16*4+8*12+8+12) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) \ - ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \ - : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \ - : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 12 bytes. */ - -#define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 8-byte doubles. */ - -#define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 12 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 8 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_from_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_to_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (9, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -/* when it return the floating value, use the FP0 in NEWS. */ -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - { if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ - { \ - REGISTER_CONVERT_TO_VIRTUAL (FP0_REGNUM, \ - ®BUF[REGISTER_BYTE (FP0_REGNUM)], VALBUF); \ - } \ - else \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)); } - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -/* when it return the floating value, use the FP0 in NEWS. */ -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - { if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ - { \ - char raw_buf[REGISTER_RAW_SIZE (FP0_REGNUM)]; \ - REGISTER_CONVERT_TO_RAW (FP0_REGNUM, VALBUF, raw_buf); \ - write_register_bytes (FP0_REGNUM, \ - raw_buf, REGISTER_RAW_SIZE (FP0_REGNUM)); \ - } \ - else \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)); } - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* Compensate for lack of `vprintf' function. */ -#ifndef HAVE_VPRINTF -#define vprintf(format, ap) _doprnt (format, ap, stdout) -#endif /* not HAVE_VPRINTF */ - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the NEWS, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(val, fi) \ -{ register CORE_ADDR pc = FRAME_SAVED_PC (fi); \ - register int insn = 0177777 & read_memory_integer (pc, 2); \ - val = 0; \ - if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \ - val = read_memory_integer (pc + 2, 2); \ - else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \ - || (insn & 0170777) == 0050117) /* addqw */ \ - { val = (insn >> 9) & 7; if (val == 0) val = 8; } \ - else if (insn == 0157774) /* addal #WW, sp */ \ - val = read_memory_integer (pc + 2, 4); \ - val >>= 2; } - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - int nextinsn; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ - && (frame_info)->pc <= (frame_info)->frame) \ - { next_addr = (frame_info)->frame; \ - pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info)->pc); \ - /* Verify we have a link a6 instruction next; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ - if (044016 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ - else if (047126 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ - else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - regmask = read_memory_integer (pc + 2, 2); \ - /* But before that can come an fmovem. Check for it. */ \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf227 == nextinsn \ - && (regmask & 0xff00) == 0xe000) \ - { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 12); \ - regmask = read_memory_integer (pc + 2, 2); } \ - if (0044327 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ - else if (0044347 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - else if (0x2f00 == (0xfff0 & read_memory_integer (pc, 2))) \ - { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* fmovemx to index of sp may follow. */ \ - regmask = read_memory_integer (pc + 2, 2); \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf236 == nextinsn \ - && (regmask & 0xff00) == 0xf000) \ - { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \ - regmask = read_memory_integer (pc + 2, 2); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (0x426742e7 == read_memory_integer (pc, 4)) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ -} - -/* Things needed for making the inferior call functions. */ -/* On NEWS os 2.x ptrace cannot modify fp and floating registers. */ -#define PTRACE_BUG - -/* Push an empty stack frame, to record the current PC, etc. */ -/* now ptrace has a bug to write floating register in old OS */ -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); } - -/* This sequence of words is the instructions - fmove.m #,-(sp) - movem.l 0xfffc,-(sp) ;; no save a6(fp) and a7(sp) - clr.w -(sp) - move.w ccr,-(sp) - /..* The arguments are pushed at this point by GDB; - no code is needed in the dummy for this. - The CALL_DUMMY_START_OFFSET gives the position of - the following jsr instruction. *../ - jbsr (#32323232) - add.l #69696969,sp - bpt - nop -Note this is 24 bytes. -We actually start executing at the jsr, since the pushing of the -registers is done by PUSH_DUMMY_FRAME. If this were real code, -the arguments for the function called by the jsr would be pushed -between the moveml and the jsr, and we could allow it to execute through. -But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done, -and we cannot allow the moveml to push the registers again lest they be -taken for the arguments. */ - -#define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71} - -#define CALL_DUMMY_LENGTH 28 - -#define CALL_DUMMY_START_OFFSET 12 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *(int *)((char *) dummyname + 20) = nargs * 4; \ - *(int *)((char *) dummyname + 14) = fun; } - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#ifdef MOTOROLA -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("move.l $ end, sp"); \ - asm ("clr.l fp"); } -#else -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } -#endif - -/* Push the frame pointer register on the stack. */ -#ifdef MOTOROLA -#define PUSH_FRAME_PTR \ - asm ("move.l fp, -(sp)"); -#else -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); -#endif - -/* Copy the top-of-stack to the frame pointer register. */ -#ifdef MOTOROLA -#define POP_FRAME_PTR \ - asm ("move.l (sp), fp"); -#else -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); -#endif - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#ifdef MOTOROLA -#define PUSH_REGISTERS \ -{ asm ("clr.w -(sp)"); \ - asm ("pea (10,sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } -#else -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } -#endif - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#ifdef MOTOROLA -#define POP_REGISTERS \ -{ asm ("subi.l $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } -#else -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } -#endif - diff --git a/gnu/usr.bin/gdb/config/m-newsos3.h b/gnu/usr.bin/gdb/config/m-newsos3.h deleted file mode 100644 index ff9797b2e592..000000000000 --- a/gnu/usr.bin/gdb/config/m-newsos3.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Parameters for execution on a Sony/NEWS with News-OS version 3, - for GDB, the GNU debugger. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-newsos3.h,v 1.2 1993/08/02 17:40:01 mycroft Exp $ -*/ -#define NEWSOS3 -#include "m-news.h" - -#undef STACK_END_ADDR -/* USRSTACK */ -#define STACK_END_ADDR (0x80000000 - UPAGES*NBPG) - -/* Have siginterupt on NEWS OS 3.x. */ -#undef NO_SIGINTERRUPT - -#undef USE_PCB - -/* now old ptrace bug has fixed almost. Remain constrain is; - When some process do not touch the floating register, - ptrace cannot change the floating register containts. -*/ -#undef PTRACE_BUG - -#undef PUSH_DUMMY_FRAME -#undef POP_FRAME -/* now ptrace has a bug to write floating register in NEWS OS version 2.x */ -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ - char raw_buffer[12]; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - { read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); \ - sp = push_bytes (sp, raw_buffer, 12); } \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - char raw_buffer[12]; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - if (fsr.regs[regnum]) \ - { read_memory (fsr.regs[regnum], raw_buffer, 12); \ - write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); }\ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); } - -/* NewsOS 3 apparently dies on large alloca's -- roland@ai.mit.edu. */ -#define BROKEN_LARGE_ALLOCA - -/* Make this macro from peep of core file. */ -#undef REGISTER_U_ADDR -#ifdef USE_PCB -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ blockend += 4; /* why? */ \ - if (regno <= FP_REGNUM) \ - addr = blockend + regno * 4; \ - else if (regno == SP_REGNUM) \ - addr = blockend - 4 - 4 * 4; \ - else if (regno <= PS_REGNUM) \ - addr = blockend - 4 + (regno - PS_REGNUM) * 4; \ - else if (regno < FPC_REGNUM) \ - addr = blockend + (14 + 1 + 3) * 4 + (regno - FP0_REGNUM) * 12; \ - else \ - addr = blockend + 15 * 4 + (regno - FPC_REGNUM) * 4; \ -} -#else -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ blockend += 4; /* why? */ \ - if (regno <= FP_REGNUM) \ - addr = blockend + regno * 4; \ - else if (regno == SP_REGNUM) \ - addr = blockend -4 - 4 * 4; \ - else if (regno <= PS_REGNUM) \ - addr = blockend - 4 + (regno - PS_REGNUM) * 4; \ - else if (regno < FPC_REGNUM) \ - addr = blockend + (14 + 1 + 3) * 4 + (regno - FP0_REGNUM) * 12; \ - else \ - addr = blockend + 15 * 4 + (regno - FPC_REGNUM) * 4; \ -} -#endif diff --git a/gnu/usr.bin/gdb/config/m-npl.h b/gnu/usr.bin/gdb/config/m-npl.h deleted file mode 100644 index 27eed8760c13..000000000000 --- a/gnu/usr.bin/gdb/config/m-npl.h +++ /dev/null @@ -1,534 +0,0 @@ -/* Parameters for execution on a Gould NP1, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-npl.h,v 1.2 1993/08/02 17:40:02 mycroft Exp $ -*/ - -/* Define the bit, byte, and word ordering of the machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* This code appears in libraries on Gould machines. Ignore it. */ -#define IGNORE_SYMBOL(type) (type == N_ENTRY) - -/* We don't want the extra gnu symbols on the machine; - they will interfere with the shared segment symbols. */ -#define NO_GNU_STABS - -/* Macro for text-offset and data info (in NPL a.out format). */ -#define TEXTINFO \ - text_offset = N_TXTOFF (exec_coffhdr, exec_aouthdr); \ - exec_data_offset = N_TXTOFF (exec_coffhdr, exec_aouthdr)\ - + exec_aouthdr.a_text - -/* Macro for number of symbol table entries */ -#define END_OF_TEXT_DEFAULT \ - (0xffffff) - -/* Macro for number of symbol table entries */ -#define NUMBER_OF_SYMBOLS \ - (coffhdr.f_nsyms) - -/* Macro for file-offset of symbol table (in NPL a.out format). */ -#define SYMBOL_TABLE_OFFSET \ - N_SYMOFF (coffhdr) - -/* Macro for file-offset of string table (in NPL a.out format). */ -#define STRING_TABLE_OFFSET \ - (N_STROFF (coffhdr) + sizeof(int)) - -/* Macro to store the length of the string table data in INTO. */ -#define READ_STRING_TABLE_SIZE(INTO) \ - { INTO = hdr.a_stsize; } - -/* Macro to declare variables to hold the file's header data. */ -#define DECLARE_FILE_HEADERS struct exec hdr; \ - FILHDR coffhdr - -/* Macro to read the header data from descriptor DESC and validate it. - NAME is the file name, for error messages. */ -#define READ_FILE_HEADERS(DESC, NAME) \ -{ val = myread (DESC, &coffhdr, sizeof coffhdr); \ - if (val < 0) \ - perror_with_name (NAME); \ - val = myread (DESC, &hdr, sizeof hdr); \ - if (val < 0) \ - perror_with_name (NAME); \ - if (coffhdr.f_magic != GNP1MAGIC) \ - error ("File \"%s\" not in coff executable format.", NAME); \ - if (N_BADMAG (hdr)) \ - error ("File \"%s\" not in executable format.", NAME); } - -/* Define COFF and other symbolic names needed on NP1 */ -#define NS32GMAGIC GNP1MAGIC -#define NS32SMAGIC GPNMAGIC -#ifndef HAVE_VPRINTF -#define vprintf printf -#endif /* not HAVE_VPRINTF */ - -/* Get rid of any system-imposed stack limit if possible. */ -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ -#define FUNCTION_START_OFFSET 8 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. One NPL we can have one two startup - sequences depending on the size of the local stack: - - Either: - "suabr b2, #" - of - "lil r4, #", "suabr b2, #(r4)" - - "lwbr b6, #", "stw r1, 8(b2)" - Optional "stwbr b3, c(b2)" - Optional "trr r2,r7" (Gould first argument register passing) - or - Optional "stw r2,8(b3)" (Gould first argument register passing) - */ -#define SKIP_PROLOGUE(pc) { \ - register int op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0xFA0B0000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x59400000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x5F000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xD4820008) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0x5582000C) { \ - pc += 4; \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } else { \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xd5030008) { \ - pc += 4; \ - } \ - } \ - } else { \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } \ - } \ - } \ - } \ - } \ - } \ - if ((op & 0xffff0000) == 0x59000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x5F000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xD4820008) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0x5582000C) { \ - pc += 4; \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } else { \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xd5030008) { \ - pc += 4; \ - } \ - } \ - } else { \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } \ - } \ - } \ - } \ - } \ -} - -/* Immediately after a function call, return the saved pc. - Can't go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. True on NPL! Return address is in R1. - The true return address is REALLY 4 past that location! */ -`#define SAVED_PC_AFTER_CALL(frame) \ - (read_register(R1_REGNUM) + 4) - -/* Address of U in kernel space */ -#define KERNEL_U_ADDR 0x7fffc000 - -/* Address of end of stack space. */ -#define STACK_END_ADDR 0x7fffc000 - -/* Stack grows downward. */ -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ -#define BREAKPOINT {0x28, 0x09} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ -#define DECR_PC_AFTER_BREAK 2 - -/* Nonzero if instruction at PC is a return instruction. "bu 4(r1)" */ -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0x40100004) - -/* Return 1 if P points to an invalid floating point value. */ -#define INVALID_FLOAT(p, len) ((*(short *)p & 0xff80) == 0x8000) - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ -#define REGISTER_TYPE long - -/* Size of bytes of vector register (NP1 only), 32 elements * sizeof(int) */ -#define VR_SIZE 128 - -/* Number of machine registers */ -#define NUM_REGS 27 -#define NUM_GEN_REGS 16 -#define NUM_CPU_REGS 4 -#define NUM_VECTOR_REGS 7 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ -#define REGISTER_NAMES { \ - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ - "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", \ - "sp", "ps", "pc", "ve", \ - "v1", "v2", "v3", "v4", "v5", "v6", "v7", \ -} - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ -#define R1_REGNUM 1 /* Gr1 => return address of caller */ -#define R4_REGNUM 4 /* Gr4 => register save area */ -#define R5_REGNUM 5 /* Gr5 => register save area */ -#define R6_REGNUM 6 /* Gr6 => register save area */ -#define R7_REGNUM 7 /* Gr7 => register save area */ -#define B1_REGNUM 9 /* Br1 => start of this code routine */ -#define FP_REGNUM 10 /* Br2 == (sp) */ -#define AP_REGNUM 11 /* Br3 == (ap) */ -#define SP_REGNUM 16 /* A copy of Br2 saved in trap */ -#define PS_REGNUM 17 /* Contains processor status */ -#define PC_REGNUM 18 /* Contains program counter */ -#define VE_REGNUM 19 /* Vector end (user setup) register */ -#define V1_REGNUM 20 /* First vector register */ -#define V7_REGNUM 27 /* First vector register */ - -/* This is a piece of magic that is given a register number REGNO - and as BLOCKEND the address in the system of the end of the user structure - and stores in ADDR the address in the kernel or core dump - of that register. */ -#define REGISTER_U_ADDR(addr, blockend, regno) { \ - addr = blockend + regno * 4; \ - if (regno == VE_REGNUM) addr = blockend - 9 * 4; \ - if (regno == PC_REGNUM) addr = blockend - 8 * 4; \ - if (regno == PS_REGNUM) addr = blockend - 7 * 4; \ - if (regno == SP_REGNUM) addr = blockend - 6 * 4; \ - if (regno >= V1_REGNUM) \ - addr = blockend + 16 * 4 + (regno - V1_REGNUM) * VR_SIZE; \ -} - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES \ - (NUM_GEN_REGS*4 + NUM_VECTOR_REGS*VR_SIZE + NUM_CPU_REGS*4) - -/* Index within `registers' of the first byte of the space for - register N. */ -#define REGISTER_BYTE(N) \ - (((N) < V1_REGNUM) ? ((N) * 4) : (((N) - V1_REGNUM) * VR_SIZE) + 80) - -/* Number of bytes of storage in the actual machine representation - for register N. On the NP1, all normal regs are 4 bytes, but - the vector registers are VR_SIZE*4 bytes long. */ -#define REGISTER_RAW_SIZE(N) \ - (((N) < V1_REGNUM) ? 4 : VR_SIZE) - -/* Number of bytes of storage in the program's representation - for register N. On the NP1, all regs are 4 bytes. */ -#define REGISTER_VIRTUAL_SIZE(N) \ - (((N) < V1_REGNUM) ? 4 : VR_SIZE) - -/* Largest value REGISTER_RAW_SIZE can have. */ -#define MAX_REGISTER_RAW_SIZE VR_SIZE - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ -#define MAX_REGISTER_VIRTUAL_SIZE VR_SIZE - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_RAW_SIZE(REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ -#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. - - On this machine this is a no-op, because gcc isn't used on it - yet. So this calling convention is not used. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) - -/* Extract from an arrary REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the NPL, the frame's norminal address is Br2 and the - previous routines frame is up the stack X bytes, where X is the - value stored in the code function header xA(Br1). */ -#define FRAME_CHAIN(thisframe) (findframe(thisframe)) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && chain != (thisframe)->frame) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) \ - (chain) - -/* Define other aspects of the stack frame on NPL. */ -#define FRAME_SAVED_PC(FRAME) \ - (read_memory_integer ((FRAME)->frame + 8, 4)) - -#define FRAME_ARGS_ADDRESS(fi) \ - ((fi)->next_frame ? \ - read_memory_integer ((fi)->frame + 12, 4) : \ - read_register (AP_REGNUM)) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame + 80) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can check the stab info to see how - many arg we have. No info in stack will tell us */ -#define FRAME_NUM_ARGS(val,fi) (val = findarg(fi)) - -/* Return number of bytes at start of arglist that are not really args. */ -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[R4_REGNUM] = (frame_info)->frame + 0x30; \ - (frame_saved_regs).regs[R5_REGNUM] = (frame_info)->frame + 0x34; \ - (frame_saved_regs).regs[R6_REGNUM] = (frame_info)->frame + 0x38; \ - (frame_saved_regs).regs[R7_REGNUM] = (frame_info)->frame + 0x3C; \ -} - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame ( create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); } - -/* This sequence of words is the instructions: - halt - halt - halt - halt - suabr b2, # - lwbr b6, #con - stw r1, 8(b2) - save caller address, do we care? - lw r2, 60(b2) - arg1 - labr b3, 50(b2) - std r4, 30(b2) - save r4-r7 - std r6, 38(b2) - lwbr b1, # - load function call address - brlnk r1, 8(b1) - call function - halt - halt - ld r4, 30(b2) - restore r4-r7 - ld r6, 38(b2) - - Setup our stack frame, load argumemts, call and then restore registers. -*/ - -#define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71} - -#define CALL_DUMMY_LENGTH 28 - -#define CALL_DUMMY_START_OFFSET 12 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *(int *)((char *) dummyname + 20) = nargs * 4; \ - *(int *)((char *) dummyname + 14) = fun; } - -/* - * No KDB support, Yet! */ -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } diff --git a/gnu/usr.bin/gdb/config/m-pn.h b/gnu/usr.bin/gdb/config/m-pn.h deleted file mode 100644 index b05cc83a0e97..000000000000 --- a/gnu/usr.bin/gdb/config/m-pn.h +++ /dev/null @@ -1,518 +0,0 @@ -/* Parameters for execution on a Gould PN, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-pn.h,v 1.2 1993/08/02 17:40:03 mycroft Exp $ -*/ - -/* Define the bit, byte, and word ordering of the machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* This code appears in libraries on Gould machines. Ignore it. */ -#define IGNORE_SYMBOL(type) (type == N_ENTRY) - -/* We don't want the extra gnu symbols on the machine; - they will interfere with the shared segment symbols. */ -#define NO_GNU_STABS - -/* Macro for text-offset and data info (in PN a.out format). */ -#define TEXTINFO \ - text_offset = N_TXTOFF (exec_coffhdr); \ - exec_data_offset = N_TXTOFF (exec_coffhdr) \ - + exec_aouthdr.a_text - -/* Macro for number of symbol table entries */ -#define END_OF_TEXT_DEFAULT \ - (0xffffff) - -/* Macro for number of symbol table entries */ -#define NUMBER_OF_SYMBOLS \ - (coffhdr.f_nsyms) - -/* Macro for file-offset of symbol table (in usual a.out format). */ -#define SYMBOL_TABLE_OFFSET \ - N_SYMOFF (coffhdr) - -/* Macro for file-offset of string table (in usual a.out format). */ -#define STRING_TABLE_OFFSET \ - (N_STROFF (coffhdr) + sizeof(int)) - -/* Macro to store the length of the string table data in INTO. */ -#define READ_STRING_TABLE_SIZE(INTO) \ - { INTO = hdr.a_stsize; } - -/* Macro to declare variables to hold the file's header data. */ -#define DECLARE_FILE_HEADERS struct old_exec hdr; \ - FILHDR coffhdr - -/* Macro to read the header data from descriptor DESC and validate it. - NAME is the file name, for error messages. */ -#define READ_FILE_HEADERS(DESC, NAME) \ -{ val = myread (DESC, &coffhdr, sizeof coffhdr); \ - if (val < 0) \ - perror_with_name (NAME); \ - val = myread (DESC, &hdr, sizeof hdr); \ - if (val < 0) \ - perror_with_name (NAME); \ - if (coffhdr.f_magic != GNP1MAGIC) \ - error ("File \"%s\" not in coff executable format.", NAME); \ - if (N_BADMAG (hdr)) \ - error ("File \"%s\" not in executable format.", NAME); } - -/* Define COFF and other symbolic names needed on NP1 */ -#define NS32GMAGIC GDPMAGIC -#define NS32SMAGIC PN_MAGIC -#ifndef HAVE_VPRINTF -#define vprintf printf -#endif /* not HAVE_VPRINTF */ - -/* Get rid of any system-imposed stack limit if possible. */ -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ -#define FUNCTION_START_OFFSET 4 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. One PN we can have one or two startup - sequences depending on the size of the local stack: - - Either: - "suabr b2, #" - of - "lil r4, #", "suabr b2, #(r4)" - - "lwbr b6, #", "stw r1, 8(b2)" - Optional "stwbr b3, c(b2)" - Optional "trr r2,r7" (Gould first argument register passing) - or - Optional "stw r2,8(b3)" (Gould first argument register passing) - */ -#define SKIP_PROLOGUE(pc) { \ - register int op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x580B0000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x59400000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x5F000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xD4820008) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0x5582000C) { \ - pc += 4; \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } else { \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xd5030008) { \ - pc += 4; \ - } \ - } \ - } else { \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } \ - } \ - } \ - } \ - } \ - } \ - if ((op & 0xffff0000) == 0x59000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x5F000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xD4820008) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0x5582000C) { \ - pc += 4; \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } else { \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xd5030008) { \ - pc += 4; \ - } \ - } \ - } else { \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } \ - } \ - } \ - } \ - } \ -} - -/* Immediately after a function call, return the saved pc. - Can't go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. True on PN! Return address is in R1. - Note: true return location is 4 bytes past R1! */ -#define SAVED_PC_AFTER_CALL(frame) \ - (read_register(R1_REGNUM) + 4) - -/* Address of U in kernel space */ -#define KERNEL_U_ADDR 0x3fc000 - -/* Address of end of stack space. */ -#define STACK_END_ADDR 0x480000 - -/* Stack grows downward. */ -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ -#define BREAKPOINT {0x28, 0x09} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ -#define DECR_PC_AFTER_BREAK 2 - -/* Nonzero if instruction at PC is a return instruction. "bu 4(r1)" */ -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0xEC100004) - -/* Return 1 if P points to an invalid floating point value. */ -#define INVALID_FLOAT(p, len) ((*(short *)p & 0xff80) == 0x8000) - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ -#define REGISTER_TYPE long - -/* Number of machine registers */ -#define NUM_REGS 19 -#define NUM_GEN_REGS 16 -#define NUM_CPU_REGS 3 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ -#define REGISTER_NAMES { \ - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ - "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", \ - "sp", "ps", "pc", \ -} - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ -#define R1_REGNUM 1 /* Gr1 => return address of caller */ -#define R4_REGNUM 4 /* Gr4 => register save area */ -#define R5_REGNUM 5 /* Gr5 => register save area */ -#define R6_REGNUM 6 /* Gr6 => register save area */ -#define R7_REGNUM 7 /* Gr7 => register save area */ -#define B1_REGNUM 9 /* Br1 => start of this code routine */ -#define FP_REGNUM 10 /* Br2 == (sp) */ -#define AP_REGNUM 11 /* Br3 == (ap) */ -#define SP_REGNUM 16 /* A copy of Br2 saved in trap */ -#define PS_REGNUM 17 /* Contains processor status */ -#define PC_REGNUM 18 /* Contains program counter */ - -/* This is a piece of magic that is given a register number REGNO - and as BLOCKEND the address in the system of the end of the user structure - and stores in ADDR the address in the kernel or core dump - of that register. */ -#define REGISTER_U_ADDR(addr, blockend, regno) { \ - addr = blockend + regno * 4; \ - if (regno == PC_REGNUM) addr = blockend - 8 * 4; \ - if (regno == PS_REGNUM) addr = blockend - 7 * 4; \ - if (regno == SP_REGNUM) addr = blockend - 6 * 4; \ -} - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (NUM_GEN_REGS*4 + NUM_CPU_REGS*4) - -/* Index within `registers' of the first byte of the space for - register N. */ -#define REGISTER_BYTE(N) ((N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the PN, all normal regs are 4 bytes. */ -#define REGISTER_RAW_SIZE(N) (4) - -/* Number of bytes of storage in the program's representation - for register N. On the PN, all regs are 4 bytes. */ -#define REGISTER_VIRTUAL_SIZE(N) (4) - -/* Largest value REGISTER_RAW_SIZE can have. */ -#define MAX_REGISTER_RAW_SIZE (4) - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ -#define MAX_REGISTER_VIRTUAL_SIZE (4) - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_RAW_SIZE(REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ -#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. - - On this machine this is a no-op, because gcc isn't used on it - yet. So this calling convention is not used. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) - -/* Extract from an arrary REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the NPL, the frame's norminal address is Br2 and the - previous routines frame is up the stack X bytes, where X is the - value stored in the code function header xA(Br1). */ -#define FRAME_CHAIN(thisframe) (findframe(thisframe)) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && chain != (thisframe)->frame) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) \ - (chain) - -/* Define other aspects of the stack frame on NPL. */ -#define FRAME_SAVED_PC(frame) \ - (read_memory_integer ((frame)->frame + 8, 4)) - -#define FRAME_ARGS_ADDRESS(fi) \ - ((fi)->next_frame ? \ - read_memory_integer ((fi)->frame + 12, 4) : \ - read_register (AP_REGNUM)) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame + 80) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can check the stab info to see how - many arg we have. No info in stack will tell us */ -#define FRAME_NUM_ARGS(val,fi) (val = findarg(fi)) - -/* Return number of bytes at start of arglist that are not really args. */ -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[R4_REGNUM] = (frame_info)->frame + 0x30; \ - (frame_saved_regs).regs[R5_REGNUM] = (frame_info)->frame + 0x34; \ - (frame_saved_regs).regs[R6_REGNUM] = (frame_info)->frame + 0x38; \ - (frame_saved_regs).regs[R7_REGNUM] = (frame_info)->frame + 0x3C; \ -} - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame ( create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); } - -/* This sequence of words is the instructions: - halt - halt - halt - halt - suabr b2, # - lwbr b6, #con - stw r1, 8(b2) - save caller address, do we care? - lw r2, 60(b2) - arg1 - labr b3, 50(b2) - std r4, 30(b2) - save r4-r7 - std r6, 38(b2) - lwbr b1, # - load function call address - brlnk r1, 8(b1) - call function - halt - halt - ld r4, 30(b2) - restore r4-r7 - ld r6, 38(b2) - - Setup our stack frame, load argumemts, call and then restore registers. -*/ - -#define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71} - -#define CALL_DUMMY_LENGTH 28 - -#define CALL_DUMMY_START_OFFSET 12 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *(int *)((char *) dummyname + 20) = nargs * 4; \ - *(int *)((char *) dummyname + 14) = fun; } - -/* - * No KDB support, Yet! */ -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } diff --git a/gnu/usr.bin/gdb/config/m-pyr.h b/gnu/usr.bin/gdb/config/m-pyr.h deleted file mode 100644 index 501ded76469c..000000000000 --- a/gnu/usr.bin/gdb/config/m-pyr.h +++ /dev/null @@ -1,615 +0,0 @@ -/* Definitions to make GDB run on a Pyramidax under OSx 4.0 (4.2bsd). - Copyright (C) 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-pyr.h,v 1.2 1993/08/02 17:40:04 mycroft Exp $ -*/ - -/* The FSF prefers to define "pyramid on Pyramid 90x machines; the - manufacturer insists on "pyr". Define both. */ - -#ifndef pyr -#define pyr -#endif - -#ifndef pyramid -#define pyramid -#endif - -/* Define PYRAMID_CONTROL_FRAME_DEBUGGING to get copious messages - about reading the control stack on standard output. This - makes gdb unusable as a debugger. */ - -/* #define PYRAMID_CONTROL_FRAME_DEBUGGING */ - -/* Define PYRAMID_FRAME_DEBUGGING -/* use Pyramid's slightly strange ptrace */ -#define PYRAMID_PTRACE - -/* Traditional Unix virtual address spaces have thre regions: text, - data and stack. The text, initialised data, and uninitialised data - are represented in separate segments of the a.out file. - When a process dumps core, the data and stack regions are written - to a core file. This gives a debugger enough information to - reconstruct (and debug) the virtual address space at the time of - the coredump. - Pyramids have an distinct fourth region of the virtual address - space, in which the contents of the windowed registers are stacked - in fixed-size frames. Pyramid refer to this region as the control - stack. Each call (or trap) automatically allocates a new register - frame; each return deallocates the current frame and restores the - windowed registers to their values before the call. - - When dumping core, the control stack is written to a core files as - a third segment. The core-handling functions need to know to deal - with it. */ -/* Tell core.c there is an extra segment. */ -#define REG_STACK_SEGMENT -/* Tell dep.c what the extra segment is. */ -#define PYRAMID_CORE - -/* Define the bit, byte, and word ordering of the machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* Floating point is IEEE compatible on most Pyramid hardware - (Older processors do not have IEEE NaNs). */ -#define IEEE_FLOAT - -#define NO_SIGINTERRUPT - -#define HAVE_WAIT_STRUCT - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -/* FIXME -- do we want to skip insns to allocate the local frame? - If so, what do they look like? - This is becoming harder, since tege@sics.SE wants to change - gcc to not output a prologue when no frame is needed. */ -#define SKIP_PROLOGUE(pc) do {} while (0) - - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) FRAME_SAVED_PC(frame) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG)) - -/* Address of end of stack space. */ -/* This seems to be right for the 90x comp.vuw.ac.nz. - The correct value at any site may be a function of the configured - maximum control stack depth. If so, I don't know where the - control-stack depth is configured, so I can't #include it here. */ -#define STACK_END_ADDR (0xc00cc000) - -/* Register window stack (Control stack) stack definitions - - Address of beginning of control stack. - - size of control stack frame - (Note that since crts0 is usually the first function called, - main()'s control stack is one frame (0x80 bytes) beyond this value. */ - -#define CONTROL_STACK_ADDR (0xc00cd000) - -/* Bytes in a register window -- 16 parameter regs, 16 local regs - for each call, is 32 regs * 4 bytes */ - -#define CONTROL_STACK_FRAME_SIZE (32*4) - -/* FIXME. On a pyr, Data Stack grows downward; control stack goes upwards. - Which direction should we use for INNER_THAN, PC_INNER_THAN ?? */ - -#define INNER_THAN < -#define PC_INNER_THAN > - -/* Stack has strict alignment. */ - -#define STACK_ALIGN(ADDR) (((ADDR)+3)&-4) - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xf0, 00, 00, 00} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. - On a pyr, this is either "ret" or "retd". - It would be friendly to check that any "retd" always had an - argument of 0, since anything else is invalid. */ - -#define ABOUT_TO_RETURN(pc) \ -(((read_memory_integer (pc, 2) & 0x3ff0) == 0x3090) || \ - ((read_memory_integer (pc, 2) & 0x0ff0) == 0x00a0)) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes -- not relevant on the Vax. */ -/* FIXME -- this is ok for a vax, bad for big-endian ieee format. - I would use the definition for a Sun; but it is no better! */ - -#define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000) - -/* Larges integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ -/* pyramids have 64, plus one for the PSW; plus perhaps one more for the - kernel stack pointer (ksp) and control-stack pointer (CSP) */ - -#define NUM_REGS 67 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ -{"gr0", "gr1", "gr2", "gr3", "gr4", "gr5", "gr6", "gr7", \ - "gr8", "gr9", "gr10", "gr11", "logpsw", "cfp", "sp", "pc", \ - "pr0", "pr1", "pr2", "pr3", "pr4", "pr5", "pr6", "pr7", \ - "pr8", "pr9", "pr10", "pr11", "pr12", "pr13", "pr14", "pr15", \ - "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", \ - "lr8", "lr9", "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", \ - "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7", \ - "tr8", "tr9", "tr10", "tr11", "tr12", "tr13", "tr14", "tr15", \ - "psw", "ksp", "csp"} - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -/* pseudo-registers: */ -#define PS_REGNUM 64 /* Contains processor status */ -#define PSW_REGNUM 64 /* Contains current psw, whatever it is.*/ -#define CSP_REGNUM 65 /* address of this control stack frame*/ -#define KSP_REGNUM 66 /* Contains process's Kernel Stack Pointer */ - -#define CFP_REGNUM 13 /* Current data-stack frame ptr */ -#define TR0_REGNUM 48 /* After function call, contains - function result */ - -/* Registers interesting to the machine-independent part of gdb*/ - -#define FP_REGNUM CSP_REGNUM /* Contains address of executing (control) - stack frame */ -#define SP_REGNUM 14 /* Contains address of top of stack -??*/ -#define PC_REGNUM 15 /* Contains program counter */ - -/* Define DO_REGISTERS_INFO() to do machine-specific formatting - of register dumps. */ - -#define DO_REGISTERS_INFO(_regnum) pyr_do_registers_info(_regnum) - -/* need this so we can find the global registers: they never get saved. */ -extern unsigned int global_reg_offset; -extern unsigned int last_frame_offset; -extern unsigned int reg_stack_start; -extern unsigned int reg_stack_end; -extern unsigned int reg_stack_offset; - - -/* Define offsets of registers in the core file (or maybe u area) */ -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ struct user __u; \ - addr = blockend + (regno - 16 ) * 4; \ - if (regno == 67) { \ - printf("\\geting reg 67\\"); \ - addr = (int)(&__u.u_pcb.pcb_csp) - (int) &__u; \ - } else if (regno == KSP_REGNUM) { \ - printf("\\geting KSP (reg %d)\\", KSP_REGNUM); \ - addr = (int)(&__u.u_pcb.pcb_ksp) - (int) &__u; \ - } else if (regno == CSP_REGNUM) { \ - printf("\\geting CSP (reg %d\\",CSP_REGNUM); \ - addr = (int)(&__u.u_pcb.pcb_csp) - (int) &__u; \ - } else if (regno == 64) { \ - printf("\\geting reg 64\\"); \ - addr = (int)(&__u.u_pcb.pcb_csp) - (int) &__u; \ - } else if (regno == PS_REGNUM) \ - addr = blockend - 4; \ - else if (1 && ((16 > regno) && (regno > 11))) \ - addr = last_frame_offset + (4 *(regno+32)); \ - else if (0 && (12 > regno)) \ - addr = global_reg_offset + (4 *regno); \ - else if (16 > regno) \ - addr = global_reg_offset + (4 *regno); \ - else \ - addr = blockend + (regno - 16 ) * 4; \ -} - - - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (NUM_REGS*4) - -/* the Pyramid has register windows. */ - -#define HAVE_REGISTER_WINDOWS - -/* Is this register part of the register window system? A yes answer - implies that 1) The name of this register will not be the same in - other frames, and 2) This register is automatically "saved" (out - registers shifting into ins counts) upon subroutine calls and thus - there is no need to search more than one stack frame for it. */ - -#define REGISTER_IN_WINDOW_P(regnum) \ - ((regnum) >= 16 && (regnum) < 64) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the Pyramid, all regs are 4 bytes. */ - -#define REGISTER_RAW_SIZE(N) 4 - -/* Number of bytes of storage in the program's representation - for register N. On the Pyramid, all regs are 4 bytes. */ - -#define REGISTER_VIRTUAL_SIZE(N) 4 - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 4 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 4 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) builtin_type_int - -/* FIXME: It seems impossible for both EXTRACT_RETURN_VALUE and - STORE_RETURN_VALUE to be correct. */ - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -/****FIXME****/ -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (TR0_REGNUM, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -/* Note that on a register-windowing machine (eg, Pyr, SPARC), this is - where the value is found after the function call -- ie, it should - correspond to GNU CC's FUNCTION_VALUE rather than FUNCTION_OUTGOING_VALUE.*/ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (((int *)(REGBUF))+TR0_REGNUM, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ -/* on pyrs, values are returned in */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (REGISTER_BYTE(TR0_REGNUM), VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ -/* FIXME */ -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \ - ( ((int *)(REGBUF)) [TR0_REGNUM]) - -/* Compensate for lack of `vprintf' function. */ -#define vprintf(format, ap) _doprnt (format, ap, stdout) - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -#define EXTRA_FRAME_INFO \ - FRAME_ADDR bottom; \ - CORE_ADDR frame_cfp; \ - CORE_ADDR frame_window_addr; - -#define INIT_EXTRA_FRAME_INFO(fci) \ -do { \ - (fci)->frame_window_addr = (fci)->frame; \ - (fci)->bottom = \ - ((fci)->next ? \ - ((fci)->frame == (fci)->next_frame ? \ - (fci)->next->bottom : (fci)->next->frame) : \ - read_register (SP_REGNUM)); \ - (fci)->frame_cfp = \ - read_register (CFP_REGNUM); \ - /***fprintf (stderr, \ - "[[creating new frame for %0x,pc=%0x,csp=%0x]]\n", \ - (fci)->frame, (fci)->pc,(fci)->frame_cfp);*/ \ -} while (0); - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the pyr, the frame's nominal address is the address - of parameter register 0. The previous frame is found 32 words up. */ - -#define FRAME_CHAIN(thisframe) \ - ( (thisframe) -> frame - CONTROL_STACK_FRAME_SIZE) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - - /*((thisframe) >= CONTROL_STACK_ADDR))*/ - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. - - I do not understand what this means on a Pyramid, where functions - *always* have a control-stack frame, but may or may not have a - frame on the data stack. Since GBD uses the value of the - control stack pointer as its "address" of a frame, FRAMELESS - is always 1, so does not need to be defined. */ - - -/* Where is the PC for a specific frame */ - -#define FRAME_SAVED_PC(fi) \ - ((CORE_ADDR) (read_memory_integer ( (fi) -> frame + 60, 4))) - -/* There may be bugs in FRAME_ARGS_ADDRESS and FRAME_LOCALS_ADDRESS; - or there may be bugs in accessing the registers that break - their definitions. - Having the macros expand into functions makes them easier to debug. - When the bug is finally located, the inline macro defintions can - be un-#if 0ed, and frame_args_addr and frame_locals_address can - be deleted from pyr-dep.c */ - -/* If the argument is on the stack, it will be here. */ -#define FRAME_ARGS_ADDRESS(fi) \ - frame_args_addr(fi) - -#define FRAME_LOCALS_ADDRESS(fi) \ - frame_locals_address(fi) - -/* The following definitions doesn't seem to work. - I don't understand why. */ -#if 0 -#define FRAME_ARGS_ADDRESS(fi) \ - /*(FRAME_FP(fi) + (13*4))*/ (read_register (CFP_REGNUM)) - -#define FRAME_LOCALS_ADDRESS(fi) \ - ((fi)->frame +(16*4)) - -#endif /* 0 */ - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(val, fi) (val = -1) - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 0 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. - - Note that on register window machines, we are currently making the - assumption that window registers are being saved somewhere in the - frame in which they are being used. If they are stored in an - inferior frame, find_saved_register will break. - - On pyrs, frames of window registers are stored contiguously on a - separate stack. All window registers are always stored. - The pc and psw (gr15 and gr14) are also always saved: the call - insn saves them in pr15 and pr14 of the new frame (tr15,tr14 of the - old frame). - The data-stack frame pointer (CFP) is only saved in functions which - allocate a (data)stack frame (with "adsf"). We detect them by - looking at the first insn of the procedure. - - Other non-window registers (gr0-gr11) are never saved. Pyramid's C - compiler and gcc currently ignore them, so it's not an issue. */ - -#define FRAME_FIND_SAVED_REGS(fi_p, frame_saved_regs) \ -{ register int regnum; \ - register CORE_ADDR pc; \ - register CORE_ADDR fn_start_pc; \ - register int first_insn; \ - register CORE_ADDR prev_cf_addr; \ - register int window_ptr; \ - FRAME fid = FRAME_INFO_ID (fi_p); \ - if (!fid) fatal ("Bad frame info struct in FRAME_FIND_SAVED_REGS"); \ - bzero (&(frame_saved_regs), sizeof (frame_saved_regs)); \ - \ - window_ptr = prev_cf_addr = FRAME_FP(fi_p); \ - \ - for (regnum = 16 ; regnum < 64; regnum++,window_ptr+=4) \ - { \ - (frame_saved_regs).regs[regnum] = window_ptr; \ - } \ - \ - /* In each window, psw, and pc are "saved" in tr14,tr15. */ \ - /*** psw is sometimes saved in gr12 (so sez ) */ \ - (frame_saved_regs).regs[PS_REGNUM] = FRAME_FP(fi_p) + (14*4); \ - \ -/*(frame_saved_regs).regs[PC_REGNUM] = (frame_saved_regs).regs[31];*/ \ - (frame_saved_regs).regs[PC_REGNUM] = FRAME_FP(fi_p) + ((15+32)*4); \ - \ - /* Functions that allocate a frame save sp *where*? */ \ -/*first_insn = read_memory_integer (get_pc_function_start ((fi_p)->pc),4); */ \ - \ - fn_start_pc = (get_pc_function_start ((fi_p)->pc)); \ - first_insn = read_memory_integer(fn_start_pc, 4); \ - \ - if (0x08 == ((first_insn >> 20) &0x0ff)) { \ - /* NB: because WINDOW_REGISTER_P(cfp) is false, a saved cfp \ - in this frame is only visible in this frame's callers. \ - That means the cfp we mark saved is my caller's cfp, ie pr13. \ - I don't understand why we don't have to do that for pc, too. */ \ - \ - (frame_saved_regs).regs[CFP_REGNUM] = FRAME_FP(fi_p)+(13*4); \ - \ - (frame_saved_regs).regs[SP_REGNUM] = \ - read_memory_integer (FRAME_FP(fi_p)+((13+32)*4),4); \ - } \ - \ -/* \ - *(frame_saved_regs).regs[CFP_REGNUM] = (frame_saved_regs).regs[61]; \ - * (frame_saved_regs).regs[SP_REGNUM] = \ - * read_memory_integer (FRAME_FP(fi_p)+((13+32)*4),4); \ - */ \ - \ - (frame_saved_regs).regs[CSP_REGNUM] = prev_cf_addr; \ -} - -/* Things needed for making the inferior call functions. */ - -/* These are all lies. These macro definitions are appropriate for a - SPARC. On a pyramid, pushing a dummy frame will - surely involve writing the control stack pointer, - then saving the pc. This requires a privileged instruction. - Maybe one day Pyramid can be persuaded to add a syscall to do this. - Until then, we are out of luck. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM);\ - register int regnum; \ - sp = push_word (sp, 0); /* arglist */ \ - for (regnum = 11; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ -/* sp = push_word (sp, read_register (AP_REGNUM));*/ \ - sp = push_word (sp, (read_register (PS_REGNUM) & 0xffef) \ - + 0x2fff0000); \ - sp = push_word (sp, 0); \ - write_register (SP_REGNUM, sp); \ - write_register (FP_REGNUM, sp); \ -/* write_register (AP_REGNUM, sp + 17 * sizeof (int));*/ } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register CORE_ADDR fp = read_register (FP_REGNUM); \ - register int regnum; \ - register int regmask = read_memory_integer (fp + 4, 4); \ - write_register (PS_REGNUM, \ - (regmask & 0xffff) \ - | (read_register (PS_REGNUM) & 0xffff0000)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 16, 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp + 12, 4)); \ -/* write_register (AP_REGNUM, read_memory_integer (fp + 8, 4));*/ \ - fp += 16; \ - for (regnum = 0; regnum < 12; regnum++) \ - if (regmask & (0x10000 << regnum)) \ - write_register (regnum, read_memory_integer (fp += 4, 4)); \ - fp = fp + 4 + ((regmask >> 30) & 3); \ - if (regmask & 0x20000000) \ - { regnum = read_memory_integer (fp, 4); \ - fp += (regnum + 1) * 4; } \ - write_register (SP_REGNUM, fp); \ - set_current_frame (read_register (FP_REGNUM)); } - -/* This sequence of words is the instructions - calls #69, @#32323232 - bpt - Note this is 8 bytes. */ - -#define CALL_DUMMY {0x329f69fb, 0x03323232} - -#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *((char *) dummyname + 1) = nargs; \ - *(int *)((char *) dummyname + 3) = fun; } - -/* Interface definitions for kernel debugger KDB. */ - -/* I have *no idea* how to debug OSx kernels, so this - is flushed, possible forever. */ diff --git a/gnu/usr.bin/gdb/config/m-sparc.h b/gnu/usr.bin/gdb/config/m-sparc.h deleted file mode 100644 index 0964473235cd..000000000000 --- a/gnu/usr.bin/gdb/config/m-sparc.h +++ /dev/null @@ -1,501 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - * - * from: @(#)m-sparc.h 6.4 (Berkeley) 5/8/91 - * $Id: m-sparc.h,v 1.2 1993/08/01 18:48:34 mycroft Exp $ - */ - -/* Parameters for execution on a Sun 4, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@mcc.com) -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef sun4 -#define sun4 -#endif - -/* Define the bit, byte, and word ordering of the machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* Floating point is IEEE compatible. */ -#define IEEE_FLOAT - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* When passing a structure to a function, Sun cc passes the address - in a register, not the structure itself. It (under SunOS4) creates - two symbols, so we get a LOC_ARG saying the address is on the stack - (a lie, and a serious one since we don't know which register to - use), and a LOC_REGISTER saying that the struct is in a register - (sort of a lie, but fixable with REG_STRUCT_HAS_ADDR). - - This still doesn't work if the argument is not one passed in a - register (i.e. it's the 7th or later argument). */ -#define REG_STRUCT_HAS_ADDR(gcc_p) (!gcc_p) -#define STRUCT_ARG_SYM_GARBAGE(gcc_p) (!gcc_p) - -/* If Pcc says that a parameter is a short, it's a short. This is - because the parameter does get passed in in a register as an int, - but pcc puts it onto the stack frame as a short (not nailing - whatever else might be there. I'm not sure that I consider this - swift. Sigh.) - - No, don't do this. The problem here is that pcc says that the - argument is in the upper half of the word reserved on the stack, - but puts it in the lower half. */ -/* #define BELIEVE_PCC_PROMOTION 1 */ -/* OK, I've added code to dbxread.c to deal with this case. */ -#define BELIEVE_PCC_PROMOTION_TYPE - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ - { pc = skip_prologue (pc); } - -/* Immediately after a function call, return the saved pc. - Can't go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -/* On the Sun 4 under SunOS, the compile will leave a fake insn which - encodes the structure size being returned. If we detect such - a fake insn, step past it. */ - -#define PC_ADJUST(pc) ((read_memory_integer (pc + 8, 4) & 0xfffffe00) == 0 ? \ - pc+12 : pc+8) - -#define SAVED_PC_AFTER_CALL(frame) PC_ADJUST (read_register (RP_REGNUM)) - -/* Address of end of stack space. */ -#include -#include -#define STACK_END_ADDR USRSTACK - -#define INNER_THAN < - -/* Stack has strict alignment. */ - -#define STACK_ALIGN(ADDR) (((ADDR)+7)&-8) - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x91, 0xd0, 0x20, 0x01} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. */ -/* For SPARC, this is either a "jmpl %o7+8,%g0" or "jmpl %i7+8,%g0". - - Note: this does not work for functions returning structures under SunOS. */ -#define ABOUT_TO_RETURN(pc) \ - ((read_memory_integer (pc, 4)|0x00040000) == 0x81c7e008) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 72 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ -{ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \ - "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7", \ - "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", \ - "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7", \ - \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ - "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ - "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \ - "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \ - \ - "y", "psr", "wim", "tbr", "pc", "npc", "fpsr", "cpsr" }; - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP_REGNUM 30 /* Contains address of executing stack frame */ -#define RP_REGNUM 15 /* Contains return address value, *before* \ - any windows get switched. */ -#define SP_REGNUM 14 /* Contains address of top of stack, \ - which is also the bottom of the frame. */ -#define Y_REGNUM 64 /* Temp register for multiplication, etc. */ -#define PS_REGNUM 65 /* Contains processor status */ -#define PC_REGNUM 68 /* Contains program counter */ -#define NPC_REGNUM 69 /* Contains next PC */ -#define FP0_REGNUM 32 /* Floating point register 0 */ -#define FPS_REGNUM 70 /* Floating point status register */ -#define CPS_REGNUM 71 /* Coprocessor status register */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (32*4+32*4+8*4) - -/* Index within `registers' of the first byte of the space for - register N. */ -/* ?? */ -#define REGISTER_BYTE(N) ((N)*4) - -/* The SPARC processor has register windows. */ - -#define HAVE_REGISTER_WINDOWS - -/* Is this register part of the register window system? A yes answer - implies that 1) The name of this register will not be the same in - other frames, and 2) This register is automatically "saved" (out - registers shifting into ins counts) upon subroutine calls and thus - there is no need to search more than one stack frame for it. */ - -#define REGISTER_IN_WINDOW_P(regnum) \ - ((regnum) >= 8 && (regnum) < 32) - -/* Number of bytes of storage in the actual machine representation - for register N. */ - -/* On the SPARC, all regs are 4 bytes. */ - -#define REGISTER_RAW_SIZE(N) (4) - -/* Number of bytes of storage in the program's representation - for register N. */ - -/* On the SPARC, all regs are 4 bytes. */ - -#define REGISTER_VIRTUAL_SIZE(N) (4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 8 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 8 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ bcopy ((FROM), (TO), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ bcopy ((FROM), (TO), 4); } - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - ((N) < 32 ? builtin_type_int : (N) < 64 ? builtin_type_float : \ - builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_memory ((SP)+(16*4), &(ADDR), 4); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - { \ - if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ - { \ - bcopy (((int *)(REGBUF))+FP0_REGNUM, \ - (VALBUF), TYPE_LENGTH(TYPE)); \ - } \ - else \ - bcopy ((char *)((int *)(REGBUF) + 8) + \ - (TYPE_LENGTH (TYPE) < 4 ? 4 - TYPE_LENGTH (TYPE) : 0), \ - VALBUF, TYPE_LENGTH (TYPE)); \ - } - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ -/* On sparc, values are returned in register %o0. */ -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - { \ - if (TYPE_CODE (TYPE) = TYPE_CODE_FLT) \ - /* Floating-point values are returned in the register pair */ \ - /* formed by %f0 and %f1 (doubles are, anyway). */ \ - write_register_bytes (REGISTER_BYTE (FP0_REGNUM), (VALBUF), \ - TYPE_LENGTH (TYPE)); \ - else \ - /* Other values are returned in register %o0. */ \ - write_register_bytes (REGISTER_BYTE (8), VALBUF, TYPE_LENGTH (TYPE)); \ - } - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \ - (read_memory_integer (((int *)(REGBUF))[SP_REGNUM]+(16*4), 4)) - -/* Enable use of alternate code to read and write registers. */ - -#define NEW_SUN_PTRACE - -/* Enable use of alternate code for Sun's format of core dump file. */ - -#define NEW_SUN_CORE - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ -#include - -#define GET_RWINDOW_REG(FRAME, REG) \ - (read_memory_integer (&((struct rwindow *)FRAME)->REG, 4)) - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the Sun 4, the frame-chain's nominal address - is held in the frame pointer register. - - On the Sun4, the frame (in %fp) is %sp for the previous frame. - From the previous frame's %sp, we can find the previous frame's - %fp: it is in the save area just above the previous frame's %sp. - - If we are setting up an arbitrary frame, we'll need to know where - it ends. Hence the following. This part of the frame cache - structure should be checked before it is assumed that this frame's - bottom is in the stack pointer. - - If there isn't a frame below this one, the bottom of this frame is - in the stack pointer. - - If there is a frame below this one, and the frame pointers are - identical, it's a leaf frame and the bottoms are the same also. - - Otherwise the bottom of this frame is the top of the next frame. */ - -#define EXTRA_FRAME_INFO FRAME_ADDR bottom; -#define INIT_EXTRA_FRAME_INFO(fci) \ - (fci)->bottom = \ - ((fci)->next ? \ - ((fci)->frame == (fci)->next_frame ? \ - (fci)->next->bottom : (fci)->next->frame) : \ - read_register (SP_REGNUM)); - - -#ifdef KERNELDEBUG -extern int kernel_debugging; -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && \ - kernel_debugging ? inside_kernstack(chain) : \ - outside_startup_file(FRAME_SAVED_PC(thisframe))) -#else -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) -#endif - -#define FRAME_CHAIN(thisframe) \ - GET_RWINDOW_REG ((thisframe)->frame, rw_in[6]) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -/* Where is the PC for a specific frame */ - -#define FRAME_SAVED_PC(FRAME) frame_saved_pc (FRAME) - -/* If the argument is on the stack, it will be here. */ -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_STRUCT_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can't tell how many args there are - now that the C compiler delays popping them. */ -extern int default_function_nargs; -#define FRAME_NUM_ARGS(val,fi) (val = default_function_nargs) - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 68 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. - - Note that on register window machines, we are currently making the - assumption that window registers are being saved somewhere in the - frame in which they are being used. If they are stored in an - inferior frame, find_saved_register will break. - - On the Sun 4, the only time all registers are saved is when - a dummy frame is involved. Otherwise, the only saved registers - are the LOCAL and IN registers which are saved as a result - of the "save/restore" opcodes. This condition is determined - by address rather than by value. */ - -#define FRAME_FIND_SAVED_REGS(fi, frame_saved_regs) \ - frame_find_saved_regs(fi, &(frame_saved_regs)) - -/* Discard from the stack the innermost frame, - restoring all saved registers. - Note that the values stored in fsr by get_frame_saved_regs are *in - the context of the inferior frame*. What this means is that the i - regs of fsr must be restored into the o regs of the frame popped - into. We don't care about the output regs of the inferior frame. - - This is true for dummy frames. Is it true for normal frames? It - really does appear so. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register CORE_ADDR pc; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - char raw_buffer[REGISTER_BYTES]; \ - void do_restore_insn (); \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - pc = read_memory_integer (fsr.regs[PC_REGNUM], 4); \ - do_restore_insn (PC_ADJUST (pc)); \ - if (fsr.regs[FP0_REGNUM]) \ - { \ - read_memory (fsr.regs[FP0_REGNUM], raw_buffer, 32 * 4); \ - write_register_bytes (REGISTER_BYTE (FP0_REGNUM), raw_buffer, 32 * 4); \ - } \ - if (fsr.regs[1]) \ - { \ - read_memory (fsr.regs[1], raw_buffer, 7 * 4); \ - write_register_bytes (REGISTER_BYTE (1), raw_buffer, 7 * 4); \ - } \ - if (fsr.regs[24]) \ - { \ - read_memory (fsr.regs[24], raw_buffer, 8 * 4); \ - write_register_bytes (REGISTER_BYTE (8), raw_buffer, 8 * 4); \ - } \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - if (fsr.regs[Y_REGNUM]) \ - write_register (Y_REGNUM, read_memory_integer (fsr.regs[Y_REGNUM], 4)); \ - if (fsr.regs[NPC_REGNUM]) \ - write_register (NPC_REGNUM, read_memory_integer (fsr.regs[NPC_REGNUM], 4)); \ - flush_cached_frames (); \ - set_current_frame ( create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); } - -#define NEW_CALL_FUNCTION - - -/* Sparc has no reliable single step ptrace call */ - -#define NO_SINGLE_STEP 1 - -/* It does have a wait structure, and it might help things out . . . */ - -#define HAVE_WAIT_STRUCT - -/* Handle a feature in the sun4 compiler ("call .stret4" at the end of - functions returning structures). */ - -#define SUN4_COMPILER_FEATURE - -/* We need two arguments (in general) to the "info frame" command. - Note that the definition of this macro implies that there exists a - function "setup_arbitrary_frame" in mach-dep.c */ - -#define FRAME_SPECIFICATION_DYADIC - -/* KDB stuff flushed for now. */ - -#define NAMELESS_ARG(fi, n) GET_RWINDOW_REG((fi)->bottom, rw_in[n]) - diff --git a/gnu/usr.bin/gdb/config/m-sun2.h b/gnu/usr.bin/gdb/config/m-sun2.h deleted file mode 100644 index d5005e423d61..000000000000 --- a/gnu/usr.bin/gdb/config/m-sun2.h +++ /dev/null @@ -1,465 +0,0 @@ -/* Parameters for execution on a Sun, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-sun2.h,v 1.2 1993/08/02 17:40:05 mycroft Exp $ -*/ - -#ifndef sun2 -#define sun2 -#endif - -/* Define the bit, byte, and word ordering of the machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = read_memory_integer (pc, 2); \ - if (op == 0047126) \ - pc += 4; /* Skip link #word */ \ - else if (op == 0044016) \ - pc += 6; /* Skip link #long */ \ -} - -/* Immediately after a function call, return the saved pc. - Can't go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ -read_memory_integer (read_register (SP_REGNUM), 4) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR 0x2800 - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0x1000000 - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x4e, 0x4f} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 2 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e75) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 18 - -/* Number that are really general registers */ - -#define NUM_GENERAL_REGS 16 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", "ps", "pc"} - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP_REGNUM 14 /* Contains address of executing stack frame */ -#define SP_REGNUM 15 /* Contains address of top of stack */ -#define PS_REGNUM 16 /* Contains processor status */ -#define PC_REGNUM 17 /* Contains program counter */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (16*4+8) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 68000, all regs are 4 bytes. */ - -#define REGISTER_RAW_SIZE(N) 4 - -/* Number of bytes of storage in the program's representation - for register N. On the 68000, all regs are 4 bytes. */ - -#define REGISTER_VIRTUAL_SIZE(N) 4 - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 4 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 4 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) bcopy ((FROM), (TO), 4); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) builtin_type_int - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (9, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* Enable use of alternate code to read and write registers. */ - -#define NEW_SUN_PTRACE - -/* Enable use of alternate code for Sun's format of core dump file. */ - -#define NEW_SUN_CORE - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* This is a piece of magic that is given a register number REGNO - and as BLOCKEND the address in the system of the end of the user structure - and stores in ADDR the address in the kernel or core dump - of that register. */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ addr = blockend + regno * 4; } - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the Sun, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can't tell how many args there are - now that the C compiler delays popping them. */ -#define FRAME_NUM_ARGS(val,fi) (val = -1) - -#if 0 -#define FRAME_NUM_ARGS(val, fi) \ -{ register CORE_ADDR pc = FRAME_SAVED_PC (fi); \ - register int insn = 0177777 & read_memory_integer (pc, 2); \ - val = 0; \ - if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \ - val = read_memory_integer (pc + 2, 2); \ - else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \ - || (insn & 0170777) == 0050117) /* addqw */ \ - { val = (insn >> 9) & 7; if (val == 0) val = 8; } \ - else if (insn == 0157774) /* addal #WW, sp */ \ - val = read_memory_integer (pc + 2, 4); \ - val >>= 2; } -#endif - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 4 \ - && (frame_info)->pc <= (frame_info)->frame) \ - { next_addr = (frame_info)->frame; \ - pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info)->pc); \ - /* Verify we have a link a6 instruction next; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ - if (044016 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ - else if (047126 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ - else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - regmask = read_memory_integer (pc + 2, 2); \ - if (0044327 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ - else if (0044347 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - else if (0x2f00 == 0xfff0 & read_memory_integer (pc, 2)) \ - { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (0x426742e7 == read_memory_integer (pc, 4)) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ -} - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM);\ - register int regnum; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame ( create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); } - -/* This sequence of words is the instructions - moveml 0xfffc,-(sp) - clrw -(sp) - movew ccr,-(sp) - /..* The arguments are pushed at this point by GDB; - no code is needed in the dummy for this. - The CALL_DUMMY_START_OFFSET gives the position of - the following jsr instruction. *../ - jsr @#32323232 - addl #69696969,sp - bpt - nop -Note this is 24 bytes. -We actually start executing at the jsr, since the pushing of the -registers is done by PUSH_DUMMY_FRAME. If this were real code, -the arguments for the function called by the jsr would be pushed -between the moveml and the jsr, and we could allow it to execute through. -But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done, -and we cannot allow the moveml to push the registers again lest they be -taken for the arguments. */ - -#define CALL_DUMMY {0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71} - -#define CALL_DUMMY_LENGTH 24 - -#define CALL_DUMMY_START_OFFSET 8 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *(int *)((char *) dummyname + 16) = nargs * 4; \ - *(int *)((char *) dummyname + 10) = fun; } - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } diff --git a/gnu/usr.bin/gdb/config/m-sun2os4.h b/gnu/usr.bin/gdb/config/m-sun2os4.h deleted file mode 100644 index e641795b1c17..000000000000 --- a/gnu/usr.bin/gdb/config/m-sun2os4.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Macro definitions for a sun 2 running os 4. - Copyright (C) 1989, Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-sun2os4.h,v 1.2 1993/08/02 17:40:06 mycroft Exp $ -*/ - -#include "m-sun2.h" -#define SUNOS4 diff --git a/gnu/usr.bin/gdb/config/m-sun3.h b/gnu/usr.bin/gdb/config/m-sun3.h deleted file mode 100644 index 9fdca6ef15ff..000000000000 --- a/gnu/usr.bin/gdb/config/m-sun3.h +++ /dev/null @@ -1,519 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - * - * from: @(#)m-sun3.h 6.3 (Berkeley) 5/8/91 - * $Id: m-sun3.h,v 1.2 1993/08/01 18:48:31 mycroft Exp $ - */ - -/* Parameters for execution on a Sun, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef sun3 -#define sun3 -#endif - -/* Define the bit, byte, and word ordering of the machine. */ -#define BITS_BIG_ENDIAN -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = read_memory_integer (pc, 2); \ - if (op == 0047126) \ - pc += 4; /* Skip link #word */ \ - else if (op == 0044016) \ - pc += 6; /* Skip link #long */ \ -} - -/* Immediately after a function call, return the saved pc. - Can't go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ -read_memory_integer (read_register (SP_REGNUM), 4) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0xf000000 - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x4e, 0x4f} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 2 - -/* Nonzero if instruction at PC is a return instruction. */ -/* Allow any of the return instructions, including a trapv and a return - from interupt. */ - -#define ABOUT_TO_RETURN(pc) ((read_memory_integer (pc, 2) & ~0x3) == 0x4e74) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 31 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ - {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \ - "ps", "pc", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fpcontrol", "fpstatus", "fpiaddr", "fpcode", "fpflags" } - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP_REGNUM 14 /* Contains address of executing stack frame */ -#define SP_REGNUM 15 /* Contains address of top of stack */ -#define PS_REGNUM 16 /* Contains processor status */ -#define PC_REGNUM 17 /* Contains program counter */ -#define FP0_REGNUM 18 /* Floating point register 0 */ -#define FPC_REGNUM 26 /* 68881 control register */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (16*4+8*12+8+20) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) \ - ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \ - : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \ - : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 12 bytes. */ -/* Note that the unsigned cast here forces the result of the - subtractiion to very high positive values if N < FP0_REGNUM */ - -#define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 8-byte doubles. */ - -#define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 12 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 8 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_from_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - convert_to_68881 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (9, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy ((char *)(REGBUF) + \ - (TYPE_LENGTH (TYPE) < 4 ? 4 - TYPE_LENGTH (TYPE) : 0), \ - VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* Enable use of alternate code to read and write registers. */ - -#define NEW_SUN_PTRACE - -/* Enable use of alternate code for Sun's format of core dump file. */ - -#define NEW_SUN_CORE - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the Sun, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can't tell how many args there are - now that the C compiler delays popping them. */ -#define FRAME_NUM_ARGS(val,fi) (val = -1) - -#if 0 -#define FRAME_NUM_ARGS(val, fi) \ -{ register CORE_ADDR pc = FRAME_SAVED_PC (fi); \ - register int insn = 0177777 & read_memory_integer (pc, 2); \ - val = 0; \ - if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \ - val = read_memory_integer (pc + 2, 2); \ - else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \ - || (insn & 0170777) == 0050117) /* addqw */ \ - { val = (insn >> 9) & 7; if (val == 0) val = 8; } \ - else if (insn == 0157774) /* addal #WW, sp */ \ - val = read_memory_integer (pc + 2, 4); \ - val >>= 2; } -#endif - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - int nextinsn; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ - && (frame_info)->pc <= (frame_info)->frame) \ - { next_addr = (frame_info)->frame; \ - pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info)->pc); \ - /* Verify we have a link a6 instruction next; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ - if (044016 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ - else if (047126 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ - else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - regmask = read_memory_integer (pc + 2, 2); \ - /* But before that can come an fmovem. Check for it. */ \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf227 == nextinsn \ - && (regmask & 0xff00) == 0xe000) \ - { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 12); \ - regmask = read_memory_integer (pc + 2, 2); } \ - if (0044327 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ - else if (0044347 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - else if (0x2f00 == (0xfff0 & read_memory_integer (pc, 2))) \ - { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* fmovemx to index of sp may follow. */ \ - regmask = read_memory_integer (pc + 2, 2); \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf236 == nextinsn \ - && (regmask & 0xff00) == 0xf000) \ - { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \ - regmask = read_memory_integer (pc + 2, 2); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (0x426742e7 == read_memory_integer (pc, 4)) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ -} - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ - char raw_buffer[12]; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - { read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); \ - sp = push_bytes (sp, raw_buffer, 12); } \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - char raw_buffer[12]; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ - if (fsr.regs[regnum]) \ - { read_memory (fsr.regs[regnum], raw_buffer, 12); \ - write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); }\ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); } - -/* This sequence of words is the instructions - fmovem 0xff,-(sp) - moveml 0xfffc,-(sp) - clrw -(sp) - movew ccr,-(sp) - /..* The arguments are pushed at this point by GDB; - no code is needed in the dummy for this. - The CALL_DUMMY_START_OFFSET gives the position of - the following jsr instruction. *../ - jsr @#32323232 - addl #69696969,sp - trap #15 - nop -Note this is 28 bytes. -We actually start executing at the jsr, since the pushing of the -registers is done by PUSH_DUMMY_FRAME. If this were real code, -the arguments for the function called by the jsr would be pushed -between the moveml and the jsr, and we could allow it to execute through. -But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done, -and we cannot allow the moveml to push the registers again lest they be -taken for the arguments. */ - -#define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71} - -#define CALL_DUMMY_LENGTH 28 - -#define CALL_DUMMY_START_OFFSET 12 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *(int *)((char *) dummyname + 20) = nargs * 4; \ - *(int *)((char *) dummyname + 14) = fun; } - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel #end, sp"); \ - asm ("movel #0,a6"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel a6,sp@-"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl sp@,a6"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea sp@(10)"); \ - asm ("movem #0xfffe,sp@-"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil #8,sp@(28)"); \ - asm ("movem sp@,#0xffff"); \ - asm ("rte"); } diff --git a/gnu/usr.bin/gdb/config/m-sun3os4.h b/gnu/usr.bin/gdb/config/m-sun3os4.h deleted file mode 100644 index 0a1726b5e4e0..000000000000 --- a/gnu/usr.bin/gdb/config/m-sun3os4.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Macro definitions for a sun 3 running os 4. - Copyright (C) 1989, Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-sun3os4.h,v 1.2 1993/08/02 17:40:07 mycroft Exp $ -*/ - -#include "m-sun3.h" -#define SUNOS4 -#define FPU - -/* There is a bug which can cause alloca to fail to allocate large - areas of memory one time in every 4096 (we think). */ -/* chase@orc.olivetti.com says that 4 megabyte alloca's consistently fail, - even though the stack limit (SET_STACK_LIMIT_HUGE) has been set - to 250 megabytes. */ -#define BROKEN_LARGE_ALLOCA diff --git a/gnu/usr.bin/gdb/config/m-sun4os4.h b/gnu/usr.bin/gdb/config/m-sun4os4.h deleted file mode 100644 index d1579fce5b4a..000000000000 --- a/gnu/usr.bin/gdb/config/m-sun4os4.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Macro definitions for running gdb on a Sun 4 running sunos 4. - Copyright (C) 1989, Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-sun4os4.h,v 1.2 1993/08/02 17:40:08 mycroft Exp $ -*/ - -#include "m-sparc.h" -#undef STACK_END_ADDRESS -#define STACK_END_ADDRESS 0xf8000000 -#define SUNOS4 -#define FPU diff --git a/gnu/usr.bin/gdb/config/m-symmetry.h b/gnu/usr.bin/gdb/config/m-symmetry.h deleted file mode 100644 index 880416102cfe..000000000000 --- a/gnu/usr.bin/gdb/config/m-symmetry.h +++ /dev/null @@ -1,617 +0,0 @@ -/* Definitions to make GDB run on a Sequent Symmetry under dynix 3.0, - with Weitek 1167 and i387 support. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-symmetry.h,v 1.2 1993/08/02 17:40:08 mycroft Exp $ -*/ - -/* Symmetry version by Jay Vosburgh (uunet!sequent!fubar) */ - -#include - -#define SYMMETRY - -/* This machine doesn't have the siginterrupt call. */ -#define NO_SIGINTERRUPT - -#define HAVE_WAIT_STRUCT - -/* Define the bit, byte, and word ordering of the machine. */ -/* #define BITS_BIG_ENDIAN */ -/* #define BYTES_BIG_ENDIAN */ -/* #define WORDS_BIG_ENDIAN */ - -/* Define SFILE_FN_FLAGGED if the source file is flagged with an N_FN - symbol instead of an N_TEXT symbol. */ - -#define OFILE_FN_FLAGGED - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. From m-i386.h */ - -#define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));} - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ - read_memory_integer(read_register(SP_REGNUM), 4) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG)) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0x40000000 - (UPAGES * NBPG)) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xcc} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. */ -/* For Symmetry, this is really the 'leave' instruction, which */ -/* is right before the ret */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9) - -/* Return 1 if P points to an invalid floating point value. -*/ - -#define INVALID_FLOAT(p, len) (0) - -/* code for 80387 fpu. Functions are from i386-dep.c, copied into - * symm-dep.c. - */ -#define FLOAT_INFO { i386_float_info(); } - -/* largest int type */ -#define LONGEST long - -#define BUILTIN_TYPE_LONGEST builtin_type_long - - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ -#define NUM_REGS 49 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -/* Symmetry registers are in this weird order to match the register - numbers in the symbol table entries. If you change the order, - things will probably break mysteriously for no apparent reason. - Also note that the st(0)...st(7) 387 registers are represented as - st0...st7. */ - -#define REGISTER_NAMES { "eax", "edx", "ecx", "st0", "st1", \ - "ebx", "esi", "edi", "st2", "st3", \ - "st4", "st5", "st6", "st7", "esp", \ - "ebp", "eip", "eflags", "fp1", "fp2", \ - "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fp8", "fp9", "fp10", "fp11", "fp12", \ - "fp13", "fp14", "fp15", "fp16", "fp17", \ - "fp18", "fp19", "fp20", "fp21", "fp22", \ - "fp23", "fp24", "fp25", "fp26", "fp27", \ - "fp28", "fp29", "fp30", "fp31" } - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP1_REGNUM 18 /* first 1167 register */ -#define SP_REGNUM 14 /* Contains address of top of stack */ -#define FP_REGNUM 15 /* Contains address of executing stack frame */ -#define PC_REGNUM 16 /* Contains program counter */ -#define PS_REGNUM 17 /* Contains processor status */ - -/* The magic numbers below are offsets into u_ar0 in the user struct. - * They live in . Gdb calls this macro with blockend - * holding u.u_ar0 - KERNEL_U_ADDR. Only the registers listed are - * saved in the u area (along with a few others that aren't useful - * here. See ). - */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ struct user foo; /* needed for finding fpu regs */ \ -switch (regno) { \ - case 0: \ - addr = blockend + EAX * sizeof(int); break; \ - case 1: \ - addr = blockend + EDX * sizeof(int); break; \ - case 2: \ - addr = blockend + ECX * sizeof(int); break; \ - case 3: /* st(0) */ \ - addr = blockend - \ - ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \ - break; \ - case 4: /* st(1) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \ - break; \ - case 5: \ - addr = blockend + EBX * sizeof(int); break; \ - case 6: \ - addr = blockend + ESI * sizeof(int); break; \ - case 7: \ - addr = blockend + EDI * sizeof(int); break; \ - case 8: /* st(2) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \ - break; \ - case 9: /* st(3) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \ - break; \ - case 10: /* st(4) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \ - break; \ - case 11: /* st(5) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \ - break; \ - case 12: /* st(6) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \ - break; \ - case 13: /* st(7) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \ - break; \ - case 14: \ - addr = blockend + ESP * sizeof(int); break; \ - case 15: \ - addr = blockend + EBP * sizeof(int); break; \ - case 16: \ - addr = blockend + EIP * sizeof(int); break; \ - case 17: \ - addr = blockend + FLAGS * sizeof(int); break; \ - case 18: /* fp1 */ \ - case 19: /* fp2 */ \ - case 20: /* fp3 */ \ - case 21: /* fp4 */ \ - case 22: /* fp5 */ \ - case 23: /* fp6 */ \ - case 24: /* fp7 */ \ - case 25: /* fp8 */ \ - case 26: /* fp9 */ \ - case 27: /* fp10 */ \ - case 28: /* fp11 */ \ - case 29: /* fp12 */ \ - case 30: /* fp13 */ \ - case 31: /* fp14 */ \ - case 32: /* fp15 */ \ - case 33: /* fp16 */ \ - case 34: /* fp17 */ \ - case 35: /* fp18 */ \ - case 36: /* fp19 */ \ - case 37: /* fp20 */ \ - case 38: /* fp21 */ \ - case 39: /* fp22 */ \ - case 40: /* fp23 */ \ - case 41: /* fp24 */ \ - case 42: /* fp25 */ \ - case 43: /* fp26 */ \ - case 44: /* fp27 */ \ - case 45: /* fp28 */ \ - case 46: /* fp29 */ \ - case 47: /* fp30 */ \ - case 48: /* fp31 */ \ - addr = blockend - \ - ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \ - } \ -} - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -/* 10 i386 registers, 8 i387 registers, and 31 Weitek 1167 registers */ -#define REGISTER_BYTES ((10 * 4) + (8 * 10) + (31 * 4)) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) \ -((N < 3) ? (N * 4) : \ -(N < 5) ? (((N - 2) * 10) + 2) : \ -(N < 8) ? (((N - 5) * 4) + 32) : \ -(N < 14) ? (((N - 8) * 10) + 44) : \ - (((N - 14) * 4) + 104)) - -/* Number of bytes of storage in the actual machine representation - * for register N. All registers are 4 bytes, except 387 st(0) - st(7), - * which are 80 bits each. - */ - -#define REGISTER_RAW_SIZE(N) \ -((N < 3) ? 4 : \ -(N < 5) ? 10 : \ -(N < 8) ? 4 : \ -(N < 14) ? 10 : \ - 4) - -/* Number of bytes of storage in the program's representation - for register N. On the vax, all regs are 4 bytes. */ - -#define REGISTER_VIRTUAL_SIZE(N) 4 - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 10 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 4 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) \ -((N < 3) ? 0 : \ -(N < 5) ? 1 : \ -(N < 8) ? 0 : \ -(N < 14) ? 1 : \ - 0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \ -(REGNUM < 5) ? i387_to_double((FROM), (TO)) : \ -(REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \ -(REGNUM < 14) ? i387_to_double((FROM), (TO)) : \ - bcopy ((FROM), (TO), 4)) - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \ -(REGNUM < 5) ? double_to_i387((FROM), (TO)) : \ -(REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \ -(REGNUM < 14) ? double_to_i387((FROM), (TO)) : \ - bcopy ((FROM), (TO), 4)) - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ -((N < 3) ? builtin_type_int : \ -(N < 5) ? builtin_type_double : \ -(N < 8) ? builtin_type_int : \ -(N < 14) ? builtin_type_double : \ - builtin_type_int) - -/* from m-i386.h */ -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { (SP) -= sizeof (ADDR); \ - write_memory ((SP), &(ADDR), sizeof (ADDR)); \ - write_register(0, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - symmetry_extract_return_value(TYPE, REGBUF, VALBUF) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* Compensate for lack of `vprintf' function. */ -#ifndef HAVE_VPRINTF -#define vprintf(format, ap) _doprnt (format, ap, stdout) -#endif /* not HAVE_VPRINTF */ - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* On Symmetry, %ebp points to caller's %ebp, and the return address - is right on top of that. -*/ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) - -#define FRAME_SAVED_PC(fi) (read_memory_integer((fi)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. - - The weirdness in the "addl $imm8" case is due to gcc sometimes - issuing "addl $-int" after function call returns; this would - produce ridiculously huge arg counts. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ \ - int op = read_memory_integer(FRAME_SAVED_PC((fi)), 4); \ - int narg; \ - if ((op & 0xff) == 0x59) /* 0x59 'popl %ecx' */ \ - { \ - numargs = 1; \ - } \ - else if ((op & 0xffff) == 0xc483) /* 0xc483 'addl $imm8' */ \ - { \ - narg = ((op >> 16) & 0xff); \ - numargs = (narg >= 128) ? -1 : narg / 4; \ - } \ - else if ((op & 0xffff) == 0xc481) /* 0xc481 'addl $imm32' */ \ - { \ - narg = read_memory_integer(FRAME_SAVED_PC((fi))+2,4); \ - numargs = (narg < 0) ? -1 : narg / 4; \ - } \ - else \ - { \ - numargs = -1; \ - } \ -} - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); } - - -/* Things needed for making the inferior call functions. */ - -#define PUSH_DUMMY_FRAME \ -{ CORE_ADDR sp = read_register (SP_REGNUM); \ - int regnum; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = 0; regnum < NUM_REGS; regnum++) \ - sp = push_word (sp, read_register (regnum)); \ - write_register (SP_REGNUM, sp); \ -} - -#define POP_FRAME \ -{ \ - FRAME frame = get_current_frame (); \ - CORE_ADDR fp; \ - int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = 0; regnum < NUM_REGS; regnum++) { \ - CORE_ADDR adr; \ - adr = fsr.regs[regnum]; \ - if (adr) \ - write_register (regnum, read_memory_integer (adr, 4)); \ - } \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame ( create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); \ -} - -/* from i386-dep.c, worked better than my original... */ -/* This sequence of words is the instructions - * call (32-bit offset) - * int 3 - * This is 6 bytes. - */ - -#define CALL_DUMMY { 0x223344e8, 0xcc11 } - -#define CALL_DUMMY_LENGTH 8 - -#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ \ - int from, to, delta, loc; \ - loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \ - from = loc + 5; \ - to = (int)(fun); \ - delta = to - from; \ - *(int *)((char *)(dummyname) + 1) = delta; \ -} - -/* Interface definitions for kernel debugger KDB. */ -/* This doesn't work... */ -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ - 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, %esp"); \ - asm ("movl %ebp, $0"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("pushl %ebp"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (%esp), %ebp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm("pushad"); } -/* -{ asm("pushl %eax"); \ - asm("pushl %edx"); \ - asm("pushl %ecx"); \ - asm("pushl %st(0)"); \ - asm("pushl %st(1)"); \ - asm("pushl %ebx"); \ - asm("pushl %esi"); \ - asm("pushl %edi"); \ - asm("pushl %st(2)"); \ - asm("pushl %st(3)"); \ - asm("pushl %st(4)"); \ - asm("pushl %st(5)"); \ - asm("pushl %st(6)"); \ - asm("pushl %st(7)"); \ - asm("pushl %esp"); \ - asm("pushl %ebp"); \ - asm("pushl %eip"); \ - asm("pushl %eflags"); \ - asm("pushl %fp1"); \ - asm("pushl %fp2"); \ - asm("pushl %fp3"); \ - asm("pushl %fp4"); \ - asm("pushl %fp5"); \ - asm("pushl %fp6"); \ - asm("pushl %fp7"); \ - asm("pushl %fp8"); \ - asm("pushl %fp9"); \ - asm("pushl %fp10"); \ - asm("pushl %fp11"); \ - asm("pushl %fp12"); \ - asm("pushl %fp13"); \ - asm("pushl %fp14"); \ - asm("pushl %fp15"); \ - asm("pushl %fp16"); \ - asm("pushl %fp17"); \ - asm("pushl %fp18"); \ - asm("pushl %fp19"); \ - asm("pushl %fp20"); \ - asm("pushl %fp21"); \ - asm("pushl %fp22"); \ - asm("pushl %fp23"); \ - asm("pushl %fp24"); \ - asm("pushl %fp25"); \ - asm("pushl %fp26"); \ - asm("pushl %fp27"); \ - asm("pushl %fp28"); \ - asm("pushl %fp29"); \ - asm("pushl %fp30"); \ - asm("pushl %fp31"); \ -} -*/ -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("popad"); } diff --git a/gnu/usr.bin/gdb/config/m-tahoe.h b/gnu/usr.bin/gdb/config/m-tahoe.h deleted file mode 100644 index e8b7c1a67164..000000000000 --- a/gnu/usr.bin/gdb/config/m-tahoe.h +++ /dev/null @@ -1,477 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * - * from: @(#)m-tahoe.h 6.4 (Berkeley) 5/8/91 - * $Id: m-tahoe.h,v 1.2 1993/08/01 18:48:29 mycroft Exp $ - */ - -/* - * Ported by the State University of New York at Buffalo by the Distributed - * Computer Systems Lab, Department of Computer Science, 1991. - */ - -/* - * These first two are kludges to get this thing to compile under Reno (or - * at least the Reno running on okeeffe). It seems there are a few problems - * with the include files. - */ - -/* - * Until gdb becomes POSIX-compatible... - */ -#define USE_OLD_TTY 1 - -/* - * That's all for the kludges. Now on to the port... - */ - -#ifndef tahoe -#define tahoe -#endif - -/* Define the bit, byte, and word ordering of the machine. */ - -/* #define BITS_BIG_ENDIAN */ -#define BYTES_BIG_ENDIAN -#define WORDS_BIG_ENDIAN - -/* Library stuff: POSIX tty (not supported yet), V7 tty (sigh), vprintf. */ - -#define HAVE_TERMIOS 1 -#define USE_OLD_TTY 1 -#define HAVE_VPRINTF 1 - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 2 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = (unsigned char) read_memory_integer (pc, 1); \ - if (op == 0x11) pc += 2; /* skip brb */ \ - if (op == 0x13) pc += 3; /* skip brw */ \ - if (op == 0x2c && \ - ((unsigned char) read_memory_integer (pc+2, 1)) == 0x5e) \ - pc += 3; /* skip subl2 */ \ - if (op == 0xe9 && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xae && \ - ((unsigned char) read_memory_integer(pc+3, 1)) == 0x5e) \ - pc += 4; /* skip movab */ \ - if (op == 0xe9 && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xce && \ - ((unsigned char) read_memory_integer(pc+4, 1)) == 0x5e) \ - pc += 5; /* skip movab */ \ - if (op == 0xe9 && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xee && \ - ((unsigned char) read_memory_integer(pc+6, 1)) == 0x5e) \ - pc += 7; /* skip movab */ \ -} - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) FRAME_SAVED_PC(frame) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0xc0000000 - (UPAGES * NBPG)) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0xc0000000 - (UPAGES * NBPG)) - -/* Same as offsetof macro from stddef.h (which 4.3BSD doesn't have). */ - -#define my_offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER) - -/* Under BSD, sigtramp is in the u area. Note that this definition - includes both the subroutine at u_pcb.pcb_sigc[3], and the - routine at u_pcb.pcb_sigc[0] (which does a calls to u_pcb.pcb_sigc[3]). - I think this is what we want. */ - -#define IN_SIGTRAMP(pc, name) \ - ((pc) >= KERNEL_U_ADDR + my_offsetof (struct user, u_pcb.pcb_sigc[0]) \ - && (pc) < KERNEL_U_ADDR + my_offsetof (struct user, u_pcb.pcb_sigc[5]) \ - ) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x30} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x40) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes -- not relevant on the Tahoe. */ - -#define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000) - -/* Largest integer type */ - -#define LONGEST long - - /* Name of the builtin type for the LONGEST type above. */ - -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 19 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "fp", "sp", "pc", "ps", "al", "ah"} - -#define FP_REGNUM 13 /* Contains address of executing stack frame */ -#define SP_REGNUM 14 /* Contains address of top of stack */ -#define PC_REGNUM 15 /* Contains program counter */ -#define PS_REGNUM 16 /* Contains processor status */ - -#define AL_REGNUM 17 /* Contains accumulator */ -#define AH_REGNUM 18 - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ addr = blockend - 100 + regno * 4; \ - if (regno == PC_REGNUM) addr = blockend - 8; \ - if (regno == PS_REGNUM) addr = blockend - 4; \ - if (regno == FP_REGNUM) addr = blockend - 40; \ - if (regno == SP_REGNUM) addr = blockend - 36; \ - if (regno == AL_REGNUM) addr = blockend - 20; \ - if (regno == AH_REGNUM) addr = blockend - 24;} - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ - -#define REGISTER_BYTES (19*4) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the tahoe, all regs are 4 bytes. */ - -#define REGISTER_RAW_SIZE(N) 4 - -/* Number of bytes of storage in the program's representation - for register N. On the tahoe, all regs are 4 bytes. */ - -#define REGISTER_VIRTUAL_SIZE(N) 4 - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 4 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 4 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) builtin_type_int - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (1, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* Compensate for lack of `vprintf' function. */ - -#ifndef HAVE_VPRINTF -#define vprintf(format, ap) _doprnt (format, ap, stdout) -#endif /* not HAVE_VPRINTF */ - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). - - FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the Tahoe, the frame's nominal address is the FP value, - and it points to the old FP */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* Saved PC */ - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame - 8, 4)) - -/* In most of GDB, getting the args address is too important to - just say "I don't know". */ - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -/* Address to use as an anchor for finding local variables */ - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ numargs = ((0xffff & read_memory_integer(((fi)->frame-4),4)) - 4) >> 2; } - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 4 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int rmask = read_memory_integer ((frame_info)->frame-4, 4) >> 16;\ - register CORE_ADDR next_addr; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - next_addr = (frame_info)->frame - 8; \ - for (regnum = 12; regnum >= 0; regnum--, rmask <<= 1) \ - (frame_saved_regs).regs[regnum] = (rmask & 0x1000) ? (next_addr -= 4) : 0;\ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame - 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ -} - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM); \ - register int regnum; \ -printf("PUSH_DUMMY_FRAME\n"); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - sp = push_word (sp, 0x1fff0004); /*SAVE MASK*/ \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - for (regnum = 12; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - write_register (SP_REGNUM, sp); \ -} - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register CORE_ADDR fp = read_register (FP_REGNUM); \ - register int regnum; \ - register int regmask = read_memory_integer (fp-4, 4); \ -printf("POP_FRAME\n"); \ - regmask >>= 16; \ - write_register (SP_REGNUM, fp+4); \ - write_register (PC_REGNUM, read_memory_integer(fp-8, 4)); \ - write_register (FP_REGNUM, read_memory_integer(fp, 4)); \ - fp -= 8; \ - for (regnum = 12; regnum >= 0; regnum--, regmask <<= 1) \ - if (regmask & 0x1000) \ - write_register (regnum, read_memory_integer (fp-=4, 4)); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); } - -/* This sequence of words is the instructions - calls #69, @#32323232 - bpt - Note this is 8 bytes. */ - -#define CALL_DUMMY {0xbf699f32, 0x32323230} - -/* Start execution at beginning of dummy */ - -#define CALL_DUMMY_START_OFFSET 0 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ int temp = (int) fun; \ - *((char *) dummyname + 1) = nargs; \ - bcopy(&temp,(char *)dummyname+3,4); } - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ - 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ - -#define PUSH_FRAME_PTR \ - asm ("pushl fp"); - -/* Copy the top-of-stack to the frame pointer register. */ - -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("pushl 8(sp)"); \ - asm ("pushl 8(sp)"); \ - asm ("pushal 0x41(sp)"); \ - asm ("pushl r0" ); \ - asm ("pushl r1" ); \ - asm ("pushl r2" ); \ - asm ("pushl r3" ); \ - asm ("pushl r4" ); \ - asm ("pushl r5" ); \ - asm ("pushl r6" ); \ - asm ("pushl r7" ); \ - asm ("pushl r8" ); \ - asm ("pushl r9" ); \ - asm ("pushl r10" ); \ - asm ("pushl r11" ); \ - asm ("pushl r12" ); \ - asm ("pushl fp" ); \ - asm ("pushl sp" ); \ - asm ("pushl pc" ); \ - asm ("pushl ps" ); \ - asm ("pushl aclo" ); \ - asm ("pushl achi" ); \ -} - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ \ - asm ("movl (sp)+, achi"); \ - asm ("movl (sp)+, aclo"); \ - asm ("movl (sp)+, ps"); \ - asm ("movl (sp)+, pc"); \ - asm ("movl (sp)+, sp"); \ - asm ("movl (sp)+, fp"); \ - asm ("movl (sp)+, r12"); \ - asm ("movl (sp)+, r11"); \ - asm ("movl (sp)+, r10"); \ - asm ("movl (sp)+, r9"); \ - asm ("movl (sp)+, r8"); \ - asm ("movl (sp)+, r7"); \ - asm ("movl (sp)+, r6"); \ - asm ("movl (sp)+, r5"); \ - asm ("movl (sp)+, r4"); \ - asm ("movl (sp)+, r3"); \ - asm ("movl (sp)+, r2"); \ - asm ("movl (sp)+, r1"); \ - asm ("movl (sp)+, r0"); \ - asm ("subl2 $8,(sp)"); \ - asm ("movl (sp),sp"); \ - asm ("rei"); } diff --git a/gnu/usr.bin/gdb/config/m-umax.h b/gnu/usr.bin/gdb/config/m-umax.h deleted file mode 100644 index aca92082adb0..000000000000 --- a/gnu/usr.bin/gdb/config/m-umax.h +++ /dev/null @@ -1,469 +0,0 @@ -/* Definitions to make GDB run on an encore under umax 4.2 - Copyright (C) 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-umax.h,v 1.2 1993/08/02 17:40:10 mycroft Exp $ -*/ - -#ifndef ns16000 -#define ns16000 -#endif - -#define HAVE_WAIT_STRUCT - -/* Define the bit, byte, and word ordering of the machine. */ -/* #define BITS_BIG_ENDIAN */ -/* #define BYTES_BIG_ENDIAN */ -/* #define WORDS_BIG_ENDIAN */ - -/* Encore's modifications to ptrace format */ - -#define UMAX_PTRACE - -/* Encore's modifications to core-file format */ - -#define UMAX_CORE - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Exec files and symbol tables are in COFF format */ - -#define COFF_FORMAT - -/* Doesn't have siginterupt. */ -#define NO_SIGINTERRUPT - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register unsigned char op = read_memory_integer (pc, 1); \ - if (op == 0x82) { op = read_memory_integer (pc+2,1); \ - if ((op & 0x80) == 0) pc += 3; \ - else if ((op & 0xc0) == 0x80) pc += 4; \ - else pc += 6; \ - } \ -} - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) \ - read_memory_integer (read_register (SP_REGNUM), 4) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0xfffff000) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xf2} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x12) - -#ifndef NaN -#include -#endif NaN - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, s) \ - ((s == sizeof (float))? \ - NaF (*(float *) p) : \ - NaD (*(double *) p)) - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 25 - -#define NUM_GENERAL_REGS 8 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ - "sp", "fp", "pc", "ps", \ - "fsr", \ - "l0", "l1", "l2", "l3", "xx", \ - } - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define FP0_REGNUM 8 /* Floating point register 0 */ -#define SP_REGNUM 16 /* Contains address of top of stack */ -#define AP_REGNUM FP_REGNUM -#define FP_REGNUM 17 /* Contains address of executing stack frame */ -#define PC_REGNUM 18 /* Contains program counter */ -#define PS_REGNUM 19 /* Contains processor status */ -#define FPS_REGNUM 20 /* Floating point status register */ -#define LP0_REGNUM 21 /* Double register 0 (same as FP0) */ - -/* called from register_addr() -- blockend not used for now */ -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ \ - switch (regno) { \ - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: \ - addr = PU_R0 - (regno * sizeof (int)); break; \ - case SP_REGNUM: \ - addr = PU_SP; break; \ - case PC_REGNUM: \ - addr = PU_PC; break; \ - case FP_REGNUM: \ - addr = PU_FP; break; \ - case PS_REGNUM: \ - addr = PU_PSL; break; \ - case FPS_REGNUM: \ - addr = PU_FSR; break; \ - case FP0_REGNUM + 0: case FP0_REGNUM + 1: \ - case FP0_REGNUM + 2: case FP0_REGNUM + 3: \ - case FP0_REGNUM + 4: case FP0_REGNUM + 5: \ - case FP0_REGNUM + 6: case FP0_REGNUM + 7: \ - addr = PU_F0 + (regno - FP0_REGNUM) * sizeof (float); break; \ - case LP0_REGNUM + 0: case LP0_REGNUM + 1: \ - case LP0_REGNUM + 2: case LP0_REGNUM + 3: \ - addr = PU_F0 + (regno - LP0_REGNUM) * sizeof (double); break; \ - default: \ - printf ("bad argument to REGISTER_U_ADDR %d\n", regno); \ - abort (); \ - } \ -} - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double)) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \ - LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 32000, all regs are 4 bytes - except for the doubled floating registers. */ - -#define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 32000, all regs are 4 bytes - except for the doubled floating registers. */ - -#define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 8 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 8 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((N) < FP0_REGNUM) ? \ - builtin_type_int : \ - ((N) < FP0_REGNUM + 8) ? \ - builtin_type_float : \ - ((N) < LP0_REGNUM) ? \ - builtin_type_int : \ - builtin_type_double) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. - - On this machine this is a no-op, because gcc isn't used on it - yet. So this calling convention is not used. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the ns32000 series, the frame's nominal address is the FP - value, and at that address is saved previous FP value as a 4-byte word. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -/* Compute base of arguments. */ - -#define FRAME_ARGS_ADDRESS(fi) \ - ((ns32k_get_enter_addr ((fi)->pc) > 1) ? \ - ((fi)->frame) : (read_register (SP_REGNUM) - 4)) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Get the address of the enter opcode for this function, if it is active. - Returns positive address > 1 if pc is between enter/exit, - 1 if pc before enter or after exit, 0 otherwise. */ - -#ifndef CORE_ADDR -#include "defs.h" /* Make sure CORE_ADDR is defined. */ -#endif - -extern CORE_ADDR ns32k_get_enter_addr (); - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. - Encore's C compiler often reuses same area on stack for args, - so this will often not work properly. If the arg names - are known, it's likely most of them will be printed. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ CORE_ADDR pc; \ - CORE_ADDR enter_addr; \ - unsigned int insn; \ - unsigned int addr_mode; \ - int width; \ - \ - numargs = -1; \ - enter_addr = ns32k_get_enter_addr ((fi)->pc); \ - if (enter_addr > 0) \ - { \ - pc = (enter_addr == 1) ? \ - SAVED_PC_AFTER_CALL (fi) : \ - FRAME_SAVED_PC (fi); \ - insn = read_memory_integer (pc,2); \ - addr_mode = (insn >> 11) & 0x1f; \ - insn = insn & 0x7ff; \ - if ((insn & 0x7fc) == 0x57c && \ - addr_mode == 0x14) /* immediate */ \ - { \ - if (insn == 0x57c) /* adjspb */ \ - width = 1; \ - else if (insn == 0x57d) /* adjspw */ \ - width = 2; \ - else if (insn == 0x57f) /* adjspd */ \ - width = 4; \ - numargs = read_memory_integer (pc+2,width); \ - if (width > 1) \ - flip_bytes (&numargs, width); \ - numargs = - sign_extend (numargs, width*8) / 4;\ - } \ - } \ -} - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ \ - register int regmask, regnum; \ - int localcount; \ - register CORE_ADDR enter_addr; \ - register CORE_ADDR next_addr; \ - \ - bzero (&(frame_saved_regs), sizeof (frame_saved_regs)); \ - enter_addr = ns32k_get_enter_addr ((frame_info)->pc); \ - if (enter_addr > 1) \ - { \ - regmask = read_memory_integer (enter_addr+1, 1) & 0xff; \ - localcount = ns32k_localcount (enter_addr); \ - next_addr = (frame_info)->frame + localcount; \ - for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \ - (frame_saved_regs).regs[regnum] = (regmask & 1) ? \ - (next_addr -= 4) : 0; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4;\ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4;\ - (frame_saved_regs).regs[FP_REGNUM] = \ - (read_memory_integer ((frame_info)->frame, 4));\ - } \ - else if (enter_addr == 1) \ - { \ - CORE_ADDR sp = read_register (SP_REGNUM); \ - (frame_saved_regs).regs[PC_REGNUM] = sp; \ - (frame_saved_regs).regs[SP_REGNUM] = sp + 4; \ - } \ -} - -/* Compensate for lack of `vprintf' function. */ -#ifndef HAVE_VPRINTF -#define vprintf(format, ap) _doprnt (format, ap, stdout) -#endif /* not HAVE_VPRINTF */ - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM);\ - register int regnum; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = 0; regnum < 8; regnum++) \ - sp = push_word (sp, read_register (regnum)); \ - write_register (SP_REGNUM, sp); \ -} - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = 0; regnum < 8; regnum++) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); } - -/* This sequence of words is the instructions - enter 0xff,0 82 ff 00 - jsr @0x00010203 7f ae c0 01 02 03 - adjspd 0x69696969 7f a5 01 02 03 04 - bpt f2 - Note this is 16 bytes. */ - -#define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 } - -#define CALL_DUMMY_START_OFFSET 3 -#define CALL_DUMMY_LENGTH 16 -#define CALL_DUMMY_ADDR 5 -#define CALL_DUMMY_NARGS 11 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ \ - int flipped; \ - flipped = fun | 0xc0000000; \ - flip_bytes (&flipped, 4); \ - *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \ - flipped = - nargs * 4; \ - flip_bytes (&flipped, 4); \ - *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \ -} diff --git a/gnu/usr.bin/gdb/config/m-vax.h b/gnu/usr.bin/gdb/config/m-vax.h deleted file mode 100644 index 0923b5f8021e..000000000000 --- a/gnu/usr.bin/gdb/config/m-vax.h +++ /dev/null @@ -1,475 +0,0 @@ -/* Definitions to make GDB run on a vax under 4.2bsd. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m-vax.h,v 1.2 1993/08/02 17:40:11 mycroft Exp $ -*/ - -/* There is one known bug with VAX support that I don't know how to - fix: if you do a backtrace from a signal handler, you get something - like: -#0 0xbc in kill (592, 3) -#1 0x7f in hand (...) (...) -#2 0x7fffec7e in ?? (2, 0, 2147478112, 94) - ^^ GDB doesn't know about sigtramp -#3 0x7fffec70 in ?? (592, 2) - ^^^^^^^^^^ wrong address -#4 0xae in main (...) (...) - -when the correct backtrace (as given by adb) is: -_kill(250,3) from _hand+21 -_hand(2,0,7fffea60,5e) from 7fffec7e -sigtramp(2,0,7fffea60,5e) from _kill+4 -_kill(250,2) from _main+2e -_main(1,7fffeac4,7fffeacc) from start+3d - -If anyone knows enough about VAX BSD to fix this, please send the -fix to bug-gdb@prep.ai.mit.edu. */ - -#ifndef vax -#define vax -#endif - -/* Define the bit, byte, and word ordering of the machine. */ -/* #define BITS_BIG_ENDIAN */ -/* #define BYTES_BIG_ENDIAN */ -/* #define WORDS_BIG_ENDIAN */ - -/* Library stuff: POSIX tty (not supported yet), V7 tty (sigh), vprintf. */ - -#define HAVE_TERMIOS 1 -#define USE_OLD_TTY 1 -#define HAVE_VPRINTF 1 - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in DBX format. */ - -#define READ_DBX_FORMAT - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 2 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = (unsigned char) read_memory_integer (pc, 1); \ - if (op == 0x11) pc += 2; /* skip brb */ \ - if (op == 0x31) pc += 3; /* skip brw */ \ - if (op == 0xC2 && \ - ((unsigned char) read_memory_integer (pc+2, 1)) == 0x5E) \ - pc += 3; /* skip subl2 */ \ - if (op == 0x9E && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xAE && \ - ((unsigned char) read_memory_integer(pc+3, 1)) == 0x5E) \ - pc += 4; /* skip movab */ \ - if (op == 0x9E && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xCE && \ - ((unsigned char) read_memory_integer(pc+4, 1)) == 0x5E) \ - pc += 5; /* skip movab */ \ - if (op == 0x9E && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xEE && \ - ((unsigned char) read_memory_integer(pc+6, 1)) == 0x5E) \ - pc += 7; /* skip movab */ \ -} - -/* Immediately after a function call, return the saved pc. - Can't always go through the frames for this because on some machines - the new frame is not set up until the new function executes - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) FRAME_SAVED_PC(frame) - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG)) - -/* Same as offsetof macro from stddef.h (which 4.3BSD doesn't have). */ -#define my_offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER) - -/* On the VAX, sigtramp is in the u area. Note that this definition - includes both the subroutine at u_pcb.pcb_sigc[3], and the - routine at u_pcb.pcb_sigc[0] (which does a calls to u_pcb.pcb_sigc[3]). - I think this is what we want. */ -#define IN_SIGTRAMP(pc, name) \ - ((pc) >= KERNEL_U_ADDR + my_offsetof (struct user, u_pcb.pcb_sigc[0]) \ - && (pc) < KERNEL_U_ADDR + my_offsetof (struct user, u_pcb.pcb_sigc[5]) \ - ) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0x80000000 - (UPAGES * NBPG)) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {3} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 04) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes -- not relevant on the Vax. */ - -#define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000) - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 17 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "ap", "fp", "sp", "pc", "ps"} - -/* Register numbers of various important registers. - Note that some of these values are "real" register numbers, - and correspond to the general registers of the machine, - and some are "phony" register numbers which are too large - to be actual register numbers as far as the user is concerned - but do serve to get the desired values when passed to read_register. */ - -#define AP_REGNUM 12 -#define FP_REGNUM 13 /* Contains address of executing stack frame */ -#define SP_REGNUM 14 /* Contains address of top of stack */ -#define PC_REGNUM 15 /* Contains program counter */ -#define PS_REGNUM 16 /* Contains processor status */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ addr = blockend - 0110 + regno * 4; \ - if (regno == PC_REGNUM) addr = blockend - 8; \ - if (regno == PS_REGNUM) addr = blockend - 4; \ - if (regno == FP_REGNUM) addr = blockend - 0120; \ - if (regno == AP_REGNUM) addr = blockend - 0124; \ - if (regno == SP_REGNUM) addr = blockend - 20; } - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (17*4) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the vax, all regs are 4 bytes. */ - -#define REGISTER_RAW_SIZE(N) 4 - -/* Number of bytes of storage in the program's representation - for register N. On the vax, all regs are 4 bytes. */ - -#define REGISTER_VIRTUAL_SIZE(N) 4 - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 4 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 4 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) builtin_type_int - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (1, (ADDR)); } - -/* Extract from an array REGBUF containing the (raw) register state - a function return value of type TYPE, and copy that, in virtual format, - into VALBUF. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) - -/* Extract from an array REGBUF containing the (raw) register state - the address in which a function should return its structure value, - as a CORE_ADDR (or an expression that can be used as one). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address - and produces the nominal address of the caller frame. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. - In that case, FRAME_CHAIN_COMBINE is not used. */ - -/* In the case of the Vax, the frame's nominal address is the FP value, - and 12 bytes later comes the saved previous FP value as a 4-byte word. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame + 12, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) - -/* Define other aspects of the stack frame. */ - -/* A macro that tells us whether the function invocation represented - by FI does not have a frame on the stack associated with it. If it - does not, FRAMELESS is set to 1, else 0. */ -/* On the vax, all functions have frames. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) {(FRAMELESS) = 0;} - -/* Saved Pc. */ - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 16, 4)) - -/* Cannot find the AP register value directly from the FP value. Must - find it saved in the frame called by this one, or in the AP - register for the innermost frame. However, there is no way to tell - the difference between the innermost frame and a frame for which we - just don't know the frame that it called (e.g. "info frame - 0x7ffec789"). For the sake of argument suppose that the stack is - somewhat trashed (which is one reason that "info frame" exists). - So return Frame_unknown (indicating we don't know the address of - the arglist) if we don't know what frame this frame calls. */ -#define FRAME_ARGS_ADDRESS_CORRECT(fi) \ - (((fi)->next_frame \ - ? read_memory_integer ((fi)->next_frame + 8, 4) \ - : /* read_register (AP_REGNUM) */ Frame_unknown)) - -/* In most of GDB, getting the args address is too important to - just say "I don't know". This is sometimes wrong, but c'est - la vie. */ -#define FRAME_ARGS_ADDRESS(fi) \ - (((fi)->next_frame \ - ? read_memory_integer ((fi)->next_frame + 8, 4) \ - : read_register (AP_REGNUM) /* Frame_unknown */)) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ numargs = (0xff & read_memory_integer (FRAME_ARGS_ADDRESS (fi), 1)); } - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 4 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - This includes special registers such as pc and fp saved in special - ways in the stack frame. sp is even more special: - the address we return for it IS the sp for the next frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask = read_memory_integer ((frame_info)->frame+4, 4) >> 16; \ - register CORE_ADDR next_addr; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - next_addr = (frame_info)->frame + 16; \ - /* Regmask's low bit is for register 0, \ - which is the first one that would be pushed. */ \ - for (regnum = 0; regnum < 12; regnum++, regmask >>= 1) \ - (frame_saved_regs).regs[regnum] = (regmask & 1) ? (next_addr += 4) : 0; \ - (frame_saved_regs).regs[SP_REGNUM] = next_addr + 4; \ - if (read_memory_integer ((frame_info)->frame + 4, 4) & 0x20000000) \ - (frame_saved_regs).regs[SP_REGNUM] += 4 + 4 * read_memory_integer (next_addr + 4, 4); \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 16; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame + 12; \ - (frame_saved_regs).regs[AP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[PS_REGNUM] = (frame_info)->frame + 4; \ -} - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME \ -{ register CORE_ADDR sp = read_register (SP_REGNUM);\ - register int regnum; \ - sp = push_word (sp, 0); /* arglist */ \ - for (regnum = 11; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - sp = push_word (sp, read_register (AP_REGNUM)); \ - sp = push_word (sp, (read_register (PS_REGNUM) & 0xffef) \ - + 0x2fff0000); \ - sp = push_word (sp, 0); \ - write_register (SP_REGNUM, sp); \ - write_register (FP_REGNUM, sp); \ - write_register (AP_REGNUM, sp + 17 * sizeof (int)); } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register CORE_ADDR fp = read_register (FP_REGNUM); \ - register int regnum; \ - register int regmask = read_memory_integer (fp + 4, 4); \ - write_register (PS_REGNUM, \ - (regmask & 0xffff) \ - | (read_register (PS_REGNUM) & 0xffff0000)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 16, 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp + 12, 4)); \ - write_register (AP_REGNUM, read_memory_integer (fp + 8, 4)); \ - fp += 16; \ - for (regnum = 0; regnum < 12; regnum++) \ - if (regmask & (0x10000 << regnum)) \ - write_register (regnum, read_memory_integer (fp += 4, 4)); \ - fp = fp + 4 + ((regmask >> 30) & 3); \ - if (regmask & 0x20000000) \ - { regnum = read_memory_integer (fp, 4); \ - fp += (regnum + 1) * 4; } \ - write_register (SP_REGNUM, fp); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); } - -/* This sequence of words is the instructions - calls #69, @#32323232 - bpt - Note this is 8 bytes. */ - -#define CALL_DUMMY {0x329f69fb, 0x03323232} - -#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ -{ *((char *) dummyname + 1) = nargs; \ - *(int *)((char *) dummyname + 3) = fun; } - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ - 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("pushl fp"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("pushl 8(sp)"); \ - asm ("pushl 8(sp)"); \ - asm ("pushal 0x14(sp)"); \ - asm ("pushr $037777"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("popr $037777"); \ - asm ("subl2 $8,(sp)"); \ - asm ("movl (sp),sp"); \ - asm ("rei"); } diff --git a/gnu/usr.bin/gdb/config/m68k-opcode.h b/gnu/usr.bin/gdb/config/m68k-opcode.h deleted file mode 100644 index 59aaf16abe55..000000000000 --- a/gnu/usr.bin/gdb/config/m68k-opcode.h +++ /dev/null @@ -1,1683 +0,0 @@ -/* Opcode table for m68000/m68020 and m68881. - Copyright (C) 1989, Free Software Foundation. - -This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler. - -Both GDB and GAS are free software; you can redistribute 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. - -GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: m68k-opcode.h,v 1.2 1993/08/02 17:40:12 mycroft Exp $ -*/ - - -struct m68k_opcode -{ - char *name; - unsigned long opcode; - unsigned long match; - char *args; -}; - -/* We store four bytes of opcode for all opcodes because that - is the most any of them need. The actual length of an instruction - is always at least 2 bytes, and is as much longer as necessary to - hold the operands it has. - - The match component is a mask saying which bits must match - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing two characters - for each operand of the instruction. The first specifies - the kind of operand; the second, the place it is stored. */ - -/* Kinds of operands: - D data register only. Stored as 3 bits. - A address register only. Stored as 3 bits. - R either kind of register. Stored as 4 bits. - F floating point coprocessor register only. Stored as 3 bits. - O an offset (or width): immediate data 0-31 or data register. - Stored as 6 bits in special format for BF... insns. - + autoincrement only. Stored as 3 bits (number of the address register). - - autodecrement only. Stored as 3 bits (number of the address register). - Q quick immediate data. Stored as 3 bits. - This matches an immediate operand only when value is in range 1 .. 8. - M moveq immediate data. Stored as 8 bits. - This matches an immediate operand only when value is in range -128..127 - T trap vector immediate data. Stored as 4 bits. - - k K-factor for fmove.p instruction. Stored as a 7-bit constant or - a three bit register offset, depending on the field type. - - # immediate data. Stored in special places (b, w or l) - which say how many bits to store. - ^ immediate data for floating point instructions. Special places - are offset by 2 bytes from '#'... - B pc-relative address, converted to an offset - that is treated as immediate data. - d displacement and register. Stores the register as 3 bits - and stores the displacement in the entire second word. - - C the CCR. No need to store it; this is just for filtering validity. - S the SR. No need to store, just as with CCR. - U the USP. No need to store, just as with CCR. - - I Coprocessor ID. Not printed if 1. The Coprocessor ID is always - extracted from the 'd' field of word one, which means that an extended - coprocessor opcode can be skipped using the 'i' place, if needed. - - s System Control register for the floating point coprocessor. - S List of system control registers for floating point coprocessor. - - J Misc register for movec instruction, stored in 'j' format. - Possible values: - 000 SFC Source Function Code reg - 001 DFC Data Function Code reg - 002 CACR Cache Control Register - 800 USP User Stack Pointer - 801 VBR Vector Base reg - 802 CAAR Cache Address Register - 803 MSP Master Stack Pointer - 804 ISP Interrupt Stack Pointer - - L Register list of the type d0-d7/a0-a7 etc. - (New! Improved! Can also hold fp0-fp7, as well!) - The assembler tries to see if the registers match the insn by - looking at where the insn wants them stored. - - l Register list like L, but with all the bits reversed. - Used for going the other way. . . - - They are all stored as 6 bits using an address mode and a register number; - they differ in which addressing modes they match. - - * all (modes 0-6,7.*) - ~ alterable memory (modes 2-6,7.0,7.1)(not 0,1,7.~) - % alterable (modes 0-6,7.0,7.1)(not 7.~) - ; data (modes 0,2-6,7.*)(not 1) - @ data, but not immediate (modes 0,2-6,7.? ? ?)(not 1,7.?) This may really be ;, the 68020 book says it is - ! control (modes 2,5,6,7.*-)(not 0,1,3,4,7.4) - & alterable control (modes 2,5,6,7.0,7.1)(not 0,1,7.? ? ?) - $ alterable data (modes 0,2-6,7.0,7.1)(not 1,7.~) - ? alterable control, or data register (modes 0,2,5,6,7.0,7.1)(not 1,3,4,7.~) - / control, or data register (modes 0,2,5,6,7.0,7.1,7.2,7.3)(not 1,3,4,7.4) -*/ - -/* JF: for the 68851 */ -/* - I didn't use much imagination in choosing the - following codes, so many of them aren't very - mnemonic. -rab - - P pmmu register - Possible values: - 000 TC Translation Control reg - 100 CAL Current Access Level - 101 VAL Validate Access Level - 110 SCC Stack Change Control - 111 AC Access Control - - W wide pmmu registers - Possible values: - 001 DRP Dma Root Pointer - 010 SRP Supervisor Root Pointer - 011 CRP Cpu Root Pointer - - f function code register - 0 SFC - 1 DFC - - V VAL register only - - X BADx, BACx - 100 BAD Breakpoint Acknowledge Data - 101 BAC Breakpoint Acknowledge Control - - Y PSR - Z PCSR - - | memory (modes 2-6, 7.*) - -*/ - -/* Places to put an operand, for non-general operands: - s source, low bits of first word. - d dest, shifted 9 in first word - 1 second word, shifted 12 - 2 second word, shifted 6 - 3 second word, shifted 0 - 4 third word, shifted 12 - 5 third word, shifted 6 - 6 third word, shifted 0 - 7 second word, shifted 7 - 8 second word, shifted 10 - D store in both place 1 and place 3; for divul and divsl. - b second word, low byte - w second word (entire) - l second and third word (entire) - g branch offset for bra and similar instructions. - The place to store depends on the magnitude of offset. - t store in both place 7 and place 8; for floating point operations - c branch offset for cpBcc operations. - The place to store is word two if bit six of word one is zero, - and words two and three if bit six of word one is one. - i Increment by two, to skip over coprocessor extended operands. Only - works with the 'I' format. - k Dynamic K-factor field. Bits 6-4 of word 2, used as a register number. - Also used for dynamic fmovem instruction. - C floating point coprocessor constant - 7 bits. Also used for static - K-factors... - j Movec register #, stored in 12 low bits of second word. - - Places to put operand, for general operands: - d destination, shifted 6 bits in first word - b source, at low bit of first word, and immediate uses one byte - w source, at low bit of first word, and immediate uses two bytes - l source, at low bit of first word, and immediate uses four bytes - s source, at low bit of first word. - Used sometimes in contexts where immediate is not allowed anyway. - f single precision float, low bit of 1st word, immediate uses 4 bytes - F double precision float, low bit of 1st word, immediate uses 8 bytes - x extended precision float, low bit of 1st word, immediate uses 12 bytes - p packed float, low bit of 1st word, immediate uses 12 bytes -*/ - -#define one(x) ((x) << 16) -#define two(x, y) (((x) << 16) + y) - -/* - *** DANGER WILL ROBINSON *** - - The assembler requires that all instances of the same mnemonic must be - consecutive. If they aren't, the assembler will bomb at runtime - */ -struct m68k_opcode m68k_opcodes[] = -{ -{"abcd", one(0140400), one(0170770), "DsDd"}, -{"abcd", one(0140410), one(0170770), "-s-d"}, - - /* Add instructions */ -{"addal", one(0150700), one(0170700), "*lAd"}, -{"addaw", one(0150300), one(0170700), "*wAd"}, -{"addib", one(0003000), one(0177700), "#b$b"}, -{"addil", one(0003200), one(0177700), "#l$l"}, -{"addiw", one(0003100), one(0177700), "#w$w"}, -{"addqb", one(0050000), one(0170700), "Qd$b"}, -{"addql", one(0050200), one(0170700), "Qd%l"}, -{"addqw", one(0050100), one(0170700), "Qd%w"}, - -{"addb", one(0050000), one(0170700), "Qd$b"}, /* addq written as add */ -{"addb", one(0003000), one(0177700), "#b$b"}, /* addi written as add */ -{"addb", one(0150000), one(0170700), ";bDd"}, /* addb , Dd */ -{"addb", one(0150400), one(0170700), "Dd~b"}, /* addb Dd, */ - -{"addw", one(0050100), one(0170700), "Qd%w"}, /* addq written as add */ -{"addw", one(0003100), one(0177700), "#w$w"}, /* addi written as add */ -{"addw", one(0150300), one(0170700), "*wAd"}, /* adda written as add */ -{"addw", one(0150100), one(0170700), "*wDd"}, /* addw , Dd */ -{"addw", one(0150500), one(0170700), "Dd~w"}, /* addw Dd, */ - -{"addl", one(0050200), one(0170700), "Qd%l"}, /* addq written as add */ -{"addl", one(0003200), one(0177700), "#l$l"}, /* addi written as add */ -{"addl", one(0150700), one(0170700), "*lAd"}, /* adda written as add */ -{"addl", one(0150200), one(0170700), "*lDd"}, /* addl , Dd */ -{"addl", one(0150600), one(0170700), "Dd~l"}, /* addl Dd, */ - -{"addxb", one(0150400), one(0170770), "DsDd"}, -{"addxb", one(0150410), one(0170770), "-s-d"}, -{"addxl", one(0150600), one(0170770), "DsDd"}, -{"addxl", one(0150610), one(0170770), "-s-d"}, -{"addxw", one(0150500), one(0170770), "DsDd"}, -{"addxw", one(0150510), one(0170770), "-s-d"}, - -{"andib", one(0001000), one(0177700), "#b$b"}, -{"andib", one(0001074), one(0177777), "#bCb"}, /* andi to ccr */ -{"andiw", one(0001100), one(0177700), "#w$w"}, -{"andiw", one(0001174), one(0177777), "#wSw"}, /* andi to sr */ -{"andil", one(0001200), one(0177700), "#l$l"}, - -{"andb", one(0001000), one(0177700), "#b$b"}, /* andi written as or */ -{"andb", one(0001074), one(0177777), "#bCb"}, /* andi to ccr */ -{"andb", one(0140000), one(0170700), ";bDd"}, /* memory to register */ -{"andb", one(0140400), one(0170700), "Dd~b"}, /* register to memory */ -{"andw", one(0001100), one(0177700), "#w$w"}, /* andi written as or */ -{"andw", one(0001174), one(0177777), "#wSw"}, /* andi to sr */ -{"andw", one(0140100), one(0170700), ";wDd"}, /* memory to register */ -{"andw", one(0140500), one(0170700), "Dd~w"}, /* register to memory */ -{"andl", one(0001200), one(0177700), "#l$l"}, /* andi written as or */ -{"andl", one(0140200), one(0170700), ";lDd"}, /* memory to register */ -{"andl", one(0140600), one(0170700), "Dd~l"}, /* register to memory */ - -{"aslb", one(0160400), one(0170770), "QdDs"}, -{"aslb", one(0160440), one(0170770), "DdDs"}, -{"asll", one(0160600), one(0170770), "QdDs"}, -{"asll", one(0160640), one(0170770), "DdDs"}, -{"aslw", one(0160500), one(0170770), "QdDs"}, -{"aslw", one(0160540), one(0170770), "DdDs"}, -{"aslw", one(0160700), one(0177700), "~s"}, /* Shift memory */ -{"asrb", one(0160000), one(0170770), "QdDs"}, -{"asrb", one(0160040), one(0170770), "DdDs"}, -{"asrl", one(0160200), one(0170770), "QdDs"}, -{"asrl", one(0160240), one(0170770), "DdDs"}, -{"asrw", one(0160100), one(0170770), "QdDs"}, -{"asrw", one(0160140), one(0170770), "DdDs"}, -{"asrw", one(0160300), one(0177700), "~s"}, /* Shift memory */ - -{"bhi", one(0061000), one(0177400), "Bg"}, -{"bls", one(0061400), one(0177400), "Bg"}, -{"bcc", one(0062000), one(0177400), "Bg"}, -{"bcs", one(0062400), one(0177400), "Bg"}, -{"bne", one(0063000), one(0177400), "Bg"}, -{"beq", one(0063400), one(0177400), "Bg"}, -{"bvc", one(0064000), one(0177400), "Bg"}, -{"bvs", one(0064400), one(0177400), "Bg"}, -{"bpl", one(0065000), one(0177400), "Bg"}, -{"bmi", one(0065400), one(0177400), "Bg"}, -{"bge", one(0066000), one(0177400), "Bg"}, -{"blt", one(0066400), one(0177400), "Bg"}, -{"bgt", one(0067000), one(0177400), "Bg"}, -{"ble", one(0067400), one(0177400), "Bg"}, - -{"bchg", one(0000500), one(0170700), "Dd$s"}, -{"bchg", one(0004100), one(0177700), "#b$s"}, -{"bclr", one(0000600), one(0170700), "Dd$s"}, -{"bclr", one(0004200), one(0177700), "#b$s"}, -{"bfchg", two(0165300, 0), two(0177700, 0170000), "?sO2O3"}, -{"bfclr", two(0166300, 0), two(0177700, 0170000), "?sO2O3"}, -{"bfexts", two(0165700, 0), two(0177700, 0100000), "/sO2O3D1"}, -{"bfextu", two(0164700, 0), two(0177700, 0100000), "/sO2O3D1"}, -{"bfffo", two(0166700, 0), two(0177700, 0100000), "/sO2O3D1"}, -{"bfins", two(0167700, 0), two(0177700, 0100000), "D1?sO2O3"}, -{"bfset", two(0167300, 0), two(0177700, 0170000), "?sO2O3"}, -{"bftst", two(0164300, 0), two(0177700, 0170000), "/sO2O3"}, -{"bset", one(0000700), one(0170700), "Dd$s"}, -{"bset", one(0004300), one(0177700), "#b$s"}, -{"btst", one(0000400), one(0170700), "Dd@s"}, -{"btst", one(0004000), one(0177700), "#b@s"}, - -{"bkpt", one(0044110), one(0177770), "Qs"}, -{"bra", one(0060000), one(0177400), "Bg"}, -{"bras", one(0060000), one(0177400), "Bg"}, -{"bsr", one(0060400), one(0177400), "Bg"}, -{"bsrs", one(0060400), one(0177400), "Bg"}, - -{"callm", one(0003300), one(0177700), "#b!s"}, -{"cas2l", two(0007374, 0), two(0177777, 0107070), "D3D6D2D5R1R4"}, /* JF FOO this is really a 3 word ins */ -{"cas2w", two(0006374, 0), two(0177777, 0107070), "D3D6D2D5R1R4"}, /* JF ditto */ -{"casb", two(0005300, 0), two(0177700, 0177070), "D3D2~s"}, -{"casl", two(0007300, 0), two(0177700, 0177070), "D3D2~s"}, -{"casw", two(0006300, 0), two(0177700, 0177070), "D3D2~s"}, - -/* {"chk", one(0040600), one(0170700), ";wDd"}, JF FOO this looks wrong */ -{"chk2b", two(0000300, 0004000), two(0177700, 07777), "!sR1"}, -{"chk2l", two(0002300, 0004000), two(0177700, 07777), "!sR1"}, -{"chk2w", two(0001300, 0004000), two(0177700, 07777), "!sR1"}, -{"chkl", one(0040400), one(0170700), ";lDd"}, -{"chkw", one(0040600), one(0170700), ";wDd"}, -{"clrb", one(0041000), one(0177700), "$s"}, -{"clrl", one(0041200), one(0177700), "$s"}, -{"clrw", one(0041100), one(0177700), "$s"}, - -{"cmp2b", two(0000300, 0), two(0177700, 07777), "!sR1"}, -{"cmp2l", two(0002300, 0), two(0177700, 07777), "!sR1"}, -{"cmp2w", two(0001300, 0), two(0177700, 07777), "!sR1"}, -{"cmpal", one(0130700), one(0170700), "*lAd"}, -{"cmpaw", one(0130300), one(0170700), "*wAd"}, -{"cmpib", one(0006000), one(0177700), "#b;b"}, -{"cmpil", one(0006200), one(0177700), "#l;l"}, -{"cmpiw", one(0006100), one(0177700), "#w;w"}, -{"cmpb", one(0006000), one(0177700), "#b;b"}, /* cmpi written as cmp */ -{"cmpb", one(0130000), one(0170700), ";bDd"}, -{"cmpw", one(0006100), one(0177700), "#w;w"}, -{"cmpw", one(0130100), one(0170700), "*wDd"}, -{"cmpw", one(0130300), one(0170700), "*wAd"}, /* cmpa written as cmp */ -{"cmpl", one(0006200), one(0177700), "#l;l"}, -{"cmpl", one(0130200), one(0170700), "*lDd"}, -{"cmpl", one(0130700), one(0170700), "*lAd"}, -{"cmpmb", one(0130410), one(0170770), "+s+d"}, -{"cmpml", one(0130610), one(0170770), "+s+d"}, -{"cmpmw", one(0130510), one(0170770), "+s+d"}, - -{"dbcc", one(0052310), one(0177770), "DsBw"}, -{"dbcs", one(0052710), one(0177770), "DsBw"}, -{"dbeq", one(0053710), one(0177770), "DsBw"}, -{"dbf", one(0050710), one(0177770), "DsBw"}, -{"dbge", one(0056310), one(0177770), "DsBw"}, -{"dbgt", one(0057310), one(0177770), "DsBw"}, -{"dbhi", one(0051310), one(0177770), "DsBw"}, -{"dble", one(0057710), one(0177770), "DsBw"}, -{"dbls", one(0051710), one(0177770), "DsBw"}, -{"dblt", one(0056710), one(0177770), "DsBw"}, -{"dbmi", one(0055710), one(0177770), "DsBw"}, -{"dbne", one(0053310), one(0177770), "DsBw"}, -{"dbpl", one(0055310), one(0177770), "DsBw"}, -{"dbra", one(0050710), one(0177770), "DsBw"}, -{"dbt", one(0050310), one(0177770), "DsBw"}, -{"dbvc", one(0054310), one(0177770), "DsBw"}, -{"dbvs", one(0054710), one(0177770), "DsBw"}, - -{"divsl", two(0046100, 0006000), two(0177700, 0107770), ";lD3D1"}, -{"divsl", two(0046100, 0004000), two(0177700, 0107770), ";lDD"}, -{"divsll", two(0046100, 0004000), two(0177700, 0107770), ";lD3D1"}, -{"divsw", one(0100700), one(0170700), ";wDd"}, -{"divs", one(0100700), one(0170700), ";wDd"}, -{"divul", two(0046100, 0002000), two(0177700, 0107770), ";lD3D1"}, -{"divul", two(0046100, 0000000), two(0177700, 0107770), ";lDD"}, -{"divull", two(0046100, 0000000), two(0177700, 0107770), ";lD3D1"}, -{"divuw", one(0100300), one(0170700), ";wDd"}, -{"divu", one(0100300), one(0170700), ";wDd"}, -{"eorb", one(0005000), one(0177700), "#b$s"}, /* eori written as or */ -{"eorb", one(0005074), one(0177777), "#bCs"}, /* eori to ccr */ -{"eorb", one(0130400), one(0170700), "Dd$s"}, /* register to memory */ -{"eorib", one(0005000), one(0177700), "#b$s"}, -{"eorib", one(0005074), one(0177777), "#bCs"}, /* eori to ccr */ -{"eoril", one(0005200), one(0177700), "#l$s"}, -{"eoriw", one(0005100), one(0177700), "#w$s"}, -{"eoriw", one(0005174), one(0177777), "#wSs"}, /* eori to sr */ -{"eorl", one(0005200), one(0177700), "#l$s"}, -{"eorl", one(0130600), one(0170700), "Dd$s"}, -{"eorw", one(0005100), one(0177700), "#w$s"}, -{"eorw", one(0005174), one(0177777), "#wSs"}, /* eori to sr */ -{"eorw", one(0130500), one(0170700), "Dd$s"}, - -{"exg", one(0140500), one(0170770), "DdDs"}, -{"exg", one(0140510), one(0170770), "AdAs"}, -{"exg", one(0140610), one(0170770), "DdAs"}, -{"exg", one(0140610), one(0170770), "AsDd"}, - -{"extw", one(0044200), one(0177770), "Ds"}, -{"extl", one(0044300), one(0177770), "Ds"}, -{"extbl", one(0044700), one(0177770), "Ds"}, -{"extb.l", one(0044700), one(0177770), "Ds"}, /* Not sure we should support this one*/ - -{"illegal", one(0045374), one(0177777), ""}, -{"jmp", one(0047300), one(0177700), "!s"}, -{"jsr", one(0047200), one(0177700), "!s"}, -{"lea", one(0040700), one(0170700), "!sAd"}, -{"linkw", one(0047120), one(0177770), "As#w"}, -{"linkl", one(0044010), one(0177770), "As#l"}, -{"link", one(0047120), one(0177770), "As#w"}, -{"link", one(0044010), one(0177770), "As#l"}, - -{"lslb", one(0160410), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lslb", one(0160450), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ -{"lslw", one(0160510), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lslw", one(0160550), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ -{"lslw", one(0161700), one(0177700), "~s"}, /* Shift memory */ -{"lsll", one(0160610), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lsll", one(0160650), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ - -{"lsrb", one(0160010), one(0170770), "QdDs"} /* lsrb #Q, Ds */, -{"lsrb", one(0160050), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ -{"lsrl", one(0160210), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lsrl", one(0160250), one(0170770), "DdDs"}, /* lsrb #Q, Ds */ -{"lsrw", one(0160110), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lsrw", one(0160150), one(0170770), "DdDs"}, /* lsrb #Q, Ds */ -{"lsrw", one(0161300), one(0177700), "~s"}, /* Shift memory */ - -{"moveal", one(0020100), one(0170700), "*lAd"}, -{"moveaw", one(0030100), one(0170700), "*wAd"}, -{"moveb", one(0010000), one(0170000), ";b$d"}, /* move */ -{"movel", one(0070000), one(0170400), "MsDd"}, /* moveq written as move */ -{"movel", one(0020000), one(0170000), "*l$d"}, -{"movel", one(0020100), one(0170700), "*lAd"}, -{"movel", one(0047140), one(0177770), "AsUd"}, /* move to USP */ -{"movel", one(0047150), one(0177770), "UdAs"}, /* move from USP */ - -{"movec", one(0047173), one(0177777), "R1Jj"}, -{"movec", one(0047173), one(0177777), "R1#j"}, -{"movec", one(0047172), one(0177777), "JjR1"}, -{"movec", one(0047172), one(0177777), "#jR1"}, - -/* JF added these next four for the assembler */ -{"moveml", one(0044300), one(0177700), "Lw&s"}, /* movem reg to mem. */ -{"moveml", one(0044340), one(0177770), "lw-s"}, /* movem reg to autodecrement. */ -{"moveml", one(0046300), one(0177700), "!sLw"}, /* movem mem to reg. */ -{"moveml", one(0046330), one(0177770), "+sLw"}, /* movem autoinc to reg. */ - -{"moveml", one(0044300), one(0177700), "#w&s"}, /* movem reg to mem. */ -{"moveml", one(0044340), one(0177770), "#w-s"}, /* movem reg to autodecrement. */ -{"moveml", one(0046300), one(0177700), "!s#w"}, /* movem mem to reg. */ -{"moveml", one(0046330), one(0177770), "+s#w"}, /* movem autoinc to reg. */ - -/* JF added these next four for the assembler */ -{"movemw", one(0044200), one(0177700), "Lw&s"}, /* movem reg to mem. */ -{"movemw", one(0044240), one(0177770), "lw-s"}, /* movem reg to autodecrement. */ -{"movemw", one(0046200), one(0177700), "!sLw"}, /* movem mem to reg. */ -{"movemw", one(0046230), one(0177770), "+sLw"}, /* movem autoinc to reg. */ - -{"movemw", one(0044200), one(0177700), "#w&s"}, /* movem reg to mem. */ -{"movemw", one(0044240), one(0177770), "#w-s"}, /* movem reg to autodecrement. */ -{"movemw", one(0046200), one(0177700), "!s#w"}, /* movem mem to reg. */ -{"movemw", one(0046230), one(0177770), "+s#w"}, /* movem autoinc to reg. */ - -{"movepl", one(0000510), one(0170770), "dsDd"}, /* memory to register */ -{"movepl", one(0000710), one(0170770), "Ddds"}, /* register to memory */ -{"movepw", one(0000410), one(0170770), "dsDd"}, /* memory to register */ -{"movepw", one(0000610), one(0170770), "Ddds"}, /* register to memory */ -{"moveq", one(0070000), one(0170400), "MsDd"}, -{"movew", one(0030000), one(0170000), "*w$d"}, -{"movew", one(0030100), one(0170700), "*wAd"}, /* movea, written as move */ -{"movew", one(0040300), one(0177700), "Ss$s"}, /* Move from sr */ -{"movew", one(0041300), one(0177700), "Cs$s"}, /* Move from ccr */ -{"movew", one(0042300), one(0177700), ";wCd"}, /* move to ccr */ -{"movew", one(0043300), one(0177700), ";wSd"}, /* move to sr */ - -{"movesb", two(0007000, 0), two(0177700, 07777), "~sR1"}, /* moves from memory */ -{"movesb", two(0007000, 04000), two(0177700, 07777), "R1~s"}, /* moves to memory */ -{"movesl", two(0007200, 0), two(0177700, 07777), "~sR1"}, /* moves from memory */ -{"movesl", two(0007200, 04000), two(0177700, 07777), "R1~s"}, /* moves to memory */ -{"movesw", two(0007100, 0), two(0177700, 07777), "~sR1"}, /* moves from memory */ -{"movesw", two(0007100, 04000), two(0177700, 07777), "R1~s"}, /* moves to memory */ - -{"mulsl", two(0046000, 004000), two(0177700, 0107770), ";lD1"}, -{"mulsl", two(0046000, 006000), two(0177700, 0107770), ";lD3D1"}, -{"mulsw", one(0140700), one(0170700), ";wDd"}, -{"muls", one(0140700), one(0170700), ";wDd"}, -{"mulul", two(0046000, 000000), two(0177700, 0107770), ";lD1"}, -{"mulul", two(0046000, 002000), two(0177700, 0107770), ";lD3D1"}, -{"muluw", one(0140300), one(0170700), ";wDd"}, -{"mulu", one(0140300), one(0170700), ";wDd"}, -{"nbcd", one(0044000), one(0177700), "$s"}, -{"negb", one(0042000), one(0177700), "$s"}, -{"negl", one(0042200), one(0177700), "$s"}, -{"negw", one(0042100), one(0177700), "$s"}, -{"negxb", one(0040000), one(0177700), "$s"}, -{"negxl", one(0040200), one(0177700), "$s"}, -{"negxw", one(0040100), one(0177700), "$s"}, -{"nop", one(0047161), one(0177777), ""}, -{"notb", one(0043000), one(0177700), "$s"}, -{"notl", one(0043200), one(0177700), "$s"}, -{"notw", one(0043100), one(0177700), "$s"}, - -{"orb", one(0000000), one(0177700), "#b$s"}, /* ori written as or */ -{"orb", one(0000074), one(0177777), "#bCs"}, /* ori to ccr */ -{"orb", one(0100000), one(0170700), ";bDd"}, /* memory to register */ -{"orb", one(0100400), one(0170700), "Dd~s"}, /* register to memory */ -{"orib", one(0000000), one(0177700), "#b$s"}, -{"orib", one(0000074), one(0177777), "#bCs"}, /* ori to ccr */ -{"oril", one(0000200), one(0177700), "#l$s"}, -{"oriw", one(0000100), one(0177700), "#w$s"}, -{"oriw", one(0000174), one(0177777), "#wSs"}, /* ori to sr */ -{"orl", one(0000200), one(0177700), "#l$s"}, -{"orl", one(0100200), one(0170700), ";lDd"}, /* memory to register */ -{"orl", one(0100600), one(0170700), "Dd~s"}, /* register to memory */ -{"orw", one(0000100), one(0177700), "#w$s"}, -{"orw", one(0000174), one(0177777), "#wSs"}, /* ori to sr */ -{"orw", one(0100100), one(0170700), ";wDd"}, /* memory to register */ -{"orw", one(0100500), one(0170700), "Dd~s"}, /* register to memory */ - -{"pack", one(0100500), one(0170770), "DsDd#w"}, /* pack Ds, Dd, #w */ -{"pack", one(0100510), one(0170770), "-s-d#w"}, /* pack -(As), -(Ad), #w */ -{"pea", one(0044100), one(0177700), "!s"}, -{"reset", one(0047160), one(0177777), ""}, - -{"rolb", one(0160430), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rolb", one(0160470), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"roll", one(0160630), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"roll", one(0160670), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rolw", one(0160530), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rolw", one(0160570), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rolw", one(0163700), one(0177700), "~s"}, /* Rotate memory */ -{"rorb", one(0160030), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rorb", one(0160070), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rorl", one(0160230), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rorl", one(0160270), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rorw", one(0160130), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rorw", one(0160170), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rorw", one(0163300), one(0177700), "~s"}, /* Rotate memory */ - -{"roxlb", one(0160420), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxlb", one(0160460), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxll", one(0160620), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxll", one(0160660), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxlw", one(0160520), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxlw", one(0160560), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxlw", one(0162700), one(0177700), "~s"}, /* Rotate memory */ -{"roxrb", one(0160020), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxrb", one(0160060), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxrl", one(0160220), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxrl", one(0160260), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxrw", one(0160120), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxrw", one(0160160), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxrw", one(0162300), one(0177700), "~s"}, /* Rotate memory */ - -{"rtd", one(0047164), one(0177777), "#w"}, -{"rte", one(0047163), one(0177777), ""}, -{"rtm", one(0003300), one(0177760), "Rs"}, -{"rtr", one(0047167), one(0177777), ""}, -{"rts", one(0047165), one(0177777), ""}, - -{"scc", one(0052300), one(0177700), "$s"}, -{"scs", one(0052700), one(0177700), "$s"}, -{"seq", one(0053700), one(0177700), "$s"}, -{"sf", one(0050700), one(0177700), "$s"}, -{"sge", one(0056300), one(0177700), "$s"}, -{"sgt", one(0057300), one(0177700), "$s"}, -{"shi", one(0051300), one(0177700), "$s"}, -{"sle", one(0057700), one(0177700), "$s"}, -{"sls", one(0051700), one(0177700), "$s"}, -{"slt", one(0056700), one(0177700), "$s"}, -{"smi", one(0055700), one(0177700), "$s"}, -{"sne", one(0053300), one(0177700), "$s"}, -{"spl", one(0055300), one(0177700), "$s"}, -{"st", one(0050300), one(0177700), "$s"}, -{"svc", one(0054300), one(0177700), "$s"}, -{"svs", one(0054700), one(0177700), "$s"}, - -{"sbcd", one(0100400), one(0170770), "DsDd"}, -{"sbcd", one(0100410), one(0170770), "-s-d"}, -{"stop", one(0047162), one(0177777), "#w"}, - -{"subal", one(0110700), one(0170700), "*lAd"}, -{"subaw", one(0110300), one(0170700), "*wAd"}, -{"subb", one(0050400), one(0170700), "Qd%s"}, /* subq written as sub */ -{"subb", one(0002000), one(0177700), "#b$s"}, /* subi written as sub */ -{"subb", one(0110000), one(0170700), ";bDd"}, /* subb ? ?, Dd */ -{"subb", one(0110400), one(0170700), "Dd~s"}, /* subb Dd, ? ? */ -{"subib", one(0002000), one(0177700), "#b$s"}, -{"subil", one(0002200), one(0177700), "#l$s"}, -{"subiw", one(0002100), one(0177700), "#w$s"}, -{"subl", one(0050600), one(0170700), "Qd%s"}, -{"subl", one(0002200), one(0177700), "#l$s"}, -{"subl", one(0110700), one(0170700), "*lAd"}, -{"subl", one(0110200), one(0170700), "*lDd"}, -{"subl", one(0110600), one(0170700), "Dd~s"}, -{"subqb", one(0050400), one(0170700), "Qd%s"}, -{"subql", one(0050600), one(0170700), "Qd%s"}, -{"subqw", one(0050500), one(0170700), "Qd%s"}, -{"subw", one(0050500), one(0170700), "Qd%s"}, -{"subw", one(0002100), one(0177700), "#w$s"}, -{"subw", one(0110100), one(0170700), "*wDd"}, -{"subw", one(0110300), one(0170700), "*wAd"}, /* suba written as sub */ -{"subw", one(0110500), one(0170700), "Dd~s"}, -{"subxb", one(0110400), one(0170770), "DsDd"}, /* subxb Ds, Dd */ -{"subxb", one(0110410), one(0170770), "-s-d"}, /* subxb -(As), -(Ad) */ -{"subxl", one(0110600), one(0170770), "DsDd"}, -{"subxl", one(0110610), one(0170770), "-s-d"}, -{"subxw", one(0110500), one(0170770), "DsDd"}, -{"subxw", one(0110510), one(0170770), "-s-d"}, - -{"swap", one(0044100), one(0177770), "Ds"}, - -{"tas", one(0045300), one(0177700), "$s"}, -{"trap", one(0047100), one(0177760), "Ts"}, - -{"trapcc", one(0052374), one(0177777), ""}, -{"trapcs", one(0052774), one(0177777), ""}, -{"trapeq", one(0053774), one(0177777), ""}, -{"trapf", one(0050774), one(0177777), ""}, -{"trapge", one(0056374), one(0177777), ""}, -{"trapgt", one(0057374), one(0177777), ""}, -{"traphi", one(0051374), one(0177777), ""}, -{"traple", one(0057774), one(0177777), ""}, -{"trapls", one(0051774), one(0177777), ""}, -{"traplt", one(0056774), one(0177777), ""}, -{"trapmi", one(0055774), one(0177777), ""}, -{"trapne", one(0053374), one(0177777), ""}, -{"trappl", one(0055374), one(0177777), ""}, -{"trapt", one(0050374), one(0177777), ""}, -{"trapvc", one(0054374), one(0177777), ""}, -{"trapvs", one(0054774), one(0177777), ""}, - -{"trapcc.w", one(0052372), one(0177777), ""}, -{"trapcs.w", one(0052772), one(0177777), ""}, -{"trapeq.w", one(0053772), one(0177777), ""}, -{"trapf.w", one(0050772), one(0177777), ""}, -{"trapge.w", one(0056372), one(0177777), ""}, -{"trapgt.w", one(0057372), one(0177777), ""}, -{"traphi.w", one(0051372), one(0177777), ""}, -{"traple.w", one(0057772), one(0177777), ""}, -{"trapls.w", one(0051772), one(0177777), ""}, -{"traplt.w", one(0056772), one(0177777), ""}, -{"trapmi.w", one(0055772), one(0177777), ""}, -{"trapne.w", one(0053372), one(0177777), ""}, -{"trappl.w", one(0055372), one(0177777), ""}, -{"trapt.w", one(0050372), one(0177777), ""}, -{"trapvc.w", one(0054372), one(0177777), ""}, -{"trapvs.w", one(0054772), one(0177777), ""}, - -{"trapcc.l", one(0052373), one(0177777), ""}, -{"trapcs.l", one(0052773), one(0177777), ""}, -{"trapeq.l", one(0053773), one(0177777), ""}, -{"trapf.l", one(0050773), one(0177777), ""}, -{"trapge.l", one(0056373), one(0177777), ""}, -{"trapgt.l", one(0057373), one(0177777), ""}, -{"traphi.l", one(0051373), one(0177777), ""}, -{"traple.l", one(0057773), one(0177777), ""}, -{"trapls.l", one(0051773), one(0177777), ""}, -{"traplt.l", one(0056773), one(0177777), ""}, -{"trapmi.l", one(0055773), one(0177777), ""}, -{"trapne.l", one(0053373), one(0177777), ""}, -{"trappl.l", one(0055373), one(0177777), ""}, -{"trapt.l", one(0050373), one(0177777), ""}, -{"trapvc.l", one(0054373), one(0177777), ""}, -{"trapvs.l", one(0054773), one(0177777), ""}, - -{"trapv", one(0047166), one(0177777), ""}, - -{"tstb", one(0045000), one(0177700), ";b"}, -{"tstw", one(0045100), one(0177700), "*w"}, -{"tstl", one(0045200), one(0177700), "*l"}, - -{"unlk", one(0047130), one(0177770), "As"}, -{"unpk", one(0100600), one(0170770), "DsDd#w"}, -{"unpk", one(0100610), one(0170770), "-s-d#w"}, - /* JF floating pt stuff moved down here */ - -{"fabsb", two(0xF000, 0x5818), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fabsd", two(0xF000, 0x5418), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fabsl", two(0xF000, 0x4018), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fabsp", two(0xF000, 0x4C18), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fabss", two(0xF000, 0x4418), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fabsw", two(0xF000, 0x5018), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fabsx", two(0xF000, 0x4818), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiFt"}, - -{"facosb", two(0xF000, 0x581C), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"facosd", two(0xF000, 0x541C), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"facosl", two(0xF000, 0x401C), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"facosp", two(0xF000, 0x4C1C), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"facoss", two(0xF000, 0x441C), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"facosw", two(0xF000, 0x501C), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"facosx", two(0xF000, 0x481C), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiFt"}, - -{"faddb", two(0xF000, 0x5822), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"faddd", two(0xF000, 0x5422), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"faddl", two(0xF000, 0x4022), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"faddp", two(0xF000, 0x4C22), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fadds", two(0xF000, 0x4422), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"faddw", two(0xF000, 0x5022), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"faddx", two(0xF000, 0x4822), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiFt"}, JF removed */ - -{"fasinb", two(0xF000, 0x580C), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fasind", two(0xF000, 0x540C), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fasinl", two(0xF000, 0x400C), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fasinp", two(0xF000, 0x4C0C), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fasins", two(0xF000, 0x440C), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fasinw", two(0xF000, 0x500C), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fasinx", two(0xF000, 0x480C), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fatanb", two(0xF000, 0x580A), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fatand", two(0xF000, 0x540A), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fatanl", two(0xF000, 0x400A), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fatanp", two(0xF000, 0x4C0A), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fatans", two(0xF000, 0x440A), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fatanw", two(0xF000, 0x500A), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fatanx", two(0xF000, 0x480A), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fatanhb", two(0xF000, 0x580D), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fatanhd", two(0xF000, 0x540D), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fatanhl", two(0xF000, 0x400D), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fatanhp", two(0xF000, 0x4C0D), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fatanhs", two(0xF000, 0x440D), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fatanhw", two(0xF000, 0x500D), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fatanhx", two(0xF000, 0x480D), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fbeq", one(0xF081), one(0xF1BF), "IdBc"}, -{"fbf", one(0xF080), one(0xF1BF), "IdBc"}, -{"fbge", one(0xF093), one(0xF1BF), "IdBc"}, -{"fbgl", one(0xF096), one(0xF1BF), "IdBc"}, -{"fbgle", one(0xF097), one(0xF1BF), "IdBc"}, -{"fbgt", one(0xF092), one(0xF1BF), "IdBc"}, -{"fble", one(0xF095), one(0xF1BF), "IdBc"}, -{"fblt", one(0xF094), one(0xF1BF), "IdBc"}, -{"fbne", one(0xF08E), one(0xF1BF), "IdBc"}, -{"fbnge", one(0xF09C), one(0xF1BF), "IdBc"}, -{"fbngl", one(0xF099), one(0xF1BF), "IdBc"}, -{"fbngle", one(0xF098), one(0xF1BF), "IdBc"}, -{"fbngt", one(0xF09D), one(0xF1BF), "IdBc"}, -{"fbnle", one(0xF09A), one(0xF1BF), "IdBc"}, -{"fbnlt", one(0xF09B), one(0xF1BF), "IdBc"}, -{"fboge", one(0xF083), one(0xF1BF), "IdBc"}, -{"fbogl", one(0xF086), one(0xF1BF), "IdBc"}, -{"fbogt", one(0xF082), one(0xF1BF), "IdBc"}, -{"fbole", one(0xF085), one(0xF1BF), "IdBc"}, -{"fbolt", one(0xF084), one(0xF1BF), "IdBc"}, -{"fbor", one(0xF087), one(0xF1BF), "IdBc"}, -{"fbseq", one(0xF091), one(0xF1BF), "IdBc"}, -{"fbsf", one(0xF090), one(0xF1BF), "IdBc"}, -{"fbsne", one(0xF09E), one(0xF1BF), "IdBc"}, -{"fbst", one(0xF09F), one(0xF1BF), "IdBc"}, -{"fbt", one(0xF08F), one(0xF1BF), "IdBc"}, -{"fbueq", one(0xF089), one(0xF1BF), "IdBc"}, -{"fbuge", one(0xF08B), one(0xF1BF), "IdBc"}, -{"fbugt", one(0xF08A), one(0xF1BF), "IdBc"}, -{"fbule", one(0xF08D), one(0xF1BF), "IdBc"}, -{"fbult", one(0xF08C), one(0xF1BF), "IdBc"}, -{"fbun", one(0xF088), one(0xF1BF), "IdBc"}, - -{"fcmpb", two(0xF000, 0x5838), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fcmpd", two(0xF000, 0x5438), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fcmpl", two(0xF000, 0x4038), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fcmpp", two(0xF000, 0x4C38), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fcmps", two(0xF000, 0x4438), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fcmpw", two(0xF000, 0x5038), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fcmpx", two(0xF000, 0x4838), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiFt"}, JF removed */ - -{"fcosb", two(0xF000, 0x581D), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fcosd", two(0xF000, 0x541D), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fcosl", two(0xF000, 0x401D), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fcosp", two(0xF000, 0x4C1D), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fcoss", two(0xF000, 0x441D), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fcosw", two(0xF000, 0x501D), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fcosx", two(0xF000, 0x481D), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fcoshb", two(0xF000, 0x5819), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fcoshd", two(0xF000, 0x5419), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fcoshl", two(0xF000, 0x4019), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fcoshp", two(0xF000, 0x4C19), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fcoshs", two(0xF000, 0x4419), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fcoshw", two(0xF000, 0x5019), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fcoshx", two(0xF000, 0x4819), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fdbeq", two(0xF048, 0x0001), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbf", two(0xF048, 0x0000), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbge", two(0xF048, 0x0013), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbgl", two(0xF048, 0x0016), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbgle", two(0xF048, 0x0017), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbgt", two(0xF048, 0x0012), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdble", two(0xF048, 0x0015), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdblt", two(0xF048, 0x0014), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbne", two(0xF048, 0x000E), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbnge", two(0xF048, 0x001C), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbngl", two(0xF048, 0x0019), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbngle", two(0xF048, 0x0018), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbngt", two(0xF048, 0x001D), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbnle", two(0xF048, 0x001A), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbnlt", two(0xF048, 0x001B), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdboge", two(0xF048, 0x0003), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbogl", two(0xF048, 0x0006), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbogt", two(0xF048, 0x0002), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbole", two(0xF048, 0x0005), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbolt", two(0xF048, 0x0004), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbor", two(0xF048, 0x0007), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbseq", two(0xF048, 0x0011), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbsf", two(0xF048, 0x0010), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbsne", two(0xF048, 0x001E), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbst", two(0xF048, 0x001F), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbt", two(0xF048, 0x000F), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbueq", two(0xF048, 0x0009), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbuge", two(0xF048, 0x000B), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbugt", two(0xF048, 0x000A), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbule", two(0xF048, 0x000D), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbult", two(0xF048, 0x000C), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbun", two(0xF048, 0x0008), two(0xF1F8, 0xFFFF), "IiDsBw"}, - -{"fdivb", two(0xF000, 0x5820), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fdivd", two(0xF000, 0x5420), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fdivl", two(0xF000, 0x4020), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fdivp", two(0xF000, 0x4C20), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fdivs", two(0xF000, 0x4420), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fdivw", two(0xF000, 0x5020), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fdivx", two(0xF000, 0x4820), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"fetoxb", two(0xF000, 0x5810), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fetoxd", two(0xF000, 0x5410), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fetoxl", two(0xF000, 0x4010), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fetoxp", two(0xF000, 0x4C10), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fetoxs", two(0xF000, 0x4410), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fetoxw", two(0xF000, 0x5010), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fetoxx", two(0xF000, 0x4810), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fetoxm1b", two(0xF000, 0x5808), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fetoxm1d", two(0xF000, 0x5408), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fetoxm1l", two(0xF000, 0x4008), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fetoxm1p", two(0xF000, 0x4C08), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fetoxm1s", two(0xF000, 0x4408), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fetoxm1w", two(0xF000, 0x5008), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fetoxm1x", two(0xF000, 0x4808), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fgetexpb", two(0xF000, 0x581E), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fgetexpd", two(0xF000, 0x541E), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fgetexpl", two(0xF000, 0x401E), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fgetexpp", two(0xF000, 0x4C1E), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fgetexps", two(0xF000, 0x441E), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fgetexpw", two(0xF000, 0x501E), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fgetexpx", two(0xF000, 0x481E), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fgetmanb", two(0xF000, 0x581F), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fgetmand", two(0xF000, 0x541F), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fgetmanl", two(0xF000, 0x401F), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fgetmanp", two(0xF000, 0x4C1F), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fgetmans", two(0xF000, 0x441F), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fgetmanw", two(0xF000, 0x501F), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fgetmanx", two(0xF000, 0x481F), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fintb", two(0xF000, 0x5801), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fintd", two(0xF000, 0x5401), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fintl", two(0xF000, 0x4001), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fintp", two(0xF000, 0x4C01), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fints", two(0xF000, 0x4401), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fintw", two(0xF000, 0x5001), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fintx", two(0xF000, 0x4801), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fintrzb", two(0xF000, 0x5803), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fintrzd", two(0xF000, 0x5403), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fintrzl", two(0xF000, 0x4003), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fintrzp", two(0xF000, 0x4C03), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fintrzs", two(0xF000, 0x4403), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fintrzw", two(0xF000, 0x5003), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fintrzx", two(0xF000, 0x4803), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flog10b", two(0xF000, 0x5815), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flog10d", two(0xF000, 0x5415), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flog10l", two(0xF000, 0x4015), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flog10p", two(0xF000, 0x4C15), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flog10s", two(0xF000, 0x4415), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flog10w", two(0xF000, 0x5015), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flog10x", two(0xF000, 0x4815), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flog2b", two(0xF000, 0x5816), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flog2d", two(0xF000, 0x5416), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flog2l", two(0xF000, 0x4016), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flog2p", two(0xF000, 0x4C16), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flog2s", two(0xF000, 0x4416), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flog2w", two(0xF000, 0x5016), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flog2x", two(0xF000, 0x4816), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flognb", two(0xF000, 0x5814), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flognd", two(0xF000, 0x5414), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flognl", two(0xF000, 0x4014), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flognp", two(0xF000, 0x4C14), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flogns", two(0xF000, 0x4414), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flognw", two(0xF000, 0x5014), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flognx", two(0xF000, 0x4814), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flognp1b", two(0xF000, 0x5806), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flognp1d", two(0xF000, 0x5406), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flognp1l", two(0xF000, 0x4006), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flognp1p", two(0xF000, 0x4C06), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flognp1s", two(0xF000, 0x4406), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flognp1w", two(0xF000, 0x5006), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flognp1x", two(0xF000, 0x4806), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fmodb", two(0xF000, 0x5821), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fmodd", two(0xF000, 0x5421), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fmodl", two(0xF000, 0x4021), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fmodp", two(0xF000, 0x4C21), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fmods", two(0xF000, 0x4421), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fmodw", two(0xF000, 0x5021), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fmodx", two(0xF000, 0x4821), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"fmoveb", two(0xF000, 0x5800), two(0xF1C0, 0xFC7F), "Ii;bF7"}, /* fmove from to fp */ -{"fmoveb", two(0xF000, 0x7800), two(0xF1C0, 0xFC7F), "IiF7@b"}, /* fmove from fp to */ -{"fmoved", two(0xF000, 0x5400), two(0xF1C0, 0xFC7F), "Ii;FF7"}, /* fmove from to fp */ -{"fmoved", two(0xF000, 0x7400), two(0xF1C0, 0xFC7F), "IiF7@F"}, /* fmove from fp to */ -{"fmovel", two(0xF000, 0x4000), two(0xF1C0, 0xFC7F), "Ii;lF7"}, /* fmove from to fp */ -{"fmovel", two(0xF000, 0x6000), two(0xF1C0, 0xFC7F), "IiF7@l"}, /* fmove from fp to */ -/* Warning: The addressing modes on these are probably not right: - esp, Areg direct is only allowed for FPI */ - /* fmove.l from/to system control registers: */ -{"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, -{"fmovel", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ls8"}, - -/* {"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, -{"fmovel", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*ss8"}, */ - -{"fmovep", two(0xF000, 0x4C00), two(0xF1C0, 0xFC7F), "Ii;pF7"}, /* fmove from to fp */ -{"fmovep", two(0xF000, 0x6C00), two(0xF1C0, 0xFC00), "IiF7@pkC"}, /* fmove.p with k-factors: */ -{"fmovep", two(0xF000, 0x7C00), two(0xF1C0, 0xFC0F), "IiF7@pDk"}, /* fmove.p with k-factors: */ - -{"fmoves", two(0xF000, 0x4400), two(0xF1C0, 0xFC7F), "Ii;fF7"}, /* fmove from to fp */ -{"fmoves", two(0xF000, 0x6400), two(0xF1C0, 0xFC7F), "IiF7@f"}, /* fmove from fp to */ -{"fmovew", two(0xF000, 0x5000), two(0xF1C0, 0xFC7F), "Ii;wF7"}, /* fmove from to fp */ -{"fmovew", two(0xF000, 0x7000), two(0xF1C0, 0xFC7F), "IiF7@w"}, /* fmove from fp to */ -{"fmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiF8F7"}, /* fmove from to fp */ -{"fmovex", two(0xF000, 0x4800), two(0xF1C0, 0xFC7F), "Ii;xF7"}, /* fmove from to fp */ -{"fmovex", two(0xF000, 0x6800), two(0xF1C0, 0xFC7F), "IiF7@x"}, /* fmove from fp to */ -/* JF removed {"fmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiFt"}, / * fmove from to fp */ - -{"fmovecrx", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7"}, /* fmovecr.x #ccc, FPn */ -{"fmovecr", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7"}, - -/* Other fmovemx. */ -{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s"}, /* fmovem.x to autodecrement, static and dynamic */ -{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s"}, /* fmovem.x to autodecrement, static and dynamic */ - -{"fmovemx", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s"}, /* fmovem.x to autodecrement, static and dynamic */ - -{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3"}, /* fmovem.x from control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk"}, /* fmovem.x from control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3"}, /* fmovem.x from control, static and dynamic: */ - -{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovemx", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk"}, /* fmovem.x from autoincrement, static and dynamic: */ - -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8@s"}, -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Ii#8@s"}, -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, - -{"fmoveml", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8"}, -{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*s#8"}, -{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8"}, - -/* fmovemx with register lists */ -{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s"}, /* fmovem.x to autodecrement, static and dynamic */ -{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3"}, /* fmovem.x from control, static and dynamic: */ - - /* Alternate mnemonics for GNU as and GNU CC */ -{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s"}, /* fmovem.x to autodecrement, static and dynamic */ -{"fmovem", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s"}, /* fmovem.x to autodecrement, static and dynamic */ - -{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovem", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s"}, /* fmovem.x to control, static and dynamic: */ - -{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovem", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk"}, /* fmovem.x from autoincrement, static and dynamic: */ - -{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3"}, /* fmovem.x from control, static and dynamic: */ -{"fmovem", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk"}, /* fmovem.x from control, static and dynamic: */ - -/* fmoveml a FP-control register */ -{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, -{"fmovem", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8"}, - -/* fmoveml a FP-control reglist */ -{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8@s"}, -{"fmovem", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8"}, - -{"fmulb", two(0xF000, 0x5823), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fmuld", two(0xF000, 0x5423), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fmull", two(0xF000, 0x4023), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fmulp", two(0xF000, 0x4C23), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fmuls", two(0xF000, 0x4423), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fmulw", two(0xF000, 0x5023), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fmulx", two(0xF000, 0x4823), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"fnegb", two(0xF000, 0x581A), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fnegd", two(0xF000, 0x541A), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fnegl", two(0xF000, 0x401A), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fnegp", two(0xF000, 0x4C1A), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fnegs", two(0xF000, 0x441A), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fnegw", two(0xF000, 0x501A), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fnegx", two(0xF000, 0x481A), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fnop", two(0xF280, 0x0000), two(0xFFFF, 0xFFFF), "Ii"}, - -{"fremb", two(0xF000, 0x5825), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fremd", two(0xF000, 0x5425), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"freml", two(0xF000, 0x4025), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fremp", two(0xF000, 0x4C25), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"frems", two(0xF000, 0x4425), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fremw", two(0xF000, 0x5025), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fremx", two(0xF000, 0x4825), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"frestore", one(0xF140), one(0xF1C0), "Id&s"}, -{"frestore", one(0xF158), one(0xF1F8), "Id+s"}, -{"fsave", one(0xF100), one(0xF1C0), "Id&s"}, -{"fsave", one(0xF120), one(0xF1F8), "Id-s"}, - -{"fsincosb", two(0xF000, 0x5830), two(0xF1C0, 0xFC78), "Ii;bF7FC"}, -{"fsincosd", two(0xF000, 0x5430), two(0xF1C0, 0xFC78), "Ii;FF7FC"}, -{"fsincosl", two(0xF000, 0x4030), two(0xF1C0, 0xFC78), "Ii;lF7FC"}, -{"fsincosp", two(0xF000, 0x4C30), two(0xF1C0, 0xFC78), "Ii;pF7FC"}, -{"fsincoss", two(0xF000, 0x4430), two(0xF1C0, 0xFC78), "Ii;fF7FC"}, -{"fsincosw", two(0xF000, 0x5030), two(0xF1C0, 0xFC78), "Ii;wF7FC"}, -{"fsincosx", two(0xF000, 0x0030), two(0xF1C0, 0xE078), "IiF8F7FC"}, -{"fsincosx", two(0xF000, 0x4830), two(0xF1C0, 0xFC78), "Ii;xF7FC"}, - -{"fscaleb", two(0xF000, 0x5826), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fscaled", two(0xF000, 0x5426), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fscalel", two(0xF000, 0x4026), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fscalep", two(0xF000, 0x4C26), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fscales", two(0xF000, 0x4426), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fscalew", two(0xF000, 0x5026), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fscalex", two(0xF000, 0x4826), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -/* $ is necessary to prevent the assembler from using PC-relative. - If @ were used, "label: fseq label" could produce "ftrapeq", - because "label" became "pc@label". */ -{"fseq", two(0xF040, 0x0001), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsf", two(0xF040, 0x0000), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsge", two(0xF040, 0x0013), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsgl", two(0xF040, 0x0016), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsgle", two(0xF040, 0x0017), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsgt", two(0xF040, 0x0012), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsle", two(0xF040, 0x0015), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fslt", two(0xF040, 0x0014), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsne", two(0xF040, 0x000E), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsnge", two(0xF040, 0x001C), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsngl", two(0xF040, 0x0019), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsngle", two(0xF040, 0x0018), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsngt", two(0xF040, 0x001D), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsnle", two(0xF040, 0x001A), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsnlt", two(0xF040, 0x001B), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsoge", two(0xF040, 0x0003), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsogl", two(0xF040, 0x0006), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsogt", two(0xF040, 0x0002), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsole", two(0xF040, 0x0005), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsolt", two(0xF040, 0x0004), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsor", two(0xF040, 0x0007), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsseq", two(0xF040, 0x0011), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fssf", two(0xF040, 0x0010), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fssne", two(0xF040, 0x001E), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsst", two(0xF040, 0x001F), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fst", two(0xF040, 0x000F), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsueq", two(0xF040, 0x0009), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsuge", two(0xF040, 0x000B), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsugt", two(0xF040, 0x000A), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsule", two(0xF040, 0x000D), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsult", two(0xF040, 0x000C), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsun", two(0xF040, 0x0008), two(0xF1C0, 0xFFFF), "Ii$s"}, - -{"fsgldivb", two(0xF000, 0x5824), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsgldivd", two(0xF000, 0x5424), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsgldivl", two(0xF000, 0x4024), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsgldivp", two(0xF000, 0x4C24), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsgldivs", two(0xF000, 0x4424), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsgldivw", two(0xF000, 0x5024), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsgldivx", two(0xF000, 0x4824), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsglmulb", two(0xF000, 0x5827), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsglmuld", two(0xF000, 0x5427), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsglmull", two(0xF000, 0x4027), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsglmulp", two(0xF000, 0x4C27), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsglmuls", two(0xF000, 0x4427), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsglmulw", two(0xF000, 0x5027), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsglmulx", two(0xF000, 0x4827), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsinb", two(0xF000, 0x580E), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsind", two(0xF000, 0x540E), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsinl", two(0xF000, 0x400E), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsinp", two(0xF000, 0x4C0E), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsins", two(0xF000, 0x440E), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsinw", two(0xF000, 0x500E), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsinx", two(0xF000, 0x480E), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsinhb", two(0xF000, 0x5802), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsinhd", two(0xF000, 0x5402), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsinhl", two(0xF000, 0x4002), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsinhp", two(0xF000, 0x4C02), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsinhs", two(0xF000, 0x4402), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsinhw", two(0xF000, 0x5002), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsinhx", two(0xF000, 0x4802), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsqrtb", two(0xF000, 0x5804), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsqrtd", two(0xF000, 0x5404), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsqrtl", two(0xF000, 0x4004), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsqrtp", two(0xF000, 0x4C04), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsqrts", two(0xF000, 0x4404), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsqrtw", two(0xF000, 0x5004), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsqrtx", two(0xF000, 0x4804), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsubb", two(0xF000, 0x5828), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsubd", two(0xF000, 0x5428), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsubl", two(0xF000, 0x4028), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsubp", two(0xF000, 0x4C28), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsubs", two(0xF000, 0x4428), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsubw", two(0xF000, 0x5028), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsubx", two(0xF000, 0x4828), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftanb", two(0xF000, 0x580F), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftand", two(0xF000, 0x540F), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftanl", two(0xF000, 0x400F), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftanp", two(0xF000, 0x4C0F), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftans", two(0xF000, 0x440F), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftanw", two(0xF000, 0x500F), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftanx", two(0xF000, 0x480F), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftanhb", two(0xF000, 0x5809), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftanhd", two(0xF000, 0x5409), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftanhl", two(0xF000, 0x4009), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftanhp", two(0xF000, 0x4C09), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftanhs", two(0xF000, 0x4409), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftanhw", two(0xF000, 0x5009), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftanhx", two(0xF000, 0x4809), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftentoxb", two(0xF000, 0x5812), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftentoxd", two(0xF000, 0x5412), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftentoxl", two(0xF000, 0x4012), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftentoxp", two(0xF000, 0x4C12), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftentoxs", two(0xF000, 0x4412), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftentoxw", two(0xF000, 0x5012), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftentoxx", two(0xF000, 0x4812), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftrapeq", two(0xF07C, 0x0001), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapf", two(0xF07C, 0x0000), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapge", two(0xF07C, 0x0013), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapgl", two(0xF07C, 0x0016), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapgle", two(0xF07C, 0x0017), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapgt", two(0xF07C, 0x0012), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftraple", two(0xF07C, 0x0015), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftraplt", two(0xF07C, 0x0014), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapne", two(0xF07C, 0x000E), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapnge", two(0xF07C, 0x001C), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapngl", two(0xF07C, 0x0019), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapngle", two(0xF07C, 0x0018), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapngt", two(0xF07C, 0x001D), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapnle", two(0xF07C, 0x001A), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapnlt", two(0xF07C, 0x001B), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapoge", two(0xF07C, 0x0003), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapogl", two(0xF07C, 0x0006), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapogt", two(0xF07C, 0x0002), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapole", two(0xF07C, 0x0005), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapolt", two(0xF07C, 0x0004), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapor", two(0xF07C, 0x0007), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapseq", two(0xF07C, 0x0011), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapsf", two(0xF07C, 0x0010), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapsne", two(0xF07C, 0x001E), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapst", two(0xF07C, 0x001F), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapt", two(0xF07C, 0x000F), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapueq", two(0xF07C, 0x0009), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapuge", two(0xF07C, 0x000B), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapugt", two(0xF07C, 0x000A), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapule", two(0xF07C, 0x000D), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapult", two(0xF07C, 0x000C), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapun", two(0xF07C, 0x0008), two(0xF1FF, 0xFFFF), "Ii"}, - -{"ftrapeqw", two(0xF07A, 0x0001), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapfw", two(0xF07A, 0x0000), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapgew", two(0xF07A, 0x0013), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapglw", two(0xF07A, 0x0016), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapglew", two(0xF07A, 0x0017), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapgtw", two(0xF07A, 0x0012), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftraplew", two(0xF07A, 0x0015), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapltw", two(0xF07A, 0x0014), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnew", two(0xF07A, 0x000E), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapngew", two(0xF07A, 0x001C), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnglw", two(0xF07A, 0x0019), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnglew", two(0xF07A, 0x0018), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapngtw", two(0xF07A, 0x001D), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnlew", two(0xF07A, 0x001A), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnltw", two(0xF07A, 0x001B), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapogew", two(0xF07A, 0x0003), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapoglw", two(0xF07A, 0x0006), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapogtw", two(0xF07A, 0x0002), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapolew", two(0xF07A, 0x0005), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapoltw", two(0xF07A, 0x0004), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftraporw", two(0xF07A, 0x0007), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapseqw", two(0xF07A, 0x0011), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapsfw", two(0xF07A, 0x0010), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapsnew", two(0xF07A, 0x001E), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapstw", two(0xF07A, 0x001F), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftraptw", two(0xF07A, 0x000F), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapueqw", two(0xF07A, 0x0009), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapugew", two(0xF07A, 0x000B), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapugtw", two(0xF07A, 0x000A), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapulew", two(0xF07A, 0x000D), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapultw", two(0xF07A, 0x000C), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapunw", two(0xF07A, 0x0008), two(0xF1FF, 0xFFFF), "Ii^w"}, - -{"ftrapeql", two(0xF07B, 0x0001), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapfl", two(0xF07B, 0x0000), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapgel", two(0xF07B, 0x0013), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapgll", two(0xF07B, 0x0016), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapglel", two(0xF07B, 0x0017), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapgtl", two(0xF07B, 0x0012), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftraplel", two(0xF07B, 0x0015), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapltl", two(0xF07B, 0x0014), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnel", two(0xF07B, 0x000E), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapngel", two(0xF07B, 0x001C), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapngll", two(0xF07B, 0x0019), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnglel", two(0xF07B, 0x0018), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapngtl", two(0xF07B, 0x001D), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnlel", two(0xF07B, 0x001A), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnltl", two(0xF07B, 0x001B), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapogel", two(0xF07B, 0x0003), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapogll", two(0xF07B, 0x0006), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapogtl", two(0xF07B, 0x0002), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapolel", two(0xF07B, 0x0005), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapoltl", two(0xF07B, 0x0004), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftraporl", two(0xF07B, 0x0007), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapseql", two(0xF07B, 0x0011), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapsfl", two(0xF07B, 0x0010), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapsnel", two(0xF07B, 0x001E), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapstl", two(0xF07B, 0x001F), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftraptl", two(0xF07B, 0x000F), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapueql", two(0xF07B, 0x0009), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapugel", two(0xF07B, 0x000B), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapugtl", two(0xF07B, 0x000A), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapulel", two(0xF07B, 0x000D), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapultl", two(0xF07B, 0x000C), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapunl", two(0xF07B, 0x0008), two(0xF1FF, 0xFFFF), "Ii^l"}, - -{"ftstb", two(0xF000, 0x583A), two(0xF1C0, 0xFC7F), "Ii;b"}, -{"ftstd", two(0xF000, 0x543A), two(0xF1C0, 0xFC7F), "Ii;F"}, -{"ftstl", two(0xF000, 0x403A), two(0xF1C0, 0xFC7F), "Ii;l"}, -{"ftstp", two(0xF000, 0x4C3A), two(0xF1C0, 0xFC7F), "Ii;p"}, -{"ftsts", two(0xF000, 0x443A), two(0xF1C0, 0xFC7F), "Ii;f"}, -{"ftstw", two(0xF000, 0x503A), two(0xF1C0, 0xFC7F), "Ii;w"}, -{"ftstx", two(0xF000, 0x003A), two(0xF1C0, 0xE07F), "IiF8"}, -{"ftstx", two(0xF000, 0x483A), two(0xF1C0, 0xFC7F), "Ii;x"}, - -{"ftwotoxb", two(0xF000, 0x5811), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftwotoxd", two(0xF000, 0x5411), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftwotoxl", two(0xF000, 0x4011), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftwotoxp", two(0xF000, 0x4C11), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftwotoxs", two(0xF000, 0x4411), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftwotoxw", two(0xF000, 0x5011), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftwotoxx", two(0xF000, 0x4811), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiFt"}, - - -{"fjeq", one(0xF081), one(0xF1FF), "IdBc"}, -{"fjf", one(0xF080), one(0xF1FF), "IdBc"}, -{"fjge", one(0xF093), one(0xF1FF), "IdBc"}, -{"fjgl", one(0xF096), one(0xF1FF), "IdBc"}, -{"fjgle", one(0xF097), one(0xF1FF), "IdBc"}, -{"fjgt", one(0xF092), one(0xF1FF), "IdBc"}, -{"fjle", one(0xF095), one(0xF1FF), "IdBc"}, -{"fjlt", one(0xF094), one(0xF1FF), "IdBc"}, -{"fjne", one(0xF08E), one(0xF1FF), "IdBc"}, -{"fjnge", one(0xF09C), one(0xF1FF), "IdBc"}, -{"fjngl", one(0xF099), one(0xF1FF), "IdBc"}, -{"fjngle", one(0xF098), one(0xF1FF), "IdBc"}, -{"fjngt", one(0xF09D), one(0xF1FF), "IdBc"}, -{"fjnle", one(0xF09A), one(0xF1FF), "IdBc"}, -{"fjnlt", one(0xF09B), one(0xF1FF), "IdBc"}, -{"fjoge", one(0xF083), one(0xF1FF), "IdBc"}, -{"fjogl", one(0xF086), one(0xF1FF), "IdBc"}, -{"fjogt", one(0xF082), one(0xF1FF), "IdBc"}, -{"fjole", one(0xF085), one(0xF1FF), "IdBc"}, -{"fjolt", one(0xF084), one(0xF1FF), "IdBc"}, -{"fjor", one(0xF087), one(0xF1FF), "IdBc"}, -{"fjseq", one(0xF091), one(0xF1FF), "IdBc"}, -{"fjsf", one(0xF090), one(0xF1FF), "IdBc"}, -{"fjsne", one(0xF09E), one(0xF1FF), "IdBc"}, -{"fjst", one(0xF09F), one(0xF1FF), "IdBc"}, -{"fjt", one(0xF08F), one(0xF1FF), "IdBc"}, -{"fjueq", one(0xF089), one(0xF1FF), "IdBc"}, -{"fjuge", one(0xF08B), one(0xF1FF), "IdBc"}, -{"fjugt", one(0xF08A), one(0xF1FF), "IdBc"}, -{"fjule", one(0xF08D), one(0xF1FF), "IdBc"}, -{"fjult", one(0xF08C), one(0xF1FF), "IdBc"}, -{"fjun", one(0xF088), one(0xF1FF), "IdBc"}, - -/* The assembler will ignore attempts to force a short offset */ - -{"bhis", one(0061000), one(0177400), "Bg"}, -{"blss", one(0061400), one(0177400), "Bg"}, -{"bccs", one(0062000), one(0177400), "Bg"}, -{"bcss", one(0062400), one(0177400), "Bg"}, -{"bnes", one(0063000), one(0177400), "Bg"}, -{"beqs", one(0063400), one(0177400), "Bg"}, -{"bvcs", one(0064000), one(0177400), "Bg"}, -{"bvss", one(0064400), one(0177400), "Bg"}, -{"bpls", one(0065000), one(0177400), "Bg"}, -{"bmis", one(0065400), one(0177400), "Bg"}, -{"bges", one(0066000), one(0177400), "Bg"}, -{"blts", one(0066400), one(0177400), "Bg"}, -{"bgts", one(0067000), one(0177400), "Bg"}, -{"bles", one(0067400), one(0177400), "Bg"}, - -/* Alternate mnemonics for SUN */ - -{"jbsr", one(0060400), one(0177400), "Bg"}, -{"jbsr", one(0047200), one(0177700), "!s"}, -{"jra", one(0060000), one(0177400), "Bg"}, -{"jra", one(0047300), one(0177700), "!s"}, - -{"jhi", one(0061000), one(0177400), "Bg"}, -{"jls", one(0061400), one(0177400), "Bg"}, -{"jcc", one(0062000), one(0177400), "Bg"}, -{"jcs", one(0062400), one(0177400), "Bg"}, -{"jne", one(0063000), one(0177400), "Bg"}, -{"jeq", one(0063400), one(0177400), "Bg"}, -{"jvc", one(0064000), one(0177400), "Bg"}, -{"jvs", one(0064400), one(0177400), "Bg"}, -{"jpl", one(0065000), one(0177400), "Bg"}, -{"jmi", one(0065400), one(0177400), "Bg"}, -{"jge", one(0066000), one(0177400), "Bg"}, -{"jlt", one(0066400), one(0177400), "Bg"}, -{"jgt", one(0067000), one(0177400), "Bg"}, -{"jle", one(0067400), one(0177400), "Bg"}, - -/* Short offsets are ignored */ - -{"jbsrs", one(0060400), one(0177400), "Bg"}, -{"jras", one(0060000), one(0177400), "Bg"}, -{"jhis", one(0061000), one(0177400), "Bg"}, -{"jlss", one(0061400), one(0177400), "Bg"}, -{"jccs", one(0062000), one(0177400), "Bg"}, -{"jcss", one(0062400), one(0177400), "Bg"}, -{"jnes", one(0063000), one(0177400), "Bg"}, -{"jeqs", one(0063400), one(0177400), "Bg"}, -{"jvcs", one(0064000), one(0177400), "Bg"}, -{"jvss", one(0064400), one(0177400), "Bg"}, -{"jpls", one(0065000), one(0177400), "Bg"}, -{"jmis", one(0065400), one(0177400), "Bg"}, -{"jges", one(0066000), one(0177400), "Bg"}, -{"jlts", one(0066400), one(0177400), "Bg"}, -{"jgts", one(0067000), one(0177400), "Bg"}, -{"jles", one(0067400), one(0177400), "Bg"}, - -{"movql", one(0070000), one(0170400), "MsDd"}, -{"moveql", one(0070000), one(0170400), "MsDd"}, -{"moval", one(0020100), one(0170700), "*lAd"}, -{"movaw", one(0030100), one(0170700), "*wAd"}, -{"movb", one(0010000), one(0170000), ";b$d"}, /* mov */ -{"movl", one(0070000), one(0170400), "MsDd"}, /* movq written as mov */ -{"movl", one(0020000), one(0170000), "*l$d"}, -{"movl", one(0020100), one(0170700), "*lAd"}, -{"movl", one(0047140), one(0177770), "AsUd"}, /* mov to USP */ -{"movl", one(0047150), one(0177770), "UdAs"}, /* mov from USP */ -{"movc", one(0047173), one(0177777), "R1Jj"}, -{"movc", one(0047173), one(0177777), "R1#j"}, -{"movc", one(0047172), one(0177777), "JjR1"}, -{"movc", one(0047172), one(0177777), "#jR1"}, -{"movml", one(0044300), one(0177700), "#w&s"}, /* movm reg to mem. */ -{"movml", one(0044340), one(0177770), "#w-s"}, /* movm reg to autodecrement. */ -{"movml", one(0046300), one(0177700), "!s#w"}, /* movm mem to reg. */ -{"movml", one(0046330), one(0177770), "+s#w"}, /* movm autoinc to reg. */ -{"movml", one(0044300), one(0177700), "Lw&s"}, /* movm reg to mem. */ -{"movml", one(0044340), one(0177770), "lw-s"}, /* movm reg to autodecrement. */ -{"movml", one(0046300), one(0177700), "!sLw"}, /* movm mem to reg. */ -{"movml", one(0046330), one(0177770), "+sLw"}, /* movm autoinc to reg. */ -{"movmw", one(0044200), one(0177700), "#w&s"}, /* movm reg to mem. */ -{"movmw", one(0044240), one(0177770), "#w-s"}, /* movm reg to autodecrement. */ -{"movmw", one(0046200), one(0177700), "!s#w"}, /* movm mem to reg. */ -{"movmw", one(0046230), one(0177770), "+s#w"}, /* movm autoinc to reg. */ -{"movmw", one(0044200), one(0177700), "Lw&s"}, /* movm reg to mem. */ -{"movmw", one(0044240), one(0177770), "lw-s"}, /* movm reg to autodecrement. */ -{"movmw", one(0046200), one(0177700), "!sLw"}, /* movm mem to reg. */ -{"movmw", one(0046230), one(0177770), "+sLw"}, /* movm autoinc to reg. */ -{"movpl", one(0000510), one(0170770), "dsDd"}, /* memory to register */ -{"movpl", one(0000710), one(0170770), "Ddds"}, /* register to memory */ -{"movpw", one(0000410), one(0170770), "dsDd"}, /* memory to register */ -{"movpw", one(0000610), one(0170770), "Ddds"}, /* register to memory */ -{"movq", one(0070000), one(0170400), "MsDd"}, -{"movw", one(0030000), one(0170000), "*w$d"}, -{"movw", one(0030100), one(0170700), "*wAd"}, /* mova, written as mov */ -{"movw", one(0040300), one(0177700), "Ss$s"}, /* Move from sr */ -{"movw", one(0041300), one(0177700), "Cs$s"}, /* Move from ccr */ -{"movw", one(0042300), one(0177700), ";wCd"}, /* mov to ccr */ -{"movw", one(0043300), one(0177700), ";wSd"}, /* mov to sr */ - -{"movsb", two(0007000, 0), two(0177700, 07777), "~sR1"}, -{"movsb", two(0007000, 04000), two(0177700, 07777), "R1~s"}, -{"movsl", two(0007200, 0), two(0177700, 07777), "~sR1"}, -{"movsl", two(0007200, 04000), two(0177700, 07777), "R1~s"}, -{"movsw", two(0007100, 0), two(0177700, 07777), "~sR1"}, -{"movsw", two(0007100, 04000), two(0177700, 07777), "R1~s"}, - -#ifdef m68851 - /* name */ /* opcode */ /* match */ /* args */ - -{"pbac", one(0xf0c7), one(0xffbf), "Bc"}, -{"pbacw", one(0xf087), one(0xffbf), "Bc"}, -{"pbas", one(0xf0c6), one(0xffbf), "Bc"}, -{"pbasw", one(0xf086), one(0xffbf), "Bc"}, -{"pbbc", one(0xf0c1), one(0xffbf), "Bc"}, -{"pbbcw", one(0xf081), one(0xffbf), "Bc"}, -{"pbbs", one(0xf0c0), one(0xffbf), "Bc"}, -{"pbbsw", one(0xf080), one(0xffbf), "Bc"}, -{"pbcc", one(0xf0cf), one(0xffbf), "Bc"}, -{"pbccw", one(0xf08f), one(0xffbf), "Bc"}, -{"pbcs", one(0xf0ce), one(0xffbf), "Bc"}, -{"pbcsw", one(0xf08e), one(0xffbf), "Bc"}, -{"pbgc", one(0xf0cd), one(0xffbf), "Bc"}, -{"pbgcw", one(0xf08d), one(0xffbf), "Bc"}, -{"pbgs", one(0xf0cc), one(0xffbf), "Bc"}, -{"pbgsw", one(0xf08c), one(0xffbf), "Bc"}, -{"pbic", one(0xf0cb), one(0xffbf), "Bc"}, -{"pbicw", one(0xf08b), one(0xffbf), "Bc"}, -{"pbis", one(0xf0ca), one(0xffbf), "Bc"}, -{"pbisw", one(0xf08a), one(0xffbf), "Bc"}, -{"pblc", one(0xf0c3), one(0xffbf), "Bc"}, -{"pblcw", one(0xf083), one(0xffbf), "Bc"}, -{"pbls", one(0xf0c2), one(0xffbf), "Bc"}, -{"pblsw", one(0xf082), one(0xffbf), "Bc"}, -{"pbsc", one(0xf0c5), one(0xffbf), "Bc"}, -{"pbscw", one(0xf085), one(0xffbf), "Bc"}, -{"pbss", one(0xf0c4), one(0xffbf), "Bc"}, -{"pbssw", one(0xf084), one(0xffbf), "Bc"}, -{"pbwc", one(0xf0c9), one(0xffbf), "Bc"}, -{"pbwcw", one(0xf089), one(0xffbf), "Bc"}, -{"pbws", one(0xf0c8), one(0xffbf), "Bc"}, -{"pbwsw", one(0xf088), one(0xffbf), "Bc"}, - - -{"pdbac", two(0xf048, 0x0007), two(0xfff8, 0xffff), "DsBw"}, -{"pdbas", two(0xf048, 0x0006), two(0xfff8, 0xffff), "DsBw"}, -{"pdbbc", two(0xf048, 0x0001), two(0xfff8, 0xffff), "DsBw"}, -{"pdbbs", two(0xf048, 0x0000), two(0xfff8, 0xffff), "DsBw"}, -{"pdbcc", two(0xf048, 0x000f), two(0xfff8, 0xffff), "DsBw"}, -{"pdbcs", two(0xf048, 0x000e), two(0xfff8, 0xffff), "DsBw"}, -{"pdbgc", two(0xf048, 0x000d), two(0xfff8, 0xffff), "DsBw"}, -{"pdbgs", two(0xf048, 0x000c), two(0xfff8, 0xffff), "DsBw"}, -{"pdbic", two(0xf048, 0x000b), two(0xfff8, 0xffff), "DsBw"}, -{"pdbis", two(0xf048, 0x000a), two(0xfff8, 0xffff), "DsBw"}, -{"pdblc", two(0xf048, 0x0003), two(0xfff8, 0xffff), "DsBw"}, -{"pdbls", two(0xf048, 0x0002), two(0xfff8, 0xffff), "DsBw"}, -{"pdbsc", two(0xf048, 0x0005), two(0xfff8, 0xffff), "DsBw"}, -{"pdbss", two(0xf048, 0x0004), two(0xfff8, 0xffff), "DsBw"}, -{"pdbwc", two(0xf048, 0x0009), two(0xfff8, 0xffff), "DsBw"}, -{"pdbws", two(0xf048, 0x0008), two(0xfff8, 0xffff), "DsBw"}, - -{"pflusha", two(0xf000, 0x2400), two(0xffff, 0xffff), "" }, - -{"pflush", two(0xf000, 0x3010), two(0xffc0, 0xfe10), "T3T9" }, -{"pflush", two(0xf000, 0x3810), two(0xffc0, 0xfe10), "T3T9&s" }, -{"pflush", two(0xf000, 0x3008), two(0xffc0, 0xfe18), "D3T9" }, -{"pflush", two(0xf000, 0x3808), two(0xffc0, 0xfe18), "D3T9&s" }, -{"pflush", two(0xf000, 0x3000), two(0xffc0, 0xfe1e), "f3T9" }, -{"pflush", two(0xf000, 0x3800), two(0xffc0, 0xfe1e), "f3T9&s" }, - -{"pflushs", two(0xf000, 0x3410), two(0xfff8, 0xfe10), "T3T9" }, -{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe00), "T3T9&s" }, -{"pflushs", two(0xf000, 0x3408), two(0xfff8, 0xfe18), "D3T9" }, -{"pflushs", two(0xf000, 0x3c08), two(0xfff8, 0xfe18), "D3T9&s" }, -{"pflushs", two(0xf000, 0x3400), two(0xfff8, 0xfe1e), "f3T9" }, -{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe1e), "f3T9&s"}, - -{"pflushr", two(0xf000, 0xa000), two(0xffc0, 0xffff), "|s" }, - -{"ploadr", two(0xf000, 0x2210), two(0xffc0, 0xfff0), "T3&s" }, -{"ploadr", two(0xf000, 0x2208), two(0xffc0, 0xfff8), "D3&s" }, -{"ploadr", two(0xf000, 0x2200), two(0xffc0, 0xfffe), "f3&s" }, -{"ploadw", two(0xf000, 0x2010), two(0xffc0, 0xfff0), "T3&s" }, -{"ploadw", two(0xf000, 0x2008), two(0xffc0, 0xfff8), "D3&s" }, -{"ploadw", two(0xf000, 0x2000), two(0xffc0, 0xfffe), "f3&s" }, - -/* TC, CRP, DRP, SRP, CAL, VAL, SCC, AC */ -{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "*sP8" }, -{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "P8%s" }, -{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "|sW8" }, -{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "W8~s" }, - -/* BADx, BACx */ -{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xe3e3), "*sX3" }, -{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xe3e3), "X3%s" }, - -/* PSR, PCSR */ -/* {"pmove", two(0xf000, 0x6100), two(oxffc0, oxffff), "*sZ8" }, */ -{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xffff), "*sY8" }, -{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xffff), "Y8%s" }, -{"pmove", two(0xf000, 0x6600), two(0xffc0, 0xffff), "Z8%s" }, - -{"prestore", one(0xf140), one(0xffc0), "&s"}, -{"prestore", one(0xf158), one(0xfff8), "+s"}, -{"psave", one(0xf100), one(0xffc0), "&s"}, -{"psave", one(0xf100), one(0xffc0), "+s"}, - -{"psac", two(0xf040, 0x0007), two(0xffc0, 0xffff), "@s"}, -{"psas", two(0xf040, 0x0006), two(0xffc0, 0xffff), "@s"}, -{"psbc", two(0xf040, 0x0001), two(0xffc0, 0xffff), "@s"}, -{"psbs", two(0xf040, 0x0000), two(0xffc0, 0xffff), "@s"}, -{"pscc", two(0xf040, 0x000f), two(0xffc0, 0xffff), "@s"}, -{"pscs", two(0xf040, 0x000e), two(0xffc0, 0xffff), "@s"}, -{"psgc", two(0xf040, 0x000d), two(0xffc0, 0xffff), "@s"}, -{"psgs", two(0xf040, 0x000c), two(0xffc0, 0xffff), "@s"}, -{"psic", two(0xf040, 0x000b), two(0xffc0, 0xffff), "@s"}, -{"psis", two(0xf040, 0x000a), two(0xffc0, 0xffff), "@s"}, -{"pslc", two(0xf040, 0x0003), two(0xffc0, 0xffff), "@s"}, -{"psls", two(0xf040, 0x0002), two(0xffc0, 0xffff), "@s"}, -{"pssc", two(0xf040, 0x0005), two(0xffc0, 0xffff), "@s"}, -{"psss", two(0xf040, 0x0004), two(0xffc0, 0xffff), "@s"}, -{"pswc", two(0xf040, 0x0009), two(0xffc0, 0xffff), "@s"}, -{"psws", two(0xf040, 0x0008), two(0xffc0, 0xffff), "@s"}, - -{"ptestr", two(0xf000, 0x8210), two(0xffc0, 0xe3f0), "T3&sQ8" }, -{"ptestr", two(0xf000, 0x8310), two(0xffc0, 0xe310), "T3&sQ8A9" }, -{"ptestr", two(0xf000, 0x8208), two(0xffc0, 0xe3f8), "D3&sQ8" }, -{"ptestr", two(0xf000, 0x8308), two(0xffc0, 0xe318), "D3&sQ8A9" }, -{"ptestr", two(0xf000, 0x8200), two(0xffc0, 0xe3fe), "f3&sQ8" }, -{"ptestr", two(0xf000, 0x8300), two(0xffc0, 0xe31e), "f3&sQ8A9" }, - -{"ptestw", two(0xf000, 0x8010), two(0xffc0, 0xe3f0), "T3&sQ8" }, -{"ptestw", two(0xf000, 0x8110), two(0xffc0, 0xe310), "T3&sQ8A9" }, -{"ptestw", two(0xf000, 0x8008), two(0xffc0, 0xe3f8), "D3&sQ8" }, -{"ptestw", two(0xf000, 0x8108), two(0xffc0, 0xe318), "D3&sQ8A9" }, -{"ptestw", two(0xf000, 0x8000), two(0xffc0, 0xe3fe), "f3&sQ8" }, -{"ptestw", two(0xf000, 0x8100), two(0xffc0, 0xe31e), "f3&sQ8A9" }, - -{"ptrapacw", two(0xf07a, 0x0007), two(0xffff, 0xffff), "#w"}, -{"ptrapacl", two(0xf07b, 0x0007), two(0xffff, 0xffff), "#l"}, -{"ptrapac", two(0xf07c, 0x0007), two(0xffff, 0xffff), ""}, - -{"ptrapasw", two(0xf07a, 0x0006), two(0xffff, 0xffff), "#w"}, -{"ptrapasl", two(0xf07b, 0x0006), two(0xffff, 0xffff), "#l"}, -{"ptrapas", two(0xf07c, 0x0006), two(0xffff, 0xffff), ""}, - -{"ptrapbcw", two(0xf07a, 0x0001), two(0xffff, 0xffff), "#w"}, -{"ptrapbcl", two(0xf07b, 0x0001), two(0xffff, 0xffff), "#l"}, -{"ptrapbc", two(0xf07c, 0x0001), two(0xffff, 0xffff), ""}, - -{"ptrapbsw", two(0xf07a, 0x0000), two(0xffff, 0xffff), "#w"}, -{"ptrapbsl", two(0xf07b, 0x0000), two(0xffff, 0xffff), "#l"}, -{"ptrapbs", two(0xf07c, 0x0000), two(0xffff, 0xffff), ""}, - -{"ptrapccw", two(0xf07a, 0x000f), two(0xffff, 0xffff), "#w"}, -{"ptrapccl", two(0xf07b, 0x000f), two(0xffff, 0xffff), "#l"}, -{"ptrapcc", two(0xf07c, 0x000f), two(0xffff, 0xffff), ""}, - -{"ptrapcsw", two(0xf07a, 0x000e), two(0xffff, 0xffff), "#w"}, -{"ptrapcsl", two(0xf07b, 0x000e), two(0xffff, 0xffff), "#l"}, -{"ptrapcs", two(0xf07c, 0x000e), two(0xffff, 0xffff), ""}, - -{"ptrapgcw", two(0xf07a, 0x000d), two(0xffff, 0xffff), "#w"}, -{"ptrapgcl", two(0xf07b, 0x000d), two(0xffff, 0xffff), "#l"}, -{"ptrapgc", two(0xf07c, 0x000d), two(0xffff, 0xffff), ""}, - -{"ptrapgsw", two(0xf07a, 0x000c), two(0xffff, 0xffff), "#w"}, -{"ptrapgsl", two(0xf07b, 0x000c), two(0xffff, 0xffff), "#l"}, -{"ptrapgs", two(0xf07c, 0x000c), two(0xffff, 0xffff), ""}, - -{"ptrapicw", two(0xf07a, 0x000b), two(0xffff, 0xffff), "#w"}, -{"ptrapicl", two(0xf07b, 0x000b), two(0xffff, 0xffff), "#l"}, -{"ptrapic", two(0xf07c, 0x000b), two(0xffff, 0xffff), ""}, - -{"ptrapisw", two(0xf07a, 0x000a), two(0xffff, 0xffff), "#w"}, -{"ptrapisl", two(0xf07b, 0x000a), two(0xffff, 0xffff), "#l"}, -{"ptrapis", two(0xf07c, 0x000a), two(0xffff, 0xffff), ""}, - -{"ptraplcw", two(0xf07a, 0x0003), two(0xffff, 0xffff), "#w"}, -{"ptraplcl", two(0xf07b, 0x0003), two(0xffff, 0xffff), "#l"}, -{"ptraplc", two(0xf07c, 0x0003), two(0xffff, 0xffff), ""}, - -{"ptraplsw", two(0xf07a, 0x0002), two(0xffff, 0xffff), "#w"}, -{"ptraplsl", two(0xf07b, 0x0002), two(0xffff, 0xffff), "#l"}, -{"ptrapls", two(0xf07c, 0x0002), two(0xffff, 0xffff), ""}, - -{"ptrapscw", two(0xf07a, 0x0005), two(0xffff, 0xffff), "#w"}, -{"ptrapscl", two(0xf07b, 0x0005), two(0xffff, 0xffff), "#l"}, -{"ptrapsc", two(0xf07c, 0x0005), two(0xffff, 0xffff), ""}, - -{"ptrapssw", two(0xf07a, 0x0004), two(0xffff, 0xffff), "#w"}, -{"ptrapssl", two(0xf07b, 0x0004), two(0xffff, 0xffff), "#l"}, -{"ptrapss", two(0xf07c, 0x0004), two(0xffff, 0xffff), ""}, - -{"ptrapwcw", two(0xf07a, 0x0009), two(0xffff, 0xffff), "#w"}, -{"ptrapwcl", two(0xf07b, 0x0009), two(0xffff, 0xffff), "#l"}, -{"ptrapwc", two(0xf07c, 0x0009), two(0xffff, 0xffff), ""}, - -{"ptrapwsw", two(0xf07a, 0x0008), two(0xffff, 0xffff), "#w"}, -{"ptrapwsl", two(0xf07b, 0x0008), two(0xffff, 0xffff), "#l"}, -{"ptrapws", two(0xf07c, 0x0008), two(0xffff, 0xffff), ""}, - -{"pvalid", two(0xf000, 0x2800), two(0xffc0, 0xffff), "Vs&s"}, -{"pvalid", two(0xf000, 0x2c00), two(0xffc0, 0xfff8), "A3&s" }, - -#endif /* m68851 */ - -}; - -int numopcodes=sizeof(m68k_opcodes)/sizeof(m68k_opcodes[0]); - -struct m68k_opcode *endop = m68k_opcodes+sizeof(m68k_opcodes)/sizeof(m68k_opcodes[0]); diff --git a/gnu/usr.bin/gdb/config/m68k-pinsn.c b/gnu/usr.bin/gdb/config/m68k-pinsn.c deleted file mode 100644 index ac63259d787e..000000000000 --- a/gnu/usr.bin/gdb/config/m68k-pinsn.c +++ /dev/null @@ -1,902 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)m68k-pinsn.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: m68k-pinsn.c,v 1.2 1993/08/01 18:48:22 mycroft Exp $"; -#endif /* not lint */ - -/* Print m68k instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "m68k-opcode.h" - -/* 68k instructions are never longer than this many bytes. */ -#define MAXLEN 22 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof m68k_opcodes / sizeof m68k_opcodes[0]) - -extern char *reg_names[]; -char *fpcr_names[] = { "", "fpiar", "fpsr", "fpiar/fpsr", "fpcr", - "fpiar/fpcr", "fpsr/fpcr", "fpiar-fpcr"}; - -static unsigned char *print_insn_arg (); -static unsigned char *print_indexed (); -static void print_base (); -static int fetch_arg (); - -#define NEXTBYTE(p) (p += 2, ((char *)p)[-1]) - -#define NEXTWORD(p) \ - (p += 2, ((((char *)p)[-2]) << 8) + p[-1]) - -#define NEXTLONG(p) \ - (p += 4, (((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]) - -#define NEXTSINGLE(p) \ - (p += 4, *((float *)(p - 4))) - -#define NEXTDOUBLE(p) \ - (p += 8, *((double *)(p - 8))) - -#define NEXTEXTEND(p) \ - (p += 12, 0.0) /* Need a function to convert from extended to double - precision... */ - -#define NEXTPACKED(p) \ - (p += 12, 0.0) /* Need a function to convert from packed to double - precision. Actually, it's easier to print a - packed number than a double anyway, so maybe - there should be a special case to handle this... */ - -/* Print the m68k instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register unsigned char *p; - register char *d; - register int bestmask; - int best; - - read_memory (memaddr, buffer, MAXLEN); - - bestmask = 0; - best = -1; - for (i = 0; i < NOPCODES; i++) - { - register unsigned int opcode = m68k_opcodes[i].opcode; - register unsigned int match = m68k_opcodes[i].match; - if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24))) - && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16))) - && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8))) - && ((0xff & buffer[3] & match) == (0xff & opcode))) - { - /* Don't use for printout the variants of divul and divsl - that have the same register number in two places. - The more general variants will match instead. */ - for (d = m68k_opcodes[i].args; *d; d += 2) - if (d[1] == 'D') - break; - - /* Don't use for printout the variants of most floating - point coprocessor instructions which use the same - register number in two places, as above. */ - if (*d == 0) - for (d = m68k_opcodes[i].args; *d; d += 2) - if (d[1] == 't') - break; - - if (*d == 0 && match > bestmask) - { - best = i; - bestmask = match; - } - } - } - - /* Handle undefined instructions. */ - if (best < 0) - { - fprintf_filtered (stream, "0%o", (buffer[0] << 8) + buffer[1]); - return 2; - } - - fprintf_filtered (stream, "%s", m68k_opcodes[best].name); - - /* Point at first word of argument data, - and at descriptor for first argument. */ - p = buffer + 2; - - /* Why do this this way? -MelloN */ - for (d = m68k_opcodes[best].args; *d; d += 2) - { - if (d[0] == '#') - { - if (d[1] == 'l' && p - buffer < 6) - p = buffer + 6; - else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8' ) - p = buffer + 4; - } - if (d[1] >= '1' && d[1] <= '3' && p - buffer < 4) - p = buffer + 4; - if (d[1] >= '4' && d[1] <= '6' && p - buffer < 6) - p = buffer + 6; - if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4) - p = buffer + 4; - } - - d = m68k_opcodes[best].args; - - if (*d) - fputs_filtered (" ", stream); - - while (*d) - { - p = print_insn_arg (d, buffer, p, memaddr + p - buffer, stream); - d += 2; - if (*d && *(d - 2) != 'I' && *d != 'k') - fputs_filtered (",", stream); - } - return p - buffer; -} - -static unsigned char * -print_insn_arg (d, buffer, p, addr, stream) - char *d; - unsigned char *buffer; - register unsigned char *p; - CORE_ADDR addr; /* PC for this arg to be relative to */ - FILE *stream; -{ - register int val; - register int place = d[1]; - int regno; - register char *regname; - register unsigned char *p1; - register double flval; - int flt_p; - - switch (*d) - { - case 'C': - fprintf_filtered (stream, "ccr"); - break; - - case 'S': - fprintf_filtered (stream, "sr"); - break; - - case 'U': - fprintf_filtered (stream, "usp"); - break; - - case 'J': - { - static struct { char *name; int value; } names[] - = {{"sfc", 0x000}, {"dfc", 0x001}, {"cacr", 0x002}, - {"usp", 0x800}, {"vbr", 0x801}, {"caar", 0x802}, - {"msp", 0x803}, {"isp", 0x804}}; - - val = fetch_arg (buffer, place, 12); - for (regno = sizeof names / sizeof names[0] - 1; regno >= 0; regno--) - if (names[regno].value == val) - { - fprintf_filtered (stream, names[regno].name); - break; - } - if (regno < 0) - fprintf_filtered (stream, "%d", val); - } - break; - - case 'Q': - val = fetch_arg (buffer, place, 3); - if (val == 0) val = 8; - fprintf_filtered (stream, "#%d", val); - break; - - case 'M': - val = fetch_arg (buffer, place, 8); - if (val & 0x80) - val = val - 0x100; - fprintf_filtered (stream, "#%d", val); - break; - - case 'T': - val = fetch_arg (buffer, place, 4); - fprintf_filtered (stream, "#%d", val); - break; - - case 'D': - fprintf_filtered (stream, "%s", reg_names[fetch_arg (buffer, place, 3)]); - break; - - case 'A': - fprintf_filtered (stream, "%s", - reg_names[fetch_arg (buffer, place, 3) + 010]); - break; - - case 'R': - fprintf_filtered (stream, "%s", reg_names[fetch_arg (buffer, place, 4)]); - break; - - case 'F': - fprintf_filtered (stream, "fp%d", fetch_arg (buffer, place, 3)); - break; - - case 'O': - val = fetch_arg (buffer, place, 6); - if (val & 0x20) - fprintf_filtered (stream, "%s", reg_names [val & 7]); - else - fprintf_filtered (stream, "%d", val); - break; - - case '+': - fprintf_filtered (stream, "%s@+", - reg_names[fetch_arg (buffer, place, 3) + 8]); - break; - - case '-': - fprintf_filtered (stream, "%s@-", - reg_names[fetch_arg (buffer, place, 3) + 8]); - break; - - case 'k': - if (place == 'k') - fprintf_filtered (stream, "{%s}", reg_names[fetch_arg (buffer, place, 3)]); - else if (place == 'C') - { - val = fetch_arg (buffer, place, 7); - if ( val > 63 ) /* This is a signed constant. */ - val -= 128; - fprintf_filtered (stream, "{#%d}", val); - } - else - error ("Invalid arg format in opcode table: \"%c%c\".", - *d, place); - break; - - case '#': - case '^': - p1 = buffer + (*d == '#' ? 2 : 4); - if (place == 's') - val = fetch_arg (buffer, place, 4); - else if (place == 'C') - val = fetch_arg (buffer, place, 7); - else if (place == '8') - val = fetch_arg (buffer, place, 3); - else if (place == '3') - val = fetch_arg (buffer, place, 8); - else if (place == 'b') - val = NEXTBYTE (p1); - else if (place == 'w') - val = NEXTWORD (p1); - else if (place == 'l') - val = NEXTLONG (p1); - else - error ("Invalid arg format in opcode table: \"%c%c\".", - *d, place); - fprintf_filtered (stream, "#%d", val); - break; - - case 'B': - if (place == 'b') - val = NEXTBYTE (p); - else if (place == 'w') - val = NEXTWORD (p); - else if (place == 'l') - val = NEXTLONG (p); - else if (place == 'g') - { - val = ((char *)buffer)[1]; - if (val == 0) - val = NEXTWORD (p); - else if (val == -1) - val = NEXTLONG (p); - } - else if (place == 'c') - { - if (buffer[1] & 0x40) /* If bit six is one, long offset */ - val = NEXTLONG (p); - else - val = NEXTWORD (p); - } - else - error ("Invalid arg format in opcode table: \"%c%c\".", - *d, place); - - print_address (addr + val, stream); - break; - - case 'd': - val = NEXTWORD (p); - fprintf_filtered (stream, "%s@(%d)", - reg_names[fetch_arg (buffer, place, 3)], val); - break; - - case 's': - fprintf_filtered (stream, "%s", - fpcr_names[fetch_arg (buffer, place, 3)]); - break; - - case 'I': - val = fetch_arg (buffer, 'd', 3); /* Get coprocessor ID... */ - if (val != 1) /* Unusual coprocessor ID? */ - fprintf_filtered (stream, "(cpid=%d) ", val); - if (place == 'i') - p += 2; /* Skip coprocessor extended operands */ - break; - - case '*': - case '~': - case '%': - case ';': - case '@': - case '!': - case '$': - case '?': - case '/': - case '&': - - if (place == 'd') - { - val = fetch_arg (buffer, 'x', 6); - val = ((val & 7) << 3) + ((val >> 3) & 7); - } - else - val = fetch_arg (buffer, 's', 6); - - /* Get register number assuming address register. */ - regno = (val & 7) + 8; - regname = reg_names[regno]; - switch (val >> 3) - { - case 0: - fprintf_filtered (stream, "%s", reg_names[val]); - break; - - case 1: - fprintf_filtered (stream, "%s", regname); - break; - - case 2: - fprintf_filtered (stream, "%s@", regname); - break; - - case 3: - fprintf_filtered (stream, "%s@+", regname); - break; - - case 4: - fprintf_filtered (stream, "%s@-", regname); - break; - - case 5: - val = NEXTWORD (p); - fprintf_filtered (stream, "%s@(%d)", regname, val); - break; - - case 6: - p = print_indexed (regno, p, addr, stream); - break; - - case 7: - switch (val & 7) - { - case 0: - val = NEXTWORD (p); - fprintf_filtered (stream, "@#"); - print_address (val, stream); - break; - - case 1: - val = NEXTLONG (p); - fprintf_filtered (stream, "@#"); - print_address (val, stream); - break; - - case 2: - val = NEXTWORD (p); - print_address (addr + val, stream); - break; - - case 3: - p = print_indexed (-1, p, addr, stream); - break; - - case 4: - flt_p = 1; /* Assume it's a float... */ - switch( place ) - { - case 'b': - val = NEXTBYTE (p); - flt_p = 0; - break; - - case 'w': - val = NEXTWORD (p); - flt_p = 0; - break; - - case 'l': - val = NEXTLONG (p); - flt_p = 0; - break; - - case 'f': - flval = NEXTSINGLE(p); - break; - - case 'F': - flval = NEXTDOUBLE(p); - break; - - case 'x': - flval = NEXTEXTEND(p); - break; - - case 'p': - flval = NEXTPACKED(p); - break; - - default: - error ("Invalid arg format in opcode table: \"%c%c\".", - *d, place); - } - if ( flt_p ) /* Print a float? */ - fprintf_filtered (stream, "#%g", flval); - else - fprintf_filtered (stream, "#%d", val); - break; - - default: - fprintf_filtered (stream, "", val); - } - } - break; - - case 'L': - case 'l': - if (place == 'w') - { - char doneany; - p1 = buffer + 2; - val = NEXTWORD (p1); - /* Move the pointer ahead if this point is farther ahead - than the last. */ - p = p1 > p ? p1 : p; - if (val == 0) - { - fputs_filtered ("#0", stream); - break; - } - if (*d == 'l') - { - register int newval = 0; - for (regno = 0; regno < 16; ++regno) - if (val & (0x8000 >> regno)) - newval |= 1 << regno; - val = newval; - } - val &= 0xffff; - doneany = 0; - for (regno = 0; regno < 16; ++regno) - if (val & (1 << regno)) - { - int first_regno; - if (doneany) - fputs_filtered ("/", stream); - doneany = 1; - fprintf_filtered (stream, "%s", reg_names[regno]); - first_regno = regno; - while (val & (1 << (regno + 1))) - ++regno; - if (regno > first_regno) - fprintf_filtered (stream, "-%s", reg_names[regno]); - } - } - else if (place == '3') - { - /* `fmovem' insn. */ - char doneany; - val = fetch_arg (buffer, place, 8); - if (val == 0) - { - fputs_filtered ("#0", stream); - break; - } - if (*d == 'l') - { - register int newval = 0; - for (regno = 0; regno < 8; ++regno) - if (val & (0x80 >> regno)) - newval |= 1 << regno; - val = newval; - } - val &= 0xff; - doneany = 0; - for (regno = 0; regno < 8; ++regno) - if (val & (1 << regno)) - { - int first_regno; - if (doneany) - fputs_filtered ("/", stream); - doneany = 1; - fprintf_filtered (stream, "fp%d", regno); - first_regno = regno; - while (val & (1 << (regno + 1))) - ++regno; - if (regno > first_regno) - fprintf_filtered (stream, "-fp%d", regno); - } - } - else - abort (); - break; - - default: - error ("Invalid arg format in opcode table: \"%c\".", *d); - } - - return (unsigned char *) p; -} - -/* Fetch BITS bits from a position in the instruction specified by CODE. - CODE is a "place to put an argument", or 'x' for a destination - that is a general address (mode and register). - BUFFER contains the instruction. */ - -static int -fetch_arg (buffer, code, bits) - unsigned char *buffer; - char code; - int bits; -{ - register int val; - switch (code) - { - case 's': - val = buffer[1]; - break; - - case 'd': /* Destination, for register or quick. */ - val = (buffer[0] << 8) + buffer[1]; - val >>= 9; - break; - - case 'x': /* Destination, for general arg */ - val = (buffer[0] << 8) + buffer[1]; - val >>= 6; - break; - - case 'k': - val = (buffer[3] >> 4); - break; - - case 'C': - val = buffer[3]; - break; - - case '1': - val = (buffer[2] << 8) + buffer[3]; - val >>= 12; - break; - - case '2': - val = (buffer[2] << 8) + buffer[3]; - val >>= 6; - break; - - case '3': - case 'j': - val = (buffer[2] << 8) + buffer[3]; - break; - - case '4': - val = (buffer[4] << 8) + buffer[5]; - val >>= 12; - break; - - case '5': - val = (buffer[4] << 8) + buffer[5]; - val >>= 6; - break; - - case '6': - val = (buffer[4] << 8) + buffer[5]; - break; - - case '7': - val = (buffer[2] << 8) + buffer[3]; - val >>= 7; - break; - - case '8': - val = (buffer[2] << 8) + buffer[3]; - val >>= 10; - break; - - default: - abort (); - } - - switch (bits) - { - case 3: - return val & 7; - case 4: - return val & 017; - case 5: - return val & 037; - case 6: - return val & 077; - case 7: - return val & 0177; - case 8: - return val & 0377; - case 12: - return val & 07777; - default: - abort (); - } -} - -/* Print an indexed argument. The base register is BASEREG (-1 for pc). - P points to extension word, in buffer. - ADDR is the nominal core address of that extension word. */ - -static unsigned char * -print_indexed (basereg, p, addr, stream) - int basereg; - unsigned char *p; - FILE *stream; - CORE_ADDR addr; -{ - register int word; - static char *scales[] = {"", "*2", "*4", "*8"}; - register int base_disp; - register int outer_disp; - char buf[40]; - - word = NEXTWORD (p); - - /* Generate the text for the index register. - Where this will be output is not yet determined. */ - sprintf (buf, "[%s.%c%s]", - reg_names[(word >> 12) & 0xf], - (word & 0x800) ? 'l' : 'w', - scales[(word >> 9) & 3]); - - /* Handle the 68000 style of indexing. */ - - if ((word & 0x100) == 0) - { - print_base (basereg, - ((word & 0x80) ? word | 0xff00 : word & 0xff) - + ((basereg == -1) ? addr : 0), - stream); - fputs_filtered (buf, stream); - return p; - } - - /* Handle the generalized kind. */ - /* First, compute the displacement to add to the base register. */ - - if (word & 0200) - basereg = -2; - if (word & 0100) - buf[0] = 0; - base_disp = 0; - switch ((word >> 4) & 3) - { - case 2: - base_disp = NEXTWORD (p); - break; - case 3: - base_disp = NEXTLONG (p); - } - if (basereg == -1) - base_disp += addr; - - /* Handle single-level case (not indirect) */ - - if ((word & 7) == 0) - { - print_base (basereg, base_disp, stream); - fputs_filtered (buf, stream); - return p; - } - - /* Two level. Compute displacement to add after indirection. */ - - outer_disp = 0; - switch (word & 3) - { - case 2: - outer_disp = NEXTWORD (p); - break; - case 3: - outer_disp = NEXTLONG (p); - } - - fprintf_filtered (stream, "%d(", outer_disp); - print_base (basereg, base_disp, stream); - - /* If postindexed, print the closeparen before the index. */ - if (word & 4) - fprintf_filtered (stream, ")%s", buf); - /* If preindexed, print the closeparen after the index. */ - else - fprintf_filtered (stream, "%s)", buf); - - return p; -} - -/* Print a base register REGNO and displacement DISP, on STREAM. - REGNO = -1 for pc, -2 for none (suppressed). */ - -static void -print_base (regno, disp, stream) - int regno; - int disp; - FILE *stream; -{ - if (regno == -2) - fprintf_filtered (stream, "%d", disp); - else if (regno == -1) - fprintf_filtered (stream, "0x%x", disp); - else - fprintf_filtered (stream, "%d(%s)", disp, reg_names[regno]); -} - -/* Nonzero if the host system has a 68881 (or compatible) - floating-point unit. This does *not* indicate whether the target - system has a co-processor, just whether the host system does. - There might be a difference in the case of remote debugging. */ -static int have_fpu = 1; - -/* This is not part of insn printing, but it is machine-specific, - so this is a convenient place to put it. - - Convert a 68881 extended float to a double. - FROM is the address of the extended float. - Store the double in *TO. */ - -convert_from_68881 (from, to) - char *from; - double *to; -{ - if (!have_fpu) - { - *to = 0.0; - return; - } - else - { -#ifdef HPUX_ASM - asm ("mov.l 8(%a6),%a0"); - asm ("mov.l 12(%a6),%a1"); - asm ("fmove.x (%a0),%fp0"); - asm ("fmove.d %fp0,(%a1)"); -#else /* not HPUX_ASM */ -#if 0 - asm ("movl a6@(8),a0"); - asm ("movl a6@(12),a1"); - asm ("fmovex a0@,fp0"); - asm ("fmoved fp0,a1@"); -#else - /* Hand-assemble those insns since some assemblers lose - and some have different syntax. */ - asm (".word 020156"); - asm (".word 8"); - asm (".word 021156"); - asm (".word 12"); - asm (".long 0xf2104800"); - asm (".long 0xf2117400"); -#endif -#endif /* not HPUX_ASM */ - } -} - -/* The converse: convert the double *FROM to an extended float - and store where TO points. */ - -convert_to_68881 (from, to) - double *from; - char *to; -{ - if (!have_fpu) - return; - else - { -#ifdef HPUX_ASM - asm ("mov.l 8(%a6),%a0"); - asm ("mov.l 12(%a6),%a1"); - asm ("fmove.d (%a0),%fp0"); - asm ("fmove.x %fp0,(%a1)"); -#else /* not HPUX_ASM */ -#if 0 - asm ("movl a6@(8),a0"); - asm ("movl a6@(12),a1"); - asm ("fmoved a0@,fp0"); - asm ("fmovex fp0,a1@"); -#else - /* Hand-assemble those insns since some assemblers lose. */ - asm (".word 020156"); - asm (".word 8"); - asm (".word 021156"); - asm (".word 12"); - asm (".long 0xf2105400"); - asm (".long 0xf2116800"); -#endif -#endif /* not HPUX_ASM */ - } -} - -static jmp_buf fpu_check; - -void -sigemt() -{ - have_fpu = 0; - longjmp (fpu_check, 1); -} - -void -_initialize_pinsn() -{ - /* Want to figure out if we've got a coprocessor. The idea is to catch the - signal that gets delivered if no coprocessor is around (SIGEMT) then - execute a coprocessor instruction and see what happens. have_fpu is set - to zero if the EMT signal arrives. Else it is left at 1. */ - /* If this turns out not to be portable to all 68k machines, we'll - have to move it to the dep files. */ - void (*emthandler) (); - - emthandler = (void (*) ()) signal (SIGEMT, sigemt); - if (!setjmp (fpu_check)) - { -#if defined(HPUX_ASM) - asm (" long 0xf2000600"); /* fmovel fp0, d0 */ -#else - asm(".long 0xf2000600"); /* fmovel fp0, d0 */ -#endif - } - signal(SIGEMT, emthandler); -} diff --git a/gnu/usr.bin/gdb/config/m68kbsd-dep.c b/gnu/usr.bin/gdb/config/m68kbsd-dep.c deleted file mode 100644 index ed68589d2f68..000000000000 --- a/gnu/usr.bin/gdb/config/m68kbsd-dep.c +++ /dev/null @@ -1,1160 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)hp300bsd-dep.c 6.10 (Berkeley) 5/12/91";*/ -static char rcsid[] = "$Id: m68kbsd-dep.c,v 1.3 1993/08/10 00:12:42 mycroft Exp $"; -#endif /* not lint */ - -/* - * Machine-dependent code for a Hewlett-Packard 9000/300, running bsd. - * Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - * - * This file is part of GDB. - * - * GDB 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. - * - * GDB 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 - * GDB; see the file COPYING. If not, write to the Free Software Foundation, - * 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "value.h" - - -#include -#include -#include -#include -/* #include Can we live without this? */ - -#include -#ifndef N_SET_MAGIC -#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val)) -#endif - -#ifdef NEWVM -#include -#endif - -#include -#include -#include -#include /* After a.out.h */ -#include -#include -#include - -CORE_ADDR kernel_u_addr; - -#ifdef KERNELDEBUG -#ifndef NEWVM -#include -#include -#endif -#include -#include -#include -#include "symtab.h" /* XXX */ - -extern int kernel_debugging; - -#define KERNOFF ((unsigned)KERNBASE) -#define LOWRAM ((unsigned)0xfffffdce) -/* actually you can't really distinguish user and kernel by address */ -#define INKERNEL(x) ((x) >= KERNOFF && (x) < KERNOFF + ctob(slr)) -#define INUDOT(x) \ - ((x) >= KERNEL_U_ADDR && (x) < KERNEL_U_ADDR + ctob(UPAGES)) - -#define PT_ADDR_ANY ((caddr_t) 1) - -/* - * Convert from sysmap pte index to system virtual address & vice-versa. - * (why aren't these in one of the system vm macro files???) - */ -#define smxtob(a) (sbr + (a) * sizeof(pte)) -#define btosmx(b) (((b) - sbr) / sizeof(pte)) - -static int ok_to_cache(); -#ifdef NEWVM -static int found_pcb; -static CORE_ADDR curpcb; -static CORE_ADDR kstack; -#endif -#endif - -extern int errno; - -/* - * This function simply calls ptrace with the given arguments. It exists so - * that all calls to ptrace are isolated in this machine-dependent file. - */ -int -call_ptrace(request, pid, arg3, arg4) - int request; - pid_t pid; - caddr_t arg3; - int arg4; -{ - return(ptrace(request, pid, arg3, arg4)); -} - -kill_inferior() -{ - if (remote_debugging) { -#ifdef KERNELDEBUG - if (kernel_debugging) - /* - * It's a very, very bad idea to go away leaving - * breakpoints in a remote kernel or to leave it - * stopped at a breakpoint. - */ - clear_breakpoints(); -#endif - remote_close(0); - inferior_died(); - } else if (inferior_pid != 0) { - ptrace(PT_KILL, inferior_pid, 0, 0); - wait(0); - inferior_died(); - } -} - -/* - * This is used when GDB is exiting. It gives less chance of error. - */ -kill_inferior_fast() -{ - if (remote_debugging) { -#ifdef KERNELDEBUG - if (kernel_debugging) - clear_breakpoints(); -#endif - remote_close(0); - return; - } - if (inferior_pid == 0) - return; - - ptrace(PT_KILL, inferior_pid, 0, 0); - wait(0); -} - -/* - * Resume execution of the inferior process. If STEP is nonzero, single-step - * it. If SIGNAL is nonzero, give it that signal. - */ -void -resume(step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume(step, signal); - else { - ptrace(step ? PT_STEP : PT_CONTINUE, inferior_pid, - PT_ADDR_ANY, signal); - if (errno) - perror_with_name("ptrace"); - } -} - -#ifdef ATTACH_DETACH -extern int attach_flag; - -/* - * Start debugging the process whose number is PID. - */ -attach(pid) - int pid; -{ - errno = 0; - ptrace(PT_ATTACH, pid, 0, 0); - if (errno) - perror_with_name("ptrace"); - attach_flag = 1; - return pid; -} - -/* - * Stop debugging the process whose number is PID and continue it - * with signal number SIGNAL. SIGNAL = 0 means just continue it. - */ -void -detach(signal) - int signal; -{ - errno = 0; - ptrace(PT_DETACH, inferior_pid, PT_ADDR_ANY, signal); - if (errno) - perror_with_name("ptrace"); - attach_flag = 0; -} -#endif /* ATTACH_DETACH */ - -static unsigned int -get_register_offset() -{ - unsigned int offset; - struct user u; /* XXX */ - -#ifdef NEWVM - offset = (char *) &u.u_kproc.kp_proc.p_regs - (char *) &u; - offset = ptrace(PT_READ_U, inferior_pid, (caddr_t)offset, 0) - - USRSTACK; -#else - offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace(PT_READ_U, inferior_pid, (caddr_t)offset, 0) - - KERNEL_U_ADDR; -#endif - return offset; -} - -void -fetch_inferior_registers() -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - unsigned int offset; - - if (remote_debugging) { - extern char registers[]; - - remote_fetch_registers(registers); - return; - } - - offset = get_register_offset(); - - for (regno = 0; regno < NUM_REGS; regno++) { - regaddr = register_addr(regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE(regno); i += sizeof(int)) { - *(int *)&buf[i] = ptrace(PT_READ_U, inferior_pid, - (caddr_t)regaddr, 0); - regaddr += sizeof(int); - } - supply_register(regno, buf); - } -} - -/* - * Store our register values back into the inferior. If REGNO is -1, do this - * for all registers. Otherwise, REGNO specifies which register (so we can - * save time). - */ -store_inferior_registers(regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - extern char registers[]; - register int i; - unsigned int offset; - - if (remote_debugging) { - extern char registers[]; - - remote_store_registers(registers); - return; - } - - offset = get_register_offset(); - - if (regno >= 0) { - regaddr = register_addr(regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE(regno); i += sizeof(int)) { - errno = 0; - ptrace(PT_WRITE_U, inferior_pid, (caddr_t)regaddr, - *(int *) ®isters[REGISTER_BYTE(regno) + i]); - if (errno != 0) { - sprintf(buf, "writing register number %d(%d)", - regno, i); - perror_with_name(buf); - } - regaddr += sizeof(int); - } - } else - for (regno = 0; regno < NUM_REGS; regno++) { - regaddr = register_addr(regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE(regno); - i += sizeof(int)) { - errno = 0; - ptrace(PT_WRITE_U, inferior_pid, - (caddr_t)regaddr, - *(int *) ®isters[REGISTER_BYTE(regno) + i]); - if (errno != 0) { - sprintf(buf, - "writing register number %d(%d)", - regno, i); - perror_with_name(buf); - } - regaddr += sizeof(int); - } - } -} - -/* - * Copy LEN bytes from inferior's memory starting at MEMADDR to debugger - * memory starting at MYADDR. On failure (cannot read from inferior, usually - * because address is out of bounds) returns the value of errno. - */ -int -read_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & -sizeof(int); - /* Round ending address up; get number of longwords that makes. */ - register int count = (((memaddr + len) - addr) + sizeof(int) - 1) / - sizeof(int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca(count * sizeof(int)); - extern int errno; - - if (remote_debugging) - return (remote_read_inferior_memory(memaddr, myaddr, len)); - - /* Read all the longwords */ - errno = 0; - for (i = 0; i < count && errno == 0; i++, addr += sizeof(int)) - buffer[i] = ptrace(PT_READ_I, inferior_pid, (caddr_t)addr, 0); - - /* Copy appropriate bytes out of the buffer. */ - bcopy((char *) buffer + (memaddr & (sizeof(int) - 1)), myaddr, len); - return(errno); -} - -/* - * Copy LEN bytes of data from debugger memory at MYADDR to inferior's memory - * at MEMADDR. On failure (cannot write the inferior) returns the value of - * errno. - */ - -int -write_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & -sizeof(int); - /* Round ending address up; get number of longwords that makes. */ - register int count = (((memaddr + len) - addr) + sizeof(int) - 1) / - sizeof(int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca(count * sizeof(int)); - extern int errno; - - /* - * Fill start and end extra bytes of buffer with existing memory - * data. - */ - if (remote_debugging) - return (remote_write_inferior_memory(memaddr, myaddr, len)); - - /* - * Fill start and end extra bytes of buffer with existing memory - * data. - */ - buffer[0] = ptrace(PT_READ_I, inferior_pid, (caddr_t)addr, 0); - - if (count > 1) - buffer[count - 1] = ptrace(PT_READ_I, inferior_pid, - (caddr_t)addr + (count - 1) * sizeof(int), 0); - - /* Copy data to be written over corresponding part of buffer */ - - bcopy(myaddr, (char *) buffer + (memaddr & (sizeof(int) - 1)), len); - - /* Write the entire buffer. */ - - errno = 0; - for (i = 0; i < count && errno == 0; i++, addr += sizeof(int)) - ptrace(PT_WRITE_I, inferior_pid, (caddr_t)addr, buffer[i]); - - return(errno); -} - - -/* - * Work with core dump and executable files, for GDB. - * This code would be in core.c if it weren't machine-dependent. - */ - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* - * Make COFF and non-COFF names for things a little more compatible to reduce - * conditionals later. - */ - - -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files(); - - -extern int (*core_file_hook)(); - -#ifdef KERNELDEBUG -/* - * Kernel debugging routines. - */ - -static CORE_ADDR file_offset; -static CORE_ADDR lowram; -static CORE_ADDR sbr; -static CORE_ADDR slr; -static struct pcb pcb; -static CORE_ADDR kernel_udot_va; - -#ifndef CFSIZE -#include -#endif - -static CORE_ADDR -ksym_lookup(name) - char *name; -{ - struct symbol *sym; - int i; - - if ((i = lookup_misc_func(name)) < 0) - error("kernel symbol `%s' not found.", name); - - return (misc_function_vector[i].address); -} - -/* - * return true if 'len' bytes starting at 'addr' can be read out as - * longwords and/or locally cached (this is mostly for memory mapped - * i/o register access when debugging remote kernels). - */ -static int -ok_to_cache(addr, len) -{ -#ifdef NEWVM - static CORE_ADDR intiobase, extiobase; - - if (! intiobase) { - intiobase = ksym_lookup("intiobase"); - (void)remote_read_inferior_memory(intiobase, &intiobase, - sizeof(intiobase)); - extiobase = ksym_lookup("extiobase"); - (void)remote_read_inferior_memory(extiobase, &extiobase, - sizeof(extiobase)); - } - - if (addr >= intiobase && addr < intiobase + ctob(IIOMAPSIZE)) - return (0); - if (addr >= extiobase && addr < extiobase + ctob(EIOMAPSIZE)) - return (0); -#else - static CORE_ADDR IObase; - - if (! IObase) - IObase = ksym_lookup("IObase"); - - if (addr >= IObase && addr < IObase + (IOTOP - IOBASE)) - return (0); -#endif - - return (1); -} - -static -physrd(addr, dat, len) - u_int addr; - char *dat; -{ - if (lseek(corechan, addr - file_offset, L_SET) == -1) - return (-1); - if (read(corechan, dat, len) != len) - return (-1); - - return (0); -} - -/* - * When looking at kernel data space through /dev/mem or with a core file, do - * virtual memory mapping. - */ -#ifdef NEWVM -static CORE_ADDR -vtophys(addr) - CORE_ADDR addr; -{ - CORE_ADDR v; - struct pte pte; - CORE_ADDR stp; - CORE_ADDR oldaddr = addr; - static CORE_ADDR curstp = -1; - - /* - * If we're looking at the kernel stack, - * munge the address to refer to the user space mapping instead; - * that way we get the requested process's kstack, not the running one. - */ - if (addr >= kstack && addr < kstack + ctob(UPAGES)) - addr = (addr - kstack) + curpcb; - - /* - * Identify the current segment table. - * Since the given VA could come from either kernel - * or user space, the following heuristics don't always work. - */ - if (INKERNEL(addr)) - stp = sbr; - else if (found_pcb == 0) { - /* We have a pcb address, but haven't read it yet. Cheat. */ - if (curstp == -1) { - v = vtophys((CORE_ADDR)&((struct pcb *)curpcb)->pcb_ustp); - physrd(v, &curstp, sizeof curstp); - } - stp = curstp; - } else - stp = pcb.pcb_ustp; - - /* - * Read the current segment table. - */ - v = stp + ((addr >> SG_ISHIFT) * sizeof pte); - if (physrd(v, (char *)&pte, sizeof(pte))) - return (~0); - if (*(int *)&pte == SG_NV) - return (~0); - v = hp300_btop(addr & SG_PMASK); - addr = (CORE_ADDR)(hp300_ptob(pte.pg_pfnum) + v*sizeof pte); - - /* - * Addr is now address of the pte of the page we are interested in; - * get the pte and paste up the physical address. - */ - if (physrd(addr, (char *) &pte, sizeof(pte))) - return (~0); - if (pte.pg_v == 0 && pte.pg_pfnum == 0) - return (~0); - addr = (CORE_ADDR)hp300_ptob(pte.pg_pfnum) + (oldaddr & PGOFSET); -#if 0 - printf("vtophys(%x) -> %x\n", oldaddr, addr); -#endif - return (addr); -} -#else -static CORE_ADDR -vtophys(addr) - CORE_ADDR addr; -{ - CORE_ADDR v; - struct pte pte; - CORE_ADDR oldaddr = addr; - - /* permit direct reference to physical memory */ - if (addr >= lowram) - return (addr); - - if (kernel_udot_va && INUDOT(addr)) { - addr -= KERNEL_U_ADDR; - addr = kernel_udot_va + btop(addr) * sizeof (struct pte); - addr = vtophys(addr); - } else if (INKERNEL(addr)) { - /* - * In system space get system pte. If valid or reclaimable - * then physical address is combination of its page number - * and the page offset of the original address. - */ - v = smxtob(btop(addr - KERNOFF)); - addr = v + lowram; - } else { - /* In p0 space must not be off end of region. */ - v = btop(addr); - if (v >= pcb.pcb_p0lr) - /* address out of segment */ - return (~0); - - addr = (CORE_ADDR)(pcb.pcb_p0br + v); - /* - * For p0/p1 address, user-level page table should be in - * kernel vm. Do second-level indirect by recursing. - */ - if (!INKERNEL(addr)) - return (~0); - - addr = vtophys(addr); - } - /* - * Addr is now address of the pte of the page we are interested in; - * get the pte and paste up the physical address. - */ - if (physrd(addr, (char *) &pte, sizeof(pte))) - return (~0); - - if (pte.pg_v == 0 && (pte.pg_fod || pte.pg_pfnum == 0)) - return (~0); - - addr = (CORE_ADDR)ptob(pte.pg_pfnum) + (oldaddr & PGOFSET); -#if 0 - printf("vtophys(%x) -> %x\n", oldaddr, addr); -#endif - return (addr); -} -#endif - -static -kvread(addr) - CORE_ADDR addr; -{ - CORE_ADDR paddr = vtophys(addr); - - if (paddr != ~0) - if (physrd(paddr, (char *)&addr, sizeof(addr)) == 0); - return (addr); - - return (~0); -} - -static void -read_pcb(uaddr) - u_int uaddr; -{ - int i; - -#ifdef NEWVM - if (physrd(uaddr, (char *)&pcb, sizeof pcb)) - error("cannot read pcb at %x\n", uaddr); - printf("current pcb at %x\n", uaddr); -#else - if (physrd (uaddr, (char *)&pcb, sizeof pcb)) - error ("cannot read pcb at %x.\n", uaddr); - printf("p0br %x p0lr %x p1br %x p1lr %x\n", - pcb.pcb_p0br, pcb.pcb_p0lr, pcb.pcb_p1br, pcb.pcb_p1lr); - - kernel_udot_va = (CORE_ADDR) (pcb.pcb_p1br + BTOPUSRSTACK); -#endif - - /* - * get the register values out of the sys pcb and - * store them where `read_register' will find them. - */ - for (i = 2; i < 8; ++i) - supply_register(i, &pcb.pcb_regs[i-2]); - for (i = 10; i < 16; ++i) - supply_register(i, &pcb.pcb_regs[i-4]); - - /* fake 'scratch' regs d0, d1, a0, a1 */ - i = 0; - supply_register(0, &i); supply_register(1, &i); - supply_register(8, &i); supply_register(9, &i); - - i = kvread(pcb.pcb_regs[10] + 4); - if (i != -1) - supply_register(PC_REGNUM, &i); - - supply_register(PS_REGNUM, &pcb.pcb_ps); - - for (i = FP0_REGNUM; i < NUM_REGS; ++i) { - int fpreg; - - REGISTER_U_ADDR(fpreg, 0, i); - supply_register(i, ((char *)&pcb) + fpreg); - } -} - -static void -setup_kernel_debugging() -{ - struct stat stb; - int devmem = 0; - CORE_ADDR addr; - - fstat(corechan, &stb); - if ((stb.st_mode & S_IFMT) == S_IFCHR && stb.st_rdev == makedev(2, 0)) - devmem = 1; - - /* - * Must get value of lowram before we can read PCB. - */ - if (devmem) - /* /dev/mem == physical memory */ - (void)physrd(LOWRAM, (char *)&lowram, sizeof(lowram)); - else - /* normal file -- use standard offset */ - (void)physrd(ksym_lookup("lowram"), (char *)&lowram, - sizeof(lowram)); - lowram = roundup(lowram, NBPG); - if (! devmem) - file_offset = lowram; - - /* - * Get system mapping information. - */ -#ifdef NEWVM - sbr = ksym_lookup("Sysseg") + lowram; - (void)physrd(sbr, (char *)&sbr, sizeof(sbr)); - sbr += lowram; /* sbr is a physical address for NEWVM */ - slr = NPTEPG * (NPTEPG-1); - curpcb = ksym_lookup("curpcb") + lowram; - physrd(curpcb, &curpcb, sizeof curpcb); - kstack = ksym_lookup("kstack"); -#else - sbr = ksym_lookup("Sysmap"); - slr = ksym_lookup("Syssize"); -#endif - printf("sbr %x slr %x\n", sbr, slr); - - /* - * pcb where "panic" saved registers in first thing in current - * u area. - */ -#ifdef NEWVM - read_pcb(vtophys(kstack)); - found_pcb = 1; -#else - read_pcb(vtophys(ksym_lookup("u"))); -#endif - if (!devmem) { - /* find stack frame */ - CORE_ADDR panicstr; - char buf[256]; - register char *cp; - - panicstr = kvread(ksym_lookup("panicstr")); - if (panicstr == ~0) - return; - (void) kernel_core_file_hook(panicstr, buf, sizeof(buf)); - for (cp = buf; cp < &buf[sizeof(buf)] && *cp; cp++) - if (!isascii(*cp) || (!isprint(*cp) && !isspace(*cp))) - *cp = '?'; - if (*cp) - *cp = '\0'; - printf("panic: %s\n", buf); - } - - stack_start = USRSTACK; - stack_end = USRSTACK + ctob(UPAGES); -} - -set_paddr_command(arg) - char *arg; -{ - u_int uaddr; - - if (!arg) - error_no_arg("ps-style address for new current process"); - if (!kernel_debugging) - error("not debugging kernel"); - if (lowram == 0) - error("need kernel core file"); - uaddr = (u_int) parse_and_eval_address(arg); -#ifndef NEWVM - read_pcb(ctob(uaddr)); -#else - /* p_addr is now a pcb virtual address */ - read_pcb(vtophys(uaddr)); - curpcb = uaddr; -#endif - - flush_cached_frames(); - set_current_frame(create_new_frame(read_register(FP_REGNUM), read_pc())); - select_frame(get_current_frame(), 0); -} - -/* - * read len bytes from kernel virtual address 'addr' into local - * buffer 'buf'. Return 0 if read ok, 1 otherwise. On read - * errors, portion of buffer not read is zeroed. - */ -kernel_core_file_hook(addr, buf, len) - CORE_ADDR addr; - char *buf; - int len; -{ - int i; - CORE_ADDR paddr; - - while (len > 0) { - paddr = vtophys(addr); - if (paddr == ~0) { - bzero(buf, len); - return (1); - } - /* we can't read across a page boundary */ - i = min(len, NBPG - (addr & PGOFSET)); - if (physrd(paddr, buf, i)) { - bzero(buf, len); - return (1); - } - buf += i; - addr += i; - len -= i; - } - return (0); -} -#endif - -core_file_command(filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - unsigned int reg_offset; -#ifdef KERNELDEBUG - struct stat stb; -#endif - struct user u; - - /* - * Discard all vestiges of any previous core file and mark data and - * stack spaces as empty. - */ - if (corefile) - free(corefile); - corefile = 0; - core_file_hook = 0; - - if (corechan >= 0) - close(corechan); - corechan = -1; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename == 0) { - if (from_tty) - printf("No core file now.\n"); - return; - } - filename = tilde_expand(filename); - make_cleanup(free, filename); - if (have_inferior_p()) - error("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open(filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name(filename); - -#ifdef KERNELDEBUG - fstat(corechan, &stb); - - if (kernel_debugging) { - setup_kernel_debugging(); - core_file_hook = kernel_core_file_hook; - } else if ((stb.st_mode & S_IFMT) == S_IFCHR && - stb.st_rdev == makedev(2, 1)) { - /* looking at /dev/kmem */ - data_offset = data_start = KERNOFF; - data_end = ~0; /* XXX */ - stack_end = stack_start = data_end; - } else -#endif - { - val = myread(corechan, &u, sizeof u); - if (val < 0) - perror_with_name("Not a core file: reading upage"); - if (val != sizeof u) - error("Not a core file: could only read %d bytes", val); - - /* - * We are depending on exec_file_command having been - * called previously to set exec_data_start. Since - * the executable and the core file share the same - * text segment, the address of the data segment will - * be the same in both. - */ - data_start = exec_data_start; - -#ifndef NEWVM - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - - /* - * Some machines put an absolute address in here and - * some put the offset in the upage of the regs. - */ - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; -#else - data_end = data_start + - NBPG * u.u_kproc.kp_eproc.e_vm.vm_dsize; - stack_start = stack_end - - NBPG * u.u_kproc.kp_eproc.e_vm.vm_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * - (UPAGES + u.u_kproc.kp_eproc.e_vm.vm_dsize); - - reg_offset = (int) u.u_kproc.kp_proc.p_regs - USRSTACK; -#endif - - /* - * I don't know where to find this info. So, for now, - * mark it as not available. - */ - /* N_SET_MAGIC(core_aouthdr, 0); */ - bzero ((char *) &core_aouthdr, sizeof core_aouthdr); - - /* - * Read the register values out of the core file and - * store them where `read_register' will find them. - */ - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek(corechan, register_addr(regno, reg_offset), 0); - if (val < 0 - || (val = myread(corechan, buf, sizeof buf)) < 0) { - char *buffer = (char *) alloca(strlen(reg_names[regno]) + 30); - strcpy(buffer, "Reading register "); - strcat(buffer, reg_names[regno]); - perror_with_name(buffer); - } - supply_register(regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring(filename, strlen(filename)); - else - corefile = concat(current_directory, "/", filename); - - set_current_frame(create_new_frame(read_register(FP_REGNUM), - read_pc())); - select_frame(get_current_frame(), 0); - validate_files(); -} - - -exec_file_command(filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* - * Eliminate all traces of old exec file. Mark text segment as empty. - */ - - if (execfile) - free(execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close(execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) { - filename = tilde_expand(filename); - make_cleanup(free, filename); - - execchan = openp(getenv("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name(filename); - - { - struct stat st_exec; - -#ifdef HEADER_SEEK_FD - HEADER_SEEK_FD(execchan); -#endif - - val = myread(execchan, &exec_aouthdr, sizeof(AOUTHDR)); - - if (val < 0) - perror_with_name(filename); - - text_start = N_TXTADDR(exec_aouthdr); - exec_data_start = N_DATADDR(exec_aouthdr); - - text_offset = N_TXTOFF(exec_aouthdr); - exec_data_offset = N_TXTOFF(exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat(execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } - - validate_files(); - } else if (from_tty) - printf("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -int dummy_code[] = { - 0x4e714eb9, /* nop, jsr @#32323232 */ - 0x32323232, -#define DUMMY_CALL_INDEX 1 - 0x4e424e71, /* trap 2, nop */ -}; - -/* - * Build `dummy' call instructions on inferior's stack to cause - * it to call a subroutine. - * - * N.B. - code in wait_for_inferior requires that sp < pc < fp when - * we take the trap 2 above so it will recognize that we stopped - * at a `dummy' call. So, after the call sp is *not* decremented - * to clean the arguments, code & other stuff we lay on the stack. - * Since the regs are restored to saved values at the breakpoint, - * sp will get reset correctly. Also, this restore means we don't - * have to construct frame linkage info to save pc & fp. The lack - * of frame linkage means we can't do a backtrace, etc., if the - * called function gets a fault or hits a breakpoint but code in - * run_stack_dummy makes this impossible anyway. - */ -CORE_ADDR -setup_dummy(sp, funaddr, nargs, args, struct_return_bytes, pushfn) - CORE_ADDR sp; - CORE_ADDR funaddr; - int nargs; - value *args; - int struct_return_bytes; - CORE_ADDR (*pushfn)(); -{ - int padding, i; - CORE_ADDR top = sp, struct_addr, pc; - - i = arg_stacklen(nargs, args) + struct_return_bytes - + sizeof(dummy_code); - if (i & 3) - padding = 4 - (i & 3); - else - padding = 0; - pc = sp - sizeof(dummy_code); - sp = pc - padding - struct_return_bytes; - struct_addr = sp; - while (--nargs >= 0) - sp = (*pushfn)(sp, *args++); - if (struct_return_bytes) - STORE_STRUCT_RETURN(struct_addr, sp); - write_register(SP_REGNUM, sp); - - dummy_code[DUMMY_CALL_INDEX] = (int)funaddr; - write_memory(pc, (char *)dummy_code, sizeof(dummy_code)); - - return pc; -} - -void -_initialize_hp300bsd_dep() -{ -#ifdef KERNELDEBUG - add_com ("process-address", class_obscure, set_paddr_command, - "The process identified by (ps-style) ADDR becomes the\n\ -\"current\" process context for kernel debugging."); - add_com_alias ("paddr", "process-address", class_obscure, 0); -#endif -} diff --git a/gnu/usr.bin/gdb/config/news-dep.c b/gnu/usr.bin/gdb/config/news-dep.c deleted file mode 100644 index 1763c6c0c597..000000000000 --- a/gnu/usr.bin/gdb/config/news-dep.c +++ /dev/null @@ -1,643 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: news-dep.c,v 1.2 1993/08/02 17:40:14 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#include -#include -#include -#include -#include -#if 0 -#include -#endif /* I don't think that I need this file. */ - -#include -#include -#include - -extern int errno; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -void -fetch_inferior_registers () -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - struct user u; -#ifdef USE_PCB - unsigned int offset = (char *) &u.u_pcb.pcb_d0 - (char *) &u; -#else - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; -#endif - - for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - extern char registers[]; - - struct user u; -#ifdef USE_PCB - unsigned int offset = (char *) &u.u_pcb.pcb_d0 - (char *) &u; -#else - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; -#endif - -#ifdef PTRACE_BUG - if (regno >= FP0_REGNUM) - printf ("warning: floating register num %d not written due to OS bug.\n", - regno); - else -#endif - if (regno >= 0) - { - int i; - int *p = (int *) ®isters[REGISTER_BYTE (regno)]; - -#ifdef PTRACE_BUG - if (regno == FP_REGNUM) - printf ("warning: ptrace bug for writing register number fp(a6).\n"); -#endif - - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - errno = 0; - ptrace (6, inferior_pid, regaddr, *p++); - if (errno != 0) - { - sprintf (buf, "writing register number %d[%d]", regno, i); - perror_with_name (buf); - } - regaddr += sizeof (int); - } - } - else - { -#ifdef PTRACE_BUG - for (regno = 0; regno < FP0_REGNUM; regno++) -#else - for (regno = 0; regno < NUM_REGS; regno++) -#endif - { - int i; - int *p = (int *) ®isters[REGISTER_BYTE (regno)]; - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - errno = 0; - ptrace (6, inferior_pid, regaddr, *p++); - if (errno != 0) - { - sprintf (buf, "writing register number %d[%d]", regno, i); - perror_with_name (buf); - } - regaddr += sizeof (int); - } - } -#ifdef PTRACE_BUG - printf ("warning: ptrace bug for writing floating registers(no write).\n"); -#endif - } -} - -/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory - in the NEW_SUN_PTRACE case. - It ought to be straightforward. But it appears that writing did - not write the data that I specified. I cannot understand where - it got the data that it actually did write. */ - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - buffer[0] = remote_fetch_word (addr); - else - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - if (remote_debugging) - buffer[count - 1] - = remote_fetch_word (addr + (count - 1) * sizeof (int)); - else - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - remote_store_word (addr, buffer[i]); - else - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - core_aouthdr.a_magic = 0; - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_TXTADDR (exec_aouthdr); - exec_data_start = N_DATADDR (exec_aouthdr); - - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -#ifdef __GNUC__ -/* Bad implement execle(3). It's depend for "/bin/cc". - - main() - { - printf("execle:\n"); - execle(FILE, ARGS, envp); - exit(1); - } - - GCC: - link a6,#0 - pea LC5 ; call printf - jbsr _printf - ; ; (not popd stack) - pea _envp ; call execle - clrl sp@- - pea LC4 - pea LC4 - pea LC4 - pea LC3 - pea LC6 - jbsr _execle - addw #32,sp ; delayed pop !! - - /bin/cc: - link.l fp,#L23 - movem.l #L24,(sp) - pea L26 ; call printf - jbsr _printf - addq.l #4,sp ; <--- popd stack !! - pea _envp ; call execle - clr.l -(sp) - pea L32 - - */ - -execle(name, args) - char *name, *args; -{ - register char **env = &args; - while (*env++) - ; - execve(name, (char **)&args, (char **)*env); -} -#endif diff --git a/gnu/usr.bin/gdb/config/npl-opcode.h b/gnu/usr.bin/gdb/config/npl-opcode.h deleted file mode 100644 index 2fbdc9cfbe19..000000000000 --- a/gnu/usr.bin/gdb/config/npl-opcode.h +++ /dev/null @@ -1,425 +0,0 @@ -/* Print GOULD NPL instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: npl-opcode.h,v 1.2 1993/08/02 17:40:15 mycroft Exp $ -*/ - -struct gld_opcode -{ - char *name; - unsigned long opcode; - unsigned long mask; - char *args; - int length; -}; - -/* We store four bytes of opcode for all opcodes because that - is the most any of them need. The actual length of an instruction - is always at least 2 bytes, and at most four. The length of the - instruction is based on the opcode. - - The mask component is a mask saying which bits must match - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing characters - that are used to format the arguments to the instruction. */ - -/* Kinds of operands: - r Register in first field - R Register in second field - b Base register in first field - B Base register in second field - v Vector register in first field - V Vector register in first field - A Optional address register (base register) - X Optional index register - I Immediate data (16bits signed) - O Offset field (16bits signed) - h Offset field (15bits signed) - d Offset field (14bits signed) - S Shift count field - - any other characters are printed as is... -*/ - -/* The assembler requires that this array be sorted as follows: - all instances of the same mnemonic must be consecutive. - All instances of the same mnemonic with the same number of operands - must be consecutive. - */ -struct gld_opcode gld_opcodes[] = -{ -{ "lb", 0xb4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lbs", 0xec080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lh", 0xb4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lnh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lw", 0xb4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "ld", 0xb4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lnd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "li", 0xf8000000, 0xfc7f0000, "r,I", 4 }, -{ "lpa", 0x50080000, 0xfc080000, "r,xOA,X", 4 }, -{ "la", 0x50000000, 0xfc080000, "r,xOA,X", 4 }, -{ "labr", 0x58080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lbp", 0x90080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lhp", 0x90000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lwp", 0x90000000, 0xfc080000, "r,xOA,X", 4 }, -{ "ldp", 0x90000002, 0xfc080002, "r,xOA,X", 4 }, -{ "suabr", 0x58000000, 0xfc080000, "b,xOA,X", 4 }, -{ "lf", 0xbc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lfbr", 0xbc080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lwbr", 0x5c000000, 0xfc080000, "b,xOA,X", 4 }, -{ "stb", 0xd4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sth", 0xd4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stw", 0xd4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "std", 0xd4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stf", 0xdc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stfbr", 0xdc080000, 0xfc080000, "b,xOA,X", 4 }, -{ "stwbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 }, -{ "zmb", 0xd8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "zmh", 0xd8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "zmw", 0xd8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "zmd", 0xd8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stbp", 0x94080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sthp", 0x94000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stwp", 0x94000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stdp", 0x94000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lil", 0xf8080000, 0xfc7f0000, "r,D", 4 }, -{ "lwsl1", 0xec000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lwsl2", 0xfc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lwsl3", 0xfc080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "lvb", 0xb0080000, 0xfc080000, "v,xOA,X", 4 }, -{ "lvh", 0xb0000001, 0xfc080001, "v,xOA,X", 4 }, -{ "lvw", 0xb0000000, 0xfc080000, "v,xOA,X", 4 }, -{ "lvd", 0xb0000002, 0xfc080002, "v,xOA,X", 4 }, -{ "liv", 0x3c040000, 0xfc0f0000, "v,R", 2 }, -{ "livf", 0x3c080000, 0xfc0f0000, "v,R", 2 }, -{ "stvb", 0xd0080000, 0xfc080000, "v,xOA,X", 4 }, -{ "stvh", 0xd0000001, 0xfc080001, "v,xOA,X", 4 }, -{ "stvw", 0xd0000000, 0xfc080000, "v,xOA,X", 4 }, -{ "stvd", 0xd0000002, 0xfc080002, "v,xOA,X", 4 }, - -{ "trr", 0x2c000000, 0xfc0f0000, "r,R", 2 }, -{ "trn", 0x2c040000, 0xfc0f0000, "r,R", 2 }, -{ "trnd", 0x2c0c0000, 0xfc0f0000, "r,R", 2 }, -{ "trabs", 0x2c010000, 0xfc0f0000, "r,R", 2 }, -{ "trabsd", 0x2c090000, 0xfc0f0000, "r,R", 2 }, -{ "trc", 0x2c030000, 0xfc0f0000, "r,R", 2 }, -{ "xcr", 0x28040000, 0xfc0f0000, "r,R", 2 }, -{ "cxcr", 0x2c060000, 0xfc0f0000, "r,R", 2 }, -{ "cxcrd", 0x2c0e0000, 0xfc0f0000, "r,R", 2 }, -{ "tbrr", 0x2c020000, 0xfc0f0000, "r,B", 2 }, -{ "trbr", 0x28030000, 0xfc0f0000, "b,R", 2 }, -{ "xcbr", 0x28020000, 0xfc0f0000, "b,B", 2 }, -{ "tbrbr", 0x28010000, 0xfc0f0000, "b,B", 2 }, - -{ "trvv", 0x28050000, 0xfc0f0000, "v,V", 2 }, -{ "trvvn", 0x2c050000, 0xfc0f0000, "v,V", 2 }, -{ "trvvnd", 0x2c0d0000, 0xfc0f0000, "v,V", 2 }, -{ "trvab", 0x2c070000, 0xfc0f0000, "v,V", 2 }, -{ "trvabd", 0x2c0f0000, 0xfc0f0000, "v,V", 2 }, -{ "cmpv", 0x14060000, 0xfc0f0000, "v,V", 2 }, -{ "expv", 0x14070000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvlt", 0x10030000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvle", 0x10040000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvgt", 0x14030000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvge", 0x14040000, 0xfc0f0000, "v,V", 2 }, -{ "mrvveq", 0x10050000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvne", 0x10050000, 0xfc0f0000, "v,V", 2 }, -{ "mrvrlt", 0x100d0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrle", 0x100e0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrgt", 0x140d0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrge", 0x140e0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvreq", 0x100f0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrne", 0x140f0000, 0xfc0f0000, "v,R", 2 }, -{ "trvr", 0x140b0000, 0xfc0f0000, "r,V", 2 }, -{ "trrv", 0x140c0000, 0xfc0f0000, "v,R", 2 }, - -{ "bu", 0x40000000, 0xff880000, "xOA,X", 4 }, -{ "bns", 0x70080000, 0xff880000, "xOA,X", 4 }, -{ "bnco", 0x70880000, 0xff880000, "xOA,X", 4 }, -{ "bge", 0x71080000, 0xff880000, "xOA,X", 4 }, -{ "bne", 0x71880000, 0xff880000, "xOA,X", 4 }, -{ "bunge", 0x72080000, 0xff880000, "xOA,X", 4 }, -{ "bunle", 0x72880000, 0xff880000, "xOA,X", 4 }, -{ "bgt", 0x73080000, 0xff880000, "xOA,X", 4 }, -{ "bnany", 0x73880000, 0xff880000, "xOA,X", 4 }, -{ "bs" , 0x70000000, 0xff880000, "xOA,X", 4 }, -{ "bco", 0x70800000, 0xff880000, "xOA,X", 4 }, -{ "blt", 0x71000000, 0xff880000, "xOA,X", 4 }, -{ "beq", 0x71800000, 0xff880000, "xOA,X", 4 }, -{ "buge", 0x72000000, 0xff880000, "xOA,X", 4 }, -{ "bult", 0x72800000, 0xff880000, "xOA,X", 4 }, -{ "ble", 0x73000000, 0xff880000, "xOA,X", 4 }, -{ "bany", 0x73800000, 0xff880000, "xOA,X", 4 }, -{ "brlnk", 0x44000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bib", 0x48000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bih", 0x48080000, 0xfc080000, "r,xOA,X", 4 }, -{ "biw", 0x4c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bid", 0x4c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivb", 0x60000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivh", 0x60080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivw", 0x64000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivd", 0x64080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsb", 0x68000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsh", 0x68080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsw", 0x6c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsd", 0x6c080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "camb", 0x80080000, 0xfc080000, "r,xOA,X", 4 }, -{ "camh", 0x80000001, 0xfc080001, "r,xOA,X", 4 }, -{ "camw", 0x80000000, 0xfc080000, "r,xOA,X", 4 }, -{ "camd", 0x80000002, 0xfc080002, "r,xOA,X", 4 }, -{ "car", 0x10000000, 0xfc0f0000, "r,R", 2 }, -{ "card", 0x14000000, 0xfc0f0000, "r,R", 2 }, -{ "ci", 0xf8050000, 0xfc7f0000, "r,I", 4 }, -{ "chkbnd", 0x5c080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "cavv", 0x10010000, 0xfc0f0000, "v,V", 2 }, -{ "cavr", 0x10020000, 0xfc0f0000, "v,R", 2 }, -{ "cavvd", 0x10090000, 0xfc0f0000, "v,V", 2 }, -{ "cavrd", 0x100b0000, 0xfc0f0000, "v,R", 2 }, - -{ "anmb", 0x84080000, 0xfc080000, "r,xOA,X", 4 }, -{ "anmh", 0x84000001, 0xfc080001, "r,xOA,X", 4 }, -{ "anmw", 0x84000000, 0xfc080000, "r,xOA,X", 4 }, -{ "anmd", 0x84000002, 0xfc080002, "r,xOA,X", 4 }, -{ "anr", 0x04000000, 0xfc0f0000, "r,R", 2 }, -{ "ani", 0xf8080000, 0xfc7f0000, "r,I", 4 }, -{ "ormb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "ormh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "ormw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "ormd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "orr", 0x08000000, 0xfc0f0000, "r,R", 2 }, -{ "oi", 0xf8090000, 0xfc7f0000, "r,I", 4 }, -{ "eomb", 0x8c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "eomh", 0x8c000001, 0xfc080001, "r,xOA,X", 4 }, -{ "eomw", 0x8c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "eomd", 0x8c000002, 0xfc080002, "r,xOA,X", 4 }, -{ "eor", 0x0c000000, 0xfc0f0000, "r,R", 2 }, -{ "eoi", 0xf80a0000, 0xfc7f0000, "r,I", 4 }, - -{ "anvv", 0x04010000, 0xfc0f0000, "v,V", 2 }, -{ "anvr", 0x04020000, 0xfc0f0000, "v,R", 2 }, -{ "orvv", 0x08010000, 0xfc0f0000, "v,V", 2 }, -{ "orvr", 0x08020000, 0xfc0f0000, "v,R", 2 }, -{ "eovv", 0x0c010000, 0xfc0f0000, "v,V", 2 }, -{ "eovr", 0x0c020000, 0xfc0f0000, "v,R", 2 }, - -{ "sacz", 0x100c0000, 0xfc0f0000, "r,R", 2 }, -{ "sla", 0x1c400000, 0xfc600000, "r,S", 2 }, -{ "sll", 0x1c600000, 0xfc600000, "r,S", 2 }, -{ "slc", 0x24400000, 0xfc600000, "r,S", 2 }, -{ "slad", 0x20400000, 0xfc600000, "r,S", 2 }, -{ "slld", 0x20600000, 0xfc600000, "r,S", 2 }, -{ "sra", 0x1c000000, 0xfc600000, "r,S", 2 }, -{ "srl", 0x1c200000, 0xfc600000, "r,S", 2 }, -{ "src", 0x24000000, 0xfc600000, "r,S", 2 }, -{ "srad", 0x20000000, 0xfc600000, "r,S", 2 }, -{ "srld", 0x20200000, 0xfc600000, "r,S", 2 }, -{ "sda", 0x3c030000, 0xfc0f0000, "r,R", 2 }, -{ "sdl", 0x3c020000, 0xfc0f0000, "r,R", 2 }, -{ "sdc", 0x3c010000, 0xfc0f0000, "r,R", 2 }, -{ "sdad", 0x3c0b0000, 0xfc0f0000, "r,R", 2 }, -{ "sdld", 0x3c0a0000, 0xfc0f0000, "r,R", 2 }, - -{ "svda", 0x3c070000, 0xfc0f0000, "v,R", 2 }, -{ "svdl", 0x3c060000, 0xfc0f0000, "v,R", 2 }, -{ "svdc", 0x3c050000, 0xfc0f0000, "v,R", 2 }, -{ "svdad", 0x3c0e0000, 0xfc0f0000, "v,R", 2 }, -{ "svdld", 0x3c0d0000, 0xfc0f0000, "v,R", 2 }, - -{ "sbm", 0xac080000, 0xfc080000, "f,xOA,X", 4 }, -{ "zbm", 0xac000000, 0xfc080000, "f,xOA,X", 4 }, -{ "tbm", 0xa8080000, 0xfc080000, "f,xOA,X", 4 }, -{ "incmb", 0xa0000000, 0xfc080000, "xOA,X", 4 }, -{ "incmh", 0xa0080000, 0xfc080000, "xOA,X", 4 }, -{ "incmw", 0xa4000000, 0xfc080000, "xOA,X", 4 }, -{ "incmd", 0xa4080000, 0xfc080000, "xOA,X", 4 }, -{ "sbmd", 0x7c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "zbmd", 0x7c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "tbmd", 0x78080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "ssm", 0x9c080000, 0xfc080000, "f,xOA,X", 4 }, -{ "zsm", 0x9c000000, 0xfc080000, "f,xOA,X", 4 }, -{ "tsm", 0x98080000, 0xfc080000, "f,xOA,X", 4 }, - -{ "admb", 0xc8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "admh", 0xc8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "admw", 0xc8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "admd", 0xc8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "adr", 0x38000000, 0xfc0f0000, "r,R", 2 }, -{ "armb", 0xe8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "armh", 0xe8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "armw", 0xe8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "armd", 0xe8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "adi", 0xf8010000, 0xfc0f0000, "r,I", 4 }, -{ "sumb", 0xcc080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sumh", 0xcc000001, 0xfc080001, "r,xOA,X", 4 }, -{ "sumw", 0xcc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "sumd", 0xcc000002, 0xfc080002, "r,xOA,X", 4 }, -{ "sur", 0x3c000000, 0xfc0f0000, "r,R", 2 }, -{ "sui", 0xf8020000, 0xfc0f0000, "r,I", 4 }, -{ "mpmb", 0xc0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpmh", 0xc0000001, 0xfc080001, "r,xOA,X", 4 }, -{ "mpmw", 0xc0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpr", 0x38020000, 0xfc0f0000, "r,R", 2 }, -{ "mprd", 0x3c0f0000, 0xfc0f0000, "r,R", 2 }, -{ "mpi", 0xf8030000, 0xfc0f0000, "r,I", 4 }, -{ "dvmb", 0xc4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvmh", 0xc4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "dvmw", 0xc4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvr", 0x380a0000, 0xfc0f0000, "r,R", 2 }, -{ "dvi", 0xf8040000, 0xfc0f0000, "r,I", 4 }, -{ "exs", 0x38080000, 0xfc0f0000, "r,R", 2 }, - -{ "advv", 0x30000000, 0xfc0f0000, "v,V", 2 }, -{ "advvd", 0x30080000, 0xfc0f0000, "v,V", 2 }, -{ "adrv", 0x34000000, 0xfc0f0000, "v,R", 2 }, -{ "adrvd", 0x34080000, 0xfc0f0000, "v,R", 2 }, -{ "suvv", 0x30010000, 0xfc0f0000, "v,V", 2 }, -{ "suvvd", 0x30090000, 0xfc0f0000, "v,V", 2 }, -{ "surv", 0x34010000, 0xfc0f0000, "v,R", 2 }, -{ "survd", 0x34090000, 0xfc0f0000, "v,R", 2 }, -{ "mpvv", 0x30020000, 0xfc0f0000, "v,V", 2 }, -{ "mprv", 0x34020000, 0xfc0f0000, "v,R", 2 }, - -{ "adfw", 0xe0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "adfd", 0xe0080002, 0xfc080002, "r,xOA,X", 4 }, -{ "adrfw", 0x38010000, 0xfc0f0000, "r,R", 2 }, -{ "adrfd", 0x38090000, 0xfc0f0000, "r,R", 2 }, -{ "surfw", 0xe0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "surfd", 0xe0000002, 0xfc080002, "r,xOA,X", 4 }, -{ "surfw", 0x38030000, 0xfc0f0000, "r,R", 2 }, -{ "surfd", 0x380b0000, 0xfc0f0000, "r,R", 2 }, -{ "mpfw", 0xe4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpfd", 0xe4080002, 0xfc080002, "r,xOA,X", 4 }, -{ "mprfw", 0x38060000, 0xfc0f0000, "r,R", 2 }, -{ "mprfd", 0x380e0000, 0xfc0f0000, "r,R", 2 }, -{ "rfw", 0xe4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "rfd", 0xe4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "rrfw", 0x0c0e0000, 0xfc0f0000, "r", 2 }, -{ "rrfd", 0x0c0f0000, 0xfc0f0000, "r", 2 }, - -{ "advvfw", 0x30040000, 0xfc0f0000, "v,V", 2 }, -{ "advvfd", 0x300c0000, 0xfc0f0000, "v,V", 2 }, -{ "adrvfw", 0x34040000, 0xfc0f0000, "v,R", 2 }, -{ "adrvfd", 0x340c0000, 0xfc0f0000, "v,R", 2 }, -{ "suvvfw", 0x30050000, 0xfc0f0000, "v,V", 2 }, -{ "suvvfd", 0x300d0000, 0xfc0f0000, "v,V", 2 }, -{ "survfw", 0x34050000, 0xfc0f0000, "v,R", 2 }, -{ "survfd", 0x340d0000, 0xfc0f0000, "v,R", 2 }, -{ "mpvvfw", 0x30060000, 0xfc0f0000, "v,V", 2 }, -{ "mpvvfd", 0x300e0000, 0xfc0f0000, "v,V", 2 }, -{ "mprvfw", 0x34060000, 0xfc0f0000, "v,R", 2 }, -{ "mprvfd", 0x340e0000, 0xfc0f0000, "v,R", 2 }, -{ "rvfw", 0x30070000, 0xfc0f0000, "v", 2 }, -{ "rvfd", 0x300f0000, 0xfc0f0000, "v", 2 }, - -{ "fltw", 0x38070000, 0xfc0f0000, "r,R", 2 }, -{ "fltd", 0x380f0000, 0xfc0f0000, "r,R", 2 }, -{ "fixw", 0x38050000, 0xfc0f0000, "r,R", 2 }, -{ "fixd", 0x380d0000, 0xfc0f0000, "r,R", 2 }, -{ "cfpds", 0x3c090000, 0xfc0f0000, "r,R", 2 }, - -{ "fltvw", 0x080d0000, 0xfc0f0000, "v,V", 2 }, -{ "fltvd", 0x080f0000, 0xfc0f0000, "v,V", 2 }, -{ "fixvw", 0x080c0000, 0xfc0f0000, "v,V", 2 }, -{ "fixvd", 0x080e0000, 0xfc0f0000, "v,V", 2 }, -{ "cfpvds", 0x0c0d0000, 0xfc0f0000, "v,V", 2 }, - -{ "orvrn", 0x000a0000, 0xfc0f0000, "r,V", 2 }, -{ "andvrn", 0x00080000, 0xfc0f0000, "r,V", 2 }, -{ "frsteq", 0x04090000, 0xfc0f0000, "r,V", 2 }, -{ "sigma", 0x0c080000, 0xfc0f0000, "r,V", 2 }, -{ "sigmad", 0x0c0a0000, 0xfc0f0000, "r,V", 2 }, -{ "sigmf", 0x08080000, 0xfc0f0000, "r,V", 2 }, -{ "sigmfd", 0x080a0000, 0xfc0f0000, "r,V", 2 }, -{ "prodf", 0x04080000, 0xfc0f0000, "r,V", 2 }, -{ "prodfd", 0x040a0000, 0xfc0f0000, "r,V", 2 }, -{ "maxv", 0x10080000, 0xfc0f0000, "r,V", 2 }, -{ "maxvd", 0x100a0000, 0xfc0f0000, "r,V", 2 }, -{ "minv", 0x14080000, 0xfc0f0000, "r,V", 2 }, -{ "minvd", 0x140a0000, 0xfc0f0000, "r,V", 2 }, - -{ "lpsd", 0xf0000000, 0xfc080000, "xOA,X", 4 }, -{ "ldc", 0xf0080000, 0xfc080000, "xOA,X", 4 }, -{ "spm", 0x040c0000, 0xfc0f0000, "r", 2 }, -{ "rpm", 0x040d0000, 0xfc0f0000, "r", 2 }, -{ "tritr", 0x00070000, 0xfc0f0000, "r", 2 }, -{ "trrit", 0x00060000, 0xfc0f0000, "r", 2 }, -{ "rpswt", 0x04080000, 0xfc0f0000, "r", 2 }, -{ "exr", 0xf8070000, 0xfc0f0000, "", 4 }, -{ "halt", 0x00000000, 0xfc0f0000, "", 2 }, -{ "wait", 0x00010000, 0xfc0f0000, "", 2 }, -{ "nop", 0x00020000, 0xfc0f0000, "", 2 }, -{ "eiae", 0x00030000, 0xfc0f0000, "", 2 }, -{ "efae", 0x000d0000, 0xfc0f0000, "", 2 }, -{ "diae", 0x000e0000, 0xfc0f0000, "", 2 }, -{ "dfae", 0x000f0000, 0xfc0f0000, "", 2 }, -{ "spvc", 0xf8060000, 0xfc0f0000, "r,T,N", 4 }, -{ "rdsts", 0x00090000, 0xfc0f0000, "r", 2 }, -{ "setcpu", 0x000c0000, 0xfc0f0000, "r", 2 }, -{ "cmc", 0x000b0000, 0xfc0f0000, "r", 2 }, -{ "trrcu", 0x00040000, 0xfc0f0000, "r", 2 }, -{ "attnio", 0x00050000, 0xfc0f0000, "", 2 }, -{ "fudit", 0x28080000, 0xfc0f0000, "", 2 }, -{ "break", 0x28090000, 0xfc0f0000, "", 2 }, -{ "frzss", 0x280a0000, 0xfc0f0000, "", 2 }, -{ "ripi", 0x04040000, 0xfc0f0000, "r,R", 2 }, -{ "xcp", 0x04050000, 0xfc0f0000, "r", 2 }, -{ "block", 0x04060000, 0xfc0f0000, "", 2 }, -{ "unblock", 0x04070000, 0xfc0f0000, "", 2 }, -{ "trsc", 0x08060000, 0xfc0f0000, "r,R", 2 }, -{ "tscr", 0x08070000, 0xfc0f0000, "r,R", 2 }, -{ "fq", 0x04080000, 0xfc0f0000, "r", 2 }, -{ "flupte", 0x2c080000, 0xfc0f0000, "r", 2 }, -{ "rviu", 0x040f0000, 0xfc0f0000, "", 2 }, -{ "ldel", 0x280c0000, 0xfc0f0000, "r,R", 2 }, -{ "ldu", 0x280d0000, 0xfc0f0000, "r,R", 2 }, -{ "stdecc", 0x280b0000, 0xfc0f0000, "r,R", 2 }, -{ "trpc", 0x08040000, 0xfc0f0000, "r", 2 }, -{ "tpcr", 0x08050000, 0xfc0f0000, "r", 2 }, -{ "ghalt", 0x0c050000, 0xfc0f0000, "r", 2 }, -{ "grun", 0x0c040000, 0xfc0f0000, "", 2 }, -{ "tmpr", 0x2c0a0000, 0xfc0f0000, "r,R", 2 }, -{ "trmp", 0x2c0b0000, 0xfc0f0000, "r,R", 2 }, - -{ "trrve", 0x28060000, 0xfc0f0000, "r", 2 }, -{ "trver", 0x28070000, 0xfc0f0000, "r", 2 }, -{ "trvlr", 0x280f0000, 0xfc0f0000, "r", 2 }, - -{ "linkfl", 0x18000000, 0xfc0f0000, "r,R", 2 }, -{ "linkbl", 0x18020000, 0xfc0f0000, "r,R", 2 }, -{ "linkfp", 0x18010000, 0xfc0f0000, "r,R", 2 }, -{ "linkbp", 0x18030000, 0xfc0f0000, "r,R", 2 }, -{ "linkpl", 0x18040000, 0xfc0f0000, "r,R", 2 }, -{ "ulinkl", 0x18080000, 0xfc0f0000, "r,R", 2 }, -{ "ulinkp", 0x18090000, 0xfc0f0000, "r,R", 2 }, -{ "ulinktl", 0x180a0000, 0xfc0f0000, "r,R", 2 }, -{ "ulinktp", 0x180b0000, 0xfc0f0000, "r,R", 2 }, -}; - -int numopcodes = sizeof(gld_opcodes) / sizeof(gld_opcodes[0]); - -struct gld_opcode *endop = gld_opcodes + sizeof(gld_opcodes) / - sizeof(gld_opcodes[0]); diff --git a/gnu/usr.bin/gdb/config/ns32k-opcode.h b/gnu/usr.bin/gdb/config/ns32k-opcode.h deleted file mode 100644 index b4f974ffd193..000000000000 --- a/gnu/usr.bin/gdb/config/ns32k-opcode.h +++ /dev/null @@ -1,331 +0,0 @@ -/* ns32k-opcode.h - - $Id: ns32k-opcode.h,v 1.2 1993/08/02 17:40:16 mycroft Exp $ -*/ - -#ifndef ns32k_opcodeT -#define ns32k_opcodeT int -#endif /* no ns32k_opcodeT */ - -struct not_wot /* ns32k opcode table: wot to do with this */ - /* particular opcode */ -{ - int obits; /* number of opcode bits */ - int ibits; /* number of instruction bits */ - ns32k_opcodeT code; /* op-code (may be > 8 bits!) */ - char *args; /* how to compile said opcode */ -}; - -struct not /* ns32k opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct not_wot detail; /* rest of opcode table [datum] */ -}; - -/* Instructions look like this: - - basic instruction--1, 2, or 3 bytes - index byte for operand A, if operand A is indexed--1 byte - index byte for operand B, if operand B is indexed--1 byte - addressing extension for operand A - addressing extension for operand B - implied operands - - Operand A is the operand listed first in the following opcode table. - Operand B is the operand listed second in the following opcode table. - All instructions have at most 2 general operands, so this is enough. - The implied operands are associated with operands other than A and B. - - Each operand has a digit and a letter. - - The digit gives the position in the assembly language. The letter, - one of the following, tells us what kind of operand it is. */ - -/* F : 32 bit float - * L : 64 bit float - * B : byte - * W : word - * D : double-word - * Q : quad-word - * d : displacement - * q : quick - * i : immediate (8 bits) - * r : register number (3 bits) - * p : displacement - pc relative addressing -*/ -static struct not -notstrs[] = -{ - { "absf", 14,24, 0x35be, "1F2F" }, - { "absl", 14,24, 0x34be, "1L2L" }, - { "absb", 14,24, 0x304e, "1B2B" }, - { "absw", 14,24, 0x314e, "1W2W" }, - { "absd", 14,24, 0x334e, "1D2D" }, - { "acbb", 7,16, 0x4c, "2B1q3p" }, - { "acbw", 7,16, 0x4d, "2W1q3p" }, - { "acbd", 7,16, 0x4f, "2D1q3p" }, - { "addf", 14,24, 0x01be, "1F2F" }, - { "addl", 14,24, 0x00be, "1L2L" }, - { "addb", 6,16, 0x00, "1B2B" }, - { "addw", 6,16, 0x01, "1W2W" }, - { "addd", 6,16, 0x03, "1D2D" }, - { "addcb", 6,16, 0x10, "1B2B" }, - { "addcw", 6,16, 0x11, "1W2W" }, - { "addcd", 6,16, 0x13, "1D2D" }, - { "addpb", 14,24, 0x3c4e, "1B2B" }, - { "addpw", 14,24, 0x3d4e, "1W2W" }, - { "addpd", 14,24, 0x3f4e, "1D2D" }, - { "addqb", 7,16, 0x0c, "2B1q" }, - { "addqw", 7,16, 0x0d, "2W1q" }, - { "addqd", 7,16, 0x0f, "2D1q" }, - { "addr", 6,16, 0x27, "1D2D" }, - { "adjspb", 11,16, 0x057c, "1B" }, - { "adjspw", 11,16, 0x057d, "1W" }, - { "adjspd", 11,16, 0x057f, "1D" }, - { "andb", 6,16, 0x28, "1B2B" }, - { "andw", 6,16, 0x29, "1W2W" }, - { "andd", 6,16, 0x2b, "1D2D" }, - { "ashb", 14,24, 0x044e, "1B2B" }, - { "ashw", 14,24, 0x054e, "1B2W" }, - { "ashd", 14,24, 0x074e, "1B2D" }, - { "beq", 8,8, 0x0a, "1p" }, - { "bne", 8,8, 0x1a, "1p" }, - { "bcs", 8,8, 0x2a, "1p" }, - { "bcc", 8,8, 0x3a, "1p" }, - { "bhi", 8,8, 0x4a, "1p" }, - { "bls", 8,8, 0x5a, "1p" }, - { "bgt", 8,8, 0x6a, "1p" }, - { "ble", 8,8, 0x7a, "1p" }, - { "bfs", 8,8, 0x8a, "1p" }, - { "bfc", 8,8, 0x9a, "1p" }, - { "blo", 8,8, 0xaa, "1p" }, - { "bhs", 8,8, 0xba, "1p" }, - { "blt", 8,8, 0xca, "1p" }, - { "bge", 8,8, 0xda, "1p" }, - { "bicb", 6,16, 0x08, "1B2B" }, - { "bicw", 6,16, 0x09, "1W2W" }, - { "bicd", 6,16, 0x0b, "1D2D" }, - { "bicpsrb", 11,16, 0x17c, "1B" }, - { "bicpsrw", 11,16, 0x17d, "1W" }, - { "bispsrb", 11,16, 0x37c, "1B" }, - { "bispsrw", 11,16, 0x37d, "1W" }, - { "bpt", 8,8, 0xf2, "" }, - { "br", 8,8, 0xea, "1p" }, - { "bsr", 8,8, 0x02, "1p" }, - { "caseb", 11,16, 0x77c, "1B" }, - { "casew", 11,16, 0x77d, "1W" }, - { "cased", 11,16, 0x77f, "1D" }, - { "cbitb", 14,24, 0x084e, "1B2D" }, - { "cbitw", 14,24, 0x094e, "1W2D" }, - { "cbitd", 14,24, 0x0b4e, "1D2D" }, - { "cbitib", 14,24, 0x0c4e, "1B2D" }, - { "cbitiw", 14,24, 0x0d4e, "1W2D" }, - { "cbitid", 14,24, 0x0f4e, "1D2D" }, - { "checkb", 11,24, 0x0ee, "2A3B1r" }, - { "checkw", 11,24, 0x1ee, "2A3B1r" }, - { "checkd", 11,24, 0x3ee, "2A3D1r" }, - { "cmpf", 14,24, 0x09be, "1F2F" }, - { "cmpl", 14,24, 0x08be, "1L2L" }, - { "cmpb", 6,16, 0x04, "1B2B" }, - { "cmpw", 6,16, 0x05, "1W2W" }, - { "cmpd", 6,16, 0x07, "1D2D" }, - { "cmpmb", 14,24, 0x04ce, "1D2D3d" }, - { "cmpmw", 14,24, 0x05ce, "1D2D3d" }, - { "cmpmd", 14,24, 0x07ce, "1D2D3d" }, - { "cmpqb", 7,16, 0x1c, "2B1q" }, - { "cmpqw", 7,16, 0x1d, "2W1q" }, - { "cmpqd", 7,16, 0x1f, "2D1q" }, - { "cmpsb", 16,16, 0x040e, "1i" }, - { "cmpsw", 16,16, 0x050e, "1i" }, - { "cmpsd", 16,16, 0x070e, "1i" }, - { "cmpst", 16,16, 0x840e, "1i" }, - { "comb", 14,24, 0x344e, "1B2B" }, - { "comw", 14,24, 0x354e, "1W2W" }, - { "comd", 14,24, 0x374e, "1D2D" }, - { "cvtp", 11,24, 0x036e, "2D3D1r" }, - { "cxp", 8,8, 0x22, "1p" }, - { "cxpd", 11,16, 0x07f, "1D" }, - { "deib", 14,24, 0x2cce, "1B2W" }, - { "deiw", 14,24, 0x2cce, "1W2D" }, - { "deid", 14,24, 0x2cce, "1D2Q" }, - { "dia", 8,8, 0xc2, "" }, - { "divf", 14,24, 0x21be, "1F2F" }, - { "divl", 14,24, 0x20be, "1L2L" }, - { "divb", 14,24, 0x3cce, "1B2B" }, - { "divw", 14,24, 0x3dce, "1W2W" }, - { "divd", 14,24, 0x3fce, "1D2D" }, - { "enter", 8,8, 0x82, "1i2d" }, - { "exit", 8,8, 0x92, "1i" }, - { "extb", 11,24, 0x02e, "2D3B1r4d" }, - { "extw", 11,24, 0x12e, "2D3W1r4d" }, - { "extd", 11,24, 0x32e, "2D3D1r4d" }, - { "extsb", 14,24, 0x0cce, "1D2B3i" }, - { "extsw", 14,24, 0x0dce, "1D2W3i" }, - { "extsd", 14,24, 0x0fce, "1D2D3i" }, - { "ffsb", 14,24, 0x046e, "1B2B" }, - { "ffsw", 14,24, 0x056e, "1W2B" }, - { "ffsd", 14,24, 0x076e, "1D2B" }, - { "flag", 8,8, 0xd2, "" }, - { "floorfb", 14,24, 0x3c3e, "1F2B" }, - { "floorfw", 14,24, 0x3d3e, "1F2W" }, - { "floorfd", 14,24, 0x3f3e, "1F2D" }, - { "floorlb", 14,24, 0x383e, "1L2B" }, - { "floorlw", 14,24, 0x393e, "1L2W" }, - { "floorld", 14,24, 0x3b3e, "1L2D" }, - { "ibitb", 14,24, 0x384e, "1B2D" }, - { "ibitw", 14,24, 0x394e, "1W2D" }, - { "ibitd", 14,24, 0x3b4e, "1D2D" }, - { "indexb", 11,24, 0x42e, "2B3B1r" }, - { "indexw", 11,24, 0x52e, "2W3W1r" }, - { "indexd", 11,24, 0x72e, "2D3D1r" }, - { "insb", 11,24, 0x0ae, "2B3B1r4d" }, - { "insw", 11,24, 0x1ae, "2W3W1r4d" }, - { "insd", 11,24, 0x3ae, "2D3D1r4d" }, - { "inssb", 14,24, 0x08ce, "1B2D3i" }, - { "inssw", 14,24, 0x09ce, "1W2D3i" }, - { "inssd", 14,24, 0x0bce, "1D2D3i" }, - { "jsr", 11,16, 0x67f, "1A" }, - { "jump", 11,16, 0x27f, "1A" }, - { "lfsr", 19,24, 0x00f3e,"1D" }, - { "lmr", 15,24, 0x0b1e, "2D1q" }, - { "lprb", 7,16, 0x6c, "2B1q" }, - { "lprw", 7,16, 0x6d, "2W1q" }, - { "lprd", 7,16, 0x6f, "2D1q" }, - { "lshb", 14,24, 0x144e, "1B2B" }, - { "lshw", 14,24, 0x154e, "1B2W" }, - { "lshd", 14,24, 0x174e, "1B2D" }, - { "meib", 14,24, 0x24ce, "1B2W" }, - { "meiw", 14,24, 0x25ce, "1W2D" }, - { "meid", 14,24, 0x27ce, "1D2Q" }, - { "modb", 14,24, 0x38ce, "1B2B" }, - { "modw", 14,24, 0x39ce, "1W2W" }, - { "modd", 14,24, 0x3bce, "1D2D" }, - { "movf", 14,24, 0x05be, "1F2F" }, - { "movl", 14,24, 0x04be, "1L2L" }, - { "movb", 6,16, 0x14, "1B2B" }, - { "movw", 6,16, 0x15, "1W2W" }, - { "movd", 6,16, 0x17, "1D2D" }, - { "movbf", 14,24, 0x043e, "1B2F" }, - { "movwf", 14,24, 0x053e, "1W2F" }, - { "movdf", 14,24, 0x073e, "1D2F" }, - { "movbl", 14,24, 0x003e, "1B2L" }, - { "movwl", 14,24, 0x013e, "1W2L" }, - { "movdl", 14,24, 0x033e, "1D2L" }, - { "movfl", 14,24, 0x1b3e, "1F2L" }, - { "movlf", 14,24, 0x163e, "1L2F" }, - { "movmb", 14,24, 0x00ce, "1D2D3d" }, - { "movmw", 14,24, 0x00de, "1D2D3d" }, - { "movmd", 14,24, 0x00fe, "1D2D3d" }, - { "movqb", 7,16, 0x5c, "2B1q" }, - { "movqw", 7,16, 0x5d, "2B1q" }, - { "movqd", 7,16, 0x5f, "2B1q" }, - { "movsb", 16,16, 0x000e, "1i" }, - { "movsw", 16,16, 0x010e, "1i" }, - { "movsd", 16,16, 0x030e, "1i" }, - { "movst", 16,16, 0x800e, "1i" }, - { "movsub", 14,24, 0x0cae, "1A1A" }, - { "movsuw", 14,24, 0x0dae, "1A1A" }, - { "movsud", 14,24, 0x0fae, "1A1A" }, - { "movusb", 14,24, 0x1cae, "1A1A" }, - { "movusw", 14,24, 0x1dae, "1A1A" }, - { "movusd", 14,24, 0x1fae, "1A1A" }, - { "movxbd", 14,24, 0x1cce, "1B2D" }, - { "movxwd", 14,24, 0x1dce, "1W2D" }, - { "movxbw", 14,24, 0x10ce, "1B2W" }, - { "movzbd", 14,24, 0x18ce, "1B2D" }, - { "movzwd", 14,24, 0x19ce, "1W2D" }, - { "movzbw", 14,24, 0x14ce, "1B2W" }, - { "mulf", 14,24, 0x31be, "1F2F" }, - { "mull", 14,24, 0x30be, "1L2L" }, - { "mulb", 14,24, 0x20ce, "1B2B" }, - { "mulw", 14,24, 0x21ce, "1W2W" }, - { "muld", 14,24, 0x23ce, "1D2D" }, - { "negf", 14,24, 0x15be, "1F2F" }, - { "negl", 14,24, 0x14be, "1L2L" }, - { "negb", 14,24, 0x204e, "1B2B" }, - { "negw", 14,24, 0x214e, "1W2W" }, - { "negd", 14,24, 0x234e, "1D2D" }, - { "nop", 8,8, 0xa2, "" }, - { "notb", 14,24, 0x244e, "1B2B" }, - { "notw", 14,24, 0x254e, "1W2W" }, - { "notd", 14,24, 0x274e, "1D2D" }, - { "orb", 6,16, 0x18, "1B1B" }, - { "orw", 6,16, 0x19, "1W1W" }, - { "ord", 6,16, 0x1b, "1D2D" }, - { "quob", 14,24, 0x30ce, "1B2B" }, - { "quow", 14,24, 0x31ce, "1W2W" }, - { "quod", 14,24, 0x33ce, "1D2D" }, - { "rdval", 19,24, 0x0031e,"1A" }, - { "remb", 14,24, 0x34ce, "1B2B" }, - { "remw", 14,24, 0x35ce, "1W2W" }, - { "remd", 14,24, 0x37ce, "1D2D" }, - { "restore", 8,8, 0x72, "1i" }, - { "ret", 8,8, 0x12, "1d" }, - { "reti", 8,8, 0x52, "" }, - { "rett", 8,8, 0x42, "" }, - { "rotb", 14,24, 0x004e, "1B2B" }, - { "rotw", 14,24, 0x014e, "1B2W" }, - { "rotd", 14,24, 0x034e, "1B2D" }, - { "roundfb", 14,24, 0x243e, "1F2B" }, - { "roundfw", 14,24, 0x253e, "1F2W" }, - { "roundfd", 14,24, 0x273e, "1F2D" }, - { "roundlb", 14,24, 0x203e, "1L2B" }, - { "roundlw", 14,24, 0x213e, "1L2W" }, - { "roundld", 14,24, 0x233e, "1L2D" }, - { "rxp", 8,8, 0x32, "1d" }, - { "sCONDb", 7,16, 0x3c, "2B1q" }, - { "sCONDw", 7,16, 0x3d, "2D1q" }, - { "sCONDd", 7,16, 0x3f, "2D1q" }, - { "save", 8,8, 0x62, "1i" }, - { "sbitb", 14,24, 0x184e, "1B2A" }, - { "sbitw", 14,24, 0x194e, "1W2A" }, - { "sbitd", 14,24, 0x1b4e, "1D2A" }, - { "sbitib", 14,24, 0x1c4e, "1B2A" }, - { "sbitiw", 14,24, 0x1d4e, "1W2A" }, - { "sbitid", 14,24, 0x1f4e, "1D2A" }, - { "setcfg", 15,24, 0x0b0e, "5D1q" }, - { "sfsr", 14,24, 0x673e, "5D1D" }, - { "skpsb", 16,16, 0x0c0e, "1i" }, - { "skpsw", 16,16, 0x0d0e, "1i" }, - { "skpsd", 16,16, 0x0f0e, "1i" }, - { "skpst", 16,16, 0x8c0e, "1i" }, - { "smr", 15,24, 0x0f1e, "2D1q" }, - { "sprb", 7,16, 0x2c, "2B1q" }, - { "sprw", 7,16, 0x2d, "2W1q" }, - { "sprd", 7,16, 0x2f, "2D1q" }, - { "subf", 14,24, 0x11be, "1F2F" }, - { "subl", 14,24, 0x10be, "1L2L" }, - { "subb", 6,16, 0x20, "1B2B" }, - { "subw", 6,16, 0x21, "1W2W" }, - { "subd", 6,16, 0x23, "1D2D" }, - { "subcb", 6,16, 0x30, "1B2B" }, - { "subcw", 6,16, 0x31, "1W2W" }, - { "subcd", 6,16, 0x33, "1D2D" }, - { "subpb", 14,24, 0x2c4e, "1B2B" }, - { "subpw", 14,24, 0x2d4e, "1W2W" }, - { "subpd", 14,24, 0x2f4e, "1D2D" }, -#ifndef NS32K_SVC_IMMED_OPERANDS - { "svc", 8,8, 0xe2, "2i1i" }, /* not really, but unix uses it */ -#else - { "svc", 8,8, 0xe2, "" }, /* not really, but unix uses it */ -#endif - { "tbitb", 6,16, 0x34, "1B2A" }, - { "tbitw", 6,16, 0x35, "1W2A" }, - { "tbitd", 6,16, 0x37, "1D2A" }, - { "truncfb", 14,24, 0x2c3e, "1F2B" }, - { "truncfw", 14,24, 0x2d3e, "1F2W" }, - { "truncfd", 14,24, 0x2f3e, "1F2D" }, - { "trunclb", 14,24, 0x283e, "1L2B" }, - { "trunclw", 14,24, 0x293e, "1L2W" }, - { "truncld", 14,24, 0x2b3e, "1L2D" }, - { "wait", 8,8, 0xb2, "" }, - { "wrval", 19,24, 0x0071e,"1A" }, - { "xorb", 6,16, 0x38, "1B2B" }, - { "xorw", 6,16, 0x39, "1W2W" }, - { "xord", 6,16, 0x3b, "1D2D" }, -}; /* notstrs */ - -/* end: ns32k.opcode.h */ - -#define MAX_ARGS 4 -#define ARG_LEN 50 diff --git a/gnu/usr.bin/gdb/config/ns32k-pinsn.c b/gnu/usr.bin/gdb/config/ns32k-pinsn.c deleted file mode 100644 index cfde3fa27aba..000000000000 --- a/gnu/usr.bin/gdb/config/ns32k-pinsn.c +++ /dev/null @@ -1,526 +0,0 @@ -/* Print 32000 instructions for GDB, the GNU debugger. - Copyright (C) 1986,1988 Free Software Foundation, Inc. - -GDB is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY. No author or distributor accepts responsibility to anyone -for the consequences of using it or for whether it serves any -particular purpose or works at all, unless he says so in writing. -Refer to the GDB General Public License for full details. - -Everyone is granted permission to copy, modify and redistribute GDB, -but only under the conditions described in the GDB General Public -License. A copy of this license is supposed to have been given to you -along with GDB so you can know your rights and responsibilities. It -should be in a file named COPYING. Among other things, the copyright -notice and this notice must be preserved on all copies. - -In other words, go ahead and share GDB, but don't try to stop -anyone else from sharing it farther. Help stamp out software hoarding! -*/ - -#ifndef lint -static char rcsid[] = "$Id: ns32k-pinsn.c,v 1.2 1993/08/02 17:40:16 mycroft Exp $"; -#endif /* not lint */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "opcode.h" - -/* 32000 instructions are never longer than this. */ -#define MAXLEN 62 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof notstrs / sizeof notstrs[0]) - -extern char *reg_names[]; - -#define NEXT_IS_ADDR '|' - -/* - * extract "count" bits starting "offset" bits - * into buffer - */ - -int -bit_extract (buffer, offset, count) - char *buffer; - int offset; - int count; -{ - int result; - int mask; - int bit; - - buffer += offset >> 3; - offset &= 7; - bit = 1; - result = 0; - while (count--) - { - if ((*buffer & (1 << offset))) - result |= bit; - if (++offset == 8) - { - offset = 0; - buffer++; - } - bit <<= 1; - } - return result; -} - -float -fbit_extract (buffer, offset, count) -{ - union { - int ival; - float fval; - } foo; - - foo.ival = bit_extract (buffer, offset, 32); - return foo.fval; -} - -double -dbit_extract (buffer, offset, count) -{ - union { - struct {int low, high; } ival; - double dval; - } foo; - - foo.ival.low = bit_extract (buffer, offset, 32); - foo.ival.high = bit_extract (buffer, offset+32, 32); - return foo.dval; -} - -sign_extend (value, bits) -{ - value = value & ((1 << bits) - 1); - return (value & (1 << (bits-1)) - ? value | (~((1 << bits) - 1)) - : value); -} - -flip_bytes (ptr, count) - char *ptr; - int count; -{ - char tmp; - - while (count > 0) - { - tmp = *ptr; - ptr[0] = ptr[count-1]; - ptr[count-1] = tmp; - ptr++; - count -= 2; - } -} - -/* Given a character C, does it represent a general addressing mode? */ -#define Is_gen(c) \ - ((c) == 'F' || (c) == 'L' || (c) == 'B' \ - || (c) == 'W' || (c) == 'D' || (c) == 'A') - -/* Adressing modes. */ -#define Adrmod_index_byte 0x1c -#define Adrmod_index_word 0x1d -#define Adrmod_index_doubleword 0x1e -#define Adrmod_index_quadword 0x1f - -/* Is MODE an indexed addressing mode? */ -#define Adrmod_is_index(mode) \ - (mode == Adrmod_index_byte \ - || mode == Adrmod_index_word \ - || mode == Adrmod_index_doubleword \ - || mode == Adrmod_index_quadword) - - -/* Print the 32000 instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register unsigned char *p; - register char *d; - unsigned short first_word; - int gen, disp; - int ioffset; /* bits into instruction */ - int aoffset; /* bits into arguments */ - char arg_bufs[MAX_ARGS+1][ARG_LEN]; - int argnum; - int maxarg; - - read_memory (memaddr, buffer, MAXLEN); - - first_word = *(unsigned short *) buffer; - for (i = 0; i < NOPCODES; i++) - if ((first_word & ((1 << notstrs[i].detail.obits) - 1)) - == notstrs[i].detail.code) - break; - - /* Handle undefined instructions. */ - if (i == NOPCODES) - { - fprintf (stream, "0%o", buffer[0]); - return 1; - } - - fprintf (stream, "%s", notstrs[i].name); - - ioffset = notstrs[i].detail.ibits; - aoffset = notstrs[i].detail.ibits; - d = notstrs[i].detail.args; - - if (*d) - { - /* Offset in bits of the first thing beyond each index byte. - Element 0 is for operand A and element 1 is for operand B. - The rest are irrelevant, but we put them here so we don't - index outside the array. */ - int index_offset[MAX_ARGS]; - - /* 0 for operand A, 1 for operand B, greater for other args. */ - int whicharg = 0; - - fputc ('\t', stream); - - maxarg = 0; - - /* First we have to find and keep track of the index bytes, - if we are using scaled indexed addressing mode, since the index - bytes occur right after the basic instruction, not as part - of the addressing extension. */ - if (Is_gen(d[1])) - { - int addr_mode = bit_extract (buffer, ioffset - 5, 5); - - if (Adrmod_is_index (addr_mode)) - { - aoffset += 8; - index_offset[0] = aoffset; - } - } - if (d[2] && Is_gen(d[3])) - { - int addr_mode = bit_extract (buffer, ioffset - 10, 5); - - if (Adrmod_is_index (addr_mode)) - { - aoffset += 8; - index_offset[1] = aoffset; - } - } - - while (*d) - { - argnum = *d - '1'; - d++; - if (argnum > maxarg && argnum < MAX_ARGS) - maxarg = argnum; - ioffset = print_insn_arg (*d, ioffset, &aoffset, buffer, - memaddr, arg_bufs[argnum], - index_offset[whicharg]); - d++; - whicharg++; - } - for (argnum = 0; argnum <= maxarg; argnum++) - { - CORE_ADDR addr; - char *ch, *index (); - for (ch = arg_bufs[argnum]; *ch;) - { - if (*ch == NEXT_IS_ADDR) - { - ++ch; - addr = atoi (ch); - print_address (addr, stream); - while (*ch && *ch != NEXT_IS_ADDR) - ++ch; - if (*ch) - ++ch; - } - else - putc (*ch++, stream); - } - if (argnum < maxarg) - fprintf (stream, ", "); - } - } - return aoffset / 8; -} - -/* Print an instruction operand of category given by d. IOFFSET is - the bit position below which small (<1 byte) parts of the operand can - be found (usually in the basic instruction, but for indexed - addressing it can be in the index byte). AOFFSETP is a pointer to the - bit position of the addressing extension. BUFFER contains the - instruction. ADDR is where BUFFER was read from. Put the disassembled - version of the operand in RESULT. INDEX_OFFSET is the bit position - of the index byte (it contains garbage if this operand is not a - general operand using scaled indexed addressing mode). */ - -print_insn_arg (d, ioffset, aoffsetp, buffer, addr, result, index_offset) - char d; - int ioffset, *aoffsetp; - char *buffer; - CORE_ADDR addr; - char *result; - int index_offset; -{ - int addr_mode; - float Fvalue; - double Lvalue; - int Ivalue; - int disp1, disp2; - int index; - - switch (d) - { - case 'F': - case 'L': - case 'B': - case 'W': - case 'D': - case 'A': - addr_mode = bit_extract (buffer, ioffset-5, 5); - ioffset -= 5; - switch (addr_mode) - { - case 0x0: case 0x1: case 0x2: case 0x3: - case 0x4: case 0x5: case 0x6: case 0x7: - switch (d) - { - case 'F': - case 'L': - sprintf (result, "f%d", addr_mode); - break; - default: - sprintf (result, "r%d", addr_mode); - } - break; - case 0x8: case 0x9: case 0xa: case 0xb: - case 0xc: case 0xd: case 0xe: case 0xf: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "%d(r%d)", disp1, addr_mode & 7); - break; - case 0x10: - case 0x11: - case 0x12: - disp1 = get_displacement (buffer, aoffsetp); - disp2 = get_displacement (buffer, aoffsetp); - sprintf (result, "%d(%d(%s))", disp2, disp1, - addr_mode==0x10?"fp":addr_mode==0x11?"sp":"sb"); - break; - case 0x13: - sprintf (result, "reserved"); - break; - case 0x14: - switch (d) - { - case 'B': - Ivalue = bit_extract (buffer, *aoffsetp, 8); - Ivalue = sign_extend (Ivalue, 8); - *aoffsetp += 8; - sprintf (result, "$%d", Ivalue); - break; - case 'W': - Ivalue = bit_extract (buffer, *aoffsetp, 16); - flip_bytes (&Ivalue, 2); - *aoffsetp += 16; - Ivalue = sign_extend (Ivalue, 16); - sprintf (result, "$%d", Ivalue); - break; - case 'D': - Ivalue = bit_extract (buffer, *aoffsetp, 32); - flip_bytes (&Ivalue, 4); - *aoffsetp += 32; - sprintf (result, "$%d", Ivalue); - break; - case 'A': - Ivalue = bit_extract (buffer, *aoffsetp, 32); - flip_bytes (&Ivalue, 4); - *aoffsetp += 32; - sprintf (result, "$|%d|", Ivalue); - break; - case 'F': - Fvalue = fbit_extract (buffer, *aoffsetp, 32); - flip_bytes (&Fvalue, 4); - *aoffsetp += 32; - sprintf (result, "$%g", Fvalue); - break; - case 'L': - Lvalue = dbit_extract (buffer, *aoffsetp, 64); - flip_bytes (&Lvalue, 8); - *aoffsetp += 64; - sprintf (result, "$%g", Lvalue); - break; - } - break; - case 0x15: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "@|%d|", disp1); - break; - case 0x16: - disp1 = get_displacement (buffer, aoffsetp); - disp2 = get_displacement (buffer, aoffsetp); - sprintf (result, "EXT(%d) + %d", disp1, disp2); - break; - case 0x17: - sprintf (result, "tos"); - break; - case 0x18: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "%d(fp)", disp1); - break; - case 0x19: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "%d(sp)", disp1); - break; - case 0x1a: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "%d(sb)", disp1); - break; - case 0x1b: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "|%d|", addr + disp1); - break; - case 0x1c: - case 0x1d: - case 0x1e: - case 0x1f: - index = bit_extract (buffer, index_offset - 8, 3); - print_insn_arg (d, index_offset, aoffsetp, buffer, addr, - result, 0); - { - static char *ind[] = {"b", "w", "d", "q"}; - char *off; - - off = result + strlen (result); - sprintf (off, "[r%d:%s]", index, - ind[addr_mode & 3]); - } - break; - } - break; - case 'q': - Ivalue = bit_extract (buffer, ioffset-4, 4); - Ivalue = sign_extend (Ivalue, 4); - sprintf (result, "%d", Ivalue); - ioffset -= 4; - break; - case 'r': - Ivalue = bit_extract (buffer, ioffset-3, 3); - sprintf (result, "r%d", Ivalue&7); - ioffset -= 3; - break; - case 'd': - sprintf (result, "%d", get_displacement (buffer, aoffsetp)); - break; - case 'p': - sprintf (result, "%c%d%c", NEXT_IS_ADDR, - addr + get_displacement (buffer, aoffsetp), - NEXT_IS_ADDR); - break; - case 'i': - Ivalue = bit_extract (buffer, *aoffsetp, 8); - *aoffsetp += 8; - sprintf (result, "0x%x", Ivalue); - break; - } - return ioffset; -} - -get_displacement (buffer, aoffsetp) - char *buffer; - int *aoffsetp; -{ - int Ivalue; - - Ivalue = bit_extract (buffer, *aoffsetp, 8); - switch (Ivalue & 0xc0) - { - case 0x00: - case 0x40: - Ivalue = sign_extend (Ivalue, 7); - *aoffsetp += 8; - break; - case 0x80: - Ivalue = bit_extract (buffer, *aoffsetp, 16); - flip_bytes (&Ivalue, 2); - Ivalue = sign_extend (Ivalue, 14); - *aoffsetp += 16; - break; - case 0xc0: - Ivalue = bit_extract (buffer, *aoffsetp, 32); - flip_bytes (&Ivalue, 4); - Ivalue = sign_extend (Ivalue, 30); - *aoffsetp += 32; - break; - } - return Ivalue; -} - -/* Return the number of locals in the current frame given a pc - pointing to the enter instruction. This is used in the macro - FRAME_FIND_SAVED_REGS. */ - -ns32k_localcount (enter_pc) - CORE_ADDR enter_pc; -{ - unsigned char localtype; - int localcount; - - localtype = read_memory_integer (enter_pc+2, 1); - if ((localtype & 0x80) == 0) - localcount = localtype; - else if ((localtype & 0xc0) == 0x80) - localcount = (((localtype & 0x3f) << 8) - | (read_memory_integer (enter_pc+3, 1) & 0xff)); - else - localcount = (((localtype & 0x3f) << 24) - | ((read_memory_integer (enter_pc+3, 1) & 0xff) << 16) - | ((read_memory_integer (enter_pc+4, 1) & 0xff) << 8 ) - | (read_memory_integer (enter_pc+5, 1) & 0xff)); - return localcount; -} - -/* - * Get the address of the enter opcode for the function - * containing PC, if there is an enter for the function, - * and if the pc is between the enter and exit. - * Returns positive address if pc is between enter/exit, - * 1 if pc before enter or after exit, 0 otherwise. - */ - -CORE_ADDR -ns32k_get_enter_addr (pc) - CORE_ADDR pc; -{ - CORE_ADDR enter_addr; - unsigned char op; - - if (ABOUT_TO_RETURN (pc)) - return 1; /* after exit */ - - enter_addr = get_pc_function_start (pc); - - if (pc == enter_addr) - return 1; /* before enter */ - - op = read_memory_integer (enter_addr, 1); - - if (op != 0x82) - return 0; /* function has no enter/exit */ - - return enter_addr; /* pc is between enter and exit */ -} diff --git a/gnu/usr.bin/gdb/config/pn-opcode.h b/gnu/usr.bin/gdb/config/pn-opcode.h deleted file mode 100644 index 105c7840e67f..000000000000 --- a/gnu/usr.bin/gdb/config/pn-opcode.h +++ /dev/null @@ -1,285 +0,0 @@ -/* Print PN instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: pn-opcode.h,v 1.2 1993/08/02 17:40:17 mycroft Exp $ -*/ - -struct gld_opcode -{ - char *name; - unsigned long opcode; - unsigned long mask; - char *args; - int length; -}; - -/* We store four bytes of opcode for all opcodes because that - is the most any of them need. The actual length of an instruction - is always at least 2 bytes, and at most four. The length of the - instruction is based on the opcode. - - The mask component is a mask saying which bits must match - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing characters - that are used to format the arguments to the instruction. */ - -/* Kinds of operands: - r Register in first field - R Register in second field - b Base register in first field - B Base register in second field - v Vector register in first field - V Vector register in first field - A Optional address register (base register) - X Optional index register - I Immediate data (16bits signed) - O Offset field (16bits signed) - h Offset field (15bits signed) - d Offset field (14bits signed) - S Shift count field - - any other characters are printed as is... -*/ - -/* The assembler requires that this array be sorted as follows: - all instances of the same mnemonic must be consecutive. - All instances of the same mnemonic with the same number of operands - must be consecutive. - */ -struct gld_opcode gld_opcodes[] = -{ -{ "abm", 0xa0080000, 0xfc080000, "f,xOA,X", 4 }, -{ "abr", 0x18080000, 0xfc0c0000, "r,f", 2 }, -{ "aci", 0xfc770000, 0xfc7f8000, "r,I", 4 }, -{ "adfd", 0xe0080002, 0xfc080002, "r,xOA,X", 4 }, -{ "adfw", 0xe0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "adi", 0xc8010000, 0xfc7f0000, "r,I", 4 }, -{ "admb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "admd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "admh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "admw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "adr", 0x38000000, 0xfc0f0000, "r,R", 2 }, -{ "adrfd", 0x38090000, 0xfc0f0000, "r,R", 2 }, -{ "adrfw", 0x38010000, 0xfc0f0000, "r,R", 2 }, -{ "adrm", 0x38080000, 0xfc0f0000, "r,R", 2 }, -{ "ai", 0xfc030000, 0xfc07ffff, "I", 4 }, -{ "anmb", 0x84080000, 0xfc080000, "r,xOA,X", 4 }, -{ "anmd", 0x84000002, 0xfc080002, "r,xOA,X", 4 }, -{ "anmh", 0x84000001, 0xfc080001, "r,xOA,X", 4 }, -{ "anmw", 0x84000000, 0xfc080000, "r,xOA,X", 4 }, -{ "anr", 0x04000000, 0xfc0f0000, "r,R", 2 }, -{ "armb", 0xe8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "armd", 0xe8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "armh", 0xe8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "armw", 0xe8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bcf", 0xf0000000, 0xfc080000, "I,xOA,X", 4 }, -{ "bct", 0xec000000, 0xfc080000, "I,xOA,X", 4 }, -{ "bei", 0x00060000, 0xffff0000, "", 2 }, -{ "bft", 0xf0000000, 0xff880000, "xOA,X", 4 }, -{ "bib", 0xf4000000, 0xfc780000, "r,xOA", 4 }, -{ "bid", 0xf4600000, 0xfc780000, "r,xOA", 4 }, -{ "bih", 0xf4200000, 0xfc780000, "r,xOA", 4 }, -{ "biw", 0xf4400000, 0xfc780000, "r,xOA", 4 }, -{ "bl", 0xf8800000, 0xff880000, "xOA,X", 4 }, -{ "bsub", 0x5c080000, 0xff8f0000, "", 2 }, -{ "bsubm", 0x28080000, 0xfc080000, "", 4 }, -{ "bu", 0xec000000, 0xff880000, "xOA,X", 4 }, -{ "call", 0x28080000, 0xfc0f0000, "", 2 }, -{ "callm", 0x5c080000, 0xff880000, "", 4 }, -{ "camb", 0x90080000, 0xfc080000, "r,xOA,X", 4 }, -{ "camd", 0x90000002, 0xfc080002, "r,xOA,X", 4 }, -{ "camh", 0x90000001, 0xfc080001, "r,xOA,X", 4 }, -{ "camw", 0x90000000, 0xfc080000, "r.xOA,X", 4 }, -{ "car", 0x10000000, 0xfc0f0000, "r,R", 2 }, -{ "cd", 0xfc060000, 0xfc070000, "r,f", 4 }, -{ "cea", 0x000f0000, 0xffff0000, "", 2 }, -{ "ci", 0xc8050000, 0xfc7f0000, "r,I", 4 }, -{ "cmc", 0x040a0000, 0xfc7f0000, "r", 2 }, -{ "cmmb", 0x94080000, 0xfc080000, "r,xOA,X", 4 }, -{ "cmmd", 0x94000002, 0xfc080002, "r,xOA,X", 4 }, -{ "cmmh", 0x94000001, 0xfc080001, "r,xOA,X", 4 }, -{ "cmmw", 0x94000000, 0xfc080000, "r,xOA,X", 4 }, -{ "cmr", 0x14000000, 0xfc0f0000, "r,R", 2 }, -{ "daci", 0xfc7f0000, 0xfc7f8000, "r,I", 4 }, -{ "dae", 0x000e0000, 0xffff0000, "", 2 }, -{ "dai", 0xfc040000, 0xfc07ffff, "I", 4 }, -{ "dci", 0xfc6f0000, 0xfc7f8000, "r,I", 4 }, -{ "di", 0xfc010000, 0xfc07ffff, "I", 4 }, -{ "dvfd", 0xe4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "dvfw", 0xe4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvi", 0xc8040000, 0xfc7f0000, "r,I", 4 }, -{ "dvmb", 0xc4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvmh", 0xc4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "dvmw", 0xc4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvr", 0x380a0000, 0xfc0f0000, "r,R", 2 }, -{ "dvrfd", 0x380c0000, 0xfc0f0000, "r,R", 4 }, -{ "dvrfw", 0x38040000, 0xfc0f0000, "r,xOA,X", 4 }, -{ "eae", 0x00080000, 0xffff0000, "", 2 }, -{ "eci", 0xfc670000, 0xfc7f8080, "r,I", 4 }, -{ "ecwcs", 0xfc4f0000, 0xfc7f8000, "", 4 }, -{ "ei", 0xfc000000, 0xfc07ffff, "I", 4 }, -{ "eomb", 0x8c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "eomd", 0x8c000002, 0xfc080002, "r,xOA,X", 4 }, -{ "eomh", 0x8c000001, 0xfc080001, "r,xOA,X", 4 }, -{ "eomw", 0x8c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "eor", 0x0c000000, 0xfc0f0000, "r,R", 2 }, -{ "eorm", 0x0c080000, 0xfc0f0000, "r,R", 2 }, -{ "es", 0x00040000, 0xfc7f0000, "r", 2 }, -{ "exm", 0xa8000000, 0xff880000, "xOA,X", 4 }, -{ "exr", 0xc8070000, 0xfc7f0000, "r", 2 }, -{ "exrr", 0xc8070002, 0xfc7f0002, "r", 2 }, -{ "fixd", 0x380d0000, 0xfc0f0000, "r,R", 2 }, -{ "fixw", 0x38050000, 0xfc0f0000, "r,R", 2 }, -{ "fltd", 0x380f0000, 0xfc0f0000, "r,R", 2 }, -{ "fltw", 0x38070000, 0xfc0f0000, "r,R", 2 }, -{ "grio", 0xfc3f0000, 0xfc7f8000, "r,I", 4 }, -{ "halt", 0x00000000, 0xffff0000, "", 2 }, -{ "hio", 0xfc370000, 0xfc7f8000, "r,I", 4 }, -{ "jwcs", 0xfa080000, 0xff880000, "xOA,X", 4 }, -{ "la", 0x50000000, 0xfc000000, "r,xOA,X", 4 }, -{ "labr", 0x58080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lb", 0xac080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lcs", 0x00030000, 0xfc7f0000, "r", 2 }, -{ "ld", 0xac000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lear", 0x80000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lf", 0xcc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lfbr", 0xcc080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lh", 0xac000001, 0xfc080001, "r,xOA,X", 4 }, -{ "li", 0xc8000000, 0xfc7f0000, "r,I", 4 }, -{ "lmap", 0x2c070000, 0xfc7f0000, "r", 2 }, -{ "lmb", 0xb0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lmd", 0xb0000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lmh", 0xb0000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lmw", 0xb0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnb", 0xb4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnd", 0xb4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lnh", 0xb4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lnw", 0xb4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lpsd", 0xf9800000, 0xff880000, "r,xOA,X", 4 }, -{ "lpsdcm", 0xfa800000, 0xff880000, "r,xOA,X", 4 }, -{ "lw", 0xac000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lwbr", 0x5c000000, 0xfc080000, "b,xOA,X", 4 }, -{ "mpfd", 0xe4080002, 0xfc080002, "r,xOA,X", 4 }, -{ "mpfw", 0xe4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpi", 0xc8030000, 0xfc7f0000, "r,I", 4 }, -{ "mpmb", 0xc0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpmh", 0xc0000001, 0xfc080001, "r,xOA,X", 4 }, -{ "mpmw", 0xc0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpr", 0x38020000, 0xfc0f0000, "r,R", 2 }, -{ "mprfd", 0x380e0000, 0xfc0f0000, "r,R", 2 }, -{ "mprfw", 0x38060000, 0xfc0f0000, "r,R", 2 }, -{ "nop", 0x00020000, 0xffff0000, "", 2 }, -{ "ormb", 0x88080000, 0xfc080000, "r,xOA,X", 4 }, -{ "ormd", 0x88000002, 0xfc080002, "r,xOA,X", 4 }, -{ "ormh", 0x88000001, 0xfc080001, "r,xOA,X", 4 }, -{ "ormw", 0x88000000, 0xfc080000, "r,xOA,X", 4 }, -{ "orr", 0x08000000, 0xfc0f0000, "r,R", 2 }, -{ "orrm", 0x08080000, 0xfc0f0000, "r,R", 2 }, -{ "rdsts", 0x00090000, 0xfc7f0000, "r", 2 }, -{ "return", 0x280e0000, 0xfc7f0000, "", 2 }, -{ "ri", 0xfc020000, 0xfc07ffff, "I", 4 }, -{ "rnd", 0x00050000, 0xfc7f0000, "r", 2 }, -{ "rpswt", 0x040b0000, 0xfc7f0000, "r", 2 }, -{ "rschnl", 0xfc2f0000, 0xfc7f8000, "r,I", 4 }, -{ "rsctl", 0xfc470000, 0xfc7f8000, "r,I", 4 }, -{ "rwcs", 0x000b0000, 0xfc0f0000, "r,R", 2 }, -{ "sacz", 0x10080000, 0xfc0f0000, "r,R", 2 }, -{ "sbm", 0x98080000, 0xfc080000, "f,xOA,X", 4 }, -{ "sbr", 0x18000000, 0xfc0c0000, "r,f", 4 }, -{ "sea", 0x000d0000, 0xffff0000, "", 2 }, -{ "setcpu", 0x2c090000, 0xfc7f0000, "r", 2 }, -{ "sio", 0xfc170000, 0xfc7f8000, "r,I", 4 }, -{ "sipu", 0x000a0000, 0xffff0000, "", 2 }, -{ "sla", 0x1c400000, 0xfc600000, "r,S", 2 }, -{ "slad", 0x20400000, 0xfc600000, "r,S", 2 }, -{ "slc", 0x24400000, 0xfc600000, "r,S", 2 }, -{ "sll", 0x1c600000, 0xfc600000, "r,S", 2 }, -{ "slld", 0x20600000, 0xfc600000, "r,S", 2 }, -{ "smc", 0x04070000, 0xfc070000, "", 2 }, -{ "sra", 0x1c000000, 0xfc600000, "r,S", 2 }, -{ "srad", 0x20000000, 0xfc600000, "r,S", 2 }, -{ "src", 0x24000000, 0xfc600000, "r,S", 2 }, -{ "srl", 0x1c200000, 0xfc600000, "r,S", 2 }, -{ "srld", 0x20200000, 0xfc600000, "r,S", 2 }, -{ "stb", 0xd4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "std", 0xd4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stf", 0xdc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stfbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 }, -{ "sth", 0xd4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stmb", 0xd8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "stmd", 0xd8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stmh", 0xd8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stmw", 0xd8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stpio", 0xfc270000, 0xfc7f8000, "r,I", 4 }, -{ "stw", 0xd4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stwbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 }, -{ "suabr", 0x58000000, 0xfc080000, "b,xOA,X", 4 }, -{ "sufd", 0xe0000002, 0xfc080002, "r,xOA,X", 4 }, -{ "sufw", 0xe0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "sui", 0xc8020000, 0xfc7f0000, "r,I", 4 }, -{ "sumb", 0xbc080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sumd", 0xbc000002, 0xfc080002, "r,xOA,X", 4 }, -{ "sumh", 0xbc000001, 0xfc080001, "r,xOA,X", 4 }, -{ "sumw", 0xbc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "sur", 0x3c000000, 0xfc0f0000, "r,R", 2 }, -{ "surfd", 0x380b0000, 0xfc0f0000, "r,xOA,X", 4 }, -{ "surfw", 0x38030000, 0xfc0f0000, "r,R", 2 }, -{ "surm", 0x3c080000, 0xfc0f0000, "r,R", 2 }, -{ "svc", 0xc8060000, 0xffff0000, "", 4 }, -{ "tbm", 0xa4080000, 0xfc080000, "f,xOA,X", 4 }, -{ "tbr", 0x180c0000, 0xfc0c0000, "r,f", 2 }, -{ "tbrr", 0x2c020000, 0xfc0f0000, "r,B", 2 }, -{ "tccr", 0x28040000, 0xfc7f0000, "", 2 }, -{ "td", 0xfc050000, 0xfc070000, "r,f", 4 }, -{ "tio", 0xfc1f0000, 0xfc7f8000, "r,I", 4 }, -{ "tmapr", 0x2c0a0000, 0xfc0f0000, "r,R", 2 }, -{ "tpcbr", 0x280c0000, 0xfc7f0000, "r", 2 }, -{ "trbr", 0x2c010000, 0xfc0f0000, "b,R", 2 }, -{ "trc", 0x2c030000, 0xfc0f0000, "r,R", 2 }, -{ "trcc", 0x28050000, 0xfc7f0000, "", 2 }, -{ "trcm", 0x2c0b0000, 0xfc0f0000, "r,R", 2 }, -{ "trn", 0x2c040000, 0xfc0f0000, "r,R", 2 }, -{ "trnm", 0x2c0c0000, 0xfc0f0000, "r,R", 2 }, -{ "trr", 0x2c000000, 0xfc0f0000, "r,R", 2 }, -{ "trrm", 0x2c080000, 0xfc0f0000, "r,R", 2 }, -{ "trsc", 0x2c0e0000, 0xfc0f0000, "r,R", 2 }, -{ "trsw", 0x28000000, 0xfc7f0000, "r", 2 }, -{ "tscr", 0x2c0f0000, 0xfc0f0000, "r,R", 2 }, -{ "uei", 0x00070000, 0xffff0000, "", 2 }, -{ "wait", 0x00010000, 0xffff0000, "", 2 }, -{ "wcwcs", 0xfc5f0000, 0xfc7f8000, "", 4 }, -{ "wwcs", 0x000c0000, 0xfc0f0000, "r,R", 2 }, -{ "xcbr", 0x28020000, 0xfc0f0000, "b,B", 2 }, -{ "xcr", 0x2c050000, 0xfc0f0000, "r,R", 2 }, -{ "xcrm", 0x2c0d0000, 0xfc0f0000, "r,R", 2 }, -{ "zbm", 0x9c080000, 0xfc080000, "f,xOA,X", 4 }, -{ "zbr", 0x18040000, 0xfc0c0000, "r,f", 2 }, -{ "zmb", 0xf8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "zmd", 0xf8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "zmh", 0xf8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "zmw", 0xf8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "zr", 0x0c000000, 0xfc0f0000, "r", 2 }, -}; - -int numopcodes = sizeof(gld_opcodes) / sizeof(gld_opcodes[0]); - -struct gld_opcode *endop = gld_opcodes + sizeof(gld_opcodes) / - sizeof(gld_opcodes[0]); diff --git a/gnu/usr.bin/gdb/config/pyr-dep.c b/gnu/usr.bin/gdb/config/pyr-dep.c deleted file mode 100644 index a0d849a7567e..000000000000 --- a/gnu/usr.bin/gdb/config/pyr-dep.c +++ /dev/null @@ -1,823 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: pyr-dep.c,v 1.2 1993/08/02 17:40:18 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#include -#include -#include -#include -/* #include Can we live without this? */ - -#include -#ifndef N_SET_MAGIC -#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val)) -#endif - -#include /* After a.out.h */ -#include -#include - -extern int errno; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -void -fetch_inferior_registers () -{ - register int regno, datum; - register unsigned int regaddr; - int reg_buf[NUM_REGS+1]; - struct user u; - register int skipped_frames = 0; - - if (remote_debugging) - remote_fetch_registers (); - else - { - for (regno = 0; regno < 64; regno++) { - reg_buf[regno] = ptrace (3, inferior_pid, regno, 0); - -#if defined(PYRAMID_CONTROL_FRAME_DEBUGGING) - printf ("Fetching %s from inferior, got %0x\n", - reg_names[regno], - reg_buf[regno]); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - - if (reg_buf[regno] == -1 && errno == EIO) { - printf("fetch_interior_registers: fetching %s from inferior\n", - reg_names[regno]); - errno = 0; - } - supply_register (regno, reg_buf+regno); - } - /* that leaves regs 64, 65, and 66 */ - datum = ptrace (3, inferior_pid, - ((char *)&u.u_pcb.pcb_csp) - - ((char *)&u), 0); - - - - /* FIXME: Find the Current Frame Pointer (CFP). CFP is a global - register (ie, NOT windowed), that gets saved in a frame iff - the code for that frame has a prologue (ie, "adsf N"). If - there is a prologue, the adsf insn saves the old cfp in - pr13, cfp is set to sp, and N bytes of locals are allocated - (sp is decremented by n). - This makes finding CFP hard. I guess the right way to do it - is: - - If this is the innermost frame, believe ptrace() or - the core area. - - Otherwise: - Find the first insn of the current frame. - - find the saved pc; - - find the call insn that saved it; - - figure out where the call is to; - - if the first insn is an adsf, we got a frame - pointer. */ - - - /* Normal processors have separate stack pointers for user and - kernel mode. Getting the last user mode frame on such - machines is easy: the kernel context of the ptrace()'d - process is on the kernel stack, and the USP points to what - we want. But Pyramids only have a single cfp for both user and - kernel mode. And processes being ptrace()'d have some - kernel-context control frames on their stack. - To avoid tracing back into the kernel context of an inferior, - we skip 0 or more contiguous control frames where the pc is - in the kernel. */ - - while (1) { - register int inferior_saved_pc; - inferior_saved_pc = ptrace (1, inferior_pid, datum+((32+15)*4), 0); - if (inferior_saved_pc > 0) break; -#if defined(PYRAMID_CONTROL_FRAME_DEBUGGING) - printf("skipping kernel frame %08x, pc=%08x\n", datum, - inferior_saved_pc); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - skipped_frames++; - datum -= CONTROL_STACK_FRAME_SIZE; - } - - reg_buf[CSP_REGNUM] = datum; - supply_register(CSP_REGNUM, reg_buf+CSP_REGNUM); -#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING - if (skipped_frames) { - fprintf (stderr, - "skipped %d frames from %x to %x; cfp was %x, now %x\n", - skipped_frames, reg_buf[CSP_REGNUM]); - } -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - if (regno >= 0) - { - if ((0 <= regno) && (regno < 64)) { - /*regaddr = register_addr (regno, offset);*/ - regaddr = regno; - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - } - else for (regno = 0; regno < NUM_REGS; regno++) - { - /*regaddr = register_addr (regno, offset);*/ - regaddr = regno; - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing all regs, number %d", regno); - perror_with_name (buf); - } - } -} - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; -#if 0 -/*This is now done by read_memory, because when this function did it, - reading a byte or short int hardware port read whole longs, causing - serious side effects - such as bus errors and unexpected hardware operation. This would - also be a problem with ptrace if the inferior process could read - or write hardware registers, but that's not usually the case. */ - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else -#endif - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - buffer[0] = remote_fetch_word (addr); - else - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - if (remote_debugging) - buffer[count - 1] - = remote_fetch_word (addr + (count - 1) * sizeof (int)); - else - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - remote_store_word (addr, buffer[i]); - else - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -/*** Extensions to core and dump files, for GDB. */ - -extern unsigned int last_frame_offset; - -#ifdef PYRAMID_CORE - -/* Can't make definitions here static, since core.c needs them - to do bounds checking on the core-file areas. O well. */ - -/* have two stacks: one for data, one for register windows. */ -extern CORE_ADDR reg_stack_start; -extern CORE_ADDR reg_stack_end; - -/* need this so we can find the global registers: they never get saved. */ -static CORE_ADDR global_reg_offset; -static CORE_ADDR last_frame_address; -static CORE_ADDR last_frame_offset; - - -/* Address in core file of start of register window stack area. - Don't know if is this any of meaningful, useful or necessary. */ -static CORE_ADDR reg_stack_offset; - -#endif /* PYRAMID_CORE */ - - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -#ifdef PYRAMID_CORE -/* Well, "two areas of memory" on most machines; but pyramids have a - third area, for the register-window stack, and we need its - base and bound too. */ - -extern CORE_ADDR reg_stack_start; -extern CORE_ADDR reg_stack_start; -#endif /* PYRAMID_CORE */ - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - -#ifdef PYRAMID_CORE - reg_stack_start = CONTROL_STACK_ADDR; - reg_stack_end = CONTROL_STACK_ADDR; /* this isn't strictly true...*/ -#endif /* PYRAMID_CORE */ - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - - unsigned int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name ("Not a core file: reading upage"); - if (val != sizeof u) - error ("Not a core file: could only read %d bytes", val); - data_start = exec_data_start; - - data_end = data_start + NBPG * u.u_dsize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - - /* find registers in core file */ -#ifdef PYRAMID_PTRACE - stack_start = stack_end - NBPG * u.u_ussize; - reg_stack_offset = stack_offset + (NBPG *u.u_ussize); - reg_stack_end = reg_stack_start + NBPG * u.u_cssize; - - last_frame_address = ((int) u.u_pcb.pcb_csp); - last_frame_offset = reg_stack_offset + last_frame_address - - CONTROL_STACK_ADDR ; - global_reg_offset = (char *)&u - (char *)&u.u_pcb.pcb_gr0 ; - - /* skip any control-stack frames that were executed in the - kernel. */ - - while (1) { - char buf[4]; - val = lseek (corechan, last_frame_offset+(47*4), 0); - if (val < 0) - perror_with_name (filename); - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - - if (*(int *)buf >= 0) - break; - printf ("skipping frame %0x\n", last_frame_address); - last_frame_offset -= CONTROL_STACK_FRAME_SIZE; - last_frame_address -= CONTROL_STACK_FRAME_SIZE; - } - reg_offset = last_frame_offset; - -#if 1 || defined(PYRAMID_CONTROL_FRAME_DEBUGGING) - printf ("Control stack pointer = 0x%08x\n", - u.u_pcb.pcb_csp); - printf ("offset to control stack %d outermost frame %d (%0x)\n", - reg_stack_offset, reg_offset, last_frame_address); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - -#else /* not PYRAMID_CORE */ - stack_start = stack_end - NBPG * u.u_ssize; - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; -#endif /* not PYRAMID_CORE */ - -#ifdef __not_on_pyr_yet - /* Some machines put an absolute address in here and some put - the offset in the upage of the regs. */ - reg_offset = (int) u.u_ar0; - if (reg_offset > NBPG * UPAGES) - reg_offset -= KERNEL_U_ADDR; -#endif - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - N_SET_MAGIC (core_aouthdr, 0); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < 64; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0 - || (val = myread (corechan, buf, sizeof buf)) < 0) - { - char * buffer = (char *) alloca (strlen (reg_names[regno]) - + 30); - strcpy (buffer, "Reading register "); - strcat (buffer, reg_names[regno]); - - perror_with_name (buffer); - } - - if (val < 0) - perror_with_name (filename); -#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING - printf ("[reg %s(%d), offset in file %s=0x%0x, addr =0x%0x, =%0x]\n", - reg_names[regno], regno, filename, - register_addr(regno, reg_offset), - regno * 4 + last_frame_address, - *((int *)buf)); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - -#if 1 || defined(PYRAMID_CONTROL_FRAME_DEBUGGING) - printf ("Providing CSP (%0x) as nominal address of current frame.\n", - last_frame_address); -#endif PYRAMID_CONTROL_FRAME_DEBUGGING - /* FIXME: Which of the following is correct? */ -#if 0 - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); -#else - set_current_frame ( create_new_frame (last_frame_address, - read_pc ())); -#endif - - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - -#ifdef gould -#endif /* gould */ - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_TXTADDR (exec_aouthdr); - exec_data_start = N_DATADDR (exec_aouthdr); -#ifdef gould -#else - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; -#endif - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -/*** Prettier register printing. ***/ - -/* Print registers in the same format as pyramid's dbx, adb, sdb. */ -pyr_print_registers(reg_buf, regnum) - long *reg_buf[]; -{ - register int regno; - int usp, ksp; - struct user u; - - for (regno = 0; regno < 16; regno++) { - printf/*_filtered*/ ("%6.6s: %8x %6.6s: %8x %6s: %8x %6s: %8x\n", - reg_names[regno], reg_buf[regno], - reg_names[regno+16], reg_buf[regno+16], - reg_names[regno+32], reg_buf[regno+32], - reg_names[regno+48], reg_buf[regno+48]); - } - usp = ptrace (3, inferior_pid, - ((char *)&u.u_pcb.pcb_usp) - - ((char *)&u), 0); - ksp = ptrace (3, inferior_pid, - ((char *)&u.u_pcb.pcb_ksp) - - ((char *)&u), 0); - printf/*_filtered*/ ("\n%6.6s: %8x %6.6s: %8x (%08x) %6.6s %8x\n", - reg_names[CSP_REGNUM],reg_buf[CSP_REGNUM], - reg_names[KSP_REGNUM], reg_buf[KSP_REGNUM], ksp, - "usp", usp); -} - -/* Print the register regnum, or all registers if regnum is -1. */ - -pyr_do_registers_info (regnum) - int regnum; -{ - /* On a pyr, we know a virtual register can always fit in an long. - Here (and elsewhere) we take advantage of that. Yuk. */ - long raw_regs[MAX_REGISTER_RAW_SIZE*NUM_REGS]; - register int i; - - for (i = 0 ; i < 64 ; i++) { - read_relative_register_raw_bytes(i, raw_regs+i); - } - if (regnum == -1) - pyr_print_registers (raw_regs, regnum); - else - for (i = 0; i < NUM_REGS; i++) - if (i == regnum) { - long val = raw_regs[i]; - - fputs_filtered (reg_names[i], stdout); - printf_filtered(":"); - print_spaces_filtered (6 - strlen (reg_names[i]), stdout); - if (val == 0) - printf_filtered ("0"); - else - printf_filtered ("0x%08x %d", val, val); - printf_filtered("\n"); - } -} - -/*** Debugging editions of various macros from m-pyr.h ****/ - -CORE_ADDR frame_locals_address (frame) - FRAME frame; -{ - register int addr = find_saved_register (frame,CFP_REGNUM); - register int result = read_memory_integer (addr, 4); -#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING - fprintf (stderr, - "\t[[..frame_locals:%8x, %s= %x @%x fcfp= %x foo= %x\n\t gr13=%x pr13=%x tr13=%x @%x]]\n", - frame->frame, - reg_names[CFP_REGNUM], - result, addr, - frame->frame_cfp, (CFP_REGNUM), - - - read_register(13), read_register(29), read_register(61), - find_saved_register(frame, 61)); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - - /* FIXME: I thought read_register (CFP_REGNUM) should be the right answer; - or at least CFP_REGNUM relative to FRAME (ie, result). - There seems to be a bug in the way the innermost frame is set up. */ - - return ((frame->next) ? result: frame->frame_cfp); -} - -CORE_ADDR frame_args_addr (frame) - FRAME frame; -{ - register int addr = find_saved_register (frame,CFP_REGNUM); - register int result = read_memory_integer (addr, 4); - -#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING - fprintf (stderr, - "\t[[..frame_args:%8x, %s= %x @%x fcfp= %x r_r= %x\n\t gr13=%x pr13=%x tr13=%x @%x]]\n", - frame->frame, - reg_names[CFP_REGNUM], - result, addr, - frame->frame_cfp, read_register(CFP_REGNUM), - - read_register(13), read_register(29), read_register(61), - find_saved_register(frame, 61)); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - - /* FIXME: I thought read_register (CFP_REGNUM) should be the right answer; - or at least CFP_REGNUM relative to FRAME (ie, result). - There seems to be a bug in the way the innermost frame is set up. */ - return ((frame->next) ? result: frame->frame_cfp); -} diff --git a/gnu/usr.bin/gdb/config/pyr-opcode.h b/gnu/usr.bin/gdb/config/pyr-opcode.h deleted file mode 100644 index 2e844c9e1c0d..000000000000 --- a/gnu/usr.bin/gdb/config/pyr-opcode.h +++ /dev/null @@ -1,290 +0,0 @@ -/* pyramid.opcode.h -- gdb initial attempt. - - $Id: pyr-opcode.h,v 1.2 1993/08/02 17:40:19 mycroft Exp $ -*/ - -/* pyramid opcode table: wot to do with this - particular opcode */ - -struct pyr_datum -{ - char nargs; - char * args; /* how to compile said opcode */ - unsigned long mask; /* Bit vector: which operand modes are valid - for this opcode */ - unsigned char code; /* op-code (always 6(?) bits */ -}; - -typedef struct pyr_insn_format { - unsigned int mode :4; - unsigned int operator :8; - unsigned int index_scale :2; - unsigned int index_reg :6; - unsigned int operand_1 :6; - unsigned int operand_2:6; -} pyr_insn_format; - - -/* We store four bytes of opcode for all opcodes. - Pyramid is sufficiently RISCy that: - - insns are always an integral number of words; - - the length of any insn can be told from the first word of - the insn. (ie, if there are zero, one, or two words of - immediate operand/offset). - - - The args component is a string containing two characters for each - operand of the instruction. The first specifies the kind of operand; - the second, the place it is stored. */ - -/* Kinds of operands: - mask assembler syntax description - 0x0001: movw Rn,Rn register to register - 0x0002: movw K,Rn quick immediate to register - 0x0004: movw I,Rn long immediate to register - 0x0008: movw (Rn),Rn register indirect to register - movw (Rn)[x],Rn register indirect to register - 0x0010: movw I(Rn),Rn offset register indirect to register - movw I(Rn)[x],Rn offset register indirect, indexed, to register - - 0x0020: movw Rn,(Rn) register to register indirect - 0x0040: movw K,(Rn) quick immediate to register indirect - 0x0080: movw I,(Rn) long immediate to register indirect - 0x0100: movw (Rn),(Rn) register indirect to-register indirect - 0x0100: movw (Rn),(Rn) register indirect to-register indirect - 0x0200: movw I(Rn),(Rn) register indirect+offset to register indirect - 0x0200: movw I(Rn),(Rn) register indirect+offset to register indirect - - 0x0400: movw Rn,I(Rn) register to register indirect+offset - 0x0800: movw K,I(Rn) quick immediate to register indirect+offset - 0x1000: movw I,I(Rn) long immediate to register indirect+offset - 0x1000: movw (Rn),I(Rn) register indirect to-register indirect+offset - 0x1000: movw I(Rn),I(Rn) register indirect+offset to register indirect - +offset - 0x0000: (irregular) ??? - - - Each insn has a four-bit field encoding the type(s) of its operands. -*/ - -/* Some common combinations - */ - -/* the first 5,(0x1|0x2|0x4|0x8|0x10) ie (1|2|4|8|16), ie ( 32 -1)*/ -#define GEN_TO_REG (31) - -#define UNKNOWN ((unsigned long)-1) -#define ANY (GEN_TO_REG | (GEN_TO_REG << 5) | (GEN_TO_REG << 15)) - -#define CONVERT (1|8|0x10|0x20|0x200) - -#define K_TO_REG (2) -#define I_TO_REG (4) -#define NOTK_TO_REG (GEN_TO_REG & ~K_TO_REG) -#define NOTI_TO_REG (GEN_TO_REG & ~I_TO_REG) - -/* The assembler requires that this array be sorted as follows: - all instances of the same mnemonic must be consecutive. - All instances of the same mnemonic with the same number of operands - must be consecutive. - */ - -struct pyr_opcode /* pyr opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct pyr_datum datum; /* rest of opcode table [datum] */ -}; - -#define pyr_how args -#define pyr_nargs nargs -#define pyr_mask mask -#define pyr_name name - -struct pyr_opcode pyr_opcodes[] = -{ - {"movb", { 2, "", UNKNOWN, 0x11}, }, - {"movh", { 2, "", UNKNOWN, 0x12} }, - {"movw", { 2, "", ANY, 0x10} }, - {"movl", { 2, "", ANY, 0x13} }, - {"mnegw", { 2, "", (0x1|0x8|0x10), 0x14} }, - {"mnegf", { 2, "", 0x1, 0x15} }, - {"mnegd", { 2, "", 0x1, 0x16} }, - {"mcomw", { 2, "", (0x1|0x8|0x10), 0x17} }, - {"mabsw", { 2, "", (0x1|0x8|0x10), 0x18} }, - {"mabsf", { 2, "", 0x1, 0x19} }, - {"mabsd", { 2, "", 0x1, 0x1a} }, - {"mtstw", { 2, "", (0x1|0x8|0x10), 0x1c} }, - {"mtstf", { 2, "", 0x1, 0x1d} }, - {"mtstd", { 2, "", 0x1, 0x1e} }, - {"mova", { 2, "", 0x8|0x10, 0x1f} }, - {"movzbw", { 2, "", (0x1|0x8|0x10), 0x20} }, - {"movzhw", { 2, "", (0x1|0x8|0x10), 0x21} }, - /* 2 insns out of order here */ - {"movbl", { 2, "", 1, 0x4f} }, - {"filbl", { 2, "", 1, 0x4e} }, - - {"cvtbw", { 2, "", CONVERT, 0x22} }, - {"cvthw", { 2, "", CONVERT, 0x23} }, - {"cvtwb", { 2, "", CONVERT, 0x24} }, - {"cvtwh", { 2, "", CONVERT, 0x25} }, - {"cvtwf", { 2, "", CONVERT, 0x26} }, - {"cvtwd", { 2, "", CONVERT, 0x27} }, - {"cvtfw", { 2, "", CONVERT, 0x28} }, - {"cvtfd", { 2, "", CONVERT, 0x29} }, - {"cvtdw", { 2, "", CONVERT, 0x2a} }, - {"cvtdf", { 2, "", CONVERT, 0x2b} }, - - {"addw", { 2, "", GEN_TO_REG, 0x40} }, - {"addwc", { 2, "", GEN_TO_REG, 0x41} }, - {"subw", { 2, "", GEN_TO_REG, 0x42} }, - {"subwb", { 2, "", GEN_TO_REG, 0x43} }, - {"rsubw", { 2, "", GEN_TO_REG, 0x44} }, - {"mulw", { 2, "", GEN_TO_REG, 0x45} }, - {"emul", { 2, "", GEN_TO_REG, 0x47} }, - {"umulw", { 2, "", GEN_TO_REG, 0x46} }, - {"divw", { 2, "", GEN_TO_REG, 0x48} }, - {"ediv", { 2, "", GEN_TO_REG, 0x4a} }, - {"rdivw", { 2, "", GEN_TO_REG, 0x4b} }, - {"udivw", { 2, "", GEN_TO_REG, 0x49} }, - {"modw", { 2, "", GEN_TO_REG, 0x4c} }, - {"umodw", { 2, "", GEN_TO_REG, 0x4d} }, - - - {"addf", { 2, "", 1, 0x50} }, - {"addd", { 2, "", 1, 0x51} }, - {"subf", { 2, "", 1, 0x52} }, - {"subd", { 2, "", 1, 0x53} }, - {"mulf", { 2, "", 1, 0x56} }, - {"muld", { 2, "", 1, 0x57} }, - {"divf", { 2, "", 1, 0x58} }, - {"divd", { 2, "", 1, 0x59} }, - - - {"cmpb", { 2, "", UNKNOWN, 0x61} }, - {"cmph", { 2, "", UNKNOWN, 0x62} }, - {"cmpw", { 2, "", UNKNOWN, 0x60} }, - {"ucmpb", { 2, "", UNKNOWN, 0x66} }, - /* WHY no "ucmph"??? */ - {"ucmpw", { 2, "", UNKNOWN, 0x65} }, - {"xchw", { 2, "", UNKNOWN, 0x0f} }, - - - {"andw", { 2, "", GEN_TO_REG, 0x30} }, - {"orw", { 2, "", GEN_TO_REG, 0x31} }, - {"xorw", { 2, "", GEN_TO_REG, 0x32} }, - {"bicw", { 2, "", GEN_TO_REG, 0x33} }, - {"lshlw", { 2, "", GEN_TO_REG, 0x38} }, - {"ashlw", { 2, "", GEN_TO_REG, 0x3a} }, - {"ashll", { 2, "", GEN_TO_REG, 0x3c} }, - {"ashrw", { 2, "", GEN_TO_REG, 0x3b} }, - {"ashrl", { 2, "", GEN_TO_REG, 0x3d} }, - {"rotlw", { 2, "", GEN_TO_REG, 0x3e} }, - {"rotrw", { 2, "", GEN_TO_REG, 0x3f} }, - - /* push and pop insns are "going away next release". */ - {"pushw", { 2, "", GEN_TO_REG, 0x0c} }, - {"popw", { 2, "", (0x1|0x8|0x10), 0x0d} }, - {"pusha", { 2, "", (0x8|0x10), 0x0e} }, - - {"bitsw", { 2, "", UNKNOWN, 0x35} }, - {"bitcw", { 2, "", UNKNOWN, 0x36} }, - /* some kind of ibra/dbra insns??*/ - {"icmpw", { 2, "", UNKNOWN, 0x67} }, - {"dcmpw", { 2, "", (1|4|0x20|0x80|0x400|0x1000), 0x69} },/*FIXME*/ - {"acmpw", { 2, "", 1, 0x6b} }, - - /* Call is written as a 1-op insn, but is always (dis)assembled as a 2-op - insn with a 2nd op of tr14. The assembler will have to grok this. */ - {"call", { 2, "", GEN_TO_REG, 0x04} }, - {"call", { 1, "", GEN_TO_REG, 0x04} }, - - {"callk", { 1, "", UNKNOWN, 0x06} },/* system call?*/ - /* Ret is usually written as a 0-op insn, but gets disassembled as a - 1-op insn. The operand is always tr15. */ - {"ret", { 0, "", UNKNOWN, 0x09} }, - {"ret", { 1, "", UNKNOWN, 0x09} }, - {"adsf", { 2, "", (1|2|4), 0x08} }, - {"retd", { 2, "", UNKNOWN, 0x0a} }, - {"btc", { 2, "", UNKNOWN, 0x01} }, - {"bfc", { 2, "", UNKNOWN, 0x02} }, - /* Careful: halt is 0x00000000. Jump must have some other (mode?)bit set?? */ - {"jump", { 1, "", UNKNOWN, 0x00} }, - {"btp", { 2, "", UNKNOWN, 0xf00} }, - /* read control-stack pointer is another 1-or-2 operand insn. */ - {"rcsp", { 2, "", UNKNOWN, 0x01f} }, - {"rcsp", { 1, "", UNKNOWN, 0x01f} } -}; - -/* end: pyramid.opcode.h */ -/* One day I will have to take the time to find out what operands - are valid for these insns, and guess at what they mean. - - I can't imagine what the "I???" insns (iglob, etc) do. - - the arithmetic-sounding insns ending in "p" sound awfully like BCD - arithmetic insns: - dshlp -> Decimal SHift Left Packed - dshrp -> Decimal SHift Right Packed - and cvtlp would be convert long to packed. - I have no idea how the operands are interpreted; but having them be - a long register with (address, length) of an in-memory packed BCD operand - would not be surprising. - They are unlikely to be a packed bcd string: 64 bits of long give - is only 15 digits+sign, which isn't enough for COBOL. - */ -#if 0 - {"wcsp", { 2, "", UNKNOWN, 0x00} }, /*write csp?*/ - /* The OSx Operating System Porting Guide claims SSL does things - with tr12 (a register reserved to it) to do with static block-structure - references. SSL=Set Static Link? It's "Going away next release". */ - {"ssl", { 2, "", UNKNOWN, 0x00} }, - {"ccmps", { 2, "", UNKNOWN, 0x00} }, - {"lcd", { 2, "", UNKNOWN, 0x00} }, - {"uemul", { 2, "", UNKNOWN, 0x00} }, /*unsigned emul*/ - {"srf", { 2, "", UNKNOWN, 0x00} }, /*Gidget time???*/ - {"mnegp", { 2, "", UNKNOWN, 0x00} }, /move-neg phys?*/ - {"ldp", { 2, "", UNKNOWN, 0x00} }, /*load phys?*/ - {"ldti", { 2, "", UNKNOWN, 0x00} }, - {"ldb", { 2, "", UNKNOWN, 0x00} }, - {"stp", { 2, "", UNKNOWN, 0x00} }, - {"stti", { 2, "", UNKNOWN, 0x00} }, - {"stb", { 2, "", UNKNOWN, 0x00} }, - {"stu", { 2, "", UNKNOWN, 0x00} }, - {"addp", { 2, "", UNKNOWN, 0x00} }, - {"subp", { 2, "", UNKNOWN, 0x00} }, - {"mulp", { 2, "", UNKNOWN, 0x00} }, - {"divp", { 2, "", UNKNOWN, 0x00} }, - {"dshlp", { 2, "", UNKNOWN, 0x00} }, /* dec shl packed? */ - {"dshrp", { 2, "", UNKNOWN, 0x00} }, /* dec shr packed? */ - {"movs", { 2, "", UNKNOWN, 0x00} }, /*move (string?)?*/ - {"cmpp", { 2, "", UNKNOWN, 0x00} }, /* cmp phys?*/ - {"cmps", { 2, "", UNKNOWN, 0x00} }, /* cmp (string?)?*/ - {"cvtlp", { 2, "", UNKNOWN, 0x00} }, /* cvt long to p??*/ - {"cvtpl", { 2, "", UNKNOWN, 0x00} }, /* cvt p to l??*/ - {"dintr", { 2, "", UNKNOWN, 0x00} }, /* ?? intr ?*/ - {"rphysw", { 2, "", UNKNOWN, 0x00} }, /* read phys word?*/ - {"wphysw", { 2, "", UNKNOWN, 0x00} }, /* write phys word?*/ - {"cmovs", { 2, "", UNKNOWN, 0x00} }, - {"rsubw", { 2, "", UNKNOWN, 0x00} }, - {"bicpsw", { 2, "", UNKNOWN, 0x00} }, /* clr bit in psw? */ - {"bispsw", { 2, "", UNKNOWN, 0x00} }, /* set bit in psw? */ - {"eio", { 2, "", UNKNOWN, 0x00} }, /* ?? ?io ? */ - {"callp", { 2, "", UNKNOWN, 0x00} }, /* call phys?*/ - {"callr", { 2, "", UNKNOWN, 0x00} }, - {"lpcxt", { 2, "", UNKNOWN, 0x00} }, /*load proc context*/ - {"rei", { 2, "", UNKNOWN, 0x00} }, /*ret from intrpt*/ - {"rport", { 2, "", UNKNOWN, 0x00} }, /*read-port?*/ - {"rtod", { 2, "", UNKNOWN, 0x00} }, /*read-time-of-day?*/ - {"ssi", { 2, "", UNKNOWN, 0x00} }, - {"vtpa", { 2, "", UNKNOWN, 0x00} }, /*virt-to-phys-addr?*/ - {"wicl", { 2, "", UNKNOWN, 0x00} }, /* write icl ? */ - {"wport", { 2, "", UNKNOWN, 0x00} }, /*write-port?*/ - {"wtod", { 2, "", UNKNOWN, 0x00} }, /*write-time-of-day?*/ - {"flic", { 2, "", UNKNOWN, 0x00} }, - {"iglob", { 2, "", UNKNOWN, 0x00} }, /* I global? */ - {"iphys", { 2, "", UNKNOWN, 0x00} }, /* I physical? */ - {"ipid", { 2, "", UNKNOWN, 0x00} }, /* I pid? */ - {"ivect", { 2, "", UNKNOWN, 0x00} }, /* I vector? */ - {"lamst", { 2, "", UNKNOWN, 0x00} }, - {"tio", { 2, "", UNKNOWN, 0x00} }, -#endif diff --git a/gnu/usr.bin/gdb/config/pyr-pinsn.c b/gnu/usr.bin/gdb/config/pyr-pinsn.c deleted file mode 100644 index 8c0124866722..000000000000 --- a/gnu/usr.bin/gdb/config/pyr-pinsn.c +++ /dev/null @@ -1,350 +0,0 @@ -/* Disassembler for the Pyramid Technology 90x - Copyright (C) 1988,1989 Free Software Foundation, Inc. - -This file is part of GDB, the GNU disassembler. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: pyr-pinsn.c,v 1.2 1993/08/02 17:40:20 mycroft Exp $"; -#endif /* not lint */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "opcode.h" - - -/* A couple of functions used for debugging frame-handling on - Pyramids. (The Pyramid-dependent handling of register values for - windowed registers is known to be buggy.) - - When debugging, these functions supplant the normal definitions of some - of the macros in m-pyramid.h The quantity of information produced - when these functions are used makes the gdb unusable as a - debugger for user programs. */ - -extern unsigned pyr_saved_pc(), pyr_frame_chain(); - -CORE_ADDR pyr_frame_chain(frame) - CORE_ADDR frame; -{ - int foo=frame - CONTROL_STACK_FRAME_SIZE; - /* printf ("...following chain from %x: got %x\n", frame, foo);*/ - return foo; -} - -CORE_ADDR pyr_saved_pc(frame) - CORE_ADDR frame; -{ - int foo=0; - foo = read_memory_integer (((CORE_ADDR)(frame))+60, 4); - printf ("..reading pc from frame 0x%0x+%d regs: got %0x\n", - frame, 60/4, foo); - return foo; -} - - -/* Pyramid instructions are never longer than this many bytes. */ -#define MAXLEN 24 - -/* Number of elements in the opcode table. */ -/*const*/ static int nopcodes = (sizeof (pyr_opcodes) / sizeof( pyr_opcodes[0])); -#define NOPCODES (nopcodes) - -extern char *reg_names[]; - -/* Let's be byte-independent so we can use this as a cross-assembler. - (will this ever be useful? - */ - -#define NEXTLONG(p) \ - (p += 4, (((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]) - - -/* Print one instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i, nargs, insn_size =4; - register unsigned char *p; - register char *d; - register int insn_opcode, operand_mode; - register int index_multiplier, index_reg_regno, op_1_regno, op_2_regno ; - long insn; /* first word of the insn, not broken down. */ - pyr_insn_format insn_decode; /* the same, broken out into op{code,erands} */ - long extra_1, extra_2; - - read_memory (memaddr, buffer, MAXLEN); - insn_decode = *((pyr_insn_format *) buffer); - insn = * ((int *) buffer); - insn_opcode = insn_decode.operator; - operand_mode = insn_decode.mode; - index_multiplier = insn_decode.index_scale; - index_reg_regno = insn_decode.index_reg; - op_1_regno = insn_decode.operand_1; - op_2_regno = insn_decode.operand_2; - - - if (*((int *)buffer) == 0x0) { - /* "halt" looks just like an invalid "jump" to the insn decoder, - so is dealt with as a special case */ - fprintf (stream, "halt"); - return (4); - } - - for (i = 0; i < NOPCODES; i++) - if (pyr_opcodes[i].datum.code == insn_opcode) - break; - - if (i == NOPCODES) - /* FIXME: Handle unrecognised instructions better. */ - fprintf (stream, "???\t#%08x\t(op=%x mode =%x)", - insn, insn_decode.operator, insn_decode.mode); - else - { - /* Print the mnemonic for the instruction. Pyramid insn operands - are so regular that we can deal with almost all of them - separately. - Unconditional branches are an exception: they are encoded as - conditional branches (branch if false condition, I think) - with no condition specified. The average user will not be - aware of this. To maintain their illusion that an - unconditional branch insn exists, we will have to FIXME to - treat the insn mnemnonic of all branch instructions here as a - special case: check the operands of branch insn and print an - appropriate mnemonic. */ - - fprintf (stream, "%s\t", pyr_opcodes[i].name); - - /* Print the operands of the insn (as specified in - insn.operand_mode). - Branch operands of branches are a special case: they are a word - offset, not a byte offset. */ - - if (insn_decode.operator == 0x01 || insn_decode.operator == 0x02) { - register int bit_codes=(insn >> 16)&0xf; - register int i; - register int displacement = (insn & 0x0000ffff) << 2; - - static char cc_bit_names[] = "cvzn"; /* z,n,c,v: strange order? */ - - /* Is bfc and no bits specified an unconditional branch?*/ - for (i=0;i<4;i++) { - if ((bit_codes) & 0x1) - fputc (cc_bit_names[i], stream); - bit_codes >>= 1; - } - - fprintf (stream, ",%0x", - displacement + memaddr); - return (insn_size); - } - - switch (operand_mode) { - case 0: - fprintf (stream, "%s,%s", - reg_names [op_1_regno], - reg_names [op_2_regno]); - break; - - case 1: - fprintf (stream, " 0x%0x,%s", - op_1_regno, - reg_names [op_2_regno]); - break; - - case 2: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, " $0x%0x,%s", - extra_1, - reg_names [op_2_regno]); - break; - case 3: - fprintf (stream, " (%s),%s", - reg_names [op_1_regno], - reg_names [op_2_regno]); - break; - - case 4: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, " 0x%0x(%s),%s", - extra_1, - reg_names [op_1_regno], - reg_names [op_2_regno]); - break; - - /* S1 destination mode */ - case 5: - fprintf (stream, - ((index_reg_regno) ? "%s,(%s)[%s*%1d]" : "%s,(%s)"), - reg_names [op_1_regno], - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - case 6: - fprintf (stream, - ((index_reg_regno) ? " $%#0x,(%s)[%s*%1d]" - : " $%#0x,(%s)"), - op_1_regno, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - case 7: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) ? " $%#0x,(%s)[%s*%1d]" - : " $%#0x,(%s)"), - extra_1, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - case 8: - fprintf (stream, - ((index_reg_regno) ? " (%s),(%s)[%s*%1d]" : " (%s),(%s)"), - reg_names [op_1_regno], - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - case 9: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) - ? "%#0x(%s),(%s)[%s*%1d]" - : "%#0x(%s),(%s)"), - extra_1, - reg_names [op_1_regno], - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - /* S2 destination mode */ - case 10: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) ? "%s,%#0x(%s)[%s*%1d]" : "%s,%#0x(%s)"), - reg_names [op_1_regno], - extra_1, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - case 11: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) ? - " $%#0x,%#0x(%s)[%s*%1d]" : " $%#0x,%#0x(%s)"), - op_1_regno, - extra_1, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - case 12: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - read_memory (memaddr+8, buffer, MAXLEN); - insn_size += 4; - extra_2 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) ? - " $%#0x,%#0x(%s)[%s*%1d]" : " $%#0x,%#0x(%s)"), - extra_1, - extra_2, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - case 13: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) - ? " (%s),%#0x(%s)[%s*%1d]" - : " (%s),%#0x(%s)"), - reg_names [op_1_regno], - extra_1, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - case 14: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - read_memory (memaddr+8, buffer, MAXLEN); - insn_size += 4; - extra_2 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) ? "%#0x(%s),%#0x(%s)[%s*%1d]" - : "%#0x(%s),%#0x(%s) "), - extra_1, - reg_names [op_1_regno], - extra_2, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - default: - fprintf (stream, - ((index_reg_regno) ? "%s,%s [%s*%1d]" : "%s,%s"), - reg_names [op_1_regno], - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - fprintf (stream, - "\t\t# unknown mode in %08x", - insn); - break; - } /* switch */ - } - - { - return insn_size; - } - abort (); -} diff --git a/gnu/usr.bin/gdb/config/sparc-dep.c b/gnu/usr.bin/gdb/config/sparc-dep.c deleted file mode 100644 index 414f6f650200..000000000000 --- a/gnu/usr.bin/gdb/config/sparc-dep.c +++ /dev/null @@ -1,1457 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)sparc-dep.c 6.4 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: sparc-dep.c,v 1.2 1993/08/01 18:48:21 mycroft Exp $"; -#endif /* not lint */ - -/* Machine-dependent code which would otherwise be in inflow.c and core.c, - for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - This code is for the sparc cpu. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "obstack.h" -#include "value.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#ifdef KERNELDEBUG -#include -#include - -extern int kernel_debugging; -kvm_t *kd; - -static struct proc *cur_proc; -CORE_ADDR intstack_top; -CORE_ADDR intstack_bottom; - -CORE_ADDR kernstack_top; -CORE_ADDR kernstack_bottom; - -#endif - -extern int errno; -extern int attach_flag; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -void -kill_inferior () -{ - if (remote_debugging) { -#ifdef KERNELDEBUG - if (kernel_debugging) { - /* - * It's a very, very bad idea to go away leaving - * breakpoints in a remote kernel or to leave it - * stopped at a breakpoint. - */ - clear_breakpoints(); - } -#endif - remote_close(0); - inferior_died(); - } else if (inferior_pid != 0) { - ptrace(8, inferior_pid, 0, 0); - wait(0); - inferior_died(); - } -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -void -kill_inferior_fast () -{ - if (remote_debugging) { -#ifdef KERNELDEBUG - if (kernel_debugging) - clear_breakpoints(); -#endif - remote_close(0); - } else if (inferior_pid != 0) { - ptrace(8, inferior_pid, 0, 0); - wait(0); - } -} - -/* - * Simulate single-step ptrace call for sun4. Code written by Gary - * Beihl (beihl@mcc.com); modified by Steven McCanne (mccanne@ee.lbl.gov). - */ - -union sparcinsn { - u_long code; - struct { - u_int op:2; - u_int a:1; - u_int cond:4; - u_int op2:3; - u_int disp22:22; - } b; -}; - -/* - * Return the address, other than npc, that could be executed next. - * If only the possibility is npc, return 0. - * (There is only one such "other" possible address.) - */ -CORE_ADDR -annulled_dest(insn, pc, npc) - union sparcinsn insn; - CORE_ADDR pc, npc; -{ - long int offset; - - if (insn.b.op == 0 && insn.b.a && - (insn.b.op2 == 2 || insn.b.op2 == 6 || insn.b.op2 == 7)) { - offset = 4 * ((int) (insn.b.disp22 << 10) >> 10); - if (insn.b.cond == 8) - return pc + offset; - else - return npc + 4; - } - return 0; -} - -/* - * Duplicated from breakpoint.c because (at least for now) this is a - * machine dependent routine. - */ -static char break_insn[] = BREAKPOINT; - -/* From infrun.c */ -extern int stop_after_trap, stop_after_attach; - -u_long target0_addr; -u_long target0_shadow; -u_long target1_addr; -u_long target1_shadow; - -/* - * Non-zero if we just simulated a single-step ptrace call. This is - * needed because we cannot remove the breakpoints in the inferior - * process until after the `wait' in `wait_for_inferior'. - * Used for sun4. - */ -int one_stepped; - -void -single_step(signal) - int signal; -{ - CORE_ADDR pc, target0, target1; - union sparcinsn insn; - - pc = read_register(PC_REGNUM); - (void)read_memory(pc, &insn.code, 4); - - if (!one_stepped) { - /* - * This is a hack to special case call instructions. - * If we are stepping over subroutines, find each call - * and trap on return, rather than single step until - * wait_for_inferior() discovers that we hit a new routine. - * The reason is that stepping over functions in a remote - * kernel can have bad results when the function being - * stepped over is used by the kernel in between traps. - * (i.e., a trap instruction gets poked into the function - * being stepped over). - */ - if (step_over_calls > 0 && - ((insn.code & 0xc0000000) == 0x40000000 || - (insn.code & 0xfff80000) == 0x9fc00000)) { - target0 = PC_ADJUST(pc); - target1 = 0; - } else { - target0 = read_register(NPC_REGNUM); - target1 = annulled_dest(insn, pc, target0); - } - target0_addr = target0; - read_memory(target0, &target0_shadow, 4); - write_memory(target0, break_insn, 4); - - target1_addr = target1; - if (target1) { - read_memory(target1, &target1_shadow, 4); - write_memory(target1, break_insn, 4); - } - /* - * Resume the inferior. - */ - if (remote_debugging) - remote_resume(0, 0); - else - ptrace(7, inferior_pid, 1, signal); - one_stepped = 1; - } else { - /* Remove breakpoints */ - write_memory(target0_addr, &target0_shadow, 4); - if (target1_addr) - write_memory(target1_addr, &target1_shadow, 4); - one_stepped = 0; - } -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) { - /* invalidate the kernel stack limits */ - cur_proc = 0; - remote_resume(step, signal); - } else { - /* Sparc doesn't have single step on ptrace */ - if (step) - single_step(signal); - else - ptrace(7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -#ifdef ATTACH_DETACH - -/* Start debugging the process whose number is PID. */ - -int -attach (pid) - int pid; -{ - errno = 0; - ptrace (PTRACE_ATTACH, pid, 0, 0); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 1; - return pid; -} - -/* Stop debugging the process whose number is PID - and continue it with signal number SIGNAL. - SIGNAL = 0 means just continue it. */ - -void -detach (signal) - int signal; -{ - errno = 0; - ptrace (PTRACE_DETACH, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 0; -} -#endif /* ATTACH_DETACH */ - -void -fetch_inferior_registers () -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - int cwp; - struct rwindow local_and_ins; - - if (remote_debugging) { - remote_fetch_registers(registers); - return; - } - ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers); - ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers); - - registers[REGISTER_BYTE (0)] = 0; - bcopy (&inferior_registers.r_g1, ®isters[REGISTER_BYTE (1)], 15 * 4); - bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fpu_fr); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; - *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = inferior_registers.r_npc; - *(int *)®isters[REGISTER_BYTE (Y_REGNUM)] = inferior_registers.r_y; - /* *(int *)®isters[REGISTER_BYTE (RP_REGNUM)] = - inferior_registers.r_o7 + 8; - bcopy (&inferior_fp_registers.Fpu_fsr, - ®isters[REGISTER_BYTE (FPS_REGNUM)], - sizeof (FPU_FSR_TYPE)); */ - - read_inferior_memory (inferior_registers.r_sp, - ®isters[REGISTER_BYTE (16)], - 16*4); -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -void -store_inferior_registers (regno) - int regno; -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - - if (remote_debugging) - remote_store_registers (registers); - else - { - int in_regs = 1, in_fpregs = 1, in_fparegs, in_cpregs = 1; - - if (regno >= 0) - if (FP0_REGNUM <= regno && regno <= FP0_REGNUM + 32) - in_regs = 0; - else - in_fpregs = 0; - - if (in_regs) - { - bcopy (®isters[REGISTER_BYTE (1)], - &inferior_registers.r_g1, 15 * 4); - - inferior_registers.r_ps = - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_registers.r_pc = - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; - inferior_registers.r_npc = - *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)]; - inferior_registers.r_y = - *(int *)®isters[REGISTER_BYTE (Y_REGNUM)]; - - write_inferior_memory (*(int *)®isters[REGISTER_BYTE (SP_REGNUM)], - ®isters[REGISTER_BYTE (16)], - 16*4); - } - if (in_fpregs) - { - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], - &inferior_fp_registers, - sizeof inferior_fp_registers.fpu_fr); - - /* bcopy (®isters[REGISTER_BYTE (FPS_REGNUM)], - &inferior_fp_registers.Fpu_fsr, - sizeof (FPU_FSR_TYPE)); - ****/ - } - - if (in_regs) - ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); - if (in_fpregs) - ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers); - } -} - -/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory - in the NEW_SUN_PTRACE case. - It ought to be straightforward. But it appears that writing did - not write the data that I specified. I cannot understand where - it got the data that it actually did write. */ - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - if (remote_debugging) - return (remote_read_inferior_memory(memaddr, myaddr, len)); - /* Read all the longwords */ - errno = 0; - for (i = 0; i < count && errno == 0; i++, addr += sizeof (int)) - buffer[i] = ptrace (1, inferior_pid, addr, 0); - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return errno; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - return (remote_write_inferior_memory(memaddr, myaddr, len)); - - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - errno = 0; - for (i = 0; i < count && errno == 0; i++, addr += sizeof (int)) - ptrace (4, inferior_pid, addr, buffer[i]); - - return errno; -} - - -/* Machine-dependent code which would otherwise be in core.c */ -/* Work with core dump and executable files, for GDB. */ - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Non-zero if this is an object (.o) file, rather than an executable. - Distinguishing between the two is rarely necessary (and seems like - a hack, but there is no other way to get the text and data - addresses--N_TXTADDR should probably take care of - this, but it doesn't). */ -/* This definition will not work - if someone decides to make ld preserve relocation info. */ -#define IS_OBJECT_FILE(hdr) (hdr.a_trsize != 0) - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern char *sys_siglist[]; - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -extern int (*core_file_hook)(); - -#ifdef KERNELDEBUG - -/* - * Process control block. - */ -static struct pcb pcb; -/* - * Floating point unit. - */ -static struct fpu fpu; - -/* XXX For misc_function_vector. */ -#include "symtab.h" - -/* - * Read the "thing" at kernel address 'addr' into the space pointed to - * by point. The length of the "thing" is determined by the type of p. - * Result is non-zero if transfer fails. - */ -#define kvread(addr, p) \ - (read_memory((CORE_ADDR)(addr), (char *)(p), sizeof(*(p)))) - -static CORE_ADDR -ksym_lookup(name) - char *name; -{ - struct symbol *sym; - int i; - - if ((i = lookup_misc_func(name)) < 0) - error("Kernel symbol `%s' not found.", name); - - return (misc_function_vector[i].address); -} - -/* - * Return the current proc. masterprocp points to - * current proc which points to current u area. - */ -struct proc * -curProc() -{ - struct proc *p; - CORE_ADDR addr = ksym_lookup("masterprocp"); - - if (kvread(addr, &p)) - error("cannot read proc pointer at %x\n", addr); - return p; -} - -/* - * (re-)set the variables that make inside_kernstack() work. - */ -set_kernel_boundaries(p) - struct proc *p; -{ - CORE_ADDR kstack; - - if (intstack_top == 0) { - intstack_top = ksym_lookup("eintstack"); - intstack_bottom = ksym_lookup("intstack"); - } - if (kvread(&p->p_segu, &kstack)) - error("cannot read kernel stack pointer at %x\n", &p->p_segu); - kernstack_bottom = kstack; - kernstack_top = kstack + KERNSTACK; -} - -inside_kernstack(addr) - CORE_ADDR addr; -{ - if (cur_proc == 0) { - cur_proc = curProc(); - set_kernel_boundaries(cur_proc); - } - return (addr > intstack_bottom && addr < intstack_top) || - (addr > kernstack_bottom && addr < kernstack_top); -} - -clear_regs() -{ - u_long reg = 0; - float freg = 0.0; - int i; - - for (i = 0; i < FP0_REGNUM; ++i) - supply_register(i, ®); - for (; i < FP0_REGNUM + 32; ++i) /* XXX */ - supply_register(i, &freg); - for (; i < NUM_REGS; ++i) - supply_register(i, ®); -} - -static void -read_pcb() -{ - struct user *uaddr; - int i; - u_long cps, reg, sp; - float freg; - struct rwindow win; - - /* find the pcb for the current process */ - if (kvread(&cur_proc->p_uarea, &uaddr)) - error("cannot u area ptr for proc at 0x%x", cur_proc); - if (kvread(&uaddr->u_pcb, &pcb)) - error("cannot read pcb at 0x%x", &uaddr->u_pcb); - /* - * Zero out register set then fill in the ones we know about. - */ - clear_regs(); - sp = pcb.pcb_sp; - printf("sp=%x pc=%x sr=%x\n", sp, pcb.pcb_pc, pcb.pcb_psr); - supply_register(SP_REGNUM, (char *)&pcb.pcb_sp); - supply_register(PC_REGNUM, (char *)&pcb.pcb_pc); - /* PC came from o7. */ - supply_register(15, (char *)&pcb.pcb_pc); - supply_register(PS_REGNUM, (char *)&pcb.pcb_psr); - /* XXX There should be a WIM_REGNUM. */ - supply_register(66, (char *)&pcb.pcb_uwm); - /* - * Read last register window saved on stack. - */ - if (kvread(sp, &win)) { - printf("cannot read register window at sp=%x\n", pcb.pcb_sp); - bzero((char *)&win, sizeof win); - } - for (i = 0; i < sizeof(win.rw_local); ++i) - supply_register(i + 16, &win.rw_local[i]); - for (i = 0; i < sizeof(win.rw_in); ++i) - supply_register(i + 24, &win.rw_in[i]); - /* - * read the globals & outs saved on the stack (for a trap frame). - */ - sp += 92 + 12; /* XXX - MINFRAME + R_Y */ - for (i = 1; i < 14; ++i) { - u_long val; - - if (kvread(sp + i*4, &val) == 0) - supply_register(i, (char *)&val); - } - if (kvread(pcb.pcb_cpctxp, &cps) == 0) - supply_register(CPS_REGNUM, (char *)&cps); -} - -/* - * Set the process context to that of the proc structure at - * system address paddr. - * - * This is REALLY STUPID. The only way to tell libkvm that we want to - * change user address maps is with kvm_getu. - */ -set_procaddr(paddr) - CORE_ADDR paddr; -{ - struct proc p; - struct user *uaddr; - - if (paddr < KERNELBASE) - return (1); - - if (cur_proc == NULL) - if (kvread(ksym_lookup("proc"), &cur_proc)) - error("cannot find proc table"); - if (kvread(paddr, &p)) - error("cannot read proc struct at 0x%x", paddr); - if (kd) - if (kvm_getu(kd, (u_long *)&p) == 0) { - (void)kvread(cur_proc, &p); - (void)kvm_getu(kd, (u_long *)&p); - error("cannot read uarea for proc at 0x%x", paddr); - return (1); - } - cur_proc = (struct proc *)paddr; - read_pcb(); - set_kernel_boundaries(cur_proc); - return (0); -} - -static void -setup_kernel_corefile(namefile, corefile) - char *namefile, *corefile; -{ - struct stat stb; - int kmem = 0; - CORE_ADDR addr, paddr; - char buf[256], *cp; - - if (strcmp(corefile, "/dev/mem") == 0) - /* XXX - Sun libkvm botch: this is only way to get - * correct mappings for swap set up. */ - kd = kvm_open(namefile, (char *)0, (char *)0, O_RDONLY, - (char *)0); - else - kd = kvm_open(namefile, corefile, (char *)0, O_RDONLY, - (char *)0); - if (kd == 0) { - printf("Cannot open '%s' as core file of '%s'\n", - corefile, namefile); - return; - } - /* - * Need to find current u area to get kernel stack and pcb - * where "panic" saved registers. - * (libkvm also needs to know current u area to get user - * address space mapping). - */ - (void)set_procaddr(curProc()); - - /* print out the panic string if there is one */ - if (kvread(ksym_lookup("panicstr"), &addr) || addr == 0 || - read_memory(addr, buf, sizeof(buf))) - return; - - for (cp = buf; cp < &buf[sizeof(buf)] && *cp; cp++) - if (!isascii(*cp) || (!isprint(*cp) && !isspace(*cp))) - *cp = '?'; - *cp = '\0'; - if (buf[0] != '\0') - printf("panic: %s\n", buf); -} - -set_paddr_command(arg) - char *arg; -{ - u_int paddr, uaddr; - - if (!arg) - error_no_arg("proc address for new current process"); - if (!kernel_debugging) - error("not debugging kernel"); - - paddr = (u_int)parse_and_eval_address(arg); - if (set_procaddr(paddr)) - error("invalid proc address"); - - flush_cached_frames(); - set_current_frame(create_new_frame(read_register(FP_REGNUM), - read_pc())); - select_frame(get_current_frame(), 0); -} - -/* - * read len bytes from kernel virtual address 'addr' into local - * buffer 'buf'. Return 0 if read ok, 1 otherwise. On read - * errors, portion of buffer not read is zeroed. - */ -kernel_core_file_hook(addr, buf, len) - CORE_ADDR addr; - char *buf; - int len; -{ - int i, cc; - - if (kd == 0) - error("no kernel core file"); - - cc = kvm_read(kd, (u_long)addr, buf, len); - if (cc == len) - return (0); - if (cc < 0) - cc = 0; - bzero(buf, len - cc); - return (1); -} - -static int -is_a_vmunix(name) - char *name; -{ - register char *cp; - - if (name && (cp = strstr(name, "vmunix")) && - (cp == name || cp[-1] == '/')) - return (1); - return (0); -} -#endif - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val, sp; - extern char registers[]; -#ifdef KERNELDEBUG - struct stat stb; - - if (kd != 0) { - kvm_close(kd); - kd = 0; - } -#endif - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - if (filename == 0) { - if (from_tty) - printf("No core file now.\n"); - return; - } - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); -#ifdef KERNELDEBUG - if (!kernel_debugging && is_a_vmunix(execfile)) { - kernel_debugging = 1; - set_prompt_command("(kgdb)"); - } - if (kernel_debugging) { - core_file_hook = kernel_core_file_hook; - setup_kernel_corefile(execfile, filename); - goto finish; - } -#endif - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); -#ifdef KERNELDEBUG - fstat(corechan, &stb); - if ((stb.st_mode & S_IFMT) == S_IFCHR && - stb.st_rdev == makedev(3, 1)) { - /* looking at /dev/kmem */ - data_offset = data_start = KERNELBASE; - data_end = ~0; /* XXX */ - stack_end = stack_start = data_end; - set_kernel_boundaries(curProc()); - goto finish; - } -#endif - { - struct core corestr; - - val = myread (corechan, &corestr, sizeof corestr); - if (val < 0) - perror_with_name (filename); - if (corestr.c_magic != CORE_MAGIC) - error ("\"%s\" does not appear to be a core dump file (magic 0x%x, expected 0x%x)", - filename, corestr.c_magic, (int) CORE_MAGIC); - else if (sizeof (struct core) != corestr.c_len) - error ("\"%s\" has an invalid struct core length (%d, expected %d)", - filename, corestr.c_len, (int) sizeof (struct core)); - - data_start = exec_data_start; - data_end = data_start + corestr.c_dsize; - stack_start = stack_end - corestr.c_ssize; - data_offset = sizeof corestr; - stack_offset = sizeof corestr + corestr.c_dsize; - - /* G0 *always* holds 0. */ - *(int *)®isters[REGISTER_BYTE (0)] = 0; - /* The globals and output registers. */ - - bcopy (&corestr.c_regs.r_g1, ((int *) registers) + 1, 15 * 4); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = corestr.c_regs.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = corestr.c_regs.r_pc; - *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = corestr.c_regs.r_npc; - *(int *)®isters[REGISTER_BYTE (Y_REGNUM)] = corestr.c_regs.r_y; - - /* My best guess at where to get the locals and input - registers is exactly where they usually are, right above - the stack pointer. If the core dump was caused by a bus - writing off the stack pointer (as is possible) then this - won't work, but it's worth the try. */ - - sp = *(int *)®isters[REGISTER_BYTE (SP_REGNUM)]; - lseek (corechan, sp - stack_start + stack_offset, L_SET); - if (16 * 4 != myread (corechan, - ®isters[REGISTER_BYTE (16)], - 16 * 4)) - /* fprintf so user can still use gdb */ - fprintf (stderr, "Couldn't read input and local registers from core file\n"); - - bcopy (corestr.c_fpu.fpu_regs, - ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof corestr.c_fpu.fpu_regs); -#ifdef FPU - bcopy (&corestr.c_fpu.fpu_fsr, - ®isters[REGISTER_BYTE (FPS_REGNUM)], - sizeof (FPU_FSR_TYPE)); -#endif - - bcopy (&corestr.c_aouthdr, &core_aouthdr, sizeof (struct exec)); - - printf ("Core file is from \"%s\".\n", corestr.c_cmdname); - if (corestr.c_signo > 0) - printf ("Program terminated with signal %d, %s.\n", - corestr.c_signo, - corestr.c_signo < NSIG - ? sys_siglist[corestr.c_signo] - : "(undocumented)"); - } - finish: - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - corefile = concat (current_directory, "/", filename); - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); -} - -void -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - if (kernel_debugging) - text_start = exec_aouthdr.a_entry; - else - text_start = IS_OBJECT_FILE (exec_aouthdr) ? - 0 : N_TXTADDR (exec_aouthdr); - - exec_data_start = IS_OBJECT_FILE (exec_aouthdr) - ? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr); - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_DATOFF (exec_aouthdr); - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -#ifndef offsetof -#define offsetof(t, f) ((int)(&((t *)0)->f)) -#endif - -/* - * Return the address of the saved pc in frame. - */ -CORE_ADDR -addr_of_pc(frame) - struct frame_info *frame; -{ - CORE_ADDR addr; - -#ifdef KERNELDEBUG - /* - * If we are kernel debugging, we must special case trap frames. - * We can tell if we are a trap frame by looking at the return - * address of the frame below us. If it is in locore, then - * we are such a frame and we can find our saved pc in %l1. - */ - if (kernel_debugging && frame->next) { - static CORE_ADDR locore_h, locore_t; - - if (locore_h == 0) { - locore_h = ksym_lookup("sys_trap"); - locore_t = ksym_lookup("kadb_tcode"); - } - addr = GET_RWINDOW_REG(frame->next->bottom, rw_in[7]); - if (addr > locore_h && addr < locore_t) - return frame->bottom + - offsetof(struct rwindow, rw_local[1]); - } -#endif - return (CORE_ADDR)&((struct rwindow *)frame->bottom)->rw_in[7]; -} - -/* - * Find the pc saved in frame FRAME. - */ -CORE_ADDR -frame_saved_pc(frame) - FRAME frame; -{ - return PC_ADJUST(read_memory_integer(addr_of_pc(frame), 4)); -} - -/* - * Since an individual frame in the frame cache is defined by two - * arguments (a frame pointer and a stack pointer), we need two - * arguments to get info for an arbitrary stack frame. This routine - * takes two arguments and makes the cached frames look as if these - * two arguments defined a frame on the cache. This allows the rest - * of info frame to extract the important arguments without - * difficulty. - */ -FRAME -setup_arbitrary_frame (frame, stack) - FRAME_ADDR frame, stack; -{ - struct frame_info *fci; - FRAME fid = create_new_frame (frame, 0); - - if (!fid) - fatal ("internal: create_new_frame returned invalid frame id"); - - fid->bottom = stack; - - return fid; -} - -/* This code was written by Gary Beihl (beihl@mcc.com). - It was modified by Michael Tiemann (tiemann@corto.inria.fr). */ - -struct command_line *get_breakpoint_commands (); - -/* - * This routine takes a program counter value. It restores the - * register window system to the frame above the current one, and sets - * the pc and npc to the correct values. - */ - -/* The following insns translate to: - - restore - t g0,0x1,o0 - sethi %hi(0x0), g0 */ - -static int restore_insn_opcodes[] = { 0x81e80000, 0x91d02001, 0x01000000 }; - -void -do_restore_insn (pc) - CORE_ADDR pc; -{ - CORE_ADDR sp = read_register (SP_REGNUM); - CORE_ADDR npc = pc + 4; - CORE_ADDR fake_pc = sp - sizeof (restore_insn_opcodes); - struct inferior_status inf_status; - - save_inferior_status (&inf_status, 0); /* Don't restore stack info */ - - if (!pc) - abort(); - - write_memory (fake_pc, restore_insn_opcodes, sizeof (restore_insn_opcodes)); - - clear_proceed_status (); - stop_after_trap = 1; - proceed (fake_pc, 0, 0); - - write_register (PC_REGNUM, pc); - write_register (NPC_REGNUM, npc); - restore_inferior_status (&inf_status); -} - -/* - * This routine should be more specific in it's actions; making sure - * that it uses the same register in the initial prologue section. - */ -CORE_ADDR -skip_prologue (pc) - CORE_ADDR pc; -{ - union - { - unsigned long int code; - struct - { - unsigned int op:2; - unsigned int rd:5; - unsigned int op2:3; - unsigned int imm22:22; - } sethi; - struct - { - unsigned int op:2; - unsigned int rd:5; - unsigned int op3:6; - unsigned int rs1:5; - unsigned int i:1; - unsigned int simm13:13; - } add; - int i; - } x; - int dest = -1; - - x.i = read_memory_integer (pc, 4); - - /* Recognize the `sethi' insn and record its destination. */ - if (x.sethi.op == 0 && x.sethi.op2 == 4) - { - dest = x.sethi.rd; - pc += 4; - x.i = read_memory_integer (pc, 4); - } - - /* Recognize an add immediate value to register to either %g1 or - the destination register recorded above. Actually, this might - well recognize several different arithmetic operations. */ - if (x.add.op == 2 && x.add.i && (x.add.rd == 1 || x.add.rd == dest)) - { - pc += 4; - x.i = read_memory_integer (pc, 4); - } - - /* This recognizes any SAVE insn. But why do the XOR and then - the compare? That's identical to comparing against 60 (as long - as there isn't any sign extension). */ - if (x.add.op == 2 && (x.add.op3 ^ 32) == 28) - { - pc += 4; - x.i = read_memory_integer (pc, 4); - } - - /* Now we need to recognize stores into the frame from the input - registers. This recognizes all non alternate stores of input - register, into a location offset from the frame pointer. */ - while (x.add.op == 3 - && (x.add.op3 & 0x3c) == 4 /* Store, non-alternate. */ - && (x.add.rd & 0x18) == 0x18 /* Input register. */ - && x.add.i /* Immediate mode. */ - && x.add.rs1 == 30 /* Off of frame pointer. */ - /* Into reserved stack space. */ - && x.add.simm13 >= 0x44 - && x.add.simm13 < 0x5b) - { - pc += 4; - x.i = read_memory_integer (pc, 4); - } - return pc; -} - -int dummy_code[] = { - 0xd003a044, /* ld [%sp + 68], %o0 */ - 0xd203a048, /* ld [%sp + 72], %o1 */ - 0xd403a04c, /* ld [%sp + 76], %o2 */ - 0xd603a050, /* ld [%sp + 80], %o3 */ - 0xd803a054, /* ld [%sp + 84], %o4 */ -#define DUMMY_CALL_INDEX 5 - 0x40000000, /* call . */ - 0xda03a058, /* ld [%sp + 88], %o5 */ - 0x01000000, /* nop - extra insn for Sun cc */ - 0x91d02001, /* ta 1 */ -}; - -/* - * Leave room on the stack for the kernel save area and the pointer - * for structure return values. - */ -#define KSA_AND_STRUCT_ADJUST 68 - -/* - * Build `dummy' call instructions on inferior's stack to cause - * it to call a subroutine. - * - * N.B. - code in wait_for_inferior requires that sp < pc < fp when - * we take the trap 2 above so it will recognize that we stopped - * at a `dummy' call. So, after the call sp is *not* decremented - * to clean the arguments, code & other stuff we lay on the stack. - * Since the regs are restored to saved values at the breakpoint, - * sp will get reset correctly. Also, this restore means we don't - * have to construct frame linkage info to save pc & fp. The lack - * of frame linkage means we can't do a backtrace, etc., if the - * called function gets a fault or hits a breakpoint but code in - * run_stack_dummy makes this impossible anyway. - */ -CORE_ADDR -setup_dummy(sp, funaddr, nargs, args, struct_return_bytes, pushfn) - CORE_ADDR sp; - CORE_ADDR funaddr; - int nargs; - value *args; - int struct_return_bytes; - CORE_ADDR (*pushfn)(); -{ - int len, padding, i; - CORE_ADDR top = sp, struct_addr, pc; - - pc = sp - sizeof(dummy_code); - len = arg_stacklen(nargs, args) + KSA_AND_STRUCT_ADJUST + - sizeof(dummy_code) + struct_return_bytes; - padding = STACK_ALIGN(len) - len; - sp = pc - padding - struct_return_bytes; - struct_addr = sp; - for (i = 0; i < nargs; ++i) { - /* pushfn doesn't actually change SP_REGNUM */ - sp = (*pushfn)(sp, args[i]); - } - sp -= KSA_AND_STRUCT_ADJUST; - if (struct_return_bytes) - write_memory(sp + KSA_AND_STRUCT_ADJUST - 4, - (char *)&struct_addr, 4); - - write_register(SP_REGNUM, sp); - dummy_code[DUMMY_CALL_INDEX] = 0x40000000 | - ((unsigned)(funaddr - (pc + 4 * DUMMY_CALL_INDEX)) >> 2); - - write_memory(pc, (char *)dummy_code, sizeof(dummy_code)); - - return pc; -} - -int default_function_nargs = 4; - -set_default_funargs_command(arg) - char *arg; -{ - if (arg == 0 || arg[0] == 0) - printf("%d\n", default_function_nargs); - else - default_function_nargs = atoi(arg); -} - -frame_find_saved_regs(fi, srp) - struct frame_info *fi; - struct frame_saved_regs *srp; -{ - register int i; - register CORE_ADDR pc; - - FRAME_ADDR frame = read_register (FP_REGNUM); - FRAME fid = FRAME_INFO_ID (fi); - if (!fid) fatal ("Bad frame info struct in FRAME_FIND_SAVED_REGS"); - bzero ((char *)srp, sizeof *srp); - if (fi->pc >= (fi->bottom ? fi->bottom : - read_register (SP_REGNUM)) && - fi->pc <= FRAME_FP(fi)) { - - for (i = 1; i < 8; i++) - srp->regs[i] = frame + i * 4 - 0xa0; - for (i = 24; i < 32; i++) - srp->regs[i] = frame + (i - 24) * 4 - 0xc0; - for (i = FP0_REGNUM; i < FP0_REGNUM + 32; i++) - srp->regs[i] = frame + (i - FP0_REGNUM) * 4 - 0x80; - for (i = 64; i < NUM_REGS; i++) - srp->regs[i] = frame + (i - 64) * 4 - 0xe0; - frame = fi->bottom ? fi->bottom : read_register (SP_REGNUM); - } else { - frame = fi->bottom ? fi->bottom : read_register (SP_REGNUM); - for (i = 16; i < 32; i++) - srp->regs[i] = frame + (i-16) * 4; - } - if (fi->next) { - /* Pull off either the next frame pointer or - the stack pointer */ - FRAME_ADDR next_next_frame =(fi->next->bottom ? - fi->next->bottom : - read_register (SP_REGNUM)); - for (i = 8; i < 16; i++) - srp->regs[i] = next_next_frame + i * 4; - } - /* Otherwise, whatever we would get from ptrace(GETREGS) */ - /* is accurate */ - for (i = 30; i < 32; i++) - srp->regs[i] = frame + (i-16) * 4; - srp->regs[SP_REGNUM] = FRAME_FP (fi); - srp->regs[PC_REGNUM] = -#ifdef KERNELDEBUG - kernel_debugging ? addr_of_pc(fi) : -#endif - frame + 15*4; -} - -extern struct cmd_list_element *setlist; - -#ifdef KERNELDEBUG -void - _initialize_sparc_dep() -{ - add_com ("process-address", class_obscure, set_paddr_command, -"The process with proc structure at ADDR becomes the\n\ -\"current\" process context for kernel debugging."); - add_com_alias ("paddr", "process-address", class_obscure, 0); - add_cmd("default-funargs", class_support, - set_default_funargs_command, -"Set the number of arguments to be printed for functions with\n\ -no debugging info.\n", - &setlist); -} -#endif diff --git a/gnu/usr.bin/gdb/config/sparc-opcode.h b/gnu/usr.bin/gdb/config/sparc-opcode.h deleted file mode 100644 index 3a6b536416c5..000000000000 --- a/gnu/usr.bin/gdb/config/sparc-opcode.h +++ /dev/null @@ -1,635 +0,0 @@ -/* Table of opcodes for the sparc. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler, and GDB, the GNU disassembler. - -GAS/GDB 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. - -GAS/GDB 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 GAS or GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: sparc-opcode.h,v 1.2 1993/08/02 17:40:21 mycroft Exp $ -*/ - -#if !defined(__STDC__) && !defined(const) -#define const -#endif - -/* - * Structure of an opcode table entry. - */ -struct sparc_opcode -{ - const char *name; - unsigned long int match; /* Bits that must be set. */ - unsigned long int lose; /* Bits that must not be set. */ - const char *args; - /* Nonzero if this is a delayed branch instruction. */ - char delayed; -}; - -/* - All sparc opcodes are 32 bits, except for the `set' instruction (really - a macro), which is 64 bits. It is handled as a special case. - - The match component is a mask saying which bits must match a - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing one character - for each operand of the instruction. - -Kinds of operands: - # Number used by optimizer. It is ignored. - 1 rs1 register. - 2 rs2 register. - d rd register. - e frs1 floating point register. - f frs2 floating point register. - g frsd floating point register. - b crs1 coprocessor register - c crs2 coprocessor register - D crsd coprocessor register - h 22 high bits. - i 13 bit Immediate. - l 22 bit PC relative immediate. - L 30 bit PC relative immediate. - a Annul. The annul bit is set. - A Alternate address space. Stored as 8 bits. - C Coprocessor state register. - F floating point state register. - p Processor state register. - q Floating point queue. - r Single register that is both rs1 and rsd. - Q Coprocessor queue. - S Special case. - t Trap base register. - w Window invalid mask register. - y Y register. - -*/ - -/* The order of the opcodes in this table is significant: - - * The assembler requires that all instances of the same mnemonic must be - consecutive. If they aren't, the assembler will bomb at runtime. - - * The disassembler should not care about the order of the opcodes. */ - -static struct sparc_opcode sparc_opcodes[] = -{ - -{ "ldd", 0xc1980000, 0x0060201f, "[1],D", 0 }, /* ldd [rs1+%g0],d */ -{ "ldd", 0xc1982000, 0x00601fff, "[1],D", 0 }, /* ldd [rs1+0],d */ -{ "ldd", 0xc1982000, 0x00600000, "[1+i],D", 0 }, -{ "ldd", 0xc1982000, 0x00600000, "[i+1],D", 0 }, -{ "ldd", 0xc1980000, 0x00602000, "[1+2],D", 0 }, -{ "ldd", 0xc1180000, 0x00e0201f, "[1],g", 0 }, /* ldd [rs1+%g0],d */ -{ "ldd", 0xc1182000, 0x00e01fff, "[1],g", 0 }, /* ldd [rs1+0],d */ -{ "ldd", 0xc1182000, 0x00e00000, "[1+i],g", 0 }, -{ "ldd", 0xc1182000, 0x00e00000, "[i+1],g", 0 }, -{ "ldd", 0xc1180000, 0x00e02000, "[1+2],g", 0 }, -{ "ldd", 0xc0180000, 0x01e0201f, "[1],d", 0 }, /* ldd [rs1+%g0],d */ -{ "ldd", 0xc0182000, 0x01e01fff, "[1],d", 0 }, /* ldd [rs1+0],d */ -{ "ldd", 0xc0182000, 0x01e00000, "[1+i],d", 0 }, -{ "ldd", 0xc0182000, 0x01e00000, "[i+1],d", 0 }, -{ "ldd", 0xc0180000, 0x01e02000, "[1+2],d", 0 }, -{ "ld", 0xc1880000, 0x0070201f, "[1],C", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1882000, 0x00701fff, "[1],C", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1882000, 0x00700000, "[1+i],C", 0 }, -{ "ld", 0xc1882000, 0x00700000, "[i+1],C", 0 }, -{ "ld", 0xc1880000, 0x00702000, "[1+2],C", 0 }, -{ "ld", 0xc1800000, 0x0078201f, "[1],D", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1802000, 0x00781fff, "[1],D", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1802000, 0x00780000, "[1+i],D", 0 }, -{ "ld", 0xc1802000, 0x00780000, "[i+1],D", 0 }, -{ "ld", 0xc1800000, 0x00782000, "[1+2],D", 0 }, -{ "ld", 0xc1080000, 0x00f0201f, "[1],F", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1082000, 0x00f01fff, "[1],F", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1082000, 0x00f00000, "[1+i],F", 0 }, -{ "ld", 0xc1082000, 0x00f00000, "[i+1],F", 0 }, -{ "ld", 0xc1080000, 0x00f02000, "[1+2],F", 0 }, -{ "ld", 0xc1000000, 0x00f8201f, "[1],g", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1002000, 0x00f81fff, "[1],g", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1002000, 0x00f80000, "[1+i],g", 0 }, -{ "ld", 0xc1002000, 0x00f80000, "[i+1],g", 0 }, -{ "ld", 0xc1000000, 0x00f82000, "[1+2],g", 0 }, -{ "ld", 0xc0000000, 0x01f8201f, "[1],d", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc0002000, 0x01f81fff, "[1],d", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc0002000, 0x01f80000, "[1+i],d", 0 }, -{ "ld", 0xc0002000, 0x01f80000, "[i+1],d", 0 }, -{ "ld", 0xc0000000, 0x01f82000, "[1+2],d", 0 }, -{ "ldstuba", 0xc0d80000, 0x0100201f, "[1]A,d", 0 }, /* ldstuba [rs1+%g0],d */ -{ "ldstuba", 0xc0d80000, 0x01002000, "[1+2]A,d", 0 }, -{ "ldsha", 0xc0d00000, 0x0128201f, "[1]A,d", 0 }, /* ldsha [rs1+%g0],d */ -{ "ldsha", 0xc0d00000, 0x01282000, "[1+2]A,d", 0 }, -{ "ldsba", 0xc0c80000, 0x0130201f, "[1]A,d", 0 }, /* ldsba [rs1+%g0],d */ -{ "ldsba", 0xc0c80000, 0x01302000, "[1+2]A,d", 0 }, -{ "ldda", 0xc0980000, 0x0160201f, "[1]A,d", 0 }, /* ldda [rs1+%g0],d */ -{ "ldda", 0xc0980000, 0x01602000, "[1+2]A,d", 0 }, -{ "lduha", 0xc0900000, 0x0168201f, "[1]A,d", 0 }, /* lduha [rs1+%g0],d */ -{ "lduha", 0xc0900000, 0x01682000, "[1+2]A,d", 0 }, -{ "ldstub", 0xc0680000, 0x0190201f, "[1],d", 0 }, /* ldstub [rs1+%g0],d */ -{ "ldstub", 0xc0682000, 0x01900000, "[1+i],d", 0 }, -{ "ldstub", 0xc0682000, 0x01900000, "[i+1],d", 0 }, -{ "ldstub", 0xc0680000, 0x01902000, "[1+2],d", 0 }, -{ "lda", 0xc0800000, 0x0178201f, "[1]A,d", 0 }, /* lda [rs1+%g0],d */ -{ "lda", 0xc0800000, 0x01782000, "[1+2]A,d", 0 }, -{ "ldsh", 0xc0500000, 0x0000000d, "[1],d", 0 }, /* ldsh [rs1+%g0],d */ -{ "ldsh", 0xc0502000, 0x01a81fff, "[1],d", 0 }, /* ldsh [rs1+0],d */ -{ "ldsh", 0xc0502000, 0x01a80000, "[1+i],d", 0 }, -{ "ldsh", 0xc0502000, 0x01a80000, "[i+1],d", 0 }, -{ "ldsh", 0xc0500000, 0x01a82000, "[1+2],d", 0 }, -{ "ldsb", 0xc0480000, 0x01b0201f, "[1],d", 0 }, /* ldsb [rs1+%g0],d */ -{ "ldsb", 0xc0482000, 0x01b01fff, "[1],d", 0 }, /* ldsb [rs1+0],d */ -{ "ldsb", 0xc0482000, 0x01b00000, "[1+i],d", 0 }, -{ "ldsb", 0xc0482000, 0x01b00000, "[i+1],d", 0 }, -{ "ldsb", 0xc0480000, 0x01b02000, "[1+2],d", 0 }, -{ "ldub", 0xc0080000, 0x01f0201f, "[1],d", 0 }, /* ldub [rs1+%g0],d */ -{ "ldub", 0xc0082000, 0x01f01fff, "[1],d", 0 }, /* ldub [rs1+0],d */ -{ "ldub", 0xc0082000, 0x01f00000, "[1+i],d", 0 }, -{ "ldub", 0xc0082000, 0x01f00000, "[i+1],d", 0 }, -{ "ldub", 0xc0080000, 0x01f02000, "[1+2],d", 0 }, -{ "lduba", 0xc0880000, 0x0170201f, "[1]A,d", 0 }, /* lduba [rs1+%g0],d */ -{ "lduba", 0xc0880000, 0x01702000, "[1+2]A,d", 0 }, -{ "lduh", 0xc0102000, 0x01e80000, "[1+i],d", 0 }, -{ "lduh", 0xc0102000, 0x01e80000, "[i+1],d", 0 }, -{ "lduh", 0xc0100000, 0x01e8201f, "[1],d", 0 }, /* lduh [rs1+%g0],d */ -{ "lduh", 0xc0102000, 0x01e81fff, "[1],d", 0 }, /* lduh [rs1+0],d */ -{ "lduh", 0xc0100000, 0x01e82000, "[1+2],d", 0 }, - -{ "st", 0xc0200000, 0x01d8201f, "d,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc0202000, 0x01d81fff, "d,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc0202000, 0x01d80000, "d,[1+i]", 0 }, -{ "st", 0xc0202000, 0x01d80000, "d,[i+1]", 0 }, -{ "st", 0xc0200000, 0x01d82000, "d,[1+2]", 0 }, -{ "st", 0xc1200000, 0x00d8201f, "g,[1]", 0 }, /* st d[rs1+%g0] */ -{ "st", 0xc1202000, 0x00d81fff, "g,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1202000, 0x00d80000, "g,[1+i]", 0 }, -{ "st", 0xc1202000, 0x00d80000, "g,[i+1]", 0 }, -{ "st", 0xc1200000, 0x00d82000, "g,[1+2]", 0 }, -{ "st", 0xc1100000, 0x00c0201f, "F,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc1102000, 0x00c01fff, "F,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1102000, 0x00c00000, "F,[1+i]", 0 }, -{ "st", 0xc1102000, 0x00c00000, "F,[i+1]", 0 }, -{ "st", 0xc1100000, 0x00c02000, "F,[1+2]", 0 }, -{ "st", 0xc1a00000, 0x0058201f, "D,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc1a02000, 0x00581fff, "D,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1a02000, 0x00580000, "D,[1+i]", 0 }, -{ "st", 0xc1a02000, 0x00580000, "D,[i+1]", 0 }, -{ "st", 0xc1a00000, 0x00582000, "D,[1+2]", 0 }, -{ "st", 0xc1a80000, 0x0050201f, "C,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc1a82000, 0x00501fff, "C,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1a82000, 0x00500000, "C,[1+i]", 0 }, -{ "st", 0xc1a82000, 0x00500000, "C,[i+1]", 0 }, -{ "st", 0xc1a80000, 0x00502000, "C,[1+2]", 0 }, -{ "sta", 0xc0a00000, 0x0108201f, "d,[1]A", 0 }, /* sta d,[rs1+%g0] */ -{ "sta", 0xc0a00000, 0x01082000, "d,[1+2]A", 0 }, - -{ "stb", 0xc0280000, 0x01d0201f, "d,[1]", 0 }, /* stb d,[rs1+%g0] */ -{ "stb", 0xc0282000, 0x01d01fff, "d,[1]", 0 }, /* stb d,[rs1+0] */ -{ "stb", 0xc0282000, 0x01d00000, "d,[1+i]", 0 }, -{ "stb", 0xc0282000, 0x01d00000, "d,[i+1]", 0 }, -{ "stb", 0xc0280000, 0x01d02000, "d,[1+2]", 0 }, -{ "stba", 0xc0a80000, 0x01002000, "d,[1+2]A", 0 }, -{ "stba", 0xc0a80000, 0x0100201f, "d,[1]A", 0 }, /* stba d,[rs1+%g0] */ - -{ "std", 0xc0380000, 0x01c0201f, "d,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc0382000, 0x01c01fff, "d,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc0382000, 0x01c00000, "d,[1+i]", 0 }, -{ "std", 0xc0382000, 0x01c00000, "d,[i+1]", 0 }, -{ "std", 0xc0380000, 0x01c02000, "d,[1+2]", 0 }, -{ "std", 0xc1380000, 0x00c0201f, "g,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1382000, 0x00c01fff, "g,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1382000, 0x00c00000, "g,[1+i]", 0 }, -{ "std", 0xc1382000, 0x00c00000, "g,[i+1]", 0 }, -{ "std", 0xc1380000, 0x00c02000, "g,[1+2]", 0 }, -{ "std", 0xc1300000, 0x00c8201f, "q,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1302000, 0x00c81fff, "q,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1302000, 0x00c80000, "q,[1+i]", 0 }, -{ "std", 0xc1302000, 0x00c80000, "q,[i+1]", 0 }, -{ "std", 0xc1300000, 0x00c82000, "q,[1+2]", 0 }, -{ "std", 0xc1b80000, 0x0040201f, "D,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1b82000, 0x00401fff, "D,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1b82000, 0x00400000, "D,[1+i]", 0 }, -{ "std", 0xc1b82000, 0x00400000, "D,[i+1]", 0 }, -{ "std", 0xc1b80000, 0x00402000, "D,[1+2]", 0 }, -{ "std", 0xc1b00000, 0x0048201f, "Q,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1b02000, 0x00481fff, "Q,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1b02000, 0x00480000, "Q,[1+i]", 0 }, -{ "std", 0xc1b02000, 0x00480000, "Q,[i+1]", 0 }, -{ "std", 0xc1b00000, 0x00482000, "Q,[1+2]", 0 }, -{ "stda", 0xc0b80000, 0x01402000, "d,[1+2]A", 0 }, -{ "stda", 0xc0b80000, 0x0140201f, "d,[1]A", 0 }, /* stda d,[rs1+%g0] */ - -{ "sth", 0xc0300000, 0x01c8201f, "d,[1]", 0 }, /* sth d,[rs1+%g0] */ -{ "sth", 0xc0302000, 0x01c81fff, "d,[1]", 0 }, /* sth d,[rs1+0] */ -{ "sth", 0xc0300000, 0x01c82000, "d,[1+2]", 0 }, -{ "sth", 0xc0302000, 0x01c80000, "d,[1+i]", 0 }, -{ "sth", 0xc0302000, 0x01c80000, "d,[i+1]", 0 }, -{ "stha", 0xc0b00000, 0x0148201f, "d,[1]A", 0 }, /* stha d,[rs1+%g0] */ -{ "stha", 0xc0b00000, 0x01482000, "d,[1+2]A", 0 }, - -{ "swap", 0xc0780000, 0x0180201f, "[1],d", 0 }, /* swap [rs1+%g0],d */ -{ "swap", 0xc0782000, 0x01801fff, "[1],d", 0 }, /* swap [rs1+0],d */ -{ "swap", 0xc0782000, 0x01800000, "[1+i],d", 0 }, -{ "swap", 0xc0782000, 0x01800000, "[i+1],d", 0 }, -{ "swap", 0xc0780000, 0x01802000, "[1+2],d", 0 }, -{ "swapa", 0xc0f80000, 0x01002000, "[1+2]A,d", 0 }, -{ "swapa", 0xc0f80000, 0x0100201f, "[1]A,d", 0 }, /* swapa [rs1+%g0],d */ - -{ "restore", 0x81e80000, 0x7e17e01f, "", 0 }, /* restore %g0,%g0,%g0 */ -{ "restore", 0x81e82000, 0x7e14dfff, "", 0 }, /* restore %g0,0,%g0 */ -{ "restore", 0x81e82000, 0x00000000, "1,i,d", 0 }, -{ "restore", 0x81e80000, 0x00000000, "1,2,d", 0 }, -{ "rett", 0x81c82000, 0x40300000, "1+i", 1 }, -{ "rett", 0x81c82000, 0x40300000, "i+1", 1 }, -{ "rett", 0x81c80000, 0x40302000, "1+2", 1 }, -{ "save", 0x81e02000, 0x40180000, "1,i,d", 0 }, -{ "save", 0x81e00000, 0x40180000, "1,2,d", 0 }, - -{ "ret", 0x81c7e008, 0x00001ff7, "", 1 }, /* jmpl %i7+8,%g0 */ -{ "retl", 0x81c3e008, 0x00001ff7, "", 1 }, /* jmpl %o7+8,%g0 */ - -{ "jmpl", 0x81c00000, 0x4038201f, "1,d", 1 }, /* jmpl rs1+%g0,d */ -{ "jmpl", 0x81c02000, 0x4037c000, "i,d", 1 }, /* jmpl %g0+i,d */ -{ "jmpl", 0x81c02000, 0x40380000, "1+i,d", 1 }, -{ "jmpl", 0x81c02000, 0x40380000, "i+1,d", 1 }, -{ "jmpl", 0x81c00000, 0x40382000, "1+2,d", 1 }, -{ "wr", 0x81982000, 0x40600000, "1,i,t", 0 }, -{ "wr", 0x81980000, 0x40600000, "1,2,t", 0 }, -{ "wr", 0x81902000, 0x40680000, "1,i,w", 0 }, -{ "wr", 0x81900000, 0x40680000, "1,2,w", 0 }, -{ "wr", 0x81882000, 0x40700000, "1,i,p", 0 }, -{ "wr", 0x81880000, 0x40700000, "1,2,p", 0 }, -{ "wr", 0x81802000, 0x40780000, "1,i,y", 0 }, -{ "wr", 0x81800000, 0x40780000, "1,2,y", 0 }, - -{ "rd", 0x81580000, 0x40a00000, "t,d", 0 }, -{ "rd", 0x81500000, 0x40a80000, "w,d", 0 }, -{ "rd", 0x81480000, 0x40b00000, "p,d", 0 }, -{ "rd", 0x81400000, 0x40b80000, "y,d", 0 }, - -{ "sra", 0x81382000, 0x00000000, "1,i,d", 0 }, -{ "sra", 0x81380000, 0x00000000, "1,2,d", 0 }, -{ "srl", 0x81302000, 0x40c80000, "1,i,d", 0 }, -{ "srl", 0x81300000, 0x40c80000, "1,2,d", 0 }, -{ "sll", 0x81282000, 0x40d00000, "1,i,d", 0 }, -{ "sll", 0x81280000, 0x40d00000, "1,2,d", 0 }, - -{ "mulscc", 0x81202000, 0x40d80000, "1,i,d", 0 }, -{ "mulscc", 0x81200000, 0x40d80000, "1,2,d", 0 }, - -{ "clr", 0x80100000, 0x4e87e01f, "d", 0 }, /* or %g0,%g0,d */ -{ "clr", 0x80102000, 0x41efdfff, "d", 0 }, /* or %g0,0,d */ - -{ "orncc", 0x80b02000, 0x04048000, "1,i,d", 0 }, -{ "orncc", 0x80b02000, 0x04048000, "i,1,d", 0 }, -{ "orncc", 0x80b00000, 0x04048000, "1,2,d", 0 }, - -{ "tst", 0x80900000, 0x7f6fe000, "2", 0 }, /* orcc %g0, rs2, %g0 */ -{ "tst", 0x80900000, 0x7f68201f, "1", 0 }, /* orcc rs1, %g0, %g0 */ -{ "tst", 0x80902000, 0x7f681fff, "1", 0 }, /* orcc rs1, 0, %g0 */ - -{ "orcc", 0x80902000, 0x41680000, "1,i,d", 0 }, -{ "orcc", 0x80902000, 0x41680000, "i,1,d", 0 }, -{ "orcc", 0x80900000, 0x41680000, "1,2,d", 0 }, -{ "orn", 0x80302000, 0x41c80000, "1,i,d", 0 }, -{ "orn", 0x80302000, 0x41c80000, "i,1,d", 0 }, -{ "orn", 0x80300000, 0x41c80000, "1,2,d", 0 }, - -{ "mov", 0x81800000, 0x4078201f, "1,y", 0 }, /* wr rs1,%g0,%y */ -{ "mov", 0x81802000, 0x40781fff, "1,y", 0 }, /* wr rs1,0,%y */ -{ "mov", 0x81400000, 0x40b80000, "y,d", 0 }, /* rd %y,d */ -{ "mov", 0x81980000, 0x4060201f, "1,t", 0 }, /* wr rs1,%g0,%tbr */ -{ "mov", 0x81982000, 0x40601fff, "1,t", 0 }, /* wr rs1,0,%tbr */ -{ "mov", 0x81580000, 0x40a00000, "t,d", 0 }, /* rd %tbr,d */ -{ "mov", 0x81900000, 0x4068201f, "1,w", 0 }, /* wr rs1,%g0,%wim */ -{ "mov", 0x81902000, 0x40681fff, "1,w", 0 }, /* wr rs1,0,%wim */ -{ "mov", 0x81500000, 0x40a80000, "w,d", 0 }, /* rd %wim,d */ -{ "mov", 0x81880000, 0x4070201f, "1,p", 0 }, /* wr rs1,%g0,%psr */ -{ "mov", 0x81882000, 0x40701fff, "1,p", 0 }, /* wr rs1,0,%psr */ -{ "mov", 0x81480000, 0x40b00000, "p,d", 0 }, /* rd %psr,d */ - -{ "mov", 0x80102000, 0x41efc000, "i,d", 0 }, /* or %g0,i,d */ -{ "mov", 0x80100000, 0x41efe000, "2,d", 0 }, /* or %g0,rs2,d */ - -{ "or", 0x80102000, 0x40800000, "1,i,d", 0 }, -{ "or", 0x80102000, 0x40800000, "i,1,d", 0 }, -{ "or", 0x80100000, 0x40800000, "1,2,d", 0 }, - -{ "andncc", 0x80a82000, 0x41500000, "1,i,d", 0 }, -{ "andncc", 0x80a82000, 0x41500000, "i,1,d", 0 }, -{ "andncc", 0x80a80000, 0x41500000, "1,2,d", 0 }, -{ "andn", 0x80282000, 0x41d00000, "1,i,d", 0 }, -{ "andn", 0x80282000, 0x41d00000, "i,1,d", 0 }, -{ "andn", 0x80280000, 0x41d00000, "1,2,d", 0 }, - -{ "cmp", 0x80a02000, 0x7d580000, "1,i", 0 }, /* subcc rs1,i,%g0 */ -{ "cmp", 0x80a00000, 0x7d580000, "1,2", 0 }, /* subcc rs1,rs2,%g0 */ - -{ "subcc", 0x80a02000, 0x41580000, "1,i,d", 0 }, -{ "subcc", 0x80a00000, 0x41580000, "1,2,d", 0 }, -{ "sub", 0x80202000, 0x41d80000, "1,i,d", 0 }, -{ "sub", 0x80200000, 0x41d80000, "1,2,d", 0 }, -{ "subx", 0x80602000, 0x41980000, "1,i,d", 0 }, -{ "subx", 0x80600000, 0x41980000, "1,2,d", 0 }, -{ "subxcc", 0x80e02000, 0x41180000, "1,i,d", 0 }, -{ "subxcc", 0x80e00000, 0x41180000, "1,2,d", 0 }, - -{ "andcc", 0x80882000, 0x41700000, "1,i,d", 0 }, -{ "andcc", 0x80882000, 0x41700000, "i,1,d", 0 }, -{ "andcc", 0x80880000, 0x41700000, "1,2,d", 0 }, -{ "and", 0x80082000, 0x41f00000, "1,i,d", 0 }, -{ "and", 0x80082000, 0x41f00000, "i,1,d", 0 }, -{ "and", 0x80080000, 0x41f00000, "1,2,d", 0 }, - -{ "inc", 0x80002001, 0x00001ffe, "r", 0 }, /* add rs1,1,rsd */ - -{ "addxcc", 0x80c02000, 0x41380000, "1,i,d", 0 }, -{ "addxcc", 0x80c02000, 0x41380000, "i,1,d", 0 }, -{ "addxcc", 0x80c00000, 0x41380000, "1,2,d", 0 }, -{ "addcc", 0x80802000, 0x41780000, "1,i,d", 0 }, -{ "addcc", 0x80802000, 0x41780000, "i,1,d", 0 }, -{ "addcc", 0x80800000, 0x41780000, "1,2,d", 0 }, -{ "addx", 0x80402000, 0x41b80000, "1,i,d", 0 }, -{ "addx", 0x80402000, 0x41b80000, "i,1,d", 0 }, -{ "addx", 0x80400000, 0x41b80000, "1,2,d", 0 }, -{ "add", 0x80002000, 0x41f80000, "1,i,d", 0 }, -{ "add", 0x80002000, 0x41f80000, "i,1,d", 0 }, -{ "add", 0x80000000, 0x41f80000, "1,2,d", 0 }, - -{ "call", 0x9fc00000, 0x4038201f, "1", 1 }, /* jmpl rs1+%g0, %o7 */ -{ "call", 0x9fc00000, 0x4038201f, "1,#", 1 }, -{ "call", 0x40000000, 0x80000000, "L", 1 }, -{ "call", 0x40000000, 0x80000000, "L,#", 1 }, - -{ "bvc", 0x3e800000, 0xc1400000, ",al", 1 }, -{ "bvc", 0x1e800000, 0xc1400000, "l", 1 }, -{ "bvs", 0x2e800000, 0xc1400000, ",al", 1 }, -{ "bvs", 0x0e800000, 0xc1400000, "l", 1 }, -{ "bpos", 0x3c800000, 0xc1400000, ",al", 1 }, -{ "bpos", 0x1c800000, 0xc1400000, "l", 1 }, -{ "bneg", 0x2c800000, 0xc1400000, ",al", 1 }, -{ "bneg", 0x0c800000, 0xc1400000, "l", 1 }, -{ "bcc", 0x3a800000, 0xc1400000, ",al", 1 }, -{ "bcc", 0x1a800000, 0xc1400000, "l", 1 }, -{ "bcs", 0x2a800000, 0xc1400000, ",al", 1 }, -{ "bcs", 0x0a800000, 0xc1400000, "l", 1 }, -{ "blu", 0x2a800000, 0xc1400000, ",al", 1 }, -{ "blu", 0x0a800000, 0xc1400000, "l", 1 }, /* same as bcs */ -{ "bgeu", 0x3a800000, 0xc1400000, ",al", 1 }, -{ "bgeu", 0x1a800000, 0xc1400000, "l", 1 }, /* same as bcc */ -{ "bgu", 0x38800000, 0xc1400000, ",al", 1 }, -{ "bgu", 0x18800000, 0xc1400000, "l", 1 }, -{ "bleu", 0x28800000, 0xc1400000, ",al", 1 }, -{ "bleu", 0x08800000, 0xc1400000, "l", 1 }, -{ "bge", 0x36800000, 0xc1400000, ",al", 1 }, -{ "bge", 0x16800000, 0xc1400000, "l", 1 }, -{ "bl", 0x26800000, 0xc1400000, ",al", 1 }, -{ "bl", 0x06800000, 0xc1400000, "l", 1 }, -{ "bg", 0x34800000, 0xc1400000, ",al", 1 }, -{ "bg", 0x14800000, 0xc1400000, "l", 1 }, -{ "ble", 0x24800000, 0xc1400000, ",al", 1 }, -{ "ble", 0x04800000, 0xc1400000, "l", 1 }, -{ "be", 0x22800000, 0xc1400000, ",al", 1 }, -{ "be", 0x02800000, 0xc1400000, "l", 1 }, -{ "bne", 0x32800000, 0xc1400000, ",al", 1 }, -{ "bne", 0x12800000, 0xc1400000, "l", 1 }, -{ "b", 0x30800000, 0xc1400000, ",al", 1 }, -{ "b", 0x10800000, 0xc1400000, "l", 1 }, -{ "ba", 0x30800000, 0xc1400000, ",al", 1 }, -{ "ba", 0x10800000, 0xc1400000, "l", 1 }, -{ "bn", 0x20800000, 0xc1400000, ",al", 1 }, -{ "bn", 0x00800000, 0xc1400000, "l", 1 }, - -{ "jmp", 0x81c00000, 0x7e38201f, "1", 1 }, /* jmpl rs1+%g0,%g0 */ -{ "jmp", 0x81c02000, 0x7e3fc000, "i", 1 }, /* jmpl %g0+i,%g0 */ - -{ "nop", 0x01000000, 0xfe3fffff, "", 0 }, /* sethi 0, %g0 */ - -{ "set", 0x01000000, 0xc0c00000, "Sh,d", 0 }, - -{ "sethi", 0x01000000, 0xc0c00000, "h,d", 0 }, - -{ "taddcctv", 0x81102000, 0x40e00000, "1,i,d", 0 }, -{ "taddcctv", 0x81100000, 0x40e00000, "1,2,d", 0 }, -{ "taddcc", 0x81002000, 0x40f80000, "1,i,d", 0 }, -{ "taddcc", 0x81000000, 0x40f80000, "1,2,d", 0 }, - -{ "tvc", 0x9fd02000, 0x402fc000, "i", 0 }, /* tvc %g0+i */ -{ "tvc", 0x9fd02000, 0x40280000, "1+i", 0 }, -{ "tvc", 0x9fd00000, 0x40282000, "1+2", 0 }, -{ "tvc", 0x9fd00000, 0x4028201f, "1", 0 }, /* tvc rs1+%g0 */ -{ "tpos", 0x9dd02000, 0x402fc000, "i", 0 }, /* tpos %g0+i */ -{ "tpos", 0x9dd02000, 0x40280000, "1+i", 0 }, -{ "tpos", 0x9dd00000, 0x40282000, "1+2", 0 }, -{ "tpos", 0x9dd00000, 0x4028201f, "1", 0 }, /* tpos rs1+%g0 */ -{ "tcc", 0x9bd02000, 0x402fc000, "i", 0 }, /* tcc %g0+i */ -{ "tcc", 0x9bd02000, 0x40280000, "1+i", 0 }, -{ "tcc", 0x9bd00000, 0x40282000, "1+2", 0 }, -{ "tcc", 0x9bd00000, 0x4028201f, "1", 0 }, /* tcc rs1+%g0 */ -{ "tgu", 0x99d02000, 0x402fc000, "i", 0 }, /* tgu %g0+i */ -{ "tgu", 0x99d02000, 0x40280000, "1+i", 0 }, -{ "tgu", 0x99d00000, 0x40282000, "1+2", 0 }, -{ "tgu", 0x99d00000, 0x4028201f, "1", 0 }, /* tgu rs1+%g0 */ -{ "tge", 0x97d02000, 0x402fc000, "i", 0 }, /* tge %g0+i */ -{ "tge", 0x97d02000, 0x40280000, "1+i", 0 }, -{ "tge", 0x97d00000, 0x40282000, "1+2", 0 }, -{ "tge", 0x97d00000, 0x4028201f, "1", 0 }, /* tge rs1+%g0 */ -{ "tg", 0x95d02000, 0x402fc000, "i", 0 }, /* tg %g0+i */ -{ "tg", 0x95d02000, 0x40280000, "1+i", 0 }, -{ "tg", 0x95d00000, 0x40282000, "1+2", 0 }, -{ "tg", 0x95d00000, 0x4028201f, "1", 0 }, /* tg rs1+%g0 */ -{ "tne", 0x93d02000, 0x402fc000, "i", 0 }, /* tne %g0+i */ -{ "tne", 0x93d02000, 0x40280000, "1+i", 0 }, -{ "tne", 0x93d00000, 0x40282000, "1+2", 0 }, -{ "tne", 0x93d00000, 0x4028201f, "1", 0 }, /* tne rs1+%g0 */ -{ "tleu", 0x8bd02000, 0x502fc000, "i", 0 }, /* tleu %g0+i */ -{ "tleu", 0x8bd02000, 0x50280000, "1+i", 0 }, -{ "tleu", 0x8bd00000, 0x50282000, "1+2", 0 }, -{ "tleu", 0x8bd00000, 0x5028201f, "1", 0 }, /* tleu rs1+%g0 */ -{ "ta", 0x91d02000, 0x402fc000, "i", 0 }, /* ta %g0+i */ -{ "ta", 0x91d02000, 0x402d0000, "1+i", 0 }, -{ "ta", 0x91d00000, 0x40282000, "1+2", 0 }, -{ "ta", 0x91d00000, 0x4028201f, "1", 0 }, /* ta rs1+%g0 */ -{ "tvs", 0x8fd02000, 0x502fc000, "i", 0 }, /* tvs %g0+i */ -{ "tvs", 0x8fd02000, 0x50280000, "1+i", 0 }, -{ "tvs", 0x8fd00000, 0x50282000, "1+2", 0 }, -{ "tvs", 0x8fd00000, 0x5028201f, "1", 0 }, /* tvs rs1+%g0 */ -{ "tneg", 0x8dd02000, 0x502fc000, "i", 0 }, /* tneg %g0+i */ -{ "tneg", 0x8dd02000, 0x50280000, "1+i", 0 }, -{ "tneg", 0x8dd00000, 0x50282000, "1+2", 0 }, -{ "tneg", 0x8dd00000, 0x5028201f, "1", 0 }, /* tneg rs1+%g0 */ -{ "tcs", 0x8bd02000, 0x502fc000, "i", 0 }, /* tcs %g0+i */ -{ "tcs", 0x8bd02000, 0x50280000, "1+i", 0 }, -{ "tcs", 0x8bd00000, 0x50282000, "1+2", 0 }, -{ "tcs", 0x8bd00000, 0x5028201f, "1", 0 }, /* tcs rs1+%g0 */ -{ "tl", 0x87d02000, 0x502fc000, "i", 0 }, /* tl %g0+i */ -{ "tl", 0x87d02000, 0x50280000, "1+i", 0 }, -{ "tl", 0x87d00000, 0x50282000, "1+2", 0 }, -{ "tl", 0x87d00000, 0x5028201f, "1", 0 }, /* tl rs1+%g0 */ -{ "tle", 0x85d02000, 0x502fc000, "i", 0 }, /* tle %g0+i */ -{ "tle", 0x85d02000, 0x50280000, "1+i", 0 }, -{ "tle", 0x85d00000, 0x50282000, "1+2", 0 }, -{ "tle", 0x85d00000, 0x5028201f, "1", 0 }, /* tle rs1+%g0 */ -{ "te", 0x83d02000, 0x502fc000, "i", 0 }, /* te %g0+i */ -{ "te", 0x83d02000, 0x50280000, "1+i", 0 }, -{ "te", 0x83d00000, 0x50282000, "1+2", 0 }, -{ "te", 0x83d00000, 0x5028201f, "1", 0 }, /* te rs1+%g0 */ -{ "tn", 0x81d02000, 0x502fc000, "i", 0 }, /* tn %g0+i */ -{ "tn", 0x81d02000, 0x50280000, "1+i", 0 }, -{ "tn", 0x81d00000, 0x50282000, "1+2", 0 }, -{ "tn", 0x81d00000, 0x5028201f, "1", 0 }, /* tn rs1+%g0 */ - -{ "tsubcc", 0x81080000, 0x40f00000, "1,2,d", 0 }, -{ "tsubcc", 0x81082000, 0x40f00000, "1,i,d", 0 }, -{ "tsubcctv", 0x80580000, 0x40a00000, "1,2,d", 0 }, -{ "tsubcctv", 0x80582000, 0x40a00000, "1,i,d", 0 }, - -{ "unimp", 0x00000000, 0x00000000, "l", 0 }, - -{ "iflush", 0x81d80000, 0x40202000, "1+2", 0 }, -{ "iflush", 0x81d82000, 0x40200000, "1+i", 0 }, - -{ "xnorcc", 0x80b80000, 0x41400000, "1,2,d", 0 }, -{ "xnorcc", 0x80b82000, 0x41400000, "1,i,d", 0 }, -{ "xnorcc", 0x80b82000, 0x41400000, "i,1,d", 0 }, -{ "xorcc", 0x80980000, 0x41600000, "1,2,d", 0 }, -{ "xorcc", 0x80982000, 0x41600000, "1,i,d", 0 }, -{ "xorcc", 0x80982000, 0x41600000, "i,1,d", 0 }, -{ "xnor", 0x80380000, 0x41c00000, "1,2,d", 0 }, -{ "xnor", 0x80382000, 0x41c00000, "1,i,d", 0 }, -{ "xnor", 0x80382000, 0x41c00000, "i,1,d", 0 }, -{ "xor", 0x80180000, 0x41e00000, "1,2,d", 0 }, -{ "xor", 0x80182000, 0x41e00000, "1,i,d", 0 }, -{ "xor", 0x80182000, 0x41e00000, "i,1,d", 0 }, - -{ "fpop1", 0x81a00000, 0x40580000, "[1+2],d", 0 }, -{ "fpop2", 0x81a80000, 0x40500000, "[1+2],d", 0 }, - -{ "fb", 0x31800000, 0xc0400000, ",al", 1 }, -{ "fb", 0x11800000, 0xc0400000, "l", 1 }, -{ "fba", 0x31800000, 0xc0400000, ",al", 1 }, -{ "fba", 0x11800000, 0xc0400000, "l", 1 }, -{ "fbn", 0x21800000, 0xc0400000, ",al", 1 }, -{ "fbn", 0x01800000, 0xc0400000, "l", 1 }, -{ "fbu", 0x2f800000, 0xc0400000, ",al", 1 }, -{ "fbu", 0x0f800000, 0xc0400000, "l", 1 }, -{ "fbg", 0x2d800000, 0xc0400000, ",al", 1 }, -{ "fbg", 0x0d800000, 0xc0400000, "l", 1 }, -{ "fbug", 0x2b800000, 0xc0400000, ",al", 1 }, -{ "fbug", 0x0b800000, 0xc0400000, "l", 1 }, -{ "fbl", 0x29800000, 0xc0400000, ",al", 1 }, -{ "fbl", 0x09800000, 0xc0400000, "l", 1 }, -{ "fbul", 0x27800000, 0xc0400000, ",al", 1 }, -{ "fbul", 0x07800000, 0xc0400000, "l", 1 }, -{ "fblg", 0x25800000, 0xc0400000, ",al", 1 }, -{ "fblg", 0x05800000, 0xc0400000, "l", 1 }, -{ "fbne", 0x23800000, 0xc0400000, ",al", 1 }, -{ "fbne", 0x03800000, 0xc0400000, "l", 1 }, -{ "fbe", 0x33800000, 0xc0400000, ",al", 1 }, -{ "fbe", 0x13800000, 0xc0400000, "l", 1 }, -{ "fbue", 0x35800000, 0xc0400000, ",al", 1 }, -{ "fbue", 0x15800000, 0xc0400000, "l", 1 }, -{ "fbge", 0x37800000, 0xc0400000, ",al", 1 }, -{ "fbge", 0x17800000, 0xc0400000, "l", 1 }, -{ "fbuge", 0x39800000, 0xc0400000, ",al", 1 }, -{ "fbuge", 0x19800000, 0xc0400000, "l", 1 }, -{ "fble", 0x3b800000, 0xc0400000, ",al", 1 }, -{ "fble", 0x1b800000, 0xc0400000, "l", 1 }, -{ "fbule", 0x3d800000, 0xc0400000, ",al", 1 }, -{ "fbule", 0x1d800000, 0xc0400000, "l", 1 }, -{ "fbo", 0x3f800000, 0xc0400000, ",al", 1 }, -{ "fbo", 0x1f800000, 0xc0400000, "l", 1 }, - -{ "cba", 0x31c00000, 0xce000000, ",al", 1 }, -{ "cba", 0x11c00000, 0xce000000, "l", 1 }, -{ "cbn", 0x21c00000, 0xde000000, ",al", 1 }, -{ "cbn", 0x01c00000, 0xde000000, "l", 1 }, -{ "cb3", 0x2fc00000, 0xc0000000, ",al", 1 }, -{ "cb3", 0x0fc00000, 0xc0000000, "l", 1 }, -{ "cb2", 0x2dc00000, 0xc0000000, ",al", 1 }, -{ "cb2", 0x0dc00000, 0xc0000000, "l", 1 }, -{ "cb23", 0x2bc00000, 0xc0000000, ",al", 1 }, -{ "cb23", 0x0bc00000, 0xc0000000, "l", 1 }, -{ "cb1", 0x29c00000, 0xc0000000, ",al", 1 }, -{ "cb1", 0x09c00000, 0xc0000000, "l", 1 }, -{ "cb13", 0x27c00000, 0xc0000000, ",al", 1 }, -{ "cb13", 0x07c00000, 0xc0000000, "l", 1 }, -{ "cb12", 0x25c00000, 0xc0000000, ",al", 1 }, -{ "cb12", 0x05c00000, 0xc0000000, "l", 1 }, -{ "cb123", 0x23c00000, 0xc0000000, ",al", 1 }, -{ "cb123", 0x03c00000, 0xc0000000, "l", 1 }, -{ "cb0", 0x33c00000, 0xc0000000, ",al", 1 }, -{ "cb0", 0x13c00000, 0xc0000000, "l", 1 }, -{ "cb03", 0x35c00000, 0xc0000000, ",al", 1 }, -{ "cb03", 0x15c00000, 0xc0000000, "l", 1 }, -{ "cb02", 0x37c00000, 0xc0000000, ",al", 1 }, -{ "cb02", 0x17c00000, 0xc0000000, "l", 1 }, -{ "cb023", 0x39c00000, 0xc0000000, ",al", 1 }, -{ "cb023", 0x19c00000, 0xc0000000, "l", 1 }, -{ "cb013", 0x3dc00000, 0xc0000000, ",al", 1 }, -{ "cb013", 0x1dc00000, 0xc0000000, "l", 1 }, -{ "cb012", 0x3fc00000, 0xc0000000, ",al", 1 }, -{ "cb012", 0x1fc00000, 0xc0000000, "l", 1 }, - -{ "fstoi", 0x81a01a20, 0x400025c0, "f,g", 0 }, -{ "fdtoi", 0x81a01a40, 0x400025a0, "f,g", 0 }, -{ "fxtoi", 0x81a01a60, 0x40002580, "f,g", 0 }, - -{ "fitox", 0x81a01980, 0x40002660, "f,g", 0 }, -{ "fitod", 0x81a01900, 0x400026e0, "f,g", 0 }, -{ "fitos", 0x81a01880, 0x40002660, "f,g", 0 }, - -{ "fstod", 0x81a01920, 0x400026c0, "f,g", 0 }, -{ "fstox", 0x81a019a0, 0x40002640, "f,g", 0 }, -{ "fdtos", 0x81a018c0, 0x40002720, "f,g", 0 }, -{ "fdtox", 0x81a019c0, 0x40002620, "f,g", 0 }, -{ "fxtos", 0x81a018e0, 0x40002700, "f,g", 0 }, -{ "fxtod", 0x81a01960, 0x40002680, "f,g", 0 }, - -{ "fdivx", 0x81a009e0, 0x40083600, "e,f,g", 0 }, -{ "fdivd", 0x81a009c0, 0x40003620, "e,f,g", 0 }, -{ "fdivs", 0x81a009a0, 0x40003640, "e,f,g", 0 }, -{ "fmuls", 0x81a00920, 0x400036c0, "e,f,g", 0 }, -{ "fmuld", 0x81a00940, 0x400036a0, "e,f,g", 0 }, -{ "fmulx", 0x81a00960, 0x40003680, "e,f,g", 0 }, - -{ "fsqrts", 0x81a00520, 0x40003ac0, "f,g", 0 }, -{ "fsqrtd", 0x81a00540, 0x40003aa8, "f,g", 0 }, -{ "fsqrtx", 0x81a00560, 0x40003a80, "f,g", 0 }, - -{ "fabss", 0x81a00120, 0x40003ec0, "f,g", 0 }, -{ "fnegs", 0x81a000a0, 0x40003f40, "f,g", 0 }, -{ "fmovs", 0x81a00020, 0x40003fc0, "f,g", 0 }, - -{ "fsubx", 0x81a008e0, 0x40003700, "e,f,g", 0 }, -{ "fsubd", 0x81a008c0, 0x40003720, "e,f,g", 0 }, -{ "fsubs", 0x81a008a0, 0x40003740, "e,f,g", 0 }, -{ "faddx", 0x81a00860, 0x40003780, "e,f,g", 0 }, -{ "faddd", 0x81a00840, 0x400037a0, "e,f,g", 0 }, -{ "fadds", 0x81a00820, 0x400037c0, "e,f,g", 0 }, - -{ "fcmpex", 0x81a80ae0, 0x40003500, "e,f", 0 }, -{ "fcmped", 0x81a80ac0, 0x40003520, "e,f", 0 }, -{ "fcmpes", 0x81a80aa0, 0x40003540, "e,f", 0 }, -{ "fcmpx", 0x81a80a60, 0x40003580, "e,f", 0 }, -{ "fcmpd", 0x81a80a40, 0x400035a0, "e,f", 0 }, -{ "fcmps", 0x81a80a20, 0x400035c0, "e,f", 0 }, - -{ "cpop1", 0x81b00000, 0x40480000, "[1+2],d", 0 }, -{ "cpop2", 0x81b80000, 0x40400000, "[1+2],d", 0 }, -}; - -#define NUMOPCODES ((sizeof sparc_opcodes)/(sizeof sparc_opcodes[0])) - diff --git a/gnu/usr.bin/gdb/config/sparc-pinsn.c b/gnu/usr.bin/gdb/config/sparc-pinsn.c deleted file mode 100644 index 6f3954706ad1..000000000000 --- a/gnu/usr.bin/gdb/config/sparc-pinsn.c +++ /dev/null @@ -1,452 +0,0 @@ -/* Disassembler for the sparc. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GDB, the GNU disassembler. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: sparc-pinsn.c,v 1.2 1993/08/02 17:40:22 mycroft Exp $"; -#endif /* not lint */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "sparc-opcode.h" - -extern char *reg_names[]; -#define freg_names (®_names[4 * 8]) - -union sparc_insn - { - unsigned long int code; - struct - { - unsigned int OP:2; -#define op ldst.OP - unsigned int RD:5; -#define rd ldst.RD - unsigned int op3:6; - unsigned int RS1:5; -#define rs1 ldst.RS1 - unsigned int i:1; - unsigned int ASI:8; -#define asi ldst.ASI - unsigned int RS2:5; -#define rs2 ldst.RS2 -#define shcnt rs2 - } ldst; - struct - { - unsigned int OP:2, RD:5, op3:6, RS1:5, i:1; - unsigned int IMM13:13; -#define imm13 IMM13.IMM13 - } IMM13; - struct - { - unsigned int OP:2; - unsigned int a:1; - unsigned int cond:4; - unsigned int op2:3; - unsigned int DISP22:22; -#define disp22 branch.DISP22 - } branch; -#define imm22 disp22 - struct - { - unsigned int OP:2; - unsigned int DISP30:30; -#define disp30 call.DISP30 - } call; - }; - -/* Nonzero if INSN is the opcode for a delayed branch. */ -static int -is_delayed_branch (insn) - union sparc_insn insn; -{ - unsigned int i; - - for (i = 0; i < NUMOPCODES; ++i) - { - const struct sparc_opcode *opcode = &sparc_opcodes[i]; - if ((opcode->match & insn.code) == opcode->match - && (opcode->lose & insn.code) == 0 - && (opcode->delayed)) - return 1; - } - return 0; -} - -static int opcodes_sorted = 0; - -/* Print one instruction from MEMADDR on STREAM. */ -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - union sparc_insn insn; - - register unsigned int i; - - if (!opcodes_sorted) - { - static int compare_opcodes (); - qsort ((char *) sparc_opcodes, NUMOPCODES, - sizeof (sparc_opcodes[0]), compare_opcodes); - opcodes_sorted = 1; - } - - read_memory (memaddr, &insn, sizeof (insn)); - - for (i = 0; i < NUMOPCODES; ++i) - { - const struct sparc_opcode *opcode = &sparc_opcodes[i]; - if ((opcode->match & insn.code) == opcode->match - && (opcode->lose & insn.code) == 0) - { - /* Nonzero means that we have found an instruction which has - the effect of adding or or'ing the imm13 field to rs1. */ - int imm_added_to_rs1 = 0; - - /* Nonzero means that we have found a plus sign in the args - field of the opcode table. */ - int found_plus = 0; - - /* Do we have an 'or' instruction where rs1 is the same - as rsd, and which has the i bit set? */ - if (opcode->match == 0x80102000 - && insn.rs1 == insn.rd) - imm_added_to_rs1 = 1; - - if (index (opcode->args, 'S') != 0) - /* Reject the special case for `set'. - The real `sethi' will match. */ - continue; - if (insn.rs1 != insn.rd - && index (opcode->args, 'r') != 0) - /* Can't do simple format if source and dest are different. */ - continue; - - fputs_filtered (opcode->name, stream); - - { - register const char *s; - - if (opcode->args[0] != ',') - fputs_filtered (" ", stream); - for (s = opcode->args; *s != '\0'; ++s) - { - if (*s == ',') - { - fputs_filtered (",", stream); - ++s; - if (*s == 'a') - { - fputs_filtered ("a", stream); - ++s; - } - fputs_filtered (" ", stream); - } - - switch (*s) - { - case '+': - found_plus = 1; - - /* note fall-through */ - default: - fprintf_filtered (stream, "%c", *s); - break; - - case '#': - fputs_filtered ("0", stream); - break; - -#define reg(n) fprintf_filtered (stream, "%%%s", reg_names[n]) - case '1': - case 'r': - reg (insn.rs1); - break; - - case '2': - reg (insn.rs2); - break; - - case 'd': - reg (insn.rd); - break; -#undef reg - -#define freg(n) fprintf_filtered (stream, "%%%s", freg_names[n]) - case 'e': - freg (insn.rs1); - break; - - case 'f': - freg (insn.rs2); - break; - - case 'g': - freg (insn.rd); - break; -#undef freg - -#define creg(n) fprintf_filtered (stream, "%%c%u", (unsigned int) (n)) - case 'b': - creg (insn.rs1); - break; - - case 'c': - creg (insn.rs2); - break; - - case 'D': - creg (insn.rd); - break; -#undef creg - - case 'h': - fprintf_filtered (stream, "%%hi(%#x)", - (int) insn.imm22 << 10); - break; - - case 'i': - { - /* We cannot trust the compiler to sign-extend - when extracting the bitfield, hence the shifts. */ - int imm = ((int) insn.imm13 << 19) >> 19; - - /* Check to see whether we have a 1+i, and take - note of that fact. - - Note: because of the way we sort the table, - we will be matching 1+i rather than i+1, - so it is OK to assume that i is after +, - not before it. */ - if (found_plus) - imm_added_to_rs1 = 1; - - if (imm <= 9) - fprintf_filtered (stream, "%d", imm); - else - fprintf_filtered (stream, "%#x", imm); - } - break; - - case 'L': - print_address ((CORE_ADDR) memaddr + insn.disp30 * 4, - stream); - break; - - case 'l': - if ((insn.code >> 22) == 0) - /* Special case for `unimp'. Don't try to turn - it's operand into a function offset. */ - fprintf_filtered (stream, "%#x", - (int) (((int) insn.disp22 << 10) >> 10)); - else - /* We cannot trust the compiler to sign-extend - when extracting the bitfield, hence the shifts. */ - print_address ((CORE_ADDR) - (memaddr - + (((int) insn.disp22 << 10) >> 10) * 4), - stream); - break; - - case 'A': - fprintf_filtered (stream, "(%d)", (int) insn.asi); - break; - - case 'C': - fputs_filtered ("%csr", stream); - break; - - case 'F': - fputs_filtered ("%fsr", stream); - break; - - case 'p': - fputs_filtered ("%psr", stream); - break; - - case 'q': - fputs_filtered ("%fq", stream); - break; - - case 'Q': - fputs_filtered ("%cq", stream); - break; - - case 't': - fputs_filtered ("%tbr", stream); - break; - - case 'w': - fputs_filtered ("%wim", stream); - break; - - case 'y': - fputs_filtered ("%y", stream); - break; - } - } - } - - /* If we are adding or or'ing something to rs1, then - check to see whether the previous instruction was - a sethi to the same register as in the sethi. - If so, attempt to print the result of the add or - or (in this context add and or do the same thing) - and its symbolic value. */ - if (imm_added_to_rs1) - { - union sparc_insn prev_insn; - int errcode; - - errcode = read_memory (memaddr - 4, - &prev_insn, sizeof (prev_insn)); - - if (errcode == 0) - { - /* If it is a delayed branch, we need to look at the - instruction before the delayed branch. This handles - sequences such as - - sethi %o1, %hi(_foo), %o1 - call _printf - or %o1, %lo(_foo), %o1 - */ - - if (is_delayed_branch (prev_insn)) - errcode = read_memory (memaddr - 8, - &prev_insn, sizeof (prev_insn)); - } - - /* If there was a problem reading memory, then assume - the previous instruction was not sethi. */ - if (errcode == 0) - { - /* Is it sethi to the same register? */ - if ((prev_insn.code & 0xc1c00000) == 0x01000000 - && prev_insn.rd == insn.rs1) - { - fprintf_filtered (stream, "\t! "); - /* We cannot trust the compiler to sign-extend - when extracting the bitfield, hence the shifts. */ - print_address (((int) prev_insn.imm22 << 10) - | (insn.imm13 << 19) >> 19, stream); - } - } - } - - return sizeof (insn); - } - } - - fprintf_filtered ("%#8x", insn.code); - return sizeof (insn); -} - - -/* Compare opcodes A and B. */ - -static int -compare_opcodes (a, b) - char *a, *b; -{ - struct sparc_opcode *op0 = (struct sparc_opcode *) a; - struct sparc_opcode *op1 = (struct sparc_opcode *) b; - unsigned long int match0 = op0->match, match1 = op1->match; - unsigned long int lose0 = op0->lose, lose1 = op1->lose; - register unsigned int i; - - /* If a bit is set in both match and lose, there is something - wrong with the opcode table. */ - if (match0 & lose0) - { - fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\", %#.8x, %#.8x\n", - op0->name, match0, lose0); - op0->lose &= ~op0->match; - lose0 = op0->lose; - } - - if (match1 & lose1) - { - fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\", %#.8x, %#.8x\n", - op1->name, match1, lose1); - op1->lose &= ~op1->match; - lose1 = op1->lose; - } - - /* Because the bits that are variable in one opcode are constant in - another, it is important to order the opcodes in the right order. */ - for (i = 0; i < 32; ++i) - { - unsigned long int x = 1 << i; - int x0 = (match0 & x) != 0; - int x1 = (match1 & x) != 0; - - if (x0 != x1) - return x1 - x0; - } - - for (i = 0; i < 32; ++i) - { - unsigned long int x = 1 << i; - int x0 = (lose0 & x) != 0; - int x1 = (lose1 & x) != 0; - - if (x0 != x1) - return x1 - x0; - } - - /* They are functionally equal. So as long as the opcode table is - valid, we can put whichever one first we want, on aesthetic grounds. */ - { - int length_diff = strlen (op0->args) - strlen (op1->args); - if (length_diff != 0) - /* Put the one with fewer arguments first. */ - return length_diff; - } - - /* Put 1+i before i+1. */ - { - char *p0 = (char *) index(op0->args, '+'); - char *p1 = (char *) index(op1->args, '+'); - - if (p0 && p1) - { - /* There is a plus in both operands. Note that a plus - sign cannot be the first character in args, - so the following [-1]'s are valid. */ - if (p0[-1] == 'i' && p1[1] == 'i') - /* op0 is i+1 and op1 is 1+i, so op1 goes first. */ - return 1; - if (p0[1] == 'i' && p1[-1] == 'i') - /* op0 is 1+i and op1 is i+1, so op0 goes first. */ - return -1; - } - } - - /* They are, as far as we can tell, identical. - Since qsort may have rearranged the table partially, there is - no way to tell which one was first in the opcode table as - written, so just say there are equal. */ - return 0; -} diff --git a/gnu/usr.bin/gdb/config/sun3-dep.c b/gnu/usr.bin/gdb/config/sun3-dep.c deleted file mode 100644 index 780558808562..000000000000 --- a/gnu/usr.bin/gdb/config/sun3-dep.c +++ /dev/null @@ -1,632 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)sun3-dep.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: sun3-dep.c,v 1.2 1993/08/01 18:48:28 mycroft Exp $"; -#endif /* not lint */ - -/* XXX - Added some bogus code so program will compile. The problem is that - this module needs to be updated to use the new remote memory interface. - In the meantime, remote debugging is broken. (mccanne) -*/ -#define remote_store_word do_nothing -#define remote_fetch_word do_nothing -static do_nothing() {} - -/* Machine-dependent code which would otherwise be in inflow.c and core.c, - for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -extern int errno; -extern int attach_flag; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -#ifdef ATTACH_DETACH - -/* Start debugging the process whose number is PID. */ - -attach (pid) - int pid; -{ - errno = 0; - ptrace (PTRACE_ATTACH, pid, 0, 0); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 1; - return pid; -} - -/* Stop debugging the process whose number is PID - and continue it with signal number SIGNAL. - SIGNAL = 0 means just continue it. */ - -void -detach (signal) - int signal; -{ - errno = 0; - ptrace (PTRACE_DETACH, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 0; -} -#endif /* ATTACH_DETACH */ - -void -fetch_inferior_registers () -{ - struct regs inferior_registers; -#ifdef FP0_REGNUM - struct fp_status inferior_fp_registers; -#endif - extern char registers[]; - - if (remote_debugging) - remote_fetch_registers (registers); - else - { - ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers); -#ifdef FP0_REGNUM - ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers); -#endif - - bcopy (&inferior_registers, registers, 16 * 4); -#ifdef FP0_REGNUM - bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fps_regs); -#endif - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; -#ifdef FP0_REGNUM - bcopy (&inferior_fp_registers.fps_control, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); -#endif - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - - if (remote_debugging) - remote_store_registers (registers); - else - { - bcopy (registers, &inferior_registers, 16 * 4); -#ifdef FP0_REGNUM - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, - sizeof inferior_fp_registers.fps_regs); -#endif - inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; - -#ifdef FP0_REGNUM - bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], - &inferior_fp_registers.fps_control, - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); -#endif - - ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); -#if FP0_REGNUM - ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers); -#endif - } -} - -/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory - in the NEW_SUN_PTRACE case. - It ought to be straightforward. But it appears that writing did - not write the data that I specified. I cannot understand where - it got the data that it actually did write. */ - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - buffer[0] = remote_fetch_word (addr); - else - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - if (remote_debugging) - buffer[count - 1] - = remote_fetch_word (addr + (count - 1) * sizeof (int)); - else - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - remote_store_word (addr, buffer[i]); - else - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - - -/* Machine-dependent code which would otherwise be in core.c */ -/* Work with core dump and executable files, for GDB. */ - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Non-zero if this is an object (.o) file, rather than an executable. - Distinguishing between the two is rarely necessary (and seems like - a hack, but there is no other way to get the text and data - addresses--N_TXTADDR should probably take care of - this, but it doesn't). */ -/* This definition will not work - if someone decides to make ld preserve relocation info. */ -#define IS_OBJECT_FILE(hdr) (hdr.a_trsize != 0) - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern char *sys_siglist[]; - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - - { - struct core corestr; - - val = myread (corechan, &corestr, sizeof corestr); - if (val < 0) - perror_with_name (filename); - if (corestr.c_magic != CORE_MAGIC) - error ("\"%s\" does not appear to be a core dump file (magic 0x%x, expected 0x%x)", - filename, corestr.c_magic, (int) CORE_MAGIC); - else if (sizeof (struct core) != corestr.c_len) - error ("\"%s\" has an invalid struct core length (%d, expected %d)", - filename, corestr.c_len, (int) sizeof (struct core)); - - data_start = exec_data_start; - data_end = data_start + corestr.c_dsize; - stack_start = stack_end - corestr.c_ssize; - data_offset = sizeof corestr; - stack_offset = sizeof corestr + corestr.c_dsize; - - bcopy (&corestr.c_regs, registers, 16 * 4); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = corestr.c_regs.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = corestr.c_regs.r_pc; -#ifdef FP0_REGNUM -#ifdef FPU - bcopy (corestr.c_fpu.f_fpstatus.fps_regs, - ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof corestr.c_fpu.f_fpstatus.fps_regs); - bcopy (&corestr.c_fpu.f_fpstatus.fps_control, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof corestr.c_fpu.f_fpstatus - sizeof corestr.c_fpu.f_fpstatus.fps_regs); -#else - bcopy (corestr.c_fpstatus.fps_regs, - ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof corestr.c_fpstatus.fps_regs); - bcopy (&corestr.c_fpstatus.fps_control, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof corestr.c_fpstatus - sizeof corestr.c_fpstatus.fps_regs); -#endif -#endif - bcopy (&corestr.c_aouthdr, &core_aouthdr, sizeof (struct exec)); - - printf ("Core file is from \"%s\".\n", corestr.c_cmdname); - if (corestr.c_signo > 0) - printf ("Program terminated with signal %d, %s.\n", - corestr.c_signo, - corestr.c_signo < NSIG - ? sys_siglist[corestr.c_signo] - : "(undocumented)"); - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = - IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr); - exec_data_start = IS_OBJECT_FILE (exec_aouthdr) - ? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr); - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - diff --git a/gnu/usr.bin/gdb/config/symmetry-dep.c b/gnu/usr.bin/gdb/config/symmetry-dep.c deleted file mode 100644 index fb069d44c635..000000000000 --- a/gnu/usr.bin/gdb/config/symmetry-dep.c +++ /dev/null @@ -1,1291 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: symmetry-dep.c,v 1.2 1993/08/02 17:40:23 mycroft Exp $"; -#endif /* not lint */ - -/* many 387-specific items of use taken from i386-dep.c */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "symtab.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -static long i386_get_frame_setup (); -static i386_follow_jump (); - -/* XPT_DEBUG doesn't work yet under Dynix 3.0.12, but UNDEBUG does... */ -#define PTRACE_ATTACH XPT_DEBUG -#define PTRACE_DETACH XPT_UNDEBUG - -#include -#define TERMINAL struct sgttyb - -extern int errno; - -/* Nonzero if we are debugging an attached outside process - rather than an inferior. */ - -static int attach_flag; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - - - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -#ifdef ATTACH_DETACH - -/* Start debugging the process whose number is PID. */ - -attach (pid) - int pid; -{ - errno = 0; - ptrace (PTRACE_ATTACH, pid, 0, 0); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 1; - return pid; -} - -/* Stop debugging the process whose number is PID - and continue it with signal number SIGNAL. - SIGNAL = 0 means just continue it. */ - -void -detach (signal) - int signal; -{ - errno = 0; - ptrace (PTRACE_DETACH, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 0; -} -#endif /* ATTACH_DETACH */ - - -store_inferior_registers(regno) -int regno; -{ - struct pt_regset regs; - int reg_tmp, i; - extern char registers[]; - - if (-1 == regno) - { - regs.pr_eax = *(int *)®isters[REGISTER_BYTE(0)]; - regs.pr_ebx = *(int *)®isters[REGISTER_BYTE(5)]; - regs.pr_ecx = *(int *)®isters[REGISTER_BYTE(2)]; - regs.pr_edx = *(int *)®isters[REGISTER_BYTE(1)]; - regs.pr_esi = *(int *)®isters[REGISTER_BYTE(6)]; - regs.pr_edi = *(int *)®isters[REGISTER_BYTE(7)]; - regs.pr_esp = *(int *)®isters[REGISTER_BYTE(14)]; - regs.pr_ebp = *(int *)®isters[REGISTER_BYTE(15)]; - regs.pr_eip = *(int *)®isters[REGISTER_BYTE(16)]; - regs.pr_flags = *(int *)®isters[REGISTER_BYTE(17)]; - for (i = 0; i < 31; i++) { - regs.pr_fpa.fpa_regs[i] = - *(int *)®isters[REGISTER_BYTE(FP1_REGNUM+i)]; - } - } - else - { - reg_tmp = *(int *)®isters[REGISTER_BYTE(regno)]; - ptrace(XPT_RREGS, inferior_pid, ®s, 0); - switch (regno) - { - case 0: - regs.pr_eax = *(int *)®isters[REGISTER_BYTE(0)]; - break; - case 5: - regs.pr_ebx = *(int *)®isters[REGISTER_BYTE(5)]; - break; - case 2: - regs.pr_ecx = *(int *)®isters[REGISTER_BYTE(2)]; - break; - case 1: - regs.pr_edx = *(int *)®isters[REGISTER_BYTE(1)]; - break; - case 6: - regs.pr_esi = *(int *)®isters[REGISTER_BYTE(6)]; - break; - case 7: - regs.pr_edi = *(int *)®isters[REGISTER_BYTE(7)]; - break; - case 15: - regs.pr_ebp = *(int *)®isters[REGISTER_BYTE(15)]; - break; - case 14: - regs.pr_esp = *(int *)®isters[REGISTER_BYTE(14)]; - break; - case 16: - regs.pr_eip = *(int *)®isters[REGISTER_BYTE(16)]; - break; - case 17: - regs.pr_flags = *(int *)®isters[REGISTER_BYTE(17)]; - break; - } - } - ptrace(XPT_WREGS, inferior_pid, ®s, 0); -} - -void -fetch_inferior_registers() -{ - int i; - struct pt_regset regs; - extern char registers[]; - - ptrace(XPT_RREGS, inferior_pid, ®s, 0); - *(int *)®isters[REGISTER_BYTE(0)] = regs.pr_eax; - *(int *)®isters[REGISTER_BYTE(5)] = regs.pr_ebx; - *(int *)®isters[REGISTER_BYTE(2)] = regs.pr_ecx; - *(int *)®isters[REGISTER_BYTE(1)] = regs.pr_edx; - *(int *)®isters[REGISTER_BYTE(6)] = regs.pr_esi; - *(int *)®isters[REGISTER_BYTE(7)] = regs.pr_edi; - *(int *)®isters[REGISTER_BYTE(15)] = regs.pr_ebp; - *(int *)®isters[REGISTER_BYTE(14)] = regs.pr_esp; - *(int *)®isters[REGISTER_BYTE(16)] = regs.pr_eip; - *(int *)®isters[REGISTER_BYTE(17)] = regs.pr_flags; - for (i = 0; i < FPA_NREGS; i++) { - *(int *)®isters[REGISTER_BYTE(FP1_REGNUM+i)] = regs.pr_fpa.fpa_regs[i]; - } - bcopy(regs.pr_fpu.fpu_stack[0], ®isters[REGISTER_BYTE(3)], 10); - bcopy(regs.pr_fpu.fpu_stack[1], ®isters[REGISTER_BYTE(4)], 10); - bcopy(regs.pr_fpu.fpu_stack[2], ®isters[REGISTER_BYTE(8)], 10); - bcopy(regs.pr_fpu.fpu_stack[3], ®isters[REGISTER_BYTE(9)], 10); - bcopy(regs.pr_fpu.fpu_stack[4], ®isters[REGISTER_BYTE(10)], 10); - bcopy(regs.pr_fpu.fpu_stack[5], ®isters[REGISTER_BYTE(11)], 10); - bcopy(regs.pr_fpu.fpu_stack[6], ®isters[REGISTER_BYTE(12)], 10); - bcopy(regs.pr_fpu.fpu_stack[7], ®isters[REGISTER_BYTE(13)], 10); -} - - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. */ - -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) { - errno = 0; - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - buffer[0] = remote_fetch_word (addr); - else - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - if (remote_debugging) - buffer[count - 1] - = remote_fetch_word (addr + (count - 1) * sizeof (int)); - else - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - remote_store_word (addr, buffer[i]); - else - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - - -/* Recognize COFF format systems because a.out.h defines AOUTHDR. */ -#ifdef AOUTHDR -#define COFF_FORMAT -#endif - - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#define AOUTHDR struct exec -#endif - -extern char *sys_siglist[]; - -/* Hook for `exec_file_command' command to call. */ - -void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); -unsigned int register_addr (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + NBPG * (u.u_dsize - u.u_tsize); - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = ctob(UPAGES + u.u_dsize - u.u_tsize); - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; -printf("u.u_tsize= %#x, u.u_dsize= %#x, u.u_ssize= %#x, stack_off= %#x\n", - u.u_tsize, u.u_dsize, u.u_ssize, stack_offset); - - core_aouthdr.a_magic = 0; - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame(create_new_frame(read_register(FP_REGNUM), - read_pc())); -/* set_current_frame (read_register (FP_REGNUM));*/ - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_ADDRADJ(exec_aouthdr); - exec_data_start = round(exec_aouthdr.a_text, NBPG*CLSIZE); - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - text_end = exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end = data_start + exec_aouthdr.a_data; - exec_data_offset = N_TXTOFF(exec_aouthdr); - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -/* rounds 'one' up to divide evenly by 'two' */ - -int -round(one,two) -register int one, two; - -{ - register int temp; - temp = (one/two)*two; - if (one != temp) { - temp += two; - } - return temp; -} - - -static CORE_ADDR codestream_next_addr; -static CORE_ADDR codestream_addr; -static unsigned char codestream_buf[sizeof (int)]; -static int codestream_off; -static int codestream_cnt; - -#define codestream_tell() (codestream_addr + codestream_off) -#define codestream_peek() (codestream_cnt == 0 ? \ - codestream_fill(1): codestream_buf[codestream_off]) -#define codestream_get() (codestream_cnt-- == 0 ? \ - codestream_fill(0) : codestream_buf[codestream_off++]) - - -static unsigned char -codestream_fill (peek_flag) -{ - codestream_addr = codestream_next_addr; - codestream_next_addr += sizeof (int); - codestream_off = 0; - codestream_cnt = sizeof (int); - read_memory (codestream_addr, - (unsigned char *)codestream_buf, - sizeof (int)); - - if (peek_flag) - return (codestream_peek()); - else - return (codestream_get()); -} - -static void -codestream_seek (place) -{ - codestream_next_addr = place & -sizeof (int); - codestream_cnt = 0; - codestream_fill (1); - while (codestream_tell() != place) - codestream_get (); -} - -static void -codestream_read (buf, count) - unsigned char *buf; -{ - unsigned char *p; - int i; - p = buf; - for (i = 0; i < count; i++) - *p++ = codestream_get (); -} - -/* - * Following macro translates i386 opcode register numbers to Symmetry - * register numbers. This is used by FRAME_FIND_SAVED_REGS. - * - * %eax %ecx %edx %ebx %esp %ebp %esi %edi - * i386 0 1 2 3 4 5 6 7 - * Symmetry 0 2 1 5 14 15 6 7 - * - */ -#define I386_REGNO_TO_SYMMETRY(n) \ -((n)==0?0 :(n)==1?2 :(n)==2?1 :(n)==3?5 :(n)==4?14 :(n)==5?15 :(n)) - -/* from i386-dep.c */ -i386_frame_find_saved_regs (fip, fsrp) - struct frame_info *fip; - struct frame_saved_regs *fsrp; -{ - unsigned long locals; - unsigned char *p; - unsigned char op; - CORE_ADDR dummy_bottom; - CORE_ADDR adr; - int i; - - bzero (fsrp, sizeof *fsrp); - - /* if frame is the end of a dummy, compute where the - * beginning would be - */ - dummy_bottom = fip->frame - 4 - NUM_REGS*4 - CALL_DUMMY_LENGTH; - - /* check if the PC is in the stack, in a dummy frame */ - if (dummy_bottom <= fip->pc && fip->pc <= fip->frame) - { - /* all regs were saved by push_call_dummy () */ - adr = fip->frame - 4; - for (i = 0; i < NUM_REGS; i++) - { - fsrp->regs[i] = adr; - adr -= 4; - } - return; - } - - locals = i386_get_frame_setup (get_pc_function_start (fip->pc)); - - if (locals >= 0) - { - adr = fip->frame - 4 - locals; - for (i = 0; i < 8; i++) - { - op = codestream_get (); - if (op < 0x50 || op > 0x57) - break; - fsrp->regs[I386_REGNO_TO_SYMMETRY(op - 0x50)] = adr; - adr -= 4; - } - } - - fsrp->regs[PC_REGNUM] = fip->frame + 4; - fsrp->regs[FP_REGNUM] = fip->frame; -} - -/* from i386-dep.c */ -static -print_387_control_word (control) -unsigned short control; -{ - printf ("control 0x%04x: ", control); - printf ("compute to "); - switch ((control >> 8) & 3) - { - case 0: printf ("24 bits; "); break; - case 1: printf ("(bad); "); break; - case 2: printf ("53 bits; "); break; - case 3: printf ("64 bits; "); break; - } - printf ("round "); - switch ((control >> 10) & 3) - { - case 0: printf ("NEAREST; "); break; - case 1: printf ("DOWN; "); break; - case 2: printf ("UP; "); break; - case 3: printf ("CHOP; "); break; - } - if (control & 0x3f) - { - printf ("mask:"); - if (control & 0x0001) printf (" INVALID"); - if (control & 0x0002) printf (" DENORM"); - if (control & 0x0004) printf (" DIVZ"); - if (control & 0x0008) printf (" OVERF"); - if (control & 0x0010) printf (" UNDERF"); - if (control & 0x0020) printf (" LOS"); - printf (";"); - } - printf ("\n"); - if (control & 0xe080) printf ("warning: reserved bits on 0x%x\n", - control & 0xe080); -} - -static -print_387_status_word (status) - unsigned short status; -{ - printf ("status %#04x: ", status); - if (status & 0xff) { - printf ("exceptions:"); /* exception names match */ - if (status & 0x0001) printf (" FLTINV"); - if (status & 0x0002) printf (" FLTDEN"); - if (status & 0x0004) printf (" FLTDIV"); - if (status & 0x0008) printf (" FLTOVF"); - if (status & 0x0010) printf (" FLTUND"); - if (status & 0x0020) printf (" FLTPRE"); - if (status & 0x0040) printf (" FLTSTK"); - printf ("; "); - } - printf ("flags: %d%d%d%d; ", - (status & 0x4000) != 0, - (status & 0x0400) != 0, - (status & 0x0200) != 0, - (status & 0x0100) != 0); - - printf ("top %d\n", (status >> 11) & 7); -} - -static -print_fpu_status(ep) -struct pt_regset ep; - -{ - int i; - int bothstatus; - int top; - int fpreg; - unsigned char *p; - - printf("80387:"); - if (ep.pr_fpu.fpu_ip == 0) { - printf(" not in use.\n"); - return; - } else { - printf("\n"); - } - if (ep.pr_fpu.fpu_status != 0) { - print_387_status_word (ep.pr_fpu.fpu_status); - } - print_387_control_word (ep.pr_fpu.fpu_control); - printf ("last exception: "); - printf ("opcode 0x%x; ", ep.pr_fpu.fpu_rsvd4); - printf ("pc 0x%x:0x%x; ", ep.pr_fpu.fpu_cs, ep.pr_fpu.fpu_ip); - printf ("operand 0x%x:0x%x\n", ep.pr_fpu.fpu_data_offset, ep.pr_fpu.fpu_op_sel); - - top = (ep.pr_fpu.fpu_status >> 11) & 7; - - printf ("regno tag msb lsb value\n"); - for (fpreg = 7; fpreg >= 0; fpreg--) - { - double val; - - printf ("%s %d: ", fpreg == top ? "=>" : " ", fpreg); - - switch ((ep.pr_fpu.fpu_tag >> (fpreg * 2)) & 3) - { - case 0: printf ("valid "); break; - case 1: printf ("zero "); break; - case 2: printf ("trap "); break; - case 3: printf ("empty "); break; - } - for (i = 9; i >= 0; i--) - printf ("%02x", ep.pr_fpu.fpu_stack[fpreg][i]); - - i387_to_double (ep.pr_fpu.fpu_stack[fpreg], (char *)&val); - printf (" %g\n", val); - } - if (ep.pr_fpu.fpu_rsvd1) - printf ("warning: rsvd1 is 0x%x\n", ep.pr_fpu.fpu_rsvd1); - if (ep.pr_fpu.fpu_rsvd2) - printf ("warning: rsvd2 is 0x%x\n", ep.pr_fpu.fpu_rsvd2); - if (ep.pr_fpu.fpu_rsvd3) - printf ("warning: rsvd3 is 0x%x\n", ep.pr_fpu.fpu_rsvd3); - if (ep.pr_fpu.fpu_rsvd5) - printf ("warning: rsvd5 is 0x%x\n", ep.pr_fpu.fpu_rsvd5); -} - - -print_1167_control_word(pcr) -unsigned int pcr; - -{ - int pcr_tmp; - - pcr_tmp = pcr & FPA_PCR_MODE; - printf("\tMODE= %#x; RND= %#x ", pcr_tmp, pcr_tmp & 12); - switch (pcr_tmp & 12) { - case 0: - printf("RN (Nearest Value)"); - break; - case 1: - printf("RZ (Zero)"); - break; - case 2: - printf("RP (Positive Infinity)"); - break; - case 3: - printf("RM (Negative Infinity)"); - break; - } - printf("; IRND= %d ", pcr_tmp & 2); - if (0 == pcr_tmp & 2) { - printf("(same as RND)\n"); - } else { - printf("(toward zero)\n"); - } - pcr_tmp = pcr & FPA_PCR_EM; - printf("\tEM= %#x", pcr_tmp); - if (pcr_tmp & FPA_PCR_EM_DM) printf(" DM"); - if (pcr_tmp & FPA_PCR_EM_UOM) printf(" UOM"); - if (pcr_tmp & FPA_PCR_EM_PM) printf(" PM"); - if (pcr_tmp & FPA_PCR_EM_UM) printf(" UM"); - if (pcr_tmp & FPA_PCR_EM_OM) printf(" OM"); - if (pcr_tmp & FPA_PCR_EM_ZM) printf(" ZM"); - if (pcr_tmp & FPA_PCR_EM_IM) printf(" IM"); - printf("\n"); - pcr_tmp = FPA_PCR_CC; - printf("\tCC= %#x", pcr_tmp); - if (pcr_tmp & FPA_PCR_20MHZ) printf(" 20MHZ"); - if (pcr_tmp & FPA_PCR_CC_Z) printf(" Z"); - if (pcr_tmp & FPA_PCR_CC_C2) printf(" C2"); - if (pcr_tmp & FPA_PCR_CC_C1) printf(" C1"); - switch (pcr_tmp) { - case FPA_PCR_CC_Z: - printf(" (Equal)"); - break; - case FPA_PCR_CC_C1: - printf(" (Less than)"); - break; - case 0: - printf(" (Greater than)"); - break; - case FPA_PCR_CC_Z | FPA_PCR_CC_C1 | FPA_PCR_CC_C2: - printf(" (Unordered)"); - break; - default: - printf(" (Undefined)"); - break; - } - printf("\n"); - pcr_tmp = pcr & FPA_PCR_AE; - printf("\tAE= %#x", pcr_tmp); - if (pcr_tmp & FPA_PCR_AE_DE) printf(" DE"); - if (pcr_tmp & FPA_PCR_AE_UOE) printf(" UOE"); - if (pcr_tmp & FPA_PCR_AE_PE) printf(" PE"); - if (pcr_tmp & FPA_PCR_AE_UE) printf(" UE"); - if (pcr_tmp & FPA_PCR_AE_OE) printf(" OE"); - if (pcr_tmp & FPA_PCR_AE_ZE) printf(" ZE"); - if (pcr_tmp & FPA_PCR_AE_EE) printf(" EE"); - if (pcr_tmp & FPA_PCR_AE_IE) printf(" IE"); - printf("\n"); -} - -print_1167_regs(regs) -long regs[FPA_NREGS]; - -{ - int i; - - union { - double d; - long l[2]; - } xd; - union { - float f; - long l; - } xf; - - - for (i = 0; i < FPA_NREGS; i++) { - xf.l = regs[i]; - printf("%%fp%d: raw= %#x, single= %f", i+1, regs[i], xf.f); - if (!(i & 1)) { - printf("\n"); - } else { - xd.l[1] = regs[i]; - xd.l[0] = regs[i+1]; - printf(", double= %f\n", xd.d); - } - } -} - -print_fpa_status(ep) -struct pt_regset ep; - -{ - - printf("WTL 1167:"); - if (ep.pr_fpa.fpa_pcr !=0) { - printf("\n"); - print_1167_control_word(ep.pr_fpa.fpa_pcr); - print_1167_regs(ep.pr_fpa.fpa_regs); - } else { - printf(" not in use.\n"); - } -} - -i386_float_info () - -{ - char ubuf[UPAGES*NBPG]; - struct pt_regset regset; - extern int corechan; - - if (have_inferior_p()) { - call_ptrace(XPT_RREGS, inferior_pid, ®set, 0); - } else { - if (lseek (corechan, 0, 0) < 0) { - perror ("seek on core file"); - } - if (myread (corechan, ubuf, UPAGES*NBPG) < 0) { - perror ("read on core file"); - } - /* only interested in the floating point registers */ - regset.pr_fpu = ((struct user *) ubuf)->u_fpusave; - regset.pr_fpa = ((struct user *) ubuf)->u_fpasave; - } - print_fpu_status(regset); - print_fpa_status(regset); -} - -i387_to_double (from, to) - char *from; - char *to; -{ - long *lp; - /* push extended mode on 387 stack, then pop in double mode - * - * first, set exception masks so no error is generated - - * number will be rounded to inf or 0, if necessary - */ - asm ("pushl %eax"); /* grab a stack slot */ - asm ("fstcw (%esp)"); /* get 387 control word */ - asm ("movl (%esp),%eax"); /* save old value */ - asm ("orl $0x3f,%eax"); /* mask all exceptions */ - asm ("pushl %eax"); - asm ("fldcw (%esp)"); /* load new value into 387 */ - - asm ("movl 8(%ebp),%eax"); - asm ("fldt (%eax)"); /* push extended number on 387 stack */ - asm ("fwait"); - asm ("movl 12(%ebp),%eax"); - asm ("fstpl (%eax)"); /* pop double */ - asm ("fwait"); - - asm ("popl %eax"); /* flush modified control word */ - asm ("fnclex"); /* clear exceptions */ - asm ("fldcw (%esp)"); /* restore original control word */ - asm ("popl %eax"); /* flush saved copy */ -} - -double_to_i387 (from, to) - char *from; - char *to; -{ - /* push double mode on 387 stack, then pop in extended mode - * no errors are possible because every 64-bit pattern - * can be converted to an extended - */ - asm ("movl 8(%ebp),%eax"); - asm ("fldl (%eax)"); - asm ("fwait"); - asm ("movl 12(%ebp),%eax"); - asm ("fstpt (%eax)"); - asm ("fwait"); -} - -static long -i386_get_frame_setup (pc) -{ - unsigned char op; - - codestream_seek (pc); - - i386_follow_jump (); - - op = codestream_get (); - - if (op == 0x58) /* popl %eax */ - { - /* - * this function must start with - * - * popl %eax 0x58 - * xchgl %eax, (%esp) 0x87 0x04 0x24 - * or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00 - * - * (the system 5 compiler puts out the second xchg - * inst, and the assembler doesn't try to optimize it, - * so the 'sib' form gets generated) - * - * this sequence is used to get the address of the return - * buffer for a function that returns a structure - */ - int pos; - unsigned char buf[4]; - static unsigned char proto1[3] = { 0x87,0x04,0x24 }; - static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 }; - pos = codestream_tell (); - codestream_read (buf, 4); - if (bcmp (buf, proto1, 3) == 0) - pos += 3; - else if (bcmp (buf, proto2, 4) == 0) - pos += 4; - - codestream_seek (pos); - op = codestream_get (); /* update next opcode */ - } - - if (op == 0x55) /* pushl %esp */ - { - if (codestream_get () != 0x8b) /* movl %esp, %ebp (2bytes) */ - return (-1); - if (codestream_get () != 0xec) - return (-1); - /* - * check for stack adjustment - * - * subl $XXX, %esp - * - * note: you can't subtract a 16 bit immediate - * from a 32 bit reg, so we don't have to worry - * about a data16 prefix - */ - op = codestream_peek (); - if (op == 0x83) /* subl with 8 bit immed */ - { - codestream_get (); - if (codestream_get () != 0xec) - return (-1); - /* subl with signed byte immediate - * (though it wouldn't make sense to be negative) - */ - return (codestream_get()); - } - else if (op == 0x81) /* subl with 32 bit immed */ - { - int locals; - if (codestream_get () != 0xec) - return (-1); - /* subl with 32 bit immediate */ - codestream_read ((unsigned char *)&locals, 4); - return (locals); - } - else - { - return (0); - } - } - else if (op == 0xc8) - { - /* enter instruction: arg is 16 unsigned immed */ - unsigned short slocals; - codestream_read ((unsigned char *)&slocals, 2); - codestream_get (); /* flush final byte of enter instruction */ - return (slocals); - } - return (-1); -} - -/* next instruction is a jump, move to target */ -static -i386_follow_jump () -{ - int long_delta; - short short_delta; - char byte_delta; - int data16; - int pos; - - pos = codestream_tell (); - - data16 = 0; - if (codestream_peek () == 0x66) - { - codestream_get (); - data16 = 1; - } - - switch (codestream_get ()) - { - case 0xe9: - /* relative jump: if data16 == 0, disp32, else disp16 */ - if (data16) - { - codestream_read ((unsigned char *)&short_delta, 2); - pos += short_delta + 3; /* include size of jmp inst */ - } - else - { - codestream_read ((unsigned char *)&long_delta, 4); - pos += long_delta + 5; - } - break; - case 0xeb: - /* relative jump, disp8 (ignore data16) */ - codestream_read ((unsigned char *)&byte_delta, 1); - pos += byte_delta + 2; - break; - } - codestream_seek (pos + data16); -} - -/* return pc of first real instruction */ -/* from i386-dep.c */ - -i386_skip_prologue (pc) -{ - unsigned char op; - int i; - - if (i386_get_frame_setup (pc) < 0) - return (pc); - - /* found valid frame setup - codestream now points to - * start of push instructions for saving registers - */ - - /* skip over register saves */ - for (i = 0; i < 8; i++) - { - op = codestream_peek (); - /* break if not pushl inst */ - if (op < 0x50 || op > 0x57) - break; - codestream_get (); - } - - i386_follow_jump (); - - return (codestream_tell ()); -} - -symmetry_extract_return_value(type, regbuf, valbuf) - struct type *type; - char *regbuf; - char *valbuf; -{ - union { - double d; - int l[2]; - } xd; - int i; - float f; - - if (TYPE_CODE_FLT == TYPE_CODE(type)) { - for (i = 0; i < misc_function_count; i++) { - if (!strcmp(misc_function_vector[i].name, "1167_flt")) - break; - } - if (i < misc_function_count) { - /* found "1167_flt" means 1167, %fp2-%fp3 */ - /* float & double; 19= %fp2, 20= %fp3 */ - /* no single precision on 1167 */ - xd.l[1] = *((int *)®buf[REGISTER_BYTE(19)]); - xd.l[0] = *((int *)®buf[REGISTER_BYTE(20)]); - switch (TYPE_LENGTH(type)) { - case 4: - f = (float) xd.d; - bcopy(&f, valbuf, TYPE_LENGTH(type)); - break; - case 8: - bcopy(&xd.d, valbuf, TYPE_LENGTH(type)); - break; - default: - error("Unknown floating point size"); - break; - } - } else { - /* 387 %st(0), gcc uses this */ - i387_to_double(((int *)®buf[REGISTER_BYTE(3)]), - &xd.d); - switch (TYPE_LENGTH(type)) { - case 4: /* float */ - f = (float) xd.d; - bcopy(&f, valbuf, 4); - break; - case 8: /* double */ - bcopy(&xd.d, valbuf, 8); - break; - default: - error("Unknown floating point size"); - break; - } - } - } else { - bcopy (regbuf, valbuf, TYPE_LENGTH (type)); - } -} diff --git a/gnu/usr.bin/gdb/config/tahoe-opcode.h b/gnu/usr.bin/gdb/config/tahoe-opcode.h deleted file mode 100644 index f7768a246143..000000000000 --- a/gnu/usr.bin/gdb/config/tahoe-opcode.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Ported by the State University of New York at Buffalo by the Distributed - * Computer Systems Lab, Department of Computer Science, 1991. - * - * $Id: tahoe-opcode.h,v 1.2 1993/08/02 17:40:24 mycroft Exp $ - */ - -#ifndef tahoe_opcodeT -#define tahoe_opcodeT int -#endif /* no tahoe_opcodeT */ - -struct vot_wot /* tahoe opcode table: wot to do with this */ - /* particular opcode */ -{ - char * args; /* how to compile said opcode */ - tahoe_opcodeT code; /* op-code (may be > 8 bits!) */ -}; - -struct vot /* tahoe opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct vot_wot detail; /* rest of opcode table [datum] */ -}; - -#define vot_how args -#define vot_code code -#define vot_detail detail -#define vot_name name - -static struct vot -votstrs[] = -{ -{ "halt", {"", 0x00 } }, -{ "sinf", {"", 0x05 } }, -{ "ldf", {"rl", 0x06 } }, -{ "ldd", {"rq", 0x07 } }, -{ "addb2", {"rbmb", 0x08 } }, -{ "movb", {"rbwb", 0x09 } }, -{ "addw2", {"rwmw", 0x0a } }, -{ "movw", {"rwww", 0x0b } }, -{ "addl2", {"rlml", 0x0c } }, -{ "movl", {"rlwl", 0x0d } }, -{ "bbs", {"rlvlbw", 0x0e } }, -{ "nop", {"", 0x10 } }, -{ "brb", {"bb", 0x11 } }, -{ "brw", {"bw", 0x13 } }, -{ "cosf", {"", 0x15 } }, -{ "lnf", {"rl", 0x16 } }, -{ "lnd", {"rq", 0x17 } }, -{ "addb3", {"rbrbwb", 0x18 } }, -{ "cmpb", {"rbwb", 0x19 } }, -{ "addw3", {"rwrwww", 0x1a } }, -{ "cmpw", {"rwww", 0x1b } }, -{ "addl3", {"rlrlwl", 0x1c } }, -{ "cmpl", {"rlwl", 0x1d } }, -{ "bbc", {"rlvlbw", 0x1e } }, -{ "rei", {"", 0x20 } }, -{ "bneq", {"bb", 0x21 } }, -{ "bnequ", {"bb", 0x21 } }, -{ "cvtwl", {"rwwl", 0x23 } }, -{ "stf", {"wl", 0x26 } }, -{ "std", {"wq", 0x27 } }, -{ "subb2", {"rbmb", 0x28 } }, -{ "mcomb", {"rbwb", 0x29 } }, -{ "subw2", {"rwmw", 0x2a } }, -{ "mcomw", {"rwww", 0x2b } }, -{ "subl2", {"rlml", 0x2c } }, -{ "mcoml", {"rlwl", 0x2d } }, -{ "emul", {"rlrlrlwq", 0x2e } }, -{ "aoblss", {"rlmlbw", 0x2f } }, -{ "bpt", {"", 0x30 } }, -{ "beql", {"bb", 0x31 } }, -{ "beqlu", {"bb", 0x31 } }, -{ "cvtwb", {"rwwb", 0x33 } }, -{ "logf", {"", 0x35 } }, -{ "cmpf", {"rl", 0x36 } }, -{ "cmpd", {"rq", 0x37 } }, -{ "subb3", {"rbrbwb", 0x38 } }, -{ "bitb", {"rbrb", 0x39 } }, -{ "subw3", {"rwrwww", 0x3a } }, -{ "bitw", {"rwrw", 0x3b } }, -{ "subl3", {"rlrlwl", 0x3c } }, -{ "bitl", {"rlrl", 0x3d } }, -{ "ediv", {"rlrqwlwl", 0x3e } }, -{ "aobleq", {"rlmlbw", 0x3f } }, -{ "ret", {"", 0x40 } }, -{ "bgtr", {"bb", 0x41 } }, -{ "sqrtf", {"", 0x45 } }, -{ "cmpf2", {"rl", 0x46 } }, -{ "cmpd2", {"rqrq", 0x47 } }, -{ "shll", {"rbrlwl", 0x48 } }, -{ "clrb", {"wb", 0x49 } }, -{ "shlq", {"rbrqwq", 0x4a } }, -{ "clrw", {"ww", 0x4b } }, -{ "mull2", {"rlml", 0x4c } }, -{ "clrl", {"wl", 0x4d } }, -{ "shal", {"rbrlwl", 0x4e } }, -{ "bleq", {"bb", 0x51 } }, -{ "expf", {"", 0x55 } }, -{ "tstf", {"", 0x56 } }, -{ "tstd", {"", 0x57 } }, -{ "shrl", {"rbrlwl", 0x58 } }, -{ "tstb", {"rb", 0x59 } }, -{ "shrq", {"rbrqwq", 0x5a } }, -{ "tstw", {"rw", 0x5b } }, -{ "mull3", {"rlrlwl", 0x5c } }, -{ "tstl", {"rl", 0x5d } }, -{ "shar", {"rbrlwl", 0x5e } }, -{ "bbssi", {"rlmlbw", 0x5f } }, -{ "ldpctx", {"", 0x60 } }, -{ "pushd", {"", 0x67 } }, -{ "incb", {"mb", 0x69 } }, -{ "incw", {"mw", 0x6b } }, -{ "divl2", {"rlml", 0x6c } }, -{ "incl", {"ml", 0x6d } }, -{ "cvtlb", {"rlwb", 0x6f } }, -{ "svpctx", {"", 0x70 } }, -{ "jmp", {"ab", 0x71 } }, -{ "cvlf", {"rl", 0x76 } }, -{ "cvld", {"rl", 0x77 } }, -{ "decb", {"mb", 0x79 } }, -{ "decw", {"mw", 0x7b } }, -{ "divl3", {"rlrlwl", 0x7c } }, -{ "decl", {"ml", 0x7d } }, -{ "cvtlw", {"rlww", 0x7f } }, -{ "bgeq", {"bb", 0x81 } }, -{ "movs2", {"abab", 0x82 } }, -{ "cvfl", {"wl", 0x86 } }, -{ "cvdl", {"wl", 0x87 } }, -{ "orb2", {"rbmb", 0x88 } }, -{ "cvtbl", {"rbwl", 0x89 } }, -{ "orw2", {"rwmw", 0x8a } }, -{ "bispsw", {"rw", 0x8b } }, -{ "orl2", {"rlml", 0x8c } }, -{ "adwc", {"rlml", 0x8d } }, -{ "adda", {"rlml", 0x8e } }, -{ "blss", {"bb", 0x91 } }, -{ "cmps2", {"abab", 0x92 } }, -{ "ldfd", {"rl", 0x97 } }, -{ "orb3", {"rbrbwb", 0x98 } }, -{ "cvtbw", {"rbww", 0x99 } }, -{ "orw3", {"rwrwww", 0x9a } }, -{ "bicpsw", {"rw", 0x9b } }, -{ "orl3", {"rlrlwl", 0x9c } }, -{ "sbwc", {"rlml", 0x9d } }, -{ "suba", {"rlml", 0x9e } }, -{ "bgtru", {"bb", 0xa1 } }, -{ "cvdf", {"", 0xa6 } }, -{ "andb2", {"rbmb", 0xa8 } }, -{ "movzbl", {"rbwl", 0xa9 } }, -{ "andw2", {"rwmw", 0xaa } }, -{ "loadr", {"rwal", 0xab } }, -{ "andl2", {"rlml", 0xac } }, -{ "mtpr", {"rlrl", 0xad } }, -{ "ffs", {"rlwl", 0xae } }, -{ "blequ", {"bb", 0xb1 } }, -{ "negf", {"", 0xb6 } }, -{ "negd", {"", 0xb7 } }, -{ "andb3", {"rbrbwb", 0xb8 } }, -{ "movzbw", {"rbww", 0xb9 } }, -{ "andw3", {"rwrwww", 0xba } }, -{ "storer", {"rwal", 0xbb } }, -{ "andl3", {"rlrlwl", 0xbc } }, -{ "mfpr", {"rlwl", 0xbd } }, -{ "ffc", {"rlwl", 0xbe } }, -{ "calls", {"rbab", 0xbf } }, -{ "prober", {"rbabrl", 0xc0 } }, -{ "bvc", {"bb", 0xc1 } }, -{ "movs3", {"ababrw", 0xc2 } }, -{ "movzwl", {"rwwl", 0xc3 } }, -{ "addf", {"rl", 0xc6 } }, -{ "addd", {"rq", 0xc7 } }, -{ "xorb2", {"rbmb", 0xc8 } }, -{ "movob", {"rbwb", 0xc9 } }, -{ "xorw2", {"rwmw", 0xca } }, -{ "movow", {"rwww", 0xcb } }, -{ "xorl2", {"rlml", 0xcc } }, -{ "movpsl", {"wl", 0xcd } }, -{ "kcall", {"rw", 0xcf } }, -{ "probew", {"rbabrl", 0xd0 } }, -{ "bvs", {"bb", 0xd1 } }, -{ "cmps3", {"ababrw", 0xd2 } }, -{ "subf", {"rq", 0xd6 } }, -{ "subd", {"rq", 0xd7 } }, -{ "xorb3", {"rbrbwb", 0xd8 } }, -{ "pushb", {"rb", 0xd9 } }, -{ "xorw3", {"rwrwww", 0xda } }, -{ "pushw", {"rw", 0xdb } }, -{ "xorl3", {"rlrlwl", 0xdc } }, -{ "pushl", {"rl", 0xdd } }, -{ "insque", {"abab", 0xe0 } }, -{ "bcs", {"bb", 0xe1 } }, -{ "bgequ", {"bb", 0xe1 } }, -{ "mulf", {"rq", 0xe6 } }, -{ "muld", {"rq", 0xe7 } }, -{ "mnegb", {"rbwb", 0xe8 } }, -{ "movab", {"abwl", 0xe9 } }, -{ "mnegw", {"rwww", 0xea } }, -{ "movaw", {"awwl", 0xeb } }, -{ "mnegl", {"rlwl", 0xec } }, -{ "moval", {"alwl", 0xed } }, -{ "remque", {"ab", 0xf0 } }, -{ "bcc", {"bb", 0xf1 } }, -{ "blssu", {"bb", 0xf1 } }, -{ "divf", {"rq", 0xf6 } }, -{ "divd", {"rq", 0xf7 } }, -{ "movblk", {"alalrw", 0xf8 } }, -{ "pushab", {"ab", 0xf9 } }, -{ "pushaw", {"aw", 0xfb } }, -{ "casel", {"rlrlrl", 0xfc } }, -{ "pushal", {"al", 0xfd } }, -{ "callf", {"rbab", 0xfe } }, -{ "" , "" } /* empty is end sentinel */ - -}; diff --git a/gnu/usr.bin/gdb/config/tahoe-pinsn.c b/gnu/usr.bin/gdb/config/tahoe-pinsn.c deleted file mode 100644 index 68c27f117af7..000000000000 --- a/gnu/usr.bin/gdb/config/tahoe-pinsn.c +++ /dev/null @@ -1,260 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by the - * Distributed Computer Systems Lab, Department of Computer Science - * at the State University of New York at Buffalo. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)tahoe-pinsn.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: tahoe-pinsn.c,v 1.2 1993/08/01 18:48:20 mycroft Exp $"; -#endif /* not lint */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "tahoe-opcode.h" - -/* Tahoe instructions are never longer than this. */ -#define MAXLEN 62 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof votstrs / sizeof votstrs[0]) - -extern char *reg_names[]; - -static unsigned char *print_insn_arg (); - -/* Print the Tahoe instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register unsigned char *p; - register char *d; - - read_memory (memaddr, buffer, MAXLEN); - - for (i = 0; i < NOPCODES; i++) - if (votstrs[i].detail.code == buffer[0] - || votstrs[i].detail.code == *(unsigned short *)buffer) - break; - - /* Handle undefined instructions. */ - if (i == NOPCODES) - { - fprintf (stream, "0%o", buffer[0]); - return 1; - } - - fprintf (stream, "%s", votstrs[i].name); - - /* Point at first byte of argument data, - and at descriptor for first argument. */ - p = buffer + 1 + (votstrs[i].detail.code >= 0x100); - d = votstrs[i].detail.args; - - if (*d) - fputc ('\t', stream); - - while (*d) - { - p = print_insn_arg (d, p, memaddr + (p - buffer), stream); - d += 2; - if (*d) - fprintf (stream, ","); - } - return p - buffer; -} -/*******************************************************************/ -static unsigned char * -print_insn_arg (d, p, addr, stream) - char *d; - register char *p; - CORE_ADDR addr; - FILE *stream; -{ - int temp1 = 0; - register int regnum = *p & 0xf; - float floatlitbuf; - - if (*d == 'b') - { - if (d[1] == 'b') - fprintf (stream, "0x%x", addr + *p++ + 1); - else - { - - temp1 = *p; - temp1 <<= 8; - temp1 |= *(p + 1); - fprintf (stream, "0x%x", addr + temp1 + 2); - p += 2; - } - } - else - switch ((*p++ >> 4) & 0xf) - { - case 0: - case 1: - case 2: - case 3: /* Liter>al(short immediate byte) mode */ - if (d[1] == 'd' || d[1] == 'f' || d[1] == 'g' || d[1] == 'h') - { - *(int *)&floatlitbuf = 0x4000 + ((p[-1] & 0x3f) << 4); - fprintf (stream, "$%f", floatlitbuf); - } - else - fprintf (stream, "$%d", p[-1] & 0x3f); - break; - - case 4: /* Indexed */ - p = (char *) print_insn_arg (d, p, addr + 1, stream); - fprintf (stream, "[%s]", reg_names[regnum]); - break; - - case 5: /* Register */ - fprintf (stream, reg_names[regnum]); - break; - - case 7: /* Autodecrement */ - fputc ('-', stream); - case 6: /* Register deferred */ - fprintf (stream, "(%s)", reg_names[regnum]); - break; - - case 9: /* Absolute Address & Autoincrement deferred */ - fputc ('*', stream); - if (regnum == PC_REGNUM) - { - temp1 = *p; - temp1 <<= 8; - temp1 |= *(p +1); - - fputc ('$', stream); - print_address (temp1, stream); - p += 4; - break; - } - case 8: /*Immediate & Autoincrement SP */ - if (regnum == 8) /*88 is Immediate Byte Mode*/ - fprintf (stream, "$%d", *p++); - - else if (regnum == 9) /*89 is Immediate Word Mode*/ - { - temp1 = *p; - temp1 <<= 8; - temp1 |= *(p +1); - fprintf (stream, "$%d", temp1); - p += 2; - } - - else if (regnum == PC_REGNUM) /*8F is Immediate Long Mode*/ - { - temp1 = *p; - temp1 <<=8; - temp1 |= *(p +1); - temp1 <<=8; - temp1 |= *(p +2); - temp1 <<= 8; - temp1 |= *(p +3); - fprintf (stream, "$%d", temp1); - p += 4; - } - - else /*8E is Autoincrement SP Mode*/ - fprintf (stream, "(%s)+", reg_names[regnum]); - break; - - case 11: /* Register + Byte Displacement Deferred Mode*/ - fputc ('*', stream); - case 10: /* Register + Byte Displacement Mode*/ - if (regnum == PC_REGNUM) - print_address (addr + *p + 2, stream); - else - fprintf (stream, "%d(%s)", *p, reg_names[regnum]); - p += 1; - break; - - case 13: /* Register + Word Displacement Deferred Mode*/ - fputc ('*', stream); - case 12: /* Register + Word Displacement Mode*/ - temp1 = *p; - temp1 <<= 8; - temp1 |= *(p +1); - if (regnum == PC_REGNUM) - print_address (addr + temp1 + 3, stream); - else - fprintf (stream, "%d(%s)", temp1, reg_names[regnum]); - p += 2; - break; - - case 15: /* Register + Long Displacement Deferred Mode*/ - fputc ('*', stream); - case 14: /* Register + Long Displacement Mode*/ - temp1 = *p; - temp1 <<= 8; - temp1 |= *(p +1); - temp1 <<= 8; - temp1 |= *(p +2); - temp1 <<= 8; - temp1 |= *(p +3); - if (regnum == PC_REGNUM) - print_address (addr + temp1 + 5, stream); - else - fprintf (stream, "%d(%s)", temp1, reg_names[regnum]); - p += 4; - } - - return (unsigned char *) p; -} - - - - - - - - - - - - - diff --git a/gnu/usr.bin/gdb/config/umax-dep.c b/gnu/usr.bin/gdb/config/umax-dep.c deleted file mode 100644 index b8d59522d6d9..000000000000 --- a/gnu/usr.bin/gdb/config/umax-dep.c +++ /dev/null @@ -1,592 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: umax-dep.c,v 1.2 1993/08/02 17:40:25 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#include -#include -#include -#include -#include - -#include -#include -#define PTRACE_ATTACH PT_ATTACH -#define PTRACE_DETACH PT_FREEPROC - -#include -#include - -extern int errno; -extern int attach_flag; - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, arg3, arg4) - int request, pid, arg3, arg4; -{ - return ptrace (request, pid, arg3, arg4); -} - -kill_inferior () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - inferior_died (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (remote_debugging) - return; - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (remote_debugging) - remote_resume (step, signal); - else - { - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - } -} - -#ifdef ATTACH_DETACH - -/* Start debugging the process whose number is PID. */ - -attach (pid) - int pid; -{ - errno = 0; - ptrace (PTRACE_ATTACH, pid, 0, 0); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 1; - return pid; -} - -/* Stop debugging the process whose number is PID - and continue it with signal number SIGNAL. - SIGNAL = 0 means just continue it. */ - -void -detach (signal) - int signal; -{ - errno = 0; - ptrace (PTRACE_DETACH, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 0; -} -#endif /* ATTACH_DETACH */ - -void -fetch_inferior_registers () -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - unsigned int offset = 0; - - for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - unsigned int offset = 0; - - if (regno >= 0) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - else for (regno = 0; regno < NUM_REGS; regno++) - { - regaddr = register_addr (regno, offset); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } -} - -/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory - in the NEW_SUN_PTRACE case. - It ought to be straightforward. But it appears that writing did - not write the data that I specified. I cannot understand where - it got the data that it actually did write. */ - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - buffer[i] = remote_fetch_word (addr); - else - buffer[i] = ptrace (1, inferior_pid, addr, 0); - if (errno) - return errno; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (remote_debugging) - buffer[0] = remote_fetch_word (addr); - else - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - if (remote_debugging) - buffer[count - 1] - = remote_fetch_word (addr + (count - 1) * sizeof (int)); - else - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - if (remote_debugging) - remote_store_word (addr, buffer[i]); - else - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -/* Recognize COFF format systems because a.out.h defines AOUTHDR. */ -#ifdef AOUTHDR -#define COFF_FORMAT -#endif - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -/* Make COFF and non-COFF names for things a little more compatible - to reduce conditionals later. */ - -#ifdef COFF_FORMAT -#define a_magic magic -#endif - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern char *sys_siglist[]; - - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -extern char *corefile; -extern char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -extern int corechan; -extern int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -extern int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -extern CORE_ADDR data_start; -extern CORE_ADDR data_end; -extern CORE_ADDR stack_start; -extern CORE_ADDR stack_end; - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -extern CORE_ADDR text_start; -extern CORE_ADDR text_end; - -extern CORE_ADDR exec_data_start; -extern CORE_ADDR exec_data_end; - -/* Address in executable file of start of text area data. */ - -extern int text_offset; - -/* Address in executable file of start of data area data. */ - -extern int exec_data_offset; - -/* Address in core file of start of data area data. */ - -extern int data_offset; - -/* Address in core file of start of stack area data. */ - -extern int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -extern FILHDR file_hdr; -extern SCNHDR text_hdr; -extern SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -extern AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -extern AOUTHDR exec_aouthdr; - -extern void validate_files (); - -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct ptrace_user u; - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + u.pt_dsize; - stack_start = stack_end - u.pt_ssize; - data_offset = sizeof u; - stack_offset = data_offset + u.pt_dsize; - reg_offset = 0; - - bcopy (&u.pt_aouthdr, &core_aouthdr, sizeof (AOUTHDR)); - printf ("Core file is from \"%s\".\n", u.pt_comm); - if (u.pt_signal > 0) - printf ("Program terminated with signal %d, %s.\n", - u.pt_signal, - u.pt_signal < NSIG - ? sys_siglist[u.pt_signal] - : "(undocumented)"); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_TXTADDR (exec_aouthdr); - exec_data_start = N_DATADDR (exec_aouthdr); - - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - - text_end = text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} diff --git a/gnu/usr.bin/gdb/config/vax-opcode.h b/gnu/usr.bin/gdb/config/vax-opcode.h deleted file mode 100644 index bc1db38f7201..000000000000 --- a/gnu/usr.bin/gdb/config/vax-opcode.h +++ /dev/null @@ -1,385 +0,0 @@ -/* Vax opcde list. - Copyright (C) 1989, Free Software Foundation, Inc. - -This file is part of GDB and GAS. - -GDB and GAS are 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. - -GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: vax-opcode.h,v 1.2 1993/08/02 17:40:26 mycroft Exp $ -*/ - -#ifndef vax_opcodeT -#define vax_opcodeT int -#endif /* no vax_opcodeT */ - -struct vot_wot /* vax opcode table: wot to do with this */ - /* particular opcode */ -{ - char * args; /* how to compile said opcode */ - vax_opcodeT code; /* op-code (may be > 8 bits!) */ -}; - -struct vot /* vax opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct vot_wot detail; /* rest of opcode table [datum] */ -}; - -#define vot_how args -#define vot_code code -#define vot_detail detail -#define vot_name name - -static struct vot -votstrs[] = -{ -{ "halt", {"", 0x00 } }, -{ "nop", {"", 0x01 } }, -{ "rei", {"", 0x02 } }, -{ "bpt", {"", 0x03 } }, -{ "ret", {"", 0x04 } }, -{ "rsb", {"", 0x05 } }, -{ "ldpctx", {"", 0x06 } }, -{ "svpctx", {"", 0x07 } }, -{ "cvtps", {"rwabrwab", 0x08 } }, -{ "cvtsp", {"rwabrwab", 0x09 } }, -{ "index", {"rlrlrlrlrlwl", 0x0a } }, -{ "crc", {"abrlrwab", 0x0b } }, -{ "prober", {"rbrwab", 0x0c } }, -{ "probew", {"rbrwab", 0x0d } }, -{ "insque", {"abab", 0x0e } }, -{ "remque", {"abwl", 0x0f } }, -{ "bsbb", {"bb", 0x10 } }, -{ "brb", {"bb", 0x11 } }, -{ "bneq", {"bb", 0x12 } }, -{ "bnequ", {"bb", 0x12 } }, -{ "beql", {"bb", 0x13 } }, -{ "beqlu", {"bb", 0x13 } }, -{ "bgtr", {"bb", 0x14 } }, -{ "bleq", {"bb", 0x15 } }, -{ "jsb", {"ab", 0x16 } }, -{ "jmp", {"ab", 0x17 } }, -{ "bgeq", {"bb", 0x18 } }, -{ "blss", {"bb", 0x19 } }, -{ "bgtru", {"bb", 0x1a } }, -{ "blequ", {"bb", 0x1b } }, -{ "bvc", {"bb", 0x1c } }, -{ "bvs", {"bb", 0x1d } }, -{ "bcc", {"bb", 0x1e } }, -{ "bgequ", {"bb", 0x1e } }, -{ "blssu", {"bb", 0x1f } }, -{ "bcs", {"bb", 0x1f } }, -{ "addp4", {"rwabrwab", 0x20 } }, -{ "addp6", {"rwabrwabrwab", 0x21 } }, -{ "subp4", {"rwabrwab", 0x22 } }, -{ "subp6", {"rwabrwabrwab", 0x23 } }, -{ "cvtpt", {"rwababrwab", 0x24 } }, -{ "mulp", {"rwabrwabrwab", 0x25 } }, -{ "cvttp", {"rwababrwab", 0x26 } }, -{ "divp", {"rwabrwabrwab", 0x27 } }, -{ "movc3", {"rwabab", 0x28 } }, -{ "cmpc3", {"rwabab", 0x29 } }, -{ "scanc", {"rwababrb", 0x2a } }, -{ "spanc", {"rwababrb", 0x2b } }, -{ "movc5", {"rwabrbrwab", 0x2c } }, -{ "cmpc5", {"rwabrbrwab", 0x2d } }, -{ "movtc", {"rwabrbabrwab", 0x2e } }, -{ "movtuc", {"rwabrbabrwab", 0x2f } }, -{ "bsbw", {"bw", 0x30 } }, -{ "brw", {"bw", 0x31 } }, -{ "cvtwl", {"rwwl", 0x32 } }, -{ "cvtwb", {"rwwb", 0x33 } }, -{ "movp", {"rwabab", 0x34 } }, -{ "cmpp3", {"rwabab", 0x35 } }, -{ "cvtpl", {"rwabwl", 0x36 } }, -{ "cmpp4", {"rwabrwab", 0x37 } }, -{ "editpc", {"rwababab", 0x38 } }, -{ "matchc", {"rwabrwab", 0x39 } }, -{ "locc", {"rbrwab", 0x3a } }, -{ "skpc", {"rbrwab", 0x3b } }, -{ "movzwl", {"rwwl", 0x3c } }, -{ "acbw", {"rwrwmwbw", 0x3d } }, -{ "movaw", {"awwl", 0x3e } }, -{ "pushaw", {"aw", 0x3f } }, -{ "addf2", {"rfmf", 0x40 } }, -{ "addf3", {"rfrfwf", 0x41 } }, -{ "subf2", {"rfmf", 0x42 } }, -{ "subf3", {"rfrfwf", 0x43 } }, -{ "mulf2", {"rfmf", 0x44 } }, -{ "mulf3", {"rfrfwf", 0x45 } }, -{ "divf2", {"rfmf", 0x46 } }, -{ "divf3", {"rfrfwf", 0x47 } }, -{ "cvtfb", {"rfwb", 0x48 } }, -{ "cvtfw", {"rfww", 0x49 } }, -{ "cvtfl", {"rfwl", 0x4a } }, -{ "cvtrfl", {"rfwl", 0x4b } }, -{ "cvtbf", {"rbwf", 0x4c } }, -{ "cvtwf", {"rwwf", 0x4d } }, -{ "cvtlf", {"rlwf", 0x4e } }, -{ "acbf", {"rfrfmfbw", 0x4f } }, -{ "movf", {"rfwf", 0x50 } }, -{ "cmpf", {"rfrf", 0x51 } }, -{ "mnegf", {"rfwf", 0x52 } }, -{ "tstf", {"rf", 0x53 } }, -{ "emodf", {"rfrbrfwlwf", 0x54 } }, -{ "polyf", {"rfrwab", 0x55 } }, -{ "cvtfd", {"rfwd", 0x56 } }, - /* opcode 57 is not defined yet */ -{ "adawi", {"rwmw", 0x58 } }, - /* opcode 59 is not defined yet */ - /* opcode 5a is not defined yet */ - /* opcode 5b is not defined yet */ -{ "insqhi", {"abaq", 0x5c } }, -{ "insqti", {"abaq", 0x5d } }, -{ "remqhi", {"aqwl", 0x5e } }, -{ "remqti", {"aqwl", 0x5f } }, -{ "addd2", {"rdmd", 0x60 } }, -{ "addd3", {"rdrdwd", 0x61 } }, -{ "subd2", {"rdmd", 0x62 } }, -{ "subd3", {"rdrdwd", 0x63 } }, -{ "muld2", {"rdmd", 0x64 } }, -{ "muld3", {"rdrdwd", 0x65 } }, -{ "divd2", {"rdmd", 0x66 } }, -{ "divd3", {"rdrdwd", 0x67 } }, -{ "cvtdb", {"rdwb", 0x68 } }, -{ "cvtdw", {"rdww", 0x69 } }, -{ "cvtdl", {"rdwl", 0x6a } }, -{ "cvtrdl", {"rdwl", 0x6b } }, -{ "cvtbd", {"rbwd", 0x6c } }, -{ "cvtwd", {"rwwd", 0x6d } }, -{ "cvtld", {"rlwd", 0x6e } }, -{ "acbd", {"rdrdmdbw", 0x6f } }, -{ "movd", {"rdwd", 0x70 } }, -{ "cmpd", {"rdrd", 0x71 } }, -{ "mnegd", {"rdwd", 0x72 } }, -{ "tstd", {"rd", 0x73 } }, -{ "emodd", {"rdrbrdwlwd", 0x74 } }, -{ "polyd", {"rdrwab", 0x75 } }, -{ "cvtdf", {"rdwf", 0x76 } }, - /* opcode 77 is not defined yet */ -{ "ashl", {"rbrlwl", 0x78 } }, -{ "ashq", {"rbrqwq", 0x79 } }, -{ "emul", {"rlrlrlwq", 0x7a } }, -{ "ediv", {"rlrqwlwl", 0x7b } }, -{ "clrd", {"wd", 0x7c } }, -{ "clrg", {"wg", 0x7c } }, -{ "clrq", {"wd", 0x7c } }, -{ "movq", {"rqwq", 0x7d } }, -{ "movaq", {"aqwl", 0x7e } }, -{ "movad", {"adwl", 0x7e } }, -{ "pushaq", {"aq", 0x7f } }, -{ "pushad", {"ad", 0x7f } }, -{ "addb2", {"rbmb", 0x80 } }, -{ "addb3", {"rbrbwb", 0x81 } }, -{ "subb2", {"rbmb", 0x82 } }, -{ "subb3", {"rbrbwb", 0x83 } }, -{ "mulb2", {"rbmb", 0x84 } }, -{ "mulb3", {"rbrbwb", 0x85 } }, -{ "divb2", {"rbmb", 0x86 } }, -{ "divb3", {"rbrbwb", 0x87 } }, -{ "bisb2", {"rbmb", 0x88 } }, -{ "bisb3", {"rbrbwb", 0x89 } }, -{ "bicb2", {"rbmb", 0x8a } }, -{ "bicb3", {"rbrbwb", 0x8b } }, -{ "xorb2", {"rbmb", 0x8c } }, -{ "xorb3", {"rbrbwb", 0x8d } }, -{ "mnegb", {"rbwb", 0x8e } }, -{ "caseb", {"rbrbrb", 0x8f } }, -{ "movb", {"rbwb", 0x90 } }, -{ "cmpb", {"rbrb", 0x91 } }, -{ "mcomb", {"rbwb", 0x92 } }, -{ "bitb", {"rbrb", 0x93 } }, -{ "clrb", {"wb", 0x94 } }, -{ "tstb", {"rb", 0x95 } }, -{ "incb", {"mb", 0x96 } }, -{ "decb", {"mb", 0x97 } }, -{ "cvtbl", {"rbwl", 0x98 } }, -{ "cvtbw", {"rbww", 0x99 } }, -{ "movzbl", {"rbwl", 0x9a } }, -{ "movzbw", {"rbww", 0x9b } }, -{ "rotl", {"rbrlwl", 0x9c } }, -{ "acbb", {"rbrbmbbw", 0x9d } }, -{ "movab", {"abwl", 0x9e } }, -{ "pushab", {"ab", 0x9f } }, -{ "addw2", {"rwmw", 0xa0 } }, -{ "addw3", {"rwrwww", 0xa1 } }, -{ "subw2", {"rwmw", 0xa2 } }, -{ "subw3", {"rwrwww", 0xa3 } }, -{ "mulw2", {"rwmw", 0xa4 } }, -{ "mulw3", {"rwrwww", 0xa5 } }, -{ "divw2", {"rwmw", 0xa6 } }, -{ "divw3", {"rwrwww", 0xa7 } }, -{ "bisw2", {"rwmw", 0xa8 } }, -{ "bisw3", {"rwrwww", 0xa9 } }, -{ "bicw2", {"rwmw", 0xaa } }, -{ "bicw3", {"rwrwww", 0xab } }, -{ "xorw2", {"rwmw", 0xac } }, -{ "xorw3", {"rwrwww", 0xad } }, -{ "mnegw", {"rwww", 0xae } }, -{ "casew", {"rwrwrw", 0xaf } }, -{ "movw", {"rwww", 0xb0 } }, -{ "cmpw", {"rwrw", 0xb1 } }, -{ "mcomw", {"rwww", 0xb2 } }, -{ "bitw", {"rwrw", 0xb3 } }, -{ "clrw", {"ww", 0xb4 } }, -{ "tstw", {"rw", 0xb5 } }, -{ "incw", {"mw", 0xb6 } }, -{ "decw", {"mw", 0xb7 } }, -{ "bispsw", {"rw", 0xb8 } }, -{ "bicpsw", {"rw", 0xb9 } }, -{ "popr", {"rw", 0xba } }, -{ "pushr", {"rw", 0xbb } }, -{ "chmk", {"rw", 0xbc } }, -{ "chme", {"rw", 0xbd } }, -{ "chms", {"rw", 0xbe } }, -{ "chmu", {"rw", 0xbf } }, -{ "addl2", {"rlml", 0xc0 } }, -{ "addl3", {"rlrlwl", 0xc1 } }, -{ "subl2", {"rlml", 0xc2 } }, -{ "subl3", {"rlrlwl", 0xc3 } }, -{ "mull2", {"rlml", 0xc4 } }, -{ "mull3", {"rlrlwl", 0xc5 } }, -{ "divl2", {"rlml", 0xc6 } }, -{ "divl3", {"rlrlwl", 0xc7 } }, -{ "bisl2", {"rlml", 0xc8 } }, -{ "bisl3", {"rlrlwl", 0xc9 } }, -{ "bicl2", {"rlml", 0xca } }, -{ "bicl3", {"rlrlwl", 0xcb } }, -{ "xorl2", {"rlml", 0xcc } }, -{ "xorl3", {"rlrlwl", 0xcd } }, -{ "mnegl", {"rlwl", 0xce } }, -{ "casel", {"rlrlrl", 0xcf } }, -{ "movl", {"rlwl", 0xd0 } }, -{ "cmpl", {"rlrl", 0xd1 } }, -{ "mcoml", {"rlwl", 0xd2 } }, -{ "bitl", {"rlrl", 0xd3 } }, -{ "clrf", {"wf", 0xd4 } }, -{ "clrl", {"wl", 0xd4 } }, -{ "tstl", {"rl", 0xd5 } }, -{ "incl", {"ml", 0xd6 } }, -{ "decl", {"ml", 0xd7 } }, -{ "adwc", {"rlml", 0xd8 } }, -{ "sbwc", {"rlml", 0xd9 } }, -{ "mtpr", {"rlrl", 0xda } }, -{ "mfpr", {"rlwl", 0xdb } }, -{ "movpsl", {"wl", 0xdc } }, -{ "pushl", {"rl", 0xdd } }, -{ "moval", {"alwl", 0xde } }, -{ "movaf", {"afwl", 0xde } }, -{ "pushal", {"al", 0xdf } }, -{ "pushaf", {"af", 0xdf } }, -{ "bbs", {"rlabbb", 0xe0 } }, -{ "bbc", {"rlabbb", 0xe1 } }, -{ "bbss", {"rlabbb", 0xe2 } }, -{ "bbcs", {"rlabbb", 0xe3 } }, -{ "bbsc", {"rlabbb", 0xe4 } }, -{ "bbcc", {"rlabbb", 0xe5 } }, -{ "bbssi", {"rlabbb", 0xe6 } }, -{ "bbcci", {"rlabbb", 0xe7 } }, -{ "blbs", {"rlbb", 0xe8 } }, -{ "blbc", {"rlbb", 0xe9 } }, -{ "ffs", {"rlrbvbwl", 0xea } }, -{ "ffc", {"rlrbvbwl", 0xeb } }, -{ "cmpv", {"rlrbvbrl", 0xec } }, -{ "cmpzv", {"rlrbvbrl", 0xed } }, -{ "extv", {"rlrbvbwl", 0xee } }, -{ "extzv", {"rlrbvbwl", 0xef } }, -{ "insv", {"rlrlrbvb", 0xf0 } }, -{ "acbl", {"rlrlmlbw", 0xf1 } }, -{ "aoblss", {"rlmlbb", 0xf2 } }, -{ "aobleq", {"rlmlbb", 0xf3 } }, -{ "sobgeq", {"mlbb", 0xf4 } }, -{ "sobgtr", {"mlbb", 0xf5 } }, -{ "cvtlb", {"rlwb", 0xf6 } }, -{ "cvtlw", {"rlww", 0xf7 } }, -{ "ashp", {"rbrwabrbrwab", 0xf8 } }, -{ "cvtlp", {"rlrwab", 0xf9 } }, -{ "callg", {"abab", 0xfa } }, -{ "calls", {"rlab", 0xfb } }, -{ "xfc", {"", 0xfc } }, - /* undefined opcodes here */ -{ "cvtdh", {"rdwh", 0x32fd } }, -{ "cvtgf", {"rgwh", 0x33fd } }, -{ "addg2", {"rgmg", 0x40fd } }, -{ "addg3", {"rgrgwg", 0x41fd } }, -{ "subg2", {"rgmg", 0x42fd } }, -{ "subg3", {"rgrgwg", 0x43fd } }, -{ "mulg2", {"rgmg", 0x44fd } }, -{ "mulg3", {"rgrgwg", 0x45fd } }, -{ "divg2", {"rgmg", 0x46fd } }, -{ "divg3", {"rgrgwg", 0x47fd } }, -{ "cvtgb", {"rgwb", 0x48fd } }, -{ "cvtgw", {"rgww", 0x49fd } }, -{ "cvtgl", {"rgwl", 0x4afd } }, -{ "cvtrgl", {"rgwl", 0x4bfd } }, -{ "cvtbg", {"rbwg", 0x4cfd } }, -{ "cvtwg", {"rwwg", 0x4dfd } }, -{ "cvtlg", {"rlwg", 0x4efd } }, -{ "acbg", {"rgrgmgbw", 0x4ffd } }, -{ "movg", {"rgwg", 0x50fd } }, -{ "cmpg", {"rgrg", 0x51fd } }, -{ "mnegg", {"rgwg", 0x52fd } }, -{ "tstg", {"rg", 0x53fd } }, -{ "emodg", {"rgrwrgwlwg", 0x54fd } }, -{ "polyg", {"rgrwab", 0x55fd } }, -{ "cvtgh", {"rgwh", 0x56fd } }, - /* undefined opcodes here */ -{ "addh2", {"rhmh", 0x60fd } }, -{ "addh3", {"rhrhwh", 0x61fd } }, -{ "subh2", {"rhmh", 0x62fd } }, -{ "subh3", {"rhrhwh", 0x63fd } }, -{ "mulh2", {"rhmh", 0x64fd } }, -{ "mulh3", {"rhrhwh", 0x65fd } }, -{ "divh2", {"rhmh", 0x66fd } }, -{ "divh3", {"rhrhwh", 0x67fd } }, -{ "cvthb", {"rhwb", 0x68fd } }, -{ "cvthw", {"rhww", 0x69fd } }, -{ "cvthl", {"rhwl", 0x6afd } }, -{ "cvtrhl", {"rhwl", 0x6bfd } }, -{ "cvtbh", {"rbwh", 0x6cfd } }, -{ "cvtwh", {"rwwh", 0x6dfd } }, -{ "cvtlh", {"rlwh", 0x6efd } }, -{ "acbh", {"rhrhmhbw", 0x6ffd } }, -{ "movh", {"rhwh", 0x70fd } }, -{ "cmph", {"rhrh", 0x71fd } }, -{ "mnegh", {"rhwh", 0x72fd } }, -{ "tsth", {"rh", 0x73fd } }, -{ "emodh", {"rhrwrhwlwh", 0x74fd } }, -{ "polyh", {"rhrwab", 0x75fd } }, -{ "cvthg", {"rhwg", 0x76fd } }, - /* undefined opcodes here */ -{ "clrh", {"wh", 0x7cfd } }, -{ "clro", {"wo", 0x7cfd } }, -{ "movo", {"rowo", 0x7dfd } }, -{ "movah", {"ahwl", 0x7efd } }, -{ "movao", {"aowl", 0x7efd } }, -{ "pushah", {"ah", 0x7ffd } }, -{ "pushao", {"ao", 0x7ffd } }, - /* undefined opcodes here */ -{ "cvtfh", {"rfwh", 0x98fd } }, -{ "cvtfg", {"rfwg", 0x99fd } }, - /* undefined opcodes here */ -{ "cvthf", {"rhwf", 0xf6fd } }, -{ "cvthd", {"rhwd", 0xf7fd } }, - /* undefined opcodes here */ -{ "bugl", {"rl", 0xfdff } }, -{ "bugw", {"rw", 0xfeff } }, - /* undefined opcodes here */ - -{ "" , "" } /* empty is end sentinel */ - -}; /* votstrs */ - -/* end: vax.opcode.h */ diff --git a/gnu/usr.bin/gdb/config/vax-pinsn.c b/gnu/usr.bin/gdb/config/vax-pinsn.c deleted file mode 100644 index 049c7ca58ebe..000000000000 --- a/gnu/usr.bin/gdb/config/vax-pinsn.c +++ /dev/null @@ -1,252 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)vax-pinsn.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: vax-pinsn.c,v 1.2 1993/08/01 18:48:19 mycroft Exp $"; -#endif /* not lint */ - -/* Print vax instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "vax-opcode.h" - -/* Vax instructions are never longer than this. */ -#define MAXLEN 62 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof votstrs / sizeof votstrs[0]) - -extern char *reg_names[]; - -static unsigned char *print_insn_arg (); - -/* Print the vax instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register unsigned char *p; - register char *d; - - read_memory (memaddr, buffer, MAXLEN); - - for (i = 0; i < NOPCODES; i++) - if (votstrs[i].detail.code == buffer[0] - || votstrs[i].detail.code == *(unsigned short *)buffer) - break; - - /* Handle undefined instructions. */ - if (i == NOPCODES) - { - fprintf (stream, "0%o", buffer[0]); - return 1; - } - - fprintf (stream, "%s", votstrs[i].name); - - /* Point at first byte of argument data, - and at descriptor for first argument. */ - p = buffer + 1 + (votstrs[i].detail.code >= 0x100); - d = votstrs[i].detail.args; - - if (*d) - fputc (' ', stream); - - while (*d) - { - p = print_insn_arg (d, p, memaddr + (p - buffer), stream); - d += 2; - if (*d) - fprintf (stream, ","); - } - return p - buffer; -} - -static unsigned char * -print_insn_arg (d, p, addr, stream) - char *d; - register char *p; - CORE_ADDR addr; - FILE *stream; -{ - register int regnum = *p & 0xf; - float floatlitbuf; - - if (*d == 'b') - { - if (d[1] == 'b') - fprintf (stream, "0x%x", addr + *p++ + 1); - else - { - fprintf (stream, "0x%x", addr + *(short *)p + 2); - p += 2; - } - } - else - switch ((*p++ >> 4) & 0xf) - { - case 0: - case 1: - case 2: - case 3: /* Literal mode */ - if (d[1] == 'd' || d[1] == 'f' || d[1] == 'g' || d[1] == 'h') - { - *(int *)&floatlitbuf = 0x4000 + ((p[-1] & 0x3f) << 4); - fprintf (stream, "$%f", floatlitbuf); - } - else - fprintf (stream, "$%d", p[-1] & 0x3f); - break; - - case 4: /* Indexed */ - p = (char *) print_insn_arg (d, p, addr + 1, stream); - fprintf (stream, "[%s]", reg_names[regnum]); - break; - - case 5: /* Register */ - fprintf (stream, reg_names[regnum]); - break; - - case 7: /* Autodecrement */ - fputc ('-', stream); - case 6: /* Register deferred */ - fprintf (stream, "(%s)", reg_names[regnum]); - break; - - case 9: /* Autoincrement deferred */ - fputc ('@', stream); - if (regnum == PC_REGNUM) - { - fputc ('#', stream); - print_address (*(long *)p, stream); - p += 4; - break; - } - case 8: /* Autoincrement */ - if (regnum == PC_REGNUM) - { - fputc ('#', stream); - switch (d[1]) - { - case 'b': - fprintf (stream, "%d", *p++); - break; - - case 'w': - fprintf (stream, "%d", *(short *)p); - p += 2; - break; - - case 'l': - fprintf (stream, "%d", *(long *)p); - p += 4; - break; - - case 'q': - fprintf (stream, "0x%x%08x", ((long *)p)[1], ((long *)p)[0]); - p += 8; - break; - - case 'o': - fprintf (stream, "0x%x%08x%08x%08x", - ((long *)p)[3], ((long *)p)[2], - ((long *)p)[1], ((long *)p)[0]); - p += 16; - break; - - case 'f': - if (INVALID_FLOAT (p, 4)) - fprintf (stream, "<>", *(int *) p); - else - fprintf (stream, "%f", *(float *) p); - p += 4; - break; - - case 'd': - if (INVALID_FLOAT (p, 8)) - fprintf (stream, "<>", - ((long *)p)[1], ((long *)p)[0]); - else - fprintf (stream, "%f", *(double *) p); - p += 8; - break; - - case 'g': - fprintf (stream, "g-float"); - p += 8; - break; - - case 'h': - fprintf (stream, "h-float"); - p += 16; - break; - - } - } - else - fprintf (stream, "(%s)+", reg_names[regnum]); - break; - - case 11: /* Byte displacement deferred */ - fputc ('@', stream); - case 10: /* Byte displacement */ - if (regnum == PC_REGNUM) - print_address (addr + *p + 2, stream); - else - fprintf (stream, "%d(%s)", *p, reg_names[regnum]); - p += 1; - break; - - case 13: /* Word displacement deferred */ - fputc ('@', stream); - case 12: /* Word displacement */ - if (regnum == PC_REGNUM) - print_address (addr + *(short *)p + 3, stream); - else - fprintf (stream, "%d(%s)", *(short *)p, reg_names[regnum]); - p += 2; - break; - - case 15: /* Long displacement deferred */ - fputc ('@', stream); - case 14: /* Long displacement */ - if (regnum == PC_REGNUM) - print_address (addr + *(long *)p + 5, stream); - else - fprintf (stream, "%d(%s)", *(long *)p, reg_names[regnum]); - p += 4; - } - - return (unsigned char *) p; -} diff --git a/gnu/usr.bin/gdb/copying.c b/gnu/usr.bin/gdb/copying.c deleted file mode 100644 index 0ae4bb686c0f..000000000000 --- a/gnu/usr.bin/gdb/copying.c +++ /dev/null @@ -1,216 +0,0 @@ -/* $Id: copying.c,v 1.2 1993/08/02 17:40:54 mycroft Exp $ */ -/* Do not modify this file; it is created automatically - by copying.awk. */ -extern int immediate_quit; -static void -copying_info () -{ - immediate_quit++; - printf_filtered ("\n"); - printf_filtered (" GNU GENERAL PUBLIC LICENSE\n"); - printf_filtered (" Version 1, February 1989\n"); - printf_filtered ("\n"); - printf_filtered (" Copyright (C) 1989 Free Software Foundation, Inc.\n"); - printf_filtered (" 675 Mass Ave, Cambridge, MA 02139, USA\n"); - printf_filtered (" Everyone is permitted to copy and distribute verbatim copies\n"); - printf_filtered (" of this license document, but changing it is not allowed.\n"); - printf_filtered ("\n"); - printf_filtered (" Preamble\n"); - printf_filtered ("\n"); - printf_filtered (" The license agreements of most software companies try to keep users\n"); - printf_filtered ("at the mercy of those companies. By contrast, our General Public\n"); - printf_filtered ("License is intended to guarantee your freedom to share and change free\n"); - printf_filtered ("software--to make sure the software is free for all its users. The\n"); - printf_filtered ("General Public License applies to the Free Software Foundation's\n"); - printf_filtered ("software and to any other program whose authors commit to using it.\n"); - printf_filtered ("You can use it for your programs, too.\n"); - printf_filtered ("\n"); - printf_filtered (" When we speak of free software, we are referring to freedom, not\n"); - printf_filtered ("price. Specifically, the General Public License is designed to make\n"); - printf_filtered ("sure that you have the freedom to give away or sell copies of free\n"); - printf_filtered ("software, that you receive source code or can get it if you want it,\n"); - printf_filtered ("that you can change the software or use pieces of it in new free\n"); - printf_filtered ("programs; and that you know you can do these things.\n"); - printf_filtered ("\n"); - printf_filtered (" To protect your rights, we need to make restrictions that forbid\n"); - printf_filtered ("anyone to deny you these rights or to ask you to surrender the rights.\n"); - printf_filtered ("These restrictions translate to certain responsibilities for you if you\n"); - printf_filtered ("distribute copies of the software, or if you modify it.\n"); - printf_filtered ("\n"); - printf_filtered (" For example, if you distribute copies of a such a program, whether\n"); - printf_filtered ("gratis or for a fee, you must give the recipients all the rights that\n"); - printf_filtered ("you have. You must make sure that they, too, receive or can get the\n"); - printf_filtered ("source code. And you must tell them their rights.\n"); - printf_filtered ("\n"); - printf_filtered (" We protect your rights with two steps: (1) copyright the software, and\n"); - printf_filtered ("(2) offer you this license which gives you legal permission to copy,\n"); - printf_filtered ("distribute and/or modify the software.\n"); - printf_filtered ("\n"); - printf_filtered (" Also, for each author's protection and ours, we want to make certain\n"); - printf_filtered ("that everyone understands that there is no warranty for this free\n"); - printf_filtered ("software. If the software is modified by someone else and passed on, we\n"); - printf_filtered ("want its recipients to know that what they have is not the original, so\n"); - printf_filtered ("that any problems introduced by others will not reflect on the original\n"); - printf_filtered ("authors' reputations.\n"); - printf_filtered ("\n"); - printf_filtered (" The precise terms and conditions for copying, distribution and\n"); - printf_filtered ("modification follow.\n"); - printf_filtered (" \n"); - printf_filtered (" GNU GENERAL PUBLIC LICENSE\n"); - printf_filtered (" TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"); - printf_filtered ("\n"); - printf_filtered (" 0. This License Agreement applies to any program or other work which\n"); - printf_filtered ("contains a notice placed by the copyright holder saying it may be\n"); - printf_filtered ("distributed under the terms of this General Public License. The\n"); - printf_filtered ("\"Program\", below, refers to any such program or work, and a \"work based\n"); - printf_filtered ("on the Program\" means either the Program or any work containing the\n"); - printf_filtered ("Program or a portion of it, either verbatim or with modifications. Each\n"); - printf_filtered ("licensee is addressed as \"you\".\n"); - printf_filtered ("\n"); - printf_filtered (" 1. You may copy and distribute verbatim copies of the Program's source\n"); - printf_filtered ("code as you receive it, in any medium, provided that you conspicuously and\n"); - printf_filtered ("appropriately publish on each copy an appropriate copyright notice and\n"); - printf_filtered ("disclaimer of warranty; keep intact all the notices that refer to this\n"); - printf_filtered ("General Public License and to the absence of any warranty; and give any\n"); - printf_filtered ("other recipients of the Program a copy of this General Public License\n"); - printf_filtered ("along with the Program. You may charge a fee for the physical act of\n"); - printf_filtered ("transferring a copy.\n"); - printf_filtered ("\n"); - printf_filtered (" 2. You may modify your copy or copies of the Program or any portion of\n"); - printf_filtered ("it, and copy and distribute such modifications under the terms of Paragraph\n"); - printf_filtered ("1 above, provided that you also do the following:\n"); - printf_filtered ("\n"); - printf_filtered (" a) cause the modified files to carry prominent notices stating that\n"); - printf_filtered (" you changed the files and the date of any change; and\n"); - printf_filtered ("\n"); - printf_filtered (" b) cause the whole of any work that you distribute or publish, that\n"); - printf_filtered (" in whole or in part contains the Program or any part thereof, either\n"); - printf_filtered (" with or without modifications, to be licensed at no charge to all\n"); - printf_filtered (" third parties under the terms of this General Public License (except\n"); - printf_filtered (" that you may choose to grant warranty protection to some or all\n"); - printf_filtered (" third parties, at your option).\n"); - printf_filtered ("\n"); - printf_filtered (" c) If the modified program normally reads commands interactively when\n"); - printf_filtered (" run, you must cause it, when started running for such interactive use\n"); - printf_filtered (" in the simplest and most usual way, to print or display an\n"); - printf_filtered (" announcement including an appropriate copyright notice and a notice\n"); - printf_filtered (" that there is no warranty (or else, saying that you provide a\n"); - printf_filtered (" warranty) and that users may redistribute the program under these\n"); - printf_filtered (" conditions, and telling the user how to view a copy of this General\n"); - printf_filtered (" Public License.\n"); - printf_filtered ("\n"); - printf_filtered (" d) You may charge a fee for the physical act of transferring a\n"); - printf_filtered (" copy, and you may at your option offer warranty protection in\n"); - printf_filtered (" exchange for a fee.\n"); - printf_filtered ("\n"); - printf_filtered ("Mere aggregation of another independent work with the Program (or its\n"); - printf_filtered ("derivative) on a volume of a storage or distribution medium does not bring\n"); - printf_filtered ("the other work under the scope of these terms.\n"); - printf_filtered (" \n"); - printf_filtered (" 3. You may copy and distribute the Program (or a portion or derivative of\n"); - printf_filtered ("it, under Paragraph 2) in object code or executable form under the terms of\n"); - printf_filtered ("Paragraphs 1 and 2 above provided that you also do one of the following:\n"); - printf_filtered ("\n"); - printf_filtered (" a) accompany it with the complete corresponding machine-readable\n"); - printf_filtered (" source code, which must be distributed under the terms of\n"); - printf_filtered (" Paragraphs 1 and 2 above; or,\n"); - printf_filtered ("\n"); - printf_filtered (" b) accompany it with a written offer, valid for at least three\n"); - printf_filtered (" years, to give any third party free (except for a nominal charge\n"); - printf_filtered (" for the cost of distribution) a complete machine-readable copy of the\n"); - printf_filtered (" corresponding source code, to be distributed under the terms of\n"); - printf_filtered (" Paragraphs 1 and 2 above; or,\n"); - printf_filtered ("\n"); - printf_filtered (" c) accompany it with the information you received as to where the\n"); - printf_filtered (" corresponding source code may be obtained. (This alternative is\n"); - printf_filtered (" allowed only for noncommercial distribution and only if you\n"); - printf_filtered (" received the program in object code or executable form alone.)\n"); - printf_filtered ("\n"); - printf_filtered ("Source code for a work means the preferred form of the work for making\n"); - printf_filtered ("modifications to it. For an executable file, complete source code means\n"); - printf_filtered ("all the source code for all modules it contains; but, as a special\n"); - printf_filtered ("exception, it need not include source code for modules which are standard\n"); - printf_filtered ("libraries that accompany the operating system on which the executable\n"); - printf_filtered ("file runs, or for standard header files or definitions files that\n"); - printf_filtered ("accompany that operating system.\n"); - printf_filtered ("\n"); - printf_filtered (" 4. You may not copy, modify, sublicense, distribute or transfer the\n"); - printf_filtered ("Program except as expressly provided under this General Public License.\n"); - printf_filtered ("Any attempt otherwise to copy, modify, sublicense, distribute or transfer\n"); - printf_filtered ("the Program is void, and will automatically terminate your rights to use\n"); - printf_filtered ("the Program under this License. However, parties who have received\n"); - printf_filtered ("copies, or rights to use copies, from you under this General Public\n"); - printf_filtered ("License will not have their licenses terminated so long as such parties\n"); - printf_filtered ("remain in full compliance.\n"); - printf_filtered ("\n"); - printf_filtered (" 5. By copying, distributing or modifying the Program (or any work based\n"); - printf_filtered ("on the Program) you indicate your acceptance of this license to do so,\n"); - printf_filtered ("and all its terms and conditions.\n"); - printf_filtered ("\n"); - printf_filtered (" 6. Each time you redistribute the Program (or any work based on the\n"); - printf_filtered ("Program), the recipient automatically receives a license from the original\n"); - printf_filtered ("licensor to copy, distribute or modify the Program subject to these\n"); - printf_filtered ("terms and conditions. You may not impose any further restrictions on the\n"); - printf_filtered ("recipients' exercise of the rights granted herein.\n"); - printf_filtered (" \n"); - printf_filtered (" 7. The Free Software Foundation may publish revised and/or new versions\n"); - printf_filtered ("of the General Public License from time to time. Such new versions will\n"); - printf_filtered ("be similar in spirit to the present version, but may differ in detail to\n"); - printf_filtered ("address new problems or concerns.\n"); - printf_filtered ("\n"); - printf_filtered ("Each version is given a distinguishing version number. If the Program\n"); - printf_filtered ("specifies a version number of the license which applies to it and \"any\n"); - printf_filtered ("later version\", you have the option of following the terms and conditions\n"); - printf_filtered ("either of that version or of any later version published by the Free\n"); - printf_filtered ("Software Foundation. If the Program does not specify a version number of\n"); - printf_filtered ("the license, you may choose any version ever published by the Free Software\n"); - printf_filtered ("Foundation.\n"); - printf_filtered ("\n"); - printf_filtered (" 8. If you wish to incorporate parts of the Program into other free\n"); - printf_filtered ("programs whose distribution conditions are different, write to the author\n"); - printf_filtered ("to ask for permission. For software which is copyrighted by the Free\n"); - printf_filtered ("Software Foundation, write to the Free Software Foundation; we sometimes\n"); - printf_filtered ("make exceptions for this. Our decision will be guided by the two goals\n"); - printf_filtered ("of preserving the free status of all derivatives of our free software and\n"); - printf_filtered ("of promoting the sharing and reuse of software generally.\n"); - printf_filtered ("\n"); - immediate_quit--; -} - -static void -warranty_info () -{ - immediate_quit++; - printf_filtered (" NO WARRANTY\n"); - printf_filtered ("\n"); - printf_filtered (" 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n"); - printf_filtered ("FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\n"); - printf_filtered ("OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n"); - printf_filtered ("PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n"); - printf_filtered ("OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n"); - printf_filtered ("MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\n"); - printf_filtered ("TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\n"); - printf_filtered ("PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n"); - printf_filtered ("REPAIR OR CORRECTION.\n"); - printf_filtered ("\n"); - printf_filtered (" 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n"); - printf_filtered ("WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n"); - printf_filtered ("REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n"); - printf_filtered ("INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n"); - printf_filtered ("OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n"); - printf_filtered ("TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n"); - printf_filtered ("YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n"); - printf_filtered ("PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n"); - printf_filtered ("POSSIBILITY OF SUCH DAMAGES.\n"); - printf_filtered ("\n"); - immediate_quit--; -} - -void -_initialize_copying () -{ - add_info ("copying", copying_info, - "Conditions for redistributing copies of GDB."); - add_info ("warranty", warranty_info, - "Various kinds of warranty you do not have."); -} diff --git a/gnu/usr.bin/gdb/core.c b/gnu/usr.bin/gdb/core.c deleted file mode 100644 index fec0dbb3daf1..000000000000 --- a/gnu/usr.bin/gdb/core.c +++ /dev/null @@ -1,580 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)core.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: core.c,v 1.4 1994/01/28 02:12:02 mycroft Exp $"; -#endif /* not lint */ - -/* Work with core dump and executable files, for GDB. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" /* required by inferior.h */ -#include "inferior.h" - -#ifdef USG -#include -#include -#endif - -#ifdef COFF_ENCAPSULATE -#include "a.out.encap.h" -#else -#include -#endif -#ifndef N_MAGIC -#ifdef COFF_FORMAT -#define N_MAGIC(exec) ((exec).magic) -#else -#define N_MAGIC(exec) (N_GETMAGIC(exec)) -#endif -#endif -#include -#include -#include -#include -#include - -#ifdef UMAX_CORE -#include -#else -#include -#endif - -#ifndef N_TXTADDR -#define N_TXTADDR(hdr) 0 -#endif /* no N_TXTADDR */ - -#ifndef N_DATADDR -#define N_DATADDR(hdr) hdr.a_text -#endif /* no N_DATADDR */ - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -extern core_file_command (), exec_file_command (); - -/* Hook for `exec_file_command' command to call. */ - -void (*exec_file_display_hook) (); - -/* File names of core file and executable file. */ - -char *corefile; -char *execfile; - -/* Descriptors on which core file and executable file are open. - Note that the execchan is closed when an inferior is created - and reopened if the inferior dies or is killed. */ - -int corechan; -int execchan; - -/* Last modification time of executable file. - Also used in source.c to compare against mtime of a source file. */ - -int exec_mtime; - -/* Virtual addresses of bounds of the two areas of memory in the core file. */ - -CORE_ADDR data_start; -CORE_ADDR data_end; -CORE_ADDR stack_start; -CORE_ADDR stack_end; - -#if defined (REG_STACK_SEGMENT) -/* Start and end of the register stack segment. */ -CORE_ADDR reg_stack_start; -CORE_ADDR reg_stack_end; -#endif /* REG_STACK_SEGMENT */ - -/* Virtual addresses of bounds of two areas of memory in the exec file. - Note that the data area in the exec file is used only when there is no core file. */ - -CORE_ADDR text_start; -CORE_ADDR text_end; - -CORE_ADDR exec_data_start; -CORE_ADDR exec_data_end; - -/* Offset within executable file of start of text area data. */ - -int text_offset; - -/* Offset within executable file of start of data area data. */ - -int exec_data_offset; - -/* Offset within core file of start of data area data. */ - -int data_offset; - -/* Offset within core file of start of stack area data. */ - -int stack_offset; - -#ifdef COFF_FORMAT -/* various coff data structures */ - -FILHDR file_hdr; -SCNHDR text_hdr; -SCNHDR data_hdr; - -#endif /* not COFF_FORMAT */ - -/* a.out header saved in core file. */ - -AOUTHDR core_aouthdr; - -/* a.out header of exec file. */ - -AOUTHDR exec_aouthdr; - -void validate_files (); -unsigned int register_addr (); - -/* Call this to specify the hook for exec_file_command to call back. - This is called from the x-window display code. */ - -void -specify_exec_file_hook (hook) - void (*hook) (); -{ - exec_file_display_hook = hook; -} - -/* The exec file must be closed before running an inferior. - If it is needed again after the inferior dies, it must - be reopened. */ - -void -close_exec_file () -{ - if (execchan >= 0) - close (execchan); - execchan = -1; -} - -void -reopen_exec_file () -{ - if (execchan < 0 && execfile != 0) - { - char *filename = concat (execfile, "", ""); - exec_file_command (filename, 0); - free (filename); - } -} - -/* If we have both a core file and an exec file, - print a warning if they don't go together. - This should really check that the core file came - from that exec file, but I don't know how to do it. */ - -void -validate_files () -{ - if (execfile != 0 && corefile != 0) - { - struct stat st_core; - - if (fstat (corechan, &st_core) < 0) - /* It might be a good idea to print an error message. - On the other hand, if the user tries to *do* anything with - the core file, (s)he'll find out soon enough. */ - return; - - if (N_MAGIC (core_aouthdr) != 0 - && bcmp (&core_aouthdr, &exec_aouthdr, sizeof core_aouthdr)) - printf ("Warning: core file does not match specified executable file.\n"); - else if (exec_mtime > st_core.st_mtime) { -#ifdef KERNELDEBUG - extern int kernel_debugging; - if (!kernel_debugging) -#endif - printf ("Warning: exec file is newer than core file.\n"); - } - } -} - -/* Return the name of the executable file as a string. - ERR nonzero means get error if there is none specified; - otherwise return 0 in that case. */ - -char * -get_exec_file (err) - int err; -{ - if (err && execfile == 0) - error ("No executable file specified.\n\ -Use the \"exec-file\" and \"symbol-file\" commands."); - return execfile; -} - -int -have_core_file_p () -{ - return corefile != 0; -} - -static void -files_info () -{ - char *symfile; - extern char *get_sym_file (); - - if (execfile) - printf ("Executable file \"%s\".\n", execfile); - else - printf ("No executable file\n"); - if (corefile == 0) - printf ("No core dump file\n"); - else - printf ("Core dump file \"%s\".\n", corefile); - - if (have_inferior_p ()) - printf ("Using the running image of the program, rather than these files.\n"); - - symfile = get_sym_file (); - if (symfile != 0) - printf ("Symbols from \"%s\".\n", symfile); - -#ifdef FILES_INFO_HOOK - if (FILES_INFO_HOOK ()) - return; -#endif - - if (! have_inferior_p ()) - { - if (execfile) - { - printf ("Text segment in executable from 0x%x to 0x%x.\n", - text_start, text_end); - printf ("Data segment in executable from 0x%x to 0x%x.\n", - exec_data_start, exec_data_end); - if (corefile) - printf ("(But since we have a core file, we're using...)\n"); - } - if (corefile) - { - printf ("Data segment in core file from 0x%x to 0x%x.\n", - data_start, data_end); - printf ("Stack segment in core file from 0x%x to 0x%x.\n", - stack_start, stack_end); - } - } -} - -/* Read "memory data" from core file and/or executable file. - Returns zero if successful, 1 if xfer_core_file failed, errno value if - ptrace failed. */ - -int -read_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - if (len == 0) - return 0; - - if (have_inferior_p ()) - { - if (remote_debugging) - return remote_read_inferior_memory (memaddr, myaddr, len); - else - return read_inferior_memory (memaddr, myaddr, len); - } - else - return xfer_core_file (memaddr, myaddr, len); -} - -/* Write LEN bytes of data starting at address MYADDR - into debugged program memory at address MEMADDR. - Returns zero if successful, or an errno value if ptrace failed. */ - -int -write_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - if (have_inferior_p ()) - { - if (remote_debugging) - return remote_write_inferior_memory (memaddr, myaddr, len); - else - return write_inferior_memory (memaddr, myaddr, len); - } - else - error ("Can write memory only when program being debugged is running."); -} - -#ifndef XFER_CORE_FILE -int (*core_file_hook)(); /* hook to handle special core files like - like /dev/mem and crash dumps */ - -/* Read from the program's memory (except for inferior processes). - This function is misnamed, since it only reads, never writes; and - since it will use the core file and/or executable file as necessary. - - It should be extended to write as well as read, FIXME, for patching files. - - Return 0 if address could be read, 1 if not. */ - -int -xfer_core_file (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - register int val; - int xferchan; - char **xferfile; - int fileptr; - int returnval = 0; - - if (core_file_hook) - return ((*core_file_hook)(memaddr, myaddr, len)); - - while (len > 0) - { - xferfile = 0; - xferchan = 0; - - /* Determine which file the next bunch of addresses reside in, - and where in the file. Set the file's read/write pointer - to point at the proper place for the desired address - and set xferfile and xferchan for the correct file. - - If desired address is nonexistent, leave them zero. - - i is set to the number of bytes that can be handled - along with the next address. - - We put the most likely tests first for efficiency. */ - - /* Note that if there is no core file - data_start and data_end are equal. */ - if (memaddr >= data_start && memaddr < data_end) - { - i = min (len, data_end - memaddr); - fileptr = memaddr - data_start + data_offset; - xferfile = &corefile; - xferchan = corechan; - } - /* Note that if there is no core file - stack_start and stack_end are equal. */ - else if (memaddr >= stack_start && memaddr < stack_end) - { - i = min (len, stack_end - memaddr); - fileptr = memaddr - stack_start + stack_offset; - xferfile = &corefile; - xferchan = corechan; - } -#ifdef REG_STACK_SEGMENT - /* Pyramids have an extra segment in the virtual address space - for the (control) stack of register-window frames */ - else if (memaddr >= reg_stack_start && memaddr < reg_stack_end) - { - i = min (len, reg_stack_end - memaddr); - fileptr = memaddr - reg_stack_start + reg_stack_offset; - xferfile = &corefile; - xferchan = corechan; - } -#endif /* REG_STACK_SEGMENT */ - - else if (corechan < 0 - && memaddr >= exec_data_start && memaddr < exec_data_end) - { - i = min (len, exec_data_end - memaddr); - fileptr = memaddr - exec_data_start + exec_data_offset; - xferfile = &execfile; - xferchan = execchan; - } - else if (memaddr >= text_start && memaddr < text_end) - { - i = min (len, text_end - memaddr); - fileptr = memaddr - text_start + text_offset; - xferfile = &execfile; - xferchan = execchan; - } - else if (memaddr < text_start) - { - i = min (len, text_start - memaddr); - } - else if (memaddr >= text_end - && memaddr < (corechan >= 0? data_start : exec_data_start)) - { - i = min (len, data_start - memaddr); - } - else if (corechan >= 0 - && memaddr >= data_end && memaddr < stack_start) - { - i = min (len, stack_start - memaddr); - } - else if (corechan < 0 && memaddr >= exec_data_end) - { - /* Since there is nothing at higher addresses than data - (without a core file or an inferior, there is no - stack, set i to do the rest of the operation now. */ - i = len; - } -#ifdef REG_STACK_SEGMENT - else if (memaddr >= reg_stack_end && reg_stack_end != 0) - { - i = min (len, reg_stack_start - memaddr); - } - else if (memaddr >= stack_end && memaddr < reg_stack_start) -#else /* no REG_STACK_SEGMENT. */ - else if (memaddr >= stack_end && stack_end != 0) -#endif /* no REG_STACK_SEGMENT. */ - { - /* Since there is nothing at higher addresses than - the stack, set i to do the rest of the operation now. */ - i = len; - } - else - { - /* Address did not classify into one of the known ranges. - This shouldn't happen; we catch the endpoints. */ - fatal ("Internal: Bad case logic in xfer_core_file."); - } - - /* Now we know which file to use. - Set up its pointer and transfer the data. */ - if (xferfile) - { - if (*xferfile == 0) - if (xferfile == &execfile) - error ("No program file to examine."); - else - error ("No core dump file or running program to examine."); - val = lseek (xferchan, fileptr, 0); - if (val == -1) - perror_with_name (*xferfile); - val = myread (xferchan, myaddr, i); - if (val < 0) - perror_with_name (*xferfile); - } - /* If this address is for nonexistent memory, - read zeros if reading, or do nothing if writing. - Actually, we never right. */ - else - { - bzero (myaddr, i); - returnval = 1; - } - - memaddr += i; - myaddr += i; - len -= i; - } - return returnval; -} -#endif /* XFER_CORE_FILE */ - -/* My replacement for the read system call. - Used like `read' but keeps going if `read' returns too soon. */ - -int -myread (desc, addr, len) - int desc; - char *addr; - int len; -{ - register int val; - int orglen = len; - - while (len > 0) - { - val = read (desc, addr, len); - if (val < 0) - return val; - if (val == 0) - return orglen - len; - len -= val; - addr += val; - } - return orglen; -} - -#ifdef REGISTER_U_ADDR - -/* Return the address in the core dump or inferior of register REGNO. - BLOCKEND is the address of the end of the user structure. */ - -unsigned int -register_addr (regno, blockend) - int regno; - int blockend; -{ - int addr; - - if (regno < 0 || regno >= NUM_REGS) - error ("Invalid register number %d.", regno); - - REGISTER_U_ADDR (addr, blockend, regno); - - return addr; -} - -#endif /* REGISTER_U_ADDR */ - -void -_initialize_core() -{ - corechan = -1; - execchan = -1; - corefile = 0; - execfile = 0; - exec_file_display_hook = 0; - - text_start = 0; - text_end = 0; - data_start = 0; - data_end = 0; - exec_data_start = 0; - exec_data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - add_com ("core-file", class_files, core_file_command, - "Use FILE as core dump for examining memory and registers.\n\ -No arg means have no core file."); - add_com ("exec-file", class_files, exec_file_command, - "Use FILE as program for getting contents of pure memory.\n\ -If FILE cannot be found as specified, your execution directory path\n\ -is searched for a command of that name.\n\ -No arg means have no executable file."); - add_info ("files", files_info, "Names of files being debugged."); -} - diff --git a/gnu/usr.bin/gdb/cplus-dem.c b/gnu/usr.bin/gdb/cplus-dem.c deleted file mode 100644 index bdb45bf64ffa..000000000000 --- a/gnu/usr.bin/gdb/cplus-dem.c +++ /dev/null @@ -1,1000 +0,0 @@ -/* Demangler for GNU C++ - Copyright (C) 1989 Free Software Foundation, Inc. - written by James Clark (jjc@jclark.uucp) - - 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. */ - -#ifndef lint -static char rcsid[] = "$Id: cplus-dem.c,v 1.2 1993/08/02 17:40:56 mycroft Exp $"; -#endif /* not lint */ - -/* This is for g++ 1.36.1 (November 6 version). It will probably - require changes for any other version. - - Modified for g++ 1.36.2 (November 18 version). */ - -/* This file exports one function - - char *cplus_demangle (const char *name, int mode) - - If NAME is a mangled function name produced by GNU C++, then - a pointer to a malloced string giving a C++ representation - of the name will be returned; otherwise NULL will be returned. - It is the caller's responsibility to free the string which - is returned. - - If MODE > 0, then ANSI qualifiers such as `const' and `void' are output. - Otherwise they are not. - If MODE >= 0, parameters are emitted; otherwise not. - - For example, - - cplus_demangle ("foo__1Ai", 0) => "A::foo(int)" - cplus_demangle ("foo__1Ai", 1) => "A::foo(int)" - cplus_demangle ("foo__1Ai", -1) => "A::foo" - - cplus_demangle ("foo__1Afe", 0) => "A::foo(float,...)" - cplus_demangle ("foo__1Afe", 1) => "A::foo(float,...)" - cplus_demangle ("foo__1Afe", -1) => "A::foo" - - This file imports xmalloc and xrealloc, which are like malloc and - realloc except that they generate a fatal error if there is no - available memory. */ - -/* #define nounderscore 1 /* define this is names don't start with _ */ - -#include -#include - -#ifdef USG -#include -#include -#else -#include -#define memcpy(s1, s2, n) bcopy ((s2), (s1), (n)) -#define memcmp(s1, s2, n) bcmp ((s2), (s1), (n)) -#define strchr index -#define strrchr rindex -#endif - -#ifndef __STDC__ -#define const -#endif - -#ifdef __STDC__ -extern char *cplus_demangle (const char *type, int mode); -#else -extern char *cplus_demangle (); -#endif - -#ifdef __STDC__ -extern char *xmalloc (int); -extern char *xrealloc (char *, int); -#else -extern char *xmalloc (); -extern char *xrealloc (); -#endif - -static char **typevec = 0; -static int ntypes = 0; -static int typevec_size = 0; - -static struct { - const char *in; - const char *out; -} optable[] = { - "new", " new", - "delete", " delete", - "ne", "!=", - "eq", "==", - "ge", ">=", - "gt", ">", - "le", "<=", - "lt", "<", - "plus", "+", - "minus", "-", - "mult", "*", - "convert", "+", /* unary + */ - "negate", "-", /* unary - */ - "trunc_mod", "%", - "trunc_div", "/", - "truth_andif", "&&", - "truth_orif", "||", - "truth_not", "!", - "postincrement", "++", - "postdecrement", "--", - "bit_ior", "|", - "bit_xor", "^", - "bit_and", "&", - "bit_not", "~", - "call", "()", - "cond", "?:", - "alshift", "<<", - "arshift", ">>", - "component", "->", - "indirect", "*", - "method_call", "->()", - "addr", "&", /* unary & */ - "array", "[]", - "nop", "", /* for operator= */ -}; - -/* Beware: these aren't '\0' terminated. */ - -typedef struct { - char *b; /* pointer to start of string */ - char *p; /* pointer after last character */ - char *e; /* pointer after end of allocated space */ -} string; - -#ifdef __STDC__ -static void string_need (string *s, int n); -static void string_delete (string *s); -static void string_init (string *s); -static void string_clear (string *s); -static int string_empty (string *s); -static void string_append (string *p, const char *s); -static void string_appends (string *p, string *s); -static void string_appendn (string *p, const char *s, int n); -static void string_prepend (string *p, const char *s); -#if 0 -static void string_prepends (string *p, string *s); -#endif -static void string_prependn (string *p, const char *s, int n); -static int get_count (const char **type, int *count); -static int do_args (const char **type, string *decl, int arg_mode); -static int do_type (const char **type, string *result, int arg_mode); -static int do_arg (const char **type, string *result, int arg_mode); -static void munge_function_name (string *name, int arg_mode); -static void remember_type (const char *type, int len); -#else -static void string_need (); -static void string_delete (); -static void string_init (); -static void string_clear (); -static int string_empty (); -static void string_append (); -static void string_appends (); -static void string_appendn (); -static void string_prepend (); -static void string_prepends (); -static void string_prependn (); -static int get_count (); -static int do_args (); -static int do_type (); -static int do_arg (); -static int do_args (); -static void munge_function_name (); -static void remember_type (); -#endif - -char * -cplus_demangle (type, arg_mode) - const char *type; - int arg_mode; -{ - string decl; - int n; - int success = 0; - int constructor = 0; - int const_flag = 0; - int i; - const char *p; -#ifndef LONGERNAMES - const char *premangle; -#endif - -# define print_ansi_qualifiers (arg_mode > 0) -# define print_arg_types (arg_mode >= 0) - - if (type == NULL || *type == '\0') - return NULL; -#ifndef nounderscore - if (*type++ != '_') - return NULL; -#endif - p = type; - while (*p != '\0' && !(*p == '_' && p[1] == '_')) - p++; - if (*p == '\0') - { - /* destructor */ - if (type[0] == '_' && type[1] == '$' && type[2] == '_') - { - int n = (strlen (type) - 3)*2 + 3 + 2 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 3); - strcat (tem, "::~"); - strcat (tem, type + 3); - strcat (tem, "()"); - return tem; - } - /* static data member */ - if (*type != '_' && (p = strchr (type, '$')) != NULL) - { - int n = strlen (type) + 2; - char *tem = (char *) xmalloc (n); - memcpy (tem, type, p - type); - strcpy (tem + (p - type), "::"); - strcpy (tem + (p - type) + 2, p + 1); - return tem; - } - /* virtual table "_vt$" */ - if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == '$') - { - int n = strlen (type + 4) + 14 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 4); - strcat (tem, " virtual table"); - return tem; - } - return NULL; - } - - string_init (&decl); - - if (p == type) - { - if (!isdigit (p[2])) - { - string_delete (&decl); - return NULL; - } - constructor = 1; - } - else - { - string_appendn (&decl, type, p - type); - munge_function_name (&decl, arg_mode); - } - p += 2; - -#ifndef LONGERNAMES - premangle = p; -#endif - switch (*p) - { - case 'C': - /* a const member function */ - if (!isdigit (p[1])) - { - string_delete (&decl); - return NULL; - } - p += 1; - const_flag = 1; - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (strlen (p) < n) - { - string_delete (&decl); - return NULL; - } - if (constructor) - { - string_appendn (&decl, p, n); - string_append (&decl, "::"); - string_appendn (&decl, p, n); - } - else - { - string_prepend (&decl, "::"); - string_prependn (&decl, p, n); - } - p += n; -#ifndef LONGERNAMES - remember_type (premangle, p - premangle); -#endif - success = do_args (&p, &decl, arg_mode); - if (const_flag && print_arg_types) - string_append (&decl, " const"); - break; - case 'F': - p += 1; - success = do_args (&p, &decl, arg_mode); - break; - } - - for (i = 0; i < ntypes; i++) - if (typevec[i] != NULL) - free (typevec[i]); - ntypes = 0; - if (typevec != NULL) - { - free ((char *)typevec); - typevec = NULL; - typevec_size = 0; - } - - if (success) - { - string_appendn (&decl, "", 1); - return decl.b; - } - else - { - string_delete (&decl); - return NULL; - } -} - -static int -get_count (type, count) - const char **type; - int *count; -{ - if (!isdigit (**type)) - return 0; - *count = **type - '0'; - *type += 1; - /* see flush_repeats in cplus-method.c */ - if (isdigit (**type)) - { - const char *p = *type; - int n = *count; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (*p == '_') - { - *type = p + 1; - *count = n; - } - } - return 1; -} - -/* result will be initialised here; it will be freed on failure */ - -static int -do_type (type, result, arg_mode) - const char **type; - string *result; - int arg_mode; -{ - int n; - int done; - int non_empty = 0; - int success; - string decl; - const char *remembered_type; - - string_init (&decl); - string_init (result); - - done = 0; - success = 1; - while (success && !done) - { - int member; - switch (**type) - { - case 'P': - *type += 1; - string_prepend (&decl, "*"); - break; - - case 'R': - *type += 1; - string_prepend (&decl, "&"); - break; - - case 'T': - *type += 1; - if (!get_count (type, &n) || n >= ntypes) - success = 0; - else - { - remembered_type = typevec[n]; - type = &remembered_type; - } - break; - - case 'F': - *type += 1; - if (!string_empty (&decl) && decl.b[0] == '*') - { - string_prepend (&decl, "("); - string_append (&decl, ")"); - } - if (!do_args (type, &decl, arg_mode) || **type != '_') - success = 0; - else - *type += 1; - break; - - case 'M': - case 'O': - { - int constp = 0; - int volatilep = 0; - - member = **type == 'M'; - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - string_append (&decl, ")"); - string_prepend (&decl, "::"); - string_prependn (&decl, *type, n); - string_prepend (&decl, "("); - *type += n; - if (member) - { - if (**type == 'C') - { - *type += 1; - constp = 1; - } - if (**type == 'V') - { - *type += 1; - volatilep = 1; - } - if (*(*type)++ != 'F') - { - success = 0; - break; - } - } - if ((member && !do_args (type, &decl, arg_mode)) || **type != '_') - { - success = 0; - break; - } - *type += 1; - if (! print_ansi_qualifiers) - break; - if (constp) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "const"); - } - if (volatilep) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "volatile"); - } - break; - } - - case 'C': - if ((*type)[1] == 'P') - { - *type += 1; - if (print_ansi_qualifiers) - { - if (!string_empty (&decl)) - string_prepend (&decl, " "); - string_prepend (&decl, "const"); - } - break; - } - - /* fall through */ - default: - done = 1; - break; - } - } - - done = 0; - non_empty = 0; - while (success && !done) - { - switch (**type) - { - case 'C': - *type += 1; - if (print_ansi_qualifiers) - { - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "const"); - } - break; - case 'U': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "unsigned"); - break; - case 'V': - *type += 1; - if (print_ansi_qualifiers) - { - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "volatile"); - } - break; - default: - done = 1; - break; - } - } - - if (success) - switch (**type) - { - case '\0': - case '_': - break; - case 'v': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "void"); - break; - case 'x': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long long"); - break; - case 'l': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long"); - break; - case 'i': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "int"); - break; - case 's': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "short"); - break; - case 'c': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "char"); - break; - case 'r': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long double"); - break; - case 'd': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "double"); - break; - case 'f': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "float"); - break; - case 'G': - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - if (non_empty) - string_append (result, " "); - string_appendn (result, *type, n); - *type += n; - break; - default: - success = 0; - break; - } - - if (success) - { - if (!string_empty (&decl)) - { - string_append (result, " "); - string_appends (result, &decl); - } - string_delete (&decl); - return 1; - } - else - { - string_delete (&decl); - string_delete (result); - return 0; - } -} - -/* `result' will be initialised in do_type; it will be freed on failure */ - -static int -do_arg (type, result, arg_mode) - const char **type; - string *result; - int arg_mode; -{ - const char *start = *type; - - if (!do_type (type, result, arg_mode)) - return 0; - remember_type (start, *type - start); - return 1; -} - -static void -remember_type (start, len) - const char *start; - int len; -{ - char *tem; - - if (ntypes >= typevec_size) - { - if (typevec_size == 0) - { - typevec_size = 3; - typevec = (char **) xmalloc (sizeof (char*)*typevec_size); - } - else - { - typevec_size *= 2; - typevec = (char **) xrealloc ((char *)typevec, sizeof (char*)*typevec_size); - } - } - tem = (char *) xmalloc (len + 1); - memcpy (tem, start, len); - tem[len] = '\0'; - typevec[ntypes++] = tem; -} - -/* `decl' must be already initialised, usually non-empty; - it won't be freed on failure */ - -static int -do_args (type, decl, arg_mode) - const char **type; - string *decl; - int arg_mode; -{ - string arg; - int need_comma = 0; - - if (print_arg_types) - string_append (decl, "("); - - while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v') - { - if (**type == 'N') - { - int r; - int t; - *type += 1; - if (!get_count (type, &r) || !get_count (type, &t) || t >= ntypes) - return 0; - while (--r >= 0) - { - const char *tem = typevec[t]; - if (need_comma && print_arg_types) - string_append (decl, ", "); - if (!do_arg (&tem, &arg, arg_mode)) - return 0; - if (print_arg_types) - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - else - { - if (need_comma & print_arg_types) - string_append (decl, ", "); - if (!do_arg (type, &arg, arg_mode)) - return 0; - if (print_arg_types) - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - - if (**type == 'v') - *type += 1; - else if (**type == 'e') - { - *type += 1; - if (print_arg_types) - { - if (need_comma) - string_append (decl, ","); - string_append (decl, "..."); - } - } - - if (print_arg_types) - string_append (decl, ")"); - return 1; -} - -static void -munge_function_name (name, arg_mode) - string *name; - int arg_mode; -{ - if (!string_empty (name) && name->p - name->b >= 3 - && name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == '$') - { - int i; - /* see if it's an assignment expression */ - if (name->p - name->b >= 10 /* op$assign_ */ - && memcmp (name->b + 3, "assign_", 7) == 0) - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 10; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 10, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - string_append (name, "="); - return; - } - } - } - else - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 3; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 3, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - return; - } - } - } - return; - } - else if (!string_empty (name) && name->p - name->b >= 5 - && memcmp (name->b, "type$", 5) == 0) - { - /* type conversion operator */ - string type; - const char *tem = name->b + 5; - if (do_type (&tem, &type, arg_mode)) - { - string_clear (name); - string_append (name, "operator "); - string_appends (name, &type); - string_delete (&type); - return; - } - } -} - -/* a mini string-handling package */ - -static void -string_need (s, n) - string *s; - int n; -{ - if (s->b == NULL) - { - if (n < 32) - n = 32; - s->p = s->b = (char *) xmalloc (n); - s->e = s->b + n; - } - else if (s->e - s->p < n) - { - int tem = s->p - s->b; - n += tem; - n *= 2; - s->b = (char *) xrealloc (s->b, n); - s->p = s->b + tem; - s->e = s->b + n; - } -} - -static void -string_delete (s) - string *s; -{ - if (s->b != NULL) - { - free (s->b); - s->b = s->e = s->p = NULL; - } -} - -static void -string_init (s) - string *s; -{ - s->b = s->p = s->e = NULL; -} - -static void -string_clear (s) - string *s; -{ - s->p = s->b; -} - -static int -string_empty (s) - string *s; -{ - return s->b == s->p; -} - -static void -string_append (p, s) - string *p; - const char *s; -{ - int n; - if (s == NULL || *s == '\0') - return; - n = strlen (s); - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_appends (p, s) - string *p, *s; -{ - int n; - if (s->b == s->p) - return; - n = s->p - s->b; - string_need (p, n); - memcpy (p->p, s->b, n); - p->p += n; -} - -static void -string_appendn (p, s, n) - string *p; - const char *s; - int n; -{ - if (n == 0) - return; - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_prepend (p, s) - string *p; - const char *s; -{ - if (s == NULL || *s == '\0') - return; - string_prependn (p, s, strlen (s)); -} - -#if 0 -static void -string_prepends (p, s) - string *p, *s; -{ - if (s->b == s->p) - return; - string_prependn (p, s->b, s->p - s->b); -} -#endif - -static void -string_prependn (p, s, n) - string *p; - const char *s; - int n; -{ - char *q; - - if (n == 0) - return; - string_need (p, n); - for (q = p->p - 1; q >= p->b; q--) - q[n] = q[0]; - memcpy (p->b, s, n); - p->p += n; -} diff --git a/gnu/usr.bin/gdb/dbxread.c b/gnu/usr.bin/gdb/dbxread.c deleted file mode 100644 index 6aaf0e4e4793..000000000000 --- a/gnu/usr.bin/gdb/dbxread.c +++ /dev/null @@ -1,5738 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)dbxread.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: dbxread.c,v 1.4 1993/12/08 08:33:40 pk Exp $"; -#endif /* not lint */ - -/* Read dbx symbol tables and convert to internal format, for GDB. - Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Symbol read-in occurs in two phases: - 1. A scan (read_dbx_symtab()) of the entire executable, whose sole - purpose is to make a list of symbols (partial symbol table) - which will cause symbols - to be read in if referenced. This scan happens when the - "symbol-file" command is given (symbol_file_command()). - 2. Full read-in of symbols. (psymtab_to_symtab()). This happens - when a symbol in a file for which symbols have not yet been - read in is referenced. - 2a. The "add-file" command. Similar to #2. */ - -#include -#include "defs.h" -#include "param.h" - -#ifdef READ_DBX_FORMAT - -#ifdef USG -#include -#include -#define L_SET 0 -#define L_INCR 1 -#endif - -#ifdef COFF_ENCAPSULATE -#include "a.out.encap.h" -#include "stab.gnu.h" -#else -#include -#include -#endif -#include - -/* This type specified the size of a N_DATA symbol of the same name */ -#ifndef N_SIZE -#define N_SIZE 0xc -#endif - -#ifndef NO_GNU_STABS -/* - * Define specifically gnu symbols here. - */ - -/* 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. */ -#ifndef N_INDR -#define N_INDR 0xa -#endif - -/* 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. */ - -#ifndef N_SETA -#define N_SETA 0x14 /* Absolute set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETT -#define N_SETT 0x16 /* Text set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETD -#define N_SETD 0x18 /* Data set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETB -#define N_SETB 0x1A /* Bss set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -/* Macros dealing with the set element symbols defined in a.out.h */ -#define SET_ELEMENT_P(x) ((x)>=N_SETA&&(x)<=(N_SETB|N_EXT)) -#define TYPE_OF_SET_ELEMENT(x) ((x)-N_SETA+N_ABS) - -#ifndef N_SETV -#define N_SETV 0x1C /* Pointer to set vector in data area. */ -#endif /* This is output from LD. */ - -#ifndef N_WARNING -#define N_WARNING 0x1E /* Warning message to print if file included */ -#endif /* This is input to ld */ - -#ifndef __GNU_STAB__ - -/* Line number for the data section. This is to be used to describe - the source location of a variable declaration. */ -#ifndef N_DSLINE -#define N_DSLINE (N_SLINE+N_DATA-N_TEXT) -#endif - -/* Line number for the bss section. This is to be used to describe - the source location of a variable declaration. */ -#ifndef N_BSLINE -#define N_BSLINE (N_SLINE+N_BSS-N_TEXT) -#endif - -#endif /* not __GNU_STAB__ */ -#endif /* NO_GNU_STABS */ - -#include -#include -#include -#include - -#include "symtab.h" - -#ifndef COFF_FORMAT -#ifndef AOUTHDR -#define AOUTHDR struct exec -#endif -#endif - -static void add_symbol_to_list (); -static void read_dbx_symtab (); -static void process_one_symbol (); -static void free_all_psymbols (); -static struct type *read_type (); -static struct type *read_range_type (); -static struct type *read_enum_type (); -static struct type *read_struct_type (); -static struct type *read_array_type (); -static long read_number (); -static void read_huge_number (); -static void finish_block (); -static struct blockvector *make_blockvector (); -static struct symbol *define_symbol (); -static void start_subfile (); -static int hashname (); -static void hash_symsegs (); -static struct pending *copy_pending (); -static void fix_common_block (); - -static void add_undefined_type (); -static void cleanup_undefined_types (); - -extern char *index(); - -extern struct symtab *read_symsegs (); -extern void free_all_symtabs (); -extern void free_all_psymtabs (); -extern void free_inclink_symtabs (); - -/* C++ */ -static struct type **read_args (); - -/* Macro to determine which symbols to ignore when reading the first symbol - of a file. Some machines override this definition. */ -#ifdef N_NSYMS -#ifndef IGNORE_SYMBOL -/* This code is used on Ultrix systems. Ignore it */ -#define IGNORE_SYMBOL(type) (type == N_NSYMS) -#endif -#else -#ifndef IGNORE_SYMBOL -/* Don't ignore any symbols. */ -#define IGNORE_SYMBOL(type) (0) -#endif -#endif /* not N_NSYMS */ - -/* Macro for number of symbol table entries (in usual a.out format). - Some machines override this definition. */ -#ifndef NUMBER_OF_SYMBOLS -#ifdef COFF_HEADER -#define NUMBER_OF_SYMBOLS \ - ((COFF_HEADER(hdr) ? hdr.coffhdr.filehdr.f_nsyms : hdr.a_syms) / \ - sizeof (struct nlist)) -#else -#define NUMBER_OF_SYMBOLS (hdr.a_syms / sizeof (struct nlist)) -#endif -#endif - -/* Macro for file-offset of symbol table (in usual a.out format). */ -#ifndef SYMBOL_TABLE_OFFSET -#define SYMBOL_TABLE_OFFSET N_SYMOFF (hdr) -#endif - -/* Macro for file-offset of string table (in usual a.out format). */ -#ifndef STRING_TABLE_OFFSET -#define STRING_TABLE_OFFSET (N_SYMOFF (hdr) + hdr.a_syms) -#endif - -/* Macro to store the length of the string table data in INTO. */ -#ifndef READ_STRING_TABLE_SIZE -#define READ_STRING_TABLE_SIZE(INTO) \ -{ val = myread (desc, &INTO, sizeof INTO); \ - if (val < 0) perror_with_name (name); } -#endif - -/* Macro to declare variables to hold the file's header data. */ -#ifndef DECLARE_FILE_HEADERS -#define DECLARE_FILE_HEADERS AOUTHDR hdr -#endif - -/* Macro to read the header data from descriptor DESC and validate it. - NAME is the file name, for error messages. */ -#ifndef READ_FILE_HEADERS -#ifdef HEADER_SEEK_FD -#define READ_FILE_HEADERS(DESC, NAME) \ -{ HEADER_SEEK_FD (DESC); \ - val = myread (DESC, &hdr, sizeof hdr); \ - if (val < 0) perror_with_name (NAME); \ - if (N_BADMAG (hdr)) \ - error ("File \"%s\" not in executable format.", NAME); } -#else -#define READ_FILE_HEADERS(DESC, NAME) \ -{ val = myread (DESC, &hdr, sizeof hdr); \ - if (val < 0) perror_with_name (NAME); \ - if (N_BADMAG (hdr)) \ - error ("File \"%s\" not in executable format.", NAME); } -#endif -#endif - -/* Non-zero if this is an object (.o) file, rather than an executable. - Distinguishing between the two is rarely necessary (and seems like - a hack, but there is no other way to do ADDR_OF_TEXT_SEGMENT - right for SunOS). */ -#if !defined (IS_OBJECT_FILE) -/* This will not work - if someone decides to make ld preserve relocation info. */ -#define IS_OBJECT_FILE (hdr.a_trsize != 0) -#endif - -/* Macro for size of text segment */ -#ifndef SIZE_OF_TEXT_SEGMENT -#define SIZE_OF_TEXT_SEGMENT hdr.a_text -#endif - -/* Get the address in debugged memory of the start - of the text segment. */ -#if !defined (ADDR_OF_TEXT_SEGMENT) -#if defined (N_TXTADDR) -#define ADDR_OF_TEXT_SEGMENT (IS_OBJECT_FILE ? 0 : N_TXTADDR (hdr)) -#else /* no N_TXTADDR */ -#define ADDR_OF_TEXT_SEGMENT 0 -#endif /* no N_TXTADDR */ -#endif /* no ADDR_OF_TEXT_SEGMENT */ - -/* Macro to get entry point from headers. */ -#ifndef ENTRY_POINT -#define ENTRY_POINT hdr.a_entry -#endif - -/* Macro for name of symbol to indicate a file compiled with gcc. */ -#ifndef GCC_COMPILED_FLAG_SYMBOL -#define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled." -#endif - -/* Convert stab register number (from `r' declaration) to a gdb REGNUM. */ - -#ifndef STAB_REG_TO_REGNUM -#define STAB_REG_TO_REGNUM(VALUE) (VALUE) -#endif - -/* Define this as 1 if a pcc declaration of a char or short argument - gives the correct address. Otherwise assume pcc gives the - address of the corresponding int, which is not the same on a - big-endian machine. */ - -#ifndef BELIEVE_PCC_PROMOTION -#define BELIEVE_PCC_PROMOTION 0 -#endif - -/* Nonzero means give verbose info on gdb action. From main.c. */ -extern int info_verbose; - -/* Chain of symtabs made from reading the file's symsegs. - These symtabs do not go into symtab_list themselves, - but the information is copied from them when appropriate - to make the symtabs that will exist permanently. */ - -static struct symtab *symseg_chain; - -/* Symseg symbol table for the file whose data we are now processing. - It is one of those in symseg_chain. Or 0, for a compilation that - has no symseg. */ - -static struct symtab *current_symseg; - -/* Name of source file whose symbol data we are now processing. - This comes from a symbol of type N_SO. */ - -static char *last_source_file; - -/* Core address of start of text of current source file. - This too comes from the N_SO symbol. */ - -static CORE_ADDR last_source_start_addr; - -/* End of the text segment of the executable file, - as found in the symbol _etext. */ - -static CORE_ADDR end_of_text_addr; - -/* The list of sub-source-files within the current individual compilation. - Each file gets its own symtab with its own linetable and associated info, - but they all share one blockvector. */ - -struct subfile -{ - struct subfile *next; - char *name; - struct linetable *line_vector; - int line_vector_length; - int line_vector_index; - int prev_line_number; -}; - -static struct subfile *subfiles; - -static struct subfile *current_subfile; - -/* Count symbols as they are processed, for error messages. */ - -static int symnum; - -/* Vector of types defined so far, indexed by their dbx type numbers. - (In newer sun systems, dbx uses a pair of numbers in parens, - as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be - translated through the type_translations hash table to get - the index into the type vector.) */ - -static struct typevector *type_vector; - -/* Number of elements allocated for type_vector currently. */ - -static int type_vector_length; - -/* Vector of line number information. */ - -static struct linetable *line_vector; - -/* Index of next entry to go in line_vector_index. */ - -static int line_vector_index; - -/* Last line number recorded in the line vector. */ - -static int prev_line_number; - -/* Number of elements allocated for line_vector currently. */ - -static int line_vector_length; - -/* Hash table of global symbols whose values are not known yet. - They are chained thru the SYMBOL_VALUE, since we don't - have the correct data for that slot yet. */ -/* The use of the LOC_BLOCK code in this chain is nonstandard-- - it refers to a FORTRAN common block rather than the usual meaning. */ - -#define HASHSIZE 127 -static struct symbol *global_sym_chain[HASHSIZE]; - -/* Record the symbols defined for each context in a list. - We don't create a struct block for the context until we - know how long to make it. */ - -#define PENDINGSIZE 100 - -struct pending -{ - struct pending *next; - int nsyms; - struct symbol *symbol[PENDINGSIZE]; -}; - -/* List of free `struct pending' structures for reuse. */ -struct pending *free_pendings; - -/* Here are the three lists that symbols are put on. */ - -struct pending *file_symbols; /* static at top level, and types */ - -struct pending *global_symbols; /* global functions and variables */ - -struct pending *local_symbols; /* everything local to lexical context */ - -/* List of symbols declared since the last BCOMM. This list is a tail - of local_symbols. When ECOMM is seen, the symbols on the list - are noted so their proper addresses can be filled in later, - using the common block base address gotten from the assembler - stabs. */ - -struct pending *common_block; -int common_block_i; - -/* Stack representing unclosed lexical contexts - (that will become blocks, eventually). */ - -struct context_stack -{ - struct pending *locals; - struct pending_block *old_blocks; - struct symbol *name; - CORE_ADDR start_addr; - int depth; -}; - -struct context_stack *context_stack; - -/* Index of first unused entry in context stack. */ -int context_stack_depth; - -/* Currently allocated size of context stack. */ - -int context_stack_size; - -/* Nonzero if within a function (so symbols should be local, - if nothing says specifically). */ - -int within_function; - -/* List of blocks already made (lexical contexts already closed). - This is used at the end to make the blockvector. */ - -struct pending_block -{ - struct pending_block *next; - struct block *block; -}; - -struct pending_block *pending_blocks; - -extern CORE_ADDR startup_file_start; /* From blockframe.c */ -extern CORE_ADDR startup_file_end; /* From blockframe.c */ - -/* File name symbols were loaded from. */ - -static char *symfile; - -/* Low and high symbol values (inclusive) for the global variable - entries in the symbol file. */ - -static int first_global_sym, last_global_sym; - -/* Structures with which to manage partial symbol allocation. */ - -struct psymbol_allocation_list global_psymbols, static_psymbols; - -/* Global variable which, when set, indicates that we are processing a - .o file compiled with gcc */ - -static unsigned char processing_gcc_compilation; - -/* Make a list of forward references which haven't been defined. */ -static struct type **undef_types; -static int undef_types_allocated, undef_types_length; - - /* Setup a define to deal cleanly with the underscore problem */ - -#ifdef NAMES_HAVE_UNDERSCORE -#define HASH_OFFSET 1 -#else -#define HASH_OFFSET 0 -#endif - -#if 0 -/* I'm not sure why this is here. To debug bugs which cause - an infinite loop of allocations, I suppose. In any event, - dumping core when out of memory isn't usually right. */ -static int -xxmalloc (n) -{ - int v = malloc (n); - if (v == 0) - { - fprintf (stderr, "Virtual memory exhausted.\n"); - abort (); - } - return v; -} -#else /* not 0 */ -#define xxmalloc xmalloc -#endif /* not 0 */ - -/* Make a copy of the string at PTR with SIZE characters in the symbol obstack - (and add a null character at the end in the copy). - Returns the address of the copy. */ - -static char * -obsavestring (ptr, size) - char *ptr; - int size; -{ - register char *p = (char *) obstack_alloc (symbol_obstack, size + 1); - /* Open-coded bcopy--saves function call time. - These strings are usually short. */ - { - register char *p1 = ptr; - register char *p2 = p; - char *end = ptr + size; - while (p1 != end) - *p2++ = *p1++; - } - p[size] = 0; - return p; -} - -/* Concatenate strings S1, S2 and S3; return the new string. - Space is found in the symbol_obstack. */ - -static char * -obconcat (s1, s2, s3) - char *s1, *s2, *s3; -{ - register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1; - register char *val = (char *) obstack_alloc (symbol_obstack, len); - strcpy (val, s1); - strcat (val, s2); - strcat (val, s3); - return val; -} - -/* Support for Sun changes to dbx symbol format */ - -/* For each identified header file, we have a table of types defined - in that header file. - - header_files maps header file names to their type tables. - It is a vector of n_header_files elements. - Each element describes one header file. - It contains a vector of types. - - Sometimes it can happen that the same header file produces - different results when included in different places. - This can result from conditionals or from different - things done before including the file. - When this happens, there are multiple entries for the file in this table, - one entry for each distinct set of results. - The entries are distinguished by the INSTANCE field. - The INSTANCE field appears in the N_BINCL and N_EXCL symbol table and is - used to match header-file references to their corresponding data. */ - -struct header_file -{ - char *name; /* Name of header file */ - int instance; /* Numeric code distinguishing instances - of one header file that produced - different results when included. - It comes from the N_BINCL or N_EXCL. */ - struct type **vector; /* Pointer to vector of types */ - int length; /* Allocated length (# elts) of that vector */ -}; - -static struct header_file *header_files; - -static int n_header_files; - -static int n_allocated_header_files; - -/* During initial symbol readin, we need to have a structure to keep - track of which psymtabs have which bincls in them. This structure - is used during readin to setup the list of dependencies within each - partial symbol table. */ - -struct header_file_location -{ - char *name; /* Name of header file */ - int instance; /* See above */ - struct partial_symtab *pst; /* Partial symtab that has the - BINCL/EINCL defs for this file */ -}; - -/* The actual list and controling variables */ -static struct header_file_location *bincl_list, *next_bincl; -static int bincls_allocated; - -/* Within each object file, various header files are assigned numbers. - A type is defined or referred to with a pair of numbers - (FILENUM,TYPENUM) where FILENUM is the number of the header file - and TYPENUM is the number within that header file. - TYPENUM is the index within the vector of types for that header file. - - FILENUM == 1 is special; it refers to the main source of the object file, - and not to any header file. FILENUM != 1 is interpreted by looking it up - in the following table, which contains indices in header_files. */ - -static int *this_object_header_files; - -static int n_this_object_header_files; - -static int n_allocated_this_object_header_files; - -/* When a header file is getting special overriding definitions - for one source file, record here the header_files index - of its normal definition vector. - At other times, this is -1. */ - -static int header_file_prev_index; - -/* At the start of reading dbx symbols, allocate our tables. */ - -static void -init_header_files () -{ - n_allocated_header_files = 10; - header_files = (struct header_file *) xxmalloc (10 * sizeof (struct header_file)); - n_header_files = 0; - - n_allocated_this_object_header_files = 10; - this_object_header_files = (int *) xxmalloc (10 * sizeof (int)); -} - -/* At the end of reading dbx symbols, free our tables. */ - -static void -free_header_files () -{ - register int i; - for (i = 0; i < n_header_files; i++) - free (header_files[i].name); - if (header_files) free (header_files); - if (this_object_header_files) - free (this_object_header_files); -} - -/* Called at the start of each object file's symbols. - Clear out the mapping of header file numbers to header files. */ - -static void -new_object_header_files () -{ - /* Leave FILENUM of 0 free for builtin types and this file's types. */ - n_this_object_header_files = 1; - header_file_prev_index = -1; -} - -/* Add header file number I for this object file - at the next successive FILENUM. */ - -static void -add_this_object_header_file (i) - int i; -{ - if (n_this_object_header_files == n_allocated_this_object_header_files) - { - n_allocated_this_object_header_files *= 2; - this_object_header_files - = (int *) xrealloc (this_object_header_files, - n_allocated_this_object_header_files * sizeof (int)); - } - - this_object_header_files[n_this_object_header_files++] = i; -} - -/* Add to this file an "old" header file, one already seen in - a previous object file. NAME is the header file's name. - INSTANCE is its instance code, to select among multiple - symbol tables for the same header file. */ - -static void -add_old_header_file (name, instance) - char *name; - int instance; -{ - register struct header_file *p = header_files; - register int i; - - for (i = 0; i < n_header_files; i++) - if (!strcmp (p[i].name, name) && instance == p[i].instance) - { - add_this_object_header_file (i); - return; - } - error ("Invalid symbol data: \"repeated\" header file that hasn't been seen before, at symtab pos %d.", - symnum); -} - -/* Add to this file a "new" header file: definitions for its types follow. - NAME is the header file's name. - Most often this happens only once for each distinct header file, - but not necessarily. If it happens more than once, INSTANCE has - a different value each time, and references to the header file - use INSTANCE values to select among them. - - dbx output contains "begin" and "end" markers for each new header file, - but at this level we just need to know which files there have been; - so we record the file when its "begin" is seen and ignore the "end". */ - -static void -add_new_header_file (name, instance) - char *name; - int instance; -{ - register int i; - register struct header_file *p = header_files; - header_file_prev_index = -1; - -#if 0 - /* This code was used before I knew about the instance codes. - My first hypothesis is that it is not necessary now - that instance codes are handled. */ - - /* Has this header file a previous definition? - If so, make a new entry anyway so that this use in this source file - gets a separate entry. Later source files get the old entry. - Record here the index of the old entry, so that any type indices - not previously defined can get defined in the old entry as - well as in the new one. */ - - for (i = 0; i < n_header_files; i++) - if (!strcmp (p[i].name, name)) - { - header_file_prev_index = i; - } - -#endif - - /* Make sure there is room for one more header file. */ - - if (n_header_files == n_allocated_header_files) - { - n_allocated_header_files *= 2; - header_files = (struct header_file *) - xrealloc (header_files, - (n_allocated_header_files - * sizeof (struct header_file))); - } - - /* Create an entry for this header file. */ - - i = n_header_files++; - header_files[i].name = savestring (name, strlen(name)); - header_files[i].instance = instance; - header_files[i].length = 10; - header_files[i].vector - = (struct type **) xxmalloc (10 * sizeof (struct type *)); - bzero (header_files[i].vector, 10 * sizeof (struct type *)); - - add_this_object_header_file (i); -} - -/* Look up a dbx type-number pair. Return the address of the slot - where the type for that number-pair is stored. - The number-pair is in TYPENUMS. - - This can be used for finding the type associated with that pair - or for associating a new type with the pair. */ - -static struct type ** -dbx_lookup_type (typenums) - int typenums[2]; -{ - register int filenum = typenums[0], index = typenums[1]; - - if (filenum < 0 || filenum >= n_this_object_header_files) - error ("Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.", - filenum, index, symnum); - - if (filenum == 0) - { - /* Type is defined outside of header files. - Find it in this object file's type vector. */ - if (index >= type_vector_length) - { - type_vector_length *= 2; - type_vector = (struct typevector *) - xrealloc (type_vector, - (sizeof (struct typevector) - + type_vector_length * sizeof (struct type *))); - bzero (&type_vector->type[type_vector_length / 2], - type_vector_length * sizeof (struct type *) / 2); - } - return &type_vector->type[index]; - } - else - { - register int real_filenum = this_object_header_files[filenum]; - register struct header_file *f; - - if (real_filenum >= n_header_files) - abort (); - - f = &header_files[real_filenum]; - - if (index >= f->length) - { - f->length *= 2; - f->vector = (struct type **) - xrealloc (f->vector, f->length * sizeof (struct type *)); - bzero (&f->vector[f->length / 2], - f->length * sizeof (struct type *) / 2); - } - return &f->vector[index]; - } -} - -/* Create a type object. Occaisionally used when you need a type - which isn't going to be given a type number. */ - -static struct type * -dbx_create_type () -{ - register struct type *type = - (struct type *) obstack_alloc (symbol_obstack, sizeof (struct type)); - - bzero (type, sizeof (struct type)); - TYPE_VPTR_FIELDNO (type) = -1; - return type; -} - -/* Make sure there is a type allocated for type numbers TYPENUMS - and return the type object. - This can create an empty (zeroed) type object. - TYPENUMS may be (-1, -1) to return a new type object that is not - put into the type vector, and so may not be referred to by number. */ - -static struct type * -dbx_alloc_type (typenums) - int typenums[2]; -{ - register struct type **type_addr; - register struct type *type; - - if (typenums[1] != -1) - { - type_addr = dbx_lookup_type (typenums); - type = *type_addr; - } - else - { - type_addr = 0; - type = 0; - } - - /* If we are referring to a type not known at all yet, - allocate an empty type for it. - We will fill it in later if we find out how. */ - if (type == 0) - { - type = dbx_create_type (); - if (type_addr) - *type_addr = type; - } - - return type; -} - -#if 0 -static struct type ** -explicit_lookup_type (real_filenum, index) - int real_filenum, index; -{ - register struct header_file *f = &header_files[real_filenum]; - - if (index >= f->length) - { - f->length *= 2; - f->vector = (struct type **) - xrealloc (f->vector, f->length * sizeof (struct type *)); - bzero (&f->vector[f->length / 2], - f->length * sizeof (struct type *) / 2); - } - return &f->vector[index]; -} -#endif - -/* maintain the lists of symbols and blocks */ - -/* Add a symbol to one of the lists of symbols. */ -static void -add_symbol_to_list (symbol, listhead) - struct symbol *symbol; - struct pending **listhead; -{ - /* We keep PENDINGSIZE symbols in each link of the list. - If we don't have a link with room in it, add a new link. */ - if (*listhead == 0 || (*listhead)->nsyms == PENDINGSIZE) - { - register struct pending *link; - if (free_pendings) - { - link = free_pendings; - free_pendings = link->next; - } - else - link = (struct pending *) xxmalloc (sizeof (struct pending)); - - link->next = *listhead; - *listhead = link; - link->nsyms = 0; - } - - (*listhead)->symbol[(*listhead)->nsyms++] = symbol; -} - -/* At end of reading syms, or in case of quit, - really free as many `struct pending's as we can easily find. */ - -static void -really_free_pendings () -{ - struct pending *next, *next1; - struct pending_block *bnext, *bnext1; - - for (next = free_pendings; next; next = next1) - { - next1 = next->next; - free (next); - } - free_pendings = 0; - - for (bnext = pending_blocks; bnext; bnext = bnext1) - { - bnext1 = bnext->next; - free (bnext); - } - pending_blocks = 0; - - for (next = file_symbols; next; next = next1) - { - next1 = next->next; - free (next); - } - for (next = global_symbols; next; next = next1) - { - next1 = next->next; - free (next); - } -} - -/* Take one of the lists of symbols and make a block from it. - Keep the order the symbols have in the list (reversed from the input file). - Put the block on the list of pending blocks. */ - -static void -finish_block (symbol, listhead, old_blocks, start, end) - struct symbol *symbol; - struct pending **listhead; - struct pending_block *old_blocks; - CORE_ADDR start, end; -{ - register struct pending *next, *next1; - register struct block *block; - register struct pending_block *pblock; - struct pending_block *opblock; - register int i; - - /* Count the length of the list of symbols. */ - - for (next = *listhead, i = 0; next; i += next->nsyms, next = next->next); - - block = (struct block *) obstack_alloc (symbol_obstack, - (sizeof (struct block) - + ((i - 1) - * sizeof (struct symbol *)))); - - /* Copy the symbols into the block. */ - - BLOCK_NSYMS (block) = i; - for (next = *listhead; next; next = next->next) - { - register int j; - for (j = next->nsyms - 1; j >= 0; j--) - BLOCK_SYM (block, --i) = next->symbol[j]; - } - - BLOCK_START (block) = start; - BLOCK_END (block) = end; - BLOCK_SUPERBLOCK (block) = 0; /* Filled in when containing block is made */ - BLOCK_GCC_COMPILED (block) = processing_gcc_compilation; - - /* Put the block in as the value of the symbol that names it. */ - - if (symbol) - { - SYMBOL_BLOCK_VALUE (symbol) = block; - BLOCK_FUNCTION (block) = symbol; - } - else - BLOCK_FUNCTION (block) = 0; - - /* Now "free" the links of the list, and empty the list. */ - - for (next = *listhead; next; next = next1) - { - next1 = next->next; - next->next = free_pendings; - free_pendings = next; - } - *listhead = 0; - - /* Install this block as the superblock - of all blocks made since the start of this scope - that don't have superblocks yet. */ - - opblock = 0; - for (pblock = pending_blocks; pblock != old_blocks; pblock = pblock->next) - { - if (BLOCK_SUPERBLOCK (pblock->block) == 0) - BLOCK_SUPERBLOCK (pblock->block) = block; - opblock = pblock; - } - - /* Record this block on the list of all blocks in the file. - Put it after opblock, or at the beginning if opblock is 0. - This puts the block in the list after all its subblocks. */ - - /* Allocate in the symbol_obstack to save time. - It wastes a little space. */ - pblock = (struct pending_block *) - obstack_alloc (symbol_obstack, - sizeof (struct pending_block)); - pblock->block = block; - if (opblock) - { - pblock->next = opblock->next; - opblock->next = pblock; - } - else - { - pblock->next = pending_blocks; - pending_blocks = pblock; - } -} - -static struct blockvector * -make_blockvector () -{ - register struct pending_block *next, *next1; - register struct blockvector *blockvector; - register int i; - - /* Count the length of the list of blocks. */ - - for (next = pending_blocks, i = 0; next; next = next->next, i++); - - blockvector = (struct blockvector *) - obstack_alloc (symbol_obstack, - (sizeof (struct blockvector) - + (i - 1) * sizeof (struct block *))); - - /* Copy the blocks into the blockvector. - This is done in reverse order, which happens to put - the blocks into the proper order (ascending starting address). - finish_block has hair to insert each block into the list - after its subblocks in order to make sure this is true. */ - - BLOCKVECTOR_NBLOCKS (blockvector) = i; - for (next = pending_blocks; next; next = next->next) - BLOCKVECTOR_BLOCK (blockvector, --i) = next->block; - -#if 0 /* Now we make the links in the obstack, so don't free them. */ - /* Now free the links of the list, and empty the list. */ - - for (next = pending_blocks; next; next = next1) - { - next1 = next->next; - free (next); - } -#endif - pending_blocks = 0; - - return blockvector; -} - -/* Manage the vector of line numbers. */ - -static void -record_line (line, pc) - int line; - CORE_ADDR pc; -{ - struct linetable_entry *e; - /* Ignore the dummy line number in libg.o */ - - if (line == 0xffff) - return; - - /* Make sure line vector is big enough. */ - - if (line_vector_index + 1 >= line_vector_length) - { - line_vector_length *= 2; - line_vector = (struct linetable *) - xrealloc (line_vector, - (sizeof (struct linetable) - + line_vector_length * sizeof (struct linetable_entry))); - current_subfile->line_vector = line_vector; - } - - e = line_vector->item + line_vector_index++; - e->line = line; e->pc = pc; -} - -/* Start a new symtab for a new source file. - This is called when a dbx symbol of type N_SO is seen; - it indicates the start of data for one original source file. */ - -static void -start_symtab (name, start_addr) - char *name; - CORE_ADDR start_addr; -{ - register struct symtab *s; - - last_source_file = name; - last_source_start_addr = start_addr; - file_symbols = 0; - global_symbols = 0; - within_function = 0; - - /* Context stack is initially empty, with room for 10 levels. */ - context_stack - = (struct context_stack *) xxmalloc (10 * sizeof (struct context_stack)); - context_stack_size = 10; - context_stack_depth = 0; - - new_object_header_files (); - - for (s = symseg_chain; s; s = s->next) - if (s->ldsymoff == symnum * sizeof (struct nlist)) - break; - current_symseg = s; - if (s != 0) - return; - - type_vector_length = 160; - type_vector = (struct typevector *) - xxmalloc (sizeof (struct typevector) - + type_vector_length * sizeof (struct type *)); - bzero (type_vector->type, type_vector_length * sizeof (struct type *)); - - /* Initialize the list of sub source files with one entry - for this file (the top-level source file). */ - - subfiles = 0; - current_subfile = 0; - start_subfile (name); - -#if 0 /* This is now set at the beginning of read_ofile_symtab */ - /* Set default for compiler to pcc; assume that we aren't processing - a gcc compiled file until proved otherwise. */ - - processing_gcc_compilation = 0; -#endif -} - -/* Handle an N_SOL symbol, which indicates the start of - code that came from an included (or otherwise merged-in) - source file with a different name. */ - -static void -start_subfile (name) - char *name; -{ - register struct subfile *subfile; - - /* Save the current subfile's line vector data. */ - - if (current_subfile) - { - current_subfile->line_vector_index = line_vector_index; - current_subfile->line_vector_length = line_vector_length; - current_subfile->prev_line_number = prev_line_number; - } - - /* See if this subfile is already known as a subfile of the - current main source file. */ - - for (subfile = subfiles; subfile; subfile = subfile->next) - { - if (!strcmp (subfile->name, name)) - { - line_vector = subfile->line_vector; - line_vector_index = subfile->line_vector_index; - line_vector_length = subfile->line_vector_length; - prev_line_number = subfile->prev_line_number; - current_subfile = subfile; - return; - } - } - - /* This subfile is not known. Add an entry for it. */ - - line_vector_index = 0; - line_vector_length = 1000; - prev_line_number = -2; /* Force first line number to be explicit */ - line_vector = (struct linetable *) - xxmalloc (sizeof (struct linetable) - + line_vector_length * sizeof (struct linetable_entry)); - - /* Make an entry for this subfile in the list of all subfiles - of the current main source file. */ - - subfile = (struct subfile *) xxmalloc (sizeof (struct subfile)); - subfile->next = subfiles; - subfile->name = savestring (name, strlen (name)); - subfile->line_vector = line_vector; - subfiles = subfile; - current_subfile = subfile; -} - -/* Finish the symbol definitions for one main source file, - close off all the lexical contexts for that file - (creating struct block's for them), then make the struct symtab - for that file and put it in the list of all such. - - END_ADDR is the address of the end of the file's text. */ - -static void -end_symtab (end_addr) - CORE_ADDR end_addr; -{ - register struct symtab *symtab; - register struct blockvector *blockvector; - register struct subfile *subfile; - register struct linetable *lv; - struct subfile *nextsub; - - if (current_symseg != 0) - { - last_source_file = 0; - current_symseg = 0; - return; - } - - /* Finish the lexical context of the last function in the file; - pop the context stack. */ - - if (context_stack_depth > 0) - { - register struct context_stack *cstk; - context_stack_depth--; - cstk = &context_stack[context_stack_depth]; - /* Make a block for the local symbols within. */ - finish_block (cstk->name, &local_symbols, cstk->old_blocks, - cstk->start_addr, end_addr); - } - - /* Cleanup any undefined types that have been left hanging around - (this needs to be done before the finish_blocks so that - file_symbols is still good). */ - cleanup_undefined_types (); - - /* Finish defining all the blocks of this symtab. */ - finish_block (0, &file_symbols, 0, last_source_start_addr, end_addr); - finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr); - blockvector = make_blockvector (); - - current_subfile->line_vector_index = line_vector_index; - - /* Now create the symtab objects proper, one for each subfile. */ - /* (The main file is one of them.) */ - - for (subfile = subfiles; subfile; subfile = nextsub) - { - symtab = (struct symtab *) xxmalloc (sizeof (struct symtab)); - symtab->free_ptr = 0; - - /* Fill in its components. */ - symtab->blockvector = blockvector; - type_vector->length = type_vector_length; - symtab->typevector = type_vector; - symtab->free_code = free_linetable; - if (subfile->next == 0) - symtab->free_ptr = (char *) type_vector; - - symtab->filename = subfile->name; - lv = subfile->line_vector; - lv->nitems = subfile->line_vector_index; - symtab->linetable = (struct linetable *) - xrealloc (lv, (sizeof (struct linetable) - + lv->nitems * sizeof (struct linetable_entry))); - symtab->nlines = 0; - symtab->line_charpos = 0; - - /* Link the new symtab into the list of such. */ - symtab->next = symtab_list; - symtab_list = symtab; - - nextsub = subfile->next; - free (subfile); - } - - type_vector = 0; - type_vector_length = -1; - line_vector = 0; - line_vector_length = -1; - last_source_file = 0; -} - -#ifdef N_BINCL - -/* Handle the N_BINCL and N_EINCL symbol types - that act like N_SOL for switching source files - (different subfiles, as we call them) within one object file, - but using a stack rather than in an arbitrary order. */ - -struct subfile_stack -{ - struct subfile_stack *next; - char *name; - int prev_index; -}; - -struct subfile_stack *subfile_stack; - -static void -push_subfile () -{ - register struct subfile_stack *tem - = (struct subfile_stack *) xxmalloc (sizeof (struct subfile_stack)); - - tem->next = subfile_stack; - subfile_stack = tem; - if (current_subfile == 0 || current_subfile->name == 0) - abort (); - tem->name = current_subfile->name; - tem->prev_index = header_file_prev_index; -} - -static char * -pop_subfile () -{ - register char *name; - register struct subfile_stack *link = subfile_stack; - - if (link == 0) - abort (); - - name = link->name; - subfile_stack = link->next; - header_file_prev_index = link->prev_index; - free (link); - - return name; -} -#endif /* Have N_BINCL */ - -/* Accumulate the misc functions in bunches of 127. - At the end, copy them all into one newly allocated structure. */ - -#define MISC_BUNCH_SIZE 127 - -struct misc_bunch -{ - struct misc_bunch *next; - struct misc_function contents[MISC_BUNCH_SIZE]; -}; - -/* Bunch currently being filled up. - The next field points to chain of filled bunches. */ - -static struct misc_bunch *misc_bunch; - -/* Number of slots filled in current bunch. */ - -static int misc_bunch_index; - -/* Total number of misc functions recorded so far. */ - -static int misc_count; - -static void -init_misc_functions () -{ - misc_count = 0; - misc_bunch = 0; - misc_bunch_index = MISC_BUNCH_SIZE; -} - -static void -record_misc_function (name, address, type) - char *name; - CORE_ADDR address; - int type; -{ - register struct misc_bunch *new; - register unsigned char mtype; - - if (misc_bunch_index == MISC_BUNCH_SIZE) - { - new = (struct misc_bunch *) xxmalloc (sizeof (struct misc_bunch)); - misc_bunch_index = 0; - new->next = misc_bunch; - misc_bunch = new; - } - misc_bunch->contents[misc_bunch_index].name = name; - misc_bunch->contents[misc_bunch_index].address = address; - switch (type &~ N_EXT) - { - case N_TEXT: mtype = mf_text; break; - case N_DATA: mtype = mf_data; break; - case N_BSS: mtype = mf_bss; break; - case N_ABS: mtype = mf_abs; break; -#ifdef N_SETV - case N_SETV: mtype = mf_data; break; -#endif - default: mtype = mf_unknown; break; - } - misc_bunch->contents[misc_bunch_index].type = mtype; - misc_bunch_index++; - misc_count++; -} - -static int -compare_misc_functions (fn1, fn2) - struct misc_function *fn1, *fn2; -{ - /* Return a signed result based on unsigned comparisons - so that we sort into unsigned numeric order. */ - if (fn1->address < fn2->address) - return -1; - if (fn1->address > fn2->address) - return 1; - return 0; -} - -static void -discard_misc_bunches () -{ - register struct misc_bunch *next; - - while (misc_bunch) - { - next = misc_bunch->next; - free (misc_bunch); - misc_bunch = next; - } -} - -/* INCLINK nonzero means bunches are from an incrementally-linked file. - Add them to the existing bunches. - Otherwise INCLINK is zero, and we start from scratch. */ -static void -condense_misc_bunches (inclink) - int inclink; -{ - register int i, j; - register struct misc_bunch *bunch; -#ifdef NAMES_HAVE_UNDERSCORE - int offset = 1; -#else - int offset = 0; -#endif - - if (inclink) - { - misc_function_vector - = (struct misc_function *) - xrealloc (misc_function_vector, (misc_count + misc_function_count) - * sizeof (struct misc_function)); - j = misc_function_count; - } - else - { - misc_function_vector - = (struct misc_function *) - xxmalloc (misc_count * sizeof (struct misc_function)); - j = 0; - } - - bunch = misc_bunch; - while (bunch) - { - for (i = 0; i < misc_bunch_index; i++) - { - misc_function_vector[j] = bunch->contents[i]; - misc_function_vector[j].name - = obconcat (misc_function_vector[j].name - + (misc_function_vector[j].name[0] == '_' ? offset : 0), - "", ""); - j++; - } - bunch = bunch->next; - misc_bunch_index = MISC_BUNCH_SIZE; - } - - if (inclink) - misc_function_count += misc_count; - else - misc_function_count = j; - - /* Sort the misc functions by address. */ - - qsort (misc_function_vector, misc_function_count, - sizeof (struct misc_function), - compare_misc_functions); - - /* (re)build the hash table (positions changed during the sort) */ - - for (i = 0; i < MISC_FUNC_HASH_SIZE; ++i) - misc_function_hash_tab[i] = -1; - for (i = 0; i < misc_function_count; ++i) - { - j = hash_symbol(misc_function_vector[i].name) & (MISC_FUNC_HASH_SIZE - 1); - misc_function_vector[i].next = misc_function_hash_tab[j]; - misc_function_hash_tab[j] = i; - } -} - -/* Call sort_syms to sort alphabetically - the symbols of each block of each symtab. */ - -static int -compare_symbols (s1, s2) - struct symbol **s1, **s2; -{ - register int namediff; - - /* Compare the initial characters. */ - namediff = SYMBOL_NAME (*s1)[0] - SYMBOL_NAME (*s2)[0]; - if (namediff != 0) return namediff; - - /* If they match, compare the rest of the names. */ - namediff = strcmp (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2)); - if (namediff != 0) return namediff; - - /* For symbols of the same name, registers should come first. */ - return ((SYMBOL_CLASS (*s2) == LOC_REGISTER) - - (SYMBOL_CLASS (*s1) == LOC_REGISTER)); -} - -static void sort_symtab_syms (); - -static void -sort_syms () -{ - register struct symtab *s; - - for (s = symtab_list; s; s = s->next) - sort_symtab_syms (s); -} - -static void -sort_symtab_syms (s) - register struct symtab *s; -{ - register struct blockvector *bv = BLOCKVECTOR (s); - int nbl = BLOCKVECTOR_NBLOCKS (bv); - int i; - register struct block *b; - - /* Note that in the following sort, we always make sure that - register debug symbol declarations always come before regular - debug symbol declarations (as might happen when parameters are - then put into registers by the compiler). We do this by a - correct compare in compare_symbols, and by the reversal of the - symbols if we don't sort. This works as long as a register debug - symbol always comes after a parameter debug symbol. */ - - /* This is no longer necessary; lookup_block_symbol now always - prefers some other declaration over a parameter declaration. We - still sort the thing (that is necessary), but we don't reverse it - if we shouldn't sort it. */ - - for (i = 0; i < nbl; i++) - { - b = BLOCKVECTOR_BLOCK (bv, i); - if (BLOCK_SHOULD_SORT (b)) - qsort (&BLOCK_SYM (b, 0), BLOCK_NSYMS (b), - sizeof (struct symbol *), compare_symbols); - } -} - - -extern struct symtab *psymtab_to_symtab (); - -/* The entry point. */ -static CORE_ADDR entry_point; - -static char *symfile_string_table; -static int symfile_string_table_size; - -/* This is the symbol-file command. Read the file, analyze its symbols, - and add a struct symtab to symtab_list. */ - -void -symbol_file_command (name, from_tty) - char *name; - int from_tty; -{ - register int desc; - DECLARE_FILE_HEADERS; - struct nlist *nlist; - - /* The string table. */ - char *stringtab; - - /* The size of the string table (buffer is a bizarre name...). */ - long buffer; - - register int val; - extern void close (); - struct cleanup *old_chain; - struct symtab *symseg; - struct stat statbuf; - - dont_repeat (); - - if (name == 0) - { - if ((symtab_list || partial_symtab_list) - && from_tty - && !query ("Discard symbol table? ", 0)) - error ("Not confirmed."); - if (symfile) - free (symfile); - symfile = 0; - free_all_symtabs (); - free_all_psymtabs (); - return; - } - - name = tilde_expand (name); - make_cleanup (free, name); - - if ((symtab_list || partial_symtab_list) - && !query ("Load new symbol table from \"%s\"? ", name)) - error ("Not confirmed."); - - { - char *absolute_name; - desc = openp (getenv ("PATH"), 1, name, O_RDONLY, 0, &absolute_name); - if (desc < 0) - perror_with_name (name); - else - name = absolute_name; - } - - old_chain = make_cleanup (close, desc); - make_cleanup (free_current_contents, &name); - - READ_FILE_HEADERS (desc, name); - - entry_point = ENTRY_POINT; - - if (NUMBER_OF_SYMBOLS == 0) - { - if (symfile) - free (symfile); - symfile = 0; - free_all_symtabs (); - free_all_psymtabs (); - printf ("%s has no symbol-table; symbols discarded.\n", name); - fflush (stdout); - do_cleanups (old_chain); - return; - } - - printf ("Reading symbol data from %s...", name); - fflush (stdout); - - /* Now read the string table, all at once. */ - val = lseek (desc, STRING_TABLE_OFFSET, 0); - if (val < 0) - perror_with_name (name); - if (stat (name, &statbuf) == -1) - perror_with_name (name); - READ_STRING_TABLE_SIZE (buffer); - if (buffer >= 0 && buffer < statbuf.st_size) - { - /* This should speed things up without consuming much - extra memory (because probably little of the space is going - to be reused anyway, whether in data or stack space). - - A quick test (running GDB on itself and setting 9 breakpoints - in different files) showed that memory usage was almost - identical for the two cases. */ -#if 0 -#ifdef BROKEN_LARGE_ALLOCA - stringtab = (char *) xmalloc (buffer); - make_cleanup (free, stringtab); -#else - stringtab = (char *) alloca (buffer); -#endif -#endif - stringtab = (char *) xmalloc (buffer); - symfile_string_table = stringtab; - symfile_string_table_size = buffer; - } - else - stringtab = NULL; - if (stringtab == NULL) - error ("ridiculous string table size: %d bytes", buffer); - - /* Usually READ_STRING_TABLE_SIZE will have shifted the file pointer. - Occaisionally, it won't. */ - val = lseek (desc, STRING_TABLE_OFFSET, L_SET); - if (val < 0) - perror_with_name (name); - val = myread (desc, stringtab, buffer); - if (val < 0) - perror_with_name (name); - - /* Throw away the old symbol table. */ - - if (symfile) - free (symfile); - symfile = 0; - free_all_symtabs (); - free_all_psymtabs (); - - /* Empty the hash table of global syms looking for values. */ - bzero (global_sym_chain, sizeof global_sym_chain); - - /* Symsegs are no longer supported by GDB. Setting symseg_chain to - 0 is easier than finding all the symseg code and eliminating it. */ - symseg_chain = 0; - - /* Position to read the symbol table. Do not read it all at once. */ - val = lseek (desc, SYMBOL_TABLE_OFFSET, 0); - if (val < 0) - perror_with_name (name); - - /* Don't put these on the cleanup chain; they need to stick around - until the next call to symbol_file_command. *Then* we'll free - them. */ - free_header_files (); - init_header_files (); - - init_misc_functions (); - make_cleanup (discard_misc_bunches, 0); - - free_pendings = 0; - pending_blocks = 0; - file_symbols = 0; - global_symbols = 0; - make_cleanup (really_free_pendings, 0); - - /* Now that the symbol table data of the executable file are all in core, - process them and define symbols accordingly. Closes desc. */ - - read_dbx_symtab (desc, stringtab, buffer, NUMBER_OF_SYMBOLS, 0, - ADDR_OF_TEXT_SEGMENT, SIZE_OF_TEXT_SEGMENT); - - /* Go over the misc functions and install them in vector. */ - - condense_misc_bunches (0); - - /* Don't allow char * to have a typename (else would get caddr_t.) */ - - TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0; - - /* Make a default for file to list. */ - - symfile = savestring (name, strlen (name)); - - /* Call to select_source_symtab used to be here; it was using too - much time. I'll make sure that list_sources can handle the lack - of current_source_symtab */ - - do_cleanups (old_chain); /* Descriptor closed here */ - - /* Free the symtabs made by read_symsegs, but not their contents, - which have been copied into symtabs on symtab_list. */ - while (symseg_chain) - { - register struct symtab *s = symseg_chain->next; - free (symseg_chain); - symseg_chain = s; - } - - if (!partial_symtab_list) - printf ("\n(no debugging symbols found)..."); - - printf ("done.\n"); - fflush (stdout); -} - -/* Return name of file symbols were loaded from, or 0 if none.. */ - -char * -get_sym_file () -{ - return symfile; -} - -/* Buffer for reading the symbol table entries. */ -static struct nlist symbuf[4096]; -static int symbuf_idx; -static int symbuf_end; - -/* I/O descriptor for reading the symbol table. */ -static int symtab_input_desc; - -/* The address of the string table - of the object file we are reading (as copied into core). */ -static char *stringtab_global; - -/* Refill the symbol table input buffer - and set the variables that control fetching entries from it. - Reports an error if no data available. - This function can read past the end of the symbol table - (into the string table) but this does no harm. */ - -static int -fill_symbuf () -{ - int nbytes = myread (symtab_input_desc, symbuf, sizeof (symbuf)); - if (nbytes <= 0) - error ("error or end of file reading symbol table"); - symbuf_end = nbytes / sizeof (struct nlist); - symbuf_idx = 0; - return 1; -} - -/* dbx allows the text of a symbol name to be continued into the - next symbol name! When such a continuation is encountered - (a \ at the end of the text of a name) - call this function to get the continuation. */ - -static char * -next_symbol_text () -{ - if (symbuf_idx == symbuf_end) - fill_symbuf (); - symnum++; - return symbuf[symbuf_idx++].n_un.n_strx + stringtab_global; -} - -/* - * Initializes storage for all of the partial symbols that will be - * created by read_dbx_symtab and subsidiaries. - */ -void -init_psymbol_list (total_symbols) - int total_symbols; -{ - /* Current best guess is that there are approximately a twentieth - of the total symbols (in a debugging file) are global or static - oriented symbols */ - global_psymbols.size = total_symbols / 10; - static_psymbols.size = total_symbols / 10; - global_psymbols.next = global_psymbols.list = (struct partial_symbol *) - xmalloc (global_psymbols.size * sizeof (struct partial_symbol)); - static_psymbols.next = static_psymbols.list = (struct partial_symbol *) - xmalloc (static_psymbols.size * sizeof (struct partial_symbol)); -} - -/* - * Initialize the list of bincls to contain none and have some - * allocated. - */ -static void -init_bincl_list (number) - int number; -{ - bincls_allocated = number; - next_bincl = bincl_list = (struct header_file_location *) - xmalloc (bincls_allocated * sizeof(struct header_file_location)); -} - -/* - * Add a bincl to the list. - */ -static void -add_bincl_to_list (pst, name, instance) - struct partial_symtab *pst; - char *name; - int instance; -{ - if (next_bincl >= bincl_list + bincls_allocated) - { - int offset = next_bincl - bincl_list; - bincls_allocated *= 2; - bincl_list = (struct header_file_location *) - xrealloc (bincl_list, - bincls_allocated * sizeof (struct header_file_location)); - next_bincl = bincl_list + offset; - } - next_bincl->pst = pst; - next_bincl->instance = instance; - next_bincl++->name = name; -} - -/* - * Given a name, value pair, find the corresponding - * bincl in the list. Return the partial symtab associated - * with that header_file_location. - */ -struct partial_symtab * -find_corresponding_bincl_psymtab (name, instance) - char *name; - int instance; -{ - struct header_file_location *bincl; - - for (bincl = bincl_list; bincl < next_bincl; bincl++) - if (bincl->instance == instance - && !strcmp (name, bincl->name)) - return bincl->pst; - - return (struct partial_symtab *) 0; -} - -/* - * Free the storage allocated for the bincl list. - */ -static void -free_bincl_list () -{ - free (bincl_list); - bincls_allocated = 0; -} - -static struct partial_symtab *start_psymtab (); -static void add_psymtab_dependency (); -static void end_psymtab(); - -static int -compare_psymbols (s1, s2) - register struct partial_symbol *s1, *s2; -{ - register char - *st1 = SYMBOL_NAME (s1), - *st2 = SYMBOL_NAME (s2); - register int i; - - if (st1[0] - st2[0]) - return (st1[0] - st2[0]); - if (st1[1] - st2[1]) - return (st1[1] - st2[1]); - if (i = strcmp(st1, st2)) - return (i); - /* Next comparison implements policy that used to be in lookup_symbol: - * it would search psymtabs in psymtab_list order (reverse order of - * declaration) & take first occurance of symbol it found. So, we - * collate duplicate names in reverse psymtab order. */ - return (s2->pst - s1->pst); -} - -/* Given pointers to an a.out symbol table in core containing dbx - style data, setup partial_symtab's describing each source file for - which debugging information is available. NLISTLEN is the number - of symbols in the symbol table. All symbol names are given as - offsets relative to STRINGTAB. STRINGTAB_SIZE is the size of - STRINGTAB. - - I have no idea whether or not this routine should be setup to deal - with inclinks. It seems reasonable to me that they be dealt with - standardly, so I am not going to make a strong effort to deal with - them here. - */ - -static void -read_dbx_symtab (desc, stringtab, stringtab_size, nlistlen, inclink, - text_addr, text_size) - int desc; - register char *stringtab; - register long stringtab_size; - register int nlistlen; - int inclink; - unsigned text_addr; - int text_size; -{ - register struct nlist *bufp; - register char *namestring; - register struct partial_symbol *psym; - register struct psymbol_allocation_list *psymbol_struct; - - int nsl; - int past_first_source_file = 0; - CORE_ADDR last_o_file_start = 0; - char *last_o_file_name = "*bogus*"; - struct cleanup *old_chain; - char *p; - enum namespace ns; - enum address_class class; - -#ifdef PROFILE_TYPES - int i; - int profile_types [256]; - int strcmp_called = 0; - int autovars = 0; - int global_funs = 0; -#endif - - /* Current partial symtab */ - struct partial_symtab *pst; - - /* List of current psymtab's include files */ - char **psymtab_include_list; - int includes_allocated; - int includes_used; - - /* Index within current psymtab dependency list */ - struct partial_symtab **dependency_list; - int dependencies_used, dependencies_allocated; - -#ifdef PROFILE_TYPES - for (i = 0; i < 256; i++) - profile_types[i] = 0; -#endif - - stringtab_global = stringtab; - - pst = (struct partial_symtab *) 0; - - includes_allocated = 30; - includes_used = 0; - psymtab_include_list = (char **) alloca (includes_allocated * - sizeof (char *)); - - dependencies_allocated = 30; - dependencies_used = 0; - dependency_list = - (struct partial_symtab **) alloca (dependencies_allocated * - sizeof (struct partial_symtab *)); - - old_chain = make_cleanup (free_all_psymtabs, 0); - - /* Init bincl list */ - init_bincl_list (20); - make_cleanup (free_bincl_list, 0); - - /* Setup global partial symbol list */ - init_psymbol_list (nlistlen); - - last_source_file = 0; - -#ifdef END_OF_TEXT_DEFAULT - end_of_text_addr = END_OF_TEXT_DEFAULT; -#else - end_of_text_addr = text_addr + text_size; -#endif - - symtab_input_desc = desc; /* This is needed for fill_symbuf below */ - symbuf_end = symbuf_idx = 0; - - for (symnum = 0; symnum < nlistlen; symnum++) - { - /* Get the symbol for this run and pull out some info */ - QUIT; /* allow this to be interruptable */ - if (symbuf_idx == symbuf_end) - fill_symbuf (); - bufp = &symbuf[symbuf_idx++]; - -#ifdef PROFILE_TYPES - profile_types[bufp->n_type]++; -#endif - - /* - * Special case to speed up readin. - */ - if (bufp->n_type == N_SLINE) continue; - - /* Ok. There is a lot of code duplicated in the rest of this - switch statiement (for efficiency reasons). Since I don't - like duplicating code, I will do my penance here, and - describe the code which is duplicated: - - *) The assignment to namestring. - *) The call to index. - *) The addition of a partial symbol the the two partial - symbol lists. This last is a large section of code, so - I've imbedded it in the following macro. - */ - -/* Set namestring based on bufp. */ -#define SET_NAMESTRING()\ - if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size) \ - error ("Invalid symbol data: bad string table offset: %d", \ - bufp->n_un.n_strx); \ - namestring = bufp->n_un.n_strx + stringtab - -#define ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE)\ - do { \ - if ((LIST).next >= \ - (LIST).list + (LIST).size) \ - { \ - (LIST).list = (struct partial_symbol *) \ - xrealloc ((LIST).list, \ - ((LIST).size * 2 \ - * sizeof (struct partial_symbol))); \ - /* Next assumes we only went one over. Should be good if \ - program works correctly */ \ - (LIST).next = \ - (LIST).list + (LIST).size; \ - (LIST).size *= 2; \ - } \ - psym = (LIST).next++; \ - \ - SYMBOL_NAME (psym) = (char *) obstack_alloc (psymbol_obstack, \ - (NAMELENGTH) + 1); \ - strncpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH)); \ - SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0'; \ - SYMBOL_NAMESPACE (psym) = (NAMESPACE); \ - SYMBOL_CLASS (psym) = (CLASS); \ - SYMBOL_VALUE (psym) = (VALUE); \ - } while (0); - - - switch (bufp->n_type) - { - /* - * Standard, non-debugger, symbols - */ - - case N_TEXT | N_EXT: - /* Catch etext */ - - SET_NAMESTRING(); - - if (namestring[6] == '\0' && namestring[5] == 't' - && namestring[4] == 'x' && namestring[3] == 'e' - && namestring[2] == 't' && namestring[1] == 'e' - && namestring[0] == '_') - end_of_text_addr = bufp->n_value; - - /* Figure out beginning and end of global linker symbol - section and put non-debugger specified symbols on - tmp_symchain */ - - last_global_sym = symnum; - if (!first_global_sym) first_global_sym = symnum; - - record_misc_function (namestring, bufp->n_value, - bufp->n_type); /* Always */ - - continue; - -#ifdef N_NBTEXT - case N_NBTEXT | N_EXT: -#endif -#ifdef N_NBDATA - case N_NBDATA | N_EXT: -#endif -#ifdef N_NBBSS - case N_NBBSS | N_EXT: -#endif -#ifdef N_SETV - case N_SETV | N_EXT: -#endif - case N_ABS | N_EXT: - case N_DATA | N_EXT: - case N_BSS | N_EXT: - /* Figure out beginning and end of global linker symbol - section and put non-debugger specified symbols on - tmp_symchain */ - - SET_NAMESTRING(); - - last_global_sym = symnum; - if (!first_global_sym) first_global_sym = symnum; - - /* Not really a function here, but... */ - record_misc_function (namestring, bufp->n_value, - bufp->n_type); /* Always */ - - continue; - -#ifdef N_NBTEXT - case N_NBTEXT: -#endif - - /* We need to be able to deal with both N_FN or N_TEXT, - because we have no way of knowing whether the sys-supplied ld - or GNU ld was used to make the executable. */ -#if ! (N_FN & N_EXT) - case N_FN: -#endif - case N_FN | N_EXT: - case N_TEXT: - SET_NAMESTRING(); - if ((namestring[0] == '-' && namestring[1] == 'l') - || (namestring [(nsl = strlen (namestring)) - 1] == 'o' - && namestring [nsl - 2] == '.')) - { - if (entry_point < bufp->n_value - && entry_point >= last_o_file_start) - { - startup_file_start = last_o_file_start; - startup_file_end = bufp->n_value; - } - if (past_first_source_file && pst) - { - end_psymtab (pst, psymtab_include_list, includes_used, - symnum * sizeof (struct nlist), bufp->n_value, - dependency_list, dependencies_used, - global_psymbols.next, static_psymbols.next); - pst = (struct partial_symtab *) 0; - includes_used = 0; - dependencies_used = 0; - } - else - past_first_source_file = 1; - last_o_file_start = bufp->n_value; - last_o_file_name = namestring; - nsl = strlen(namestring); - if (namestring[nsl-2] == '.' && namestring[nsl-1] == 'o') - namestring[nsl-2] = 0; - } - else if (strcmp(namestring, "gcc_compiled.")) - { - if (*namestring == '_') - ++namestring; - namestring = obconcat(last_o_file_name, ":", namestring); - last_global_sym = symnum; - if (!first_global_sym) - first_global_sym = symnum; - record_misc_function(namestring, bufp->n_value, bufp->n_type); - } - continue; - - case N_ABS: - case N_DATA: - case N_BSS: - SET_NAMESTRING(); - if (*namestring == '_') - ++namestring; - namestring = obconcat(last_o_file_name, ":", namestring); - last_global_sym = symnum; - if (!first_global_sym) - first_global_sym = symnum; - record_misc_function(namestring, bufp->n_value, bufp->n_type); - continue; - - case N_UNDF: - case N_UNDF | N_EXT: -#ifdef N_NBDATA - case N_NBDATA: -#endif -#ifdef N_NBBSS - case N_NBBSS: -#endif - - /* Keep going . . .*/ - - /* - * Special symbol types for GNU - */ -#ifdef N_INDR - case N_INDR: - case N_INDR | N_EXT: -#endif -#ifdef N_SETA - case N_SETA: - case N_SETA | N_EXT: - case N_SETT: - case N_SETT | N_EXT: - case N_SETD: - case N_SETD | N_EXT: - case N_SETB: - case N_SETB | N_EXT: - case N_SETV: -#endif - -#ifdef N_SIZE - case N_SIZE: - case N_SIZE | N_EXT: -#endif - continue; - - /* - * Debugger symbols - */ - - case N_SO: - /* End the current partial symtab and start a new one */ - - SET_NAMESTRING(); - - if (pst && past_first_source_file) - { - end_psymtab (pst, psymtab_include_list, includes_used, - symnum * sizeof (struct nlist), bufp->n_value, - dependency_list, dependencies_used, - global_psymbols.next, static_psymbols.next); - pst = (struct partial_symtab *) 0; - includes_used = 0; - dependencies_used = 0; - } - else - past_first_source_file = 1; - - pst = start_psymtab (namestring, bufp->n_value, - symnum * sizeof (struct nlist), - global_psymbols.next, static_psymbols.next); - - continue; - -#ifdef N_BINCL - case N_BINCL: - /* Add this bincl to the bincl_list for future EXCLs. No - need to save the string; it'll be around until - read_dbx_symtab function return */ - - SET_NAMESTRING(); - - add_bincl_to_list (pst, namestring, bufp->n_value); - - /* Mark down an include file in the current psymtab */ - - psymtab_include_list[includes_used++] = namestring; - if (includes_used >= includes_allocated) - { - char **orig = psymtab_include_list; - - psymtab_include_list = (char **) - alloca ((includes_allocated *= 2) * - sizeof (char *)); - bcopy (orig, psymtab_include_list, - includes_used * sizeof (char *)); - } - - continue; -#endif - - case N_SOL: - /* Mark down an include file in the current psymtab */ - - SET_NAMESTRING(); - - /* In C++, one may expect the same filename to come round many - times, when code is coming alternately from the main file - and from inline functions in other files. So I check to see - if this is a file we've seen before. - - This seems to be a lot of time to be spending on N_SOL, but - things like "break expread.y:435" need to work (I - suppose the psymtab_include_list could be hashed or put - in a binary tree, if profiling shows this is a major hog). */ - { - register int i; - for (i = 0; i < includes_used; i++) - if (!strcmp (namestring, psymtab_include_list[i])) - { - i = -1; - break; - } - if (i == -1) - continue; - } - - psymtab_include_list[includes_used++] = namestring; - if (includes_used >= includes_allocated) - { - char **orig = psymtab_include_list; - - psymtab_include_list = (char **) - alloca ((includes_allocated *= 2) * - sizeof (char *)); - bcopy (orig, psymtab_include_list, - includes_used * sizeof (char *)); - } - continue; - - case N_LSYM: /* Typedef or automatic variable. */ - SET_NAMESTRING(); - - p = (char *) index (namestring, ':'); - - /* Skip if there is no :. */ - if (!p) continue; - - switch (p[1]) - { - case 'T': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - STRUCT_NAMESPACE, LOC_TYPEDEF, - static_psymbols, bufp->n_value); - goto check_enum; - case 't': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_TYPEDEF, - static_psymbols, bufp->n_value); - check_enum: - /* If this is an enumerated type, we need to - add all the enum constants to the partial symbol - table. This does not cover enums without names, e.g. - "enum {a, b} c;" in C, but fortunately those are - rare. There is no way for GDB to find those from the - enum type without spending too much time on it. Thus - to solve this problem, the compiler needs to put out separate - constant symbols ('c' N_LSYMS) for enum constants in - enums without names. */ - - /* We are looking for something of the form - ":" ("t" | "T") [ "="] "e" - { ":" ","} ";". */ - - /* Skip over the colon and the 't' or 'T'. */ - p += 2; - /* This type may be given a number. Skip over it. */ - while ((*p >= '0' && *p <= '9') - || *p == '=') - p++; - - if (*p++ == 'e') - { - /* We have found an enumerated type. */ - /* According to comments in read_enum_type - a comma could end it instead of a semicolon. - I don't know where that happens. - Accept either. */ - while (*p && *p != ';' && *p != ',') - { - char *q; - - /* Check for and handle cretinous dbx symbol name - continuation! */ - if (*p == '\\') - p = next_symbol_text (); - - /* Point to the character after the name - of the enum constant. */ - for (q = p; *q && *q != ':'; q++) - ; - /* Note that the value doesn't matter for - enum constants in psymtabs, just in symtabs. */ - ADD_PSYMBOL_TO_LIST (p, q - p, - VAR_NAMESPACE, LOC_CONST, - static_psymbols, 0); - /* Point past the name. */ - p = q; - /* Skip over the value. */ - while (*p && *p != ',') - p++; - /* Advance past the comma. */ - if (*p) - p++; - } - } - - continue; - case 'c': - /* Constant, e.g. from "const" in Pascal. */ - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_CONST, - static_psymbols, bufp->n_value); - continue; - default: -#ifdef PROFILE_TYPES - if (isalpha(p[1])) - printf ("Funny...LSYM with a letter that isn't a type\n"); - autovars++; -#endif - /* Skip if the thing following the : is - not a letter (which indicates declaration of a local - variable, which we aren't interested in). */ - continue; - } - - case N_FUN: -#if 0 - /* This special-casing of N_FUN is just wrong; N_FUN - does not mean "function"; it means "text segment". - So N_FUN can go with 'V', etc. as well as 'f' or 'F'. */ - - SET_NAMESTRING(); - - p = (char *) index (namestring, ':'); - - if (!p || p[1] == 'F') continue; - -#ifdef PROFILE_TYPES - if (p[1] != 'f') - printf ("Funny...FUN with a letter that isn't 'F' or 'f'.\n"); - global_funs++; -#endif - - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_BLOCK, - static_psymbols, bufp->n_value); - - continue; -#endif /* 0 */ - case N_GSYM: /* Global (extern) variable; can be - data or bss (sigh). */ - case N_STSYM: /* Data seg var -- static */ - case N_LCSYM: /* BSS " */ - - /* Following may probably be ignored; I'll leave them here - for now (until I do Pascal and Modula 2 extensions). */ - - case N_PC: /* I may or may not need this; I - suspect not. */ -#ifdef N_M2C - case N_M2C: /* I suspect that I can ignore this here. */ - case N_SCOPE: /* Same. */ -#endif - - SET_NAMESTRING(); - - p = (char *) index (namestring, ':'); - if (!p) - continue; /* Not a debugging symbol. */ - - process_symbol_for_psymtab: - - /* Main processing section for debugging symbols which - the initial read through the symbol tables needs to worry - about. If we reach this point, the symbol which we are - considering is definitely one we are interested in. - p must also contain the (valid) index into the namestring - which indicates the debugging type symbol. */ - - switch (p[1]) - { - case 'c': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_CONST, - static_psymbols, bufp->n_value); - continue; - case 'S': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_STATIC, - static_psymbols, bufp->n_value); - continue; - case 'G': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_EXTERNAL, - global_psymbols, bufp->n_value); - continue; - - case 't': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_TYPEDEF, - global_psymbols, bufp->n_value); - continue; - - case 'f': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_BLOCK, - static_psymbols, bufp->n_value); - continue; - - /* Two things show up here (hopefully); static symbols of - local scope (static used inside braces) or extensions - of structure symbols. We can ignore both. */ - case 'V': - case '(': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - /* Global functions are ignored here. I'm not - sure what psymtab they go into (or just the misc - function vector). */ - case 'F': - continue; - - default: - fatal ("Internal error: Unexpected debugging symbol type '%c' at symnum %d.\n", - p[1], symnum); - } - -#ifdef N_BINCL - case N_EXCL: - - SET_NAMESTRING(); - - /* Find the corresponding bincl and mark that psymtab on the - psymtab dependency list */ - { - struct partial_symtab *needed_pst = - find_corresponding_bincl_psymtab (namestring, bufp->n_value); - - /* If this include file was defined earlier in this file, - leave it alone. */ - if (needed_pst == pst) continue; - - if (needed_pst) - { - int i; - int found = 0; - - for (i = 0; i < dependencies_used; i++) - if (dependency_list[i] == needed_pst) - { - found = 1; - break; - } - - /* If it's already in the list, skip the rest. */ - if (found) continue; - - dependency_list[dependencies_used++] = needed_pst; - if (dependencies_used >= dependencies_allocated) - { - struct partial_symtab **orig = dependency_list; - dependency_list = - (struct partial_symtab **) - alloca ((dependencies_allocated *= 2) - * sizeof (struct partial_symtab *)); - bcopy (orig, dependency_list, - (dependencies_used - * sizeof (struct partial_symtab *))); -#ifdef DEBUG_INFO - fprintf (stderr, "Had to reallocate dependency list.\n"); - fprintf (stderr, "New dependencies allocated: %d\n", - dependencies_allocated); -#endif - } - } - else - error ("Invalid symbol data: \"repeated\" header file not previously seen, at symtab pos %d.", - symnum); - } - continue; - - case N_EINCL: -#endif -#ifdef N_DSLINE - case N_DSLINE: -#endif -#ifdef N_BSLINE - case N_BSLINE: -#endif - case N_SSYM: /* Claim: Structure or union element. - Hopefully, I can ignore this. */ - case N_ENTRY: /* Alternate entry point; can ignore. */ -#ifdef N_MAIN - case N_MAIN: /* Can definitely ignore this. */ -#endif - case N_LENG: - case N_BCOMM: - case N_ECOMM: - case N_ECOML: - case N_FNAME: - case N_SLINE: - case N_RSYM: - case N_PSYM: - case N_LBRAC: - case N_RBRAC: - /* These symbols aren't interesting; don't worry about them */ - - continue; - - default: - /* If we haven't found it yet, we've got problems */ - - if (IGNORE_SYMBOL (bufp->n_type)) - continue; - - fatal ("Bad symbol type 0x%x encountered in gdb scan", bufp->n_type); - } - } - - /* If there's stuff to be cleaned up, clean it up. */ - if (entry_point < bufp->n_value - && entry_point >= last_o_file_start) - { - startup_file_start = last_o_file_start; - startup_file_end = bufp->n_value; - } - - if (pst) - { - end_psymtab (pst, psymtab_include_list, includes_used, - symnum * sizeof (struct nlist), end_of_text_addr, - dependency_list, dependencies_used, - global_psymbols.next, static_psymbols.next); - includes_used = 0; - dependencies_used = 0; - pst = (struct partial_symtab *) 0; - } - - /* sort the global & static symtab list so we can binary search them */ - qsort (global_psymbols.list, global_psymbols.next - global_psymbols.list, - sizeof (struct partial_symbol), compare_psymbols); - qsort (static_psymbols.list, static_psymbols.next - static_psymbols.list, - sizeof (struct partial_symbol), compare_psymbols); - free_bincl_list (); - discard_cleanups (old_chain); -#ifdef PROFILE_TYPES - { - int i, j; -#define __define_stab(SYM, NUMBER, NAME) {NUMBER, NAME}, - static struct xyzzy { - unsigned char symnum; - char *name; - } tmp_list[] = { -#include "stab.def" - {0x1, "eREF"}, - {0x2, "ABS"}, - {0x3, "eABS"}, - {0x4, "TEXT"}, - {0x5, "eTEXT"}, - {0x6, "DATA"}, - {0x7, "eDATA"}, - {0x8, "BSS"}, - {0x9, "eBSS"}, - {0x12, "COMM"}, - {0x13, "eCOMM"}, - {0x1f, "FN"}, - {0, "Unknown"}, -}; - for (i = 0; i < 256; i++) - { - for (j = 0; j < (sizeof (tmp_list) / sizeof (struct xyzzy)) - 1; j++) - if (tmp_list[j].symnum == i) - break; - printf ("Symbol \"%s\" (0x%x) occured %d times.\n", - tmp_list[j].name, i, profile_types[i]); - } - printf ("Auto vars (under LSYM): %d\n", autovars); - printf ("Global funs (under FUN): %d\n", global_funs); - } -#endif -} - -/* - * Allocate and partially fill a partial symtab. It will be - * completely filled at the end of the symbol list. - */ -static struct partial_symtab * -start_psymtab (filename, textlow, ldsymoff, global_syms, static_syms) - char *filename; - int textlow; - int ldsymoff; - struct partial_symbol *global_syms; - struct partial_symbol *static_syms; -{ - struct partial_symtab *result = - (struct partial_symtab *) obstack_alloc (psymbol_obstack, - sizeof (struct partial_symtab)); - - result->filename = - (char *) obstack_alloc (psymbol_obstack, - strlen (filename) + 1); - strcpy (result->filename, filename); - - result->textlow = textlow; - result->ldsymoff = ldsymoff; - - result->readin = 0; - - result->globals_offset = global_syms - global_psymbols.list; - result->statics_offset = static_syms - static_psymbols.list; - - result->n_global_syms = 0; - result->n_static_syms = 0; - - return result; -} - - -/* Close off the current usage of a partial_symbol table entry. This - involves setting the correct number of includes (with a realloc), - setting the high text mark, setting the symbol length in the - executable, and setting the length of the global and static lists - of psymbols. - - The global symbols and static symbols are then seperately sorted. - - Then the partial symtab is put on the global list. - *** List variables and peculiarities of same. *** - */ -static void -end_psymtab (pst, include_list, num_includes, capping_symbol_offset, - capping_text, dependency_list, number_dependencies, - capping_global, capping_static) - struct partial_symtab *pst; - char **include_list; - int num_includes; - int capping_symbol_offset; - int capping_text; - struct partial_symtab **dependency_list; - int number_dependencies; - struct partial_symbol *capping_global, *capping_static; -{ - int i; - register struct partial_symbol *ps; - - pst->ldsymlen = capping_symbol_offset - pst->ldsymoff; - pst->texthigh = capping_text; - - pst->n_global_syms = - capping_global - (global_psymbols.list + pst->globals_offset); - pst->n_static_syms = - capping_static - (static_psymbols.list + pst->statics_offset); - - pst->dependencies = (struct partial_symtab **) - obstack_alloc (psymbol_obstack, - number_dependencies * sizeof (struct partial_symtab *)); - bcopy (dependency_list, pst->dependencies, - number_dependencies * sizeof (struct partial_symtab *)); - pst->number_of_dependencies = number_dependencies; - - for (i = 0; i < num_includes; i++) - { - /* Eventually, put this on obstack */ - struct partial_symtab *subpst = - (struct partial_symtab *) - obstack_alloc (psymbol_obstack, - sizeof (struct partial_symtab)); - - subpst->filename = - (char *) obstack_alloc (psymbol_obstack, - strlen (include_list[i]) + 1); - strcpy (subpst->filename, include_list[i]); - - subpst->ldsymoff = - subpst->ldsymlen = - subpst->textlow = - subpst->texthigh = 0; - subpst->readin = 0; - - subpst->dependencies = (struct partial_symtab **) - obstack_alloc (psymbol_obstack, - sizeof (struct partial_symtab *)); - subpst->dependencies[0] = pst; - subpst->number_of_dependencies = 1; - - subpst->globals_offset = - subpst->n_global_syms = - subpst->statics_offset = - subpst->n_static_syms = 0; - - subpst->next = partial_symtab_list; - partial_symtab_list = subpst; - } - - for (ps = global_psymbols.list + pst->globals_offset; - ps < capping_global; ++ps) - ps->pst = pst; - for (ps = static_psymbols.list + pst->statics_offset; - ps < capping_static; ++ps) - ps->pst = pst; - - /* Put the psymtab on the psymtab list */ - pst->next = partial_symtab_list; - partial_symtab_list = pst; -} - - -/* Helper routines for psymtab_to_symtab. */ -static void scan_file_globals (); -static void read_ofile_symtab (); - -static void -psymtab_to_symtab_1 (pst, desc, stringtab, stringtab_size, sym_offset) - struct partial_symtab *pst; - int desc; - char *stringtab; - int stringtab_size; - int sym_offset; -{ - struct cleanup *old_chain; - int i; - - if (!pst) - return; - - if (pst->readin) - { - fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n", - pst->filename); - return; - } - - /* Read in all partial symbtabs on which this one is dependent */ - for (i = 0; i < pst->number_of_dependencies; i++) - if (!pst->dependencies[i]->readin) - { - /* Inform about additional files that need to be read in. */ - if (info_verbose) - { - printf_filtered (" and %s...", pst->dependencies[i]->filename); - fflush (stdout); - } - psymtab_to_symtab_1 (pst->dependencies[i], desc, - stringtab, stringtab_size, sym_offset); - } - - if (pst->ldsymlen) /* Otherwise it's a dummy */ - { - /* Init stuff necessary for reading in symbols */ - free_pendings = 0; - pending_blocks = 0; - file_symbols = 0; - global_symbols = 0; - old_chain = make_cleanup (really_free_pendings, 0); - - /* Read in this files symbols */ - lseek (desc, sym_offset, L_SET); - read_ofile_symtab (desc, stringtab, stringtab_size, - pst->ldsymoff, - pst->ldsymlen, pst->textlow, - pst->texthigh - pst->textlow, 0); - sort_symtab_syms (symtab_list); /* At beginning since just added */ - - do_cleanups (old_chain); - } - - pst->readin = 1; -} - -/* - * Read in all of the symbols for a given psymtab for real. Return - * the value of the symtab you create. Do not free the storage - * allocated to the psymtab; it may have pointers to it. - */ -struct symtab * -psymtab_to_symtab(pst) - struct partial_symtab *pst; -{ - int desc; - DECLARE_FILE_HEADERS; - char *stringtab; - struct partial_symtab **list_patch; - int stsize, val; - struct stat statbuf; - struct cleanup *old_chain; - extern void close (); - int i; - struct symtab *result; - char *name = symfile; /* Some of the macros require the */ - /* variable "name" to be defined in */ - /* the context in which they execute */ - /* (Yech!) */ - - if (!pst) - return 0; - - if (pst->readin) - { - fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n", - pst->filename); - return 0; - } - - if (!name) - error("No symbol file currently specified; use command symbol-file"); - - if (pst->ldsymlen || pst->number_of_dependencies) - { - /* Print the message now, before reading the string table, - to avoid disconcerting pauses. */ - if (info_verbose) - { - printf_filtered ("Reading in symbols for %s...", pst->filename); - fflush (stdout); - } - - /* Open symbol file and read in string table */ - if (stat (name, &statbuf) < 0) - perror_with_name (name); - desc = open(name, O_RDONLY, 0); /* symbol_file_command - guarrantees that the symbol file name - will be absolute, so there is no - need for openp */ - - old_chain = make_cleanup (close, desc); - - if (desc < 0) - error("Symbol file not readable"); - - READ_FILE_HEADERS (desc, name); - -#if 0 - /* Read in the string table */ - lseek (desc, STRING_TABLE_OFFSET, L_SET); - READ_STRING_TABLE_SIZE (stsize); - if (stsize >= 0 && stsize < statbuf.st_size) - { -#ifdef BROKEN_LARGE_ALLOCA - stringtab = (char *) xmalloc (stsize); - make_cleanup (free, stringtab); -#else - stringtab = (char *) alloca (stsize); -#endif - } - else - stringtab = NULL; - if (stringtab == NULL) - error ("ridiculous string table size: %d bytes", stsize); - - /* Usually READ_STRING_TABLE_SIZE will have shifted the file pointer. - Occaisionally, it won't. */ - val = lseek (desc, STRING_TABLE_OFFSET, L_SET); - if (val < 0) - perror_with_name (name); - val = myread (desc, stringtab, stsize); - if (val < 0) - perror_with_name (name); -#endif /* 0 */ - stringtab = symfile_string_table; - stsize = symfile_string_table_size; - - psymtab_to_symtab_1 (pst, desc, stringtab, stsize, - SYMBOL_TABLE_OFFSET); - - /* Match with global symbols. This only needs to be done once, - after all of the symtabs and dependencies have been read in. */ - scan_file_globals (); - - do_cleanups (old_chain); - - /* Finish up the debug error message. */ - if (info_verbose) - printf_filtered ("done.\n"); - } - - /* Search through list for correct name. */ - for (result = symtab_list; result; result = result->next) - if (!strcmp (result->filename, pst->filename)) - return result; - - return 0; -} - -/* - * Scan through all of the global symbols defined in the object file, - * assigning values to the debugging symbols that need to be assigned - * to. Get these symbols from the misc function list. - */ -static void -scan_file_globals () -{ - int hash; - int mf; - - for (mf = 0; mf < misc_function_count; mf++) - { - char *namestring = misc_function_vector[mf].name; - struct symbol *sym, *prev; - - QUIT; - - prev = (struct symbol *) 0; - - /* Get the hash index and check all the symbols - under that hash index. */ - - hash = hashname (namestring); - - for (sym = global_sym_chain[hash]; sym;) - { - if (*namestring == SYMBOL_NAME (sym)[0] - && !strcmp(namestring + 1, SYMBOL_NAME (sym) + 1)) - { - /* Splice this symbol out of the hash chain and - assign the value we have to it. */ - if (prev) - SYMBOL_VALUE (prev) = SYMBOL_VALUE (sym); - else - global_sym_chain[hash] - = (struct symbol *) SYMBOL_VALUE (sym); - - /* Check to see whether we need to fix up a common block. */ - /* Note: this code might be executed several times for - the same symbol if there are multiple references. */ - if (SYMBOL_CLASS (sym) == LOC_BLOCK) - fix_common_block (sym, misc_function_vector[mf].address); - else - SYMBOL_VALUE (sym) = misc_function_vector[mf].address; - - if (prev) - sym = (struct symbol *) SYMBOL_VALUE (prev); - else - sym = global_sym_chain[hash]; - } - else - { - prev = sym; - sym = (struct symbol *) SYMBOL_VALUE (sym); - } - } - } -} - -/* - * Read in a defined section of a specific object file's symbols. - * - * DESC is the file descriptor for the file, positioned at the - * beginning of the symtab - * STRINGTAB is a pointer to the files string - * table, already read in - * SYM_OFFSET is the offset within the file of - * the beginning of the symbols we want to read, NUM_SUMBOLS is the - * number of symbols to read - * TEXT_OFFSET is the offset to be added to - * all values of symbols coming in and - * TEXT_SIZE is the size of the text segment read in. - * OFFSET is a flag which indicates that the value of all of the - * symbols should be offset by TEXT_OFFSET (for the purposes of - * incremental linking). - */ - -static void -read_ofile_symtab (desc, stringtab, stringtab_size, sym_offset, - sym_size, text_offset, text_size, offset) - int desc; - register char *stringtab; - int sym_offset; - int sym_size; - int text_offset; - int text_size; - int offset; -{ - register char *namestring; - register struct symbol *sym, *prev; - int hash; - struct cleanup *old_chain; - struct nlist *bufp; - unsigned char type; -#ifdef N_BINCL - subfile_stack = 0; -#endif - - stringtab_global = stringtab; - last_source_file = 0; - - symtab_input_desc = desc; - symbuf_end = symbuf_idx = 0; - - /* It is necessary to actually read one symbol *before* the start - of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL - occurs before the N_SO symbol. - - Detecting this in read_dbx_symtab - would slow down initial readin, so we look for it here instead. */ - if (sym_offset >= sizeof (struct nlist)) - { - lseek (desc, sym_offset - sizeof (struct nlist), L_INCR); - fill_symbuf (); - bufp = &symbuf[symbuf_idx++]; - - if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size) - error ("Invalid symbol data: bad string table offset: %d", - bufp->n_un.n_strx); - namestring = bufp->n_un.n_strx + stringtab; - - processing_gcc_compilation = - (bufp->n_type == N_TEXT - && !strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL)); - } - else - { - /* The N_SO starting this symtab is the first symbol, so we - better not check the symbol before it. I'm not this can - happen, but it doesn't hurt to check for it. */ - lseek(desc, sym_offset, L_INCR); - processing_gcc_compilation = 0; - } - - if (symbuf_idx == symbuf_end) - fill_symbuf(); - bufp = &symbuf[symbuf_idx]; - if ((unsigned char) bufp->n_type != N_SO) - fatal("First symbol in segment of executable not a source symbol"); - - for (symnum = 0; - symnum < sym_size / sizeof(struct nlist); - symnum++) - { - QUIT; /* Allow this to be interruptable */ - if (symbuf_idx == symbuf_end) - fill_symbuf(); - bufp = &symbuf[symbuf_idx++]; - type = bufp->n_type; - - if (offset && - (type == N_TEXT || type == N_DATA || type == N_BSS)) - bufp->n_value += text_offset; - - if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size) - error ("Invalid symbol data: bad string table offset: %d", - bufp->n_un.n_strx); - namestring = bufp->n_un.n_strx + stringtab; - - if (type & N_STAB) - process_one_symbol(type, bufp->n_desc, - bufp->n_value, namestring); - /* We skip checking for a new .o or -l file; that should never - happen in this routine. */ - else if (type == N_TEXT - && !strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL)) - /* I don't think this code will ever be executed, because - the GCC_COMPILED_FLAG_SYMBOL usually is right before - the N_SO symbol which starts this source file. - However, there is no reason not to accept - the GCC_COMPILED_FLAG_SYMBOL anywhere. */ - processing_gcc_compilation = 1; - else if (type & N_EXT || type == N_TEXT -#ifdef N_NBTEXT - || type == N_NBTEXT -#endif - ) - /* Global symbol: see if we came across a dbx defintion for - a corresponding symbol. If so, store the value. Remove - syms from the chain when their values are stored, but - search the whole chain, as there may be several syms from - different files with the same name. */ - /* This is probably not true. Since the files will be read - in one at a time, each reference to a global symbol will - be satisfied in each file as it appears. So we skip this - section. */ - &stringtab_global; /* For debugger; am I right? */ - } - end_symtab (text_offset + text_size); -} - -static int -hashname (name) - char *name; -{ - register char *p = name; - register int total = p[0]; - register int c; - - c = p[1]; - total += c << 2; - if (c) - { - c = p[2]; - total += c << 4; - if (c) - total += p[3] << 6; - } - - /* Ensure result is positive. */ - if (total < 0) total += (1000 << 6); - return total % HASHSIZE; -} - -/* Put all appropriate global symbols in the symseg data - onto the hash chains so that their addresses will be stored - when seen later in loader global symbols. */ - -static void -hash_symsegs () -{ - /* Look at each symbol in each block in each symseg symtab. */ - struct symtab *s; - for (s = symseg_chain; s; s = s->next) - { - register int n; - for (n = BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)) - 1; n >= 0; n--) - { - register struct block *b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), n); - register int i; - for (i = BLOCK_NSYMS (b) - 1; i >= 0; i--) - { - register struct symbol *sym = BLOCK_SYM (b, i); - - /* Put the symbol on a chain if its value is an address - that is figured out by the loader. */ - - if (SYMBOL_CLASS (sym) == LOC_EXTERNAL) - { - register int hash = hashname (SYMBOL_NAME (sym)); - SYMBOL_VALUE (sym) = (int) global_sym_chain[hash]; - global_sym_chain[hash] = sym; - SYMBOL_CLASS (sym) = LOC_STATIC; - } - } - } - } -} - -static void -process_one_symbol (type, desc, value, name) - int type, desc; - CORE_ADDR value; - char *name; -{ - register struct context_stack *new; - char *colon_pos; - - /* Something is wrong if we see real data before - seeing a source file name. */ - - if (last_source_file == 0 && type != N_SO) - { - /* Currently this ignores N_ENTRY on Gould machines, N_NSYM on machines - where that code is defined. */ - if (IGNORE_SYMBOL (type)) - return; - - error ("Invalid symbol data: does not start by identifying a source file."); - } - - switch (type) - { - case N_FUN: - case N_FNAME: - /* Either of these types of symbols indicates the start of - a new function. We must process its "name" normally for dbx, - but also record the start of a new lexical context, and possibly - also the end of the lexical context for the previous function. */ - /* This is not always true. This type of symbol may indicate a - text segment variable. */ - - colon_pos = index (name, ':'); - if (!colon_pos++ - || (*colon_pos != 'f' && *colon_pos != 'F')) - { - define_symbol (value, name, desc); - break; - } - - within_function = 1; - if (context_stack_depth > 0) - { - new = &context_stack[--context_stack_depth]; - /* Make a block for the local symbols within. */ - finish_block (new->name, &local_symbols, new->old_blocks, - new->start_addr, value); - } - /* Stack must be empty now. */ - if (context_stack_depth != 0) - error ("Invalid symbol data: unmatched N_LBRAC before symtab pos %d.", - symnum); - - new = &context_stack[context_stack_depth++]; - new->old_blocks = pending_blocks; - new->start_addr = value; - new->name = define_symbol (value, name, desc); - local_symbols = 0; - break; - - case N_LBRAC: - /* This "symbol" just indicates the start of an inner lexical - context within a function. */ - - if (context_stack_depth == context_stack_size) - { - context_stack_size *= 2; - context_stack = (struct context_stack *) - xrealloc (context_stack, - (context_stack_size - * sizeof (struct context_stack))); - } - - new = &context_stack[context_stack_depth++]; - new->depth = desc; - new->locals = local_symbols; - new->old_blocks = pending_blocks; - new->start_addr = value; - new->name = 0; - local_symbols = 0; - break; - - case N_RBRAC: - /* This "symbol" just indicates the end of an inner lexical - context that was started with N_LBRAC. */ - new = &context_stack[--context_stack_depth]; - if (desc != new->depth) - error ("Invalid symbol data: N_LBRAC/N_RBRAC symbol mismatch, symtab pos %d.", symnum); - - /* Some native compilers put the variable decls inside of an - LBRAC/RBRAC block. This macro should be nonzero if this - is true. DESC is N_DESC from the N_RBRAC symbol. */ -#if !defined (VARIABLES_INSIDE_BLOCK) -#define VARIABLES_INSIDE_BLOCK(desc) 0 -#endif - - /* Can only use new->locals as local symbols here if we're in - gcc or on a machine that puts them before the lbrack. */ - if (!VARIABLES_INSIDE_BLOCK(desc)) - local_symbols = new->locals; - - /* If this is not the outermost LBRAC...RBRAC pair in the - function, its local symbols preceded it, and are the ones - just recovered from the context stack. Defined the block for them. - - If this is the outermost LBRAC...RBRAC pair, there is no - need to do anything; leave the symbols that preceded it - to be attached to the function's own block. However, if - it is so, we need to indicate that we just moved outside - of the function. */ - if (local_symbols - && context_stack_depth > !VARIABLES_INSIDE_BLOCK(desc)) - { - /* Muzzle a compiler bug that makes end < start. */ - if (new->start_addr > value) - new->start_addr = value; - /* Make a block for the local symbols within. */ - finish_block (0, &local_symbols, new->old_blocks, - new->start_addr + last_source_start_addr, - value + last_source_start_addr); - } - else - { - within_function = 0; - } - if (VARIABLES_INSIDE_BLOCK(desc)) - /* Now pop locals of block just finished. */ - local_symbols = new->locals; - break; - - case N_FN | N_EXT: - /* This kind of symbol supposedly indicates the start - of an object file. In fact this type does not appear. */ - break; - - case N_SO: - /* This type of symbol indicates the start of data - for one source file. - Finish the symbol table of the previous source file - (if any) and start accumulating a new symbol table. */ -#ifdef PCC_SOL_BROKEN - /* pcc bug, occasionally puts out SO for SOL. */ - if (context_stack_depth > 0) - { - start_subfile (name); - break; - } -#endif - if (last_source_file) - end_symtab (value); - start_symtab (name, value); - break; - - case N_SOL: - /* This type of symbol indicates the start of data for - a sub-source-file, one whose contents were copied or - included in the compilation of the main source file - (whose name was given in the N_SO symbol.) */ - start_subfile (name); - break; - -#ifdef N_BINCL - case N_BINCL: - push_subfile (); - add_new_header_file (name, value); - start_subfile (name); - break; - - case N_EINCL: - start_subfile (pop_subfile ()); - break; - - case N_EXCL: - add_old_header_file (name, value); - break; -#endif /* have N_BINCL */ - - case N_SLINE: - /* This type of "symbol" really just records - one line-number -- core-address correspondence. - Enter it in the line list for this symbol table. */ - record_line (desc, value); - break; - - case N_BCOMM: - if (common_block) - error ("Invalid symbol data: common within common at symtab pos %d", - symnum); - common_block = local_symbols; - common_block_i = local_symbols ? local_symbols->nsyms : 0; - break; - - case N_ECOMM: - /* Symbols declared since the BCOMM are to have the common block - start address added in when we know it. common_block points to - the first symbol after the BCOMM in the local_symbols list; - copy the list and hang it off the symbol for the common block name - for later fixup. */ - { - int i; - struct pending *link = local_symbols; - struct symbol *sym = - (struct symbol *) xmalloc (sizeof (struct symbol)); - bzero (sym, sizeof *sym); - SYMBOL_NAME (sym) = savestring (name, strlen (name)); - SYMBOL_CLASS (sym) = LOC_BLOCK; - SYMBOL_NAMESPACE (sym) = (enum namespace)((long) - copy_pending (local_symbols, common_block_i, common_block)); - i = hashname (SYMBOL_NAME (sym)); - SYMBOL_VALUE (sym) = (int) global_sym_chain[i]; - global_sym_chain[i] = sym; - common_block = 0; - break; - } - - case N_ECOML: - case N_LENG: - break; - - default: - if (name) - define_symbol (value, name, desc); - } -} - -/* This function was added for C++ functionality. I presume that it - condenses the bunches formed by reading in an additional .o file - (incremental linking). */ - -static void -condense_addl_misc_bunches () -{ - register int i, j; - register struct misc_bunch *bunch; -#ifdef NAMES_HAVE_UNDERSCORE - int offset = 1; -#else - int offset = 0; -#endif - - misc_function_vector - = (struct misc_function *) xrealloc (misc_function_vector, - (misc_count + misc_function_count) * sizeof (struct misc_function)); - - j = misc_function_count; - bunch = misc_bunch; - while (bunch) - { - for (i = 0; i < misc_bunch_index; i++) - { - misc_function_vector[j] = bunch->contents[i]; - misc_function_vector[j].name - = concat (misc_function_vector[j].name - + (misc_function_vector[j].name[0] == '_' ? offset : 0), - "", ""); - j++; - } - bunch = bunch->next; - misc_bunch_index = MISC_BUNCH_SIZE; - } - - misc_function_count += misc_count; - - /* Sort the misc functions by address. */ - - qsort (misc_function_vector, misc_function_count, - sizeof (struct misc_function), compare_misc_functions); -} - - -/* Read in another .o file and create a symtab entry for it.*/ - -static void -read_addl_syms (desc, stringtab, nlistlen, text_addr, text_size) - int desc; - register char *stringtab; - register int nlistlen; - unsigned text_addr; - int text_size; -{ - FILE *stream = fdopen (desc, "r"); - register char *namestring; - register struct symbol *sym, *prev; - int hash; - -#ifdef N_BINCL - subfile_stack = 0; -#endif - - last_source_file = 0; - bzero (global_sym_chain, sizeof global_sym_chain); - symtab_input_desc = desc; - stringtab_global = stringtab; - fill_symbuf (); - - for (symnum = 0; symnum < nlistlen; symnum++) - { - struct nlist *bufp; - unsigned char type; - - QUIT; /* allow this to be interruptable */ - if (symbuf_idx == symbuf_end) - fill_symbuf (); - bufp = &symbuf[symbuf_idx++]; - type = bufp->n_type & N_TYPE; - namestring = bufp->n_un.n_strx + stringtab; - - if( (type == N_TEXT) || (type == N_DATA) || (type == N_BSS) ) - { - /* Relocate this file's symbol table information - to the address it has been loaded into. */ - bufp->n_value += text_addr; - } - - type = bufp->n_type; - - if (type & N_STAB) - process_one_symbol (type, bufp->n_desc, - bufp->n_value, namestring); - /* A static text symbol whose name ends in ".o" - can only mean the start of another object file. - So end the symtab of the source file we have been processing. - This is how we avoid counting the libraries as part - or the last source file. - Also this way we find end of first object file (crt0). */ - else if ((type == N_TEXT -#ifdef N_NBTEXT - || type == N_NBTEXT -#endif - ) - && (!strcmp (namestring + strlen (namestring) - 2, ".o")) - || ! strncmp (namestring, "-l", 2)) - { - if (last_source_file) - end_symtab (bufp->n_value); - } - else if (type & N_EXT || type == N_TEXT -#ifdef N_NBTEXT - || type == N_NBTEXT -#endif - ) - { - int used_up = 0; - - /* Record the location of _etext. */ - if (type == (N_TEXT | N_EXT) - && !strcmp (namestring, "_etext")) - end_of_text_addr = bufp->n_value; - -#if 0 - /* 25 Sep 89: The following seems to be stolen from - read_ofile_symtab, and is wrong here (i.e. there was no - first pass for add-file symbols). */ - /* This shouldn't be necessary, as we now do all of this work - in scan_global syms and all misc functions should have been - recorded on the first pass. */ - /* Global symbol: see if we came across a dbx definition - for a corresponding symbol. If so, store the value. - Remove syms from the chain when their values are stored, - but search the whole chain, as there may be several syms - from different files with the same name. */ - if (type & N_EXT) - { - prev = 0; -#ifdef NAMES_HAVE_UNDERSCORE - hash = hashname (namestring + 1); -#else /* not NAMES_HAVE_UNDERSCORE */ - hash = hashname (namestring); -#endif /* not NAMES_HAVE_UNDERSCORE */ - for (sym = global_sym_chain[hash]; - sym;) - { - if ( -#ifdef NAMES_HAVE_UNDERSCORE - *namestring == '_' - && namestring[1] == SYMBOL_NAME (sym)[0] - && - !strcmp (namestring + 2, SYMBOL_NAME (sym) + 1) -#else /* NAMES_HAVE_UNDERSCORE */ - namestring[0] == SYMBOL_NAME (sym)[0] - && - !strcmp (namestring + 1, SYMBOL_NAME (sym) + 1) -#endif /* NAMES_HAVE_UNDERSCORE */ - ) - { - if (prev) - SYMBOL_VALUE (prev) = SYMBOL_VALUE (sym); - else - global_sym_chain[hash] - = (struct symbol *) SYMBOL_VALUE (sym); - if (SYMBOL_CLASS (sym) == LOC_BLOCK) - fix_common_block (sym, bufp->n_value); - else - SYMBOL_VALUE (sym) = bufp->n_value; - if (prev) - sym = (struct symbol *) SYMBOL_VALUE (prev); - else - sym = global_sym_chain[hash]; - - used_up = 1; - } - else - { - prev = sym; - sym = (struct symbol *) SYMBOL_VALUE (sym); - } - } - } - - /* Defined global or text symbol: record as a misc function - if it didn't give its address to a debugger symbol above. */ - if (type <= (N_TYPE | N_EXT) - && type != N_EXT - && ! used_up) - record_misc_function (namestring, bufp->n_value, - bufp->n_type); -#endif /* 0 */ - } - } - - if (last_source_file) - end_symtab (text_addr + text_size); - - fclose (stream); -} - -/* C++: - This function allows the addition of incrementally linked object files. - Since this has a fair amount of code in common with symbol_file_command, - it might be worthwhile to consolidate things, as was done with - read_dbx_symtab and condense_misc_bunches. */ - -void -add_file_command (arg_string) - char* arg_string; -{ - register int desc; - DECLARE_FILE_HEADERS; - struct nlist *nlist; - char *stringtab; - long buffer; - register int val; - extern void close (); - struct cleanup *old_chain; - struct symtab *symseg; - struct stat statbuf; - char *name; - unsigned text_addr; - - if (arg_string == 0) - error ("add-file takes a file name and an address"); - - arg_string = tilde_expand (arg_string); - make_cleanup (free, arg_string); - - for( ; *arg_string == ' '; arg_string++ ); - name = arg_string; - for( ; *arg_string && *arg_string != ' ' ; arg_string++ ); - *arg_string++ = (char) 0; - - if (name[0] == 0) - error ("add-file takes a file name and an address"); - - text_addr = parse_and_eval_address (arg_string); - - dont_repeat (); - - if (!query ("add symbol table from filename \"%s\" at text_addr = 0x%x\n", - name, text_addr)) - error ("Not confirmed."); - - desc = open (name, O_RDONLY); - if (desc < 0) - perror_with_name (name); - - old_chain = make_cleanup (close, desc); - - READ_FILE_HEADERS (desc, name); - - if (NUMBER_OF_SYMBOLS == 0) - { - printf ("%s does not have a symbol-table.\n", name); - fflush (stdout); - return; - } - - printf ("Reading symbol data from %s...", name); - fflush (stdout); - - /* Now read the string table, all at once. */ - val = lseek (desc, STRING_TABLE_OFFSET, 0); - if (val < 0) - perror_with_name (name); - if (stat (name, &statbuf) < 0) - perror_with_name (name); - READ_STRING_TABLE_SIZE (buffer); - if (buffer >= 0 && buffer < statbuf.st_size) - { -#ifdef BROKEN_LARGE_ALLOCA - stringtab = (char *) xmalloc (buffer); - make_cleanup (free, stringtab); -#else - stringtab = (char *) alloca (buffer); -#endif - } - else - stringtab = NULL; - if (stringtab == NULL) - error ("ridiculous string table size: %d bytes", buffer); - - /* Usually READ_STRING_TABLE_SIZE will have shifted the file pointer. - Occaisionally, it won't. */ - val = lseek (desc, STRING_TABLE_OFFSET, 0); - if (val < 0) - perror_with_name (name); - val = myread (desc, stringtab, buffer); - if (val < 0) - perror_with_name (name); - - /* Symsegs are no longer supported by GDB. Setting symseg_chain to - 0 is easier than finding all the symseg code and eliminating it. */ - symseg_chain = 0; - - /* Position to read the symbol table. Do not read it all at once. */ - val = lseek (desc, SYMBOL_TABLE_OFFSET, 0); - if (val < 0) - perror_with_name (name); - - init_misc_functions (); - make_cleanup (discard_misc_bunches, 0); - init_header_files (); - make_cleanup (free_header_files, 0); - free_pendings = 0; - pending_blocks = 0; - file_symbols = 0; - global_symbols = 0; - make_cleanup (really_free_pendings, 0); - - read_addl_syms (desc, stringtab, NUMBER_OF_SYMBOLS, text_addr, - SIZE_OF_TEXT_SEGMENT); - - - /* Sort symbols alphabetically within each block. */ - - sort_syms (); - - /* Go over the misc functions and install them in vector. */ - - condense_addl_misc_bunches (1); - - /* Don't allow char * to have a typename (else would get caddr_t.) */ - - TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0; - - do_cleanups (old_chain); - - /* Free the symtabs made by read_symsegs, but not their contents, - which have been copied into symtabs on symtab_list. */ - while (symseg_chain) - { - register struct symtab *s = symseg_chain->next; - free (symseg_chain); - symseg_chain = s; - } - - printf ("done.\n"); - fflush (stdout); -} - -/* Read a number by which a type is referred to in dbx data, - or perhaps read a pair (FILENUM, TYPENUM) in parentheses. - Just a single number N is equivalent to (0,N). - Return the two numbers by storing them in the vector TYPENUMS. - TYPENUMS will then be used as an argument to dbx_lookup_type. */ - -static void -read_type_number (pp, typenums) - register char **pp; - register int *typenums; -{ - if (**pp == '(') - { - (*pp)++; - typenums[0] = read_number (pp, ','); - typenums[1] = read_number (pp, ')'); - } - else - { - typenums[0] = 0; - typenums[1] = read_number (pp, 0); - } -} - - - -static struct symbol * -define_symbol (value, string, desc) - int value; - char *string; - int desc; -{ - register struct symbol *sym - = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol)); - char *p = (char *) index (string, ':'); - int deftype; - register int i; - - /* Ignore syms with empty names. */ - if (string[0] == 0) - return 0; - - /* Ignore old-style symbols from cc -go */ - if (p == 0) - return 0; - - SYMBOL_NAME (sym) - = (char *) obstack_alloc (symbol_obstack, ((p - string) + 1)); - /* Open-coded bcopy--saves function call time. */ - { - register char *p1 = string; - register char *p2 = SYMBOL_NAME (sym); - while (p1 != p) - *p2++ = *p1++; - *p2++ = '\0'; - } - p++; - /* Determine the type of name being defined. */ - if ((*p >= '0' && *p <= '9') || *p == '(') - deftype = 'l'; - else - deftype = *p++; - - /* c is a special case, not followed by a type-number. - SYMBOL:c=iVALUE for an integer constant symbol. - SYMBOL:c=rVALUE for a floating constant symbol. - SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol. - e.g. "b:c=e6,0" for "const b = blob1" - (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */ - if (deftype == 'c') - { - if (*p++ != '=') - error ("Invalid symbol data at symtab pos %d.", symnum); - switch (*p++) - { - case 'r': - { - double d = atof (p); - char *value; - - SYMBOL_TYPE (sym) = builtin_type_double; - value = (char *) obstack_alloc (symbol_obstack, sizeof (double)); - bcopy (&d, value, sizeof (double)); - SYMBOL_VALUE_BYTES (sym) = value; - SYMBOL_CLASS (sym) = LOC_CONST_BYTES; - } - break; - case 'i': - { - SYMBOL_TYPE (sym) = builtin_type_int; - SYMBOL_VALUE (sym) = atoi (p); - SYMBOL_CLASS (sym) = LOC_CONST; - } - break; - case 'e': - /* SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol. - e.g. "b:c=e6,0" for "const b = blob1" - (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */ - { - int typenums[2]; - - read_type_number (&p, typenums); - if (*p++ != ',') - error ("Invalid symbol data: no comma in enum const symbol"); - - SYMBOL_TYPE (sym) = *dbx_lookup_type (typenums); - SYMBOL_VALUE (sym) = atoi (p); - SYMBOL_CLASS (sym) = LOC_CONST; - } - break; - default: - error ("Invalid symbol data at symtab pos %d.", symnum); - } - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &file_symbols); - return sym; - } - - /* Now usually comes a number that says which data type, - and possibly more stuff to define the type - (all of which is handled by read_type) */ - - if (deftype == 'p' && *p == 'F') - /* pF is a two-letter code that means a function parameter in Fortran. - The type-number specifies the type of the return value. - Translate it into a pointer-to-function type. */ - { - p++; - SYMBOL_TYPE (sym) - = lookup_pointer_type (lookup_function_type (read_type (&p))); - } - else - { - struct type *type = read_type (&p); - - if ((deftype == 'F' || deftype == 'f') - && TYPE_CODE (type) != TYPE_CODE_FUNC) - SYMBOL_TYPE (sym) = lookup_function_type (type); - else - SYMBOL_TYPE (sym) = type; - } - - switch (deftype) - { - case 'f': - SYMBOL_CLASS (sym) = LOC_BLOCK; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &file_symbols); - break; - - case 'F': - SYMBOL_CLASS (sym) = LOC_BLOCK; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &global_symbols); - break; - - case 'G': - /* For a class G (global) symbol, it appears that the - value is not correct. It is necessary to search for the - corresponding linker definition to find the value. - These definitions appear at the end of the namelist. */ - i = hashname (SYMBOL_NAME (sym)); - SYMBOL_VALUE (sym) = (int) global_sym_chain[i]; - global_sym_chain[i] = sym; - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &global_symbols); - break; - - /* This case is faked by a conditional above, - when there is no code letter in the dbx data. - Dbx data never actually contains 'l'. */ - case 'l': - SYMBOL_CLASS (sym) = LOC_LOCAL; - SYMBOL_VALUE (sym) = value; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'p': - SYMBOL_CLASS (sym) = LOC_ARG; - SYMBOL_VALUE (sym) = value; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - - /* If it's gcc compiled, if it says `short', believe it. */ - if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION) - break; - -#if defined(BELIEVE_PCC_PROMOTION_TYPE) - /* This macro is defined on machines (e.g. sparc) where - we should believe the type of a PCC 'short' argument, - but shouldn't believe the address (the address is - the address of the corresponding int). Note that - this is only different from the BELIEVE_PCC_PROMOTION - case on big-endian machines. - - My guess is that this correction, as opposed to changing - the parameter to an 'int' (as done below, for PCC - on most machines), is the right thing to do - on all machines, but I don't want to risk breaking - something that already works. On most PCC machines, - the sparc problem doesn't come up because the calling - function has to zero the top bytes (not knowing whether - the called function wants an int or a short), so there - is no practical difference between an int and a short - (except perhaps what happens when the GDB user types - "print short_arg = 0x10000;"). - Hacked for SunOS 4.1 by gnu@cygnus.com. In 4.1, the compiler - actually produces the correct address (we don't need to fix it - up). I made this code adapt so that it will offset the symbol - if it was pointing at an int-aligned location and not - otherwise. This way you can use the same gdb for 4.0.x and - 4.1 systems. */ - - if (0 == SYMBOL_VALUE (sym) % sizeof (int)) - { - if (SYMBOL_TYPE (sym) == builtin_type_char - || SYMBOL_TYPE (sym) == builtin_type_unsigned_char) - SYMBOL_VALUE (sym) += 3; - else if (SYMBOL_TYPE (sym) == builtin_type_short - || SYMBOL_TYPE (sym) == builtin_type_unsigned_short) - SYMBOL_VALUE (sym) += 2; - } - break; - -#else /* no BELIEVE_PCC_PROMOTION_TYPE. */ - - /* If PCC says a parameter is a short or a char, - it is really an int. */ - if (SYMBOL_TYPE (sym) == builtin_type_char - || SYMBOL_TYPE (sym) == builtin_type_short) - SYMBOL_TYPE (sym) = builtin_type_int; - else if (SYMBOL_TYPE (sym) == builtin_type_unsigned_char - || SYMBOL_TYPE (sym) == builtin_type_unsigned_short) - SYMBOL_TYPE (sym) = builtin_type_unsigned_int; - break; - -#endif /* no BELIEVE_PCC_PROMOTION_TYPE. */ - - case 'P': - SYMBOL_CLASS (sym) = LOC_REGPARM; - SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (value); - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'r': -/* XXX */ -#ifdef sparc -{ - struct symbol *s0; - - /* - * If we see a parm decl immediately followed by a reg decl of - * the same name (and in the same block), we change it to a single - * instance of a reg parm. Sun's cc will generate these. - */ - if (local_symbols && - (s0 = local_symbols->symbol[local_symbols->nsyms - 1]) && - SYMBOL_CLASS(s0) == LOC_ARG && - strcmp(SYMBOL_NAME(s0), SYMBOL_NAME(sym)) == 0) { - SYMBOL_CLASS (s0) = LOC_REGPARM; - SYMBOL_VALUE (s0) = STAB_REG_TO_REGNUM (value); - SYMBOL_NAMESPACE (s0) = VAR_NAMESPACE; - return s0; - } -} -#endif - SYMBOL_CLASS (sym) = LOC_REGISTER; - SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (value); - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'S': - /* Static symbol at top level of file */ - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE (sym) = value; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &file_symbols); - break; - - case 't': - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_VALUE (sym) = value; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0 - && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) = - obsavestring (SYMBOL_NAME (sym), - strlen (SYMBOL_NAME (sym))); - /* C++ vagaries: we may have a type which is derived from - a base type which did not have its name defined when the - derived class was output. We fill in the derived class's - base part member's name here in that case. */ - else if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT - || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION) - && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym))) - { - int i; - for (i = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)); i > 0; i--) - if (TYPE_FIELD_NAME (SYMBOL_TYPE (sym), i - 1) == 0) - TYPE_FIELD_NAME (SYMBOL_TYPE (sym), i - 1) = - TYPE_NAME (TYPE_BASECLASS (SYMBOL_TYPE (sym), i)); - } - - add_symbol_to_list (sym, &file_symbols); - break; - - case 'T': - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_VALUE (sym) = value; - SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; - if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0 - && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) - = obconcat ("", - (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_ENUM - ? "enum " - : (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT - ? "struct " : "union ")), - SYMBOL_NAME (sym)); - add_symbol_to_list (sym, &file_symbols); - break; - - case 'V': - /* Static symbol of local scope */ - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE (sym) = value; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'v': - /* Reference parameter */ - SYMBOL_CLASS (sym) = LOC_REF_ARG; - SYMBOL_VALUE (sym) = value; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'X': - /* This is used by Sun FORTRAN for "function result value". - Sun claims ("dbx and dbxtool interfaces", 2nd ed) - that Pascal uses it too, but when I tried it Pascal used - "x:3" (local symbol) instead. */ - SYMBOL_CLASS (sym) = LOC_LOCAL; - SYMBOL_VALUE (sym) = value; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - default: - error ("Invalid symbol data: unknown symbol-type code `%c' at symtab pos %d.", deftype, symnum); - } - return sym; -} - -/* What about types defined as forward references inside of a small lexical - scope? */ -/* Add a type to the list of undefined types to be checked through - once this file has been read in. */ -static void -add_undefined_type (type) - struct type *type; -{ - if (undef_types_length == undef_types_allocated) - { - undef_types_allocated *= 2; - undef_types = (struct type **) - xrealloc (undef_types, - undef_types_allocated * sizeof (struct type *)); - } - undef_types[undef_types_length++] = type; -} - -/* Add here something to go through each undefined type, see if it's - still undefined, and do a full lookup if so. */ -static void -cleanup_undefined_types () -{ - struct type **type, *ntype; - struct symbol *sym; - - for (type = undef_types; type < undef_types + undef_types_length; type++) - { - struct type *ntype = 0; - /* Reasonable test to see if it's been defined since. */ - if (TYPE_NFIELDS (*type) == 0) - { - struct pending *ppt; - int i; - /* Name of the type, without "struct" or "union" */ - char *typename = TYPE_NAME (*type); - - if (!strncmp (typename, "struct ", 7)) - typename += 7; - if (!strncmp (typename, "union ", 6)) - typename += 6; - - for (ppt = file_symbols; ppt; ppt = ppt->next) - for (i = 0; i < ppt->nsyms; i++) - { - struct symbol *sym = ppt->symbol[i]; - - if (SYMBOL_CLASS (sym) == LOC_TYPEDEF - && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE - && (TYPE_CODE (SYMBOL_TYPE (sym)) == - TYPE_CODE (*type)) - && !strcmp (SYMBOL_NAME (sym), typename)) - bcopy (SYMBOL_TYPE (sym), *type, sizeof (struct type)); - } - } - else - /* It has been defined; don't mark it as a stub. */ - TYPE_FLAGS (*type) &= ~TYPE_FLAG_STUB; - } - undef_types_length = 0; -} - - - -/* Read a dbx type reference or definition; - return the type that is meant. - This can be just a number, in which case it references - a type already defined and placed in type_vector. - Or the number can be followed by an =, in which case - it means to define a new type according to the text that - follows the =. */ - -static -struct type * -read_type (pp) - register char **pp; -{ - register struct type *type = 0; - register int n; - struct type *type1; - int typenums[2]; - int xtypenums[2]; - char *tmpc; - - /* Read type number if present. The type number may be omitted. - for instance in a two-dimensional array declared with type - "ar1;1;10;ar1;1;10;4". */ - if ((**pp >= '0' && **pp <= '9') - || **pp == '(') - { - read_type_number (pp, typenums); - - /* Detect random reference to type not yet defined. - Allocate a type object but leave it zeroed. */ - if (**pp != '=') - return dbx_alloc_type (typenums); - - *pp += 2; - } - else - { - /* 'typenums=' not present, type is anonymous. Read and return - the definition, but don't put it in the type vector. */ - typenums[0] = typenums[1] = -1; - *pp += 1; - } - - switch ((*pp)[-1]) - { - case 'x': - { - enum type_code code; - - /* Used to index through file_symbols. */ - struct pending *ppt; - int i; - - /* Name including "struct", etc. */ - char *type_name; - - /* Name without "struct", etc. */ - char *type_name_only; - - { - char *prefix; - char *from, *to; - - /* Set the type code according to the following letter. */ - switch ((*pp)[0]) - { - case 's': - code = TYPE_CODE_STRUCT; - prefix = "struct "; - break; - case 'u': - code = TYPE_CODE_UNION; - prefix = "union "; - break; - case 'e': - code = TYPE_CODE_ENUM; - prefix = "enum "; - break; - default: - error ("Bad type cross reference at symnum: %d.", symnum); - } - - to = type_name = (char *) - obstack_alloc (symbol_obstack, - (strlen (prefix) + - ((char *) index (*pp, ':') - (*pp)) + 1)); - - /* Copy the prefix. */ - from = prefix; - while (*to++ = *from++) - ; - to--; - - type_name_only = to; - - /* Copy the name. */ - from = *pp + 1; - while ((*to++ = *from++) != ':') - ; - *--to = '\0'; - - /* Set the pointer ahead of the name which we just read. */ - *pp = from; - -#if 0 - /* The following hack is clearly wrong, because it doesn't - check whether we are in a baseclass. I tried to reproduce - the case that it is trying to fix, but I couldn't get - g++ to put out a cross reference to a basetype. Perhaps - it doesn't do it anymore. */ - /* Note: for C++, the cross reference may be to a base type which - has not yet been seen. In this case, we skip to the comma, - which will mark the end of the base class name. (The ':' - at the end of the base class name will be skipped as well.) - But sometimes (ie. when the cross ref is the last thing on - the line) there will be no ','. */ - from = (char *) index (*pp, ','); - if (from) - *pp = from; -#endif /* 0 */ - } - - /* Now check to see whether the type has already been declared. */ - /* This is necessary at least in the case where the - program says something like - struct foo bar[5]; - The compiler puts out a cross-reference; we better find - set the length of the structure correctly so we can - set the length of the array. */ - for (ppt = file_symbols; ppt; ppt = ppt->next) - for (i = 0; i < ppt->nsyms; i++) - { - struct symbol *sym = ppt->symbol[i]; - - if (SYMBOL_CLASS (sym) == LOC_TYPEDEF - && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE - && (TYPE_CODE (SYMBOL_TYPE (sym)) == code) - && !strcmp (SYMBOL_NAME (sym), type_name_only)) - { - obstack_free (symbol_obstack, type_name); - type = SYMBOL_TYPE (sym); - return type; - } - } - - /* Didn't find the type to which this refers, so we must - be dealing with a forward reference. Allocate a type - structure for it, and keep track of it so we can - fill in the rest of the fields when we get the full - type. */ - type = dbx_alloc_type (typenums); - TYPE_CODE (type) = code; - TYPE_NAME (type) = type_name; - - TYPE_FLAGS (type) |= TYPE_FLAG_STUB; - - add_undefined_type (type); - return type; - } - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '(': - (*pp)--; - read_type_number (pp, xtypenums); - type = *dbx_lookup_type (xtypenums); - if (type == 0) - type = builtin_type_void; - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - break; - - case '*': - type1 = read_type (pp); - if (TYPE_POINTER_TYPE (type1)) - { - type = TYPE_POINTER_TYPE (type1); - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - } - else - { - type = dbx_alloc_type (typenums); - smash_to_pointer_type (type, type1); - } - break; - - case '@': - { - struct type *domain = read_type (pp); - char c; - struct type *memtype; - - if (*(*pp)++ != ',') - error ("invalid member type data format, at symtab pos %d.", - symnum); - - memtype = read_type (pp); - type = dbx_alloc_type (typenums); - smash_to_member_type (type, domain, memtype); - } - break; - - case '#': - { - struct type *domain = read_type (pp); - char c; - struct type *return_type; - struct type **args; - - if (*(*pp)++ != ',') - error ("invalid member type data format, at symtab pos %d.", - symnum); - - return_type = read_type (pp); - args = read_args (pp, ';'); - type = dbx_alloc_type (typenums); - smash_to_method_type (type, domain, return_type, args); - } - break; - - case '&': - type1 = read_type (pp); - if (TYPE_REFERENCE_TYPE (type1)) - { - type = TYPE_REFERENCE_TYPE (type1); - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - } - else - { - type = dbx_alloc_type (typenums); - smash_to_reference_type (type, type1); - } - break; - - case 'f': - type1 = read_type (pp); - if (TYPE_FUNCTION_TYPE (type1)) - { - type = TYPE_FUNCTION_TYPE (type1); - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - } - else - { - type = dbx_alloc_type (typenums); - smash_to_function_type (type, type1); - } - break; - - case 'r': - type = read_range_type (pp, typenums); - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - break; - - case 'e': - type = dbx_alloc_type (typenums); - type = read_enum_type (pp, type); - *dbx_lookup_type (typenums) = type; - break; - - case 's': - type = dbx_alloc_type (typenums); - type = read_struct_type (pp, type); - break; - - case 'u': - type = dbx_alloc_type (typenums); - type = read_struct_type (pp, type); - TYPE_CODE (type) = TYPE_CODE_UNION; - break; - - case 'a': - if (*(*pp)++ != 'r') - error ("Invalid symbol data: unrecognized type-code `a%c' %s %d.", - (*pp)[-1], "at symtab position", symnum); - - type = dbx_alloc_type (typenums); - type = read_array_type (pp, type); - break; - - default: - error ("Invalid symbol data: unrecognized type-code `%c' at symtab pos %d.", - (*pp)[-1], symnum); - } - - if (type == 0) - abort (); - -#if 0 - /* If this is an overriding temporary alteration for a header file's - contents, and this type number is unknown in the global definition, - put this type into the global definition at this type number. */ - if (header_file_prev_index >= 0) - { - register struct type **tp - = explicit_lookup_type (header_file_prev_index, typenums[1]); - if (*tp == 0) - *tp = type; - } -#endif - return type; -} - -/* This page contains subroutines of read_type. */ - -/* Read the description of a structure (or union type) - and return an object describing the type. */ - -static struct type * -read_struct_type (pp, type) - char **pp; - register struct type *type; -{ - struct nextfield - { - struct nextfield *next; - int visibility; - struct field field; - }; - - struct next_fnfield - { - struct next_fnfield *next; - int visibility; - struct fn_field fn_field; - }; - - struct next_fnfieldlist - { - struct next_fnfieldlist *next; - struct fn_fieldlist fn_fieldlist; - }; - - register struct nextfield *list = 0; - struct nextfield *new; - int totalsize; - char *name; - register char *p; - int nfields = 0; - register int n; - - register struct next_fnfieldlist *mainlist = 0; - int nfn_fields = 0; - int read_possible_virtual_info = 0; - - if (TYPE_MAIN_VARIANT (type) == 0) - { - TYPE_MAIN_VARIANT (type) = type; - } - - TYPE_CODE (type) = TYPE_CODE_STRUCT; - - /* First comes the total size in bytes. */ - - TYPE_LENGTH (type) = read_number (pp, 0); - - /* C++: Now, if the class is a derived class, then the next character - will be a '!', followed by the number of base classes derived from. - Each element in the list contains visibility information, - the offset of this base class in the derived structure, - and then the base type. */ - if (**pp == '!') - { - int i, n_baseclasses, offset; - struct type **baseclass_vec; - struct type *baseclass; - int via_public; - - /* Nonzero if it is a virtual baseclass, i.e., - - struct A{}; - struct B{}; - struct C : public B, public virtual A {}; - - B is a baseclass of C; A is a virtual baseclass for C. This is a C++ - 2.0 language feature. */ - int via_virtual; - - *pp += 1; - - n_baseclasses = read_number (pp, ','); - baseclass_vec = (struct type **) - obstack_alloc (symbol_obstack, - (n_baseclasses) * sizeof (struct type **)) - 1; - - for (i = 1; i <= n_baseclasses; i++) - { - if (**pp == '\\') - *pp = next_symbol_text (); - - switch (*(*pp)++) - { - case '0': - via_virtual = 0; - break; - case '1': - via_virtual = 1; - break; - default: - error ("Invalid symbol data: bad visibility format at symtab pos %d", - symnum); - } - - switch (*(*pp)++) - { - case '0': - via_public = 0; - break; - case '2': - via_public = 1; - break; - default: - error ("Invalid symbol data: bad visibility format at symtab pos %d.", - symnum); - } - - /* Offset of the portion of the object corresponding to - this baseclass. Always zero in the absence of - multiple inheritance. */ - offset = read_number (pp, ','); - baseclass = read_type (pp); - *pp += 1; /* skip trailing ';' */ - - if (offset != 0) - { - static int error_printed = 0; - - if (!error_printed) - { - fprintf (stderr, -"\nWarning: GDB has limited understanding of multiple inheritance..."); - error_printed = 1; - } - offset = 0; - } - - baseclass_vec[i] = lookup_basetype_type (baseclass, offset, via_virtual, via_public); - - /* Since lookup_basetype_type can copy the type, - it might copy a stub type (complete with stub flag). - If so, we need to add it to the list of undefined types - to clean up later. Even if lookup_basetype_type - didn't copy the type, adding it to the undefined list - will not do any harm. */ - if (TYPE_FLAGS(baseclass_vec[i]) & TYPE_FLAG_STUB) - add_undefined_type (baseclass_vec[i]); - - /* Make this baseclass visible for structure-printing purposes. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - list->field.type = baseclass_vec[i]; - list->field.name = TYPE_NAME (baseclass_vec[i]); - list->field.bitpos = offset; - list->field.bitsize = 0; /* this should be an unpacked field! */ - nfields++; - } - TYPE_N_BASECLASSES (type) = n_baseclasses; - TYPE_BASECLASSES (type) = baseclass_vec; - } - - /* Now come the fields, as NAME:?TYPENUM,BITPOS,BITSIZE; for each one. - At the end, we see a semicolon instead of a field. - - In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for - a static field. - - The `?' is a placeholder for one of '+' (public visibility), - '0' (protected visibility), and '-' (private visibility). */ - - /* We better set p right now, in case there are no fields at all... */ - p = *pp; - - while (**pp != ';') - { - int visibility; - - /* Check for and handle cretinous dbx symbol name continuation! */ - if (**pp == '\\') *pp = next_symbol_text (); - - /* Get space to record the next field's data. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - - /* Get the field name. */ - p = *pp; - while (*p != ':') p++; - list->field.name = obsavestring (*pp, p - *pp); - - /* C++: Check to see if we have hit the methods yet. */ - if (p[1] == ':') - break; - - *pp = p + 1; - - /* This means we have a visibility for a field coming. */ - if (**pp == '/') - { - switch (*++*pp) - { - case '0': - visibility = 0; - *pp += 1; - break; - - case '1': - visibility = 1; - *pp += 1; - break; - - case '2': - visibility = 2; - *pp += 1; - break; - } - } - /* else normal dbx-style format. */ - - list->field.type = read_type (pp); - if (**pp == ':') - { - list->field.bitpos = (long)-1; - p = ++(*pp); - while (*p != ';') p++; - list->field.bitsize = (long) savestring (*pp, p - *pp); - *pp = p + 1; - nfields++; - continue; - } - else if (**pp != ',') - error ("Invalid symbol data: bad structure-type format at symtab pos %d.", - symnum); - (*pp)++; /* Skip the comma. */ - list->field.bitpos = read_number (pp, ','); - list->field.bitsize = read_number (pp, ';'); - -#if 0 - /* This is wrong because this is identical to the symbols - produced for GCC 0-size arrays. For example: - typedef union { - int num; - char str[0]; - } foo; - The code which dumped core in such circumstances should be - fixed not to dump core. */ - - /* g++ -g0 can put out bitpos & bitsize zero for a static - field. This does not give us any way of getting its - class, so we can't know its name. But we can just - ignore the field so we don't dump core and other nasty - stuff. */ - if (list->field.bitpos == 0 - && list->field.bitsize == 0) - { - /* Have we given the warning yet? */ - static int warning_given = 0; - - /* Only give the warning once, no matter how many class - variables there are. */ - if (!warning_given) - { - warning_given = 1; - fprintf_filtered (stderr, "\n\ -Warning: DBX-style class variable debugging information encountered.\n\ -You seem to have compiled your program with \ -\"g++ -g0\" instead of \"g++ -g\".\n\ -Therefore GDB will not know about your class variables.\n\ -"); - } - - /* Ignore this field. */ - list = list->next; - } - else -#endif /* 0 */ - { - /* Detect an unpacked field and mark it as such. - dbx gives a bit size for all fields. - Note that forward refs cannot be packed, - and treat enums as if they had the width of ints. */ - if (TYPE_CODE (list->field.type) != TYPE_CODE_INT - && TYPE_CODE (list->field.type) != TYPE_CODE_ENUM) - list->field.bitsize = 0; - if ((list->field.bitsize == 8 * TYPE_LENGTH (list->field.type) - || (TYPE_CODE (list->field.type) == TYPE_CODE_ENUM - && (list->field.bitsize - == 8 * TYPE_LENGTH (builtin_type_int)) - ) - ) - && - list->field.bitpos % 8 == 0) - list->field.bitsize = 0; - nfields++; - } - } - - /* Now come the method fields, as NAME::methods - where each method is of the form TYPENUM,ARGS,...:PHYSNAME; - At the end, we see a semicolon instead of a field. - - For the case of overloaded operators, the format is - OPERATOR::*.methods, where OPERATOR is the string "operator", - `*' holds the place for an operator name (such as `+=') - and `.' marks the end of the operator name. */ - if (p[1] == ':') - { - /* Now, read in the methods. To simplify matters, we - "unread" the name that has been read, so that we can - start from the top. */ - - p = *pp; - - /* chill the list of fields: the last entry (at the head) - is a partially constructed entry which we now scrub. */ - list = list->next; - - /* For each list of method lists... */ - do - { - int i; - struct next_fnfield *sublist = 0; - struct fn_field *fn_fields = 0; - int length = 0; - struct next_fnfieldlist *new_mainlist = - (struct next_fnfieldlist *)alloca (sizeof (struct next_fnfieldlist)); - - /* read in the name. */ - while (*p != ':') p++; - if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && (*pp)[2] == '$') - { - static char opname[] = "operator"; - char *o = opname + strlen(opname); - - /* Skip past '::'. */ - p += 2; - while (*p != '.') - *o++ = *p++; - new_mainlist->fn_fieldlist.name = savestring (opname, o - opname); - /* Skip past '.' */ - *pp = p + 1; - } - else - { - i = 0; - new_mainlist->fn_fieldlist.name = savestring (*pp, p - *pp); - /* Skip past '::'. */ - *pp = p + 2; - } - - do - { - struct next_fnfield *new_sublist = - (struct next_fnfield *)alloca (sizeof (struct next_fnfield)); - - /* Check for and handle cretinous dbx symbol name continuation! */ - if (**pp == '\\') *pp = next_symbol_text (); - - new_sublist->fn_field.type = read_type (pp); - if (**pp != ':') - error ("invalid symtab info for method at symbol number %d.", - symnum); - *pp += 1; - new_sublist->fn_field.args = - TYPE_ARG_TYPES (new_sublist->fn_field.type); - p = *pp; - while (*p != ';') p++; - new_sublist->fn_field.physname = savestring (*pp, p - *pp); - *pp = p + 1; - new_sublist->visibility = *(*pp)++ - '0'; - if (**pp == '\\') *pp = next_symbol_text (); - - switch (*(*pp)++) - { - case '*': - /* virtual member function, followed by index. */ - new_sublist->fn_field.voffset = read_number (pp, ';') + 1; - break; - case '?': - /* static member function. */ - new_sublist->fn_field.voffset = 1; - break; - default: - /* **pp == '.'. */ - /* normal member function. */ - new_sublist->fn_field.voffset = 0; - break; - } - - new_sublist->next = sublist; - sublist = new_sublist; - length++; - } - while (**pp != ';'); - - *pp += 1; - - new_mainlist->fn_fieldlist.fn_fields = - (struct fn_field *) obstack_alloc (symbol_obstack, - sizeof (struct fn_field) * length); - TYPE_FN_PRIVATE_BITS (new_mainlist->fn_fieldlist) = - (int *) obstack_alloc (symbol_obstack, - sizeof (int) * (1 + (length >> 5))); - - TYPE_FN_PROTECTED_BITS (new_mainlist->fn_fieldlist) = - (int *) obstack_alloc (symbol_obstack, - sizeof (int) * (1 + (length >> 5))); - - for (i = length; sublist; sublist = sublist->next) - { - new_mainlist->fn_fieldlist.fn_fields[--i] = sublist->fn_field; - if (sublist->visibility == 0) - B_SET (new_mainlist->fn_fieldlist.private_fn_field_bits, i); - else if (sublist->visibility == 1) - B_SET (new_mainlist->fn_fieldlist.protected_fn_field_bits, i); - } - - new_mainlist->fn_fieldlist.length = length; - new_mainlist->next = mainlist; - mainlist = new_mainlist; - nfn_fields++; - } - while (**pp != ';'); - } - - *pp += 1; - - /* Now create the vector of fields, and record how big it is. */ - - TYPE_NFIELDS (type) = nfields; - TYPE_FIELDS (type) = (struct field *) obstack_alloc (symbol_obstack, - sizeof (struct field) * nfields); - TYPE_FIELD_PRIVATE_BITS (type) = - (int *) obstack_alloc (symbol_obstack, - sizeof (int) * (1 + (nfields >> 5))); - TYPE_FIELD_PROTECTED_BITS (type) = - (int *) obstack_alloc (symbol_obstack, - sizeof (int) * (1 + (nfields >> 5))); - - TYPE_NFN_FIELDS (type) = nfn_fields; - TYPE_NFN_FIELDS_TOTAL (type) = nfn_fields; - - { - int i; - for (i = 1; i <= TYPE_N_BASECLASSES (type); ++i) - TYPE_NFN_FIELDS_TOTAL (type) += - TYPE_NFN_FIELDS_TOTAL (TYPE_BASECLASS (type, i)); - } - - TYPE_FN_FIELDLISTS (type) = - (struct fn_fieldlist *) obstack_alloc (symbol_obstack, - sizeof (struct fn_fieldlist) * nfn_fields); - - /* Copy the saved-up fields into the field vector. */ - - for (n = nfields; list; list = list->next) - { - TYPE_FIELD (type, --n) = list->field; - if (list->visibility == 0) - SET_TYPE_FIELD_PRIVATE (type, n); - else if (list->visibility == 1) - SET_TYPE_FIELD_PROTECTED (type, n); - } - - for (n = nfn_fields; mainlist; mainlist = mainlist->next) - TYPE_FN_FIELDLISTS (type)[--n] = mainlist->fn_fieldlist; - - if (**pp == '~') - { - *pp += 1; - - if (**pp == '=') - { - TYPE_FLAGS (type) - |= TYPE_FLAG_HAS_CONSTRUCTOR | TYPE_FLAG_HAS_DESTRUCTOR; - *pp += 1; - } - else if (**pp == '+') - { - TYPE_FLAGS (type) |= TYPE_FLAG_HAS_CONSTRUCTOR; - *pp += 1; - } - else if (**pp == '-') - { - TYPE_FLAGS (type) |= TYPE_FLAG_HAS_DESTRUCTOR; - *pp += 1; - } - - /* Read either a '%' or the final ';'. */ - if (*(*pp)++ == '%') - { - /* Now we must record the virtual function table pointer's - field information. */ - - struct type *t; - int i; - - t = read_type (pp); - p = (*pp)++; - while (*p != ';') p++; - TYPE_VPTR_BASETYPE (type) = t; - if (type == t) - { - if (TYPE_FIELD_NAME (t, 0) == 0) - TYPE_VPTR_FIELDNO (type) = i = 0; - else for (i = TYPE_NFIELDS (t) - 1; i >= 0; --i) - if (! strncmp (TYPE_FIELD_NAME (t, i), *pp, - strlen (TYPE_FIELD_NAME (t, i)))) - { - TYPE_VPTR_FIELDNO (type) = i; - break; - } - if (i < 0) - error ("virtual function table field not found"); - } - else - TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, 1)); - *pp = p + 1; - } - else - { - TYPE_VPTR_BASETYPE (type) = 0; - TYPE_VPTR_FIELDNO (type) = -1; - } - } - else - { - TYPE_VPTR_BASETYPE (type) = 0; - TYPE_VPTR_FIELDNO (type) = -1; - } - - return type; -} - -/* Read a definition of an array type, - and create and return a suitable type object. - Also creates a range type which represents the bounds of that - array. */ -static struct type * -read_array_type (pp, type) - register char **pp; - register struct type *type; -{ - struct type *index_type, *element_type, *range_type; - int lower, upper; - int adjustable = 0; - - /* Format of an array type: - "ar;lower;upper;". Put code in - to handle this. - - Fortran adjustable arrays use Adigits or Tdigits for lower or upper; - for these, produce a type like float[][]. */ - - index_type = read_type (pp); - if (*(*pp)++ != ';') - error ("Invalid symbol data; improper format of array type decl."); - - if (!(**pp >= '0' && **pp <= '9')) - { - *pp += 1; - adjustable = 1; - } - lower = read_number (pp, ';'); - - if (!(**pp >= '0' && **pp <= '9')) - { - *pp += 1; - adjustable = 1; - } - upper = read_number (pp, ';'); - - element_type = read_type (pp); - - if (adjustable) - { - lower = 0; - upper = -1; - } - - { - /* Create range type. */ - range_type = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - TYPE_CODE (range_type) = TYPE_CODE_RANGE; - TYPE_TARGET_TYPE (range_type) = index_type; - - /* This should never be needed. */ - TYPE_LENGTH (range_type) = sizeof (int); - - TYPE_NFIELDS (range_type) = 2; - TYPE_FIELDS (range_type) = - (struct field *) obstack_alloc (symbol_obstack, - 2 * sizeof (struct field)); - TYPE_FIELD_BITPOS (range_type, 0) = lower; - TYPE_FIELD_BITPOS (range_type, 1) = upper; - } - - TYPE_CODE (type) = TYPE_CODE_ARRAY; - TYPE_TARGET_TYPE (type) = element_type; - TYPE_LENGTH (type) = (upper - lower + 1) * TYPE_LENGTH (element_type); - TYPE_NFIELDS (type) = 1; - TYPE_FIELDS (type) = - (struct field *) obstack_alloc (symbol_obstack, - sizeof (struct field)); - TYPE_FIELD_TYPE (type, 0) = range_type; - - return type; -} - - -/* Read a definition of an enumeration type, - and create and return a suitable type object. - Also defines the symbols that represent the values of the type. */ - -static struct type * -read_enum_type (pp, type) - register char **pp; - register struct type *type; -{ - register char *p; - char *name; - register long n; - register struct symbol *sym; - int nsyms = 0; - struct pending **symlist; - struct pending *osyms, *syms; - int o_nsyms; - - if (within_function) - symlist = &local_symbols; - else - symlist = &file_symbols; - osyms = *symlist; - o_nsyms = osyms ? osyms->nsyms : 0; - - /* Read the value-names and their values. - The input syntax is NAME:VALUE,NAME:VALUE, and so on. - A semicolon or comman instead of a NAME means the end. */ - while (**pp && **pp != ';' && **pp != ',') - { - /* Check for and handle cretinous dbx symbol name continuation! */ - if (**pp == '\\') *pp = next_symbol_text (); - - p = *pp; - while (*p != ':') p++; - name = obsavestring (*pp, p - *pp); - *pp = p + 1; - n = read_number (pp, ','); - - sym = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol)); - bzero (sym, sizeof (struct symbol)); - SYMBOL_NAME (sym) = name; - SYMBOL_CLASS (sym) = LOC_CONST; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - SYMBOL_VALUE (sym) = n; - add_symbol_to_list (sym, symlist); - nsyms++; - } - - if (**pp == ';') - (*pp)++; /* Skip the semicolon. */ - - /* Now fill in the fields of the type-structure. */ - - TYPE_LENGTH (type) = sizeof (int); - TYPE_CODE (type) = TYPE_CODE_ENUM; - TYPE_NFIELDS (type) = nsyms; - TYPE_FIELDS (type) = (struct field *) obstack_alloc (symbol_obstack, sizeof (struct field) * nsyms); - - /* Find the symbols for the values and put them into the type. - The symbols can be found in the symlist that we put them on - to cause them to be defined. osyms contains the old value - of that symlist; everything up to there was defined by us. */ - /* Note that we preserve the order of the enum constants, so - that in something like "enum {FOO, LAST_THING=FOO}" we print - FOO, not LAST_THING. */ - - for (syms = *symlist, n = 0; syms; syms = syms->next) - { - int j = 0; - if (syms == osyms) - j = o_nsyms; - for (; j < syms->nsyms; j++) - { - struct symbol *sym = syms->symbol[j]; - SYMBOL_TYPE (sym) = type; - TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (sym); - TYPE_FIELD_VALUE (type, n) = 0; - TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (sym); - TYPE_FIELD_BITSIZE (type, n++) = 0; - } - if (syms == osyms) - break; - } - - return type; -} - -#define MAX_OF_TYPE(t) ((1 << (sizeof (t) - 1)) - 1) -#define MIN_OF_TYPE(t) (-(1 << (sizeof (t) - 1))) - -static struct type * -read_range_type (pp, typenums) - char **pp; - int typenums[2]; -{ - int rangenums[2]; - long n2, n3; - int n2bits, n3bits; - int self_subrange; - struct type *result_type; - struct type *index_type; - - /* First comes a type we are a subrange of. - In C it is usually 0, 1 or the type being defined. */ - read_type_number (pp, rangenums); - self_subrange = (rangenums[0] == typenums[0] && - rangenums[1] == typenums[1]); - - /* A semicolon should now follow; skip it. */ - if (**pp == ';') - (*pp)++; - - /* The remaining two operands are usually lower and upper bounds - of the range. But in some special cases they mean something else. */ - read_huge_number (pp, ';', &n2, &n2bits); - read_huge_number (pp, ';', &n3, &n3bits); - - if (n2bits == -1 || n3bits == -1) - error ("Unrecognized type range %s.", pp); - - if (n2bits != 0 || n3bits != 0) -#ifdef LONG_LONG - { - char got_signed = 0; - char got_unsigned = 0; - /* Number of bits in the type. */ - int nbits; - - /* Range from 0 to is an unsigned large integral type. */ - if ((n2bits == 0 && n2 == 0) && n3bits != 0) - { - got_unsigned = 1; - nbits = n3bits; - } - /* Range fro to -1 is a large signed - integral type. */ - else if (n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1) - { - got_signed = 1; - nbits = n2bits; - } - - /* Check for "long long". */ - if (got_signed && nbits == CHAR_BIT * sizeof (long long)) - return builtin_type_long_long; - if (got_unsigned && nbits == CHAR_BIT * sizeof (long long)) - return builtin_type_unsigned_long_long; - - error ("Large type isn't a long long."); - } -#else /* LONG_LONG */ - error ("Type long long not supported on this machine."); -#endif - - /* A type defined as a subrange of itself, with bounds both 0, is void. */ - if (self_subrange && n2 == 0 && n3 == 0) - return builtin_type_void; - - /* If n3 is zero and n2 is not, we want a floating type, - and n2 is the width in bytes. - - Fortran programs appear to use this for complex types also, - and they give no way to distinguish between double and single-complex! - We don't have complex types, so we would lose on all fortran files! - So return type `double' for all of those. It won't work right - for the complex values, but at least it makes the file loadable. */ - - if (n3 == 0 && n2 > 0) - { - if (n2 == sizeof (float)) - return builtin_type_float; - return builtin_type_double; - } - - /* If the upper bound is -1, it must really be an unsigned int. */ - - else if (n2 == 0 && n3 == -1) - { - if (sizeof (int) == sizeof (long)) - return builtin_type_unsigned_int; - else - return builtin_type_unsigned_long; - } - - /* Special case: char is defined (Who knows why) as a subrange of - itself with range 0-127. */ - else if (self_subrange && n2 == 0 && n3 == 127) - return builtin_type_char; - - /* Assumptions made here: Subrange of self is equivalent to subrange - of int. */ - else if (n2 == 0 - && (self_subrange || - *dbx_lookup_type (rangenums) == builtin_type_int)) - { - /* an unsigned type */ - if (n3 == UINT_MAX) - return builtin_type_unsigned_int; - if (n3 == ULONG_MAX) - return builtin_type_unsigned_long; - if (n3 == USHRT_MAX) - return builtin_type_unsigned_short; - if (n3 == UCHAR_MAX) - return builtin_type_unsigned_char; - } -#ifdef LONG_LONG - else if (n3 == 0 && n2 == -sizeof (long long)) - return builtin_type_long_long; -#endif - else if (n2 == -n3 -1) - { - /* a signed type */ - if (n3 == INT_MAX) - return builtin_type_int; - if (n3 == LONG_MAX) - return builtin_type_long; - if (n3 == SHRT_MAX) - return builtin_type_short; - if (n3 == CHAR_MAX) - return builtin_type_char; - } - - /* We have a real range type on our hands. Allocate space and - return a real pointer. */ - - /* At this point I don't have the faintest idea how to deal with - a self_subrange type; I'm going to assume that this is used - as an idiom, and that all of them are special cases. So . . . */ - if (self_subrange) - error ("Type defined as subrange of itself: %s.", pp); - - result_type = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - bzero (result_type, sizeof (struct type)); - - TYPE_TARGET_TYPE (result_type) = (self_subrange ? - builtin_type_int : - *dbx_lookup_type(rangenums)); - - /* We have to figure out how many bytes it takes to hold this - range type. I'm going to assume that anything that is pushing - the bounds of a long was taken care of above. */ - if (n2 >= MIN_OF_TYPE(char) && n3 <= MAX_OF_TYPE(char)) - TYPE_LENGTH (result_type) = 1; - else if (n2 >= MIN_OF_TYPE(short) && n3 <= MAX_OF_TYPE(short)) - TYPE_LENGTH (result_type) = sizeof (short); - else if (n2 >= MIN_OF_TYPE(int) && n3 <= MAX_OF_TYPE(int)) - TYPE_LENGTH (result_type) = sizeof (int); - else if (n2 >= MIN_OF_TYPE(long) && n3 <= MAX_OF_TYPE(long)) - TYPE_LENGTH (result_type) = sizeof (long); - else - error ("Ranged type doesn't fit within known sizes."); - - TYPE_LENGTH (result_type) = TYPE_LENGTH (TYPE_TARGET_TYPE (result_type)); - TYPE_CODE (result_type) = TYPE_CODE_RANGE; - TYPE_NFIELDS (result_type) = 2; - TYPE_FIELDS (result_type) = - (struct field *) obstack_alloc (symbol_obstack, - 2 * sizeof (struct field)); - bzero (TYPE_FIELDS (result_type), 2 * sizeof (struct field)); - TYPE_FIELD_BITPOS (result_type, 0) = n2; - TYPE_FIELD_BITPOS (result_type, 1) = n3; - - return result_type; -} - -/* Read a number from the string pointed to by *PP. - The value of *PP is advanced over the number. - If END is nonzero, the character that ends the - number must match END, or an error happens; - and that character is skipped if it does match. - If END is zero, *PP is left pointing to that character. */ - -static long -read_number (pp, end) - char **pp; - int end; -{ - register char *p = *pp; - register long n = 0; - register int c; - int sign = 1; - - /* Handle an optional leading minus sign. */ - - if (*p == '-') - { - sign = -1; - p++; - } - - /* Read the digits, as far as they go. */ - - while ((c = *p++) >= '0' && c <= '9') - { - n *= 10; - n += c - '0'; - } - if (end) - { - if (c && c != end) - error ("Invalid symbol data: invalid character \\%03o at symbol pos %d.", c, symnum); - } - else - --p; - - *pp = p; - return n * sign; -} - -static void -read_huge_number (pp, end, valu, bits) - char **pp; - int end; - long *valu; - int *bits; -{ - char *p = *pp; - int sign = 1; - long n = 0; - int radix = 10; - char overflow = 0; - int nbits = 0; - int c; - long upper_limit; - - /* Handle an optional leading minus sign. */ - - if (*p == '-') - { - sign = -1; - p++; - } - - /* Leading zero means octal. GCC uses this to output values larger - than an int (because that would be hard in decimal). */ - if (*p == '0') - { - radix = 8; - p++; - } - - upper_limit = LONG_MAX / radix; - while ((c = *p++) >= '0' && c <= '9') - { - if (n <= upper_limit) - { - n *= radix; - n += c - '0'; - } - else - overflow = 1; - - /* This depends on large values being output in octal, which is - what GCC does. */ - if (radix == 8) - { - if (nbits == 0) - { - if (c == '0') - /* Ignore leading zeroes. */ - ; - else if (c == '1') - nbits = 1; - else if (c == '2' || c == '3') - nbits = 2; - else - nbits = 3; - } - else - nbits += 3; - } - } - if (end) - { - if (c && c != end) - { - if (bits != NULL) - *bits = -1; - return; - } - } - else - --p; - - *pp = p; - if (overflow) - { - if (nbits == 0) - { - /* Large decimal constants are an error (because it is hard to - count how many bits are in them). */ - if (bits != NULL) - *bits = -1; - return; - } - - /* -0x7f is the same as 0x80. So deal with it by adding one to - the number of bits. */ - if (sign == -1) - ++nbits; - if (bits) - *bits = nbits; - } - else - { - if (valu) - *valu = n * sign; - if (bits) - *bits = 0; - } -} - -/* Read in an argument list. This is a list of types. It is terminated with - a ':', FYI. Return the list of types read in. */ -static struct type ** -read_args (pp, end) - char **pp; - int end; -{ - struct type *types[1024], **rval; /* allow for fns of 1023 parameters */ - int n = 0; - - while (**pp != end) - { - if (**pp != ',') - error ("Invalid argument list: no ',', at symtab pos %d", symnum); - *pp += 1; - - /* Check for and handle cretinous dbx symbol name continuation! */ - if (**pp == '\\') - *pp = next_symbol_text (); - - types[n++] = read_type (pp); - } - *pp += 1; /* get past `end' (the ':' character) */ - - if (n == 1) - { - rval = (struct type **) xmalloc (2 * sizeof (struct type *)); - } - else if (TYPE_CODE (types[n-1]) != TYPE_CODE_VOID) - { - rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *)); - bzero (rval + n, sizeof (struct type *)); - } - else - { - rval = (struct type **) xmalloc (n * sizeof (struct type *)); - } - bcopy (types, rval, n * sizeof (struct type *)); - return rval; -} - -/* This function is really horrible, but to avoid it, there would need - to be more filling in of forward references. THIS SHOULD BE MOVED OUT - OF COFFREAD.C AND DBXREAD.C TO SOME PLACE WHERE IT CAN BE SHARED */ -int -fill_in_vptr_fieldno (type) - struct type *type; -{ - if (TYPE_VPTR_FIELDNO (type) < 0) - TYPE_VPTR_FIELDNO (type) = - fill_in_vptr_fieldno (TYPE_BASECLASS (type, 1)); - return TYPE_VPTR_FIELDNO (type); -} - -/* Copy a pending list, used to record the contents of a common - block for later fixup. BUG FIX by rde@topexpress.co.uk */ -static struct pending * -copy_pending (beg, begi, end) - struct pending *beg, *end; - int begi; -{ - struct pending *new = 0; - struct pending *next; - - /* rde note: `begi' is an offset in block `end', NOT `beg' */ - for (next = beg; next != 0; next = next->next) - { - register int j; - for (j = next == end ? begi : 0; j < next->nsyms; j++) - add_symbol_to_list (next->symbol[j], &new); - - if (next == end) - break; - } - return new; -} - -/* Add a common block's start address to the offset of each symbol - declared to be in it (by being between a BCOMM/ECOMM pair that uses - the common block name). */ - -static void -fix_common_block (sym, value) - struct symbol *sym; - int value; -{ - struct pending *next = (struct pending *) SYMBOL_NAMESPACE (sym); - for ( ; next; next = next->next) - { - register int j; - for (j = next->nsyms - 1; j >= 0; j--) - SYMBOL_VALUE (next->symbol[j]) += value; - } -} - -void -_initialize_dbxread () -{ - symfile = 0; - header_files = (struct header_file *) 0; - this_object_header_files = (int *) 0; - - undef_types_allocated = 20; - undef_types_length = 0; - undef_types = (struct type **) xmalloc (undef_types_allocated * - sizeof (struct type *)); - - add_com ("symbol-file", class_files, symbol_file_command, - "Load symbol table (in dbx format) from executable file FILE."); - - add_com ("add-file", class_files, add_file_command, - "Load the symbols from FILE, assuming its code is at TEXT_START.") ; -} - -#endif /* READ_DBX_FORMAT */ diff --git a/gnu/usr.bin/gdb/defs.h b/gnu/usr.bin/gdb/defs.h deleted file mode 100644 index 150cf5a712cd..000000000000 --- a/gnu/usr.bin/gdb/defs.h +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - * - * from: @(#)defs.h 6.3 (Berkeley) 5/8/91 - * $Id: defs.h,v 1.2 1993/08/01 18:47:56 mycroft Exp $ - */ - -/* Basic definitions for GDB, the GNU debugger. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define CORE_ADDR unsigned int - -#define min(a, b) ((a) < (b) ? (a) : (b)) -#define max(a, b) ((a) > (b) ? (a) : (b)) - -extern char *savestring (); -extern char *concat (); -extern char *xmalloc (), *xrealloc (); -extern int parse_escape (); -extern char *reg_names[]; - -/* Various possibilities for alloca. */ -#ifdef sparc -#include -#else -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -extern char *alloca (); -#endif -#endif - -extern int quit_flag; - -extern int immediate_quit; - -#define QUIT { if (quit_flag) quit (); } - -/* Notes on classes: class_alias is for alias commands which are not - abbreviations of the original command. */ - -enum command_class -{ - no_class = -1, class_run = 0, class_vars, class_stack, - class_files, class_support, class_info, class_breakpoint, - class_alias, class_obscure, class_user, -}; - -/* the cleanup list records things that have to be undone - if an error happens (descriptors to be closed, memory to be freed, etc.) - Each link in the chain records a function to call and an - argument to give it. - - Use make_cleanup to add an element to the cleanup chain. - Use do_cleanups to do all cleanup actions back to a given - point in the chain. Use discard_cleanups to remove cleanups - from the chain back to a given point, not doing them. */ - -struct cleanup -{ - struct cleanup *next; - void (*function) (); - int arg; -}; - -extern void do_cleanups (); -extern void discard_cleanups (); -extern struct cleanup *make_cleanup (); -extern struct cleanup *save_cleanups (); -extern void restore_cleanups (); -extern void free_current_contents (); -extern void reinitialize_more_filter (); -extern void fputs_filtered (); -extern void fprintf_filtered (); -extern void printf_filtered (); -extern void print_spaces_filtered (); -extern char *tilde_expand (); - -/* Structure for saved commands lines - (for breakpoints, defined commands, etc). */ - -struct command_line -{ - struct command_line *next; - char *line; - int type; /* statement type */ -#define CL_END 0 -#define CL_NORMAL 1 -#define CL_WHILE 2 -#define CL_IF 3 -#define CL_EXITLOOP 4 -#define CL_NOP 5 - struct command_line *body; /* body of loop for while, body of if */ - struct command_line *elsebody; /* body of else part of if */ -}; - -extern struct command_line *read_command_lines (); -extern void do_command_lines(); - -/* String containing the current directory (what getwd would return). */ - -char *current_directory; - diff --git a/gnu/usr.bin/gdb/environ.c b/gnu/usr.bin/gdb/environ.c deleted file mode 100644 index fed31c91b8ca..000000000000 --- a/gnu/usr.bin/gdb/environ.c +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)environ.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: environ.c,v 1.2 1993/08/01 18:47:21 mycroft Exp $"; -#endif /* not lint */ - -/* environ.c -- library for manipulating environments for GNU. - Copyright (C) 1986, 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 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. */ - -#define min(a, b) ((a) < (b) ? (a) : (b)) -#define max(a, b) ((a) > (b) ? (a) : (b)) - -#include "environ.h" - -/* Return a new environment object. */ - -struct environ * -make_environ () -{ - register struct environ *e; - - e = (struct environ *) xmalloc (sizeof (struct environ)); - - e->allocated = 10; - e->vector = (char **) xmalloc ((e->allocated + 1) * sizeof (char *)); - e->vector[0] = 0; - return e; -} - -/* Free an environment and all the strings in it. */ - -void -free_environ (e) - register struct environ *e; -{ - register char **vector = e->vector; - - while (*vector) - free (*vector++); - - free (e); -} - -/* Copy the environment given to this process into E. - Also copies all the strings in it, so we can be sure - that all strings in these environments are safe to free. */ - -void -init_environ (e) - register struct environ *e; -{ - extern char **environ; - register int i; - - for (i = 0; environ[i]; i++); - - if (e->allocated < i) - { - e->allocated = max (i, e->allocated + 10); - e->vector = (char **) xrealloc (e->vector, - (e->allocated + 1) * sizeof (char *)); - } - - bcopy (environ, e->vector, (i + 1) * sizeof (char *)); - - while (--i >= 0) - { - register int len = strlen (e->vector[i]) + 1; - register char *new = (char *) xmalloc (len); - bcopy (e->vector[i], new, len); - e->vector[i] = new; - } -} - -/* Return the vector of environment E. - This is used to get something to pass to execve. */ - -char ** -environ_vector (e) - struct environ *e; -{ - return e->vector; -} - -/* Return the value in environment E of variable VAR. */ - -char * -get_in_environ (e, var) - struct environ *e; - char *var; -{ - register int len = strlen (var); - register char **vector = e->vector; - register char *s; - - for (; s = *vector; vector++) - if (!strncmp (s, var, len) - && s[len] == '=') - return &s[len + 1]; - - return 0; -} - -/* Store the value in E of VAR as VALUE. */ - -void -set_in_environ (e, var, value) - struct environ *e; - char *var; - char *value; -{ - register int i; - register int len = strlen (var); - register char **vector = e->vector; - register char *s; - - for (i = 0; s = vector[i]; i++) - if (!strncmp (s, var, len) - && s[len] == '=') - break; - - if (s == 0) - { - if (i == e->allocated) - { - e->allocated += 10; - vector = (char **) xrealloc (vector, - (e->allocated + 1) * sizeof (char *)); - e->vector = vector; - } - vector[i + 1] = 0; - } - else - free (s); - - s = (char *) xmalloc (len + strlen (value) + 2); - strcpy (s, var); - strcat (s, "="); - strcat (s, value); - vector[i] = s; - return; -} - -/* Remove the setting for variable VAR from environment E. */ - -void -unset_in_environ (e, var) - struct environ *e; - char *var; -{ - register int len = strlen (var); - register char **vector = e->vector; - register char *s; - - for (; s = *vector; vector++) - if (!strncmp (s, var, len) - && s[len] == '=') - { - free (s); - bcopy (vector + 1, vector, - (e->allocated - (vector - e->vector)) * sizeof (char *)); - e->vector[e->allocated - 1] = 0; - return; - } -} diff --git a/gnu/usr.bin/gdb/environ.h b/gnu/usr.bin/gdb/environ.h deleted file mode 100644 index 45464308cd2e..000000000000 --- a/gnu/usr.bin/gdb/environ.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Header for environment manipulation library. - Copyright (C) 1989, Free Software Foundation. - - 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. - - $Id: environ.h,v 1.2 1993/08/02 17:40:57 mycroft Exp $ -*/ - -/* We manipulate environments represented as these structures. */ - -struct environ -{ - /* Number of usable slots allocated in VECTOR. - VECTOR always has one slot not counted here, - to hold the terminating zero. */ - int allocated; - /* A vector of slots, ALLOCATED + 1 of them. - The first few slots contain strings "VAR=VALUE" - and the next one contains zero. - Then come some unused slots. */ - char **vector; -}; - -struct environ *make_environ (); -void free_environ (); -void init_environ (); -char *get_in_environ (); -void set_in_environ (); -void unset_in_environ (); -char **environ_vector (); diff --git a/gnu/usr.bin/gdb/eval.c b/gnu/usr.bin/gdb/eval.c deleted file mode 100644 index ac9e562ae348..000000000000 --- a/gnu/usr.bin/gdb/eval.c +++ /dev/null @@ -1,1066 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)eval.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: eval.c,v 1.2 1993/08/01 18:47:20 mycroft Exp $"; -#endif /* not lint */ - -/* Evaluate expressions for GDB. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "value.h" -#include "expression.h" - - -/* Parse the string EXP as a C expression, evaluate it, - and return the result as a number. */ - -CORE_ADDR -parse_and_eval_address (exp) - char *exp; -{ - struct expression *expr = parse_c_expression (exp); - register CORE_ADDR addr; - register struct cleanup *old_chain - = make_cleanup (free_current_contents, &expr); - - addr = (CORE_ADDR) value_as_long (evaluate_expression (expr)); - do_cleanups (old_chain); - return addr; -} - -/* Like parse_and_eval_address but takes a pointer to a char * variable - and advanced that variable across the characters parsed. */ - -CORE_ADDR -parse_and_eval_address_1 (expptr) - char **expptr; -{ - struct expression *expr = parse_c_1 (expptr, 0, 0); - register CORE_ADDR addr; - register struct cleanup *old_chain - = make_cleanup (free_current_contents, &expr); - - addr = value_as_long (evaluate_expression (expr)); - do_cleanups (old_chain); - return addr; -} - -value -parse_and_eval (exp) - char *exp; -{ - struct expression *expr = parse_c_expression (exp); - register value val; - register struct cleanup *old_chain - = make_cleanup (free_current_contents, &expr); - - val = evaluate_expression (expr); - do_cleanups (old_chain); - return val; -} - -/* Parse up to a comma (or to a closeparen) - in the string EXPP as an expression, evaluate it, and return the value. - EXPP is advanced to point to the comma. */ - -value -parse_to_comma_and_eval (expp) - char **expp; -{ - struct expression *expr = parse_c_1 (expp, 0, 1); - register value val; - register struct cleanup *old_chain - = make_cleanup (free_current_contents, &expr); - - val = evaluate_expression (expr); - do_cleanups (old_chain); - return val; -} - -/* Evaluate an expression in internal prefix form - such as is constructed by expread.y. - - See expression.h for info on the format of an expression. */ - -static value evaluate_subexp (); -static value evaluate_subexp_for_address (); -static value evaluate_subexp_for_sizeof (); -static value evaluate_subexp_with_coercion (); - -/* return true if 'var' has an address in inferior's memory. */ -static int -value_has_lval(var) - register struct symbol *var; -{ - switch (SYMBOL_CLASS(var)) - { - case LOC_STATIC: - case LOC_LABEL: - case LOC_ARG: - case LOC_REF_ARG: - case LOC_LOCAL: - case LOC_BLOCK: - return (1); - } - return (0); -} - -/* Values of NOSIDE argument to eval_subexp. */ -enum noside -{ EVAL_NORMAL, - EVAL_SKIP, /* Only effect is to increment pos. */ - EVAL_AVOID_SIDE_EFFECTS, /* Don't modify any variables or - call any functions. The value - returned will have the correct - type, and will have an - approximately correct lvalue - type (inaccuracy: anything that is - listed as being in a register in - the function in which it was - declared will be lval_register). */ -}; - -value -evaluate_expression (exp) - struct expression *exp; -{ - int pc = 0; - return evaluate_subexp (0, exp, &pc, EVAL_NORMAL); -} - -/* Evaluate an expression, avoiding all memory references - and getting a value whose type alone is correct. */ - -value -evaluate_type (exp) - struct expression *exp; -{ - int pc = 0; - return evaluate_subexp (0, exp, &pc, EVAL_AVOID_SIDE_EFFECTS); -} - -static value -evaluate_subexp (expect_type, exp, pos, noside) - struct type *expect_type; - register struct expression *exp; - register int *pos; - enum noside noside; -{ - enum exp_opcode op; - int tem; - register int pc, pc2, oldpos; - register value arg1, arg2, arg3; - int nargs; - value *argvec; - - pc = (*pos)++; - op = exp->elts[pc].opcode; - - switch (op) - { - case OP_SCOPE: - tem = strlen (&exp->elts[pc + 2].string); - (*pos) += 3 + ((tem + sizeof (union exp_element)) - / sizeof (union exp_element)); - return value_static_field (exp->elts[pc + 1].type, - &exp->elts[pc + 2].string, -1); - - case OP_LONG: - (*pos) += 3; - return value_from_long (exp->elts[pc + 1].type, - exp->elts[pc + 2].longconst); - - case OP_DOUBLE: - (*pos) += 3; - return value_from_double (exp->elts[pc + 1].type, - exp->elts[pc + 2].doubleconst); - - case OP_VAR_VALUE: - (*pos) += 2; - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - struct symbol * sym = exp->elts[pc + 1].symbol; - enum lval_type lv; - - switch (SYMBOL_CLASS (sym)) - { - case LOC_CONST: - case LOC_LABEL: - case LOC_CONST_BYTES: - lv = not_lval; - case LOC_REGISTER: - case LOC_REGPARM: - lv = lval_register; - default: - lv = lval_memory; - } - - return value_zero (SYMBOL_TYPE (sym), lv); - } - else - return value_of_variable (exp->elts[pc + 1].symbol); - - case OP_LAST: - (*pos) += 2; - return access_value_history ((int) exp->elts[pc + 1].longconst); - - case OP_REGISTER: - (*pos) += 2; - return value_of_register ((int) exp->elts[pc + 1].longconst); - - case OP_INTERNALVAR: - (*pos) += 2; - return value_of_internalvar (exp->elts[pc + 1].internalvar); - - case OP_STRING: - tem = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + ((tem + sizeof (union exp_element)) - / sizeof (union exp_element)); - if (noside == EVAL_SKIP) - goto nosideret; - return value_string (&exp->elts[pc + 1].string, tem); - - case TERNOP_COND: - /* Skip third and second args to evaluate the first one. */ - arg1 = evaluate_subexp (0, exp, pos, noside); - if (value_zerop (arg1)) - { - evaluate_subexp (0, exp, pos, EVAL_SKIP); - return evaluate_subexp (0, exp, pos, noside); - } - else - { - arg2 = evaluate_subexp (0, exp, pos, noside); - evaluate_subexp (0, exp, pos, EVAL_SKIP); - return arg2; - } - - case OP_FUNCALL: - (*pos) += 2; - op = exp->elts[*pos].opcode; - if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR) - { - int fnptr; - int tem2; - - nargs = (int) exp->elts[pc + 1].longconst + 1; - /* First, evaluate the structure into arg2 */ - pc2 = (*pos)++; - - if (noside == EVAL_SKIP) - goto nosideret; - - if (op == STRUCTOP_MEMBER) - { - arg2 = evaluate_subexp_for_address (exp, pos, noside); - } - else - { - arg2 = evaluate_subexp (0, exp, pos, noside); - } - - /* If the function is a virtual function, then the - aggregate value (providing the structure) plays - its part by providing the vtable. Otherwise, - it is just along for the ride: call the function - directly. */ - - arg1 = evaluate_subexp (0, exp, pos, noside); - - fnptr = (int) value_as_long (arg1); - if (fnptr < 128) - { - struct type *basetype; - int i, j; - basetype = TYPE_TARGET_TYPE (VALUE_TYPE (arg2)); - basetype = TYPE_VPTR_BASETYPE (basetype); - for (i = TYPE_NFN_FIELDS (basetype) - 1; i >= 0; i--) - { - struct fn_field *f = TYPE_FN_FIELDLIST1 (basetype, i); - /* If one is virtual, then all are virtual. */ - if (TYPE_FN_FIELD_VIRTUAL_P (f, 0)) - for (j = TYPE_FN_FIELDLIST_LENGTH (basetype, i) - 1; j >= 0; --j) - if (TYPE_FN_FIELD_VOFFSET (f, j) == fnptr) - { - value vtbl; - value base = value_ind (arg2); - struct type *fntype = lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j)); - - if (TYPE_VPTR_FIELDNO (basetype) < 0) - TYPE_VPTR_FIELDNO (basetype) - = fill_in_vptr_fieldno (basetype); - - VALUE_TYPE (base) = basetype; - vtbl = value_field (base, TYPE_VPTR_FIELDNO (basetype)); - VALUE_TYPE (vtbl) = lookup_pointer_type (fntype); - VALUE_TYPE (arg1) = builtin_type_int; - arg1 = value_subscript (vtbl, arg1); - VALUE_TYPE (arg1) = fntype; - goto got_it; - } - } - if (i < 0) - error ("virtual function at index %d not found", fnptr); - } - else - { - VALUE_TYPE (arg1) = lookup_pointer_type (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))); - } - got_it: - - /* Now, say which argument to start evaluating from */ - tem = 2; - } - else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR) - { - /* Hair for method invocations */ - int tem2; - - nargs = (int) exp->elts[pc + 1].longconst + 1; - /* First, evaluate the structure into arg2 */ - pc2 = (*pos)++; - tem2 = strlen (&exp->elts[pc2 + 1].string); - *pos += 2 + (tem2 + sizeof (union exp_element)) / sizeof (union exp_element); - if (noside == EVAL_SKIP) - goto nosideret; - - if (op == STRUCTOP_STRUCT) - { - arg2 = evaluate_subexp_for_address (exp, pos, noside); - } - else - { - arg2 = evaluate_subexp (0, exp, pos, noside); - } - /* Now, say which argument to start evaluating from */ - tem = 2; - } - else - { - nargs = (int) exp->elts[pc + 1].longconst; - tem = 0; - } - argvec = (value *) alloca (sizeof (value) * (nargs + 2)); - for (; tem <= nargs; tem++) - /* Ensure that array expressions are coerced into pointer objects. */ - argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside); - - /* signal end of arglist */ - argvec[tem] = 0; - - if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR) - { - int static_memfuncp; - - argvec[1] = arg2; - argvec[0] = - value_struct_elt (arg2, argvec+1, &exp->elts[pc2 + 1].string, - &static_memfuncp, - op == STRUCTOP_STRUCT - ? "structure" : "structure pointer"); - if (static_memfuncp) - { - argvec[1] = argvec[0]; - nargs--; - argvec++; - } - } - else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR) - { - argvec[1] = arg2; - argvec[0] = arg1; - } - - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - /* If the return type doesn't look like a function type, call an - error. This can happen if somebody tries to turn a variable into - a function call. This is here because people often want to - call, eg, strcmp, which gdb doesn't know is a function. If - gdb isn't asked for it's opinion (ie. through "whatis"), - it won't offer it. */ - - struct type *ftype = - TYPE_TARGET_TYPE (VALUE_TYPE (argvec[0])); - - if (ftype) - return allocate_value (TYPE_TARGET_TYPE (VALUE_TYPE (argvec[0]))); - else - error ("Expression of type other than \"Function returning ...\" used as function"); - } - return call_function (argvec[0], nargs, argvec + 1); - - case STRUCTOP_STRUCT: - tem = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + ((tem + sizeof (union exp_element)) - / sizeof (union exp_element)); - - /* Try to convert "foo.bar" into "(&foo)->bar" so we won't copy - * the entire contents of a large struct just to extract one - * value from it. */ - if (noside == EVAL_NORMAL && exp->elts[*pos].opcode == OP_VAR_VALUE - && value_has_lval(exp->elts[*pos + 1].symbol)) - arg1 = evaluate_subexp_for_address(exp, pos, noside); - else - arg1 = evaluate_subexp (0, exp, pos, noside); - - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - register struct type *type = VALUE_TYPE (arg1); - if (TYPE_CODE (type) == TYPE_CODE_PTR) - type = TYPE_TARGET_TYPE (type); - return value_zero (lookup_struct_elt_type (type, - &exp->elts[pc + 1].string), - lval_memory); - } - else - return value_struct_elt (arg1, 0, &exp->elts[pc + 1].string, 0, - "structure"); - - case STRUCTOP_PTR: - tem = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element); - arg1 = evaluate_subexp (0, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (lookup_struct_elt_type (TYPE_TARGET_TYPE - (VALUE_TYPE (arg1)), - &exp->elts[pc + 1].string), - lval_memory); - else - return value_struct_elt (arg1, 0, &exp->elts[pc + 1].string, 0, - "structure pointer"); - - case STRUCTOP_MEMBER: - arg1 = evaluate_subexp_for_address (exp, pos, noside); - arg2 = evaluate_subexp (0, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - /* Now, convert these values to an address. */ - if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_PTR - || ((TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) - != TYPE_CODE_MEMBER) - && (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) - != TYPE_CODE_METHOD))) - error ("non-pointer-to-member value used in pointer-to-member construct"); - arg3 = value_from_long (builtin_type_long, - value_as_long (arg1) + value_as_long (arg2)); - VALUE_TYPE (arg3) = - lookup_pointer_type (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2)))); - return value_ind (arg3); - - case STRUCTOP_MPTR: - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (0, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - /* Now, convert these values to an address. */ - if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_PTR - || (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) != TYPE_CODE_MEMBER - && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) != TYPE_CODE_METHOD)) - error ("non-pointer-to-member value used in pointer-to-member construct"); - arg3 = value_from_long (builtin_type_long, - value_as_long (arg1) + value_as_long (arg2)); - VALUE_TYPE (arg3) = - lookup_pointer_type (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2)))); - return value_ind (arg3); - - case BINOP_ASSIGN: - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, op, 0); - else - return value_assign (arg1, arg2); - - case BINOP_ASSIGN_MODIFY: - (*pos) += 2; - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - op = exp->elts[pc + 1].opcode; - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op); - else if (op == BINOP_ADD) - arg2 = value_add (arg1, arg2); - else if (op == BINOP_SUB) - arg2 = value_sub (arg1, arg2); - else - arg2 = value_binop (arg1, arg2, op); - return value_assign (arg1, arg2); - - case BINOP_ADD: - arg1 = evaluate_subexp_with_coercion (exp, pos, noside); - arg2 = evaluate_subexp_with_coercion (exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, op, 0); - else - return value_add (arg1, arg2); - - case BINOP_SUB: - arg1 = evaluate_subexp_with_coercion (exp, pos, noside); - arg2 = evaluate_subexp_with_coercion (exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, op, 0); - else - return value_sub (arg1, arg2); - - case BINOP_MUL: - case BINOP_DIV: - case BINOP_REM: - case BINOP_LSH: - case BINOP_RSH: - case BINOP_LOGAND: - case BINOP_LOGIOR: - case BINOP_LOGXOR: - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (0, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, op, 0); - else - if (noside == EVAL_AVOID_SIDE_EFFECTS - && op == BINOP_DIV) - return value_zero (VALUE_TYPE (arg1), not_lval); - else - return value_binop (arg1, arg2, op); - - case BINOP_SUBSCRIPT: - arg1 = evaluate_subexp_with_coercion (exp, pos, noside); - arg2 = evaluate_subexp_with_coercion (exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)), - VALUE_LVAL (arg1)); - - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, op, 0); - else - return value_subscript (arg1, arg2); - - case BINOP_AND: - arg1 = evaluate_subexp (0, exp, pos, noside); - if (noside == EVAL_SKIP) - { - arg2 = evaluate_subexp (0, exp, pos, noside); - goto nosideret; - } - - oldpos = *pos; - arg2 = evaluate_subexp (0, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - *pos = oldpos; - - if (binop_user_defined_p (op, arg1, arg2)) - { - arg2 = evaluate_subexp (0, exp, pos, noside); - return value_x_binop (arg1, arg2, op, 0); - } - else - { - tem = value_zerop (arg1); - arg2 = evaluate_subexp (0, exp, pos, - (tem ? EVAL_SKIP : noside)); - return value_from_long (builtin_type_int, - (LONGEST) (!tem && !value_zerop (arg2))); - } - - case BINOP_OR: - arg1 = evaluate_subexp (0, exp, pos, noside); - if (noside == EVAL_SKIP) - { - arg2 = evaluate_subexp (0, exp, pos, noside); - goto nosideret; - } - - oldpos = *pos; - arg2 = evaluate_subexp (0, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - *pos = oldpos; - - if (binop_user_defined_p (op, arg1, arg2)) - { - arg2 = evaluate_subexp (0, exp, pos, noside); - return value_x_binop (arg1, arg2, op, 0); - } - else - { - tem = value_zerop (arg1); - arg2 = evaluate_subexp (0, exp, pos, - (!tem ? EVAL_SKIP : noside)); - return value_from_long (builtin_type_int, - (LONGEST) (!tem || !value_zerop (arg2))); - } - - case BINOP_EQUAL: - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, 0); - } - else - { - tem = value_equal (arg1, arg2); - return value_from_long (builtin_type_int, (LONGEST) tem); - } - - case BINOP_NOTEQUAL: - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, 0); - } - else - { - tem = value_equal (arg1, arg2); - return value_from_long (builtin_type_int, (LONGEST) ! tem); - } - - case BINOP_LESS: - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, 0); - } - else - { - tem = value_less (arg1, arg2); - return value_from_long (builtin_type_int, (LONGEST) tem); - } - - case BINOP_GTR: - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, 0); - } - else - { - tem = value_less (arg2, arg1); - return value_from_long (builtin_type_int, (LONGEST) tem); - } - - case BINOP_GEQ: - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, 0); - } - else - { - tem = value_less (arg1, arg2); - return value_from_long (builtin_type_int, (LONGEST) ! tem); - } - - case BINOP_LEQ: - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, 0); - } - else - { - tem = value_less (arg2, arg1); - return value_from_long (builtin_type_int, (LONGEST) ! tem); - } - - case BINOP_REPEAT: - arg1 = evaluate_subexp (0, exp, pos, noside); - arg2 = evaluate_subexp (0, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT) - error ("Non-integral right operand for \"@\" operator."); - if (noside == EVAL_AVOID_SIDE_EFFECTS) - return allocate_repeat_value (VALUE_TYPE (arg1), - (int) value_as_long (arg2)); - else - return value_repeat (arg1, (int) value_as_long (arg2)); - - case BINOP_COMMA: - evaluate_subexp (0, exp, pos, noside); - return evaluate_subexp (0, exp, pos, noside); - - case UNOP_NEG: - arg1 = evaluate_subexp (0, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (unop_user_defined_p (op, arg1)) - return value_x_unop (arg1, op); - else - return value_neg (arg1); - - case UNOP_LOGNOT: - arg1 = evaluate_subexp (0, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (unop_user_defined_p (op, arg1)) - return value_x_unop (arg1, op); - else - return value_lognot (arg1); - - case UNOP_ZEROP: - arg1 = evaluate_subexp (0, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (unop_user_defined_p (op, arg1)) - return value_x_unop (arg1, op); - else - return value_from_long (builtin_type_int, - (LONGEST) value_zerop (arg1)); - - case UNOP_IND: - if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR) - expect_type = TYPE_TARGET_TYPE (expect_type); - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR - || TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF - /* In C you can dereference an array to get the 1st elt. */ - || TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_ARRAY - ) - return value_zero (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)), - lval_memory); - else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT) - /* GDB allows dereferencing an int. */ - return value_zero (builtin_type_int, lval_memory); - else - error ("Attempt to take contents of a non-pointer value."); - } - return value_ind (arg1); - - case UNOP_ADDR: - /* C++: check for and handle pointer to members. */ - - op = exp->elts[*pos].opcode; - - if (noside == EVAL_SKIP) - { - if (op == OP_SCOPE) - { - char *name = &exp->elts[pc+3].string; - int tem = strlen (name); - (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element); - } - else - evaluate_subexp (expect_type, exp, pos, EVAL_SKIP); - goto nosideret; - } - - if (op == OP_SCOPE) - { - char *name = &exp->elts[pc+3].string; - int tem = strlen (name); - struct type *domain = exp->elts[pc+2].type; - (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element); - arg1 = value_struct_elt_for_address (domain, expect_type, name); - if (arg1) - return arg1; - error ("no field `%s' in structure", name); - } - else - return evaluate_subexp_for_address (exp, pos, noside); - - case UNOP_SIZEOF: - if (noside == EVAL_SKIP) - { - evaluate_subexp (0, exp, pos, EVAL_SKIP); - goto nosideret; - } - return evaluate_subexp_for_sizeof (exp, pos); - - case UNOP_CAST: - (*pos) += 2; - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - return value_cast (exp->elts[pc + 1].type, arg1); - - case UNOP_MEMVAL: - (*pos) += 2; - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (exp->elts[pc + 1].type, lval_memory); - else - return value_at (exp->elts[pc + 1].type, - (CORE_ADDR) value_as_long (arg1)); - - case UNOP_PREINCREMENT: - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - else if (unop_user_defined_p (op, arg1)) - { - return value_x_unop (arg1, op); - } - else - { - arg2 = value_add (arg1, value_from_long (builtin_type_char, - (LONGEST) 1)); - return value_assign (arg1, arg2); - } - - case UNOP_PREDECREMENT: - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - else if (unop_user_defined_p (op, arg1)) - { - return value_x_unop (arg1, op); - } - else - { - arg2 = value_sub (arg1, value_from_long (builtin_type_char, - (LONGEST) 1)); - return value_assign (arg1, arg2); - } - - case UNOP_POSTINCREMENT: - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - else if (unop_user_defined_p (op, arg1)) - { - return value_x_unop (arg1, op); - } - else - { - arg2 = value_add (arg1, value_from_long (builtin_type_char, - (LONGEST) 1)); - value_assign (arg1, arg2); - return arg1; - } - - case UNOP_POSTDECREMENT: - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - else if (unop_user_defined_p (op, arg1)) - { - return value_x_unop (arg1, op); - } - else - { - arg2 = value_sub (arg1, value_from_long (builtin_type_char, - (LONGEST) 1)); - value_assign (arg1, arg2); - return arg1; - } - - case OP_THIS: - (*pos) += 1; - return value_of_this (1); - - default: - error ("internal error: I do not know how to evaluate what you gave me"); - } - - nosideret: - return value_from_long (builtin_type_long, (LONGEST) 1); -} - -/* Evaluate a subexpression of EXP, at index *POS, - and return the address of that subexpression. - Advance *POS over the subexpression. - If the subexpression isn't an lvalue, get an error. - NOSIDE may be EVAL_AVOID_SIDE_EFFECTS; - then only the type of the result need be correct. */ - -static value -evaluate_subexp_for_address (exp, pos, noside) - register struct expression *exp; - register int *pos; - enum noside noside; -{ - enum exp_opcode op; - register int pc; - - pc = (*pos); - op = exp->elts[pc].opcode; - - switch (op) - { - case UNOP_IND: - (*pos)++; - return evaluate_subexp (0, exp, pos, noside); - - case UNOP_MEMVAL: - (*pos) += 3; - return value_cast (lookup_pointer_type (exp->elts[pc + 1].type), - evaluate_subexp (0, exp, pos, noside)); - - case OP_VAR_VALUE: - (*pos) += 3; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - struct type *type = - lookup_pointer_type (SYMBOL_TYPE (exp->elts[pc + 1].symbol)); - enum address_class sym_class = - SYMBOL_CLASS (exp->elts[pc + 1].symbol); - - if (sym_class == LOC_CONST - || sym_class == LOC_CONST_BYTES - || sym_class == LOC_REGISTER - || sym_class == LOC_REGPARM) - error ("Attempt to take address of register or constant."); - - return - value_zero (type, not_lval); - } - else - return locate_var_value (exp->elts[pc + 1].symbol, (CORE_ADDR) 0); - - default: - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - value x = evaluate_subexp (0, exp, pos, noside); - if (VALUE_LVAL (x) == lval_memory) - return value_zero (TYPE_POINTER_TYPE (VALUE_TYPE (x)), - not_lval); - else - error ("Attempt to take address of non-lval"); - } - return value_addr (evaluate_subexp (0, exp, pos, noside)); - } -} - -/* Evaluate like `evaluate_subexp' except coercing arrays to pointers. - When used in contexts where arrays will be coerced anyway, - this is equivalent to `evaluate_subexp' - but much faster because it avoids actually fetching array contents. */ - -static value -evaluate_subexp_with_coercion (exp, pos, noside) - register struct expression *exp; - register int *pos; - enum noside noside; -{ - register enum exp_opcode op; - register int pc; - register value val; - - pc = (*pos); - op = exp->elts[pc].opcode; - - switch (op) - { - case OP_VAR_VALUE: - if (TYPE_CODE (SYMBOL_TYPE (exp->elts[pc + 1].symbol)) == TYPE_CODE_ARRAY) - { - (*pos) += 3; - val = locate_var_value (exp->elts[pc + 1].symbol, (CORE_ADDR) 0); - return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (SYMBOL_TYPE (exp->elts[pc + 1].symbol))), - val); - } - } - - return evaluate_subexp (0, exp, pos, noside); -} - -/* Evaluate a subexpression of EXP, at index *POS, - and return a value for the size of that subexpression. - Advance *POS over the subexpression. */ - -static value -evaluate_subexp_for_sizeof (exp, pos) - register struct expression *exp; - register int *pos; -{ - enum exp_opcode op; - register int pc; - value val; - - pc = (*pos); - op = exp->elts[pc].opcode; - - switch (op) - { - /* This case is handled specially - so that we avoid creating a value for the result type. - If the result type is very big, it's desirable not to - create a value unnecessarily. */ - case UNOP_IND: - (*pos)++; - val = evaluate_subexp (0, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - return value_from_long (builtin_type_int, (LONGEST) - TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (val)))); - - case UNOP_MEMVAL: - (*pos) += 3; - return value_from_long (builtin_type_int, - (LONGEST) TYPE_LENGTH (exp->elts[pc + 1].type)); - - case OP_VAR_VALUE: - (*pos) += 3; - return value_from_long (builtin_type_int, - (LONGEST) TYPE_LENGTH (SYMBOL_TYPE (exp->elts[pc + 1].symbol))); - - default: - val = evaluate_subexp (0, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - return value_from_long (builtin_type_int, - (LONGEST) TYPE_LENGTH (VALUE_TYPE (val))); - } -} diff --git a/gnu/usr.bin/gdb/expprint.c b/gnu/usr.bin/gdb/expprint.c deleted file mode 100644 index 24f912027af4..000000000000 --- a/gnu/usr.bin/gdb/expprint.c +++ /dev/null @@ -1,328 +0,0 @@ -/* Print in infix form a struct expression. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: expprint.c,v 1.2 1993/08/02 17:40:58 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "symtab.h" -#include "param.h" -#include "expression.h" -#include "value.h" - - -/* These codes indicate operator precedences, least tightly binding first. */ -/* Adding 1 to a precedence value is done for binary operators, - on the operand which is more tightly bound, so that operators - of equal precedence within that operand will get parentheses. */ -/* PREC_HYPER and PREC_ABOVE_COMMA are not the precedence of any operator; - they are used as the "surrounding precedence" to force - various kinds of things to be parenthesized. */ -enum precedence -{ PREC_NULL, PREC_COMMA, PREC_ABOVE_COMMA, PREC_ASSIGN, PREC_OR, PREC_AND, - PREC_LOGIOR, PREC_LOGAND, PREC_LOGXOR, PREC_EQUAL, PREC_ORDER, - PREC_SHIFT, PREC_ADD, PREC_MUL, PREC_REPEAT, - PREC_HYPER, PREC_PREFIX, PREC_SUFFIX }; - -/* Table mapping opcodes into strings for printing operators - and precedences of the operators. */ - -struct op_print -{ - char *string; - enum exp_opcode opcode; - /* Precedence of operator. These values are used only by comparisons. */ - enum precedence precedence; - int right_assoc; -}; - -static struct op_print op_print_tab[] = - { - {",", BINOP_COMMA, PREC_COMMA, 0}, - {"=", BINOP_ASSIGN, PREC_ASSIGN, 1}, - {"||", BINOP_OR, PREC_OR, 0}, - {"&&", BINOP_AND, PREC_AND, 0}, - {"|", BINOP_LOGIOR, PREC_LOGIOR, 0}, - {"&", BINOP_LOGAND, PREC_LOGAND, 0}, - {"^", BINOP_LOGXOR, PREC_LOGXOR, 0}, - {"==", BINOP_EQUAL, PREC_EQUAL, 0}, - {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0}, - {"<=", BINOP_LEQ, PREC_ORDER, 0}, - {">=", BINOP_GEQ, PREC_ORDER, 0}, - {">", BINOP_GTR, PREC_ORDER, 0}, - {"<", BINOP_LESS, PREC_ORDER, 0}, - {">>", BINOP_RSH, PREC_SHIFT, 0}, - {"<<", BINOP_LSH, PREC_SHIFT, 0}, - {"+", BINOP_ADD, PREC_ADD, 0}, - {"-", BINOP_SUB, PREC_ADD, 0}, - {"*", BINOP_MUL, PREC_MUL, 0}, - {"/", BINOP_DIV, PREC_MUL, 0}, - {"%", BINOP_REM, PREC_MUL, 0}, - {"@", BINOP_REPEAT, PREC_REPEAT, 0}, - {"-", UNOP_NEG, PREC_PREFIX, 0}, - {"!", UNOP_ZEROP, PREC_PREFIX, 0}, - {"~", UNOP_LOGNOT, PREC_PREFIX, 0}, - {"*", UNOP_IND, PREC_PREFIX, 0}, - {"&", UNOP_ADDR, PREC_PREFIX, 0}, - {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0}, - {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0}, - {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0}, - /* C++ */ - {"::", BINOP_SCOPE, PREC_PREFIX, 0}, - }; - -static void print_subexp (); - -void -print_expression (exp, stream) - struct expression *exp; - FILE *stream; -{ - int pc = 0; - print_subexp (exp, &pc, stream, PREC_NULL); -} - -/* Print the subexpression of EXP that starts in position POS, on STREAM. - PREC is the precedence of the surrounding operator; - if the precedence of the main operator of this subexpression is less, - parentheses are needed here. */ - -static void -print_subexp (exp, pos, stream, prec) - register struct expression *exp; - register int *pos; - FILE *stream; - enum precedence prec; -{ - register int tem; - register int pc; - int nargs; - register char *op_str; - int assign_modify = 0; - enum exp_opcode opcode; - enum precedence myprec; - /* Set to 1 for a right-associative operator. */ - int assoc; - - pc = (*pos)++; - opcode = exp->elts[pc].opcode; - switch (opcode) - { - case OP_SCOPE: - myprec = PREC_PREFIX; - assoc = 0; - (*pos) += 2; - print_subexp (exp, pos, stream, (int) myprec + assoc); - fprintf (stream, " :: "); - nargs = strlen (&exp->elts[pc + 2].string); - (*pos) += 1 + (nargs + sizeof (union exp_element)) / sizeof (union exp_element); - - fprintf (stream, &exp->elts[pc + 2].string); - return; - - case OP_LONG: - (*pos) += 3; - value_print (value_from_long (exp->elts[pc + 1].type, - exp->elts[pc + 2].longconst), - stream, 0, Val_no_prettyprint); - return; - - case OP_DOUBLE: - (*pos) += 3; - value_print (value_from_double (exp->elts[pc + 1].type, - exp->elts[pc + 2].doubleconst), - stream, 0, Val_no_prettyprint); - return; - - case OP_VAR_VALUE: - (*pos) += 2; - fprintf (stream, "%s", SYMBOL_NAME (exp->elts[pc + 1].symbol)); - return; - - case OP_LAST: - (*pos) += 2; - fprintf (stream, "$%d", (int) exp->elts[pc + 1].longconst); - return; - - case OP_REGISTER: - (*pos) += 2; - fprintf (stream, "$%s", reg_names[exp->elts[pc + 1].longconst]); - return; - - case OP_INTERNALVAR: - (*pos) += 2; - fprintf (stream, "$%s", - internalvar_name (exp->elts[pc + 1].internalvar)); - return; - - case OP_FUNCALL: - (*pos) += 2; - nargs = exp->elts[pc + 1].longconst; - print_subexp (exp, pos, stream, PREC_SUFFIX); - fprintf (stream, " ("); - for (tem = 0; tem < nargs; tem++) - { - if (tem > 0) - fprintf (stream, ", "); - print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); - } - fprintf (stream, ")"); - return; - - case OP_STRING: - nargs = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + (nargs + sizeof (union exp_element)) / sizeof (union exp_element); - fprintf (stream, "\""); - for (tem = 0; tem < nargs; tem++) - printchar ((&exp->elts[pc + 1].string)[tem], stream, '"'); - fprintf (stream, "\""); - return; - - case TERNOP_COND: - if ((int) prec > (int) PREC_COMMA) - fprintf (stream, "("); - /* Print the subexpressions, forcing parentheses - around any binary operations within them. - This is more parentheses than are strictly necessary, - but it looks clearer. */ - print_subexp (exp, pos, stream, PREC_HYPER); - fprintf (stream, " ? "); - print_subexp (exp, pos, stream, PREC_HYPER); - fprintf (stream, " : "); - print_subexp (exp, pos, stream, PREC_HYPER); - if ((int) prec > (int) PREC_COMMA) - fprintf (stream, ")"); - return; - - case STRUCTOP_STRUCT: - tem = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element); - print_subexp (exp, pos, stream, PREC_SUFFIX); - fprintf (stream, ".%s", &exp->elts[pc + 1].string); - return; - - case STRUCTOP_PTR: - tem = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element); - print_subexp (exp, pos, stream, PREC_SUFFIX); - fprintf (stream, "->%s", &exp->elts[pc + 1].string); - return; - - case BINOP_SUBSCRIPT: - print_subexp (exp, pos, stream, PREC_SUFFIX); - fprintf (stream, "["); - print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); - fprintf (stream, "]"); - return; - - case UNOP_POSTINCREMENT: - print_subexp (exp, pos, stream, PREC_SUFFIX); - fprintf (stream, "++"); - return; - - case UNOP_POSTDECREMENT: - print_subexp (exp, pos, stream, PREC_SUFFIX); - fprintf (stream, "--"); - return; - - case UNOP_CAST: - (*pos) += 2; - if ((int) prec > (int) PREC_PREFIX) - fprintf (stream, "("); - fprintf (stream, "("); - type_print (exp->elts[pc + 1].type, "", stream, 0); - fprintf (stream, ") "); - print_subexp (exp, pos, stream, PREC_PREFIX); - if ((int) prec > (int) PREC_PREFIX) - fprintf (stream, ")"); - return; - - case UNOP_MEMVAL: - (*pos) += 2; - if ((int) prec > (int) PREC_PREFIX) - fprintf (stream, "("); - fprintf (stream, "{"); - type_print (exp->elts[pc + 1].type, "", stream, 0); - fprintf (stream, "} "); - print_subexp (exp, pos, stream, PREC_PREFIX); - if ((int) prec > (int) PREC_PREFIX) - fprintf (stream, ")"); - return; - - case BINOP_ASSIGN_MODIFY: - opcode = exp->elts[pc + 1].opcode; - (*pos) += 2; - myprec = PREC_ASSIGN; - assoc = 1; - assign_modify = 1; - for (tem = 0; tem < sizeof op_print_tab / sizeof op_print_tab[0]; tem++) - if (op_print_tab[tem].opcode == opcode) - { - op_str = op_print_tab[tem].string; - break; - } - - case OP_THIS: - ++(*pos); - fprintf (stream, "this"); - return; - - default: - for (tem = 0; tem < sizeof op_print_tab / sizeof op_print_tab[0]; tem++) - if (op_print_tab[tem].opcode == opcode) - { - op_str = op_print_tab[tem].string; - myprec = op_print_tab[tem].precedence; - assoc = op_print_tab[tem].right_assoc; - break; - } - } - - if ((int) myprec < (int) prec) - fprintf (stream, "("); - if ((int) opcode > (int) BINOP_END) - { - /* Unary prefix operator. */ - fprintf (stream, "%s", op_str); - print_subexp (exp, pos, stream, PREC_PREFIX); - } - else - { - /* Binary operator. */ - /* Print left operand. - If operator is right-associative, - increment precedence for this operand. */ - print_subexp (exp, pos, stream, (int) myprec + assoc); - /* Print the operator itself. */ - if (assign_modify) - fprintf (stream, " %s= ", op_str); - else if (op_str[0] == ',') - fprintf (stream, "%s ", op_str); - else - fprintf (stream, " %s ", op_str); - /* Print right operand. - If operator is left-associative, - increment precedence for this operand. */ - print_subexp (exp, pos, stream, (int) myprec + !assoc); - } - if ((int) myprec < (int) prec) - fprintf (stream, ")"); -} diff --git a/gnu/usr.bin/gdb/expread.y b/gnu/usr.bin/gdb/expread.y deleted file mode 100644 index b9d2c15a8cb2..000000000000 --- a/gnu/usr.bin/gdb/expread.y +++ /dev/null @@ -1,1783 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -/* Parse C expressions for GDB. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Parse a C expression from text in a string, - and return the result as a struct expression pointer. - That structure contains arithmetic operations in reverse polish, - with constants represented by operations that are followed by special data. - See expression.h for the details of the format. - What is important here is that it can be built up sequentially - during the process of parsing; the lower levels of the tree always - come first in the result. */ - -%{ -#ifndef lint -/*static char sccsid[] = "from: @(#)expread.y 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: expread.y,v 1.2 1993/08/01 18:47:18 mycroft Exp $"; -#endif /* not lint */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "expression.h" - -#include - -static struct expression *expout; -static int expout_size; -static int expout_ptr; - -static int yylex (); -static void yyerror (); -static void write_exp_elt (); -static void write_exp_elt_opcode (); -static void write_exp_elt_sym (); -static void write_exp_elt_longcst (); -static void write_exp_elt_dblcst (); -static void write_exp_elt_type (); -static void write_exp_elt_intern (); -static void write_exp_string (); -static void start_arglist (); -static int end_arglist (); -static void free_funcalls (); -static char *copy_name (); - -/* If this is nonzero, this block is used as the lexical context - for symbol names. */ - -static struct block *expression_context_block; - -/* The innermost context required by the stack and register variables - we've encountered so far. */ -struct block *innermost_block; - -/* The block in which the most recently discovered symbol was found. */ -struct block *block_found; - -/* Number of arguments seen so far in innermost function call. */ -static int arglist_len; - -/* Data structure for saving values of arglist_len - for function calls whose arguments contain other function calls. */ - -struct funcall - { - struct funcall *next; - int arglist_len; - }; - -struct funcall *funcall_chain; - -/* This kind of datum is used to represent the name - of a symbol token. */ - -struct stoken - { - char *ptr; - int length; - }; - -/* For parsing of complicated types. - An array should be preceded in the list by the size of the array. */ -enum type_pieces - {tp_end = -1, tp_pointer, tp_reference, tp_array, tp_function}; -static enum type_pieces *type_stack; -static int type_stack_depth, type_stack_size; - -static void push_type (); -static enum type_pieces pop_type (); - -/* Allow debugging of parsing. */ -#define YYDEBUG 1 -%} - -/* Although the yacc "value" of an expression is not used, - since the result is stored in the structure being created, - other node types do have values. */ - -%union - { - LONGEST lval; - unsigned LONGEST ulval; - double dval; - struct symbol *sym; - struct type *tval; - struct stoken sval; - int voidval; - struct block *bval; - enum exp_opcode opcode; - struct internalvar *ivar; - - struct type **tvec; - int *ivec; - } - -%type exp exp1 start variable -%type type typebase -%type nonempty_typelist -%type block - -/* Fancy type parsing. */ -%type func_mod direct_abs_decl abs_decl -%type ptype -%type array_mod - -%token INT CHAR -%token UINT -%token FLOAT - -/* Both NAME and TYPENAME tokens represent symbols in the input, - and both convey their data as strings. - But a TYPENAME is a string that happens to be defined as a typedef - or builtin type name (such as int or char) - and a NAME is any other symbol. - - Contexts where this distinction is not important can use the - nonterminal "name", which matches either NAME or TYPENAME. */ - -%token NAME TYPENAME BLOCKNAME STRING -%type name name_not_typename typename - -%token STRUCT UNION ENUM SIZEOF UNSIGNED COLONCOLON - -/* Special type cases, put in to allow the parser to distinguish different - legal basetypes. */ -%token SIGNED LONG SHORT INT_KEYWORD - -%token LAST REGNAME - -%token VARIABLE - -%token ASSIGN_MODIFY - -/* C++ */ -%token THIS - -%left ',' -%left ABOVE_COMMA -%right '=' ASSIGN_MODIFY -%right '?' -%left OR -%left AND -%left '|' -%left '^' -%left '&' -%left EQUAL NOTEQUAL -%left '<' '>' LEQ GEQ -%left LSH RSH -%left '@' -%left '+' '-' -%left '*' '/' '%' -%right UNARY INCREMENT DECREMENT -%right ARROW '.' '[' '(' -%left COLONCOLON - -%% - -start : exp1 - ; - -/* Expressions, including the comma operator. */ -exp1 : exp - | exp1 ',' exp - { write_exp_elt_opcode (BINOP_COMMA); } - ; - -/* Expressions, not including the comma operator. */ -exp : '*' exp %prec UNARY - { write_exp_elt_opcode (UNOP_IND); } - -exp : '&' exp %prec UNARY - { write_exp_elt_opcode (UNOP_ADDR); } - -exp : '-' exp %prec UNARY - { write_exp_elt_opcode (UNOP_NEG); } - ; - -exp : '!' exp %prec UNARY - { write_exp_elt_opcode (UNOP_ZEROP); } - ; - -exp : '~' exp %prec UNARY - { write_exp_elt_opcode (UNOP_LOGNOT); } - ; - -exp : INCREMENT exp %prec UNARY - { write_exp_elt_opcode (UNOP_PREINCREMENT); } - ; - -exp : DECREMENT exp %prec UNARY - { write_exp_elt_opcode (UNOP_PREDECREMENT); } - ; - -exp : exp INCREMENT %prec UNARY - { write_exp_elt_opcode (UNOP_POSTINCREMENT); } - ; - -exp : exp DECREMENT %prec UNARY - { write_exp_elt_opcode (UNOP_POSTDECREMENT); } - ; - -exp : SIZEOF exp %prec UNARY - { write_exp_elt_opcode (UNOP_SIZEOF); } - ; - -exp : exp ARROW name - { write_exp_elt_opcode (STRUCTOP_PTR); - write_exp_string ($3); - write_exp_elt_opcode (STRUCTOP_PTR); } - ; - -exp : exp ARROW '*' exp - { write_exp_elt_opcode (STRUCTOP_MPTR); } - ; - -exp : exp '.' name - { write_exp_elt_opcode (STRUCTOP_STRUCT); - write_exp_string ($3); - write_exp_elt_opcode (STRUCTOP_STRUCT); } - ; - -exp : exp '.' '*' exp - { write_exp_elt_opcode (STRUCTOP_MEMBER); } - ; - -exp : exp '[' exp1 ']' - { write_exp_elt_opcode (BINOP_SUBSCRIPT); } - ; - -exp : exp '(' - /* This is to save the value of arglist_len - being accumulated by an outer function call. */ - { start_arglist (); } - arglist ')' %prec ARROW - { write_exp_elt_opcode (OP_FUNCALL); - write_exp_elt_longcst ((LONGEST) end_arglist ()); - write_exp_elt_opcode (OP_FUNCALL); } - ; - -arglist : - ; - -arglist : exp - { arglist_len = 1; } - ; - -arglist : arglist ',' exp %prec ABOVE_COMMA - { arglist_len++; } - ; - -exp : '{' type '}' exp %prec UNARY - { write_exp_elt_opcode (UNOP_MEMVAL); - write_exp_elt_type ($2); - write_exp_elt_opcode (UNOP_MEMVAL); } - ; - -exp : '(' type ')' exp %prec UNARY - { write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type ($2); - write_exp_elt_opcode (UNOP_CAST); } - ; - -exp : '(' exp1 ')' - { } - ; - -/* Binary operators in order of decreasing precedence. */ - -exp : exp '@' exp - { write_exp_elt_opcode (BINOP_REPEAT); } - ; - -exp : exp '*' exp - { write_exp_elt_opcode (BINOP_MUL); } - ; - -exp : exp '/' exp - { write_exp_elt_opcode (BINOP_DIV); } - ; - -exp : exp '%' exp - { write_exp_elt_opcode (BINOP_REM); } - ; - -exp : exp '+' exp - { write_exp_elt_opcode (BINOP_ADD); } - ; - -exp : exp '-' exp - { write_exp_elt_opcode (BINOP_SUB); } - ; - -exp : exp LSH exp - { write_exp_elt_opcode (BINOP_LSH); } - ; - -exp : exp RSH exp - { write_exp_elt_opcode (BINOP_RSH); } - ; - -exp : exp EQUAL exp - { write_exp_elt_opcode (BINOP_EQUAL); } - ; - -exp : exp NOTEQUAL exp - { write_exp_elt_opcode (BINOP_NOTEQUAL); } - ; - -exp : exp LEQ exp - { write_exp_elt_opcode (BINOP_LEQ); } - ; - -exp : exp GEQ exp - { write_exp_elt_opcode (BINOP_GEQ); } - ; - -exp : exp '<' exp - { write_exp_elt_opcode (BINOP_LESS); } - ; - -exp : exp '>' exp - { write_exp_elt_opcode (BINOP_GTR); } - ; - -exp : exp '&' exp - { write_exp_elt_opcode (BINOP_LOGAND); } - ; - -exp : exp '^' exp - { write_exp_elt_opcode (BINOP_LOGXOR); } - ; - -exp : exp '|' exp - { write_exp_elt_opcode (BINOP_LOGIOR); } - ; - -exp : exp AND exp - { write_exp_elt_opcode (BINOP_AND); } - ; - -exp : exp OR exp - { write_exp_elt_opcode (BINOP_OR); } - ; - -exp : exp '?' exp ':' exp %prec '?' - { write_exp_elt_opcode (TERNOP_COND); } - ; - -exp : exp '=' exp - { write_exp_elt_opcode (BINOP_ASSIGN); } - ; - -exp : exp ASSIGN_MODIFY exp - { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); - write_exp_elt_opcode ($2); - write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); } - ; - -exp : INT - { write_exp_elt_opcode (OP_LONG); - if ($1 == (int) $1 || $1 == (unsigned int) $1) - write_exp_elt_type (builtin_type_int); - else - write_exp_elt_type (BUILTIN_TYPE_LONGEST); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : UINT - { - write_exp_elt_opcode (OP_LONG); - if ($1 == (unsigned int) $1) - write_exp_elt_type (builtin_type_unsigned_int); - else - write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); - } - ; - -exp : CHAR - { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_char); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : FLOAT - { write_exp_elt_opcode (OP_DOUBLE); - write_exp_elt_type (builtin_type_double); - write_exp_elt_dblcst ($1); - write_exp_elt_opcode (OP_DOUBLE); } - ; - -exp : variable - ; - -exp : LAST - { write_exp_elt_opcode (OP_LAST); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LAST); } - ; - -exp : REGNAME - { write_exp_elt_opcode (OP_REGISTER); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_REGISTER); } - ; - -exp : VARIABLE - { write_exp_elt_opcode (OP_INTERNALVAR); - write_exp_elt_intern ($1); - write_exp_elt_opcode (OP_INTERNALVAR); } - ; - -exp : SIZEOF '(' type ')' %prec UNARY - { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : STRING - { write_exp_elt_opcode (OP_STRING); - write_exp_string ($1); - write_exp_elt_opcode (OP_STRING); } - ; - -/* C++. */ -exp : THIS - { write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (OP_THIS); } - ; - -/* end of C++. */ - -block : BLOCKNAME - { - struct symtab *tem = lookup_symtab (copy_name ($1)); - struct symbol *sym; - - if (tem) - $$ = BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem), 1); - else - { - sym = lookup_symbol (copy_name ($1), - expression_context_block, - VAR_NAMESPACE, 0); - if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK) - $$ = SYMBOL_BLOCK_VALUE (sym); - else - error ("No file or function \"%s\".", - copy_name ($1)); - } - } - ; - -block : block COLONCOLON name - { struct symbol *tem - = lookup_symbol (copy_name ($3), $1, VAR_NAMESPACE, 0); - if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK) - error ("No function \"%s\" in specified context.", - copy_name ($3)); - $$ = SYMBOL_BLOCK_VALUE (tem); } - ; - -variable: block COLONCOLON name - { struct symbol *sym; - sym = lookup_symbol (copy_name ($3), $1, VAR_NAMESPACE, 0); - if (sym == 0) - error ("No symbol \"%s\" in specified context.", - copy_name ($3)); - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); } - ; - -variable: typebase COLONCOLON name - { - struct type *type = $1; - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION) - error ("`%s' is not defined as an aggregate type.", - TYPE_NAME (type)); - - write_exp_elt_opcode (OP_SCOPE); - write_exp_elt_type (type); - write_exp_string ($3); - write_exp_elt_opcode (OP_SCOPE); - } - | COLONCOLON name - { - char *name = copy_name ($2); - struct symbol *sym; - int i; - - sym = lookup_symbol (name, 0, VAR_NAMESPACE, 0); - if (sym) - { - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); - break; - } - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, name)) - break; - - if (i < misc_function_count) - { - enum misc_function_type mft = - (enum misc_function_type) - misc_function_vector[i].type; - - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address); - write_exp_elt_opcode (OP_LONG); - write_exp_elt_opcode (UNOP_MEMVAL); - if (mft == mf_data || mft == mf_bss) - write_exp_elt_type (builtin_type_int); - else if (mft == mf_text) - write_exp_elt_type (lookup_function_type (builtin_type_int)); - else - write_exp_elt_type (builtin_type_char); - write_exp_elt_opcode (UNOP_MEMVAL); - } - else - if (symtab_list == 0 - && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"symbol-file\" command."); - else - error ("No symbol \"%s\" in current context.", name); - } - ; - -variable: name_not_typename - { struct symbol *sym; - int is_a_field_of_this; - - sym = lookup_symbol (copy_name ($1), - expression_context_block, - VAR_NAMESPACE, - &is_a_field_of_this); - if (sym) - { - switch (sym->class) - { - case LOC_REGISTER: - case LOC_ARG: - case LOC_LOCAL: - if (innermost_block == 0 || - contained_in (block_found, - innermost_block)) - innermost_block = block_found; - } - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); - } - else if (is_a_field_of_this) - { - /* C++: it hangs off of `this'. Must - not inadvertently convert from a method call - to data ref. */ - if (innermost_block == 0 || - contained_in (block_found, innermost_block)) - innermost_block = block_found; - write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (STRUCTOP_PTR); - write_exp_string ($1); - write_exp_elt_opcode (STRUCTOP_PTR); - } - else - { - register int i; - register char *arg = copy_name ($1); - - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, arg)) - break; - - if (i < misc_function_count) - { - enum misc_function_type mft = - (enum misc_function_type) - misc_function_vector[i].type; - - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address); - write_exp_elt_opcode (OP_LONG); - write_exp_elt_opcode (UNOP_MEMVAL); - if (mft == mf_data || mft == mf_bss) - write_exp_elt_type (builtin_type_int); - else if (mft == mf_text) - write_exp_elt_type (lookup_function_type (builtin_type_int)); - else - write_exp_elt_type (builtin_type_char); - write_exp_elt_opcode (UNOP_MEMVAL); - } - else if (symtab_list == 0 - && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"symbol-file\" command."); - else - error ("No symbol \"%s\" in current context.", - copy_name ($1)); - } - } - ; - - -ptype : typebase - | typebase abs_decl - { - /* This is where the interesting stuff happens. */ - int done = 0; - int array_size; - struct type *follow_type = $1; - - while (!done) - switch (pop_type ()) - { - case tp_end: - done = 1; - break; - case tp_pointer: - follow_type = lookup_pointer_type (follow_type); - break; - case tp_reference: - follow_type = lookup_reference_type (follow_type); - break; - case tp_array: - array_size = (int) pop_type (); - if (array_size != -1) - follow_type = create_array_type (follow_type, - array_size); - else - follow_type = lookup_pointer_type (follow_type); - break; - case tp_function: - follow_type = lookup_function_type (follow_type); - break; - } - $$ = follow_type; - } - ; - -abs_decl: '*' - { push_type (tp_pointer); $$ = 0; } - | '*' abs_decl - { push_type (tp_pointer); $$ = $2; } - | direct_abs_decl - ; - -direct_abs_decl: '(' abs_decl ')' - { $$ = $2; } - | direct_abs_decl array_mod - { - push_type ((enum type_pieces) $2); - push_type (tp_array); - } - | array_mod - { - push_type ((enum type_pieces) $1); - push_type (tp_array); - $$ = 0; - } - | direct_abs_decl func_mod - { push_type (tp_function); } - | func_mod - { push_type (tp_function); } - ; - -array_mod: '[' ']' - { $$ = -1; } - | '[' INT ']' - { $$ = $2; } - ; - -func_mod: '(' ')' - { $$ = 0; } - ; - -type : ptype - | typebase COLONCOLON '*' - { $$ = lookup_member_type (builtin_type_int, $1); } - | type '(' typebase COLONCOLON '*' ')' - { $$ = lookup_member_type ($1, $3); } - | type '(' typebase COLONCOLON '*' ')' '(' ')' - { $$ = lookup_member_type - (lookup_function_type ($1), $3); } - | type '(' typebase COLONCOLON '*' ')' '(' nonempty_typelist ')' - { $$ = lookup_member_type - (lookup_function_type ($1), $3); - free ($8); } - ; - -typebase - : TYPENAME - { $$ = lookup_typename (copy_name ($1), - expression_context_block, 0); } - | INT_KEYWORD - { $$ = builtin_type_int; } - | LONG - { $$ = builtin_type_long; } - | SHORT - { $$ = builtin_type_short; } - | LONG INT_KEYWORD - { $$ = builtin_type_long; } - | UNSIGNED LONG INT_KEYWORD - { $$ = builtin_type_unsigned_long; } - | SHORT INT_KEYWORD - { $$ = builtin_type_short; } - | UNSIGNED SHORT INT_KEYWORD - { $$ = builtin_type_unsigned_short; } - | STRUCT name - { $$ = lookup_struct (copy_name ($2), - expression_context_block); } - | UNION name - { $$ = lookup_union (copy_name ($2), - expression_context_block); } - | ENUM name - { $$ = lookup_enum (copy_name ($2), - expression_context_block); } - | UNSIGNED typename - { $$ = lookup_unsigned_typename (copy_name ($2)); } - | UNSIGNED - { $$ = builtin_type_unsigned_int; } - | SIGNED typename - { $$ = lookup_typename (copy_name ($2), - expression_context_block, 0); } - | SIGNED - { $$ = builtin_type_int; } - ; - -typename: TYPENAME - | INT_KEYWORD - { - $$.ptr = "int"; - $$.length = 3; - } - | LONG - { - $$.ptr = "long"; - $$.length = 4; - } - | SHORT - { - $$.ptr = "short"; - $$.length = 5; - } - ; - -nonempty_typelist - : type - { $$ = (struct type **)xmalloc (sizeof (struct type *) * 2); - $$[0] = (struct type *)0; - $$[1] = $1; - } - | nonempty_typelist ',' type - { int len = sizeof (struct type *) * ++($1[0]); - $$ = (struct type **)xrealloc ($1, len); - $$[$$[0]] = $3; - } - ; - -name : NAME - | BLOCKNAME - | TYPENAME - ; - -name_not_typename : NAME - | BLOCKNAME - ; - -%% - -/* Begin counting arguments for a function call, - saving the data about any containing call. */ - -static void -start_arglist () -{ - register struct funcall *new = (struct funcall *) xmalloc (sizeof (struct funcall)); - - new->next = funcall_chain; - new->arglist_len = arglist_len; - arglist_len = 0; - funcall_chain = new; -} - -/* Return the number of arguments in a function call just terminated, - and restore the data for the containing function call. */ - -static int -end_arglist () -{ - register int val = arglist_len; - register struct funcall *call = funcall_chain; - funcall_chain = call->next; - arglist_len = call->arglist_len; - free (call); - return val; -} - -/* Free everything in the funcall chain. - Used when there is an error inside parsing. */ - -static void -free_funcalls () -{ - register struct funcall *call, *next; - - for (call = funcall_chain; call; call = next) - { - next = call->next; - free (call); - } -} - -/* This page contains the functions for adding data to the struct expression - being constructed. */ - -/* Add one element to the end of the expression. */ - -/* To avoid a bug in the Sun 4 compiler, we pass things that can fit into - a register through here */ - -static void -write_exp_elt (expelt) - union exp_element expelt; -{ - if (expout_ptr >= expout_size) - { - expout_size *= 2; - expout = (struct expression *) xrealloc (expout, - sizeof (struct expression) - + expout_size * sizeof (union exp_element)); - } - expout->elts[expout_ptr++] = expelt; -} - -static void -write_exp_elt_opcode (expelt) - enum exp_opcode expelt; -{ - union exp_element tmp; - - tmp.opcode = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_sym (expelt) - struct symbol *expelt; -{ - union exp_element tmp; - - tmp.symbol = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_longcst (expelt) - LONGEST expelt; -{ - union exp_element tmp; - - tmp.longconst = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_dblcst (expelt) - double expelt; -{ - union exp_element tmp; - - tmp.doubleconst = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_type (expelt) - struct type *expelt; -{ - union exp_element tmp; - - tmp.type = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_intern (expelt) - struct internalvar *expelt; -{ - union exp_element tmp; - - tmp.internalvar = expelt; - - write_exp_elt (tmp); -} - -/* Add a string constant to the end of the expression. - Follow it by its length in bytes, as a separate exp_element. */ - -static void -write_exp_string (str) - struct stoken str; -{ - register int len = str.length; - register int lenelt - = (len + sizeof (union exp_element)) / sizeof (union exp_element); - - expout_ptr += lenelt; - - if (expout_ptr >= expout_size) - { - expout_size = max (expout_size * 2, expout_ptr + 10); - expout = (struct expression *) - xrealloc (expout, (sizeof (struct expression) - + (expout_size * sizeof (union exp_element)))); - } - bcopy (str.ptr, (char *) &expout->elts[expout_ptr - lenelt], len); - ((char *) &expout->elts[expout_ptr - lenelt])[len] = 0; - write_exp_elt_longcst ((LONGEST) len); -} - -/* During parsing of a C expression, the pointer to the next character - is in this variable. */ - -static char *lexptr; - -/* Tokens that refer to names do so with explicit pointer and length, - so they can share the storage that lexptr is parsing. - - When it is necessary to pass a name to a function that expects - a null-terminated string, the substring is copied out - into a block of storage that namecopy points to. - - namecopy is allocated once, guaranteed big enough, for each parsing. */ - -static char *namecopy; - -/* Current depth in parentheses within the expression. */ - -static int paren_depth; - -/* Nonzero means stop parsing on first comma (if not within parentheses). */ - -static int comma_terminates; - -/* Take care of parsing a number (anything that starts with a digit). - Set yylval and return the token type; update lexptr. - LEN is the number of characters in it. */ - -/*** Needs some error checking for the float case ***/ - -static int -parse_number (olen) - int olen; -{ - register char *p = lexptr; - register LONGEST n = 0; - register int c; - register int base = 10; - register int len = olen; - char *err_copy; - int unsigned_p = 0; - - extern double atof (); - - for (c = 0; c < len; c++) - if (p[c] == '.') - { - /* It's a float since it contains a point. */ - yylval.dval = atof (p); - lexptr += len; - return FLOAT; - } - - if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) - { - p += 2; - base = 16; - len -= 2; - } - else if (*p == '0') - base = 8; - - while (len-- > 0) - { - c = *p++; - if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; - if (c != 'l' && c != 'u') - n *= base; - if (c >= '0' && c <= '9') - n += c - '0'; - else - { - if (base == 16 && c >= 'a' && c <= 'f') - n += c - 'a' + 10; - else if (len == 0 && c == 'l') - ; - else if (len == 0 && c == 'u') - unsigned_p = 1; - else if (base == 10 && len != 0 && (c == 'e' || c == 'E')) - { - /* Scientific notation, where we are unlucky enough not - to have a '.' in the string. */ - yylval.dval = atof (lexptr); - lexptr += olen; - return FLOAT; - } - else - { - err_copy = (char *) alloca (olen + 1); - bcopy (lexptr, err_copy, olen); - err_copy[olen] = 0; - error ("Invalid number \"%s\".", err_copy); - } - } - } - - lexptr = p; - if (unsigned_p) - { - yylval.ulval = n; - return UINT; - } - else - { - yylval.lval = n; - return INT; - } -} - -struct token -{ - char *operator; - int token; - enum exp_opcode opcode; -}; - -static struct token tokentab3[] = - { - {">>=", ASSIGN_MODIFY, BINOP_RSH}, - {"<<=", ASSIGN_MODIFY, BINOP_LSH} - }; - -static struct token tokentab2[] = - { - {"+=", ASSIGN_MODIFY, BINOP_ADD}, - {"-=", ASSIGN_MODIFY, BINOP_SUB}, - {"*=", ASSIGN_MODIFY, BINOP_MUL}, - {"/=", ASSIGN_MODIFY, BINOP_DIV}, - {"%=", ASSIGN_MODIFY, BINOP_REM}, - {"|=", ASSIGN_MODIFY, BINOP_LOGIOR}, - {"&=", ASSIGN_MODIFY, BINOP_LOGAND}, - {"^=", ASSIGN_MODIFY, BINOP_LOGXOR}, - {"++", INCREMENT, BINOP_END}, - {"--", DECREMENT, BINOP_END}, - {"->", ARROW, BINOP_END}, - {"&&", AND, BINOP_END}, - {"||", OR, BINOP_END}, - {"::", COLONCOLON, BINOP_END}, - {"<<", LSH, BINOP_END}, - {">>", RSH, BINOP_END}, - {"==", EQUAL, BINOP_END}, - {"!=", NOTEQUAL, BINOP_END}, - {"<=", LEQ, BINOP_END}, - {">=", GEQ, BINOP_END} - }; - -/* assign machine-independent names to certain registers - * (unless overridden by the REGISTER_NAMES table) - */ -struct std_regs { - char *name; - int regnum; -} std_regs[] = { -#ifdef PC_REGNUM - { "pc", PC_REGNUM }, -#endif -#ifdef FP_REGNUM - { "fp", FP_REGNUM }, -#endif -#ifdef SP_REGNUM - { "sp", SP_REGNUM }, -#endif -#ifdef PS_REGNUM - { "ps", PS_REGNUM }, -#endif -}; - -#define NUM_STD_REGS (sizeof std_regs / sizeof std_regs[0]) - -/* Read one token, getting characters through lexptr. */ - -static int -yylex () -{ - register int c; - register int namelen; - register int i; - register char *tokstart; - - retry: - - tokstart = lexptr; - /* See if it is a special token of length 3. */ - for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++) - if (!strncmp (tokstart, tokentab3[i].operator, 3)) - { - lexptr += 3; - yylval.opcode = tokentab3[i].opcode; - return tokentab3[i].token; - } - - /* See if it is a special token of length 2. */ - for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++) - if (!strncmp (tokstart, tokentab2[i].operator, 2)) - { - lexptr += 2; - yylval.opcode = tokentab2[i].opcode; - return tokentab2[i].token; - } - - switch (c = *tokstart) - { - case 0: - return 0; - - case ' ': - case '\t': - case '\n': - lexptr++; - goto retry; - - case '\'': - lexptr++; - c = *lexptr++; - if (c == '\\') - c = parse_escape (&lexptr); - yylval.lval = c; - c = *lexptr++; - if (c != '\'') - error ("Invalid character constant."); - return CHAR; - - case '(': - paren_depth++; - lexptr++; - return c; - - case ')': - if (paren_depth == 0) - return 0; - paren_depth--; - lexptr++; - return c; - - case ',': - if (comma_terminates && paren_depth == 0) - return 0; - lexptr++; - return c; - - case '.': - /* Might be a floating point number. */ - if (lexptr[1] >= '0' && lexptr[1] <= '9') - break; /* Falls into number code. */ - - case '+': - case '-': - case '*': - case '/': - case '%': - case '|': - case '&': - case '^': - case '~': - case '!': - case '@': - case '<': - case '>': - case '[': - case ']': - case '?': - case ':': - case '=': - case '{': - case '}': - lexptr++; - return c; - - case '"': - for (namelen = 1; (c = tokstart[namelen]) != '"'; namelen++) - if (c == '\\') - { - c = tokstart[++namelen]; - if (c >= '0' && c <= '9') - { - c = tokstart[++namelen]; - if (c >= '0' && c <= '9') - c = tokstart[++namelen]; - } - } - yylval.sval.ptr = tokstart + 1; - yylval.sval.length = namelen - 1; - lexptr += namelen + 1; - return STRING; - } - - /* Is it a number? */ - /* Note: We have already dealt with the case of the token '.'. - See case '.' above. */ - if ((c >= '0' && c <= '9') || c == '.') - { - /* It's a number. */ - int got_dot = 0, got_e = 0; - register char *p = tokstart; - int hex = c == '0' && (p[1] == 'x' || p[1] == 'X'); - if (hex) - p += 2; - for (;; ++p) - { - if (!hex && !got_e && (*p == 'e' || *p == 'E')) - got_dot = got_e = 1; - else if (!hex && !got_dot && *p == '.') - got_dot = 1; - else if (got_e && (p[-1] == 'e' || p[-1] == 'E') - && (*p == '-' || *p == '+')) - /* This is the sign of the exponent, not the end of the - number. */ - continue; - else if (!got_dot && !got_e && (*p=='l'||*p=='L')){ - ++p; break; - } - else if (!got_dot && !got_e && !hex && (*p=='u'||*p=='U')){ - ++p; break; - } - else if (*p < '0' || *p > '9' - && (!hex || ((*p < 'a' || *p > 'f') - && (*p < 'A' || *p > 'F')))) - break; - } - return parse_number (p - tokstart); - } - - if (!(c == '_' || c == '$' - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) - /* We must have come across a bad character (e.g. ';'). */ - error ("Invalid character '%c' in expression.", c); - - /* It's a name. See how long it is. */ - namelen = 0; - for (c = tokstart[namelen]; - (c == '_' || c == '$' || (c >= '0' && c <= '9') - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); - c = tokstart[++namelen]) - ; - - /* The token "if" terminates the expression and is NOT - removed from the input stream. */ - if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') - { - return 0; - } - - lexptr += namelen; - - /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) - and $$digits (equivalent to $<-digits> if you could type that). - Make token type LAST, and put the number (the digits) in yylval. */ - - if (*tokstart == '$') - { - register int negate = 0; - c = 1; - /* Double dollar means negate the number and add -1 as well. - Thus $$ alone means -1. */ - if (namelen >= 2 && tokstart[1] == '$') - { - negate = 1; - c = 2; - } - if (c == namelen) - { - /* Just dollars (one or two) */ - yylval.lval = - negate; - return LAST; - } - /* Is the rest of the token digits? */ - for (; c < namelen; c++) - if (!(tokstart[c] >= '0' && tokstart[c] <= '9')) - break; - if (c == namelen) - { - yylval.lval = atoi (tokstart + 1 + negate); - if (negate) - yylval.lval = - yylval.lval; - return LAST; - } - } - - /* Handle tokens that refer to machine registers: - $ followed by a register name. */ - - if (*tokstart == '$') { - for (c = 0; c < NUM_REGS; c++) - if (namelen - 1 == strlen (reg_names[c]) - && !strncmp (tokstart + 1, reg_names[c], namelen - 1)) - { - yylval.lval = c; - return REGNAME; - } - for (c = 0; c < NUM_STD_REGS; c++) - if (namelen - 1 == strlen (std_regs[c].name) - && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1)) - { - yylval.lval = std_regs[c].regnum; - return REGNAME; - } - } - /* Catch specific keywords. Should be done with a data structure. */ - switch (namelen) - { - case 8: - if (!strncmp (tokstart, "unsigned", 8)) - return UNSIGNED; - break; - case 6: - if (!strncmp (tokstart, "struct", 6)) - return STRUCT; - if (!strncmp (tokstart, "signed", 6)) - return SIGNED; - if (!strncmp (tokstart, "sizeof", 6)) - return SIZEOF; - break; - case 5: - if (!strncmp (tokstart, "union", 5)) - return UNION; - if (!strncmp (tokstart, "short", 5)) - return SHORT; - break; - case 4: - if (!strncmp (tokstart, "enum", 4)) - return ENUM; - if (!strncmp (tokstart, "long", 4)) - return LONG; - if (!strncmp (tokstart, "this", 4) - && lookup_symbol ("$this", expression_context_block, - VAR_NAMESPACE, 0)) - return THIS; - break; - case 3: - if (!strncmp (tokstart, "int", 3)) - return INT_KEYWORD; - break; - default: - break; - } - - yylval.sval.ptr = tokstart; - yylval.sval.length = namelen; - - /* Any other names starting in $ are debugger internal variables. */ - - if (*tokstart == '$') - { - yylval.ivar = (struct internalvar *) lookup_internalvar (copy_name (yylval.sval) + 1); - return VARIABLE; - } - - /* Use token-type BLOCKNAME for symbols that happen to be defined as - functions or symtabs. If this is not so, then ... - Use token-type TYPENAME for symbols that happen to be defined - currently as names of types; NAME for other symbols. - The caller is not constrained to care about the distinction. */ - { - char *tmp = copy_name (yylval.sval); - struct symbol *sym; - - if (lookup_partial_symtab (tmp)) - return BLOCKNAME; - sym = lookup_symbol (tmp, expression_context_block, - VAR_NAMESPACE, 0); - if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK) - return BLOCKNAME; - if (lookup_typename (copy_name (yylval.sval), expression_context_block, 1)) - return TYPENAME; - return NAME; - } -} - -static void -yyerror () -{ - error ("Invalid syntax in expression."); -} - -/* Return a null-terminated temporary copy of the name - of a string token. */ - -static char * -copy_name (token) - struct stoken token; -{ - bcopy (token.ptr, namecopy, token.length); - namecopy[token.length] = 0; - return namecopy; -} - -/* Reverse an expression from suffix form (in which it is constructed) - to prefix form (in which we can conveniently print or execute it). */ - -static void prefixify_subexp (); - -static void -prefixify_expression (expr) - register struct expression *expr; -{ - register int len = sizeof (struct expression) + - expr->nelts * sizeof (union exp_element); - register struct expression *temp; - register int inpos = expr->nelts, outpos = 0; - - temp = (struct expression *) alloca (len); - - /* Copy the original expression into temp. */ - bcopy (expr, temp, len); - - prefixify_subexp (temp, expr, inpos, outpos); -} - -/* Return the number of exp_elements in the subexpression of EXPR - whose last exp_element is at index ENDPOS - 1 in EXPR. */ - -static int -length_of_subexp (expr, endpos) - register struct expression *expr; - register int endpos; -{ - register int oplen = 1; - register int args = 0; - register int i; - - if (endpos < 0) - error ("?error in length_of_subexp"); - - i = (int) expr->elts[endpos - 1].opcode; - - switch (i) - { - /* C++ */ - case OP_SCOPE: - oplen = 4 + ((expr->elts[endpos - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case OP_LONG: - case OP_DOUBLE: - oplen = 4; - break; - - case OP_VAR_VALUE: - case OP_LAST: - case OP_REGISTER: - case OP_INTERNALVAR: - oplen = 3; - break; - - case OP_FUNCALL: - oplen = 3; - args = 1 + expr->elts[endpos - 2].longconst; - break; - - case UNOP_CAST: - case UNOP_MEMVAL: - oplen = 3; - args = 1; - break; - - case STRUCTOP_STRUCT: - case STRUCTOP_PTR: - args = 1; - case OP_STRING: - oplen = 3 + ((expr->elts[endpos - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case TERNOP_COND: - args = 3; - break; - - case BINOP_ASSIGN_MODIFY: - oplen = 3; - args = 2; - break; - - /* C++ */ - case OP_THIS: - oplen = 2; - break; - - default: - args = 1 + (i < (int) BINOP_END); - } - - while (args > 0) - { - oplen += length_of_subexp (expr, endpos - oplen); - args--; - } - - return oplen; -} - -/* Copy the subexpression ending just before index INEND in INEXPR - into OUTEXPR, starting at index OUTBEG. - In the process, convert it from suffix to prefix form. */ - -static void -prefixify_subexp (inexpr, outexpr, inend, outbeg) - register struct expression *inexpr; - struct expression *outexpr; - register int inend; - int outbeg; -{ - register int oplen = 1; - register int args = 0; - register int i; - int *arglens; - enum exp_opcode opcode; - - /* Compute how long the last operation is (in OPLEN), - and also how many preceding subexpressions serve as - arguments for it (in ARGS). */ - - opcode = inexpr->elts[inend - 1].opcode; - switch (opcode) - { - /* C++ */ - case OP_SCOPE: - oplen = 4 + ((inexpr->elts[inend - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case OP_LONG: - case OP_DOUBLE: - oplen = 4; - break; - - case OP_VAR_VALUE: - case OP_LAST: - case OP_REGISTER: - case OP_INTERNALVAR: - oplen = 3; - break; - - case OP_FUNCALL: - oplen = 3; - args = 1 + inexpr->elts[inend - 2].longconst; - break; - - case UNOP_CAST: - case UNOP_MEMVAL: - oplen = 3; - args = 1; - break; - - case STRUCTOP_STRUCT: - case STRUCTOP_PTR: - args = 1; - case OP_STRING: - oplen = 3 + ((inexpr->elts[inend - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - - break; - - case TERNOP_COND: - args = 3; - break; - - case BINOP_ASSIGN_MODIFY: - oplen = 3; - args = 2; - break; - - /* C++ */ - case OP_THIS: - oplen = 2; - break; - - default: - args = 1 + ((int) opcode < (int) BINOP_END); - } - - /* Copy the final operator itself, from the end of the input - to the beginning of the output. */ - inend -= oplen; - bcopy (&inexpr->elts[inend], &outexpr->elts[outbeg], - oplen * sizeof (union exp_element)); - outbeg += oplen; - - /* Find the lengths of the arg subexpressions. */ - arglens = (int *) alloca (args * sizeof (int)); - for (i = args - 1; i >= 0; i--) - { - oplen = length_of_subexp (inexpr, inend); - arglens[i] = oplen; - inend -= oplen; - } - - /* Now copy each subexpression, preserving the order of - the subexpressions, but prefixifying each one. - In this loop, inend starts at the beginning of - the expression this level is working on - and marches forward over the arguments. - outbeg does similarly in the output. */ - for (i = 0; i < args; i++) - { - oplen = arglens[i]; - inend += oplen; - prefixify_subexp (inexpr, outexpr, inend, outbeg); - outbeg += oplen; - } -} - -/* This page contains the two entry points to this file. */ - -/* Read a C expression from the string *STRINGPTR points to, - parse it, and return a pointer to a struct expression that we malloc. - Use block BLOCK as the lexical context for variable names; - if BLOCK is zero, use the block of the selected stack frame. - Meanwhile, advance *STRINGPTR to point after the expression, - at the first nonwhite character that is not part of the expression - (possibly a null character). - - If COMMA is nonzero, stop if a comma is reached. */ - -struct expression * -parse_c_1 (stringptr, block, comma) - char **stringptr; - struct block *block; -{ - struct cleanup *old_chain; - - lexptr = *stringptr; - - paren_depth = 0; - type_stack_depth = 0; - - comma_terminates = comma; - - if (lexptr == 0 || *lexptr == 0) - error_no_arg ("expression to compute"); - - old_chain = make_cleanup (free_funcalls, 0); - funcall_chain = 0; - - expression_context_block = block ? block : get_selected_block (); - - namecopy = (char *) alloca (strlen (lexptr) + 1); - expout_size = 10; - expout_ptr = 0; - expout = (struct expression *) - xmalloc (sizeof (struct expression) - + expout_size * sizeof (union exp_element)); - make_cleanup (free_current_contents, &expout); - if (yyparse ()) - yyerror (); - discard_cleanups (old_chain); - expout->nelts = expout_ptr; - expout = (struct expression *) - xrealloc (expout, - sizeof (struct expression) - + expout_ptr * sizeof (union exp_element)); - prefixify_expression (expout); - *stringptr = lexptr; - return expout; -} - -/* Parse STRING as an expression, and complain if this fails - to use up all of the contents of STRING. */ - -struct expression * -parse_c_expression (string) - char *string; -{ - register struct expression *exp; - exp = parse_c_1 (&string, 0, 0); - if (*string) - error ("Junk after end of expression."); - return exp; -} - -static void -push_type (tp) - enum type_pieces tp; -{ - if (type_stack_depth == type_stack_size) - { - type_stack_size *= 2; - type_stack = (enum type_pieces *) - xrealloc (type_stack, type_stack_size * sizeof (enum type_pieces)); - } - type_stack[type_stack_depth++] = tp; -} - -static enum type_pieces -pop_type () -{ - if (type_stack_depth) - return type_stack[--type_stack_depth]; - return tp_end; -} - -void -_initialize_expread () -{ - type_stack_size = 80; - type_stack_depth = 0; - type_stack = (enum type_pieces *) - xmalloc (type_stack_size * sizeof (enum type_pieces)); -} diff --git a/gnu/usr.bin/gdb/expression.h b/gnu/usr.bin/gdb/expression.h deleted file mode 100644 index 3f2f20be2b42..000000000000 --- a/gnu/usr.bin/gdb/expression.h +++ /dev/null @@ -1,194 +0,0 @@ -/* Definitions for expressions stored in reversed prefix form, for GDB. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: expression.h,v 1.2 1993/08/02 17:40:59 mycroft Exp $ -*/ - -/* Definitions for saved C expressions. */ - -/* An expression is represented as a vector of union exp_element's. - Each exp_element is an opcode, except that some opcodes cause - the following exp_element to be treated as a long or double constant - or as a variable. The opcodes are obeyed, using a stack for temporaries. - The value is left on the temporary stack at the end. */ - -/* When it is necessary to include a string, - it can occupy as many exp_elements as it needs. - We find the length of the string using strlen, - divide to find out how many exp_elements are used up, - and skip that many. Strings, like numbers, are indicated - by the preceding opcode. */ - -enum exp_opcode -{ -/* BINOP_... operate on two values computed by following subexpressions, - replacing them by one result value. They take no immediate arguments. */ - BINOP_ADD, /* + */ - BINOP_SUB, /* - */ - BINOP_MUL, /* * */ - BINOP_DIV, /* / */ - BINOP_REM, /* % */ - BINOP_LSH, /* << */ - BINOP_RSH, /* >> */ - BINOP_AND, /* && */ - BINOP_OR, /* || */ - BINOP_LOGAND, /* & */ - BINOP_LOGIOR, /* | */ - BINOP_LOGXOR, /* ^ */ - BINOP_EQUAL, /* == */ - BINOP_NOTEQUAL, /* != */ - BINOP_LESS, /* < */ - BINOP_GTR, /* > */ - BINOP_LEQ, /* <= */ - BINOP_GEQ, /* >= */ - BINOP_REPEAT, /* @ */ - BINOP_ASSIGN, /* = */ - BINOP_COMMA, /* , */ - BINOP_SUBSCRIPT, /* x[y] */ - BINOP_EXP, /* Exponentiation */ - -/* C++. */ - BINOP_MIN, /* ? */ - BINOP_SCOPE, /* :: */ - - /* STRUCTOP_MEMBER is used for pointer-to-member constructs. - X . * Y translates into X STRUCTOP_MEMBER Y. */ - STRUCTOP_MEMBER, - /* STRUCTOP_MPTR is used for pointer-to-member constructs - when X is a pointer instead of an aggregate. */ - STRUCTOP_MPTR, -/* end of C++. */ - - BINOP_END, - - BINOP_ASSIGN_MODIFY, /* +=, -=, *=, and so on. - The following exp_element is another opcode, - a BINOP_, saying how to modify. - Then comes another BINOP_ASSIGN_MODIFY, - making three exp_elements in total. */ - -/* Operates on three values computed by following subexpressions. */ - TERNOP_COND, /* ?: */ - -/* The OP_... series take immediate following arguments. - After the arguments come another OP_... (the same one) - so that the grouping can be recognized from the end. */ - -/* OP_LONG is followed by a type pointer in the next exp_element - and the long constant value in the following exp_element. - Then comes another OP_LONG. - Thus, the operation occupies four exp_elements. */ - - OP_LONG, -/* OP_DOUBLE is similar but takes a double constant instead of a long one. */ - OP_DOUBLE, -/* OP_VAR_VALUE takes one struct symbol * in the following exp_element, - followed by another OP_VAR_VALUE, making three exp_elements. */ - OP_VAR_VALUE, -/* OP_LAST is followed by an integer in the next exp_element. - The integer is zero for the last value printed, - or it is the absolute number of a history element. - With another OP_LAST at the end, this makes three exp_elements. */ - OP_LAST, -/* OP_REGISTER is followed by an integer in the next exp_element. - This is the number of a register to fetch (as an int). - With another OP_REGISTER at the end, this makes three exp_elements. */ - OP_REGISTER, -/* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element. - With another OP_INTERNALVAR at the end, this makes three exp_elements. */ - OP_INTERNALVAR, -/* OP_FUNCALL is followed by an integer in the next exp_element. - The integer is the number of args to the function call. - That many plus one values from following subexpressions - are used, the first one being the function. - The integer is followed by a repeat of OP_FUNCALL, - making three exp_elements. */ - OP_FUNCALL, -/* OP_STRING represents a string constant. - Its format is the same as that of a STRUCTOP, but the string - data is just made into a string constant when the operation - is executed. */ - OP_STRING, - -/* UNOP_CAST is followed by a type pointer in the next exp_element. - With another UNOP_CAST at the end, this makes three exp_elements. - It casts the value of the following subexpression. */ - UNOP_CAST, -/* UNOP_MEMVAL is followed by a type pointer in the next exp_element - With another UNOP_MEMVAL at the end, this makes three exp_elements. - It casts the contents of the word addressed by the value of the - following subexpression. */ - UNOP_MEMVAL, -/* UNOP_... operate on one value from a following subexpression - and replace it with a result. They take no immediate arguments. */ - UNOP_NEG, /* Unary - */ - UNOP_ZEROP, /* Unary ! */ - UNOP_LOGNOT, /* Unary ~ */ - UNOP_IND, /* Unary * */ - UNOP_ADDR, /* Unary & */ - UNOP_PREINCREMENT, /* ++ before an expression */ - UNOP_POSTINCREMENT, /* ++ after an expression */ - UNOP_PREDECREMENT, /* -- before an expression */ - UNOP_POSTDECREMENT, /* -- after an expression */ - UNOP_SIZEOF, /* Unary sizeof (followed by expression) */ - -/* STRUCTOP_... operate on a value from a following subexpression - by extracting a structure component specified by a string - that appears in the following exp_elements (as many as needed). - STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->". - They differ only in the error message given in case the value is - not suitable or the structure component specified is not found. - - The length of the string follows in the next exp_element, - (after the string), followed by another STRUCTOP_... code. */ - STRUCTOP_STRUCT, - STRUCTOP_PTR, - -/* C++ */ - /* OP_THIS is just a placeholder for the class instance variable. - It just comes in a tight (OP_THIS, OP_THIS) pair. */ - OP_THIS, - - /* OP_SCOPE surrounds a type name and a field name. The type - name is encoded as one element, but the field name stays as - a string, which, of course, is variable length. */ - OP_SCOPE, - -}; - -union exp_element -{ - enum exp_opcode opcode; - struct symbol *symbol; - LONGEST longconst; - double doubleconst; - char string; - struct type *type; - struct internalvar *internalvar; -}; - -struct expression -{ - int nelts; - union exp_element elts[1]; -}; - -struct expression *parse_c_expression (); -struct expression *parse_c_1 (); diff --git a/gnu/usr.bin/gdb/findvar.c b/gnu/usr.bin/gdb/findvar.c deleted file mode 100644 index 1d6b191be9e9..000000000000 --- a/gnu/usr.bin/gdb/findvar.c +++ /dev/null @@ -1,583 +0,0 @@ -/* Find a variable's value in memory, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: findvar.c,v 1.2 1993/08/02 17:41:00 mycroft Exp $"; -#endif /* not lint */ - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "value.h" - -CORE_ADDR read_register (); - -/* Return the address in which frame FRAME's value of register REGNUM - has been saved in memory. Or return zero if it has not been saved. - If REGNUM specifies the SP, the value we return is actually - the SP value, not an address where it was saved. */ - -CORE_ADDR -find_saved_register (frame, regnum) - FRAME frame; - int regnum; -{ - struct frame_info *fi; - struct frame_saved_regs saved_regs; - - register FRAME frame1 = 0; - register CORE_ADDR addr = 0; - -#ifdef HAVE_REGISTER_WINDOWS - /* We assume that a register in a register window will only be saved - in one place (since the name changes and disappears as you go - towards inner frames), so we only call get_frame_saved_regs on - the current frame. This is directly in contradiction to the - usage below, which assumes that registers used in a frame must be - saved in a lower (more interior) frame. This change is a result - of working on a register window machine; get_frame_saved_regs - always returns the registers saved within a frame, within the - context (register namespace) of that frame. */ - - /* However, note that we don't want this to return anything if - nothing is saved (if there's a frame inside of this one). Also, - callers to this routine asking for the stack pointer want the - stack pointer saved for *this* frame; this is returned from the - next frame. */ - - - if (REGISTER_IN_WINDOW_P(regnum)) - { - frame1 = get_next_frame (frame); - if (!frame1) return 0; /* Registers of this frame are - active. */ - - /* Get the SP from the next frame in; it will be this - current frame. */ - if (regnum != SP_REGNUM) - frame1 = frame; - - fi = get_frame_info (frame1); - get_frame_saved_regs (fi, &saved_regs); - return (saved_regs.regs[regnum] ? - saved_regs.regs[regnum] : 0); - } -#endif /* HAVE_REGISTER_WINDOWS */ - - /* Note that this next routine assumes that registers used in - frame x will be saved only in the frame that x calls and - frames interior to it. This is not true on the sparc, but the - above macro takes care of it, so we should be all right. */ - while (1) - { - QUIT; - frame1 = get_prev_frame (frame1); - if (frame1 == 0 || frame1 == frame) - break; - fi = get_frame_info (frame1); - get_frame_saved_regs (fi, &saved_regs); - if (saved_regs.regs[regnum]) - addr = saved_regs.regs[regnum]; - } - - return addr; -} - -/* Copy the bytes of register REGNUM, relative to the current stack frame, - into our memory at MYADDR. - The number of bytes copied is REGISTER_RAW_SIZE (REGNUM). */ - -void -read_relative_register_raw_bytes (regnum, myaddr) - int regnum; - char *myaddr; -{ - register CORE_ADDR addr; - - if (regnum == FP_REGNUM) - { - bcopy (&FRAME_FP(selected_frame), myaddr, sizeof (CORE_ADDR)); - return; - } - - addr = find_saved_register (selected_frame, regnum); - - if (addr) - { - if (regnum == SP_REGNUM) - { - CORE_ADDR buffer = addr; - bcopy (&buffer, myaddr, sizeof (CORE_ADDR)); - } - else - read_memory (addr, myaddr, REGISTER_RAW_SIZE (regnum)); - return; - } - read_register_bytes (REGISTER_BYTE (regnum), - myaddr, REGISTER_RAW_SIZE (regnum)); -} - -/* Return a `value' with the contents of register REGNUM - in its virtual format, with the type specified by - REGISTER_VIRTUAL_TYPE. */ - -value -value_of_register (regnum) - int regnum; -{ - register CORE_ADDR addr; - register value val; - char raw_buffer[MAX_REGISTER_RAW_SIZE]; - char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; - - if (! (have_inferior_p () || have_core_file_p ())) - error ("Can't get value of register without inferior or core file"); - - addr = find_saved_register (selected_frame, regnum); - if (addr) - { - if (regnum == SP_REGNUM) - return value_from_long (builtin_type_int, (LONGEST) addr); - read_memory (addr, raw_buffer, REGISTER_RAW_SIZE (regnum)); - } - else - read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, - REGISTER_RAW_SIZE (regnum)); - - REGISTER_CONVERT_TO_VIRTUAL (regnum, raw_buffer, virtual_buffer); - val = allocate_value (REGISTER_VIRTUAL_TYPE (regnum)); - bcopy (virtual_buffer, VALUE_CONTENTS (val), REGISTER_VIRTUAL_SIZE (regnum)); - VALUE_LVAL (val) = addr ? lval_memory : lval_register; - VALUE_ADDRESS (val) = addr ? addr : REGISTER_BYTE (regnum); - VALUE_REGNO (val) = regnum; - return val; -} - -/* Low level examining and depositing of registers. - - Note that you must call `fetch_registers' once - before examining or depositing any registers. */ - -char registers[REGISTER_BYTES]; - -/* Copy LEN bytes of consecutive data from registers - starting with the REGBYTE'th byte of register data - into memory at MYADDR. */ - -void -read_register_bytes (regbyte, myaddr, len) - int regbyte; - char *myaddr; - int len; -{ - bcopy (®isters[regbyte], myaddr, len); -} - -/* Copy LEN bytes of consecutive data from memory at MYADDR - into registers starting with the REGBYTE'th byte of register data. */ - -void -write_register_bytes (regbyte, myaddr, len) - int regbyte; - char *myaddr; - int len; -{ - bcopy (myaddr, ®isters[regbyte], len); - if (have_inferior_p ()) - store_inferior_registers (-1); -} - -/* Return the contents of register REGNO, - regarding it as an integer. */ - -CORE_ADDR -read_register (regno) - int regno; -{ - /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */ - return *(int *) ®isters[REGISTER_BYTE (regno)]; -} - -/* Store VALUE in the register number REGNO, regarded as an integer. */ - -void -write_register (regno, val) - int regno, val; -{ - /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */ -#if defined(sun4) - /* This is a no-op on a Sun 4. */ - if (regno == 0) - return; -#endif - - *(int *) ®isters[REGISTER_BYTE (regno)] = val; - - if (have_inferior_p ()) - store_inferior_registers (regno); -} - -/* Record that register REGNO contains VAL. - This is used when the value is obtained from the inferior or core dump, - so there is no need to store the value there. */ - -void -supply_register (regno, val) - int regno; - char *val; -{ - bcopy (val, ®isters[REGISTER_BYTE (regno)], REGISTER_RAW_SIZE (regno)); -} - -/* Given a struct symbol for a variable, - and a stack frame id, read the value of the variable - and return a (pointer to a) struct value containing the value. */ - -value -read_var_value (var, frame) - register struct symbol *var; - FRAME frame; -{ - register value v; - - struct frame_info *fi; - - struct type *type = SYMBOL_TYPE (var); - register CORE_ADDR addr = 0; - int val = SYMBOL_VALUE (var); - register int len; - - v = allocate_value (type); - VALUE_LVAL (v) = lval_memory; /* The most likely possibility. */ - len = TYPE_LENGTH (type); - - if (frame == 0) frame = selected_frame; - - switch (SYMBOL_CLASS (var)) - { - case LOC_CONST: - case LOC_LABEL: - bcopy (&val, VALUE_CONTENTS (v), len); - VALUE_LVAL (v) = not_lval; - return v; - - case LOC_CONST_BYTES: - bcopy (val, VALUE_CONTENTS (v), len); - VALUE_LVAL (v) = not_lval; - return v; - - case LOC_STATIC: - addr = val; - break; - -/* Nonzero if a struct which is located in a register or a LOC_ARG - really contains - the address of the struct, not the struct itself. GCC_P is nonzero - if the function was compiled with GCC. */ -#if !defined (REG_STRUCT_HAS_ADDR) -#define REG_STRUCT_HAS_ADDR(gcc_p) 0 -#endif - - case LOC_ARG: - fi = get_frame_info (frame); - addr = val + FRAME_ARGS_ADDRESS (fi); - break; - - case LOC_REF_ARG: - fi = get_frame_info (frame); - addr = val + FRAME_ARGS_ADDRESS (fi); - addr = read_memory_integer (addr, sizeof (CORE_ADDR)); - break; - - case LOC_LOCAL: - fi = get_frame_info (frame); - addr = val + FRAME_LOCALS_ADDRESS (fi); - break; - - case LOC_TYPEDEF: - error ("Cannot look up value of a typedef"); - - case LOC_BLOCK: - VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (var)); - return v; - - case LOC_REGISTER: - case LOC_REGPARM: - { - struct block *b = get_frame_block (frame); - - v = value_from_register (type, val, frame); - - if (REG_STRUCT_HAS_ADDR(b->gcc_compile_flag) - && TYPE_CODE (type) == TYPE_CODE_STRUCT) - addr = *(CORE_ADDR *)VALUE_CONTENTS (v); - else - return v; - } - } - - read_memory (addr, VALUE_CONTENTS (v), len); - VALUE_ADDRESS (v) = addr; - return v; -} - -/* Return a value of type TYPE, stored in register REGNUM, in frame - FRAME. */ - -value -value_from_register (type, regnum, frame) - struct type *type; - int regnum; - FRAME frame; -{ - char raw_buffer [MAX_REGISTER_RAW_SIZE]; - char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; - CORE_ADDR addr; - value v = allocate_value (type); - int len = TYPE_LENGTH (type); - char *value_bytes = 0; - int value_bytes_copied = 0; - int num_storage_locs; - - VALUE_REGNO (v) = regnum; - - num_storage_locs = (len > REGISTER_VIRTUAL_SIZE (regnum) ? - ((len - 1) / REGISTER_RAW_SIZE (regnum)) + 1 : - 1); - - if (num_storage_locs > 1) - { - /* Value spread across multiple storage locations. */ - - int local_regnum; - int mem_stor = 0, reg_stor = 0; - int mem_tracking = 1; - CORE_ADDR last_addr = 0; - - value_bytes = (char *) alloca (len + MAX_REGISTER_RAW_SIZE); - - /* Copy all of the data out, whereever it may be. */ - - for (local_regnum = regnum; - value_bytes_copied < len; - (value_bytes_copied += REGISTER_RAW_SIZE (local_regnum), - ++local_regnum)) - { - int register_index = local_regnum - regnum; - addr = find_saved_register (frame, local_regnum); - if (addr == 0) - { - read_register_bytes (REGISTER_BYTE (local_regnum), - value_bytes + value_bytes_copied, - REGISTER_RAW_SIZE (local_regnum)); - reg_stor++; - } - else - { - read_memory (addr, value_bytes + value_bytes_copied, - REGISTER_RAW_SIZE (local_regnum)); - mem_stor++; - mem_tracking = - (mem_tracking - && (regnum == local_regnum - || addr == last_addr)); - } - last_addr = addr; - } - - if ((reg_stor && mem_stor) - || (mem_stor && !mem_tracking)) - /* Mixed storage; all of the hassle we just went through was - for some good purpose. */ - { - VALUE_LVAL (v) = lval_reg_frame_relative; - VALUE_FRAME (v) = FRAME_FP (frame); - VALUE_FRAME_REGNUM (v) = regnum; - } - else if (mem_stor) - { - VALUE_LVAL (v) = lval_memory; - VALUE_ADDRESS (v) = find_saved_register (frame, regnum); - } - else if (reg_stor) - { - VALUE_LVAL (v) = lval_register; - VALUE_ADDRESS (v) = REGISTER_BYTE (regnum); - } - else - fatal ("value_from_register: Value not stored anywhere!"); - - /* Any structure stored in more than one register will always be - an inegral number of registers. Otherwise, you'd need to do - some fiddling with the last register copied here for little - endian machines. */ - - /* Copy into the contents section of the value. */ - bcopy (value_bytes, VALUE_CONTENTS (v), len); - - return v; - } - - /* Data is completely contained within a single register. Locate the - register's contents in a real register or in core; - read the data in raw format. */ - - addr = find_saved_register (frame, regnum); - if (addr == 0) - { - /* Value is really in a register. */ - - VALUE_LVAL (v) = lval_register; - VALUE_ADDRESS (v) = REGISTER_BYTE (regnum); - - read_register_bytes (REGISTER_BYTE (regnum), - raw_buffer, REGISTER_RAW_SIZE (regnum)); - } - else - { - /* Value was in a register that has been saved in memory. */ - - read_memory (addr, raw_buffer, REGISTER_RAW_SIZE (regnum)); - VALUE_LVAL (v) = lval_memory; - VALUE_ADDRESS (v) = addr; - } - - /* Convert the raw contents to virtual contents. - (Just copy them if the formats are the same.) */ - - REGISTER_CONVERT_TO_VIRTUAL (regnum, raw_buffer, virtual_buffer); - - if (REGISTER_CONVERTIBLE (regnum)) - { - /* When the raw and virtual formats differ, the virtual format - corresponds to a specific data type. If we want that type, - copy the data into the value. - Otherwise, do a type-conversion. */ - - if (type != REGISTER_VIRTUAL_TYPE (regnum)) - { - /* eg a variable of type `float' in a 68881 register - with raw type `extended' and virtual type `double'. - Fetch it as a `double' and then convert to `float'. */ - v = allocate_value (REGISTER_VIRTUAL_TYPE (regnum)); - bcopy (virtual_buffer, VALUE_CONTENTS (v), len); - v = value_cast (type, v); - } - else - bcopy (virtual_buffer, VALUE_CONTENTS (v), len); - } - else - { - /* Raw and virtual formats are the same for this register. */ - -#ifdef BYTES_BIG_ENDIAN - if (len < REGISTER_RAW_SIZE (regnum)) - { - /* Big-endian, and we want less than full size. */ - VALUE_OFFSET (v) = REGISTER_RAW_SIZE (regnum) - len; - } -#endif - - bcopy (virtual_buffer + VALUE_OFFSET (v), - VALUE_CONTENTS (v), len); - } - - return v; -} - -/* Given a struct symbol for a variable, - and a stack frame id, - return a (pointer to a) struct value containing the variable's address. */ - -value -locate_var_value (var, frame) - register struct symbol *var; - FRAME frame; -{ - register CORE_ADDR addr = 0; - int val = SYMBOL_VALUE (var); - struct frame_info *fi; - struct type *type = SYMBOL_TYPE (var); - struct type *result_type; - - if (frame == 0) frame = selected_frame; - - switch (SYMBOL_CLASS (var)) - { - case LOC_CONST: - case LOC_CONST_BYTES: - error ("Address requested for identifier \"%s\" which is a constant.", - SYMBOL_NAME (var)); - - case LOC_REGISTER: - case LOC_REGPARM: - addr = find_saved_register (frame, val); - if (addr != 0) - { - int len = TYPE_LENGTH (type); -#ifdef BYTES_BIG_ENDIAN - if (len < REGISTER_RAW_SIZE (val)) - /* Big-endian, and we want less than full size. */ - addr += REGISTER_RAW_SIZE (val) - len; -#endif - break; - } - error ("Address requested for identifier \"%s\" which is in a register.", - SYMBOL_NAME (var)); - - case LOC_STATIC: - case LOC_LABEL: - addr = val; - break; - - case LOC_ARG: - fi = get_frame_info (frame); - addr = val + FRAME_ARGS_ADDRESS (fi); - break; - - case LOC_REF_ARG: - fi = get_frame_info (frame); - addr = val + FRAME_ARGS_ADDRESS (fi); - addr = read_memory_integer (addr, sizeof (CORE_ADDR)); - break; - - case LOC_LOCAL: - fi = get_frame_info (frame); - addr = val + FRAME_LOCALS_ADDRESS (fi); - break; - - case LOC_TYPEDEF: - error ("Address requested for identifier \"%s\" which is a typedef.", - SYMBOL_NAME (var)); - - case LOC_BLOCK: - addr = BLOCK_START (SYMBOL_BLOCK_VALUE (var)); - break; - } - - /* Address of an array is of the type of address of it's elements. */ - result_type = - lookup_pointer_type (TYPE_CODE (type) == TYPE_CODE_ARRAY ? - TYPE_TARGET_TYPE (type) : type); - - return value_cast (result_type, - value_from_long (builtin_type_long, (LONGEST) addr)); -} - diff --git a/gnu/usr.bin/gdb/frame.h b/gnu/usr.bin/gdb/frame.h deleted file mode 100644 index 4b95d6454866..000000000000 --- a/gnu/usr.bin/gdb/frame.h +++ /dev/null @@ -1,118 +0,0 @@ -/* Definitions for dealing with stack frames, for GDB, the GNU debugger. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: frame.h,v 1.2 1993/08/02 17:41:01 mycroft Exp $ -*/ - -/* Note that frame.h requires param.h! */ - -/* - * FRAME is the type of the identifier of a specific stack frame. It - * is a pointer to the frame cache item corresponding to this frame. - * Please note that frame id's are *not* constant over calls to the - * inferior. Use frame addresses, which are. - * - * FRAME_ADDR is the type of the address of a specific frame. I - * cannot imagine a case in which this would not be CORE_ADDR, so - * maybe it's silly to give it it's own type. Life's rough. - * - * FRAME_FP is a macro which converts from a frame identifier into a - * frame_address. - * - * FRAME_INFO_ID is a macro which "converts" from a frame info pointer - * to a frame id. This is here in case I or someone else decides to - * change the FRAME type again. - * - * This file and blockframe.c are the only places which are allowed to - * use the equivalence between FRAME and struct frame_info *. EXCEPTION: - * value.h uses CORE_ADDR instead of FRAME_ADDR because the compiler - * will accept that in the absense of this file. - */ -typedef struct frame_info *FRAME; -typedef CORE_ADDR FRAME_ADDR; -#define FRAME_FP(fr) ((fr)->frame) -#define FRAME_INFO_ID(f) (f) - -/* - * Caching structure for stack frames. This is also the structure - * used for extended info about stack frames. May add more to this - * structure as it becomes necessary. - * - * Note that the first entry in the cache will always refer to the - * innermost executing frame. This value should be set (is it? - * Check) in something like normal_stop. - */ -struct frame_info - { - /* Nominal address of the frame described. */ - FRAME_ADDR frame; - /* Address at which execution is occurring in this frame. - For the innermost frame, it's the current pc. - For other frames, it is a pc saved in the next frame. */ - CORE_ADDR pc; - /* The frame called by the frame we are describing, or 0. - This may be set even if there isn't a frame called by the one - we are describing (.->next == 0); in that case it is simply the - bottom of this frame */ - FRAME_ADDR next_frame; - /* Anything extra for this structure that may have been defined - in the machine depedent files. */ -#ifdef EXTRA_FRAME_INFO - EXTRA_FRAME_INFO -#endif - /* Pointers to the next and previous frame_info's in this stack. */ - FRAME next, prev; - }; - -/* Describe the saved registers of a frame. */ - -struct frame_saved_regs - { - /* For each register, address of where it was saved on entry to the frame, - or zero if it was not saved on entry to this frame. */ - CORE_ADDR regs[NUM_REGS]; - }; - -/* The stack frame that the user has specified for commands to act on. - Note that one cannot assume this is the address of valid data. */ - -extern FRAME selected_frame; - -extern struct frame_info *get_frame_info (); -extern struct frame_info *get_prev_frame_info (); - -extern FRAME create_new_frame (); - -extern void get_frame_saved_regs (); - -extern FRAME get_prev_frame (); -extern FRAME get_current_frame (); -extern FRAME get_next_frame (); - -extern struct block *get_frame_block (); -extern struct block *get_current_block (); -extern struct block *get_selected_block (); -extern struct symbol *get_frame_function (); -extern struct symbol *get_pc_function (); - -/* In stack.c */ -extern FRAME find_relative_frame (); - -/* Generic pointer value indicating "I don't know." */ -#define Frame_unknown (CORE_ADDR)-1 diff --git a/gnu/usr.bin/gdb/gdb.1 b/gnu/usr.bin/gdb/gdb.1 deleted file mode 100644 index 30ab6aacb4d8..000000000000 --- a/gnu/usr.bin/gdb/gdb.1 +++ /dev/null @@ -1,2 +0,0 @@ -.\" $Id: gdb.1,v 1.2 1993/08/02 17:41:02 mycroft Exp $ -*- nroff -*- -.\" placeholder, until we can produce the manual page diff --git a/gnu/usr.bin/gdb/getpagesize.h b/gnu/usr.bin/gdb/getpagesize.h deleted file mode 100644 index 71e9d7071a86..000000000000 --- a/gnu/usr.bin/gdb/getpagesize.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $Id: getpagesize.h,v 1.2 1993/08/02 17:41:03 mycroft Exp $ */ - -#ifdef BSD -#ifndef BSD4_1 -#define HAVE_GETPAGESIZE -#endif -#endif - -#ifndef HAVE_GETPAGESIZE - -#include - -#ifdef EXEC_PAGESIZE -#define getpagesize() EXEC_PAGESIZE -#else -#ifdef NBPG -#define getpagesize() NBPG * CLSIZE -#ifndef CLSIZE -#define CLSIZE 1 -#endif /* no CLSIZE */ -#else /* no NBPG */ -#define getpagesize() NBPC -#endif /* no NBPG */ -#endif /* no EXEC_PAGESIZE */ - -#endif /* not HAVE_GETPAGESIZE */ - diff --git a/gnu/usr.bin/gdb/infcmd.c b/gnu/usr.bin/gdb/infcmd.c deleted file mode 100644 index f273e634779a..000000000000 --- a/gnu/usr.bin/gdb/infcmd.c +++ /dev/null @@ -1,1199 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)infcmd.c 6.4 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: infcmd.c,v 1.3 1993/12/07 19:58:30 mycroft Exp $"; -#endif /* not lint */ - -/* Memory-access and commands for inferior process, for GDB. - Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "inferior.h" -#include "environ.h" -#include "value.h" - -#include -#include -#include -#include - -#define ERROR_NO_INFERIOR \ - if (inferior_pid == 0) error ("The program is not being run."); - -/* String containing arguments to give to the program, - with a space added at the front. Just a space means no args. */ - -static char *inferior_args; - -/* File name for default use for standard in/out in the inferior. */ - -char *inferior_io_terminal; - -/* Pid of our debugged inferior, or 0 if no inferior now. */ - -int inferior_pid; - -/* Last signal that the inferior received (why it stopped). */ - -int stop_signal; - -/* Address at which inferior stopped. */ - -CORE_ADDR stop_pc; - -/* Stack frame when program stopped. */ - -FRAME_ADDR stop_frame_address; - -/* Number of breakpoint it stopped at, or 0 if none. */ - -int stop_breakpoint; - -/* Nonzero if stopped due to a step command. */ - -int stop_step; - -/* Nonzero if stopped due to completion of a stack dummy routine. */ - -int stop_stack_dummy; - -/* Nonzero if stopped due to a random (unexpected) signal in inferior - process. */ - -int stopped_by_random_signal; - -/* Range to single step within. - If this is nonzero, respond to a single-step signal - by continuing to step if the pc is in this range. */ - -CORE_ADDR step_range_start; /* Inclusive */ -CORE_ADDR step_range_end; /* Exclusive */ - -/* Stack frame address as of when stepping command was issued. - This is how we know when we step into a subroutine call, - and how to set the frame for the breakpoint used to step out. */ - -FRAME_ADDR step_frame_address; - -/* 1 means step over all subroutine calls. - -1 means step over calls to undebuggable functions. */ - -int step_over_calls; - -/* If stepping, nonzero means step count is > 1 - so don't print frame next time inferior stops - if it stops due to stepping. */ - -int step_multi; - -/* Environment to use for running inferior, - in format described in environ.h. */ - -struct environ *inferior_environ; - -CORE_ADDR read_pc (); -struct command_line *get_breakpoint_commands (); -void breakpoint_clear_ignore_counts (); - - -int -have_inferior_p () -{ - return inferior_pid != 0; -} - -static void -set_args_command (args) - char *args; -{ - free (inferior_args); - if (!args) args = ""; - inferior_args = concat (" ", args, ""); -} - -void -tty_command (file, from_tty) - char *file; - int from_tty; -{ - if (file == 0) - error_no_arg ("terminal name for running target process"); - - inferior_io_terminal = savestring (file, strlen (file)); -} - -static void -run_command (args, from_tty) - char *args; - int from_tty; -{ - extern char **environ; - register int i; - char *exec_file; - char *allargs; - - dont_repeat (); - - if (inferior_pid) - { - extern int inhibit_confirm; - if (!(inhibit_confirm || - query ("The program being debugged has been started already.\n\ -Start it from the beginning? "))) - error ("Program not restarted."); - kill_inferior (); - } - -#if 0 - /* On the other hand, some users want to do - break open - ignore 1 40 - run - So it's not clear what is best. */ - - /* It is confusing to the user for ignore counts to stick around - from previous runs of the inferior. So clear them. */ - breakpoint_clear_ignore_counts (); -#endif - - exec_file = (char *) get_exec_file (1); - - if (remote_debugging) - { - if (from_tty) - { - printf ("Starting program: %s\n", exec_file); - fflush (stdout); - } - } - else - { - if (args) - set_args_command (args); - - if (from_tty) - { - printf ("Starting program: %s%s\n", - exec_file, inferior_args); - fflush (stdout); - } - - allargs = concat ("exec ", exec_file, inferior_args); - inferior_pid = create_inferior (allargs, environ_vector (inferior_environ)); - } - - clear_proceed_status (); - - start_inferior (); -} - -void -cont_command (proc_count_exp, from_tty) - char *proc_count_exp; - int from_tty; -{ - ERROR_NO_INFERIOR; - - clear_proceed_status (); - - /* If have argument, set proceed count of breakpoint we stopped at. */ - - if (stop_breakpoint > 0 && proc_count_exp) - { - set_ignore_count (stop_breakpoint, - parse_and_eval_address (proc_count_exp) - 1, - from_tty); - if (from_tty) - printf (" "); - } - - if (from_tty) - printf ("Continuing.\n"); - - proceed (-1, -1, 0); -} - -/* Step until outside of current statement. */ -static void step_1 (); - -static void -step_command (count_string) -{ - step_1 (0, 0, count_string); -} - -/* Likewise, but skip over subroutine calls as if single instructions. */ - -static void -next_command (count_string) -{ - step_1 (1, 0, count_string); -} - -/* Likewise, but step only one instruction. */ - -static void -stepi_command (count_string) -{ - step_1 (0, 1, count_string); -} - -static void -nexti_command (count_string) -{ - step_1 (1, 1, count_string); -} - -static void -step_1 (skip_subroutines, single_inst, count_string) - int skip_subroutines; - int single_inst; - char *count_string; -{ - register int count = 1; - - ERROR_NO_INFERIOR; - count = count_string ? parse_and_eval_address (count_string) : 1; - - for (; count > 0; count--) - { - clear_proceed_status (); - - step_frame_address = FRAME_FP (get_current_frame ()); - - if (! single_inst) - { - find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end); - if (step_range_end == 0) - { - int misc; - - misc = find_pc_misc_function (stop_pc); - terminal_ours (); - printf ("Current function has no line number information.\n"); - fflush (stdout); - - /* No info or after _etext ("Can't happen") */ - if (misc == -1 || misc == misc_function_count - 1) - error ("No data available on pc function."); - - printf ("Single stepping until function exit.\n"); - fflush (stdout); - - step_range_start = misc_function_vector[misc].address; - step_range_end = misc_function_vector[misc + 1].address; - } - } - else - { - /* Say we are stepping, but stop after one insn whatever it does. - Don't step through subroutine calls even to undebuggable - functions. */ - step_range_start = step_range_end = 1; - if (!skip_subroutines) - step_over_calls = 0; - } - - if (skip_subroutines) - step_over_calls = 1; - - step_multi = (count > 1); - proceed (-1, -1, 1); - if (! stop_step) - break; - } -} - -/* Continue program at specified address. */ - -static void -jump_command (arg, from_tty) - char *arg; - int from_tty; -{ - register CORE_ADDR addr; - struct symtabs_and_lines sals; - struct symtab_and_line sal; - - ERROR_NO_INFERIOR; - - if (!arg) - error_no_arg ("starting address"); - - sals = decode_line_spec_1 (arg, 1); - if (sals.nelts != 1) - { - error ("Unreasonable jump request"); - } - - sal = sals.sals[0]; - free (sals.sals); - - if (sal.symtab == 0 && sal.pc == 0) - error ("No source file has been specified."); - - if (sal.pc == 0) - sal.pc = find_line_pc (sal.symtab, sal.line); - - { - struct symbol *fn = get_frame_function (get_current_frame ()); - struct symbol *sfn = find_pc_function (sal.pc); - if (fn != 0 && sfn != fn - && ! query ("Line %d is not in `%s'. Jump anyway? ", - sal.line, SYMBOL_NAME (fn))) - error ("Not confirmed."); - } - - if (sal.pc == 0) - error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename); - - addr = sal.pc; - - clear_proceed_status (); - - if (from_tty) - printf ("Continuing at 0x%x.\n", addr); - - proceed (addr, 0, 0); -} - -/* Continue program giving it specified signal. */ - -static void -signal_command (signum_exp, from_tty) - char *signum_exp; - int from_tty; -{ - register int signum; - - dont_repeat (); /* Too dangerous. */ - ERROR_NO_INFERIOR; - - if (!signum_exp) - error_no_arg ("signal number"); - - signum = parse_and_eval_address (signum_exp); - - clear_proceed_status (); - - if (from_tty) - printf ("Continuing with signal %d.\n", signum); - - proceed (stop_pc, signum, 0); -} - -/* Execute a "stack dummy", a piece of code stored in the stack - by the debugger to be executed in the inferior. - - To call: first, do PUSH_DUMMY_FRAME. - Then push the contents of the dummy. It should end with a breakpoint insn. - Then call here, passing address at which to start the dummy. - - The contents of all registers are saved before the dummy frame is popped - and copied into the buffer BUFFER. - - The dummy's frame is automatically popped whenever that break is hit. - If that is the first time the program stops, run_stack_dummy - returns to its caller with that frame already gone. - Otherwise, the caller never gets returned to. */ - -/* 4 => return instead of letting the stack dummy run. */ - -static int stack_dummy_testing = 0; - -void -run_stack_dummy (addr, buffer) - CORE_ADDR addr; - REGISTER_TYPE *buffer; -{ - /* Now proceed, having reached the desired place. */ - clear_proceed_status (); -#ifdef notdef - if (stack_dummy_testing & 4) - { - POP_FRAME; - return; - } -#endif - proceed (addr, 0, 0); - - if (!stop_stack_dummy) - error ("Cannot continue previously requested operation."); - - /* On return, the stack dummy has been popped already. */ - - read_register_bytes(0, buffer, REGISTER_BYTES); -} - -/* Proceed until we reach the given line as argument or exit the - function. When called with no argument, proceed until we reach a - different source line with pc greater than our current one or exit - the function. We skip calls in both cases. - - The effect of this command with an argument is identical to setting - a momentary breakpoint at the line specified and executing - "finish". - - Note that eventually this command should probably be changed so - that only source lines are printed out when we hit the breakpoint - we set. I'm going to postpone this until after a hopeful rewrite - of wait_for_inferior and the proceed status code. -- randy */ - -void -until_next_command (arg, from_tty) - char *arg; - int from_tty; -{ - FRAME frame; - CORE_ADDR pc; - struct symbol *func; - struct symtab_and_line sal; - - clear_proceed_status (); - - frame = get_current_frame (); - - /* Step until either exited from this function or greater - than the current line (if in symbolic section) or pc (if - not). */ - - pc = read_pc (); - func = find_pc_function (pc); - - if (!func) - { - int misc_func = find_pc_misc_function (pc); - - if (misc_func != -1) - error ("Execution is not within a known function."); - - step_range_start = misc_function_vector[misc_func].address; - step_range_end = pc; - } - else - { - sal = find_pc_line (pc, 0); - - step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); - step_range_end = sal.end; - } - - step_over_calls = 1; - step_frame_address = FRAME_FP (frame); - - step_multi = 0; /* Only one call to proceed */ - - proceed (-1, -1, 1); -} - -void -until_command (arg, from_tty) - char *arg; - int from_tty; -{ - if (!have_inferior_p ()) - error ("The program is not being run."); - - if (arg) - until_break_command (arg, from_tty); - else - until_next_command (arg, from_tty); -} - -/* "finish": Set a temporary breakpoint at the place - the selected frame will return to, then continue. */ - -static void -finish_command (arg, from_tty) - char *arg; - int from_tty; -{ - struct symtab_and_line sal; - register FRAME frame; - struct frame_info *fi; - register struct symbol *function; - - if (!have_inferior_p ()) - error ("The program is not being run."); - if (arg) - error ("The \"finish\" command does not take any arguments."); - - frame = get_prev_frame (selected_frame); - if (frame == 0) - error ("\"finish\" not meaningful in the outermost frame."); - - clear_proceed_status (); - - fi = get_frame_info (frame); - sal = find_pc_line (fi->pc, 0); - sal.pc = fi->pc; - set_momentary_breakpoint (sal, frame); - - /* Find the function we will return from. */ - - fi = get_frame_info (selected_frame); - function = find_pc_function (fi->pc); - - if (from_tty) - { - printf ("Run till exit from "); - print_selected_frame (); - } - - proceed (-1, -1, 0); - - if (stop_breakpoint == -3 && function != 0) - { - struct type *value_type; - register value val; - CORE_ADDR funcaddr; - extern char registers[]; - - value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function)); - if (!value_type) - fatal ("internal: finish_command: function has no target type"); - - if (TYPE_CODE (value_type) == TYPE_CODE_VOID) - return; - - funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function)); - - val = value_being_returned (value_type, registers, - using_struct_return (function, - funcaddr, - value_type)); - - printf ("Value returned is $%d = ", record_latest_value (val)); - value_print (val, stdout, 0, Val_no_prettyprint); - putchar ('\n'); - } -} - -static void -program_info () -{ - if (inferior_pid == 0) - { - printf ("The program being debugged is not being run.\n"); - return; - } - - printf ("Program being debugged is in process %d, stopped at 0x%x.\n", - inferior_pid, stop_pc); - if (stop_step) - printf ("It stopped after being stepped.\n"); - else if (stop_breakpoint > 0) - printf ("It stopped at breakpoint %d.\n", stop_breakpoint); - else if (stop_signal) - printf ("It stopped with signal %d (%s).\n", - stop_signal, sys_siglist[stop_signal]); - - printf ("\nType \"info stack\" or \"info reg\" for more information.\n"); -} - -static void -environment_info (var) - char *var; -{ - if (var) - { - register char *val = get_in_environ (inferior_environ, var); - if (val) - printf ("%s = %s\n", var, val); - else - printf ("Environment variable \"%s\" not defined.\n", var); - } - else - { - register char **vector = environ_vector (inferior_environ); - while (*vector) - printf ("%s\n", *vector++); - } -} - -static void -set_environment_command (arg) - char *arg; -{ - register char *p, *val, *var; - int nullset = 0; - - if (arg == 0) - error_no_arg ("environment variable and value"); - - /* Find seperation between variable name and value */ - p = (char *) index (arg, '='); - val = (char *) index (arg, ' '); - - if (p != 0 && val != 0) - { - /* We have both a space and an equals. If the space is before the - equals and the only thing between the two is more space, use - the equals */ - if (p > val) - while (*val == ' ') - val++; - - /* Take the smaller of the two. If there was space before the - "=", they will be the same right now. */ - p = arg + min (p - arg, val - arg); - } - else if (val != 0 && p == 0) - p = val; - - if (p == arg) - error_no_arg ("environment variable to set"); - - if (p == 0 || p[1] == 0) - { - nullset = 1; - if (p == 0) - p = arg + strlen (arg); /* So that savestring below will work */ - } - else - { - /* Not setting variable value to null */ - val = p + 1; - while (*val == ' ' || *val == '\t') - val++; - } - - while (p != arg && (p[-1] == ' ' || p[-1] == '\t')) p--; - - var = savestring (arg, p - arg); - if (nullset) - { - printf ("Setting environment variable \"%s\" to null value.\n", var); - set_in_environ (inferior_environ, var, ""); - } - else - set_in_environ (inferior_environ, var, val); - free (var); -} - -static void -unset_environment_command (var, from_tty) - char *var; - int from_tty; -{ - if (var == 0) - /* If there is no argument, delete all environment variables. - Ask for confirmation if reading from the terminal. */ - if (!from_tty || query ("Delete all environment variables? ")) - { - free_environ (inferior_environ); - inferior_environ = make_environ (); - } - - unset_in_environ (inferior_environ, var); -} - -/* Read an integer from debugged memory, given address and number of bytes. */ - -long -read_memory_integer (memaddr, len) - CORE_ADDR memaddr; - int len; -{ - char cbuf; - short sbuf; - int ibuf; - long lbuf; - int result_err; - - if (len == sizeof (char)) - { - result_err = read_memory (memaddr, &cbuf, len); - if (result_err) - error ("Error reading memory address 0x%x: %s (%d).", - memaddr, (result_err < sys_nerr ? - sys_errlist[result_err] : - "uknown error"), result_err); - return cbuf; - } - if (len == sizeof (short)) - { - result_err = read_memory (memaddr, &sbuf, len); - if (result_err) - error ("Error reading memory address 0x%x: %s (%d).", - memaddr, (result_err < sys_nerr ? - sys_errlist[result_err] : - "uknown error"), result_err); - return sbuf; - } - if (len == sizeof (int)) - { - result_err = read_memory (memaddr, &ibuf, len); - if (result_err) - error ("Error reading memory address 0x%x: %s (%d).", - memaddr, (result_err < sys_nerr ? - sys_errlist[result_err] : - "uknown error"), result_err); - return ibuf; - } - if (len == sizeof (lbuf)) - { - result_err = read_memory (memaddr, &lbuf, len); - if (result_err) - error ("Error reading memory address 0x%x: %s (%d).", - memaddr, (result_err < sys_nerr ? - sys_errlist[result_err] : - "uknown error"), result_err); - return lbuf; - } - error ("Cannot handle integers of %d bytes.", len); -} - -CORE_ADDR -read_pc () -{ - return (CORE_ADDR) read_register (PC_REGNUM); -} - -void -write_pc (val) - CORE_ADDR val; -{ - write_register (PC_REGNUM, (long) val); -#ifdef NPC_REGNUM - write_register (NPC_REGNUM, (long) val+4); -#endif -} - -char *reg_names[] = REGISTER_NAMES; - -#if !defined (DO_REGISTERS_INFO) -static void -print_one_register(i) - int i; -{ - unsigned char raw_buffer[MAX_REGISTER_RAW_SIZE]; - unsigned char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; - REGISTER_TYPE val; - - /* Get the data in raw format, then convert also to virtual format. */ - read_relative_register_raw_bytes (i, raw_buffer); - REGISTER_CONVERT_TO_VIRTUAL (i, raw_buffer, virtual_buffer); - - fputs_filtered (reg_names[i], stdout); - print_spaces_filtered (15 - strlen (reg_names[i]), stdout); - - /* If virtual format is floating, print it that way. */ - if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT - && ! INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i))) - val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, - stdout, 0, 1, 0, Val_pretty_default); - /* Else if virtual format is too long for printf, - print in hex a byte at a time. */ - else if (REGISTER_VIRTUAL_SIZE (i) > sizeof (long)) - { - register int j; - printf_filtered ("0x"); - for (j = 0; j < REGISTER_VIRTUAL_SIZE (i); j++) - printf_filtered ("%02x", virtual_buffer[j]); - } - /* Else print as integer in hex and in decimal. */ - else - { - long val; - - bcopy (virtual_buffer, &val, sizeof (long)); - if (val == 0) - printf_filtered ("0"); - else - printf_filtered ("0x%08x %d", val, val); - } - - /* If register has different raw and virtual formats, - print the raw format in hex now. */ - - if (REGISTER_CONVERTIBLE (i)) - { - register int j; - - printf_filtered (" (raw 0x"); - for (j = 0; j < REGISTER_RAW_SIZE (i); j++) - printf_filtered ("%02x", raw_buffer[j]); - printf_filtered (")"); - } - printf_filtered ("\n"); -} - - -/* Print out the machine register regnum. If regnum is -1, - print all registers. - For most machines, having all_registers_info() print the - register(s) one per line is good enough. If a different format - is required, (eg, for SPARC or Pyramid 90x, which both have - lots of regs), or there is an existing convention for showing - all the registers, define the macro DO_REGISTERS_INFO(regnum) - to provide that format. */ -static void -do_registers_info (regnum, fpregs) - int regnum; - int fpregs; -{ - register int i; - - if (regnum >= 0) { - print_one_register(regnum); - return; - } -#ifdef notdef - printf_filtered ( -"Register Contents (relative to selected stack frame)\n\n"); -#endif - for (i = 0; i < NUM_REGS; i++) - if (TYPE_CODE(REGISTER_VIRTUAL_TYPE(i)) != TYPE_CODE_FLT || - fpregs) - print_one_register(i); -} -#endif /* no DO_REGISTERS_INFO. */ - -static void -registers_info (addr_exp, fpregs) - char *addr_exp; - int fpregs; -{ - int regnum; - - if (!have_inferior_p () && !have_core_file_p ()) - error ("No inferior or core file"); - - if (addr_exp) - { - if (*addr_exp >= '0' && *addr_exp <= '9') - regnum = atoi (addr_exp); - else - { - register char *p = addr_exp; - if (p[0] == '$') - p++; - for (regnum = 0; regnum < NUM_REGS; regnum++) - if (!strcmp (p, reg_names[regnum])) - break; - if (regnum == NUM_REGS) - error ("%s: invalid register name.", addr_exp); - } - } - else - regnum = -1; - -#ifdef DO_REGISTERS_INFO - DO_REGISTERS_INFO(regnum); -#else - do_registers_info(regnum, fpregs); -#endif -} - -static void -all_registers_info (addr_exp) - char *addr_exp; -{ - registers_info(addr_exp, 1); -} - -static void -nofp_registers_info (addr_exp) - char *addr_exp; -{ - registers_info(addr_exp, 0); -} - - -#ifdef ATTACH_DETACH -#define PROCESS_ATTACH_ALLOWED 1 -#else -#define PROCESS_ATTACH_ALLOWED 0 -#endif -/* - * TODO: - * Should save/restore the tty state since it might be that the - * program to be debugged was started on this tty and it wants - * the tty in some state other than what we want. If it's running - * on another terminal or without a terminal, then saving and - * restoring the tty state is a harmless no-op. - * This only needs to be done if we are attaching to a process. - */ - -/* - * attach_command -- - * takes a program started up outside of gdb and ``attaches'' to it. - * This stops it cold in its tracks and allows us to start tracing it. - * For this to work, we must be able to send the process a - * signal and we must have the same effective uid as the program. - */ -static void -attach_command (args, from_tty) - char *args; - int from_tty; -{ - char *exec_file; - int pid; - int remote = 0; - - dont_repeat(); - - if (!args) - error_no_arg ("process-id or device file to attach"); - - while (*args == ' ' || *args == '\t') args++; - - if (args[0] < '0' || args[0] > '9') - remote = 1; - else -#ifndef ATTACH_DETACH - error ("Can't attach to a process on this machine."); -#else - pid = atoi (args); -#endif - - if (inferior_pid) - { - if (query ("A program is being debugged already. Kill it? ")) - kill_inferior (); - else - error ("Inferior not killed."); - } - - exec_file = (char *) get_exec_file (1); - - if (from_tty) - { - if (remote) - printf ("Attaching remote machine\n"); - else - printf ("Attaching program: %s pid %d\n", - exec_file, pid); - fflush (stdout); - } - - if (remote) - { - remote_open (args, from_tty); - start_remote (); - } -#ifdef ATTACH_DETACH - else - attach_program (pid); -#endif -} - -/* - * detach_command -- - * takes a program previously attached to and detaches it. - * The program resumes execution and will no longer stop - * on signals, etc. We better not have left any breakpoints - * in the program or it'll die when it hits one. For this - * to work, it may be necessary for the process to have been - * previously attached. It *might* work if the program was - * started via the normal ptrace (PTRACE_TRACEME). - */ - -static void -detach_command (args, from_tty) - char *args; - int from_tty; -{ - int signal = 0; - -#ifdef ATTACH_DETACH - if (inferior_pid && !remote_debugging) - { - if (from_tty) - { - char *exec_file = (char *)get_exec_file (0); - if (exec_file == 0) - exec_file = ""; - printf ("Detaching program: %s pid %d\n", - exec_file, inferior_pid); - fflush (stdout); - } - if (args) - signal = atoi (args); - - detach (signal); - inferior_pid = 0; - } - else -#endif - { - if (!remote_debugging) - error ("Not currently attached to subsidiary or remote process."); - - if (args) - error ("Argument given to \"detach\" when remotely debugging."); - - inferior_pid = 0; - remote_close (from_tty); - } -} - -/* ARGSUSED */ -static void -float_info (addr_exp) - char *addr_exp; -{ -#ifdef FLOAT_INFO - FLOAT_INFO; -#else - printf ("No floating point info available for this processor.\n"); -#endif -} - -extern struct cmd_list_element *setlist, *deletelist; - -void -_initialize_infcmd () -{ - add_com ("tty", class_run, tty_command, - "Set terminal for future runs of program being debugged."); - - add_cmd ("args", class_run, set_args_command, - "Specify arguments to give program being debugged when it is started.\n\ -Follow this command with any number of args, to be passed to the program.", - &setlist); - - add_info ("environment", environment_info, - "The environment to give the program, or one variable's value.\n\ -With an argument VAR, prints the value of environment variable VAR to\n\ -give the program being debugged. With no arguments, prints the entire\n\ -environment to be given to the program."); - - add_cmd ("environment", class_run, unset_environment_command, - "Cancel environment variable VAR for the program.\n\ -This does not affect the program until the next \"run\" command.", - &deletelist); - - add_cmd ("environment", class_run, set_environment_command, - "Set environment variable value to give the program.\n\ -Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\ -VALUES of environment variables are uninterpreted strings.\n\ -This does not affect the program until the next \"run\" command.", - &setlist); - -#ifdef ATTACH_DETACH - add_com ("attach", class_run, attach_command, - "Attach to a process that was started up outside of GDB.\n\ -This command may take as argument a process id or a device file.\n\ -For a process id, you must have permission to send the process a signal,\n\ -and it must have the same effective uid as the debugger.\n\ -For a device file, the file must be a connection to a remote debug server.\n\n\ -Before using \"attach\", you must use the \"exec-file\" command\n\ -to specify the program running in the process,\n\ -and the \"symbol-file\" command to load its symbol table."); -#else - add_com ("attach", class_run, attach_command, - "Attach to a process that was started up outside of GDB.\n\ -This commands takes as an argument the name of a device file.\n\ -This file must be a connection to a remote debug server.\n\n\ -Before using \"attach\", you must use the \"exec-file\" command\n\ -to specify the program running in the process,\n\ -and the \"symbol-file\" command to load its symbol table."); -#endif - add_com ("detach", class_run, detach_command, - "Detach the process previously attached.\n\ -The process is no longer traced and continues its execution."); - - add_com ("signal", class_run, signal_command, - "Continue program giving it signal number SIGNUMBER."); - - add_com ("stepi", class_run, stepi_command, - "Step one instruction exactly.\n\ -Argument N means do this N times (or till program stops for another reason)."); - add_com_alias ("si", "stepi", class_alias, 0); - - add_com ("nexti", class_run, nexti_command, - "Step one instruction, but proceed through subroutine calls.\n\ -Argument N means do this N times (or till program stops for another reason)."); - add_com_alias ("ni", "nexti", class_alias, 0); - - add_com ("finish", class_run, finish_command, - "Execute until selected stack frame returns.\n\ -Upon return, the value returned is printed and put in the value history."); - - add_com ("next", class_run, next_command, - "Step program, proceeding through subroutine calls.\n\ -Like the \"step\" command as long as subroutine calls do not happen;\n\ -when they do, the call is treated as one instruction.\n\ -Argument N means do this N times (or till program stops for another reason)."); - add_com_alias ("n", "next", class_run, 1); - - add_com ("step", class_run, step_command, - "Step program until it reaches a different source line.\n\ -Argument N means do this N times (or till program stops for another reason)."); - add_com_alias ("s", "step", class_run, 1); - - add_com ("until", class_run, until_command, - "Execute until the program reaches a source line greater than the current\n\ -or a specified line or address or function (same args as break command).\n\ -Execution will also stop upon exit from the current stack frame."); - add_com_alias ("u", "until", class_run, 1); - - add_com ("jump", class_run, jump_command, - "Continue program being debugged at specified line or address.\n\ -Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\ -for an address to start at."); - - add_com ("cont", class_run, cont_command, - "Continue program being debugged, after signal or breakpoint.\n\ -If proceeding from breakpoint, a number N may be used as an argument:\n\ -then the same breakpoint won't break until the Nth time it is reached."); - add_com_alias ("c", "cont", class_run, 1); - - add_com ("run", class_run, run_command, - "Start debugged program. You may specify arguments to give it.\n\ -Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\ -Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\ -With no arguments, uses arguments last specified (with \"run\" or \"set args\".\n\ -To cancel previous arguments and run with no arguments,\n\ -use \"set args\" without arguments."); - add_com_alias ("r", "run", class_run, 1); - - add_info ("registers", nofp_registers_info, - "List of registers and their contents, for selected stack frame.\n\ -Register name as argument means describe only that register.\n\ -(Doesn't display floating point registers; use 'info all-registers'.)\n"); - - add_info ("all-registers", all_registers_info, - "List of registers and their contents, for selected stack frame.\n\ -Register name as argument means describe only that register."); - - add_info ("program", program_info, - "Execution status of the program."); - - add_info ("float", float_info, - "Print the status of the floating point unit\n"); - - inferior_args = savestring (" ", 1); /* By default, no args. */ - inferior_environ = make_environ (); - init_environ (inferior_environ); -} - diff --git a/gnu/usr.bin/gdb/inferior.h b/gnu/usr.bin/gdb/inferior.h deleted file mode 100644 index ec2375e02f52..000000000000 --- a/gnu/usr.bin/gdb/inferior.h +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - * - * from: @(#)inferior.h 6.3 (Berkeley) 5/8/91 - * $Id: inferior.h,v 1.2 1993/08/01 18:47:55 mycroft Exp $ - */ - -/* Variables that describe the inferior process running under GDB: - Where it is, why it stopped, and how to step it. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Structure in which to save the status of the inferior. Save - * through "save_inferior_status", restore through - * "restore_inferior_status". - * This pair of routines should be called around any transfer of - * control to the inferior which you don't want showing up in your - * control variables. - */ -struct inferior_status { - int pc_changed; - int stop_signal; - int stop_pc; - int stop_frame_address; - int stop_breakpoint; - int stop_step; - int stop_stack_dummy; - int stopped_by_random_signal; - int trap_expected; - CORE_ADDR step_range_start; - CORE_ADDR step_range_end; - FRAME_ADDR step_frame_address; - int step_over_calls; - CORE_ADDR step_resume_break_address; - int stop_after_trap; - int stop_after_attach; - FRAME_ADDR selected_frame_address; - int selected_level; - struct command_line *breakpoint_commands; - char register_context[REGISTER_BYTES]; - int restore_stack_info; -}; - -void save_inferior_status (), restore_inferior_status (); - -/* File name for default use for standard in/out in the inferior. */ - -extern char *inferior_io_terminal; - -/* Pid of our debugged inferior, or 0 if no inferior now. */ - -extern int inferior_pid; - -/* Nonzero if debugging a remote machine via a serial link or ethernet. */ -extern int remote_debugging; - -/* Routines for use in remote debugging. Documented in remote.c. */ -int remote_read_inferior_memory (); -int remote_write_inferior_memory (); - -/* Last signal that the inferior received (why it stopped). */ - -extern int stop_signal; - -/* Address at which inferior stopped. */ - -extern CORE_ADDR stop_pc; - -/* Stack frame when program stopped. */ - -extern FRAME_ADDR stop_frame_address; - -/* Number of breakpoint it stopped at, or 0 if none. */ - -extern int stop_breakpoint; - -/* Nonzero if stopped due to a step command. */ - -extern int stop_step; - -/* Nonzero if stopped due to completion of a stack dummy routine. */ - -extern int stop_stack_dummy; - -/* Nonzero if program stopped due to a random (unexpected) signal in - inferior process. */ - -extern int stopped_by_random_signal; - -/* Range to single step within. - If this is nonzero, respond to a single-step signal - by continuing to step if the pc is in this range. */ - -extern CORE_ADDR step_range_start; /* Inclusive */ -extern CORE_ADDR step_range_end; /* Exclusive */ - -/* Stack frame address as of when stepping command was issued. - This is how we know when we step into a subroutine call, - and how to set the frame for the breakpoint used to step out. */ - -extern FRAME_ADDR step_frame_address; - -/* 1 means step over all subroutine calls. - -1 means step over calls to undebuggable functions. */ - -extern int step_over_calls; - -/* If stepping, nonzero means step count is > 1 - so don't print frame next time inferior stops - if it stops due to stepping. */ - -extern int step_multi; - -/* Save register contents here when about to pop a stack dummy frame. */ - -extern char stop_registers[REGISTER_BYTES]; - -/* Nonzero if pc has been changed by the debugger - since the inferior stopped. */ - -extern int pc_changed; - -long read_memory_integer (); diff --git a/gnu/usr.bin/gdb/inflow.c b/gnu/usr.bin/gdb/inflow.c deleted file mode 100644 index a8a3f4b5bc7a..000000000000 --- a/gnu/usr.bin/gdb/inflow.c +++ /dev/null @@ -1,566 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)inflow.c 6.5 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: inflow.c,v 1.3 1993/12/07 19:58:32 mycroft Exp $"; -#endif /* not lint */ - -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#ifdef USG -#include -#endif - -/* Some USG-esque systems (some of which are BSD-esque enough so that USG - is not defined) want this header, and it won't do any harm. */ -#include - -#include -#include -#include -#include - -#ifdef HAVE_TERMIO -#include -#undef TIOCGETP -#define TIOCGETP TCGETA -#undef TIOCSETN -#define TIOCSETN TCSETA -#undef TIOCSETP -#define TIOCSETP TCSETAF -#define TERMINAL struct termio -#else -#include -#include -#include -#define TERMINAL struct sgttyb -#endif - -#ifdef SET_STACK_LIMIT_HUGE -#include -#include -extern int original_stack_limit; -#endif /* SET_STACK_LIMIT_HUGE */ - -/* Nonzero if we are debugging an attached outside process - rather than an inferior. */ - -int attach_flag; - - -/* Record terminal status separately for debugger and inferior. */ - -static TERMINAL sg_inferior; -static TERMINAL sg_ours; - -static int tflags_inferior; -static int tflags_ours; - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) -static struct tchars tc_inferior; -static struct tchars tc_ours; -#endif - -#ifdef TIOCGLTC -static struct ltchars ltc_inferior; -static struct ltchars ltc_ours; -#endif - -#ifdef TIOCLGET -static int lmode_inferior; -static int lmode_ours; -#endif - -#ifdef TIOCGPGRP -static int pgrp_inferior; -static int pgrp_ours; -#else -static int (*sigint_ours) (); -static int (*sigquit_ours) (); -#endif /* TIOCGPGRP */ - -/* Copy of inferior_io_terminal when inferior was last started. */ -static char *inferior_thisrun_terminal; - -static void terminal_ours_1 (); - -/* Nonzero if our terminal settings are in effect. - Zero if the inferior's settings are in effect. */ -static int terminal_is_ours; - -/* Initialize the terminal settings we record for the inferior, - before we actually run the inferior. */ - -void -terminal_init_inferior () -{ - if (remote_debugging) - return; - - sg_inferior = sg_ours; - tflags_inferior = tflags_ours; - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - tc_inferior = tc_ours; -#endif - -#ifdef TIOCGLTC - ltc_inferior = ltc_ours; -#endif - -#ifdef TIOCLGET - lmode_inferior = lmode_ours; -#endif - -#ifdef TIOCGPGRP - pgrp_inferior = inferior_pid; -#endif /* TIOCGPGRP */ - - terminal_is_ours = 1; -} - -/* Put the inferior's terminal settings into effect. - This is preparation for starting or resuming the inferior. */ - -void -terminal_inferior () -{ - if (remote_debugging) - return; - - if (terminal_is_ours) /* && inferior_thisrun_terminal == 0) */ - { - fcntl (0, F_SETFL, tflags_inferior); - fcntl (0, F_SETFL, tflags_inferior); - ioctl (0, TIOCSETN, &sg_inferior); - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - ioctl (0, TIOCSETC, &tc_inferior); -#endif -#ifdef TIOCGLTC - ioctl (0, TIOCSLTC, <c_inferior); -#endif -#ifdef TIOCLGET - ioctl (0, TIOCLSET, &lmode_inferior); -#endif - -#ifdef TIOCGPGRP - ioctl (0, TIOCSPGRP, &pgrp_inferior); -#else - sigint_ours = (int (*) ()) signal (SIGINT, SIG_IGN); - sigquit_ours = (int (*) ()) signal (SIGQUIT, SIG_IGN); -#endif /* TIOCGPGRP */ - } - terminal_is_ours = 0; -} - -/* Put some of our terminal settings into effect, - enough to get proper results from our output, - but do not change into or out of RAW mode - so that no input is discarded. - - After doing this, either terminal_ours or terminal_inferior - should be called to get back to a normal state of affairs. */ - -void -terminal_ours_for_output () -{ - if (remote_debugging) - return; - - terminal_ours_1 (1); -} - -/* Put our terminal settings into effect. - First record the inferior's terminal settings - so they can be restored properly later. */ - -void -terminal_ours () -{ - if (remote_debugging) - return; - - terminal_ours_1 (0); -} - -static void -terminal_ours_1 (output_only) - int output_only; -{ -#ifdef TIOCGPGRP - /* Ignore this signal since it will happen when we try to set the pgrp. */ - void (*osigttou) (); -#endif /* TIOCGPGRP */ - - if (!terminal_is_ours) /* && inferior_thisrun_terminal == 0) */ - { - terminal_is_ours = 1; - -#ifdef TIOCGPGRP - osigttou = signal (SIGTTOU, SIG_IGN); - - ioctl (0, TIOCGPGRP, &pgrp_inferior); - ioctl (0, TIOCSPGRP, &pgrp_ours); - - signal (SIGTTOU, osigttou); -#else - signal (SIGINT, sigint_ours); - signal (SIGQUIT, sigquit_ours); -#endif /* TIOCGPGRP */ - - tflags_inferior = fcntl (0, F_GETFL, 0); - ioctl (0, TIOCGETP, &sg_inferior); - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - ioctl (0, TIOCGETC, &tc_inferior); -#endif -#ifdef TIOCGLTC - ioctl (0, TIOCGLTC, <c_inferior); -#endif -#ifdef TIOCLGET - ioctl (0, TIOCLGET, &lmode_inferior); -#endif - } - -#ifdef HAVE_TERMIO - sg_ours.c_lflag |= ICANON; - if (output_only && !(sg_inferior.c_lflag & ICANON)) - sg_ours.c_lflag &= ~ICANON; -#else /* not HAVE_TERMIO */ - sg_ours.sg_flags &= ~RAW & ~CBREAK; - if (output_only) - sg_ours.sg_flags |= (RAW | CBREAK) & sg_inferior.sg_flags; -#endif /* not HAVE_TERMIO */ - - fcntl (0, F_SETFL, tflags_ours); - fcntl (0, F_SETFL, tflags_ours); - ioctl (0, TIOCSETN, &sg_ours); - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - ioctl (0, TIOCSETC, &tc_ours); -#endif -#ifdef TIOCGLTC - ioctl (0, TIOCSLTC, <c_ours); -#endif -#ifdef TIOCLGET - ioctl (0, TIOCLSET, &lmode_ours); -#endif - -#ifdef HAVE_TERMIO - sg_ours.c_lflag |= ICANON; -#else /* not HAVE_TERMIO */ - sg_ours.sg_flags &= ~RAW & ~CBREAK; -#endif /* not HAVE_TERMIO */ -} - -static void -term_status_command () -{ - register int i; - - if (remote_debugging) - { - printf_filtered ("No terminal status when remote debugging.\n"); - return; - } - - printf_filtered ("Inferior's terminal status (currently saved by GDB):\n"); - -#ifdef HAVE_TERMIO - - printf_filtered ("fcntl flags = 0x%x, c_iflag = 0x%x, c_oflag = 0x%x,\n", - tflags_inferior, sg_inferior.c_iflag, sg_inferior.c_oflag); - printf_filtered ("c_cflag = 0x%x, c_lflag = 0x%x, c_line = 0x%x.\n", - sg_inferior.c_cflag, sg_inferior.c_lflag, sg_inferior.c_line); - printf_filtered ("c_cc: "); - for (i = 0; (i < NCC); i += 1) - printf_filtered ("0x%x ", sg_inferior.c_cc[i]); - printf_filtered ("\n"); - -#else /* not HAVE_TERMIO */ - - printf_filtered ("fcntl flags = 0x%x, sgttyb.sg_flags = 0x%x, owner pid = %d.\n", - tflags_inferior, sg_inferior.sg_flags, pgrp_inferior); - -#endif /* not HAVE_TERMIO */ - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - printf_filtered ("tchars: "); - for (i = 0; i < sizeof (struct tchars); i++) - printf_filtered ("0x%x ", ((char *)&tc_inferior)[i]); - printf_filtered ("\n"); -#endif - -#ifdef TIOCGLTC - printf_filtered ("ltchars: "); - for (i = 0; i < sizeof (struct ltchars); i++) - printf_filtered ("0x%x ", ((char *)<c_inferior)[i]); - printf_filtered ("\n"); - ioctl (0, TIOCSLTC, <c_ours); -#endif - -#ifdef TIOCLGET - printf_filtered ("lmode: %x\n", lmode_inferior); -#endif -} - -static void -new_tty (ttyname) - char *ttyname; -{ - register int tty; - register int fd; - -#ifdef TIOCNOTTY - /* Disconnect the child process from our controlling terminal. */ - tty = open("/dev/tty", O_RDWR); - if (tty > 0) - { - ioctl(tty, TIOCNOTTY, 0); - close(tty); - } -#endif - - /* Now open the specified new terminal. */ - - tty = open(ttyname, O_RDWR); - if (tty == -1) - _exit(1); - - /* Avoid use of dup2; doesn't exist on all systems. */ - if (tty != 0) - { close (0); dup (tty); } - if (tty != 1) - { close (1); dup (tty); } - if (tty != 2) - { close (2); dup (tty); } - if (tty > 2) - close(tty); -} - -/* Start an inferior process and returns its pid. - ALLARGS is a string containing shell command to run the program. - ENV is the environment vector to pass. */ - -#ifndef SHELL_FILE -#define SHELL_FILE "/bin/sh" -#endif - -int -create_inferior (allargs, env) - char *allargs; - char **env; -{ - int pid; - char *shell_command; - - /* If desired, concat something onto the front of ALLARGS. - SHELL_COMMAND is the result. */ -#ifdef SHELL_COMMAND_CONCAT - shell_command = (char *) alloca (strlen (SHELL_COMMAND_CONCAT) + strlen (allargs) + 1); - strcpy (shell_command, SHELL_COMMAND_CONCAT); - strcat (shell_command, allargs); -#else - shell_command = allargs; -#endif - - /* exec is said to fail if the executable is open. */ - close_exec_file (); - -#if defined(USG) && !defined(HAVE_VFORK) - pid = fork (); -#else - pid = vfork (); -#endif - - if (pid < 0) - perror_with_name ("vfork"); - - if (pid == 0) - { -#ifdef TIOCGPGRP - /* Run inferior in a separate process group. */ - setpgrp (getpid (), getpid ()); -#endif /* TIOCGPGRP */ - -#ifdef SET_STACK_LIMIT_HUGE - /* Reset the stack limit back to what it was. */ - { - struct rlimit rlim; - - getrlimit (RLIMIT_STACK, &rlim); - rlim.rlim_cur = original_stack_limit; - setrlimit (RLIMIT_STACK, &rlim); - } -#endif /* SET_STACK_LIMIT_HUGE */ - - - inferior_thisrun_terminal = inferior_io_terminal; - if (inferior_io_terminal != 0) - new_tty (inferior_io_terminal); - -/* It seems that changing the signal handlers for the inferior after - a vfork also changes them for the superior. See comments in - initialize_signals for how we get the right signal handlers - for the inferior. */ -/* Not needed on Sun, at least, and loses there - because it clobbers the superior. */ -/*??? signal (SIGQUIT, SIG_DFL); - signal (SIGINT, SIG_DFL); */ - - call_ptrace (0); - execle (SHELL_FILE, "sh", "-c", shell_command, 0, env); - - fprintf (stderr, "Cannot exec %s: %s.\n", SHELL_FILE, - errno < sys_nerr ? sys_errlist[errno] : "unknown error"); - fflush (stderr); - _exit (0177); - } - -#ifdef TIOCGPGRP - /* Avoid race with TIOCSPGRP: guarantee that inferior's pgrp exists. */ - setpgrp (pid, pid); -#endif /* TIOCGPGRP */ - -#ifdef CREATE_INFERIOR_HOOK - CREATE_INFERIOR_HOOK (pid); -#endif - return pid; -} - -/* Kill the inferior process. Make us have no inferior. */ - -static void -kill_command () -{ - if (remote_debugging) - { - inferior_pid = 0; - return; - } - if (inferior_pid == 0) - error ("The program is not being run."); - if (!query ("Kill the inferior process? ")) - error ("Not confirmed."); - kill_inferior (); -} - -void -inferior_died () -{ - inferior_pid = 0; - attach_flag = 0; - mark_breakpoints_out (); - select_frame ((FRAME) 0, -1); - reopen_exec_file (); - if (have_core_file_p ()) - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - else - set_current_frame (0); -} - -#if 0 -/* This function is just for testing, and on some systems (Sony NewsOS - 3.2) also includes which leads to errors - (since on this system at least sys/time.h is not protected against - multiple inclusion). */ -static void -try_writing_regs_command () -{ - register int i; - register int value; - extern int errno; - - if (inferior_pid == 0) - error ("There is no inferior process now."); - - /* A Sun 3/50 or 3/60 (at least) running SunOS 4.0.3 will have a - kernel panic if we try to write past the end of the user area. - Presumably Sun will fix this bug (it has been reported), but it - is tacky to crash the system, so at least on SunOS4 we need to - stop writing when we hit the end of the user area. */ - for (i = 0; i < sizeof (struct user); i += 2) - { - QUIT; - errno = 0; - value = call_ptrace (3, inferior_pid, i, 0); - call_ptrace (6, inferior_pid, i, value); - if (errno == 0) - { - printf (" Succeeded with address 0x%x; value 0x%x (%d).\n", - i, value, value); - } - else if ((i & 0377) == 0) - printf (" Failed at 0x%x.\n", i); - } -} -#endif - -void -_initialize_inflow () -{ - add_com ("term-status", class_obscure, term_status_command, - "Print info on inferior's saved terminal status."); - -#if 0 - add_com ("try-writing-regs", class_obscure, try_writing_regs_command, - "Try writing all locations in inferior's system block.\n\ -Report which ones can be written."); -#endif - - add_com ("kill", class_run, kill_command, - "Kill execution of program being debugged."); - - inferior_pid = 0; - - ioctl (0, TIOCGETP, &sg_ours); - tflags_ours = fcntl (0, F_GETFL, 0); - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - ioctl (0, TIOCGETC, &tc_ours); -#endif -#ifdef TIOCGLTC - ioctl (0, TIOCGLTC, <c_ours); -#endif -#ifdef TIOCLGET - ioctl (0, TIOCLGET, &lmode_ours); -#endif - -#ifdef TIOCGPGRP - ioctl (0, TIOCGPGRP, &pgrp_ours); -#endif /* TIOCGPGRP */ - - terminal_is_ours = 1; -} - diff --git a/gnu/usr.bin/gdb/infrun.c b/gnu/usr.bin/gdb/infrun.c deleted file mode 100644 index d0f910466214..000000000000 --- a/gnu/usr.bin/gdb/infrun.c +++ /dev/null @@ -1,1459 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)infrun.c 6.4 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: infrun.c,v 1.3 1994/01/28 02:17:44 mycroft Exp $"; -#endif /* not lint */ - -/* Start and stop the inferior process, for GDB. - Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Notes on the algorithm used in wait_for_inferior to determine if we - just did a subroutine call when stepping. We have the following - information at that point: - - Current and previous (just before this step) pc. - Current and previous sp. - Current and previous start of current function. - - If the start's of the functions don't match, then - - a) We did a subroutine call. - - In this case, the pc will be at the beginning of a function. - - b) We did a subroutine return. - - Otherwise. - - c) We did a longjmp. - - If we did a longjump, we were doing "nexti", since a next would - have attempted to skip over the assembly language routine in which - the longjmp is coded and would have simply been the equivalent of a - continue. I consider this ok behaivior. We'd like one of two - things to happen if we are doing a nexti through the longjmp() - routine: 1) It behaves as a stepi, or 2) It acts like a continue as - above. Given that this is a special case, and that anybody who - thinks that the concept of sub calls is meaningful in the context - of a longjmp, I'll take either one. Let's see what happens. - - Acts like a subroutine return. I can handle that with no problem - at all. - - -->So: If the current and previous beginnings of the current - function don't match, *and* the pc is at the start of a function, - we've done a subroutine call. If the pc is not at the start of a - function, we *didn't* do a subroutine call. - - -->If the beginnings of the current and previous function do match, - either: - - a) We just did a recursive call. - - In this case, we would be at the very beginning of a - function and 1) it will have a prologue (don't jump to - before prologue, or 2) (we assume here that it doesn't have - a prologue) there will have been a change in the stack - pointer over the last instruction. (Ie. it's got to put - the saved pc somewhere. The stack is the usual place. In - a recursive call a register is only an option if there's a - prologue to do something with it. This is even true on - register window machines; the prologue sets up the new - window. It might not be true on a register window machine - where the call instruction moved the register window - itself. Hmmm. One would hope that the stack pointer would - also change. If it doesn't, somebody send me a note, and - I'll work out a more general theory. - randy@wheaties.ai.mit.edu). This is true (albeit slipperly - so) on all machines I'm aware of: - - m68k: Call changes stack pointer. Regular jumps don't. - - sparc: Recursive calls must have frames and therefor, - prologues. - - vax: All calls have frames and hence change the - stack pointer. - - b) We did a return from a recursive call. I don't see that we - have either the ability or the need to distinguish this - from an ordinary jump. The stack frame will be printed - when and if the frame pointer changes; if we are in a - function without a frame pointer, it's the users own - lookout. - - c) We did a jump within a function. We assume that this is - true if we didn't do a recursive call. - - d) We are in no-man's land ("I see no symbols here"). We - don't worry about this; it will make calls look like simple - jumps (and the stack frames will be printed when the frame - pointer moves), which is a reasonably non-violent response. - -#if 0 - We skip this; it causes more problems than it's worth. -#ifdef SUN4_COMPILER_FEATURE - We do a special ifdef for the sun 4, forcing it to single step - into calls which don't have prologues. This means that we can't - nexti over leaf nodes, we can probably next over them (since they - won't have debugging symbols, usually), and we can next out of - functions returning structures (with a "call .stret4" at the end). -#endif -#endif -*/ - - - - - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "inferior.h" -#include "wait.h" - -#include - -/* unistd.h is needed to #define X_OK */ -#ifdef USG -#include -#else -#include -#endif - -#ifdef UMAX_PTRACE -#include -#include -#include -#endif /* UMAX_PTRACE */ - -/* Required by . */ -#include -/* Required by , at least on system V. */ -#include -/* Needed by IN_SIGTRAMP on some machines (e.g. vax). */ -#include -/* Needed by IN_SIGTRAMP on some machines (e.g. vax). */ -#include - -extern int errno; - -/* Sigtramp is a routine that the kernel calls (which then calls the - signal handler). On most machines it is a library routine that - is linked into the executable. - - This macro, given a program counter value and the name of the - function in which that PC resides (which can be null if the - name is not known), returns nonzero if the PC and name show - that we are in sigtramp. - - On most machines just see if the name is sigtramp (and if we have - no name, assume we are not in sigtramp). */ -#if !defined (IN_SIGTRAMP) -#define IN_SIGTRAMP(pc, name) \ - name && !strcmp ("_sigtramp", name) -#endif - -/* Tables of how to react to signals; the user sets them. */ - -static char signal_stop[NSIG]; -static char signal_print[NSIG]; -static char signal_program[NSIG]; - -/* Nonzero if breakpoints are now inserted in the inferior. */ - -static int breakpoints_inserted; - -/* Function inferior was in as of last step command. */ - -static struct symbol *step_start_function; - -/* This is the sequence of bytes we insert for a breakpoint. */ - -static char break_insn[] = BREAKPOINT; - -/* Nonzero => address for special breakpoint for resuming stepping. */ - -static CORE_ADDR step_resume_break_address; - -/* Original contents of the byte where the special breakpoint is. */ - -static char step_resume_break_shadow[sizeof break_insn]; - -/* Nonzero means the special breakpoint is a duplicate - so it has not itself been inserted. */ - -static int step_resume_break_duplicate; - -/* Nonzero if we are expecting a trace trap and should proceed from it. - 2 means expecting 2 trace traps and should continue both times. - That occurs when we tell sh to exec the program: we will get - a trap after the exec of sh and a second when the program is exec'd. */ - -static int trap_expected; - -/* Nonzero if the next time we try to continue the inferior, it will - step one instruction and generate a spurious trace trap. - This is used to compensate for a bug in HP-UX. */ - -static int trap_expected_after_continue; - -/* Nonzero means expecting a trace trap - and should stop the inferior and return silently when it happens. */ - -int stop_after_trap; - -/* Nonzero means expecting a trace trap due to attaching to a process. */ - -int stop_after_attach; - -/* Nonzero if pc has been changed by the debugger - since the inferior stopped. */ - -int pc_changed; - -/* Nonzero if debugging a remote machine via a serial link or ethernet. */ - -int remote_debugging; - -/* Nonzero if program stopped due to error trying to insert breakpoints. */ - -static int breakpoints_failed; - -/* Nonzero if inferior is in sh before our program got exec'd. */ - -static int running_in_shell; - -/* Nonzero after stop if current stack frame should be printed. */ - -static int stop_print_frame; - -#ifdef NO_SINGLE_STEP -extern int one_stepped; /* From machine dependent code */ -extern void single_step (); /* Same. */ -#endif /* NO_SINGLE_STEP */ - -static void insert_step_breakpoint (); -static void remove_step_breakpoint (); -static void wait_for_inferior (); -static void normal_stop (); - - -/* Clear out all variables saying what to do when inferior is continued. - First do this, then set the ones you want, then call `proceed'. */ - -void -clear_proceed_status () -{ - trap_expected = 0; - step_range_start = 0; - step_range_end = 0; - step_frame_address = 0; - step_over_calls = -1; - step_resume_break_address = 0; - stop_after_trap = 0; - stop_after_attach = 0; - - /* Discard any remaining commands left by breakpoint we had stopped at. */ - clear_breakpoint_commands (); -} - -/* Basic routine for continuing the program in various fashions. - - ADDR is the address to resume at, or -1 for resume where stopped. - SIGNAL is the signal to give it, or 0 for none, - or -1 for act according to how it stopped. - STEP is nonzero if should trap after one instruction. - -1 means return after that and print nothing. - You should probably set various step_... variables - before calling here, if you are stepping. - - You should call clear_proceed_status before calling proceed. */ - -void -proceed (addr, signal, step) - CORE_ADDR addr; - int signal; - int step; -{ - int oneproc = 0; - - if (step > 0) - step_start_function = find_pc_function (read_pc ()); - if (step < 0) - stop_after_trap = 1; - - if (addr == -1) - { - /* If there is a breakpoint at the address we will resume at, - step one instruction before inserting breakpoints - so that we do not stop right away. */ - - if (!pc_changed && breakpoint_here_p (read_pc ())) - oneproc = 1; - } - else - { - write_register (PC_REGNUM, addr); -#ifdef NPC_REGNUM - write_register (NPC_REGNUM, addr + 4); -#endif - } - - if (trap_expected_after_continue) - { - /* If (step == 0), a trap will be automatically generated after - the first instruction is executed. Force step one - instruction to clear this condition. This should not occur - if step is nonzero, but it is harmless in that case. */ - oneproc = 1; - trap_expected_after_continue = 0; - } - - if (oneproc) - /* We will get a trace trap after one instruction. - Continue it automatically and insert breakpoints then. */ - trap_expected = 1; - else - { - int temp = insert_breakpoints (); - if (temp) - { - print_sys_errmsg ("ptrace", temp); - error ("Cannot insert breakpoints.\n\ -The same program may be running in another process."); - } - breakpoints_inserted = 1; - } - - /* Install inferior's terminal modes. */ - terminal_inferior (); - - if (signal >= 0) - stop_signal = signal; - /* If this signal should not be seen by program, - give it zero. Used for debugging signals. */ - else if (stop_signal < NSIG && !signal_program[stop_signal]) - stop_signal= 0; - - /* Resume inferior. */ - resume (oneproc || step, stop_signal); - - /* Wait for it to stop (if not standalone) - and in any case decode why it stopped, and act accordingly. */ - - wait_for_inferior (); - normal_stop (); -} - -/* Writing the inferior pc as a register calls this function - to inform infrun that the pc has been set in the debugger. */ - -void -writing_pc (val) - CORE_ADDR val; -{ - stop_pc = val; - pc_changed = 1; -} - -/* Start an inferior process for the first time. - Actually it was started by the fork that created it, - but it will have stopped one instruction after execing sh. - Here we must get it up to actual execution of the real program. */ - -void -start_inferior () -{ - /* We will get a trace trap after one instruction. - Continue it automatically. Eventually (after shell does an exec) - it will get another trace trap. Then insert breakpoints and continue. */ - -#ifdef START_INFERIOR_TRAPS_EXPECTED - trap_expected = START_INFERIOR_TRAPS_EXPECTED; -#else - trap_expected = 2; -#endif - - running_in_shell = 0; /* Set to 1 at first SIGTRAP, 0 at second. */ - trap_expected_after_continue = 0; - breakpoints_inserted = 0; - mark_breakpoints_out (); - - /* Set up the "saved terminal modes" of the inferior - based on what modes we are starting it with. */ - terminal_init_inferior (); - - /* Install inferior's terminal modes. */ - terminal_inferior (); - - if (remote_debugging) - { - trap_expected = 0; - fetch_inferior_registers(); - set_current_frame (create_new_frame (read_register (FP_REGNUM), - read_pc ())); - stop_frame_address = FRAME_FP (get_current_frame()); - inferior_pid = 3; - if (insert_breakpoints()) - fatal("Can't insert breakpoints"); - breakpoints_inserted = 1; - proceed(-1, -1, 0); - } - else - { - wait_for_inferior (); - normal_stop (); - } -} - -/* Start or restart remote-debugging of a machine over a serial link. */ - -void -restart_remote () -{ - clear_proceed_status (); - running_in_shell = 0; - trap_expected = 0; - stop_after_attach = 1; - inferior_pid = 3; - wait_for_inferior (); - normal_stop(); -} - -void -start_remote () -{ - breakpoints_inserted = 0; - mark_breakpoints_out (); - restart_remote(); -} - -#ifdef ATTACH_DETACH - -/* Attach to process PID, then initialize for debugging it - and wait for the trace-trap that results from attaching. */ - -void -attach_program (pid) - int pid; -{ - attach (pid); - inferior_pid = pid; - - mark_breakpoints_out (); - terminal_init_inferior (); - clear_proceed_status (); - stop_after_attach = 1; - /*proceed (-1, 0, -2);*/ - terminal_inferior (); - wait_for_inferior (); - normal_stop (); -} -#endif /* ATTACH_DETACH */ - -/* Wait for control to return from inferior to debugger. - If inferior gets a signal, we may decide to start it up again - instead of returning. That is why there is a loop in this function. - When this function actually returns it means the inferior - should be left stopped and GDB should read more commands. */ - -static void -wait_for_inferior () -{ - register int pid; - WAITTYPE w; - CORE_ADDR pc; - int tem; - int another_trap; - int random_signal; - CORE_ADDR stop_sp, prev_sp; - CORE_ADDR prev_func_start, stop_func_start; - char *prev_func_name, *stop_func_name; - CORE_ADDR prologue_pc; - int stop_step_resume_break; - CORE_ADDR step_resume_break_sp; - int newmisc; - int newfun_pc; - struct symtab_and_line sal; - int prev_pc; - extern CORE_ADDR text_end; - int remove_breakpoints_on_following_step = 0; - - prev_pc = read_pc (); - (void) find_pc_partial_function (prev_pc, &prev_func_name, - &prev_func_start); - prev_func_start += FUNCTION_START_OFFSET; - prev_sp = read_register (SP_REGNUM); - - while (1) - { - /* Clean up saved state that will become invalid. */ - pc_changed = 0; - flush_cached_frames (); - - if (remote_debugging) - remote_wait (&w); - else - { - pid = wait (&w); - if (pid != inferior_pid) - continue; - } - - /* See if the process still exists; clean up if it doesn't. */ - if (WIFEXITED (w)) - { - terminal_ours_for_output (); - if (WEXITSTATUS (w)) - printf ("\nProgram exited with code 0%o.\n", WEXITSTATUS (w)); - else - printf ("\nProgram exited normally.\n"); - fflush (stdout); - inferior_died (); -#ifdef NO_SINGLE_STEP - one_stepped = 0; -#endif - stop_print_frame = 0; - break; - } - else if (!WIFSTOPPED (w)) - { - kill_inferior (); - stop_print_frame = 0; - stop_signal = WTERMSIG (w); - terminal_ours_for_output (); - printf ("\nProgram terminated with signal %d, %s\n", - stop_signal, - stop_signal < NSIG - ? sys_siglist[stop_signal] - : "(undocumented)"); - printf ("The inferior process no longer exists.\n"); - fflush (stdout); -#ifdef NO_SINGLE_STEP - one_stepped = 0; -#endif - break; - } - -#ifdef NO_SINGLE_STEP - if (one_stepped) - single_step (0); /* This actually cleans up the ss */ -#endif /* NO_SINGLE_STEP */ - - fetch_inferior_registers (); - stop_pc = read_pc (); - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - - stop_frame_address = FRAME_FP (get_current_frame ()); - stop_sp = read_register (SP_REGNUM); - stop_func_start = 0; - stop_func_name = 0; - /* Don't care about return value; stop_func_start and stop_func_name - will both be 0 if it doesn't work. */ - (void) find_pc_partial_function (stop_pc, &stop_func_name, - &stop_func_start); - stop_func_start += FUNCTION_START_OFFSET; - another_trap = 0; - stop_breakpoint = 0; - stop_step = 0; - stop_stack_dummy = 0; - stop_print_frame = 1; - stop_step_resume_break = 0; - random_signal = 0; - stopped_by_random_signal = 0; - breakpoints_failed = 0; - - /* Look at the cause of the stop, and decide what to do. - The alternatives are: - 1) break; to really stop and return to the debugger, - 2) drop through to start up again - (set another_trap to 1 to single step once) - 3) set random_signal to 1, and the decision between 1 and 2 - will be made according to the signal handling tables. */ - - stop_signal = WSTOPSIG (w); - - /* First, distinguish signals caused by the debugger from signals - that have to do with the program's own actions. - Note that breakpoint insns may cause SIGTRAP or SIGILL - or SIGEMT, depending on the operating system version. - Here we detect when a SIGILL or SIGEMT is really a breakpoint - and change it to SIGTRAP. */ - - if (stop_signal == SIGTRAP - || (breakpoints_inserted && - (stop_signal == SIGILL - || stop_signal == SIGEMT)) - || stop_after_attach) - { - if (stop_signal == SIGTRAP && stop_after_trap) - { - stop_print_frame = 0; - break; - } - if (stop_after_attach) - break; - /* Don't even think about breakpoints - if still running the shell that will exec the program - or if just proceeded over a breakpoint. */ - if (stop_signal == SIGTRAP && trap_expected) - stop_breakpoint = 0; - else - { - /* See if there is a breakpoint at the current PC. */ -#if DECR_PC_AFTER_BREAK - /* Notice the case of stepping through a jump - that leads just after a breakpoint. - Don't confuse that with hitting the breakpoint. - What we check for is that 1) stepping is going on - and 2) the pc before the last insn does not match - the address of the breakpoint before the current pc. */ - if (!(prev_pc != stop_pc - DECR_PC_AFTER_BREAK - && step_range_end && !step_resume_break_address)) -#endif /* DECR_PC_AFTER_BREAK not zero */ - { - /* See if we stopped at the special breakpoint for - stepping over a subroutine call. */ - if (stop_pc - DECR_PC_AFTER_BREAK - == step_resume_break_address) - { - stop_step_resume_break = 1; - if (DECR_PC_AFTER_BREAK) - { - stop_pc -= DECR_PC_AFTER_BREAK; - write_register (PC_REGNUM, stop_pc); - pc_changed = 0; - } - } - else - { - stop_breakpoint = - breakpoint_stop_status (stop_pc, stop_frame_address); - /* Following in case break condition called a - function. */ - stop_print_frame = 1; - if (stop_breakpoint && DECR_PC_AFTER_BREAK) - { - stop_pc -= DECR_PC_AFTER_BREAK; - write_register (PC_REGNUM, stop_pc); -#ifdef NPC_REGNUM - write_register (NPC_REGNUM, stop_pc + 4); -#endif - pc_changed = 0; - } - } - } - } - - if (stop_signal == SIGTRAP) - random_signal - = !(stop_breakpoint || trap_expected - || stop_step_resume_break -#ifndef CANNOT_EXECUTE_STACK - || (stop_sp INNER_THAN stop_pc - && stop_pc INNER_THAN stop_frame_address) -#else - || stop_pc == text_end - 2 -#endif - || (step_range_end && !step_resume_break_address)); - else - { - random_signal - = !(stop_breakpoint - || stop_step_resume_break -#ifdef sony_news - || (stop_sp INNER_THAN stop_pc - && stop_pc INNER_THAN stop_frame_address) -#endif - - ); - if (!random_signal) - stop_signal = SIGTRAP; - } - } - else - random_signal = 1; - - /* For the program's own signals, act according to - the signal handling tables. */ - - if (random_signal - && !(running_in_shell && stop_signal == SIGSEGV)) - { - /* Signal not for debugging purposes. */ - int printed = 0; - - stopped_by_random_signal = 1; - - if (stop_signal >= NSIG - || signal_print[stop_signal]) - { - printed = 1; - terminal_ours_for_output (); - printf ("\nProgram received signal %d, %s\n", - stop_signal, - stop_signal < NSIG - ? sys_siglist[stop_signal] - : "(undocumented)"); - fflush (stdout); - } - if (stop_signal >= NSIG - || signal_stop[stop_signal]) - break; - /* If not going to stop, give terminal back - if we took it away. */ - else if (printed) - terminal_inferior (); - } - - /* Handle cases caused by hitting a breakpoint. */ - - if (!random_signal - && (stop_breakpoint || stop_step_resume_break)) - { - /* Does a breakpoint want us to stop? */ - if (stop_breakpoint && stop_breakpoint != -1 - && stop_breakpoint != -0x1000001) - { - /* 0x1000000 is set in stop_breakpoint as returned by - breakpoint_stop_status to indicate a silent - breakpoint. */ - if ((stop_breakpoint > 0 ? stop_breakpoint : - -stop_breakpoint) - & 0x1000000) - { - stop_print_frame = 0; - if (stop_breakpoint > 0) - stop_breakpoint -= 0x1000000; - else - stop_breakpoint += 0x1000000; - } - break; - } - /* But if we have hit the step-resumption breakpoint, - remove it. It has done its job getting us here. - The sp test is to make sure that we don't get hung - up in recursive calls in functions without frame - pointers. If the stack pointer isn't outside of - where the breakpoint was set (within a routine to be - stepped over), we're in the middle of a recursive - call. Not true for reg window machines (sparc) - because the must change frames to call things and - the stack pointer doesn't have to change if it - the bp was set in a routine without a frame (pc can - be stored in some other window). - - The removal of the sp test is to allow calls to - alloca. Nasty things were happening. Oh, well, - gdb can only handle one level deep of lack of - frame pointer. */ - if (stop_step_resume_break - && (step_frame_address == 0 - || (stop_frame_address == step_frame_address))) - { - remove_step_breakpoint (); - step_resume_break_address = 0; - } - /* Otherwise, must remove breakpoints and single-step - to get us past the one we hit. */ - else - { - remove_breakpoints (); - remove_step_breakpoint (); - breakpoints_inserted = 0; - another_trap = 1; - } - - /* We come here if we hit a breakpoint but should not - stop for it. Possibly we also were stepping - and should stop for that. So fall through and - test for stepping. But, if not stepping, - do not stop. */ - } - - /* If this is the breakpoint at the end of a stack dummy, - just stop silently. */ -#ifndef CANNOT_EXECUTE_STACK - if (stop_sp INNER_THAN stop_pc - && stop_pc INNER_THAN stop_frame_address) -#else - if (stop_pc == text_end - 2) -#endif - { - stop_print_frame = 0; - stop_stack_dummy = 1; -#ifdef HP_OS_BUG - trap_expected_after_continue = 1; -#endif - break; - } - - if (step_resume_break_address) - /* Having a step-resume breakpoint overrides anything - else having to do with stepping commands until - that breakpoint is reached. */ - ; - /* If stepping through a line, keep going if still within it. */ - else if (!random_signal - && step_range_end - && stop_pc >= step_range_start - && stop_pc < step_range_end - /* The step range might include the start of the - function, so if we are at the start of the - step range and either the stack or frame pointers - just changed, we've stepped outside */ - && !(stop_pc == step_range_start - && stop_frame_address - && (stop_sp INNER_THAN prev_sp - || stop_frame_address != step_frame_address))) - { - /* Don't step through the return from a function - unless that is the first instruction stepped through. */ - if (ABOUT_TO_RETURN (stop_pc)) - { - stop_step = 1; - break; - } - } - - /* We stepped out of the stepping range. See if that was due - to a subroutine call that we should proceed to the end of. */ - else if (!random_signal && step_range_end) - { - if (stop_func_start) - { - prologue_pc = stop_func_start; - SKIP_PROLOGUE (prologue_pc); - } - - /* Did we just take a signal? */ - if (IN_SIGTRAMP (stop_pc, stop_func_name) - && !IN_SIGTRAMP (prev_pc, prev_func_name)) - { - /* This code is needed at least in the following case: - The user types "next" and then a signal arrives (before - the "next" is done). */ - /* We've just taken a signal; go until we are back to - the point where we took it and one more. */ - step_resume_break_address = prev_pc; - step_resume_break_duplicate = - breakpoint_here_p (step_resume_break_address); - step_resume_break_sp = stop_sp; - if (breakpoints_inserted) - insert_step_breakpoint (); - /* Make sure that the stepping range gets us past - that instruction. */ - if (step_range_end == 1) - step_range_end = (step_range_start = prev_pc) + 1; - remove_breakpoints_on_following_step = 1; - } - - /* ==> See comments at top of file on this algorithm. <==*/ - - else if (stop_pc == stop_func_start - && (stop_func_start != prev_func_start - || prologue_pc != stop_func_start - || stop_sp != prev_sp)) - { - /* It's a subroutine call */ - if (step_over_calls > 0 - || (step_over_calls && find_pc_function (stop_pc) == 0)) - { - /* A subroutine call has happened. */ - /* Set a special breakpoint after the return */ - step_resume_break_address = - SAVED_PC_AFTER_CALL (get_current_frame ()); - step_resume_break_duplicate - = breakpoint_here_p (step_resume_break_address); - step_resume_break_sp = stop_sp; - if (breakpoints_inserted) - insert_step_breakpoint (); - } - /* Subroutine call with source code we should not step over. - Do step to the first line of code in it. */ - else if (step_over_calls) - { - SKIP_PROLOGUE (stop_func_start); - sal = find_pc_line (stop_func_start, 0); - /* Use the step_resume_break to step until - the end of the prologue, even if that involves jumps - (as it seems to on the vax under 4.2). */ - /* If the prologue ends in the middle of a source line, - continue to the end of that source line. - Otherwise, just go to end of prologue. */ -#ifdef PROLOGUE_FIRSTLINE_OVERLAP - /* no, don't either. It skips any code that's - legitimately on the first line. */ -#else - if (sal.end && sal.pc != stop_func_start) - stop_func_start = sal.end; -#endif - - if (stop_func_start == stop_pc) - { - /* We are already there: stop now. */ - stop_step = 1; - break; - } - else - /* Put the step-breakpoint there and go until there. */ - { - step_resume_break_address = stop_func_start; - step_resume_break_sp = stop_sp; - - step_resume_break_duplicate - = breakpoint_here_p (step_resume_break_address); - if (breakpoints_inserted) - insert_step_breakpoint (); - /* Do not specify what the fp should be when we stop - since on some machines the prologue - is where the new fp value is established. */ - step_frame_address = 0; - /* And make sure stepping stops right away then. */ - step_range_end = step_range_start; - } - } - else - { - /* We get here only if step_over_calls is 0 and we - just stepped into a subroutine. I presume - that step_over_calls is only 0 when we're - supposed to be stepping at the assembly - language level.*/ - stop_step = 1; - break; - } - } - /* No subroutince call; stop now. */ - else - { - stop_step = 1; - break; - } - } - - /* Save the pc before execution, to compare with pc after stop. */ - prev_pc = read_pc (); /* Might have been DECR_AFTER_BREAK */ - prev_func_start = stop_func_start; /* Ok, since if DECR_PC_AFTER - BREAK is defined, the - original pc would not have - been at the start of a - function. */ - prev_func_name = stop_func_name; - prev_sp = stop_sp; - - /* If we did not do break;, it means we should keep - running the inferior and not return to debugger. */ - - /* If trap_expected is 2, it means continue once more - and insert breakpoints at the next trap. - If trap_expected is 1 and the signal was SIGSEGV, it means - the shell is doing some memory allocation--just resume it - with SIGSEGV. - Otherwise insert breakpoints now, and possibly single step. */ - - if (trap_expected > 1) - { - trap_expected--; - running_in_shell = 1; - resume (0, 0); - } - else if (running_in_shell && stop_signal == SIGSEGV) - { - resume (0, SIGSEGV); - } - else if (trap_expected && stop_signal != SIGTRAP) - { - /* We took a signal which we are supposed to pass through to - the inferior and we haven't yet gotten our trap. Simply - continue. */ - resume ((step_range_end && !step_resume_break_address) - || trap_expected, - stop_signal); - } - else - { - /* Here, we are not awaiting another exec to get - the program we really want to debug. - Insert breakpoints now, unless we are trying - to one-proceed past a breakpoint. */ - running_in_shell = 0; - /* If we've just finished a special step resume and we don't - want to hit a breakpoint, pull em out. */ - if (!step_resume_break_address && - remove_breakpoints_on_following_step) - { - remove_breakpoints_on_following_step = 0; - remove_breakpoints (); - breakpoints_inserted = 0; - } - else if (!breakpoints_inserted && !another_trap) - { - insert_step_breakpoint (); - breakpoints_failed = insert_breakpoints (); - if (breakpoints_failed) - break; - breakpoints_inserted = 1; - } - - trap_expected = another_trap; - - if (stop_signal == SIGTRAP) - stop_signal = 0; - - resume ((step_range_end && !step_resume_break_address) - || trap_expected, - stop_signal); - } - } -} - -/* Here to return control to GDB when the inferior stops for real. - Print appropriate messages, remove breakpoints, give terminal our modes. - - RUNNING_IN_SHELL nonzero means the shell got a signal before - exec'ing the program we wanted to run. - STOP_PRINT_FRAME nonzero means print the executing frame - (pc, function, args, file, line number and line text). - BREAKPOINTS_FAILED nonzero means stop was due to error - attempting to insert breakpoints. */ - -static void -normal_stop () -{ - /* Make sure that the current_frame's pc is correct. This - is a correction for setting up the frame info before doing - DECR_PC_AFTER_BREAK */ - if (inferior_pid) - (get_current_frame ())->pc = read_pc (); - - if (breakpoints_failed) - { - terminal_ours_for_output (); - print_sys_errmsg ("ptrace", breakpoints_failed); - printf ("Stopped; cannot insert breakpoints.\n\ -The same program may be running in another process.\n"); - } - - if (inferior_pid) - remove_step_breakpoint (); - - if (inferior_pid && breakpoints_inserted) - if (remove_breakpoints ()) - { - terminal_ours_for_output (); - printf ("Cannot remove breakpoints because program is no longer writable.\n\ -It must be running in another process.\n\ -Further execution is probably impossible.\n"); - } - - breakpoints_inserted = 0; - - /* Delete the breakpoint we stopped at, if it wants to be deleted. - Delete any breakpoint that is to be deleted at the next stop. */ - - breakpoint_auto_delete (stop_breakpoint); - - /* If an auto-display called a function and that got a signal, - delete that auto-display to avoid an infinite recursion. */ - - if (stopped_by_random_signal) - disable_current_display (); - - if (step_multi && stop_step) - return; - - terminal_ours (); - - if (running_in_shell) - { - if (stop_signal == SIGSEGV) - { - char *exec_file = (char *) get_exec_file (1); - - if (access (exec_file, X_OK) != 0) - printf ("The file \"%s\" is not executable.\n", exec_file); - else - /* I don't think we should ever get here. - wait_for_inferior now ignores SIGSEGV's which happen in - the shell (since the Bourne shell (/bin/sh) has some - rather, er, uh, *unorthodox* memory management - involving catching SIGSEGV). */ - printf ("\ -You have just encountered a bug in \"sh\". GDB starts your program\n\ -by running \"sh\" with a command to exec your program.\n\ -This is so that \"sh\" will process wildcards and I/O redirection.\n\ -This time, \"sh\" crashed.\n\ -\n\ -One known bug in \"sh\" bites when the environment takes up a lot of space.\n\ -Try \"info env\" to see the environment; then use \"delete env\" to kill\n\ -some variables whose values are large; then do \"run\" again.\n\ -\n\ -If that works, you might want to put those \"delete env\" commands\n\ -into a \".gdbinit\" file in this directory so they will happen every time.\n"); - } - /* Don't confuse user with his program's symbols on sh's data. */ - stop_print_frame = 0; - } - - if (inferior_pid == 0) - return; - - /* Select innermost stack frame except on return from a stack dummy routine, - or if the program has exited. */ - if (!stop_stack_dummy) - { - select_frame (get_current_frame (), 0); - - if (stop_print_frame) - { - if (stop_breakpoint > 0) - printf ("\nBpt %d, ", stop_breakpoint); - print_sel_frame (stop_step - && step_frame_address == stop_frame_address - && step_start_function == find_pc_function (stop_pc)); - /* Display the auto-display expressions. */ - do_displays (); - } - } - - if (stop_stack_dummy) - { - /* Pop the empty frame that contains the stack dummy. - POP_FRAME ends with a setting of the current frame, so we - can use that next. */ -#ifndef NEW_CALL_FUNCTION - POP_FRAME; -#endif - select_frame (get_current_frame (), 0); - } -} - -static void -insert_step_breakpoint () -{ - if (step_resume_break_address && !step_resume_break_duplicate) - { - read_memory (step_resume_break_address, - step_resume_break_shadow, sizeof break_insn); - write_memory (step_resume_break_address, - break_insn, sizeof break_insn); - } -} - -static void -remove_step_breakpoint () -{ - if (step_resume_break_address && !step_resume_break_duplicate) - write_memory (step_resume_break_address, step_resume_break_shadow, - sizeof break_insn); -} - -/* Specify how various signals in the inferior should be handled. */ - -static void -handle_command (args, from_tty) - char *args; - int from_tty; -{ - register char *p = args; - int signum = 0; - register int digits, wordlen; - - if (!args) - error_no_arg ("signal to handle"); - - while (*p) - { - /* Find the end of the next word in the args. */ - for (wordlen = 0; p[wordlen] && p[wordlen] != ' ' && p[wordlen] != '\t'; - wordlen++); - for (digits = 0; p[digits] >= '0' && p[digits] <= '9'; digits++); - - /* If it is all digits, it is signal number to operate on. */ - if (digits == wordlen) - { - signum = atoi (p); - if (signum <= 0 || signum >= NSIG) - { - p[wordlen] = '\0'; - error ("Invalid signal %s given as argument to \"handle\".", p); - } - if (signum == SIGTRAP || signum == SIGINT) - { - if (!query ("Signal %d is used by the debugger.\nAre you sure you want to change it? ", signum)) - error ("Not confirmed."); - } - } - else if (signum == 0) - error ("First argument is not a signal number."); - - /* Else, if already got a signal number, look for flag words - saying what to do for it. */ - else if (!strncmp (p, "stop", wordlen)) - { - signal_stop[signum] = 1; - signal_print[signum] = 1; - } - else if (wordlen >= 2 && !strncmp (p, "print", wordlen)) - signal_print[signum] = 1; - else if (wordlen >= 2 && !strncmp (p, "pass", wordlen)) - signal_program[signum] = 1; - else if (!strncmp (p, "ignore", wordlen)) - signal_program[signum] = 0; - else if (wordlen >= 3 && !strncmp (p, "nostop", wordlen)) - signal_stop[signum] = 0; - else if (wordlen >= 4 && !strncmp (p, "noprint", wordlen)) - { - signal_print[signum] = 0; - signal_stop[signum] = 0; - } - else if (wordlen >= 4 && !strncmp (p, "nopass", wordlen)) - signal_program[signum] = 0; - else if (wordlen >= 3 && !strncmp (p, "noignore", wordlen)) - signal_program[signum] = 1; - /* Not a number and not a recognized flag word => complain. */ - else - { - p[wordlen] = 0; - error ("Unrecognized flag word: \"%s\".", p); - } - - /* Find start of next word. */ - p += wordlen; - while (*p == ' ' || *p == '\t') p++; - } - - if (from_tty) - { - /* Show the results. */ - printf ("Number\tStop\tPrint\tPass to program\tDescription\n"); - printf ("%d\t", signum); - printf ("%s\t", signal_stop[signum] ? "Yes" : "No"); - printf ("%s\t", signal_print[signum] ? "Yes" : "No"); - printf ("%s\t\t", signal_program[signum] ? "Yes" : "No"); - printf ("%s\n", sys_siglist[signum]); - } -} - -/* Print current contents of the tables set by the handle command. */ - -static void -signals_info (signum_exp) - char *signum_exp; -{ - register int i; - printf_filtered ("Number\tStop\tPrint\tPass to program\tDescription\n"); - - if (signum_exp) - { - i = parse_and_eval_address (signum_exp); - if (i >= NSIG || i < 0) - error ("Signal number out of bounds."); - printf_filtered ("%d\t", i); - printf_filtered ("%s\t", signal_stop[i] ? "Yes" : "No"); - printf_filtered ("%s\t", signal_print[i] ? "Yes" : "No"); - printf_filtered ("%s\t\t", signal_program[i] ? "Yes" : "No"); - printf_filtered ("%s\n", sys_siglist[i]); - return; - } - - printf_filtered ("\n"); - for (i = 0; i < NSIG; i++) - { - QUIT; - - printf_filtered ("%d\t", i); - printf_filtered ("%s\t", signal_stop[i] ? "Yes" : "No"); - printf_filtered ("%s\t", signal_print[i] ? "Yes" : "No"); - printf_filtered ("%s\t\t", signal_program[i] ? "Yes" : "No"); - printf_filtered ("%s\n", sys_siglist[i]); - } - - printf_filtered ("\nUse the \"handle\" command to change these tables.\n"); -} - -/* Save all of the information associated with the inferior<==>gdb - connection. INF_STATUS is a pointer to a "struct inferior_status" - (defined in inferior.h). */ - -struct command_line *get_breakpoint_commands (); - -void -save_inferior_status (inf_status, restore_stack_info) - struct inferior_status *inf_status; - int restore_stack_info; -{ - inf_status->pc_changed = pc_changed; - inf_status->stop_signal = stop_signal; - inf_status->stop_pc = stop_pc; - inf_status->stop_frame_address = stop_frame_address; - inf_status->stop_breakpoint = stop_breakpoint; - inf_status->stop_step = stop_step; - inf_status->stop_stack_dummy = stop_stack_dummy; - inf_status->stopped_by_random_signal = stopped_by_random_signal; - inf_status->trap_expected = trap_expected; - inf_status->step_range_start = step_range_start; - inf_status->step_range_end = step_range_end; - inf_status->step_frame_address = step_frame_address; - inf_status->step_over_calls = step_over_calls; - inf_status->step_resume_break_address = step_resume_break_address; - inf_status->stop_after_trap = stop_after_trap; - inf_status->stop_after_attach = stop_after_attach; - inf_status->breakpoint_commands = get_breakpoint_commands (); - inf_status->restore_stack_info = restore_stack_info; - - read_register_bytes(0, inf_status->register_context, REGISTER_BYTES); - record_selected_frame (&(inf_status->selected_frame_address), - &(inf_status->selected_level)); - return; -} - -void -restore_inferior_status (inf_status) - struct inferior_status *inf_status; -{ - FRAME fid; - int level = inf_status->selected_level; - - pc_changed = inf_status->pc_changed; - stop_signal = inf_status->stop_signal; - stop_pc = inf_status->stop_pc; - stop_frame_address = inf_status->stop_frame_address; - stop_breakpoint = inf_status->stop_breakpoint; - stop_step = inf_status->stop_step; - stop_stack_dummy = inf_status->stop_stack_dummy; - stopped_by_random_signal = inf_status->stopped_by_random_signal; - trap_expected = inf_status->trap_expected; - step_range_start = inf_status->step_range_start; - step_range_end = inf_status->step_range_end; - step_frame_address = inf_status->step_frame_address; - step_over_calls = inf_status->step_over_calls; - step_resume_break_address = inf_status->step_resume_break_address; - stop_after_trap = inf_status->stop_after_trap; - stop_after_attach = inf_status->stop_after_attach; - set_breakpoint_commands (inf_status->breakpoint_commands); - - write_register_bytes(0, inf_status->register_context, REGISTER_BYTES); - - /* The inferior can be gone if the user types "print exit(0)" - (and perhaps other times). */ - if (have_inferior_p() && inf_status->restore_stack_info) - { - flush_cached_frames(); - set_current_frame(create_new_frame(read_register (FP_REGNUM), - read_pc())); - - fid = find_relative_frame (get_current_frame (), &level); - - if (fid == 0 || - FRAME_FP (fid) != inf_status->selected_frame_address || - level != 0) - { - /* I'm not sure this error message is a good idea. I have - only seen it occur after "Can't continue previously - requested operation" (we get called from do_cleanups), in - which case it just adds insult to injury (one confusing - error message after another. Besides which, does the - user really care if we can't restore the previously - selected frame? */ - fprintf (stderr, "Unable to restore previously selected frame.\n"); - select_frame (get_current_frame (), 0); - return; - } - - select_frame (fid, inf_status->selected_level); - } - return; -} - - -void -_initialize_infrun () -{ - register int i; - - add_info ("signals", signals_info, - "What debugger does when program gets various signals.\n\ -Specify a signal number as argument to print info on that signal only."); - - add_com ("handle", class_run, handle_command, - "Specify how to handle a signal.\n\ -Args are signal number followed by flags.\n\ -Flags allowed are \"stop\", \"print\", \"pass\",\n\ - \"nostop\", \"noprint\" or \"nopass\".\n\ -Print means print a message if this signal happens.\n\ -Stop means reenter debugger if this signal happens (implies print).\n\ -Pass means let program see this signal; otherwise program doesn't know.\n\ -Pass and Stop may be combined."); - - for (i = 0; i < NSIG; i++) - { - signal_stop[i] = 1; - signal_print[i] = 1; - signal_program[i] = 1; - } - - /* Signals caused by debugger's own actions - should not be given to the program afterwards. */ - signal_program[SIGTRAP] = 0; - signal_program[SIGINT] = 0; - - /* Signals that are not errors should not normally enter the debugger. */ -#ifdef SIGALRM - signal_stop[SIGALRM] = 0; - signal_print[SIGALRM] = 0; -#endif /* SIGALRM */ -#ifdef SIGVTALRM - signal_stop[SIGVTALRM] = 0; - signal_print[SIGVTALRM] = 0; -#endif /* SIGVTALRM */ -#ifdef SIGPROF - signal_stop[SIGPROF] = 0; - signal_print[SIGPROF] = 0; -#endif /* SIGPROF */ -#ifdef SIGCHLD - signal_stop[SIGCHLD] = 0; - signal_print[SIGCHLD] = 0; -#endif /* SIGCHLD */ -#ifdef SIGCLD - signal_stop[SIGCLD] = 0; - signal_print[SIGCLD] = 0; -#endif /* SIGCLD */ -#ifdef SIGIO - signal_stop[SIGIO] = 0; - signal_print[SIGIO] = 0; -#endif /* SIGIO */ -#ifdef SIGURG - signal_stop[SIGURG] = 0; - signal_print[SIGURG] = 0; -#endif /* SIGURG */ -} - diff --git a/gnu/usr.bin/gdb/kgdb_proto.h b/gnu/usr.bin/gdb/kgdb_proto.h deleted file mode 100644 index d792cc008db8..000000000000 --- a/gnu/usr.bin/gdb/kgdb_proto.h +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Steven McCanne of Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)kgdb_proto.h 6.3 (Berkeley) 5/8/91 - * $Id: kgdb_proto.h,v 1.2 1993/08/01 18:47:54 mycroft Exp $ - * - */ - -/* - * Message types. - */ -#define KGDB_MEM_R 0x01 -#define KGDB_MEM_W 0x02 -#define KGDB_REG_R 0x03 -#define KGDB_REG_W 0x04 -#define KGDB_CONT 0x05 -#define KGDB_STEP 0x06 -#define KGDB_KILL 0x07 -#define KGDB_SIGNAL 0x08 -#define KGDB_EXEC 0x09 - -#define KGDB_CMD(x) ((x) & 0x0f) - -/* - * Message flags. - */ -#define KGDB_ACK 0x80 -#define KGDB_DELTA 0x40 -#define KGDB_MORE 0x20 -#define KGDB_SEQ 0x10 diff --git a/gnu/usr.bin/gdb/main.c b/gnu/usr.bin/gdb/main.c deleted file mode 100644 index 22103079a923..000000000000 --- a/gnu/usr.bin/gdb/main.c +++ /dev/null @@ -1,2242 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)main.c 6.6 (Berkeley) 5/13/91";*/ -static char rcsid[] = "$Id: main.c,v 1.3 1993/08/01 18:47:47 mycroft Exp $"; -#endif /* not lint */ - -/* Top level for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "command.h" -#include "param.h" -#include "expression.h" - -#ifdef USG -#include -#include -#endif - -#include -#include -#include -#include -#include -#include - -#ifdef SET_STACK_LIMIT_HUGE -#include -#include - -int original_stack_limit; -#endif - -/* If this definition isn't overridden by the header files, assume - that isatty and fileno exist on this system. */ -#ifndef ISATTY -#define ISATTY(FP) (isatty (fileno (FP))) -#endif - -extern void free (); - -/* Version number of GDB, as a string. */ - -extern char *version; - -/* - * Declare all cmd_list_element's - */ - -/* Chain containing all defined commands. */ - -struct cmd_list_element *cmdlist; - -/* Chain containing all defined info subcommands. */ - -struct cmd_list_element *infolist; - -/* Chain containing all defined enable subcommands. */ - -struct cmd_list_element *enablelist; - -/* Chain containing all defined disable subcommands. */ - -struct cmd_list_element *disablelist; - -/* Chain containing all defined delete subcommands. */ - -struct cmd_list_element *deletelist; - -/* Chain containing all defined "enable breakpoint" subcommands. */ - -struct cmd_list_element *enablebreaklist; - -/* Chain containing all defined set subcommands */ - -struct cmd_list_element *setlist; - -/* Chain containing all defined \"set history\". */ - -struct cmd_list_element *sethistlist; - -/* Chain containing all defined \"unset history\". */ - -struct cmd_list_element *unsethistlist; - -/* stdio stream that command input is being read from. */ - -FILE *instream; - -/* Current working directory. */ - -char *current_directory; - -/* The directory name is actually stored here (usually). */ -static char dirbuf[MAXPATHLEN]; - -#ifdef KERNELDEBUG -/* Nonzero if we're debugging /dev/mem or a kernel crash dump */ - -int kernel_debugging; -#endif - -/* Nonzero to inhibit confirmation of quitting or restarting - a stopped inferior. */ -int inhibit_confirm; - -/* Nonzero if we can write in text or core file */ - -int writeable_text; - -/* The number of lines on a page, and the number of spaces - in a line. */ -int linesize, pagesize; - -/* Nonzero if we should refrain from using an X window. */ - -int inhibit_windows = 0; - -/* Function to call before reading a command, if nonzero. - The function receives two args: an input stream, - and a prompt string. */ - -void (*window_hook) (); - -extern int frame_file_full_name; -int xgdb_verbose; - -void execute_command(); -void free_command_lines (); -char *gdb_readline (); -char *command_line_input (); -static void initialize_main (); -static void initialize_cmd_lists (); -void command_loop (); -static void source_command (); -static void print_gdb_version (); -static void float_handler (); -static void cd_command (); - -char *getenv (); - -/* gdb prints this when reading a command interactively */ -static char *prompt; - -/* Buffer used for reading command lines, and the size - allocated for it so far. */ - -char *line; -int linesize; - - -/* This is how `error' returns to command level. */ - -jmp_buf to_top_level; - -void -return_to_top_level () -{ - quit_flag = 0; - immediate_quit = 0; - clear_breakpoint_commands (); - clear_momentary_breakpoints (); - disable_current_display (); - do_cleanups (0); - longjmp (to_top_level, 1); -} - -/* Call FUNC with arg ARG, catching any errors. - If there is no error, return the value returned by FUNC. - If there is an error, return zero after printing ERRSTRING - (which is in addition to the specific error message already printed). */ - -int -catch_errors (func, arg, errstring) - int (*func) (); - int arg; - char *errstring; -{ - jmp_buf saved; - int val; - struct cleanup *saved_cleanup_chain; - - saved_cleanup_chain = save_cleanups (); - - bcopy (to_top_level, saved, sizeof (jmp_buf)); - - if (setjmp (to_top_level) == 0) - val = (*func) (arg); - else - { - fprintf (stderr, "%s\n", errstring); - val = 0; - } - - restore_cleanups (saved_cleanup_chain); - - bcopy (saved, to_top_level, sizeof (jmp_buf)); - return val; -} - -/* Handler for SIGHUP. */ - -static void -disconnect () -{ - kill_inferior_fast (); - signal (SIGHUP, SIG_DFL); - kill (getpid (), SIGHUP); -} - -/* Clean up on error during a "source" command (or execution of a - user-defined command). - Close the file opened by the command - and restore the previous input stream. */ - -static void -source_cleanup (stream) - FILE *stream; -{ - /* Instream may be 0; set to it when executing user-defined command. */ - if (instream) - fclose (instream); - instream = stream; -} - -/* - * Source $HOME/.gdbinit and $cwd/.gdbinit. - * If X is enabled, also $HOME/.xgdbinit and $cwd/.xgdbinit.source - */ -void -source_init_files() -{ - char *homedir, initfile[256]; - int samedir = 0; - - /* Read init file, if it exists in home directory */ - homedir = getenv ("HOME"); - if (homedir) { - struct stat homebuf, cwdbuf; - - sprintf(initfile, "%s/.gdbinit", homedir); - if (access (initfile, R_OK) == 0) - if (!setjmp (to_top_level)) - source_command (initfile); - if (!inhibit_windows) { - sprintf(initfile, "%s/.xgdbinit", homedir); - if (access (initfile, R_OK) == 0) - if (!setjmp (to_top_level)) - source_command (initfile); - } - /* Determine if current directory is the same as the home - directory, so we don't source the same file twice. */ - - bzero (&homebuf, sizeof (struct stat)); - bzero (&cwdbuf, sizeof (struct stat)); - - stat(homedir, &homebuf); - stat(".", &cwdbuf); - - samedir = bcmp(&homebuf, &cwdbuf, sizeof(struct stat)) == 0; - } - /* Read the input file in the current directory, *if* it isn't - the same file (it should exist, also). */ - if (!samedir) { - if (access (".gdbinit", R_OK) == 0) - if (!setjmp (to_top_level)) - source_command (".gdbinit"); - if (access (".xgdbinit", R_OK) == 0) - if (!setjmp (to_top_level)) - source_command (".xgdbinit"); - } -} - - -int -main (argc, argv, envp) - int argc; - char **argv; - char **envp; -{ - int count; - int inhibit_gdbinit = 0; - int quiet = 1; - int batch = 0; - register int i; - char *cp; - - /* XXX Windows only for xgdb. */ - char *strrchr(); - if (cp = strrchr(argv[0], '/')) - ++cp; - else - cp = argv[0]; - if (*cp != 'x') - inhibit_windows = 1; - -#if defined (ALIGN_STACK_ON_STARTUP) - i = (int) &count & 0x3; - if (i != 0) - alloca (4 - i); -#endif - - quit_flag = 0; - linesize = 100; - line = (char *) xmalloc (linesize); - *line = 0; - instream = stdin; - - getwd (dirbuf); - current_directory = dirbuf; - -#ifdef SET_STACK_LIMIT_HUGE - { - struct rlimit rlim; - - /* Set the stack limit huge so that alloca (particularly stringtab - * in dbxread.c) does not fail. */ - getrlimit (RLIMIT_STACK, &rlim); - original_stack_limit = rlim.rlim_cur; - rlim.rlim_cur = rlim.rlim_max; - setrlimit (RLIMIT_STACK, &rlim); - } -#endif /* SET_STACK_LIMIT_HUGE */ - - /* Look for flag arguments. */ - - for (i = 1; i < argc; i++) - { - if (!strcmp (argv[i], "-q") || !strcmp (argv[i], "-quiet")) - quiet = 1; - else if (!strcmp (argv[i], "-nx")) - inhibit_gdbinit = 1; - else if (!strcmp (argv[i], "-nw")) - inhibit_windows = 1; - else if (!strcmp (argv[i], "-batch")) - batch = 1, quiet = 1; - else if (!strcmp (argv[i], "-fullname")) - frame_file_full_name = 1; - else if (!strcmp (argv[i], "-xgdb_verbose")) - xgdb_verbose = 1; - /* -help: print a summary of command line switches. */ - else if (!strcmp (argv[i], "-help")) - { - fputs ("\ -This is GDB, the GNU debugger. Use the command\n\ - gdb [options] [executable [core-file]]\n\ -to enter the debugger.\n\ -\n\ -Options available are:\n\ - -help Print this message.\n\ - -quiet Do not print version number on startup.\n\ - -fullname Output information used by emacs-GDB interface.\n\ - -batch Exit after processing options.\n\ - -nx Do not read .gdbinit file.\n\ - -tty TTY Use TTY for input/output by the program being debugged.\n\ - -cd DIR Change current directory to DIR.\n\ - -directory DIR Search for source files in DIR.\n\ - -command FILE Execute GDB commands from FILE.\n\ - -symbols SYMFILE Read symbols from SYMFILE.\n\ - -exec EXECFILE Use EXECFILE as the executable.\n\ - -se FILE Use FILE as symbol file and executable file.\n\ - -core COREFILE Analyze the core dump COREFILE.\n\ - -k Kernel debugging.\n\ - -w Writeable text.\n\ - -v Print GNU message and version number on startup.\n\ - -nc Don't confirm quit or run commands.\n\ -\n\ -For more information, type \"help\" from within GDB, or consult the\n\ -GDB manual (available as on-line info or a printed manual).\n", stderr); - /* Exiting after printing this message seems like - the most useful thing to do. */ - exit (0); - } -#ifdef KERNELDEBUG - else if (!strcmp (argv[i], "-k")) - kernel_debugging = 1; -#endif - else if (!strcmp (argv[i], "-w")) - writeable_text = 1; - else if (!strcmp (argv[i], "-v")) - quiet = 0; - else if (!strcmp (argv[i], "-nc")) - inhibit_confirm = 1; - else if (argv[i][0] == '-') - /* Other options take arguments, so don't confuse an - argument with an option. */ - i++; - } - - /* Run the init function of each source file */ - - initialize_cmd_lists (); /* This needs to be done first */ - initialize_all_files (); - initialize_main (); /* But that omits this file! Do it now */ - initialize_signals (); - - if (!quiet) - print_gdb_version (); - - /* Process the command line arguments. */ - - count = 0; - for (i = 1; i < argc; i++) - { - extern void exec_file_command (), symbol_file_command (); - extern void core_file_command (); - register char *arg = argv[i]; - /* Args starting with - say what to do with the following arg - as a filename. */ - if (arg[0] == '-') - { - extern void tty_command (), directory_command (); - - if (!strcmp (arg, "-q") || !strcmp (arg, "-nx") - || !strcmp (arg, "-quiet") || !strcmp (arg, "-batch") - || !strcmp (arg, "-fullname") || !strcmp (arg, "-nw") - || !strcmp (arg, "-xgdb_verbose") - || !strcmp (arg, "-help") - || !strcmp (arg, "-k") - || !strcmp (arg, "-w") - || !strcmp (arg, "-v") - || !strcmp (arg, "-nc")) - /* Already processed above */ - continue; - - if (++i == argc) - fprintf (stderr, "No argument follows \"%s\".\n", arg); - if (!setjmp (to_top_level)) - { - /* -s foo: get syms from foo. -e foo: execute foo. - -se foo: do both with foo. -c foo: use foo as core dump. */ - if (!strcmp (arg, "-se")) - { - exec_file_command (argv[i], !batch); - symbol_file_command (argv[i], !batch); - } - else if (!strcmp (arg, "-s") || !strcmp (arg, "-symbols")) - symbol_file_command (argv[i], !batch); - else if (!strcmp (arg, "-e") || !strcmp (arg, "-exec")) - exec_file_command (argv[i], !batch); - else if (!strcmp (arg, "-c") || !strcmp (arg, "-core")) - core_file_command (argv[i], !batch); - /* -x foo: execute commands from foo. */ - else if (!strcmp (arg, "-x") || !strcmp (arg, "-command") - || !strcmp (arg, "-commands")) - source_command (argv[i]); - /* -d foo: add directory `foo' to source-file directory - search-list */ - else if (!strcmp (arg, "-d") || !strcmp (arg, "-dir") - || !strcmp (arg, "-directory")) - directory_command (argv[i], 0); - /* -cd FOO: specify current directory as FOO. - GDB remembers the precise string FOO as the dirname. */ - else if (!strcmp (arg, "-cd")) - { - cd_command (argv[i], 0); - init_source_path (); - } - /* -t /def/ttyp1: use /dev/ttyp1 for inferior I/O. */ - else if (!strcmp (arg, "-t") || !strcmp (arg, "-tty")) - tty_command (argv[i], 0); - - else - error ("Unknown command-line switch: \"%s\"\n", arg); - } - } - else - { - /* Args not thus accounted for - are treated as, first, the symbol/executable file - and, second, the core dump file. */ - count++; - if (!setjmp (to_top_level)) - switch (count) - { - case 1: - exec_file_command (arg, !batch); - symbol_file_command (arg, !batch); - break; - - case 2: - core_file_command (arg, !batch); - break; - - case 3: - fprintf (stderr, "Excess command line args ignored. (%s%s)\n", - arg, (i == argc - 1) ? "" : " ..."); - } - } - } - - if (!inhibit_gdbinit) - source_init_files(); - - if (batch) - { -#if 0 - fatal ("Attempt to read commands from stdin in batch mode."); -#endif - /* We have hit the end of the batch file. */ - exit (0); - } - - if (!quiet) - printf ("Type \"help\" for a list of commands.\n"); - - /* The command loop. */ - - while (1) - { - if (!setjmp (to_top_level)) - command_loop (); - if (ISATTY(stdin)) - clearerr (stdin); /* Don't get hung if C-d is typed. */ - else if (feof(instream)) /* Avoid endless loops for redirected stdin */ - break; - } - exit (0); -} - - -static void -do_nothing () -{ -} - -/* Read commands from `instream' and execute them - until end of file. */ -void -command_loop () -{ - struct cleanup *old_chain; - register int toplevel = (instream == stdin); - register int interactive = (toplevel && ISATTY(stdin)); - - while (!feof (instream)) - { - register char *cmd_line; - - quit_flag = 0; - if (interactive) - reinitialize_more_filter (); - old_chain = make_cleanup (do_nothing, 0); - cmd_line = command_line_input (prompt, toplevel); - execute_command (cmd_line, toplevel); - /* Do any commands attached to breakpoint we stopped at. */ - do_breakpoint_commands (); - do_cleanups (old_chain); - } -} - -/* Commands call this if they do not want to be repeated by null lines. */ - -void -dont_repeat () -{ - /* If we aren't reading from standard input, we are saving the last - thing read from stdin in line and don't want to delete it. Null lines - won't repeat here in any case. */ - if (instream == stdin) - *line = 0; -} - -/* Read a line from the stream "instream" without command line editing. - - It prints PROMPT once at the start. - Action is compatible with "readline" (i.e., space for typing is - malloced & should be freed by caller). */ -char * -gdb_readline (prompt) - char *prompt; -{ - int c; - char *result; - int input_index = 0; - int result_size = 80; - - if (prompt) - { - printf (prompt); - fflush (stdout); - } - - result = (char *) xmalloc (result_size); - - while (1) - { - c = fgetc (instream ? instream : stdin); - if (c == EOF) - { - free(result); - return ((char *)0); - } - if (c == '\n') - break; - - result[input_index++] = c; - if (input_index >= result_size) - { - result_size <= 1; - result = (char *)xrealloc(result, result_size); - } - } - result[input_index++] = '\0'; - return result; -} - -/* Declaration for fancy readline with command line editing. */ -char *readline (); - -/* Variables which control command line editing and history - substitution. These variables are given default values at the end - of this file. */ -static int command_editing_p; -static int history_expansion_p; -static int write_history_p; -static int history_size; -static char *history_filename; - -/* Variables which are necessary for fancy command line editing. */ -char *gdb_completer_word_break_characters = - " \t\n!@#$%^&*()-+=|~`}{[]\"';:?/>.<,"; - -/* Functions that are used as part of the fancy command line editing. */ - -/* Generate symbol names one by one for the completer. If STATE is - zero, then we need to initialize, otherwise the initialization has - already taken place. TEXT is what we expect the symbol to start - with. RL_LINE_BUFFER is available to be looked at; it contains the - entire text of the line. RL_POINT is the offset in that line of - the cursor. You should pretend that the line ends at RL_POINT. */ -char * -symbol_completion_function (text, state) - char *text; - int state; -{ - char **make_symbol_completion_list (); - static char **list = (char **)NULL; - static int index; - char *output; - extern char *rl_line_buffer; - extern int rl_point; - char *tmp_command, *p; - struct cmd_list_element *c, *result_list; - - if (!state) - { - /* Free the storage used by LIST, but not by the strings inside. This is - because rl_complete_internal () frees the strings. */ - if (list) - free (list); - list = 0; - index = 0; - - /* Decide whether to complete on a list of gdb commands or on - symbols. */ - tmp_command = (char *) alloca (rl_point + 1); - p = tmp_command; - - strncpy (tmp_command, rl_line_buffer, rl_point); - tmp_command[rl_point] = '\0'; - - if (rl_point == 0) - { - /* An empty line we want to consider ambiguous; that is, - it could be any command. */ - c = (struct cmd_list_element *) -1; - result_list = 0; - } - else - c = lookup_cmd_1 (&p, cmdlist, &result_list, 1); - - /* Move p up to the next interesting thing. */ - while (*p == ' ' || *p == '\t') - p++; - - if (!c) - /* He's typed something unrecognizable. Sigh. */ - list = (char **) 0; - else if (c == (struct cmd_list_element *) -1) - { - if (p + strlen(text) != tmp_command + rl_point) - error ("Unrecognized command."); - - /* He's typed something ambiguous. This is easier. */ - if (result_list) - list = complete_on_cmdlist (*result_list->prefixlist, text); - else - list = complete_on_cmdlist (cmdlist, text); - } - else - { - /* If we've gotten this far, gdb has recognized a full - command. There are several possibilities: - - 1) We need to complete on the command. - 2) We need to complete on the possibilities coming after - the command. - 2) We need to complete the text of what comes after the - command. */ - - if (!*p && *text) - /* Always (might be longer versions of thie command). */ - list = complete_on_cmdlist (result_list, text); - else if (!*p && !*text) - { - if (c->prefixlist) - list = complete_on_cmdlist (*c->prefixlist, ""); - else - list = make_symbol_completion_list (""); - } - else - { - if (c->prefixlist && !c->allow_unknown) - { - *p = '\0'; - error ("\"%s\" command requires a subcommand.", - tmp_command); - } - else - list = make_symbol_completion_list (text); - } - } - } - - /* If the debugged program wasn't compiled with symbols, or if we're - clearly completing on a command and no command matches, return - NULL. */ - if (!list) - return ((char *)NULL); - - output = list[index]; - if (output) - index++; - - return (output); -} - - -void -print_prompt () -{ - if (prompt) - { - printf ("%s", prompt); - fflush (stdout); - } -} - - -#ifdef HAVE_TERMIO -#include -static struct termio norm_tty; - -static void -suspend_sig() -{ - int tty = fileno(stdin); - struct termio cur_tty; - - ioctl(tty, TCGETA, &cur_tty); - ioctl(tty, TCSETAW, &norm_tty); - - (void) sigsetmask(0); - signal(SIGTSTP, SIG_DFL); - kill(0, SIGTSTP); - - /* - * we've just been resumed -- current tty params become new - * 'normal' params (in case tset/stty was done while we were - * suspended). Merge values that readline might have changed - * into new params, then restore term mode. - */ - ioctl(tty, TCGETA, &norm_tty); - cur_tty.c_lflag = (cur_tty.c_lflag & (ICANON|ECHO|ISIG)) | - (norm_tty.c_lflag &~ (ICANON|ECHO|ISIG)); - cur_tty.c_iflag = (cur_tty.c_iflag & (IXON|ISTRIP|INPCK)) | - (norm_tty.c_iflag &~ (IXON|ISTRIP|INPCK)); - ioctl(tty, TCSETAW, &cur_tty); - - signal(SIGTSTP, suspend_sig); - print_prompt(); - - /* - * Forget about any previous command -- null line now will do - * nothing. - */ - dont_repeat(); -} - -#else - -#include -#include -#include - -static struct sgttyb norm_tty; -static struct tchars norm_tchars; -static struct ltchars norm_ltchars; -static int norm_lflags; - -#ifdef PASS8 -#define RL_TFLAGS (RAW|CRMOD|ECHO|CBREAK|PASS8) -#else -#define RL_TFLAGS (RAW|CRMOD|ECHO|CBREAK) -#endif - -static void -suspend_sig() -{ - int tty = fileno(stdin); - struct sgttyb cur_tty; - struct tchars cur_tchars; - struct ltchars cur_ltchars; - int cur_lflags; - int cur_flags; - - ioctl(tty, TIOCGETP, &cur_tty); - ioctl(tty, TIOCGETC, &cur_tchars); - ioctl(tty, TIOCLGET, &cur_lflags); - ioctl(tty, TIOCGLTC, &cur_ltchars); - - ioctl(tty, TIOCSETP, &norm_tty); - ioctl(tty, TIOCSETC, &norm_tchars); - ioctl(tty, TIOCLSET, &norm_lflags); - ioctl(tty, TIOCSLTC, &norm_ltchars); - - (void) sigsetmask(0); - signal(SIGTSTP, SIG_DFL); - kill(0, SIGTSTP); - - /* - * we've just been resumed -- current tty params become new - * 'normal' params (in case tset/stty was done while we were - * suspended). Merge values that readline might have changed - * into new params, then restore term mode. - */ - ioctl(tty, TIOCGETP, &norm_tty); - cur_flags = cur_tty.sg_flags; - cur_tty = norm_tty; - cur_tty.sg_flags = (cur_tty.sg_flags &~ RL_TFLAGS) - | (cur_flags & RL_TFLAGS); - - ioctl(tty, TIOCLGET, &norm_lflags); -#ifdef LPASS8 - cur_lflags = (cur_lflags &~ LPASS8) | (cur_flags & LPASS8); -#endif - ioctl(tty, TIOCGETC, &norm_tchars); - ioctl(tty, TIOCGLTC, &norm_ltchars); - - ioctl(tty, TIOCSETP, &cur_tty); - ioctl(tty, TIOCSETC, &cur_tchars); - ioctl(tty, TIOCLSET, &cur_lflags); - ioctl(tty, TIOCSLTC, &cur_ltchars); - - signal(SIGTSTP, suspend_sig); - print_prompt(); - - /* - * Forget about any previous command -- null line now will do - * nothing. - */ - dont_repeat(); -} -#endif /* HAVE_TERMIO */ - -/* Initialize signal handlers. */ -initialize_signals () -{ - extern void request_quit (); - int tty = fileno(stdin); - - signal (SIGINT, request_quit); - - /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get - passed to the inferior, which we don't want. It would be - possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but - on BSD4.3 systems using vfork, that will (apparently) affect the - GDB process as well as the inferior (the signal handling tables - being shared between the two, apparently). Since we establish - a handler for SIGQUIT, when we call exec it will set the signal - to SIG_DFL for us. */ - signal (SIGQUIT, do_nothing); - if (signal (SIGHUP, do_nothing) != SIG_IGN) - signal (SIGHUP, disconnect); - signal (SIGFPE, float_handler); - - ioctl(tty, TIOCGETP, &norm_tty); - ioctl(tty, TIOCLGET, &norm_lflags); - ioctl(tty, TIOCGETC, &norm_tchars); - ioctl(tty, TIOCGLTC, &norm_ltchars); - signal(SIGTSTP, suspend_sig); -} - -char * -finish_command_input(inputline, repeat, interactive) - register char *inputline; - int repeat; - int interactive; -{ - static char *do_free; - - if (do_free) { - free(do_free); - do_free = NULL; - } - - /* Do history expansion if that is wished. */ - if (interactive && history_expansion_p) { - int expanded; - - expanded = history_expand(inputline, &do_free); - if (expanded) { - /* Print the changes. */ - puts(do_free); - - /* An error acts like no input. */ - if (expanded < 0) { - *do_free = 0; - return (do_free); - } - } - inputline = do_free; - } - /* get rid of any leading whitespace */ - while (isspace(*inputline)) - ++inputline; - /* - * If we just got an empty line, and that is supposed to repeat the - * previous command, return the value in the global buffer. - */ - if (*inputline == 0) { - if (repeat) - return (line); - } else if (interactive) - add_history(inputline); - - /* - * If line is a comment, clear it out. - * Note: comments are added to the command history. This is useful - * when you type a command, and then realize you don't want to - * execute it quite yet. You can comment out the command and then - * later fetch it from the value history and remove the '#'. - */ - if (*inputline == '#') - *inputline = 0; - else if (repeat) { - /* Save into global buffer. */ - register int i = strlen(inputline) + 1; - - if (i > linesize) { - line = xrealloc(line, i); - linesize = i; - } - strcpy(line, inputline); - } - return (inputline); -} - -static char * -get_a_cmd_line(prompt, interactive) - char *prompt; - int interactive; -{ - register char *cp; - - /* Control-C quits instantly if typed while reading input. */ - immediate_quit++; - if (interactive && command_editing_p) { - extern void (*rl_event_hook)(); - - rl_event_hook = window_hook; - cp = readline(prompt); - } else { - if (interactive) { - if (window_hook) { - print_prompt(); - (*window_hook)(); - } - } else - prompt = NULL; - cp = gdb_readline(prompt); - } - --immediate_quit; - return (cp); -} - -/* Read one line from the command input stream `instream' - Returns the address of the start of the line. - - *If* the instream == stdin & stdin is a terminal, the line read - is copied into the file line saver (global var char *line, - length linesize) so that it can be duplicated. - - This routine either uses fancy command line editing or - simple input as the user has requested. */ - -char * -command_line_input(prompt, repeat) - char *prompt; - int repeat; -{ - static char *do_free; - register int interactive = (instream == stdin && ISATTY(instream)); - register char *cp; - register int i; - - if (do_free) { - free(do_free); - do_free = NULL; - } - cp = get_a_cmd_line(prompt, interactive); - - /* - * handle continued lines (this loop is not particularly - * efficient because it's rare). - */ - while (cp && cp[i = strlen(cp) - 1] == '\\') { - register char *np = get_a_cmd_line(prompt, interactive); - register int j; - - if (np == NULL) { - cp[i] = 0; - break; - } - j = strlen(np); - cp = xrealloc(cp, i + j + 1); - strcpy(cp + i, np); - free(np); - } - if (cp == NULL) - return (""); - do_free = cp; - return (finish_command_input(cp, repeat, interactive)); -} - - -#define MAX_USER_ARGS 32 - -static struct user_args { - struct { - char *arg; - int len; - } a[10]; -} uargs[MAX_USER_ARGS]; - -static struct user_args *user_arg = uargs; - -static void -arg_cleanup(ap) - struct user_args *ap; -{ - user_arg = ap; -} - -/* Bind arguments $arg0, $arg1, ..., for a user defined command. */ -struct cleanup * -setup_user_args(p) - char *p; -{ - register int i; - struct cleanup *old_chain = make_cleanup(arg_cleanup, user_arg); - - if (++user_arg >= &uargs[MAX_USER_ARGS]) - error("user defined functions nested too deeply\n"); - - bzero(user_arg, sizeof(*user_arg)); - - i = 0; - while (*p) { - while (isspace(*p)) - ++p; - user_arg->a[i].arg = p; - while (*p && ! isspace(*p)) - ++p; - user_arg->a[i].len = p - user_arg->a[i].arg; - ++i; - } - return (old_chain); -} - -static char * -findarg(str) - register char *str; -{ - register char *cp = str; - extern char *index(); - - while (cp = index(cp, '$')) { - if (strncmp(cp, "$arg", 4) == 0 && isdigit(cp[4])) - return (cp); - ++cp; - } - return (char *)0; -} - -/* expand arguments from "line" into "new" */ -static void -expand_args(line, new) - register char *line, *new; -{ - register char *cp = findarg(line); - - while (cp = findarg(line)) { - int i, len; - - bcopy(line, new, cp - line); - new += cp - line; - i = cp[4] - '0'; - if (len = user_arg->a[i].len) { - bcopy(user_arg->a[i].arg, new, len); - new += len; - } - line = cp + 5; - } - strcpy(new, line); -} - -/* expand any arguments in "line" then execute the result */ -static void -expand_and_execute(line, from_tty) - char *line; - int from_tty; -{ - void execute_command(); - char new[1024]; - - if (! findarg(line)) { - execute_command(line, from_tty); - return; - } - expand_args(line, new); - execute_command(new, from_tty); -} - -char * -read_one_command_line(prompt, from_tty) - char *prompt; -{ - register char *p, *p1; - - dont_repeat(); - p = command_line_input(prompt, from_tty); - - /* Remove trailing blanks. */ - p1 = p + strlen(p); - while (--p1 > p && (*p1 == ' ' || *p1 == '\t')) - ; - *++p1 = 0; - return (p); -} - -static char cmd_prompt[] = " > "; - -int -parse_control_structure(rootcmd, from_tty, level) - struct command_line *rootcmd; - int from_tty; -{ - struct command_line *cmd = (struct command_line *)xmalloc(sizeof(*cmd)); - char *prompt; - - ++level; - prompt = from_tty? &cmd_prompt[sizeof(cmd_prompt) - 1 - 2*level] : - (char *)0; - bzero(cmd, sizeof(*cmd)); - rootcmd->body = cmd; - while (1) { - char *p = read_one_command_line(prompt, from_tty); - - p = savestring(p, strlen(p)); - cmd->line = p; - if (!strncmp(p, "while ", 6)) { - cmd->type = CL_WHILE; - if (parse_control_structure(cmd, from_tty, level)) - return (1); - } else if (!strncmp(p, "if ", 3)) { - cmd->type = CL_IF; - if (parse_control_structure(cmd, from_tty, level)) { - struct command_line *tmp; - int stat; - - cmd->elsebody = cmd->body; - stat = parse_control_structure(cmd, from_tty, - level); - tmp = cmd->elsebody; - cmd->elsebody = cmd->body; - cmd->body = tmp; - if (stat) - return (1); - } - } else if (!strcmp(p, "else")) { - cmd->type = CL_END; - return (1); - } else if (!strcmp(p, "end")) { - cmd->type = CL_END; - return (0); - } else if (!strcmp(p, "exitloop")) { - cmd->type = CL_EXITLOOP; - } else { - cmd->type = CL_NORMAL; - } - cmd->next = (struct command_line *)xmalloc(sizeof(*cmd)); - cmd = cmd->next; - bzero(cmd, sizeof(*cmd)); - } - /* NOTREACHED */ -} - -int -execute_control_structure(cmd) - register struct command_line *cmd; -{ - char expn[1024]; - struct expression *cond; - int stat; - - while (cmd) { - QUIT; - switch (cmd->type) { - case CL_END: - return (0); - case CL_NORMAL: - expand_and_execute(cmd->line, 0); - break; - case CL_WHILE: - expand_args(cmd->line + 6, expn); - cond = parse_c_expression(expn); - while (breakpoint_cond_eval(cond) == 0) - if (execute_control_structure(cmd->body)) - break; - free(cond); - break; - case CL_IF: - expand_args(cmd->line + 3, expn); - cond = parse_c_expression(expn); - stat = breakpoint_cond_eval(cond); - free(cond); - if (stat == 0) { - if (execute_control_structure(cmd->body)) - return (1); - } else if (cmd->elsebody) { - if (execute_control_structure(cmd->elsebody)) - return (1); - } - break; - case CL_EXITLOOP: - return (1); - } - cmd = cmd->next; - } - free_all_values(); -} - -execute_command_lines(cmd) - struct command_line *cmd; -{ - struct cleanup *old_chain = make_cleanup(source_cleanup, instream); - - /* - * Set the instream to 0, indicating execution of a user-defined - * function. - */ - ++immediate_quit; - instream = (FILE *) 0; - (void)execute_control_structure(cmd); - --immediate_quit; - do_cleanups(old_chain); -} - -/* do following command lines if expression true */ -if_command(p, from_tty) - char *p; - int from_tty; -{ - struct cleanup *old_chain; - struct command_line *cmd = (struct command_line *)xmalloc(sizeof(*cmd)); - char buf[128]; - - sprintf(buf, "if %s", p); - - bzero(cmd, sizeof(*cmd)); - old_chain = make_cleanup(free_command_lines, cmd); - cmd->type = CL_IF; - cmd->line = savestring(buf, strlen(buf)); - /* XXX cmd->line? */ - if (parse_control_structure(cmd, from_tty, 0)) { - struct command_line *tmp; - - cmd->elsebody = cmd->body; - (void) parse_control_structure(cmd, from_tty, 0); - tmp = cmd->elsebody; - cmd->elsebody = cmd->body; - cmd->body = tmp; - } - (void) execute_command_lines(cmd); - do_cleanups(old_chain); -} - -/* do following command lines while expression true */ -while_command(p, from_tty) - char *p; - int from_tty; -{ - struct cleanup *old_chain; - struct command_line *cmd = (struct command_line *)xmalloc(sizeof(*cmd)); - char buf[128]; - - sprintf(buf, "while %s", p); - - bzero(cmd, sizeof(*cmd)); - old_chain = make_cleanup(free_command_lines, cmd); - cmd->type = CL_WHILE; - cmd->line = savestring(buf, strlen(buf)); - (void)parse_control_structure(cmd, from_tty, 0); - (void)execute_command_lines(cmd); - do_cleanups(old_chain); -} - -/* - * Execute the line P as a command. - * Pass FROM_TTY as second argument to the defining function. - */ -void -execute_command (p, from_tty) - char *p; - int from_tty; -{ - register struct cmd_list_element *c; - register struct command_line *cmdlines; - - free_all_values(); - if (*p) { - c = lookup_cmd(&p, cmdlist, "", 0, 1); - if (c->function == 0) - error("That is not a command, just a help topic."); - else if (c->class == (int) class_user) { - struct cleanup *old_chain = setup_user_args(p); - - cmdlines = (struct command_line *) c->function; - if (cmdlines) - (void)execute_command_lines(cmdlines); - - do_cleanups(old_chain); - } else - /* Pass null arg rather than an empty one. */ - (*c->function) (*p ? p : 0, from_tty); - } -} - -/* - * Read lines from the input stream and accumulate them in a chain of struct - * command_line's which is then returned. - */ -struct command_line * -read_command_lines(from_tty) - int from_tty; -{ - struct cleanup *old_chain; - struct command_line *cmd = (struct command_line *)xmalloc(sizeof(*cmd)); - struct command_line *next; - - bzero(cmd, sizeof(*cmd)); - old_chain = make_cleanup(free_command_lines, cmd); - cmd->type = CL_NOP; - (void)parse_control_structure(cmd, from_tty, 0); - dont_repeat(); - discard_cleanups(old_chain); - next = cmd->body; - free(cmd); - return (next); -} - -/* Free a chain of struct command_line's. */ - -void -free_command_lines(cmds) - struct command_line *cmds; -{ - struct command_line *next; - - while (cmds) { - if (cmds->body) - free(cmds->body); - if (cmds->elsebody) - free(cmds->elsebody); - if (cmds->line) - free(cmds->line); - next = cmds->next; - free(cmds); - cmds = next; - } -} - -/* Add an element to the list of info subcommands. */ - -void -add_info (name, fun, doc) - char *name; - void (*fun) (); - char *doc; -{ - add_cmd (name, no_class, fun, doc, &infolist); -} - -/* Add an alias to the list of info subcommands. */ - -void -add_info_alias (name, oldname, abbrev_flag) - char *name; - char *oldname; - int abbrev_flag; -{ - add_alias_cmd (name, oldname, 0, abbrev_flag, &infolist); -} - -/* The "info" command is defined as a prefix, with allow_unknown = 0. - Therefore, its own definition is called only for "info" with no args. */ - -static void -info_command () -{ - printf ("\"info\" must be followed by the name of an info command.\n"); - help_list (infolist, "info ", -1, stdout); -} - -/* Add an element to the list of commands. */ - -void -add_com (name, class, fun, doc) - char *name; - int class; - void (*fun) (); - char *doc; -{ - add_cmd (name, class, fun, doc, &cmdlist); -} - -/* Add an alias or abbreviation command to the list of commands. */ - -void -add_com_alias (name, oldname, class, abbrev_flag) - char *name; - char *oldname; - int class; - int abbrev_flag; -{ - add_alias_cmd (name, oldname, class, abbrev_flag, &cmdlist); -} - -void -error_no_arg (why) - char *why; -{ - error ("Argument required (%s).", why); -} - -static void -help_command (command, from_tty) - char *command; - int from_tty; /* Ignored */ -{ - help_cmd (command, stdout); -} - -static void -validate_comname (comname) - char *comname; -{ - register char *p; - - if (comname == 0) - error_no_arg ("name of command to define"); - - p = comname; - while (*p) - { - if (!(*p >= 'A' && *p <= 'Z') - && !(*p >= 'a' && *p <= 'z') - && !(*p >= '0' && *p <= '9') - && *p != '-') - error ("Junk in argument list: \"%s\"", p); - p++; - } -} - -static void -define_command (comname, from_tty) - char *comname; - int from_tty; -{ - register struct command_line *cmds; - register struct cmd_list_element *c; - char *tem = comname; - - validate_comname (comname); - - c = lookup_cmd (&tem, cmdlist, "", -1, 1); - if (c) - { - if (c->class == (int) class_user || c->class == (int) class_alias) - tem = "Redefine command \"%s\"? "; - else - tem = "Really redefine built-in command \"%s\"? "; - if (!query (tem, comname)) - error ("Command \"%s\" not redefined.", comname); - } - - if (from_tty) - { - printf ("Type commands for definition of \"%s\".\n\ -End with a line saying just \"end\".\n", comname); - fflush (stdout); - } - comname = savestring (comname, strlen (comname)); - - cmds = read_command_lines (from_tty); - - if (c && c->class == (int) class_user) - free_command_lines (c->function); - - add_com (comname, class_user, cmds, - (c && c->class == (int) class_user) - ? c->doc : savestring ("User-defined.", 13)); -} - -static void -document_command (comname, from_tty) - char *comname; - int from_tty; -{ - register struct cmd_list_element *c; - register char *p; - register char *cp; - register char *doc = 0; - register int len; - char *tmp = comname; - - validate_comname (comname); - c = lookup_cmd (&tmp, cmdlist, "", 0, 1); - if (c->class != (int) class_user) - error ("Command \"%s\" is built-in.", comname); - - if (from_tty) - printf ("Type documentation for \"%s\". \ -End with a line saying just \"end\".\n", comname); - - while (p = read_one_command_line(from_tty? "> " : 0, from_tty)) - { - if (strcmp(p, "end") == 0) - break; - len = strlen(p) + 1; - if (! doc) - { - doc = xmalloc(len); - cp = doc; - } - else - { - int i = cp - doc; - doc = xrealloc(doc, i + len); - cp = doc + i; - } - strcpy(cp, p); - cp += len; - cp[-1] = '\n'; - } - if (doc && cp > doc) - cp[-1] = 0; - if (c->doc) - free (c->doc); - c->doc = doc; -} - -static void -print_gdb_version () -{ - printf ("GDB %s, Copyright (C) 1989 Free Software Foundation, Inc.\n\ -There is ABSOLUTELY NO WARRANTY for GDB; type \"info warranty\" for details.\n\ -GDB is free software and you are welcome to distribute copies of it\n\ - under certain conditions; type \"info copying\" to see the conditions.\n", - version); -} - -static void -version_info () -{ - immediate_quit++; - print_gdb_version (); - immediate_quit--; -} - - -/* Command to specify a prompt string instead of "(gdb) ". */ - -void -set_prompt_command (text) - char *text; -{ - char *p, *q; - register int c; - char *new; - - if (text == 0) - error_no_arg ("string to which to set prompt"); - - new = (char *) xmalloc (strlen (text) + 2); - p = text; q = new; - while (c = *p++) - { - if (c == '\\') - { - /* \ at end of argument is used after spaces - so they won't be lost. */ - if (*p == 0) - break; - c = parse_escape (&p); - if (c == 0) - break; /* C loses */ - else if (c > 0) - *q++ = c; - } - else - *q++ = c; - } - if (*(p - 1) != '\\') - *q++ = ' '; - *q++ = '\0'; - new = (char *) xrealloc (new, q - new); - free (prompt); - prompt = new; -} - -static void -quit_command () -{ - extern void exec_file_command (); - if (have_inferior_p ()) - { - if (inhibit_confirm || query ("The program is running. Quit anyway? ")) - { - /* Prevent any warning message from reopen_exec_file, in case - we have a core file that's inconsistent with the exec file. */ - exec_file_command (0, 0); - kill_inferior (); - } - else - error ("Not confirmed."); - } - /* Save the history information if it is appropriate to do so. */ - if (write_history_p && history_filename) - write_history (history_filename); - exit (0); -} - -int -input_from_terminal_p () -{ - return instream == stdin; -} - -static void -pwd_command (arg, from_tty) - char *arg; - int from_tty; -{ - if (arg) error ("The \"pwd\" command does not take an argument: %s", arg); - getwd (dirbuf); - - if (strcmp (dirbuf, current_directory)) - printf ("Working directory %s\n (canonically %s).\n", - current_directory, dirbuf); - else - printf ("Working directory %s.\n", current_directory); -} - -static void -cd_command (dir, from_tty) - char *dir; - int from_tty; -{ - int len; - int change; - - if (dir == 0) - error_no_arg ("new working directory"); - - dir = tilde_expand (dir); - make_cleanup (free, dir); - - len = strlen (dir); - dir = savestring (dir, len - (len > 1 && dir[len-1] == '/')); - if (dir[0] == '/') - current_directory = dir; - else - { - current_directory = concat (current_directory, "/", dir); - free (dir); - } - - /* Now simplify any occurrences of `.' and `..' in the pathname. */ - - change = 1; - while (change) - { - char *p; - change = 0; - - for (p = current_directory; *p;) - { - if (!strncmp (p, "/./", 2) - && (p[2] == 0 || p[2] == '/')) - strcpy (p, p + 2); - else if (!strncmp (p, "/..", 3) - && (p[3] == 0 || p[3] == '/') - && p != current_directory) - { - char *q = p; - while (q != current_directory && q[-1] != '/') q--; - if (q != current_directory) - { - strcpy (q-1, p+3); - p = q-1; - } - } - else p++; - } - } - - if (chdir (dir) < 0) - perror_with_name (dir); - - if (from_tty) - pwd_command ((char *) 0, 1); -} - -static void -source_command (arg, from_tty) - char *arg; - int from_tty; -{ - FILE *stream; - struct cleanup *cleanups; - char *file = arg; - char *path; - - if (file == 0) - /* Let source without arguments read .gdbinit. */ - file = ".gdbinit"; - - file = tilde_expand (file); - make_cleanup (free, file); - -#ifdef KERNELDEBUG - if (path = getenv(kernel_debugging? "KGDBPATH" : "GDBPATH")) -#else - if (path = getenv("GDBPATH")) -#endif - { - int fd = openp(path, 1, file, O_RDONLY, 0, 0); - - if (fd == -1) - stream = 0; - else - stream = fdopen(fd, "r"); - } - else - stream = fopen (file, "r"); - - if (stream == 0) - perror_with_name (file); - - cleanups = make_cleanup (source_cleanup, instream); - - instream = stream; - - command_loop (); - - do_cleanups (cleanups); -} - -static void -echo_command (text) - char *text; -{ - char *p = text; - register int c; - - if (text) - while (c = *p++) - { - if (c == '\\') - { - /* \ at end of argument is used after spaces - so they won't be lost. */ - if (*p == 0) - return; - - c = parse_escape (&p); - if (c >= 0) - fputc (c, stdout); - } - else - fputc (c, stdout); - } - fflush(stdout); -} - -static void -dump_me_command () -{ - if (query ("Should GDB dump core? ")) - { - signal (SIGQUIT, SIG_DFL); - kill (getpid (), SIGQUIT); - } -} - -int -parse_binary_operation (caller, arg) - char *caller, *arg; -{ - int length; - - if (!arg || !*arg) - return 1; - - length = strlen (arg); - - while (arg[length - 1] == ' ' || arg[length - 1] == '\t') - length--; - - if (!strncmp (arg, "on", length) - || !strncmp (arg, "1", length) - || !strncmp (arg, "yes", length)) - return 1; - else - if (!strncmp (arg, "off", length) - || !strncmp (arg, "0", length) - || !strncmp (arg, "no", length)) - return 0; - else - error ("\"%s\" not given a binary valued argument.", caller); -} - -/* Functions to manipulate command line editing control variables. */ - -static void -set_editing (arg, from_tty) - char *arg; - int from_tty; -{ - command_editing_p = parse_binary_operation ("set command-editing", arg); -} - -/* Number of commands to print in each call to editing_info. */ -#define Hist_print 10 -static void -editing_info (arg, from_tty) - char *arg; - int from_tty; -{ - /* Index for history commands. Relative to history_base. */ - int offset; - - /* Number of the history entry which we are planning to display next. - Relative to history_base. */ - static int num = 0; - - /* The first command in the history which doesn't exist (i.e. one more - than the number of the last command). Relative to history_base. */ - int hist_len; - - struct _hist_entry { - char *line; - char *data; - } *history_get(); - extern int history_base; - - printf_filtered ("Interactive command editing is %s.\n", - command_editing_p ? "on" : "off"); - - printf_filtered ("History expansion of command input is %s.\n", - history_expansion_p ? "on" : "off"); - printf_filtered ("Writing of a history record upon exit is %s.\n", - write_history_p ? "enabled" : "disabled"); - printf_filtered ("The size of the history list (number of stored commands) is %d.\n", - history_size); - printf_filtered ("The name of the history record is \"%s\".\n\n", - history_filename ? history_filename : ""); - - /* Print out some of the commands from the command history. */ - /* First determine the length of the history list. */ - hist_len = history_size; - for (offset = 0; offset < history_size; offset++) - { - if (!history_get (history_base + offset)) - { - hist_len = offset; - break; - } - } - - if (arg) - { - if (arg[0] == '+' && arg[1] == '\0') - /* "info editing +" should print from the stored position. */ - ; - else - /* "info editing " should print around command number . */ - num = (parse_and_eval_address (arg) - history_base) - Hist_print / 2; - } - /* "info editing" means print the last Hist_print commands. */ - else - { - num = hist_len - Hist_print; - } - - if (num < 0) - num = 0; - - /* If there are at least Hist_print commands, we want to display the last - Hist_print rather than, say, the last 6. */ - if (hist_len - num < Hist_print) - { - num = hist_len - Hist_print; - if (num < 0) - num = 0; - } - - if (num == hist_len - Hist_print) - printf_filtered ("The list of the last %d commands is:\n\n", Hist_print); - else - printf_filtered ("Some of the stored commands are:\n\n"); - - for (offset = num; offset < num + Hist_print && offset < hist_len; offset++) - { - printf_filtered ("%5d %s\n", history_base + offset, - (history_get (history_base + offset))->line); - } - - /* The next command we want to display is the next one that we haven't - displayed yet. */ - num += Hist_print; - - /* If the user repeats this command with return, it should do what - "info editing +" does. This is unnecessary if arg is null, - because "info editing +" is not useful after "info editing". */ - if (from_tty && arg) - { - arg[0] = '+'; - arg[1] = '\0'; - } -} - -static void -set_history_expansion (arg, from_tty) - char *arg; - int from_tty; -{ - history_expansion_p = parse_binary_operation ("set history expansion", arg); -} - -static void -set_history_write (arg, from_tty) - char *arg; - int from_tty; -{ - write_history_p = parse_binary_operation ("set history write", arg); -} - -static void -set_history (arg, from_tty) - char *arg; - int from_tty; -{ - printf ("\"set history\" must be followed by the name of a history subcommand.\n"); - help_list (sethistlist, "set history ", -1, stdout); -} - -static void -set_history_size (arg, from_tty) - char *arg; - int from_tty; -{ - if (!*arg) - error_no_arg ("set history size"); - - history_size = atoi (arg); -} - -static void -set_history_filename (arg, from_tty) - char *arg; - int from_tty; -{ - int i; - - if (!arg) - error_no_arg ("history file name"); - - arg = tilde_expand (arg); - make_cleanup (free, arg); - - i = strlen (arg) - 1; - - free (history_filename); - - while (i > 0 && (arg[i] == ' ' || arg[i] == '\t')) - i--; - ++i; - - if (!*arg) - history_filename = (char *) 0; - else - history_filename = savestring (arg, i + 1); - history_filename[i] = '\0'; -} - -int info_verbose; - -static void -set_verbose_command (arg, from_tty) - char *arg; - int from_tty; -{ - info_verbose = parse_binary_operation ("set verbose", arg); -} - -static void -verbose_info (arg, from_tty) - char *arg; - int from_tty; -{ - if (arg) - error ("\"info verbose\" does not take any arguments.\n"); - - printf ("Verbose printing of information is %s.\n", - info_verbose ? "on" : "off"); -} - -static void -float_handler () -{ - error ("Invalid floating value encountered or computed."); -} - - -static void -initialize_cmd_lists () -{ - cmdlist = (struct cmd_list_element *) 0; - infolist = (struct cmd_list_element *) 0; - enablelist = (struct cmd_list_element *) 0; - disablelist = (struct cmd_list_element *) 0; - deletelist = (struct cmd_list_element *) 0; - enablebreaklist = (struct cmd_list_element *) 0; - setlist = (struct cmd_list_element *) 0; - sethistlist = (struct cmd_list_element *) 0; - unsethistlist = (struct cmd_list_element *) 0; -} - -static void -initialize_main () -{ - char *tmpenv; - /* Command line editing externals. */ - extern int (*rl_completion_entry_function)(); - extern char *rl_completer_word_break_characters; - extern char *rl_readline_name; - - /* Set default verbose mode on. */ - info_verbose = 1; - -#ifdef KERNELDEBUG - if (kernel_debugging) - prompt = savestring ("(kgdb) ", 7); - else -#endif - prompt = savestring ("(gdb) ", 6); - - /* Set the important stuff up for command editing. */ - command_editing_p = 1; - history_expansion_p = 0; - write_history_p = 0; - - if (tmpenv = getenv ("HISTSIZE")) - history_size = atoi (tmpenv); - else - history_size = 256; - - stifle_history (history_size); - - if (tmpenv = getenv ("GDBHISTFILE")) - history_filename = savestring (tmpenv, strlen(tmpenv)); - else - /* We include the current directory so that if the user changes - directories the file written will be the same as the one - that was read. */ - history_filename = concat (current_directory, "/.gdb_history", ""); - - read_history (history_filename); - - /* Setup important stuff for command line editing. */ - rl_completion_entry_function = (int (*)()) symbol_completion_function; - rl_completer_word_break_characters = gdb_completer_word_break_characters; - rl_readline_name = "gdb"; - - /* Define the classes of commands. - They will appear in the help list in the reverse of this order. */ - - add_cmd ("obscure", class_obscure, 0, "Obscure features.", &cmdlist); - add_cmd ("alias", class_alias, 0, "Aliases of other commands.", &cmdlist); - add_cmd ("user", class_user, 0, "User-defined commands.\n\ -The commands in this class are those defined by the user.\n\ -Use the \"define\" command to define a command.", &cmdlist); - add_cmd ("support", class_support, 0, "Support facilities.", &cmdlist); - add_cmd ("status", class_info, 0, "Status inquiries.", &cmdlist); - add_cmd ("files", class_files, 0, "Specifying and examining files.", &cmdlist); - add_cmd ("breakpoints", class_breakpoint, 0, "Making program stop at certain points.", &cmdlist); - add_cmd ("data", class_vars, 0, "Examining data.", &cmdlist); - add_cmd ("stack", class_stack, 0, "Examining the stack.\n\ -The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\ -counting from zero for the innermost (currently executing) frame.\n\n\ -At any time gdb identifies one frame as the \"selected\" frame.\n\ -Variable lookups are done with respect to the selected frame.\n\ -When the program being debugged stops, gdb selects the innermost frame.\n\ -The commands below can be used to select other frames by number or address.", - &cmdlist); - add_cmd ("running", class_run, 0, "Running the program.", &cmdlist); - - add_com ("pwd", class_files, pwd_command, - "Print working directory. This is used for your program as well."); - add_com ("cd", class_files, cd_command, - "Set working directory to DIR for debugger and program being debugged.\n\ -The change does not take effect for the program being debugged\n\ -until the next time it is started."); - - add_cmd ("prompt", class_support, set_prompt_command, - "Change gdb's prompt from the default of \"(gdb)\"", - &setlist); - add_com ("echo", class_support, echo_command, - "Print a constant string. Give string as argument.\n\ -C escape sequences may be used in the argument.\n\ -No newline is added at the end of the argument;\n\ -use \"\\n\" if you want a newline to be printed.\n\ -Since leading and trailing whitespace are ignored in command arguments,\n\ -if you want to print some you must use \"\\\" before leading whitespace\n\ -to be printed or after trailing whitespace."); - add_com ("document", class_support, document_command, - "Document a user-defined command.\n\ -Give command name as argument. Give documentation on following lines.\n\ -End with a line of just \"end\"."); - add_com ("define", class_support, define_command, - "Define a new command name. Command name is argument.\n\ -Definition appears on following lines, one command per line.\n\ -End with a line of just \"end\".\n\ -Use the \"document\" command to give documentation for the new command.\n\ -Commands defined in this way do not take arguments."); - - add_com ("source", class_support, source_command, - "Read commands from a file named FILE.\n\ -Note that the file \".gdbinit\" is read automatically in this way\n\ -when gdb is started."); - add_com ("quit", class_support, quit_command, "Exit gdb."); - add_com ("help", class_support, help_command, "Print list of commands."); - add_com_alias ("q", "quit", class_support, 1); - add_com_alias ("h", "help", class_support, 1); - add_com ("while", class_support, while_command, - "execute following commands while condition is true.\n\ -Expression for condition follows \"while\" keyword."); - add_com ("if", class_support, if_command, - "execute following commands if condition is true.\n\ -Expression for condition follows \"if\" keyword."); - add_cmd ("verbose", class_support, set_verbose_command, - "Change the number of informational messages gdb prints.", - &setlist); - add_info ("verbose", verbose_info, - "Status of gdb's verbose printing option.\n"); - - add_com ("dump-me", class_obscure, dump_me_command, - "Get fatal error; make debugger dump its core."); - - add_cmd ("editing", class_support, set_editing, - "Enable or disable command line editing.\n\ -Use \"on\" to enable to enable the editing, and \"off\" to disable it.\n\ -Without an argument, command line editing is enabled.", &setlist); - - add_prefix_cmd ("history", class_support, set_history, - "Generic command for setting command history parameters.", - &sethistlist, "set history ", 0, &setlist); - - add_cmd ("expansion", no_class, set_history_expansion, - "Enable or disable history expansion on command input.\n\ -Without an argument, history expansion is enabled.", &sethistlist); - - add_cmd ("write", no_class, set_history_write, - "Enable or disable saving of the history record on exit.\n\ -Use \"on\" to enable to enable the saving, and \"off\" to disable it.\n\ -Without an argument, saving is enabled.", &sethistlist); - - add_cmd ("size", no_class, set_history_size, - "Set the size of the command history, \n\ -ie. the number of previous commands to keep a record of.", &sethistlist); - - add_cmd ("filename", no_class, set_history_filename, - "Set the filename in which to record the command history\n\ - (the list of previous commands of which a record is kept).", &sethistlist); - - add_prefix_cmd ("info", class_info, info_command, - "Generic command for printing status.", - &infolist, "info ", 0, &cmdlist); - add_com_alias ("i", "info", class_info, 1); - - add_info ("editing", editing_info, "Status of command editor."); - - add_info ("version", version_info, "Report what version of GDB this is."); -} diff --git a/gnu/usr.bin/gdb/obstack.c b/gnu/usr.bin/gdb/obstack.c deleted file mode 100644 index 5cbdd524c7b5..000000000000 --- a/gnu/usr.bin/gdb/obstack.c +++ /dev/null @@ -1,316 +0,0 @@ -/* obstack.c - subroutines used implicitly by object stack macros - Copyright (C) 1988 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 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, 675 Mass Ave, Cambridge, MA 02139, USA. - - -In other words, you are welcome to use, share and improve this program. -You are forbidden to forbid anyone else to use, share and improve -what you give them. Help stamp out software-hoarding! */ - -#ifndef lint -static char rcsid[] = "$Id: obstack.c,v 1.2 1993/08/02 17:41:04 mycroft Exp $"; -#endif /* not lint */ - -#include "obstack.h" - -#ifdef __STDC__ -#define POINTER void * -#else -#define POINTER char * -#endif - -/* Determine default alignment. */ -struct fooalign {char x; double d;}; -#define DEFAULT_ALIGNMENT ((char *)&((struct fooalign *) 0)->d - (char *)0) -/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. - But in fact it might be less smart and round addresses to as much as - DEFAULT_ROUNDING. So we prepare for it to do that. */ -union fooround {long x; double d;}; -#define DEFAULT_ROUNDING (sizeof (union fooround)) - -/* When we copy a long block of data, this is the unit to do it with. - On some machines, copying successive ints does not work; - in such a case, redefine COPYING_UNIT to `long' (if that works) - or `char' as a last resort. */ -#ifndef COPYING_UNIT -#define COPYING_UNIT int -#endif - -/* The non-GNU-C macros copy the obstack into this global variable - to avoid multiple evaluation. */ - -struct obstack *_obstack; - -/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). - Objects start on multiples of ALIGNMENT (0 means use default). - CHUNKFUN is the function to use to allocate chunks, - and FREEFUN the function to free them. */ - -void -_obstack_begin (h, size, alignment, chunkfun, freefun) - struct obstack *h; - int size; - int alignment; - POINTER (*chunkfun) (); - void (*freefun) (); -{ - register struct _obstack_chunk* chunk; /* points to new chunk */ - - if (alignment == 0) - alignment = DEFAULT_ALIGNMENT; - if (size == 0) - /* Default size is what GNU malloc can fit in a 4096-byte block. - Pick a number small enough that when rounded up to DEFAULT_ROUNDING - it is still smaller than 4096 - 4. */ - { - int extra = 4; - if (extra < DEFAULT_ROUNDING) - extra = DEFAULT_ROUNDING; - size = 4096 - extra; - } - - h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; - h->freefun = freefun; - h->chunk_size = size; - h->alignment_mask = alignment - 1; - - chunk = h->chunk = (*h->chunkfun) (h->chunk_size); - h->next_free = h->object_base = chunk->contents; - h->chunk_limit = chunk->limit - = (char *) chunk + h->chunk_size; - chunk->prev = 0; -} - -/* Allocate a new current chunk for the obstack *H - on the assumption that LENGTH bytes need to be added - to the current object, or a new object of length LENGTH allocated. - Copies any partial object from the end of the old chunk - to the beginning of the new one. */ - -void -_obstack_newchunk (h, length) - struct obstack *h; - int length; -{ - register struct _obstack_chunk* old_chunk = h->chunk; - register struct _obstack_chunk* new_chunk; - register long new_size; - register int obj_size = h->next_free - h->object_base; - register int i; - - /* Compute size for new chunk. */ - new_size = (obj_size + length) << 1; - if (new_size < h->chunk_size) - new_size = h->chunk_size; - - /* Allocate and initialize the new chunk. */ - new_chunk = h->chunk = (*h->chunkfun) (new_size); - new_chunk->prev = old_chunk; - new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; - - /* Move the existing object to the new chunk. - Word at a time is fast and is safe because these - structures are aligned at least that much. */ - for (i = (obj_size + sizeof (COPYING_UNIT) - 1) / sizeof (COPYING_UNIT) - 1; - i >= 0; i--) - ((COPYING_UNIT *)new_chunk->contents)[i] - = ((COPYING_UNIT *)h->object_base)[i]; - - h->object_base = new_chunk->contents; - h->next_free = h->object_base + obj_size; -} - -/* Return nonzero if object OBJ has been allocated from obstack H. - This is here for debugging. - If you use it in a program, you are probably losing. */ - -int -_obstack_allocated_p (h, obj) - struct obstack *h; - POINTER obj; -{ - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ - - lp = (h)->chunk; - while (lp != 0 && ((POINTER)lp > obj || (POINTER)(lp)->limit < obj)) - { - plp = lp -> prev; - lp = plp; - } - return lp != 0; -} - -/* Free objects in obstack H, including OBJ and everything allocate - more recently than OBJ. If OBJ is zero, free everything in H. */ - -void -#ifdef __STDC__ -#undef obstack_free -obstack_free (struct obstack *h, POINTER obj) -#else -_obstack_free (h, obj) - struct obstack *h; - POINTER obj; -#endif -{ - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ - - lp = (h)->chunk; - while (lp != 0 && ((POINTER)lp > obj || (POINTER)(lp)->limit < obj)) - { - plp = lp -> prev; - (*h->freefun) (lp); - lp = plp; - } - if (lp) - { - (h)->object_base = (h)->next_free = (char *)(obj); - (h)->chunk_limit = lp->limit; - (h)->chunk = lp; - } - else if (obj != 0) - /* obj is not in any of the chunks! */ - abort (); -} - -/* Let same .o link with output of gcc and other compilers. */ - -#ifdef __STDC__ -void -_obstack_free (h, obj) - struct obstack *h; - POINTER obj; -{ - obstack_free (h, obj); -} -#endif - -#if 0 -/* These are now turned off because the applications do not use it - and it uses bcopy via obstack_grow, which causes trouble on sysV. */ - -/* Now define the functional versions of the obstack macros. - Define them to simply use the corresponding macros to do the job. */ - -#ifdef __STDC__ -/* These function definitions do not work with non-ANSI preprocessors; - they won't pass through the macro names in parentheses. */ - -/* The function names appear in parentheses in order to prevent - the macro-definitions of the names from being expanded there. */ - -POINTER (obstack_base) (obstack) - struct obstack *obstack; -{ - return obstack_base (obstack); -} - -POINTER (obstack_next_free) (obstack) - struct obstack *obstack; -{ - return obstack_next_free (obstack); -} - -int (obstack_object_size) (obstack) - struct obstack *obstack; -{ - return obstack_object_size (obstack); -} - -int (obstack_room) (obstack) - struct obstack *obstack; -{ - return obstack_room (obstack); -} - -void (obstack_grow) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - obstack_grow (obstack, pointer, length); -} - -void (obstack_grow0) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - obstack_grow0 (obstack, pointer, length); -} - -void (obstack_1grow) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow (obstack, character); -} - -void (obstack_blank) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank (obstack, length); -} - -void (obstack_1grow_fast) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow_fast (obstack, character); -} - -void (obstack_blank_fast) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank_fast (obstack, length); -} - -POINTER (obstack_finish) (obstack) - struct obstack *obstack; -{ - return obstack_finish (obstack); -} - -POINTER (obstack_alloc) (obstack, length) - struct obstack *obstack; - int length; -{ - return obstack_alloc (obstack, length); -} - -POINTER (obstack_copy) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - return obstack_copy (obstack, pointer, length); -} - -POINTER (obstack_copy0) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - return obstack_copy0 (obstack, pointer, length); -} - -#endif /* __STDC__ */ - -#endif /* 0 */ diff --git a/gnu/usr.bin/gdb/obstack.h b/gnu/usr.bin/gdb/obstack.h deleted file mode 100644 index 3098b5390bb9..000000000000 --- a/gnu/usr.bin/gdb/obstack.h +++ /dev/null @@ -1,375 +0,0 @@ -/* obstack.h - object stack macros - Copyright (C) 1988 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 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, 675 Mass Ave, Cambridge, MA 02139, USA. - - -In other words, you are welcome to use, share and improve this program. -You are forbidden to forbid anyone else to use, share and improve -what you give them. Help stamp out software-hoarding! - - $Id: obstack.h,v 1.2 1993/08/02 17:41:05 mycroft Exp $ -*/ - - -/* Summary: - -All the apparent functions defined here are macros. The idea -is that you would use these pre-tested macros to solve a -very specific set of problems, and they would run fast. -Caution: no side-effects in arguments please!! They may be -evaluated MANY times!! - -These macros operate a stack of objects. Each object starts life -small, and may grow to maturity. (Consider building a word syllable -by syllable.) An object can move while it is growing. Once it has -been "finished" it never changes address again. So the "top of the -stack" is typically an immature growing object, while the rest of the -stack is of mature, fixed size and fixed address objects. - -These routines grab large chunks of memory, using a function you -supply, called `obstack_chunk_alloc'. On occasion, they free chunks, -by calling `obstack_chunk_free'. You must define them and declare -them before using any obstack macros. - -Each independent stack is represented by a `struct obstack'. -Each of the obstack macros expects a pointer to such a structure -as the first argument. - -One motivation for this package is the problem of growing char strings -in symbol tables. Unless you are "facist pig with a read-only mind" -[Gosper's immortal quote from HAKMEM item 154, out of context] you -would not like to put any arbitrary upper limit on the length of your -symbols. - -In practice this often means you will build many short symbols and a -few long symbols. At the time you are reading a symbol you don't know -how long it is. One traditional method is to read a symbol into a -buffer, realloc()ating the buffer every time you try to read a symbol -that is longer than the buffer. This is beaut, but you still will -want to copy the symbol from the buffer to a more permanent -symbol-table entry say about half the time. - -With obstacks, you can work differently. Use one obstack for all symbol -names. As you read a symbol, grow the name in the obstack gradually. -When the name is complete, finalize it. Then, if the symbol exists already, -free the newly read name. - -The way we do this is to take a large chunk, allocating memory from -low addresses. When you want to build a aymbol in the chunk you just -add chars above the current "high water mark" in the chunk. When you -have finished adding chars, because you got to the end of the symbol, -you know how long the chars are, and you can create a new object. -Mostly the chars will not burst over the highest address of the chunk, -because you would typically expect a chunk to be (say) 100 times as -long as an average object. - -In case that isn't clear, when we have enough chars to make up -the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) -so we just point to it where it lies. No moving of chars is -needed and this is the second win: potentially long strings need -never be explicitly shuffled. Once an object is formed, it does not -change its address during its lifetime. - -When the chars burst over a chunk boundary, we allocate a larger -chunk, and then copy the partly formed object from the end of the old -chunk to the beggining of the new larger chunk. We then carry on -accreting characters to the end of the object as we normaly would. - -A special macro is provided to add a single char at a time to a -growing object. This allows the use of register variables, which -break the ordinary 'growth' macro. - -Summary: - We allocate large chunks. - We carve out one object at a time from the current chunk. - Once carved, an object never moves. - We are free to append data of any size to the currently - growing object. - Exactly one object is growing in an obstack at any one time. - You can run one obstack per control block. - You may have as many control blocks as you dare. - Because of the way we do it, you can `unwind' a obstack - back to a previous state. (You may remove objects much - as you would with a stack.) -*/ - - -/* Don't do the contents of this file more than once. */ - -#ifndef __OBSTACKS__ -#define __OBSTACKS__ - -/* We use subtraction of (char *)0 instead of casting to int - because on word-addressable machines a simple cast to int - may ignore the byte-within-word field of the pointer. */ - -#ifndef __PTR_TO_INT -#define __PTR_TO_INT(P) ((P) - (char *)0) -#endif - -#ifndef __INT_TO_PTR -#define __INT_TO_PTR(P) ((P) + (char *)0) -#endif - -struct _obstack_chunk /* Lives at front of each chunk. */ -{ - char *limit; /* 1 past end of this chunk */ - struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ -}; - -struct obstack /* control current object in current chunk */ -{ - long chunk_size; /* preferred size to allocate chunks in */ - struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ - int temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ - struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ - void (*freefun) (); /* User's function to free a chunk. */ -}; - -#ifdef __STDC__ - -/* Do the function-declarations after the structs - but before defining the macros. */ - -void obstack_init (struct obstack *obstack); - -void * obstack_alloc (struct obstack *obstack, int size); - -void * obstack_copy (struct obstack *obstack, void *address, int size); -void * obstack_copy0 (struct obstack *obstack, void *address, int size); - -void obstack_free (struct obstack *obstack, void *block); - -void obstack_blank (struct obstack *obstack, int size); - -void obstack_grow (struct obstack *obstack, void *data, int size); -void obstack_grow0 (struct obstack *obstack, void *data, int size); - -void obstack_1grow (struct obstack *obstack, int data_char); - -void * obstack_finish (struct obstack *obstack); - -int obstack_object_size (struct obstack *obstack); - -int obstack_room (struct obstack *obstack); -void obstack_1grow_fast (struct obstack *obstack, int data_char); -void obstack_blank_fast (struct obstack *obstack, int size); - -void * obstack_base (struct obstack *obstack); -void * obstack_next_free (struct obstack *obstack); -int obstack_alignment_mask (struct obstack *obstack); -int obstack_chunk_size (struct obstack *obstack); - -#endif /* __STDC__ */ - -/* Non-ANSI C cannot really support alternative functions for these macros, - so we do not declare them. */ - -/* Pointer to beginning of object being allocated or to be allocated next. - Note that this might not be the final address of the object - because a new chunk might be needed to hold the final size. */ - -#define obstack_base(h) ((h)->object_base) - -/* Size for allocating ordinary chunks. */ - -#define obstack_chunk_size(h) ((h)->chunk_size) - -/* Pointer to next byte not yet allocated in current chunk. */ - -#define obstack_next_free(h) ((h)->next_free) - -/* Mask specifying low bits that should be clear in address of an object. */ - -#define obstack_alignment_mask(h) ((h)->alignment_mask) - -#define obstack_init(h) \ - _obstack_begin ((h), 0, 0, obstack_chunk_alloc, obstack_chunk_free) - -#define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, obstack_chunk_alloc, obstack_chunk_free) - -#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) - -#define obstack_blank_fast(h,n) ((h)->next_free += (n)) - -#if defined (__GNUC__) && defined (__STDC__) - -/* For GNU C, if not -traditional, - we can define these macros to compute all args only once - without using a global variable. - Also, we can avoid using the `temp' slot, to make faster code. */ - -#define obstack_object_size(OBSTACK) \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->next_free - __o->object_base); }) - -#define obstack_room(OBSTACK) \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->chunk_limit - __o->next_free); }) - -#define obstack_grow(OBSTACK,where,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len) : 0); \ - bcopy (where, __o->next_free, __len); \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_grow0(OBSTACK,where,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len + 1 > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len + 1) : 0), \ - bcopy (where, __o->next_free, __len), \ - __o->next_free += __len, \ - *(__o->next_free)++ = 0; \ - (void) 0; }) - -#define obstack_1grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + 1 > __o->chunk_limit) \ - ? _obstack_newchunk (__o, 1) : 0), \ - *(__o->next_free)++ = (datum); \ - (void) 0; }) - -#define obstack_blank(OBSTACK,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len) : 0); \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_alloc(OBSTACK,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_blank (__h, (length)); \ - obstack_finish (__h); }) - -#define obstack_copy(OBSTACK,where,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_copy0(OBSTACK,where,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow0 (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_finish(OBSTACK) \ -({ struct obstack *__o = (OBSTACK); \ - void *value = (void *) __o->object_base; \ - __o->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT (__o->next_free)+__o->alignment_mask)\ - & ~ (__o->alignment_mask)); \ - ((__o->next_free - (char *)__o->chunk \ - > __o->chunk_limit - (char *)__o->chunk) \ - ? (__o->next_free = __o->chunk_limit) : 0); \ - __o->object_base = __o->next_free; \ - value; }) - -#define obstack_free(OBSTACK, OBJ) \ -({ struct obstack *__o = (OBSTACK); \ - void *__obj = (OBJ); \ - if (__obj >= (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ - __o->next_free = __o->object_base = __obj; \ - else (obstack_free) (__o, __obj); }) - -#else /* not __GNUC__ or not __STDC__ */ - -/* The non-GNU macros copy the obstack-pointer into this global variable - to avoid multiple evaluation. */ - -extern struct obstack *_obstack; - -#define obstack_object_size(h) \ - (unsigned) (_obstack = (h), (h)->next_free - (h)->object_base) - -#define obstack_room(h) \ - (unsigned) (_obstack = (h), (h)->chunk_limit - (h)->next_free) - -#define obstack_grow(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp) - -#define obstack_grow0(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp + 1) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp, \ - *((h)->next_free)++ = 0) - -#define obstack_1grow(h,datum) \ -( (((h)->next_free + 1 > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), 1) : 0), \ - *((h)->next_free)++ = (datum)) - -#define obstack_blank(h,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp) : 0), \ - (h)->next_free += (h)->temp) - -#define obstack_alloc(h,length) \ - (obstack_blank ((h), (length)), obstack_finish ((h))) - -#define obstack_copy(h,where,length) \ - (obstack_grow ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_copy0(h,where,length) \ - (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_finish(h) \ -( (h)->temp = __PTR_TO_INT ((h)->object_base), \ - (h)->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ - & ~ ((h)->alignment_mask)), \ - (((h)->next_free - (char *)(h)->chunk \ - > (h)->chunk_limit - (char *)(h)->chunk) \ - ? ((h)->next_free = (h)->chunk_limit) : 0), \ - (h)->object_base = (h)->next_free, \ - __INT_TO_PTR ((h)->temp)) - -#ifdef __STDC__ -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : ((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0))) -#else -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (int) _obstack_free ((h), (h)->temp + (char *) (h)->chunk))) -#endif - -#endif /* not __GNUC__ or not __STDC__ */ - -#endif /* not __OBSTACKS__ */ - diff --git a/gnu/usr.bin/gdb/printcmd.c b/gnu/usr.bin/gdb/printcmd.c deleted file mode 100644 index 3f61a261a64f..000000000000 --- a/gnu/usr.bin/gdb/printcmd.c +++ /dev/null @@ -1,1872 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)printcmd.c 6.5 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: printcmd.c,v 1.3 1993/12/03 05:13:07 paulus Exp $"; -#endif /* not lint */ - -/* Print values for GNU debugger GDB. - Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "symtab.h" -#include "value.h" -#include "expression.h" - -struct format_data -{ - int count; - char format; - char size; -}; - -/* Last specified output format. */ - -static char last_format = 'x'; - -/* Last specified examination size. 'b', 'h', 'w' or `q'. */ - -static char last_size = 'w'; - -/* Default address to examine next. */ - -static CORE_ADDR next_address; - -/* Last address examined. */ - -static CORE_ADDR last_examine_address; - -/* Contents of last address examined. - This is not valid past the end of the `x' command! */ - -static value last_examine_value; - -/* Number of auto-display expression currently being displayed. - So that we can deleted it if we get an error or a signal within it. - -1 when not doing one. */ - -int current_display_number; - -static void do_one_display (); - -void do_displays (); -void print_address (); -void print_floating (); -void print_scalar_formatted (); -void print_formatted_address (); - - -/* Decode a format specification. *STRING_PTR should point to it. - OFORMAT and OSIZE are used as defaults for the format and size - if none are given in the format specification. - If OSIZE is zero, then the size field of the returned value - should be set only if a size is explicitly specified by the - user. - The structure returned describes all the data - found in the specification. In addition, *STRING_PTR is advanced - past the specification and past all whitespace following it. */ - -struct format_data -decode_format (string_ptr, oformat, osize) - char **string_ptr; - char oformat; - char osize; -{ - struct format_data val; - register char *p = *string_ptr; - - val.format = '?'; - val.size = '?'; - val.count = 1; - - if (*p >= '0' && *p <= '9') - val.count = atoi (p); - while (*p >= '0' && *p <= '9') p++; - - /* Now process size or format letters that follow. */ - - while (1) - { - if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g') - val.size = *p++; -#ifdef LONG_LONG - else if (*p == 'l') - { - val.size = 'g'; - p++; - } -#endif - else if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z')) - val.format = *p++; - else - break; - } - -#ifndef LONG_LONG - /* Make sure 'g' size is not used on integer types. - Well, actually, we can handle hex. */ - if (val.size == 'g' && val.format != 'f' && val.format != 'x') - val.size = 'w'; -#endif - - while (*p == ' ' || *p == '\t') p++; - *string_ptr = p; - - /* Set defaults for format and size if not specified. */ - if (val.format == '?') - { - if (val.size == '?') - { - /* Neither has been specified. */ - val.format = oformat; - val.size = osize; - } - else - /* If a size is specified, any format makes a reasonable - default except 'i'. */ - val.format = oformat == 'i' ? 'x' : oformat; - } - else if (val.size == '?') - switch (val.format) - { - case 'a': - case 's': - case 'A': - /* Addresses must be words. */ - val.size = osize ? 'w' : osize; - break; - case 'f': - /* Floating point has to be word or giantword. */ - if (osize == 'w' || osize == 'g') - val.size = osize; - else - /* Default it to giantword if the last used size is not - appropriate. */ - val.size = osize ? 'g' : osize; - break; - case 'c': - /* Characters default to one byte. */ - val.size = osize ? 'b' : osize; - break; - default: - /* The default is the size most recently specified. */ - val.size = osize; - } - - return val; -} - -/* Print value VAL on stdout according to FORMAT, a letter or 0. - Do not end with a newline. - 0 means print VAL according to its own type. - SIZE is the letter for the size of datum being printed. - This is used to pad hex numbers so they line up. */ - -static void -print_formatted (val, format, size) - register value val; - register char format; - char size; -{ - int len = TYPE_LENGTH (VALUE_TYPE (val)); - - if (VALUE_LVAL (val) == lval_memory) - next_address = VALUE_ADDRESS (val) + len; - - switch (format) - { - case 's': - next_address = VALUE_ADDRESS (val) - + value_print (value_addr (val), stdout, 0, Val_pretty_default); - break; - - case 'i': - next_address = VALUE_ADDRESS (val) - + print_insn (VALUE_ADDRESS (val), stdout); - break; - - default: - if (format == 0 - || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ARRAY - || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRUCT - || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_UNION - || VALUE_REPEATED (val)) - value_print (val, stdout, format, Val_pretty_default); - else - print_scalar_formatted (VALUE_CONTENTS (val), VALUE_TYPE (val), - format, size, stdout); - } -} - -/* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR, - according to letters FORMAT and SIZE on STREAM. - FORMAT may not be zero. Formats s and i are not supported at this level. - - This is how the elements of an array or structure are printed - with a format. */ - -void -print_scalar_formatted (valaddr, type, format, size, stream) - char *valaddr; - struct type *type; - char format; - int size; - FILE *stream; -{ - LONGEST val_long; - int len = TYPE_LENGTH (type); - - if (size == 'g' && sizeof (LONGEST) < 8 - && format == 'x') - { - /* ok, we're going to have to get fancy here. Assumption: a - long is four bytes. */ - unsigned long v1, v2, tmp; - - v1 = unpack_long (builtin_type_long, valaddr); - v2 = unpack_long (builtin_type_long, valaddr + 4); - -#ifdef BYTES_BIG_ENDIAN -#else - /* Little endian -- swap the two for printing */ - tmp = v1; - v1 = v2; - v2 = tmp; -#endif - - switch (format) - { - case 'x': - fprintf_filtered (stream, "0x%08x%08x", v1, v2); - break; - default: - error ("Output size \"g\" unimplemented for format \"%c\".", - format); - } - return; - } - - val_long = unpack_long (type, valaddr); - - /* If value is unsigned, truncate it in case negative. */ - if (format != 'd') - { - if (len == sizeof (char)) - val_long &= (1 << 8 * sizeof(char)) - 1; - else if (len == sizeof (short)) - val_long &= (1 << 8 * sizeof(short)) - 1; - else if (len == sizeof (long)) - val_long &= (unsigned long) - 1; - } - - switch (format) - { - case 'x': -#ifdef LONG_LONG - if (!size) - size = (len < sizeof (long long) ? 'w' : 'g'); - switch (size) - { - case 'b': - fprintf_filtered (stream, "0x%02qx", val_long); - break; - case 'h': - fprintf_filtered (stream, "0x%04qx", val_long); - break; - case 0: /* no size specified, like in print */ - fprintf_filtered (stream, "%#qx", val_long); - break; - case 'w': - fprintf_filtered (stream, "0x%08qx", val_long); - break; - case 'g': - fprintf_filtered (stream, "0x%016qx", val_long); - break; - default: - error ("Undefined output size \"%c\".", size); - } -#else - switch (size) - { - case 'b': - fprintf_filtered (stream, "0x%02x", val_long); - break; - case 'h': - fprintf_filtered (stream, "0x%04x", val_long); - break; - case 0: /* no size specified, like in print */ - case 'w': - fprintf_filtered (stream, "0x%08x", val_long); - break; - case 'g': - fprintf_filtered (stream, "0x%o16x", val_long); - break; - default: - error ("Undefined output size \"%c\".", size); - } -#endif /* not LONG_LONG */ - break; - - case 'd': -#ifdef LONG_LONG - fprintf_filtered (stream, "%qd", val_long); -#else - fprintf_filtered (stream, "%d", val_long); -#endif - break; - - case 'u': -#ifdef LONG_LONG - fprintf_filtered (stream, "%qu", val_long); -#else - fprintf_filtered (stream, "%u", val_long); -#endif - break; - - case 'o': - if (val_long) -#ifdef LONG_LONG - fprintf_filtered (stream, "0%qo", val_long); -#else - fprintf_filtered (stream, "0%o", val_long); -#endif - else - fprintf_filtered (stream, "0"); - break; - - case 'a': - print_address ((CORE_ADDR) val_long, stream); - break; - - case 'A': - print_formatted_address ((CORE_ADDR) val_long, stream); - break; - - case 'c': - value_print (value_from_long (builtin_type_char, val_long), stream, 0, - Val_pretty_default); - break; - - case 'f': - if (len == sizeof (float)) - type = builtin_type_float; - else if (len == sizeof (double)) - type = builtin_type_double; - print_floating(valaddr, type, stream); - break; - - case 0: - abort (); - - default: - error ("Undefined output format \"%c\".", format); - } -} - -/* Print a floating point value of type TYPE, pointed to in GDB by VALADDR, - on STREAM. */ - -void -print_floating(valaddr, type, stream) - char *valaddr; - struct type *type; - FILE *stream; -{ - double doub; - int inv; - int len = TYPE_LENGTH (type); - - doub = unpack_double (type, valaddr, &inv); - if (inv) - fprintf_filtered (stream, "Invalid float value"); - else if (doub != doub) - { - /* Surely it is an IEEE floating point NaN. */ - - long low, high, *arg = (long *)valaddr; /* ASSUMED 32 BITS */ - int nonneg; - - if (len <= sizeof(float)) - { - /* It's single precision. */ - low = *arg; - nonneg = low >= 0; - low &= 0x7fffff; - high = 0; - } - else - { - /* It's double precision. - Get the high and low words of the fraction. - Distinguish big and little-endian machines. */ -#ifdef WORDS_BIG_ENDIAN - low = arg[1], high = arg[0]; -#else - low = arg[0], high = arg[1]; -#endif - nonneg = high >= 0; - high &= 0xfffff; - } - if (high) - fprintf_filtered (stream, "-NaN(0x%lx%.8lx)" + nonneg, high, low); - else - fprintf_filtered (stream, "-NaN(0x%lx)" + nonneg, low); - } - else - fprintf_filtered (stream, len <= sizeof(float) ? "%.6g" : "%.17g", doub); -} - -/* Specify default address for `x' command. - `info lines' uses this. */ - -void -set_next_address (addr) - CORE_ADDR addr; -{ - next_address = addr; - - /* Make address available to the user as $_. */ - set_internalvar (lookup_internalvar ("_"), - value_from_long (builtin_type_int, (LONGEST) addr)); -} - -/* Optionally print address ADDR symbolically as on STREAM. */ - -void -print_address_symbolic (addr, stream) - CORE_ADDR addr; - FILE *stream; -{ - register char *format; - int name_location; - register int i = find_pc_misc_function (addr); - - /* If nothing comes out, don't print anything symbolic. */ - if (i < 0) return; - name_location = misc_function_vector[i].address; - - if (addr - name_location) - format = " <%s+%d>"; - else - format = " <%s>"; - - fprintf_filtered (stream, format, - misc_function_vector[i].name, addr - name_location); -} - -/* Print address ADDR symbolically on STREAM. - First print it as a number. Then perhaps print - after the number. */ - -void -print_address (addr, stream) - CORE_ADDR addr; - FILE *stream; -{ - fprintf_filtered (stream, "0x%x", addr); - print_address_symbolic (addr, stream); -} - -/* Like print_address but opnly prints symbolically. */ - -void -print_formatted_address (addr, stream) - CORE_ADDR addr; - FILE *stream; -{ - register int i = 0; - register char *format; - register struct symbol *fs; - char *name; - int name_location; - - i = find_pc_partial_function (addr, &name, &name_location); - - /* If nothing comes out, don't print anything symbolic. */ - - if (i == 0) - fprintf_filtered (stream, "0x%x", addr); - else if (addr - name_location) - fprintf_filtered (stream, "%s+%d", name, addr - name_location); - else - fprintf_filtered (stream, "%s", name); -} - -/* Examine data at address ADDR in format FMT. - Fetch it from memory and print on stdout. */ - -static void -do_examine (fmt, addr) - struct format_data fmt; - CORE_ADDR addr; -{ - register char format = 0; - register char size; - register int count = 1; - struct type *val_type; - register int i; - register int maxelts; - - format = fmt.format; - size = fmt.size; - count = fmt.count; - next_address = addr; - - /* String or instruction format implies fetch single bytes - regardless of the specified size. */ - if (format == 's' || format == 'i') - size = 'b'; - - if (size == 'b') - val_type = builtin_type_char; - else if (size == 'h') - val_type = builtin_type_short; - else if (size == 'w') - val_type = builtin_type_long; - else if (size == 'g') -#ifndef LONG_LONG - val_type = builtin_type_double; -#else - val_type = builtin_type_long_long; -#endif - - maxelts = 8; - if (size == 'w') - maxelts = 4; - if (size == 'g') - maxelts = 2; - if (format == 's' || format == 'i') - maxelts = 1; - - /* Print as many objects as specified in COUNT, at most maxelts per line, - with the address of the next one at the start of each line. */ - - while (count > 0) - { - print_address (next_address, stdout); - printf_filtered (":"); - for (i = maxelts; - i > 0 && count > 0; - i--, count--) - { - printf_filtered ("\t"); - /* Note that print_formatted sets next_address for the next - object. */ - last_examine_address = next_address; - last_examine_value = value_at (val_type, next_address); - print_formatted (last_examine_value, format, size); - } - printf_filtered ("\n"); - fflush (stdout); - } -} - -static void -validate_format (fmt, cmdname) - struct format_data fmt; - char *cmdname; -{ - if (fmt.size != 0) - error ("Size letters are meaningless in \"%s\" command.", cmdname); - if (fmt.count != 1) - error ("Item count other than 1 is meaningless in \"%s\" command.", - cmdname); - if (fmt.format == 'i' || fmt.format == 's') - error ("Format letter \"%c\" is meaningless in \"%s\" command.", - fmt.format, cmdname); -} - -static void -print_command (exp) - char *exp; -{ - struct expression *expr; - register struct cleanup *old_chain = 0; - register char format = 0; - register value val; - struct format_data fmt; - int histindex; - int cleanup = 0; - - if (exp && *exp == '/') - { - exp++; - fmt = decode_format (&exp, last_format, 0); - validate_format (fmt, "print"); - last_format = format = fmt.format; - } - - if (exp && *exp) - { - expr = parse_c_expression (exp); - old_chain = make_cleanup (free_current_contents, &expr); - cleanup = 1; - val = evaluate_expression (expr); - } - else - val = access_value_history (0); - - histindex = record_latest_value (val); - if (histindex >= 0) printf_filtered ("$%d = ", histindex); - - print_formatted (val, format, fmt.size); - printf_filtered ("\n"); - - if (cleanup) - do_cleanups (old_chain); -} - -static void -output_command (exp) - char *exp; -{ - struct expression *expr; - register struct cleanup *old_chain; - register char format = 0; - register value val; - struct format_data fmt; - - if (exp && *exp == '/') - { - exp++; - fmt = decode_format (&exp, 0, 0); - validate_format (fmt, "print"); - format = fmt.format; - } - - expr = parse_c_expression (exp); - old_chain = make_cleanup (free_current_contents, &expr); - - val = evaluate_expression (expr); - - print_formatted (val, format, fmt.size); - - do_cleanups (old_chain); -} - -static void -set_command (exp) - char *exp; -{ - struct expression *expr = parse_c_expression (exp); - register struct cleanup *old_chain - = make_cleanup (free_current_contents, &expr); - evaluate_expression (expr); - do_cleanups (old_chain); -} - -static void -address_info (exp) - char *exp; -{ - register struct symbol *sym; - register CORE_ADDR val; - int is_a_field_of_this; /* C++: lookup_symbol sets this to nonzero - if exp is a field of `this'. */ - - if (exp == 0) - error ("Argument required."); - - sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE, - &is_a_field_of_this); - if (sym == 0) - { - register int i; - - if (is_a_field_of_this) - { - printf ("Symbol \"%s\" is a field of the local class variable `this'\n", exp); - return; - } - - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, exp)) - break; - - if (i < misc_function_count) - printf ("Symbol \"%s\" is at 0x%x in a file compiled without -g.\n", - exp, misc_function_vector[i].address); - else - error ("No symbol \"%s\" in current context.", exp); - return; - } - - printf ("Symbol \"%s\" is ", SYMBOL_NAME (sym)); - val = SYMBOL_VALUE (sym); - - switch (SYMBOL_CLASS (sym)) - { - case LOC_CONST: - case LOC_CONST_BYTES: - printf ("constant"); - break; - - case LOC_LABEL: - printf ("a label at address 0x%x", val); - break; - - case LOC_REGISTER: - printf ("a variable in register %s", reg_names[val]); - break; - - case LOC_STATIC: - printf ("static at address 0x%x", val); - break; - - case LOC_REGPARM: - printf ("an argument in register %s", reg_names[val]); - break; - - case LOC_ARG: - printf ("an argument at offset %d", val); - break; - - case LOC_LOCAL: - printf ("a local variable at frame offset %d", val); - break; - - case LOC_REF_ARG: - printf ("a reference argument at offset %d", val); - break; - - case LOC_TYPEDEF: - printf ("a typedef"); - break; - - case LOC_BLOCK: - printf ("a function at address 0x%x", - BLOCK_START (SYMBOL_BLOCK_VALUE (sym))); - break; - } - printf (".\n"); -} - -static void -x_command (exp, from_tty) - char *exp; - int from_tty; -{ - struct expression *expr; - struct format_data fmt; - struct cleanup *old_chain; - struct value *val; - - fmt.format = last_format; - fmt.size = last_size; - fmt.count = 1; - - if (exp && *exp == '/') - { - exp++; - fmt = decode_format (&exp, last_format, last_size); - last_size = fmt.size; - last_format = fmt.format; - } - - /* If we have an expression, evaluate it and use it as the address. */ - - if (exp != 0 && *exp != 0) - { - expr = parse_c_expression (exp); - /* Cause expression not to be there any more - if this command is repeated with Newline. - But don't clobber a user-defined command's definition. */ - if (from_tty) - *exp = 0; - old_chain = make_cleanup (free_current_contents, &expr); - val = evaluate_expression (expr); - /* In rvalue contexts, such as this, functions are coerced into - pointers to functions. This makes "x/i main" work. */ - if (/* last_format == 'i' - && */ TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC - && VALUE_LVAL (val) == lval_memory) - next_address = VALUE_ADDRESS (val); - else - next_address = (CORE_ADDR) value_as_long (val); - do_cleanups (old_chain); - } - - do_examine (fmt, next_address); - - /* Set a couple of internal variables if appropriate. */ - if (last_examine_value) - { - /* Make last address examined available to the user as $_. */ - set_internalvar (lookup_internalvar ("_"), - value_from_long (builtin_type_int, - (LONGEST) last_examine_address)); - - /* Make contents of last address examined available to the user as $__.*/ - set_internalvar (lookup_internalvar ("__"), last_examine_value); - } -} - -/* Commands for printing types of things. */ - -static void -whatis_command (exp) - char *exp; -{ - struct expression *expr; - register value val; - register struct cleanup *old_chain; - - if (exp) - { - expr = parse_c_expression (exp); - old_chain = make_cleanup (free_current_contents, &expr); - val = evaluate_type (expr); - } - else - val = access_value_history (0); - - printf_filtered ("type = "); - /* Most of the time users do not want to see all the fields - in a structure. If they do they can use the "ptype" command. - Hence the "-1" below. */ - type_print (VALUE_TYPE (val), "", stdout, -1); - printf_filtered ("\n"); - - if (exp) - do_cleanups (old_chain); -} - -static void -ptype_command (typename) - char *typename; -{ - register char *p = typename; - register int len; - extern struct block *get_current_block (); - register struct block *b - = (have_inferior_p () || have_core_file_p ()) ? get_current_block () : 0; - register struct type *type; - - if (typename == 0) - error_no_arg ("type name"); - - while (*p && *p != ' ' && *p != '\t') p++; - len = p - typename; - while (*p == ' ' || *p == '\t') p++; - - if (len == 6 && !strncmp (typename, "struct", 6)) - type = lookup_struct (p, b); - else if (len == 5 && !strncmp (typename, "union", 5)) - type = lookup_union (p, b); - else if (len == 4 && !strncmp (typename, "enum", 4)) - type = lookup_enum (p, b); - else - { - type = lookup_typename (typename, b, 1); - if (type == 0) - { - register struct symbol *sym - = lookup_symbol (typename, b, STRUCT_NAMESPACE, 0); - if (sym == 0) - error ("No type named %s.", typename); - printf_filtered ("No type named %s, but there is a ", - typename); - switch (TYPE_CODE (SYMBOL_TYPE (sym))) - { - case TYPE_CODE_STRUCT: - printf_filtered ("struct"); - break; - - case TYPE_CODE_UNION: - printf_filtered ("union"); - break; - - case TYPE_CODE_ENUM: - printf_filtered ("enum"); - } - printf_filtered (" %s. Type \"help ptype\".\n", typename); - type = SYMBOL_TYPE (sym); - } - } - - type_print (type, "", stdout, 1); - printf_filtered ("\n"); -} - -enum display_status {disabled, enabled}; - -struct display -{ - /* Chain link to next auto-display item. */ - struct display *next; - /* Expression to be evaluated and displayed. */ - struct expression *exp; - /* Item number of this auto-display item. */ - int number; - /* Display format specified. */ - struct format_data format; - /* Innermost block required by this expression when evaluated */ - struct block *block; - /* Status of this display (enabled or disabled) */ - enum display_status status; -}; - -/* Chain of expressions whose values should be displayed - automatically each time the program stops. */ - -static struct display *display_chain; - -static int display_number; - -/* Add an expression to the auto-display chain. - Specify the expression. */ - -static void -display_command (exp, from_tty) - char *exp; - int from_tty; -{ - struct format_data fmt; - register struct expression *expr; - register struct display *new; - extern struct block *innermost_block; - - if (exp == 0) - { - do_displays (); - return; - } - - if (*exp == '/') - { - exp++; - fmt = decode_format (&exp, 0, 0); - if (fmt.size && fmt.format == 0) - fmt.format = 'x'; - if (fmt.format == 'i' || fmt.format == 's') - fmt.size = 'b'; - } - else - { - fmt.format = 0; - fmt.size = 0; - fmt.count = 0; - } - - innermost_block = 0; - expr = parse_c_expression (exp); - - new = (struct display *) xmalloc (sizeof (struct display)); - - new->exp = expr; - new->block = innermost_block; - new->next = display_chain; - new->number = ++display_number; - new->format = fmt; - new->status = enabled; - display_chain = new; - - if (from_tty && have_inferior_p ()) - do_one_display (new); - - dont_repeat (); -} - -static void -free_display (d) - struct display *d; -{ - free (d->exp); - free (d); -} - -/* Clear out the display_chain. - Done when new symtabs are loaded, since this invalidates - the types stored in many expressions. */ - -void -clear_displays () -{ - register struct display *d; - - while (d = display_chain) - { - free (d->exp); - display_chain = d->next; - free (d); - } -} - -/* Delete the auto-display number NUM. */ - -void -delete_display (num) - int num; -{ - register struct display *d1, *d; - - if (!display_chain) - error ("No display number %d.", num); - - if (display_chain->number == num) - { - d1 = display_chain; - display_chain = d1->next; - free_display (d1); - } - else - for (d = display_chain; ; d = d->next) - { - if (d->next == 0) - error ("No display number %d.", num); - if (d->next->number == num) - { - d1 = d->next; - d->next = d1->next; - free_display (d1); - break; - } - } -} - -/* Delete some values from the auto-display chain. - Specify the element numbers. */ - -static void -undisplay_command (args) - char *args; -{ - register char *p = args; - register char *p1; - register int num; - register struct display *d, *d1; - - if (args == 0) - { - if (query ("Delete all auto-display expressions? ")) - clear_displays (); - dont_repeat (); - return; - } - - while (*p) - { - p1 = p; - while (*p1 >= '0' && *p1 <= '9') p1++; - if (*p1 && *p1 != ' ' && *p1 != '\t') - error ("Arguments must be display numbers."); - - num = atoi (p); - - delete_display (num); - - p = p1; - while (*p == ' ' || *p == '\t') p++; - } - dont_repeat (); -} - -/* Display a single auto-display. - Do nothing if the display cannot be printed in the current context, - or if the display is disabled. */ - -static void -do_one_display (d) - struct display *d; -{ - int within_current_scope; - - if (d->status == disabled) - return; - - if (d->block) - within_current_scope = contained_in (get_selected_block (), d->block); - else - within_current_scope = 1; - if (!within_current_scope) - return; - - current_display_number = d->number; - - printf_filtered ("%d: ", d->number); - if (d->format.size) - { - printf_filtered ("x/"); - if (d->format.count != 1) - printf_filtered ("%d", d->format.count); - printf_filtered ("%c", d->format.format); - if (d->format.format != 'i' && d->format.format != 's') - printf_filtered ("%c", d->format.size); - printf_filtered (" "); - print_expression (d->exp, stdout); - if (d->format.count != 1) - printf_filtered ("\n"); - else - printf_filtered (" "); - do_examine (d->format, - (CORE_ADDR) value_as_long (evaluate_expression (d->exp))); - - } - else - { - if (d->format.format) - printf_filtered ("/%c ", d->format.format); - print_expression (d->exp, stdout); - printf_filtered (" = "); - print_formatted (evaluate_expression (d->exp), - d->format.format, d->format.size); - printf_filtered ("\n"); - } - - fflush (stdout); - current_display_number = -1; -} - -/* Display all of the values on the auto-display chain which can be - evaluated in the current scope. */ - -void -do_displays () -{ - register struct display *d; - - for (d = display_chain; d; d = d->next) - do_one_display (d); -} - -/* Delete the auto-display which we were in the process of displaying. - This is done when there is an error or a signal. */ - -void -disable_display (num) - int num; -{ - register struct display *d; - - for (d = display_chain; d; d = d->next) - if (d->number == num) - { - d->status = disabled; - return; - } - printf ("No display number %d.\n", num); -} - -void -disable_current_display () -{ - if (current_display_number >= 0) - { - disable_display (current_display_number); - fprintf (stderr, "Disabling display %d to avoid infinite recursion.\n", - current_display_number); - } - current_display_number = -1; -} - -static void -display_info () -{ - register struct display *d; - - if (!display_chain) - printf ("There are no auto-display expressions now.\n"); - else - printf_filtered ("Auto-display expressions now in effect:\n\ -Num Enb Expression\n"); - - for (d = display_chain; d; d = d->next) - { - printf_filtered ("%d: %c ", d->number, "ny"[(int)d->status]); - if (d->format.size) - printf_filtered ("/%d%c%c ", d->format.count, d->format.size, - d->format.format); - else if (d->format.format) - printf_filtered ("/%c ", d->format.format); - print_expression (d->exp, stdout); - if (d->block && !contained_in (get_selected_block (), d->block)) - printf_filtered (" (cannot be evaluated in the current context)"); - printf_filtered ("\n"); - fflush (stdout); - } -} - -void -enable_display (args) - char *args; -{ - register char *p = args; - register char *p1; - register int num; - register struct display *d; - - if (p == 0) - { - for (d = display_chain; d; d = d->next) - d->status = enabled; - } - else - while (*p) - { - p1 = p; - while (*p1 >= '0' && *p1 <= '9') - p1++; - if (*p1 && *p1 != ' ' && *p1 != '\t') - error ("Arguments must be display numbers."); - - num = atoi (p); - - for (d = display_chain; d; d = d->next) - if (d->number == num) - { - d->status = enabled; - goto win; - } - printf ("No display number %d.\n", num); - win: - p = p1; - while (*p == ' ' || *p == '\t') - p++; - } -} - -void -disable_display_command (args, from_tty) - char *args; - int from_tty; -{ - register char *p = args; - register char *p1; - register int num; - register struct display *d; - - if (p == 0) - { - for (d = display_chain; d; d = d->next) - d->status = disabled; - } - else - while (*p) - { - p1 = p; - while (*p1 >= '0' && *p1 <= '9') - p1++; - if (*p1 && *p1 != ' ' && *p1 != '\t') - error ("Arguments must be display numbers."); - - num = atoi (p); - - disable_display (atoi (p)); - - p = p1; - while (*p == ' ' || *p == '\t') - p++; - } -} - - -/* Print the value in stack frame FRAME of a variable - specified by a struct symbol. */ - -void -print_variable_value (var, frame, stream) - struct symbol *var; - FRAME frame; - FILE *stream; -{ - value val = read_var_value (var, frame); - value_print (val, stream, 0, Val_pretty_default); -} - -static int -compare_ints (i, j) - int *i, *j; -{ - return *i - *j; -} - -/* Print the arguments of a stack frame, given the function FUNC - running in that frame (as a symbol), the info on the frame, - and the number of args according to the stack frame (or -1 if unknown). */ - -static void print_frame_nameless_args (); - -void -print_frame_args (func, fi, num, stream) - struct symbol *func; - struct frame_info *fi; - int num; - FILE *stream; -{ - struct block *b; - int nsyms = 0; - int first = 1; - register int i; - register int last_regparm = 0; - register struct symbol *lastsym, *sym, *nextsym; - register value val; - /* Offset of stack argument that is at the highest offset. - -1 if we haven't come to a stack argument yet. */ - CORE_ADDR highest_offset = (CORE_ADDR) -1; - register CORE_ADDR addr = FRAME_ARGS_ADDRESS (fi); - - if (func) - { - b = SYMBOL_BLOCK_VALUE (func); - nsyms = BLOCK_NSYMS (b); - } - - for (i = 0; i < nsyms; i++) - { - QUIT; - sym = BLOCK_SYM (b, i); - - if (SYMBOL_CLASS (sym) != LOC_REGPARM - && SYMBOL_CLASS (sym) != LOC_ARG - && SYMBOL_CLASS (sym) != LOC_REF_ARG) - continue; - - /* Print the next arg. */ - if (SYMBOL_CLASS (sym) == LOC_REGPARM) - val = value_from_register (SYMBOL_TYPE (sym), - SYMBOL_VALUE (sym), - FRAME_INFO_ID (fi)); - else - { - int current_offset = SYMBOL_VALUE (sym); - int arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym)); - - if (SYMBOL_CLASS (sym) == LOC_REF_ARG) - val = value_at (SYMBOL_TYPE (sym), - read_memory_integer (addr + current_offset, - sizeof (CORE_ADDR))); - else - val = value_at (SYMBOL_TYPE (sym), addr + current_offset); - - /* Round up address of next arg to multiple of size of int. */ - current_offset - = (((current_offset + sizeof (int) - 1) / sizeof (int)) - * sizeof (int)); - - /* If this is the highest offset seen yet, set highest_offset. */ - if (highest_offset == (CORE_ADDR)-1 - || ((current_offset - + (arg_size - sizeof (int) + 3) / (sizeof (int))) - > highest_offset)) - highest_offset = current_offset; - } - - if (! first) - fprintf_filtered (stream, ", "); - fputs_filtered (SYMBOL_NAME (sym), stream); - fputs_filtered ("=", stream); - -/* Nonzero if a LOC_ARG which is a struct is useless. */ -#if !defined (STRUCT_ARG_SYM_GARBAGE) -#define STRUCT_ARG_SYM_GARBAGE(gcc_p) 0 -#endif - - if (STRUCT_ARG_SYM_GARBAGE (b->gcc_compile_flag) - && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT - && SYMBOL_CLASS (sym) == LOC_ARG) - { - /* Try looking up that name. SunOS4 puts out a usable - symbol as a local variable (in addition to the one - for the arg). */ - struct symbol *sym2 = - lookup_symbol (SYMBOL_NAME (sym), b, VAR_NAMESPACE, 0); - - if (sym2 != NULL) - val = value_of_variable (sym2); - else - { - fputs_filtered ("?", stream); - first = 0; - continue; - } - } - - value_print (val, stream, 0, Val_no_prettyprint); - first = 0; - } - - /* Don't print nameless args in situations where we don't know - enough about the stack to find them. */ - if (num != -1) - { - if (highest_offset != (CORE_ADDR) -1 - && num * sizeof (int) + FRAME_ARGS_SKIP > highest_offset) - print_frame_nameless_args (fi, addr, - highest_offset + sizeof (int), - num * sizeof (int) + FRAME_ARGS_SKIP, - stream); - else - print_frame_nameless_args (fi, addr, FRAME_ARGS_SKIP, - num * sizeof (int) + FRAME_ARGS_SKIP, - stream); - } -} - -static void -print_frame_nameless_args (fi, argsaddr, start, end, stream) - struct frame_info *fi; - CORE_ADDR argsaddr; - int start; - int end; - FILE *stream; -{ - extern void (*default_scalar_print)(); - LONGEST v; - int p = start; - char *s = ""; - - for (p = start; p < end; p += sizeof(int)) { - QUIT; -#if defined(NAMELESS_ARG) - v = NAMELESS_ARG(fi, (p - start) / sizeof(int)); -#else - v = read_memory_integer (argsaddr + p, sizeof (int)); -#endif - fprintf_filtered (stream, s); - s = ", "; - (*default_scalar_print) (stream, builtin_type_int, v); - } -} - -static void -printf_command (arg) - char *arg; -{ - register char *f; - register char *s = arg; - char *string; - value *val_args; - int nargs = 0; - int allocated_args = 20; - char *arg_bytes; - - val_args = (value *) xmalloc (allocated_args * sizeof (value)); - - if (s == 0) - error_no_arg ("format-control string and values to print"); - - /* Skip white space before format string */ - while (*s == ' ' || *s == '\t') s++; - - /* A format string should follow, enveloped in double quotes */ - if (*s++ != '"') - error ("Bad format string, missing '\"'."); - - /* Parse the format-control string and copy it into the string STRING, - processing some kinds of escape sequence. */ - - f = string = (char *) alloca (strlen (s) + 1); - while (*s != '"') - { - int c = *s++; - switch (c) - { - case '\0': - error ("Bad format string, non-terminated '\"'."); - /* doesn't return */ - - case '\\': - switch (c = *s++) - { - case '\\': - *f++ = '\\'; - break; - case 'n': - *f++ = '\n'; - break; - case 't': - *f++ = '\t'; - break; - case 'r': - *f++ = '\r'; - break; - case '"': - *f++ = '"'; - break; - default: - /* ??? TODO: handle other escape sequences */ - error ("Unrecognized \\ escape character in format string."); - } - break; - - default: - *f++ = c; - } - } - - /* Skip over " and following space and comma. */ - s++; - *f++ = '\0'; - while (*s == ' ' || *s == '\t') s++; - - if (*s != ',' && *s != 0) - error ("Invalid argument syntax"); - - if (*s == ',') s++; - while (*s == ' ' || *s == '\t') s++; - - { - /* Now scan the string for %-specs and see what kinds of args they want. - argclass[I] classifies the %-specs so we can give vprintf something - of the right size. */ - - enum argclass {int_arg, string_arg, double_arg, long_long_arg}; - enum argclass *argclass; - int nargs_wanted; - int argindex; - int lcount; - int i; - - argclass = (enum argclass *) alloca (strlen (s) * sizeof *argclass); - nargs_wanted = 0; - f = string; - while (*f) - if (*f++ == '%') - { - lcount = 0; - while (index ("0123456789.hlLq-+ #", *f)) - { - if (*f == 'l' || *f == 'L') - lcount++; - else if (*f == 'q') - lcount += 2; - f++; - } - if (*f == 's') - argclass[nargs_wanted++] = string_arg; - else if (*f == 'e' || *f == 'f' || *f == 'g') - argclass[nargs_wanted++] = double_arg; - else if (lcount > 1) - argclass[nargs_wanted++] = long_long_arg; - else if (*f != '%') - argclass[nargs_wanted++] = int_arg; - f++; - } - - /* Now, parse all arguments and evaluate them. - Store the VALUEs in VAL_ARGS. */ - - while (*s != '\0') - { - char *s1; - if (nargs == allocated_args) - val_args = (value *) xrealloc (val_args, - (allocated_args *= 2) - * sizeof (value)); - s1 = s; - val_args[nargs] = parse_to_comma_and_eval (&s1); - - /* If format string wants a float, unchecked-convert the value to - floating point of the same size */ - - if (argclass[nargs] == double_arg) - { - if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (float)) - VALUE_TYPE (val_args[nargs]) = builtin_type_float; - if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (double)) - VALUE_TYPE (val_args[nargs]) = builtin_type_double; - } - nargs++; - s = s1; - if (*s == ',') - s++; - } - - if (nargs != nargs_wanted) - error ("Wrong number of arguments for specified format-string"); - - /* Now lay out an argument-list containing the arguments - as doubles, integers and C pointers. */ - - arg_bytes = (char *) alloca (sizeof (double) * nargs); - argindex = 0; - for (i = 0; i < nargs; i++) - { - if (argclass[i] == string_arg) - { - char *str; - int tem, j; - tem = value_as_long (val_args[i]); - - /* This is a %s argument. Find the length of the string. */ - for (j = 0; ; j++) - { - char c; - QUIT; - read_memory (tem + j, &c, 1); - if (c == 0) - break; - } - - /* Copy the string contents into a string inside GDB. */ - str = (char *) alloca (j + 1); - read_memory (tem, str, j); - str[j] = 0; - - /* Pass address of internal copy as the arg to vprintf. */ - *((int *) &arg_bytes[argindex]) = (int) str; - argindex += sizeof (int); - } - else if (VALUE_TYPE (val_args[i])->code == TYPE_CODE_FLT) - { - *((double *) &arg_bytes[argindex]) = value_as_double (val_args[i]); - argindex += sizeof (double); - } - else -#ifdef LONG_LONG - if (argclass[i] == long_long_arg) - { - *(long long *) &arg_bytes[argindex] = value_as_long (val_args[i]); - argindex += sizeof (long long); - } - else -#endif - { - *((int *) &arg_bytes[argindex]) = value_as_long (val_args[i]); - argindex += sizeof (int); - } - } - } - vprintf (string, arg_bytes); -} - -/* Helper function for asdump_command. Finds the bounds of a function - for a specified section of text. PC is an address within the - function which you want bounds for; *LOW and *HIGH are set to the - beginning (inclusive) and end (exclusive) of the function. This - function returns 1 on success and 0 on failure. */ - -static int -containing_function_bounds (pc, low, high) - CORE_ADDR pc, *low, *high; -{ - int scan; - - if (!find_pc_partial_function (pc, 0, low)) - return 0; - - scan = *low; - do { - scan++; - if (!find_pc_partial_function (scan, 0, high)) - return 0; - } while (*low == *high); - - return 1; -} - -/* Dump a specified section of assembly code. With no command line - arguments, this command will dump the assembly code for the - function surrounding the pc value in the selected frame. With one - argument, it will dump the assembly code surrounding that pc value. - Two arguments are interpeted as bounds within which to dump - assembly. */ - -static void -disassemble_command (arg, from_tty) - char *arg; - int from_tty; -{ - CORE_ADDR low, high; - CORE_ADDR pc; - char *space_index; - - if (!arg) - { - if (!selected_frame) - error ("No frame selected.\n"); - - pc = get_frame_pc (selected_frame); - if (!containing_function_bounds (pc, &low, &high)) - error ("No function contains pc specified by selected frame.\n"); - } - else if (!(space_index = (char *) index (arg, ' '))) - { - /* One argument. */ - pc = parse_and_eval_address (arg); - if (!containing_function_bounds (pc, &low, &high)) - error ("No function contains specified pc.\n"); - } - else - { - /* Two arguments. */ - *space_index = '\0'; - low = parse_and_eval_address (arg); - high = parse_and_eval_address (space_index + 1); - } - - printf_filtered ("Dump of assembler code "); - if (!space_index) - { - char *name; - find_pc_partial_function (pc, &name, 0); - printf_filtered ("for function %s:\n", name); - } - else - printf_filtered ("from 0x%x to 0x%x:\n", low, high); - - /* Dump the specified range. */ - for (pc = low; pc < high; ) - { - QUIT; - print_address (pc, stdout); - printf_filtered (":\t"); - pc += print_insn (pc, stdout); - printf_filtered ("\n"); - } - printf_filtered ("End of assembler dump.\n"); - fflush (stdout); -} - - -extern struct cmd_list_element *enablelist, *disablelist, *deletelist; -extern struct cmd_list_element *cmdlist, *setlist; - -void -_initialize_printcmd () -{ - current_display_number = -1; - - add_info ("address", address_info, - "Describe where variable VAR is stored."); - - add_com ("x", class_vars, x_command, - "Examine memory: x/FMT ADDRESS.\n\ -ADDRESS is an expression for the memory address to examine.\n\ -FMT is a repeat count followed by a format letter and a size letter.\n\ -Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\ - f(float), a(address), i(instruction), c(char) and s(string).\n\ -Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\ - g is meaningful only with f, for type double.\n\ -The specified number of objects of the specified size are printed\n\ -according to the format.\n\n\ -Defaults for format and size letters are those previously used.\n\ -Default count is 1. Default address is following last thing printed\n\ -with this command or \"print\"."); - - add_com ("disassemble", class_vars, disassemble_command, - "Disassemble a specified section of memory.\n\ -Default is the function surrounding the pc of the selected frame.\n\ -With a single argument, the function surrounding that address is dumped.\n\ -Two arguments are taken as a range of memory to dump."); - - add_com ("ptype", class_vars, ptype_command, - "Print definition of type TYPE.\n\ -Argument may be a type name defined by typedef, or \"struct STRUCTNAME\"\n\ -or \"union UNIONNAME\" or \"enum ENUMNAME\".\n\ -The selected stack frame's lexical context is used to look up the name."); - - add_com ("whatis", class_vars, whatis_command, - "Print data type of expression EXP."); - - add_info ("display", display_info, - "Expressions to display when program stops, with code numbers."); - - add_cmd ("undisplay", class_vars, undisplay_command, - "Cancel some expressions to be displayed when program stops.\n\ -Arguments are the code numbers of the expressions to stop displaying.\n\ -No argument means cancel all automatic-display expressions.\n\ -\"delete display\" has the same effect as this command.\n\ -Do \"info display\" to see current list of code numbers.", - &cmdlist); - - add_com ("display", class_vars, display_command, - "Print value of expression EXP each time the program stops.\n\ -/FMT may be used before EXP as in the \"print\" command.\n\ -/FMT \"i\" or \"s\" or including a size-letter is allowed,\n\ -as in the \"x\" command, and then EXP is used to get the address to examine\n\ -and examining is done as in the \"x\" command.\n\n\ -With no argument, display all currently requested auto-display expressions.\n\ -Use \"undisplay\" to cancel display requests previously made."); - - add_cmd ("display", class_vars, enable_display, - "Enable some expressions to be displayed when program stops.\n\ -Arguments are the code numbers of the expressions to resume displaying.\n\ -No argument means enable all automatic-display expressions.\n\ -Do \"info display\" to see current list of code numbers.", &enablelist); - - add_cmd ("display", class_vars, disable_display_command, - "Disable some expressions to be displayed when program stops.\n\ -Arguments are the code numbers of the expressions to stop displaying.\n\ -No argument means disable all automatic-display expressions.\n\ -Do \"info display\" to see current list of code numbers.", &disablelist); - - add_cmd ("display", class_vars, undisplay_command, - "Cancel some expressions to be displayed when program stops.\n\ -Arguments are the code numbers of the expressions to stop displaying.\n\ -No argument means cancel all automatic-display expressions.\n\ -Do \"info display\" to see current list of code numbers.", &deletelist); - - add_com ("printf", class_vars, printf_command, - "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\ -This is useful for formatted output in user-defined commands."); - add_com ("output", class_vars, output_command, - "Like \"print\" but don't put in value history and don't print newline.\n\ -This is useful in user-defined commands."); - - add_prefix_cmd ("set", class_vars, set_command, -"Perform an assignment VAR = EXP.\n\ -You must type the \"=\". VAR may be a debugger \"convenience\" variable\n\ -(names starting with $), a register (a few standard names starting with $),\n\ -or an actual variable in the program being debugged. EXP is any expression.\n\ -Use \"set variable\" for variables with names identical to set subcommands.\n\ -\nWith a subcommand, this command modifies parts of the gdb environment", - &setlist, "set ", 1, &cmdlist); - - add_cmd ("variable", class_vars, set_command, - "Perform an assignment VAR = EXP.\n\ -You must type the \"=\". VAR may be a debugger \"convenience\" variable\n\ -(names starting with $), a register (a few standard names starting with $),\n\ -or an actual variable in the program being debugged. EXP is any expression.\n\ -This may usually be abbreviated to simply \"set\".", - &setlist); - - add_com ("print", class_vars, print_command, - concat ("Print value of expression EXP.\n\ -Variables accessible are those of the lexical environment of the selected\n\ -stack frame, plus all those whose scope is global or an entire file.\n\ -\n\ -$NUM gets previous value number NUM. $ and $$ are the last two values.\n\ -$$NUM refers to NUM'th value back from the last one.\n\ -Names starting with $ refer to registers (with the values they would have\n\ -if the program were to return to the stack frame now selected, restoring\n\ -all registers saved by frames farther in) or else to debugger\n\ -\"convenience\" variables (any such name not a known register).\n\ -Use assignment expressions to give values to convenience variables.\n", - "\n\ -\{TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\ -@ is a binary operator for treating consecutive data objects\n\ -anywhere in memory as an array. FOO@NUM gives an array whose first\n\ -element is FOO, whose second element is stored in the space following\n\ -where FOO is stored, etc. FOO must be an expression whose value\n\ -resides in memory.\n", - "\n\ -EXP may be preceded with /FMT, where FMT is a format letter\n\ -but no count or size letter (see \"x\" command).")); - add_com_alias ("p", "print", class_vars, 1); -} diff --git a/gnu/usr.bin/gdb/regex.c b/gnu/usr.bin/gdb/regex.c deleted file mode 100644 index e7c4d4439c30..000000000000 --- a/gnu/usr.bin/gdb/regex.c +++ /dev/null @@ -1,1741 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 1985, 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 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. - - - In other words, you are welcome to use, share and improve this program. - You are forbidden to forbid anyone else to use, share and improve - what you give them. Help stamp out software-hoarding! */ - -#ifndef lint -static char rcsid[] = "$Id: regex.c,v 1.2 1993/08/02 17:41:06 mycroft Exp $"; -#endif /* not lint */ - -/* To test, compile with -Dtest. - This Dtestable feature turns this into a self-contained program - which reads a pattern, describes how it compiles, - then reads a string and searches for it. */ - -#ifdef emacs - -/* The `emacs' switch turns on certain special matching commands - that make sense only in emacs. */ - -#include "config.h" -#include "lisp.h" -#include "buffer.h" -#include "syntax.h" - -#else /* not emacs */ - -#ifdef USG -#ifndef BSTRING -#define bcopy(s,d,n) memcpy((d),(s),(n)) -#define bcmp(s1,s2,n) memcmp((s1),(s2),(n)) -#define bzero(s,n) memset((s),0,(n)) -#endif -#endif - -/* Make alloca work the best possible way. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#ifdef sparc -#include -#endif -#endif - -/* - * Define the syntax stuff, so we can do the \<...\> things. - */ - -#ifndef Sword /* must be non-zero in some of the tests below... */ -#define Sword 1 -#endif - -#define SYNTAX(c) re_syntax_table[c] - -#ifdef SYNTAX_TABLE - -char *re_syntax_table; - -#else - -static char re_syntax_table[256]; - -static void -init_syntax_once () -{ - register int c; - static int done = 0; - - if (done) - return; - - bzero (re_syntax_table, sizeof re_syntax_table); - - for (c = 'a'; c <= 'z'; c++) - re_syntax_table[c] = Sword; - - for (c = 'A'; c <= 'Z'; c++) - re_syntax_table[c] = Sword; - - for (c = '0'; c <= '9'; c++) - re_syntax_table[c] = Sword; - - done = 1; -} - -#endif /* SYNTAX_TABLE */ -#endif /* not emacs */ - -#include "regex.h" - -/* Number of failure points to allocate space for initially, - when matching. If this number is exceeded, more space is allocated, - so it is not a hard limit. */ - -#ifndef NFAILURES -#define NFAILURES 80 -#endif /* NFAILURES */ - -/* width of a byte in bits */ - -#define BYTEWIDTH 8 - -#ifndef SIGN_EXTEND_CHAR -#define SIGN_EXTEND_CHAR(x) (x) -#endif - -static int obscure_syntax = 0; - -/* Specify the precise syntax of regexp for compilation. - This provides for compatibility for various utilities - which historically have different, incompatible syntaxes. - - The argument SYNTAX is a bit-mask containing the two bits - RE_NO_BK_PARENS and RE_NO_BK_VBAR. */ - -int -re_set_syntax (syntax) -{ - int ret; - - ret = obscure_syntax; - obscure_syntax = syntax; - return ret; -} - -/* re_compile_pattern takes a regular-expression string - and converts it into a buffer full of byte commands for matching. - - PATTERN is the address of the pattern string - SIZE is the length of it. - BUFP is a struct re_pattern_buffer * which points to the info - on where to store the byte commands. - This structure contains a char * which points to the - actual space, which should have been obtained with malloc. - re_compile_pattern may use realloc to grow the buffer space. - - The number of bytes of commands can be found out by looking in - the struct re_pattern_buffer that bufp pointed to, - after re_compile_pattern returns. -*/ - -#define PATPUSH(ch) (*b++ = (char) (ch)) - -#define PATFETCH(c) \ - {if (p == pend) goto end_of_pattern; \ - c = * (unsigned char *) p++; \ - if (translate) c = translate[c]; } - -#define PATFETCH_RAW(c) \ - {if (p == pend) goto end_of_pattern; \ - c = * (unsigned char *) p++; } - -#define PATUNFETCH p-- - -#define EXTEND_BUFFER \ - { char *old_buffer = bufp->buffer; \ - if (bufp->allocated == (1<<16)) goto too_big; \ - bufp->allocated *= 2; \ - if (bufp->allocated > (1<<16)) bufp->allocated = (1<<16); \ - if (!(bufp->buffer = (char *) realloc (bufp->buffer, bufp->allocated))) \ - goto memory_exhausted; \ - c = bufp->buffer - old_buffer; \ - b += c; \ - if (fixup_jump) \ - fixup_jump += c; \ - if (laststart) \ - laststart += c; \ - begalt += c; \ - if (pending_exact) \ - pending_exact += c; \ - } - -static int store_jump (), insert_jump (); - -char * -re_compile_pattern (pattern, size, bufp) - char *pattern; - int size; - struct re_pattern_buffer *bufp; -{ - register char *b = bufp->buffer; - register char *p = pattern; - char *pend = pattern + size; - register unsigned c, c1; - char *p1; - unsigned char *translate = (unsigned char *) bufp->translate; - - /* address of the count-byte of the most recently inserted "exactn" command. - This makes it possible to tell whether a new exact-match character - can be added to that command or requires a new "exactn" command. */ - - char *pending_exact = 0; - - /* address of the place where a forward-jump should go - to the end of the containing expression. - Each alternative of an "or", except the last, ends with a forward-jump - of this sort. */ - - char *fixup_jump = 0; - - /* address of start of the most recently finished expression. - This tells postfix * where to find the start of its operand. */ - - char *laststart = 0; - - /* In processing a repeat, 1 means zero matches is allowed */ - - char zero_times_ok; - - /* In processing a repeat, 1 means many matches is allowed */ - - char many_times_ok; - - /* address of beginning of regexp, or inside of last \( */ - - char *begalt = b; - - /* Stack of information saved by \( and restored by \). - Four stack elements are pushed by each \(: - First, the value of b. - Second, the value of fixup_jump. - Third, the value of regnum. - Fourth, the value of begalt. */ - - int stackb[40]; - int *stackp = stackb; - int *stacke = stackb + 40; - int *stackt; - - /* Counts \('s as they are encountered. Remembered for the matching \), - where it becomes the "register number" to put in the stop_memory command */ - - int regnum = 1; - - bufp->fastmap_accurate = 0; - -#ifndef emacs -#ifndef SYNTAX_TABLE - /* - * Initialize the syntax table. - */ - init_syntax_once(); -#endif -#endif - - if (bufp->allocated == 0) - { - bufp->allocated = 28; - if (bufp->buffer) - /* EXTEND_BUFFER loses when bufp->allocated is 0 */ - bufp->buffer = (char *) realloc (bufp->buffer, 28); - else - /* Caller did not allocate a buffer. Do it for him */ - bufp->buffer = (char *) malloc (28); - if (!bufp->buffer) goto memory_exhausted; - begalt = b = bufp->buffer; - } - - while (p != pend) - { - if (b - bufp->buffer > bufp->allocated - 10) - /* Note that EXTEND_BUFFER clobbers c */ - EXTEND_BUFFER; - - PATFETCH (c); - - switch (c) - { - case '$': - if (obscure_syntax & RE_TIGHT_VBAR) - { - if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS) && p != pend) - goto normal_char; - /* Make operand of last vbar end before this `$'. */ - if (fixup_jump) - store_jump (fixup_jump, jump, b); - fixup_jump = 0; - PATPUSH (endline); - break; - } - - /* $ means succeed if at end of line, but only in special contexts. - If randomly in the middle of a pattern, it is a normal character. */ - if (p == pend || *p == '\n' - || (obscure_syntax & RE_CONTEXT_INDEP_OPS) - || (obscure_syntax & RE_NO_BK_PARENS - ? *p == ')' - : *p == '\\' && p[1] == ')') - || (obscure_syntax & RE_NO_BK_VBAR - ? *p == '|' - : *p == '\\' && p[1] == '|')) - { - PATPUSH (endline); - break; - } - goto normal_char; - - case '^': - /* ^ means succeed if at beg of line, but only if no preceding pattern. */ - - if (laststart && p[-2] != '\n' - && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - if (obscure_syntax & RE_TIGHT_VBAR) - { - if (p != pattern + 1 - && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - PATPUSH (begline); - begalt = b; - } - else - PATPUSH (begline); - break; - - case '+': - case '?': - if (obscure_syntax & RE_BK_PLUS_QM) - goto normal_char; - handle_plus: - case '*': - /* If there is no previous pattern, char not special. */ - if (!laststart && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - /* If there is a sequence of repetition chars, - collapse it down to equivalent to just one. */ - zero_times_ok = 0; - many_times_ok = 0; - while (1) - { - zero_times_ok |= c != '+'; - many_times_ok |= c != '?'; - if (p == pend) - break; - PATFETCH (c); - if (c == '*') - ; - else if (!(obscure_syntax & RE_BK_PLUS_QM) - && (c == '+' || c == '?')) - ; - else if ((obscure_syntax & RE_BK_PLUS_QM) - && c == '\\') - { - int c1; - PATFETCH (c1); - if (!(c1 == '+' || c1 == '?')) - { - PATUNFETCH; - PATUNFETCH; - break; - } - c = c1; - } - else - { - PATUNFETCH; - break; - } - } - - /* Star, etc. applied to an empty pattern is equivalent - to an empty pattern. */ - if (!laststart) - break; - - /* Now we know whether 0 matches is allowed, - and whether 2 or more matches is allowed. */ - if (many_times_ok) - { - /* If more than one repetition is allowed, - put in a backward jump at the end. */ - store_jump (b, maybe_finalize_jump, laststart - 3); - b += 3; - } - insert_jump (on_failure_jump, laststart, b + 3, b); - pending_exact = 0; - b += 3; - if (!zero_times_ok) - { - /* At least one repetition required: insert before the loop - a skip over the initial on-failure-jump instruction */ - insert_jump (dummy_failure_jump, laststart, laststart + 6, b); - b += 3; - } - break; - - case '.': - laststart = b; - PATPUSH (anychar); - break; - - case '[': - while (b - bufp->buffer - > bufp->allocated - 3 - (1 << BYTEWIDTH) / BYTEWIDTH) - /* Note that EXTEND_BUFFER clobbers c */ - EXTEND_BUFFER; - - laststart = b; - if (*p == '^') - PATPUSH (charset_not), p++; - else - PATPUSH (charset); - p1 = p; - - PATPUSH ((1 << BYTEWIDTH) / BYTEWIDTH); - /* Clear the whole map */ - bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); - /* Read in characters and ranges, setting map bits */ - while (1) - { - PATFETCH (c); - if (c == ']' && p != p1 + 1) break; - if (*p == '-' && p[1] != ']') - { - PATFETCH (c1); - PATFETCH (c1); - while (c <= c1) - b[c / BYTEWIDTH] |= 1 << (c % BYTEWIDTH), c++; - } - else - { - b[c / BYTEWIDTH] |= 1 << (c % BYTEWIDTH); - } - } - /* Discard any bitmap bytes that are all 0 at the end of the map. - Decrement the map-length byte too. */ - while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) - b[-1]--; - b += b[-1]; - break; - - case '(': - if (! (obscure_syntax & RE_NO_BK_PARENS)) - goto normal_char; - else - goto handle_open; - - case ')': - if (! (obscure_syntax & RE_NO_BK_PARENS)) - goto normal_char; - else - goto handle_close; - - case '\n': - if (! (obscure_syntax & RE_NEWLINE_OR)) - goto normal_char; - else - goto handle_bar; - - case '|': - if (! (obscure_syntax & RE_NO_BK_VBAR)) - goto normal_char; - else - goto handle_bar; - - case '\\': - if (p == pend) goto invalid_pattern; - PATFETCH_RAW (c); - switch (c) - { - case '(': - if (obscure_syntax & RE_NO_BK_PARENS) - goto normal_backsl; - handle_open: - if (stackp == stacke) goto nesting_too_deep; - if (regnum < RE_NREGS) - { - PATPUSH (start_memory); - PATPUSH (regnum); - } - *stackp++ = b - bufp->buffer; - *stackp++ = fixup_jump ? fixup_jump - bufp->buffer + 1 : 0; - *stackp++ = regnum++; - *stackp++ = begalt - bufp->buffer; - fixup_jump = 0; - laststart = 0; - begalt = b; - break; - - case ')': - if (obscure_syntax & RE_NO_BK_PARENS) - goto normal_backsl; - handle_close: - if (stackp == stackb) goto unmatched_close; - begalt = *--stackp + bufp->buffer; - if (fixup_jump) - store_jump (fixup_jump, jump, b); - if (stackp[-1] < RE_NREGS) - { - PATPUSH (stop_memory); - PATPUSH (stackp[-1]); - } - stackp -= 2; - fixup_jump = 0; - if (*stackp) - fixup_jump = *stackp + bufp->buffer - 1; - laststart = *--stackp + bufp->buffer; - break; - - case '|': - if (obscure_syntax & RE_NO_BK_VBAR) - goto normal_backsl; - handle_bar: - insert_jump (on_failure_jump, begalt, b + 6, b); - pending_exact = 0; - b += 3; - if (fixup_jump) - store_jump (fixup_jump, jump, b); - fixup_jump = b; - b += 3; - laststart = 0; - begalt = b; - break; - -#ifdef emacs - case '=': - PATPUSH (at_dot); - break; - - case 's': - laststart = b; - PATPUSH (syntaxspec); - PATFETCH (c); - PATPUSH (syntax_spec_code[c]); - break; - - case 'S': - laststart = b; - PATPUSH (notsyntaxspec); - PATFETCH (c); - PATPUSH (syntax_spec_code[c]); - break; -#endif /* emacs */ - - case 'w': - laststart = b; - PATPUSH (wordchar); - break; - - case 'W': - laststart = b; - PATPUSH (notwordchar); - break; - - case '<': - PATPUSH (wordbeg); - break; - - case '>': - PATPUSH (wordend); - break; - - case 'b': - PATPUSH (wordbound); - break; - - case 'B': - PATPUSH (notwordbound); - break; - - case '`': - PATPUSH (begbuf); - break; - - case '\'': - PATPUSH (endbuf); - break; - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - c1 = c - '0'; - if (c1 >= regnum) - goto normal_char; - for (stackt = stackp - 2; stackt > stackb; stackt -= 4) - if (*stackt == c1) - goto normal_char; - laststart = b; - PATPUSH (duplicate); - PATPUSH (c1); - break; - - case '+': - case '?': - if (obscure_syntax & RE_BK_PLUS_QM) - goto handle_plus; - - default: - normal_backsl: - /* You might think it would be useful for \ to mean - not to translate; but if we don't translate it - it will never match anything. */ - if (translate) c = translate[c]; - goto normal_char; - } - break; - - default: - normal_char: - if (!pending_exact || pending_exact + *pending_exact + 1 != b - || *pending_exact == 0177 || *p == '*' || *p == '^' - || ((obscure_syntax & RE_BK_PLUS_QM) - ? *p == '\\' && (p[1] == '+' || p[1] == '?') - : (*p == '+' || *p == '?'))) - { - laststart = b; - PATPUSH (exactn); - pending_exact = b; - PATPUSH (0); - } - PATPUSH (c); - (*pending_exact)++; - } - } - - if (fixup_jump) - store_jump (fixup_jump, jump, b); - - if (stackp != stackb) goto unmatched_open; - - bufp->used = b - bufp->buffer; - return 0; - - invalid_pattern: - return "Invalid regular expression"; - - unmatched_open: - return "Unmatched \\("; - - unmatched_close: - return "Unmatched \\)"; - - end_of_pattern: - return "Premature end of regular expression"; - - nesting_too_deep: - return "Nesting too deep"; - - too_big: - return "Regular expression too big"; - - memory_exhausted: - return "Memory exhausted"; -} - -/* Store where `from' points a jump operation to jump to where `to' points. - `opcode' is the opcode to store. */ - -static int -store_jump (from, opcode, to) - char *from, *to; - char opcode; -{ - from[0] = opcode; - from[1] = (to - (from + 3)) & 0377; - from[2] = (to - (from + 3)) >> 8; -} - -/* Open up space at char FROM, and insert there a jump to TO. - CURRENT_END gives te end of the storage no in use, - so we know how much data to copy up. - OP is the opcode of the jump to insert. - - If you call this function, you must zero out pending_exact. */ - -static int -insert_jump (op, from, to, current_end) - char op; - char *from, *to, *current_end; -{ - register char *pto = current_end + 3; - register char *pfrom = current_end; - while (pfrom != from) - *--pto = *--pfrom; - store_jump (from, op, to); -} - -/* Given a pattern, compute a fastmap from it. - The fastmap records which of the (1 << BYTEWIDTH) possible characters - can start a string that matches the pattern. - This fastmap is used by re_search to skip quickly over totally implausible text. - - The caller must supply the address of a (1 << BYTEWIDTH)-byte data area - as bufp->fastmap. - The other components of bufp describe the pattern to be used. */ - -void -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; -{ - unsigned char *pattern = (unsigned char *) bufp->buffer; - int size = bufp->used; - register char *fastmap = bufp->fastmap; - register unsigned char *p = pattern; - register unsigned char *pend = pattern + size; - register int j, k; - unsigned char *translate = (unsigned char *) bufp->translate; - - unsigned char *stackb[NFAILURES]; - unsigned char **stackp = stackb; - - bzero (fastmap, (1 << BYTEWIDTH)); - bufp->fastmap_accurate = 1; - bufp->can_be_null = 0; - - while (p) - { - if (p == pend) - { - bufp->can_be_null = 1; - break; - } -#ifdef SWITCH_ENUM_BUG - switch ((int) ((enum regexpcode) *p++)) -#else - switch ((enum regexpcode) *p++) -#endif - { - case exactn: - if (translate) - fastmap[translate[p[1]]] = 1; - else - fastmap[p[1]] = 1; - break; - - case begline: - case before_dot: - case at_dot: - case after_dot: - case begbuf: - case endbuf: - case wordbound: - case notwordbound: - case wordbeg: - case wordend: - continue; - - case endline: - if (translate) - fastmap[translate['\n']] = 1; - else - fastmap['\n'] = 1; - if (bufp->can_be_null != 1) - bufp->can_be_null = 2; - break; - - case finalize_jump: - case maybe_finalize_jump: - case jump: - case dummy_failure_jump: - bufp->can_be_null = 1; - j = *p++ & 0377; - j += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p += j + 1; /* The 1 compensates for missing ++ above */ - if (j > 0) - continue; - /* Jump backward reached implies we just went through - the body of a loop and matched nothing. - Opcode jumped to should be an on_failure_jump. - Just treat it like an ordinary jump. - For a * loop, it has pushed its failure point already; - if so, discard that as redundant. */ - if ((enum regexpcode) *p != on_failure_jump) - continue; - p++; - j = *p++ & 0377; - j += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p += j + 1; /* The 1 compensates for missing ++ above */ - if (stackp != stackb && *stackp == p) - stackp--; - continue; - - case on_failure_jump: - j = *p++ & 0377; - j += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p++; - *++stackp = p + j; - continue; - - case start_memory: - case stop_memory: - p++; - continue; - - case duplicate: - bufp->can_be_null = 1; - fastmap['\n'] = 1; - case anychar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (j != '\n') - fastmap[j] = 1; - if (bufp->can_be_null) - return; - /* Don't return; check the alternative paths - so we can set can_be_null if appropriate. */ - break; - - case wordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == Sword) - fastmap[j] = 1; - break; - - case notwordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != Sword) - fastmap[j] = 1; - break; - -#ifdef emacs - case syntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == (enum syntaxcode) k) - fastmap[j] = 1; - break; - - case notsyntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != (enum syntaxcode) k) - fastmap[j] = 1; - break; -#endif /* emacs */ - - case charset: - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) - { - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - } - break; - - case charset_not: - /* Chars beyond end of map must be allowed */ - for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) - { - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - } - break; - } - - /* Get here means we have successfully found the possible starting characters - of one path of the pattern. We need not follow this path any farther. - Instead, look at the next alternative remembered in the stack. */ - if (stackp != stackb) - p = *stackp--; - else - break; - } -} - -/* Like re_search_2, below, but only one string is specified. */ - -int -re_search (pbufp, string, size, startpos, range, regs) - struct re_pattern_buffer *pbufp; - char *string; - int size, startpos, range; - struct re_registers *regs; -{ - return re_search_2 (pbufp, 0, 0, string, size, startpos, range, regs, size); -} - -/* Like re_match_2 but tries first a match starting at index STARTPOS, - then at STARTPOS + 1, and so on. - RANGE is the number of places to try before giving up. - If RANGE is negative, the starting positions tried are - STARTPOS, STARTPOS - 1, etc. - It is up to the caller to make sure that range is not so large - as to take the starting position outside of the input strings. - -The value returned is the position at which the match was found, - or -1 if no match was found, - or -2 if error (such as failure stack overflow). */ - -int -re_search_2 (pbufp, string1, size1, string2, size2, startpos, range, regs, mstop) - struct re_pattern_buffer *pbufp; - char *string1, *string2; - int size1, size2; - int startpos; - register int range; - struct re_registers *regs; - int mstop; -{ - register char *fastmap = pbufp->fastmap; - register unsigned char *translate = (unsigned char *) pbufp->translate; - int total = size1 + size2; - int val; - - /* Update the fastmap now if not correct already */ - if (fastmap && !pbufp->fastmap_accurate) - re_compile_fastmap (pbufp); - - /* Don't waste time in a long search for a pattern - that says it is anchored. */ - if (pbufp->used > 0 && (enum regexpcode) pbufp->buffer[0] == begbuf - && range > 0) - { - if (startpos > 0) - return -1; - else - range = 1; - } - - while (1) - { - /* If a fastmap is supplied, skip quickly over characters - that cannot possibly be the start of a match. - Note, however, that if the pattern can possibly match - the null string, we must test it at each starting point - so that we take the first null string we get. */ - - if (fastmap && startpos < total && pbufp->can_be_null != 1) - { - if (range > 0) - { - register int lim = 0; - register unsigned char *p; - int irange = range; - if (startpos < size1 && startpos + range >= size1) - lim = range - (size1 - startpos); - - p = ((unsigned char *) - &(startpos >= size1 ? string2 - size1 : string1)[startpos]); - - if (translate) - { - while (range > lim && !fastmap[translate[*p++]]) - range--; - } - else - { - while (range > lim && !fastmap[*p++]) - range--; - } - startpos += irange - range; - } - else - { - register unsigned char c; - if (startpos >= size1) - c = string2[startpos - size1]; - else - c = string1[startpos]; - c &= 0xff; - if (translate ? !fastmap[translate[c]] : !fastmap[c]) - goto advance; - } - } - - if (range >= 0 && startpos == total - && fastmap && pbufp->can_be_null == 0) - return -1; - - val = re_match_2 (pbufp, string1, size1, string2, size2, startpos, regs, mstop); - if (0 <= val) - { - if (val == -2) - return -2; - return startpos; - } - -#ifdef C_ALLOCA - alloca (0); -#endif /* C_ALLOCA */ - - advance: - if (!range) break; - if (range > 0) range--, startpos++; else range++, startpos--; - } - return -1; -} - -#ifndef emacs /* emacs never uses this */ -int -re_match (pbufp, string, size, pos, regs) - struct re_pattern_buffer *pbufp; - char *string; - int size, pos; - struct re_registers *regs; -{ - return re_match_2 (pbufp, 0, 0, string, size, pos, regs, size); -} -#endif /* emacs */ - -/* Maximum size of failure stack. Beyond this, overflow is an error. */ - -int re_max_failures = 2000; - -static int bcmp_translate(); -/* Match the pattern described by PBUFP - against data which is the virtual concatenation of STRING1 and STRING2. - SIZE1 and SIZE2 are the sizes of the two data strings. - Start the match at position POS. - Do not consider matching past the position MSTOP. - - If pbufp->fastmap is nonzero, then it had better be up to date. - - The reason that the data to match are specified as two components - which are to be regarded as concatenated - is so this function can be used directly on the contents of an Emacs buffer. - - -1 is returned if there is no match. -2 is returned if there is - an error (such as match stack overflow). Otherwise the value is the length - of the substring which was matched. */ - -int -re_match_2 (pbufp, string1, size1, string2, size2, pos, regs, mstop) - struct re_pattern_buffer *pbufp; - unsigned char *string1, *string2; - int size1, size2; - int pos; - struct re_registers *regs; - int mstop; -{ - register unsigned char *p = (unsigned char *) pbufp->buffer; - register unsigned char *pend = p + pbufp->used; - /* End of first string */ - unsigned char *end1; - /* End of second string */ - unsigned char *end2; - /* Pointer just past last char to consider matching */ - unsigned char *end_match_1, *end_match_2; - register unsigned char *d, *dend; - register int mcnt; - unsigned char *translate = (unsigned char *) pbufp->translate; - - /* Failure point stack. Each place that can handle a failure further down the line - pushes a failure point on this stack. It consists of two char *'s. - The first one pushed is where to resume scanning the pattern; - the second pushed is where to resume scanning the strings. - If the latter is zero, the failure point is a "dummy". - If a failure happens and the innermost failure point is dormant, - it discards that failure point and tries the next one. */ - - unsigned char *initial_stack[2 * NFAILURES]; - unsigned char **stackb = initial_stack; - unsigned char **stackp = stackb, **stacke = &stackb[2 * NFAILURES]; - - /* Information on the "contents" of registers. - These are pointers into the input strings; they record - just what was matched (on this attempt) by some part of the pattern. - The start_memory command stores the start of a register's contents - and the stop_memory command stores the end. - - At that point, regstart[regnum] points to the first character in the register, - regend[regnum] points to the first character beyond the end of the register, - regstart_seg1[regnum] is true iff regstart[regnum] points into string1, - and regend_seg1[regnum] is true iff regend[regnum] points into string1. */ - - unsigned char *regstart[RE_NREGS]; - unsigned char *regend[RE_NREGS]; - unsigned char regstart_seg1[RE_NREGS], regend_seg1[RE_NREGS]; - - /* Set up pointers to ends of strings. - Don't allow the second string to be empty unless both are empty. */ - if (!size2) - { - string2 = string1; - size2 = size1; - string1 = 0; - size1 = 0; - } - end1 = string1 + size1; - end2 = string2 + size2; - - /* Compute where to stop matching, within the two strings */ - if (mstop <= size1) - { - end_match_1 = string1 + mstop; - end_match_2 = string2; - } - else - { - end_match_1 = end1; - end_match_2 = string2 + mstop - size1; - } - - /* Initialize \) text positions to -1 - to mark ones that no \( or \) has been seen for. */ - - for (mcnt = 0; mcnt < sizeof (regend) / sizeof (*regend); mcnt++) - regend[mcnt] = (unsigned char *) -1; - - /* `p' scans through the pattern as `d' scans through the data. - `dend' is the end of the input string that `d' points within. - `d' is advanced into the following input string whenever necessary, - but this happens before fetching; - therefore, at the beginning of the loop, - `d' can be pointing at the end of a string, - but it cannot equal string2. */ - - if (pos <= size1) - d = string1 + pos, dend = end_match_1; - else - d = string2 + pos - size1, dend = end_match_2; - -/* Write PREFETCH; just before fetching a character with *d. */ -#define PREFETCH \ - while (d == dend) \ - { if (dend == end_match_2) goto fail; /* end of string2 => failure */ \ - d = string2; /* end of string1 => advance to string2. */ \ - dend = end_match_2; } - - /* This loop loops over pattern commands. - It exits by returning from the function if match is complete, - or it drops through if match fails at this starting point in the input data. */ - - while (1) - { - if (p == pend) - /* End of pattern means we have succeeded! */ - { - /* If caller wants register contents data back, convert it to indices */ - if (regs) - { - regs->start[0] = pos; - if (dend == end_match_1) - regs->end[0] = d - string1; - else - regs->end[0] = d - string2 + size1; - for (mcnt = 1; mcnt < RE_NREGS; mcnt++) - { - if (regend[mcnt] == (unsigned char *) -1) - { - regs->start[mcnt] = -1; - regs->end[mcnt] = -1; - continue; - } - if (regstart_seg1[mcnt]) - regs->start[mcnt] = regstart[mcnt] - string1; - else - regs->start[mcnt] = regstart[mcnt] - string2 + size1; - if (regend_seg1[mcnt]) - regs->end[mcnt] = regend[mcnt] - string1; - else - regs->end[mcnt] = regend[mcnt] - string2 + size1; - } - } - if (dend == end_match_1) - return (d - string1 - pos); - else - return d - string2 + size1 - pos; - } - - /* Otherwise match next pattern command */ -#ifdef SWITCH_ENUM_BUG - switch ((int) ((enum regexpcode) *p++)) -#else - switch ((enum regexpcode) *p++) -#endif - { - - /* \( is represented by a start_memory, \) by a stop_memory. - Both of those commands contain a "register number" argument. - The text matched within the \( and \) is recorded under that number. - Then, \ turns into a `duplicate' command which - is followed by the numeric value of as the register number. */ - - case start_memory: - regstart[*p] = d; - regstart_seg1[*p++] = (dend == end_match_1); - break; - - case stop_memory: - regend[*p] = d; - regend_seg1[*p++] = (dend == end_match_1); - break; - - case duplicate: - { - int regno = *p++; /* Get which register to match against */ - register unsigned char *d2, *dend2; - - d2 = regstart[regno]; - dend2 = ((regstart_seg1[regno] == regend_seg1[regno]) - ? regend[regno] : end_match_1); - while (1) - { - /* Advance to next segment in register contents, if necessary */ - while (d2 == dend2) - { - if (dend2 == end_match_2) break; - if (dend2 == regend[regno]) break; - d2 = string2, dend2 = regend[regno]; /* end of string1 => advance to string2. */ - } - /* At end of register contents => success */ - if (d2 == dend2) break; - - /* Advance to next segment in data being matched, if necessary */ - PREFETCH; - - /* mcnt gets # consecutive chars to compare */ - mcnt = dend - d; - if (mcnt > dend2 - d2) - mcnt = dend2 - d2; - /* Compare that many; failure if mismatch, else skip them. */ - if (translate ? bcmp_translate (d, d2, mcnt, translate) : bcmp (d, d2, mcnt)) - goto fail; - d += mcnt, d2 += mcnt; - } - } - break; - - case anychar: - /* fetch a data character */ - PREFETCH; - /* Match anything but a newline. */ - if ((translate ? translate[*d++] : *d++) == '\n') - goto fail; - break; - - case charset: - case charset_not: - { - /* Nonzero for charset_not */ - int not = 0; - register int c; - if (*(p - 1) == (unsigned char) charset_not) - not = 1; - - /* fetch a data character */ - PREFETCH; - - if (translate) - c = translate [*d]; - else - c = *d; - - if (c < *p * BYTEWIDTH - && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - p += 1 + *p; - - if (!not) goto fail; - d++; - break; - } - - case begline: - if (d == string1 || d[-1] == '\n') - break; - goto fail; - - case endline: - if (d == end2 - || (d == end1 ? (size2 == 0 || *string2 == '\n') : *d == '\n')) - break; - goto fail; - - /* "or" constructs ("|") are handled by starting each alternative - with an on_failure_jump that points to the start of the next alternative. - Each alternative except the last ends with a jump to the joining point. - (Actually, each jump except for the last one really jumps - to the following jump, because tensioning the jumps is a hassle.) */ - - /* The start of a stupid repeat has an on_failure_jump that points - past the end of the repeat text. - This makes a failure point so that, on failure to match a repetition, - matching restarts past as many repetitions have been found - with no way to fail and look for another one. */ - - /* A smart repeat is similar but loops back to the on_failure_jump - so that each repetition makes another failure point. */ - - case on_failure_jump: - if (stackp == stacke) - { - unsigned char **stackx; - if (stacke - stackb > re_max_failures * 2) - return -2; - stackx = (unsigned char **) alloca (2 * (stacke - stackb) - * sizeof (char *)); - bcopy (stackb, stackx, (stacke - stackb) * sizeof (char *)); - stackp = stackx + (stackp - stackb); - stacke = stackx + 2 * (stacke - stackb); - stackb = stackx; - } - mcnt = *p++ & 0377; - mcnt += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p++; - *stackp++ = mcnt + p; - *stackp++ = d; - break; - - /* The end of a smart repeat has an maybe_finalize_jump back. - Change it either to a finalize_jump or an ordinary jump. */ - - case maybe_finalize_jump: - mcnt = *p++ & 0377; - mcnt += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p++; - { - register unsigned char *p2 = p; - /* Compare what follows with the begining of the repeat. - If we can establish that there is nothing that they would - both match, we can change to finalize_jump */ - while (p2 != pend - && (*p2 == (unsigned char) stop_memory - || *p2 == (unsigned char) start_memory)) - p2++; - if (p2 == pend) - p[-3] = (unsigned char) finalize_jump; - else if (*p2 == (unsigned char) exactn - || *p2 == (unsigned char) endline) - { - register int c = *p2 == (unsigned char) endline ? '\n' : p2[2]; - register unsigned char *p1 = p + mcnt; - /* p1[0] ... p1[2] are an on_failure_jump. - Examine what follows that */ - if (p1[3] == (unsigned char) exactn && p1[5] != c) - p[-3] = (unsigned char) finalize_jump; - else if (p1[3] == (unsigned char) charset - || p1[3] == (unsigned char) charset_not) - { - int not = p1[3] == (unsigned char) charset_not; - if (c < p1[4] * BYTEWIDTH - && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - /* not is 1 if c would match */ - /* That means it is not safe to finalize */ - if (!not) - p[-3] = (unsigned char) finalize_jump; - } - } - } - p -= 2; - if (p[-1] != (unsigned char) finalize_jump) - { - p[-1] = (unsigned char) jump; - goto nofinalize; - } - - /* The end of a stupid repeat has a finalize-jump - back to the start, where another failure point will be made - which will point after all the repetitions found so far. */ - - case finalize_jump: - stackp -= 2; - - case jump: - nofinalize: - mcnt = *p++ & 0377; - mcnt += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p += mcnt + 1; /* The 1 compensates for missing ++ above */ - break; - - case dummy_failure_jump: - if (stackp == stacke) - { - unsigned char **stackx - = (unsigned char **) alloca (2 * (stacke - stackb) - * sizeof (char *)); - bcopy (stackb, stackx, (stacke - stackb) * sizeof (char *)); - stackp = stackx + (stackp - stackb); - stacke = stackx + 2 * (stacke - stackb); - stackb = stackx; - } - *stackp++ = 0; - *stackp++ = 0; - goto nofinalize; - - case wordbound: - if (d == string1 /* Points to first char */ - || d == end2 /* Points to end */ - || (d == end1 && size2 == 0)) /* Points to end */ - break; - if ((SYNTAX (d[-1]) == Sword) - != (SYNTAX (d == end1 ? *string2 : *d) == Sword)) - break; - goto fail; - - case notwordbound: - if (d == string1 /* Points to first char */ - || d == end2 /* Points to end */ - || (d == end1 && size2 == 0)) /* Points to end */ - goto fail; - if ((SYNTAX (d[-1]) == Sword) - != (SYNTAX (d == end1 ? *string2 : *d) == Sword)) - goto fail; - break; - - case wordbeg: - if (d == end2 /* Points to end */ - || (d == end1 && size2 == 0) /* Points to end */ - || SYNTAX (* (d == end1 ? string2 : d)) != Sword) /* Next char not a letter */ - goto fail; - if (d == string1 /* Points to first char */ - || SYNTAX (d[-1]) != Sword) /* prev char not letter */ - break; - goto fail; - - case wordend: - if (d == string1 /* Points to first char */ - || SYNTAX (d[-1]) != Sword) /* prev char not letter */ - goto fail; - if (d == end2 /* Points to end */ - || (d == end1 && size2 == 0) /* Points to end */ - || SYNTAX (d == end1 ? *string2 : *d) != Sword) /* Next char not a letter */ - break; - goto fail; - -#ifdef emacs - case before_dot: - if (((d - string2 <= (unsigned) size2) - ? d - bf_p2 : d - bf_p1) - <= point) - goto fail; - break; - - case at_dot: - if (((d - string2 <= (unsigned) size2) - ? d - bf_p2 : d - bf_p1) - == point) - goto fail; - break; - - case after_dot: - if (((d - string2 <= (unsigned) size2) - ? d - bf_p2 : d - bf_p1) - >= point) - goto fail; - break; - - case wordchar: - mcnt = (int) Sword; - goto matchsyntax; - - case syntaxspec: - mcnt = *p++; - matchsyntax: - PREFETCH; - if (SYNTAX (*d++) != (enum syntaxcode) mcnt) goto fail; - break; - - case notwordchar: - mcnt = (int) Sword; - goto matchnotsyntax; - - case notsyntaxspec: - mcnt = *p++; - matchnotsyntax: - PREFETCH; - if (SYNTAX (*d++) == (enum syntaxcode) mcnt) goto fail; - break; -#else - case wordchar: - PREFETCH; - if (SYNTAX (*d++) == 0) goto fail; - break; - - case notwordchar: - PREFETCH; - if (SYNTAX (*d++) != 0) goto fail; - break; -#endif /* not emacs */ - - case begbuf: - if (d == string1) /* Note, d cannot equal string2 */ - break; /* unless string1 == string2. */ - goto fail; - - case endbuf: - if (d == end2 || (d == end1 && size2 == 0)) - break; - goto fail; - - case exactn: - /* Match the next few pattern characters exactly. - mcnt is how many characters to match. */ - mcnt = *p++; - if (translate) - { - do - { - PREFETCH; - if (translate[*d++] != *p++) goto fail; - } - while (--mcnt); - } - else - { - do - { - PREFETCH; - if (*d++ != *p++) goto fail; - } - while (--mcnt); - } - break; - } - continue; /* Successfully matched one pattern command; keep matching */ - - /* Jump here if any matching operation fails. */ - fail: - if (stackp != stackb) - /* A restart point is known. Restart there and pop it. */ - { - if (!stackp[-2]) - { /* If innermost failure point is dormant, flush it and keep looking */ - stackp -= 2; - goto fail; - } - d = *--stackp; - p = *--stackp; - if (d >= string1 && d <= end1) - dend = end_match_1; - } - else break; /* Matching at this starting point really fails! */ - } - return -1; /* Failure to match */ -} - -static int -bcmp_translate (s1, s2, len, translate) - unsigned char *s1, *s2; - register int len; - unsigned char *translate; -{ - register unsigned char *p1 = s1, *p2 = s2; - while (len) - { - if (translate [*p1++] != translate [*p2++]) return 1; - len--; - } - return 0; -} - -/* Entry points compatible with bsd4.2 regex library */ - -#ifndef emacs - -static struct re_pattern_buffer re_comp_buf; - -char * -re_comp (s) - char *s; -{ - if (!s) - { - if (!re_comp_buf.buffer) - return "No previous regular expression"; - return 0; - } - - if (!re_comp_buf.buffer) - { - if (!(re_comp_buf.buffer = (char *) malloc (200))) - return "Memory exhausted"; - re_comp_buf.allocated = 200; - if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH))) - return "Memory exhausted"; - } - return re_compile_pattern (s, strlen (s), &re_comp_buf); -} - -int -re_exec (s) - char *s; -{ - int len = strlen (s); - return 0 <= re_search (&re_comp_buf, s, len, 0, len, 0); -} - -#endif /* emacs */ - -#ifdef test - -#include - -/* Indexed by a character, gives the upper case equivalent of the character */ - -static char upcase[0400] = - { 000, 001, 002, 003, 004, 005, 006, 007, - 010, 011, 012, 013, 014, 015, 016, 017, - 020, 021, 022, 023, 024, 025, 026, 027, - 030, 031, 032, 033, 034, 035, 036, 037, - 040, 041, 042, 043, 044, 045, 046, 047, - 050, 051, 052, 053, 054, 055, 056, 057, - 060, 061, 062, 063, 064, 065, 066, 067, - 070, 071, 072, 073, 074, 075, 076, 077, - 0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137, - 0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177, - 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, - 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, - 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, - 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, - 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, - 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, - 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, - 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, - 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, - 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, - 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, - 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, - 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, - 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, - 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, - 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377 - }; - -main (argc, argv) - int argc; - char **argv; -{ - char pat[80]; - struct re_pattern_buffer buf; - int i; - char c; - char fastmap[(1 << BYTEWIDTH)]; - - /* Allow a command argument to specify the style of syntax. */ - if (argc > 1) - obscure_syntax = atoi (argv[1]); - - buf.allocated = 40; - buf.buffer = (char *) malloc (buf.allocated); - buf.fastmap = fastmap; - buf.translate = upcase; - - while (1) - { - gets (pat); - - if (*pat) - { - re_compile_pattern (pat, strlen(pat), &buf); - - for (i = 0; i < buf.used; i++) - printchar (buf.buffer[i]); - - putchar ('\n'); - - printf ("%d allocated, %d used.\n", buf.allocated, buf.used); - - re_compile_fastmap (&buf); - printf ("Allowed by fastmap: "); - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (fastmap[i]) printchar (i); - putchar ('\n'); - } - - gets (pat); /* Now read the string to match against */ - - i = re_match (&buf, pat, strlen (pat), 0, 0); - printf ("Match value %d.\n", i); - } -} - -#ifdef NOTDEF -print_buf (bufp) - struct re_pattern_buffer *bufp; -{ - int i; - - printf ("buf is :\n----------------\n"); - for (i = 0; i < bufp->used; i++) - printchar (bufp->buffer[i]); - - printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used); - - printf ("Allowed by fastmap: "); - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (bufp->fastmap[i]) - printchar (i); - printf ("\nAllowed by translate: "); - if (bufp->translate) - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (bufp->translate[i]) - printchar (i); - printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't"); - printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not"); -} -#endif - -printchar (c) - char c; -{ - if (c < 041 || c >= 0177) - { - putchar ('\\'); - putchar (((c >> 6) & 3) + '0'); - putchar (((c >> 3) & 7) + '0'); - putchar ((c & 7) + '0'); - } - else - putchar (c); -} - -error (string) - char *string; -{ - puts (string); - exit (1); -} - -#endif /* test */ diff --git a/gnu/usr.bin/gdb/regex.h b/gnu/usr.bin/gdb/regex.h deleted file mode 100644 index 1cb2566bda1e..000000000000 --- a/gnu/usr.bin/gdb/regex.h +++ /dev/null @@ -1,188 +0,0 @@ -/* Definitions for data structures callers pass the regex library. - Copyright (C) 1985, 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 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. - - - In other words, you are welcome to use, share and improve this program. - You are forbidden to forbid anyone else to use, share and improve - what you give them. Help stamp out software-hoarding! - - $Id: regex.h,v 1.2 1993/08/02 17:41:08 mycroft Exp $ -*/ - - -/* 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 - -/* These bits are used in the obscure_syntax variable to choose among - alternative regexp syntaxes. */ - -/* 1 means plain parentheses serve as grouping, and backslash - parentheses are needed for literal searching. - 0 means backslash-parentheses are grouping, and plain parentheses - are for literal searching. */ -#define RE_NO_BK_PARENS 1 - -/* 1 means plain | serves as the "or"-operator, and \| is a literal. - 0 means \| serves as the "or"-operator, and | is a literal. */ -#define RE_NO_BK_VBAR 2 - -/* 0 means plain + or ? serves as an operator, and \+, \? are literals. - 1 means \+, \? are operators and plain +, ? are literals. */ -#define RE_BK_PLUS_QM 4 - -/* 1 means | binds tighter than ^ or $. - 0 means the contrary. */ -#define RE_TIGHT_VBAR 8 - -/* 1 means treat \n as an _OR operator - 0 means treat it as a normal character */ -#define RE_NEWLINE_OR 16 - -/* 0 means that a special characters (such as *, ^, and $) always have - their special meaning regardless of the surrounding context. - 1 means that 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 | */ -#define RE_CONTEXT_INDEP_OPS 32 - -/* Now define combinations of bits for the standard possibilities. */ -#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS) -#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR) -#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR) -#define RE_SYNTAX_EMACS 0 - -/* This data structure is used to represent a compiled pattern. */ - -struct re_pattern_buffer - { - char *buffer; /* Space holding the compiled pattern commands. */ - int allocated; /* Size of space that buffer points to */ - int 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 quickly 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. */ - }; - -/* 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. - - start[i] and end[i] record the string matched by \( ... \) grouping i, - for i from 1 to RE_NREGS - 1. - start[0] and end[0] record the entire string matched. */ - -struct re_registers - { - int start[RE_NREGS]; - int end[RE_NREGS]; - }; - -/* These are the command codes that appear in compiled regular expressions, one per byte. - Some command codes are followed by argument bytes. - A command code can specify any interpretation whatever for its arguments. - Zero-bytes may appear in the compiled regular expression. */ - -enum regexpcode - { - unused, - exactn, /* followed by one byte giving n, and then by n literal bytes */ - begline, /* fails unless at beginning of line */ - endline, /* fails unless at end of line */ - jump, /* followed by two bytes giving relative address to jump to */ - on_failure_jump, /* followed by two bytes giving relative address of place - to resume at in case of failure. */ - finalize_jump, /* Throw away latest failure point and then jump to address. */ - maybe_finalize_jump, /* Like jump but finalize if safe to do so. - This is used to jump back to the beginning - of a repeat. If the command that follows - this jump is clearly incompatible with the - one at the beginning of the repeat, such that - we can be sure that there is no use backtracking - out of repetitions already completed, - then we finalize. */ - dummy_failure_jump, /* jump, and push a dummy failure point. - This failure point will be thrown away - if an attempt is made to use it for a failure. - A + construct makes this before the first repeat. */ - anychar, /* matches any one character */ - charset, /* matches any one char belonging to specified set. - First following byte is # bitmap bytes. - Then come bytes for a bit-map saying which chars are in. - Bits in each byte are ordered low-bit-first. - A character is in the set if its bit is 1. - A character too large to have a bit in the map - is automatically not in the set */ - charset_not, /* similar but match any character that is NOT one of those specified */ - start_memory, /* starts remembering the text that is matched - and stores it in a memory register. - followed by one byte containing the register number. - Register numbers must be in the range 0 through NREGS. */ - stop_memory, /* stops remembering the text that is matched - and stores it in a memory register. - followed by one byte containing the register number. - Register numbers must be in the range 0 through NREGS. */ - duplicate, /* match a duplicate of something remembered. - Followed by one byte containing the index of the memory register. */ - before_dot, /* Succeeds if before dot */ - at_dot, /* Succeeds if at dot */ - after_dot, /* Succeeds if after dot */ - begbuf, /* Succeeds if at beginning of buffer */ - endbuf, /* Succeeds if at end of buffer */ - wordchar, /* Matches any word-constituent character */ - notwordchar, /* Matches any char that is not a word-constituent */ - wordbeg, /* Succeeds if at word beginning */ - wordend, /* Succeeds if at word end */ - wordbound, /* Succeeds if at a word boundary */ - notwordbound, /* Succeeds if not at a word boundary */ - syntaxspec, /* Matches any character whose syntax is specified. - followed by a byte which contains a syntax code, Sword or such like */ - notsyntaxspec /* Matches any character whose syntax differs from the specified. */ - }; - -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 (yuck) */ -extern char *re_comp (); -extern int re_exec (); - -#ifdef SYNTAX_TABLE -extern char *re_syntax_table; -#endif diff --git a/gnu/usr.bin/gdb/remote-sl.c b/gnu/usr.bin/gdb/remote-sl.c deleted file mode 100644 index abd6a007d2ff..000000000000 --- a/gnu/usr.bin/gdb/remote-sl.c +++ /dev/null @@ -1,12 +0,0 @@ -/* $Id: remote-sl.c,v 1.2 1993/08/02 17:41:08 mycroft Exp $ */ - -/* - * The binary remote protocol is still under development at LBL; - * the current version can't be released. - * Sorry, folks... - */ -int -sl_open() -{ - return -1; -} diff --git a/gnu/usr.bin/gdb/remote.c b/gnu/usr.bin/gdb/remote.c deleted file mode 100644 index 48976b147ccd..000000000000 --- a/gnu/usr.bin/gdb/remote.c +++ /dev/null @@ -1,627 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Van Jacobson and Steven McCanne of Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Header: /cvsroot/src/gnu/usr.bin/gdb/Attic/remote.c,v 1.2 1993/08/01 18:47:43 mycroft Exp $; - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)remote.c 6.5 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: remote.c,v 1.2 1993/08/01 18:47:43 mycroft Exp $"; -#endif /* not lint */ - -#include "param.h" - -#include -#include - -#include -#include -#include -#include - -#include "defs.h" -#include "frame.h" -#include "inferior.h" -#include "wait.h" - -#include "kgdb_proto.h" - -static FILE *kiodebug; -static int icache = 1; -extern int kernel_debugging; - -static int remote_cache_valid; -static int remote_instub; - -static void remote_signal(); -static void remote_debug(); -static void print_msg(); - -static int remote_mtu; -static int (*send_msg)(); -static int (*recv_msg)(); -static void (*closelink)(); - -static u_char *inbuffer; -static u_char *outbuffer; - -/* - * Statistics. - */ -static int remote_ierrs; -static int remote_oerrs; -static int remote_seqerrs; -static int remote_spurious; - -#define PUTCMD(cmd) m_xchg(cmd, (u_char *)0, 0, (u_char *)0, (int *)0) - -/* - * Send an outbound message to the remote machine and read the reply. - * Either or both message buffers may be NULL. - */ -static int -m_xchg(type, out, outlen, in, inlen) - int type; - u_char *out; - int outlen; - u_char *in; - int *inlen; -{ - register int err, (*send)() = send_msg, (*recv)() = recv_msg; - int ack; - static int seqbit = 0; - - if (!remote_instub) { - remote_instub = 1; - PUTCMD(KGDB_EXEC); - } - - seqbit ^= KGDB_SEQ; - while (1) { - err = (*send)(type | seqbit, out, outlen); - if (err) { - ++remote_oerrs; - if (kiodebug) - remote_debug("send error %d\n", err); - } - if (kiodebug) - print_msg(type | seqbit, out, outlen, 'O'); - - recv: - err = (*recv)(&ack, in, inlen); - if (err) { - ++remote_ierrs; - if (kiodebug) - remote_debug("recv error %d\n", err); - remote_cache_valid = 0; - } else if (kiodebug) - print_msg(ack, in, inlen ? *inlen : 0, 'I'); - - if (err) - continue; - - if ((ack & KGDB_ACK) == 0 || KGDB_CMD(ack) != KGDB_CMD(type)) { - ++remote_spurious; - continue; - } - if ((ack & KGDB_SEQ) ^ seqbit) { - ++remote_seqerrs; - goto recv; - } - return ack; - } -} - -/* - * Wait for the specified message type. Discard anything else. - * (this is used by 'remote-signal' to help us resync with other side.) - */ -static void -m_recv(type, in, inlen) - int type; - u_char *in; - int *inlen; -{ - int reply, err; - - while (1) { - err = (*recv_msg)(&reply, in, inlen); - if (err) { - ++remote_ierrs; - if (kiodebug) - remote_debug("recv error %d\n", err); - } else if (kiodebug) - print_msg(reply, in, inlen ? *inlen : 0, 'I'); - - if (KGDB_CMD(reply) == type) - return; - ++remote_spurious; - } -} - -/* - * Send a message. Do not wait for *any* response from the other side. - * Some other thread of control will pick up the ack that will be generated. - */ -static void -m_send(type, buf, len) - int type; - u_char *buf; - int len; -{ - int err; - - if (!remote_instub) { - remote_instub = 1; - PUTCMD(KGDB_EXEC); - } - - err = (*send_msg)(type, buf, len); - if (err) { - ++remote_ierrs; - if (kiodebug) - remote_debug("[send error %d] ", err); - } - if (kiodebug) - print_msg(type, buf, len, 'O'); -} - -/* - * Open a connection to a remote debugger. - * NAME is the filename used for communication. - */ -void -remote_open(name, from_tty) - char *name; - int from_tty; -{ - int bufsize; - - remote_debugging = 0; - if (sl_open(name, &send_msg, &recv_msg, &closelink, &remote_mtu, - &bufsize)) - return; - if (from_tty) - printf("Remote debugging using %s\n", name); - remote_debugging = 1; - - remote_cache_valid = 0; - - inbuffer = (u_char *)malloc(bufsize); - outbuffer = (u_char *)malloc(bufsize); - - remote_signal(); - - remote_ierrs = 0; - remote_oerrs = 0; - remote_spurious = 0; -} - -/* - * Close the open connection to the remote debugger. Use this when you want - * to detach and do something else with your gdb. - */ -void -remote_close(from_tty) - int from_tty; -{ - if (!remote_debugging) - error("remote debugging not enabled"); - - remote_debugging = 0; - /* - * Take remote machine out of debug mode. - */ - (void)PUTCMD(KGDB_KILL); - (*closelink)(); - if (from_tty) - printf("Ending remote debugging\n"); - - free((char *)inbuffer); - free((char *)outbuffer); -} - -/* - * Tell the remote machine to resume. - */ -int -remote_resume(step, signal) - int step, signal; -{ - if (!step) { - (void)PUTCMD(KGDB_CONT); - remote_instub = 0; - } else { -#ifdef NO_SINGLE_STEP - single_step(0); -#else - (void)PUTCMD(KGDB_STEP); -#endif - } -} - -/* - * Wait until the remote machine stops, then return, storing status in STATUS - * just as `wait' would. - */ -int -remote_wait(status) - WAITTYPE *status; -{ - int len; - - WSETEXIT((*status), 0); - /* - * When the machine stops, it will send us a KGDB_SIGNAL message, - * so we wait for one of these. - */ - m_recv(KGDB_SIGNAL, inbuffer, &len); - WSETSTOP((*status), inbuffer[0]); -} - -/* - * Register context as of last remote_fetch_registers(). - */ -static char reg_cache[REGISTER_BYTES]; - -/* - * Read the remote registers into the block REGS. - */ -void -remote_fetch_registers(regs) - char *regs; -{ - int regno, len, rlen, ack; - u_char *cp, *ep; - - regno = -1; - do { - outbuffer[0] = regno + 1; - ack = m_xchg(remote_cache_valid ? - KGDB_REG_R|KGDB_DELTA : KGDB_REG_R, - outbuffer, 1, inbuffer, &len); - cp = inbuffer; - ep = cp + len; - while (cp < ep) { - regno = *cp++; - rlen = REGISTER_RAW_SIZE(regno); - bcopy((char *)cp, - ®_cache[REGISTER_BYTE(regno)], rlen); - cp += rlen; - } - } while (ack & KGDB_MORE); - - remote_cache_valid = 1; - bcopy(reg_cache, regs, REGISTER_BYTES); -} - -/* - * Store the remote registers from the contents of the block REGS. - */ -void -remote_store_registers(regs) - char *regs; -{ - u_char *cp, *ep; - int regno, off, rlen; - - cp = outbuffer; - ep = cp + remote_mtu; - - for (regno = 0; regno < NUM_REGS; ++regno) { - off = REGISTER_BYTE(regno); - rlen = REGISTER_RAW_SIZE(regno); - if (!remote_cache_valid || - bcmp(®s[off], ®_cache[off], rlen) != 0) { - if (cp + rlen + 1 >= ep) { - (void)m_xchg(KGDB_REG_W, - outbuffer, cp - outbuffer, - (u_char *)0, (int *)0); - cp = outbuffer; - } - *cp++ = regno; - bcopy(®s[off], cp, rlen); - cp += rlen; - } - } - if (cp != outbuffer) - (void)m_xchg(KGDB_REG_W, outbuffer, cp - outbuffer, - (u_char *)0, (int *)0); - bcopy(regs, reg_cache, REGISTER_BYTES); -} - -/* - * Store a chunk of memory into the remote host. - * 'remote_addr' is the address in the remote memory space. - * 'cp' is the address of the buffer in our space, and 'len' is - * the number of bytes. Returns an errno status. - */ -int -remote_write_inferior_memory(remote_addr, cp, len) - CORE_ADDR remote_addr; - u_char *cp; - int len; -{ - int cnt; - - while (len > 0) { - cnt = min(len, remote_mtu - 4); - bcopy((char *)&remote_addr, outbuffer, 4); - bcopy(cp, outbuffer + 4, cnt); - (void)m_xchg(KGDB_MEM_W, outbuffer, cnt + 4, inbuffer, &len); - - if (inbuffer[0]) - return inbuffer[0]; - - remote_addr += cnt; - cp += cnt; - len -= cnt; - } - return 0; -} - -/* - * Read memory data directly from the remote machine. - * 'remote_addr' is the address in the remote memory space. - * 'cp' is the address of the buffer in our space, and 'len' is - * the number of bytes. Returns an errno status. - */ -static int -remote_read_memory(remote_addr, cp, len) - CORE_ADDR remote_addr; - u_char *cp; - int len; -{ - int cnt, inlen; - - while (len > 0) { - cnt = min(len, remote_mtu - 1); - outbuffer[0] = cnt; - bcopy((char *)&remote_addr, (char *)&outbuffer[1], 4); - - (void)m_xchg(KGDB_MEM_R, outbuffer, 5, inbuffer, &inlen); - - if (inbuffer[0] != 0) - return inbuffer[0]; - - if (cnt != inlen - 1) - /* XXX */ - error("remote_read_memory() request botched"); - - bcopy((char *)&inbuffer[1], (char *)cp, cnt); - - remote_addr += cnt; - cp += cnt; - len -= cnt; - } - return 0; -} - -int -remote_read_inferior_memory(remote_addr, cp, len) - CORE_ADDR remote_addr; - char *cp; - int len; -{ - int stat = 0; - - if (icache) { - extern CORE_ADDR text_start, text_end; - CORE_ADDR xferend = remote_addr + len; - - if (remote_addr < text_end && text_start < xferend) { - /* - * at least part of this xfer is in the text - * space -- xfer the overlap from the exec file. - */ - if (remote_addr >= text_start && xferend < text_end) - return (xfer_core_file(remote_addr, cp, len)); - if (remote_addr >= text_start) { - int i = text_end - remote_addr; - - if (stat = xfer_core_file(remote_addr, cp, i)) - return (stat); - remote_addr += i; - cp += i; - len -= i; - } else if (xferend <= text_end) { - int i = xferend - text_start; - - len = text_start - remote_addr; - if (stat = xfer_core_file(text_start, - cp + len, i)) - return (stat); - } - } - } - return remote_read_memory(remote_addr, cp, len); -} - -/* - * Signal the remote machine. The remote end might be idle or it might - * already be in debug mode -- we need to handle both case. Thus, we use - * the framing character as the wakeup byte, and send a SIGNAL packet. - * If the remote host is idle, the framing character will wake it up. - * If it is in the kgdb stub, then we will get a SIGNAL reply. - */ -static void -remote_signal() -{ - if (!remote_debugging) - printf("Remote debugging not enabled.\n"); - else { - remote_instub = 0; - m_send(KGDB_SIGNAL, (u_char *)0, 0); - } -} - -static void -remote_signal_command() -{ - extern int stop_after_attach; - - if (!remote_debugging) - error("Not debugging remote."); - remote_cache_valid = 0; - remote_signal(); - restart_remote(); -} - -/* - * Print a message for debugging. - */ -static void -print_msg(type, buf, len, dir) - int type; - u_char *buf; - int len; - int dir; -{ - int i; - char *s; - - switch (KGDB_CMD(type)) { - case KGDB_MEM_R: s = "memr"; break; - case KGDB_MEM_W: s = "memw"; break; - case KGDB_REG_R: s = "regr"; break; - case KGDB_REG_W: s = "regw"; break; - case KGDB_CONT: s = "cont"; break; - case KGDB_STEP: s = "step"; break; - case KGDB_KILL: s = "kill"; break; - case KGDB_SIGNAL: s = "sig "; break; - case KGDB_EXEC: s = "exec"; break; - default: s = "unk "; break; - } - remote_debug("%c %c%c%c%c %s (%02x): ", dir, - (type & KGDB_ACK) ? 'A' : '.', - (type & KGDB_DELTA) ? 'D' : '.', - (type & KGDB_MORE) ? 'M' : '.', - (type & KGDB_SEQ) ? '-' : '+', - s, type); - if (buf) - for (i = 0; i < len; ++i) - remote_debug("%02x", buf[i]); - remote_debug("\n"); -} - -static void -set_remote_text_refs_command(arg, from_tty) - char *arg; - int from_tty; -{ - icache = !parse_binary_operation("set remote-text-refs", arg); -} - -static void -remote_debug_command(arg, from_tty) - char *arg; - int from_tty; -{ - char *name; - - if (kiodebug != 0 && kiodebug != stderr) - (void)fclose(kiodebug); - - if (arg == 0) { - kiodebug = 0; - printf("Remote debugging off.\n"); - return; - } - if (arg[0] == '-') { - kiodebug = stderr; - name = "stderr"; - } else { - kiodebug = fopen(arg, "w"); - if (kiodebug == 0) { - printf("Cannot open '%s'.\n", arg); - return; - } - name = arg; - } - printf("Remote debugging output routed to %s.\n", name); -} - -/* ARGSUSED */ -static void -remote_info(arg, from_tty) - char *arg; - int from_tty; -{ - printf("Using %s for text references.\n", - icache? "local executable" : "remote"); - printf("Protocol debugging is %s.\n", kiodebug? "on" : "off"); - printf("%d spurious input messages.\n", remote_spurious); - printf("%d input errors; %d output errors; %d sequence errors.\n", - remote_ierrs, remote_oerrs, remote_seqerrs); -} - -/* VARARGS */ -static void -remote_debug(va_alist) - va_dcl -{ - register char *cp; - va_list ap; - - va_start(ap); - cp = va_arg(ap, char *); - (void)vfprintf(kiodebug, cp, ap); - va_end(ap); - fflush(kiodebug); -} - -extern struct cmd_list_element *setlist; - -void -_initialize_remote() -{ - add_com("remote-signal", class_run, remote_signal_command, - "If remote debugging, send interrupt signal to remote."); - add_cmd("remote-text-refs", class_support, - set_remote_text_refs_command, -"Enable/disable use of local executable for text segment references.\n\ -If on, all memory read/writes go to remote.\n\ -If off, text segment reads use the local executable.", - &setlist); - - add_com("remote-debug", class_run, remote_debug_command, -"With a file name argument, enables output of remote protocol debugging\n\ -messages to said file. If file is `-', stderr is used.\n\ -With no argument, remote debugging is disabled."); - - add_info("remote", remote_info, - "Show current settings of remote debugging options."); -} - diff --git a/gnu/usr.bin/gdb/source.c b/gnu/usr.bin/gdb/source.c deleted file mode 100644 index dc106ae89664..000000000000 --- a/gnu/usr.bin/gdb/source.c +++ /dev/null @@ -1,1167 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)source.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: source.c,v 1.3 1993/12/07 19:58:34 mycroft Exp $"; -#endif /* not lint */ - -/* List lines of source files for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "defs.h" -#include "symtab.h" -#include "param.h" - -#ifdef USG -#include -#include -#endif - -#include -#include -#include - -/* Path of directories to search for source files. - Same format as the PATH environment variable's value. */ - -static char *source_path; - -/* Symtab of default file for listing lines of. */ - -struct symtab *current_source_symtab; - -/* Default next line to list. */ - -int current_source_line; - -/* Line number of last line printed. Default for various commands. - current_source_line is usually, but not always, the same as this. */ - -static int last_line_listed; - -/* First line number listed by last listing command. */ - -static int first_line_listed; - - -struct symtab *psymtab_to_symtab (); - -/* Set the source file default for the "list" command, specifying a - symtab. Sigh. Behaivior specification: If it is called with a - non-zero argument, that is the symtab to select. If it is not, - first lookup "main"; if it exists, use the symtab and line it - defines. If not, take the last symtab in the symtab_list (if it - exists) or the last symtab in the psytab_list (if *it* exists). If - none of this works, report an error. */ - -void -select_source_symtab (s) - register struct symtab *s; -{ - struct symtabs_and_lines sals; - struct symtab_and_line sal; - struct partial_symtab *ps, *cs_pst; - - if (s) - { - current_source_symtab = s; - current_source_line = 1; - return; - } - - /* Make the default place to list be the function `main' - if one exists. */ - if (lookup_symbol ("main", 0, VAR_NAMESPACE, 0)) - { - sals = decode_line_spec ("main", 1); - sal = sals.sals[0]; - free (sals.sals); - current_source_symtab = sal.symtab; - current_source_line = max (sal.line - 9, 1); - return; - } - - /* All right; find the last file in the symtab list (ignoring .h's). */ - - if (s = symtab_list) - { - do - { - char *name = s->filename; - int len = strlen (name); - if (! (len > 2 && !strcmp (&name[len - 2], ".h"))) - current_source_symtab = s; - s = s->next; - } - while (s); - current_source_line = 1; - } - else if (partial_symtab_list) - { - ps = partial_symtab_list; - while (ps) - { - char *name = ps->filename; - int len = strlen (name); - if (! (len > 2 && !strcmp (&name[len - 2], ".h"))) - cs_pst = ps; - ps = ps->next; - } - if (cs_pst) - if (cs_pst->readin) - fatal ("Internal: select_source_symtab: readin pst found and no symtabs."); - else - current_source_symtab = psymtab_to_symtab (cs_pst); - else - current_source_symtab = 0; - current_source_line = 1; - } -} - -static void -directories_info () -{ - printf ("Source directories searched: %s\n", source_path); -} - -void -init_source_path () -{ - register struct symtab *s; - - source_path = savestring (current_directory, strlen (current_directory)); - - /* Forget what we learned about line positions in source files; - must check again now since files may be found in - a different directory now. */ - for (s = symtab_list; s; s = s->next) - if (s->line_charpos != 0) - { - free (s->line_charpos); - s->line_charpos = 0; - } -} - -void -directory_command (dirname, from_tty) - char *dirname; - int from_tty; -{ - char *old = source_path; - - dont_repeat (); - - if (dirname == 0) - { - if (query ("Reinitialize source path to %s? ", current_directory)) - { - init_source_path (); - free (old); - } - } - else - { - dirname = tilde_expand (dirname); - make_cleanup (free, dirname); - - do - { - char *name = dirname; - register char *p; - struct stat st; - - { - char *colon = index (name, ':'); - char *space = index (name, ' '); - char *tab = index (name, '\t'); - if (colon == 0 && space == 0 && tab == 0) - p = dirname = name + strlen (name); - else - { - p = 0; - if (colon != 0 && (p == 0 || colon < p)) - p = colon; - if (space != 0 && (p == 0 || space < p)) - p = space; - if (tab != 0 && (p == 0 || tab < p)) - p = tab; - dirname = p + 1; - while (*dirname == ':' || *dirname == ' ' || *dirname == '\t') - ++dirname; - } - } - - if (p[-1] == '/') - /* Sigh. "foo/" => "foo" */ - --p; - *p = '\0'; - - while (p[-1] == '.') - { - if (p - name == 1) - { - /* "." => getwd (). */ - name = current_directory; - goto append; - } - else if (p[-2] == '/') - { - if (p - name == 2) - { - /* "/." => "/". */ - *--p = '\0'; - goto append; - } - else - { - /* "...foo/." => "...foo". */ - p -= 2; - *p = '\0'; - continue; - } - } - else - break; - } - - if (*name != '/') - name = concat (current_directory, "/", name); - else - name = savestring (name, p - name); - make_cleanup (free, name); - - if (stat (name, &st) < 0) - perror_with_name (name); - if ((st.st_mode & S_IFMT) != S_IFDIR) - error ("%s is not a directory.", name); - - append: - { - register unsigned int len = strlen (name); - - p = source_path; - while (1) - { - if (!strncmp (p, name, len) - && (p[len] == '\0' || p[len] == ':')) - { - if (from_tty) - printf ("\"%s\" is already in the source path.\n", name); - break; - } - p = index (p, ':'); - if (p != 0) - ++p; - else - break; - } - if (p == 0) - { - source_path = concat (old, ":", name); - free (old); - old = source_path; - } - } - } while (*dirname != '\0'); - if (from_tty) - directories_info (); - } -} - -/* Open a file named STRING, searching path PATH (dir names sep by colons) - using mode MODE and protection bits PROT in the calls to open. - If TRY_CWD_FIRST, try to open ./STRING before searching PATH. - (ie pretend the first element of PATH is ".") - If FILENAMED_OPENED is non-null, set it to a newly allocated string naming - the actual file opened (this string will always start with a "/" - - If a file is found, return the descriptor. - Otherwise, return -1, with errno set for the last name we tried to open. */ - -/* >>>> This should only allow files of certain types, - >>>> eg executable, non-directory */ -int -openp (path, try_cwd_first, string, mode, prot, filename_opened) - char *path; - int try_cwd_first; - char *string; - int mode; - int prot; - char **filename_opened; -{ - register int fd; - register char *filename; - register char *p, *p1; - register int len; - - if (!path) - path = "."; - - /* ./foo => foo */ - while (string[0] == '.' && string[1] == '/') - string += 2; - - if (try_cwd_first || string[0] == '/') - { - filename = string; - fd = open (filename, mode, prot); - if (fd >= 0 || string[0] == '/') - goto done; - } - - filename = (char *) alloca (strlen (path) + strlen (string) + 2); - fd = -1; - for (p = path; p; p = p1 ? p1 + 1 : 0) - { - p1 = (char *) index (p, ':'); - if (p1) - len = p1 - p; - else - len = strlen (p); - - strncpy (filename, p, len); - filename[len] = 0; - strcat (filename, "/"); - strcat (filename, string); - - fd = open (filename, mode, prot); - if (fd >= 0) break; - } - - done: - if (filename_opened) - if (fd < 0) - *filename_opened = (char *) 0; - else if (filename[0] == '/') - *filename_opened = savestring (filename, strlen (filename)); - else - { - *filename_opened = concat (current_directory, "/", filename); - } - - return fd; -} - -/* Create and initialize the table S->line_charpos that records - the positions of the lines in the source file, which is assumed - to be open on descriptor DESC. - All set S->nlines to the number of such lines. */ - -static void -find_source_lines (s, desc) - struct symtab *s; - int desc; -{ - struct stat st; - register char *data, *p, *end; - int nlines = 0; - int lines_allocated = 1000; - int *line_charpos = (int *) xmalloc (lines_allocated * sizeof (int)); - extern int exec_mtime; - - if (fstat (desc, &st) < 0) - perror_with_name (s->filename); - if (get_exec_file (0) != 0 && exec_mtime < st.st_mtime) - printf ("Source file is more recent than executable.\n"); - - data = (char *) alloca (st.st_size); - if (myread (desc, data, st.st_size) < 0) - perror_with_name (s->filename); - end = data + st.st_size; - p = data; - line_charpos[0] = 0; - nlines = 1; - while (p != end) - { - if (*p++ == '\n' - /* A newline at the end does not start a new line. */ - && p != end) - { - if (nlines == lines_allocated) - { - lines_allocated *= 2; - line_charpos = (int *) xrealloc (line_charpos, - sizeof (int) * lines_allocated); - } - line_charpos[nlines++] = p - data; - } - } - s->nlines = nlines; - s->line_charpos = (int *) xrealloc (line_charpos, nlines * sizeof (int)); -} - -/* Return the character position of a line LINE in symtab S. - Return 0 if anything is invalid. */ - -int -source_line_charpos (s, line) - struct symtab *s; - int line; -{ - if (!s) return 0; - if (!s->line_charpos || line <= 0) return 0; - if (line > s->nlines) - line = s->nlines; - return s->line_charpos[line - 1]; -} - -/* Return the line number of character position POS in symtab S. */ - -int -source_charpos_line (s, chr) - register struct symtab *s; - register int chr; -{ - register int line = 0; - register int *lnp; - - if (s == 0 || s->line_charpos == 0) return 0; - lnp = s->line_charpos; - /* Files are usually short, so sequential search is Ok */ - while (line < s->nlines && *lnp <= chr) - { - line++; - lnp++; - } - if (line >= s->nlines) - line = s->nlines; - return line; -} - -/* Get full pathname and line number positions for a symtab. - Return nonzero if line numbers may have changed. - Set *FULLNAME to actual name of the file as found by `openp', - or to 0 if the file is not found. */ - -int -get_filename_and_charpos (s, line, fullname) - struct symtab *s; - int line; - char **fullname; -{ - register int desc, linenums_changed = 0; - - desc = openp (source_path, 0, s->filename, O_RDONLY, 0, &s->fullname); - if (desc < 0) - { - if (fullname) - *fullname = NULL; - return 0; - } - if (fullname) - *fullname = s->fullname; - if (s->line_charpos == 0) linenums_changed = 1; - if (linenums_changed) find_source_lines (s, desc); - close (desc); - return linenums_changed; -} - -/* Print text describing the full name of the source file S - and the line number LINE and its corresponding character position. - The text starts with two Ctrl-z so that the Emacs-GDB interface - can easily find it. - - MID_STATEMENT is nonzero if the PC is not at the beginning of that line. - - Return 1 if successful, 0 if could not find the file. */ - -int -identify_source_line (s, line, mid_statement) - struct symtab *s; - int line; - int mid_statement; -{ - if (s->line_charpos == 0) - get_filename_and_charpos (s, line, 0); - if (s->fullname == 0) - return 0; - printf ("\032\032%s:%d:%d:%s:0x%x\n", s->fullname, - line, s->line_charpos[line - 1], - mid_statement ? "middle" : "beg", - get_frame_pc (get_current_frame())); - current_source_line = line; - first_line_listed = line; - last_line_listed = line; - current_source_symtab = s; - return 1; -} - -/* Print source lines from the file of symtab S, - starting with line number LINE and stopping before line number STOPLINE. */ - -void -print_source_lines (s, line, stopline, noerror) - struct symtab *s; - int line, stopline; - int noerror; -{ - register int c; - register int desc; - register FILE *stream; - int nlines = stopline - line; - - desc = openp (source_path, 0, s->filename, O_RDONLY, 0, &s->fullname); - if (desc < 0) - { - extern int errno; - if (noerror && line + 1 == stopline) - { - /* can't find the file - tell user where we are anyway */ - current_source_symtab = s; - current_source_line = line; - first_line_listed = line; - last_line_listed = line; - printf_filtered ("%d\t(%s)\n", current_source_line++, s->filename); - } - else - { - if (! noerror) - perror_with_name (s->filename); - print_sys_errmsg (s->filename, errno); - } - return; - } - - if (s->line_charpos == 0) - find_source_lines (s, desc); - - if (line < 1 || line > s->nlines) - { - close (desc); - error ("Line number %d out of range; %s has %d lines.", - line, s->filename, s->nlines); - } - - if (lseek (desc, s->line_charpos[line - 1], 0) < 0) - { - close (desc); - perror_with_name (s->filename); - } - - current_source_symtab = s; - current_source_line = line; - first_line_listed = line; - - stream = fdopen (desc, "r"); - clearerr (stream); - - while (nlines-- > 0) - { - c = fgetc (stream); - if (c == EOF) break; - last_line_listed = current_source_line; - printf_filtered ("%d\t", current_source_line++); - do - { - if (c < 040 && c != '\t' && c != '\n') - printf_filtered ("^%c", c + 0100); - else if (c == 0177) - printf_filtered ("^?"); - else - printf_filtered ("%c", c); - } while (c != '\n' && (c = fgetc (stream)) >= 0); - } - - fclose (stream); -} - - - -/* - C++ - Print a list of files and line numbers which a user may choose from - in order to list a function which was specified ambiguously - (as with `list classname::overloadedfuncname', for example). - The vector in SALS provides the filenames and line numbers. - */ -static void -ambiguous_line_spec (sals) - struct symtabs_and_lines *sals; -{ - int i; - - for (i = 0; i < sals->nelts; ++i) - printf("file: \"%s\", line number: %d\n", - sals->sals[i].symtab->filename, sals->sals[i].line); -} - - -static void -file_command(arg, from_tty) - char *arg; - int from_tty; -{ - struct symtabs_and_lines sals; - struct symtab_and_line sal; - struct symbol *sym; - char *arg1; - int linenum_beg = 0; - char *p; - - if (symtab_list == 0 && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"symbol-file\" command."); - - /* Pull in a current source symtab if necessary */ - if (arg == 0 || arg[0] == 0) { - if (current_source_symtab == 0) - select_source_symtab(0); - else - printf("%s\n", current_source_symtab->filename); - return; - } - arg1 = arg; - sals = decode_line_1 (&arg1, 0, 0, 0); - - if (! sals.nelts) - return; /* C++ */ - - if (sals.nelts > 1) - { - ambiguous_line_spec (&sals); - free (sals.sals); - return; - } - - sal = sals.sals[0]; - free (sals.sals); - - /* Record whether the BEG arg is all digits. */ - - for (p = arg; p != arg1 && *p >= '0' && *p <= '9'; ++p) - ; - linenum_beg = (p == arg1); - - /* if line was specified by address, - print exactly which line, and which file. - In this case, sal.symtab == 0 means address is outside - of all known source files, not that user failed to give a filename. */ - if (*arg == '*') - { - if (sal.symtab == 0) - error ("No source file for address 0x%x.", sal.pc); - sym = find_pc_function (sal.pc); - if (sym) - printf ("0x%x is in %s (%s, line %d).\n", - sal.pc, SYMBOL_NAME (sym), sal.symtab->filename, sal.line); - else - printf ("0x%x is in %s, line %d.\n", - sal.pc, sal.symtab->filename, sal.line); - } - - /* If line was not specified by just a line number, - and it does not imply a symtab, it must be an undebuggable symbol - which means no source code. */ - - if (sal.symtab == 0) - { - if (! linenum_beg) - error ("No line number known for %s.", arg); - else - error ("No default source file yet. Do \"help list\"."); - } - else - { - current_source_symtab = sal.symtab; - current_source_line = sal.line; - first_line_listed = sal.line; - } -} - -#define PUSH_STACK_SIZE 32 -static struct { - struct symtab *symtab; - int line; -} push_stack[PUSH_STACK_SIZE]; - -static unsigned int push_stack_ptr; - -static void -push_to_file_command (arg, from_tty) - char *arg; - int from_tty; -{ - struct symtab *cursym = current_source_symtab; - int curline = current_source_line; - register unsigned int i; - - file_command(arg, from_tty); - - /* if we got back, command was successful */ - i = push_stack_ptr; - push_stack[i].symtab = cursym; - push_stack[i].line = curline; - push_stack_ptr = (i + 1) & (PUSH_STACK_SIZE - 1); -} - -static void -pop_file_command (arg, from_tty) - char *arg; - int from_tty; -{ - register unsigned int i = push_stack_ptr; - - /* if there's something on the stack, pop it & clear the slot. */ - i = (i + (PUSH_STACK_SIZE - 1)) & (PUSH_STACK_SIZE - 1); - if (push_stack[i].symtab) { - current_source_symtab = push_stack[i].symtab; - first_line_listed = current_source_line = push_stack[i].line; - push_stack[i].symtab = NULL; - push_stack_ptr = i; - } -} - - -static void -list_command (arg, from_tty) - char *arg; - int from_tty; -{ - struct symtabs_and_lines sals, sals_end; - struct symtab_and_line sal, sal_end; - struct symbol *sym; - char *arg1; - int no_end = 1; - int dummy_end = 0; - int dummy_beg = 0; - int linenum_beg = 0; - char *p; - - if (symtab_list == 0 && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"symbol-file\" command."); - - /* Pull in a current source symtab if necessary */ - if (current_source_symtab == 0 && - (arg == 0 || arg[0] == '+' || arg[0] == '-')) - select_source_symtab (0); - - /* "l" or "l +" lists next ten lines. */ - - if (arg == 0 || !strcmp (arg, "+")) - { - if (current_source_symtab == 0) - error ("No default source file yet. Do \"help list\"."); - print_source_lines (current_source_symtab, current_source_line, - current_source_line + 10, 0); - return; - } - - /* "l -" lists previous ten lines, the ones before the ten just listed. */ - if (!strcmp (arg, "-")) - { - if (current_source_symtab == 0) - error ("No default source file yet. Do \"help list\"."); - print_source_lines (current_source_symtab, - max (first_line_listed - 10, 1), - first_line_listed, 0); - return; - } - - /* Now if there is only one argument, decode it in SAL - and set NO_END. - If there are two arguments, decode them in SAL and SAL_END - and clear NO_END; however, if one of the arguments is blank, - set DUMMY_BEG or DUMMY_END to record that fact. */ - - arg1 = arg; - if (*arg1 == ',') - dummy_beg = 1; - else - { - sals = decode_line_1 (&arg1, 0, 0, 0); - - if (! sals.nelts) return; /* C++ */ - if (sals.nelts > 1) - { - ambiguous_line_spec (&sals); - free (sals.sals); - return; - } - - sal = sals.sals[0]; - free (sals.sals); - } - - /* Record whether the BEG arg is all digits. */ - - for (p = arg; p != arg1 && *p >= '0' && *p <= '9'; p++); - linenum_beg = (p == arg1); - - while (*arg1 == ' ' || *arg1 == '\t') - arg1++; - if (*arg1 == ',') - { - no_end = 0; - arg1++; - while (*arg1 == ' ' || *arg1 == '\t') - arg1++; - if (*arg1 == 0) - dummy_end = 1; - else - { - if (dummy_beg) - sals_end = decode_line_1 (&arg1, 0, 0, 0); - else - sals_end = decode_line_1 (&arg1, 0, sal.symtab, sal.line); - if (sals_end.nelts == 0) - return; - if (sals_end.nelts > 1) - { - ambiguous_line_spec (&sals_end); - free (sals_end.sals); - return; - } - sal_end = sals_end.sals[0]; - free (sals_end.sals); - } - } - - if (*arg1) - error ("Junk at end of line specification."); - - if (!no_end && !dummy_beg && !dummy_end - && sal.symtab != sal_end.symtab) - error ("Specified start and end are in different files."); - if (dummy_beg && dummy_end) - error ("Two empty args do not say what lines to list."); - - /* if line was specified by address, - first print exactly which line, and which file. - In this case, sal.symtab == 0 means address is outside - of all known source files, not that user failed to give a filename. */ - if (*arg == '*') - { - if (sal.symtab == 0) - error ("No source file for address 0x%x.", sal.pc); - sym = find_pc_function (sal.pc); - if (sym) - printf ("0x%x is in %s (%s, line %d).\n", - sal.pc, SYMBOL_NAME (sym), sal.symtab->filename, sal.line); - else - printf ("0x%x is in %s, line %d.\n", - sal.pc, sal.symtab->filename, sal.line); - } - - /* If line was not specified by just a line number, - and it does not imply a symtab, it must be an undebuggable symbol - which means no source code. */ - - if (! linenum_beg && sal.symtab == 0) - error ("No line number known for %s.", arg); - - /* If this command is repeated with RET, - turn it into the no-arg variant. */ - - if (from_tty) - *arg = 0; - - if (dummy_beg && sal_end.symtab == 0) - error ("No default source file yet. Do \"help list\"."); - if (dummy_beg) - print_source_lines (sal_end.symtab, max (sal_end.line - 9, 1), - sal_end.line + 1, 0); - else if (sal.symtab == 0) - error ("No default source file yet. Do \"help list\"."); - else if (no_end) - print_source_lines (sal.symtab, max (sal.line - 5, 1), sal.line + 5, 0); - else - print_source_lines (sal.symtab, sal.line, - dummy_end ? sal.line + 10 : sal_end.line + 1, - 0); -} - -/* Print info on range of pc's in a specified line. */ - -static void -line_info (arg, from_tty) - char *arg; - int from_tty; -{ - struct symtabs_and_lines sals; - struct symtab_and_line sal; - int start_pc, end_pc; - int i; - - if (arg == 0) - { - sal.symtab = current_source_symtab; - sal.line = last_line_listed; - sals.nelts = 1; - sals.sals = (struct symtab_and_line *) - xmalloc (sizeof (struct symtab_and_line)); - sals.sals[0] = sal; - } - else - { - sals = decode_line_spec_1 (arg, 0); - - /* If this command is repeated with RET, - turn it into the no-arg variant. */ - if (from_tty) - *arg = 0; - } - - /* C++ More than one line may have been specified, as when the user - specifies an overloaded function name. Print info on them all. */ - for (i = 0; i < sals.nelts; i++) - { - sal = sals.sals[i]; - - if (sal.symtab == 0) - error ("No source file specified."); - - if (sal.line > 0 - && find_line_pc_range (sal.symtab, sal.line, &start_pc, &end_pc)) - { - if (start_pc == end_pc) - printf ("Line %d of \"%s\" is at pc 0x%x but contains no code.\n", - sal.line, sal.symtab->filename, start_pc); - else - printf ("Line %d of \"%s\" starts at pc 0x%x and ends at 0x%x.\n", - sal.line, sal.symtab->filename, start_pc, end_pc); - /* x/i should display this line's code. */ - set_next_address (start_pc); - /* Repeating "info line" should do the following line. */ - last_line_listed = sal.line + 1; - } - else - printf ("Line number %d is out of range for \"%s\".\n", - sal.line, sal.symtab->filename); - } -} - -/* Commands to search the source file for a regexp. */ - -static void -forward_search_command (regex, from_tty) - char *regex; -{ - register int c; - register int desc; - register FILE *stream; - int line = last_line_listed + 1; - char *msg; - - msg = (char *) re_comp (regex); - if (msg) - error (msg); - - if (current_source_symtab == 0) - select_source_symtab (0); - - /* Search from last_line_listed+1 in current_source_symtab */ - - desc = openp (source_path, 0, current_source_symtab->filename, - O_RDONLY, 0, ¤t_source_symtab->fullname); - if (desc < 0) - perror_with_name (current_source_symtab->filename); - - if (current_source_symtab->line_charpos == 0) - find_source_lines (current_source_symtab, desc); - - if (line < 1 || line > current_source_symtab->nlines) - { - close (desc); - error ("Expression not found"); - } - - if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0) - { - close (desc); - perror_with_name (current_source_symtab->filename); - } - - stream = fdopen (desc, "r"); - clearerr (stream); - while (1) { - char buf[4096]; /* Should be reasonable??? */ - register char *p = buf; - - c = fgetc (stream); - if (c == EOF) - break; - do { - *p++ = c; - } while (c != '\n' && (c = fgetc (stream)) >= 0); - - /* we now have a source line in buf, null terminate and match */ - *p = 0; - if (re_exec (buf) > 0) - { - /* Match! */ - fclose (stream); - print_source_lines (current_source_symtab, - line, line+1, 0); - current_source_line = max (line - 5, 1); - return; - } - line++; - } - - printf ("Expression not found\n"); - fclose (stream); -} - -static void -reverse_search_command (regex, from_tty) - char *regex; -{ - register int c; - register int desc; - register FILE *stream; - int line = last_line_listed - 1; - char *msg; - - msg = (char *) re_comp (regex); - if (msg) - error (msg); - - if (current_source_symtab == 0) - select_source_symtab (0); - - /* Search from last_line_listed-1 in current_source_symtab */ - - desc = openp (source_path, 0, current_source_symtab->filename, - O_RDONLY, 0, ¤t_source_symtab->fullname); - if (desc < 0) - perror_with_name (current_source_symtab->filename); - - if (current_source_symtab->line_charpos == 0) - find_source_lines (current_source_symtab, desc); - - if (line < 1 || line > current_source_symtab->nlines) - { - close (desc); - error ("Expression not found"); - } - - if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0) - { - close (desc); - perror_with_name (current_source_symtab->filename); - } - - stream = fdopen (desc, "r"); - clearerr (stream); - while (1) - { - char buf[4096]; /* Should be reasonable??? */ - register char *p = buf; - - c = fgetc (stream); - if (c == EOF) - break; - do { - *p++ = c; - } while (c != '\n' && (c = fgetc (stream)) >= 0); - - /* We now have a source line in buf; null terminate and match. */ - *p = 0; - if (re_exec (buf) > 0) - { - /* Match! */ - fclose (stream); - print_source_lines (current_source_symtab, - line, line+1, 0); - current_source_line = max (line - 5, 1); - return; - } - line--; - if (fseek (stream, current_source_symtab->line_charpos[line - 1], 0) < 0) - { - fclose (stream); - perror_with_name (current_source_symtab->filename); - } - } - - printf ("Expression not found\n"); - fclose (stream); - return; -} - -void -_initialize_source () -{ - current_source_symtab = 0; - init_source_path (); - - add_com ("directory", class_files, directory_command, - "Add directory DIR to end of search path for source files.\n\ -With no argument, reset the search path to just the working directory\n\ -and forget cached info on line positions in source files."); - - add_info ("directories", directories_info, - "Current search path for finding source files."); - - add_info ("line", line_info, - "Core addresses of the code for a source line.\n\ -Line can be specified as\n\ - LINENUM, to list around that line in current file,\n\ - FILE:LINENUM, to list around that line in that file,\n\ - FUNCTION, to list around beginning of that function,\n\ - FILE:FUNCTION, to distinguish among like-named static functions.\n\ -Default is to describe the last source line that was listed.\n\n\ -This sets the default address for \"x\" to the line's first instruction\n\ -so that \"x/i\" suffices to start examining the machine code.\n\ -The address is also stored as the value of \"$_\"."); - - add_com ("forward-search", class_files, forward_search_command, - "Search for regular expression (see regex(3)) from last line listed."); - add_com_alias ("search", "forward-search", class_files, 0); - - add_com ("reverse-search", class_files, reverse_search_command, - "Search backward for regular expression (see regex(3)) from last line listed."); - - add_com ("list", class_files, list_command, - "List specified function or line.\n\ -With no argument, lists ten more lines after or around previous listing.\n\ -\"list -\" lists the ten lines before a previous ten-line listing.\n\ -One argument specifies a line, and ten lines are listed around that line.\n\ -Two arguments with comma between specify starting and ending lines to list.\n\ -Lines can be specified in these ways:\n\ - LINENUM, to list around that line in current file,\n\ - FILE:LINENUM, to list around that line in that file,\n\ - FUNCTION, to list around beginning of that function,\n\ - FILE:FUNCTION, to distinguish among like-named static functions.\n\ - *ADDRESS, to list around the line containing that address.\n\ -With two args if one is empty it stands for ten lines away from the other arg."); - add_com ("file", class_files, file_command, - "Select current file, function and line for display or list.\n\ -Specification can have the form:\n\ - LINENUM, to select that line in current file,\n\ - FILE:LINENUM, to select that line in that file,\n\ - FUNCTION, to select beginning of that function,\n\ - FILE:FUNCTION, to distinguish among like-named static functions.\n\ - *ADDRESS, to select the line containing that address."); - add_com ("push-to-file", class_files, push_to_file_command, - "Like \"file\" command but remembers current file & line on a stack.\n\ -Can later return to current file with \"pop-file\" command.\n\ -Up to 32 file positions can be pushed on stack."); - add_com ("pop-file", class_files, pop_file_command, - "Pops back to file position saved by most recent \"push-to-file\".\n\ -If everything has been popped from stack, command does nothing."); -} - diff --git a/gnu/usr.bin/gdb/stab.def b/gnu/usr.bin/gdb/stab.def deleted file mode 100644 index b81cda4bdc31..000000000000 --- a/gnu/usr.bin/gdb/stab.def +++ /dev/null @@ -1,115 +0,0 @@ -/* Table of DBX symbol codes for the GNU system. - Copyright (C) 1988 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 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. */ - -/* Global variable. Only the name is significant. - To find the address, look in the corresponding external symbol. */ -__define_stab (N_GSYM, 0x20, "GSYM") - -/* Function name for BSD Fortran. Only the name is significant. - To find the address, look in the corresponding external symbol. */ -__define_stab (N_FNAME, 0x22, "FNAME") - -/* Function name or text-segment variable for C. Value is its address. - Desc is supposedly starting line number, but GCC doesn't set it - and DBX seems not to miss it. */ -__define_stab (N_FUN, 0x24, "FUN") - -/* Data-segment variable with internal linkage. Value is its address. */ -__define_stab (N_STSYM, 0x26, "STSYM") - -/* BSS-segment variable with internal linkage. Value is its address. */ -__define_stab (N_LCSYM, 0x28, "LCSYM") - -/* Name of main routine. Only the name is significant. - This is not used in C. */ -__define_stab (N_MAIN, 0x2a, "MAIN") - -/* Register variable. Value is number of register. */ -__define_stab (N_RSYM, 0x40, "RSYM") - -/* Structure or union element. Value is offset in the structure. */ -__define_stab (N_SSYM, 0x60, "SSYM") - -/* Parameter variable. Value is offset from argument pointer. - (On most machines the argument pointer is the same as the frame pointer. */ -__define_stab (N_PSYM, 0xa0, "PSYM") - -/* Automatic variable in the stack. Value is offset from frame pointer. - Also used for type descriptions. */ -__define_stab (N_LSYM, 0x80, "LSYM") - -/* Alternate entry point. Value is its address. */ -__define_stab (N_ENTRY, 0xa4, "ENTRY") - -/* Name of main source file. - Value is starting text address of the compilation. */ -__define_stab (N_SO, 0x64, "SO") - -/* Name of sub-source file. - Value is starting text address of the compilation. */ -__define_stab (N_SOL, 0x84, "SOL") - -/* Line number in text segment. Desc is the line number; - value is corresponding address. */ -__define_stab (N_SLINE, 0x44, "SLINE") -/* Similar, for data segment. */ -__define_stab (N_DSLINE, 0x46, "DSLINE") -/* Similar, for bss segment. */ -__define_stab (N_BSLINE, 0x48, "BSLINE") - -/* Beginning of an include file. Only Sun uses this. - In an object file, only the name is significant. - The Sun linker puts data into some of the other fields. */ -__define_stab (N_BINCL, 0x82, "BINCL") -/* End of an include file. No name. - These two act as brackets around the file's output. - In an object file, there is no significant data in this entry. - The Sun linker puts data into some of the fields. */ -__define_stab (N_EINCL, 0xa2, "EINCL") -/* Place holder for deleted include file. - This appears only in output from the Sun linker. */ -__define_stab (N_EXCL, 0xc2, "EXCL") - -/* Beginning of lexical block. - The desc is the nesting level in lexical blocks. - The value is the address of the start of the text for the block. - The variables declared inside the block *precede* the N_LBRAC symbol. */ -__define_stab (N_LBRAC, 0xc0, "LBRAC") -/* End of a lexical block. Desc matches the N_LBRAC's desc. - The value is the address of the end of the text for the block. */ -__define_stab (N_RBRAC, 0xe0, "RBRAC") - -/* Begin named common block. Only the name is significant. */ -__define_stab (N_BCOMM, 0xe2, "BCOMM") -/* Begin named common block. Only the name is significant - (and it should match the N_BCOMM). */ -__define_stab (N_ECOMM, 0xe4, "ECOMM") -/* End common (local name): value is address. - I'm not sure how this is used. */ -__define_stab (N_ECOML, 0xe8, "ECOML") -/* Second symbol entry containing a length-value for the preceding entry. - The value is the length. */ -__define_stab (N_LENG, 0xfe, "LENG") - -/* Global symbol in Pascal. - Supposedly the value is its line number; I'm skeptical. */ -__define_stab (N_PC, 0x30, "PC") - -/* Modula-2 compilation unit. Can someone say what info it contains? */ -__define_stab (N_M2C, 0x42, "M2C") -/* Modula-2 scope information. Can someone say what info it contains? */ -__define_stab (N_SCOPE, 0xc4, "SCOPE") diff --git a/gnu/usr.bin/gdb/stack.c b/gnu/usr.bin/gdb/stack.c deleted file mode 100644 index 39bc558470d6..000000000000 --- a/gnu/usr.bin/gdb/stack.c +++ /dev/null @@ -1,961 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)stack.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: stack.c,v 1.2 1993/08/01 18:47:39 mycroft Exp $"; -#endif /* not lint */ - -/* Print and select stack frames for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* modified by rjc Thu Nov 1 16:46:57 1990, fixed return_command so that - it can return values, it still has problems when running on pmax, - cannot write register 65 */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "value.h" - - -/* Thie "selected" stack frame is used by default for local and arg access. - May be zero, for no selected frame. */ - -FRAME selected_frame; - -/* Level of the selected frame: - 0 for innermost, 1 for its caller, ... - or -1 for frame specified by address with no defined level. */ - -int selected_frame_level; - -/* Nonzero means print the full filename and linenumber - when a frame is printed, and do so in a format programs can parse. */ - -int frame_file_full_name = 0; - -static void select_calling_frame (); - -void print_frame_info (); - -/* Print a stack frame briefly. FRAME should be the frame id - and LEVEL should be its level in the stack (or -1 for level not defined). - This prints the level, the function executing, the arguments, - and the file name and line number. - If the pc is not at the beginning of the source line, - the actual pc is printed at the beginning. - - If SOURCE is 1, print the source line as well. - If SOURCE is -1, print ONLY the source line. */ - -static void -print_stack_frame (frame, level, source) - FRAME frame; - int level; - int source; -{ - struct frame_info *fi; - - fi = get_frame_info (frame); - - print_frame_info (fi, level, source, 1); -} - -/* Flag which will indicate when the frame has been changed - by and "up" or "down" command. */ -static int frame_changed; - -void -print_frame_info (fi, level, source, args) - struct frame_info *fi; - register int level; - int source; - int args; -{ - struct symtab_and_line sal; - struct symbol *func; - register char *funname = 0; - int numargs; - struct partial_symtab *pst; - - /* Don't give very much information if we haven't readin the - symbol table yet. */ - pst = find_pc_psymtab (fi->pc); - if (pst && !pst->readin) - { - /* Abbreviated information. */ - char *fname; - - if (!find_pc_partial_function (fi->pc, &fname, 0)) - fname = "??"; - - printf_filtered ("#%-2d ", level); - printf_filtered ("0x%x in ", fi->pc); - - fputs_demangled(fname, stdout, -1); - fputs_filtered(" (...)\n", stdout); - - return; - } - - sal = find_pc_line (fi->pc, fi->next_frame); - func = find_pc_function (fi->pc); - if (func) - { - /* In certain pathological cases, the symtabs give the wrong - function (when we are in the first function in a file which - is compiled without debugging symbols, the previous function - is compiled with debugging symbols, and the "foo.o" symbol - that is supposed to tell us where the file with debugging symbols - ends has been truncated by ar because it is longer than 15 - characters). - - So look in the misc_function_vector as well, and if it comes - up with a larger address for the function use that instead. - I don't think this can ever cause any problems; - there shouldn't be any - misc_function_vector symbols in the middle of a function. */ - int misc_index = find_pc_misc_function (fi->pc); - if (misc_index >= 0 - && (misc_function_vector[misc_index].address - > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) - { - /* In this case we have no way of knowing the source file - and line number, so don't print them. */ - sal.symtab = 0; - /* We also don't know anything about the function besides - its address and name. */ - func = 0; - funname = misc_function_vector[misc_index].name; - } - else - funname = SYMBOL_NAME (func); - } - else - { - register int misc_index = find_pc_misc_function (fi->pc); - if (misc_index >= 0) - funname = misc_function_vector[misc_index].name; - } - - if (frame_changed || source >= 0 || !sal.symtab) - { - if (level >= 0) - printf_filtered ("#%-2d ", level); - else if (frame_changed) - printf ("#%-2d ", 0); - if (fi->pc != sal.pc || !sal.symtab) - printf_filtered ("0x%x in ", fi->pc); - fputs_demangled(funname ? funname : "??", stdout, -1); - printf_filtered(" ("); - if (args) - { - if (func) - numargs = -1; - else - FRAME_NUM_ARGS (numargs, fi); - - print_frame_args (func, fi, numargs, stdout); - } - printf_filtered (")"); - if (sal.symtab) - printf_filtered (" (%s line %d)", sal.symtab->filename, sal.line); - printf_filtered ("\n"); - } - - if ((frame_changed || source != 0) && sal.symtab) - { - int done = 0; - int mid_statement = source < 0 && fi->pc != sal.pc; - if (frame_file_full_name) - done = identify_source_line (sal.symtab, sal.line, mid_statement); - if (!done) - { - if (mid_statement) - printf_filtered ("0x%x\t", fi->pc); - print_source_lines (sal.symtab, sal.line, sal.line + 1, 1); - } - current_source_line = max (sal.line - 5, 1); - } - frame_changed = 0; - if (source != 0) - set_default_breakpoint (1, fi->pc, sal.symtab, sal.line); - - fflush (stdout); -} - -/* Call here to print info on selected frame, after a trap. */ - -void -print_sel_frame (just_source) - int just_source; -{ - print_stack_frame (selected_frame, -1, just_source ? -1 : 1); -} - -/* Print info on the selected frame, including level number - but not source. */ - -void -print_selected_frame () -{ - print_stack_frame (selected_frame, selected_frame_level, 0); -} - -void flush_cached_frames (); - -#ifdef FRAME_SPECIFICATION_DYADIC -extern FRAME setup_arbitrary_frame (); -#endif - -/* - * Read a frame specification in whatever the appropriate format is. - */ -static FRAME -parse_frame_specification (frame_exp) - char *frame_exp; -{ - int numargs = 0; - int arg1, arg2; - - if (frame_exp) - { - char *addr_string, *p; - struct cleanup *tmp_cleanup; - struct frame_info *fci; - - while (*frame_exp == ' ') frame_exp++; - for (p = frame_exp; *p && *p != ' '; p++) - ; - - if (*frame_exp) - { - numargs = 1; - addr_string = savestring(frame_exp, p - frame_exp); - - { - tmp_cleanup = make_cleanup (free, addr_string); - arg1 = parse_and_eval_address (addr_string); - do_cleanups (tmp_cleanup); - } - - while (*p == ' ') p++; - - if (*p) - { - numargs = 2; - arg2 = parse_and_eval_address (p); - } - } - } - - switch (numargs) - { - case 0: - return selected_frame; - /* NOTREACHED */ - case 1: - { - int level = arg1; - FRAME fid = find_relative_frame (get_current_frame (), &level); - FRAME tfid; - - if (level == 0) - /* find_relative_frame was successful */ - return fid; - - /* If (s)he specifies the frame with an address, he deserves what - (s)he gets. Still, give the highest one that matches. */ - - for (fid = get_current_frame (); - fid && FRAME_FP (fid) != arg1; - fid = get_prev_frame (fid)) - ; - - if (fid) - while ((tfid = get_prev_frame (fid)) && - (FRAME_FP (tfid) == arg1)) - fid = tfid; - -#ifdef FRAME_SPECIFICATION_DYADIC - if (!fid) - error ("Incorrect number of args in frame specification"); - - return fid; -#else - return create_new_frame (arg1, 0); -#endif - } - /* NOTREACHED */ - case 2: - /* Must be addresses */ -#ifndef FRAME_SPECIFICATION_DYADIC - error ("Incorrect number of args in frame specification"); -#else - return setup_arbitrary_frame (arg1, arg2); -#endif - /* NOTREACHED */ - } - fatal ("Internal: Error in parsing in parse_frame_specification"); - /* NOTREACHED */ -} - -/* FRAME_ARGS_ADDRESS_CORRECT is just like FRAME_ARGS_ADDRESS except - that if it is unsure about the answer, it returns Frame_unknown - instead of guessing (this happens on the VAX, for example). - - On most machines, we never have to guess about the args address, - so FRAME_ARGS_ADDRESS{,_CORRECT} are the same. */ -#if !defined (FRAME_ARGS_ADDRESS_CORRECT) -#define FRAME_ARGS_ADDRESS_CORRECT FRAME_ARGS_ADDRESS -#endif - -/* Print verbosely the selected frame or the frame at address ADDR. - This means absolutely all information in the frame is printed. */ - -static void -frame_info (addr_exp) - char *addr_exp; -{ - FRAME frame; - struct frame_info *fi; - struct frame_saved_regs fsr; - struct symtab_and_line sal; - struct symbol *func; - FRAME calling_frame; - int i, count; - char *funname = 0; - - if (!(have_inferior_p () || have_core_file_p ())) - error ("No inferior or core file."); - - frame = parse_frame_specification (addr_exp); - if (!frame) - error ("Invalid frame specified."); - - fi = get_frame_info (frame); - get_frame_saved_regs (fi, &fsr); - sal = find_pc_line (fi->pc, fi->next_frame); - func = get_frame_function (frame); - if (func) - funname = SYMBOL_NAME (func); - else - { - register int misc_index = find_pc_misc_function (fi->pc); - if (misc_index >= 0) - funname = misc_function_vector[misc_index].name; - } - calling_frame = get_prev_frame (frame); - - if (!addr_exp && selected_frame_level >= 0) - printf ("Stack level %d, frame at 0x%x:\n pc = 0x%x", - selected_frame_level, FRAME_FP(frame), fi->pc); - else - printf ("Stack frame at 0x%x:\n pc = 0x%x", - FRAME_FP(frame), fi->pc); - - if (funname) - printf (" in %s", funname); - if (sal.symtab) - printf (" (%s line %d)", sal.symtab->filename, sal.line); - printf ("; saved pc 0x%x\n", FRAME_SAVED_PC (frame)); - if (calling_frame) - printf (" called by frame at 0x%x", FRAME_FP (calling_frame)); - if (fi->next_frame && calling_frame) - printf (","); - if (fi->next_frame) - printf (" caller of frame at 0x%x", fi->next_frame); - if (fi->next_frame || calling_frame) - printf ("\n"); - - { - /* Address of the argument list for this frame, or Frame_unknown. */ - CORE_ADDR arg_list = FRAME_ARGS_ADDRESS_CORRECT (fi); - /* Number of args for this frame, or -1 if unknown. */ - int numargs; - - if (arg_list != Frame_unknown) - { - printf (" Arglist at 0x%x,", arg_list); - - FRAME_NUM_ARGS (numargs, fi); - if (numargs < 0) - printf (" args: "); - else if (numargs == 0) - printf (" no args."); - else if (numargs == 1) - printf (" 1 arg: "); - else - printf (" %d args: ", numargs); - print_frame_args (func, fi, numargs, stdout); - printf ("\n"); - } - } - - /* The sp is special; what's returned isn't the save address, but - actually the value of the previous frame's sp. */ - printf (" Previous frame's sp is 0x%x\n", fsr.regs[SP_REGNUM]); - count = 0; - for (i = 0; i < NUM_REGS; i++) - if (fsr.regs[i] && i != SP_REGNUM) - { - if (count % 4 != 0) - printf (", "); - else - { - if (count == 0) - printf (" Saved registers:"); - printf ("\n "); - } - printf ("%s at 0x%x", reg_names[i], fsr.regs[i]); - count++; - } - if (count) - printf ("\n"); -} - -#if 0 -/* Set a limit on the number of frames printed by default in a - backtrace. */ - -static int backtrace_limit; - -static void -set_backtrace_limit_command (count_exp, from_tty) - char *count_exp; - int from_tty; -{ - int count = parse_and_eval_address (count_exp); - - if (count < 0) - error ("Negative argument not meaningful as backtrace limit."); - - backtrace_limit = count; -} - -static void -backtrace_limit_info (arg, from_tty) - char *arg; - int from_tty; -{ - if (arg) - error ("\"Info backtrace-limit\" takes no arguments."); - - printf ("Backtrace limit: %d.\n", backtrace_limit); -} -#endif - -/* Print briefly all stack frames or just the innermost COUNT frames. */ - -static void -backtrace_command (count_exp) - char *count_exp; -{ - struct frame_info *fi; - register int count; - register FRAME frame; - register int i; - register FRAME trailing; - register int trailing_level; - - /* The following code must do two things. First, it must - set the variable TRAILING to the frame from which we should start - printing. Second, it must set the variable count to the number - of frames which we should print, or -1 if all of them. */ - trailing = get_current_frame (); - trailing_level = 0; - if (count_exp) - { - count = parse_and_eval_address (count_exp); - if (count < 0) - { - FRAME current; - - count = -count; - - current = trailing; - while (current && count--) - current = get_prev_frame (current); - - /* Will stop when CURRENT reaches the top of the stack. TRAILING - will be COUNT below it. */ - while (current) - { - trailing = get_prev_frame (trailing); - current = get_prev_frame (current); - trailing_level++; - } - - count = -1; - } - } - else - count = -1; - - for (i = 0, frame = trailing; - frame && count--; - i++, frame = get_prev_frame (frame)) - { - QUIT; - fi = get_frame_info (frame); - print_frame_info (fi, trailing_level + i, 0, 1); - } - - /* If we've stopped before the end, mention that. */ - if (frame) - printf_filtered ("(More stack frames follow...)\n"); -} - -/* Print the local variables of a block B active in FRAME. - Return 1 if any variables were printed; 0 otherwise. */ - -static int -print_block_frame_locals (b, frame, stream) - struct block *b; - register FRAME frame; - register FILE *stream; -{ - int nsyms; - register int i; - register struct symbol *sym; - register int values_printed = 0; - - nsyms = BLOCK_NSYMS (b); - - for (i = 0; i < nsyms; i++) - { - sym = BLOCK_SYM (b, i); - if (SYMBOL_CLASS (sym) == LOC_LOCAL - || SYMBOL_CLASS (sym) == LOC_REGISTER - || SYMBOL_CLASS (sym) == LOC_STATIC) - { - values_printed = 1; - fputs_filtered (SYMBOL_NAME (sym), stream); - fputs_filtered (" = ", stream); - print_variable_value (sym, frame, stream); - fprintf_filtered (stream, "\n"); - fflush (stream); - } - } - return values_printed; -} - -/* Print on STREAM all the local variables in frame FRAME, - including all the blocks active in that frame - at its current pc. - - Returns 1 if the job was done, - or 0 if nothing was printed because we have no info - on the function running in FRAME. */ - -static int -print_frame_local_vars (frame, stream) - register FRAME frame; - register FILE *stream; -{ - register struct block *block = get_frame_block (frame); - register int values_printed = 0; - - if (block == 0) - { - fprintf_filtered (stream, "No symbol table info available.\n"); - fflush (stream); - return 0; - } - - while (block != 0) - { - if (print_block_frame_locals (block, frame, stream)) - values_printed = 1; - /* After handling the function's top-level block, stop. - Don't continue to its superblock, the block of - per-file symbols. */ - if (BLOCK_FUNCTION (block)) - break; - block = BLOCK_SUPERBLOCK (block); - } - - if (!values_printed) - { - fprintf_filtered (stream, "No locals.\n"); - fflush (stream); - } - - return 1; -} - -static void -locals_info () -{ - if (!have_inferior_p () && !have_core_file_p ()) - error ("No inferior or core file."); - - print_frame_local_vars (selected_frame, stdout); -} - -static int -print_frame_arg_vars (frame, stream) - register FRAME frame; - register FILE *stream; -{ - struct symbol *func = get_frame_function (frame); - register struct block *b; - int nsyms; - register int i; - register struct symbol *sym; - register int values_printed = 0; - - if (func == 0) - { - fprintf_filtered (stream, "No symbol table info available.\n"); - fflush (stream); - return 0; - } - - b = SYMBOL_BLOCK_VALUE (func); - nsyms = BLOCK_NSYMS (b); - - for (i = 0; i < nsyms; i++) - { - sym = BLOCK_SYM (b, i); - if (SYMBOL_CLASS (sym) == LOC_ARG - || SYMBOL_CLASS (sym) == LOC_REF_ARG - || SYMBOL_CLASS (sym) == LOC_REGPARM) - { - values_printed = 1; - fputs_filtered (SYMBOL_NAME (sym), stream); - fputs_filtered (" = ", stream); - print_variable_value (sym, frame, stream); - fprintf_filtered (stream, "\n"); - fflush (stream); - } - } - - if (!values_printed) - { - fprintf_filtered (stream, "No arguments.\n"); - fflush (stream); - } - - return 1; -} - -static void -args_info () -{ - if (!have_inferior_p () && !have_core_file_p ()) - error ("No inferior or core file."); - print_frame_arg_vars (selected_frame, stdout); -} - -/* Select frame FRAME, and note that its stack level is LEVEL. - LEVEL may be -1 if an actual level number is not known. */ - -void -select_frame (frame, level) - FRAME frame; - int level; -{ - selected_frame = frame; - selected_frame_level = level; - /* Ensure that symbols for this frame are readin. */ - if (frame) - find_pc_symtab (get_frame_info (frame)->pc); -} - -/* Store the selected frame and its level into *FRAMEP and *LEVELP. */ - -void -record_selected_frame (frameaddrp, levelp) - FRAME_ADDR *frameaddrp; - int *levelp; -{ - *frameaddrp = FRAME_FP (selected_frame); - *levelp = selected_frame_level; -} - -/* Return the symbol-block in which the selected frame is executing. - Can return zero under various legitimate circumstances. */ - -struct block * -get_selected_block () -{ - if (!have_inferior_p () && !have_core_file_p ()) - return 0; - - if (!selected_frame) - return get_current_block (); - return get_frame_block (selected_frame); -} - -/* Find a frame a certain number of levels away from FRAME. - LEVEL_OFFSET_PTR points to an int containing the number of levels. - Positive means go to earlier frames (up); negative, the reverse. - The int that contains the number of levels is counted toward - zero as the frames for those levels are found. - If the top or bottom frame is reached, that frame is returned, - but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates - how much farther the original request asked to go. */ - -FRAME -find_relative_frame (frame, level_offset_ptr) - register FRAME frame; - register int* level_offset_ptr; -{ - register FRAME prev; - register FRAME frame1, frame2; - - /* Going up is simple: just do get_prev_frame enough times - or until initial frame is reached. */ - while (*level_offset_ptr > 0) - { - prev = get_prev_frame (frame); - if (prev == 0) - break; - (*level_offset_ptr)--; - frame = prev; - } - /* Going down could be done by iterating get_frame_info to - find the next frame, but that would be quadratic - since get_frame_info must scan all the way from the current frame. - The following algorithm is linear. */ - if (*level_offset_ptr < 0) - { - /* First put frame1 at innermost frame - and frame2 N levels up from there. */ - frame1 = get_current_frame (); - frame2 = frame1; - while (*level_offset_ptr < 0 && frame2 != frame) - { - frame2 = get_prev_frame (frame2); - (*level_offset_ptr) ++; - } - /* Then slide frame1 and frame2 up in synchrony - and when frame2 reaches our starting point - frame1 must be N levels down from there. */ - while (frame2 != frame) - { - frame1 = get_prev_frame (frame1); - frame2 = get_prev_frame (frame2); - } - return frame1; - } - return frame; -} - -/* The "frame" command. With no arg, print selected frame briefly. - With arg LEVEL_EXP, select the frame at level LEVEL if it is a - valid level. Otherwise, treat level_exp as an address expression - and print it. See parse_frame_specification for more info on proper - frame expressions. */ - -static void -frame_command (level_exp, from_tty) - char *level_exp; - int from_tty; -{ - register FRAME frame, frame1; - unsigned int level = 0; - - if (!have_inferior_p () && ! have_core_file_p ()) - error ("No inferior or core file."); - - frame = parse_frame_specification (level_exp); - - for (frame1 = get_prev_frame (0); - frame1 && frame1 != frame; - frame1 = get_prev_frame (frame1)) - level++; - - if (!frame1) - level = 0; - - frame_changed = level; - select_frame (frame, level); - - if (!from_tty) - return; - - print_stack_frame (selected_frame, selected_frame_level, 1); -} - -/* Select the frame up one or COUNT stack levels - from the previously selected frame, and print it briefly. */ - -static void -up_command (count_exp) - char *count_exp; -{ - register FRAME frame; - int count = 1, count1; - if (count_exp) - count = parse_and_eval_address (count_exp); - count1 = count; - - if (!have_inferior_p () && !have_core_file_p ()) - error ("No inferior or core file."); - - frame = find_relative_frame (selected_frame, &count1); - if (count1 != 0 && count_exp == 0) - error ("Initial frame selected; you cannot go up."); - select_frame (frame, selected_frame_level + count - count1); - - print_stack_frame (selected_frame, selected_frame_level, 1); - frame_changed++; -} - -/* Select the frame down one or COUNT stack levels - from the previously selected frame, and print it briefly. */ - -static void -down_command (count_exp) - char *count_exp; -{ - register FRAME frame; - int count = -1, count1; - if (count_exp) - count = - parse_and_eval_address (count_exp); - count1 = count; - - frame = find_relative_frame (selected_frame, &count1); - if (count1 != 0 && count_exp == 0) - error ("Bottom (i.e., innermost) frame selected; you cannot go down."); - select_frame (frame, selected_frame_level + count - count1); - - print_stack_frame (selected_frame, selected_frame_level, 1); - frame_changed--; -} - -static void -return_command (retval_exp, from_tty) - char *retval_exp; - int from_tty; -{ - value return_value; - struct symbol *thisfun = get_frame_function (selected_frame); - FRAME_ADDR selected_frame_addr = FRAME_FP (selected_frame); - - /* If interactive, require confirmation. */ - - if (from_tty) - { - if (thisfun != 0) - { - if (!query ("Make %s return now? ", SYMBOL_NAME (thisfun))) - error ("Not confirmed."); - } - else - if (!query ("Make selected stack frame return now? ")) - error ("Not confirmed."); - } - - /* Do the real work. Pop until the specified frame is current. We - use this method because the selected_frame is not valid after - a POP_FRAME. Note that this will not work if the selected frame - shares it's fp with another frame. */ - - while (selected_frame_addr != FRAME_FP (get_current_frame())) - POP_FRAME; - - /* get the return value while still in this frame */ - if (retval_exp) - return_value = parse_and_eval (retval_exp); - - /* Then pop that frame. */ - POP_FRAME; - - /* Store the return value if there was one */ - - if (retval_exp) - set_return_value (return_value); - - /* If interactive, print the frame that is now current. */ - - if (from_tty) - frame_command ("0", 1); -} - -extern struct cmd_list_element *setlist; - -void -_initialize_stack () -{ -#if 0 - backtrace_limit = 30; -#endif - - add_com ("return", class_stack, return_command, - "Make selected stack frame return to its caller.\n\ -Control remains in the debugger, but when you continue\n\ -execution will resume in the frame above the one now selected.\n\ -If an argument is given, it is an expression for the value to return."); - - add_com ("up", class_stack, up_command, - "Select and print stack frame that called this one.\n\ -An argument says how many frames up to go."); - - add_com ("down", class_stack, down_command, - "Select and print stack frame called by this one.\n\ -An argument says how many frames down to go."); - add_com_alias ("do", "down", class_stack, 1); - - add_com ("frame", class_stack, frame_command, - "Select and print a stack frame.\n\ -With no argument, print the selected stack frame. (See also \"info frame\").\n\ -An argument specifies the frame to select.\n\ -It can be a stack frame number or the address of the frame.\n\ -With argument, nothing is printed if input is coming from\n\ -a command file or a user-defined command."); - - add_com_alias ("f", "frame", class_stack, 1); - - add_com ("backtrace", class_stack, backtrace_command, - "Print backtrace of all stack frames, or innermost COUNT frames.\n\ -With a negative argument, print outermost -COUNT frames."); - add_com_alias ("bt", "backtrace", class_stack, 0); - add_com_alias ("where", "backtrace", class_alias, 0); - add_info ("stack", backtrace_command, - "Backtrace of the stack, or innermost COUNT frames."); - add_info_alias ("s", "stack", 1); - add_info ("frame", frame_info, - "All about selected stack frame, or frame at ADDR."); - add_info_alias ("f", "frame", 1); - add_info ("locals", locals_info, - "Local variables of current stack frame."); - add_info ("args", args_info, - "Argument variables of current stack frame."); - -#if 0 - add_cmd ("backtrace-limit", class_stack, set_backtrace_limit_command, - "Specify maximum number of frames for \"backtrace\" to print by default.", - &setlist); - add_info ("backtrace-limit", backtrace_limit_info, - "The maximum number of frames for \"backtrace\" to print by default."); -#endif -} - diff --git a/gnu/usr.bin/gdb/symmisc.c b/gnu/usr.bin/gdb/symmisc.c deleted file mode 100644 index 05a6cfd23634..000000000000 --- a/gnu/usr.bin/gdb/symmisc.c +++ /dev/null @@ -1,587 +0,0 @@ -/* Do various things to symbol tables (other than lookup)), for GDB. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef lint -static char rcsid[] = "$Id: symmisc.c,v 1.2 1993/08/02 17:41:11 mycroft Exp $"; -#endif /* not lint */ - -#include "defs.h" -#include "symtab.h" - -#include -#include - -static void free_symtab (); - - -/* Free all the symtabs that are currently installed, - and all storage associated with them. - Leaves us in a consistent state with no symtabs installed. */ - -void -free_all_symtabs () -{ - register struct symtab *s, *snext; - - /* All values will be invalid because their types will be! */ - - clear_value_history (); - clear_displays (); - clear_internalvars (); - clear_breakpoints (); - set_default_breakpoint (0, 0, 0, 0); - - current_source_symtab = 0; - - for (s = symtab_list; s; s = snext) - { - snext = s->next; - free_symtab (s); - } - symtab_list = 0; - obstack_free (symbol_obstack, 0); - obstack_init (symbol_obstack); - - if (misc_function_vector) - free (misc_function_vector); - misc_function_count = 0; - misc_function_vector = 0; -} - -/* Free a struct block <- B and all the symbols defined in that block. */ - -static void -free_symtab_block (b) - struct block *b; -{ - register int i, n; - n = BLOCK_NSYMS (b); - for (i = 0; i < n; i++) - { - free (SYMBOL_NAME (BLOCK_SYM (b, i))); - free (BLOCK_SYM (b, i)); - } - free (b); -} - -/* Free all the storage associated with the struct symtab <- S. - Note that some symtabs have contents malloc'ed structure by structure, - while some have contents that all live inside one big block of memory, - and some share the contents of another symbol table and so you should - not free the contents on their behalf (except sometimes the linetable, - which maybe per symtab even when the rest is not). - It is s->free_code that says which alternative to use. */ - -static void -free_symtab (s) - register struct symtab *s; -{ - register int i, n; - register struct blockvector *bv; - register struct type *type; - register struct typevector *tv; - - switch (s->free_code) - { - case free_nothing: - /* All the contents are part of a big block of memory - and some other symtab is in charge of freeing that block. - Therefore, do nothing. */ - break; - - case free_contents: - /* Here all the contents were malloc'ed structure by structure - and must be freed that way. */ - /* First free the blocks (and their symbols. */ - bv = BLOCKVECTOR (s); - n = BLOCKVECTOR_NBLOCKS (bv); - for (i = 0; i < n; i++) - free_symtab_block (BLOCKVECTOR_BLOCK (bv, i)); - /* Free the blockvector itself. */ - free (bv); - /* Free the type vector. */ - tv = TYPEVECTOR (s); - free (tv); - /* Also free the linetable. */ - - case free_linetable: - /* Everything will be freed either by our `free_ptr' - or by some other symbatb, except for our linetable. - Free that now. */ - free (LINETABLE (s)); - break; - } - - /* If there is a single block of memory to free, free it. */ - if (s->free_ptr) - free (s->free_ptr); - - if (s->line_charpos) - free (s->line_charpos); - free (s->filename); - free (s); -} - -/* Convert a raw symbol-segment to a struct symtab, - and relocate its internal pointers so that it is valid. */ - -/* This is how to relocate one pointer, given a name for it. - Works independent of the type of object pointed to. */ -#define RELOCATE(slot) (slot ? (* (char **) &slot += relocation) : 0) - -/* This is the inverse of RELOCATE. We use it when storing - a core address into a slot that has yet to be relocated. */ -#define UNRELOCATE(slot) (slot ? (* (char **) &slot -= relocation) : 0) - -/* During the process of relocation, this holds the amount to relocate by - (the address of the file's symtab data, in core in the debugger). */ -static int relocation; - -#define CORE_RELOCATE(slot) \ - ((slot) += (((slot) < data_start) ? text_relocation \ - : ((slot) < bss_start) ? data_relocation : bss_relocation)) - -#define TEXT_RELOCATE(slot) ((slot) += text_relocation) - -/* Relocation amounts for addresses in the program's core image. */ -static int text_relocation, data_relocation, bss_relocation; - -/* Boundaries that divide program core addresses into text, data and bss; - used to determine which relocation amount to use. */ -static int data_start, bss_start; - -static void relocate_typevector (); -static void relocate_blockvector (); -static void relocate_type (); -static void relocate_block (); -static void relocate_symbol (); -static void relocate_source (); - -/* Relocate a file's symseg so that all the pointers are valid C pointers. - Value is a `struct symtab'; but it is not suitable for direct - insertion into the `symtab_list' because it describes several files. */ - -static struct symtab * -relocate_symtab (root) - struct symbol_root *root; -{ - struct symtab *sp = (struct symtab *) xmalloc (sizeof (struct symtab)); - bzero (sp, sizeof (struct symtab)); - - relocation = (int) root; - text_relocation = root->textrel; - data_relocation = root->datarel; - bss_relocation = root->bssrel; - data_start = root->databeg; - bss_start = root->bssbeg; - - sp->filename = root->filename; - sp->ldsymoff = root->ldsymoff; - sp->language = root->language; - sp->compilation = root->compilation; - sp->version = root->version; - sp->blockvector = root->blockvector; - sp->typevector = root->typevector; - - RELOCATE (TYPEVECTOR (sp)); - RELOCATE (BLOCKVECTOR (sp)); - RELOCATE (sp->version); - RELOCATE (sp->compilation); - RELOCATE (sp->filename); - - relocate_typevector (TYPEVECTOR (sp)); - relocate_blockvector (BLOCKVECTOR (sp)); - - return sp; -} - -static void -relocate_blockvector (blp) - register struct blockvector *blp; -{ - register int nblocks = BLOCKVECTOR_NBLOCKS (blp); - register int i; - for (i = 0; i < nblocks; i++) - RELOCATE (BLOCKVECTOR_BLOCK (blp, i)); - for (i = 0; i < nblocks; i++) - relocate_block (BLOCKVECTOR_BLOCK (blp, i)); -} - -static void -relocate_block (bp) - register struct block *bp; -{ - register int nsyms = BLOCK_NSYMS (bp); - register int i; - - TEXT_RELOCATE (BLOCK_START (bp)); - TEXT_RELOCATE (BLOCK_END (bp)); - - /* These two should not be recursively processed. - The superblock need not be because all blocks are - processed from relocate_blockvector. - The function need not be because it will be processed - under the block which is its scope. */ - RELOCATE (BLOCK_SUPERBLOCK (bp)); - RELOCATE (BLOCK_FUNCTION (bp)); - - for (i = 0; i < nsyms; i++) - RELOCATE (BLOCK_SYM (bp, i)); - - for (i = 0; i < nsyms; i++) - relocate_symbol (BLOCK_SYM (bp, i)); -} - -static void -relocate_symbol (sp) - register struct symbol *sp; -{ - RELOCATE (SYMBOL_NAME (sp)); - if (SYMBOL_CLASS (sp) == LOC_BLOCK) - { - RELOCATE (SYMBOL_BLOCK_VALUE (sp)); - /* We can assume the block that belongs to this symbol - is not relocated yet, since it comes after - the block that contains this symbol. */ - BLOCK_FUNCTION (SYMBOL_BLOCK_VALUE (sp)) = sp; - UNRELOCATE (BLOCK_FUNCTION (SYMBOL_BLOCK_VALUE (sp))); - } - else if (SYMBOL_CLASS (sp) == LOC_STATIC) - CORE_RELOCATE (SYMBOL_VALUE (sp)); - else if (SYMBOL_CLASS (sp) == LOC_LABEL) - TEXT_RELOCATE (SYMBOL_VALUE (sp)); - RELOCATE (SYMBOL_TYPE (sp)); -} - -static void -relocate_typevector (tv) - struct typevector *tv; -{ - register int ntypes = TYPEVECTOR_NTYPES (tv); - register int i; - - for (i = 0; i < ntypes; i++) - RELOCATE (TYPEVECTOR_TYPE (tv, i)); - for (i = 0; i < ntypes; i++) - relocate_type (TYPEVECTOR_TYPE (tv, i)); -} - -/* We cannot come up with an a priori spanning tree - for the network of types, since types can be used - for many symbols and also as components of other types. - Therefore, we need to be able to mark types that we - already have relocated (or are already in the middle of relocating) - as in a garbage collector. */ - -static void -relocate_type (tp) - register struct type *tp; -{ - register int nfields = TYPE_NFIELDS (tp); - register int i; - - RELOCATE (TYPE_NAME (tp)); - RELOCATE (TYPE_TARGET_TYPE (tp)); - RELOCATE (TYPE_FIELDS (tp)); - RELOCATE (TYPE_POINTER_TYPE (tp)); - - for (i = 0; i < nfields; i++) - { - RELOCATE (TYPE_FIELD_TYPE (tp, i)); - RELOCATE (TYPE_FIELD_NAME (tp, i)); - } -} - -static void -relocate_sourcevector (svp) - register struct sourcevector *svp; -{ - register int nfiles = svp->length; - register int i; - for (i = 0; i < nfiles; i++) - RELOCATE (svp->source[i]); - for (i = 0; i < nfiles; i++) - relocate_source (svp->source[i]); -} - -static void -relocate_source (sp) - register struct source *sp; -{ - register int nitems = sp->contents.nitems; - register int i; - - RELOCATE (sp->name); - for (i = 0; i < nitems; i++) - TEXT_RELOCATE (sp->contents.item[i].pc); -} - -/* Read symsegs from file named NAME open on DESC, - make symtabs from them, and return a chain of them. - These symtabs are not suitable for direct use in `symtab_list' - because each one describes a single object file, perhaps many source files. - `symbol_file_command' takes each of these, makes many real symtabs - from it, and then frees it. - - We assume DESC is prepositioned at the end of the string table, - just before the symsegs if there are any. */ - -struct symtab * -read_symsegs (desc, name) - int desc; - char *name; -{ - struct symbol_root root; - register char *data; - register struct symtab *sp, *sp1, *chain = 0; - register int len; - - while (1) - { - len = myread (desc, &root, sizeof root); - if (len == 0 || root.format == 0) - break; - /* format 1 was ok for the original gdb, but since the size of the - type structure changed when C++ support was added, it can no - longer be used. Accept only format 2. */ - if (root.format != 2 || - root.length < sizeof root) - error ("\nInvalid symbol segment format code"); - data = (char *) xmalloc (root.length); - bcopy (&root, data, sizeof root); - len = myread (desc, data + sizeof root, - root.length - sizeof root); - sp = relocate_symtab (data); - RELOCATE (((struct symbol_root *)data)->sourcevector); - relocate_sourcevector (((struct symbol_root *)data)->sourcevector); - sp->next = chain; - chain = sp; - sp->linetable = (struct linetable *) ((struct symbol_root *)data)->sourcevector; - } - - return chain; -} - -static int block_depth (); -void print_spaces (); -static void print_symbol (); - -void -print_symtabs (filename) - char *filename; -{ - FILE *outfile; - register struct symtab *s; - register int i, j; - int len, line, blen; - register struct linetable *l; - struct blockvector *bv; - register struct block *b; - int depth; - struct cleanup *cleanups; - extern int fclose(); - - if (filename == 0) - error_no_arg ("file to write symbol data in"); - - filename = tilde_expand (filename); - make_cleanup (free, filename); - - outfile = fopen (filename, "w"); - if (outfile == 0) - perror_with_name (filename); - - cleanups = make_cleanup (fclose, outfile); - immediate_quit++; - - for (s = symtab_list; s; s = s->next) - { - /* First print the line table. */ - fprintf (outfile, "Symtab for file %s\n\n", s->filename); - fprintf (outfile, "Line table:\n\n"); - l = LINETABLE (s); - len = l->nitems; - for (i = 0; i < len; i++) - fprintf (outfile, " line %d at %x\n", l->item[i].line, - l->item[i].pc); - /* Now print the block info. */ - fprintf (outfile, "\nBlockvector:\n\n"); - bv = BLOCKVECTOR (s); - len = BLOCKVECTOR_NBLOCKS (bv); - for (i = 0; i < len; i++) - { - b = BLOCKVECTOR_BLOCK (bv, i); - depth = block_depth (b) * 2; - print_spaces (depth, outfile); - fprintf (outfile, "block #%03d (object 0x%x) ", i, b); - fprintf (outfile, "[0x%x..0x%x]", BLOCK_START (b), BLOCK_END (b)); - if (BLOCK_SUPERBLOCK (b)) - fprintf (outfile, " (under 0x%x)", BLOCK_SUPERBLOCK (b)); - if (BLOCK_FUNCTION (b)) - fprintf (outfile, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b))); - fputc ('\n', outfile); - blen = BLOCK_NSYMS (b); - for (j = 0; j < blen; j++) - { - print_symbol (BLOCK_SYM (b, j), depth + 1, outfile); - } - } - - fprintf (outfile, "\n\n"); - } - - immediate_quit--; - do_cleanups (cleanups); -} - -static void -print_symbol (symbol, depth, outfile) - struct symbol *symbol; - int depth; - FILE *outfile; -{ - print_spaces (depth, outfile); - if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE) - { - fprintf (outfile, "label %s at 0x%x\n", SYMBOL_NAME (symbol), - SYMBOL_VALUE (symbol)); - return; - } - if (SYMBOL_NAMESPACE (symbol) == STRUCT_NAMESPACE) - { - if (TYPE_NAME (SYMBOL_TYPE (symbol))) - { - type_print_1 (SYMBOL_TYPE (symbol), "", outfile, 1, depth); - } - else - { - fprintf (outfile, "%s %s = ", - (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_ENUM - ? "enum" - : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT - ? "struct" : "union")), - SYMBOL_NAME (symbol)); - type_print_1 (SYMBOL_TYPE (symbol), "", outfile, 1, depth); - } - fprintf (outfile, ";\n"); - } - else - { - if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF) - fprintf (outfile, "typedef "); - if (SYMBOL_TYPE (symbol)) - { - type_print_1 (SYMBOL_TYPE (symbol), SYMBOL_NAME (symbol), - outfile, 1, depth); - fprintf (outfile, "; "); - } - else - fprintf (outfile, "%s ", SYMBOL_NAME (symbol)); - - switch (SYMBOL_CLASS (symbol)) - { - case LOC_CONST: - fprintf (outfile, "const %d (0x%x),", - SYMBOL_VALUE (symbol), SYMBOL_VALUE (symbol)); - break; - - case LOC_CONST_BYTES: - fprintf (outfile, "const %d hex bytes:", - TYPE_LENGTH (SYMBOL_TYPE (symbol))); - { - int i; - for (i = 0; i < TYPE_LENGTH (SYMBOL_TYPE (symbol)); i++) - fprintf (outfile, " %2x", SYMBOL_VALUE_BYTES (symbol) [i]); - fprintf (outfile, ","); - } - break; - - case LOC_STATIC: - fprintf (outfile, "static at 0x%x,", SYMBOL_VALUE (symbol)); - break; - - case LOC_REGISTER: - fprintf (outfile, "register %d,", SYMBOL_VALUE (symbol)); - break; - - case LOC_ARG: - fprintf (outfile, "arg at 0x%x,", SYMBOL_VALUE (symbol)); - break; - - case LOC_REF_ARG: - fprintf (outfile, "reference arg at 0x%x,", SYMBOL_VALUE (symbol)); - break; - - case LOC_REGPARM: - fprintf (outfile, "parameter register %d,", SYMBOL_VALUE (symbol)); - break; - - case LOC_LOCAL: - fprintf (outfile, "local at 0x%x,", SYMBOL_VALUE (symbol)); - break; - - case LOC_TYPEDEF: - break; - - case LOC_LABEL: - fprintf (outfile, "label at 0x%x", SYMBOL_VALUE (symbol)); - break; - - case LOC_BLOCK: - fprintf (outfile, "block (object 0x%x) starting at 0x%x,", - SYMBOL_VALUE (symbol), - BLOCK_START (SYMBOL_BLOCK_VALUE (symbol))); - break; - } - } - fprintf (outfile, "\n"); -} - -/* Return the nexting depth of a block within other blocks in its symtab. */ - -static int -block_depth (block) - struct block *block; -{ - register int i = 0; - while (block = BLOCK_SUPERBLOCK (block)) i++; - return i; -} - -/* - * Free all partial_symtab storage. - */ -void -free_all_psymtabs() -{ - obstack_free (psymbol_obstack, 0); - obstack_init (psymbol_obstack); - partial_symtab_list = (struct partial_symtab *) 0; -} - -void -_initialize_symmisc () -{ - symtab_list = (struct symtab *) 0; - partial_symtab_list = (struct partial_symtab *) 0; - - add_com ("printsyms", class_obscure, print_symtabs, - "Print dump of current symbol definitions to file OUTFILE."); -} - diff --git a/gnu/usr.bin/gdb/symseg.h b/gnu/usr.bin/gdb/symseg.h deleted file mode 100644 index c794e9c95527..000000000000 --- a/gnu/usr.bin/gdb/symseg.h +++ /dev/null @@ -1,524 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - * - * from: @(#)symseg.h 6.3 (Berkeley) 5/8/91 - * $Id: symseg.h,v 1.2 1993/08/01 18:47:52 mycroft Exp $ - */ - -/* GDB symbol table format definitions. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@mcc.com) - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Format of GDB symbol table data. - There is one symbol segment for each source file or - independant compilation. These segments are simply concatenated - to form the GDB symbol table. A zero word where the beginning - of a segment is expected indicates there are no more segments. - -Format of a symbol segment: - - The symbol segment begins with a word containing 1 - if it is in the format described here. Other formats may - be designed, with other code numbers. - - The segment contains many objects which point at each other. - The pointers are offsets in bytes from the beginning of the segment. - Thus, each segment can be loaded into core and its pointers relocated - to make valid in-core pointers. - - All the data objects in the segment can be found indirectly from - one of them, the root object, of type `struct symbol_root'. - It appears at the beginning of the segment. - - The total size of the segment, in bytes, appears as the `length' - field of this object. This size includes the size of the - root object. - - All the object data types are defined here to contain pointer types - appropriate for in-core use on a relocated symbol segment. - Casts to and from type int are required for working with - unrelocated symbol segments such as are found in the file. - - The ldsymaddr word is filled in by the loader to contain - the offset (in bytes) within the ld symbol table - of the first nonglobal symbol from this compilation. - This makes it possible to match those symbols - (which contain line number information) reliably with - the segment they go with. - - Core addresses within the program that appear in the symbol segment - are not relocated by the loader. They are inserted by the assembler - and apply to addresses as output by the assembler, so GDB must - relocate them when it loads the symbol segment. It gets the information - on how to relocate from the textrel, datarel, bssrel, databeg and bssbeg - words of the root object. - - The words textrel, datarel and bssrel - are filled in by ld with the amounts to relocate within-the-file - text, data and bss addresses by; databeg and bssbeg can be - used to tell which kind of relocation an address needs. */ - -enum language {language_c}; - -struct symbol_root -{ - int format; /* Data format version */ - int length; /* # bytes in this symbol segment */ - int ldsymoff; /* Offset in ld symtab of this file's syms */ - int textrel; /* Relocation for text addresses */ - int datarel; /* Relocation for data addresses */ - int bssrel; /* Relocation for bss addresses */ - char *filename; /* Name of main source file compiled */ - char *filedir; /* Name of directory it was reached from */ - struct blockvector *blockvector; /* Vector of all symbol-naming blocks */ - struct typevector *typevector; /* Vector of all data types */ - enum language language; /* Code identifying the language used */ - char *version; /* Version info. Not fully specified */ - char *compilation; /* Compilation info. Not fully specified */ - int databeg; /* Address within the file of data start */ - int bssbeg; /* Address within the file of bss start */ - struct sourcevector *sourcevector; /* Vector of line-number info */ -}; - -/* All data types of symbols in the compiled program - are represented by `struct type' objects. - All of these objects are pointed to by the typevector. - The type vector may have empty slots that contain zero. */ - -struct typevector -{ - int length; /* Number of types described */ - struct type *type[1]; -}; - -/* Different kinds of data types are distinguished by the `code' field. */ - -enum type_code -{ - TYPE_CODE_UNDEF, /* Not used; catches errors */ - TYPE_CODE_PTR, /* Pointer type */ - TYPE_CODE_ARRAY, /* Array type, lower bound zero */ - TYPE_CODE_STRUCT, /* C struct or Pascal record */ - TYPE_CODE_UNION, /* C union or Pascal variant part */ - TYPE_CODE_ENUM, /* Enumeration type */ - TYPE_CODE_FUNC, /* Function type */ - TYPE_CODE_INT, /* Integer type */ - TYPE_CODE_FLT, /* Floating type */ - TYPE_CODE_VOID, /* Void type (values zero length) */ - TYPE_CODE_SET, /* Pascal sets */ - TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */ - TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */ - - /* C++ */ - TYPE_CODE_MEMBER, /* Member type */ - TYPE_CODE_METHOD, /* Method type */ - TYPE_CODE_REF, /* C++ Reference types */ -}; - -/* This appears in a type's flags word for an unsigned integer type. */ -#define TYPE_FLAG_UNSIGNED 1 -/* This appears in a type's flags word - if it is a (pointer to a|function returning a)* built in scalar type. - These types are never freed. */ -#define TYPE_FLAG_PERM 4 -/* This appears in a type's flags word if it is a stub type (eg. if - someone referenced a type that wasn't definined in a source file - via (struct sir_not_appearing_in_this_film *)). */ -#define TYPE_FLAG_STUB 8 -/* Set when a class has a constructor defined */ -#define TYPE_FLAG_HAS_CONSTRUCTOR 256 -/* Set when a class has a destructor defined */ -#define TYPE_FLAG_HAS_DESTRUCTOR 512 -/* Indicates that this type is a public baseclass of another class, - i.e. that all its public methods are available in the derived - class. */ -#define TYPE_FLAG_VIA_PUBLIC 1024 -/* Indicates that this type is a virtual baseclass of another class, - i.e. that if this class is inherited more than once by another - class, only one set of member variables will be included. */ -#define TYPE_FLAG_VIA_VIRTUAL 2048 - -struct type -{ - /* Code for kind of type */ - enum type_code code; - /* Name of this type, or zero if none. - This is used for printing only. - Type names specified as input are defined by symbols. */ - char *name; - /* Length in bytes of storage for a value of this type */ - int length; - /* For a pointer type, describes the type of object pointed to. - For an array type, describes the type of the elements. - For a function or method type, describes the type of the value. - For a range type, describes the type of the full range. - Unused otherwise. */ - struct type *target_type; - /* Type that is a pointer to this type. - Zero if no such pointer-to type is known yet. - The debugger may add the address of such a type - if it has to construct one later. */ - struct type *pointer_type; - /* C++: also need a reference type. */ - struct type *reference_type; - struct type **arg_types; - - /* Type that is a function returning this type. - Zero if no such function type is known here. - The debugger may add the address of such a type - if it has to construct one later. */ - struct type *function_type; - -/* Handling of pointers to members: - TYPE_MAIN_VARIANT is used for pointer and pointer - to member types. Normally it the value of the address of its - containing type. However, for pointers to members, we must be - able to allocate pointer to member types and look them up - from some place of reference. - NEXT_VARIANT is the next element in the chain. */ - struct type *main_variant, *next_variant; - - /* Flags about this type. */ - short flags; - /* Number of fields described for this type */ - short nfields; - /* For structure and union types, a description of each field. - For set and pascal array types, there is one "field", - whose type is the domain type of the set or array. - For range types, there are two "fields", - the minimum and maximum values (both inclusive). - For enum types, each possible value is described by one "field". - - Using a pointer to a separate array of fields - allows all types to have the same size, which is useful - because we can allocate the space for a type before - we know what to put in it. */ - struct field - { - /* Position of this field, counting in bits from start of - containing structure. For a function type, this is the - position in the argument list of this argument. - For a range bound or enum value, this is the value itself. */ - int bitpos; - /* Size of this field, in bits, or zero if not packed. - For an unpacked field, the field's type's length - says how many bytes the field occupies. */ - int bitsize; - /* In a struct or enum type, type of this field. - In a function type, type of this argument. - In an array type, the domain-type of the array. */ - struct type *type; - /* Name of field, value or argument. - Zero for range bounds and array domains. */ - char *name; - } *fields; - - /* C++ */ - int *private_field_bits; - int *protected_field_bits; - - /* Number of methods described for this type */ - short nfn_fields; - /* Number of base classes this type derives from. */ - short n_baseclasses; - - /* Number of methods described for this type plus all the - methods that it derives from. */ - int nfn_fields_total; - - /* For classes, structures, and unions, a description of each field, - which consists of an overloaded name, followed by the types of - arguments that the method expects, and then the name after it - has been renamed to make it distinct. */ - struct fn_fieldlist - { - /* The overloaded name. */ - char *name; - /* The number of methods with this name. */ - int length; - /* The list of methods. */ - struct fn_field - { -#if 0 - /* The overloaded name */ - char *name; -#endif - /* The return value of the method */ - struct type *type; - /* The argument list */ - struct type **args; - /* The name after it has been processed */ - char *physname; - /* If this is a virtual function, the offset into the vtbl-1, - else 0. */ - int voffset; - } *fn_fields; - - int *private_fn_field_bits; - int *protected_fn_field_bits; - - } *fn_fieldlists; - - unsigned char via_protected; - unsigned char via_public; - - /* For types with virtual functions, VPTR_BASETYPE is the base class which - defined the virtual function table pointer. VPTR_FIELDNO is - the field number of that pointer in the structure. - - For types that are pointer to member types, VPTR_BASETYPE - ifs the type that this pointer is a member of. - - Unused otherwise. */ - struct type *vptr_basetype; - - int vptr_fieldno; - - /* If this type has a base class, put it here. - If this type is a pointer type, the chain of member pointer - types goes here. - Unused otherwise. - - Contrary to all maxims of C style and common sense, the baseclasses - are indexed from 1 to N_BASECLASSES rather than 0 to N_BASECLASSES-1 - (i.e. BASECLASSES points to one *before* the first element of - the array). */ - struct type **baseclasses; -}; - -/* All of the name-scope contours of the program - are represented by `struct block' objects. - All of these objects are pointed to by the blockvector. - - Each block represents one name scope. - Each lexical context has its own block. - - The first two blocks in the blockvector are special. - The first one contains all the symbols defined in this compilation - whose scope is the entire program linked together. - The second one contains all the symbols whose scope is the - entire compilation excluding other separate compilations. - In C, these correspond to global symbols and static symbols. - - Each block records a range of core addresses for the code that - is in the scope of the block. The first two special blocks - give, for the range of code, the entire range of code produced - by the compilation that the symbol segment belongs to. - - The blocks appear in the blockvector - in order of increasing starting-address, - and, within that, in order of decreasing ending-address. - - This implies that within the body of one function - the blocks appear in the order of a depth-first tree walk. */ - -struct blockvector -{ - /* Number of blocks in the list. */ - int nblocks; - /* The blocks themselves. */ - struct block *block[1]; -}; - -struct block -{ - /* Addresses in the executable code that are in this block. - Note: in an unrelocated symbol segment in a file, - these are always zero. They can be filled in from the - N_LBRAC and N_RBRAC symbols in the loader symbol table. */ - int startaddr, endaddr; - /* The symbol that names this block, - if the block is the body of a function; - otherwise, zero. - Note: In an unrelocated symbol segment in an object file, - this field may be zero even when the block has a name. - That is because the block is output before the name - (since the name resides in a higher block). - Since the symbol does point to the block (as its value), - it is possible to find the block and set its name properly. */ - struct symbol *function; - /* The `struct block' for the containing block, or 0 if none. */ - /* Note that in an unrelocated symbol segment in an object file - this pointer may be zero when the correct value should be - the second special block (for symbols whose scope is one compilation). - This is because the compiler ouptuts the special blocks at the - very end, after the other blocks. */ - struct block *superblock; - /* A flag indicating whether or not the fucntion corresponding - to this block was compiled with gcc or not. If there is no - function corresponding to this block, this meaning of this flag - is undefined. (In practice it will be 1 if the block was created - while processing a file compiled with gcc and 0 when not). */ - unsigned char gcc_compile_flag; - /* Number of local symbols. */ - int nsyms; - /* The symbols. */ - struct symbol *sym[1]; -}; - -/* Represent one symbol name; a variable, constant, function or typedef. */ - -/* Different name spaces for symbols. Looking up a symbol specifies - a namespace and ignores symbol definitions in other name spaces. - - VAR_NAMESPACE is the usual namespace. - In C, this contains variables, function names, typedef names - and enum type values. - - STRUCT_NAMESPACE is used in C to hold struct, union and enum type names. - Thus, if `struct foo' is used in a C program, - it produces a symbol named `foo' in the STRUCT_NAMESPACE. - - LABEL_NAMESPACE may be used for names of labels (for gotos); - currently it is not used and labels are not recorded at all. */ - -/* For a non-global symbol allocated statically, - the correct core address cannot be determined by the compiler. - The compiler puts an index number into the symbol's value field. - This index number can be matched with the "desc" field of - an entry in the loader symbol table. */ - -enum namespace -{ - UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE, -}; - -/* An address-class says where to find the value of the symbol in core. */ - -enum address_class -{ - LOC_UNDEF, /* Not used; catches errors */ - LOC_CONST, /* Value is constant int */ - LOC_STATIC, /* Value is at fixed address */ - LOC_REGISTER, /* Value is in register */ - LOC_ARG, /* Value is at spec'd position in arglist */ - LOC_REF_ARG, /* Value address is at spec'd position in */ - /* arglist. */ - LOC_REGPARM, /* Value is at spec'd position in register window */ - LOC_LOCAL, /* Value is at spec'd pos in stack frame */ - LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE - Symbols in the namespace STRUCT_NAMESPACE - all have this class. */ - LOC_LABEL, /* Value is address in the code */ - LOC_BLOCK, /* Value is address of a `struct block'. - Function names have this class. */ - LOC_EXTERNAL, /* Value is at address not in this compilation. - This is used for .comm symbols - and for extern symbols within functions. - Inside GDB, this is changed to LOC_STATIC once the - real address is obtained from a loader symbol. */ - LOC_CONST_BYTES /* Value is a constant byte-sequence. */ -}; - -struct symbol -{ - /* Symbol name */ - char *name; - /* Name space code. */ - enum namespace namespace; - /* Address class */ - enum address_class class; - /* Data type of value */ - struct type *type; - /* constant value, or address if static, or register number, - or offset in arguments, or offset in stack frame. */ - union - { - long value; - struct block *block; /* for LOC_BLOCK */ - char *bytes; /* for LOC_CONST_BYTES */ - } - value; -}; - -struct partial_symbol -{ - /* Symbol name */ - char *name; - /* Name space code. */ - enum namespace namespace; - /* Address class (for info_symbols) */ - enum address_class class; - /* Associated partial symbol table */ - struct partial_symtab *pst; - /* Value (only used for static functions currently). Done this - way so that we can use the struct symbol macros. - Note that the address of a function is SYMBOL_VALUE (pst) - in a partial symbol table, but BLOCK_START (SYMBOL_BLOCK_VALUE (st)) - in a symbol table. */ - union - { - long value; - } - value; -}; - -/* - * Vectors of all partial symbols read in from file; actually declared - * and used in dbxread.c. - */ -extern struct psymbol_allocation_list { - struct partial_symbol *list, *next; - int size; -} global_psymbols, static_psymbols; - - -/* Source-file information. - This describes the relation between source files and line numbers - and addresses in the program text. */ - -struct sourcevector -{ - int length; /* Number of source files described */ - struct source *source[1]; /* Descriptions of the files */ -}; - -/* Each item represents a line-->pc (or the reverse) mapping. This is - somewhat more wasteful of space than one might wish, but since only - the files which are actually debugged are read in to core, we don't - waste much space. - - Each item used to be an int; either minus a line number, or a - program counter. If it represents a line number, that is the line - described by the next program counter value. If it is positive, it - is the program counter at which the code for the next line starts. */ - -struct linetable_entry -{ - int line; - CORE_ADDR pc; -}; - -struct linetable -{ - int nitems; - struct linetable_entry item[1]; -}; - -/* All the information on one source file. */ - -struct source -{ - char *name; /* Name of file */ - struct linetable contents; -}; diff --git a/gnu/usr.bin/gdb/symtab.c b/gnu/usr.bin/gdb/symtab.c deleted file mode 100644 index 99e7aac8c223..000000000000 --- a/gnu/usr.bin/gdb/symtab.c +++ /dev/null @@ -1,2472 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)symtab.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: symtab.c,v 1.2 1993/08/01 18:47:38 mycroft Exp $"; -#endif /* not lint */ - -/* Symbol table lookup for the GNU debugger, GDB. - Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "symtab.h" -#include "param.h" - -#include -#include - -char *index (); -extern char *cplus_demangle (); -extern struct value * value_of_this (); - -/* Allocate an obstack to hold objects that should be freed - when we load a new symbol table. - This includes the symbols made by dbxread - and the types that are not permanent. */ - -struct obstack obstack1; - -struct obstack *symbol_obstack = &obstack1; - -/* This obstack will be used for partial_symbol objects. It can - probably actually be the same as the symbol_obstack above, but I'd - like to keep them seperate for now. If I want to later, I'll - replace one with the other. */ - -struct obstack obstack2; - -struct obstack *psymbol_obstack = &obstack2; - -/* These variables point to the objects - representing the predefined C data types. */ - -struct type *builtin_type_void; -struct type *builtin_type_char; -struct type *builtin_type_short; -struct type *builtin_type_int; -struct type *builtin_type_long; -#ifdef LONG_LONG -struct type *builtin_type_long_long; -#endif -struct type *builtin_type_unsigned_char; -struct type *builtin_type_unsigned_short; -struct type *builtin_type_unsigned_int; -struct type *builtin_type_unsigned_long; -#ifdef LONG_LONG -struct type *builtin_type_unsigned_long_long; -#endif -struct type *builtin_type_float; -struct type *builtin_type_double; - -/* Block in which the most recently searched-for symbol was found. - Might be better to make this a parameter to lookup_symbol and - value_of_this. */ -struct block *block_found; - -/* Functions */ -static int find_line_common (); -int lookup_misc_func (); -struct partial_symtab *lookup_partial_symtab (); -struct symtab *psymtab_to_symtab (); -static struct partial_symbol *lookup_partial_symbol (); - -/* Check for a symtab of a specific name; first in symtabs, then in - psymtabs. *If* there is no '/' in the name, a match after a '/' - in the symtab filename will also work. */ - -static struct symtab * -lookup_symtab_1 (name) - char *name; -{ - register struct symtab *s; - register struct partial_symtab *ps; - register char *slash = index (name, '/'); - register int len = strlen (name); - - for (s = symtab_list; s; s = s->next) - if (!strcmp (name, s->filename)) - return s; - - for (ps = partial_symtab_list; ps; ps = ps->next) - if (!strcmp (name, ps->filename)) - { - if (ps->readin) - fatal ("Internal: readin pst found when no symtab found."); - s = psymtab_to_symtab (ps); - return s; - } - - if (!slash) - { - for (s = symtab_list; s; s = s->next) - { - int l = strlen (s->filename); - - if (s->filename[l - len -1] == '/' - && !strcmp (s->filename + l - len, name)) - return s; - } - - for (ps = partial_symtab_list; ps; ps = ps->next) - { - int l = strlen (ps->filename); - - if (ps->filename[l - len - 1] == '/' - && !strcmp (ps->filename + l - len, name)) - { - if (ps->readin) - fatal ("Internal: readin pst found when no symtab found."); - s = psymtab_to_symtab (ps); - return s; - } - } - } - return 0; -} - -/* Lookup the symbol table of a source file named NAME. Try a couple - of variations if the first lookup doesn't work. */ - -struct symtab * -lookup_symtab (name) - char *name; -{ - register struct symtab *s; - register char *copy; - - s = lookup_symtab_1 (name); - if (s) return s; - - /* If name not found as specified, see if adding ".c" helps. */ - - copy = (char *) alloca (strlen (name) + 3); - strcpy (copy, name); - strcat (copy, ".c"); - s = lookup_symtab_1 (copy); - if (s) return s; - - /* We didn't find anything; die. */ - return 0; -} - -/* Lookup the partial symbol table of a source file named NAME. This - only returns true on an exact match (ie. this semantics are - different from lookup_symtab. */ - -struct partial_symtab * -lookup_partial_symtab (name) -char *name; -{ - register struct partial_symtab *s; - register char *copy; - - for (s = partial_symtab_list; s; s = s->next) - if (!strcmp (name, s->filename)) - return s; - - return 0; -} - -/* Lookup a typedef or primitive type named NAME, - visible in lexical block BLOCK. - If NOERR is nonzero, return zero if NAME is not suitably defined. */ - -struct type * -lookup_typename (name, block, noerr) - char *name; - struct block *block; - int noerr; -{ - register struct symbol *sym = lookup_symbol (name, block, VAR_NAMESPACE, 0); - if (sym == 0 || SYMBOL_CLASS (sym) != LOC_TYPEDEF) - { - if (!strcmp (name, "int")) - return builtin_type_int; - if (!strcmp (name, "long")) - return builtin_type_long; - if (!strcmp (name, "short")) - return builtin_type_short; - if (!strcmp (name, "char")) - return builtin_type_char; - if (!strcmp (name, "float")) - return builtin_type_float; - if (!strcmp (name, "double")) - return builtin_type_double; - if (!strcmp (name, "void")) - return builtin_type_void; - - if (noerr) - return 0; - error ("No type named %s.", name); - } - return SYMBOL_TYPE (sym); -} - -struct type * -lookup_unsigned_typename (name) - char *name; -{ - if (!strcmp (name, "int")) - return builtin_type_unsigned_int; - if (!strcmp (name, "long")) - return builtin_type_unsigned_long; - if (!strcmp (name, "short")) - return builtin_type_unsigned_short; - if (!strcmp (name, "char")) - return builtin_type_unsigned_char; - error ("No type named unsigned %s.", name); -} - -/* Lookup a structure type named "struct NAME", - visible in lexical block BLOCK. */ - -struct type * -lookup_struct (name, block) - char *name; - struct block *block; -{ - register struct symbol *sym - = lookup_symbol (name, block, STRUCT_NAMESPACE, 0); - - if (sym == 0) - error ("No struct type named %s.", name); - if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT) - error ("This context has class, union or enum %s, not a struct.", name); - return SYMBOL_TYPE (sym); -} - -/* Lookup a union type named "union NAME", - visible in lexical block BLOCK. */ - -struct type * -lookup_union (name, block) - char *name; - struct block *block; -{ - register struct symbol *sym - = lookup_symbol (name, block, STRUCT_NAMESPACE, 0); - - if (sym == 0) - error ("No union type named %s.", name); - if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_UNION) - error ("This context has class, struct or enum %s, not a union.", name); - return SYMBOL_TYPE (sym); -} - -/* Lookup an enum type named "enum NAME", - visible in lexical block BLOCK. */ - -struct type * -lookup_enum (name, block) - char *name; - struct block *block; -{ - register struct symbol *sym - = lookup_symbol (name, block, STRUCT_NAMESPACE, 0); - if (sym == 0) - error ("No enum type named %s.", name); - if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_ENUM) - error ("This context has class, struct or union %s, not an enum.", name); - return SYMBOL_TYPE (sym); -} - -/* Given a type TYPE, lookup the type of the component of type named - NAME. */ - -struct type * -lookup_struct_elt_type (type, name) - struct type *type; - char *name; -{ - struct type *t; - int i; - char *errmsg; - - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION) - { - terminal_ours (); - fflush (stdout); - fprintf (stderr, "Type "); - type_print (type, "", stderr, -1); - fprintf (stderr, " is not a structure or union type.\n"); - return_to_top_level (); - } - - for (i = TYPE_NFIELDS (type) - 1; i >= 0; i--) - if (!strcmp (TYPE_FIELD_NAME (type, i), name)) - return TYPE_FIELD_TYPE (type, i); - - terminal_ours (); - fflush (stdout); - fprintf (stderr, "Type "); - type_print (type, "", stderr, -1); - fprintf (stderr, " has no component named %s\n", name); - return_to_top_level (); -} - -/* Given a type TYPE, return a type of pointers to that type. - May need to construct such a type if this is the first use. - - C++: use TYPE_MAIN_VARIANT and TYPE_CHAIN to keep pointer - to member types under control. */ - -struct type * -lookup_pointer_type (type) - struct type *type; -{ - register struct type *ptype = TYPE_POINTER_TYPE (type); - if (ptype) return TYPE_MAIN_VARIANT (ptype); - - /* This is the first time anyone wanted a pointer to a TYPE. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - ptype = (struct type *) xmalloc (sizeof (struct type)); - else - ptype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - bzero (ptype, sizeof (struct type)); - TYPE_MAIN_VARIANT (ptype) = ptype; - TYPE_TARGET_TYPE (ptype) = type; - TYPE_POINTER_TYPE (type) = ptype; - /* New type is permanent if type pointed to is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (ptype) |= TYPE_FLAG_PERM; - /* We assume the machine has only one representation for pointers! */ - TYPE_LENGTH (ptype) = sizeof (char *); - TYPE_CODE (ptype) = TYPE_CODE_PTR; - return ptype; -} - -struct type * -lookup_reference_type (type) - struct type *type; -{ - register struct type *rtype = TYPE_REFERENCE_TYPE (type); - if (rtype) return TYPE_MAIN_VARIANT (rtype); - - /* This is the first time anyone wanted a pointer to a TYPE. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - rtype = (struct type *) xmalloc (sizeof (struct type)); - else - rtype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - bzero (rtype, sizeof (struct type)); - TYPE_MAIN_VARIANT (rtype) = rtype; - TYPE_TARGET_TYPE (rtype) = type; - TYPE_REFERENCE_TYPE (type) = rtype; - /* New type is permanent if type pointed to is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (rtype) |= TYPE_FLAG_PERM; - /* We assume the machine has only one representation for pointers! */ - TYPE_LENGTH (rtype) = sizeof (char *); - TYPE_CODE (rtype) = TYPE_CODE_REF; - return rtype; -} - - -/* Implement direct support for MEMBER_TYPE in GNU C++. - May need to construct such a type if this is the first use. - The TYPE is the type of the member. The DOMAIN is the type - of the aggregate that the member belongs to. */ - -struct type * -lookup_member_type (type, domain) - struct type *type, *domain; -{ - register struct type *mtype = TYPE_MAIN_VARIANT (type); - struct type *main_type; - - main_type = mtype; - while (mtype) - { - if (TYPE_DOMAIN_TYPE (mtype) == domain) - return mtype; - mtype = TYPE_NEXT_VARIANT (mtype); - } - - /* This is the first time anyone wanted this member type. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - mtype = (struct type *) xmalloc (sizeof (struct type)); - else - mtype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - bzero (mtype, sizeof (struct type)); - if (main_type == 0) - main_type = mtype; - else - { - TYPE_NEXT_VARIANT (mtype) = TYPE_NEXT_VARIANT (main_type); - TYPE_NEXT_VARIANT (main_type) = mtype; - } - TYPE_MAIN_VARIANT (mtype) = main_type; - TYPE_TARGET_TYPE (mtype) = type; - TYPE_DOMAIN_TYPE (mtype) = domain; - /* New type is permanent if type pointed to is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (mtype) |= TYPE_FLAG_PERM; - - /* In practice, this is never used. */ - TYPE_LENGTH (mtype) = 1; - TYPE_CODE (mtype) = TYPE_CODE_MEMBER; - -#if 0 - /* Now splice in the new member pointer type. */ - if (main_type) - { - /* This type was not "smashed". */ - TYPE_CHAIN (mtype) = TYPE_CHAIN (main_type); - TYPE_CHAIN (main_type) = mtype; - } -#endif - - return mtype; -} - -struct type * -lookup_method_type (type, domain, args) - struct type *type, *domain, **args; -{ - register struct type *mtype = TYPE_MAIN_VARIANT (type); - struct type *main_type; - - main_type = mtype; - while (mtype) - { - if (TYPE_DOMAIN_TYPE (mtype) == domain) - { - struct type **t1 = args; - struct type **t2 = TYPE_ARG_TYPES (mtype); - if (t2) - { - int i; - for (i = 0; t1[i] != 0 && t1[i]->code != TYPE_CODE_VOID; i++) - if (t1[i] != t2[i]) - break; - if (t1[i] == t2[i]) - return mtype; - } - } - mtype = TYPE_NEXT_VARIANT (mtype); - } - - /* This is the first time anyone wanted this member type. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - mtype = (struct type *) xmalloc (sizeof (struct type)); - else - mtype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - bzero (mtype, sizeof (struct type)); - if (main_type == 0) - main_type = mtype; - else - { - TYPE_NEXT_VARIANT (mtype) = TYPE_NEXT_VARIANT (main_type); - TYPE_NEXT_VARIANT (main_type) = mtype; - } - TYPE_MAIN_VARIANT (mtype) = main_type; - TYPE_TARGET_TYPE (mtype) = type; - TYPE_DOMAIN_TYPE (mtype) = domain; - TYPE_ARG_TYPES (mtype) = args; - /* New type is permanent if type pointed to is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (mtype) |= TYPE_FLAG_PERM; - - /* In practice, this is never used. */ - TYPE_LENGTH (mtype) = 1; - TYPE_CODE (mtype) = TYPE_CODE_METHOD; - -#if 0 - /* Now splice in the new member pointer type. */ - if (main_type) - { - /* This type was not "smashed". */ - TYPE_CHAIN (mtype) = TYPE_CHAIN (main_type); - TYPE_CHAIN (main_type) = mtype; - } -#endif - - return mtype; -} - -/* Given a type TYPE, return a type which has offset OFFSET, - via_virtual VIA_VIRTUAL, and via_public VIA_PUBLIC. - May need to construct such a type if none exists. */ -struct type * -lookup_basetype_type (type, offset, via_virtual, via_public) - struct type *type; - int offset; - int via_virtual, via_public; -{ - register struct type *btype = TYPE_MAIN_VARIANT (type); - struct type *main_type; - - if (offset != 0) - { - printf ("Internal error: type offset non-zero in lookup_basetype_type"); - offset = 0; - } - - main_type = btype; - while (btype) - { - if (/* TYPE_OFFSET (btype) == offset - && */ TYPE_VIA_PUBLIC (btype) == via_public - && TYPE_VIA_VIRTUAL (btype) == via_virtual) - return btype; - btype = TYPE_NEXT_VARIANT (btype); - } - - /* This is the first time anyone wanted this member type. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - btype = (struct type *) xmalloc (sizeof (struct type)); - else - btype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - if (main_type == 0) - { - main_type = btype; - bzero (btype, sizeof (struct type)); - TYPE_MAIN_VARIANT (btype) = main_type; - } - else - { - bcopy (main_type, btype, sizeof (struct type)); - TYPE_NEXT_VARIANT (main_type) = btype; - } -/* TYPE_OFFSET (btype) = offset; */ - if (via_public) - TYPE_FLAGS (btype) |= TYPE_FLAG_VIA_PUBLIC; - if (via_virtual) - TYPE_FLAGS (btype) |= TYPE_FLAG_VIA_VIRTUAL; - /* New type is permanent if type pointed to is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (btype) |= TYPE_FLAG_PERM; - - /* In practice, this is never used. */ - TYPE_LENGTH (btype) = 1; - TYPE_CODE (btype) = TYPE_CODE_STRUCT; - - return btype; -} - -/* Given a type TYPE, return a type of functions that return that type. - May need to construct such a type if this is the first use. */ - -struct type * -lookup_function_type (type) - struct type *type; -{ - register struct type *ptype = TYPE_FUNCTION_TYPE (type); - if (ptype) return ptype; - - /* This is the first time anyone wanted a function returning a TYPE. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - ptype = (struct type *) xmalloc (sizeof (struct type)); - else - ptype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - bzero (ptype, sizeof (struct type)); - TYPE_TARGET_TYPE (ptype) = type; - TYPE_FUNCTION_TYPE (type) = ptype; - /* New type is permanent if type returned is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (ptype) |= TYPE_FLAG_PERM; - TYPE_LENGTH (ptype) = 1; - TYPE_CODE (ptype) = TYPE_CODE_FUNC; - TYPE_NFIELDS (ptype) = 0; - return ptype; -} - -/* Create an array type. Elements will be of type TYPE, and there will - be NUM of them. - - Eventually this should be extended to take two more arguments which - specify the bounds of the array and the type of the index. - It should also be changed to be a "lookup" function, with the - appropriate data structures added to the type field. - Then read array type should call here. */ - -struct type * -create_array_type (element_type, number) - struct type *element_type; - int number; -{ - struct type *result_type = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); - - bzero (result_type, sizeof (struct type)); - - TYPE_CODE (result_type) = TYPE_CODE_ARRAY; - TYPE_TARGET_TYPE (result_type) = element_type; - TYPE_LENGTH (result_type) = number * TYPE_LENGTH (element_type); - TYPE_NFIELDS (result_type) = 1; - TYPE_FIELDS (result_type) = - (struct field *) obstack_alloc (symbol_obstack, sizeof (struct field)); - TYPE_FIELD_TYPE (result_type, 0) = builtin_type_int; - TYPE_VPTR_FIELDNO (result_type) = -1; - - return result_type; -} - - -/* Smash TYPE to be a type of pointers to TO_TYPE. - If TO_TYPE is not permanent and has no pointer-type yet, - record TYPE as its pointer-type. */ - -void -smash_to_pointer_type (type, to_type) - struct type *type, *to_type; -{ - int type_permanent = (TYPE_FLAGS (type) & TYPE_FLAG_PERM); - - bzero (type, sizeof (struct type)); - TYPE_TARGET_TYPE (type) = to_type; - /* We assume the machine has only one representation for pointers! */ - TYPE_LENGTH (type) = sizeof (char *); - TYPE_CODE (type) = TYPE_CODE_PTR; - - TYPE_MAIN_VARIANT (type) = type; - - if (type_permanent) - TYPE_FLAGS (type) |= TYPE_FLAG_PERM; - - if (TYPE_POINTER_TYPE (to_type) == 0 - && (!(TYPE_FLAGS (to_type) & TYPE_FLAG_PERM) - || type_permanent)) - { - TYPE_POINTER_TYPE (to_type) = type; - } -} - -/* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE. */ - -void -smash_to_member_type (type, domain, to_type) - struct type *type, *domain, *to_type; -{ - bzero (type, sizeof (struct type)); - TYPE_TARGET_TYPE (type) = to_type; - TYPE_DOMAIN_TYPE (type) = domain; - - /* In practice, this is never needed. */ - TYPE_LENGTH (type) = 1; - TYPE_CODE (type) = TYPE_CODE_MEMBER; - - TYPE_MAIN_VARIANT (type) = lookup_member_type (domain, to_type); -} - -/* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE. */ - -void -smash_to_method_type (type, domain, to_type, args) - struct type *type, *domain, *to_type, **args; -{ - bzero (type, sizeof (struct type)); - TYPE_TARGET_TYPE (type) = to_type; - TYPE_DOMAIN_TYPE (type) = domain; - TYPE_ARG_TYPES (type) = args; - - /* In practice, this is never needed. */ - TYPE_LENGTH (type) = 1; - TYPE_CODE (type) = TYPE_CODE_METHOD; - - TYPE_MAIN_VARIANT (type) = lookup_method_type (domain, to_type, args); -} - -/* Smash TYPE to be a type of reference to TO_TYPE. - If TO_TYPE is not permanent and has no pointer-type yet, - record TYPE as its pointer-type. */ - -void -smash_to_reference_type (type, to_type) - struct type *type, *to_type; -{ - int type_permanent = (TYPE_FLAGS (type) & TYPE_FLAG_PERM); - - bzero (type, sizeof (struct type)); - TYPE_TARGET_TYPE (type) = to_type; - /* We assume the machine has only one representation for pointers! */ - TYPE_LENGTH (type) = sizeof (char *); - TYPE_CODE (type) = TYPE_CODE_REF; - - TYPE_MAIN_VARIANT (type) = type; - - if (type_permanent) - TYPE_FLAGS (type) |= TYPE_FLAG_PERM; - - if (TYPE_REFERENCE_TYPE (to_type) == 0 - && (!(TYPE_FLAGS (to_type) & TYPE_FLAG_PERM) - || type_permanent)) - { - TYPE_REFERENCE_TYPE (to_type) = type; - } -} - -/* Smash TYPE to be a type of functions returning TO_TYPE. - If TO_TYPE is not permanent and has no function-type yet, - record TYPE as its function-type. */ - -void -smash_to_function_type (type, to_type) - struct type *type, *to_type; -{ - int type_permanent = (TYPE_FLAGS (type) & TYPE_FLAG_PERM); - - bzero (type, sizeof (struct type)); - TYPE_TARGET_TYPE (type) = to_type; - TYPE_LENGTH (type) = 1; - TYPE_CODE (type) = TYPE_CODE_FUNC; - TYPE_NFIELDS (type) = 0; - - if (type_permanent) - TYPE_FLAGS (type) |= TYPE_FLAG_PERM; - - if (TYPE_FUNCTION_TYPE (to_type) == 0 - && (!(TYPE_FLAGS (to_type) & TYPE_FLAG_PERM) - || type_permanent)) - { - TYPE_FUNCTION_TYPE (to_type) = type; - } -} - -/* Find which partial symtab on the partial_symtab_list contains - PC. Return 0 if none. */ - -struct partial_symtab * -find_pc_psymtab (pc) - register CORE_ADDR pc; -{ - register struct partial_symtab *ps; - - for (ps = partial_symtab_list; ps; ps = ps->next) - if (pc >= ps->textlow && pc < ps->texthigh) - return ps; - - return 0; -} - -/* Find which partial symbol within a psymtab contains PC. Return 0 - if none. Check all psymtabs if PSYMTAB is 0. */ -struct partial_symbol * -find_pc_psymbol (psymtab, pc) - struct partial_symtab *psymtab; - CORE_ADDR pc; -{ - struct partial_symbol *best, *p; - int best_pc; - - if (!psymtab) - psymtab = find_pc_psymtab (pc); - if (!psymtab) - return 0; - - best_pc = psymtab->textlow - 1; - - for (p = static_psymbols.list + psymtab->statics_offset; - (p - (static_psymbols.list + psymtab->statics_offset) - < psymtab->n_static_syms); - p++) - if (SYMBOL_NAMESPACE (p) == VAR_NAMESPACE - && SYMBOL_CLASS (p) == LOC_BLOCK - && pc >= SYMBOL_VALUE (p) - && SYMBOL_VALUE (p) > best_pc) - { - best_pc = SYMBOL_VALUE (p); - best = p; - } - if (best_pc == psymtab->textlow - 1) - return 0; - return best; -} - - -static struct symbol *lookup_block_symbol (); - -/* Find the definition for a specified symbol name NAME - in namespace NAMESPACE, visible from lexical block BLOCK. - Returns the struct symbol pointer, or zero if no symbol is found. - C++: if IS_A_FIELD_OF_THIS is nonzero on entry, check to see if - NAME is a field of the current implied argument `this'. If so set - *IS_A_FIELD_OF_THIS to 1, otherwise set it to zero. - BLOCK_FOUND is set to the block in which NAME is found (in the case of - a field of `this', value_of_this sets BLOCK_FOUND to the proper value.) */ - -struct symbol * -lookup_symbol (name, block, namespace, is_a_field_of_this) - char *name; - register struct block *block; - enum namespace namespace; - int *is_a_field_of_this; -{ - register int i, n; - register struct symbol *sym; - register struct symtab *s; - register struct partial_symtab *ps; - register struct partial_symbol *psym; - struct blockvector *bv; - - /* Search specified block and its superiors. */ - - while (block != 0) - { - sym = lookup_block_symbol (block, name, namespace); - if (sym) - { - block_found = block; - return sym; - } - block = BLOCK_SUPERBLOCK (block); - } - - /* C++: If requested to do so by the caller, - check to see if NAME is a field of `this'. */ - if (is_a_field_of_this) - { - struct value *v = value_of_this (0); - - *is_a_field_of_this = 0; - if (v && check_field (v, name)) - { - *is_a_field_of_this = 1; - return 0; - } - } - - /* Now search all global blocks. Do the symtab's first, then - check the psymtab's */ - - for (s = symtab_list; s; s = s->next) - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, 0); - sym = lookup_block_symbol (block, name, namespace); - if (sym) - { - block_found = block; - return sym; - } - } - - /* Check for the possibility of the symbol being a global function - that is stored on the misc function vector. Eventually, all - global symbols might be resolved in this way. */ - - if (namespace == VAR_NAMESPACE) - { - int index = lookup_misc_func (name); - - if (index == -1) - { /* Look for a mangled C++ name for NAME. */ - int name_len = strlen (name); - for (index = misc_function_count; --index >= 0; ) - /* Assume orginal name is prefix of mangled name. */ - if (!strncmp (misc_function_vector[index].name, name, name_len)) - { - char *demangled = - cplus_demangle(misc_function_vector[index].name, -1); - if (demangled != NULL) - { - int cond = strcmp (demangled, name); - free (demangled); - if (!cond) - break; - } - } - /* Loop terminates on no match with index == -1. */ - } - - if (index != -1) - { - ps = find_pc_psymtab (misc_function_vector[index].address); - if (ps && !ps->readin) - { - s = psymtab_to_symtab (ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, 0); - sym = lookup_block_symbol (block, name, namespace); - /* sym == 0 if symbol was found in the psymtab but not - in the symtab. - Return 0 to use the misc_function definition of "foo_". - - This happens for Fortran "foo_" symbols, - which are "foo" in the symtab. - - This can also happen if "asm" is used to make a - regular symbol but not a debugging symbol, e.g. - asm(".globl _main"); - asm("_main:"); - */ - - return sym; - } - } - } - - if (psym = lookup_partial_symbol (name, 1, namespace)) - { - ps = psym->pst; - s = psymtab_to_symtab(ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, 0); - sym = lookup_block_symbol (block, name, namespace); - if (!sym) - fatal ("Internal: global symbol found in psymtab but not in symtab"); - return sym; - } - - /* Now search all per-file blocks. - Not strictly correct, but more useful than an error. - Do the symtabs first, then check the psymtabs */ - - for (s = symtab_list; s; s = s->next) - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, 1); - sym = lookup_block_symbol (block, name, namespace); - if (sym) - { - block_found = block; - return sym; - } - } - - if (psym = lookup_partial_symbol(name, 0, namespace)) - { - ps = psym->pst; - s = psymtab_to_symtab(ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, 1); - sym = lookup_block_symbol (block, name, namespace); - if (!sym) - fatal ("Internal: static symbol found in psymtab but not in symtab"); - return sym; - } - - return 0; -} - -/* Look, in partial_symtab PST, for symbol NAME. Check the global - symbols if GLOBAL, the static symbols if not */ - -static struct partial_symbol * -lookup_partial_symbol (name, global, namespace) - register char *name; - register int global; - register enum namespace namespace; -{ - register struct partial_symbol *start, *psym; - register struct partial_symbol *top, *bottom, *center; - register struct partial_symtab *pst; - register int length; - - if (global) - { - start = global_psymbols.list; - length = global_psymbols.next - start; - } - else - { - start = static_psymbols.list; - length = static_psymbols.next - start; - } - - if (!length) - return (struct partial_symbol *) 0; - - /* Binary search. This search is guarranteed to end with center - pointing at the earliest partial symbol with the correct - name. At that point *all* partial symbols with that name - will be checked against the correct namespace. */ - bottom = start; - top = start + length - 1; - while (top > bottom) - { - center = bottom + (top - bottom) / 2; - - assert (center < top); - - if (strcmp (SYMBOL_NAME (center), name) >= 0) - top = center; - else - bottom = center + 1; - } - assert (top == bottom); - - while (strcmp (SYMBOL_NAME (top), name) == 0) - { - if (!top->pst->readin && SYMBOL_NAMESPACE (top) == namespace) - return top; - top ++; - } - - return (struct partial_symbol *) 0; -} - -/* Look for a symbol in block BLOCK. */ - -static struct symbol * -lookup_block_symbol (block, name, namespace) - register struct block *block; - char *name; - enum namespace namespace; -{ - register int bot, top, inc; - register struct symbol *sym, *parameter_sym; - - top = BLOCK_NSYMS (block); - bot = 0; - - /* If the blocks's symbols were sorted, start with a binary search. */ - - if (BLOCK_SHOULD_SORT (block)) - { - /* First, advance BOT to not far before - the first symbol whose name is NAME. */ - - while (1) - { - inc = (top - bot + 1); - /* No need to keep binary searching for the last few bits worth. */ - if (inc < 4) - break; - inc = (inc >> 1) + bot; - sym = BLOCK_SYM (block, inc); - if (SYMBOL_NAME (sym)[0] < name[0]) - bot = inc; - else if (SYMBOL_NAME (sym)[0] > name[0]) - top = inc; - else if (strcmp (SYMBOL_NAME (sym), name) < 0) - bot = inc; - else - top = inc; - } - - /* Now scan forward until we run out of symbols, - find one whose name is greater than NAME, - or find one we want. - If there is more than one symbol with the right name and namespace, - we return the first one. dbxread.c is careful to make sure - that if one is a register then it comes first. */ - - top = BLOCK_NSYMS (block); - while (bot < top) - { - sym = BLOCK_SYM (block, bot); - inc = SYMBOL_NAME (sym)[0] - name[0]; - if (inc == 0) - inc = strcmp (SYMBOL_NAME (sym), name); - if (inc == 0 && SYMBOL_NAMESPACE (sym) == namespace) - return sym; - if (inc > 0) - return 0; - bot++; - } - return 0; - } - - /* Here if block isn't sorted. - This loop is equivalent to the loop above, - but hacked greatly for speed. - - Note that parameter symbols do not always show up last in the - list; this loop makes sure to take anything else other than - parameter symbols first; it only uses parameter symbols as a - last resort. Note that this only takes up extra computation - time on a match. */ - - parameter_sym = (struct symbol *) 0; - top = BLOCK_NSYMS (block); - inc = name[0]; - while (bot < top) - { - sym = BLOCK_SYM (block, bot); - if (SYMBOL_NAME (sym)[0] == inc - && !strcmp (SYMBOL_NAME (sym), name) - && SYMBOL_NAMESPACE (sym) == namespace) - { - if (SYMBOL_CLASS (sym) == LOC_ARG - || SYMBOL_CLASS (sym) == LOC_REF_ARG - || SYMBOL_CLASS (sym) == LOC_REGPARM) - parameter_sym = sym; - else - return sym; - } - bot++; - } - return parameter_sym; /* Will be 0 if not found. */ -} - -/* Return the symbol for the function which contains a specified - lexical block, described by a struct block BL. */ - -struct symbol * -block_function (bl) - struct block *bl; -{ - while (BLOCK_FUNCTION (bl) == 0 && BLOCK_SUPERBLOCK (bl) != 0) - bl = BLOCK_SUPERBLOCK (bl); - - return BLOCK_FUNCTION (bl); -} - -/* Subroutine of find_pc_line */ - -struct symtab * -find_pc_symtab (pc) - register CORE_ADDR pc; -{ - register struct block *b; - struct blockvector *bv; - register struct symtab *s; - register struct partial_symtab *ps; - - /* Search all symtabs for one whose file contains our pc */ - - for (s = symtab_list; s; s = s->next) - { - bv = BLOCKVECTOR (s); - b = BLOCKVECTOR_BLOCK (bv, 0); - if (BLOCK_START (b) <= pc - && BLOCK_END (b) > pc) - break; - } - - if (!s) - { - ps = find_pc_psymtab (pc); - if (ps && ps->readin) - fatal ("Internal error: pc in read in psymtab, but not in symtab."); - - if (ps) - s = psymtab_to_symtab (ps); - } - - return s; -} - -/* Find the source file and line number for a given PC value. - Return a structure containing a symtab pointer, a line number, - and a pc range for the entire source line. - The value's .pc field is NOT the specified pc. - NOTCURRENT nonzero means, if specified pc is on a line boundary, - use the line that ends there. Otherwise, in that case, the line - that begins there is used. */ - -struct symtab_and_line -find_pc_line (pc, notcurrent) - CORE_ADDR pc; - int notcurrent; -{ - struct symtab *s; - register struct linetable *l; - register int len; - register int i; - register struct linetable_entry *item; - struct symtab_and_line value; - struct blockvector *bv; - - /* Info on best line seen so far, and where it starts, and its file. */ - - int best_line = 0; - CORE_ADDR best_pc = 0; - CORE_ADDR best_end = 0; - struct symtab *best_symtab = 0; - - /* Store here the first line number - of a file which contains the line at the smallest pc after PC. - If we don't find a line whose range contains PC, - we will use a line one less than this, - with a range from the start of that file to the first line's pc. */ - int alt_line = 0; - CORE_ADDR alt_pc = 0; - struct symtab *alt_symtab = 0; - - /* Info on best line seen in this file. */ - - int prev_line; - CORE_ADDR prev_pc; - - /* Info on first line of this file. */ - - int first_line; - CORE_ADDR first_pc; - - /* If this pc is not from the current frame, - it is the address of the end of a call instruction. - Quite likely that is the start of the following statement. - But what we want is the statement containing the instruction. - Fudge the pc to make sure we get that. */ - - if (notcurrent) pc -= 1; - - s = find_pc_symtab (pc); - if (s == 0) - { - value.symtab = 0; - value.line = 0; - value.pc = pc; - value.end = 0; - return value; - } - - bv = BLOCKVECTOR (s); - - /* Look at all the symtabs that share this blockvector. - They all have the same apriori range, that we found was right; - but they have different line tables. */ - - for (; s && BLOCKVECTOR (s) == bv; s = s->next) - { - /* Find the best line in this symtab. */ - l = LINETABLE (s); - len = l->nitems; - prev_line = -1; - first_line = -1; - for (i = 0; i < len; i++) - { - item = &(l->item[i]); - - if (first_line < 0) - { - first_line = item->line; - first_pc = item->pc; - } - /* Return the last line that did not start after PC. */ - if (pc >= item->pc) - { - prev_line = item->line; - prev_pc = item->pc; - } - else - break; - } - - /* Is this file's best line closer than the best in the other files? - If so, record this file, and its best line, as best so far. */ - if (prev_line >= 0 && prev_pc > best_pc) - { - best_pc = prev_pc; - best_line = prev_line; - best_symtab = s; - if (i < len) - best_end = item->pc; - else - best_end = 0; - } - /* Is this file's first line closer than the first lines of other files? - If so, record this file, and its first line, as best alternate. */ - if (first_line >= 0 && first_pc > pc - && (alt_pc == 0 || first_pc < alt_pc)) - { - alt_pc = first_pc; - alt_line = first_line; - alt_symtab = s; - } - } - if (best_symtab == 0) - { - value.symtab = alt_symtab; - value.line = alt_line - 1; - value.pc = BLOCK_END (BLOCKVECTOR_BLOCK (bv, 0)); - value.end = alt_pc; - } - else - { - value.symtab = best_symtab; - value.line = best_line; - value.pc = best_pc; - value.end = (best_end ? best_end - : (alt_pc ? alt_pc - : BLOCK_END (BLOCKVECTOR_BLOCK (bv, 0)))); - } - return value; -} - -/* Find the PC value for a given source file and line number. - Returns zero for invalid line number. - The source file is specified with a struct symtab. */ - -CORE_ADDR -find_line_pc (symtab, line) - struct symtab *symtab; - int line; -{ - register struct linetable *l; - register int index; - int dummy; - - if (symtab == 0) - return 0; - l = LINETABLE (symtab); - index = find_line_common(l, line, &dummy); - return index ? l->item[index].pc : 0; -} - -/* Find the range of pc values in a line. - Store the starting pc of the line into *STARTPTR - and the ending pc (start of next line) into *ENDPTR. - Returns 1 to indicate success. - Returns 0 if could not find the specified line. */ - -int -find_line_pc_range (symtab, thisline, startptr, endptr) - struct symtab *symtab; - int thisline; - CORE_ADDR *startptr, *endptr; -{ - register struct linetable *l; - register int index; - int exact_match; /* did we get an exact linenumber match */ - register CORE_ADDR prev_pc; - CORE_ADDR last_pc; - - if (symtab == 0) - return 0; - - l = LINETABLE (symtab); - index = find_line_common (l, thisline, &exact_match); - if (index) - { - *startptr = l->item[index].pc; - /* If we have not seen an entry for the specified line, - assume that means the specified line has zero bytes. */ - if (!exact_match || index == l->nitems-1) - *endptr = *startptr; - else - /* Perhaps the following entry is for the following line. - It's worth a try. */ - if (l->item[index+1].line == thisline + 1) - *endptr = l->item[index+1].pc; - else - *endptr = find_line_pc (symtab, thisline+1); - return 1; - } - - return 0; -} - -/* Given a line table and a line number, return the index into the line - table for the pc of the nearest line whose number is >= the specified one. - Return 0 if none is found. The value is never zero is it is an index. - - Set *EXACT_MATCH nonzero if the value returned is an exact match. */ - -static int -find_line_common (l, lineno, exact_match) - register struct linetable *l; - register int lineno; - int *exact_match; -{ - register int i; - register int len; - - /* BEST is the smallest linenumber > LINENO so far seen, - or 0 if none has been seen so far. - BEST_INDEX identifies the item for it. */ - - int best_index = 0; - int best = 0; - - int nextline = -1; - - if (lineno <= 0) - return 0; - - len = l->nitems; - for (i = 0; i < len; i++) - { - register struct linetable_entry *item = &(l->item[i]); - - if (item->line == lineno) - { - *exact_match = 1; - return i; - } - - if (item->line > lineno && (best == 0 || item->line < best)) - { - best = item->line; - best_index = i; - } - } - - /* If we got here, we didn't get an exact match. */ - - *exact_match = 0; - return best_index; -} - -int -find_pc_line_pc_range (pc, startptr, endptr) - CORE_ADDR pc; - CORE_ADDR *startptr, *endptr; -{ - struct symtab_and_line sal; - sal = find_pc_line (pc, 0); - *startptr = sal.pc; - *endptr = sal.end; - return sal.symtab != 0; -} - -/* Parse a string that specifies a line number. - Pass the address of a char * variable; that variable will be - advanced over the characters actually parsed. - - The string can be: - - LINENUM -- that line number in current file. PC returned is 0. - FILE:LINENUM -- that line in that file. PC returned is 0. - FUNCTION -- line number of openbrace of that function. - PC returned is the start of the function. - FILE:FUNCTION -- likewise, but prefer functions in that file. - *EXPR -- line in which address EXPR appears. - - FUNCTION may be an undebuggable function found in misc_function_vector. - - If the argument FUNFIRSTLINE is nonzero, we want the first line - of real code inside a function when a function is specified. - - DEFAULT_SYMTAB specifies the file to use if none is specified. - It defaults to current_source_symtab. - DEFAULT_LINE specifies the line number to use for relative - line numbers (that start with signs). Defaults to current_source_line. - - Note that it is possible to return zero for the symtab - if no file is validly specified. Callers must check that. - Also, the line number returned may be invalid. */ - -struct symtabs_and_lines -decode_line_1 (argptr, funfirstline, default_symtab, default_line) - char **argptr; - int funfirstline; - struct symtab *default_symtab; - int default_line; -{ - struct symtabs_and_lines decode_line_2 (); - struct symtabs_and_lines values; - struct symtab_and_line value; - register char *p, *p1; - register struct symtab *s; - register struct symbol *sym; - register CORE_ADDR pc; - register int i; - char *copy; - struct symbol *sym_class; - char *class_name, *method_name, *phys_name; - int method_counter; - int i1; - struct symbol **sym_arr; - struct type *t, *field; - char **physnames; - - /* Defaults have defaults. */ - - if (default_symtab == 0) - { - default_symtab = current_source_symtab; - default_line = current_source_line; - } - - /* See if arg is *PC */ - - if (**argptr == '*') - { - (*argptr)++; - pc = parse_and_eval_address_1 (argptr); - values.sals = (struct symtab_and_line *) - malloc (sizeof (struct symtab_and_line)); - values.nelts = 1; - values.sals[0] = find_pc_line (pc, 0); - values.sals[0].pc = pc; - return values; - } - - /* Maybe arg is FILE : LINENUM or FILE : FUNCTION */ - - s = 0; - - for (p = *argptr; *p; p++) - { - if (p[0] == ':' || p[0] == ' ' || p[0] == '\t') - break; - } - while (p[0] == ' ' || p[0] == '\t') p++; - - if (p[0] == ':') - { - - /* C++ */ - if (p[1] ==':') - { - /* Extract the class name. */ - p1 = p; - while (p != *argptr && p[-1] == ' ') --p; - copy = (char *) alloca (p - *argptr + 1); - bcopy (*argptr, copy, p - *argptr); - copy[p - *argptr] = 0; - - /* Discard the class name from the arg. */ - p = p1 + 2; - while (*p == ' ' || *p == '\t') p++; - *argptr = p; - - sym_class = lookup_symbol (copy, 0, STRUCT_NAMESPACE, 0); - - if (sym_class && - (TYPE_CODE (SYMBOL_TYPE (sym_class)) == TYPE_CODE_STRUCT - || TYPE_CODE (SYMBOL_TYPE (sym_class)) == TYPE_CODE_UNION)) - { - /* Arg token is not digits => try it as a function name - Find the next token (everything up to end or next whitespace). */ - p = *argptr; - while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p !=':') p++; - copy = (char *) alloca (p - *argptr + 1); - bcopy (*argptr, copy, p - *argptr); - copy[p - *argptr] = '\0'; - - /* no line number may be specified */ - while (*p == ' ' || *p == '\t') p++; - *argptr = p; - - sym = 0; - i1 = 0; /* counter for the symbol array */ - t = SYMBOL_TYPE (sym_class); - sym_arr = (struct symbol **) alloca(TYPE_NFN_FIELDS_TOTAL (t) * sizeof(struct symbol*)); - physnames = (char **) alloca (TYPE_NFN_FIELDS_TOTAL (t) * sizeof(char*)); - - if (destructor_name_p (copy, t)) - { - /* destructors are a special case. */ - struct fn_field *f = TYPE_FN_FIELDLIST1 (t, 0); - int len = TYPE_FN_FIELDLIST_LENGTH (t, 0) - 1; - phys_name = TYPE_FN_FIELD_PHYSNAME (f, len); - physnames[i1] = (char *)alloca (strlen (phys_name) + 1); - strcpy (physnames[i1], phys_name); - sym_arr[i1] = lookup_symbol (phys_name, SYMBOL_BLOCK_VALUE (sym_class), VAR_NAMESPACE, 0); - if (sym_arr[i1]) i1++; - } - else while (t) - { - class_name = TYPE_NAME (t); - /* Ignore this class if it doesn't have a name. - This prevents core dumps, but is just a workaround - because we might not find the function in - certain cases, such as - struct D {virtual int f();} - struct C : D {virtual int g();} - (in this case g++ 1.35.1- does not put out a name - for D as such, it defines type 19 (for example) in - the same stab as C, and then does a - .stabs "D:T19" and a .stabs "D:t19". - Thus - "break C::f" should not be looking for field f in - the class named D, - but just for the field f in the baseclasses of C - (no matter what their names). - - However, I don't know how to replace the code below - that depends on knowing the name of D. */ - if (class_name) - { - /* We just want the class name. In the context - of C++, stripping off "struct " is always - sensible. */ - if (strncmp("struct ", class_name, 7) == 0) - class_name += 7; - if (strncmp("union ", class_name, 6) == 0) - class_name += 6; - - sym_class = lookup_symbol (class_name, 0, STRUCT_NAMESPACE, 0); - for (method_counter = TYPE_NFN_FIELDS (SYMBOL_TYPE (sym_class)) - 1; - method_counter >= 0; - --method_counter) - { - int field_counter; - struct fn_field *f = - TYPE_FN_FIELDLIST1 (SYMBOL_TYPE (sym_class), method_counter); - - method_name = TYPE_FN_FIELDLIST_NAME (SYMBOL_TYPE (sym_class), method_counter); - if (!strcmp (copy, method_name)) - /* Find all the fields with that name. */ - for (field_counter = TYPE_FN_FIELDLIST_LENGTH (SYMBOL_TYPE (sym_class), method_counter) - 1; - field_counter >= 0; - --field_counter) - { - phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter); - physnames[i1] = (char*) alloca (strlen (phys_name) + 1); - strcpy (physnames[i1], phys_name); - sym_arr[i1] = lookup_symbol (phys_name, SYMBOL_BLOCK_VALUE (sym_class), VAR_NAMESPACE, 0); - if (sym_arr[i1]) i1++; - } - } - } - if (TYPE_N_BASECLASSES (t)) - t = TYPE_BASECLASS(t, 1); - else - break; - } - - if (i1 == 1) - { - /* There is exactly one field with that name. */ - sym = sym_arr[0]; - - if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK) - { - /* Arg is the name of a function */ - pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) + FUNCTION_START_OFFSET; - if (funfirstline) - SKIP_PROLOGUE (pc); - values.sals = (struct symtab_and_line *)malloc (sizeof (struct symtab_and_line)); - values.nelts = 1; - values.sals[0] = find_pc_line (pc, 0); - values.sals[0].pc = (values.sals[0].end && values.sals[0].pc != pc) ? values.sals[0].end : pc; - } - else - { - values.nelts = 0; - } - return values; - } - if (i1 > 0) - { - /* There is more than one field with that name - (overloaded). Ask the user which one to use. */ - return decode_line_2 (argptr, sym_arr, physnames, - i1, funfirstline); - } - else - error ("that class does not have any method named %s",copy); - } - else - error("no class, struct, or union named %s", copy ); - } - /* end of C++ */ - - - /* Extract the file name. */ - p1 = p; - while (p != *argptr && p[-1] == ' ') --p; - copy = (char *) alloca (p - *argptr + 1); - bcopy (*argptr, copy, p - *argptr); - copy[p - *argptr] = 0; - - /* Find that file's data. */ - s = lookup_symtab (copy); - if (s == 0) - { - if (symtab_list == 0 && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"symbol-file\" command."); - error ("No source file named %s.", copy); - } - - /* Discard the file name from the arg. */ - p = p1 + 1; - while (*p == ' ' || *p == '\t') p++; - *argptr = p; - } - - /* S is specified file's symtab, or 0 if no file specified. - arg no longer contains the file name. */ - - /* Check whether arg is all digits (and sign) */ - - p = *argptr; - if (*p == '-' || *p == '+') p++; - while (*p >= '0' && *p <= '9') - p++; - - if (p != *argptr && (*p == 0 || *p == ' ' || *p == '\t' || *p == ',')) - { - /* We found a token consisting of all digits -- at least one digit. */ - enum sign {none, plus, minus} sign = none; - - /* This is where we need to make sure that we have good defaults. - We must guarrantee that this section of code is never executed - when we are called with just a function name, since - select_source_symtab calls us with such an argument */ - - if (s == 0 && default_symtab == 0) - { - if (symtab_list == 0 && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"symbol-file\" command."); - select_source_symtab (0); - default_symtab = current_source_symtab; - default_line = current_source_line; - } - - if (**argptr == '+') - sign = plus, (*argptr)++; - else if (**argptr == '-') - sign = minus, (*argptr)++; - value.line = atoi (*argptr); - switch (sign) - { - case plus: - if (p == *argptr) - value.line = 5; - if (s == 0) - value.line = default_line + value.line; - break; - case minus: - if (p == *argptr) - value.line = 15; - if (s == 0) - value.line = default_line - value.line; - else - value.line = 1; - break; - } - - while (*p == ' ' || *p == '\t') p++; - *argptr = p; - if (s == 0) - s = default_symtab; - value.symtab = s; - value.pc = 0; - values.sals = (struct symtab_and_line *)malloc (sizeof (struct symtab_and_line)); - values.sals[0] = value; - values.nelts = 1; - return values; - } - - /* Arg token is not digits => try it as a function name - Find the next token (everything up to end or next whitespace). */ - p = *argptr; - while (*p && *p != ' ' && *p != '\t' && *p != ',') p++; - copy = (char *) alloca (p - *argptr + 1); - bcopy (*argptr, copy, p - *argptr); - copy[p - *argptr] = 0; - while (*p == ' ' || *p == '\t') p++; - *argptr = p; - - /* Look up that token as a function. - If file specified, use that file's per-file block to start with. */ - - if (s == 0) - /* use current file as default if none is specified. */ - s = default_symtab; - - sym = lookup_symbol (copy, s ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), 1) : 0, - VAR_NAMESPACE, 0); - - if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK) - { - /* Arg is the name of a function */ - pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) + FUNCTION_START_OFFSET; - if (funfirstline) - SKIP_PROLOGUE (pc); - value = find_pc_line (pc, 0); -#ifdef PROLOGUE_FIRSTLINE_OVERLAP - /* Convex: no need to suppress code on first line, if any */ - value.pc = pc; -#else - value.pc = (value.end && value.pc != pc) ? value.end : pc; -#endif - values.sals = (struct symtab_and_line *)malloc (sizeof (struct symtab_and_line)); - values.sals[0] = value; - values.nelts = 1; - return values; - } - - if (sym) - error ("%s is not a function.", copy); - - if (symtab_list == 0 && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"symbol-file\" command."); - - if ((i = lookup_misc_func (copy)) >= 0) - { - value.symtab = 0; - value.line = 0; - value.pc = misc_function_vector[i].address + FUNCTION_START_OFFSET; - if (funfirstline) - SKIP_PROLOGUE (value.pc); - values.sals = (struct symtab_and_line *)malloc (sizeof (struct symtab_and_line)); - values.sals[0] = value; - values.nelts = 1; - return values; - } - - error ("Function %s not defined.", copy); -} - -struct symtabs_and_lines -decode_line_spec (string, funfirstline) - char *string; - int funfirstline; -{ - struct symtabs_and_lines sals; - if (string == 0) - error ("Empty line specification."); - sals = decode_line_1 (&string, funfirstline, - current_source_symtab, current_source_line); - if (*string) - error ("Junk at end of line specification: %s", string); - return sals; -} - -/* Given a list of NELTS symbols in sym_arr (with corresponding - mangled names in physnames), return a list of lines to operate on - (ask user if necessary). */ -struct symtabs_and_lines -decode_line_2 (argptr, sym_arr, physnames, nelts, funfirstline) - char **argptr; - struct symbol *sym_arr[]; - char *physnames[]; - int nelts; - int funfirstline; -{ - char *getenv(); - struct symtabs_and_lines values, return_values; - register CORE_ADDR pc; - char *args, *arg1, *command_line_input (); - int i; - char *prompt; - - values.sals = (struct symtab_and_line *) alloca (nelts * sizeof(struct symtab_and_line)); - return_values.sals = (struct symtab_and_line *) malloc (nelts * sizeof(struct symtab_and_line)); - - i = 0; - printf("[0] cancel\n[1] all\n"); - while (i < nelts) - { - if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK) - { - /* Arg is the name of a function */ - pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym_arr[i])) - + FUNCTION_START_OFFSET; - if (funfirstline) - SKIP_PROLOGUE (pc); - values.sals[i] = find_pc_line (pc, 0); - values.sals[i].pc = (values.sals[i].end && values.sals[i].pc != pc) ? values.sals[i].end : pc; - printf("[%d] file:%s; line number:%d\n", - (i+2), values.sals[i].symtab->filename, values.sals[i].line); - } - else printf ("?HERE\n"); - i++; - } - - if ((prompt = getenv ("PS2")) == NULL) - { - prompt = ">"; - } - printf("%s ",prompt); - fflush(stdout); - - args = command_line_input (0, 0); - - if (args == 0) - error_no_arg ("one or more choice numbers"); - - i = 0; - while (*args) - { - int num; - - arg1 = args; - while (*arg1 >= '0' && *arg1 <= '9') arg1++; - if (*arg1 && *arg1 != ' ' && *arg1 != '\t') - error ("Arguments must be choice numbers."); - - num = atoi (args); - - if (num == 0) - error ("cancelled"); - else if (num == 1) - { - bcopy (values.sals, return_values.sals, (nelts * sizeof(struct symtab_and_line))); - return_values.nelts = nelts; - return return_values; - } - - if (num > nelts + 2) - { - printf ("No choice number %d.\n", num); - } - else - { - num -= 2; - if (values.sals[num].pc) - { - return_values.sals[i++] = values.sals[num]; - values.sals[num].pc = 0; - } - else - { - printf ("duplicate request for %d ignored.\n", num); - } - } - - args = arg1; - while (*args == ' ' || *args == '\t') args++; - } - return_values.nelts = i; - return return_values; -} - -/* hash a symbol ("hashpjw" from Aho, Sethi & Ullman, p.436) */ - -int -hash_symbol(str) - register char *str; -{ - register unsigned int h = 0, g; - register unsigned char c; - - while (c = *(unsigned char *)str++) { - h = (h << 4) + c; - if (g = h & 0xf0000000) { - h = h ^ (g >> 24); - h = h ^ g; - } - } - return ((int)h); -} - -/* Return the index of misc function named NAME. */ - -int -lookup_misc_func (name) - register char *name; -{ - register int i = hash_symbol(name) & (MISC_FUNC_HASH_SIZE - 1); - - if (misc_function_vector == 0) - error("No symbol file"); - - i = misc_function_hash_tab[i]; - while (i >= 0) - { - if (strcmp(misc_function_vector[i].name, name) == 0) - break; - i = misc_function_vector[i].next; - } - return (i); -} - -/* - * Slave routine for sources_info. Force line breaks at ,'s. - */ -static void -output_source_filename (name, next) -char *name; -int next; -{ - static int column = 0; - - if (column != 0 && column + strlen (name) >= 70) - { - printf_filtered ("\n"); - column = 0; - } - else if (column != 0) - { - printf_filtered (" "); - column++; - } - printf_filtered ("%s", name); - column += strlen (name); - if (next) - { - printf_filtered (","); - column++; - } - - if (!next) column = 0; -} - -static void -sources_info () -{ - register struct symtab *s; - register struct partial_symtab *ps; - register int column = 0; - - if (symtab_list == 0 && partial_symtab_list == 0) - { - printf ("No symbol table is loaded.\n"); - return; - } - - printf_filtered ("Source files for which symbols have been read in:\n\n"); - - for (s = symtab_list; s; s = s->next) - output_source_filename (s->filename, s->next); - printf_filtered ("\n\n"); - - printf_filtered ("Source files for which symbols will be read in on demand:\n\n"); - - for (ps = partial_symtab_list; ps; ps = ps->next) - if (!ps->readin) - output_source_filename (ps->filename, ps->next); - printf_filtered ("\n"); -} - -/* List all symbols (if REGEXP is 0) or all symbols matching REGEXP. - If CLASS is zero, list all symbols except functions and type names. - If CLASS is 1, list only functions. - If CLASS is 2, list only type names. */ - -static void sort_block_syms (); - -static void -list_symbols (regexp, class) - char *regexp; - int class; -{ - register struct symtab *s; - register struct partial_symtab *ps; - register struct blockvector *bv; - struct blockvector *prev_bv = 0; - register struct block *b; - register int i, j; - register struct symbol *sym; - struct partial_symbol *psym, *bound; - char *val; - static char *classnames[] - = {"variable", "function", "type", "method"}; - int print_count = 0; - int found_in_file = 0; - - if (regexp) - if (val = (char *) re_comp (regexp)) - error ("Invalid regexp: %s", val); - - /* Search through the partial_symtab_list *first* for all symbols - matching the regexp. That way we don't have to reproduce all of - the machinery below. */ - for (psym = global_psymbols.list, bound = global_psymbols.next; ; - psym = static_psymbols.list, bound = static_psymbols.next) - { - for (; psym < bound; ++psym) - { - if (psym->pst->readin) - continue; - - QUIT; - /* If it would match (logic taken from loop below) - load the file and go on to the next one */ - if ((regexp == 0 || re_exec (SYMBOL_NAME (psym))) - && ((class == 0 && SYMBOL_CLASS (psym) != LOC_TYPEDEF - && SYMBOL_CLASS (psym) != LOC_BLOCK) - || (class == 1 && SYMBOL_CLASS (psym) == LOC_BLOCK) - || (class == 2 && SYMBOL_CLASS (psym) == LOC_TYPEDEF) - || (class == 3 && SYMBOL_CLASS (psym) == LOC_BLOCK))) - psymtab_to_symtab(psym->pst); - } - if (psym == static_psymbols.next) - break; - } - - /* Printout here so as to get after the "Reading in symbols" - messages which will be generated above. */ - printf_filtered (regexp - ? "All %ss matching regular expression \"%s\":\n" - : "All defined %ss:\n", - classnames[class], - regexp); - - /* Here, *if* the class is correct (function only, right now), we - should search through the misc function vector for symbols that - match and call find_pc_psymtab on them. If find_pc_psymtab returns - 0, don't worry about it (already read in or no debugging info). */ - - if (class == 1) - { - for (i = 0; i < misc_function_count; i++) - if (regexp == 0 || re_exec (misc_function_vector[i].name)) - { - ps = find_pc_psymtab (misc_function_vector[i].address); - if (ps && !ps->readin) - psymtab_to_symtab (ps); - } - } - - for (s = symtab_list; s; s = s->next) - { - found_in_file = 0; - bv = BLOCKVECTOR (s); - /* Often many files share a blockvector. - Scan each blockvector only once so that - we don't get every symbol many times. - It happens that the first symtab in the list - for any given blockvector is the main file. */ - if (bv != prev_bv) - for (i = 0; i < 2; i++) - { - b = BLOCKVECTOR_BLOCK (bv, i); - /* Skip the sort if this block is always sorted. */ - if (!BLOCK_SHOULD_SORT (b)) - sort_block_syms (b); - for (j = 0; j < BLOCK_NSYMS (b); j++) - { - QUIT; - sym = BLOCK_SYM (b, j); - if ((regexp == 0 || re_exec (SYMBOL_NAME (sym))) - && ((class == 0 && SYMBOL_CLASS (sym) != LOC_TYPEDEF - && SYMBOL_CLASS (sym) != LOC_BLOCK) - || (class == 1 && SYMBOL_CLASS (sym) == LOC_BLOCK) - || (class == 2 && SYMBOL_CLASS (sym) == LOC_TYPEDEF) - || (class == 3 && SYMBOL_CLASS (sym) == LOC_BLOCK))) - { - if (!found_in_file) - { - printf_filtered ("\nFile %s:\n", s->filename); - print_count += 2; - } - found_in_file = 1; - if (class != 2 && i == 1) - printf_filtered ("static "); - if (class == 2 - && SYMBOL_NAMESPACE (sym) != STRUCT_NAMESPACE) - printf_filtered ("typedef "); - - if (class < 3) - { - type_print (SYMBOL_TYPE (sym), - (SYMBOL_CLASS (sym) == LOC_TYPEDEF - ? "" : SYMBOL_NAME (sym)), - stdout, 0); - - if (class == 2 - && SYMBOL_NAMESPACE (sym) != STRUCT_NAMESPACE - && (TYPE_NAME ((SYMBOL_TYPE (sym))) == 0 - || 0 != strcmp (TYPE_NAME ((SYMBOL_TYPE (sym))), - SYMBOL_NAME (sym)))) - printf_filtered (" %s", SYMBOL_NAME (sym)); - - printf_filtered (";\n"); - } - else - { -# if 0 - char buf[1024]; - type_print_base (TYPE_FN_FIELD_TYPE(t, i), stdout, 0, 0); - type_print_varspec_prefix (TYPE_FN_FIELD_TYPE(t, i), stdout, 0); - sprintf (buf, " %s::", TYPE_NAME (t)); - type_print_method_args (TYPE_FN_FIELD_ARGS (t, i), buf, name, stdout); -# endif - } - } - } - } - prev_bv = bv; - } -} - -static void -variables_info (regexp) - char *regexp; -{ - list_symbols (regexp, 0); -} - -static void -functions_info (regexp) - char *regexp; -{ - list_symbols (regexp, 1); -} - -static void -types_info (regexp) - char *regexp; -{ - list_symbols (regexp, 2); -} - -#if 0 -/* Tiemann says: "info methods was never implemented." */ -static void -methods_info (regexp) - char *regexp; -{ - list_symbols (regexp, 3); -} -#endif /* 0 */ - -/* Call sort_block_syms to sort alphabetically the symbols of one block. */ - -static int -compare_symbols (s1, s2) - struct symbol **s1, **s2; -{ - /* Names that are less should come first. */ - register int namediff = strcmp (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2)); - if (namediff != 0) return namediff; - /* For symbols of the same name, registers should come first. */ - return ((SYMBOL_CLASS (*s2) == LOC_REGISTER) - - (SYMBOL_CLASS (*s1) == LOC_REGISTER)); -} - -static void -sort_block_syms (b) - register struct block *b; -{ - qsort (&BLOCK_SYM (b, 0), BLOCK_NSYMS (b), - sizeof (struct symbol *), compare_symbols); -} - -/* Initialize the standard C scalar types. */ - -static -struct type * -init_type (code, length, uns, name) - enum type_code code; - int length, uns; - char *name; -{ - register struct type *type; - - type = (struct type *) xmalloc (sizeof (struct type)); - bzero (type, sizeof *type); - TYPE_MAIN_VARIANT (type) = type; - TYPE_CODE (type) = code; - TYPE_LENGTH (type) = length; - TYPE_FLAGS (type) = uns ? TYPE_FLAG_UNSIGNED : 0; - TYPE_FLAGS (type) |= TYPE_FLAG_PERM; - TYPE_NFIELDS (type) = 0; - TYPE_NAME (type) = name; - - /* C++ fancies. */ - TYPE_NFN_FIELDS (type) = 0; - TYPE_N_BASECLASSES (type) = 0; - TYPE_BASECLASSES (type) = 0; - return type; -} - -/* Return Nonzero if block a is lexically nested within block b, - or if a and b have the same pc range. - Return zero otherwise. */ -int -contained_in (a, b) - struct block *a, *b; -{ - if (!a || !b) - return 0; - return a->startaddr >= b->startaddr && a->endaddr <= b->endaddr; -} - - -/* Helper routine for make_symbol_completion_list. */ - -int return_val_size, return_val_index; -char **return_val; - -void -completion_list_add_symbol (symname) - char *symname; -{ - if (return_val_index + 3 > return_val_size) - return_val = - (char **)xrealloc (return_val, - (return_val_size *= 2) * sizeof (char *)); - - return_val[return_val_index] = - (char *)xmalloc (1 + strlen (symname)); - - strcpy (return_val[return_val_index], symname); - - return_val[++return_val_index] = (char *)NULL; -} - -/* Return a NULL terminated array of all symbols (regardless of class) which - begin by matching TEXT. If the answer is no symbols, then the return value - is an array which contains only a NULL pointer. - - Problem: All of the symbols have to be copied because readline - frees them. I'm not going to worry about this; hopefully there - won't be that many. */ - -char ** -make_symbol_completion_list (text) - char *text; -{ - register struct symtab *s; - register struct partial_symtab *ps; - register struct blockvector *bv; - struct blockvector *prev_bv = 0; - register struct block *b, *surrounding_static_block; - extern struct block *get_selected_block (); - register int i, j; - register struct symbol *sym; - struct partial_symbol *psym; - - int text_len = strlen (text); - return_val_size = 100; - return_val_index = 0; - return_val = - (char **)xmalloc ((1 + return_val_size) *sizeof (char *)); - return_val[0] = (char *)NULL; - - /* Look through the partial symtabs for all symbols which begin - by matching TEXT. Add each one that you find to the list. */ - - for (ps = partial_symtab_list; ps; ps = ps->next) - { - /* If the psymtab's been read in we'll get it when we search - through the blockvector. */ - if (ps->readin) continue; - - for (psym = global_psymbols.list + ps->globals_offset; - psym < (global_psymbols.list + ps->globals_offset - + ps->n_global_syms); - psym++) - { - QUIT; /* If interrupted, then quit. */ - if ((strncmp (SYMBOL_NAME (psym), text, text_len) == 0)) - completion_list_add_symbol (SYMBOL_NAME (psym)); - } - - for (psym = static_psymbols.list + ps->statics_offset; - psym < (static_psymbols.list + ps->statics_offset - + ps->n_static_syms); - psym++) - { - QUIT; - if ((strncmp (SYMBOL_NAME (psym), text, text_len) == 0)) - completion_list_add_symbol (SYMBOL_NAME (psym)); - } - } - - /* At this point scan through the misc function vector and add each - symbol you find to the list. Eventually we want to ignore - anything that isn't a text symbol (everything else will be - handled by the psymtab code above). */ - - for (i = 0; i < misc_function_count; i++) - if (!strncmp (text, misc_function_vector[i].name, text_len)) - completion_list_add_symbol (misc_function_vector[i].name); - - /* Search upwards from currently selected frame (so that we can - complete on local vars. */ - for (b = get_selected_block (); b; b = BLOCK_SUPERBLOCK (b)) - { - if (!BLOCK_SUPERBLOCK (b)) - surrounding_static_block = b; /* For elmin of dups */ - - /* Also catch fields of types defined in this places which - match our text string. Only complete on types visible - from current context. */ - for (i = 0; i < BLOCK_NSYMS (b); i++) - { - register struct symbol *sym = BLOCK_SYM (b, i); - - if (!strncmp (SYMBOL_NAME (sym), text, text_len)) - completion_list_add_symbol (SYMBOL_NAME (sym)); - - if (SYMBOL_CLASS (sym) == LOC_TYPEDEF) - { - struct type *t = SYMBOL_TYPE (sym); - enum type_code c = TYPE_CODE (t); - - if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT) - for (j = 0; j < TYPE_NFIELDS (t); j++) - if (TYPE_FIELD_NAME (t, j) && - !strncmp (TYPE_FIELD_NAME (t, j), text, text_len)) - completion_list_add_symbol (TYPE_FIELD_NAME (t, j)); - } - } - } - - /* Go through the symtabs and check the externs and statics for - symbols which match. */ - - for (s = symtab_list; s; s = s->next) - { - struct block *b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), 0); - - for (i = 0; i < BLOCK_NSYMS (b); i++) - if (!strncmp (SYMBOL_NAME (BLOCK_SYM (b, i)), text, text_len)) - completion_list_add_symbol (SYMBOL_NAME (BLOCK_SYM (b, i))); - } - - for (s = symtab_list; s; s = s->next) - { - struct block *b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), 1); - - /* Don't do this block twice. */ - if (b == surrounding_static_block) continue; - - for (i = 0; i < BLOCK_NSYMS (b); i++) - if (!strncmp (SYMBOL_NAME (BLOCK_SYM (b, i)), text, text_len)) - completion_list_add_symbol (SYMBOL_NAME (BLOCK_SYM (b, i))); - } - - return (return_val); -} - -void -_initialize_symtab () -{ - add_info ("variables", variables_info, - "All global and static variable names, or those matching REGEXP."); - add_info ("functions", functions_info, - "All function names, or those matching REGEXP."); - add_info ("types", types_info, - "All types names, or those matching REGEXP."); -#if 0 - add_info ("methods", methods_info, - "All method names, or those matching REGEXP::REGEXP.\n\ -If the class qualifier is ommited, it is assumed to be the current scope.\n\ -If the first REGEXP is ommited, then all methods matching the second REGEXP\n\ -are listed."); -#endif - add_info ("sources", sources_info, - "Source files in the program."); - - obstack_init (symbol_obstack); - obstack_init (psymbol_obstack); - - builtin_type_void = init_type (TYPE_CODE_VOID, 1, 0, "void"); - - builtin_type_float = init_type (TYPE_CODE_FLT, sizeof (float), 0, "float"); - builtin_type_double = init_type (TYPE_CODE_FLT, sizeof (double), 0, "double"); - - builtin_type_char = init_type (TYPE_CODE_INT, sizeof (char), 0, "char"); - builtin_type_short = init_type (TYPE_CODE_INT, sizeof (short), 0, "short"); - builtin_type_long = init_type (TYPE_CODE_INT, sizeof (long), 0, "long"); - builtin_type_int = init_type (TYPE_CODE_INT, sizeof (int), 0, "int"); - - builtin_type_unsigned_char = init_type (TYPE_CODE_INT, sizeof (char), 1, "unsigned char"); - builtin_type_unsigned_short = init_type (TYPE_CODE_INT, sizeof (short), 1, "unsigned short"); - builtin_type_unsigned_long = init_type (TYPE_CODE_INT, sizeof (long), 1, "unsigned long"); - builtin_type_unsigned_int = init_type (TYPE_CODE_INT, sizeof (int), 1, "unsigned int"); -#ifdef LONG_LONG - builtin_type_long_long = - init_type (TYPE_CODE_INT, sizeof (long long), 0, "long long"); - builtin_type_unsigned_long_long = - init_type (TYPE_CODE_INT, sizeof (long long), 1, "unsigned long long"); -#endif -} - diff --git a/gnu/usr.bin/gdb/symtab.h b/gnu/usr.bin/gdb/symtab.h deleted file mode 100644 index ae3754df5ee1..000000000000 --- a/gnu/usr.bin/gdb/symtab.h +++ /dev/null @@ -1,385 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - * - * from: @(#)symtab.h 6.3 (Berkeley) 5/8/91 - * $Id: symtab.h,v 1.2 1993/08/01 18:47:51 mycroft Exp $ - */ - -/* Symbol table definitions for GDB. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -/* An obstack to hold objects that should be freed - when we load a new symbol table. - This includes the symbols made by dbxread - and the types that are not permanent. */ - -extern struct obstack *symbol_obstack; -extern struct obstack *psymbol_obstack; - -/* Some definitions and declarations to go with use of obstacks. */ -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free -extern char *xmalloc (); -extern void free (); - -/* gdb can know one or several symbol tables at the same time; - the ultimate intent is to have one for each separately-compiled module. - Each such symbol table is recorded by a struct symtab, and they - are all chained together. */ - -/* In addition, gdb can record any number of miscellaneous undebuggable - functions' addresses. In a system that appends _ to function names, - the _'s are removed from the names stored in this table. */ - -/* Actually, the misc function list is used to store *all* of the - global symbols (text, data, bss, and abs). It is sometimes used - to figure out what symtabs to read in. The "type" field appears - never to be used. */ - -enum misc_function_type {mf_unknown = 0, mf_text, mf_data, mf_bss, mf_abs}; - -struct misc_function -{ - char *name; - CORE_ADDR address; - int next; /* index of next in this hash bucket */ - unsigned char type; /* Really enum misc_function_type. */ -}; - -/* Address and length of the vector recording all misc function names/addresses. */ - -struct misc_function *misc_function_vector; -int misc_function_count; -#define MISC_FUNC_HASH_SIZE (2048) -int misc_function_hash_tab[MISC_FUNC_HASH_SIZE]; - -#include "symseg.h" - -/* Each source file is represented by a struct symtab. */ -/* These objects are chained through the `next' field. */ - -struct symtab - { - /* Chain of all existing symtabs. */ - struct symtab *next; - /* List of all symbol scope blocks for this symtab. */ - struct blockvector *blockvector; - /* Table mapping core addresses to line numbers for this file. */ - struct linetable *linetable; - /* Vector containing all types defined for this symtab. */ - struct typevector *typevector; - /* Name of this source file. */ - char *filename; - /* This component says how to free the data we point to: - free_contents => do a tree walk and free each object. - free_nothing => do nothing; some other symtab will free - the data this one uses. - free_linetable => free just the linetable. */ - enum free_code {free_nothing, free_contents, free_linetable} - free_code; - /* Pointer to one block of storage to be freed, if nonzero. */ - char *free_ptr; - /* Total number of lines found in source file. */ - int nlines; - /* Array mapping line number to character position. */ - int *line_charpos; - /* Language of this source file. */ - enum language language; - /* String of version information. May be zero. */ - char *version; - /* String of compilation information. May be zero. */ - char *compilation; - /* Offset within loader symbol table - of first local symbol for this file. */ - int ldsymoff; - /* Full name of file as found by searching the source path. - 0 if not yet known. */ - char *fullname; - }; - -/* - * Each source file that has not been fully read in is represented by - * a partial_symtab. This contains the information on where in the - * executable the debugging symbols for a specific file are, and a - * list of names of global symbols which are located in this file. - */ -struct partial_symtab -{ - /* Chain of all existing partial symtabs. */ - struct partial_symtab *next; - /* Name of the source file which this partial_symtab defines */ - char *filename; - /* Offset within loader symbol table of first local symbol for this - file and length (in bytes) of the section of the symbol table - devoted to this file's symbols (actually, the section bracketed - may contain more than just this files symbols - If ldsymlen is 0, the only reason for this things existence is - the dependency list below. Nothing else will happen when it is - read in. */ - int ldsymoff, ldsymlen; - /* Range of text addresses covered by this file; texthigh is the - beginning of the next section. */ - int textlow, texthigh; - /* Non-zero if the symtab corresponding to this psymtab has been - readin */ - unsigned char readin; - /* Array of pointers to all of the partial_symtab s which this one - depends one. Since this array can only be set to previous or - the current (?) psymtab, this dependency tree is guarranteed not - to have any loops. */ - struct partial_symtab **dependencies; - int number_of_dependencies; - /* Global symbol list. This list will be sorted after readin to - improve access. Binary search will be the usual method of - finding a symbol within it. globals_offset is an integer offset - within ps_globals */ - int globals_offset, n_global_syms; - /* Static symbol list. This list will *not* be sorted after readin; - to find a symbol in it, exhaustive search must be used. This is - reasonable because searches through this list will eventually - lead to either the read in of a files symbols for real (assumed - to take a *lot* of time; check) or an error (and we don't care - how long errors take). */ - int statics_offset, n_static_syms; -}; - -/* This is the list of struct symtab's that gdb considers current. */ - -struct symtab *symtab_list; - -/* This is the list of struct partial_symtab's that gdb may need to access */ - -struct partial_symtab *partial_symtab_list; - -/* This symtab variable specifies the current file for printing source lines */ - -struct symtab *current_source_symtab; - -/* This is the next line to print for listing source lines. */ - -int current_source_line; - -#define BLOCKLIST(symtab) (symtab)->blockvector -#define BLOCKVECTOR(symtab) (symtab)->blockvector - -#define TYPEVECTOR(symtab) (symtab)->typevector - -#define LINELIST(symtab) (symtab)->linetable -#define LINETABLE(symtab) (symtab)->linetable - -/* Macros normally used to access components of symbol table structures. */ - -#define BLOCKLIST_NBLOCKS(blocklist) (blocklist)->nblocks -#define BLOCKLIST_BLOCK(blocklist,n) (blocklist)->block[n] -#define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks -#define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n] - -#define TYPEVECTOR_NTYPES(typelist) (typelist)->length -#define TYPEVECTOR_TYPE(typelist,n) (typelist)->type[n] - -#define BLOCK_START(bl) (bl)->startaddr -#define BLOCK_END(bl) (bl)->endaddr -#define BLOCK_NSYMS(bl) (bl)->nsyms -#define BLOCK_SYM(bl, n) (bl)->sym[n] -#define BLOCK_FUNCTION(bl) (bl)->function -#define BLOCK_SUPERBLOCK(bl) (bl)->superblock -#define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag - -/* Nonzero if symbols of block BL should be sorted alphabetically. */ -#define BLOCK_SHOULD_SORT(bl) ((bl)->nsyms >= 40) - -#define SYMBOL_NAME(symbol) (symbol)->name -#define SYMBOL_NAMESPACE(symbol) (symbol)->namespace -#define SYMBOL_CLASS(symbol) (symbol)->class -#define SYMBOL_VALUE(symbol) (symbol)->value.value -#define SYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes -#define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block -#define SYMBOL_TYPE(symbol) (symbol)->type - -/* Some macros for bitfields. */ -#define B_SET(a,x) (a[x>>5] |= (1 << (x&31))) -#define B_CLR(a,x) (a[x>>5] &= ~(1 << (x&31))) -#define B_TST(a,x) (a[x>>5] & (1 << (x&31))) - -#define TYPE_NAME(thistype) (thistype)->name -#define TYPE_TARGET_TYPE(thistype) (thistype)->target_type -#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type -#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type -#define TYPE_FUNCTION_TYPE(thistype) (thistype)->function_type -#define TYPE_MAIN_VARIANT(thistype) (thistype)->main_variant -#define TYPE_NEXT_VARIANT(thistype) (thistype)->next_variant -#define TYPE_LENGTH(thistype) (thistype)->length -#define TYPE_FLAGS(thistype) (thistype)->flags -#define TYPE_UNSIGNED(thistype) ((thistype)->flags & TYPE_FLAG_UNSIGNED) -#define TYPE_CODE(thistype) (thistype)->code -#define TYPE_NFIELDS(thistype) (thistype)->nfields -#define TYPE_FIELDS(thistype) (thistype)->fields -/* C++ */ -#define TYPE_VPTR_BASETYPE(thistype) (thistype)->vptr_basetype -#define TYPE_DOMAIN_TYPE(thistype) (thistype)->vptr_basetype -#define TYPE_VPTR_FIELDNO(thistype) (thistype)->vptr_fieldno -#define TYPE_FN_FIELDS(thistype) (thistype)->fn_fields -#define TYPE_NFN_FIELDS(thistype) (thistype)->nfn_fields -#define TYPE_NFN_FIELDS_TOTAL(thistype) (thistype)->nfn_fields_total -#define TYPE_BASECLASSES(thistype) (thistype)->baseclasses -#define TYPE_ARG_TYPES(thistype) (thistype)->arg_types -#define TYPE_BASECLASS(thistype,index) (thistype)->baseclasses[index] -#define TYPE_N_BASECLASSES(thistype) (thistype)->n_baseclasses -#define TYPE_VIA_PUBLIC(thistype) ((thistype)->flags & TYPE_FLAG_VIA_PUBLIC) -#define TYPE_VIA_VIRTUAL(thistype) ((thistype)->flags & TYPE_FLAG_VIA_VIRTUAL) - -#define TYPE_FIELD(thistype, n) (thistype)->fields[n] -#define TYPE_FIELD_TYPE(thistype, n) (thistype)->fields[n].type -#define TYPE_FIELD_NAME(thistype, n) (thistype)->fields[n].name -#define TYPE_FIELD_VALUE(thistype, n) (* (int*) &(thistype)->fields[n].type) -#define TYPE_FIELD_BITPOS(thistype, n) (thistype)->fields[n].bitpos -#define TYPE_FIELD_BITSIZE(thistype, n) (thistype)->fields[n].bitsize -#define TYPE_FIELD_PACKED(thistype, n) (thistype)->fields[n].bitsize - -#define TYPE_FIELD_PRIVATE_BITS(thistype) (thistype)->private_field_bits -#define TYPE_FIELD_PROTECTED_BITS(thistype) (thistype)->protected_field_bits -#define SET_TYPE_FIELD_PRIVATE(thistype, n) B_SET ((thistype)->private_field_bits, (n)) -#define SET_TYPE_FIELD_PROTECTED(thistype, n) B_SET ((thistype)->protected_field_bits, (n)) -#define TYPE_FIELD_PRIVATE(thistype, n) B_TST((thistype)->private_field_bits, (n)) -#define TYPE_FIELD_PROTECTED(thistype, n) B_TST((thistype)->protected_field_bits, (n)) - -#define TYPE_HAS_DESTRUCTOR(thistype) ((thistype)->flags & TYPE_FLAG_HAS_DESTRUCTOR) -#define TYPE_HAS_CONSTRUCTOR(thistype) ((thistype)->flags & TYPE_FLAG_HAS_CONSTRUCTOR) - -#define TYPE_FIELD_STATIC(thistype, n) ((thistype)->fields[n].bitpos == -1) -#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((char *)(thistype)->fields[n].bitsize) - -#define TYPE_FN_FIELDLISTS(thistype) (thistype)->fn_fieldlists -#define TYPE_FN_FIELDLIST(thistype, n) (thistype)->fn_fieldlists[n] -#define TYPE_FN_FIELDLIST1(thistype, n) (thistype)->fn_fieldlists[n].fn_fields -#define TYPE_FN_FIELDLIST_NAME(thistype, n) (thistype)->fn_fieldlists[n].name -#define TYPE_FN_FIELDLIST_LENGTH(thistype, n) (thistype)->fn_fieldlists[n].length - -#define TYPE_FN_FIELD(thistype, n) (thistype)[n] -#define TYPE_FN_FIELD_NAME(thistype, n) (thistype)[n].name -#define TYPE_FN_FIELD_TYPE(thistype, n) (thistype)[n].type -#define TYPE_FN_FIELD_ARGS(thistype, n) (thistype)[n].args -#define TYPE_FN_FIELD_PHYSNAME(thistype, n) (thistype)[n].physname -#define TYPE_FN_FIELD_VIRTUAL_P(thistype, n) ((thistype)[n].voffset < 0) -#define TYPE_FN_FIELD_STATIC_P(thistype, n) ((thistype)[n].voffset > 0) -#define TYPE_FN_FIELD_VOFFSET(thistype, n) ((thistype)[n].voffset-1) - -#define TYPE_FN_PRIVATE_BITS(thistype) (thistype).private_fn_field_bits -#define TYPE_FN_PROTECTED_BITS(thistype) (thistype).protected_fn_field_bits -#define SET_TYPE_FN_PRIVATE(thistype, n) B_SET ((thistype).private_fn_field_bits, n) -#define SET_TYPE_FN_PROTECTED(thistype, n) B_SET ((thistype).protected_fn_field_bits, n) -#define TYPE_FN_PRIVATE(thistype, n) B_TST ((thistype).private_fn_field_bits, n) -#define TYPE_FN_PROTECTED(thistype, n) B_TST ((thistype).protected_fn_field_bits, n) - -/* Functions that work on the objects described above */ - -extern struct symtab *lookup_symtab (); -extern struct symbol *lookup_symbol (); -extern struct type *lookup_typename (); -extern struct type *lookup_unsigned_typename (); -extern struct type *lookup_struct (); -extern struct type *lookup_union (); -extern struct type *lookup_enum (); -extern struct type *lookup_struct_elt_type (); -extern struct type *lookup_pointer_type (); -extern struct type *lookup_function_type (); -extern struct type *lookup_basetype_type (); -extern struct type *create_array_type (); -extern struct symbol *block_function (); -extern struct symbol *find_pc_function (); -extern int find_pc_partial_function (); -extern struct partial_symtab *find_pc_psymtab (); -extern struct symtab *find_pc_symtab (); -extern struct partial_symbol *find_pc_psymbol (); -extern int find_pc_misc_function (); - -/* C++ stuff. */ -extern struct type *lookup_reference_type (); -extern struct type *lookup_member_type (); -extern struct type *lookup_class (); -/* end of C++ stuff. */ - -extern struct type *builtin_type_void; -extern struct type *builtin_type_char; -extern struct type *builtin_type_short; -extern struct type *builtin_type_int; -extern struct type *builtin_type_long; -extern struct type *builtin_type_unsigned_char; -extern struct type *builtin_type_unsigned_short; -extern struct type *builtin_type_unsigned_int; -extern struct type *builtin_type_unsigned_long; -extern struct type *builtin_type_float; -extern struct type *builtin_type_double; - -#ifdef LONG_LONG -extern struct type *builtin_type_long_long; -extern struct type *builtin_type_unsigned_long_long; - -#ifndef BUILTIN_TYPE_LONGEST -#define BUILTIN_TYPE_LONGEST builtin_type_long_long -#endif - -#ifndef BUILTIN_TYPE_UNSIGNED_LONGEST -#define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long_long -#endif - -#else /* LONG_LONG */ - -#ifndef BUILTIN_TYPE_LONGEST -#define BUILTIN_TYPE_LONGEST builtin_type_long -#endif - -#ifndef BUILTIN_TYPE_UNSIGNED_LONGEST -#define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long -#endif - -#endif - -struct symtab_and_line -{ - struct symtab *symtab; - int line; - CORE_ADDR pc; - CORE_ADDR end; -}; - -struct symtabs_and_lines -{ - struct symtab_and_line *sals; - int nelts; -}; - -/* Given a pc value, return line number it is in. - Second arg nonzero means if pc is on the boundary - use the previous statement's line number. */ - -struct symtab_and_line find_pc_line (); - -/* Given a string, return the line specified by it. - For commands like "list" and "breakpoint". */ - -struct symtabs_and_lines decode_line_spec (); -struct symtabs_and_lines decode_line_spec_1 (); -struct symtabs_and_lines decode_line_1 (); diff --git a/gnu/usr.bin/gdb/utils.c b/gnu/usr.bin/gdb/utils.c deleted file mode 100644 index ed2b640bcd4d..000000000000 --- a/gnu/usr.bin/gdb/utils.c +++ /dev/null @@ -1,1091 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)utils.c 6.4 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: utils.c,v 1.3 1993/12/07 19:58:35 mycroft Exp $"; -#endif /* not lint */ - -/* General utility routines for GDB, the GNU debugger. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "param.h" - -#include -#include -#include -#include -#include -#include -#include -#include "defs.h" -#ifdef HAVE_TERMIO -#include -#endif - -/* If this definition isn't overridden by the header files, assume - that isatty and fileno exist on this system. */ -#ifndef ISATTY -#define ISATTY(FP) (isatty (fileno (FP))) -#endif - -extern FILE *instream; - -void error (); -void fatal (); - -/* Chain of cleanup actions established with make_cleanup, - to be executed if an error happens. */ - -static struct cleanup *cleanup_chain; - -/* Nonzero means a quit has been requested. */ - -int quit_flag; - -/* Nonzero means quit immediately if Control-C is typed now, - rather than waiting until QUIT is executed. */ - -int immediate_quit; - -/* Add a new cleanup to the cleanup_chain, - and return the previous chain pointer - to be passed later to do_cleanups or discard_cleanups. - Args are FUNCTION to clean up with, and ARG to pass to it. */ - -struct cleanup * -make_cleanup (function, arg) - void (*function) (); - int arg; -{ - register struct cleanup *new - = (struct cleanup *) xmalloc (sizeof (struct cleanup)); - register struct cleanup *old_chain = cleanup_chain; - - new->next = cleanup_chain; - new->function = function; - new->arg = arg; - cleanup_chain = new; - - return old_chain; -} - -/* Discard cleanups and do the actions they describe - until we get back to the point OLD_CHAIN in the cleanup_chain. */ - -void -do_cleanups (old_chain) - register struct cleanup *old_chain; -{ - register struct cleanup *ptr; - while ((ptr = cleanup_chain) != old_chain) - { - (*ptr->function) (ptr->arg); - cleanup_chain = ptr->next; - free (ptr); - } -} - -/* Discard cleanups, not doing the actions they describe, - until we get back to the point OLD_CHAIN in the cleanup_chain. */ - -void -discard_cleanups (old_chain) - register struct cleanup *old_chain; -{ - register struct cleanup *ptr; - while ((ptr = cleanup_chain) != old_chain) - { - cleanup_chain = ptr->next; - free (ptr); - } -} - -/* Set the cleanup_chain to 0, and return the old cleanup chain. */ -struct cleanup * -save_cleanups () -{ - struct cleanup *old_chain = cleanup_chain; - - cleanup_chain = 0; - return old_chain; -} - -/* Restore the cleanup chain from a previously saved chain. */ -void -restore_cleanups (chain) - struct cleanup *chain; -{ - cleanup_chain = chain; -} - -/* This function is useful for cleanups. - Do - - foo = xmalloc (...); - old_chain = make_cleanup (free_current_contents, &foo); - - to arrange to free the object thus allocated. */ - -void -free_current_contents (location) - char **location; -{ - free (*location); -} - -/* Generally useful subroutines used throughout the program. */ - -/* Like malloc but get error if no storage available. */ - -char * -xmalloc (size) - long size; -{ - register char *val = (char *) malloc (size); - if (!val) - fatal ("virtual memory exhausted.", 0); - return val; -} - -/* Like realloc but get error if no storage available. */ - -char * -xrealloc (ptr, size) - char *ptr; - long size; -{ - register char *val = (char *) realloc (ptr, size); - if (!val) - fatal ("virtual memory exhausted.", 0); - return val; -} - -/* Print the system error message for errno, and also mention STRING - as the file name for which the error was encountered. - Then return to command level. */ - -void -perror_with_name (string) - char *string; -{ - const char *err; - char *combined; - - if (errno < sys_nerr) - err = sys_errlist[errno]; - else - err = "unknown error"; - - combined = (char *) alloca (strlen (err) + strlen (string) + 3); - strcpy (combined, string); - strcat (combined, ": "); - strcat (combined, err); - - error ("%s.", combined); -} - -/* Print the system error message for ERRCODE, and also mention STRING - as the file name for which the error was encountered. */ - -void -print_sys_errmsg (string, errcode) - char *string; - int errcode; -{ - const char *err; - char *combined; - - if (errcode < sys_nerr) - err = sys_errlist[errcode]; - else - err = "unknown error"; - - combined = (char *) alloca (strlen (err) + strlen (string) + 3); - strcpy (combined, string); - strcat (combined, ": "); - strcat (combined, err); - - printf ("%s.\n", combined); -} - -void -quit () -{ -#ifdef HAVE_TERMIO - ioctl (fileno (stdout), TCFLSH, 1); -#else /* not HAVE_TERMIO */ - ioctl (fileno (stdout), TIOCFLUSH, 0); -#endif /* not HAVE_TERMIO */ -#ifdef TIOCGPGRP - error ("Quit"); -#else - error ("Quit (expect signal %d when inferior is resumed)", SIGINT); -#endif /* TIOCGPGRP */ -} - -/* Control C comes here */ - -void -request_quit () -{ - extern int remote_debugging; - - quit_flag = 1; - -#ifdef USG - /* Restore the signal handler. */ - signal (SIGINT, request_quit); -#endif - - if (immediate_quit) - quit(); -} - -/* Print an error message and return to command level. - STRING is the error message, used as a fprintf string, - and ARG is passed as an argument to it. */ - -void -error (string, arg1, arg2, arg3) - char *string; - int arg1, arg2, arg3; -{ - terminal_ours (); /* Should be ok even if no inf. */ - fflush (stdout); - fprintf (stderr, string, arg1, arg2, arg3); - fprintf (stderr, "\n"); - return_to_top_level (); -} - -/* Print an error message and exit reporting failure. - This is for a error that we cannot continue from. - STRING and ARG are passed to fprintf. */ - -void -fatal (string, arg) - char *string; - int arg; -{ - fprintf (stderr, "gdb: "); - fprintf (stderr, string, arg); - fprintf (stderr, "\n"); - exit (1); -} - -/* Print an error message and exit, dumping core. - STRING is a printf-style control string, and ARG is a corresponding - argument. */ -void -fatal_dump_core (string, arg) - char *string; - int arg; -{ - /* "internal error" is always correct, since GDB should never dump - core, no matter what the input. */ - fprintf (stderr, "gdb internal error: "); - fprintf (stderr, string, arg); - fprintf (stderr, "\n"); - signal (SIGQUIT, SIG_DFL); - kill (getpid (), SIGQUIT); - /* We should never get here, but just in case... */ - exit (1); -} - -/* Make a copy of the string at PTR with SIZE characters - (and add a null character at the end in the copy). - Uses malloc to get the space. Returns the address of the copy. */ - -char * -savestring (ptr, size) - char *ptr; - int size; -{ - register char *p = (char *) xmalloc (size + 1); - bcopy (ptr, p, size); - p[size] = 0; - return p; -} - -char * -concat (s1, s2, s3) - char *s1, *s2, *s3; -{ - register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1; - register char *val = (char *) xmalloc (len); - strcpy (val, s1); - strcat (val, s2); - strcat (val, s3); - return val; -} - -void -print_spaces (n, file) - register int n; - register FILE *file; -{ - while (n-- > 0) - fputc (' ', file); -} - -/* Ask user a y-or-n question and return 1 iff answer is yes. - Takes three args which are given to printf to print the question. - The first, a control string, should end in "? ". - It should not say how to answer, because we do that. */ - -int -query (ctlstr, arg1, arg2) - char *ctlstr; -{ - register int answer; - - /* Automatically answer "yes" if input is not from a terminal. */ - if (!input_from_terminal_p ()) - return 1; - - while (1) - { - printf (ctlstr, arg1, arg2); - printf ("(y or n) "); - fflush (stdout); - answer = fgetc (stdin); - clearerr (stdin); /* in case of C-d */ - if (answer != '\n') - while (fgetc (stdin) != '\n') clearerr (stdin); - if (answer >= 'a') - answer -= 040; - if (answer == 'Y') - return 1; - if (answer == 'N') - return 0; - printf ("Please answer y or n.\n"); - } -} - -/* Parse a C escape sequence. STRING_PTR points to a variable - containing a pointer to the string to parse. That pointer - is updated past the characters we use. The value of the - escape sequence is returned. - - A negative value means the sequence \ newline was seen, - which is supposed to be equivalent to nothing at all. - - If \ is followed by a null character, we return a negative - value and leave the string pointer pointing at the null character. - - If \ is followed by 000, we return 0 and leave the string pointer - after the zeros. A value of 0 does not mean end of string. */ - -int -parse_escape (string_ptr) - char **string_ptr; -{ - register int c = *(*string_ptr)++; - switch (c) - { - case 'a': - return '\a'; - case 'b': - return '\b'; - case 'e': - return 033; - case 'f': - return '\f'; - case 'n': - return '\n'; - case 'r': - return '\r'; - case 't': - return '\t'; - case 'v': - return '\v'; - case '\n': - return -2; - case 0: - (*string_ptr)--; - return 0; - case '^': - c = *(*string_ptr)++; - if (c == '\\') - c = parse_escape (string_ptr); - if (c == '?') - return 0177; - return (c & 0200) | (c & 037); - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - register int i = c - '0'; - register int count = 0; - while (++count < 3) - { - if ((c = *(*string_ptr)++) >= '0' && c <= '7') - { - i *= 8; - i += c - '0'; - } - else - { - (*string_ptr)--; - break; - } - } - return i; - } - default: - return c; - } -} - -/* Print the character CH on STREAM as part of the contents - of a literal string whose delimiter is QUOTER. */ - -void -printchar (ch, stream, quoter) - unsigned char ch; - FILE *stream; - int quoter; -{ - register int c = ch; - if (c < 040 || c >= 0177) - switch (c) - { - case '\n': - fputs_filtered ("\\n", stream); - break; - case '\b': - fputs_filtered ("\\b", stream); - break; - case '\t': - fputs_filtered ("\\t", stream); - break; - case '\f': - fputs_filtered ("\\f", stream); - break; - case '\r': - fputs_filtered ("\\r", stream); - break; - case '\033': - fputs_filtered ("\\e", stream); - break; - case '\007': - fputs_filtered ("\\a", stream); - break; - default: - fprintf_filtered (stream, "\\%.3o", (unsigned int) c); - break; - } - else - { - if (c == '\\' || c == quoter) - fputs_filtered ("\\", stream); - fprintf_filtered (stream, "%c", c); - } -} - -static int lines_per_page, lines_printed, chars_per_line, chars_printed; - -/* Set values of page and line size. */ -static void -set_screensize_command (arg, from_tty) - char *arg; - int from_tty; -{ - char *p = arg; - char *p1; - int tolinesize = lines_per_page; - int tocharsize = chars_per_line; - - if (p == 0) - error_no_arg ("set screensize"); - - while (*p >= '0' && *p <= '9') - p++; - - if (*p && *p != ' ' && *p != '\t') - error ("Non-integral argument given to \"set screensize\"."); - - tolinesize = atoi (arg); - - while (*p == ' ' || *p == '\t') - p++; - - if (*p) - { - p1 = p; - while (*p1 >= '0' && *p1 <= '9') - p1++; - - if (*p1) - error ("Non-integral second argument given to \"set screensize\"."); - - tocharsize = atoi (p); - } - - lines_per_page = tolinesize; - chars_per_line = tocharsize; -} - -static void -instream_cleanup(stream) - FILE *stream; -{ - instream = stream; -} - -static void -prompt_for_continue () -{ - if (ISATTY(stdin) && ISATTY(stdout)) - { - struct cleanup *old_chain = make_cleanup(instream_cleanup, instream); - char *cp, *gdb_readline(); - - instream = stdin; - immediate_quit++; - if (cp = gdb_readline ("---Type to continue---")) - free(cp); - chars_printed = lines_printed = 0; - immediate_quit--; - do_cleanups(old_chain); - } -} - -/* Reinitialize filter; ie. tell it to reset to original values. */ - -void -reinitialize_more_filter () -{ - lines_printed = 0; - chars_printed = 0; -} - -static void -screensize_info (arg, from_tty) - char *arg; - int from_tty; -{ - if (arg) - error ("\"info screensize\" does not take any arguments."); - - if (!lines_per_page) - printf ("Output more filtering is disabled.\n"); - else - { - printf ("Output more filtering is enabled with\n"); - printf ("%d lines per page and %d characters per line.\n", - lines_per_page, chars_per_line); - } -} - -/* Like fputs but pause after every screenful. - Unlike fputs, fputs_filtered does not return a value. - It is OK for LINEBUFFER to be NULL, in which case just don't print - anything. - - Note that a longjmp to top level may occur in this routine - (since prompt_for_continue may do so) so this routine should not be - called when cleanups are not in place. */ - -void -fputs_filtered (linebuffer, stream) - char *linebuffer; - FILE *stream; -{ - char *lineptr; - - if (linebuffer == 0) - return; - - /* Don't do any filtering if it is disabled. */ - if (stream != stdout || !ISATTY(stdout) || lines_per_page == 0) - { - fputs (linebuffer, stream); - return; - } - - /* Go through and output each character. Show line extension - when this is necessary; prompt user for new page when this is - necessary. */ - - lineptr = linebuffer; - while (*lineptr) - { - /* Possible new page. */ - if (lines_printed >= lines_per_page - 1) - prompt_for_continue (); - - while (*lineptr && *lineptr != '\n') - { - /* Print a single line. */ - if (*lineptr == '\t') - { - putc ('\t', stream); - /* Shifting right by 3 produces the number of tab stops - we have already passed, and then adding one and - shifting left 3 advances to the next tab stop. */ - chars_printed = ((chars_printed >> 3) + 1) << 3; - lineptr++; - } - else - { - putc (*lineptr, stream); - chars_printed++; - lineptr++; - } - - if (chars_printed >= chars_per_line) - { - chars_printed = 0; - lines_printed++; - /* Possible new page. */ - if (lines_printed >= lines_per_page - 1) - prompt_for_continue (); - } - } - - if (*lineptr == '\n') - { - lines_printed++; - putc ('\n', stream); - lineptr++; - chars_printed = 0; - } - } -} - -/* fputs_demangled is a variant of fputs_filtered that - demangles g++ names.*/ - -void -fputs_demangled (linebuffer, stream, arg_mode) - char *linebuffer; - FILE *stream; -{ -#ifdef __STDC__ - extern char *cplus_demangle (const char *, int); -#else - extern char *cplus_demangle (); -#endif -#define SYMBOL_MAX 1024 - -#define SYMBOL_CHAR(c) (isascii(c) && (isalnum(c) || (c) == '_' || (c) == '$')) - - char buf[SYMBOL_MAX+1]; - char *p; - - if (linebuffer == NULL) - return; - - p = linebuffer; - - while ( *p != (char) 0 ) { - int i = 0; - - /* collect non-interesting characters into buf */ - while ( *p != (char) 0 && !SYMBOL_CHAR(*p) ) { - buf[i++] = *p; - p++; - } - if (i > 0) { - /* output the non-interesting characters without demangling */ - buf[i] = (char) 0; - fputs_filtered(buf, stream); - i = 0; /* reset buf */ - } - - /* and now the interesting characters */ - while (i < SYMBOL_MAX && *p != (char) 0 && SYMBOL_CHAR(*p) ) { - buf[i++] = *p; - p++; - } - buf[i] = (char) 0; - if (i > 0) { - char * result; - - if ( (result = cplus_demangle(buf, arg_mode)) != NULL ) { - fputs_filtered(result, stream); - free(result); - } - else { - fputs_filtered(buf, stream); - } - } - } -} - -/* Print ARG1, ARG2, and ARG3 on stdout using format FORMAT. If this - information is going to put the amount written since the last call - to INIIALIZE_MORE_FILTER or the last page break over the page size, - print out a pause message and do a gdb_readline to get the users - permision to continue. - - Unlike fprintf, this function does not return a value. - - Note that this routine has a restriction that the length of the - final output line must be less than 255 characters *or* it must be - less than twice the size of the format string. This is a very - arbitrary restriction, but it is an internal restriction, so I'll - put it in. This means that the %s format specifier is almost - useless; unless the caller can GUARANTEE that the string is short - enough, fputs_filtered should be used instead. - - Note also that a longjmp to top level may occur in this routine - (since prompt_for_continue may do so) so this routine should not be - called when cleanups are not in place. */ - -void -fprintf_filtered (stream, format, arg1, arg2, arg3, arg4, arg5, arg6) - FILE *stream; - char *format; - int arg1, arg2, arg3, arg4, arg5, arg6; -{ - static char *linebuffer = (char *) 0; - static int line_size; - int format_length = strlen (format); - int numchars; - - /* Allocated linebuffer for the first time. */ - if (!linebuffer) - { - linebuffer = (char *) xmalloc (255); - line_size = 255; - } - - /* Reallocate buffer to a larger size if this is necessary. */ - if (format_length * 2 > line_size) - { - line_size = format_length * 2; - - /* You don't have to copy. */ - free (linebuffer); - linebuffer = (char *) xmalloc (line_size); - } - - /* This won't blow up if the restrictions described above are - followed. */ - (void) sprintf (linebuffer, format, arg1, arg2, arg3, arg4, arg5, arg6); - - fputs_filtered (linebuffer, stream); -} - -void -printf_filtered (format, arg1, arg2, arg3, arg4, arg5, arg6) - char *format; - int arg1, arg2, arg3, arg4, arg5, arg6; -{ - fprintf_filtered (stdout, format, arg1, arg2, arg3, arg4, arg5, arg6); -} - -/* Print N spaces. */ -void -print_spaces_filtered (n, stream) - int n; - FILE *stream; -{ - register char *s = (char *) alloca (n + 1); - register char *t = s; - - while (n--) - *t++ = ' '; - *t = '\0'; - - fputs_filtered (s, stream); -} - - -#ifdef USG -bcopy (from, to, count) -char *from, *to; -{ - memcpy (to, from, count); -} - -bcmp (from, to, count) -{ - return (memcmp (to, from, count)); -} - -bzero (to, count) -char *to; -{ - while (count--) - *to++ = 0; -} - -getwd (buf) -char *buf; -{ - getcwd (buf, MAXPATHLEN); -} - -char * -index (s, c) - char *s; -{ - char *strchr (); - return strchr (s, c); -} - -char * -rindex (s, c) - char *s; -{ - char *strrchr (); - return strrchr (s, c); -} - -#ifndef USG -char *sys_siglist[32] = { - "SIG0", - "SIGHUP", - "SIGINT", - "SIGQUIT", - "SIGILL", - "SIGTRAP", - "SIGIOT", - "SIGEMT", - "SIGFPE", - "SIGKILL", - "SIGBUS", - "SIGSEGV", - "SIGSYS", - "SIGPIPE", - "SIGALRM", - "SIGTERM", - "SIGUSR1", - "SIGUSR2", - "SIGCLD", - "SIGPWR", - "SIGWIND", - "SIGPHONE", - "SIGPOLL", -}; -#endif - -/* Queue routines */ - -struct queue { - struct queue *forw; - struct queue *back; -}; - -insque (item, after) -struct queue *item; -struct queue *after; -{ - item->forw = after->forw; - after->forw->back = item; - - item->back = after; - after->forw = item; -} - -remque (item) -struct queue *item; -{ - item->forw->back = item->back; - item->back->forw = item->forw; -} -#endif /* USG */ - -#ifdef USG -/* There is too much variation in Sys V signal numbers and names, so - we must initialize them at runtime. */ -static char undoc[] = "(undocumented)"; - -char *sys_siglist[NSIG]; -#endif /* USG */ - -extern struct cmd_list_element *setlist; - -void -_initialize_utils () -{ - int i; - add_cmd ("screensize", class_support, set_screensize_command, - "Change gdb's notion of the size of the output screen.\n\ -The first argument is the number of lines on a page.\n\ -The second argument (optional) is the number of characters on a line.", - &setlist); - add_info ("screensize", screensize_info, - "Show gdb's current notion of the size of the output screen."); - - /* These defaults will be used if we are unable to get the correct - values from termcap. */ - lines_per_page = 24; - chars_per_line = 80; - /* Initialize the screen height and width from termcap. */ - { - int termtype = getenv ("TERM"); - - /* Positive means success, nonpositive means failure. */ - int status; - - /* 2048 is large enough for all known terminals, according to the - GNU termcap manual. */ - char term_buffer[2048]; - - if (termtype) - { - status = tgetent (term_buffer, termtype); - if (status > 0) - { - int val; - - val = tgetnum ("li"); - if (val >= 0) - lines_per_page = val; - else - /* The number of lines per page is not mentioned - in the terminal description. This probably means - that paging is not useful (e.g. emacs shell window), - so disable paging. */ - lines_per_page = 0; - - val = tgetnum ("co"); - if (val >= 0) - chars_per_line = val; - } - } - } - -#ifdef USG - /* Initialize signal names. */ - for (i = 0; i < NSIG; i++) - sys_siglist[i] = undoc; - -#ifdef SIGHUP - sys_siglist[SIGHUP ] = "SIGHUP"; -#endif -#ifdef SIGINT - sys_siglist[SIGINT ] = "SIGINT"; -#endif -#ifdef SIGQUIT - sys_siglist[SIGQUIT ] = "SIGQUIT"; -#endif -#ifdef SIGILL - sys_siglist[SIGILL ] = "SIGILL"; -#endif -#ifdef SIGTRAP - sys_siglist[SIGTRAP ] = "SIGTRAP"; -#endif -#ifdef SIGIOT - sys_siglist[SIGIOT ] = "SIGIOT"; -#endif -#ifdef SIGEMT - sys_siglist[SIGEMT ] = "SIGEMT"; -#endif -#ifdef SIGFPE - sys_siglist[SIGFPE ] = "SIGFPE"; -#endif -#ifdef SIGKILL - sys_siglist[SIGKILL ] = "SIGKILL"; -#endif -#ifdef SIGBUS - sys_siglist[SIGBUS ] = "SIGBUS"; -#endif -#ifdef SIGSEGV - sys_siglist[SIGSEGV ] = "SIGSEGV"; -#endif -#ifdef SIGSYS - sys_siglist[SIGSYS ] = "SIGSYS"; -#endif -#ifdef SIGPIPE - sys_siglist[SIGPIPE ] = "SIGPIPE"; -#endif -#ifdef SIGALRM - sys_siglist[SIGALRM ] = "SIGALRM"; -#endif -#ifdef SIGTERM - sys_siglist[SIGTERM ] = "SIGTERM"; -#endif -#ifdef SIGUSR1 - sys_siglist[SIGUSR1 ] = "SIGUSR1"; -#endif -#ifdef SIGUSR2 - sys_siglist[SIGUSR2 ] = "SIGUSR2"; -#endif -#ifdef SIGCLD - sys_siglist[SIGCLD ] = "SIGCLD"; -#endif -#ifdef SIGCHLD - sys_siglist[SIGCHLD ] = "SIGCHLD"; -#endif -#ifdef SIGPWR - sys_siglist[SIGPWR ] = "SIGPWR"; -#endif -#ifdef SIGTSTP - sys_siglist[SIGTSTP ] = "SIGTSTP"; -#endif -#ifdef SIGTTIN - sys_siglist[SIGTTIN ] = "SIGTTIN"; -#endif -#ifdef SIGTTOU - sys_siglist[SIGTTOU ] = "SIGTTOU"; -#endif -#ifdef SIGSTOP - sys_siglist[SIGSTOP ] = "SIGSTOP"; -#endif -#ifdef SIGXCPU - sys_siglist[SIGXCPU ] = "SIGXCPU"; -#endif -#ifdef SIGXFSZ - sys_siglist[SIGXFSZ ] = "SIGXFSZ"; -#endif -#ifdef SIGVTALRM - sys_siglist[SIGVTALRM ] = "SIGVTALRM"; -#endif -#ifdef SIGPROF - sys_siglist[SIGPROF ] = "SIGPROF"; -#endif -#ifdef SIGWINCH - sys_siglist[SIGWINCH ] = "SIGWINCH"; -#endif -#ifdef SIGCONT - sys_siglist[SIGCONT ] = "SIGCONT"; -#endif -#ifdef SIGURG - sys_siglist[SIGURG ] = "SIGURG"; -#endif -#ifdef SIGIO - sys_siglist[SIGIO ] = "SIGIO"; -#endif -#ifdef SIGWIND - sys_siglist[SIGWIND ] = "SIGWIND"; -#endif -#ifdef SIGPHONE - sys_siglist[SIGPHONE ] = "SIGPHONE"; -#endif -#ifdef SIGPOLL - sys_siglist[SIGPOLL ] = "SIGPOLL"; -#endif -#endif /* USG */ -} diff --git a/gnu/usr.bin/gdb/valarith.c b/gnu/usr.bin/gdb/valarith.c deleted file mode 100644 index d557fdaa1019..000000000000 --- a/gnu/usr.bin/gdb/valarith.c +++ /dev/null @@ -1,691 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)valarith.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: valarith.c,v 1.2 1993/08/01 18:47:35 mycroft Exp $"; -#endif /* not lint */ - -/* Perform arithmetic and other operations on values, for GDB. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "value.h" -#include "expression.h" - - -value value_x_binop (); -value value_subscripted_rvalue (); - -value -value_add (arg1, arg2) - value arg1, arg2; -{ - register value val, valint, valptr; - register int len; - - COERCE_ARRAY (arg1); - COERCE_ARRAY (arg2); - - if ((TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR - || TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_PTR) - && - (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT - || TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_INT)) - /* Exactly one argument is a pointer, and one is an integer. */ - { - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR) - { - valptr = arg1; - valint = arg2; - } - else - { - valptr = arg2; - valint = arg1; - } - len = TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (valptr))); - if (len == 0) len = 1; /* For (void *) */ - val = value_from_long (builtin_type_long, - value_as_long (valptr) - + (len * value_as_long (valint))); - VALUE_TYPE (val) = VALUE_TYPE (valptr); - return val; - } - - return value_binop (arg1, arg2, BINOP_ADD); -} - -value -value_sub (arg1, arg2) - value arg1, arg2; -{ - register value val; - - COERCE_ARRAY (arg1); - COERCE_ARRAY (arg2); - - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR - && - TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_INT) - { - val = value_from_long (builtin_type_long, - value_as_long (arg1) - - TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) * value_as_long (arg2)); - VALUE_TYPE (val) = VALUE_TYPE (arg1); - return val; - } - - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR - && - VALUE_TYPE (arg1) == VALUE_TYPE (arg2)) - { - val = value_from_long (builtin_type_long, - (value_as_long (arg1) - value_as_long (arg2)) - / TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)))); - return val; - } - - return value_binop (arg1, arg2, BINOP_SUB); -} - -/* Return the value of ARRAY[IDX]. */ - -value -value_subscript (array, idx) - value array, idx; -{ - if (TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_ARRAY - && VALUE_LVAL (array) != lval_memory) - return value_subscripted_rvalue (array, idx); - else - return value_ind (value_add (array, idx)); -} - -/* Return the value of EXPR[IDX], expr an aggregate rvalue - (eg, a vector register) */ - -value -value_subscripted_rvalue (array, idx) - value array, idx; -{ - struct type *elt_type = TYPE_TARGET_TYPE (VALUE_TYPE (array)); - int elt_size = TYPE_LENGTH (elt_type); - int elt_offs = elt_size * value_as_long (idx); - value v; - - if (elt_offs >= TYPE_LENGTH (VALUE_TYPE (array))) - error ("no such vector element"); - - if (TYPE_CODE (elt_type) == TYPE_CODE_FLT) - { - if (elt_size == sizeof (float)) - v = value_from_double (elt_type, (double) *(float *) - (VALUE_CONTENTS (array) + elt_offs)); - else - v = value_from_double (elt_type, *(double *) - (VALUE_CONTENTS (array) + elt_offs)); - } - else - { - int offs; - union {int i; char c;} test; - test.i = 1; - if (test.c == 1) - offs = 0; - else - offs = sizeof (LONGEST) - elt_size; - v = value_from_long (elt_type, *(LONGEST *) - (VALUE_CONTENTS (array) + elt_offs - offs)); - } - - if (VALUE_LVAL (array) == lval_internalvar) - VALUE_LVAL (v) = lval_internalvar_component; - else - VALUE_LVAL (v) = not_lval; - VALUE_ADDRESS (v) = VALUE_ADDRESS (array); - VALUE_OFFSET (v) = VALUE_OFFSET (array) + elt_offs; - VALUE_BITSIZE (v) = elt_size * 8; - return v; -} - -/* Check to see if either argument is a structure. This is called so - we know whether to go ahead with the normal binop or look for a - user defined function instead. - - For now, we do not overload the `=' operator. */ - -int -binop_user_defined_p (op, arg1, arg2) - enum exp_opcode op; - value arg1, arg2; -{ - if (op == BINOP_ASSIGN) - return 0; - return (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_STRUCT - || TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_STRUCT - || (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF - && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_STRUCT) - || (TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_REF - && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_STRUCT)); -} - -/* Check to see if argument is a structure. This is called so - we know whether to go ahead with the normal unop or look for a - user defined function instead. - - For now, we do not overload the `&' operator. */ - -int unop_user_defined_p (op, arg1) - enum exp_opcode op; - value arg1; -{ - if (op == UNOP_ADDR) - return 0; - return (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_STRUCT - || (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF - && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_STRUCT)); -} - -/* We know either arg1 or arg2 is a structure, so try to find the right - user defined function. Create an argument vector that calls - arg1.operator @ (arg1,arg2) and return that value (where '@' is any - binary operator which is legal for GNU C++). */ - -value -value_x_binop (arg1, arg2, op, otherop) - value arg1, arg2; - int op, otherop; -{ - value * argvec; - char *ptr; - char tstr[13]; - int static_memfuncp; - - COERCE_ENUM (arg1); - COERCE_ENUM (arg2); - - /* now we know that what we have to do is construct our - arg vector and find the right function to call it with. */ - - if (TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_STRUCT) - error ("friend functions not implemented yet"); - - argvec = (value *) alloca (sizeof (value) * 4); - argvec[1] = value_addr (arg1); - argvec[2] = arg2; - argvec[3] = 0; - - /* make the right function name up */ - strcpy(tstr, "operator __"); - ptr = tstr+9; - switch (op) - { - case BINOP_ADD: strcpy(ptr,"+"); break; - case BINOP_SUB: strcpy(ptr,"-"); break; - case BINOP_MUL: strcpy(ptr,"*"); break; - case BINOP_DIV: strcpy(ptr,"/"); break; - case BINOP_REM: strcpy(ptr,"%"); break; - case BINOP_LSH: strcpy(ptr,"<<"); break; - case BINOP_RSH: strcpy(ptr,">>"); break; - case BINOP_LOGAND: strcpy(ptr,"&"); break; - case BINOP_LOGIOR: strcpy(ptr,"|"); break; - case BINOP_LOGXOR: strcpy(ptr,"^"); break; - case BINOP_AND: strcpy(ptr,"&&"); break; - case BINOP_OR: strcpy(ptr,"||"); break; - case BINOP_MIN: strcpy(ptr,"?"); break; - case BINOP_ASSIGN: strcpy(ptr,"="); break; - case BINOP_ASSIGN_MODIFY: - switch (otherop) - { - case BINOP_ADD: strcpy(ptr,"+="); break; - case BINOP_SUB: strcpy(ptr,"-="); break; - case BINOP_MUL: strcpy(ptr,"*="); break; - case BINOP_DIV: strcpy(ptr,"/="); break; - case BINOP_REM: strcpy(ptr,"%="); break; - case BINOP_LOGAND: strcpy(ptr,"&="); break; - case BINOP_LOGIOR: strcpy(ptr,"|="); break; - case BINOP_LOGXOR: strcpy(ptr,"^="); break; - default: - error ("Invalid binary operation specified."); - } - break; - case BINOP_SUBSCRIPT: strcpy(ptr,"[]"); break; - case BINOP_EQUAL: strcpy(ptr,"=="); break; - case BINOP_NOTEQUAL: strcpy(ptr,"!="); break; - case BINOP_LESS: strcpy(ptr,"<"); break; - case BINOP_GTR: strcpy(ptr,">"); break; - case BINOP_GEQ: strcpy(ptr,">="); break; - case BINOP_LEQ: strcpy(ptr,"<="); break; - default: - error ("Invalid binary operation specified."); - } - argvec[0] = value_struct_elt (arg1, argvec+1, tstr, &static_memfuncp, "structure"); - if (argvec[0]) - { - if (static_memfuncp) - { - argvec[1] = argvec[0]; - argvec++; - } - return call_function (argvec[0], 2 - static_memfuncp, argvec + 1); - } - error ("member function %s not found", tstr); -} - -/* We know that arg1 is a structure, so try to find a unary user - defined operator that matches the operator in question. - Create an argument vector that calls arg1.operator @ (arg1) - and return that value (where '@' is (almost) any unary operator which - is legal for GNU C++). */ - -value -value_x_unop (arg1, op) - value arg1; - int op; -{ - value * argvec; - char *ptr; - char tstr[13]; - int static_memfuncp; - - COERCE_ENUM (arg1); - - /* now we know that what we have to do is construct our - arg vector and find the right function to call it with. */ - - if (TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_STRUCT) - error ("friend functions not implemented yet"); - - argvec = (value *) alloca (sizeof (value) * 3); - argvec[1] = value_addr (arg1); - argvec[2] = 0; - - /* make the right function name up */ - strcpy(tstr,"operator __"); - ptr = tstr+9; - switch (op) - { - case UNOP_PREINCREMENT: strcpy(ptr,"++"); break; - case UNOP_PREDECREMENT: strcpy(ptr,"++"); break; - case UNOP_POSTINCREMENT: strcpy(ptr,"++"); break; - case UNOP_POSTDECREMENT: strcpy(ptr,"++"); break; - case UNOP_ZEROP: strcpy(ptr,"!"); break; - case UNOP_LOGNOT: strcpy(ptr,"~"); break; - case UNOP_NEG: strcpy(ptr,"-"); break; - default: - error ("Invalid binary operation specified."); - } - argvec[0] = value_struct_elt (arg1, argvec+1, tstr, &static_memfuncp, "structure"); - if (argvec[0]) - { - if (static_memfuncp) - { - argvec[1] = argvec[0]; - argvec++; - } - return call_function (argvec[0], 1 - static_memfuncp, argvec + 1); - } - error ("member function %s not found", tstr); -} - -/* Perform a binary operation on two integers or two floats. - Does not support addition and subtraction on pointers; - use value_add or value_sub if you want to handle those possibilities. */ - -value -value_binop (arg1, arg2, op) - value arg1, arg2; - int op; -{ - register value val; - - COERCE_ENUM (arg1); - COERCE_ENUM (arg2); - - if ((TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_FLT - && - TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_INT) - || - (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_FLT - && - TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT)) - error ("Argument to arithmetic operation not a number."); - - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_FLT - || - TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_FLT) - { - double v1, v2, v; - v1 = value_as_double (arg1); - v2 = value_as_double (arg2); - switch (op) - { - case BINOP_ADD: - v = v1 + v2; - break; - - case BINOP_SUB: - v = v1 - v2; - break; - - case BINOP_MUL: - v = v1 * v2; - break; - - case BINOP_DIV: - v = v1 / v2; - break; - - default: - error ("Integer-only operation on floating point number."); - } - - val = allocate_value (builtin_type_double); - *(double *) VALUE_CONTENTS (val) = v; - } - else - /* Integral operations here. */ - { - /* Should we promote to unsigned longest? */ - if ((TYPE_UNSIGNED (VALUE_TYPE (arg1)) - || TYPE_UNSIGNED (VALUE_TYPE (arg2))) - && (TYPE_LENGTH (VALUE_TYPE (arg1)) >= sizeof (unsigned LONGEST) - || TYPE_LENGTH (VALUE_TYPE (arg2)) >= sizeof (unsigned LONGEST))) - { - unsigned LONGEST v1, v2, v; - v1 = (unsigned LONGEST) value_as_long (arg1); - v2 = (unsigned LONGEST) value_as_long (arg2); - - switch (op) - { - case BINOP_ADD: - v = v1 + v2; - break; - - case BINOP_SUB: - v = v1 - v2; - break; - - case BINOP_MUL: - v = v1 * v2; - break; - - case BINOP_DIV: - v = v1 / v2; - break; - - case BINOP_REM: - v = v1 % v2; - break; - - case BINOP_LSH: - v = v1 << v2; - break; - - case BINOP_RSH: - v = v1 >> v2; - break; - - case BINOP_LOGAND: - v = v1 & v2; - break; - - case BINOP_LOGIOR: - v = v1 | v2; - break; - - case BINOP_LOGXOR: - v = v1 ^ v2; - break; - - case BINOP_AND: - v = v1 && v2; - break; - - case BINOP_OR: - v = v1 || v2; - break; - - case BINOP_MIN: - v = v1 < v2 ? v1 : v2; - break; - - case BINOP_MAX: - v = v1 > v2 ? v1 : v2; - break; - - default: - error ("Invalid binary operation on numbers."); - } - - val = allocate_value (BUILTIN_TYPE_UNSIGNED_LONGEST); - *(unsigned LONGEST *) VALUE_CONTENTS (val) = v; - } - else - { - LONGEST v1, v2, v; - v1 = value_as_long (arg1); - v2 = value_as_long (arg2); - - switch (op) - { - case BINOP_ADD: - v = v1 + v2; - break; - - case BINOP_SUB: - v = v1 - v2; - break; - - case BINOP_MUL: - v = v1 * v2; - break; - - case BINOP_DIV: - v = v1 / v2; - break; - - case BINOP_REM: - v = v1 % v2; - break; - - case BINOP_LSH: - v = v1 << v2; - break; - - case BINOP_RSH: - v = v1 >> v2; - break; - - case BINOP_LOGAND: - v = v1 & v2; - break; - - case BINOP_LOGIOR: - v = v1 | v2; - break; - - case BINOP_LOGXOR: - v = v1 ^ v2; - break; - - case BINOP_AND: - v = v1 && v2; - break; - - case BINOP_OR: - v = v1 || v2; - break; - - case BINOP_MIN: - v = v1 < v2 ? v1 : v2; - break; - - case BINOP_MAX: - v = v1 > v2 ? v1 : v2; - break; - - default: - error ("Invalid binary operation on numbers."); - } - - val = allocate_value (BUILTIN_TYPE_LONGEST); - *(LONGEST *) VALUE_CONTENTS (val) = v; - } - } - - return val; -} - -/* Simulate the C operator ! -- return 1 if ARG1 contains zeros. */ - -int -value_zerop (arg1) - value arg1; -{ - register int len; - register char *p; - - COERCE_ARRAY (arg1); - - len = TYPE_LENGTH (VALUE_TYPE (arg1)); - p = VALUE_CONTENTS (arg1); - - while (--len >= 0) - { - if (*p++) - break; - } - - return len < 0; -} - -/* Simulate the C operator == by returning a 1 - iff ARG1 and ARG2 have equal contents. */ - -int -value_equal (arg1, arg2) - register value arg1, arg2; - -{ - register int len; - register char *p1, *p2; - enum type_code code1; - enum type_code code2; - - COERCE_ARRAY (arg1); - COERCE_ARRAY (arg2); - - code1 = TYPE_CODE (VALUE_TYPE (arg1)); - code2 = TYPE_CODE (VALUE_TYPE (arg2)); - - if (code1 == TYPE_CODE_INT && code2 == TYPE_CODE_INT) - return value_as_long (arg1) == value_as_long (arg2); - else if ((code1 == TYPE_CODE_FLT || code1 == TYPE_CODE_INT) - && (code2 == TYPE_CODE_FLT || code2 == TYPE_CODE_INT)) - return value_as_double (arg1) == value_as_double (arg2); - else if ((code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_INT) - || (code2 == TYPE_CODE_PTR && code1 == TYPE_CODE_INT)) - return (char *) value_as_long (arg1) == (char *) value_as_long (arg2); - else if (code1 == code2 - && ((len = TYPE_LENGTH (VALUE_TYPE (arg1))) - == TYPE_LENGTH (VALUE_TYPE (arg2)))) - { - p1 = VALUE_CONTENTS (arg1); - p2 = VALUE_CONTENTS (arg2); - while (--len >= 0) - { - if (*p1++ != *p2++) - break; - } - return len < 0; - } - else - error ("Invalid type combination in equality test."); -} - -/* Simulate the C operator < by returning 1 - iff ARG1's contents are less than ARG2's. */ - -int -value_less (arg1, arg2) - register value arg1, arg2; -{ - register enum type_code code1; - register enum type_code code2; - - COERCE_ARRAY (arg1); - COERCE_ARRAY (arg2); - - code1 = TYPE_CODE (VALUE_TYPE (arg1)); - code2 = TYPE_CODE (VALUE_TYPE (arg2)); - - if (code1 == TYPE_CODE_INT && code2 == TYPE_CODE_INT) - return value_as_long (arg1) < value_as_long (arg2); - else if ((code1 == TYPE_CODE_FLT || code1 == TYPE_CODE_INT) - && (code2 == TYPE_CODE_FLT || code2 == TYPE_CODE_INT)) - return value_as_double (arg1) < value_as_double (arg2); - else if ((code1 == TYPE_CODE_PTR || code1 == TYPE_CODE_INT) - && (code2 == TYPE_CODE_PTR || code2 == TYPE_CODE_INT)) - return (char *) value_as_long (arg1) < (char *) value_as_long (arg2); - else - error ("Invalid type combination in ordering comparison."); -} - -/* The unary operators - and ~. Both free the argument ARG1. */ - -value -value_neg (arg1) - register value arg1; -{ - register struct type *type; - - COERCE_ENUM (arg1); - - type = VALUE_TYPE (arg1); - - if (TYPE_CODE (type) == TYPE_CODE_FLT) - return value_from_double (type, - value_as_double (arg1)); - else if (TYPE_CODE (type) == TYPE_CODE_INT) - return value_from_long (type, - value_as_long (arg1)); - else - error ("Argument to negate operation not a number."); -} - -value -value_lognot (arg1) - register value arg1; -{ - COERCE_ENUM (arg1); - - if (TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_INT) - error ("Argument to complement operation not an integer."); - - return value_from_long (VALUE_TYPE (arg1), ~ value_as_long (arg1)); -} - diff --git a/gnu/usr.bin/gdb/valops.c b/gnu/usr.bin/gdb/valops.c deleted file mode 100644 index 3c87c22cdabd..000000000000 --- a/gnu/usr.bin/gdb/valops.c +++ /dev/null @@ -1,1419 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)valops.c 6.4 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: valops.c,v 1.2 1993/08/01 18:47:33 mycroft Exp $"; -#endif /* not lint */ - -/* Perform non-arithmetic operations on values, for GDB. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "stdio.h" -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "value.h" -#include "frame.h" -#include "inferior.h" - -/* Cast value ARG2 to type TYPE and return as a value. - More general than a C cast: accepts any two types of the same length, - and if ARG2 is an lvalue it can be cast into anything at all. */ - -value -value_cast (type, arg2) - struct type *type; - register value arg2; -{ - register enum type_code code1; - register enum type_code code2; - register int scalar; - - /* Coerce arrays but not enums. Enums will work as-is - and coercing them would cause an infinite recursion. */ - if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_ENUM) - COERCE_ARRAY (arg2); - - code1 = TYPE_CODE (type); - code2 = TYPE_CODE (VALUE_TYPE (arg2)); - scalar = (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_FLT - || code2 == TYPE_CODE_ENUM); - - if (code1 == TYPE_CODE_FLT && scalar) - return value_from_double (type, value_as_double (arg2)); - else if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_ENUM) - && (scalar || code2 == TYPE_CODE_PTR)) - return value_from_long (type, value_as_long (arg2)); - else if (TYPE_LENGTH (type) == TYPE_LENGTH (VALUE_TYPE (arg2))) - { - VALUE_TYPE (arg2) = type; - return arg2; - } - else if (VALUE_LVAL (arg2) == lval_memory) - { - return value_at (type, VALUE_ADDRESS (arg2) + VALUE_OFFSET (arg2)); - } - else - error ("Invalid cast."); -} - -/* Create a value of type TYPE that is zero, and return it. */ - -value -value_zero (type, lv) - struct type *type; - enum lval_type lv; -{ - register value val = allocate_value (type); - - bzero (VALUE_CONTENTS (val), TYPE_LENGTH (type)); - VALUE_LVAL (val) = lv; - - return val; -} - -/* Return the value with a specified type located at specified address. */ - -value -value_at (type, addr) - struct type *type; - CORE_ADDR addr; -{ - register value val = allocate_value (type); - int temp; - - temp = read_memory (addr, VALUE_CONTENTS (val), TYPE_LENGTH (type)); - if (temp) - { - if (have_inferior_p () && !remote_debugging) - print_sys_errmsg ("ptrace", temp); - /* Actually, address between addr and addr + len was out of bounds. */ - error ("Cannot read memory: address 0x%x out of bounds.", addr); - } - - VALUE_LVAL (val) = lval_memory; - VALUE_ADDRESS (val) = addr; - - return val; -} - -/* Store the contents of FROMVAL into the location of TOVAL. - Return a new value with the location of TOVAL and contents of FROMVAL. */ - -value -value_assign (toval, fromval) - register value toval, fromval; -{ - register struct type *type = VALUE_TYPE (toval); - register value val; - char raw_buffer[MAX_REGISTER_RAW_SIZE]; - char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; - int use_buffer = 0; - - extern CORE_ADDR find_saved_register (); - - COERCE_ARRAY (fromval); - - if (VALUE_LVAL (toval) != lval_internalvar) - fromval = value_cast (type, fromval); - - /* If TOVAL is a special machine register requiring conversion - of program values to a special raw format, - convert FROMVAL's contents now, with result in `raw_buffer', - and set USE_BUFFER to the number of bytes to write. */ - - if (VALUE_REGNO (toval) >= 0 - && REGISTER_CONVERTIBLE (VALUE_REGNO (toval))) - { - int regno = VALUE_REGNO (toval); - if (VALUE_TYPE (fromval) != REGISTER_VIRTUAL_TYPE (regno)) - fromval = value_cast (REGISTER_VIRTUAL_TYPE (regno), fromval); - bcopy (VALUE_CONTENTS (fromval), virtual_buffer, - REGISTER_VIRTUAL_SIZE (regno)); - REGISTER_CONVERT_TO_RAW (regno, virtual_buffer, raw_buffer); - use_buffer = REGISTER_RAW_SIZE (regno); - } - - switch (VALUE_LVAL (toval)) - { - case lval_internalvar: - set_internalvar (VALUE_INTERNALVAR (toval), fromval); - break; - - case lval_internalvar_component: - set_internalvar_component (VALUE_INTERNALVAR (toval), - VALUE_OFFSET (toval), - VALUE_BITPOS (toval), - VALUE_BITSIZE (toval), - fromval); - break; - - case lval_memory: - if (VALUE_BITSIZE (toval)) - { - int val; - read_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - &val, sizeof val); - modify_field (&val, (int) value_as_long (fromval), - VALUE_BITPOS (toval), VALUE_BITSIZE (toval)); - write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - &val, sizeof val); - } - else if (use_buffer) - write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - raw_buffer, use_buffer); - else - write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - VALUE_CONTENTS (fromval), TYPE_LENGTH (type)); - break; - - case lval_register: - if (VALUE_BITSIZE (toval)) - { - int val; - - read_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - &val, sizeof val); - modify_field (&val, (int) value_as_long (fromval), - VALUE_BITPOS (toval), VALUE_BITSIZE (toval)); - write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - &val, sizeof val); - } - else if (use_buffer) - write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - raw_buffer, use_buffer); - else - write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - VALUE_CONTENTS (fromval), TYPE_LENGTH (type)); - break; - - case lval_reg_frame_relative: - { - /* value is stored in a series of registers in the frame - specified by the structure. Copy that value out, modify - it, and copy it back in. */ - int amount_to_copy = (VALUE_BITSIZE (toval) ? 1 : TYPE_LENGTH (type)); - int reg_size = REGISTER_RAW_SIZE (VALUE_FRAME_REGNUM (toval)); - int byte_offset = VALUE_OFFSET (toval) % reg_size; - int reg_offset = VALUE_OFFSET (toval) / reg_size; - int amount_copied; - char *buffer = (char *) alloca (amount_to_copy); - int regno; - FRAME frame; - CORE_ADDR addr; - - /* Figure out which frame this is in currently. */ - for (frame = get_current_frame (); - frame && FRAME_FP (frame) != VALUE_FRAME (toval); - frame = get_prev_frame (frame)) - ; - - if (!frame) - error ("Value being assigned to is no longer active."); - - amount_to_copy += (reg_size - amount_to_copy % reg_size); - - /* Copy it out. */ - for ((regno = VALUE_FRAME_REGNUM (toval) + reg_offset, - amount_copied = 0); - amount_copied < amount_to_copy; - amount_copied += reg_size, regno++) - { - addr = find_saved_register (frame, regno); - if (addr == 0) - read_register_bytes (REGISTER_BYTE (regno), - buffer + amount_copied, - reg_size); - else - read_memory (addr, buffer + amount_copied, reg_size); - } - - /* Modify what needs to be modified. */ - if (VALUE_BITSIZE (toval)) - modify_field (buffer + byte_offset, - (int) value_as_long (fromval), - VALUE_BITPOS (toval), VALUE_BITSIZE (toval)); - else if (use_buffer) - bcopy (raw_buffer, buffer + byte_offset, use_buffer); - else - bcopy (VALUE_CONTENTS (fromval), buffer + byte_offset, - TYPE_LENGTH (type)); - - /* Copy it back. */ - for ((regno = VALUE_FRAME_REGNUM (toval) + reg_offset, - amount_copied = 0); - amount_copied < amount_to_copy; - amount_copied += reg_size, regno++) - { - addr = find_saved_register (frame, regno); - if (addr == 0) - write_register_bytes (REGISTER_BYTE (regno), - buffer + amount_copied, - reg_size); - else - write_memory (addr, buffer + amount_copied, reg_size); - } - } - break; - - - default: - error ("Left side of = operation is not an lvalue."); - } - - /* Return a value just like TOVAL except with the contents of FROMVAL - (except in the case of the type if TOVAL is an internalvar). */ - - if (VALUE_LVAL (toval) == lval_internalvar - || VALUE_LVAL (toval) == lval_internalvar_component) - { - type = VALUE_TYPE (fromval); - } - - val = allocate_value (type); - bcopy (toval, val, VALUE_CONTENTS (val) - (char *) val); - bcopy (VALUE_CONTENTS (fromval), VALUE_CONTENTS (val), TYPE_LENGTH (type)); - VALUE_TYPE (val) = type; - - return val; -} - -/* Extend a value VAL to COUNT repetitions of its type. */ - -value -value_repeat (arg1, count) - value arg1; - int count; -{ - register value val; - - if (VALUE_LVAL (arg1) != lval_memory) - error ("Only values in memory can be extended with '@'."); - if (count < 1) - error ("Invalid number %d of repetitions.", count); - - val = allocate_repeat_value (VALUE_TYPE (arg1), count); - - read_memory (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1), - VALUE_CONTENTS (val), - TYPE_LENGTH (VALUE_TYPE (val)) * count); - VALUE_LVAL (val) = lval_memory; - VALUE_ADDRESS (val) = VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1); - - return val; -} - -value -value_of_variable (var) - struct symbol *var; -{ - return read_var_value (var, (FRAME) 0); -} - -/* Given a value which is an array, return a value which is - a pointer to its first element. */ - -value -value_coerce_array (arg1) - value arg1; -{ - register struct type *type; - register value val; - - if (VALUE_LVAL (arg1) != lval_memory) - error ("Attempt to take address of value not located in memory."); - - /* Get type of elements. */ - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_ARRAY) - type = TYPE_TARGET_TYPE (VALUE_TYPE (arg1)); - else - /* A phony array made by value_repeat. - Its type is the type of the elements, not an array type. */ - type = VALUE_TYPE (arg1); - - /* Get the type of the result. */ - type = lookup_pointer_type (type); - val = value_from_long (builtin_type_long, - (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1))); - VALUE_TYPE (val) = type; - return val; -} - -/* Return a pointer value for the object for which ARG1 is the contents. */ - -value -value_addr (arg1) - value arg1; -{ - register struct type *type; - register value val, arg1_coerced; - - /* Taking the address of an array is really a no-op - once the array is coerced to a pointer to its first element. */ - arg1_coerced = arg1; - COERCE_ARRAY (arg1_coerced); - if (arg1 != arg1_coerced) - return arg1_coerced; - - if (VALUE_LVAL (arg1) != lval_memory) - error ("Attempt to take address of value not located in memory."); - - /* Get the type of the result. */ - type = lookup_pointer_type (VALUE_TYPE (arg1)); - val = value_from_long (builtin_type_long, - (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1))); - VALUE_TYPE (val) = type; - return val; -} - -/* Given a value of a pointer type, apply the C unary * operator to it. */ - -value -value_ind (arg1) - value arg1; -{ - /* Must do this before COERCE_ARRAY, otherwise an infinite loop - will result */ - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF) - return value_at (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)), - (CORE_ADDR) value_as_long (arg1)); - - COERCE_ARRAY (arg1); - - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_MEMBER) - error ("not implemented: member types in value_ind"); - - /* Allow * on an integer so we can cast it to whatever we want. - This returns an int, which seems like the most C-like thing - to do. "long long" variables are rare enough that - BUILTIN_TYPE_LONGEST would seem to be a mistake. */ - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT) - return value_at (builtin_type_int, - (CORE_ADDR) value_as_long (arg1)); - else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR) - return value_at (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)), - (CORE_ADDR) value_as_long (arg1)); - else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF) - return value_at (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)), - (CORE_ADDR) value_as_long (arg1)); - error ("Attempt to take contents of a non-pointer value."); -} - -/* Pushing small parts of stack frames. */ - -/* Push one word (the size of object that a register holds). */ - -CORE_ADDR -push_word (sp, buffer) - CORE_ADDR sp; - REGISTER_TYPE buffer; -{ - register int len = sizeof (REGISTER_TYPE); - -#if 1 INNER_THAN 2 - sp -= len; - write_memory (sp, &buffer, len); -#else /* stack grows upward */ - write_memory (sp, &buffer, len); - sp += len; -#endif /* stack grows upward */ - - return sp; -} - -/* Push LEN bytes with data at BUFFER. */ - -CORE_ADDR -push_bytes (sp, buffer, len) - CORE_ADDR sp; - char *buffer; - int len; -{ -#if 1 INNER_THAN 2 - sp -= len; - write_memory (sp, buffer, len); -#else /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; -#endif /* stack grows upward */ - - return sp; -} - -/* Push onto the stack the specified value VALUE. */ - -CORE_ADDR -value_push (sp, arg) - register CORE_ADDR sp; - value arg; -{ - register int len = TYPE_LENGTH (VALUE_TYPE (arg)); - -#if 1 INNER_THAN 2 - sp -= len; - write_memory (sp, VALUE_CONTENTS (arg), len); -#else /* stack grows upward */ - write_memory (sp, VALUE_CONTENTS (arg), len); - sp += len; -#endif /* stack grows upward */ - - return sp; -} - -/* Perform the standard coercions that are specified - for arguments to be passed to C functions. */ - -value -value_arg_coerce (arg) - value arg; -{ - register struct type *type; - - COERCE_ENUM (arg); - - type = VALUE_TYPE (arg); - - if (TYPE_CODE (type) == TYPE_CODE_INT - && TYPE_LENGTH (type) < sizeof (int)) - return value_cast (builtin_type_int, arg); - - if (type == builtin_type_float) - return value_cast (builtin_type_double, arg); - - return arg; -} - -/* Push the value ARG, first coercing it as an argument - to a C function. */ - -CORE_ADDR -value_arg_push (sp, arg) - register CORE_ADDR sp; - value arg; -{ - return value_push (sp, value_arg_coerce (arg)); -} - -#ifdef NEW_CALL_FUNCTION - -int -arg_stacklen(nargs, args) - int nargs; - value *args; -{ - int len = 0; - - while (--nargs >= 0) - len += TYPE_LENGTH(VALUE_TYPE(value_arg_coerce(args[nargs]))); - - return len; -} - -CORE_ADDR -function_address(function, type) - value function; - struct type **type; -{ - register CORE_ADDR funaddr; - register struct type *ftype = VALUE_TYPE(function); - register enum type_code code = TYPE_CODE(ftype); - - /* - * If it's a member function, just look at the function part - * of it. - */ - - /* Determine address to call. */ - if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD) { - funaddr = VALUE_ADDRESS(function); - *type = TYPE_TARGET_TYPE(ftype); - } else if (code == TYPE_CODE_PTR) { - funaddr = value_as_long(function); - if (TYPE_CODE(TYPE_TARGET_TYPE(ftype)) == TYPE_CODE_FUNC - || TYPE_CODE(TYPE_TARGET_TYPE(ftype)) == TYPE_CODE_METHOD) - *type = TYPE_TARGET_TYPE(TYPE_TARGET_TYPE(ftype)); - else - *type = builtin_type_int; - } else if (code == TYPE_CODE_INT) { - /* - * Handle the case of functions lacking debugging - * info. Their values are characters since their - * addresses are char - */ - if (TYPE_LENGTH(ftype) == 1) - - funaddr = value_as_long(value_addr(function)); - else - /* - * Handle integer used as address of a - * function. - */ - funaddr = value_as_long(function); - - *type = builtin_type_int; - } else - error("Invalid data type for function to be called."); - - return funaddr; -} - -/* Perform a function call in the inferior. - ARGS is a vector of values of arguments (NARGS of them). - FUNCTION is a value, the function to be called. - Returns a value representing what the function returned. - May fail to return, if a breakpoint or signal is hit - during the execution of the function. */ - -value -call_function(function, nargs, args) - value function; - int nargs; - value *args; -{ - register CORE_ADDR sp, pc; - struct type *value_type; - struct inferior_status inf_status; - struct cleanup *old_chain; - register CORE_ADDR funaddr; - int struct_return_bytes; - char retbuf[REGISTER_BYTES]; - - if (!have_inferior_p()) - error("Cannot invoke functions if the inferior is not running."); - - save_inferior_status(&inf_status, 1); - old_chain = make_cleanup(restore_inferior_status, &inf_status); - - sp = read_register(SP_REGNUM); - funaddr = function_address(function, &value_type); - /* - * Are we returning a value using a structure return or a - * normal value return? - */ - if (using_struct_return(function, funaddr, value_type)) - struct_return_bytes = TYPE_LENGTH(value_type); - else - struct_return_bytes = 0; - /* - * Create a call sequence customized for this function and - * the number of arguments for it. - */ - pc = setup_dummy(sp, funaddr, nargs, args, - struct_return_bytes, value_arg_push); - - /* - * Execute the stack dummy stub. The register state will be - * returned in retbuf. It is restored below. - */ - run_stack_dummy(pc, retbuf); - - /* - * This will restore the register context that existed before - * we called the dummy function. - */ - do_cleanups(old_chain); - - return value_being_returned(value_type, retbuf, struct_return_bytes); -} -#else - -/* Perform a function call in the inferior. - ARGS is a vector of values of arguments (NARGS of them). - FUNCTION is a value, the function to be called. - Returns a value representing what the function returned. - May fail to return, if a breakpoint or signal is hit - during the execution of the function. */ - -value -call_function (function, nargs, args) - value function; - int nargs; - value *args; -{ - register CORE_ADDR sp; - register int i; - CORE_ADDR start_sp; - static REGISTER_TYPE dummy[] = CALL_DUMMY; - REGISTER_TYPE dummy1[sizeof dummy / sizeof (REGISTER_TYPE)]; - CORE_ADDR old_sp; - struct type *value_type; - unsigned char struct_return; - CORE_ADDR struct_addr; - struct inferior_status inf_status; - struct cleanup *old_chain; - - if (!have_inferior_p ()) - error ("Cannot invoke functions if the inferior is not running."); - - save_inferior_status (&inf_status, 1); - old_chain = make_cleanup (restore_inferior_status, &inf_status); - - /* PUSH_DUMMY_FRAME is responsible for saving the inferior registers - (and POP_FRAME for restoring them). (At least on most machines) - they are saved on the stack in the inferior. */ - PUSH_DUMMY_FRAME; - - old_sp = sp = read_register (SP_REGNUM); - -#if 1 INNER_THAN 2 /* Stack grows down */ - sp -= sizeof dummy; - start_sp = sp; -#else /* Stack grows up */ - start_sp = sp; - sp += sizeof dummy; -#endif - - { - register CORE_ADDR funaddr; - register struct type *ftype = VALUE_TYPE (function); - register enum type_code code = TYPE_CODE (ftype); - - /* If it's a member function, just look at the function - part of it. */ - - /* Determine address to call. */ - if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD) - { - funaddr = VALUE_ADDRESS (function); - value_type = TYPE_TARGET_TYPE (ftype); - } - else if (code == TYPE_CODE_PTR) - { - funaddr = value_as_long (function); - if (TYPE_CODE (TYPE_TARGET_TYPE (ftype)) == TYPE_CODE_FUNC - || TYPE_CODE (TYPE_TARGET_TYPE (ftype)) == TYPE_CODE_METHOD) - value_type = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (ftype)); - else - value_type = builtin_type_int; - } - else if (code == TYPE_CODE_INT) - { - /* Handle the case of functions lacking debugging info. - Their values are characters since their addresses are char */ - if (TYPE_LENGTH (ftype) == 1) - funaddr = value_as_long (value_addr (function)); - else - /* Handle integer used as address of a function. */ - funaddr = value_as_long (function); - - value_type = builtin_type_int; - } - else - error ("Invalid data type for function to be called."); - - /* Are we returning a value using a structure return or a normal - value return? */ - - struct_return = using_struct_return (function, funaddr, value_type); - - /* Create a call sequence customized for this function - and the number of arguments for it. */ - bcopy (dummy, dummy1, sizeof dummy); - FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, value_type); - } - -#ifndef CANNOT_EXECUTE_STACK - write_memory (start_sp, dummy1, sizeof dummy); - -#else - /* Convex Unix prohibits executing in the stack segment. */ - /* Hope there is empty room at the top of the text segment. */ - { - extern CORE_ADDR text_end; - static checked = 0; - if (!checked) - for (start_sp = text_end - sizeof dummy; start_sp < text_end; ++start_sp) - if (read_memory_integer (start_sp, 1) != 0) - error ("text segment full -- no place to put call"); - checked = 1; - sp = old_sp; - start_sp = text_end - sizeof dummy; - write_memory (start_sp, dummy1, sizeof dummy); - } -#endif /* CANNOT_EXECUTE_STACK */ -#ifdef STACK_ALIGN - /* If stack grows down, we must leave a hole at the top. */ - { - int len = 0; - - /* Reserve space for the return structure to be written on the - stack, if necessary */ - - if (struct_return) - len += TYPE_LENGTH (value_type); - - for (i = nargs - 1; i >= 0; i--) - len += TYPE_LENGTH (VALUE_TYPE (value_arg_coerce (args[i]))); -#ifdef CALL_DUMMY_STACK_ADJUST - len += CALL_DUMMY_STACK_ADJUST; -#endif -#if 1 INNER_THAN 2 - sp -= STACK_ALIGN (len) - len; -#else - sp += STACK_ALIGN (len) - len; -#endif - } -#endif /* STACK_ALIGN */ - - /* Reserve space for the return structure to be written on the - stack, if necessary */ - - if (struct_return) - { -#if 1 INNER_THAN 2 - sp -= TYPE_LENGTH (value_type); - struct_addr = sp; -#else - struct_addr = sp; - sp += TYPE_LENGTH (value_type); -#endif - } - - for (i = nargs - 1; i >= 0; i--) - sp = value_arg_push (sp, args[i]); - -#ifdef CALL_DUMMY_STACK_ADJUST -#if 1 INNER_THAN 2 - sp -= CALL_DUMMY_STACK_ADJUST; -#else - sp += CALL_DUMMY_STACK_ADJUST; -#endif -#endif /* CALL_DUMMY_STACK_ADJUST */ - - /* Store the address at which the structure is supposed to be - written. Note that this (and the code which reserved the space - above) assumes that gcc was used to compile this function. Since - it doesn't cost us anything but space and if the function is pcc - it will ignore this value, we will make that assumption. - - Also note that on some machines (like the sparc) pcc uses this - convention in a slightly twisted way also. */ - - if (struct_return) - STORE_STRUCT_RETURN (struct_addr, sp); - - /* Write the stack pointer. This is here because the statement above - might fool with it */ - write_register (SP_REGNUM, sp); - - /* Figure out the value returned by the function. */ - { - char retbuf[REGISTER_BYTES]; - - /* Execute the stack dummy routine, calling FUNCTION. - When it is done, discard the empty frame - after storing the contents of all regs into retbuf. */ - run_stack_dummy (start_sp + CALL_DUMMY_START_OFFSET, retbuf); - - do_cleanups (old_chain); - - return value_being_returned (value_type, retbuf, struct_return); - } -} -#endif - -/* Create a value for a string constant: - Call the function malloc in the inferior to get space for it, - then copy the data into that space - and then return the address with type char *. - PTR points to the string constant data; LEN is number of characters. */ - -value -value_string (ptr, len) - char *ptr; - int len; -{ - register value val; - register struct symbol *sym; - value blocklen; - register char *copy = (char *) alloca (len + 1); - char *i = ptr; - register char *o = copy, *ibeg = ptr; - register int c; -#ifdef KERNELDEBUG - extern int kernel_debugging; - - if (kernel_debugging) - error("Can't stuff string constants into kernel (yet)."); -#endif - - /* Copy the string into COPY, processing escapes. - We could not conveniently process them in expread - because the string there wants to be a substring of the input. */ - - while (i - ibeg < len) - { - c = *i++; - if (c == '\\') - { - c = parse_escape (&i); - if (c == -1) - continue; - } - *o++ = c; - } - *o = 0; - - /* Get the length of the string after escapes are processed. */ - - len = o - copy; - - /* Find the address of malloc in the inferior. */ - - sym = lookup_symbol ("malloc", 0, VAR_NAMESPACE, 0); - if (sym != 0) - { - if (SYMBOL_CLASS (sym) != LOC_BLOCK) - error ("\"malloc\" exists in this program but is not a function."); - val = value_of_variable (sym); - } - else - { - register int i; - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, "malloc")) - break; - if (i < misc_function_count) - val = value_from_long (builtin_type_long, - (LONGEST) misc_function_vector[i].address); - else - error ("String constants require the program to have a function \"malloc\"."); - } - - blocklen = value_from_long (builtin_type_int, (LONGEST) (len + 1)); - val = call_function (val, 1, &blocklen); - if (value_zerop (val)) - error ("No memory available for string constant."); - write_memory ((CORE_ADDR) value_as_long (val), copy, len + 1); - VALUE_TYPE (val) = lookup_pointer_type (builtin_type_char); - return val; -} - -static int -type_field_index(t, name) - register struct type *t; - register char *name; -{ - register int i; - - for (i = TYPE_NFIELDS(t); --i >= 0;) - { - register char *t_field_name = TYPE_FIELD_NAME (t, i); - - if (t_field_name && !strcmp (t_field_name, name)) - break; - } - return (i); -} - -/* Given ARG1, a value of type (pointer to a)* structure/union, - extract the component named NAME from the ultimate target structure/union - and return it as a value with its appropriate type. - ERR is used in the error message if ARG1's type is wrong. - - C++: ARGS is a list of argument types to aid in the selection of - an appropriate method. Also, handle derived types. - - STATIC_MEMFUNCP, if non-NULL, points to a caller-supplied location - where the truthvalue of whether the function that was resolved was - a static member function or not. - - ERR is an error message to be printed in case the field is not found. */ - -value -value_struct_elt (arg1, args, name, static_memfuncp, err) - register value arg1, *args; - char *name; - int *static_memfuncp; - char *err; -{ - register struct type *t; - register int i; - int found = 0; - - struct type *baseclass; - - COERCE_ARRAY (arg1); - - t = VALUE_TYPE (arg1); - - /* Check for the usual case: we have pointer, target type is a struct - * and `name' is a legal field of the struct. In this case, we can - * just snarf the value of the field & not waste time while value_ind - * sucks over the entire struct. */ - if (! args) - { - if (TYPE_CODE(t) == TYPE_CODE_PTR - && (TYPE_CODE((baseclass = TYPE_TARGET_TYPE(t))) == TYPE_CODE_STRUCT - || TYPE_CODE(baseclass) == TYPE_CODE_UNION) - && (i = type_field_index(baseclass, name)) >= 0) - { - register int offset; - register struct type *f = TYPE_FIELD_TYPE(baseclass, i); - - offset = TYPE_FIELD_BITPOS(baseclass, i) >> 3; - if (TYPE_FIELD_BITSIZE(baseclass, i) == 0) - return value_at(f, (CORE_ADDR)(value_as_long(arg1) + offset)); - } - } - - /* Follow pointers until we get to a non-pointer. */ - - while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF) - { - arg1 = value_ind (arg1); - COERCE_ARRAY (arg1); - t = VALUE_TYPE (arg1); - } - - if (TYPE_CODE (t) == TYPE_CODE_MEMBER) - error ("not implemented: member type in value_struct_elt"); - - if (TYPE_CODE (t) != TYPE_CODE_STRUCT - && TYPE_CODE (t) != TYPE_CODE_UNION) - error ("Attempt to extract a component of a value that is not a %s.", err); - - baseclass = t; - - /* Assume it's not, unless we see that it is. */ - if (static_memfuncp) - *static_memfuncp =0; - - if (!args) - { - /* if there are no arguments ...do this... */ - - /* Try as a variable first, because if we succeed, there - is less work to be done. */ - while (t) - { - i = type_field_index(t, name); - if (i >= 0) - return TYPE_FIELD_STATIC (t, i) - ? value_static_field (t, name, i) : value_field (arg1, i); - - if (TYPE_N_BASECLASSES (t) == 0) - break; - - t = TYPE_BASECLASS (t, 1); - VALUE_TYPE (arg1) = t; /* side effect! */ - } - - /* C++: If it was not found as a data field, then try to - return it as a pointer to a method. */ - t = baseclass; - VALUE_TYPE (arg1) = t; /* side effect! */ - - if (destructor_name_p (name, t)) - error ("use `info method' command to print out value of destructor"); - - while (t) - { - for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i) - { - if (! strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name)) - { - error ("use `info method' command to print value of method \"%s\"", name); - } - } - - if (TYPE_N_BASECLASSES (t) == 0) - break; - - t = TYPE_BASECLASS (t, 1); - } - - error ("There is no field named %s.", name); - return 0; - } - - if (destructor_name_p (name, t)) - { - if (!args[1]) - { - /* destructors are a special case. */ - return (value)value_fn_field (arg1, 0, - TYPE_FN_FIELDLIST_LENGTH (t, 0)); - } - else - { - error ("destructor should not have any argument"); - } - } - - /* This following loop is for methods with arguments. */ - while (t) - { - /* Look up as method first, because that is where we - expect to find it first. */ - for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; i--) - { - struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i); - - if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name)) - { - int j; - struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i); - - found = 1; - for (j = TYPE_FN_FIELDLIST_LENGTH (t, i) - 1; j >= 0; --j) - if (!typecmp (TYPE_FN_FIELD_STATIC_P (f, j), - TYPE_FN_FIELD_ARGS (f, j), args)) - { - if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) - return (value)value_virtual_fn_field (arg1, f, j, t); - if (TYPE_FN_FIELD_STATIC_P (f, j) && static_memfuncp) - *static_memfuncp = 1; - return (value)value_fn_field (arg1, i, j); - } - } - } - - if (TYPE_N_BASECLASSES (t) == 0) - break; - - t = TYPE_BASECLASS (t, 1); - VALUE_TYPE (arg1) = t; /* side effect! */ - } - - if (found) - { - error ("Structure method %s not defined for arglist.", name); - return 0; - } - else - { - /* See if user tried to invoke data as function */ - t = baseclass; - while (t) - { - i = type_field_index(t, name); - if (i >= 0) - return TYPE_FIELD_STATIC (t, i) - ? value_static_field (t, name, i) : value_field (arg1, i); - - if (TYPE_N_BASECLASSES (t) == 0) - break; - - t = TYPE_BASECLASS (t, 1); - VALUE_TYPE (arg1) = t; /* side effect! */ - } - error ("Structure has no component named %s.", name); - } -} - -/* C++: return 1 is NAME is a legitimate name for the destructor - of type TYPE. If TYPE does not have a destructor, or - if NAME is inappropriate for TYPE, an error is signaled. */ -int -destructor_name_p (name, type) - char *name; - struct type *type; -{ - /* destructors are a special case. */ - char *dname = TYPE_NAME (type); - - if (name[0] == '~') - { - if (! TYPE_HAS_DESTRUCTOR (type)) - error ("type `%s' does not have destructor defined", - TYPE_NAME (type)); - /* Skip past the "struct " at the front. */ - while (*dname++ != ' ') ; - if (strcmp (dname, name+1)) - error ("destructor specification error"); - else - return 1; - } - return 0; -} - -/* C++: Given ARG1, a value of type (pointer to a)* structure/union, - return 1 if the component named NAME from the ultimate - target structure/union is defined, otherwise, return 0. */ - -int -check_field (arg1, name) - register value arg1; - char *name; -{ - register struct type *t; - register int i; - int found = 0; - - struct type *baseclass; - - COERCE_ARRAY (arg1); - - t = VALUE_TYPE (arg1); - - /* Follow pointers until we get to a non-pointer. */ - - while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF) - t = TYPE_TARGET_TYPE (t); - - if (TYPE_CODE (t) == TYPE_CODE_MEMBER) - error ("not implemented: member type in check_field"); - - if (TYPE_CODE (t) != TYPE_CODE_STRUCT - && TYPE_CODE (t) != TYPE_CODE_UNION) - error ("Internal error: `this' is not an aggregate"); - - baseclass = t; - - while (t) - { - for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--) - { - char *t_field_name = TYPE_FIELD_NAME (t, i); - if (t_field_name && !strcmp (t_field_name, name)) - goto success; - } - if (TYPE_N_BASECLASSES (t) == 0) - break; - - t = TYPE_BASECLASS (t, 1); - VALUE_TYPE (arg1) = t; /* side effect! */ - } - - /* C++: If it was not found as a data field, then try to - return it as a pointer to a method. */ - t = baseclass; - - /* Destructors are a special case. */ - if (destructor_name_p (name, t)) - goto success; - - while (t) - { - for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i) - { - if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name)) - return 1; - } - - if (TYPE_N_BASECLASSES (t) == 0) - break; - - t = TYPE_BASECLASS (t, 1); - } - return 0; - - success: - t = VALUE_TYPE (arg1); - while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF) - { - arg1 = value_ind (arg1); - COERCE_ARRAY (arg1); - t = VALUE_TYPE (arg1); - } -} - -/* C++: Given an aggregate type DOMAIN, and a member name NAME, - return the address of this member as a pointer to member - type. If INTYPE is non-null, then it will be the type - of the member we are looking for. This will help us resolve - pointers to member functions. */ - -value -value_struct_elt_for_address (domain, intype, name) - struct type *domain, *intype; - char *name; -{ - register struct type *t = domain; - register int i; - int found = 0; - value v; - - struct type *baseclass; - - if (TYPE_CODE (t) != TYPE_CODE_STRUCT - && TYPE_CODE (t) != TYPE_CODE_UNION) - error ("Internal error: non-aggregate type to value_struct_elt_for_address"); - - baseclass = t; - - while (t) - { - for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--) - { - char *t_field_name = TYPE_FIELD_NAME (t, i); - if (t_field_name && !strcmp (t_field_name, name)) - { - if (TYPE_FIELD_PACKED (t, i)) - error ("pointers to bitfield members not allowed"); - - v = value_from_long (builtin_type_int, - (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3)); - VALUE_TYPE (v) = lookup_pointer_type ( - lookup_member_type (TYPE_FIELD_TYPE (t, i), baseclass)); - return v; - } - } - - if (TYPE_N_BASECLASSES (t) == 0) - break; - - t = TYPE_BASECLASS (t, 1); - } - - /* C++: If it was not found as a data field, then try to - return it as a pointer to a method. */ - t = baseclass; - - /* Destructors are a special case. */ - if (destructor_name_p (name, t)) - { - error ("pointers to destructors not implemented yet"); - } - - /* Perform all necessary dereferencing. */ - while (intype && TYPE_CODE (intype) == TYPE_CODE_PTR) - intype = TYPE_TARGET_TYPE (intype); - - while (t) - { - for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i) - { - if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name)) - { - int j = TYPE_FN_FIELDLIST_LENGTH (t, i); - struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i); - - if (intype == 0 && j > 1) - error ("non-unique member `%s' requires type instantiation", name); - if (intype) - { - while (j--) - if (TYPE_FN_FIELD_TYPE (f, j) == intype) - break; - if (j < 0) - error ("no member function matches that type instantiation"); - } - else - j = 0; - - if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) - { - v = value_from_long (builtin_type_long, - (LONGEST) TYPE_FN_FIELD_VOFFSET (f, j)); - } - else - { - struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_NAMESPACE, 0); - v = locate_var_value (s, 0); - } - VALUE_TYPE (v) = lookup_pointer_type (lookup_member_type (TYPE_FN_FIELD_TYPE (f, j), baseclass)); - return v; - } - } - - if (TYPE_N_BASECLASSES (t) == 0) - break; - - t = TYPE_BASECLASS (t, 1); - } - return 0; -} - -/* Compare two argument lists and return the position in which they differ, - or zero if equal. - - STATICP is nonzero if the T1 argument list came from a - static member function. - - For non-static member functions, we ignore the first argument, - which is the type of the instance variable. This is because we want - to handle calls with objects from derived classes. This is not - entirely correct: we should actually check to make sure that a - requested operation is type secure, shouldn't we? */ - -int -typecmp (staticp, t1, t2) - int staticp; - struct type *t1[]; - value t2[]; -{ - int i; - - if (staticp && t1 == 0) - return t2[1] != 0; - if (t1 == 0) - return 1; - if (t1[0]->code == TYPE_CODE_VOID) return 0; - if (t1[!staticp] == 0) return 0; - for (i = !staticp; t1[i] && t1[i]->code != TYPE_CODE_VOID; i++) - { - if (! t2[i] - || t1[i]->code != t2[i]->type->code - || t1[i]->target_type != t2[i]->type->target_type) - return i+1; - } - if (!t1[i]) return 0; - return t2[i] ? i+1 : 0; -} - -/* C++: return the value of the class instance variable, if one exists. - Flag COMPLAIN signals an error if the request is made in an - inappropriate context. */ -value -value_of_this (complain) - int complain; -{ - extern FRAME selected_frame; - struct symbol *func, *sym; - char *funname = 0; - struct block *b; - int i; - - if (selected_frame == 0) - if (complain) - error ("no frame selected"); - else return 0; - - func = get_frame_function (selected_frame); - if (func) - funname = SYMBOL_NAME (func); - else - if (complain) - error ("no `this' in nameless context"); - else return 0; - - b = SYMBOL_BLOCK_VALUE (func); - i = BLOCK_NSYMS (b); - if (i <= 0) - if (complain) - error ("no args, no `this'"); - else return 0; - - sym = BLOCK_SYM (b, 0); - if (strncmp ("$this", SYMBOL_NAME (sym), 5)) - if (complain) - error ("current stack frame not in method"); - else return 0; - - return read_var_value (sym, selected_frame); -} diff --git a/gnu/usr.bin/gdb/valprint.c b/gnu/usr.bin/gdb/valprint.c deleted file mode 100644 index e41ad9e30afc..000000000000 --- a/gnu/usr.bin/gdb/valprint.c +++ /dev/null @@ -1,1443 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)valprint.c 6.5 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: valprint.c,v 1.3 1993/12/03 05:13:11 paulus Exp $"; -#endif /* not lint */ - -/* Print values for GNU debugger gdb. - Copyright (C) 1986, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "value.h" - -/* GNU software is only expected to run on systems with 32-bit integers. */ -#define UINT_MAX 0xffffffff - -/* Maximum number of chars to print for a string pointer value - or vector contents, or UINT_MAX for no limit. */ - -static unsigned int print_max; - -static void type_print_varspec_suffix (); -static void type_print_varspec_prefix (); -static void type_print_base (); -static void type_print_method_args (); - - -char **unsigned_type_table; -char **signed_type_table; -char **float_type_table; - - -/* Print repeat counts if there are more than this - many repetitions of an element in an array. */ -#define REPEAT_COUNT_THRESHOLD 10 - -/* Print the character string STRING, printing at most LENGTH characters. - Printing stops early if the number hits print_max; repeat counts - are printed as appropriate. Print ellipses at the end if we - had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */ - -void -print_string (stream, string, length, force_ellipses) - FILE *stream; - char *string; - unsigned int length; - int force_ellipses; -{ - register unsigned int i; - unsigned int things_printed = 0; - int in_quotes = 0; - int need_comma = 0; - - if (length == 0) - { - fputs_filtered ("\"\"", stdout); - return; - } - - for (i = 0; i < length && things_printed < print_max; ++i) - { - /* Position of the character we are examining - to see whether it is repeated. */ - unsigned int rep1; - /* Number of repititions we have detected so far. */ - unsigned int reps; - - QUIT; - - if (need_comma) - { - fputs_filtered (", ", stream); - need_comma = 0; - } - - rep1 = i + 1; - reps = 1; - while (rep1 < length && string[rep1] == string[i]) - { - ++rep1; - ++reps; - } - - if (reps > REPEAT_COUNT_THRESHOLD) - { - if (in_quotes) - { - fputs_filtered ("\", ", stream); - in_quotes = 0; - } - fputs_filtered ("'", stream); - printchar (string[i], stream, '\''); - fprintf_filtered (stream, "' ", reps); - i = rep1 - 1; - things_printed += REPEAT_COUNT_THRESHOLD; - need_comma = 1; - } - else - { - if (!in_quotes) - { - fputs_filtered ("\"", stream); - in_quotes = 1; - } - printchar (string[i], stream, '"'); - ++things_printed; - } - } - - /* Terminate the quotes if necessary. */ - if (in_quotes) - fputs_filtered ("\"", stream); - - if (force_ellipses || i < length) - fputs_filtered ("...", stream); -} - -/* Print the value VAL in C-ish syntax on stream STREAM. - FORMAT is a format-letter, or 0 for print in natural format of data type. - If the object printed is a string pointer, returns - the number of string bytes printed. */ - -int -value_print (val, stream, format, pretty) - value val; - FILE *stream; - char format; - enum val_prettyprint pretty; -{ - register unsigned int i, n, typelen; - - /* A "repeated" value really contains several values in a row. - They are made by the @ operator. - Print such values as if they were arrays. */ - - if (VALUE_REPEATED (val)) - { - n = VALUE_REPETITIONS (val); - typelen = TYPE_LENGTH (VALUE_TYPE (val)); - fprintf_filtered (stream, "{"); - /* Print arrays of characters using string syntax. */ - if (typelen == 1 && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT - && format == 0) - print_string (stream, VALUE_CONTENTS (val), n, 0); - else - { - unsigned int things_printed = 0; - - for (i = 0; i < n && things_printed < print_max; i++) - { - /* Position of the array element we are examining to see - whether it is repeated. */ - unsigned int rep1; - /* Number of repititions we have detected so far. */ - unsigned int reps; - - if (i != 0) - fprintf_filtered (stream, ", "); - - rep1 = i + 1; - reps = 1; - while (rep1 < n - && !bcmp (VALUE_CONTENTS (val) + typelen * i, - VALUE_CONTENTS (val) + typelen * rep1, typelen)) - { - ++reps; - ++rep1; - } - - if (reps > REPEAT_COUNT_THRESHOLD) - { - val_print (VALUE_TYPE (val), - VALUE_CONTENTS (val) + typelen * i, - VALUE_ADDRESS (val) + typelen * i, - stream, format, 1, 0, pretty); - fprintf (stream, " ", reps); - i = rep1 - 1; - things_printed += REPEAT_COUNT_THRESHOLD; - } - else - { - val_print (VALUE_TYPE (val), - VALUE_CONTENTS (val) + typelen * i, - VALUE_ADDRESS (val) + typelen * i, - stream, format, 1, 0, pretty); - things_printed++; - } - } - if (i < n) - fprintf_filtered (stream, "..."); - } - fprintf_filtered (stream, "}"); - return n * typelen; - } - else - { - /* If it is a pointer, indicate what it points to. - - Print type also if it is a reference. - - C++: if it is a member pointer, we will take care - of that when we print it. */ - if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_PTR - || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_REF) - { - fprintf_filtered (stream, "("); - type_print (VALUE_TYPE (val), "", stream, -1); - fprintf_filtered (stream, ") "); - - /* If this is a function pointer, try to print what - function it is pointing to by name. */ - if (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (val))) - == TYPE_CODE_FUNC) - { - print_address (((int *) VALUE_CONTENTS (val))[0], stream); - /* Return value is irrelevant except for string pointers. */ - return 0; - } - } - return val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), - VALUE_ADDRESS (val), stream, format, 1, 0, pretty); - } -} - -static int prettyprint; /* Controls prettyprinting of structures. */ -int unionprint; /* Controls printing of nested unions. */ -static void scalar_print_hack(); -void (*default_scalar_print)() = scalar_print_hack; - -/* Print data of type TYPE located at VALADDR (within GDB), - which came from the inferior at address ADDRESS, - onto stdio stream STREAM according to FORMAT - (a letter or 0 for natural format). - - If the data are a string pointer, returns the number of - sting characters printed. - - if DEREF_REF is nonzero, then dereference references, - otherwise just print them like pointers. - - The PRETTY parameter controls prettyprinting. */ - -int -val_print (type, valaddr, address, stream, format, - deref_ref, recurse, pretty) - struct type *type; - char *valaddr; - CORE_ADDR address; - FILE *stream; - char format; - int deref_ref; - int recurse; - enum val_prettyprint pretty; -{ - register unsigned int i; - int len, n_baseclasses; - struct type *elttype; - int eltlen; - LONGEST val; - unsigned char c; - - if (pretty == Val_pretty_default) - { - pretty = prettyprint ? Val_prettyprint : Val_no_prettyprint; - } - - QUIT; - - if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) - { - fprintf_filtered (stream, ""); - fflush (stream); - return 0; - } - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: - if (TYPE_LENGTH (type) >= 0 - && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) - { - elttype = TYPE_TARGET_TYPE (type); - eltlen = TYPE_LENGTH (elttype); - len = TYPE_LENGTH (type) / eltlen; - fprintf_filtered (stream, "{"); - /* For an array of chars, print with string syntax. */ - if (eltlen == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT - && format == 0) - print_string (stream, valaddr, len, 0); - else - { - unsigned int things_printed = 0; - - for (i = 0; i < len && things_printed < print_max; i++) - { - /* Position of the array element we are examining to see - whether it is repeated. */ - unsigned int rep1; - /* Number of repititions we have detected so far. */ - unsigned int reps; - - if (i > 0) - fprintf_filtered (stream, ", "); - - rep1 = i + 1; - reps = 1; - while (rep1 < len - && !bcmp (valaddr + i * eltlen, - valaddr + rep1 * eltlen, eltlen)) - { - ++reps; - ++rep1; - } - - if (reps > REPEAT_COUNT_THRESHOLD) - { - val_print (elttype, valaddr + i * eltlen, - 0, stream, format, deref_ref, - recurse + 1, pretty); - fprintf_filtered (stream, " ", reps); - i = rep1 - 1; - things_printed += REPEAT_COUNT_THRESHOLD; - } - else - { - val_print (elttype, valaddr + i * eltlen, - 0, stream, format, deref_ref, - recurse + 1, pretty); - things_printed++; - } - } - if (i < len) - fprintf_filtered (stream, "..."); - } - fprintf_filtered (stream, "}"); - break; - } - /* Array of unspecified length: treat like pointer to first elt. */ - valaddr = (char *) &address; - - case TYPE_CODE_PTR: - if (format) - { - print_scalar_formatted (valaddr, type, format, 0, stream); - break; - } - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_METHOD) - { - struct type *domain = TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)); - struct type *target = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type)); - struct fn_field *f; - int j, len2; - char *kind = ""; - - val = unpack_long (builtin_type_int, valaddr); - if (val < 128) - { - len = TYPE_NFN_FIELDS (domain); - for (i = 0; i < len; i++) - { - f = TYPE_FN_FIELDLIST1 (domain, i); - len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i); - - for (j = 0; j < len2; j++) - { - QUIT; - if (TYPE_FN_FIELD_VOFFSET (f, j) == val) - { - kind = "virtual"; - goto common; - } - } - } - } - else - { - struct symbol *sym = find_pc_function ((CORE_ADDR) val); - if (sym == 0) - error ("invalid pointer to member function"); - len = TYPE_NFN_FIELDS (domain); - for (i = 0; i < len; i++) - { - f = TYPE_FN_FIELDLIST1 (domain, i); - len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i); - - for (j = 0; j < len2; j++) - { - QUIT; - if (!strcmp (SYMBOL_NAME (sym), TYPE_FN_FIELD_PHYSNAME (f, j))) - goto common; - } - } - } - common: - if (i < len) - { - fprintf_filtered (stream, "&"); - type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f, j), stream, 0, 0); - fprintf (stream, kind); - if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_' - && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == '$') - type_print_method_args - (TYPE_FN_FIELD_ARGS (f, j) + 1, "~", - TYPE_FN_FIELDLIST_NAME (domain, i), 0, stream); - else - type_print_method_args - (TYPE_FN_FIELD_ARGS (f, j), "", - TYPE_FN_FIELDLIST_NAME (domain, i), 0, stream); - break; - } - fprintf_filtered (stream, "("); - type_print (type, "", stream, -1); - fprintf_filtered (stream, ") %d", (int) val >> 3); - } - else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_MEMBER) - { - struct type *domain = TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)); - struct type *target = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type)); - char *kind = ""; - - /* VAL is a byte offset into the structure type DOMAIN. - Find the name of the field for that offset and - print it. */ - int extra = 0; - int bits = 0; - len = TYPE_NFIELDS (domain); - /* @@ Make VAL into bit offset */ - val = unpack_long (builtin_type_int, valaddr) << 3; - for (i = 0; i < len; i++) - { - int bitpos = TYPE_FIELD_BITPOS (domain, i); - QUIT; - if (val == bitpos) - break; - if (val < bitpos && i > 0) - { - int ptrsize = (TYPE_LENGTH (builtin_type_char) * TYPE_LENGTH (target)); - /* Somehow pointing into a field. */ - i -= 1; - extra = (val - TYPE_FIELD_BITPOS (domain, i)); - if (extra & 0x3) - bits = 1; - else - extra >>= 3; - break; - } - } - if (i < len) - { - fprintf_filtered (stream, "&"); - type_print_base (domain, stream, 0, 0); - fprintf_filtered (stream, "::"); - fputs_filtered (TYPE_FIELD_NAME (domain, i), stream); - if (extra) - fprintf_filtered (stream, " + %d bytes", extra); - if (bits) - fprintf_filtered (stream, " (offset in bits)"); - break; - } - fprintf_filtered (stream, "%d", (int) val >> 3); - } - else - { - fprintf_filtered (stream, "0x%x", * (int *) valaddr); - /* For a pointer to char or unsigned char, - also print the string pointed to, unless pointer is null. */ - - /* For an array of chars, print with string syntax. */ - elttype = TYPE_TARGET_TYPE (type); - i = 0; /* Number of characters printed. */ - if (TYPE_LENGTH (elttype) == 1 - && TYPE_CODE (elttype) == TYPE_CODE_INT - && format == 0 - && unpack_long (type, valaddr) != 0 - /* If print_max is UINT_MAX, the alloca below will fail. - In that case don't try to print the string. */ - && print_max < UINT_MAX) - { - fprintf_filtered (stream, " "); - - /* Get first character. */ - if (read_memory ( (CORE_ADDR) unpack_long (type, valaddr), - &c, 1)) - { - /* First address out of bounds. */ - fprintf_filtered (stream, "

", - (* (int *) valaddr)); - break; - } - else - { - /* A real string. */ - int out_of_bounds = 0; - char *string = (char *) alloca (print_max); - - /* If the loop ends by us hitting print_max characters, - we need to have elipses at the end. */ - int force_ellipses = 1; - - /* This loop only fetches print_max characters, even - though print_string might want to print more - (with repeated characters). This is so that - we don't spend forever fetching if we print - a long string consisting of the same character - repeated. */ - while (i < print_max) - { - QUIT; - if (read_memory ((CORE_ADDR) unpack_long (type, valaddr) - + i, &c, 1)) - { - out_of_bounds = 1; - force_ellipses = 0; - break; - } - else if (c == '\0') - { - force_ellipses = 0; - break; - } - else - string[i++] = c; - } - - if (i != 0) - print_string (stream, string, i, force_ellipses); - if (out_of_bounds) - fprintf_filtered (stream, - "
", - (*(int *) valaddr) + i); - } - - fflush (stream); - } - /* Return number of characters printed, plus one for the - terminating null if we have "reached the end". */ - return i + (print_max && i != print_max); - } - break; - - case TYPE_CODE_MEMBER: - error ("not implemented: member type in val_print"); - break; - - case TYPE_CODE_REF: - fprintf_filtered (stream, "(0x%x &) = ", * (int *) valaddr); - /* De-reference the reference. */ - if (deref_ref) - { - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF) - { - value val = value_at (TYPE_TARGET_TYPE (type), * (int *) valaddr); - val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), - VALUE_ADDRESS (val), stream, format, - deref_ref, recurse + 1, pretty); - } - else - fprintf_filtered (stream, "???"); - } - break; - - case TYPE_CODE_UNION: - if (recurse && !unionprint) - { - fprintf_filtered (stream, "{...}"); - break; - } - /* Fall through. */ - case TYPE_CODE_STRUCT: - fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); - n_baseclasses = TYPE_N_BASECLASSES (type); - for (i = 1; i <= n_baseclasses; i++) - { - fprintf_filtered (stream, "\n"); - if (pretty) - print_spaces_filtered (2 + 2 * recurse, stream); - fputs_filtered ("<", stream); - fputs_filtered (TYPE_NAME (TYPE_BASECLASS (type, i)), stream); - fputs_filtered ("> = ", stream); - val_print (TYPE_FIELD_TYPE (type, 0), - valaddr + TYPE_FIELD_BITPOS (type, i-1) / 8, - 0, stream, 0, 0, recurse + 1, pretty); - } - if (i > 1) { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - fputs_filtered ("members of ", stream); - fputs_filtered (TYPE_NAME (type), stream); - fputs_filtered (": ", stream); - } - if (!len && i == 1) - fprintf_filtered (stream, ""); - else - { - for (i -= 1; i < len; i++) - { - if (i > n_baseclasses) fprintf_filtered (stream, ", "); - if (pretty) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - } - fputs_filtered (TYPE_FIELD_NAME (type, i), stream); - fputs_filtered (" = ", stream); - /* check if static field */ - if (TYPE_FIELD_STATIC (type, i)) - { - value v; - - v = value_static_field (type, TYPE_FIELD_NAME (type, i), i); - val_print (TYPE_FIELD_TYPE (type, i), - VALUE_CONTENTS (v), 0, stream, format, - deref_ref, recurse + 1, pretty); - } - else if (TYPE_FIELD_PACKED (type, i)) - { - char *valp = (char *) & val; - union {int i; char c;} test; - test.i = 1; - if (test.c != 1) - valp += sizeof val - TYPE_LENGTH (TYPE_FIELD_TYPE (type, i)); - val = unpack_field_as_long (type, valaddr, i); - val_print (TYPE_FIELD_TYPE (type, i), valp, 0, - stream, format, deref_ref, recurse + 1, pretty); - } - else - { - val_print (TYPE_FIELD_TYPE (type, i), - valaddr + TYPE_FIELD_BITPOS (type, i) / 8, - 0, stream, format, deref_ref, - recurse + 1, pretty); - } - } - if (pretty) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 * recurse, stream); - } - } - fprintf_filtered (stream, "}"); - break; - - case TYPE_CODE_ENUM: - if (format) - { - print_scalar_formatted (valaddr, type, format, 0, stream); - break; - } - len = TYPE_NFIELDS (type); - val = unpack_long (builtin_type_int, valaddr); - for (i = 0; i < len; i++) - { - QUIT; - if (val == TYPE_FIELD_BITPOS (type, i)) - break; - } - if (i < len) - fputs_filtered (TYPE_FIELD_NAME (type, i), stream); - else - fprintf_filtered (stream, "%d", (int) val); - break; - - case TYPE_CODE_FUNC: - if (format) - { - print_scalar_formatted (valaddr, type, format, 0, stream); - break; - } - fprintf_filtered (stream, "{"); - type_print (type, "", stream, -1); - fprintf_filtered (stream, "} "); - fprintf_filtered (stream, "0x%x", address); - break; - - case TYPE_CODE_INT: - if (format) - print_scalar_formatted (valaddr, type, format, 0, stream); - else - { - (*default_scalar_print)(stream, type, unpack_long(type, valaddr)); -#ifdef notdef - if (TYPE_LENGTH (type) == 1) - { - fprintf_filtered (stream, " '"); - printchar ((unsigned char) unpack_long (type, valaddr), - stream, '\''); - fprintf_filtered (stream, "'"); - } -#endif - } - break; - - case TYPE_CODE_FLT: - if (format) - print_scalar_formatted (valaddr, type, format, 0, stream); - else - print_floating (valaddr, type, stream); - break; - - case TYPE_CODE_VOID: - fprintf_filtered (stream, "void"); - break; - - default: - error ("Invalid type code in symbol table."); - } - fflush (stream); - return 0; -} - -/* Print a description of a type TYPE - in the form of a declaration of a variable named VARSTRING. - Output goes to STREAM (via stdio). - If SHOW is positive, we show the contents of the outermost level - of structure even if there is a type name that could be used instead. - If SHOW is negative, we never show the details of elements' types. */ - -void -type_print (type, varstring, stream, show) - struct type *type; - char *varstring; - FILE *stream; - int show; -{ - type_print_1 (type, varstring, stream, show, 0); -} - -/* LEVEL is the depth to indent lines by. */ - -void -type_print_1 (type, varstring, stream, show, level) - struct type *type; - char *varstring; - FILE *stream; - int show; - int level; -{ - register enum type_code code; - type_print_base (type, stream, show, level); - code = TYPE_CODE (type); - if ((varstring && *varstring) - || - /* Need a space if going to print stars or brackets; - but not if we will print just a type name. */ - ((show > 0 || TYPE_NAME (type) == 0) - && - (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC - || code == TYPE_CODE_METHOD - || code == TYPE_CODE_ARRAY - || code == TYPE_CODE_MEMBER - || code == TYPE_CODE_REF))) - fprintf_filtered (stream, " "); - type_print_varspec_prefix (type, stream, show, 0); - fputs_filtered (varstring, stream); - type_print_varspec_suffix (type, stream, show, 0); -} - -/* Print the method arguments ARGS to the file STREAM. */ -static void -type_print_method_args (args, prefix, varstring, staticp, stream) - struct type **args; - char *prefix, *varstring; - int staticp; - FILE *stream; -{ - int i; - - fputs_filtered (" ", stream); - fputs_filtered (prefix, stream); - fputs_filtered (varstring, stream); - fputs_filtered (" (", stream); - if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID) - { - i = !staticp; /* skip the class variable */ - while (1) - { - type_print (args[i++], "", stream, 0); - if (!args[i]) - { - fprintf_filtered (stream, " ..."); - break; - } - else if (args[i]->code != TYPE_CODE_VOID) - { - fprintf_filtered (stream, ", "); - } - else break; - } - } - fprintf_filtered (stream, ")"); -} - -/* If TYPE is a derived type, then print out derivation - information. Print out all layers of the type heirarchy - until we encounter one with multiple inheritance. - At that point, print out that ply, and return. */ -static void -type_print_derivation_info (stream, type) - FILE *stream; - struct type *type; -{ - char *name; - int i, n_baseclasses = TYPE_N_BASECLASSES (type); - struct type *basetype = 0; - - while (type && n_baseclasses == 1) - { - basetype = TYPE_BASECLASS (type, 1); - if (TYPE_NAME (basetype) && (name = TYPE_NAME (basetype))) - { - while (*name != ' ') name++; - fprintf_filtered (stream, ": %s%s ", - TYPE_VIA_PUBLIC (basetype) ? "public" : "private", - TYPE_VIA_VIRTUAL (basetype) ? " virtual" : ""); - fputs_filtered (name + 1, stream); - fputs_filtered (" ", stream); - } - n_baseclasses = TYPE_N_BASECLASSES (basetype); - type = basetype; - } - - if (type) - { - if (n_baseclasses != 0) - fprintf_filtered (stream, ": "); - for (i = 1; i <= n_baseclasses; i++) - { - basetype = TYPE_BASECLASS (type, i); - if (TYPE_NAME (basetype) && (name = TYPE_NAME (basetype))) - { - while (*name != ' ') name++; - fprintf_filtered (stream, "%s%s ", - TYPE_VIA_PUBLIC (basetype) ? "public" : "private", - TYPE_VIA_VIRTUAL (basetype) ? " virtual" : ""); - fputs_filtered (name + 1, stream); - } - if (i < n_baseclasses) - fprintf_filtered (stream, ", "); - } - fprintf_filtered (stream, " "); - } -} - -/* Print any asterisks or open-parentheses needed before the - variable name (to describe its type). - - On outermost call, pass 0 for PASSED_A_PTR. - On outermost call, SHOW > 0 means should ignore - any typename for TYPE and show its details. - SHOW is always zero on recursive calls. */ - -static void -type_print_varspec_prefix (type, stream, show, passed_a_ptr) - struct type *type; - FILE *stream; - int show; - int passed_a_ptr; -{ - if (type == 0) - return; - - if (TYPE_NAME (type) && show <= 0) - return; - - QUIT; - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_PTR: - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1); - fprintf_filtered (stream, "*"); - break; - - case TYPE_CODE_MEMBER: - if (passed_a_ptr) - fprintf_filtered (stream, "("); - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - fprintf_filtered (stream, " "); - type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, - passed_a_ptr); - fprintf_filtered (stream, "::"); - break; - - case TYPE_CODE_METHOD: - if (passed_a_ptr) - fprintf (stream, "("); - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - fprintf_filtered (stream, " "); - type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, - passed_a_ptr); - fprintf_filtered (stream, "::"); - break; - - case TYPE_CODE_REF: - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1); - fprintf_filtered (stream, "&"); - break; - - case TYPE_CODE_FUNC: - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - if (passed_a_ptr) - fprintf_filtered (stream, "("); - break; - - case TYPE_CODE_ARRAY: - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - if (passed_a_ptr) - fprintf_filtered (stream, "("); - } -} - -/* Print any array sizes, function arguments or close parentheses - needed after the variable name (to describe its type). - Args work like type_print_varspec_prefix. */ - -static void -type_print_varspec_suffix (type, stream, show, passed_a_ptr) - struct type *type; - FILE *stream; - int show; - int passed_a_ptr; -{ - if (type == 0) - return; - - if (TYPE_NAME (type) && show <= 0) - return; - - QUIT; - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: - if (passed_a_ptr) - fprintf_filtered (stream, ")"); - - fprintf_filtered (stream, "["); - if (TYPE_LENGTH (type) >= 0 - && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) - fprintf_filtered (stream, "%d", - (TYPE_LENGTH (type) - / TYPE_LENGTH (TYPE_TARGET_TYPE (type)))); - fprintf_filtered (stream, "]"); - - type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - break; - - case TYPE_CODE_MEMBER: - if (passed_a_ptr) - fprintf_filtered (stream, ")"); - type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0); - break; - - case TYPE_CODE_METHOD: - if (passed_a_ptr) - fprintf_filtered (stream, ")"); - type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0); - if (passed_a_ptr) - { - int i; - struct type **args = TYPE_ARG_TYPES (type); - - fprintf_filtered (stream, "("); - if (args[1] == 0) - fprintf_filtered (stream, "..."); - else for (i = 1; args[i] != 0 && args[i]->code != TYPE_CODE_VOID; i++) - { - type_print_1 (args[i], "", stream, -1, 0); - if (args[i+1] == 0) - fprintf_filtered (stream, "..."); - else if (args[i+1]->code != TYPE_CODE_VOID) - fprintf_filtered (stream, ","); - } - fprintf_filtered (stream, ")"); - } - break; - - case TYPE_CODE_PTR: - case TYPE_CODE_REF: - type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1); - break; - - case TYPE_CODE_FUNC: - type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, - passed_a_ptr); - if (passed_a_ptr) - fprintf_filtered (stream, ")"); - fprintf_filtered (stream, "()"); - break; - } -} - -/* Print the name of the type (or the ultimate pointer target, - function value or array element), or the description of a - structure or union. - - SHOW nonzero means don't print this type as just its name; - show its real definition even if it has a name. - SHOW zero means print just typename or struct tag if there is one - SHOW negative means abbreviate structure elements. - SHOW is decremented for printing of structure elements. - - LEVEL is the depth to indent by. - We increase it for some recursive calls. */ - -static void -type_print_base (type, stream, show, level) - struct type *type; - FILE *stream; - int show; - int level; -{ - char *name; - register int i; - register int len; - register int lastval; - - QUIT; - - if (type == 0) - { - fprintf_filtered (stream, "type unknown"); - return; - } - - if (TYPE_NAME (type) && show <= 0) - { - fputs_filtered (TYPE_NAME (type), stream); - return; - } - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: - case TYPE_CODE_PTR: - case TYPE_CODE_MEMBER: - case TYPE_CODE_REF: - case TYPE_CODE_FUNC: - case TYPE_CODE_METHOD: - type_print_base (TYPE_TARGET_TYPE (type), stream, show, level); - break; - - case TYPE_CODE_STRUCT: - fprintf_filtered (stream, "struct "); - goto struct_union; - - case TYPE_CODE_UNION: - fprintf_filtered (stream, "union "); - struct_union: - if (TYPE_NAME (type) && (name = TYPE_NAME (type))) - { - while (*name != ' ') name++; - fputs_filtered (name + 1, stream); - fputs_filtered (" ", stream); - } - if (show < 0) - fprintf_filtered (stream, "{...}"); - else - { - int i; - - type_print_derivation_info (stream, type); - - fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); - if (len) - fprintf_filtered (stream, "\n"); - else - { - if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) - fprintf_filtered (stream, "\n"); - else - fprintf_filtered (stream, "\n"); - } - - /* If there is a base class for this type, - do not print the field that it occupies. */ - for (i = TYPE_N_BASECLASSES (type); i < len; i++) - { - QUIT; - /* Don't print out virtual function table. */ - if (! strncmp (TYPE_FIELD_NAME (type, i), - "_vptr$", 6)) - continue; - - print_spaces_filtered (level + 4, stream); - if (TYPE_FIELD_STATIC (type, i)) - { - fprintf_filtered (stream, "static "); - } - type_print_1 (TYPE_FIELD_TYPE (type, i), - TYPE_FIELD_NAME (type, i), - stream, show - 1, level + 4); - if (!TYPE_FIELD_STATIC (type, i) - && TYPE_FIELD_PACKED (type, i)) - { - /* It is a bitfield. This code does not attempt - to look at the bitpos and reconstruct filler, - unnamed fields. This would lead to misleading - results if the compiler does not put out fields - for such things (I don't know what it does). */ - fprintf_filtered (stream, " : %d", - TYPE_FIELD_BITSIZE (type, i)); - } - fprintf_filtered (stream, ";\n"); - } - - /* C++: print out the methods */ - len = TYPE_NFN_FIELDS (type); - if (len) fprintf_filtered (stream, "\n"); - for (i = 0; i < len; i++) - { - struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); - int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); - - for (j = 0; j < len2; j++) - { - QUIT; - print_spaces_filtered (level + 4, stream); - if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) - fprintf_filtered (stream, "virtual "); - else if (TYPE_FN_FIELD_STATIC_P (f, j)) - fprintf_filtered (stream, "static "); - type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), "", stream, 0); - if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_' - && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == '$') - type_print_method_args - (TYPE_FN_FIELD_ARGS (f, j) + 1, "~", - TYPE_FN_FIELDLIST_NAME (type, i), 0, stream); - else - type_print_method_args - (TYPE_FN_FIELD_ARGS (f, j), "", - TYPE_FN_FIELDLIST_NAME (type, i), - TYPE_FN_FIELD_STATIC_P (f, j), stream); - - fprintf_filtered (stream, ";\n"); - } - if (len2) fprintf_filtered (stream, "\n"); - } - - print_spaces_filtered (level, stream); - fprintf_filtered (stream, "}"); - } - break; - - case TYPE_CODE_ENUM: - fprintf_filtered (stream, "enum "); - if (TYPE_NAME (type)) - { - name = TYPE_NAME (type); - while (*name != ' ') name++; - fputs_filtered (name + 1, stream); - fputs_filtered (" ", stream); - } - if (show < 0) - fprintf_filtered (stream, "{...}"); - else - { - fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); - lastval = 0; - for (i = 0; i < len; i++) - { - QUIT; - if (i) fprintf_filtered (stream, ", "); - fputs_filtered (TYPE_FIELD_NAME (type, i), stream); - if (lastval != TYPE_FIELD_BITPOS (type, i)) - { - fprintf_filtered (stream, " : %d", TYPE_FIELD_BITPOS (type, i)); - lastval = TYPE_FIELD_BITPOS (type, i); - } - lastval++; - } - fprintf_filtered (stream, "}"); - } - break; - - case TYPE_CODE_INT: - if (TYPE_UNSIGNED (type)) - name = unsigned_type_table[TYPE_LENGTH (type)]; - else - name = signed_type_table[TYPE_LENGTH (type)]; - fputs_filtered (name, stream); - break; - - case TYPE_CODE_FLT: - name = float_type_table[TYPE_LENGTH (type)]; - fputs_filtered (name, stream); - break; - - case TYPE_CODE_VOID: - fprintf_filtered (stream, "void"); - break; - - case 0: - fprintf_filtered (stream, "struct unknown"); - break; - - default: - error ("Invalid type code in symbol table."); - } -} - -static void -scalar_print_decimal(stream, type, val) - FILE *stream; - struct type *type; - LONGEST val; -{ -#ifdef LONG_LONG - fprintf_filtered(stream, TYPE_UNSIGNED(type)? "%qu":"%qd", val); -#else - fprintf_filtered(stream, TYPE_UNSIGNED(type)? "%lu":"%ld", val); -#endif -} - -static void -scalar_print_hex(stream, type, val) - FILE *stream; - struct type *type; - LONGEST val; -{ - switch (TYPE_LENGTH(type)) { - case 1: - fprintf_filtered (stream, "0x%02lx", (long) val); - break; - case 2: - fprintf_filtered (stream, "0x%04lx", (long) val); - break; - case 4: - fprintf_filtered (stream, "0x%08lx", (long) val); - break; - default: -#ifdef LONG_LONG - fprintf_filtered (stream, "0x%qx", val); -#else - fprintf_filtered (stream, "0x%lx", val); -#endif - break; - } -} - -static void -scalar_print_octal(stream, type, val) - FILE *stream; - struct type *type; - LONGEST val; -{ - switch (TYPE_LENGTH(type)) { - case 1: - fprintf_filtered (stream, "0%03lo", (long) val); - break; - case 2: - fprintf_filtered (stream, "0%06lo", (long) val); - break; - case 4: - fprintf_filtered (stream, "0%012lo", (long) val); - break; - default: -#ifdef LONG_LONG - fprintf_filtered (stream, "0%lo", val); -#else - fprintf_filtered (stream, "0%qo", val); -#endif - break; - } -} - -static void -scalar_print_hack(stream, type, val) - FILE *stream; - struct type *type; - LONGEST val; -{ - if (TYPE_UNSIGNED(type)) - scalar_print_hex(stream, type, val); - else - scalar_print_decimal(stream, type, val); -} - -static void -set_maximum_command (arg) - char *arg; -{ - if (!arg) error_no_arg ("value for maximum elements to print"); - print_max = parse_and_eval_address (arg); - if (print_max == 0) - print_max = UINT_MAX; -} - -static void -set_base_command(arg) - char *arg; -{ - int base; - - if (!arg) - base = 0; - else - base = parse_and_eval_address (arg); - switch (base) { - default: - default_scalar_print = scalar_print_hack; - break; - case 8: - default_scalar_print = scalar_print_octal; - break; - case 10: - default_scalar_print = scalar_print_decimal; - break; - case 16: - default_scalar_print = scalar_print_hex; - break; - } -} - -static void -set_prettyprint_command (arg, from_tty) - char *arg; - int from_tty; -{ - prettyprint = parse_binary_operation ("set prettyprint", arg); -} - -static void -set_unionprint_command (arg, from_tty) - char *arg; - int from_tty; -{ - unionprint = parse_binary_operation ("set unionprint", arg); -} - -format_info (arg, from_tty) - char *arg; - int from_tty; -{ - if (arg) - error ("\"info format\" does not take any arguments."); - printf ("Prettyprinting of structures is %s.\n", - prettyprint ? "on" : "off"); - printf ("Printing of unions interior to structures is %s.\n", - unionprint ? "on" : "off"); - if (print_max == UINT_MAX) - printf_filtered - ("There is no maximum number of array elements printed.\n"); - else - printf_filtered - ("The maximum number of array elements printed is %d.\n", print_max); -} - -extern struct cmd_list_element *setlist; - -void -_initialize_valprint () -{ - add_cmd ("base", class_support, set_base_command, - "Change default integer print radix to 8, 10 or 16\n\ -No args returns to the ad-hoc default of `16' for unsigned values\n\ -and `10' otherwise.", - &setlist); - add_cmd ("array-max", class_vars, set_maximum_command, - "Set NUMBER as limit on string chars or array elements to print.\n\ -\"set array-max 0\" causes there to be no limit.", - &setlist); - - add_cmd ("prettyprint", class_support, set_prettyprint_command, - "Turn prettyprinting of structures on and off.", - &setlist); - add_alias_cmd ("pp", "prettyprint", class_support, 1, &setlist); - - add_cmd ("unionprint", class_support, set_unionprint_command, - "Turn printing of unions interior to structures on and off.", - &setlist); - - add_info ("format", format_info, - "Show current settings of data formatting options."); - - /* Give people the defaults which they are used to. */ - prettyprint = 0; - unionprint = 1; - - print_max = 200; - - unsigned_type_table - = (char **) xmalloc ((1 + sizeof (unsigned LONGEST)) * sizeof (char *)); - bzero (unsigned_type_table, (1 + sizeof (unsigned LONGEST))); - unsigned_type_table[sizeof (unsigned char)] = "unsigned char"; - unsigned_type_table[sizeof (unsigned short)] = "unsigned short"; - unsigned_type_table[sizeof (unsigned long)] = "unsigned long"; - unsigned_type_table[sizeof (unsigned int)] = "unsigned int"; -#ifdef LONG_LONG - unsigned_type_table[sizeof (unsigned long long)] = "unsigned long long"; -#endif - - signed_type_table - = (char **) xmalloc ((1 + sizeof (LONGEST)) * sizeof (char *)); - bzero (signed_type_table, (1 + sizeof (LONGEST))); - signed_type_table[sizeof (char)] = "char"; - signed_type_table[sizeof (short)] = "short"; - signed_type_table[sizeof (long)] = "long"; - signed_type_table[sizeof (int)] = "int"; -#ifdef LONG_LONG - signed_type_table[sizeof (long long)] = "long long"; -#endif - - float_type_table - = (char **) xmalloc ((1 + sizeof (double)) * sizeof (char *)); - bzero (float_type_table, (1 + sizeof (double))); - float_type_table[sizeof (float)] = "float"; - float_type_table[sizeof (double)] = "double"; -} - diff --git a/gnu/usr.bin/gdb/value.h b/gnu/usr.bin/gdb/value.h deleted file mode 100644 index d88249304af2..000000000000 --- a/gnu/usr.bin/gdb/value.h +++ /dev/null @@ -1,215 +0,0 @@ -/* Definitions for values of C expressions, for GDB. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: value.h,v 1.2 1993/08/02 17:41:12 mycroft Exp $ -*/ - -/* - * The structure which defines the type of a value. It should never - * be possible for a program lval value to survive over a call to the inferior - * (ie to be put into the history list or an internal variable). - */ -enum lval_type { - /* Not an lval. */ - not_lval, - /* In memory. Could be a saved register. */ - lval_memory, - /* In a register. */ - lval_register, - /* In a gdb internal variable. */ - lval_internalvar, - /* Part of a gdb internal variable (structure field). */ - lval_internalvar_component, - /* In a register series in a frame not the current one, which may have been - partially saved or saved in different places (otherwise would be - lval_register or lval_memory). */ - lval_reg_frame_relative, -}; - -struct value - { - /* Type of value; either not an lval, or one of the various - different possible kinds of lval. */ - enum lval_type lval; - /* Location of value (if lval). */ - union - { - /* Address in inferior or byte of registers structure. */ - CORE_ADDR address; - /* Pointer to interrnal variable. */ - struct internalvar *internalvar; - /* Number of register. Only used with - lval_reg_frame_relative. */ - int regnum; - } location; - /* Describes offset of a value within lval a structure in bytes. */ - int offset; - /* Only used for bitfields; number of bits contained in them. */ - int bitsize; - /* Only used for bitfields; position of start of field. */ - int bitpos; - /* Frame value is relative to. In practice, this address is only - used if the value is stored in several registers in other than - the current frame, and these registers have not all been saved - at the same place in memory. This will be described in the - lval enum above as "lval_reg_frame_relative". */ - CORE_ADDR frame_addr; - /* Type of the value. */ - struct type *type; - /* Values are stored in a chain, so that they can be deleted - easily over calls to the inferior. Values assigned to internal - variables or put into the value history are taken off this - list. */ - struct value *next; - /* If an lval is forced to repeat, a new value is created with - these fields set. The new value is not an lval. */ - short repeated; - short repetitions; - /* Register number if the value is from a register. Is not kept - if you take a field of a structure that is stored in a - register. Shouldn't it be? */ - short regno; - /* Actual contents of the value. For use of this value; setting - it uses the stuff above. */ - long contents[1]; - }; - -typedef struct value *value; - -#define VALUE_TYPE(val) (val)->type -#define VALUE_CONTENTS(val) ((char *) (val)->contents) -#define VALUE_LVAL(val) (val)->lval -#define VALUE_ADDRESS(val) (val)->location.address -#define VALUE_INTERNALVAR(val) (val)->location.internalvar -#define VALUE_FRAME_REGNUM(val) ((val)->location.regnum) -#define VALUE_FRAME(val) ((val)->frame_addr) -#define VALUE_OFFSET(val) (val)->offset -#define VALUE_BITSIZE(val) (val)->bitsize -#define VALUE_BITPOS(val) (val)->bitpos -#define VALUE_NEXT(val) (val)->next -#define VALUE_REPEATED(val) (val)->repeated -#define VALUE_REPETITIONS(val) (val)->repetitions -#define VALUE_REGNO(val) (val)->regno - -/* If ARG is an array, convert it to a pointer. - If ARG is an enum, convert it to an integer. - - References are dereferenced. */ - -#define COERCE_ARRAY(arg) \ -{ if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \ - arg = value_ind (arg); \ - if (VALUE_REPEATED (arg) \ - || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY) \ - arg = value_coerce_array (arg); \ - if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \ - arg = value_cast (builtin_type_unsigned_int, arg); \ -} - -/* If ARG is an enum, convert it to an integer. */ - -#define COERCE_ENUM(arg) \ -{ if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \ - arg = value_ind (arg); \ - if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \ - arg = value_cast (builtin_type_unsigned_int, arg); \ -} - -/* Internal variables (variables for convenience of use of debugger) - are recorded as a chain of these structures. */ - -struct internalvar -{ - struct internalvar *next; - char *name; - value value; -}; - -LONGEST value_as_long (); -double value_as_double (); -LONGEST unpack_long (); -double unpack_double (); -long unpack_field_as_long (); -value value_from_long (); -value value_from_double (); -value value_at (); -value value_from_register (); -value value_of_variable (); -value value_of_register (); -value read_var_value (); -value locate_var_value (); -value allocate_value (); -value allocate_repeat_value (); -value value_string (); - -value value_binop (); -value value_add (); -value value_sub (); -value value_coerce_array (); -value value_ind (); -value value_addr (); -value value_assign (); -value value_neg (); -value value_lognot (); -value value_struct_elt (), value_struct_elt_for_address (); -value value_field (); -value value_cast (); -value value_zero (); -value value_repeat (); -value value_subscript (); - -value call_function (); -value value_being_returned (); -int using_struct_return (); - -value evaluate_expression (); -value evaluate_type (); -value parse_and_eval (); -value parse_to_comma_and_eval (); - -value access_value_history (); -value value_of_internalvar (); -struct internalvar *lookup_internalvar (); - -int value_equal (); -int value_less (); -int value_zerop (); - -/* C++ */ -value value_of_this (); -value value_static_field (); -value value_x_binop (); -value value_x_unop (); -int binop_user_defined_p (); -int unop_user_defined_p (); - -void read_register_bytes (); -void modify_field (); -void type_print (); -void type_print_1 (); - -/* Possibilities for prettyprint parameters to routines which print - things. */ -enum val_prettyprint { - Val_no_prettyprint = 0, - Val_prettyprint, - /* Use the default setting which the user has specified. */ - Val_pretty_default - }; - diff --git a/gnu/usr.bin/gdb/values.c b/gnu/usr.bin/gdb/values.c deleted file mode 100644 index f7ade9dd0c5f..000000000000 --- a/gnu/usr.bin/gdb/values.c +++ /dev/null @@ -1,1060 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * Modified 1990 by Van Jacobson at Lawrence Berkeley Laboratory. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)values.c 6.3 (Berkeley) 5/8/91";*/ -static char rcsid[] = "$Id: values.c,v 1.2 1993/08/01 18:47:30 mycroft Exp $"; -#endif /* not lint */ - -/* Low level packing and unpacking of values for GDB. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "value.h" - -/* The value-history records all the values printed - by print commands during this session. Each chunk - records 60 consecutive values. The first chunk on - the chain records the most recent values. - The total number of values is in value_history_count. */ - -#define VALUE_HISTORY_CHUNK 60 - -struct value_history_chunk -{ - struct value_history_chunk *next; - value values[VALUE_HISTORY_CHUNK]; -}; - -/* Chain of chunks now in use. */ - -static struct value_history_chunk *value_history_chain; - -static int value_history_count; /* Abs number of last entry stored */ - - -/* List of all value objects currently allocated - (except for those released by calls to release_value) - This is so they can be freed after each command. */ - -static value all_values; - -/* Allocate a value that has the correct length for type TYPE. */ - -value -allocate_value (type) - struct type *type; -{ - register value val; - - /* If the type we want had no definition in the file it first - * appeared in, it will be marked a `stub'. The real definition - * probably appeared later so try to find it. */ - if (TYPE_FLAGS(type) & TYPE_FLAG_STUB) - { - register char *cp; - register struct symbol *sym; - extern char *index(); - - if (cp = index(TYPE_NAME(type), ' ')) - ++cp; - else - cp = TYPE_NAME(type); - - sym = lookup_symbol(cp, 0, STRUCT_NAMESPACE, 0); - - if (sym && TYPE_CODE(SYMBOL_TYPE(sym)) == TYPE_CODE(type)) - bcopy (SYMBOL_TYPE (sym), type, sizeof (*type)); - } - val = (value) xmalloc (sizeof (struct value) + TYPE_LENGTH (type)); - VALUE_NEXT (val) = all_values; - all_values = val; - VALUE_TYPE (val) = type; - VALUE_LVAL (val) = not_lval; - VALUE_ADDRESS (val) = 0; - VALUE_FRAME (val) = 0; - VALUE_OFFSET (val) = 0; - VALUE_BITPOS (val) = 0; - VALUE_BITSIZE (val) = 0; - VALUE_REPEATED (val) = 0; - VALUE_REPETITIONS (val) = 0; - VALUE_REGNO (val) = -1; - return val; -} - -/* Allocate a value that has the correct length - for COUNT repetitions type TYPE. */ - -value -allocate_repeat_value (type, count) - struct type *type; - int count; -{ - register value val; - - val = (value) xmalloc (sizeof (struct value) + TYPE_LENGTH (type) * count); - VALUE_NEXT (val) = all_values; - all_values = val; - VALUE_TYPE (val) = type; - VALUE_LVAL (val) = not_lval; - VALUE_ADDRESS (val) = 0; - VALUE_FRAME (val) = 0; - VALUE_OFFSET (val) = 0; - VALUE_BITPOS (val) = 0; - VALUE_BITSIZE (val) = 0; - VALUE_REPEATED (val) = 1; - VALUE_REPETITIONS (val) = count; - VALUE_REGNO (val) = -1; - return val; -} - -/* Free all the values that have been allocated (except for those released). - Called after each command, successful or not. */ - -void -free_all_values () -{ - register value val, next; - - for (val = all_values; val; val = next) - { - next = VALUE_NEXT (val); - free (val); - } - - all_values = 0; -} - -/* Remove VAL from the chain all_values - so it will not be freed automatically. */ - -void -release_value (val) - register value val; -{ - register value v; - - if (all_values == val) - { - all_values = val->next; - return; - } - - for (v = all_values; v; v = v->next) - { - if (v->next == val) - { - v->next = val->next; - break; - } - } -} - -/* Return a copy of the value ARG. - It contains the same contents, for same memory address, - but it's a different block of storage. */ - -static value -value_copy (arg) - value arg; -{ - register value val; - register struct type *type = VALUE_TYPE (arg); - if (VALUE_REPEATED (arg)) - val = allocate_repeat_value (type, VALUE_REPETITIONS (arg)); - else - val = allocate_value (type); - VALUE_LVAL (val) = VALUE_LVAL (arg); - VALUE_ADDRESS (val) = VALUE_ADDRESS (arg); - VALUE_OFFSET (val) = VALUE_OFFSET (arg); - VALUE_BITPOS (val) = VALUE_BITPOS (arg); - VALUE_BITSIZE (val) = VALUE_BITSIZE (arg); - VALUE_REGNO (val) = VALUE_REGNO (arg); - bcopy (VALUE_CONTENTS (arg), VALUE_CONTENTS (val), - TYPE_LENGTH (VALUE_TYPE (arg)) - * (VALUE_REPEATED (arg) ? VALUE_REPETITIONS (arg) : 1)); - return val; -} - -/* Access to the value history. */ - -/* Record a new value in the value history. - Returns the absolute history index of the entry. */ - -int -record_latest_value (val) - value val; -{ - int i; - double foo; - - /* Check error now if about to store an invalid float. We return -1 - to the caller, but allow them to continue, e.g. to print it as "Nan". */ - if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FLT) { - foo = unpack_double (VALUE_TYPE (val), VALUE_CONTENTS (val), &i); - if (i) return -1; /* Indicate value not saved in history */ - } - - /* Here we treat value_history_count as origin-zero - and applying to the value being stored now. */ - - i = value_history_count % VALUE_HISTORY_CHUNK; - if (i == 0) - { - register struct value_history_chunk *new - = (struct value_history_chunk *) - xmalloc (sizeof (struct value_history_chunk)); - bzero (new->values, sizeof new->values); - new->next = value_history_chain; - value_history_chain = new; - } - - value_history_chain->values[i] = val; - release_value (val); - - /* Now we regard value_history_count as origin-one - and applying to the value just stored. */ - - return ++value_history_count; -} - -/* Return a copy of the value in the history with sequence number NUM. */ - -value -access_value_history (num) - int num; -{ - register struct value_history_chunk *chunk; - register int i; - register int absnum = num; - - if (absnum <= 0) - absnum += value_history_count; - - if (absnum <= 0) - { - if (num == 0) - error ("The history is empty."); - else if (num == 1) - error ("There is only one value in the history."); - else - error ("History does not go back to $$%d.", -num); - } - if (absnum > value_history_count) - error ("History has not yet reached $%d.", absnum); - - absnum--; - - /* Now absnum is always absolute and origin zero. */ - - chunk = value_history_chain; - for (i = (value_history_count - 1) / VALUE_HISTORY_CHUNK - absnum / VALUE_HISTORY_CHUNK; - i > 0; i--) - chunk = chunk->next; - - return value_copy (chunk->values[absnum % VALUE_HISTORY_CHUNK]); -} - -/* Clear the value history entirely. - Must be done when new symbol tables are loaded, - because the type pointers become invalid. */ - -void -clear_value_history () -{ - register struct value_history_chunk *next; - register int i; - register value val; - - while (value_history_chain) - { - for (i = 0; i < VALUE_HISTORY_CHUNK; i++) - if (val = value_history_chain->values[i]) - free (val); - next = value_history_chain->next; - free (value_history_chain); - value_history_chain = next; - } - value_history_count = 0; -} - -static void -value_history_info (num_exp, from_tty) - char *num_exp; - int from_tty; -{ - register int i; - register value val; - static int num = 1; - - if (num_exp) - { - if (num_exp[0] == '+' && num_exp[1] == '\0') - /* "info history +" should print from the stored position. */ - ; - else - /* "info history " should print around value number . */ - num = parse_and_eval_address (num_exp) - 5; - } - else - { - /* "info history" means print the last 10 values. */ - num = value_history_count - 9; - } - - if (num <= 0) - num = 1; - - for (i = num; i < num + 10 && i <= value_history_count; i++) - { - val = access_value_history (i); - printf_filtered ("$%d = ", i); - value_print (val, stdout, 0, Val_pretty_default); - printf_filtered ("\n"); - } - - /* The next "info history +" should start after what we just printed. */ - num += 10; - - /* Hitting just return after this command should do the same thing as - "info history +". If num_exp is null, this is unnecessary, since - "info history +" is not useful after "info history". */ - if (from_tty && num_exp) - { - num_exp[0] = '+'; - num_exp[1] = '\0'; - } -} - -/* Internal variables. These are variables within the debugger - that hold values assigned by debugger commands. - The user refers to them with a '$' prefix - that does not appear in the variable names stored internally. */ - -static struct internalvar *internalvars; - -/* Look up an internal variable with name NAME. NAME should not - normally include a dollar sign. - - If the specified internal variable does not exist, - one is created, with a void value. */ - -struct internalvar * -lookup_internalvar (name) - char *name; -{ - register struct internalvar *var; - - for (var = internalvars; var; var = var->next) - if (!strcmp (var->name, name)) - return var; - - var = (struct internalvar *) xmalloc (sizeof (struct internalvar)); - var->name = concat (name, "", ""); - var->value = allocate_value (builtin_type_void); - release_value (var->value); - var->next = internalvars; - internalvars = var; - return var; -} - -value -value_of_internalvar (var) - struct internalvar *var; -{ - register value val; - -#ifdef IS_TRAPPED_INTERNALVAR - if (IS_TRAPPED_INTERNALVAR (var->name)) - return VALUE_OF_TRAPPED_INTERNALVAR (var); -#endif - - val = value_copy (var->value); - VALUE_LVAL (val) = lval_internalvar; - VALUE_INTERNALVAR (val) = var; - return val; -} - -void -set_internalvar_component (var, offset, bitpos, bitsize, newval) - struct internalvar *var; - int offset, bitpos, bitsize; - value newval; -{ - register char *addr = VALUE_CONTENTS (var->value) + offset; - -#ifdef IS_TRAPPED_INTERNALVAR - if (IS_TRAPPED_INTERNALVAR (var->name)) - SET_TRAPPED_INTERNALVAR (var, newval, bitpos, bitsize, offset); -#endif - - if (bitsize) - modify_field (addr, (int) value_as_long (newval), - bitpos, bitsize); - else - bcopy (VALUE_CONTENTS (newval), addr, - TYPE_LENGTH (VALUE_TYPE (newval))); -} - -void -set_internalvar (var, val) - struct internalvar *var; - value val; -{ -#ifdef IS_TRAPPED_INTERNALVAR - if (IS_TRAPPED_INTERNALVAR (var->name)) - SET_TRAPPED_INTERNALVAR (var, val, 0, 0, 0); -#endif - - free (var->value); - var->value = value_copy (val); - release_value (var->value); -} - -char * -internalvar_name (var) - struct internalvar *var; -{ - return var->name; -} - -/* Free all internalvars. Done when new symtabs are loaded, - because that makes the values invalid. */ - -void -clear_internalvars () -{ - register struct internalvar *var; - - while (internalvars) - { - var = internalvars; - internalvars = var->next; - free (var->name); - free (var->value); - free (var); - } -} - -static void -convenience_info () -{ - register struct internalvar *var; - int varseen = 0; - - for (var = internalvars; var; var = var->next) - { -#ifdef IS_TRAPPED_INTERNALVAR - if (IS_TRAPPED_INTERNALVAR (var->name)) - continue; -#endif - if (!varseen) - { - printf ("Debugger convenience variables:\n\n"); - varseen = 1; - } - printf ("$%s: ", var->name); - value_print (var->value, stdout, 0, Val_pretty_default); - printf ("\n"); - } - if (!varseen) - printf ("No debugger convenience variables now defined.\n\ -Convenience variables have names starting with \"$\";\n\ -use \"set\" as in \"set $foo = 5\" to define them.\n"); -} - -/* Extract a value as a C number (either long or double). - Knows how to convert fixed values to double, or - floating values to long. - Does not deallocate the value. */ - -LONGEST -value_as_long (val) - register value val; -{ - return unpack_long (VALUE_TYPE (val), VALUE_CONTENTS (val)); -} - -double -value_as_double (val) - register value val; -{ - double foo; - int inv; - - foo = unpack_double (VALUE_TYPE (val), VALUE_CONTENTS (val), &inv); - if (inv) - error ("Invalid floating value found in program."); - return foo; -} - -/* Unpack raw data (copied from debugee) at VALADDR - as a long, or as a double, assuming the raw data is described - by type TYPE. Knows how to convert different sizes of values - and can convert between fixed and floating point. - - C++: It is assumed that the front-end has taken care of - all matters concerning pointers to members. A pointer - to member which reaches here is considered to be equivalent - to an INT (or some size). After all, it is only an offset. */ - -LONGEST -unpack_long (type, valaddr) - struct type *type; - char *valaddr; -{ - register enum type_code code = TYPE_CODE (type); - register int len = TYPE_LENGTH (type); - register int nosign = TYPE_UNSIGNED (type); - - if (code == TYPE_CODE_ENUM) - code = TYPE_CODE_INT; - if (code == TYPE_CODE_FLT) - { - if (len == sizeof (float)) - return * (float *) valaddr; - - if (len == sizeof (double)) - return * (double *) valaddr; - } - else if (code == TYPE_CODE_INT && nosign) - { - if (len == sizeof (char)) - return * (unsigned char *) valaddr; - - if (len == sizeof (short)) - return * (unsigned short *) valaddr; - - if (len == sizeof (int)) - return * (unsigned int *) valaddr; - - if (len == sizeof (long)) - return * (unsigned long *) valaddr; -#ifdef LONG_LONG - if (len == sizeof (long long)) - return * (unsigned long long *) valaddr; -#endif - } - else if (code == TYPE_CODE_INT) - { - if (len == sizeof (char)) - return * (char *) valaddr; - - if (len == sizeof (short)) - return * (short *) valaddr; - - if (len == sizeof (int)) - return * (int *) valaddr; - - if (len == sizeof (long)) - return * (long *) valaddr; - -#ifdef LONG_LONG - if (len == sizeof (long long)) - return * (long long *) valaddr; -#endif - } - else if (code == TYPE_CODE_PTR - || code == TYPE_CODE_REF) - { - if (len == sizeof (char *)) - return (CORE_ADDR) * (char **) valaddr; - } - else if (code == TYPE_CODE_MEMBER) - error ("not implemented: member types in unpack_long"); - - error ("Value not integer or pointer."); -} - -/* Return a double value from the specified type and address. - INVP points to an int which is set to 0 for valid value, - 1 for invalid value (bad float format). In either case, - the returned double is OK to use. */ - -double -unpack_double (type, valaddr, invp) - struct type *type; - char *valaddr; - int *invp; -{ - register enum type_code code = TYPE_CODE (type); - register int len = TYPE_LENGTH (type); - register int nosign = TYPE_UNSIGNED (type); - - *invp = 0; /* Assume valid. */ - if (code == TYPE_CODE_FLT) - { - if (INVALID_FLOAT (valaddr, len)) - { - *invp = 1; - return 1.234567891011121314; - } - - if (len == sizeof (float)) - return * (float *) valaddr; - - if (len == sizeof (double)) - { - /* Some machines require doubleword alignment for doubles. - This code works on them, and on other machines. */ - double temp; - bcopy ((char *) valaddr, (char *) &temp, sizeof (double)); - return temp; - } - } - else if (code == TYPE_CODE_INT && nosign) - { - if (len == sizeof (char)) - return * (unsigned char *) valaddr; - - if (len == sizeof (short)) - return * (unsigned short *) valaddr; - - if (len == sizeof (int)) - return * (unsigned int *) valaddr; - - if (len == sizeof (long)) - return * (unsigned long *) valaddr; - -#ifdef LONG_LONG - if (len == sizeof (long long)) - return * (unsigned long long *) valaddr; -#endif - } - else if (code == TYPE_CODE_INT) - { - if (len == sizeof (char)) - return * (char *) valaddr; - - if (len == sizeof (short)) - return * (short *) valaddr; - - if (len == sizeof (int)) - return * (int *) valaddr; - - if (len == sizeof (long)) - return * (long *) valaddr; - -#ifdef LONG_LONG - if (len == sizeof (long long)) - return * (long long *) valaddr; -#endif - } - - error ("Value not floating number."); - /* NOTREACHED */ - return (double) 0; /* To silence compiler warning. */ -} - -/* Given a value ARG1 of a struct or union type, - extract and return the value of one of its fields. - FIELDNO says which field. - - For C++, must also be able to return values from static fields */ - -value -value_field (arg1, fieldno) - register value arg1; - register int fieldno; -{ - register value v; - register struct type *type = TYPE_FIELD_TYPE (VALUE_TYPE (arg1), fieldno); - register int offset; - - /* Handle packed fields */ - - offset = TYPE_FIELD_BITPOS (VALUE_TYPE (arg1), fieldno) / 8; - if (TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno)) - { - v = value_from_long (type, - unpack_field_as_long (VALUE_TYPE (arg1), - VALUE_CONTENTS (arg1), - fieldno)); - VALUE_BITPOS (v) = TYPE_FIELD_BITPOS (VALUE_TYPE (arg1), fieldno) % 8; - VALUE_BITSIZE (v) = TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno); - } - else - { - v = allocate_value (type); - bcopy (VALUE_CONTENTS (arg1) + offset, - VALUE_CONTENTS (v), - TYPE_LENGTH (type)); - } - VALUE_LVAL (v) = VALUE_LVAL (arg1); - if (VALUE_LVAL (arg1) == lval_internalvar) - VALUE_LVAL (v) = lval_internalvar_component; - VALUE_ADDRESS (v) = VALUE_ADDRESS (arg1); - VALUE_OFFSET (v) = offset + VALUE_OFFSET (arg1); - return v; -} - -value -value_fn_field (arg1, fieldno, subfieldno) - register value arg1; - register int fieldno; -{ - register value v; - struct fn_field *f = TYPE_FN_FIELDLIST1 (VALUE_TYPE (arg1), fieldno); - register struct type *type = TYPE_FN_FIELD_TYPE (f, subfieldno); - struct symbol *sym; - - sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, subfieldno), - 0, VAR_NAMESPACE, 0); - if (! sym) error ("Internal error: could not find physical method named %s", - TYPE_FN_FIELD_PHYSNAME (f, subfieldno)); - - v = allocate_value (type); - VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); - VALUE_TYPE (v) = type; - return v; -} - -/* Return a virtual function as a value. - ARG1 is the object which provides the virtual function - table pointer. - F is the list of member functions which contains the desired virtual - function. - J is an index into F which provides the desired virtual function. - TYPE is the basetype which first provides the virtual function table. */ -value -value_virtual_fn_field (arg1, f, j, type) - value arg1; - struct fn_field *f; - int j; - struct type *type; -{ - /* First, get the virtual function table pointer. That comes - with a strange type, so cast it to type `pointer to long' (which - should serve just fine as a function type). Then, index into - the table, and convert final value to appropriate function type. */ - value vfn, vtbl; - value vi = value_from_long (builtin_type_int, - (LONGEST) TYPE_FN_FIELD_VOFFSET (f, j)); - VALUE_TYPE (arg1) = TYPE_VPTR_BASETYPE (type); - - /* This type may have been defined before its virtual function table - was. If so, fill in the virtual function table entry for the - type now. */ - if (TYPE_VPTR_FIELDNO (type) < 0) - TYPE_VPTR_FIELDNO (type) - = fill_in_vptr_fieldno (type); - - /* The virtual function table is now an array of structures - which have the form { int16 offset, delta; void *pfn; }. */ - vtbl = value_ind (value_field (arg1, TYPE_VPTR_FIELDNO (type))); - - /* Index into the virtual function table. This is hard-coded because - looking up a field is not cheap, and it may be important to save - time, e.g. if the user has set a conditional breakpoint calling - a virtual function. */ - vfn = value_field (value_subscript (vtbl, vi), 2); - - /* Reinstantiate the function pointer with the correct type. */ - VALUE_TYPE (vfn) = lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j)); - return vfn; -} - -/* The value of a static class member does not depend - on its instance, only on its type. If FIELDNO >= 0, - then fieldno is a valid field number and is used directly. - Otherwise, FIELDNAME is the name of the field we are - searching for. If it is not a static field name, an - error is signaled. TYPE is the type in which we look for the - static field member. */ -value -value_static_field (type, fieldname, fieldno) - register struct type *type; - char *fieldname; - register int fieldno; -{ - register value v; - struct symbol *sym; - - if (fieldno < 0) - { - register struct type *t = type; - /* Look for static field. */ - while (t) - { - int i; - for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--) - if (! strcmp (TYPE_FIELD_NAME (t, i), fieldname)) - { - if (TYPE_FIELD_STATIC (t, i)) - { - fieldno = i; - goto found; - } - else - error ("field `%s' is not static"); - } - t = TYPE_BASECLASSES (t) ? TYPE_BASECLASS (t, 1) : 0; - } - - t = type; - - if (destructor_name_p (fieldname, t)) - error ("use `info method' command to print out value of destructor"); - - while (t) - { - int i, j; - - for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; i--) - { - if (! strcmp (TYPE_FN_FIELDLIST_NAME (t, i), fieldname)) - { - error ("use `info method' command to print value of method \"%s\"", fieldname); - } - } - t = TYPE_BASECLASSES (t) ? TYPE_BASECLASS (t, 1) : 0; - } - error("there is no field named %s", fieldname); - } - - found: - - sym = lookup_symbol (TYPE_FIELD_STATIC_PHYSNAME (type, fieldno), - 0, VAR_NAMESPACE, 0); - if (! sym) error ("Internal error: could not find physical static variable named %s", TYPE_FIELD_BITSIZE (type, fieldno)); - - type = TYPE_FIELD_TYPE (type, fieldno); - v = value_at (type, (CORE_ADDR)SYMBOL_BLOCK_VALUE (sym)); - return v; -} - -long -unpack_field_as_long (type, valaddr, fieldno) - struct type *type; - char *valaddr; - int fieldno; -{ - long val; - int bitpos = TYPE_FIELD_BITPOS (type, fieldno); - int bitsize = TYPE_FIELD_BITSIZE (type, fieldno); - - bcopy (valaddr + bitpos / 8, &val, sizeof val); - - /* Extracting bits depends on endianness of the machine. */ -#ifdef BITS_BIG_ENDIAN - val = val >> (sizeof val * 8 - bitpos % 8 - bitsize); -#else - val = val >> (bitpos % 8); -#endif - - val &= (1 << bitsize) - 1; - return val; -} - -void -modify_field (addr, fieldval, bitpos, bitsize) - char *addr; - int fieldval; - int bitpos, bitsize; -{ - long oword; - - /* Reject values too big to fit in the field in question. - Otherwise adjoining fields may be corrupted. */ - if (fieldval & ~((1<> 8) -#define WSTOPSIG(w) ((w) >> 8) -#define WCOREDUMP(w) (((w)&0200) != 0) -#define WTERMSIG(w) ((w) & 0177) -#define WSETEXIT(w, status) ((w) = (status)) -#define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8))) - -#else - -#include - -#define WAITTYPE union wait -#ifndef WEXITSTATUS -#define WEXITSTATUS(w) (w).w_retcode -#endif -#ifndef WSTOPSIG -#define WSTOPSIG(w) (w).w_stopsig -#endif -#ifndef WCOREDUMP -#define WCOREDUMP(w) (w).w_coredump -#endif -#ifndef WTERMSIG -#define WTERMSIG(w) (w).w_termsig -#endif -#ifndef WSETEXIT -#define WSETEXIT(w, status) ((w).w_status = (status)) -#endif -#ifndef WSETSTOP -#define WSETSTOP(w,sig) \ - ((w).w_stopsig = (sig), (w).w_coredump = 0, (w).w_termsig = 0177) -#endif - -#endif diff --git a/gnu/usr.bin/groff/Makefile.gnu b/gnu/usr.bin/groff/Makefile.gnu deleted file mode 100644 index 65a549505423..000000000000 --- a/gnu/usr.bin/groff/Makefile.gnu +++ /dev/null @@ -1,285 +0,0 @@ -#Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. -# Written by James Clark (jjc@jclark.uucp) -# -#This file is part of groff. -# -#groff 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. -# -#groff 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 groff; see the file LICENSE. If not, write to the Free Software -#Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -# Define PAGE to be letter if your PostScript printer uses 8.5x11 paper (USA) -# and define it to be A4, if it uses A4 paper (rest of the world). -PAGE=A4 -#PAGE=letter - -# BINDIR says where to install executables. -BINDIR=/usr/local/bin - -GROFFLIBDIR=/usr/local/lib/groff - -# FONTDIR says where to install dev*/*. -FONTDIR=$(GROFFLIBDIR)/font - -# FONTPATH says where to look for dev*/*. -FONTPATH=.:$(FONTDIR):/usr/local/lib/font:/usr/lib/font - -# MACRODIR says where to install macros. -MACRODIR=$(GROFFLIBDIR)/tmac - -# MACROPATH says where to look for macro files. -MACROPATH=.:$(MACRODIR):/usr/lib/tmac - -# DEVICE is the default device. -DEVICE=ps - -# PSPRINT is the command to use for printing a PostScript file. -# It must be a simple command, not a pipeline. -PSPRINT=lpr - -# DVIPRINT is the command to use for printing a TeX dvi file. -# It must be a simple command, not a pipeline. -DVIPRINT=lpr -d - -# HYPHENFILE is the file containing the hyphenation patterns. -HYPHENFILE=$(GROFFLIBDIR)/hyphen - -# MANROOT is the root of the man page directory tree. -MANROOT=/usr/local/man - -# MAN1EXT is the man section for user commands. -MAN1EXT=1 -MAN1DIR=$(MANROOT)/man$(MAN1EXT) - -# MAN5EXT is the man section for file formats. -MAN5EXT=5 -MAN5DIR=$(MANROOT)/man$(MAN5EXT) - -# MAN7EXT is the man section for macros. -MAN7EXT=7 -MAN7DIR=$(MANROOT)/man$(MAN7EXT) - -# The groff ms macros will be available as -m$(TMAC_S). -# If you use `TMAC_S=s', you can use the Unix ms macros by using -# groff -ms -M/usr/lib/tmac. -TMAC_S=gs - -# Include -DBROKEN_SPOOLER in CPPDEFINES if you have a PostScript -# spooler or previewer that is unable to cope with anything after -# %%EndProlog and before the first page (old versions of TranScript -# have this problem) or gets confused by included documents (the Sun -# pageview previewer has this problem), or if you are going to be -# sharing PostScript documents with others who might be running such a -# spooler or previewer. -# Include -DCFRONT_ANSI_BUG if you are using AT&T C++ 2.0 with an ANSI C -# compiler backend. -# Include -DHAVE_VFORK if you have vfork(). -# Include -DHAVE_SYS_SIGLIST if you have sys_siglist[]. -# Include -DHAVE_UNION_WAIT if wait() is declared by osfcn.h to take -# an argument of type union wait * (Sun C++ does this). Don't include -# it if you're using the libg++ header files. -CPPDEFINES=-DBROKEN_SPOOLER -DHAVE_VFORK -DHAVE_SYS_SIGLIST # -DHAVE_UNION_WAIT -DCFRONT_ANSI_BUG - -# Uncomment the next line if you don't have fmod in your math library. -# I believe this is needed on Ultrix and BSD 4.3. -# FMOD=fmod.o - -# Uncomment the next line if you don't have strtol in your C library. -# I believe this is needed on BSD 4.3. -# STRTOL=strtol.o - -# Additional flags needed to compile lib/malloc.c -# Use this with BSD. -MALLOCFLAGS=-DBSD -# Use this with System V -# MALLOCFLAGS=-DUSG -# Use this with SunOS 4.1 -# MALLOCFLAGS=-DBSD -DSUNOS_LOCALTIME_BUG - -# Comment this out if the GNU malloc gives you problems, or if you would -# prefer to use the system malloc. -MALLOC=malloc.o - -GROFF= -# Comment the next line out if groff.c gives problems. -GROFF=groff - -# CC is the C++ compiler -CC=g++ -# I'm told that -fno-inline is needed on a 68030-based Apollo -# CC=g++ -fno-inline - -# OLDCC is the C compiler. -OLDCC=gcc - -PROFILE_FLAG= -DEBUG_FLAG=-g -OPTIMIZE_FLAG=-O -WARNING_FLAGS=#-Wall -Wcast-qual -Wwrite-strings - -# Use this to pass additional flags on the command line. -XCFLAGS= - -# CFLAGS are passed to sub makes -CFLAGS=$(PROFILE_FLAG) $(DEBUG_FLAG) $(OPTIMIZE_FLAG) $(WARNING_FLAGS) \ - $(CPPDEFINES) $(XCFLAGS) - -XOLDCFLAGS= -# OLDCFLAGS are passed to sub makes -OLDCFLAGS=$(DEBUG_FLAG) $(PROFILE_FLAG) $(OPTIMIZE_FLAG) $(XOLDCFLAGS) - -XLDFLAGS= -LDFLAGS=$(PROFILE_FLAG) $(DEBUG_FLAG) $(XLDFLAGS) -# Libraries needed for linking C++ programs. -LIBS= -# Libraries needed for linking C++ programs that use libm.a. -MLIBS=$(LIBS) -lm - -AR=ar - -# Define RANLIB to be empty if you don't have ranlib. -RANLIB=ranlib - -# YACC can be either yacc or bison -y -YACC=bison -y -YACCFLAGS=-v - -ETAGS=/usr/local/bin/etags -# Flag to make etags treat *.[ch] files as C++ -ETAGSFLAGS=-p - -SHELL=/bin/sh - -SUBDIRS=lib troff pic tbl eqn etc driver ps tty dvi macros man - -# SUBFLAGS says what flags to pass to sub makes -SUBFLAGS="CC=$(CC)" "CFLAGS=$(CFLAGS)" "LDFLAGS=$(LDFLAGS)" \ - "OLDCC=$(OLDCC)" "OLDCFLAGS=$(OLDCFLAGS)" \ - "YACC=$(YACC)" "YACCFLAGS=$(YACCFLAGS)" \ - "DEVICE=$(DEVICE)" "FONTPATH=$(FONTPATH)" "MACROPATH=$(MACROPATH)" \ - "MALLOCFLAGS=$(MALLOCFLAGS)" "MALLOC=$(MALLOC)" \ - "FMOD=$(FMOD)" "STRTOL=$(STRTOL)" \ - "AR=$(AR)" "RANLIB=$(RANLIB)" "LIBS=$(LIBS)" "MLIBS=$(MLIBS)" \ - "FONTDIR=$(FONTDIR)" "BINDIR=$(BINDIR)" "PAGE=$(PAGE)" \ - "MACRODIR=$(MACRODIR)" "HYPHENFILE=$(HYPHENFILE)" \ - "TMAC_S=$(TMAC_S)" "MAN1EXT=$(MAN1EXT)" "MAN1DIR=$(MAN1DIR)" \ - "MAN5EXT=$(MAN5EXT)" "MAN5DIR=$(MAN5DIR)" \ - "MAN7EXT=$(MAN7EXT)" "MAN7DIR=$(MAN7DIR)" - -all: $(SUBDIRS) $(GROFF) shgroff - -$(SUBDIRS): FORCE - @cd $@; \ - echo Making all in $@; \ - $(MAKE) $(SUBFLAGS) all - -troff pic tbl eqn etc ps tty dvi: lib -ps tty dvi: driver - -TAGS: FORCE - @for dir in $(SUBDIRS); do \ - echo Making TAGS in $$dir; \ - (cd $$dir; $(MAKE) "ETAGSFLAGS=$(ETAGSFLAGS)" "ETAGS=$(ETAGS)" TAGS); \ - done - -topclean: FORCE - -rm -f shgroff - -rm -f groff *.o core - -clean: topclean FORCE - @for dir in $(SUBDIRS) doc; do \ - echo Making clean in $$dir; \ - (cd $$dir; $(MAKE) clean); done - -distclean: topclean FORCE - @for dir in $(SUBDIRS) doc; do \ - echo Making distclean in $$dir; \ - (cd $$dir; $(MAKE) distclean); done - -# You really don't want to use this target. -realclean: topclean FORCE - @for dir in $(SUBDIRS) doc; do \ - echo Making realclean in $$dir; \ - (cd $$dir; $(MAKE) realclean); done - -install.nobin: FORCE shgroff - -[ -d $(BINDIR) ] || mkdir $(BINDIR) - -[ -d $(GROFFLIBDIR) ] || mkdir $(GROFFLIBDIR) - -[ -d $(MANROOT) ] || mkdir $(MANROOT) - @for dir in $(SUBDIRS); do \ - echo Making install.nobin in $$dir; \ - (cd $$dir; $(MAKE) $(SUBFLAGS) install.nobin); done - if [ -z "$(GROFF)" ] ; then cp shgroff $(BINDIR)/groff ; fi - -install.bin: FORCE $(GROFF) - -[ -d $(BINDIR) ] || mkdir $(BINDIR) - @for dir in $(SUBDIRS); do \ - echo Making install.bin in $$dir; \ - (cd $$dir; $(MAKE) $(SUBFLAGS) install.bin); done - if [ -n "$(GROFF)" ] ; then cp groff $(BINDIR)/groff ; fi - -install: install.bin install.nobin - -install.mm: FORCE - -[ -d $(GROFFLIBDIR) ] || mkdir $(GROFFLIBDIR) - -[ -d $(MACRODIR) ] || mkdir $(MACRODIR) - sed -f macros/fixmacros.sed -e 's;/usr/lib/tmac;$(MACRODIR);' \ - /usr/lib/macros/mmt >$(MACRODIR)/tmac.m - sed -f macros/fixmacros.sed /usr/lib/tmac/sys.name \ - >$(MACRODIR)/sys.name - patch -s $(MACRODIR)/tmac.m macros/mm.diff - -shgroff: groff.sh - @echo Making $@ from groff.sh - @-rm -f $@ - @sed -e "s;@BINDIR@;$(BINDIR);" \ - -e "s;@DEVICE@;$(DEVICE);" \ - -e "s;@PROG_PREFIX@;$(PROG_PREFIX);" \ - -e "s;@FONTDIR@;$(FONTDIR);" \ - -e "s;@PSPRINT@;$(PSPRINT);" \ - -e "s;@DVIPRINT@;$(DVIPRINT);" \ - groff.sh >$@ || rm -f $@ - @chmod +x $@ - -groff: groff.o lib/libgroff.a - $(CC) $(LDFLAGS) -o $@ groff.o lib/libgroff.a $(LIBS) - -lib/libgroff.a: lib - -groff.o: groff.c stringify - $(CC) -c -Ilib $(CFLAGS) -DDEVICE=\"$(DEVICE)\" \ - "-DPSPRINT=`$(SHELL) stringify $(PSPRINT)`" \ - "-DDVIPRINT=`$(SHELL) stringify $(DVIPRINT)`" \ - groff.c - -groff.o: lib/lib.h lib/errarg.h lib/error.h lib/stringclass.h lib/font.h - -bindist: all VERSION Makefile.bd README.bd FORCE - -[ -d bindist ] || mkdir bindist - @topdir=`pwd`; \ - for dir in $(SUBDIRS); do \ - (cd $$dir; $(MAKE) "BINDIR=$$topdir/bindist" install.bin); done - cp README.bd bindist/README - cp VERSION bindist - if [ "$(GROFF)" ] ; then cp groff bindist/groff ; fi - @echo Making bindist/Makefile - @sed -e "s;@GROFFLIBDIR@;$(GROFFLIBDIR);" \ - -e "s;@FONTDIR@;$(FONTDIR);" \ - -e "s;@FONTPATH@;$(FONTPATH);" \ - -e "s;@MACRODIR@;$(MACRODIR);" \ - -e "s;@MACROPATH@;$(MACROPATH);" \ - -e "s;@HYPHENFILE@;$(HYPHENFILE);" \ - -e "s;@DEVICE@;$(DEVICE);" \ - -e "s;@GROFF@;$(GROFF);" \ - Makefile.bd >bindist/Makefile - -FORCE: diff --git a/gnu/usr.bin/groff/devices/devdvi/texex.map b/gnu/usr.bin/groff/devices/devdvi/texex.map deleted file mode 100644 index a5b26901da29..000000000000 --- a/gnu/usr.bin/groff/devices/devdvi/texex.map +++ /dev/null @@ -1,100 +0,0 @@ -0 parenleft0 -1 parenright0 -2 bracketleft0 -3 bracketright0 -4 floorleft0 -5 floorright0 -6 ceilingleft0 -7 ceilingright0 -8 braceleft0 -9 braceright0 -10 angleleft0 -11 angleright0 -12 barex -13 bardblex -14 slash0 -15 backslash0 -16 parenleft1 -17 parenright1 -18 parenleft2 -19 parenright2 -20 bracketleft2 -21 bracketright2 -22 floorleft2 -23 floorright2 -24 ceilingleft2 -25 ceilingright2 -26 braceleft2 -27 braceright2 -28 angleleft2 -29 angleright2 -30 slash2 -31 backslash2 -32 parenleft3 -33 parenright3 -34 bracketleft3 -35 bracketright3 -36 floorleft3 -37 floorright3 -38 ceilingleft3 -39 ceilingright3 -40 braceleft3 -41 braceright3 -42 angleleft3 -43 angleright3 -44 slash3 -45 backslash3 -46 slash1 -47 backslash1 -48 parenlefttp -49 parenrighttp -50 bracketlefttp -51 bracketrighttp -52 bracketleftbt -53 bracketrightbt -54 bracketleftex -55 bracketrightex -56 bracelefttp lt -57 bracerighttp rt -58 braceleftbt lb -59 bracerightbt rb -60 braceleftmid lk -61 bracerightmid rk -62 braceex bracerightex braceleftex -63 arrowvertex -64 parenleftbt -65 parenrightbt -66 parenleftex -67 parenrightex -68 angleleft1 -69 angleright1 -73 ois ointegral -75 bigcircledot -77 bigcircleplus -79 bigcirclemultiply -88 sum -89 product -90 is integral -91 bigunion -92 bigintersection -93 bigunionplus -94 biglogicaland -95 biglogicalor -97 coproduct -104 bracketleft1 -105 bracketright1 -106 floorleft1 -107 floorright1 -108 ceilingleft1 -109 ceilingright1 -110 braceleft1 -111 braceright1 -112 sr0 -113 sr1 -114 sr2 -115 sr3 -119 arrowvertdblex -120 arrowverttp -121 arrowvertbt -126 arrowvertdbltp -127 arrowvertdblbt diff --git a/gnu/usr.bin/groff/devices/devdvi/texi.map b/gnu/usr.bin/groff/devices/devdvi/texi.map deleted file mode 100644 index 6e29b5bddae7..000000000000 --- a/gnu/usr.bin/groff/devices/devdvi/texi.map +++ /dev/null @@ -1,125 +0,0 @@ -0 *G -1 *D -2 *H -3 *L -4 *C -5 *P -6 *S -7 *U -8 *F -9 *Q -10 *W -11 ff -12 fi -13 fl -14 Fi -15 Fl -16 .i -17 .j -18 ga -19 aa char180 -20 ah -21 ab -22 a- char175 -23 ao -24 ac char184 -25 ss char223 -26 ae char230 -27 oe -28 /o char248 -29 AE char198 -30 OE -31 /O char216 -33 ! -35 # sh -36 Po char163 -37 % -38 & -39 ' -40 ( -41 ) -42 * -43 + -44 , -45 - hy char173 -46 . -47 / sl -48 0 -49 1 -50 2 -51 3 -52 4 -53 5 -54 6 -55 7 -56 8 -57 9 -58 : -59 ; -60 r! char161 -61 = -62 r? char191 -63 ? -64 @ at -65 A -66 B -67 C -68 D -69 E -70 F -71 G -72 H -73 I -74 J -75 K -76 L -77 M -78 N -79 O -80 P -81 Q -82 R -83 S -84 T -85 U -86 V -87 W -88 X -89 Y -90 Z -91 [ lB -93 ] rB -94 a^ ^ ha -95 a. -96 ` oq -97 a -98 b -99 c -100 d -101 e -102 f -103 g -104 h -105 i -106 j -107 k -108 l -109 m -110 n -111 o -112 p -113 q -114 r -115 s -116 t -117 u -118 v -119 w -120 x -121 y -122 z -123 en -124 em -125 a" -126 a~ ~ -127 ad char168 diff --git a/gnu/usr.bin/groff/devices/devdvi/texmi.map b/gnu/usr.bin/groff/devices/devdvi/texmi.map deleted file mode 100644 index ee64fece8a8b..000000000000 --- a/gnu/usr.bin/groff/devices/devdvi/texmi.map +++ /dev/null @@ -1,29 +0,0 @@ -11 *a -12 *b -13 *g -14 *d -15 *e -16 *z -17 *y -18 *h -19 *i -20 *k -21 *l -22 *m char181 -23 *n -24 *c -25 *p -26 *r -27 *s -28 *t -29 *u -30 *f -31 *x -32 *q -33 *w -38 ts -60 < -62 > -64 pd -111 *o -125 wp diff --git a/gnu/usr.bin/groff/devices/devdvi/texr.map b/gnu/usr.bin/groff/devices/devdvi/texr.map deleted file mode 100644 index 32d5e34dc793..000000000000 --- a/gnu/usr.bin/groff/devices/devdvi/texr.map +++ /dev/null @@ -1,125 +0,0 @@ -0 *G -1 *D -2 *H -3 *L -4 *C -5 *P -6 *S -7 *U -8 *F -9 *Q -10 *W -11 ff -12 fi -13 fl -14 Fi -15 Fl -16 .i -17 .j -18 ga -19 aa char180 -20 ah -21 ab -22 a- char175 -23 ao -24 ac char184 -25 ss char223 -26 ae char230 -27 oe -28 /o char248 -29 AE char198 -30 OE -31 /O char216 -33 ! -35 # sh -36 $ Do -37 % -38 & -39 ' -40 ( -41 ) -42 * -43 + pl -44 , -45 - hy char173 -46 . -47 / sl -48 0 -49 1 -50 2 -51 3 -52 4 -53 5 -54 6 -55 7 -56 8 -57 9 -58 : -59 ; -60 r! char161 -61 = eq -62 r? char191 -63 ? -64 @ at -65 A *A -66 B *B -67 C -68 D -69 E *E -70 F -71 G -72 H *Y -73 I *I -74 J -75 K *K -76 L -77 M *M -78 N *N -79 O *O -80 P *R -81 Q -82 R -83 S -84 T *T -85 U -86 V -87 W -88 X *X -89 Y -90 Z *Z -91 [ lB -93 ] rB -94 a^ ^ ha -95 a. -96 ` oq -97 a -98 b -99 c -100 d -101 e -102 f -103 g -104 h -105 i -106 j -107 k -108 l -109 m -110 n -111 o -112 p -113 q -114 r -115 s -116 t -117 u -118 v -119 w -120 x -121 y -122 z -123 en -124 em -125 a" -126 a~ ~ -127 ad char168 diff --git a/gnu/usr.bin/groff/devices/devdvi/texsy.map b/gnu/usr.bin/groff/devices/devdvi/texsy.map deleted file mode 100644 index 2c970bc2a47e..000000000000 --- a/gnu/usr.bin/groff/devices/devdvi/texsy.map +++ /dev/null @@ -1,100 +0,0 @@ -0 \- mi -1 md -2 mu char215 -3 ** -4 di char247 -6 +- char177 -7 -+ -8 c+ -10 c* -13 ci -15 bu -17 == -18 ib -19 ip -20 <= -21 >= -24 ap ti -25 ~~ -26 sb -27 sp -28 << -29 >> -32 <- -33 -> -34 ua -35 da -36 <> -39 ~= -40 lA lh -41 rA rh -42 uA -43 dA -44 hA -47 pt -48 prime -49 if -50 mo -51 st -54 slashnot -56 fa -57 te -58 no char172 -59 es -60 Re -61 Im -63 pp -64 Ah -65 A -66 B -67 C -68 D -69 E -70 F -71 G -72 H -73 I -74 J -75 K -76 L -77 M -78 N -79 O -80 P -81 Q -82 R -83 S -84 T -85 U -86 V -87 W -88 X -89 Y -90 Z -91 cu -92 ca -94 AN -95 OR -98 lf -99 rf -100 lc -101 rc -102 lC { -103 rC } -104 la -105 ra -106 ba | bv or bar -107 bardbl -108 va -109 vA -110 \ rs -112 sr -114 gr -120 sc char167 -121 dg -122 dd -123 ps char182 -124 CL -125 DI -126 HE -127 SP diff --git a/gnu/usr.bin/groff/devices/devdvi/textt.map b/gnu/usr.bin/groff/devices/devdvi/textt.map deleted file mode 100644 index ce1185dd965f..000000000000 --- a/gnu/usr.bin/groff/devices/devdvi/textt.map +++ /dev/null @@ -1,126 +0,0 @@ -0 *G -1 *D -2 *H -3 *L -4 *C -5 *P -6 *S -7 *U -8 *F -9 *Q -10 *W -11 ff -12 fi -13 fl -14 Fi -15 Fl -16 .i -17 .j -18 ga -19 aa char180 -20 ah -21 ab -22 a- char175 -23 ao -24 ac char184 -25 ss char223 -26 ae char230 -27 oe -28 /o char248 -29 AE char198 -30 OE -31 /O char216 -33 ! -34 " -35 # sh -36 $ Do -37 % -38 & -39 ' -40 ( -41 ) -42 * -43 + -44 , -45 \- -46 . -47 / sl -48 0 -49 1 -50 2 -51 3 -52 4 -53 5 -54 6 -55 7 -56 8 -57 9 -58 : -59 ; -60 < -61 = -62 > -63 ? -64 @ at -65 A -66 B -67 C -68 D -69 E -70 F -71 G -72 H -73 I -74 J -75 K -76 L -77 M -78 N -79 O -80 P -81 Q -82 R -83 S -84 T -85 U -86 V -87 W -88 X -89 Y -90 Z -91 [ lB -92 \ rs -93 ] rB -94 a^ ^ ha -95 _ -96 ` oq -97 a -98 b -99 c -100 d -101 e -102 f -103 g -104 h -105 i -106 j -107 k -108 l -109 m -110 n -111 o -112 p -113 q -114 r -115 s -116 t -117 u -118 v -119 w -120 x -121 y -122 z -123 lC { -124 ba | -125 rC } -126 a~ ~ diff --git a/gnu/usr.bin/groff/devices/devps/symbol.diff b/gnu/usr.bin/groff/devices/devps/symbol.diff deleted file mode 100644 index adbde6e6758e..000000000000 --- a/gnu/usr.bin/groff/devices/devps/symbol.diff +++ /dev/null @@ -1,65 +0,0 @@ -*** /usr/local/afm/symbol.afm Mon Mar 26 11:40:00 1990 ---- symbol.afm Tue Oct 16 09:46:37 1990 -*************** -*** 177,192 **** - C 227 ; WX 790 ; N copyrightsans ; B 49 -15 739 675 ; - C 228 ; WX 786 ; N trademarksans ; B 5 293 725 673 ; - C 229 ; WX 713 ; N summation ; B 14 -108 695 752 ; -! C 230 ; WX 384 ; N parenlefttp ; B 40 -293 436 926 ; -! C 231 ; WX 384 ; N parenleftex ; B 40 -85 92 925 ; -! C 232 ; WX 384 ; N parenleftbt ; B 40 -293 436 926 ; -! C 233 ; WX 384 ; N bracketlefttp ; B 0 -80 341 926 ; -! C 234 ; WX 384 ; N bracketleftex ; B 0 -79 55 925 ; -! C 235 ; WX 384 ; N bracketleftbt ; B 0 -80 340 926 ; -! C 236 ; WX 494 ; N bracelefttp ; B 201 -75 439 926 ; -! C 237 ; WX 494 ; N braceleftmid ; B 14 -85 255 935 ; -! C 238 ; WX 494 ; N braceleftbt ; B 201 -70 439 926 ; -! C 239 ; WX 494 ; N braceex ; B 201 -80 255 935 ; - C 240 ; WX 790 ; N apple ; B 56 -3 733 808 ; - C 241 ; WX 329 ; N angleright ; B 21 -198 302 746 ; - C 242 ; WX 274 ; N integral ; B 2 -107 291 916 ; ---- 177,192 ---- - C 227 ; WX 790 ; N copyrightsans ; B 49 -15 739 675 ; - C 228 ; WX 786 ; N trademarksans ; B 5 293 725 673 ; - C 229 ; WX 713 ; N summation ; B 14 -108 695 752 ; -! C 230 ; WX 384 ; N parenlefttp ; B 40 -290 436 926 ; -! C 231 ; WX 384 ; N parenleftex ; B 40 -80 92 920 ; -! C 232 ; WX 384 ; N parenleftbt ; B 40 -293 436 920 ; -! C 233 ; WX 384 ; N bracketlefttp ; B 0 -75 341 925 ; -! C 234 ; WX 384 ; N bracketleftex ; B 0 -75 55 925 ; -! C 235 ; WX 384 ; N bracketleftbt ; B 0 -75 340 925 ; -! C 236 ; WX 494 ; N bracelefttp ; B 201 -75 439 925 ; -! C 237 ; WX 494 ; N braceleftmid ; B 14 -75 255 925 ; -! C 238 ; WX 494 ; N braceleftbt ; B 201 -75 439 925 ; -! C 239 ; WX 494 ; N braceex ; B 201 -75 255 925 ; - C 240 ; WX 790 ; N apple ; B 56 -3 733 808 ; - C 241 ; WX 329 ; N angleright ; B 21 -198 302 746 ; - C 242 ; WX 274 ; N integral ; B 2 -107 291 916 ; -*************** -*** 196,206 **** - C 246 ; WX 384 ; N parenrighttp ; B 54 -293 450 926 ; - C 247 ; WX 384 ; N parenrightex ; B 398 -85 450 925 ; - C 248 ; WX 384 ; N parenrightbt ; B 54 -293 450 926 ; -! C 249 ; WX 384 ; N bracketrighttp ; B 22 -80 360 926 ; -! C 250 ; WX 384 ; N bracketrightex ; B 305 -79 360 925 ; -! C 251 ; WX 384 ; N bracketrightbt ; B 20 -80 360 926 ; -! C 252 ; WX 494 ; N bracerighttp ; B 17 -75 255 926 ; -! C 253 ; WX 494 ; N bracerightmid ; B 201 -85 442 935 ; -! C 254 ; WX 494 ; N bracerightbt ; B 17 -70 255 926 ; - EndCharMetrics - EndFontMetrics ---- 196,209 ---- - C 246 ; WX 384 ; N parenrighttp ; B 54 -293 450 926 ; - C 247 ; WX 384 ; N parenrightex ; B 398 -85 450 925 ; - C 248 ; WX 384 ; N parenrightbt ; B 54 -293 450 926 ; -! C 249 ; WX 384 ; N bracketrighttp ; B 22 -75 360 925 ; -! C 250 ; WX 384 ; N bracketrightex ; B 305 -75 360 925 ; -! C 251 ; WX 384 ; N bracketrightbt ; B 20 -75 360 925 ; -! C 252 ; WX 494 ; N bracerighttp ; B 17 -75 255 925 ; -! C 253 ; WX 494 ; N bracerightmid ; B 201 -75 442 925 ; -! C 254 ; WX 494 ; N bracerightbt ; B 17 -75 255 925 ; - EndCharMetrics -+ italicCorrection integral 67 -+ leftItalicCorrection integral 52 -+ subscriptCorrection integral -10 - EndFontMetrics diff --git a/gnu/usr.bin/groff/devices/devps/symbolchars b/gnu/usr.bin/groff/devices/devps/symbolchars deleted file mode 100644 index c5d4c445dd91..000000000000 --- a/gnu/usr.bin/groff/devices/devps/symbolchars +++ /dev/null @@ -1,3 +0,0 @@ -plus pl -minus mi -equal eq diff --git a/gnu/usr.bin/groff/devices/devps/symbolsl.afm b/gnu/usr.bin/groff/devices/devps/symbolsl.afm deleted file mode 100644 index 90939ada9697..000000000000 --- a/gnu/usr.bin/groff/devices/devps/symbolsl.afm +++ /dev/null @@ -1,203 +0,0 @@ -StartFontMetrics 2.0 -FontName Symbol-Slanted -Version 001.001 -FamilyName Symbol -ItalicAngle -15.5 -IsFixedPitch false -UnderlineThickness 54 -Weight Medium -UnderlinePosition -98 -FullName Symbol -FontBBox -241 -261 1250 899 -StartCharMetrics 189 -C 32 ; WX 223 ; N space ; B 223 0 223 0 ; -C 33 ; WX 296 ; N exclam ; B 122 -15 383 599 ; -C 34 ; WX 635 ; N universal ; B 223 0 801 627 ; -C 35 ; WX 445 ; N numbersign ; B 71 -15 557 599 ; -C 36 ; WX 489 ; N existential ; B 22 0 622 629 ; -C 37 ; WX 741 ; N percent ; B 147 -32 766 583 ; -C 38 ; WX 692 ; N ampersand ; B 68 -16 745 589 ; -C 39 ; WX 391 ; N suchthat ; B 44 -15 450 444 ; -C 40 ; WX 296 ; N parenleft ; B 89 -170 449 599 ; -C 41 ; WX 296 ; N parenright ; B -22 -170 339 600 ; -C 42 ; WX 445 ; N asteriskmath ; B 126 119 500 490 ; -C 43 ; WX 489 ; N plus ; B 76 0 562 474 ; -C 44 ; WX 223 ; N comma ; B 9 -136 183 93 ; -C 45 ; WX 489 ; N minus ; B 74 207 556 256 ; -C 46 ; WX 223 ; N period ; B 70 -15 174 85 ; -C 47 ; WX 247 ; N slash ; B -5 -15 405 575 ; -C 48 ; WX 445 ; N zero ; B 90 -15 537 610 ; -C 49 ; WX 445 ; N one ; B 107 0 451 599 ; -C 50 ; WX 445 ; N two ; B 22 0 524 611 ; -C 51 ; WX 445 ; N three ; B 56 -16 510 611 ; -C 52 ; WX 445 ; N four ; B 58 0 530 610 ; -C 53 ; WX 445 ; N five ; B 36 -15 583 610 ; -C 54 ; WX 445 ; N six ; B 87 -16 588 610 ; -C 55 ; WX 445 ; N seven ; B 151 -15 585 599 ; -C 56 ; WX 445 ; N eight ; B 82 -16 536 611 ; -C 57 ; WX 445 ; N nine ; B 52 -15 535 609 ; -C 58 ; WX 247 ; N colon ; B 81 -15 286 409 ; -C 59 ; WX 247 ; N semicolon ; B 33 -136 296 409 ; -C 60 ; WX 489 ; N less ; B 87 0 610 464 ; -C 61 ; WX 489 ; N equal ; B 49 126 586 347 ; -C 62 ; WX 489 ; N greater ; B 23 0 547 464 ; -C 63 ; WX 395 ; N question ; B 163 -15 517 610 ; -C 64 ; WX 489 ; N congruent ; B 10 0 597 423 ; -C 65 ; WX 643 ; N Alpha ; B 3 0 614 599 ; -C 66 ; WX 594 ; N Beta ; B 26 0 645 598 ; -C 67 ; WX 643 ; N Chi ; B -8 0 798 599 ; -C 68 ; WX 545 ; N Delta ; B 5 0 541 612 ; -C 69 ; WX 544 ; N Epsilon ; B 28 0 688 599 ; -C 70 ; WX 679 ; N Phi ; B 105 0 761 598 ; -C 71 ; WX 537 ; N Gamma ; B 31 0 714 599 ; -C 72 ; WX 643 ; N Eta ; B 35 0 836 599 ; -C 73 ; WX 296 ; N Iota ; B 28 0 468 599 ; -C 74 ; WX 562 ; N theta1 ; B 108 -15 645 614 ; -C 75 ; WX 643 ; N Kappa ; B 31 0 778 598 ; -C 76 ; WX 611 ; N Lambda ; B 5 0 610 612 ; -C 77 ; WX 791 ; N Mu ; B 28 0 974 599 ; -C 78 ; WX 643 ; N Nu ; B 26 -7 827 599 ; -C 79 ; WX 643 ; N Omicron ; B 112 -15 747 610 ; -C 80 ; WX 684 ; N Pi ; B 22 0 847 599 ; -C 81 ; WX 659 ; N Theta ; B 112 -15 747 610 ; -C 82 ; WX 495 ; N Rho ; B 25 0 645 599 ; -C 83 ; WX 527 ; N Sigma ; B 5 0 663 599 ; -C 84 ; WX 544 ; N Tau ; B 159 0 723 599 ; -C 85 ; WX 614 ; N Upsilon ; B 175 0 804 599 ; -C 86 ; WX 391 ; N sigma1 ; B 78 -208 492 445 ; -C 87 ; WX 684 ; N Omega ; B 30 0 760 612 ; -C 88 ; WX 574 ; N Xi ; B 36 0 700 598 ; -C 89 ; WX 708 ; N Psi ; B 188 0 885 608 ; -C 90 ; WX 544 ; N Zeta ; B 39 0 725 599 ; -C 91 ; WX 296 ; N bracketleft ; B 34 -138 453 599 ; -C 92 ; WX 768 ; N therefore ; B 160 0 645 426 ; -C 93 ; WX 296 ; N bracketright ; B -14 -138 405 599 ; -C 94 ; WX 586 ; N perpendicular ; B 13 0 596 600 ; -C 95 ; WX 445 ; N underscore ; B -72 -224 390 -183 ; -C 96 ; WX 445 ; N radicalex ; B 672 784 1224 816 ; -C 97 ; WX 562 ; N alpha ; B 84 -15 658 445 ; -C 98 ; WX 489 ; N beta ; B -7 -198 578 659 ; -C 99 ; WX 489 ; N chi ; B -48 -206 573 445 ; -C 100 ; WX 440 ; N delta ; B 83 -16 571 658 ; -C 101 ; WX 391 ; N epsilon ; B 49 -17 468 447 ; -C 102 ; WX 464 ; N phi ; B 78 -200 517 596 ; -C 103 ; WX 366 ; N gamma ; B 92 -200 568 444 ; -C 104 ; WX 537 ; N eta ; B 100 -180 555 457 ; -C 105 ; WX 293 ; N iota ; B 97 -16 296 448 ; -C 106 ; WX 537 ; N phi1 ; B 92 -199 604 444 ; -C 107 ; WX 489 ; N kappa ; B 106 0 621 447 ; -C 108 ; WX 489 ; N lambda ; B 21 -16 530 658 ; -C 109 ; WX 513 ; N mu ; B -18 -198 533 445 ; -C 110 ; WX 464 ; N nu ; B 119 -15 548 451 ; -C 111 ; WX 489 ; N omicron ; B 86 -17 526 444 ; -C 112 ; WX 489 ; N pi ; B 58 -18 599 433 ; -C 113 ; WX 464 ; N theta ; B 103 -16 554 614 ; -C 114 ; WX 489 ; N rho ; B -19 -205 521 444 ; -C 115 ; WX 537 ; N sigma ; B 87 -19 662 445 ; -C 116 ; WX 391 ; N tau ; B 95 -16 511 445 ; -C 117 ; WX 513 ; N upsilon ; B 105 -15 558 451 ; -C 118 ; WX 635 ; N omega1 ; B 78 -15 758 519 ; -C 119 ; WX 611 ; N omega ; B 85 -16 687 445 ; -C 120 ; WX 439 ; N xi ; B 70 -200 515 681 ; -C 121 ; WX 611 ; N psi ; B 141 -203 759 445 ; -C 122 ; WX 440 ; N zeta ; B 100 -200 580 673 ; -C 123 ; WX 427 ; N braceleft ; B 116 -163 540 599 ; -C 124 ; WX 178 ; N bar ; B 9 -158 307 599 ; -C 125 ; WX 427 ; N braceright ; B 19 -163 444 599 ; -C 126 ; WX 489 ; N similar ; B 78 181 549 273 ; -C 161 ; WX 552 ; N Upsilon1 ; B 134 0 710 609 ; -C 162 ; WX 220 ; N minute ; B 156 408 393 654 ; -C 163 ; WX 489 ; N lessequal ; B 26 0 645 569 ; -C 164 ; WX 149 ; N fraction ; B -164 -11 490 603 ; -C 165 ; WX 635 ; N infinity ; B 91 111 692 360 ; -C 166 ; WX 445 ; N florin ; B -36 -172 614 612 ; -C 167 ; WX 670 ; N club ; B 119 -23 645 474 ; -C 168 ; WX 670 ; N diamond ; B 198 -32 605 490 ; -C 169 ; WX 670 ; N heart ; B 205 -29 679 473 ; -C 170 ; WX 670 ; N spade ; B 132 -32 604 488 ; -C 171 ; WX 927 ; N arrowboth ; B 90 -13 980 455 ; -C 172 ; WX 878 ; N arrowleft ; B 97 -13 915 455 ; -C 173 ; WX 537 ; N arrowup ; B 223 0 691 810 ; -C 174 ; WX 878 ; N arrowright ; B 105 -13 922 455 ; -C 175 ; WX 537 ; N arrowdown ; B 104 -20 572 790 ; -C 176 ; WX 356 ; N degree ; B 187 343 466 609 ; -C 177 ; WX 489 ; N plusminus ; B 9 0 593 574 ; -C 178 ; WX 366 ; N second ; B 150 408 560 656 ; -C 179 ; WX 489 ; N greaterequal ; B 26 0 582 569 ; -C 180 ; WX 489 ; N multiply ; B 28 7 609 466 ; -C 181 ; WX 635 ; N proportional ; B 90 110 667 360 ; -C 182 ; WX 440 ; N partialdiff ; B 62 -18 542 664 ; -C 183 ; WX 409 ; N bullet ; B 118 101 454 421 ; -C 184 ; WX 489 ; N divide ; B 74 63 558 406 ; -C 185 ; WX 489 ; N notequal ; B 51 -22 587 489 ; -C 186 ; WX 489 ; N equivalence ; B 35 73 602 394 ; -C 187 ; WX 489 ; N approxequal ; B 57 120 572 351 ; -C 188 ; WX 890 ; N ellipsis ; B 107 -15 804 85 ; -C 189 ; WX 537 ; N arrowvertex ; B 216 -107 579 899 ; -C 190 ; WX 890 ; N arrowhorizex ; B 8 196 1011 246 ; -C 191 ; WX 586 ; N carriagereturn ; B 40 -14 710 560 ; -C 192 ; WX 732 ; N aleph ; B 159 -16 740 586 ; -C 193 ; WX 611 ; N Ifraktur ; B 26 -47 684 659 ; -C 194 ; WX 708 ; N Rfraktur ; B 71 -13 833 653 ; -C 195 ; WX 878 ; N weierstrass ; B 112 -188 878 510 ; -C 196 ; WX 684 ; N circlemultiply ; B 114 -15 758 599 ; -C 197 ; WX 684 ; N circleplus ; B 115 -13 759 601 ; -C 198 ; WX 732 ; N emptyset ; B 38 -21 884 640 ; -C 199 ; WX 684 ; N intersection ; B 36 0 714 453 ; -C 200 ; WX 684 ; N union ; B 110 -15 788 438 ; -C 201 ; WX 635 ; N propersuperset ; B 18 0 675 418 ; -C 202 ; WX 635 ; N reflexsuperset ; B -17 -111 674 418 ; -C 203 ; WX 635 ; N notsubset ; B 87 -62 744 481 ; -C 204 ; WX 635 ; N propersubset ; B 87 0 744 418 ; -C 205 ; WX 635 ; N reflexsubset ; B 16 -111 744 418 ; -C 206 ; WX 635 ; N element ; B 93 0 579 417 ; -C 207 ; WX 635 ; N notelement ; B 74 -52 579 494 ; -C 208 ; WX 684 ; N angle ; B 23 0 833 599 ; -C 209 ; WX 635 ; N gradient ; B 231 -17 805 639 ; -C 210 ; WX 703 ; N registerserif ; B 120 -18 763 596 ; -C 211 ; WX 703 ; N copyrightserif ; B 122 -13 766 601 ; -C 212 ; WX 792 ; N trademarkserif ; B 169 261 947 599 ; -C 213 ; WX 732 ; N product ; B -6 -90 920 668 ; -C 214 ; WX 489 ; N radical ; B 134 -34 711 816 ; -C 215 ; WX 223 ; N dotmath ; B 131 187 225 276 ; -C 216 ; WX 635 ; N logicalnot ; B 78 0 685 256 ; -C 217 ; WX 537 ; N logicaland ; B 21 0 519 404 ; -C 218 ; WX 537 ; N logicalor ; B 151 0 639 424 ; -C 219 ; WX 927 ; N arrowdblboth ; B 92 -18 978 454 ; -C 220 ; WX 878 ; N arrowdblleft ; B 96 -13 942 457 ; -C 221 ; WX 537 ; N arrowdblup ; B 152 2 688 811 ; -C 222 ; WX 878 ; N arrowdblright ; B 71 -18 917 452 ; -C 223 ; WX 537 ; N arrowdbldown ; B 103 -17 639 792 ; -C 224 ; WX 440 ; N lozenge ; B 121 0 519 663 ; -C 225 ; WX 293 ; N angleleft ; B 98 -176 472 664 ; -C 226 ; WX 703 ; N registersans ; B 120 -18 763 596 ; -C 227 ; WX 703 ; N copyrightsans ; B 120 -13 764 601 ; -C 228 ; WX 700 ; N trademarksans ; B 179 261 832 599 ; -C 229 ; WX 635 ; N summation ; B -15 -96 756 669 ; -C 230 ; WX 342 ; N parenlefttp ; B -46 -261 642 824 ; -C 231 ; WX 342 ; N parenleftex ; B 12 -76 338 823 ; -C 232 ; WX 342 ; N parenleftbt ; B 113 -261 339 824 ; -C 233 ; WX 342 ; N bracketlefttp ; B -22 -71 560 824 ; -C 234 ; WX 342 ; N bracketleftex ; B -22 -70 305 823 ; -C 235 ; WX 342 ; N bracketleftbt ; B -22 -71 306 824 ; -C 236 ; WX 440 ; N bracelefttp ; B 158 -67 648 824 ; -C 237 ; WX 440 ; N braceleftmid ; B 126 -76 486 832 ; -C 238 ; WX 440 ; N braceleftbt ; B 219 -62 484 824 ; -C 239 ; WX 440 ; N braceex ; B 157 -71 486 832 ; -C 241 ; WX 293 ; N angleright ; B -29 -176 345 664 ; -C 242 ; WX 244 ; N integral ; B -13 -95 499 815 ; -C 243 ; WX 611 ; N integraltp ; B 272 -74 873 820 ; -C 244 ; WX 611 ; N integralex ; B 271 -78 640 868 ; -C 245 ; WX 611 ; N integralbt ; B 30 -72 625 820 ; -C 246 ; WX 342 ; N parenrighttp ; B 273 -261 498 824 ; -C 247 ; WX 342 ; N parenrightex ; B 331 -76 657 823 ; -C 248 ; WX 342 ; N parenrightbt ; B -30 -261 657 824 ; -C 249 ; WX 342 ; N bracketrighttp ; B 249 -71 577 824 ; -C 250 ; WX 342 ; N bracketrightex ; B 250 -70 577 823 ; -C 251 ; WX 342 ; N bracketrightbt ; B -4 -71 577 824 ; -C 252 ; WX 440 ; N bracerighttp ; B 158 -67 425 824 ; -C 253 ; WX 440 ; N bracerightmid ; B 155 -76 517 832 ; -C 254 ; WX 440 ; N bracerightbt ; B -4 -62 484 824 ; -C -1 ; WX 703 ; N apple ; B 136 -2 784 719 ; -EndCharMetrics -EndFontMetrics diff --git a/gnu/usr.bin/groff/devices/devps/symbolsl.ps b/gnu/usr.bin/groff/devices/devps/symbolsl.ps deleted file mode 100644 index c1d10baeedbe..000000000000 --- a/gnu/usr.bin/groff/devices/devps/symbolsl.ps +++ /dev/null @@ -1,40 +0,0 @@ -%!PS-Adobe-2.1 -%%DocumentFonts: Symbol - -% newfontname matrix oldfontname MakeTransformedFont - -/MakeTransformedFont { - findfont dup maxlength dict begin - { - exch dup dup /FID ne exch /UniqueID ne and { - exch def - } { - pop pop - } ifelse - } forall - % first copy FontBBox - /FontBBox - % FontBBox sometimes seems to have the executable - % attribute set - % so to get the array on the stack, we have to do this - currentdict /FontBBox get - 4 array copy def - % now transform it - FontBBox aload pop - 4 index transform 4 2 roll - 4 index transform 4 2 roll - FontBBox astore pop - % matrix - % now transform FontMatrix - FontMatrix exch matrix concatmatrix - /FontMatrix exch def - dup /FontName exch def - currentdict end - definefont pop -} bind def - - -/Symbol-Slanted -[.89 0.0 15.5 dup sin exch cos div .89 0.0 0.0] -/Symbol -MakeTransformedFont diff --git a/gnu/usr.bin/groff/devices/devps/textmap b/gnu/usr.bin/groff/devices/devps/textmap deleted file mode 100644 index 9a4f2e77af72..000000000000 --- a/gnu/usr.bin/groff/devices/devps/textmap +++ /dev/null @@ -1,492 +0,0 @@ -a a -b b -c c -d d -e e -f f -g g -h h -i i -j j -k k -l l -m m -n n -o o -p p -q q -r r -s s -t t -u u -v v -w w -x x -y y -z z -A A -B B -C C -D D -E E -F F -G G -H H -I I -J J -K K -L L -M M -N N -O O -P P -Q Q -R R -S S -T T -U U -V V -W W -X X -Y Y -Z Z -AE AE -Aacute 'A -Acircumflex ^A -Adieresis :A -Agrave `A -Alpha *A -Aring oA -Atilde ~A -Beta *B -Cacute 'C -Ccedilla ,C -Chi *X -Delta *D -Eacute 'E -Ecircumflex ^E -Edieresis :E -Egrave `E -Epsilon *E -Eta *Y -Eth -D -Gamma *G -IJ IJ -Iacute 'I -Icircumflex ^I -Idieresis :I -Ifraktur Im -Igrave `I -Iota *I -Kappa *K -Lambda *L -Lslash /L -Mu *M -Ntilde ~N -Nu *N -OE OE -Oacute 'O -Ocircumflex ^O -Odieresis :O -Ograve `O -Omega *W -Omicron *O -Oslash /O -Otilde ~O -Phi *F -Pi *P -Psi *Q -Rfraktur Re -Rho *R -Scaron vS -Sigma *S -Tau *T -Theta *H -Thorn TP -Uacute 'U -Ucircumflex ^U -Udieresis :U -Ugrave `U -Upsilon1 *U -Xi *C -Yacute 'Y -Ydieresis :Y -Zcaron vZ -Zeta *Z -aacute 'a -acircumflex ^a -acute aa -adieresis :a -ae ae -agrave `a -angle /_ -angleleft la -angleright ra -aleph Ah -alpha *a -ampersand & -approxequal ~~ -aring oa -arrowboth <> -arrowdblboth hA -arrowdbldown dA -arrowdblleft lA -arrowdblright rA -arrowdblup uA -arrowdown da -arrowleft <- -arrowright -> -arrowup ua -asciicircum ha -asciitilde ti -asterisk * -asteriskmath ** -at @ -at at -atilde ~a -backslash \ -backslash rs -bar ba -bar | -bell bs -beta *b -braceleft lC -braceleft { -braceright rC -braceright } -bracketleft [ -bracketleft lB -bracketright ] -bracketright rB -breve ab -brokenbar bb -bullet bu -cacute 'c -caron ah -ccedilla ,c -cedilla ac -cent ct -checkmark OK -chi *x -circle ci -circlemultiply c* -circleplus c+ -circumflex a^ -circumflex ^ -colon : -comma , -congruent =~ -copyright co -currency Cs -dagger dg -daggerdbl dd -degree de -delta *d -dieresis ad -divide di -dollar $ -dollar Do -dotaccent a. -dotlessi .i -dotlessj .j -dotmath md -eacute 'e -ecircumflex ^e -edieresis :e -egrave `e -eight 8 -element mo -emdash em -emptyset es -endash en -epsilon *e -equal = -equalmath eq -equivalence == -eta *y -eth Sd -exclam ! -exclamdown r! -existential te -ff ff -ffi Fi -ffl Fl -fi fi -five 5 -fl fl -four 4 -gamma *g -germandbls ss -gradient gr -grave ga -greater > -greaterequal >= -guillemotleft Fo -guillemotright Fc -guilsinglleft fo -guilsinglright fc -handleft lh -handright rh -hbar -h -hungarumlaut a" -hyphen - -hyphen hy -iacute 'i -icircumflex ^i -idieresis :i -igrave `i -ij ij -infinity if -integral is -intersection ca -iota *i -kappa *k -lambda *l -less < -lessequal <= -logicaland AN -logicalnot no -logicalor OR -lslash /l -macron a- -minus \- -minusplus -+ -minute fm -mu *m -multiply mu -nine 9 -notelement nm -notequal != -notequivalence ne -notpropersuperset nc -ntilde ~n -nu *n -numbersign # -numbersign sh -oacute 'o -ocircumflex ^o -odieresis :o -oe oe -ogonek ho -ograve `o -omega *w -omicron *o -one 1 -onehalf 12 -onequarter 14 -onesuperior S1 -ordfeminine Of -ordmasculine Om -oslash /o -otilde ~o -paragraph ps -parenleft ( -parenright ) -partialdiff pd -percent % -period . -perthousand %0 -perpendicular pp -phi *f -pi *p -plus + -plusmath pl -plusminus +- -propersubset sb -propersuperset sp -proportional pt -psi *q -question ? -questiondown r? -quotedbl " -quoteleft ` -quoteleft oq -quoteright ' -reflexsubset ib -reflexsuperset ip -registered rg -rho *r -ring ao -scaron vs -second sd -section sc -semicolon ; -seven 7 -sigma *s -sigma1 ts -similar ap -similarequal ~= -six 6 -slash / -slash sl -square sq -sterling Po -tau *t -therefore 3d -therefore tf -theta *h -thorn Tp -three 3 -threequarters 34 -threesuperior S3 -tilde a~ -tilde ~ -trademark tm -two 2 -twosuperior S2 -uacute 'u -ucircumflex ^u -udieresis :u -ugrave `u -underscore _ -union cu -universal fa -upsilon *u -weierstrass wp -xi *c -yacute 'y -ydieresis :y -yen Ye -zcaron vz -zero 0 -zeta *z -exclamdown char161 -cent char162 -sterling char163 -currency char164 -yen char165 -brokenbar char166 -section char167 -dieresis char168 -copyright char169 -ordfeminine char170 -guillemotleft char171 -logicalnot char172 -hyphen char173 -registered char174 -macron char175 -degree char176 -plusminus char177 -twosuperior char178 -threesuperior char179 -acute char180 -mu char181 -paragraph char182 -periodcentered char183 -cedilla char184 -onesuperior char185 -ordmasculine char186 -guillemotright char187 -onequarter char188 -onehalf char189 -threequarters char190 -questiondown char191 -Agrave char192 -Aacute char193 -Acircumflex char194 -Atilde char195 -Adieresis char196 -Aring char197 -AE char198 -Ccedilla char199 -Egrave char200 -Eacute char201 -Ecircumflex char202 -Edieresis char203 -Igrave char204 -Iacute char205 -Icircumflex char206 -Idieresis char207 -Eth char208 -Ntilde char209 -Ograve char210 -Oacute char211 -Ocircumflex char212 -Otilde char213 -Odieresis char214 -multiply char215 -Oslash char216 -Ugrave char217 -Uacute char218 -Ucircumflex char219 -Udieresis char220 -Yacute char221 -Thorn char222 -germandbls char223 -agrave char224 -aacute char225 -acircumflex char226 -atilde char227 -adieresis char228 -aring char229 -ae char230 -ccedilla char231 -egrave char232 -eacute char233 -ecircumflex char234 -edieresis char235 -igrave char236 -iacute char237 -icircumflex char238 -idieresis char239 -eth char240 -ntilde char241 -ograve char242 -oacute char243 -ocircumflex char244 -otilde char245 -odieresis char246 -divide char247 -oslash char248 -ugrave char249 -uacute char250 -ucircumflex char251 -udieresis char252 -yacute char253 -thorn char254 -ydieresis char255 -fraction f/ -club CL -diamond DI -heart HE -spade SP -carriagereturn CR -suchthat st -bracelefttp bracelefttp -braceleftmid braceleftmid -braceleftbt braceleftbt -braceex braceex -braceex bracerightex -braceex braceleftex -braceex barex -bracerighttp bracerighttp -bracerightmid bracerightmid -bracerightbt bracerightbt -parenlefttp parenlefttp -parenleftbt parenleftbt -parenleftex parenleftex -parenrighttp parenrighttp -parenrightbt parenrightbt -parenrightex parenrightex -bracketlefttp bracketlefttp -bracketleftbt bracketleftbt -bracketleftex bracketleftex -bracketrighttp bracketrighttp -bracketrightbt bracketrightbt -bracketrightex bracketrightex -radical sr -radicalex rn -approxequal ~= -bracketlefttp lc -bracketleftbt lf -bracketrighttp rc -bracketrightbt rf -bracelefttp lt -braceleftmid lk -braceleftbt lb -braceex bv -bracerighttp rt -bracerightmid rk -bracerightbt rb -summation sum -product product diff --git a/gnu/usr.bin/groff/devices/devps/zapfdr.ps b/gnu/usr.bin/groff/devices/devps/zapfdr.ps deleted file mode 100644 index b6e34302e82b..000000000000 --- a/gnu/usr.bin/groff/devices/devps/zapfdr.ps +++ /dev/null @@ -1,222 +0,0 @@ -%!PS-Adobe-2.1 -%%DocumentFonts: ZapfDingbats - -/ZapfDingbats findfont [-1 0 0 1 0 0] makefont -dup length 1 add dict /newdict exch def { - 1 index /FID ne { - newdict 3 1 roll put - } { - pop pop - } ifelse -} forall - -newdict /FontName /ZapfDingbats-Reverse put - -202 dict begin - /space [0 -278] def - /a1 [-939 -974] def - /a2 [-926 -961] def - /a202 [-939 -974] def - /a3 [-945 -980] def - /a4 [-685 -719] def - /a5 [-754 -789] def - /a119 [-755 -790] def - /a118 [-756 -791] def - /a117 [-655 -690] def - /a11 [-925 -960] def - /a12 [-904 -939] def - /a13 [-520 -549] def - /a14 [-821 -855] def - /a15 [-876 -911] def - /a16 [-898 -933] def - /a105 [-876 -911] def - /a17 [-910 -945] def - /a18 [-939 -974] def - /a19 [-721 -755] def - /a20 [-811 -846] def - /a21 [-727 -762] def - /a22 [-726 -761] def - /a23 [-572 -571] def - /a24 [-641 -677] def - /a25 [-728 -763] def - /a26 [-725 -760] def - /a27 [-724 -759] def - /a28 [-719 -754] def - /a6 [-459 -494] def - /a7 [-517 -552] def - /a8 [-502 -537] def - /a9 [-542 -577] def - /a10 [-657 -692] def - /a29 [-751 -786] def - /a30 [-753 -788] def - /a31 [-753 -788] def - /a32 [-755 -790] def - /a33 [-758 -793] def - /a34 [-759 -794] def - /a35 [-781 -816] def - /a36 [-788 -823] def - /a37 [-754 -789] def - /a38 [-806 -841] def - /a39 [-788 -823] def - /a40 [-798 -833] def - /a41 [-781 -816] def - /a42 [-796 -831] def - /a43 [-888 -923] def - /a44 [-709 -744] def - /a45 [-688 -723] def - /a46 [-714 -749] def - /a47 [-756 -790] def - /a48 [-757 -792] def - /a49 [-660 -695] def - /a50 [-741 -776] def - /a51 [-733 -768] def - /a52 [-757 -792] def - /a53 [-724 -759] def - /a54 [-672 -707] def - /a55 [-673 -708] def - /a56 [-647 -682] def - /a57 [-666 -701] def - /a58 [-791 -826] def - /a59 [-780 -815] def - /a60 [-754 -789] def - /a61 [-754 -789] def - /a62 [-673 -707] def - /a63 [-651 -687] def - /a64 [-661 -696] def - /a65 [-654 -689] def - /a66 [-752 -786] def - /a67 [-752 -787] def - /a68 [-678 -713] def - /a69 [-756 -791] def - /a70 [-749 -785] def - /a71 [-756 -791] def - /a72 [-838 -873] def - /a73 [-726 -761] def - /a74 [-727 -762] def - /a203 [-727 -762] def - /a75 [-724 -759] def - /a204 [-724 -759] def - /a76 [-857 -892] def - /a77 [-857 -892] def - /a78 [-753 -788] def - /a79 [-749 -784] def - /a81 [-403 -438] def - /a82 [-103 -138] def - /a83 [-242 -277] def - /a84 [-380 -415] def - /a97 [-357 -392] def - /a98 [-358 -392] def - /a99 [-633 -668] def - /a100 [-632 -668] def - /a101 [-697 -732] def - /a102 [-488 -544] def - /a103 [-510 -544] def - /a104 [-875 -910] def - /a106 [-632 -667] def - /a107 [-725 -760] def - /a108 [-760 -760] def - /a112 [-741 -776] def - /a111 [-561 -595] def - /a110 [-659 -694] def - /a109 [-592 -626] def - /a120 [-753 -788] def - /a121 [-753 -788] def - /a122 [-753 -788] def - /a123 [-753 -788] def - /a124 [-753 -788] def - /a125 [-753 -788] def - /a126 [-753 -788] def - /a127 [-753 -788] def - /a128 [-753 -788] def - /a129 [-753 -788] def - /a130 [-753 -788] def - /a131 [-753 -788] def - /a132 [-753 -788] def - /a133 [-753 -788] def - /a134 [-753 -788] def - /a135 [-753 -788] def - /a136 [-753 -788] def - /a137 [-753 -788] def - /a138 [-753 -788] def - /a139 [-753 -788] def - /a140 [-753 -788] def - /a141 [-753 -788] def - /a142 [-753 -788] def - /a143 [-753 -788] def - /a144 [-753 -788] def - /a145 [-753 -788] def - /a146 [-753 -788] def - /a147 [-753 -788] def - /a148 [-753 -788] def - /a149 [-753 -788] def - /a150 [-753 -788] def - /a151 [-753 -788] def - /a152 [-753 -788] def - /a153 [-753 -788] def - /a154 [-753 -788] def - /a155 [-753 -788] def - /a156 [-753 -788] def - /a157 [-753 -788] def - /a158 [-753 -788] def - /a159 [-753 -788] def - /a160 [-859 -894] def - /a161 [-803 -838] def - /a163 [-982 -1016] def - /a164 [-423 -458] def - /a196 [-713 -748] def - /a165 [-889 -924] def - /a192 [-713 -748] def - /a166 [-883 -918] def - /a167 [-892 -927] def - /a168 [-893 -928] def - /a169 [-893 -928] def - /a170 [-799 -834] def - /a171 [-838 -873] def - /a172 [-793 -828] def - /a173 [-889 -924] def - /a162 [-889 -924] def - /a174 [-882 -917] def - /a175 [-895 -930] def - /a176 [-896 -931] def - /a177 [-428 -463] def - /a178 [-848 -883] def - /a179 [-801 -836] def - /a193 [-801 -836] def - /a180 [-832 -867] def - /a199 [-832 -867] def - /a181 [-661 -696] def - /a200 [-661 -696] def - /a182 [-839 -874] def - /a201 [-839 -874] def - /a183 [-725 -760] def - /a184 [-911 -946] def - /a197 [-737 -771] def - /a185 [-830 -865] def - /a194 [-737 -771] def - /a198 [-854 -888] def - /a186 [-932 -967] def - /a195 [-854 -888] def - /a187 [-796 -831] def - /a188 [-837 -873] def - /a189 [-892 -927] def - /a190 [-935 -970] def - /a191 [-884 -918] def - /a205 [-474 -509] def - /a206 [-375 -410] def - /a85 [-474 -509] def - /a86 [-375 -410] def - /a87 [-199 -234] def - /a88 [-199 -234] def - /a89 [-355 -390] def - /a90 [-355 -390] def - /a91 [-241 -276] def - /a92 [-241 -276] def - /a93 [-282 -317] def - /a94 [-282 -317] def - /a95 [-299 -334] def - /a96 [-299 -334] def - - newdict /Metrics currentdict put -end - -/ZapfDingbats-Reverse newdict definefont pop diff --git a/gnu/usr.bin/groff/grops/Makefile.dep b/gnu/usr.bin/groff/grops/Makefile.dep deleted file mode 100644 index 2320a9ecd129..000000000000 --- a/gnu/usr.bin/groff/grops/Makefile.dep +++ /dev/null @@ -1,6 +0,0 @@ -ps.o : ps.cc ../include/driver.h ../include/errarg.h ../include/error.h \ - ../include/font.h ../include/printer.h ../include/lib.h \ - ../include/stringclass.h ../include/cset.h ps.h -psrm.o : psrm.cc ../include/driver.h ../include/errarg.h ../include/error.h \ - ../include/font.h ../include/printer.h ../include/lib.h \ - ../include/stringclass.h ../include/cset.h ps.h diff --git a/gnu/usr.bin/groff/libXdvi/Makefile.gnu b/gnu/usr.bin/groff/libXdvi/Makefile.gnu deleted file mode 100644 index f9b1a0dd910d..000000000000 --- a/gnu/usr.bin/groff/libXdvi/Makefile.gnu +++ /dev/null @@ -1,25 +0,0 @@ -RANLIB=ranlib -AR=ar -CFLAGS=-g -OBJECTS=Dvi.o draw.o font.o lex.o page.o parse.o XFontName.o DviChar.o - -.c.o: - $(CC) -c $(CFLAGS) -o $@ $< - -all: libXdvi.a - -libXdvi.a: $(OBJECTS) - $(AR) r $@ $? - if test "$(RANLIB)" ; then $(RANLIB) $@ ; fi - -clean: - -rm -f *.o core libXdvi.a - -Dvi.o: DviP.h Dvi.h DviChar.h -draw.o: DviP.h Dvi.h DviChar.h -font.o: DviP.h Dvi.h DviChar.h XFontName.h -lex.o: DviP.h Dvi.h DviChar.h -page.o: DviP.h Dvi.h DviChar.h -parse.o: DviP.h Dvi.h DviChar.h -XFontName.o: XFontName.h -DviChar.o: DviChar.h diff --git a/gnu/usr.bin/groff/libXdvi/Menu.h b/gnu/usr.bin/groff/libXdvi/Menu.h deleted file mode 100644 index c306b2740a61..000000000000 --- a/gnu/usr.bin/groff/libXdvi/Menu.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * $XConsortium: Menu.h,v 1.2 89/07/21 14:22:10 jim Exp $ - */ - -#ifndef _XtMenu_h -#define _XtMenu_h - -/*********************************************************************** - * - * Menu Widget - * - ***********************************************************************/ - -/* Parameters: - - Name Class RepType Default Value - ---- ----- ------- ------------- - background Background pixel White - border BorderColor pixel Black - borderWidth BorderWidth int 1 - height Height int 120 - mappedWhenManaged MappedWhenManaged Boolean True - reverseVideo ReverseVideo Boolean False - width Width int 120 - x Position int 0 - y Position int 0 - -*/ - -#define XtNmenuEntries "menuEntries" -#define XtNhorizontalPadding "horizontalPadding" -#define XtNverticalPadding "verticalPadding" -#define XtNselection "Selection" - -#define XtCMenuEntries "MenuEntries" -#define XtCPadding "Padding" -#define XtCSelection "Selection" - -typedef struct _MenuRec *MenuWidget; /* completely defined in MenuPrivate.h */ -typedef struct _MenuClassRec *MenuWidgetClass; /* completely defined in MenuPrivate.h */ - -extern WidgetClass menuWidgetClass; - -extern Widget XawMenuCreate (); -#endif /* _XtMenu_h */ -/* DON'T ADD STUFF AFTER THIS #endif */ diff --git a/gnu/usr.bin/groff/libXdvi/XFontName.c b/gnu/usr.bin/groff/libXdvi/XFontName.c deleted file mode 100644 index e214421d7dba..000000000000 --- a/gnu/usr.bin/groff/libXdvi/XFontName.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * XFontName.c - * - * build/parse X Font name strings - */ - -# include -# include "XFontName.h" -#include - -static char * -extractStringField (name, buffer, size, attrp, bit) - char *name; - char *buffer; - int size; - unsigned int *attrp; - unsigned int bit; -{ - char *buf = buffer; - - if (!*name) - return 0; - while (*name && *name != '-' && size > 0) { - *buf++ = *name++; - --size; - } - if (size <= 0) - return 0; - *buf = '\0'; - if (buffer[0] != '*' || buffer[1] != '\0') - *attrp |= bit; - if (*name == '-') - return name+1; - return name; -} - -static char * -extractUnsignedField (name, result, attrp, bit) - char *name; - unsigned int *result; - unsigned int *attrp; - unsigned int bit; -{ - char buf[256]; - char *c; - unsigned int i; - - name = extractStringField (name, buf, sizeof (buf), attrp, bit); - if (!name) - return 0; - if (!(*attrp & bit)) - return name; - i = 0; - for (c = buf; *c; c++) { - if (!isdigit (*c)) - return 0; - i = i * 10 + (*c - '0'); - } - *result = i; - return name; -} - -Bool -XParseFontName (fontNameString, fontName, fontNameAttributes) - XFontNameString fontNameString; - XFontName *fontName; - unsigned int *fontNameAttributes; -{ - char *name = fontNameString; - XFontName temp; - unsigned int attributes = 0; - -#define GetString(field,bit)\ - if (!(name = extractStringField \ - (name, temp.field, sizeof (temp.field),\ - &attributes, bit))) \ - return False; - -#define GetUnsigned(field,bit)\ - if (!(name = extractUnsignedField \ - (name, &temp.field, \ - &attributes, bit))) \ - return False; - - GetString (Registry, FontNameRegistry) - GetString (Foundry, FontNameFoundry) - GetString (FamilyName, FontNameFamilyName) - GetString (WeightName, FontNameWeightName) - GetString (Slant, FontNameSlant) - GetString (SetwidthName, FontNameSetwidthName) - GetString (AddStyleName, FontNameAddStyleName) - GetUnsigned (PixelSize, FontNamePixelSize) - GetUnsigned (PointSize, FontNamePointSize) - GetUnsigned (ResolutionX, FontNameResolutionX) - GetUnsigned (ResolutionY, FontNameResolutionY) - GetString (Spacing, FontNameSpacing) - GetUnsigned (AverageWidth, FontNameAverageWidth) - GetString (CharSetRegistry, FontNameCharSetRegistry) - if (!*name) { - temp.CharSetEncoding[0] = '\0'; - attributes |= FontNameCharSetEncoding; - } else { - GetString (CharSetEncoding, FontNameCharSetEncoding) - } - *fontName = temp; - *fontNameAttributes = attributes; - return True; -} - -static char * -utoa (u, s, size) - unsigned int u; - char *s; - int size; -{ - char *t; - - t = s + size; - *--t = '\0'; - do - *--t = (u % 10) + '0'; - while (u /= 10); - return t; -} - -Bool -XFormatFontName (fontName, fontNameAttributes, fontNameString) - XFontName *fontName; - unsigned int fontNameAttributes; - XFontNameString fontNameString; -{ - XFontNameString tmp; - char *name = tmp, *f; - int left = sizeof (tmp) - 1; - char number[32]; - -#define PutString(field, bit)\ - f = (fontNameAttributes & bit) ? \ - fontName->field \ - : "*"; \ - if ((left -= strlen (f)) < 0) \ - return False; \ - while (*f) \ - if ((*name++ = *f++) == '-') \ - return False; -#define PutHyphen()\ - if (--left < 0) \ - return False; \ - *name++ = '-'; - -#define PutUnsigned(field, bit) \ - f = (fontNameAttributes & bit) ? \ - utoa (fontName->field, number, sizeof (number)) \ - : "*"; \ - if ((left -= strlen (f)) < 0) \ - return False; \ - while (*f) \ - *name++ = *f++; - - PutString (Registry, FontNameRegistry) - PutHyphen (); - PutString (Foundry, FontNameFoundry) - PutHyphen (); - PutString (FamilyName, FontNameFamilyName) - PutHyphen (); - PutString (WeightName, FontNameWeightName) - PutHyphen (); - PutString (Slant, FontNameSlant) - PutHyphen (); - PutString (SetwidthName, FontNameSetwidthName) - PutHyphen (); - PutString (AddStyleName, FontNameAddStyleName) - PutHyphen (); - PutUnsigned (PixelSize, FontNamePixelSize) - PutHyphen (); - PutUnsigned (PointSize, FontNamePointSize) - PutHyphen (); - PutUnsigned (ResolutionX, FontNameResolutionX) - PutHyphen (); - PutUnsigned (ResolutionY, FontNameResolutionY) - PutHyphen (); - PutString (Spacing, FontNameSpacing) - PutHyphen (); - PutUnsigned (AverageWidth, FontNameAverageWidth) - PutHyphen (); - PutString (CharSetRegistry, FontNameCharSetRegistry) - PutHyphen (); - PutString (CharSetEncoding, FontNameCharSetEncoding) - *name = '\0'; - strcpy (fontNameString, tmp); -} - -Bool -XCompareFontName (name1, name2, fontNameAttributes) - XFontName *name1, *name2; - unsigned int fontNameAttributes; -{ -#define CompareString(field,bit) \ - if (fontNameAttributes & bit) \ - if (strcmp (name1->field, name2->field)) \ - return False; - -#define CompareUnsigned(field,bit) \ - if (fontNameAttributes & bit) \ - if (name1->field != name2->field) \ - return False; - - CompareString (Registry, FontNameRegistry) - CompareString (Foundry, FontNameFoundry) - CompareString (FamilyName, FontNameFamilyName) - CompareString (WeightName, FontNameWeightName) - CompareString (Slant, FontNameSlant) - CompareString (SetwidthName, FontNameSetwidthName) - CompareString (AddStyleName, FontNameAddStyleName) - CompareUnsigned (PixelSize, FontNamePixelSize) - CompareUnsigned (PointSize, FontNamePointSize) - CompareUnsigned (ResolutionX, FontNameResolutionX) - CompareUnsigned (ResolutionY, FontNameResolutionY) - CompareString (Spacing, FontNameSpacing) - CompareUnsigned (AverageWidth, FontNameAverageWidth) - CompareString (CharSetRegistry, FontNameCharSetRegistry) - CompareString (CharSetEncoding, FontNameCharSetEncoding) - return True; -} - -XCopyFontName (name1, name2, fontNameAttributes) - XFontName *name1, *name2; - unsigned int fontNameAttributes; -{ -#define CopyString(field,bit) \ - if (fontNameAttributes & bit) \ - strcpy (name2->field, name1->field); - -#define CopyUnsigned(field,bit) \ - if (fontNameAttributes & bit) \ - name2->field = name1->field; - - CopyString (Registry, FontNameRegistry) - CopyString (Foundry, FontNameFoundry) - CopyString (FamilyName, FontNameFamilyName) - CopyString (WeightName, FontNameWeightName) - CopyString (Slant, FontNameSlant) - CopyString (SetwidthName, FontNameSetwidthName) - CopyString (AddStyleName, FontNameAddStyleName) - CopyUnsigned (PixelSize, FontNamePixelSize) - CopyUnsigned (PointSize, FontNamePointSize) - CopyUnsigned (ResolutionX, FontNameResolutionX) - CopyUnsigned (ResolutionY, FontNameResolutionY) - CopyString (Spacing, FontNameSpacing) - CopyUnsigned (AverageWidth, FontNameAverageWidth) - CopyString (CharSetRegistry, FontNameCharSetRegistry) - CopyString (CharSetEncoding, FontNameCharSetEncoding) - return True; -} diff --git a/gnu/usr.bin/groff/libXdvi/XFontName.h b/gnu/usr.bin/groff/libXdvi/XFontName.h deleted file mode 100644 index efe9eb16d1d4..000000000000 --- a/gnu/usr.bin/groff/libXdvi/XFontName.h +++ /dev/null @@ -1,45 +0,0 @@ -typedef struct _xFontName { - char Registry[256]; - char Foundry[256]; - char FamilyName[256]; - char WeightName[256]; - char Slant[3]; - char SetwidthName[256]; - char AddStyleName[256]; - unsigned int PixelSize; - unsigned int PointSize; - unsigned int ResolutionX; - unsigned int ResolutionY; - char Spacing[2]; - unsigned int AverageWidth; - char CharSetRegistry[256]; - char CharSetEncoding[256]; -} XFontName; - -#define FontNameRegistry (1<<0) -#define FontNameFoundry (1<<1) -#define FontNameFamilyName (1<<2) -#define FontNameWeightName (1<<3) -#define FontNameSlant (1<<4) -#define FontNameSetwidthName (1<<5) -#define FontNameAddStyleName (1<<6) -#define FontNamePixelSize (1<<7) -#define FontNamePointSize (1<<8) -#define FontNameResolutionX (1<<9) -#define FontNameResolutionY (1<<10) -#define FontNameSpacing (1<<11) -#define FontNameAverageWidth (1<<12) -#define FontNameCharSetRegistry (1<<13) -#define FontNameCharSetEncoding (1<<14) - -#define SlantRoman "R" -#define SlantItalic "I" -#define SlantOblique "O" -#define SlantReverseItalic "RI" -#define SlantReverseOblique "RO" - -#define SpacingMonoSpaced "M" -#define SpacingProportional "P" -#define SpacingCharacterCell "C" - -typedef char XFontNameString[256]; diff --git a/gnu/usr.bin/groff/libXdvi/draw.c b/gnu/usr.bin/groff/libXdvi/draw.c deleted file mode 100644 index 5c9f3ac99eca..000000000000 --- a/gnu/usr.bin/groff/libXdvi/draw.c +++ /dev/null @@ -1,368 +0,0 @@ -/* - * draw.c - * - * accept dvi function calls and translate to X - */ - -#include -#include -#include -#include -#include -#include - -/* math.h on a Sequent doesn't define M_PI, apparently */ -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#include "DviP.h" - -HorizontalMove(dw, delta) - DviWidget dw; - int delta; -{ - dw->dvi.state->x += delta; -} - -HorizontalGoto(dw, NewPosition) - DviWidget dw; - int NewPosition; -{ - dw->dvi.state->x = NewPosition; -} - -VerticalMove(dw, delta) - DviWidget dw; - int delta; -{ - dw->dvi.state->y += delta; -} - -VerticalGoto(dw, NewPosition) - DviWidget dw; - int NewPosition; -{ - dw->dvi.state->y = NewPosition; -} - -FlushCharCache (dw) - DviWidget dw; -{ - if (dw->dvi.cache.char_index != 0) - XDrawText (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - dw->dvi.cache.start_x, dw->dvi.cache.start_y, - dw->dvi.cache.cache, dw->dvi.cache.index + 1); - dw->dvi.cache.index = 0; - dw->dvi.cache.max = DVI_TEXT_CACHE_SIZE; - if (dw->dvi.noPolyText) - dw->dvi.cache.max = 1; - dw->dvi.cache.char_index = 0; - dw->dvi.cache.cache[0].nchars = 0; - dw->dvi.cache.start_x = dw->dvi.cache.x = dw->dvi.state->x; - dw->dvi.cache.start_y = dw->dvi.cache.y = dw->dvi.state->y; -} - -ClearPage (dw) - DviWidget dw; -{ - XClearWindow (XtDisplay (dw), XtWindow (dw)); -} - -static -setGC (dw) - DviWidget dw; -{ - int desired_line_width; - - if (dw->dvi.line_thickness < 0) { - desired_line_width = (((dw->dvi.device_resolution - * dw->dvi.state->font_size) + 5*72) - / (10*72)); - if (desired_line_width == 0) - desired_line_width = 1; - } - else - desired_line_width = dw->dvi.line_thickness; - - if (desired_line_width != dw->dvi.line_width) { - XGCValues values; - values.line_width = desired_line_width; - XChangeGC(XtDisplay (dw), dw->dvi.normal_GC, - GCLineWidth, &values); - dw->dvi.line_width = desired_line_width; - } -} - -static -setFillGC (dw) - DviWidget dw; -{ - int fill_type; - - if (dw->dvi.fill == DVI_FILL_MAX) - fill_type = DVI_FILL_BLACK; - else if (dw->dvi.fill == 0) - fill_type = DVI_FILL_WHITE; - else - fill_type = DVI_FILL_GRAY; - if (dw->dvi.fill_type != fill_type) { - XGCValues values; - switch (fill_type) { - case DVI_FILL_WHITE: - values.foreground = dw->dvi.background; - values.fill_style = FillSolid; - break; - case DVI_FILL_BLACK: - values.foreground = dw->dvi.foreground; - values.fill_style = FillSolid; - break; - case DVI_FILL_GRAY: - values.foreground = dw->dvi.foreground; - values.fill_style = FillOpaqueStippled; - break; - } - XChangeGC(XtDisplay (dw), dw->dvi.fill_GC, - GCFillStyle|GCForeground, - &values); - dw->dvi.fill_type = fill_type; - } -} - -DrawLine (dw, x, y) - DviWidget dw; - int x, y; -{ - setGC (dw); - XDrawLine (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - dw->dvi.state->x, dw->dvi.state->y, - dw->dvi.state->x + x, dw->dvi.state->y + y); -} - -DrawCircle (dw, diam) - DviWidget dw; - int diam; -{ - setGC (dw); - XDrawArc (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - dw->dvi.state->x, dw->dvi.state->y - diam/2, - diam, diam, 0, 64*360); -} - -DrawFilledCircle (dw, diam) - DviWidget dw; - int diam; -{ - setFillGC (dw); - XFillArc (XtDisplay (dw), XtWindow (dw), dw->dvi.fill_GC, - dw->dvi.state->x, dw->dvi.state->y - diam/2, - diam, diam, 0, 64*360); -} - -DrawEllipse (dw, a, b) - DviWidget dw; - int a, b; -{ - setGC (dw); - XDrawArc (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - dw->dvi.state->x, dw->dvi.state->y - b/2, - a, b, 0, 64*360); -} - -DrawFilledEllipse (dw, a, b) - DviWidget dw; - int a, b; -{ - setFillGC (dw); - XFillArc (XtDisplay (dw), XtWindow (dw), dw->dvi.fill_GC, - dw->dvi.state->x, dw->dvi.state->y - b/2, - a, b, 0, 64*360); -} - -DrawArc (dw, x0, y0, x1, y1) - DviWidget dw; - int x0, y0, x1, y1; -{ - int x, y; - int angle1, angle2; - int rad = (int)((sqrt ((double)x0*x0 + (double)y0*y0) - + sqrt ((double)x1*x1 + (double)y1*y1) + 1.0)/2.0); - if ((x0 == 0 && y0 == 0) || (x1 == 0 && y1 == 0)) - return; - angle1 = (int)(atan2 ((double)y0, (double)-x0)*180.0*64.0/M_PI); - angle2 = (int)(atan2 ((double)-y1, (double)x1)*180.0*64.0/M_PI); - - angle2 -= angle1; - if (angle2 < 0) - angle2 += 64*360; - - setGC (dw); - XDrawArc (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - dw->dvi.state->x + x0 - rad, dw->dvi.state->y + y0 - rad, - rad*2, rad*2, angle1, angle2); -} - -DrawPolygon (dw, v, n) - DviWidget dw; - int *v; - int n; -{ - extern char *malloc(); - XPoint *p; - int i; - - n /= 2; - - setGC (dw); - p = (XPoint *)malloc((n + 2)*sizeof(XPoint)); - if (p == NULL) - return; - p[0].x = dw->dvi.state->x; - p[0].y = dw->dvi.state->y; - for (i = 0; i < n; i++) { - p[i + 1].x = v[2*i] + p[i].x; - p[i + 1].y = v[2*i + 1] + p[i].y; - } - p[n+1].x = dw->dvi.state->x; - p[n+1].y = dw->dvi.state->y; - XDrawLines (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - p, n + 2, CoordModeOrigin); - free(p); -} - - -DrawFilledPolygon (dw, v, n) - DviWidget dw; - int *v; - int n; -{ - extern char *malloc(); - XPoint *p; - int i; - - n /= 2; - if (n < 2) - return; - - setFillGC (dw); - p = (XPoint *)malloc((n + 1)*sizeof(XPoint)); - if (p == NULL) - return; - p[0].x = dw->dvi.state->x; - p[0].y = dw->dvi.state->y; - for (i = 0; i < n; i++) { - p[i + 1].x = v[2*i]; - p[i + 1].y = v[2*i + 1]; - } - XFillPolygon (XtDisplay (dw), XtWindow (dw), dw->dvi.fill_GC, - p, n + 1, Complex, CoordModePrevious); - free(p); -} - -#define POINTS_MAX 10000 - -static -appendPoint(points, pointi, x, y) - XPoint *points; - int *pointi; - int x, y; -{ - if (*pointi < POINTS_MAX) { - points[*pointi].x = x; - points[*pointi].y = y; - *pointi += 1; - } -} - -#define FLATNESS 1 - -static -flattenCurve(points, pointi, x2, y2, x3, y3, x4, y4) - XPoint *points; - int *pointi; - int x2, y2, x3, y3, x4, y4; -{ - int x1, y1, dx, dy, n1, n2, n; - - x1 = points[*pointi - 1].x; - y1 = points[*pointi - 1].y; - - dx = x4 - x1; - dy = y4 - y1; - - n1 = dy*(x2 - x1) - dx*(y2 - y1); - n2 = dy*(x3 - x1) - dx*(y3 - y1); - if (n1 < 0) - n1 = -n1; - if (n2 < 0) - n2 = -n2; - n = n1 > n2 ? n1 : n2; - - if (n*n / (dy*dy + dx*dx) <= FLATNESS*FLATNESS) - appendPoint (points, pointi, x4, y4); - else { - flattenCurve (points, pointi, - (x1 + x2)/2, (y1 + y2)/2, - (x1 + x2*2 + x3)/4, (y1 + y2*2 + y3)/4, - (x1 +3*x2 + 3*x3 + x4)/8, (y1 +3*y2 + 3*y3 + y4)/8); - flattenCurve (points, pointi, - (x2 + x3*2 + x4)/4, (y2 + y3*2 + y4)/4, - (x3 + x4)/2, (y3 + y4)/2, - x4, y4); - } -} - - -DrawSpline (dw, v, n) - DviWidget dw; - int *v; - int n; -{ - int sx, sy, tx, ty, ux, uy; - int i; - int pointi; - XPoint points[POINTS_MAX]; - - if (n == 0 || (n & 1) != 0) - return; - setGC (dw); - sx = dw->dvi.state->x; - sy = dw->dvi.state->y; - tx = sx + v[0]; - ty = sy + v[1]; - - pointi = 0; - - appendPoint (points, &pointi, sx, sy); - appendPoint (points, &pointi, (sx + tx)/2, (sy + ty)/2); - - for (i = 2; i < n; i += 2) { - int ux = tx + v[i]; - int uy = ty + v[i+1]; - flattenCurve (points, &pointi, - (sx + tx*5)/6, (sy + ty*5)/6, - (tx*5 + ux)/6, (ty*5 + uy)/6, - (tx + ux)/2, (ty + uy)/2); - sx = tx; - sy = ty; - tx = ux; - ty = uy; - } - - appendPoint (points, &pointi, tx, ty); - - XDrawLines (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC, - points, pointi, CoordModeOrigin); -} - - -/* -Local Variables: -c-indent-level: 8 -c-continued-statement-offset: 8 -c-brace-offset: -8 -c-argdecl-indent: 8 -c-label-offset: -8 -c-tab-always-indent: nil -End: -*/ diff --git a/gnu/usr.bin/groff/libXdvi/font.c b/gnu/usr.bin/groff/libXdvi/font.c deleted file mode 100644 index e99883552df4..000000000000 --- a/gnu/usr.bin/groff/libXdvi/font.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * font.c - * - * map dvi fonts to X fonts - */ - -#include -#include -#include -#include -#include -#include "DviP.h" -#include "XFontName.h" - -extern char *malloc (); - -static char * -savestr (s) - char *s; -{ - char *n; - - if (!s) - return 0; - n = malloc (strlen (s) + 1); - if (n) - strcpy (n, s); - return n; -} - -static DviFontList * -LookupFontByPosition (dw, position) - DviWidget dw; - int position; -{ - DviFontList *f; - - for (f = dw->dvi.fonts; f; f=f->next) - if (f->dvi_number == position) - break; - return f; -} - -static DviFontSizeList * -LookupFontSizeBySize (f, size) - DviFontList *f; - int size; -{ - DviFontSizeList *fs, *best = 0; - int bestsize = 0; - - for (fs = f->sizes; fs; fs=fs->next) { - if (fs->size <= size && fs->size >= bestsize) { - best = fs; - bestsize = fs->size; - } - } - return best; -} - -static char * -SkipFontNameElement (n) - char *n; -{ - while (*n != '-') - if (!*++n) - return 0; - return n+1; -} - -# define SizePosition 8 -# define EncodingPosition 13 - -static -ConvertFontNameToSize (n) - char *n; -{ - int i, size; - - for (i = 0; i < SizePosition; i++) { - n = SkipFontNameElement (n); - if (!n) - return -1; - } - size = atoi (n); - return size/10; -} - -static char * -ConvertFontNameToEncoding (n) - char *n; -{ - int i; - for (i = 0; i < EncodingPosition; i++) { - n = SkipFontNameElement (n); - if (!n) - return 0; - } - return n; -} - -DviFontSizeList * -InstallFontSizes (dw, x_name) - DviWidget dw; - char *x_name; -{ - char fontNameString[2048]; - char **fonts; - int i, count; - int size; - DviFontSizeList *sizes, *new; - XFontName fontName; - unsigned int fontNameAttributes; - - if (!XParseFontName (x_name, &fontName, &fontNameAttributes)) - return; - fontNameAttributes &= ~(FontNamePixelSize|FontNamePointSize); - fontNameAttributes |= FontNameResolutionX; - fontNameAttributes |= FontNameResolutionY; - fontName.ResolutionX = dw->dvi.device_resolution; - fontName.ResolutionY = dw->dvi.device_resolution; - XFormatFontName (&fontName, fontNameAttributes, fontNameString); - fonts = XListFonts (XtDisplay (dw), fontNameString, 10000000, &count); - sizes = 0; - for (i = 0; i < count; i++) { - if ((size = ConvertFontNameToSize (fonts[i])) != -1) { - new = (DviFontSizeList *) malloc (sizeof *new); - new->next = sizes; - new->size = size; - new->x_name = savestr (fonts[i]); - new->doesnt_exist = 0; - new->font = 0; - sizes = new; - } - } - XFreeFontNames (fonts); - return sizes; -} - -static -DisposeFontSizes (fs) - DviFontSizeList *fs; -{ - DviFontSizeList *next; - - for (; fs; fs=next) { - next = fs->next; - if (fs->x_name) - free (fs->x_name); - if (fs->font) - XFree ((char *)fs->font); - free ((char *) fs); - } -} - -static DviFontList * -InstallFont (dw, position, dvi_name, x_name) - DviWidget dw; - int position; - char *dvi_name; - char *x_name; -{ - DviFontList *f; - DviFontSizeList *sizes; - char *encoding; - - if (f = LookupFontByPosition (dw, position)) { - /* - * ignore gratuitous font loading - */ - if (!strcmp (f->dvi_name, dvi_name) && - !strcmp (f->x_name, x_name)) - return; - - sizes = InstallFontSizes (dw, x_name); - if (!sizes) - return f; - - DisposeFontSizes (f->sizes); - if (f->dvi_name) - free (f->dvi_name); - if (f->x_name) - free (f->x_name); - } else { - sizes = InstallFontSizes (dw, x_name); - if (!sizes) - return 0; - f = (DviFontList *) malloc (sizeof (*f)); - f->next = dw->dvi.fonts; - dw->dvi.fonts = f; - } - f->dvi_name = savestr (dvi_name); - f->x_name = savestr (x_name); - f->dvi_number = position; - f->sizes = sizes; - if (f->x_name) { - encoding = ConvertFontNameToEncoding (f->x_name); - f->char_map = DviFindMap (encoding); - } else - f->char_map = 0; - /* - * force requery of fonts - */ - dw->dvi.font = 0; - dw->dvi.font_number = -1; - dw->dvi.cache.font = 0; - dw->dvi.cache.font_number = -1; - return f; -} - -static char * -MapDviNameToXName (dw, dvi_name) - DviWidget dw; - char *dvi_name; -{ - DviFontMap *fm; - - for (fm = dw->dvi.font_map; fm; fm=fm->next) - if (!strcmp (fm->dvi_name, dvi_name)) - return fm->x_name; - return 0; -} - -static char * -MapXNameToDviName (dw, x_name) - DviWidget dw; - char *x_name; -{ - DviFontMap *fm; - - for (fm = dw->dvi.font_map; fm; fm=fm->next) - if (!strcmp (fm->x_name, x_name)) - return fm->dvi_name; - return 0; -} - -ParseFontMap (dw) - DviWidget dw; -{ - char dvi_name[1024]; - char x_name[2048]; - char *m, *s; - char *encoding; - DviFontMap *fm, *new; - - if (dw->dvi.font_map) - DestroyFontMap (dw->dvi.font_map); - fm = 0; - m = dw->dvi.font_map_string; - while (*m) { - s = m; - while (*m && !isspace (*m)) - ++m; - strncpy (dvi_name, s, m-s); - dvi_name[m-s] = '\0'; - while (isspace (*m)) - ++m; - s = m; - while (*m && *m != '\n') - ++m; - strncpy (x_name, s, m-s); - x_name[m-s] = '\0'; - new = (DviFontMap *) malloc (sizeof *new); - new->x_name = savestr (x_name); - new->dvi_name = savestr (dvi_name); - new->next = fm; - fm = new; - ++m; - } - dw->dvi.font_map = fm; -} - -DestroyFontMap (font_map) - DviFontMap *font_map; -{ - DviFontMap *next; - - for (; font_map; font_map = next) { - next = font_map->next; - if (font_map->x_name) - free (font_map->x_name); - if (font_map->dvi_name) - free (font_map->dvi_name); - free ((char *) font_map); - } -} - -SetFontPosition (dw, position, dvi_name, extra) - DviWidget dw; - int position; - char *dvi_name; - char *extra; /* unused */ -{ - char *x_name; - - x_name = MapDviNameToXName (dw, dvi_name); - (void) InstallFont (dw, position, dvi_name, x_name); -} - -XFontStruct * -QueryFont (dw, position, size) - DviWidget dw; - int position; - int size; -{ - DviFontList *f; - DviFontSizeList *fs; - - f = LookupFontByPosition (dw, position); - if (!f) - return dw->dvi.default_font; - fs = LookupFontSizeBySize (f, size); - if (!fs->font) { - if (fs->x_name) - fs->font = XLoadQueryFont (XtDisplay (dw), fs->x_name); - if (!fs->font) - fs->font = dw->dvi.default_font; - } - return fs->font; -} - -DviCharNameMap * -QueryFontMap (dw, position) - DviWidget dw; - int position; -{ - DviFontList *f; - char *encoding; - - f = LookupFontByPosition (dw, position); - if (f) - return f->char_map; - else - return 0; -} - -LoadFont (dw, position, size) - DviWidget dw; - int position; - int size; -{ - XFontStruct *font; - - font = QueryFont (dw, position, size); - dw->dvi.font_number = position; - dw->dvi.font_size = size; - dw->dvi.font = font; - XSetFont (XtDisplay (dw), dw->dvi.normal_GC, font->fid); - return; -} diff --git a/gnu/usr.bin/groff/libXdvi/lex.c b/gnu/usr.bin/groff/libXdvi/lex.c deleted file mode 100644 index 4c7d3ced7011..000000000000 --- a/gnu/usr.bin/groff/libXdvi/lex.c +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include -#include -#include -#include "DviP.h" - -DviGetAndPut(dw, cp) - DviWidget dw; - int *cp; -{ - if (dw->dvi.ungot) - { - dw->dvi.ungot = 0; - *cp = getc (dw->dvi.file); - } - else - { - *cp = getc (dw->dvi.file); - putc (*cp, dw->dvi.tmpFile); - } - return *cp; -} - -char * -GetLine(dw, Buffer, Length) - DviWidget dw; - char *Buffer; - int Length; -{ - int i = 0, c; - char *p = Buffer; - - Length--; /* Save room for final NULL */ - - while (i < Length && DviGetC (dw, &c) != EOF && c != '\n') - if (p) - *p++ = c; - if (c == '\n' && p) /* Retain the newline like fgets */ - *p++ = c; - if (c == '\n') - DviUngetC(dw, c); - if (p) - *p = NULL; - return (Buffer); -} - -char * -GetWord(dw, Buffer, Length) - DviWidget dw; - char *Buffer; - int Length; -{ - int i = 0, c; - char *p = Buffer; - - Length--; /* Save room for final NULL */ - while (DviGetC(dw, &c) != EOF && (c == ' ' || c == '\n')) - ; - if (c != EOF) - DviUngetC(dw, c); - while (i < Length && DviGetC(dw, &c) != EOF && c != ' ' && c != '\n') - if (p) - *p++ = c; - if (c != EOF) - DviUngetC(dw, c); - if (p) - *p = NULL; - return (Buffer); -} - -GetNumber(dw) - DviWidget dw; -{ - int i = 0, c; - int negative = 0; - - while (DviGetC(dw, &c) != EOF && (c == ' ' || c == '\n')) - ; - if (c != EOF) - DviUngetC(dw, c); - - while (DviGetC(dw, &c) != EOF && c >= '0' && c <= '9') { - if (negative) - i = i*10 - (c - '0'); - else - i = i*10 + c - '0'; - } - - if (c != EOF) - DviUngetC(dw, c); - return (i); -} - -/* -Local Variables: -c-indent-level: 8 -c-continued-statement-offset: 8 -c-brace-offset: -8 -c-argdecl-indent: 8 -c-label-offset: -8 -c-tab-always-indent: nil -End: -*/ diff --git a/gnu/usr.bin/groff/libXdvi/page.c b/gnu/usr.bin/groff/libXdvi/page.c deleted file mode 100644 index 0c5a5f6080ea..000000000000 --- a/gnu/usr.bin/groff/libXdvi/page.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * page.c - * - * map page numbers to file position - */ - -#include -#include -#include -#include -#include -#include "DviP.h" - -static DviFileMap * -MapPageNumberToFileMap (dw, number) - DviWidget dw; - int number; -{ - DviFileMap *m; - - for (m = dw->dvi.file_map; m; m=m->next) - if (m->page_number == number) - break; - return m; -} - -DestroyFileMap (m) - DviFileMap *m; -{ - DviFileMap *next; - - for (; m; m = next) { - next = m->next; - free ((char *) m); - } -} - -ForgetPagePositions (dw) - DviWidget dw; -{ - DestroyFileMap (dw->dvi.file_map); - dw->dvi.file_map = 0; -} - -RememberPagePosition(dw, number) - DviWidget dw; - int number; -{ - extern long ftell(); - DviFileMap *m; - - if (!(m = MapPageNumberToFileMap (dw, number))) { - m = (DviFileMap *) malloc (sizeof *m); - m->page_number = number; - m->next = dw->dvi.file_map; - dw->dvi.file_map = m; - } - if (dw->dvi.tmpFile) - m->position = ftell (dw->dvi.tmpFile); - else - m->position = ftell (dw->dvi.file); -} - -SearchPagePosition (dw, number) - DviWidget dw; - int number; -{ - DviFileMap *m; - - if (!(m = MapPageNumberToFileMap (dw, number))) - return -1; - return m->position; -} - -FileSeek(dw, position) -DviWidget dw; -long position; -{ - if (dw->dvi.tmpFile) { - dw->dvi.readingTmp = 1; - fseek (dw->dvi.tmpFile, position, 0); - } else - fseek (dw->dvi.file, position, 0); -} - diff --git a/gnu/usr.bin/groff/libXdvi/parse.c b/gnu/usr.bin/groff/libXdvi/parse.c deleted file mode 100644 index b10936907a2c..000000000000 --- a/gnu/usr.bin/groff/libXdvi/parse.c +++ /dev/null @@ -1,419 +0,0 @@ -/* - * parse.c - * - * parse dvi input - */ - -#include -#include -#include -#include -#include -#include "DviP.h" - -static int StopSeen = 0; -static ParseDrawFunction(), ParseDeviceControl(); -static push_env(), pop_env(); - -#define HorizontalMove(dw, delta) ((dw)->dvi.state->x += (delta)) - -#define charWidth(fi,c) (\ - (fi)->per_char ?\ - (fi)->per_char[(c) - (fi)->min_char_or_byte2].width\ - :\ - (fi)->max_bounds.width\ -) - - -int charExists (fi, c) - XFontStruct *fi; - int c; -{ - XCharStruct *p; - - if (c < fi->min_char_or_byte2 || c > fi->max_char_or_byte2) - return 0; - p = fi->per_char + (c - fi->min_char_or_byte2); - return (p->lbearing != 0 || p->rbearing != 0 || p->width != 0 - || p->ascent != 0 || p->descent != 0 || p->attributes != 0); -} - - -ParseInput(dw) - register DviWidget dw; -{ - int n, k; - int c; - char Buffer[BUFSIZ]; - int NextPage; - int prevFont; - int otherc; - - StopSeen = 0; - - /* - * make sure some state exists - */ - - if (!dw->dvi.state) - push_env (dw); - for (;;) { - switch (DviGetC(dw, &c)) { - case '\n': - break; - case ' ': /* when input is text */ - case 0: /* occasional noise creeps in */ - break; - case '{': /* push down current environment */ - push_env(dw); - break; - case '}': - pop_env(dw); - break; - /* - * two motion digits plus a character - */ - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - HorizontalMove(dw, (c-'0')*10 + - DviGetC(dw,&otherc)-'0'); - /* fall through */ - case 'c': /* single ascii character */ - DviGetC(dw,&c); - if (c == ' ') - break; - Buffer[0] = c; - Buffer[1] = '\0'; - goto FunnyCharacter; - - case 'C': - GetWord(dw, Buffer, BUFSIZ); - FunnyCharacter: - prevFont = -1; - c = -1; - { - DviCharNameMap *map; - int i; - - map = QueryFontMap (dw, dw->dvi.state->font_number); - if (map) { - c = DviCharIndex (map, Buffer); - if (c == -1) { - for (i = 1; map = QueryFontMap (dw, i); i++) - if (map->special) - if ((c = DviCharIndex (map, Buffer)) != -1) { - prevFont = dw->dvi.state->font_number; - dw->dvi.state->font_number = i; - break; - } - } - } - } - if (c == -1) - break; - NumberedCharacter: - /* - * quick and dirty extents calculation: - */ - if (dw->dvi.state->y + 24 >= dw->dvi.extents.y1 && - dw->dvi.state->y - 24 <= dw->dvi.extents.y2 && - dw->dvi.state->x + 24 >= dw->dvi.extents.x1 && - dw->dvi.state->x - 24 <= dw->dvi.extents.x2) - { - register XFontStruct *font; - register XTextItem *text; - - if (!dw->dvi.display_enable) - break; - - if (dw->dvi.state->y != dw->dvi.cache.y || - dw->dvi.cache.char_index >= DVI_CHAR_CACHE_SIZE) - FlushCharCache (dw); - /* - * load a new font, if the current block is not empty, - * step to the next. - */ - if (dw->dvi.cache.font_size != dw->dvi.state->font_size || - dw->dvi.cache.font_number != dw->dvi.state->font_number) - { - dw->dvi.cache.font_size = dw->dvi.state->font_size; - dw->dvi.cache.font_number = dw->dvi.state->font_number; - dw->dvi.cache.font = QueryFont (dw, - dw->dvi.cache.font_number, - dw->dvi.cache.font_size); - if (dw->dvi.cache.cache[dw->dvi.cache.index].nchars != 0) { - ++dw->dvi.cache.index; - if (dw->dvi.cache.index >= dw->dvi.cache.max) - FlushCharCache (dw); - dw->dvi.cache.cache[dw->dvi.cache.index].nchars = 0; - } - } - if (dw->dvi.cache.x != dw->dvi.state->x) { - if (dw->dvi.cache.cache[dw->dvi.cache.index].nchars != 0) { - ++dw->dvi.cache.index; - if (dw->dvi.cache.index >= dw->dvi.cache.max) - FlushCharCache (dw); - dw->dvi.cache.cache[dw->dvi.cache.index].nchars = 0; - } - } - font = dw->dvi.cache.font; - text = &dw->dvi.cache.cache[dw->dvi.cache.index]; - if (text->nchars == 0) { - text->chars = &dw->dvi.cache.char_cache[dw->dvi.cache.char_index]; - text->delta = dw->dvi.state->x - dw->dvi.cache.x; - if (font != dw->dvi.font) { - text->font = font->fid; - dw->dvi.font = font; - } else - text->font = None; - dw->dvi.cache.x += text->delta; - } - if (charExists(font, c)) { - dw->dvi.cache.char_cache[dw->dvi.cache.char_index++] = (char) c; - ++text->nchars; - dw->dvi.cache.x += charWidth(font,c); - } - } - if (prevFont != -1) - dw->dvi.state->font_number = prevFont; - break; - case 'D': /* draw function */ - GetLine(dw, Buffer, BUFSIZ); - if (dw->dvi.display_enable) - ParseDrawFunction(dw, Buffer); - break; - case 's': /* ignore fractional sizes */ - n = GetNumber(dw); - dw->dvi.state->font_size = n; - break; - case 'f': - n = GetNumber(dw); - dw->dvi.state->font_number = n; - break; - case 'H': /* absolute horizontal motion */ - k = GetNumber(dw); - HorizontalGoto(dw, k); - break; - case 'h': /* relative horizontal motion */ - k = GetNumber(dw); - HorizontalMove(dw, k); - break; - case 'w': /* word space */ - break; - case 'V': - n = GetNumber(dw); - VerticalGoto(dw, n); - break; - case 'v': - n = GetNumber(dw); - VerticalMove(dw, n); - break; - case 'P': /* new spread */ - break; - case 'p': /* new page */ - (void) GetNumber(dw); - NextPage = dw->dvi.current_page + 1; - RememberPagePosition(dw, NextPage); - FlushCharCache (dw); - return(NextPage); - case 'N': - c = GetNumber(dw); - goto NumberedCharacter; - case 'n': /* end of line */ - GetNumber(dw); - GetNumber(dw); - HorizontalGoto(dw, 0); - break; - case '+': /* continuation of X device control */ - case '#': /* comment */ - GetLine(dw, NULL, 0); - break; - case 'x': /* device control */ - ParseDeviceControl(dw); - break; - case EOF: - dw->dvi.last_page = dw->dvi.current_page; - FlushCharCache (dw); - return dw->dvi.current_page; - default: - break; - } - } -} - -static -push_env(dw) - DviWidget dw; -{ - DviState *new; - - new = (DviState *) malloc (sizeof (*new)); - if (dw->dvi.state) - *new = *(dw->dvi.state); - else { - new->font_size = 10; - new->font_number = 1; - new->x = 0; - new->y = 0; - } - new->next = dw->dvi.state; - dw->dvi.state = new; -} - -static -pop_env(dw) - DviWidget dw; -{ - DviState *old; - - old = dw->dvi.state; - dw->dvi.state = old->next; - free ((char *) old); -} - -static -InitTypesetter (dw) - DviWidget dw; -{ - while (dw->dvi.state) - pop_env (dw); - push_env (dw); - FlushCharCache (dw); -} - -#define DRAW_ARGS_MAX 128 - -static -ParseDrawFunction(dw, buf) -DviWidget dw; -char *buf; -{ - int v[DRAW_ARGS_MAX]; - int i; - char *ptr; - - v[0] = v[1] = v[2] = v[3] = 0; - - if (buf[0] == '\0') - return; - ptr = buf+1; - - for (i = 0; i < DRAW_ARGS_MAX; i++) { - if (sscanf(ptr, "%d", v + i) != 1) - break; - while (*ptr == ' ') - ptr++; - while (*ptr != '\0' && *ptr != ' ') - ptr++; - } - - switch (buf[0]) { - case 'l': /* draw a line */ - DrawLine(dw, v[0], v[1]); - break; - case 'c': /* circle */ - DrawCircle(dw, v[0]); - break; - case 'C': - DrawFilledCircle(dw, v[0]); - break; - case 'e': /* ellipse */ - DrawEllipse(dw, v[0], v[1]); - break; - case 'E': - DrawFilledEllipse(dw, v[0], v[1]); - break; - case 'a': /* arc */ - DrawArc(dw, v[0], v[1], v[2], v[3]); - break; - case 'p': - DrawPolygon(dw, v, i); - break; - case 'P': - DrawFilledPolygon(dw, v, i); - break; - case '~': /* wiggly line */ - DrawSpline(dw, v, i); - break; - case 't': - dw->dvi.line_thickness = v[0]; - break; - case 'f': - if (i > 0 && v[0] >= 0 && v[0] <= DVI_FILL_MAX) - dw->dvi.fill = v[0]; - break; - default: -#if 0 - warning("unknown drawing function %s", buf); -#endif - break; - } - - if (buf[0] == 'e') { - if (i > 0) - dw->dvi.state->x += v[0]; - } - else { - while (--i >= 0) { - if (i & 1) - dw->dvi.state->y += v[i]; - else - dw->dvi.state->x += v[i]; - } - } -} - -static -ParseDeviceControl(dw) /* Parse the x commands */ - DviWidget dw; -{ - char str[20], str1[50], buf[50]; - int c, n; - extern int LastPage, CurrentPage; - - GetWord (dw, str, 20); - switch (str[0]) { /* crude for now */ - case 'T': /* output device */ - GetWord(dw, str, 20); - break; - case 'i': /* initialize */ - InitTypesetter (dw); - break; - case 't': /* trailer */ - break; - case 'p': /* pause -- can restart */ - break; - case 's': /* stop */ - StopSeen = 1; - return; - case 'r': /* resolution when prepared */ - SetDeviceResolution (dw, GetNumber (dw)); - break; - case 'f': /* font used */ - n = GetNumber(dw); - GetWord(dw, str, 20); - GetLine(dw, str1, 50); - SetFontPosition(dw, n, str, str1); - break; - case 'H': /* char height */ - break; - case 'S': /* slant */ - break; - } - while (DviGetC(dw,&c) != '\n') /* skip rest of input line */ - if (c == EOF) - return; - return; -} - - -/* -Local Variables: -c-indent-level: 8 -c-continued-statement-offset: 8 -c-brace-offset: -8 -c-argdecl-indent: 8 -c-label-offset: -8 -c-tab-always-indent: nil -End: -*/ diff --git a/gnu/usr.bin/groff/libgroff/getpagesize.h b/gnu/usr.bin/groff/libgroff/getpagesize.h deleted file mode 100644 index 32adae61efa2..000000000000 --- a/gnu/usr.bin/groff/libgroff/getpagesize.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifdef BSD -#ifndef BSD4_1 -#define HAVE_GETPAGESIZE -#endif -#endif - -#ifndef HAVE_GETPAGESIZE - -#include - -#ifdef EXEC_PAGESIZE -#define getpagesize() EXEC_PAGESIZE -#else -#ifdef NBPG -#define getpagesize() NBPG * CLSIZE -#ifndef CLSIZE -#define CLSIZE 1 -#endif /* no CLSIZE */ -#else /* no NBPG */ -#define getpagesize() NBPC -#endif /* no NBPG */ -#endif /* no EXEC_PAGESIZE */ - -#endif /* not HAVE_GETPAGESIZE */ - diff --git a/gnu/usr.bin/groff/libgroff/groff.order b/gnu/usr.bin/groff/libgroff/groff.order deleted file mode 100644 index ed1884c11b77..000000000000 --- a/gnu/usr.bin/groff/libgroff/groff.order +++ /dev/null @@ -1,21 +0,0 @@ -version.o -ptable.o -lf.o -iftoa.o -font.o -error.o -errarg.o -cmap.o -change_lf.o -strsave.o -string.o -nametoindex.o -lineno.o -itoa.o -fontfile.o -filename.o -fatal.o -cset.o -assert.o -new.o -progname.o diff --git a/gnu/usr.bin/groff/libgroff/iftoa.cc b/gnu/usr.bin/groff/libgroff/iftoa.cc deleted file mode 100644 index 07e739a2be41..000000000000 --- a/gnu/usr.bin/groff/libgroff/iftoa.cc +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - */ - -#ifndef lint -static char sccsid[] = "@(#)iftoa.cc 6.3 (Berkeley) 5/8/91"; -#endif /* not lint */ - -/* Copyright (C) 1989, 1990 Free Software Foundation, Inc. - Written by James Clark (jjc@jclark.uucp) - -This file is part of groff. - -groff 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. - -groff 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 groff; see the file LICENSE. If not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "lib.h" - -const char *iftoa(int i, int decimal_point) -{ - /* room for a -, 10 digits, a decimal point, and a terminating '\0' */ - static char buf[INT_DIGITS + 3]; - char *p = buf + INT_DIGITS + 2; - int point = 0; - buf[INT_DIGITS + 2] = '\0'; - /* assert(decimal_point <= INT_DIGITS); */ - if (i >= 0) { - do { - *--p = '0' + (i % 10); - i /= 10; - if (++point == decimal_point) - *--p = '.'; - } while (i != 0 || point < decimal_point); - } - else { /* i < 0 */ - do { - *--p = '0' - (i % 10); - i /= 10; - if (++point == decimal_point) - *--p = '.'; - } while (i != 0 || point < decimal_point); - *--p = '-'; - } - if (decimal_point > 0) { - char *q; - /* there must be a dot, so this will terminate */ - for (q = buf + INT_DIGITS + 2; q[-1] == '0'; --q) - ; - if (q[-1] == '.') { - if (q - 1 == p) { - q[-1] = '0'; - q[0] = '\0'; - } - else - q[-1] = '\0'; - } - else - *q = '\0'; - } - return p; -} diff --git a/gnu/usr.bin/groff/libgroff/itoa.cc b/gnu/usr.bin/groff/libgroff/itoa.cc deleted file mode 100644 index e155625f0364..000000000000 --- a/gnu/usr.bin/groff/libgroff/itoa.cc +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - */ - -#ifndef lint -static char sccsid[] = "@(#)itoa.cc 6.3 (Berkeley) 5/8/91"; -#endif /* not lint */ - -/* Copyright (C) 1989, 1990 Free Software Foundation, Inc. - Written by James Clark (jjc@jclark.uucp) - -This file is part of groff. - -groff 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. - -groff 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 groff; see the file LICENSE. If not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "lib.h" - -const char *itoa(int i) -{ - /* Room for 10 digits, - and '\0' */ - static char buf[INT_DIGITS + 2]; - char *p = buf + INT_DIGITS + 1; /* points to terminating '\0' */ - if (i >= 0) { - do { - *--p = '0' + (i % 10); - i /= 10; - } while (i != 0); - return p; - } - else { /* i < 0 */ - do { - *--p = '0' - (i % 10); - i /= 10; - } while (i != 0); - *--p = '-'; - } - return p; -} diff --git a/gnu/usr.bin/groff/libgroff/lib.h b/gnu/usr.bin/groff/libgroff/lib.h deleted file mode 100644 index ff6eba6439cc..000000000000 --- a/gnu/usr.bin/groff/libgroff/lib.h +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * This code is derived from software copyrighted by the Free Software - * Foundation. - * - * Modified 1991 by Donn Seeley at UUNET Technologies, Inc. - * - * @(#)lib.h 6.4 (Berkeley) 5/8/91 - */ - -/* Copyright (C) 1989, 1990 Free Software Foundation, Inc. - Written by James Clark (jjc@jclark.uucp) - -This file is part of groff. - -groff 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. - -groff 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 groff; see the file LICENSE. If not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This file is included in both C and C++ compilations. */ - -#ifdef __cplusplus -extern "C" { - // const char *strerror(int); - // const char *itoa(int); - // const char *iftoa(int, int); -}; - -const char *itoa(int); -const char *iftoa(int, int); - -char *strsave(const char *s); - -int interpret_lf_args(const char *p); - -inline int illegal_input_char(int c) -{ - return c == 000 || (c > 012 && c < 040) || (c >= 0200 && c < 0240); -} - -#endif - -#ifndef INT_MAX -#define INT_MAX 2147483647 -#endif - -/* It's not safe to rely on people getting INT_MIN right (ie signed). */ - -#ifdef INT_MIN -#undef INT_MIN -#endif - -#ifdef CFRONT_ANSI_BUG - -/* This works around a bug in cfront 2.0 used with ANSI C compilers. */ - -#define INT_MIN ((long)(-INT_MAX-1)) - -#else /* CFRONT_ANSI_BUG */ - -#define INT_MIN (-INT_MAX-1) - -#endif /* CFRONT_ANSI_BUG */ - -/* Maximum number of digits in the decimal representation of an int -(not including the -). */ - -#define INT_DIGITS 10 - -/* From the old GNU math.h; does some standard actually require these? */ -#define M_E 2.7182818284590452354 -#define M_LOG2E 1.4426950408889634074 -#define M_LOG10E 0.43429448190325182765 -#define M_LN2 0.69314718055994530942 -#define M_LN10 2.30258509299404568402 -#define M_PI 3.14159265358979323846 -#define M_PI_2 1.57079632679489661923 -#define M_1_PI 0.31830988618379067154 -#define M_PI_4 0.78539816339744830962 -#define M_2_PI 0.63661977236758134308 -#define M_2_SQRTPI 1.12837916709551257390 -#define M_SQRT2 1.41421356237309504880 -#define M_SQRT1_2 0.70710678118654752440 -#define PI M_PI -#define PI2 M_PI_2 diff --git a/gnu/usr.bin/groff/libgroff/ptable.h b/gnu/usr.bin/groff/libgroff/ptable.h deleted file mode 100644 index 0f1d25b9ba44..000000000000 --- a/gnu/usr.bin/groff/libgroff/ptable.h +++ /dev/null @@ -1,159 +0,0 @@ -// -*- C++ -*- -/* Copyright (C) 1989, 1990 Free Software Foundation, Inc. - Written by James Clark (jjc@jclark.uucp) - -This file is part of groff. - -groff 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. - -groff 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 groff; see the file LICENSE. If not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include - -#define PTABLE(T) name2(T,_ptable) -#define PASSOC(T) name2(T,_passoc) -#define PTABLE_ITERATOR(T) name2(T,_ptable_iterator) - -extern int next_ptable_size(int); -extern unsigned hash_string(const char *); - -#define declare_ptable(T) \ - \ -struct PASSOC(T) { \ - char *key; \ - T *val; \ - PASSOC(T)(); \ -}; \ - \ -struct PTABLE(T); \ - \ -class PTABLE_ITERATOR(T) { \ - PTABLE(T) *p; \ - int i; \ -public: \ - PTABLE_ITERATOR(T)(PTABLE(T) *); \ - int next(const char **, T **); \ -}; \ - \ -class PTABLE(T) { \ - PASSOC(T) *v; \ - int size; \ - int used; \ - enum { FULL_NUM = 2, FULL_DEN = 3, INITIAL_SIZE = 17 }; \ -public: \ - PTABLE(T)(); \ - ~PTABLE(T)(); \ - void define(const char *, T *); \ - T *lookup(const char *); \ - friend class PTABLE_ITERATOR(T); \ -}; - - -#define implement_ptable(T) \ - \ -PASSOC(T)::PASSOC(T)() \ -: key(0), val(0) \ -{ \ -} \ - \ -PTABLE(T)::PTABLE(T)() \ -{ \ - v = new PASSOC(T)[size = INITIAL_SIZE]; \ - used = 0; \ -} \ - \ -PTABLE(T)::~PTABLE(T)() \ -{ \ - for (int i = 0; i < size; i++) { \ - delete v[i].key; \ - delete v[i].val; \ - } \ -} \ - \ -void PTABLE(T)::define(const char *key, T *val) \ -{ \ - assert(key != 0); \ - int h = hash_string(key); \ - for (int n = h % size; \ - v[n].key != 0; \ - n = (n == 0 ? size - 1 : n - 1)) \ - if (strcmp(v[n].key, key) == 0) { \ - delete v[n].val; \ - v[n].val = val; \ - return; \ - } \ - if (val == 0) \ - return; \ - if (used*FULL_DEN >= size*FULL_NUM) { \ - PASSOC(T) *oldv = v; \ - int old_size = size; \ - size = next_ptable_size(size); \ - v = new PASSOC(T)[size]; \ - for (int i = 0; i < old_size; i++) \ - if (oldv[i].key != 0) { \ - if (oldv[i].val == 0) \ - delete oldv[i].key; \ - else { \ - for (int j = hash_string(oldv[i].key) % size; \ - v[j].key != 0; \ - j = (j == 0 ? size - 1 : j - 1)) \ - ; \ - v[j].key = oldv[i].key; \ - v[j].val = oldv[i].val; \ - } \ - } \ - for (n = h % size; \ - v[n].key != 0; \ - n = (n == 0 ? size - 1 : n - 1)) \ - ; \ - delete oldv; \ - } \ - char *temp = new char[strlen(key)+1]; \ - strcpy(temp, key); \ - v[n].key = temp; \ - v[n].val = val; \ - used++; \ -} \ - \ -T *PTABLE(T)::lookup(const char *key) \ -{ \ - assert(key != 0); \ - for (int n = hash_string(key) % size; \ - v[n].key != 0; \ - n = (n == 0 ? size - 1 : n - 1)) \ - if (strcmp(v[n].key, key) == 0) \ - return v[n].val; \ - return 0; \ -} \ - \ -PTABLE_ITERATOR(T)::PTABLE_ITERATOR(T)(PTABLE(T) *t) \ -: p(t), i(0) \ -{ \ -} \ - \ -int PTABLE_ITERATOR(T)::next(const char **keyp, T **valp) \ -{ \ - int size = p->size; \ - PASSOC(T) *v = p->v; \ - for (; i < size; i++) \ - if (v[i].key != 0) { \ - *keyp = v[i].key; \ - *valp = v[i].val; \ - i++; \ - return 1; \ - } \ - return 0; \ -} - diff --git a/gnu/usr.bin/groff/libgroff/stringclass.h b/gnu/usr.bin/groff/libgroff/stringclass.h deleted file mode 100644 index db8753c22437..000000000000 --- a/gnu/usr.bin/groff/libgroff/stringclass.h +++ /dev/null @@ -1,174 +0,0 @@ -// -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - Written by James Clark (jjc@jclark.uucp) - -This file is part of groff. - -groff 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. - -groff 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 groff; see the file LICENSE. If not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include - -class string { -public: - string(); - string(const string &); - string(const char *); - string(const char *, int); - string(char); - - ~string(); - - string &operator=(const string &); - string &operator=(const char *); - string &operator=(char); - - string &operator+=(const string &); - string &operator+=(const char *); - string &operator+=(char); - void append(const char *, int); - - int length() const; - int empty() const; - int operator*() const; - - string substring(int i, int n) const; - - char &operator[](int); - char operator[](int) const; - - void set_length(int i); - const char *contents() const; - int search(char) const; - char *extract() const; - void clear(); - void move(string &); - - friend string operator+(const string &, const string &); - friend string operator+(const string &, const char *); - friend string operator+(const char *, const string &); - friend string operator+(const string &, char); - friend string operator+(char, const string &); - - friend int operator==(const string &, const string &); - friend int operator!=(const string &, const string &); - friend int operator<=(const string &, const string &); - friend int operator<(const string &, const string &); - friend int operator>=(const string &, const string &); - friend int operator>(const string &, const string &); - -private: - char *ptr; - int len; - int sz; - - string(const char *, int, const char *, int); // for use by operator+ - void grow1(); -}; - - -inline char &string::operator[](int i) -{ - assert(i >= 0 && i < len); - return ptr[i]; -} - -inline char string::operator[](int i) const -{ - assert(i >= 0 && i < len); - return ptr[i]; -} - -inline int string::length() const -{ - return len; -} - -inline int string::empty() const -{ - return len == 0; -} - -inline int string::operator*() const -{ - return len; -} - -inline const char *string::contents() const -{ - return ptr; -} - -inline string operator+(const string &s1, const string &s2) -{ - return string(s1.ptr, s1.len, s2.ptr, s2.len); -} - -inline string operator+(const string &s1, const char *s2) -{ - if (s2 == 0) - return s1; - else - return string(s1.ptr, s1.len, s2, strlen(s2)); -} - -inline string operator+(const char *s1, const string &s2) -{ - if (s1 == 0) - return s2; - else - return string(s1, strlen(s1), s2.ptr, s2.len); -} - -inline string operator+(const string &s, char c) -{ - return string(s.ptr, s.len, &c, 1); -} - -inline string operator+(char c, const string &s) -{ - return string(&c, 1, s.ptr, s.len); -} - -inline int operator==(const string &s1, const string &s2) -{ - return (s1.len == s2.len - && (s1.len == 0 || memcmp(s1.ptr, s2.ptr, s1.len) == 0)); -} - -inline int operator!=(const string &s1, const string &s2) -{ - return (s1.len != s2.len - || (s1.len != 0 && memcmp(s1.ptr, s2.ptr, s1.len) != 0)); -} - -inline string string::substring(int i, int n) const -{ - assert(i >= 0 && i + n <= len); - return string(ptr + i, n); -} - -inline string &string::operator+=(char c) -{ - if (len >= sz) - grow1(); - ptr[len++] = c; - return *this; -} - -void put_string(const string &, FILE *); - -string as_string(int); diff --git a/gnu/usr.bin/groff/libgroff/version.cc b/gnu/usr.bin/groff/libgroff/version.cc deleted file mode 100644 index 763c6befc5f2..000000000000 --- a/gnu/usr.bin/groff/libgroff/version.cc +++ /dev/null @@ -1,3 +0,0 @@ -const char *version_string = "1.01"; -const char *major_version = "1"; -const char *minor_version = "1"; diff --git a/gnu/usr.bin/groff/macros/tmac.pic b/gnu/usr.bin/groff/macros/tmac.pic deleted file mode 100644 index 1177fc09d179..000000000000 --- a/gnu/usr.bin/groff/macros/tmac.pic +++ /dev/null @@ -1,10 +0,0 @@ -.de PS -.br -.sp .3v -.ne 0\\$1+1v+\n(.Vu -.in \\n(.lu-\\n(.iu-0\\$2/2u>?0 -.. -.de PE -.in -.sp .3v+.5m -.. diff --git a/gnu/usr.bin/groff/macros/tmac.ps b/gnu/usr.bin/groff/macros/tmac.ps deleted file mode 100644 index 07196d961cae..000000000000 --- a/gnu/usr.bin/groff/macros/tmac.ps +++ /dev/null @@ -1,115 +0,0 @@ -.nr _C \n(.C -.cp 0 -.ftr AX ABI -.ftr KR BMR -.ftr KI BMI -.ftr KB BMB -.ftr KX BMBI -.ftr CW CR -.ftr CO CI -.ftr CX CBI -.ftr H HR -.ftr HO HI -.ftr HX HBI -.ftr Hr HNR -.ftr Hi HNI -.ftr Hb HNB -.ftr Hx HNBI -.ftr NX NBI -.ftr PA PR -.ftr PX PBI -.ftr ZI ZCMI -.ftr C CR -.char \(rn \h'-\w'\(sr'u'\(rn\h'\w'\(sr'u' -.char \[parenlefttp] \[parenlefttp]\h'.016m' -.char \[parenleftbt] \[parenleftbt]\h'.016m' -.char \[parenleftex] \[parenleftex]\h'.016m' -.char \[parenrighttp] \[parenrighttp]\h'.016m' -.char \[parenrightbt] \[parenrightbt]\h'.016m' -.char \[parenrightex] \[parenrightex]\h'.016m' -.char \[ci] \v'-.25m'\h'.05m'\D'c .5m'\h'.05m'\v'.25m' -.char \[sq] \h'.05m'\D'l .5m 0'\D'l 0 -.5m'\D'l -.5m 0'\D'l 0 .5m'\h'.55m' -.char \[ru] \D'l .5m 0' -.char \[ul] \v'.25m'\D'l .5m 0'\v'-.25m' -.char \[br] \Z'\v'.25m'\D'l 0 -1m'' -.char \[or] \h'.1m'\Z'\D'l 0 -.675m''\h'.1m' -.char \[12] \v'-.7m\s[\\n(.s*6u/10u]+.7m'1\v'-.7m\s0+.7m'\ -\(f/\s[\\n(.s*6u/10u]2\s0 -.char \[14] \v'-.7m\s[\\n(.s*6u/10u]+.7m'1\v'-.7m\s0+.7m'\ -\(f/\s[\\n(.s*6u/10u]4\s0 -.char \[34] \v'-.7m\s[\\n(.s*6u/10u]+.7m'3\v'-.7m\s0+.7m'\ -\(f/\s[\\n(.s*6u/10u]4\s0 -.char \[S1] \v'-.2m'\s-31\s+3\v'+.2m' -.char \[S2] \v'-.2m'\s-32\s+3\v'+.2m' -.char \[S3] \v'-.2m'\s-33\s+3\v'+.2m' -.tr \[char178]\[S2] -.tr \[char179]\[S3] -.tr \[char185]\[S1] -.tr \[char188]\[14] -.tr \[char189]\[12] -.tr \[char190]\[34] -.char \[Fi] ffi -.char \[Fl] ffl -.char \[ff] ff -.char \[ij] ij -.char \[IJ] IJ -.if !c\[tm] .char \[tm] \s-3\v'-.3m'TM\v'+.3m'\s+3 -.cp \n(_C -.\" ignore the rest of the file in compatibility mode -.if \n(.C .nx /dev/null -.de ps-achar -.char \\$1 \\$3\ -\k[acc]\ -\h'(u;-\w'\\$2'-\w'\\$3'/2+\\\\n[skw]+(\w'x'*0)-\\\\n[skw])'\ -\v'(u;\w'x'*0+\\\\n[rst]+(\w'\\$3'*0)-\\\\n[rst])'\ -\\$2\ -\v'(u;\w'x'*0-\\\\n[rst]+(\w'\\$3'*0)+\\\\n[rst])'\ -\h'|\\\\n[acc]u' -.ie '\\$3'\(.i' .hcode \\$1i -.el .hcode \\$1\\$3 -.. -.if !c\['y] \{\ -.ps-achar \['y] \[aa] y -.tr \[char253]\['y] -.\} -.if !c\['Y] \{\ -.ps-achar \['Y] \[aa] Y -.tr \[char221]\['Y] -.\} -.if !c\['c] .ps-achar \['c] \[aa] c -.if !c\['C] .ps-achar \['C] \[aa] C -.de ps-bb -.nr ps-nargs \\n[.$] -.if \\n[ps-nargs]=4 \{\ -. nr ps-llx 0\\$1 -. nr ps-lly 0\\$2 -. nr ps-urx 0\\$3 -. nr ps-ury 0\\$4 -.\} -.. -.de PSPIC -.sy echo .ps-bb `psbb \\$1` >/tmp/psbb\\n[$$] -.so /tmp/psbb\\n[$$] -.if \\n[ps-nargs]=4 \{\ -. nr ps-wid (\\n[ps-urx]-\\n[ps-llx]) -. nr ps-ht (\\n[ps-ury]-\\n[ps-lly]) -. if \\n[ps-wid]<0 .nr ps-wid 0-\\n[ps-wid] -. if \\n[ps-ht]<0 .nr ps-ht 0-\\n[ps-ht] -. ie \\n[.$]>=2 .nr ps-deswid (i;\\$2) -. el .nr ps-deswid \\n[.l]-\\n[.i]=3 .nr ps-desht (i;\\$3) -. el .nr ps-desht \\n[ps-deswid]*1000+(\\n[ps-wid]/2)/\\n[ps-wid]\ -*\\n[ps-ht]+500/1000 -. ne \\n[ps-desht]u+1v -. sp \\n[ps-desht]u -. nr ps-offset \\n[.l]-\\n[.i]-\\n[ps-deswid]/2 -. ie \\n[.$]>=3 \ -\h'\\n[ps-offset]u'\X'ps: import \\$1 \\n[ps-llx] \\n[ps-lly] \\n[ps-urx] \ -\\n[ps-ury] \\n[ps-deswid] \\n[ps-desht]' -. el \ -\h'\\n[ps-offset]u'\X'ps: import \\$1 \\n[ps-llx] \\n[ps-lly] \\n[ps-urx] \ -\\n[ps-ury] \\n[ps-deswid]' -. br -.\} -.sy rm /tmp/psbb\\n[$$] -.. diff --git a/gnu/usr.bin/groff/macros/tmac.psfig b/gnu/usr.bin/groff/macros/tmac.psfig deleted file mode 100644 index 6db9a71140ca..000000000000 --- a/gnu/usr.bin/groff/macros/tmac.psfig +++ /dev/null @@ -1,86 +0,0 @@ -.\" These are macros to make psfig work with groff. See the file psfig.diff. -.de psfig-defs -ps: mdef 100 - -% wid ht llx lly urx ury psfigstart - - -/psfigstart { - /level1 save def - /ury exch def - /urx exch def - /lly exch def - /llx exch def - /ht exch u def - /wid exch u def - currentpoint ht add translate - wid urx llx sub div ht ury lly sub div neg scale - llx neg lly neg translate - - % set the graphics state to default values - 0 setgray - 0 setlinecap - 1 setlinewidth - 0 setlinejoin - 10 setmiterlimit - [] 0 setdash - newpath - /showpage {} def -} bind def - -% psfigclip - - -/psfigclip { - currentpoint newpath - llx lly moveto - urx lly lineto - urx ury lineto - llx ury lineto - closepath clip - newpath moveto -} bind def - -% psfigend - - -/psfigend { - level1 restore -} bind def - -% globalstart - - -/globalstart { - % save the current space code on the stack - SC - level0 restore -} bind def - -% globalend - - -/globalend { - end - BP - /SC exch def - DEFS begin -} bind def -.. -.de psfig-init -.if \\n[.P] \{\ -\Y[psfig-defs] -. br -. sp -1 -. ds psfig-init\" empty -. rm psfig-defs -.\} -.. -.de F+ -.br -.psfig-init -.nr psfig-fill \\n[.u] -.nf -.sp -.5 -.if !\\n[.$] .ce 9999 -.. -.de F- -.br -.ce 0 -.if \\n[psfig-fill] .fi -.. diff --git a/gnu/usr.bin/groff/macros/tmac.s b/gnu/usr.bin/groff/macros/tmac.s deleted file mode 100644 index 75f6bca79fa1..000000000000 --- a/gnu/usr.bin/groff/macros/tmac.s +++ /dev/null @@ -1,1808 +0,0 @@ -.ig -Copyright (C) 1990, 1991 Free Software Foundation, Inc. - Written by James Clark (jjc@jclark.uucp) - -This file is part of groff. - -groff 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. - -groff 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 groff; see the file LICENSE. If not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -.. -.if !\n(.g .ab These ms macros require groff. -.if \n(.C \ -. ab The groff ms macros do not work in compatibility mode. -.\" Enable warnings. You can delete this if you want. -.warn -.\" See if already loaded. -.if r GS .nx /dev/null -.nr GS 1 -.de @error -.tm \\n(.F:\\n(.c: macro error: \\$* -.. -.de @warning -.tm \\n(.F:\\n(.c: macro warning: \\$* -.. -.de @fatal -.ab \\n(.F:\\n(.c: fatal macro error: \\$* -.. -.de @not-implemented -.@error sorry, \\$0 not implemented -.als \\$0 @nop -.. -.als TM @not-implemented -.als CT @not-implemented -.de @nop -.. -.de @init -.\" a non-empty environment -.ev ne -\c -.ev -.ev nf -'nf -.ev -.. -.ds REFERENCES References -.ds ABSTRACT ABSTRACT -.ds TOC Table of Contents -.ds MONTH1 January -.ds MONTH2 February -.ds MONTH3 March -.ds MONTH4 April -.ds MONTH5 May -.ds MONTH6 June -.ds MONTH7 July -.ds MONTH8 August -.ds MONTH9 September -.ds MONTH10 October -.ds MONTH11 November -.ds MONTH12 December -.ds MO \\*[MONTH\n[mo]] -.nr *year \n[yr]+1900 -.ds DY \n[dy] \*[MO] \n[*year] -.de ND -.if \\n[.$] .ds DY "\\$* -.. -.de DA -.if \\n[.$] .ds DY "\\$* -.ds CF \\*[DY] -.. -.\" indexing -.de IX -.tm \\$1\t\\$2\t\\$3\t\\$4 ... \\n[PN] -.. -.\" print an error message and then try to recover -.de @error-recover -.@error \\$@ (recovering) -.nr *pop-count 0 -.while !'\\n(.z'' \{\ -. \"@warning automatically terminating diversion \\n(.z -. ie d @div-end!\\n(.z .@div-end!\\n(.z -. el .*div-end-default -. nr *pop-count +1 -. \" ensure that we don't loop forever -. if \\n[*pop-count]>20 .@fatal recovery failed -.\} -.while !'\\n[.ev]'0' .ev -.par@reset-env -.par@reset -.. -.de *div-end-default -.ds *last-div \\n(.z -.br -.di -.ev nf -.\\*[*last-div] -.ev -.. -.\" **************************** -.\" ******** module cov ******** -.\" **************************** -.\" Cover sheet and first page. -.de cov*err-not-after-first-page -.@error \\$0 is not allowed after the first page has started -.. -.de cov*err-not-before-tl -.@error \\$0 is not allowed before TL -.. -.de cov*err-not-again -.@error \\$0 is not allowed more than once -.. -.de cov*err-not-after-ab -.@error \\$0 is not allowed after first AB, LP, PP, IP, SH or NH -.. -.als AU cov*err-not-before-tl -.als AI cov*err-not-before-tl -.als AB cov*err-not-before-tl -.de cov*first-page-init -.rm cov*first-page-init -.par@init -.als RP cov*err-not-after-first-page -.@init -.ie \\n[cov*rp-format] \{\ -. pg@cs-top -. als FS cov*FS -. als FE cov*FE -.\} -.el \{\ -. pg@top -. als FS @FS -. als FE @FE -.\} -.wh 0 pg@top -.. -.wh 0 cov*first-page-init -.\" This handles the case where FS occurs before TL or LP. -.de FS -.br -\\*[FS]\\ -.. -.nr cov*rp-format 0 -.nr cov*rp-no 0 -.\" released paper format -.de RP -.nr cov*rp-format 1 -.if \\n[.$] .if '\\$1'no' .nr cov*rp-no 1 -.pn 0 -.. -.de TL -.br -.als TL cov*err-not-again -.rn @AB AB -.rn @AU AU -.rn @AI AI -.di cov*tl-div -.par@reset -.ft B -.ps +2 -.vs +3p -.ll (u;\\n[LL]*5/6) -.nr cov*n-au 0 -.. -.de @AU -.par@reset -.if !'\\n(.z'' \{\ -. br -. di -.\} -.nr cov*n-au +1 -.di cov*au-div!\\n[cov*n-au] -.nf -.ft I -.ps \\n[PS] -.. -.de @AI -.par@reset -.if !'\\n(.z'' \{\ -. br -. di -.\} -.ie !\\n[cov*n-au] .@error AI before AU -.el \{\ -. di cov*ai-div!\\n[cov*n-au] -. nf -. ft R -. ps \\n[PS] -.\} -.. -.de LP -.if !'\\n[.z]'' \{\ -. br -. di -.\} -.br -.cov*ab-init -.cov*print -\\*[\\$0]\\ -.. -.als IP LP -.als PP LP -.als XP LP -.als NH LP -.als SH LP -.als MC LP -.als RT LP -.de cov*ab-init -.als cov*ab-init @nop -.als LP @LP -.als IP @IP -.als PP @PP -.als XP @XP -.als RT @RT -.als SH @SH -.als NH @NH -.als QP @QP -.als RS @RS -.als RE @RE -.als QS @QS -.als QE @QE -.als MC @MC -.als EQ @EQ -.als EN @EN -.als AB cov*err-not-after-ab -.als AU par@AU -.als AI par@AI -.als TL par@TL -.. -.de @AB -.if !'\\n(.z'' \{\ -. br -. di -.\} -.cov*ab-init -.di cov*ab-div -.par@ab-indent -.par@reset -.if !'\\$1'no' \{\ -. ft I -. ce 1 -\\*[ABSTRACT] -. sp -. ft R -.\} -.ns -.@PP -.. -.de AE -.ie '\\n(.z'cov*ab-div' \{\ -. als AE cov*err-not-again -. br -. di -.\" nr cov*ab-height \\n[dn] -. par@reset-env -. par@reset -. cov*print -.\} -.el .@error AE without AB -.. -.de @div-end!cov*ab-div -.AE -.. -.de cov*print -.als cov*print @nop -.ie d cov*tl-div \{\ -. ie \\n[cov*rp-format] .cov*rp-print -. el .cov*draft-print -.\} -.el \{\ -. if \\n[cov*rp-format] \{\ -. @warning RP format but no TL -. bp 1 -. als FS @FS -. als FE @FE -. \} -. br -.\} -.. -.de cov*rp-print -.nr cov*page-length \\n[.p] -.pl 1000i -.cov*tl-au-print -.sp 3 -.if d cov*ab-div \{\ -. nf -. cov*ab-div -.\} -.sp 3 -.par@reset -\\*[DY] -.br -.if \\n[cov*fn-height] \{\ -. sp |(u;\\n[cov*page-length]-\\n[FM]\ --\\n[cov*fn-height]-\\n[fn@sep-dist]>?\\n[nl]) -. fn@print-sep -. ev nf -. cov*fn-div -. ev -. ie \\n[cov*rp-no] .rm cov*fn-div -. el \{\ -. rn cov*fn-div fn@overflow-div -. nr fn@have-overflow 1 -. \} -.\} -.als FS @FS -.als FE @FE -.\" If anything was printed below where the footer line is normally printed, -.\" then that's an overflow. -.if -\\n[FM]/2+1v+\\n[cov*page-length]<\\n[nl] .@error cover sheet overflow -.pl \\n[cov*page-length]u -.bp 1 -.if !\\n[cov*rp-no] .cov*tl-au-print -.rs -.sp 1 -.. -.de cov*draft-print -.cov*tl-au-print -.if d cov*ab-div \{\ -. nf -. sp 2 -. cov*ab-div -.\} -.sp 1 -.. -.de cov*tl-au-print -.par@reset -.nf -.rs -.sp 3 -.ce 9999 -.cov*tl-div -.nr cov*i 1 -.nr cov*sp 1v -.while \\n[cov*i]<=\\n[cov*n-au] \{\ -. sp \\n[cov*sp]u -. cov*au-div!\\n[cov*i] -. ie d cov*ai-div!\\n[cov*i] \{\ -. sp .5v -. cov*ai-div!\\n[cov*i] -. nr cov*sp 1v -. \} -. el .nr cov*sp .5v -. nr cov*i +1 -.\} -.ce 0 -.. -.nr cov*fn-height 0 -.nr cov*in-fn 0 -.\" start of footnote on cover -.de cov*FS -.if \\n[cov*in-fn] \{\ -. @error nested FS -. FE -.\} -.nr cov*in-fn 1 -.ev fn -.par@reset-env -.da cov*fn-div -.if !\\n[cov*fn-height] .ns -.ie \\n[.$] .FP "\\$1" no -.el .@LP -.. -.de @div-end!cov*fn-div -.cov*FE -.. -.\" end of footnote on cover -.de cov*FE -.ie '\\n(.z'cov*fn-div' \{\ -. br -. ev -. di -. nr cov*in-fn 0 -. nr cov*fn-height +\\n[dn] -.\} -.el .@error FE without matching FS -.. -.\" *************************** -.\" ******** module pg ******** -.\" *************************** -.\" Page-level formatting. -.\" > 0 if we have a footnote on the current page -.nr pg@fn-flag 0 -.nr pg@colw 0 -.nr pg@fn-colw 0 -.nr HM 1i -.nr FM 1i -.nr PO 1i -.ds LF -.ds CF -.ds RF -.ds LH -.ds CH -\\n[PN]- -.ds RH -.ds pg*OH '\\*[LH]'\\*[CH]'\\*[RH]' -.ds pg*EH '\\*[LH]'\\*[CH]'\\*[RH]' -.ds pg*OF '\\*[LF]'\\*[CF]'\\*[RF]' -.ds pg*EF '\\*[LF]'\\*[CF]'\\*[RF]' -.de OH -.ds pg*\\$0 "\\$* -.. -.als EH OH -.als OF OH -.als EF OH -.de PT -.ie \\n%=1 .if \\n[pg*P1] .tl \\*[pg*OH] -.el \{\ -. ie o .tl \\*[pg*OH] -. el .tl \\*[pg*EH] -.\} -.. -.de BT -.ie o .tl \\*[pg*OF] -.el .tl \\*[pg*EF] -.. -.nr pg*P1 0 -.de P1 -.nr pg*P1 1 -.. -.wh -\n[FM]u pg@bottom -.wh -\n[FM]u/2u pg*footer -.nr MINGW 2n -.nr pg@ncols 1 -.de @MC -.if !'\\n(.z'' .error-recover MC while diversion open -.br -.ie \\n[pg@ncols]>1 .pg@super-eject -.el \{\ -. \" flush out any floating keeps -. while \\n[kp@tail]>\\n[kp@head] \{\ -. rs -. bp -. \} -.\} -.ie !\\n(.$ \{\ -. nr pg@colw \\n[LL]*7/15 -. nr pg*gutw \\n[LL]-(2*\\n[pg@colw]) -. nr pg@ncols 2 -.\} -.el \{\ -. nr pg@colw (n;\\$1)1 \ -. nr pg*gutw \\n[LL]-(\\n[pg@ncols]*\\n[pg@colw])/(\\n[pg@ncols]-1) -. el .nr pg*gutw 0 -.\} -.mk pg*col-top -.ns -.nr pg*col-num 0 -.nr pg@fn-colw \\n[pg@colw]*5/6 -.par@reset -.. -.de 2C -.MC -.. -.de 1C -.MC \\n[LL]u -.. -.\" top of page macro -.de pg@top -.ch pg*footer -\\n[FM]u/2u -.nr PN \\n% -.nr pg*col-num 0 -.nr pg@fn-bottom-margin 0 -.nr pg*saved-po \\n[PO] -.po \\n[PO]u -.ev h -.par@reset -.sp (u;\\n[HM]/2) -.PT -.sp |\\n[HM]u -.if d HD .HD -.mk pg@header-bottom -.ev -.mk pg*col-top -.pg*start-col -.. -.de pg*start-col -.ns -.\" Handle footnote overflow before floating keeps, because the keep -.\" might contain an embedded footnote. -.fn@top-hook -.kp@top-hook -.tbl@top-hook -.. -.de pg@cs-top -.sp \\n[HM]u -.\" move pg@bottom and pg*footer out of the way -.ch pg@bottom \\n[.p]u*2u -.ch pg*footer \\n[.p]u*2u -.ns -.. -.de pg@bottom -.tbl@bottom-hook -.if \\n[pg@fn-flag] .fn@bottom-hook -.nr pg*col-num +1 -.ie \\n[pg*col-num]<\\n[pg@ncols] .pg*end-col -.el .pg*end-page -.. -.de pg*end-col -'sp |\\n[pg*col-top]u -.po (u;\\n[pg*saved-po]+(\\n[pg@colw]+\\n[pg*gutw]*\\n[pg*col-num])) -.\"po +(u;\\n[pg@colw]+\\n[pg*gutw]) -.pg*start-col -.. -.de pg*end-page -.po \\n[pg*saved-po]u -.\" Make sure we don't exit if there are still floats or footnotes left-over. -.ie \\n[kp@head]<\\n[kp@tail]:\\n[fn@have-overflow] \{\ -. \" Switching environments ensures that we don't get an unnecessary -. \" blank line at the top of the page. -. ev ne -' bp -. ev -.\} -.el \{\ -. if r pg*next-number \{\ -. pn \\n[pg*next-number] -. rr pg*next-number -. if d pg*next-format \{\ -. af PN \\*[pg*next-format] -. rm pg*next-format -. \} -. \} -' bp -.\} -.. -.\" pg@begin number format -.de pg@begin -.ie \\n[.$]>0 \{\ -. nr pg*next-number (;\\$1) -. ie \\n[.$]>1 .ds pg*next-format \\$2 -. el .rm pg*next-format -.\} -.el .rr pg*next-number -.pg@super-eject -.. -.\" print the footer line -.de pg*footer -.ev h -.par@reset -.BT -.ev -.. -.\" flush out any keeps or footnotes -.de pg@super-eject -.br -.if !'\\n(.z'' .@error-recover diversion open while ejecting page -.\" Make sure we stay in the end macro while there is still footnote overflow -.\" left, or floating keeps. -.while \\n[kp@tail]>\\n[kp@head]:\\n[pg@fn-flag] \{\ -. rs -. bp -.\} -.bp -.. -.em pg@super-eject -.\" *************************** -.\" ******** module fn ******** -.\" *************************** -.\" Footnotes. -.nr fn@sep-dist 8p -.ev fn -.\" Round it vertically -.vs \n[fn@sep-dist]u -.nr fn@sep-dist \n[.v] -.ev -.nr fn*text-num 0 1 -.nr fn*note-num 0 1 -.ds * \\*[par@sup-start]\En+[fn*text-num]\\*[par@sup-end] -.nr fn*open 0 -.\" normal FS -.de @FS -.ie \\n[.$] .fn*do-FS "\\$1" no -.el \{\ -. ie \\n[fn*text-num]>\\n[fn*note-num] .fn*do-FS \\n+[fn*note-num] -. el .fn*do-FS -.\} -.. -.\" Second argument of `no' means don't embellish the first argument. -.de fn*do-FS -.if \\n[fn*open] .@error-recover nested FS -.nr fn*open 1 -.if \\n[.u] \{\ -. \" Ensure that the first line of the footnote is on the same page -. \" as the reference. I think this is minimal. -. ev fn -. nr fn*need 1v -. ev -. ie \\n[pg@fn-flag] .nr fn*need +\\n[fn:PD] -. el .nr fn*need +\\n[fn@sep-dist] -. ne \\n[fn*need]u+\\n[.V]u>?0 -.\} -.ev fn -.par@reset-env -.fn*start-div -.par@reset -.ie \\n[.$] .FP \\$@ -.el .@LP -.. -.de @FE -.ie !\\n[fn*open] .@error FE without FS -.el \{\ -. nr fn*open 0 -. br -. ev -. fn*end-div -.\} -.. -.nr fn@have-overflow 0 -.\" called at the top of each column -.de fn@top-hook -.nr fn*max-width 0 -.nr fn*page-bottom-pos 0-\\n[FM]-\\n[pg@fn-bottom-margin] -.ch pg@bottom \\n[fn*page-bottom-pos]u -.if \\n[fn@have-overflow] \{\ -. nr fn@have-overflow 0 -. fn*start-div -. ev nf -. fn@overflow-div -. ev -. fn*end-div -.\} -.. -.\" This is called at the bottom of the column if pg@fn-flag is set. -.de fn@bottom-hook -.nr pg@fn-flag 0 -.nr fn@have-overflow 0 -.nr fn@bottom-pos \\n[.p]-\\n[FM]-\\n[pg@fn-bottom-margin]+\\n[.v] -.ev fn -.nr fn@bottom-pos -\\n[.v] -.ev -.ie \\n[nl]+\\n[fn@sep-dist]+\n[.V]>\\n[fn@bottom-pos] \{\ -. rn fn@div fn@overflow-div -. nr fn@have-overflow 1 -.\} -.el \{\ -. if \\n[pg@ncols]>1 \ -. if \\n[fn*max-width]>\\n[pg@fn-colw] \ -. nr pg@fn-bottom-margin \\n[.p]-\\n[FM]-\\n[nl]+1v -. wh \\n[fn@bottom-pos]u fn*catch-overflow -. fn@print-sep -. ev nf -. fn@div -. rm fn@div -. ev -. if '\\n(.z'fn@overflow-div' \{\ -. di -. nr fn@have-overflow \\n[dn]>0 -. \} -. ch fn*catch-overflow -.\} -.. -.de fn*catch-overflow -.di fn@overflow-div -.. -.nr fn*embed-count 0 -.de @div-end!fn@div -.br -.if '\\n[.ev]'fn' .ev -.fn*end-div -.nr fn*open 0 -.. -.als @div-end!fn*embed-div @div-end!fn@div -.de fn*start-div -.ie '\\n(.z'' \{\ -. da fn@div -. if !\\n[pg@fn-flag] .ns -.\} -.el .di fn*embed-div -.. -.de fn*end-div -.ie '\\n(.z'fn@div' \{\ -. di -. nr fn*page-bottom-pos -\\n[dn] -. nr fn*max-width \\n[fn*max-width]>?\\n[dl] -. if !\\n[pg@fn-flag] .nr fn*page-bottom-pos -\\n[fn@sep-dist] -. nr pg@fn-flag 1 -. nr fn*page-bottom-pos \\n[nl]-\\n[.p]+\n[.V]>?\\n[fn*page-bottom-pos] -. ch pg@bottom \\n[fn*page-bottom-pos]u -.\} -.el \{\ -. ie '\\n(.z'fn*embed-div' \{\ -. di -. rn fn*embed-div fn*embed-div!\\n[fn*embed-count] -\!. fn*embed-start \\n[fn*embed-count] -. rs -' sp (u;\\n[dn]+\\n[fn@sep-dist]+\\n[.V]) -\!. fn*embed-end -. nr fn*embed-count +1 -. \} -. el \{\ -. ev fn -. @error-recover unclosed diversion within footnote -. \} -.\} -.. -.de fn*embed-start -.ie '\\n(.z'' \{\ -. fn*start-div -. ev nf -. fn*embed-div!\\$1 -. rm fn*embed-div!\\$1 -. ev -. fn*end-div -. di fn*null -.\} -.el \{\ -\!. fn*embed-start \\$1 -. rs -.\} -.. -.de fn*embed-end -.ie '\\n(.z'fn*null' \{\ -. di -. rm fn*null -.\} -.el \!.fn*embed-end -.. -.\" It's important that fn@print-sep use up exactly fn@sep-dist vertical space. -.de fn@print-sep -.ev fn -.in 0 -.vs \\n[fn@sep-dist]u -\D'l 1i 0' -.br -.ev -.. -.\" *************************** -.\" ******** module kp ******** -.\" *************************** -.\" Keeps. -.de KS -.br -.di kp*div -.. -.de KF -.if !'\\n(.z'' .@error-recover KF while open diversion -.di kp*fdiv -.ev k -.par@reset-env -.par@reset -.. -.de KE -.ie '\\n(.z'kp*div' .kp*end -.el \{\ -. ie '\\n(.z'kp*fdiv' .kp*fend -. el .@error KE without KS or KF -.\} -.. -.de @div-end!kp*div -.kp*end -.. -.de @div-end!kp*fdiv -.kp*fend -.. -.de kp*need -.ie '\\n(.z'' .ds@need \\$1 -.el \!.kp*need \\$1 -.. -.\" end non-floating keep -.de kp*end -.br -.di -.kp*need \\n[dn] -.ev nf -.kp*div -.ev -.rm kp*div -.. -.\" Floating keeps. -.nr kp@head 0 -.nr kp@tail 0 -.\" end floating keep -.de kp*fend -.br -.ev -.di -.ie \\n[.t]-(\\n[.k]>0*1v)>\\n[dn] \{\ -. br -. ev nf -. kp*fdiv -. rm kp*fdiv -. ev -.\} -.el \{\ -. rn kp*fdiv kp*div!\\n[kp@tail] -. nr kp*ht!\\n[kp@tail] 0\\n[dn] -. nr kp@tail +1 -.\} -.. -.\" top of page processing for KF -.nr kp*doing-top 0 -.de kp@top-hook -.if !\\n[kp*doing-top] \{\ -. nr kp*doing-top 1 -. kp*do-top -. nr kp*doing-top 0 -.\} -.. -.de kp*do-top -.\" If the first keep won't fit, only force it out if we haven't had a footnote -.\" and we're at the top of the page. -.nr kp*force \\n[pg@fn-flag]=0&(\\n[nl]<=\\n[pg@header-bottom]) -.nr kp*fits 1 -.while \\n[kp@tail]>\\n[kp@head]&\\n[kp*fits] \{\ -. ie \\n[.t]>\\n[kp*ht!\\n[kp@head]]:\\n[kp*force] \{\ -. nr kp*force 0 -. \" It's important to advance kp@head before bringing -. \" back the keep, so that if the last line of the -. \" last keep springs the bottom of page trap, a new -. \" page will not be started unnecessarily. -. rn kp*div!\\n[kp@head] kp*temp -. nr kp@head +1 -. ev nf -. kp*temp -. ev -. rm kp*temp -. \} -. el .nr kp*fits 0 -.\} -.. -.\" *************************** -.\" ******** module ds ******** -.\" *************************** -.\" Displays and non-floating keeps. -.de DE -.ds*end!\\n[\\n[.ev]:ds-type] -.nr \\n[.ev]:ds-type 0 -.. -.de ds@auto-end -.if \\n[\\n[.ev]:ds-type] \{\ -. @error automatically terminating display -. DE -.\} -.. -.de @div-end!ds*div -.ie \\n[\\n[.ev]:ds-type] .DE -.el .ds*end!2 -.. -.de ds*end!0 -.@error DE without DS, ID, CD, LD or BD -.. -.de LD -.br -.nr \\n[.ev]:ds-type 1 -.par@reset -.nf -.sp \\n[DD]u -.. -.de ID -.LD -.ie \\n[.$] .in +(n;\\$1) -.el .in +\\n[DI]u -.. -.de CD -.LD -.ce 9999 -.. -.de RD -.LD -.rj 9999 -.. -.de ds*common-end -.par@reset -.sp \\n[DD]u -.. -.als ds*end!1 ds*common-end -.de BD -.LD -.nr \\n[.ev]:ds-type 2 -.di ds*div -.. -.de ds*end!2 -.br -.ie '\\n(.z'ds*div' \{\ -. di -. nf -. in (u;\\n[.l]-\\n[dl]/2) -. ds*div -. rm ds*div -. ds*common-end -.\} -.el .@error-recover mismatched DE -.. -.de DS -.br -.di ds*div -.ie '\\$1'B' \{\ -. LD -. nr \\n[.ev]:ds-type 4 -.\} -.el \{\ -. ie '\\$1'L' .LD -. el \{\ -. ie '\\$1'C' .CD -. el \{\ -. ie '\\$1'R' .RD -. el \{\ -. ie '\\$1'I' .ID \\$2 -. el .ID \\$1 -. \} -. \} -. \} -. nr \\n[.ev]:ds-type 3 -.\} -.. -.de ds@need -.if '\\n(.z'' \{\ -. while \\n[.t]<=(\\$1)&(\\n[nl]>\\n[pg@header-bottom]) \{\ -. rs -' sp \\n[.t]u -. \} -.\} -.. -.de ds*end!3 -.br -.ie '\\n(.z'ds*div' \{\ -. di -. ds@need \\n[dn] -. ev nf -. ds*div -. ev -. rm ds*div -. ds*common-end -.\} -.el .@error-recover mismatched DE -.. -.de ds*end!4 -.ie '\\n(.z'ds*div' \{\ -. br -. di -. nf -. in (u;\\n[.l]-\\n[dl]/2) -. ds@need \\n[dn] -. ds*div -. rm ds*div -. ds*common-end -.\} -.el .@error-recover mismatched DE -.. -.\" **************************** -.\" ******** module par ******** -.\" **************************** -.\" Paragraph-level formatting. -.nr PS 10 -.nr LL 6i -.de par*vs -.\" If it's too big to be in points, treat it as units. -.ie (p;\\$1)>=40p .vs (u;\\$1) -.el .vs (p;\\$1) -.. -.de par@ab-indent -.nr 0:li (u;\\n[LL]/12) -.nr 0:ri \\n[0:li] -.. -.de par*env-init -.aln \\n[.ev]:PS PS -.aln \\n[.ev]:VS VS -.aln \\n[.ev]:LL LL -.aln \\n[.ev]:MCLL LL -.aln \\n[.ev]:LT LT -.aln \\n[.ev]:MCLT LT -.aln \\n[.ev]:PI PI -.aln \\n[.ev]:PD PD -.par@reset-env -.. -.\" happens when the first page begins -.de par@init -.if !rLT .nr LT \\n[LL] -.if !rFL .nr FL \\n[LL]*5/6 -.if !rVS .nr VS \\n[PS]+2 -.ps \\n[PS] -.if !rDI .nr DI .5i -.if !rQI .nr QI 5n -.if !rPI .nr PI 5n -.par*vs \\n[VS] -.if !rPD .nr PD .3v -.if !rDD .nr DD .5v -.if !dFAM .ds FAM \\n[.fam] -.nr par*adj \\n[.j] -.par*env-init -.ev h -.par*env-init -.ev -.ev fn -.par*env-init -.ev -.ev k -.par*env-init -.ev -.aln 0:MCLL pg@colw -.aln 0:MCLT pg@colw -.aln k:MCLL pg@colw -.aln k:MCLT pg@colw -.if !rFPS .nr FPS \\n[PS]-2 -.if !rFVS .nr FVS (p;\\n[FPS]+2) -.if !rFI .nr FI 2n -.if !rFPD .nr FPD \\n[PD]/2 -.aln fn:PS FPS -.aln fn:VS FVS -.aln fn:LL FL -.aln fn:LT FL -.aln fn:PI FI -.aln fn:PD FPD -.aln fn:MCLL pg@fn-colw -.aln fn:MCLT pg@fn-colw -.. -.de par@reset-env -.nr \\n[.ev]:il 0 -.nr \\n[.ev]:li 0 -.nr \\n[.ev]:ri 0 -.nr \\n[.ev]:ai \\n[\\n[.ev]:PI] -.nr \\n[.ev]:pli 0 -.nr \\n[.ev]:pri 0 -.nr \\n[.ev]:ds-type 0 -.. -.\" par@reset -.de par@reset -.br -.ce 0 -.rj 0 -.ul 0 -.fi -.ad \\n[par*adj] -.ie \\n[pg@ncols]>1 \{\ -. ll (u;\\n[\\n[.ev]:MCLL]-\\n[\\n[.ev]:ri]-\\n[\\n[.ev]:pri]) -. lt \\n[\\n[.ev]:MCLT]u -.\} -.el \{\ -. ll (u;\\n[\\n[.ev]:LL]-\\n[\\n[.ev]:ri]-\\n[\\n[.ev]:pri]) -. lt \\n[\\n[.ev]:LT]u -.\} -.in (u;\\n[\\n[.ev]:li]+\\n[\\n[.ev]:pli]) -.ft 1 -.fam \\*[FAM] -.ps \\n[\\n[.ev]:PS] -.par*vs \\n[\\n[.ev]:VS] -.ls 1 -.TA -.hy 14 -.. -.als @RT par@reset -.\" This can be redefined by the user. -.de TA -.ta T 5n -.. -.de par*start -.ds@auto-end -.nr \\n[.ev]:pli \\$1 -.nr \\n[.ev]:pri \\$2 -.par@reset -.sp \\n[\\n[.ev]:PD]u -.ne 1v+\\n(.Vu -.. -.de par@finish -.nr \\n[.ev]:pli 0 -.nr \\n[.ev]:pri 0 -.par@reset -.. -.\" normal LP -.de @LP -.par*start 0 0 -.nr \\n[.ev]:ai \\n[\\n[.ev]:PI] -.. -.de @PP -.par*start 0 0 -.nr \\n[.ev]:ai \\n[\\n[.ev]:PI] -.ti +\\n[\\n[.ev]:ai]u -.. -.de @QP -.nr \\n[.ev]:ai \\n[\\n[.ev]:PI] -.par*start \\n[QI] \\n[QI] -.. -.de @XP -.par*start \\n[\\n[.ev]:PI] 0 -.ti -\\n[\\n[.ev]:PI]u -.. -.de @IP -.if \\n[.$]>1 .nr \\n[.ev]:ai (n;\\$2) -.par*start \\n[\\n[.ev]:ai] 0 -.if !'\\$1'' \{\ -. \" Divert the label so as to freeze any spaces. -. di par*label -. in 0 -. nf -\&\\$1 -. di -. in -. fi -. chop par*label -. ti -\\n[\\n[.ev]:ai]u -. ie \\n[dl]+1n<=\\n[\\n[.ev]:ai] \\*[par*label]\h'|\\n[\\n[.ev]:ai]u'\c -. el \{\ -\\*[par*label] -. br -. \} -. rm par*label -.\} -.. -.de @RS -.br -.nr \\n[.ev]:li!\\n[\\n[.ev]:il] \\n[\\n[.ev]:li] -.nr \\n[.ev]:ri!\\n[\\n[.ev]:il] \\n[\\n[.ev]:ri] -.nr \\n[.ev]:ai!\\n[\\n[.ev]:il] \\n[\\n[.ev]:ai] -.nr \\n[.ev]:pli!\\n[\\n[.ev]:il] \\n[\\n[.ev]:pli] -.nr \\n[.ev]:pri!\\n[\\n[.ev]:il] \\n[\\n[.ev]:pri] -.nr \\n[.ev]:il +1 -.nr \\n[.ev]:li +\\n[\\n[.ev]:ai] -.nr \\n[.ev]:ai \\n[\\n[.ev]:PI] -.par@reset -.. -.de @RE -.br -.ie \\n[\\n[.ev]:il] \{\ -. nr \\n[.ev]:il -1 -. nr \\n[.ev]:ai \\n[\\n[.ev]:ai!\\n[\\n[.ev]:il]] -. nr \\n[.ev]:li \\n[\\n[.ev]:li!\\n[\\n[.ev]:il]] -. nr \\n[.ev]:ri \\n[\\n[.ev]:ri!\\n[\\n[.ev]:il]] -. nr \\n[.ev]:pli \\n[\\n[.ev]:pli!\\n[\\n[.ev]:il]] -. nr \\n[.ev]:pri \\n[\\n[.ev]:pri!\\n[\\n[.ev]:il]] -.\} -.el .@error unbalanced \\$0 -.par@reset -.. -.de @QS -.br -.nr \\n[.ev]:li!\\n[\\n[.ev]:il] \\n[\\n[.ev]:li] -.nr \\n[.ev]:ri!\\n[\\n[.ev]:il] \\n[\\n[.ev]:ri] -.nr \\n[.ev]:ai!\\n[\\n[.ev]:il] \\n[\\n[.ev]:ai] -.nr \\n[.ev]:pli!\\n[\\n[.ev]:il] \\n[\\n[.ev]:pli] -.nr \\n[.ev]:pri!\\n[\\n[.ev]:il] \\n[\\n[.ev]:pri] -.nr \\n[.ev]:il +1 -.nr \\n[.ev]:li +\\n[QI] -.nr \\n[.ev]:ri +\\n[QI] -.nr \\n[.ev]:ai \\n[\\n[.ev]:PI] -.par@reset -.. -.als @QE @RE -.\" start boxed text -.de B1 -.br -.di par*box-div -.nr \\n[.ev]:li +1n -.nr \\n[.ev]:ri +1n -.par@reset -.. -.de @div-end!par*box-div -.B2 -.. -.\" end boxed text -.\" Postpone the drawing of the box until we're in the top-level diversion, -.\" in case there's a footnote inside the box. -.de B2 -.ie '\\n(.z'par*box-div' \{\ -. br -. di -. ds@need \\n[dn] -. par*box-mark-top -. ev nf -. par*box-div -. ev -. nr \\n[.ev]:ri -1n -. nr \\n[.ev]:li -1n -. par@finish -. par*box-draw \\n[.i]u \\n[.l]u -.\} -.el .@error B2 without B1 -.. -.de par*box-mark-top -.ie '\\n[.z]'' .mk par*box-top -.el \!.par*box-mark-top -.. -.de par*box-draw -.ie '\\n[.z]'' \{\ -. nr par*box-in \\n[.i] -. nr par*box-ll \\n[.l] -. nr par*box-vpt \\n[.vpt] -. vpt 0 -. in \\$1 -. ll \\$2 -\v'-1v+.25m'\ -\D'l (u;\\n[.l]-\\n[.i]) 0'\ -\D'l 0 |\\n[par*box-top]u'\ -\D'l -(u;\\n[.l]-\\n[.i]) 0'\ -\D'l 0 -|\\n[par*box-top]u' -. br -. sp -1 -. in \\n[par*box-in]u -. ll \\n[par*box-ll]u -. vpt \\n[par*box-vpt] -.\} -.el \!.par*box-draw \\$1 \\$2 -.. -.de @SH -.par@finish -.\" Keep together the heading and the first two lines of the next paragraph. -.ne 3v+\\n[\\n[.ev]:PD]u+\\n(.Vu -.sp 1 -.ft B -.. -.\" TL, AU, and AI are aliased to these in cov*ab-init. -.de par@TL -.par@finish -.sp 1 -.ft B -.ps +2 -.vs +3p -.ce 9999 -.. -.de par@AU -.par@finish -.sp 1 -.ft I -.ce 9999 -.. -.de par@AI -.par@finish -.sp .5 -.ce 9999 -.. -.\" In paragraph macros. -.de NL -.ps \\n[\\n[.ev]:PS] -.. -.de SM -.ps -2 -.. -.de LG -.ps +2 -.. -.de R -.ft R -.. -.de par*set-font -.ie \\n[.$] \{\ -. nr par*prev-font \\n[.f] -\&\\$3\f[\\*[par*font-name!\\$0]]\\$1\f[\\n[par*prev-font]]\\$2 -.\} -.el .ft \\*[par*font-name!\\$0] -.. -.ds par*font-name!B B -.ds par*font-name!I I -.ds par*font-name!BI BI -.ds par*font-name!CW CR -.als B par*set-font -.als I par*set-font -.als BI par*set-font -.als CW par*set-font -.\" underline a word -.de UL -\Z'\\$1'\v'.25m'\D'l \w'\\$1'u 0'\v'-.25m'\\$2 -.. -.\" box a word -.de BX -.nr par*bxw \w'\\$1'+.4m -\Z'\v'.25m'\D'l 0 -1m'\D'l \\n[par*bxw]u 0'\D'l 0 1m'\D'l -\\n[par*bxw]u 0''\ -\Z'\h'.2m'\\$1'\ -\h'\\n[par*bxw]u' -.. -.\" The first time UX is used, put a registered mark after it. -.ds par*ux-rg \(rg -.de UX -\s[\\n[.s]*8u/10u]UNIX\s0\\$1\\*[par*ux-rg] -.ds par*ux-rg -.. -.ds par@sup-start \v'-.9m\s'\En[.s]*7u/10u'+.7m' -.als { par@sup-start -.ds par@sup-end \v'-.7m\s0+.9m' -.als } par@sup-end -.\" footnote paragraphs -.\" FF is the footnote format -.nr FF 0 -.\" This can be redefined. It gets a second argument of `no' if the first -.\" argument was supplied by the user, rather than automatically. -.de FP -.br -.if !d par*fp!\\n[FF] \{\ -. @error unknown footnote format `\\n[FF]' -. nr FF 0 -.\} -.ie '\\$2'no' .par*fp!\\n[FF]-no "\\$1" -.el .par*fp!\\n[FF] "\\$1" -.. -.de par*fp!0 -.@PP -\&\\*[par@sup-start]\\$1\\*[par@sup-end]\ \c -.. -.de par*fp!0-no -.@PP -\&\\$1\ \c -.. -.de par*fp!1 -.@PP -\&\\$1.\ \c -.. -.de par*fp!1-no -.@PP -\&\\$1\ \c -.. -.de par*fp!2 -.@LP -\&\\$1.\ \c -.. -.de par*fp!2-no -.@LP -\&\\$1\ \c -.. -.de par*fp!3 -.@IP "\\$1." (u;\\n[\\n[.ev]:PI]*2) -.. -.de par*fp!3-no -.@IP "\\$1" (u;\\n[\\n[.ev]:PI]*2) -.. -.\" *************************** -.\" ******** module nh ******** -.\" *************************** -.\" Numbered headings. -.\" nh*hl is the level of the last heading -.nr nh*hl 0 -.\" numbered heading -.de @NH -.ie '\\$1'S' \{\ -. shift -. nr nh*hl 0 -. while \\n[.$] \{\ -. nr nh*hl +1 -. nr H\\n[nh*hl] 0\\$1 -. shift -. \} -. if !\\n[nh*hl] \{\ -. nr H1 1 -. nr nh*hl 1 -. @error missing arguments to .NH S -. \} -.\} -.el \{\ -. nr nh*ohl \\n[nh*hl] -. ie \\n[.$] \{\ -. nr nh*hl 0\\$1 -. ie \\n[nh*hl]<=0 \{\ -. nr nh*ohl 0 -. nr nh*hl 1 -. \} -. el \{\ -. if \\n[nh*hl]-\\n[nh*ohl]>1 \ -. @warning .NH \\n[nh*ohl] followed by .NH \\n[nh*hl] -. \} -. \} -. el .nr nh*hl 1 -. while \\n[nh*hl]>\\n[nh*ohl] \{\ -. nr nh*ohl +1 -. nr H\\n[nh*ohl] 0 -. \} -. nr H\\n[nh*hl] +1 -.\} -.ds SN -.nr nh*i 0 -.while \\n[nh*i]<\\n[nh*hl] \{\ -. nr nh*i +1 -. as SN \\n[H\\n[nh*i]]. -.\} -.SH -\\*[SN] -.. -.\" **************************** -.\" ******** module toc ******** -.\" **************************** -.\" Table of contents generation. -.de XS -.da toc*div -.ev h -.par@reset -.fi -.ie \\n[.$] .XA "\\$1" -.el .XA -.. -.de @div-end!toc*div -.XE -.. -.de XA -.ie '\\n(.z'toc*div' \{\ -. if d toc*num .toc*end-entry -. ie \\n[.$] \{\ -. ie '\\$1'no' .ds toc*num -. el .ds toc*num "\\$1 -. \} -. el .ds toc*num \\n[PN] -. in (n;0\\$2) -.\} -.el .@error XA without XS -.. -.de XE -.ie '\\n(.z'toc*div' \{\ -. if d toc*num .toc*end-entry -. ev -. di -.\} -.el .@error XS without XE -.. -.de toc*end-entry -\\a\\t\\*[toc*num] -.br -.rm toc*num -.. -.de PX -.1C -.if !'\\$1'no' \{\ -. ce 1 -. ps \\n[PS]+2 -. ft B -\\*[TOC] -. ft -. ps -.\} -.nf -.char \[toc*leader-char] .\h'1m' -.lc \[toc*leader-char] -.ta (u;\\n[.l]-\\n[.i]-\w'000') (u;\\n[.l]-\\n[.i])R -.sp 2 -.toc*div -.par@reset -.. -.\" print the table of contents on page i -.de TC -.P1 -.pg@begin 1 i -.PX \\$1 -.. -.\" **************************** -.\" ******** module eqn ******** -.\" **************************** -.\" Eqn support. -.de EQ -.. -.de EN -.. -.de @EQ -.br -.ds eqn*num "\\$2 -.ie '\\$1'L' .nr eqn*type 0 -.el \{\ -. ie '\\$1'I' .nr eqn*type 1 -. el \{\ -. nr eqn*type 2 -. if !'\\$1'C' .ds eqn*num "\\$1 -. \} -.\} -.di eqn*div -.in 0 -.nf -.. -.de @div-end!eqn*div -.@EN -.. -.\" Note that geqn mark and lineup work correctly in centered equations. -.de @EN -.ie !'\\n(.z'eqn*div' .@error-recover mismatched EN -.el \{\ -. br -. di -. nr eqn*have-num 0 -. if !'\\*[eqn*num]'' .nr eqn*have-num 1 -. if \\n[dl]:\\n[eqn*have-num] \{\ -. sp \\n[DD]u -. par@reset -. ds eqn*tabs \\n[.tabs] -. nf -. ie \\n[dl] \{\ -. ds@need \\n[dn]u-1v+\n[.V]u -. chop eqn*div -. ie \\n[eqn*type]=0 \{\ -. ta (u;\\n[.l]-\\n[.i])R -\\*[eqn*div]\t\\*[eqn*num] -. \} -. el \{\ -. ie \\n[eqn*type]=1 .ta \\n[DI]u \ -(u;\\n[.l]-\\n[.i])R -. el .ta (u;\\n[.l]-\\n[.i]/2)C \ -(u;\\n[.l]-\\n[.i])R -\t\\*[eqn*div]\t\\*[eqn*num] -. \} -. \} -. el \{\ -. ta (u;\\n[.l]-\\n[.i])R -\t\\*[eqn*num] -. \} -. sp \\n[DD]u -. fi -. ta \\*[eqn*tabs] -. \} -.\} -.. -.\" **************************** -.\" ******** module tbl ******** -.\" **************************** -.\" Tbl support. -.nr tbl*have-header 0 -.de TS -.\" The break is necessary in the case where the first page has not yet begun. -.br -.sp \\n[DD]u -.if '\\$1'H' .di tbl*header-div -.. -.de tbl@top-hook -.if \\n[tbl*have-header] \{\ -. ie \\n[.t]-\\n[tbl*header-ht]-1v .tbl*print-header -. el .sp \\n[.t]u -.\} -.. -.de tbl*print-header -.ev nf -.tbl*header-div -.ev -.mk #T -.. -.de TH -.ie '\\n[.z]'tbl*header-div' \{\ -. nr T. 0 -. T# -. br -. di -. ie \\n[dn]+\\n[FM]+\\n[HM]+2v>=\\n[.p] \{\ -. @error ridiculously long table header -. ds@need \\n[dn] -. tbl*print-header -. \} -. el \{\ -. nr tbl*header-ht \\n[dn] -. ds@need \\n[dn]u+1v -. tbl*print-header -. nr tbl*have-header 1 -. \} -.\} -.el .@error-recover .TH without .TS H -.. -.de @div-end!tbl*header-div -.TH -.TE -.. -.de TE -.ie '\\n(.z'tbl*header-div' .@error-recover .TS H but no .TH before .TE -.el \{\ -. nr tbl*have-header 0 -. sp \\n[DD]u -.\} -.\" reset tabs -.TA -.. -.de tbl@bottom-hook -.if \\n[tbl*have-header] \{\ -. nr T. 1 -. T# -.\} -.. -.de T& -.. -.\" **************************** -.\" ******** module pic ******** -.\" **************************** -.\" Pic support. -.\" PS height width -.de PS -.br -.sp \\n[DD]u -.ie \\n[.$]<2 .@error bad arguments to PS (not preprocessed with pic?) -.el \{\ -. ds@need (u;\\$1)+1v -. in +(u;\\n[.l]-\\n[.i]-\\$2/2) -.\} -.. -.de PE -.par@reset -.sp \\n[DD]u+.5m -.. -.\" **************************** -.\" ******** module ref ******** -.\" **************************** -.\" Refer support. -.de ]- -.rm [A [B [C [D [E [G [I [J [N [O [P [Q [R [S [T [V -.rm ref*string -.. -.\" Other -.ds ref*spec!0 Q A T S V N P I C D O -.\" Journal article -.ds ref*spec!1 Q A T J S V N P I C D O -.\" Book -.ds ref*spec!2 Q A T S V P I C D O -.\" Article within book -.ds ref*spec!3 Q A T B E S V P I C D O -.\" Tech report -.ds ref*spec!4 Q A T R G P I C D O -.\" ][ type -.de ][ -.ie d ref*spec!\\$1 .ref*build \\*[ref*spec!\\$1] -.el \{\ -. @error unknown reference type `\\$1' -. ref*build \\*[ref*spec!0] -.\} -.ref*print -.rm ref*string -.rm [F -.. -.\" start of reference number -.ds [. \\*[par@sup-start] -.\" end of reference number -.ds .] \\*[par@sup-end] -.\" period before reference -.ds <. . -.\" period after reference -.ds >. \" empty -.\" comma before reference -.ds <, , -.\" comma after reference -.ds >, \" empty -.\" start collected references -.de ]< -.als ref*print ref*end-print -.SH -\&\\*[REFERENCES] -.par@reset -.. -.\" end collected references -.de ]> -.par@finish -.als ref*print ref*normal-print -.. -.de ref*normal-print -.ie d [F .FS "\\*([.\\*([F\\*(.]" -.el .FS \& -\\*[ref*string] -.FE -.. -.de ref*end-print -.ie d [F .IP "\\*([F." -.el .XP -\\*[ref*string] -.. -.als ref*print ref*normal-print -.de ref*build -.rm ref*string ref*post-punct -.nr ref*suppress-period 1 -.while \\n[.$] \{\ -. if d [\\$1 \{\ -. ie d ref*add-\\$1 .ref*add-\\$1 -. el .ref*add-dflt \\$1 -. \} -. shift -.\} -.\" now add a final period -.ie d ref*string \{\ -. if !\\n[ref*suppress-period] .as ref*string . -. if d ref*post-punct \{\ -. as ref*string "\\*[ref*post-punct] -. rm ref*post-punct -. \} -.\} -.el .ds ref*string -.. -.de ref*add-T -.ref*field T , "\\*Q" "" "\\*U" -.if r [T .nr ref*suppress-period \\n([T -.. -.de ref*add-P -.ie \\n([P>0 .ref*field P , "pp. " -.el .ref*field P , "p. " -.. -.de ref*add-J -.ref*field J , \fI "" \fP -.. -.de ref*add-D -.ref*field D "" ( ) -.. -.de ref*add-E -.ref*field E , "ed. " -.. -.de ref*add-G -.ref*field G "" ( ) -.. -.de ref*add-B -.ref*field B "" "in \fI" "" \fP -.. -.de ref*add-O -.ref*field O . -.ie r [O .nr ref*suppress-period \\n([O -.el .nr ref*suppress-period 1 -.. -.de ref*add-A -.ref*field A , -.if r [A .nr ref*suppress-period \\n([A -.. -.de ref*add-dflt -.ref*field \\$1 , -.. -.\" First argument is the field letter. -.\" Second argument is the punctuation character to use to separate this field -.\" from the previous field. -.\" Third argument is a string with which to prefix this field. -.\" Fourth argument is a string with which to postfix this field. -.\" Fifth argument is a string to add after the punctuation character supplied -.\" by the next field. -.de ref*field -.if d ref*string \{\ -. ie d ref*post-punct \{\ -. as ref*string "\\$2\\*[ref*post-punct] \" -. rm ref*post-punct -. \} -. el .as ref*string "\\$2 \" -.\} -.as ref*string "\\$3\\*([\\$1\\$4 -.if \\n[.$]>4 .ds ref*post-punct "\\$5 -.nr ref*suppress-period 0 -.. -.\" **************************** -.\" ******** module acc ******** -.\" **************************** -.\" Accents and special characters. -.ds Q \)``\) -.ds U \)''\) -.ds - \(em -.\" Characters -.if !c\(rg .char \(rg (R) -.if !c\(ah .char \(ah \v'-.55m'\s[\En[.s]/2u]v\s0\v'.55m' -.if !c\(ad .char \(ad \v'-.55m'\s[\En[.s]*7u/10u].\h'.05m'.\s0\v'.55m' -.if !c\(a- .char \(a- \v'-.55m'\D'l .25m 0'\v'.55m' -.if !c\(ao .char \(ao \v'-.55m'\s[\En[.s]*6u/10u]\D'c .25m'\s0\v'.55m' -.if !c\(ac .char \(ac \s[\En[.s]*8u/10u]\v'.05m',\v'-.05m'\s0 -.if !c\(ho .char \(ho \s[\En[.s]/2u]\v'.4m'c\v'-.4m'\s0 -.if !c\(-D .char \(-D \Z'\v'-.1m'-'D -.if !c\(Sd .char \(Sd \Z'\v'-.3m'\h'.2m'-'\(pd -.if !c\(TP .char \(TP I\h'-.25m'\v'-.33m'\s[\En[.s]*6u/10u]\v'.33m'D\ -\v'-.33m'\s0\v'.33m' -.if !c\(Tp .char \(Tp \zlp -.if !c\(ss .char \(ss \(*b -.if !c\(AE .char \(AE A\h'-.3m'E -.if !c\(ae .char \(ae a\h'-.19m'e -.if !c\(OE .char \(OE O\h'-.25m'E -.if !c\(oe .char \(oe o\h'-.14m'e -.if !c\(r? .char \(r? \Z'\h'.1m'\v'-.15m'\s[\En[.s]*7u/10u]i\s0\v'.15m''\ -\v'.15m'\s[\En[.s]*7u/10u]c\s0\v'-.15m' -.if !c\(r! .char \(r! \h'.1m'\Z'\v'-.4m'\s[\En[.s]*8u/10u].\s0\v'.4m''\ -\s[\En[.s]*8u/10u]\v'.4m'\(or\v'-.4m'\s0\h'.1m' -.\" The idea of this definition is for the top of the 3 to be at the x-height. -.\" A yogh really ought to have a little line going north-west from the top -.\" left of the 3. -.if !c\[yogh] .char \[yogh] \Z'\v'\w'x'*0-\En[rst]u'\s[\En[.s]*8u/10u]\ -\v'\w'3'*0+\En[rst]u'3\s0'\h'\w'\s[\En[.s]*8u/10u]3'u' -.\" Accents -.de acc*over-def -.ds \\$1 \Z'\v'(u;\w'x'*0+\En[rst]-\En[.cht])'\ -\h'(u;-\En[skw]+(-\En[.w]-\w'\\$2'/2)+\En[.csk])'\\$2' -.. -.de acc*under-def -.ds \\$1 \Z'\v'\En[.cdp]u'\h'(u;-\En[.w]-\w'\\$2'/2)'\\$2' -.. -.de acc*slash-def -.ds \\$1 \Z'\h'(u;-\En[.w]-\w'\\$2'/2)'\ -\v'(u;\En[.cdp]-\En[.cht]+\En[rst]+\En[rsb]/2)'\\$2' -.. -.de acc*prefix-def -.ds \\$1 \Z'\h'(u;\w'x'-\w'\\$2'/2)'\\$2' -.. -.acc*prefix-def ' \' -.acc*prefix-def ` \` -.acc*prefix-def ^ ^ -.acc*prefix-def , \(ac -.acc*prefix-def : \(ad -.acc*prefix-def ~ ~ -.\" improved accent marks -.de AM -.acc*over-def ' \' -.acc*over-def ` \` -.acc*over-def ^ ^ -.acc*over-def ~ ~ -.acc*over-def : \(ad -.acc*over-def v \(ah -.acc*over-def _ \(a- -.acc*over-def o \(ao -.acc*under-def , \(ac -.acc*under-def . \s[\En[.s]*8u/10u]\v'.2m'.\v'-.2m'\s0 -.acc*under-def hook \(ho -.acc*slash-def / / -.char \[hooko] o\\\\*[hook] -.ds q \[hooko] -.ds 3 \[yogh] -.ds D- \(-D\" Icelandic uppercase eth -.ds d- \(Sd\" Icelandic lowercase eth -.ds Th \(TP\" Icelandic uppercase thorn -.ds th \(Tp\" Icelandic lowercase thorn -.ds 8 \(ss\" German double s -.ds Ae \(AE\" AE ligature -.ds ae \(ae\" ae ligature -.ds Oe \(OE\" OE ligature -.ds oe \(oe\" oe ligature -.ds ? \(r?\" upside down ? -.ds ! \(r!\" upside down ! -.. -.\" Make sure that no blank lines creep in at the end of this file. diff --git a/gnu/usr.bin/groff/macros/tmac.tty b/gnu/usr.bin/groff/macros/tmac.tty deleted file mode 100644 index 755761bcb549..000000000000 --- a/gnu/usr.bin/groff/macros/tmac.tty +++ /dev/null @@ -1,44 +0,0 @@ -.\" -.\" -.nr _C \n(.C -.cp 0 -.nroff -.ftr CW B -.ftr C B -.ftr CR B -.po 0 -.de tty-char -.if !c\\$1 .char \\$1 \\$2 -.. -.tty-char \(14 1/4 -.tty-char \(12 1/2 -.tty-char \(34 1/4 -.tty-char \(fi fi -.tty-char \(fl fl -.tty-char \(Fi ffi -.tty-char \(Fl ffl -.tty-char \(<- <- -.tty-char \(-> -> -.tty-char \(<> <-> -.tty-char \(lA <= -.tty-char \(rA => -.tty-char \(<= <= -.tty-char \(>= => -.tty-char \(hA <=> -.tty-char \(ua ^ -.tty-char \(da v -.tty-char \(uA ^ -.tty-char \(dA v -.tty-char \(em -- -.tty-char \(en - -.tty-char \(ru _ -.tty-char \(ul _ -.tty-char \(br | -.tty-char \(bv | -.tty-char \(sl / -.tty-char \(+- +- -.tty-char \(co (C) -.tty-char \(co (C) -.tty-char \(*G gamma -.tty-char \(*E epsilon -.cp \n(_C diff --git a/gnu/usr.bin/groff/man/groff_me.man b/gnu/usr.bin/groff/man/groff_me.man deleted file mode 100644 index 8e07ff62fcfe..000000000000 --- a/gnu/usr.bin/groff/man/groff_me.man +++ /dev/null @@ -1,271 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms are permitted -.\" provided that the above copyright notice and this paragraph are -.\" duplicated in all such forms and that any documentation, -.\" advertising materials, and other materials related to such -.\" distribution and use acknowledge that the software was developed -.\" by the University of California, Berkeley. The name of the -.\" University may not be used to endorse or promote products derived -.\" from this software without specific prior written permission. -.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -.\" -.\" @(#)me.7 6.4 (Berkeley) 4/13/90 -.\" -.\" Modified for groff by jjc@jclark.uucp. -.hc % -.TH GROFF_ME @MAN7EXT@ "April 13, 1990" "Groff Version @VERSION@" -.UC 3 -.SH NAME -groff_me \- groff macros for formatting papers -.SH SYNOPSIS -.B "groff \-me" -[ options ] -file ... -.br -.B "troff \-me" -[ options ] -file ... -.SH DESCRIPTION -This package of -.I groff -macro definitions provides a canned formatting -facility for tech%nical papers in various formats. -.PP -The macro requests are defined below. -Many -.I groff -requests are unsafe in conjunction with -this package, however, these requests may be used with -impunity after the first .pp: -.nf -.IP -.ta \w'.sz +n 'u -\&.bp begin new page -\&.br break output line here -\&.sp n insert n spacing lines -\&.ls n (line spacing) n=1 single, n=2 double space -\&.na no alignment of right margin -\&.ce n center next n lines -\&.ul n underline next n lines -.fi -.PP -Output of the -.I gpic, -.I geqn, -.I refer, -and -.I gtbl -preprocessors -is acceptable as input. -.SH FILES -@MACRODIR@/tmac.e -.SH "SEE ALSO" -.BR groff (@MAN1EXT@), -.BR gtroff (@MAN1EXT@) -.br -\-me Reference Manual, Eric P. Allman -.br -Writing Papers with Groff Using \-me -.tr &. -.SH REQUESTS -This list is incomplete; -see -.I "The \-me Reference Manual" -for interesting details. -.PP -.ta \w'.eh \'x\'y\'z\' 'u +\w'Initial 'u +\w'Cause 'u -.br -.di x - \ka -.br -.di -.in \nau -.ti 0 -Request Initial Cause Explanation -.ti 0 - Value Break -.br -.in \nau -.ti 0 -\&.(c - yes Begin centered block -.ti 0 -\&.(d - no Begin delayed text -.ti 0 -\&.(f - no Begin footnote -.ti 0 -\&.(l - yes Begin list -.ti 0 -\&.(q - yes Begin major quote -.ti 0 -\&.(x \fIx\fR - no Begin indexed item in index -.I x -.ti 0 -\&.(z - no Begin floating keep -.ti 0 -\&.)c - yes End centered block -.ti 0 -\&.)d - yes End delayed text -.ti 0 -\&.)f - yes End footnote -.ti 0 -\&.)l - yes End list -.ti 0 -\&.)q - yes End major quote -.ti 0 -\&.)x - yes End index item -.ti 0 -\&.)z - yes End floating keep -.ti 0 -\&.++ \fIm H\fR - no Define paper section. -.I m -defines the part of the paper, and can be -.B C -(chapter), -.B A -(appendix), -.B P -(preliminary, e.g., abstract, table of contents, etc.), -.B B -(bibliography), -.B RC -(chapters renumbered from page one each chapter), -or -.B RA -(appendix renumbered from page one). -.ti 0 -\&.+c \fIT\fR - yes Begin chapter (or appendix, etc., as -set by .++). -.I T -is the chapter title. -.ti 0 -\&.1c 1 yes One column format on a new page. -.ti 0 -\&.2c 1 yes Two column format. -.ti 0 -\&.EN - yes Space after equation -produced by -.I eqn -or -.IR neqn . -.ti 0 -\&.EQ \fIx y\fR - yes Precede equation; break out and -add space. -Equation number is -.IR y . -The optional argument \fIx\fR -may be -.I I -to indent equation (default), -.I L -to left-adjust the equation, or -.I C -to center the equation. -.ti 0 -\&.GE - yes End \fIgremlin\fP picture. -.ti 0 -\&.GS - yes Begin \fIgremlin\fP picture. -.ti 0 -\&.PE - yes End \fIpic\fP picture. -.ti 0 -\&.PS - yes Begin \fIpic\fP picture. -.ti 0 -\&.TE - yes End table. -.ti 0 -\&.TH - yes End heading section of table. -.ti 0 -\&.TS \fIx\fR - yes Begin table; if \fIx\fR is -.I H -table has repeated heading. -.ti 0 -\&.b \fIx\fR no no Print -.I x -in boldface; if no argument switch to boldface. -.ti 0 -\&.ba \fI+n\fR 0 yes Augments the base indent by -.I n. -This indent is used to set the indent on regular text -(like paragraphs). -.ti 0 -\&.bc no yes Begin new column -.ti 0 -\&.bi \fIx\fR no no Print -.I x -in bold italics (nofill only) -.ti 0 -\&.bu - yes Begin bulleted paragraph -.ti 0 -\&.bx \fIx\fR no no Print \fIx\fR in a box (nofill only). -.ti 0 -\&.ef \fI\'x\'y\'z\'\fR \'\'\'\' no Set even footer to x y z -.ti 0 -\&.eh \fI\'x\'y\'z\'\fR \'\'\'\' no Set even header to x y z -.ti 0 -\&.fo \fI\'x\'y\'z\'\fR \'\'\'\' no Set footer to x y z -.ti 0 -\&.hx - no Suppress headers and footers on next page. -.ti 0 -\&.he \fI\'x\'y\'z\'\fR \'\'\'\' no Set header to x y z -.ti 0 -\&.hl - yes Draw a horizontal line -.ti 0 -\&.i \fIx\fR no no Italicize -.I x; -if -.I x -missing, italic text follows. -.ti 0 -\&.ip \fIx y\fR no yes Start indented paragraph, -with hanging tag -.IR x . -Indentation is -.I y -ens (default 5). -.ti 0 -\&.lp yes yes Start left-blocked paragraph. -.ti 0 -\&.np 1 yes Start numbered paragraph. -.ti 0 -\&.of \fI\'x\'y\'z\'\fR \'\'\'\' no Set odd footer to x y z -.ti 0 -\&.oh \fI\'x\'y\'z\'\fR \'\'\'\' no Set odd header to x y z -.ti 0 -\&.pd - yes Print delayed text. -.ti 0 -\&.pp no yes Begin paragraph. -First line indented. -.ti 0 -\&.r yes no Roman text follows. -.ti 0 -\&.re - no Reset tabs to default values. -.ti 0 -\&.sh \fIn x\fR - yes Section head follows, -font automatically bold. -.I n -is level of section, -.I x -is title of section. -.ti 0 -\&.sk no no Leave the next page blank. -Only one page is remembered ahead. -.ti 0 -\&.sm \fIx\fR - no Set -.I x -in a smaller pointsize. -.ti 0 -\&.sz \fI+n\fR 10p no Augment the point size by -.I n -points. -.ti 0 -\&.tp no yes Begin title page. -.ti 0 -\&.u \fIx\fR - no Underline argument (even in \fItroff\fR). -(Nofill only). -.ti 0 -\&.uh - yes Like .sh but unnumbered. -.ti 0 -\&.xp \fIx\fR - no Print index -.I x. diff --git a/gnu/usr.bin/groff/man/groff_ms.man b/gnu/usr.bin/groff/man/groff_ms.man deleted file mode 100644 index 9de321826970..000000000000 --- a/gnu/usr.bin/groff/man/groff_ms.man +++ /dev/null @@ -1,209 +0,0 @@ -.\" -*- nroff -*- -.TH GROFF_MS @MAN7EXT@ "29 November 1990" "Groff Version @VERSION@" -.SH NAME -groff_ms \- groff ms macros -.SH SYNOPSIS -.B groff -.B \-m@TMAC_S@ -[ -.IR options .\|.\|. -] -[ -.IR files .\|.\|. -] -.SH DESCRIPTION -The groff ms macros are intended to be compatible with the 4.3 -.SM BSD -Unix ms macros subject to the following limitations: -.IP \(bu -the internals of groff ms are not similar to the internals of Unix ms -and so documents that depend upon implementation details of Unix ms -may well not work with groff ms; -.IP \(bu -there is no support for typewriter-like devices; -.IP \(bu -Berkeley localisms, in particular the -.B TM -and -.B CT -macros, are not implemented; -.IP \(bu -groff ms -does not provide cut marks; -.IP \(bu -multiple line spacing is not allowed -(use a larger vertical spacing instead); -.IP \(bu -groff ms does not work in compatibility mode (eg with the -.B \-C -option); -.IP \(bu -the error-handling policy of groff ms -is to detect and report errors, -rather than silently to ignore them. -.LP -The groff ms macros make use of many features of -.B gtroff -and therefore cannot be used with any other troff. -.LP -Bell Labs localisms are not implemented in either the -.SM BSD -ms macros or in the groff ms macros. -.LP -Some Unix ms documentation says that the -.B CW -and -.B GW -number registers can be used to control the column width and -gutter width respectively. -This is not the case. -These number registers are not used in groff ms. -.LP -Macros that cause a reset set the indent. -Macros that change the indent do not increment or decrement -the indent, but rather set it absolutely. -This can cause problems for documents that define -additional macros of their own. -The solution is to use not the -.B in -request but instead the -.B RS -and -.B RE -macros. -.LP -The number register -.B GS -is set to 1 by the groff ms macros, -but is not used by the Unix ms macros. -It is intended that documents that need to determine whether -they are being formatted with Unix ms or groff ms make use of this -number register. -.LP -Footnotes are implemented so that they can safely be used within -keeps and displays. -Automatically numbered footnotes within floating keeps are -not recommended. -It is safe to have another -.B \e** -between a -.B \e** -and the corresponding -.BR .FS ; -it is required only that each -.B .FS -occur after the corresponding -.B \e** -and that the occurrences of -.B .FS -are in the same order as the corresponding occurrences of -.BR \e** . -.LP -The strings -.B \e*{ -and -.B \e*} -can be used to begin and end a superscript. -.LP -Some Unix V10 ms features are implemented. -The -.BR B , -.BR I -and -.B BI -macros can have an optional third argument which will be printed -in the current font before the first argument. -There is a macro -.B CW -like -.B B -that changes to a constant-width font. -.LP -The following strings can be redefined to adapt the groff ms macros -to languages other than English: -.LP -.nf -.ta \w'REFERENCES'u+2n -String Default Value -.sp .3v -REFERENCES References -ABSTRACT ABSTRACT -TOC Table of Contents -MONTH1 January -MONTH2 February -MONTH3 March -MONTH4 April -MONTH5 May -MONTH6 June -MONTH7 July -MONTH8 August -MONTH9 September -MONTH10 October -MONTH11 November -MONTH12 December -.fi -.LP -The font family is reset from the string -.BR FAM ; -at initialization if this string is undefined it is set to the current -font family. -The point size, vertical spacing, and inter-paragraph spacing for footnotes -are taken from the number registers -.BR FPS , -.BR FVS , -and -.BR FPD ; -at initialization these are set to -.BR \en(PS-2 , -.BR \en[FPS]+2 , -and -.B \en(PD/2 -respectively; however, if any of these registers has been defined -before initialization, it will not be set. -.LP -Right-aligned displays are available with -.B ".DS R" -and -.BR .RD . -.LP -The following conventions are used for names of macros, strings and -number registers. -External names available to documents that use the groff ms -macros contain only uppercase letters and digits. -Internally the macros are divided into modules. -Names used only within one module are of the form -.IB module * name\fR. -Names used outside the module in which they are defined are of the form -.IB module @ name\fR. -Names associated with a particular environment are of the form -.IB environment : name; -these are used only within the -.B par -module, -and -.I name -does not have a module prefix. -Constructed names used to implement arrays are of the form -.IB array ! index\fR. -Thus the groff ms macros reserve the following names: -.IP \(bu -names containing -.BR * ; -.IP \(bu -names containing -.BR @ ; -.IP \(bu -names containing -.BR : ; -.IP \(bu -names containing only uppercase letters and digits. -.SH FILES -.B @MACRODIR@/tmac.@TMAC_S@ -.SH "SEE ALSO" -.BR groff (@MAN1EXT@), -.BR gtroff (@MAN1EXT@), -.BR gtbl (@MAN1EXT@), -.BR gpic (@MAN1EXT@), -.BR geqn (@MAN1EXT@) -.br -.BR ms (@MAN7EXT@) diff --git a/gnu/usr.bin/groff/man/groff_out.man b/gnu/usr.bin/groff/man/groff_out.man deleted file mode 100644 index 4a94c5cb1c4d..000000000000 --- a/gnu/usr.bin/groff/man/groff_out.man +++ /dev/null @@ -1,215 +0,0 @@ -'\" e -.\" -*- nroff -*- -.\" This man page must be preprocessed with eqn. -.ie \n(.g .ds ic \/ -.el .ds ic \^ -.TH GROFF_OUT @MAN5EXT@ "17 September 1990" "Groff Version @VERSION@" -.SH SYNOPSIS -groff_out \- format of groff output -.SH DESCRIPTION -The output format used by groff is very similar to that used -by device-independent troff. Only the differences are documented -here. -.LP -The argument to the -.B s -command is in scaled points (units of -.IR points/ n , -where -.I n -is the argument to the -.B sizescale -command in the DESC file.) -The argument to the -.B x\ Height -command is also in scaled points. -.LP -The first three output commands are guaranteed to be: -.IP -.BI x\ T\ device -.br -.BI x\ res\ n\ h\ v -.br -.B x init -.LP -If the -.B tcommand -line is present in the DESC file, gtroff will use the following -two commands -.TP -.BI t xxx -.I xxx -is any sequence of characters terminated by a space or a newline; -the first character should be printed at the current position, -the the current horizontal position should be increased by -the width of the first character, and so on for each character. -The width of the character is that given in the font file, -appropriately scaled for the current point size, and rounded -so that it is a multiple of the horizontal resolution. -Special characters cannot be printed using this command. -.TP -.BI u n\ xxx -This is same as the -.B t -command except that after printing each character, the current horizontal -position is increased by the sum of the width of that character -and -.IR n . -.LP -Note that single characters can have the eighth bit set, as can the -names of fonts and special characters. -.LP -The names of characters and fonts an be of arbitrary length; drivers -should not assume that they will be only two characters long. -.LP -When a character is to be printed, that character will always be -in the current font. -Unlike device-independent troff, it is not necessary -for drivers to search special fonts to find a character. -.LP -The -.B D -drawing command has been extended. -These extensions will only be used by gpic -.B \-x -option is given. -.TP -\fBDf \fIn\fR\*(ic\en -Set the shade of gray to be used for filling solid objects to -.IR n ; -.I n -must be an integer between 0 and 1000, where 0 corresponds solid white -and 1000 to solid black, and values in between correspond to -intermediate shades of gray. -This applies only to solid circles, solid ellipses and solid -polygons. -By default, a level of 1000 will be used. -Whatever color a solid object has, it should completely obscure -everything beneath it. -A value greater than 1000 or less than 0 can also be used: -this means fill with the shade of gray that is currently being used -for lines and text. -Normally this will be black, but some drivers may provide -a way of changing this. -.TP -\fBDC \fId\fR\*(ic\en -Draw a solid circle with a diameter of -.I d -with the leftmost point at the current position. -.TP -\fBDE \fIdx dy\fR\*(ic\en -Draw a solid ellipse with a horizontal diameter of -.I dx -and a vertical diameter of -.I dy -with the leftmost point at the current position. -.EQ -delim $$ -.EN -.TP -\fBDp\fR $dx sub 1$ $dy sub 1$ $dx sub 2$ $dy sub 2$ $...$ $dx sub n$ $dy sub n$\en -Draw a polygon with, -for $i = 1 ,..., n+1$, the -.IR i -th -vertex at the current position -$+ sum from j=1 to i-1 ( dx sub j , dy sub j )$. -At the moment, -gpic only uses this command to generate triangles and rectangles. -.TP -\fBDP\fR $dx sub 1$ $dy sub 1$ $dx sub 2$ $dy sub 2$ $...$ $dx sub n$ $dy sub n$\en -Like -.B Dp -but draw a solid rather than outlined polygon. -.TP -\fBDt \fIn\fR\*(ic\en -Set the current line thickness to -.I n -machine units. -Traditionally troff drivers use a line thickness proportional to the current -point size; drivers should continue to do this if no -.B Dt -command has been given, or if a -.B Dt -command has been given with a negative value of -.IR n . -A zero value of -.I n -selects the smallest available line thickness. -.LP -A difficulty arises in how the current position should be changed after -the execution of these commands. -This is not of great importance since the code generated by gpic -does not depend on this. -Given a drawing command of the form -.IP -\fB\eD\(fm\fIc\fR $x sub 1$ $y sub 1$ $x sub 2$ $y sub 2$ $...$ $x sub n$ $y sub n$\(fm -.LP -where -.I c -is not one of -.BR c , -.BR e , -.BR l , -.B a -or -.BR ~ , -troff will treat each of the $x sub i$ as a horizontal quantity, -and each of the $y sub i$ as a vertical quantity and will assume that -the width of the drawn object is $sum from i=1 to n x sub i$, -and that the height is $sum from i=1 to n y sub i$. -(The assumption about the height can be seen by examining the -.B st -and -.B sb -registers after using such a -.B D -command in a \ew escape sequence.) -This rule also holds for all the original drawing commands -with the exception of -.BR De . -For the sake of compatibility gtroff also follows this rule, -even though it produces an ugly result in the case of the -.BR Df , -.BR Dt , -and, to a lesser extent, -.B DE -commands. -Thus after executing a -.B D -command of the form -.IP -\fBD\fIc\fR $x sub 1$ $y sub 1$ $x sub 2$ $y sub 2$ $...$ $x sub n$ $y sub n$\en -.LP -the current position should be increased by -$( sum from i=1 to n x sub i , sum from i=1 to n y sub i )$. -.LP -There is a continuation convention which permits the argument to the -.B x\ X -command to contain newlines: -when outputting the argument to the -.B x\ X -command, -.B gtroff -will follow each newline in the argument with a -.B + -character -(as usual, it will terminate the entire argument with a newline); -thus if the line after the line containing the -.B x\ X -command starts with -.BR + , -then the newline ending the line containing the -.B x\ X -command should be treated as part of the argument to the -.B x\ X -command, -the -.B + -should be ignored, -and the part of the line following the -.B + -should be treated like the part of the line following the -.B x\ X -command. -.SH "SEE ALSO" -.BR groff_font (@MAN5EXT@) diff --git a/gnu/usr.bin/groff/man/grog.man b/gnu/usr.bin/groff/man/grog.man deleted file mode 100644 index 99d5fe6274f6..000000000000 --- a/gnu/usr.bin/groff/man/grog.man +++ /dev/null @@ -1,54 +0,0 @@ -.TH GROG @MAN1EXT@ "20 October 1990" "Groff Version @VERSION@" -.SH NAME -grog \- guess options for groff command -.SH SYNOPSIS -.B grog -[ -.BI \- option -\|.\|.\|. -] -[ -.IR files \|.\|.\|. -] -.SH DESCRIPTION -.B grog -reads -.I files -and guesses which of the -.BR groff (@MAN1EXT@) -options -.BR \-e , -.BR \-man , -.BR \-me , -.BR \-mm , -.BR \-ms , -.BR \-p , -.BR \-s , -and -.BR \-t -are required for printing -.IR files , -and prints the groff command including those options on the standard output. -A filename of -.B \- -is taken to refer to the standard input. -If no files are specified the standard input will be read. -Any specified options will be included in the printed command. -No space is allowed between options and their arguments. -For example, -.IP -.B `grog \-Tdvi paper.ms` -.LP -will guess the approriate command to print -.B paper.ms -and then run it after adding the -.B \-Tdvi -option. -.SH "SEE ALSO" -.BR doctype (1), -.BR groff (@MAN1EXT@), -.BR gtroff (@MAN1EXT@), -.BR gtbl (@MAN1EXT@), -.BR gpic (@MAN1EXT@), -.BR geqn (@MAN1EXT@), -.BR gsoelim (@MAN1EXT@) diff --git a/gnu/usr.bin/groff/man/gsoelim.man b/gnu/usr.bin/groff/man/gsoelim.man deleted file mode 100644 index 2605917fcfac..000000000000 --- a/gnu/usr.bin/groff/man/gsoelim.man +++ /dev/null @@ -1,42 +0,0 @@ -.\" -*- nroff -*- -.TH GSOELIM @MAN1EXT@ "22 April 1990" "Groff Version @VERSION@" -.SH NAME -gsoelim \- interpret .so requests in groff input -.SH SYNOPSIS -.B gsoelim -[ -.B \-Cv -] -[ -.IR files \|.\|.\|.\| -] -.SH DESCRIPTION -.B gsoelim -reads -.I files -and replaces lines of the form -.IP -.BI .so\ file -.LP -by the contents of -.IR file . -It is useful if files included with -.B so -need to be preprocessed. -Normally, -.B gsoelim -should be invoked with the -.B \-s -option of -.BR groff . -.SH OPTIONS -.TP -.B \-C -Recognize -.B .so -even when followed by a character other than space or newline. -.TP -.B \-v -Print the version number. -.SH "SEE ALSO" -.BR groff (@MAN1EXT@) diff --git a/gnu/usr.bin/groff/man/tfmtodit.man b/gnu/usr.bin/groff/man/tfmtodit.man deleted file mode 100644 index 2cbb97cdf5a0..000000000000 --- a/gnu/usr.bin/groff/man/tfmtodit.man +++ /dev/null @@ -1,144 +0,0 @@ -.\" -*- nroff -*- -.ie t .ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X -.el .ds tx TeX -.TH TFMTODIT @MAN1EXT@ "23 August 1990" "Groff Version @VERSION@" -.SH NAME -tfmtodit \- create font files for use with groff \-Tdvi -.SH SYNOPSIS -.B tfmtodit -[ -.B \-sv -] -[ -.BI \-g gf_file -] -[ -.BI \-k skewchar -] -.I tfm_file -.I map_file -.I font -.SH DESCRIPTION -.B tfmtodit -creates a font file for use with -.B -groff \-Tdvi\fR. -.I tfm_file -is the name of the \*(tx font metric file for the font. -.I map_file -is a file giving the groff names for characters in the font; -this file should consist of a sequence of lines of the form: -.IP -.I -n c1 c2 \fR.\|.\|. -.LP -where -.I n -is a decimal integer giving the position of the character in the font, -and -.IR c1 , -.IR c2 ,.\|.\|. -are the groff names of the character. -If a character has no groff names but exists in the tfm file, -then it will be put in the groff font file as an unnamed character. -.I font -is the name of the groff font file. -The groff font file is written to -.IR font . -.LP -The -.B \-s -option should be given if the font is special -(a font is -.I special -if -.B gtroff -should search it whenever -a character is not found in the current font.) -If the font is special, -it should be listed in the -.B fonts -command in the DESC file; -if it is not special, there is no need to list it, since -.B gtroff -can automatically mount it when it's first used. -.LP -To do a good job of math typesetting, groff requires -font metric information not present in the tfm file. -The reason for this is that \*(tx has separate math italic fonts -whereas groff uses normal italic fonts for math. -The additional information required by groff is given by the -two arguments to the -.B math_fit -macro in the Metafont programs for the Computer Modern fonts. -In a text font (a font for which -.B math_fitting -is false), Metafont normally ignores these two arguments. -Metafont can be made to put this information in the gf file -by loading the following definition after -.B cmbase -when creating -.BR cm.base : -.IP -.nf -.ft B -def ignore_math_fit(expr left_adjustment,right_adjustment) = - special "adjustment"; - numspecial left_adjustment*16/designsize; - numspecial right_adjustment*16/designsize; - enddef; -.fi -.ft R -.LP -The gf file created using this modified -.B cm.base -should be specified with the -.B \-g -option. -The -.B \-g -option should not be given for a font for which -.B math_fitting -is true. -.SH OPTIONS -.TP -.B \-v -Print the version number. -.TP -.B \-s -The font is special. -The effect of this option is to add the -.B special -command to the font file. -.TP -.BI \-k n -The skewchar of this font is at position -.IR n . -.I n -should be an integer; -it may be given in decimal, -or with a leading -.B 0 -in octal, -or with a leading -.B 0x -in hexadecimal. -The effect of this option is to ignore any kerns whose second component -is the specified character. -.TP -.BI \-g gf_file -.I gf_file -is a gf file produced by Metafont containing special and numspecial -commands giving additional font metric information. -.SH FILES -.TP \w'\fB@FONTDIR@/devdvi/DESC'u+2n -.B @FONTDIR@/devdvi/DESC -Device desciption file. -.TP -.BI @FONTDIR@/devdvi/ F -Font description file for font -.IR F . -.SH "SEE ALSO" -.BR groff (@MAN1EXT@), -.BR grodvi (@MAN1EXT@), -.BR groff_font (@MAN5EXT@) diff --git a/gnu/usr.bin/gzip-1.0.7/THANKS b/gnu/usr.bin/gzip-1.0.7/THANKS deleted file mode 100644 index 77a9e3aaad60..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/THANKS +++ /dev/null @@ -1,136 +0,0 @@ -gzip has been written by Jean-loup Gailly , with -portions written by Mark Adler (inflate.c) and Peter Jannesen -(unlzw.c). The zip deflate format was defined by Phil Katz. -Thanks to those who reported problems and suggested -various improvements. Here is a partial list of them: - -Mark Adler madler@cco.caltech.edu -Joseph Arceneaux jla@gnu.ai.mit.edu -Tim Auckland tda10@cus.cam.ac.uk -Ken-ichiro Aoki aoki@madonna.physics.ucla.edu -Eric Backus ericb@lsid.hp.com -Becky A. Badgett badgett@cs.utexas.edu -Neal Becker neal@ctd.comsat.com -Dieter Becker becker@med-in.uni-sb.de -Nelson H. F. Beebe beebe@geronimo.math.utah.edu -Jeff Beadles jeff@onion.rain.com -Jim Bernard jbernard@iola.mines.colorado.edu -Karl Berry karl@cs.umb.edu -Wayne E. Bouchard web@paladine.hacks.arizona.edu -Marc Boucher marc@cam.org -Rodney Brown rdb@mel.cocam.oz.au -Bruce bde@runx.oz.au -Leila Burrell-Davis leilabd@syma.sussex.ac.uk -Roger Butenuth butenuth@ira.uka.de -Bud Carlson bud@isle.pegasus.com -Lim Fung Chai fclim@i1sin.daq.semi.harris.com -Paul Close pdc@lunch.wpd.sgi.com -Kevin Cosgrove kevinc@tekig6.pen.tek.com -Stephen J Cowley s.j.cowley@amtp.cam.ac.uk -Frank Crawford frank@photon.ansto.gov.au -James R. Crawford qralston@cislabs.pitt.edu -Lawrence Crowl crowl@research.cs.orst.edu -William E Davidsen davidsen@ariel.crd.ge.com -Jeff Deifik jdeifik@isi.edu -Vince DeMarco vince@whatnxt.cuc.ab.ca -Lawrence R. Dodd dodd@roebling.poly.edu -Matthew Donadio donadio@mxd120.rh.psu.edu -Andy Dougherty andy@crystal.phys.lafayette.edu -John Eaton jwe@che.utexas.edu -Paul Eggert eggert@twinsun.com -Enami enami@sys.ptg.sony.co.jp -Daniel Eriksson m91der@bellatrix.tdb.uu.se -Rik Faith faith@cs.unc.edu -Larry Fahnoe fahnoe@c1mpls.mn.org -Per Foreby perf@efd.lth.se -Noah Friedman friedman@gnu.ai.mit.edu -Bob Friesenhahn bfriesen@iphase.com -Andy Fyfe andy@scp.caltech.edu -Geoff geoff@frs.faxon.com -Kaveh R. Ghazi ghazi@staccato.rutgers.edu -Torbjorn Granlund tege@sics.se -Carl Greco cgreco@parrot.creighton.edu -Harald Hanche-Olsen hanche@ams.sunysb.edu -Ruediger Helsch ruediger@ramz.ing.tu-bs.de -Mark C. Henderson mch@sqwest.wimsey.bc.ca -Thomas Hiller hiller@fzi.de -Eiji Hirai hirai@cc.swarthmore.edu -Kjetil Torgrim Homme kjetilho@ifi.uio.no -Preston Hunt gt5708a@prism.gatech.edu -Shane C Hutchins sch@nymph.msel.unh.edu -Lester Ingber ingber@alumni.caltech.edu -Ken Ishii ishii@sni-usa.com -Per Steinar Iversen iversen@vsfys1.fi.uib.no -Denny de Jonge witaddj@dutrex.tudelft.nl -Arne H. Juul arnej@lise.unit.no -Randy Kirchhof rkk@posms.aus.tx.us -Winfried Koenig win@in.rhein-main.de -Dana Jacobsen jacobsd@solar.cor2.epa.gov -Peter Jannesen peter@ncs.nl -Sarantos Kapidakis sarantos%manteion@ics.forth.gr -Amir J. Katz amir@matis.ingr.com -Ned Kittlitz kittlitz@seagoon.sw.stratus.com -Fritz Kleemann kleemann@informatik.uni-wuerzburg.dbp.de -Tom Kloos tk@sequent.com -Carsten Koch carsten.koch@icem.de -Michael D. Lawler mdlawler@bsu-cs.bsu.edu -Hugues Leroy hugues.leroy@irisa.fr -Charles Levert charles@aramis.comm.polymtl.ca -Torbj|rn Lindh toobii@elixir.e.kth.se -David R. Linn drl@vuse.vanderbilt.edu -Jamie Lokier u90jl@ecs.oxford.ac.uk -David J. MacKenzie djm@eng.umd.edu -John R MacMillan john@chance.gts.org -Tod McQuillin mcquill@ccit05.duq.edu -Bernd Melchers melchers@chemie.fu-berlin.de -Jason Merrill jason@jarthur.claremont.edu -Dean S. Messing deanm@medulla.labs.tek.com -Luke Mewburn zak@rmit.edu.au -Jim Meyering meyering@cs.utexas.edu -Chris Moore moore@src.bae.co.uk -Helmut Muelner hmuelner@fiicmds04.tu-graz.ac.at -Greg Naber greg@squally.halcyon.com -Karl L. Noell noell@informatik.fh-wiesbaden.dbp.de -Piet van Oostrum piet@cs.ruu.nl -Rafael R. Pappalardo rafapa@obelix.cica.es -Hal Peterson hrp@pecan.cray.com -Bruno Pillard bp@chorus.fr -Franc,ois Pinard pinard@iro.umontreal.ca -Thomas Plass thomas@cogsci.ed.ac.uk -Mike Polo mikep@cfsmo.honeywell.com -Francesco Potorti pot@fly.cnuce.cnr.it -Klaus Reimann kr@cip.physik.uni-stuttgart.de -Roland B Roberts roberts@nsrl31.nsrl.rochester.edu -Kevin Rodgers kevin@rolling-stone.den.mmc.com -Kai Uwe Rommel rommel@informatik.tu-muenchen.de -Paul A Sand pas@unh.edu -Tony Sanders sanders@bsdi.com -Mike Sangrey mike@sojurn.lns.pa.us -Niimi Satoshi a01309@cfi.waseda.ac.jp -Andreas Schwab schwab@lamothe.informatik.uni-dortmund.de -Eric Schenk schenk@cs.toronto.edu -Rick Sladkey jrs@world.std.com -Daniel L Smith dls@autodesk.com -Paul Southworth pauls@css.itd.umich.edu -Rob Spencer robbie@winkle.bhpese.oz.au -Richard Stallman rms@gnu.ai.mit.edu -Carsten Steger carsten.steger@informatik.tu-muenchen.de -Ed Sznyter ews@babel.babel.com -Andrew Telford ajt@peregrin.resmel.bhp.com.au -Glenn E. Thobe thobe@getunx.info.com -Kei Thomsen kt@keihh.hanse.de -Karsten Thygesen karthy@dannug.dk -Stephane Tsacas slt@is21.isoft.fr -Stephen Tweedie sct@dcs.ed.ac.uk -Sotiris Vassilopoulos vassilopoulos@virginia.edu -Pedro A. M. Vazquez vazquez@iqm.unicamp.br -Arjan de Vet devet@win.tue.nl -Vadim V. Vlasov vvlasov@inucres.msk.su -Eduard Vopicka eduard.vopicka@vse.cs -Theo Vosse vosse@ruls41.leidenuniv.nl -Marcel Waldvogel marcel@nice.usergroup.ethz.ch -Gray Watson gray@antaire.com -Scott Weikart scott@igc.apc.org -Wietze van Winden wietze@swi.psy.uva.nl -Bill Wohler wohler@sap-ag.de -Christos Zoulas christos@deshaw.com diff --git a/gnu/usr.bin/gzip-1.0.7/TODO b/gnu/usr.bin/gzip-1.0.7/TODO deleted file mode 100644 index 8988781ca453..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/TODO +++ /dev/null @@ -1,58 +0,0 @@ -TODO file for gzip. - -Some of the planned features include: - -- Structure the sources so that the compression and decompression code - form a library usable by any program, and write both gzip and zip on - top of this library. This will be a thread safe library. In the meantime, - you can look at the sample program zread.c. - -- Make it convenient to define alternative user interfaces (in - particular for windowing environments). - -- Support in-memory compression for arbitrarily large amounts of data - (zip currently supports in-memory compression only for a single buffer.) - -- Map files in memory when possible, this is generally much faster - than read/write. (zip currently maps entire files at once, this - should be done in chunks to reduce memory usage.) - -- Add a super-fast compression method, suitable for implementing - file systems with transparent compression. One problem is that the - best candidate (lzrw1) is patented twice (Waterworth 4,701,745 - and Gibson & Graybill 5,049,881). The lzrw series of algorithms - are available by ftp in ftp.adelaide.edu.au:/pub/compression/lzrw*. - -- Add a super-tight (but slow) compression method, suitable for long - term archives. One problem is that the best versions of arithmetic - coding are patented (4,286,256 4,295,125 4,463,342 4,467,317 - 4,633,490 4,652,856 4,891,643 4,905,297 4,935,882 4,973,961 - 5,023,611 5,025,258). - - Note: I will introduce new compression methods only if they are - significantly better in either speed or compression ratio than the - existing method(s). So the total number of different methods should - reasonably not exceed 3. (The current 9 compression levels are just - tuning parameters for a single method, deflation.) - -- Add optional error correction. One problem is that the current version - of ecc cannot recover from inserted or missing bytes. It would be - nice to recover from the most common error (transfer of a binary - file in ascii mode). - -- Add a block size (-b) option to improve error recovery in case of - failure of a complete sector. Each block could be extracted - independently, but this reduces the compression ratio. - -- Use a larger window size to deal with some large redundant files that - 'compress' currently handles better than gzip. - -- implement the following options: - - -a ascii text mode; convert end-of-lines to local OS conventions - -e encrypt - -l list .z file contents - -- support .Z files in SCO 'compress -H' format. - -Send comments to Jean-loup Gailly . diff --git a/gnu/usr.bin/gzip-1.0.7/algorithm.doc b/gnu/usr.bin/gzip-1.0.7/algorithm.doc deleted file mode 100644 index 0a5dee87e09e..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/algorithm.doc +++ /dev/null @@ -1,148 +0,0 @@ -1. Algorithm - -The deflation algorithm used by zip and gzip is a variation of LZ77 -(Lempel-Ziv 1977, see reference below). It finds duplicated strings in -the input data. The second occurrence of a string is replaced by a -pointer to the previous string, in the form of a pair (distance, -length). Distances are limited to 32K bytes, and lengths are limited -to 258 bytes. When a string does not occur anywhere in the previous -32K bytes, it is emitted as a sequence of literal bytes. (In this -description, 'string' must be taken as an arbitrary sequence of bytes, -and is not restricted to printable characters.) - -Literals or match lengths are compressed with one Huffman tree, and -match distances are compressed with another tree. The trees are stored -in a compact form at the start of each block. The blocks can have any -size (except that the compressed data for one block must fit in -available memory). A block is terminated when zip determines that it -would be useful to start another block with fresh trees. (This is -somewhat similar to compress.) - -Duplicated strings are found using a hash table. All input strings of -length 3 are inserted in the hash table. A hash index is computed for -the next 3 bytes. If the hash chain for this index is not empty, all -strings in the chain are compared with the current input string, and -the longest match is selected. - -The hash chains are searched starting with the most recent strings, to -favor small distances and thus take advantage of the Huffman encoding. -The hash chains are singly linked. There are no deletions from the -hash chains, the algorithm simply discards matches that are too old. - -To avoid a worst-case situation, very long hash chains are arbitrarily -truncated at a certain length, determined by a runtime option (zip -1 -to -9). So zip does not always find the longest possible match but -generally finds a match which is long enough. - -zip also defers the selection of matches with a lazy evaluation -mechanism. After a match of length N has been found, zip searches for a -longer match at the next input byte. If a longer match is found, the -previous match is truncated to a length of one (thus producing a single -literal byte) and the longer match is emitted afterwards. Otherwise, -the original match is kept, and the next match search is attempted only -N steps later. - -The lazy match evaluation is also subject to a runtime parameter. If -the current match is long enough, zip reduces the search for a longer -match, thus speeding up the whole process. If compression ratio is more -important than speed, zip attempts a complete second search even if -the first match is already long enough. - - -2. gzip file format - -The pkzip format imposes a lot of overhead in various headers, which -are useful for an archiver but not necessary when only one file is -compressed. gzip uses a much simpler structure. Numbers are in little -endian format, and bit 0 is the least significant bit. -A gzip file is a sequence of compressed members. Each member has the -following structure: - -2 bytes magic header 0x1f, 0x8b (\037 \213) -1 byte compression method (0..7 reserved, 8 = deflate) -1 byte flags - bit 0 set: file probably ascii text - bit 1 set: continuation of multi-part gzip file - bit 2 set: extra field present - bit 3 set: original file name present - bit 4 set: file comment present - bit 5 set: file is encrypted - bit 6,7: reserved -4 bytes file modification time in Unix format -1 byte extra flags (depend on compression method) -1 byte operating system on which compression took place - -2 bytes optional part number (second part=1) -2 bytes optional extra field length -? bytes optional extra field -? bytes optional original file name, zero terminated -? bytes optional file comment, zero terminated -12 bytes optional encryption header -? bytes compressed data -4 bytes crc32 -4 bytes uncompressed input size modulo 2^32 - -The format was designed to allow single pass compression without any -backwards seek, and without a priori knowledge of the uncompressed -input size or the available size on the output media. If input does -not come from a regular disk file, the file modification time is set -to the time at which compression started. - -The time stamp is useful mainly when one gzip file is transferred over -a network. In this case it would not help to keep ownership -attributes. In the local case, the ownership attributes are preserved -by gzip when compressing/decompressing the file. A time stamp of zero -is ignored. - -Bit 0 in the flags is only an optional indication, which can be set by -a small lookahead in the input data. In case of doubt, the flag is -cleared indicating binary data. For systems which have different -file formats for ascii text and binary data, the decompressor can -use the flag to choose the appropriate format. - -It must be possible to detect the end of the compressed data with any -compression format, regardless of the actual size of the compressed -data. If the compressed data cannot fit in one file (in particular for -diskettes), each part starts with a header as described above, but -only the last part has the crc32 and uncompressed size. A decompressor -may prompt for additional data for multipart compressed files. It is -desirable but not mandatory that multiple parts be extractable -independently so that partial data can be recovered if one of the -parts is damaged. This is possible only if no compression state is -kept from one part to the other. The compression-type dependent flags -can indicate this. - -If the file being compressed is on a file system with case insensitive -names, the original name field must be forced to lower case. There is -no original file name if the data was compressed from standard input. - -On operating systems which support multiple extensions, and on -original files without extension, the extension ".z" is added to the -original file name (foo.c => foo.c.z). Otherwise the string "z" (or -"-z" for VMS) is added to the original extension (foo.c => foo.cz or -foo.c-z). The original name or extension is truncated if necessary, -but in this case the original name is always saved in the compressed -file (foo.doc => foo.doz). - -Compression is always performed, even if the compressed file is -slightly larger than the original. The worst case expansion is -a few bytes for the gzip file header, plus 5 bytes every 32K block, -or an expansion ratio of 0.015% for large files. - -The encryption is that of zip 1.9. For the encryption check, the -last byte of the decoded encryption header must be zero. The time -stamp of an encrypted file might be set to zero to avoid giving a clue -about the construction of the random header. - -Jean-loup Gailly -jloup@chorus.fr - -References: - -[LZ77] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data -Compression", IEEE Transactions on Information Theory", Vol. 23, No. 3, -pp. 337-343. - -APPNOTE.TXT documentation file in PKZIP 1.93a. It is available by -ftp in ux1.cso.uiuc.edu:/pc/exec-pc/pkz193a.exe [128.174.5.59] -Use "unzip pkz193a.exe APPNOTE.TXT" to extract. diff --git a/gnu/usr.bin/gzip-1.0.7/alloca.c b/gnu/usr.bin/gzip-1.0.7/alloca.c deleted file mode 100644 index 729f74414a0d..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/alloca.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - alloca -- (mostly) portable public-domain implementation -- D A Gwyn - - last edit: 86/05/30 rms - include config.h, since on VMS it renames some symbols. - Use xmalloc instead of malloc. - - This implementation of the PWB library alloca() function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - - It should work under any C implementation that uses an - actual procedure stack (as opposed to a linked list of - frames). There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca()-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. -*/ -#ifndef lint -static char SCCSid[] = "@(#)alloca.c 1.1"; /* for the "what" utility */ -#endif - -#ifdef emacs -#include "config.h" -#ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -#ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ - -#if !defined(alloca) && !defined(__GNUC__) -/* If compiling with GCC, this file's not needed. */ - -#ifdef __STDC__ -typedef void *pointer; /* generic pointer type */ -#else -typedef char *pointer; /* generic pointer type */ -#endif - -#define NULL 0 /* null pointer constant */ - -extern void free(); -extern pointer xmalloc(); - -/* - Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown -*/ - -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* direction unknown */ -#endif - -#if STACK_DIRECTION != 0 - -#define STACK_DIR STACK_DIRECTION /* known at compile-time */ - -#else /* STACK_DIRECTION == 0; need run-time code */ - -static int stack_dir; /* 1 or -1 once known */ -#define STACK_DIR stack_dir - -static void -find_stack_direction (/* void */) -{ - static char *addr = NULL; /* address of first - `dummy', once known */ - auto char dummy; /* to get stack address */ - - if (addr == NULL) - { /* initial entry */ - addr = &dummy; - - find_stack_direction (); /* recurse once */ - } - else /* second entry */ - if (&dummy > addr) - stack_dir = 1; /* stack grew upward */ - else - stack_dir = -1; /* stack grew downward */ -} - -#endif /* STACK_DIRECTION == 0 */ - -/* - An "alloca header" is used to: - (a) chain together all alloca()ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc() - alignment chunk size. The following default should work okay. -*/ - -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* to force sizeof(header) */ - struct - { - union hdr *next; /* for chaining headers */ - char *deep; /* for stack depth measure */ - } h; -} header; - -/* - alloca( size ) returns a pointer to at least `size' bytes of - storage which will be automatically reclaimed upon exit from - the procedure that called alloca(). Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. -*/ - -static header *last_alloca_header = NULL; /* -> last alloca header */ - -pointer -alloca (size) /* returns pointer to storage */ - unsigned size; /* # bytes to allocate */ -{ - auto char probe; /* probes stack depth: */ - register char *depth = &probe; - -#if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* unknown growth direction */ - find_stack_direction (); -#endif - - /* Reclaim garbage, defined as all alloca()ed storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* traverses linked list */ - - for (hp = last_alloca_header; hp != NULL;) - if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; - - free ((pointer) hp); /* collect garbage */ - - hp = np; /* -> next header */ - } - else - break; /* rest are not deeper */ - - last_alloca_header = hp; /* -> last valid storage */ - } - - if (size == 0) - return NULL; /* no allocation required */ - - /* Allocate combined header + user data storage. */ - - { - register pointer new = xmalloc (sizeof (header) + size); - /* address of header */ - - ((header *)new)->h.next = last_alloca_header; - ((header *)new)->h.deep = depth; - - last_alloca_header = (header *)new; - - /* User storage begins just after header. */ - - return (pointer)((char *)new + sizeof(header)); - } -} - -#endif /* no alloca */ diff --git a/gnu/usr.bin/gzip-1.0.7/bits.c b/gnu/usr.bin/gzip-1.0.7/bits.c deleted file mode 100644 index 4e8219bf478a..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/bits.c +++ /dev/null @@ -1,205 +0,0 @@ -/* bits.c -- output variable-length bit strings - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - - -/* - * PURPOSE - * - * Output variable-length bit strings. Compression can be done - * to a file or to memory. (The latter is not supported in this version.) - * - * DISCUSSION - * - * The PKZIP "deflate" file format interprets compressed file data - * as a sequence of bits. Multi-bit strings in the file may cross - * byte boundaries without restriction. - * - * The first bit of each byte is the low-order bit. - * - * The routines in this file allow a variable-length bit value to - * be output right-to-left (useful for literal values). For - * left-to-right output (useful for code strings from the tree routines), - * the bits must have been reversed first with bi_reverse(). - * - * For in-memory compression, the compressed bit stream goes directly - * into the requested output buffer. The input data is read in blocks - * by the mem_read() function. The buffer is limited to 64K on 16 bit - * machines. - * - * INTERFACE - * - * void bi_init (FILE *zipfile) - * Initialize the bit string routines. - * - * void send_bits (int value, int length) - * Write out a bit string, taking the source bits right to - * left. - * - * int bi_reverse (int value, int length) - * Reverse the bits of a bit string, taking the source bits left to - * right and emitting them right to left. - * - * void bi_windup (void) - * Write out any remaining bits in an incomplete byte. - * - * void copy_block(char *buf, unsigned len, int header) - * Copy a stored block to the zip file, storing first the length and - * its one's complement if requested. - * - */ - -#include "tailor.h" -#include "gzip.h" -#include "crypt.h" - -#ifdef DEBUG -# include -#endif - -#ifndef lint -static char rcsid[] = "$Id: bits.c,v 1.1 1993/04/10 15:55:33 cgd Exp $"; -#endif - -/* =========================================================================== - * Local data used by the "bit string" routines. - */ - -local file_t zfile; /* output gzip file */ - -local unsigned short bi_buf; -/* Output buffer. bits are inserted starting at the bottom (least significant - * bits). - */ - -#define Buf_size (8 * 2*sizeof(char)) -/* Number of bits used within bi_buf. (bi_buf might be implemented on - * more than 16 bits on some systems.) - */ - -local int bi_valid; -/* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - -int (*read_buf) OF((char *buf, unsigned size)) = file_read; -/* Current input function. Set to mem_read for in-memory compression */ - -#ifdef DEBUG - ulg bits_sent; /* bit length of the compressed data */ -#endif - -/* =========================================================================== - * Initialize the bit string routines. - */ -void bi_init (zipfile) - file_t zipfile; /* output zip file, NO_FILE for in-memory compression */ -{ - zfile = zipfile; - bi_buf = 0; - bi_valid = 0; -#ifdef DEBUG - bits_sent = 0L; -#endif - - /* Set the defaults for file compression. They are set by memcompress - * for in-memory compression. - */ - if (zfile != NO_FILE) { - read_buf = file_read; - } -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -void send_bits(value, length) - int value; /* value to send */ - int length; /* number of bits */ -{ -#ifdef DEBUG - Tracev((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - bits_sent += (ulg)length; -#endif - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (bi_valid > (int)Buf_size - length) { - bi_buf |= (value << bi_valid); - put_short(bi_buf); - bi_buf = (ush)value >> (Buf_size - bi_valid); - bi_valid += length - Buf_size; - } else { - bi_buf |= value << bi_valid; - bi_valid += length; - } -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Write out any remaining bits in an incomplete byte. - */ -void bi_windup() -{ - if (bi_valid > 8) { - put_short(bi_buf); - } else if (bi_valid > 0) { - put_byte(bi_buf); - } - bi_buf = 0; - bi_valid = 0; -#ifdef DEBUG - bits_sent = (bits_sent+7) & ~7; -#endif -} - -/* =========================================================================== - * Copy a stored block to the zip file, storing first the length and its - * one's complement if requested. - */ -void copy_block(buf, len, header) - char *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(); /* align on byte boundary */ - - if (header) { - put_short((ush)len); - put_short((ush)~len); -#ifdef DEBUG - bits_sent += 2*16; -#endif - } -#ifdef DEBUG - bits_sent += (ulg)len<<3; -#endif - while (len--) { -#ifdef CRYPT - int t; - if (key) zencode(*buf, t); -#endif - put_byte(*buf++); - } -} diff --git a/gnu/usr.bin/gzip-1.0.7/configure b/gnu/usr.bin/gzip-1.0.7/configure deleted file mode 100644 index a7b3226fa0b1..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/configure +++ /dev/null @@ -1,674 +0,0 @@ -#!/bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf. -# Copyright (C) 1991, 1992, 1993 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: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [--no-create] -# [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE] [TARGET] -# Ignores all args except --srcdir, --prefix, --exec-prefix, --no-create, and -# --with-PACKAGE unless this script has special code to handle it. - - -for arg -do - # Handle --exec-prefix with a space before the argument. - if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix= - # Handle --host with a space before the argument. - elif test x$next_host = xyes; then next_host= - # Handle --prefix with a space before the argument. - elif test x$next_prefix = xyes; then prefix=$arg; next_prefix= - # Handle --srcdir with a space before the argument. - elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir= - else - case $arg in - # For backward compatibility, also recognize exact --exec_prefix. - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*) - exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;; - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e) - next_exec_prefix=yes ;; - - -gas | --gas | --ga | --g) ;; - - -host=* | --host=* | --hos=* | --ho=* | --h=*) ;; - -host | --host | --hos | --ho | --h) - next_host=yes ;; - - -nfp | --nfp | --nf) ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no) - no_create=1 ;; - - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;; - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - next_prefix=yes ;; - - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*) - srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;; - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s) - next_srcdir=yes ;; - - -with-* | --with-*) - package=`echo $arg|sed 's/-*with-//'` - # Delete all the valid chars; see if any are left. - if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then - echo "configure: $package: invalid package name" >&2; exit 1 - fi - eval "with_`echo $package|sed s/-/_/g`=1" ;; - - *) ;; - esac - fi -done - -trap 'rm -f conftest* core; exit 1' 1 3 15 - -rm -f conftest* -compile='${CC-cc} $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1' - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -unique_file=gzip.c - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - srcdirdefaulted=yes - # Try the directory containing this script, then `..'. - prog=$0 - confdir=`echo $prog|sed 's%/[^/][^/]*$%%'` - test "X$confdir" = "X$prog" && confdir=. - srcdir=$confdir - if test ! -r $srcdir/$unique_file; then - srcdir=.. - fi -fi -if test ! -r $srcdir/$unique_file; then - if test x$srcdirdefaulted = xyes; then - echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2 - else - echo "configure: Can not find sources in \`${srcdir}'." 1>&2 - fi - exit 1 -fi -# Preserve a srcdir of `.' to avoid automounter screwups with pwd. -# But we can't avoid them for `..', to make subdirectories work. -case $srcdir in - .|/*|~*) ;; - *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute. -esac - -if test -z "$CC"; then - echo checking for gcc - saveifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - test -z "$dir" && dir=. - if test -f $dir/gcc; then - CC="gcc" - break - fi - done - IFS="$saveifs" -fi -test -z "$CC" && CC="cc" - -# Find out if we are using GNU C, under whatever name. -cat > conftest.c < conftest.out 2>&1 -if egrep yes conftest.out >/dev/null 2>&1; then - GCC=1 # For later tests. - CC="$CC -O" -fi -rm -f conftest* - -echo checking for underline in external names -test -z "$CPP" -a -f /lib/cpp && CPP=/lib/cpp -test -z "$CPP" && CPP="$CC -E" -cat > conftest.c < /dev/null 2>&1 -if nm conftest.o | grep _foo > /dev/null 2>&1 ; then - : -else - CPP="${CPP} -DNO_UNDERLINE" -fi -echo checking for assembler -rm -f _match.o conftest.co -$CPP $srcdir/match.S > _match.s -if grep error < _match.s > /dev/null; then - OBJA="" -elif $CC -c _match.s >/dev/null 2>&1 && test -f _match.o; then - DEFS="${DEFS} -DASMV" - OBJA=match.o -fi -rm -f _match.s _match.o -# Make sure to not get the incompatible SysV /etc/install and -# /usr/sbin/install, which might be in PATH before a BSD-like install, -# or the SunOS /usr/etc/install directory, or the AIX /bin/install, -# or the AFS install, which mishandles nonexistent args. (Sigh.) -if test -z "$INSTALL"; then - echo checking for install - saveifs="$IFS"; IFS="${IFS}:" - for dir in $PATH; do - test -z "$dir" && dir=. - case $dir in - /etc|/usr/sbin|/usr/etc|/usr/afsws/bin) ;; - *) - if test -f $dir/install; then - if grep dspmsg $dir/install >/dev/null 2>&1; then - : # AIX - else - INSTALL="$dir/install -c" - INSTALL_PROGRAM='$(INSTALL)' - INSTALL_DATA='$(INSTALL) -m 644' - break - fi - fi - ;; - esac - done - IFS="$saveifs" -fi -INSTALL=${INSTALL-cp} -INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'} -INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'} - -echo checking for AIX -echo checking how to run the C preprocessor -if test -z "$CPP"; then - CPP='${CC-cc} -E' - cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - : -else - CPP=/lib/cpp -fi -rm -f conftest* -fi - -cat > conftest.c < conftest.out 2>&1" -if egrep "yes" conftest.out >/dev/null 2>&1; then - DEFS="$DEFS -D_ALL_SOURCE=1" -fi -rm -f conftest* - - -echo checking for minix/config.h -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - MINIX=1 -fi -rm -f conftest* - -# The Minix shell can't assign to the same variable on the same line! -if test -n "$MINIX"; then - DEFS="$DEFS -D_POSIX_SOURCE=1" - DEFS="$DEFS -D_POSIX_1_SOURCE=2" - DEFS="$DEFS -D_MINIX=1" -fi - -echo checking for POSIXized ISC -if test -d /etc/conf/kconfig.d && - grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 -then - ISC=1 # If later tests want to check for ISC. - DEFS="$DEFS -D_POSIX_SOURCE=1" - if test -n "$GCC"; then - CC="$CC -posix" - else - CC="$CC -Xp" - fi -fi - -echo checking for DYNIX/ptx libseq -cat > conftest.c < conftest.out 2>&1" -if egrep "yes" conftest.out >/dev/null 2>&1; then - SEQUENT=1 -fi -rm -f conftest* - -test -n "$SEQUENT" && test -f /usr/lib/libseq.a && - LIBS="$LIBS -lseq" - -echo checking for ANSI C header files -cat > conftest.c < -#include -#include -#include -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - # SunOS string.h does not declare mem*, contrary to ANSI. -echo '#include ' > conftest.c -eval "$CPP $DEFS conftest.c > conftest.out 2>&1" -if egrep "memchr" conftest.out >/dev/null 2>&1; then - # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -cat > conftest.c < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e,f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -eval $compile -if test -s conftest && (./conftest; exit) 2>/dev/null; then - DEFS="$DEFS -DSTDC_HEADERS=1" -fi -rm -f conftest* -fi -rm -f conftest* - -fi -rm -f conftest* - -echo checking for string.h -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - : -else - DEFS="$DEFS -DNO_STRING_H=1" -fi -rm -f conftest* - -echo checking for stdlib.h -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - : -else - DEFS="$DEFS -DNO_STDLIB_H=1" -fi -rm -f conftest* - -echo checking for memory.h -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - : -else - DEFS="$DEFS -DNO_MEMORY_H=1" -fi -rm -f conftest* - -echo checking for fcntl.h -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - : -else - DEFS="$DEFS -DNO_FCNTL_H=1" -fi -rm -f conftest* - -for hdr in unistd.h -do -trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'` -echo checking for ${hdr} -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - DEFS="$DEFS -D${trhdr}=1" -fi -rm -f conftest* -done - -utime=0 -echo checking for utime.h -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - utime=1 -else - DEFS="$DEFS -DNO_UTIME_H=1" -fi -rm -f conftest* - -if test $utime -eq 0; then - for hdr in sys/utime.h -do -trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'` -echo checking for ${hdr} -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - DEFS="$DEFS -D${trhdr}=1" -fi -rm -f conftest* -done - -fi -echo checking for directory library header -echo checking for dirent.h -cat > conftest.c < -#include -int main() { return 0; } -int t() { DIR *x=0; return x-x; } -EOF -if eval $compile; then - DEFS="$DEFS -DDIRENT=1" dirheader=dirent.h -fi -rm -f conftest* - -if test -z "$dirheader"; then -echo checking for sys/ndir.h -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - DEFS="$DEFS -DSYSNDIR=1" dirheader=sys/ndir.h -fi -rm -f conftest* - -fi -if test -z "$dirheader"; then -echo checking for sys/dir.h -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - DEFS="$DEFS -DSYSDIR=1" dirheader=sys/dir.h -fi -rm -f conftest* - -fi -if test -z "$dirheader"; then -echo checking for ndir.h -cat > conftest.c < -EOF -err=`eval "($CPP $DEFS conftest.c >/dev/null) 2>&1"` -if test -z "$err"; then - DEFS="$DEFS -DNDIR=1" dirheader=ndir.h -fi -rm -f conftest* - -fi - -echo checking for closedir return value -cat > conftest.c < -#include <$dirheader> -int closedir(); main() { exit(0); } -EOF -eval $compile -if test -s conftest && (./conftest; exit) 2>/dev/null; then - : -else - DEFS="$DEFS -DVOID_CLOSEDIR=1" -fi -rm -f conftest* - -echo checking for Xenix -cat > conftest.c < conftest.out 2>&1" -if egrep "yes" conftest.out >/dev/null 2>&1; then - XENIX=1 -fi -rm -f conftest* - -if test -n "$XENIX"; then - DEFS="$DEFS -DVOID_CLOSEDIR=1" - LIBS="$LIBS -lx" - case "$DEFS" in - *SYSNDIR*) ;; - *) LIBS="-ldir $LIBS" ;; # Make sure -ldir precedes any -lx. - esac -fi - -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -echo checking for working alloca.h -cat > conftest.c < -int main() { return 0; } -int t() { char *p = alloca(2 * sizeof(int)); } -EOF -if eval $compile; then - DEFS="$DEFS -DHAVE_ALLOCA_H=1" -fi -rm -f conftest* - -decl="#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#if HAVE_ALLOCA_H -#include -#else -#ifdef _AIX - #pragma alloca -#else -char *alloca (); -#endif -#endif -#endif -" -echo checking for alloca -cat > conftest.c < conftest.c < -#include -#ifdef signal -#undef signal -#endif -extern int (*signal ()) (); -int main() { return 0; } -int t() { int i; } -EOF -if eval $compile; then - DEFS="$DEFS -DRETSIGTYPE=int" -fi -rm -f conftest* - - -echo "checking for #! kernel hack" -cat <<'__EOF__' > conftest.csh -#!/bin/csh -f -setenv SHELL /bin/csh -# Avoid tcsh bug 'Bad Hertz Value': -setenv HZ 60 -# Make sure foo doesn't get exported into the environment -# Astoundingly, some versions of csh don't have unsetenv. -if (${?foo}) unsetenv foo >& /dev/null -if (${?foo}) unset foo -set output="`./conftest.sh`" -if ( "$output" == "foo=bar" ) then - exit 0 -endif -exit 1 -__EOF__ -cat <<'__EOF__' > conftest.sh -#!/bin/sh -# If this is really run with sh, then 1st positional arg will be "foo=bar". -# If this script was executed by csh, then a shell variable "foo" will have -# the value "var". -set foo=bar -echo "$*" -__EOF__ -chmod 777 conftest.csh conftest.sh -(csh -f ./conftest.csh) 2> /dev/null -if test $? = 0 ; then - :; SEDCMD="1d" -else - :; SEDCMD="" -fi -rm -f conftest.csh conftest.sh - -if test -z "$prefix" -then - echo checking for gzip to derive installation directory prefix - saveifs="$IFS"; IFS="$IFS:" - for dir in $PATH; do - test -z "$dir" && dir=. - if test $dir != . && test -f $dir/gzip; then - # Not all systems have dirname. - prefix=`echo $dir|sed 's%/[^/][^/]*$%%'` - break - fi - done - IFS="$saveifs" -fi - -if test -n "$prefix"; then - test -z "$exec_prefix" && exec_prefix='${prefix}' - prsub="s%^prefix\\([ ]*\\)=\\([ ]*\\).*$%prefix\\1=\\2$prefix%" -fi -if test -n "$exec_prefix"; then - prsub="$prsub -s%^exec_prefix\\([ ]*\\)=\\([ ]*\\).*$%\ -exec_prefix\\1=\\2$exec_prefix%" -fi - -trap 'rm -f config.status; exit 1' 1 3 15 -echo creating config.status -rm -f config.status -cat > config.status </dev/null | sed 1q`: -# -# $0 $* - -for arg -do - case "\$arg" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - exec /bin/sh $0 $* ;; - *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;; - esac -done - -trap 'rm -f Makefile; exit 1' 1 3 15 -CC='$CC' -INSTALL='$INSTALL' -INSTALL_PROGRAM='$INSTALL_PROGRAM' -INSTALL_DATA='$INSTALL_DATA' -CPP='$CPP' -ALLOCA='$ALLOCA' -OBJA='$OBJA' -SEDCMD='$SEDCMD' -LIBS='$LIBS' -srcdir='$srcdir' -DEFS='$DEFS' -prefix='$prefix' -exec_prefix='$exec_prefix' -prsub='$prsub' -EOF -cat >> config.status <<\EOF - -top_srcdir=$srcdir -for file in .. Makefile; do if [ "x$file" != "x.." ]; then - srcdir=$top_srcdir - # Remove last slash and all that follows it. Not all systems have dirname. - dir=`echo $file|sed 's%/[^/][^/]*$%%'` - if test "$dir" != "$file"; then - test "$top_srcdir" != . && srcdir=$top_srcdir/$dir - test ! -d $dir && mkdir $dir - fi - echo creating $file - rm -f $file - echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file - sed -e " -$prsub -s%@CC@%$CC%g -s%@INSTALL@%$INSTALL%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@CPP@%$CPP%g -s%@ALLOCA@%$ALLOCA%g -s%@OBJA@%$OBJA%g -s%@SEDCMD@%$SEDCMD%g -s%@LIBS@%$LIBS%g -s%@srcdir@%$srcdir%g -s%@DEFS@%$DEFS% -" $top_srcdir/${file}.in >> $file -fi; done - -EOF -chmod +x config.status -test -n "$no_create" || ./config.status - diff --git a/gnu/usr.bin/gzip-1.0.7/configure.in b/gnu/usr.bin/gzip-1.0.7/configure.in deleted file mode 100644 index f6b925bb4291..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/configure.in +++ /dev/null @@ -1,116 +0,0 @@ -dnl Process this file with autoconf to produce a configure script for gzip -dnl -dnl Written by friedman@prep.ai.mit.edu 28-Dec-92 -dnl Last modified 26-Jan-93 -dnl "Usage: ACL_HAVE_SHELL_HACK(ACTION_IF_EXISTS [, ACTION_IF_NOT_EXISTS])" -dnl -define(ACL_HAVE_SHELL_HACK, [dnl -echo "checking for #! kernel hack" -cat <<'__EOF__' > conftest.csh -#!/bin/csh -f -setenv SHELL /bin/csh -# Avoid tcsh bug 'Bad Hertz Value': -setenv HZ 60 -# Make sure foo doesn't get exported into the environment -# Astoundingly, some versions of csh don't have unsetenv. -if (${?foo}) unsetenv foo >& /dev/null -if (${?foo}) unset foo -set output="`./conftest.sh`" -if ( "$[]output" == "foo=bar" ) then - exit 0 -endif -exit 1 -__EOF__ -cat <<'__EOF__' > conftest.sh -#!/bin/sh -# If this is really run with sh, then 1st positional arg will be "foo=bar". -# If this script was executed by csh, then a shell variable "foo" will have -# the value "var". -set foo=bar -echo "$[]*" -__EOF__ -chmod 777 conftest.csh conftest.sh -(csh -f ./conftest.csh) 2> /dev/null -if test $? = 0 ; then - :; $1 -else - :; $2 -fi -rm -f conftest.csh conftest.sh -])dnl -dnl -dnl Same as AC_RETSIGTYPE, but use a void default. -dnl -define(AC_RETSIGTYP, -[AC_COMPILE_CHECK([return type of signal handlers], -[#include -#include -#ifdef signal -#undef signal -#endif -extern int (*signal ()) ();], -[int i;], -[AC_DEFINE(RETSIGTYPE, int)], -[], -)] -)dnl -dnl -dnl -dnl End of local macros -dnl -AC_INIT(gzip.c) -AC_PROG_CC -dnl AC_PROG_CPP -dnl -dnl Try to assemble match.S with and without leading underline. -dnl cc -E produces incorrect asm files on SVR4, we must use /lib/cpp. -dnl Also, "gcc -E match.s" ignores -E, so we must use match.S. -echo checking for underline in external names -test -z "$CPP" -a -f /lib/cpp && CPP=/lib/cpp -test -z "$CPP" && CPP="$CC -E" -cat > conftest.c < /dev/null 2>&1 -if nm conftest.o | grep _foo > /dev/null 2>&1 ; then - : -else - CPP="${CPP} -DNO_UNDERLINE" -fi -echo checking for assembler -rm -f _match.o conftest.[co] -$CPP $srcdir/match.S > _match.s -if grep error < _match.s > /dev/null; then - OBJA="" -elif $CC -c _match.s >/dev/null 2>&1 && test -f _match.o; then - DEFS="${DEFS} -DASMV" - OBJA=match.o -fi -rm -f _match.s _match.o -dnl -AC_PROG_INSTALL -AC_AIX -AC_MINIX -AC_ISC_POSIX -AC_DYNIX_SEQ -AC_STDC_HEADERS -dnl if STDC_HEADERS can't be defined, look for special files: -AC_HEADER_CHECK(string.h, ,AC_DEFINE(NO_STRING_H)) -AC_HEADER_CHECK(stdlib.h, ,AC_DEFINE(NO_STDLIB_H)) -AC_HEADER_CHECK(memory.h, ,AC_DEFINE(NO_MEMORY_H)) -AC_HEADER_CHECK(fcntl.h, ,AC_DEFINE(NO_FCNTL_H)) -AC_HAVE_HEADERS(unistd.h) -utime=0 -AC_HEADER_CHECK(utime.h, utime=1 ,AC_DEFINE(NO_UTIME_H)) -if test $utime -eq 0; then - AC_HAVE_HEADERS(sys/utime.h) -fi -AC_DIR_HEADER -AC_XENIX_DIR -AC_ALLOCA -AC_RETSIGTYP -ACL_HAVE_SHELL_HACK([SEDCMD="1d"], [SEDCMD=""]) -AC_PREFIX(gzip) -AC_SUBST(OBJA)dnl -AC_SUBST(SEDCMD)dnl -AC_OUTPUT(Makefile) diff --git a/gnu/usr.bin/gzip-1.0.7/crypt.c b/gnu/usr.bin/gzip-1.0.7/crypt.c deleted file mode 100644 index 269cfd2b6dbb..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/crypt.c +++ /dev/null @@ -1,6 +0,0 @@ -/* crypt.c (dummy version) -- do not perform encrytion - * Hardly worth copyrighting :-) - */ -#ifndef lint -static char rcsid[] = "$Id: crypt.c,v 1.1 1993/04/10 15:55:38 cgd Exp $"; -#endif diff --git a/gnu/usr.bin/gzip-1.0.7/crypt.h b/gnu/usr.bin/gzip-1.0.7/crypt.h deleted file mode 100644 index f4aac50c3b10..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/crypt.h +++ /dev/null @@ -1,12 +0,0 @@ -/* crypt.h (dummy version) -- do not perform encrytion - * Hardly worth copyrighting :-) - */ - -#ifdef CRYPT -# undef CRYPT /* dummy version */ -#endif - -#define RAND_HEAD_LEN 12 /* length of encryption random header */ - -#define zencode -#define zdecode diff --git a/gnu/usr.bin/gzip-1.0.7/deflate.c b/gnu/usr.bin/gzip-1.0.7/deflate.c deleted file mode 100644 index cf03f08542f2..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/deflate.c +++ /dev/null @@ -1,733 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -/* - * PURPOSE - * - * Identify new text as repetitions of old text within a fixed- - * length sliding window trailing behind the new text. - * - * DISCUSSION - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many info-zippers for bug reports and testing. - * - * REFERENCES - * - * APPNOTE.TXT documentation file in PKZIP 1.93a distribution. - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - * INTERFACE - * - * void lm_init (int pack_level, ush *flags) - * Initialize the "longest match" routines for a new file - * - * ulg deflate (void) - * Processes a new input file and return its compressed length. Sets - * the compressed length, crc, deflate flags and internal file - * attributes. - */ - -#include "tailor.h" -#include "gzip.h" -#include "lzw.h" /* just for consistency checking */ - -#include - -#ifndef lint -static char rcsid[] = "$Id: deflate.c,v 1.1 1993/04/10 15:55:42 cgd Exp $"; -#endif - -/* =========================================================================== - * Configuration parameters - */ - -/* Compile with MEDIUM_MEM to reduce the memory requirements or - * with SMALL_MEM to use as little memory as possible. Use BIG_MEM if the - * entire input file can be held in memory (not possible on 16 bit systems). - * Warning: defining these symbols affects HASH_BITS (see below) and thus - * affects the compression ratio. The compressed output - * is still correct, and might even be smaller in some cases. - */ - -#ifdef SMALL_MEM -# define HASH_BITS 13 /* Number of bits used to hash strings */ -#endif -#ifdef MEDIUM_MEM -# define HASH_BITS 14 -#endif -#ifndef HASH_BITS -# define HASH_BITS 15 - /* For portability to 16 bit machines, do not use values above 15. */ -#endif - -/* To save space (see unlzw.c), we overlay prev+head with tab_prefix and - * window with tab_suffix. Check that we can do this: - */ -#if WSIZE<<1 > 1< BITS-1 - error: cannot overlay head with tab_prefix1 -#endif - -#define HASH_SIZE (unsigned)(1<= HASH_BITS - */ - -unsigned int near prev_length; -/* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - unsigned near strstart; /* start of string to insert */ - unsigned near match_start; /* start of matching string */ -local int eofile; /* flag set at end of input file */ -local unsigned lookahead; /* number of valid bytes ahead in window */ - -unsigned near max_chain_length; -/* To speed up deflation, hash chains are never searched beyond this length. - * A higher limit improves compression ratio but degrades the speed. - */ - -local unsigned int max_lazy_match; -/* Attempt to find a better match only when the current match is strictly - * smaller than this value. - */ - -int near good_match; -/* Use a faster search when the previous match is longer than this */ - - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ - -typedef struct config { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; -} config; - -#ifdef FULL_SEARCH -# define nice_match MAX_MATCH -#else - int near nice_match; /* Stop searching when current match exceeds this */ -#endif - -local config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0}, /* store only */ -/* 1 */ {4, 4, 16, 16}, /* maximum speed */ -/* 2 */ {6, 8, 16, 16}, -/* 3 */ {8, 16, 32, 32}, -/* 4 */ {8, 16, 64, 64}, -/* 5 */ {8, 16, 128, 128}, -/* 6 */ {8, 32, 128, 256}, -/* 7 */ {8, 64, 128, 512}, -/* 8 */ {32, 128, 258, 1024}, -/* 9 */ {32, 258, 258, 4096}}; /* maximum compression */ - -/* Note: the current code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * but these restrictions can easily be removed at a small cost. - */ - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -/* =========================================================================== - * Prototypes for local functions. - */ -local void fill_window OF((void)); - int longest_match OF((IPos cur_match)); -#ifdef ASMV - void match_init OF((void)); /* asm code initialization */ -#endif - -#ifdef DEBUG -local void check_match OF((IPos start, IPos match, int length)); -#endif - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. - */ -#define UPDATE_HASH(h,c) (h = (((h)< 9) error("bad pack level"); - - /* Initialize the hash table. */ -#if defined(MAXSEG_64K) && HASH_BITS == 15 - for (j = 0; j < HASH_SIZE; j++) head[j] = NIL; -#else - memzero(head, HASH_SIZE*sizeof(*head)); -#endif - /* prev will be initialized on the fly */ - - /* Set the default configuration parameters: - */ - max_lazy_match = configuration_table[pack_level].max_lazy; - good_match = configuration_table[pack_level].good_length; -#ifndef FULL_SEARCH - nice_match = configuration_table[pack_level].nice_length; -#endif - max_chain_length = configuration_table[pack_level].max_chain; - if (pack_level == 1) { - *flags |= FAST; - } else if (pack_level == 9) { - *flags |= SLOW; - } - /* ??? reduce max_chain_length for binary files */ - - strstart = 0; - block_start = 0L; -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif - -#ifdef MAXSEG_64K - /* Can't read a 64K block */ - lookahead = read_buf((char*)window, (unsigned)WSIZE); -#else - lookahead = read_buf((char*)window, 2*WSIZE); -#endif - if (lookahead == 0 || lookahead == (unsigned)EOF) { - eofile = 1, lookahead = 0; - return; - } - eofile = 0; - /* Make sure that we always have enough lookahead. This is important - * if input comes from a device such as a tty. - */ - while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); - - ins_h = 0; - for (j=0; j= 1 - */ -#ifndef ASMV -/* For MSDOS, OS/2 and 386 Unix, an optimized version is in match.asm or - * match.s. The code is functionally equivalent, so you can use the C version - * if desired. - */ -int longest_match(cur_match) - IPos cur_match; /* current match */ -{ - unsigned chain_length = max_chain_length; /* max hash chain length */ - register uch *scan = window + strstart; /* current string */ - register uch *match; /* matched string */ - register int len; /* length of current match */ - int best_len = prev_length; /* best match length so far */ - IPos limit = strstart > (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - -/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ -#if HASH_BITS < 8 || MAX_MATCH != 258 - error: Code too clever -#endif - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register uch *strend = window + strstart + MAX_MATCH - 1; - register ush scan_start = *(ush*)scan; - register ush scan_end = *(ush*)(scan+best_len-1); -#else - register uch *strend = window + strstart + MAX_MATCH; - register uch scan_end1 = scan[best_len-1]; - register uch scan_end = scan[best_len]; -#endif - - /* Do not waste too much time if we already have a good match: */ - if (prev_length >= good_match) { - chain_length >>= 2; - } - Assert(strstart <= window_size-MIN_LOOKAHEAD, "insufficient lookahead"); - - do { - Assert(cur_match < strstart, "no future"); - match = window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2: - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ush*)(match+best_len-1) != scan_end || - *(ush*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - scan++, match++; - do { - } while (*(ush*)(scan+=2) == *(ush*)(match+=2) && - *(ush*)(scan+=2) == *(ush*)(match+=2) && - *(ush*)(scan+=2) == *(ush*)(match+=2) && - *(ush*)(scan+=2) == *(ush*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= window+(unsigned)(window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ush*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & WMASK]) > limit - && --chain_length != 0); - - return best_len; -} -#endif /* ASMV */ - -#ifdef DEBUG -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(start, match, length) - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (memcmp((char*)window + match, - (char*)window + start, length) != EQUAL) { - fprintf(stderr, - " start %d, match %d, length %d\n", - start, match, length); - error("invalid match"); - } - if (verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(start, match, length) -#endif - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead, and sets eofile if end of input file. - * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0 - * OUT assertions: at least one byte has been read, or eofile is set; - * file reads are performed for at least two bytes (required for the - * translate_eol option). - */ -local void fill_window() -{ - register unsigned n, m; - unsigned more = (unsigned)(window_size - (ulg)lookahead - (ulg)strstart); - /* Amount of free space at the end of the window. */ - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (more == (unsigned)EOF) { - /* Very unlikely, but possible on 16 bit machine if strstart == 0 - * and lookahead == 1 (input done one byte at time) - */ - more--; - } else if (strstart >= WSIZE+MAX_DIST) { - /* By the IN assertion, the window is not empty so we can't confuse - * more == 0 with more == 64K on a 16 bit machine. - */ - Assert(window_size == (ulg)2*WSIZE, "no sliding with BIG_MEM"); - - memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE); - match_start -= WSIZE; - strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */ - - block_start -= (long) WSIZE; - - for (n = 0; n < HASH_SIZE; n++) { - m = head[n]; - head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL); - } - for (n = 0; n < WSIZE; n++) { - m = prev[n]; - prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } - more += WSIZE; - } - /* At this point, more >= 2 */ - if (!eofile) { - n = read_buf((char*)window+strstart+lookahead, more); - if (n == 0 || n == (unsigned)EOF) { - eofile = 1; - } else { - lookahead += n; - } - } -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK(eof) \ - flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \ - (char*)NULL, (long)strstart - block_start, (eof)) - -/* =========================================================================== - * Processes a new input file and return its compressed length. - */ -#ifdef NO_LAZY -ulg deflate() -{ - IPos hash_head; /* head of the hash chain */ - int flush; /* set if current block must be flushed */ - unsigned match_length = 0; /* length of best match */ - - prev_length = MIN_MATCH-1; - while (lookahead != 0) { - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - INSERT_STRING(strstart, hash_head); - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && strstart - hash_head <= MAX_DIST) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - match_length = longest_match (hash_head); - /* longest_match() sets match_start */ - if (match_length > lookahead) match_length = lookahead; - } - if (match_length >= MIN_MATCH) { - check_match(strstart, match_start, match_length); - - flush = ct_tally(strstart-match_start, match_length - MIN_MATCH); - - lookahead -= match_length; - match_length--; /* string at strstart already in hash table */ - do { - strstart++; - INSERT_STRING(strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH - * these bytes are garbage, but it does not matter since the - * next lookahead bytes will always be emitted as literals. - */ - } while (--match_length != 0); - } else { - /* No match, output a literal byte */ - flush = ct_tally (0, window[strstart]); - lookahead--; - } - strstart++; - if (flush) FLUSH_BLOCK(0), block_start = strstart; - - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); - - } - return FLUSH_BLOCK(1); /* eof */ -} -#else /* LAZY */ -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -ulg deflate() -{ - IPos hash_head; /* head of hash chain */ - IPos prev_match; /* previous match */ - int flush; /* set if current block must be flushed */ - int match_available = 0; /* set if previous match exists */ - register unsigned match_length = MIN_MATCH-1; /* length of best match */ -#ifdef DEBUG - extern long isize; /* byte length of input file, for debug only */ -#endif - - /* Process the input block. */ - while (lookahead != 0) { - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - INSERT_STRING(strstart, hash_head); - - /* Find the longest match, discarding those <= prev_length. - */ - prev_length = match_length, prev_match = match_start; - match_length = MIN_MATCH-1; - - if (hash_head != NIL && prev_length < max_lazy_match && - strstart - hash_head <= MAX_DIST) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - match_length = longest_match (hash_head); - /* longest_match() sets match_start */ - if (match_length > lookahead) match_length = lookahead; - - /* Ignore a length 3 match if it is too distant: */ - if (match_length == MIN_MATCH && strstart-match_start > TOO_FAR){ - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - match_length--; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (prev_length >= MIN_MATCH && match_length <= prev_length) { - - check_match(strstart-1, prev_match, prev_length); - - flush = ct_tally(strstart-1-prev_match, prev_length - MIN_MATCH); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. - */ - lookahead -= prev_length-1; - prev_length -= 2; - do { - strstart++; - INSERT_STRING(strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH - * these bytes are garbage, but it does not matter since the - * next lookahead bytes will always be emitted as literals. - */ - } while (--prev_length != 0); - match_available = 0; - match_length = MIN_MATCH-1; - strstart++; - if (flush) FLUSH_BLOCK(0), block_start = strstart; - - } else if (match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c",window[strstart-1])); - if (ct_tally (0, window[strstart-1])) { - FLUSH_BLOCK(0), block_start = strstart; - } - strstart++; - lookahead--; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - match_available = 1; - strstart++; - lookahead--; - } - Assert (strstart <= isize && lookahead <= isize, "a bit too far"); - - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); - } - if (match_available) ct_tally (0, window[strstart-1]); - - return FLUSH_BLOCK(1); /* eof */ -} -#endif /* LAZY */ diff --git a/gnu/usr.bin/gzip-1.0.7/getopt.c b/gnu/usr.bin/gzip-1.0.7/getopt.c deleted file mode 100644 index 30679b9a52a9..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/getopt.c +++ /dev/null @@ -1,711 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu - before changing it! - - Copyright (C) 1987, 88, 89, 90, 91, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* AIX requires this to be the first thing in the file. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__)))) -#include -#else -#ifdef _AIX - #pragma alloca -#else -char *alloca (); -#endif -#endif /* alloca.h */ -#endif /* not __GNUC__ */ - -#include - -#if defined(USG) || defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) -#include -#endif - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#undef alloca -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -#include -#else /* Not GNU C library. */ -#define __alloca alloca -#endif /* GNU C library. */ - -#if !__STDC__ -#define const -#endif - -/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a - long-named option. Because this is not POSIX.2 compliant, it is - being phased out. */ -#define GETOPT_COMPAT - -/* 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 POSIXLY_CORRECT 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 "getopt.h" - -/* 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 - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the 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; - -#ifdef __GNU_LIBRARY__ -#include -#define my_index strchr -#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) -#else - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -char *getenv (); - -static char * -my_index (string, chr) - char *string; - int chr; -{ - while (*string) - { - if (*string == chr) - return string; - string++; - } - return 0; -} - -static void -my_bcopy (from, to, size) - char *from, *to; - int size; -{ - int i; - for (i = 0; i < size; i++) - to[i] = from[i]; -} -#endif /* GNU C library. */ - -/* 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 *); -#ifdef _CRAY - char *temp[last_nonopt - first_nonopt]; -#else - char **temp = (char **) __alloca (nonopts_size); -#endif - - /* Interchange the two blocks of data in ARGV. */ - - my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size); - my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt], - (optind - last_nonopt) * sizeof (char *)); - my_bcopy ((char *) temp, - (char *) &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 - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - int option_index; - - 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 = NULL; - - /* 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 ("POSIXLY_CORRECT") != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - } - - 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 ((char **) 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') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - 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 ((char **) 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') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - { - 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 - + (longopts != NULL && argv[optind][1] == '-')); - } - - if (longopts != NULL - && ((argv[optind][0] == '-' - && (argv[optind][1] == '-' || long_only)) -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - )) - { - const struct option *p; - char *s = nextchar; - int exact = 0; - int ambig = 0; - const struct option *pfound = NULL; - int indfound = 0; - - while (*s && *s != '=') - s++; - - /* Test all options for either exact match or abbreviated matches. */ - for (p = longopts, 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 == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*s) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = s + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - else - /* +option or -option */ - 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 - { - if (opterr) - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, "%s: unrecognized option `--%s'\n", - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, "%s: unrecognized option `%c%s'\n", - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - return '?'; - } - } - - /* Look at and handle the next option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (opterr) - { - 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 = NULL; - } - 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) - 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 = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') 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 *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - - -#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/gnu/usr.bin/gzip-1.0.7/getopt.h b/gnu/usr.bin/gzip-1.0.7/getopt.h deleted file mode 100644 index 764f2f4cf5a1..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/getopt.h +++ /dev/null @@ -1,128 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* 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. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, 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 -{ -#if __STDC__ - const char *name; -#else - char *name; -#endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -enum _argtype -{ - no_argument, - required_argument, - optional_argument -}; - -#if __STDC__ || defined(PROTO) -#if defined(__GNU_LIBRARY__) -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ -extern int getopt (); -#endif /* not __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* not __STDC__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* _GETOPT_H */ diff --git a/gnu/usr.bin/gzip-1.0.7/gpl.texinfo b/gnu/usr.bin/gzip-1.0.7/gpl.texinfo deleted file mode 100644 index 6fb0afb4c060..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/gpl.texinfo +++ /dev/null @@ -1,394 +0,0 @@ -@setfilename gpl.info - -@unnumbered GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 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. -@end display - -@unnumberedsec 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. - -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -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. - -@item -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. - -@item -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: - -@enumerate a -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -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. - -@item -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.) -@end enumerate - -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. - -@item -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: - -@enumerate a -@item -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, - -@item -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, - -@item -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.) -@end enumerate - -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@item -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. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -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. - -@item -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 enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec 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. - -@smallexample -@var{one line to give the program's name and an idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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. -@end smallexample - -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: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{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. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{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: - -@example -Yoyodyne, Inc., hereby disclaims all copyright -interest in the program `Gnomovision' -(which makes passes at compilers) written -by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end example - -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/gnu/usr.bin/gzip-1.0.7/gzexe.1 b/gnu/usr.bin/gzip-1.0.7/gzexe.1 deleted file mode 100644 index 68e41279d753..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/gzexe.1 +++ /dev/null @@ -1,36 +0,0 @@ -.TH GZEXE 1 -.SH NAME -gzexe \- compress executable files in place -.SH SYNOPSIS -.B gzexe -[ name ... ] -.SH DESCRIPTION -The -.I gzexe -utility allows you to compress executables in place and have them -automatically uncompress and execute when you run them (at a penalty -in performance). For example if you execute ``gzexe /bin/cat'' it -will create the following two files: -.nf -.br - -r-xr-xr-x 1 root bin 9644 Feb 11 11:16 /bin/cat - -r-xr-xr-x 1 bin bin 24576 Nov 23 13:21 /bin/cat~ -.fi -/bin/cat~ is the original file and /bin/cat is the self-uncompressing -executable file. You can remove /bin/cat~ once you are sure that -/bin/cat works properly. -.PP -This utility is most useful on systems with very small disks. -.SH OPTIONS -.TP -.B \-d -Decompress the given executables instead of compressing them. -.SH "SEE ALSO" -gzip(1), znew(1), zmore(1), zcmp(1), zforce(1) -.SH "BUGS" -.I gzexe -attempts to retain the original file attributes on the compressed executable, -but you may have to fix them manually in some cases, using -.I chmod -or -.I chown. diff --git a/gnu/usr.bin/gzip-1.0.7/gzexe.in b/gnu/usr.bin/gzip-1.0.7/gzexe.in deleted file mode 100644 index d172a59b330d..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/gzexe.in +++ /dev/null @@ -1,135 +0,0 @@ -: -#!/bin/sh -# gzexe: compressor for Unix executables. -# Use this only for binaries that you do not use frequently. -# -# The compressed version is a shell script which decompresses itself after -# skipping $skip lines of shell commands. We try invoking the compressed -# executable with the original name (for programs looking at their name). -# We also try to retain the original file permissions on the compressed file. -# For safety reasons, gzexe will not create setuid or setgid shell scripts. - -# Warning: the first line of this file must be either : or #!/bin/sh -# The : is required for some old versions of csh. - -x=`basename $0` -if test $# = 0; then - echo compress executables. original file foo is renamed to foo~ - echo usage: ${x} [-d] files... - echo " -d decompress the executables" - exit 1 -fi - -tmp=gz$$ -trap "rm -f $tmp; exit 1" 1 2 3 5 10 13 15 - -decomp=0 -res=0 -test "$x" = "ungzexe" && decomp=1 -if test "$1" = "-d"; then - decomp=1 - shift -fi - -echo hi > zfoo1$$ -echo hi > zfoo2$$ -if test -z "`(${CPMOD-cpmod} zfoo1$$ zfoo2$$) 2>&1`"; then - cpmod=${CPMOD-cpmod} -fi -rm -f zfoo[12]$$ - -for i do - if test ! -f "$i" ; then - echo ${x}: $i not a file - res=1 - continue - fi - if test $decomp -eq 0; then - if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then - echo "${x}: $i is already gzexe'd" - continue - fi - fi - if ls -l "$i" | grep '^...[sS]' > /dev/null; then - echo "${x}: $i has setuid permission, unchanged" - continue - fi - if ls -l "$i" | grep '^......[sS]' > /dev/null; then - echo "${x}: $i has setgid permission, unchanged" - continue - fi - if test "`basename $i`" = gzip; then - echo "${x}: cannot compress gzip itself" - continue - fi - if test -z "$cpmod"; then - cp -p "$i" $tmp 2>/dev/null || cp "$i" $tmp - if test -w $tmp 2>/dev/null; then - writable=1 - else - writable=0 - chmod u+w $tmp 2>/dev/null - fi - fi - if test $decomp -eq 0; then - sed 1q $0 > $tmp - cat >> $tmp <<'EOF' -skip=18 -if tail +$skip $0 | gzip -cd > /tmp/gztmp$$; then - chmod 755 /tmp/gztmp$$ - prog="`basename $0`" - if ln /tmp/gztmp$$ "/tmp/$prog" 2>/dev/null; then - trap '/bin/rm -f /tmp/gztmp$$ "/tmp/$prog"; exit $res' 0 - (sleep 5; /bin/rm -f /tmp/gztmp$$ "/tmp/$prog") 2>/dev/null & - /tmp/"$prog" ${1+"$@"}; res=$? - else - trap '/bin/rm -f /tmp/gztmp$$; exit $res' 0 - (sleep 5; /bin/rm -f /tmp/gztmp$$) 2>/dev/null & - /tmp/gztmp$$ ${1+"$@"}; res=$? - fi -else - echo Cannot decompress $0; exit 1 -fi; exit $res -EOF - gzip -cv9 "$i" >> $tmp || { - /bin/rm -f $tmp - echo ${x}: compression not possible for $i, file unchanged. - res=1 - continue - } - - else - # decompression - skip=18 - if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then - eval `sed -e 1d -e 2q "$i"` - fi - if tail +$skip "$i" | gzip -cd > $tmp; then - : - else - echo ${x}: $i probably not in gzexe format, file unchanged. - res=1 - continue - fi - fi - rm -f "$i~" - mv "$i" "$i~" || { - echo ${x}: cannot backup $i as $i~ - rm -f $tmp - res=1 - continue - } - mv $tmp "$i" || cp -p $tmp "$i" 2>/dev/null || cp $tmp "$i" || { - echo ${x}: cannot create $i - rm -f $tmp - res=1 - continue - } - rm -f $tmp - if test -n "$cpmod"; then - $cpmod "$i~" "$i" 2>/dev/null - elif test $writable -eq 0; then - chmod u-w $i 2>/dev/null - fi -done -exit $res diff --git a/gnu/usr.bin/gzip-1.0.7/gzip-tar.patch b/gnu/usr.bin/gzip-1.0.7/gzip-tar.patch deleted file mode 100644 index d81b1dc55163..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/gzip-tar.patch +++ /dev/null @@ -1,124 +0,0 @@ -This is a *NON official* patch to GNU tar 1.11.1 to support gzip. With -this patch, tar -cz invokes gzip, tar -cZ invokes compress. You can -use tar -xz to extract both compressed and gzip'ed tar files. -For example you can transfer files from one machine to another -in a compressed form using: - - tar cfz - files | rsh machine 'tar xvpfz -' - -tar and gzip are available on all GNU archive sites, such as -prep.ai.mit.edu:/pub/gnu and its mirrors. - -Jean-loup Gailly -jloup@chorus.fr - -diff -c bak/buffer.c ./buffer.c -*** bak/buffer.c Mon Sep 14 22:56:39 1992 ---- ./buffer.c Mon Dec 28 19:07:52 1992 -*************** -*** 452,459 **** - } - } - /* So we should exec compress (-d) */ -! if(ar_reading) - execlp("compress", "compress", "-d", (char *)0); - else - execlp("compress", "compress", (char *)0); - msg_perror("can't exec compress"); ---- 452,463 ---- - } - } - /* So we should exec compress (-d) */ -! if(ar_reading) { -! execlp("gzip", "gzip", "-d", (char *)0); -! /* Try uncompress if gunzip fails */ - execlp("compress", "compress", "-d", (char *)0); -+ } else if (f_zip) -+ execlp("gzip", "gzip", "-8", (char *)0); - else - execlp("compress", "compress", (char *)0); - msg_perror("can't exec compress"); -diff -c bak/tar.c ./tar.c -*** bak/tar.c Mon Sep 14 23:31:38 1992 ---- ./tar.c Mon Dec 28 19:14:29 1992 -*************** -*** 158,163 **** ---- 158,164 ---- - {"ignore-zeros", 0, &f_ignorez, 1}, - {"keep-old-files", 0, 0, 'k'}, - {"uncompress", 0, &f_compress, 1}, -+ {"unzip", 0, 0, 'z'}, - {"same-permissions", 0, &f_use_protection, 1}, - {"preserve-permissions",0, &f_use_protection, 1}, - {"modification-time", 0, &f_modified, 1}, -*************** -*** 183,188 **** ---- 184,190 ---- - {"old-archive", 0, 0, 'o'}, - {"portability", 0, 0, 'o'}, - {"compress", 0, &f_compress, 1}, -+ {"zip", 0, 0, 'z'}, - {"compress-block", 0, &f_compress, 2}, - {"sparse", 0, &f_sparse_files, 1}, - {"tape-length", 1, 0, 'L'}, -*************** -*** 609,615 **** - add_exclude_file(optarg); - break; - -! case 'z': /* Easy to type */ - case 'Z': /* Like the filename extension .Z */ - f_compress++; - break; ---- 611,621 ---- - add_exclude_file(optarg); - break; - -! case 'z': /* Like the filename extension .z */ -! f_zip++; -! f_compress++; -! break; -! - case 'Z': /* Like the filename extension .Z */ - f_compress++; - break; -*************** -*** 716,722 **** - -W, --verify attempt to verify the archive after writing it\n\ - --exclude FILE exclude file FILE\n\ - -X, --exclude-from FILE exclude files listed in FILE\n\ -! -z, -Z, --compress,\n\ - --uncompress filter the archive through compress\n\ - -[0-7][lmh] specify drive and density\n\ - ", stdout); ---- 722,729 ---- - -W, --verify attempt to verify the archive after writing it\n\ - --exclude FILE exclude file FILE\n\ - -X, --exclude-from FILE exclude files listed in FILE\n\ -! -z, --zip, --unzip filter the archive through gzip\n\ -! -Z, --compress,\n\ - --uncompress filter the archive through compress\n\ - -[0-7][lmh] specify drive and density\n\ - ", stdout); -diff -c bak/tar.h ./tar.h -*** bak/tar.h Tue Sep 8 21:45:34 1992 ---- ./tar.h Mon Dec 28 19:06:40 1992 -*************** -*** 224,231 **** - TAR_EXTERN int f_verify; /* -W */ - /* CMD_EXTRACT -x */ - TAR_EXTERN int f_exclude; /* -X */ -! TAR_EXTERN int f_compress; /* -z */ -! /* -Z */ - TAR_EXTERN int f_do_chown; /* --do-chown */ - TAR_EXTERN int f_totals; /* --totals */ - TAR_EXTERN int f_remove_files; /* --remove-files */ ---- 224,231 ---- - TAR_EXTERN int f_verify; /* -W */ - /* CMD_EXTRACT -x */ - TAR_EXTERN int f_exclude; /* -X */ -! TAR_EXTERN int f_zip; /* -z */ -! TAR_EXTERN int f_compress; /* -Z */ - TAR_EXTERN int f_do_chown; /* --do-chown */ - TAR_EXTERN int f_totals; /* --totals */ - TAR_EXTERN int f_remove_files; /* --remove-files */ diff --git a/gnu/usr.bin/gzip-1.0.7/gzip.1 b/gnu/usr.bin/gzip-1.0.7/gzip.1 deleted file mode 100644 index 1518f5e4cd06..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/gzip.1 +++ /dev/null @@ -1,340 +0,0 @@ -.PU -.TH GZIP 1 local -.SH NAME -gzip, gunzip, zcat \- compress or expand files -.SH SYNOPSIS -.ll +8 -.B gzip -.RB [ " \-cdfhLrtvV19 " ] -[ -.I "name \&..." -] -.ll -8 -.br -.B gunzip -.RB [ " \-cfhLrtvV " ] -[ -.I "name \&..." -] -.br -.B zcat -.RB [ " \-hLV " ] -[ -.I "name \&..." -] -.SH DESCRIPTION -.I Gzip -reduces the size of the named files using Lempel-Ziv coding (LZ77). -Whenever possible, -each file is replaced by one with the extension -.B "\&.z," -while keeping the same ownership modes, access and modification times. -(The extension is -.B "\-z" -for VMS, -.B "z" -for MSDOS, OS/2 and Atari.) -If no files are specified, the standard input is compressed to the -standard output. If the new file name is too long, -.I gzip -truncates it and keeps the original file name in the compressed file. -.I Gzip -will only attempt to compress regular files. -In particular, it will ignore symbolic links. -.PP -Compressed files can be restored to their original form using -.I gzip -d -or -.I gunzip -or -.I zcat. -.PP -.I gunzip -takes a list of files on its command line and replaces each -file whose name ends with -.B "\&.z" -or -.B "\&.Z" -or -.B "\&-z" -and which begins with the correct magic number with an uncompressed -file without the original extension. -.I gunzip -also recognizes the special extensions -.B "\&.tgz" -and -.B "\&.taz" -as shorthands for -.B "\&.tar.z" -or -.B "\&.tar.Z" -.PP -.I gunzip -can currently decompress files created by -.I gzip, zip, compress -or -.I pack. -The detection of the input format is automatic. When using -the first two formats, -.I gunzip -checks a 32 bit CRC. For -.I pack, gunzip -checks the uncompressed length. The -.I compress -format was not designed to allow consistency checks. However -.I gunzip -is sometimes able to detect a bad .Z file. If you get an error -when uncompressing a .Z file, do not assume that the .Z file is -correct simply because the standard -.I uncompress -does not complain. This generally means that the standard -.I uncompress -does not check its input, and happily generates garbage output. -.PP -Files created by -.I zip -can be uncompressed by gzip only if they have a single member compressed -with the 'deflation' method. This feature is only intended to help -conversion of tar.zip files to the tar.z format. To extract zip files -with several members, use -.I unzip -instead of -.I gunzip. -.PP -.I zcat -is identical to -.I gunzip -.B \-c. -(On some systems, -.I zcat -may be installed as -.I gzcat -to preserve the original link to -.I compress.) -.I zcat -uncompresses either a list of files on the command line or its -standard input and writes the uncompressed data on standard output. -.I zcat -will uncompress files that have the correct magic number whether -they have a -.B "\&.z" -suffix or not. -.PP -.I Gzip -uses the Lempel-Ziv algorithm used in -.I zip -and PKZIP. -The amount of compression obtained depends on the size of the -input and the distribution of common substrings. -Typically, text such as source code or English -is reduced by 60\-70%. -Compression is generally much better than that achieved by -LZW (as used in -.IR compress ), -Huffman coding (as used in -.IR pack ), -or adaptive Huffman coding -.RI ( compact ). -.PP -Compression is always performed, even if the compressed file is -slightly larger than the original. The worst case expansion is -a few bytes for the gzip file header, plus 5 bytes every 32K block, -or an expansion ratio of 0.015% for large files. -.I gzip -preserves the mode, ownership and timestamps of files when compressing -or decompressing. - -.SH OPTIONS -.TP -.B \-c --stdout -Write output on standard output; keep original files unchanged. -If there are several input files, the output consists of a sequence of -independently compressed members. To obtain better compression, -concatenate all input files before compressing them. -.TP -.B \-d --decompress -Decompress. -.TP -.B \-f --force -Force compression or decompression even if the file has multiple links -or the corresponding file already exists. -If -.B \-f -is not given, -and when not running in the background, -.I gzip -prompts to verify whether an existing file should be overwritten. -.TP -.B \-h --help -Display a help screen. -.TP -.B \-L --license -Display the -.I gzip -license. -.TP -.B \-q --quiet -Suppress all warnings. -.TP -.B \-r --recurse -Travel the directory structure recursively. If any of the file names -specified on the command line are directories, -.I gzip -will descend into the directory and compress all the files it finds there -(or decompress them in the case of -.I gunzip -). -.TP -.B \-t --test -Test. Check the compressed file integrity. -.TP -.B \-v --verbose -Verbose. Display the name and percentage reduction for each file compressed. -.TP -.B \-V --version -Version. Display the version number and compilation options. -.TP -.B \-# --fast --best -Regulate the speed of compression using the specified digit -.IR # , -where -.B \-1 -or -.B \-\-fast -indicates the fastest compression method (less compression) -and -.B \-9 -or -.B \-\-best -indicates the slowest compression method (optimal compression). -The default compression level is -.BR \-5. -.SH "ADVANCED USAGE" -Multiple compressed files can be concatenated. In this case, -.I gunzip -will extract all members at once. For example: - - gzip -c file1 > foo.z - gzip -c file2 >> foo.z -Then - gunzip -c foo - -is equivalent to - - cat file1 file2 - -In case of damage to one member of a .z file, other members can -still be recovered (if the damaged member is removed). However, -you can get better compression by compressing all members at once: - - cat file1 file2 | gzip > foo.z - -compresses better than - - gzip -c file1 file2 > foo.z - -If you want to recompress concatenated files to get better compression, do: - - zcat old.z | gzip > new.z -.SH "ENVIRONMENT" -The environment variable -.B GZIP -can hold a set of default options for -.I gzip. -These options are interpreted first and can be overwritten by -explicit command line parameters. For example: - for sh: GZIP="-8 -v"; export GZIP - for csh: setenv GZIP "-8 -v" - for MSDOS: set GZIP=-8 -v - -On Vax/VMS, the name of the environment variable is GZIP_OPT, to -avoid a conflict with the symbol set for invocation of the program. -.SH "SEE ALSO" -znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1), unzip(1), compress(1), -pack(1), compact(1) -.SH "DIAGNOSTICS" -Exit status is normally 0; -if an error occurs, exit status is 1. If a warning occurs, exit status is 2. -.PP -Usage: gzip [-cdfhLrtvV19] [file ...] -.in +8 -Invalid options were specified on the command line. -.in -8 -.IR file : -not in gzip format -.in +8 -The file specified to -.I gunzip -has not been compressed. -.in -8 -.IR file: -Corrupt input. Use zcat to recover some data. -.in +8 -The compressed file has been damaged. The data up to the point of failure -can be recovered using -.in +8 -zcat file > recover -.in -16 -.IR file : -compressed with -.I xx -bits, can only handle -.I yy -bits -.in +8 -.I File -was compressed (using LZW) by a program that could deal with -more -.I bits -than the decompress code on this machine. -Recompress the file with gzip, which compresses better and uses -less memory. -.in -8 -.IR file : -already has z suffix -- no change -.in +8 -The file is assumed to be already compressed. -Rename the file and try again or use zcat. -.in -8 -.I file -already exists; do you wish to overwrite (y or n)? -.in +8 -Respond "y" if you want the output file to be replaced; "n" if not. -.in -8 -gunzip: corrupt input -.in +8 -A SIGSEGV violation was detected which usually means that the input file has -been corrupted. -.in -8 -.I "xx.x%" -.in +8 -Percentage of the input saved by compression. -(Relevant only for -.BR \-v \.) -.in -8 --- not a regular file or directory: ignored -.in +8 -When the input file is not a regular file or directory, -(e.g. a symbolic link, socket, FIFO, device file), it is -left unaltered. -.in -8 --- has -.I xx -other links: unchanged -.in +8 -The input file has links; it is left unchanged. See -.IR ln "(1)" -for more information. Use the -.B \-f -flag to force compression of multiply-linked files. -.in -8 -.SH CAVEATS -The .z extension is already used by -.IR pack "(1)". -You can link -.I gzip -to -.I pcat -to get transparent decompression for programs expecting .z files to be in -.IR pack -format. diff --git a/gnu/usr.bin/gzip-1.0.7/gzip.c b/gnu/usr.bin/gzip-1.0.7/gzip.c deleted file mode 100644 index c34cddaf33d7..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/gzip.c +++ /dev/null @@ -1,1369 +0,0 @@ -/* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface - * Copyright (C) 1992-1993 Jean-loup Gailly - * The unzip code was written and put in the public domain by Mark Adler. - * Portions of the lzw code are derived from the public domain 'compress' - * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, - * Ken Turkowski, Dave Mack and Peter Jannesen. - * - * See the license_msg below and the file COPYING for the software license. - * See the file algorithm.doc for the compression algorithms and file formats. - */ - -static char *license_msg[] = { -" Copyright (C) 1992-1993 Jean-loup Gailly", -" 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.", -0}; - -/* Compress files with zip algorithm and 'compress' interface. - * See usage() and help() functions below for all options. - * Outputs: - * file.z: compressed file with same mode, owner, and utimes - * file.Z: same with -Z option (old compress format) - * or stdout with -c option or if stdin used as input. - * If the OS does not support file names with multiple dots (MSDOS, VMS) or - * if the output file name had to be truncated, the original name is kept - * in the compressed .z file. (Feature not available in old compress format.) - * On MSDOS, file.tmp -> file.tmz. On VMS, file.tmp -> file.tmp-z. - * - * For the meaning of all compilation flags, see comments in Makefile.in. - */ - -#ifndef lint -static char rcsid[] = "$Id: gzip.c,v 1.1 1993/04/10 15:55:57 cgd Exp $"; -#endif - -#include "tailor.h" -#include "gzip.h" -#include "lzw.h" -#include "revision.h" -#include "getopt.h" - -#include -#include -#include -#include -#include -#include - - /* configuration */ - -#ifndef NO_FCNTL_H -# include -#endif - -#ifdef HAVE_UNISTD_H -# include -#endif - -#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H) -# include -#else - extern int errno; -#endif - -#if defined(DIRENT) || defined(_POSIX_VERSION) -# include - typedef struct dirent dir_type; -# define NLENGTH(dirent) ((int)strlen((dirent)->d_name)) -# define DIR_OPT "DIRENT" -#else -# define NLENGTH(dirent) ((dirent)->d_namlen) -# ifdef SYSDIR -# include - typedef struct direct dir_type; -# define DIR_OPT "SYSDIR" -# else -# ifdef SYSNDIR -# include - typedef struct direct dir_type; -# define DIR_OPT "SYSNDIR" -# else -# ifdef NDIR -# include - typedef struct direct dir_type; -# define DIR_OPT "NDIR" -# else -# define NO_DIR -# define DIR_OPT "NO_DIR" -# endif -# endif -# endif -#endif - -#ifndef NO_UTIME -# ifndef NO_UTIME_H -# include -# define TIME_OPT "UTIME" -# else -# ifdef HAVE_SYS_UTIME_H -# include -# define TIME_OPT "SYS_UTIME" -# else - struct utimbuf { - time_t actime; - time_t modtime; - }; -# define TIME_OPT "" -# endif -# endif -#else -# define TIME_OPT "NO_UTIME" -#endif - -#if !defined(S_ISDIR) && defined(S_IFDIR) -# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#endif -#if !defined(S_ISREG) && defined(S_IFREG) -# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#endif - -typedef RETSIGTYPE (*sig_type)(); - -#ifndef O_BINARY -# define O_BINARY 0 /* creation mode for open() */ -#endif - -#ifndef O_CREAT - /* Pure BSD system? */ -# include -# ifndef O_CREAT -# define O_CREAT FCREAT -# endif -# ifndef O_EXCL -# define O_EXCL FEXCL -# endif -#endif - -#define RW_USER 0600 /* creation mode for open() */ - -#ifndef MAX_PATH_LEN -# define MAX_PATH_LEN 1024 /* max pathname length */ -#endif - -#define MAX_HEADER_LEN 16 -/* max length of a compressed file header, fixed part only */ - - /* global buffers */ - -DECLARE(uch, inbuf, INBUFSIZ +INBUF_EXTRA); -DECLARE(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA); -DECLARE(ush, d_buf, DIST_BUFSIZE); -DECLARE(uch, window, 2L*WSIZE); -#ifndef MAXSEG_64K - DECLARE(ush, tab_prefix, 1L< 4 && strequ(progname+proglen-4, ".exe")) { - progname[proglen-4] = '\0'; - } - - /* Add options in GZIP environment variable if there is one */ - env = add_envopt(&argc, &argv, OPTIONS_VAR); - if (env != NULL) args = argv; - - foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; - if (foreground) { - signal (SIGINT, (sig_type)abort_gzip); - } -#ifdef SIGTERM - signal(SIGTERM, (sig_type)abort_gzip); -#endif -#ifdef SIGHUP - signal(SIGHUP, (sig_type)abort_gzip); -#endif - -#ifndef GNU_STANDARD - /* For compatibility with old compress, use program name as an option. - * If you compile with -DGNU_STANDARD, this program will behave as - * gzip even if it is invoked under the name gunzip or zcat. - * - * Systems which do not support links can still use -d or -dc. - * Ignore an .exe extension for MSDOS, OS/2 and VMS. - */ - if ( strncmp(progname, "un", 2) == 0 /* ungzip, uncompress */ - || strncmp(progname, "gun", 3) == 0) { /* gunzip */ - decompress = 1; - } else if (strequ(progname+1, "cat") /* zcat, pcat */ - || strequ(progname, "gzcat")) { /* gzcat */ - decompress = to_stdout = 1; - } -#endif - - while ((optc = getopt_long (argc, argv, "b:cdfhLqrtvVZ123456789", - longopts, (int *)0)) != EOF) { - switch (optc) { - case 'b': - maxbits = atoi(optarg); - break; - case 'c': - to_stdout = 1; break; - case 'd': - decompress = 1; break; - case 'f': - force++; break; - case 'h': - help(); do_exit(OK); break; - case 'L': - license(); do_exit(OK); break; - case 'q': - quiet = 1; verbose = 0; break; - case 'r': -#ifdef NO_DIR - fprintf(stderr, "%s: -r not supported on this system\n", progname); - usage(); - do_exit(ERROR); break; -#else - recursive = 1; break; -#endif - case 't': - test = decompress = to_stdout = 1; - break; - case 'v': - verbose++; quiet = 0; break; - case 'V': - version(); quit_on_tty = 1; break; - case 'Z': -#ifdef LZW - do_lzw = 1; break; -#else - fprintf(stderr, "%s: -Z not supported in this version\n", - progname); - usage(); - do_exit(ERROR); break; -#endif - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - level = optc - '0'; - break; - default: - /* Error message already emitted by getopt_long. */ - usage(); - do_exit(ERROR); - } - } /* loop on all arguments */ - - file_count = argc - optind; - - if (do_lzw && !decompress) work = lzw; - - /* Allocate all global buffers (for DYN_ALLOC option) */ - ALLOC(uch, inbuf, INBUFSIZ +INBUF_EXTRA); - ALLOC(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA); - ALLOC(ush, d_buf, DIST_BUFSIZE); - ALLOC(uch, window, 2L*WSIZE); -#ifndef MAXSEG_64K - ALLOC(ush, tab_prefix, 1L< 1 && !to_stdout && !force) { - WARN((stderr, "%s: %s has %d other link%c -- unchanged\n", - progname, ifname, - (int)istat.st_nlink - 1, istat.st_nlink > 2 ? 's' : ' ')); - return; - } - - ifile_size = istat.st_size; - time_stamp = istat.st_mtime; - - /* Generate output file name */ - if (to_stdout) { - strcpy(ofname, "stdout"); - - } else if (make_ofname() != 0) { - return; - } - - /* Open the input file and determine compression method. The mode - * parameter is ignored but required by some systems (VMS). - */ - ifd = open(ifname, O_RDONLY | O_BINARY, RW_USER); - if (ifd == -1) { - perror(ifname); - exit_code = ERROR; - return; - } - clear_bufs(); /* clear input and output buffers */ - part_nb = 0; - - if (decompress) { - method = get_method(ifd); /* updates ofname if original given */ - if (method < 0) { - close(ifd); - return; /* error message already emitted */ - } - } - - /* If compressing to a file, check if ofname is not ambiguous - * because the operating system truncates names. Otherwise, generate - * a new ofname and save the original name in the compressed file. - */ - if (to_stdout) { - ofd = fileno(stdout); - /* keep remove_ofname as zero */ - } else { - if (create_outfile() == -1) return; - - if (save_orig_name && !verbose && !quiet) { - fprintf(stderr, "%s: %s compressed to %s\n", - progname, ifname, ofname); - } - } - if (verbose) { - fprintf(stderr, "%s:\t%s", ifname, (int)strlen(ifname) >= 15 ? - "" : ((int)strlen(ifname) >= 7 ? "\t" : "\t\t")); - } - - /* Actually do the compression/decompression. Loop over zipped members. - */ - for (;;) { - (*work)(ifd, ofd); - - if (!decompress || last_member || inptr == insize) break; - /* end of file */ - - method = get_method(ifd); - if (method < 0) break; /* error message already emitted */ - bytes_out = 0; /* required for length check */ - } - - close(ifd); - if (!to_stdout && close(ofd)) { - write_error(); - } - if (method == -1) return; /* error, don't display success msg */ - - /* Display statistics */ - if(verbose) { - if (!decompress) { - display_ratio(bytes_in-bytes_out-overhead, bytes_in); - } - if (test) { - fprintf(stderr, " OK"); - } else if (!to_stdout) { - fprintf(stderr, " -- replaced with %s", ofname); - } - fprintf(stderr, "\n"); - } - /* Copy modes, times, ownership */ - if (!to_stdout) { - copy_stat(&istat); - } -} - -/* ======================================================================== - * Create the output file. Return 0 for success, -1 for error. - * Try twice if ofname is exactly one beyond the name limit, to avoid - * creating a compressed file of name "1234567890123." - * We could actually loop more than once if the user gives an extra long - * name, but I prefer generating an error then. (Posix forbids the system - * to truncate names.) The error message is generated by check_ofname() - * in this case. - * IN assertions: the input file has already been open (ifd is set) and - * ofname has already been updated if there was an original name. - * OUT assertions: ifd and ofd are closed in case of error. - */ -local int create_outfile() -{ - struct stat ostat; /* stat for ofname */ - int n; /* loop counter */ - - for (n = 1; n <= 2; n++) { - if (check_ofname() == -1) { - close(ifd); - return -1; - } - /* Create the output file */ - remove_ofname = 1; - ofd = open(ofname, O_WRONLY|O_CREAT|O_EXCL|O_BINARY, RW_USER); - if (ofd == -1) { - perror(ofname); - close(ifd); - exit_code = ERROR; - return -1; - } - - /* Check for name truncation on new file (1234567890123.z) */ - if (fstat(ofd, &ostat) != 0) { - fprintf(stderr, "%s: ", progname); - perror(ofname); - close(ifd); close(ofd); - unlink(ofname); - exit_code = ERROR; - return -1; - } - if (!name_too_long(ofname, &ostat)) return 0; - - if (decompress) { - /* name might be too long if an original name was saved */ - WARN((stderr, "%s: %s: warning, name truncated\n", - progname, ofname)); - return 0; - } else { -#ifdef NO_MULTIPLE_DOTS - /* Should never happen, see check_ofname() */ - fprintf(stderr, "%s: %s: name too long\n", progname, ofname); - do_exit(ERROR); -#else - close(ofd); - unlink(ofname); - save_orig_name = 1; - strcpy(ofname+strlen(ofname)-Z_LEN-1, Z_SUFFIX); - /* 1234567890123.z -> 123456789012.z */ -#endif - } /* decompress ? */ - } /* for (n) */ - - close(ifd); - fprintf(stderr, "%s: %s: name too long\n", progname, ofname); - exit_code = ERROR; - return -1; -} - -/* ======================================================================== - * Use lstat if available, except for -c or -f. Use stat otherwise. - * This allows links when not removing the original file. - */ -local int do_stat(name, sbuf) - char *name; - struct stat *sbuf; -{ -#if (defined(S_IFLNK) || defined (S_ISLNK)) && !defined(NO_SYMLINK) - if (!to_stdout && !force) { - return lstat(name, sbuf); - } -#endif - return stat(name, sbuf); -} - -/* ======================================================================== - * Return a pointer to the 'z' suffix of a file name, or NULL. - * For all systems, ".z", ".Z", ".taz", ".tgz", "-z" are accepted suffixes. - * ".tgz" is a useful convention for tar.z files on systems limited - * to 3 characters extensions. On such systems, ".?z" and ".??z" are - * also accepted suffixes. For Unix, we do not want to accept any - * .??z suffix as indicating a compressed file; some people use .xyz - * to denote volume data. - */ -local char *get_suffix(name) - char *name; -{ - int len; - char *p = strrchr(name, '.'); - char suffix[10]; /* last few chars of name, forced to lower case */ - - if (p == NULL || p == name || strchr(p-1, PATH_SEP) != NULL) return NULL; - strncpy(suffix, p, sizeof(suffix)); - suffix[sizeof(suffix)-1] = '\0'; /* Force null termination */ - -#ifdef SUFFIX_SEP - /* strip a version number from the file name */ - { - char *v = strrchr(suffix, SUFFIX_SEP); - if (v != NULL) *v = '\0'; - } -#endif - strlwr(suffix); - if (strequ(suffix, ".z") || strequ(suffix, ".zip") - || strequ(suffix, ".tgz") || strequ(suffix, ".taz")) { - return p; - } - len = strlen(suffix); - if (len <= 2) return NULL; - - if (strequ(suffix+len-2, "-z")) return p+len-2; -#ifdef MAX_EXT_CHARS - if (suffix[len-1] == 'z') return p+len-1; -#endif - return NULL; -} - - -/* ======================================================================== - * Set ifname to the input file name (with .z appended if necessary) - * and istat to its stats. Return 0 if ok, -1 if error. - */ -local int get_istat(iname, sbuf) - char *iname; - struct stat *sbuf; -{ - int iexists; /* set if iname exists */ - int ilen = strlen(iname); - char *suff; - - strcpy(ifname, iname); - errno = 0; - - /* If input file exists, return OK. */ - if (do_stat(ifname, sbuf) == 0) return 0; - - if (!decompress || errno != ENOENT) { - perror(ifname); - exit_code = ERROR; - return -1; - } - /* file.ext doesn't exist, try file.ext.z and file.ext.Z. For MSDOS - * try file.exz, for VMS try file.ext-z. - */ - suff = get_suffix(ifname); - if (suff != NULL) { - perror(ifname); /* ifname already has z suffix and does not exist */ - exit_code = ERROR; - return -1; - } -#ifdef SUFFIX_SEP - /* strip a version number from the input file name */ - if ((suff = strrchr(ifname, SUFFIX_SEP)) != NULL) *suff = '\0'; -#endif - if (strrchr(ifname, '.') != NULL) { - strcat(ifname, Z_SUFFIX); - ilen += Z_LEN; - } else { - strcat(ifname, ".z"); - ilen += 2; - } - errno = 0; - iexists = !do_stat(ifname, sbuf); - if (!iexists) { - errno = 0; - ifname[ilen-1] = 'Z'; - iexists = !do_stat(ifname, sbuf); - } -#ifdef NO_MULTIPLE_DOTS - /* One more try just to be nice to you */ - if (!iexists) { - char c = ifname[ilen-2]; - errno = 0; - strcpy(ifname+ilen-2, "z"); - iexists = !do_stat(ifname, sbuf); - if (!iexists) { - ifname[ilen-2] = c; - } - } -#endif - if (!iexists) { - ifname[ilen-1] = 'z'; - perror(ifname); - exit_code = ERROR; - return -1; - } - if (!S_ISREG (sbuf->st_mode)) { - WARN((stderr, "%s: %s: not a regular file -- ignored\n", - progname, ifname)); - return -1; - } - return 0; /* ok */ -} - -/* ======================================================================== - * Generate ofname given ifname. Return 0 if ok, -1 if file must be skipped. - * Initializes save_orig_name. - * IN assertion: this function is not called if to_stdout is true. - */ -local int make_ofname() -{ - char *suff; /* ofname z suffix */ - - strcpy(ofname, ifname); - suff = get_suffix(ofname); - - if (decompress) { - if (suff == NULL) { - WARN((stderr,"%s: %s: no z suffix -- ignored\n", - progname, ifname)); - return -1; - } - /* Make a special case for .tgz and .taz: */ - strlwr(suff); - if (strequ(suff, ".tgz") || strequ(suff, ".taz")) { - strcpy(suff, ".tar"); - } else { - *suff = '\0'; /* strip z suffix and optional version number */ - } - /* ofname might be changed later if infile contains an original name */ - - } else if (suff != NULL) { - /* Avoid annoying messages with -r (see treat_dir()) */ - if (verbose || (!recursive && !quiet)) { - fprintf(stderr, "%s: %s already has %s suffix -- unchanged\n", - progname, ifname, suff); - } - if (exit_code == OK) exit_code = WARNING; - return -1; - } else { - save_orig_name = 0; - -#ifdef SUFFIX_SEP - /* strip a version number from the file name */ - if ((suff = strrchr(ofname, SUFFIX_SEP)) != NULL) *suff = '\0'; -#endif - -#ifdef NO_MULTIPLE_DOTS - suff = strrchr(ofname, '.'); - if (suff != NULL) { -# ifdef MAX_EXT_CHARS - /* On the Atari and some versions of MSDOS, name_too_long() - * does not work correctly because of a bug in stat(). So we - * must truncate here. - */ - if (strlen(suff) > MAX_EXT_CHARS) { - strcpy(suff + MAX_EXT_CHARS, do_lzw ? "Z" : "z"); - save_orig_name = 1; - return 0; - } -# endif - strcat(ofname, Z_SUFFIX); - return 0; - } -#endif - strcat(ofname, do_lzw ? ".Z" : ".z"); - - } /* decompress ? */ - return 0; -} - - -/* ======================================================================== - * Check the magic number of the input file and update ofname if an - * original name was given and to_stdout is not set. - * Return the compression method, -1 for error, -2 for warning. - * Set inptr to the offset of the next byte to be processed. - * This function may be called repeatedly for an input file consisting - * of several contiguous gzip'ed members. - * IN assertions: there is at least one remaining compressed member. - * If the member is a zip file, it must be the only one. - */ -local int get_method(in) - int in; /* input file descriptor */ -{ - uch flags; - char magic[2]; /* magic header */ - - magic[0] = (char)get_byte(); - magic[1] = (char)get_byte(); - - time_stamp = istat.st_mtime; /* may be modified later for some methods */ - method = -1; /* unknown yet */ - part_nb++; /* number of parts in gzip file */ - last_member = RECORD_IO; - /* assume multiple members in gzip file except for record oriented I/O */ - - if (memcmp(magic, GZIP_MAGIC, 2) == 0 - || memcmp(magic, OLD_GZIP_MAGIC, 2) == 0) { - - work = unzip; - method = (int)get_byte(); - flags = (uch)get_byte(); - - if ((flags & ENCRYPTED) != 0) { - fprintf(stderr, - "%s: %s is encrypted -- get newer version of gzip\n", - progname, ifname); - exit_code = ERROR; - return -1; - } - if ((flags & CONTINUATION) != 0) { - fprintf(stderr, - "%s: %s is a a multi-part gzip file -- get newer version of gzip\n", - progname, ifname); - exit_code = ERROR; - if (force <= 1) return -1; - } - if ((flags & RESERVED) != 0) { - fprintf(stderr, - "%s: %s has flags 0x%x -- get newer version of gzip\n", - progname, ifname, flags); - exit_code = ERROR; - if (force <= 1) return -1; - } - time_stamp = (ulg)get_byte(); - time_stamp |= ((ulg)get_byte()) << 8; - time_stamp |= ((ulg)get_byte()) << 16; - time_stamp |= ((ulg)get_byte()) << 24; - - (void)get_byte(); /* Ignore extra flags for the moment */ - (void)get_byte(); /* Ignore OS type for the moment */ - - if ((flags & CONTINUATION) != 0) { - unsigned part = (unsigned)get_byte(); - part |= ((unsigned)get_byte())<<8; - if (verbose) { - fprintf(stderr,"%s: %s: part number %u\n", - progname, ifname, part); - } - } - if ((flags & EXTRA_FIELD) != 0) { - unsigned len = (unsigned)get_byte(); - len |= ((unsigned)get_byte())<<8; - if (verbose) { - fprintf(stderr,"%s: %s: extra field of %u bytes ignored\n", - progname, ifname, len); - } - while (len--) (void)get_byte(); - } - - /* Get original file name if it was truncated */ - if ((flags & ORIG_NAME) != 0) { - if (to_stdout || part_nb > 1) { - /* Discard the old name */ - while (get_byte() != 0) /* null */ ; - } else { - /* Copy the base name. Keep a directory prefix intact. */ - char *p = basename(ofname); - for (;;) { - *p = (char)get_byte(); - if (*p++ == '\0') break; - if (p >= ofname+sizeof(ofname)) { - error("corrupted input -- file name too large"); - } - } - } /* to_stdout */ - } /* orig_name */ - - /* Discard file comment if any */ - if ((flags & COMMENT) != 0) { - while (get_byte() != 0) /* null */ ; - } - - } else if (memcmp(magic, PKZIP_MAGIC, 2) == 0 && inptr == 2 - && memcmp(inbuf, PKZIP_MAGIC, 4) == 0) { - /* To simplify the code, we support a zip file when alone only. - * We are thus guaranteed that the entire local header fits in inbuf. - */ - inptr = 0; - work = unzip; - if (check_zipfile(in) == -1) return -1; - /* check_zipfile may get ofname from the local header */ - last_member = 1; - - } else if (memcmp(magic, PACK_MAGIC, 2) == 0) { - work = unpack; - method = PACKED; - } else if (memcmp(magic, LZW_MAGIC, 2) == 0) { - work = unlzw; - method = COMPRESSED; - last_member = 1; - } - if (method >= 0) return method; - if (part_nb == 1) { - fprintf(stderr, "%s: %s is not in gzip format\n", progname, ifname); - exit_code = ERROR; - return -1; - } else { - WARN((stderr, "%s: %s: trailing garbage ignored\n", progname, ifname)); - return -2; - } -} - -/* ======================================================================== - * Return true if the two stat structures correspond to the same file. - */ -local int same_file(stat1, stat2) - struct stat *stat1; - struct stat *stat2; -{ - return stat1->st_mode == stat2->st_mode - && stat1->st_ino == stat2->st_ino - && stat1->st_dev == stat2->st_dev - && stat1->st_uid == stat2->st_uid - && stat1->st_gid == stat2->st_gid - && stat1->st_size == stat2->st_size - && stat1->st_atime == stat2->st_atime - && stat1->st_mtime == stat2->st_mtime - && stat1->st_ctime == stat2->st_ctime; -} - -/* ======================================================================== - * Return true if a file name is ambiguous because the operating system - * truncates file names. - */ -local int name_too_long(name, statb) - char *name; /* file name to check */ - struct stat *statb; /* stat buf for this file name */ -{ - int s = strlen(name); - char c = name[s-1]; - struct stat tstat; /* stat for truncated name */ - int res; - - tstat = *statb; /* Just in case OS does not fill all fields */ - name[s-1] = '\0'; - res = stat(name, &tstat) == 0 && same_file(statb, &tstat); - name[s-1] = c; - return res; -} - -/* ======================================================================== - * If compressing to a file, check if ofname is not ambigous - * because the operating system truncates names. Otherwise, generate - * a new ofname and save the original name in the compressed file. - * If the compressed file already exists, ask for confirmation. - * The check for name truncation is made dynamically, because different - * file systems on the same OS might use different truncation rules (on SVR4 - * s5 truncates to 14 chars and ufs does not truncate). - * This function returns -1 if the file must be skipped, and - * updates save_orig_name if necessary. - * IN assertions: save_orig_name is already set if ofname has been - * already truncated because of NO_MULTIPLE_DOTS. The input file has - * already been open and istat is set. - */ -local int check_ofname() -{ - int s = strlen(ofname); - struct stat ostat; /* stat for ofname */ - - if (stat(ofname, &ostat) != 0) return 0; - - /* Check for name truncation on existing file: */ -#ifdef NO_MULTIPLE_DOTS - if (!decompress && name_too_long(ofname, &ostat)) { -#else - if (!decompress && s > 8 && name_too_long(ofname, &ostat)) { -#endif - save_orig_name = 1; -#ifdef NO_MULTIPLE_DOTS - strcpy(ofname+s-Z_LEN-1, Z_SUFFIX); /* f.extz -> f.exz */ -#else - strcpy(ofname+s-4, ".z"); /* 12345678901234.z -> 123456789012.z */ -#endif - if (stat(ofname, &ostat) != 0) return 0; - } /* !decompress && name_too_long */ - - /* Check that the input and output files are different (could be - * the same by name truncation or links). - */ - if (same_file(&istat, &ostat)) { - fprintf(stderr, "%s: %s and %s are the same file\n", - progname, ifname, ofname); - exit_code = ERROR; - return -1; - } - /* Ask permission to overwrite the existing file */ - if (!force) { - char response[80]; - strcpy(response,"n"); - fprintf(stderr, "%s: %s already exists;", progname, ofname); - if (foreground && isatty(fileno(stdin))) { - fprintf(stderr, " do you wish to overwrite (y or n)? "); - fflush(stderr); - (void)read(fileno(stdin), response, sizeof(response)); - } - if (tolow(*response) != 'y') { - fprintf(stderr, "\tnot overwritten\n"); - if (exit_code == OK) exit_code = WARNING; - return -1; - } - } - (void) chmod(ofname, 0777); - if (unlink(ofname)) { - fprintf(stderr, "%s: ", progname); - perror(ofname); - exit_code = ERROR; - return -1; - } - return 0; -} - - -/* ======================================================================== - * Set the access and modification times from the given stat buffer. - */ -local void reset_times (name, statb) - char *name; - struct stat *statb; -{ -#ifndef NO_UTIME - struct utimbuf timep; - - /* Copy the time stamp */ - timep.actime = statb->st_atime; - timep.modtime = statb->st_mtime; - - if (utime(name, &timep)) { - WARN((stderr, "%s: ", progname)); - if (!quiet) perror(ofname); - } -#else - name = name; statb = statb; /* avoid warnings */ -#endif -} - - -/* ======================================================================== - * Copy modes, times, ownership from input file to output file. - * IN assertion: to_stdout is false. - */ -local void copy_stat(ifstat) - struct stat *ifstat; -{ -#ifndef NO_UTIME - time_t diff = ifstat->st_mtime - time_stamp; - - if (diff < 0) diff = -diff; - if (decompress && diff > 60 && time_stamp != 0) { - ifstat->st_mtime = time_stamp; - if (verbose) { - fprintf(stderr, "%s: time stamp restored\n", ofname); - } - } - reset_times(ofname, ifstat); -#endif - /* Copy the protection modes */ - if (chmod(ofname, ifstat->st_mode & 07777)) { - WARN((stderr, "%s: ", progname)); - if (!quiet) perror(ofname); - } -#ifndef NO_CHOWN - chown(ofname, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */ -#endif - remove_ofname = 0; - /* It's now safe to remove the input file: */ - (void) chmod(ifname, 0777); - if (unlink(ifname)) { - WARN((stderr, "%s: ", progname)); - if (!quiet) perror(ifname); - } -} - -#ifndef NO_DIR - -/* ======================================================================== - * Recurse through the given directory. This code is taken from ncompress. - */ -local void treat_dir(dir) - char *dir; -{ - dir_type *dp; - DIR *dirp; - char nbuf[MAX_PATH_LEN]; - - dirp = opendir(dir); - - if (dirp == NULL) { - fprintf(stderr, "%s: %s unreadable\n", progname, dir); - exit_code = ERROR; - return ; - } - /* - ** WARNING: the following algorithm could occasionally cause - ** compress to produce error warnings of the form ".z - ** already has .z suffix - ignored". This occurs when the - ** .z output file is inserted into the directory below - ** readdir's current pointer. - ** These warnings are harmless but annoying, so they are suppressed - ** with option -r (except when -v is on). An alternative - ** to allowing this would be to store the entire directory - ** list in memory, then compress the entries in the stored - ** list. Given the depth-first recursive algorithm used here, - ** this could use up a tremendous amount of memory. I don't - ** think it's worth it. -- Dave Mack - ** (An other alternative might be two passes to avoid depth-first.) - */ - - while ((dp = readdir(dirp)) != NULL) { - - if (strequ(dp->d_name,".") || strequ(dp->d_name,"..")) { - continue; - } - if (((int)strlen(dir) + NLENGTH(dp) + 1) < (MAX_PATH_LEN - 1)) { - strcpy(nbuf,dir); - if (strlen(dir) != 0) { /* dir = "" means current dir on Amiga */ -#ifdef OTHER_PATH_SEP - if (dir[strlen(dir)-1] != OTHER_PATH_SEP) -#endif - strcat(nbuf,"/"); - } - strcat(nbuf,dp->d_name); - treat_file(nbuf); - } else { - fprintf(stderr,"%s: %s/%s: pathname too long\n", - progname, dir, dp->d_name); - exit_code = ERROR; - } - } - closedir(dirp); -} -#endif /* ? NO_DIR */ - -/* ======================================================================== - * Free all dynamically allocated variables and exit with the given code. - */ -local void do_exit(exitcode) - int exitcode; -{ - if (env != NULL) free(env), env = NULL; - if (args != NULL) free(args), args = NULL; - FREE(inbuf); - FREE(outbuf); - FREE(d_buf); - FREE(window); -#ifndef MAXSEG_64K - FREE(tab_prefix); -#else - FREE(tab_prefix0); - FREE(tab_prefix1); -#endif - exit(exitcode); -} - -/* ======================================================================== - * Signal and error handler. - */ -RETSIGTYPE abort_gzip() -{ - if (remove_ofname) { - close(ofd); - unlink (ofname); - } - do_exit(ERROR); -} diff --git a/gnu/usr.bin/gzip-1.0.7/gzip.doc b/gnu/usr.bin/gzip-1.0.7/gzip.doc deleted file mode 100644 index 1b8823fea265..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/gzip.doc +++ /dev/null @@ -1,214 +0,0 @@ - -GZIP(1) USER COMMANDS GZIP(1) - -NAME - gzip, gunzip, zcat - compress or expand files - -SYNOPSIS - gzip [ -cdfhLrtvV19 ] [ name ... ] - gunzip [ -cfhLrtvV ] [ name ... ] - zcat [ -hLV ] [ name ... ] - -DESCRIPTION - Gzip reduces the size of the named files using Lempel-Ziv - coding (LZ77). Whenever possible, each file is replaced by - one with the extension .z, while keeping the same ownership - modes, access and modification times. (The extension is -z - for VMS, z for MSDOS, OS/2 and Atari.) If no files are - specified, the standard input is compressed to the standard - output. If the new file name is too long, gzip truncates it - and keeps the original file name in the compressed file. - Gzip will only attempt to compress regular files. In par- - ticular, it will ignore symbolic links. - - Compressed files can be restored to their original form - using gzip -d or gunzip or zcat. - - gunzip takes a list of files on its command line and - replaces each file whose name ends with .z or .Z or -z and - which begins with the correct magic number with an - uncompressed file without the original extension. gunzip - also recognizes the special extensions .tgz and .taz as - shorthands for .tar.z or .tar.Z - - gunzip can currently decompress files created by gzip, zip, - compress or pack. The detection of the input format is - automatic. When using the first two formats, gunzip checks - a 32 bit CRC. For pack, gunzip checks the uncompressed - length. The compress format was not designed to allow con- - sistency checks. However gunzip is sometimes able to detect - a bad .Z file. If you get an error when uncompressing a .Z - file, do not assume that the .Z file is correct simply - because the standard uncompress does not complain. This gen- - erally means that the standard uncompress does not check its - input, and happily generates garbage output. - - Files created by zip can be uncompressed by gzip only if - they have a single member compressed with the 'deflation' - method. This feature is only intended to help conversion of - tar.zip files to the tar.z format. To extract zip files with - several members, use unzip instead of gunzip. - - zcat is identical to gunzip -c. (On some systems, zcat may - be installed as gzcat to preserve the original link to - compress.) zcat uncompresses either a list of files on the - command line or its standard input and writes the - uncompressed data on standard output. zcat will uncompress - files that have the correct magic number whether they have a - .z suffix or not. - - Gzip uses the Lempel-Ziv algorithm used in zip and PKZIP. - The amount of compression obtained depends on the size of - the input and the distribution of common substrings. Typi- - cally, text such as source code or English is reduced by - 60-70%. Compression is generally much better than that - achieved by LZW (as used in compress), Huffman coding (as - used in pack), or adaptive Huffman coding (compact). - - Compression is always performed, even if the compressed file - is slightly larger than the original. The worst case expan- - sion is a few bytes for the gzip file header, plus 5 bytes - every 32K block, or an expansion ratio of 0.015% for large - files. gzip preserves the mode, ownership and timestamps of - files when compressing or decompressing. - -OPTIONS - -c --stdout - Write output on standard output; keep original files - unchanged. If there are several input files, the out- - put consists of a sequence of independently compressed - members. To obtain better compression, concatenate all - input files before compressing them. - - -d --decompress - Decompress. - - -f --force - Force compression or decompression even if the file has - multiple links or the corresponding file already - exists. If -f is not given, and when not running in - the background, gzip prompts to verify whether an - existing file should be overwritten. - - -h --help - Display a help screen. - - -L --license - Display the gzip license. - - -q --quiet - Suppress all warnings. - - -r --recurse - Travel the directory structure recursively. If any of - the file names specified on the command line are direc- - tories, gzip will descend into the directory and - compress all the files it finds there (or decompress - them in the case of gunzip ). - - -t --test - Test. Check the compressed file integrity. - - -v --verbose - Verbose. Display the name and percentage reduction for - each file compressed. - - -V --version - Version. Display the version number and compilation - options. - - -# --fast --best - Regulate the speed of compression using the specified - digit #, where -1 or --fast indicates the fastest - compression method (less compression) and -9 or --best - indicates the slowest compression method (optimal - compression). The default compression level is -5. - -ADVANCED USAGE - Multiple compressed files can be concatenated. In this case, - gunzip will extract all members at once. For example: - - gzip -c file1 > foo.z - gzip -c file2 >> foo.z Then - gunzip -c foo - - is equivalent to - - cat file1 file2 - - In case of damage to one member of a .z file, other members - can still be recovered (if the damaged member is removed). - However, you can get better compression by compressing all - members at once: - - cat file1 file2 | gzip > foo.z - - compresses better than - - gzip -c file1 file2 > foo.z - - If you want to recompress concatenated files to get better - compression, do: - - zcat old.z | gzip > new.z - -ENVIRONMENT - The environment variable GZIP can hold a set of default - options for gzip. These options are interpreted first and - can be overwritten by explicit command line parameters. For - example: - for sh: GZIP="-8 -v"; export GZIP - for csh: setenv GZIP "-8 -v" - for MSDOS: set GZIP=-8 -v - - On Vax/VMS, the name of the environment variable is - GZIP_OPT, to avoid a conflict with the symbol set for invo- - cation of the program. - -SEE ALSO - znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1), - unzip(1), compress(1), pack(1), compact(1) - -DIAGNOSTICS - Exit status is normally 0; if an error occurs, exit status - is 1. If a warning occurs, exit status is 2. - - Usage: gzip [-cdfhLrtvV19] [file ...] - Invalid options were specified on the command line. - file: not in gzip format - The file specified to gunzip has not been - compressed. - file: Corrupt input. Use zcat to recover some data. - The compressed file has been damaged. The data up to - the point of failure can be recovered using - zcat file > recover - file: compressed with xx bits, can only handle yy bits - File was compressed (using LZW) by a program that - could deal with more bits than the decompress code - on this machine. Recompress the file with gzip, - which compresses better and uses less memory. - file: already has z suffix -- no change - The file is assumed to be already compressed. - Rename the file and try again or use zcat. - file already exists; do you wish to overwrite (y or n)? - Respond "y" if you want the output file to be - replaced; "n" if not. - gunzip: corrupt input - A SIGSEGV violation was detected which usually means - that the input file has been corrupted. - xx.x% - Percentage of the input saved by compression. - (Relevant only for -v.) - -- not a regular file or directory: ignored - When the input file is not a regular file or direc- - tory, (e.g. a symbolic link, socket, FIFO, device - file), it is left unaltered. - -- has xx other links: unchanged - The input file has links; it is left unchanged. See - ln(1) for more information. Use the -f flag to force - compression of multiply-linked files. - -CAVEATS - The .z extension is already used by pack(1). You can link - gzip to pcat to get transparent decompression for programs - expecting .z files to be in pack format. diff --git a/gnu/usr.bin/gzip-1.0.7/gzip.h b/gnu/usr.bin/gzip-1.0.7/gzip.h deleted file mode 100644 index 42a308d5bafd..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/gzip.h +++ /dev/null @@ -1,288 +0,0 @@ -/* gzip.h -- common declarations for all gzip modules - * Copyright (C) 1992-1993 Jean-loup Gailly. - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#if defined(__STDC__) || defined(PROTO) -# define OF(args) args -#else -# define OF(args) () -#endif - -#ifdef __STDC__ - typedef void *voidp; -#else - typedef char *voidp; -#endif - -/* I don't like nested includes, but the string functions are used too often */ -#if !defined(NO_STRING_H) || defined(STDC_HEADERS) -# include -# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) -# include -# endif -# define memzero(s, n) memset ((voidp)(s), 0, (n)) -#else -# include -# define strchr index -# define strrchr rindex -# define memcpy(d, s, n) bcopy((s), (d), (n)) -# define memcmp(s1, s2, n) bcmp((s1), (s2), (n)) -# define memzero(s, n) bzero((s), (n)) -#endif - -#ifndef RETSIGTYPE -# define RETSIGTYPE void -#endif - -#define local static - -typedef unsigned char uch; -typedef unsigned short ush; -typedef unsigned long ulg; - -/* Return codes from gzip */ -#define OK 0 -#define ERROR 1 -#define WARNING 2 - -/* Compression methods (see algorithm.doc) */ -#define STORED 0 -#define COMPRESSED 1 -#define PACKED 2 -/* methods 3 to 7 reserved */ -#define DEFLATED 8 -extern int method; /* compression method */ - -/* To save memory for 16 bit systems, some arrays are overlaid between - * the various modules: - * deflate: prev+head window d_buf l_buf outbuf - * unlzw: tab_prefix tab_suffix stack inbuf outbuf - * inflate: window inbuf - * unpack: window inbuf - * For compression, input is done in window[]. For decompression, output - * is done in window except for unlzw. - */ - -#ifndef INBUFSIZ -# define INBUFSIZ 0x8000 /* input buffer size */ -#endif -#define INBUF_EXTRA 64 /* required by unlzw() */ - -#ifndef OUTBUFSIZ -# define OUTBUFSIZ 16384 /* output buffer size */ -#endif -#define OUTBUF_EXTRA 2048 /* required by unlzw() */ - -#define DIST_BUFSIZE 0x8000 /* buffer for distances, see trees.c */ - -#ifdef DYN_ALLOC -# define EXTERN(type, array) extern type * near array -# define DECLARE(type, array, size) type * near array -# define ALLOC(type, array, size) { \ - array = (type*)fcalloc((unsigned)(((size)+1L)/2), 2*sizeof(type)); \ - if (array == NULL) error("insufficient memory"); \ - } -# define FREE(array) {if (array != NULL) fcfree(array), array=NULL;} -#else -# define EXTERN(type, array) extern type array[] -# define DECLARE(type, array, size) type array[size] -# define ALLOC(type, array, size) -# define FREE(array) -#endif - -EXTERN(uch, inbuf); /* input buffer */ -EXTERN(uch, outbuf); /* output buffer */ -EXTERN(ush, d_buf); /* buffer for distances, see trees.c */ -EXTERN(uch, window); /* Sliding window and suffix table (unlzw) */ -#define tab_suffix window -#ifndef MAXSEG_64K -# define tab_prefix prev /* hash link (see deflate.c) */ -# define head (prev+WSIZE) /* hash head (see deflate.c) */ - EXTERN(ush, tab_prefix); /* prefix code (see unlzw.c) */ -#else -# define tab_prefix0 prev -# define head tab_prefix1 - EXTERN(ush, tab_prefix0); /* prefix for even codes */ - EXTERN(ush, tab_prefix1); /* prefix for odd codes */ -#endif - -extern unsigned insize; /* valid bytes in inbuf */ -extern unsigned inptr; /* index of next byte to be processed in inbuf */ -extern unsigned outcnt; /* bytes in output buffer */ - -extern long bytes_in; /* number of input bytes */ -extern long bytes_out; /* number of output bytes */ -extern long overhead; /* number of bytes in gzip header */ - -#define isize bytes_in -/* for compatibility with old zip sources (to be cleaned) */ - -extern int ifd; /* input file descriptor */ -extern int ofd; /* output file descriptor */ -extern char ifname[]; /* input filename or "stdin" */ -extern char ofname[]; /* output filename or "stdout" */ -extern char *progname; /* program name */ - -extern ulg time_stamp; /* original time stamp (modification time) */ -extern long ifile_size; /* input file size, -1 for devices (debug only) */ - -typedef int file_t; /* Do not use stdio */ -#define NO_FILE (-1) /* in memory compression */ - - -#define GZIP_MAGIC "\037\213" /* Magic header for gzip files, 1F 8B */ -#define OLD_GZIP_MAGIC "\037\236" /* Magic header for gzip 0.5 = freeze 1.x */ -#define PKZIP_MAGIC "PK\003\004" /* Magic header for pkzip files */ -#define PACK_MAGIC "\037\036" /* Magic header for packed files */ - -/* gzip flag byte */ -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ -#define RESERVED 0xC0 /* bit 6,7: reserved */ - -/* internal file attribute */ -#define UNKNOWN 0xffff -#define BINARY 0 -#define ASCII 1 - -#ifndef WSIZE -# define WSIZE 0x8000 /* window size--must be a power of two, and */ -#endif /* at least 32K for zip's deflate method */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST (WSIZE-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - -extern int decrypt; /* flag to turn on decryption */ -extern int exit_code; /* program exit code */ -extern int verbose; /* be verbose (-v) */ -extern int quiet; /* be quiet (-q) */ -extern int level; /* compression level */ -extern int test; /* check .z file integrity */ -extern int to_stdout; /* output to stdout (-c) */ -extern int save_orig_name; /* set if original name must be saved */ - -#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) - -/* put_byte is used for the compressed output, put_char for the - * uncompressed output. However unlzw() uses window for its - * suffix table instead of its output buffer, so it does not use put_char. - * (to be cleaned up). - */ -#define put_byte(c) {outbuf[outcnt++]=(uch)(c); if (outcnt==OUTBUFSIZ)\ - flush_outbuf();} -#define put_char(c) {window[outcnt++]=(uch)(c); if (outcnt==WSIZE)\ - flush_window();} - -/* Output a 16 bit value, lsb first */ -#define put_short(w) \ -{ if (outcnt < OUTBUFSIZ-2) { \ - outbuf[outcnt++] = (uch) ((w) & 0xff); \ - outbuf[outcnt++] = (uch) ((ush)(w) >> 8); \ - } else { \ - put_byte((uch)((w) & 0xff)); \ - put_byte((uch)((ush)(w) >> 8)); \ - } \ -} - -/* Output a 32 bit value to the bit stream, lsb first */ -#define put_long(n) { \ - put_short((n) & 0xffff); \ - put_short(((ulg)(n)) >> 16); \ -} - -#define seekable() 0 /* force sequential output */ -#define translate_eol 0 /* no option -a yet */ - -#define tolow(c) (isupper(c) ? (c)-'A'+'a' : (c)) /* force to lower case */ - -/* Macros for getting two-byte and four-byte header values */ -#define SH(p) ((ush)(uch)((p)[0]) | ((ush)(uch)((p)[1]) << 8)) -#define LG(p) ((ulg)(SH(p)) | ((ulg)(SH((p)+2)) << 16)) - -/* Diagnostic functions */ -#ifdef DEBUG -# define Assert(cond,msg) {if(!(cond)) error(msg);} -# define Trace(x) fprintf x -# define Tracev(x) {if (verbose) fprintf x ;} -# define Tracevv(x) {if (verbose>1) fprintf x ;} -# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} -# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - -#define WARN(msg) {if (!quiet) fprintf msg ; \ - if (exit_code == OK) exit_code = WARNING;} - - /* in zip.c: */ -extern void zip OF((int in, int out)); -extern int file_read OF((char *buf, unsigned size)); - - /* in unzip.c */ -extern void unzip OF((int in, int out)); -extern int check_zipfile OF((int in)); - - /* in unpack.c */ -extern void unpack OF((int in, int out)); - - /* in gzip.c */ -RETSIGTYPE abort_gzip OF((void)); - - /* in deflate.c */ -void lm_init OF((int pack_level, ush *flags)); -ulg deflate OF((void)); - - /* in trees.c */ -void ct_init OF((ush *attr, int *method)); -int ct_tally OF((int dist, int lc)); -ulg flush_block OF((char *buf, ulg stored_len, int eof)); - - /* in bits.c */ -void bi_init OF((file_t zipfile)); -void send_bits OF((int value, int length)); -unsigned bi_reverse OF((unsigned value, int length)); -void bi_windup OF((void)); -void copy_block OF((char *buf, unsigned len, int header)); -extern int (*read_buf) OF((char *buf, unsigned size)); - - /* in util.c: */ -extern ulg updcrc OF((uch *s, unsigned n)); -extern void clear_bufs OF((void)); -extern int fill_inbuf OF((void)); -extern void flush_outbuf OF((void)); -extern void flush_window OF((void)); -extern void write_buf OF((int fd, voidp buf, unsigned cnt)); -extern char *strlwr OF((char *s)); -extern char *basename OF((char *fname)); -extern char *add_envopt OF((int *argcp, char ***argvp, char *env)); -extern void error OF((char *m)); -extern void warn OF((char *a, char *b)); -extern void read_error OF((void)); -extern void write_error OF((void)); -extern void display_ratio OF((long num, long den)); -extern voidp xmalloc OF((unsigned int size)); - - /* in inflate.c */ -extern int inflate OF((void)); diff --git a/gnu/usr.bin/gzip-1.0.7/gzip.info b/gnu/usr.bin/gzip-1.0.7/gzip.info deleted file mode 100644 index a0c44e2fbcaa..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/gzip.info +++ /dev/null @@ -1,678 +0,0 @@ -Info file gzip.info, produced by Makeinfo, -*- Text -*- from input -file gzip.texi. - - This file documents the the GNU `gzip' command for compressing -files. - - Copyright (C) 1992-1993 Jean-loup Gailly - - 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. - - -File: gzip.info, Node: Top, Up: (dir) - - This file documents the `gzip' command to compress files. - -* Menu: - -* Copying:: How you can copy and share `gzip'. -* Overview:: Preliminary information. -* Sample:: Sample output from `gzip'. -* Invoking gzip:: How to run `gzip'. -* Advanced usage:: Concatenated files. -* Environment:: The `GZIP' environment variable -* Problems:: Reporting bugs. -* Concept Index:: Index of concepts. - - -File: gzip.info, Node: Copying, Next: Overview, Up: Top - -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. - - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 1. 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. - - 2. 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. - - 3. 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: - - 1. You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any - change. - - 2. 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. - - 3. 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. - - 4. 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: - - 1. 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, - - 2. 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, - - 3. 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. - - 5. 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. - - 6. 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. - - 7. 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. - - 8. 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. - - 9. 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. - - 10. 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. - - 11. 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 - - 12. 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. - - 13. 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 - -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. - - ONE LINE TO GIVE THE PROGRAM'S NAME AND AN IDEA OF WHAT IT DOES. - Copyright (C) 19YY NAME OF AUTHOR - - 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. - - SIGNATURE OF TY COON, 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. - - -File: gzip.info, Node: Overview, Next: Sample, Prev: Copying, Up: Top - -Overview -******** - - `Gzip' reduces the size of the named files using Lempel-Ziv coding -(LZ77). Whenever possible, each file is replaced by one with the -extension ".z", while keeping the same ownership modes, access and -modification times. (The extension is "-z" for VMS, "z" for MSDOS, -OS/2 and Atari.) If no files are specified, the standard input is -compressed to the standard output. If the new file name is too long, -`gzip' truncates it and keeps the original file name in the compressed -file. `gzip' will only attempt to compress regular files. In -particular, it will ignore symbolic links. - - Compressed files can be restored to their original form using -"`gzip' -d" or `gunzip' or `zcat'. - - `gunzip' takes a list of files on its command line and replaces -each file whose name ends with ".z" or ".Z" and which begins with the -correct magic number with an uncompressed file without the original -extension. `gunzip' also recognizes the special extensions ".tgz" and -".taz" as shorthands for ".tar.z" or ".tar.Z". - - `gunzip' can currently decompress files created by `gzip', `zip', -`compress' or `pack'. The detection of the input format is automatic. -When using the first two formats, `gunzip' checks a 32 bit CRC (cyclic -redundancy check). For `pack', `gunzip' checks the uncompressed -length. The `compress' format was not designed to allow consistency -checks. However `gunzip' is sometimes able to detect a bad .Z file. If -you get an error when uncompressing a .Z file, do not assume that the -.Z file is correct simply because the standard `uncompress' does not -complain. This generally means that the standard `uncompress' does -not check its input, and happily generates garbage output. - - Files created by `zip' can be uncompressed by `gzip' only if they -have a single member compressed with the 'deflation' method. This -feature is only intended to help conversion of `tar.zip' files to the -`tar.z' format. To extract `zip' files with several members, use -`unzip' instead of `gunzip'. - - `zcat' is identical to "`gunzip' -c". `zcat' uncompresses either a -list of files on the command line or its standard input and writes the -uncompressed data on standard output. `zcat' will uncompress files -that have the correct magic number whether they have a ".z" suffix or -not. - - `gzip' uses the Lempel-Ziv algorithm used in `zip' and PKZIP. The -amount of compression obtained depends on the size of the input and -the distribution of common substrings. Typically, text such as source -code or English is reduced by 60-70%. Compression is generally much -better than that achieved by LZW (as used in `compress'), Huffman -coding (as used in `pack'), or adaptive Huffman coding (`compact'). - - Compression is always performed, even if the compressed file is -slightly larger than the original. The worst case expansion is a few -bytes for the gzip file header, plus 5 bytes every 32K block, or an -expansion ratio of 0.015% for large files. `gzip' preserves the mode, -ownership and timestamps of files when compressing or decompressing. - - -File: gzip.info, Node: Sample, Next: Invoking gzip, Prev: Overview, Up: Top - -Sample Output -************* - - Here are some realistic examples of running `gzip'. - - This is the output of the command `gzip': - - usage: gzip [-cdfhLrv19] [file ...] - For more help, type: gzip -h - - This is the output of the command `gzip -h': - - gzip 1.0.7 (18 Mar 93) - usage: gzip [-cdfhLrtvV19] [file ...] - -c --stdout write on standard output, keep original files unchanged - -d --decompress decompress - -f --force force overwrite of output file and compress links - -h --help give this help - -L --license display software license - -q --quiet suppress all warnings - -r --recurse recurse through directories - -t --test test compressed file integrity (implies -d) - -v --verbose verbose mode - -V --version display version number - -1 --fast compress faster - -9 --best compress better - file... files to (de)compress. If none given, use standard input - - This is the output of the command `gzip -v gzip.c': - - gzip.c: 69.8% -- replaced with gzip.c.z - - -File: gzip.info, Node: Invoking gzip, Next: Advanced usage, Prev: Sample, Up: Top - -Invoking `gzip' -*************** - - The format for running the `gzip' program is: - - gzip OPTION ... - - `gzip' supports the following options: - -`--help' -`-h' - Print an informative help message describing the options. - -`--stdout' -`-c' - Write output on standard output; keep original files unchanged. - If there are several input files, the output consists of a - sequence of independently compressed members. To obtain better - compression, concatenate all input files before compressing them. - -`--decompress' -`-d' - Decompress. - -`--force' -`-f' - Force compression or decompression even if the file has multiple - links or the corresponding file already exists. If -f is not - given, and when not running in the background, `gzip' prompts to - verify whether an existing file should be overwritten. - -`--help' -`-h' - Display a help screen. - -`--license' -`-L' - Display the `gzip' license. - -`--recurse' -`-r' - Travel the directory structure recursively. If any of the file - names specified on the command line are directories, `gzip' will - descend into the directory and compress all the files it finds - there (or decompress them in the case of `gunzip'). - -`--test' -`-t' - Test. Check the compressed file integrity. - -`--verbose' -`-v' - Verbose. Display the name and percentage reduction for each file - compressed. - -`--version' -`-V' - Version. Display the version number and compilation options. - -`--fast' -`--best' -`-#' - Regulate the speed of compression using the specified digit #, - where -1 or --fast indicates the fastest compression method (less - compression) and --best or -9 indicates the slowest compression - method (optimal compression). The default compression level is - -5. - - -File: gzip.info, Node: Advanced usage, Next: Environment, Prev: Invoking gzip, Up: Top - -Advanced usage -************** - - Multiple compressed files can be concatenated. In this case, -`gunzip' will extract all members at once. If one member is damaged, -other members might still be recovered after removal of the damaged -member. Better compression can be usually obtained if all members are -decompressed then recompressed in a single step. - - This is an example of concatenating gzip files: - - gzip -c file1 > foo.z - gzip -c file2 >> foo.z - - Then - - gunzip -c foo - - is equivalent to - - cat file1 file2 - - In case of damage to one member of a .z file, other members can -still be recovered (if the damaged member is removed). However, you -can get better compression by compressing all members at once: - - cat file1 file2 | gzip > foo.z - - compresses better than - - gzip -c file1 file2 > foo.z - - If you want to recompress concatenated files to get better -compression, do: - - zcat old.z | gzip > new.z - - -File: gzip.info, Node: Environment, Next: Problems, Prev: Advanced usage, Up: Top - -Environment -*********** - - The environment variable `GZIP' can hold a set of default options -for gzip. These options are interpreted first and can be overwritten -by explicit command line parameters. For example: - - for sh: GZIP="-8 -v"; export GZIP - for csh: setenv GZIP "-8 -v" - for MSDOS: set GZIP=-8 -v - - On Vax/VMS, the name of the environment variable is `GZIP_OPT', to -avoid a conflict with the symbol set for invocation of the program. - - -File: gzip.info, Node: Problems, Next: Concept Index, Prev: Environment, Up: Top - -Reporting Bugs -************** - - If you find a bug in `gzip', please send electronic mail to -`jloup@chorus.fr' or, if this fails, to -`bug-gnu-utils@prep.ai.mit.edu'. Include the version number, which -you can find by running `gzip -V'. Also include in your message the -hardware and operating system, the compiler used to compile, a -description of the bug behavior, and the input to gzip that triggered -the bug. - - -File: gzip.info, Node: Concept Index, Prev: Problems, Up: Top - -Concept Index -************* - -* Menu: - -* Environment: Environment. -* bugs: Problems. -* concatenated files: Advanced usage. -* invoking: Invoking gzip. -* options: Invoking gzip. -* overview: Overview. -* sample: Sample. - - - -Tag Table: -Node: Top864 -Node: Copying1297 -Node: Overview20555 -Node: Sample23686 -Node: Invoking gzip24890 -Node: Advanced usage26752 -Node: Environment27788 -Node: Problems28342 -Node: Concept Index28844 - -End Tag Table diff --git a/gnu/usr.bin/gzip-1.0.7/gzip.texi b/gnu/usr.bin/gzip-1.0.7/gzip.texi deleted file mode 100644 index 22ce28348ab3..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/gzip.texi +++ /dev/null @@ -1,339 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header -@setfilename gzip.info -@settitle Gzip User's Manual -@finalout -@setchapternewpage odd -@c %**end of header - -@ifinfo -This file documents the the GNU @code{gzip} command for compressing files. - -Copyright (C) 1992-1993 Jean-loup Gailly - -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 gzip -@subtitle The data compression program -@subtitle Edition 1.0.7, for Gzip Version 1.0.7 -@subtitle March 1993 -@author by Jean-loup Gailly - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1992-1993 Jean-loup Gailly - -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) - -@ifinfo -This file documents the @code{gzip} command to compress files. -@end ifinfo - -@menu -* Copying:: How you can copy and share @code{gzip}. -* Overview:: Preliminary information. -* Sample:: Sample output from @code{gzip}. -* Invoking gzip:: How to run @code{gzip}. -* Advanced usage:: Concatenated files. -* Environment:: The @code{GZIP} environment variable -* Problems:: Reporting bugs. -* Concept Index:: Index of concepts. -@end menu - -@node Copying, Overview, , Top -@include gpl.texinfo - -@node Overview, Sample, Copying, Top -@chapter Overview -@cindex overview - -@code{Gzip} reduces the size of the named files using Lempel-Ziv coding -(LZ77). Whenever possible, each file is replaced by one with the -extension ".z", while keeping the same ownership modes, access and -modification times. (The extension is "-z" for VMS, "z" for MSDOS, OS/2 -and Atari.) If no files are specified, the standard input is compressed -to the standard output. If the new file name is too long, @code{gzip} -truncates it and keeps the original file name in the compressed file. -@code{gzip} will only attempt to compress regular files. In particular, -it will ignore symbolic links. - -Compressed files can be restored to their original form using -"@code{gzip} -d" or @code{gunzip} or @code{zcat}. - -@code{gunzip} takes a list of files on its command line and replaces -each file whose name ends with ".z" or ".Z" and which begins with the -correct magic number with an uncompressed file without the original -extension. @code{gunzip} also recognizes the special extensions ".tgz" -and ".taz" as shorthands for ".tar.z" or ".tar.Z". - -@code{gunzip} can currently decompress files created by @code{gzip}, -@code{zip}, @code{compress} or @code{pack}. The detection of the input -format is automatic. When using the first two formats, @code{gunzip} -checks a 32 bit CRC (cyclic redundancy check). For @code{pack}, -@code{gunzip} checks the uncompressed length. The @code{compress} -format was not designed to allow consistency checks. However @code{gunzip} -is sometimes able to detect a bad .Z file. If you get an error -when uncompressing a .Z file, do not assume that the .Z file is -correct simply because the standard @code{uncompress} does not complain. -This generally means that the standard @code{uncompress} does not check its -input, and happily generates garbage output. - -Files created by @code{zip} can be uncompressed by @code{gzip} only if -they have a single member compressed with the 'deflation' method. This -feature is only intended to help conversion of @code{tar.zip} files to -the @code{tar.z} format. To extract @code{zip} files with several -members, use @code{unzip} instead of @code{gunzip}. - -@code{zcat} is identical to "@code{gunzip} -c". @code{zcat} -uncompresses either a list of files on the command line or its standard -input and writes the uncompressed data on standard output. @code{zcat} -will uncompress files that have the correct magic number whether they -have a ".z" suffix or not. - -@code{gzip} uses the Lempel-Ziv algorithm used in @code{zip} and PKZIP. -The amount of compression obtained depends on the size of the input and -the distribution of common substrings. Typically, text such as source -code or English is reduced by 60-70%. Compression is generally much -better than that achieved by LZW (as used in @code{compress}), Huffman -coding (as used in @code{pack}), or adaptive Huffman coding -(@code{compact}). - -Compression is always performed, even if the compressed file is slightly -larger than the original. The worst case expansion is a few bytes for -the gzip file header, plus 5 bytes every 32K block, or an expansion -ratio of 0.015% for large files. @code{gzip} preserves the mode, -ownership and timestamps of files when compressing or decompressing. - -@node Sample, Invoking gzip, Overview, Top -@chapter Sample Output -@cindex sample - -Here are some realistic examples of running @code{gzip}. - -This is the output of the command @samp{gzip}: - -@example -usage: gzip [-cdfhLrv19] [file ...] -For more help, type: gzip -h -@end example - -This is the output of the command @samp{gzip -h}: - -@example -gzip 1.0.7 (18 Mar 93) -usage: gzip [-cdfhLrtvV19] [file ...] - -c --stdout write on standard output, keep original files unchanged - -d --decompress decompress - -f --force force overwrite of output file and compress links - -h --help give this help - -L --license display software license - -q --quiet suppress all warnings - -r --recurse recurse through directories - -t --test test compressed file integrity (implies -d) - -v --verbose verbose mode - -V --version display version number - -1 --fast compress faster - -9 --best compress better - file... files to (de)compress. If none given, use standard input -@end example - -This is the output of the command @samp{gzip -v gzip.c}: - -@example -gzip.c: 69.8% -- replaced with gzip.c.z -@end example - -@node Invoking gzip, Advanced usage, Sample, Top -@chapter Invoking @code{gzip} -@cindex invoking -@cindex options - -The format for running the @code{gzip} program is: - -@example -gzip @var{option} @dots{} -@end example - -@code{gzip} supports the following options: - -@table @samp -@item --help -@itemx -h -Print an informative help message describing the options. - -@item --stdout -@itemx -c -Write output on standard output; keep original files unchanged. -If there are several input files, the output consists of a sequence of -independently compressed members. To obtain better compression, -concatenate all input files before compressing them. - -@item --decompress -@itemx -d -Decompress. - -@item --force -@itemx -f -Force compression or decompression even if the file has multiple links -or the corresponding file already exists. If -f is not given, and -when not running in the background, @code{gzip} prompts to verify -whether an existing file should be overwritten. - -@item --help -@itemx -h -Display a help screen. - -@item --license -@itemx -L -Display the @code{gzip} license. - -@item --recurse -@itemx -r -Travel the directory structure recursively. If any of the file names -specified on the command line are directories, @code{gzip} will descend -into the directory and compress all the files it finds there (or -decompress them in the case of @code{gunzip}). - -@item --test -@itemx -t -Test. Check the compressed file integrity. - -@item --verbose -@itemx -v -Verbose. Display the name and percentage reduction for each file compressed. - -@item --version -@itemx -V -Version. Display the version number and compilation options. - -@item --fast -@itemx --best -@itemx -# -Regulate the speed of compression using the specified digit #, where -1 -or --fast indicates the fastest compression method (less compression) -and --best or -9 indicates the slowest compression method (optimal -compression). The default compression level is -5. -@end table - -@node Advanced usage, Environment, Invoking gzip, Top -@chapter Advanced usage -@cindex concatenated files - -Multiple compressed files can be concatenated. In this case, -@code{gunzip} will extract all members at once. If one member is -damaged, other members might still be recovered after removal of the -damaged member. Better compression can be usually obtained if all -members are decompressed then recompressed in a single step. - -This is an example of concatenating gzip files: - -@example -gzip -c file1 > foo.z -gzip -c file2 >> foo.z -@end example - -Then - -@example -gunzip -c foo -@end example - -is equivalent to - -@example -cat file1 file2 -@end example - -In case of damage to one member of a .z file, other members can -still be recovered (if the damaged member is removed). However, -you can get better compression by compressing all members at once: - -@example -cat file1 file2 | gzip > foo.z -@end example - -compresses better than - -@example -gzip -c file1 file2 > foo.z -@end example - -If you want to recompress concatenated files to get better compression, do: - -@example -zcat old.z | gzip > new.z -@end example - -@node Environment, Problems, Advanced usage, Top -@chapter Environment -@cindex Environment - -The environment variable @code{GZIP} can hold a set of default options for -gzip. These options are interpreted first and can be overwritten by -explicit command line parameters. For example: - -@example -for sh: GZIP="-8 -v"; export GZIP -for csh: setenv GZIP "-8 -v" -for MSDOS: set GZIP=-8 -v -@end example - -On Vax/VMS, the name of the environment variable is @code{GZIP_OPT}, to -avoid a conflict with the symbol set for invocation of the program. - -@node Problems, Concept Index, Environment, Top -@chapter Reporting Bugs -@cindex bugs - -If you find a bug in @code{gzip}, please send electronic mail to -@w{@samp{jloup@@chorus.fr}} or, if this fails, to -@w{@samp{bug-gnu-utils@@prep.ai.mit.edu}}. Include the version number, -which you can find by running @w{@samp{gzip -V}}. Also include in your -message the hardware and operating system, the compiler used to compile, -a description of the bug behavior, and the input to gzip that triggered -the bug.@refill - -@node Concept Index, , Problems, Top -@unnumbered Concept Index - -@printindex cp - -@shortcontents -@contents -@bye diff --git a/gnu/usr.bin/gzip-1.0.7/inflate.c b/gnu/usr.bin/gzip-1.0.7/inflate.c deleted file mode 100644 index 056a592f347c..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/inflate.c +++ /dev/null @@ -1,952 +0,0 @@ -/* inflate.c -- Not copyrighted 1992 by Mark Adler - version c10p1, 10 January 1993 */ - -/* You can do whatever you like with this source file, though I would - prefer that if you modify it and redistribute it that you include - comments to that effect with your name and the date. Thank you. - [The history has been moved to the file ChangeLog.] - */ - -/* - Inflate deflated (PKZIP's method 8 compressed) data. The compression - method searches for as much of the current string of bytes (up to a - length of 258) in the previous 32K bytes. If it doesn't find any - matches (of at least length 3), it codes the next byte. Otherwise, it - codes the length of the matched string and its distance backwards from - the current position. There is a single Huffman code that codes both - single bytes (called "literals") and match lengths. A second Huffman - code codes the distance information, which follows a length code. Each - length or distance code actually represents a base value and a number - of "extra" (sometimes zero) bits to get to add to the base value. At - the end of each deflated block is a special end-of-block (EOB) literal/ - length code. The decoding process is basically: get a literal/length - code; if EOB then done; if a literal, emit the decoded byte; if a - length then get the distance and emit the referred-to bytes from the - sliding window of previously emitted data. - - There are (currently) three kinds of inflate blocks: stored, fixed, and - dynamic. The compressor deals with some chunk of data at a time, and - decides which method to use on a chunk-by-chunk basis. A chunk might - typically be 32K or 64K. If the chunk is uncompressible, then the - "stored" method is used. In this case, the bytes are simply stored as - is, eight bits per byte, with none of the above coding. The bytes are - preceded by a count, since there is no longer an EOB code. - - If the data is compressible, then either the fixed or dynamic methods - are used. In the dynamic method, the compressed data is preceded by - an encoding of the literal/length and distance Huffman codes that are - to be used to decode this block. The representation is itself Huffman - coded, and so is preceded by a description of that code. These code - descriptions take up a little space, and so for small blocks, there is - a predefined set of codes, called the fixed codes. The fixed method is - used if the block codes up smaller that way (usually for quite small - chunks), otherwise the dynamic method is used. In the latter case, the - codes are customized to the probabilities in the current block, and so - can code it much better than the pre-determined fixed codes. - - The Huffman codes themselves are decoded using a mutli-level table - lookup, in order to maximize the speed of decoding plus the speed of - building the decoding tables. See the comments below that precede the - lbits and dbits tuning parameters. - */ - - -/* - Notes beyond the 1.93a appnote.txt: - - 1. Distance pointers never point before the beginning of the output - stream. - 2. Distance pointers can point back across blocks, up to 32k away. - 3. There is an implied maximum of 7 bits for the bit length table and - 15 bits for the actual data. - 4. If only one code exists, then it is encoded using one bit. (Zero - would be more efficient, but perhaps a little confusing.) If two - codes exist, they are coded using one bit each (0 and 1). - 5. There is no way of sending zero distance codes--a dummy must be - sent if there are none. (History: a pre 2.0 version of PKZIP would - store blocks with no distance codes, but this was discovered to be - too harsh a criterion.) Valid only for 1.93a. 2.04c does allow - zero distance codes, which is sent as one code of zero bits in - length. - 6. There are up to 286 literal/length codes. Code 256 represents the - end-of-block. Note however that the static length tree defines - 288 codes just to fill out the Huffman codes. Codes 286 and 287 - cannot be used though, since there is no length base or extra bits - defined for them. Similarly, there are up to 30 distance codes. - However, static trees define 32 codes (all 5 bits) to fill out the - Huffman codes, but the last two had better not show up in the data. - 7. Unzip can check dynamic Huffman blocks for complete code sets. - The exception is that a single code would not be complete (see #4). - 8. The five bits following the block type is really the number of - literal codes sent minus 257. - 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits - (1+6+6). Therefore, to output three times the length, you output - three codes (1+1+1), whereas to output four times the same length, - you only need two codes (1+3). Hmm. - 10. In the tree reconstruction algorithm, Code = Code + Increment - only if BitLength(i) is not zero. (Pretty obvious.) - 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) - 12. Note: length code 284 can represent 227-258, but length code 285 - really is 258. The last length deserves its own, short code - since it gets used a lot in very redundant files. The length - 258 is special since 258 - 3 (the min match length) is 255. - 13. The literal/length and distance code bit lengths are read as a - single stream of lengths. It is possible (and advantageous) for - a repeat code (16, 17, or 18) to go across the boundary between - the two sets of lengths. - */ - -#ifndef lint -static char rcsid[] = "$Id: inflate.c,v 1.1 1993/04/10 15:56:06 cgd Exp $"; -#endif - -#include "tailor.h" -#include "gzip.h" -#define slide window - -#include - -#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H) -# include -# include -#endif - -/* Huffman code lookup table entry--this entry is four bytes for machines - that have 16-bit pointers (e.g. PC's in the small or medium model). - Valid extra bits are 0..13. e == 15 is EOB (end of block), e == 16 - means that v is a literal, 16 < e < 32 means that v is a pointer to - the next table, which codes e - 16 bits, and lastly e == 99 indicates - an unused code. If a code with e == 99 is looked up, this implies an - error in the data. */ -struct huft { - uch e; /* number of extra bits or operation */ - uch b; /* number of bits in this code or subcode */ - union { - ush n; /* literal, length base, or distance base */ - struct huft *t; /* pointer to next level of table */ - } v; -}; - - -/* Function prototypes */ -int huft_build OF((unsigned *, unsigned, unsigned, ush *, ush *, - struct huft **, int *)); -int huft_free OF((struct huft *)); -int inflate_codes OF((struct huft *, struct huft *, int, int)); -int inflate_stored OF((void)); -int inflate_fixed OF((void)); -int inflate_dynamic OF((void)); -int inflate_block OF((int *)); -int inflate OF((void)); - - -/* The inflate algorithm uses a sliding 32K byte window on the uncompressed - stream to find repeated byte strings. This is implemented here as a - circular buffer. The index is updated simply by incrementing and then - and'ing with 0x7fff (32K-1). */ -/* It is left to other modules to supply the 32K area. It is assumed - to be usable as if it were declared "uch slide[32768];" or as just - "uch *slide;" and then malloc'ed in the latter case. The definition - must be in unzip.h, included above. */ -/* unsigned wp; current position in slide */ -#define wp outcnt -#define flush_output(w) (wp=(w),flush_window()) - -/* Tables for deflate from PKZIP's appnote.txt. */ -static unsigned border[] = { /* Order of the bit length code lengths */ - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; -static ush cplens[] = { /* Copy lengths for literal codes 257..285 */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - /* note: see note #13 above about the 258 in this list. */ -static ush cplext[] = { /* Extra bits for literal codes 257..285 */ - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */ -static ush cpdist[] = { /* Copy offsets for distance codes 0..29 */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577}; -static ush cpdext[] = { /* Extra bits for distance codes */ - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, - 12, 12, 13, 13}; - - - -/* Macros for inflate() bit peeking and grabbing. - The usage is: - - NEEDBITS(j) - x = b & mask_bits[j]; - DUMPBITS(j) - - where NEEDBITS makes sure that b has at least j bits in it, and - DUMPBITS removes the bits from b. The macros use the variable k - for the number of bits in b. Normally, b and k are register - variables for speed, and are initialized at the beginning of a - routine that uses these macros from a global bit buffer and count. - - If we assume that EOB will be the longest code, then we will never - ask for bits with NEEDBITS that are beyond the end of the stream. - So, NEEDBITS should not read any more bytes than are needed to - meet the request. Then no bytes need to be "returned" to the buffer - at the end of the last block. - - However, this assumption is not true for fixed blocks--the EOB code - is 7 bits, but the other literal/length codes can be 8 or 9 bits. - (The EOB code is shorter than other codes becuase fixed blocks are - generally short. So, while a block always has an EOB, many other - literal/length codes have a significantly lower probability of - showing up at all.) However, by making the first table have a - lookup of seven bits, the EOB code will be found in that first - lookup, and so will not require that too many bits be pulled from - the stream. - */ - -ulg bb; /* bit buffer */ -unsigned bk; /* bits in bit buffer */ - -ush mask_bits[] = { - 0x0000, - 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff -}; - -#ifdef CRYPT - uch cc; -# define NEXTBYTE() \ - (decrypt ? (cc = get_byte(), zdecode(cc), cc) : get_byte()) -#else -# define NEXTBYTE() (uch)get_byte() -#endif -#define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE())<>=(n);k-=(n);} - - -/* - Huffman code decoding is performed using a multi-level table lookup. - The fastest way to decode is to simply build a lookup table whose - size is determined by the longest code. However, the time it takes - to build this table can also be a factor if the data being decoded - is not very long. The most common codes are necessarily the - shortest codes, so those codes dominate the decoding time, and hence - the speed. The idea is you can have a shorter table that decodes the - shorter, more probable codes, and then point to subsidiary tables for - the longer codes. The time it costs to decode the longer codes is - then traded against the time it takes to make longer tables. - - This results of this trade are in the variables lbits and dbits - below. lbits is the number of bits the first level table for literal/ - length codes can decode in one step, and dbits is the same thing for - the distance codes. Subsequent tables are also less than or equal to - those sizes. These values may be adjusted either when all of the - codes are shorter than that, in which case the longest code length in - bits is used, or when the shortest code is *longer* than the requested - table size, in which case the length of the shortest code in bits is - used. - - There are two different values for the two tables, since they code a - different number of possibilities each. The literal/length table - codes 286 possible values, or in a flat code, a little over eight - bits. The distance table codes 30 possible values, or a little less - than five bits, flat. The optimum values for speed end up being - about one bit more than those, so lbits is 8+1 and dbits is 5+1. - The optimum values may differ though from machine to machine, and - possibly even between compilers. Your mileage may vary. - */ - - -int lbits = 9; /* bits in base literal/length lookup table */ -int dbits = 6; /* bits in base distance lookup table */ - - -/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */ -#define BMAX 16 /* maximum bit length of any code (16 for explode) */ -#define N_MAX 288 /* maximum number of codes in any set */ - - -unsigned hufts; /* track memory usage */ - - -int huft_build(b, n, s, d, e, t, m) -unsigned *b; /* code lengths in bits (all assumed <= BMAX) */ -unsigned n; /* number of codes (assumed <= N_MAX) */ -unsigned s; /* number of simple-valued codes (0..s-1) */ -ush *d; /* list of base values for non-simple codes */ -ush *e; /* list of extra bits for non-simple codes */ -struct huft **t; /* result: starting table */ -int *m; /* maximum lookup bits, returns actual */ -/* Given a list of code lengths and a maximum table size, make a set of - tables to decode that set of codes. Return zero on success, one if - the given code set is incomplete (the tables are still built in this - case), two if the input is invalid (all zero length codes or an - oversubscribed set of lengths), and three if not enough memory. */ -{ - unsigned a; /* counter for codes of length k */ - unsigned c[BMAX+1]; /* bit length count table */ - unsigned f; /* i repeats in table every f entries */ - int g; /* maximum code length */ - int h; /* table level */ - register unsigned i; /* counter, current code */ - register unsigned j; /* counter */ - register int k; /* number of bits in current code */ - int l; /* bits per table (returned in m) */ - register unsigned *p; /* pointer into c[], b[], or v[] */ - register struct huft *q; /* points to current table */ - struct huft r; /* table entry for structure assignment */ - struct huft *u[BMAX]; /* table stack */ - unsigned v[N_MAX]; /* values in order of bit length */ - register int w; /* bits before this table == (l * h) */ - unsigned x[BMAX+1]; /* bit offsets, then code stack */ - unsigned *xp; /* pointer into x */ - int y; /* number of dummy codes added */ - unsigned z; /* number of entries in current table */ - - - /* Generate counts for each bit length */ - memzero(c, sizeof(c)); - p = b; i = n; - do { - Tracecv(*p, (stderr, (n-i >= ' ' && n-i <= '~' ? "%c %d\n" : "0x%x %d\n"), - n-i, *p)); - c[*p++]++; /* assume all entries <= BMAX */ - } while (--i); - if (c[0] == n) /* null input--all zero length codes */ - { - *t = (struct huft *)NULL; - *m = 0; - return 0; - } - - - /* Find minimum and maximum length, bound *m by those */ - l = *m; - for (j = 1; j <= BMAX; j++) - if (c[j]) - break; - k = j; /* minimum code length */ - if ((unsigned)l < j) - l = j; - for (i = BMAX; i; i--) - if (c[i]) - break; - g = i; /* maximum code length */ - if ((unsigned)l > i) - l = i; - *m = l; - - - /* Adjust last length count to fill out codes, if needed */ - for (y = 1 << j; j < i; j++, y <<= 1) - if ((y -= c[j]) < 0) - return 2; /* bad input: more codes than bits */ - if ((y -= c[i]) < 0) - return 2; - c[i] += y; - - - /* Generate starting offsets into the value table for each length */ - x[1] = j = 0; - p = c + 1; xp = x + 2; - while (--i) { /* note that i == g from above */ - *xp++ = (j += *p++); - } - - - /* Make a table of values in order of bit lengths */ - p = b; i = 0; - do { - if ((j = *p++) != 0) - v[x[j]++] = i; - } while (++i < n); - - - /* Generate the Huffman codes and for each, make the table entries */ - x[0] = i = 0; /* first Huffman code is zero */ - p = v; /* grab values in bit order */ - h = -1; /* no tables yet--level -1 */ - w = -l; /* bits decoded == (l * h) */ - u[0] = (struct huft *)NULL; /* just to keep compilers happy */ - q = (struct huft *)NULL; /* ditto */ - z = 0; /* ditto */ - - /* go through the bit lengths (k already is bits in shortest code) */ - for (; k <= g; k++) - { - a = c[k]; - while (a--) - { - /* here i is the Huffman code of length k bits for value *p */ - /* make tables up to required level */ - while (k > w + l) - { - h++; - w += l; /* previous table always l bits */ - - /* compute minimum size table less than or equal to l bits */ - z = (z = g - w) > (unsigned)l ? l : z; /* upper limit on table size */ - if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ - { /* too few codes for k-w bit table */ - f -= a + 1; /* deduct codes from patterns left */ - xp = c + k; - while (++j < z) /* try smaller tables up to z bits */ - { - if ((f <<= 1) <= *++xp) - break; /* enough codes to use up j bits */ - f -= *xp; /* else deduct codes from patterns */ - } - } - z = 1 << j; /* table entries for j-bit table */ - - /* allocate and link in new table */ - if ((q = (struct huft *)malloc((z + 1)*sizeof(struct huft))) == - (struct huft *)NULL) - { - if (h) - huft_free(u[0]); - return 3; /* not enough memory */ - } - hufts += z + 1; /* track memory usage */ - *t = q + 1; /* link to list for huft_free() */ - *(t = &(q->v.t)) = (struct huft *)NULL; - u[h] = ++q; /* table starts after link */ - - /* connect to last table, if there is one */ - if (h) - { - x[h] = i; /* save pattern for backing up */ - r.b = (uch)l; /* bits to dump before this table */ - r.e = (uch)(16 + j); /* bits in this table */ - r.v.t = q; /* pointer to this table */ - j = i >> (w - l); /* (get around Turbo C bug) */ - u[h-1][j] = r; /* connect to last table */ - } - } - - /* set up table entry in r */ - r.b = (uch)(k - w); - if (p >= v + n) - r.e = 99; /* out of values--invalid code */ - else if (*p < s) - { - r.e = (uch)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */ - r.v.n = *p++; /* simple code is just the value */ - } - else - { - r.e = (uch)e[*p - s]; /* non-simple--look up in lists */ - r.v.n = d[*p++ - s]; - } - - /* fill code-like entries with r */ - f = 1 << (k - w); - for (j = i >> w; j < z; j += f) - q[j] = r; - - /* backwards increment the k-bit code i */ - for (j = 1 << (k - 1); i & j; j >>= 1) - i ^= j; - i ^= j; - - /* backup over finished tables */ - while ((i & ((1 << w) - 1)) != x[h]) - { - h--; /* don't need to update q */ - w -= l; - } - } - } - - - /* Return true (1) if we were given an incomplete table */ - return y != 0 && g != 1; -} - - - -int huft_free(t) -struct huft *t; /* table to free */ -/* Free the malloc'ed tables built by huft_build(), which makes a linked - list of the tables it made, with the links in a dummy first entry of - each table. */ -{ - register struct huft *p, *q; - - - /* Go through linked list, freeing from the malloced (t[-1]) address. */ - p = t; - while (p != (struct huft *)NULL) - { - q = (--p)->v.t; - free(p); - p = q; - } - return 0; -} - - -int inflate_codes(tl, td, bl, bd) -struct huft *tl, *td; /* literal/length and distance decoder tables */ -int bl, bd; /* number of bits decoded by tl[] and td[] */ -/* inflate (decompress) the codes in a deflated (compressed) block. - Return an error code or zero if it all goes ok. */ -{ - register unsigned e; /* table entry flag/number of extra bits */ - unsigned n, d; /* length and index for copy */ - unsigned w; /* current window position */ - struct huft *t; /* pointer to table entry */ - unsigned ml, md; /* masks for bl and bd bits */ - register ulg b; /* bit buffer */ - register unsigned k; /* number of bits in bit buffer */ - - - /* make local copies of globals */ - b = bb; /* initialize bit buffer */ - k = bk; - w = wp; /* initialize window position */ - - /* inflate the coded data */ - ml = mask_bits[bl]; /* precompute masks for speed */ - md = mask_bits[bd]; - for (;;) /* do until end of block */ - { - NEEDBITS((unsigned)bl) - if ((e = (t = tl + ((unsigned)b & ml))->e) > 16) - do { - if (e == 99) - return 1; - DUMPBITS(t->b) - e -= 16; - NEEDBITS(e) - } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16); - DUMPBITS(t->b) - if (e == 16) /* then it's a literal */ - { - slide[w++] = (uch)t->v.n; - Tracevv((stderr, "%c", slide[w-1])); - if (w == WSIZE) - { - flush_output(w); - w = 0; - } - } - else /* it's an EOB or a length */ - { - /* exit if end of block */ - if (e == 15) - break; - - /* get length of block to copy */ - NEEDBITS(e) - n = t->v.n + ((unsigned)b & mask_bits[e]); - DUMPBITS(e); - - /* decode distance of block to copy */ - NEEDBITS((unsigned)bd) - if ((e = (t = td + ((unsigned)b & md))->e) > 16) - do { - if (e == 99) - return 1; - DUMPBITS(t->b) - e -= 16; - NEEDBITS(e) - } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16); - DUMPBITS(t->b) - NEEDBITS(e) - d = w - t->v.n - ((unsigned)b & mask_bits[e]); - DUMPBITS(e) - Tracevv((stderr,"\\[%d,%d]", w-d, n)); - - /* do the copy */ - do { - n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e); -#if !defined(NOMEMCPY) && !defined(DEBUG) - if (w - d >= e) /* (this test assumes unsigned comparison) */ - { - memcpy(slide + w, slide + d, e); - w += e; - d += e; - } - else /* do it slow to avoid memcpy() overlap */ -#endif /* !NOMEMCPY */ - do { - slide[w++] = slide[d++]; - Tracevv((stderr, "%c", slide[w-1])); - } while (--e); - if (w == WSIZE) - { - flush_output(w); - w = 0; - } - } while (n); - } - } - - - /* restore the globals from the locals */ - wp = w; /* restore global window pointer */ - bb = b; /* restore global bit buffer */ - bk = k; - - /* done */ - return 0; -} - - - -int inflate_stored() -/* "decompress" an inflated type 0 (stored) block. */ -{ - unsigned n; /* number of bytes in block */ - unsigned w; /* current window position */ - register ulg b; /* bit buffer */ - register unsigned k; /* number of bits in bit buffer */ - - - /* make local copies of globals */ - b = bb; /* initialize bit buffer */ - k = bk; - w = wp; /* initialize window position */ - - - /* go to byte boundary */ - n = k & 7; - DUMPBITS(n); - - - /* get the length and its complement */ - NEEDBITS(16) - n = ((unsigned)b & 0xffff); - DUMPBITS(16) - NEEDBITS(16) - if (n != (unsigned)((~b) & 0xffff)) - return 1; /* error in compressed data */ - DUMPBITS(16) - - - /* read and output the compressed data */ - while (n--) - { - NEEDBITS(8) - slide[w++] = (uch)b; - if (w == WSIZE) - { - flush_output(w); - w = 0; - } - DUMPBITS(8) - } - - - /* restore the globals from the locals */ - wp = w; /* restore global window pointer */ - bb = b; /* restore global bit buffer */ - bk = k; - return 0; -} - - - -int inflate_fixed() -/* decompress an inflated type 1 (fixed Huffman codes) block. We should - either replace this with a custom decoder, or at least precompute the - Huffman tables. */ -{ - int i; /* temporary variable */ - struct huft *tl; /* literal/length code table */ - struct huft *td; /* distance code table */ - int bl; /* lookup bits for tl */ - int bd; /* lookup bits for td */ - unsigned l[288]; /* length list for huft_build */ - - - /* set up literal table */ - for (i = 0; i < 144; i++) - l[i] = 8; - for (; i < 256; i++) - l[i] = 9; - for (; i < 280; i++) - l[i] = 7; - for (; i < 288; i++) /* make a complete, but wrong code set */ - l[i] = 8; - bl = 7; - if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0) - return i; - - - /* set up distance table */ - for (i = 0; i < 30; i++) /* make an incomplete code set */ - l[i] = 5; - bd = 5; - if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1) - { - huft_free(tl); - return i; - } - - - /* decompress until an end-of-block code */ - if (inflate_codes(tl, td, bl, bd)) - return 1; - - - /* free the decoding tables, return */ - huft_free(tl); - huft_free(td); - return 0; -} - - - -int inflate_dynamic() -/* decompress an inflated type 2 (dynamic Huffman codes) block. */ -{ - int i; /* temporary variables */ - unsigned j; - unsigned l; /* last length */ - unsigned m; /* mask for bit lengths table */ - unsigned n; /* number of lengths to get */ - struct huft *tl; /* literal/length code table */ - struct huft *td; /* distance code table */ - int bl; /* lookup bits for tl */ - int bd; /* lookup bits for td */ - unsigned nb; /* number of bit length codes */ - unsigned nl; /* number of literal/length codes */ - unsigned nd; /* number of distance codes */ -#ifdef PKZIP_BUG_WORKAROUND - unsigned ll[288+32]; /* literal/length and distance code lengths */ -#else - unsigned ll[286+30]; /* literal/length and distance code lengths */ -#endif - register ulg b; /* bit buffer */ - register unsigned k; /* number of bits in bit buffer */ - - - /* make local bit buffer */ - b = bb; - k = bk; - - - /* read in table lengths */ - NEEDBITS(5) - nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes */ - DUMPBITS(5) - NEEDBITS(5) - nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */ - DUMPBITS(5) - NEEDBITS(4) - nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */ - DUMPBITS(4) -#ifdef PKZIP_BUG_WORKAROUND - if (nl > 288 || nd > 32) -#else - if (nl > 286 || nd > 30) -#endif - return 1; /* bad lengths */ - - - /* read in bit-length-code lengths */ - for (j = 0; j < nb; j++) - { - NEEDBITS(3) - ll[border[j]] = (unsigned)b & 7; - DUMPBITS(3) - } - for (; j < 19; j++) - ll[border[j]] = 0; - - - /* build decoding table for trees--single level, 7 bit lookup */ - bl = 7; - if ((i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl)) != 0) - { - if (i == 1) - huft_free(tl); - return i; /* incomplete code set */ - } - - - /* read in literal and distance code lengths */ - n = nl + nd; - m = mask_bits[bl]; - i = l = 0; - while ((unsigned)i < n) - { - NEEDBITS((unsigned)bl) - j = (td = tl + ((unsigned)b & m))->b; - DUMPBITS(j) - j = td->v.n; - if (j < 16) /* length of code in bits (0..15) */ - ll[i++] = l = j; /* save last length in l */ - else if (j == 16) /* repeat last length 3 to 6 times */ - { - NEEDBITS(2) - j = 3 + ((unsigned)b & 3); - DUMPBITS(2) - if ((unsigned)i + j > n) - return 1; - while (j--) - ll[i++] = l; - } - else if (j == 17) /* 3 to 10 zero length codes */ - { - NEEDBITS(3) - j = 3 + ((unsigned)b & 7); - DUMPBITS(3) - if ((unsigned)i + j > n) - return 1; - while (j--) - ll[i++] = 0; - l = 0; - } - else /* j == 18: 11 to 138 zero length codes */ - { - NEEDBITS(7) - j = 11 + ((unsigned)b & 0x7f); - DUMPBITS(7) - if ((unsigned)i + j > n) - return 1; - while (j--) - ll[i++] = 0; - l = 0; - } - } - - - /* free decoding table for trees */ - huft_free(tl); - - - /* restore the global bit buffer */ - bb = b; - bk = k; - - - /* build the decoding tables for literal/length and distance codes */ - bl = lbits; - if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) - { - if (i == 1) { - fprintf(stderr, " incomplete literal tree\n"); - huft_free(tl); - } - return i; /* incomplete code set */ - } - bd = dbits; - if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) - { - if (i == 1) { - fprintf(stderr, " incomplete distance tree\n"); -#ifdef PKZIP_BUG_WORKAROUND - i = 0; - } -#else - huft_free(td); - } - huft_free(tl); - return i; /* incomplete code set */ -#endif - } - - - /* decompress until an end-of-block code */ - if (inflate_codes(tl, td, bl, bd)) - return 1; - - - /* free the decoding tables, return */ - huft_free(tl); - huft_free(td); - return 0; -} - - - -int inflate_block(e) -int *e; /* last block flag */ -/* decompress an inflated block */ -{ - unsigned t; /* block type */ - register ulg b; /* bit buffer */ - register unsigned k; /* number of bits in bit buffer */ - - - /* make local bit buffer */ - b = bb; - k = bk; - - - /* read in last block bit */ - NEEDBITS(1) - *e = (int)b & 1; - DUMPBITS(1) - - - /* read in block type */ - NEEDBITS(2) - t = (unsigned)b & 3; - DUMPBITS(2) - - - /* restore the global bit buffer */ - bb = b; - bk = k; - - - /* inflate that block type */ - if (t == 2) - return inflate_dynamic(); - if (t == 0) - return inflate_stored(); - if (t == 1) - return inflate_fixed(); - - - /* bad block type */ - return 2; -} - - - -int inflate() -/* decompress an inflated entry */ -{ - int e; /* last block flag */ - int r; /* result code */ - unsigned h; /* maximum struct huft's malloc'ed */ - - - /* initialize window, bit buffer */ - wp = 0; - bk = 0; - bb = 0; - - - /* decompress until the last block */ - h = 0; - do { - hufts = 0; - if ((r = inflate_block(&e)) != 0) - return r; - if (hufts > h) - h = hufts; - } while (!e); - - /* Undo too much lookahead. The next read will be byte aligned so we - * can discard unused bits in the last meaningful byte. - */ - while (bk >= 8) { - bk -= 8; - inptr--; - } - - /* flush out slide */ - flush_output(wp); - - - /* return success */ -#ifdef DEBUG - fprintf(stderr, "<%u> ", h); -#endif /* DEBUG */ - return 0; -} diff --git a/gnu/usr.bin/gzip-1.0.7/lzw.c b/gnu/usr.bin/gzip-1.0.7/lzw.c deleted file mode 100644 index 33650ed18137..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/lzw.c +++ /dev/null @@ -1,26 +0,0 @@ -/* lzw.c -- compress files in LZW format. - * This is a dummy version avoiding patent problems. - */ - -#ifndef lint -static char rcsid[] = "$Id: lzw.c,v 1.1 1993/04/10 15:56:09 cgd Exp $"; -#endif - -#include "tailor.h" -#include "gzip.h" -#include "lzw.h" - -#include - -static int msg_done = 0; - -/* Compress in to out with lzw method. */ -void lzw(in, out) - int in, out; -{ - if (msg_done) return; - msg_done = 1; - fprintf(stderr,"output in compress .Z format not supported\n"); - in++, out++; /* avoid warnings on unused variables */ - exit_code = ERROR; -} diff --git a/gnu/usr.bin/gzip-1.0.7/lzw.h b/gnu/usr.bin/gzip-1.0.7/lzw.h deleted file mode 100644 index 4e640f5a23c0..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/lzw.h +++ /dev/null @@ -1,42 +0,0 @@ -/* lzw.h -- define the lzw functions. - * Copyright (C) 1992-1993 Jean-loup Gailly. - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#if !defined(OF) && defined(lint) -# include "gzip.h" -#endif - -#ifndef BITS -# define BITS 16 -#endif -#define INIT_BITS 9 /* Initial number of bits per code */ - -#define LZW_MAGIC "\037\235" /* Magic header for lzw files, 1F 9D */ - -#define BIT_MASK 0x1f /* Mask for 'number of compression bits' */ -/* Mask 0x20 is reserved to mean a fourth header byte, and 0x40 is free. - * It's a pity that old uncompress does not check bit 0x20. That makes - * extension of the format actually undesirable because old compress - * would just crash on the new format instead of giving a meaningful - * error message. It does check the number of bits, but it's more - * helpful to say "unsupported format, get a new version" than - * "can only handle 16 bits". - */ - -#define BLOCK_MODE 0x80 -/* Block compression: if table is full and compression rate is dropping, - * clear the dictionary. - */ - -#define LZW_RESERVED 0x60 /* reserved bits */ - -#define CLEAR 256 /* flush the dictionary */ -#define FIRST (CLEAR+1) /* first free entry */ - -extern int maxbits; /* max bits per code for LZW */ -extern int block_mode; /* block compress mode -C compatible with 2.0 */ - -extern void lzw OF((int in, int out)); -extern void unlzw OF((int in, int out)); diff --git a/gnu/usr.bin/gzip-1.0.7/makecrc.c b/gnu/usr.bin/gzip-1.0.7/makecrc.c deleted file mode 100644 index 302f07728c2b..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/makecrc.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Not copyrighted 1990 Mark Adler */ - -#ifndef lint -static char rcsid[] = "$Id: makecrc.c,v 1.1 1993/04/10 15:56:11 cgd Exp $"; -#endif - -#include - -main() -/* - Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The table is simply the CRC of all possible eight bit values. This is all - the information needed to generate CRC's on data a byte at a time for all - combinations of CRC register values and incoming bytes. The table is - written to stdout as 256 long hexadecimal values in C language format. -*/ -{ - unsigned long c; /* crc shift register */ - unsigned long e; /* polynomial exclusive-or pattern */ - int i; /* counter for all possible eight bit values */ - int k; /* byte being shifted into crc apparatus */ - - /* terms of polynomial defining this crc (except x^32): */ - static int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* Make exclusive-or pattern from polynomial */ - e = 0; - for (i = 0; i < sizeof(p)/sizeof(int); i++) - e |= 1L << (31 - p[i]); - - /* Compute and print table of CRC's, five per line */ - printf(" 0x00000000L"); - for (i = 1; i < 256; i++) - { - c = 0; - for (k = i | 256; k != 1; k >>= 1) - { - c = c & 1 ? (c >> 1) ^ e : c >> 1; - if (k & 1) - c ^= e; - } - printf(i % 5 ? ", 0x%08lxL" : ",\n 0x%08lxL", c); - } - putchar('\n'); - return 0; -} diff --git a/gnu/usr.bin/gzip-1.0.7/match.S b/gnu/usr.bin/gzip-1.0.7/match.S deleted file mode 100644 index 048f1b6f1cef..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/match.S +++ /dev/null @@ -1,377 +0,0 @@ -/* match.s -- optional optimized asm version of longest match in deflate.c - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - * - * The 68020 version has been written by Francesco Potorti` - * adapted to the 68000 by Carsten Steger - * and Andreas Schwab . - */ - -/* $Id: match.S,v 1.2 1993/06/19 06:57:00 mycroft Exp $ */ - -/* Preprocess with -DNO_UNDERLINE if your C compiler does not prefix - * external symbols with an underline character '_'. - */ -#ifdef NO_UNDERLINE -# define _prev prev -# define _window window -# define _match_start match_start -# define _prev_length prev_length -# define _good_match good_match -# define _nice_match nice_match -# define _strstart strstart -# define _max_chain_length max_chain_length - -# define _match_init match_init -# define _longest_match longest_match -#endif - -#ifdef DYN_ALLOC - error: DYN_ALLOC not yet supported in match.s -#endif - -#if defined(i386) || defined(_I386) - -/* This version is for 386 Unix or OS/2 in 32 bit mode. - * Warning: it uses the AT&T syntax: mov source,dest - * This file is only optional. If you want to force the C version, - * add -DNO_ASM to CFLAGS in Makefile and set OBJA to an empty string. - * If you have reduced WSIZE in gzip.h, then change its value below. - * This version assumes static allocation of the arrays (-DDYN_ALLOC not used). - */ - - .file "match.S" - -#define MAX_MATCH 258 -#define MAX_MATCH2 128 /* MAX_MATCH/2-1 */ -#define MIN_MATCH 3 -#define WSIZE 32768 -#define MAX_DIST WSIZE - MAX_MATCH - MIN_MATCH - 1 - - .globl _match_init - .globl _longest_match - - .text - -_match_init: - ret - -/*----------------------------------------------------------------------- - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - */ - -_longest_match: /* int longest_match(cur_match) */ - -#define cur_match 20(%esp) - /* return address */ /* esp+16 */ - push %ebp /* esp+12 */ - push %edi /* esp+8 */ - push %esi /* esp+4 */ - push %ebx /* esp */ - -/* - * match equ esi - * scan equ edi - * chain_length equ ebp - * best_len equ ebx - * limit equ edx - */ - mov cur_match,%esi - mov _max_chain_length,%ebp /* chain_length = max_chain_length */ - mov _strstart,%edi - mov %edi,%edx - sub $(MAX_DIST),%edx /* limit = strstart-MAX_DIST */ - jae limit_ok - sub %edx,%edx /* limit = NIL */ -limit_ok: - add $(_window+2),%edi /* edi = offset(window+strstart+2) */ - mov _prev_length,%ebx /* best_len = prev_length */ - movw -3(%ebx,%edi),%ax /* ax = scan[best_len-1..best_len] */ - movw -2(%edi),%cx /* cx = scan[0..1] */ - cmp _good_match,%ebx /* do we have a good match already? */ - jb do_scan - shr $2,%ebp /* chain_length >>= 2 */ - jmp do_scan - - .align 4 -long_loop: -/* at this point, edi == scan+2, esi == cur_match */ - movw -3(%ebx,%edi),%ax /* ax = scan[best_len-1..best_len] */ - movw -2(%edi),%cx /* cx = scan[0..1] */ -short_loop: -/* - * at this point, di == scan+2, si == cur_match, - * ax = scan[best_len-1..best_len] and cx = scan[0..1] - */ - and $(WSIZE-1), %esi - movw _prev(%esi,%esi),%si /* cur_match = prev[cur_match] */ - /* top word of esi is still 0 */ - cmp %edx,%esi /* cur_match <= limit ? */ - jbe the_end - dec %ebp /* --chain_length */ - jz the_end -do_scan: - cmpw _window-1(%ebx,%esi),%ax/* check match at best_len-1 */ - jne short_loop - cmpw _window(%esi),%cx /* check min_match_length match */ - jne short_loop - - lea _window+2(%esi),%esi /* si = match */ - mov %edi,%eax /* ax = scan+2 */ - mov $(MAX_MATCH2),%ecx /* scan for at most MAX_MATCH bytes */ - rep; cmpsw /* loop until mismatch */ - je maxmatch /* match of length MAX_MATCH? */ -mismatch: - movb -2(%edi),%cl /* mismatch on first or second byte? */ - subb -2(%esi),%cl /* cl = 0 if first bytes equal */ - xchg %edi,%eax /* edi = scan+2, eax = end of scan */ - sub %edi,%eax /* eax = len */ - sub %eax,%esi /* esi = cur_match + 2 + offset(window) */ - sub $(_window+2),%esi /* esi = cur_match */ - subb $1,%cl /* set carry if cl == 0 (cannot use DEC) */ - adc $0,%eax /* eax = carry ? len+1 : len */ - cmp %ebx,%eax /* len > best_len ? */ - jle long_loop - mov %esi,_match_start /* match_start = cur_match */ - mov %eax,%ebx /* ebx = best_len = len */ - cmp _nice_match,%eax /* len >= nice_match ? */ - jl long_loop -the_end: - mov %ebx,%eax /* result = eax = best_len */ - pop %ebx - pop %esi - pop %edi - pop %ebp - ret -maxmatch: - cmpsb - jmp mismatch - -#else - -/* ======================== 680x0 version ================================= */ - -#if defined(m68k) || defined(__mc68000__) || defined(__MC68000__) -# ifndef mc68000 -# define mc68000 -# endif -#endif - -#if (defined(__mc68020__) || defined(__MC68020__)) && !defined(mc68020) -# define mc68020 -#endif - -#if defined(mc68020) || defined(mc68000) - -#if defined(mc68020) && !defined(UNALIGNED_OK) -# define UNALIGNED_OK -#endif - -#if defined(m68k) && !defined(NeXT) && !defined(atarist) - /* Try 'delta' style */ - -# define GLOBAL(symbol) global symbol -# define TEXT text -# define FILE(filename) file filename -# define invert_maybe(src,dst) dst,src -# define imm(data) &data -# define reg(register) %register - -# define addl add.l -# define addql addq.l -# define blos blo.b -# define bhis bhi.b -# define bras bra.b -# define clrl clr.l -# define cmpmb cmpm.b -# define cmpw cmp.w -# define cmpl cmp.l -# define lslw lsl.w -# define lsrl lsr.l -# define movel move.l -# define movew move.w -# define moveb move.b -# define moveml movem.l -# define subl sub.l -# define subw sub.w -# define subql subq.l - -# define IndBase(bd,An) (bd,An) -# define IndBaseNdxl(bd,An,Xn) (bd,An,Xn.l) -# define IndBaseNdxw(bd,An,Xn) (bd,An,Xn.w) -# define predec(An) -(An) -# define postinc(An) (An)+ - -#else /* Motorola style (Sun 3, NeXT, Amiga, Atari) */ - -# define GLOBAL(symbol) .globl symbol -# define TEXT .text -# define FILE(filename) .even -# define invert_maybe(src,dst) src,dst -# ifdef sun -# define imm(data) #data -# else -# define imm(data) \#data -# endif -# define reg(register) register - -# define blos bcss -# ifdef sun -# define movel movl -# define movew movw -# define moveb movb -# endif -# define IndBase(bd,An) An@(bd) -# define IndBaseNdxl(bd,An,Xn) An@(bd,Xn:l) -# define IndBaseNdxw(bd,An,Xn) An@(bd,Xn:w) -# define predec(An) An@- -# define postinc(An) An@+ - -#endif /* styles */ - -#define Best_Len reg(d0) /* unsigned */ -#define Cur_Match reg(d1) /* Ipos */ -#define Loop_Counter reg(d2) /* int */ -#define Scan_Start reg(d3) /* unsigned short */ -#define Scan_End reg(d4) /* unsigned short */ -#define Limit reg(d5) /* IPos */ -#define Chain_Length reg(d6) /* unsigned */ -#define Scan_Test reg(d7) -#define Scan reg(a0) /* *uch */ -#define Match reg(a1) /* *uch */ -#define Prev_Address reg(a2) /* *Pos */ -#define Scan_Ini reg(a3) /* *uch */ -#define Match_Ini reg(a4) /* *uch */ -#define Stack_Pointer reg(sp) - -#define MAX_MATCH 258 -#define MIN_MATCH 3 -#define WSIZE 32768 -#define MAX_DIST (WSIZE - MAX_MATCH - MIN_MATCH - 1) - - GLOBAL (_match_init) - GLOBAL (_longest_match) - - TEXT - - FILE ("match.S") - -_match_init: - rts - -/*----------------------------------------------------------------------- - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - */ - -/* int longest_match (cur_match) */ - -#ifdef UNALIGNED_OK -# define pushreg 15928 /* d2-d6/a2-a4 */ -# define popreg 7292 -#else -# define pushreg 16184 /* d2-d7/a2-a4 */ -# define popreg 7420 -#endif - -_longest_match: - movel IndBase(4,Stack_Pointer),Cur_Match - moveml imm(pushreg),predec(Stack_Pointer) - movel _max_chain_length,Chain_Length - movel _prev_length,Best_Len - movel imm(_prev),Prev_Address - movel imm(_window+MIN_MATCH),Match_Ini - movel _strstart,Limit - movel Match_Ini,Scan_Ini - addl Limit,Scan_Ini - subw imm(MAX_DIST),Limit - bhis L__limit_ok - clrl Limit -L__limit_ok: - cmpl invert_maybe(_good_match,Best_Len) - blos L__length_ok - lsrl imm(2),Chain_Length -L__length_ok: - subql imm(1),Chain_Length -#ifdef UNALIGNED_OK - movew IndBase(-MIN_MATCH,Scan_Ini),Scan_Start - movew IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End -#else - moveb IndBase(-MIN_MATCH,Scan_Ini),Scan_Start - lslw imm(8),Scan_Start - moveb IndBase(-MIN_MATCH+1,Scan_Ini),Scan_Start - moveb IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End - lslw imm(8),Scan_End - moveb IndBaseNdxw(-MIN_MATCH,Scan_Ini,Best_Len),Scan_End -#endif - bras L__do_scan - -L__long_loop: -#ifdef UNALIGNED_OK - movew IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End -#else - moveb IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End - lslw imm(8),Scan_End - moveb IndBaseNdxw(-MIN_MATCH,Scan_Ini,Best_Len),Scan_End -#endif - -L__short_loop: - lslw imm(1),Cur_Match - movew IndBaseNdxl(0,Prev_Address,Cur_Match),Cur_Match - cmpw invert_maybe(Limit,Cur_Match) - dbls Chain_Length,L__do_scan - bras L__return - -L__do_scan: - movel Match_Ini,Match - addl Cur_Match,Match -#ifdef UNALIGNED_OK - cmpw invert_maybe(IndBaseNdxw(-MIN_MATCH-1,Match,Best_Len),Scan_End) - bne L__short_loop - cmpw invert_maybe(IndBase(-MIN_MATCH,Match),Scan_Start) - bne L__short_loop -#else - moveb IndBaseNdxw(-MIN_MATCH-1,Match,Best_Len),Scan_Test - lslw imm(8),Scan_Test - moveb IndBaseNdxw(-MIN_MATCH,Match,Best_Len),Scan_Test - cmpw invert_maybe(Scan_Test,Scan_End) - bne L__short_loop - moveb IndBase(-MIN_MATCH,Match),Scan_Test - lslw imm(8),Scan_Test - moveb IndBase(-MIN_MATCH+1,Match),Scan_Test - cmpw invert_maybe(Scan_Test,Scan_Start) - bne L__short_loop -#endif - - movew imm((MAX_MATCH-MIN_MATCH+1)-1),Loop_Counter - movel Scan_Ini,Scan -L__scan_loop: - cmpmb postinc(Match),postinc(Scan) - dbne Loop_Counter,L__scan_loop - - subl Scan_Ini,Scan - addql imm(MIN_MATCH-1),Scan - cmpl invert_maybe(Best_Len,Scan) - bls L__short_loop - movel Scan,Best_Len - movel Cur_Match,_match_start - cmpl invert_maybe(_nice_match,Best_Len) - blos L__long_loop -L__return: - moveml postinc(Stack_Pointer),imm(popreg) - rts - -#else - error: this asm version is for 386 or 680x0 only -#endif /* mc68000 || mc68020 */ -#endif /* i386 || _I386 */ diff --git a/gnu/usr.bin/gzip-1.0.7/msdos/match.asm b/gnu/usr.bin/gzip-1.0.7/msdos/match.asm deleted file mode 100644 index 07c4137fc32d..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/msdos/match.asm +++ /dev/null @@ -1,240 +0,0 @@ -; match.asm -- optional optimized asm version of longest match in deflate.c -; Copyright (C) 1992-1993 Jean-loup Gailly -; This is free software; you can redistribute it and/or modify it under the -; terms of the GNU General Public License, see the file COPYING. -; -; Must be assembled with masm -ml. To be used only with C compact model -; or large model. (For large model, assemble with -D__LARGE__). -; This file is only optional. If you don't have masm or tasm, use the -; C version (add -DNO_ASM to CFLAGS in makefile.msc and remove match.obj -; from OBJI). If you have reduced WSIZE in zip.h, then change its value -; below. -; -; Turbo C 2.0 does not support static allocation of more than 64K bytes per -; file, and does not have SS == DS. So TC and BC++ users must use: -; tasm -ml -DDYN_ALLOC -DSS_NEQ_DS match; -; -; To simplify the code, the option -DDYN_ALLOC is supported for OS/2 -; only if the arrays are guaranteed to have zero offset (allocated by -; halloc). We also require SS==DS. This is satisfied for MSC but not Turbo C. - -; $Id: match.asm,v 1.1 1993/04/10 15:59:25 cgd Exp $ - - name match - -ifndef DYN_ALLOC - extrn _prev : word - extrn _window : byte - prev equ _prev ; offset part - window equ _window -endif - -_DATA segment word public 'DATA' - extrn _nice_match : word - extrn _match_start : word - extrn _prev_length : word - extrn _good_match : word - extrn _strstart : word - extrn _max_chain_length : word -ifdef DYN_ALLOC - extrn _prev : word - extrn _window : word - prev equ 0 ; offset forced to zero - window equ 0 - window_seg equ _window[2] - window_off equ 0 -else - wseg dw seg _window - window_seg equ wseg - window_off equ offset _window -endif -_DATA ends - -DGROUP group _DATA - -_TEXT segment word public 'CODE' - assume cs: _TEXT, ds: DGROUP - - public _match_init - public _longest_match - - MIN_MATCH equ 3 - MAX_MATCH equ 258 - WSIZE equ 32768 ; keep in sync with zip.h ! - MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) - MAX_DIST equ (WSIZE-MIN_LOOKAHEAD) - -prev_ptr dw seg _prev ; pointer to the prev array -ifdef SS_NEQ_DS - match_start dw 0 ; copy of _match_start if SS != DS - nice_match dw 0 ; copy of _nice_match if SS != DS -endif - -; initialize or check the variables used in match.asm. - -ifdef __LARGE__ -_match_init proc far ; 'proc far' for large model -else -_match_init proc near ; 'proc near' for compact model -endif -ifdef SS_NEQ_DS - ma_start equ cs:match_start ; does not work on OS/2 - nice equ cs:nice_match - mov ax,_nice_match - mov cs:nice_match,ax ; ugly write to code, crash on OS/2 -else - assume ss: DGROUP - ma_start equ ss:_match_start - nice equ ss:_nice_match - mov ax,ds - mov bx,ss - cmp ax,bx ; SS == DS? - jne error -endif -ifdef DYN_ALLOC - cmp _prev[0],0 ; verify zero offset - jne error - cmp _window[0],0 - jne error - ifdef SS_NEQ_DS - mov ax,_prev[2] ; segment value - mov cs:prev_ptr,ax ; ugly write to code, crash on OS/2 - prev_seg equ cs:prev_ptr - else - prev_seg equ ss:_prev[2] ; works on OS/2 if SS == DS - endif -else - prev_seg equ cs:prev_ptr -endif - ret -ifdef __LARGE__ - extrn _exit : far ; 'far' for large model -else - extrn _exit : near ; 'near' for compact model -endif -error: call _exit - -_match_init endp - -; ----------------------------------------------------------------------- -; Set match_start to the longest match starting at the given string and -; return its length. Matches shorter or equal to prev_length are discarded, -; in which case the result is equal to prev_length and match_start is -; garbage. -; IN assertions: cur_match is the head of the hash chain for the current -; string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - -; int longest_match(cur_match) - -ifdef __LARGE__ -_longest_match proc far ; 'proc far' for large model -else -_longest_match proc near ; 'proc near' for compact model -endif - push bp - mov bp,sp - push di - push si - push ds - -ifdef __LARGE__ - cur_match equ word ptr [bp+6] ; [bp+6] for large model -else - cur_match equ word ptr [bp+4] ; [bp+4] for compact model -endif - -; window equ es:window (es:0 for DYN_ALLOC) -; prev equ ds:prev -; match equ es:si -; scan equ es:di -; chain_length equ bp -; best_len equ bx -; limit equ dx - - mov si,cur_match ; use bp before it is destroyed - mov bp,_max_chain_length ; chain_length = max_chain_length - mov di,_strstart - mov dx,di - sub dx,MAX_DIST ; limit = strstart-MAX_DIST - jae limit_ok - sub dx,dx ; limit = NIL -limit_ok: - add di,2+window_off ; di = offset(window + strstart + 2) - mov bx,_prev_length ; best_len = prev_length - mov es,window_seg - mov ax,es:[bx+di-3] ; ax = scan[best_len-1..best_len] - mov cx,es:[di-2] ; cx = scan[0..1] - cmp bx,_good_match ; do we have a good match already? - mov ds,prev_seg ; (does not destroy the flags) - assume ds: nothing - jb do_scan ; good match? - shr bp,1 ; chain_length >>= 2 - shr bp,1 - jmp short do_scan - - even ; align destination of branch -long_loop: -; at this point, ds:di == scan+2, ds:si == cur_match - mov ax,[bx+di-3] ; ax = scan[best_len-1..best_len] - mov cx,[di-2] ; cx = scan[0..1] - mov ds,prev_seg ; reset ds to address the prev array -short_loop: -; at this point, di == scan+2, si = cur_match, -; ax = scan[best_len-1..best_len] and cx = scan[0..1] -if (WSIZE-32768) - and si,WSIZE-1 ; not needed if WSIZE=32768 -endif - shl si,1 ; cur_match as word index - mov si,prev[si] ; cur_match = prev[cur_match] - cmp si,dx ; cur_match <= limit ? - jbe the_end - dec bp ; --chain_length - jz the_end -do_scan: - cmp ax,word ptr es:window[bx+si-1] ; check match at best_len-1 - jne short_loop - cmp cx,word ptr es:window[si] ; check min_match_length match - jne short_loop - - lea si,window[si+2] ; si = match - mov ax,di ; ax = scan+2 - mov cx,es - mov ds,cx ; ds = es = window - mov cx,(MAX_MATCH-2)/2 ; scan for at most MAX_MATCH bytes - repe cmpsw ; loop until mismatch - je maxmatch ; match of length MAX_MATCH? -mismatch: - mov cl,[di-2] ; mismatch on first or second byte? - sub cl,[si-2] ; cl = 0 if first bytes equal - xchg ax,di ; di = scan+2, ax = end of scan - sub ax,di ; ax = len - sub si,ax ; si = cur_match + 2 + offset(window) - sub si,2+window_off ; si = cur_match - sub cl,1 ; set carry if cl == 0 (can't use DEC) - adc ax,0 ; ax = carry ? len+1 : len - cmp ax,bx ; len > best_len ? - jle long_loop - mov ma_start,si ; match_start = cur_match - mov bx,ax ; bx = best_len = len - cmp ax,nice ; len >= nice_match ? - jl long_loop -the_end: - pop ds - assume ds: DGROUP -ifdef SS_NEQ_DS - mov ax,ma_start ; garbage if no match found - mov ds:_match_start,ax -endif - pop si - pop di - pop bp - mov ax,bx ; result = ax = best_len - ret -maxmatch: ; come here if maximum match - cmpsb ; increment si and di - jmp mismatch ; force match_length = MAX_LENGTH - -_longest_match endp - -_TEXT ends -end diff --git a/gnu/usr.bin/gzip-1.0.7/msdos/tailor.c b/gnu/usr.bin/gzip-1.0.7/msdos/tailor.c deleted file mode 100644 index 4c3947484738..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/msdos/tailor.c +++ /dev/null @@ -1,53 +0,0 @@ -/* tailor.c -- target dependent functions - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -/* tailor.c is a bunch of non portable routines. - * It should be kept to a minimum. - */ - -#include "tailor.h" -#include "gzip.h" - -#ifndef lint -static char rcsid[] = "$Id: tailor.c,v 1.1 1993/04/10 15:59:29 cgd Exp $"; -#endif - -#ifdef __TURBOC__ - -/************************/ -/* Function fcalloc() */ -/************************/ - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use fcfree(). - * For MSC, use halloc instead of this function (see tailor.h). - */ -static ush ptr_offset; - -void * fcalloc(items, size) - unsigned items; /* number of items */ - unsigned size; /* item size */ -{ - void * buf = farmalloc((ulg)items*size + 16L); - /* Normalize the pointer to seg:0 */ - ptr_offset = (ush)((uch*)buf-0); - *((ush*)&buf+1) += (ptr_offset + 15) >> 4; - *(ush*)&buf = 0; - return buf; /* buf stays NULL if alloc failed */ -} - -void fcfree(ptr) - void *ptr; /* region allocated with fcalloc() */ -{ - /* Put the pointer back to its original form: */ - *((ush*)&ptr+1) -= (ptr_offset + 15) >> 4; - *(ush*)&ptr = ptr_offset; - farfree(ptr); - } - -#endif /* __TURBOC__ */ diff --git a/gnu/usr.bin/gzip-1.0.7/revision.h b/gnu/usr.bin/gzip-1.0.7/revision.h deleted file mode 100644 index 292728275a47..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/revision.h +++ /dev/null @@ -1,16 +0,0 @@ -/* revision.h -- define the version number - * Copyright (C) 1992-1993 Jean-loup Gailly. - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#define VERSION "1.0.7" -#define PATCHLEVEL 0 -#define REVDATE "18 Mar 93" - -/* This version does not support compression into old compress format: */ -#ifdef LZW -# undef LZW -#endif - -/* $Id: revision.h,v 1.1 1993/04/10 15:56:13 cgd Exp $ */ diff --git a/gnu/usr.bin/gzip-1.0.7/tailor.h b/gnu/usr.bin/gzip-1.0.7/tailor.h deleted file mode 100644 index df2f0d107681..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/tailor.h +++ /dev/null @@ -1,207 +0,0 @@ -/* tailor.h -- target dependent definitions - * Copyright (C) 1992-1993 Jean-loup Gailly. - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -/* The target dependent definitions should be defined here only. - * The target dependent functions should be defined in tailor.c. - */ - -/* $Id: tailor.h,v 1.1 1993/04/10 15:56:14 cgd Exp $ */ - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif - -#ifdef MSDOS -# ifdef __GNUC__ - /* DJGPP version 1.09+ on MS-DOS. - * The DJGPP 1.09 stat() function must be upgraded before gzip will - * fully work. - * No need for DIRENT, since defines POSIX_SOURCE which - * implies DIRENT. - */ -# define near -# else -# define MAXSEG_64K -# ifdef __TURBOC__ -# define NO_UTIME -# else /* MSC */ -# define HAVE_SYS_UTIME_H -# define NO_UTIME_H -# endif -# endif -# define PATH_SEP2 '\\' -# define PATH_SEP3 ':' -# define MAX_PATH_LEN 128 -# define NO_MULTIPLE_DOTS -# define MAX_EXT_CHARS 3 -# define Z_SUFFIX "z" -# define NO_CHOWN -# define PROTO -# define STDC_HEADERS -# define NO_SIZE_CHECK -# define casemap(c) tolow(c) /* Force file names to lower case */ -# include -# define OS_CODE 0x00 -# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY) -# if !defined(NO_ASM) && !defined(ASMV) -# define ASMV -# endif -#else -# define near -#endif - -#ifdef OS2 -# define PATH_SEP2 '\\' -# define PATH_SEP3 ':' -# define MAX_PATH_LEN 260 -# ifdef OS2FAT -# define NO_MULTIPLE_DOTS -# define MAX_EXT_CHARS 3 -# define Z_SUFFIX "z" -# endif -# define NO_CHOWN -# define PROTO -# define STDC_HEADERS -# define HAVE_SYS_UTIME_H -# define NO_UTIME_H -# define DIRENT -# define casemap(c) tolow(c) -# include -# define OS_CODE 0x06 -# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY) -#endif - -#ifdef __EMX__ -# define EXPAND(argc,argv) {_response(&argc, &argv); _wildcard(&argc, &argv);} -#endif - -#ifndef MAXSEG_64K -# define fcalloc(items,size) malloc((unsigned)(items)*(unsigned)(size)) -# define fcfree(ptr) free(ptr) -#else -# ifdef __TURBOC__ -# include -# define DYN_ALLOC - /* Turbo C 2.0 does not accept static allocations of large arrays */ - void * fcalloc (unsigned items, unsigned size); - void fcfree (void *ptr); -# else /* MSC */ -# include -# define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize)) -# define fcfree(ptr) hfree(ptr) -# endif -#endif - -#if defined(VAXC) || defined(VMS) -# define PATH_SEP ']' -# define PATH_SEP2 ':' -# define SUFFIX_SEP ';' -# define NO_MULTIPLE_DOTS -# define Z_SUFFIX "-z" -# define RECORD_IO 1 -# define casemap(c) tolow(c) -# define OS_CODE 0x02 -# define OPTIONS_VAR "GZIP_OPT" -# define STDC_HEADERS -# define NO_UTIME -# include -# ifdef VAXC -# define NO_FCNTL_H -# define unlink delete -# include -# endif -#endif - -#ifdef AMIGA -# define PATH_SEP2 ':' -# define STDC_HEADERS -# define casemap(c) tolow(c) /* Force file names to lower case */ -# define OS_CODE 0x01 -# define ASMV -# ifdef __GNUC__ -# define DIRENT -# define HAVE_UNISTD_H -# define RETSIGTYPE int -# else /* SASC */ -# define NO_STDIN_FSTAT -# define SYSDIR -# define NO_SYMLINK -# define NO_CHOWN -# define NO_FCNTL_H -# include /* for read() and write() */ -# define direct dirent - extern void _expand_args(int *argc, char ***argv); -# define EXPAND(argc,argv) _expand_args(&argc,&argv); -# endif -#endif - -#if defined(ATARI) || defined(atarist) -# ifndef STDC_HEADERS -# define STDC_HEADERS -# define HAVE_UNISTD_H -# define DIRENT -# endif -# define ASMV -# define OS_CODE 0x05 -# ifdef TOSFS -# define NO_SYMLINK -# define NO_MULTIPLE_DOTS -# define MAX_EXT_CHARS 3 -# define Z_SUFFIX "z" -# define NO_CHOWN -# endif -#endif - -#ifdef MACOS -# define OS_CODE 0x07 -#endif - -#ifdef WIN32 -# define OS_CODE 0x0b -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifndef unix -# define NO_PTY /* no pseudo ttys */ -#endif - - /* Common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef PATH_SEP -# define PATH_SEP '/' -#endif - -#ifndef casemap -# define casemap(c) (c) -#endif - -#ifndef OPTIONS_VAR -# define OPTIONS_VAR "GZIP" -#endif - -#ifndef Z_SUFFIX -# define Z_SUFFIX ".z" -#endif -#define Z_LEN strlen(Z_SUFFIX) - -#ifndef EXPAND -# define EXPAND(argc,argv) -#endif - -#ifndef RECORD_IO -# define RECORD_IO 0 -#endif - -#ifndef SET_BINARY_MODE -# define SET_BINARY_MODE(fd) -#endif diff --git a/gnu/usr.bin/gzip-1.0.7/texinfo.tex b/gnu/usr.bin/gzip-1.0.7/texinfo.tex deleted file mode 100644 index 203dca72c22b..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/texinfo.tex +++ /dev/null @@ -1,3350 +0,0 @@ -%% TeX macros to handle texinfo files - -% Copyright (C) 1985, 1986, 1988, 1990, 1991 Free Software Foundation, Inc. - -%This texinfo.tex file 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 texinfo.tex file 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 texinfo.tex file; see the file COPYING. If not, write -%to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, -%USA. - - -%In other words, you are welcome to use, share and improve this program. -%You are forbidden to forbid anyone else to use, share and improve -%what you give them. Help stamp out software-hoarding! - -\def\texinfoversion{2.73} -\message{Loading texinfo package [Version \texinfoversion]:} -\message{} - -% Print the version number if in a .fmt file. -\everyjob{\message{[Texinfo version \texinfoversion]}\message{}} - -% Save some parts of plain tex whose names we will redefine. - -\let\ptexlbrace=\{ -\let\ptexrbrace=\} -\let\ptexdots=\dots -\let\ptexdot=\. -\let\ptexstar=\* -\let\ptexend=\end -\let\ptexbullet=\bullet -\let\ptexb=\b -\let\ptexc=\c -\let\ptexi=\i -\let\ptext=\t -\let\ptexl=\l -\let\ptexL=\L - -\def\tie{\penalty 10000\ } % Save plain tex definition of ~. - -\message{Basics,} -\chardef\other=12 - -% If this character appears in an error message or help string, it -% starts a new line in the output. -\newlinechar = `^^J - -\hyphenation{ap-pen-dix} -\hyphenation{mini-buf-fer mini-buf-fers} -\hyphenation{eshell} - -% Margin to add to right of even pages, to left of odd pages. -\newdimen \bindingoffset \bindingoffset=0pt -\newdimen \normaloffset \normaloffset=\hoffset -\newdimen\pagewidth \newdimen\pageheight -\pagewidth=\hsize \pageheight=\vsize - -% Sometimes it is convenient to have everything in the transcript file -% and nothing on the terminal. We don't just call \tracingall here, -% since that produces some useless output on the terminal. -% -\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% -\def\loggingall{\tracingcommands2 \tracingstats2 - \tracingpages1 \tracingoutput1 \tracinglostchars1 - \tracingmacros2 \tracingparagraphs1 \tracingrestores1 - \showboxbreadth\maxdimen\showboxdepth\maxdimen -}% - -%---------------------Begin change----------------------- -% -%%%% For @cropmarks command. -% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986 -% -\newdimen\cornerlong \newdimen\cornerthick -\newdimen \topandbottommargin -\newdimen \outerhsize \newdimen \outervsize -\cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks -\outerhsize=7in -%\outervsize=9.5in -% Alternative @smallbook page size is 9.25in -\outervsize=9.25in -\topandbottommargin=.75in -% -%---------------------End change----------------------- - -% \onepageout takes a vbox as an argument. Note that \pagecontents -% does insertions itself, but you have to call it yourself. -\chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}} -\def\onepageout#1{\hoffset=\normaloffset -\ifodd\pageno \advance\hoffset by \bindingoffset -\else \advance\hoffset by -\bindingoffset\fi -{\escapechar=`\\\relax % makes sure backslash is used in output files. -\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}% -{\let\hsize=\pagewidth \makefootline}}}% -\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} - -%%%% For @cropmarks command %%%% - -% Here is a modification of the main output routine for Near East Publications -% This provides right-angle cropmarks at all four corners. -% The contents of the page are centerlined into the cropmarks, -% and any desired binding offset is added as an \hskip on either -% site of the centerlined box. (P. A. MacKay, 12 November, 1986) -% -\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up - \shipout - \vbox to \outervsize{\hsize=\outerhsize - \vbox{\line{\ewtop\hfill\ewtop}} - \nointerlineskip - \line{\vbox{\moveleft\cornerthick\nstop} - \hfill - \vbox{\moveright\cornerthick\nstop}} - \vskip \topandbottommargin - \centerline{\ifodd\pageno\hskip\bindingoffset\fi - \vbox{ - {\let\hsize=\pagewidth \makeheadline} - \pagebody{#1} - {\let\hsize=\pagewidth \makefootline}} - \ifodd\pageno\else\hskip\bindingoffset\fi} - \vskip \topandbottommargin plus1fill minus1fill - \boxmaxdepth\cornerthick - \line{\vbox{\moveleft\cornerthick\nsbot} - \hfill - \vbox{\moveright\cornerthick\nsbot}} - \nointerlineskip - \vbox{\line{\ewbot\hfill\ewbot}} - } - \advancepageno - \ifnum\outputpenalty>-20000 \else\dosupereject\fi} -% -% Do @cropmarks to get crop marks -\def\cropmarks{\let\onepageout=\croppageout } - -\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} -{\catcode`\@ =11 -\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi -\dimen@=\dp#1 \unvbox#1 -\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi -\ifr@ggedbottom \kern-\dimen@ \vfil \fi} -} - -% -% Here are the rules for the cropmarks. Note that they are -% offset so that the space between them is truly \outerhsize or \outervsize -% (P. A. MacKay, 12 November, 1986) -% -\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} -\def\nstop{\vbox - {\hrule height\cornerthick depth\cornerlong width\cornerthick}} -\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} -\def\nsbot{\vbox - {\hrule height\cornerlong depth\cornerthick width\cornerthick}} - -% Parse an argument, then pass it to #1. -% The argument can be delimited with [...] or with "..." or braces -% or it can be a whole line. -% #1 should be a macro which expects -% an ordinary undelimited TeX argument. - -\def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx} - -\def\parseargx{% -\ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else% -\aftergroup \parseargline % -\fi \endgroup} - -{\obeyspaces % -\gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}} - -\gdef\obeyedspace{\ } - -\def\parseargline{\begingroup \obeylines \parsearglinex} -{\obeylines % -\gdef\parsearglinex #1^^M{\endgroup \next {#1}}} - -\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} - -%% These are used to keep @begin/@end levels from running away -%% Call \inENV within environments (after a \begingroup) -\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} -\def\ENVcheck{% -\ifENV\errmessage{Still within an environment. Type Return to continue.} -\endgroup\fi} % This is not perfect, but it should reduce lossage - -% @begin foo is the same as @foo, for now. -\newhelp\EMsimple{Type to continue} - -\outer\def\begin{\parsearg\beginxxx} - -\def\beginxxx #1{% -\expandafter\ifx\csname #1\endcsname\relax -{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else -\csname #1\endcsname\fi} - -%% @end foo executes the definition of \Efoo. -%% foo can be delimited by doublequotes or brackets. - -\def\end{\parsearg\endxxx} - -\def\endxxx #1{% -\expandafter\ifx\csname E#1\endcsname\relax -\expandafter\ifx\csname #1\endcsname\relax -\errmessage{Undefined command @end #1}\else -\errorE{#1}\fi\fi -\csname E#1\endcsname} -\def\errorE#1{ -{\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}} - -% Single-spacing is done by various environments. - -\newskip\singlespaceskip \singlespaceskip = \baselineskip -\def\singlespace{% -{\advance \baselineskip by -\singlespaceskip -\kern \baselineskip}% -\baselineskip=\singlespaceskip -} - -%% Simple single-character @ commands - -% @@ prints an @ -% Kludge this until the fonts are right (grr). -\def\@{{\tt \char '100}} - -% Define @` and @' to be the same as ` and ' -% but suppressing ligatures. -\def\`{{`}} -\def\'{{'}} - -% Used to generate quoted braces. - -\def\mylbrace {{\tt \char '173}} -\def\myrbrace {{\tt \char '175}} -\let\{=\mylbrace -\let\}=\myrbrace - -% @: forces normal size whitespace following. -\def\:{\spacefactor=1000 } - -% @* forces a line break. -\def\*{\hfil\break\hbox{}\ignorespaces} - -% @. is an end-of-sentence period. -\def\.{.\spacefactor=3000 } - -% @w prevents a word break. Without the \leavevmode, @w at the -% beginning of a paragraph, when TeX is still in vertical mode, would -% produce a whole line of output instead of starting the paragraph. -\def\w#1{\leavevmode\hbox{#1}} - -% @group ... @end group forces ... to be all on one page, by enclosing -% it in a TeX vbox. We use \vtop instead of \vbox to construct the box -% to keep its height that of a normal line. According to the rules for -% \topskip (p.114 of the TeXbook), the glue inserted is -% max (\topskip - \ht (first item), 0). If that height is large, -% therefore, no glue is inserted, and the space between the headline and -% the text is small, which looks bad. -% -\def\group{\begingroup - \ifnum\catcode13=\active \else - \errhelp = \groupinvalidhelp - \errmessage{@group invalid in context where filling is enabled}% - \fi - \def\Egroup{\egroup\endgroup}% - \vtop\bgroup -} -% -% TeX puts in an \escapechar (i.e., `@') at the beginning of the help -% message, so this ends up printing `@group can only ...'. -% -\newhelp\groupinvalidhelp{% -group can only be used in environments such as @example,^^J% -where each line of input produces a line of output.} - -% @need space-in-mils -% forces a page break if there is not space-in-mils remaining. - -\newdimen\mil \mil=0.001in - -\def\need{\parsearg\needx} - -% Old definition--didn't work. -%\def\needx #1{\par % -%% This method tries to make TeX break the page naturally -%% if the depth of the box does not fit. -%{\baselineskip=0pt% -%\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000 -%\prevdepth=-1000pt -%}} - -\def\needx#1{% - % Go into vertical mode, so we don't make a big box in the middle of a - % paragraph. - \par - % - % Don't add any leading before our big empty box, but allow a page - % break, since the best break might be right here. - \allowbreak - \nointerlineskip - \vtop to #1\mil{\vfil}% - % - % TeX does not even consider page breaks if a penalty added to the - % main vertical list is 10000 or more. But in order to see if the - % empty box we just added fits on the page, we must make it consider - % page breaks. On the other hand, we don't want to actually break the - % page after the empty box. So we use a penalty of 9999. - % - % There is an extremely small chance that TeX will actually break the - % page at this \penalty, if there are no other feasible breakpoints in - % sight. (If the user is using lots of big @group commands, which - % almost-but-not-quite fill up a page, TeX will have a hard time doing - % good page breaking, for example.) However, I could not construct an - % example where a page broke at this \penalty; if it happens in a real - % document, then we can reconsider our strategy. - \penalty9999 - % - % Back up by the size of the box, whether we did a page break or not. - \kern -#1\mil - % - % Do not allow a page break right after this kern. - \nobreak -} - -% @br forces paragraph break - -\let\br = \par - -% @dots{} output some dots - -\def\dots{$\ldots$} - -% @page forces the start of a new page - -\def\page{\par\vfill\supereject} - -% @exdent text.... -% outputs text on separate line in roman font, starting at standard page margin - -% This records the amount of indent in the innermost environment. -% That's how much \exdent should take out. -\newskip\exdentamount - -% This defn is used inside fill environments such as @defun. -\def\exdent{\parsearg\exdentyyy} -\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} - -% This defn is used inside nofill environments such as @example. -\def\nofillexdent{\parsearg\nofillexdentyyy} -\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount -\leftline{\hskip\leftskip{\rm#1}}}} - -%\hbox{{\rm#1}}\hfil\break}} - -% @include file insert text of that file as input. - -\def\include{\parsearg\includezzz} -\def\includezzz #1{{\def\thisfile{#1}\input #1 -}} - -\def\thisfile{} - -% @center line outputs that line, centered - -\def\center{\parsearg\centerzzz} -\def\centerzzz #1{{\advance\hsize by -\leftskip -\advance\hsize by -\rightskip -\centerline{#1}}} - -% @sp n outputs n lines of vertical space - -\def\sp{\parsearg\spxxx} -\def\spxxx #1{\par \vskip #1\baselineskip} - -% @comment ...line which is ignored... -% @c is the same as @comment -% @ignore ... @end ignore is another way to write a comment - -\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other% -\parsearg \commentxxx} - -\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 } - -\let\c=\comment - -% Prevent errors for section commands. -% Used in @ignore and in failing conditionals. -\def\ignoresections{% -\let\chapter=\relax -\let\unnumbered=\relax -\let\top=\relax -\let\unnumberedsec=\relax -\let\unnumberedsection=\relax -\let\unnumberedsubsec=\relax -\let\unnumberedsubsection=\relax -\let\unnumberedsubsubsec=\relax -\let\unnumberedsubsubsection=\relax -\let\section=\relax -\let\subsec=\relax -\let\subsubsec=\relax -\let\subsection=\relax -\let\subsubsection=\relax -\let\appendix=\relax -\let\appendixsec=\relax -\let\appendixsection=\relax -\let\appendixsubsec=\relax -\let\appendixsubsection=\relax -\let\appendixsubsubsec=\relax -\let\appendixsubsubsection=\relax -\let\contents=\relax -\let\smallbook=\relax -\let\titlepage=\relax -} - -\def\ignore{\begingroup\ignoresections -% Make sure that spaces turn into tokens that match what \ignorexxx wants. -\catcode32=10 -\ignorexxx} -\long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces} - -\def\direntry{\begingroup\direntryxxx} -\long\def\direntryxxx #1\end direntry{\endgroup\ignorespaces} - -% Conditionals to test whether a flag is set. - -\def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx} - -\def\ifsetxxx #1{\endgroup -\expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail -\else \let\temp=\relax \fi -\temp} -\def\Eifset{} -\def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx} -\long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces} - -\def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx} - -\def\ifclearxxx #1{\endgroup -\expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax -\else \let\temp=\ifclearfail \fi -\temp} -\def\Eifclear{} -\def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx} -\long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces} - -% @set foo to set the flag named foo. -% @clear foo to clear the flag named foo. -\def\set{\parsearg\setxxx} -\def\setxxx #1{ -\expandafter\let\csname IF#1\endcsname=\set} - -\def\clear{\parsearg\clearxxx} -\def\clearxxx #1{ -\expandafter\let\csname IF#1\endcsname=\relax} - -% Some texinfo constructs that are trivial in tex - -\def\iftex{} -\def\Eiftex{} -\def\ifinfo{\begingroup\ignoresections\ifinfoxxx} -\long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces} - -\long\def\menu #1\end menu{} -\def\asis#1{#1} - -% @math means output in math mode. -% We don't use $'s directly in the definition of \math because control -% sequences like \math are expanded when the toc file is written. Then, -% we read the toc file back, the $'s will be normal characters (as they -% should be, according to the definition of Texinfo). So we must use a -% control sequence to switch into and out of math mode. -% -% This isn't quite enough for @math to work properly in indices, but it -% seems unlikely it will ever be needed there. -% -\let\implicitmath = $ -\def\math#1{\implicitmath #1\implicitmath} - -\def\node{\ENVcheck\parsearg\nodezzz} -\def\nodezzz#1{\nodexxx [#1,]} -\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} -\let\lastnode=\relax - -\def\donoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\setref{\lastnode}\fi -\let\lastnode=\relax} - -\def\unnumbnoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi -\let\lastnode=\relax} - -\def\appendixnoderef{\ifx\lastnode\relax\else -\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi -\let\lastnode=\relax} - -\let\refill=\relax - -% @setfilename is done at the beginning of every texinfo file. -% So open here the files we need to have open while reading the input. -% This makes it possible to make a .fmt file for texinfo. -\def\setfilename{% - \readauxfile - \opencontents - \openindices - \fixbackslash % Turn off hack to swallow `\input texinfo'. - \global\let\setfilename=\comment % Ignore extra @setfilename cmds. - \comment % Ignore the actual filename. -} - -\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} - -\def\inforef #1{\inforefzzz #1,,,,**} -\def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}}, - node \samp{\losespace#1{}}} -\def\losespace #1{#1} - -\message{fonts,} - -% Font-change commands. - -% Texinfo supports the sans serif font style, which plain TeX does not. -% So we set up a \sf analogous to plain's \rm, etc. -\newfam\sffam -\def\sf{\fam=\sffam \tensf} -\let\li = \sf % Sometimes we call it \li, not \sf. - -%% Try out Computer Modern fonts at \magstephalf -\let\mainmagstep=\magstephalf - -\ifx\bigger\relax -\let\mainmagstep=\magstep1 -\font\textrm=cmr12 -\font\texttt=cmtt12 -\else -\font\textrm=cmr10 scaled \mainmagstep -\font\texttt=cmtt10 scaled \mainmagstep -\fi -% Instead of cmb10, you many want to use cmbx10. -% cmbx10 is a prettier font on its own, but cmb10 -% looks better when embedded in a line with cmr10. -\font\textbf=cmb10 scaled \mainmagstep -\font\textit=cmti10 scaled \mainmagstep -\font\textsl=cmsl10 scaled \mainmagstep -\font\textsf=cmss10 scaled \mainmagstep -\font\textsc=cmcsc10 scaled \mainmagstep -\font\texti=cmmi10 scaled \mainmagstep -\font\textsy=cmsy10 scaled \mainmagstep - -% A few fonts for @defun, etc. -\font\defbf=cmbx10 scaled \magstep1 %was 1314 -\font\deftt=cmtt10 scaled \magstep1 -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} - -% Fonts for indices and small examples. -% We actually use the slanted font rather than the italic, -% because texinfo normally uses the slanted fonts for that. -% Do not make many font distinctions in general in the index, since they -% aren't very useful. -\font\ninett=cmtt9 -\font\indrm=cmr9 -\font\indit=cmsl9 -\let\indsl=\indit -\let\indtt=\ninett -\let\indsf=\indrm -\let\indbf=\indrm -\let\indsc=\indrm -\font\indi=cmmi9 -\font\indsy=cmsy9 - -% Fonts for headings -\font\chaprm=cmbx12 scaled \magstep2 -\font\chapit=cmti12 scaled \magstep2 -\font\chapsl=cmsl12 scaled \magstep2 -\font\chaptt=cmtt12 scaled \magstep2 -\font\chapsf=cmss12 scaled \magstep2 -\let\chapbf=\chaprm -\font\chapsc=cmcsc10 scaled\magstep3 -\font\chapi=cmmi12 scaled \magstep2 -\font\chapsy=cmsy10 scaled \magstep3 - -\font\secrm=cmbx12 scaled \magstep1 -\font\secit=cmti12 scaled \magstep1 -\font\secsl=cmsl12 scaled \magstep1 -\font\sectt=cmtt12 scaled \magstep1 -\font\secsf=cmss12 scaled \magstep1 -\font\secbf=cmbx12 scaled \magstep1 -\font\secsc=cmcsc10 scaled\magstep2 -\font\seci=cmmi12 scaled \magstep1 -\font\secsy=cmsy10 scaled \magstep2 - -% \font\ssecrm=cmbx10 scaled \magstep1 % This size an font looked bad. -% \font\ssecit=cmti10 scaled \magstep1 % The letters were too crowded. -% \font\ssecsl=cmsl10 scaled \magstep1 -% \font\ssectt=cmtt10 scaled \magstep1 -% \font\ssecsf=cmss10 scaled \magstep1 - -%\font\ssecrm=cmb10 scaled 1315 % Note the use of cmb rather than cmbx. -%\font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than -%\font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1. -%\font\ssectt=cmtt10 scaled 1315 -%\font\ssecsf=cmss10 scaled 1315 - -%\let\ssecbf=\ssecrm - -\font\ssecrm=cmbx12 scaled \magstephalf -\font\ssecit=cmti12 scaled \magstephalf -\font\ssecsl=cmsl12 scaled \magstephalf -\font\ssectt=cmtt12 scaled \magstephalf -\font\ssecsf=cmss12 scaled \magstephalf -\font\ssecbf=cmbx12 scaled \magstephalf -\font\ssecsc=cmcsc10 scaled \magstep1 -\font\sseci=cmmi12 scaled \magstephalf -\font\ssecsy=cmsy10 scaled \magstep1 -% The smallcaps and symbol fonts should actually be scaled \magstep1.5, -% but that is not a standard magnification. - -% Fonts for title page: -\font\titlerm = cmbx12 scaled \magstep3 -\let\authorrm = \secrm - -% In order for the font changes to affect most math symbols and letters, -% we have to define the \textfont of the standard families. Since -% texinfo doesn't allow for producing subscripts and superscripts, we -% don't bother to reset \scriptfont and \scriptscriptfont (which would -% also require loading a lot more fonts). -% -\def\resetmathfonts{% - \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy - \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf - \textfont\ttfam = \tentt \textfont\sffam = \tensf -} - - -% The font-changing commands redefine the meanings of \tenSTYLE, instead -% of just \STYLE. We do this so that font changes will continue to work -% in math mode, where it is the current \fam that is relevant in most -% cases, not the current. Plain TeX does, for example, -% \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need -% to redefine \bf itself. -\def\textfonts{% - \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl - \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc - \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy - \resetmathfonts} -\def\chapfonts{% - \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl - \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc - \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy - \resetmathfonts} -\def\secfonts{% - \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl - \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc - \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy - \resetmathfonts} -\def\subsecfonts{% - \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl - \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc - \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy - \resetmathfonts} -\def\indexfonts{% - \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl - \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc - \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy - \resetmathfonts} - -% Set up the default fonts, so we can use them for creating boxes. -% -\textfonts - -% Count depth in font-changes, for error checks -\newcount\fontdepth \fontdepth=0 - -% Fonts for short table of contents. -\font\shortcontrm=cmr12 -\font\shortcontbf=cmbx12 -\font\shortcontsl=cmsl12 - -%% Add scribe-like font environments, plus @l for inline lisp (usually sans -%% serif) and @ii for TeX italic - -% \smartitalic{ARG} outputs arg in italics, followed by an italic correction -% unless the following character is such as not to need one. -\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} -\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx} - -\let\i=\smartitalic -\let\var=\smartitalic -\let\dfn=\smartitalic -\let\emph=\smartitalic -\let\cite=\smartitalic - -\def\b#1{{\bf #1}} -\let\strong=\b - -\def\t#1{{\tt \exhyphenpenalty=10000\rawbackslash \frenchspacing #1}\null} -\let\ttfont = \t -%\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null} -\def\samp #1{`\tclose{#1}'\null} -\def\key #1{{\tt \exhyphenpenalty=10000\uppercase{#1}}\null} -\def\ctrl #1{{\tt \rawbackslash \hat}#1} - -\let\file=\samp - -% @code is a modification of @t, -% which makes spaces the same size as normal in the surrounding text. -\newdimen\tclosesave -\newdimen\tcloserm -\def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font -\fontdimen2\font=\tcloserm -% prevent breaking lines at hyphens. -\exhyphenpenalty=10000 -\def\ {{\fontdimen2\font=\tclosesave{} }}% - \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null} -\let\code=\tclose -%\let\exp=\tclose %Was temporary - -% @kbd is like @code, except that if the argument is just one @key command, -% then @kbd has no effect. - -\def\xkey{\key} -\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% -\ifx\one\xkey\ifx\threex\three \key{#2}% -\else\tclose{\look}\fi -\else\tclose{\look}\fi} - -% Typeset a dimension, e.g., `in' or `pt'. The only reason for the -% argument is to make the input look right: @dmn{pt} instead of -% @dmn{}pt. -% -\def\dmn#1{\thinspace #1} - -\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} - -\def\l#1{{\li #1}\null} % - -\def\r#1{{\rm #1}} % roman font -% Use of \lowercase was suggested. -\def\sc#1{{\smallcaps#1}} % smallcaps font -\def\ii#1{{\it #1}} % italic font - -\message{page headings,} - -\newskip\titlepagetopglue \titlepagetopglue = 1.5in -\newskip\titlepagebottomglue \titlepagebottomglue = 2pc - -% First the title page. Must do @settitle before @titlepage. -\def\titlefont#1{{\titlerm #1}} - -\newtoks\realeverypar -\newif\ifseenauthor -\newif\iffinishedtitlepage - -\def\titlepage{\begingroup \parindent=0pt \textfonts - \let\subtitlerm=\tenrm -% I deinstalled the following change because \cmr12 is undefined. -% This change was not in the ChangeLog anyway. --rms. -% \let\subtitlerm=\cmr12 - \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% - % - \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% - % - % Leave some space at the very top of the page. - \vglue\titlepagetopglue - % - % Now you can print the title using @title. - \def\title{\parsearg\titlezzz}% - \def\titlezzz##1{\leftline{\titlefont{##1}} - % print a rule at the page bottom also. - \finishedtitlepagefalse - \vskip4pt \hrule height 4pt \vskip4pt}% - % No rule at page bottom unless we print one at the top with @title. - \finishedtitlepagetrue - % - % Now you can put text using @subtitle. - \def\subtitle{\parsearg\subtitlezzz}% - \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% - % - % @author should come last, but may come many times. - \def\author{\parsearg\authorzzz}% - \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi - {\authorfont \leftline{##1}}}% - % - % Most title ``pages'' are actually two pages long, with space - % at the top of the second. We don't want the ragged left on the second. - \let\oldpage = \page - \def\page{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - \oldpage - \let\page = \oldpage - \hbox{}}% -% \def\page{\oldpage \hbox{}} -} - -\def\Etitlepage{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - % It is important to do the page break before ending the group, - % because the headline and footline are only empty inside the group. - % If we use the new definition of \page, we always get a blank page - % after the title page, which we certainly don't want. - \oldpage - \endgroup - \HEADINGSon -} - -\def\finishtitlepage{% - \vskip4pt \hrule height 2pt - \vskip\titlepagebottomglue - \finishedtitlepagetrue -} - -%%% Set up page headings and footings. - -\let\thispage=\folio - -\newtoks \evenheadline % Token sequence for heading line of even pages -\newtoks \oddheadline % Token sequence for heading line of odd pages -\newtoks \evenfootline % Token sequence for footing line of even pages -\newtoks \oddfootline % Token sequence for footing line of odd pages - -% Now make Tex use those variables -\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline - \else \the\evenheadline \fi}} -\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline - \else \the\evenfootline \fi}\HEADINGShook} -\let\HEADINGShook=\relax - -% Commands to set those variables. -% For example, this is what @headings on does -% @evenheading @thistitle|@thispage|@thischapter -% @oddheading @thischapter|@thispage|@thistitle -% @evenfooting @thisfile|| -% @oddfooting ||@thisfile - -\def\evenheading{\parsearg\evenheadingxxx} -\def\oddheading{\parsearg\oddheadingxxx} -\def\everyheading{\parsearg\everyheadingxxx} - -\def\evenfooting{\parsearg\evenfootingxxx} -\def\oddfooting{\parsearg\oddfootingxxx} -\def\everyfooting{\parsearg\everyfootingxxx} - -{\catcode`\@=0 % - -\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} -\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} -\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish} -\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} -\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} -\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% -\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish} -\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}} -\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} -% -}% unbind the catcode of @. - -% @headings double turns headings on for double-sided printing. -% @headings single turns headings on for single-sided printing. -% @headings off turns them off. -% @headings on same as @headings double, retained for compatibility. -% @headings after turns on double-sided headings after this page. -% @headings doubleafter turns on double-sided headings after this page. -% @headings singleafter turns on single-sided headings after this page. -% By default, they are off. - -\def\headings #1 {\csname HEADINGS#1\endcsname} - -\def\HEADINGSoff{ -\global\evenheadline={\hfil} \global\evenfootline={\hfil} -\global\oddheadline={\hfil} \global\oddfootline={\hfil}} -\HEADINGSoff -% When we turn headings on, set the page number to 1. -% For double-sided printing, put current file name in lower left corner, -% chapter name on inside top of right hand pages, document -% title on inside top of left hand pages, and page numbers on outside top -% edge of all pages. -\def\HEADINGSdouble{ -%\pagealignmacro -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} -% For single-sided printing, chapter title goes across top left of page, -% page number on top right. -\def\HEADINGSsingle{ -%\pagealignmacro -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} -\def\HEADINGSon{\HEADINGSdouble} - -\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} -\let\HEADINGSdoubleafter=\HEADINGSafter -\def\HEADINGSdoublex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} - -\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} -\def\HEADINGSsinglex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -} - -% Subroutines used in generating headings -% Produces Day Month Year style of output. -\def\today{\number\day\space -\ifcase\month\or -January\or February\or March\or April\or May\or June\or -July\or August\or September\or October\or November\or December\fi -\space\number\year} - -% Use this if you want the Month Day, Year style of output. -%\def\today{\ifcase\month\or -%January\or February\or March\or April\or May\or June\or -%July\or August\or September\or October\or November\or December\fi -%\space\number\day, \number\year} - -% @settitle line... specifies the title of the document, for headings -% It generates no output of its own - -\def\thistitle{No Title} -\def\settitle{\parsearg\settitlezzz} -\def\settitlezzz #1{\gdef\thistitle{#1}} - -\message{tables,} - -% @tabs -- simple alignment - -% These don't work. For one thing, \+ is defined as outer. -% So these macros cannot even be defined. - -%\def\tabs{\parsearg\tabszzz} -%\def\tabszzz #1{\settabs\+#1\cr} -%\def\tabline{\parsearg\tablinezzz} -%\def\tablinezzz #1{\+#1\cr} -%\def\&{&} - -% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). - -% default indentation of table text -\newdimen\tableindent \tableindent=.8in -% default indentation of @itemize and @enumerate text -\newdimen\itemindent \itemindent=.3in -% margin between end of table item and start of table text. -\newdimen\itemmargin \itemmargin=.1in - -% used internally for \itemindent minus \itemmargin -\newdimen\itemmax - -% Note @table, @vtable, and @vtable define @item, @itemx, etc., with -% these defs. -% They also define \itemindex -% to index the item name in whatever manner is desired (perhaps none). - -\def\internalBitem{\smallbreak \parsearg\itemzzz} -\def\internalBitemx{\par \parsearg\itemzzz} - -\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} -\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz} - -\def\internalBkitem{\smallbreak \parsearg\kitemzzz} -\def\internalBkitemx{\par \parsearg\kitemzzz} - -\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% - \itemzzz {#1}} - -\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% - \itemzzz {#1}} - -\def\itemzzz #1{\begingroup % - \advance\hsize by -\rightskip - \advance\hsize by -\tableindent - \setbox0=\hbox{\itemfont{#1}}% - \itemindex{#1}% - \nobreak % This prevents a break before @itemx. - % - % Be sure we are not still in the middle of a paragraph. - \parskip=0in - \par - % - % If the item text does not fit in the space we have, put it on a line - % by itself, and do not allow a page break either before or after that - % line. We do not start a paragraph here because then if the next - % command is, e.g., @kindex, the whatsit would get put into the - % horizontal list on a line by itself, resulting in extra blank space. - \ifdim \wd0>\itemmax - \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0 - \nobreak - \else - % The item text fits into the space. Start a paragraph, so that the - % following text (if any) will end up on the same line. Since that - % text will be indented by \tableindent, we make the item text be in - % a zero-width box. - \noindent - \rlap{\hskip -\tableindent\box0}% - \fi - \endgroup -} - -\def\item{\errmessage{@item while not in a table}} -\def\itemx{\errmessage{@itemx while not in a table}} -\def\kitem{\errmessage{@kitem while not in a table}} -\def\kitemx{\errmessage{@kitemx while not in a table}} -\def\xitem{\errmessage{@xitem while not in a table}} -\def\xitemx{\errmessage{@xitemx while not in a table}} - -%% Contains a kludge to get @end[description] to work -\def\description{\tablez{\dontindex}{1}{}{}{}{}} - -\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} -{\obeylines\obeyspaces% -\gdef\tablex #1^^M{% -\tabley\dontindex#1 \endtabley}} - -\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} -{\obeylines\obeyspaces% -\gdef\ftablex #1^^M{% -\tabley\fnitemindex#1 \endtabley -\def\Eftable{\endgraf\endgroup\afterenvbreak}% -\let\Etable=\relax}} - -\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} -{\obeylines\obeyspaces% -\gdef\vtablex #1^^M{% -\tabley\vritemindex#1 \endtabley -\def\Evtable{\endgraf\endgroup\afterenvbreak}% -\let\Etable=\relax}} - -\def\dontindex #1{} -\def\fnitemindex #1{\doind {fn}{\code{#1}}}% -\def\vritemindex #1{\doind {vr}{\code{#1}}}% - -{\obeyspaces % -\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% -\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} - -\def\tablez #1#2#3#4#5#6{% -\aboveenvbreak % -\begingroup % -\def\Edescription{\Etable}% Neccessary kludge. -\let\itemindex=#1% -\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % -\ifnum 0#4>0 \tableindent=#4\mil \fi % -\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % -\def\itemfont{#2}% -\itemmax=\tableindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \tableindent % -\exdentamount=\tableindent -\parindent = 0pt -\parskip = \smallskipamount -\ifdim \parskip=0pt \parskip=2pt \fi% -\def\Etable{\endgraf\endgroup\afterenvbreak}% -\let\item = \internalBitem % -\let\itemx = \internalBitemx % -\let\kitem = \internalBkitem % -\let\kitemx = \internalBkitemx % -\let\xitem = \internalBxitem % -\let\xitemx = \internalBxitemx % -} - -% This is the counter used by @enumerate, which is really @itemize - -\newcount \itemno - -\def\itemize{\parsearg\itemizezzz} - -\def\itemizezzz #1{% - \begingroup % ended by the @end itemsize - \itemizey {#1}{\Eitemize} -} - -\def\itemizey #1#2{% -\aboveenvbreak % -\itemmax=\itemindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \itemindent % -\exdentamount=\itemindent -\parindent = 0pt % -\parskip = \smallskipamount % -\ifdim \parskip=0pt \parskip=2pt \fi% -\def#2{\endgraf\endgroup\afterenvbreak}% -\def\itemcontents{#1}% -\let\item=\itemizeitem} - -\def\bullet{$\ptexbullet$} -\def\minus{$-$} - -% Set sfcode to normal for the chars that usually have another value. -% These are `.?!:;,' -\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 - \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } - -% \splitoff TOKENS\endmark defines \first to be the first token in -% TOKENS, and \rest to be the remainder. -% -\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% - -% Allow an optional argument of an uppercase letter, lowercase letter, -% or number, to specify the first label in the enumerated list. No -% argument is the same as `1'. -% -\def\enumerate{\parsearg\enumeratezzz} -\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} -\def\enumeratey #1 #2\endenumeratey{% - \begingroup % ended by the @end enumerate - % - % If we were given no argument, pretend we were given `1'. - \def\thearg{#1}% - \ifx\thearg\empty \def\thearg{1}\fi - % - % Detect if the argument is a single token. If so, it might be a - % letter. Otherwise, the only valid thing it can be is a number. - % (We will always have one token, because of the test we just made. - % This is a good thing, since \splitoff doesn't work given nothing at - % all -- the first parameter is undelimited.) - \expandafter\splitoff\thearg\endmark - \ifx\rest\empty - % Only one token in the argument. It could still be anything. - % A ``lowercase letter'' is one whose \lccode is nonzero. - % An ``uppercase letter'' is one whose \lccode is both nonzero, and - % not equal to itself. - % Otherwise, we assume it's a number. - % - % We need the \relax at the end of the \ifnum lines to stop TeX from - % continuing to look for a . - % - \ifnum\lccode\expandafter`\thearg=0\relax - \numericenumerate % a number (we hope) - \else - % It's a letter. - \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax - \lowercaseenumerate % lowercase letter - \else - \uppercaseenumerate % uppercase letter - \fi - \fi - \else - % Multiple tokens in the argument. We hope it's a number. - \numericenumerate - \fi -} - -% An @enumerate whose labels are integers. The starting integer is -% given in \thearg. -% -\def\numericenumerate{% - \itemno = \thearg - \startenumeration{\the\itemno}% -} - -% The starting (lowercase) letter is in \thearg. -\def\lowercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more lowercase letters in @enumerate; get a bigger - alphabet}% - \fi - \char\lccode\itemno - }% -} - -% The starting (uppercase) letter is in \thearg. -\def\uppercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more uppercase letters in @enumerate; get a bigger - alphabet} - \fi - \char\uccode\itemno - }% -} - -% Call itemizey, adding a period to the first argument and supplying the -% common last two arguments. Also subtract one from the initial value in -% \itemno, since @item increments \itemno. -% -\def\startenumeration#1{% - \advance\itemno by -1 - \itemizey{#1.}\Eenumerate\flushcr -} - -% @alphaenumerate and @capsenumerate are abbreviations for giving an arg -% to @enumerate. -% -\def\alphaenumerate{\enumerate{a}} -\def\capsenumerate{\enumerate{A}} -\def\Ealphaenumerate{\Eenumerate} -\def\Ecapsenumerate{\Eenumerate} - -% Definition of @item while inside @itemize. - -\def\itemizeitem{% -\advance\itemno by 1 -{\let\par=\endgraf \smallbreak}% -\ifhmode \errmessage{\in hmode at itemizeitem}\fi -{\parskip=0in \hskip 0pt -\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% -\vadjust{\penalty 1200}}% -\flushcr} - -\message{indexing,} -% Index generation facilities - -% Define \newwrite to be identical to plain tex's \newwrite -% except not \outer, so it can be used within \newindex. -{\catcode`\@=11 -\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} - -% \newindex {foo} defines an index named foo. -% It automatically defines \fooindex such that -% \fooindex ...rest of line... puts an entry in the index foo. -% It also defines \fooindfile to be the number of the output channel for -% the file that accumulates this index. The file's extension is foo. -% The name of an index should be no more than 2 characters long -% for the sake of vms. - -\def\newindex #1{ -\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file -\openout \csname#1indfile\endcsname \jobname.#1 % Open the file -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\doindex {#1}} -} - -% @defindex foo == \newindex{foo} - -\def\defindex{\parsearg\newindex} - -% Define @defcodeindex, like @defindex except put all entries in @code. - -\def\newcodeindex #1{ -\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file -\openout \csname#1indfile\endcsname \jobname.#1 % Open the file -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\docodeindex {#1}} -} - -\def\defcodeindex{\parsearg\newcodeindex} - -% @synindex foo bar makes index foo feed into index bar. -% Do this instead of @defindex foo if you don't want it as a separate index. -\def\synindex #1 #2 {% -\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname -\expandafter\let\csname#1indfile\endcsname=\synindexfoo -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\doindex {#2}}% -} - -% @syncodeindex foo bar similar, but put all entries made for index foo -% inside @code. -\def\syncodeindex #1 #2 {% -\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname -\expandafter\let\csname#1indfile\endcsname=\synindexfoo -\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex -\noexpand\docodeindex {#2}}% -} - -% Define \doindex, the driver for all \fooindex macros. -% Argument #1 is generated by the calling \fooindex macro, -% and it is "foo", the name of the index. - -% \doindex just uses \parsearg; it calls \doind for the actual work. -% This is because \doind is more useful to call from other macros. - -% There is also \dosubind {index}{topic}{subtopic} -% which makes an entry in a two-level index such as the operation index. - -\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} -\def\singleindexer #1{\doind{\indexname}{#1}} - -% like the previous two, but they put @code around the argument. -\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} -\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} - -\def\indexdummies{% -\def\_{{\realbackslash _}}% -\def\w{\realbackslash w }% -\def\bf{\realbackslash bf }% -\def\rm{\realbackslash rm }% -\def\sl{\realbackslash sl }% -\def\sf{\realbackslash sf}% -\def\tt{\realbackslash tt}% -\def\gtr{\realbackslash gtr}% -\def\less{\realbackslash less}% -\def\hat{\realbackslash hat}% -\def\char{\realbackslash char}% -\def\TeX{\realbackslash TeX}% -\def\dots{\realbackslash dots }% -\def\copyright{\realbackslash copyright }% -\def\tclose##1{\realbackslash tclose {##1}}% -\def\code##1{\realbackslash code {##1}}% -\def\samp##1{\realbackslash samp {##1}}% -\def\t##1{\realbackslash r {##1}}% -\def\r##1{\realbackslash r {##1}}% -\def\i##1{\realbackslash i {##1}}% -\def\b##1{\realbackslash b {##1}}% -\def\cite##1{\realbackslash cite {##1}}% -\def\key##1{\realbackslash key {##1}}% -\def\file##1{\realbackslash file {##1}}% -\def\var##1{\realbackslash var {##1}}% -\def\kbd##1{\realbackslash kbd {##1}}% -} - -% \indexnofonts no-ops all font-change commands. -% This is used when outputting the strings to sort the index by. -\def\indexdummyfont#1{#1} -\def\indexdummytex{TeX} -\def\indexdummydots{...} - -\def\indexnofonts{% -\let\w=\indexdummyfont -\let\t=\indexdummyfont -\let\r=\indexdummyfont -\let\i=\indexdummyfont -\let\b=\indexdummyfont -\let\emph=\indexdummyfont -\let\strong=\indexdummyfont -\let\cite=\indexdummyfont -\let\sc=\indexdummyfont -%Don't no-op \tt, since it isn't a user-level command -% and is used in the definitions of the active chars like <, >, |... -%\let\tt=\indexdummyfont -\let\tclose=\indexdummyfont -\let\code=\indexdummyfont -\let\file=\indexdummyfont -\let\samp=\indexdummyfont -\let\kbd=\indexdummyfont -\let\key=\indexdummyfont -\let\var=\indexdummyfont -\let\TeX=\indexdummytex -\let\dots=\indexdummydots -} - -% To define \realbackslash, we must make \ not be an escape. -% We must first make another character (@) an escape -% so we do not become unable to do a definition. - -{\catcode`\@=0 \catcode`\\=\other -@gdef@realbackslash{\}} - -\let\indexbackslash=0 %overridden during \printindex. - -\def\doind #1#2{% -{\count10=\lastpenalty % -{\indexdummies % Must do this here, since \bf, etc expand at this stage -\escapechar=`\\% -{\let\folio=0% Expand all macros now EXCEPT \folio -\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now -% so it will be output as is; and it will print as backslash in the indx. -% -% Now process the index-string once, with all font commands turned off, -% to get the string to sort the index by. -{\indexnofonts -\xdef\temp1{#2}% -}% -% Now produce the complete index entry. We process the index-string again, -% this time with font commands expanded, to get what to print in the index. -\edef\temp{% -\write \csname#1indfile\endcsname{% -\realbackslash entry {\temp1}{\folio}{#2}}}% -\temp }% -}\penalty\count10}} - -\def\dosubind #1#2#3{% -{\count10=\lastpenalty % -{\indexdummies % Must do this here, since \bf, etc expand at this stage -\escapechar=`\\% -{\let\folio=0% -\def\rawbackslashxx{\indexbackslash}% -% -% Now process the index-string once, with all font commands turned off, -% to get the string to sort the index by. -{\indexnofonts -\xdef\temp1{#2 #3}% -}% -% Now produce the complete index entry. We process the index-string again, -% this time with font commands expanded, to get what to print in the index. -\edef\temp{% -\write \csname#1indfile\endcsname{% -\realbackslash entry {\temp1}{\folio}{#2}{#3}}}% -\temp }% -}\penalty\count10}} - -% The index entry written in the file actually looks like -% \entry {sortstring}{page}{topic} -% or -% \entry {sortstring}{page}{topic}{subtopic} -% The texindex program reads in these files and writes files -% containing these kinds of lines: -% \initial {c} -% before the first topic whose initial is c -% \entry {topic}{pagelist} -% for a topic that is used without subtopics -% \primary {topic} -% for the beginning of a topic that is used with subtopics -% \secondary {subtopic}{pagelist} -% for each subtopic. - -% Define the user-accessible indexing commands -% @findex, @vindex, @kindex, @cindex. - -\def\findex {\fnindex} -\def\kindex {\kyindex} -\def\cindex {\cpindex} -\def\vindex {\vrindex} -\def\tindex {\tpindex} -\def\pindex {\pgindex} - -\def\cindexsub {\begingroup\obeylines\cindexsub} -{\obeylines % -\gdef\cindexsub "#1" #2^^M{\endgroup % -\dosubind{cp}{#2}{#1}}} - -% Define the macros used in formatting output of the sorted index material. - -% This is what you call to cause a particular index to get printed. -% Write -% @unnumbered Function Index -% @printindex fn - -\def\printindex{\parsearg\doprintindex} - -\def\doprintindex#1{% - \tex - \dobreak \chapheadingskip {10000} - \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other - \catcode`\$=\other\catcode`\_=\other - \catcode`\~=\other - % - % The following don't help, since the chars were translated - % when the raw index was written, and their fonts were discarded - % due to \indexnofonts. - %\catcode`\"=\active - %\catcode`\^=\active - %\catcode`\_=\active - %\catcode`\|=\active - %\catcode`\<=\active - %\catcode`\>=\active - % % - \def\indexbackslash{\rawbackslashxx} - \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt - \begindoublecolumns - % - % See if the index file exists and is nonempty. - \openin 1 \jobname.#1s - \ifeof 1 - % \enddoublecolumns gets confused if there is no text in the index, - % and it loses the chapter title and the aux file entries for the - % index. The easiest way to prevent this problem is to make sure - % there is some text. - (Index is nonexistent) - \else - % - % If the index file exists but is empty, then \openin leaves \ifeof - % false. We have to make TeX try to read something from the file, so - % it can discover if there is anything in it. - \read 1 to \temp - \ifeof 1 - (Index is empty) - \else - \input \jobname.#1s - \fi - \fi - \closein 1 - \enddoublecolumns - \Etex -} - -% These macros are used by the sorted index file itself. -% Change them to control the appearance of the index. - -% Same as \bigskipamount except no shrink. -% \balancecolumns gets confused if there is any shrink. -\newskip\initialskipamount \initialskipamount 12pt plus4pt - -\def\initial #1{% -{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt -\ifdim\lastskip<\initialskipamount -\removelastskip \penalty-200 \vskip \initialskipamount\fi -\line{\secbf#1\hfill}\kern 2pt\penalty10000}} - -\def\entry #1#2{\begingroup - \parfillskip=0in \parskip=0in \parindent=0in - % - % \hangindent is only relevant when the page number and the entry text - % don't fit on one line. In that case, bob suggests starting the dots - % pretty far over on the line. - % \hangafter is reset to 1 at the start of each paragraph. - \hangindent=.75\hsize - \noindent - % - % Don't break the text of the index entry. - \hbox{#1}% - % - % If we must, put the page number on a line of its own, and fill out - % this line with blank space. (The \hfil is overwhelmed with the - % fill leaders glue in \indexdotfill if the page number does fit.) - \hfil\penalty50 - \null\nobreak\indexdotfill % Have leaders before the page number. - % - % The `\ ' here is removed by the implicit \unskip that TeX does as - % part of (the primitive) \par. Without, a spurious underfull \hbox ensues. - \ #2% The page number ends the paragraph. - \par -\endgroup} - -% Like \dotfill except takes at least 1 em. -\def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill} - -\def\primary #1{\line{#1\hfil}} - -\newskip\secondaryindent \secondaryindent=0.5cm - -\def\secondary #1#2{ -{\parfillskip=0in \parskip=0in -\hangindent =1in \hangafter=1 -\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par -}} - -%% Define two-column mode, which is used in indexes. -%% Adapted from the TeXBook, page 416 -\catcode `\@=11 - -\newbox\partialpage - -\newdimen\doublecolumnhsize \doublecolumnhsize = 3.11in -\newdimen\doublecolumnvsize \doublecolumnvsize = 19.1in -\newdimen\availdimen@ - -\def\begindoublecolumns{\begingroup - \output={\global\setbox\partialpage= - \vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject - \output={\doublecolumnout}% - \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize} -\def\enddoublecolumns{\output={\balancecolumns}\eject - \endgroup \pagegoal=\vsize} - -\def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth - \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage - \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ - \onepageout\pagesofar \unvbox255 \penalty\outputpenalty} -\def\pagesofar{\unvbox\partialpage % - \hsize=\doublecolumnhsize % have to restore this since output routine -% changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986) - \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}} -\def\balancecolumns{% -% Unset the glue. - \setbox255=\vbox{\unvbox255} - \dimen@=\ht255 - \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip - \divide\dimen@ by2 - \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage -% If the remaining data is too big for one page, -% output one page normally, then work with what remains. - \ifdim \dimen@>\availdimen@ - { - \splittopskip=\topskip \splitmaxdepth=\maxdepth - \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage - \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ - \onepageout\pagesofar - } -% Recompute size of what remains, in case we just output some of it. - \dimen@=\ht255 - \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip - \divide\dimen@ by2 - \fi - \setbox0=\vbox{\unvbox255} - \splittopskip=\topskip - {\vbadness=10000 \loop \global\setbox3=\copy0 - \global\setbox1=\vsplit3 to\dimen@ - \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat} - \setbox0=\vbox to\dimen@{\unvbox1} \setbox2=\vbox to\dimen@{\unvbox3} - \pagesofar} - -\catcode `\@=\other -\message{sectioning,} -% Define chapters, sections, etc. - -\newcount \chapno -\newcount \secno \secno=0 -\newcount \subsecno \subsecno=0 -\newcount \subsubsecno \subsubsecno=0 - -% This counter is funny since it counts through charcodes of letters A, B, ... -\newcount \appendixno \appendixno = `\@ -\def\appendixletter{\char\the\appendixno} - -\newwrite \contentsfile -% This is called from \setfilename. -\def\opencontents{\openout \contentsfile = \jobname.toc} - -% Each @chapter defines this as the name of the chapter. -% page headings and footings can use it. @section does likewise - -\def\thischapter{} \def\thissection{} -\def\seccheck#1{\if \pageno<0 % -\errmessage{@#1 not allowed after generating table of contents}\fi -% -} - -\def\chapternofonts{% -\let\rawbackslash=\relax% -\let\frenchspacing=\relax% -\def\result{\realbackslash result} -\def\equiv{\realbackslash equiv} -\def\expansion{\realbackslash expansion} -\def\print{\realbackslash print} -\def\TeX{\realbackslash TeX} -\def\dots{\realbackslash dots} -\def\copyright{\realbackslash copyright} -\def\tt{\realbackslash tt} -\def\bf{\realbackslash bf } -\def\w{\realbackslash w} -\def\less{\realbackslash less} -\def\gtr{\realbackslash gtr} -\def\hat{\realbackslash hat} -\def\char{\realbackslash char} -\def\tclose##1{\realbackslash tclose {##1}} -\def\code##1{\realbackslash code {##1}} -\def\samp##1{\realbackslash samp {##1}} -\def\r##1{\realbackslash r {##1}} -\def\b##1{\realbackslash b {##1}} -\def\key##1{\realbackslash key {##1}} -\def\file##1{\realbackslash file {##1}} -\def\kbd##1{\realbackslash kbd {##1}} -% These are redefined because @smartitalic wouldn't work inside xdef. -\def\i##1{\realbackslash i {##1}} -\def\cite##1{\realbackslash cite {##1}} -\def\var##1{\realbackslash var {##1}} -\def\emph##1{\realbackslash emph {##1}} -\def\dfn##1{\realbackslash dfn {##1}} -} - -\def\thischaptername{No Chapter Title} -\outer\def\chapter{\parsearg\chapterzzz} -\def\chapterzzz #1{\seccheck{chapter}% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \chapno by 1 \message{Chapter \the\chapno}% -\chapmacro {#1}{\the\chapno}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -% We don't substitute the actual chapter name into \thischapter -% because we don't want its macros evaluated now. -\xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}% -{\chapternofonts% -\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec -}} - -\outer\def\appendix{\parsearg\appendixzzz} -\def\appendixzzz #1{\seccheck{appendix}% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \appendixno by 1 \message{Appendix \appendixletter}% -\chapmacro {#1}{Appendix \appendixletter}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -\xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}% -{\chapternofonts% -\edef\temp{{\realbackslash chapentry - {#1}{Appendix \appendixletter}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\global\let\section = \appendixsec -\global\let\subsection = \appendixsubsec -\global\let\subsubsection = \appendixsubsubsec -}} - -\outer\def\top{\parsearg\unnumberedzzz} -\outer\def\unnumbered{\parsearg\unnumberedzzz} -\def\unnumberedzzz #1{\seccheck{unnumbered}% -\secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)} -\unnumbchapmacro {#1}% -\gdef\thischapter{#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\global\let\section = \unnumberedsec -\global\let\subsection = \unnumberedsubsec -\global\let\subsubsection = \unnumberedsubsubsec -}} - -\outer\def\numberedsec{\parsearg\seczzz} -\def\seczzz #1{\seccheck{section}% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% -{\chapternofonts% -\edef\temp{{\realbackslash secentry % -{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appendixsection{\parsearg\appendixsectionzzz} -\outer\def\appendixsec{\parsearg\appendixsectionzzz} -\def\appendixsectionzzz #1{\seccheck{appendixsection}% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% -{\chapternofonts% -\edef\temp{{\realbackslash secentry % -{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsec{\parsearg\unnumberedseczzz} -\def\unnumberedseczzz #1{\seccheck{unnumberedsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -\outer\def\numberedsubsec{\parsearg\numberedsubseczzz} -\def\numberedsubseczzz #1{\seccheck{subsection}% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsecentry % -{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appendixsubsec{\parsearg\appendixsubseczzz} -\def\appendixsubseczzz #1{\seccheck{appendixsubsec}% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsecentry % -{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz} -\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -\outer\def\numberedsubsubsec{\parsearg\numberedsubsubseczzz} -\def\numberedsubsubseczzz #1{\seccheck{subsubsection}% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsubsecentry % - {#1} - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno} - {\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\donoderef % -\penalty 10000 % -}} - -\outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz} -\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -{\chapternofonts% -\edef\temp{{\realbackslash subsubsecentry{#1}% - {\appendixletter} - {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\appendixnoderef % -\penalty 10000 % -}} - -\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} -\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}% -\plainsecheading {#1}\gdef\thissection{#1}% -{\chapternofonts% -\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}% -\escapechar=`\\% -\write \contentsfile \temp % -\unnumbnoderef % -\penalty 10000 % -}} - -% These are variants which are not "outer", so they can appear in @ifinfo. -% Actually, they should now be obsolete; ordinary section commands should work. -\def\infotop{\parsearg\unnumberedzzz} -\def\infounnumbered{\parsearg\unnumberedzzz} -\def\infounnumberedsec{\parsearg\unnumberedseczzz} -\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} -\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} - -\def\infoappendix{\parsearg\appendixzzz} -\def\infoappendixsec{\parsearg\appendixseczzz} -\def\infoappendixsubsec{\parsearg\appendixsubseczzz} -\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} - -\def\infochapter{\parsearg\chapterzzz} -\def\infosection{\parsearg\sectionzzz} -\def\infosubsection{\parsearg\subsectionzzz} -\def\infosubsubsection{\parsearg\subsubsectionzzz} - -% These macros control what the section commands do, according -% to what kind of chapter we are in (ordinary, appendix, or unnumbered). -% Define them by default for a numbered chapter. -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec - -% Define @majorheading, @heading and @subheading - -% NOTE on use of \vbox for chapter headings, section headings, and -% such: -% 1) We use \vbox rather than the earlier \line to permit -% overlong headings to fold. -% 2) \hyphenpenalty is set to 10000 because hyphenation in a -% heading is obnoxious; this forbids it. -% 3) Likewise, headings look best if no \parindent is used, and -% if justification is not attempted. Hence \raggedright. - - -\def\majorheading{\parsearg\majorheadingzzz} -\def\majorheadingzzz #1{% -{\advance\chapheadingskip by 10pt \chapbreak }% -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} - -\def\chapheading{\parsearg\chapheadingzzz} -\def\chapheadingzzz #1{\chapbreak % -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} - -\def\heading{\parsearg\secheadingi} - -\def\subheading{\parsearg\subsecheadingi} - -\def\subsubheading{\parsearg\subsubsecheadingi} - -% These macros generate a chapter, section, etc. heading only -% (including whitespace, linebreaking, etc. around it), -% given all the information in convenient, parsed form. - -%%% Args are the skip and penalty (usually negative) -\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} - -\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} - -%%% Define plain chapter starts, and page on/off switching for it -% Parameter controlling skip before chapter headings (if needed) - -\newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt - -\def\chapbreak{\dobreak \chapheadingskip {-4000}} -\def\chappager{\par\vfill\supereject} -\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} - -\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} - -\def\CHAPPAGoff{ -\global\let\pchapsepmacro=\chapbreak -\global\let\pagealignmacro=\chappager} - -\def\CHAPPAGon{ -\global\let\pchapsepmacro=\chappager -\global\let\pagealignmacro=\chappager -\global\def\HEADINGSon{\HEADINGSsingle}} - -\def\CHAPPAGodd{ -\global\let\pchapsepmacro=\chapoddpage -\global\let\pagealignmacro=\chapoddpage -\global\def\HEADINGSon{\HEADINGSdouble}} - -\CHAPPAGon - -\def\CHAPFplain{ -\global\let\chapmacro=\chfplain -\global\let\unnumbchapmacro=\unnchfplain} - -\def\chfplain #1#2{% - \pchapsepmacro - {% - \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #2\enspace #1}% - }% - \bigskip - \penalty5000 -} - -\def\unnchfplain #1{% -\pchapsepmacro % -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 10000 % -} -\CHAPFplain % The default - -\def\unnchfopen #1{% -\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 10000 % -} - -\def\chfopen #1#2{\chapoddpage {\chapfonts -\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% -\par\penalty 5000 % -} - -\def\CHAPFopen{ -\global\let\chapmacro=\chfopen -\global\let\unnumbchapmacro=\unnchfopen} - -% Parameter controlling skip before section headings. - -\newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt -\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} - -\newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt -\def\secheadingbreak{\dobreak \secheadingskip {-1000}} - -% @paragraphindent is defined for the Info formatting commands only. -\let\paragraphindent=\comment - -% Section fonts are the base font at magstep2, which produces -% a size a bit more than 14 points in the default situation. - -\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}} -\def\plainsecheading #1{\secheadingi {#1}} -\def\secheadingi #1{{\advance \secheadingskip by \parskip % -\secheadingbreak}% -{\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } - - -% Subsection fonts are the base font at magstep1, -% which produces a size of 12 points. - -\def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}} -\def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip % -\subsecheadingbreak}% -{\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } - -\def\subsubsecfonts{\subsecfonts} % Maybe this should change: - % Perhaps make sssec fonts scaled - % magstep half -\def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}} -\def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip % -\subsecheadingbreak}% -{\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}% -\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000} - - -\message{toc printing,} - -% Finish up the main text and prepare to read what we've written -% to \contentsfile. - -\newskip\contentsrightmargin \contentsrightmargin=1in -\def\startcontents#1{% - \pagealignmacro - \immediate\closeout \contentsfile - \ifnum \pageno>0 - \pageno = -1 % Request roman numbered pages. - \fi - % Don't need to put `Contents' or `Short Contents' in the headline. - % It is abundantly clear what they are. - \unnumbchapmacro{#1}\def\thischapter{}% - \begingroup % Set up to handle contents files properly. - \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 - \raggedbottom % Worry more about breakpoints than the bottom. - \advance\hsize by -\contentsrightmargin % Don't use the full line length. -} - - -% Normal (long) toc. -\outer\def\contents{% - \startcontents{Table of Contents}% - \input \jobname.toc - \endgroup - \vfill \eject -} - -% And just the chapters. -\outer\def\summarycontents{% - \startcontents{Short Contents}% - % - \let\chapentry = \shortchapentry - \let\unnumbchapentry = \shortunnumberedentry - % We want a true roman here for the page numbers. - \secfonts - \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl - \rm - \advance\baselineskip by 1pt % Open it up a little. - \def\secentry ##1##2##3##4{} - \def\unnumbsecentry ##1##2{} - \def\subsecentry ##1##2##3##4##5{} - \def\unnumbsubsecentry ##1##2{} - \def\subsubsecentry ##1##2##3##4##5##6{} - \def\unnumbsubsubsecentry ##1##2{} - \input \jobname.toc - \endgroup - \vfill \eject -} -\let\shortcontents = \summarycontents - -% These macros generate individual entries in the table of contents. -% The first argument is the chapter or section name. -% The last argument is the page number. -% The arguments in between are the chapter number, section number, ... - -% Chapter-level things, for both the long and short contents. -\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} - -% See comments in \dochapentry re vbox and related settings -\def\shortchapentry#1#2#3{% - \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\strut\raggedright - {#2\labelspace #1}\dotfill\doshortpageno{#3}}% -} - -\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} -\def\shortunnumberedentry#1#2{% - \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\strut\raggedright - #1\dotfill\doshortpageno{#2}}% -} - -% Sections. -\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} -\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} - -% Subsections. -\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} -\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} - -% And subsubsections. -\def\subsubsecentry#1#2#3#4#5#6{% - \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} -\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} - - -% This parameter controls the indentation of the various levels. -\newdimen\tocindent \tocindent = 3pc - -% Now for the actual typesetting. In all these, #1 is the text and #2 is the -% page number. -% -% If the toc has to be broken over pages, we would want to be at chapters -% if at all possible; hence the \penalty. -\def\dochapentry#1#2{% - \penalty-300 \vskip\baselineskip - % This \vbox (and similar ones in dosecentry etc.) used to be a - % \line; changed to permit linebreaks for long headings. See - % comments above \majorheading. Here we also use \strut to - % keep the top end of the vbox from jamming up against the previous - % entry in the table of contents. - \vbox{\chapentryfonts - \hyphenpenalty=10000\tolerance=5000 % this line and next introduced - \parindent=0pt\strut\raggedright % with \line -> \vbox change - #1\dotfill - \dopageno{#2}}% - \nobreak\vskip .25\baselineskip -} - -\def\dosecentry#1#2{% - \vbox{\secentryfonts \leftskip=\tocindent - \hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\strut\raggedright #1\dotfill - \dopageno{#2}}% -} - -\def\dosubsecentry#1#2{% - \vbox{\subsecentryfonts \leftskip=2\tocindent - \hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\strut\raggedright #1\dotfill - \dopageno{#2}}% -} - -\def\dosubsubsecentry#1#2{% - \vbox{\subsubsecentryfonts \leftskip=3\tocindent - \hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\strut\raggedright #1\dotfill - \dopageno{#2}}% -} - -% Space between chapter (or whatever) number and the title. -\def\labelspace{\hskip1em \relax} - -\def\dopageno#1{{\rm #1}} -\def\doshortpageno#1{{\rm #1}} - -\def\chapentryfonts{\secfonts \rm} -\def\secentryfonts{\textfonts} -\let\subsecentryfonts = \textfonts -\let\subsubsecentryfonts = \textfonts - - -\message{environments,} - -% Since these characters are used in examples, it should be an even number of -% \tt widths. Each \tt character is 1en, so two makes it 1em. -% Furthermore, these definitions must come after we define our fonts. -\newbox\dblarrowbox \newbox\longdblarrowbox -\newbox\pushcharbox \newbox\bullbox -\newbox\equivbox \newbox\errorbox - -\let\ptexequiv = \equiv - -%{\tentt -%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} -%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} -%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} -%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} -% Adapted from the manmac format (p.420 of TeXbook) -%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex -% depth .1ex\hfil} -%} - -\def\point{$\star$} - -\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} -\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} -\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} - -\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} - -% Adapted from the TeXbook's \boxit. -{\tentt \global\dimen0 = 3em}% Width of the box. -\dimen2 = .55pt % Thickness of rules -% The text. (`r' is open on the right, `e' somewhat less so on the left.) -\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} - -\global\setbox\errorbox=\hbox to \dimen0{\hfil - \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. - \advance\hsize by -2\dimen2 % Rules. - \vbox{ - \hrule height\dimen2 - \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. - \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. - \kern3pt\vrule width\dimen2}% Space to right. - \hrule height\dimen2} - \hfil} - -% The @error{} command. -\def\error{\leavevmode\lower.7ex\copy\errorbox} - -% @tex ... @end tex escapes into raw Tex temporarily. -% One exception: @ is still an escape character, so that @end tex works. -% But \@ or @@ will get a plain tex @ character. - -\def\tex{\begingroup -\catcode `\\=0 \catcode `\{=1 \catcode `\}=2 -\catcode `\$=3 \catcode `\&=4 \catcode `\#=6 -\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie -\catcode `\%=14 -\catcode 43=12 -\catcode`\"=12 -\catcode`\==12 -\catcode`\|=12 -\catcode`\<=12 -\catcode`\>=12 -\escapechar=`\\ -% -\let\{=\ptexlbrace -\let\}=\ptexrbrace -\let\.=\ptexdot -\let\*=\ptexstar -\let\dots=\ptexdots -\def\@{@}% -\let\bullet=\ptexbullet -\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl -\let\L=\ptexL -% -\let\Etex=\endgroup} - -% Define @lisp ... @endlisp. -% @lisp does a \begingroup so it can rebind things, -% including the definition of @endlisp (which normally is erroneous). - -% Amount to narrow the margins by for @lisp. -\newskip\lispnarrowing \lispnarrowing=0.4in - -% This is the definition that ^M gets inside @lisp -% phr: changed space to \null, to avoid overfull hbox problems. -{\obeyspaces% -\gdef\lisppar{\null\endgraf}} - -% Cause \obeyspaces to make each Space cause a word-separation -% rather than the default which is that it acts punctuation. -% This is because space in tt font looks funny. -{\obeyspaces % -\gdef\sepspaces{\def {\ }}} - -\newskip\aboveenvskipamount \aboveenvskipamount= 0pt -\def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip -\endgraf \ifdim\lastskip<\aboveenvskipamount -\removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}} - -\def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount -\removelastskip \penalty-50 \vskip\aboveenvskipamount \fi} - -% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. -\let\nonarrowing=\relax - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \cartouche: draw rectangle w/rounded corners around argument -\font\circle=lcircle10 -\newdimen\circthick -\newdimen\cartouter\newdimen\cartinner -\newskip\normbskip\newskip\normpskip\newskip\normlskip -\circthick=\fontdimen8\circle -% -\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth -\def\ctr{{\hskip 6pt\circle\char'010}} -\def\cbl{{\circle\char'012\hskip -6pt}} -\def\cbr{{\hskip 6pt\circle\char'011}} -\def\carttop{\hbox to \cartouter{\hskip\lskip - \ctl\leaders\hrule height\circthick\hfil\ctr - \hskip\rskip}} -\def\cartbot{\hbox to \cartouter{\hskip\lskip - \cbl\leaders\hrule height\circthick\hfil\cbr - \hskip\rskip}} -% -\newskip\lskip\newskip\rskip - -\long\def\cartouche{% -\begingroup - \lskip=\leftskip \rskip=\rightskip - \leftskip=0pt\rightskip=0pt %we want these *outside*. - \cartinner=\hsize \advance\cartinner by-\lskip - \advance\cartinner by-\rskip - \cartouter=\hsize - \advance\cartouter by 18pt % allow for 3pt kerns on either -% side, and for 6pt waste from -% each corner char - \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip - % Flag to tell @lisp, etc., not to narrow margin. - \let\nonarrowing=\comment - \vbox\bgroup - \baselineskip=0pt\parskip=0pt\lineskip=0pt - \carttop - \hbox\bgroup - \hskip\lskip - \vrule\kern3pt - \vbox\bgroup - \hsize=\cartinner - \kern3pt - \begingroup - \baselineskip=\normbskip - \lineskip=\normlskip - \parskip=\normpskip - \vskip -\parskip -\def\Ecartouche{% - \endgroup - \kern3pt - \egroup - \kern3pt\vrule - \hskip\rskip - \egroup - \cartbot - \egroup -\endgroup -}} - -\def\lisp{\aboveenvbreak -\begingroup\inENV % This group ends at the end of the @lisp body -\hfuzz=12truept % Don't be fussy -% Make spaces be word-separators rather than space tokens. -\sepspaces % -% Single space lines -\singlespace % -% The following causes blank lines not to be ignored -% by adding a space to the end of each line. -\let\par=\lisppar -\def\Elisp{\endgroup\afterenvbreak}% -\parskip=0pt -% @cartouche defines \nonarrowing to inhibit narrowing -% at next level down. -\ifx\nonarrowing\relax -\advance \leftskip by \lispnarrowing -\exdentamount=\lispnarrowing -\let\exdent=\nofillexdent -\let\nonarrowing=\relax -\fi -\parindent=0pt -\obeyspaces \obeylines \tt \rawbackslash -\def\next##1{}\next} - - -\let\example=\lisp -\def\Eexample{\Elisp} - -\let\smallexample=\lisp -\def\Esmallexample{\Elisp} - -% Macro for 9 pt. examples, necessary to print with 5" lines. -% From Pavel@xerox. This is not really used unless the -% @smallbook command is given. - -\def\smalllispx{\aboveenvbreak\begingroup\inENV -% This group ends at the end of the @lisp body -\hfuzz=12truept % Don't be fussy -% Make spaces be word-separators rather than space tokens. -\sepspaces % -% Single space lines -\singlespace % -% The following causes blank lines not to be ignored -% by adding a space to the end of each line. -\let\par=\lisppar -\def\Esmalllisp{\endgroup\afterenvbreak}% -%%%% Smaller baseline skip for small examples. -\baselineskip 10pt -\parskip=0pt -% @cartouche defines \nonarrowing to inhibit narrowing -% at next level down. -\ifx\nonarrowing\relax -\advance \leftskip by \lispnarrowing -\exdentamount=\lispnarrowing -\let\exdent=\nofillexdent -\let\nonarrowing=\relax -\fi -\parindent=0pt -\obeyspaces \obeylines \ninett \indexfonts \rawbackslash -\def\next##1{}\next} - -% This is @display; same as @lisp except use roman font. - -\def\display{\begingroup\inENV %This group ends at the end of the @display body -\aboveenvbreak -% Make spaces be word-separators rather than space tokens. -\sepspaces % -% Single space lines -\singlespace % -% The following causes blank lines not to be ignored -% by adding a space to the end of each line. -\let\par=\lisppar -\def\Edisplay{\endgroup\afterenvbreak}% -\parskip=0pt -% @cartouche defines \nonarrowing to inhibit narrowing -% at next level down. -\ifx\nonarrowing\relax -\advance \leftskip by \lispnarrowing -\exdentamount=\lispnarrowing -\let\exdent=\nofillexdent -\let\nonarrowing=\relax -\fi -\parindent=0pt -\obeyspaces \obeylines -\def\next##1{}\next} - -% This is @format; same as @lisp except use roman font and don't narrow margins - -\def\format{\begingroup\inENV %This group ends at the end of the @format body -\aboveenvbreak -% Make spaces be word-separators rather than space tokens. -\sepspaces % -\singlespace % -% The following causes blank lines not to be ignored -% by adding a space to the end of each line. -\let\par=\lisppar -\def\Eformat{\endgroup\afterenvbreak} -\parskip=0pt \parindent=0pt -\obeyspaces \obeylines -\def\next##1{}\next} - -% @flushleft and @flushright - -\def\flushleft{% -\begingroup\inENV %This group ends at the end of the @format body -\aboveenvbreak -% Make spaces be word-separators rather than space tokens. -\sepspaces % -% The following causes blank lines not to be ignored -% by adding a space to the end of each line. -% This also causes @ to work when the directive name -% is terminated by end of line. -\let\par=\lisppar -\def\Eflushleft{\endgroup\afterenvbreak}% -\parskip=0pt \parindent=0pt -\obeyspaces \obeylines -\def\next##1{}\next} - -\def\flushright{% -\begingroup\inENV %This group ends at the end of the @format body -\aboveenvbreak -% Make spaces be word-separators rather than space tokens. -\sepspaces % -% The following causes blank lines not to be ignored -% by adding a space to the end of each line. -% This also causes @ to work when the directive name -% is terminated by end of line. -\let\par=\lisppar -\def\Eflushright{\endgroup\afterenvbreak}% -\parskip=0pt \parindent=0pt -\advance \leftskip by 0pt plus 1fill -\obeyspaces \obeylines -\def\next##1{}\next} - -% @quotation - narrow the margins. - -\def\quotation{% -\begingroup\inENV %This group ends at the end of the @quotation body -{\parskip=0pt % because we will skip by \parskip too, later -\aboveenvbreak}% -\singlespace -\parindent=0pt -\def\Equotation{\par\endgroup\afterenvbreak}% -% @cartouche defines \nonarrowing to inhibit narrowing -% at next level down. -\ifx\nonarrowing\relax -\advance \leftskip by \lispnarrowing -\advance \rightskip by \lispnarrowing -\exdentamount=\lispnarrowing -\let\nonarrowing=\relax -\fi} - -\message{defuns,} -% Define formatter for defuns -% First, allow user to change definition object font (\df) internally -\def\setdeffont #1 {\csname DEF#1\endcsname} - -\newskip\defbodyindent \defbodyindent=.4in -\newskip\defargsindent \defargsindent=50pt -\newskip\deftypemargin \deftypemargin=12pt -\newskip\deflastargmargin \deflastargmargin=18pt - -\newcount\parencount -% define \functionparens, which makes ( and ) and & do special things. -% \functionparens affects the group it is contained in. -\def\activeparens{% -\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active -\catcode`\[=\active \catcode`\]=\active} -{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) -\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } -\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} - -% Definitions of (, ) and & used in args for functions. -% This is the definition of ( outside of all parentheses. -\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested % -\global\advance\parencount by 1 } -% -% This is the definition of ( when already inside a level of parens. -\gdef\opnested{\char`\(\global\advance\parencount by 1 } -% -\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. -% also in that case restore the outer-level definition of (. -\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi -\global\advance \parencount by -1 } -% If we encounter &foo, then turn on ()-hacking afterwards -\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } -% -\gdef\normalparens{\boldbrax\let&=\ampnr} -} % End of definition inside \activeparens -%% These parens (in \boldbrax) actually are a little bolder than the -%% contained text. This is especially needed for [ and ] -\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&} -\def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} - -% First, defname, which formats the header line itself. -% #1 should be the function name. -% #2 should be the type of definition, such as "Function". - -\def\defname #1#2{% -% Get the values of \leftskip and \rightskip as they were -% outside the @def... -\dimen2=\leftskip -\advance\dimen2 by -\defbodyindent -\dimen3=\rightskip -\advance\dimen3 by -\defbodyindent -\noindent % -\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% -\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line -\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations -\parshape 2 0in \dimen0 \defargsindent \dimen1 % -% Now output arg 2 ("Function" or some such) -% ending at \deftypemargin from the right margin, -% but stuck inside a box of width 0 so it does not interfere with linebreaking -{% Adjust \hsize to exclude the ambient margins, -% so that \rightline will obey them. -\advance \hsize by -\dimen2 \advance \hsize by -\dimen3 -\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% -% Make all lines underfull and no complaints: -\tolerance=10000 \hbadness=10000 -\advance\leftskip by -\defbodyindent -\exdentamount=\defbodyindent -{\df #1}\enskip % Generate function name -} - -% Actually process the body of a definition -% #1 should be the terminating control sequence, such as \Edefun. -% #2 should be the "another name" control sequence, such as \defunx. -% #3 should be the control sequence that actually processes the header, -% such as \defunheader. - -\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % -\obeylines\activeparens\spacesplit#3} - -\def\defmethparsebody #1#2#3#4 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} - -\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} - -% These parsing functions are similar to the preceding ones -% except that they do not make parens into active characters. -% These are used for "variables" since they have no arguments. - -\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % -\obeylines\spacesplit#3} - -\def\defvrparsebody #1#2#3#4 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\spacesplit{#3{#4}}} - -\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\spacesplit{#3{#5}}} - -% Split up #2 at the first space token. -% call #1 with two arguments: -% the first is all of #2 before the space token, -% the second is all of #2 after that space token. -% If #2 contains no space token, all of it is passed as the first arg -% and the second is passed as empty. - -{\obeylines -\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% -\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% -\ifx\relax #3% -#1{#2}{}\else #1{#2}{#3#4}\fi}} - -% So much for the things common to all kinds of definitions. - -% Define @defun. - -% First, define the processing that is wanted for arguments of \defun -% Use this to expand the args and terminate the paragraph they make up - -\def\defunargs #1{\functionparens \sl -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -\hyphenchar\tensl=0 -#1% -\hyphenchar\tensl=45 -\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi% -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\penalty 10000\vskip -\parskip\penalty 10000% -} - -\def\deftypefunargs #1{% -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -\functionparens -\code{#1}% -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\penalty 10000\vskip -\parskip\penalty 10000% -} - -% Do complete processing of one @defun or @defunx line already parsed. - -% @deffn Command forward-char nchars - -\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} - -\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% -\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defun == @deffn Function - -\def\defun{\defparsebody\Edefun\defunx\defunheader} - -\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Function}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefun int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} - -% #1 is the data type. #2 is the name and args. -\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} -% #1 is the data type, #2 the name, #3 the args. -\def\deftypefunheaderx #1#2 #3\relax{% -\doind {fn}{\code{#2}}% Make entry in function index -\begingroup\defname {\code{#1} #2}{Function}% -\deftypefunargs {#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} - -% #1 is the classification. #2 is the data type. #3 is the name and args. -\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} -% #1 is the classification, #2 the data type, #3 the name, #4 the args. -\def\deftypefnheaderx #1#2#3 #4\relax{% -\doind {fn}{\code{#3}}% Make entry in function index -\begingroup\defname {\code{#2} #3}{#1}% -\deftypefunargs {#4}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defmac == @deffn Macro - -\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} - -\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Macro}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defspec == @deffn Special Form - -\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} - -\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{Special Form}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% This definition is run if you use @defunx -% anywhere other than immediately after a @defun or @defunx. - -\def\deffnx #1 {\errmessage{@deffnx in invalid context}} -\def\defunx #1 {\errmessage{@defunx in invalid context}} -\def\defmacx #1 {\errmessage{@defmacx in invalid context}} -\def\defspecx #1 {\errmessage{@defspecx in invalid context}} -\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} -\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}} - -% @defmethod, and so on - -% @defop {Funny Method} foo-class frobnicate argument - -\def\defop #1 {\def\defoptype{#1}% -\defopparsebody\Edefop\defopx\defopheader\defoptype} - -\def\defopheader #1#2#3{% -\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index -\begingroup\defname {#2}{\defoptype{} on #1}% -\defunargs {#3}\endgroup % -} - -% @defmethod == @defop Method - -\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} - -\def\defmethodheader #1#2#3{% -\dosubind {fn}{\code{#2}}{on #1}% entry in function index -\begingroup\defname {#2}{Method on #1}% -\defunargs {#3}\endgroup % -} - -% @defcv {Class Option} foo-class foo-flag - -\def\defcv #1 {\def\defcvtype{#1}% -\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} - -\def\defcvarheader #1#2#3{% -\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index -\begingroup\defname {#2}{\defcvtype{} of #1}% -\defvarargs {#3}\endgroup % -} - -% @defivar == @defcv {Instance Variable} - -\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} - -\def\defivarheader #1#2#3{% -\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index -\begingroup\defname {#2}{Instance Variable of #1}% -\defvarargs {#3}\endgroup % -} - -% These definitions are run if you use @defmethodx, etc., -% anywhere other than immediately after a @defmethod, etc. - -\def\defopx #1 {\errmessage{@defopx in invalid context}} -\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} -\def\defcvx #1 {\errmessage{@defcvx in invalid context}} -\def\defivarx #1 {\errmessage{@defivarx in invalid context}} - -% Now @defvar - -% First, define the processing that is wanted for arguments of @defvar. -% This is actually simple: just print them in roman. -% This must expand the args and terminate the paragraph they make up -\def\defvarargs #1{\normalparens #1% -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000} - -% @defvr Counter foo-count - -\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} - -\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% -\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} - -% @defvar == @defvr Variable - -\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} - -\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{Variable}% -\defvarargs {#2}\endgroup % -} - -% @defopt == @defvr {User Option} - -\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} - -\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{User Option}% -\defvarargs {#2}\endgroup % -} - -% @deftypevar int foobar - -\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} - -% #1 is the data type. #2 is the name. -\def\deftypevarheader #1#2{% -\doind {vr}{\code{#2}}% Make entry in variables index -\begingroup\defname {\code{#1} #2}{Variable}% -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000 -\endgroup} - -% @deftypevr {Global Flag} int enable - -\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} - -\def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% -\begingroup\defname {\code{#2} #3}{#1} -\interlinepenalty=10000 -\endgraf\penalty 10000\vskip -\parskip\penalty 10000 -\endgroup} - -% This definition is run if you use @defvarx -% anywhere other than immediately after a @defvar or @defvarx. - -\def\defvrx #1 {\errmessage{@defvrx in invalid context}} -\def\defvarx #1 {\errmessage{@defvarx in invalid context}} -\def\defoptx #1 {\errmessage{@defoptx in invalid context}} -\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} -\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} - -% Now define @deftp -% Args are printed in bold, a slight difference from @defvar. - -\def\deftpargs #1{\bf \defvarargs{#1}} - -% @deftp Class window height width ... - -\def\deftp{\defvrparsebody\Edeftp\deftpx\deftpheader} - -\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% -\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} - -% This definition is run if you use @deftpx, etc -% anywhere other than immediately after a @deftp, etc. - -\def\deftpx #1 {\errmessage{@deftpx in invalid context}} - -\message{cross reference,} -% Define cross-reference macros -\newwrite \auxfile - -\newif\ifhavexrefs % True if xref values are known. -\newif\ifwarnedxrefs % True if we warned once that they aren't known. - -% \setref{foo} defines a cross-reference point named foo. - -\def\setref#1{% -%\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Ysectionnumberandtype}} - -\def\unnumbsetref#1{% -%\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Ynothing}} - -\def\appendixsetref#1{% -%\dosetq{#1-title}{Ytitle}% -\dosetq{#1-pg}{Ypagenumber}% -\dosetq{#1-snt}{Yappendixletterandtype}} - -% \xref, \pxref, and \ref generate cross-references to specified points. -% For \xrefX, #1 is the node name, #2 the name of the Info -% cross-reference, #3 the printed node name, #4 the name of the Info -% file, #5 the name of the printed manual. All but the node name can be -% omitted. -% -\def\pxref#1{see \xrefX[#1,,,,,,,]} -\def\xref#1{See \xrefX[#1,,,,,,,]} -\def\ref#1{\xrefX[#1,,,,,,,]} -\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup% -\def\printedmanual{\ignorespaces #5}% -\def\printednodename{\ignorespaces #3}% -% -\setbox1=\hbox{\printedmanual}% -\setbox0=\hbox{\printednodename}% -\ifdim \wd0=0pt% -\def\printednodename{\ignorespaces #1}% -%%% Uncommment the following line to make the actual chapter or section title -%%% appear inside the square brackets. -%\def\printednodename{#1-title}% -\fi% -% -% -% If we use \unhbox0 and \unhbox1 to print the node names, TeX does -% not insert empty discretionaries after hyphens, which means that it -% will not find a line break at a hyphen in a node names. Since some -% manuals are best written with fairly long node names, containing -% hyphens, this is a loss. Therefore, we simply give the text of -% the node name again, so it is as if TeX is seeing it for the first -% time. -\ifdim \wd1>0pt -section ``\printednodename'' in \cite{\printedmanual}% -\else% -\turnoffactive% -\refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}% -\fi -\endgroup} - -% \dosetq is the interface for calls from other macros - -% Use \turnoffactive so that punctuation chars such as underscore -% work in node names. -\def\dosetq #1#2{{\let\folio=0 \turnoffactive% -\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}% -\next}} - -% \internalsetq {foo}{page} expands into -% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} -% When the aux file is read, ' is the escape character - -\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} - -% Things to be expanded by \internalsetq - -\def\Ypagenumber{\folio} - -\def\Ytitle{\thischapter} - -\def\Ynothing{} - -\def\Ysectionnumberandtype{% -\ifnum\secno=0 Chapter\xreftie\the\chapno % -\else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno % -\else \ifnum \subsubsecno=0 % -Section\xreftie\the\chapno.\the\secno.\the\subsecno % -\else % -Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\def\Yappendixletterandtype{% -\ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}% -\else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno % -\else \ifnum \subsubsecno=0 % -Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno % -\else % -Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\gdef\xreftie{'tie} - -% Use TeX 3.0's \inputlineno to get the line number, for better error -% messages, but if we're using an old version of TeX, don't do anything. -% -\ifx\inputlineno\thisisundefined - \let\linenumber = \empty % Non-3.0. -\else - \def\linenumber{\the\inputlineno:\space} -\fi - -% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. -% If its value is nonempty, SUFFIX is output afterward. - -\def\refx#1#2{% - \expandafter\ifx\csname X#1\endcsname\relax - % If not defined, say something at least. - $\langle$un\-de\-fined$\rangle$% - \ifhavexrefs - \message{\linenumber Undefined cross reference `#1'.}% - \else - \ifwarnedxrefs\else - \global\warnedxrefstrue - \message{Cross reference values unknown; you must run TeX again.}% - \fi - \fi - \else - % It's defined, so just use it. - \csname X#1\endcsname - \fi - #2% Output the suffix in any case. -} - -% Read the last existing aux file, if any. No error if none exists. - -% This is the macro invoked by entries in the aux file. -\def\xrdef #1#2{ -{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}} - -\def\readauxfile{% -\begingroup -\catcode `\^^@=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\^^C=\other -\catcode `\^^D=\other -\catcode `\^^E=\other -\catcode `\^^F=\other -\catcode `\^^G=\other -\catcode `\^^H=\other -\catcode `\ =\other -\catcode `\^^L=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode `\=\other -\catcode 26=\other -\catcode `\^^[=\other -\catcode `\^^\=\other -\catcode `\^^]=\other -\catcode `\^^^=\other -\catcode `\^^_=\other -\catcode `\@=\other -\catcode `\^=\other -\catcode `\~=\other -\catcode `\[=\other -\catcode `\]=\other -\catcode`\"=\other -\catcode`\_=\other -\catcode`\|=\other -\catcode`\<=\other -\catcode`\>=\other -\catcode `\$=\other -\catcode `\#=\other -\catcode `\&=\other -% the aux file uses ' as the escape. -% Turn off \ as an escape so we do not lose on -% entries which were dumped with control sequences in their names. -% For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ -% Reference to such entries still does not work the way one would wish, -% but at least they do not bomb out when the aux file is read in. -\catcode `\{=1 \catcode `\}=2 -\catcode `\%=\other -\catcode `\'=0 -\catcode `\\=\other -\openin 1 \jobname.aux -\ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue -\fi -% Open the new aux file. Tex will close it automatically at exit. -\openout \auxfile=\jobname.aux -\endgroup} - - -% Footnotes. - -\newcount \footnoteno - -% The trailing space in the following definition for supereject is -% vital for proper filling; pages come out unaligned when you do a -% pagealignmacro call if that space before the closing brace is -% removed. -\def\supereject{\par\penalty -20000\footnoteno =0 } - -% @footnotestyle is meaningful for info output only.. -\let\footnotestyle=\comment - -\let\ptexfootnote=\footnote - -{\catcode `\@=11 -\long\gdef\footnote #1{\global\advance \footnoteno by \@ne -\unskip -\edef\thisfootno{$^{\the\footnoteno}$}% -\let\@sf\empty -\ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi -\thisfootno\@sf \footnotezzz{#1}} -% \parsearg\footnotezzz} - -\long\gdef\footnotezzz #1{\insert\footins{ -\interlinepenalty\interfootnotelinepenalty -\splittopskip\ht\strutbox % top baseline for broken footnotes -\splitmaxdepth\dp\strutbox \floatingpenalty\@MM -\leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip -\footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}} - -}%end \catcode `\@=11 - -% End of control word definitions. - -\message{and turning on texinfo input format.} - -\def\openindices{% - \newindex{cp}% - \newcodeindex{fn}% - \newcodeindex{vr}% - \newcodeindex{tp}% - \newcodeindex{ky}% - \newcodeindex{pg}% -} - -% Set some numeric style parameters, for 8.5 x 11 format. - -%\hsize = 6.5in -\newdimen\defaultparindent \defaultparindent = 15pt -\parindent = \defaultparindent -\parskip 18pt plus 1pt -\baselineskip 15pt -\advance\topskip by 1.2cm - -% Prevent underfull vbox error messages. -\vbadness=10000 - -% Following George Bush, just get rid of widows and orphans. -\widowpenalty=10000 -\clubpenalty=10000 - -% Use TeX 3.0's \emergencystretch to help line breaking, but if we're -% using an old version of TeX, don't do anything. We want the amount of -% stretch added to depend on the line length, hence the dependence on -% \hsize. This makes it come to about 9pt for the 8.5x11 format. -% -\ifx\emergencystretch\thisisundefined \else - \emergencystretch = \hsize - \divide\emergencystretch by 45 -\fi - -% Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25) -\def\smallbook{ -\global\lispnarrowing = 0.3in -\global\baselineskip 12pt -\advance\topskip by -1cm -\global\parskip 3pt plus 1pt -\global\hsize = 5in -\global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in -\global\vsize=7.5in -\global\tolerance=700 -\global\hfuzz=1pt -\global\contentsrightmargin=0pt - -\global\pagewidth=\hsize -\global\pageheight=\vsize - -\global\let\smalllisp=\smalllispx -\global\let\smallexample=\smalllispx -\global\def\Esmallexample{\Esmalllisp} -} - -% Use @afourpaper to print on European A4 paper. -\def\afourpaper{ -\global\tolerance=700 -\global\hfuzz=1pt -\global\baselineskip=12pt -\global\parskip 15pt plus 1pt - -\global\vsize= 53\baselineskip -\advance\vsize by \topskip -%\global\hsize= 5.85in % A4 wide 10pt -\global\hsize= 6.5in -\global\outerhsize=\hsize -\global\advance\outerhsize by 0.5in -\global\outervsize=\vsize -\global\advance\outervsize by 0.6in -\global\doublecolumnhsize=\hsize -\global\divide\doublecolumnhsize by 2 -\global\advance\doublecolumnhsize by -0.1in -\global\doublecolumnvsize=\vsize -\global\multiply\doublecolumnvsize by 2 -\global\advance\doublecolumnvsize by 0.1in - -\global\pagewidth=\hsize -\global\pageheight=\vsize -} - -%% For a final copy, take out the rectangles -%% that mark overfull boxes (in case you have decided -%% that the text looks ok even though it passes the margin). -\def\finalout{\overfullrule=0pt} - -% Define macros to output various characters with catcode for normal text. -\catcode`\"=\other -\catcode`\~=\other -\catcode`\^=\other -\catcode`\_=\other -\catcode`\|=\other -\catcode`\<=\other -\catcode`\>=\other -\catcode`\+=\other -\def\normaldoublequote{"} -\def\normaltilde{~} -\def\normalcaret{^} -\def\normalunderscore{_} -\def\normalverticalbar{|} -\def\normalless{<} -\def\normalgreater{>} -\def\normalplus{+} - -% This macro is used to make a character print one way in ttfont -% where it can probably just be output, and another way in other fonts, -% where something hairier probably needs to be done. -% -% #1 is what to print if we are indeed using \tt; #2 is what to print -% otherwise. Since all the Computer Modern typewriter fonts have zero -% interword stretch (and shrink), and it is reasonable to expect all -% typewriter fonts to have this, we can check that font parameter. -% -\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} - -% Turn off all special characters except @ -% (and those which the user can use as if they were ordinary). -% Most of these we simply print from the \tt font, but for some, we can -% use math or other variants that look better in normal text. - -\catcode`\"=\active -\def\activedoublequote{{\tt \char '042}} -\let"=\activedoublequote -\catcode`\~=\active -\def~{{\tt \char '176}} -\chardef\hat=`\^ -\catcode`\^=\active -\def^{{\tt \hat}} - -\catcode`\_=\active -\def_{\ifusingtt\normalunderscore\_} -% Subroutine for the previous macro. -\def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}} - -% \lvvmode is equivalent in function to \leavevmode. -% Using \leavevmode runs into trouble when written out to -% an index file due to the expansion of \leavevmode into ``\unhbox -% \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our -% magic tricks with @. -\def\lvvmode{\vbox to 0pt{}} - -\catcode`\|=\active -\def|{{\tt \char '174}} -\chardef \less=`\< -\catcode`\<=\active -\def<{{\tt \less}} -\chardef \gtr=`\> -\catcode`\>=\active -\def>{{\tt \gtr}} -\catcode`\+=\active -\def+{{\tt \char 43}} -%\catcode 27=\active -%\def^^[{$\diamondsuit$} - -% Used sometimes to turn off (effectively) the active characters -% even after parsing them. -\def\turnoffactive{\let"=\normaldoublequote -\let~=\normaltilde -\let^=\normalcaret -\let_=\normalunderscore -\let|=\normalverticalbar -\let<=\normalless -\let>=\normalgreater -\let+=\normalplus} - -% Set up an active definition for =, but don't enable it most of the time. -{\catcode`\==\active -\global\def={{\tt \char 61}}} - -\catcode`\@=0 - -% \rawbackslashxx output one backslash character in current font -\global\chardef\rawbackslashxx=`\\ -%{\catcode`\\=\other -%@gdef@rawbackslashxx{\}} - -% \rawbackslash redefines \ as input to do \rawbackslashxx. -{\catcode`\\=\active -@gdef@rawbackslash{@let\=@rawbackslashxx }} - -% \normalbackslash outputs one backslash in fixed width font. -\def\normalbackslash{{\tt\rawbackslashxx}} - -% Say @foo, not \foo, in error messages. -\escapechar=`\@ - -% \catcode 17=0 % Define control-q -\catcode`\\=\active - -% If a .fmt file is being used, we don't want the `\input texinfo' to show up. -% That is what \eatinput is for; after that, the `\' should revert to printing -% a backslash. -% -@gdef@eatinput input texinfo{@fixbackslash} -@global@let\ = @eatinput - -% On the other hand, perhaps the file did not have a `\input texinfo'. Then -% the first `\{ in the file would cause an error. This macro tries to fix -% that, assuming it is called before the first `\' could plausibly occur. -% -@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi} - -%% These look ok in all fonts, so just make them not special. The @rm below -%% makes sure that the current font starts out as the newly loaded cmr10 -@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other - -@textfonts -@rm - -@c Local variables: -@c page-delimiter: "^\\\\message" -@c End: diff --git a/gnu/usr.bin/gzip-1.0.7/trees.c b/gnu/usr.bin/gzip-1.0.7/trees.c deleted file mode 100644 index a432435f0e79..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/trees.c +++ /dev/null @@ -1,1076 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -/* - * PURPOSE - * - * Encode various sets of source values using variable-length - * binary code trees. - * - * DISCUSSION - * - * The PKZIP "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in the ZIP file in a compressed form - * which is itself a Huffman encoding of the lengths of - * all the code strings (in ascending order by source values). - * The actual code strings are reconstructed from the lengths in - * the UNZIP process, as described in the "application note" - * (APPNOTE.TXT) distributed as part of PKWARE's PKZIP program. - * - * REFERENCES - * - * Lynch, Thomas J. - * Data Compression: Techniques and Applications, pp. 53-55. - * Lifetime Learning Publications, 1985. ISBN 0-534-03418-7. - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - * - * INTERFACE - * - * void ct_init (ush *attr, int *methodp) - * Allocate the match buffer, initialize the various tables and save - * the location of the internal file attribute (ascii/binary) and - * method (DEFLATE/STORE) - * - * void ct_tally (int dist, int lc); - * Save the match info and tally the frequency counts. - * - * long flush_block (char *buf, ulg stored_len, int eof) - * Determine the best encoding for the current block: dynamic trees, - * static trees or store, and output the encoded block to the zip - * file. Returns the total compressed length for the file so far. - * - */ - -#include "tailor.h" -#include "gzip.h" - -#include -#include - -#ifndef lint -static char rcsid[] = "$Id: trees.c,v 1.1 1993/04/10 15:56:21 cgd Exp $"; -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - - -local int near extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local int near extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local int near extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#ifndef LIT_BUFSIZE -# ifdef SMALL_MEM -# define LIT_BUFSIZE 0x2000 -# else -# ifdef MEDIUM_MEM -# define LIT_BUFSIZE 0x4000 -# else -# define LIT_BUFSIZE 0x8000 -# endif -# endif -#endif -#ifndef DIST_BUFSIZE -# define DIST_BUFSIZE LIT_BUFSIZE -#endif -/* Sizes of match buffers for literals/lengths and distances. There are - * 4 reasons for limiting LIT_BUFSIZE to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input data is - * still in the window so we can still emit a stored block even when input - * comes from standard input. (This can also be done for all blocks if - * LIT_BUFSIZE is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting trees - * more frequently. - * - I can't count above 4 - * The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to save - * memory at the expense of compression). Some optimizations would be possible - * if we rely on DIST_BUFSIZE == LIT_BUFSIZE. - */ -#if LIT_BUFSIZE > INBUFSIZ - error cannot overlay l_buf and inbuf -#endif - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -/* =========================================================================== - * Local data - */ - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -local ct_data near dyn_ltree[HEAP_SIZE]; /* literal and length tree */ -local ct_data near dyn_dtree[2*D_CODES+1]; /* distance tree */ - -local ct_data near static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see ct_init - * below). - */ - -local ct_data near static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -local ct_data near bl_tree[2*BL_CODES+1]; -/* Huffman tree for the bit lengths */ - -typedef struct tree_desc { - ct_data near *dyn_tree; /* the dynamic tree */ - ct_data near *static_tree; /* corresponding static tree or NULL */ - int near *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ - int max_code; /* largest code with non zero frequency */ -} tree_desc; - -local tree_desc near l_desc = -{dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0}; - -local tree_desc near d_desc = -{dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0}; - -local tree_desc near bl_desc = -{bl_tree, (ct_data near *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0}; - - -local ush near bl_count[MAX_BITS+1]; -/* number of codes at each bit length for an optimal tree */ - -local uch near bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -local int near heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ -local int heap_len; /* number of elements in the heap */ -local int heap_max; /* element of largest frequency */ -/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - -local uch near depth[2*L_CODES+1]; -/* Depth of each subtree used as tie breaker for trees of equal frequency */ - -local uch length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local uch dist_code[512]; -/* distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -local int near base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int near base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -#define l_buf inbuf -/* DECLARE(uch, l_buf, LIT_BUFSIZE); buffer for literals or lengths */ - -/* DECLARE(ush, d_buf, DIST_BUFSIZE); buffer for distances */ - -local uch near flag_buf[(LIT_BUFSIZE/8)]; -/* flag_buf is a bit array distinguishing literals from lengths in - * l_buf, thus indicating the presence or absence of a distance. - */ - -local unsigned last_lit; /* running index in l_buf */ -local unsigned last_dist; /* running index in d_buf */ -local unsigned last_flags; /* running index in flag_buf */ -local uch flags; /* current flags not yet saved in flag_buf */ -local uch flag_bit; /* current bit used in flags */ -/* bits are filled in flags starting at bit 0 (least significant). - * Note: these flags are overkill in the current code since we don't - * take advantage of DIST_BUFSIZE == LIT_BUFSIZE. - */ - -local ulg opt_len; /* bit length of current block with optimal trees */ -local ulg static_len; /* bit length of current block with static trees */ - -local ulg compressed_len; /* total bit length of compressed file */ - -local ulg input_len; /* total byte length of input file */ -/* input_len is for debugging only since we can get it by other means. */ - -ush *file_type; /* pointer to UNKNOWN, BINARY or ASCII */ -int *file_method; /* pointer to DEFLATE or STORE */ - -#ifdef DEBUG -extern ulg bits_sent; /* bit length of the compressed data */ -extern long isize; /* byte length of input file */ -#endif - -extern long block_start; /* window offset of current block */ -extern unsigned near strstart; /* window offset of current string */ - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void init_block OF((void)); -local void pqdownheap OF((ct_data near *tree, int k)); -local void gen_bitlen OF((tree_desc near *desc)); -local void gen_codes OF((ct_data near *tree, int max_code)); -local void build_tree OF((tree_desc near *desc)); -local void scan_tree OF((ct_data near *tree, int max_code)); -local void send_tree OF((ct_data near *tree, int max_code)); -local int build_bl_tree OF((void)); -local void send_all_trees OF((int lcodes, int dcodes, int blcodes)); -local void compress_block OF((ct_data near *ltree, ct_data near *dtree)); -local void set_file_type OF((void)); - - -#ifndef DEBUG -# define send_code(c, tree) send_bits(tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* DEBUG */ -# define send_code(c, tree) \ - { if (verbose>1) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(tree[c].Code, tree[c].Len); } -#endif - -#define d_code(dist) \ - ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. dist_code[256] and dist_code[257] are never - * used. - */ - -#define MAX(a,b) (a >= b ? a : b) -/* the arguments must not have side effects */ - -/* =========================================================================== - * Allocate the match buffer, initialize the various tables and save the - * location of the internal file attribute (ascii/binary) and method - * (DEFLATE/STORE). - */ -void ct_init(attr, methodp) - ush *attr; /* pointer to internal file attribute */ - int *methodp; /* pointer to compression method */ -{ - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - - file_type = attr; - file_method = methodp; - compressed_len = input_len = 0L; - - if (static_dtree[0].Len != 0) return; /* ct_init already called */ - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "ct_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data near *)static_ltree, L_CODES+1); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse(n, 5); - } - - /* Initialize the first block of the first file: */ - init_block(); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block() -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) bl_tree[n].Freq = 0; - - dyn_ltree[END_BLOCK].Freq = 1; - opt_len = static_len = 0L; - last_lit = last_dist = last_flags = 0; - flags = 0; flag_bit = 1; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(tree, top) \ -{\ - top = heap[SMALLEST]; \ - heap[SMALLEST] = heap[heap_len--]; \ - pqdownheap(tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(tree, k) - ct_data near *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = heap[k]; - int j = k << 1; /* left son of k */ - while (j <= heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < heap_len && smaller(tree, heap[j+1], heap[j])) j++; - - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, heap[j])) break; - - /* Exchange v with the smallest son */ - heap[k] = heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(desc) - tree_desc near *desc; /* the tree descriptor */ -{ - ct_data near *tree = desc->dyn_tree; - int near *extra = desc->extra_bits; - int base = desc->extra_base; - int max_code = desc->max_code; - int max_length = desc->max_length; - ct_data near *stree = desc->static_tree; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[heap[heap_max]].Len = 0; /* root of the heap */ - - for (h = heap_max+1; h < HEAP_SIZE; h++) { - n = heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - opt_len += (ulg)f * (bits + xbits); - if (stree) static_len += (ulg)f * (stree[n].Len + xbits); - } - if (overflow == 0) return; - - Trace((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (bl_count[bits] == 0) bits--; - bl_count[bits]--; /* move one leaf down the tree */ - bl_count[bits+1] += 2; /* move one overflow item as its brother */ - bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = bl_count[bits]; - while (n != 0) { - m = heap[--h]; - if (m > max_code) continue; - if (tree[m].Len != (unsigned) bits) { - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - opt_len += ((long)bits-(long)tree[m].Len)*(long)tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code) - ct_data near *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; - ct_data near *stree = desc->static_tree; - int elems = desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node = elems; /* next internal node of the tree */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - heap_len = 0, heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - heap[++heap_len] = max_code = n; - depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (heap_len < 2) { - int new = heap[++heap_len] = (max_code < 2 ? ++max_code : 0); - tree[new].Freq = 1; - depth[new] = 0; - opt_len--; if (stree) static_len -= stree[new].Len; - /* new is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = heap_len/2; n >= 1; n--) pqdownheap(tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - do { - pqremove(tree, n); /* n = node of least frequency */ - m = heap[SMALLEST]; /* m = node of next least frequency */ - - heap[--heap_max] = n; /* keep the nodes sorted by frequency */ - heap[--heap_max] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - depth[node] = (uch) (MAX(depth[n], depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - heap[SMALLEST] = node++; - pqdownheap(tree, SMALLEST); - - } while (heap_len >= 2); - - heap[--heap_max] = heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen((tree_desc near *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data near *)tree, max_code); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. Updates opt_len to take into account the repeat - * counts. (The contribution of the bit length codes will be added later - * during the construction of bl_tree.) - */ -local void scan_tree (tree, max_code) - ct_data near *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) bl_tree[curlen].Freq++; - bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - bl_tree[REPZ_3_10].Freq++; - } else { - bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (tree, max_code) - ct_data near *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(curlen, bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(curlen, bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(REP_3_6, bl_tree); send_bits(count-3, 2); - - } else if (count <= 10) { - send_code(REPZ_3_10, bl_tree); send_bits(count-3, 3); - - } else { - send_code(REPZ_11_138, bl_tree); send_bits(count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree() -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree((ct_data near *)dyn_ltree, l_desc.max_code); - scan_tree((ct_data near *)dyn_dtree, d_desc.max_code); - - /* Build the bit length tree: */ - build_tree((tree_desc near *)(&bl_desc)); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - opt_len += 3*(max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", opt_len, static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(lcodes, dcodes, blcodes) - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(dcodes-1, 5); - send_bits(blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", bits_sent)); - - send_tree((ct_data near *)dyn_ltree, lcodes-1); /* send the literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", bits_sent)); - - send_tree((ct_data near *)dyn_dtree, dcodes-1); /* send the distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", bits_sent)); -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. This function - * returns the total compressed length for the file so far. - */ -ulg flush_block(buf, stored_len, eof) - char *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex; /* index of last bit length code of non zero freq */ - - flag_buf[last_flags] = flags; /* Save the flags for the last 8 items */ - - /* Check if the file is ascii or binary */ - if (*file_type == (ush)UNKNOWN) set_file_type(); - - /* Construct the literal and distance trees */ - build_tree((tree_desc near *)(&l_desc)); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", opt_len, static_len)); - - build_tree((tree_desc near *)(&d_desc)); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", opt_len, static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(); - - /* Determine the best encoding. Compute first the block length in bytes */ - opt_lenb = (opt_len+3+7)>>3; - static_lenb = (static_len+3+7)>>3; - input_len += stored_len; /* for debugging only */ - - Trace((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ", - opt_lenb, opt_len, static_lenb, static_len, stored_len, - last_lit, last_dist)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - /* If compression failed and this is the first and last block, - * and if the zip file can be seeked (to rewrite the local header), - * the whole file is transformed into a stored file: - */ -#ifdef FORCE_METHOD - if (level == 1 && eof && compressed_len == 0L) { /* force stored file */ -#else - if (stored_len <= opt_lenb && eof && compressed_len == 0L && seekable()) { -#endif - /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ - if (buf == (char*)0) error ("block vanished"); - - copy_block(buf, (unsigned)stored_len, 0); /* without header */ - compressed_len = stored_len << 3; - *file_method = STORED; - -#ifdef FORCE_METHOD - } else if (level == 2 && buf != (char*)0) { /* force stored block */ -#else - } else if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - send_bits((STORED_BLOCK<<1)+eof, 3); /* send block type */ - compressed_len = (compressed_len + 3 + 7) & ~7L; - compressed_len += (stored_len + 4) << 3; - - copy_block(buf, (unsigned)stored_len, 1); /* with header */ - -#ifdef FORCE_METHOD - } else if (level == 3) { /* force static trees */ -#else - } else if (static_lenb == opt_lenb) { -#endif - send_bits((STATIC_TREES<<1)+eof, 3); - compress_block((ct_data near *)static_ltree, (ct_data near *)static_dtree); - compressed_len += 3 + static_len; - } else { - send_bits((DYN_TREES<<1)+eof, 3); - send_all_trees(l_desc.max_code+1, d_desc.max_code+1, max_blindex+1); - compress_block((ct_data near *)dyn_ltree, (ct_data near *)dyn_dtree); - compressed_len += 3 + opt_len; - } - Assert (compressed_len == bits_sent, "bad compressed size"); - init_block(); - - if (eof) { - Assert (input_len == isize, "bad input size"); - bi_windup(); - compressed_len += 7; /* align on byte boundary */ - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", compressed_len>>3, - compressed_len-7*eof)); - - return compressed_len >> 3; -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int ct_tally (dist, lc) - int dist; /* distance of matched string */ - int lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - l_buf[last_lit++] = (uch)lc; - if (dist == 0) { - /* lc is the unmatched char */ - dyn_ltree[lc].Freq++; - } else { - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "ct_tally: bad match"); - - dyn_ltree[length_code[lc]+LITERALS+1].Freq++; - dyn_dtree[d_code(dist)].Freq++; - - d_buf[last_dist++] = (ush)dist; - flags |= flag_bit; - } - flag_bit <<= 1; - - /* Output the flags if they fill a byte: */ - if ((last_lit & 7) == 0) { - flag_buf[last_flags++] = flags; - flags = 0, flag_bit = 1; - } - /* Try to guess if it is profitable to stop the current block here */ - if (level > 2 && (last_lit & 0xfff) == 0) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)last_lit*8L; - ulg in_length = (ulg)strstart-block_start; - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)dyn_dtree[dcode].Freq*(5L+extra_dbits[dcode]); - } - out_length >>= 3; - Trace((stderr,"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ", - last_lit, last_dist, in_length, out_length, - 100L - out_length*100L/in_length)); - if (last_dist < last_lit/2 && out_length < in_length/2) return 1; - } - return (last_lit == LIT_BUFSIZE-1 || last_dist == DIST_BUFSIZE); - /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(ltree, dtree) - ct_data near *ltree; /* literal tree */ - ct_data near *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned dx = 0; /* running index in d_buf */ - unsigned fx = 0; /* running index in flag_buf */ - uch flag = 0; /* current flags */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (last_lit != 0) do { - if ((lx & 7) == 0) flag = flag_buf[fx++]; - lc = l_buf[lx++]; - if ((flag & 1) == 0) { - send_code(lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = length_code[lc]; - send_code(code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(lc, extra); /* send the extra length bits */ - } - dist = d_buf[dx++]; - /* Here, dist is the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - send_bits(dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - flag >>= 1; - } while (lx < last_lit); - - send_code(END_BLOCK, ltree); -} - -/* =========================================================================== - * Set the file type to ASCII or BINARY, using a crude approximation: - * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. - * IN assertion: the fields freq of dyn_ltree are set and the total of all - * frequencies does not exceed 64K (to fit in an int on 16 bit machines). - */ -local void set_file_type() -{ - int n = 0; - unsigned ascii_freq = 0; - unsigned bin_freq = 0; - while (n < 7) bin_freq += dyn_ltree[n++].Freq; - while (n < 128) ascii_freq += dyn_ltree[n++].Freq; - while (n < LITERALS) bin_freq += dyn_ltree[n++].Freq; - *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; - if (*file_type == BINARY && translate_eol) { - warn("-l used on binary file", ""); - } -} diff --git a/gnu/usr.bin/gzip-1.0.7/unlzw.c b/gnu/usr.bin/gzip-1.0.7/unlzw.c deleted file mode 100644 index 3272d0df1191..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/unlzw.c +++ /dev/null @@ -1,365 +0,0 @@ -/* unlzw.c -- decompress files in LZW format. - * The code in this file is directly derived from the public domain 'compress' - * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, - * Ken Turkowski, Dave Mack and Peter Jannesen. - * - * This is a temporary version which will be rewritten in some future version - * to accommodate in-memory decompression. - */ - -#ifndef lint -static char rcsid[] = "$Id: unlzw.c,v 1.1 1993/04/10 15:56:22 cgd Exp $"; -#endif - -#include "tailor.h" -#include "gzip.h" -#include "lzw.h" - -#include - -#ifdef HAVE_UNISTD_H -# include -# include -#endif - -typedef unsigned char char_type; -typedef long code_int; -typedef unsigned long count_int; -typedef unsigned short count_short; -typedef unsigned long cmp_code_int; - -#define MAXCODE(n) (1L << (n)) - -#ifndef REGISTERS -# define REGISTERS 2 -#endif -#define REG1 -#define REG2 -#define REG3 -#define REG4 -#define REG5 -#define REG6 -#define REG7 -#define REG8 -#define REG9 -#define REG10 -#define REG11 -#define REG12 -#define REG13 -#define REG14 -#define REG15 -#define REG16 -#if REGISTERS >= 1 -# undef REG1 -# define REG1 register -#endif -#if REGISTERS >= 2 -# undef REG2 -# define REG2 register -#endif -#if REGISTERS >= 3 -# undef REG3 -# define REG3 register -#endif -#if REGISTERS >= 4 -# undef REG4 -# define REG4 register -#endif -#if REGISTERS >= 5 -# undef REG5 -# define REG5 register -#endif -#if REGISTERS >= 6 -# undef REG6 -# define REG6 register -#endif -#if REGISTERS >= 7 -# undef REG7 -# define REG7 register -#endif -#if REGISTERS >= 8 -# undef REG8 -# define REG8 register -#endif -#if REGISTERS >= 9 -# undef REG9 -# define REG9 register -#endif -#if REGISTERS >= 10 -# undef REG10 -# define REG10 register -#endif -#if REGISTERS >= 11 -# undef REG11 -# define REG11 register -#endif -#if REGISTERS >= 12 -# undef REG12 -# define REG12 register -#endif -#if REGISTERS >= 13 -# undef REG13 -# define REG13 register -#endif -#if REGISTERS >= 14 -# undef REG14 -# define REG14 register -#endif -#if REGISTERS >= 15 -# undef REG15 -# define REG15 register -#endif -#if REGISTERS >= 16 -# undef REG16 -# define REG16 register -#endif - -#ifndef BYTEORDER -# define BYTEORDER 0000 -#endif - -#ifndef NOALLIGN -# define NOALLIGN 0 -#endif - - -union bytes { - long word; - struct { -#if BYTEORDER == 4321 - char_type b1; - char_type b2; - char_type b3; - char_type b4; -#else -#if BYTEORDER == 1234 - char_type b4; - char_type b3; - char_type b2; - char_type b1; -#else -# undef BYTEORDER - int dummy; -#endif -#endif - } bytes; -}; - -#if BYTEORDER == 4321 && NOALLIGN == 1 -# define input(b,o,c,n,m){ \ - (c) = (*(long *)(&(b)[(o)>>3])>>((o)&0x7))&(m); \ - (o) += (n); \ - } -#else -# define input(b,o,c,n,m){ \ - REG1 char_type *p = &(b)[(o)>>3]; \ - (c) = ((((long)(p[0]))|((long)(p[1])<<8)| \ - ((long)(p[2])<<16))>>((o)&0x7))&(m); \ - (o) += (n); \ - } -#endif - -#ifndef MAXSEG_64K - /* DECLARE(ush, tab_prefix, (1<>1] -# define clear_tab_prefixof() \ - memzero(tab_prefix0, 128), \ - memzero(tab_prefix1, 128); -#endif -#define de_stack ((char_type *)(&d_buf[DIST_BUFSIZE-1])) -#define tab_suffixof(i) tab_suffix[i] - -int block_mode = BLOCK_MODE; /* block compress mode -C compatible with 2.0 */ - -/* ============================================================================ - * Decompress in to out. This routine adapts to the codes in the - * file building the "string" table on-the-fly; requiring no table to - * be stored in the compressed file. - * IN assertions: the buffer inbuf contains already the beginning of - * the compressed data, from offsets iptr to insize-1 included. - * The magic header has already been checked and skipped. - * bytes_in and bytes_out have been initialized. - */ -void unlzw(in, out) - int in, out; /* input and output file descriptors */ -{ - REG2 char_type *stackp; - REG3 code_int code; - REG4 int finchar; - REG5 code_int oldcode; - REG6 code_int incode; - REG7 long inbits; - REG8 long posbits; - REG9 int outpos; -/* REG10 int insize; (global) */ - REG11 unsigned bitmask; - REG12 code_int free_ent; - REG13 code_int maxcode; - REG14 code_int maxmaxcode; - REG15 int n_bits; - REG16 int rsize; - -#ifdef MAXSEG_64K - tab_prefix[0] = tab_prefix0; - tab_prefix[1] = tab_prefix1; -#endif - maxbits = get_byte(); - block_mode = maxbits & BLOCK_MODE; - if ((maxbits & LZW_RESERVED) != 0) { - WARN((stderr, "%s: %s: warning, unknown flags 0x%x\n", - progname, ifname, maxbits & LZW_RESERVED)); - } - maxbits &= BIT_MASK; - maxmaxcode = MAXCODE(maxbits); - - if (maxbits > BITS) { - fprintf(stderr, - "%s: %s: compressed with %d bits, can only handle %d bits\n", - progname, ifname, maxbits, BITS); - exit_code = ERROR; - return; - } - rsize = insize; - maxcode = MAXCODE(n_bits = INIT_BITS)-1; - bitmask = (1<= 0 ; --code) { - tab_suffixof(code) = (char_type)code; - } - do { - REG1 int i; - int e; - int o; - - resetbuf: - e = insize-(o = (posbits>>3)); - - for (i = 0 ; i < e ; ++i) { - inbuf[i] = inbuf[i+o]; - } - insize = e; - posbits = 0; - - if (insize < INBUF_EXTRA) { - if ((rsize = read(in, inbuf+insize, INBUFSIZ)) == EOF) { - read_error(); - } - insize += rsize; - } - inbits = ((rsize != 0) ? ((long)insize - insize%n_bits)<<3 : - ((long)insize<<3)-(n_bits-1)); - - while (inbits > posbits) { - if (free_ent > maxcode) { - posbits = ((posbits-1) + - ((n_bits<<3)-(posbits-1+(n_bits<<3))%(n_bits<<3))); - ++n_bits; - if (n_bits == maxbits) { - maxcode = maxmaxcode; - } else { - maxcode = MAXCODE(n_bits)-1; - } - bitmask = (1<= free_ent) { /* Special case for KwKwK string. */ - if (code > free_ent) { - - REG1 char_type *p; - - posbits -= n_bits; - p = &inbuf[posbits>>3]; -#ifdef DEBUG - fprintf(stderr, - "code:%ld free_ent:%ld n_bits:%d insize:%u\n", - code, free_ent, n_bits, insize); - fprintf(stderr, - "posbits:%ld inbuf:%02X %02X %02X %02X %02X\n", - posbits, p[-1],p[0],p[1],p[2],p[3]); -#endif - if (!test && outpos > 0) { - write_buf(out, outbuf, outpos); - } - error("corrupt input. Use zcat to recover some data."); - } - *--stackp = (char_type)finchar; - code = oldcode; - } - - while ((cmp_code_int)code >= (cmp_code_int)256) { - /* Generate output characters in reverse order */ - *--stackp = tab_suffixof(code); - code = tab_prefixof(code); - } - *--stackp = (char_type)(finchar = tab_suffixof(code)); - - /* And put them out in forward order */ - { - REG1 int i; - - if (outpos+(i = (de_stack-stackp)) >= OUTBUFSIZ) { - do { - if (i > OUTBUFSIZ-outpos) i = OUTBUFSIZ-outpos; - - if (i > 0) { - memcpy(outbuf+outpos, stackp, i); - outpos += i; - } - if (outpos >= OUTBUFSIZ) { - if (!test) write_buf(out, outbuf, outpos); - outpos = 0; - } - stackp+= i; - } while ((i = (de_stack-stackp)) > 0); - } else { - memcpy(outbuf+outpos, stackp, i); - outpos += i; - } - } - - if ((code = free_ent) < maxmaxcode) { /* Generate the new entry. */ - - tab_prefixof(code) = (unsigned short)oldcode; - tab_suffixof(code) = (char_type)finchar; - free_ent = code+1; - } - oldcode = incode; /* Remember previous code. */ - } - bytes_in += rsize; - - } while (rsize != 0); - - if (!test && outpos > 0) write_buf(out, outbuf, outpos); -} diff --git a/gnu/usr.bin/gzip-1.0.7/unpack.c b/gnu/usr.bin/gzip-1.0.7/unpack.c deleted file mode 100644 index 7c22280e5ede..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/unpack.c +++ /dev/null @@ -1,238 +0,0 @@ -/* unpack.c -- decompress files in pack format. - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#ifndef lint -static char rcsid[] = "$Id: unpack.c,v 1.1 1993/04/10 15:56:23 cgd Exp $"; -#endif - -#include "tailor.h" -#include "gzip.h" -#include "crypt.h" - -#include - -#define MIN(a,b) ((a) <= (b) ? (a) : (b)) -/* The arguments must not have side effects. */ - -#define MAX_BITLEN 25 -/* Maximum length of Huffman codes. (Minor modifications to the code - * would be needed to support 32 bits codes, but pack never generates - * more than 24 bits anyway.) - */ - -#define LITERALS 256 -/* Number of literals, excluding the End of Block (EOB) code */ - -#define MAX_PEEK 12 -/* Maximum number of 'peek' bits used to optimize traversal of the - * Huffman tree. - */ - -local ulg orig_len; /* original uncompressed length */ -local int max_len; /* maximum bit length of Huffman codes */ - -local uch literal[LITERALS]; -/* The literal bytes present in the Huffman tree. The EOB code is not - * represented. - */ - -local int lit_base[MAX_BITLEN+1]; -/* All literals of a given bit length are contiguous in literal[] and - * have contiguous codes. literal[code+lit_base[len]] is the literal - * for a code of len bits. - */ - -local int leaves [MAX_BITLEN+1]; /* Number of leaves for each bit length */ -local int parents[MAX_BITLEN+1]; /* Number of parents for each bit length */ - -local int peek_bits; /* Number of peek bits currently used */ - -local uch prefix_len[1 << MAX_PEEK]; -/* For each bit pattern b of peek_bits bits, prefix_len[b] is the length - * of the Huffman code starting with a prefix of b (upper bits), or 0 - * if all codes of prefix b have more than peek_bits bits. It is not - * necessary to have a huge table (large MAX_PEEK) because most of the - * codes encountered in the input stream are short codes (by construction). - * So for most codes a single lookup will be necessary. - */ - -local ulg bitbuf; -/* Bits are added on the low part of bitbuf and read from the high part. */ - -local int valid; /* number of valid bits in bitbuf */ -/* all bits above the last valid bit are always zero */ - -/* Set code to the next 'bits' input bits without skipping them. code - * must be the name of a simple variable and bits must not have side effects. - * IN assertions: bits <= 25 (so that we still have room for an extra byte - * when valid is only 24), and mask = (1<> (valid-(bits))) & (mask); \ -} - -/* Skip the given number of bits (after having peeked at them): */ -#define skip_bits(bits) (valid -= (bits)) - -#define clear_bitbuf() (valid = 0, bitbuf = 0) - -/* Local functions */ - -local void read_tree OF((void)); -local void build_tree OF((void)); - -/* =========================================================================== - * Read the Huffman tree. - */ -local void read_tree() -{ - int len; /* bit length */ - int base; /* base offset for a sequence of leaves */ - int n; - - /* Read the original input size, MSB first */ - orig_len = 0; - for (n = 1; n <= 4; n++) orig_len = (orig_len << 8) | (ulg)get_byte(); - - max_len = (int)get_byte(); /* maximum bit length of Huffman codes */ - if (max_len > MAX_BITLEN) { - error("invalid compressed data -- Huffman code > 32 bits"); - } - - /* Get the number of leaves at each bit length */ - n = 0; - for (len = 1; len <= max_len; len++) { - leaves[len] = (int)get_byte(); - n += leaves[len]; - } - if (n > LITERALS) { - error("too many leaves in Huffman tree"); - } - Trace((stderr, "orig_len %ld, max_len %d, leaves %d\n", - orig_len, max_len, n)); - /* There are at least 2 and at most 256 leaves of length max_len. - * (Pack arbitrarily rejects empty files and files consisting of - * a single byte even repeated.) To fit the last leaf count in a - * byte, it is offset by 2. However, the last literal is the EOB - * code, and is not transmitted explicitly in the tree, so we must - * adjust here by one only. - */ - leaves[max_len]++; - - /* Now read the leaves themselves */ - base = 0; - for (len = 1; len <= max_len; len++) { - /* Remember where the literals of this length start in literal[] : */ - lit_base[len] = base; - /* And read the literals: */ - for (n = leaves[len]; n > 0; n--) { - literal[base++] = (uch)get_byte(); - } - } - leaves[max_len]++; /* Now include the EOB code in the Huffman tree */ -} - -/* =========================================================================== - * Build the Huffman tree and the prefix table. - */ -local void build_tree() -{ - int nodes = 0; /* number of nodes (parents+leaves) at current bit length */ - int len; /* current bit length */ - uch *prefixp; /* pointer in prefix_len */ - - for (len = max_len; len >= 1; len--) { - /* The number of parent nodes at this level is half the total - * number of nodes at parent level: - */ - nodes >>= 1; - parents[len] = nodes; - /* Update lit_base by the appropriate bias to skip the parent nodes - * (which are not represented in the literal array): - */ - lit_base[len] -= nodes; - /* Restore nodes to be parents+leaves: */ - nodes += leaves[len]; - } - /* Construct the prefix table, from shortest leaves to longest ones. - * The shortest code is all ones, so we start at the end of the table. - */ - peek_bits = MIN(max_len, MAX_PEEK); - prefixp = &prefix_len[1< prefix_len) *--prefixp = 0; -} - -/* =========================================================================== - * Unpack in to out. This routine does not support the old pack format - * with magic header \037\037. - * - * IN assertions: the buffer inbuf contains already the beginning of - * the compressed data, from offsets inptr to insize-1 included. - * The magic header has already been checked. The output buffer is cleared. - */ -void unpack(in, out) - int in, out; /* input and output file descriptors */ -{ - int len; /* Bit length of current code */ - unsigned eob; /* End Of Block code */ - register unsigned peek; /* lookahead bits */ - unsigned peek_mask; /* Mask for peek_bits bits */ - - ifd = in; - ofd = out; - - read_tree(); /* Read the Huffman tree */ - build_tree(); /* Build the prefix table */ - clear_bitbuf(); /* Initialize bit input */ - peek_mask = (1< 0) { - peek >>= peek_bits - len; /* discard the extra bits */ - } else { - /* Code of more than peek_bits bits, we must traverse the tree */ - ulg mask = peek_mask; - len = peek_bits; - do { - len++, mask = (mask<<1)+1; - look_bits(peek, len, mask); - } while (peek < parents[len]); - /* loop as long as peek is a parent node */ - } - /* At this point, peek is the next complete code, of len bits */ - if (peek == eob && len == max_len) break; /* end of file? */ - put_char(literal[peek+lit_base[len]]); - Tracev((stderr,"%02d %04x %c\n", len, peek, - literal[peek+lit_base[len]])); - skip_bits(len); - } /* for (;;) */ - - flush_window(); - Trace((stderr, "bytes_out %ld\n", bytes_out)); - if (orig_len != bytes_out) { - error("invalid compressed data--length error"); - } -} - - diff --git a/gnu/usr.bin/gzip-1.0.7/unzip.c b/gnu/usr.bin/gzip-1.0.7/unzip.c deleted file mode 100644 index ace819877296..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/unzip.c +++ /dev/null @@ -1,186 +0,0 @@ -/* unzip.c -- decompress files in gzip or pkzip format. - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - * - * The code in this file is derived from the file funzip.c written - * and put in the public domain by Mark Adler. - */ - -/* - This version can extract files in gzip or pkzip format. - For the latter, only the first entry is extracted, and it has to be - either deflated or stored. - */ - -#ifndef lint -static char rcsid[] = "$Id: unzip.c,v 1.1 1993/04/10 15:56:25 cgd Exp $"; -#endif - -#include "tailor.h" -#include "gzip.h" -#include "crypt.h" - -#include - -/* PKZIP header definitions */ -#define LOCSIG 0x04034b50L /* four-byte lead-in (lsb first) */ -#define LOCFLG 6 /* offset of bit flag */ -#define CRPFLG 1 /* bit for encrypted entry */ -#define EXTFLG 8 /* bit for extended local header */ -#define LOCHOW 8 /* offset of compression method */ -#define LOCTIM 10 /* file mod time (for decryption) */ -#define LOCCRC 14 /* offset of crc */ -#define LOCSIZ 18 /* offset of compressed size */ -#define LOCLEN 22 /* offset of uncompressed length */ -#define LOCFIL 26 /* offset of file name field length */ -#define LOCEXT 28 /* offset of extra field length */ -#define LOCHDR 30 /* size of local header, including sig */ -#define EXTHDR 16 /* size of extended local header, inc sig */ - - -/* Globals */ - -int decrypt; /* flag to turn on decryption */ -char *key; /* not used--needed to link crypt.c */ -int pkzip = 0; /* set for a pkzip file */ -int extended = 0; /* set if extended local header */ - -/* =========================================================================== - * Check zip file and advance inptr to the start of the compressed data. - * Get ofname from the local header if necessary. - */ -int check_zipfile(in) - int in; /* input file descriptors */ -{ - uch *h = inbuf + inptr; /* first local header */ - - ifd = in; - - /* Check validity of local header, and skip name and extra fields */ - inptr += LOCHDR + SH(h + LOCFIL) + SH(h + LOCEXT); - - if (inptr > insize || LG(h) != LOCSIG) { - error("input not a zip file or empty"); - } - method = h[LOCHOW]; - if (method != STORED && method != DEFLATED) { - error("first entry not deflated or stored -- use unzip"); - } - - /* If entry encrypted, decrypt and validate encryption header */ - if ((decrypt = h[LOCFLG] & CRPFLG) != 0) { - fprintf(stderr, "encrypted file, not yet supported.\n"); - exit_code = ERROR; - return -1; - } - - /* Save flags for unzip() */ - extended = (h[LOCFLG] & EXTFLG) != 0; - pkzip = 1; - - /* Get ofname and time stamp from local header (to be done) */ - return 0; -} - -/* =========================================================================== - * Unzip in to out. This routine works on both gzip and pkzip files. - * - * IN assertions: the buffer inbuf contains already the beginning of - * the compressed data, from offsets inptr to insize-1 included. - * The magic header has already been checked. The output buffer is cleared. - */ -void unzip(in, out) - int in, out; /* input and output file descriptors */ -{ - ulg orig_crc = 0; /* original crc */ - ulg orig_len = 0; /* original uncompressed length */ - int n; - uch buf[EXTHDR]; /* extended local header */ - - ifd = in; - ofd = out; - - updcrc(NULL, 0); /* initialize crc */ - - if (pkzip && !extended) { /* crc and length at the end otherwise */ - orig_crc = LG(inbuf + LOCCRC); - orig_len = LG(inbuf + LOCLEN); - } - - /* Decompress */ - if (method == DEFLATED) { - - int res = inflate(); - - if (res == 3) { - error("out of memory"); - } else if (res != 0) { - error("invalid compressed data--format violated"); - } - - } else if (pkzip && method == STORED) { - - register ulg n = LG(inbuf + LOCLEN); - - if (n != LG(inbuf + LOCSIZ) - (decrypt ? RAND_HEAD_LEN : 0)) { - - fprintf(stderr, "len %ld, siz %ld\n", n, LG(inbuf + LOCSIZ)); - error("invalid compressed data--length mismatch"); - } - while (n--) { - uch c = (uch)get_byte(); -#ifdef CRYPT - if (decrypt) zdecode(c); -#endif - put_char(c); - } - flush_window(); - } else { - error("internal error, invalid method"); - } - - /* Get the crc and original length */ - if (!pkzip) { - /* crc32 (see algorithm.doc) - * uncompressed input size modulo 2^32 - */ - for (n = 0; n < 8; n++) { - buf[n] = (uch)get_byte(); /* may cause an error if EOF */ - } - orig_crc = LG(buf); - orig_len = LG(buf+4); - - } else if (extended) { /* If extended header, check it */ - /* signature - 4bytes: 0x50 0x4b 0x07 0x08 - * CRC-32 value - * compressed size 4-bytes - * uncompressed size 4-bytes - */ - for (n = 0; n < EXTHDR; n++) { - buf[n] = (uch)get_byte(); /* may cause an error if EOF */ - } - orig_crc = LG(buf+4); - orig_len = LG(buf+12); - } - - /* Validate decompression */ - if (orig_crc != updcrc(outbuf, 0)) { - error("invalid compressed data--crc error"); - } - if (orig_len != bytes_out) { - error("invalid compressed data--length error"); - } - - /* Check if there are more entries in a pkzip file */ - if (pkzip && inptr + 4 < insize && LG(inbuf+inptr) == LOCSIG) { - if (to_stdout) { - fprintf(stderr, - "warning: zip file has more than one entry--rest ignored\n"); - } else { - /* Don't destroy the input zip file */ - error("zip file has more than one entry"); - } - } - extended = pkzip = 0; /* for next file */ -} diff --git a/gnu/usr.bin/gzip-1.0.7/util.c b/gnu/usr.bin/gzip-1.0.7/util.c deleted file mode 100644 index b587210f57bc..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/util.c +++ /dev/null @@ -1,414 +0,0 @@ -/* util.c -- utility functions for gzip support - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#ifndef lint -static char rcsid[] = "$Id: util.c,v 1.1 1993/04/10 15:56:28 cgd Exp $"; -#endif - -#include "tailor.h" -#include "gzip.h" -#include "crypt.h" - -#include -#include -#include - -#ifdef HAVE_UNISTD_H -# include -# include -#endif - -#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H) -# include -#else - extern int errno; -#endif - -extern ulg crc_32_tab[]; /* crc table, defined below */ - -/* =========================================================================== - * Run a set of bytes through the crc shift register. If s is a NULL - * pointer, then initialize the crc shift register contents instead. - * Return the current crc in either case. - */ -ulg updcrc(s, n) - uch *s; /* pointer to bytes to pump through */ - unsigned n; /* number of bytes in s[] */ -{ - register ulg c; /* temporary variable */ - - static ulg crc = (ulg)0xffffffffL; /* shift register contents */ - - if (s == NULL) { - c = 0xffffffffL; - } else { - c = crc; - while (n--) { - c = crc_32_tab[((int)c ^ (*s++)) & 0xff] ^ (c >> 8); - } - } - crc = c; - return c ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */ -} - -/* =========================================================================== - * Clear input and output buffers - */ -void clear_bufs() -{ - outcnt = 0; - insize = inptr = 0; - bytes_in = bytes_out = 0L; -} - -/* =========================================================================== - * Fill the input buffer. This is called only when the buffer is empty - * and at least one byte is really needed. - */ -int fill_inbuf() -{ - int len; - - /* Read as much as possible */ - insize = 0; - do { - len = read(ifd, inbuf+insize, INBUFSIZ-insize); - if (len == 0 || len == EOF) break; - insize += len; - } while (insize < INBUFSIZ); - - if (insize == 0) { - read_error(); - } - bytes_in += (ulg)insize; - inptr = 1; - return inbuf[0]; -} - -/* =========================================================================== - * Write the output buffer outbuf[0..outcnt-1] and update bytes_out. - * (used for the compressed data only) - */ -void flush_outbuf() -{ - if (outcnt == 0) return; - - write_buf(ofd, (char *)outbuf, outcnt); - bytes_out += (ulg)outcnt; - outcnt = 0; -} - -/* =========================================================================== - * Write the output window window[0..outcnt-1] and update crc and bytes_out. - * (Used for the decompressed data only.) - */ -void flush_window() -{ - if (outcnt == 0) return; - updcrc(window, outcnt); - - if (!test) { - write_buf(ofd, (char *)window, outcnt); - } - bytes_out += (ulg)outcnt; - outcnt = 0; -} - -/* =========================================================================== - * Does the same as write(), but also handles partial pipe writes and checks - * for error return. - */ -void write_buf(fd, buf, cnt) - int fd; - voidp buf; - unsigned cnt; -{ - unsigned n; - - while ((n = write(fd, buf, cnt)) != cnt) { - if (n == (unsigned)(-1)) { - write_error(); - } - cnt -= n; - buf = (voidp)((char*)buf+n); - } -} - -/* ======================================================================== - * Put string s in lower case, return s. - */ -char *strlwr(s) - char *s; -{ - char *t; - for (t = s; *t; t++) *t = tolow(*t); - return s; -} - -/* ======================================================================== - * Return the base name of a file (remove any directory prefix and - * any version suffix). For systems with filenames that are not - * case sensitive, force the base name to lower case. - */ -char *basename(fname) - char *fname; -{ - char *p; - - if ((p = strrchr(fname, PATH_SEP)) != NULL) fname = p+1; -#ifdef PATH_SEP2 - if ((p = strrchr(fname, PATH_SEP2)) != NULL) fname = p+1; -#endif -#ifdef PATH_SEP3 - if ((p = strrchr(fname, PATH_SEP3)) != NULL) fname = p+1; -#endif -#ifdef SUFFIX_SEP - if ((p = strrchr(fname, SUFFIX_SEP)) != NULL) *p = '\0'; -#endif - if (casemap('A') == 'a') strlwr(fname); - return fname; -} - -#if defined(NO_STRING_H) && !defined(STDC_HEADERS) - -/* Provide missing strspn and strcspn functions. */ - -# ifndef __STDC__ -# define const -# endif - -int strspn OF((const char *s, const char *accept)); -int strcspn OF((const char *s, const char *reject)); - -/* ======================================================================== - * Return the length of the maximum initial segment - * of s which contains only characters in accept. - */ -int strspn(s, accept) - const char *s; - const char *accept; -{ - register const char *p; - register const char *a; - register int count = 0; - - for (p = s; *p != '\0'; ++p) { - for (a = accept; *a != '\0'; ++a) { - if (*p == *a) break; - } - if (*a == '\0') return count; - ++count; - } - return count; -} - -/* ======================================================================== - * Return the length of the maximum inital segment of s - * which contains no characters from reject. - */ -int strcspn(s, reject) - const char *s; - const char *reject; -{ - register int count = 0; - - while (*s != '\0') { - if (strchr(reject, *s++) != NULL) return count; - ++count; - } - return count; -} - -#endif /* NO_STRING_H */ - -/* ======================================================================== - * Add an environment variable (if any) before argv, and update argc. - * Return the expanded environment variable to be freed later, or NULL - * if no options were added to argv. - */ -#define SEPARATOR " \t" /* separators in env variable */ - -char *add_envopt(argcp, argvp, env) - int *argcp; /* pointer to argc */ - char ***argvp; /* pointer to argv */ - char *env; /* name of environment variable */ -{ - char *p; /* running pointer through env variable */ - char **oargv; /* runs through old argv array */ - char **nargv; /* runs through new argv array */ - int oargc = *argcp; /* old argc */ - int nargc = 0; /* number of arguments in env variable */ - - env = (char*)getenv(env); - if (env == NULL) return NULL; - - p = (char*)xmalloc(strlen(env)+1); - env = strcpy(p, env); /* keep env variable intact */ - - for (p = env; *p; nargc++ ) { /* move through env */ - p += strspn(p, SEPARATOR); /* skip leading separators */ - if (*p == '\0') break; - - p += strcspn(p, SEPARATOR); /* find end of word */ - if (*p) *p++ = '\0'; /* mark it */ - } - if (nargc == 0) { - free(env); env = NULL; - return NULL; - } - *argcp += nargc; - /* Allocate the new argv array, with an extra element just in case - * the original arg list did not end with a NULL. - */ - nargv = (char**)calloc(*argcp+1, sizeof(char *)); - if (nargv == NULL) error("out of memory"); - oargv = *argvp; - *argvp = nargv; - - /* Copy the program name first */ - if (oargc-- < 0) error("argc<=0"); - *(nargv++) = *(oargv++); - - /* Then copy the environment args */ - for (p = env; nargc > 0; nargc--) { - p += strspn(p, SEPARATOR); /* skip separators */ - *(nargv++) = p; /* store start */ - while (*p++) ; /* skip over word */ - } - - /* Finally copy the old args and add a NULL (usual convention) */ - while (oargc--) *(nargv++) = *(oargv++); - *nargv = NULL; - return env; -} - -/* ======================================================================== - * Error handlers. - */ -void error(m) - char *m; -{ - fprintf(stderr, "\n%s: %s: %s\n", progname, ifname, m); - abort_gzip(); -} - -void warn(a, b) - char *a, *b; /* message strings juxtaposed in output */ -{ - WARN((stderr, "%s: %s: warning: %s%s\n", progname, ifname, a, b)); -} - -void read_error() -{ - fprintf(stderr, "\n%s: ", progname); - if (errno != 0) { - perror(ifname); - } else { - fprintf(stderr, "%s: unexpected end of file\n", ifname); - } - abort_gzip(); -} - -void write_error() -{ - fprintf(stderr, "\n%s: ", progname); - perror(ofname); - abort_gzip(); -} - -/* ======================================================================== - * Display compression ratio on stderr. - */ -void display_ratio(num, den) - long num; - long den; -{ - long ratio; /* 1000 times the compression ratio */ - - if (den == 0) { - ratio = 0; /* no compression */ - } else if (den < 2147483L) { /* (2**31 -1)/1000 */ - ratio = 1000L*num/den; - } else { - ratio = num/(den/1000L); - } - if (ratio < 0) { - putc('-', stderr); - ratio = -ratio; - } - fprintf(stderr, "%2ld.%ld%%", ratio / 10L, ratio % 10L); -} - - -/* ======================================================================== - * Semi-safe malloc -- never returns NULL. - */ -voidp xmalloc (size) - unsigned size; -{ - voidp cp = (voidp)malloc (size); - - if (cp == NULL) error("out of memory"); - return cp; -} - -/* ======================================================================== - * Table of CRC-32's of all single-byte values (made by makecrc.c) - */ -ulg crc_32_tab[] = { - 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, - 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, - 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, - 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, - 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, - 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, - 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, - 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, - 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, - 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, - 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, - 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, - 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, - 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, - 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, - 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, - 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, - 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, - 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, - 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, - 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, - 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, - 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, - 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, - 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, - 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, - 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, - 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, - 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, - 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, - 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, - 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, - 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, - 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, - 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, - 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, - 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, - 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, - 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, - 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, - 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, - 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, - 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, - 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, - 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, - 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, - 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, - 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, - 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, - 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, - 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, - 0x2d02ef8dL -}; diff --git a/gnu/usr.bin/gzip-1.0.7/zdiff.1 b/gnu/usr.bin/gzip-1.0.7/zdiff.1 deleted file mode 100644 index ca07a4a8f823..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/zdiff.1 +++ /dev/null @@ -1,45 +0,0 @@ -.TH ZDIFF 1 -.SH NAME -zcmp, zdiff \- compare compressed files -.SH SYNOPSIS -.B zcmp -[ cmp_options ] file1 -[ file2 ] -.br -.B zdiff -[ diff_options ] file1 -[ file2 ] -.SH DESCRIPTION -.I Zcmp -and -.I zdiff -are used to invoke the -.I cmp -or the -.I diff -program on compressed files. All options specified are passed directly to -.I cmp -or -.IR diff "." -If only 1 file is specified, then the files compared are -.I file1 -and an uncompressed -.IR file1 ".z." -If two files are specified, then they are uncompressed (if ending with ".z") -and fed to -.I cmp -or -.IR diff "." -The exit status from -.I cmp -or -.I diff -is preserved. -.SH "SEE ALSO" -cmp(1), diff(1), zmore(1), znew(1), zforce(1), gzip(1), gzexe(1) -.SH BUGS -Messages from the -.I cmp -or -.I diff -programs refer to temporary filenames instead of those specified. diff --git a/gnu/usr.bin/gzip-1.0.7/zdiff.in b/gnu/usr.bin/gzip-1.0.7/zdiff.in deleted file mode 100644 index d7eac98942f5..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/zdiff.in +++ /dev/null @@ -1,68 +0,0 @@ -: -#!/bin/sh - -# Zcmp and zdiff are used to invoke the cmp or the diff pro- -# gram on compressed files. All options specified are passed -# directly to cmp or diff. If only 1 file is specified, then -# the files compared are file1 and an uncompressed file1.z. -# If two files are specified, then they are uncompressed (if -# ending with ".z") and fed to cmp or diff. The exit status -# from cmp or diff is preserved. - -prog=`echo $0 | sed 's|.*/||'` -case "$prog" in - *cmp) comp=${CMP-cmp} ;; - *) comp=${DIFF-diff} ;; -esac - -OPTIONS= -FILES= -for ARG -do - case "$ARG" in - -*) OPTIONS="$OPTIONS $ARG";; - *) if test -f "$ARG"; then - FILES="$FILES $ARG" - else - echo "${prog}: $ARG not found or not a regular file" - exit 1 - fi ;; - esac -done -if test -z "$FILES"; then - echo "Usage: $prog [${comp}_options] file [file]" - exit 1 -fi -set $FILES -if test $# -eq 1; then - FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'` - gzip -cd "$1" | $comp $OPTIONS - "$FILE" - STAT="$?" - -elif test $# -eq 2; then - case "$1" in - *[-.][zZ] | *.t[ga]z) - case "$2" in - *[-.][zZ] | *.t[ga]z) - F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*$||'` - gzip -cd "$2" > /tmp/"$F".$$ - gzip -cd "$1" | $comp $OPTIONS - /tmp/"$F".$$ - STAT="$?" - /bin/rm -f /tmp/"$F".$$;; - - *) gzip -cd "$1" | $comp $OPTIONS - "$2" - STAT="$?";; - esac;; - *) case "$2" in - *[-.][zZ] | *.t[ga]z) - gzip -cd "$2" | $comp $OPTIONS "$1" - - STAT="$?";; - *) $comp $OPTIONS "$1" "$2" - STAT="$?";; - esac;; - esac - exit "$STAT" -else - echo "Usage: $prog [${comp}_options] file [file]" - exit 1 -fi diff --git a/gnu/usr.bin/gzip-1.0.7/zforce.1 b/gnu/usr.bin/gzip-1.0.7/zforce.1 deleted file mode 100644 index c82ace162bfa..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/zforce.1 +++ /dev/null @@ -1,23 +0,0 @@ -.TH ZFORCE 1 -.SH NAME -zforce \- force a 'z' extension on all gzip files -.SH SYNOPSIS -.B zforce -[ name ... ] -.SH DESCRIPTION -.I zforce -forces a z extension on all -.I gzip -files so that -.I gzip -will not compress them twice. -This can be useful for files with names truncated after a file transfer. -On systems with a 14 char limitation on file names, the original name -is truncated to make room for the .z suffix. For example, -12345678901234 is renamed to 123456789012.z. A file name such as foo.tgz -is left intact. -.SH "SEE ALSO" -gzip(1), znew(1), zmore(1), zcmp(1), gzexe(1) -.SH BUGS -File names of exactly 13 characters are first truncated to 12 characters -even on file systems not limited to 14 characters. diff --git a/gnu/usr.bin/gzip-1.0.7/zforce.in b/gnu/usr.bin/gzip-1.0.7/zforce.in deleted file mode 100644 index c9a2d22d7da0..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/zforce.in +++ /dev/null @@ -1,45 +0,0 @@ -: -#!/bin/sh -# zforce: force a z extension on all gzip files so that gzip will not -# compress them twice. -# -# This can be useful for files with names truncated after a file transfer. -# 12345678901234 is renamed to 123456789012.z - -x=`basename $0` -if test $# = 0; then - echo "force a '.z' extension on all gzip files" - echo usage: $x files... - exit 1 -fi - -res=0 -for i do - if test ! -f "$i" ; then - echo ${x}: $i not a file - res=1 - continue - fi - test `expr "$i" : '.*[.-]z$'` -eq 0 || continue - test `expr "$i" : '.*[.]t[ag]z$'` -eq 0 || continue - - gzip -t "$i" 2>/dev/null || continue - - if test `expr "$i" : '^.............$'` -eq 13; then - new=`expr "$i" : '\(.*\).$`.z - else - new="$i.z" - fi - if mv "$i" "$new" 2>/dev/null; then - echo $i -- replaced with $new - continue - fi - new=`expr "$i" : '\(.*\)..$`.z - - if mv "$i" "$new" 2>/dev/null; then - echo $i -- replaced with $new - continue - fi - res=1; echo ${x}: cannot rename $i to $new -done -exit $res diff --git a/gnu/usr.bin/gzip-1.0.7/zip.c b/gnu/usr.bin/gzip-1.0.7/zip.c deleted file mode 100644 index f455a4ab3423..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/zip.c +++ /dev/null @@ -1,113 +0,0 @@ -/* zip.c -- compress files to the gzip or pkzip format - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#ifndef lint -static char rcsid[] = "$Id: zip.c,v 1.1 1993/04/10 15:56:34 cgd Exp $"; -#endif - -#include "tailor.h" -#include "gzip.h" -#include "crypt.h" - -#include -#include - -#ifdef HAVE_UNISTD_H -# include -# include -#endif - -local ulg crc; /* crc on uncompressed file data */ -long overhead; /* number of bytes in gzip header */ - -/* =========================================================================== - * Deflate in to out. - * IN assertions: the input and output buffers are cleared. - * The variables time_stamp and save_orig_name are initialized. - */ -void zip(in, out) - int in, out; /* input and output file descriptors */ -{ - uch flags = 0; /* general purpose bit flags */ - ush attr = 0; /* ascii/binary flag */ - ush deflate_flags = 0; /* pkzip -es, -en or -ex equivalent */ - - ifd = in; - ofd = out; - outcnt = 0; - - /* Write the header to the gzip file. See algorithm.doc for the format */ - - method = DEFLATED; - put_byte(GZIP_MAGIC[0]); /* magic header */ - put_byte(GZIP_MAGIC[1]); - put_byte(DEFLATED); /* compression method */ - - if (save_orig_name) { - flags |= ORIG_NAME; - } - put_byte(flags); /* general flags */ - put_long(time_stamp); - - /* Write deflated file to zip file */ - crc = updcrc(0, 0); - - bi_init(out); - ct_init(&attr, &method); - lm_init(level, &deflate_flags); - - put_byte((uch)deflate_flags); /* extra flags */ - put_byte(OS_CODE); /* OS identifier */ - - if (save_orig_name) { - char *p = basename(ifname); /* Don't save the directory part. */ - do { - put_byte(*p); - } while (*p++); - } - overhead = (long)outcnt; - - (void)deflate(); - -#if !defined(NO_SIZE_CHECK) && !defined(RECORD_IO) - /* Check input size (but not in VMS -- variable record lengths mess it up) - * and not on MSDOS -- diet in TSR mode reports an incorrect file size) - */ - if (ifile_size != -1L && isize != (ulg)ifile_size) { - Trace((stderr, " actual=%ld, read=%ld ", ifile_size, isize)); - fprintf(stderr, "%s: %s: file size changed while zipping\n", - progname, ifname); - } -#endif - - /* Write the crc and uncompressed size */ - put_long(crc); - put_long(isize); - - flush_outbuf(); -} - - -/* =========================================================================== - * Read a new buffer from the current input file, perform end-of-line - * translation, and update the crc and input file size. - * IN assertion: size >= 2 (for end-of-line translation) - */ -int file_read(buf, size) - char *buf; - unsigned size; -{ - unsigned len; - - Assert(insize == 0, "inbuf not empty"); - - len = read(ifd, buf, size); - if (len == (unsigned)(-1) || len == 0) return (int)len; - - crc = updcrc((uch*)buf, len); - isize += (ulg)len; - return (int)len; -} diff --git a/gnu/usr.bin/gzip-1.0.7/zmore.1 b/gnu/usr.bin/gzip-1.0.7/zmore.1 deleted file mode 100644 index 08b49fbae5f5..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/zmore.1 +++ /dev/null @@ -1,134 +0,0 @@ -.TH ZMORE 1 -.SH NAME -zmore \- file perusal filter for crt viewing of compressed text -.SH SYNOPSIS -.B zmore -[ name ... ] -.SH DESCRIPTION -.I Zmore -is a filter which allows examination of compressed text files -one screenful at a time on a soft-copy terminal. -It normally pauses after each screenful, printing --More-- -at the bottom of the screen. -If the user then types a carriage return, one more line is displayed. -If the user hits a space, -another screenful is displayed. Other possibilities are enumerated later. -.PP -.I Zmore -looks in the file -.I /etc/termcap -to determine terminal characteristics, -and to determine the default window size. -On a terminal capable of displaying 24 lines, -the default window size is 22 lines. -To use a pager other than the default -.I more, -set environment variable PAGER to the name of the desired program, such as -.I less. -.PP -Other sequences which may be typed when -.I zmore -pauses, and their effects, are as follows (\fIi\fP is an optional integer -argument, defaulting to 1) : -.PP -.IP \fIi\|\fP -display -.I i -more lines, (or another screenful if no argument is given) -.PP -.IP ^D -display 11 more lines (a ``scroll''). -If -.I i -is given, then the scroll size is set to \fIi\|\fP. -.PP -.IP d -same as ^D (control-D) -.PP -.IP \fIi\|\fPz -same as typing a space except that \fIi\|\fP, if present, becomes the new -window size. Note that the window size reverts back to the default at the -end of the current file. -.PP -.IP \fIi\|\fPs -skip \fIi\|\fP lines and print a screenful of lines -.PP -.IP \fIi\|\fPf -skip \fIi\fP screenfuls and print a screenful of lines -.PP -.IP "q or Q" -quit reading the current file; go on to the next (if any) -.PP -.IP "e or q" -When the prompt --More--(Next file: -.IR file ) -is printed, this command causes zmore to exit. -.PP -.IP s -When the prompt --More--(Next file: -.IR file ) -is printed, this command causes zmore to skip the next file and continue. -.PP -.IP = -Display the current line number. -.PP -.IP \fIi\|\fP/expr -search for the \fIi\|\fP-th occurrence of the regular expression \fIexpr.\fP -If the pattern is not found, -.I zmore -goes on to the next file (if any). -Otherwise, a screenful is displayed, starting two lines before the place -where the expression was found. -The user's erase and kill characters may be used to edit the regular -expression. -Erasing back past the first column cancels the search command. -.PP -.IP \fIi\|\fPn -search for the \fIi\|\fP-th occurrence of the last regular expression entered. -.PP -.IP !command -invoke a shell with \fIcommand\|\fP. -The character `!' in "command" are replaced with the -previous shell command. The sequence "\\!" is replaced by "!". -.PP -.IP ":q or :Q" -quit reading the current file; go on to the next (if any) -(same as q or Q). -.PP -.IP . -(dot) repeat the previous command. -.PP -The commands take effect immediately, i.e., it is not necessary to -type a carriage return. -Up to the time when the command character itself is given, -the user may hit the line kill character to cancel the numerical -argument being formed. -In addition, the user may hit the erase character to redisplay the ---More-- message. -.PP -At any time when output is being sent to the terminal, the user can -hit the quit key (normally control\-\\). -.I Zmore -will stop sending output, and will display the usual --More-- -prompt. -The user may then enter one of the above commands in the normal manner. -Unfortunately, some output is lost when this is done, due to the -fact that any characters waiting in the terminal's output queue -are flushed when the quit signal occurs. -.PP -The terminal is set to -.I noecho -mode by this program so that the output can be continuous. -What you type will thus not show on your terminal, except for the / and ! -commands. -.PP -If the standard output is not a teletype, then -.I zmore -acts just like -.I zcat, -except that a header is printed before each file. -.SH FILES -.DT -/etc/termcap Terminal data base -.SH "SEE ALSO" -more(1), gzip(1), zcmp(1), znew(1), zforce(1), gzexe(1) diff --git a/gnu/usr.bin/gzip-1.0.7/zmore.in b/gnu/usr.bin/gzip-1.0.7/zmore.in deleted file mode 100644 index cee373e78782..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/zmore.in +++ /dev/null @@ -1,42 +0,0 @@ -: -#!/bin/sh - -if test "`echo -n a`" = "-n a"; then - # looks like a SysV system: - n1=''; n2='\c' -else - n1='-n'; n2='' -fi -if stty -cbreak 2>/dev/null; then - cb='cbreak'; ncb='-cbreak' -else - # 'stty min 1' resets eof to ^a on both SunOS and SysV! - cb='min 1 -icanon'; ncb='icanon eof ^d' -fi -trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15 - -if test $# = 0; then - gzip -cd | eval ${PAGER-more} -else - FIRST=1 - for FILE - do - if test $FIRST -eq 0; then - echo $n1 "--More--(Next file: $FILE)$n2" - stty $cb -echo 2>/dev/null - ANS=`dd bs=1 count=1 2>/dev/null` - stty $ncb echo 2>/dev/null - echo " " - if test "$ANS" = 'e' -o "$ANS" = 'q'; then - exit - fi - fi - if test "$ANS" != 's'; then - echo "------> $FILE <------" - gzip -cd "$FILE" | eval ${PAGER-more} - fi - if test -t; then - FIRST=0 - fi - done -fi diff --git a/gnu/usr.bin/gzip-1.0.7/znew.1 b/gnu/usr.bin/gzip-1.0.7/znew.1 deleted file mode 100644 index 8e1a83273d24..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/znew.1 +++ /dev/null @@ -1,31 +0,0 @@ -.TH ZNEW 1 -.SH NAME -znew \- recompress .Z files to .z files -.SH SYNOPSIS -.B znew -[ -tv9PK] [ name.Z ... ] -.SH DESCRIPTION -.I Znew -recompresses files from .Z (compress) format to .z (gzip) format. -.SH OPTIONS -.TP -.B \-t -Tests the new files before deleting originals. -.TP -.B \-v -Verbose. Display the name and percentage reduction for each file compressed. -.TP -.B \-9 -Use the slowest compression method (optimal compression). -.TP -.B \-P -Use pipes for the conversion to reduce disk space usage. -.TP -.B \-K -Keep a .Z file when it is smaller than the .z file -.SH "SEE ALSO" -gzip(1), zmore(1), zcmp(1), zforce(1), gzexe(1), compress(1) -.SH BUGS -.I Znew -does not maintain the time stamp with the -P option if 'touch' does -not support the -r option. diff --git a/gnu/usr.bin/gzip-1.0.7/znew.in b/gnu/usr.bin/gzip-1.0.7/znew.in deleted file mode 100644 index 048a59c3fa39..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/znew.in +++ /dev/null @@ -1,126 +0,0 @@ -: -#!/bin/sh - -check=0 -pipe=0 -opt= -files= -keep=0 -res=0 -old=0 -new=0 -block=1024 -# block is the disk block size (best guess, need not be exact) - -warn="(does not preserve modes and timestamp)" -echo hi > zfoo1$$ -echo hi > zfoo2$$ -if test -z "`(${CPMOD-cpmod} zfoo1$$ zfoo2$$) 2>&1`"; then - cpmod=${CPMOD-cpmod} - warn="" -fi - -if test -z "$cpmod" && ${TOUCH-touch} -r zfoo1$$ zfoo2$$ 2>/dev/null; then - cpmod="${TOUCH-touch}" - cpmodarg="-r" - warn="(does not preserve file modes)" -fi -rm -f zfoo[12]$$ - -for arg -do - case "$arg" in - -*) opt="$opt $arg";; - *) files="$files $arg";; - esac -done - -if test -z "$files"; then - echo 'recompress .Z files into .z (gzip) files' - echo usage: `echo $0 | sed 's,^.*/,,'` "[-tv9P]" file.Z... - echo " -t tests the new files before deleting originals" - echo " -v be verbose" - echo " -9 use the slowest compression method (optimal compression)" - echo " -K keep a .Z file when it is smaller than the .z file" - echo " -P use pipes for the conversion $warn" - exit 1 -fi -opt=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'` -case "$opt" in - *t*) check=1; opt=`echo "$opt" | sed 's/t//g'` -esac -case "$opt" in - *K*) keep=1; opt=`echo "$opt" | sed 's/K//g'` -esac -case "$opt" in - *P*) pipe=1; opt=`echo "$opt" | sed 's/P//g'` -esac -if test -n "$opt"; then - opt="-$opt" -fi - -for i in $files; do - n=`echo $i | sed 's/.Z$//'` - if test ! -f $n.Z ; then - echo $n.Z not found - res=1; continue - fi - test $keep -eq 1 && old=`wc -c < $n.Z` - if test $pipe -eq 1; then - if gzip -d < $n.Z | gzip $opt > $n.z; then - # Copy file attributes from old file to new one, if possible. - test -n "$cpmod" && $cpmod $cpmodarg $n.Z $n.z 2> /dev/null - else - echo error while recompressing $n.Z - res=1; continue - fi - else - if test $check -eq 1; then - if cp -p $n.Z $n.$$ 2> /dev/null || cp $n.Z $n.$$; then - : - else - echo cannot backup $n.Z - res=1; continue - fi - fi - if gzip -d $n.Z; then - : - else - test $check -eq 1 && mv $n.$$ $n.Z - echo error while uncompressing $n.Z - res=1; continue - fi - if gzip $opt $n; then - : - else - test $check -eq 1 && mv $n.$$ $n.Z - echo error while recompressing $n - res=1; continue - fi - fi - test $keep -eq 1 && new=`wc -c < $n.z` - if test $keep -eq 1 -a `expr \( $old + $block - 1 \) / $block` -lt \ - `expr \( $new + $block - 1 \) / $block`; then - if test $pipe -eq 1; then - rm -f $n.z - elif test $check -eq 1; then - mv $n.$$ $n.Z && rm -f $n.z - else - gzip -d $n.z && compress $n && rm -f $n.z - fi - echo "$n.Z smaller than $n.z -- unchanged" - - elif test $check -eq 1; then - if gzip -t $n.z ; then - rm -f $n.$$ $n.Z - else - test $pipe -eq 0 && mv $n.$$ $n.Z - rm -f $n.z - echo error while testing $n.z, $n.Z unchanged - res=1; continue - fi - elif test $pipe -eq 1; then - rm -f $n.Z - fi -done -exit $res diff --git a/gnu/usr.bin/gzip-1.0.7/zread.c b/gnu/usr.bin/gzip-1.0.7/zread.c deleted file mode 100644 index 06647f4e434d..000000000000 --- a/gnu/usr.bin/gzip-1.0.7/zread.c +++ /dev/null @@ -1,53 +0,0 @@ -#include - -/* Trivial example of reading a gzip'ed file or gzip'ed standard input - * using stdio functions fread(), getc(), etc... fseek() is not supported. - * Modify according to your needs. You can easily construct the symmetric - * zwrite program. - * - * Usage: zread [file[.z]] - * This programs assumes that gzip is somewhere in your path. - */ -int main(argc, argv) - int argc; - char **argv; -{ - FILE *infile; - char cmd[256]; - char buf[BUFSIZ]; - int n; - - if (argc < 1 || argc > 2) { - fprintf(stderr, "usage: %s [file[.z]]\n", argv[0]); - exit(1); - } - strcpy(cmd, "gzip -dc "); /* use "gzip -c" for zwrite */ - if (argc == 2) { - strncat(cmd, argv[1], sizeof(cmd)-strlen(cmd)); - } - infile = popen(cmd, "r"); /* use "w" for zwrite */ - if (infile == NULL) { - fprintf(stderr, "%s: popen('%s', 'r') failed\n", argv[0], cmd); - exit(1); - } - /* Read one byte using getc: */ - n = getc(infile); - if (n == EOF) { - pclose(infile); - exit(0); - } - putchar(n); - - /* Read the rest using fread: */ - for (;;) { - n = fread(buf, 1, BUFSIZ, infile); - if (n <= 0) break; - fwrite(buf, 1, n, stdout); - } - if (pclose(infile) != 0) { - fprintf(stderr, "%s: pclose failed\n", argv[0]); - exit(1); - } - exit(0); - return 0; /* just to make compiler happy */ -} diff --git a/gnu/usr.bin/gzip-1.1.1/algorithm.doc b/gnu/usr.bin/gzip-1.1.1/algorithm.doc deleted file mode 100644 index 9c4b0c2d2d1d..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/algorithm.doc +++ /dev/null @@ -1,141 +0,0 @@ -1. Algorithm - -The deflation algorithm used by zip and gzip is a variation of LZ77 -(Lempel-Ziv 1977, see reference below). It finds duplicated strings in -the input data. The second occurrence of a string is replaced by a -pointer to the previous string, in the form of a pair (distance, -length). Distances are limited to 32K bytes, and lengths are limited -to 258 bytes. When a string does not occur anywhere in the previous -32K bytes, it is emitted as a sequence of literal bytes. (In this -description, 'string' must be taken as an arbitrary sequence of bytes, -and is not restricted to printable characters.) - -Literals or match lengths are compressed with one Huffman tree, and -match distances are compressed with another tree. The trees are stored -in a compact form at the start of each block. The blocks can have any -size (except that the compressed data for one block must fit in -available memory). A block is terminated when zip determines that it -would be useful to start another block with fresh trees. (This is -somewhat similar to compress.) - -Duplicated strings are found using a hash table. All input strings of -length 3 are inserted in the hash table. A hash index is computed for -the next 3 bytes. If the hash chain for this index is not empty, all -strings in the chain are compared with the current input string, and -the longest match is selected. - -The hash chains are searched starting with the most recent strings, to -favor small distances and thus take advantage of the Huffman encoding. -The hash chains are singly linked. There are no deletions from the -hash chains, the algorithm simply discards matches that are too old. - -To avoid a worst-case situation, very long hash chains are arbitrarily -truncated at a certain length, determined by a runtime option (zip -1 -to -9). So zip does not always find the longest possible match but -generally finds a match which is long enough. - -zip also defers the selection of matches with a lazy evaluation -mechanism. After a match of length N has been found, zip searches for a -longer match at the next input byte. If a longer match is found, the -previous match is truncated to a length of one (thus producing a single -literal byte) and the longer match is emitted afterwards. Otherwise, -the original match is kept, and the next match search is attempted only -N steps later. - -The lazy match evaluation is also subject to a runtime parameter. If -the current match is long enough, zip reduces the search for a longer -match, thus speeding up the whole process. If compression ratio is more -important than speed, zip attempts a complete second search even if -the first match is already long enough. - - -2. gzip file format - -The pkzip format imposes a lot of overhead in various headers, which -are useful for an archiver but not necessary when only one file is -compressed. gzip uses a much simpler structure. Numbers are in little -endian format, and bit 0 is the least significant bit. -A gzip file is a sequence of compressed members. Each member has the -following structure: - -2 bytes magic header 0x1f, 0x8b (\037 \213) -1 byte compression method (0..7 reserved, 8 = deflate) -1 byte flags - bit 0 set: file probably ascii text - bit 1 set: continuation of multi-part gzip file - bit 2 set: extra field present - bit 3 set: original file name present - bit 4 set: file comment present - bit 5 set: file is encrypted - bit 6,7: reserved -4 bytes file modification time in Unix format -1 byte extra flags (depend on compression method) -1 byte operating system on which compression took place - -2 bytes optional part number (second part=1) -2 bytes optional extra field length -? bytes optional extra field -? bytes optional original file name, zero terminated -? bytes optional file comment, zero terminated -12 bytes optional encryption header -? bytes compressed data -4 bytes crc32 -4 bytes uncompressed input size modulo 2^32 - -The format was designed to allow single pass compression without any -backwards seek, and without a priori knowledge of the uncompressed -input size or the available size on the output media. If input does -not come from a regular disk file, the file modification time is set -to the time at which compression started. - -The time stamp is useful mainly when one gzip file is transferred over -a network. In this case it would not help to keep ownership -attributes. In the local case, the ownership attributes are preserved -by gzip when compressing/decompressing the file. A time stamp of zero -is ignored. - -Bit 0 in the flags is only an optional indication, which can be set by -a small lookahead in the input data. In case of doubt, the flag is -cleared indicating binary data. For systems which have different -file formats for ascii text and binary data, the decompressor can -use the flag to choose the appropriate format. - -It must be possible to detect the end of the compressed data with any -compression format, regardless of the actual size of the compressed -data. If the compressed data cannot fit in one file (in particular for -diskettes), each part starts with a header as described above, but -only the last part has the crc32 and uncompressed size. A decompressor -may prompt for additional data for multipart compressed files. It is -desirable but not mandatory that multiple parts be extractable -independently so that partial data can be recovered if one of the -parts is damaged. This is possible only if no compression state is -kept from one part to the other. The compression-type dependent flags -can indicate this. - -If the file being compressed is on a file system with case insensitive -names, the original name field must be forced to lower case. There is -no original file name if the data was compressed from standard input. - -Compression is always performed, even if the compressed file is -slightly larger than the original. The worst case expansion is -a few bytes for the gzip file header, plus 5 bytes every 32K block, -or an expansion ratio of 0.015% for large files. Note that the actual -number of used disk blocks almost never increases. - -The encryption is that of zip 1.9. For the encryption check, the -last byte of the decoded encryption header must be zero. The time -stamp of an encrypted file might be set to zero to avoid giving a clue -about the construction of the random header. - -Jean-loup Gailly -jloup@chorus.fr - -References: - -[LZ77] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data -Compression", IEEE Transactions on Information Theory", Vol. 23, No. 3, -pp. 337-343. - -APPNOTE.TXT documentation file in PKZIP 1.93a. It is available by -ftp in ftp.cso.uiuc.edu:/pc/exec-pc/pkz193a.exe [128.174.5.59] -Use "unzip pkz193a.exe APPNOTE.TXT" to extract. diff --git a/gnu/usr.bin/gzip-1.1.1/bits.c b/gnu/usr.bin/gzip-1.1.1/bits.c deleted file mode 100644 index e182f346e35a..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/bits.c +++ /dev/null @@ -1,205 +0,0 @@ -/* bits.c -- output variable-length bit strings - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - - -/* - * PURPOSE - * - * Output variable-length bit strings. Compression can be done - * to a file or to memory. (The latter is not supported in this version.) - * - * DISCUSSION - * - * The PKZIP "deflate" file format interprets compressed file data - * as a sequence of bits. Multi-bit strings in the file may cross - * byte boundaries without restriction. - * - * The first bit of each byte is the low-order bit. - * - * The routines in this file allow a variable-length bit value to - * be output right-to-left (useful for literal values). For - * left-to-right output (useful for code strings from the tree routines), - * the bits must have been reversed first with bi_reverse(). - * - * For in-memory compression, the compressed bit stream goes directly - * into the requested output buffer. The input data is read in blocks - * by the mem_read() function. The buffer is limited to 64K on 16 bit - * machines. - * - * INTERFACE - * - * void bi_init (FILE *zipfile) - * Initialize the bit string routines. - * - * void send_bits (int value, int length) - * Write out a bit string, taking the source bits right to - * left. - * - * int bi_reverse (int value, int length) - * Reverse the bits of a bit string, taking the source bits left to - * right and emitting them right to left. - * - * void bi_windup (void) - * Write out any remaining bits in an incomplete byte. - * - * void copy_block(char *buf, unsigned len, int header) - * Copy a stored block to the zip file, storing first the length and - * its one's complement if requested. - * - */ - -#include "tailor.h" -#include "gzip.h" -#include "crypt.h" - -#ifdef DEBUG -# include -#endif - -#ifndef lint -static char rcsid[] = "$Id: bits.c,v 1.1 1993/06/29 14:49:25 brezak Exp $"; -#endif - -/* =========================================================================== - * Local data used by the "bit string" routines. - */ - -local file_t zfile; /* output gzip file */ - -local unsigned short bi_buf; -/* Output buffer. bits are inserted starting at the bottom (least significant - * bits). - */ - -#define Buf_size (8 * 2*sizeof(char)) -/* Number of bits used within bi_buf. (bi_buf might be implemented on - * more than 16 bits on some systems.) - */ - -local int bi_valid; -/* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - -int (*read_buf) OF((char *buf, unsigned size)) = file_read; -/* Current input function. Set to mem_read for in-memory compression */ - -#ifdef DEBUG - ulg bits_sent; /* bit length of the compressed data */ -#endif - -/* =========================================================================== - * Initialize the bit string routines. - */ -void bi_init (zipfile) - file_t zipfile; /* output zip file, NO_FILE for in-memory compression */ -{ - zfile = zipfile; - bi_buf = 0; - bi_valid = 0; -#ifdef DEBUG - bits_sent = 0L; -#endif - - /* Set the defaults for file compression. They are set by memcompress - * for in-memory compression. - */ - if (zfile != NO_FILE) { - read_buf = file_read; - } -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -void send_bits(value, length) - int value; /* value to send */ - int length; /* number of bits */ -{ -#ifdef DEBUG - Tracev((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - bits_sent += (ulg)length; -#endif - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (bi_valid > (int)Buf_size - length) { - bi_buf |= (value << bi_valid); - put_short(bi_buf); - bi_buf = (ush)value >> (Buf_size - bi_valid); - bi_valid += length - Buf_size; - } else { - bi_buf |= value << bi_valid; - bi_valid += length; - } -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Write out any remaining bits in an incomplete byte. - */ -void bi_windup() -{ - if (bi_valid > 8) { - put_short(bi_buf); - } else if (bi_valid > 0) { - put_byte(bi_buf); - } - bi_buf = 0; - bi_valid = 0; -#ifdef DEBUG - bits_sent = (bits_sent+7) & ~7; -#endif -} - -/* =========================================================================== - * Copy a stored block to the zip file, storing first the length and its - * one's complement if requested. - */ -void copy_block(buf, len, header) - char *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(); /* align on byte boundary */ - - if (header) { - put_short((ush)len); - put_short((ush)~len); -#ifdef DEBUG - bits_sent += 2*16; -#endif - } -#ifdef DEBUG - bits_sent += (ulg)len<<3; -#endif - while (len--) { -#ifdef CRYPT - int t; - if (key) zencode(*buf, t); -#endif - put_byte(*buf++); - } -} diff --git a/gnu/usr.bin/gzip-1.1.1/crypt.c b/gnu/usr.bin/gzip-1.1.1/crypt.c deleted file mode 100644 index 93896bd9824a..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/crypt.c +++ /dev/null @@ -1,6 +0,0 @@ -/* crypt.c (dummy version) -- do not perform encryption - * Hardly worth copyrighting :-) - */ -#ifndef lint -static char rcsid[] = "$Id: crypt.c,v 1.1 1993/06/29 14:49:26 brezak Exp $"; -#endif diff --git a/gnu/usr.bin/gzip-1.1.1/crypt.h b/gnu/usr.bin/gzip-1.1.1/crypt.h deleted file mode 100644 index 2a4c203caa72..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/crypt.h +++ /dev/null @@ -1,12 +0,0 @@ -/* crypt.h (dummy version) -- do not perform encryption - * Hardly worth copyrighting :-) - */ - -#ifdef CRYPT -# undef CRYPT /* dummy version */ -#endif - -#define RAND_HEAD_LEN 12 /* length of encryption random header */ - -#define zencode -#define zdecode diff --git a/gnu/usr.bin/gzip-1.1.1/deflate.c b/gnu/usr.bin/gzip-1.1.1/deflate.c deleted file mode 100644 index 8185e2beb1ab..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/deflate.c +++ /dev/null @@ -1,730 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -/* - * PURPOSE - * - * Identify new text as repetitions of old text within a fixed- - * length sliding window trailing behind the new text. - * - * DISCUSSION - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many info-zippers for bug reports and testing. - * - * REFERENCES - * - * APPNOTE.TXT documentation file in PKZIP 1.93a distribution. - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - * INTERFACE - * - * void lm_init (int pack_level, ush *flags) - * Initialize the "longest match" routines for a new file - * - * ulg deflate (void) - * Processes a new input file and return its compressed length. Sets - * the compressed length, crc, deflate flags and internal file - * attributes. - */ - -#include - -#include "tailor.h" -#include "gzip.h" -#include "lzw.h" /* just for consistency checking */ - -#ifndef lint -static char rcsid[] = "$Id: deflate.c,v 1.1 1993/06/29 14:49:28 brezak Exp $"; -#endif - -/* =========================================================================== - * Configuration parameters - */ - -/* Compile with MEDIUM_MEM to reduce the memory requirements or - * with SMALL_MEM to use as little memory as possible. Use BIG_MEM if the - * entire input file can be held in memory (not possible on 16 bit systems). - * Warning: defining these symbols affects HASH_BITS (see below) and thus - * affects the compression ratio. The compressed output - * is still correct, and might even be smaller in some cases. - */ - -#ifdef SMALL_MEM -# define HASH_BITS 13 /* Number of bits used to hash strings */ -#endif -#ifdef MEDIUM_MEM -# define HASH_BITS 14 -#endif -#ifndef HASH_BITS -# define HASH_BITS 15 - /* For portability to 16 bit machines, do not use values above 15. */ -#endif - -/* To save space (see unlzw.c), we overlay prev+head with tab_prefix and - * window with tab_suffix. Check that we can do this: - */ -#if WSIZE<<1 > 1< BITS-1 - error: cannot overlay head with tab_prefix1 -#endif - -#define HASH_SIZE (unsigned)(1<= HASH_BITS - */ - -unsigned int near prev_length; -/* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - unsigned near strstart; /* start of string to insert */ - unsigned near match_start; /* start of matching string */ -local int eofile; /* flag set at end of input file */ -local unsigned lookahead; /* number of valid bytes ahead in window */ - -unsigned near max_chain_length; -/* To speed up deflation, hash chains are never searched beyond this length. - * A higher limit improves compression ratio but degrades the speed. - */ - -local unsigned int max_lazy_match; -/* Attempt to find a better match only when the current match is strictly - * smaller than this value. - */ - -int near good_match; -/* Use a faster search when the previous match is longer than this */ - - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ - -typedef struct config { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; -} config; - -#ifdef FULL_SEARCH -# define nice_match MAX_MATCH -#else - int near nice_match; /* Stop searching when current match exceeds this */ -#endif - -local config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0}, /* store only */ -/* 1 */ {4, 4, 16, 16}, /* maximum speed */ -/* 2 */ {6, 8, 16, 16}, -/* 3 */ {8, 16, 32, 32}, -/* 4 */ {8, 16, 64, 64}, -/* 5 */ {8, 16, 128, 128}, -/* 6 */ {8, 32, 128, 256}, -/* 7 */ {8, 64, 128, 512}, -/* 8 */ {32, 128, 258, 1024}, -/* 9 */ {32, 258, 258, 4096}}; /* maximum compression */ - -/* Note: the current code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * but these restrictions can easily be removed at a small cost. - */ - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -/* =========================================================================== - * Prototypes for local functions. - */ -local void fill_window OF((void)); - int longest_match OF((IPos cur_match)); -#ifdef ASMV - void match_init OF((void)); /* asm code initialization */ -#endif - -#ifdef DEBUG -local void check_match OF((IPos start, IPos match, int length)); -#endif - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. - */ -#define UPDATE_HASH(h,c) (h = (((h)< 9) error("bad pack level"); - - /* Initialize the hash table. */ -#if defined(MAXSEG_64K) && HASH_BITS == 15 - for (j = 0; j < HASH_SIZE; j++) head[j] = NIL; -#else - memzero((char*)head, HASH_SIZE*sizeof(*head)); -#endif - /* prev will be initialized on the fly */ - - /* Set the default configuration parameters: - */ - max_lazy_match = configuration_table[pack_level].max_lazy; - good_match = configuration_table[pack_level].good_length; -#ifndef FULL_SEARCH - nice_match = configuration_table[pack_level].nice_length; -#endif - max_chain_length = configuration_table[pack_level].max_chain; - if (pack_level == 1) { - *flags |= FAST; - } else if (pack_level == 9) { - *flags |= SLOW; - } - /* ??? reduce max_chain_length for binary files */ - - strstart = 0; - block_start = 0L; -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif - - lookahead = read_buf((char*)window, - sizeof(int) <= 2 ? (unsigned)WSIZE : 2*WSIZE); - - if (lookahead == 0 || lookahead == (unsigned)EOF) { - eofile = 1, lookahead = 0; - return; - } - eofile = 0; - /* Make sure that we always have enough lookahead. This is important - * if input comes from a device such as a tty. - */ - while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); - - ins_h = 0; - for (j=0; j= 1 - */ -#ifndef ASMV -/* For MSDOS, OS/2 and 386 Unix, an optimized version is in match.asm or - * match.s. The code is functionally equivalent, so you can use the C version - * if desired. - */ -int longest_match(cur_match) - IPos cur_match; /* current match */ -{ - unsigned chain_length = max_chain_length; /* max hash chain length */ - register uch *scan = window + strstart; /* current string */ - register uch *match; /* matched string */ - register int len; /* length of current match */ - int best_len = prev_length; /* best match length so far */ - IPos limit = strstart > (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - -/* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ -#if HASH_BITS < 8 || MAX_MATCH != 258 - error: Code too clever -#endif - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register uch *strend = window + strstart + MAX_MATCH - 1; - register ush scan_start = *(ush*)scan; - register ush scan_end = *(ush*)(scan+best_len-1); -#else - register uch *strend = window + strstart + MAX_MATCH; - register uch scan_end1 = scan[best_len-1]; - register uch scan_end = scan[best_len]; -#endif - - /* Do not waste too much time if we already have a good match: */ - if (prev_length >= good_match) { - chain_length >>= 2; - } - Assert(strstart <= window_size-MIN_LOOKAHEAD, "insufficient lookahead"); - - do { - Assert(cur_match < strstart, "no future"); - match = window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2: - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ush*)(match+best_len-1) != scan_end || - *(ush*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - scan++, match++; - do { - } while (*(ush*)(scan+=2) == *(ush*)(match+=2) && - *(ush*)(scan+=2) == *(ush*)(match+=2) && - *(ush*)(scan+=2) == *(ush*)(match+=2) && - *(ush*)(scan+=2) == *(ush*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= window+(unsigned)(window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ush*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & WMASK]) > limit - && --chain_length != 0); - - return best_len; -} -#endif /* ASMV */ - -#ifdef DEBUG -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(start, match, length) - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (memcmp((char*)window + match, - (char*)window + start, length) != EQUAL) { - fprintf(stderr, - " start %d, match %d, length %d\n", - start, match, length); - error("invalid match"); - } - if (verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(start, match, length) -#endif - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead, and sets eofile if end of input file. - * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0 - * OUT assertions: at least one byte has been read, or eofile is set; - * file reads are performed for at least two bytes (required for the - * translate_eol option). - */ -local void fill_window() -{ - register unsigned n, m; - unsigned more = (unsigned)(window_size - (ulg)lookahead - (ulg)strstart); - /* Amount of free space at the end of the window. */ - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (more == (unsigned)EOF) { - /* Very unlikely, but possible on 16 bit machine if strstart == 0 - * and lookahead == 1 (input done one byte at time) - */ - more--; - } else if (strstart >= WSIZE+MAX_DIST) { - /* By the IN assertion, the window is not empty so we can't confuse - * more == 0 with more == 64K on a 16 bit machine. - */ - Assert(window_size == (ulg)2*WSIZE, "no sliding with BIG_MEM"); - - memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE); - match_start -= WSIZE; - strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */ - - block_start -= (long) WSIZE; - - for (n = 0; n < HASH_SIZE; n++) { - m = head[n]; - head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL); - } - for (n = 0; n < WSIZE; n++) { - m = prev[n]; - prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } - more += WSIZE; - } - /* At this point, more >= 2 */ - if (!eofile) { - n = read_buf((char*)window+strstart+lookahead, more); - if (n == 0 || n == (unsigned)EOF) { - eofile = 1; - } else { - lookahead += n; - } - } -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK(eof) \ - flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \ - (char*)NULL, (long)strstart - block_start, (eof)) - -/* =========================================================================== - * Processes a new input file and return its compressed length. - */ -#ifdef NO_LAZY -ulg deflate() -{ - IPos hash_head; /* head of the hash chain */ - int flush; /* set if current block must be flushed */ - unsigned match_length = 0; /* length of best match */ - - prev_length = MIN_MATCH-1; - while (lookahead != 0) { - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - INSERT_STRING(strstart, hash_head); - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && strstart - hash_head <= MAX_DIST) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - match_length = longest_match (hash_head); - /* longest_match() sets match_start */ - if (match_length > lookahead) match_length = lookahead; - } - if (match_length >= MIN_MATCH) { - check_match(strstart, match_start, match_length); - - flush = ct_tally(strstart-match_start, match_length - MIN_MATCH); - - lookahead -= match_length; - match_length--; /* string at strstart already in hash table */ - do { - strstart++; - INSERT_STRING(strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH - * these bytes are garbage, but it does not matter since the - * next lookahead bytes will always be emitted as literals. - */ - } while (--match_length != 0); - } else { - /* No match, output a literal byte */ - flush = ct_tally (0, window[strstart]); - lookahead--; - } - strstart++; - if (flush) FLUSH_BLOCK(0), block_start = strstart; - - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); - - } - return FLUSH_BLOCK(1); /* eof */ -} -#else /* LAZY */ -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -ulg deflate() -{ - IPos hash_head; /* head of hash chain */ - IPos prev_match; /* previous match */ - int flush; /* set if current block must be flushed */ - int match_available = 0; /* set if previous match exists */ - register unsigned match_length = MIN_MATCH-1; /* length of best match */ -#ifdef DEBUG - extern long isize; /* byte length of input file, for debug only */ -#endif - - /* Process the input block. */ - while (lookahead != 0) { - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - INSERT_STRING(strstart, hash_head); - - /* Find the longest match, discarding those <= prev_length. - */ - prev_length = match_length, prev_match = match_start; - match_length = MIN_MATCH-1; - - if (hash_head != NIL && prev_length < max_lazy_match && - strstart - hash_head <= MAX_DIST) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - match_length = longest_match (hash_head); - /* longest_match() sets match_start */ - if (match_length > lookahead) match_length = lookahead; - - /* Ignore a length 3 match if it is too distant: */ - if (match_length == MIN_MATCH && strstart-match_start > TOO_FAR){ - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - match_length--; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (prev_length >= MIN_MATCH && match_length <= prev_length) { - - check_match(strstart-1, prev_match, prev_length); - - flush = ct_tally(strstart-1-prev_match, prev_length - MIN_MATCH); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. - */ - lookahead -= prev_length-1; - prev_length -= 2; - do { - strstart++; - INSERT_STRING(strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH - * these bytes are garbage, but it does not matter since the - * next lookahead bytes will always be emitted as literals. - */ - } while (--prev_length != 0); - match_available = 0; - match_length = MIN_MATCH-1; - strstart++; - if (flush) FLUSH_BLOCK(0), block_start = strstart; - - } else if (match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c",window[strstart-1])); - if (ct_tally (0, window[strstart-1])) { - FLUSH_BLOCK(0), block_start = strstart; - } - strstart++; - lookahead--; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - match_available = 1; - strstart++; - lookahead--; - } - Assert (strstart <= isize && lookahead <= isize, "a bit too far"); - - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); - } - if (match_available) ct_tally (0, window[strstart-1]); - - return FLUSH_BLOCK(1); /* eof */ -} -#endif /* LAZY */ diff --git a/gnu/usr.bin/gzip-1.1.1/getopt.c b/gnu/usr.bin/gzip-1.1.1/getopt.c deleted file mode 100644 index 3bf027710fb9..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/getopt.c +++ /dev/null @@ -1,711 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu - before changing it! - - Copyright (C) 1987, 88, 89, 90, 91, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* AIX requires this to be the first thing in the file. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__)))) -#include -#else -#ifdef _AIX - #pragma alloca -#else -char *alloca (); -#endif -#endif /* alloca.h */ -#endif /* not __GNUC__ */ - -#include - -#if defined(USG) || defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) -#include -#endif - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#undef alloca -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -#include -#else /* Not GNU C library. */ -#define __alloca alloca -#endif /* GNU C library. */ - -#if !__STDC__ -#define const -#endif - -/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a - long-named option. Because this is not POSIX.2 compliant, it is - being phased out. */ -#define GETOPT_COMPAT - -/* 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 POSIXLY_CORRECT 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 "getopt.h" - -/* 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 - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the 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; - -#ifdef __GNU_LIBRARY__ -#include -#define my_index strchr -#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) -#else - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -char *getenv (); - -static char * -my_index (string, chr) - char *string; - int chr; -{ - while (*string) - { - if (*string == chr) - return string; - string++; - } - return 0; -} - -static void -my_bcopy (from, to, size) - char *from, *to; - int size; -{ - int i; - for (i = 0; i < size; i++) - to[i] = from[i]; -} -#endif /* GNU C library. */ - -/* 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 *); -#ifdef _CRAY - char *temp[last_nonopt - first_nonopt]; -#else - char **temp = (char **) __alloca (nonopts_size); -#endif - - /* Interchange the two blocks of data in ARGV. */ - - my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size); - my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt], - (optind - last_nonopt) * sizeof (char *)); - my_bcopy ((char *) temp, - (char *) &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 - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - int option_index; - - 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 = NULL; - - /* 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 ("POSIXLY_CORRECT") != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - } - - 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 ((char **) 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') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - 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 ((char **) 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') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - { - 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 - + (longopts != NULL && argv[optind][1] == '-')); - } - - if (longopts != NULL - && ((argv[optind][0] == '-' - && (argv[optind][1] == '-' || long_only)) -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - )) - { - const struct option *p; - char *s = nextchar; - int exact = 0; - int ambig = 0; - const struct option *pfound = NULL; - int indfound = 0; - - while (*s && *s != '=') - s++; - - /* Test all options for either exact match or abbreviated matches. */ - for (p = longopts, 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 == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*s) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = s + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - else - /* +option or -option */ - 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 - { - if (opterr) - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - || my_index ((char*)optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, "%s: unrecognized option `--%s'\n", - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, "%s: unrecognized option `%c%s'\n", - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - return '?'; - } - } - - /* Look at and handle the next option-character. */ - - { - char c = *nextchar++; - char *temp = my_index ((char*)optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (opterr) - { - 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 = NULL; - } - 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) - 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 = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') 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 *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - - -#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/gnu/usr.bin/gzip-1.1.1/getopt.h b/gnu/usr.bin/gzip-1.1.1/getopt.h deleted file mode 100644 index 764f2f4cf5a1..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/getopt.h +++ /dev/null @@ -1,128 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* 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. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, 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 -{ -#if __STDC__ - const char *name; -#else - char *name; -#endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -enum _argtype -{ - no_argument, - required_argument, - optional_argument -}; - -#if __STDC__ || defined(PROTO) -#if defined(__GNU_LIBRARY__) -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ -extern int getopt (); -#endif /* not __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* not __STDC__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* _GETOPT_H */ diff --git a/gnu/usr.bin/gzip-1.1.1/gzexe b/gnu/usr.bin/gzip-1.1.1/gzexe deleted file mode 100644 index ba22eb1e6fea..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/gzexe +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/sh -# gzexe: compressor for Unix executables. -# Use this only for binaries that you do not use frequently. -# -# The compressed version is a shell script which decompresses itself after -# skipping $skip lines of shell commands. We try invoking the compressed -# executable with the original name (for programs looking at their name). -# We also try to retain the original file permissions on the compressed file. -# For safety reasons, gzexe will not create setuid or setgid shell scripts. - -# Warning: the first line of this file must be either : or #!/bin/sh -# The : is required for some old versions of csh. - -x=`basename $0` -if test $# = 0; then - echo compress executables. original file foo is renamed to foo~ - echo usage: ${x} [-d] files... - echo " -d decompress the executables" - exit 1 -fi - -tmp=gz$$ -trap "rm -f $tmp; exit 1" 1 2 3 5 10 13 15 - -decomp=0 -res=0 -test "$x" = "ungzexe" && decomp=1 -if test "x$1" = "x-d"; then - decomp=1 - shift -fi - -echo hi > zfoo1$$ -echo hi > zfoo2$$ -if test -z "`(${CPMOD-cpmod} zfoo1$$ zfoo2$$) 2>&1`"; then - cpmod=${CPMOD-cpmod} -fi -rm -f zfoo[12]$$ - -for i do - if test ! -f "$i" ; then - echo ${x}: $i not a file - res=1 - continue - fi - if test $decomp -eq 0; then - if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then - echo "${x}: $i is already gzexe'd" - continue - fi - fi - if ls -l "$i" | grep '^...[sS]' > /dev/null; then - echo "${x}: $i has setuid permission, unchanged" - continue - fi - if ls -l "$i" | grep '^......[sS]' > /dev/null; then - echo "${x}: $i has setgid permission, unchanged" - continue - fi - if test "`basename $i`" = gzip; then - echo "${x}: cannot compress gzip itself" - continue - fi - if test -z "$cpmod"; then - cp -p "$i" $tmp 2>/dev/null || cp "$i" $tmp - if test -w $tmp 2>/dev/null; then - writable=1 - else - writable=0 - chmod u+w $tmp 2>/dev/null - fi - fi - if test $decomp -eq 0; then - sed 1q $0 > $tmp - cat >> $tmp <<'EOF' -skip=18 -if tail +$skip $0 | gzip -cd > /tmp/gztmp$$; then - chmod 755 /tmp/gztmp$$ - prog="`basename $0`" - if ln /tmp/gztmp$$ "/tmp/$prog" 2>/dev/null; then - trap '/bin/rm -f /tmp/gztmp$$ "/tmp/$prog"; exit $res' 0 - (sleep 5; /bin/rm -f /tmp/gztmp$$ "/tmp/$prog") 2>/dev/null & - /tmp/"$prog" ${1+"$@"}; res=$? - else - trap '/bin/rm -f /tmp/gztmp$$; exit $res' 0 - (sleep 5; /bin/rm -f /tmp/gztmp$$) 2>/dev/null & - /tmp/gztmp$$ ${1+"$@"}; res=$? - fi -else - echo Cannot decompress $0; exit 1 -fi; exit $res -EOF - gzip -cv9 "$i" >> $tmp || { - /bin/rm -f $tmp - echo ${x}: compression not possible for $i, file unchanged. - res=1 - continue - } - - else - # decompression - skip=18 - if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then - eval `sed -e 1d -e 2q "$i"` - fi - if tail +$skip "$i" | gzip -cd > $tmp; then - : - else - echo ${x}: $i probably not in gzexe format, file unchanged. - res=1 - continue - fi - fi - rm -f "$i~" - mv "$i" "$i~" || { - echo ${x}: cannot backup $i as $i~ - rm -f $tmp - res=1 - continue - } - mv $tmp "$i" || cp -p $tmp "$i" 2>/dev/null || cp $tmp "$i" || { - echo ${x}: cannot create $i - rm -f $tmp - res=1 - continue - } - rm -f $tmp - if test -n "$cpmod"; then - $cpmod "$i~" "$i" 2>/dev/null - elif test $writable -eq 0; then - chmod u-w $i 2>/dev/null - fi -done -exit $res diff --git a/gnu/usr.bin/gzip-1.1.1/gzexe.1 b/gnu/usr.bin/gzip-1.1.1/gzexe.1 deleted file mode 100644 index 68e41279d753..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/gzexe.1 +++ /dev/null @@ -1,36 +0,0 @@ -.TH GZEXE 1 -.SH NAME -gzexe \- compress executable files in place -.SH SYNOPSIS -.B gzexe -[ name ... ] -.SH DESCRIPTION -The -.I gzexe -utility allows you to compress executables in place and have them -automatically uncompress and execute when you run them (at a penalty -in performance). For example if you execute ``gzexe /bin/cat'' it -will create the following two files: -.nf -.br - -r-xr-xr-x 1 root bin 9644 Feb 11 11:16 /bin/cat - -r-xr-xr-x 1 bin bin 24576 Nov 23 13:21 /bin/cat~ -.fi -/bin/cat~ is the original file and /bin/cat is the self-uncompressing -executable file. You can remove /bin/cat~ once you are sure that -/bin/cat works properly. -.PP -This utility is most useful on systems with very small disks. -.SH OPTIONS -.TP -.B \-d -Decompress the given executables instead of compressing them. -.SH "SEE ALSO" -gzip(1), znew(1), zmore(1), zcmp(1), zforce(1) -.SH "BUGS" -.I gzexe -attempts to retain the original file attributes on the compressed executable, -but you may have to fix them manually in some cases, using -.I chmod -or -.I chown. diff --git a/gnu/usr.bin/gzip-1.1.1/gzexe.in b/gnu/usr.bin/gzip-1.1.1/gzexe.in deleted file mode 100644 index dcbab88d3be9..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/gzexe.in +++ /dev/null @@ -1,135 +0,0 @@ -: -#!/bin/sh -# gzexe: compressor for Unix executables. -# Use this only for binaries that you do not use frequently. -# -# The compressed version is a shell script which decompresses itself after -# skipping $skip lines of shell commands. We try invoking the compressed -# executable with the original name (for programs looking at their name). -# We also try to retain the original file permissions on the compressed file. -# For safety reasons, gzexe will not create setuid or setgid shell scripts. - -# Warning: the first line of this file must be either : or #!/bin/sh -# The : is required for some old versions of csh. - -x=`basename $0` -if test $# = 0; then - echo compress executables. original file foo is renamed to foo~ - echo usage: ${x} [-d] files... - echo " -d decompress the executables" - exit 1 -fi - -tmp=gz$$ -trap "rm -f $tmp; exit 1" 1 2 3 5 10 13 15 - -decomp=0 -res=0 -test "$x" = "ungzexe" && decomp=1 -if test "x$1" = "x-d"; then - decomp=1 - shift -fi - -echo hi > zfoo1$$ -echo hi > zfoo2$$ -if test -z "`(${CPMOD-cpmod} zfoo1$$ zfoo2$$) 2>&1`"; then - cpmod=${CPMOD-cpmod} -fi -rm -f zfoo[12]$$ - -for i do - if test ! -f "$i" ; then - echo ${x}: $i not a file - res=1 - continue - fi - if test $decomp -eq 0; then - if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then - echo "${x}: $i is already gzexe'd" - continue - fi - fi - if ls -l "$i" | grep '^...[sS]' > /dev/null; then - echo "${x}: $i has setuid permission, unchanged" - continue - fi - if ls -l "$i" | grep '^......[sS]' > /dev/null; then - echo "${x}: $i has setgid permission, unchanged" - continue - fi - if test "`basename $i`" = gzip; then - echo "${x}: cannot compress gzip itself" - continue - fi - if test -z "$cpmod"; then - cp -p "$i" $tmp 2>/dev/null || cp "$i" $tmp - if test -w $tmp 2>/dev/null; then - writable=1 - else - writable=0 - chmod u+w $tmp 2>/dev/null - fi - fi - if test $decomp -eq 0; then - sed 1q $0 > $tmp - cat >> $tmp <<'EOF' -skip=18 -if tail +$skip $0 | gzip -cd > /tmp/gztmp$$; then - chmod 755 /tmp/gztmp$$ - prog="`basename $0`" - if ln /tmp/gztmp$$ "/tmp/$prog" 2>/dev/null; then - trap '/bin/rm -f /tmp/gztmp$$ "/tmp/$prog"; exit $res' 0 - (sleep 5; /bin/rm -f /tmp/gztmp$$ "/tmp/$prog") 2>/dev/null & - /tmp/"$prog" ${1+"$@"}; res=$? - else - trap '/bin/rm -f /tmp/gztmp$$; exit $res' 0 - (sleep 5; /bin/rm -f /tmp/gztmp$$) 2>/dev/null & - /tmp/gztmp$$ ${1+"$@"}; res=$? - fi -else - echo Cannot decompress $0; exit 1 -fi; exit $res -EOF - gzip -cv9 "$i" >> $tmp || { - /bin/rm -f $tmp - echo ${x}: compression not possible for $i, file unchanged. - res=1 - continue - } - - else - # decompression - skip=18 - if sed -e 1d -e 2q "$i" | grep "^skip=[0-9]*$" >/dev/null; then - eval `sed -e 1d -e 2q "$i"` - fi - if tail +$skip "$i" | gzip -cd > $tmp; then - : - else - echo ${x}: $i probably not in gzexe format, file unchanged. - res=1 - continue - fi - fi - rm -f "$i~" - mv "$i" "$i~" || { - echo ${x}: cannot backup $i as $i~ - rm -f $tmp - res=1 - continue - } - mv $tmp "$i" || cp -p $tmp "$i" 2>/dev/null || cp $tmp "$i" || { - echo ${x}: cannot create $i - rm -f $tmp - res=1 - continue - } - rm -f $tmp - if test -n "$cpmod"; then - $cpmod "$i~" "$i" 2>/dev/null - elif test $writable -eq 0; then - chmod u-w $i 2>/dev/null - fi -done -exit $res diff --git a/gnu/usr.bin/gzip-1.1.1/gzip.1 b/gnu/usr.bin/gzip-1.1.1/gzip.1 deleted file mode 100644 index a7d331f6fb2b..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/gzip.1 +++ /dev/null @@ -1,360 +0,0 @@ -.PU -.TH GZIP 1 -.SH NAME -gzip, gunzip, zcat \- compress or expand files -.SH SYNOPSIS -.ll +8 -.B gzip -.RB [ " \-acdfhLrtvV19 " ] -.RB [ \-S\ suffix ] -[ -.I "name \&..." -] -.ll -8 -.br -.B gunzip -.RB [ " \-acfhLrtvV " ] -.RB [ \-S\ suffix ] -[ -.I "name \&..." -] -.br -.B zcat -.RB [ " \-hLV " ] -[ -.I "name \&..." -] -.SH DESCRIPTION -.I Gzip -reduces the size of the named files using Lempel-Ziv coding (LZ77). -Whenever possible, -each file is replaced by one with the extension -.B "\&.gz," -while keeping the same ownership modes, access and modification times. -(The default extension is -.B "\-gz" -for VMS, -.B "z" -for MSDOS, OS/2 and Atari.) -If no files are specified, the standard input is compressed to the -standard output. If the new file name is too long, -.I gzip -truncates it and keeps the original file name in the compressed file. -.I Gzip -will only attempt to compress regular files. -In particular, it will ignore symbolic links. -.PP -Compressed files can be restored to their original form using -.I gzip -d -or -.I gunzip -or -.I zcat. -.PP -.I gunzip -takes a list of files on its command line and replaces each -file whose name ends with .gz, -gz, .z, -z, _z or .Z -and which begins with the correct magic number with an uncompressed -file without the original extension. -.I gunzip -also recognizes the special extensions -.B "\&.tgz" -and -.B "\&.taz" -as shorthands for -.B "\&.tar.gz" -and -.B "\&.tar.Z" -respectively. -.PP -.I gunzip -can currently decompress files created by -.I gzip, zip, compress -or -.I pack. -The detection of the input format is automatic. When using -the first two formats, -.I gunzip -checks a 32 bit CRC. For -.I pack, gunzip -checks the uncompressed length. The -.I compress -format was not designed to allow consistency checks. However -.I gunzip -is sometimes able to detect a bad .Z file. If you get an error -when uncompressing a .Z file, do not assume that the .Z file is -correct simply because the standard -.I uncompress -does not complain. This generally means that the standard -.I uncompress -does not check its input, and happily generates garbage output. -.PP -Files created by -.I zip -can be uncompressed by gzip only if they have a single member compressed -with the 'deflation' method. This feature is only intended to help -conversion of tar.zip files to the tar.gz format. To extract zip files -with several members, use -.I unzip -instead of -.I gunzip. -.PP -.I zcat -is identical to -.I gunzip -.B \-c. -(On some systems, -.I zcat -may be installed as -.I gzcat -to preserve the original link to -.I compress.) -.I zcat -uncompresses either a list of files on the command line or its -standard input and writes the uncompressed data on standard output. -.I zcat -will uncompress files that have the correct magic number whether -they have a -.B "\&.gz" -suffix or not. -.PP -.I Gzip -uses the Lempel-Ziv algorithm used in -.I zip -and PKZIP. -The amount of compression obtained depends on the size of the -input and the distribution of common substrings. -Typically, text such as source code or English -is reduced by 60\-70%. -Compression is generally much better than that achieved by -LZW (as used in -.IR compress ), -Huffman coding (as used in -.IR pack ), -or adaptive Huffman coding -.RI ( compact ). -.PP -Compression is always performed, even if the compressed file is -slightly larger than the original. The worst case expansion is -a few bytes for the gzip file header, plus 5 bytes every 32K block, -or an expansion ratio of 0.015% for large files. Note that the actual -number of used disk blocks almost never increases. -.I gzip -preserves the mode, ownership and timestamps of files when compressing -or decompressing. - -.SH OPTIONS -.TP -.B \-a --ascii -Ascii text mode: convert end-of-lines using local conventions. This option -is supported only on some non-Unix systems. For MSDOS, CR LF is converted -to LF when compressing, and LF is converted to CR LF when decompressing. -.TP -.B \-c --stdout -Write output on standard output; keep original files unchanged. -If there are several input files, the output consists of a sequence of -independently compressed members. To obtain better compression, -concatenate all input files before compressing them. -.TP -.B \-d --decompress --uncompress -Decompress. -.TP -.B \-f --force -Force compression or decompression even if the file has multiple links -or the corresponding file already exists, or if the compressed data -is read from or written to a terminal. If -.B \-f -is not given, -and when not running in the background, -.I gzip -prompts to verify whether an existing file should be overwritten. -.TP -.B \-h --help -Display a help screen and quit. -.TP -.B \-L --license -Display the -.I gzip -license. -.TP -.B \-q --quiet -Suppress all warnings. -.TP -.B \-r --recurse -Travel the directory structure recursively. If any of the file names -specified on the command line are directories, -.I gzip -will descend into the directory and compress all the files it finds there -(or decompress them in the case of -.I gunzip -). -.TP -.B \-S .z --suffix .z -Use suffix .z instead of .gz. Any suffix can be given, but suffixes -other than .z and .gz should be avoided to avoid confusion when files -are transferred to other systems. Previous versions of gzip used -the .z suffix. This was changed to avoid a conflict with -.IR pack "(1)". -.TP -.B \-t --test -Test. Check the compressed file integrity. -.TP -.B \-v --verbose -Verbose. Display the name and percentage reduction for each file compressed. -.TP -.B \-V --version -Version. Display the version number and compilation options then quit. -.TP -.B \-# --fast --best -Regulate the speed of compression using the specified digit -.IR # , -where -.B \-1 -or -.B \-\-fast -indicates the fastest compression method (less compression) -and -.B \-9 -or -.B \-\-best -indicates the slowest compression method (optimal compression). -The default compression level is -.BR \-5. -.SH "ADVANCED USAGE" -Multiple compressed files can be concatenated. In this case, -.I gunzip -will extract all members at once. For example: - - gzip -c file1 > foo.gz - gzip -c file2 >> foo.gz - -Then - gunzip -c foo - -is equivalent to - - cat file1 file2 - -In case of damage to one member of a .gz file, other members can -still be recovered (if the damaged member is removed). However, -you can get better compression by compressing all members at once: - - cat file1 file2 | gzip > foo.gz - -compresses better than - - gzip -c file1 file2 > foo.gz - -If you want to recompress concatenated files to get better compression, do: - - zcat old.gz | gzip > new.gz -.SH "ENVIRONMENT" -The environment variable -.B GZIP -can hold a set of default options for -.I gzip. -These options are interpreted first and can be overwritten by -explicit command line parameters. For example: - for sh: GZIP="-8 -v"; export GZIP - for csh: setenv GZIP "-8 -v" - for MSDOS: set GZIP=-8 -v - -On Vax/VMS, the name of the environment variable is GZIP_OPT, to -avoid a conflict with the symbol set for invocation of the program. -.SH "SEE ALSO" -znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1), unzip(1), compress(1), -pack(1), compact(1) -.SH "DIAGNOSTICS" -Exit status is normally 0; -if an error occurs, exit status is 1. If a warning occurs, exit status is 2. -.PP -Usage: gzip [-cdfhLrtvV19] [-S suffix] [file ...] -.in +8 -Invalid options were specified on the command line. -.in -8 -.IR file : -not in gzip format -.in +8 -The file specified to -.I gunzip -has not been compressed. -.in -8 -.IR file: -Corrupt input. Use zcat to recover some data. -.in +8 -The compressed file has been damaged. The data up to the point of failure -can be recovered using -.in +8 -zcat file > recover -.in -16 -.IR file : -compressed with -.I xx -bits, can only handle -.I yy -bits -.in +8 -.I File -was compressed (using LZW) by a program that could deal with -more -.I bits -than the decompress code on this machine. -Recompress the file with gzip, which compresses better and uses -less memory. -.in -8 -.IR file : -already has .gz suffix -- no change -.in +8 -The file is assumed to be already compressed. -Rename the file and try again. -.in -8 -.I file -already exists; do you wish to overwrite (y or n)? -.in +8 -Respond "y" if you want the output file to be replaced; "n" if not. -.in -8 -gunzip: corrupt input -.in +8 -A SIGSEGV violation was detected which usually means that the input file has -been corrupted. -.in -8 -.I "xx.x%" -.in +8 -Percentage of the input saved by compression. -(Relevant only for -.BR \-v \.) -.in -8 --- not a regular file or directory: ignored -.in +8 -When the input file is not a regular file or directory, -(e.g. a symbolic link, socket, FIFO, device file), it is -left unaltered. -.in -8 --- has -.I xx -other links: unchanged -.in +8 -The input file has links; it is left unchanged. See -.IR ln "(1)" -for more information. Use the -.B \-f -flag to force compression of multiply-linked files. -.in -8 -.SH CAVEATS -When writing compressed data to a tape, it is generally necessary to -pad the output with zeroes up to a block boundary. When the data is -read and the whole block is passed to -.I gunzip -for decompression, -.I gunzip -detects that there is extra trailing garbage after the compressed data -and emits a warning by default. You have to use the --quiet option to -suppress the warning. This option can be set in the -.B GZIP -environment variable as in: - for sh: GZIP="-q" tar xfz /dev/rmt/datn - for csh: (setenv GZIP "-q"; tar xfz /dev/rmt/datn) - -In the above example, gzip is invoked implicitly by the -z option -of GNU tar. Make sure that the same block size (-b option of -tar) is used for reading and writing compressed data on tapes. diff --git a/gnu/usr.bin/gzip-1.1.1/gzip.c b/gnu/usr.bin/gzip-1.1.1/gzip.c deleted file mode 100644 index b63087fc4726..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/gzip.c +++ /dev/null @@ -1,1458 +0,0 @@ -/* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface - * Copyright (C) 1992-1993 Jean-loup Gailly - * The unzip code was written and put in the public domain by Mark Adler. - * Portions of the lzw code are derived from the public domain 'compress' - * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, - * Ken Turkowski, Dave Mack and Peter Jannesen. - * - * See the license_msg below and the file COPYING for the software license. - * See the file algorithm.doc for the compression algorithms and file formats. - */ - -static char *license_msg[] = { -" Copyright (C) 1992-1993 Jean-loup Gailly", -" 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.", -0}; - -/* Compress files with zip algorithm and 'compress' interface. - * See usage() and help() functions below for all options. - * Outputs: - * file.gz: compressed file with same mode, owner, and utimes - * or stdout with -c option or if stdin used as input. - * If the OS does not support file names with multiple dots (MSDOS, VMS) or - * if the output file name had to be truncated, the original name is kept - * in the compressed file. - * On MSDOS, file.tmp -> file.tmz. On VMS, file.tmp -> file.tmp-gz. - * - * For the meaning of all compilation flags, see comments in Makefile.in. - */ - -#ifndef lint -static char rcsid[] = "$Id: gzip.c,v 1.1 1993/06/29 14:49:37 brezak Exp $"; -#endif - -#include -#include -#include -#include -#include -#include - -#include "tailor.h" -#include "gzip.h" -#include "lzw.h" -#include "revision.h" -#include "getopt.h" - - /* configuration */ - -#ifndef NO_FCNTL_H -# include -#endif - -#ifdef HAVE_UNISTD_H -# include -#endif - -#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H) -# include -#else - extern int errno; -#endif - -#if defined(DIRENT) -# include - typedef struct dirent dir_type; -# define NLENGTH(dirent) ((int)strlen((dirent)->d_name)) -# define DIR_OPT "DIRENT" -#else -# define NLENGTH(dirent) ((dirent)->d_namlen) -# ifdef SYSDIR -# include - typedef struct direct dir_type; -# define DIR_OPT "SYSDIR" -# else -# ifdef SYSNDIR -# include - typedef struct direct dir_type; -# define DIR_OPT "SYSNDIR" -# else -# ifdef NDIR -# include - typedef struct direct dir_type; -# define DIR_OPT "NDIR" -# else -# define NO_DIR -# define DIR_OPT "NO_DIR" -# endif -# endif -# endif -#endif - -#ifndef NO_UTIME -# ifndef NO_UTIME_H -# include -# define TIME_OPT "UTIME" -# else -# ifdef HAVE_SYS_UTIME_H -# include -# define TIME_OPT "SYS_UTIME" -# else - struct utimbuf { - time_t actime; - time_t modtime; - }; -# define TIME_OPT "" -# endif -# endif -#else -# define TIME_OPT "NO_UTIME" -#endif - -#if !defined(S_ISDIR) && defined(S_IFDIR) -# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#endif -#if !defined(S_ISREG) && defined(S_IFREG) -# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#endif - -typedef RETSIGTYPE (*sig_type) OF((int)); - -#ifndef O_BINARY -# define O_BINARY 0 /* creation mode for open() */ -#endif - -#ifndef O_CREAT - /* Pure BSD system? */ -# include -# ifndef O_CREAT -# define O_CREAT FCREAT -# endif -# ifndef O_EXCL -# define O_EXCL FEXCL -# endif -#endif - -#ifndef S_IRUSR -# define S_IRUSR 0400 -#endif -#ifndef S_IWUSR -# define S_IWUSR 0200 -#endif -#define RW_USER (S_IRUSR | S_IWUSR) /* creation mode for open() */ - -#ifndef MAX_PATH_LEN -# define MAX_PATH_LEN 1024 /* max pathname length */ -#endif - -#define MAX_HEADER_LEN 16 -/* max length of a compressed file header, fixed part only */ - - /* global buffers */ - -DECLARE(uch, inbuf, INBUFSIZ +INBUF_EXTRA); -DECLARE(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA); -DECLARE(ush, d_buf, DIST_BUFSIZE); -DECLARE(uch, window, 2L*WSIZE); -#ifndef MAXSEG_64K - DECLARE(ush, tab_prefix, 1L< 4 && strequ(progname+proglen-4, ".exe")) { - progname[proglen-4] = '\0'; - } - - /* Add options in GZIP environment variable if there is one */ - env = add_envopt(&argc, &argv, OPTIONS_VAR); - if (env != NULL) args = argv; - - foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; - if (foreground) { - signal (SIGINT, (sig_type)abort_gzip); - } -#ifdef SIGTERM - signal(SIGTERM, (sig_type)abort_gzip); -#endif -#ifdef SIGHUP - signal(SIGHUP, (sig_type)abort_gzip); -#endif - -#ifndef GNU_STANDARD - /* For compatibility with old compress, use program name as an option. - * If you compile with -DGNU_STANDARD, this program will behave as - * gzip even if it is invoked under the name gunzip or zcat. - * - * Systems which do not support links can still use -d or -dc. - * Ignore an .exe extension for MSDOS, OS/2 and VMS. - */ - if ( strncmp(progname, "un", 2) == 0 /* ungzip, uncompress */ - || strncmp(progname, "gun", 3) == 0) { /* gunzip */ - decompress = 1; - } else if (strequ(progname+1, "cat") /* zcat, pcat, gcat */ - || strequ(progname, "gzcat")) { /* gzcat */ - decompress = to_stdout = 1; - } -#endif - - strncpy(z_suffix, Z_SUFFIX, sizeof(z_suffix)-1); - z_len = strlen(z_suffix); - - while ((optc = getopt_long (argc, argv, "ab:cdfhLqrS:tvVZ123456789", - longopts, (int *)0)) != EOF) { - switch (optc) { - case 'a': - ascii = 1; break; - case 'b': - maxbits = atoi(optarg); - break; - case 'c': - to_stdout = 1; break; - case 'd': - decompress = 1; break; - case 'f': - force++; break; - case 'h': case 'H': case '?': - help(); do_exit(OK); break; - case 'L': - license(); do_exit(OK); break; - case 'q': - quiet = 1; verbose = 0; break; - case 'r': -#ifdef NO_DIR - fprintf(stderr, "%s: -r not supported on this system\n", progname); - usage(); - do_exit(ERROR); break; -#else - recursive = 1; break; -#endif - case 'S': -#ifdef NO_MULTIPLE_DOTS - if (*optarg == '.') optarg++; -#endif - z_len = strlen(optarg); - if (z_len == 0 || z_len > MAX_SUFFIX) { - fprintf(stderr, "%s: incorrect suffix '%s'\n", - progname, optarg); - do_exit(ERROR); - } - strcpy(z_suffix, optarg); - break; - case 't': - test = decompress = to_stdout = 1; - break; - case 'v': - verbose++; quiet = 0; break; - case 'V': - version(); do_exit(OK); break; - case 'Z': -#ifdef LZW - do_lzw = 1; break; -#else - fprintf(stderr, "%s: -Z not supported in this version\n", - progname); - usage(); - do_exit(ERROR); break; -#endif - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - level = optc - '0'; - break; - default: - /* Error message already emitted by getopt_long. */ - usage(); - do_exit(ERROR); - } - } /* loop on all arguments */ - - file_count = argc - optind; - -#if O_BINARY -#else - if (ascii && !quiet) { - fprintf(stderr, "%s: option --ascii ignored on this system\n", - progname); - } -#endif - if (do_lzw && !decompress) work = lzw; - - /* Allocate all global buffers (for DYN_ALLOC option) */ - ALLOC(uch, inbuf, INBUFSIZ +INBUF_EXTRA); - ALLOC(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA); - ALLOC(ush, d_buf, DIST_BUFSIZE); - ALLOC(uch, window, 2L*WSIZE); -#ifndef MAXSEG_64K - ALLOC(ush, tab_prefix, 1L< 1 && !to_stdout && !force) { - WARN((stderr, "%s: %s has %d other link%c -- unchanged\n", - progname, ifname, - (int)istat.st_nlink - 1, istat.st_nlink > 2 ? 's' : ' ')); - return; - } - - ifile_size = istat.st_size; - time_stamp = istat.st_mtime; - - /* Generate output file name */ - if (to_stdout) { - strcpy(ofname, "stdout"); - - } else if (make_ofname() != OK) { - return; - } - - /* Open the input file and determine compression method. The mode - * parameter is ignored but required by some systems (VMS) and forbidden - * on other systems (MacOS). - */ - ifd = OPEN(ifname, ascii && !decompress ? O_RDONLY : O_RDONLY | O_BINARY, - RW_USER); - if (ifd == -1) { - fprintf(stderr, "%s: ", progname); - perror(ifname); - exit_code = ERROR; - return; - } - clear_bufs(); /* clear input and output buffers */ - part_nb = 0; - - if (decompress) { - method = get_method(ifd); /* updates ofname if original given */ - if (method < 0) { - close(ifd); - return; /* error message already emitted */ - } - } - - /* If compressing to a file, check if ofname is not ambiguous - * because the operating system truncates names. Otherwise, generate - * a new ofname and save the original name in the compressed file. - */ - if (to_stdout) { - ofd = fileno(stdout); - /* keep remove_ofname as zero */ - } else { - if (create_outfile() != OK) return; - - if (save_orig_name && !verbose && !quiet) { - fprintf(stderr, "%s: %s compressed to %s\n", - progname, ifname, ofname); - } - } - if (verbose) { - fprintf(stderr, "%s:\t%s", ifname, (int)strlen(ifname) >= 15 ? - "" : ((int)strlen(ifname) >= 7 ? "\t" : "\t\t")); - } - - /* Actually do the compression/decompression. Loop over zipped members. - */ - for (;;) { - if ((*work)(ifd, ofd) != OK) { - method = -1; /* force cleanup */ - break; - } - if (!decompress || last_member || inptr == insize) break; - /* end of file */ - - method = get_method(ifd); - if (method < 0) break; /* error message already emitted */ - bytes_out = 0; /* required for length check */ - } - - close(ifd); - if (!to_stdout && close(ofd)) { - write_error(); - } - if (method == -1) { - if (!to_stdout) unlink (ofname); - return; - } - /* Display statistics */ - if(verbose) { - if (test) { - fprintf(stderr, " OK"); - } else if (decompress) { - display_ratio(bytes_out-(bytes_in-header_bytes), bytes_out); - } else { - display_ratio(bytes_in-(bytes_out-header_bytes), bytes_in); - } - if (!test && !to_stdout) { - fprintf(stderr, " -- replaced with %s", ofname); - } - fprintf(stderr, "\n"); - } - /* Copy modes, times, ownership, and remove the input file */ - if (!to_stdout) { - copy_stat(&istat); - } -} - -/* ======================================================================== - * Create the output file. Return OK or ERROR. - * Try several times if necessary to avoid truncating the z_suffix. For - * example, do not create a compressed file of name "1234567890123." - * IN assertions: the input file has already been open (ifd is set) and - * ofname has already been updated if there was an original name. - * OUT assertions: ifd and ofd are closed in case of error. - */ -local int create_outfile() -{ - struct stat ostat; /* stat for ofname */ - int len; - int flags = O_WRONLY | O_CREAT | O_EXCL | O_BINARY; - - if (ascii && decompress) { - flags &= ~O_BINARY; /* force ascii text mode */ - } - for (;;) { - len = strlen(ofname); - if (len == 0 || ofname[len] == PATH_SEP) break; - if (check_ofname() != OK) { - close(ifd); - return ERROR; - } - /* Create the output file */ - remove_ofname = 1; - ofd = OPEN(ofname, flags, RW_USER); - if (ofd == -1) { - perror(ofname); - close(ifd); - exit_code = ERROR; - return ERROR; - } - - /* Check for name truncation on new file (1234567890123.gz) */ - if (fstat(ofd, &ostat) != 0) { - fprintf(stderr, "%s: ", progname); - perror(ofname); - close(ifd); close(ofd); - unlink(ofname); - exit_code = ERROR; - return ERROR; - } - if (!name_too_long(ofname, &ostat)) return OK; - - if (decompress) { - /* name might be too long if an original name was saved */ - WARN((stderr, "%s: %s: warning, name truncated\n", - progname, ofname)); - return OK; - } else { -#ifdef NO_MULTIPLE_DOTS - /* Should never happen, see check_ofname() */ - fprintf(stderr, "%s: %s: name too long\n", progname, ofname); - do_exit(ERROR); -#else - close(ofd); - unlink(ofname); - save_orig_name = 1; - strcpy(ofname+strlen(ofname)-z_len-1, z_suffix); - /* 123456789012.gz -> 12345678901.gz */ -#endif - } /* decompress ? */ - } /* while non null name */ - - close(ifd); - fprintf(stderr, "%s: %s: name too long\n", progname, ofname); - exit_code = ERROR; - return ERROR; -} - -/* ======================================================================== - * Use lstat if available, except for -c or -f. Use stat otherwise. - * This allows links when not removing the original file. - */ -local int do_stat(name, sbuf) - char *name; - struct stat *sbuf; -{ - errno = 0; -#if (defined(S_IFLNK) || defined (S_ISLNK)) && !defined(NO_SYMLINK) - if (!to_stdout && !force) { - return lstat(name, sbuf); - } -#endif - return stat(name, sbuf); -} - -/* ======================================================================== - * Return a pointer to the 'z' suffix of a file name, or NULL. For all - * systems, ".gz", ".z", ".Z", ".taz", ".tgz", "-gz", "-z" and "_z" are - * accepted suffixes, in addition to the value of the --suffix option. - * ".tgz" is a useful convention for tar.z files on systems limited - * to 3 characters extensions. On such systems, ".?z" and ".??z" are - * also accepted suffixes. For Unix, we do not want to accept any - * .??z suffix as indicating a compressed file; some people use .xyz - * to denote volume data. - */ -local char *get_suffix(name) - char *name; -{ - int nlen, slen; - char suffix[MAX_SUFFIX+3]; /* last chars of name, forced to lower case */ - static char *known_suffixes[] = - {z_suffix, ".gz", ".z", ".taz", ".tgz", "-gz", "-z", "_z", -#ifdef MAX_EXT_CHARS - "z", -#endif - NULL}; - char **suf = known_suffixes; - - if (strequ(z_suffix, "z")) suf++; /* check long suffixes first */ - - nlen = strlen(name); - if (nlen <= MAX_SUFFIX+2) { - strcpy(suffix, name); - } else { - strcpy(suffix, name+nlen-MAX_SUFFIX-2); - } -#ifdef SUFFIX_SEP - /* strip a version number from the file name */ - { - char *v = strrchr(suffix, SUFFIX_SEP); - if (v != NULL) *v = '\0', nlen = v - name; - } -#endif - strlwr(suffix); - slen = strlen(suffix); - do { - int s = strlen(*suf); - if (slen > s && suffix[slen-s-1] != PATH_SEP - && strequ(suffix + slen - s, *suf)) { - return name+nlen-s; - } - } while (*++suf != NULL); - - return NULL; -} - - -/* ======================================================================== - * Set ifname to the input file name (with a suffix appended if necessary) - * and istat to its stats. For decompression, if no file exists with the - * original name, try adding successively z_suffix, .gz, .z, -z and .Z. - * For MSDOS, we try only z_suffix and z. - * Return OK or ERROR. - */ -local int get_istat(iname, sbuf) - char *iname; - struct stat *sbuf; -{ - int ilen; /* strlen(ifname) */ - static char *suffixes[] = {z_suffix, ".gz", ".z", "-z", ".Z", NULL}; - char **suf = suffixes; - char *s; -#ifdef NO_MULTIPLE_DOTS - char *dot; /* pointer to ifname extension, or NULL */ -#endif - - strcpy(ifname, iname); - - /* If input file exists, return OK. */ - if (do_stat(ifname, sbuf) == 0) return OK; - - if (!decompress || errno != ENOENT) { - perror(ifname); - exit_code = ERROR; - return ERROR; - } - /* file.ext doesn't exist, try adding a suffix. - */ - s = get_suffix(ifname); - if (s != NULL) { - perror(ifname); /* ifname already has z suffix and does not exist */ - exit_code = ERROR; - return ERROR; - } -#ifdef SUFFIX_SEP - /* strip a version number from the input file name */ - if ((s = strrchr(ifname, SUFFIX_SEP)) != NULL) *s = '\0'; -#endif -#ifdef NO_MULTIPLE_DOTS - dot = strrchr(ifname, '.'); - if (dot == NULL) { - strcat(ifname, "."); - dot = strrchr(ifname, '.'); - } -#endif - ilen = strlen(ifname); - if (strequ(z_suffix, ".gz")) suf++; - - /* Search for all suffixes */ - do { - s = *suf; -#ifdef NO_MULTIPLE_DOTS - if (*s == '.') s++; -#endif -#ifdef MAX_EXT_CHARS - strcpy(ifname, iname); - /* Needed if the suffixes are not sorted by increasing length */ - - if (*dot == '\0') strcpy(dot, "."); - dot[MAX_EXT_CHARS+1-strlen(s)] = '\0'; -#endif - strcat(ifname, s); - if (do_stat(ifname, sbuf) == 0) return OK; - ifname[ilen] = '\0'; - } while (*++suf != NULL); - - /* No suffix found, complain using z_suffix: */ -#ifdef MAX_EXT_CHARS - strcpy(ifname, iname); - if (*dot == '\0') strcpy(dot, "."); - dot[MAX_EXT_CHARS+1-z_len] = '\0'; -#endif - strcat(ifname, z_suffix); - perror(ifname); - exit_code = ERROR; - return ERROR; -} - -/* ======================================================================== - * Generate ofname given ifname. Return OK, or WARNING if file must be skipped. - * Initializes save_orig_name. - * IN assertion: this function is not called if to_stdout is true. - */ -local int make_ofname() -{ - char *suff; /* ofname z suffix */ - - strcpy(ofname, ifname); - suff = get_suffix(ofname); - - if (decompress) { - if (suff == NULL) { - WARN((stderr,"%s: %s: unknown suffix -- ignored\n", - progname, ifname)); - return WARNING; - } - /* Make a special case for .tgz and .taz: */ - strlwr(suff); - if (strequ(suff, ".tgz") || strequ(suff, ".taz")) { - strcpy(suff, ".tar"); - } else { - *suff = '\0'; /* strip z suffix and optional version number */ - } - /* ofname might be changed later if infile contains an original name */ - - } else if (suff != NULL) { - /* Avoid annoying messages with -r (see treat_dir()) */ - if (verbose || (!recursive && !quiet)) { - fprintf(stderr, "%s: %s already has %s suffix -- unchanged\n", - progname, ifname, suff); - } - if (exit_code == OK) exit_code = WARNING; - return WARNING; - } else { - save_orig_name = 0; - -#ifdef SUFFIX_SEP - /* strip a version number from the file name */ - if ((suff = strrchr(ofname, SUFFIX_SEP)) != NULL) *suff = '\0'; -#endif - -#ifdef NO_MULTIPLE_DOTS - suff = strrchr(ofname, '.'); - if (suff == NULL) { - strcat(ofname, "."); -# ifdef MAX_EXT_CHARS - /* On the Atari and some versions of MSDOS, name_too_long() - * does not work correctly because of a bug in stat(). So we - * must truncate here. - */ - } else if (strlen(suff)-1 + z_len > MAX_SUFFIX) { - suff[MAX_SUFFIX+1-z_len] = '\0'; - save_orig_name = 1; -# endif - } -#endif /* NO_MULTIPLE_DOTS */ - strcat(ofname, z_suffix); - - } /* decompress ? */ - return OK; -} - - -/* ======================================================================== - * Check the magic number of the input file and update ofname if an - * original name was given and to_stdout is not set. - * Return the compression method, -1 for error, -2 for warning. - * Set inptr to the offset of the next byte to be processed. - * This function may be called repeatedly for an input file consisting - * of several contiguous gzip'ed members. - * IN assertions: there is at least one remaining compressed member. - * If the member is a zip file, it must be the only one. - */ -local int get_method(in) - int in; /* input file descriptor */ -{ - uch flags; - char magic[2]; /* magic header */ - - magic[0] = (char)get_byte(); - magic[1] = (char)get_byte(); - - time_stamp = istat.st_mtime; /* may be modified later for some methods */ - method = -1; /* unknown yet */ - part_nb++; /* number of parts in gzip file */ - header_bytes = 0; - last_member = RECORD_IO; - /* assume multiple members in gzip file except for record oriented I/O */ - - if (memcmp(magic, GZIP_MAGIC, 2) == 0 - || memcmp(magic, OLD_GZIP_MAGIC, 2) == 0) { - - work = unzip; - method = (int)get_byte(); - flags = (uch)get_byte(); - - if ((flags & ENCRYPTED) != 0) { - fprintf(stderr, - "%s: %s is encrypted -- get newer version of gzip\n", - progname, ifname); - exit_code = ERROR; - return -1; - } - if ((flags & CONTINUATION) != 0) { - fprintf(stderr, - "%s: %s is a a multi-part gzip file -- get newer version of gzip\n", - progname, ifname); - exit_code = ERROR; - if (force <= 1) return -1; - } - if ((flags & RESERVED) != 0) { - fprintf(stderr, - "%s: %s has flags 0x%x -- get newer version of gzip\n", - progname, ifname, flags); - exit_code = ERROR; - if (force <= 1) return -1; - } - time_stamp = (ulg)get_byte(); - time_stamp |= ((ulg)get_byte()) << 8; - time_stamp |= ((ulg)get_byte()) << 16; - time_stamp |= ((ulg)get_byte()) << 24; - - (void)get_byte(); /* Ignore extra flags for the moment */ - (void)get_byte(); /* Ignore OS type for the moment */ - - if ((flags & CONTINUATION) != 0) { - unsigned part = (unsigned)get_byte(); - part |= ((unsigned)get_byte())<<8; - if (verbose) { - fprintf(stderr,"%s: %s: part number %u\n", - progname, ifname, part); - } - } - if ((flags & EXTRA_FIELD) != 0) { - unsigned len = (unsigned)get_byte(); - len |= ((unsigned)get_byte())<<8; - if (verbose) { - fprintf(stderr,"%s: %s: extra field of %u bytes ignored\n", - progname, ifname, len); - } - while (len--) (void)get_byte(); - } - - /* Get original file name if it was truncated */ - if ((flags & ORIG_NAME) != 0) { - if (to_stdout || part_nb > 1) { - /* Discard the old name */ - char c; /* dummy used for NeXTstep 3.0 cc optimizer bug */ - while ((c=get_byte()) != 0) c++; - } else { - /* Copy the base name. Keep a directory prefix intact. */ - char *p = basename(ofname); - for (;;) { - *p = (char)get_char(); - if (*p++ == '\0') break; - if (p >= ofname+sizeof(ofname)) { - error("corrupted input -- file name too large"); - } - } - } /* to_stdout */ - } /* orig_name */ - - /* Discard file comment if any */ - if ((flags & COMMENT) != 0) { - while (get_char() != 0) /* null */ ; - } - if (part_nb == 1) { - header_bytes = inptr + 2*sizeof(long); /* include crc and size */ - } - - } else if (memcmp(magic, PKZIP_MAGIC, 2) == 0 && inptr == 2 - && memcmp((char*)inbuf, PKZIP_MAGIC, 4) == 0) { - /* To simplify the code, we support a zip file when alone only. - * We are thus guaranteed that the entire local header fits in inbuf. - */ - inptr = 0; - work = unzip; - if (check_zipfile(in) != OK) return -1; - /* check_zipfile may get ofname from the local header */ - last_member = 1; - - } else if (memcmp(magic, PACK_MAGIC, 2) == 0) { - work = unpack; - method = PACKED; - } else if (memcmp(magic, LZW_MAGIC, 2) == 0) { - work = unlzw; - method = COMPRESSED; - last_member = 1; - } - if (method >= 0) return method; - if (part_nb == 1) { - fprintf(stderr, "\n%s: %s: not in gzip format\n", progname, ifname); - exit_code = ERROR; - return -1; - } else { - WARN((stderr, "\n%s: %s: trailing garbage ignored\n", - progname, ifname)); - return -2; - } -} - -/* ======================================================================== - * Return true if the two stat structures correspond to the same file. - */ -local int same_file(stat1, stat2) - struct stat *stat1; - struct stat *stat2; -{ - return stat1->st_ino == stat2->st_ino - && stat1->st_dev == stat2->st_dev -#ifdef NO_ST_INO - /* Can't rely on st_ino and st_dev, use other fields: */ - && stat1->st_mode == stat2->st_mode - && stat1->st_uid == stat2->st_uid - && stat1->st_gid == stat2->st_gid - && stat1->st_size == stat2->st_size - && stat1->st_atime == stat2->st_atime - && stat1->st_mtime == stat2->st_mtime - && stat1->st_ctime == stat2->st_ctime -#endif - ; -} - -/* ======================================================================== - * Return true if a file name is ambiguous because the operating system - * truncates file names. - */ -local int name_too_long(name, statb) - char *name; /* file name to check */ - struct stat *statb; /* stat buf for this file name */ -{ - int s = strlen(name); - char c = name[s-1]; - struct stat tstat; /* stat for truncated name */ - int res; - - tstat = *statb; /* Just in case OS does not fill all fields */ - name[s-1] = '\0'; - res = stat(name, &tstat) == 0 && same_file(statb, &tstat); - name[s-1] = c; - Trace((stderr, " too_long(%s) => %d\n", name, res)); - return res; -} - -/* ======================================================================== - * If compressing to a file, check if ofname is not ambiguous - * because the operating system truncates names. Otherwise, generate - * a new ofname and save the original name in the compressed file. - * If the compressed file already exists, ask for confirmation. - * The check for name truncation is made dynamically, because different - * file systems on the same OS might use different truncation rules (on SVR4 - * s5 truncates to 14 chars and ufs does not truncate). - * This function returns -1 if the file must be skipped, and - * updates save_orig_name if necessary. - * IN assertions: save_orig_name is already set if ofname has been - * already truncated because of NO_MULTIPLE_DOTS. The input file has - * already been open and istat is set. - */ -local int check_ofname() -{ - int s = strlen(ofname); - struct stat ostat; /* stat for ofname */ - - if (stat(ofname, &ostat) != 0) return 0; - - /* Check for name truncation on existing file: */ -#ifdef NO_MULTIPLE_DOTS - if (!decompress && name_too_long(ofname, &ostat)) { -#else - if (!decompress && s > 8 && name_too_long(ofname, &ostat)) { -#endif - save_orig_name = 1; - strcpy(ofname+s-z_len-1, z_suffix); /* f.ext.gz -> f.ex.gz */ - - if (stat(ofname, &ostat) != 0) return 0; - } /* !decompress && name_too_long */ - - /* Check that the input and output files are different (could be - * the same by name truncation or links). - */ - if (same_file(&istat, &ostat)) { - fprintf(stderr, "%s: %s and %s are the same file\n", - progname, ifname, ofname); - exit_code = ERROR; - return ERROR; - } - /* Ask permission to overwrite the existing file */ - if (!force) { - char response[80]; - strcpy(response,"n"); - fprintf(stderr, "%s: %s already exists;", progname, ofname); - if (foreground && isatty(fileno(stdin))) { - fprintf(stderr, " do you wish to overwrite (y or n)? "); - fflush(stderr); - (void)fgets(response, sizeof(response)-1, stdin); - } - if (tolow(*response) != 'y') { - fprintf(stderr, "\tnot overwritten\n"); - if (exit_code == OK) exit_code = WARNING; - return ERROR; - } - } - (void) chmod(ofname, 0777); - if (unlink(ofname)) { - fprintf(stderr, "%s: ", progname); - perror(ofname); - exit_code = ERROR; - return ERROR; - } - return OK; -} - - -/* ======================================================================== - * Set the access and modification times from the given stat buffer. - */ -local void reset_times (name, statb) - char *name; - struct stat *statb; -{ -#ifndef NO_UTIME - struct utimbuf timep; - - /* Copy the time stamp */ - timep.actime = statb->st_atime; - timep.modtime = statb->st_mtime; - - /* Some systems (at least OS/2) do not support utime on directories */ - if (utime(name, &timep) && !S_ISDIR(statb->st_mode)) { - WARN((stderr, "%s: ", progname)); - if (!quiet) perror(ofname); - } -#else - name = name; statb = statb; /* avoid warnings */ -#endif -} - - -/* ======================================================================== - * Copy modes, times, ownership from input file to output file. - * IN assertion: to_stdout is false. - */ -local void copy_stat(ifstat) - struct stat *ifstat; -{ -#ifndef NO_UTIME - if (decompress && time_stamp != 0 && ifstat->st_mtime != time_stamp) { - ifstat->st_mtime = time_stamp; - if (verbose) { - fprintf(stderr, "%s: time stamp restored\n", ofname); - } - } - reset_times(ofname, ifstat); -#endif - /* Copy the protection modes */ - if (chmod(ofname, ifstat->st_mode & 07777)) { - WARN((stderr, "%s: ", progname)); - if (!quiet) perror(ofname); - } -#ifndef NO_CHOWN - chown(ofname, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */ -#endif - remove_ofname = 0; - /* It's now safe to remove the input file: */ - (void) chmod(ifname, 0777); - if (unlink(ifname)) { - WARN((stderr, "%s: ", progname)); - if (!quiet) perror(ifname); - } -} - -#ifndef NO_DIR - -/* ======================================================================== - * Recurse through the given directory. This code is taken from ncompress. - */ -local void treat_dir(dir) - char *dir; -{ - dir_type *dp; - DIR *dirp; - char nbuf[MAX_PATH_LEN]; - int len; - - dirp = opendir(dir); - - if (dirp == NULL) { - fprintf(stderr, "%s: %s unreadable\n", progname, dir); - exit_code = ERROR; - return ; - } - /* - ** WARNING: the following algorithm could occasionally cause - ** compress to produce error warnings of the form ".gz - ** already has .gz suffix - ignored". This occurs when the - ** .gz output file is inserted into the directory below - ** readdir's current pointer. - ** These warnings are harmless but annoying, so they are suppressed - ** with option -r (except when -v is on). An alternative - ** to allowing this would be to store the entire directory - ** list in memory, then compress the entries in the stored - ** list. Given the depth-first recursive algorithm used here, - ** this could use up a tremendous amount of memory. I don't - ** think it's worth it. -- Dave Mack - ** (An other alternative might be two passes to avoid depth-first.) - */ - - while ((dp = readdir(dirp)) != NULL) { - - if (strequ(dp->d_name,".") || strequ(dp->d_name,"..")) { - continue; - } - len = strlen(dir); - if (len + NLENGTH(dp) + 1 < MAX_PATH_LEN - 1) { - strcpy(nbuf,dir); - if (len != 0 /* dir = "" means current dir on Amiga */ -#ifdef PATH_SEP2 - && dir[len-1] != PATH_SEP2 -#endif -#ifdef PATH_SEP3 - && dir[len-1] != PATH_SEP3 -#endif - ) { - nbuf[len++] = PATH_SEP; - } - strcpy(nbuf+len, dp->d_name); - treat_file(nbuf); - } else { - fprintf(stderr,"%s: %s/%s: pathname too long\n", - progname, dir, dp->d_name); - exit_code = ERROR; - } - } - closedir(dirp); -} -#endif /* ? NO_DIR */ - -/* ======================================================================== - * Free all dynamically allocated variables and exit with the given code. - */ -local void do_exit(exitcode) - int exitcode; -{ - if (env != NULL) free(env), env = NULL; - if (args != NULL) free((char*)args), args = NULL; - FREE(inbuf); - FREE(outbuf); - FREE(d_buf); - FREE(window); -#ifndef MAXSEG_64K - FREE(tab_prefix); -#else - FREE(tab_prefix0); - FREE(tab_prefix1); -#endif - exit(exitcode); -} - -/* ======================================================================== - * Signal and error handler. - */ -RETSIGTYPE abort_gzip() -{ - if (remove_ofname) { - close(ofd); - unlink (ofname); - } - do_exit(ERROR); -} diff --git a/gnu/usr.bin/gzip-1.1.1/gzip.h b/gnu/usr.bin/gzip-1.1.1/gzip.h deleted file mode 100644 index a4d637626042..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/gzip.h +++ /dev/null @@ -1,302 +0,0 @@ -/* gzip.h -- common declarations for all gzip modules - * Copyright (C) 1992-1993 Jean-loup Gailly. - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#if defined(__STDC__) || defined(PROTO) -# define OF(args) args -#else -# define OF(args) () -#endif - -#ifdef __STDC__ - typedef void *voidp; -#else - typedef char *voidp; -#endif - -/* I don't like nested includes, but the string functions are used too often */ -#if !defined(NO_STRING_H) || defined(STDC_HEADERS) -# include -# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__) -# include -# endif -# define memzero(s, n) memset ((voidp)(s), 0, (n)) -#else -# include -# define strchr index -# define strrchr rindex -# define memcpy(d, s, n) bcopy((s), (d), (n)) -# define memcmp(s1, s2, n) bcmp((s1), (s2), (n)) -# define memzero(s, n) bzero((s), (n)) -#endif - -#ifndef RETSIGTYPE -# define RETSIGTYPE void -#endif - -#define local static - -typedef unsigned char uch; -typedef unsigned short ush; -typedef unsigned long ulg; - -/* Return codes from gzip */ -#define OK 0 -#define ERROR 1 -#define WARNING 2 - -/* Compression methods (see algorithm.doc) */ -#define STORED 0 -#define COMPRESSED 1 -#define PACKED 2 -/* methods 3 to 7 reserved */ -#define DEFLATED 8 -extern int method; /* compression method */ - -/* To save memory for 16 bit systems, some arrays are overlaid between - * the various modules: - * deflate: prev+head window d_buf l_buf outbuf - * unlzw: tab_prefix tab_suffix stack inbuf outbuf - * inflate: window inbuf - * unpack: window inbuf - * For compression, input is done in window[]. For decompression, output - * is done in window except for unlzw. - */ - -#ifndef INBUFSIZ -# ifdef SMALL_MEM -# define INBUFSIZ 0x2000 /* input buffer size */ -# else -# define INBUFSIZ 0x8000 /* input buffer size */ -# endif -#endif -#define INBUF_EXTRA 64 /* required by unlzw() */ - -#ifndef OUTBUFSIZ -# ifdef SMALL_MEM -# define OUTBUFSIZ 8192 /* output buffer size */ -# else -# define OUTBUFSIZ 16384 /* output buffer size */ -# endif -#endif -#define OUTBUF_EXTRA 2048 /* required by unlzw() */ - -#ifndef DIST_BUFSIZE -# ifdef SMALL_MEM -# define DIST_BUFSIZE 0x2000 /* buffer for distances, see trees.c */ -# else -# define DIST_BUFSIZE 0x8000 /* buffer for distances, see trees.c */ -# endif -#endif - -#ifdef DYN_ALLOC -# define EXTERN(type, array) extern type * near array -# define DECLARE(type, array, size) type * near array -# define ALLOC(type, array, size) { \ - array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ - if (array == NULL) error("insufficient memory"); \ - } -# define FREE(array) {if (array != NULL) fcfree(array), array=NULL;} -#else -# define EXTERN(type, array) extern type array[] -# define DECLARE(type, array, size) type array[size] -# define ALLOC(type, array, size) -# define FREE(array) -#endif - -EXTERN(uch, inbuf); /* input buffer */ -EXTERN(uch, outbuf); /* output buffer */ -EXTERN(ush, d_buf); /* buffer for distances, see trees.c */ -EXTERN(uch, window); /* Sliding window and suffix table (unlzw) */ -#define tab_suffix window -#ifndef MAXSEG_64K -# define tab_prefix prev /* hash link (see deflate.c) */ -# define head (prev+WSIZE) /* hash head (see deflate.c) */ - EXTERN(ush, tab_prefix); /* prefix code (see unlzw.c) */ -#else -# define tab_prefix0 prev -# define head tab_prefix1 - EXTERN(ush, tab_prefix0); /* prefix for even codes */ - EXTERN(ush, tab_prefix1); /* prefix for odd codes */ -#endif - -extern unsigned insize; /* valid bytes in inbuf */ -extern unsigned inptr; /* index of next byte to be processed in inbuf */ -extern unsigned outcnt; /* bytes in output buffer */ - -extern long bytes_in; /* number of input bytes */ -extern long bytes_out; /* number of output bytes */ -extern long header_bytes;/* number of bytes in gzip header */ - -#define isize bytes_in -/* for compatibility with old zip sources (to be cleaned) */ - -extern int ifd; /* input file descriptor */ -extern int ofd; /* output file descriptor */ -extern char ifname[]; /* input file name or "stdin" */ -extern char ofname[]; /* output file name or "stdout" */ -extern char *progname; /* program name */ - -extern ulg time_stamp; /* original time stamp (modification time) */ -extern long ifile_size; /* input file size, -1 for devices (debug only) */ - -typedef int file_t; /* Do not use stdio */ -#define NO_FILE (-1) /* in memory compression */ - - -#define GZIP_MAGIC "\037\213" /* Magic header for gzip files, 1F 8B */ -#define OLD_GZIP_MAGIC "\037\236" /* Magic header for gzip 0.5 = freeze 1.x */ -#define PKZIP_MAGIC "\120\113\003\004" /* Magic header for pkzip files */ -#define PACK_MAGIC "\037\036" /* Magic header for packed files */ - -/* gzip flag byte */ -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ -#define RESERVED 0xC0 /* bit 6,7: reserved */ - -/* internal file attribute */ -#define UNKNOWN 0xffff -#define BINARY 0 -#define ASCII 1 - -#ifndef WSIZE -# define WSIZE 0x8000 /* window size--must be a power of two, and */ -#endif /* at least 32K for zip's deflate method */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST (WSIZE-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - -extern int decrypt; /* flag to turn on decryption */ -extern int exit_code; /* program exit code */ -extern int verbose; /* be verbose (-v) */ -extern int quiet; /* be quiet (-q) */ -extern int level; /* compression level */ -extern int test; /* check .z file integrity */ -extern int to_stdout; /* output to stdout (-c) */ -extern int save_orig_name; /* set if original name must be saved */ - -#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) - -/* put_byte is used for the compressed output, put_ubyte for the - * uncompressed output. However unlzw() uses window for its - * suffix table instead of its output buffer, so it does not use put_ubyte - * (to be cleaned up). - */ -#define put_byte(c) {outbuf[outcnt++]=(uch)(c); if (outcnt==OUTBUFSIZ)\ - flush_outbuf();} -#define put_ubyte(c) {window[outcnt++]=(uch)(c); if (outcnt==WSIZE)\ - flush_window();} - -/* Output a 16 bit value, lsb first */ -#define put_short(w) \ -{ if (outcnt < OUTBUFSIZ-2) { \ - outbuf[outcnt++] = (uch) ((w) & 0xff); \ - outbuf[outcnt++] = (uch) ((ush)(w) >> 8); \ - } else { \ - put_byte((uch)((w) & 0xff)); \ - put_byte((uch)((ush)(w) >> 8)); \ - } \ -} - -/* Output a 32 bit value to the bit stream, lsb first */ -#define put_long(n) { \ - put_short((n) & 0xffff); \ - put_short(((ulg)(n)) >> 16); \ -} - -#define seekable() 0 /* force sequential output */ -#define translate_eol 0 /* no option -a yet */ - -#define tolow(c) (isupper(c) ? (c)-'A'+'a' : (c)) /* force to lower case */ - -/* Macros for getting two-byte and four-byte header values */ -#define SH(p) ((ush)(uch)((p)[0]) | ((ush)(uch)((p)[1]) << 8)) -#define LG(p) ((ulg)(SH(p)) | ((ulg)(SH((p)+2)) << 16)) - -/* Diagnostic functions */ -#ifdef DEBUG -# define Assert(cond,msg) {if(!(cond)) error(msg);} -# define Trace(x) fprintf x -# define Tracev(x) {if (verbose) fprintf x ;} -# define Tracevv(x) {if (verbose>1) fprintf x ;} -# define Tracec(c,x) {if (verbose && (c)) fprintf x ;} -# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - -#define WARN(msg) {if (!quiet) fprintf msg ; \ - if (exit_code == OK) exit_code = WARNING;} - - /* in zip.c: */ -extern int zip OF((int in, int out)); -extern int file_read OF((char *buf, unsigned size)); - - /* in unzip.c */ -extern int unzip OF((int in, int out)); -extern int check_zipfile OF((int in)); - - /* in unpack.c */ -extern int unpack OF((int in, int out)); - - /* in gzip.c */ -RETSIGTYPE abort_gzip OF((void)); - - /* in deflate.c */ -void lm_init OF((int pack_level, ush *flags)); -ulg deflate OF((void)); - - /* in trees.c */ -void ct_init OF((ush *attr, int *method)); -int ct_tally OF((int dist, int lc)); -ulg flush_block OF((char *buf, ulg stored_len, int eof)); - - /* in bits.c */ -void bi_init OF((file_t zipfile)); -void send_bits OF((int value, int length)); -unsigned bi_reverse OF((unsigned value, int length)); -void bi_windup OF((void)); -void copy_block OF((char *buf, unsigned len, int header)); -extern int (*read_buf) OF((char *buf, unsigned size)); - - /* in util.c: */ -extern ulg updcrc OF((uch *s, unsigned n)); -extern void clear_bufs OF((void)); -extern int fill_inbuf OF((void)); -extern void flush_outbuf OF((void)); -extern void flush_window OF((void)); -extern void write_buf OF((int fd, voidp buf, unsigned cnt)); -extern char *strlwr OF((char *s)); -extern char *basename OF((char *fname)); -extern char *add_envopt OF((int *argcp, char ***argvp, char *env)); -extern void error OF((char *m)); -extern void warn OF((char *a, char *b)); -extern void read_error OF((void)); -extern void write_error OF((void)); -extern void display_ratio OF((long num, long den)); -extern voidp xmalloc OF((unsigned int size)); - - /* in inflate.c */ -extern int inflate OF((void)); diff --git a/gnu/usr.bin/gzip-1.1.1/inflate.c b/gnu/usr.bin/gzip-1.1.1/inflate.c deleted file mode 100644 index 3d16458aba90..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/inflate.c +++ /dev/null @@ -1,954 +0,0 @@ -/* inflate.c -- Not copyrighted 1992 by Mark Adler - version c10p1, 10 January 1993 */ - -/* You can do whatever you like with this source file, though I would - prefer that if you modify it and redistribute it that you include - comments to that effect with your name and the date. Thank you. - [The history has been moved to the file ChangeLog.] - */ - -/* - Inflate deflated (PKZIP's method 8 compressed) data. The compression - method searches for as much of the current string of bytes (up to a - length of 258) in the previous 32K bytes. If it doesn't find any - matches (of at least length 3), it codes the next byte. Otherwise, it - codes the length of the matched string and its distance backwards from - the current position. There is a single Huffman code that codes both - single bytes (called "literals") and match lengths. A second Huffman - code codes the distance information, which follows a length code. Each - length or distance code actually represents a base value and a number - of "extra" (sometimes zero) bits to get to add to the base value. At - the end of each deflated block is a special end-of-block (EOB) literal/ - length code. The decoding process is basically: get a literal/length - code; if EOB then done; if a literal, emit the decoded byte; if a - length then get the distance and emit the referred-to bytes from the - sliding window of previously emitted data. - - There are (currently) three kinds of inflate blocks: stored, fixed, and - dynamic. The compressor deals with some chunk of data at a time, and - decides which method to use on a chunk-by-chunk basis. A chunk might - typically be 32K or 64K. If the chunk is uncompressible, then the - "stored" method is used. In this case, the bytes are simply stored as - is, eight bits per byte, with none of the above coding. The bytes are - preceded by a count, since there is no longer an EOB code. - - If the data is compressible, then either the fixed or dynamic methods - are used. In the dynamic method, the compressed data is preceded by - an encoding of the literal/length and distance Huffman codes that are - to be used to decode this block. The representation is itself Huffman - coded, and so is preceded by a description of that code. These code - descriptions take up a little space, and so for small blocks, there is - a predefined set of codes, called the fixed codes. The fixed method is - used if the block codes up smaller that way (usually for quite small - chunks), otherwise the dynamic method is used. In the latter case, the - codes are customized to the probabilities in the current block, and so - can code it much better than the pre-determined fixed codes. - - The Huffman codes themselves are decoded using a mutli-level table - lookup, in order to maximize the speed of decoding plus the speed of - building the decoding tables. See the comments below that precede the - lbits and dbits tuning parameters. - */ - - -/* - Notes beyond the 1.93a appnote.txt: - - 1. Distance pointers never point before the beginning of the output - stream. - 2. Distance pointers can point back across blocks, up to 32k away. - 3. There is an implied maximum of 7 bits for the bit length table and - 15 bits for the actual data. - 4. If only one code exists, then it is encoded using one bit. (Zero - would be more efficient, but perhaps a little confusing.) If two - codes exist, they are coded using one bit each (0 and 1). - 5. There is no way of sending zero distance codes--a dummy must be - sent if there are none. (History: a pre 2.0 version of PKZIP would - store blocks with no distance codes, but this was discovered to be - too harsh a criterion.) Valid only for 1.93a. 2.04c does allow - zero distance codes, which is sent as one code of zero bits in - length. - 6. There are up to 286 literal/length codes. Code 256 represents the - end-of-block. Note however that the static length tree defines - 288 codes just to fill out the Huffman codes. Codes 286 and 287 - cannot be used though, since there is no length base or extra bits - defined for them. Similarly, there are up to 30 distance codes. - However, static trees define 32 codes (all 5 bits) to fill out the - Huffman codes, but the last two had better not show up in the data. - 7. Unzip can check dynamic Huffman blocks for complete code sets. - The exception is that a single code would not be complete (see #4). - 8. The five bits following the block type is really the number of - literal codes sent minus 257. - 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits - (1+6+6). Therefore, to output three times the length, you output - three codes (1+1+1), whereas to output four times the same length, - you only need two codes (1+3). Hmm. - 10. In the tree reconstruction algorithm, Code = Code + Increment - only if BitLength(i) is not zero. (Pretty obvious.) - 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) - 12. Note: length code 284 can represent 227-258, but length code 285 - really is 258. The last length deserves its own, short code - since it gets used a lot in very redundant files. The length - 258 is special since 258 - 3 (the min match length) is 255. - 13. The literal/length and distance code bit lengths are read as a - single stream of lengths. It is possible (and advantageous) for - a repeat code (16, 17, or 18) to go across the boundary between - the two sets of lengths. - */ - -#ifndef lint -static char rcsid[] = "$Id: inflate.c,v 1.1 1993/06/29 14:49:39 brezak Exp $"; -#endif - -#include -#include - -#include "tailor.h" - -#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H) -# include -#endif - -#include "gzip.h" -#define slide window - -/* Huffman code lookup table entry--this entry is four bytes for machines - that have 16-bit pointers (e.g. PC's in the small or medium model). - Valid extra bits are 0..13. e == 15 is EOB (end of block), e == 16 - means that v is a literal, 16 < e < 32 means that v is a pointer to - the next table, which codes e - 16 bits, and lastly e == 99 indicates - an unused code. If a code with e == 99 is looked up, this implies an - error in the data. */ -struct huft { - uch e; /* number of extra bits or operation */ - uch b; /* number of bits in this code or subcode */ - union { - ush n; /* literal, length base, or distance base */ - struct huft *t; /* pointer to next level of table */ - } v; -}; - - -/* Function prototypes */ -int huft_build OF((unsigned *, unsigned, unsigned, ush *, ush *, - struct huft **, int *)); -int huft_free OF((struct huft *)); -int inflate_codes OF((struct huft *, struct huft *, int, int)); -int inflate_stored OF((void)); -int inflate_fixed OF((void)); -int inflate_dynamic OF((void)); -int inflate_block OF((int *)); -int inflate OF((void)); - - -/* The inflate algorithm uses a sliding 32K byte window on the uncompressed - stream to find repeated byte strings. This is implemented here as a - circular buffer. The index is updated simply by incrementing and then - and'ing with 0x7fff (32K-1). */ -/* It is left to other modules to supply the 32K area. It is assumed - to be usable as if it were declared "uch slide[32768];" or as just - "uch *slide;" and then malloc'ed in the latter case. The definition - must be in unzip.h, included above. */ -/* unsigned wp; current position in slide */ -#define wp outcnt -#define flush_output(w) (wp=(w),flush_window()) - -/* Tables for deflate from PKZIP's appnote.txt. */ -static unsigned border[] = { /* Order of the bit length code lengths */ - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; -static ush cplens[] = { /* Copy lengths for literal codes 257..285 */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - /* note: see note #13 above about the 258 in this list. */ -static ush cplext[] = { /* Extra bits for literal codes 257..285 */ - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */ -static ush cpdist[] = { /* Copy offsets for distance codes 0..29 */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577}; -static ush cpdext[] = { /* Extra bits for distance codes */ - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, - 12, 12, 13, 13}; - - - -/* Macros for inflate() bit peeking and grabbing. - The usage is: - - NEEDBITS(j) - x = b & mask_bits[j]; - DUMPBITS(j) - - where NEEDBITS makes sure that b has at least j bits in it, and - DUMPBITS removes the bits from b. The macros use the variable k - for the number of bits in b. Normally, b and k are register - variables for speed, and are initialized at the beginning of a - routine that uses these macros from a global bit buffer and count. - - If we assume that EOB will be the longest code, then we will never - ask for bits with NEEDBITS that are beyond the end of the stream. - So, NEEDBITS should not read any more bytes than are needed to - meet the request. Then no bytes need to be "returned" to the buffer - at the end of the last block. - - However, this assumption is not true for fixed blocks--the EOB code - is 7 bits, but the other literal/length codes can be 8 or 9 bits. - (The EOB code is shorter than other codes because fixed blocks are - generally short. So, while a block always has an EOB, many other - literal/length codes have a significantly lower probability of - showing up at all.) However, by making the first table have a - lookup of seven bits, the EOB code will be found in that first - lookup, and so will not require that too many bits be pulled from - the stream. - */ - -ulg bb; /* bit buffer */ -unsigned bk; /* bits in bit buffer */ - -ush mask_bits[] = { - 0x0000, - 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff -}; - -#ifdef CRYPT - uch cc; -# define NEXTBYTE() \ - (decrypt ? (cc = get_byte(), zdecode(cc), cc) : get_byte()) -#else -# define NEXTBYTE() (uch)get_byte() -#endif -#define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE())<>=(n);k-=(n);} - - -/* - Huffman code decoding is performed using a multi-level table lookup. - The fastest way to decode is to simply build a lookup table whose - size is determined by the longest code. However, the time it takes - to build this table can also be a factor if the data being decoded - is not very long. The most common codes are necessarily the - shortest codes, so those codes dominate the decoding time, and hence - the speed. The idea is you can have a shorter table that decodes the - shorter, more probable codes, and then point to subsidiary tables for - the longer codes. The time it costs to decode the longer codes is - then traded against the time it takes to make longer tables. - - This results of this trade are in the variables lbits and dbits - below. lbits is the number of bits the first level table for literal/ - length codes can decode in one step, and dbits is the same thing for - the distance codes. Subsequent tables are also less than or equal to - those sizes. These values may be adjusted either when all of the - codes are shorter than that, in which case the longest code length in - bits is used, or when the shortest code is *longer* than the requested - table size, in which case the length of the shortest code in bits is - used. - - There are two different values for the two tables, since they code a - different number of possibilities each. The literal/length table - codes 286 possible values, or in a flat code, a little over eight - bits. The distance table codes 30 possible values, or a little less - than five bits, flat. The optimum values for speed end up being - about one bit more than those, so lbits is 8+1 and dbits is 5+1. - The optimum values may differ though from machine to machine, and - possibly even between compilers. Your mileage may vary. - */ - - -int lbits = 9; /* bits in base literal/length lookup table */ -int dbits = 6; /* bits in base distance lookup table */ - - -/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */ -#define BMAX 16 /* maximum bit length of any code (16 for explode) */ -#define N_MAX 288 /* maximum number of codes in any set */ - - -unsigned hufts; /* track memory usage */ - - -int huft_build(b, n, s, d, e, t, m) -unsigned *b; /* code lengths in bits (all assumed <= BMAX) */ -unsigned n; /* number of codes (assumed <= N_MAX) */ -unsigned s; /* number of simple-valued codes (0..s-1) */ -ush *d; /* list of base values for non-simple codes */ -ush *e; /* list of extra bits for non-simple codes */ -struct huft **t; /* result: starting table */ -int *m; /* maximum lookup bits, returns actual */ -/* Given a list of code lengths and a maximum table size, make a set of - tables to decode that set of codes. Return zero on success, one if - the given code set is incomplete (the tables are still built in this - case), two if the input is invalid (all zero length codes or an - oversubscribed set of lengths), and three if not enough memory. */ -{ - unsigned a; /* counter for codes of length k */ - unsigned c[BMAX+1]; /* bit length count table */ - unsigned f; /* i repeats in table every f entries */ - int g; /* maximum code length */ - int h; /* table level */ - register unsigned i; /* counter, current code */ - register unsigned j; /* counter */ - register int k; /* number of bits in current code */ - int l; /* bits per table (returned in m) */ - register unsigned *p; /* pointer into c[], b[], or v[] */ - register struct huft *q; /* points to current table */ - struct huft r; /* table entry for structure assignment */ - struct huft *u[BMAX]; /* table stack */ - unsigned v[N_MAX]; /* values in order of bit length */ - register int w; /* bits before this table == (l * h) */ - unsigned x[BMAX+1]; /* bit offsets, then code stack */ - unsigned *xp; /* pointer into x */ - int y; /* number of dummy codes added */ - unsigned z; /* number of entries in current table */ - - - /* Generate counts for each bit length */ - memzero(c, sizeof(c)); - p = b; i = n; - do { - Tracecv(*p, (stderr, (n-i >= ' ' && n-i <= '~' ? "%c %d\n" : "0x%x %d\n"), - n-i, *p)); - c[*p++]++; /* assume all entries <= BMAX */ - } while (--i); - if (c[0] == n) /* null input--all zero length codes */ - { - *t = (struct huft *)NULL; - *m = 0; - return 0; - } - - - /* Find minimum and maximum length, bound *m by those */ - l = *m; - for (j = 1; j <= BMAX; j++) - if (c[j]) - break; - k = j; /* minimum code length */ - if ((unsigned)l < j) - l = j; - for (i = BMAX; i; i--) - if (c[i]) - break; - g = i; /* maximum code length */ - if ((unsigned)l > i) - l = i; - *m = l; - - - /* Adjust last length count to fill out codes, if needed */ - for (y = 1 << j; j < i; j++, y <<= 1) - if ((y -= c[j]) < 0) - return 2; /* bad input: more codes than bits */ - if ((y -= c[i]) < 0) - return 2; - c[i] += y; - - - /* Generate starting offsets into the value table for each length */ - x[1] = j = 0; - p = c + 1; xp = x + 2; - while (--i) { /* note that i == g from above */ - *xp++ = (j += *p++); - } - - - /* Make a table of values in order of bit lengths */ - p = b; i = 0; - do { - if ((j = *p++) != 0) - v[x[j]++] = i; - } while (++i < n); - - - /* Generate the Huffman codes and for each, make the table entries */ - x[0] = i = 0; /* first Huffman code is zero */ - p = v; /* grab values in bit order */ - h = -1; /* no tables yet--level -1 */ - w = -l; /* bits decoded == (l * h) */ - u[0] = (struct huft *)NULL; /* just to keep compilers happy */ - q = (struct huft *)NULL; /* ditto */ - z = 0; /* ditto */ - - /* go through the bit lengths (k already is bits in shortest code) */ - for (; k <= g; k++) - { - a = c[k]; - while (a--) - { - /* here i is the Huffman code of length k bits for value *p */ - /* make tables up to required level */ - while (k > w + l) - { - h++; - w += l; /* previous table always l bits */ - - /* compute minimum size table less than or equal to l bits */ - z = (z = g - w) > (unsigned)l ? l : z; /* upper limit on table size */ - if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ - { /* too few codes for k-w bit table */ - f -= a + 1; /* deduct codes from patterns left */ - xp = c + k; - while (++j < z) /* try smaller tables up to z bits */ - { - if ((f <<= 1) <= *++xp) - break; /* enough codes to use up j bits */ - f -= *xp; /* else deduct codes from patterns */ - } - } - z = 1 << j; /* table entries for j-bit table */ - - /* allocate and link in new table */ - if ((q = (struct huft *)malloc((z + 1)*sizeof(struct huft))) == - (struct huft *)NULL) - { - if (h) - huft_free(u[0]); - return 3; /* not enough memory */ - } - hufts += z + 1; /* track memory usage */ - *t = q + 1; /* link to list for huft_free() */ - *(t = &(q->v.t)) = (struct huft *)NULL; - u[h] = ++q; /* table starts after link */ - - /* connect to last table, if there is one */ - if (h) - { - x[h] = i; /* save pattern for backing up */ - r.b = (uch)l; /* bits to dump before this table */ - r.e = (uch)(16 + j); /* bits in this table */ - r.v.t = q; /* pointer to this table */ - j = i >> (w - l); /* (get around Turbo C bug) */ - u[h-1][j] = r; /* connect to last table */ - } - } - - /* set up table entry in r */ - r.b = (uch)(k - w); - if (p >= v + n) - r.e = 99; /* out of values--invalid code */ - else if (*p < s) - { - r.e = (uch)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */ - r.v.n = (ush)(*p); /* simple code is just the value */ - p++; /* one compiler does not like *p++ */ - } - else - { - r.e = (uch)e[*p - s]; /* non-simple--look up in lists */ - r.v.n = d[*p++ - s]; - } - - /* fill code-like entries with r */ - f = 1 << (k - w); - for (j = i >> w; j < z; j += f) - q[j] = r; - - /* backwards increment the k-bit code i */ - for (j = 1 << (k - 1); i & j; j >>= 1) - i ^= j; - i ^= j; - - /* backup over finished tables */ - while ((i & ((1 << w) - 1)) != x[h]) - { - h--; /* don't need to update q */ - w -= l; - } - } - } - - - /* Return true (1) if we were given an incomplete table */ - return y != 0 && g != 1; -} - - - -int huft_free(t) -struct huft *t; /* table to free */ -/* Free the malloc'ed tables built by huft_build(), which makes a linked - list of the tables it made, with the links in a dummy first entry of - each table. */ -{ - register struct huft *p, *q; - - - /* Go through linked list, freeing from the malloced (t[-1]) address. */ - p = t; - while (p != (struct huft *)NULL) - { - q = (--p)->v.t; - free((char*)p); - p = q; - } - return 0; -} - - -int inflate_codes(tl, td, bl, bd) -struct huft *tl, *td; /* literal/length and distance decoder tables */ -int bl, bd; /* number of bits decoded by tl[] and td[] */ -/* inflate (decompress) the codes in a deflated (compressed) block. - Return an error code or zero if it all goes ok. */ -{ - register unsigned e; /* table entry flag/number of extra bits */ - unsigned n, d; /* length and index for copy */ - unsigned w; /* current window position */ - struct huft *t; /* pointer to table entry */ - unsigned ml, md; /* masks for bl and bd bits */ - register ulg b; /* bit buffer */ - register unsigned k; /* number of bits in bit buffer */ - - - /* make local copies of globals */ - b = bb; /* initialize bit buffer */ - k = bk; - w = wp; /* initialize window position */ - - /* inflate the coded data */ - ml = mask_bits[bl]; /* precompute masks for speed */ - md = mask_bits[bd]; - for (;;) /* do until end of block */ - { - NEEDBITS((unsigned)bl) - if ((e = (t = tl + ((unsigned)b & ml))->e) > 16) - do { - if (e == 99) - return 1; - DUMPBITS(t->b) - e -= 16; - NEEDBITS(e) - } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16); - DUMPBITS(t->b) - if (e == 16) /* then it's a literal */ - { - slide[w++] = (uch)t->v.n; - Tracevv((stderr, "%c", slide[w-1])); - if (w == WSIZE) - { - flush_output(w); - w = 0; - } - } - else /* it's an EOB or a length */ - { - /* exit if end of block */ - if (e == 15) - break; - - /* get length of block to copy */ - NEEDBITS(e) - n = t->v.n + ((unsigned)b & mask_bits[e]); - DUMPBITS(e); - - /* decode distance of block to copy */ - NEEDBITS((unsigned)bd) - if ((e = (t = td + ((unsigned)b & md))->e) > 16) - do { - if (e == 99) - return 1; - DUMPBITS(t->b) - e -= 16; - NEEDBITS(e) - } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16); - DUMPBITS(t->b) - NEEDBITS(e) - d = w - t->v.n - ((unsigned)b & mask_bits[e]); - DUMPBITS(e) - Tracevv((stderr,"\\[%d,%d]", w-d, n)); - - /* do the copy */ - do { - n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e); -#if !defined(NOMEMCPY) && !defined(DEBUG) - if (w - d >= e) /* (this test assumes unsigned comparison) */ - { - memcpy(slide + w, slide + d, e); - w += e; - d += e; - } - else /* do it slow to avoid memcpy() overlap */ -#endif /* !NOMEMCPY */ - do { - slide[w++] = slide[d++]; - Tracevv((stderr, "%c", slide[w-1])); - } while (--e); - if (w == WSIZE) - { - flush_output(w); - w = 0; - } - } while (n); - } - } - - - /* restore the globals from the locals */ - wp = w; /* restore global window pointer */ - bb = b; /* restore global bit buffer */ - bk = k; - - /* done */ - return 0; -} - - - -int inflate_stored() -/* "decompress" an inflated type 0 (stored) block. */ -{ - unsigned n; /* number of bytes in block */ - unsigned w; /* current window position */ - register ulg b; /* bit buffer */ - register unsigned k; /* number of bits in bit buffer */ - - - /* make local copies of globals */ - b = bb; /* initialize bit buffer */ - k = bk; - w = wp; /* initialize window position */ - - - /* go to byte boundary */ - n = k & 7; - DUMPBITS(n); - - - /* get the length and its complement */ - NEEDBITS(16) - n = ((unsigned)b & 0xffff); - DUMPBITS(16) - NEEDBITS(16) - if (n != (unsigned)((~b) & 0xffff)) - return 1; /* error in compressed data */ - DUMPBITS(16) - - - /* read and output the compressed data */ - while (n--) - { - NEEDBITS(8) - slide[w++] = (uch)b; - if (w == WSIZE) - { - flush_output(w); - w = 0; - } - DUMPBITS(8) - } - - - /* restore the globals from the locals */ - wp = w; /* restore global window pointer */ - bb = b; /* restore global bit buffer */ - bk = k; - return 0; -} - - - -int inflate_fixed() -/* decompress an inflated type 1 (fixed Huffman codes) block. We should - either replace this with a custom decoder, or at least precompute the - Huffman tables. */ -{ - int i; /* temporary variable */ - struct huft *tl; /* literal/length code table */ - struct huft *td; /* distance code table */ - int bl; /* lookup bits for tl */ - int bd; /* lookup bits for td */ - unsigned l[288]; /* length list for huft_build */ - - - /* set up literal table */ - for (i = 0; i < 144; i++) - l[i] = 8; - for (; i < 256; i++) - l[i] = 9; - for (; i < 280; i++) - l[i] = 7; - for (; i < 288; i++) /* make a complete, but wrong code set */ - l[i] = 8; - bl = 7; - if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0) - return i; - - - /* set up distance table */ - for (i = 0; i < 30; i++) /* make an incomplete code set */ - l[i] = 5; - bd = 5; - if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1) - { - huft_free(tl); - return i; - } - - - /* decompress until an end-of-block code */ - if (inflate_codes(tl, td, bl, bd)) - return 1; - - - /* free the decoding tables, return */ - huft_free(tl); - huft_free(td); - return 0; -} - - - -int inflate_dynamic() -/* decompress an inflated type 2 (dynamic Huffman codes) block. */ -{ - int i; /* temporary variables */ - unsigned j; - unsigned l; /* last length */ - unsigned m; /* mask for bit lengths table */ - unsigned n; /* number of lengths to get */ - struct huft *tl; /* literal/length code table */ - struct huft *td; /* distance code table */ - int bl; /* lookup bits for tl */ - int bd; /* lookup bits for td */ - unsigned nb; /* number of bit length codes */ - unsigned nl; /* number of literal/length codes */ - unsigned nd; /* number of distance codes */ -#ifdef PKZIP_BUG_WORKAROUND - unsigned ll[288+32]; /* literal/length and distance code lengths */ -#else - unsigned ll[286+30]; /* literal/length and distance code lengths */ -#endif - register ulg b; /* bit buffer */ - register unsigned k; /* number of bits in bit buffer */ - - - /* make local bit buffer */ - b = bb; - k = bk; - - - /* read in table lengths */ - NEEDBITS(5) - nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes */ - DUMPBITS(5) - NEEDBITS(5) - nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */ - DUMPBITS(5) - NEEDBITS(4) - nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */ - DUMPBITS(4) -#ifdef PKZIP_BUG_WORKAROUND - if (nl > 288 || nd > 32) -#else - if (nl > 286 || nd > 30) -#endif - return 1; /* bad lengths */ - - - /* read in bit-length-code lengths */ - for (j = 0; j < nb; j++) - { - NEEDBITS(3) - ll[border[j]] = (unsigned)b & 7; - DUMPBITS(3) - } - for (; j < 19; j++) - ll[border[j]] = 0; - - - /* build decoding table for trees--single level, 7 bit lookup */ - bl = 7; - if ((i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl)) != 0) - { - if (i == 1) - huft_free(tl); - return i; /* incomplete code set */ - } - - - /* read in literal and distance code lengths */ - n = nl + nd; - m = mask_bits[bl]; - i = l = 0; - while ((unsigned)i < n) - { - NEEDBITS((unsigned)bl) - j = (td = tl + ((unsigned)b & m))->b; - DUMPBITS(j) - j = td->v.n; - if (j < 16) /* length of code in bits (0..15) */ - ll[i++] = l = j; /* save last length in l */ - else if (j == 16) /* repeat last length 3 to 6 times */ - { - NEEDBITS(2) - j = 3 + ((unsigned)b & 3); - DUMPBITS(2) - if ((unsigned)i + j > n) - return 1; - while (j--) - ll[i++] = l; - } - else if (j == 17) /* 3 to 10 zero length codes */ - { - NEEDBITS(3) - j = 3 + ((unsigned)b & 7); - DUMPBITS(3) - if ((unsigned)i + j > n) - return 1; - while (j--) - ll[i++] = 0; - l = 0; - } - else /* j == 18: 11 to 138 zero length codes */ - { - NEEDBITS(7) - j = 11 + ((unsigned)b & 0x7f); - DUMPBITS(7) - if ((unsigned)i + j > n) - return 1; - while (j--) - ll[i++] = 0; - l = 0; - } - } - - - /* free decoding table for trees */ - huft_free(tl); - - - /* restore the global bit buffer */ - bb = b; - bk = k; - - - /* build the decoding tables for literal/length and distance codes */ - bl = lbits; - if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) - { - if (i == 1) { - fprintf(stderr, " incomplete literal tree\n"); - huft_free(tl); - } - return i; /* incomplete code set */ - } - bd = dbits; - if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) - { - if (i == 1) { - fprintf(stderr, " incomplete distance tree\n"); -#ifdef PKZIP_BUG_WORKAROUND - i = 0; - } -#else - huft_free(td); - } - huft_free(tl); - return i; /* incomplete code set */ -#endif - } - - - /* decompress until an end-of-block code */ - if (inflate_codes(tl, td, bl, bd)) - return 1; - - - /* free the decoding tables, return */ - huft_free(tl); - huft_free(td); - return 0; -} - - - -int inflate_block(e) -int *e; /* last block flag */ -/* decompress an inflated block */ -{ - unsigned t; /* block type */ - register ulg b; /* bit buffer */ - register unsigned k; /* number of bits in bit buffer */ - - - /* make local bit buffer */ - b = bb; - k = bk; - - - /* read in last block bit */ - NEEDBITS(1) - *e = (int)b & 1; - DUMPBITS(1) - - - /* read in block type */ - NEEDBITS(2) - t = (unsigned)b & 3; - DUMPBITS(2) - - - /* restore the global bit buffer */ - bb = b; - bk = k; - - - /* inflate that block type */ - if (t == 2) - return inflate_dynamic(); - if (t == 0) - return inflate_stored(); - if (t == 1) - return inflate_fixed(); - - - /* bad block type */ - return 2; -} - - - -int inflate() -/* decompress an inflated entry */ -{ - int e; /* last block flag */ - int r; /* result code */ - unsigned h; /* maximum struct huft's malloc'ed */ - - - /* initialize window, bit buffer */ - wp = 0; - bk = 0; - bb = 0; - - - /* decompress until the last block */ - h = 0; - do { - hufts = 0; - if ((r = inflate_block(&e)) != 0) - return r; - if (hufts > h) - h = hufts; - } while (!e); - - /* Undo too much lookahead. The next read will be byte aligned so we - * can discard unused bits in the last meaningful byte. - */ - while (bk >= 8) { - bk -= 8; - inptr--; - } - - /* flush out slide */ - flush_output(wp); - - - /* return success */ -#ifdef DEBUG - fprintf(stderr, "<%u> ", h); -#endif /* DEBUG */ - return 0; -} diff --git a/gnu/usr.bin/gzip-1.1.1/lzw.c b/gnu/usr.bin/gzip-1.1.1/lzw.c deleted file mode 100644 index 5beac0fb1023..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/lzw.c +++ /dev/null @@ -1,27 +0,0 @@ -/* lzw.c -- compress files in LZW format. - * This is a dummy version avoiding patent problems. - */ - -#ifndef lint -static char rcsid[] = "$Id: lzw.c,v 1.1 1993/06/29 14:49:41 brezak Exp $"; -#endif - -#include "tailor.h" -#include "gzip.h" -#include "lzw.h" - -#include - -static int msg_done = 0; - -/* Compress in to out with lzw method. */ -int lzw(in, out) - int in, out; -{ - if (msg_done) return ERROR; - msg_done = 1; - fprintf(stderr,"output in compress .Z format not supported\n"); - in++, out++; /* avoid warnings on unused variables */ - exit_code = ERROR; - return ERROR; -} diff --git a/gnu/usr.bin/gzip-1.1.1/lzw.h b/gnu/usr.bin/gzip-1.1.1/lzw.h deleted file mode 100644 index 4b7ac8680e17..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/lzw.h +++ /dev/null @@ -1,42 +0,0 @@ -/* lzw.h -- define the lzw functions. - * Copyright (C) 1992-1993 Jean-loup Gailly. - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#if !defined(OF) && defined(lint) -# include "gzip.h" -#endif - -#ifndef BITS -# define BITS 16 -#endif -#define INIT_BITS 9 /* Initial number of bits per code */ - -#define LZW_MAGIC "\037\235" /* Magic header for lzw files, 1F 9D */ - -#define BIT_MASK 0x1f /* Mask for 'number of compression bits' */ -/* Mask 0x20 is reserved to mean a fourth header byte, and 0x40 is free. - * It's a pity that old uncompress does not check bit 0x20. That makes - * extension of the format actually undesirable because old compress - * would just crash on the new format instead of giving a meaningful - * error message. It does check the number of bits, but it's more - * helpful to say "unsupported format, get a new version" than - * "can only handle 16 bits". - */ - -#define BLOCK_MODE 0x80 -/* Block compression: if table is full and compression rate is dropping, - * clear the dictionary. - */ - -#define LZW_RESERVED 0x60 /* reserved bits */ - -#define CLEAR 256 /* flush the dictionary */ -#define FIRST (CLEAR+1) /* first free entry */ - -extern int maxbits; /* max bits per code for LZW */ -extern int block_mode; /* block compress mode -C compatible with 2.0 */ - -extern int lzw OF((int in, int out)); -extern int unlzw OF((int in, int out)); diff --git a/gnu/usr.bin/gzip-1.1.1/match.S b/gnu/usr.bin/gzip-1.1.1/match.S deleted file mode 100644 index 96d845a61508..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/match.S +++ /dev/null @@ -1,379 +0,0 @@ -/* match.s -- optional optimized asm version of longest match in deflate.c - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - * - * The 68020 version has been written by Francesco Potorti` - * with adaptations by Carsten Steger , - * Andreas Schwab and - * Kristoffer Eriksson - */ - -/* $Id: match.S,v 1.1 1993/06/29 14:49:43 brezak Exp $ */ - -/* Preprocess with -DNO_UNDERLINE if your C compiler does not prefix - * external symbols with an underline character '_'. - */ -#ifdef NO_UNDERLINE -# define _prev prev -# define _window window -# define _match_start match_start -# define _prev_length prev_length -# define _good_match good_match -# define _nice_match nice_match -# define _strstart strstart -# define _max_chain_length max_chain_length - -# define _match_init match_init -# define _longest_match longest_match -#endif - -#ifdef DYN_ALLOC - error: DYN_ALLOC not yet supported in match.s -#endif - -#if defined(i386) || defined(_I386) - -/* This version is for 386 Unix or OS/2 in 32 bit mode. - * Warning: it uses the AT&T syntax: mov source,dest - * This file is only optional. If you want to force the C version, - * add -DNO_ASM to CFLAGS in Makefile and set OBJA to an empty string. - * If you have reduced WSIZE in gzip.h, then change its value below. - * This version assumes static allocation of the arrays (-DDYN_ALLOC not used). - */ - - .file "match.S" - -#define MAX_MATCH 258 -#define MAX_MATCH2 128 /* MAX_MATCH/2-1 */ -#define MIN_MATCH 3 -#define WSIZE 32768 -#define MAX_DIST WSIZE - MAX_MATCH - MIN_MATCH - 1 - - .globl _match_init - .globl _longest_match - - .text - -_match_init: - ret - -/*----------------------------------------------------------------------- - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - */ - -_longest_match: /* int longest_match(cur_match) */ - -#define cur_match 20(%esp) - /* return address */ /* esp+16 */ - push %ebp /* esp+12 */ - push %edi /* esp+8 */ - push %esi /* esp+4 */ - push %ebx /* esp */ - -/* - * match equ esi - * scan equ edi - * chain_length equ ebp - * best_len equ ebx - * limit equ edx - */ - mov cur_match,%esi - mov _max_chain_length,%ebp /* chain_length = max_chain_length */ - mov _strstart,%edi - mov %edi,%edx - sub $ MAX_DIST,%edx /* limit = strstart-MAX_DIST */ - jae limit_ok - sub %edx,%edx /* limit = NIL */ -limit_ok: - add $ _window+2,%edi /* edi = offset(window+strstart+2) */ - mov _prev_length,%ebx /* best_len = prev_length */ - movw -3(%ebx,%edi),%ax /* ax = scan[best_len-1..best_len] */ - movw -2(%edi),%cx /* cx = scan[0..1] */ - cmp _good_match,%ebx /* do we have a good match already? */ - jb do_scan - shr $2,%ebp /* chain_length >>= 2 */ - jmp do_scan - - .align 4 -long_loop: -/* at this point, edi == scan+2, esi == cur_match */ - movw -3(%ebx,%edi),%ax /* ax = scan[best_len-1..best_len] */ - movw -2(%edi),%cx /* cx = scan[0..1] */ -short_loop: -/* - * at this point, di == scan+2, si == cur_match, - * ax = scan[best_len-1..best_len] and cx = scan[0..1] - */ - and $ WSIZE-1, %esi - movw _prev(%esi,%esi),%si /* cur_match = prev[cur_match] */ - /* top word of esi is still 0 */ - cmp %edx,%esi /* cur_match <= limit ? */ - jbe the_end - dec %ebp /* --chain_length */ - jz the_end -do_scan: - cmpw _window-1(%ebx,%esi),%ax/* check match at best_len-1 */ - jne short_loop - cmpw _window(%esi),%cx /* check min_match_length match */ - jne short_loop - - lea _window+2(%esi),%esi /* si = match */ - mov %edi,%eax /* ax = scan+2 */ - mov $ MAX_MATCH2,%ecx /* scan for at most MAX_MATCH bytes */ - rep; cmpsw /* loop until mismatch */ - je maxmatch /* match of length MAX_MATCH? */ -mismatch: - movb -2(%edi),%cl /* mismatch on first or second byte? */ - subb -2(%esi),%cl /* cl = 0 if first bytes equal */ - xchg %edi,%eax /* edi = scan+2, eax = end of scan */ - sub %edi,%eax /* eax = len */ - sub %eax,%esi /* esi = cur_match + 2 + offset(window) */ - sub $ _window+2,%esi /* esi = cur_match */ - subb $1,%cl /* set carry if cl == 0 (cannot use DEC) */ - adc $0,%eax /* eax = carry ? len+1 : len */ - cmp %ebx,%eax /* len > best_len ? */ - jle long_loop - mov %esi,_match_start /* match_start = cur_match */ - mov %eax,%ebx /* ebx = best_len = len */ - cmp _nice_match,%eax /* len >= nice_match ? */ - jl long_loop -the_end: - mov %ebx,%eax /* result = eax = best_len */ - pop %ebx - pop %esi - pop %edi - pop %ebp - ret -maxmatch: - cmpsb - jmp mismatch - -#else - -/* ======================== 680x0 version ================================= */ - -#if defined(m68k)||defined(mc68k)||defined(__mc68000__)||defined(__MC68000__) -# ifndef mc68000 -# define mc68000 -# endif -#endif - -#if defined(__mc68020__) || defined(__MC68020__) || defined(sysV68) -# ifndef mc68020 -# define mc68020 -# endif -#endif - -#if defined(mc68020) || defined(mc68000) - -#if (defined(mc68020) || defined(NeXT)) && !defined(UNALIGNED_OK) -# define UNALIGNED_OK -#endif - -#ifdef sysV68 /* Try Motorola Delta style */ - -# define GLOBAL(symbol) global symbol -# define TEXT text -# define FILE(filename) file filename -# define invert_maybe(src,dst) dst,src -# define imm(data) &data -# define reg(register) %register - -# define addl add.l -# define addql addq.l -# define blos blo.b -# define bhis bhi.b -# define bras bra.b -# define clrl clr.l -# define cmpmb cmpm.b -# define cmpw cmp.w -# define cmpl cmp.l -# define lslw lsl.w -# define lsrl lsr.l -# define movel move.l -# define movew move.w -# define moveb move.b -# define moveml movem.l -# define subl sub.l -# define subw sub.w -# define subql subq.l - -# define IndBase(bd,An) (bd,An) -# define IndBaseNdxl(bd,An,Xn) (bd,An,Xn.l) -# define IndBaseNdxw(bd,An,Xn) (bd,An,Xn.w) -# define predec(An) -(An) -# define postinc(An) (An)+ - -#else /* default style (Sun 3, NeXT, Amiga, Atari) */ - -# define GLOBAL(symbol) .globl symbol -# define TEXT .text -# define FILE(filename) .even -# define invert_maybe(src,dst) src,dst -# if defined(sun) || defined(mc68k) -# define imm(data) #data -# else -# define imm(data) \#data -# endif -# define reg(register) register - -# define blos bcss -# if defined(sun) || defined(mc68k) -# define movel movl -# define movew movw -# define moveb movb -# endif -# define IndBase(bd,An) An@(bd) -# define IndBaseNdxl(bd,An,Xn) An@(bd,Xn:l) -# define IndBaseNdxw(bd,An,Xn) An@(bd,Xn:w) -# define predec(An) An@- -# define postinc(An) An@+ - -#endif /* styles */ - -#define Best_Len reg(d0) /* unsigned */ -#define Cur_Match reg(d1) /* Ipos */ -#define Loop_Counter reg(d2) /* int */ -#define Scan_Start reg(d3) /* unsigned short */ -#define Scan_End reg(d4) /* unsigned short */ -#define Limit reg(d5) /* IPos */ -#define Chain_Length reg(d6) /* unsigned */ -#define Scan_Test reg(d7) -#define Scan reg(a0) /* *uch */ -#define Match reg(a1) /* *uch */ -#define Prev_Address reg(a2) /* *Pos */ -#define Scan_Ini reg(a3) /* *uch */ -#define Match_Ini reg(a4) /* *uch */ -#define Stack_Pointer reg(sp) - -#define MAX_MATCH 258 -#define MIN_MATCH 3 -#define WSIZE 32768 -#define MAX_DIST (WSIZE - MAX_MATCH - MIN_MATCH - 1) - - GLOBAL (_match_init) - GLOBAL (_longest_match) - - TEXT - - FILE ("match.S") - -_match_init: - rts - -/*----------------------------------------------------------------------- - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - */ - -/* int longest_match (cur_match) */ - -#ifdef UNALIGNED_OK -# define pushreg 15928 /* d2-d6/a2-a4 */ -# define popreg 7292 -#else -# define pushreg 16184 /* d2-d7/a2-a4 */ -# define popreg 7420 -#endif - -_longest_match: - movel IndBase(4,Stack_Pointer),Cur_Match - moveml imm(pushreg),predec(Stack_Pointer) - movel _max_chain_length,Chain_Length - movel _prev_length,Best_Len - movel imm(_prev),Prev_Address - movel imm(_window+MIN_MATCH),Match_Ini - movel _strstart,Limit - movel Match_Ini,Scan_Ini - addl Limit,Scan_Ini - subw imm(MAX_DIST),Limit - bhis L__limit_ok - clrl Limit -L__limit_ok: - cmpl invert_maybe(_good_match,Best_Len) - blos L__length_ok - lsrl imm(2),Chain_Length -L__length_ok: - subql imm(1),Chain_Length -#ifdef UNALIGNED_OK - movew IndBase(-MIN_MATCH,Scan_Ini),Scan_Start - movew IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End -#else - moveb IndBase(-MIN_MATCH,Scan_Ini),Scan_Start - lslw imm(8),Scan_Start - moveb IndBase(-MIN_MATCH+1,Scan_Ini),Scan_Start - moveb IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End - lslw imm(8),Scan_End - moveb IndBaseNdxw(-MIN_MATCH,Scan_Ini,Best_Len),Scan_End -#endif - bras L__do_scan - -L__long_loop: -#ifdef UNALIGNED_OK - movew IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End -#else - moveb IndBaseNdxw(-MIN_MATCH-1,Scan_Ini,Best_Len),Scan_End - lslw imm(8),Scan_End - moveb IndBaseNdxw(-MIN_MATCH,Scan_Ini,Best_Len),Scan_End -#endif - -L__short_loop: - lslw imm(1),Cur_Match - movew IndBaseNdxl(0,Prev_Address,Cur_Match),Cur_Match - cmpw invert_maybe(Limit,Cur_Match) - dbls Chain_Length,L__do_scan - bras L__return - -L__do_scan: - movel Match_Ini,Match - addl Cur_Match,Match -#ifdef UNALIGNED_OK - cmpw invert_maybe(IndBaseNdxw(-MIN_MATCH-1,Match,Best_Len),Scan_End) - bne L__short_loop - cmpw invert_maybe(IndBase(-MIN_MATCH,Match),Scan_Start) - bne L__short_loop -#else - moveb IndBaseNdxw(-MIN_MATCH-1,Match,Best_Len),Scan_Test - lslw imm(8),Scan_Test - moveb IndBaseNdxw(-MIN_MATCH,Match,Best_Len),Scan_Test - cmpw invert_maybe(Scan_Test,Scan_End) - bne L__short_loop - moveb IndBase(-MIN_MATCH,Match),Scan_Test - lslw imm(8),Scan_Test - moveb IndBase(-MIN_MATCH+1,Match),Scan_Test - cmpw invert_maybe(Scan_Test,Scan_Start) - bne L__short_loop -#endif - - movew imm((MAX_MATCH-MIN_MATCH+1)-1),Loop_Counter - movel Scan_Ini,Scan -L__scan_loop: - cmpmb postinc(Match),postinc(Scan) - dbne Loop_Counter,L__scan_loop - - subl Scan_Ini,Scan - addql imm(MIN_MATCH-1),Scan - cmpl invert_maybe(Best_Len,Scan) - bls L__short_loop - movel Scan,Best_Len - movel Cur_Match,_match_start - cmpl invert_maybe(_nice_match,Best_Len) - blos L__long_loop -L__return: - moveml postinc(Stack_Pointer),imm(popreg) - rts - -#else - error: this asm version is for 386 or 680x0 only -#endif /* mc68000 || mc68020 */ -#endif /* i386 || _I386 */ diff --git a/gnu/usr.bin/gzip-1.1.1/revision.h b/gnu/usr.bin/gzip-1.1.1/revision.h deleted file mode 100644 index 2dc04db08903..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/revision.h +++ /dev/null @@ -1,16 +0,0 @@ -/* revision.h -- define the version number - * Copyright (C) 1992-1993 Jean-loup Gailly. - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#define VERSION "1.1.1" -#define PATCHLEVEL 0 -#define REVDATE "1 Jun 93" - -/* This version does not support compression into old compress format: */ -#ifdef LZW -# undef LZW -#endif - -/* $Id: revision.h,v 1.1 1993/06/29 14:49:44 brezak Exp $ */ diff --git a/gnu/usr.bin/gzip-1.1.1/tailor.h b/gnu/usr.bin/gzip-1.1.1/tailor.h deleted file mode 100644 index 96bee2c3fb93..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/tailor.h +++ /dev/null @@ -1,268 +0,0 @@ -/* tailor.h -- target dependent definitions - * Copyright (C) 1992-1993 Jean-loup Gailly. - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -/* The target dependent definitions should be defined here only. - * The target dependent functions should be defined in tailor.c. - */ - -/* $Id: tailor.h,v 1.1 1993/06/29 14:49:45 brezak Exp $ */ - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif - -#if defined(OS2) && defined(MSDOS) /* MS C under OS/2 */ -# undef MSDOS -#endif - -#ifdef MSDOS -# ifdef __GNUC__ - /* DJGPP version 1.09+ on MS-DOS. - * The DJGPP 1.09 stat() function must be upgraded before gzip will - * fully work. - * No need for DIRENT, since defines POSIX_SOURCE which - * implies DIRENT. - */ -# define near -# else -# define MAXSEG_64K -# ifdef __TURBOC__ -# define NO_UTIME -# else /* MSC */ -# define HAVE_SYS_UTIME_H -# define NO_UTIME_H -# endif -# endif -# define PATH_SEP2 '\\' -# define PATH_SEP3 ':' -# define MAX_PATH_LEN 128 -# define NO_MULTIPLE_DOTS -# define MAX_EXT_CHARS 3 -# define Z_SUFFIX "z" -# define NO_CHOWN -# define PROTO -# define STDC_HEADERS -# define NO_SIZE_CHECK -# define casemap(c) tolow(c) /* Force file names to lower case */ -# include -# define OS_CODE 0x00 -# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY) -# if !defined(NO_ASM) && !defined(ASMV) -# define ASMV -# endif -#else -# define near -#endif - -#ifdef OS2 -# define PATH_SEP2 '\\' -# define PATH_SEP3 ':' -# define MAX_PATH_LEN 260 -# ifdef OS2FAT -# define NO_MULTIPLE_DOTS -# define MAX_EXT_CHARS 3 -# define Z_SUFFIX "z" -# endif -# define NO_CHOWN -# define PROTO -# define STDC_HEADERS -# define HAVE_SYS_UTIME_H -# define NO_UTIME_H -# define casemap(c) tolow(c) -# include -# define OS_CODE 0x06 -# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY) -# ifdef _MSC_VER -# define MAXSEG_64K -# undef near -# define near _near -# endif -# ifdef __EMX__ -# define DIRENT -# define EXPAND(argc,argv) \ - {_response(&argc, &argv); _wildcard(&argc, &argv);} -# endif -#endif - -#ifdef MSDOS -# ifdef __TURBOC__ -# include -# define DYN_ALLOC - /* Turbo C 2.0 does not accept static allocations of large arrays */ - void * fcalloc (unsigned items, unsigned size); - void fcfree (void *ptr); -# else /* MSC */ -# include -# define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize)) -# define fcfree(ptr) hfree(ptr) -# endif -#else -# ifdef MAXSEG_64K -# define fcalloc(items,size) calloc((items),(size)) -# else -# define fcalloc(items,size) malloc((size_t)(items)*(size_t)(size)) -# endif -# define fcfree(ptr) free(ptr) -#endif - -#if defined(VAXC) || defined(VMS) -# define PATH_SEP ']' -# define PATH_SEP2 ':' -# define SUFFIX_SEP ';' -# define NO_MULTIPLE_DOTS -# define Z_SUFFIX "-gz" -# define RECORD_IO 1 -# define casemap(c) tolow(c) -# define OS_CODE 0x02 -# define OPTIONS_VAR "GZIP_OPT" -# define STDC_HEADERS -# define NO_UTIME -# define EXPAND(argc,argv) vms_expand_args(&argc,&argv); -# include -# define unlink delete -# ifdef VAXC -# define NO_FCNTL_H -# include -# endif -#endif - -#ifdef AMIGA -# define PATH_SEP2 ':' -# define STDC_HEADERS -# define casemap(c) tolow(c) /* Force file names to lower case */ -# define OS_CODE 0x01 -# define ASMV -# ifdef __GNUC__ -# define DIRENT -# define HAVE_UNISTD_H -# define RETSIGTYPE int -# else /* SASC */ -# define NO_STDIN_FSTAT -# define SYSDIR -# define NO_SYMLINK -# define NO_CHOWN -# define NO_FCNTL_H -# include /* for read() and write() */ -# define direct dirent - extern void _expand_args(int *argc, char ***argv); -# define EXPAND(argc,argv) _expand_args(&argc,&argv); -# endif -#endif - -#if defined(ATARI) || defined(atarist) -# ifndef STDC_HEADERS -# define STDC_HEADERS -# define HAVE_UNISTD_H -# define DIRENT -# endif -# define ASMV -# define OS_CODE 0x05 -# ifdef TOSFS -# define NO_SYMLINK -# define NO_MULTIPLE_DOTS -# define MAX_EXT_CHARS 3 -# define Z_SUFFIX "z" -# define NO_CHOWN -# endif -#endif - -#ifdef MACOS -# define PATH_SEP ':' -# define DYN_ALLOC -# define PROTO -# define NO_STDIN_FSTAT -# define NO_CHOWN -# define NO_UTIME -# define chmod(file, mode) (0) -# define OPEN(name, flags, mode) open(name, flags) -# define OS_CODE 0x07 -# ifdef MPW -# define isatty(fd) ((fd) <= 2) -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define PATH_SEP '>' -# define STDC_HEADERS -# define NO_MEMORY_H -# define NO_UTIME_H -# define NO_UTIME -# define NO_CHOWN -# define NO_STDIN_FSTAT -# define NO_SIZE_CHECK -# define NO_SYMLINK -# define RECORD_IO 1 -# define casemap(c) tolow(c) /* Force file names to lower case */ -# define put_char(c) put_byte((c) & 0x7F) -# define get_char(c) ascii2pascii(get_byte()) -# define OS_CODE 0x0F /* temporary, subject to change */ -# undef SIGTERM /* We don't want a signal handler for SIGTERM */ -#endif - -#ifdef WIN32 -# define OS_CODE 0x0b -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifndef unix -# define NO_ST_INO /* don't rely on inode numbers */ -#endif - - - /* Common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef PATH_SEP -# define PATH_SEP '/' -#endif - -#ifndef casemap -# define casemap(c) (c) -#endif - -#ifndef OPTIONS_VAR -# define OPTIONS_VAR "GZIP" -#endif - -#ifndef Z_SUFFIX -# define Z_SUFFIX ".gz" -#endif - -#ifdef MAX_EXT_CHARS -# define MAX_SUFFIX MAX_EXT_CHARS -#else -# define MAX_SUFFIX 30 -#endif - -#ifndef EXPAND -# define EXPAND(argc,argv) -#endif - -#ifndef RECORD_IO -# define RECORD_IO 0 -#endif - -#ifndef SET_BINARY_MODE -# define SET_BINARY_MODE(fd) -#endif - -#ifndef OPEN -# define OPEN(name, flags, mode) open(name, flags, mode) -#endif - -#ifndef get_char -# define get_char() get_byte() -#endif - -#ifndef put_char -# define put_char(c) put_byte(c) -#endif diff --git a/gnu/usr.bin/gzip-1.1.1/trees.c b/gnu/usr.bin/gzip-1.1.1/trees.c deleted file mode 100644 index 9c1e48de9768..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/trees.c +++ /dev/null @@ -1,1076 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -/* - * PURPOSE - * - * Encode various sets of source values using variable-length - * binary code trees. - * - * DISCUSSION - * - * The PKZIP "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in the ZIP file in a compressed form - * which is itself a Huffman encoding of the lengths of - * all the code strings (in ascending order by source values). - * The actual code strings are reconstructed from the lengths in - * the UNZIP process, as described in the "application note" - * (APPNOTE.TXT) distributed as part of PKWARE's PKZIP program. - * - * REFERENCES - * - * Lynch, Thomas J. - * Data Compression: Techniques and Applications, pp. 53-55. - * Lifetime Learning Publications, 1985. ISBN 0-534-03418-7. - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - * - * INTERFACE - * - * void ct_init (ush *attr, int *methodp) - * Allocate the match buffer, initialize the various tables and save - * the location of the internal file attribute (ascii/binary) and - * method (DEFLATE/STORE) - * - * void ct_tally (int dist, int lc); - * Save the match info and tally the frequency counts. - * - * long flush_block (char *buf, ulg stored_len, int eof) - * Determine the best encoding for the current block: dynamic trees, - * static trees or store, and output the encoded block to the zip - * file. Returns the total compressed length for the file so far. - * - */ - -#include -#include - -#include "tailor.h" -#include "gzip.h" - -#ifndef lint -static char rcsid[] = "$Id: trees.c,v 1.1 1993/06/29 14:49:47 brezak Exp $"; -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - - -local int near extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local int near extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local int near extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#ifndef LIT_BUFSIZE -# ifdef SMALL_MEM -# define LIT_BUFSIZE 0x2000 -# else -# ifdef MEDIUM_MEM -# define LIT_BUFSIZE 0x4000 -# else -# define LIT_BUFSIZE 0x8000 -# endif -# endif -#endif -#ifndef DIST_BUFSIZE -# define DIST_BUFSIZE LIT_BUFSIZE -#endif -/* Sizes of match buffers for literals/lengths and distances. There are - * 4 reasons for limiting LIT_BUFSIZE to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input data is - * still in the window so we can still emit a stored block even when input - * comes from standard input. (This can also be done for all blocks if - * LIT_BUFSIZE is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting trees - * more frequently. - * - I can't count above 4 - * The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to save - * memory at the expense of compression). Some optimizations would be possible - * if we rely on DIST_BUFSIZE == LIT_BUFSIZE. - */ -#if LIT_BUFSIZE > INBUFSIZ - error cannot overlay l_buf and inbuf -#endif - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -/* =========================================================================== - * Local data - */ - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -local ct_data near dyn_ltree[HEAP_SIZE]; /* literal and length tree */ -local ct_data near dyn_dtree[2*D_CODES+1]; /* distance tree */ - -local ct_data near static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see ct_init - * below). - */ - -local ct_data near static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -local ct_data near bl_tree[2*BL_CODES+1]; -/* Huffman tree for the bit lengths */ - -typedef struct tree_desc { - ct_data near *dyn_tree; /* the dynamic tree */ - ct_data near *static_tree; /* corresponding static tree or NULL */ - int near *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ - int max_code; /* largest code with non zero frequency */ -} tree_desc; - -local tree_desc near l_desc = -{dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0}; - -local tree_desc near d_desc = -{dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0}; - -local tree_desc near bl_desc = -{bl_tree, (ct_data near *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0}; - - -local ush near bl_count[MAX_BITS+1]; -/* number of codes at each bit length for an optimal tree */ - -local uch near bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -local int near heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ -local int heap_len; /* number of elements in the heap */ -local int heap_max; /* element of largest frequency */ -/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - -local uch near depth[2*L_CODES+1]; -/* Depth of each subtree used as tie breaker for trees of equal frequency */ - -local uch length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local uch dist_code[512]; -/* distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -local int near base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int near base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -#define l_buf inbuf -/* DECLARE(uch, l_buf, LIT_BUFSIZE); buffer for literals or lengths */ - -/* DECLARE(ush, d_buf, DIST_BUFSIZE); buffer for distances */ - -local uch near flag_buf[(LIT_BUFSIZE/8)]; -/* flag_buf is a bit array distinguishing literals from lengths in - * l_buf, thus indicating the presence or absence of a distance. - */ - -local unsigned last_lit; /* running index in l_buf */ -local unsigned last_dist; /* running index in d_buf */ -local unsigned last_flags; /* running index in flag_buf */ -local uch flags; /* current flags not yet saved in flag_buf */ -local uch flag_bit; /* current bit used in flags */ -/* bits are filled in flags starting at bit 0 (least significant). - * Note: these flags are overkill in the current code since we don't - * take advantage of DIST_BUFSIZE == LIT_BUFSIZE. - */ - -local ulg opt_len; /* bit length of current block with optimal trees */ -local ulg static_len; /* bit length of current block with static trees */ - -local ulg compressed_len; /* total bit length of compressed file */ - -local ulg input_len; /* total byte length of input file */ -/* input_len is for debugging only since we can get it by other means. */ - -ush *file_type; /* pointer to UNKNOWN, BINARY or ASCII */ -int *file_method; /* pointer to DEFLATE or STORE */ - -#ifdef DEBUG -extern ulg bits_sent; /* bit length of the compressed data */ -extern long isize; /* byte length of input file */ -#endif - -extern long block_start; /* window offset of current block */ -extern unsigned near strstart; /* window offset of current string */ - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void init_block OF((void)); -local void pqdownheap OF((ct_data near *tree, int k)); -local void gen_bitlen OF((tree_desc near *desc)); -local void gen_codes OF((ct_data near *tree, int max_code)); -local void build_tree OF((tree_desc near *desc)); -local void scan_tree OF((ct_data near *tree, int max_code)); -local void send_tree OF((ct_data near *tree, int max_code)); -local int build_bl_tree OF((void)); -local void send_all_trees OF((int lcodes, int dcodes, int blcodes)); -local void compress_block OF((ct_data near *ltree, ct_data near *dtree)); -local void set_file_type OF((void)); - - -#ifndef DEBUG -# define send_code(c, tree) send_bits(tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* DEBUG */ -# define send_code(c, tree) \ - { if (verbose>1) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(tree[c].Code, tree[c].Len); } -#endif - -#define d_code(dist) \ - ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. dist_code[256] and dist_code[257] are never - * used. - */ - -#define MAX(a,b) (a >= b ? a : b) -/* the arguments must not have side effects */ - -/* =========================================================================== - * Allocate the match buffer, initialize the various tables and save the - * location of the internal file attribute (ascii/binary) and method - * (DEFLATE/STORE). - */ -void ct_init(attr, methodp) - ush *attr; /* pointer to internal file attribute */ - int *methodp; /* pointer to compression method */ -{ - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - - file_type = attr; - file_method = methodp; - compressed_len = input_len = 0L; - - if (static_dtree[0].Len != 0) return; /* ct_init already called */ - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "ct_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data near *)static_ltree, L_CODES+1); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse(n, 5); - } - - /* Initialize the first block of the first file: */ - init_block(); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block() -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) bl_tree[n].Freq = 0; - - dyn_ltree[END_BLOCK].Freq = 1; - opt_len = static_len = 0L; - last_lit = last_dist = last_flags = 0; - flags = 0; flag_bit = 1; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(tree, top) \ -{\ - top = heap[SMALLEST]; \ - heap[SMALLEST] = heap[heap_len--]; \ - pqdownheap(tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(tree, k) - ct_data near *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = heap[k]; - int j = k << 1; /* left son of k */ - while (j <= heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < heap_len && smaller(tree, heap[j+1], heap[j])) j++; - - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, heap[j])) break; - - /* Exchange v with the smallest son */ - heap[k] = heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(desc) - tree_desc near *desc; /* the tree descriptor */ -{ - ct_data near *tree = desc->dyn_tree; - int near *extra = desc->extra_bits; - int base = desc->extra_base; - int max_code = desc->max_code; - int max_length = desc->max_length; - ct_data near *stree = desc->static_tree; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[heap[heap_max]].Len = 0; /* root of the heap */ - - for (h = heap_max+1; h < HEAP_SIZE; h++) { - n = heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - opt_len += (ulg)f * (bits + xbits); - if (stree) static_len += (ulg)f * (stree[n].Len + xbits); - } - if (overflow == 0) return; - - Trace((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (bl_count[bits] == 0) bits--; - bl_count[bits]--; /* move one leaf down the tree */ - bl_count[bits+1] += 2; /* move one overflow item as its brother */ - bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = bl_count[bits]; - while (n != 0) { - m = heap[--h]; - if (m > max_code) continue; - if (tree[m].Len != (unsigned) bits) { - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - opt_len += ((long)bits-(long)tree[m].Len)*(long)tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code) - ct_data near *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; - ct_data near *stree = desc->static_tree; - int elems = desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node = elems; /* next internal node of the tree */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - heap_len = 0, heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - heap[++heap_len] = max_code = n; - depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (heap_len < 2) { - int new = heap[++heap_len] = (max_code < 2 ? ++max_code : 0); - tree[new].Freq = 1; - depth[new] = 0; - opt_len--; if (stree) static_len -= stree[new].Len; - /* new is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = heap_len/2; n >= 1; n--) pqdownheap(tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - do { - pqremove(tree, n); /* n = node of least frequency */ - m = heap[SMALLEST]; /* m = node of next least frequency */ - - heap[--heap_max] = n; /* keep the nodes sorted by frequency */ - heap[--heap_max] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - depth[node] = (uch) (MAX(depth[n], depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - heap[SMALLEST] = node++; - pqdownheap(tree, SMALLEST); - - } while (heap_len >= 2); - - heap[--heap_max] = heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen((tree_desc near *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data near *)tree, max_code); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. Updates opt_len to take into account the repeat - * counts. (The contribution of the bit length codes will be added later - * during the construction of bl_tree.) - */ -local void scan_tree (tree, max_code) - ct_data near *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) bl_tree[curlen].Freq++; - bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - bl_tree[REPZ_3_10].Freq++; - } else { - bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (tree, max_code) - ct_data near *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(curlen, bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(curlen, bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(REP_3_6, bl_tree); send_bits(count-3, 2); - - } else if (count <= 10) { - send_code(REPZ_3_10, bl_tree); send_bits(count-3, 3); - - } else { - send_code(REPZ_11_138, bl_tree); send_bits(count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree() -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree((ct_data near *)dyn_ltree, l_desc.max_code); - scan_tree((ct_data near *)dyn_dtree, d_desc.max_code); - - /* Build the bit length tree: */ - build_tree((tree_desc near *)(&bl_desc)); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - opt_len += 3*(max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", opt_len, static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(lcodes, dcodes, blcodes) - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(dcodes-1, 5); - send_bits(blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", bits_sent)); - - send_tree((ct_data near *)dyn_ltree, lcodes-1); /* send the literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", bits_sent)); - - send_tree((ct_data near *)dyn_dtree, dcodes-1); /* send the distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", bits_sent)); -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. This function - * returns the total compressed length for the file so far. - */ -ulg flush_block(buf, stored_len, eof) - char *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex; /* index of last bit length code of non zero freq */ - - flag_buf[last_flags] = flags; /* Save the flags for the last 8 items */ - - /* Check if the file is ascii or binary */ - if (*file_type == (ush)UNKNOWN) set_file_type(); - - /* Construct the literal and distance trees */ - build_tree((tree_desc near *)(&l_desc)); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", opt_len, static_len)); - - build_tree((tree_desc near *)(&d_desc)); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", opt_len, static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(); - - /* Determine the best encoding. Compute first the block length in bytes */ - opt_lenb = (opt_len+3+7)>>3; - static_lenb = (static_len+3+7)>>3; - input_len += stored_len; /* for debugging only */ - - Trace((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ", - opt_lenb, opt_len, static_lenb, static_len, stored_len, - last_lit, last_dist)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - /* If compression failed and this is the first and last block, - * and if the zip file can be seeked (to rewrite the local header), - * the whole file is transformed into a stored file: - */ -#ifdef FORCE_METHOD - if (level == 1 && eof && compressed_len == 0L) { /* force stored file */ -#else - if (stored_len <= opt_lenb && eof && compressed_len == 0L && seekable()) { -#endif - /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ - if (buf == (char*)0) error ("block vanished"); - - copy_block(buf, (unsigned)stored_len, 0); /* without header */ - compressed_len = stored_len << 3; - *file_method = STORED; - -#ifdef FORCE_METHOD - } else if (level == 2 && buf != (char*)0) { /* force stored block */ -#else - } else if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - send_bits((STORED_BLOCK<<1)+eof, 3); /* send block type */ - compressed_len = (compressed_len + 3 + 7) & ~7L; - compressed_len += (stored_len + 4) << 3; - - copy_block(buf, (unsigned)stored_len, 1); /* with header */ - -#ifdef FORCE_METHOD - } else if (level == 3) { /* force static trees */ -#else - } else if (static_lenb == opt_lenb) { -#endif - send_bits((STATIC_TREES<<1)+eof, 3); - compress_block((ct_data near *)static_ltree, (ct_data near *)static_dtree); - compressed_len += 3 + static_len; - } else { - send_bits((DYN_TREES<<1)+eof, 3); - send_all_trees(l_desc.max_code+1, d_desc.max_code+1, max_blindex+1); - compress_block((ct_data near *)dyn_ltree, (ct_data near *)dyn_dtree); - compressed_len += 3 + opt_len; - } - Assert (compressed_len == bits_sent, "bad compressed size"); - init_block(); - - if (eof) { - Assert (input_len == isize, "bad input size"); - bi_windup(); - compressed_len += 7; /* align on byte boundary */ - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", compressed_len>>3, - compressed_len-7*eof)); - - return compressed_len >> 3; -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int ct_tally (dist, lc) - int dist; /* distance of matched string */ - int lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - l_buf[last_lit++] = (uch)lc; - if (dist == 0) { - /* lc is the unmatched char */ - dyn_ltree[lc].Freq++; - } else { - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "ct_tally: bad match"); - - dyn_ltree[length_code[lc]+LITERALS+1].Freq++; - dyn_dtree[d_code(dist)].Freq++; - - d_buf[last_dist++] = (ush)dist; - flags |= flag_bit; - } - flag_bit <<= 1; - - /* Output the flags if they fill a byte: */ - if ((last_lit & 7) == 0) { - flag_buf[last_flags++] = flags; - flags = 0, flag_bit = 1; - } - /* Try to guess if it is profitable to stop the current block here */ - if (level > 2 && (last_lit & 0xfff) == 0) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)last_lit*8L; - ulg in_length = (ulg)strstart-block_start; - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)dyn_dtree[dcode].Freq*(5L+extra_dbits[dcode]); - } - out_length >>= 3; - Trace((stderr,"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ", - last_lit, last_dist, in_length, out_length, - 100L - out_length*100L/in_length)); - if (last_dist < last_lit/2 && out_length < in_length/2) return 1; - } - return (last_lit == LIT_BUFSIZE-1 || last_dist == DIST_BUFSIZE); - /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(ltree, dtree) - ct_data near *ltree; /* literal tree */ - ct_data near *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned dx = 0; /* running index in d_buf */ - unsigned fx = 0; /* running index in flag_buf */ - uch flag = 0; /* current flags */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (last_lit != 0) do { - if ((lx & 7) == 0) flag = flag_buf[fx++]; - lc = l_buf[lx++]; - if ((flag & 1) == 0) { - send_code(lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = length_code[lc]; - send_code(code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(lc, extra); /* send the extra length bits */ - } - dist = d_buf[dx++]; - /* Here, dist is the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - send_bits(dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - flag >>= 1; - } while (lx < last_lit); - - send_code(END_BLOCK, ltree); -} - -/* =========================================================================== - * Set the file type to ASCII or BINARY, using a crude approximation: - * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. - * IN assertion: the fields freq of dyn_ltree are set and the total of all - * frequencies does not exceed 64K (to fit in an int on 16 bit machines). - */ -local void set_file_type() -{ - int n = 0; - unsigned ascii_freq = 0; - unsigned bin_freq = 0; - while (n < 7) bin_freq += dyn_ltree[n++].Freq; - while (n < 128) ascii_freq += dyn_ltree[n++].Freq; - while (n < LITERALS) bin_freq += dyn_ltree[n++].Freq; - *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; - if (*file_type == BINARY && translate_eol) { - warn("-l used on binary file", ""); - } -} diff --git a/gnu/usr.bin/gzip-1.1.1/unlzw.c b/gnu/usr.bin/gzip-1.1.1/unlzw.c deleted file mode 100644 index 81230933790f..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/unlzw.c +++ /dev/null @@ -1,369 +0,0 @@ -/* unlzw.c -- decompress files in LZW format. - * The code in this file is directly derived from the public domain 'compress' - * written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies, - * Ken Turkowski, Dave Mack and Peter Jannesen. - * - * This is a temporary version which will be rewritten in some future version - * to accommodate in-memory decompression. - */ - -#ifndef lint -static char rcsid[] = "$Id: unlzw.c,v 1.1 1993/06/29 14:49:48 brezak Exp $"; -#endif - -#include -#include - -#include "tailor.h" - -#ifdef HAVE_UNISTD_H -# include -#endif -#ifndef NO_FCNTL_H -# include -#endif - -#include "gzip.h" -#include "lzw.h" - -typedef unsigned char char_type; -typedef long code_int; -typedef unsigned long count_int; -typedef unsigned short count_short; -typedef unsigned long cmp_code_int; - -#define MAXCODE(n) (1L << (n)) - -#ifndef REGISTERS -# define REGISTERS 2 -#endif -#define REG1 -#define REG2 -#define REG3 -#define REG4 -#define REG5 -#define REG6 -#define REG7 -#define REG8 -#define REG9 -#define REG10 -#define REG11 -#define REG12 -#define REG13 -#define REG14 -#define REG15 -#define REG16 -#if REGISTERS >= 1 -# undef REG1 -# define REG1 register -#endif -#if REGISTERS >= 2 -# undef REG2 -# define REG2 register -#endif -#if REGISTERS >= 3 -# undef REG3 -# define REG3 register -#endif -#if REGISTERS >= 4 -# undef REG4 -# define REG4 register -#endif -#if REGISTERS >= 5 -# undef REG5 -# define REG5 register -#endif -#if REGISTERS >= 6 -# undef REG6 -# define REG6 register -#endif -#if REGISTERS >= 7 -# undef REG7 -# define REG7 register -#endif -#if REGISTERS >= 8 -# undef REG8 -# define REG8 register -#endif -#if REGISTERS >= 9 -# undef REG9 -# define REG9 register -#endif -#if REGISTERS >= 10 -# undef REG10 -# define REG10 register -#endif -#if REGISTERS >= 11 -# undef REG11 -# define REG11 register -#endif -#if REGISTERS >= 12 -# undef REG12 -# define REG12 register -#endif -#if REGISTERS >= 13 -# undef REG13 -# define REG13 register -#endif -#if REGISTERS >= 14 -# undef REG14 -# define REG14 register -#endif -#if REGISTERS >= 15 -# undef REG15 -# define REG15 register -#endif -#if REGISTERS >= 16 -# undef REG16 -# define REG16 register -#endif - -#ifndef BYTEORDER -# define BYTEORDER 0000 -#endif - -#ifndef NOALLIGN -# define NOALLIGN 0 -#endif - - -union bytes { - long word; - struct { -#if BYTEORDER == 4321 - char_type b1; - char_type b2; - char_type b3; - char_type b4; -#else -#if BYTEORDER == 1234 - char_type b4; - char_type b3; - char_type b2; - char_type b1; -#else -# undef BYTEORDER - int dummy; -#endif -#endif - } bytes; -}; - -#if BYTEORDER == 4321 && NOALLIGN == 1 -# define input(b,o,c,n,m){ \ - (c) = (*(long *)(&(b)[(o)>>3])>>((o)&0x7))&(m); \ - (o) += (n); \ - } -#else -# define input(b,o,c,n,m){ \ - REG1 char_type *p = &(b)[(o)>>3]; \ - (c) = ((((long)(p[0]))|((long)(p[1])<<8)| \ - ((long)(p[2])<<16))>>((o)&0x7))&(m); \ - (o) += (n); \ - } -#endif - -#ifndef MAXSEG_64K - /* DECLARE(ush, tab_prefix, (1<>1] -# define clear_tab_prefixof() \ - memzero(tab_prefix0, 128), \ - memzero(tab_prefix1, 128); -#endif -#define de_stack ((char_type *)(&d_buf[DIST_BUFSIZE-1])) -#define tab_suffixof(i) tab_suffix[i] - -int block_mode = BLOCK_MODE; /* block compress mode -C compatible with 2.0 */ - -/* ============================================================================ - * Decompress in to out. This routine adapts to the codes in the - * file building the "string" table on-the-fly; requiring no table to - * be stored in the compressed file. - * IN assertions: the buffer inbuf contains already the beginning of - * the compressed data, from offsets iptr to insize-1 included. - * The magic header has already been checked and skipped. - * bytes_in and bytes_out have been initialized. - */ -int unlzw(in, out) - int in, out; /* input and output file descriptors */ -{ - REG2 char_type *stackp; - REG3 code_int code; - REG4 int finchar; - REG5 code_int oldcode; - REG6 code_int incode; - REG7 long inbits; - REG8 long posbits; - REG9 int outpos; -/* REG10 int insize; (global) */ - REG11 unsigned bitmask; - REG12 code_int free_ent; - REG13 code_int maxcode; - REG14 code_int maxmaxcode; - REG15 int n_bits; - REG16 int rsize; - -#ifdef MAXSEG_64K - tab_prefix[0] = tab_prefix0; - tab_prefix[1] = tab_prefix1; -#endif - maxbits = get_byte(); - block_mode = maxbits & BLOCK_MODE; - if ((maxbits & LZW_RESERVED) != 0) { - WARN((stderr, "\n%s: %s: warning, unknown flags 0x%x\n", - progname, ifname, maxbits & LZW_RESERVED)); - } - maxbits &= BIT_MASK; - maxmaxcode = MAXCODE(maxbits); - - if (maxbits > BITS) { - fprintf(stderr, - "\n%s: %s: compressed with %d bits, can only handle %d bits\n", - progname, ifname, maxbits, BITS); - exit_code = ERROR; - return ERROR; - } - rsize = insize; - maxcode = MAXCODE(n_bits = INIT_BITS)-1; - bitmask = (1<= 0 ; --code) { - tab_suffixof(code) = (char_type)code; - } - do { - REG1 int i; - int e; - int o; - - resetbuf: - e = insize-(o = (posbits>>3)); - - for (i = 0 ; i < e ; ++i) { - inbuf[i] = inbuf[i+o]; - } - insize = e; - posbits = 0; - - if (insize < INBUF_EXTRA) { - if ((rsize = read(in, (char*)inbuf+insize, INBUFSIZ)) == EOF) { - read_error(); - } - insize += rsize; - } - inbits = ((rsize != 0) ? ((long)insize - insize%n_bits)<<3 : - ((long)insize<<3)-(n_bits-1)); - - while (inbits > posbits) { - if (free_ent > maxcode) { - posbits = ((posbits-1) + - ((n_bits<<3)-(posbits-1+(n_bits<<3))%(n_bits<<3))); - ++n_bits; - if (n_bits == maxbits) { - maxcode = maxmaxcode; - } else { - maxcode = MAXCODE(n_bits)-1; - } - bitmask = (1<= free_ent) { /* Special case for KwKwK string. */ - if (code > free_ent) { -#ifdef DEBUG - char_type *p; - - posbits -= n_bits; - p = &inbuf[posbits>>3]; - fprintf(stderr, - "code:%ld free_ent:%ld n_bits:%d insize:%u\n", - code, free_ent, n_bits, insize); - fprintf(stderr, - "posbits:%ld inbuf:%02X %02X %02X %02X %02X\n", - posbits, p[-1],p[0],p[1],p[2],p[3]); -#endif - if (!test && outpos > 0) { - write_buf(out, outbuf, outpos); - } - error("corrupt input. Use zcat to recover some data."); - } - *--stackp = (char_type)finchar; - code = oldcode; - } - - while ((cmp_code_int)code >= (cmp_code_int)256) { - /* Generate output characters in reverse order */ - *--stackp = tab_suffixof(code); - code = tab_prefixof(code); - } - *--stackp = (char_type)(finchar = tab_suffixof(code)); - - /* And put them out in forward order */ - { - REG1 int i; - - if (outpos+(i = (de_stack-stackp)) >= OUTBUFSIZ) { - do { - if (i > OUTBUFSIZ-outpos) i = OUTBUFSIZ-outpos; - - if (i > 0) { - memcpy(outbuf+outpos, stackp, i); - outpos += i; - } - if (outpos >= OUTBUFSIZ) { - if (!test) write_buf(out, outbuf, outpos); - outpos = 0; - } - stackp+= i; - } while ((i = (de_stack-stackp)) > 0); - } else { - memcpy(outbuf+outpos, stackp, i); - outpos += i; - } - } - - if ((code = free_ent) < maxmaxcode) { /* Generate the new entry. */ - - tab_prefixof(code) = (unsigned short)oldcode; - tab_suffixof(code) = (char_type)finchar; - free_ent = code+1; - } - oldcode = incode; /* Remember previous code. */ - } - bytes_in += rsize; - - } while (rsize != 0); - - if (!test && outpos > 0) write_buf(out, outbuf, outpos); - return OK; -} diff --git a/gnu/usr.bin/gzip-1.1.1/unpack.c b/gnu/usr.bin/gzip-1.1.1/unpack.c deleted file mode 100644 index 6df28d8b2f2b..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/unpack.c +++ /dev/null @@ -1,241 +0,0 @@ -/* unpack.c -- decompress files in pack format. - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#ifndef lint -static char rcsid[] = "$Id: unpack.c,v 1.1 1993/06/29 14:49:49 brezak Exp $"; -#endif - -#include - -#include "tailor.h" -#include "gzip.h" -#include "crypt.h" - -#define MIN(a,b) ((a) <= (b) ? (a) : (b)) -/* The arguments must not have side effects. */ - -#define MAX_BITLEN 25 -/* Maximum length of Huffman codes. (Minor modifications to the code - * would be needed to support 32 bits codes, but pack never generates - * more than 24 bits anyway.) - */ - -#define LITERALS 256 -/* Number of literals, excluding the End of Block (EOB) code */ - -#ifdef SMALL_MEM -# define MAX_PEEK 10 -#else -# define MAX_PEEK 12 -#endif -/* Maximum number of 'peek' bits used to optimize traversal of the - * Huffman tree. - */ - -local ulg orig_len; /* original uncompressed length */ -local int max_len; /* maximum bit length of Huffman codes */ - -local uch literal[LITERALS]; -/* The literal bytes present in the Huffman tree. The EOB code is not - * represented. - */ - -local int lit_base[MAX_BITLEN+1]; -/* All literals of a given bit length are contiguous in literal[] and - * have contiguous codes. literal[code+lit_base[len]] is the literal - * for a code of len bits. - */ - -local int leaves [MAX_BITLEN+1]; /* Number of leaves for each bit length */ -local int parents[MAX_BITLEN+1]; /* Number of parents for each bit length */ - -local int peek_bits; /* Number of peek bits currently used */ - -local uch prefix_len[1 << MAX_PEEK]; -/* For each bit pattern b of peek_bits bits, prefix_len[b] is the length - * of the Huffman code starting with a prefix of b (upper bits), or 0 - * if all codes of prefix b have more than peek_bits bits. It is not - * necessary to have a huge table (large MAX_PEEK) because most of the - * codes encountered in the input stream are short codes (by construction). - * So for most codes a single lookup will be necessary. - */ - -local ulg bitbuf; -/* Bits are added on the low part of bitbuf and read from the high part. */ - -local int valid; /* number of valid bits in bitbuf */ -/* all bits above the last valid bit are always zero */ - -/* Set code to the next 'bits' input bits without skipping them. code - * must be the name of a simple variable and bits must not have side effects. - * IN assertions: bits <= 25 (so that we still have room for an extra byte - * when valid is only 24), and mask = (1<> (valid-(bits))) & (mask); \ -} - -/* Skip the given number of bits (after having peeked at them): */ -#define skip_bits(bits) (valid -= (bits)) - -#define clear_bitbuf() (valid = 0, bitbuf = 0) - -/* Local functions */ - -local void read_tree OF((void)); -local void build_tree OF((void)); - -/* =========================================================================== - * Read the Huffman tree. - */ -local void read_tree() -{ - int len; /* bit length */ - int base; /* base offset for a sequence of leaves */ - int n; - - /* Read the original input size, MSB first */ - orig_len = 0; - for (n = 1; n <= 4; n++) orig_len = (orig_len << 8) | (ulg)get_byte(); - - max_len = (int)get_byte(); /* maximum bit length of Huffman codes */ - if (max_len > MAX_BITLEN) { - error("invalid compressed data -- Huffman code > 32 bits"); - } - - /* Get the number of leaves at each bit length */ - n = 0; - for (len = 1; len <= max_len; len++) { - leaves[len] = (int)get_byte(); - n += leaves[len]; - } - if (n > LITERALS) { - error("too many leaves in Huffman tree"); - } - Trace((stderr, "orig_len %ld, max_len %d, leaves %d\n", - orig_len, max_len, n)); - /* There are at least 2 and at most 256 leaves of length max_len. - * (Pack arbitrarily rejects empty files and files consisting of - * a single byte even repeated.) To fit the last leaf count in a - * byte, it is offset by 2. However, the last literal is the EOB - * code, and is not transmitted explicitly in the tree, so we must - * adjust here by one only. - */ - leaves[max_len]++; - - /* Now read the leaves themselves */ - base = 0; - for (len = 1; len <= max_len; len++) { - /* Remember where the literals of this length start in literal[] : */ - lit_base[len] = base; - /* And read the literals: */ - for (n = leaves[len]; n > 0; n--) { - literal[base++] = (uch)get_byte(); - } - } - leaves[max_len]++; /* Now include the EOB code in the Huffman tree */ -} - -/* =========================================================================== - * Build the Huffman tree and the prefix table. - */ -local void build_tree() -{ - int nodes = 0; /* number of nodes (parents+leaves) at current bit length */ - int len; /* current bit length */ - uch *prefixp; /* pointer in prefix_len */ - - for (len = max_len; len >= 1; len--) { - /* The number of parent nodes at this level is half the total - * number of nodes at parent level: - */ - nodes >>= 1; - parents[len] = nodes; - /* Update lit_base by the appropriate bias to skip the parent nodes - * (which are not represented in the literal array): - */ - lit_base[len] -= nodes; - /* Restore nodes to be parents+leaves: */ - nodes += leaves[len]; - } - /* Construct the prefix table, from shortest leaves to longest ones. - * The shortest code is all ones, so we start at the end of the table. - */ - peek_bits = MIN(max_len, MAX_PEEK); - prefixp = &prefix_len[1< prefix_len) *--prefixp = 0; -} - -/* =========================================================================== - * Unpack in to out. This routine does not support the old pack format - * with magic header \037\037. - * - * IN assertions: the buffer inbuf contains already the beginning of - * the compressed data, from offsets inptr to insize-1 included. - * The magic header has already been checked. The output buffer is cleared. - */ -int unpack(in, out) - int in, out; /* input and output file descriptors */ -{ - int len; /* Bit length of current code */ - unsigned eob; /* End Of Block code */ - register unsigned peek; /* lookahead bits */ - unsigned peek_mask; /* Mask for peek_bits bits */ - - ifd = in; - ofd = out; - - read_tree(); /* Read the Huffman tree */ - build_tree(); /* Build the prefix table */ - clear_bitbuf(); /* Initialize bit input */ - peek_mask = (1< 0) { - peek >>= peek_bits - len; /* discard the extra bits */ - } else { - /* Code of more than peek_bits bits, we must traverse the tree */ - ulg mask = peek_mask; - len = peek_bits; - do { - len++, mask = (mask<<1)+1; - look_bits(peek, len, mask); - } while (peek < parents[len]); - /* loop as long as peek is a parent node */ - } - /* At this point, peek is the next complete code, of len bits */ - if (peek == eob && len == max_len) break; /* end of file? */ - put_ubyte(literal[peek+lit_base[len]]); - Tracev((stderr,"%02d %04x %c\n", len, peek, - literal[peek+lit_base[len]])); - skip_bits(len); - } /* for (;;) */ - - flush_window(); - Trace((stderr, "bytes_out %ld\n", bytes_out)); - if (orig_len != bytes_out) { - error("invalid compressed data--length error"); - } - return OK; -} diff --git a/gnu/usr.bin/gzip-1.1.1/unzip.c b/gnu/usr.bin/gzip-1.1.1/unzip.c deleted file mode 100644 index 60b6ac09d310..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/unzip.c +++ /dev/null @@ -1,201 +0,0 @@ -/* unzip.c -- decompress files in gzip or pkzip format. - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - * - * The code in this file is derived from the file funzip.c written - * and put in the public domain by Mark Adler. - */ - -/* - This version can extract files in gzip or pkzip format. - For the latter, only the first entry is extracted, and it has to be - either deflated or stored. - */ - -#ifndef lint -static char rcsid[] = "$Id: unzip.c,v 1.1 1993/06/29 14:49:50 brezak Exp $"; -#endif - -#include - -#include "tailor.h" -#include "gzip.h" -#include "crypt.h" - -/* PKZIP header definitions */ -#define LOCSIG 0x04034b50L /* four-byte lead-in (lsb first) */ -#define LOCFLG 6 /* offset of bit flag */ -#define CRPFLG 1 /* bit for encrypted entry */ -#define EXTFLG 8 /* bit for extended local header */ -#define LOCHOW 8 /* offset of compression method */ -#define LOCTIM 10 /* file mod time (for decryption) */ -#define LOCCRC 14 /* offset of crc */ -#define LOCSIZ 18 /* offset of compressed size */ -#define LOCLEN 22 /* offset of uncompressed length */ -#define LOCFIL 26 /* offset of file name field length */ -#define LOCEXT 28 /* offset of extra field length */ -#define LOCHDR 30 /* size of local header, including sig */ -#define EXTHDR 16 /* size of extended local header, inc sig */ - - -/* Globals */ - -int decrypt; /* flag to turn on decryption */ -char *key; /* not used--needed to link crypt.c */ -int pkzip = 0; /* set for a pkzip file */ -int ext_header = 0; /* set if extended local header */ - -/* =========================================================================== - * Check zip file and advance inptr to the start of the compressed data. - * Get ofname from the local header if necessary. - */ -int check_zipfile(in) - int in; /* input file descriptors */ -{ - uch *h = inbuf + inptr; /* first local header */ - - ifd = in; - - /* Check validity of local header, and skip name and extra fields */ - inptr += LOCHDR + SH(h + LOCFIL) + SH(h + LOCEXT); - - if (inptr > insize || LG(h) != LOCSIG) { - fprintf(stderr, "\n%s: %s: not a valid zip file\n", - progname, ifname); - exit_code = ERROR; - return ERROR; - } - method = h[LOCHOW]; - if (method != STORED && method != DEFLATED) { - fprintf(stderr, - "\n%s: %s: first entry not deflated or stored -- use unzip\n", - progname, ifname); - exit_code = ERROR; - return ERROR; - } - - /* If entry encrypted, decrypt and validate encryption header */ - if ((decrypt = h[LOCFLG] & CRPFLG) != 0) { - fprintf(stderr, "\n%s: %s: encrypted file -- use unzip\n", - progname, ifname); - exit_code = ERROR; - return ERROR; - } - - /* Save flags for unzip() */ - ext_header = (h[LOCFLG] & EXTFLG) != 0; - pkzip = 1; - - /* Get ofname and time stamp from local header (to be done) */ - return OK; -} - -/* =========================================================================== - * Unzip in to out. This routine works on both gzip and pkzip files. - * - * IN assertions: the buffer inbuf contains already the beginning of - * the compressed data, from offsets inptr to insize-1 included. - * The magic header has already been checked. The output buffer is cleared. - */ -int unzip(in, out) - int in, out; /* input and output file descriptors */ -{ - ulg orig_crc = 0; /* original crc */ - ulg orig_len = 0; /* original uncompressed length */ - int n; - uch buf[EXTHDR]; /* extended local header */ - - ifd = in; - ofd = out; - - updcrc(NULL, 0); /* initialize crc */ - - if (pkzip && !ext_header) { /* crc and length at the end otherwise */ - orig_crc = LG(inbuf + LOCCRC); - orig_len = LG(inbuf + LOCLEN); - } - - /* Decompress */ - if (method == DEFLATED) { - - int res = inflate(); - - if (res == 3) { - error("out of memory"); - } else if (res != 0) { - error("invalid compressed data--format violated"); - } - - } else if (pkzip && method == STORED) { - - register ulg n = LG(inbuf + LOCLEN); - - if (n != LG(inbuf + LOCSIZ) - (decrypt ? RAND_HEAD_LEN : 0)) { - - fprintf(stderr, "len %ld, siz %ld\n", n, LG(inbuf + LOCSIZ)); - error("invalid compressed data--length mismatch"); - } - while (n--) { - uch c = (uch)get_byte(); -#ifdef CRYPT - if (decrypt) zdecode(c); -#endif - put_ubyte(c); - } - flush_window(); - } else { - error("internal error, invalid method"); - } - - /* Get the crc and original length */ - if (!pkzip) { - /* crc32 (see algorithm.doc) - * uncompressed input size modulo 2^32 - */ - for (n = 0; n < 8; n++) { - buf[n] = (uch)get_byte(); /* may cause an error if EOF */ - } - orig_crc = LG(buf); - orig_len = LG(buf+4); - - } else if (ext_header) { /* If extended header, check it */ - /* signature - 4bytes: 0x50 0x4b 0x07 0x08 - * CRC-32 value - * compressed size 4-bytes - * uncompressed size 4-bytes - */ - for (n = 0; n < EXTHDR; n++) { - buf[n] = (uch)get_byte(); /* may cause an error if EOF */ - } - orig_crc = LG(buf+4); - orig_len = LG(buf+12); - } - - /* Validate decompression */ - if (orig_crc != updcrc(outbuf, 0)) { - error("invalid compressed data--crc error"); - } - if (orig_len != bytes_out) { - error("invalid compressed data--length error"); - } - - /* Check if there are more entries in a pkzip file */ - if (pkzip && inptr + 4 < insize && LG(inbuf+inptr) == LOCSIG) { - if (to_stdout) { - WARN((stderr, - "%s: %s has more than one entry--rest ignored\n", - progname, ifname)); - } else { - /* Don't destroy the input zip file */ - fprintf(stderr, - "%s: %s has more than one entry -- unchanged\n", - progname, ifname); - exit_code = ERROR; - ext_header = pkzip = 0; - return ERROR; - } - } - ext_header = pkzip = 0; /* for next file */ - return OK; -} diff --git a/gnu/usr.bin/gzip-1.1.1/util.c b/gnu/usr.bin/gzip-1.1.1/util.c deleted file mode 100644 index bed78970cef1..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/util.c +++ /dev/null @@ -1,419 +0,0 @@ -/* util.c -- utility functions for gzip support - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#ifndef lint -static char rcsid[] = "$Id: util.c,v 1.1 1993/06/29 14:49:52 brezak Exp $"; -#endif - -#include -#include -#include -#include - -#include "tailor.h" - -#ifdef HAVE_UNISTD_H -# include -#endif -#ifndef NO_FCNTL_H -# include -#endif - -#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H) -# include -#else - extern int errno; -#endif - -#include "gzip.h" -#include "crypt.h" - -extern ulg crc_32_tab[]; /* crc table, defined below */ - -/* =========================================================================== - * Run a set of bytes through the crc shift register. If s is a NULL - * pointer, then initialize the crc shift register contents instead. - * Return the current crc in either case. - */ -ulg updcrc(s, n) - uch *s; /* pointer to bytes to pump through */ - unsigned n; /* number of bytes in s[] */ -{ - register ulg c; /* temporary variable */ - - static ulg crc = (ulg)0xffffffffL; /* shift register contents */ - - if (s == NULL) { - c = 0xffffffffL; - } else { - c = crc; - if (n) do { - c = crc_32_tab[((int)c ^ (*s++)) & 0xff] ^ (c >> 8); - } while (--n); - } - crc = c; - return c ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */ -} - -/* =========================================================================== - * Clear input and output buffers - */ -void clear_bufs() -{ - outcnt = 0; - insize = inptr = 0; - bytes_in = bytes_out = 0L; -} - -/* =========================================================================== - * Fill the input buffer. This is called only when the buffer is empty - * and at least one byte is really needed. - */ -int fill_inbuf() -{ - int len; - - /* Read as much as possible */ - insize = 0; - errno = 0; - do { - len = read(ifd, (char*)inbuf+insize, INBUFSIZ-insize); - if (len == 0 || len == EOF) break; - insize += len; - } while (insize < INBUFSIZ); - - if (insize == 0) { - read_error(); - } - bytes_in += (ulg)insize; - inptr = 1; - return inbuf[0]; -} - -/* =========================================================================== - * Write the output buffer outbuf[0..outcnt-1] and update bytes_out. - * (used for the compressed data only) - */ -void flush_outbuf() -{ - if (outcnt == 0) return; - - write_buf(ofd, (char *)outbuf, outcnt); - bytes_out += (ulg)outcnt; - outcnt = 0; -} - -/* =========================================================================== - * Write the output window window[0..outcnt-1] and update crc and bytes_out. - * (Used for the decompressed data only.) - */ -void flush_window() -{ - if (outcnt == 0) return; - updcrc(window, outcnt); - - if (!test) { - write_buf(ofd, (char *)window, outcnt); - } - bytes_out += (ulg)outcnt; - outcnt = 0; -} - -/* =========================================================================== - * Does the same as write(), but also handles partial pipe writes and checks - * for error return. - */ -void write_buf(fd, buf, cnt) - int fd; - voidp buf; - unsigned cnt; -{ - unsigned n; - - while ((n = write(fd, buf, cnt)) != cnt) { - if (n == (unsigned)(-1)) { - write_error(); - } - cnt -= n; - buf = (voidp)((char*)buf+n); - } -} - -/* ======================================================================== - * Put string s in lower case, return s. - */ -char *strlwr(s) - char *s; -{ - char *t; - for (t = s; *t; t++) *t = tolow(*t); - return s; -} - -/* ======================================================================== - * Return the base name of a file (remove any directory prefix and - * any version suffix). For systems with file names that are not - * case sensitive, force the base name to lower case. - */ -char *basename(fname) - char *fname; -{ - char *p; - - if ((p = strrchr(fname, PATH_SEP)) != NULL) fname = p+1; -#ifdef PATH_SEP2 - if ((p = strrchr(fname, PATH_SEP2)) != NULL) fname = p+1; -#endif -#ifdef PATH_SEP3 - if ((p = strrchr(fname, PATH_SEP3)) != NULL) fname = p+1; -#endif -#ifdef SUFFIX_SEP - if ((p = strrchr(fname, SUFFIX_SEP)) != NULL) *p = '\0'; -#endif - if (casemap('A') == 'a') strlwr(fname); - return fname; -} - -#if defined(NO_STRING_H) && !defined(STDC_HEADERS) - -/* Provide missing strspn and strcspn functions. */ - -# ifndef __STDC__ -# define const -# endif - -int strspn OF((const char *s, const char *accept)); -int strcspn OF((const char *s, const char *reject)); - -/* ======================================================================== - * Return the length of the maximum initial segment - * of s which contains only characters in accept. - */ -int strspn(s, accept) - const char *s; - const char *accept; -{ - register const char *p; - register const char *a; - register int count = 0; - - for (p = s; *p != '\0'; ++p) { - for (a = accept; *a != '\0'; ++a) { - if (*p == *a) break; - } - if (*a == '\0') return count; - ++count; - } - return count; -} - -/* ======================================================================== - * Return the length of the maximum inital segment of s - * which contains no characters from reject. - */ -int strcspn(s, reject) - const char *s; - const char *reject; -{ - register int count = 0; - - while (*s != '\0') { - if (strchr(reject, *s++) != NULL) return count; - ++count; - } - return count; -} - -#endif /* NO_STRING_H */ - -/* ======================================================================== - * Add an environment variable (if any) before argv, and update argc. - * Return the expanded environment variable to be freed later, or NULL - * if no options were added to argv. - */ -#define SEPARATOR " \t" /* separators in env variable */ - -char *add_envopt(argcp, argvp, env) - int *argcp; /* pointer to argc */ - char ***argvp; /* pointer to argv */ - char *env; /* name of environment variable */ -{ - char *p; /* running pointer through env variable */ - char **oargv; /* runs through old argv array */ - char **nargv; /* runs through new argv array */ - int oargc = *argcp; /* old argc */ - int nargc = 0; /* number of arguments in env variable */ - - env = (char*)getenv(env); - if (env == NULL) return NULL; - - p = (char*)xmalloc(strlen(env)+1); - env = strcpy(p, env); /* keep env variable intact */ - - for (p = env; *p; nargc++ ) { /* move through env */ - p += strspn(p, SEPARATOR); /* skip leading separators */ - if (*p == '\0') break; - - p += strcspn(p, SEPARATOR); /* find end of word */ - if (*p) *p++ = '\0'; /* mark it */ - } - if (nargc == 0) { - free(env); env = NULL; - return NULL; - } - *argcp += nargc; - /* Allocate the new argv array, with an extra element just in case - * the original arg list did not end with a NULL. - */ - nargv = (char**)calloc(*argcp+1, sizeof(char *)); - if (nargv == NULL) error("out of memory"); - oargv = *argvp; - *argvp = nargv; - - /* Copy the program name first */ - if (oargc-- < 0) error("argc<=0"); - *(nargv++) = *(oargv++); - - /* Then copy the environment args */ - for (p = env; nargc > 0; nargc--) { - p += strspn(p, SEPARATOR); /* skip separators */ - *(nargv++) = p; /* store start */ - while (*p++) ; /* skip over word */ - } - - /* Finally copy the old args and add a NULL (usual convention) */ - while (oargc--) *(nargv++) = *(oargv++); - *nargv = NULL; - return env; -} - -/* ======================================================================== - * Error handlers. - */ -void error(m) - char *m; -{ - fprintf(stderr, "\n%s: %s: %s\n", progname, ifname, m); - abort_gzip(); -} - -void warn(a, b) - char *a, *b; /* message strings juxtaposed in output */ -{ - WARN((stderr, "%s: %s: warning: %s%s\n", progname, ifname, a, b)); -} - -void read_error() -{ - fprintf(stderr, "\n%s: ", progname); - if (errno != 0) { - perror(ifname); - } else { - fprintf(stderr, "%s: unexpected end of file\n", ifname); - } - abort_gzip(); -} - -void write_error() -{ - fprintf(stderr, "\n%s: ", progname); - perror(ofname); - abort_gzip(); -} - -/* ======================================================================== - * Display compression ratio on stderr. - */ -void display_ratio(num, den) - long num; - long den; -{ - long ratio; /* 1000 times the compression ratio */ - - if (den == 0) { - ratio = 0; /* no compression */ - } else if (den < 2147483L) { /* (2**31 -1)/1000 */ - ratio = 1000L*num/den; - } else { - ratio = num/(den/1000L); - } - if (ratio < 0) { - putc('-', stderr); - ratio = -ratio; - } - fprintf(stderr, "%2ld.%ld%%", ratio / 10L, ratio % 10L); -} - - -/* ======================================================================== - * Semi-safe malloc -- never returns NULL. - */ -voidp xmalloc (size) - unsigned size; -{ - voidp cp = (voidp)malloc (size); - - if (cp == NULL) error("out of memory"); - return cp; -} - -/* ======================================================================== - * Table of CRC-32's of all single-byte values (made by makecrc.c) - */ -ulg crc_32_tab[] = { - 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, - 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, - 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, - 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, - 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, - 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, - 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, - 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, - 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, - 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, - 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, - 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, - 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, - 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, - 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, - 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, - 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, - 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, - 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, - 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, - 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, - 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, - 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, - 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, - 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, - 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, - 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, - 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, - 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, - 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, - 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, - 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, - 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, - 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, - 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, - 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, - 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, - 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, - 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, - 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, - 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, - 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, - 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, - 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, - 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, - 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, - 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, - 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, - 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, - 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, - 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, - 0x2d02ef8dL -}; diff --git a/gnu/usr.bin/gzip-1.1.1/zcmp b/gnu/usr.bin/gzip-1.1.1/zcmp deleted file mode 100644 index c21e7ef8ae06..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/zcmp +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -# Zcmp and zdiff are used to invoke the cmp or the diff pro- -# gram on compressed files. All options specified are passed -# directly to cmp or diff. If only 1 file is specified, then -# the files compared are file1 and an uncompressed file1.gz. -# If two files are specified, then they are uncompressed (if -# necessary) and fed to cmp or diff. The exit status from cmp -# or diff is preserved. - -prog=`echo $0 | sed 's|.*/||'` -case "$prog" in - *cmp) comp=${CMP-cmp} ;; - *) comp=${DIFF-diff} ;; -esac - -OPTIONS= -FILES= -for ARG -do - case "$ARG" in - -*) OPTIONS="$OPTIONS $ARG";; - *) if test -f "$ARG"; then - FILES="$FILES $ARG" - else - echo "${prog}: $ARG not found or not a regular file" - exit 1 - fi ;; - esac -done -if test -z "$FILES"; then - echo "Usage: $prog [${comp}_options] file [file]" - exit 1 -fi -set $FILES -if test $# -eq 1; then - FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'` - gzip -cd "$1" | $comp $OPTIONS - "$FILE" - STAT="$?" - -elif test $# -eq 2; then - case "$1" in - *[-.]gz | *[-.][zZ] | *.t[ga]z) - case "$2" in - *[-.]gz | *[-.][zZ] | *.t[ga]z) - F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*$||'` - gzip -cd "$2" > /tmp/"$F".$$ - gzip -cd "$1" | $comp $OPTIONS - /tmp/"$F".$$ - STAT="$?" - /bin/rm -f /tmp/"$F".$$;; - - *) gzip -cd "$1" | $comp $OPTIONS - "$2" - STAT="$?";; - esac;; - *) case "$2" in - *[-.]gz | *[-.][zZ] | *.t[ga]z) - gzip -cd "$2" | $comp $OPTIONS "$1" - - STAT="$?";; - *) $comp $OPTIONS "$1" "$2" - STAT="$?";; - esac;; - esac - exit "$STAT" -else - echo "Usage: $prog [${comp}_options] file [file]" - exit 1 -fi diff --git a/gnu/usr.bin/gzip-1.1.1/zdiff b/gnu/usr.bin/gzip-1.1.1/zdiff deleted file mode 100644 index c21e7ef8ae06..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/zdiff +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -# Zcmp and zdiff are used to invoke the cmp or the diff pro- -# gram on compressed files. All options specified are passed -# directly to cmp or diff. If only 1 file is specified, then -# the files compared are file1 and an uncompressed file1.gz. -# If two files are specified, then they are uncompressed (if -# necessary) and fed to cmp or diff. The exit status from cmp -# or diff is preserved. - -prog=`echo $0 | sed 's|.*/||'` -case "$prog" in - *cmp) comp=${CMP-cmp} ;; - *) comp=${DIFF-diff} ;; -esac - -OPTIONS= -FILES= -for ARG -do - case "$ARG" in - -*) OPTIONS="$OPTIONS $ARG";; - *) if test -f "$ARG"; then - FILES="$FILES $ARG" - else - echo "${prog}: $ARG not found or not a regular file" - exit 1 - fi ;; - esac -done -if test -z "$FILES"; then - echo "Usage: $prog [${comp}_options] file [file]" - exit 1 -fi -set $FILES -if test $# -eq 1; then - FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'` - gzip -cd "$1" | $comp $OPTIONS - "$FILE" - STAT="$?" - -elif test $# -eq 2; then - case "$1" in - *[-.]gz | *[-.][zZ] | *.t[ga]z) - case "$2" in - *[-.]gz | *[-.][zZ] | *.t[ga]z) - F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*$||'` - gzip -cd "$2" > /tmp/"$F".$$ - gzip -cd "$1" | $comp $OPTIONS - /tmp/"$F".$$ - STAT="$?" - /bin/rm -f /tmp/"$F".$$;; - - *) gzip -cd "$1" | $comp $OPTIONS - "$2" - STAT="$?";; - esac;; - *) case "$2" in - *[-.]gz | *[-.][zZ] | *.t[ga]z) - gzip -cd "$2" | $comp $OPTIONS "$1" - - STAT="$?";; - *) $comp $OPTIONS "$1" "$2" - STAT="$?";; - esac;; - esac - exit "$STAT" -else - echo "Usage: $prog [${comp}_options] file [file]" - exit 1 -fi diff --git a/gnu/usr.bin/gzip-1.1.1/zdiff.1 b/gnu/usr.bin/gzip-1.1.1/zdiff.1 deleted file mode 100644 index 44f9137c9f3d..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/zdiff.1 +++ /dev/null @@ -1,44 +0,0 @@ -.TH ZDIFF 1 -.SH NAME -zcmp, zdiff \- compare compressed files -.SH SYNOPSIS -.B zcmp -[ cmp_options ] file1 -[ file2 ] -.br -.B zdiff -[ diff_options ] file1 -[ file2 ] -.SH DESCRIPTION -.I Zcmp -and -.I zdiff -are used to invoke the -.I cmp -or the -.I diff -program on compressed files. All options specified are passed directly to -.I cmp -or -.IR diff "." -If only 1 file is specified, then the files compared are -.I file1 -and an uncompressed -.IR file1 ".gz." -If two files are specified, then they are uncompressed if necessary and fed to -.I cmp -or -.IR diff "." -The exit status from -.I cmp -or -.I diff -is preserved. -.SH "SEE ALSO" -cmp(1), diff(1), zmore(1), znew(1), zforce(1), gzip(1), gzexe(1) -.SH BUGS -Messages from the -.I cmp -or -.I diff -programs refer to temporary filenames instead of those specified. diff --git a/gnu/usr.bin/gzip-1.1.1/zforce b/gnu/usr.bin/gzip-1.1.1/zforce deleted file mode 100644 index 9fe85ad866dd..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/zforce +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# zforce: force a gz extension on all gzip files so that gzip will not -# compress them twice. -# -# This can be useful for files with names truncated after a file transfer. -# 12345678901234 is renamed to 12345678901.gz - -x=`basename $0` -if test $# = 0; then - echo "force a '.gz' extension on all gzip files" - echo usage: $x files... - exit 1 -fi - -res=0 -for i do - if test ! -f "$i" ; then - echo ${x}: $i not a file - res=1 - continue - fi - test `expr "$i" : '.*[.-]z$'` -eq 0 || continue - test `expr "$i" : '.*[.-]gz$'` -eq 0 || continue - test `expr "$i" : '.*[.]t[ag]z$'` -eq 0 || continue - - gzip -t "$i" 2>/dev/null || continue - - if test `expr "$i" : '^............'` -eq 12; then - new=`expr "$i" : '\(.*\)...$`.gz - else - new="$i.gz" - fi - if mv "$i" "$new" 2>/dev/null; then - echo $i -- replaced with $new - continue - fi - res=1; echo ${x}: cannot rename $i to $new -done -exit $res diff --git a/gnu/usr.bin/gzip-1.1.1/zforce.1 b/gnu/usr.bin/gzip-1.1.1/zforce.1 deleted file mode 100644 index e2318150ef03..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/zforce.1 +++ /dev/null @@ -1,20 +0,0 @@ -.TH ZFORCE 1 -.SH NAME -zforce \- force a '.gz' extension on all gzip files -.SH SYNOPSIS -.B zforce -[ name ... ] -.SH DESCRIPTION -.I zforce -forces a .gz extension on all -.I gzip -files so that -.I gzip -will not compress them twice. -This can be useful for files with names truncated after a file transfer. -On systems with a 14 char limitation on file names, the original name -is truncated to make room for the .gz suffix. For example, -12345678901234 is renamed to 12345678901.gz. A file name such as foo.tgz -is left intact. -.SH "SEE ALSO" -gzip(1), znew(1), zmore(1), zcmp(1), gzexe(1) diff --git a/gnu/usr.bin/gzip-1.1.1/zip.c b/gnu/usr.bin/gzip-1.1.1/zip.c deleted file mode 100644 index 382fa55b1dc2..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/zip.c +++ /dev/null @@ -1,118 +0,0 @@ -/* zip.c -- compress files to the gzip or pkzip format - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - */ - -#ifndef lint -static char rcsid[] = "$Id: zip.c,v 1.1 1993/06/29 14:49:59 brezak Exp $"; -#endif - -#include -#include -#include - -#include "tailor.h" -#include "gzip.h" -#include "crypt.h" - -#ifdef HAVE_UNISTD_H -# include -#endif -#ifndef NO_FCNTL_H -# include -#endif - -local ulg crc; /* crc on uncompressed file data */ -long header_bytes; /* number of bytes in gzip header */ - -/* =========================================================================== - * Deflate in to out. - * IN assertions: the input and output buffers are cleared. - * The variables time_stamp and save_orig_name are initialized. - */ -int zip(in, out) - int in, out; /* input and output file descriptors */ -{ - uch flags = 0; /* general purpose bit flags */ - ush attr = 0; /* ascii/binary flag */ - ush deflate_flags = 0; /* pkzip -es, -en or -ex equivalent */ - - ifd = in; - ofd = out; - outcnt = 0; - - /* Write the header to the gzip file. See algorithm.doc for the format */ - - method = DEFLATED; - put_byte(GZIP_MAGIC[0]); /* magic header */ - put_byte(GZIP_MAGIC[1]); - put_byte(DEFLATED); /* compression method */ - - if (save_orig_name) { - flags |= ORIG_NAME; - } - put_byte(flags); /* general flags */ - put_long(time_stamp); - - /* Write deflated file to zip file */ - crc = updcrc(0, 0); - - bi_init(out); - ct_init(&attr, &method); - lm_init(level, &deflate_flags); - - put_byte((uch)deflate_flags); /* extra flags */ - put_byte(OS_CODE); /* OS identifier */ - - if (save_orig_name) { - char *p = basename(ifname); /* Don't save the directory part. */ - do { - put_char(*p); - } while (*p++); - } - header_bytes = (long)outcnt; - - (void)deflate(); - -#if !defined(NO_SIZE_CHECK) && !defined(RECORD_IO) - /* Check input size (but not in VMS -- variable record lengths mess it up) - * and not on MSDOS -- diet in TSR mode reports an incorrect file size) - */ - if (ifile_size != -1L && isize != (ulg)ifile_size) { - Trace((stderr, " actual=%ld, read=%ld ", ifile_size, isize)); - fprintf(stderr, "%s: %s: file size changed while zipping\n", - progname, ifname); - } -#endif - - /* Write the crc and uncompressed size */ - put_long(crc); - put_long(isize); - header_bytes += 2*sizeof(long); - - flush_outbuf(); - return OK; -} - - -/* =========================================================================== - * Read a new buffer from the current input file, perform end-of-line - * translation, and update the crc and input file size. - * IN assertion: size >= 2 (for end-of-line translation) - */ -int file_read(buf, size) - char *buf; - unsigned size; -{ - unsigned len; - - Assert(insize == 0, "inbuf not empty"); - - len = read(ifd, buf, size); - if (len == (unsigned)(-1) || len == 0) return (int)len; - - crc = updcrc((uch*)buf, len); - isize += (ulg)len; - return (int)len; -} diff --git a/gnu/usr.bin/gzip-1.1.1/zmore b/gnu/usr.bin/gzip-1.1.1/zmore deleted file mode 100644 index 64f7b1b99a8c..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/zmore +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -if test "`echo -n a`" = "-n a"; then - # looks like a SysV system: - n1=''; n2='\c' -else - n1='-n'; n2='' -fi -if stty -cbreak 2>/dev/null; then - cb='cbreak'; ncb='-cbreak' -else - # 'stty min 1' resets eof to ^a on both SunOS and SysV! - cb='min 1 -icanon'; ncb='icanon eof ^d' -fi -oldtty=`stty -g` -trap 'stty -g $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15 - -if test $# = 0; then - gzip -cd | eval ${PAGER-more} -else - FIRST=1 - for FILE - do - if test $FIRST -eq 0; then - echo $n1 "--More--(Next file: $FILE)$n2" - stty $cb -echo 2>/dev/null - ANS=`dd bs=1 count=1 2>/dev/null` - stty $ncb echo 2>/dev/null - echo " " - if test "$ANS" = 'e' -o "$ANS" = 'q'; then - exit - fi - fi - if test "$ANS" != 's'; then - echo "------> $FILE <------" - gzip -cd "$FILE" | eval ${PAGER-more} - fi - if test -t; then - FIRST=0 - fi - done -fi diff --git a/gnu/usr.bin/gzip-1.1.1/zmore.1 b/gnu/usr.bin/gzip-1.1.1/zmore.1 deleted file mode 100644 index 08b49fbae5f5..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/zmore.1 +++ /dev/null @@ -1,134 +0,0 @@ -.TH ZMORE 1 -.SH NAME -zmore \- file perusal filter for crt viewing of compressed text -.SH SYNOPSIS -.B zmore -[ name ... ] -.SH DESCRIPTION -.I Zmore -is a filter which allows examination of compressed text files -one screenful at a time on a soft-copy terminal. -It normally pauses after each screenful, printing --More-- -at the bottom of the screen. -If the user then types a carriage return, one more line is displayed. -If the user hits a space, -another screenful is displayed. Other possibilities are enumerated later. -.PP -.I Zmore -looks in the file -.I /etc/termcap -to determine terminal characteristics, -and to determine the default window size. -On a terminal capable of displaying 24 lines, -the default window size is 22 lines. -To use a pager other than the default -.I more, -set environment variable PAGER to the name of the desired program, such as -.I less. -.PP -Other sequences which may be typed when -.I zmore -pauses, and their effects, are as follows (\fIi\fP is an optional integer -argument, defaulting to 1) : -.PP -.IP \fIi\|\fP -display -.I i -more lines, (or another screenful if no argument is given) -.PP -.IP ^D -display 11 more lines (a ``scroll''). -If -.I i -is given, then the scroll size is set to \fIi\|\fP. -.PP -.IP d -same as ^D (control-D) -.PP -.IP \fIi\|\fPz -same as typing a space except that \fIi\|\fP, if present, becomes the new -window size. Note that the window size reverts back to the default at the -end of the current file. -.PP -.IP \fIi\|\fPs -skip \fIi\|\fP lines and print a screenful of lines -.PP -.IP \fIi\|\fPf -skip \fIi\fP screenfuls and print a screenful of lines -.PP -.IP "q or Q" -quit reading the current file; go on to the next (if any) -.PP -.IP "e or q" -When the prompt --More--(Next file: -.IR file ) -is printed, this command causes zmore to exit. -.PP -.IP s -When the prompt --More--(Next file: -.IR file ) -is printed, this command causes zmore to skip the next file and continue. -.PP -.IP = -Display the current line number. -.PP -.IP \fIi\|\fP/expr -search for the \fIi\|\fP-th occurrence of the regular expression \fIexpr.\fP -If the pattern is not found, -.I zmore -goes on to the next file (if any). -Otherwise, a screenful is displayed, starting two lines before the place -where the expression was found. -The user's erase and kill characters may be used to edit the regular -expression. -Erasing back past the first column cancels the search command. -.PP -.IP \fIi\|\fPn -search for the \fIi\|\fP-th occurrence of the last regular expression entered. -.PP -.IP !command -invoke a shell with \fIcommand\|\fP. -The character `!' in "command" are replaced with the -previous shell command. The sequence "\\!" is replaced by "!". -.PP -.IP ":q or :Q" -quit reading the current file; go on to the next (if any) -(same as q or Q). -.PP -.IP . -(dot) repeat the previous command. -.PP -The commands take effect immediately, i.e., it is not necessary to -type a carriage return. -Up to the time when the command character itself is given, -the user may hit the line kill character to cancel the numerical -argument being formed. -In addition, the user may hit the erase character to redisplay the ---More-- message. -.PP -At any time when output is being sent to the terminal, the user can -hit the quit key (normally control\-\\). -.I Zmore -will stop sending output, and will display the usual --More-- -prompt. -The user may then enter one of the above commands in the normal manner. -Unfortunately, some output is lost when this is done, due to the -fact that any characters waiting in the terminal's output queue -are flushed when the quit signal occurs. -.PP -The terminal is set to -.I noecho -mode by this program so that the output can be continuous. -What you type will thus not show on your terminal, except for the / and ! -commands. -.PP -If the standard output is not a teletype, then -.I zmore -acts just like -.I zcat, -except that a header is printed before each file. -.SH FILES -.DT -/etc/termcap Terminal data base -.SH "SEE ALSO" -more(1), gzip(1), zcmp(1), znew(1), zforce(1), gzexe(1) diff --git a/gnu/usr.bin/gzip-1.1.1/znew b/gnu/usr.bin/gzip-1.1.1/znew deleted file mode 100644 index fcbc466ae2fd..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/znew +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/sh - -check=0 -pipe=0 -opt= -files= -keep=0 -res=0 -old=0 -new=0 -block=1024 -# block is the disk block size (best guess, need not be exact) - -warn="(does not preserve modes and timestamp)" -tmp=/tmp/zfoo.$$ -echo hi > $tmp.1 -echo hi > $tmp.2 -if test -z "`(${CPMOD-cpmod} $tmp.1 $tmp.2) 2>&1`"; then - cpmod=${CPMOD-cpmod} - warn="" -fi - -if test -z "$cpmod" && ${TOUCH-touch} -r $tmp.1 $tmp.2 2>/dev/null; then - cpmod="${TOUCH-touch}" - cpmodarg="-r" - warn="(does not preserve file modes)" -fi -rm -f $tmp.[12] - -A= -fileno=0 - -for arg -do - case "$arg" in - -*) opt="$opt $arg";; - *) fileno=`expr $fileno + 1` - eval A$fileno=\$arg - A="$A \"\$A$fileno\"" - ;; - esac -done - -if test $fileno -eq 0; then - echo 'recompress .Z files into .gz (gzip) files' - echo usage: `echo $0 | sed 's,^.*/,,'` "[-tv9P]" file.Z... - echo " -t tests the new files before deleting originals" - echo " -v be verbose" - echo " -9 use the slowest compression method (optimal compression)" - echo " -K keep a .Z file when it is smaller than the .gz file" - echo " -P use pipes for the conversion $warn" - exit 1 -fi - -eval set "$A" # the files are now in $1, $2, ... - -opt=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'` -case "$opt" in - *t*) check=1; opt=`echo "$opt" | sed 's/t//g'` -esac -case "$opt" in - *K*) keep=1; opt=`echo "$opt" | sed 's/K//g'` -esac -case "$opt" in - *P*) pipe=1; opt=`echo "$opt" | sed 's/P//g'` -esac -if test -n "$opt"; then - opt="-$opt" -fi - -for i do - n=`echo $i | sed 's/.Z$//'` - if test ! -f "$n.Z" ; then - echo $n.Z not found - res=1; continue - fi - test $keep -eq 1 && old=`wc -c < "$n.Z"` - if test $pipe -eq 1; then - if gzip -d < "$n.Z" | gzip $opt > "$n.gz"; then - # Copy file attributes from old file to new one, if possible. - test -n "$cpmod" && $cpmod $cpmodarg "$n.Z" "$n.gz" 2> /dev/null - else - echo error while recompressing $n.Z - res=1; continue - fi - else - if test $check -eq 1; then - if cp -p "$n.Z" "$n.$$" 2> /dev/null || cp "$n.Z" "$n.$$"; then - : - else - echo cannot backup "$n.Z" - res=1; continue - fi - fi - if gzip -d "$n.Z"; then - : - else - test $check -eq 1 && mv "$n.$$" "$n.Z" - echo error while uncompressing $n.Z - res=1; continue - fi - if gzip $opt "$n"; then - : - else - if test $check -eq 1; then - mv "$n.$$" "$n.Z" && rm -f "$n" - echo error while recompressing $n - else - # compress $n (might be dangerous if disk full) - echo error while recompressing $n, left uncompressed - fi - res=1; continue - fi - fi - test $keep -eq 1 && new=`wc -c < "$n.gz"` - if test $keep -eq 1 -a `expr \( $old + $block - 1 \) / $block` -lt \ - `expr \( $new + $block - 1 \) / $block`; then - if test $pipe -eq 1; then - rm -f "$n.gz" - elif test $check -eq 1; then - mv "$n.$$" "$n.Z" && rm -f "$n.gz" - else - gzip -d "$n.gz" && compress "$n" && rm -f "$n.gz" - fi - echo "$n.Z smaller than $n.gz -- unchanged" - - elif test $check -eq 1; then - if gzip -t "$n.gz" ; then - rm -f "$n.$$" "$n.Z" - else - test $pipe -eq 0 && mv "$n.$$" "$n.Z" - rm -f "$n.gz" - echo error while testing $n.gz, $n.Z unchanged - res=1; continue - fi - elif test $pipe -eq 1; then - rm -f "$n.Z" - fi -done -exit $res diff --git a/gnu/usr.bin/gzip-1.1.1/znew.1 b/gnu/usr.bin/gzip-1.1.1/znew.1 deleted file mode 100644 index 644873bdf5ef..000000000000 --- a/gnu/usr.bin/gzip-1.1.1/znew.1 +++ /dev/null @@ -1,36 +0,0 @@ -.TH ZNEW 1 -.SH NAME -znew \- recompress .Z files to .gz files -.SH SYNOPSIS -.B znew -[ -ftv9PK] [ name.Z ... ] -.SH DESCRIPTION -.I Znew -recompresses files from .Z (compress) format to .gz (gzip) format. -.SH OPTIONS -.B \-f -Force recompression from .Z to .gz format even if a .gz file already exists. -.TP -.B \-t -Tests the new files before deleting originals. -.TP -.B \-v -Verbose. Display the name and percentage reduction for each file compressed. -.TP -.B \-9 -Use the slowest compression method (optimal compression). -.TP -.B \-P -Use pipes for the conversion to reduce disk space usage. -.TP -.B \-K -Keep a .Z file when it is smaller than the .gz file -.SH "SEE ALSO" -gzip(1), zmore(1), zcmp(1), zforce(1), gzexe(1), compress(1) -.SH BUGS -.I Znew -does not maintain the time stamp with the -P option if -.I cpmod(1) -is not available and -.I touch(1) -does not support the -r option. diff --git a/gnu/usr.bin/lex/flex.skl b/gnu/usr.bin/lex/flex.skl deleted file mode 100644 index ee65d985b30f..000000000000 --- a/gnu/usr.bin/lex/flex.skl +++ /dev/null @@ -1,1051 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/flex.skl,v 1.3 1993/12/09 19:06:08 jtc Exp $ - */ - -#define FLEX_SCANNER - -%- -#include -%* - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include -%+ -class istream; -%* -#include - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#ifdef __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - - -#ifdef __TURBOC__ -#define YY_USE_CONST -#endif - - -#ifndef YY_USE_CONST -#ifndef const -#define const -#endif -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. - */ -#define YY_START ((yy_start - 1) / 2) - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". Now included - * only for backward compatibility with previous versions of flex. - */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -%- -extern FILE *yyin, *yyout; -%* - -#ifdef __cplusplus -extern "C" { -#endif - extern void *yy_flex_alloc YY_PROTO(( int )); - extern void *yy_flex_realloc YY_PROTO(( void *ptr, int size )); - extern void yy_flex_free YY_PROTO(( void * )); - extern int yywrap YY_PROTO(( void )); - extern void yy_strcpy YY_PROTO(( char *s1, const char *s2 )); -#ifdef __cplusplus - } -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - - -struct yy_buffer_state - { -%- - FILE *yy_input_file; -%+ - istream* yy_input_file; -%* - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int is_interactive; - - /* Whether we've seen an EOF on this buffer. */ - int yy_eof_status; -#define EOF_NOT_SEEN 0 - /* "Pending" happens when the EOF has been seen but there's still - * some text to process. Note that when we actually see the EOF, - * we switch the status back to "not seen" (via yyrestart()), so - * that the user can continue scanning by just pointing yyin at - * a new input file. - */ -#define EOF_PENDING 1 - }; - -%- Standard (non-C++) definition -static YY_BUFFER_STATE yy_current_buffer = 0; -%* - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -%- Standard (non-C++) definition -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -void yyrestart YY_PROTO(( FILE *input_file )); -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -%* - -#define yy_new_buffer yy_create_buffer - -%% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here - -%- Standard (non-C++) definition -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -%* - -%- Standard (non-C++) definition -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -%* -static void yy_fatal_error YY_PROTO(( const char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ -%% code to fiddle yytext and yyleng for yymore() goes here - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ -%% code to copy yytext_ptr to yytext[] goes here, if %array - yy_c_buf_p = yy_cp; - -%% data tables for the DFA and the user's section 1 definitions go here - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -%- Standard (non-C++) definition -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -%+ C++ definition -#define ECHO LexerOutput( yytext, yyleng ) -%* -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ -%% fread()/read() definition of YY_INPUT goes here unless we're doing C++ -%+ C++ definition - if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -%* -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -%- -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -%+ -#define YY_FATAL_ERROR(msg) LexerError( msg ) -%* -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -%- Standard (non-C++) definition -#define YY_DECL int yylex YY_PROTO(( void )) -%+ C++ definition -#define YY_DECL int yyFlexLexer::yylex() -%* -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -%% user's declarations go here - - if ( yy_init ) - { -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) -%- - yyin = stdin; -%+ - yyin = &cin; -%* - - if ( ! yyout ) -%- - yyout = stdout; -%+ - yyout = &cout; -%* - - if ( yy_current_buffer ) - yy_init_buffer( yy_current_buffer, yyin ); - else - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - - yy_init = 0; - } - - while ( 1 ) /* loops until end-of-file is reached */ - { -%% yymore()-related code goes here - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - -%% code to set up and find next match goes here - -yy_find_action: -%% code to find the action number goes here - - YY_DO_BEFORE_ACTION; - -%% code for yylineno update goes here, if -l option - -do_action: /* This label is used only to access EOF actions. */ - -%% debug code goes here - - switch ( yy_act ) - { /* beginning of action switch */ -%% actions go here - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = yy_cp - yytext_ptr - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - - if ( yy_current_buffer->yy_input_file != yyin ) - { - /* This can happen if we scan a file, yywrap() returns - * 1, and then later the user points yyin at a new - * file to resume scanning. We have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input file. - */ - yy_current_buffer->yy_input_file = yyin; - yy_n_chars = yy_current_buffer->yy_n_chars; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { -%% code to do back-up for compressed tables and set up yy_cp goes here - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - -%+ -#ifdef YY_INTERACTIVE -int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) -#else -int yyFlexLexer::LexerInput( char* buf, int max_size ) -#endif - { - if ( yyin->eof() || yyin->fail() ) - return 0; - -#ifdef YY_INTERACTIVE - yyin->get( buf[0] ); - - if ( yyin->eof() ) - return 0; - - if ( yyin->bad() ) - return -1; - - return 1; - -#else - (void) yyin->read( buf, max_size ); - - if ( yyin->bad() ) - return -1; - else - return yyin->gcount(); -#endif - } - -void yyFlexLexer::LexerOutput( const char* buf, int size ) - { - (void) yyout->write( buf, size ); - } -%* - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -%- -static int yy_get_next_buffer() -%+ -int yyFlexLexer::yy_get_next_buffer() -%* - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr - 1; /* copy prev. char, too */ - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = yy_c_buf_p - yytext_ptr; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = yy_c_buf_p - b->yy_ch_buf; - - b->yy_buf_size *= 2; - b->yy_ch_buf = (char *) - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size ); - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move - YY_MORE_ADJ == 1 ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_eof_status = EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - /* yytext begins at the second character in yy_ch_buf; the first - * character is the one which preceded it before reading in the latest - * buffer; it needs to be kept around in case it's a newline, so - * yy_get_previous_state() will have with '^' rules active. - */ - - yytext_ptr = &yy_current_buffer->yy_ch_buf[1]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -%- -static yy_state_type yy_get_previous_state() -%+ -yy_state_type yyFlexLexer::yy_get_previous_state() -%* - { - register yy_state_type yy_current_state; - register char *yy_cp; - -%% code to get the start state into yy_current_state goes here - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { -%% code to find the next state goes here - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -%- -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif -%+ -yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) -%* - { - register int yy_is_jam; -%% code to find the next state, and perhaps do backing up, goes here - - return yy_is_jam ? 0 : yy_current_state; - } - - -%- -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif -%+ -void yyFlexLexer::yyunput( int c, register char* yy_bp ) -%* - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += dest - source; - yy_bp += dest - source; - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - if ( yy_cp > yy_bp && yy_cp[-1] == '\n' ) - yy_cp[-2] = '\n'; - - *--yy_cp = (char) c; - -%% update yylineno here, if doing -l - - /* Note: the formal parameter *must* be called "yy_bp" for this - * macro to now work correctly. - */ - YY_DO_BEFORE_ACTION; /* set up yytext again */ - } - - -%- -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif -%+ -int yyFlexLexer::yyinput() -%* - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - yytext_ptr = yy_c_buf_p; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - { - yy_c_buf_p = - yytext_ptr + YY_MORE_ADJ; - return EOF; - } - - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - break; - - case EOB_ACT_LAST_MATCH: -#ifdef __cplusplus - YY_FATAL_ERROR( - "unexpected last match in yyinput()" ); -#else - YY_FATAL_ERROR( - "unexpected last match in input()" ); -#endif - } - } - } - - c = *yy_c_buf_p; - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - return c; - } - - -%- -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif -%+ -void yyFlexLexer::yyrestart( istream* input_file ) -%* - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -%- -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif -%+ -void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -%* - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -%- -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif -%+ -void yyFlexLexer::yy_load_buffer_state() -%* - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -%- -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif -%+ -YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size ) -%* - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - yy_init_buffer( b, file ); - - return b; - } - - -%- -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif -%+ -void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) -%* - { - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - yy_flex_free( (void *) b->yy_ch_buf ); - yy_flex_free( (void *) b ); - } - - -%- -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif -%+ -void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file ) -%* - { - b->yy_input_file = file; - - /* We put in the '\n' and start reading from [1] so that an - * initial match-at-newline will be true. - */ - - b->yy_ch_buf[0] = '\n'; - b->yy_n_chars = 1; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[1]; - -%- - b->is_interactive = file ? isatty( fileno(file) ) : 0; -%+ - b->is_interactive = 0; -%* - - b->yy_eof_status = EOF_NOT_SEEN; - } - - -%- -#ifdef YY_USE_PROTOS -static void yy_fatal_error( const char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( 1 ); - } - -%+ - -void yyFlexLexer::LexerError( const char msg[] ) - { - cerr << msg << '\n'; - exit( 1 ); - } -%* - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n - YY_MORE_ADJ; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) diff --git a/gnu/usr.bin/lex/flexdef.h b/gnu/usr.bin/lex/flexdef.h deleted file mode 100644 index 3cce94dfd706..000000000000 --- a/gnu/usr.bin/lex/flexdef.h +++ /dev/null @@ -1,895 +0,0 @@ -/* flexdef - definitions file for flex */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * 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. - */ - -/* @(#) $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/flexdef.h,v 1.7 1993/12/09 19:06:10 jtc Exp $ (LBL) */ - -#include -#include - -/* Always be prepared to generate an 8-bit scanner. */ -#define CSIZE 256 -#define Char unsigned char - -/* Size of input alphabet - should be size of ASCII set. */ -#ifndef DEFAULT_CSIZE -#define DEFAULT_CSIZE 128 -#endif - -#ifndef PROTO -#ifdef __STDC__ -#define PROTO(proto) proto -#else -#define PROTO(proto) () -#endif -#endif - -#ifdef VMS -#define unlink delete -#define SHORT_FILE_NAMES -#endif - -#ifdef MS_DOS -#define SHORT_FILE_NAMES -#endif - - -/* Maximum line length we'll have to deal with. */ -#define MAXLINE 2048 - -#ifndef MIN -#define MIN(x,y) ((x) < (y) ? (x) : (y)) -#endif -#ifndef MAX -#define MAX(x,y) ((x) > (y) ? (x) : (y)) -#endif -#ifndef ABS -#define ABS(x) ((x) < 0 ? -(x) : (x)) -#endif - - -/* ANSI C does not guarantee that isascii() is defined */ -#ifndef isascii -#define isascii(c) ((c) <= 0177) -#endif - - -#define true 1 -#define false 0 - - -/* Special chk[] values marking the slots taking by end-of-buffer and action - * numbers. - */ -#define EOB_POSITION -1 -#define ACTION_POSITION -2 - -/* Number of data items per line for -f output. */ -#define NUMDATAITEMS 10 - -/* Number of lines of data in -f output before inserting a blank line for - * readability. - */ -#define NUMDATALINES 10 - -/* Transition_struct_out() definitions. */ -#define TRANS_STRUCT_PRINT_LENGTH 15 - -/* Returns true if an nfa state has an epsilon out-transition slot - * that can be used. This definition is currently not used. - */ -#define FREE_EPSILON(state) \ - (transchar[state] == SYM_EPSILON && \ - trans2[state] == NO_TRANSITION && \ - finalst[state] != state) - -/* Returns true if an nfa state has an epsilon out-transition character - * and both slots are free - */ -#define SUPER_FREE_EPSILON(state) \ - (transchar[state] == SYM_EPSILON && \ - trans1[state] == NO_TRANSITION) \ - -/* Maximum number of NFA states that can comprise a DFA state. It's real - * big because if there's a lot of rules, the initial state will have a - * huge epsilon closure. - */ -#define INITIAL_MAX_DFA_SIZE 750 -#define MAX_DFA_SIZE_INCREMENT 750 - - -/* A note on the following masks. They are used to mark accepting numbers - * as being special. As such, they implicitly limit the number of accepting - * numbers (i.e., rules) because if there are too many rules the rule numbers - * will overload the mask bits. Fortunately, this limit is \large/ (0x2000 == - * 8192) so unlikely to actually cause any problems. A check is made in - * new_rule() to ensure that this limit is not reached. - */ - -/* Mask to mark a trailing context accepting number. */ -#define YY_TRAILING_MASK 0x2000 - -/* Mask to mark the accepting number of the "head" of a trailing context - * rule. - */ -#define YY_TRAILING_HEAD_MASK 0x4000 - -/* Maximum number of rules, as outlined in the above note. */ -#define MAX_RULE (YY_TRAILING_MASK - 1) - - -/* NIL must be 0. If not, its special meaning when making equivalence classes - * (it marks the representative of a given e.c.) will be unidentifiable. - */ -#define NIL 0 - -#define JAM -1 /* to mark a missing DFA transition */ -#define NO_TRANSITION NIL -#define UNIQUE -1 /* marks a symbol as an e.c. representative */ -#define INFINITY -1 /* for x{5,} constructions */ - -#define INITIAL_MAX_CCLS 100 /* max number of unique character classes */ -#define MAX_CCLS_INCREMENT 100 - -/* Size of table holding members of character classes. */ -#define INITIAL_MAX_CCL_TBL_SIZE 500 -#define MAX_CCL_TBL_SIZE_INCREMENT 250 - -#define INITIAL_MAX_RULES 100 /* default maximum number of rules */ -#define MAX_RULES_INCREMENT 100 - -#define INITIAL_MNS 2000 /* default maximum number of nfa states */ -#define MNS_INCREMENT 1000 /* amount to bump above by if it's not enough */ - -#define INITIAL_MAX_DFAS 1000 /* default maximum number of dfa states */ -#define MAX_DFAS_INCREMENT 1000 - -#define JAMSTATE -32766 /* marks a reference to the state that always jams */ - -/* Enough so that if it's subtracted from an NFA state number, the result - * is guaranteed to be negative. - */ -#define MARKER_DIFFERENCE 32000 -#define MAXIMUM_MNS 31999 - -/* Maximum number of nxt/chk pairs for non-templates. */ -#define INITIAL_MAX_XPAIRS 2000 -#define MAX_XPAIRS_INCREMENT 2000 - -/* Maximum number of nxt/chk pairs needed for templates. */ -#define INITIAL_MAX_TEMPLATE_XPAIRS 2500 -#define MAX_TEMPLATE_XPAIRS_INCREMENT 2500 - -#define SYM_EPSILON (CSIZE + 1) /* to mark transitions on the symbol epsilon */ - -#define INITIAL_MAX_SCS 40 /* maximum number of start conditions */ -#define MAX_SCS_INCREMENT 40 /* amount to bump by if it's not enough */ - -#define ONE_STACK_SIZE 500 /* stack of states with only one out-transition */ -#define SAME_TRANS -1 /* transition is the same as "default" entry for state */ - -/* The following percentages are used to tune table compression: - - * The percentage the number of out-transitions a state must be of the - * number of equivalence classes in order to be considered for table - * compaction by using protos. - */ -#define PROTO_SIZE_PERCENTAGE 15 - -/* The percentage the number of homogeneous out-transitions of a state - * must be of the number of total out-transitions of the state in order - * that the state's transition table is first compared with a potential - * template of the most common out-transition instead of with the first - * proto in the proto queue. - */ -#define CHECK_COM_PERCENTAGE 50 - -/* The percentage the number of differences between a state's transition - * table and the proto it was first compared with must be of the total - * number of out-transitions of the state in order to keep the first - * proto as a good match and not search any further. - */ -#define FIRST_MATCH_DIFF_PERCENTAGE 10 - -/* The percentage the number of differences between a state's transition - * table and the most similar proto must be of the state's total number - * of out-transitions to use the proto as an acceptable close match. - */ -#define ACCEPTABLE_DIFF_PERCENTAGE 50 - -/* The percentage the number of homogeneous out-transitions of a state - * must be of the number of total out-transitions of the state in order - * to consider making a template from the state. - */ -#define TEMPLATE_SAME_PERCENTAGE 60 - -/* The percentage the number of differences between a state's transition - * table and the most similar proto must be of the state's total number - * of out-transitions to create a new proto from the state. - */ -#define NEW_PROTO_DIFF_PERCENTAGE 20 - -/* The percentage the total number of out-transitions of a state must be - * of the number of equivalence classes in order to consider trying to - * fit the transition table into "holes" inside the nxt/chk table. - */ -#define INTERIOR_FIT_PERCENTAGE 15 - -/* Size of region set aside to cache the complete transition table of - * protos on the proto queue to enable quick comparisons. - */ -#define PROT_SAVE_SIZE 2000 - -#define MSP 50 /* maximum number of saved protos (protos on the proto queue) */ - -/* Maximum number of out-transitions a state can have that we'll rummage - * around through the interior of the internal fast table looking for a - * spot for it. - */ -#define MAX_XTIONS_FULL_INTERIOR_FIT 4 - -/* Maximum number of rules which will be reported as being associated - * with a DFA state. - */ -#define MAX_ASSOC_RULES 100 - -/* Number that, if used to subscript an array, has a good chance of producing - * an error; should be small enough to fit into a short. - */ -#define BAD_SUBSCRIPT -32767 - -/* Absolute value of largest number that can be stored in a short, with a - * bit of slop thrown in for general paranoia. - */ -#define MAX_SHORT 32700 - - -/* Declarations for global variables. */ - -/* Variables for symbol tables: - * sctbl - start-condition symbol table - * ndtbl - name-definition symbol table - * ccltab - character class text symbol table - */ - -struct hash_entry - { - struct hash_entry *prev, *next; - char *name; - char *str_val; - int int_val; - } ; - -typedef struct hash_entry **hash_table; - -#define NAME_TABLE_HASH_SIZE 101 -#define START_COND_HASH_SIZE 101 -#define CCL_HASH_SIZE 101 - -extern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; -extern struct hash_entry *sctbl[START_COND_HASH_SIZE]; -extern struct hash_entry *ccltab[CCL_HASH_SIZE]; - - -/* Variables for flags: - * printstats - if true (-v), dump statistics - * syntaxerror - true if a syntax error has been found - * eofseen - true if we've seen an eof in the input file - * ddebug - if true (-d), make a "debug" scanner - * trace - if true (-T), trace processing - * nowarn - if true (-w), do not generate warnings - * spprdflt - if true (-s), suppress the default rule - * interactive - if true (-I), generate an interactive scanner - * caseins - if true (-i), generate a case-insensitive scanner - * lex_compat - if true (-l), maximize compatibility with AT&T lex - * useecs - if true (-Ce flag), use equivalence classes - * fulltbl - if true (-Cf flag), don't compress the DFA state table - * usemecs - if true (-Cm flag), use meta-equivalence classes - * fullspd - if true (-F flag), use Jacobson method of table representation - * gen_line_dirs - if true (i.e., no -L flag), generate #line directives - * performance_report - if > 0 (i.e., -p flag), generate a report relating - * to scanner performance; if > 1 (-p -p), report on minor performance - * problems, too - * backing_up_report - if true (i.e., -b flag), generate "lex.backup" file - * listing backing-up states - * C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class; - * otherwise, a standard C scanner - * long_align - if true (-Ca flag), favor long-word alignment. - * use_read - if true (-f, -F, or -Cr) then use read() for scanner input; - * otherwise, use fread(). - * yytext_is_array - if true (i.e., %array directive), then declare - * yytext as a array instead of a character pointer. Nice and inefficient. - * csize - size of character set for the scanner we're generating; - * 128 for 7-bit chars and 256 for 8-bit - * yymore_used - if true, yymore() is used in input rules - * reject - if true, generate back-up tables for REJECT macro - * real_reject - if true, scanner really uses REJECT (as opposed to just - * having "reject" set for variable trailing context) - * continued_action - true if this rule's action is to "fall through" to - * the next rule's action (i.e., the '|' action) - * yymore_really_used - has a REALLY_xxx value indicating whether a - * %used or %notused was used with yymore() - * reject_really_used - same for REJECT - */ - -extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; -extern int interactive, caseins, lex_compat, useecs, fulltbl, usemecs; -extern int fullspd, gen_line_dirs, performance_report, backing_up_report; -extern int C_plus_plus, long_align, use_read, yytext_is_array, csize; -extern int yymore_used, reject, real_reject, continued_action; - -#define REALLY_NOT_DETERMINED 0 -#define REALLY_USED 1 -#define REALLY_NOT_USED 2 -extern int yymore_really_used, reject_really_used; - - -/* Variables used in the flex input routines: - * datapos - characters on current output line - * dataline - number of contiguous lines of data in current data - * statement. Used to generate readable -f output - * linenum - current input line number - * skelfile - the skeleton file - * skel - compiled-in skeleton array - * skel_ind - index into "skel" array, if skelfile is nil - * yyin - input file - * backing_up_file - file to summarize backing-up states to - * infilename - name of input file - * input_files - array holding names of input files - * num_input_files - size of input_files array - * program_name - name with which program was invoked - * - * action_array - array to hold the rule actions - * action_size - size of action_array - * defs1_offset - index where the user's section 1 definitions start - * in action_array - * prolog_offset - index where the prolog starts in action_array - * action_offset - index where the non-prolog starts in action_array - * action_index - index where the next action should go, with respect - * to "action_array" - */ - -extern int datapos, dataline, linenum; -extern FILE *skelfile, *yyin, *backing_up_file; -extern char *skel[]; -extern int skel_ind; -extern char *infilename; -extern char **input_files; -extern int num_input_files; -extern char *program_name; - -extern char *action_array; -extern int action_size; -extern int defs1_offset, prolog_offset, action_offset, action_index; - - -/* Variables for stack of states having only one out-transition: - * onestate - state number - * onesym - transition symbol - * onenext - target state - * onedef - default base entry - * onesp - stack pointer - */ - -extern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; -extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; - - -/* Variables for nfa machine data: - * current_mns - current maximum on number of NFA states - * num_rules - number of the last accepting state; also is number of - * rules created so far - * num_eof_rules - number of <> rules - * default_rule - number of the default rule - * current_max_rules - current maximum number of rules - * lastnfa - last nfa state number created - * firstst - physically the first state of a fragment - * lastst - last physical state of fragment - * finalst - last logical state of fragment - * transchar - transition character - * trans1 - transition state - * trans2 - 2nd transition state for epsilons - * accptnum - accepting number - * assoc_rule - rule associated with this NFA state (or 0 if none) - * state_type - a STATE_xxx type identifying whether the state is part - * of a normal rule, the leading state in a trailing context - * rule (i.e., the state which marks the transition from - * recognizing the text-to-be-matched to the beginning of - * the trailing context), or a subsequent state in a trailing - * context rule - * rule_type - a RULE_xxx type identifying whether this a ho-hum - * normal rule or one which has variable head & trailing - * context - * rule_linenum - line number associated with rule - * rule_useful - true if we've determined that the rule can be matched - */ - -extern int current_mns, num_rules, num_eof_rules, default_rule; -extern int current_max_rules, lastnfa; -extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2; -extern int *accptnum, *assoc_rule, *state_type; -extern int *rule_type, *rule_linenum, *rule_useful; - -/* Different types of states; values are useful as masks, as well, for - * routines like check_trailing_context(). - */ -#define STATE_NORMAL 0x1 -#define STATE_TRAILING_CONTEXT 0x2 - -/* Global holding current type of state we're making. */ - -extern int current_state_type; - -/* Different types of rules. */ -#define RULE_NORMAL 0 -#define RULE_VARIABLE 1 - -/* True if the input rules include a rule with both variable-length head - * and trailing context, false otherwise. - */ -extern int variable_trailing_context_rules; - - -/* Variables for protos: - * numtemps - number of templates created - * numprots - number of protos created - * protprev - backlink to a more-recently used proto - * protnext - forward link to a less-recently used proto - * prottbl - base/def table entry for proto - * protcomst - common state of proto - * firstprot - number of the most recently used proto - * lastprot - number of the least recently used proto - * protsave contains the entire state array for protos - */ - -extern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP]; -extern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE]; - - -/* Variables for managing equivalence classes: - * numecs - number of equivalence classes - * nextecm - forward link of Equivalence Class members - * ecgroup - class number or backward link of EC members - * nummecs - number of meta-equivalence classes (used to compress - * templates) - * tecfwd - forward link of meta-equivalence classes members - * tecbck - backward link of MEC's - */ - -/* Reserve enough room in the equivalence class arrays so that we - * can use the CSIZE'th element to hold equivalence class information - * for the NUL character. Later we'll move this information into - * the 0th element. - */ -extern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs; - -/* Meta-equivalence classes are indexed starting at 1, so it's possible - * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1 - * slots total (since the arrays are 0-based). nextecm[] and ecgroup[] - * don't require the extra position since they're indexed from 1 .. CSIZE - 1. - */ -extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1]; - - -/* Variables for start conditions: - * lastsc - last start condition created - * current_max_scs - current limit on number of start conditions - * scset - set of rules active in start condition - * scbol - set of rules active only at the beginning of line in a s.c. - * scxclu - true if start condition is exclusive - * sceof - true if start condition has EOF rule - * scname - start condition name - * actvsc - stack of active start conditions for the current rule; - * a negative entry means that the start condition is *not* - * active for the current rule. Start conditions may appear - * multiple times on the stack; the entry for it closest - * to the top of the stack (i.e., actvsc[actvp]) is the - * one to use. Others are present from "{" scoping - * constructs. - */ - -extern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc; -extern char **scname; - - -/* Variables for dfa machine data: - * current_max_dfa_size - current maximum number of NFA states in DFA - * current_max_xpairs - current maximum number of non-template xtion pairs - * current_max_template_xpairs - current maximum number of template pairs - * current_max_dfas - current maximum number DFA states - * lastdfa - last dfa state number created - * nxt - state to enter upon reading character - * chk - check value to see if "nxt" applies - * tnxt - internal nxt table for templates - * base - offset into "nxt" for given state - * def - where to go if "chk" disallows "nxt" entry - * nultrans - NUL transition for each state - * NUL_ec - equivalence class of the NUL character - * tblend - last "nxt/chk" table entry being used - * firstfree - first empty entry in "nxt/chk" table - * dss - nfa state set for each dfa - * dfasiz - size of nfa state set for each dfa - * dfaacc - accepting set for each dfa state (if using REJECT), or accepting - * number, if not - * accsiz - size of accepting set for each dfa state - * dhash - dfa state hash value - * numas - number of DFA accepting states created; note that this - * is not necessarily the same value as num_rules, which is the analogous - * value for the NFA - * numsnpairs - number of state/nextstate transition pairs - * jambase - position in base/def where the default jam table starts - * jamstate - state number corresponding to "jam" state - * end_of_buffer_state - end-of-buffer dfa state number - */ - -extern int current_max_dfa_size, current_max_xpairs; -extern int current_max_template_xpairs, current_max_dfas; -extern int lastdfa, *nxt, *chk, *tnxt; -extern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz; -extern union dfaacc_union - { - int *dfaacc_set; - int dfaacc_state; - } *dfaacc; -extern int *accsiz, *dhash, numas; -extern int numsnpairs, jambase, jamstate; -extern int end_of_buffer_state; - -/* Variables for ccl information: - * lastccl - ccl index of the last created ccl - * current_maxccls - current limit on the maximum number of unique ccl's - * cclmap - maps a ccl index to its set pointer - * ccllen - gives the length of a ccl - * cclng - true for a given ccl if the ccl is negated - * cclreuse - counts how many times a ccl is re-used - * current_max_ccl_tbl_size - current limit on number of characters needed - * to represent the unique ccl's - * ccltbl - holds the characters in each ccl - indexed by cclmap - */ - -extern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse; -extern int current_max_ccl_tbl_size; -extern Char *ccltbl; - - -/* Variables for miscellaneous information: - * nmstr - last NAME scanned by the scanner - * sectnum - section number currently being parsed - * nummt - number of empty nxt/chk table entries - * hshcol - number of hash collisions detected by snstods - * dfaeql - number of times a newly created dfa was equal to an old one - * numeps - number of epsilon NFA states created - * eps2 - number of epsilon states which have 2 out-transitions - * num_reallocs - number of times it was necessary to realloc() a group - * of arrays - * tmpuses - number of DFA states that chain to templates - * totnst - total number of NFA states used to make DFA states - * peakpairs - peak number of transition pairs we had to store internally - * numuniq - number of unique transitions - * numdup - number of duplicate transitions - * hshsave - number of hash collisions saved by checking number of states - * num_backing_up - number of DFA states requiring backing up - * bol_needed - whether scanner needs beginning-of-line recognition - */ - -extern char nmstr[MAXLINE]; -extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; -extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; -extern int num_backing_up, bol_needed; - -void *allocate_array PROTO((int, int)); -void *reallocate_array PROTO((void*, int, int)); - -void *yy_flex_alloc PROTO((int)); -void *yy_flex_realloc PROTO((void*, int)); -void yy_flex_free PROTO((void*)); -int yy_strcmp PROTO(( const char *s1, const char *s2 )); -void yy_strcpy PROTO(( char *s1, const char *s2 )); -int yy_strlen PROTO(( const char *s )); - -#define allocate_integer_array(size) \ - (int *) allocate_array( size, sizeof( int ) ) - -#define reallocate_integer_array(array,size) \ - (int *) reallocate_array( (void *) array, size, sizeof( int ) ) - -#define allocate_int_ptr_array(size) \ - (int **) allocate_array( size, sizeof( int * ) ) - -#define allocate_char_ptr_array(size) \ - (char **) allocate_array( size, sizeof( char * ) ) - -#define allocate_dfaacc_union(size) \ - (union dfaacc_union *) \ - allocate_array( size, sizeof( union dfaacc_union ) ) - -#define reallocate_int_ptr_array(array,size) \ - (int **) reallocate_array( (void *) array, size, sizeof( int * ) ) - -#define reallocate_char_ptr_array(array,size) \ - (char **) reallocate_array( (void *) array, size, sizeof( char * ) ) - -#define reallocate_dfaacc_union(array, size) \ - (union dfaacc_union *) \ - reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) ) - -#define allocate_character_array(size) \ - (char *) allocate_array( size, sizeof( char ) ) - -#define reallocate_character_array(array,size) \ - (char *) reallocate_array( (void *) array, size, sizeof( char ) ) - -#define allocate_Character_array(size) \ - (Char *) allocate_array( size, sizeof( Char ) ) - -#define reallocate_Character_array(array,size) \ - (Char *) reallocate_array( (void *) array, size, sizeof( Char ) ) - - -/* Used to communicate between scanner and parser. The type should really - * be YYSTYPE, but we can't easily get our hands on it. - */ -extern int yylval; - - -/* External functions that are cross-referenced among the flex source files. */ - - -/* from file ccl.c */ - -extern void ccladd PROTO((int, int)); /* add a single character to a ccl */ -extern int cclinit PROTO((void)); /* make an empty ccl */ -extern void cclnegate PROTO((int)); /* negate a ccl */ - -/* List the members of a set of characters in CCL form. */ -extern void list_character_set PROTO((FILE*, int[])); - - -/* from file dfa.c */ - -/* Increase the maximum number of dfas. */ -extern void increase_max_dfas PROTO((void)); - -extern void ntod PROTO((void)); /* convert a ndfa to a dfa */ - - -/* from file ecs.c */ - -/* Convert character classes to set of equivalence classes. */ -extern void ccl2ecl PROTO((void)); - -/* Associate equivalence class numbers with class members. */ -extern int cre8ecs PROTO((int[], int[], int)); - -/* Update equivalence classes based on character class transitions. */ -extern void mkeccl PROTO((Char[], int, int[], int[], int, int)); - -/* Create equivalence class for single character. */ -extern void mkechar PROTO((int, int[], int[])); - - -/* from file gen.c */ - -extern void make_tables PROTO((void)); /* generate transition tables */ - - -/* from file main.c */ - -extern void flexend PROTO((int)); -extern void usage PROTO((void)); - - -/* from file misc.c */ - -/* Add the given text to the stored actions. */ -extern void add_action PROTO(( char *new_text )); - -/* True if a string is all lower case. */ -extern int all_lower PROTO((register char *)); - -/* True if a string is all upper case. */ -extern int all_upper PROTO((register char *)); - -/* Bubble sort an integer array. */ -extern void bubble PROTO((int [], int)); - -/* Check a character to make sure it's in the expected range. */ -extern void check_char PROTO((int c)); - -/* Shell sort a character array. */ -extern void cshell PROTO((Char [], int, int)); - -/* Finish up a block of data declarations. */ -extern void dataend PROTO((void)); - -/* Report an error message and terminate. */ -extern void flexerror PROTO((char[])); - -/* Report a fatal error message and terminate. */ -extern void flexfatal PROTO((char[])); - -/* Report an error message formatted with one integer argument. */ -extern void lerrif PROTO((char[], int)); - -/* Report an error message formatted with one string argument. */ -extern void lerrsf PROTO((char[], char[])); - -/* Spit out a "# line" statement. */ -extern void line_directive_out PROTO((FILE*)); - -/* Mark the current position in the action array as the end of the section 1 - * user defs. - */ -extern void mark_defs1 PROTO((void)); - -/* Mark the current position in the action array as the end of the prolog. */ -extern void mark_prolog PROTO((void)); - -/* Generate a data statment for a two-dimensional array. */ -extern void mk2data PROTO((int)); - -extern void mkdata PROTO((int)); /* generate a data statement */ - -/* Return the integer represented by a string of digits. */ -extern int myctoi PROTO((char [])); - -/* Return a printable version of the given character, which might be - * 8-bit. - */ -extern char *readable_form PROTO((int)); - -/* Write out one section of the skeleton file. */ -extern void skelout PROTO((void)); - -/* Output a yy_trans_info structure. */ -extern void transition_struct_out PROTO((int, int)); - -/* Only needed when using certain broken versions of bison to build parse.c. */ -extern void *yy_flex_xmalloc PROTO(( int )); - -/* Set a region of memory to 0. */ -extern void zero_out PROTO((char *, int)); - - -/* from file nfa.c */ - -/* Add an accepting state to a machine. */ -extern void add_accept PROTO((int, int)); - -/* Make a given number of copies of a singleton machine. */ -extern int copysingl PROTO((int, int)); - -/* Debugging routine to write out an nfa. */ -extern void dumpnfa PROTO((int)); - -/* Finish up the processing for a rule. */ -extern void finish_rule PROTO((int, int, int, int)); - -/* Connect two machines together. */ -extern int link_machines PROTO((int, int)); - -/* Mark each "beginning" state in a machine as being a "normal" (i.e., - * not trailing context associated) state. - */ -extern void mark_beginning_as_normal PROTO((register int)); - -/* Make a machine that branches to two machines. */ -extern int mkbranch PROTO((int, int)); - -extern int mkclos PROTO((int)); /* convert a machine into a closure */ -extern int mkopt PROTO((int)); /* make a machine optional */ - -/* Make a machine that matches either one of two machines. */ -extern int mkor PROTO((int, int)); - -/* Convert a machine into a positive closure. */ -extern int mkposcl PROTO((int)); - -extern int mkrep PROTO((int, int, int)); /* make a replicated machine */ - -/* Create a state with a transition on a given symbol. */ -extern int mkstate PROTO((int)); - -extern void new_rule PROTO((void)); /* initialize for a new rule */ - - -/* from file parse.y */ - -/* Write out a message formatted with one string, pinpointing its location. */ -extern void format_pinpoint_message PROTO((char[], char[])); - -/* Write out a message, pinpointing its location. */ -extern void pinpoint_message PROTO((char[])); - -/* Write out a warning, pinpointing it at the given line. */ -void line_warning PROTO(( char[], int )); - -/* Write out a message, pinpointing it at the given line. */ -void line_pinpoint PROTO(( char[], int )); - -/* Report a formatted syntax error. */ -extern void format_synerr PROTO((char [], char[])); -extern void synerr PROTO((char [])); /* report a syntax error */ -extern void warn PROTO((char [])); /* report a warning */ -extern int yyparse PROTO((void)); /* the YACC parser */ - - -/* from file scan.l */ - -/* The Flex-generated scanner for flex. */ -extern int flexscan PROTO((void)); - -/* Open the given file (if NULL, stdin) for scanning. */ -extern void set_input_file PROTO((char*)); - -/* Wrapup a file in the lexical analyzer. */ -extern int yywrap PROTO((void)); - - -/* from file sym.c */ - -/* Save the text of a character class. */ -extern void cclinstal PROTO ((Char [], int)); - -/* Lookup the number associated with character class. */ -extern int ccllookup PROTO((Char [])); - -extern void ndinstal PROTO((char[], Char[])); /* install a name definition */ -/* Increase maximum number of SC's. */ -extern void scextend PROTO((void)); -extern void scinstal PROTO((char[], int)); /* make a start condition */ - -/* Lookup the number associated with a start condition. */ -extern int sclookup PROTO((char[])); - - -/* from file tblcmp.c */ - -/* Build table entries for dfa state. */ -extern void bldtbl PROTO((int[], int, int, int, int)); - -extern void cmptmps PROTO((void)); /* compress template table entries */ -extern void expand_nxt_chk PROTO((void)); /* increase nxt/chk arrays */ -extern void inittbl PROTO((void)); /* initialize transition tables */ -/* Make the default, "jam" table entries. */ -extern void mkdeftbl PROTO((void)); - -/* Create table entries for a state (or state fragment) which has - * only one out-transition. - */ -extern void mk1tbl PROTO((int, int, int, int)); - -/* Place a state into full speed transition table. */ -extern void place_state PROTO((int*, int, int)); - -/* Save states with only one out-transition to be processed later. */ -extern void stack1 PROTO((int, int, int, int)); - - -/* from file yylex.c */ - -extern int yylex PROTO((void)); diff --git a/gnu/usr.bin/lex/flexdoc.1 b/gnu/usr.bin/lex/flexdoc.1 deleted file mode 100644 index 6bd57d2561e9..000000000000 --- a/gnu/usr.bin/lex/flexdoc.1 +++ /dev/null @@ -1,3059 +0,0 @@ -.TH FLEXDOC 1 "November 1993" "Version 2.4" -.SH NAME -flexdoc \- documentation for flex, fast lexical analyzer generator -.SH SYNOPSIS -.B flex -.B [\-bcdfhilnpstvwBFILTV78+ \-C[aefFmr] \-Pprefix \-Sskeleton] -.I [filename ...] -.SH DESCRIPTION -.I flex -is a tool for generating -.I scanners: -programs which recognized lexical patterns in text. -.I flex -reads -the given input files, or its standard input if no file names are given, -for a description of a scanner to generate. The description is in -the form of pairs -of regular expressions and C code, called -.I rules. flex -generates as output a C source file, -.B lex.yy.c, -which defines a routine -.B yylex(). -This file is compiled and linked with the -.B \-lfl -library to produce an executable. When the executable is run, -it analyzes its input for occurrences -of the regular expressions. Whenever it finds one, it executes -the corresponding C code. -.SH SOME SIMPLE EXAMPLES -.PP -First some simple examples to get the flavor of how one uses -.I flex. -The following -.I flex -input specifies a scanner which whenever it encounters the string -"username" will replace it with the user's login name: -.nf - - %% - username printf( "%s", getlogin() ); - -.fi -By default, any text not matched by a -.I flex -scanner -is copied to the output, so the net effect of this scanner is -to copy its input file to its output with each occurrence -of "username" expanded. -In this input, there is just one rule. "username" is the -.I pattern -and the "printf" is the -.I action. -The "%%" marks the beginning of the rules. -.PP -Here's another simple example: -.nf - - int num_lines = 0, num_chars = 0; - - %% - \\n ++num_lines; ++num_chars; - . ++num_chars; - - %% - main() - { - yylex(); - printf( "# of lines = %d, # of chars = %d\\n", - num_lines, num_chars ); - } - -.fi -This scanner counts the number of characters and the number -of lines in its input (it produces no output other than the -final report on the counts). The first line -declares two globals, "num_lines" and "num_chars", which are accessible -both inside -.B yylex() -and in the -.B main() -routine declared after the second "%%". There are two rules, one -which matches a newline ("\\n") and increments both the line count and -the character count, and one which matches any character other than -a newline (indicated by the "." regular expression). -.PP -A somewhat more complicated example: -.nf - - /* scanner for a toy Pascal-like language */ - - %{ - /* need this for the call to atof() below */ - #include - %} - - DIGIT [0-9] - ID [a-z][a-z0-9]* - - %% - - {DIGIT}+ { - printf( "An integer: %s (%d)\\n", yytext, - atoi( yytext ) ); - } - - {DIGIT}+"."{DIGIT}* { - printf( "A float: %s (%g)\\n", yytext, - atof( yytext ) ); - } - - if|then|begin|end|procedure|function { - printf( "A keyword: %s\\n", yytext ); - } - - {ID} printf( "An identifier: %s\\n", yytext ); - - "+"|"-"|"*"|"/" printf( "An operator: %s\\n", yytext ); - - "{"[^}\\n]*"}" /* eat up one-line comments */ - - [ \\t\\n]+ /* eat up whitespace */ - - . printf( "Unrecognized character: %s\\n", yytext ); - - %% - - main( argc, argv ) - int argc; - char **argv; - { - ++argv, --argc; /* skip over program name */ - if ( argc > 0 ) - yyin = fopen( argv[0], "r" ); - else - yyin = stdin; - - yylex(); - } - -.fi -This is the beginnings of a simple scanner for a language like -Pascal. It identifies different types of -.I tokens -and reports on what it has seen. -.PP -The details of this example will be explained in the following -sections. -.SH FORMAT OF THE INPUT FILE -The -.I flex -input file consists of three sections, separated by a line with just -.B %% -in it: -.nf - - definitions - %% - rules - %% - user code - -.fi -The -.I definitions -section contains declarations of simple -.I name -definitions to simplify the scanner specification, and declarations of -.I start conditions, -which are explained in a later section. -.PP -Name definitions have the form: -.nf - - name definition - -.fi -The "name" is a word beginning with a letter or an underscore ('_') -followed by zero or more letters, digits, '_', or '-' (dash). -The definition is taken to begin at the first non-white-space character -following the name and continuing to the end of the line. -The definition can subsequently be referred to using "{name}", which -will expand to "(definition)". For example, -.nf - - DIGIT [0-9] - ID [a-z][a-z0-9]* - -.fi -defines "DIGIT" to be a regular expression which matches a -single digit, and -"ID" to be a regular expression which matches a letter -followed by zero-or-more letters-or-digits. -A subsequent reference to -.nf - - {DIGIT}+"."{DIGIT}* - -.fi -is identical to -.nf - - ([0-9])+"."([0-9])* - -.fi -and matches one-or-more digits followed by a '.' followed -by zero-or-more digits. -.PP -The -.I rules -section of the -.I flex -input contains a series of rules of the form: -.nf - - pattern action - -.fi -where the pattern must be unindented and the action must begin -on the same line. -.PP -See below for a further description of patterns and actions. -.PP -Finally, the user code section is simply copied to -.B lex.yy.c -verbatim. -It is used for companion routines which call or are called -by the scanner. The presence of this section is optional; -if it is missing, the second -.B %% -in the input file may be skipped, too. -.PP -In the definitions and rules sections, any -.I indented -text or text enclosed in -.B %{ -and -.B %} -is copied verbatim to the output (with the %{}'s removed). -The %{}'s must appear unindented on lines by themselves. -.PP -In the rules section, -any indented or %{} text appearing before the -first rule may be used to declare variables -which are local to the scanning routine and (after the declarations) -code which is to be executed whenever the scanning routine is entered. -Other indented or %{} text in the rule section is still copied to the output, -but its meaning is not well-defined and it may well cause compile-time -errors (this feature is present for -.I POSIX -compliance; see below for other such features). -.PP -In the definitions section (but not in the rules section), -an unindented comment (i.e., a line -beginning with "/*") is also copied verbatim to the output up -to the next "*/". -.SH PATTERNS -The patterns in the input are written using an extended set of regular -expressions. These are: -.nf - - x match the character 'x' - . any character except newline - [xyz] a "character class"; in this case, the pattern - matches either an 'x', a 'y', or a 'z' - [abj-oZ] a "character class" with a range in it; matches - an 'a', a 'b', any letter from 'j' through 'o', - or a 'Z' - [^A-Z] a "negated character class", i.e., any character - but those in the class. In this case, any - character EXCEPT an uppercase letter. - [^A-Z\\n] any character EXCEPT an uppercase letter or - a newline - r* zero or more r's, where r is any regular expression - r+ one or more r's - r? zero or one r's (that is, "an optional r") - r{2,5} anywhere from two to five r's - r{2,} two or more r's - r{4} exactly 4 r's - {name} the expansion of the "name" definition - (see above) - "[xyz]\\"foo" - the literal string: [xyz]"foo - \\X if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v', - then the ANSI-C interpretation of \\x. - Otherwise, a literal 'X' (used to escape - operators such as '*') - \\123 the character with octal value 123 - \\x2a the character with hexadecimal value 2a - (r) match an r; parentheses are used to override - precedence (see below) - - - rs the regular expression r followed by the - regular expression s; called "concatenation" - - - r|s either an r or an s - - - r/s an r but only if it is followed by an s. The - s is not part of the matched text. This type - of pattern is called as "trailing context". - ^r an r, but only at the beginning of a line - r$ an r, but only at the end of a line. Equivalent - to "r/\\n". - - - r an r, but only in start condition s (see - below for discussion of start conditions) - r - same, but in any of start conditions s1, - s2, or s3 - <*>r an r in any start condition, even an exclusive one. - - - <> an end-of-file - <> - an end-of-file when in start condition s1 or s2 - -.fi -Note that inside of a character class, all regular expression operators -lose their special meaning except escape ('\\') and the character class -operators, '-', ']', and, at the beginning of the class, '^'. -.PP -The regular expressions listed above are grouped according to -precedence, from highest precedence at the top to lowest at the bottom. -Those grouped together have equal precedence. For example, -.nf - - foo|bar* - -.fi -is the same as -.nf - - (foo)|(ba(r*)) - -.fi -since the '*' operator has higher precedence than concatenation, -and concatenation higher than alternation ('|'). This pattern -therefore matches -.I either -the string "foo" -.I or -the string "ba" followed by zero-or-more r's. -To match "foo" or zero-or-more "bar"'s, use: -.nf - - foo|(bar)* - -.fi -and to match zero-or-more "foo"'s-or-"bar"'s: -.nf - - (foo|bar)* - -.fi -.PP -Some notes on patterns: -.IP - -A negated character class such as the example "[^A-Z]" -above -.I will match a newline -unless "\\n" (or an equivalent escape sequence) is one of the -characters explicitly present in the negated character class -(e.g., "[^A-Z\\n]"). This is unlike how many other regular -expression tools treat negated character classes, but unfortunately -the inconsistency is historically entrenched. -Matching newlines means that a pattern like [^"]* can match the entire -input unless there's another quote in the input. -.IP - -A rule can have at most one instance of trailing context (the '/' operator -or the '$' operator). The start condition, '^', and "<>" patterns -can only occur at the beginning of a pattern, and, as well as with '/' and '$', -cannot be grouped inside parentheses. A '^' which does not occur at -the beginning of a rule or a '$' which does not occur at the end of -a rule loses its special properties and is treated as a normal character. -.IP -The following are illegal: -.nf - - foo/bar$ - foobar - -.fi -Note that the first of these, can be written "foo/bar\\n". -.IP -The following will result in '$' or '^' being treated as a normal character: -.nf - - foo|(bar$) - foo|^bar - -.fi -If what's wanted is a "foo" or a bar-followed-by-a-newline, the following -could be used (the special '|' action is explained below): -.nf - - foo | - bar$ /* action goes here */ - -.fi -A similar trick will work for matching a foo or a -bar-at-the-beginning-of-a-line. -.SH HOW THE INPUT IS MATCHED -When the generated scanner is run, it analyzes its input looking -for strings which match any of its patterns. If it finds more than -one match, it takes the one matching the most text (for trailing -context rules, this includes the length of the trailing part, even -though it will then be returned to the input). If it finds two -or more matches of the same length, the -rule listed first in the -.I flex -input file is chosen. -.PP -Once the match is determined, the text corresponding to the match -(called the -.I token) -is made available in the global character pointer -.B yytext, -and its length in the global integer -.B yyleng. -The -.I action -corresponding to the matched pattern is then executed (a more -detailed description of actions follows), and then the remaining -input is scanned for another match. -.PP -If no match is found, then the -.I default rule -is executed: the next character in the input is considered matched and -copied to the standard output. Thus, the simplest legal -.I flex -input is: -.nf - - %% - -.fi -which generates a scanner that simply copies its input (one character -at a time) to its output. -.PP -Note that -.B yytext -can be defined in two different ways: either as a character -.I pointer -or as a character -.I array. -You can control which definition -.I flex -uses by including one of the special directives -.B %pointer -or -.B %array -in the first (definitions) section of your flex input. The default is -.B %pointer, -unless you use the -.B -l -lex compatibility option, in which case -.B yytext -will be an array. -The advantage of using -.B %pointer -is substantially faster scanning and no buffer overflow when matching -very large tokens (unless you run out of dynamic memory). The disadvantage -is that you are restricted in how your actions can modify -.B yytext -(see the next section), and calls to the -.B input() -and -.B unput() -functions destroy the present contents of -.B yytext, -which can be a considerable porting headache when moving between different -.I lex -versions. -.PP -The advantage of -.B %array -is that you can then modify -.B yytext -to your heart's content, and calls to -.B input() -and -.B unput() -do not destroy -.B yytext -(see below). Furthermore, existing -.I lex -programs sometimes access -.B yytext -externally using declarations of the form: -.nf - extern char yytext[]; -.fi -This definition is erroneous when used with -.B %pointer, -but correct for -.B %array. -.PP -.B %array -defines -.B yytext -to be an array of -.B YYLMAX -characters, which defaults to a fairly large value. You can change -the size by simply #define'ing -.B YYLMAX -to a different value in the first section of your -.I flex -input. As mentioned above, with -.B %pointer -yytext grows dynamically to accomodate large tokens. While this means your -.B %pointer -scanner can accomodate very large tokens (such as matching entire blocks -of comments), bear in mind that each time the scanner must resize -.B yytext -it also must rescan the entire token from the beginning, so matching such -tokens can prove slow. -.B yytext -presently does -.I not -dynamically grow if a call to -.B unput() -results in too much text being pushed back; instead, a run-time error results. -.PP -Also note that you cannot use -.B %array -with C++ scanner classes -(the -.B \-+ -option; see below). -.SH ACTIONS -Each pattern in a rule has a corresponding action, which can be any -arbitrary C statement. The pattern ends at the first non-escaped -whitespace character; the remainder of the line is its action. If the -action is empty, then when the pattern is matched the input token -is simply discarded. For example, here is the specification for a program -which deletes all occurrences of "zap me" from its input: -.nf - - %% - "zap me" - -.fi -(It will copy all other characters in the input to the output since -they will be matched by the default rule.) -.PP -Here is a program which compresses multiple blanks and tabs down to -a single blank, and throws away whitespace found at the end of a line: -.nf - - %% - [ \\t]+ putchar( ' ' ); - [ \\t]+$ /* ignore this token */ - -.fi -.PP -If the action contains a '{', then the action spans till the balancing '}' -is found, and the action may cross multiple lines. -.I flex -knows about C strings and comments and won't be fooled by braces found -within them, but also allows actions to begin with -.B %{ -and will consider the action to be all the text up to the next -.B %} -(regardless of ordinary braces inside the action). -.PP -An action consisting solely of a vertical bar ('|') means "same as -the action for the next rule." See below for an illustration. -.PP -Actions can include arbitrary C code, including -.B return -statements to return a value to whatever routine called -.B yylex(). -Each time -.B yylex() -is called it continues processing tokens from where it last left -off until it either reaches -the end of the file or executes a return. -.PP -Actions are free to modify -.B yytext -except for lengthening it (adding -characters to its end--these will overwrite later characters in the -input stream). Modifying the final character of yytext may alter -whether when scanning resumes rules anchored with '^' are active. -Specifically, changing the final character of yytext to a newline will -activate such rules on the next scan, and changing it to anything else -will deactivate the rules. Users should not rely on this behavior being -present in future releases. Finally, note that none of this paragraph -applies when using -.B %array -(see above). -.PP -Actions are free to modify -.B yyleng -except they should not do so if the action also includes use of -.B yymore() -(see below). -.PP -There are a number of special directives which can be included within -an action: -.IP - -.B ECHO -copies yytext to the scanner's output. -.IP - -.B BEGIN -followed by the name of a start condition places the scanner in the -corresponding start condition (see below). -.IP - -.B REJECT -directs the scanner to proceed on to the "second best" rule which matched the -input (or a prefix of the input). The rule is chosen as described -above in "How the Input is Matched", and -.B yytext -and -.B yyleng -set up appropriately. -It may either be one which matched as much text -as the originally chosen rule but came later in the -.I flex -input file, or one which matched less text. -For example, the following will both count the -words in the input and call the routine special() whenever "frob" is seen: -.nf - - int word_count = 0; - %% - - frob special(); REJECT; - [^ \\t\\n]+ ++word_count; - -.fi -Without the -.B REJECT, -any "frob"'s in the input would not be counted as words, since the -scanner normally executes only one action per token. -Multiple -.B REJECT's -are allowed, each one finding the next best choice to the currently -active rule. For example, when the following scanner scans the token -"abcd", it will write "abcdabcaba" to the output: -.nf - - %% - a | - ab | - abc | - abcd ECHO; REJECT; - .|\\n /* eat up any unmatched character */ - -.fi -(The first three rules share the fourth's action since they use -the special '|' action.) -.B REJECT -is a particularly expensive feature in terms scanner performance; -if it is used in -.I any -of the scanner's actions it will slow down -.I all -of the scanner's matching. Furthermore, -.B REJECT -cannot be used with the -.I -Cf -or -.I -CF -options (see below). -.IP -Note also that unlike the other special actions, -.B REJECT -is a -.I branch; -code immediately following it in the action will -.I not -be executed. -.IP - -.B yymore() -tells the scanner that the next time it matches a rule, the corresponding -token should be -.I appended -onto the current value of -.B yytext -rather than replacing it. For example, given the input "mega-kludge" -the following will write "mega-mega-kludge" to the output: -.nf - - %% - mega- ECHO; yymore(); - kludge ECHO; - -.fi -First "mega-" is matched and echoed to the output. Then "kludge" -is matched, but the previous "mega-" is still hanging around at the -beginning of -.B yytext -so the -.B ECHO -for the "kludge" rule will actually write "mega-kludge". -The presence of -.B yymore() -in the scanner's action entails a minor performance penalty in the -scanner's matching speed. -.IP - -.B yyless(n) -returns all but the first -.I n -characters of the current token back to the input stream, where they -will be rescanned when the scanner looks for the next match. -.B yytext -and -.B yyleng -are adjusted appropriately (e.g., -.B yyleng -will now be equal to -.I n -). For example, on the input "foobar" the following will write out -"foobarbar": -.nf - - %% - foobar ECHO; yyless(3); - [a-z]+ ECHO; - -.fi -An argument of 0 to -.B yyless -will cause the entire current input string to be scanned again. Unless you've -changed how the scanner will subsequently process its input (using -.B BEGIN, -for example), this will result in an endless loop. -.PP -Note that -.B yyless -is a macro and can only be used in the flex input file, not from -other source files. -.IP - -.B unput(c) -puts the character -.I c -back onto the input stream. It will be the next character scanned. -The following action will take the current token and cause it -to be rescanned enclosed in parentheses. -.nf - - { - int i; - unput( ')' ); - for ( i = yyleng - 1; i >= 0; --i ) - unput( yytext[i] ); - unput( '(' ); - } - -.fi -Note that since each -.B unput() -puts the given character back at the -.I beginning -of the input stream, pushing back strings must be done back-to-front. -Also note that you cannot put back -.B EOF -to attempt to mark the input stream with an end-of-file. -.IP - -.B input() -reads the next character from the input stream. For example, -the following is one way to eat up C comments: -.nf - - %% - "/*" { - register int c; - - for ( ; ; ) - { - while ( (c = input()) != '*' && - c != EOF ) - ; /* eat up text of comment */ - - if ( c == '*' ) - { - while ( (c = input()) == '*' ) - ; - if ( c == '/' ) - break; /* found the end */ - } - - if ( c == EOF ) - { - error( "EOF in comment" ); - break; - } - } - } - -.fi -(Note that if the scanner is compiled using -.B C++, -then -.B input() -is instead referred to as -.B yyinput(), -in order to avoid a name clash with the -.B C++ -stream by the name of -.I input.) -.IP - -.B yyterminate() -can be used in lieu of a return statement in an action. It terminates -the scanner and returns a 0 to the scanner's caller, indicating "all done". -By default, -.B yyterminate() -is also called when an end-of-file is encountered. It is a macro and -may be redefined. -.SH THE GENERATED SCANNER -The output of -.I flex -is the file -.B lex.yy.c, -which contains the scanning routine -.B yylex(), -a number of tables used by it for matching tokens, and a number -of auxiliary routines and macros. By default, -.B yylex() -is declared as follows: -.nf - - int yylex() - { - ... various definitions and the actions in here ... - } - -.fi -(If your environment supports function prototypes, then it will -be "int yylex( void )".) This definition may be changed by defining -the "YY_DECL" macro. For example, you could use: -.nf - - #define YY_DECL float lexscan( a, b ) float a, b; - -.fi -to give the scanning routine the name -.I lexscan, -returning a float, and taking two floats as arguments. Note that -if you give arguments to the scanning routine using a -K&R-style/non-prototyped function declaration, you must terminate -the definition with a semi-colon (;). -.PP -Whenever -.B yylex() -is called, it scans tokens from the global input file -.I yyin -(which defaults to stdin). It continues until it either reaches -an end-of-file (at which point it returns the value 0) or -one of its actions executes a -.I return -statement. -.PP -If the scanner reaches an end-of-file, subsequent calls are undefined -unless either -.I yyin -is pointed at a new input file (in which case scanning continues from -that file), or -.B yyrestart() -is called. -.B yyrestart() -takes one argument, a -.B FILE * -pointer, and initializes -.I yyin -for scanning from that file. Essentially there is no difference between -just assigning -.I yyin -to a new input file or using -.B yyrestart() -to do so; the latter is available for compatibility with previous versions -of -.I flex, -and because it can be used to switch input files in the middle of scanning. -It can also be used to throw away the current input buffer, by calling -it with an argument of -.I yyin. -.PP -If -.B yylex() -stops scanning due to executing a -.I return -statement in one of the actions, the scanner may then be called again and it -will resume scanning where it left off. -.PP -By default (and for purposes of efficiency), the scanner uses -block-reads rather than simple -.I getc() -calls to read characters from -.I yyin. -The nature of how it gets its input can be controlled by defining the -.B YY_INPUT -macro. -YY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)". Its -action is to place up to -.I max_size -characters in the character array -.I buf -and return in the integer variable -.I result -either the -number of characters read or the constant YY_NULL (0 on Unix systems) -to indicate EOF. The default YY_INPUT reads from the -global file-pointer "yyin". -.PP -A sample definition of YY_INPUT (in the definitions -section of the input file): -.nf - - %{ - #define YY_INPUT(buf,result,max_size) \\ - { \\ - int c = getchar(); \\ - result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \\ - } - %} - -.fi -This definition will change the input processing to occur -one character at a time. -.PP -You also can add in things like keeping track of the -input line number this way; but don't expect your scanner to -go very fast. -.PP -When the scanner receives an end-of-file indication from YY_INPUT, -it then checks the -.B yywrap() -function. If -.B yywrap() -returns false (zero), then it is assumed that the -function has gone ahead and set up -.I yyin -to point to another input file, and scanning continues. If it returns -true (non-zero), then the scanner terminates, returning 0 to its -caller. -.PP -The default -.B yywrap() -always returns 1. -.PP -The scanner writes its -.B ECHO -output to the -.I yyout -global (default, stdout), which may be redefined by the user simply -by assigning it to some other -.B FILE -pointer. -.SH START CONDITIONS -.I flex -provides a mechanism for conditionally activating rules. Any rule -whose pattern is prefixed with "" will only be active when -the scanner is in the start condition named "sc". For example, -.nf - - [^"]* { /* eat up the string body ... */ - ... - } - -.fi -will be active only when the scanner is in the "STRING" start -condition, and -.nf - - \\. { /* handle an escape ... */ - ... - } - -.fi -will be active only when the current start condition is -either "INITIAL", "STRING", or "QUOTE". -.PP -Start conditions -are declared in the definitions (first) section of the input -using unindented lines beginning with either -.B %s -or -.B %x -followed by a list of names. -The former declares -.I inclusive -start conditions, the latter -.I exclusive -start conditions. A start condition is activated using the -.B BEGIN -action. Until the next -.B BEGIN -action is executed, rules with the given start -condition will be active and -rules with other start conditions will be inactive. -If the start condition is -.I inclusive, -then rules with no start conditions at all will also be active. -If it is -.I exclusive, -then -.I only -rules qualified with the start condition will be active. -A set of rules contingent on the same exclusive start condition -describe a scanner which is independent of any of the other rules in the -.I flex -input. Because of this, -exclusive start conditions make it easy to specify "mini-scanners" -which scan portions of the input that are syntactically different -from the rest (e.g., comments). -.PP -If the distinction between inclusive and exclusive start conditions -is still a little vague, here's a simple example illustrating the -connection between the two. The set of rules: -.nf - - %s example - %% - foo /* do something */ - -.fi -is equivalent to -.nf - - %x example - %% - foo /* do something */ - -.fi -.PP -Also note that the special start-condition specifier -.B <*> -matches every start condition. Thus, the above example could also -have been written; -.nf - - %x example - %% - <*>foo /* do something */ - -.fi -.PP -The default rule (to -.B ECHO -any unmatched character) remains active in start conditions. -.PP -.B BEGIN(0) -returns to the original state where only the rules with -no start conditions are active. This state can also be -referred to as the start-condition "INITIAL", so -.B BEGIN(INITIAL) -is equivalent to -.B BEGIN(0). -(The parentheses around the start condition name are not required but -are considered good style.) -.PP -.B BEGIN -actions can also be given as indented code at the beginning -of the rules section. For example, the following will cause -the scanner to enter the "SPECIAL" start condition whenever -.I yylex() -is called and the global variable -.I enter_special -is true: -.nf - - int enter_special; - - %x SPECIAL - %% - if ( enter_special ) - BEGIN(SPECIAL); - - blahblahblah - ...more rules follow... - -.fi -.PP -To illustrate the uses of start conditions, -here is a scanner which provides two different interpretations -of a string like "123.456". By default it will treat it as -as three tokens, the integer "123", a dot ('.'), and the integer "456". -But if the string is preceded earlier in the line by the string -"expect-floats" -it will treat it as a single token, the floating-point number -123.456: -.nf - - %{ - #include - %} - %s expect - - %% - expect-floats BEGIN(expect); - - [0-9]+"."[0-9]+ { - printf( "found a float, = %f\\n", - atof( yytext ) ); - } - \\n { - /* that's the end of the line, so - * we need another "expect-number" - * before we'll recognize any more - * numbers - */ - BEGIN(INITIAL); - } - - [0-9]+ { - printf( "found an integer, = %d\\n", - atoi( yytext ) ); - } - - "." printf( "found a dot\\n" ); - -.fi -Here is a scanner which recognizes (and discards) C comments while -maintaining a count of the current input line. -.nf - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\\n]* /* eat anything that's not a '*' */ - "*"+[^*/\\n]* /* eat up '*'s not followed by '/'s */ - \\n ++line_num; - "*"+"/" BEGIN(INITIAL); - -.fi -This scanner goes to a bit of trouble to match as much -text as possible with each rule. In general, when attempting to write -a high-speed scanner try to match as much possible in each rule, as -it's a big win. -.PP -Note that start-conditions names are really integer values and -can be stored as such. Thus, the above could be extended in the -following fashion: -.nf - - %x comment foo - %% - int line_num = 1; - int comment_caller; - - "/*" { - comment_caller = INITIAL; - BEGIN(comment); - } - - ... - - "/*" { - comment_caller = foo; - BEGIN(comment); - } - - [^*\\n]* /* eat anything that's not a '*' */ - "*"+[^*/\\n]* /* eat up '*'s not followed by '/'s */ - \\n ++line_num; - "*"+"/" BEGIN(comment_caller); - -.fi -Furthermore, you can access the current start condition using -the integer-valued -.B YY_START -macro. For example, the above assignments to -.I comment_caller -could instead be written -.nf - - comment_caller = YY_START; -.fi -.PP -Note that start conditions do not have their own name-space; %s's and %x's -declare names in the same fashion as #define's. -.PP -Finally, here's an example of how to match C-style quoted strings using -exclusive start conditions, including expanded escape sequences (but -not including checking for a string that's too long): -.nf - - %x str - - %% - char string_buf[MAX_STR_CONST]; - char *string_buf_ptr; - - - \\" string_buf_ptr = string_buf; BEGIN(str); - - \\" { /* saw closing quote - all done */ - BEGIN(INITIAL); - *string_buf_ptr = '\\0'; - /* return string constant token type and - * value to parser - */ - } - - \\n { - /* error - unterminated string constant */ - /* generate error message */ - } - - \\\\[0-7]{1,3} { - /* octal escape sequence */ - int result; - - (void) sscanf( yytext + 1, "%o", &result ); - - if ( result > 0xff ) - /* error, constant is out-of-bounds */ - - *string_buf_ptr++ = result; - } - - \\\\[0-9]+ { - /* generate error - bad escape sequence; something - * like '\\48' or '\\0777777' - */ - } - - \\\\n *string_buf_ptr++ = '\\n'; - \\\\t *string_buf_ptr++ = '\\t'; - \\\\r *string_buf_ptr++ = '\\r'; - \\\\b *string_buf_ptr++ = '\\b'; - \\\\f *string_buf_ptr++ = '\\f'; - - \\\\(.|\\n) *string_buf_ptr++ = yytext[1]; - - [^\\\\\\n\\"]+ { - char *yytext_ptr = yytext; - - while ( *yytext_ptr ) - *string_buf_ptr++ = *yytext_ptr++; - } - -.fi -.SH MULTIPLE INPUT BUFFERS -Some scanners (such as those which support "include" files) -require reading from several input streams. As -.I flex -scanners do a large amount of buffering, one cannot control -where the next input will be read from by simply writing a -.B YY_INPUT -which is sensitive to the scanning context. -.B YY_INPUT -is only called when the scanner reaches the end of its buffer, which -may be a long time after scanning a statement such as an "include" -which requires switching the input source. -.PP -To negotiate these sorts of problems, -.I flex -provides a mechanism for creating and switching between multiple -input buffers. An input buffer is created by using: -.nf - - YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) - -.fi -which takes a -.I FILE -pointer and a size and creates a buffer associated with the given -file and large enough to hold -.I size -characters (when in doubt, use -.B YY_BUF_SIZE -for the size). It returns a -.B YY_BUFFER_STATE -handle, which may then be passed to other routines: -.nf - - void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) - -.fi -switches the scanner's input buffer so subsequent tokens will -come from -.I new_buffer. -Note that -.B yy_switch_to_buffer() -may be used by yywrap() to set things up for continued scanning, instead -of opening a new file and pointing -.I yyin -at it. -.nf - - void yy_delete_buffer( YY_BUFFER_STATE buffer ) - -.fi -is used to reclaim the storage associated with a buffer. -.PP -.B yy_new_buffer() -is an alias for -.B yy_create_buffer(), -provided for compatibility with the C++ use of -.I new -and -.I delete -for creating and destroying dynamic objects. -.PP -Finally, the -.B YY_CURRENT_BUFFER -macro returns a -.B YY_BUFFER_STATE -handle to the current buffer. -.PP -Here is an example of using these features for writing a scanner -which expands include files (the -.B <> -feature is discussed below): -.nf - - /* the "incl" state is used for picking up the name - * of an include file - */ - %x incl - - %{ - #define MAX_INCLUDE_DEPTH 10 - YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; - int include_stack_ptr = 0; - %} - - %% - include BEGIN(incl); - - [a-z]+ ECHO; - [^a-z\\n]*\\n? ECHO; - - [ \\t]* /* eat the whitespace */ - [^ \\t\\n]+ { /* got the include file name */ - if ( include_stack_ptr >= MAX_INCLUDE_DEPTH ) - { - fprintf( stderr, "Includes nested too deeply" ); - exit( 1 ); - } - - include_stack[include_stack_ptr++] = - YY_CURRENT_BUFFER; - - yyin = fopen( yytext, "r" ); - - if ( ! yyin ) - error( ... ); - - yy_switch_to_buffer( - yy_create_buffer( yyin, YY_BUF_SIZE ) ); - - BEGIN(INITIAL); - } - - <> { - if ( --include_stack_ptr < 0 ) - { - yyterminate(); - } - - else - { - yy_delete_buffer( YY_CURRENT_BUFFER ); - yy_switch_to_buffer( - include_stack[include_stack_ptr] ); - } - } - -.fi -.SH END-OF-FILE RULES -The special rule "<>" indicates -actions which are to be taken when an end-of-file is -encountered and yywrap() returns non-zero (i.e., indicates -no further files to process). The action must finish -by doing one of four things: -.IP - -assigning -.I yyin -to a new input file (in previous versions of flex, after doing the -assignment you had to call the special action -.B YY_NEW_FILE; -this is no longer necessary); -.IP - -executing a -.I return -statement; -.IP - -executing the special -.B yyterminate() -action; -.IP - -or, switching to a new buffer using -.B yy_switch_to_buffer() -as shown in the example above. -.PP -<> rules may not be used with other -patterns; they may only be qualified with a list of start -conditions. If an unqualified <> rule is given, it -applies to -.I all -start conditions which do not already have <> actions. To -specify an <> rule for only the initial start condition, use -.nf - - <> - -.fi -.PP -These rules are useful for catching things like unclosed comments. -An example: -.nf - - %x quote - %% - - ...other rules for dealing with quotes... - - <> { - error( "unterminated quote" ); - yyterminate(); - } - <> { - if ( *++filelist ) - yyin = fopen( *filelist, "r" ); - else - yyterminate(); - } - -.fi -.SH MISCELLANEOUS MACROS -The macro -.bd -YY_USER_ACTION -can be defined to provide an action -which is always executed prior to the matched rule's action. For example, -it could be #define'd to call a routine to convert yytext to lower-case. -.PP -The macro -.B YY_USER_INIT -may be defined to provide an action which is always executed before -the first scan (and before the scanner's internal initializations are done). -For example, it could be used to call a routine to read -in a data table or open a logging file. -.PP -In the generated scanner, the actions are all gathered in one large -switch statement and separated using -.B YY_BREAK, -which may be redefined. By default, it is simply a "break", to separate -each rule's action from the following rule's. -Redefining -.B YY_BREAK -allows, for example, C++ users to -#define YY_BREAK to do nothing (while being very careful that every -rule ends with a "break" or a "return"!) to avoid suffering from -unreachable statement warnings where because a rule's action ends with -"return", the -.B YY_BREAK -is inaccessible. -.SH INTERFACING WITH YACC -One of the main uses of -.I flex -is as a companion to the -.I yacc -parser-generator. -.I yacc -parsers expect to call a routine named -.B yylex() -to find the next input token. The routine is supposed to -return the type of the next token as well as putting any associated -value in the global -.B yylval. -To use -.I flex -with -.I yacc, -one specifies the -.B \-d -option to -.I yacc -to instruct it to generate the file -.B y.tab.h -containing definitions of all the -.B %tokens -appearing in the -.I yacc -input. This file is then included in the -.I flex -scanner. For example, if one of the tokens is "TOK_NUMBER", -part of the scanner might look like: -.nf - - %{ - #include "y.tab.h" - %} - - %% - - [0-9]+ yylval = atoi( yytext ); return TOK_NUMBER; - -.fi -.SH OPTIONS -.I flex -has the following options: -.TP -.B \-b -Generate backing-up information to -.I lex.backup. -This is a list of scanner states which require backing up -and the input characters on which they do so. By adding rules one -can remove backing-up states. If all backing-up states -are eliminated and -.B \-Cf -or -.B \-CF -is used, the generated scanner will run faster (see the -.B \-p -flag). Only users who wish to squeeze every last cycle out of their -scanners need worry about this option. (See the section on Performance -Considerations below.) -.TP -.B \-c -is a do-nothing, deprecated option included for POSIX compliance. -.IP -.B NOTE: -in previous releases of -.I flex -.B \-c -specified table-compression options. This functionality is -now given by the -.B \-C -flag. To ease the the impact of this change, when -.I flex -encounters -.B \-c, -it currently issues a warning message and assumes that -.B \-C -was desired instead. In the future this "promotion" of -.B \-c -to -.B \-C -will go away in the name of full POSIX compliance (unless -the POSIX meaning is removed first). -.TP -.B \-d -makes the generated scanner run in -.I debug -mode. Whenever a pattern is recognized and the global -.B yy_flex_debug -is non-zero (which is the default), -the scanner will write to -.I stderr -a line of the form: -.nf - - --accepting rule at line 53 ("the matched text") - -.fi -The line number refers to the location of the rule in the file -defining the scanner (i.e., the file that was fed to flex). Messages -are also generated when the scanner backs up, accepts the -default rule, reaches the end of its input buffer (or encounters -a NUL; at this point, the two look the same as far as the scanner's concerned), -or reaches an end-of-file. -.TP -.B \-f -specifies -.I fast scanner. -No table compression is done and stdio is bypassed. -The result is large but fast. This option is equivalent to -.B \-Cfr -(see below). -.TP -.B \-h -generates a "help" summary of -.I flex's -options to -.I stderr -and then exits. -.TP -.B \-i -instructs -.I flex -to generate a -.I case-insensitive -scanner. The case of letters given in the -.I flex -input patterns will -be ignored, and tokens in the input will be matched regardless of case. The -matched text given in -.I yytext -will have the preserved case (i.e., it will not be folded). -.TP -.B \-l -turns on maximum compatibility with the original AT&T -.I lex -implementation. Note that this does not mean -.I full -compatibility. Use of this option costs a considerable amount of -performance, and it cannot be used with the -.B \-+, -f, -F, -Cf, -or -.B -CF -options. For details on the compatibilities it provides, see the section -"Incompatibilities With Lex And POSIX" below. -.TP -.B \-n -is another do-nothing, deprecated option included only for -POSIX compliance. -.TP -.B \-p -generates a performance report to stderr. The report -consists of comments regarding features of the -.I flex -input file which will cause a serious loss of performance in the resulting -scanner. If you give the flag twice, you will also get comments regarding -features that lead to minor performance losses. -.IP -Note that the use of -.B REJECT -and variable trailing context (see the Bugs section in flex(1)) -entails a substantial performance penalty; use of -.I yymore(), -the -.B ^ -operator, -and the -.B \-I -flag entail minor performance penalties. -.TP -.B \-s -causes the -.I default rule -(that unmatched scanner input is echoed to -.I stdout) -to be suppressed. If the scanner encounters input that does not -match any of its rules, it aborts with an error. This option is -useful for finding holes in a scanner's rule set. -.TP -.B \-t -instructs -.I flex -to write the scanner it generates to standard output instead -of -.B lex.yy.c. -.TP -.B \-v -specifies that -.I flex -should write to -.I stderr -a summary of statistics regarding the scanner it generates. -Most of the statistics are meaningless to the casual -.I flex -user, but the first line identifies the version of -.I flex -(same as reported by -.B \-V), -and the next line the flags used when generating the scanner, including -those that are on by default. -.TP -.B \-w -suppresses warning messages. -.TP -.B \-B -instructs -.I flex -to generate a -.I batch -scanner, the opposite of -.I interactive -scanners generated by -.B \-I -(see below). In general, you use -.B \-B -when you are -.I certain -that your scanner will never be used interactively, and you want to -squeeze a -.I little -more performance out of it. If your goal is instead to squeeze out a -.I lot -more performance, you should be using the -.B \-Cf -or -.B \-CF -options (discussed below), which turn on -.B \-B -automatically anyway. -.TP -.B \-F -specifies that the -.ul -fast -scanner table representation should be used (and stdio -bypassed). This representation is -about as fast as the full table representation -.B (-f), -and for some sets of patterns will be considerably smaller (and for -others, larger). In general, if the pattern set contains both "keywords" -and a catch-all, "identifier" rule, such as in the set: -.nf - - "case" return TOK_CASE; - "switch" return TOK_SWITCH; - ... - "default" return TOK_DEFAULT; - [a-z]+ return TOK_ID; - -.fi -then you're better off using the full table representation. If only -the "identifier" rule is present and you then use a hash table or some such -to detect the keywords, you're better off using -.B -F. -.IP -This option is equivalent to -.B \-CFr -(see below). It cannot be used with -.B \-+. -.TP -.B \-I -instructs -.I flex -to generate an -.I interactive -scanner. An interactive scanner is one that only looks ahead to decide -what token has been matched if it absolutely must. It turns out that -always looking one extra character ahead, even if the scanner has already -seen enough text to disambiguate the current token, is a bit faster than -only looking ahead when necessary. But scanners that always look ahead -give dreadful interactive performance; for example, when a user types -a newline, it is not recognized as a newline token until they enter -.I another -token, which often means typing in another whole line. -.IP -.I Flex -scanners default to -.I interactive -unless you use the -.B \-Cf -or -.B \-CF -table-compression options (see below). That's because if you're looking -for high-performance you should be using one of these options, so if you -didn't, -.I flex -assumes you'd rather trade off a bit of run-time performance for intuitive -interactive behavior. Note also that you -.I cannot -use -.B \-I -in conjunction with -.B \-Cf -or -.B \-CF. -Thus, this option is not really needed; it is on by default for all those -cases in which it is allowed. -.IP -You can force a scanner to -.I not -be interactive by using -.B \-B -(see above). -.TP -.B \-L -instructs -.I flex -not to generate -.B #line -directives. Without this option, -.I flex -peppers the generated scanner -with #line directives so error messages in the actions will be correctly -located with respect to the original -.I flex -input file, and not to -the fairly meaningless line numbers of -.B lex.yy.c. -(Unfortunately -.I flex -does not presently generate the necessary directives -to "retarget" the line numbers for those parts of -.B lex.yy.c -which it generated. So if there is an error in the generated code, -a meaningless line number is reported.) -.TP -.B \-T -makes -.I flex -run in -.I trace -mode. It will generate a lot of messages to -.I stderr -concerning -the form of the input and the resultant non-deterministic and deterministic -finite automata. This option is mostly for use in maintaining -.I flex. -.TP -.B \-V -prints the version number to -.I stderr -and exits. -.TP -.B \-7 -instructs -.I flex -to generate a 7-bit scanner, i.e., one which can only recognized 7-bit -characters in its input. The advantage of using -.B \-7 -is that the scanner's tables can be up to half the size of those generated -using the -.B \-8 -option (see below). The disadvantage is that such scanners often hang -or crash if their input contains an 8-bit character. -.IP -Note, however, that unless you generate your scanner using the -.B \-Cf -or -.B \-CF -table compression options, use of -.B \-7 -will save only a small amount of table space, and make your scanner -considerably less portable. -.I Flex's -default behavior is to generate an 8-bit scanner unless you use the -.B \-Cf -or -.B \-CF, -in which case -.I flex -defaults to generating 7-bit scanners unless your site was always -configured to generate 8-bit scanners (as will often be the case -with non-USA sites). You can tell whether flex generated a 7-bit -or an 8-bit scanner by inspecting the flag summary in the -.B \-v -output as described above. -.IP -Note that if you use -.B \-Cfe -or -.B \-CFe -(those table compression options, but also using equivalence classes as -discussed see below), flex still defaults to generating an 8-bit -scanner, since usually with these compression options full 8-bit tables -are not much more expensive than 7-bit tables. -.TP -.B \-8 -instructs -.I flex -to generate an 8-bit scanner, i.e., one which can recognize 8-bit -characters. This flag is only needed for scanners generated using -.B \-Cf -or -.B \-CF, -as otherwise flex defaults to generating an 8-bit scanner anyway. -.IP -See the discussion of -.B \-7 -above for flex's default behavior and the tradeoffs between 7-bit -and 8-bit scanners. -.TP -.B \-+ -specifies that you want flex to generate a C++ -scanner class. See the section on Generating C++ Scanners below for -details. -.TP -.B \-C[aefFmr] -controls the degree of table compression and, more generally, trade-offs -between small scanners and fast scanners. -.IP -.B \-Ca -("align") instructs flex to trade off larger tables in the -generated scanner for faster performance because the elements of -the tables are better aligned for memory access and computation. On some -RISC architectures, fetching and manipulating longwords is more efficient -than with smaller-sized datums such as shortwords. This option can -double the size of the tables used by your scanner. -.IP -.B \-Ce -directs -.I flex -to construct -.I equivalence classes, -i.e., sets of characters -which have identical lexical properties (for example, if the only -appearance of digits in the -.I flex -input is in the character class -"[0-9]" then the digits '0', '1', ..., '9' will all be put -in the same equivalence class). Equivalence classes usually give -dramatic reductions in the final table/object file sizes (typically -a factor of 2-5) and are pretty cheap performance-wise (one array -look-up per character scanned). -.IP -.B \-Cf -specifies that the -.I full -scanner tables should be generated - -.I flex -should not compress the -tables by taking advantages of similar transition functions for -different states. -.IP -.B \-CF -specifies that the alternate fast scanner representation (described -above under the -.B \-F -flag) -should be used. This option cannot be used with -.B \-+. -.IP -.B \-Cm -directs -.I flex -to construct -.I meta-equivalence classes, -which are sets of equivalence classes (or characters, if equivalence -classes are not being used) that are commonly used together. Meta-equivalence -classes are often a big win when using compressed tables, but they -have a moderate performance impact (one or two "if" tests and one -array look-up per character scanned). -.IP -.B \-Cr -causes the generated scanner to -.I bypass -use of the standard I/O library (stdio) for input. Instead of calling -.B fread() -or -.B getc(), -the scanner will use the -.B read() -system call, resulting in a performance gain which varies from system -to system, but in general is probably negligible unless you are also using -.B \-Cf -or -.B \-CF. -Using -.B \-Cr -can cause strange behavior if, for example, you read from -.I yyin -using stdio prior to calling the scanner (because the scanner will miss -whatever text your previous reads left in the stdio input buffer). -.IP -.B \-Cr -has no effect if you define -.B YY_INPUT -(see The Generated Scanner above). -.IP -A lone -.B \-C -specifies that the scanner tables should be compressed but neither -equivalence classes nor meta-equivalence classes should be used. -.IP -The options -.B \-Cf -or -.B \-CF -and -.B \-Cm -do not make sense together - there is no opportunity for meta-equivalence -classes if the table is not being compressed. Otherwise the options -may be freely mixed, and are cumulative. -.IP -The default setting is -.B \-Cem, -which specifies that -.I flex -should generate equivalence classes -and meta-equivalence classes. This setting provides the highest -degree of table compression. You can trade off -faster-executing scanners at the cost of larger tables with -the following generally being true: -.nf - - slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} - -C{f,F}a - fastest & largest - -.fi -Note that scanners with the smallest tables are usually generated and -compiled the quickest, so -during development you will usually want to use the default, maximal -compression. -.IP -.B \-Cfe -is often a good compromise between speed and size for production -scanners. -.TP -.B \-Pprefix -changes the default -.I "yy" -prefix used by -.I flex -for all globally-visible variable and function names to instead be -.I prefix. -For example, -.B \-Pfoo -changes the name of -.B yytext -to -.B footext. -It also changes the name of the default output file from -.B lex.yy.c -to -.B lex.foo.c. -Here are all of the names affected: -.nf - - yyFlexLexer - yy_create_buffer - yy_delete_buffer - yy_flex_debug - yy_init_buffer - yy_load_buffer_state - yy_switch_to_buffer - yyin - yyleng - yylex - yyout - yyrestart - yytext - yywrap - -.fi -Within your scanner itself, you can still refer to the global variables -and functions using either version of their name; but eternally, they -have the modified name. -.IP -This option lets you easily link together multiple -.I flex -programs into the same executable. Note, though, that using this -option also renames -.B yywrap(), -so you now -.I must -provide your own (appropriately-named) version of the routine for your -scanner, as linking with -.B \-lfl -no longer provides one for you by default. -.TP -.B \-Sskeleton_file -overrides the default skeleton file from which -.I flex -constructs its scanners. You'll never need this option unless you are doing -.I flex -maintenance or development. -.SH PERFORMANCE CONSIDERATIONS -The main design goal of -.I flex -is that it generate high-performance scanners. It has been optimized -for dealing well with large sets of rules. Aside from the effects on -scanner speed of the table compression -.B \-C -options outlined above, -there are a number of options/actions which degrade performance. These -are, from most expensive to least: -.nf - - REJECT - - pattern sets that require backing up - arbitrary trailing context - - yymore() - '^' beginning-of-line operator - -.fi -with the first three all being quite expensive and the last two -being quite cheap. Note also that -.B unput() -is implemented as a routine call that potentially does quite a bit of -work, while -.B yyless() -is a quite-cheap macro; so if just putting back some excess text you -scanned, use -.B yyless(). -.PP -.B REJECT -should be avoided at all costs when performance is important. -It is a particularly expensive option. -.PP -Getting rid of backing up is messy and often may be an enormous -amount of work for a complicated scanner. In principal, one begins -by using the -.B \-b -flag to generate a -.I lex.backup -file. For example, on the input -.nf - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - -.fi -the file looks like: -.nf - - State #6 is non-accepting - - associated rule line numbers: - 2 3 - out-transitions: [ o ] - jam-transitions: EOF [ \\001-n p-\\177 ] - - State #8 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ a ] - jam-transitions: EOF [ \\001-` b-\\177 ] - - State #9 is non-accepting - - associated rule line numbers: - 3 - out-transitions: [ r ] - jam-transitions: EOF [ \\001-q s-\\177 ] - - Compressed tables always back up. - -.fi -The first few lines tell us that there's a scanner state in -which it can make a transition on an 'o' but not on any other -character, and that in that state the currently scanned text does not match -any rule. The state occurs when trying to match the rules found -at lines 2 and 3 in the input file. -If the scanner is in that state and then reads -something other than an 'o', it will have to back up to find -a rule which is matched. With -a bit of headscratching one can see that this must be the -state it's in when it has seen "fo". When this has happened, -if anything other than another 'o' is seen, the scanner will -have to back up to simply match the 'f' (by the default rule). -.PP -The comment regarding State #8 indicates there's a problem -when "foob" has been scanned. Indeed, on any character other -than an 'a', the scanner will have to back up to accept "foo". -Similarly, the comment for State #9 concerns when "fooba" has -been scanned and an 'r' does not follow. -.PP -The final comment reminds us that there's no point going to -all the trouble of removing backing up from the rules unless -we're using -.B \-Cf -or -.B \-CF, -since there's no performance gain doing so with compressed scanners. -.PP -The way to remove the backing up is to add "error" rules: -.nf - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - fooba | - foob | - fo { - /* false alarm, not really a keyword */ - return TOK_ID; - } - -.fi -.PP -Eliminating backing up among a list of keywords can also be -done using a "catch-all" rule: -.nf - - %% - foo return TOK_KEYWORD; - foobar return TOK_KEYWORD; - - [a-z]+ return TOK_ID; - -.fi -This is usually the best solution when appropriate. -.PP -Backing up messages tend to cascade. -With a complicated set of rules it's not uncommon to get hundreds -of messages. If one can decipher them, though, it often -only takes a dozen or so rules to eliminate the backing up (though -it's easy to make a mistake and have an error rule accidentally match -a valid token. A possible future -.I flex -feature will be to automatically add rules to eliminate backing up). -.PP -.I Variable -trailing context (where both the leading and trailing parts do not have -a fixed length) entails almost the same performance loss as -.B REJECT -(i.e., substantial). So when possible a rule like: -.nf - - %% - mouse|rat/(cat|dog) run(); - -.fi -is better written: -.nf - - %% - mouse/cat|dog run(); - rat/cat|dog run(); - -.fi -or as -.nf - - %% - mouse|rat/cat run(); - mouse|rat/dog run(); - -.fi -Note that here the special '|' action does -.I not -provide any savings, and can even make things worse (see -.PP -A final note regarding performance: as mentioned above in the section -How the Input is Matched, dynamically resizing -.B yytext -to accomodate huge tokens is a slow process because it presently requires that -the (huge) token be rescanned from the beginning. Thus if performance is -vital, you should attempt to match "large" quantities of text but not -"huge" quantities, where the cutoff between the two is at about 8K -characters/token. -.PP -Another area where the user can increase a scanner's performance -(and one that's easier to implement) arises from the fact that -the longer the tokens matched, the faster the scanner will run. -This is because with long tokens the processing of most input -characters takes place in the (short) inner scanning loop, and -does not often have to go through the additional work of setting up -the scanning environment (e.g., -.B yytext) -for the action. Recall the scanner for C comments: -.nf - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\\n]* - "*"+[^*/\\n]* - \\n ++line_num; - "*"+"/" BEGIN(INITIAL); - -.fi -This could be sped up by writing it as: -.nf - - %x comment - %% - int line_num = 1; - - "/*" BEGIN(comment); - - [^*\\n]* - [^*\\n]*\\n ++line_num; - "*"+[^*/\\n]* - "*"+[^*/\\n]*\\n ++line_num; - "*"+"/" BEGIN(INITIAL); - -.fi -Now instead of each newline requiring the processing of another -action, recognizing the newlines is "distributed" over the other rules -to keep the matched text as long as possible. Note that -.I adding -rules does -.I not -slow down the scanner! The speed of the scanner is independent -of the number of rules or (modulo the considerations given at the -beginning of this section) how complicated the rules are with -regard to operators such as '*' and '|'. -.PP -A final example in speeding up a scanner: suppose you want to scan -through a file containing identifiers and keywords, one per line -and with no other extraneous characters, and recognize all the -keywords. A natural first approach is: -.nf - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - .|\\n /* it's not a keyword */ - -.fi -To eliminate the back-tracking, introduce a catch-all rule: -.nf - - %% - asm | - auto | - break | - ... etc ... - volatile | - while /* it's a keyword */ - - [a-z]+ | - .|\\n /* it's not a keyword */ - -.fi -Now, if it's guaranteed that there's exactly one word per line, -then we can reduce the total number of matches by a half by -merging in the recognition of newlines with that of the other -tokens: -.nf - - %% - asm\\n | - auto\\n | - break\\n | - ... etc ... - volatile\\n | - while\\n /* it's a keyword */ - - [a-z]+\\n | - .|\\n /* it's not a keyword */ - -.fi -One has to be careful here, as we have now reintroduced backing up -into the scanner. In particular, while -.I we -know that there will never be any characters in the input stream -other than letters or newlines, -.I flex -can't figure this out, and it will plan for possibly needing to back up -when it has scanned a token like "auto" and then the next character -is something other than a newline or a letter. Previously it would -then just match the "auto" rule and be done, but now it has no "auto" -rule, only a "auto\\n" rule. To eliminate the possibility of backing up, -we could either duplicate all rules but without final newlines, or, -since we never expect to encounter such an input and therefore don't -how it's classified, we can introduce one more catch-all rule, this -one which doesn't include a newline: -.nf - - %% - asm\\n | - auto\\n | - break\\n | - ... etc ... - volatile\\n | - while\\n /* it's a keyword */ - - [a-z]+\\n | - [a-z]+ | - .|\\n /* it's not a keyword */ - -.fi -Compiled with -.B \-Cf, -this is about as fast as one can get a -.I flex -scanner to go for this particular problem. -.PP -A final note: -.I flex -is slow when matching NUL's, particularly when a token contains -multiple NUL's. -It's best to write rules which match -.I short -amounts of text if it's anticipated that the text will often include NUL's. -.SH GENERATING C++ SCANNERS -.I flex -provides two different ways to generate scanners for use with C++. The -first way is to simply compile a scanner generated by -.I flex -using a C++ compiler instead of a C compiler. You should not encounter -any compilations errors (please report any you find to the email address -given in the Author section below). You can then use C++ code in your -rule actions instead of C code. Note that the default input source for -your scanner remains -.I yyin, -and default echoing is still done to -.I yyout. -Both of these remain -.I FILE * -variables and not C++ -.I streams. -.PP -You can also use -.I flex -to generate a C++ scanner class, using the -.B \-+ -option, which is automatically specified if the name of the flex -executable ends in a '+', such as -.I flex++. -When using this option, flex defaults to generating the scanner to the file -.B lex.yy.cc -instead of -.B lex.yy.c. -The generated scanner includes the header file -.I FlexLexer.h, -which defines the interface to two C++ classes. -.PP -The first class, -.B FlexLexer, -provides an abstract base class defining the general scanner class -interface. It provides the following member functions: -.TP -.B const char* YYText() -returns the text of the most recently matched token, the equivalent of -.B yytext. -.TP -.B int YYLeng() -returns the length of the most recently matched token, the equivalent of -.B yyleng. -.PP -Also provided are member functions equivalent to -.B yy_switch_to_buffer(), -.B yy_create_buffer() -(though the first argument is an -.B istream* -object pointer and not a -.B FILE*), -.B yy_delete_buffer(), -and -.B yyrestart() -(again, the first argument is a -.B istream* -object pointer). -.PP -The second class defined in -.I FlexLexer.h -is -.B yyFlexLexer, -which is derived from -.B FlexLexer. -It defines the following additional member functions: -.TP -.B -yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 ) -constructs a -.B yyFlexLexer -object using the given streams for input and output. If not specified, -the streams default to -.B cin -and -.B cout, -respectively. -.TP -.B virtual int yylex() -performs the same role is -.B yylex() -does for ordinary flex scanners: it scans the input stream, consuming -tokens, until a rule's action returns a value. -.PP -In addition, -.B yyFlexLexer -defines the following protected virtual functions which you can redefine -in derived classes to tailor the scanner: -.TP -.B -virtual int LexerInput( char* buf, int max_size ) -reads up to -.B max_size -characters into -.B buf -and returns the number of characters read. To indicate end-of-input, -return 0 characters. Note that "interactive" scanners (see the -.B \-B -and -.B \-I -flags) define the macro -.B YY_INTERACTIVE. -If you redefine -.B LexerInput() -and need to take different actions depending on whether or not -the scanner might be scanning an interactive input source, you can -test for the presence of this name via -.B #ifdef. -.TP -.B -virtual void LexerOutput( const char* buf, int size ) -writes out -.B size -characters from the buffer -.B buf, -which, while NUL-terminated, may also contain "internal" NUL's if -the scanner's rules can match text with NUL's in them. -.TP -.B -virtual void LexerError( const char* msg ) -reports a fatal error message. The default version of this function -writes the message to the stream -.B cerr -and exits. -.PP -Note that a -.B yyFlexLexer -object contains its -.I entire -scanning state. Thus you can use such objects to create reentrant -scanners. You can instantiate multiple instances of the same -.B yyFlexLexer -class, and you can also combine multiple C++ scanner classes together -in the same program using the -.B \-P -option discussed above. -.PP -Finally, note that the -.B %array -feature is not available to C++ scanner classes; you must use -.B %pointer -(the default). -.PP -Here is an example of a simple C++ scanner: -.nf - - // An example of using the flex C++ scanner class. - - %{ - int mylineno = 0; - %} - - string \\"[^\\n"]+\\" - - ws [ \\t]+ - - alpha [A-Za-z] - dig [0-9] - name ({alpha}|{dig}|\\$)({alpha}|{dig}|[_.\\-/$])* - num1 [-+]?{dig}+\\.?([eE][-+]?{dig}+)? - num2 [-+]?{dig}*\\.{dig}+([eE][-+]?{dig}+)? - number {num1}|{num2} - - %% - - {ws} /* skip blanks and tabs */ - - "/*" { - int c; - - while((c = yyinput()) != 0) - { - if(c == '\\n') - ++mylineno; - - else if(c == '*') - { - if((c = yyinput()) == '/') - break; - else - unput(c); - } - } - } - - {number} cout << "number " << YYText() << '\\n'; - - \\n mylineno++; - - {name} cout << "name " << YYText() << '\\n'; - - {string} cout << "string " << YYText() << '\\n'; - - %% - - int main( int /* argc */, char** /* argv */ ) - { - FlexLexer* lexer = new yyFlexLexer; - while(lexer->yylex() != 0) - ; - return 0; - } -.fi -IMPORTANT: the present form of the scanning class is -.I experimental -and may change considerably between major releases. -.SH INCOMPATIBILITIES WITH LEX AND POSIX -.I flex -is a rewrite of the AT&T Unix -.I lex -tool (the two implementations do not share any code, though), -with some extensions and incompatibilities, both of which -are of concern to those who wish to write scanners acceptable -to either implementation. The POSIX -.I lex -specification is closer to -.I flex's -behavior than that of the original -.I lex -implementation, but there also remain some incompatibilities between -.I flex -and POSIX. The intent is that ultimately -.I flex -will be fully POSIX-conformant. In this section we discuss all of -the known areas of incompatibility. -.PP -.I flex's -.B \-l -option turns on maximum compatibility with the original AT&T -.I lex -implementation, at the cost of a major loss in the generated scanner's -performance. We note below which incompatibilities can be overcome -using the -.B \-l -option. -.PP -.I flex -is fully compatible with -.I lex -with the following exceptions: -.IP - -The undocumented -.I lex -scanner internal variable -.B yylineno -is not supported unless -.B \-l -is used. -.IP -yylineno is not part of the POSIX specification. -.IP - -The -.B input() -routine is not redefinable, though it may be called to read characters -following whatever has been matched by a rule. If -.B input() -encounters an end-of-file the normal -.B yywrap() -processing is done. A ``real'' end-of-file is returned by -.B input() -as -.I EOF. -.IP -Input is instead controlled by defining the -.B YY_INPUT -macro. -.IP -The -.I flex -restriction that -.B input() -cannot be redefined is in accordance with the POSIX specification, -which simply does not specify any way of controlling the -scanner's input other than by making an initial assignment to -.I yyin. -.IP - -.I flex -scanners are not as reentrant as -.I lex -scanners. In particular, if you have an interactive scanner and -an interrupt handler which long-jumps out of the scanner, and -the scanner is subsequently called again, you may get the following -message: -.nf - - fatal flex scanner internal error--end of buffer missed - -.fi -To reenter the scanner, first use -.nf - - yyrestart( yyin ); - -.fi -Note that this call will throw away any buffered input; usually this -isn't a problem with an interactive scanner. -.IP -Also note that flex C++ scanner classes -.I are -reentrant, so if using C++ is an option for you, you should use -them instead. See "Generating C++ Scanners" above for details. -.IP - -.B output() -is not supported. -Output from the -.B ECHO -macro is done to the file-pointer -.I yyout -(default -.I stdout). -.IP -.B output() -is not part of the POSIX specification. -.IP - -.I lex -does not support exclusive start conditions (%x), though they -are in the POSIX specification. -.IP - -When definitions are expanded, -.I flex -encloses them in parentheses. -With lex, the following: -.nf - - NAME [A-Z][A-Z0-9]* - %% - foo{NAME}? printf( "Found it\\n" ); - %% - -.fi -will not match the string "foo" because when the macro -is expanded the rule is equivalent to "foo[A-Z][A-Z0-9]*?" -and the precedence is such that the '?' is associated with -"[A-Z0-9]*". With -.I flex, -the rule will be expanded to -"foo([A-Z][A-Z0-9]*)?" and so the string "foo" will match. -.IP -Note that if the definition begins with -.B ^ -or ends with -.B $ -then it is -.I not -expanded with parentheses, to allow these operators to appear in -definitions without losing their special meanings. But the -.B , /, -and -.B <> -operators cannot be used in a -.I flex -definition. -.IP -Using -.B \-l -results in the -.I lex -behavior of no parentheses around the definition. -.IP -The POSIX specification is that the definition be enclosed in parentheses. -.IP - -The -.I lex -.B %r -(generate a Ratfor scanner) option is not supported. It is not part -of the POSIX specification. -.IP - -After a call to -.B unput(), -.I yytext -and -.I yyleng -are undefined until the next token is matched, unless the scanner -was built using -.B %array. -This is not the case with -.I lex -or the POSIX specification. The -.B \-l -option does away with this incompatibility. -.IP - -The precedence of the -.B {} -(numeric range) operator is different. -.I lex -interprets "abc{1,3}" as "match one, two, or -three occurrences of 'abc'", whereas -.I flex -interprets it as "match 'ab' -followed by one, two, or three occurrences of 'c'". The latter is -in agreement with the POSIX specification. -.IP - -The precedence of the -.B ^ -operator is different. -.I lex -interprets "^foo|bar" as "match either 'foo' at the beginning of a line, -or 'bar' anywhere", whereas -.I flex -interprets it as "match either 'foo' or 'bar' if they come at the beginning -of a line". The latter is in agreement with the POSIX specification. -.IP - -.I yyin -is -.I initialized -by -.I lex -to be -.I stdin; -.I flex, -on the other hand, -initializes -.I yyin -to NULL -and then -.I assigns -it to -.I stdin -the first time the scanner is called, providing -.I yyin -has not already been assigned to a non-NULL value. The difference is -subtle, but the net effect is that with -.I flex -scanners, -.I yyin -does not have a valid value until the scanner has been called. -.IP -The -.B \-l -option does away with this incompatibility. -.IP - -The special table-size declarations such as -.B %a -supported by -.I lex -are not required by -.I flex -scanners; -.I flex -ignores them. -.IP - -The name -.bd -FLEX_SCANNER -is #define'd so scanners may be written for use with either -.I flex -or -.I lex. -.PP -The following -.I flex -features are not included in -.I lex -or the POSIX specification: -.nf - - yyterminate() - <> - <*> - YY_DECL - YY_START - YY_USER_ACTION - #line directives - %{}'s around actions - multiple actions on a line - -.fi -plus almost all of the flex flags. -The last feature in the list refers to the fact that with -.I flex -you can put multiple actions on the same line, separated with -semi-colons, while with -.I lex, -the following -.nf - - foo handle_foo(); ++num_foos_seen; - -.fi -is (rather surprisingly) truncated to -.nf - - foo handle_foo(); - -.fi -.I flex -does not truncate the action. Actions that are not enclosed in -braces are simply terminated at the end of the line. -.SH DIAGNOSTICS -If you receive errors when linking a -.I flex -scanner complaining about the following missing routines: -.ds - yywrap - yy_flex_alloc - ... -.de -(and various others) then you forgot to link your program with -.B \-lfl. -This run-time library is -.I required -for all -.I flex -scanners. -.PP -.I warning, rule cannot be matched -indicates that the given rule -cannot be matched because it follows other rules that will -always match the same text as it. For -example, in the following "foo" cannot be matched because it comes after -an identifier "catch-all" rule: -.nf - - [a-z]+ got_identifier(); - foo got_foo(); - -.fi -Using -.B REJECT -in a scanner suppresses this warning. -.PP -.I warning, -.B \-s -.I -option given but default rule can be matched -means that it is possible (perhaps only in a particular start condition) -that the default rule (match any single character) is the only one -that will match a particular input. Since -.B \-s -was given, presumably this is not intended. -.PP -.I reject_used_but_not_detected undefined -or -.I yymore_used_but_not_detected undefined - -These errors can occur at compile time. They indicate that the -scanner uses -.B REJECT -or -.B yymore() -but that -.I flex -failed to notice the fact, meaning that -.I flex -scanned the first two sections looking for occurrences of these actions -and failed to find any, but somehow you snuck some in (via a #include -file, for example). Make an explicit reference to the action in your -.I flex -input file. (Note that previously -.I flex -supported a -.B %used/%unused -mechanism for dealing with this problem; this feature is still supported -but now deprecated, and will go away soon unless the author hears from -people who can argue compellingly that they need it.) -.PP -.I flex scanner jammed - -a scanner compiled with -.B \-s -has encountered an input string which wasn't matched by -any of its rules. This error can also occur due to internal problems. -.PP -.I token too large, exceeds YYLMAX - -your scanner uses -.B %array -and one of its rules matched a string longer than the -.B YYLMAX -constant (8K bytes by default). You can increase the value by -#define'ing -.B YYLMAX -in the definitions section of your -.I flex -input. -.PP -.I scanner requires \-8 flag to -.I use the character 'x' - -Your scanner specification includes recognizing the 8-bit character -.I 'x' -and you did not specify the \-8 flag, and your scanner defaulted to 7-bit -because you used the -.B \-Cf -or -.B \-CF -table compression options. See the discussion of the -.B \-7 -flag for details. -.PP -.I flex scanner push-back overflow - -you used -.B unput() -to push back so much text that the scanner's buffer could not hold -both the pushed-back text and the current token in -.B yytext. -Ideally the scanner should dynamically resize the buffer in this case, but at -present it does not. -.PP -.I -input buffer overflow, can't enlarge buffer because scanner uses REJECT - -the scanner was working on matching an extremely large token and needed -to expand the input buffer. This doesn't work with scanners that use -.B -REJECT. -.PP -.I -fatal flex scanner internal error--end of buffer missed - -This can occur in an scanner which is reentered after a long-jump -has jumped out (or over) the scanner's activation frame. Before -reentering the scanner, use: -.nf - - yyrestart( yyin ); - -.fi -or, as noted above, switch to using the C++ scanner class. -.PP -.I too many start conditions in <> construct! - -you listed more start conditions in a <> construct than exist (so -you must have listed at least one of them twice). -.SH FILES -See flex(1). -.SH DEFICIENCIES / BUGS -Again, see flex(1). -.SH "SEE ALSO" -.PP -flex(1), lex(1), yacc(1), sed(1), awk(1). -.PP -M. E. Lesk and E. Schmidt, -.I LEX \- Lexical Analyzer Generator -.SH AUTHOR -Vern Paxson, with the help of many ideas and much inspiration from -Van Jacobson. Original version by Jef Poskanzer. The fast table -representation is a partial implementation of a design done by Van -Jacobson. The implementation was done by Kevin Gong and Vern Paxson. -.PP -Thanks to the many -.I flex -beta-testers, feedbackers, and contributors, especially Francois Pinard, -Casey Leedom, -Nelson H.F. Beebe, benson@odi.com, Peter A. Bigot, Keith Bostic, Frederic -Brehm, Nick Christopher, Jason Coughlin, Bill Cox, Dave Curtis, Scott David -Daniels, Chris G. Demetriou, Mike Donahue, Chuck Doucette, Tom Epperly, Leo -Eskin, Chris Faylor, Jon Forrest, Kaveh R. Ghazi, -Eric Goldman, Ulrich Grepel, Jan Hajic, -Jarkko Hietaniemi, Eric Hughes, John Interrante, -Ceriel Jacobs, Jeffrey R. Jones, Henry -Juengst, Amir Katz, ken@ken.hilco.com, Kevin B. Kenny, Marq Kole, Ronald -Lamprecht, Greg Lee, Craig Leres, John Levine, Mohamed el Lozy, Chris -Metcalf, Luke Mewburn, Jim Meyering, G.T. Nicol, Landon Noll, Marc Nozell, -Richard Ohnemus, Sven Panne, Roland Pesch, Walter Pelissero, Gaumond -Pierre, Esmond Pitt, Jef Poskanzer, Joe Rahmeh, Frederic Raimbault, -Rick Richardson, -Kevin Rodgers, Jim Roskind, -Doug Schmidt, Philippe Schnoebelen, -Alex Siegel, Paul Stuart, Dave Tallman, Chris Thewalt, -Paul Tuinenga, Gary Weik, Frank Whaley, Gerhard Wilhelms, Kent Williams, Ken -Yap, Nathan Zelle, David Zuhn, and those whose names have slipped my marginal -mail-archiving skills but whose contributions are appreciated all the -same. -.PP -Thanks to Keith Bostic, Jon Forrest, Noah Friedman, -John Gilmore, Craig Leres, John Levine, Bob Mulcahy, G.T. -Nicol, Francois Pinard, Rich Salz, and Richard Stallman for help with various -distribution headaches. -.PP -Thanks to Esmond Pitt and Earle Horton for 8-bit character support; to -Benson Margulies and Fred Burke for C++ support; to Kent Williams and Tom -Epperly for C++ class support; to Ove Ewerlid for support of NUL's; and to -Eric Hughes for support of multiple buffers. -.PP -This work was primarily done when I was with the Real Time Systems Group -at the Lawrence Berkeley Laboratory in Berkeley, CA. Many thanks to all there -for the support I received. -.PP -Send comments to: -.nf - - Vern Paxson - Systems Engineering - Bldg. 46A, Room 1123 - Lawrence Berkeley Laboratory - University of California - Berkeley, CA 94720 - - vern@ee.lbl.gov - -.fi diff --git a/gnu/usr.bin/lex/gen.c b/gnu/usr.bin/lex/gen.c deleted file mode 100644 index f899c89559a7..000000000000 --- a/gnu/usr.bin/lex/gen.c +++ /dev/null @@ -1,1448 +0,0 @@ -/* gen - actual generation (writing) of flex scanners */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * 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. - */ - -/* $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/gen.c,v 1.6 1993/12/09 19:06:16 jtc Exp $ */ - -#include "flexdef.h" - - -/* declare functions that have forward references */ - -void gen_next_state PROTO((int)); -void genecs PROTO((void)); -void indent_put2s PROTO((char [], char [])); -void indent_puts PROTO((char [])); - - -static int indent_level = 0; /* each level is 8 spaces */ - -#define indent_up() (++indent_level) -#define indent_down() (--indent_level) -#define set_indent(indent_val) indent_level = indent_val - -/* *Everything* is done in terms of arrays starting at 1, so provide - * a null entry for the zero element of all C arrays. - */ -static char C_int_decl[] = "static const int %s[%d] =\n { 0,\n"; -static char C_short_decl[] = "static const short int %s[%d] =\n { 0,\n"; -static char C_long_decl[] = "static const long int %s[%d] =\n { 0,\n"; -static char C_state_decl[] = - "static const yy_state_type %s[%d] =\n { 0,\n"; - - -/* Indent to the current level. */ - -void do_indent() - { - register int i = indent_level * 8; - - while ( i >= 8 ) - { - putchar( '\t' ); - i -= 8; - } - - while ( i > 0 ) - { - putchar( ' ' ); - --i; - } - } - - -/* Generate the code to keep backing-up information. */ - -void gen_backing_up() - { - if ( reject || num_backing_up == 0 ) - return; - - if ( fullspd ) - indent_puts( "if ( yy_current_state[-1].yy_nxt )" ); - else - indent_puts( "if ( yy_accept[yy_current_state] )" ); - - indent_up(); - indent_puts( "{" ); - indent_puts( "yy_last_accepting_state = yy_current_state;" ); - indent_puts( "yy_last_accepting_cpos = yy_cp;" ); - indent_puts( "}" ); - indent_down(); - } - - -/* Generate the code to perform the backing up. */ - -void gen_bu_action() - { - if ( reject || num_backing_up == 0 ) - return; - - set_indent( 3 ); - - indent_puts( "case 0: /* must back up */" ); - indent_puts( "/* undo the effects of YY_DO_BEFORE_ACTION */" ); - indent_puts( "*yy_cp = yy_hold_char;" ); - - if ( fullspd || fulltbl ) - indent_puts( "yy_cp = yy_last_accepting_cpos + 1;" ); - else - /* Backing-up info for compressed tables is taken \after/ - * yy_cp has been incremented for the next state. - */ - indent_puts( "yy_cp = yy_last_accepting_cpos;" ); - - indent_puts( "yy_current_state = yy_last_accepting_state;" ); - indent_puts( "goto yy_find_action;" ); - putchar( '\n' ); - - set_indent( 0 ); - } - - -/* genctbl - generates full speed compressed transition table */ - -void genctbl() - { - register int i; - int end_of_buffer_action = num_rules + 1; - - /* Table of verify for transition and offset to next state. */ - printf( "static const struct yy_trans_info yy_transition[%d] =\n", - tblend + numecs + 1 ); - printf( " {\n" ); - - /* We want the transition to be represented as the offset to the - * next state, not the actual state number, which is what it currently - * is. The offset is base[nxt[i]] - (base of current state)]. That's - * just the difference between the starting points of the two involved - * states (to - from). - * - * First, though, we need to find some way to put in our end-of-buffer - * flags and states. We do this by making a state with absolutely no - * transitions. We put it at the end of the table. - */ - - /* We need to have room in nxt/chk for two more slots: One for the - * action and one for the end-of-buffer transition. We now *assume* - * that we're guaranteed the only character we'll try to index this - * nxt/chk pair with is EOB, i.e., 0, so we don't have to make sure - * there's room for jam entries for other characters. - */ - - while ( tblend + 2 >= current_max_xpairs ) - expand_nxt_chk(); - - while ( lastdfa + 1 >= current_max_dfas ) - increase_max_dfas(); - - base[lastdfa + 1] = tblend + 2; - nxt[tblend + 1] = end_of_buffer_action; - chk[tblend + 1] = numecs + 1; - chk[tblend + 2] = 1; /* anything but EOB */ - - /* So that "make test" won't show arb. differences. */ - nxt[tblend + 2] = 0; - - /* Make sure every state has a end-of-buffer transition and an - * action #. - */ - for ( i = 0; i <= lastdfa; ++i ) - { - register int anum = dfaacc[i].dfaacc_state; - - chk[base[i]] = EOB_POSITION; - chk[base[i] - 1] = ACTION_POSITION; - nxt[base[i] - 1] = anum; /* action number */ - } - - for ( i = 0; i <= tblend; ++i ) - { - if ( chk[i] == EOB_POSITION ) - transition_struct_out( 0, base[lastdfa + 1] - i ); - - else if ( chk[i] == ACTION_POSITION ) - transition_struct_out( 0, nxt[i] ); - - else if ( chk[i] > numecs || chk[i] == 0 ) - transition_struct_out( 0, 0 ); /* unused slot */ - - else /* verify, transition */ - transition_struct_out( chk[i], - base[nxt[i]] - (i - chk[i]) ); - } - - - /* Here's the final, end-of-buffer state. */ - transition_struct_out( chk[tblend + 1], nxt[tblend + 1] ); - transition_struct_out( chk[tblend + 2], nxt[tblend + 2] ); - - printf( " };\n" ); - printf( "\n" ); - - /* Table of pointers to start states. */ - printf( - "static const struct yy_trans_info *yy_start_state_list[%d] =\n", - lastsc * 2 + 1 ); - printf( " {\n" ); /* } so vi doesn't get confused */ - - for ( i = 0; i <= lastsc * 2; ++i ) - printf( " &yy_transition[%d],\n", base[i] ); - - dataend(); - - if ( useecs ) - genecs(); - } - - -/* Generate equivalence-class tables. */ - -void genecs() - { - Char clower(); - register int i, j; - int numrows; - - printf( C_int_decl, "yy_ec", csize ); - - for ( i = 1; i < csize; ++i ) - { - if ( caseins && (i >= 'A') && (i <= 'Z') ) - ecgroup[i] = ecgroup[clower( i )]; - - ecgroup[i] = ABS( ecgroup[i] ); - mkdata( ecgroup[i] ); - } - - dataend(); - - if ( trace ) - { - fputs( "\n\nEquivalence Classes:\n\n", stderr ); - - numrows = csize / 8; - - for ( j = 0; j < numrows; ++j ) - { - for ( i = j; i < csize; i = i + numrows ) - { - fprintf( stderr, "%4s = %-2d", - readable_form( i ), ecgroup[i] ); - - putc( ' ', stderr ); - } - - putc( '\n', stderr ); - } - } - } - - -/* Generate the code to find the action number. */ - -void gen_find_action() - { - if ( fullspd ) - indent_puts( "yy_act = yy_current_state[-1].yy_nxt;" ); - - else if ( fulltbl ) - indent_puts( "yy_act = yy_accept[yy_current_state];" ); - - else if ( reject ) - { - indent_puts( "yy_current_state = *--yy_state_ptr;" ); - indent_puts( "yy_lp = yy_accept[yy_current_state];" ); - - puts( - "find_rule: /* we branch to this label when backing up */" ); - - indent_puts( - "for ( ; ; ) /* until we find what rule we matched */" ); - - indent_up(); - - indent_puts( "{" ); - - indent_puts( - "if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )" ); - indent_up(); - indent_puts( "{" ); - indent_puts( "yy_act = yy_acclist[yy_lp];" ); - - if ( variable_trailing_context_rules ) - { - indent_puts( "if ( yy_act & YY_TRAILING_HEAD_MASK ||" ); - indent_puts( " yy_looking_for_trail_begin )" ); - indent_up(); - indent_puts( "{" ); - - indent_puts( - "if ( yy_act == yy_looking_for_trail_begin )" ); - indent_up(); - indent_puts( "{" ); - indent_puts( "yy_looking_for_trail_begin = 0;" ); - indent_puts( "yy_act &= ~YY_TRAILING_HEAD_MASK;" ); - indent_puts( "break;" ); - indent_puts( "}" ); - indent_down(); - - indent_puts( "}" ); - indent_down(); - - indent_puts( "else if ( yy_act & YY_TRAILING_MASK )" ); - indent_up(); - indent_puts( "{" ); - indent_puts( - "yy_looking_for_trail_begin = yy_act & ~YY_TRAILING_MASK;" ); - indent_puts( - "yy_looking_for_trail_begin |= YY_TRAILING_HEAD_MASK;" ); - - if ( real_reject ) - { - /* Remember matched text in case we back up - * due to REJECT. - */ - indent_puts( "yy_full_match = yy_cp;" ); - indent_puts( "yy_full_state = yy_state_ptr;" ); - indent_puts( "yy_full_lp = yy_lp;" ); - } - - indent_puts( "}" ); - indent_down(); - - indent_puts( "else" ); - indent_up(); - indent_puts( "{" ); - indent_puts( "yy_full_match = yy_cp;" ); - indent_puts( "yy_full_state = yy_state_ptr;" ); - indent_puts( "yy_full_lp = yy_lp;" ); - indent_puts( "break;" ); - indent_puts( "}" ); - indent_down(); - - indent_puts( "++yy_lp;" ); - indent_puts( "goto find_rule;" ); - } - - else - { - /* Remember matched text in case we back up due to trailing - * context plus REJECT. - */ - indent_up(); - indent_puts( "{" ); - indent_puts( "yy_full_match = yy_cp;" ); - indent_puts( "break;" ); - indent_puts( "}" ); - indent_down(); - } - - indent_puts( "}" ); - indent_down(); - - indent_puts( "--yy_cp;" ); - - /* We could consolidate the following two lines with those at - * the beginning, but at the cost of complaints that we're - * branching inside a loop. - */ - indent_puts( "yy_current_state = *--yy_state_ptr;" ); - indent_puts( "yy_lp = yy_accept[yy_current_state];" ); - - indent_puts( "}" ); - - indent_down(); - } - - else - /* compressed */ - indent_puts( "yy_act = yy_accept[yy_current_state];" ); - } - - -/* genftbl - generates full transition table */ - -void genftbl() - { - register int i; - int end_of_buffer_action = num_rules + 1; - - printf( long_align ? C_long_decl : C_short_decl, - "yy_accept", lastdfa + 1 ); - - dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; - - for ( i = 1; i <= lastdfa; ++i ) - { - register int anum = dfaacc[i].dfaacc_state; - - mkdata( anum ); - - if ( trace && anum ) - fprintf( stderr, "state # %d accepts: [%d]\n", - i, anum ); - } - - dataend(); - - if ( useecs ) - genecs(); - - /* Don't have to dump the actual full table entries - they were - * created on-the-fly. - */ - } - - -/* Generate the code to find the next compressed-table state. */ - -void gen_next_compressed_state( char_map ) -char *char_map; - { - indent_put2s( "register YY_CHAR yy_c = %s;", char_map ); - - /* Save the backing-up info \before/ computing the next state - * because we always compute one more state than needed - we - * always proceed until we reach a jam state - */ - gen_backing_up(); - - indent_puts( -"while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )" ); - indent_up(); - indent_puts( "{" ); - indent_puts( "yy_current_state = (int) yy_def[yy_current_state];" ); - - if ( usemecs ) - { - /* We've arrange it so that templates are never chained - * to one another. This means we can afford to make a - * very simple test to see if we need to convert to - * yy_c's meta-equivalence class without worrying - * about erroneously looking up the meta-equivalence - * class twice - */ - do_indent(); - - /* lastdfa + 2 is the beginning of the templates */ - printf( "if ( yy_current_state >= %d )\n", lastdfa + 2 ); - - indent_up(); - indent_puts( "yy_c = yy_meta[(unsigned int) yy_c];" ); - indent_down(); - } - - indent_puts( "}" ); - indent_down(); - - indent_puts( -"yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];" ); - } - - -/* Generate the code to find the next match. */ - -void gen_next_match() - { - /* NOTE - changes in here should be reflected in gen_next_state() and - * gen_NUL_trans(). - */ - char *char_map = useecs ? - "yy_ec[YY_SC_TO_UI(*yy_cp)]" : - "YY_SC_TO_UI(*yy_cp)"; - - char *char_map_2 = useecs ? - "yy_ec[YY_SC_TO_UI(*++yy_cp)]" : - "YY_SC_TO_UI(*++yy_cp)"; - - if ( fulltbl ) - { - indent_put2s( - "while ( (yy_current_state = yy_nxt[yy_current_state][%s]) > 0 )", - char_map ); - - indent_up(); - - if ( num_backing_up > 0 ) - { - indent_puts( "{" ); /* } for vi */ - gen_backing_up(); - putchar( '\n' ); - } - - indent_puts( "++yy_cp;" ); - - if ( num_backing_up > 0 ) - /* { for vi */ - indent_puts( "}" ); - - indent_down(); - - putchar( '\n' ); - indent_puts( "yy_current_state = -yy_current_state;" ); - } - - else if ( fullspd ) - { - indent_puts( "{" ); /* } for vi */ - indent_puts( - "register const struct yy_trans_info *yy_trans_info;\n" ); - indent_puts( "register YY_CHAR yy_c;\n" ); - indent_put2s( "for ( yy_c = %s;", char_map ); - indent_puts( - " (yy_trans_info = &yy_current_state[(unsigned int) yy_c])->" ); - indent_puts( "yy_verify == yy_c;" ); - indent_put2s( " yy_c = %s )", char_map_2 ); - - indent_up(); - - if ( num_backing_up > 0 ) - indent_puts( "{" ); /* } for vi */ - - indent_puts( "yy_current_state += yy_trans_info->yy_nxt;" ); - - if ( num_backing_up > 0 ) - { - putchar( '\n' ); - gen_backing_up(); /* { for vi */ - indent_puts( "}" ); - } - - indent_down(); /* { for vi */ - indent_puts( "}" ); - } - - else - { /* compressed */ - indent_puts( "do" ); - - indent_up(); - indent_puts( "{" ); /* } for vi */ - - gen_next_state( false ); - - indent_puts( "++yy_cp;" ); - - /* { for vi */ - indent_puts( "}" ); - indent_down(); - - do_indent(); - - if ( interactive ) - printf( "while ( yy_base[yy_current_state] != %d );\n", - jambase ); - else - printf( "while ( yy_current_state != %d );\n", - jamstate ); - - if ( ! reject && ! interactive ) - { - /* Do the guaranteed-needed backing up to figure out - * the match. - */ - indent_puts( "yy_cp = yy_last_accepting_cpos;" ); - indent_puts( - "yy_current_state = yy_last_accepting_state;" ); - } - } - } - - -/* Generate the code to find the next state. */ - -void gen_next_state( worry_about_NULs ) -int worry_about_NULs; - { /* NOTE - changes in here should be reflected in get_next_match() */ - char char_map[256]; - - if ( worry_about_NULs && ! nultrans ) - { - if ( useecs ) - (void) sprintf( char_map, - "(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : %d)", - NUL_ec ); - else - (void) sprintf( char_map, - "(*yy_cp ? YY_SC_TO_UI(*yy_cp) : %d)", NUL_ec ); - } - - else - yy_strcpy( char_map, useecs ? - "yy_ec[YY_SC_TO_UI(*yy_cp)]" : - "YY_SC_TO_UI(*yy_cp)" ); - - if ( worry_about_NULs && nultrans ) - { - if ( ! fulltbl && ! fullspd ) - /* Compressed tables back up *before* they match. */ - gen_backing_up(); - - indent_puts( "if ( *yy_cp )" ); - indent_up(); - indent_puts( "{" ); /* } for vi */ - } - - if ( fulltbl ) - indent_put2s( - "yy_current_state = yy_nxt[yy_current_state][%s];", - char_map ); - - else if ( fullspd ) - indent_put2s( - "yy_current_state += yy_current_state[%s].yy_nxt;", - char_map ); - - else - gen_next_compressed_state( char_map ); - - if ( worry_about_NULs && nultrans ) - { - /* { for vi */ - indent_puts( "}" ); - indent_down(); - indent_puts( "else" ); - indent_up(); - indent_puts( - "yy_current_state = yy_NUL_trans[yy_current_state];" ); - indent_down(); - } - - if ( fullspd || fulltbl ) - gen_backing_up(); - - if ( reject ) - indent_puts( "*yy_state_ptr++ = yy_current_state;" ); - } - - -/* Generate the code to make a NUL transition. */ - -void gen_NUL_trans() - { /* NOTE - changes in here should be reflected in get_next_match() */ - int need_backing_up = (num_backing_up > 0 && ! reject); - - if ( need_backing_up ) - /* We'll need yy_cp lying around for the gen_backing_up(). */ - indent_puts( "register char *yy_cp = yy_c_buf_p;" ); - - putchar( '\n' ); - - if ( nultrans ) - { - indent_puts( - "yy_current_state = yy_NUL_trans[yy_current_state];" ); - indent_puts( "yy_is_jam = (yy_current_state == 0);" ); - } - - else if ( fulltbl ) - { - do_indent(); - printf( "yy_current_state = yy_nxt[yy_current_state][%d];\n", - NUL_ec ); - indent_puts( "yy_is_jam = (yy_current_state <= 0);" ); - } - - else if ( fullspd ) - { - do_indent(); - printf( "register int yy_c = %d;\n", NUL_ec ); - - indent_puts( - "register const struct yy_trans_info *yy_trans_info;\n" ); - indent_puts( - "yy_trans_info = &yy_current_state[(unsigned int) yy_c];" ); - indent_puts( "yy_current_state += yy_trans_info->yy_nxt;" ); - - indent_puts( - "yy_is_jam = (yy_trans_info->yy_verify != yy_c);" ); - } - - else - { - char NUL_ec_str[20]; - - (void) sprintf( NUL_ec_str, "%d", NUL_ec ); - gen_next_compressed_state( NUL_ec_str ); - - if ( reject ) - indent_puts( "*yy_state_ptr++ = yy_current_state;" ); - - do_indent(); - - printf( "yy_is_jam = (yy_current_state == %d);\n", jamstate ); - } - - /* If we've entered an accepting state, back up; note that - * compressed tables have *already* done such backing up, so - * we needn't bother with it again. - */ - if ( need_backing_up && (fullspd || fulltbl) ) - { - putchar( '\n' ); - indent_puts( "if ( ! yy_is_jam )" ); - indent_up(); - indent_puts( "{" ); - gen_backing_up(); - indent_puts( "}" ); - indent_down(); - } - } - - -/* Generate the code to find the start state. */ - -void gen_start_state() - { - if ( fullspd ) - indent_put2s( - "yy_current_state = yy_start_state_list[yy_start%s];", - bol_needed ? " + (yy_bp[-1] == '\\n' ? 1 : 0)" : "" ); - - else - { - indent_puts( "yy_current_state = yy_start;" ); - - if ( bol_needed ) - { - indent_puts( "if ( yy_bp[-1] == '\\n' )" ); - indent_up(); - indent_puts( "++yy_current_state;" ); - indent_down(); - } - - if ( reject ) - { - /* Set up for storing up states. */ - indent_puts( "yy_state_ptr = yy_state_buf;" ); - indent_puts( "*yy_state_ptr++ = yy_current_state;" ); - } - } - } - - -/* gentabs - generate data statements for the transition tables */ - -void gentabs() - { - int i, j, k, *accset, nacc, *acc_array, total_states; - int end_of_buffer_action = num_rules + 1; - - /* *Everything* is done in terms of arrays starting at 1, so provide - * a null entry for the zero element of all C arrays. - */ - static char C_char_decl[] = - "static const YY_CHAR %s[%d] =\n { 0,\n"; /* } for vi */ - - acc_array = allocate_integer_array( current_max_dfas ); - nummt = 0; - - /* The compressed table format jams by entering the "jam state", - * losing information about the previous state in the process. - * In order to recover the previous state, we effectively need - * to keep backing-up information. - */ - ++num_backing_up; - - if ( reject ) - { - /* Write out accepting list and pointer list. - * - * First we generate the "yy_acclist" array. In the process, - * we compute the indices that will go into the "yy_accept" - * array, and save the indices in the dfaacc array. - */ - int EOB_accepting_list[2]; - - /* Set up accepting structures for the End Of Buffer state. */ - EOB_accepting_list[0] = 0; - EOB_accepting_list[1] = end_of_buffer_action; - accsiz[end_of_buffer_state] = 1; - dfaacc[end_of_buffer_state].dfaacc_set = EOB_accepting_list; - - printf( long_align ? C_long_decl : C_short_decl, - "yy_acclist", MAX( numas, 1 ) + 1 ); - - j = 1; /* index into "yy_acclist" array */ - - for ( i = 1; i <= lastdfa; ++i ) - { - acc_array[i] = j; - - if ( accsiz[i] != 0 ) - { - accset = dfaacc[i].dfaacc_set; - nacc = accsiz[i]; - - if ( trace ) - fprintf( stderr, - "state # %d accepts: ", i ); - - for ( k = 1; k <= nacc; ++k ) - { - int accnum = accset[k]; - - ++j; - - if ( variable_trailing_context_rules && - ! (accnum & YY_TRAILING_HEAD_MASK) && - accnum > 0 && accnum <= num_rules && - rule_type[accnum] == RULE_VARIABLE ) - { - /* Special hack to flag - * accepting number as part - * of trailing context rule. - */ - accnum |= YY_TRAILING_MASK; - } - - mkdata( accnum ); - - if ( trace ) - { - fprintf( stderr, "[%d]", - accset[k] ); - - if ( k < nacc ) - fputs( ", ", stderr ); - else - putc( '\n', stderr ); - } - } - } - } - - /* add accepting number for the "jam" state */ - acc_array[i] = j; - - dataend(); - } - - else - { - dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; - - for ( i = 1; i <= lastdfa; ++i ) - acc_array[i] = dfaacc[i].dfaacc_state; - - /* add accepting number for jam state */ - acc_array[i] = 0; - } - - /* Spit out "yy_accept" array. If we're doing "reject", it'll be - * pointers into the "yy_acclist" array. Otherwise it's actual - * accepting numbers. In either case, we just dump the numbers. - */ - - /* "lastdfa + 2" is the size of "yy_accept"; includes room for C arrays - * beginning at 0 and for "jam" state. - */ - k = lastdfa + 2; - - if ( reject ) - /* We put a "cap" on the table associating lists of accepting - * numbers with state numbers. This is needed because we tell - * where the end of an accepting list is by looking at where - * the list for the next state starts. - */ - ++k; - - printf( long_align ? C_long_decl : C_short_decl, "yy_accept", k ); - - for ( i = 1; i <= lastdfa; ++i ) - { - mkdata( acc_array[i] ); - - if ( ! reject && trace && acc_array[i] ) - fprintf( stderr, "state # %d accepts: [%d]\n", - i, acc_array[i] ); - } - - /* Add entry for "jam" state. */ - mkdata( acc_array[i] ); - - if ( reject ) - /* Add "cap" for the list. */ - mkdata( acc_array[i] ); - - dataend(); - - if ( useecs ) - genecs(); - - if ( usemecs ) - { - /* Write out meta-equivalence classes (used to index - * templates with). - */ - - if ( trace ) - fputs( "\n\nMeta-Equivalence Classes:\n", stderr ); - - printf( C_int_decl, "yy_meta", numecs + 1 ); - - for ( i = 1; i <= numecs; ++i ) - { - if ( trace ) - fprintf( stderr, "%d = %d\n", - i, ABS( tecbck[i] ) ); - - mkdata( ABS( tecbck[i] ) ); - } - - dataend(); - } - - total_states = lastdfa + numtemps; - - printf( (tblend >= MAX_SHORT || long_align) ? - C_long_decl : C_short_decl, - "yy_base", total_states + 1 ); - - for ( i = 1; i <= lastdfa; ++i ) - { - register int d = def[i]; - - if ( base[i] == JAMSTATE ) - base[i] = jambase; - - if ( d == JAMSTATE ) - def[i] = jamstate; - - else if ( d < 0 ) - { - /* Template reference. */ - ++tmpuses; - def[i] = lastdfa - d + 1; - } - - mkdata( base[i] ); - } - - /* Generate jam state's base index. */ - mkdata( base[i] ); - - for ( ++i /* skip jam state */; i <= total_states; ++i ) - { - mkdata( base[i] ); - def[i] = jamstate; - } - - dataend(); - - printf( (total_states >= MAX_SHORT || long_align) ? - C_long_decl : C_short_decl, - "yy_def", total_states + 1 ); - - for ( i = 1; i <= total_states; ++i ) - mkdata( def[i] ); - - dataend(); - - printf( (total_states >= MAX_SHORT || long_align) ? - C_long_decl : C_short_decl, - "yy_nxt", tblend + 1 ); - - for ( i = 1; i <= tblend; ++i ) - { - if ( nxt[i] == 0 || chk[i] == 0 ) - nxt[i] = jamstate; /* new state is the JAM state */ - - mkdata( nxt[i] ); - } - - dataend(); - - printf( (total_states >= MAX_SHORT || long_align) ? - C_long_decl : C_short_decl, - "yy_chk", tblend + 1 ); - - for ( i = 1; i <= tblend; ++i ) - { - if ( chk[i] == 0 ) - ++nummt; - - mkdata( chk[i] ); - } - - dataend(); - } - - -/* Write out a formatted string (with a secondary string argument) at the - * current indentation level, adding a final newline. - */ - -void indent_put2s( fmt, arg ) -char fmt[], arg[]; - { - do_indent(); - printf( fmt, arg ); - putchar( '\n' ); - } - - -/* Write out a string at the current indentation level, adding a final - * newline. - */ - -void indent_puts( str ) -char str[]; - { - do_indent(); - puts( str ); - } - - -/* make_tables - generate transition tables and finishes generating output file - */ - -void make_tables() - { - register int i; - int did_eof_rule = false; - - skelout(); - - /* First, take care of YY_DO_BEFORE_ACTION depending on yymore - * being used. - */ - set_indent( 1 ); - - if ( yymore_used ) - { - indent_puts( "yytext_ptr -= yy_more_len; \\" ); - indent_puts( "yyleng = yy_cp - yytext_ptr; \\" ); - } - - else - indent_puts( "yyleng = yy_cp - yy_bp; \\" ); - - /* Now also deal with copying yytext_ptr to yytext if needed. */ - skelout(); - if ( yytext_is_array ) - { - indent_puts( "if ( yyleng >= YYLMAX ) \\" ); - indent_up(); - indent_puts( - "YY_FATAL_ERROR( \"token too large, exceeds YYLMAX\" ); \\" ); - indent_down(); - indent_puts( "yy_strcpy( yytext, yytext_ptr ); \\" ); - } - - set_indent( 0 ); - - skelout(); - - - printf( "#define YY_END_OF_BUFFER %d\n", num_rules + 1 ); - - if ( fullspd ) - { - /* Need to define the transet type as a size large - * enough to hold the biggest offset. - */ - int total_table_size = tblend + numecs + 1; - char *trans_offset_type = - (total_table_size >= MAX_SHORT || long_align) ? - "long" : "short"; - - set_indent( 0 ); - indent_puts( "struct yy_trans_info" ); - indent_up(); - indent_puts( "{" ); /* } for vi */ - - if ( long_align ) - indent_puts( "long yy_verify;" ); - else - indent_puts( "short yy_verify;" ); - - /* In cases where its sister yy_verify *is* a "yes, there is - * a transition", yy_nxt is the offset (in records) to the - * next state. In most cases where there is no transition, - * the value of yy_nxt is irrelevant. If yy_nxt is the -1th - * record of a state, though, then yy_nxt is the action number - * for that state. - */ - - indent_put2s( "%s yy_nxt;", trans_offset_type ); - indent_puts( "};" ); - indent_down(); - } - - if ( fullspd ) - genctbl(); - else if ( fulltbl ) - genftbl(); - else - gentabs(); - - /* Definitions for backing up. We don't need them if REJECT - * is being used because then we use an alternative backin-up - * technique instead. - */ - if ( num_backing_up > 0 && ! reject ) - { - if ( ! C_plus_plus ) - { - indent_puts( - "static yy_state_type yy_last_accepting_state;" ); - indent_puts( - "static char *yy_last_accepting_cpos;\n" ); - } - } - - if ( nultrans ) - { - printf( C_state_decl, "yy_NUL_trans", lastdfa + 1 ); - - for ( i = 1; i <= lastdfa; ++i ) - { - if ( fullspd ) - printf( " &yy_transition[%d],\n", base[i] ); - else - mkdata( nultrans[i] ); - } - - dataend(); - } - - if ( ddebug ) - { /* Spit out table mapping rules to line numbers. */ - indent_puts( "extern int yy_flex_debug;" ); - indent_puts( "int yy_flex_debug = 1;\n" ); - - printf( long_align ? C_long_decl : C_short_decl, - "yy_rule_linenum", num_rules ); - for ( i = 1; i < num_rules; ++i ) - mkdata( rule_linenum[i] ); - dataend(); - } - - if ( reject ) - { - /* Declare state buffer variables. */ - if ( ! C_plus_plus ) - { - puts( - "static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;" ); - puts( "static char *yy_full_match;" ); - puts( "static int yy_lp;" ); - } - - if ( variable_trailing_context_rules ) - { - if ( ! C_plus_plus ) - { - puts( - "static int yy_looking_for_trail_begin = 0;" ); - puts( "static int yy_full_lp;" ); - puts( "static int *yy_full_state;" ); - } - - printf( "#define YY_TRAILING_MASK 0x%x\n", - (unsigned int) YY_TRAILING_MASK ); - printf( "#define YY_TRAILING_HEAD_MASK 0x%x\n", - (unsigned int) YY_TRAILING_HEAD_MASK ); - } - - puts( "#define REJECT \\" ); - puts( "{ \\" ); /* } for vi */ - puts( - "*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \\" ); - puts( - "yy_cp = yy_full_match; /* restore poss. backed-over text */ \\" ); - - if ( variable_trailing_context_rules ) - { - puts( - "yy_lp = yy_full_lp; /* restore orig. accepting pos. */ \\" ); - puts( - "yy_state_ptr = yy_full_state; /* restore orig. state */ \\" ); - puts( - "yy_current_state = *yy_state_ptr; /* restore curr. state */ \\" ); - } - - puts( "++yy_lp; \\" ); - puts( "goto find_rule; \\" ); - /* { for vi */ - puts( "}" ); - } - - else - { - puts( - "/* The intent behind this definition is that it'll catch" ); - puts( " * any uses of REJECT which flex missed." ); - puts( " */" ); - puts( "#define REJECT reject_used_but_not_detected" ); - } - - if ( yymore_used ) - { - if ( ! C_plus_plus ) - { - indent_puts( "static int yy_more_flag = 0;" ); - indent_puts( "static int yy_more_len = 0;" ); - } - - indent_puts( "#define yymore() (yy_more_flag = 1)" ); - indent_puts( "#define YY_MORE_ADJ yy_more_len" ); - } - - else - { - indent_puts( "#define yymore() yymore_used_but_not_detected" ); - indent_puts( "#define YY_MORE_ADJ 0" ); - } - - if ( ! C_plus_plus ) - { - if ( yytext_is_array ) - { - puts( "#ifndef YYLMAX" ); - puts( "#define YYLMAX 8192" ); - puts( "#endif\n" ); - puts( "char yytext[YYLMAX];" ); - puts( "char *yytext_ptr;" ); - } - - else - puts( "char *yytext;" ); - } - - fputs( &action_array[defs1_offset], stdout ); - - skelout(); - - if ( ! C_plus_plus ) - { - if ( use_read ) - { - printf( -"\tif ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\\n" ); - printf( - "\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );\n" ); - } - - else - { - printf( - "\tif ( yy_current_buffer->is_interactive ) \\\n" ); - printf( -"\t\tresult = ((int) (buf[0] = getc( yyin ))) == EOF ? 0 : 1; \\\n" ); - printf( -"\telse if ( ((result = fread( (char *) buf, 1, max_size, yyin )) == 0)\\\n" ); - printf( "\t\t && ferror( yyin ) ) \\\n" ); - printf( - "\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );\n" ); - } - } - - skelout(); - - /* Copy prolog to output file. */ - fputs( &action_array[prolog_offset], stdout ); - - skelout(); - - set_indent( 2 ); - - if ( yymore_used ) - { - indent_puts( "yy_more_len = 0;" ); - indent_puts( "if ( yy_more_flag )" ); - indent_up(); - indent_puts( "{" ); - indent_puts( "yy_more_len = yyleng;" ); - indent_puts( "yy_more_flag = 0;" ); - indent_puts( "}" ); - indent_down(); - } - - skelout(); - - gen_start_state(); - - /* Note, don't use any indentation. */ - puts( "yy_match:" ); - gen_next_match(); - - skelout(); - set_indent( 2 ); - gen_find_action(); - - skelout(); - if ( lex_compat ) - { - indent_puts( "if ( yy_act != YY_END_OF_BUFFER )" ); - indent_up(); - indent_puts( "{" ); - indent_puts( "int yyl;" ); - indent_puts( "for ( yyl = 0; yyl < yyleng; ++yyl )" ); - indent_up(); - indent_puts( "if ( yytext[yyl] == '\\n' )" ); - indent_up(); - indent_puts( "++yylineno;" ); - indent_down(); - indent_down(); - indent_puts( "}" ); - indent_down(); - } - - skelout(); - if ( ddebug ) - { - indent_puts( "if ( yy_flex_debug )" ); - indent_up(); - - indent_puts( "{" ); - indent_puts( "if ( yy_act == 0 )" ); - indent_up(); - indent_puts( - "fprintf( stderr, \"--scanner backing up\\n\" );" ); - indent_down(); - - do_indent(); - printf( "else if ( yy_act < %d )\n", num_rules ); - indent_up(); - indent_puts( - "fprintf( stderr, \"--accepting rule at line %d (\\\"%s\\\")\\n\"," ); - indent_puts( " yy_rule_linenum[yy_act], yytext );" ); - indent_down(); - - do_indent(); - printf( "else if ( yy_act == %d )\n", num_rules ); - indent_up(); - indent_puts( - "fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\"," ); - indent_puts( " yytext );" ); - indent_down(); - - do_indent(); - printf( "else if ( yy_act == %d )\n", num_rules + 1 ); - indent_up(); - indent_puts( - "fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );" ); - indent_down(); - - do_indent(); - printf( "else\n" ); - indent_up(); - indent_puts( - "fprintf( stderr, \"--EOF (start condition %d)\\n\", YY_START );" ); - indent_down(); - - indent_puts( "}" ); - indent_down(); - } - - /* Copy actions to output file. */ - skelout(); - indent_up(); - gen_bu_action(); - fputs( &action_array[action_offset], stdout ); - - /* generate cases for any missing EOF rules */ - for ( i = 1; i <= lastsc; ++i ) - if ( ! sceof[i] ) - { - do_indent(); - printf( "case YY_STATE_EOF(%s):\n", scname[i] ); - did_eof_rule = true; - } - - if ( did_eof_rule ) - { - indent_up(); - indent_puts( "yyterminate();" ); - indent_down(); - } - - - /* Generate code for handling NUL's, if needed. */ - - /* First, deal with backing up and setting up yy_cp if the scanner - * finds that it should JAM on the NUL> - */ - skelout(); - set_indent( 7 ); - - if ( fullspd || fulltbl ) - indent_puts( "yy_cp = yy_c_buf_p;" ); - - else - { /* compressed table */ - if ( ! reject && ! interactive ) - { - /* Do the guaranteed-needed backing up to figure - * out the match. - */ - indent_puts( "yy_cp = yy_last_accepting_cpos;" ); - indent_puts( - "yy_current_state = yy_last_accepting_state;" ); - } - } - - - /* Generate code for yy_get_previous_state(). */ - set_indent( 1 ); - skelout(); - - if ( bol_needed ) - indent_puts( "register char *yy_bp = yytext_ptr;\n" ); - - gen_start_state(); - - set_indent( 2 ); - skelout(); - gen_next_state( true ); - - set_indent( 1 ); - skelout(); - gen_NUL_trans(); - - skelout(); - if ( lex_compat ) - { /* update yylineno inside of unput() */ - indent_puts( "if ( c == '\\n' )" ); - indent_up(); - indent_puts( "--yylineno;" ); - indent_down(); - } - - skelout(); - - /* Copy remainder of input to output. */ - - line_directive_out( stdout ); - - if ( sectnum == 3 ) - (void) flexscan(); /* copy remainder of input to output */ - } diff --git a/gnu/usr.bin/lex/initscan.c b/gnu/usr.bin/lex/initscan.c deleted file mode 100644 index 1290d96ed319..000000000000 --- a/gnu/usr.bin/lex/initscan.c +++ /dev/null @@ -1,2534 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/initscan.c,v 1.6 1993/12/09 19:06:21 jtc Exp $ - */ - -#define FLEX_SCANNER - -#include - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include -#include - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#ifdef __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - - -#ifdef __TURBOC__ -#define YY_USE_CONST -#endif - - -#ifndef YY_USE_CONST -#ifndef const -#define const -#endif -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. - */ -#define YY_START ((yy_start - 1) / 2) - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". Now included - * only for backward compatibility with previous versions of flex. - */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; -extern FILE *yyin, *yyout; - -#ifdef __cplusplus -extern "C" { -#endif - extern void *yy_flex_alloc YY_PROTO(( int )); - extern void *yy_flex_realloc YY_PROTO(( void *ptr, int size )); - extern void yy_flex_free YY_PROTO(( void * )); - extern int yywrap YY_PROTO(( void )); - extern void yy_strcpy YY_PROTO(( char *s1, const char *s2 )); -#ifdef __cplusplus - } -#endif - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - - -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - int yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int is_interactive; - - /* Whether we've seen an EOF on this buffer. */ - int yy_eof_status; -#define EOF_NOT_SEEN 0 - /* "Pending" happens when the EOF has been seen but there's still - * some text to process. Note that when we actually see the EOF, - * we switch the status back to "not seen" (via yyrestart()), so - * that the user can continue scanning by just pointing yyin at - * a new input file. - */ -#define EOF_PENDING 1 - }; - -static YY_BUFFER_STATE yy_current_buffer = 0; - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed. */ -static char yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - -int yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -void yyrestart YY_PROTO(( FILE *input_file )); -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); - -#define yy_new_buffer yy_create_buffer - -#define INITIAL 0 -#define SECT2 1 -#define SECT2PROLOG 2 -#define SECT3 3 -#define CODEBLOCK 4 -#define PICKUPDEF 5 -#define SC 6 -#define CARETISBOL 7 -#define NUM 8 -#define QUOTE 9 -#define FIRSTCCL 10 -#define CCL 11 -#define ACTION 12 -#define RECOVER 13 -#define BRACEERROR 14 -#define C_COMMENT 15 -#define ACTION_COMMENT 16 -#define ACTION_STRING 17 -#define PERCENT_BRACE_ACTION 18 -#define USED_LIST 19 -#define CODEBLOCK_2 20 -typedef unsigned char YY_CHAR; -typedef int yy_state_type; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; -extern char *yytext; -#define yytext_ptr yytext - -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( const char msg[] )); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = yy_cp - yy_bp; \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define YY_END_OF_BUFFER 113 -static const short int yy_accept[408] = - { 0, - 0, 0, 0, 0, 41, 41, 110, 110, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 113, 111, 6, 17, 111, 15, 1, 16, - 111, 111, 111, 14, 60, 53, 54, 60, 47, 60, - 59, 60, 60, 60, 60, 44, 43, 60, 60, 45, - 46, 41, 42, 41, 40, 39, 40, 40, 110, 110, - 26, 27, 26, 26, 26, 26, 26, 26, 29, 28, - 30, 29, 65, 61, 62, 64, 66, 80, 81, 80, - - 78, 77, 79, 67, 69, 67, 68, 67, 72, 72, - 72, 74, 76, 74, 74, 74, 75, 92, 97, 92, - 96, 98, 98, 93, 93, 93, 90, 91, 111, 31, - 111, 83, 111, 82, 20, 22, 20, 21, 101, 102, - 101, 100, 103, 105, 103, 106, 107, 88, 88, 89, - 88, 88, 88, 88, 88, 88, 36, 33, 32, 36, - 36, 36, 88, 6, 17, 0, 17, 15, 1, 16, - 0, 16, 13, 7, 0, 0, 0, 3, 0, 4, - 0, 2, 14, 53, 54, 0, 0, 0, 54, 50, - 50, 0, 0, 57, 0, 108, 108, 108, 49, 48, - - 49, 44, 43, 0, 43, 56, 44, 41, 42, 40, - 39, 39, 37, 38, 110, 110, 26, 27, 26, 26, - 26, 26, 29, 28, 30, 63, 64, 81, 77, 69, - 109, 109, 109, 70, 71, 76, 73, 92, 97, 0, - 95, 0, 94, 93, 93, 93, 0, 31, 0, 31, - 31, 83, 20, 22, 18, 101, 102, 101, 102, 102, - 99, 103, 105, 104, 88, 88, 88, 89, 85, 88, - 88, 88, 36, 33, 32, 36, 36, 84, 13, 7, - 0, 12, 0, 0, 0, 0, 3, 0, 0, 4, - 0, 5, 0, 51, 0, 52, 0, 0, 57, 0, - - 57, 57, 108, 108, 49, 49, 58, 56, 37, 38, - 26, 26, 26, 23, 26, 0, 109, 109, 93, 93, - 0, 19, 0, 85, 85, 88, 88, 36, 36, 12, - 0, 0, 0, 3, 0, 0, 4, 5, 5, 52, - 52, 0, 57, 57, 57, 57, 108, 26, 26, 23, - 23, 0, 109, 93, 93, 19, 19, 88, 88, 36, - 36, 0, 0, 0, 10, 0, 57, 57, 57, 57, - 26, 26, 93, 93, 88, 88, 36, 36, 0, 0, - 0, 0, 57, 57, 24, 25, 86, 87, 86, 87, - 34, 35, 0, 9, 0, 0, 11, 55, 9, 9, - - 0, 0, 8, 0, 8, 8, 0 - } ; - -static const int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 5, 1, 6, 7, 1, 8, 9, - 9, 10, 9, 11, 12, 9, 13, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 1, 1, 15, - 1, 16, 9, 1, 22, 23, 24, 25, 26, 27, - 21, 21, 28, 29, 30, 21, 31, 32, 33, 34, - 21, 35, 36, 37, 38, 21, 21, 39, 40, 21, - 17, 18, 19, 20, 21, 1, 22, 23, 24, 25, - - 26, 27, 21, 21, 28, 29, 30, 21, 31, 32, - 33, 34, 21, 35, 36, 37, 38, 21, 21, 39, - 40, 21, 41, 42, 43, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static const int yy_meta[44] = - { 0, - 1, 2, 3, 1, 4, 1, 1, 5, 1, 6, - 1, 7, 5, 8, 1, 1, 1, 9, 10, 1, - 11, 12, 12, 12, 12, 12, 12, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 13, 11, 11, 11, - 5, 1, 14 - } ; - -static const short int yy_base[470] = - { 0, - 0, 43, 85, 126, 89, 102, 1611, 1610, 168, 1605, - 108, 111, 211, 0, 1591, 1590, 252, 254, 116, 119, - 98, 122, 144, 146, 297, 0, 93, 104, 338, 340, - 149, 151, 257, 266, 268, 274, 383, 0, 425, 428, - 1596, 1595, 1607, 1615, 278, 1602, 1602, 0, 281, 1600, - 1600, 462, 1592, 0, 1615, 431, 1597, 1597, 1615, 285, - 1615, 1584, 1580, 331, 503, 437, 1593, 1593, 110, 1580, - 1615, 0, 1590, 1590, 0, 1590, 1588, 221, 1587, 1615, - 0, 1585, 1585, 1615, 0, 1561, 1546, 1511, 0, 1551, - 1543, 1543, 1615, 1615, 1498, 0, 1615, 1615, 1500, 1487, - - 1615, 1463, 1615, 1615, 1466, 1460, 1615, 332, 1615, 333, - 126, 1615, 1411, 1398, 0, 334, 1615, 0, 1383, 1383, - 1615, 341, 1371, 0, 1354, 1336, 1615, 1615, 271, 1371, - 287, 1370, 1366, 1615, 0, 1362, 1349, 1331, 290, 1335, - 347, 1325, 0, 1323, 1310, 1615, 0, 0, 350, 1306, - 1287, 1246, 1615, 0, 1249, 1227, 0, 1264, 1261, 1255, - 1225, 1197, 1213, 351, 1213, 1213, 1615, 0, 358, 1198, - 1193, 1615, 0, 0, 443, 361, 447, 0, 342, 0, - 363, 1615, 0, 451, 1191, 1188, 1149, 365, 1615, 1615, - 1185, 1181, 1155, 1135, 423, 1615, 1125, 0, 0, 1615, - - 546, 588, 1121, 1108, 1615, 0, 1615, 0, 1615, 0, - 0, 1095, 0, 0, 1088, 1615, 0, 1615, 0, 1061, - 1041, 630, 0, 1069, 1615, 1615, 0, 1615, 838, 1615, - 1615, 837, 0, 1615, 1615, 1615, 1615, 0, 1615, 434, - 1615, 0, 1615, 0, 821, 817, 373, 843, 376, 1615, - 842, 1615, 0, 1615, 463, 467, 834, 471, 1615, 833, - 1615, 0, 1615, 1615, 0, 441, 793, 1615, 673, 0, - 805, 802, 0, 830, 1615, 795, 792, 1615, 0, 0, - 594, 818, 817, 597, 784, 790, 0, 775, 786, 0, - 473, 807, 478, 1615, 486, 806, 590, 776, 790, 588, - - 469, 703, 793, 0, 0, 0, 1615, 0, 0, 0, - 780, 772, 0, 800, 800, 730, 788, 0, 775, 767, - 600, 795, 602, 0, 773, 772, 764, 770, 762, 1615, - 610, 772, 751, 0, 740, 745, 0, 1615, 765, 1615, - 764, 740, 488, 803, 601, 817, 1615, 742, 730, 1615, - 760, 760, 1615, 738, 726, 1615, 756, 735, 723, 733, - 721, 714, 716, 726, 1615, 724, 602, 831, 715, 658, - 512, 473, 454, 459, 435, 438, 422, 430, 606, 410, - 357, 342, 338, 278, 0, 0, 0, 0, 0, 0, - 0, 0, 614, 255, 618, 131, 1615, 1615, 1615, 156, - - 620, 622, 153, 625, 1615, 95, 1615, 858, 872, 886, - 900, 914, 928, 942, 956, 970, 984, 998, 1012, 1026, - 1040, 1054, 1062, 1075, 1081, 1094, 1108, 1122, 1136, 1150, - 1164, 1178, 1186, 1199, 1207, 1220, 1234, 1248, 1262, 1272, - 1280, 1293, 1307, 1321, 1335, 1349, 1363, 1371, 1384, 1398, - 1412, 1416, 1419, 1432, 1446, 1460, 710, 1474, 1487, 1501, - 1515, 711, 1529, 1537, 1544, 712, 743, 1557, 1571 - } ; - -static const short int yy_def[470] = - { 0, - 407, 407, 408, 408, 409, 410, 411, 411, 407, 9, - 412, 412, 407, 13, 413, 413, 414, 414, 415, 415, - 416, 416, 417, 417, 407, 25, 418, 418, 413, 413, - 419, 419, 420, 420, 421, 421, 407, 37, 422, 422, - 37, 37, 407, 407, 407, 407, 407, 423, 407, 407, - 407, 424, 407, 425, 407, 407, 407, 407, 407, 407, - 407, 407, 426, 427, 407, 407, 407, 407, 407, 407, - 407, 428, 407, 428, 429, 430, 429, 429, 431, 407, - 432, 407, 432, 407, 433, 433, 433, 432, 434, 407, - 407, 434, 407, 407, 407, 435, 407, 407, 407, 407, - - 407, 407, 407, 407, 407, 407, 407, 427, 407, 436, - 437, 407, 407, 407, 438, 427, 407, 439, 407, 439, - 407, 440, 407, 441, 441, 441, 407, 407, 442, 407, - 442, 407, 407, 407, 443, 407, 443, 407, 444, 407, - 444, 407, 445, 407, 445, 407, 446, 447, 447, 407, - 447, 447, 407, 448, 448, 448, 449, 407, 407, 449, - 449, 449, 447, 407, 407, 407, 407, 423, 407, 407, - 407, 407, 450, 451, 407, 407, 407, 452, 407, 453, - 454, 407, 425, 407, 407, 407, 407, 455, 407, 407, - 407, 407, 407, 456, 426, 407, 407, 457, 458, 407, - - 407, 407, 407, 407, 407, 459, 407, 428, 407, 429, - 430, 430, 460, 461, 431, 407, 432, 407, 433, 433, - 433, 407, 434, 407, 407, 407, 435, 407, 407, 407, - 407, 407, 462, 407, 407, 407, 407, 439, 407, 440, - 407, 440, 407, 441, 441, 441, 442, 407, 442, 407, - 407, 407, 443, 407, 463, 444, 407, 444, 407, 407, - 407, 445, 407, 407, 447, 447, 447, 407, 407, 448, - 448, 448, 449, 407, 407, 449, 449, 407, 450, 451, - 407, 407, 407, 407, 407, 407, 464, 407, 407, 465, - 454, 407, 454, 407, 455, 407, 455, 407, 456, 456, - - 456, 456, 407, 466, 458, 201, 407, 459, 460, 461, - 433, 433, 222, 407, 222, 222, 407, 467, 441, 441, - 463, 407, 463, 269, 269, 448, 448, 449, 449, 407, - 407, 407, 407, 464, 407, 407, 465, 407, 407, 407, - 407, 407, 456, 456, 456, 456, 407, 433, 433, 407, - 407, 316, 407, 441, 441, 407, 407, 448, 448, 449, - 449, 407, 407, 407, 407, 407, 456, 456, 456, 456, - 433, 433, 441, 441, 448, 448, 449, 449, 468, 407, - 407, 407, 456, 456, 433, 433, 441, 441, 448, 448, - 449, 449, 468, 407, 468, 407, 407, 407, 407, 407, - - 469, 469, 407, 469, 407, 407, 0, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407 - } ; - -static const short int yy_nxt[1659] = - { 0, - 44, 45, 46, 47, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, - 44, 44, 44, 44, 49, 50, 51, 44, 44, 52, - 44, 44, 44, 44, 44, 53, 44, 44, 44, 44, - 44, 44, 44, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 44, 44, 44, 56, 57, 58, 59, - 60, 73, 74, 61, 61, 130, 131, 61, 405, 62, - - 44, 63, 64, 76, 73, 77, 130, 131, 78, 90, - 91, 92, 90, 91, 92, 110, 206, 111, 105, 106, - 107, 105, 106, 107, 44, 65, 61, 66, 67, 68, - 59, 60, 69, 108, 61, 61, 108, 235, 61, 110, - 70, 111, 63, 64, 235, 71, 113, 114, 113, 114, - 207, 136, 137, 136, 137, 115, 405, 115, 138, 399, - 138, 116, 117, 116, 117, 401, 65, 61, 81, 81, - 82, 83, 81, 81, 81, 81, 81, 84, 81, 81, - 81, 81, 81, 81, 81, 81, 81, 81, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - - 85, 85, 86, 85, 85, 85, 85, 87, 81, 81, - 81, 93, 93, 44, 93, 93, 93, 93, 93, 93, - 94, 94, 93, 93, 93, 93, 95, 93, 93, 93, - 93, 96, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 93, 93, 93, 99, 100, 99, 100, 399, 140, - 141, 213, 101, 214, 101, 102, 142, 102, 140, 141, - 144, 145, 146, 248, 249, 142, 144, 145, 146, 164, - 165, 166, 169, 170, 171, 147, 190, 191, 192, 251, - 249, 147, 257, 258, 103, 300, 103, 118, 118, 119, - - 120, 121, 118, 118, 122, 118, 118, 118, 118, 123, - 118, 118, 118, 118, 118, 118, 118, 124, 124, 124, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 125, 124, 124, 124, 124, 126, 127, 118, 128, - 132, 133, 132, 133, 197, 197, 232, 197, 241, 260, - 258, 266, 164, 165, 166, 300, 267, 398, 242, 169, - 170, 171, 281, 282, 283, 292, 293, 296, 297, 198, - 198, 233, 198, 288, 284, 248, 249, 289, 251, 249, - 134, 397, 134, 148, 149, 150, 151, 148, 148, 152, - 148, 148, 153, 148, 148, 148, 148, 148, 148, 148, - - 148, 148, 148, 154, 154, 154, 154, 154, 154, 154, - 154, 154, 154, 154, 154, 154, 154, 155, 154, 154, - 154, 154, 156, 148, 148, 148, 158, 159, 160, 158, - 159, 160, 184, 185, 186, 396, 301, 187, 202, 203, - 204, 241, 266, 187, 281, 282, 283, 267, 281, 282, - 283, 242, 184, 185, 186, 392, 284, 187, 391, 161, - 284, 302, 161, 390, 162, 322, 323, 162, 174, 257, - 258, 389, 188, 260, 258, 292, 293, 285, 188, 286, - 339, 293, 345, 175, 388, 176, 300, 176, 296, 297, - 387, 176, 188, 176, 176, 177, 176, 178, 386, 179, - - 180, 367, 181, 199, 199, 300, 199, 199, 199, 199, - 199, 199, 199, 199, 199, 199, 200, 199, 199, 199, - 199, 199, 199, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 199, 199, 199, 305, 305, 385, 305, - 305, 305, 305, 305, 305, 305, 305, 306, 305, 306, - 305, 305, 305, 305, 305, 305, 306, 306, 306, 306, - 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, - 306, 306, 306, 306, 306, 306, 305, 305, 307, 202, - 203, 204, 341, 297, 187, 281, 282, 283, 331, 282, - - 283, 343, 322, 323, 357, 323, 299, 284, 394, 395, - 284, 331, 282, 283, 369, 383, 394, 395, 300, 300, - 400, 395, 403, 404, 403, 404, 344, 406, 404, 188, - 313, 313, 314, 315, 313, 313, 313, 313, 313, 316, - 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 313, 313, 313, 324, 324, 300, 324, 324, 324, 324, - 324, 324, 325, 324, 324, 324, 324, 324, 324, 324, - 324, 324, 324, 325, 325, 325, 325, 325, 325, 325, - - 325, 325, 325, 325, 325, 325, 325, 325, 325, 325, - 325, 325, 325, 324, 324, 324, 346, 304, 318, 347, - 300, 304, 318, 347, 346, 346, 346, 346, 346, 346, - 316, 316, 300, 352, 316, 316, 316, 316, 316, 382, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 353, 381, 380, 379, 353, 378, 377, 376, 375, 356, - 374, 373, 351, 350, 372, 371, 366, 340, 338, 365, - 316, 316, 316, 325, 325, 364, 325, 325, 325, 325, - 325, 325, 363, 325, 325, 325, 325, 325, 325, 325, - 325, 325, 325, 362, 361, 360, 359, 358, 356, 355, - - 354, 231, 351, 350, 349, 348, 196, 300, 342, 340, - 338, 336, 335, 325, 325, 325, 368, 333, 332, 330, - 300, 330, 329, 328, 368, 368, 368, 368, 368, 368, - 370, 274, 327, 326, 300, 269, 259, 259, 370, 370, - 370, 370, 370, 370, 384, 250, 250, 320, 300, 319, - 317, 229, 384, 384, 384, 384, 384, 384, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 72, 72, 72, 72, 72, 72, 72, 72, - 72, 72, 72, 72, 72, 72, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, - 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, 129, 129, - - 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, - 129, 129, 135, 135, 135, 135, 135, 135, 135, 135, - 135, 135, 135, 135, 135, 135, 139, 139, 139, 139, - 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 168, 168, - 224, 312, 168, 168, 168, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 183, 183, 311, - 216, 183, 183, 183, 194, 194, 212, 194, 194, 194, - - 194, 194, 194, 194, 194, 194, 194, 194, 196, 196, - 205, 196, 196, 196, 196, 196, 196, 196, 196, 196, - 196, 196, 208, 208, 205, 208, 208, 208, 208, 208, - 208, 208, 208, 208, 208, 208, 210, 210, 303, 210, - 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, - 211, 211, 300, 211, 211, 211, 211, 211, 211, 211, - 211, 211, 211, 211, 215, 215, 215, 215, 215, 215, - 215, 215, 215, 215, 215, 215, 215, 215, 217, 217, - 298, 217, 217, 190, 217, 217, 217, 217, 190, 294, - 189, 217, 219, 219, 189, 172, 219, 219, 219, 223, - - 223, 172, 223, 223, 223, 223, 223, 223, 223, 223, - 223, 223, 223, 227, 227, 167, 167, 227, 227, 227, - 231, 231, 278, 231, 231, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 234, 234, 277, 234, 234, 234, - 234, 234, 234, 234, 234, 234, 234, 234, 237, 237, - 276, 237, 237, 237, 237, 237, 237, 275, 237, 237, - 237, 237, 238, 238, 275, 274, 272, 238, 238, 238, - 238, 238, 240, 240, 271, 240, 240, 240, 240, 240, - 240, 240, 240, 240, 240, 240, 244, 244, 269, 268, - 244, 244, 244, 247, 247, 247, 247, 247, 247, 247, - - 247, 247, 247, 247, 247, 247, 247, 253, 253, 268, - 253, 253, 263, 253, 253, 253, 253, 253, 253, 253, - 253, 256, 256, 256, 256, 256, 263, 256, 256, 256, - 256, 256, 256, 256, 256, 262, 262, 261, 259, 262, - 262, 262, 262, 255, 262, 262, 262, 262, 262, 264, - 264, 254, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 265, 265, 254, 265, 265, 252, 265, - 265, 265, 265, 252, 250, 246, 265, 270, 270, 245, - 243, 270, 270, 270, 273, 239, 239, 273, 273, 273, - 273, 273, 273, 273, 273, 273, 273, 273, 279, 279, - - 236, 279, 279, 279, 279, 279, 279, 279, 279, 279, - 279, 279, 280, 280, 236, 280, 280, 280, 280, 280, - 280, 280, 280, 280, 280, 280, 287, 287, 287, 290, - 290, 290, 291, 291, 291, 291, 291, 291, 291, 291, - 291, 291, 291, 291, 291, 291, 295, 295, 295, 295, - 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, - 299, 299, 230, 299, 299, 299, 299, 299, 299, 230, - 299, 299, 299, 299, 305, 305, 229, 305, 305, 305, - 305, 305, 305, 305, 305, 305, 305, 308, 308, 228, - 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, - - 308, 309, 309, 228, 309, 309, 309, 309, 309, 309, - 309, 309, 309, 309, 309, 310, 310, 226, 310, 310, - 310, 310, 310, 310, 310, 310, 310, 310, 310, 321, - 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, - 321, 321, 321, 334, 334, 225, 225, 334, 334, 334, - 337, 337, 224, 222, 337, 337, 337, 393, 393, 393, - 393, 393, 393, 393, 393, 393, 393, 393, 393, 393, - 393, 402, 402, 402, 402, 402, 402, 402, 402, 402, - 402, 402, 402, 402, 402, 221, 220, 218, 218, 216, - 209, 212, 209, 209, 193, 205, 205, 195, 193, 189, - - 189, 182, 172, 172, 167, 167, 407, 163, 163, 97, - 97, 88, 80, 80, 43, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407 - } ; - -static const short int yy_chk[1659] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, - 3, 5, 5, 3, 3, 27, 27, 3, 406, 3, - - 21, 3, 3, 6, 6, 6, 28, 28, 6, 11, - 11, 11, 12, 12, 12, 21, 69, 21, 19, 19, - 19, 20, 20, 20, 22, 3, 3, 4, 4, 4, - 4, 4, 4, 19, 4, 4, 20, 111, 4, 22, - 4, 22, 4, 4, 111, 4, 23, 23, 24, 24, - 69, 31, 31, 32, 32, 23, 403, 24, 31, 400, - 32, 23, 23, 24, 24, 396, 4, 4, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 17, 17, 18, 18, 394, 33, - 33, 78, 17, 78, 18, 17, 33, 18, 34, 34, - 35, 35, 35, 129, 129, 34, 36, 36, 36, 45, - 45, 45, 49, 49, 49, 35, 60, 60, 60, 131, - 131, 36, 139, 139, 17, 384, 18, 25, 25, 25, - - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 29, 29, 30, 30, 64, 108, 110, 116, 122, 141, - 141, 149, 164, 164, 164, 383, 149, 382, 122, 169, - 169, 169, 176, 176, 176, 181, 181, 188, 188, 64, - 108, 110, 116, 179, 176, 247, 247, 179, 249, 249, - 29, 381, 30, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 39, 39, 39, 40, - 40, 40, 56, 56, 56, 380, 195, 56, 66, 66, - 66, 240, 266, 66, 175, 175, 175, 266, 177, 177, - 177, 240, 184, 184, 184, 378, 175, 184, 377, 39, - 177, 195, 40, 376, 39, 255, 255, 40, 52, 256, - 256, 375, 56, 258, 258, 291, 291, 175, 66, 177, - 293, 293, 301, 52, 374, 52, 301, 52, 295, 295, - 373, 52, 184, 52, 52, 52, 52, 52, 372, 52, - - 52, 343, 52, 65, 65, 343, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 201, 201, 371, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, - 201, 201, 201, 201, 201, 201, 201, 201, 201, 202, - 202, 202, 297, 297, 202, 281, 281, 281, 284, 284, - - 284, 300, 321, 321, 323, 323, 300, 281, 379, 379, - 284, 331, 331, 331, 345, 367, 393, 393, 345, 367, - 395, 395, 401, 401, 402, 402, 300, 404, 404, 202, - 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, - 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, - 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, - 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, - 222, 222, 222, 269, 269, 370, 269, 269, 269, 269, - 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, - 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, - - 269, 269, 269, 269, 269, 269, 269, 269, 269, 269, - 269, 269, 269, 269, 269, 269, 302, 457, 462, 466, - 302, 457, 462, 466, 302, 302, 302, 302, 302, 302, - 316, 316, 369, 316, 316, 316, 316, 316, 316, 366, - 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 467, 364, 363, 362, 467, 361, 360, 359, 358, 357, - 355, 354, 352, 351, 349, 348, 342, 341, 339, 336, - 316, 316, 316, 325, 325, 335, 325, 325, 325, 325, - 325, 325, 333, 325, 325, 325, 325, 325, 325, 325, - 325, 325, 325, 332, 329, 328, 327, 326, 322, 320, - - 319, 317, 315, 314, 312, 311, 303, 299, 298, 296, - 292, 289, 288, 325, 325, 325, 344, 286, 285, 283, - 344, 282, 277, 276, 344, 344, 344, 344, 344, 344, - 346, 274, 272, 271, 346, 267, 260, 257, 346, 346, - 346, 346, 346, 346, 368, 251, 248, 246, 368, 245, - 232, 229, 368, 368, 368, 368, 368, 368, 408, 408, - 408, 408, 408, 408, 408, 408, 408, 408, 408, 408, - 408, 408, 409, 409, 409, 409, 409, 409, 409, 409, - 409, 409, 409, 409, 409, 409, 410, 410, 410, 410, - 410, 410, 410, 410, 410, 410, 410, 410, 410, 410, - - 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, - 411, 411, 411, 411, 412, 412, 412, 412, 412, 412, - 412, 412, 412, 412, 412, 412, 412, 412, 413, 413, - 413, 413, 413, 413, 413, 413, 413, 413, 413, 413, - 413, 413, 414, 414, 414, 414, 414, 414, 414, 414, - 414, 414, 414, 414, 414, 414, 415, 415, 415, 415, - 415, 415, 415, 415, 415, 415, 415, 415, 415, 415, - 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, - 416, 416, 416, 416, 417, 417, 417, 417, 417, 417, - 417, 417, 417, 417, 417, 417, 417, 417, 418, 418, - - 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, - 418, 418, 419, 419, 419, 419, 419, 419, 419, 419, - 419, 419, 419, 419, 419, 419, 420, 420, 420, 420, - 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, - 421, 421, 421, 421, 421, 421, 421, 421, 421, 421, - 421, 421, 421, 421, 422, 422, 422, 422, 422, 422, - 422, 422, 422, 422, 422, 422, 422, 422, 423, 423, - 224, 221, 423, 423, 423, 424, 424, 424, 424, 424, - 424, 424, 424, 424, 424, 424, 424, 425, 425, 220, - 215, 425, 425, 425, 426, 426, 212, 426, 426, 426, - - 426, 426, 426, 426, 426, 426, 426, 426, 427, 427, - 204, 427, 427, 427, 427, 427, 427, 427, 427, 427, - 427, 427, 428, 428, 203, 428, 428, 428, 428, 428, - 428, 428, 428, 428, 428, 428, 429, 429, 197, 429, - 429, 429, 429, 429, 429, 429, 429, 429, 429, 429, - 430, 430, 194, 430, 430, 430, 430, 430, 430, 430, - 430, 430, 430, 430, 431, 431, 431, 431, 431, 431, - 431, 431, 431, 431, 431, 431, 431, 431, 432, 432, - 193, 432, 432, 192, 432, 432, 432, 432, 191, 187, - 186, 432, 433, 433, 185, 171, 433, 433, 433, 434, - - 434, 170, 434, 434, 434, 434, 434, 434, 434, 434, - 434, 434, 434, 435, 435, 166, 165, 435, 435, 435, - 436, 436, 163, 436, 436, 436, 436, 436, 436, 436, - 436, 436, 436, 436, 437, 437, 162, 437, 437, 437, - 437, 437, 437, 437, 437, 437, 437, 437, 438, 438, - 161, 438, 438, 438, 438, 438, 438, 160, 438, 438, - 438, 438, 439, 439, 159, 158, 156, 439, 439, 439, - 439, 439, 440, 440, 155, 440, 440, 440, 440, 440, - 440, 440, 440, 440, 440, 440, 441, 441, 152, 151, - 441, 441, 441, 442, 442, 442, 442, 442, 442, 442, - - 442, 442, 442, 442, 442, 442, 442, 443, 443, 150, - 443, 443, 145, 443, 443, 443, 443, 443, 443, 443, - 443, 444, 444, 444, 444, 444, 144, 444, 444, 444, - 444, 444, 444, 444, 444, 445, 445, 142, 140, 445, - 445, 445, 445, 138, 445, 445, 445, 445, 445, 446, - 446, 137, 446, 446, 446, 446, 446, 446, 446, 446, - 446, 446, 446, 447, 447, 136, 447, 447, 133, 447, - 447, 447, 447, 132, 130, 126, 447, 448, 448, 125, - 123, 448, 448, 448, 449, 120, 119, 449, 449, 449, - 449, 449, 449, 449, 449, 449, 449, 449, 450, 450, - - 114, 450, 450, 450, 450, 450, 450, 450, 450, 450, - 450, 450, 451, 451, 113, 451, 451, 451, 451, 451, - 451, 451, 451, 451, 451, 451, 452, 452, 452, 453, - 453, 453, 454, 454, 454, 454, 454, 454, 454, 454, - 454, 454, 454, 454, 454, 454, 455, 455, 455, 455, - 455, 455, 455, 455, 455, 455, 455, 455, 455, 455, - 456, 456, 106, 456, 456, 456, 456, 456, 456, 105, - 456, 456, 456, 456, 458, 458, 102, 458, 458, 458, - 458, 458, 458, 458, 458, 458, 458, 459, 459, 100, - 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, - - 459, 460, 460, 99, 460, 460, 460, 460, 460, 460, - 460, 460, 460, 460, 460, 461, 461, 95, 461, 461, - 461, 461, 461, 461, 461, 461, 461, 461, 461, 463, - 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, - 463, 463, 463, 464, 464, 92, 91, 464, 464, 464, - 465, 465, 90, 88, 465, 465, 465, 468, 468, 468, - 468, 468, 468, 468, 468, 468, 468, 468, 468, 468, - 468, 469, 469, 469, 469, 469, 469, 469, 469, 469, - 469, 469, 469, 469, 469, 87, 86, 83, 82, 79, - 77, 76, 74, 73, 70, 68, 67, 63, 62, 58, - - 57, 53, 51, 50, 47, 46, 43, 42, 41, 16, - 15, 10, 8, 7, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407, 407, 407, - 407, 407, 407, 407, 407, 407, 407, 407 - } ; - -static yy_state_type yy_last_accepting_state; -static char *yy_last_accepting_cpos; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -char *yytext; -# line 1 "scan.l" -/* scan.l - scanner for flex input */ -# line 4 "scan.l" -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * 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. - */ - -/* $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/initscan.c,v 1.6 1993/12/09 19:06:21 jtc Exp $ */ - -#include "flexdef.h" -#include "parse.h" - -#define ACTION_ECHO add_action( yytext ) -#define MARK_END_OF_PROLOG mark_prolog(); - -#define YY_DECL \ - int flexscan() - -#define RETURNCHAR \ - yylval = (unsigned char) yytext[0]; \ - return CHAR; - -#define RETURNNAME \ - yy_strcpy( nmstr, yytext ); \ - return NAME; - -#define PUT_BACK_STRING(str, start) \ - for ( i = yy_strlen( str ) - 1; i >= start; --i ) \ - unput((str)[i]) - -#define CHECK_REJECT(str) \ - if ( all_upper( str ) ) \ - reject = true; - -#define CHECK_YYMORE(str) \ - if ( all_lower( str ) ) \ - yymore_used = true; - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->is_interactive ) \ - result = ((int) (buf[0] = getc( yyin ))) == EOF ? 0 : 1; \ - else if ( ((result = fread( (char *) buf, 1, max_size, yyin )) == 0)\ - && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -# line 82 "scan.l" - - static int bracelevel, didadef, indented_code, checking_used; - - int doing_codeblock = false; - int i; - Char nmdef[MAXLINE], myesc(); - - - - if ( yy_init ) - { -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( yy_current_buffer ) - yy_init_buffer( yy_current_buffer, yyin ); - else - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - - yy_init = 0; - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; - if ( yy_bp[-1] == '\n' ) - ++yy_current_state; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 408 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 1615 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_USER_ACTION -# line 90 "scan.l" -indented_code = true; BEGIN(CODEBLOCK); - YY_BREAK -case 2: -YY_USER_ACTION -# line 91 "scan.l" -ACTION_ECHO; BEGIN(C_COMMENT); - YY_BREAK -case 3: -YY_USER_ACTION -# line 92 "scan.l" -return SCDECL; - YY_BREAK -case 4: -YY_USER_ACTION -# line 93 "scan.l" -return XSCDECL; - YY_BREAK -case 5: -YY_USER_ACTION -# line 94 "scan.l" -{ - ++linenum; - line_directive_out( (FILE *) 0 ); - indented_code = false; - BEGIN(CODEBLOCK); - } - YY_BREAK -case 6: -YY_USER_ACTION -# line 101 "scan.l" -return WHITESPACE; - YY_BREAK -case 7: -YY_USER_ACTION -# line 103 "scan.l" -{ - sectnum = 2; - bracelevel = 0; - mark_defs1(); - line_directive_out( (FILE *) 0 ); - BEGIN(SECT2PROLOG); - return SECTEND; - } - YY_BREAK -case 8: -YY_USER_ACTION -# line 112 "scan.l" -{ - if ( lex_compat ) - warn( "%pointer incompatible with -l option" ); - else - yytext_is_array = false; - ++linenum; - } - YY_BREAK -case 9: -YY_USER_ACTION -# line 119 "scan.l" -{ - if ( C_plus_plus ) - warn( "%array incompatible with -+ option" ); - else - yytext_is_array = true; - ++linenum; - } - YY_BREAK -case 10: -YY_USER_ACTION -# line 127 "scan.l" -{ - warn( "%used/%unused have been deprecated" ); - checking_used = REALLY_USED; BEGIN(USED_LIST); - } - YY_BREAK -case 11: -YY_USER_ACTION -# line 131 "scan.l" -{ - warn( "%used/%unused have been deprecated" ); - checking_used = REALLY_NOT_USED; BEGIN(USED_LIST); - } - YY_BREAK -case 12: -YY_USER_ACTION -# line 137 "scan.l" -++linenum; /* ignore */ - YY_BREAK -case 13: -YY_USER_ACTION -# line 139 "scan.l" -synerr( "unrecognized '%' directive" ); - YY_BREAK -case 14: -YY_USER_ACTION -# line 141 "scan.l" -{ - yy_strcpy( nmstr, yytext ); - didadef = false; - BEGIN(PICKUPDEF); - } - YY_BREAK -case 15: -YY_USER_ACTION -# line 147 "scan.l" -RETURNNAME; - YY_BREAK -case 16: -YY_USER_ACTION -# line 148 "scan.l" -++linenum; /* allows blank lines in section 1 */ - YY_BREAK -case 17: -YY_USER_ACTION -# line 149 "scan.l" -++linenum; return '\n'; - YY_BREAK -case 18: -YY_USER_ACTION -# line 152 "scan.l" -ACTION_ECHO; BEGIN(INITIAL); - YY_BREAK -case 19: -YY_USER_ACTION -# line 153 "scan.l" -++linenum; ACTION_ECHO; BEGIN(INITIAL); - YY_BREAK -case 20: -YY_USER_ACTION -# line 154 "scan.l" -ACTION_ECHO; - YY_BREAK -case 21: -YY_USER_ACTION -# line 155 "scan.l" -ACTION_ECHO; - YY_BREAK -case 22: -YY_USER_ACTION -# line 156 "scan.l" -++linenum; ACTION_ECHO; - YY_BREAK -case 23: -YY_USER_ACTION -# line 159 "scan.l" -++linenum; BEGIN(INITIAL); - YY_BREAK -case 24: -YY_USER_ACTION -# line 160 "scan.l" -ACTION_ECHO; CHECK_REJECT(yytext); - YY_BREAK -case 25: -YY_USER_ACTION -# line 161 "scan.l" -ACTION_ECHO; CHECK_YYMORE(yytext); - YY_BREAK -case 26: -YY_USER_ACTION -# line 162 "scan.l" -ACTION_ECHO; - YY_BREAK -case 27: -YY_USER_ACTION -# line 163 "scan.l" -{ - ++linenum; - ACTION_ECHO; - if ( indented_code ) - BEGIN(INITIAL); - } - YY_BREAK -case 28: -YY_USER_ACTION -# line 171 "scan.l" -/* separates name and definition */ - YY_BREAK -case 29: -YY_USER_ACTION -# line 173 "scan.l" -{ - yy_strcpy( (char *) nmdef, yytext ); - - /* Skip trailing whitespace. */ - for ( i = yy_strlen( (char *) nmdef ) - 1; - i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t'); - --i ) - ; - - nmdef[i + 1] = '\0'; - - ndinstal( nmstr, nmdef ); - didadef = true; - } - YY_BREAK -case 30: -YY_USER_ACTION -# line 188 "scan.l" -{ - if ( ! didadef ) - synerr( "incomplete name definition" ); - BEGIN(INITIAL); - ++linenum; - } - YY_BREAK -case 31: -YY_USER_ACTION -# line 195 "scan.l" -++linenum; BEGIN(INITIAL); RETURNNAME; - YY_BREAK -case 32: -YY_USER_ACTION -# line 198 "scan.l" -++linenum; BEGIN(INITIAL); - YY_BREAK -case 33: -YY_USER_ACTION -# line 199 "scan.l" - - YY_BREAK -case 34: -YY_USER_ACTION -# line 200 "scan.l" -{ - if ( all_upper( yytext ) ) - reject_really_used = checking_used; - else - synerr( - "unrecognized %used/%unused construct" ); - } - YY_BREAK -case 35: -YY_USER_ACTION -# line 207 "scan.l" -{ - if ( all_lower( yytext ) ) - yymore_really_used = checking_used; - else - synerr( - "unrecognized %used/%unused construct" ); - } - YY_BREAK -case 36: -YY_USER_ACTION -# line 214 "scan.l" -synerr( "unrecognized %used/%unused construct" ); - YY_BREAK -case 37: -YY_USER_ACTION -# line 217 "scan.l" -++bracelevel; yyless( 2 ); /* eat only %{ */ - YY_BREAK -case 38: -YY_USER_ACTION -# line 218 "scan.l" ---bracelevel; yyless( 2 ); /* eat only %} */ - YY_BREAK -case 39: -YY_USER_ACTION -# line 220 "scan.l" -ACTION_ECHO; /* indented code in prolog */ - YY_BREAK -case 40: -YY_USER_ACTION -# line 222 "scan.l" -{ /* non-indented code */ - if ( bracelevel <= 0 ) - { /* not in %{ ... %} */ - yyless( 0 ); /* put it all back */ - mark_prolog(); - BEGIN(SECT2); - } - else - ACTION_ECHO; - } - YY_BREAK -case 41: -YY_USER_ACTION -# line 233 "scan.l" -ACTION_ECHO; - YY_BREAK -case 42: -YY_USER_ACTION -# line 234 "scan.l" -++linenum; ACTION_ECHO; - YY_BREAK -case YY_STATE_EOF(SECT2PROLOG): -# line 236 "scan.l" -{ - mark_prolog(); - sectnum = 0; - yyterminate(); /* to stop the parser */ - } - YY_BREAK -case 43: -YY_USER_ACTION -# line 242 "scan.l" -++linenum; /* allow blank lines in section 2 */ - YY_BREAK -case 44: -YY_USER_ACTION -# line 244 "scan.l" -{ - indented_code = (yytext[0] != '%'); - doing_codeblock = true; - bracelevel = 1; - - if ( indented_code ) - ACTION_ECHO; - - BEGIN(CODEBLOCK_2); - } - YY_BREAK -case 45: -YY_USER_ACTION -# line 255 "scan.l" -BEGIN(SC); return '<'; - YY_BREAK -case 46: -YY_USER_ACTION -# line 256 "scan.l" -return '^'; - YY_BREAK -case 47: -YY_USER_ACTION -# line 257 "scan.l" -BEGIN(QUOTE); return '"'; - YY_BREAK -case 48: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_USER_ACTION -# line 258 "scan.l" -BEGIN(NUM); return '{'; - YY_BREAK -case 49: -YY_USER_ACTION -# line 259 "scan.l" -BEGIN(BRACEERROR); - YY_BREAK -case 50: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_USER_ACTION -# line 260 "scan.l" -return '$'; - YY_BREAK -case 51: -YY_USER_ACTION -# line 262 "scan.l" -{ - bracelevel = 1; - BEGIN(PERCENT_BRACE_ACTION); - return '\n'; - } - YY_BREAK -case 52: -YY_USER_ACTION -# line 267 "scan.l" -continued_action = true; ++linenum; return '\n'; - YY_BREAK -case 53: -YY_USER_ACTION -# line 269 "scan.l" -{ - /* This rule is separate from the one below because - * otherwise we get variable trailing context, so - * we can't build the scanner using -{f,F}. - */ - bracelevel = 0; - continued_action = false; - BEGIN(ACTION); - return '\n'; - } - YY_BREAK -case 54: -YY_USER_ACTION -# line 280 "scan.l" -{ - bracelevel = 0; - continued_action = false; - BEGIN(ACTION); - unput( '\n' ); /* so sees it */ - return '\n'; - } - YY_BREAK -case 55: -YY_USER_ACTION -# line 288 "scan.l" -return EOF_OP; - YY_BREAK -case 56: -YY_USER_ACTION -# line 290 "scan.l" -{ - sectnum = 3; - BEGIN(SECT3); - yyterminate(); /* to stop the parser */ - } - YY_BREAK -case 57: -YY_USER_ACTION -# line 296 "scan.l" -{ - int cclval; - - yy_strcpy( nmstr, yytext ); - - /* Check to see if we've already encountered this - * ccl. - */ - if ( (cclval = ccllookup( (Char *) nmstr )) ) - { - if ( input() != ']' ) - synerr( "bad character class" ); - - yylval = cclval; - ++cclreuse; - return PREVCCL; - } - else - { - /* We fudge a bit. We know that this ccl will - * soon be numbered as lastccl + 1 by cclinit. - */ - cclinstal( (Char *) nmstr, lastccl + 1 ); - - /* Push back everything but the leading bracket - * so the ccl can be rescanned. - */ - yyless( 1 ); - - BEGIN(FIRSTCCL); - return '['; - } - } - YY_BREAK -case 58: -YY_USER_ACTION -# line 330 "scan.l" -{ - register Char *nmdefptr; - Char *ndlookup(); - - yy_strcpy( nmstr, yytext + 1 ); - nmstr[yyleng - 2] = '\0'; /* chop trailing brace */ - - if ( ! (nmdefptr = ndlookup( nmstr )) ) - format_synerr( "undefined definition {%s}", - nmstr ); - - else - { /* push back name surrounded by ()'s */ - int len = yy_strlen( (char *) nmdefptr ); - - if ( lex_compat || nmdefptr[0] == '^' || - (len > 0 && nmdefptr[len - 1] == '$') ) - { /* don't use ()'s after all */ - PUT_BACK_STRING((char *) nmdefptr, 0); - - if ( nmdefptr[0] == '^' ) - BEGIN(CARETISBOL); - } - - else - { - unput(')'); - PUT_BACK_STRING((char *) nmdefptr, 0); - unput('('); - } - } - } - YY_BREAK -case 59: -YY_USER_ACTION -# line 363 "scan.l" -return (unsigned char) yytext[0]; - YY_BREAK -case 60: -YY_USER_ACTION -# line 364 "scan.l" -RETURNCHAR; - YY_BREAK -case 61: -YY_USER_ACTION -# line 367 "scan.l" -return (unsigned char) yytext[0]; - YY_BREAK -case 62: -YY_USER_ACTION -# line 368 "scan.l" -BEGIN(SECT2); return '>'; - YY_BREAK -case 63: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_USER_ACTION -# line 369 "scan.l" -BEGIN(CARETISBOL); return '>'; - YY_BREAK -case 64: -YY_USER_ACTION -# line 370 "scan.l" -RETURNNAME; - YY_BREAK -case 65: -YY_USER_ACTION -# line 371 "scan.l" -{ - format_synerr( "bad : %s", yytext ); - } - YY_BREAK -case 66: -YY_USER_ACTION -# line 375 "scan.l" -BEGIN(SECT2); return '^'; - YY_BREAK -case 67: -YY_USER_ACTION -# line 378 "scan.l" -RETURNCHAR; - YY_BREAK -case 68: -YY_USER_ACTION -# line 379 "scan.l" -BEGIN(SECT2); return '"'; - YY_BREAK -case 69: -YY_USER_ACTION -# line 381 "scan.l" -{ - synerr( "missing quote" ); - BEGIN(SECT2); - ++linenum; - return '"'; - } - YY_BREAK -case 70: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_USER_ACTION -# line 389 "scan.l" -BEGIN(CCL); return '^'; - YY_BREAK -case 71: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_USER_ACTION -# line 390 "scan.l" -return '^'; - YY_BREAK -case 72: -YY_USER_ACTION -# line 391 "scan.l" -BEGIN(CCL); RETURNCHAR; - YY_BREAK -case 73: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp = yy_bp + 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_USER_ACTION -# line 393 "scan.l" -return '-'; - YY_BREAK -case 74: -YY_USER_ACTION -# line 394 "scan.l" -RETURNCHAR; - YY_BREAK -case 75: -YY_USER_ACTION -# line 395 "scan.l" -BEGIN(SECT2); return ']'; - YY_BREAK -case 76: -YY_USER_ACTION -# line 396 "scan.l" -{ - synerr( "bad character class" ); - BEGIN(SECT2); - return ']'; - } - YY_BREAK -case 77: -YY_USER_ACTION -# line 403 "scan.l" -{ - yylval = myctoi( yytext ); - return NUMBER; - } - YY_BREAK -case 78: -YY_USER_ACTION -# line 408 "scan.l" -return ','; - YY_BREAK -case 79: -YY_USER_ACTION -# line 409 "scan.l" -BEGIN(SECT2); return '}'; - YY_BREAK -case 80: -YY_USER_ACTION -# line 411 "scan.l" -{ - synerr( "bad character inside {}'s" ); - BEGIN(SECT2); - return '}'; - } - YY_BREAK -case 81: -YY_USER_ACTION -# line 417 "scan.l" -{ - synerr( "missing }" ); - BEGIN(SECT2); - ++linenum; - return '}'; - } - YY_BREAK -case 82: -YY_USER_ACTION -# line 425 "scan.l" -synerr( "bad name in {}'s" ); BEGIN(SECT2); - YY_BREAK -case 83: -YY_USER_ACTION -# line 426 "scan.l" -synerr( "missing }" ); ++linenum; BEGIN(SECT2); - YY_BREAK -case 84: -YY_USER_ACTION -# line 429 "scan.l" -ACTION_ECHO; BEGIN(ACTION_COMMENT); - YY_BREAK -case 85: -YY_USER_ACTION -# line 430 "scan.l" -bracelevel = 0; - YY_BREAK -case 86: -YY_USER_ACTION -# line 431 "scan.l" -{ - ACTION_ECHO; - CHECK_REJECT(yytext); - } - YY_BREAK -case 87: -YY_USER_ACTION -# line 435 "scan.l" -{ - ACTION_ECHO; - CHECK_YYMORE(yytext); - } - YY_BREAK -case 88: -YY_USER_ACTION -# line 439 "scan.l" -ACTION_ECHO; - YY_BREAK -case 89: -YY_USER_ACTION -# line 440 "scan.l" -{ - ++linenum; - ACTION_ECHO; - if ( bracelevel == 0 || - (doing_codeblock && indented_code) ) - { - if ( ! doing_codeblock ) - add_action( "\tYY_BREAK\n" ); - - doing_codeblock = false; - BEGIN(SECT2); - } - } - YY_BREAK - /* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */ -case 90: -YY_USER_ACTION -# line 456 "scan.l" -ACTION_ECHO; ++bracelevel; - YY_BREAK -case 91: -YY_USER_ACTION -# line 457 "scan.l" -ACTION_ECHO; --bracelevel; - YY_BREAK -case 92: -YY_USER_ACTION -# line 458 "scan.l" -ACTION_ECHO; - YY_BREAK -case 93: -YY_USER_ACTION -# line 459 "scan.l" -ACTION_ECHO; - YY_BREAK -case 94: -YY_USER_ACTION -# line 460 "scan.l" -ACTION_ECHO; BEGIN(ACTION_COMMENT); - YY_BREAK -case 95: -YY_USER_ACTION -# line 461 "scan.l" -ACTION_ECHO; /* character constant */ - YY_BREAK -case 96: -YY_USER_ACTION -# line 462 "scan.l" -ACTION_ECHO; BEGIN(ACTION_STRING); - YY_BREAK -case 97: -YY_USER_ACTION -# line 463 "scan.l" -{ - ++linenum; - ACTION_ECHO; - if ( bracelevel == 0 ) - { - add_action( "\tYY_BREAK\n" ); - BEGIN(SECT2); - } - } - YY_BREAK -case 98: -YY_USER_ACTION -# line 472 "scan.l" -ACTION_ECHO; - YY_BREAK -case 99: -YY_USER_ACTION -# line 474 "scan.l" -{ - ACTION_ECHO; - if ( doing_codeblock ) - BEGIN(CODEBLOCK_2); - else - BEGIN(ACTION); - } - YY_BREAK -case 100: -YY_USER_ACTION -# line 482 "scan.l" -ACTION_ECHO; - YY_BREAK -case 101: -YY_USER_ACTION -# line 483 "scan.l" -ACTION_ECHO; - YY_BREAK -case 102: -YY_USER_ACTION -# line 484 "scan.l" -++linenum; ACTION_ECHO; - YY_BREAK -case 103: -YY_USER_ACTION -# line 486 "scan.l" -ACTION_ECHO; - YY_BREAK -case 104: -YY_USER_ACTION -# line 487 "scan.l" -ACTION_ECHO; - YY_BREAK -case 105: -YY_USER_ACTION -# line 488 "scan.l" -++linenum; ACTION_ECHO; - YY_BREAK -case 106: -YY_USER_ACTION -# line 489 "scan.l" -ACTION_ECHO; BEGIN(ACTION); - YY_BREAK -case 107: -YY_USER_ACTION -# line 490 "scan.l" -ACTION_ECHO; - YY_BREAK -case YY_STATE_EOF(ACTION): -case YY_STATE_EOF(ACTION_COMMENT): -case YY_STATE_EOF(ACTION_STRING): -# line 492 "scan.l" -{ - synerr( "EOF encountered inside an action" ); - yyterminate(); - } - YY_BREAK -case 108: -YY_USER_ACTION -# line 498 "scan.l" -{ - yylval = myesc( (Char *) yytext ); - return CHAR; - } - YY_BREAK -case 109: -YY_USER_ACTION -# line 503 "scan.l" -{ - yylval = myesc( (Char *) yytext ); - BEGIN(CCL); - return CHAR; - } - YY_BREAK -case 110: -YY_USER_ACTION -# line 510 "scan.l" -ECHO; - YY_BREAK -case YY_STATE_EOF(SECT3): -# line 511 "scan.l" -sectnum = 0; yyterminate(); - YY_BREAK -case 111: -YY_USER_ACTION -# line 513 "scan.l" -format_synerr( "bad character: %s", yytext ); - YY_BREAK -case 112: -YY_USER_ACTION -# line 515 "scan.l" -YY_FATAL_ERROR( "flex scanner jammed" ); - YY_BREAK -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(SECT2): -case YY_STATE_EOF(CODEBLOCK): -case YY_STATE_EOF(PICKUPDEF): -case YY_STATE_EOF(SC): -case YY_STATE_EOF(CARETISBOL): -case YY_STATE_EOF(NUM): -case YY_STATE_EOF(QUOTE): -case YY_STATE_EOF(FIRSTCCL): -case YY_STATE_EOF(CCL): -case YY_STATE_EOF(RECOVER): -case YY_STATE_EOF(BRACEERROR): -case YY_STATE_EOF(C_COMMENT): -case YY_STATE_EOF(PERCENT_BRACE_ACTION): -case YY_STATE_EOF(USED_LIST): -case YY_STATE_EOF(CODEBLOCK_2): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = yy_cp - yytext_ptr - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - - if ( yy_current_buffer->yy_input_file != yyin ) - { - /* This can happen if we scan a file, yywrap() returns - * 1, and then later the user points yyin at a new - * file to resume scanning. We have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input file. - */ - yy_current_buffer->yy_input_file = yyin; - yy_n_chars = yy_current_buffer->yy_n_chars; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr - 1; /* copy prev. char, too */ - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = yy_c_buf_p - yytext_ptr; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = yy_c_buf_p - b->yy_ch_buf; - - b->yy_buf_size *= 2; - b->yy_ch_buf = (char *) - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size ); - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move - YY_MORE_ADJ == 1 ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_eof_status = EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - /* yytext begins at the second character in yy_ch_buf; the first - * character is the one which preceded it before reading in the latest - * buffer; it needs to be kept around in case it's a newline, so - * yy_get_previous_state() will have with '^' rules active. - */ - - yytext_ptr = &yy_current_buffer->yy_ch_buf[1]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -static yy_state_type yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - register char *yy_bp = yytext_ptr; - - yy_current_state = yy_start; - if ( yy_bp[-1] == '\n' ) - ++yy_current_state; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 408 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 408 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 407); - - return yy_is_jam ? 0 : yy_current_state; - } - - -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += dest - source; - yy_bp += dest - source; - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - if ( yy_cp > yy_bp && yy_cp[-1] == '\n' ) - yy_cp[-2] = '\n'; - - *--yy_cp = (char) c; - - - /* Note: the formal parameter *must* be called "yy_bp" for this - * macro to now work correctly. - */ - YY_DO_BEFORE_ACTION; /* set up yytext again */ - } - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - yytext_ptr = yy_c_buf_p; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - { - yy_c_buf_p = - yytext_ptr + YY_MORE_ADJ; - return EOF; - } - - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - break; - - case EOB_ACT_LAST_MATCH: -#ifdef __cplusplus - YY_FATAL_ERROR( - "unexpected last match in yyinput()" ); -#else - YY_FATAL_ERROR( - "unexpected last match in input()" ); -#endif - } - } - } - - c = *yy_c_buf_p; - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - return c; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - yy_init_buffer( b, file ); - - return b; - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - yy_flex_free( (void *) b->yy_ch_buf ); - yy_flex_free( (void *) b ); - } - - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - { - b->yy_input_file = file; - - /* We put in the '\n' and start reading from [1] so that an - * initial match-at-newline will be true. - */ - - b->yy_ch_buf[0] = '\n'; - b->yy_n_chars = 1; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[1]; - - b->is_interactive = file ? isatty( fileno(file) ) : 0; - - b->yy_eof_status = EOF_NOT_SEEN; - } - - -#ifdef YY_USE_PROTOS -static void yy_fatal_error( const char msg[] ) -#else -static void yy_fatal_error( msg ) -char msg[]; -#endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( 1 ); - } - - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n - YY_MORE_ADJ; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) -# line 515 "scan.l" - - - -int yywrap() - { - if ( --num_input_files > 0 ) - { - set_input_file( *++input_files ); - return 0; - } - - else - return 1; - } - - -/* set_input_file - open the given file (if NULL, stdin) for scanning */ - -void set_input_file( file ) -char *file; - { - if ( file ) - { - infilename = file; - yyin = fopen( infilename, "r" ); - - if ( yyin == NULL ) - lerrsf( "can't open %s", file ); - } - - else - { - yyin = stdin; - infilename = ""; - } - } diff --git a/gnu/usr.bin/lex/main.c b/gnu/usr.bin/lex/main.c deleted file mode 100644 index 1feecbaeaf93..000000000000 --- a/gnu/usr.bin/lex/main.c +++ /dev/null @@ -1,989 +0,0 @@ -/* flex - tool to generate fast lexical analyzers */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * 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 lint -char copyright[] = -"@(#) Copyright (c) 1990 The Regents of the University of California.\n\ - All rights reserved.\n"; -#endif /* not lint */ - -/* $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/main.c,v 1.6 1993/12/09 19:06:24 jtc Exp $ */ - - -#include "flexdef.h" -#include "version.h" - -static char flex_version[] = FLEX_VERSION; - - -/* declare functions that have forward references */ - -void flexinit PROTO((int, char**)); -void readin PROTO((void)); -void set_up_initial_allocations PROTO((void)); - - -/* these globals are all defined and commented in flexdef.h */ -int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt; -int interactive, caseins, lex_compat, useecs, fulltbl, usemecs; -int fullspd, gen_line_dirs, performance_report, backing_up_report; -int C_plus_plus, long_align, use_read, yytext_is_array, csize; -int yymore_used, reject, real_reject, continued_action; -int yymore_really_used, reject_really_used; -int datapos, dataline, linenum; -FILE *skelfile = NULL; -int skel_ind = 0; -char *action_array; -int action_size, defs1_offset, prolog_offset, action_offset, action_index; -char *infilename = NULL; -int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE]; -int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp; -int current_mns, num_rules, num_eof_rules, default_rule; -int current_max_rules, lastnfa; -int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2; -int *accptnum, *assoc_rule, *state_type; -int *rule_type, *rule_linenum, *rule_useful; -int current_state_type; -int variable_trailing_context_rules; -int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP]; -int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE]; -int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs, tecfwd[CSIZE + 1]; -int tecbck[CSIZE + 1]; -int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc; -char **scname; -int current_max_dfa_size, current_max_xpairs; -int current_max_template_xpairs, current_max_dfas; -int lastdfa, *nxt, *chk, *tnxt; -int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz; -union dfaacc_union *dfaacc; -int *accsiz, *dhash, numas; -int numsnpairs, jambase, jamstate; -int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse; -int current_max_ccl_tbl_size; -Char *ccltbl; -char nmstr[MAXLINE]; -int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; -int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; -int num_backing_up, bol_needed; -FILE *backing_up_file; -int end_of_buffer_state; -char **input_files; -int num_input_files; -char *program_name; - -#ifndef SHORT_FILE_NAMES -static char *outfile_template = "lex.%s.%s"; -#else -static char *outfile_template = "lex%s.%s"; -#endif -static char outfile_path[64]; - -static int outfile_created = 0; -static int use_stdout; -static char *skelname = NULL; -static char *prefix = "yy"; - - -int main( argc, argv ) -int argc; -char **argv; - { - int i; - - flexinit( argc, argv ); - - readin(); - - if ( syntaxerror ) - flexend( 1 ); - - if ( yymore_really_used == REALLY_USED ) - yymore_used = true; - else if ( yymore_really_used == REALLY_NOT_USED ) - yymore_used = false; - - if ( reject_really_used == REALLY_USED ) - reject = true; - else if ( reject_really_used == REALLY_NOT_USED ) - reject = false; - - if ( performance_report > 0 ) - { - if ( lex_compat ) - { - fprintf( stderr, -"-l AT&T lex compatibility option entails a large performance penalty\n" ); - fprintf( stderr, -" and may be the actual source of other reported performance penalties\n" ); - } - - if ( performance_report > 1 ) - { - if ( interactive ) - fprintf( stderr, - "-I (interactive) entails a minor performance penalty\n" ); - - if ( yymore_used ) - fprintf( stderr, - "yymore() entails a minor performance penalty\n" ); - } - - if ( reject ) - fprintf( stderr, - "REJECT entails a large performance penalty\n" ); - - if ( variable_trailing_context_rules ) - fprintf( stderr, -"Variable trailing context rules entail a large performance penalty\n" ); - } - - if ( reject ) - real_reject = true; - - if ( variable_trailing_context_rules ) - reject = true; - - if ( (fulltbl || fullspd) && reject ) - { - if ( real_reject ) - flexerror( "REJECT cannot be used with -f or -F" ); - else - flexerror( - "variable trailing context rules cannot be used with -f or -F" ); - } - - ntod(); - - for ( i = 1; i <= num_rules; ++i ) - if ( ! rule_useful[i] && i != default_rule ) - line_warning( "rule cannot be matched", - rule_linenum[i] ); - - if ( spprdflt && ! reject && rule_useful[default_rule] ) - line_warning( "-s option given but default rule can be matched", - rule_linenum[default_rule] ); - - /* Generate the C state transition tables from the DFA. */ - make_tables(); - - /* Note, flexend does not return. It exits with its argument - * as status. - */ - flexend( 0 ); - - return 0; /* keep compilers/lint happy */ - } - - -/* flexend - terminate flex - * - * note - * This routine does not return. - */ - -void flexend( exit_status ) -int exit_status; - - { - int tblsiz; - int unlink(); - - if ( skelfile != NULL ) - { - if ( ferror( skelfile ) ) - flexfatal( - "error occurred when reading skeleton file" ); - - else if ( fclose( skelfile ) ) - flexfatal( - "error occurred when closing skeleton file" ); - } - - if ( exit_status != 0 && outfile_created ) - { - if ( ferror( stdout ) ) - flexfatal( "error occurred when writing output file" ); - - else if ( fclose( stdout ) ) - flexfatal( "error occurred when closing output file" ); - - else if ( unlink( outfile_path ) ) - flexfatal( "error occurred when deleting output file" ); - } - - if ( backing_up_report && backing_up_file ) - { - if ( num_backing_up == 0 ) - fprintf( backing_up_file, "No backing up.\n" ); - else if ( fullspd || fulltbl ) - fprintf( backing_up_file, - "%d backing up (non-accepting) states.\n", - num_backing_up ); - else - fprintf( backing_up_file, - "Compressed tables always back up.\n" ); - - if ( ferror( backing_up_file ) ) - flexfatal( "error occurred when writing backup file" ); - - else if ( fclose( backing_up_file ) ) - flexfatal( "error occurred when closing backup file" ); - } - - if ( printstats ) - { - fprintf( stderr, "%s version %s usage statistics:\n", - program_name, flex_version ); - - fprintf( stderr, " scanner options: -" ); - - if ( C_plus_plus ) - putc( '+', stderr ); - if ( backing_up_report ) - putc( 'b', stderr ); - if ( ddebug ) - putc( 'd', stderr ); - if ( caseins ) - putc( 'i', stderr ); - if ( lex_compat ) - putc( 'l', stderr ); - if ( performance_report > 0 ) - putc( 'p', stderr ); - if ( performance_report > 1 ) - putc( 'p', stderr ); - if ( spprdflt ) - putc( 's', stderr ); - if ( use_stdout ) - putc( 't', stderr ); - if ( printstats ) - putc( 'v', stderr ); /* always true! */ - if ( nowarn ) - putc( 'w', stderr ); - if ( ! interactive ) - putc( 'B', stderr ); - if ( interactive ) - putc( 'I', stderr ); - if ( ! gen_line_dirs ) - putc( 'L', stderr ); - if ( trace ) - putc( 'T', stderr ); - if ( csize == 128 ) - putc( '7', stderr ); - else - putc( '8', stderr ); - - fprintf( stderr, " -C" ); - - if ( long_align ) - putc( 'a', stderr ); - if ( fulltbl ) - putc( 'f', stderr ); - if ( fullspd ) - putc( 'F', stderr ); - if ( useecs ) - putc( 'e', stderr ); - if ( usemecs ) - putc( 'm', stderr ); - if ( use_read ) - putc( 'r', stderr ); - - if ( skelname ) - fprintf( stderr, " -S%s", skelname ); - - if ( yy_strcmp( prefix, "yy" ) ) - fprintf( stderr, " -P%s", prefix ); - - putc( '\n', stderr ); - - fprintf( stderr, " %d/%d NFA states\n", lastnfa, current_mns ); - fprintf( stderr, " %d/%d DFA states (%d words)\n", lastdfa, - current_max_dfas, totnst ); - fprintf( stderr, " %d rules\n", - num_rules + num_eof_rules - 1 /* - 1 for def. rule */ ); - - if ( num_backing_up == 0 ) - fprintf( stderr, " No backing up\n" ); - else if ( fullspd || fulltbl ) - fprintf( stderr, - " %d backing-up (non-accepting) states\n", - num_backing_up ); - else - fprintf( stderr, - " Compressed tables always back-up\n" ); - - if ( bol_needed ) - fprintf( stderr, - " Beginning-of-line patterns used\n" ); - - fprintf( stderr, " %d/%d start conditions\n", lastsc, - current_max_scs ); - fprintf( stderr, - " %d epsilon states, %d double epsilon states\n", - numeps, eps2 ); - - if ( lastccl == 0 ) - fprintf( stderr, " no character classes\n" ); - else - fprintf( stderr, - " %d/%d character classes needed %d/%d words of storage, %d reused\n", - lastccl, current_maxccls, - cclmap[lastccl] + ccllen[lastccl], - current_max_ccl_tbl_size, cclreuse ); - - fprintf( stderr, " %d state/nextstate pairs created\n", - numsnpairs ); - fprintf( stderr, " %d/%d unique/duplicate transitions\n", - numuniq, numdup ); - - if ( fulltbl ) - { - tblsiz = lastdfa * numecs; - fprintf( stderr, " %d table entries\n", tblsiz ); - } - - else - { - tblsiz = 2 * (lastdfa + numtemps) + 2 * tblend; - - fprintf( stderr, " %d/%d base-def entries created\n", - lastdfa + numtemps, current_max_dfas ); - fprintf( stderr, - " %d/%d (peak %d) nxt-chk entries created\n", - tblend, current_max_xpairs, peakpairs ); - fprintf( stderr, - " %d/%d (peak %d) template nxt-chk entries created\n", - numtemps * nummecs, current_max_template_xpairs, - numtemps * numecs ); - fprintf( stderr, " %d empty table entries\n", nummt ); - fprintf( stderr, " %d protos created\n", numprots ); - fprintf( stderr, " %d templates created, %d uses\n", - numtemps, tmpuses ); - } - - if ( useecs ) - { - tblsiz = tblsiz + csize; - fprintf( stderr, - " %d/%d equivalence classes created\n", - numecs, csize ); - } - - if ( usemecs ) - { - tblsiz = tblsiz + numecs; - fprintf( stderr, - " %d/%d meta-equivalence classes created\n", - nummecs, csize ); - } - - fprintf( stderr, - " %d (%d saved) hash collisions, %d DFAs equal\n", - hshcol, hshsave, dfaeql ); - fprintf( stderr, " %d sets of reallocations needed\n", - num_reallocs ); - fprintf( stderr, " %d total table entries needed\n", tblsiz ); - } - -#ifndef VMS - exit( exit_status ); -#else - exit( exit_status + 1 ); -#endif - } - - -/* flexinit - initialize flex */ - -void flexinit( argc, argv ) -int argc; -char **argv; - { - int i, sawcmpflag; - int csize_given, interactive_given; - char *arg, *mktemp(); - - printstats = syntaxerror = trace = spprdflt = caseins = false; - lex_compat = false; - C_plus_plus = backing_up_report = ddebug = fulltbl = fullspd = false; - long_align = nowarn = yymore_used = continued_action = reject = false; - yytext_is_array = yymore_really_used = reject_really_used = false; - gen_line_dirs = usemecs = useecs = true; - performance_report = 0; - - sawcmpflag = false; - use_read = use_stdout = false; - csize_given = false; - interactive_given = false; - - /* Initialize dynamic array for holding the rule actions. */ - action_size = 2048; /* default size of action array in bytes */ - action_array = allocate_character_array( action_size ); - defs1_offset = prolog_offset = action_offset = action_index = 0; - action_array[0] = '\0'; - - program_name = argv[0]; - - if ( program_name[0] != '\0' && - program_name[yy_strlen( program_name ) - 1] == '+' ) - C_plus_plus = true; - - /* read flags */ - for ( --argc, ++argv; argc ; --argc, ++argv ) - { - if ( argv[0][0] != '-' || argv[0][1] == '\0' ) - break; - - arg = argv[0]; - - for ( i = 1; arg[i] != '\0'; ++i ) - switch ( arg[i] ) - { - case '+': - C_plus_plus = true; - break; - - case 'B': - interactive = false; - interactive_given = true; - break; - - case 'b': - backing_up_report = true; - break; - - case 'c': - fprintf( stderr, - "%s: Assuming use of deprecated -c flag is really intended to be -C\n", - program_name ); - - /* fall through */ - - case 'C': - if ( i != 1 ) - flexerror( - "-C flag must be given separately" ); - - if ( ! sawcmpflag ) - { - useecs = false; - usemecs = false; - fulltbl = false; - sawcmpflag = true; - } - - for ( ++i; arg[i] != '\0'; ++i ) - switch ( arg[i] ) - { - case 'a': - long_align = - true; - break; - - case 'e': - useecs = true; - break; - - case 'F': - fullspd = true; - break; - - case 'f': - fulltbl = true; - break; - - case 'm': - usemecs = true; - break; - - case 'r': - use_read = true; - break; - - default: - lerrif( - "unknown -C option '%c'", - (int) arg[i] ); - break; - } - - goto get_next_arg; - - case 'd': - ddebug = true; - break; - - case 'f': - useecs = usemecs = false; - use_read = fulltbl = true; - break; - - case 'F': - useecs = usemecs = false; - use_read = fullspd = true; - break; - - case 'h': - usage(); - exit( 0 ); - - case 'I': - interactive = true; - interactive_given = true; - break; - - case 'i': - caseins = true; - break; - - case 'l': - lex_compat = true; - break; - - case 'L': - gen_line_dirs = false; - break; - - case 'n': - /* Stupid do-nothing deprecated - * option. - */ - break; - - case 'P': - if ( i != 1 ) - flexerror( - "-P flag must be given separately" ); - - prefix = arg + i + 1; - goto get_next_arg; - - case 'p': - ++performance_report; - break; - - case 'S': - if ( i != 1 ) - flexerror( - "-S flag must be given separately" ); - - skelname = arg + i + 1; - goto get_next_arg; - - case 's': - spprdflt = true; - break; - - case 't': - use_stdout = true; - break; - - case 'T': - trace = true; - break; - - case 'v': - printstats = true; - break; - - case 'V': - fprintf( stderr, "%s version %s\n", - program_name, flex_version ); - exit( 0 ); - - case 'w': - nowarn = true; - break; - - case '7': - csize = 128; - csize_given = true; - break; - - case '8': - csize = CSIZE; - csize_given = true; - break; - - default: - fprintf( stderr, - "%s: unknown flag '%c'\n", - program_name, (int) arg[i] ); - usage(); - exit( 1 ); - } - - /* Used by -C, -S and -P flags in lieu of a "continue 2" - * control. - */ - get_next_arg: ; - } - - if ( ! csize_given ) - { - if ( (fulltbl || fullspd) && ! useecs ) - csize = DEFAULT_CSIZE; - else - csize = CSIZE; - } - - if ( ! interactive_given ) - { - if ( fulltbl || fullspd ) - interactive = false; - else - interactive = true; - } - - if ( lex_compat ) - { - if ( C_plus_plus ) - flexerror( "Can't use -+ with -l option" ); - - if ( fulltbl || fullspd ) - flexerror( "Can't use -f or -F with -l option" ); - - /* Don't rely on detecting use of yymore() and REJECT, - * just assume they'll be used. - */ - yymore_really_used = reject_really_used = true; - - yytext_is_array = true; - use_read = false; - } - - if ( (fulltbl || fullspd) && usemecs ) - flexerror( "-Cf/-CF and -Cm don't make sense together" ); - - if ( (fulltbl || fullspd) && interactive ) - flexerror( "-Cf/-CF and -I are incompatible" ); - - if ( fulltbl && fullspd ) - flexerror( "-Cf and -CF are mutually exclusive" ); - - if ( C_plus_plus && fullspd ) - flexerror( "Can't use -+ with -CF option" ); - - if ( ! use_stdout ) - { - FILE *prev_stdout; - char *suffix; - - if ( C_plus_plus ) - suffix = "cc"; - else - suffix = "c"; - - sprintf( outfile_path, outfile_template, prefix, suffix ); - - prev_stdout = freopen( outfile_path, "w", stdout ); - - if ( prev_stdout == NULL ) - lerrsf( "could not create %s", outfile_path ); - - outfile_created = 1; - } - - num_input_files = argc; - input_files = argv; - set_input_file( num_input_files > 0 ? input_files[0] : NULL ); - - if ( backing_up_report ) - { -#ifndef SHORT_FILE_NAMES - backing_up_file = fopen( "lex.backup", "w" ); -#else - backing_up_file = fopen( "lex.bck", "w" ); -#endif - - if ( backing_up_file == NULL ) - flexerror( "could not create lex.backup" ); - } - - else - backing_up_file = NULL; - - - lastccl = 0; - lastsc = 0; - - if ( skelname && (skelfile = fopen( skelname, "r" )) == NULL ) - lerrsf( "can't open skeleton file %s", skelname ); - - if ( yy_strcmp( prefix, "yy" ) ) - { -#define GEN_PREFIX(name) printf( "#define yy%s %s%s\n", name, prefix, name ); - GEN_PREFIX( "FlexLexer" ); - GEN_PREFIX( "_create_buffer" ); - GEN_PREFIX( "_delete_buffer" ); - GEN_PREFIX( "_flex_debug" ); - GEN_PREFIX( "_init_buffer" ); - GEN_PREFIX( "_load_buffer_state" ); - GEN_PREFIX( "_switch_to_buffer" ); - GEN_PREFIX( "in" ); - GEN_PREFIX( "leng" ); - GEN_PREFIX( "lex" ); - GEN_PREFIX( "out" ); - GEN_PREFIX( "restart" ); - GEN_PREFIX( "text" ); - GEN_PREFIX( "wrap" ); - printf( "\n" ); - } - - - lastdfa = lastnfa = 0; - num_rules = num_eof_rules = default_rule = 0; - numas = numsnpairs = tmpuses = 0; - numecs = numeps = eps2 = num_reallocs = hshcol = dfaeql = totnst = 0; - numuniq = numdup = hshsave = eofseen = datapos = dataline = 0; - num_backing_up = onesp = numprots = 0; - variable_trailing_context_rules = bol_needed = false; - - linenum = sectnum = 1; - firstprot = NIL; - - /* Used in mkprot() so that the first proto goes in slot 1 - * of the proto queue. - */ - lastprot = 1; - - if ( useecs ) - { - /* Set up doubly-linked equivalence classes. */ - - /* We loop all the way up to csize, since ecgroup[csize] is - * the position used for NUL characters. - */ - ecgroup[1] = NIL; - - for ( i = 2; i <= csize; ++i ) - { - ecgroup[i] = i - 1; - nextecm[i - 1] = i; - } - - nextecm[csize] = NIL; - } - - else - { - /* Put everything in its own equivalence class. */ - for ( i = 1; i <= csize; ++i ) - { - ecgroup[i] = i; - nextecm[i] = BAD_SUBSCRIPT; /* to catch errors */ - } - } - - set_up_initial_allocations(); - } - - -/* readin - read in the rules section of the input file(s) */ - -void readin() - { - skelout(); - - line_directive_out( (FILE *) 0 ); - - if ( yyparse() ) - { - pinpoint_message( "fatal parse error" ); - flexend( 1 ); - } - - if ( csize == 256 ) - puts( "typedef unsigned char YY_CHAR;" ); - else - puts( "typedef char YY_CHAR;" ); - - if ( C_plus_plus ) - { - puts( "#define yytext_ptr yytext" ); - - if ( interactive ) - puts( "#define YY_INTERACTIVE" ); - } - - if ( fullspd ) - printf( - "typedef const struct yy_trans_info *yy_state_type;\n" ); - else if ( ! C_plus_plus ) - printf( "typedef int yy_state_type;\n" ); - - if ( reject ) - printf( "\n#define YY_USES_REJECT\n" ); - - if ( ddebug ) - puts( "\n#define FLEX_DEBUG" ); - - if ( lex_compat ) - { - printf( "FILE *yyin = stdin, *yyout = stdout;\n" ); - printf( "extern int yylineno;\n" ); - printf( "int yylineno = 1;\n" ); - } - else if ( ! C_plus_plus ) - printf( "FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;\n" ); - - if ( C_plus_plus ) - printf( "\n#include \"FlexLexer.h\"\n" ); - - else - { - if ( yytext_is_array ) - puts( "extern char yytext[];\n" ); - - else - { - puts( "extern char *yytext;" ); - puts( "#define yytext_ptr yytext" ); - } - } - - if ( useecs ) - numecs = cre8ecs( nextecm, ecgroup, csize ); - else - numecs = csize; - - /* Now map the equivalence class for NUL to its expected place. */ - ecgroup[0] = ecgroup[csize]; - NUL_ec = ABS( ecgroup[0] ); - - if ( useecs ) - ccl2ecl(); - } - - -/* set_up_initial_allocations - allocate memory for internal tables */ - -void set_up_initial_allocations() - { - current_mns = INITIAL_MNS; - firstst = allocate_integer_array( current_mns ); - lastst = allocate_integer_array( current_mns ); - finalst = allocate_integer_array( current_mns ); - transchar = allocate_integer_array( current_mns ); - trans1 = allocate_integer_array( current_mns ); - trans2 = allocate_integer_array( current_mns ); - accptnum = allocate_integer_array( current_mns ); - assoc_rule = allocate_integer_array( current_mns ); - state_type = allocate_integer_array( current_mns ); - - current_max_rules = INITIAL_MAX_RULES; - rule_type = allocate_integer_array( current_max_rules ); - rule_linenum = allocate_integer_array( current_max_rules ); - rule_useful = allocate_integer_array( current_max_rules ); - - current_max_scs = INITIAL_MAX_SCS; - scset = allocate_integer_array( current_max_scs ); - scbol = allocate_integer_array( current_max_scs ); - scxclu = allocate_integer_array( current_max_scs ); - sceof = allocate_integer_array( current_max_scs ); - scname = allocate_char_ptr_array( current_max_scs ); - actvsc = allocate_integer_array( current_max_scs ); - - current_maxccls = INITIAL_MAX_CCLS; - cclmap = allocate_integer_array( current_maxccls ); - ccllen = allocate_integer_array( current_maxccls ); - cclng = allocate_integer_array( current_maxccls ); - - current_max_ccl_tbl_size = INITIAL_MAX_CCL_TBL_SIZE; - ccltbl = allocate_Character_array( current_max_ccl_tbl_size ); - - current_max_dfa_size = INITIAL_MAX_DFA_SIZE; - - current_max_xpairs = INITIAL_MAX_XPAIRS; - nxt = allocate_integer_array( current_max_xpairs ); - chk = allocate_integer_array( current_max_xpairs ); - - current_max_template_xpairs = INITIAL_MAX_TEMPLATE_XPAIRS; - tnxt = allocate_integer_array( current_max_template_xpairs ); - - current_max_dfas = INITIAL_MAX_DFAS; - base = allocate_integer_array( current_max_dfas ); - def = allocate_integer_array( current_max_dfas ); - dfasiz = allocate_integer_array( current_max_dfas ); - accsiz = allocate_integer_array( current_max_dfas ); - dhash = allocate_integer_array( current_max_dfas ); - dss = allocate_int_ptr_array( current_max_dfas ); - dfaacc = allocate_dfaacc_union( current_max_dfas ); - - nultrans = (int *) 0; - } - - -void usage() - { - fprintf( stderr, -"%s [-bcdfhilnpstvwBFILTV78+ -C[aefFmr] -Pprefix -Sskeleton] [file ...]\n", - program_name ); - - fprintf( stderr, - "\t-b generate backing-up information to lex.backup\n" ); - fprintf( stderr, "\t-c do-nothing POSIX option\n" ); - fprintf( stderr, "\t-d turn on debug mode in generated scanner\n" ); - fprintf( stderr, "\t-f generate fast, large scanner\n" ); - fprintf( stderr, "\t-h produce this help message\n" ); - fprintf( stderr, "\t-i generate case-insensitive scanner\n" ); - fprintf( stderr, "\t-l maximal compatibility with original lex\n" ); - fprintf( stderr, "\t-n do-nothing POSIX option\n" ); - fprintf( stderr, "\t-p generate performance report to stderr\n" ); - fprintf( stderr, - "\t-s suppress default rule to ECHO unmatched text\n" ); - fprintf( stderr, - "\t-t write generated scanner on stdout instead of lex.yy.c\n" ); - fprintf( stderr, - "\t-v write summary of scanner statistics to stderr\n" ); - fprintf( stderr, "\t-w do not generate warnings\n" ); - fprintf( stderr, "\t-B generate batch scanner (opposite of -I)\n" ); - fprintf( stderr, - "\t-F use alternative fast scanner representation\n" ); - fprintf( stderr, - "\t-I generate interactive scanner (opposite of -B)\n" ); - fprintf( stderr, "\t-L suppress #line directives in scanner\n" ); - fprintf( stderr, "\t-T %s should run in trace mode\n", program_name ); - fprintf( stderr, "\t-V report %s version\n", program_name ); - fprintf( stderr, "\t-7 generate 7-bit scanner\n" ); - fprintf( stderr, "\t-8 generate 8-bit scanner\n" ); - fprintf( stderr, "\t-+ generate C++ scanner class\n" ); - fprintf( stderr, - "\t-C specify degree of table compression (default is -Cem):\n" ); - fprintf( stderr, - "\t\t-Ca trade off larger tables for better memory alignment\n" ); - fprintf( stderr, "\t\t-Ce construct equivalence classes\n" ); - fprintf( stderr, - "\t\t-Cf do not compress scanner tables; use -f representation\n" ); - fprintf( stderr, - "\t\t-CF do not compress scanner tables; use -F representation\n" ); - fprintf( stderr, "\t\t-Cm construct meta-equivalence classes\n" ); - fprintf( stderr, - "\t\t-Cr use read() instead of stdio for scanner input\n" ); - fprintf( stderr, "\t-P specify scanner prefix other than \"yy\"\n" ); - fprintf( stderr, "\t-S specify skeleton file\n" ); - } diff --git a/gnu/usr.bin/lex/misc.c b/gnu/usr.bin/lex/misc.c deleted file mode 100644 index 3999c3942e8e..000000000000 --- a/gnu/usr.bin/lex/misc.c +++ /dev/null @@ -1,773 +0,0 @@ -/* misc - miscellaneous flex routines */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * 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. - */ - -/* $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/misc.c,v 1.5 1993/12/06 19:29:27 jtc Exp $ */ - -#include "flexdef.h" - - - -/* declare functions that have forward references */ - -void dataflush PROTO((void)); -int otoi PROTO((Char [])); - - -void add_action( new_text ) -char *new_text; - { - int len = yy_strlen( new_text ); - - while ( len + action_index >= action_size - 10 /* slop */ ) - { - action_size *= 2; - action_array = - reallocate_character_array( action_array, action_size ); - } - - yy_strcpy( &action_array[action_index], new_text ); - - action_index += len; - } - - -/* allocate_array - allocate memory for an integer array of the given size */ - -void *allocate_array( size, element_size ) -int size, element_size; - { - register void *mem; - - /* On 16-bit int machines (e.g., 80286) we might be trying to - * allocate more than a signed int can hold, and that won't - * work. Cheap test: - */ - if ( element_size * size <= 0 ) - flexfatal( "request for < 1 byte in allocate_array()" ); - - mem = yy_flex_alloc( element_size * size ); - - if ( mem == NULL ) - flexfatal( "memory allocation failed in allocate_array()" ); - - return mem; - } - - -/* all_lower - true if a string is all lower-case */ - -int all_lower( str ) -register char *str; - { - while ( *str ) - { - if ( ! isascii( (Char) *str ) || ! islower( *str ) ) - return 0; - ++str; - } - - return 1; - } - - -/* all_upper - true if a string is all upper-case */ - -int all_upper( str ) -register char *str; - { - while ( *str ) - { - if ( ! isascii( (Char) *str ) || ! isupper( *str ) ) - return 0; - ++str; - } - - return 1; - } - - -/* bubble - bubble sort an integer array in increasing order - * - * synopsis - * int v[n], n; - * void bubble( v, n ); - * - * description - * sorts the first n elements of array v and replaces them in - * increasing order. - * - * passed - * v - the array to be sorted - * n - the number of elements of 'v' to be sorted - */ - -void bubble( v, n ) -int v[], n; - { - register int i, j, k; - - for ( i = n; i > 1; --i ) - for ( j = 1; j < i; ++j ) - if ( v[j] > v[j + 1] ) /* compare */ - { - k = v[j]; /* exchange */ - v[j] = v[j + 1]; - v[j + 1] = k; - } - } - - -/* check_char - checks a character to make sure it's within the range - * we're expecting. If not, generates fatal error message - * and exits. - */ - -void check_char( c ) -int c; - { - if ( c >= CSIZE ) - lerrsf( "bad character '%s' detected in check_char()", - readable_form( c ) ); - - if ( c >= csize ) - lerrsf( "scanner requires -8 flag to use the character '%s'", - readable_form( c ) ); - } - - - -/* clower - replace upper-case letter to lower-case */ - -Char clower( c ) -register int c; - { - return (Char) ((isascii( c ) && isupper( c )) ? tolower( c ) : c); - } - - -/* copy_string - returns a dynamically allocated copy of a string */ - -char *copy_string( str ) -register char *str; - { - register char *c; - char *copy; - - /* find length */ - for ( c = str; *c; ++c ) - ; - - copy = (char *) yy_flex_alloc( (c - str + 1) * sizeof( char ) ); - - if ( copy == NULL ) - flexfatal( "dynamic memory failure in copy_string()" ); - - for ( c = copy; (*c++ = *str++); ) - ; - - return copy; - } - - -/* copy_unsigned_string - - * returns a dynamically allocated copy of a (potentially) unsigned string - */ - -Char *copy_unsigned_string( str ) -register Char *str; - { - register Char *c; - Char *copy; - - /* find length */ - for ( c = str; *c; ++c ) - ; - - copy = allocate_Character_array( c - str + 1 ); - - for ( c = copy; (*c++ = *str++); ) - ; - - return copy; - } - - -/* cshell - shell sort a character array in increasing order - * - * synopsis - * - * Char v[n]; - * int n, special_case_0; - * cshell( v, n, special_case_0 ); - * - * description - * Does a shell sort of the first n elements of array v. - * If special_case_0 is true, then any element equal to 0 - * is instead assumed to have infinite weight. - * - * passed - * v - array to be sorted - * n - number of elements of v to be sorted - */ - -void cshell( v, n, special_case_0 ) -Char v[]; -int n, special_case_0; - { - int gap, i, j, jg; - Char k; - - for ( gap = n / 2; gap > 0; gap = gap / 2 ) - for ( i = gap; i < n; ++i ) - for ( j = i - gap; j >= 0; j = j - gap ) - { - jg = j + gap; - - if ( special_case_0 ) - { - if ( v[jg] == 0 ) - break; - - else if ( v[j] != 0 && v[j] <= v[jg] ) - break; - } - - else if ( v[j] <= v[jg] ) - break; - - k = v[j]; - v[j] = v[jg]; - v[jg] = k; - } - } - - -/* dataend - finish up a block of data declarations */ - -void dataend() - { - if ( datapos > 0 ) - dataflush(); - - /* add terminator for initialization; { for vi */ - puts( " } ;\n" ); - - dataline = 0; - datapos = 0; - } - - -/* dataflush - flush generated data statements */ - -void dataflush() - { - putchar( '\n' ); - - if ( ++dataline >= NUMDATALINES ) - { - /* Put out a blank line so that the table is grouped into - * large blocks that enable the user to find elements easily. - */ - putchar( '\n' ); - dataline = 0; - } - - /* Reset the number of characters written on the current line. */ - datapos = 0; - } - - -/* flexerror - report an error message and terminate */ - -void flexerror( msg ) -char msg[]; - { - fprintf( stderr, "%s: %s\n", program_name, msg ); - flexend( 1 ); - } - - -/* flexfatal - report a fatal error message and terminate */ - -void flexfatal( msg ) -char msg[]; - { - fprintf( stderr, "%s: fatal internal error, %s\n", program_name, msg ); - exit( 1 ); - } - - -/* lerrif - report an error message formatted with one integer argument */ - -void lerrif( msg, arg ) -char msg[]; -int arg; - { - char errmsg[MAXLINE]; - (void) sprintf( errmsg, msg, arg ); - flexerror( errmsg ); - } - - -/* lerrsf - report an error message formatted with one string argument */ - -void lerrsf( msg, arg ) -char msg[], arg[]; - { - char errmsg[MAXLINE]; - - (void) sprintf( errmsg, msg, arg ); - flexerror( errmsg ); - } - - -/* htoi - convert a hexadecimal digit string to an integer value */ - -int htoi( str ) -Char str[]; - { - unsigned int result; - - (void) sscanf( (char *) str, "%x", &result ); - - return result; - } - - -/* is_hex_digit - returns true if a character is a valid hex digit, false - * otherwise - */ - -int is_hex_digit( ch ) -int ch; - { - if ( isdigit( ch ) ) - return 1; - - switch ( clower( ch ) ) - { - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - return 1; - - default: - return 0; - } - } - - -/* line_directive_out - spit out a "# line" statement */ - -void line_directive_out( output_file ) -FILE *output_file; - { - if ( infilename && gen_line_dirs ) - { - char directive[MAXLINE]; - sprintf( directive, "# line %d \"%s\"\n", linenum, infilename ); - - /* If output_file is nil then we should put the directive in - * the accumulated actions. - */ - if ( output_file ) - fputs( directive, output_file ); - else - add_action( directive ); - } - } - - -/* mark_defs1 - mark the current position in the action array as - * representing where the user's section 1 definitions end - * and the prolog begins - */ -void mark_defs1() - { - defs1_offset = 0; - action_array[action_index++] = '\0'; - action_offset = prolog_offset = action_index; - action_array[action_index] = '\0'; - } - - -/* mark_prolog - mark the current position in the action array as - * representing the end of the action prolog - */ -void mark_prolog() - { - action_array[action_index++] = '\0'; - action_offset = action_index; - action_array[action_index] = '\0'; - } - - -/* mk2data - generate a data statement for a two-dimensional array - * - * Generates a data statement initializing the current 2-D array to "value". - */ -void mk2data( value ) -int value; - { - if ( datapos >= NUMDATAITEMS ) - { - putchar( ',' ); - dataflush(); - } - - if ( datapos == 0 ) - /* Indent. */ - fputs( " ", stdout ); - - else - putchar( ',' ); - - ++datapos; - - printf( "%5d", value ); - } - - -/* mkdata - generate a data statement - * - * Generates a data statement initializing the current array element to - * "value". - */ -void mkdata( value ) -int value; - { - if ( datapos >= NUMDATAITEMS ) - { - putchar( ',' ); - dataflush(); - } - - if ( datapos == 0 ) - /* Indent. */ - fputs( " ", stdout ); - else - putchar( ',' ); - - ++datapos; - - printf( "%5d", value ); - } - - -/* myctoi - return the integer represented by a string of digits */ - -int myctoi( array ) -char array[]; - { - int val = 0; - - (void) sscanf( array, "%d", &val ); - - return val; - } - - -/* myesc - return character corresponding to escape sequence */ - -Char myesc( array ) -Char array[]; - { - Char c, esc_char; - - switch ( array[1] ) - { - case 'b': return '\b'; - case 'f': return '\f'; - case 'n': return '\n'; - case 'r': return '\r'; - case 't': return '\t'; - -#ifdef __STDC__ - case 'a': return '\a'; - case 'v': return '\v'; -#else - case 'a': return '\007'; - case 'v': return '\013'; -#endif - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { /* \ */ - int sptr = 1; - - while ( isascii( array[sptr] ) && - isdigit( array[sptr] ) ) - /* Don't increment inside loop control - * because if isdigit() is a macro it might - * expand into multiple increments ... - */ - ++sptr; - - c = array[sptr]; - array[sptr] = '\0'; - - esc_char = otoi( array + 1 ); - - array[sptr] = c; - - return esc_char; - } - - case 'x': - { /* \x */ - int sptr = 2; - - while ( isascii( array[sptr] ) && - is_hex_digit( (char) array[sptr] ) ) - /* Don't increment inside loop control - * because if isdigit() is a macro it might - * expand into multiple increments ... - */ - ++sptr; - - c = array[sptr]; - array[sptr] = '\0'; - - esc_char = htoi( array + 2 ); - - array[sptr] = c; - - return esc_char; - } - - default: - return array[1]; - } - } - - -/* otoi - convert an octal digit string to an integer value */ - -int otoi( str ) -Char str[]; - { - unsigned int result; - - (void) sscanf( (char *) str, "%o", &result ); - return result; - } - - -/* readable_form - return the the human-readable form of a character - * - * The returned string is in static storage. - */ - -char *readable_form( c ) -register int c; - { - static char rform[10]; - - if ( (c >= 0 && c < 32) || c >= 127 ) - { - switch ( c ) - { - case '\b': return "\\b"; - case '\f': return "\\f"; - case '\n': return "\\n"; - case '\r': return "\\r"; - case '\t': return "\\t"; - -#ifdef __STDC__ - case '\a': return "\\a"; - case '\v': return "\\v"; -#endif - - default: - (void) sprintf( rform, "\\%.3o", - (unsigned int) c ); - return rform; - } - } - - else if ( c == ' ' ) - return "' '"; - - else - { - rform[0] = c; - rform[1] = '\0'; - - return rform; - } - } - - -/* reallocate_array - increase the size of a dynamic array */ - -void *reallocate_array( array, size, element_size ) -void *array; -int size, element_size; - { - register void *new_array; - - /* Same worry as in allocate_array(): */ - if ( size * element_size <= 0 ) - flexfatal( - "attempt to increase array size by less than 1 byte" ); - - new_array = yy_flex_realloc( array, size * element_size ); - - if ( new_array == NULL ) - flexfatal( "attempt to increase array size failed" ); - - return new_array; - } - - -/* skelout - write out one section of the skeleton file - * - * Description - * Copies skelfile or skel array to stdout until a line beginning with - * "%%" or EOF is found. - */ -void skelout() - { - char buf_storage[MAXLINE]; - char *buf = buf_storage; - int do_copy = 1; - - /* Loop pulling lines either from the skelfile, if we're using - * one, or from the skel[] array. - */ - while ( skelfile ? - (fgets( buf, MAXLINE, skelfile ) != NULL) : - ((buf = skel[skel_ind++]) != 0) ) - { /* copy from skel array */ - if ( buf[0] == '%' ) - { /* control line */ - switch ( buf[1] ) - { - case '%': - return; - - case '+': - do_copy = C_plus_plus; - break; - - case '-': - do_copy = ! C_plus_plus; - break; - - case '*': - do_copy = 1; - break; - - default: - flexfatal( - "bad line in skeleton file" ); - } - } - - else if ( do_copy ) - { - if ( skelfile ) - /* Skeleton file reads include final - * newline, skel[] array does not. - */ - fputs( buf, stdout ); - else - printf( "%s\n", buf ); - } - } - } - - -/* transition_struct_out - output a yy_trans_info structure - * - * outputs the yy_trans_info structure with the two elements, element_v and - * element_n. Formats the output with spaces and carriage returns. - */ - -void transition_struct_out( element_v, element_n ) -int element_v, element_n; - { - printf( "%7d, %5d,", element_v, element_n ); - - datapos += TRANS_STRUCT_PRINT_LENGTH; - - if ( datapos >= 75 ) - { - putchar( '\n' ); - - if ( ++dataline % 10 == 0 ) - putchar( '\n' ); - - datapos = 0; - } - } - - -/* The following is only needed when building flex's parser using certain - * broken versions of bison. - */ -void *yy_flex_xmalloc( size ) -int size; - { - void *result = yy_flex_alloc( size ); - - if ( ! result ) - flexfatal( "memory allocation failed in yy_flex_xmalloc()" ); - - return result; - } - - -/* zero_out - set a region of memory to 0 - * - * Sets region_ptr[0] through region_ptr[size_in_bytes - 1] to zero. - */ - -void zero_out( region_ptr, size_in_bytes ) -char *region_ptr; -int size_in_bytes; - { - register char *rp, *rp_end; - - rp = region_ptr; - rp_end = region_ptr + size_in_bytes; - - while ( rp < rp_end ) - *rp++ = 0; - } diff --git a/gnu/usr.bin/lex/mkskel.sh b/gnu/usr.bin/lex/mkskel.sh deleted file mode 100644 index ffc7c7fe9aab..000000000000 --- a/gnu/usr.bin/lex/mkskel.sh +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/sh - -cat < 0 ) - fprintf( stderr, - "Variable trailing context rule at line %d\n", - rule_linenum[num_rules] ); - - variable_trailing_context_rules = true; - } - - else - { - rule_type[num_rules] = RULE_NORMAL; - - if ( headcnt > 0 || trailcnt > 0 ) - { - /* Do trailing context magic to not match the trailing - * characters. - */ - char *scanner_cp = "yy_c_buf_p = yy_cp"; - char *scanner_bp = "yy_bp"; - - add_action( - "*yy_cp = yy_hold_char; /* undo effects of setting up yytext */\n" ); - - if ( headcnt > 0 ) - { - sprintf( action_text, "%s = %s + %d;\n", - scanner_cp, scanner_bp, headcnt ); - add_action( action_text ); - } - - else - { - sprintf( action_text, "%s -= %d;\n", - scanner_cp, trailcnt ); - add_action( action_text ); - } - - add_action( - "YY_DO_BEFORE_ACTION; /* set up yytext again */\n" ); - } - } - - /* Okay, in the action code at this point yytext and yyleng have - * their proper final values for this rule, so here's the point - * to do any user action. - */ - add_action( "YY_USER_ACTION\n" ); - - line_directive_out( (FILE *) 0 ); - } - - -/* link_machines - connect two machines together - * - * synopsis - * - * new = link_machines( first, last ); - * - * new - a machine constructed by connecting first to last - * first - the machine whose successor is to be last - * last - the machine whose predecessor is to be first - * - * note: this routine concatenates the machine first with the machine - * last to produce a machine new which will pattern-match first first - * and then last, and will fail if either of the sub-patterns fails. - * FIRST is set to new by the operation. last is unmolested. - */ - -int link_machines( first, last ) -int first, last; - { - if ( first == NIL ) - return last; - - else if ( last == NIL ) - return first; - - else - { - mkxtion( finalst[first], last ); - finalst[first] = finalst[last]; - lastst[first] = MAX( lastst[first], lastst[last] ); - firstst[first] = MIN( firstst[first], firstst[last] ); - - return first; - } - } - - -/* mark_beginning_as_normal - mark each "beginning" state in a machine - * as being a "normal" (i.e., not trailing context- - * associated) states - * - * The "beginning" states are the epsilon closure of the first state - */ - -void mark_beginning_as_normal( mach ) -register int mach; - { - switch ( state_type[mach] ) - { - case STATE_NORMAL: - /* Oh, we've already visited here. */ - return; - - case STATE_TRAILING_CONTEXT: - state_type[mach] = STATE_NORMAL; - - if ( transchar[mach] == SYM_EPSILON ) - { - if ( trans1[mach] != NO_TRANSITION ) - mark_beginning_as_normal( - trans1[mach] ); - - if ( trans2[mach] != NO_TRANSITION ) - mark_beginning_as_normal( - trans2[mach] ); - } - break; - - default: - flexerror( - "bad state type in mark_beginning_as_normal()" ); - break; - } - } - - -/* mkbranch - make a machine that branches to two machines - * - * synopsis - * - * branch = mkbranch( first, second ); - * - * branch - a machine which matches either first's pattern or second's - * first, second - machines whose patterns are to be or'ed (the | operator) - * - * Note that first and second are NEITHER destroyed by the operation. Also, - * the resulting machine CANNOT be used with any other "mk" operation except - * more mkbranch's. Compare with mkor() - */ - -int mkbranch( first, second ) -int first, second; - { - int eps; - - if ( first == NO_TRANSITION ) - return second; - - else if ( second == NO_TRANSITION ) - return first; - - eps = mkstate( SYM_EPSILON ); - - mkxtion( eps, first ); - mkxtion( eps, second ); - - return eps; - } - - -/* mkclos - convert a machine into a closure - * - * synopsis - * new = mkclos( state ); - * - * new - a new state which matches the closure of "state" - */ - -int mkclos( state ) -int state; - { - return mkopt( mkposcl( state ) ); - } - - -/* mkopt - make a machine optional - * - * synopsis - * - * new = mkopt( mach ); - * - * new - a machine which optionally matches whatever mach matched - * mach - the machine to make optional - * - * notes: - * 1. mach must be the last machine created - * 2. mach is destroyed by the call - */ - -int mkopt( mach ) -int mach; - { - int eps; - - if ( ! SUPER_FREE_EPSILON(finalst[mach]) ) - { - eps = mkstate( SYM_EPSILON ); - mach = link_machines( mach, eps ); - } - - /* Can't skimp on the following if FREE_EPSILON(mach) is true because - * some state interior to "mach" might point back to the beginning - * for a closure. - */ - eps = mkstate( SYM_EPSILON ); - mach = link_machines( eps, mach ); - - mkxtion( mach, finalst[mach] ); - - return mach; - } - - -/* mkor - make a machine that matches either one of two machines - * - * synopsis - * - * new = mkor( first, second ); - * - * new - a machine which matches either first's pattern or second's - * first, second - machines whose patterns are to be or'ed (the | operator) - * - * note that first and second are both destroyed by the operation - * the code is rather convoluted because an attempt is made to minimize - * the number of epsilon states needed - */ - -int mkor( first, second ) -int first, second; - { - int eps, orend; - - if ( first == NIL ) - return second; - - else if ( second == NIL ) - return first; - - else - { - /* See comment in mkopt() about why we can't use the first - * state of "first" or "second" if they satisfy "FREE_EPSILON". - */ - eps = mkstate( SYM_EPSILON ); - - first = link_machines( eps, first ); - - mkxtion( first, second ); - - if ( SUPER_FREE_EPSILON(finalst[first]) && - accptnum[finalst[first]] == NIL ) - { - orend = finalst[first]; - mkxtion( finalst[second], orend ); - } - - else if ( SUPER_FREE_EPSILON(finalst[second]) && - accptnum[finalst[second]] == NIL ) - { - orend = finalst[second]; - mkxtion( finalst[first], orend ); - } - - else - { - eps = mkstate( SYM_EPSILON ); - - first = link_machines( first, eps ); - orend = finalst[first]; - - mkxtion( finalst[second], orend ); - } - } - - finalst[first] = orend; - return first; - } - - -/* mkposcl - convert a machine into a positive closure - * - * synopsis - * new = mkposcl( state ); - * - * new - a machine matching the positive closure of "state" - */ - -int mkposcl( state ) -int state; - { - int eps; - - if ( SUPER_FREE_EPSILON(finalst[state]) ) - { - mkxtion( finalst[state], state ); - return state; - } - - else - { - eps = mkstate( SYM_EPSILON ); - mkxtion( eps, state ); - return link_machines( state, eps ); - } - } - - -/* mkrep - make a replicated machine - * - * synopsis - * new = mkrep( mach, lb, ub ); - * - * new - a machine that matches whatever "mach" matched from "lb" - * number of times to "ub" number of times - * - * note - * if "ub" is INFINITY then "new" matches "lb" or more occurrences of "mach" - */ - -int mkrep( mach, lb, ub ) -int mach, lb, ub; - { - int base_mach, tail, copy, i; - - base_mach = copysingl( mach, lb - 1 ); - - if ( ub == INFINITY ) - { - copy = dupmachine( mach ); - mach = link_machines( mach, - link_machines( base_mach, mkclos( copy ) ) ); - } - - else - { - tail = mkstate( SYM_EPSILON ); - - for ( i = lb; i < ub; ++i ) - { - copy = dupmachine( mach ); - tail = mkopt( link_machines( copy, tail ) ); - } - - mach = link_machines( mach, link_machines( base_mach, tail ) ); - } - - return mach; - } - - -/* mkstate - create a state with a transition on a given symbol - * - * synopsis - * - * state = mkstate( sym ); - * - * state - a new state matching sym - * sym - the symbol the new state is to have an out-transition on - * - * note that this routine makes new states in ascending order through the - * state array (and increments LASTNFA accordingly). The routine DUPMACHINE - * relies on machines being made in ascending order and that they are - * CONTIGUOUS. Change it and you will have to rewrite DUPMACHINE (kludge - * that it admittedly is) - */ - -int mkstate( sym ) -int sym; - { - if ( ++lastnfa >= current_mns ) - { - if ( (current_mns += MNS_INCREMENT) >= MAXIMUM_MNS ) - lerrif( - "input rules are too complicated (>= %d NFA states)", - current_mns ); - - ++num_reallocs; - - firstst = reallocate_integer_array( firstst, current_mns ); - lastst = reallocate_integer_array( lastst, current_mns ); - finalst = reallocate_integer_array( finalst, current_mns ); - transchar = reallocate_integer_array( transchar, current_mns ); - trans1 = reallocate_integer_array( trans1, current_mns ); - trans2 = reallocate_integer_array( trans2, current_mns ); - accptnum = reallocate_integer_array( accptnum, current_mns ); - assoc_rule = - reallocate_integer_array( assoc_rule, current_mns ); - state_type = - reallocate_integer_array( state_type, current_mns ); - } - - firstst[lastnfa] = lastnfa; - finalst[lastnfa] = lastnfa; - lastst[lastnfa] = lastnfa; - transchar[lastnfa] = sym; - trans1[lastnfa] = NO_TRANSITION; - trans2[lastnfa] = NO_TRANSITION; - accptnum[lastnfa] = NIL; - assoc_rule[lastnfa] = num_rules; - state_type[lastnfa] = current_state_type; - - /* Fix up equivalence classes base on this transition. Note that any - * character which has its own transition gets its own equivalence - * class. Thus only characters which are only in character classes - * have a chance at being in the same equivalence class. E.g. "a|b" - * puts 'a' and 'b' into two different equivalence classes. "[ab]" - * puts them in the same equivalence class (barring other differences - * elsewhere in the input). - */ - - if ( sym < 0 ) - { - /* We don't have to update the equivalence classes since - * that was already done when the ccl was created for the - * first time. - */ - } - - else if ( sym == SYM_EPSILON ) - ++numeps; - - else - { - check_char( sym ); - - if ( useecs ) - /* Map NUL's to csize. */ - mkechar( sym ? sym : csize, nextecm, ecgroup ); - } - - return lastnfa; - } - - -/* mkxtion - make a transition from one state to another - * - * synopsis - * - * mkxtion( statefrom, stateto ); - * - * statefrom - the state from which the transition is to be made - * stateto - the state to which the transition is to be made - */ - -void mkxtion( statefrom, stateto ) -int statefrom, stateto; - { - if ( trans1[statefrom] == NO_TRANSITION ) - trans1[statefrom] = stateto; - - else if ( (transchar[statefrom] != SYM_EPSILON) || - (trans2[statefrom] != NO_TRANSITION) ) - flexfatal( "found too many transitions in mkxtion()" ); - - else - { /* second out-transition for an epsilon state */ - ++eps2; - trans2[statefrom] = stateto; - } - } - -/* new_rule - initialize for a new rule */ - -void new_rule() - { - if ( ++num_rules >= current_max_rules ) - { - ++num_reallocs; - current_max_rules += MAX_RULES_INCREMENT; - rule_type = reallocate_integer_array( rule_type, - current_max_rules ); - rule_linenum = reallocate_integer_array( rule_linenum, - current_max_rules ); - rule_useful = reallocate_integer_array( rule_useful, - current_max_rules ); - } - - if ( num_rules > MAX_RULE ) - lerrif( "too many rules (> %d)!", MAX_RULE ); - - rule_linenum[num_rules] = linenum; - rule_useful[num_rules] = false; - } diff --git a/gnu/usr.bin/lex/parse.y b/gnu/usr.bin/lex/parse.y deleted file mode 100644 index cd43bd6c99e8..000000000000 --- a/gnu/usr.bin/lex/parse.y +++ /dev/null @@ -1,822 +0,0 @@ -/* parse.y - parser for flex input */ - -%token CHAR NUMBER SECTEND SCDECL XSCDECL WHITESPACE NAME PREVCCL EOF_OP - -%{ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * 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. - */ - -/* $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/parse.y,v 1.5 1993/12/06 19:29:30 jtc Exp $ */ - - -/* Some versions of bison are broken in that they use alloca() but don't - * declare it properly. The following is the patented (just kidding!) - * #ifdef chud to fix the problem, courtesy of Francois Pinard. - */ -#ifdef YYBISON -/* AIX requires this to be the first thing in the file. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if HAVE_ALLOCA_H -#include -#else /* not HAVE_ALLOCA_H */ -#ifdef _AIX - #pragma alloca -#else /* not _AIX */ -char *alloca (); -#endif /* not _AIX */ -#endif /* not HAVE_ALLOCA_H */ -#endif /* not __GNUC__ */ -#endif /* YYBISON */ - -/* Bletch, ^^^^ that was ugly! */ - - -#include "flexdef.h" - -int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen; -int trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule; -int *active_ss; -Char clower(); -void build_eof_action(); -void yyerror(); - -static int madeany = false; /* whether we've made the '.' character class */ -int previous_continued_action; /* whether the previous rule's action was '|' */ - -/* On some over-ambitious machines, such as DEC Alpha's, the default - * token type is "long" instead of "int"; this leads to problems with - * declaring yylval in flexdef.h. But so far, all the yacc's I've seen - * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the - * following should ensure that the default token type is "int". - */ -#define YYSTYPE int - -%} - -%% -goal : initlex sect1 sect1end sect2 initforrule - { /* add default rule */ - int def_rule; - - pat = cclinit(); - cclnegate( pat ); - - def_rule = mkstate( -pat ); - - /* Remember the number of the default rule so we - * don't generate "can't match" warnings for it. - */ - default_rule = num_rules; - - finish_rule( def_rule, false, 0, 0 ); - - for ( i = 1; i <= lastsc; ++i ) - scset[i] = mkbranch( scset[i], def_rule ); - - if ( spprdflt ) - add_action( - "YY_FATAL_ERROR( \"flex scanner jammed\" )" ); - else - add_action( "ECHO" ); - - add_action( ";\n\tYY_BREAK\n" ); - } - ; - -initlex : - { /* initialize for processing rules */ - - /* Create default DFA start condition. */ - scinstal( "INITIAL", false ); - - /* Initially, the start condition scoping is - * "no start conditions active". - */ - actvp = 0; - } - ; - -sect1 : sect1 startconddecl WHITESPACE namelist1 '\n' - | - | error '\n' - { synerr( "unknown error processing section 1" ); } - ; - -sect1end : SECTEND - { - /* We now know how many start conditions there - * are, so create the "activity" map indicating - * which conditions are active. - */ - active_ss = allocate_integer_array( lastsc + 1 ); - - for ( i = 1; i <= lastsc; ++i ) - active_ss[i] = 0; - } - ; - -startconddecl : SCDECL - { xcluflg = false; } - - | XSCDECL - { xcluflg = true; } - ; - -namelist1 : namelist1 WHITESPACE NAME - { scinstal( nmstr, xcluflg ); } - - | NAME - { scinstal( nmstr, xcluflg ); } - - | error - { synerr( "bad start condition list" ); } - ; - -sect2 : sect2 initforrule flexrule '\n' - | - ; - -initforrule : - { - /* Initialize for a parse of one rule. */ - trlcontxt = variable_trail_rule = varlength = false; - trailcnt = headcnt = rulelen = 0; - current_state_type = STATE_NORMAL; - previous_continued_action = continued_action; - new_rule(); - } - ; - -flexrule : scon '^' rule - { - pat = $3; - finish_rule( pat, variable_trail_rule, - headcnt, trailcnt ); - - for ( i = 1; i <= actvp; ++i ) - scbol[actvsc[i]] = - mkbranch( scbol[actvsc[i]], pat ); - - if ( ! bol_needed ) - { - bol_needed = true; - - if ( performance_report > 1 ) - pinpoint_message( - "'^' operator results in sub-optimal performance" ); - } - } - - | scon rule - { - pat = $2; - finish_rule( pat, variable_trail_rule, - headcnt, trailcnt ); - - for ( i = 1; i <= actvp; ++i ) - scset[actvsc[i]] = - mkbranch( scset[actvsc[i]], pat ); - } - - | '^' rule - { - pat = $2; - finish_rule( pat, variable_trail_rule, - headcnt, trailcnt ); - - /* Add to all non-exclusive start conditions, - * including the default (0) start condition. - */ - - for ( i = 1; i <= lastsc; ++i ) - if ( ! scxclu[i] ) - scbol[i] = mkbranch( scbol[i], pat ); - - if ( ! bol_needed ) - { - bol_needed = true; - - if ( performance_report > 1 ) - pinpoint_message( - "'^' operator results in sub-optimal performance" ); - } - } - - | rule - { - pat = $1; - finish_rule( pat, variable_trail_rule, - headcnt, trailcnt ); - - for ( i = 1; i <= lastsc; ++i ) - if ( ! scxclu[i] ) - scset[i] = mkbranch( scset[i], pat ); - } - - | scon EOF_OP - { build_eof_action(); } - - | EOF_OP - { - /* This EOF applies to all start conditions - * which don't already have EOF actions. - */ - actvp = 0; - - for ( i = 1; i <= lastsc; ++i ) - if ( ! sceof[i] ) - actvsc[++actvp] = i; - - if ( actvp == 0 ) - warn( - "all start conditions already have <> rules" ); - - else - build_eof_action(); - } - - | error - { synerr( "unrecognized rule" ); } - ; - -scon : '<' namelist2 '>' - - | '<' '*' '>' - { - actvp = 0; - - for ( i = 1; i <= lastsc; ++i ) - actvsc[++actvp] = i; - } - ; - -namelist2 : namelist2 ',' sconname - - | { actvp = 0; } sconname - - | error - { synerr( "bad start condition list" ); } - ; - -sconname : NAME - { - if ( (scnum = sclookup( nmstr )) == 0 ) - format_pinpoint_message( - "undeclared start condition %s", - nmstr ); - else - { - if ( ++actvp >= current_max_scs ) - /* Some bozo has included multiple - * instances of start condition names. - */ - pinpoint_message( - "too many start conditions in <> construct!" ); - - else - actvsc[actvp] = scnum; - } - } - ; - -rule : re2 re - { - if ( transchar[lastst[$2]] != SYM_EPSILON ) - /* Provide final transition \now/ so it - * will be marked as a trailing context - * state. - */ - $2 = link_machines( $2, - mkstate( SYM_EPSILON ) ); - - mark_beginning_as_normal( $2 ); - current_state_type = STATE_NORMAL; - - if ( previous_continued_action ) - { - /* We need to treat this as variable trailing - * context so that the backup does not happen - * in the action but before the action switch - * statement. If the backup happens in the - * action, then the rules "falling into" this - * one's action will *also* do the backup, - * erroneously. - */ - if ( ! varlength || headcnt != 0 ) - warn( - "trailing context made variable due to preceding '|' action" ); - - /* Mark as variable. */ - varlength = true; - headcnt = 0; - } - - if ( lex_compat || (varlength && headcnt == 0) ) - { /* variable trailing context rule */ - /* Mark the first part of the rule as the - * accepting "head" part of a trailing - * context rule. - * - * By the way, we didn't do this at the - * beginning of this production because back - * then current_state_type was set up for a - * trail rule, and add_accept() can create - * a new state ... - */ - add_accept( $1, - num_rules | YY_TRAILING_HEAD_MASK ); - variable_trail_rule = true; - } - - else - trailcnt = rulelen; - - $$ = link_machines( $1, $2 ); - } - - | re2 re '$' - { synerr( "trailing context used twice" ); } - - | re '$' - { - if ( trlcontxt ) - { - synerr( "trailing context used twice" ); - $$ = mkstate( SYM_EPSILON ); - } - - else if ( previous_continued_action ) - { - /* See the comment in the rule for "re2 re" - * above. - */ - if ( ! varlength || headcnt != 0 ) - warn( - "trailing context made variable due to preceding '|' action" ); - - /* Mark as variable. */ - varlength = true; - headcnt = 0; - } - - if ( lex_compat || (varlength && headcnt == 0) ) - { - /* Again, see the comment in the rule for - * "re2 re" above. - */ - add_accept( $1, - num_rules | YY_TRAILING_HEAD_MASK ); - variable_trail_rule = true; - } - - else - { - if ( ! varlength ) - headcnt = rulelen; - - ++rulelen; - trailcnt = 1; - } - - trlcontxt = true; - - eps = mkstate( SYM_EPSILON ); - $$ = link_machines( $1, - link_machines( eps, mkstate( '\n' ) ) ); - } - - | re - { - $$ = $1; - - if ( trlcontxt ) - { - if ( lex_compat || (varlength && headcnt == 0) ) - /* Both head and trail are - * variable-length. - */ - variable_trail_rule = true; - else - trailcnt = rulelen; - } - } - ; - - -re : re '|' series - { - varlength = true; - $$ = mkor( $1, $3 ); - } - - | series - { $$ = $1; } - ; - - -re2 : re '/' - { - /* This rule is written separately so the - * reduction will occur before the trailing - * series is parsed. - */ - - if ( trlcontxt ) - synerr( "trailing context used twice" ); - else - trlcontxt = true; - - if ( varlength ) - /* We hope the trailing context is - * fixed-length. - */ - varlength = false; - else - headcnt = rulelen; - - rulelen = 0; - - current_state_type = STATE_TRAILING_CONTEXT; - $$ = $1; - } - ; - -series : series singleton - { - /* This is where concatenation of adjacent patterns - * gets done. - */ - $$ = link_machines( $1, $2 ); - } - - | singleton - { $$ = $1; } - ; - -singleton : singleton '*' - { - varlength = true; - - $$ = mkclos( $1 ); - } - - | singleton '+' - { - varlength = true; - $$ = mkposcl( $1 ); - } - - | singleton '?' - { - varlength = true; - $$ = mkopt( $1 ); - } - - | singleton '{' NUMBER ',' NUMBER '}' - { - varlength = true; - - if ( $3 > $5 || $3 < 0 ) - { - synerr( "bad iteration values" ); - $$ = $1; - } - else - { - if ( $3 == 0 ) - { - if ( $5 <= 0 ) - { - synerr( - "bad iteration values" ); - $$ = $1; - } - else - $$ = mkopt( - mkrep( $1, 1, $5 ) ); - } - else - $$ = mkrep( $1, $3, $5 ); - } - } - - | singleton '{' NUMBER ',' '}' - { - varlength = true; - - if ( $3 <= 0 ) - { - synerr( "iteration value must be positive" ); - $$ = $1; - } - - else - $$ = mkrep( $1, $3, INFINITY ); - } - - | singleton '{' NUMBER '}' - { - /* The singleton could be something like "(foo)", - * in which case we have no idea what its length - * is, so we punt here. - */ - varlength = true; - - if ( $3 <= 0 ) - { - synerr( "iteration value must be positive" ); - $$ = $1; - } - - else - $$ = link_machines( $1, - copysingl( $1, $3 - 1 ) ); - } - - | '.' - { - if ( ! madeany ) - { - /* Create the '.' character class. */ - anyccl = cclinit(); - ccladd( anyccl, '\n' ); - cclnegate( anyccl ); - - if ( useecs ) - mkeccl( ccltbl + cclmap[anyccl], - ccllen[anyccl], nextecm, - ecgroup, csize, csize ); - - madeany = true; - } - - ++rulelen; - - $$ = mkstate( -anyccl ); - } - - | fullccl - { - if ( ! cclsorted ) - /* Sort characters for fast searching. We - * use a shell sort since this list could - * be large. - */ - cshell( ccltbl + cclmap[$1], ccllen[$1], true ); - - if ( useecs ) - mkeccl( ccltbl + cclmap[$1], ccllen[$1], - nextecm, ecgroup, csize, csize ); - - ++rulelen; - - $$ = mkstate( -$1 ); - } - - | PREVCCL - { - ++rulelen; - - $$ = mkstate( -$1 ); - } - - | '"' string '"' - { $$ = $2; } - - | '(' re ')' - { $$ = $2; } - - | CHAR - { - ++rulelen; - - if ( caseins && $1 >= 'A' && $1 <= 'Z' ) - $1 = clower( $1 ); - - $$ = mkstate( $1 ); - } - ; - -fullccl : '[' ccl ']' - { $$ = $2; } - - | '[' '^' ccl ']' - { - cclnegate( $3 ); - $$ = $3; - } - ; - -ccl : ccl CHAR '-' CHAR - { - if ( caseins ) - { - if ( $2 >= 'A' && $2 <= 'Z' ) - $2 = clower( $2 ); - if ( $4 >= 'A' && $4 <= 'Z' ) - $4 = clower( $4 ); - } - - if ( $2 > $4 ) - synerr( "negative range in character class" ); - - else - { - for ( i = $2; i <= $4; ++i ) - ccladd( $1, i ); - - /* Keep track if this ccl is staying in - * alphabetical order. - */ - cclsorted = cclsorted && ($2 > lastchar); - lastchar = $4; - } - - $$ = $1; - } - - | ccl CHAR - { - if ( caseins && $2 >= 'A' && $2 <= 'Z' ) - $2 = clower( $2 ); - - ccladd( $1, $2 ); - cclsorted = cclsorted && ($2 > lastchar); - lastchar = $2; - $$ = $1; - } - - | - { - cclsorted = true; - lastchar = 0; - $$ = cclinit(); - } - ; - -string : string CHAR - { - if ( caseins && $2 >= 'A' && $2 <= 'Z' ) - $2 = clower( $2 ); - - ++rulelen; - - $$ = link_machines( $1, mkstate( $2 ) ); - } - - | - { $$ = mkstate( SYM_EPSILON ); } - ; - -%% - - -/* build_eof_action - build the "<>" action for the active start - * conditions - */ - -void build_eof_action() - { - register int i; - char action_text[MAXLINE]; - - for ( i = 1; i <= actvp; ++i ) - { - if ( sceof[actvsc[i]] ) - format_pinpoint_message( - "multiple <> rules for start condition %s", - scname[actvsc[i]] ); - - else - { - sceof[actvsc[i]] = true; - sprintf( action_text, "case YY_STATE_EOF(%s):\n", - scname[actvsc[i]] ); - add_action( action_text ); - } - } - - line_directive_out( (FILE *) 0 ); - - /* This isn't a normal rule after all - don't count it as - * such, so we don't have any holes in the rule numbering - * (which make generating "rule can never match" warnings - * more difficult. - */ - --num_rules; - ++num_eof_rules; - } - - -/* format_synerr - write out formatted syntax error */ - -void format_synerr( msg, arg ) -char msg[], arg[]; - { - char errmsg[MAXLINE]; - - (void) sprintf( errmsg, msg, arg ); - synerr( errmsg ); - } - - -/* synerr - report a syntax error */ - -void synerr( str ) -char str[]; - { - syntaxerror = true; - pinpoint_message( str ); - } - - -/* warn - report a warning, unless -w was given */ - -void warn( str ) -char str[]; - { - line_warning( str, linenum ); - } - -/* format_pinpoint_message - write out a message formatted with one string, - * pinpointing its location - */ - -void format_pinpoint_message( msg, arg ) -char msg[], arg[]; - { - char errmsg[MAXLINE]; - - (void) sprintf( errmsg, msg, arg ); - pinpoint_message( errmsg ); - } - - -/* pinpoint_message - write out a message, pinpointing its location */ - -void pinpoint_message( str ) -char str[]; - { - line_pinpoint( str, linenum ); - } - - -/* line_warning - report a warning at a given line, unless -w was given */ - -void line_warning( str, line ) -char str[]; -int line; - { - char warning[MAXLINE]; - - if ( ! nowarn ) - { - sprintf( warning, "warning, %s", str ); - line_pinpoint( warning, line ); - } - } - - -/* line_pinpoint - write out a message, pinpointing it at the given line */ - -void line_pinpoint( str, line ) -char str[]; -int line; - { - fprintf( stderr, "\"%s\", line %d: %s\n", infilename, line, str ); - } - - -/* yyerror - eat up an error message from the parser; - * currently, messages are ignore - */ - -void yyerror( msg ) -char msg[]; - { - } diff --git a/gnu/usr.bin/lex/pathnames.h b/gnu/usr.bin/lex/pathnames.h deleted file mode 100644 index 659a8108abb4..000000000000 --- a/gnu/usr.bin/lex/pathnames.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)pathnames.h 5.1 (Berkeley) 6/18/90 - * pathnames.h,v 1.2 1993/08/01 18:46:49 mycroft Exp - */ - -#define _PATH_SKELETONFILE "/usr/share/misc/lex.skel" diff --git a/gnu/usr.bin/lex/scan.l b/gnu/usr.bin/lex/scan.l deleted file mode 100644 index 750b24501545..000000000000 --- a/gnu/usr.bin/lex/scan.l +++ /dev/null @@ -1,550 +0,0 @@ -/* scan.l - scanner for flex input */ - -%{ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * 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. - */ - -/* $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/scan.l,v 1.6 1993/12/09 19:06:27 jtc Exp $ */ - -#include "flexdef.h" -#include "parse.h" - -#define ACTION_ECHO add_action( yytext ) -#define MARK_END_OF_PROLOG mark_prolog(); - -#define YY_DECL \ - int flexscan() - -#define RETURNCHAR \ - yylval = (unsigned char) yytext[0]; \ - return CHAR; - -#define RETURNNAME \ - yy_strcpy( nmstr, yytext ); \ - return NAME; - -#define PUT_BACK_STRING(str, start) \ - for ( i = yy_strlen( str ) - 1; i >= start; --i ) \ - unput((str)[i]) - -#define CHECK_REJECT(str) \ - if ( all_upper( str ) ) \ - reject = true; - -#define CHECK_YYMORE(str) \ - if ( all_lower( str ) ) \ - yymore_used = true; -%} - -%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE -%x FIRSTCCL CCL ACTION RECOVER BRACEERROR C_COMMENT ACTION_COMMENT -%x ACTION_STRING PERCENT_BRACE_ACTION USED_LIST CODEBLOCK_2 - -WS [ \t]+ -OPTWS [ \t]* -NOT_WS [^ \t\n] - -NL (\n|\r\n|\n\r) - -NAME ([a-z_][a-z_0-9-]*) -NOT_NAME [^a-z_*\n]+ - -SCNAME {NAME} - -ESCSEQ (\\([^\n]|[0-9]{1,3}|x[0-9a-f]{1,2})) - -FIRST_CCL_CHAR ([^\\\n]|{ESCSEQ}) -CCL_CHAR ([^\\\n\]]|{ESCSEQ}) - -%% - static int bracelevel, didadef, indented_code, checking_used; - - int doing_codeblock = false; - int i; - Char nmdef[MAXLINE], myesc(); - - -^{WS} indented_code = true; BEGIN(CODEBLOCK); -^"/*" ACTION_ECHO; BEGIN(C_COMMENT); -^"%s"{NAME}? return SCDECL; -^"%x"{NAME}? return XSCDECL; -^"%{".*{NL} { - ++linenum; - line_directive_out( (FILE *) 0 ); - indented_code = false; - BEGIN(CODEBLOCK); - } - -{WS} return WHITESPACE; - -^"%%".* { - sectnum = 2; - bracelevel = 0; - mark_defs1(); - line_directive_out( (FILE *) 0 ); - BEGIN(SECT2PROLOG); - return SECTEND; - } - -^"%pointer".*{NL} { - if ( lex_compat ) - warn( "%pointer incompatible with -l option" ); - else - yytext_is_array = false; - ++linenum; - } -^"%array".*{NL} { - if ( C_plus_plus ) - warn( "%array incompatible with -+ option" ); - else - yytext_is_array = true; - ++linenum; - } - -^"%used" { - warn( "%used/%unused have been deprecated" ); - checking_used = REALLY_USED; BEGIN(USED_LIST); - } -^"%unused" { - warn( "%used/%unused have been deprecated" ); - checking_used = REALLY_NOT_USED; BEGIN(USED_LIST); - } - - -^"%"[aceknopr]{OPTWS}[0-9]*{OPTWS}{NL} ++linenum; /* ignore */ - -^"%"[^sxanpekotcru{}].* synerr( "unrecognized '%' directive" ); - -^{NAME} { - yy_strcpy( nmstr, yytext ); - didadef = false; - BEGIN(PICKUPDEF); - } - -{SCNAME} RETURNNAME; -^{OPTWS}{NL} ++linenum; /* allows blank lines in section 1 */ -{OPTWS}{NL} ++linenum; return '\n'; - - -"*/" ACTION_ECHO; BEGIN(INITIAL); -"*/".*{NL} ++linenum; ACTION_ECHO; BEGIN(INITIAL); -[^*\n]+ ACTION_ECHO; -"*" ACTION_ECHO; -{NL} ++linenum; ACTION_ECHO; - - -^"%}".*{NL} ++linenum; BEGIN(INITIAL); -"reject" ACTION_ECHO; CHECK_REJECT(yytext); -"yymore" ACTION_ECHO; CHECK_YYMORE(yytext); -{NAME}|{NOT_NAME}|. ACTION_ECHO; -{NL} { - ++linenum; - ACTION_ECHO; - if ( indented_code ) - BEGIN(INITIAL); - } - - -{WS} /* separates name and definition */ - -{NOT_WS}.* { - yy_strcpy( (char *) nmdef, yytext ); - - /* Skip trailing whitespace. */ - for ( i = yy_strlen( (char *) nmdef ) - 1; - i >= 0 && (nmdef[i] == ' ' || nmdef[i] == '\t'); - --i ) - ; - - nmdef[i + 1] = '\0'; - - ndinstal( nmstr, nmdef ); - didadef = true; - } - -{NL} { - if ( ! didadef ) - synerr( "incomplete name definition" ); - BEGIN(INITIAL); - ++linenum; - } - -.*{NL} ++linenum; BEGIN(INITIAL); RETURNNAME; - - -{NL} ++linenum; BEGIN(INITIAL); -{WS} -"reject" { - if ( all_upper( yytext ) ) - reject_really_used = checking_used; - else - synerr( - "unrecognized %used/%unused construct" ); - } -"yymore" { - if ( all_lower( yytext ) ) - yymore_really_used = checking_used; - else - synerr( - "unrecognized %used/%unused construct" ); - } -{NOT_WS}+ synerr( "unrecognized %used/%unused construct" ); - - -^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */ -^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */ - -^{WS}.* ACTION_ECHO; /* indented code in prolog */ - -^{NOT_WS}.* { /* non-indented code */ - if ( bracelevel <= 0 ) - { /* not in %{ ... %} */ - yyless( 0 ); /* put it all back */ - mark_prolog(); - BEGIN(SECT2); - } - else - ACTION_ECHO; - } - -.* ACTION_ECHO; -{NL} ++linenum; ACTION_ECHO; - -<> { - mark_prolog(); - sectnum = 0; - yyterminate(); /* to stop the parser */ - } - -^{OPTWS}{NL} ++linenum; /* allow blank lines in section 2 */ - -^({WS}|"%{") { - indented_code = (yytext[0] != '%'); - doing_codeblock = true; - bracelevel = 1; - - if ( indented_code ) - ACTION_ECHO; - - BEGIN(CODEBLOCK_2); - } - -^"<" BEGIN(SC); return '<'; -^"^" return '^'; -\" BEGIN(QUOTE); return '"'; -"{"/[0-9] BEGIN(NUM); return '{'; -"{"[^0-9\n][^}\n]* BEGIN(BRACEERROR); -"$"/([ \t]|{NL}) return '$'; - -{WS}"%{" { - bracelevel = 1; - BEGIN(PERCENT_BRACE_ACTION); - return '\n'; - } -{WS}"|".*{NL} continued_action = true; ++linenum; return '\n'; - -{WS} { - /* This rule is separate from the one below because - * otherwise we get variable trailing context, so - * we can't build the scanner using -{f,F}. - */ - bracelevel = 0; - continued_action = false; - BEGIN(ACTION); - return '\n'; - } - -{OPTWS}{NL} { - bracelevel = 0; - continued_action = false; - BEGIN(ACTION); - unput( '\n' ); /* so sees it */ - return '\n'; - } - -"<>" return EOF_OP; - -^"%%".* { - sectnum = 3; - BEGIN(SECT3); - yyterminate(); /* to stop the parser */ - } - -"["{FIRST_CCL_CHAR}{CCL_CHAR}* { - int cclval; - - yy_strcpy( nmstr, yytext ); - - /* Check to see if we've already encountered this - * ccl. - */ - if ( (cclval = ccllookup( (Char *) nmstr )) ) - { - if ( input() != ']' ) - synerr( "bad character class" ); - - yylval = cclval; - ++cclreuse; - return PREVCCL; - } - else - { - /* We fudge a bit. We know that this ccl will - * soon be numbered as lastccl + 1 by cclinit. - */ - cclinstal( (Char *) nmstr, lastccl + 1 ); - - /* Push back everything but the leading bracket - * so the ccl can be rescanned. - */ - yyless( 1 ); - - BEGIN(FIRSTCCL); - return '['; - } - } - -"{"{NAME}"}" { - register Char *nmdefptr; - Char *ndlookup(); - - yy_strcpy( nmstr, yytext + 1 ); - nmstr[yyleng - 2] = '\0'; /* chop trailing brace */ - - if ( ! (nmdefptr = ndlookup( nmstr )) ) - format_synerr( "undefined definition {%s}", - nmstr ); - - else - { /* push back name surrounded by ()'s */ - int len = yy_strlen( (char *) nmdefptr ); - - if ( lex_compat || nmdefptr[0] == '^' || - (len > 0 && nmdefptr[len - 1] == '$') ) - { /* don't use ()'s after all */ - PUT_BACK_STRING((char *) nmdefptr, 0); - - if ( nmdefptr[0] == '^' ) - BEGIN(CARETISBOL); - } - - else - { - unput(')'); - PUT_BACK_STRING((char *) nmdefptr, 0); - unput('('); - } - } - } - -[/|*+?.()] return (unsigned char) yytext[0]; -. RETURNCHAR; - - -[,*] return (unsigned char) yytext[0]; -">" BEGIN(SECT2); return '>'; -">"/^ BEGIN(CARETISBOL); return '>'; -{SCNAME} RETURNNAME; -. { - format_synerr( "bad : %s", yytext ); - } - -"^" BEGIN(SECT2); return '^'; - - -[^"\n] RETURNCHAR; -\" BEGIN(SECT2); return '"'; - -{NL} { - synerr( "missing quote" ); - BEGIN(SECT2); - ++linenum; - return '"'; - } - - -"^"/[^-\]\n] BEGIN(CCL); return '^'; -"^"/("-"|"]") return '^'; -. BEGIN(CCL); RETURNCHAR; - --/[^\]\n] return '-'; -[^\]\n] RETURNCHAR; -"]" BEGIN(SECT2); return ']'; -.|{NL} { - synerr( "bad character class" ); - BEGIN(SECT2); - return ']'; - } - - -[0-9]+ { - yylval = myctoi( yytext ); - return NUMBER; - } - -"," return ','; -"}" BEGIN(SECT2); return '}'; - -. { - synerr( "bad character inside {}'s" ); - BEGIN(SECT2); - return '}'; - } - -{NL} { - synerr( "missing }" ); - BEGIN(SECT2); - ++linenum; - return '}'; - } - - -"}" synerr( "bad name in {}'s" ); BEGIN(SECT2); -{NL} synerr( "missing }" ); ++linenum; BEGIN(SECT2); - - -"/*" ACTION_ECHO; BEGIN(ACTION_COMMENT); -{OPTWS}"%}".* bracelevel = 0; -"reject" { - ACTION_ECHO; - CHECK_REJECT(yytext); - } -"yymore" { - ACTION_ECHO; - CHECK_YYMORE(yytext); - } -{NAME}|{NOT_NAME}|. ACTION_ECHO; -{NL} { - ++linenum; - ACTION_ECHO; - if ( bracelevel == 0 || - (doing_codeblock && indented_code) ) - { - if ( ! doing_codeblock ) - add_action( "\tYY_BREAK\n" ); - - doing_codeblock = false; - BEGIN(SECT2); - } - } - - - /* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */ -"{" ACTION_ECHO; ++bracelevel; -"}" ACTION_ECHO; --bracelevel; -[^a-z_{}"'/\n]+ ACTION_ECHO; -{NAME} ACTION_ECHO; -"/*" ACTION_ECHO; BEGIN(ACTION_COMMENT); -"'"([^'\\\n]|\\.)*"'" ACTION_ECHO; /* character constant */ -\" ACTION_ECHO; BEGIN(ACTION_STRING); -{NL} { - ++linenum; - ACTION_ECHO; - if ( bracelevel == 0 ) - { - add_action( "\tYY_BREAK\n" ); - BEGIN(SECT2); - } - } -. ACTION_ECHO; - -"*/" { - ACTION_ECHO; - if ( doing_codeblock ) - BEGIN(CODEBLOCK_2); - else - BEGIN(ACTION); - } - -"*" ACTION_ECHO; -[^*\n]+ ACTION_ECHO; -[^*\n]*{NL} ++linenum; ACTION_ECHO; - -[^"\\\n]+ ACTION_ECHO; -\\. ACTION_ECHO; -{NL} ++linenum; ACTION_ECHO; -\" ACTION_ECHO; BEGIN(ACTION); -. ACTION_ECHO; - -<> { - synerr( "EOF encountered inside an action" ); - yyterminate(); - } - - -{ESCSEQ} { - yylval = myesc( (Char *) yytext ); - return CHAR; - } - -{ESCSEQ} { - yylval = myesc( (Char *) yytext ); - BEGIN(CCL); - return CHAR; - } - - -.*(\n?) ECHO; -<> sectnum = 0; yyterminate(); - -<*>.|\n format_synerr( "bad character: %s", yytext ); - -%% - - -int yywrap() - { - if ( --num_input_files > 0 ) - { - set_input_file( *++input_files ); - return 0; - } - - else - return 1; - } - - -/* set_input_file - open the given file (if NULL, stdin) for scanning */ - -void set_input_file( file ) -char *file; - { - if ( file ) - { - infilename = file; - yyin = fopen( infilename, "r" ); - - if ( yyin == NULL ) - lerrsf( "can't open %s", file ); - } - - else - { - yyin = stdin; - infilename = ""; - } - } diff --git a/gnu/usr.bin/lex/sym.c b/gnu/usr.bin/lex/sym.c deleted file mode 100644 index 5672dc8036c8..000000000000 --- a/gnu/usr.bin/lex/sym.c +++ /dev/null @@ -1,262 +0,0 @@ -/* sym - symbol table routines */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * 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. - */ - -/* $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/sym.c,v 1.5 1993/12/06 19:29:33 jtc Exp $ */ - -#include "flexdef.h" - - -/* declare functions that have forward references */ - -int hashfunct PROTO((register char[], int)); - - -struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; -struct hash_entry *sctbl[START_COND_HASH_SIZE]; -struct hash_entry *ccltab[CCL_HASH_SIZE]; - -struct hash_entry *findsym(); - - -/* addsym - add symbol and definitions to symbol table - * - * -1 is returned if the symbol already exists, and the change not made. - */ - -int addsym( sym, str_def, int_def, table, table_size ) -register char sym[]; -char *str_def; -int int_def; -hash_table table; -int table_size; - { - int hash_val = hashfunct( sym, table_size ); - register struct hash_entry *sym_entry = table[hash_val]; - register struct hash_entry *new_entry; - register struct hash_entry *successor; - - while ( sym_entry ) - { - if ( ! yy_strcmp( sym, sym_entry->name ) ) - { /* entry already exists */ - return -1; - } - - sym_entry = sym_entry->next; - } - - /* create new entry */ - new_entry = (struct hash_entry *) - yy_flex_alloc( sizeof( struct hash_entry ) ); - - if ( new_entry == NULL ) - flexfatal( "symbol table memory allocation failed" ); - - if ( (successor = table[hash_val]) ) - { - new_entry->next = successor; - successor->prev = new_entry; - } - else - new_entry->next = NULL; - - new_entry->prev = NULL; - new_entry->name = sym; - new_entry->str_val = str_def; - new_entry->int_val = int_def; - - table[hash_val] = new_entry; - - return 0; - } - - -/* cclinstal - save the text of a character class */ - -void cclinstal( ccltxt, cclnum ) -Char ccltxt[]; -int cclnum; - { - /* We don't bother checking the return status because we are not - * called unless the symbol is new. - */ - Char *copy_unsigned_string(); - - (void) addsym( (char *) copy_unsigned_string( ccltxt ), - (char *) 0, cclnum, - ccltab, CCL_HASH_SIZE ); - } - - -/* ccllookup - lookup the number associated with character class text - * - * Returns 0 if there's no CCL associated with the text. - */ - -int ccllookup( ccltxt ) -Char ccltxt[]; - { - return findsym( (char *) ccltxt, ccltab, CCL_HASH_SIZE )->int_val; - } - - -/* findsym - find symbol in symbol table */ - -struct hash_entry *findsym( sym, table, table_size ) -register char sym[]; -hash_table table; -int table_size; - { - static struct hash_entry empty_entry = - { - (struct hash_entry *) 0, (struct hash_entry *) 0, - (char *) 0, (char *) 0, 0, - } ; - register struct hash_entry *sym_entry = - table[hashfunct( sym, table_size )]; - - while ( sym_entry ) - { - if ( ! yy_strcmp( sym, sym_entry->name ) ) - return sym_entry; - sym_entry = sym_entry->next; - } - - return &empty_entry; - } - - -/* hashfunct - compute the hash value for "str" and hash size "hash_size" */ - -int hashfunct( str, hash_size ) -register char str[]; -int hash_size; - { - register int hashval; - register int locstr; - - hashval = 0; - locstr = 0; - - while ( str[locstr] ) - { - hashval = (hashval << 1) + (unsigned char) str[locstr++]; - hashval %= hash_size; - } - - return hashval; - } - - -/* ndinstal - install a name definition */ - -void ndinstal( name, definition ) -char name[]; -Char definition[]; - { - char *copy_string(); - Char *copy_unsigned_string(); - - if ( addsym( copy_string( name ), - (char *) copy_unsigned_string( definition ), 0, - ndtbl, NAME_TABLE_HASH_SIZE ) ) - synerr( "name defined twice" ); - } - - -/* ndlookup - lookup a name definition - * - * Returns a nil pointer if the name definition does not exist. - */ - -Char *ndlookup( nd ) -char nd[]; - { - return (Char *) findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE )->str_val; - } - - -/* scextend - increase the maximum number of start conditions */ - -void scextend() - { - current_max_scs += MAX_SCS_INCREMENT; - - ++num_reallocs; - - scset = reallocate_integer_array( scset, current_max_scs ); - scbol = reallocate_integer_array( scbol, current_max_scs ); - scxclu = reallocate_integer_array( scxclu, current_max_scs ); - sceof = reallocate_integer_array( sceof, current_max_scs ); - scname = reallocate_char_ptr_array( scname, current_max_scs ); - actvsc = reallocate_integer_array( actvsc, current_max_scs ); - } - - -/* scinstal - make a start condition - * - * NOTE - * The start condition is "exclusive" if xcluflg is true. - */ - -void scinstal( str, xcluflg ) -char str[]; -int xcluflg; - { - char *copy_string(); - - /* Generate start condition definition, for use in BEGIN et al. */ - printf( "#define %s %d\n", str, lastsc ); - - if ( ++lastsc >= current_max_scs ) - scextend(); - - scname[lastsc] = copy_string( str ); - - if ( addsym( scname[lastsc], (char *) 0, lastsc, - sctbl, START_COND_HASH_SIZE ) ) - format_pinpoint_message( "start condition %s declared twice", - str ); - - scset[lastsc] = mkstate( SYM_EPSILON ); - scbol[lastsc] = mkstate( SYM_EPSILON ); - scxclu[lastsc] = xcluflg; - sceof[lastsc] = false; - } - - -/* sclookup - lookup the number associated with a start condition - * - * Returns 0 if no such start condition. - */ - -int sclookup( str ) -char str[]; - { - return findsym( str, sctbl, START_COND_HASH_SIZE )->int_val; - } diff --git a/gnu/usr.bin/lex/tblcmp.c b/gnu/usr.bin/lex/tblcmp.c deleted file mode 100644 index ccc737c0c619..000000000000 --- a/gnu/usr.bin/lex/tblcmp.c +++ /dev/null @@ -1,888 +0,0 @@ -/* tblcmp - table compression routines */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * 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. - */ - -/* $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/tblcmp.c,v 1.6 1993/12/09 19:06:29 jtc Exp $ */ - -#include "flexdef.h" - - -/* declarations for functions that have forward references */ - -void mkentry PROTO((register int*, int, int, int, int)); -void mkprot PROTO((int[], int, int)); -void mktemplate PROTO((int[], int, int)); -void mv2front PROTO((int)); -int tbldiff PROTO((int[], int, int[])); - - -/* bldtbl - build table entries for dfa state - * - * synopsis - * int state[numecs], statenum, totaltrans, comstate, comfreq; - * bldtbl( state, statenum, totaltrans, comstate, comfreq ); - * - * State is the statenum'th dfa state. It is indexed by equivalence class and - * gives the number of the state to enter for a given equivalence class. - * totaltrans is the total number of transitions out of the state. Comstate - * is that state which is the destination of the most transitions out of State. - * Comfreq is how many transitions there are out of State to Comstate. - * - * A note on terminology: - * "protos" are transition tables which have a high probability of - * either being redundant (a state processed later will have an identical - * transition table) or nearly redundant (a state processed later will have - * many of the same out-transitions). A "most recently used" queue of - * protos is kept around with the hope that most states will find a proto - * which is similar enough to be usable, and therefore compacting the - * output tables. - * "templates" are a special type of proto. If a transition table is - * homogeneous or nearly homogeneous (all transitions go to the same - * destination) then the odds are good that future states will also go - * to the same destination state on basically the same character set. - * These homogeneous states are so common when dealing with large rule - * sets that they merit special attention. If the transition table were - * simply made into a proto, then (typically) each subsequent, similar - * state will differ from the proto for two out-transitions. One of these - * out-transitions will be that character on which the proto does not go - * to the common destination, and one will be that character on which the - * state does not go to the common destination. Templates, on the other - * hand, go to the common state on EVERY transition character, and therefore - * cost only one difference. - */ - -void bldtbl( state, statenum, totaltrans, comstate, comfreq ) -int state[], statenum, totaltrans, comstate, comfreq; - { - int extptr, extrct[2][CSIZE + 1]; - int mindiff, minprot, i, d; - - /* If extptr is 0 then the first array of extrct holds the result - * of the "best difference" to date, which is those transitions - * which occur in "state" but not in the proto which, to date, - * has the fewest differences between itself and "state". If - * extptr is 1 then the second array of extrct hold the best - * difference. The two arrays are toggled between so that the - * best difference to date can be kept around and also a difference - * just created by checking against a candidate "best" proto. - */ - - extptr = 0; - - /* If the state has too few out-transitions, don't bother trying to - * compact its tables. - */ - - if ( (totaltrans * 100) < (numecs * PROTO_SIZE_PERCENTAGE) ) - mkentry( state, numecs, statenum, JAMSTATE, totaltrans ); - - else - { - /* "checkcom" is true if we should only check "state" against - * protos which have the same "comstate" value. - */ - int checkcom = - comfreq * 100 > totaltrans * CHECK_COM_PERCENTAGE; - - minprot = firstprot; - mindiff = totaltrans; - - if ( checkcom ) - { - /* Find first proto which has the same "comstate". */ - for ( i = firstprot; i != NIL; i = protnext[i] ) - if ( protcomst[i] == comstate ) - { - minprot = i; - mindiff = tbldiff( state, minprot, - extrct[extptr] ); - break; - } - } - - else - { - /* Since we've decided that the most common destination - * out of "state" does not occur with a high enough - * frequency, we set the "comstate" to zero, assuring - * that if this state is entered into the proto list, - * it will not be considered a template. - */ - comstate = 0; - - if ( firstprot != NIL ) - { - minprot = firstprot; - mindiff = tbldiff( state, minprot, - extrct[extptr] ); - } - } - - /* We now have the first interesting proto in "minprot". If - * it matches within the tolerances set for the first proto, - * we don't want to bother scanning the rest of the proto list - * to see if we have any other reasonable matches. - */ - - if ( mindiff * 100 > totaltrans * FIRST_MATCH_DIFF_PERCENTAGE ) - { - /* Not a good enough match. Scan the rest of the - * protos. - */ - for ( i = minprot; i != NIL; i = protnext[i] ) - { - d = tbldiff( state, i, extrct[1 - extptr] ); - if ( d < mindiff ) - { - extptr = 1 - extptr; - mindiff = d; - minprot = i; - } - } - } - - /* Check if the proto we've decided on as our best bet is close - * enough to the state we want to match to be usable. - */ - - if ( mindiff * 100 > totaltrans * ACCEPTABLE_DIFF_PERCENTAGE ) - { - /* No good. If the state is homogeneous enough, - * we make a template out of it. Otherwise, we - * make a proto. - */ - - if ( comfreq * 100 >= - totaltrans * TEMPLATE_SAME_PERCENTAGE ) - mktemplate( state, statenum, comstate ); - - else - { - mkprot( state, statenum, comstate ); - mkentry( state, numecs, statenum, - JAMSTATE, totaltrans ); - } - } - - else - { /* use the proto */ - mkentry( extrct[extptr], numecs, statenum, - prottbl[minprot], mindiff ); - - /* If this state was sufficiently different from the - * proto we built it from, make it, too, a proto. - */ - - if ( mindiff * 100 >= - totaltrans * NEW_PROTO_DIFF_PERCENTAGE ) - mkprot( state, statenum, comstate ); - - /* Since mkprot added a new proto to the proto queue, - * it's possible that "minprot" is no longer on the - * proto queue (if it happened to have been the last - * entry, it would have been bumped off). If it's - * not there, then the new proto took its physical - * place (though logically the new proto is at the - * beginning of the queue), so in that case the - * following call will do nothing. - */ - - mv2front( minprot ); - } - } - } - - -/* cmptmps - compress template table entries - * - * Template tables are compressed by using the 'template equivalence - * classes', which are collections of transition character equivalence - * classes which always appear together in templates - really meta-equivalence - * classes. - */ - -void cmptmps() - { - int tmpstorage[CSIZE + 1]; - register int *tmp = tmpstorage, i, j; - int totaltrans, trans; - - peakpairs = numtemps * numecs + tblend; - - if ( usemecs ) - { - /* Create equivalence classes based on data gathered on - * template transitions. - */ - nummecs = cre8ecs( tecfwd, tecbck, numecs ); - } - - else - nummecs = numecs; - - while ( lastdfa + numtemps + 1 >= current_max_dfas ) - increase_max_dfas(); - - /* Loop through each template. */ - - for ( i = 1; i <= numtemps; ++i ) - { - /* Number of non-jam transitions out of this template. */ - totaltrans = 0; - - for ( j = 1; j <= numecs; ++j ) - { - trans = tnxt[numecs * i + j]; - - if ( usemecs ) - { - /* The absolute value of tecbck is the - * meta-equivalence class of a given - * equivalence class, as set up by cre8ecs(). - */ - if ( tecbck[j] > 0 ) - { - tmp[tecbck[j]] = trans; - - if ( trans > 0 ) - ++totaltrans; - } - } - - else - { - tmp[j] = trans; - - if ( trans > 0 ) - ++totaltrans; - } - } - - /* It is assumed (in a rather subtle way) in the skeleton - * that if we're using meta-equivalence classes, the def[] - * entry for all templates is the jam template, i.e., - * templates never default to other non-jam table entries - * (e.g., another template) - */ - - /* Leave room for the jam-state after the last real state. */ - mkentry( tmp, nummecs, lastdfa + i + 1, JAMSTATE, totaltrans ); - } - } - - - -/* expand_nxt_chk - expand the next check arrays */ - -void expand_nxt_chk() - { - register int old_max = current_max_xpairs; - - current_max_xpairs += MAX_XPAIRS_INCREMENT; - - ++num_reallocs; - - nxt = reallocate_integer_array( nxt, current_max_xpairs ); - chk = reallocate_integer_array( chk, current_max_xpairs ); - - zero_out( (char *) (chk + old_max), - MAX_XPAIRS_INCREMENT * sizeof( int ) / sizeof( char ) ); - } - - -/* find_table_space - finds a space in the table for a state to be placed - * - * synopsis - * int *state, numtrans, block_start; - * int find_table_space(); - * - * block_start = find_table_space( state, numtrans ); - * - * State is the state to be added to the full speed transition table. - * Numtrans is the number of out-transitions for the state. - * - * find_table_space() returns the position of the start of the first block (in - * chk) able to accommodate the state - * - * In determining if a state will or will not fit, find_table_space() must take - * into account the fact that an end-of-buffer state will be added at [0], - * and an action number will be added in [-1]. - */ - -int find_table_space( state, numtrans ) -int *state, numtrans; - { - /* Firstfree is the position of the first possible occurrence of two - * consecutive unused records in the chk and nxt arrays. - */ - register int i; - register int *state_ptr, *chk_ptr; - register int *ptr_to_last_entry_in_state; - - /* If there are too many out-transitions, put the state at the end of - * nxt and chk. - */ - if ( numtrans > MAX_XTIONS_FULL_INTERIOR_FIT ) - { - /* If table is empty, return the first available spot in - * chk/nxt, which should be 1. - */ - if ( tblend < 2 ) - return 1; - - /* Start searching for table space near the end of - * chk/nxt arrays. - */ - i = tblend - numecs; - } - - else - /* Start searching for table space from the beginning - * (skipping only the elements which will definitely not - * hold the new state). - */ - i = firstfree; - - while ( 1 ) /* loops until a space is found */ - { - while ( i + numecs >= current_max_xpairs ) - expand_nxt_chk(); - - /* Loops until space for end-of-buffer and action number - * are found. - */ - while ( 1 ) - { - /* Check for action number space. */ - if ( chk[i - 1] == 0 ) - { - /* Check for end-of-buffer space. */ - if ( chk[i] == 0 ) - break; - - else - /* Since i != 0, there is no use - * checking to see if (++i) - 1 == 0, - * because that's the same as i == 0, - * so we skip a space. - */ - i += 2; - } - - else - ++i; - - while ( i + numecs >= current_max_xpairs ) - expand_nxt_chk(); - } - - /* If we started search from the beginning, store the new - * firstfree for the next call of find_table_space(). - */ - if ( numtrans <= MAX_XTIONS_FULL_INTERIOR_FIT ) - firstfree = i + 1; - - /* Check to see if all elements in chk (and therefore nxt) - * that are needed for the new state have not yet been taken. - */ - - state_ptr = &state[1]; - ptr_to_last_entry_in_state = &chk[i + numecs + 1]; - - for ( chk_ptr = &chk[i + 1]; - chk_ptr != ptr_to_last_entry_in_state; ++chk_ptr ) - if ( *(state_ptr++) != 0 && *chk_ptr != 0 ) - break; - - if ( chk_ptr == ptr_to_last_entry_in_state ) - return i; - - else - ++i; - } - } - - -/* inittbl - initialize transition tables - * - * Initializes "firstfree" to be one beyond the end of the table. Initializes - * all "chk" entries to be zero. - */ -void inittbl() - { - register int i; - - zero_out( (char *) chk, - current_max_xpairs * sizeof( int ) / sizeof( char ) ); - - tblend = 0; - firstfree = tblend + 1; - numtemps = 0; - - if ( usemecs ) - { - /* Set up doubly-linked meta-equivalence classes; these - * are sets of equivalence classes which all have identical - * transitions out of TEMPLATES. - */ - - tecbck[1] = NIL; - - for ( i = 2; i <= numecs; ++i ) - { - tecbck[i] = i - 1; - tecfwd[i - 1] = i; - } - - tecfwd[numecs] = NIL; - } - } - - -/* mkdeftbl - make the default, "jam" table entries */ - -void mkdeftbl() - { - int i; - - jamstate = lastdfa + 1; - - ++tblend; /* room for transition on end-of-buffer character */ - - while ( tblend + numecs >= current_max_xpairs ) - expand_nxt_chk(); - - /* Add in default end-of-buffer transition. */ - nxt[tblend] = end_of_buffer_state; - chk[tblend] = jamstate; - - for ( i = 1; i <= numecs; ++i ) - { - nxt[tblend + i] = 0; - chk[tblend + i] = jamstate; - } - - jambase = tblend; - - base[jamstate] = jambase; - def[jamstate] = 0; - - tblend += numecs; - ++numtemps; - } - - -/* mkentry - create base/def and nxt/chk entries for transition array - * - * synopsis - * int state[numchars + 1], numchars, statenum, deflink, totaltrans; - * mkentry( state, numchars, statenum, deflink, totaltrans ); - * - * "state" is a transition array "numchars" characters in size, "statenum" - * is the offset to be used into the base/def tables, and "deflink" is the - * entry to put in the "def" table entry. If "deflink" is equal to - * "JAMSTATE", then no attempt will be made to fit zero entries of "state" - * (i.e., jam entries) into the table. It is assumed that by linking to - * "JAMSTATE" they will be taken care of. In any case, entries in "state" - * marking transitions to "SAME_TRANS" are treated as though they will be - * taken care of by whereever "deflink" points. "totaltrans" is the total - * number of transitions out of the state. If it is below a certain threshold, - * the tables are searched for an interior spot that will accommodate the - * state array. - */ - -void mkentry( state, numchars, statenum, deflink, totaltrans ) -register int *state; -int numchars, statenum, deflink, totaltrans; - { - register int minec, maxec, i, baseaddr; - int tblbase, tbllast; - - if ( totaltrans == 0 ) - { /* there are no out-transitions */ - if ( deflink == JAMSTATE ) - base[statenum] = JAMSTATE; - else - base[statenum] = 0; - - def[statenum] = deflink; - return; - } - - for ( minec = 1; minec <= numchars; ++minec ) - { - if ( state[minec] != SAME_TRANS ) - if ( state[minec] != 0 || deflink != JAMSTATE ) - break; - } - - if ( totaltrans == 1 ) - { - /* There's only one out-transition. Save it for later to fill - * in holes in the tables. - */ - stack1( statenum, minec, state[minec], deflink ); - return; - } - - for ( maxec = numchars; maxec > 0; --maxec ) - { - if ( state[maxec] != SAME_TRANS ) - if ( state[maxec] != 0 || deflink != JAMSTATE ) - break; - } - - /* Whether we try to fit the state table in the middle of the table - * entries we have already generated, or if we just take the state - * table at the end of the nxt/chk tables, we must make sure that we - * have a valid base address (i.e., non-negative). Note that - * negative base addresses dangerous at run-time (because indexing - * the nxt array with one and a low-valued character will access - * memory before the start of the array. - */ - - /* Find the first transition of state that we need to worry about. */ - if ( totaltrans * 100 <= numchars * INTERIOR_FIT_PERCENTAGE ) - { - /* Attempt to squeeze it into the middle of the tables. */ - baseaddr = firstfree; - - while ( baseaddr < minec ) - { - /* Using baseaddr would result in a negative base - * address below; find the next free slot. - */ - for ( ++baseaddr; chk[baseaddr] != 0; ++baseaddr ) - ; - } - - while ( baseaddr + maxec - minec + 1 >= current_max_xpairs ) - expand_nxt_chk(); - - for ( i = minec; i <= maxec; ++i ) - if ( state[i] != SAME_TRANS && - (state[i] != 0 || deflink != JAMSTATE) && - chk[baseaddr + i - minec] != 0 ) - { /* baseaddr unsuitable - find another */ - for ( ++baseaddr; - baseaddr < current_max_xpairs && - chk[baseaddr] != 0; ++baseaddr ) - ; - - while ( baseaddr + maxec - minec + 1 >= - current_max_xpairs ) - expand_nxt_chk(); - - /* Reset the loop counter so we'll start all - * over again next time it's incremented. - */ - - i = minec - 1; - } - } - - else - { - /* Ensure that the base address we eventually generate is - * non-negative. - */ - baseaddr = MAX( tblend + 1, minec ); - } - - tblbase = baseaddr - minec; - tbllast = tblbase + maxec; - - while ( tbllast + 1 >= current_max_xpairs ) - expand_nxt_chk(); - - base[statenum] = tblbase; - def[statenum] = deflink; - - for ( i = minec; i <= maxec; ++i ) - if ( state[i] != SAME_TRANS ) - if ( state[i] != 0 || deflink != JAMSTATE ) - { - nxt[tblbase + i] = state[i]; - chk[tblbase + i] = statenum; - } - - if ( baseaddr == firstfree ) - /* Find next free slot in tables. */ - for ( ++firstfree; chk[firstfree] != 0; ++firstfree ) - ; - - tblend = MAX( tblend, tbllast ); - } - - -/* mk1tbl - create table entries for a state (or state fragment) which - * has only one out-transition - */ - -void mk1tbl( state, sym, onenxt, onedef ) -int state, sym, onenxt, onedef; - { - if ( firstfree < sym ) - firstfree = sym; - - while ( chk[firstfree] != 0 ) - if ( ++firstfree >= current_max_xpairs ) - expand_nxt_chk(); - - base[state] = firstfree - sym; - def[state] = onedef; - chk[firstfree] = state; - nxt[firstfree] = onenxt; - - if ( firstfree > tblend ) - { - tblend = firstfree++; - - if ( firstfree >= current_max_xpairs ) - expand_nxt_chk(); - } - } - - -/* mkprot - create new proto entry */ - -void mkprot( state, statenum, comstate ) -int state[], statenum, comstate; - { - int i, slot, tblbase; - - if ( ++numprots >= MSP || numecs * numprots >= PROT_SAVE_SIZE ) - { - /* Gotta make room for the new proto by dropping last entry in - * the queue. - */ - slot = lastprot; - lastprot = protprev[lastprot]; - protnext[lastprot] = NIL; - } - - else - slot = numprots; - - protnext[slot] = firstprot; - - if ( firstprot != NIL ) - protprev[firstprot] = slot; - - firstprot = slot; - prottbl[slot] = statenum; - protcomst[slot] = comstate; - - /* Copy state into save area so it can be compared with rapidly. */ - tblbase = numecs * (slot - 1); - - for ( i = 1; i <= numecs; ++i ) - protsave[tblbase + i] = state[i]; - } - - -/* mktemplate - create a template entry based on a state, and connect the state - * to it - */ - -void mktemplate( state, statenum, comstate ) -int state[], statenum, comstate; - { - int i, numdiff, tmpbase, tmp[CSIZE + 1]; - Char transset[CSIZE + 1]; - int tsptr; - - ++numtemps; - - tsptr = 0; - - /* Calculate where we will temporarily store the transition table - * of the template in the tnxt[] array. The final transition table - * gets created by cmptmps(). - */ - - tmpbase = numtemps * numecs; - - if ( tmpbase + numecs >= current_max_template_xpairs ) - { - current_max_template_xpairs += MAX_TEMPLATE_XPAIRS_INCREMENT; - - ++num_reallocs; - - tnxt = reallocate_integer_array( tnxt, - current_max_template_xpairs ); - } - - for ( i = 1; i <= numecs; ++i ) - if ( state[i] == 0 ) - tnxt[tmpbase + i] = 0; - else - { - transset[tsptr++] = i; - tnxt[tmpbase + i] = comstate; - } - - if ( usemecs ) - mkeccl( transset, tsptr, tecfwd, tecbck, numecs, 0 ); - - mkprot( tnxt + tmpbase, -numtemps, comstate ); - - /* We rely on the fact that mkprot adds things to the beginning - * of the proto queue. - */ - - numdiff = tbldiff( state, firstprot, tmp ); - mkentry( tmp, numecs, statenum, -numtemps, numdiff ); - } - - -/* mv2front - move proto queue element to front of queue */ - -void mv2front( qelm ) -int qelm; - { - if ( firstprot != qelm ) - { - if ( qelm == lastprot ) - lastprot = protprev[lastprot]; - - protnext[protprev[qelm]] = protnext[qelm]; - - if ( protnext[qelm] != NIL ) - protprev[protnext[qelm]] = protprev[qelm]; - - protprev[qelm] = NIL; - protnext[qelm] = firstprot; - protprev[firstprot] = qelm; - firstprot = qelm; - } - } - - -/* place_state - place a state into full speed transition table - * - * State is the statenum'th state. It is indexed by equivalence class and - * gives the number of the state to enter for a given equivalence class. - * Transnum is the number of out-transitions for the state. - */ - -void place_state( state, statenum, transnum ) -int *state, statenum, transnum; - { - register int i; - register int *state_ptr; - int position = find_table_space( state, transnum ); - - /* "base" is the table of start positions. */ - base[statenum] = position; - - /* Put in action number marker; this non-zero number makes sure that - * find_table_space() knows that this position in chk/nxt is taken - * and should not be used for another accepting number in another - * state. - */ - chk[position - 1] = 1; - - /* Put in end-of-buffer marker; this is for the same purposes as - * above. - */ - chk[position] = 1; - - /* Place the state into chk and nxt. */ - state_ptr = &state[1]; - - for ( i = 1; i <= numecs; ++i, ++state_ptr ) - if ( *state_ptr != 0 ) - { - chk[position + i] = i; - nxt[position + i] = *state_ptr; - } - - if ( position + numecs > tblend ) - tblend = position + numecs; - } - - -/* stack1 - save states with only one out-transition to be processed later - * - * If there's room for another state on the "one-transition" stack, the - * state is pushed onto it, to be processed later by mk1tbl. If there's - * no room, we process the sucker right now. - */ - -void stack1( statenum, sym, nextstate, deflink ) -int statenum, sym, nextstate, deflink; - { - if ( onesp >= ONE_STACK_SIZE - 1 ) - mk1tbl( statenum, sym, nextstate, deflink ); - - else - { - ++onesp; - onestate[onesp] = statenum; - onesym[onesp] = sym; - onenext[onesp] = nextstate; - onedef[onesp] = deflink; - } - } - - -/* tbldiff - compute differences between two state tables - * - * "state" is the state array which is to be extracted from the pr'th - * proto. "pr" is both the number of the proto we are extracting from - * and an index into the save area where we can find the proto's complete - * state table. Each entry in "state" which differs from the corresponding - * entry of "pr" will appear in "ext". - * - * Entries which are the same in both "state" and "pr" will be marked - * as transitions to "SAME_TRANS" in "ext". The total number of differences - * between "state" and "pr" is returned as function value. Note that this - * number is "numecs" minus the number of "SAME_TRANS" entries in "ext". - */ - -int tbldiff( state, pr, ext ) -int state[], pr, ext[]; - { - register int i, *sp = state, *ep = ext, *protp; - register int numdiff = 0; - - protp = &protsave[numecs * (pr - 1)]; - - for ( i = numecs; i > 0; --i ) - { - if ( *++protp == *++sp ) - *++ep = SAME_TRANS; - else - { - *++ep = *sp; - ++numdiff; - } - } - - return numdiff; - } diff --git a/gnu/usr.bin/lex/version.h b/gnu/usr.bin/lex/version.h deleted file mode 100644 index 6bf4ca0f14ca..000000000000 --- a/gnu/usr.bin/lex/version.h +++ /dev/null @@ -1 +0,0 @@ -#define FLEX_VERSION "2.4.4" diff --git a/gnu/usr.bin/lex/yylex.c b/gnu/usr.bin/lex/yylex.c deleted file mode 100644 index 1b8ba6c59d33..000000000000 --- a/gnu/usr.bin/lex/yylex.c +++ /dev/null @@ -1,199 +0,0 @@ -/* yylex - scanner front-end for flex */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Vern Paxson. - * - * The United States Government has rights in this work pursuant - * to contract no. DE-AC03-76SF00098 between the United States - * Department of Energy and the University of California. - * - * 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. - */ - -/* $Header: /cvsroot/src/gnu/usr.bin/lex/Attic/yylex.c,v 1.5 1993/12/06 19:29:38 jtc Exp $ */ - -#include -#include "flexdef.h" -#include "parse.h" - - -/* yylex - scan for a regular expression token */ - -int yylex() - { - int toktype; - static int beglin = false; - - if ( eofseen ) - toktype = EOF; - else - toktype = flexscan(); - - if ( toktype == EOF || toktype == 0 ) - { - eofseen = 1; - - if ( sectnum == 1 ) - { - synerr( "premature EOF" ); - sectnum = 2; - toktype = SECTEND; - } - - else - toktype = 0; - } - - if ( trace ) - { - if ( beglin ) - { - fprintf( stderr, "%d\t", num_rules + 1 ); - beglin = 0; - } - - switch ( toktype ) - { - case '<': - case '>': - case '^': - case '$': - case '"': - case '[': - case ']': - case '{': - case '}': - case '|': - case '(': - case ')': - case '-': - case '/': - case '\\': - case '?': - case '.': - case '*': - case '+': - case ',': - (void) putc( toktype, stderr ); - break; - - case '\n': - (void) putc( '\n', stderr ); - - if ( sectnum == 2 ) - beglin = 1; - - break; - - case SCDECL: - fputs( "%s", stderr ); - break; - - case XSCDECL: - fputs( "%x", stderr ); - break; - - case WHITESPACE: - (void) putc( ' ', stderr ); - break; - - case SECTEND: - fputs( "%%\n", stderr ); - - /* We set beglin to be true so we'll start - * writing out numbers as we echo rules. - * flexscan() has already assigned sectnum. - */ - - if ( sectnum == 2 ) - beglin = 1; - - break; - - case NAME: - fprintf( stderr, "'%s'", nmstr ); - break; - - case CHAR: - switch ( yylval ) - { - case '<': - case '>': - case '^': - case '$': - case '"': - case '[': - case ']': - case '{': - case '}': - case '|': - case '(': - case ')': - case '-': - case '/': - case '\\': - case '?': - case '.': - case '*': - case '+': - case ',': - fprintf( stderr, "\\%c", - yylval ); - break; - - default: - if ( ! isascii( yylval ) || - ! isprint( yylval ) ) - fprintf( stderr, - "\\%.3o", - (unsigned int) yylval ); - else - (void) putc( yylval, - stderr ); - break; - } - - break; - - case NUMBER: - fprintf( stderr, "%d", yylval ); - break; - - case PREVCCL: - fprintf( stderr, "[%d]", yylval ); - break; - - case EOF_OP: - fprintf( stderr, "<>" ); - break; - - case 0: - fprintf( stderr, "End Marker" ); - break; - - default: - fprintf( stderr, - "*Something Weird* - tok: %d val: %d\n", - toktype, yylval ); - break; - } - } - - return toktype; - } diff --git a/gnu/usr.bin/tar-1.11.2/create.c b/gnu/usr.bin/tar-1.11.2/create.c deleted file mode 100644 index 62b9c51178f4..000000000000 --- a/gnu/usr.bin/tar-1.11.2/create.c +++ /dev/null @@ -1,1454 +0,0 @@ -/* Create a tar archive. - Copyright (C) 1985, 1992, 1993 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Create a tar archive. - * - * Written 25 Aug 1985 by John Gilmore, ihnp4!hoptoad!gnu. - */ - -#ifdef _AIX - #pragma alloca -#endif -#include -#include -#include -#ifndef STDC_HEADERS -extern int errno; -#endif - -#ifdef BSD42 -#include -#else -#ifndef V7 -#include -#endif -#endif - -#include "tar.h" -#include "port.h" - -#ifndef __MSDOS__ -#include -#include -#endif - -#if defined (_POSIX_VERSION) -#include -#else -struct utimbuf -{ - long actime; - long modtime; -}; - -#endif - -extern struct stat hstat; /* Stat struct corresponding */ - -#ifndef __MSDOS__ -extern dev_t ar_dev; -extern ino_t ar_ino; -#endif - -/* JF */ -extern struct name *gnu_list_name; - -/* - * If there are no symbolic links, there is no lstat(). Use stat(). - */ -#ifndef S_ISLNK -#define lstat stat -#endif - -extern void print_header (); - -union record *start_header (); -void blank_name_list (); -int check_exclude (); -PTR ck_malloc (); -PTR ck_realloc (); -void clear_buffer (); -void close_archive (); -void collect_and_sort_names (); -int confirm (); -int deal_with_sparse (); -void find_new_file_size (); -void finish_header (); -int finish_sparse_file (); -void finduname (); -void findgname (); -int is_dot_or_dotdot (); -void open_archive (); -char *name_next (); -void name_close (); -void to_oct (); -void dump_file (); -void write_dir_file (); -void write_eot (); -void write_long (); -int zero_record (); - -/* This code moved from tar.h since create.c is the only file that cares - about 'struct link's. This means that other files might not have to - include sys/types.h any more. */ - -struct link - { - struct link *next; - dev_t dev; - ino_t ino; - short linkcount; - char name[1]; - }; - -struct link *linklist; /* Points to first link in list */ - -static nolinks; /* Gets set if we run out of RAM */ - -/* - * "Scratch" space to store the information about a sparse file before - * writing the info into the header or extended header - */ -/* struct sp_array *sparsearray;*/ - -/* number of elts storable in the sparsearray */ -/*int sparse_array_size = 10;*/ - -void -create_archive () -{ - register char *p; - char *name_from_list (); - - open_archive (0); /* Open for writing */ - - if (f_gnudump) - { - char *buf = ck_malloc (PATH_MAX); - char *q, *bufp; - - collect_and_sort_names (); - - while (p = name_from_list ()) - dump_file (p, -1, 1); - /* if(!f_dironly) { */ - blank_name_list (); - while (p = name_from_list ()) - { - strcpy (buf, p); - if (p[strlen (p) - 1] != '/') - strcat (buf, "/"); - bufp = buf + strlen (buf); - for (q = gnu_list_name->dir_contents; q && *q; q += strlen (q) + 1) - { - if (*q == 'Y') - { - strcpy (bufp, q + 1); - dump_file (buf, -1, 1); - } - } - } - /* } */ - free (buf); - } - else - { - while (p = name_next (1)) - dump_file (p, -1, 1); - } - - write_eot (); - close_archive (); - if (f_gnudump) - write_dir_file (); - name_close (); -} - -/* - * Dump a single file. If it's a directory, recurse. - * Result is 1 for success, 0 for failure. - * Sets global "hstat" to stat() output for this file. - */ -void -dump_file (p, curdev, toplevel) - char *p; /* File name to dump */ - int curdev; /* Device our parent dir was on */ - int toplevel; /* Whether we are a toplevel call */ -{ - union record *header; - char type; - extern char *save_name; /* JF for multi-volume support */ - extern long save_totsize; - extern long save_sizeleft; - union record *exhdr; - char save_linkflag; - extern time_t new_time; - int critical_error = 0; - struct utimbuf restore_times; - /* int sparse_ind = 0;*/ - - - if (f_confirm && !confirm ("add", p)) - return; - - /* - * Use stat if following (rather than dumping) 4.2BSD's - * symbolic links. Otherwise, use lstat (which, on non-4.2 - * systems, is #define'd to stat anyway. - */ -#ifdef STX_HIDDEN /* AIX */ - if (0 != f_follow_links ? - statx (p, &hstat, STATSIZE, STX_HIDDEN) : - statx (p, &hstat, STATSIZE, STX_HIDDEN | STX_LINK)) -#else - if (0 != f_follow_links ? stat (p, &hstat) : lstat (p, &hstat)) -#endif - { - badperror: - msg_perror ("can't add file %s", p); - badfile: - if (!f_ignore_failed_read || critical_error) - errors++; - return; - } - - restore_times.actime = hstat.st_atime; - restore_times.modtime = hstat.st_mtime; - -#ifdef S_ISHIDDEN - if (S_ISHIDDEN (hstat.st_mode)) - { - char *new = (char *) alloca (strlen (p) + 2); - if (new) - { - strcpy (new, p); - strcat (new, "@"); - p = new; - } - } -#endif - - /* See if we only want new files, and check if this one is too old to - put in the archive. */ - if (f_new_files - && !f_gnudump - && new_time > hstat.st_mtime - && !S_ISDIR (hstat.st_mode) - && (f_new_files > 1 || new_time > hstat.st_ctime)) - { - if (curdev == -1) - { - msg ("%s: is unchanged; not dumped", p); - } - return; - } - -#ifndef __MSDOS__ - /* See if we are trying to dump the archive */ - if (ar_dev && hstat.st_dev == ar_dev && hstat.st_ino == ar_ino) - { - msg ("%s is the archive; not dumped", p); - return; - } -#endif - /* - * Check for multiple links. - * - * We maintain a list of all such files that we've written so - * far. Any time we see another, we check the list and - * avoid dumping the data again if we've done it once already. - */ - if (hstat.st_nlink > 1 - && (S_ISREG (hstat.st_mode) -#ifdef S_ISCTG - || S_ISCTG (hstat.st_mode) -#endif -#ifdef S_ISCHR - || S_ISCHR (hstat.st_mode) -#endif -#ifdef S_ISBLK - || S_ISBLK (hstat.st_mode) -#endif -#ifdef S_ISFIFO - || S_ISFIFO (hstat.st_mode) -#endif - )) - { - register struct link *lp; - - /* First quick and dirty. Hashing, etc later FIXME */ - for (lp = linklist; lp; lp = lp->next) - { - if (lp->ino == hstat.st_ino && - lp->dev == hstat.st_dev) - { - char *link_name = lp->name; - - /* We found a link. */ - while (!f_absolute_paths && *link_name == '/') - { - static int link_warn = 0; - - if (!link_warn) - { - msg ("Removing leading / from absolute links"); - link_warn++; - } - link_name++; - } - if (link_name - lp->name >= NAMSIZ) - write_long (link_name, LF_LONGLINK); - current_link_name = link_name; - - hstat.st_size = 0; - header = start_header (p, &hstat); - if (header == NULL) - { - critical_error = 1; - goto badfile; - } - strncpy (header->header.arch_linkname, - link_name, NAMSIZ); - - /* Force null truncated */ - header->header.arch_linkname[NAMSIZ - 1] = 0; - - header->header.linkflag = LF_LINK; - finish_header (header); - /* FIXME: Maybe remove from list after all links found? */ - if (f_remove_files) - { - if (unlink (p) == -1) - msg_perror ("cannot remove %s", p); - } - return; /* We dumped it */ - } - } - - /* Not found. Add it to the list of possible links. */ - lp = (struct link *) ck_malloc ((unsigned) (sizeof (struct link) + strlen (p))); - if (!lp) - { - if (!nolinks) - { - msg ( - "no memory for links, they will be dumped as separate files"); - nolinks++; - } - } - lp->ino = hstat.st_ino; - lp->dev = hstat.st_dev; - strcpy (lp->name, p); - lp->next = linklist; - linklist = lp; - } - - /* - * This is not a link to a previously dumped file, so dump it. - */ - if (S_ISREG (hstat.st_mode) -#ifdef S_ISCTG - || S_ISCTG (hstat.st_mode) -#endif - ) - { - int f; /* File descriptor */ - long bufsize, count; - long sizeleft; - register union record *start; - int header_moved; - char isextended = 0; - int upperbound; - /* int end_nulls = 0; */ - - header_moved = 0; - -#ifdef BSD42 - if (f_sparse_files) - { - /* - * JK - This is the test for sparseness: whether the - * "size" of the file matches the number of blocks - * allocated for it. If there is a smaller number - * of blocks that would be necessary to accommodate - * a file of this size, we have a sparse file, i.e., - * at least one of those records in the file is just - * a useless hole. - */ -#ifdef hpux /* Nice of HPUX to gratuitiously change it, huh? - mib */ - if (hstat.st_size - (hstat.st_blocks * 1024) > 1024) -#else - if (hstat.st_size - (hstat.st_blocks * RECORDSIZE) > RECORDSIZE) -#endif - { - int filesize = hstat.st_size; - register int i; - - header = start_header (p, &hstat); - if (header == NULL) - { - critical_error = 1; - goto badfile; - } - header->header.linkflag = LF_SPARSE; - header_moved++; - - /* - * Call the routine that figures out the - * layout of the sparse file in question. - * UPPERBOUND is the index of the last - * element of the "sparsearray," i.e., - * the number of elements it needed to - * describe the file. - */ - - upperbound = deal_with_sparse (p, header); - - /* - * See if we'll need an extended header - * later - */ - if (upperbound > SPARSE_IN_HDR - 1) - header->header.isextended++; - /* - * We store the "real" file size so - * we can show that in case someone wants - * to list the archive, i.e., tar tvf . - * It might be kind of disconcerting if the - * shrunken file size was the one that showed - * up. - */ - to_oct ((long) hstat.st_size, 1 + 12, - header->header.realsize); - - /* - * This will be the new "size" of the - * file, i.e., the size of the file - * minus the records of holes that we're - * skipping over. - */ - - find_new_file_size (&filesize, upperbound); - hstat.st_size = filesize; - to_oct ((long) filesize, 1 + 12, - header->header.size); - /* to_oct((long) end_nulls, 1+12, - header->header.ending_blanks);*/ - - for (i = 0; i < SPARSE_IN_HDR; i++) - { - if (!sparsearray[i].numbytes) - break; - to_oct (sparsearray[i].offset, 1 + 12, - header->header.sp[i].offset); - to_oct (sparsearray[i].numbytes, 1 + 12, - header->header.sp[i].numbytes); - } - - } - } -#else - upperbound = SPARSE_IN_HDR - 1; -#endif - - sizeleft = hstat.st_size; - /* Don't bother opening empty, world readable files. */ - if (sizeleft > 0 || 0444 != (0444 & hstat.st_mode)) - { - f = open (p, O_RDONLY | O_BINARY); - if (f < 0) - goto badperror; - } - else - { - f = -1; - } - - /* If the file is sparse, we've already taken care of this */ - if (!header_moved) - { - header = start_header (p, &hstat); - if (header == NULL) - { - if (f >= 0) - (void) close (f); - critical_error = 1; - goto badfile; - } - } -#ifdef S_ISCTG - /* Mark contiguous files, if we support them */ - if (f_standard && S_ISCTG (hstat.st_mode)) - { - header->header.linkflag = LF_CONTIG; - } -#endif - isextended = header->header.isextended; - save_linkflag = header->header.linkflag; - finish_header (header); - if (isextended) - { - /* int sum = 0;*/ - register int i; - /* register union record *exhdr;*/ - /* int arraybound = SPARSE_EXT_HDR;*/ - /* static */ int index_offset = SPARSE_IN_HDR; - - extend:exhdr = findrec (); - - if (exhdr == NULL) - { - critical_error = 1; - goto badfile; - } - bzero (exhdr->charptr, RECORDSIZE); - for (i = 0; i < SPARSE_EXT_HDR; i++) - { - if (i + index_offset > upperbound) - break; - to_oct ((long) sparsearray[i + index_offset].numbytes, - 1 + 12, - exhdr->ext_hdr.sp[i].numbytes); - to_oct ((long) sparsearray[i + index_offset].offset, - 1 + 12, - exhdr->ext_hdr.sp[i].offset); - } - userec (exhdr); - /* sum += i; - if (sum < upperbound) - goto extend;*/ - if (index_offset + i <= upperbound) - { - index_offset += i; - exhdr->ext_hdr.isextended++; - goto extend; - } - - } - if (save_linkflag == LF_SPARSE) - { - if (finish_sparse_file (f, &sizeleft, hstat.st_size, p)) - goto padit; - } - else - while (sizeleft > 0) - { - - if (f_multivol) - { - save_name = p; - save_sizeleft = sizeleft; - save_totsize = hstat.st_size; - } - start = findrec (); - - bufsize = endofrecs ()->charptr - start->charptr; - - if (sizeleft < bufsize) - { - /* Last read -- zero out area beyond */ - bufsize = (int) sizeleft; - count = bufsize % RECORDSIZE; - if (count) - bzero (start->charptr + sizeleft, - (int) (RECORDSIZE - count)); - } - count = read (f, start->charptr, bufsize); - if (count < 0) - { - msg_perror ("read error at byte %ld, reading\ - %d bytes, in file %s", hstat.st_size - sizeleft, bufsize, p); - goto padit; - } - sizeleft -= count; - - /* This is nonportable (the type of userec's arg). */ - userec (start + (count - 1) / RECORDSIZE); - - if (count == bufsize) - continue; - msg ("file %s shrunk by %d bytes, padding with zeros.", p, sizeleft); - goto padit; /* Short read */ - } - - if (f_multivol) - save_name = 0; - - if (f >= 0) - (void) close (f); - - if (f_remove_files) - { - if (unlink (p) == -1) - msg_perror ("cannot remove %s", p); - } - if (f_atime_preserve) - utime (p, &restore_times); - return; - - /* - * File shrunk or gave error, pad out tape to match - * the size we specified in the header. - */ - padit: - while (sizeleft > 0) - { - save_sizeleft = sizeleft; - start = findrec (); - bzero (start->charptr, RECORDSIZE); - userec (start); - sizeleft -= RECORDSIZE; - } - if (f_multivol) - save_name = 0; - if (f >= 0) - (void) close (f); - if (f_atime_preserve) - utime (p, &restore_times); - return; - } - -#ifdef S_ISLNK - else if (S_ISLNK (hstat.st_mode)) - { - int size; - char *buf = alloca (PATH_MAX + 1); - - size = readlink (p, buf, PATH_MAX + 1); - if (size < 0) - goto badperror; - buf[size] = '\0'; - if (size >= NAMSIZ) - write_long (buf, LF_LONGLINK); - current_link_name = buf; - - hstat.st_size = 0; /* Force 0 size on symlink */ - header = start_header (p, &hstat); - if (header == NULL) - { - critical_error = 1; - goto badfile; - } - strncpy (header->header.arch_linkname, buf, NAMSIZ); - header->header.arch_linkname[NAMSIZ - 1] = '\0'; - header->header.linkflag = LF_SYMLINK; - finish_header (header); /* Nothing more to do to it */ - if (f_remove_files) - { - if (unlink (p) == -1) - msg_perror ("cannot remove %s", p); - } - return; - } -#endif - - else if (S_ISDIR (hstat.st_mode)) - { - register DIR *dirp; - register struct dirent *d; - char *namebuf; - int buflen; - register int len; - int our_device = hstat.st_dev; - - /* Build new prototype name */ - len = strlen (p); - buflen = len + NAMSIZ; - namebuf = ck_malloc (buflen + 1); - strncpy (namebuf, p, buflen); - while (len >= 1 && '/' == namebuf[len - 1]) - len--; /* Delete trailing slashes */ - namebuf[len++] = '/'; /* Now add exactly one back */ - namebuf[len] = '\0'; /* Make sure null-terminated */ - - /* - * Output directory header record with permissions - * FIXME, do this AFTER files, to avoid R/O dir problems? - * If old archive format, don't write record at all. - */ - if (!f_oldarch) - { - hstat.st_size = 0; /* Force 0 size on dir */ - /* - * If people could really read standard archives, - * this should be: (FIXME) - header = start_header(f_standard? p: namebuf, &hstat); - * but since they'd interpret LF_DIR records as - * regular files, we'd better put the / on the name. - */ - header = start_header (namebuf, &hstat); - if (header == NULL) - { - critical_error = 1; - goto badfile; /* eg name too long */ - } - - if (f_gnudump) - header->header.linkflag = LF_DUMPDIR; - else if (f_standard) - header->header.linkflag = LF_DIR; - - /* If we're gnudumping, we aren't done yet so don't close it. */ - if (!f_gnudump) - finish_header (header); /* Done with directory header */ - } - - if (f_gnudump) - { - int sizeleft; - int totsize; - int bufsize; - union record *start; - int count; - char *buf, *p_buf; - - buf = gnu_list_name->dir_contents; /* FOO */ - totsize = 0; - for (p_buf = buf; p_buf && *p_buf;) - { - int tmp; - - tmp = strlen (p_buf) + 1; - totsize += tmp; - p_buf += tmp; - } - totsize++; - to_oct ((long) totsize, 1 + 12, header->header.size); - finish_header (header); - p_buf = buf; - sizeleft = totsize; - while (sizeleft > 0) - { - if (f_multivol) - { - save_name = p; - save_sizeleft = sizeleft; - save_totsize = totsize; - } - start = findrec (); - bufsize = endofrecs ()->charptr - start->charptr; - if (sizeleft < bufsize) - { - bufsize = sizeleft; - count = bufsize % RECORDSIZE; - if (count) - bzero (start->charptr + sizeleft, RECORDSIZE - count); - } - bcopy (p_buf, start->charptr, bufsize); - sizeleft -= bufsize; - p_buf += bufsize; - userec (start + (bufsize - 1) / RECORDSIZE); - } - if (f_multivol) - save_name = 0; - if (f_atime_preserve) - utime (p, &restore_times); - return; - } - - /* Now output all the files in the directory */ -#if 0 - if (f_dironly) - return; /* Unless the cmdline said not to */ -#endif - /* - * See if we are crossing from one file system to another, - * and avoid doing so if the user only wants to dump one file system. - */ - if (f_local_filesys && !toplevel && curdev != hstat.st_dev) - { - if (f_verbose) - msg ("%s: is on a different filesystem; not dumped", p); - return; - } - - - errno = 0; - dirp = opendir (p); - if (!dirp) - { - if (errno) - { - msg_perror ("can't open directory %s", p); - } - else - { - msg ("error opening directory %s", - p); - } - return; - } - - /* Hack to remove "./" from the front of all the file names */ - if (len == 2 && namebuf[0] == '.' && namebuf[1] == '/') - len = 0; - - /* Should speed this up by cd-ing into the dir, FIXME */ - while (NULL != (d = readdir (dirp))) - { - /* Skip . and .. */ - if (is_dot_or_dotdot (d->d_name)) - continue; - - if (NLENGTH (d) + len >= buflen) - { - buflen = len + NLENGTH (d); - namebuf = ck_realloc (namebuf, buflen + 1); - /* namebuf[len]='\0'; - msg("file name %s%s too long", - namebuf, d->d_name); - continue; */ - } - strcpy (namebuf + len, d->d_name); - if (f_exclude && check_exclude (namebuf)) - continue; - dump_file (namebuf, our_device, 0); - } - - closedir (dirp); - free (namebuf); - if (f_atime_preserve) - utime (p, &restore_times); - return; - } - -#ifdef S_ISCHR - else if (S_ISCHR (hstat.st_mode)) - { - type = LF_CHR; - } -#endif - -#ifdef S_ISBLK - else if (S_ISBLK (hstat.st_mode)) - { - type = LF_BLK; - } -#endif - - /* Avoid screwy apollo lossage where S_IFIFO == S_IFSOCK */ -#if (_ISP__M68K == 0) && (_ISP__A88K == 0) && defined(S_ISFIFO) - else if (S_ISFIFO (hstat.st_mode)) - { - type = LF_FIFO; - } -#endif - -#ifdef S_ISSOCK - else if (S_ISSOCK (hstat.st_mode)) - { - type = LF_FIFO; - } -#endif - else - goto unknown; - - if (!f_standard) - goto unknown; - - hstat.st_size = 0; /* Force 0 size */ - header = start_header (p, &hstat); - if (header == NULL) - { - critical_error = 1; - goto badfile; /* eg name too long */ - } - - header->header.linkflag = type; -#if defined(S_IFBLK) || defined(S_IFCHR) - if (type != LF_FIFO) - { - to_oct ((long) major (hstat.st_rdev), 8, - header->header.devmajor); - to_oct ((long) minor (hstat.st_rdev), 8, - header->header.devminor); - } -#endif - - finish_header (header); - if (f_remove_files) - { - if (unlink (p) == -1) - msg_perror ("cannot remove %s", p); - } - return; - -unknown: - msg ("%s: Unknown file type; file ignored.", p); -} - -int -finish_sparse_file (fd, sizeleft, fullsize, name) - int fd; - long *sizeleft, fullsize; - char *name; -{ - union record *start; - char tempbuf[RECORDSIZE]; - int bufsize, sparse_ind = 0, count; - long pos; - long nwritten = 0; - - - while (*sizeleft > 0) - { - start = findrec (); - bzero (start->charptr, RECORDSIZE); - bufsize = sparsearray[sparse_ind].numbytes; - if (!bufsize) - { /* we blew it, maybe */ - msg ("Wrote %ld of %ld bytes to file %s", - fullsize - *sizeleft, fullsize, name); - break; - } - pos = lseek (fd, sparsearray[sparse_ind++].offset, 0); - /* - * If the number of bytes to be written here exceeds - * the size of the temporary buffer, do it in steps. - */ - while (bufsize > RECORDSIZE) - { - /* if (amt_read) { - count = read(fd, start->charptr+amt_read, RECORDSIZE-amt_read); - bufsize -= RECORDSIZE - amt_read; - amt_read = 0; - userec(start); - start = findrec(); - bzero(start->charptr, RECORDSIZE); - }*/ - /* store the data */ - count = read (fd, start->charptr, RECORDSIZE); - if (count < 0) - { - msg_perror ("read error at byte %ld, reading %d bytes, in file %s", - fullsize - *sizeleft, bufsize, name); - return 1; - } - bufsize -= count; - *sizeleft -= count; - userec (start); - nwritten += RECORDSIZE; /* XXX */ - start = findrec (); - bzero (start->charptr, RECORDSIZE); - } - - - clear_buffer (tempbuf); - count = read (fd, tempbuf, bufsize); - bcopy (tempbuf, start->charptr, RECORDSIZE); - if (count < 0) - { - msg_perror ("read error at byte %ld, reading %d bytes, in file %s", - fullsize - *sizeleft, bufsize, name); - return 1; - } - /* if (amt_read >= RECORDSIZE) { - amt_read = 0; - userec(start+(count-1)/RECORDSIZE); - if (count != bufsize) { - msg("file %s shrunk by %d bytes, padding with zeros.", name, sizeleft); - return 1; - } - start = findrec(); - } else - amt_read += bufsize;*/ - nwritten += count; /* XXX */ - *sizeleft -= count; - userec (start); - - } - free (sparsearray); - /* printf ("Amount actually written is (I hope) %d.\n", nwritten); */ - /* userec(start+(count-1)/RECORDSIZE);*/ - return 0; - -} - -void -init_sparsearray () -{ - register int i; - - sp_array_size = 10; - /* - * Make room for our scratch space -- initially is 10 elts long - */ - sparsearray = (struct sp_array *) ck_malloc (sp_array_size * sizeof (struct sp_array)); - for (i = 0; i < sp_array_size; i++) - { - sparsearray[i].offset = 0; - sparsearray[i].numbytes = 0; - } -} - - - -/* - * Okay, we've got a sparse file on our hands -- now, what we need to do is - * make a pass through the file and carefully note where any data is, i.e., - * we want to find how far into the file each instance of data is, and how - * many bytes are there. We store this information in the sparsearray, - * which will later be translated into header information. For now, we use - * the sparsearray as convenient storage. - * - * As a side note, this routine is a mess. If I could have found a cleaner - * way to do it, I would have. If anyone wants to find a nicer way to do - * this, feel free. - */ - -/* There is little point in trimming small amounts of null data at the */ -/* head and tail of blocks -- it's ok if we only avoid dumping blocks */ -/* of complete null data */ -int -deal_with_sparse (name, header, nulls_at_end) - char *name; - union record *header; - int nulls_at_end; -{ - long numbytes = 0; - long offset = 0; - /* long save_offset;*/ - int fd; - /* int current_size = hstat.st_size;*/ - int sparse_ind = 0, cc; - char buf[RECORDSIZE]; -#if 0 - int read_last_data = 0; /* did we just read the last record? */ -#endif - int amidst_data = 0; - - header->header.isextended = 0; - /* - * Can't open the file -- this problem will be caught later on, - * so just return. - */ - if ((fd = open (name, O_RDONLY)) < 0) - return 0; - - init_sparsearray (); - clear_buffer (buf); - - while ((cc = read (fd, buf, sizeof buf)) != 0) - { - - if (sparse_ind > sp_array_size - 1) - { - - /* - * realloc the scratch area, since we've run out of room -- - */ - sparsearray = (struct sp_array *) - ck_realloc (sparsearray, - 2 * sp_array_size * (sizeof (struct sp_array))); - sp_array_size *= 2; - } - if (cc == sizeof buf) - { - if (zero_record (buf)) - { - if (amidst_data) - { - sparsearray[sparse_ind++].numbytes - = numbytes; - amidst_data = 0; - } - } - else - { /* !zero_record(buf) */ - if (amidst_data) - numbytes += cc; - else - { - amidst_data = 1; - numbytes = cc; - sparsearray[sparse_ind].offset - = offset; - } - } - } - else if (cc < sizeof buf) - { - /* This has to be the last bit of the file, so this */ - /* is somewhat shorter than the above. */ - if (!zero_record (buf)) - { - if (!amidst_data) - { - amidst_data = 1; - numbytes = cc; - sparsearray[sparse_ind].offset - = offset; - } - else - numbytes += cc; - } - } - offset += cc; - clear_buffer (buf); - } - if (amidst_data) - sparsearray[sparse_ind++].numbytes = numbytes; - else - { - sparsearray[sparse_ind].offset = offset-1; - sparsearray[sparse_ind++].numbytes = 1; - } - close (fd); - - return sparse_ind - 1; -} - -/* - * Just zeroes out the buffer so we don't confuse ourselves with leftover - * data. - */ -void -clear_buffer (buf) - char *buf; -{ - register int i; - - for (i = 0; i < RECORDSIZE; i++) - buf[i] = '\0'; -} - -#if 0 /* I'm leaving this as a monument to Joy Kendall, who wrote it -mib */ -/* - * JK - - * This routine takes a character array, and tells where within that array - * the data can be found. It skips over any zeros, and sets the first - * non-zero point in the array to be the "start", and continues until it - * finds non-data again, which is marked as the "end." This routine is - * mainly for 1) seeing how far into a file we must lseek to data, given - * that we have a sparse file, and 2) determining the "real size" of the - * file, i.e., the number of bytes in the sparse file that are data, as - * opposed to the zeros we are trying to skip. - */ -where_is_data (from, to, buffer) - int *from, *to; - char *buffer; -{ - register int i = 0; - register int save_to = *to; - int amidst_data = 0; - - - while (!buffer[i]) - i++; - *from = i; - - if (*from < 16) /* don't bother */ - *from = 0; - /* keep going to make sure there isn't more real - data in this record */ - while (i < RECORDSIZE) - { - if (!buffer[i]) - { - if (amidst_data) - { - save_to = i; - amidst_data = 0; - } - i++; - } - else if (buffer[i]) - { - if (!amidst_data) - amidst_data = 1; - i++; - } - } - if (i == RECORDSIZE) - *to = i; - else - *to = save_to; - -} - -#endif - -/* Note that this routine is only called if zero_record returned true */ -#if 0 /* But we actually don't need it at all. */ -where_is_data (from, to, buffer) - int *from, *to; - char *buffer; -{ - char *fp, *tp; - - for (fp = buffer; !*fp; fp++) - ; - for (tp = buffer + RECORDSIZE - 1; !*tp; tp--) - ; - *from = fp - buffer; - *to = tp - buffer + 1; -} - -#endif - - - -/* - * Takes a recordful of data and basically cruises through it to see if - * it's made *entirely* of zeros, returning a 0 the instant it finds - * something that is a non-zero, i.e., useful data. - */ -int -zero_record (buffer) - char *buffer; -{ - register int i; - - for (i = 0; i < RECORDSIZE; i++) - if (buffer[i] != '\000') - return 0; - return 1; -} - -void -find_new_file_size (filesize, highest_index) - int *filesize; - int highest_index; -{ - register int i; - - *filesize = 0; - for (i = 0; sparsearray[i].numbytes && i <= highest_index; i++) - *filesize += sparsearray[i].numbytes; -} - -/* - * Make a header block for the file name whose stat info is st . - * Return header pointer for success, NULL if the name is too long. - */ -union record * -start_header (name, st) - char *name; - register struct stat *st; -{ - register union record *header; - - if (strlen (name) >= NAMSIZ) - write_long (name, LF_LONGNAME); - - header = (union record *) findrec (); - bzero (header->charptr, sizeof (*header)); /* XXX speed up */ - - /* - * Check the file name and put it in the record. - */ - if (!f_absolute_paths) - { - static int warned_once = 0; -#ifdef __MSDOS__ - if (name[1] == ':') - { - name += 2; - if (!warned_once++) - msg ("Removing drive spec from names in the archive"); - } -#endif - while ('/' == *name) - { - name++; /* Force relative path */ - if (!warned_once++) - msg ("Removing leading / from absolute path names in the archive."); - } - } - current_file_name = name; - strncpy (header->header.arch_name, name, NAMSIZ); - header->header.arch_name[NAMSIZ - 1] = '\0'; - - to_oct ((long) (f_oldarch ? (st->st_mode & 07777) : st->st_mode), - 8, header->header.mode); - to_oct ((long) st->st_uid, 8, header->header.uid); - to_oct ((long) st->st_gid, 8, header->header.gid); - to_oct ((long) st->st_size, 1 + 12, header->header.size); - to_oct ((long) st->st_mtime, 1 + 12, header->header.mtime); - /* header->header.linkflag is left as null */ - if (f_gnudump) - { - to_oct ((long) st->st_atime, 1 + 12, header->header.atime); - to_oct ((long) st->st_ctime, 1 + 12, header->header.ctime); - } - -#ifndef NONAMES - /* Fill in new Unix Standard fields if desired. */ - if (f_standard) - { - header->header.linkflag = LF_NORMAL; /* New default */ - strcpy (header->header.magic, TMAGIC); /* Mark as Unix Std */ - finduname (header->header.uname, st->st_uid); - findgname (header->header.gname, st->st_gid); - } -#endif - return header; -} - -/* - * Finish off a filled-in header block and write it out. - * We also print the file name and/or full info if verbose is on. - */ -void -finish_header (header) - register union record *header; -{ - register int i, sum; - register char *p; - - bcopy (CHKBLANKS, header->header.chksum, sizeof (header->header.chksum)); - - sum = 0; - p = header->charptr; - for (i = sizeof (*header); --i >= 0;) - { - /* - * We can't use unsigned char here because of old compilers, - * e.g. V7. - */ - sum += 0xFF & *p++; - } - - /* - * Fill in the checksum field. It's formatted differently - * from the other fields: it has [6] digits, a null, then a - * space -- rather than digits, a space, then a null. - * We use to_oct then write the null in over to_oct's space. - * The final space is already there, from checksumming, and - * to_oct doesn't modify it. - * - * This is a fast way to do: - * (void) sprintf(header->header.chksum, "%6o", sum); - */ - to_oct ((long) sum, 8, header->header.chksum); - header->header.chksum[6] = '\0'; /* Zap the space */ - - userec (header); - - if (f_verbose) - { - extern union record *head;/* Points to current tape header */ - extern int head_standard; /* Tape header is in ANSI format */ - - /* These globals are parameters to print_header, sigh */ - head = header; - /* hstat is already set up */ - head_standard = f_standard; - print_header (); - } - - return; -} - - -/* - * Quick and dirty octal conversion. - * Converts long "value" into a "digs"-digit field at "where", - * including a trailing space and room for a null. "digs"==3 means - * 1 digit, a space, and room for a null. - * - * We assume the trailing null is already there and don't fill it in. - * This fact is used by start_header and finish_header, so don't change it! - * - * This should be equivalent to: - * (void) sprintf(where, "%*lo ", digs-2, value); - * except that sprintf fills in the trailing null and we don't. - */ -void -to_oct (value, digs, where) - register long value; - register int digs; - register char *where; -{ - - --digs; /* Trailing null slot is left alone */ - where[--digs] = ' '; /* Put in the space, though */ - - /* Produce the digits -- at least one */ - do - { - where[--digs] = '0' + (char) (value & 7); /* one octal digit */ - value >>= 3; - } - while (digs > 0 && value != 0); - - /* Leading spaces, if necessary */ - while (digs > 0) - where[--digs] = ' '; - -} - - -/* - * Write the EOT record(s). - * We actually zero at least one record, through the end of the block. - * Old tar writes garbage after two zeroed records -- and PDtar used to. - */ -void -write_eot () -{ - union record *p; - int bufsize; - - p = findrec (); - if (p) - { - bufsize = endofrecs ()->charptr - p->charptr; - bzero (p->charptr, bufsize); - userec (p); - } -} - -/* Write a LF_LONGLINK or LF_LONGNAME record. */ -void -write_long (p, type) - char *p; - char type; -{ - int size = strlen (p) + 1; - int bufsize; - union record *header; - struct stat foo; - - - bzero (&foo, sizeof foo); - foo.st_size = size; - - header = start_header ("././@LongLink", &foo); - header->header.linkflag = type; - finish_header (header); - - header = findrec (); - - bufsize = endofrecs ()->charptr - header->charptr; - - while (bufsize < size) - { - bcopy (p, header->charptr, bufsize); - p += bufsize; - size -= bufsize; - userec (header + (bufsize - 1) / RECORDSIZE); - header = findrec (); - bufsize = endofrecs ()->charptr - header->charptr; - } - bcopy (p, header->charptr, size); - bzero (header->charptr + size, bufsize - size); - userec (header + (size - 1) / RECORDSIZE); -} diff --git a/gnu/usr.bin/tar-1.11.2/diffarch.c b/gnu/usr.bin/tar-1.11.2/diffarch.c deleted file mode 100644 index ce47d9d6cab5..000000000000 --- a/gnu/usr.bin/tar-1.11.2/diffarch.c +++ /dev/null @@ -1,759 +0,0 @@ -/* Diff files from a tar archive. - Copyright (C) 1988, 1992, 1993 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Diff files from a tar archive. - * - * Written 30 April 1987 by John Gilmore, ihnp4!hoptoad!gnu. - */ - -#include -#include -#ifndef STDC_HEADERS -extern int errno; -#endif -#include - -#ifdef BSD42 -#include -#else -#ifndef V7 -#include -#endif -#endif - -#ifdef HAVE_SYS_MTIO_H -#include -#include -#endif - -#include "tar.h" -#include "port.h" -#include "rmt.h" - -#ifndef S_ISLNK -#define lstat stat -#endif - -extern void *valloc (); - -extern union record *head; /* Points to current tape header */ -extern struct stat hstat; /* Stat struct corresponding */ -extern int head_standard; /* Tape header is in ANSI format */ - -void decode_header (); -void diff_sparse_files (); -void fill_in_sparse_array (); -void fl_read (); -long from_oct (); -int do_stat (); -extern void print_header (); -int read_header (); -void saverec (); -void sigh (); -extern void skip_file (); -extern void skip_extended_headers (); -int wantbytes (); - -extern FILE *msg_file; - -int now_verifying = 0; /* Are we verifying at the moment? */ - -int diff_fd; /* Descriptor of file we're diffing */ - -char *diff_buf = 0; /* Pointer to area for reading - file contents into */ - -char *diff_dir; /* Directory contents for LF_DUMPDIR */ - -int different = 0; - -/*struct sp_array *sparsearray; -int sp_ar_size = 10;*/ -/* - * Initialize for a diff operation - */ -void -diff_init () -{ - /*NOSTRICT*/ - diff_buf = (char *) valloc ((unsigned) blocksize); - if (!diff_buf) - { - msg ("could not allocate memory for diff buffer of %d bytes", - blocksize); - exit (EX_ARGSBAD); - } -} - -/* - * Diff a file against the archive. - */ -void -diff_archive () -{ - register char *data; - int check, namelen; - int err; - long offset; - struct stat filestat; - int compare_chunk (); - int compare_dir (); - int no_op (); -#ifndef __MSDOS__ - dev_t dev; - ino_t ino; -#endif - char *get_dir_contents (); - long from_oct (); - - errno = EPIPE; /* FIXME, remove perrors */ - - saverec (&head); /* Make sure it sticks around */ - userec (head); /* And go past it in the archive */ - decode_header (head, &hstat, &head_standard, 1); /* Snarf fields */ - - /* Print the record from 'head' and 'hstat' */ - if (f_verbose) - { - if (now_verifying) - fprintf (msg_file, "Verify "); - print_header (); - } - - switch (head->header.linkflag) - { - - default: - msg ("Unknown file type '%c' for %s, diffed as normal file", - head->header.linkflag, current_file_name); - /* FALL THRU */ - - case LF_OLDNORMAL: - case LF_NORMAL: - case LF_SPARSE: - case LF_CONTIG: - /* - * Appears to be a file. - * See if it's really a directory. - */ - namelen = strlen (current_file_name) - 1; - if (current_file_name[namelen] == '/') - goto really_dir; - - - if (do_stat (&filestat)) - { - if (head->header.isextended) - skip_extended_headers (); - skip_file ((long) hstat.st_size); - different++; - goto quit; - } - - if (!S_ISREG (filestat.st_mode)) - { - fprintf (msg_file, "%s: not a regular file\n", - current_file_name); - skip_file ((long) hstat.st_size); - different++; - goto quit; - } - - filestat.st_mode &= 07777; - if (filestat.st_mode != hstat.st_mode) - sigh ("mode"); - if (filestat.st_uid != hstat.st_uid) - sigh ("uid"); - if (filestat.st_gid != hstat.st_gid) - sigh ("gid"); - if (filestat.st_mtime != hstat.st_mtime) - sigh ("mod time"); - if (head->header.linkflag != LF_SPARSE && - filestat.st_size != hstat.st_size) - { - sigh ("size"); - skip_file ((long) hstat.st_size); - goto quit; - } - - diff_fd = open (current_file_name, O_NDELAY | O_RDONLY | O_BINARY); - - if (diff_fd < 0 && !f_absolute_paths) - { - char tmpbuf[NAMSIZ + 2]; - - tmpbuf[0] = '/'; - strcpy (&tmpbuf[1], current_file_name); - diff_fd = open (tmpbuf, O_NDELAY | O_RDONLY); - } - if (diff_fd < 0) - { - msg_perror ("cannot open %s", current_file_name); - if (head->header.isextended) - skip_extended_headers (); - skip_file ((long) hstat.st_size); - different++; - goto quit; - } - /* - * Need to treat sparse files completely differently here. - */ - if (head->header.linkflag == LF_SPARSE) - diff_sparse_files (hstat.st_size); - else - wantbytes ((long) (hstat.st_size), compare_chunk); - - check = close (diff_fd); - if (check < 0) - msg_perror ("Error while closing %s", current_file_name); - - quit: - break; - -#ifndef __MSDOS__ - case LF_LINK: - if (do_stat (&filestat)) - break; - dev = filestat.st_dev; - ino = filestat.st_ino; - err = stat (current_link_name, &filestat); - if (err < 0) - { - if (errno == ENOENT) - { - fprintf (msg_file, "%s: does not exist\n", current_file_name); - } - else - { - msg_perror ("cannot stat file %s", current_file_name); - } - different++; - break; - } - if (filestat.st_dev != dev || filestat.st_ino != ino) - { - fprintf (msg_file, "%s not linked to %s\n", current_file_name, current_link_name); - break; - } - break; -#endif - -#ifdef S_ISLNK - case LF_SYMLINK: - { - char linkbuf[NAMSIZ + 3]; - check = readlink (current_file_name, linkbuf, - (sizeof linkbuf) - 1); - - if (check < 0) - { - if (errno == ENOENT) - { - fprintf (msg_file, - "%s: no such file or directory\n", - current_file_name); - } - else - { - msg_perror ("cannot read link %s", current_file_name); - } - different++; - break; - } - - linkbuf[check] = '\0'; /* Null-terminate it */ - if (strncmp (current_link_name, linkbuf, check) != 0) - { - fprintf (msg_file, "%s: symlink differs\n", - current_link_name); - different++; - } - } - break; -#endif - -#ifdef S_IFCHR - case LF_CHR: - hstat.st_mode |= S_IFCHR; - goto check_node; -#endif - -#ifdef S_IFBLK - /* If local system doesn't support block devices, use default case */ - case LF_BLK: - hstat.st_mode |= S_IFBLK; - goto check_node; -#endif - -#ifdef S_ISFIFO - /* If local system doesn't support FIFOs, use default case */ - case LF_FIFO: -#ifdef S_IFIFO - hstat.st_mode |= S_IFIFO; -#endif - hstat.st_rdev = 0; /* FIXME, do we need this? */ - goto check_node; -#endif - - check_node: - /* FIXME, deal with umask */ - if (do_stat (&filestat)) - break; - if (hstat.st_rdev != filestat.st_rdev) - { - fprintf (msg_file, "%s: device numbers changed\n", current_file_name); - different++; - break; - } -#ifdef S_IFMT - if (hstat.st_mode != filestat.st_mode) -#else /* POSIX lossage */ - if ((hstat.st_mode & 07777) != (filestat.st_mode & 07777)) -#endif - { - fprintf (msg_file, "%s: mode or device-type changed\n", current_file_name); - different++; - break; - } - break; - - case LF_DUMPDIR: - data = diff_dir = get_dir_contents (current_file_name, 0); - if (data) - { - wantbytes ((long) (hstat.st_size), compare_dir); - free (data); - } - else - wantbytes ((long) (hstat.st_size), no_op); - /* FALL THROUGH */ - - case LF_DIR: - /* Check for trailing / */ - namelen = strlen (current_file_name) - 1; - really_dir: - while (namelen && current_file_name[namelen] == '/') - current_file_name[namelen--] = '\0'; /* Zap / */ - - if (do_stat (&filestat)) - break; - if (!S_ISDIR (filestat.st_mode)) - { - fprintf (msg_file, "%s is no longer a directory\n", current_file_name); - different++; - break; - } - if ((filestat.st_mode & 07777) != (hstat.st_mode & 07777)) - sigh ("mode"); - break; - - case LF_VOLHDR: - break; - - case LF_MULTIVOL: - namelen = strlen (current_file_name) - 1; - if (current_file_name[namelen] == '/') - goto really_dir; - - if (do_stat (&filestat)) - break; - - if (!S_ISREG (filestat.st_mode)) - { - fprintf (msg_file, "%s: not a regular file\n", - current_file_name); - skip_file ((long) hstat.st_size); - different++; - break; - } - - filestat.st_mode &= 07777; - offset = from_oct (1 + 12, head->header.offset); - if (filestat.st_size != hstat.st_size + offset) - { - sigh ("size"); - skip_file ((long) hstat.st_size); - different++; - break; - } - - diff_fd = open (current_file_name, O_NDELAY | O_RDONLY | O_BINARY); - - if (diff_fd < 0) - { - msg_perror ("cannot open file %s", current_file_name); - skip_file ((long) hstat.st_size); - different++; - break; - } - err = lseek (diff_fd, offset, 0); - if (err != offset) - { - msg_perror ("cannot seek to %ld in file %s", offset, current_file_name); - different++; - break; - } - - wantbytes ((long) (hstat.st_size), compare_chunk); - - check = close (diff_fd); - if (check < 0) - { - msg_perror ("Error while closing %s", current_file_name); - } - break; - - } - - /* We don't need to save it any longer. */ - saverec ((union record **) 0);/* Unsave it */ -} - -int -compare_chunk (bytes, buffer) - long bytes; - char *buffer; -{ - int err; - - err = read (diff_fd, diff_buf, bytes); - if (err != bytes) - { - if (err < 0) - { - msg_perror ("can't read %s", current_file_name); - } - else - { - fprintf (msg_file, "%s: could only read %d of %d bytes\n", current_file_name, err, bytes); - } - different++; - return -1; - } - if (bcmp (buffer, diff_buf, bytes)) - { - fprintf (msg_file, "%s: data differs\n", current_file_name); - different++; - return -1; - } - return 0; -} - -int -compare_dir (bytes, buffer) - long bytes; - char *buffer; -{ - if (bcmp (buffer, diff_dir, bytes)) - { - fprintf (msg_file, "%s: data differs\n", current_file_name); - different++; - return -1; - } - diff_dir += bytes; - return 0; -} - -/* - * Sigh about something that differs. - */ -void -sigh (what) - char *what; -{ - - fprintf (msg_file, "%s: %s differs\n", - current_file_name, what); -} - -void -verify_volume () -{ - int status; -#ifdef MTIOCTOP - struct mtop t; - int er; -#endif - - if (!diff_buf) - diff_init (); -#ifdef MTIOCTOP - t.mt_op = MTBSF; - t.mt_count = 1; - if ((er = rmtioctl (archive, MTIOCTOP, &t)) < 0) - { - if (errno != EIO || (er = rmtioctl (archive, MTIOCTOP, &t)) < 0) - { -#endif - if (rmtlseek (archive, 0L, 0) != 0) - { - /* Lseek failed. Try a different method */ - msg_perror ("Couldn't rewind archive file for verify"); - return; - } -#ifdef MTIOCTOP - } - } -#endif - ar_reading = 1; - now_verifying = 1; - fl_read (); - for (;;) - { - status = read_header (); - if (status == 0) - { - unsigned n; - - n = 0; - do - { - n++; - status = read_header (); - } - while (status == 0); - msg ("VERIFY FAILURE: %d invalid header%s detected!", n, n == 1 ? "" : "s"); - } - if (status == 2 || status == EOF) - break; - diff_archive (); - } - ar_reading = 0; - now_verifying = 0; - -} - -int -do_stat (statp) - struct stat *statp; -{ - int err; - - err = f_follow_links ? stat (current_file_name, statp) : lstat (current_file_name, statp); - if (err < 0) - { - if (errno == ENOENT) - { - fprintf (msg_file, "%s: does not exist\n", current_file_name); - } - else - msg_perror ("can't stat file %s", current_file_name); - /* skip_file((long)hstat.st_size); - different++;*/ - return 1; - } - else - return 0; -} - -/* - * JK - * Diff'ing a sparse file with its counterpart on the tar file is a - * bit of a different story than a normal file. First, we must know - * what areas of the file to skip through, i.e., we need to contruct - * a sparsearray, which will hold all the information we need. We must - * compare small amounts of data at a time as we find it. - */ - -void -diff_sparse_files (filesize) - int filesize; - -{ - int sparse_ind = 0; - char *buf; - int buf_size = RECORDSIZE; - union record *datarec; - int err; - long numbytes; - /* int amt_read = 0;*/ - int size = filesize; - - buf = (char *) ck_malloc (buf_size * sizeof (char)); - - fill_in_sparse_array (); - - - while (size > 0) - { - datarec = findrec (); - if (!sparsearray[sparse_ind].numbytes) - break; - - /* - * 'numbytes' is nicer to write than - * 'sparsearray[sparse_ind].numbytes' all the time ... - */ - numbytes = sparsearray[sparse_ind].numbytes; - - lseek (diff_fd, sparsearray[sparse_ind].offset, 0); - /* - * take care to not run out of room in our buffer - */ - while (buf_size < numbytes) - { - buf = (char *) ck_realloc (buf, buf_size * 2 * sizeof (char)); - buf_size *= 2; - } - while (numbytes > RECORDSIZE) - { - if ((err = read (diff_fd, buf, RECORDSIZE)) != RECORDSIZE) - { - if (err < 0) - msg_perror ("can't read %s", current_file_name); - else - fprintf (msg_file, "%s: could only read %d of %d bytes\n", - current_file_name, err, numbytes); - break; - } - if (bcmp (buf, datarec->charptr, RECORDSIZE)) - { - different++; - break; - } - numbytes -= err; - size -= err; - userec (datarec); - datarec = findrec (); - } - if ((err = read (diff_fd, buf, numbytes)) != numbytes) - { - if (err < 0) - msg_perror ("can't read %s", current_file_name); - else - fprintf (msg_file, "%s: could only read %d of %d bytes\n", - current_file_name, err, numbytes); - break; - } - - if (bcmp (buf, datarec->charptr, numbytes)) - { - different++; - break; - } - /* amt_read += numbytes; - if (amt_read >= RECORDSIZE) { - amt_read = 0; - userec(datarec); - datarec = findrec(); - }*/ - userec (datarec); - sparse_ind++; - size -= numbytes; - } - /* - * if the number of bytes read isn't the - * number of bytes supposedly in the file, - * they're different - */ - /* if (amt_read != filesize) - different++;*/ - userec (datarec); - free (sparsearray); - if (different) - fprintf (msg_file, "%s: data differs\n", current_file_name); - -} - -/* - * JK - * This routine should be used more often than it is ... look into - * that. Anyhow, what it does is translate the sparse information - * on the header, and in any subsequent extended headers, into an - * array of structures with true numbers, as opposed to character - * strings. It simply makes our life much easier, doing so many - * comparisong and such. - */ -void -fill_in_sparse_array () -{ - int ind; - - /* - * allocate space for our scratch space; it's initially - * 10 elements long, but can change in this routine if - * necessary - */ - sp_array_size = 10; - sparsearray = (struct sp_array *) ck_malloc (sp_array_size * sizeof (struct sp_array)); - - /* - * there are at most five of these structures in the header - * itself; read these in first - */ - for (ind = 0; ind < SPARSE_IN_HDR; ind++) - { - if (!head->header.sp[ind].numbytes) - break; - sparsearray[ind].offset = - from_oct (1 + 12, head->header.sp[ind].offset); - sparsearray[ind].numbytes = - from_oct (1 + 12, head->header.sp[ind].numbytes); - } - /* - * if the header's extended, we gotta read in exhdr's till - * we're done - */ - if (head->header.isextended) - { - /* how far into the sparsearray we are 'so far' */ - static int so_far_ind = SPARSE_IN_HDR; - union record *exhdr; - - for (;;) - { - exhdr = findrec (); - for (ind = 0; ind < SPARSE_EXT_HDR; ind++) - { - if (ind + so_far_ind > sp_array_size - 1) - { - /* - * we just ran out of room in our - * scratch area - realloc it - */ - sparsearray = (struct sp_array *) - ck_realloc (sparsearray, - sp_array_size * 2 * sizeof (struct sp_array)); - sp_array_size *= 2; - } - /* - * convert the character strings into longs - */ - sparsearray[ind + so_far_ind].offset = - from_oct (1 + 12, exhdr->ext_hdr.sp[ind].offset); - sparsearray[ind + so_far_ind].numbytes = - from_oct (1 + 12, exhdr->ext_hdr.sp[ind].numbytes); - } - /* - * if this is the last extended header for this - * file, we can stop - */ - if (!exhdr->ext_hdr.isextended) - break; - else - { - so_far_ind += SPARSE_EXT_HDR; - userec (exhdr); - } - } - /* be sure to skip past the last one */ - userec (exhdr); - } -} diff --git a/gnu/usr.bin/tar-1.11.2/extract.c b/gnu/usr.bin/tar-1.11.2/extract.c deleted file mode 100644 index d162cab04ec6..000000000000 --- a/gnu/usr.bin/tar-1.11.2/extract.c +++ /dev/null @@ -1,907 +0,0 @@ -/* Extract files from a tar archive. - Copyright (C) 1988, 1992, 1993 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Extract files from a tar archive. - * - * Written 19 Nov 1985 by John Gilmore, ihnp4!hoptoad!gnu. - */ - -#include -#include -#ifndef STDC_HEADERS -extern int errno; -#endif -#include -#include -time_t time (); - -#ifdef BSD42 -#include -#else -#ifndef V7 -#include -#endif -#endif - -#ifdef NO_OPEN3 -/* We need the #define's even though we don't use them. */ -#include "open3.h" -#endif - -#ifdef EMUL_OPEN3 -/* Simulated 3-argument open for systems that don't have it */ -#include "open3.h" -#endif - -#include "tar.h" -#include "port.h" - -#if defined(_POSIX_VERSION) -#include -#else -struct utimbuf -{ - long actime; - long modtime; -}; - -#endif - -extern FILE *msg_file; - -extern union record *head; /* Points to current tape header */ -extern struct stat hstat; /* Stat struct corresponding */ -extern int head_standard; /* Tape header is in ANSI format */ - -extern char *save_name; -extern long save_totsize; -extern long save_sizeleft; - -int confirm (); -void decode_header (); -void extract_mangle (); -void extract_sparse_file (); -long from_oct (); -void gnu_restore (); -extern void print_header (); -extern void skip_file (); -extern void skip_extended_headers (); -extern void pr_mkdir (); -void saverec (); - -int make_dirs (); /* Makes required directories */ - -static time_t now = 0; /* Current time */ -static we_are_root = 0; /* True if our effective uid == 0 */ -static int notumask = ~0; /* Masks out bits user doesn't want */ - -/* - * "Scratch" space to store the information about a sparse file before - * writing the info into the header or extended header - */ -/*struct sp_array *sparsearray;*/ - -/* number of elts storable in the sparsearray */ -/*int sp_array_size = 10;*/ - -struct saved_dir_info -{ - char *path; - int mode; - int atime; - int mtime; - struct saved_dir_info *next; -}; - -struct saved_dir_info *saved_dir_info_head; - -/* - * Set up to extract files. - */ -void -extr_init () -{ - int ourmask; - - now = time ((time_t *) 0); - if (geteuid () == 0) - we_are_root = 1; - - /* - * We need to know our umask. But if f_use_protection is set, - * leave our kernel umask at 0, and our "notumask" at ~0. - */ - ourmask = umask (0); /* Read it */ - if (!f_use_protection) - { - (void) umask (ourmask); /* Set it back how it was */ - notumask = ~ourmask; /* Make umask override permissions */ - } -} - - -/* - * Extract a file from the archive. - */ -void -extract_archive () -{ - register char *data; - int fd, check, namelen, written, openflag; - long size; - struct utimbuf acc_upd_times; - register int skipcrud; - register int i; - /* int sparse_ind = 0;*/ - union record *exhdr; - struct saved_dir_info *tmp; - /* int end_nulls; */ - - saverec (&head); /* Make sure it sticks around */ - userec (head); /* And go past it in the archive */ - decode_header (head, &hstat, &head_standard, 1); /* Snarf fields */ - - if (f_confirm && !confirm ("extract", current_file_name)) - { - if (head->header.isextended) - skip_extended_headers (); - skip_file ((long) hstat.st_size); - saverec ((union record **) 0); - return; - } - - /* Print the record from 'head' and 'hstat' */ - if (f_verbose) - print_header (); - - /* - * Check for fully specified pathnames and other atrocities. - * - * Note, we can't just make a pointer to the new file name, - * since saverec() might move the header and adjust "head". - * We have to start from "head" every time we want to touch - * the header record. - */ - skipcrud = 0; - while (!f_absolute_paths - && '/' == current_file_name[skipcrud]) - { - static int warned_once = 0; - - skipcrud++; /* Force relative path */ - if (!warned_once++) - { - msg ("Removing leading / from absolute path names in the archive."); - } - } - - switch (head->header.linkflag) - { - - default: - msg ("Unknown file type '%c' for %s, extracted as normal file", - head->header.linkflag, skipcrud + current_file_name); - /* FALL THRU */ - - /* - * JK - What we want to do if the file is sparse is loop through - * the array of sparse structures in the header and read in - * and translate the character strings representing 1) the offset - * at which to write and 2) how many bytes to write into numbers, - * which we store into the scratch array, "sparsearray". This - * array makes our life easier the same way it did in creating - * the tar file that had to deal with a sparse file. - * - * After we read in the first five (at most) sparse structures, - * we check to see if the file has an extended header, i.e., - * if more sparse structures are needed to describe the contents - * of the new file. If so, we read in the extended headers - * and continue to store their contents into the sparsearray. - */ - case LF_SPARSE: - sp_array_size = 10; - sparsearray = (struct sp_array *) ck_malloc (sp_array_size * sizeof (struct sp_array)); - for (i = 0; i < SPARSE_IN_HDR; i++) - { - sparsearray[i].offset = - from_oct (1 + 12, head->header.sp[i].offset); - sparsearray[i].numbytes = - from_oct (1 + 12, head->header.sp[i].numbytes); - if (!sparsearray[i].numbytes) - break; - } - - /* end_nulls = from_oct(1+12, head->header.ending_blanks);*/ - - if (head->header.isextended) - { - /* read in the list of extended headers - and translate them into the sparsearray - as before */ - - /* static */ int ind = SPARSE_IN_HDR; - - for (;;) - { - - exhdr = findrec (); - for (i = 0; i < SPARSE_EXT_HDR; i++) - { - - if (i + ind > sp_array_size - 1) - { - /* - * realloc the scratch area - * since we've run out of room -- - */ - sparsearray = (struct sp_array *) - ck_realloc (sparsearray, - 2 * sp_array_size * (sizeof (struct sp_array))); - sp_array_size *= 2; - } - if (!exhdr->ext_hdr.sp[i].numbytes) - break; - sparsearray[i + ind].offset = - from_oct (1 + 12, exhdr->ext_hdr.sp[i].offset); - sparsearray[i + ind].numbytes = - from_oct (1 + 12, exhdr->ext_hdr.sp[i].numbytes); - } - if (!exhdr->ext_hdr.isextended) - break; - else - { - ind += SPARSE_EXT_HDR; - userec (exhdr); - } - } - userec (exhdr); - } - - /* FALL THRU */ - case LF_OLDNORMAL: - case LF_NORMAL: - case LF_CONTIG: - /* - * Appears to be a file. - * See if it's really a directory. - */ - namelen = strlen (skipcrud + current_file_name) - 1; - if (current_file_name[skipcrud + namelen] == '/') - goto really_dir; - - /* FIXME, deal with protection issues */ - again_file: - openflag = (f_keep ? - O_BINARY | O_NDELAY | O_WRONLY | O_CREAT | O_EXCL : - O_BINARY | O_NDELAY | O_WRONLY | O_CREAT | O_TRUNC) - | ((head->header.linkflag == LF_SPARSE) ? 0 : O_APPEND); - /* - * JK - The last | is a kludge to solve the problem - * the O_APPEND flag causes with files we are - * trying to make sparse: when a file is opened - * with O_APPEND, it writes to the last place - * that something was written, thereby ignoring - * any lseeks that we have done. We add this - * extra condition to make it able to lseek when - * a file is sparse, i.e., we don't open the new - * file with this flag. (Grump -- this bug caused - * me to waste a good deal of time, I might add) - */ - - if (f_exstdout) - { - fd = 1; - goto extract_file; - } -#ifdef O_CTG - /* - * Contiguous files (on the Masscomp) have to specify - * the size in the open call that creates them. - */ - if (head->header.linkflag == LF_CONTIG) - fd = open ((longname ? longname : head->header.name) - + skipcrud, - openflag | O_CTG, - hstat.st_mode, hstat.st_size); - else -#endif - { -#ifdef NO_OPEN3 - /* - * On raw V7 we won't let them specify -k (f_keep), but - * we just bull ahead and create the files. - */ - fd = creat ((longname - ? longname - : head->header.name) + skipcrud, - hstat.st_mode); -#else - /* - * With 3-arg open(), we can do this up right. - */ - fd = open (skipcrud + current_file_name, - openflag, hstat.st_mode); -#endif - } - - if (fd < 0) - { - if (make_dirs (skipcrud + current_file_name)) - goto again_file; - msg_perror ("Could not create file %s", - skipcrud + current_file_name); - if (head->header.isextended) - skip_extended_headers (); - skip_file ((long) hstat.st_size); - goto quit; - } - - extract_file: - if (head->header.linkflag == LF_SPARSE) - { - char *name; - int namelen; - - /* - * Kludge alert. NAME is assigned to header.name - * because during the extraction, the space that - * contains the header will get scribbled on, and - * the name will get munged, so any error messages - * that happen to contain the filename will look - * REAL interesting unless we do this. - */ - namelen = strlen (skipcrud + current_file_name) + 1; - name = (char *) ck_malloc ((sizeof (char)) * namelen); - bcopy (skipcrud + current_file_name, name, namelen); - size = hstat.st_size; - extract_sparse_file (fd, &size, hstat.st_size, name); - } - else - for (size = hstat.st_size; - size > 0; - size -= written) - { - - /* long offset, - numbytes;*/ - - if (f_multivol) - { - save_name = current_file_name; - save_totsize = hstat.st_size; - save_sizeleft = size; - } - - /* - * Locate data, determine max length - * writeable, write it, record that - * we have used the data, then check - * if the write worked. - */ - data = findrec ()->charptr; - if (data == NULL) - { /* Check it... */ - msg ("Unexpected EOF on archive file"); - break; - } - /* - * JK - If the file is sparse, use the sparsearray - * that we created before to lseek into the new - * file the proper amount, and to see how many - * bytes we want to write at that position. - */ - /* if (head->header.linkflag == LF_SPARSE) { - off_t pos; - - pos = lseek(fd, (off_t) sparsearray[sparse_ind].offset, 0); - printf("%d at %d\n", (int) pos, sparse_ind); - written = sparsearray[sparse_ind++].numbytes; - } else*/ - written = endofrecs ()->charptr - data; - if (written > size) - written = size; - errno = 0; - check = write (fd, data, written); - /* - * The following is in violation of strict - * typing, since the arg to userec - * should be a struct rec *. FIXME. - */ - userec ((union record *) (data + written - 1)); - if (check == written) - continue; - /* - * Error in writing to file. - * Print it, skip to next file in archive. - */ - if (check < 0) - msg_perror ("couldn't write to file %s", - skipcrud + current_file_name); - else - msg ("could only write %d of %d bytes to file %s", - check, written, skipcrud + current_file_name); - skip_file ((long) (size - written)); - break; /* Still do the close, mod time, chmod, etc */ - } - - if (f_multivol) - save_name = 0; - - /* If writing to stdout, don't try to do anything - to the filename; it doesn't exist, or we don't - want to touch it anyway */ - if (f_exstdout) - break; - - /* if (head->header.isextended) { - register union record *exhdr; - register int i; - - for (i = 0; i < 21; i++) { - long offset; - - if (!exhdr->ext_hdr.sp[i].numbytes) - break; - offset = from_oct(1+12, - exhdr->ext_hdr.sp[i].offset); - written = from_oct(1+12, - exhdr->ext_hdr.sp[i].numbytes); - lseek(fd, offset, 0); - check = write(fd, data, written); - if (check == written) continue; - - } - - - }*/ - check = close (fd); - if (check < 0) - { - msg_perror ("Error while closing %s", - skipcrud + current_file_name); - } - - - set_filestat: - - /* - * If we are root, set the owner and group of the extracted - * file. This does what is wanted both on real Unix and on - * System V. If we are running as a user, we extract as that - * user; if running as root, we extract as the original owner. - */ - if (we_are_root || f_do_chown) - { - if (chown (skipcrud + current_file_name, - hstat.st_uid, hstat.st_gid) < 0) - { - msg_perror ("cannot chown file %s to uid %d gid %d", - skipcrud + current_file_name, - hstat.st_uid, hstat.st_gid); - } - } - - /* - * Set the modified time of the file. - * - * Note that we set the accessed time to "now", which - * is really "the time we started extracting files". - * unless f_gnudump is used, in which case .st_atime is used - */ - if (!f_modified) - { - /* fixme if f_gnudump should set ctime too, but how? */ - if (f_gnudump) - acc_upd_times.actime = hstat.st_atime; - else - acc_upd_times.actime = now; /* Accessed now */ - acc_upd_times.modtime = hstat.st_mtime; /* Mod'd */ - if (utime (skipcrud + current_file_name, - &acc_upd_times) < 0) - { - msg_perror ("couldn't change access and modification times of %s", skipcrud + current_file_name); - } - } - /* We do the utime before the chmod because some versions of - utime are broken and trash the modes of the file. Since - we then change the mode anyway, we don't care. . . */ - - /* - * If '-k' is not set, open() or creat() could have saved - * the permission bits from a previously created file, - * ignoring the ones we specified. - * Even if -k is set, if the file has abnormal - * mode bits, we must chmod since writing or chown() has - * probably reset them. - * - * If -k is set, we know *we* created this file, so the mode - * bits were set by our open(). If the file is "normal", we - * skip the chmod. This works because we did umask(0) if -p - * is set, so umask will have left the specified mode alone. - */ - if ((!f_keep) - || (hstat.st_mode & (S_ISUID | S_ISGID | S_ISVTX))) - { - if (chmod (skipcrud + current_file_name, - notumask & (int) hstat.st_mode) < 0) - { - msg_perror ("cannot change mode of file %s to %ld", - skipcrud + current_file_name, - notumask & (int) hstat.st_mode); - } - } - - quit: - break; - - case LF_LINK: - again_link: - { - struct stat st1, st2; - - check = link (current_link_name, skipcrud + current_file_name); - - if (check == 0) - break; - if (make_dirs (skipcrud + current_file_name)) - goto again_link; - if (f_gnudump && errno == EEXIST) - break; - if (stat (current_link_name, &st1) == 0 - && stat (current_file_name + skipcrud, &st2) == 0 - && st1.st_dev == st2.st_dev - && st1.st_ino == st2.st_ino) - break; - msg_perror ("Could not link %s to %s", - skipcrud + current_file_name, - current_link_name); - } - break; - -#ifdef S_ISLNK - case LF_SYMLINK: - again_symlink: - check = symlink (current_link_name, - skipcrud + current_file_name); - /* FIXME, don't worry uid, gid, etc... */ - if (check == 0) - break; - if (make_dirs (current_file_name + skipcrud)) - goto again_symlink; - msg_perror ("Could not create symlink to %s", - current_link_name); - break; -#endif - -#ifdef S_IFCHR - case LF_CHR: - hstat.st_mode |= S_IFCHR; - goto make_node; -#endif - -#ifdef S_IFBLK - case LF_BLK: - hstat.st_mode |= S_IFBLK; -#endif -#if defined(S_IFCHR) || defined(S_IFBLK) - make_node: - check = mknod (current_file_name + skipcrud, - (int) hstat.st_mode, (int) hstat.st_rdev); - if (check != 0) - { - if (make_dirs (skipcrud + current_file_name)) - goto make_node; - msg_perror ("Could not make %s", - current_file_name + skipcrud); - break; - }; - goto set_filestat; -#endif - -#ifdef S_ISFIFO - /* If local system doesn't support FIFOs, use default case */ - case LF_FIFO: - make_fifo: - check = mkfifo (current_file_name + skipcrud, - (int) hstat.st_mode); - if (check != 0) - { - if (make_dirs (current_file_name + skipcrud)) - goto make_fifo; - msg_perror ("Could not make %s", - skipcrud + current_file_name); - break; - }; - goto set_filestat; -#endif - - case LF_DIR: - case LF_DUMPDIR: - namelen = strlen (current_file_name + skipcrud) - 1; - really_dir: - /* Check for trailing /, and zap as many as we find. */ - while (namelen - && current_file_name[skipcrud + namelen] == '/') - current_file_name[skipcrud + namelen--] = '\0'; - if (f_gnudump) - { /* Read the entry and delete files - that aren't listed in the archive */ - gnu_restore (skipcrud); - - } - else if (head->header.linkflag == LF_DUMPDIR) - skip_file ((long) (hstat.st_size)); - - - again_dir: - check = mkdir (skipcrud + current_file_name, - (we_are_root ? 0 : 0300) | (int) hstat.st_mode); - if (check != 0) - { - struct stat st1; - - if (make_dirs (skipcrud + current_file_name)) - goto again_dir; - /* If we're trying to create '.', let it be. */ - if (current_file_name[skipcrud + namelen] == '.' && - (namelen == 0 || - current_file_name[skipcrud + namelen - 1] == '/')) - goto check_perms; - if (errno == EEXIST - && stat (skipcrud + current_file_name, &st1) == 0 - && (S_ISDIR (st1.st_mode))) - break; - msg_perror ("Could not create directory %s", skipcrud + current_file_name); - break; - } - - check_perms: - if (!we_are_root && 0300 != (0300 & (int) hstat.st_mode)) - { - hstat.st_mode |= 0300; - msg ("Added write and execute permission to directory %s", - skipcrud + current_file_name); - } - - /* - * If we are root, set the owner and group of the extracted - * file. This does what is wanted both on real Unix and on - * System V. If we are running as a user, we extract as that - * user; if running as root, we extract as the original owner. - */ - if (we_are_root || f_do_chown) - { - if (chown (skipcrud + current_file_name, - hstat.st_uid, hstat.st_gid) < 0) - { - msg_perror ("cannot chown file %s to uid %d gid %d", - skipcrud + current_file_name, - hstat.st_uid, hstat.st_gid); - } - } - - if (!f_modified) - { - tmp = ((struct saved_dir_info *) - ck_malloc (sizeof (struct saved_dir_info))); - tmp->path = (char *) ck_malloc (strlen (skipcrud - + current_file_name) + 1); - strcpy (tmp->path, skipcrud + current_file_name); - tmp->mode = hstat.st_mode; - tmp->atime = hstat.st_atime; - tmp->mtime = hstat.st_mtime; - tmp->next = saved_dir_info_head; - saved_dir_info_head = tmp; - } - else - { - /* This functions exactly as the code for set_filestat above. */ - if ((!f_keep) - || (hstat.st_mode & (S_ISUID | S_ISGID | S_ISVTX))) - { - if (chmod (skipcrud + current_file_name, - notumask & (int) hstat.st_mode) < 0) - { - msg_perror ("cannot change mode of file %s to %ld", - skipcrud + current_file_name, - notumask & (int) hstat.st_mode); - } - } - } - break; - - case LF_VOLHDR: - if (f_verbose) - { - printf ("Reading %s\n", current_file_name); - } - break; - - case LF_NAMES: - extract_mangle (head); - break; - - case LF_MULTIVOL: - msg ("Can't extract '%s'--file is continued from another volume\n", current_file_name); - skip_file ((long) hstat.st_size); - break; - - case LF_LONGNAME: - case LF_LONGLINK: - msg ("Visible long name error\n"); - skip_file ((long) hstat.st_size); - break; - } - - /* We don't need to save it any longer. */ - saverec ((union record **) 0);/* Unsave it */ -} - -/* - * After a file/link/symlink/dir creation has failed, see if - * it's because some required directory was not present, and if - * so, create all required dirs. - */ -int -make_dirs (pathname) - char *pathname; -{ - char *p; /* Points into path */ - int madeone = 0; /* Did we do anything yet? */ - int save_errno = errno; /* Remember caller's errno */ - int check; - - if (errno != ENOENT) - return 0; /* Not our problem */ - - for (p = index (pathname, '/'); p != NULL; p = index (p + 1, '/')) - { - /* Avoid mkdir of empty string, if leading or double '/' */ - if (p == pathname || p[-1] == '/') - continue; - /* Avoid mkdir where last part of path is '.' */ - if (p[-1] == '.' && (p == pathname + 1 || p[-2] == '/')) - continue; - *p = 0; /* Truncate the path there */ - check = mkdir (pathname, 0777); /* Try to create it as a dir */ - if (check == 0) - { - /* Fix ownership */ - if (we_are_root) - { - if (chown (pathname, hstat.st_uid, - hstat.st_gid) < 0) - { - msg_perror ("cannot change owner of %s to uid %d gid %d", pathname, hstat.st_uid, hstat.st_gid); - } - } - pr_mkdir (pathname, p - pathname, notumask & 0777); - madeone++; /* Remember if we made one */ - *p = '/'; - continue; - } - *p = '/'; - if (errno == EEXIST) /* Directory already exists */ - continue; - /* - * Some other error in the mkdir. We return to the caller. - */ - break; - } - - errno = save_errno; /* Restore caller's errno */ - return madeone; /* Tell them to retry if we made one */ -} - -void -extract_sparse_file (fd, sizeleft, totalsize, name) - int fd; - long *sizeleft, totalsize; - char *name; -{ - /* register char *data;*/ - union record *datarec; - int sparse_ind = 0; - int written, count; - - /* assuming sizeleft is initially totalsize */ - - - while (*sizeleft > 0) - { - datarec = findrec (); - if (datarec == NULL) - { - msg ("Unexpected EOF on archive file"); - return; - } - lseek (fd, sparsearray[sparse_ind].offset, 0); - written = sparsearray[sparse_ind++].numbytes; - while (written > RECORDSIZE) - { - count = write (fd, datarec->charptr, RECORDSIZE); - if (count < 0) - msg_perror ("couldn't write to file %s", name); - written -= count; - *sizeleft -= count; - userec (datarec); - datarec = findrec (); - } - - count = write (fd, datarec->charptr, written); - - if (count < 0) - { - msg_perror ("couldn't write to file %s", name); - } - else if (count != written) - { - msg ("could only write %d of %d bytes to file %s", count, - totalsize, name); - skip_file ((long) (*sizeleft)); - } - - written -= count; - *sizeleft -= count; - userec (datarec); - } - free (sparsearray); - /* if (end_nulls) { - register int i; - - printf("%d\n", (int) end_nulls); - for (i = 0; i < end_nulls; i++) - write(fd, "\000", 1); - }*/ - userec (datarec); -} - -/* Set back the utime and mode for all the extracted directories. */ -void -restore_saved_dir_info () -{ - struct utimbuf acc_upd_times; - - while (saved_dir_info_head != NULL) - { - /* fixme if f_gnudump should set ctime too, but how? */ - if (f_gnudump) - acc_upd_times.actime = saved_dir_info_head->atime; - else - acc_upd_times.actime = now; /* Accessed now */ - acc_upd_times.modtime = saved_dir_info_head->mtime; /* Mod'd */ - if (utime (saved_dir_info_head->path, &acc_upd_times) < 0) - { - msg_perror ("couldn't change access and modification times of %s", - saved_dir_info_head->path); - } - if ((!f_keep) || (saved_dir_info_head->mode & (S_ISUID | S_ISGID | S_ISVTX))) - { - if (chmod (saved_dir_info_head->path, - notumask & saved_dir_info_head->mode) < 0) - { - msg_perror ("cannot change mode of file %s to %ld", - saved_dir_info_head->path, - notumask & saved_dir_info_head->mode); - } - } - saved_dir_info_head = saved_dir_info_head->next; - } -} diff --git a/gnu/usr.bin/tar-1.11.2/fnmatch.c b/gnu/usr.bin/tar-1.11.2/fnmatch.c deleted file mode 100644 index ed8c9eea7e35..000000000000 --- a/gnu/usr.bin/tar-1.11.2/fnmatch.c +++ /dev/null @@ -1,173 +0,0 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. - -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; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#include -#include - -#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) -extern int errno; -#endif - -/* Match STRING against the filename pattern PATTERN, returning zero if - it matches, nonzero if not. */ -int -fnmatch (pattern, string, flags) - const char *pattern; - const char *string; - int flags; -{ - register const char *p = pattern, *n = string; - register char c; - - if ((flags & ~__FNM_FLAGS) != 0) - { - errno = EINVAL; - return -1; - } - - while ((c = *p++) != '\0') - { - switch (c) - { - case '?': - if (*n == '\0') - return FNM_NOMATCH; - else if ((flags & FNM_PATHNAME) && *n == '/') - return FNM_NOMATCH; - else if ((flags & FNM_PERIOD) && *n == '.' && - (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/'))) - return FNM_NOMATCH; - break; - - case '\\': - if (!(flags & FNM_NOESCAPE)) - c = *p++; - if (*n != c) - return FNM_NOMATCH; - break; - - case '*': - if ((flags & FNM_PERIOD) && *n == '.' && - (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/'))) - return FNM_NOMATCH; - - for (c = *p++; c == '?' || c == '*'; c = *p++, ++n) - if (((flags & FNM_PATHNAME) && *n == '/') || - (c == '?' && *n == '\0')) - return FNM_NOMATCH; - - if (c == '\0') - return 0; - - { - char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c; - for (--p; *n != '\0'; ++n) - if ((c == '[' || *n == c1) && - fnmatch (p, n, flags & ~FNM_PERIOD) == 0) - return 0; - return FNM_NOMATCH; - } - - case '[': - { - /* Nonzero if the sense of the character class is inverted. */ - register int not; - - if (*n == '\0') - return FNM_NOMATCH; - - if ((flags & FNM_PERIOD) && *n == '.' && - (n == string || ((flags & FNM_PATHNAME) && n[-1] == '/'))) - return FNM_NOMATCH; - - not = (*p == '!' || *p == '^'); - if (not) - ++p; - - c = *p++; - for (;;) - { - register char cstart = c, cend = c; - - if (!(flags & FNM_NOESCAPE) && c == '\\') - cstart = cend = *p++; - - if (c == '\0') - /* [ (unterminated) loses. */ - return FNM_NOMATCH; - - c = *p++; - - if ((flags & FNM_PATHNAME) && c == '/') - /* [/] can never match. */ - return FNM_NOMATCH; - - if (c == '-' && *p != ']') - { - cend = *p++; - if (!(flags & FNM_NOESCAPE) && cend == '\\') - cend = *p++; - if (cend == '\0') - return FNM_NOMATCH; - c = *p++; - } - - if (*n >= cstart && *n <= cend) - goto matched; - - if (c == ']') - break; - } - if (!not) - return FNM_NOMATCH; - break; - - matched:; - /* Skip the rest of the [...] that already matched. */ - while (c != ']') - { - if (c == '\0') - /* [... (unterminated) loses. */ - return FNM_NOMATCH; - - c = *p++; - if (!(flags & FNM_NOESCAPE) && c == '\\') - /* 1003.2d11 is unclear if this is right. %%% */ - ++p; - } - if (not) - return FNM_NOMATCH; - } - break; - - default: - if (c != *n) - return FNM_NOMATCH; - } - - ++n; - } - - if (*n == '\0') - return 0; - - if ((flags & FNM_LEADING_DIR) && *n == '/') - /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ - return 0; - - return FNM_NOMATCH; -} diff --git a/gnu/usr.bin/tar-1.11.2/fnmatch.h b/gnu/usr.bin/tar-1.11.2/fnmatch.h deleted file mode 100644 index d4150a9a9969..000000000000 --- a/gnu/usr.bin/tar-1.11.2/fnmatch.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. - -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; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ - -#ifndef _FNMATCH_H - -#define _FNMATCH_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined (__cplusplus) || (defined (__STDC__) && __STDC__) -#undef __P -#define __P(args) args -#else /* Not C++ or ANSI C. */ -#undef __P -#define __P(args) () -#undef const -#define const -#endif /* C++ or ANSI C. */ - -/* Bits set in the FLAGS argument to `fnmatch'. */ -#ifdef FNM_PATHNAME /* Because it is already defined in */ -#undef FNM_PATHNAME -#endif -#define FNM_PATHNAME (1 << 0)/* No wildcard can ever match `/'. */ -#define FNM_NOESCAPE (1 << 1)/* Backslashes don't quote special chars. */ -#define FNM_PERIOD (1 << 2)/* Leading `.' is matched only explicitly. */ -#define __FNM_FLAGS (FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD|FNM_LEADING_DIR) - -#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_BSD_SOURCE) -#define FNM_LEADING_DIR (1 << 3)/* Ignore `/...' after a match. */ -#define FNM_FILE_NAME FNM_PATHNAME -#endif - -/* Value returned by `fnmatch' if STRING does not match PATTERN. */ -#define FNM_NOMATCH 1 - -/* Match STRING against the filename pattern PATTERN, - returning zero if it matches, FNM_NOMATCH if not. */ -extern int fnmatch __P ((const char *__pattern, const char *__string, - int __flags)); - -#ifdef __cplusplus -} -#endif - -#endif /* fnmatch.h */ diff --git a/gnu/usr.bin/tar-1.11.2/getdate.y b/gnu/usr.bin/tar-1.11.2/getdate.y deleted file mode 100644 index 29d780dbbd74..000000000000 --- a/gnu/usr.bin/tar-1.11.2/getdate.y +++ /dev/null @@ -1,969 +0,0 @@ -%{ -/* $Revision: 1.1 $ -** -** Originally written by Steven M. Bellovin while -** at the University of North Carolina at Chapel Hill. Later tweaked by -** a couple of people on Usenet. Completely overhauled by Rich $alz -** and Jim Berets in August, 1990; -** send any email to Rich. -** -** This grammar has eight shift/reduce conflicts. -** -** This code is in the public domain and has no copyright. -*/ -/* SUPPRESS 287 on yaccpar_sccsid *//* Unusd static variable */ -/* SUPPRESS 288 on yyerrlab *//* Label unused */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#ifdef HAVE_ALLOCA_H -#include -#else -#ifdef _AIX /* for Bison */ - #pragma alloca -#else -char *alloca (); -#endif -#endif -#endif - -#include -#include - -/* The code at the top of get_date which figures out the offset of the - current time zone checks various CPP symbols to see if special - tricks are need, but defaults to using the gettimeofday system call. - Include if that will be used. */ - -#if !defined (USG) && !defined (sgi) && !defined (__386BSD__) -#include -#endif - -#if defined(vms) - -#include -#include - -#else - -#include - -#if defined(USG) || !defined(HAVE_FTIME) -/* -** If you need to do a tzset() call to set the -** timezone, and don't have ftime(). -*/ -struct timeb { - time_t time; /* Seconds since the epoch */ - unsigned short millitm; /* Field not used */ - short timezone; - short dstflag; /* Field not used */ -}; - -#else - -#include - -#endif /* defined(USG) && !defined(HAVE_FTIME) */ - -#if defined(BSD4_2) || defined(BSD4_1C) || (defined (hp9000) && !defined (hpux)) -#include -#else -#if defined(_AIX) -#include -#endif -#include -#endif /* defined(BSD4_2) */ - -#endif /* defined(vms) */ - -#if defined (STDC_HEADERS) || defined (USG) -#include -#endif - -#if sgi -#undef timezone -#endif - -extern struct tm *localtime(); - -#define yyparse getdate_yyparse -#define yylex getdate_yylex -#define yyerror getdate_yyerror - -#if !defined(lint) && !defined(SABER) -static char RCS[] = - "$Header: /cvsroot/src/gnu/usr.bin/tar-1.11.2/Attic/getdate.y,v 1.1 1993/06/29 14:51:11 brezak Exp $"; -#endif /* !defined(lint) && !defined(SABER) */ - - -#define EPOCH 1970 -#define HOUR(x) ((time_t)(x) * 60) -#define SECSPERDAY (24L * 60L * 60L) - - -/* -** An entry in the lexical lookup table. -*/ -typedef struct _TABLE { - char *name; - int type; - time_t value; -} TABLE; - - -/* -** Daylight-savings mode: on, off, or not yet known. -*/ -typedef enum _DSTMODE { - DSTon, DSToff, DSTmaybe -} DSTMODE; - -/* -** Meridian: am, pm, or 24-hour style. -*/ -typedef enum _MERIDIAN { - MERam, MERpm, MER24 -} MERIDIAN; - - -/* -** Global variables. We could get rid of most of these by using a good -** union as the yacc stack. (This routine was originally written before -** yacc had the %union construct.) Maybe someday; right now we only use -** the %union very rarely. -*/ -static char *yyInput; -static DSTMODE yyDSTmode; -static time_t yyDayOrdinal; -static time_t yyDayNumber; -static int yyHaveDate; -static int yyHaveDay; -static int yyHaveRel; -static int yyHaveTime; -static int yyHaveZone; -static time_t yyTimezone; -static time_t yyDay; -static time_t yyHour; -static time_t yyMinutes; -static time_t yyMonth; -static time_t yySeconds; -static time_t yyYear; -static MERIDIAN yyMeridian; -static time_t yyRelMonth; -static time_t yyRelSeconds; - -%} - -%union { - time_t Number; - enum _MERIDIAN Meridian; -} - -%token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT -%token tSEC_UNIT tSNUMBER tUNUMBER tZONE tDST - -%type tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT -%type tSEC_UNIT tSNUMBER tUNUMBER tZONE -%type tMERIDIAN o_merid - -%% - -spec : /* NULL */ - | spec item - ; - -item : time { - yyHaveTime++; - } - | zone { - yyHaveZone++; - } - | date { - yyHaveDate++; - } - | day { - yyHaveDay++; - } - | rel { - yyHaveRel++; - } - | number - ; - -time : tUNUMBER tMERIDIAN { - yyHour = $1; - yyMinutes = 0; - yySeconds = 0; - yyMeridian = $2; - } - | tUNUMBER ':' tUNUMBER o_merid { - yyHour = $1; - yyMinutes = $3; - yySeconds = 0; - yyMeridian = $4; - } - | tUNUMBER ':' tUNUMBER tSNUMBER { - yyHour = $1; - yyMinutes = $3; - yyMeridian = MER24; - yyDSTmode = DSToff; - yyTimezone = - ($4 % 100 + ($4 / 100) * 60); - } - | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid { - yyHour = $1; - yyMinutes = $3; - yySeconds = $5; - yyMeridian = $6; - } - | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER { - yyHour = $1; - yyMinutes = $3; - yySeconds = $5; - yyMeridian = MER24; - yyDSTmode = DSToff; - yyTimezone = - ($6 % 100 + ($6 / 100) * 60); - } - ; - -zone : tZONE { - yyTimezone = $1; - yyDSTmode = DSToff; - } - | tDAYZONE { - yyTimezone = $1; - yyDSTmode = DSTon; - } - | - tZONE tDST { - yyTimezone = $1; - yyDSTmode = DSTon; - } - ; - -day : tDAY { - yyDayOrdinal = 1; - yyDayNumber = $1; - } - | tDAY ',' { - yyDayOrdinal = 1; - yyDayNumber = $1; - } - | tUNUMBER tDAY { - yyDayOrdinal = $1; - yyDayNumber = $2; - } - ; - -date : tUNUMBER '/' tUNUMBER { - yyMonth = $1; - yyDay = $3; - } - | tUNUMBER '/' tUNUMBER '/' tUNUMBER { - yyMonth = $1; - yyDay = $3; - yyYear = $5; - } - | tUNUMBER tSNUMBER tSNUMBER { - /* ISO 8601 format. yyyy-mm-dd. */ - yyYear = $1; - yyMonth = -$2; - yyDay = -$3; - } - | tMONTH tUNUMBER { - yyMonth = $1; - yyDay = $2; - } - | tMONTH tUNUMBER ',' tUNUMBER { - yyMonth = $1; - yyDay = $2; - yyYear = $4; - } - | tUNUMBER tMONTH { - yyMonth = $2; - yyDay = $1; - } - | tUNUMBER tMONTH tUNUMBER { - yyMonth = $2; - yyDay = $1; - yyYear = $3; - } - ; - -rel : relunit tAGO { - yyRelSeconds = -yyRelSeconds; - yyRelMonth = -yyRelMonth; - } - | relunit - ; - -relunit : tUNUMBER tMINUTE_UNIT { - yyRelSeconds += $1 * $2 * 60L; - } - | tSNUMBER tMINUTE_UNIT { - yyRelSeconds += $1 * $2 * 60L; - } - | tMINUTE_UNIT { - yyRelSeconds += $1 * 60L; - } - | tSNUMBER tSEC_UNIT { - yyRelSeconds += $1; - } - | tUNUMBER tSEC_UNIT { - yyRelSeconds += $1; - } - | tSEC_UNIT { - yyRelSeconds++; - } - | tSNUMBER tMONTH_UNIT { - yyRelMonth += $1 * $2; - } - | tUNUMBER tMONTH_UNIT { - yyRelMonth += $1 * $2; - } - | tMONTH_UNIT { - yyRelMonth += $1; - } - ; - -number : tUNUMBER { - if (yyHaveTime && yyHaveDate && !yyHaveRel) - yyYear = $1; - else { - if($1>10000) { - time_t date_part; - - date_part= $1/10000; - yyHaveDate++; - yyDay= (date_part)%100; - yyMonth= (date_part/100)%100; - yyYear = date_part/10000; - } - yyHaveTime++; - if ($1 < 100) { - yyHour = $1; - yyMinutes = 0; - } - else { - yyHour = $1 / 100; - yyMinutes = $1 % 100; - } - yySeconds = 0; - yyMeridian = MER24; - } - } - ; - -o_merid : /* NULL */ { - $$ = MER24; - } - | tMERIDIAN { - $$ = $1; - } - ; - -%% - -/* Month and day table. */ -static TABLE const MonthDayTable[] = { - { "january", tMONTH, 1 }, - { "february", tMONTH, 2 }, - { "march", tMONTH, 3 }, - { "april", tMONTH, 4 }, - { "may", tMONTH, 5 }, - { "june", tMONTH, 6 }, - { "july", tMONTH, 7 }, - { "august", tMONTH, 8 }, - { "september", tMONTH, 9 }, - { "sept", tMONTH, 9 }, - { "october", tMONTH, 10 }, - { "november", tMONTH, 11 }, - { "december", tMONTH, 12 }, - { "sunday", tDAY, 0 }, - { "monday", tDAY, 1 }, - { "tuesday", tDAY, 2 }, - { "tues", tDAY, 2 }, - { "wednesday", tDAY, 3 }, - { "wednes", tDAY, 3 }, - { "thursday", tDAY, 4 }, - { "thur", tDAY, 4 }, - { "thurs", tDAY, 4 }, - { "friday", tDAY, 5 }, - { "saturday", tDAY, 6 }, - { NULL } -}; - -/* Time units table. */ -static TABLE const UnitsTable[] = { - { "year", tMONTH_UNIT, 12 }, - { "month", tMONTH_UNIT, 1 }, - { "fortnight", tMINUTE_UNIT, 14 * 24 * 60 }, - { "week", tMINUTE_UNIT, 7 * 24 * 60 }, - { "day", tMINUTE_UNIT, 1 * 24 * 60 }, - { "hour", tMINUTE_UNIT, 60 }, - { "minute", tMINUTE_UNIT, 1 }, - { "min", tMINUTE_UNIT, 1 }, - { "second", tSEC_UNIT, 1 }, - { "sec", tSEC_UNIT, 1 }, - { NULL } -}; - -/* Assorted relative-time words. */ -static TABLE const OtherTable[] = { - { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 }, - { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 }, - { "today", tMINUTE_UNIT, 0 }, - { "now", tMINUTE_UNIT, 0 }, - { "last", tUNUMBER, -1 }, - { "this", tMINUTE_UNIT, 0 }, - { "next", tUNUMBER, 2 }, - { "first", tUNUMBER, 1 }, -/* { "second", tUNUMBER, 2 }, */ - { "third", tUNUMBER, 3 }, - { "fourth", tUNUMBER, 4 }, - { "fifth", tUNUMBER, 5 }, - { "sixth", tUNUMBER, 6 }, - { "seventh", tUNUMBER, 7 }, - { "eighth", tUNUMBER, 8 }, - { "ninth", tUNUMBER, 9 }, - { "tenth", tUNUMBER, 10 }, - { "eleventh", tUNUMBER, 11 }, - { "twelfth", tUNUMBER, 12 }, - { "ago", tAGO, 1 }, - { NULL } -}; - -/* The timezone table. */ -/* Some of these are commented out because a time_t can't store a float. */ -static TABLE const TimezoneTable[] = { - { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ - { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */ - { "utc", tZONE, HOUR( 0) }, - { "wet", tZONE, HOUR( 0) }, /* Western European */ - { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */ - { "wat", tZONE, HOUR( 1) }, /* West Africa */ - { "at", tZONE, HOUR( 2) }, /* Azores */ -#if 0 - /* For completeness. BST is also British Summer, and GST is - * also Guam Standard. */ - { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */ - { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */ -#endif -#if 0 - { "nft", tZONE, HOUR(3.5) }, /* Newfoundland */ - { "nst", tZONE, HOUR(3.5) }, /* Newfoundland Standard */ - { "ndt", tDAYZONE, HOUR(3.5) }, /* Newfoundland Daylight */ -#endif - { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */ - { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */ - { "est", tZONE, HOUR( 5) }, /* Eastern Standard */ - { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */ - { "cst", tZONE, HOUR( 6) }, /* Central Standard */ - { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */ - { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */ - { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */ - { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */ - { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */ - { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */ - { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */ - { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */ - { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */ - { "cat", tZONE, HOUR(10) }, /* Central Alaska */ - { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */ - { "nt", tZONE, HOUR(11) }, /* Nome */ - { "idlw", tZONE, HOUR(12) }, /* International Date Line West */ - { "cet", tZONE, -HOUR(1) }, /* Central European */ - { "met", tZONE, -HOUR(1) }, /* Middle European */ - { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */ - { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */ - { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */ - { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */ - { "fwt", tZONE, -HOUR(1) }, /* French Winter */ - { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */ - { "eet", tZONE, -HOUR(2) }, /* Eastern Europe, USSR Zone 1 */ - { "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */ -#if 0 - { "it", tZONE, -HOUR(3.5) },/* Iran */ -#endif - { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */ - { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */ -#if 0 - { "ist", tZONE, -HOUR(5.5) },/* Indian Standard */ -#endif - { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */ -#if 0 - /* For completeness. NST is also Newfoundland Stanard, and SST is - * also Swedish Summer. */ - { "nst", tZONE, -HOUR(6.5) },/* North Sumatra */ - { "sst", tZONE, -HOUR(7) }, /* South Sumatra, USSR Zone 6 */ -#endif /* 0 */ - { "wast", tZONE, -HOUR(7) }, /* West Australian Standard */ - { "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */ -#if 0 - { "jt", tZONE, -HOUR(7.5) },/* Java (3pm in Cronusland!) */ -#endif - { "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */ - { "jst", tZONE, -HOUR(9) }, /* Japan Standard, USSR Zone 8 */ -#if 0 - { "cast", tZONE, -HOUR(9.5) },/* Central Australian Standard */ - { "cadt", tDAYZONE, -HOUR(9.5) },/* Central Australian Daylight */ -#endif - { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */ - { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */ - { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */ - { "nzt", tZONE, -HOUR(12) }, /* New Zealand */ - { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */ - { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */ - { "idle", tZONE, -HOUR(12) }, /* International Date Line East */ - { NULL } -}; - -/* Military timezone table. */ -static TABLE const MilitaryTable[] = { - { "a", tZONE, HOUR( 1) }, - { "b", tZONE, HOUR( 2) }, - { "c", tZONE, HOUR( 3) }, - { "d", tZONE, HOUR( 4) }, - { "e", tZONE, HOUR( 5) }, - { "f", tZONE, HOUR( 6) }, - { "g", tZONE, HOUR( 7) }, - { "h", tZONE, HOUR( 8) }, - { "i", tZONE, HOUR( 9) }, - { "k", tZONE, HOUR( 10) }, - { "l", tZONE, HOUR( 11) }, - { "m", tZONE, HOUR( 12) }, - { "n", tZONE, HOUR(- 1) }, - { "o", tZONE, HOUR(- 2) }, - { "p", tZONE, HOUR(- 3) }, - { "q", tZONE, HOUR(- 4) }, - { "r", tZONE, HOUR(- 5) }, - { "s", tZONE, HOUR(- 6) }, - { "t", tZONE, HOUR(- 7) }, - { "u", tZONE, HOUR(- 8) }, - { "v", tZONE, HOUR(- 9) }, - { "w", tZONE, HOUR(-10) }, - { "x", tZONE, HOUR(-11) }, - { "y", tZONE, HOUR(-12) }, - { "z", tZONE, HOUR( 0) }, - { NULL } -}; - - - - -/* ARGSUSED */ -static int -yyerror(s) - char *s; -{ - return 0; -} - - -static time_t -ToSeconds(Hours, Minutes, Seconds, Meridian) - time_t Hours; - time_t Minutes; - time_t Seconds; - MERIDIAN Meridian; -{ - if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) - return -1; - switch (Meridian) { - case MER24: - if (Hours < 0 || Hours > 23) - return -1; - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERam: - if (Hours < 1 || Hours > 12) - return -1; - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERpm: - if (Hours < 1 || Hours > 12) - return -1; - return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; - } - /* NOTREACHED */ -} - - -static time_t -Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) - time_t Month; - time_t Day; - time_t Year; - time_t Hours; - time_t Minutes; - time_t Seconds; - MERIDIAN Meridian; - DSTMODE DSTmode; -{ - static int DaysInMonth[12] = { - 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - time_t tod; - time_t Julian; - int i; - - if (Year < 0) - Year = -Year; - if (Year < 100) - Year += 1900; - DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) - ? 29 : 28; - if (Year < EPOCH || Year > 1999 - || Month < 1 || Month > 12 - /* Lint fluff: "conversion from long may lose accuracy" */ - || Day < 1 || Day > DaysInMonth[(int)--Month]) - return -1; - - for (Julian = Day - 1, i = 0; i < Month; i++) - Julian += DaysInMonth[i]; - for (i = EPOCH; i < Year; i++) - Julian += 365 + (i % 4 == 0); - Julian *= SECSPERDAY; - Julian += yyTimezone * 60L; - if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0) - return -1; - Julian += tod; - if (DSTmode == DSTon - || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst)) - Julian -= 60 * 60; - return Julian; -} - - -static time_t -DSTcorrect(Start, Future) - time_t Start; - time_t Future; -{ - time_t StartDay; - time_t FutureDay; - - StartDay = (localtime(&Start)->tm_hour + 1) % 24; - FutureDay = (localtime(&Future)->tm_hour + 1) % 24; - return (Future - Start) + (StartDay - FutureDay) * 60L * 60L; -} - - -static time_t -RelativeDate(Start, DayOrdinal, DayNumber) - time_t Start; - time_t DayOrdinal; - time_t DayNumber; -{ - struct tm *tm; - time_t now; - - now = Start; - tm = localtime(&now); - now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7); - now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); - return DSTcorrect(Start, now); -} - - -static time_t -RelativeMonth(Start, RelMonth) - time_t Start; - time_t RelMonth; -{ - struct tm *tm; - time_t Month; - time_t Year; - - if (RelMonth == 0) - return 0; - tm = localtime(&Start); - Month = 12 * tm->tm_year + tm->tm_mon + RelMonth; - Year = Month / 12; - Month = Month % 12 + 1; - return DSTcorrect(Start, - Convert(Month, (time_t)tm->tm_mday, Year, - (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, - MER24, DSTmaybe)); -} - - -static int -LookupWord(buff) - char *buff; -{ - register char *p; - register char *q; - register const TABLE *tp; - int i; - int abbrev; - - /* Make it lowercase. */ - for (p = buff; *p; p++) - if (isupper(*p)) - *p = tolower(*p); - - if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) { - yylval.Meridian = MERam; - return tMERIDIAN; - } - if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) { - yylval.Meridian = MERpm; - return tMERIDIAN; - } - - /* See if we have an abbreviation for a month. */ - if (strlen(buff) == 3) - abbrev = 1; - else if (strlen(buff) == 4 && buff[3] == '.') { - abbrev = 1; - buff[3] = '\0'; - } - else - abbrev = 0; - - for (tp = MonthDayTable; tp->name; tp++) { - if (abbrev) { - if (strncmp(buff, tp->name, 3) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - else if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - - for (tp = TimezoneTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - if (strcmp(buff, "dst") == 0) - return tDST; - - for (tp = UnitsTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - /* Strip off any plural and try the units table again. */ - i = strlen(buff) - 1; - if (buff[i] == 's') { - buff[i] = '\0'; - for (tp = UnitsTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - buff[i] = 's'; /* Put back for "this" in OtherTable. */ - } - - for (tp = OtherTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - /* Military timezones. */ - if (buff[1] == '\0' && isalpha(*buff)) { - for (tp = MilitaryTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - } - - /* Drop out any periods and try the timezone table again. */ - for (i = 0, p = q = buff; *q; q++) - if (*q != '.') - *p++ = *q; - else - i++; - *p = '\0'; - if (i) - for (tp = TimezoneTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return tp->type; - } - - return tID; -} - - -static int -yylex() -{ - register char c; - register char *p; - char buff[20]; - int Count; - int sign; - - for ( ; ; ) { - while (isspace(*yyInput)) - yyInput++; - - if (isdigit(c = *yyInput) || c == '-' || c == '+') { - if (c == '-' || c == '+') { - sign = c == '-' ? -1 : 1; - if (!isdigit(*++yyInput)) - /* skip the '-' sign */ - continue; - } - else - sign = 0; - for (yylval.Number = 0; isdigit(c = *yyInput++); ) - yylval.Number = 10 * yylval.Number + c - '0'; - yyInput--; - if (sign < 0) - yylval.Number = -yylval.Number; - return sign ? tSNUMBER : tUNUMBER; - } - if (isalpha(c)) { - for (p = buff; isalpha(c = *yyInput++) || c == '.'; ) - if (p < &buff[sizeof buff - 1]) - *p++ = c; - *p = '\0'; - yyInput--; - return LookupWord(buff); - } - if (c != '(') - return *yyInput++; - Count = 0; - do { - c = *yyInput++; - if (c == '\0') - return c; - if (c == '(') - Count++; - else if (c == ')') - Count--; - } while (Count > 0); - } -} - - -time_t -get_date(p, now) - char *p; - struct timeb *now; -{ - struct tm *tm; - struct timeb ftz; - time_t Start; - time_t tod; - - yyInput = p; - if (now == NULL) { - now = &ftz; -#if !defined(HAVE_FTIME) - (void)time(&ftz.time); - /* Set the timezone global. */ - tzset(); - { -#if sgi - ftz.timezone = (int) _timezone / 60; -#else /* not sgi */ -#ifdef __386BSD__ - ftz.timezone = 0; -#else /* neither sgi nor 386BSD */ -#if defined (USG) - extern time_t timezone; - - ftz.timezone = (int) timezone / 60; -#else /* neither sgi nor 386BSD nor USG */ - struct timeval tv; - struct timezone tz; - - gettimeofday (&tv, &tz); - ftz.timezone = (int) tz.tz_minuteswest; -#endif /* neither sgi nor 386BSD nor USG */ -#endif /* neither sgi nor 386BSD */ -#endif /* not sgi */ - } -#else /* HAVE_FTIME */ - (void)ftime(&ftz); -#endif /* HAVE_FTIME */ - } - - tm = localtime(&now->time); - yyYear = tm->tm_year; - yyMonth = tm->tm_mon + 1; - yyDay = tm->tm_mday; - yyTimezone = now->timezone; - yyDSTmode = DSTmaybe; - yyHour = 0; - yyMinutes = 0; - yySeconds = 0; - yyMeridian = MER24; - yyRelSeconds = 0; - yyRelMonth = 0; - yyHaveDate = 0; - yyHaveDay = 0; - yyHaveRel = 0; - yyHaveTime = 0; - yyHaveZone = 0; - - if (yyparse() - || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1) - return -1; - - if (yyHaveDate || yyHaveTime || yyHaveDay) { - Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds, - yyMeridian, yyDSTmode); - if (Start < 0) - return -1; - } - else { - Start = now->time; - if (!yyHaveRel) - Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec; - } - - Start += yyRelSeconds; - Start += RelativeMonth(Start, yyRelMonth); - - if (yyHaveDay && !yyHaveDate) { - tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber); - Start += tod; - } - - /* Have to do *something* with a legitimate -1 so it's distinguishable - * from the error return value. (Alternately could set errno on error.) */ - return Start == -1 ? 0 : Start; -} - - -#if defined(TEST) - -/* ARGSUSED */ -main(ac, av) - int ac; - char *av[]; -{ - char buff[128]; - time_t d; - - (void)printf("Enter date, or blank line to exit.\n\t> "); - (void)fflush(stdout); - while (gets(buff) && buff[0]) { - d = get_date(buff, (struct timeb *)NULL); - if (d == -1) - (void)printf("Bad format - couldn't convert.\n"); - else - (void)printf("%s", ctime(&d)); - (void)printf("\t> "); - (void)fflush(stdout); - } - exit(0); - /* NOTREACHED */ -} -#endif /* defined(TEST) */ diff --git a/gnu/usr.bin/tar-1.11.2/getoldopt.c b/gnu/usr.bin/tar-1.11.2/getoldopt.c deleted file mode 100644 index 27511b94b342..000000000000 --- a/gnu/usr.bin/tar-1.11.2/getoldopt.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Replacement for getopt() that can be used by tar. - Copyright (C) 1988 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Plug-compatible replacement for getopt() for parsing tar-like - * arguments. If the first argument begins with "-", it uses getopt; - * otherwise, it uses the old rules used by tar, dump, and ps. - * - * Written 25 August 1985 by John Gilmore (ihnp4!hoptoad!gnu) - */ - -#include -#include "getopt.h" -#include "tar.h" /* For msg() declaration if STDC_MSG. */ -#include -#include "port.h" - -int -getoldopt (argc, argv, optstring, long_options, opt_index) - int argc; - char **argv; - char *optstring; - struct option *long_options; - int *opt_index; -{ - extern char *optarg; /* Points to next arg */ - extern int optind; /* Global argv index */ - static char *key; /* Points to next keyletter */ - static char use_getopt; /* !=0 if argv[1][0] was '-' */ - char c; - char *place; - - optarg = NULL; - - if (key == NULL) - { /* First time */ - if (argc < 2) - return EOF; - key = argv[1]; - if ((*key == '-') || (*key == '+')) - use_getopt++; - else - optind = 2; - } - - if (use_getopt) - return getopt_long (argc, argv, optstring, - long_options, opt_index); - - c = *key++; - if (c == '\0') - { - key--; - return EOF; - } - place = index (optstring, c); - - if (place == NULL || c == ':') - { - msg ("unknown option %c", c); - return ('?'); - } - - place++; - if (*place == ':') - { - if (optind < argc) - { - optarg = argv[optind]; - optind++; - } - else - { - msg ("%c argument missing", c); - return ('?'); - } - } - - return (c); -} diff --git a/gnu/usr.bin/tar-1.11.2/getopt.c b/gnu/usr.bin/tar-1.11.2/getopt.c deleted file mode 100644 index 3db9abf121b9..000000000000 --- a/gnu/usr.bin/tar-1.11.2/getopt.c +++ /dev/null @@ -1,712 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu - before changing it! - - Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 - 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* NOTE!!! AIX requires this to be the first thing in the file. - Do not put ANYTHING before it! */ -#if !defined (__GNUC__) && defined (_AIX) - #pragma alloca -#endif - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__)))) -#include -#else -#ifndef _AIX -char *alloca (); -#endif -#endif /* alloca.h */ -#endif /* not __GNUC__ */ - -#if !__STDC__ && !defined(const) && IN_GCC -#define const -#endif - -#include - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#undef alloca -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -#include -#else /* Not GNU C library. */ -#define __alloca alloca -#endif /* GNU C library. */ - -/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a - long-named option. Because this is not POSIX.2 compliant, it is - being phased out. */ -/* #define GETOPT_COMPAT */ - -/* 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 POSIXLY_CORRECT 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 "getopt.h" - -/* 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. */ - -/* XXX 1003.2 says this must be 1 before any call. */ -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; - -/* Set to an option character which was unrecognized. - This must be initialized on some systems to avoid linking in the - system's own getopt implementation. */ - -int optopt = '?'; - -/* 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 - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the 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; - -#ifdef __GNU_LIBRARY__ -/* We want to avoid inclusion of string.h with non-GNU libraries - because there are many ways it can cause trouble. - On some systems, it contains special magic macros that don't work - in GCC. */ -#include -#define my_index strchr -#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) -#else - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -char *getenv (); - -static char * -my_index (string, chr) - char *string; - int chr; -{ - while (*string) - { - if (*string == chr) - return string; - string++; - } - return 0; -} - -static void -my_bcopy (from, to, size) - char *from, *to; - int size; -{ - int i; - for (i = 0; i < size; i++) - to[i] = from[i]; -} -#endif /* GNU C library. */ - -/* 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. */ - - my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size); - my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt], - (optind - last_nonopt) * sizeof (char *)); - my_bcopy ((char *) temp, - (char *) &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 - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - int option_index; - - 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 = NULL; - - /* 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 ("POSIXLY_CORRECT") != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - } - - 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 ((char **) 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') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - 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 ((char **) 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') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - { - 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 - + (longopts != NULL && argv[optind][1] == '-')); - } - - if (longopts != NULL - && ((argv[optind][0] == '-' - && (argv[optind][1] == '-' || long_only)) -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - )) - { - const struct option *p; - char *s = nextchar; - int exact = 0; - int ambig = 0; - const struct option *pfound = NULL; - int indfound; - - while (*s && *s != '=') - s++; - - /* Test all options for either exact match or abbreviated matches. */ - for (p = longopts, 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 == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*s) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = s + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - else - /* +option or -option */ - 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 - { - if (opterr) - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, "%s: unrecognized option `--%s'\n", - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, "%s: unrecognized option `%c%s'\n", - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - return '?'; - } - } - - /* Look at and handle the next option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (opterr) - { -#if 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); -#else - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); -#endif - } - optopt = 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 = NULL; - } - 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) - { -#if 0 - fprintf (stderr, "%s: option `-%c' requires an argument\n", - argv[0], c); -#else - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: option requires an argument -- %c\n", - argv[0], c); -#endif - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -#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/gnu/usr.bin/tar-1.11.2/getopt.h b/gnu/usr.bin/tar-1.11.2/getopt.h deleted file mode 100644 index 93a5cf77816e..000000000000 --- a/gnu/usr.bin/tar-1.11.2/getopt.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* 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. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, 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 -{ -#if __STDC__ - const char *name; -#else - char *name; -#endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -#if __STDC__ -#if defined(__GNU_LIBRARY__) -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ -extern int getopt (); -#endif /* not __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* not __STDC__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* _GETOPT_H */ diff --git a/gnu/usr.bin/tar-1.11.2/getopt1.c b/gnu/usr.bin/tar-1.11.2/getopt1.c deleted file mode 100644 index c3582cfa5caf..000000000000 --- a/gnu/usr.bin/tar-1.11.2/getopt1.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Getopt for GNU. - Copyright (C) 1987, 88, 89, 90, 91, 1992 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "getopt.h" - -#if !__STDC__ && !defined(const) && IN_GCC -#define const -#endif - -#include - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include -#else -char *getenv (); -#endif - -#ifndef NULL -#define NULL 0 -#endif - -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') 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 *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - -#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; - 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 'd': - printf ("option d 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/gnu/usr.bin/tar-1.11.2/getpagesize.h b/gnu/usr.bin/tar-1.11.2/getpagesize.h deleted file mode 100644 index 2d43f262c79d..000000000000 --- a/gnu/usr.bin/tar-1.11.2/getpagesize.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifdef BSD -#ifndef BSD4_1 -#define HAVE_GETPAGESIZE -#endif -#endif - -#ifndef HAVE_GETPAGESIZE - -#ifdef VMS -#define getpagesize() 512 -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef _SC_PAGESIZE -#define getpagesize() sysconf(_SC_PAGESIZE) -#else - -#include - -#ifdef EXEC_PAGESIZE -#define getpagesize() EXEC_PAGESIZE -#else -#ifdef NBPG -#define getpagesize() NBPG * CLSIZE -#ifndef CLSIZE -#define CLSIZE 1 -#endif /* no CLSIZE */ -#else /* no NBPG */ -#define getpagesize() NBPC -#endif /* no NBPG */ -#endif /* no EXEC_PAGESIZE */ -#endif /* no _SC_PAGESIZE */ - -#endif /* not HAVE_GETPAGESIZE */ - diff --git a/gnu/usr.bin/tar-1.11.2/gnu.c b/gnu/usr.bin/tar-1.11.2/gnu.c deleted file mode 100644 index ef51f2b5fedd..000000000000 --- a/gnu/usr.bin/tar-1.11.2/gnu.c +++ /dev/null @@ -1,677 +0,0 @@ -/* GNU dump extensions to tar. - Copyright (C) 1988, 1992, 1993 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#ifndef STDC_HEADERS -extern int errno; -#endif -#include -time_t time (); - -#include "tar.h" -#include "port.h" - -#ifndef S_ISLNK -#define lstat stat -#endif - -extern time_t new_time; -extern FILE *msg_file; - -void addname (); -int check_exclude (); -extern PTR ck_malloc (); -extern PTR ck_realloc (); -int confirm (); -extern PTR init_buffer (); -extern char *get_buffer (); -int is_dot_or_dotdot (); -extern void add_buffer (); -extern void flush_buffer (); -void name_gather (); -int recursively_delete (); -void skip_file (); -char *un_quote_string (); - -extern char *new_name (); - -static void add_dir_name (); - -struct dirname - { - struct dirname *next; - char *name; - char *dir_text; - int dev; - int ino; - int allnew; - }; -static struct dirname *dir_list; -static time_t this_time; - -void -add_dir (name, dev, ino, text) - char *name; - char *text; - dev_t dev; - ino_t ino; -{ - struct dirname *dp; - - dp = (struct dirname *) ck_malloc (sizeof (struct dirname)); - if (!dp) - abort (); - dp->next = dir_list; - dir_list = dp; - dp->dev = dev; - dp->ino = ino; - dp->name = ck_malloc (strlen (name) + 1); - strcpy (dp->name, name); - dp->dir_text = text; - dp->allnew = 0; -} - -void -read_dir_file () -{ - int dev; - int ino; - char *strp; - FILE *fp; - char buf[512]; - static char *path = 0; - - if (path == 0) - path = ck_malloc (PATH_MAX); - time (&this_time); - if (gnu_dumpfile[0] != '/') - { -#if defined(__MSDOS__) || defined(HAVE_GETCWD) || defined(_POSIX_VERSION) - if (!getcwd (path, PATH_MAX)) - { - msg ("Couldn't get current directory."); - exit (EX_SYSTEM); - } -#else - char *getwd (); - - if (!getwd (path)) - { - msg ("Couldn't get current directory: %s", path); - exit (EX_SYSTEM); - } -#endif - /* If this doesn't fit, we're in serious trouble */ - strcat (path, "/"); - strcat (path, gnu_dumpfile); - gnu_dumpfile = path; - } - fp = fopen (gnu_dumpfile, "r"); - if (fp == 0 && errno != ENOENT) - { - msg_perror ("Can't open %s", gnu_dumpfile); - return; - } - if (!fp) - return; - fgets (buf, sizeof (buf), fp); - if (!f_new_files) - { - f_new_files++; - new_time = atol (buf); - } - while (fgets (buf, sizeof (buf), fp)) - { - strp = &buf[strlen (buf)]; - if (strp[-1] == '\n') - strp[-1] = '\0'; - strp = buf; - dev = atol (strp); - while (isdigit (*strp)) - strp++; - ino = atol (strp); - while (isspace (*strp)) - strp++; - while (isdigit (*strp)) - strp++; - strp++; - add_dir (un_quote_string (strp), dev, ino, (char *) 0); - } - fclose (fp); -} - -void -write_dir_file () -{ - FILE *fp; - struct dirname *dp; - char *str; - extern char *quote_copy_string (); - - fp = fopen (gnu_dumpfile, "w"); - if (fp == 0) - { - msg_perror ("Can't write to %s", gnu_dumpfile); - return; - } - fprintf (fp, "%lu\n", this_time); - for (dp = dir_list; dp; dp = dp->next) - { - if (!dp->dir_text) - continue; - str = quote_copy_string (dp->name); - if (str) - { - fprintf (fp, "%u %u %s\n", dp->dev, dp->ino, str); - free (str); - } - else - fprintf (fp, "%u %u %s\n", dp->dev, dp->ino, dp->name); - } - fclose (fp); -} - -struct dirname * -get_dir (name) - char *name; -{ - struct dirname *dp; - - for (dp = dir_list; dp; dp = dp->next) - { - if (!strcmp (dp->name, name)) - return dp; - } - return 0; -} - - -/* Collect all the names from argv[] (or whatever), then expand them into - a directory tree, and put all the directories at the beginning. */ -void -collect_and_sort_names () -{ - struct name *n, *n_next; - int num_names; - struct stat statbuf; - int name_cmp (); - char *merge_sort (); - - name_gather (); - - if (gnu_dumpfile) - read_dir_file (); - if (!namelist) - addname ("."); - for (n = namelist; n; n = n_next) - { - n_next = n->next; - if (n->found || n->dir_contents) - continue; - if (n->regexp) /* FIXME just skip regexps for now */ - continue; - if (n->change_dir) - if (chdir (n->change_dir) < 0) - { - msg_perror ("can't chdir to %s", n->change_dir); - continue; - } - -#ifdef AIX - if (statx (n->name, &statbuf, STATSIZE, STX_HIDDEN | STX_LINK)) -#else - if (lstat (n->name, &statbuf) < 0) -#endif /* AIX */ - { - msg_perror ("can't stat %s", n->name); - continue; - } - if (S_ISDIR (statbuf.st_mode)) - { - n->found++; - add_dir_name (n->name, statbuf.st_dev); - } - } - - num_names = 0; - for (n = namelist; n; n = n->next) - num_names++; - namelist = (struct name *) merge_sort ((PTR) namelist, num_names, (char *) (&(namelist->next)) - (char *) namelist, name_cmp); - - for (n = namelist; n; n = n->next) - { - n->found = 0; - } - if (gnu_dumpfile) - write_dir_file (); -} - -int -name_cmp (n1, n2) - struct name *n1, *n2; -{ - if (n1->found) - { - if (n2->found) - return strcmp (n1->name, n2->name); - else - return -1; - } - else if (n2->found) - return 1; - else - return strcmp (n1->name, n2->name); -} - -int -dirent_cmp (p1, p2) - const PTR p1; - const PTR p2; -{ - char *frst, *scnd; - - frst = (*(char **) p1) + 1; - scnd = (*(char **) p2) + 1; - - return strcmp (frst, scnd); -} - -char * -get_dir_contents (p, device) - char *p; - int device; -{ - DIR *dirp; - register struct dirent *d; - char *new_buf; - char *namebuf; - int bufsiz; - int len; - PTR the_buffer; - char *buf; - size_t n_strs; - /* int n_size;*/ - char *p_buf; - char **vec, **p_vec; - - extern int errno; - - errno = 0; - dirp = opendir (p); - bufsiz = strlen (p) + NAMSIZ; - namebuf = ck_malloc (bufsiz + 2); - if (!dirp) - { - if (errno) - msg_perror ("can't open directory %s", p); - else - msg ("error opening directory %s", p); - new_buf = NULL; - } - else - { - struct dirname *dp; - int all_children; - - dp = get_dir (p); - all_children = dp ? dp->allnew : 0; - (void) strcpy (namebuf, p); - if (p[strlen (p) - 1] != '/') - (void) strcat (namebuf, "/"); - len = strlen (namebuf); - - the_buffer = init_buffer (); - while (d = readdir (dirp)) - { - struct stat hs; - - /* Skip . and .. */ - if (is_dot_or_dotdot (d->d_name)) - continue; - if (NLENGTH (d) + len >= bufsiz) - { - bufsiz += NAMSIZ; - namebuf = ck_realloc (namebuf, bufsiz + 2); - } - (void) strcpy (namebuf + len, d->d_name); -#ifdef AIX - if (0 != f_follow_links ? - statx (namebuf, &hs, STATSIZE, STX_HIDDEN) : - statx (namebuf, &hs, STATSIZE, STX_HIDDEN | STX_LINK)) -#else - if (0 != f_follow_links ? stat (namebuf, &hs) : lstat (namebuf, &hs)) -#endif - { - msg_perror ("can't stat %s", namebuf); - continue; - } - if ((f_local_filesys && device != hs.st_dev) - || (f_exclude && check_exclude (namebuf))) - add_buffer (the_buffer, "N", 1); -#ifdef AIX - else if (S_ISHIDDEN (hs.st_mode)) - { - add_buffer (the_buffer, "D", 1); - strcat (d->d_name, "A"); - d->d_namlen++; - } -#endif /* AIX */ - else if (S_ISDIR (hs.st_mode)) - { - if (dp = get_dir (namebuf)) - { - if (dp->dev != hs.st_dev - || dp->ino != hs.st_ino) - { - if (f_verbose) - msg ("directory %s has been renamed.", namebuf); - dp->allnew = 1; - dp->dev = hs.st_dev; - dp->ino = hs.st_ino; - } - dp->dir_text = ""; - } - else - { - if (f_verbose) - msg ("Directory %s is new", namebuf); - add_dir (namebuf, hs.st_dev, hs.st_ino, ""); - dp = get_dir (namebuf); - dp->allnew = 1; - } - if (all_children) - dp->allnew = 1; - - add_buffer (the_buffer, "D", 1); - } - else if (!all_children - && f_new_files - && new_time > hs.st_mtime - && (f_new_files > 1 - || new_time > hs.st_ctime)) - add_buffer (the_buffer, "N", 1); - else - add_buffer (the_buffer, "Y", 1); - add_buffer (the_buffer, d->d_name, (int) (NLENGTH (d) + 1)); - } - add_buffer (the_buffer, "\000\000", 2); - closedir (dirp); - - /* Well, we've read in the contents of the dir, now sort them */ - buf = get_buffer (the_buffer); - if (buf[0] == '\0') - { - flush_buffer (the_buffer); - new_buf = NULL; - } - else - { - n_strs = 0; - for (p_buf = buf; *p_buf;) - { - int tmp; - - tmp = strlen (p_buf) + 1; - n_strs++; - p_buf += tmp; - } - vec = (char **) ck_malloc (sizeof (char *) * (n_strs + 1)); - for (p_vec = vec, p_buf = buf; *p_buf; p_buf += strlen (p_buf) + 1) - *p_vec++ = p_buf; - *p_vec = 0; - qsort ((PTR) vec, n_strs, sizeof (char *), dirent_cmp); - new_buf = (char *) ck_malloc (p_buf - buf + 2); - for (p_vec = vec, p_buf = new_buf; *p_vec; p_vec++) - { - char *p_tmp; - - for (p_tmp = *p_vec; *p_buf++ = *p_tmp++;) - ; - } - *p_buf++ = '\0'; - free (vec); - flush_buffer (the_buffer); - } - } - free (namebuf); - return new_buf; -} - -/* p is a directory. Add all the files in P to the namelist. If any of the - files is a directory, recurse on the subdirectory. . . */ -static void -add_dir_name (p, device) - char *p; - int device; -{ - char *new_buf; - char *p_buf; - - char *namebuf; - int buflen; - register int len; - int sublen; - - /* PTR the_buffer;*/ - - /* char *buf;*/ - /* char **vec,**p_vec;*/ - /* int n_strs,n_size;*/ - - struct name *n; - - int dirent_cmp (); - - new_buf = get_dir_contents (p, device); - - for (n = namelist; n; n = n->next) - { - if (!strcmp (n->name, p)) - { - n->dir_contents = new_buf ? new_buf : "\0\0\0\0"; - break; - } - } - - if (new_buf) - { - len = strlen (p); - buflen = NAMSIZ <= len ? len + NAMSIZ : NAMSIZ; - namebuf = ck_malloc (buflen + 1); - - (void) strcpy (namebuf, p); - if (namebuf[len - 1] != '/') - { - namebuf[len++] = '/'; - namebuf[len] = '\0'; - } - for (p_buf = new_buf; *p_buf; p_buf += sublen + 1) - { - sublen = strlen (p_buf); - if (*p_buf == 'D') - { - if (len + sublen >= buflen) - { - buflen += NAMSIZ; - namebuf = ck_realloc (namebuf, buflen + 1); - } - (void) strcpy (namebuf + len, p_buf + 1); - addname (namebuf); - add_dir_name (namebuf, device); - } - } - free (namebuf); - } -} - -/* Returns non-zero if p is . or .. This could be a macro for speed. */ -int -is_dot_or_dotdot (p) - char *p; -{ - return (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0'))); -} - - - - - - -void -gnu_restore (skipcrud) - int skipcrud; -{ - char *current_dir; - /* int current_dir_length; */ - - char *archive_dir; - /* int archive_dir_length; */ - PTR the_buffer; - char *p; - DIR *dirp; - struct dirent *d; - char *cur, *arc; - extern struct stat hstat; /* Stat struct corresponding */ - long size, copied; - char *from, *to; - extern union record *head; - - dirp = opendir (skipcrud + current_file_name); - - if (!dirp) - { - /* The directory doesn't exist now. It'll be created. - In any case, we don't have to delete any files out - of it */ - skip_file ((long) hstat.st_size); - return; - } - - the_buffer = init_buffer (); - while (d = readdir (dirp)) - { - if (is_dot_or_dotdot (d->d_name)) - continue; - - add_buffer (the_buffer, d->d_name, (int) (NLENGTH (d) + 1)); - } - closedir (dirp); - add_buffer (the_buffer, "", 1); - - current_dir = get_buffer (the_buffer); - archive_dir = (char *) ck_malloc (hstat.st_size); - if (archive_dir == 0) - { - msg ("Can't allocate %d bytes for restore", hstat.st_size); - skip_file ((long) hstat.st_size); - return; - } - to = archive_dir; - for (size = hstat.st_size; size > 0; size -= copied) - { - from = findrec ()->charptr; - if (!from) - { - msg ("Unexpected EOF in archive\n"); - break; - } - copied = endofrecs ()->charptr - from; - if (copied > size) - copied = size; - bcopy ((PTR) from, (PTR) to, (int) copied); - to += copied; - userec ((union record *) (from + copied - 1)); - } - - for (cur = current_dir; *cur; cur += strlen (cur) + 1) - { - for (arc = archive_dir; *arc; arc += strlen (arc) + 1) - { - arc++; - if (!strcmp (arc, cur)) - break; - } - if (*arc == '\0') - { - p = new_name (skipcrud + current_file_name, cur); - if (f_confirm && !confirm ("delete", p)) - { - free (p); - continue; - } - if (f_verbose) - fprintf (msg_file, "%s: deleting %s\n", tar, p); - if (recursively_delete (p)) - { - msg ("%s: Error while deleting %s\n", tar, p); - } - free (p); - } - - } - flush_buffer (the_buffer); - free (archive_dir); -} - -int -recursively_delete (path) - char *path; -{ - struct stat sbuf; - DIR *dirp; - struct dirent *dp; - char *path_buf; - /* int path_len; */ - - - if (lstat (path, &sbuf) < 0) - return 1; - if (S_ISDIR (sbuf.st_mode)) - { - - /* path_len=strlen(path); */ - dirp = opendir (path); - if (dirp == 0) - return 1; - while (dp = readdir (dirp)) - { - if (is_dot_or_dotdot (dp->d_name)) - continue; - path_buf = new_name (path, dp->d_name); - if (recursively_delete (path_buf)) - { - free (path_buf); - closedir (dirp); - return 1; - } - free (path_buf); - } - closedir (dirp); - - if (rmdir (path) < 0) - return 1; - return 0; - } - if (unlink (path) < 0) - return 1; - return 0; -} diff --git a/gnu/usr.bin/tar-1.11.2/list.c b/gnu/usr.bin/tar-1.11.2/list.c deleted file mode 100644 index a0c65a334bf2..000000000000 --- a/gnu/usr.bin/tar-1.11.2/list.c +++ /dev/null @@ -1,881 +0,0 @@ -/* List a tar archive. - Copyright (C) 1988, 1992, 1993 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * List a tar archive. - * - * Also includes support routines for reading a tar archive. - * - * this version written 26 Aug 1985 by John Gilmore (ihnp4!hoptoad!gnu). - */ - -#include -#include -#include -#include -#ifndef STDC_HEADERS -extern int errno; -#endif -#include - -#ifdef BSD42 -#include -#else -#ifndef V7 -#include -#endif -#endif - -#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') ) - -#include "tar.h" -#include "port.h" - -extern FILE *msg_file; - -long from_oct (); /* Decode octal number */ -void demode (); /* Print file mode */ -void restore_saved_dir_info (); -PTR ck_malloc (); - -union record *head; /* Points to current archive header */ -struct stat hstat; /* Stat struct corresponding */ -int head_standard; /* Tape header is in ANSI format */ - -int check_exclude (); -void close_archive (); -void decode_header (); -int findgid (); -int finduid (); -void name_gather (); -int name_match (); -void names_notfound (); -void open_archive (); -void print_header (); -int read_header (); -void saverec (); -void skip_file (); -void skip_extended_headers (); - -extern char *quote_copy_string (); - - -/* - * Main loop for reading an archive. - */ -void -read_and (do_something) - void (*do_something) (); -{ - int status = 3; /* Initial status at start of archive */ - int prev_status; - extern time_t new_time; - char save_linkflag; - - name_gather (); /* Gather all the names */ - open_archive (1); /* Open for reading */ - - for (;;) - { - prev_status = status; - status = read_header (); - switch (status) - { - - case 1: /* Valid header */ - /* We should decode next field (mode) first... */ - /* Ensure incoming names are null terminated. */ - - if (!name_match (current_file_name) - || (f_new_files && hstat.st_mtime < new_time) - || (f_exclude && check_exclude (current_file_name))) - { - - int isextended = 0; - - if (head->header.linkflag == LF_VOLHDR - || head->header.linkflag == LF_MULTIVOL - || head->header.linkflag == LF_NAMES) - { - (*do_something) (); - continue; - } - if (f_show_omitted_dirs - && head->header.linkflag == LF_DIR) - msg ("Omitting %s\n", current_file_name); - /* Skip past it in the archive */ - if (head->header.isextended) - isextended = 1; - save_linkflag = head->header.linkflag; - userec (head); - if (isextended) - { - /* register union record *exhdr; - - for (;;) { - exhdr = findrec(); - if (!exhdr->ext_hdr.isextended) { - userec(exhdr); - break; - } - } - userec(exhdr);*/ - skip_extended_headers (); - } - /* Skip to the next header on the archive */ - if (save_linkflag != LF_DIR) - skip_file ((long) hstat.st_size); - continue; - - } - - (*do_something) (); - continue; - - /* - * If the previous header was good, tell them - * that we are skipping bad ones. - */ - case 0: /* Invalid header */ - userec (head); - switch (prev_status) - { - case 3: /* Error on first record */ - msg ("Hmm, this doesn't look like a tar archive."); - /* FALL THRU */ - case 2: /* Error after record of zeroes */ - case 1: /* Error after header rec */ - msg ("Skipping to next file header..."); - case 0: /* Error after error */ - break; - } - continue; - - case 2: /* Record of zeroes */ - userec (head); - status = prev_status; /* If error after 0's */ - if (f_ignorez) - continue; - /* FALL THRU */ - case EOF: /* End of archive */ - break; - } - break; - }; - - restore_saved_dir_info (); - close_archive (); - names_notfound (); /* Print names not found */ -} - - -/* - * Print a header record, based on tar options. - */ -void -list_archive () -{ - extern char *save_name; - int isextended = 0; /* Flag to remember if head is extended */ - - /* Save the record */ - saverec (&head); - - /* Print the header record */ - if (f_verbose) - { - if (f_verbose > 1) - decode_header (head, &hstat, &head_standard, 0); - print_header (); - } - - if (f_gnudump && head->header.linkflag == LF_DUMPDIR) - { - size_t size, written, check; - char *data; - extern long save_totsize; - extern long save_sizeleft; - - userec (head); - if (f_multivol) - { - save_name = current_file_name; - save_totsize = hstat.st_size; - } - for (size = hstat.st_size; size > 0; size -= written) - { - if (f_multivol) - save_sizeleft = size; - data = findrec ()->charptr; - if (data == NULL) - { - msg ("EOF in archive file?"); - break; - } - written = endofrecs ()->charptr - data; - if (written > size) - written = size; - errno = 0; - check = fwrite (data, sizeof (char), written, msg_file); - userec ((union record *) (data + written - 1)); - if (check != written) - { - msg_perror ("only wrote %ld of %ld bytes to file %s", check, written, current_file_name); - skip_file ((long) (size) - written); - break; - } - } - if (f_multivol) - save_name = 0; - saverec ((union record **) 0); /* Unsave it */ - fputc ('\n', msg_file); - fflush (msg_file); - return; - - } - saverec ((union record **) 0);/* Unsave it */ - /* Check to see if we have an extended header to skip over also */ - if (head->header.isextended) - isextended = 1; - - /* Skip past the header in the archive */ - userec (head); - - /* - * If we needed to skip any extended headers, do so now, by - * reading extended headers and skipping past them in the - * archive. - */ - if (isextended) - { - /* register union record *exhdr; - - for (;;) { - exhdr = findrec(); - - if (!exhdr->ext_hdr.isextended) { - userec(exhdr); - break; - } - userec(exhdr); - }*/ - skip_extended_headers (); - } - - if (f_multivol) - save_name = current_file_name; - /* Skip to the next header on the archive */ - - skip_file ((long) hstat.st_size); - - if (f_multivol) - save_name = 0; -} - - -/* - * Read a record that's supposed to be a header record. - * Return its address in "head", and if it is good, the file's - * size in hstat.st_size. - * - * Return 1 for success, 0 if the checksum is bad, EOF on eof, - * 2 for a record full of zeros (EOF marker). - * - * You must always userec(head) to skip past the header which this - * routine reads. - */ -int -read_header () -{ - register int i; - register long sum, signed_sum, recsum; - register char *p; - register union record *header; - long from_oct (); - char **longp; - char *bp, *data; - int size, written; - static char *next_long_name, *next_long_link; - char *name; - -recurse: - - header = findrec (); - head = header; /* This is our current header */ - if (NULL == header) - return EOF; - - recsum = from_oct (8, header->header.chksum); - - sum = 0; - p = header->charptr; - for (i = sizeof (*header); --i >= 0;) - { - /* - * We can't use unsigned char here because of old compilers, - * e.g. V7. - */ - signed_sum += *p; - sum += 0xFF & *p++; - } - - /* Adjust checksum to count the "chksum" field as blanks. */ - for (i = sizeof (header->header.chksum); --i >= 0;) - { - sum -= 0xFF & header->header.chksum[i]; - signed_sum -= (char) header->header.chksum[i]; - } - sum += ' ' * sizeof header->header.chksum; - signed_sum += ' ' * sizeof header->header.chksum; - - if (sum == 8 * ' ') - { - /* - * This is a zeroed record...whole record is 0's except - * for the 8 blanks we faked for the checksum field. - */ - return 2; - } - - if (sum != recsum && signed_sum != recsum) - return 0; - - /* - * Good record. Decode file size and return. - */ - if (header->header.linkflag == LF_LINK) - hstat.st_size = 0; /* Links 0 size on tape */ - else - hstat.st_size = from_oct (1 + 12, header->header.size); - - header->header.arch_name[NAMSIZ - 1] = '\0'; - if (header->header.linkflag == LF_LONGNAME - || header->header.linkflag == LF_LONGLINK) - { - longp = ((header->header.linkflag == LF_LONGNAME) - ? &next_long_name - : &next_long_link); - - userec (header); - if (*longp) - free (*longp); - bp = *longp = (char *) ck_malloc (hstat.st_size); - - for (size = hstat.st_size; - size > 0; - size -= written) - { - data = findrec ()->charptr; - if (data == NULL) - { - msg ("Unexpected EOF on archive file"); - break; - } - written = endofrecs ()->charptr - data; - if (written > size) - written = size; - - bcopy (data, bp, written); - bp += written; - userec ((union record *) (data + written - 1)); - } - goto recurse; - } - else - { - name = (next_long_name - ? next_long_name - : head->header.arch_name); - if (current_file_name) - free (current_file_name); - current_file_name = ck_malloc (strlen (name) + 1); - strcpy (current_file_name, name); - - name = (next_long_link - ? next_long_link - : head->header.arch_linkname); - if (current_link_name) - free (current_link_name); - current_link_name = ck_malloc (strlen (name) + 1); - strcpy (current_link_name, name); - - next_long_link = next_long_name = 0; - return 1; - } -} - - -/* - * Decode things from a file header record into a "struct stat". - * Also set "*stdp" to !=0 or ==0 depending whether header record is "Unix - * Standard" tar format or regular old tar format. - * - * read_header() has already decoded the checksum and length, so we don't. - * - * If wantug != 0, we want the uid/group info decoded from Unix Standard - * tapes (for extraction). If == 0, we are just printing anyway, so save time. - * - * decode_header should NOT be called twice for the same record, since the - * two calls might use different "wantug" values and thus might end up with - * different uid/gid for the two calls. If anybody wants the uid/gid they - * should decode it first, and other callers should decode it without uid/gid - * before calling a routine, e.g. print_header, that assumes decoded data. - */ -void -decode_header (header, st, stdp, wantug) - register union record *header; - register struct stat *st; - int *stdp; - int wantug; -{ - long from_oct (); - - st->st_mode = from_oct (8, header->header.mode); - st->st_mode &= 07777; - st->st_mtime = from_oct (1 + 12, header->header.mtime); - if (f_gnudump) - { - st->st_atime = from_oct (1 + 12, header->header.atime); - st->st_ctime = from_oct (1 + 12, header->header.ctime); - } - - if (0 == strcmp (header->header.magic, TMAGIC)) - { - /* Unix Standard tar archive */ - *stdp = 1; - if (wantug) - { -#ifdef NONAMES - st->st_uid = from_oct (8, header->header.uid); - st->st_gid = from_oct (8, header->header.gid); -#else - st->st_uid = - (*header->header.uname - ? finduid (header->header.uname) - : from_oct (8, header->header.uid)); - st->st_gid = - (*header->header.gname - ? findgid (header->header.gname) - : from_oct (8, header->header.gid)); -#endif - } -#if defined(S_IFBLK) || defined(S_IFCHR) - switch (header->header.linkflag) - { - case LF_BLK: - case LF_CHR: - st->st_rdev = makedev (from_oct (8, header->header.devmajor), - from_oct (8, header->header.devminor)); - } -#endif - } - else - { - /* Old fashioned tar archive */ - *stdp = 0; - st->st_uid = from_oct (8, header->header.uid); - st->st_gid = from_oct (8, header->header.gid); - st->st_rdev = 0; - } -} - - -/* - * Quick and dirty octal conversion. - * - * Result is -1 if the field is invalid (all blank, or nonoctal). - */ -long -from_oct (digs, where) - register int digs; - register char *where; -{ - register long value; - - while (isspace (*where)) - { /* Skip spaces */ - where++; - if (--digs <= 0) - return -1; /* All blank field */ - } - value = 0; - while (digs > 0 && isodigit (*where)) - { /* Scan til nonoctal */ - value = (value << 3) | (*where++ - '0'); - --digs; - } - - if (digs > 0 && *where && !isspace (*where)) - return -1; /* Ended on non-space/nul */ - - return value; -} - - -/* - * Actually print it. - * - * Plain and fancy file header block logging. - * Non-verbose just prints the name, e.g. for "tar t" or "tar x". - * This should just contain file names, so it can be fed back into tar - * with xargs or the "-T" option. The verbose option can give a bunch - * of info, one line per file. I doubt anybody tries to parse its - * format, or if they do, they shouldn't. Unix tar is pretty random here - * anyway. - * - * Note that print_header uses the globals , , and - * , which must be set up in advance. This is not very clean - * and should be cleaned up. FIXME. - */ -#define UGSWIDTH 18 /* min width of User, group, size */ -/* UGSWIDTH of 18 means that with user and group names <= 8 chars the columns - never shift during the listing. */ -#define DATEWIDTH 19 /* Last mod date */ -static int ugswidth = UGSWIDTH; /* Max width encountered so far */ - -void -print_header () -{ - char modes[11]; - char *timestamp; - char uform[11], gform[11]; /* These hold formatted ints */ - char *user, *group; - char size[24]; /* Holds a formatted long or maj, min */ - time_t longie; /* To make ctime() call portable */ - int pad; - char *name; - extern long baserec; - - if (f_sayblock) - fprintf (msg_file, "rec %10d: ", baserec + (ar_record - ar_block)); - /* annofile(msg_file, (char *)NULL); */ - - if (f_verbose <= 1) - { - /* Just the fax, mam. */ - char *name; - - name = quote_copy_string (current_file_name); - if (name == 0) - name = current_file_name; - fprintf (msg_file, "%s\n", name); - if (name != current_file_name) - free (name); - } - else - { - /* File type and modes */ - modes[0] = '?'; - switch (head->header.linkflag) - { - case LF_VOLHDR: - modes[0] = 'V'; - break; - - case LF_MULTIVOL: - modes[0] = 'M'; - break; - - case LF_NAMES: - modes[0] = 'N'; - break; - - case LF_LONGNAME: - case LF_LONGLINK: - msg ("Visible longname error\n"); - break; - - case LF_SPARSE: - case LF_NORMAL: - case LF_OLDNORMAL: - case LF_LINK: - modes[0] = '-'; - if ('/' == current_file_name[strlen (current_file_name) - 1]) - modes[0] = 'd'; - break; - case LF_DUMPDIR: - modes[0] = 'd'; - break; - case LF_DIR: - modes[0] = 'd'; - break; - case LF_SYMLINK: - modes[0] = 'l'; - break; - case LF_BLK: - modes[0] = 'b'; - break; - case LF_CHR: - modes[0] = 'c'; - break; - case LF_FIFO: - modes[0] = 'p'; - break; - case LF_CONTIG: - modes[0] = 'C'; - break; - } - - demode ((unsigned) hstat.st_mode, modes + 1); - - /* Timestamp */ - longie = hstat.st_mtime; - timestamp = ctime (&longie); - timestamp[16] = '\0'; - timestamp[24] = '\0'; - - /* User and group names */ - if (*head->header.uname && head_standard) - { - user = head->header.uname; - } - else - { - user = uform; - (void) sprintf (uform, "%d", - from_oct (8, head->header.uid)); - } - if (*head->header.gname && head_standard) - { - group = head->header.gname; - } - else - { - group = gform; - (void) sprintf (gform, "%d", - from_oct (8, head->header.gid)); - } - - /* Format the file size or major/minor device numbers */ - switch (head->header.linkflag) - { -#if defined(S_IFBLK) || defined(S_IFCHR) - case LF_CHR: - case LF_BLK: - (void) sprintf (size, "%d,%d", - major (hstat.st_rdev), - minor (hstat.st_rdev)); - break; -#endif - case LF_SPARSE: - (void) sprintf (size, "%ld", - from_oct (1 + 12, head->header.realsize)); - break; - default: - (void) sprintf (size, "%ld", (long) hstat.st_size); - } - - /* Figure out padding and print the whole line. */ - pad = strlen (user) + strlen (group) + strlen (size) + 1; - if (pad > ugswidth) - ugswidth = pad; - - name = quote_copy_string (current_file_name); - if (!name) - name = current_file_name; - fprintf (msg_file, "%s %s/%s %*s%s %s %s %s", - modes, - user, - group, - ugswidth - pad, - "", - size, - timestamp + 4, timestamp + 20, - name); - - if (name != current_file_name) - free (name); - switch (head->header.linkflag) - { - case LF_SYMLINK: - name = quote_copy_string (current_link_name); - if (!name) - name = current_link_name; - fprintf (msg_file, " -> %s\n", name); - if (name != current_link_name) - free (name); - break; - - case LF_LINK: - name = quote_copy_string (current_link_name); - if (!name) - name = current_link_name; - fprintf (msg_file, " link to %s\n", current_link_name); - if (name != current_link_name) - free (name); - break; - - default: - fprintf (msg_file, " unknown file type '%c'\n", - head->header.linkflag); - break; - - case LF_OLDNORMAL: - case LF_NORMAL: - case LF_SPARSE: - case LF_CHR: - case LF_BLK: - case LF_DIR: - case LF_FIFO: - case LF_CONTIG: - case LF_DUMPDIR: - putc ('\n', msg_file); - break; - - case LF_VOLHDR: - fprintf (msg_file, "--Volume Header--\n"); - break; - - case LF_MULTIVOL: - fprintf (msg_file, "--Continued at byte %ld--\n", from_oct (1 + 12, head->header.offset)); - break; - - case LF_NAMES: - fprintf (msg_file, "--Mangled file names--\n"); - break; - } - } - fflush (msg_file); -} - -/* - * Print a similar line when we make a directory automatically. - */ -void -pr_mkdir (pathname, length, mode) - char *pathname; - int length; - int mode; -{ - char modes[11]; - char *name; - extern long baserec; - - if (f_verbose > 1) - { - /* File type and modes */ - modes[0] = 'd'; - demode ((unsigned) mode, modes + 1); - - if (f_sayblock) - fprintf (msg_file, "rec %10d: ", baserec + (ar_record - ar_block)); - /* annofile(msg_file, (char *)NULL); */ - name = quote_copy_string (pathname); - if (!name) - name = pathname; - fprintf (msg_file, "%s %*s %.*s\n", - modes, - ugswidth + DATEWIDTH, - "Creating directory:", - length, - pathname); - if (name != pathname) - free (name); - } -} - - -/* - * Skip over bytes of data in records in the archive. - */ -void -skip_file (size) - register long size; -{ - union record *x; - extern long save_totsize; - extern long save_sizeleft; - - if (f_multivol) - { - save_totsize = size; - save_sizeleft = size; - } - - while (size > 0) - { - x = findrec (); - if (x == NULL) - { /* Check it... */ - msg ("Unexpected EOF on archive file"); - exit (EX_BADARCH); - } - userec (x); - size -= RECORDSIZE; - if (f_multivol) - save_sizeleft -= RECORDSIZE; - } -} - -void -skip_extended_headers () -{ - register union record *exhdr; - - for (;;) - { - exhdr = findrec (); - if (!exhdr->ext_hdr.isextended) - { - userec (exhdr); - break; - } - userec (exhdr); - } -} - -/* - * Decode the mode string from a stat entry into a 9-char string and a null. - */ -void -demode (mode, string) - register unsigned mode; - register char *string; -{ - register unsigned mask; - register char *rwx = "rwxrwxrwx"; - - for (mask = 0400; mask != 0; mask >>= 1) - { - if (mode & mask) - *string++ = *rwx++; - else - { - *string++ = '-'; - rwx++; - } - } - - if (mode & S_ISUID) - if (string[-7] == 'x') - string[-7] = 's'; - else - string[-7] = 'S'; - if (mode & S_ISGID) - if (string[-4] == 'x') - string[-4] = 's'; - else - string[-4] = 'S'; - if (mode & S_ISVTX) - if (string[-1] == 'x') - string[-1] = 't'; - else - string[-1] = 'T'; - *string = '\0'; -} diff --git a/gnu/usr.bin/tar-1.11.2/mangle.c b/gnu/usr.bin/tar-1.11.2/mangle.c deleted file mode 100644 index 628168473a1b..000000000000 --- a/gnu/usr.bin/tar-1.11.2/mangle.c +++ /dev/null @@ -1,270 +0,0 @@ -/* mangle.c -- encode long filenames - Copyright (C) 1988, 1992 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include -time_t time (); - -#include "tar.h" -#include "port.h" - -void add_buffer (); -extern PTR ck_malloc (); -void finish_header (); -extern PTR init_buffer (); -extern char *quote_copy_string (); -extern char *get_buffer (); -char *un_quote_string (); - -extern union record *start_header (); - -extern struct stat hstat; /* Stat struct corresponding */ - -struct mangled - { - struct mangled *next; - int type; - char mangled[NAMSIZ]; - char *linked_to; - char normal[1]; - }; - - -/* Should use a hash table, etc. . */ -struct mangled *first_mangle; -int mangled_num = 0; - -#if 0 /* Deleted because there is now a better way to do all this */ - -char * -find_mangled (name) - char *name; -{ - struct mangled *munge; - - for (munge = first_mangle; munge; munge = munge->next) - if (!strcmp (name, munge->normal)) - return munge->mangled; - return 0; -} - - -#ifdef S_ISLNK -void -add_symlink_mangle (symlink, linkto, buffer) - char *symlink; - char *linkto; - char *buffer; -{ - struct mangled *munge, *kludge; - - munge = (struct mangled *) ck_malloc (sizeof (struct mangled) + strlen (symlink) + strlen (linkto) + 2); - if (!first_mangle) - first_mangle = munge; - else - { - for (kludge = first_mangle; kludge->next; kludge = kludge->next) - ; - kludge->next = munge; - } - munge->type = 1; - munge->next = 0; - strcpy (munge->normal, symlink); - munge->linked_to = munge->normal + strlen (symlink) + 1; - strcpy (munge->linked_to, linkto); - sprintf (munge->mangled, "@@MaNgLeD.%d", mangled_num++); - strncpy (buffer, munge->mangled, NAMSIZ); -} - -#endif - -void -add_mangle (name, buffer) - char *name; - char *buffer; -{ - struct mangled *munge, *kludge; - - munge = (struct mangled *) ck_malloc (sizeof (struct mangled) + strlen (name)); - if (!first_mangle) - first_mangle = munge; - else - { - for (kludge = first_mangle; kludge->next; kludge = kludge->next) - ; - kludge->next = munge; - } - munge->next = 0; - munge->type = 0; - strcpy (munge->normal, name); - sprintf (munge->mangled, "@@MaNgLeD.%d", mangled_num++); - strncpy (buffer, munge->mangled, NAMSIZ); -} - -void -write_mangled () -{ - struct mangled *munge; - struct stat hstat; - union record *header; - char *ptr1, *ptr2; - PTR the_buffer; - int size; - int bufsize; - - if (!first_mangle) - return; - the_buffer = init_buffer (); - for (munge = first_mangle, size = 0; munge; munge = munge->next) - { - ptr1 = quote_copy_string (munge->normal); - if (!ptr1) - ptr1 = munge->normal; - if (munge->type) - { - add_buffer (the_buffer, "Symlink ", 8); - add_buffer (the_buffer, ptr1, strlen (ptr1)); - add_buffer (the_buffer, " to ", 4); - - if (ptr2 = quote_copy_string (munge->linked_to)) - { - add_buffer (the_buffer, ptr2, strlen (ptr2)); - free (ptr2); - } - else - add_buffer (the_buffer, munge->linked_to, strlen (munge->linked_to)); - } - else - { - add_buffer (the_buffer, "Rename ", 7); - add_buffer (the_buffer, munge->mangled, strlen (munge->mangled)); - add_buffer (the_buffer, " to ", 4); - add_buffer (the_buffer, ptr1, strlen (ptr1)); - } - add_buffer (the_buffer, "\n", 1); - if (ptr1 != munge->normal) - free (ptr1); - } - - bzero (&hstat, sizeof (struct stat)); - hstat.st_atime = hstat.st_mtime = hstat.st_ctime = time (0); - ptr1 = get_buffer (the_buffer); - hstat.st_size = strlen (ptr1); - - header = start_header ("././@MaNgLeD_NaMeS", &hstat); - header->header.linkflag = LF_NAMES; - finish_header (header); - size = hstat.st_size; - header = findrec (); - bufsize = endofrecs ()->charptr - header->charptr; - - while (bufsize < size) - { - bcopy (ptr1, header->charptr, bufsize); - ptr1 += bufsize; - size -= bufsize; - userec (header + (bufsize - 1) / RECORDSIZE); - header = findrec (); - bufsize = endofrecs ()->charptr - header->charptr; - } - bcopy (ptr1, header->charptr, size); - bzero (header->charptr + size, bufsize - size); - userec (header + (size - 1) / RECORDSIZE); -} - -#endif - -void -extract_mangle (head) - union record *head; -{ - char *buf; - char *fromtape; - char *to; - char *ptr, *ptrend; - char *nam1, *nam1end; - int size; - int copied; - - size = hstat.st_size; - buf = to = ck_malloc (size + 1); - buf[size] = '\0'; - while (size > 0) - { - fromtape = findrec ()->charptr; - if (fromtape == 0) - { - msg ("Unexpected EOF in mangled names!"); - return; - } - copied = endofrecs ()->charptr - fromtape; - if (copied > size) - copied = size; - bcopy (fromtape, to, copied); - to += copied; - size -= copied; - userec ((union record *) (fromtape + copied - 1)); - } - for (ptr = buf; *ptr; ptr = ptrend) - { - ptrend = index (ptr, '\n'); - *ptrend++ = '\0'; - - if (!strncmp (ptr, "Rename ", 7)) - { - nam1 = ptr + 7; - nam1end = index (nam1, ' '); - while (strncmp (nam1end, " to ", 4)) - { - nam1end++; - nam1end = index (nam1end, ' '); - } - *nam1end = '\0'; - if (ptrend[-2] == '/') - ptrend[-2] = '\0'; - un_quote_string (nam1end + 4); - if (rename (nam1, nam1end + 4)) - msg_perror ("Can't rename %s to %s", nam1, nam1end + 4); - else if (f_verbose) - msg ("Renamed %s to %s", nam1, nam1end + 4); - } -#ifdef S_ISLNK - else if (!strncmp (ptr, "Symlink ", 8)) - { - nam1 = ptr + 8; - nam1end = index (nam1, ' '); - while (strncmp (nam1end, " to ", 4)) - { - nam1end++; - nam1end = index (nam1end, ' '); - } - *nam1end = '\0'; - un_quote_string (nam1); - un_quote_string (nam1end + 4); - if (symlink (nam1, nam1end + 4) && (unlink (nam1end + 4) || symlink (nam1, nam1end + 4))) - msg_perror ("Can't symlink %s to %s", nam1, nam1end + 4); - else if (f_verbose) - msg ("Symlinkd %s to %s", nam1, nam1end + 4); - } -#endif - else - msg ("Unknown demangling command %s", ptr); - } -} diff --git a/gnu/usr.bin/tar-1.11.2/msd_dir.h b/gnu/usr.bin/tar-1.11.2/msd_dir.h deleted file mode 100644 index 06c7a644b42d..000000000000 --- a/gnu/usr.bin/tar-1.11.2/msd_dir.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * @(#)msd_dir.h 1.4 87/11/06 Public Domain. - * - * A public domain implementation of BSD directory routines for - * MS-DOS. Written by Michael Rendell ({uunet,utai}michael@garfield), - * August 1897 - */ - -#define rewinddir(dirp) seekdir(dirp, 0L) - -#define MAXNAMLEN 12 - -#ifdef __TURBOC__ -typedef int ino_t; -typedef int dev_t; -#endif - -struct dirent - { - ino_t d_ino; /* a bit of a farce */ - int d_reclen; /* more farce */ - int d_namlen; /* length of d_name */ - char d_name[MAXNAMLEN + 1]; /* garentee null termination */ - }; - -struct _dircontents - { - char *_d_entry; - struct _dircontents *_d_next; - }; - -typedef struct _dirdesc - { - int dd_id; /* uniquely identify each open directory */ - long dd_loc; /* where we are in directory entry is this */ - struct _dircontents *dd_contents; /* pointer to contents of dir */ - struct _dircontents *dd_cp; /* pointer to current position */ - } DIR; - -extern DIR *opendir (); -extern struct dirent *readdir (); -extern void seekdir (); -extern long telldir (); -extern void closedir (); diff --git a/gnu/usr.bin/tar-1.11.2/names.c b/gnu/usr.bin/tar-1.11.2/names.c deleted file mode 100644 index 0de6a8898a30..000000000000 --- a/gnu/usr.bin/tar-1.11.2/names.c +++ /dev/null @@ -1,149 +0,0 @@ -/* Look up user and/or group names. - Copyright (C) 1988, 1992 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Look up user and/or group names. - * - * This file should be modified for non-unix systems to do something - * reasonable. - */ - -#include -#include "tar.h" -#include "port.h" - -#ifndef NONAMES -/* Whole module goes away if NONAMES defined. Otherwise... */ -#include -#include -#include - -static int saveuid = -993; -static char saveuname[TUNMLEN]; -static int my_uid = -993; - -static int savegid = -993; -static char savegname[TGNMLEN]; -static int my_gid = -993; - -#define myuid ( my_uid < 0? (my_uid = getuid()): my_uid ) -#define mygid ( my_gid < 0? (my_gid = getgid()): my_gid ) - -/* - * Look up a user or group name from a uid/gid, maintaining a cache. - * FIXME, for now it's a one-entry cache. - * FIXME2, the "-993" is to reduce the chance of a hit on the first lookup. - * - * This is ifdef'd because on Suns, it drags in about 38K of "yellow - * pages" code, roughly doubling the program size. Thanks guys. - */ -void -finduname (uname, uid) - char uname[TUNMLEN]; - int uid; -{ - struct passwd *pw; -#ifndef HAVE_GETPWUID - extern struct passwd *getpwuid (); -#endif - - if (uid != saveuid) - { - saveuid = uid; - saveuname[0] = '\0'; - pw = getpwuid (uid); - if (pw) - strncpy (saveuname, pw->pw_name, TUNMLEN); - } - strncpy (uname, saveuname, TUNMLEN); -} - -int -finduid (uname) - char uname[TUNMLEN]; -{ - struct passwd *pw; - extern struct passwd *getpwnam (); - - if (uname[0] != saveuname[0] /* Quick test w/o proc call */ - || 0 != strncmp (uname, saveuname, TUNMLEN)) - { - strncpy (saveuname, uname, TUNMLEN); - pw = getpwnam (uname); - if (pw) - { - saveuid = pw->pw_uid; - } - else - { - saveuid = myuid; - } - } - return saveuid; -} - - -void -findgname (gname, gid) - char gname[TGNMLEN]; - int gid; -{ - struct group *gr; -#ifndef HAVE_GETGRGID - extern struct group *getgrgid (); -#endif - - if (gid != savegid) - { - savegid = gid; - savegname[0] = '\0'; - (void) setgrent (); - gr = getgrgid (gid); - if (gr) - strncpy (savegname, gr->gr_name, TGNMLEN); - } - (void) strncpy (gname, savegname, TGNMLEN); -} - - -int -findgid (gname) - char gname[TUNMLEN]; -{ - struct group *gr; - extern struct group *getgrnam (); - - if (gname[0] != savegname[0] /* Quick test w/o proc call */ - || 0 != strncmp (gname, savegname, TUNMLEN)) - { - strncpy (savegname, gname, TUNMLEN); - gr = getgrnam (gname); - if (gr) - { - savegid = gr->gr_gid; - } - else - { - savegid = mygid; - } - } - return savegid; -} - -#endif diff --git a/gnu/usr.bin/tar-1.11.2/open3.h b/gnu/usr.bin/tar-1.11.2/open3.h deleted file mode 100644 index c1c0e59b6761..000000000000 --- a/gnu/usr.bin/tar-1.11.2/open3.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Defines for Sys V style 3-argument open call. - Copyright (C) 1988 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * open3.h -- #defines for the various flags for the Sys V style 3-argument - * open() call. On BSD or System 5, the system already has this in an - * include file. This file is needed for V7 and MINIX systems for the - * benefit of open3() in port.c, a routine that emulates the 3-argument - * call using system calls available on V7/MINIX. - * - * This file is needed by PD tar even if we aren't using the - * emulator, since the #defines for O_WRONLY, etc. are used in - * a couple of places besides the open() calls, (e.g. in the assignment - * to openflag in extract.c). We just #include this rather than - * #ifdef them out. - * - * Written 6/10/87 by rmtodd@uokmax (Richard Todd). - * - * The names have been changed by John Gilmore, 31 July 1987, since - * Richard called it "bsdopen", and really this change was introduced in - * AT&T Unix systems before BSD picked it up. - */ - -/* Only one of the next three should be specified */ -#define O_RDONLY 0 /* only allow read */ -#define O_WRONLY 1 /* only allow write */ -#define O_RDWR 2 /* both are allowed */ - -/* The rest of these can be OR-ed in to the above. */ -/* - * O_NDELAY isn't implemented by the emulator. It's only useful (to tar) on - * systems that have named pipes anyway; it prevents tar's hanging by - * opening a named pipe. We #ifndef it because some systems already have - * it defined. - */ -#ifndef O_NDELAY -#define O_NDELAY 4 /* don't block on opening devices that would - * block on open -- ignored by emulator. */ -#endif -#define O_CREAT 8 /* create file if needed */ -#define O_EXCL 16 /* file cannot already exist */ -#define O_TRUNC 32 /* truncate file on open */ -#define O_APPEND 64 /* always write at end of file -- ignored by emul */ - -#ifdef EMUL_OPEN3 -/* - * make emulation transparent to rest of file -- redirect all open() calls - * to our routine - */ -#define open open3 -#endif diff --git a/gnu/usr.bin/tar-1.11.2/pathmax.h b/gnu/usr.bin/tar-1.11.2/pathmax.h deleted file mode 100644 index aeba9f7d2186..000000000000 --- a/gnu/usr.bin/tar-1.11.2/pathmax.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Define PATH_MAX somehow. Requires sys/types.h. - Copyright (C) 1992 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. */ - -#ifndef _PATHMAX_H -#define _PATHMAX_H - -#ifdef HAVE_UNISTD_H -#include -#endif - -/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define - PATH_MAX but might cause redefinition warnings when sys/param.h is - later included (as on MORE/BSD 4.3). */ -#if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && defined(USG)) -#include -#endif - -#ifndef _POSIX_PATH_MAX -#define _POSIX_PATH_MAX 255 -#endif - -#if !defined(PATH_MAX) && defined(_PC_PATH_MAX) -#define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX)) -#endif - -/* Don't include sys/param.h if it already has been. */ -#if !defined(PATH_MAX) && !defined(MAXPATHLEN) && !defined(__MSDOS__) -#include -#endif - -#if !defined(PATH_MAX) && defined(MAXPATHLEN) -#define PATH_MAX MAXPATHLEN -#endif - -#ifndef PATH_MAX -#define PATH_MAX _POSIX_PATH_MAX -#endif - -#endif /* _PATHMAX_H */ diff --git a/gnu/usr.bin/tar-1.11.2/port.c b/gnu/usr.bin/tar-1.11.2/port.c deleted file mode 100644 index 10ec32ed7288..000000000000 --- a/gnu/usr.bin/tar-1.11.2/port.c +++ /dev/null @@ -1,1256 +0,0 @@ -/* Supporting routines which may sometimes be missing. - Copyright (C) 1988, 1992 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#ifndef STDC_HEADERS -extern int errno; -#endif - -#ifdef BSD42 -#include -#else -#ifndef V7 -#include -#endif -#endif - -#include "tar.h" -#include "port.h" - -extern long baserec; - -/* All machine-dependent #ifdefs should appear here, instead of - being scattered through the file. For UN*X systems, it is better to - figure out what is needed in the configure script, for most of the - features. */ - -#ifdef __MSDOS__ -char TTY_NAME[] = "con"; -#define HAVE_STRSTR -#define HAVE_RENAME -#define HAVE_MKDIR -#else -char TTY_NAME[] = "/dev/tty"; -#endif - -/* End of system-dependent #ifdefs */ - - -#ifndef HAVE_VALLOC -/* - * valloc() does a malloc() on a page boundary. On some systems, - * this can make large block I/O more efficient. - */ -char * -valloc (size) - unsigned size; -{ - return (malloc (size)); -} - -#endif /* !HAVE_VALLOC */ - -#ifndef HAVE_MKDIR -/* - * Written by Robert Rother, Mariah Corporation, August 1985. - * - * If you want it, it's yours. All I ask in return is that if you - * figure out how to do this in a Bourne Shell script you send me - * a copy. - * sdcsvax!rmr or rmr@uscd - * - * Severely hacked over by John Gilmore to make a 4.2BSD compatible - * subroutine. 11Mar86; hoptoad!gnu - * - * Modified by rmtodd@uokmax 6-28-87 -- when making an already existing dir, - * subroutine didn't return EEXIST. It does now. - */ - -/* - * Make a directory. - */ -int -mkdir (dpath, dmode) - char *dpath; - int dmode; -{ - int cpid, status; - struct stat statbuf; - - if (stat (dpath, &statbuf) == 0) - { - errno = EEXIST; /* Stat worked, so it already exists */ - return -1; - } - - /* If stat fails for a reason other than non-existence, return error */ - if (errno != ENOENT) - return -1; - - switch (cpid = fork ()) - { - - case -1: /* Error in fork() */ - return (-1); /* Errno is set already */ - - case 0: /* Child process */ - /* - * Cheap hack to set mode of new directory. Since this - * child process is going away anyway, we zap its umask. - * FIXME, this won't suffice to set SUID, SGID, etc. on this - * directory. Does anybody care? - */ - status = umask (0); /* Get current umask */ - status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ - execl ("/bin/mkdir", "mkdir", dpath, (char *) 0); - _exit (-1); /* Can't exec /bin/mkdir */ - - default: /* Parent process */ - while (cpid != wait (&status)); /* Wait for kid to finish */ - } - - if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0) - { - errno = EIO; /* We don't know why, but */ - return -1; /* /bin/mkdir failed */ - } - - return 0; -} - -int -rmdir (dpath) - char *dpath; -{ - int cpid, status; - struct stat statbuf; - - if (stat (dpath, &statbuf) != 0) - { - /* Stat just set errno. We don't have to */ - return -1; - } - - switch (cpid = fork ()) - { - - case -1: /* Error in fork() */ - return (-1); /* Errno is set already */ - - case 0: /* Child process */ - execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); - _exit (-1); /* Can't exec /bin/mkdir */ - - default: /* Parent process */ - while (cpid != wait (&status)); /* Wait for kid to finish */ - } - - if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0) - { - errno = EIO; /* We don't know why, but */ - return -1; /* /bin/mkdir failed */ - } - - return 0; -} - -#endif /* !HAVE_MKDIR */ - -#ifndef HAVE_RENAME -/* Rename file FROM to file TO. - Return 0 if successful, -1 if not. */ - -int -rename (from, to) - char *from; - char *to; -{ - struct stat from_stats; - - if (stat (from, &from_stats)) - return -1; - - if (unlink (to) && errno != ENOENT) - return -1; - - if (link (from, to)) - return -1; - - if (unlink (from) && errno != ENOENT) - { - unlink (to); - return -1; - } - - return 0; -} - -#endif /* !HAVE_RENAME */ - -#ifdef minix -/* Minix has bcopy but not bzero, and no memset. Thanks, Andy. */ -void -bzero (s1, n) - register char *s1; - register int n; -{ - while (n--) - *s1++ = '\0'; -} - -/* It also has no bcmp() */ -int -bcmp (s1, s2, n) - register char *s1, *s2; - register int n; -{ - for (; n--; ++s1, ++s2) - { - if (*s1 != *s2) - return *s1 - *s2; - } - return 0; -} - -/* - * Groan, Minix doesn't have execlp either! - * - * execlp(file,arg0,arg1...argn,(char *)NULL) - * exec a program, automatically searching for the program through - * all the directories on the PATH. - * - * This version is naive about variable argument lists, it assumes - * a straightforward C calling sequence. If your system has odd stacks - * *and* doesn't have execlp, YOU get to fix it. - */ -int -execlp (filename, arg0) - char *filename, *arg0; -{ - register char *p, *path; - register char *fnbuffer; - char **argstart = &arg0; - struct stat statbuf; - extern char **environ; - - if ((p = getenv ("PATH")) == NULL) - { - /* couldn't find path variable -- try to exec given filename */ - return execve (filename, argstart, environ); - } - - /* - * make a place to build the filename. We malloc larger than we - * need, but we know it will fit in this. - */ - fnbuffer = malloc (strlen (p) + 1 + strlen (filename)); - if (fnbuffer == NULL) - { - errno = ENOMEM; - return -1; - } - - /* - * try each component of the path to see if the file's there - * and executable. - */ - for (path = p; path; path = p) - { - /* construct full path name to try */ - if ((p = index (path, ':')) == NULL) - { - strcpy (fnbuffer, path); - } - else - { - strncpy (fnbuffer, path, p - path); - fnbuffer[p - path] = '\0'; - p++; /* Skip : for next time */ - } - if (strlen (fnbuffer) != 0) - strcat (fnbuffer, "/"); - strcat (fnbuffer, filename); - - /* check to see if file is there and is a normal file */ - if (stat (fnbuffer, &statbuf) < 0) - { - if (errno == ENOENT) - continue; /* file not there,keep on looking */ - else - goto fail; /* failed for some reason, return */ - } - if (!S_ISREG (statbuf.st_mode)) - continue; - - if (execve (fnbuffer, argstart, environ) < 0 - && errno != ENOENT - && errno != ENOEXEC) - { - /* failed, for some other reason besides "file - * not found" or "not a.out format" - */ - goto fail; - } - - /* - * If we got error ENOEXEC, the file is executable but is - * not an object file. Try to execute it as a shell script, - * returning error if we can't execute /bin/sh. - * - * FIXME, this code is broken in several ways. Shell - * scripts should not in general be executed by the user's - * SHELL variable program. On more mature systems, the - * script can specify with #!/bin/whatever. Also, this - * code clobbers argstart[-1] if the exec of the shell - * fails. - */ - if (errno == ENOEXEC) - { - char *shell; - - /* Try to execute command "sh arg0 arg1 ..." */ - if ((shell = getenv ("SHELL")) == NULL) - shell = "/bin/sh"; - argstart[-1] = shell; - argstart[0] = fnbuffer; - execve (shell, &argstart[-1], environ); - goto fail; /* Exec didn't work */ - } - - /* - * If we succeeded, the execve() doesn't return, so we - * can only be here is if the file hasn't been found yet. - * Try the next place on the path. - */ - } - - /* all attempts failed to locate the file. Give up. */ - errno = ENOENT; - -fail: - free (fnbuffer); - return -1; -} - -#endif /* minix */ - - -#ifdef EMUL_OPEN3 -#include "open3.h" -/* - * open3 -- routine to emulate the 3-argument open system - * call that is present in most modern Unix systems. - * This version attempts to support all the flag bits except for O_NDELAY - * and O_APPEND, which are silently ignored. The emulation is not as efficient - * as the real thing (at worst, 4 system calls instead of one), but there's - * not much I can do about that. - * - * Written 6/10/87 by rmtodd@uokmax - * - * open3(path, flag, mode) - * Attempts to open the file specified by - * the given pathname. The following flag bits (#defined in tar.h) - * specify options to the routine: - * O_RDONLY file open for read only - * O_WRONLY file open for write only - * O_RDWR file open for both read & write - * (Needless to say, you should only specify one of the above). - * O_CREAT file is created with specified mode if it needs to be. - * O_TRUNC if file exists, it is truncated to 0 bytes - * O_EXCL used with O_CREAT--routine returns error if file exists - * Function returns file descriptor if successful, -1 and errno if not. - */ - -/* - * array to give arguments to access for various modes - * FIXME, this table depends on the specific integer values of O_XXX, - * and also contains integers (args to 'access') that should be #define's. - */ -static int modes[] = -{ - 04, /* O_RDONLY */ - 02, /* O_WRONLY */ - 06, /* O_RDWR */ - 06, /* invalid but we'd better cope -- O_WRONLY+O_RDWR */ -}; - -/* Shut off the automatic emulation of open(), we'll need it. */ -#undef open - -int -open3 (path, flags, mode) - char *path; - int flags, mode; -{ - int exists = 1; - int call_creat = 0; - int fd; - /* - * We actually do the work by calling the open() or creat() system - * call, depending on the flags. Call_creat is true if we will use - * creat(), false if we will use open(). - */ - - /* - * See if the file exists and is accessible in the requested mode. - * - * Strictly speaking we shouldn't be using access, since access checks - * against real uid, and the open call should check against euid. - * Most cases real uid == euid, so it won't matter. FIXME. - * FIXME, the construction "flags & 3" and the modes table depends - * on the specific integer values of the O_XXX #define's. Foo! - */ - if (access (path, modes[flags & 3]) < 0) - { - if (errno == ENOENT) - { - /* the file does not exist */ - exists = 0; - } - else - { - /* probably permission violation */ - if (flags & O_EXCL) - { - /* Oops, the file exists, we didn't want it. */ - /* No matter what the error, claim EEXIST. */ - errno = EEXIST; - } - return -1; - } - } - - /* if we have the O_CREAT bit set, check for O_EXCL */ - if (flags & O_CREAT) - { - if ((flags & O_EXCL) && exists) - { - /* Oops, the file exists and we didn't want it to. */ - errno = EEXIST; - return -1; - } - /* - * If the file doesn't exist, be sure to call creat() so that - * it will be created with the proper mode. - */ - if (!exists) - call_creat = 1; - } - else - { - /* If O_CREAT isn't set and the file doesn't exist, error. */ - if (!exists) - { - errno = ENOENT; - return -1; - } - } - - /* - * If the O_TRUNC flag is set and the file exists, we want to call - * creat() anyway, since creat() guarantees that the file will be - * truncated and open()-for-writing doesn't. - * (If the file doesn't exist, we're calling creat() anyway and the - * file will be created with zero length.) - */ - if ((flags & O_TRUNC) && exists) - call_creat = 1; - /* actually do the call */ - if (call_creat) - { - /* - * call creat. May have to close and reopen the file if we - * want O_RDONLY or O_RDWR access -- creat() only gives - * O_WRONLY. - */ - fd = creat (path, mode); - if (fd < 0 || (flags & O_WRONLY)) - return fd; - if (close (fd) < 0) - return -1; - /* Fall out to reopen the file we've created */ - } - - /* - * calling old open, we strip most of the new flags just in case. - */ - return open (path, flags & (O_RDONLY | O_WRONLY | O_RDWR | O_BINARY)); -} - -#endif /* EMUL_OPEN3 */ - -#ifndef HAVE_MKNOD -#ifdef __MSDOS__ -typedef int dev_t; -#endif -/* Fake mknod by complaining */ -int -mknod (path, mode, dev) - char *path; - unsigned short mode; - dev_t dev; -{ - int fd; - - errno = ENXIO; /* No such device or address */ - return -1; /* Just give an error */ -} - -/* Fake links by copying */ -int -link (path1, path2) - char *path1; - char *path2; -{ - char buf[256]; - int ifd, ofd; - int nrbytes; - int nwbytes; - - fprintf (stderr, "%s: %s: cannot link to %s, copying instead\n", - tar, path1, path2); - if ((ifd = open (path1, O_RDONLY | O_BINARY)) < 0) - return -1; - if ((ofd = creat (path2, 0666)) < 0) - return -1; - setmode (ofd, O_BINARY); - while ((nrbytes = read (ifd, buf, sizeof (buf))) > 0) - { - if ((nwbytes = write (ofd, buf, nrbytes)) != nrbytes) - { - nrbytes = -1; - break; - } - } - /* Note use of "|" rather than "||" below: we want to close - * the files even if an error occurs. - */ - if ((nrbytes < 0) | (0 != close (ifd)) | (0 != close (ofd))) - { - unlink (path2); - return -1; - } - return 0; -} - -/* everyone owns everything on MS-DOS (or is it no one owns anything?) */ -int -chown (path, uid, gid) - char *path; - int uid; - int gid; -{ - return 0; -} - -int -geteuid () -{ - return 0; -} - -#endif /* !HAVE_MKNOD */ - -#ifdef __TURBOC__ -#include -#include -#include - -struct utimbuf -{ - time_t actime; /* Access time. */ - time_t modtime; /* Modification time. */ -}; - -int -utime (char *filename, struct utimbuf *utb) -{ - struct tm *tm; - struct ftime filetime; - time_t when; - int fd; - int status; - - if (utb == 0) - when = time (0); - else - when = utb->modtime; - - fd = _open (filename, O_RDWR); - if (fd == -1) - return -1; - - tm = localtime (&when); - if (tm->tm_year < 80) - filetime.ft_year = 0; - else - filetime.ft_year = tm->tm_year - 80; - filetime.ft_month = tm->tm_mon + 1; - filetime.ft_day = tm->tm_mday; - if (tm->tm_hour < 0) - filetime.ft_hour = 0; - else - filetime.ft_hour = tm->tm_hour; - filetime.ft_min = tm->tm_min; - filetime.ft_tsec = tm->tm_sec / 2; - - status = setftime (fd, &filetime); - _close (fd); - return status; -} - -#endif /* __TURBOC__ */ - -/* Stash argv[0] here so panic will know what the program is called */ -char *myname = 0; - -void -panic (s) - char *s; -{ - if (myname) - fprintf (stderr, "%s:", myname); - fprintf (stderr, s); - putc ('\n', stderr); - exit (12); -} - - -PTR -ck_malloc (size) - size_t size; -{ - PTR ret; - - if (!size) - size++; - ret = malloc (size); - if (ret == 0) - panic ("Couldn't allocate memory"); - return ret; -} - -/* Used by alloca.c and bison.simple. */ -char * -xmalloc (size) - size_t size; -{ - return (char *) ck_malloc (size); -} - -PTR -ck_realloc (ptr, size) - PTR ptr; - size_t size; -{ - PTR ret; - - if (!ptr) - ret = ck_malloc (size); - else - ret = realloc (ptr, size); - if (ret == 0) - panic ("Couldn't re-allocate memory"); - return ret; -} - -/* Implement a variable sized buffer of 'stuff'. We don't know what it is, - nor do we care, as long as it doesn't mind being aligned on a char boundry. - */ - -struct buffer - { - int allocated; - int length; - char *b; - }; - -#define MIN_ALLOCATE 50 - -char * -init_buffer () -{ - struct buffer *b; - - b = (struct buffer *) ck_malloc (sizeof (struct buffer)); - b->allocated = MIN_ALLOCATE; - b->b = (char *) ck_malloc (MIN_ALLOCATE); - b->length = 0; - return (char *) b; -} - -void -flush_buffer (bb) - char *bb; -{ - struct buffer *b; - - b = (struct buffer *) bb; - free (b->b); - b->b = 0; - b->allocated = 0; - b->length = 0; - free ((void *) b); -} - -void -add_buffer (bb, p, n) - char *bb; - char *p; - int n; -{ - struct buffer *b; - - b = (struct buffer *) bb; - if (b->length + n > b->allocated) - { - b->allocated = b->length + n + MIN_ALLOCATE; - b->b = (char *) ck_realloc (b->b, b->allocated); - } - bcopy (p, b->b + b->length, n); - b->length += n; -} - -char * -get_buffer (bb) - char *bb; -{ - struct buffer *b; - - b = (struct buffer *) bb; - return b->b; -} - -char * -merge_sort (list, n, off, cmp) - char *list; - int (*cmp) (); - unsigned n; - int off; -{ - char *ret; - - char *alist, *blist; - unsigned alength, blength; - - char *tptr; - int tmp; - char **prev; -#define NEXTOF(ptr) (* ((char **)(((char *)(ptr))+off) ) ) - if (n == 1) - return list; - if (n == 2) - { - if ((*cmp) (list, NEXTOF (list)) > 0) - { - ret = NEXTOF (list); - NEXTOF (ret) = list; - NEXTOF (list) = 0; - return ret; - } - return list; - } - alist = list; - alength = (n + 1) / 2; - blength = n / 2; - for (tptr = list, tmp = (n - 1) / 2; tmp; tptr = NEXTOF (tptr), tmp--) - ; - blist = NEXTOF (tptr); - NEXTOF (tptr) = 0; - - alist = merge_sort (alist, alength, off, cmp); - blist = merge_sort (blist, blength, off, cmp); - prev = &ret; - for (; alist && blist;) - { - if ((*cmp) (alist, blist) < 0) - { - tptr = NEXTOF (alist); - *prev = alist; - prev = &(NEXTOF (alist)); - alist = tptr; - } - else - { - tptr = NEXTOF (blist); - *prev = blist; - prev = &(NEXTOF (blist)); - blist = tptr; - } - } - if (alist) - *prev = alist; - else - *prev = blist; - - return ret; -} - -void -ck_close (fd) - int fd; -{ - if (close (fd) < 0) - { - msg_perror ("can't close a file #%d", fd); - exit (EX_SYSTEM); - } -} - -#include - -/* Quote_copy_string is like quote_string, but instead of modifying the - string in place, it malloc-s a copy of the string, and returns that. - If the string does not have to be quoted, it returns the NULL string. - The allocated copy can, of course, be freed with free() after the - caller is done with it. - */ -char * -quote_copy_string (string) - char *string; -{ - char *from_here; - char *to_there = 0; - char *copy_buf = 0; - int c; - int copying = 0; - - from_here = string; - while (*from_here) - { - c = *from_here++; - if (c == '\\') - { - if (!copying) - { - int n; - - n = (from_here - string) - 1; - copying++; - copy_buf = (char *) malloc (n + 5 + strlen (from_here) * 4); - if (!copy_buf) - return 0; - bcopy (string, copy_buf, n); - to_there = copy_buf + n; - } - *to_there++ = '\\'; - *to_there++ = '\\'; - } - else if (isprint (c)) - { - if (copying) - *to_there++ = c; - } - else - { - if (!copying) - { - int n; - - n = (from_here - string) - 1; - copying++; - copy_buf = (char *) malloc (n + 5 + strlen (from_here) * 4); - if (!copy_buf) - return 0; - bcopy (string, copy_buf, n); - to_there = copy_buf + n; - } - *to_there++ = '\\'; - if (c == '\n') - *to_there++ = 'n'; - else if (c == '\t') - *to_there++ = 't'; - else if (c == '\f') - *to_there++ = 'f'; - else if (c == '\b') - *to_there++ = 'b'; - else if (c == '\r') - *to_there++ = 'r'; - else if (c == '\177') - *to_there++ = '?'; - else - { - to_there[0] = (c >> 6) + '0'; - to_there[1] = ((c >> 3) & 07) + '0'; - to_there[2] = (c & 07) + '0'; - to_there += 3; - } - } - } - if (copying) - { - *to_there = '\0'; - return copy_buf; - } - return (char *) 0; -} - - -/* Un_quote_string takes a quoted c-string (like those produced by - quote_string or quote_copy_string and turns it back into the - un-quoted original. This is done in place. - */ - -/* There is no un-quote-copy-string. Write it yourself */ - -char * -un_quote_string (string) - char *string; -{ - char *ret; - char *from_here; - char *to_there; - int tmp; - - ret = string; - to_there = string; - from_here = string; - while (*from_here) - { - if (*from_here != '\\') - { - if (from_here != to_there) - *to_there++ = *from_here++; - else - from_here++, to_there++; - continue; - } - switch (*++from_here) - { - case '\\': - *to_there++ = *from_here++; - break; - case 'n': - *to_there++ = '\n'; - from_here++; - break; - case 't': - *to_there++ = '\t'; - from_here++; - break; - case 'f': - *to_there++ = '\f'; - from_here++; - break; - case 'b': - *to_there++ = '\b'; - from_here++; - break; - case 'r': - *to_there++ = '\r'; - from_here++; - break; - case '?': - *to_there++ = 0177; - from_here++; - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - tmp = *from_here - '0'; - from_here++; - if (*from_here < '0' || *from_here > '7') - { - *to_there++ = tmp; - break; - } - tmp = tmp * 8 + *from_here - '0'; - from_here++; - if (*from_here < '0' || *from_here > '7') - { - *to_there++ = tmp; - break; - } - tmp = tmp * 8 + *from_here - '0'; - from_here++; - *to_there = tmp; - break; - default: - ret = 0; - *to_there++ = '\\'; - *to_there++ = *from_here++; - break; - } - } - if (*to_there) - *to_there++ = '\0'; - return ret; -} - -#ifndef __MSDOS__ -void -ck_pipe (pipes) - int *pipes; -{ - if (pipe (pipes) < 0) - { - msg_perror ("can't open a pipe"); - exit (EX_SYSTEM); - } -} -#endif /* !__MSDOS__ */ - -#ifndef HAVE_STRSTR -/* - * strstr - find first occurrence of wanted in s - */ - -char * /* found string, or NULL if none */ -strstr (s, wanted) - char *s; - char *wanted; -{ - register char *scan; - register size_t len; - register char firstc; - - if (*wanted == '\0') - return (char *) 0; - /* - * The odd placement of the two tests is so "" is findable. - * Also, we inline the first char for speed. - * The ++ on scan has been moved down for optimization. - */ - firstc = *wanted; - len = strlen (wanted); - for (scan = s; *scan != firstc || strncmp (scan, wanted, len) != 0;) - if (*scan++ == '\0') - return (char *) 0; - return scan; -} - -#endif /* !HAVE_STRSTR */ - -#ifndef HAVE_FTRUNCATE - -#ifdef F_CHSIZE -int -ftruncate (fd, length) - int fd; - off_t length; -{ - return fcntl (fd, F_CHSIZE, length); -} - -#else /* !F_CHSIZE */ -#ifdef F_FREESP -/* code courtesy of William Kucharski, kucharsk@Solbourne.com */ - -int -ftruncate (fd, length) - int fd; /* file descriptor */ - off_t length; /* length to set file to */ -{ - struct flock fl; - - fl.l_whence = 0; - fl.l_len = 0; - fl.l_start = length; - fl.l_type = F_WRLCK; /* write lock on file space */ - - /* - * This relies on the UNDOCUMENTED F_FREESP argument to - * fcntl(2), which truncates the file so that it ends at the - * position indicated by fl.l_start. - * - * Will minor miracles never cease? - */ - - if (fcntl (fd, F_FREESP, &fl) < 0) - return -1; - - return 0; -} - -#else /* !F_FREESP */ - -int -ftruncate (fd, length) - int fd; - off_t length; -{ - errno = EIO; - return -1; -} - -#endif /* !F_FREESP */ -#endif /* !F_CHSIZE */ -#endif /* !HAVE_FTRUNCATE */ - - -extern FILE *msg_file; - -#if defined (HAVE_VPRINTF) && __STDC__ -#include - -void -msg (char *str,...) -{ - va_list args; - - va_start (args, str); - fflush (msg_file); - fprintf (stderr, "%s: ", tar); - if (f_sayblock) - fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block)); - vfprintf (stderr, str, args); - va_end (args); - putc ('\n', stderr); - fflush (stderr); -} - -void -msg_perror (char *str,...) -{ - va_list args; - int save_e; - - save_e = errno; - fflush (msg_file); - fprintf (stderr, "%s: ", tar); - if (f_sayblock) - fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block)); - va_start (args, str); - vfprintf (stderr, str, args); - va_end (args); - errno = save_e; - perror (" "); - fflush (stderr); -} - -#endif /* HAVE_VPRINTF and __STDC__ */ - -#if defined(HAVE_VPRINTF) && !__STDC__ -#include -void -msg (str, va_alist) - char *str; - va_dcl -{ - va_list args; - - fflush (msg_file); - fprintf (stderr, "%s: ", tar); - if (f_sayblock) - fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block)); - va_start (args); - vfprintf (stderr, str, args); - va_end (args); - putc ('\n', stderr); - fflush (stderr); -} - -void -msg_perror (str, va_alist) - char *str; - va_dcl -{ - va_list args; - int save_e; - - save_e = errno; - fflush (msg_file); - fprintf (stderr, "%s: ", tar); - if (f_sayblock) - fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block)); - va_start (args); - vfprintf (stderr, str, args); - va_end (args); - errno = save_e; - perror (" "); - fflush (stderr); -} - -#endif /* HAVE_VPRINTF and not __STDC__ */ - -#if !defined(HAVE_VPRINTF) && defined(HAVE_DOPRNT) -void -msg (str, args) - char *str; - int args; -{ - fflush (msg_file); - fprintf (stderr, "%s: ", tar); - if (f_sayblock) - fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block)); - _doprnt (str, &args, stderr); - putc ('\n', stderr); - fflush (stderr); -} - -void -msg_perror (str, args) - char *str; - int args; -{ - int save_e; - - save_e = errno; - fflush (msg_file); - fprintf (stderr, "%s: ", tar); - if (f_sayblock) - fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block)); - _doprnt (str, &args, stderr); - errno = save_e; - perror (" "); - fflush (stderr); -} - -#endif /* !HAVE_VPRINTF and HAVE_DOPRNT */ - -#if !defined(HAVE_VPRINTF) && !defined(HAVE_DOPRNT) -void -msg (str, a1, a2, a3, a4, a5, a6) - char *str; -{ - fflush (msg_file); - fprintf (stderr, "%s: ", tar); - if (f_sayblock) - fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block)); - fprintf (stderr, str, a1, a2, a3, a4, a5, a6); - putc ('\n', stderr); - fflush (stderr); -} - -void -msg_perror (str, a1, a2, a3, a4, a5, a6) - char *str; -{ - int save_e; - - save_e = errno; - fflush (msg_file); - fprintf (stderr, "%s: ", tar); - if (f_sayblock) - fprintf (stderr, "rec %d: ", baserec + (ar_record - ar_block)); - fprintf (stderr, str, a1, a2, a3, a4, a5, a6); - fprintf (stderr, ": "); - errno = save_e; - perror (" "); -} - -#endif /* !HAVE_VPRINTF and !HAVE_DOPRNT */ diff --git a/gnu/usr.bin/tar-1.11.2/port.h b/gnu/usr.bin/tar-1.11.2/port.h deleted file mode 100644 index 4e65a9ace886..000000000000 --- a/gnu/usr.bin/tar-1.11.2/port.h +++ /dev/null @@ -1,215 +0,0 @@ -/* Portability declarations. Requires sys/types.h. - Copyright (C) 1988, 1992 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* AIX requires this to be the first thing in the file. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if HAVE_ALLOCA_H -#include -#else /* not HAVE_ALLOCA_H */ -#ifdef _AIX - #pragma alloca -#else /* not _AIX */ -char *alloca (); -#endif /* not _AIX */ -#endif /* not HAVE_ALLOCA_H */ -#endif /* not __GNUC__ */ - -#include "pathmax.h" - -#ifdef _POSIX_VERSION -#include -#else /* !_POSIX_VERSION */ -#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f) -#define WIFSIGNALED(w) (((w) & 0xff) != 0x7f && ((w) & 0xff) != 0) -#define WIFEXITED(w) (((w) & 0xff) == 0) - -#define WSTOPSIG(w) (((w) >> 8) & 0xff) -#define WTERMSIG(w) ((w) & 0x7f) -#define WEXITSTATUS(w) (((w) >> 8) & 0xff) -#endif /* _POSIX_VERSION */ - -/* nonstandard */ -#ifndef WIFCOREDUMPED -#define WIFCOREDUMPED(w) (((w) & 0x80) != 0) -#endif - -#ifdef __MSDOS__ -/* missing things from sys/stat.h */ -#define S_ISUID 0 -#define S_ISGID 0 -#define S_ISVTX 0 - -/* device stuff */ -#define makedev(ma, mi) ((ma << 8) | mi) -#define major(dev) (dev) -#define minor(dev) (dev) -typedef long off_t; -#endif /* __MSDOS__ */ - -#if defined(__STDC__) || defined(__TURBOC__) -#define PTR void * -#else -#define PTR char * -#define const -#endif - -/* Since major is a function on SVR4, we can't just use `ifndef major'. */ -#ifdef major /* Might be defined in sys/types.h. */ -#define HAVE_MAJOR -#endif - -#if !defined(HAVE_MAJOR) && defined(MAJOR_IN_MKDEV) -#include -#define HAVE_MAJOR -#endif - -#if !defined(HAVE_MAJOR) && defined(MAJOR_IN_SYSMACROS) -#include -#define HAVE_MAJOR -#endif - -#ifndef HAVE_MAJOR -#define major(dev) (((dev) >> 8) & 0xff) -#define minor(dev) ((dev) & 0xff) -#define makedev(maj, min) (((maj) << 8) | (min)) -#endif -#undef HAVE_MAJOR - -#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) -#include -#if !defined(__MSDOS__) && !defined(STDC_HEADERS) -#include -#endif -#ifdef index -#undef index -#endif -#ifdef rindex -#undef rindex -#endif -#define index strchr -#define rindex strrchr -#define bcopy(s, d, n) memcpy(d, s, n) -#define bzero(s, n) memset(s, 0, n) -#define bcmp memcmp -#else -#include -#endif - -#if defined(STDC_HEADERS) -#include -#else -char *malloc (), *realloc (); -char *getenv (); -#endif - -#ifndef _POSIX_VERSION -#ifdef __MSDOS__ -#include -#else /* !__MSDOS__ */ -off_t lseek (); -#endif /* !__MSDOS__ */ -char *getcwd (); -#endif /* !_POSIX_VERSION */ - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef O_BINARY -#define O_BINARY 0 -#endif -#ifndef O_CREAT -#define O_CREAT 0 -#endif -#ifndef O_NDELAY -#define O_NDELAY 0 -#endif -#ifndef O_RDONLY -#define O_RDONLY 0 -#endif -#ifndef O_RDWR -#define O_RDWR 2 -#endif - -#include -#ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */ -#define mode_t unsigned short -#endif -#if !defined(S_ISBLK) && defined(S_IFBLK) -#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -#endif -#if !defined(S_ISCHR) && defined(S_IFCHR) -#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -#endif -#if !defined(S_ISDIR) && defined(S_IFDIR) -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#endif -#if !defined(S_ISREG) && defined(S_IFREG) -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#endif -#if !defined(S_ISFIFO) && defined(S_IFIFO) -#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -#define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0)) -#endif -#if !defined(S_ISLNK) && defined(S_IFLNK) -#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -#endif -#if !defined(S_ISSOCK) && defined(S_IFSOCK) -#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) -#endif -#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */ -#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) -#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) -#endif -#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ -#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) -#endif -#if !defined(S_ISCTG) && defined(S_IFCTG) /* contiguous file */ -#define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG) -#endif -#if !defined(S_ISVTX) -#define S_ISVTX 0001000 -#endif - -#ifdef __MSDOS__ -#include "msd_dir.h" -#define NLENGTH(direct) ((direct)->d_namlen) - -#else /* not __MSDOS__ */ - -#if defined(DIRENT) || defined(_POSIX_VERSION) -#include -#define NLENGTH(direct) (strlen((direct)->d_name)) -#else /* not (DIRENT or _POSIX_VERSION) */ -#define dirent direct -#define NLENGTH(direct) ((direct)->d_namlen) -#ifdef SYSNDIR -#include -#endif /* SYSNDIR */ -#ifdef SYSDIR -#include -#endif /* SYSDIR */ -#ifdef NDIR -#include -#endif /* NDIR */ -#endif /* DIRENT or _POSIX_VERSION */ - -#endif /* not __MSDOS__ */ diff --git a/gnu/usr.bin/tar-1.11.2/regex.c b/gnu/usr.bin/tar-1.11.2/regex.c deleted file mode 100644 index cb94d597c6f7..000000000000 --- a/gnu/usr.bin/tar-1.11.2/regex.c +++ /dev/null @@ -1,4932 +0,0 @@ -/* Extended regular expression matching and search library, - version 0.11. - (Implements POSIX draft P10003.2/D11.2, except for - internationalization features.) - - Copyright (C) 1993 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. */ - -/* AIX requires this to be the first thing in the file. */ -#if defined (_AIX) && !defined (REGEX_MALLOC) - #pragma alloca -#endif - -#define _GNU_SOURCE - -/* We need this for `regex.h', and perhaps for the Emacs include files. */ -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* The `emacs' switch turns on certain matching commands - that make sense only in Emacs. */ -#ifdef emacs - -#include "lisp.h" -#include "buffer.h" -#include "syntax.h" - -/* Emacs uses `NULL' as a predicate. */ -#undef NULL - -#else /* not emacs */ - -/* We used to test for `BSTRING' here, but only GCC and Emacs define - `BSTRING', as far as I know, and neither of them use this code. */ -#if HAVE_STRING_H || STDC_HEADERS -#include -#ifndef bcmp -#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) -#endif -#ifndef bcopy -#define bcopy(s, d, n) memcpy ((d), (s), (n)) -#endif -#ifndef bzero -#define bzero(s, n) memset ((s), 0, (n)) -#endif -#else -#include -#endif - -#ifdef STDC_HEADERS -#include -#else -char *malloc (); -char *realloc (); -#endif - - -/* Define the syntax stuff for \<, \>, etc. */ - -/* This must be nonzero for the wordchar and notwordchar pattern - commands in re_match_2. */ -#ifndef Sword -#define Sword 1 -#endif - -#ifdef SYNTAX_TABLE - -extern char *re_syntax_table; - -#else /* not SYNTAX_TABLE */ - -/* How many characters in the character set. */ -#define CHAR_SET_SIZE 256 - -static char re_syntax_table[CHAR_SET_SIZE]; - -static void -init_syntax_once () -{ - register int c; - static int done = 0; - - if (done) - return; - - bzero (re_syntax_table, sizeof re_syntax_table); - - for (c = 'a'; c <= 'z'; c++) - re_syntax_table[c] = Sword; - - for (c = 'A'; c <= 'Z'; c++) - re_syntax_table[c] = Sword; - - for (c = '0'; c <= '9'; c++) - re_syntax_table[c] = Sword; - - re_syntax_table['_'] = Sword; - - done = 1; -} - -#endif /* not SYNTAX_TABLE */ - -#define SYNTAX(c) re_syntax_table[c] - -#endif /* not emacs */ - -/* Get the interface, including the syntax bits. */ -#include "regex.h" - -/* isalpha etc. are used for the character classes. */ -#include - -#ifndef isascii -#define isascii(c) 1 -#endif - -#ifdef isblank -#define ISBLANK(c) (isascii (c) && isblank (c)) -#else -#define ISBLANK(c) ((c) == ' ' || (c) == '\t') -#endif -#ifdef isgraph -#define ISGRAPH(c) (isascii (c) && isgraph (c)) -#else -#define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c)) -#endif - -#define ISPRINT(c) (isascii (c) && isprint (c)) -#define ISDIGIT(c) (isascii (c) && isdigit (c)) -#define ISALNUM(c) (isascii (c) && isalnum (c)) -#define ISALPHA(c) (isascii (c) && isalpha (c)) -#define ISCNTRL(c) (isascii (c) && iscntrl (c)) -#define ISLOWER(c) (isascii (c) && islower (c)) -#define ISPUNCT(c) (isascii (c) && ispunct (c)) -#define ISSPACE(c) (isascii (c) && isspace (c)) -#define ISUPPER(c) (isascii (c) && isupper (c)) -#define ISXDIGIT(c) (isascii (c) && isxdigit (c)) - -#ifndef NULL -#define NULL 0 -#endif - -/* We remove any previous definition of `SIGN_EXTEND_CHAR', - since ours (we hope) works properly with all combinations of - machines, compilers, `char' and `unsigned char' argument types. - (Per Bothner suggested the basic approach.) */ -#undef SIGN_EXTEND_CHAR -#if __STDC__ -#define SIGN_EXTEND_CHAR(c) ((signed char) (c)) -#else /* not __STDC__ */ -/* As in Harbison and Steele. */ -#define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) -#endif - -/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we - use `alloca' instead of `malloc'. This is because using malloc in - re_search* or re_match* could cause memory leaks when C-g is used in - Emacs; also, malloc is slower and causes storage fragmentation. On - the other hand, malloc is more portable, and easier to debug. - - Because we sometimes use alloca, some routines have to be macros, - not functions -- `alloca'-allocated space disappears at the end of the - function it is called in. */ - -#ifdef REGEX_MALLOC - -#define REGEX_ALLOCATE malloc -#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) - -#else /* not REGEX_MALLOC */ - -/* Emacs already defines alloca, sometimes. */ -#ifndef alloca - -/* Make alloca work the best possible way. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if HAVE_ALLOCA_H -#include -#else /* not __GNUC__ or HAVE_ALLOCA_H */ -#ifndef _AIX /* Already did AIX, up at the top. */ -char *alloca (); -#endif /* not _AIX */ -#endif /* not HAVE_ALLOCA_H */ -#endif /* not __GNUC__ */ - -#endif /* not alloca */ - -#define REGEX_ALLOCATE alloca - -/* Assumes a `char *destination' variable. */ -#define REGEX_REALLOCATE(source, osize, nsize) \ - (destination = (char *) alloca (nsize), \ - bcopy (source, destination, osize), \ - destination) - -#endif /* not REGEX_MALLOC */ - - -/* True if `size1' is non-NULL and PTR is pointing anywhere inside - `string1' or just past its end. This works if PTR is NULL, which is - a good thing. */ -#define FIRST_STRING_P(ptr) \ - (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) - -/* (Re)Allocate N items of type T using malloc, or fail. */ -#define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) -#define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) -#define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) - -#define BYTEWIDTH 8 /* In bits. */ - -#define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) - -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -typedef char boolean; -#define false 0 -#define true 1 - -/* These are the command codes that appear in compiled regular - expressions. Some opcodes are followed by argument bytes. A - command code can specify any interpretation whatsoever for its - arguments. Zero bytes may appear in the compiled regular expression. - - The value of `exactn' is needed in search.c (search_buffer) in Emacs. - So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of - `exactn' we use here must also be 1. */ - -typedef enum -{ - no_op = 0, - - /* Followed by one byte giving n, then by n literal bytes. */ - exactn = 1, - - /* Matches any (more or less) character. */ - anychar, - - /* Matches any one char belonging to specified set. First - following byte is number of bitmap bytes. Then come bytes - for a bitmap saying which chars are in. Bits in each byte - are ordered low-bit-first. A character is in the set if its - bit is 1. A character too large to have a bit in the map is - automatically not in the set. */ - charset, - - /* Same parameters as charset, but match any character that is - not one of those specified. */ - charset_not, - - /* Start remembering the text that is matched, for storing in a - register. Followed by one byte with the register number, in - the range 0 to one less than the pattern buffer's re_nsub - field. Then followed by one byte with the number of groups - inner to this one. (This last has to be part of the - start_memory only because we need it in the on_failure_jump - of re_match_2.) */ - start_memory, - - /* Stop remembering the text that is matched and store it in a - memory register. Followed by one byte with the register - number, in the range 0 to one less than `re_nsub' in the - pattern buffer, and one byte with the number of inner groups, - just like `start_memory'. (We need the number of inner - groups here because we don't have any easy way of finding the - corresponding start_memory when we're at a stop_memory.) */ - stop_memory, - - /* Match a duplicate of something remembered. Followed by one - byte containing the register number. */ - duplicate, - - /* Fail unless at beginning of line. */ - begline, - - /* Fail unless at end of line. */ - endline, - - /* Succeeds if at beginning of buffer (if emacs) or at beginning - of string to be matched (if not). */ - begbuf, - - /* Analogously, for end of buffer/string. */ - endbuf, - - /* Followed by two byte relative address to which to jump. */ - jump, - - /* Same as jump, but marks the end of an alternative. */ - jump_past_alt, - - /* Followed by two-byte relative address of place to resume at - in case of failure. */ - on_failure_jump, - - /* Like on_failure_jump, but pushes a placeholder instead of the - current string position when executed. */ - on_failure_keep_string_jump, - - /* Throw away latest failure point and then jump to following - two-byte relative address. */ - pop_failure_jump, - - /* Change to pop_failure_jump if know won't have to backtrack to - match; otherwise change to jump. This is used to jump - back to the beginning of a repeat. If what follows this jump - clearly won't match what the repeat does, such that we can be - sure that there is no use backtracking out of repetitions - already matched, then we change it to a pop_failure_jump. - Followed by two-byte address. */ - maybe_pop_jump, - - /* Jump to following two-byte address, and push a dummy failure - point. This failure point will be thrown away if an attempt - is made to use it for a failure. A `+' construct makes this - before the first repeat. Also used as an intermediary kind - of jump when compiling an alternative. */ - dummy_failure_jump, - - /* Push a dummy failure point and continue. Used at the end of - alternatives. */ - push_dummy_failure, - - /* Followed by two-byte relative address and two-byte number n. - After matching N times, jump to the address upon failure. */ - succeed_n, - - /* Followed by two-byte relative address, and two-byte number n. - Jump to the address N times, then fail. */ - jump_n, - - /* Set the following two-byte relative address to the - subsequent two-byte number. The address *includes* the two - bytes of number. */ - set_number_at, - - wordchar, /* Matches any word-constituent character. */ - notwordchar, /* Matches any char that is not a word-constituent. */ - - wordbeg, /* Succeeds if at word beginning. */ - wordend, /* Succeeds if at word end. */ - - wordbound, /* Succeeds if at a word boundary. */ - notwordbound /* Succeeds if not at a word boundary. */ - -#ifdef emacs - ,before_dot, /* Succeeds if before point. */ - at_dot, /* Succeeds if at point. */ - after_dot, /* Succeeds if after point. */ - - /* Matches any character whose syntax is specified. Followed by - a byte which contains a syntax code, e.g., Sword. */ - syntaxspec, - - /* Matches any character whose syntax is not that specified. */ - notsyntaxspec -#endif /* emacs */ -} re_opcode_t; - -/* Common operations on the compiled pattern. */ - -/* Store NUMBER in two contiguous bytes starting at DESTINATION. */ - -#define STORE_NUMBER(destination, number) \ - do { \ - (destination)[0] = (number) & 0377; \ - (destination)[1] = (number) >> 8; \ - } while (0) - -/* Same as STORE_NUMBER, except increment DESTINATION to - the byte after where the number is stored. Therefore, DESTINATION - must be an lvalue. */ - -#define STORE_NUMBER_AND_INCR(destination, number) \ - do { \ - STORE_NUMBER (destination, number); \ - (destination) += 2; \ - } while (0) - -/* Put into DESTINATION a number stored in two contiguous bytes starting - at SOURCE. */ - -#define EXTRACT_NUMBER(destination, source) \ - do { \ - (destination) = *(source) & 0377; \ - (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \ - } while (0) - -#ifdef DEBUG -static void -extract_number (dest, source) - int *dest; - unsigned char *source; -{ - int temp = SIGN_EXTEND_CHAR (*(source + 1)); - *dest = *source & 0377; - *dest += temp << 8; -} - -#ifndef EXTRACT_MACROS /* To debug the macros. */ -#undef EXTRACT_NUMBER -#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) -#endif /* not EXTRACT_MACROS */ - -#endif /* DEBUG */ - -/* Same as EXTRACT_NUMBER, except increment SOURCE to after the number. - SOURCE must be an lvalue. */ - -#define EXTRACT_NUMBER_AND_INCR(destination, source) \ - do { \ - EXTRACT_NUMBER (destination, source); \ - (source) += 2; \ - } while (0) - -#ifdef DEBUG -static void -extract_number_and_incr (destination, source) - int *destination; - unsigned char **source; -{ - extract_number (destination, *source); - *source += 2; -} - -#ifndef EXTRACT_MACROS -#undef EXTRACT_NUMBER_AND_INCR -#define EXTRACT_NUMBER_AND_INCR(dest, src) \ - extract_number_and_incr (&dest, &src) -#endif /* not EXTRACT_MACROS */ - -#endif /* DEBUG */ - -/* If DEBUG is defined, Regex prints many voluminous messages about what - it is doing (if the variable `debug' is nonzero). If linked with the - main program in `iregex.c', you can enter patterns and strings - interactively. And if linked with the main program in `main.c' and - the other test files, you can run the already-written tests. */ - -#ifdef DEBUG - -/* We use standard I/O for debugging. */ -#include - -/* It is useful to test things that ``must'' be true when debugging. */ -#include - -static int debug = 0; - -#define DEBUG_STATEMENT(e) e -#define DEBUG_PRINT1(x) if (debug) printf (x) -#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) -#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) -#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ - if (debug) print_partial_compiled_pattern (s, e) -#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ - if (debug) print_double_string (w, s1, sz1, s2, sz2) - - -extern void printchar (); - -/* Print the fastmap in human-readable form. */ - -void -print_fastmap (fastmap) - char *fastmap; -{ - unsigned was_a_range = 0; - unsigned i = 0; - - while (i < (1 << BYTEWIDTH)) - { - if (fastmap[i++]) - { - was_a_range = 0; - printchar (i - 1); - while (i < (1 << BYTEWIDTH) && fastmap[i]) - { - was_a_range = 1; - i++; - } - if (was_a_range) - { - printf ("-"); - printchar (i - 1); - } - } - } - putchar ('\n'); -} - - -/* Print a compiled pattern string in human-readable form, starting at - the START pointer into it and ending just before the pointer END. */ - -void -print_partial_compiled_pattern (start, end) - unsigned char *start; - unsigned char *end; -{ - int mcnt, mcnt2; - unsigned char *p = start; - unsigned char *pend = end; - - if (start == NULL) - { - printf ("(null)\n"); - return; - } - - /* Loop over pattern commands. */ - while (p < pend) - { - switch ((re_opcode_t) *p++) - { - case no_op: - printf ("/no_op"); - break; - - case exactn: - mcnt = *p++; - printf ("/exactn/%d", mcnt); - do - { - putchar ('/'); - printchar (*p++); - } - while (--mcnt); - break; - - case start_memory: - mcnt = *p++; - printf ("/start_memory/%d/%d", mcnt, *p++); - break; - - case stop_memory: - mcnt = *p++; - printf ("/stop_memory/%d/%d", mcnt, *p++); - break; - - case duplicate: - printf ("/duplicate/%d", *p++); - break; - - case anychar: - printf ("/anychar"); - break; - - case charset: - case charset_not: - { - register int c; - - printf ("/charset%s", - (re_opcode_t) *(p - 1) == charset_not ? "_not" : ""); - - assert (p + *p < pend); - - for (c = 0; c < *p; c++) - { - unsigned bit; - unsigned char map_byte = p[1 + c]; - - putchar ('/'); - - for (bit = 0; bit < BYTEWIDTH; bit++) - if (map_byte & (1 << bit)) - printchar (c * BYTEWIDTH + bit); - } - p += 1 + *p; - break; - } - - case begline: - printf ("/begline"); - break; - - case endline: - printf ("/endline"); - break; - - case on_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/on_failure_jump/0/%d", mcnt); - break; - - case on_failure_keep_string_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/on_failure_keep_string_jump/0/%d", mcnt); - break; - - case dummy_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/dummy_failure_jump/0/%d", mcnt); - break; - - case push_dummy_failure: - printf ("/push_dummy_failure"); - break; - - case maybe_pop_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/maybe_pop_jump/0/%d", mcnt); - break; - - case pop_failure_jump: - extract_number_and_incr (&mcnt, &p); - printf ("/pop_failure_jump/0/%d", mcnt); - break; - - case jump_past_alt: - extract_number_and_incr (&mcnt, &p); - printf ("/jump_past_alt/0/%d", mcnt); - break; - - case jump: - extract_number_and_incr (&mcnt, &p); - printf ("/jump/0/%d", mcnt); - break; - - case succeed_n: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/succeed_n/0/%d/0/%d", mcnt, mcnt2); - break; - - case jump_n: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/jump_n/0/%d/0/%d", mcnt, mcnt2); - break; - - case set_number_at: - extract_number_and_incr (&mcnt, &p); - extract_number_and_incr (&mcnt2, &p); - printf ("/set_number_at/0/%d/0/%d", mcnt, mcnt2); - break; - - case wordbound: - printf ("/wordbound"); - break; - - case notwordbound: - printf ("/notwordbound"); - break; - - case wordbeg: - printf ("/wordbeg"); - break; - - case wordend: - printf ("/wordend"); - -#ifdef emacs - case before_dot: - printf ("/before_dot"); - break; - - case at_dot: - printf ("/at_dot"); - break; - - case after_dot: - printf ("/after_dot"); - break; - - case syntaxspec: - printf ("/syntaxspec"); - mcnt = *p++; - printf ("/%d", mcnt); - break; - - case notsyntaxspec: - printf ("/notsyntaxspec"); - mcnt = *p++; - printf ("/%d", mcnt); - break; -#endif /* emacs */ - - case wordchar: - printf ("/wordchar"); - break; - - case notwordchar: - printf ("/notwordchar"); - break; - - case begbuf: - printf ("/begbuf"); - break; - - case endbuf: - printf ("/endbuf"); - break; - - default: - printf ("?%d", *(p-1)); - } - } - printf ("/\n"); -} - - -void -print_compiled_pattern (bufp) - struct re_pattern_buffer *bufp; -{ - unsigned char *buffer = bufp->buffer; - - print_partial_compiled_pattern (buffer, buffer + bufp->used); - printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated); - - if (bufp->fastmap_accurate && bufp->fastmap) - { - printf ("fastmap: "); - print_fastmap (bufp->fastmap); - } - - printf ("re_nsub: %d\t", bufp->re_nsub); - printf ("regs_alloc: %d\t", bufp->regs_allocated); - printf ("can_be_null: %d\t", bufp->can_be_null); - printf ("newline_anchor: %d\n", bufp->newline_anchor); - printf ("no_sub: %d\t", bufp->no_sub); - printf ("not_bol: %d\t", bufp->not_bol); - printf ("not_eol: %d\t", bufp->not_eol); - printf ("syntax: %d\n", bufp->syntax); - /* Perhaps we should print the translate table? */ -} - - -void -print_double_string (where, string1, size1, string2, size2) - const char *where; - const char *string1; - const char *string2; - int size1; - int size2; -{ - unsigned this_char; - - if (where == NULL) - printf ("(null)"); - else - { - if (FIRST_STRING_P (where)) - { - for (this_char = where - string1; this_char < size1; this_char++) - printchar (string1[this_char]); - - where = string2; - } - - for (this_char = where - string2; this_char < size2; this_char++) - printchar (string2[this_char]); - } -} - -#else /* not DEBUG */ - -#undef assert -#define assert(e) - -#define DEBUG_STATEMENT(e) -#define DEBUG_PRINT1(x) -#define DEBUG_PRINT2(x1, x2) -#define DEBUG_PRINT3(x1, x2, x3) -#define DEBUG_PRINT4(x1, x2, x3, x4) -#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) -#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) - -#endif /* not DEBUG */ - -/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can - also be assigned to arbitrarily: each pattern buffer stores its own - syntax, so it can be changed between regex compilations. */ -reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; - - -/* Specify the precise syntax of regexps for compilation. This provides - for compatibility for various utilities which historically have - different, incompatible syntaxes. - - The argument SYNTAX is a bit mask comprised of the various bits - defined in regex.h. We return the old syntax. */ - -reg_syntax_t -re_set_syntax (syntax) - reg_syntax_t syntax; -{ - reg_syntax_t ret = re_syntax_options; - - re_syntax_options = syntax; - return ret; -} - -/* This table gives an error message for each of the error codes listed - in regex.h. Obviously the order here has to be same as there. */ - -static const char *re_error_msg[] = - { NULL, /* REG_NOERROR */ - "No match", /* REG_NOMATCH */ - "Invalid regular expression", /* REG_BADPAT */ - "Invalid collation character", /* REG_ECOLLATE */ - "Invalid character class name", /* REG_ECTYPE */ - "Trailing backslash", /* REG_EESCAPE */ - "Invalid back reference", /* REG_ESUBREG */ - "Unmatched [ or [^", /* REG_EBRACK */ - "Unmatched ( or \\(", /* REG_EPAREN */ - "Unmatched \\{", /* REG_EBRACE */ - "Invalid content of \\{\\}", /* REG_BADBR */ - "Invalid range end", /* REG_ERANGE */ - "Memory exhausted", /* REG_ESPACE */ - "Invalid preceding regular expression", /* REG_BADRPT */ - "Premature end of regular expression", /* REG_EEND */ - "Regular expression too big", /* REG_ESIZE */ - "Unmatched ) or \\)", /* REG_ERPAREN */ - }; - -/* Subroutine declarations and macros for regex_compile. */ - -static void store_op1 (), store_op2 (); -static void insert_op1 (), insert_op2 (); -static boolean at_begline_loc_p (), at_endline_loc_p (); -static boolean group_in_compile_stack (); -static reg_errcode_t compile_range (); - -/* Fetch the next character in the uncompiled pattern---translating it - if necessary. Also cast from a signed character in the constant - string passed to us by the user to an unsigned char that we can use - as an array index (in, e.g., `translate'). */ -#define PATFETCH(c) \ - do {if (p == pend) return REG_EEND; \ - c = (unsigned char) *p++; \ - if (translate) c = translate[c]; \ - } while (0) - -/* Fetch the next character in the uncompiled pattern, with no - translation. */ -#define PATFETCH_RAW(c) \ - do {if (p == pend) return REG_EEND; \ - c = (unsigned char) *p++; \ - } while (0) - -/* Go backwards one character in the pattern. */ -#define PATUNFETCH p-- - - -/* If `translate' is non-null, return translate[D], else just D. We - cast the subscript to translate because some data is declared as - `char *', to avoid warnings when a string constant is passed. But - when we use a character as a subscript we must make it unsigned. */ -#define TRANSLATE(d) (translate ? translate[(unsigned char) (d)] : (d)) - - -/* Macros for outputting the compiled pattern into `buffer'. */ - -/* If the buffer isn't allocated when it comes in, use this. */ -#define INIT_BUF_SIZE 32 - -/* Make sure we have at least N more bytes of space in buffer. */ -#define GET_BUFFER_SPACE(n) \ - while (b - bufp->buffer + (n) > bufp->allocated) \ - EXTEND_BUFFER () - -/* Make sure we have one more byte of buffer space and then add C to it. */ -#define BUF_PUSH(c) \ - do { \ - GET_BUFFER_SPACE (1); \ - *b++ = (unsigned char) (c); \ - } while (0) - - -/* Ensure we have two more bytes of buffer space and then append C1 and C2. */ -#define BUF_PUSH_2(c1, c2) \ - do { \ - GET_BUFFER_SPACE (2); \ - *b++ = (unsigned char) (c1); \ - *b++ = (unsigned char) (c2); \ - } while (0) - - -/* As with BUF_PUSH_2, except for three bytes. */ -#define BUF_PUSH_3(c1, c2, c3) \ - do { \ - GET_BUFFER_SPACE (3); \ - *b++ = (unsigned char) (c1); \ - *b++ = (unsigned char) (c2); \ - *b++ = (unsigned char) (c3); \ - } while (0) - - -/* Store a jump with opcode OP at LOC to location TO. We store a - relative address offset by the three bytes the jump itself occupies. */ -#define STORE_JUMP(op, loc, to) \ - store_op1 (op, loc, (to) - (loc) - 3) - -/* Likewise, for a two-argument jump. */ -#define STORE_JUMP2(op, loc, to, arg) \ - store_op2 (op, loc, (to) - (loc) - 3, arg) - -/* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */ -#define INSERT_JUMP(op, loc, to) \ - insert_op1 (op, loc, (to) - (loc) - 3, b) - -/* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */ -#define INSERT_JUMP2(op, loc, to, arg) \ - insert_op2 (op, loc, (to) - (loc) - 3, arg, b) - - -/* This is not an arbitrary limit: the arguments which represent offsets - into the pattern are two bytes long. So if 2^16 bytes turns out to - be too small, many things would have to change. */ -#define MAX_BUF_SIZE (1L << 16) - - -/* Extend the buffer by twice its current size via realloc and - reset the pointers that pointed into the old block to point to the - correct places in the new one. If extending the buffer results in it - being larger than MAX_BUF_SIZE, then flag memory exhausted. */ -#define EXTEND_BUFFER() \ - do { \ - unsigned char *old_buffer = bufp->buffer; \ - if (bufp->allocated == MAX_BUF_SIZE) \ - return REG_ESIZE; \ - bufp->allocated <<= 1; \ - if (bufp->allocated > MAX_BUF_SIZE) \ - bufp->allocated = MAX_BUF_SIZE; \ - bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\ - if (bufp->buffer == NULL) \ - return REG_ESPACE; \ - /* If the buffer moved, move all the pointers into it. */ \ - if (old_buffer != bufp->buffer) \ - { \ - b = (b - old_buffer) + bufp->buffer; \ - begalt = (begalt - old_buffer) + bufp->buffer; \ - if (fixup_alt_jump) \ - fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\ - if (laststart) \ - laststart = (laststart - old_buffer) + bufp->buffer; \ - if (pending_exact) \ - pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ - } \ - } while (0) - - -/* Since we have one byte reserved for the register number argument to - {start,stop}_memory, the maximum number of groups we can report - things about is what fits in that byte. */ -#define MAX_REGNUM 255 - -/* But patterns can have more than `MAX_REGNUM' registers. We just - ignore the excess. */ -typedef unsigned regnum_t; - - -/* Macros for the compile stack. */ - -/* Since offsets can go either forwards or backwards, this type needs to - be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ -typedef int pattern_offset_t; - -typedef struct -{ - pattern_offset_t begalt_offset; - pattern_offset_t fixup_alt_jump; - pattern_offset_t inner_group_offset; - pattern_offset_t laststart_offset; - regnum_t regnum; -} compile_stack_elt_t; - - -typedef struct -{ - compile_stack_elt_t *stack; - unsigned size; - unsigned avail; /* Offset of next open position. */ -} compile_stack_type; - - -#define INIT_COMPILE_STACK_SIZE 32 - -#define COMPILE_STACK_EMPTY (compile_stack.avail == 0) -#define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) - -/* The next available element. */ -#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) - - -/* Set the bit for character C in a list. */ -#define SET_LIST_BIT(c) \ - (b[((unsigned char) (c)) / BYTEWIDTH] \ - |= 1 << (((unsigned char) c) % BYTEWIDTH)) - - -/* Get the next unsigned number in the uncompiled pattern. */ -#define GET_UNSIGNED_NUMBER(num) \ - { if (p != pend) \ - { \ - PATFETCH (c); \ - while (ISDIGIT (c)) \ - { \ - if (num < 0) \ - num = 0; \ - num = num * 10 + c - '0'; \ - if (p == pend) \ - break; \ - PATFETCH (c); \ - } \ - } \ - } - -#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ - -#define IS_CHAR_CLASS(string) \ - (STREQ (string, "alpha") || STREQ (string, "upper") \ - || STREQ (string, "lower") || STREQ (string, "digit") \ - || STREQ (string, "alnum") || STREQ (string, "xdigit") \ - || STREQ (string, "space") || STREQ (string, "print") \ - || STREQ (string, "punct") || STREQ (string, "graph") \ - || STREQ (string, "cntrl") || STREQ (string, "blank")) - -/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. - Returns one of error codes defined in `regex.h', or zero for success. - - Assumes the `allocated' (and perhaps `buffer') and `translate' - fields are set in BUFP on entry. - - If it succeeds, results are put in BUFP (if it returns an error, the - contents of BUFP are undefined): - `buffer' is the compiled pattern; - `syntax' is set to SYNTAX; - `used' is set to the length of the compiled pattern; - `fastmap_accurate' is zero; - `re_nsub' is the number of subexpressions in PATTERN; - `not_bol' and `not_eol' are zero; - - The `fastmap' and `newline_anchor' fields are neither - examined nor set. */ - -static reg_errcode_t -regex_compile (pattern, size, syntax, bufp) - const char *pattern; - int size; - reg_syntax_t syntax; - struct re_pattern_buffer *bufp; -{ - /* We fetch characters from PATTERN here. Even though PATTERN is - `char *' (i.e., signed), we declare these variables as unsigned, so - they can be reliably used as array indices. */ - register unsigned char c, c1; - - /* A random tempory spot in PATTERN. */ - const char *p1; - - /* Points to the end of the buffer, where we should append. */ - register unsigned char *b; - - /* Keeps track of unclosed groups. */ - compile_stack_type compile_stack; - - /* Points to the current (ending) position in the pattern. */ - const char *p = pattern; - const char *pend = pattern + size; - - /* How to translate the characters in the pattern. */ - char *translate = bufp->translate; - - /* Address of the count-byte of the most recently inserted `exactn' - command. This makes it possible to tell if a new exact-match - character can be added to that command or if the character requires - a new `exactn' command. */ - unsigned char *pending_exact = 0; - - /* Address of start of the most recently finished expression. - This tells, e.g., postfix * where to find the start of its - operand. Reset at the beginning of groups and alternatives. */ - unsigned char *laststart = 0; - - /* Address of beginning of regexp, or inside of last group. */ - unsigned char *begalt; - - /* Place in the uncompiled pattern (i.e., the {) to - which to go back if the interval is invalid. */ - const char *beg_interval; - - /* Address of the place where a forward jump should go to the end of - the containing expression. Each alternative of an `or' -- except the - last -- ends with a forward jump of this sort. */ - unsigned char *fixup_alt_jump = 0; - - /* Counts open-groups as they are encountered. Remembered for the - matching close-group on the compile stack, so the same register - number is put in the stop_memory as the start_memory. */ - regnum_t regnum = 0; - -#ifdef DEBUG - DEBUG_PRINT1 ("\nCompiling pattern: "); - if (debug) - { - unsigned debug_count; - - for (debug_count = 0; debug_count < size; debug_count++) - printchar (pattern[debug_count]); - putchar ('\n'); - } -#endif /* DEBUG */ - - /* Initialize the compile stack. */ - compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); - if (compile_stack.stack == NULL) - return REG_ESPACE; - - compile_stack.size = INIT_COMPILE_STACK_SIZE; - compile_stack.avail = 0; - - /* Initialize the pattern buffer. */ - bufp->syntax = syntax; - bufp->fastmap_accurate = 0; - bufp->not_bol = bufp->not_eol = 0; - - /* Set `used' to zero, so that if we return an error, the pattern - printer (for debugging) will think there's no pattern. We reset it - at the end. */ - bufp->used = 0; - - /* Always count groups, whether or not bufp->no_sub is set. */ - bufp->re_nsub = 0; - -#if !defined (emacs) && !defined (SYNTAX_TABLE) - /* Initialize the syntax table. */ - init_syntax_once (); -#endif - - if (bufp->allocated == 0) - { - if (bufp->buffer) - { /* If zero allocated, but buffer is non-null, try to realloc - enough space. This loses if buffer's address is bogus, but - that is the user's responsibility. */ - RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); - } - else - { /* Caller did not allocate a buffer. Do it for them. */ - bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); - } - if (!bufp->buffer) return REG_ESPACE; - - bufp->allocated = INIT_BUF_SIZE; - } - - begalt = b = bufp->buffer; - - /* Loop through the uncompiled pattern until we're at the end. */ - while (p != pend) - { - PATFETCH (c); - - switch (c) - { - case '^': - { - if ( /* If at start of pattern, it's an operator. */ - p == pattern + 1 - /* If context independent, it's an operator. */ - || syntax & RE_CONTEXT_INDEP_ANCHORS - /* Otherwise, depends on what's come before. */ - || at_begline_loc_p (pattern, p, syntax)) - BUF_PUSH (begline); - else - goto normal_char; - } - break; - - - case '$': - { - if ( /* If at end of pattern, it's an operator. */ - p == pend - /* If context independent, it's an operator. */ - || syntax & RE_CONTEXT_INDEP_ANCHORS - /* Otherwise, depends on what's next. */ - || at_endline_loc_p (p, pend, syntax)) - BUF_PUSH (endline); - else - goto normal_char; - } - break; - - - case '+': - case '?': - if ((syntax & RE_BK_PLUS_QM) - || (syntax & RE_LIMITED_OPS)) - goto normal_char; - handle_plus: - case '*': - /* If there is no previous pattern... */ - if (!laststart) - { - if (syntax & RE_CONTEXT_INVALID_OPS) - return REG_BADRPT; - else if (!(syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - } - - { - /* Are we optimizing this jump? */ - boolean keep_string_p = false; - - /* 1 means zero (many) matches is allowed. */ - char zero_times_ok = 0, many_times_ok = 0; - - /* If there is a sequence of repetition chars, collapse it - down to just one (the right one). We can't combine - interval operators with these because of, e.g., `a{2}*', - which should only match an even number of `a's. */ - - for (;;) - { - zero_times_ok |= c != '+'; - many_times_ok |= c != '?'; - - if (p == pend) - break; - - PATFETCH (c); - - if (c == '*' - || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?'))) - ; - - else if (syntax & RE_BK_PLUS_QM && c == '\\') - { - if (p == pend) return REG_EESCAPE; - - PATFETCH (c1); - if (!(c1 == '+' || c1 == '?')) - { - PATUNFETCH; - PATUNFETCH; - break; - } - - c = c1; - } - else - { - PATUNFETCH; - break; - } - - /* If we get here, we found another repeat character. */ - } - - /* Star, etc. applied to an empty pattern is equivalent - to an empty pattern. */ - if (!laststart) - break; - - /* Now we know whether or not zero matches is allowed - and also whether or not two or more matches is allowed. */ - if (many_times_ok) - { /* More than one repetition is allowed, so put in at the - end a backward relative jump from `b' to before the next - jump we're going to put in below (which jumps from - laststart to after this jump). - - But if we are at the `*' in the exact sequence `.*\n', - insert an unconditional jump backwards to the ., - instead of the beginning of the loop. This way we only - push a failure point once, instead of every time - through the loop. */ - assert (p - 1 > pattern); - - /* Allocate the space for the jump. */ - GET_BUFFER_SPACE (3); - - /* We know we are not at the first character of the pattern, - because laststart was nonzero. And we've already - incremented `p', by the way, to be the character after - the `*'. Do we have to do something analogous here - for null bytes, because of RE_DOT_NOT_NULL? */ - if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') - && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') - && !(syntax & RE_DOT_NEWLINE)) - { /* We have .*\n. */ - STORE_JUMP (jump, b, laststart); - keep_string_p = true; - } - else - /* Anything else. */ - STORE_JUMP (maybe_pop_jump, b, laststart - 3); - - /* We've added more stuff to the buffer. */ - b += 3; - } - - /* On failure, jump from laststart to b + 3, which will be the - end of the buffer after this jump is inserted. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump - : on_failure_jump, - laststart, b + 3); - pending_exact = 0; - b += 3; - - if (!zero_times_ok) - { - /* At least one repetition is required, so insert a - `dummy_failure_jump' before the initial - `on_failure_jump' instruction of the loop. This - effects a skip over that instruction the first time - we hit that loop. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); - b += 3; - } - } - break; - - - case '.': - laststart = b; - BUF_PUSH (anychar); - break; - - - case '[': - { - boolean had_char_class = false; - - if (p == pend) return REG_EBRACK; - - /* Ensure that we have enough space to push a charset: the - opcode, the length count, and the bitset; 34 bytes in all. */ - GET_BUFFER_SPACE (34); - - laststart = b; - - /* We test `*p == '^' twice, instead of using an if - statement, so we only need one BUF_PUSH. */ - BUF_PUSH (*p == '^' ? charset_not : charset); - if (*p == '^') - p++; - - /* Remember the first position in the bracket expression. */ - p1 = p; - - /* Push the number of bytes in the bitmap. */ - BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); - - /* Clear the whole map. */ - bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); - - /* charset_not matches newline according to a syntax bit. */ - if ((re_opcode_t) b[-2] == charset_not - && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) - SET_LIST_BIT ('\n'); - - /* Read in characters and ranges, setting map bits. */ - for (;;) - { - if (p == pend) return REG_EBRACK; - - PATFETCH (c); - - /* \ might escape characters inside [...] and [^...]. */ - if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') - { - if (p == pend) return REG_EESCAPE; - - PATFETCH (c1); - SET_LIST_BIT (c1); - continue; - } - - /* Could be the end of the bracket expression. If it's - not (i.e., when the bracket expression is `[]' so - far), the ']' character bit gets set way below. */ - if (c == ']' && p != p1 + 1) - break; - - /* Look ahead to see if it's a range when the last thing - was a character class. */ - if (had_char_class && c == '-' && *p != ']') - return REG_ERANGE; - - /* Look ahead to see if it's a range when the last thing - was a character: if this is a hyphen not at the - beginning or the end of a list, then it's the range - operator. */ - if (c == '-' - && !(p - 2 >= pattern && p[-2] == '[') - && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') - && *p != ']') - { - reg_errcode_t ret - = compile_range (&p, pend, translate, syntax, b); - if (ret != REG_NOERROR) return ret; - } - - else if (p[0] == '-' && p[1] != ']') - { /* This handles ranges made up of characters only. */ - reg_errcode_t ret; - - /* Move past the `-'. */ - PATFETCH (c1); - - ret = compile_range (&p, pend, translate, syntax, b); - if (ret != REG_NOERROR) return ret; - } - - /* See if we're at the beginning of a possible character - class. */ - - else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') - { /* Leave room for the null. */ - char str[CHAR_CLASS_MAX_LENGTH + 1]; - - PATFETCH (c); - c1 = 0; - - /* If pattern is `[[:'. */ - if (p == pend) return REG_EBRACK; - - for (;;) - { - PATFETCH (c); - if (c == ':' || c == ']' || p == pend - || c1 == CHAR_CLASS_MAX_LENGTH) - break; - str[c1++] = c; - } - str[c1] = '\0'; - - /* If isn't a word bracketed by `[:' and:`]': - undo the ending character, the letters, and leave - the leading `:' and `[' (but set bits for them). */ - if (c == ':' && *p == ']') - { - int ch; - boolean is_alnum = STREQ (str, "alnum"); - boolean is_alpha = STREQ (str, "alpha"); - boolean is_blank = STREQ (str, "blank"); - boolean is_cntrl = STREQ (str, "cntrl"); - boolean is_digit = STREQ (str, "digit"); - boolean is_graph = STREQ (str, "graph"); - boolean is_lower = STREQ (str, "lower"); - boolean is_print = STREQ (str, "print"); - boolean is_punct = STREQ (str, "punct"); - boolean is_space = STREQ (str, "space"); - boolean is_upper = STREQ (str, "upper"); - boolean is_xdigit = STREQ (str, "xdigit"); - - if (!IS_CHAR_CLASS (str)) return REG_ECTYPE; - - /* Throw away the ] at the end of the character - class. */ - PATFETCH (c); - - if (p == pend) return REG_EBRACK; - - for (ch = 0; ch < 1 << BYTEWIDTH; ch++) - { - if ( (is_alnum && ISALNUM (ch)) - || (is_alpha && ISALPHA (ch)) - || (is_blank && ISBLANK (ch)) - || (is_cntrl && ISCNTRL (ch)) - || (is_digit && ISDIGIT (ch)) - || (is_graph && ISGRAPH (ch)) - || (is_lower && ISLOWER (ch)) - || (is_print && ISPRINT (ch)) - || (is_punct && ISPUNCT (ch)) - || (is_space && ISSPACE (ch)) - || (is_upper && ISUPPER (ch)) - || (is_xdigit && ISXDIGIT (ch))) - SET_LIST_BIT (ch); - } - had_char_class = true; - } - else - { - c1++; - while (c1--) - PATUNFETCH; - SET_LIST_BIT ('['); - SET_LIST_BIT (':'); - had_char_class = false; - } - } - else - { - had_char_class = false; - SET_LIST_BIT (c); - } - } - - /* Discard any (non)matching list bytes that are all 0 at the - end of the map. Decrease the map-length byte too. */ - while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) - b[-1]--; - b += b[-1]; - } - break; - - - case '(': - if (syntax & RE_NO_BK_PARENS) - goto handle_open; - else - goto normal_char; - - - case ')': - if (syntax & RE_NO_BK_PARENS) - goto handle_close; - else - goto normal_char; - - - case '\n': - if (syntax & RE_NEWLINE_ALT) - goto handle_alt; - else - goto normal_char; - - - case '|': - if (syntax & RE_NO_BK_VBAR) - goto handle_alt; - else - goto normal_char; - - - case '{': - if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) - goto handle_interval; - else - goto normal_char; - - - case '\\': - if (p == pend) return REG_EESCAPE; - - /* Do not translate the character after the \, so that we can - distinguish, e.g., \B from \b, even if we normally would - translate, e.g., B to b. */ - PATFETCH_RAW (c); - - switch (c) - { - case '(': - if (syntax & RE_NO_BK_PARENS) - goto normal_backslash; - - handle_open: - bufp->re_nsub++; - regnum++; - - if (COMPILE_STACK_FULL) - { - RETALLOC (compile_stack.stack, compile_stack.size << 1, - compile_stack_elt_t); - if (compile_stack.stack == NULL) return REG_ESPACE; - - compile_stack.size <<= 1; - } - - /* These are the values to restore when we hit end of this - group. They are all relative offsets, so that if the - whole pattern moves because of realloc, they will still - be valid. */ - COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; - COMPILE_STACK_TOP.fixup_alt_jump - = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; - COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer; - COMPILE_STACK_TOP.regnum = regnum; - - /* We will eventually replace the 0 with the number of - groups inner to this one. But do not push a - start_memory for groups beyond the last one we can - represent in the compiled pattern. */ - if (regnum <= MAX_REGNUM) - { - COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2; - BUF_PUSH_3 (start_memory, regnum, 0); - } - - compile_stack.avail++; - - fixup_alt_jump = 0; - laststart = 0; - begalt = b; - break; - - - case ')': - if (syntax & RE_NO_BK_PARENS) goto normal_backslash; - - if (COMPILE_STACK_EMPTY) - if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) - goto normal_backslash; - else - return REG_ERPAREN; - - handle_close: - if (fixup_alt_jump) - { /* Push a dummy failure point at the end of the - alternative for a possible future - `pop_failure_jump' to pop. See comments at - `push_dummy_failure' in `re_match_2'. */ - BUF_PUSH (push_dummy_failure); - - /* We allocated space for this jump when we assigned - to `fixup_alt_jump', in the `handle_alt' case below. */ - STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1); - } - - /* See similar code for backslashed left paren above. */ - if (COMPILE_STACK_EMPTY) - if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) - goto normal_char; - else - return REG_ERPAREN; - - /* Since we just checked for an empty stack above, this - ``can't happen''. */ - assert (compile_stack.avail != 0); - { - /* We don't just want to restore into `regnum', because - later groups should continue to be numbered higher, - as in `(ab)c(de)' -- the second group is #2. */ - regnum_t this_group_regnum; - - compile_stack.avail--; - begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; - fixup_alt_jump - = COMPILE_STACK_TOP.fixup_alt_jump - ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 - : 0; - laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; - this_group_regnum = COMPILE_STACK_TOP.regnum; - - /* We're at the end of the group, so now we know how many - groups were inside this one. */ - if (this_group_regnum <= MAX_REGNUM) - { - unsigned char *inner_group_loc - = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; - - *inner_group_loc = regnum - this_group_regnum; - BUF_PUSH_3 (stop_memory, this_group_regnum, - regnum - this_group_regnum); - } - } - break; - - - case '|': /* `\|'. */ - if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) - goto normal_backslash; - handle_alt: - if (syntax & RE_LIMITED_OPS) - goto normal_char; - - /* Insert before the previous alternative a jump which - jumps to this alternative if the former fails. */ - GET_BUFFER_SPACE (3); - INSERT_JUMP (on_failure_jump, begalt, b + 6); - pending_exact = 0; - b += 3; - - /* The alternative before this one has a jump after it - which gets executed if it gets matched. Adjust that - jump so it will jump to this alternative's analogous - jump (put in below, which in turn will jump to the next - (if any) alternative's such jump, etc.). The last such - jump jumps to the correct final destination. A picture: - _____ _____ - | | | | - | v | v - a | b | c - - If we are at `b', then fixup_alt_jump right now points to a - three-byte space after `a'. We'll put in the jump, set - fixup_alt_jump to right after `b', and leave behind three - bytes which we'll fill in when we get to after `c'. */ - - if (fixup_alt_jump) - STORE_JUMP (jump_past_alt, fixup_alt_jump, b); - - /* Mark and leave space for a jump after this alternative, - to be filled in later either by next alternative or - when know we're at the end of a series of alternatives. */ - fixup_alt_jump = b; - GET_BUFFER_SPACE (3); - b += 3; - - laststart = 0; - begalt = b; - break; - - - case '{': - /* If \{ is a literal. */ - if (!(syntax & RE_INTERVALS) - /* If we're at `\{' and it's not the open-interval - operator. */ - || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) - || (p - 2 == pattern && p == pend)) - goto normal_backslash; - - handle_interval: - { - /* If got here, then the syntax allows intervals. */ - - /* At least (most) this many matches must be made. */ - int lower_bound = -1, upper_bound = -1; - - beg_interval = p - 1; - - if (p == pend) - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_EBRACE; - } - - GET_UNSIGNED_NUMBER (lower_bound); - - if (c == ',') - { - GET_UNSIGNED_NUMBER (upper_bound); - if (upper_bound < 0) upper_bound = RE_DUP_MAX; - } - else - /* Interval such as `{1}' => match exactly once. */ - upper_bound = lower_bound; - - if (lower_bound < 0 || upper_bound > RE_DUP_MAX - || lower_bound > upper_bound) - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_BADBR; - } - - if (!(syntax & RE_NO_BK_BRACES)) - { - if (c != '\\') return REG_EBRACE; - - PATFETCH (c); - } - - if (c != '}') - { - if (syntax & RE_NO_BK_BRACES) - goto unfetch_interval; - else - return REG_BADBR; - } - - /* We just parsed a valid interval. */ - - /* If it's invalid to have no preceding re. */ - if (!laststart) - { - if (syntax & RE_CONTEXT_INVALID_OPS) - return REG_BADRPT; - else if (syntax & RE_CONTEXT_INDEP_OPS) - laststart = b; - else - goto unfetch_interval; - } - - /* If the upper bound is zero, don't want to succeed at - all; jump from `laststart' to `b + 3', which will be - the end of the buffer after we insert the jump. */ - if (upper_bound == 0) - { - GET_BUFFER_SPACE (3); - INSERT_JUMP (jump, laststart, b + 3); - b += 3; - } - - /* Otherwise, we have a nontrivial interval. When - we're all done, the pattern will look like: - set_number_at - set_number_at - succeed_n - - jump_n - (The upper bound and `jump_n' are omitted if - `upper_bound' is 1, though.) */ - else - { /* If the upper bound is > 1, we need to insert - more at the end of the loop. */ - unsigned nbytes = 10 + (upper_bound > 1) * 10; - - GET_BUFFER_SPACE (nbytes); - - /* Initialize lower bound of the `succeed_n', even - though it will be set during matching by its - attendant `set_number_at' (inserted next), - because `re_compile_fastmap' needs to know. - Jump to the `jump_n' we might insert below. */ - INSERT_JUMP2 (succeed_n, laststart, - b + 5 + (upper_bound > 1) * 5, - lower_bound); - b += 5; - - /* Code to initialize the lower bound. Insert - before the `succeed_n'. The `5' is the last two - bytes of this `set_number_at', plus 3 bytes of - the following `succeed_n'. */ - insert_op2 (set_number_at, laststart, 5, lower_bound, b); - b += 5; - - if (upper_bound > 1) - { /* More than one repetition is allowed, so - append a backward jump to the `succeed_n' - that starts this interval. - - When we've reached this during matching, - we'll have matched the interval once, so - jump back only `upper_bound - 1' times. */ - STORE_JUMP2 (jump_n, b, laststart + 5, - upper_bound - 1); - b += 5; - - /* The location we want to set is the second - parameter of the `jump_n'; that is `b-2' as - an absolute address. `laststart' will be - the `set_number_at' we're about to insert; - `laststart+3' the number to set, the source - for the relative address. But we are - inserting into the middle of the pattern -- - so everything is getting moved up by 5. - Conclusion: (b - 2) - (laststart + 3) + 5, - i.e., b - laststart. - - We insert this at the beginning of the loop - so that if we fail during matching, we'll - reinitialize the bounds. */ - insert_op2 (set_number_at, laststart, b - laststart, - upper_bound - 1, b); - b += 5; - } - } - pending_exact = 0; - beg_interval = NULL; - } - break; - - unfetch_interval: - /* If an invalid interval, match the characters as literals. */ - assert (beg_interval); - p = beg_interval; - beg_interval = NULL; - - /* normal_char and normal_backslash need `c'. */ - PATFETCH (c); - - if (!(syntax & RE_NO_BK_BRACES)) - { - if (p > pattern && p[-1] == '\\') - goto normal_backslash; - } - goto normal_char; - -#ifdef emacs - /* There is no way to specify the before_dot and after_dot - operators. rms says this is ok. --karl */ - case '=': - BUF_PUSH (at_dot); - break; - - case 's': - laststart = b; - PATFETCH (c); - BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); - break; - - case 'S': - laststart = b; - PATFETCH (c); - BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); - break; -#endif /* emacs */ - - - case 'w': - laststart = b; - BUF_PUSH (wordchar); - break; - - - case 'W': - laststart = b; - BUF_PUSH (notwordchar); - break; - - - case '<': - BUF_PUSH (wordbeg); - break; - - case '>': - BUF_PUSH (wordend); - break; - - case 'b': - BUF_PUSH (wordbound); - break; - - case 'B': - BUF_PUSH (notwordbound); - break; - - case '`': - BUF_PUSH (begbuf); - break; - - case '\'': - BUF_PUSH (endbuf); - break; - - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - if (syntax & RE_NO_BK_REFS) - goto normal_char; - - c1 = c - '0'; - - if (c1 > regnum) - return REG_ESUBREG; - - /* Can't back reference to a subexpression if inside of it. */ - if (group_in_compile_stack (compile_stack, c1)) - goto normal_char; - - laststart = b; - BUF_PUSH_2 (duplicate, c1); - break; - - - case '+': - case '?': - if (syntax & RE_BK_PLUS_QM) - goto handle_plus; - else - goto normal_backslash; - - default: - normal_backslash: - /* You might think it would be useful for \ to mean - not to translate; but if we don't translate it - it will never match anything. */ - c = TRANSLATE (c); - goto normal_char; - } - break; - - - default: - /* Expects the character in `c'. */ - normal_char: - /* If no exactn currently being built. */ - if (!pending_exact - - /* If last exactn not at current position. */ - || pending_exact + *pending_exact + 1 != b - - /* We have only one byte following the exactn for the count. */ - || *pending_exact == (1 << BYTEWIDTH) - 1 - - /* If followed by a repetition operator. */ - || *p == '*' || *p == '^' - || ((syntax & RE_BK_PLUS_QM) - ? *p == '\\' && (p[1] == '+' || p[1] == '?') - : (*p == '+' || *p == '?')) - || ((syntax & RE_INTERVALS) - && ((syntax & RE_NO_BK_BRACES) - ? *p == '{' - : (p[0] == '\\' && p[1] == '{')))) - { - /* Start building a new exactn. */ - - laststart = b; - - BUF_PUSH_2 (exactn, 0); - pending_exact = b - 1; - } - - BUF_PUSH (c); - (*pending_exact)++; - break; - } /* switch (c) */ - } /* while p != pend */ - - - /* Through the pattern now. */ - - if (fixup_alt_jump) - STORE_JUMP (jump_past_alt, fixup_alt_jump, b); - - if (!COMPILE_STACK_EMPTY) - return REG_EPAREN; - - free (compile_stack.stack); - - /* We have succeeded; set the length of the buffer. */ - bufp->used = b - bufp->buffer; - -#ifdef DEBUG - if (debug) - { - DEBUG_PRINT1 ("\nCompiled pattern: "); - print_compiled_pattern (bufp); - } -#endif /* DEBUG */ - - return REG_NOERROR; -} /* regex_compile */ - -/* Subroutines for `regex_compile'. */ - -/* Store OP at LOC followed by two-byte integer parameter ARG. */ - -static void -store_op1 (op, loc, arg) - re_opcode_t op; - unsigned char *loc; - int arg; -{ - *loc = (unsigned char) op; - STORE_NUMBER (loc + 1, arg); -} - - -/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ - -static void -store_op2 (op, loc, arg1, arg2) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; -{ - *loc = (unsigned char) op; - STORE_NUMBER (loc + 1, arg1); - STORE_NUMBER (loc + 3, arg2); -} - - -/* Copy the bytes from LOC to END to open up three bytes of space at LOC - for OP followed by two-byte integer parameter ARG. */ - -static void -insert_op1 (op, loc, arg, end) - re_opcode_t op; - unsigned char *loc; - int arg; - unsigned char *end; -{ - register unsigned char *pfrom = end; - register unsigned char *pto = end + 3; - - while (pfrom != loc) - *--pto = *--pfrom; - - store_op1 (op, loc, arg); -} - - -/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ - -static void -insert_op2 (op, loc, arg1, arg2, end) - re_opcode_t op; - unsigned char *loc; - int arg1, arg2; - unsigned char *end; -{ - register unsigned char *pfrom = end; - register unsigned char *pto = end + 5; - - while (pfrom != loc) - *--pto = *--pfrom; - - store_op2 (op, loc, arg1, arg2); -} - - -/* P points to just after a ^ in PATTERN. Return true if that ^ comes - after an alternative or a begin-subexpression. We assume there is at - least one character before the ^. */ - -static boolean -at_begline_loc_p (pattern, p, syntax) - const char *pattern, *p; - reg_syntax_t syntax; -{ - const char *prev = p - 2; - boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; - - return - /* After a subexpression? */ - (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) - /* After an alternative? */ - || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); -} - - -/* The dual of at_begline_loc_p. This one is for $. We assume there is - at least one character after the $, i.e., `P < PEND'. */ - -static boolean -at_endline_loc_p (p, pend, syntax) - const char *p, *pend; - int syntax; -{ - const char *next = p; - boolean next_backslash = *next == '\\'; - const char *next_next = p + 1 < pend ? p + 1 : NULL; - - return - /* Before a subexpression? */ - (syntax & RE_NO_BK_PARENS ? *next == ')' - : next_backslash && next_next && *next_next == ')') - /* Before an alternative? */ - || (syntax & RE_NO_BK_VBAR ? *next == '|' - : next_backslash && next_next && *next_next == '|'); -} - - -/* Returns true if REGNUM is in one of COMPILE_STACK's elements and - false if it's not. */ - -static boolean -group_in_compile_stack (compile_stack, regnum) - compile_stack_type compile_stack; - regnum_t regnum; -{ - int this_element; - - for (this_element = compile_stack.avail - 1; - this_element >= 0; - this_element--) - if (compile_stack.stack[this_element].regnum == regnum) - return true; - - return false; -} - - -/* Read the ending character of a range (in a bracket expression) from the - uncompiled pattern *P_PTR (which ends at PEND). We assume the - starting character is in `P[-2]'. (`P[-1]' is the character `-'.) - Then we set the translation of all bits between the starting and - ending characters (inclusive) in the compiled pattern B. - - Return an error code. - - We use these short variable names so we can use the same macros as - `regex_compile' itself. */ - -static reg_errcode_t -compile_range (p_ptr, pend, translate, syntax, b) - const char **p_ptr, *pend; - char *translate; - reg_syntax_t syntax; - unsigned char *b; -{ - unsigned this_char; - - const char *p = *p_ptr; - int range_start, range_end; - - if (p == pend) - return REG_ERANGE; - - /* Even though the pattern is a signed `char *', we need to fetch - with unsigned char *'s; if the high bit of the pattern character - is set, the range endpoints will be negative if we fetch using a - signed char *. - - We also want to fetch the endpoints without translating them; the - appropriate translation is done in the bit-setting loop below. */ - range_start = ((unsigned char *) p)[-2]; - range_end = ((unsigned char *) p)[0]; - - /* Have to increment the pointer into the pattern string, so the - caller isn't still at the ending character. */ - (*p_ptr)++; - - /* If the start is after the end, the range is empty. */ - if (range_start > range_end) - return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; - - /* Here we see why `this_char' has to be larger than an `unsigned - char' -- the range is inclusive, so if `range_end' == 0xff - (assuming 8-bit characters), we would otherwise go into an infinite - loop, since all characters <= 0xff. */ - for (this_char = range_start; this_char <= range_end; this_char++) - { - SET_LIST_BIT (TRANSLATE (this_char)); - } - - return REG_NOERROR; -} - -/* Failure stack declarations and macros; both re_compile_fastmap and - re_match_2 use a failure stack. These have to be macros because of - REGEX_ALLOCATE. */ - - -/* Number of failure points for which to initially allocate space - when matching. If this number is exceeded, we allocate more - space, so it is not a hard limit. */ -#ifndef INIT_FAILURE_ALLOC -#define INIT_FAILURE_ALLOC 5 -#endif - -/* Roughly the maximum number of failure points on the stack. Would be - exactly that if always used MAX_FAILURE_SPACE each time we failed. - This is a variable only so users of regex can assign to it; we never - change it ourselves. */ -int re_max_failures = 2000; - -typedef const unsigned char *fail_stack_elt_t; - -typedef struct -{ - fail_stack_elt_t *stack; - unsigned size; - unsigned avail; /* Offset of next open position. */ -} fail_stack_type; - -#define FAIL_STACK_EMPTY() (fail_stack.avail == 0) -#define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) -#define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) -#define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail]) - - -/* Initialize `fail_stack'. Do `return -2' if the alloc fails. */ - -#define INIT_FAIL_STACK() \ - do { \ - fail_stack.stack = (fail_stack_elt_t *) \ - REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \ - \ - if (fail_stack.stack == NULL) \ - return -2; \ - \ - fail_stack.size = INIT_FAILURE_ALLOC; \ - fail_stack.avail = 0; \ - } while (0) - - -/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items. - - Return 1 if succeeds, and 0 if either ran out of memory - allocating space for it or it was already too large. - - REGEX_REALLOCATE requires `destination' be declared. */ - -#define DOUBLE_FAIL_STACK(fail_stack) \ - ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \ - ? 0 \ - : ((fail_stack).stack = (fail_stack_elt_t *) \ - REGEX_REALLOCATE ((fail_stack).stack, \ - (fail_stack).size * sizeof (fail_stack_elt_t), \ - ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \ - \ - (fail_stack).stack == NULL \ - ? 0 \ - : ((fail_stack).size <<= 1, \ - 1))) - - -/* Push PATTERN_OP on FAIL_STACK. - - Return 1 if was able to do so and 0 if ran out of memory allocating - space to do so. */ -#define PUSH_PATTERN_OP(pattern_op, fail_stack) \ - ((FAIL_STACK_FULL () \ - && !DOUBLE_FAIL_STACK (fail_stack)) \ - ? 0 \ - : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \ - 1)) - -/* This pushes an item onto the failure stack. Must be a four-byte - value. Assumes the variable `fail_stack'. Probably should only - be called from within `PUSH_FAILURE_POINT'. */ -#define PUSH_FAILURE_ITEM(item) \ - fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item - -/* The complement operation. Assumes `fail_stack' is nonempty. */ -#define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail] - -/* Used to omit pushing failure point id's when we're not debugging. */ -#ifdef DEBUG -#define DEBUG_PUSH PUSH_FAILURE_ITEM -#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_ITEM () -#else -#define DEBUG_PUSH(item) -#define DEBUG_POP(item_addr) -#endif - - -/* Push the information about the state we will need - if we ever fail back to it. - - Requires variables fail_stack, regstart, regend, reg_info, and - num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be - declared. - - Does `return FAILURE_CODE' if runs out of memory. */ - -#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \ - do { \ - char *destination; \ - /* Must be int, so when we don't save any registers, the arithmetic \ - of 0 + -1 isn't done as unsigned. */ \ - int this_reg; \ - \ - DEBUG_STATEMENT (failure_id++); \ - DEBUG_STATEMENT (nfailure_points_pushed++); \ - DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \ - DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\ - DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\ - \ - DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ - DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \ - \ - /* Ensure we have enough space allocated for what we will push. */ \ - while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ - { \ - if (!DOUBLE_FAIL_STACK (fail_stack)) \ - return failure_code; \ - \ - DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \ - (fail_stack).size); \ - DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\ - } \ - \ - /* Push the info, starting with the registers. */ \ - DEBUG_PRINT1 ("\n"); \ - \ - for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ - this_reg++) \ - { \ - DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ - DEBUG_STATEMENT (num_regs_pushed++); \ - \ - DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ - PUSH_FAILURE_ITEM (regstart[this_reg]); \ - \ - DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ - PUSH_FAILURE_ITEM (regend[this_reg]); \ - \ - DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ - DEBUG_PRINT2 (" match_null=%d", \ - REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ - DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ - DEBUG_PRINT2 (" matched_something=%d", \ - MATCHED_SOMETHING (reg_info[this_reg])); \ - DEBUG_PRINT2 (" ever_matched=%d", \ - EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ - DEBUG_PRINT1 ("\n"); \ - PUSH_FAILURE_ITEM (reg_info[this_reg].word); \ - } \ - \ - DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ - PUSH_FAILURE_ITEM (lowest_active_reg); \ - \ - DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ - PUSH_FAILURE_ITEM (highest_active_reg); \ - \ - DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \ - DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ - PUSH_FAILURE_ITEM (pattern_place); \ - \ - DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \ - DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ - size2); \ - DEBUG_PRINT1 ("'\n"); \ - PUSH_FAILURE_ITEM (string_place); \ - \ - DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \ - DEBUG_PUSH (failure_id); \ - } while (0) - -/* This is the number of items that are pushed and popped on the stack - for each register. */ -#define NUM_REG_ITEMS 3 - -/* Individual items aside from the registers. */ -#ifdef DEBUG -#define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ -#else -#define NUM_NONREG_ITEMS 4 -#endif - -/* We push at most this many items on the stack. */ -#define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) - -/* We actually push this many items. */ -#define NUM_FAILURE_ITEMS \ - ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ - + NUM_NONREG_ITEMS) - -/* How many items can still be added to the stack without overflowing it. */ -#define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) - - -/* Pops what PUSH_FAIL_STACK pushes. - - We restore into the parameters, all of which should be lvalues: - STR -- the saved data position. - PAT -- the saved pattern position. - LOW_REG, HIGH_REG -- the highest and lowest active registers. - REGSTART, REGEND -- arrays of string positions. - REG_INFO -- array of information about each subexpression. - - Also assumes the variables `fail_stack' and (if debugging), `bufp', - `pend', `string1', `size1', `string2', and `size2'. */ - -#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\ -{ \ - DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \ - int this_reg; \ - const unsigned char *string_temp; \ - \ - assert (!FAIL_STACK_EMPTY ()); \ - \ - /* Remove failure points and point to how many regs pushed. */ \ - DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ - DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \ - DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \ - \ - assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ - \ - DEBUG_POP (&failure_id); \ - DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \ - \ - /* If the saved string location is NULL, it came from an \ - on_failure_keep_string_jump opcode, and we want to throw away the \ - saved NULL, thus retaining our current position in the string. */ \ - string_temp = POP_FAILURE_ITEM (); \ - if (string_temp != NULL) \ - str = (const char *) string_temp; \ - \ - DEBUG_PRINT2 (" Popping string 0x%x: `", str); \ - DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ - DEBUG_PRINT1 ("'\n"); \ - \ - pat = (unsigned char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \ - DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ - \ - /* Restore register info. */ \ - high_reg = (unsigned) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ - \ - low_reg = (unsigned) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ - \ - for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ - { \ - DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ - \ - reg_info[this_reg].word = POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ - \ - regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ - \ - regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \ - DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ - } \ - \ - DEBUG_STATEMENT (nfailure_points_popped++); \ -} /* POP_FAILURE_POINT */ - -/* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in - BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible - characters can start a string that matches the pattern. This fastmap - is used by re_search to skip quickly over impossible starting points. - - The caller must supply the address of a (1 << BYTEWIDTH)-byte data - area as BUFP->fastmap. - - We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in - the pattern buffer. - - Returns 0 if we succeed, -2 if an internal error. */ - -int -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; -{ - int j, k; - fail_stack_type fail_stack; -#ifndef REGEX_MALLOC - char *destination; -#endif - /* We don't push any register information onto the failure stack. */ - unsigned num_regs = 0; - - register char *fastmap = bufp->fastmap; - unsigned char *pattern = bufp->buffer; - unsigned long size = bufp->used; - const unsigned char *p = pattern; - register unsigned char *pend = pattern + size; - - /* Assume that each path through the pattern can be null until - proven otherwise. We set this false at the bottom of switch - statement, to which we get only if a particular path doesn't - match the empty string. */ - boolean path_can_be_null = true; - - /* We aren't doing a `succeed_n' to begin with. */ - boolean succeed_n_p = false; - - assert (fastmap != NULL && p != NULL); - - INIT_FAIL_STACK (); - bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ - bufp->fastmap_accurate = 1; /* It will be when we're done. */ - bufp->can_be_null = 0; - - while (p != pend || !FAIL_STACK_EMPTY ()) - { - if (p == pend) - { - bufp->can_be_null |= path_can_be_null; - - /* Reset for next path. */ - path_can_be_null = true; - - p = fail_stack.stack[--fail_stack.avail]; - } - - /* We should never be about to go beyond the end of the pattern. */ - assert (p < pend); - -#ifdef SWITCH_ENUM_BUG - switch ((int) ((re_opcode_t) *p++)) -#else - switch ((re_opcode_t) *p++) -#endif - { - - /* I guess the idea here is to simply not bother with a fastmap - if a backreference is used, since it's too hard to figure out - the fastmap for the corresponding group. Setting - `can_be_null' stops `re_search_2' from using the fastmap, so - that is all we do. */ - case duplicate: - bufp->can_be_null = 1; - return 0; - - - /* Following are the cases which match a character. These end - with `break'. */ - - case exactn: - fastmap[p[1]] = 1; - break; - - - case charset: - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) - fastmap[j] = 1; - break; - - - case charset_not: - /* Chars beyond end of map must be allowed. */ - for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) - fastmap[j] = 1; - - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) - fastmap[j] = 1; - break; - - - case wordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == Sword) - fastmap[j] = 1; - break; - - - case notwordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != Sword) - fastmap[j] = 1; - break; - - - case anychar: - /* `.' matches anything ... */ - for (j = 0; j < (1 << BYTEWIDTH); j++) - fastmap[j] = 1; - - /* ... except perhaps newline. */ - if (!(bufp->syntax & RE_DOT_NEWLINE)) - fastmap['\n'] = 0; - - /* Return if we have already set `can_be_null'; if we have, - then the fastmap is irrelevant. Something's wrong here. */ - else if (bufp->can_be_null) - return 0; - - /* Otherwise, have to check alternative paths. */ - break; - - -#ifdef emacs - case syntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == (enum syntaxcode) k) - fastmap[j] = 1; - break; - - - case notsyntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != (enum syntaxcode) k) - fastmap[j] = 1; - break; - - - /* All cases after this match the empty string. These end with - `continue'. */ - - - case before_dot: - case at_dot: - case after_dot: - continue; -#endif /* not emacs */ - - - case no_op: - case begline: - case endline: - case begbuf: - case endbuf: - case wordbound: - case notwordbound: - case wordbeg: - case wordend: - case push_dummy_failure: - continue; - - - case jump_n: - case pop_failure_jump: - case maybe_pop_jump: - case jump: - case jump_past_alt: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - if (j > 0) - continue; - - /* Jump backward implies we just went through the body of a - loop and matched nothing. Opcode jumped to should be - `on_failure_jump' or `succeed_n'. Just treat it like an - ordinary jump. For a * loop, it has pushed its failure - point already; if so, discard that as redundant. */ - if ((re_opcode_t) *p != on_failure_jump - && (re_opcode_t) *p != succeed_n) - continue; - - p++; - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - - /* If what's on the stack is where we are now, pop it. */ - if (!FAIL_STACK_EMPTY () - && fail_stack.stack[fail_stack.avail - 1] == p) - fail_stack.avail--; - - continue; - - - case on_failure_jump: - case on_failure_keep_string_jump: - handle_on_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - - /* For some patterns, e.g., `(a?)?', `p+j' here points to the - end of the pattern. We don't want to push such a point, - since when we restore it above, entering the switch will - increment `p' past the end of the pattern. We don't need - to push such a point since we obviously won't find any more - fastmap entries beyond `pend'. Such a pattern can match - the null string, though. */ - if (p + j < pend) - { - if (!PUSH_PATTERN_OP (p + j, fail_stack)) - return -2; - } - else - bufp->can_be_null = 1; - - if (succeed_n_p) - { - EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ - succeed_n_p = false; - } - - continue; - - - case succeed_n: - /* Get to the number of times to succeed. */ - p += 2; - - /* Increment p past the n for when k != 0. */ - EXTRACT_NUMBER_AND_INCR (k, p); - if (k == 0) - { - p -= 4; - succeed_n_p = true; /* Spaghetti code alert. */ - goto handle_on_failure_jump; - } - continue; - - - case set_number_at: - p += 4; - continue; - - - case start_memory: - case stop_memory: - p += 2; - continue; - - - default: - abort (); /* We have listed all the cases. */ - } /* switch *p++ */ - - /* Getting here means we have found the possible starting - characters for one path of the pattern -- and that the empty - string does not match. We need not follow this path further. - Instead, look at the next alternative (remembered on the - stack), or quit if no more. The test at the top of the loop - does these things. */ - path_can_be_null = false; - p = pend; - } /* while p */ - - /* Set `can_be_null' for the last path (also the first path, if the - pattern is empty). */ - bufp->can_be_null |= path_can_be_null; - return 0; -} /* re_compile_fastmap */ - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use - this memory for recording register information. STARTS and ENDS - must be allocated using the malloc library routine, and must each - be at least NUM_REGS * sizeof (regoff_t) bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ - -void -re_set_registers (bufp, regs, num_regs, starts, ends) - struct re_pattern_buffer *bufp; - struct re_registers *regs; - unsigned num_regs; - regoff_t *starts, *ends; -{ - if (num_regs) - { - bufp->regs_allocated = REGS_REALLOCATE; - regs->num_regs = num_regs; - regs->start = starts; - regs->end = ends; - } - else - { - bufp->regs_allocated = REGS_UNALLOCATED; - regs->num_regs = 0; - regs->start = regs->end = (regoff_t) 0; - } -} - -/* Searching routines. */ - -/* Like re_search_2, below, but only one string is specified, and - doesn't let you say where to stop matching. */ - -int -re_search (bufp, string, size, startpos, range, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, startpos, range; - struct re_registers *regs; -{ - return re_search_2 (bufp, NULL, 0, string, size, startpos, range, - regs, size); -} - - -/* Using the compiled pattern in BUFP->buffer, first tries to match the - virtual concatenation of STRING1 and STRING2, starting first at index - STARTPOS, then at STARTPOS + 1, and so on. - - STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. - - RANGE is how far to scan while trying to match. RANGE = 0 means try - only at STARTPOS; in general, the last start tried is STARTPOS + - RANGE. - - In REGS, return the indices of the virtual concatenation of STRING1 - and STRING2 that matched the entire BUFP->buffer and its contained - subexpressions. - - Do not consider matching one past the index STOP in the virtual - concatenation of STRING1 and STRING2. - - We return either the position in the strings at which the match was - found, -1 if no match, or -2 if error (such as failure - stack overflow). */ - -int -re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int size1, size2; - int startpos; - int range; - struct re_registers *regs; - int stop; -{ - int val; - register char *fastmap = bufp->fastmap; - register char *translate = bufp->translate; - int total_size = size1 + size2; - int endpos = startpos + range; - - /* Check for out-of-range STARTPOS. */ - if (startpos < 0 || startpos > total_size) - return -1; - - /* Fix up RANGE if it might eventually take us outside - the virtual concatenation of STRING1 and STRING2. */ - if (endpos < -1) - range = -1 - startpos; - else if (endpos > total_size) - range = total_size - startpos; - - /* If the search isn't to be a backwards one, don't waste time in a - search for a pattern that must be anchored. */ - if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) - { - if (startpos > 0) - return -1; - else - range = 1; - } - - /* Update the fastmap now if not correct already. */ - if (fastmap && !bufp->fastmap_accurate) - if (re_compile_fastmap (bufp) == -2) - return -2; - - /* Loop through the string, looking for a place to start matching. */ - for (;;) - { - /* If a fastmap is supplied, skip quickly over characters that - cannot be the start of a match. If the pattern can match the - null string, however, we don't need to skip characters; we want - the first null string. */ - if (fastmap && startpos < total_size && !bufp->can_be_null) - { - if (range > 0) /* Searching forwards. */ - { - register const char *d; - register int lim = 0; - int irange = range; - - if (startpos < size1 && startpos + range >= size1) - lim = range - (size1 - startpos); - - d = (startpos >= size1 ? string2 - size1 : string1) + startpos; - - /* Written out as an if-else to avoid testing `translate' - inside the loop. */ - if (translate) - while (range > lim - && !fastmap[(unsigned char) - translate[(unsigned char) *d++]]) - range--; - else - while (range > lim && !fastmap[(unsigned char) *d++]) - range--; - - startpos += irange - range; - } - else /* Searching backwards. */ - { - register char c = (size1 == 0 || startpos >= size1 - ? string2[startpos - size1] - : string1[startpos]); - - if (!fastmap[(unsigned char) TRANSLATE (c)]) - goto advance; - } - } - - /* If can't match the null string, and that's all we have left, fail. */ - if (range >= 0 && startpos == total_size && fastmap - && !bufp->can_be_null) - return -1; - - val = re_match_2 (bufp, string1, size1, string2, size2, - startpos, regs, stop); - if (val >= 0) - return startpos; - - if (val == -2) - return -2; - - advance: - if (!range) - break; - else if (range > 0) - { - range--; - startpos++; - } - else - { - range++; - startpos--; - } - } - return -1; -} /* re_search_2 */ - -/* Declarations and macros for re_match_2. */ - -static int bcmp_translate (); -static boolean alt_match_null_string_p (), - common_op_match_null_string_p (), - group_match_null_string_p (); - -/* Structure for per-register (a.k.a. per-group) information. - This must not be longer than one word, because we push this value - onto the failure stack. Other register information, such as the - starting and ending positions (which are addresses), and the list of - inner groups (which is a bits list) are maintained in separate - variables. - - We are making a (strictly speaking) nonportable assumption here: that - the compiler will pack our bit fields into something that fits into - the type of `word', i.e., is something that fits into one item on the - failure stack. */ -typedef union -{ - fail_stack_elt_t word; - struct - { - /* This field is one if this group can match the empty string, - zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ -#define MATCH_NULL_UNSET_VALUE 3 - unsigned match_null_string_p : 2; - unsigned is_active : 1; - unsigned matched_something : 1; - unsigned ever_matched_something : 1; - } bits; -} register_info_type; - -#define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) -#define IS_ACTIVE(R) ((R).bits.is_active) -#define MATCHED_SOMETHING(R) ((R).bits.matched_something) -#define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) - - -/* Call this when have matched a real character; it sets `matched' flags - for the subexpressions which we are currently inside. Also records - that those subexprs have matched. */ -#define SET_REGS_MATCHED() \ - do \ - { \ - unsigned r; \ - for (r = lowest_active_reg; r <= highest_active_reg; r++) \ - { \ - MATCHED_SOMETHING (reg_info[r]) \ - = EVER_MATCHED_SOMETHING (reg_info[r]) \ - = 1; \ - } \ - } \ - while (0) - - -/* This converts PTR, a pointer into one of the search strings `string1' - and `string2' into an offset from the beginning of that string. */ -#define POINTER_TO_OFFSET(ptr) \ - (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1) - -/* Registers are set to a sentinel when they haven't yet matched. */ -#define REG_UNSET_VALUE ((char *) -1) -#define REG_UNSET(e) ((e) == REG_UNSET_VALUE) - - -/* Macros for dealing with the split strings in re_match_2. */ - -#define MATCHING_IN_FIRST_STRING (dend == end_match_1) - -/* Call before fetching a character with *d. This switches over to - string2 if necessary. */ -#define PREFETCH() \ - while (d == dend) \ - { \ - /* End of string2 => fail. */ \ - if (dend == end_match_2) \ - goto fail; \ - /* End of string1 => advance to string2. */ \ - d = string2; \ - dend = end_match_2; \ - } - - -/* Test if at very beginning or at very end of the virtual concatenation - of `string1' and `string2'. If only one string, it's `string2'. */ -#define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) -#define AT_STRINGS_END(d) ((d) == end2) - - -/* Test if D points to a character which is word-constituent. We have - two special cases to check for: if past the end of string1, look at - the first character in string2; and if before the beginning of - string2, look at the last character in string1. */ -#define WORDCHAR_P(d) \ - (SYNTAX ((d) == end1 ? *string2 \ - : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ - == Sword) - -/* Test if the character before D and the one at D differ with respect - to being word-constituent. */ -#define AT_WORD_BOUNDARY(d) \ - (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \ - || WORDCHAR_P (d - 1) != WORDCHAR_P (d)) - - -/* Free everything we malloc. */ -#ifdef REGEX_MALLOC -#define FREE_VAR(var) if (var) free (var); var = NULL -#define FREE_VARIABLES() \ - do { \ - FREE_VAR (fail_stack.stack); \ - FREE_VAR (regstart); \ - FREE_VAR (regend); \ - FREE_VAR (old_regstart); \ - FREE_VAR (old_regend); \ - FREE_VAR (best_regstart); \ - FREE_VAR (best_regend); \ - FREE_VAR (reg_info); \ - FREE_VAR (reg_dummy); \ - FREE_VAR (reg_info_dummy); \ - } while (0) -#else /* not REGEX_MALLOC */ -/* Some MIPS systems (at least) want this to free alloca'd storage. */ -#define FREE_VARIABLES() alloca (0) -#endif /* not REGEX_MALLOC */ - - -/* These values must meet several constraints. They must not be valid - register values; since we have a limit of 255 registers (because - we use only one byte in the pattern for the register number), we can - use numbers larger than 255. They must differ by 1, because of - NUM_FAILURE_ITEMS above. And the value for the lowest register must - be larger than the value for the highest register, so we do not try - to actually save any registers when none are active. */ -#define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH) -#define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) - -/* Matching routines. */ - -#ifndef emacs /* Emacs never uses this. */ -/* re_match is like re_match_2 except it takes only a single string. */ - -int -re_match (bufp, string, size, pos, regs) - struct re_pattern_buffer *bufp; - const char *string; - int size, pos; - struct re_registers *regs; - { - return re_match_2 (bufp, NULL, 0, string, size, pos, regs, size); -} -#endif /* not emacs */ - - -/* re_match_2 matches the compiled pattern in BUFP against the - the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 - and SIZE2, respectively). We start matching at POS, and stop - matching at STOP. - - If REGS is non-null and the `no_sub' field of BUFP is nonzero, we - store offsets for the substring each group matched in REGS. See the - documentation for exactly how many groups we fill. - - We return -1 if no match, -2 if an internal error (such as the - failure stack overflowing). Otherwise, we return the length of the - matched substring. */ - -int -re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int size1, size2; - int pos; - struct re_registers *regs; - int stop; -{ - /* General temporaries. */ - int mcnt; - unsigned char *p1; - - /* Just past the end of the corresponding string. */ - const char *end1, *end2; - - /* Pointers into string1 and string2, just past the last characters in - each to consider matching. */ - const char *end_match_1, *end_match_2; - - /* Where we are in the data, and the end of the current string. */ - const char *d, *dend; - - /* Where we are in the pattern, and the end of the pattern. */ - unsigned char *p = bufp->buffer; - register unsigned char *pend = p + bufp->used; - - /* We use this to map every character in the string. */ - char *translate = bufp->translate; - - /* Failure point stack. Each place that can handle a failure further - down the line pushes a failure point on this stack. It consists of - restart, regend, and reg_info for all registers corresponding to - the subexpressions we're currently inside, plus the number of such - registers, and, finally, two char *'s. The first char * is where - to resume scanning the pattern; the second one is where to resume - scanning the strings. If the latter is zero, the failure point is - a ``dummy''; if a failure happens and the failure point is a dummy, - it gets discarded and the next next one is tried. */ - fail_stack_type fail_stack; -#ifdef DEBUG - static unsigned failure_id = 0; - unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; -#endif - - /* We fill all the registers internally, independent of what we - return, for use in backreferences. The number here includes - an element for register zero. */ - unsigned num_regs = bufp->re_nsub + 1; - - /* The currently active registers. */ - unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG; - unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG; - - /* Information on the contents of registers. These are pointers into - the input strings; they record just what was matched (on this - attempt) by a subexpression part of the pattern, that is, the - regnum-th regstart pointer points to where in the pattern we began - matching and the regnum-th regend points to right after where we - stopped matching the regnum-th subexpression. (The zeroth register - keeps track of what the whole pattern matches.) */ - const char **regstart, **regend; - - /* If a group that's operated upon by a repetition operator fails to - match anything, then the register for its start will need to be - restored because it will have been set to wherever in the string we - are when we last see its open-group operator. Similarly for a - register's end. */ - const char **old_regstart, **old_regend; - - /* The is_active field of reg_info helps us keep track of which (possibly - nested) subexpressions we are currently in. The matched_something - field of reg_info[reg_num] helps us tell whether or not we have - matched any of the pattern so far this time through the reg_num-th - subexpression. These two fields get reset each time through any - loop their register is in. */ - register_info_type *reg_info; - - /* The following record the register info as found in the above - variables when we find a match better than any we've seen before. - This happens as we backtrack through the failure points, which in - turn happens only if we have not yet matched the entire string. */ - unsigned best_regs_set = false; - const char **best_regstart, **best_regend; - - /* Logically, this is `best_regend[0]'. But we don't want to have to - allocate space for that if we're not allocating space for anything - else (see below). Also, we never need info about register 0 for - any of the other register vectors, and it seems rather a kludge to - treat `best_regend' differently than the rest. So we keep track of - the end of the best match so far in a separate variable. We - initialize this to NULL so that when we backtrack the first time - and need to test it, it's not garbage. */ - const char *match_end = NULL; - - /* Used when we pop values we don't care about. */ - const char **reg_dummy; - register_info_type *reg_info_dummy; - -#ifdef DEBUG - /* Counts the total number of registers pushed. */ - unsigned num_regs_pushed = 0; -#endif - - DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); - - INIT_FAIL_STACK (); - - /* Do not bother to initialize all the register variables if there are - no groups in the pattern, as it takes a fair amount of time. If - there are groups, we include space for register 0 (the whole - pattern), even though we never use it, since it simplifies the - array indexing. We should fix this. */ - if (bufp->re_nsub) - { - regstart = REGEX_TALLOC (num_regs, const char *); - regend = REGEX_TALLOC (num_regs, const char *); - old_regstart = REGEX_TALLOC (num_regs, const char *); - old_regend = REGEX_TALLOC (num_regs, const char *); - best_regstart = REGEX_TALLOC (num_regs, const char *); - best_regend = REGEX_TALLOC (num_regs, const char *); - reg_info = REGEX_TALLOC (num_regs, register_info_type); - reg_dummy = REGEX_TALLOC (num_regs, const char *); - reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); - - if (!(regstart && regend && old_regstart && old_regend && reg_info - && best_regstart && best_regend && reg_dummy && reg_info_dummy)) - { - FREE_VARIABLES (); - return -2; - } - } -#ifdef REGEX_MALLOC - else - { - /* We must initialize all our variables to NULL, so that - `FREE_VARIABLES' doesn't try to free them. */ - regstart = regend = old_regstart = old_regend = best_regstart - = best_regend = reg_dummy = NULL; - reg_info = reg_info_dummy = (register_info_type *) NULL; - } -#endif /* REGEX_MALLOC */ - - /* The starting position is bogus. */ - if (pos < 0 || pos > size1 + size2) - { - FREE_VARIABLES (); - return -1; - } - - /* Initialize subexpression text positions to -1 to mark ones that no - start_memory/stop_memory has been seen for. Also initialize the - register information struct. */ - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - regstart[mcnt] = regend[mcnt] - = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE; - - REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; - IS_ACTIVE (reg_info[mcnt]) = 0; - MATCHED_SOMETHING (reg_info[mcnt]) = 0; - EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; - } - - /* We move `string1' into `string2' if the latter's empty -- but not if - `string1' is null. */ - if (size2 == 0 && string1 != NULL) - { - string2 = string1; - size2 = size1; - string1 = 0; - size1 = 0; - } - end1 = string1 + size1; - end2 = string2 + size2; - - /* Compute where to stop matching, within the two strings. */ - if (stop <= size1) - { - end_match_1 = string1 + stop; - end_match_2 = string2; - } - else - { - end_match_1 = end1; - end_match_2 = string2 + stop - size1; - } - - /* `p' scans through the pattern as `d' scans through the data. - `dend' is the end of the input string that `d' points within. `d' - is advanced into the following input string whenever necessary, but - this happens before fetching; therefore, at the beginning of the - loop, `d' can be pointing at the end of a string, but it cannot - equal `string2'. */ - if (size1 > 0 && pos <= size1) - { - d = string1 + pos; - dend = end_match_1; - } - else - { - d = string2 + pos - size1; - dend = end_match_2; - } - - DEBUG_PRINT1 ("The compiled pattern is: "); - DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend); - DEBUG_PRINT1 ("The string to match is: `"); - DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); - DEBUG_PRINT1 ("'\n"); - - /* This loops over pattern commands. It exits by returning from the - function if the match is complete, or it drops through if the match - fails at this starting point in the input data. */ - for (;;) - { - DEBUG_PRINT2 ("\n0x%x: ", p); - - if (p == pend) - { /* End of pattern means we might have succeeded. */ - DEBUG_PRINT1 ("end of pattern ... "); - - /* If we haven't matched the entire string, and we want the - longest match, try backtracking. */ - if (d != end_match_2) - { - DEBUG_PRINT1 ("backtracking.\n"); - - if (!FAIL_STACK_EMPTY ()) - { /* More failure points to try. */ - boolean same_str_p = (FIRST_STRING_P (match_end) - == MATCHING_IN_FIRST_STRING); - - /* If exceeds best match so far, save it. */ - if (!best_regs_set - || (same_str_p && d > match_end) - || (!same_str_p && !MATCHING_IN_FIRST_STRING)) - { - best_regs_set = true; - match_end = d; - - DEBUG_PRINT1 ("\nSAVING match as best so far.\n"); - - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - best_regstart[mcnt] = regstart[mcnt]; - best_regend[mcnt] = regend[mcnt]; - } - } - goto fail; - } - - /* If no failure points, don't restore garbage. */ - else if (best_regs_set) - { - restore_best_regs: - /* Restore best match. It may happen that `dend == - end_match_1' while the restored d is in string2. - For example, the pattern `x.*y.*z' against the - strings `x-' and `y-z-', if the two strings are - not consecutive in memory. */ - DEBUG_PRINT1 ("Restoring best registers.\n"); - - d = match_end; - dend = ((d >= string1 && d <= end1) - ? end_match_1 : end_match_2); - - for (mcnt = 1; mcnt < num_regs; mcnt++) - { - regstart[mcnt] = best_regstart[mcnt]; - regend[mcnt] = best_regend[mcnt]; - } - } - } /* d != end_match_2 */ - - DEBUG_PRINT1 ("Accepting match.\n"); - - /* If caller wants register contents data back, do it. */ - if (regs && !bufp->no_sub) - { - /* Have the register data arrays been allocated? */ - if (bufp->regs_allocated == REGS_UNALLOCATED) - { /* No. So allocate them with malloc. We need one - extra element beyond `num_regs' for the `-1' marker - GNU code uses. */ - regs->num_regs = MAX (RE_NREGS, num_regs + 1); - regs->start = TALLOC (regs->num_regs, regoff_t); - regs->end = TALLOC (regs->num_regs, regoff_t); - if (regs->start == NULL || regs->end == NULL) - return -2; - bufp->regs_allocated = REGS_REALLOCATE; - } - else if (bufp->regs_allocated == REGS_REALLOCATE) - { /* Yes. If we need more elements than were already - allocated, reallocate them. If we need fewer, just - leave it alone. */ - if (regs->num_regs < num_regs + 1) - { - regs->num_regs = num_regs + 1; - RETALLOC (regs->start, regs->num_regs, regoff_t); - RETALLOC (regs->end, regs->num_regs, regoff_t); - if (regs->start == NULL || regs->end == NULL) - return -2; - } - } - else - assert (bufp->regs_allocated == REGS_FIXED); - - /* Convert the pointer data in `regstart' and `regend' to - indices. Register zero has to be set differently, - since we haven't kept track of any info for it. */ - if (regs->num_regs > 0) - { - regs->start[0] = pos; - regs->end[0] = (MATCHING_IN_FIRST_STRING ? d - string1 - : d - string2 + size1); - } - - /* Go through the first `min (num_regs, regs->num_regs)' - registers, since that is all we initialized. */ - for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++) - { - if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt])) - regs->start[mcnt] = regs->end[mcnt] = -1; - else - { - regs->start[mcnt] = POINTER_TO_OFFSET (regstart[mcnt]); - regs->end[mcnt] = POINTER_TO_OFFSET (regend[mcnt]); - } - } - - /* If the regs structure we return has more elements than - were in the pattern, set the extra elements to -1. If - we (re)allocated the registers, this is the case, - because we always allocate enough to have at least one - -1 at the end. */ - for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++) - regs->start[mcnt] = regs->end[mcnt] = -1; - } /* regs && !bufp->no_sub */ - - FREE_VARIABLES (); - DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", - nfailure_points_pushed, nfailure_points_popped, - nfailure_points_pushed - nfailure_points_popped); - DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); - - mcnt = d - pos - (MATCHING_IN_FIRST_STRING - ? string1 - : string2 - size1); - - DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); - - return mcnt; - } - - /* Otherwise match next pattern command. */ -#ifdef SWITCH_ENUM_BUG - switch ((int) ((re_opcode_t) *p++)) -#else - switch ((re_opcode_t) *p++) -#endif - { - /* Ignore these. Used to ignore the n of succeed_n's which - currently have n == 0. */ - case no_op: - DEBUG_PRINT1 ("EXECUTING no_op.\n"); - break; - - - /* Match the next n pattern characters exactly. The following - byte in the pattern defines n, and the n bytes after that - are the characters to match. */ - case exactn: - mcnt = *p++; - DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt); - - /* This is written out as an if-else so we don't waste time - testing `translate' inside the loop. */ - if (translate) - { - do - { - PREFETCH (); - if (translate[(unsigned char) *d++] != (char) *p++) - goto fail; - } - while (--mcnt); - } - else - { - do - { - PREFETCH (); - if (*d++ != (char) *p++) goto fail; - } - while (--mcnt); - } - SET_REGS_MATCHED (); - break; - - - /* Match any character except possibly a newline or a null. */ - case anychar: - DEBUG_PRINT1 ("EXECUTING anychar.\n"); - - PREFETCH (); - - if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n') - || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000')) - goto fail; - - SET_REGS_MATCHED (); - DEBUG_PRINT2 (" Matched `%d'.\n", *d); - d++; - break; - - - case charset: - case charset_not: - { - register unsigned char c; - boolean not = (re_opcode_t) *(p - 1) == charset_not; - - DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); - - PREFETCH (); - c = TRANSLATE (*d); /* The character to match. */ - - /* Cast to `unsigned' instead of `unsigned char' in case the - bit list is a full 32 bytes long. */ - if (c < (unsigned) (*p * BYTEWIDTH) - && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - p += 1 + *p; - - if (!not) goto fail; - - SET_REGS_MATCHED (); - d++; - break; - } - - - /* The beginning of a group is represented by start_memory. - The arguments are the register number in the next byte, and the - number of groups inner to this one in the next. The text - matched within the group is recorded (in the internal - registers data structure) under the register number. */ - case start_memory: - DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]); - - /* Find out if this group can match the empty string. */ - p1 = p; /* To send to group_match_null_string_p. */ - - if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) - REG_MATCH_NULL_STRING_P (reg_info[*p]) - = group_match_null_string_p (&p1, pend, reg_info); - - /* Save the position in the string where we were the last time - we were at this open-group operator in case the group is - operated upon by a repetition operator, e.g., with `(a*)*b' - against `ab'; then we want to ignore where we are now in - the string in case this attempt to match fails. */ - old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) - ? REG_UNSET (regstart[*p]) ? d : regstart[*p] - : regstart[*p]; - DEBUG_PRINT2 (" old_regstart: %d\n", - POINTER_TO_OFFSET (old_regstart[*p])); - - regstart[*p] = d; - DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p])); - - IS_ACTIVE (reg_info[*p]) = 1; - MATCHED_SOMETHING (reg_info[*p]) = 0; - - /* This is the new highest active register. */ - highest_active_reg = *p; - - /* If nothing was active before, this is the new lowest active - register. */ - if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) - lowest_active_reg = *p; - - /* Move past the register number and inner group count. */ - p += 2; - break; - - - /* The stop_memory opcode represents the end of a group. Its - arguments are the same as start_memory's: the register - number, and the number of inner groups. */ - case stop_memory: - DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]); - - /* We need to save the string position the last time we were at - this close-group operator in case the group is operated - upon by a repetition operator, e.g., with `((a*)*(b*)*)*' - against `aba'; then we want to ignore where we are now in - the string in case this attempt to match fails. */ - old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) - ? REG_UNSET (regend[*p]) ? d : regend[*p] - : regend[*p]; - DEBUG_PRINT2 (" old_regend: %d\n", - POINTER_TO_OFFSET (old_regend[*p])); - - regend[*p] = d; - DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p])); - - /* This register isn't active anymore. */ - IS_ACTIVE (reg_info[*p]) = 0; - - /* If this was the only register active, nothing is active - anymore. */ - if (lowest_active_reg == highest_active_reg) - { - lowest_active_reg = NO_LOWEST_ACTIVE_REG; - highest_active_reg = NO_HIGHEST_ACTIVE_REG; - } - else - { /* We must scan for the new highest active register, since - it isn't necessarily one less than now: consider - (a(b)c(d(e)f)g). When group 3 ends, after the f), the - new highest active register is 1. */ - unsigned char r = *p - 1; - while (r > 0 && !IS_ACTIVE (reg_info[r])) - r--; - - /* If we end up at register zero, that means that we saved - the registers as the result of an `on_failure_jump', not - a `start_memory', and we jumped to past the innermost - `stop_memory'. For example, in ((.)*) we save - registers 1 and 2 as a result of the *, but when we pop - back to the second ), we are at the stop_memory 1. - Thus, nothing is active. */ - if (r == 0) - { - lowest_active_reg = NO_LOWEST_ACTIVE_REG; - highest_active_reg = NO_HIGHEST_ACTIVE_REG; - } - else - highest_active_reg = r; - } - - /* If just failed to match something this time around with a - group that's operated on by a repetition operator, try to - force exit from the ``loop'', and restore the register - information for this group that we had before trying this - last match. */ - if ((!MATCHED_SOMETHING (reg_info[*p]) - || (re_opcode_t) p[-3] == start_memory) - && (p + 2) < pend) - { - boolean is_a_jump_n = false; - - p1 = p + 2; - mcnt = 0; - switch ((re_opcode_t) *p1++) - { - case jump_n: - is_a_jump_n = true; - case pop_failure_jump: - case maybe_pop_jump: - case jump: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if (is_a_jump_n) - p1 += 2; - break; - - default: - /* do nothing */ ; - } - p1 += mcnt; - - /* If the next operation is a jump backwards in the pattern - to an on_failure_jump right before the start_memory - corresponding to this stop_memory, exit from the loop - by forcing a failure after pushing on the stack the - on_failure_jump's jump in the pattern, and d. */ - if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump - && (re_opcode_t) p1[3] == start_memory && p1[4] == *p) - { - /* If this group ever matched anything, then restore - what its registers were before trying this last - failed match, e.g., with `(a*)*b' against `ab' for - regstart[1], and, e.g., with `((a*)*(b*)*)*' - against `aba' for regend[3]. - - Also restore the registers for inner groups for, - e.g., `((a*)(b*))*' against `aba' (register 3 would - otherwise get trashed). */ - - if (EVER_MATCHED_SOMETHING (reg_info[*p])) - { - unsigned r; - - EVER_MATCHED_SOMETHING (reg_info[*p]) = 0; - - /* Restore this and inner groups' (if any) registers. */ - for (r = *p; r < *p + *(p + 1); r++) - { - regstart[r] = old_regstart[r]; - - /* xx why this test? */ - if ((int) old_regend[r] >= (int) regstart[r]) - regend[r] = old_regend[r]; - } - } - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - PUSH_FAILURE_POINT (p1 + mcnt, d, -2); - - goto fail; - } - } - - /* Move past the register number and the inner group count. */ - p += 2; - break; - - - /* \ has been turned into a `duplicate' command which is - followed by the numeric value of as the register number. */ - case duplicate: - { - register const char *d2, *dend2; - int regno = *p++; /* Get which register to match against. */ - DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno); - - /* Can't back reference a group which we've never matched. */ - if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) - goto fail; - - /* Where in input to try to start matching. */ - d2 = regstart[regno]; - - /* Where to stop matching; if both the place to start and - the place to stop matching are in the same string, then - set to the place to stop, otherwise, for now have to use - the end of the first string. */ - - dend2 = ((FIRST_STRING_P (regstart[regno]) - == FIRST_STRING_P (regend[regno])) - ? regend[regno] : end_match_1); - for (;;) - { - /* If necessary, advance to next segment in register - contents. */ - while (d2 == dend2) - { - if (dend2 == end_match_2) break; - if (dend2 == regend[regno]) break; - - /* End of string1 => advance to string2. */ - d2 = string2; - dend2 = regend[regno]; - } - /* At end of register contents => success */ - if (d2 == dend2) break; - - /* If necessary, advance to next segment in data. */ - PREFETCH (); - - /* How many characters left in this segment to match. */ - mcnt = dend - d; - - /* Want how many consecutive characters we can match in - one shot, so, if necessary, adjust the count. */ - if (mcnt > dend2 - d2) - mcnt = dend2 - d2; - - /* Compare that many; failure if mismatch, else move - past them. */ - if (translate - ? bcmp_translate (d, d2, mcnt, translate) - : bcmp (d, d2, mcnt)) - goto fail; - d += mcnt, d2 += mcnt; - } - } - break; - - - /* begline matches the empty string at the beginning of the string - (unless `not_bol' is set in `bufp'), and, if - `newline_anchor' is set, after newlines. */ - case begline: - DEBUG_PRINT1 ("EXECUTING begline.\n"); - - if (AT_STRINGS_BEG (d)) - { - if (!bufp->not_bol) break; - } - else if (d[-1] == '\n' && bufp->newline_anchor) - { - break; - } - /* In all other cases, we fail. */ - goto fail; - - - /* endline is the dual of begline. */ - case endline: - DEBUG_PRINT1 ("EXECUTING endline.\n"); - - if (AT_STRINGS_END (d)) - { - if (!bufp->not_eol) break; - } - - /* We have to ``prefetch'' the next character. */ - else if ((d == end1 ? *string2 : *d) == '\n' - && bufp->newline_anchor) - { - break; - } - goto fail; - - - /* Match at the very beginning of the data. */ - case begbuf: - DEBUG_PRINT1 ("EXECUTING begbuf.\n"); - if (AT_STRINGS_BEG (d)) - break; - goto fail; - - - /* Match at the very end of the data. */ - case endbuf: - DEBUG_PRINT1 ("EXECUTING endbuf.\n"); - if (AT_STRINGS_END (d)) - break; - goto fail; - - - /* on_failure_keep_string_jump is used to optimize `.*\n'. It - pushes NULL as the value for the string on the stack. Then - `pop_failure_point' will keep the current value for the - string, instead of restoring it. To see why, consider - matching `foo\nbar' against `.*\n'. The .* matches the foo; - then the . fails against the \n. But the next thing we want - to do is match the \n against the \n; if we restored the - string value, we would be back at the foo. - - Because this is used only in specific cases, we don't need to - check all the things that `on_failure_jump' does, to make - sure the right things get saved on the stack. Hence we don't - share its code. The only reason to push anything on the - stack at all is that otherwise we would have to change - `anychar's code to do something besides goto fail in this - case; that seems worse than this. */ - case on_failure_keep_string_jump: - DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt); - - PUSH_FAILURE_POINT (p + mcnt, NULL, -2); - break; - - - /* Uses of on_failure_jump: - - Each alternative starts with an on_failure_jump that points - to the beginning of the next alternative. Each alternative - except the last ends with a jump that in effect jumps past - the rest of the alternatives. (They really jump to the - ending jump of the following alternative, because tensioning - these jumps is a hassle.) - - Repeats start with an on_failure_jump that points past both - the repetition text and either the following jump or - pop_failure_jump back to this on_failure_jump. */ - case on_failure_jump: - on_failure: - DEBUG_PRINT1 ("EXECUTING on_failure_jump"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt); - - /* If this on_failure_jump comes right before a group (i.e., - the original * applied to a group), save the information - for that group and all inner ones, so that if we fail back - to this point, the group's information will be correct. - For example, in \(a*\)*\1, we need the preceding group, - and in \(\(a*\)b*\)\2, we need the inner group. */ - - /* We can't use `p' to check ahead because we push - a failure point to `p + mcnt' after we do this. */ - p1 = p; - - /* We need to skip no_op's before we look for the - start_memory in case this on_failure_jump is happening as - the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 - against aba. */ - while (p1 < pend && (re_opcode_t) *p1 == no_op) - p1++; - - if (p1 < pend && (re_opcode_t) *p1 == start_memory) - { - /* We have a new highest active register now. This will - get reset at the start_memory we are about to get to, - but we will have saved all the registers relevant to - this repetition op, as described above. */ - highest_active_reg = *(p1 + 1) + *(p1 + 2); - if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) - lowest_active_reg = *(p1 + 1); - } - - DEBUG_PRINT1 (":\n"); - PUSH_FAILURE_POINT (p + mcnt, d, -2); - break; - - - /* A smart repeat ends with `maybe_pop_jump'. - We change it to either `pop_failure_jump' or `jump'. */ - case maybe_pop_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); - { - register unsigned char *p2 = p; - - /* Compare the beginning of the repeat with what in the - pattern follows its end. If we can establish that there - is nothing that they would both match, i.e., that we - would have to backtrack because of (as in, e.g., `a*a') - then we can change to pop_failure_jump, because we'll - never have to backtrack. - - This is not true in the case of alternatives: in - `(a|ab)*' we do need to backtrack to the `ab' alternative - (e.g., if the string was `ab'). But instead of trying to - detect that here, the alternative has put on a dummy - failure point which is what we will end up popping. */ - - /* Skip over open/close-group commands. */ - while (p2 + 2 < pend - && ((re_opcode_t) *p2 == stop_memory - || (re_opcode_t) *p2 == start_memory)) - p2 += 3; /* Skip over args, too. */ - - /* If we're at the end of the pattern, we can change. */ - if (p2 == pend) - { - /* Consider what happens when matching ":\(.*\)" - against ":/". I don't really understand this code - yet. */ - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT1 - (" End of pattern: change to `pop_failure_jump'.\n"); - } - - else if ((re_opcode_t) *p2 == exactn - || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) - { - register unsigned char c - = *p2 == (unsigned char) endline ? '\n' : p2[2]; - p1 = p + mcnt; - - /* p1[0] ... p1[2] are the `on_failure_jump' corresponding - to the `maybe_finalize_jump' of this case. Examine what - follows. */ - if ((re_opcode_t) p1[3] == exactn && p1[5] != c) - { - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", - c, p1[5]); - } - - else if ((re_opcode_t) p1[3] == charset - || (re_opcode_t) p1[3] == charset_not) - { - int not = (re_opcode_t) p1[3] == charset_not; - - if (c < (unsigned char) (p1[4] * BYTEWIDTH) - && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - /* `not' is equal to 1 if c would match, which means - that we can't change to pop_failure_jump. */ - if (!not) - { - p[-3] = (unsigned char) pop_failure_jump; - DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); - } - } - } - } - p -= 2; /* Point at relative address again. */ - if ((re_opcode_t) p[-1] != pop_failure_jump) - { - p[-1] = (unsigned char) jump; - DEBUG_PRINT1 (" Match => jump.\n"); - goto unconditional_jump; - } - /* Note fall through. */ - - - /* The end of a simple repeat has a pop_failure_jump back to - its matching on_failure_jump, where the latter will push a - failure point. The pop_failure_jump takes off failure - points put on by this pop_failure_jump's matching - on_failure_jump; we got through the pattern to here from the - matching on_failure_jump, so didn't fail. */ - case pop_failure_jump: - { - /* We need to pass separate storage for the lowest and - highest registers, even though we don't care about the - actual values. Otherwise, we will restore only one - register from the stack, since lowest will == highest in - `pop_failure_point'. */ - unsigned dummy_low_reg, dummy_high_reg; - unsigned char *pdummy; - const char *sdummy; - - DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n"); - POP_FAILURE_POINT (sdummy, pdummy, - dummy_low_reg, dummy_high_reg, - reg_dummy, reg_dummy, reg_info_dummy); - } - /* Note fall through. */ - - - /* Unconditionally jump (without popping any failure points). */ - case jump: - unconditional_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ - DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); - p += mcnt; /* Do the jump. */ - DEBUG_PRINT2 ("(to 0x%x).\n", p); - break; - - - /* We need this opcode so we can detect where alternatives end - in `group_match_null_string_p' et al. */ - case jump_past_alt: - DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n"); - goto unconditional_jump; - - - /* Normally, the on_failure_jump pushes a failure point, which - then gets popped at pop_failure_jump. We will end up at - pop_failure_jump, also, and with a pattern of, say, `a+', we - are skipping over the on_failure_jump, so we have to push - something meaningless for pop_failure_jump to pop. */ - case dummy_failure_jump: - DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n"); - /* It doesn't matter what we push for the string here. What - the code at `fail' tests is the value for the pattern. */ - PUSH_FAILURE_POINT (0, 0, -2); - goto unconditional_jump; - - - /* At the end of an alternative, we need to push a dummy failure - point in case we are followed by a `pop_failure_jump', because - we don't want the failure point for the alternative to be - popped. For example, matching `(a|ab)*' against `aab' - requires that we match the `ab' alternative. */ - case push_dummy_failure: - DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); - /* See comments just above at `dummy_failure_jump' about the - two zeroes. */ - PUSH_FAILURE_POINT (0, 0, -2); - break; - - /* Have to succeed matching what follows at least n times. - After that, handle like `on_failure_jump'. */ - case succeed_n: - EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); - - assert (mcnt >= 0); - /* Originally, this is how many times we HAVE to succeed. */ - if (mcnt > 0) - { - mcnt--; - p += 2; - STORE_NUMBER_AND_INCR (p, mcnt); - DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p, mcnt); - } - else if (mcnt == 0) - { - DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2); - p[2] = (unsigned char) no_op; - p[3] = (unsigned char) no_op; - goto on_failure; - } - break; - - case jump_n: - EXTRACT_NUMBER (mcnt, p + 2); - DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); - - /* Originally, this is how many times we CAN jump. */ - if (mcnt) - { - mcnt--; - STORE_NUMBER (p + 2, mcnt); - goto unconditional_jump; - } - /* If don't have to jump any more, skip over the rest of command. */ - else - p += 4; - break; - - case set_number_at: - { - DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - p1 = p + mcnt; - EXTRACT_NUMBER_AND_INCR (mcnt, p); - DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt); - STORE_NUMBER (p1, mcnt); - break; - } - - case wordbound: - DEBUG_PRINT1 ("EXECUTING wordbound.\n"); - if (AT_WORD_BOUNDARY (d)) - break; - goto fail; - - case notwordbound: - DEBUG_PRINT1 ("EXECUTING notwordbound.\n"); - if (AT_WORD_BOUNDARY (d)) - goto fail; - break; - - case wordbeg: - DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); - if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) - break; - goto fail; - - case wordend: - DEBUG_PRINT1 ("EXECUTING wordend.\n"); - if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) - && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) - break; - goto fail; - -#ifdef emacs -#ifdef emacs19 - case before_dot: - DEBUG_PRINT1 ("EXECUTING before_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) >= point) - goto fail; - break; - - case at_dot: - DEBUG_PRINT1 ("EXECUTING at_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) != point) - goto fail; - break; - - case after_dot: - DEBUG_PRINT1 ("EXECUTING after_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) <= point) - goto fail; - break; -#else /* not emacs19 */ - case at_dot: - DEBUG_PRINT1 ("EXECUTING at_dot.\n"); - if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point) - goto fail; - break; -#endif /* not emacs19 */ - - case syntaxspec: - DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); - mcnt = *p++; - goto matchsyntax; - - case wordchar: - DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n"); - mcnt = (int) Sword; - matchsyntax: - PREFETCH (); - if (SYNTAX (*d++) != (enum syntaxcode) mcnt) - goto fail; - SET_REGS_MATCHED (); - break; - - case notsyntaxspec: - DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); - mcnt = *p++; - goto matchnotsyntax; - - case notwordchar: - DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n"); - mcnt = (int) Sword; - matchnotsyntax: - PREFETCH (); - if (SYNTAX (*d++) == (enum syntaxcode) mcnt) - goto fail; - SET_REGS_MATCHED (); - break; - -#else /* not emacs */ - case wordchar: - DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); - PREFETCH (); - if (!WORDCHAR_P (d)) - goto fail; - SET_REGS_MATCHED (); - d++; - break; - - case notwordchar: - DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); - PREFETCH (); - if (WORDCHAR_P (d)) - goto fail; - SET_REGS_MATCHED (); - d++; - break; -#endif /* not emacs */ - - default: - abort (); - } - continue; /* Successfully executed one pattern command; keep going. */ - - - /* We goto here if a matching operation fails. */ - fail: - if (!FAIL_STACK_EMPTY ()) - { /* A restart point is known. Restore to that state. */ - DEBUG_PRINT1 ("\nFAIL:\n"); - POP_FAILURE_POINT (d, p, - lowest_active_reg, highest_active_reg, - regstart, regend, reg_info); - - /* If this failure point is a dummy, try the next one. */ - if (!p) - goto fail; - - /* If we failed to the end of the pattern, don't examine *p. */ - assert (p <= pend); - if (p < pend) - { - boolean is_a_jump_n = false; - - /* If failed to a backwards jump that's part of a repetition - loop, need to pop this failure point and use the next one. */ - switch ((re_opcode_t) *p) - { - case jump_n: - is_a_jump_n = true; - case maybe_pop_jump: - case pop_failure_jump: - case jump: - p1 = p + 1; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - - if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n) - || (!is_a_jump_n - && (re_opcode_t) *p1 == on_failure_jump)) - goto fail; - break; - default: - /* do nothing */ ; - } - } - - if (d >= string1 && d <= end1) - dend = end_match_1; - } - else - break; /* Matching at this starting point really fails. */ - } /* for (;;) */ - - if (best_regs_set) - goto restore_best_regs; - - FREE_VARIABLES (); - - return -1; /* Failure to match. */ -} /* re_match_2 */ - -/* Subroutine definitions for re_match_2. */ - - -/* We are passed P pointing to a register number after a start_memory. - - Return true if the pattern up to the corresponding stop_memory can - match the empty string, and false otherwise. - - If we find the matching stop_memory, sets P to point to one past its number. - Otherwise, sets P to an undefined byte less than or equal to END. - - We don't handle duplicates properly (yet). */ - -static boolean -group_match_null_string_p (p, end, reg_info) - unsigned char **p, *end; - register_info_type *reg_info; -{ - int mcnt; - /* Point to after the args to the start_memory. */ - unsigned char *p1 = *p + 2; - - while (p1 < end) - { - /* Skip over opcodes that can match nothing, and return true or - false, as appropriate, when we get to one that can't, or to the - matching stop_memory. */ - - switch ((re_opcode_t) *p1) - { - /* Could be either a loop or a series of alternatives. */ - case on_failure_jump: - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - - /* If the next operation is not a jump backwards in the - pattern. */ - - if (mcnt >= 0) - { - /* Go through the on_failure_jumps of the alternatives, - seeing if any of the alternatives cannot match nothing. - The last alternative starts with only a jump, - whereas the rest start with on_failure_jump and end - with a jump, e.g., here is the pattern for `a|b|c': - - /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6 - /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3 - /exactn/1/c - - So, we have to first go through the first (n-1) - alternatives and then deal with the last one separately. */ - - - /* Deal with the first (n-1) alternatives, which start - with an on_failure_jump (see above) that jumps to right - past a jump_past_alt. */ - - while ((re_opcode_t) p1[mcnt-3] == jump_past_alt) - { - /* `mcnt' holds how many bytes long the alternative - is, including the ending `jump_past_alt' and - its number. */ - - if (!alt_match_null_string_p (p1, p1 + mcnt - 3, - reg_info)) - return false; - - /* Move to right after this alternative, including the - jump_past_alt. */ - p1 += mcnt; - - /* Break if it's the beginning of an n-th alternative - that doesn't begin with an on_failure_jump. */ - if ((re_opcode_t) *p1 != on_failure_jump) - break; - - /* Still have to check that it's not an n-th - alternative that starts with an on_failure_jump. */ - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if ((re_opcode_t) p1[mcnt-3] != jump_past_alt) - { - /* Get to the beginning of the n-th alternative. */ - p1 -= 3; - break; - } - } - - /* Deal with the last alternative: go back and get number - of the `jump_past_alt' just before it. `mcnt' contains - the length of the alternative. */ - EXTRACT_NUMBER (mcnt, p1 - 2); - - if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info)) - return false; - - p1 += mcnt; /* Get past the n-th alternative. */ - } /* if mcnt > 0 */ - break; - - - case stop_memory: - assert (p1[1] == **p); - *p = p1 + 2; - return true; - - - default: - if (!common_op_match_null_string_p (&p1, end, reg_info)) - return false; - } - } /* while p1 < end */ - - return false; -} /* group_match_null_string_p */ - - -/* Similar to group_match_null_string_p, but doesn't deal with alternatives: - It expects P to be the first byte of a single alternative and END one - byte past the last. The alternative can contain groups. */ - -static boolean -alt_match_null_string_p (p, end, reg_info) - unsigned char *p, *end; - register_info_type *reg_info; -{ - int mcnt; - unsigned char *p1 = p; - - while (p1 < end) - { - /* Skip over opcodes that can match nothing, and break when we get - to one that can't. */ - - switch ((re_opcode_t) *p1) - { - /* It's a loop. */ - case on_failure_jump: - p1++; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - break; - - default: - if (!common_op_match_null_string_p (&p1, end, reg_info)) - return false; - } - } /* while p1 < end */ - - return true; -} /* alt_match_null_string_p */ - - -/* Deals with the ops common to group_match_null_string_p and - alt_match_null_string_p. - - Sets P to one after the op and its arguments, if any. */ - -static boolean -common_op_match_null_string_p (p, end, reg_info) - unsigned char **p, *end; - register_info_type *reg_info; -{ - int mcnt; - boolean ret; - int reg_no; - unsigned char *p1 = *p; - - switch ((re_opcode_t) *p1++) - { - case no_op: - case begline: - case endline: - case begbuf: - case endbuf: - case wordbeg: - case wordend: - case wordbound: - case notwordbound: -#ifdef emacs - case before_dot: - case at_dot: - case after_dot: -#endif - break; - - case start_memory: - reg_no = *p1; - assert (reg_no > 0 && reg_no <= MAX_REGNUM); - ret = group_match_null_string_p (&p1, end, reg_info); - - /* Have to set this here in case we're checking a group which - contains a group and a back reference to it. */ - - if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE) - REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret; - - if (!ret) - return false; - break; - - /* If this is an optimized succeed_n for zero times, make the jump. */ - case jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - if (mcnt >= 0) - p1 += mcnt; - else - return false; - break; - - case succeed_n: - /* Get to the number of times to succeed. */ - p1 += 2; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - - if (mcnt == 0) - { - p1 -= 4; - EXTRACT_NUMBER_AND_INCR (mcnt, p1); - p1 += mcnt; - } - else - return false; - break; - - case duplicate: - if (!REG_MATCH_NULL_STRING_P (reg_info[*p1])) - return false; - break; - - case set_number_at: - p1 += 4; - - default: - /* All other opcodes mean we cannot match the empty string. */ - return false; - } - - *p = p1; - return true; -} /* common_op_match_null_string_p */ - - -/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN - bytes; nonzero otherwise. */ - -static int -bcmp_translate (s1, s2, len, translate) - unsigned char *s1, *s2; - register int len; - char *translate; -{ - register unsigned char *p1 = s1, *p2 = s2; - while (len) - { - if (translate[*p1++] != translate[*p2++]) return 1; - len--; - } - return 0; -} - -/* Entry points for GNU code. */ - -/* re_compile_pattern is the GNU regular expression compiler: it - compiles PATTERN (of length SIZE) and puts the result in BUFP. - Returns 0 if the pattern was valid, otherwise an error string. - - Assumes the `allocated' (and perhaps `buffer') and `translate' fields - are set in BUFP on entry. - - We call regex_compile to do the actual compilation. */ - -const char * -re_compile_pattern (pattern, length, bufp) - const char *pattern; - int length; - struct re_pattern_buffer *bufp; -{ - reg_errcode_t ret; - - /* GNU code is written to assume at least RE_NREGS registers will be set - (and at least one extra will be -1). */ - bufp->regs_allocated = REGS_UNALLOCATED; - - /* And GNU code determines whether or not to get register information - by passing null for the REGS argument to re_match, etc., not by - setting no_sub. */ - bufp->no_sub = 0; - - /* Match anchors at newline. */ - bufp->newline_anchor = 1; - - ret = regex_compile (pattern, length, re_syntax_options, bufp); - - return re_error_msg[(int) ret]; -} - -/* Entry points compatible with 4.2 BSD regex library. We don't define - them if this is an Emacs or POSIX compilation. */ - -#if !defined (emacs) && !defined (_POSIX_SOURCE) - -/* BSD has one and only one pattern buffer. */ -static struct re_pattern_buffer re_comp_buf; - -char * -re_comp (s) - const char *s; -{ - reg_errcode_t ret; - - if (!s) - { - if (!re_comp_buf.buffer) - return "No previous regular expression"; - return 0; - } - - if (!re_comp_buf.buffer) - { - re_comp_buf.buffer = (unsigned char *) malloc (200); - if (re_comp_buf.buffer == NULL) - return "Memory exhausted"; - re_comp_buf.allocated = 200; - - re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); - if (re_comp_buf.fastmap == NULL) - return "Memory exhausted"; - } - - /* Since `re_exec' always passes NULL for the `regs' argument, we - don't need to initialize the pattern buffer fields which affect it. */ - - /* Match anchors at newlines. */ - re_comp_buf.newline_anchor = 1; - - ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); - - /* Yes, we're discarding `const' here. */ - return (char *) re_error_msg[(int) ret]; -} - - -int -re_exec (s) - const char *s; -{ - const int len = strlen (s); - return - 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); -} -#endif /* not emacs and not _POSIX_SOURCE */ - -/* POSIX.2 functions. Don't define these for Emacs. */ - -#ifndef emacs - -/* regcomp takes a regular expression as a string and compiles it. - - PREG is a regex_t *. We do not expect any fields to be initialized, - since POSIX says we shouldn't. Thus, we set - - `buffer' to the compiled pattern; - `used' to the length of the compiled pattern; - `syntax' to RE_SYNTAX_POSIX_EXTENDED if the - REG_EXTENDED bit in CFLAGS is set; otherwise, to - RE_SYNTAX_POSIX_BASIC; - `newline_anchor' to REG_NEWLINE being set in CFLAGS; - `fastmap' and `fastmap_accurate' to zero; - `re_nsub' to the number of subexpressions in PATTERN. - - PATTERN is the address of the pattern string. - - CFLAGS is a series of bits which affect compilation. - - If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we - use POSIX basic syntax. - - If REG_NEWLINE is set, then . and [^...] don't match newline. - Also, regexec will try a match beginning after every newline. - - If REG_ICASE is set, then we considers upper- and lowercase - versions of letters to be equivalent when matching. - - If REG_NOSUB is set, then when PREG is passed to regexec, that - routine will report only success or failure, and nothing about the - registers. - - It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for - the return codes and their meanings.) */ - -int -regcomp (preg, pattern, cflags) - regex_t *preg; - const char *pattern; - int cflags; -{ - reg_errcode_t ret; - unsigned syntax - = (cflags & REG_EXTENDED) ? - RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; - - /* regex_compile will allocate the space for the compiled pattern. */ - preg->buffer = 0; - preg->allocated = 0; - - /* Don't bother to use a fastmap when searching. This simplifies the - REG_NEWLINE case: if we used a fastmap, we'd have to put all the - characters after newlines into the fastmap. This way, we just try - every character. */ - preg->fastmap = 0; - - if (cflags & REG_ICASE) - { - unsigned i; - - preg->translate = (char *) malloc (CHAR_SET_SIZE); - if (preg->translate == NULL) - return (int) REG_ESPACE; - - /* Map uppercase characters to corresponding lowercase ones. */ - for (i = 0; i < CHAR_SET_SIZE; i++) - preg->translate[i] = ISUPPER (i) ? tolower (i) : i; - } - else - preg->translate = NULL; - - /* If REG_NEWLINE is set, newlines are treated differently. */ - if (cflags & REG_NEWLINE) - { /* REG_NEWLINE implies neither . nor [^...] match newline. */ - syntax &= ~RE_DOT_NEWLINE; - syntax |= RE_HAT_LISTS_NOT_NEWLINE; - /* It also changes the matching behavior. */ - preg->newline_anchor = 1; - } - else - preg->newline_anchor = 0; - - preg->no_sub = !!(cflags & REG_NOSUB); - - /* POSIX says a null character in the pattern terminates it, so we - can use strlen here in compiling the pattern. */ - ret = regex_compile (pattern, strlen (pattern), syntax, preg); - - /* POSIX doesn't distinguish between an unmatched open-group and an - unmatched close-group: both are REG_EPAREN. */ - if (ret == REG_ERPAREN) ret = REG_EPAREN; - - return (int) ret; -} - - -/* regexec searches for a given pattern, specified by PREG, in the - string STRING. - - If NMATCH is zero or REG_NOSUB was set in the cflags argument to - `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at - least NMATCH elements, and we set them to the offsets of the - corresponding matched substrings. - - EFLAGS specifies `execution flags' which affect matching: if - REG_NOTBOL is set, then ^ does not match at the beginning of the - string; if REG_NOTEOL is set, then $ does not match at the end. - - We return 0 if we find a match and REG_NOMATCH if not. */ - -int -regexec (preg, string, nmatch, pmatch, eflags) - const regex_t *preg; - const char *string; - size_t nmatch; - regmatch_t pmatch[]; - int eflags; -{ - int ret; - struct re_registers regs; - regex_t private_preg; - int len = strlen (string); - boolean want_reg_info = !preg->no_sub && nmatch > 0; - - private_preg = *preg; - - private_preg.not_bol = !!(eflags & REG_NOTBOL); - private_preg.not_eol = !!(eflags & REG_NOTEOL); - - /* The user has told us exactly how many registers to return - information about, via `nmatch'. We have to pass that on to the - matching routines. */ - private_preg.regs_allocated = REGS_FIXED; - - if (want_reg_info) - { - regs.num_regs = nmatch; - regs.start = TALLOC (nmatch, regoff_t); - regs.end = TALLOC (nmatch, regoff_t); - if (regs.start == NULL || regs.end == NULL) - return (int) REG_NOMATCH; - } - - /* Perform the searching operation. */ - ret = re_search (&private_preg, string, len, - /* start: */ 0, /* range: */ len, - want_reg_info ? ®s : (struct re_registers *) 0); - - /* Copy the register information to the POSIX structure. */ - if (want_reg_info) - { - if (ret >= 0) - { - unsigned r; - - for (r = 0; r < nmatch; r++) - { - pmatch[r].rm_so = regs.start[r]; - pmatch[r].rm_eo = regs.end[r]; - } - } - - /* If we needed the temporary register info, free the space now. */ - free (regs.start); - free (regs.end); - } - - /* We want zero return to mean success, unlike `re_search'. */ - return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH; -} - - -/* Returns a message corresponding to an error code, ERRCODE, returned - from either regcomp or regexec. We don't use PREG here. */ - -size_t -regerror (errcode, preg, errbuf, errbuf_size) - int errcode; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; -{ - const char *msg; - size_t msg_size; - - if (errcode < 0 - || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0]))) - /* Only error codes returned by the rest of the code should be passed - to this routine. If we are given anything else, or if other regex - code generates an invalid error code, then the program has a bug. - Dump core so we can fix it. */ - abort (); - - msg_size = strlen (msg) + 1; /* Includes the null. */ - - if (errbuf_size != 0) - { - if (msg_size > errbuf_size) - { - strncpy (errbuf, msg, errbuf_size - 1); - errbuf[errbuf_size - 1] = 0; - } - else - strcpy (errbuf, msg); - } - - return msg_size; -} - - -/* Free dynamically allocated space used by PREG. */ - -void -regfree (preg) - regex_t *preg; -{ - if (preg->buffer != NULL) - free (preg->buffer); - preg->buffer = NULL; - - preg->allocated = 0; - preg->used = 0; - - if (preg->fastmap != NULL) - free (preg->fastmap); - preg->fastmap = NULL; - preg->fastmap_accurate = 0; - - if (preg->translate != NULL) - free (preg->translate); - preg->translate = NULL; -} - -#endif /* not emacs */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/usr.bin/tar-1.11.2/regex.h b/gnu/usr.bin/tar-1.11.2/regex.h deleted file mode 100644 index 0840861da369..000000000000 --- a/gnu/usr.bin/tar-1.11.2/regex.h +++ /dev/null @@ -1,490 +0,0 @@ -/* Definitions for data structures and routines for the regular - expression library, version 0.11. - - Copyright (C) 1985, 89, 90, 91, 92 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. */ - -#ifndef __REGEXP_LIBRARY_H__ -#define __REGEXP_LIBRARY_H__ - -/* POSIX says that must be included (by the caller) before - . */ - -#ifdef VMS -/* VMS doesn't have `size_t' in , even though POSIX says it - should be there. */ -#include -#endif - - -/* The following bits are used to determine the regexp syntax we - recognize. The set/not-set meanings are chosen so that Emacs syntax - remains the value 0. The bits are given in alphabetical order, and - the definitions shifted by one from the previous bit; thus, when we - add or remove a bit, only one other definition need change. */ -typedef unsigned reg_syntax_t; - -/* If this bit is not set, then \ inside a bracket expression is literal. - If set, then such a \ quotes the following character. */ -#define RE_BACKSLASH_ESCAPE_IN_LISTS (1) - -/* If this bit is not set, then + and ? are operators, and \+ and \? are - literals. - If set, then \+ and \? are operators and + and ? are literals. */ -#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) - -/* 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 (RE_BK_PLUS_QM << 1) - -/* If this bit is set, then ^ and $ are always anchors (outside bracket - expressions, of course). - If this bit is not set, then it depends: - ^ is an anchor if it is at the beginning of a regular - expression or after an open-group or an alternation operator; - $ is an anchor if it is at the end of a regular expression, or - before a close-group or an alternation operator. - - This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because - POSIX draft 11.2 says that * etc. in leading positions is undefined. - We already implemented a previous draft which made those constructs - invalid, though, so we haven't changed the code back. */ -#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) - -/* If this bit is set, then special characters are always special - regardless of where they are in the pattern. - If this bit is not set, then special characters are special only in - some contexts; otherwise they are ordinary. Specifically, - * + ? and intervals are only special when not after the beginning, - open-group, or alternation operator. */ -#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) - -/* If this bit is set, then *, +, ?, and { cannot be first in an re or - immediately after an alternation or begin-group operator. */ -#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) - -/* If this bit is set, then . matches newline. - If not set, then it doesn't. */ -#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) - -/* If this bit is set, then . doesn't match NUL. - If not set, then it does. */ -#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) - -/* If this bit is set, nonmatching lists [^...] do not match newline. - If not set, they do. */ -#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) - -/* If this bit is set, either \{...\} or {...} defines an - interval, depending on RE_NO_BK_BRACES. - If not set, \{, \}, {, and } are literals. */ -#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) - -/* If this bit is set, +, ? and | aren't recognized as operators. - If not set, they are. */ -#define RE_LIMITED_OPS (RE_INTERVALS << 1) - -/* If this bit is set, newline is an alternation operator. - If not set, newline is literal. */ -#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) - -/* If this bit is set, then `{...}' defines an interval, and \{ and \} - are literals. - If not set, then `\{...\}' defines an interval. */ -#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) - -/* If this bit is set, (...) defines a group, and \( and \) are literals. - If not set, \(...\) defines a group, and ( and ) are literals. */ -#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) - -/* If this bit is set, then \ matches . - If not set, then \ is a back-reference. */ -#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) - -/* If this bit is set, then | is an alternation operator, and \| is literal. - If not set, then \| is an alternation operator, and | is literal. */ -#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) - -/* If this bit is set, then an ending range point collating higher - than the starting range point, as in [z-a], is invalid. - If not set, then when ending range point collates higher than the - starting range point, the range is ignored. */ -#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) - -/* If this bit is set, then an unmatched ) is ordinary. - If not set, then an unmatched ) is invalid. */ -#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) - -/* This global variable defines the particular regexp syntax to use (for - some interfaces). When a regexp is compiled, the syntax used is - stored in the pattern buffer, so changing this does not affect - already-compiled regexps. */ -extern reg_syntax_t re_syntax_options; - -/* Define combinations of the above bits for the standard possibilities. - (The [[[ comments delimit what gets put into the Texinfo file, so - don't delete them!) */ -/* [[[begin syntaxes]]] */ -#define RE_SYNTAX_EMACS 0 - -#define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -#define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) - -#define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - -#define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - -#define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) - -/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ -#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - -#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - -/* Syntax bits common to both basic and extended POSIX regex syntax. */ -#define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - -#define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) - -/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ -#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - -#define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS - replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ -#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) -/* [[[end syntaxes]]] */ - -/* Maximum number of duplicates an interval can allow. Some systems - (erroneously) define this in other header files, but we want our - value, so remove any previous define. */ -#ifdef RE_DUP_MAX -#undef RE_DUP_MAX -#endif -#define RE_DUP_MAX ((1 << 15) - 1) - - -/* POSIX `cflags' bits (i.e., information for `regcomp'). */ - -/* If this bit is set, then use extended regular expression syntax. - If not set, then use basic regular expression syntax. */ -#define REG_EXTENDED 1 - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -#define REG_ICASE (REG_EXTENDED << 1) - -/* If this bit is set, then anchors do not match at newline - characters in the string. - If not set, then anchors do match at newlines. */ -#define REG_NEWLINE (REG_ICASE << 1) - -/* If this bit is set, then report only success or fail in regexec. - If not set, then returns differ between not matching and errors. */ -#define REG_NOSUB (REG_NEWLINE << 1) - - -/* POSIX `eflags' bits (i.e., information for regexec). */ - -/* If this bit is set, then the beginning-of-line operator doesn't match - the beginning of the string (presumably because it's not the - beginning of a line). - If not set, then the beginning-of-line operator does match the - beginning of the string. */ -#define REG_NOTBOL 1 - -/* Like REG_NOTBOL, except for the end-of-line. */ -#define REG_NOTEOL (1 << 1) - - -/* If any error codes are removed, changed, or added, update the - `re_error_msg' table in regex.c. */ -typedef enum -{ - REG_NOERROR = 0, /* Success. */ - REG_NOMATCH, /* Didn't find a match (for regexec). */ - - /* POSIX regcomp return error codes. (In the order listed in the - standard.) */ - REG_BADPAT, /* Invalid pattern. */ - REG_ECOLLATE, /* Not implemented. */ - REG_ECTYPE, /* Invalid character class name. */ - REG_EESCAPE, /* Trailing backslash. */ - REG_ESUBREG, /* Invalid back reference. */ - REG_EBRACK, /* Unmatched left bracket. */ - REG_EPAREN, /* Parenthesis imbalance. */ - REG_EBRACE, /* Unmatched \{. */ - REG_BADBR, /* Invalid contents of \{\}. */ - REG_ERANGE, /* Invalid range end. */ - REG_ESPACE, /* Ran out of memory. */ - REG_BADRPT, /* No preceding re for repetition op. */ - - /* Error codes we've added. */ - REG_EEND, /* Premature end. */ - REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ - REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ -} reg_errcode_t; - -/* This data structure represents a compiled pattern. Before calling - the pattern compiler, the fields `buffer', `allocated', `fastmap', - `translate', and `no_sub' can be set. After the pattern has been - compiled, the `re_nsub' field is available. All other fields are - private to the regex routines. */ - -struct re_pattern_buffer -{ -/* [[[begin pattern_buffer]]] */ - /* Space that holds the compiled pattern. It is declared as - `unsigned char *' because its elements are - sometimes used as array indexes. */ - unsigned char *buffer; - - /* Number of bytes to which `buffer' points. */ - unsigned long allocated; - - /* Number of bytes actually used in `buffer'. */ - unsigned long used; - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t syntax; - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses - the fastmap, if there is one, to skip over impossible - starting points for matches. */ - char *fastmap; - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation - is applied to a pattern when it is compiled and to a string - when it is matched. */ - char *translate; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in `re_search_2', to see - whether or not we should use the fastmap, so we don't set - this absolutely perfectly; see `re_compile_fastmap' (the - `duplicate' case). */ - unsigned can_be_null : 1; - - /* If REGS_UNALLOCATED, allocate space in the `regs' structure - for `max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ -#define REGS_UNALLOCATED 0 -#define REGS_REALLOCATE 1 -#define REGS_FIXED 2 - unsigned regs_allocated : 2; - - /* Set to zero when `regex_compile' compiles a pattern; set to one - by `re_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; - - /* If set, `re_match_2' does not return information about - subexpressions. */ - unsigned no_sub : 1; - - /* If set, a beginning-of-line anchor doesn't match at the - beginning of the string. */ - unsigned not_bol : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned not_eol : 1; - - /* If true, an anchor at a newline matches. */ - unsigned newline_anchor : 1; - -/* [[[end pattern_buffer]]] */ -}; - -typedef struct re_pattern_buffer regex_t; - - -/* search.c (search_buffer) in Emacs needs this one opcode value. It is - defined both in `regex.c' and here. */ -#define RE_EXACTN_VALUE 1 - -/* Type for byte offsets within the string. POSIX mandates this. */ -typedef int regoff_t; - - -/* This is the structure we store register match data in. See - regex.texinfo for a full description of what registers match. */ -struct re_registers -{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -}; - - -/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, - `re_match_2' returns information about at least this many registers - the first time a `regs' structure is passed. */ -#ifndef RE_NREGS -#define RE_NREGS 30 -#endif - - -/* POSIX specification for registers. Aside from the different names than - `re_registers', POSIX uses an array of structures, instead of a - structure of arrays. */ -typedef struct -{ - regoff_t rm_so; /* Byte offset from string's start to substring's start. */ - regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ -} regmatch_t; - -/* Declarations for routines. */ - -/* To avoid duplicating every routine declaration -- once with a - prototype (if we are ANSI), and once without (if we aren't) -- we - use the following macro to declare argument types. This - unfortunately clutters up the declarations a bit, but I think it's - worth it. */ - -#if __STDC__ - -#define _RE_ARGS(args) args - -#else /* not __STDC__ */ - -#define _RE_ARGS(args) () - -#endif /* not __STDC__ */ - -/* Sets the current default syntax to SYNTAX, and return the old syntax. - You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); - -/* Compile the regular expression PATTERN, with length LENGTH - and syntax given by the global `re_syntax_options', into the buffer - BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern - _RE_ARGS ((const char *pattern, int length, - struct re_pattern_buffer *buffer)); - - -/* Compile a fastmap for the compiled pattern in BUFFER; used to - accelerate searches. Return 0 if successful and -2 if was an - internal error. */ -extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); - - -/* Search in the string STRING (with length LENGTH) for the pattern - compiled into BUFFER. Start searching at position START, for RANGE - characters. Return the starting position of the match, -1 for no - match, or -2 for an internal error. Also return register - information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, int range, struct re_registers *regs)); - - -/* Like `re_search', but search in the concatenation of STRING1 and - STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, int range, struct re_registers *regs, int stop)); - - -/* Like `re_search', but return how many characters in STRING the regexp - in BUFFER matched, starting at position START. */ -extern int re_match - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, struct re_registers *regs)); - - -/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int re_match_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, struct re_registers *regs, int stop)); - - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using BUFFER and REGS will use this memory - for recording register information. STARTS and ENDS must be - allocated with malloc, and must each be at least `NUM_REGS * sizeof - (regoff_t)' bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ -extern void re_set_registers - _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, regoff_t *starts, regoff_t *ends)); - -/* 4.2 bsd compatibility. */ -extern char *re_comp _RE_ARGS ((const char *)); -extern int re_exec _RE_ARGS ((const char *)); - -/* POSIX compatibility. */ -extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags)); -extern int regexec - _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch, - regmatch_t pmatch[], int eflags)); -extern size_t regerror - _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf, - size_t errbuf_size)); -extern void regfree _RE_ARGS ((regex_t *preg)); - -#endif /* not __REGEXP_LIBRARY_H__ */ - -/* -Local variables: -make-backup-files: t -version-control: t -trim-versions-without-asking: nil -End: -*/ diff --git a/gnu/usr.bin/tar-1.11.2/rmt.h b/gnu/usr.bin/tar-1.11.2/rmt.h deleted file mode 100644 index 2155223954c3..000000000000 --- a/gnu/usr.bin/tar-1.11.2/rmt.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Definitions for communicating with a remote tape drive. - Copyright (C) 1988, 1992 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 HAVE_UNISTD_H -#include -#endif - -#if !defined(_POSIX_VERSION) -#ifdef __MSDOS__ -#include -#else /* !__MSDOS__ */ -extern off_t lseek (); -#endif /* __MSDOS__ */ -#endif /* _POSIX_VERSION */ - -#ifdef NO_REMOTE -#define _isrmt(f) 0 -#define rmtopen open -#define rmtaccess access -#define rmtstat stat -#define rmtcreat creat -#define rmtlstat lstat -#define rmtread read -#define rmtwrite write -#define rmtlseek lseek -#define rmtclose close -#define rmtioctl ioctl -#define rmtdup dup -#define rmtfstat fstat -#define rmtfcntl fcntl -#define rmtisatty isatty - -#else /* !NO_REMOTE */ - -#define __REM_BIAS 128 -#define RMTIOCTL - -#ifndef O_CREAT -#define O_CREAT 01000 -#endif - -extern char *__rmt_path; - -#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) -#include -#ifndef index -#define index strchr -#endif -#else -extern char *index (); -#endif - -#define _remdev(path) (!f_force_local && (__rmt_path=index(path, ':'))) -#define _isrmt(fd) ((fd) >= __REM_BIAS) - -#define rmtopen(path,oflag,mode) (_remdev(path) ? __rmt_open(path, oflag, mode, __REM_BIAS) : open(path, oflag, mode)) -#define rmtaccess(path, amode) (_remdev(path) ? 0 : access(path, amode)) -#define rmtstat(path, buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : stat(path, buf)) -#define rmtcreat(path, mode) (_remdev(path) ? __rmt_open (path, 1 | O_CREAT, mode, __REM_BIAS) : creat(path, mode)) -#define rmtlstat(path,buf) (_remdev(path) ? (errno = EOPNOTSUPP), -1 : lstat(path,buf)) - -#define rmtread(fd, buf, n) (_isrmt(fd) ? __rmt_read(fd - __REM_BIAS, buf, n) : read(fd, buf, n)) -#define rmtwrite(fd, buf, n) (_isrmt(fd) ? __rmt_write(fd - __REM_BIAS, buf, n) : write(fd, buf, n)) -#define rmtlseek(fd, off, wh) (_isrmt(fd) ? __rmt_lseek(fd - __REM_BIAS, off, wh) : lseek(fd, off, wh)) -#define rmtclose(fd) (_isrmt(fd) ? __rmt_close(fd - __REM_BIAS) : close(fd)) -#ifdef RMTIOCTL -#define rmtioctl(fd,req,arg) (_isrmt(fd) ? __rmt_ioctl(fd - __REM_BIAS, req, arg) : ioctl(fd, req, arg)) -#else -#define rmtioctl(fd,req,arg) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : ioctl(fd, req, arg)) -#endif -#define rmtdup(fd) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : dup(fd)) -#define rmtfstat(fd, buf) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fstat(fd, buf)) -#define rmtfcntl(fd,cmd,arg) (_isrmt(fd) ? (errno = EOPNOTSUPP), -1 : fcntl (fd, cmd, arg)) -#define rmtisatty(fd) (_isrmt(fd) ? 0 : isatty(fd)) - -#undef RMTIOCTL - -int __rmt_open (); -int __rmt_close (); -int __rmt_read (); -int __rmt_write (); -long __rmt_lseek (); -int __rmt_ioctl (); -#endif /* !NO_REMOTE */ diff --git a/gnu/usr.bin/tar-1.11.2/rtapelib.c b/gnu/usr.bin/tar-1.11.2/rtapelib.c deleted file mode 100644 index eece76ffcd0f..000000000000 --- a/gnu/usr.bin/tar-1.11.2/rtapelib.c +++ /dev/null @@ -1,582 +0,0 @@ -/* Functions for communicating with a remote tape drive. - Copyright (C) 1988, 1992 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. */ - -/* The man page rmt(8) for /etc/rmt documents the remote mag tape - protocol which rdump and rrestore use. Unfortunately, the man - page is *WRONG*. The author of the routines I'm including originally - wrote his code just based on the man page, and it didn't work, so he - went to the rdump source to figure out why. The only thing he had to - change was to check for the 'F' return code in addition to the 'E', - and to separate the various arguments with \n instead of a space. I - personally don't think that this is much of a problem, but I wanted to - point it out. -- Arnold Robbins - - Originally written by Jeff Lee, modified some by Arnold Robbins. - Redone as a library that can replace open, read, write, etc., by - Fred Fish, with some additional work by Arnold Robbins. - Modified to make all rmtXXX calls into macros for speed by Jay Fenlason. - Use -DHAVE_NETDB_H for rexec code, courtesy of Dan Kegel, srs!dan. */ - -#include -#include -#include - -#ifdef HAVE_SYS_MTIO_H -#include -#include -#endif - -#ifdef HAVE_NETDB_H -#include -#endif - -#include -#include -#include - -#ifndef errno -extern int errno; -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif -#ifdef STDC_HEADERS -#include -#include -#endif - -/* Maximum size of a fully qualified host name. */ -#define MAXHOSTLEN 257 - -/* Size of buffers for reading and writing commands to rmt. - (An arbitrary limit.) */ -#define CMDBUFSIZE 64 - -#ifndef RETSIGTYPE -#define RETSIGTYPE void -#endif - -/* Maximum number of simultaneous remote tape connections. - (Another arbitrary limit.) */ -#define MAXUNIT 4 - -/* Return the parent's read side of remote tape connection FILDES. */ -#define READ(fildes) (from_rmt[fildes][0]) - -/* Return the parent's write side of remote tape connection FILDES. */ -#define WRITE(fildes) (to_rmt[fildes][1]) - -/* The pipes for receiving data from remote tape drives. */ -static int from_rmt[MAXUNIT][2] = -{-1, -1, -1, -1, -1, -1, -1, -1}; - -/* The pipes for sending data to remote tape drives. */ -static int to_rmt[MAXUNIT][2] = -{-1, -1, -1, -1, -1, -1, -1, -1}; - -/* Temporary variable used by macros in rmt.h. */ -char *__rmt_path; - -/* Close remote tape connection FILDES. */ - -static void -_rmt_shutdown (fildes) - int fildes; -{ - close (READ (fildes)); - close (WRITE (fildes)); - READ (fildes) = -1; - WRITE (fildes) = -1; -} - -/* Attempt to perform the remote tape command specified in BUF - on remote tape connection FILDES. - Return 0 if successful, -1 on error. */ - -static int -command (fildes, buf) - int fildes; - char *buf; -{ - register int buflen; - RETSIGTYPE (*pipe_handler) (); - - /* Save the current pipe handler and try to make the request. */ - - pipe_handler = signal (SIGPIPE, SIG_IGN); - buflen = strlen (buf); - if (write (WRITE (fildes), buf, buflen) == buflen) - { - signal (SIGPIPE, pipe_handler); - return 0; - } - - /* Something went wrong. Close down and go home. */ - - signal (SIGPIPE, pipe_handler); - _rmt_shutdown (fildes); - errno = EIO; - return -1; -} - -/* Read and return the status from remote tape connection FILDES. - If an error occurred, return -1 and set errno. */ - -static int -status (fildes) - int fildes; -{ - int i; - char c, *cp; - char buffer[CMDBUFSIZE]; - - /* Read the reply command line. */ - - for (i = 0, cp = buffer; i < CMDBUFSIZE; i++, cp++) - { - if (read (READ (fildes), cp, 1) != 1) - { - _rmt_shutdown (fildes); - errno = EIO; - return -1; - } - if (*cp == '\n') - { - *cp = '\0'; - break; - } - } - - if (i == CMDBUFSIZE) - { - _rmt_shutdown (fildes); - errno = EIO; - return -1; - } - - /* Check the return status. */ - - for (cp = buffer; *cp; cp++) - if (*cp != ' ') - break; - - if (*cp == 'E' || *cp == 'F') - { - errno = atoi (cp + 1); - /* Skip the error message line. */ - while (read (READ (fildes), &c, 1) == 1) - if (c == '\n') - break; - - if (*cp == 'F') - _rmt_shutdown (fildes); - - return -1; - } - - /* Check for mis-synced pipes. */ - - if (*cp != 'A') - { - _rmt_shutdown (fildes); - errno = EIO; - return -1; - } - - /* Got an `A' (success) response. */ - return atoi (cp + 1); -} - -#ifdef HAVE_NETDB_H -/* Execute /etc/rmt as user USER on remote system HOST using rexec. - Return a file descriptor of a bidirectional socket for stdin and stdout. - If USER is NULL, or an empty string, use the current username. - - By default, this code is not used, since it requires that - the user have a .netrc file in his/her home directory, or that the - application designer be willing to have rexec prompt for login and - password info. This may be unacceptable, and .rhosts files for use - with rsh are much more common on BSD systems. */ - -static int -_rmt_rexec (host, user) - char *host; - char *user; -{ - struct servent *rexecserv; - int save_stdin = dup (fileno (stdin)); - int save_stdout = dup (fileno (stdout)); - int tape_fd; /* Return value. */ - - /* When using cpio -o < filename, stdin is no longer the tty. - But the rexec subroutine reads the login and the passwd on stdin, - to allow remote execution of the command. - So, reopen stdin and stdout on /dev/tty before the rexec and - give them back their original value after. */ - if (freopen ("/dev/tty", "r", stdin) == NULL) - freopen ("/dev/null", "r", stdin); - if (freopen ("/dev/tty", "w", stdout) == NULL) - freopen ("/dev/null", "w", stdout); - - rexecserv = getservbyname ("exec", "tcp"); - if (NULL == rexecserv) - { - fprintf (stderr, "exec/tcp: service not available"); - exit (1); - } - if (user != NULL && *user == '\0') - user = NULL; - tape_fd = rexec (&host, rexecserv->s_port, user, NULL, - "/etc/rmt", (int *) NULL); - fclose (stdin); - fdopen (save_stdin, "r"); - fclose (stdout); - fdopen (save_stdout, "w"); - - return tape_fd; -} - -#endif /* HAVE_NETDB_H */ - -/* Open a magtape device on the system specified in PATH, as the given user. - PATH has the form `[user@]system:/dev/????'. - If COMPAT is defined, it can also have the form `system[.user]:/dev/????'. - - OFLAG is O_RDONLY, O_WRONLY, etc. - MODE is ignored; 0666 is always used. - - If successful, return the remote tape pipe number plus BIAS. - On error, return -1. */ - -int -__rmt_open (path, oflag, mode, bias) - char *path; - int oflag; - int mode; - int bias; -{ - int i, rc; - char buffer[CMDBUFSIZE]; /* Command buffer. */ - char system[MAXHOSTLEN]; /* The remote host name. */ - char device[CMDBUFSIZE]; /* The remote device name. */ - char login[CMDBUFSIZE]; /* The remote user name. */ - char *sys, *dev, *user; /* For copying into the above buffers. */ - - sys = system; - dev = device; - user = login; - - /* Find an unused pair of file descriptors. */ - - for (i = 0; i < MAXUNIT; i++) - if (READ (i) == -1 && WRITE (i) == -1) - break; - - if (i == MAXUNIT) - { - errno = EMFILE; - return -1; - } - - /* Pull apart the system and device, and optional user. - Don't munge the original string. */ - - while (*path != '@' -#ifdef COMPAT - && *path != '.' -#endif - && *path != ':') - { - *sys++ = *path++; - } - *sys = '\0'; - path++; - - if (*(path - 1) == '@') - { - /* Saw user part of user@host. Start over. */ - strcpy (user, system); - sys = system; - while (*path != ':') - { - *sys++ = *path++; - } - *sys = '\0'; - path++; - } -#ifdef COMPAT - else if (*(path - 1) == '.') - { - while (*path != ':') - { - *user++ = *path++; - } - *user = '\0'; - path++; - } -#endif - else - *user = '\0'; - - while (*path) - { - *dev++ = *path++; - } - *dev = '\0'; - -#ifdef HAVE_NETDB_H - /* Execute the remote command using rexec. */ - READ (i) = WRITE (i) = _rmt_rexec (system, login); - if (READ (i) < 0) - return -1; -#else /* !HAVE_NETDB_H */ - /* Set up the pipes for the `rsh' command, and fork. */ - - if (pipe (to_rmt[i]) == -1 || pipe (from_rmt[i]) == -1) - return -1; - - rc = fork (); - if (rc == -1) - return -1; - - if (rc == 0) - { - /* Child. */ - close (0); - dup (to_rmt[i][0]); - close (to_rmt[i][0]); - close (to_rmt[i][1]); - - close (1); - dup (from_rmt[i][1]); - close (from_rmt[i][0]); - close (from_rmt[i][1]); - - setuid (getuid ()); - setgid (getgid ()); - - if (*login) - { - execl ("/usr/ucb/rsh", "rsh", system, "-l", login, - "/etc/rmt", (char *) 0); - execl ("/usr/bin/remsh", "remsh", system, "-l", login, - "/etc/rmt", (char *) 0); - execl ("/usr/bin/rsh", "rsh", system, "-l", login, - "/etc/rmt", (char *) 0); - execl ("/usr/bsd/rsh", "rsh", system, "-l", login, - "/etc/rmt", (char *) 0); - execl ("/usr/bin/nsh", "nsh", system, "-l", login, - "/etc/rmt", (char *) 0); - } - else - { - execl ("/usr/ucb/rsh", "rsh", system, - "/etc/rmt", (char *) 0); - execl ("/usr/bin/remsh", "remsh", system, - "/etc/rmt", (char *) 0); - execl ("/usr/bin/rsh", "rsh", system, - "/etc/rmt", (char *) 0); - execl ("/usr/bsd/rsh", "rsh", system, - "/etc/rmt", (char *) 0); - execl ("/usr/bin/nsh", "nsh", system, - "/etc/rmt", (char *) 0); - } - - /* Bad problems if we get here. */ - - perror ("cannot execute remote shell"); - _exit (1); - } - - /* Parent. */ - close (to_rmt[i][0]); - close (from_rmt[i][1]); -#endif /* !HAVE_NETDB_H */ - - /* Attempt to open the tape device. */ - - sprintf (buffer, "O%s\n%d\n", device, oflag); - if (command (i, buffer) == -1 || status (i) == -1) - return -1; - - return i + bias; -} - -/* Close remote tape connection FILDES and shut down. - Return 0 if successful, -1 on error. */ - -int -__rmt_close (fildes) - int fildes; -{ - int rc; - - if (command (fildes, "C\n") == -1) - return -1; - - rc = status (fildes); - _rmt_shutdown (fildes); - return rc; -} - -/* Read up to NBYTE bytes into BUF from remote tape connection FILDES. - Return the number of bytes read on success, -1 on error. */ - -int -__rmt_read (fildes, buf, nbyte) - int fildes; - char *buf; - unsigned int nbyte; -{ - int rc, i; - char buffer[CMDBUFSIZE]; - - sprintf (buffer, "R%d\n", nbyte); - if (command (fildes, buffer) == -1 || (rc = status (fildes)) == -1) - return -1; - - for (i = 0; i < rc; i += nbyte, buf += nbyte) - { - nbyte = read (READ (fildes), buf, rc - i); - if (nbyte <= 0) - { - _rmt_shutdown (fildes); - errno = EIO; - return -1; - } - } - - return rc; -} - -/* Write NBYTE bytes from BUF to remote tape connection FILDES. - Return the number of bytes written on success, -1 on error. */ - -int -__rmt_write (fildes, buf, nbyte) - int fildes; - char *buf; - unsigned int nbyte; -{ - char buffer[CMDBUFSIZE]; - RETSIGTYPE (*pipe_handler) (); - - sprintf (buffer, "W%d\n", nbyte); - if (command (fildes, buffer) == -1) - return -1; - - pipe_handler = signal (SIGPIPE, SIG_IGN); - if (write (WRITE (fildes), buf, nbyte) == nbyte) - { - signal (SIGPIPE, pipe_handler); - return status (fildes); - } - - /* Write error. */ - signal (SIGPIPE, pipe_handler); - _rmt_shutdown (fildes); - errno = EIO; - return -1; -} - -/* Perform an imitation lseek operation on remote tape connection FILDES. - Return the new file offset if successful, -1 if on error. */ - -long -__rmt_lseek (fildes, offset, whence) - int fildes; - long offset; - int whence; -{ - char buffer[CMDBUFSIZE]; - - sprintf (buffer, "L%ld\n%d\n", offset, whence); - if (command (fildes, buffer) == -1) - return -1; - - return status (fildes); -} - -/* Perform a raw tape operation on remote tape connection FILDES. - Return the results of the ioctl, or -1 on error. */ - -#ifdef MTIOCTOP -int -__rmt_ioctl (fildes, op, arg) - int fildes, op; - char *arg; -{ - char c; - int rc, cnt; - char buffer[CMDBUFSIZE]; - - switch (op) - { - default: - errno = EINVAL; - return -1; - - case MTIOCTOP: - /* MTIOCTOP is the easy one. Nothing is transfered in binary. */ - sprintf (buffer, "I%d\n%d\n", ((struct mtop *) arg)->mt_op, - ((struct mtop *) arg)->mt_count); - if (command (fildes, buffer) == -1) - return -1; - return status (fildes); /* Return the count. */ - - case MTIOCGET: - /* Grab the status and read it directly into the structure. - This assumes that the status buffer is not padded - and that 2 shorts fit in a long without any word - alignment problems; i.e., the whole struct is contiguous. - NOTE - this is probably NOT a good assumption. */ - - if (command (fildes, "S") == -1 || (rc = status (fildes)) == -1) - return -1; - - for (; rc > 0; rc -= cnt, arg += cnt) - { - cnt = read (READ (fildes), arg, rc); - if (cnt <= 0) - { - _rmt_shutdown (fildes); - errno = EIO; - return -1; - } - } - - /* Check for byte position. mt_type is a small integer field - (normally) so we will check its magnitude. If it is larger than - 256, we will assume that the bytes are swapped and go through - and reverse all the bytes. */ - - if (((struct mtget *) arg)->mt_type < 256) - return 0; - - for (cnt = 0; cnt < rc; cnt += 2) - { - c = arg[cnt]; - arg[cnt] = arg[cnt + 1]; - arg[cnt + 1] = c; - } - - return 0; - } -} - -#endif diff --git a/gnu/usr.bin/tar-1.11.2/tar.c b/gnu/usr.bin/tar-1.11.2/tar.c deleted file mode 100644 index 938258233980..000000000000 --- a/gnu/usr.bin/tar-1.11.2/tar.c +++ /dev/null @@ -1,1504 +0,0 @@ -/* Tar -- a tape archiver. - Copyright (C) 1988, 1992, 1993 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * A tar (tape archiver) program. - * - * Written by John Gilmore, ihnp4!hoptoad!gnu, starting 25 Aug 85. - */ - -#include -#include /* Needed for typedefs in tar.h */ -#include "getopt.h" - -/* - * The following causes "tar.h" to produce definitions of all the - * global variables, rather than just "extern" declarations of them. - */ -#define TAR_EXTERN /**/ -#include "tar.h" - -#include "port.h" -#include "regex.h" -#include "fnmatch.h" - -/* - * We should use a conversion routine that does reasonable error - * checking -- atoi doesn't. For now, punt. FIXME. - */ -#define intconv atoi -PTR ck_malloc (); -PTR ck_realloc (); -extern int getoldopt (); -extern void read_and (); -extern void list_archive (); -extern void extract_archive (); -extern void diff_archive (); -extern void create_archive (); -extern void update_archive (); -extern void junk_archive (); -extern void init_volume_number (); -extern void closeout_volume_number (); - -/* JF */ -extern time_t get_date (); - -time_t new_time; - -static FILE *namef; /* File to read names from */ -static char **n_argv; /* Argv used by name routines */ -static int n_argc; /* Argc used by name routines */ -static char **n_ind; /* Store an array of names */ -static int n_indalloc; /* How big is the array? */ -static int n_indused; /* How many entries does it have? */ -static int n_indscan; /* How many of the entries have we scanned? */ - - -extern FILE *msg_file; - -int check_exclude (); -void add_exclude (); -void add_exclude_file (); -void addname (); -void describe (); -void diff_init (); -void extr_init (); -int is_regex (); -void name_add (); -void name_init (); -void options (); -char *un_quote_string (); - -#ifndef S_ISLNK -#define lstat stat -#endif - -#ifndef DEFBLOCKING -#define DEFBLOCKING 20 -#endif - -#ifndef DEF_AR_FILE -#define DEF_AR_FILE "tar.out" -#endif - -/* For long options that unconditionally set a single flag, we have getopt - do it. For the others, we share the code for the equivalent short - named option, the name of which is stored in the otherwise-unused `val' - field of the `struct option'; for long options that have no equivalent - short option, we use nongraphic characters as pseudo short option - characters, starting (for no particular reason) with character 10. */ - -struct option long_options[] = -{ - {"create", 0, 0, 'c'}, - {"append", 0, 0, 'r'}, - {"extract", 0, 0, 'x'}, - {"get", 0, 0, 'x'}, - {"list", 0, 0, 't'}, - {"update", 0, 0, 'u'}, - {"catenate", 0, 0, 'A'}, - {"concatenate", 0, 0, 'A'}, - {"compare", 0, 0, 'd'}, - {"diff", 0, 0, 'd'}, - {"delete", 0, 0, 14}, - {"help", 0, 0, 12}, - - {"null", 0, 0, 16}, - {"directory", 1, 0, 'C'}, - {"record-number", 0, &f_sayblock, 1}, - {"files-from", 1, 0, 'T'}, - {"label", 1, 0, 'V'}, - {"exclude-from", 1, 0, 'X'}, - {"exclude", 1, 0, 15}, - {"file", 1, 0, 'f'}, - {"block-size", 1, 0, 'b'}, - {"version", 0, 0, 11}, - {"verbose", 0, 0, 'v'}, - {"totals", 0, &f_totals, 1}, - - {"read-full-blocks", 0, &f_reblock, 1}, - {"starting-file", 1, 0, 'K'}, - {"to-stdout", 0, &f_exstdout, 1}, - {"ignore-zeros", 0, &f_ignorez, 1}, - {"keep-old-files", 0, 0, 'k'}, - {"same-permissions", 0, &f_use_protection, 1}, - {"preserve-permissions", 0, &f_use_protection, 1}, - {"modification-time", 0, &f_modified, 1}, - {"preserve", 0, 0, 10}, - {"same-order", 0, &f_sorted_names, 1}, - {"same-owner", 0, &f_do_chown, 1}, - {"preserve-order", 0, &f_sorted_names, 1}, - - {"newer", 1, 0, 'N'}, - {"after-date", 1, 0, 'N'}, - {"newer-mtime", 1, 0, 13}, - {"incremental", 0, 0, 'G'}, - {"listed-incremental", 1, 0, 'g'}, - {"multi-volume", 0, &f_multivol, 1}, - {"info-script", 1, 0, 'F'}, - {"new-volume-script", 1, 0, 'F'}, - {"absolute-paths", 0, &f_absolute_paths, 1}, - {"interactive", 0, &f_confirm, 1}, - {"confirmation", 0, &f_confirm, 1}, - - {"verify", 0, &f_verify, 1}, - {"dereference", 0, &f_follow_links, 1}, - {"one-file-system", 0, &f_local_filesys, 1}, - {"old-archive", 0, 0, 'o'}, - {"portability", 0, 0, 'o'}, - {"compress", 0, 0, 'Z'}, - {"uncompress", 0, 0, 'Z'}, - {"block-compress", 0, &f_compress_block, 1}, - {"gzip", 0, 0, 'z'}, - {"ungzip", 0, 0, 'z'}, - {"use-compress-program", 1, 0, 18}, - - - {"same-permissions", 0, &f_use_protection, 1}, - {"sparse", 0, &f_sparse_files, 1}, - {"tape-length", 1, 0, 'L'}, - {"remove-files", 0, &f_remove_files, 1}, - {"ignore-failed-read", 0, &f_ignore_failed_read, 1}, - {"checkpoint", 0, &f_checkpoint, 1}, - {"show-omitted-dirs", 0, &f_show_omitted_dirs, 1}, - {"volno-file", 1, 0, 17}, - {"force-local", 0, &f_force_local, 1}, - {"atime-preserve", 0, &f_atime_preserve, 1}, - - {0, 0, 0, 0} -}; - -/* - * Main routine for tar. - */ -void -main (argc, argv) - int argc; - char **argv; -{ - extern char version_string[]; - - tar = argv[0]; /* JF: was "tar" Set program name */ - filename_terminator = '\n'; - errors = 0; - - options (argc, argv); - - if (!n_argv) - name_init (argc, argv); - - if (f_volno_file) - init_volume_number (); - - switch (cmd_mode) - { - case CMD_CAT: - case CMD_UPDATE: - case CMD_APPEND: - update_archive (); - break; - case CMD_DELETE: - junk_archive (); - break; - case CMD_CREATE: - create_archive (); - if (f_totals) - fprintf (stderr, "Total bytes written: %d\n", tot_written); - break; - case CMD_EXTRACT: - if (f_volhdr) - { - const char *err; - label_pattern = (struct re_pattern_buffer *) - ck_malloc (sizeof *label_pattern); - err = re_compile_pattern (f_volhdr, strlen (f_volhdr), - label_pattern); - if (err) - { - fprintf (stderr, "Bad regular expression: %s\n", - err); - errors++; - break; - } - - } - extr_init (); - read_and (extract_archive); - break; - case CMD_LIST: - if (f_volhdr) - { - const char *err; - label_pattern = (struct re_pattern_buffer *) - ck_malloc (sizeof *label_pattern); - err = re_compile_pattern (f_volhdr, strlen (f_volhdr), - label_pattern); - if (err) - { - fprintf (stderr, "Bad regular expression: %s\n", - err); - errors++; - break; - } - } - read_and (list_archive); -#if 0 - if (!errors) - errors = different; -#endif - break; - case CMD_DIFF: - diff_init (); - read_and (diff_archive); - break; - case CMD_VERSION: - fprintf (stderr, "%s\n", version_string); - break; - case CMD_NONE: - msg ("you must specify exactly one of the r, c, t, x, or d options\n"); - fprintf (stderr, "For more information, type ``%s --help''.\n", tar); - exit (EX_ARGSBAD); - } - if (f_volno_file) - closeout_volume_number (); - exit (errors); - /* NOTREACHED */ -} - - -/* - * Parse the options for tar. - */ -void -options (argc, argv) - int argc; - char **argv; -{ - register int c; /* Option letter */ - int ind = -1; - - /* Set default option values */ - blocking = DEFBLOCKING; /* From Makefile */ - ar_files = (char **) ck_malloc (sizeof (char *) * 10); - ar_files_len = 10; - n_ar_files = 0; - cur_ar_file = 0; - - /* Parse options */ - while ((c = getoldopt (argc, argv, - "-01234567Ab:BcC:df:F:g:GhikK:lL:mMN:oOpPrRsStT:uvV:wWxX:zZ", - long_options, &ind)) != EOF) - { - switch (c) - { - case 0: /* long options that set a single flag */ - break; - case 1: - /* File name or non-parsed option */ - name_add (optarg); - break; - case 'C': - name_add ("-C"); - name_add (optarg); - break; - case 10: /* preserve */ - f_use_protection = f_sorted_names = 1; - break; - case 11: - if (cmd_mode != CMD_NONE) - goto badopt; - cmd_mode = CMD_VERSION; - break; - case 12: /* help */ - printf ("This is GNU tar, the tape archiving program.\n"); - describe (); - exit (1); - case 13: - f_new_files++; - goto get_newer; - - case 14: /* Delete in the archive */ - if (cmd_mode != CMD_NONE) - goto badopt; - cmd_mode = CMD_DELETE; - break; - - case 15: - f_exclude++; - add_exclude (optarg); - break; - - case 16: /* -T reads null terminated filenames. */ - filename_terminator = '\0'; - break; - - case 17: - f_volno_file = optarg; - break; - - case 18: - if (f_compressprog) - { - msg ("Only one compression option permitted\n"); - exit (EX_ARGSBAD); - } - f_compressprog = optarg; - break; - - case 'g': /* We are making a GNU dump; save - directories at the beginning of - the archive, and include in each - directory its contents */ - if (f_oldarch) - goto badopt; - f_gnudump++; - gnu_dumpfile = optarg; - break; - - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - /* JF this'll have to be modified for other - systems, of course! */ - int d, add; - static char buf[50]; - - d = getoldopt (argc, argv, "lmh"); -#ifdef MAYBEDEF - sprintf (buf, "/dev/rmt/%d%c", c, d); -#else -#ifndef LOW_NUM -#define LOW_NUM 0 -#define MID_NUM 8 -#define HGH_NUM 16 -#endif - if (d == 'l') - add = LOW_NUM; - else if (d == 'm') - add = MID_NUM; - else if (d == 'h') - add = HGH_NUM; - else - goto badopt; - - sprintf (buf, "/dev/rmt%d", add + c - '0'); -#endif - if (n_ar_files == ar_files_len) - ar_files - = (char **) - ck_malloc (sizeof (char *) - * (ar_files_len *= 2)); - ar_files[n_ar_files++] = buf; - } - break; - - case 'A': /* Arguments are tar files, - just cat them onto the end - of the archive. */ - if (cmd_mode != CMD_NONE) - goto badopt; - cmd_mode = CMD_CAT; - break; - - case 'b': /* Set blocking factor */ - blocking = intconv (optarg); - break; - - case 'B': /* Try to reblock input */ - f_reblock++; /* For reading 4.2BSD pipes */ - break; - - case 'c': /* Create an archive */ - if (cmd_mode != CMD_NONE) - goto badopt; - cmd_mode = CMD_CREATE; - break; - -#if 0 - case 'C': - if (chdir (optarg) < 0) - msg_perror ("Can't change directory to %d", optarg); - break; -#endif - - case 'd': /* Find difference tape/disk */ - if (cmd_mode != CMD_NONE) - goto badopt; - cmd_mode = CMD_DIFF; - break; - - case 'f': /* Use ar_file for the archive */ - if (n_ar_files == ar_files_len) - ar_files - = (char **) ck_malloc (sizeof (char *) - * (ar_files_len *= 2)); - - ar_files[n_ar_files++] = optarg; - break; - - case 'F': - /* Since -F is only useful with -M , make it implied */ - f_run_script_at_end++;/* run this script at the end */ - info_script = optarg; /* of each tape */ - f_multivol++; - break; - - case 'G': /* We are making a GNU dump; save - directories at the beginning of - the archive, and include in each - directory its contents */ - if (f_oldarch) - goto badopt; - f_gnudump++; - gnu_dumpfile = 0; - break; - - case 'h': - f_follow_links++; /* follow symbolic links */ - break; - - case 'i': - f_ignorez++; /* Ignore zero records (eofs) */ - /* - * This can't be the default, because Unix tar - * writes two records of zeros, then pads out the - * block with garbage. - */ - break; - - case 'k': /* Don't overwrite files */ -#ifdef NO_OPEN3 - msg ("can't keep old files on this system"); - exit (EX_ARGSBAD); -#else - f_keep++; -#endif - break; - - case 'K': - f_startfile++; - addname (optarg); - break; - - case 'l': /* When dumping directories, don't - dump files/subdirectories that are - on other filesystems. */ - f_local_filesys++; - break; - - case 'L': - tape_length = intconv (optarg); - f_multivol++; - break; - case 'm': - f_modified++; - break; - - case 'M': /* Make Multivolume archive: - When we can't write any more - into the archive, re-open it, - and continue writing */ - f_multivol++; - break; - - case 'N': /* Only write files newer than X */ - get_newer: - f_new_files++; - new_time = get_date (optarg, (PTR) 0); - if (new_time == (time_t) - 1) - { - msg ("invalid date format `%s'", optarg); - exit (EX_ARGSBAD); - } - break; - - case 'o': /* Generate old archive */ - if (f_gnudump /* || f_dironly */ ) - goto badopt; - f_oldarch++; - break; - - case 'O': - f_exstdout++; - break; - - case 'p': - f_use_protection++; - break; - - case 'P': - f_absolute_paths++; - break; - - case 'r': /* Append files to the archive */ - if (cmd_mode != CMD_NONE) - goto badopt; - cmd_mode = CMD_APPEND; - break; - - case 'R': - f_sayblock++; /* Print block #s for debug */ - break; /* of bad tar archives */ - - case 's': - f_sorted_names++; /* Names to extr are sorted */ - break; - - case 'S': /* deal with sparse files */ - f_sparse_files++; - break; - case 't': - if (cmd_mode != CMD_NONE) - goto badopt; - cmd_mode = CMD_LIST; - f_verbose++; /* "t" output == "cv" or "xv" */ - break; - - case 'T': - name_file = optarg; - f_namefile++; - break; - - case 'u': /* Append files to the archive that - aren't there, or are newer than the - copy in the archive */ - if (cmd_mode != CMD_NONE) - goto badopt; - cmd_mode = CMD_UPDATE; - break; - - case 'v': - f_verbose++; - break; - - case 'V': - f_volhdr = optarg; - break; - - case 'w': - f_confirm++; - break; - - case 'W': - f_verify++; - break; - - case 'x': /* Extract files from the archive */ - if (cmd_mode != CMD_NONE) - goto badopt; - cmd_mode = CMD_EXTRACT; - break; - - case 'X': - f_exclude++; - add_exclude_file (optarg); - break; - - case 'z': - if (f_compressprog) - { - msg ("Only one compression option permitted\n"); - exit (EX_ARGSBAD); - } - f_compressprog = "gzip"; - break; - - case 'Z': - if (f_compressprog) - { - msg ("Only one compression option permitted\n"); - exit (EX_ARGSBAD); - } - f_compressprog = "compress"; - break; - - case '?': - badopt: - msg ("Unknown option. Use '%s --help' for a complete list of options.", tar); - exit (EX_ARGSBAD); - - } - } - - blocksize = blocking * RECORDSIZE; - if (n_ar_files == 0) - { - n_ar_files = 1; - ar_files[0] = getenv ("TAPE"); /* From environment, or */ - if (ar_files[0] == 0) - ar_files[0] = DEF_AR_FILE; /* From Makefile */ - } - if (n_ar_files > 1 && !f_multivol) - { - msg ("Multiple archive files requires --multi-volume\n"); - exit (EX_ARGSBAD); - } - if (f_compress_block && !f_compressprog) - { - msg ("You must use a compression option (--gzip, --compress\n\ -or --use-compress-program) with --block-compress.\n"); - exit (EX_ARGSBAD); - } -} - - -/* - * Print as much help as the user's gonna get. - * - * We have to sprinkle in the KLUDGE lines because too many compilers - * cannot handle character strings longer than about 512 bytes. Yuk! - * In particular, MS-DOS and Xenix MSC and PDP-11 V7 Unix have this - * problem. - */ -void -describe () -{ - puts ("choose one of the following:"); - fputs ("\ --A, --catenate,\n\ - --concatenate append tar files to an archive\n\ --c, --create create a new archive\n\ --d, --diff,\n\ - --compare find differences between archive and file system\n\ ---delete delete from the archive (not for use on mag tapes!)\n\ --r, --append append files to the end of an archive\n\ --t, --list list the contents of an archive\n\ --u, --update only append files that are newer than copy in archive\n\ --x, --extract,\n\ - --get extract files from an archive\n", stdout); - - fprintf (stdout, "\ -Other options:\n\ ---atime-preserve don't change access times on dumped files\n\ --b, --block-size N block size of Nx512 bytes (default N=%d)\n", DEFBLOCKING); - fputs ("\ --B, --read-full-blocks reblock as we read (for reading 4.2BSD pipes)\n\ --C, --directory DIR change to directory DIR\n\ ---checkpoint print directory names while reading the archive\n\ -", stdout); /* KLUDGE */ - fprintf (stdout, "\ --f, --file [HOSTNAME:]F use archive file or device F (default %s)\n", - DEF_AR_FILE); - fputs ("\ ---force-local archive file is local even if has a colon\n\ --F, --info-script F\n\ - --new-volume-script F run script at end of each tape (implies -M)\n\ --G, --incremental create/list/extract old GNU-format incremental backup\n\ --g, --listed-incremental F create/list/extract new GNU-format incremental backup\n\ --h, --dereference don't dump symlinks; dump the files they point to\n\ --i, --ignore-zeros ignore blocks of zeros in archive (normally mean EOF)\n\ ---ignore-failed-read don't exit with non-zero status on unreadable files\n\ --k, --keep-old-files keep existing files; don't overwrite them from archive\n\ --K, --starting-file F begin at file F in the archive\n\ --l, --one-file-system stay in local file system when creating an archive\n\ --L, --tape-length N change tapes after writing N*1024 bytes\n\ -", stdout); /* KLUDGE */ - fputs ("\ --m, --modification-time don't extract file modified time\n\ --M, --multi-volume create/list/extract multi-volume archive\n\ --N, --after-date DATE,\n\ - --newer DATE only store files newer than DATE\n\ --o, --old-archive,\n\ - --portability write a V7 format archive, rather than ANSI format\n\ --O, --to-stdout extract files to standard output\n\ --p, --same-permissions,\n\ - --preserve-permissions extract all protection information\n\ --P, --absolute-paths don't strip leading `/'s from file names\n\ ---preserve like -p -s\n\ -", stdout); /* KLUDGE */ - fputs ("\ --R, --record-number show record number within archive with each message\n\ ---remove-files remove files after adding them to the archive\n\ --s, --same-order,\n\ - --preserve-order list of names to extract is sorted to match archive\n\ ---same-owner create extracted files with the same ownership \n\ --S, --sparse handle sparse files efficiently\n\ --T, --files-from F get names to extract or create from file F\n\ ---null -T reads null-terminated names, disable -C\n\ ---totals print total bytes written with --create\n\ --v, --verbose verbosely list files processed\n\ --V, --label NAME create archive with volume name NAME\n\ ---version print tar program version number\n\ --w, --interactive,\n\ - --confirmation ask for confirmation for every action\n\ -", stdout); /* KLUDGE */ - fputs ("\ --W, --verify attempt to verify the archive after writing it\n\ ---exclude FILE exclude file FILE\n\ --X, --exclude-from FILE exclude files listed in FILE\n\ --Z, --compress,\n\ - --uncompress filter the archive through compress\n\ --z, --gzip,\n\ - --ungzip filter the archive through gzip\n\ ---use-compress-program PROG\n\ - filter the archive through PROG (which must accept -d)\n\ ---block-compress block the output of compression program for tapes\n\ --[0-7][lmh] specify drive and density\n\ -", stdout); -} - -void -name_add (name) - char *name; -{ - if (n_indalloc == n_indused) - { - n_indalloc += 10; - n_ind = (char **) (n_indused ? ck_realloc (n_ind, n_indalloc * sizeof (char *)): ck_malloc (n_indalloc * sizeof (char *))); - } - n_ind[n_indused++] = name; -} - -/* - * Set up to gather file names for tar. - * - * They can either come from stdin or from argv. - */ -void -name_init (argc, argv) - int argc; - char **argv; -{ - - if (f_namefile) - { - if (optind < argc) - { - msg ("too many args with -T option"); - exit (EX_ARGSBAD); - } - if (!strcmp (name_file, "-")) - { - namef = stdin; - } - else - { - namef = fopen (name_file, "r"); - if (namef == NULL) - { - msg_perror ("can't open file %s", name_file); - exit (EX_BADFILE); - } - } - } - else - { - /* Get file names from argv, after options. */ - n_argc = argc; - n_argv = argv; - } -} - -/* Read the next filename read from STREAM and null-terminate it. - Put it into BUFFER, reallocating and adjusting *PBUFFER_SIZE if necessary. - Return the new value for BUFFER, or NULL at end of file. */ - -char * -read_name_from_file (buffer, pbuffer_size, stream) - char *buffer; - size_t *pbuffer_size; - FILE *stream; -{ - register int c; - register int indx = 0; - register size_t buffer_size = *pbuffer_size; - - while ((c = getc (stream)) != EOF && c != filename_terminator) - { - if (indx == buffer_size) - { - buffer_size += NAMSIZ; - buffer = ck_realloc (buffer, buffer_size + 2); - } - buffer[indx++] = c; - } - if (indx == 0 && c == EOF) - return NULL; - if (indx == buffer_size) - { - buffer_size += NAMSIZ; - buffer = ck_realloc (buffer, buffer_size + 2); - } - buffer[indx] = '\0'; - *pbuffer_size = buffer_size; - return buffer; -} - -/* - * Get the next name from argv or the name file. - * - * Result is in static storage and can't be relied upon across two calls. - * - * If CHANGE_DIRS is non-zero, treat a filename of the form "-C" as - * meaning that the next filename is the name of a directory to change to. - * If `filename_terminator' is '\0', CHANGE_DIRS is effectively always 0. - */ - -char * -name_next (change_dirs) - int change_dirs; -{ - static char *buffer; /* Holding pattern */ - static int buffer_siz; - register char *p; - register char *q = 0; - register int next_name_is_dir = 0; - extern char *un_quote_string (); - - if (buffer_siz == 0) - { - buffer = ck_malloc (NAMSIZ + 2); - buffer_siz = NAMSIZ; - } - if (filename_terminator == '\0') - change_dirs = 0; -tryagain: - if (namef == NULL) - { - if (n_indscan < n_indused) - p = n_ind[n_indscan++]; - else if (optind < n_argc) - /* Names come from argv, after options */ - p = n_argv[optind++]; - else - { - if (q) - msg ("Missing filename after -C"); - return NULL; - } - - /* JF trivial support for -C option. I don't know if - chdir'ing at this point is dangerous or not. - It seems to work, which is all I ask. */ - if (change_dirs && !q && p[0] == '-' && p[1] == 'C' && p[2] == '\0') - { - q = p; - goto tryagain; - } - if (q) - { - if (chdir (p) < 0) - msg_perror ("Can't chdir to %s", p); - q = 0; - goto tryagain; - } - /* End of JF quick -C hack */ - -#if 0 - if (f_exclude && check_exclude (p)) - goto tryagain; -#endif - return un_quote_string (p); - } - while (p = read_name_from_file (buffer, &buffer_siz, namef)) - { - buffer = p; - if (*p == '\0') - continue; /* Ignore empty lines. */ - q = p + strlen (p) - 1; - while (q > p && *q == '/')/* Zap trailing "/"s. */ - *q-- = '\0'; - if (change_dirs && next_name_is_dir == 0 - && p[0] == '-' && p[1] == 'C' && p[2] == '\0') - { - next_name_is_dir = 1; - goto tryagain; - } - if (next_name_is_dir) - { - if (chdir (p) < 0) - msg_perror ("Can't change to directory %s", p); - next_name_is_dir = 0; - goto tryagain; - } -#if 0 - if (f_exclude && check_exclude (p)) - goto tryagain; -#endif - return un_quote_string (p); - } - return NULL; -} - - -/* - * Close the name file, if any. - */ -void -name_close () -{ - - if (namef != NULL && namef != stdin) - fclose (namef); -} - - -/* - * Gather names in a list for scanning. - * Could hash them later if we really care. - * - * If the names are already sorted to match the archive, we just - * read them one by one. name_gather reads the first one, and it - * is called by name_match as appropriate to read the next ones. - * At EOF, the last name read is just left in the buffer. - * This option lets users of small machines extract an arbitrary - * number of files by doing "tar t" and editing down the list of files. - */ -void -name_gather () -{ - register char *p; - static struct name *namebuf; /* One-name buffer */ - static namelen; - static char *chdir_name; - - if (f_sorted_names) - { - if (!namelen) - { - namelen = NAMSIZ; - namebuf = (struct name *) ck_malloc (sizeof (struct name) + NAMSIZ); - } - p = name_next (0); - if (p) - { - if (*p == '-' && p[1] == 'C' && p[2] == '\0') - { - chdir_name = name_next (0); - p = name_next (0); - if (!p) - { - msg ("Missing file name after -C"); - exit (EX_ARGSBAD); - } - namebuf->change_dir = chdir_name; - } - namebuf->length = strlen (p); - if (namebuf->length >= namelen) - { - namebuf = (struct name *) ck_realloc (namebuf, sizeof (struct name) + namebuf->length); - namelen = namebuf->length; - } - strncpy (namebuf->name, p, namebuf->length); - namebuf->name[namebuf->length] = 0; - namebuf->next = (struct name *) NULL; - namebuf->found = 0; - namelist = namebuf; - namelast = namelist; - } - return; - } - - /* Non sorted names -- read them all in */ - while (p = name_next (0)) - addname (p); -} - -/* - * Add a name to the namelist. - */ -void -addname (name) - char *name; /* pointer to name */ -{ - register int i; /* Length of string */ - register struct name *p; /* Current struct pointer */ - static char *chdir_name; - char *new_name (); - - if (name[0] == '-' && name[1] == 'C' && name[2] == '\0') - { - chdir_name = name_next (0); - name = name_next (0); - if (!chdir_name) - { - msg ("Missing file name after -C"); - exit (EX_ARGSBAD); - } - if (chdir_name[0] != '/') - { - char *path = ck_malloc (PATH_MAX); -#if defined(__MSDOS__) || defined(HAVE_GETCWD) || defined(_POSIX_VERSION) - if (!getcwd (path, PATH_MAX)) - { - msg ("Couldn't get current directory."); - exit (EX_SYSTEM); - } -#else - char *getwd (); - - if (!getwd (path)) - { - msg ("Couldn't get current directory: %s", path); - exit (EX_SYSTEM); - } -#endif - chdir_name = new_name (path, chdir_name); - free (path); - } - } - - if (name) - { - i = strlen (name); - /*NOSTRICT*/ - p = (struct name *) malloc ((unsigned) (sizeof (struct name) + i)); - } - else - p = (struct name *) malloc ((unsigned) (sizeof (struct name))); - if (!p) - { - if (name) - msg ("cannot allocate mem for name '%s'.", name); - else - msg ("cannot allocate mem for chdir record."); - exit (EX_SYSTEM); - } - p->next = (struct name *) NULL; - if (name) - { - p->fake = 0; - p->length = i; - strncpy (p->name, name, i); - p->name[i] = '\0'; /* Null term */ - } - else - p->fake = 1; - p->found = 0; - p->regexp = 0; /* Assume not a regular expression */ - p->firstch = 1; /* Assume first char is literal */ - p->change_dir = chdir_name; - p->dir_contents = 0; /* JF */ - if (name) - { - if (index (name, '*') || index (name, '[') || index (name, '?')) - { - p->regexp = 1; /* No, it's a regexp */ - if (name[0] == '*' || name[0] == '[' || name[0] == '?') - p->firstch = 0; /* Not even 1st char literal */ - } - } - - if (namelast) - namelast->next = p; - namelast = p; - if (!namelist) - namelist = p; -} - -/* - * Return nonzero if name P (from an archive) matches any name from - * the namelist, zero if not. - */ -int -name_match (p) - register char *p; -{ - register struct name *nlp; - register int len; - -again: - if (0 == (nlp = namelist)) /* Empty namelist is easy */ - return 1; - if (nlp->fake) - { - if (nlp->change_dir && chdir (nlp->change_dir)) - msg_perror ("Can't change to directory %d", nlp->change_dir); - namelist = 0; - return 1; - } - len = strlen (p); - for (; nlp != 0; nlp = nlp->next) - { - /* If first chars don't match, quick skip */ - if (nlp->firstch && nlp->name[0] != p[0]) - continue; - - /* Regular expressions (shell globbing, actually). */ - if (nlp->regexp) - { - if (fnmatch (nlp->name, p, FNM_LEADING_DIR) == 0) - { - nlp->found = 1; /* Remember it matched */ - if (f_startfile) - { - free ((void *) namelist); - namelist = 0; - } - if (nlp->change_dir && chdir (nlp->change_dir)) - msg_perror ("Can't change to directory %s", nlp->change_dir); - return 1; /* We got a match */ - } - continue; - } - - /* Plain Old Strings */ - if (nlp->length <= len /* Archive len >= specified */ - && (p[nlp->length] == '\0' || p[nlp->length] == '/') - /* Full match on file/dirname */ - && strncmp (p, nlp->name, nlp->length) == 0) /* Name compare */ - { - nlp->found = 1; /* Remember it matched */ - if (f_startfile) - { - free ((void *) namelist); - namelist = 0; - } - if (nlp->change_dir && chdir (nlp->change_dir)) - msg_perror ("Can't change to directory %s", nlp->change_dir); - return 1; /* We got a match */ - } - } - - /* - * Filename from archive not found in namelist. - * If we have the whole namelist here, just return 0. - * Otherwise, read the next name in and compare it. - * If this was the last name, namelist->found will remain on. - * If not, we loop to compare the newly read name. - */ - if (f_sorted_names && namelist->found) - { - name_gather (); /* Read one more */ - if (!namelist->found) - goto again; - } - return 0; -} - - -/* - * Print the names of things in the namelist that were not matched. - */ -void -names_notfound () -{ - register struct name *nlp, *next; - register char *p; - - for (nlp = namelist; nlp != 0; nlp = next) - { - next = nlp->next; - if (!nlp->found) - msg ("%s not found in archive", nlp->name); - - /* - * We could free() the list, but the process is about - * to die anyway, so save some CPU time. Amigas and - * other similarly broken software will need to waste - * the time, though. - */ -#ifdef amiga - if (!f_sorted_names) - free (nlp); -#endif - } - namelist = (struct name *) NULL; - namelast = (struct name *) NULL; - - if (f_sorted_names) - { - while (0 != (p = name_next (1))) - msg ("%s not found in archive", p); - } -} - -/* These next routines were created by JF */ - -void -name_expand () -{ - ; -} - -/* This is like name_match(), except that it returns a pointer to the name - it matched, and doesn't set ->found The caller will have to do that - if it wants to. Oh, and if the namelist is empty, it returns 0, unlike - name_match(), which returns TRUE */ - -struct name * -name_scan (p) - register char *p; -{ - register struct name *nlp; - register int len; - -again: - if (0 == (nlp = namelist)) /* Empty namelist is easy */ - return 0; - len = strlen (p); - for (; nlp != 0; nlp = nlp->next) - { - /* If first chars don't match, quick skip */ - if (nlp->firstch && nlp->name[0] != p[0]) - continue; - - /* Regular expressions */ - if (nlp->regexp) - { - if (fnmatch (nlp->name, p, FNM_LEADING_DIR) == 0) - return nlp; /* We got a match */ - continue; - } - - /* Plain Old Strings */ - if (nlp->length <= len /* Archive len >= specified */ - && (p[nlp->length] == '\0' || p[nlp->length] == '/') - /* Full match on file/dirname */ - && strncmp (p, nlp->name, nlp->length) == 0) /* Name compare */ - return nlp; /* We got a match */ - } - - /* - * Filename from archive not found in namelist. - * If we have the whole namelist here, just return 0. - * Otherwise, read the next name in and compare it. - * If this was the last name, namelist->found will remain on. - * If not, we loop to compare the newly read name. - */ - if (f_sorted_names && namelist->found) - { - name_gather (); /* Read one more */ - if (!namelist->found) - goto again; - } - return (struct name *) 0; -} - -/* This returns a name from the namelist which doesn't have ->found set. - It sets ->found before returning, so successive calls will find and return - all the non-found names in the namelist */ - -struct name *gnu_list_name; - -char * -name_from_list () -{ - if (!gnu_list_name) - gnu_list_name = namelist; - while (gnu_list_name && gnu_list_name->found) - gnu_list_name = gnu_list_name->next; - if (gnu_list_name) - { - gnu_list_name->found++; - if (gnu_list_name->change_dir) - if (chdir (gnu_list_name->change_dir) < 0) - msg_perror ("can't chdir to %s", gnu_list_name->change_dir); - return gnu_list_name->name; - } - return (char *) 0; -} - -void -blank_name_list () -{ - struct name *n; - - gnu_list_name = 0; - for (n = namelist; n; n = n->next) - n->found = 0; -} - -char * -new_name (path, name) - char *path, *name; -{ - char *path_buf; - - path_buf = (char *) malloc (strlen (path) + strlen (name) + 2); - if (path_buf == 0) - { - msg ("Can't allocate memory for name '%s/%s", path, name); - exit (EX_SYSTEM); - } - (void) sprintf (path_buf, "%s/%s", path, name); - return path_buf; -} - -/* returns non-zero if the luser typed 'y' or 'Y', zero otherwise. */ - -int -confirm (action, file) - char *action, *file; -{ - int c, nl; - static FILE *confirm_file = 0; - extern FILE *msg_file; - extern char TTY_NAME[]; - - fprintf (msg_file, "%s %s?", action, file); - fflush (msg_file); - if (!confirm_file) - { - confirm_file = (archive == 0) ? fopen (TTY_NAME, "r") : stdin; - if (!confirm_file) - { - msg ("Can't read confirmation from user"); - exit (EX_SYSTEM); - } - } - c = getc (confirm_file); - for (nl = c; nl != '\n' && nl != EOF; nl = getc (confirm_file)) - ; - return (c == 'y' || c == 'Y'); -} - -char *x_buffer = 0; -int size_x_buffer; -int free_x_buffer; - -char **exclude = 0; -int size_exclude = 0; -int free_exclude = 0; - -char **re_exclude = 0; -int size_re_exclude = 0; -int free_re_exclude = 0; - -void -add_exclude (name) - char *name; -{ - /* char *rname;*/ - /* char **tmp_ptr;*/ - int size_buf; - - un_quote_string (name); - size_buf = strlen (name); - - if (x_buffer == 0) - { - x_buffer = (char *) ck_malloc (size_buf + 1024); - free_x_buffer = 1024; - } - else if (free_x_buffer <= size_buf) - { - char *old_x_buffer; - char **tmp_ptr; - - old_x_buffer = x_buffer; - x_buffer = (char *) ck_realloc (x_buffer, size_x_buffer + 1024); - free_x_buffer = 1024; - for (tmp_ptr = exclude; tmp_ptr < exclude + size_exclude; tmp_ptr++) - *tmp_ptr = x_buffer + ((*tmp_ptr) - old_x_buffer); - for (tmp_ptr = re_exclude; tmp_ptr < re_exclude + size_re_exclude; tmp_ptr++) - *tmp_ptr = x_buffer + ((*tmp_ptr) - old_x_buffer); - } - - if (is_regex (name)) - { - if (free_re_exclude == 0) - { - re_exclude = (char **) (re_exclude ? ck_realloc (re_exclude, (size_re_exclude + 32) * sizeof (char *)): ck_malloc (sizeof (char *) * 32)); - free_re_exclude += 32; - } - re_exclude[size_re_exclude] = x_buffer + size_x_buffer; - size_re_exclude++; - free_re_exclude--; - } - else - { - if (free_exclude == 0) - { - exclude = (char **) (exclude ? ck_realloc (exclude, (size_exclude + 32) * sizeof (char *)): ck_malloc (sizeof (char *) * 32)); - free_exclude += 32; - } - exclude[size_exclude] = x_buffer + size_x_buffer; - size_exclude++; - free_exclude--; - } - strcpy (x_buffer + size_x_buffer, name); - size_x_buffer += size_buf + 1; - free_x_buffer -= size_buf + 1; -} - -void -add_exclude_file (file) - char *file; -{ - FILE *fp; - char buf[1024]; - - if (strcmp (file, "-")) - fp = fopen (file, "r"); - else - /* Let's hope the person knows what they're doing. */ - /* Using -X - -T - -f - will get you *REALLY* strange - results. . . */ - fp = stdin; - - if (!fp) - { - msg_perror ("can't open %s", file); - exit (2); - } - while (fgets (buf, 1024, fp)) - { - /* int size_buf;*/ - char *end_str; - - end_str = rindex (buf, '\n'); - if (end_str) - *end_str = '\0'; - add_exclude (buf); - - } - fclose (fp); -} - -int -is_regex (str) - char *str; -{ - return index (str, '*') || index (str, '[') || index (str, '?'); -} - -/* Returns non-zero if the file 'name' should not be added/extracted */ -int -check_exclude (name) - char *name; -{ - int n; - char *str; - extern char *strstr (); - - for (n = 0; n < size_re_exclude; n++) - { - if (fnmatch (re_exclude[n], name, FNM_LEADING_DIR) == 0) - return 1; - } - for (n = 0; n < size_exclude; n++) - { - /* Accept the output from strstr only if it is the last - part of the string. There is certainly a faster way to - do this. . . */ - if ((str = strstr (name, exclude[n])) - && (str == name || str[-1] == '/') - && str[strlen (exclude[n])] == '\0') - return 1; - } - return 0; -} diff --git a/gnu/usr.bin/tar-1.11.2/tar.h b/gnu/usr.bin/tar-1.11.2/tar.h deleted file mode 100644 index c3fec78743bb..000000000000 --- a/gnu/usr.bin/tar-1.11.2/tar.h +++ /dev/null @@ -1,291 +0,0 @@ -/* Declarations for tar archives. - Copyright (C) 1988, 1992, 1993 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* major() and minor() macros (among other things) defined here for hpux */ -#ifdef hpux -#include -#endif - -/* - * Kludge for handling systems that can't cope with multiple - * external definitions of a variable. In ONE routine (tar.c), - * we #define TAR_EXTERN to null; here, we set it to "extern" if - * it is not already set. - */ -#ifndef TAR_EXTERN -#define TAR_EXTERN extern -#endif - -/* - * Header block on tape. - * - * I'm going to use traditional DP naming conventions here. - * A "block" is a big chunk of stuff that we do I/O on. - * A "record" is a piece of info that we care about. - * Typically many "record"s fit into a "block". - */ -#define RECORDSIZE 512 -#define NAMSIZ 100 -#define TUNMLEN 32 -#define TGNMLEN 32 -#define SPARSE_EXT_HDR 21 -#define SPARSE_IN_HDR 4 - -struct sparse - { - char offset[12]; - char numbytes[12]; - }; - -struct sp_array - { - int offset; - int numbytes; - }; - -union record - { - char charptr[RECORDSIZE]; - struct header - { - char arch_name[NAMSIZ]; - char mode[8]; - char uid[8]; - char gid[8]; - char size[12]; - char mtime[12]; - char chksum[8]; - char linkflag; - char arch_linkname[NAMSIZ]; - char magic[8]; - char uname[TUNMLEN]; - char gname[TGNMLEN]; - char devmajor[8]; - char devminor[8]; - /* these following fields were added by JF for gnu */ - /* and are NOT standard */ - char atime[12]; - char ctime[12]; - char offset[12]; - char longnames[4]; -#ifdef NEEDPAD - char pad; -#endif - struct sparse sp[SPARSE_IN_HDR]; - char isextended; - char realsize[12]; /* true size of the sparse file */ - /* char ending_blanks[12];*//* number of nulls at the - end of the file, if any */ - } - header; - struct extended_header - { - struct sparse sp[21]; - char isextended; - } - ext_hdr; - }; - -/* The checksum field is filled with this while the checksum is computed. */ -#define CHKBLANKS " " /* 8 blanks, no null */ - -/* The magic field is filled with this if uname and gname are valid. */ -#define TMAGIC "ustar " /* 7 chars and a null */ - -/* The linkflag defines the type of file */ -#define LF_OLDNORMAL '\0' /* Normal disk file, Unix compat */ -#define LF_NORMAL '0' /* Normal disk file */ -#define LF_LINK '1' /* Link to previously dumped file */ -#define LF_SYMLINK '2' /* Symbolic link */ -#define LF_CHR '3' /* Character special file */ -#define LF_BLK '4' /* Block special file */ -#define LF_DIR '5' /* Directory */ -#define LF_FIFO '6' /* FIFO special file */ -#define LF_CONTIG '7' /* Contiguous file */ -/* Further link types may be defined later. */ - -/* Note that the standards committee allows only capital A through - capital Z for user-defined expansion. This means that defining something - as, say '8' is a *bad* idea. */ -#define LF_DUMPDIR 'D' /* This is a dir entry that contains - the names of files that were in - the dir at the time the dump - was made */ -#define LF_LONGLINK 'K' /* Identifies the NEXT file on the tape - as having a long linkname */ -#define LF_LONGNAME 'L' /* Identifies the NEXT file on the tape - as having a long name. */ -#define LF_MULTIVOL 'M' /* This is the continuation - of a file that began on another - volume */ -#define LF_NAMES 'N' /* For storing filenames that didn't - fit in 100 characters */ -#define LF_SPARSE 'S' /* This is for sparse files */ -#define LF_VOLHDR 'V' /* This file is a tape/volume header */ -/* Ignore it on extraction */ - -/* - * Exit codes from the "tar" program - */ -#define EX_SUCCESS 0 /* success! */ -#define EX_ARGSBAD 1 /* invalid args */ -#define EX_BADFILE 2 /* invalid filename */ -#define EX_BADARCH 3 /* bad archive */ -#define EX_SYSTEM 4 /* system gave unexpected error */ -#define EX_BADVOL 5 /* Special error code means - Tape volume doesn't match the one - specified on the command line */ - -/* - * Global variables - */ -TAR_EXTERN union record *ar_block; /* Start of block of archive */ -TAR_EXTERN union record *ar_record; /* Current record of archive */ -TAR_EXTERN union record *ar_last; /* Last+1 record of archive block */ -TAR_EXTERN char ar_reading; /* 0 writing, !0 reading archive */ -TAR_EXTERN int blocking; /* Size of each block, in records */ -TAR_EXTERN int blocksize; /* Size of each block, in bytes */ -TAR_EXTERN char *info_script; /* Script to run at end of each tape change */ -TAR_EXTERN char *name_file; /* File containing names to work on */ -TAR_EXTERN char filename_terminator; /* \n or \0. */ -TAR_EXTERN char *tar; /* Name of this program */ -TAR_EXTERN struct sp_array *sparsearray; /* Pointer to the start of the scratch space */ -TAR_EXTERN int sp_array_size; /* Initial size of the sparsearray */ -TAR_EXTERN int tot_written; /* Total written to output */ -TAR_EXTERN struct re_pattern_buffer - *label_pattern; /* compiled regex for extract label */ -TAR_EXTERN char **ar_files; /* list of tape drive names */ -TAR_EXTERN int n_ar_files; /* number of tape drive names */ -TAR_EXTERN int cur_ar_file; /* tape drive currently being used */ -TAR_EXTERN int ar_files_len; /* malloced size of ar_files */ -TAR_EXTERN char *current_file_name, *current_link_name; - -/* - * Flags from the command line - */ -TAR_EXTERN int cmd_mode; -#define CMD_NONE 0 -#define CMD_CAT 1 /* -A */ -#define CMD_CREATE 2 /* -c */ -#define CMD_DIFF 3 /* -d */ -#define CMD_APPEND 4 /* -r */ -#define CMD_LIST 5 /* -t */ -#define CMD_UPDATE 6 /* -u */ -#define CMD_EXTRACT 7 /* -x */ -#define CMD_DELETE 8 /* -D */ -#define CMD_VERSION 9 /* --version */ - - -TAR_EXTERN int f_reblock; /* -B */ -#if 0 -TAR_EXTERN char f_dironly; /* -D */ -#endif -TAR_EXTERN int f_run_script_at_end; /* -F */ -TAR_EXTERN int f_gnudump; /* -G */ -TAR_EXTERN int f_follow_links; /* -h */ -TAR_EXTERN int f_ignorez; /* -i */ -TAR_EXTERN int f_keep; /* -k */ -TAR_EXTERN int f_startfile; /* -K */ -TAR_EXTERN int f_local_filesys; /* -l */ -TAR_EXTERN int tape_length; /* -L */ -TAR_EXTERN int f_modified; /* -m */ -TAR_EXTERN int f_multivol; /* -M */ -TAR_EXTERN int f_new_files; /* -N */ -TAR_EXTERN int f_oldarch; /* -o */ -TAR_EXTERN int f_exstdout; /* -O */ -TAR_EXTERN int f_use_protection;/* -p */ -TAR_EXTERN int f_absolute_paths;/* -P */ -TAR_EXTERN int f_sayblock; /* -R */ -TAR_EXTERN int f_sorted_names; /* -s */ -TAR_EXTERN int f_sparse_files; /* -S ... JK */ -TAR_EXTERN int f_namefile; /* -T */ -TAR_EXTERN int f_verbose; /* -v */ -TAR_EXTERN char *f_volhdr; /* -V */ -TAR_EXTERN int f_confirm; /* -w */ -TAR_EXTERN int f_verify; /* -W */ -TAR_EXTERN int f_exclude; /* -X */ -TAR_EXTERN char *f_compressprog; /* -z and -Z */ -TAR_EXTERN int f_do_chown; /* --do-chown */ -TAR_EXTERN int f_totals; /* --totals */ -TAR_EXTERN int f_remove_files; /* --remove-files */ -TAR_EXTERN int f_ignore_failed_read; /* --ignore-failed-read */ -TAR_EXTERN int f_checkpoint; /* --checkpoint */ -TAR_EXTERN int f_show_omitted_dirs; /* --show-omitted-dirs */ -TAR_EXTERN char *f_volno_file; /* --volno-file */ -TAR_EXTERN int f_force_local; /* --force-local */ -TAR_EXTERN int f_atime_preserve;/* --atime-preserve */ -TAR_EXTERN int f_compress_block; /* --compress-block */ - -/* - * We default to Unix Standard format rather than 4.2BSD tar format. - * The code can actually produce all three: - * f_standard ANSI standard - * f_oldarch V7 - * neither 4.2BSD - * but we don't bother, since 4.2BSD can read ANSI standard format anyway. - * The only advantage to the "neither" option is that we can cmp our - * output to the output of 4.2BSD tar, for debugging. - */ -#define f_standard (!f_oldarch) - -/* - * Structure for keeping track of filenames and lists thereof. - */ -struct name - { - struct name *next; - short length; /* cached strlen(name) */ - char found; /* A matching file has been found */ - char firstch; /* First char is literally matched */ - char regexp; /* This name is a regexp, not literal */ - char *change_dir; /* JF set with the -C option */ - char *dir_contents; /* JF for f_gnudump */ - char fake; /* dummy entry */ - char name[1]; - }; - -TAR_EXTERN struct name *namelist; /* Points to first name in list */ -TAR_EXTERN struct name *namelast; /* Points to last name in list */ - -TAR_EXTERN int archive; /* File descriptor for archive file */ -TAR_EXTERN int errors; /* # of files in error */ - -TAR_EXTERN char *gnu_dumpfile; - -/* - * Error recovery stuff - */ -TAR_EXTERN char read_error_flag; - - -/* - * Declarations of functions available to the world. - */ -union record *findrec (); -void userec (); -union record *endofrecs (); -void anno (); - -#if defined (HAVE_VPRINTF) && __STDC__ -void msg (char *,...); -void msg_perror (char *,...); -#else -void msg (); -void msg_perror (); -#endif diff --git a/gnu/usr.bin/tar-1.11.2/update.c b/gnu/usr.bin/tar-1.11.2/update.c deleted file mode 100644 index a64317c666dc..000000000000 --- a/gnu/usr.bin/tar-1.11.2/update.c +++ /dev/null @@ -1,585 +0,0 @@ -/* Update a tar archive. - Copyright (C) 1988, 1992 Free Software Foundation - -This file is part of GNU Tar. - -GNU Tar 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. - -GNU Tar 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 Tar; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* JF implement the 'r' 'u' and 'A' options for tar. */ -/* The 'A' option is my own invention: It means that the file-names are - tar files, and they should simply be appended to the end of the archive. - No attempt is made to block the reads from the args; if they're on raw - tape or something like that, it'll probably lose. . . */ - -#include -#include -#include -#ifndef STDC_HEADERS -extern int errno; -#endif - -#ifdef HAVE_SYS_MTIO_H -#include -#include -#endif - -#ifdef BSD42 -#include -#else -#ifndef V7 -#include -#endif -#endif - -#ifndef __MSDOS__ -#include -#include -#endif - -#define STDIN 0 -#define STDOUT 1 - -#include "tar.h" -#include "port.h" -#include "rmt.h" - -int time_to_start_writing = 0; /* We've hit the end of the old stuff, - and its time to start writing new stuff - to the tape. This involves seeking - back one block and re-writing the current - block (which has been changed). */ - -char *output_start; /* Pointer to where we started to write in - the first block we write out. This is used - if we can't backspace the output and have - to null out the first part of the block */ - -extern void skip_file (); -extern void skip_extended_headers (); - -extern union record *head; -extern struct stat hstat; - -void append_file (); -void close_archive (); -int confirm (); -void decode_header (); -void fl_read (); -void fl_write (); -void flush_archive (); -int move_arch (); -struct name *name_scan (); -char *name_from_list (); -void name_expand (); -void name_gather (); -void names_notfound (); -void open_archive (); -int read_header (); -void reset_eof (); -void write_block (); -void write_eot (); - -/* Implement the 'r' (add files to end of archive), and 'u' (add files to - end of archive if they arent there, or are more up to date than the - version in the archive.) commands.*/ -void -update_archive () -{ - int found_end = 0; - int status = 3; - int prev_status; - char *p; - struct name *name; - extern void dump_file (); - - name_gather (); - if (cmd_mode == CMD_UPDATE) - name_expand (); - open_archive (2); /* Open for updating */ - - do - { - prev_status = status; - status = read_header (); - switch (status) - { - case EOF: - found_end = 1; - break; - - case 0: /* A bad record */ - userec (head); - switch (prev_status) - { - case 3: - msg ("This doesn't look like a tar archive."); - /* FALL THROUGH */ - case 2: - case 1: - msg ("Skipping to next header"); - case 0: - break; - } - break; - - /* A good record */ - case 1: - /* printf("File %s\n",head->header.name); */ - /* head->header.name[NAMSIZ-1]='\0'; */ - if (cmd_mode == CMD_UPDATE && (name = name_scan (current_file_name))) - { - - /* struct stat hstat; */ - struct stat nstat; - int head_standard; - - decode_header (head, &hstat, &head_standard, 0); - if (stat (current_file_name, &nstat) < 0) - { - msg_perror ("can't stat %s:", current_file_name); - } - else - { - if (hstat.st_mtime >= nstat.st_mtime) - name->found++; - } - } - userec (head); - if (head->header.isextended) - skip_extended_headers (); - skip_file ((long) hstat.st_size); - break; - - case 2: - ar_record = head; - found_end = 1; - break; - } - } - while (!found_end); - - reset_eof (); - time_to_start_writing = 1; - output_start = ar_record->charptr; - - while (p = name_from_list ()) - { - if (f_confirm && !confirm ("add", p)) - continue; - if (cmd_mode == CMD_CAT) - append_file (p); - else - dump_file (p, -1, 1); - } - - write_eot (); - close_archive (); - names_notfound (); -} - -/* Catenate file p to the archive without creating a header for it. It had - better be a tar file or the archive is screwed */ - -void -append_file (p) - char *p; -{ - int fd; - struct stat statbuf; - long bytes_left; - union record *start; - long bufsiz, count; - - if (0 != stat (p, &statbuf) || (fd = open (p, O_RDONLY | O_BINARY)) < 0) - { - msg_perror ("can't open file %s", p); - errors++; - return; - } - - bytes_left = statbuf.st_size; - - while (bytes_left > 0) - { - start = findrec (); - bufsiz = endofrecs ()->charptr - start->charptr; - if (bytes_left < bufsiz) - { - bufsiz = bytes_left; - count = bufsiz % RECORDSIZE; - if (count) - bzero (start->charptr + bytes_left, (int) (RECORDSIZE - count)); - } - count = read (fd, start->charptr, bufsiz); - if (count < 0) - { - msg_perror ("read error at byte %ld reading %d bytes in file %s", statbuf.st_size - bytes_left, bufsiz, p); - exit (EX_ARGSBAD); /* FOO */ - } - bytes_left -= count; - userec (start + (count - 1) / RECORDSIZE); - if (count != bufsiz) - { - msg ("%s: file shrunk by %d bytes, yark!", p, bytes_left); - abort (); - } - } - (void) close (fd); -} - -#ifdef DONTDEF -bprint (fp, buf, num) - FILE *fp; - char *buf; -{ - int c; - - if (num == 0 || num == -1) - return; - fputs (" '", fp); - while (num--) - { - c = *buf++; - if (c == '\\') - fputs ("\\\\", fp); - else if (c >= ' ' && c <= '~') - putc (c, fp); - else - switch (c) - { - case '\n': - fputs ("\\n", fp); - break; - case '\r': - fputs ("\\r", fp); - break; - case '\b': - fputs ("\\b", fp); - break; - case '\0': - /* fputs("\\-",fp); */ - break; - default: - fprintf (fp, "\\%03o", c); - break; - } - } - fputs ("'\n", fp); -} - -#endif - -int number_of_blocks_read = 0; - -int number_of_new_records = 0; -int number_of_records_needed = 0; - -union record *new_block = 0; -union record *save_block = 0; - -void -junk_archive () -{ - int found_stuff = 0; - int status = 3; - int prev_status; - struct name *name; - - /* int dummy_head; */ - int number_of_records_to_skip = 0; - int number_of_records_to_keep = 0; - int number_of_kept_records_in_block; - int sub_status; - extern int write_archive_to_stdout; - - /* fprintf(stderr,"Junk files\n"); */ - name_gather (); - open_archive (2); - - while (!found_stuff) - { - prev_status = status; - status = read_header (); - switch (status) - { - case EOF: - found_stuff = 1; - break; - - case 0: - userec (head); - switch (prev_status) - { - case 3: - msg ("This doesn't look like a tar archive."); - /* FALL THROUGH */ - case 2: - case 1: - msg ("Skipping to next header"); - /* FALL THROUGH */ - case 0: - break; - } - break; - - case 1: - /* head->header.name[NAMSIZ-1] = '\0'; */ - /* fprintf(stderr,"file %s\n",head->header.name); */ - if ((name = name_scan (current_file_name)) == (struct name *) 0) - { - userec (head); - /* fprintf(stderr,"Skip %ld\n",(long)(hstat.st_size)); */ - if (head->header.isextended) - skip_extended_headers (); - skip_file ((long) (hstat.st_size)); - break; - } - name->found = 1; - found_stuff = 2; - break; - - case 2: - found_stuff = 1; - break; - } - } - /* fprintf(stderr,"Out of first loop\n"); */ - - if (found_stuff != 2) - { - write_eot (); - close_archive (); - names_notfound (); - return; - } - - if (write_archive_to_stdout) - write_archive_to_stdout = 0; - new_block = (union record *) malloc (blocksize); - if (new_block == 0) - { - msg ("Can't allocate secondary block of %d bytes", blocksize); - exit (EX_SYSTEM); - } - - /* Save away records before this one in this block */ - number_of_new_records = ar_record - ar_block; - number_of_records_needed = blocking - number_of_new_records; - if (number_of_new_records) - bcopy ((void *) ar_block, (void *) new_block, (number_of_new_records) * RECORDSIZE); - - /* fprintf(stderr,"Saved %d recs, need %d more\n",number_of_new_records,number_of_records_needed); */ - userec (head); - if (head->header.isextended) - skip_extended_headers (); - skip_file ((long) (hstat.st_size)); - found_stuff = 0; - /* goto flush_file; */ - - for (;;) - { - /* Fill in a block */ - /* another_file: */ - if (ar_record == ar_last) - { - /* fprintf(stderr,"New block\n"); */ - flush_archive (); - number_of_blocks_read++; - } - sub_status = read_header (); - /* fprintf(stderr,"Header type %d\n",sub_status); */ - - if (sub_status == 2 && f_ignorez) - { - userec (head); - continue; - } - if (sub_status == EOF || sub_status == 2) - { - found_stuff = 1; - bzero (new_block[number_of_new_records].charptr, RECORDSIZE * number_of_records_needed); - number_of_new_records += number_of_records_needed; - number_of_records_needed = 0; - write_block (0); - break; - } - - if (sub_status == 0) - { - msg ("Deleting non-header from archive."); - userec (head); - continue; - } - - /* Found another header. Yipee! */ - /* head->header.name[NAMSIZ-1] = '\0'; */ - /* fprintf(stderr,"File %s ",head->header.name); */ - if (name = name_scan (current_file_name)) - { - name->found = 1; - /* fprintf(stderr,"Flush it\n"); */ - /* flush_file: */ - /* decode_header(head,&hstat,&dummy_head,0); */ - userec (head); - number_of_records_to_skip = (hstat.st_size + RECORDSIZE - 1) / RECORDSIZE; - /* fprintf(stderr,"Flushing %d recs from %s\n",number_of_records_to_skip,head->header.name); */ - - while (ar_last - ar_record <= number_of_records_to_skip) - { - - /* fprintf(stderr,"Block: %d <= %d ",ar_last-ar_record,number_of_records_to_skip); */ - number_of_records_to_skip -= (ar_last - ar_record); - flush_archive (); - number_of_blocks_read++; - /* fprintf(stderr,"Block %d left\n",number_of_records_to_skip); */ - } - ar_record += number_of_records_to_skip; - /* fprintf(stderr,"Final %d\n",number_of_records_to_skip); */ - number_of_records_to_skip = 0; - continue; - } - - /* copy_header: */ - new_block[number_of_new_records] = *head; - number_of_new_records++; - number_of_records_needed--; - number_of_records_to_keep = (hstat.st_size + RECORDSIZE - 1) / RECORDSIZE; - userec (head); - if (number_of_records_needed == 0) - write_block (1); - /* copy_data: */ - number_of_kept_records_in_block = ar_last - ar_record; - if (number_of_kept_records_in_block > number_of_records_to_keep) - number_of_kept_records_in_block = number_of_records_to_keep; - - /* fprintf(stderr,"Need %d kept_in %d keep %d\n",blocking,number_of_kept_records_in_block,number_of_records_to_keep); */ - - while (number_of_records_to_keep) - { - int n; - - if (ar_record == ar_last) - { - /* fprintf(stderr,"Flush. . .\n"); */ - fl_read (); - number_of_blocks_read++; - ar_record = ar_block; - number_of_kept_records_in_block = blocking; - if (number_of_kept_records_in_block > number_of_records_to_keep) - number_of_kept_records_in_block = number_of_records_to_keep; - } - n = number_of_kept_records_in_block; - if (n > number_of_records_needed) - n = number_of_records_needed; - - /* fprintf(stderr,"Copying %d\n",n); */ - bcopy ((void *) ar_record, (void *) (new_block + number_of_new_records), n * RECORDSIZE); - number_of_new_records += n; - number_of_records_needed -= n; - ar_record += n; - number_of_records_to_keep -= n; - number_of_kept_records_in_block -= n; - /* fprintf(stderr,"Now new %d need %d keep %d keep_in %d rec %d/%d\n", - number_of_new_records,number_of_records_needed,number_of_records_to_keep, - number_of_kept_records_in_block,ar_record-ar_block,ar_last-ar_block); */ - - if (number_of_records_needed == 0) - { - write_block (1); - } - } - } - - write_eot (); - close_archive (); - names_notfound (); -} - -void -write_block (f) - int f; -{ - /* fprintf(stderr,"Write block\n"); */ - /* We've filled out a block. Write it out. */ - - /* Backspace back to where we started. . . */ - if (archive != STDIN) - (void) move_arch (-(number_of_blocks_read + 1)); - - save_block = ar_block; - ar_block = new_block; - - if (archive == STDIN) - archive = STDOUT; - fl_write (); - - if (archive == STDOUT) - archive = STDIN; - ar_block = save_block; - - if (f) - { - /* Move the tape head back to where we were */ - if (archive != STDIN) - (void) move_arch (number_of_blocks_read); - number_of_blocks_read--; - } - - number_of_records_needed = blocking; - number_of_new_records = 0; -} - -/* Move archive descriptor by n blocks worth. If n is positive we move - forward, else we move negative. If its a tape, MTIOCTOP had better - work. If its something else, we try to seek on it. If we can't - seek, we lose! */ -int -move_arch (n) - int n; -{ - long cur; - -#ifdef MTIOCTOP - struct mtop t; - int er; - - if (n > 0) - { - t.mt_op = MTFSR; - t.mt_count = n; - } - else - { - t.mt_op = MTBSR; - t.mt_count = -n; - } - if ((er = rmtioctl (archive, MTIOCTOP, &t)) >= 0) - return 1; - if (errno == EIO && (er = rmtioctl (archive, MTIOCTOP, &t)) >= 0) - return 1; -#endif - - cur = rmtlseek (archive, 0L, 1); - cur += blocksize * n; - - /* fprintf(stderr,"Fore to %x\n",cur); */ - if (rmtlseek (archive, cur, 0) != cur) - { - /* Lseek failed. Try a different method */ - msg ("Couldn't re-position archive file."); - exit (EX_BADARCH); - } - return 3; -} diff --git a/gnu/usr.bin/tar-1.11.2/version.c b/gnu/usr.bin/tar-1.11.2/version.c deleted file mode 100644 index 4454f62c8e98..000000000000 --- a/gnu/usr.bin/tar-1.11.2/version.c +++ /dev/null @@ -1 +0,0 @@ -char version_string[] = "GNU tar version 1.11.2"; diff --git a/include/rpcsvc/nlm_prot.x b/include/rpcsvc/nlm_prot.x deleted file mode 100644 index 27bbd9490f5d..000000000000 --- a/include/rpcsvc/nlm_prot.x +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Network lock manager protocol definition - * Copyright (C) 1986 Sun Microsystems, Inc. - * - * protocol used between local lock manager and remote lock manager - */ - -#ifdef RPC_HDR -%#define LM_MAXSTRLEN 1024 -%#define MAXNAMELEN LM_MAXSTRLEN+1 -#else -%#ifndef lint -%/*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: nlm_prot.x,v 1.4 1993/08/03 21:53:22 mycroft Exp $"; -%#endif /* not lint */ -#endif - -/* - * status of a call to the lock manager - */ -enum nlm_stats { - nlm_granted = 0, - nlm_denied = 1, - nlm_denied_nolocks = 2, - nlm_blocked = 3, - nlm_denied_grace_period = 4 -}; - -struct nlm_holder { - bool exclusive; - int svid; - netobj oh; - unsigned l_offset; - unsigned l_len; -}; - -union nlm_testrply switch (nlm_stats stat) { - case nlm_denied: - struct nlm_holder holder; - default: - void; -}; - -struct nlm_stat { - nlm_stats stat; -}; - -struct nlm_res { - netobj cookie; - nlm_stat stat; -}; - -struct nlm_testres { - netobj cookie; - nlm_testrply stat; -}; - -struct nlm_lock { - string caller_name; - netobj fh; /* identify a file */ - netobj oh; /* identify owner of a lock */ - int svid; /* generated from pid for svid */ - unsigned l_offset; - unsigned l_len; -}; - -struct nlm_lockargs { - netobj cookie; - bool block; - bool exclusive; - struct nlm_lock alock; - bool reclaim; /* used for recovering locks */ - int state; /* specify local status monitor state */ -}; - -struct nlm_cancargs { - netobj cookie; - bool block; - bool exclusive; - struct nlm_lock alock; -}; - -struct nlm_testargs { - netobj cookie; - bool exclusive; - struct nlm_lock alock; -}; - -struct nlm_unlockargs { - netobj cookie; - struct nlm_lock alock; -}; - - -#ifdef RPC_HDR -%/* -% * The following enums are actually bit encoded for efficient -% * boolean algebra.... DON'T change them..... -% */ -#endif -enum fsh_mode { - fsm_DN = 0, /* deny none */ - fsm_DR = 1, /* deny read */ - fsm_DW = 2, /* deny write */ - fsm_DRW = 3 /* deny read/write */ -}; - -enum fsh_access { - fsa_NONE = 0, /* for completeness */ - fsa_R = 1, /* read only */ - fsa_W = 2, /* write only */ - fsa_RW = 3 /* read/write */ -}; - -struct nlm_share { - string caller_name; - netobj fh; - netobj oh; - fsh_mode mode; - fsh_access access; -}; - -struct nlm_shareargs { - netobj cookie; - nlm_share share; - bool reclaim; -}; - -struct nlm_shareres { - netobj cookie; - nlm_stats stat; - int sequence; -}; - -struct nlm_notify { - string name; - long state; -}; - -/* - * Over-the-wire protocol used between the network lock managers - */ - -program NLM_PROG { - version NLM_VERS { - - nlm_testres NLM_TEST(struct nlm_testargs) = 1; - - nlm_res NLM_LOCK(struct nlm_lockargs) = 2; - - nlm_res NLM_CANCEL(struct nlm_cancargs) = 3; - nlm_res NLM_UNLOCK(struct nlm_unlockargs) = 4; - - /* - * remote lock manager call-back to grant lock - */ - nlm_res NLM_GRANTED(struct nlm_testargs)= 5; - /* - * message passing style of requesting lock - */ - void NLM_TEST_MSG(struct nlm_testargs) = 6; - void NLM_LOCK_MSG(struct nlm_lockargs) = 7; - void NLM_CANCEL_MSG(struct nlm_cancargs) =8; - void NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9; - void NLM_GRANTED_MSG(struct nlm_testargs) = 10; - void NLM_TEST_RES(nlm_testres) = 11; - void NLM_LOCK_RES(nlm_res) = 12; - void NLM_CANCEL_RES(nlm_res) = 13; - void NLM_UNLOCK_RES(nlm_res) = 14; - void NLM_GRANTED_RES(nlm_res) = 15; - } = 1; - - version NLM_VERSX { - nlm_shareres NLM_SHARE(nlm_shareargs) = 20; - nlm_shareres NLM_UNSHARE(nlm_shareargs) = 21; - nlm_res NLM_NM_LOCK(nlm_lockargs) = 22; - void NLM_FREE_ALL(nlm_notify) = 23; - } = 3; - -} = 100021; - diff --git a/include/rpcsvc/rex.x b/include/rpcsvc/rex.x deleted file mode 100644 index d3ab0320a78c..000000000000 --- a/include/rpcsvc/rex.x +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Remote execution (rex) protocol specification - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)rex.x 1.3 87/09/18 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)rex.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: rex.x,v 1.4 1993/08/03 21:53:23 mycroft Exp $"; -%#endif /* not lint */ -#endif - -const STRINGSIZE = 1024; -typedef string rexstring<1024>; - -/* - * values to pass to REXPROC_SIGNAL - */ -const SIGINT = 2; /* interrupt */ - -/* - * Values for rst_flags, below - */ -const REX_INTERACTIVE = 1; /* interactive mode */ - -struct rex_start { - rexstring rst_cmd<>; /* list of command and args */ - rexstring rst_host; /* working directory host name */ - rexstring rst_fsname; /* working directory file system name */ - rexstring rst_dirwithin;/* working directory within file system */ - rexstring rst_env<>; /* list of environment */ - unsigned int rst_port0; /* port for stdin */ - unsigned int rst_port1; /* port for stdout */ - unsigned int rst_port2; /* port for stderr */ - unsigned int rst_flags; /* options - see const above */ -}; - -struct rex_result { - int rlt_stat; /* integer status code */ - rexstring rlt_message; /* string message for human consumption */ -}; - - -struct sgttyb { - unsigned four; /* always equals 4 */ - opaque chars[4]; - /* chars[0] == input speed */ - /* chars[1] == output speed */ - /* chars[2] == kill character */ - /* chars[3] == erase character */ - unsigned flags; -}; -/* values for speeds above (baud rates) */ -const B0 = 0; -const B50 = 1; -const B75 = 2; -const B110 = 3; -const B134 = 4; -const B150 = 5; -const B200 = 6; -const B300 = 7; -const B600 = 8; -const B1200 = 9; -const B1800 = 10; -const B2400 = 11; -const B4800 = 12; -const B9600 = 13; -const B19200 = 14; -const B38400 = 15; - -/* values for flags above */ -const TANDEM = 0x00000001; /* send stopc on out q full */ -const CBREAK = 0x00000002; /* half-cooked mode */ -const LCASE = 0x00000004; /* simulate lower case */ -const ECHO = 0x00000008; /* echo input */ -const CRMOD = 0x00000010; /* map \r to \r\n on output */ -const RAW = 0x00000020; /* no i/o processing */ -const ODDP = 0x00000040; /* get/send odd parity */ -const EVENP = 0x00000080; /* get/send even parity */ -const ANYP = 0x000000c0; /* get any parity/send none */ -const NLDELAY = 0x00000300; /* \n delay */ -const NL0 = 0x00000000; -const NL1 = 0x00000100; /* tty 37 */ -const NL2 = 0x00000200; /* vt05 */ -const NL3 = 0x00000300; -const TBDELAY = 0x00000c00; /* horizontal tab delay */ -const TAB0 = 0x00000000; -const TAB1 = 0x00000400; /* tty 37 */ -const TAB2 = 0x00000800; -const XTABS = 0x00000c00; /* expand tabs on output */ -const CRDELAY = 0x00003000; /* \r delay */ -const CR0 = 0x00000000; -const CR1 = 0x00001000; /* tn 300 */ -const CR2 = 0x00002000; /* tty 37 */ -const CR3 = 0x00003000; /* concept 100 */ -const VTDELAY = 0x00004000; /* vertical tab delay */ -const FF0 = 0x00000000; -const FF1 = 0x00004000; /* tty 37 */ -const BSDELAY = 0x00008000; /* \b delay */ -const BS0 = 0x00000000; -const BS1 = 0x00008000; -const CRTBS = 0x00010000; /* do backspacing for crt */ -const PRTERA = 0x00020000; /* \ ... / erase */ -const CRTERA = 0x00040000; /* " \b " to wipe out char */ -const TILDE = 0x00080000; /* hazeltine tilde kludge */ -const MDMBUF = 0x00100000; /* start/stop output on carrier intr */ -const LITOUT = 0x00200000; /* literal output */ -const TOSTOP = 0x00400000; /* SIGTTOU on background output */ -const FLUSHO = 0x00800000; /* flush output to terminal */ -const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */ -const L001000 = 0x02000000; -const CRTKIL = 0x04000000; /* kill line with " \b " */ -const PASS8 = 0x08000000; -const CTLECH = 0x10000000; /* echo control chars as ^X */ -const PENDIN = 0x20000000; /* tp->t_rawq needs reread */ -const DECCTQ = 0x40000000; /* only ^Q starts after ^S */ -const NOFLSH = 0x80000000; /* no output flush on signal */ - -struct tchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == interrupt char */ - /* chars[1] == quit char */ - /* chars[2] == start output char */ - /* chars[3] == stop output char */ - /* chars[4] == end-of-file char */ - /* chars[5] == input delimeter (like nl) */ -}; - -struct ltchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == stop process signal */ - /* chars[1] == delayed stop process signal */ - /* chars[2] == reprint line */ - /* chars[3] == flush output */ - /* chars[4] == word erase */ - /* chars[5] == literal next character */ - unsigned mode; -}; - -struct rex_ttysize { - int ts_lines; - int ts_cols; -}; - -struct rex_ttymode { - sgttyb basic; /* standard unix tty flags */ - tchars more; /* interrupt, kill characters, etc. */ - ltchars yetmore; /* special Berkeley characters */ - unsigned andmore; /* and Berkeley modes */ -}; - -/* values for andmore above */ -const LCRTBS = 0x0001; /* do backspacing for crt */ -const LPRTERA = 0x0002; /* \ ... / erase */ -const LCRTERA = 0x0004; /* " \b " to wipe out char */ -const LTILDE = 0x0008; /* hazeltine tilde kludge */ -const LMDMBUF = 0x0010; /* start/stop output on carrier intr */ -const LLITOUT = 0x0020; /* literal output */ -const LTOSTOP = 0x0040; /* SIGTTOU on background output */ -const LFLUSHO = 0x0080; /* flush output to terminal */ -const LNOHANG = 0x0100; /* no SIGHUP on carrier drop */ -const LL001000 = 0x0200; -const LCRTKIL = 0x0400; /* kill line with " \b " */ -const LPASS8 = 0x0800; -const LCTLECH = 0x1000; /* echo control chars as ^X */ -const LPENDIN = 0x2000; /* needs reread */ -const LDECCTQ = 0x4000; /* only ^Q starts after ^S */ -const LNOFLSH = 0x8000; /* no output flush on signal */ - -program REXPROG { - version REXVERS { - - /* - * Start remote execution - */ - rex_result - REXPROC_START(rex_start) = 1; - - /* - * Wait for remote execution to terminate - */ - rex_result - REXPROC_WAIT(void) = 2; - - /* - * Send tty modes - */ - void - REXPROC_MODES(rex_ttymode) = 3; - - /* - * Send window size change - */ - void - REXPROC_WINCH(rex_ttysize) = 4; - - /* - * Send other signal - */ - void - REXPROC_SIGNAL(int) = 5; - } = 1; -} = 100017; diff --git a/include/rpcsvc/rnusers.x b/include/rpcsvc/rnusers.x deleted file mode 100644 index cce3353d1cc0..000000000000 --- a/include/rpcsvc/rnusers.x +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Find out about remote users - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)rnusers.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: rnusers.x,v 1.5 1993/08/03 21:53:25 mycroft Exp $"; -%#endif /* not lint */ -#endif - -const MAXUSERS = 100; -const MAXUTLEN = 256; - -struct utmp { - string ut_line; - string ut_name; - string ut_host; - int ut_time; -}; - - -struct utmpidle { - utmp ui_utmp; - unsigned int ui_idle; -}; - -typedef utmp utmparr; - -typedef utmpidle utmpidlearr; - -program RUSERSPROG { - /* - * Old version does not include idle information - */ - version RUSERSVERS_ORIG { - int - RUSERSPROC_NUM(void) = 1; - - utmparr - RUSERSPROC_NAMES(void) = 2; - - utmparr - RUSERSPROC_ALLNAMES(void) = 3; - } = 1; - - /* - * Includes idle information - */ - version RUSERSVERS_IDLE { - int - RUSERSPROC_NUM(void) = 1; - - utmpidlearr - RUSERSPROC_NAMES(void) = 2; - - utmpidlearr - RUSERSPROC_ALLNAMES(void) = 3; - } = 2; -} = 100002; - diff --git a/include/rpcsvc/rquota.x b/include/rpcsvc/rquota.x deleted file mode 100644 index 296e8589f447..000000000000 --- a/include/rpcsvc/rquota.x +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Remote quota protocol - * Requires unix authentication - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)rquota.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)rquota.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: rquota.x,v 1.4 1993/08/03 21:53:26 mycroft Exp $"; -%#endif /* not lint */ -#endif - -const RQ_PATHLEN = 1024; - -struct getquota_args { - string gqa_pathp; /* path to filesystem of interest */ - int gqa_uid; /* inquire about quota for uid */ -}; - -/* - * remote quota structure - */ -struct rquota { - int rq_bsize; /* block size for block counts */ - bool rq_active; /* indicates whether quota is active */ - unsigned int rq_bhardlimit; /* absolute limit on disk blks alloc */ - unsigned int rq_bsoftlimit; /* preferred limit on disk blks */ - unsigned int rq_curblocks; /* current block count */ - unsigned int rq_fhardlimit; /* absolute limit on allocated files */ - unsigned int rq_fsoftlimit; /* preferred file limit */ - unsigned int rq_curfiles; /* current # allocated files */ - unsigned int rq_btimeleft; /* time left for excessive disk use */ - unsigned int rq_ftimeleft; /* time left for excessive files */ -}; - -enum gqr_status { - Q_OK = 1, /* quota returned */ - Q_NOQUOTA = 2, /* noquota for uid */ - Q_EPERM = 3 /* no permission to access quota */ -}; - -union getquota_rslt switch (gqr_status status) { -case Q_OK: - rquota gqr_rquota; /* valid if status == Q_OK */ -case Q_NOQUOTA: - void; -case Q_EPERM: - void; -}; - -program RQUOTAPROG { - version RQUOTAVERS { - /* - * Get all quotas - */ - getquota_rslt - RQUOTAPROC_GETQUOTA(getquota_args) = 1; - - /* - * Get active quotas only - */ - getquota_rslt - RQUOTAPROC_GETACTIVEQUOTA(getquota_args) = 2; - } = 1; -} = 100011; diff --git a/include/rpcsvc/rstat.x b/include/rpcsvc/rstat.x deleted file mode 100644 index 8557dd38e4f7..000000000000 --- a/include/rpcsvc/rstat.x +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Gather statistics on remote machines - */ - -#ifdef RPC_HDR - -%#ifndef FSCALE -%/* -% * Scale factor for scaled integers used to count load averages. -% */ -%#define FSHIFT 8 /* bits to right of fixed binary point */ -%#define FSCALE (1<; -}; - -struct my_id { - string my_name; /* name of the site iniates the monitoring request*/ - int my_prog; /* rpc program # of the requesting process */ - int my_vers; /* rpc version # of the requesting process */ - int my_proc; /* rpc procedure # of the requesting process */ -}; - -struct mon_id { - string mon_name; /* name of the site to be monitored */ - struct my_id my_id; -}; - - -struct mon{ - struct mon_id mon_id; - opaque priv[16]; /* private information to store at monitor for requesting process */ -}; - - -/* - * state # of status monitor monitonically increases each time - * status of the site changes: - * an even number (>= 0) indicates the site is down and - * an odd number (> 0) indicates the site is up; - */ -struct sm_stat { - int state; /* state # of status monitor */ -}; - -enum res { - stat_succ = 0, /* status monitor agrees to monitor */ - stat_fail = 1 /* status monitor cannot monitor */ -}; - -struct sm_stat_res { - res res_stat; - int state; -}; - -/* - * structure of the status message sent back by the status monitor - * when monitor site status changes - */ -struct status { - string mon_name; - int state; - opaque priv[16]; /* stored private information */ -}; diff --git a/include/rpcsvc/spray.x b/include/rpcsvc/spray.x deleted file mode 100644 index b20cd325e07b..000000000000 --- a/include/rpcsvc/spray.x +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Spray a server with packets - * Useful for testing flakiness of network interfaces - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)spray.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)spray.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: spray.x,v 1.4 1993/08/03 21:53:31 mycroft Exp $"; -%#endif /* not lint */ -#endif - -const SPRAYMAX = 8845; /* max amount can spray */ - -/* - * GMT since 0:00, 1 January 1970 - */ -struct spraytimeval { - unsigned int sec; - unsigned int usec; -}; - -/* - * spray statistics - */ -struct spraycumul { - unsigned int counter; - spraytimeval clock; -}; - -/* - * spray data - */ -typedef opaque sprayarr; - -program SPRAYPROG { - version SPRAYVERS { - /* - * Just throw away the data and increment the counter - * This call never returns, so the client should always - * time it out. - */ - void - SPRAYPROC_SPRAY(sprayarr) = 1; - - /* - * Get the value of the counter and elapsed time since - * last CLEAR. - */ - spraycumul - SPRAYPROC_GET(void) = 2; - - /* - * Clear the counter and reset the elapsed time - */ - void - SPRAYPROC_CLEAR(void) = 3; - } = 1; -} = 100012; diff --git a/include/rpcsvc/yp.x b/include/rpcsvc/yp.x deleted file mode 100644 index 0aad70546633..000000000000 --- a/include/rpcsvc/yp.x +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Protocol description file for the Yellow Pages Service - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)yp.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: yp.x,v 1.4 1993/08/03 21:53:32 mycroft Exp $"; -%#endif /* not lint */ -#endif - -const YPMAXRECORD = 1024; -const YPMAXDOMAIN = 64; -const YPMAXMAP = 64; -const YPMAXPEER = 64; - - -enum ypstat { - YP_TRUE = 1, - YP_NOMORE = 2, - YP_FALSE = 0, - YP_NOMAP = -1, - YP_NODOM = -2, - YP_NOKEY = -3, - YP_BADOP = -4, - YP_BADDB = -5, - YP_YPERR = -6, - YP_BADARGS = -7, - YP_VERS = -8 -}; - - -enum ypxfrstat { - YPXFR_SUCC = 1, - YPXFR_AGE = 2, - YPXFR_NOMAP = -1, - YPXFR_NODOM = -2, - YPXFR_RSRC = -3, - YPXFR_RPC = -4, - YPXFR_MADDR = -5, - YPXFR_YPERR = -6, - YPXFR_BADARGS = -7, - YPXFR_DBM = -8, - YPXFR_FILE = -9, - YPXFR_SKEW = -10, - YPXFR_CLEAR = -11, - YPXFR_FORCE = -12, - YPXFR_XFRERR = -13, - YPXFR_REFUSED = -14 -}; - - -typedef string domainname; -typedef string mapname; -typedef string peername; -typedef opaque keydat; -typedef opaque valdat; - - -struct ypmap_parms { - domainname domain; - mapname map; - unsigned int ordernum; - peername peer; -}; - -struct ypreq_key { - domainname domain; - mapname map; - keydat key; -}; - -struct ypreq_nokey { - domainname domain; - mapname map; -}; - -struct ypreq_xfr { - ypmap_parms map_parms; - unsigned int transid; - unsigned int prog; - unsigned int port; -}; - - -struct ypresp_val { - ypstat stat; - valdat val; -}; - -struct ypresp_key_val { - ypstat stat; - keydat key; - valdat val; -}; - - -struct ypresp_master { - ypstat stat; - peername peer; -}; - -struct ypresp_order { - ypstat stat; - unsigned int ordernum; -}; - -union ypresp_all switch (bool more) { -case TRUE: - ypresp_key_val val; -case FALSE: - void; -}; - -struct ypresp_xfr { - unsigned int transid; - ypxfrstat xfrstat; -}; - -struct ypmaplist { - mapname map; - ypmaplist *next; -}; - -struct ypresp_maplist { - ypstat stat; - ypmaplist *maps; -}; - -enum yppush_status { - YPPUSH_SUCC = 1, /* Success */ - YPPUSH_AGE = 2, /* Master's version not newer */ - YPPUSH_NOMAP = -1, /* Can't find server for map */ - YPPUSH_NODOM = -2, /* Domain not supported */ - YPPUSH_RSRC = -3, /* Local resource alloc failure */ - YPPUSH_RPC = -4, /* RPC failure talking to server */ - YPPUSH_MADDR = -5, /* Can't get master address */ - YPPUSH_YPERR = -6, /* YP server/map db error */ - YPPUSH_BADARGS = -7, /* Request arguments bad */ - YPPUSH_DBM = -8, /* Local dbm operation failed */ - YPPUSH_FILE = -9, /* Local file I/O operation failed */ - YPPUSH_SKEW = -10, /* Map version skew during transfer */ - YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ - YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */ - YPPUSH_XFRERR = -13, /* ypxfr error */ - YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */ -}; - -struct yppushresp_xfr { - unsigned transid; - yppush_status status; -}; - -/* - * Response structure and overall result status codes. Success and failure - * represent two separate response message types. - */ - -enum ypbind_resptype { - YPBIND_SUCC_VAL = 1, - YPBIND_FAIL_VAL = 2 -}; - -struct ypbind_binding { - opaque ypbind_binding_addr[4]; /* In network order */ - opaque ypbind_binding_port[2]; /* In network order */ -}; - -union ypbind_resp switch (ypbind_resptype ypbind_status) { -case YPBIND_FAIL_VAL: - unsigned ypbind_error; -case YPBIND_SUCC_VAL: - ypbind_binding ypbind_bindinfo; -}; - -/* Detailed failure reason codes for response field ypbind_error*/ - -const YPBIND_ERR_ERR = 1; /* Internal error */ -const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */ -const YPBIND_ERR_RESC = 3; /* System resource allocation failure */ - - -/* - * Request data structure for ypbind "Set domain" procedure. - */ -struct ypbind_setdom { - domainname ypsetdom_domain; - ypbind_binding ypsetdom_binding; - unsigned ypsetdom_vers; -}; - - -/* - * YP access protocol - */ -program YPPROG { - version YPVERS { - void - YPPROC_NULL(void) = 0; - - bool - YPPROC_DOMAIN(domainname) = 1; - - bool - YPPROC_DOMAIN_NONACK(domainname) = 2; - - ypresp_val - YPPROC_MATCH(ypreq_key) = 3; - - ypresp_key_val - YPPROC_FIRST(ypreq_key) = 4; - - ypresp_key_val - YPPROC_NEXT(ypreq_key) = 5; - - ypresp_xfr - YPPROC_XFR(ypreq_xfr) = 6; - - void - YPPROC_CLEAR(void) = 7; - - ypresp_all - YPPROC_ALL(ypreq_nokey) = 8; - - ypresp_master - YPPROC_MASTER(ypreq_nokey) = 9; - - ypresp_order - YPPROC_ORDER(ypreq_nokey) = 10; - - ypresp_maplist - YPPROC_MAPLIST(domainname) = 11; - } = 2; -} = 100004; - - -/* - * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR - */ -program YPPUSH_XFRRESPPROG { - version YPPUSH_XFRRESPVERS { - void - YPPUSHPROC_NULL(void) = 0; - - yppushresp_xfr - YPPUSHPROC_XFRRESP(void) = 1; - } = 1; -} = 0x40000000; /* transient: could be anything up to 0x5fffffff */ - - -/* - * YP binding protocol - */ -program YPBINDPROG { - version YPBINDVERS { - void - YPBINDPROC_NULL(void) = 0; - - ypbind_resp - YPBINDPROC_DOMAIN(domainname) = 1; - - void - YPBINDPROC_SETDOM(ypbind_setdom) = 2; - } = 2; -} = 100007; - - diff --git a/include/rpcsvc/yppasswd.x b/include/rpcsvc/yppasswd.x deleted file mode 100644 index 03d6701daa8e..000000000000 --- a/include/rpcsvc/yppasswd.x +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * YP password update protocol - * Requires unix authentication - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)yppasswd.x 1.1 87/04/13 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)yppasswd.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: yppasswd.x,v 1.5 1993/08/03 21:53:34 mycroft Exp $"; -%#endif /* not lint */ -#endif - -program YPPASSWDPROG { - version YPPASSWDVERS { - /* - * Update my passwd entry - */ - int - YPPASSWDPROC_UPDATE(yppasswd) = 1; - } = 1; -} = 100009; - - -struct x_passwd { - string pw_name<>; /* username */ - string pw_passwd<>; /* encrypted password */ - int pw_uid; /* user id */ - int pw_gid; /* group id */ - string pw_gecos<>; /* in real life name */ - string pw_dir<>; /* home directory */ - string pw_shell<>; /* default shell */ -}; - -struct yppasswd { - string oldpass<>; /* unencrypted old password */ - x_passwd newpw; /* new passwd entry */ -}; - - diff --git a/lib/csu/mips/crt0.s b/lib/csu/mips/crt0.s deleted file mode 100644 index 96b08804cf91..000000000000 --- a/lib/csu/mips/crt0.s +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)crt0.s 8.2 (Berkeley) 3/21/94 - * $Id: crt0.s,v 1.3 1994/12/15 17:04:55 mycroft Exp $ - */ - -#include -#include - - .data - .comm _C_LABEL(environ), 4 - .align 2 - .globl _C_LABEL(__progname) -_C_LABEL(__progname): - .word $L1 -$L1: - .word 0 # null string plus padding - .text - -NON_LEAF(start, 24, ra) - .set noreorder - lw s0, 0(sp) # get argc from stack - addu s1, sp, 4 # get pointer to argv - addu s2, s1, 4 # skip null pointer on stack - sll v0, s0, 2 # add number of argv pointers - addu s2, s2, v0 # final pointer to environment list - sw s2, _C_LABEL(environ) # save environment pointer - subu sp, sp, 24 # allocate standard frame - .mask 0x80000000, -4 - sw zero, 20(sp) # clear return address for debugging -#ifdef MCRT0 -eprol: - la a0, eprol - la a1, etext - jal _C_LABEL(monstartup) # monstartup(eprol, etext); - nop - la a0, _C_LABEL(mcleanup) - jal _C_LABEL(atexit) # atexit(mcleanup); - nop - sw zero, _C_LABEL(errno) -#endif - lw a0, 0(s1) # a0 = argv[0]; - nop - beq a0, zero, 2f # skip if a0 == NULL - move s3, a0 # save argv[0] - jal _C_LABEL(strrchr) - li a1, 0x2f # a1 = '/' - bne v0, zero, 1f # if slash found - addu v0, v0, 1 - move v0, s3 # v0 = argv[0]; -1: - sw v0, _C_LABEL(__progname) -2: - move a0, s0 - move a1, s1 - jal _C_LABEL(main) # v0 = main(argc, argv, env); - move a2, s2 - jal _C_LABEL(exit) # exit(v0); - move a0, v0 - break 0 - .set reorder -END(start) - -#ifndef MCRT0 -LEAF(moncontrol) - j ra -END(moncontrol) - -LEAF(_mcount) - .set noreorder - .set noat - addu sp, sp, 8 # undo push - j ra - move ra, AT - .set at - .set reorder -END(_mcount) -#endif diff --git a/lib/libc/DB/btree/bt_get.c b/lib/libc/DB/btree/bt_get.c deleted file mode 100644 index 8db29f3c8807..000000000000 --- a/lib/libc/DB/btree/bt_get.c +++ /dev/null @@ -1,222 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_get.c 5.9 (Berkeley) 5/16/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * __BT_GET -- Get a record from the btree. - * - * Parameters: - * dbp: pointer to access method - * key: key to find - * data: data to return - * flag: currently unused - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__bt_get(dbp, key, data, flags) - const DB *dbp; - const DBT *key; - DBT *data; - u_int flags; -{ - BTREE *t; - EPG *e; - int exact, status; - - if (flags) { - errno = EINVAL; - return (RET_ERROR); - } - t = dbp->internal; - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - if (!exact) { - mpool_put(t->bt_mp, e->page, 0); - return (RET_SPECIAL); - } - - /* - * A special case is if we found the record but it's flagged for - * deletion. In this case, we want to find another record with the - * same key, if it exists. Rather than look around the tree we call - * __bt_first and have it redo the search, as __bt_first will not - * return keys marked for deletion. Slow, but should never happen. - */ - if (ISSET(t, B_DELCRSR) && e->page->pgno == t->bt_bcursor.pgno && - e->index == t->bt_bcursor.index) { - mpool_put(t->bt_mp, e->page, 0); - if ((e = __bt_first(t, key, &exact)) == NULL) - return (RET_ERROR); - if (!exact) - return (RET_SPECIAL); - } - - status = __bt_ret(t, e, NULL, data); - mpool_put(t->bt_mp, e->page, 0); - return (status); -} - -/* - * __BT_FIRST -- Find the first entry. - * - * Parameters: - * t: the tree - * key: the key - * - * Returns: - * The first entry in the tree greater than or equal to key. - */ -EPG * -__bt_first(t, key, exactp) - BTREE *t; - const DBT *key; - int *exactp; -{ - register PAGE *h; - register EPG *e; - EPG save; - pgno_t cpgno, pg; - indx_t cindex; - int found; - - /* - * Find any matching record; __bt_search pins the page. Only exact - * matches are tricky, otherwise just return the location of the key - * if it were to be inserted into the tree. - */ - if ((e = __bt_search(t, key, exactp)) == NULL) - return (NULL); - if (!*exactp) - return (e); - - if (ISSET(t, B_DELCRSR)) { - cpgno = t->bt_bcursor.pgno; - cindex = t->bt_bcursor.index; - } else { - cpgno = P_INVALID; - cindex = 0; /* GCC thinks it's uninitialized. */ - } - - /* - * Walk backwards, skipping empty pages, as long as the entry matches - * and there are keys left in the tree. Save a copy of each match in - * case we go too far. A special case is that we don't return a match - * on records that the cursor references that have already been flagged - * for deletion. - */ - save = *e; - h = e->page; - found = 0; - do { - if (cpgno != h->pgno || cindex != e->index) { - if (save.page->pgno != e->page->pgno) { - mpool_put(t->bt_mp, save.page, 0); - save = *e; - } else - save.index = e->index; - found = 1; - } - /* - * Make a special effort not to unpin the page the last (or - * original) match was on, but also make sure it's unpinned - * if an error occurs. - */ - while (e->index == 0) { - if (h->prevpg == P_INVALID) - goto done1; - if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) { - if (h->pgno == save.page->pgno) - mpool_put(t->bt_mp, save.page, 0); - return (NULL); - } - e->page = h; - e->index = NEXTINDEX(h); - } - --e->index; - } while (__bt_cmp(t, key, e) == 0); - - /* - * Reach here with the last page that was looked at pinned, which may - * or may not be the same as the last (or original) match page. If - * it's not useful, release it. - */ -done1: if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, 0); - - /* - * If still haven't found a record, the only possibility left is the - * next one. Move forward one slot, skipping empty pages and check. - */ - if (!found) { - h = save.page; - if (++save.index == NEXTINDEX(h)) { - do { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) { - *exactp = 0; - return (e); - } - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (NULL); - } while ((save.index = NEXTINDEX(h)) == 0); - save.page = h; - } - if (__bt_cmp(t, key, &save) != 0) { - *exactp = 0; - return (e); - } - } - *e = save; - *exactp = 1; - return (e); -} diff --git a/lib/libc/DB/btree/bt_open.c b/lib/libc/DB/btree/bt_open.c deleted file mode 100644 index e8587d24444b..000000000000 --- a/lib/libc/DB/btree/bt_open.c +++ /dev/null @@ -1,428 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_open.c 5.31 (Berkeley) 5/24/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Implementation of btree access method for 4.4BSD. - * - * The design here was originally based on that of the btree access method - * used in the Postgres database system at UC Berkeley. This implementation - * is wholly independent of the Postgres code. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#define __DBINTERFACE_PRIVATE -#include -#include "btree.h" - -static int byteorder __P((void)); -static int nroot __P((BTREE *)); -static int tmp __P((void)); - -/* - * __BT_OPEN -- Open a btree. - * - * Creates and fills a DB struct, and calls the routine that actually - * opens the btree. - * - * Parameters: - * fname: filename (NULL for in-memory trees) - * flags: open flag bits - * mode: open permission bits - * b: BTREEINFO pointer - * - * Returns: - * NULL on failure, pointer to DB on success. - * - */ -DB * -__bt_open(fname, flags, mode, openinfo) - const char *fname; - int flags, mode; - const BTREEINFO *openinfo; -{ - BTMETA m; - BTREE *t; - BTREEINFO b; - DB *dbp; - pgno_t ncache; - struct stat sb; - int machine_lorder, nr; - - t = NULL; - - /* - * Intention is to make sure all of the user's selections are okay - * here and then use them without checking. Can't be complete, since - * we don't know the right page size, lorder or flags until the backing - * file is opened. Also, the file's page size can cause the cachesize - * to change. - */ - machine_lorder = byteorder(); - if (openinfo) { - b = *openinfo; - - /* Flags: R_DUP. */ - if (b.flags & ~(R_DUP)) - goto einval; - - /* - * Page size must be indx_t aligned and >= MINPSIZE. Default - * page size is set farther on, based on the underlying file - * transfer size. - */ - if (b.psize && - (b.psize < MINPSIZE || b.psize > MAX_PAGE_OFFSET + 1 || - b.psize & sizeof(indx_t) - 1)) - goto einval; - - /* Minimum number of keys per page; absolute minimum is 2. */ - if (b.minkeypage) { - if (b.minkeypage < 2) - goto einval; - } else - b.minkeypage = DEFMINKEYPAGE; - - /* If no comparison, use default comparison and prefix. */ - if (b.compare == NULL) { - b.compare = __bt_defcmp; - if (b.prefix == NULL) - b.prefix = __bt_defpfx; - } - - if (b.lorder == 0) - b.lorder = machine_lorder; - } else { - b.compare = __bt_defcmp; - b.cachesize = 0; - b.flags = 0; - b.lorder = machine_lorder; - b.minkeypage = DEFMINKEYPAGE; - b.prefix = __bt_defpfx; - b.psize = 0; - } - - /* Check for the ubiquitous PDP-11. */ - if (b.lorder != BIG_ENDIAN && b.lorder != LITTLE_ENDIAN) - goto einval; - - /* Allocate and initialize DB and BTREE structures. */ - if ((t = malloc(sizeof(BTREE))) == NULL) - goto err; - t->bt_fd = -1; /* Don't close unopened fd on error. */ - if ((t->bt_dbp = dbp = malloc(sizeof(DB))) == NULL) - goto err; - t->bt_bcursor.pgno = P_INVALID; - t->bt_bcursor.index = 0; - t->bt_stack = NULL; - t->bt_sp = t->bt_maxstack = 0; - t->bt_kbuf = t->bt_dbuf = NULL; - t->bt_kbufsz = t->bt_dbufsz = 0; - t->bt_lorder = b.lorder; - t->bt_order = NOT; - t->bt_cmp = b.compare; - t->bt_pfx = b.prefix; - t->bt_flags = 0; - if (t->bt_lorder != machine_lorder) - SET(t, B_NEEDSWAP); - - dbp->type = DB_BTREE; - dbp->internal = t; - dbp->close = __bt_close; - dbp->del = __bt_delete; - dbp->fd = __bt_fd; - dbp->get = __bt_get; - dbp->put = __bt_put; - dbp->seq = __bt_seq; - dbp->sync = __bt_sync; - - /* - * If no file name was supplied, this is an in-memory btree and we - * open a backing temporary file. Otherwise, it's a disk-based tree. - */ - if (fname) { - switch(flags & O_ACCMODE) { - case O_RDONLY: - SET(t, B_RDONLY); - break; - case O_RDWR: - break; - case O_WRONLY: - default: - goto einval; - } - - if ((t->bt_fd = - open(fname, flags & __USE_OPEN_FLAGS, mode)) < 0) - goto err; - - } else { - if ((flags & O_ACCMODE) != O_RDWR) - goto einval; - if ((t->bt_fd = tmp()) == -1) - goto err; - SET(t, B_INMEM); - } - - if (fcntl(t->bt_fd, F_SETFD, 1) == -1) - goto err; - - if (fstat(t->bt_fd, &sb)) - goto err; - if (sb.st_size) { - nr = read(t->bt_fd, &m, sizeof(BTMETA)); - if (nr < 0) - goto err; - if (nr != sizeof(BTMETA)) - goto eftype; - - /* - * Read in the meta-data. This can change the notion of what - * the lorder, page size and flags are, and, when the page size - * changes, the cachesize value can change too. If the user - * specified the wrong byte order for an existing database, we - * don't bother to return an error, we just clear the NEEDSWAP - * bit. - */ - if (m.m_magic == BTREEMAGIC) - CLR(t, B_NEEDSWAP); - else { - SET(t, B_NEEDSWAP); - BLSWAP(m.m_magic); - BLSWAP(m.m_version); - BLSWAP(m.m_psize); - BLSWAP(m.m_free); - BLSWAP(m.m_nrecs); - BLSWAP(m.m_flags); - } - if (m.m_magic != BTREEMAGIC || m.m_version != BTREEVERSION) - goto eftype; - if (m.m_psize < MINPSIZE || m.m_psize > MAX_PAGE_OFFSET + 1 || - m.m_psize & sizeof(indx_t) - 1) - goto eftype; - if (m.m_flags & ~SAVEMETA) - goto eftype; - b.psize = m.m_psize; - t->bt_flags |= m.m_flags; - t->bt_free = m.m_free; - t->bt_nrecs = m.m_nrecs; - } else { - /* - * Set the page size to the best value for I/O to this file. - * Don't overflow the page offset type. - */ - if (b.psize == 0) { - b.psize = sb.st_blksize; - if (b.psize < MINPSIZE) - b.psize = MINPSIZE; - if (b.psize > MAX_PAGE_OFFSET + 1) - b.psize = MAX_PAGE_OFFSET + 1; - } - - /* Set flag if duplicates permitted. */ - if (!(b.flags & R_DUP)) - SET(t, B_NODUPS); - - t->bt_free = P_INVALID; - t->bt_nrecs = 0; - SET(t, B_METADIRTY); - } - - t->bt_psize = b.psize; - - /* Set the cache size; must be a multiple of the page size. */ - if (b.cachesize && b.cachesize & b.psize - 1) - b.cachesize += (~b.cachesize & b.psize - 1) + 1; - if (b.cachesize < b.psize * MINCACHE) - b.cachesize = b.psize * MINCACHE; - - /* Calculate number of pages to cache. */ - ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize; - - /* - * The btree data structure requires that at least two keys can fit on - * a page, but other than that there's no fixed requirement. The user - * specified a minimum number per page, and we translated that into the - * number of bytes a key/data pair can use before being placed on an - * overflow page. This calculation includes the page header, the size - * of the index referencing the leaf item and the size of the leaf item - * structure. Also, don't let the user specify a minkeypage such that - * a key/data pair won't fit even if both key and data are on overflow - * pages. - */ - t->bt_ovflsize = (t->bt_psize - BTDATAOFF) / b.minkeypage - - (sizeof(indx_t) + NBLEAFDBT(0, 0)); - if (t->bt_ovflsize < NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t)) - t->bt_ovflsize = - NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t); - - /* Initialize the buffer pool. */ - if ((t->bt_mp = - mpool_open(NULL, t->bt_fd, t->bt_psize, ncache)) == NULL) - goto err; - if (!ISSET(t, B_INMEM)) - mpool_filter(t->bt_mp, __bt_pgin, __bt_pgout, t); - - /* Create a root page if new tree. */ - if (nroot(t) == RET_ERROR) - goto err; - - return (dbp); - -einval: errno = EINVAL; - goto err; - -eftype: errno = EFTYPE; - goto err; - -err: if (t) { - if (t->bt_dbp) - free(t->bt_dbp); - if (t->bt_fd != -1) - (void)close(t->bt_fd); - free(t); - } - return (NULL); -} - -/* - * NROOT -- Create the root of a new tree. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -nroot(t) - BTREE *t; -{ - PAGE *meta, *root; - pgno_t npg; - - if ((meta = mpool_get(t->bt_mp, 0, 0)) != NULL) { - mpool_put(t->bt_mp, meta, 0); - return (RET_SUCCESS); - } - if (errno != EINVAL) - return (RET_ERROR); - - if ((meta = mpool_new(t->bt_mp, &npg)) == NULL) - return (RET_ERROR); - - if ((root = mpool_new(t->bt_mp, &npg)) == NULL) - return (RET_ERROR); - - if (npg != P_ROOT) - return (RET_ERROR); - root->pgno = npg; - root->prevpg = root->nextpg = P_INVALID; - root->lower = BTDATAOFF; - root->upper = t->bt_psize; - root->flags = P_BLEAF; - memset(meta, 0, t->bt_psize); - mpool_put(t->bt_mp, meta, MPOOL_DIRTY); - mpool_put(t->bt_mp, root, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -static int -tmp() -{ - sigset_t set, oset; - int fd; - char *envtmp; - char path[MAXPATHLEN]; - - envtmp = getenv("TMPDIR"); - (void)snprintf(path, - sizeof(path), "%s/bt.XXXXXX", envtmp ? envtmp : "/tmp"); - - (void)sigfillset(&set); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - if ((fd = mkstemp(path)) != -1) - (void)unlink(path); - (void)sigprocmask(SIG_SETMASK, &oset, NULL); - return(fd); -} - -static int -byteorder() -{ - u_long x; /* XXX: 32-bit assumption. */ - u_char *p; - - x = 0x01020304; - p = (u_char *)&x; - switch (*p) { - case 1: - return (BIG_ENDIAN); - case 4: - return (LITTLE_ENDIAN); - default: - return (0); - } -} - -int -__bt_fd(dbp) - const DB *dbp; -{ - BTREE *t; - - t = dbp->internal; - - if (ISSET(t, B_INMEM)) { - errno = ENOENT; - return (-1); - } - return (t->bt_fd); -} diff --git a/lib/libc/DB/btree/bt_overflow.c b/lib/libc/DB/btree/bt_overflow.c deleted file mode 100644 index f6b8da1821cc..000000000000 --- a/lib/libc/DB/btree/bt_overflow.c +++ /dev/null @@ -1,224 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_overflow.c 5.8 (Berkeley) 2/16/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * Big key/data code. - * - * Big key and data entries are stored on linked lists of pages. The initial - * reference is byte string stored with the key or data and is the page number - * and size. The actual record is stored in a chain of pages linked by the - * nextpg field of the PAGE header. - * - * The first page of the chain has a special property. If the record is used - * by an internal page, it cannot be deleted and the P_PRESERVE bit will be set - * in the header. - * - * XXX - * A single DBT is written to each chain, so a lot of space on the last page - * is wasted. This is a fairly major bug for some data sets. - */ - -/* - * __OVFL_GET -- Get an overflow key/data item. - * - * Parameters: - * t: tree - * p: pointer to { pgno_t, size_t } - * buf: storage address - * bufsz: storage size - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_get(t, p, ssz, buf, bufsz) - BTREE *t; - void *p; - size_t *ssz; - char **buf; - size_t *bufsz; -{ - PAGE *h; - pgno_t pg; - size_t nb, plen, sz; - - memmove(&pg, p, sizeof(pgno_t)); - memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(size_t)); - *ssz = sz; - -#ifdef DEBUG - if (pg == P_INVALID || sz == 0) - abort(); -#endif - /* Make the buffer bigger as necessary. */ - if (*bufsz < sz) { - if ((*buf = realloc(*buf, sz)) == NULL) - return (RET_ERROR); - *bufsz = sz; - } - - /* - * Step through the linked list of pages, copying the data on each one - * into the buffer. Never copy more than the data's length. - */ - plen = t->bt_psize - BTDATAOFF; - for (p = *buf;; p = (char *)p + nb, pg = h->nextpg) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - nb = MIN(sz, plen); - memmove(p, (char *)h + BTDATAOFF, nb); - mpool_put(t->bt_mp, h, 0); - - if ((sz -= nb) == 0) - break; - } - return (RET_SUCCESS); -} - -/* - * __OVFL_PUT -- Store an overflow key/data item. - * - * Parameters: - * t: tree - * data: DBT to store - * pgno: storage page number - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_put(t, dbt, pg) - BTREE *t; - const DBT *dbt; - pgno_t *pg; -{ - PAGE *h, *last; - void *p; - pgno_t npg; - size_t nb, plen, sz; - - /* - * Allocate pages and copy the key/data record into them. Store the - * number of the first page in the chain. - */ - plen = t->bt_psize - BTDATAOFF; - for (last = NULL, p = dbt->data, sz = dbt->size;; - p = (char *)p + plen, last = h) { - if ((h = __bt_new(t, &npg)) == NULL) - return (RET_ERROR); - - h->pgno = npg; - h->nextpg = h->prevpg = P_INVALID; - h->flags = P_OVERFLOW; - h->lower = h->upper = 0; - - nb = MIN(sz, plen); - memmove((char *)h + BTDATAOFF, p, nb); - - if (last) { - last->nextpg = h->pgno; - mpool_put(t->bt_mp, last, MPOOL_DIRTY); - } else - *pg = h->pgno; - - if ((sz -= nb) == 0) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - } - } - return (RET_SUCCESS); -} - -/* - * __OVFL_DELETE -- Delete an overflow chain. - * - * Parameters: - * t: tree - * p: pointer to { pgno_t, size_t } - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_delete(t, p) - BTREE *t; - void *p; -{ - PAGE *h; - pgno_t pg; - size_t plen, sz; - - memmove(&pg, p, sizeof(pgno_t)); - memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(size_t)); - -#ifdef DEBUG - if (pg == P_INVALID || sz == 0) - abort(); -#endif - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Don't delete chains used by internal pages. */ - if (h->flags & P_PRESERVE) { - mpool_put(t->bt_mp, h, 0); - return (RET_SUCCESS); - } - - /* Step through the chain, calling the free routine for each page. */ - for (plen = t->bt_psize - BTDATAOFF;; sz -= plen) { - pg = h->nextpg; - __bt_free(t, h); - if (sz <= plen) - break; - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } - return (RET_SUCCESS); -} diff --git a/lib/libc/DB/btree/bt_page.c b/lib/libc/DB/btree/bt_page.c deleted file mode 100644 index bd2400b92163..000000000000 --- a/lib/libc/DB/btree/bt_page.c +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_page.c 5.3 (Berkeley) 2/11/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#define __DBINTERFACE_PRIVATE -#include - -#include -#include "btree.h" - -/* - * __BT_FREE -- Put a page on the freelist. - * - * Parameters: - * t: tree - * h: page to free - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_free(t, h) - BTREE *t; - PAGE *h; -{ - /* Insert the page at the start of the free list. */ - h->prevpg = P_INVALID; - h->nextpg = t->bt_free; - t->bt_free = h->pgno; - - /* Make sure the page gets written back. */ - return (mpool_put(t->bt_mp, h, MPOOL_DIRTY)); -} - -/* - * __BT_NEW -- Get a new page, preferably from the freelist. - * - * Parameters: - * t: tree - * npg: storage for page number. - * - * Returns: - * Pointer to a page, NULL on error. - */ -PAGE * -__bt_new(t, npg) - BTREE *t; - pgno_t *npg; -{ - PAGE *h; - - if (t->bt_free != P_INVALID && - (h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) { - *npg = t->bt_free; - t->bt_free = h->nextpg; - return (h); - } - return (mpool_new(t->bt_mp, npg)); -} diff --git a/lib/libc/DB/btree/bt_put.c b/lib/libc/DB/btree/bt_put.c deleted file mode 100644 index 08707422d2a6..000000000000 --- a/lib/libc/DB/btree/bt_put.c +++ /dev/null @@ -1,313 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_put.c 5.15 (Berkeley) 5/16/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static EPG *bt_fast __P((BTREE *, const DBT *, const DBT *, int *)); - -/* - * __BT_PUT -- Add a btree item to the tree. - * - * Parameters: - * dbp: pointer to access method - * key: key - * data: data - * flag: R_NOOVERWRITE - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is already in the - * tree and R_NOOVERWRITE specified. - */ -int -__bt_put(dbp, key, data, flags) - const DB *dbp; - DBT *key; - const DBT *data; - u_int flags; -{ - BTREE *t; - DBT tkey, tdata; - EPG *e; - PAGE *h; - indx_t index, nxtindex; - pgno_t pg; - size_t nbytes; - int dflags, exact, status; - char *dest, db[NOVFLSIZE], kb[NOVFLSIZE]; - - t = dbp->internal; - - switch (flags) { - case R_CURSOR: - if (!ISSET(t, B_SEQINIT)) - goto einval; - if (ISSET(t, B_DELCRSR)) - goto einval; - break; - case 0: - case R_NOOVERWRITE: - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - if (ISSET(t, B_RDONLY)) { - errno = EPERM; - return (RET_ERROR); - } - - /* - * If the key/data won't fit on a page, store it on indirect pages. - * Only store the key on the overflow page if it's too big after the - * data is on an overflow page. - * - * XXX - * If the insert fails later on, these pages aren't recovered. - */ - dflags = 0; - if (key->size + data->size > t->bt_ovflsize) { - if (key->size > t->bt_ovflsize) { -storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR) - return (RET_ERROR); - tkey.data = kb; - tkey.size = NOVFLSIZE; - memmove(kb, &pg, sizeof(pgno_t)); - memmove(kb + sizeof(pgno_t), - &key->size, sizeof(size_t)); - dflags |= P_BIGKEY; - key = &tkey; - } - if (key->size + data->size > t->bt_ovflsize) { - if (__ovfl_put(t, data, &pg) == RET_ERROR) - return (RET_ERROR); - tdata.data = db; - tdata.size = NOVFLSIZE; - memmove(db, &pg, sizeof(pgno_t)); - memmove(db + sizeof(pgno_t), - &data->size, sizeof(size_t)); - dflags |= P_BIGDATA; - data = &tdata; - } - if (key->size + data->size > t->bt_ovflsize) - goto storekey; - } - - /* Replace the cursor. */ - if (flags == R_CURSOR) { - if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL) - return (RET_ERROR); - index = t->bt_bcursor.index; - goto delete; - } - - /* - * Find the key to delete, or, the location at which to insert. Bt_fast - * and __bt_search pin the returned page. - */ - if (t->bt_order == NOT || (e = bt_fast(t, key, data, &exact)) == NULL) - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - h = e->page; - index = e->index; - - /* - * Add the specified key/data pair to the tree. If an identical key - * is already in the tree, and R_NOOVERWRITE is set, an error is - * returned. If R_NOOVERWRITE is not set, the key is either added (if - * duplicates are permitted) or an error is returned. - * - * Pages are split as required. - */ - switch (flags) { - case R_NOOVERWRITE: - if (!exact) - break; - /* - * One special case is if the cursor references the record and - * it's been flagged for deletion. Then, we delete the record, - * leaving the cursor there -- this means that the inserted - * record will not be seen in a cursor scan. - */ - if (ISSET(t, B_DELCRSR) && t->bt_bcursor.pgno == h->pgno && - t->bt_bcursor.index == index) { - CLR(t, B_DELCRSR); - goto delete; - } - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - default: - if (!exact || !ISSET(t, B_NODUPS)) - break; -delete: if (__bt_dleaf(t, h, index) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - break; - } - - /* - * If not enough room, or the user has put a ceiling on the number of - * keys permitted in the page, split the page. The split code will - * insert the key and data and unpin the current page. If inserting - * into the offset array, shift the pointers up. - */ - nbytes = NBLEAFDBT(key->size, data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - if ((status = __bt_split(t, h, key, - data, dflags, nbytes, index)) != RET_SUCCESS) - return (status); - goto success; - } - - if (index < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + index + 1, h->linp + index, - (nxtindex - index) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - - h->linp[index] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_BLEAF(dest, key, data, dflags); - - if (t->bt_order == NOT) - if (h->nextpg == P_INVALID) { - if (index == NEXTINDEX(h) - 1) { - t->bt_order = FORWARD; - t->bt_last.index = index; - t->bt_last.pgno = h->pgno; - } - } else if (h->prevpg == P_INVALID) { - if (index == 0) { - t->bt_order = BACK; - t->bt_last.index = 0; - t->bt_last.pgno = h->pgno; - } - } - - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - -success: - if (flags == R_SETCURSOR) { - t->bt_bcursor.pgno = e->page->pgno; - t->bt_bcursor.index = e->index; - } - SET(t, B_MODIFIED); - return (RET_SUCCESS); -} - -#ifdef STATISTICS -u_long bt_cache_hit, bt_cache_miss; -#endif - -/* - * BT_FAST -- Do a quick check for sorted data. - * - * Parameters: - * t: tree - * key: key to insert - * - * Returns: - * EPG for new record or NULL if not found. - */ -static EPG * -bt_fast(t, key, data, exactp) - BTREE *t; - const DBT *key, *data; - int *exactp; -{ - EPG e; - PAGE *h; - size_t nbytes; - int cmp; - - if ((h = mpool_get(t->bt_mp, t->bt_last.pgno, 0)) == NULL) { - t->bt_order = NOT; - return (NULL); - } - e.page = h; - e.index = t->bt_last.index; - - /* - * If won't fit in this page or have too many keys in this page, have - * to search to get split stack. - */ - nbytes = NBLEAFDBT(key->size, data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) - goto miss; - - if (t->bt_order == FORWARD) { - if (e.page->nextpg != P_INVALID) - goto miss; - if (e.index != NEXTINDEX(h) - 1) - goto miss; - if ((cmp = __bt_cmp(t, key, &e)) < 0) - goto miss; - t->bt_last.index = cmp ? ++e.index : e.index; - } else { - if (e.page->prevpg != P_INVALID) - goto miss; - if (e.index != 0) - goto miss; - if ((cmp = __bt_cmp(t, key, &e)) > 0) - goto miss; - t->bt_last.index = 0; - } - *exactp = cmp == 0; -#ifdef STATISTICS - ++bt_cache_hit; -#endif - return (&e); - -miss: -#ifdef STATISTICS - ++bt_cache_miss; -#endif - t->bt_order = NOT; - mpool_put(t->bt_mp, h, 0); - return (NULL); -} diff --git a/lib/libc/DB/btree/bt_search.c b/lib/libc/DB/btree/bt_search.c deleted file mode 100644 index 3f2540fc08a0..000000000000 --- a/lib/libc/DB/btree/bt_search.c +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_search.c 5.9 (Berkeley) 2/14/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include - -#include -#include "btree.h" - -/* - * __BT_SEARCH -- Search a btree for a key. - * - * Parameters: - * t: tree to search - * key: key to find - * exactp: pointer to exact match flag - * - * Returns: - * EPG for matching record, if any, or the EPG for the location of the - * key, if it were inserted into the tree. - * - * Warnings: - * The EPG returned is in static memory, and will be overwritten by the - * next search of any kind in any tree. - */ -EPG * -__bt_search(t, key, exactp) - BTREE *t; - const DBT *key; - int *exactp; -{ - register indx_t index; - register int base, cmp, lim; - register PAGE *h; - pgno_t pg; - static EPG e; - - BT_CLR(t); - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (NULL); - - /* Do a binary search on the current page. */ - e.page = h; - for (base = 0, lim = NEXTINDEX(h); lim; lim >>= 1) { - e.index = index = base + (lim >> 1); - if ((cmp = __bt_cmp(t, key, &e)) == 0) { - if (h->flags & P_BLEAF) { - *exactp = 1; - return (&e); - } - goto next; - } - if (cmp > 0) { - base = index + 1; - --lim; - } - } - - /* If it's a leaf page, we're done. */ - if (h->flags & P_BLEAF) { - e.index = base; - *exactp = 0; - return (&e); - } - - /* - * No match found. Base is the smallest index greater than - * key and may be zero or a last + 1 index. If it's non-zero, - * decrement by one, and record the internal page which should - * be a parent page for the key. If a split later occurs, the - * inserted page will be to the right of the saved page. - */ - index = base ? base - 1 : base; - -next: if (__bt_push(t, h->pgno, index) == RET_ERROR) - return (NULL); - pg = GETBINTERNAL(h, index)->pgno; - mpool_put(t->bt_mp, h, 0); - } -} diff --git a/lib/libc/DB/btree/bt_seq.c b/lib/libc/DB/btree/bt_seq.c deleted file mode 100644 index 0420ccee653a..000000000000 --- a/lib/libc/DB/btree/bt_seq.c +++ /dev/null @@ -1,365 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_seq.c 5.10 (Berkeley) 5/16/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_seqadv __P((BTREE *, EPG *, int)); -static int bt_seqset __P((BTREE *, EPG *, DBT *, int)); - -/* - * Sequential scan support. - * - * The tree can be scanned sequentially, starting from either end of the tree - * or from any specific key. A scan request before any scanning is done is - * initialized as starting from the least node. - * - * Each tree has an EPGNO which has the current position of the cursor. The - * cursor has to survive deletions/insertions in the tree without losing its - * position. This is done by noting deletions without doing them, and then - * doing them when the cursor moves (or the tree is closed). - */ - -/* - * __BT_SEQ -- Btree sequential scan interface. - * - * Parameters: - * dbp: pointer to access method - * key: key for positioning and return value - * data: data return value - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -int -__bt_seq(dbp, key, data, flags) - const DB *dbp; - DBT *key, *data; - u_int flags; -{ - BTREE *t; - EPG e; - int status; - - /* - * If scan unitialized as yet, or starting at a specific record, set - * the scan to a specific key. Both bt_seqset and bt_seqadv pin the - * page the cursor references if they're successful. - */ - t = dbp->internal; - switch(flags) { - case R_NEXT: - case R_PREV: - if (ISSET(t, B_SEQINIT)) { - status = bt_seqadv(t, &e, flags); - break; - } - /* FALLTHROUGH */ - case R_CURSOR: - case R_FIRST: - case R_LAST: - status = bt_seqset(t, &e, key, flags); - break; - default: - errno = EINVAL; - return (RET_ERROR); - } - - if (status == RET_SUCCESS) { - status = __bt_ret(t, &e, key, data); - - /* Update the actual cursor. */ - t->bt_bcursor.pgno = e.page->pgno; - t->bt_bcursor.index = e.index; - mpool_put(t->bt_mp, e.page, 0); - SET(t, B_SEQINIT); - } - return (status); -} - -/* - * BT_SEQSET -- Set the sequential scan to a specific key. - * - * Parameters: - * t: tree - * ep: storage for returned key - * key: key for initial scan position - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV - * - * Side effects: - * Pins the page the cursor references. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -static int -bt_seqset(t, ep, key, flags) - BTREE *t; - EPG *ep; - DBT *key; - int flags; -{ - EPG *e; - PAGE *h; - pgno_t pg; - int exact; - - /* - * Delete any already deleted record that we've been saving because - * the cursor pointed to it. Since going to a specific key, should - * delete any logically deleted records so they aren't found. - */ - if (ISSET(t, B_DELCRSR) && __bt_crsrdel(t, &t->bt_bcursor)) - return (RET_ERROR); - - /* - * Find the first, last or specific key in the tree and point the cursor - * at it. The cursor may not be moved until a new key has been found. - */ - switch(flags) { - case R_CURSOR: /* Keyed scan. */ - /* - * Find the first instance of the key or the smallest key which - * is greater than or equal to the specified key. If run out - * of keys, return RET_SPECIAL. - */ - if (key->data == NULL || key->size == 0) { - errno = EINVAL; - return (RET_ERROR); - } - e = __bt_first(t, key, &exact); /* Returns pinned page. */ - if (e == NULL) - return (RET_ERROR); - /* - * If at the end of a page, skip any empty pages and find the - * next entry. - */ - if (e->index == NEXTINDEX(e->page)) { - h = e->page; - do { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } while (NEXTINDEX(h) == 0); - e->index = 0; - e->page = h; - } - *ep = *e; - break; - case R_FIRST: /* First record. */ - case R_NEXT: - /* Walk down the left-hand side of the tree. */ - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - if (h->flags & (P_BLEAF | P_RLEAF)) - break; - pg = GETBINTERNAL(h, 0)->pgno; - mpool_put(t->bt_mp, h, 0); - } - - /* Skip any empty pages. */ - while (NEXTINDEX(h) == 0 && h->nextpg != P_INVALID) { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } - - if (NEXTINDEX(h) == 0) { - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - } - - ep->page = h; - ep->index = 0; - break; - case R_LAST: /* Last record. */ - case R_PREV: - /* Walk down the right-hand side of the tree. */ - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - if (h->flags & (P_BLEAF | P_RLEAF)) - break; - pg = GETBINTERNAL(h, NEXTINDEX(h) - 1)->pgno; - mpool_put(t->bt_mp, h, 0); - } - - /* Skip any empty pages. */ - while (NEXTINDEX(h) == 0 && h->prevpg != P_INVALID) { - pg = h->prevpg; - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } - - if (NEXTINDEX(h) == 0) { - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - } - - ep->page = h; - ep->index = NEXTINDEX(h) - 1; - break; - } - return (RET_SUCCESS); -} - -/* - * BT_SEQADVANCE -- Advance the sequential scan. - * - * Parameters: - * t: tree - * flags: R_NEXT, R_PREV - * - * Side effects: - * Pins the page the new key/data record is on. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -static int -bt_seqadv(t, e, flags) - BTREE *t; - EPG *e; - int flags; -{ - EPGNO *c, delc; - PAGE *h; - indx_t index; - pgno_t pg; - - /* Save the current cursor if going to delete it. */ - c = &t->bt_bcursor; - if (ISSET(t, B_DELCRSR)) - delc = *c; - - if ((h = mpool_get(t->bt_mp, c->pgno, 0)) == NULL) - return (RET_ERROR); - - /* - * Find the next/previous record in the tree and point the cursor at it. - * The cursor may not be moved until a new key has been found. - */ - index = c->index; - switch(flags) { - case R_NEXT: /* Next record. */ - if (++index == NEXTINDEX(h)) { - do { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } while (NEXTINDEX(h) == 0); - index = 0; - } - break; - case R_PREV: /* Previous record. */ - if (index-- == 0) { - do { - pg = h->prevpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } while (NEXTINDEX(h) == 0); - index = NEXTINDEX(h) - 1; - } - break; - } - - e->page = h; - e->index = index; - - /* - * Delete any already deleted record that we've been saving because the - * cursor pointed to it. This could cause the new index to be shifted - * down by one if the record we're deleting is on the same page and has - * a larger index. - */ - if (ISSET(t, B_DELCRSR)) { - CLR(t, B_DELCRSR); /* Don't try twice. */ - if (c->pgno == delc.pgno && c->index > delc.index) - --c->index; - if (__bt_crsrdel(t, &delc)) - return (RET_ERROR); - } - return (RET_SUCCESS); -} - -/* - * __BT_CRSRDEL -- Delete the record referenced by the cursor. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_crsrdel(t, c) - BTREE *t; - EPGNO *c; -{ - PAGE *h; - int status; - - CLR(t, B_DELCRSR); /* Don't try twice. */ - if ((h = mpool_get(t->bt_mp, c->pgno, 0)) == NULL) - return (RET_ERROR); - status = __bt_dleaf(t, h, c->index); - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (status); -} diff --git a/lib/libc/DB/btree/bt_split.c b/lib/libc/DB/btree/bt_split.c deleted file mode 100644 index 1b3a71255c01..000000000000 --- a/lib/libc/DB/btree/bt_split.c +++ /dev/null @@ -1,826 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_split.c 5.17 (Berkeley) 5/22/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#define __DBINTERFACE_PRIVATE -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_broot __P((BTREE *, PAGE *, PAGE *, PAGE *)); -static PAGE *bt_page - __P((BTREE *, PAGE *, PAGE **, PAGE **, u_int *, size_t)); -static int bt_preserve __P((BTREE *, pgno_t)); -static PAGE *bt_psplit - __P((BTREE *, PAGE *, PAGE *, PAGE *, u_int *, size_t)); -static PAGE *bt_root - __P((BTREE *, PAGE *, PAGE **, PAGE **, u_int *, size_t)); -static int bt_rroot __P((BTREE *, PAGE *, PAGE *, PAGE *)); -static recno_t rec_total __P((PAGE *)); - -#ifdef STATISTICS -u_long bt_rootsplit, bt_split, bt_sortsplit, bt_pfxsaved; -#endif - -/* - * __BT_SPLIT -- Split the tree. - * - * Parameters: - * t: tree - * sp: page to split - * key: key to insert - * data: data to insert - * flags: BIGKEY/BIGDATA flags - * ilen: insert length - * skip: index to leave open - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_split(t, sp, key, data, flags, ilen, skip) - BTREE *t; - PAGE *sp; - const DBT *key, *data; - u_long flags; - size_t ilen; - u_int skip; -{ - BINTERNAL *bi; - BLEAF *bl, *tbl; - DBT a, b; - EPGNO *parent; - PAGE *h, *l, *r, *lchild, *rchild; - indx_t nxtindex; - size_t n, nbytes, nksize; - int parentsplit; - char *dest; - - /* - * Split the page into two pages, l and r. The split routines return - * a pointer to the page into which the key should be inserted and with - * skip set to the offset which should be used. Additionally, l and r - * are pinned. - */ - h = sp->pgno == P_ROOT ? - bt_root(t, sp, &l, &r, &skip, ilen) : - bt_page(t, sp, &l, &r, &skip, ilen); - if (h == NULL) - return (RET_ERROR); - - /* - * Insert the new key/data pair into the leaf page. (Key inserts - * always cause a leaf page to split first.) - */ - h->linp[skip] = h->upper -= ilen; - dest = (char *)h + h->upper; - if (ISSET(t, R_RECNO)) - WR_RLEAF(dest, data, flags) - else - WR_BLEAF(dest, key, data, flags) - - /* If the root page was split, make it look right. */ - if (sp->pgno == P_ROOT && - (ISSET(t, R_RECNO) ? - bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) - goto err2; - - /* - * Now we walk the parent page stack -- a LIFO stack of the pages that - * were traversed when we searched for the page that split. Each stack - * entry is a page number and a page index offset. The offset is for - * the page traversed on the search. We've just split a page, so we - * have to insert a new key into the parent page. - * - * If the insert into the parent page causes it to split, may have to - * continue splitting all the way up the tree. We stop if the root - * splits or the page inserted into didn't have to split to hold the - * new key. Some algorithms replace the key for the old page as well - * as the new page. We don't, as there's no reason to believe that the - * first key on the old page is any better than the key we have, and, - * in the case of a key being placed at index 0 causing the split, the - * key is unavailable. - * - * There are a maximum of 5 pages pinned at any time. We keep the left - * and right pages pinned while working on the parent. The 5 are the - * two children, left parent and right parent (when the parent splits) - * and the root page or the overflow key page when calling bt_preserve. - * This code must make sure that all pins are released other than the - * root page or overflow page which is unlocked elsewhere. - */ - while ((parent = BT_POP(t)) != NULL) { - lchild = l; - rchild = r; - - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - goto err2; - - /* - * The new key goes ONE AFTER the index, because the split - * was to the right. - */ - skip = parent->index + 1; - - /* - * Calculate the space needed on the parent page. - * - * Prefix trees: space hack when inserting into BINTERNAL - * pages. Retain only what's needed to distinguish between - * the new entry and the LAST entry on the page to its left. - * If the keys compare equal, retain the entire key. Note, - * we don't touch overflow keys, and the entire key must be - * retained for the next-to-left most key on the leftmost - * page of each level, or the search will fail. Applicable - * ONLY to internal pages that have leaf pages as children. - * Further reduction of the key between pairs of internal - * pages loses too much information. - */ - switch (rchild->flags & P_TYPE) { - case P_BINTERNAL: - bi = GETBINTERNAL(rchild, 0); - nbytes = NBINTERNAL(bi->ksize); - break; - case P_BLEAF: - bl = GETBLEAF(rchild, 0); - nbytes = NBINTERNAL(bl->ksize); - if (t->bt_pfx && !(bl->flags & P_BIGKEY) && - (h->prevpg != P_INVALID || skip > 1)) { - tbl = GETBLEAF(lchild, NEXTINDEX(lchild) - 1); - a.size = tbl->ksize; - a.data = tbl->bytes; - b.size = bl->ksize; - b.data = bl->bytes; - nksize = t->bt_pfx(&a, &b); - n = NBINTERNAL(nksize); - if (n < nbytes) { -#ifdef STATISTICS - bt_pfxsaved += nbytes - n; -#endif - nbytes = n; - } else - nksize = 0; - } else - nksize = 0; - break; - case P_RINTERNAL: - case P_RLEAF: - nbytes = NRINTERNAL; - break; - default: - abort(); - } - - /* Split the parent page if necessary or shift the indices. */ - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - sp = h; - h = h->pgno == P_ROOT ? - bt_root(t, h, &l, &r, &skip, nbytes) : - bt_page(t, h, &l, &r, &skip, nbytes); - if (h == NULL) - goto err1; - parentsplit = 1; - } else { - if (skip < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + skip + 1, h->linp + skip, - (nxtindex - skip) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - parentsplit = 0; - } - - /* Insert the key into the parent page. */ - switch(rchild->flags & P_TYPE) { - case P_BINTERNAL: - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - memmove(dest, bi, nbytes); - ((BINTERNAL *)dest)->pgno = rchild->pgno; - break; - case P_BLEAF: - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - WR_BINTERNAL(dest, nksize ? nksize : bl->ksize, - rchild->pgno, bl->flags & P_BIGKEY); - memmove(dest, bl->bytes, nksize ? nksize : bl->ksize); - if (bl->flags & P_BIGKEY && - bt_preserve(t, *(pgno_t *)bl->bytes) == RET_ERROR) - goto err1; - break; - case P_RINTERNAL: - /* - * Update the left page count. If split - * added at index 0, fix the correct page. - */ - if (skip > 0) - dest = (char *)h + h->linp[skip - 1]; - else - dest = (char *)l + l->linp[NEXTINDEX(l) - 1]; - ((RINTERNAL *)dest)->nrecs = rec_total(lchild); - ((RINTERNAL *)dest)->pgno = lchild->pgno; - - /* Update the right page count. */ - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - ((RINTERNAL *)dest)->nrecs = rec_total(rchild); - ((RINTERNAL *)dest)->pgno = rchild->pgno; - break; - case P_RLEAF: - /* - * Update the left page count. If split - * added at index 0, fix the correct page. - */ - if (skip > 0) - dest = (char *)h + h->linp[skip - 1]; - else - dest = (char *)l + l->linp[NEXTINDEX(l) - 1]; - ((RINTERNAL *)dest)->nrecs = NEXTINDEX(lchild); - ((RINTERNAL *)dest)->pgno = lchild->pgno; - - /* Update the right page count. */ - h->linp[skip] = h->upper -= nbytes; - dest = (char *)h + h->linp[skip]; - ((RINTERNAL *)dest)->nrecs = NEXTINDEX(rchild); - ((RINTERNAL *)dest)->pgno = rchild->pgno; - break; - default: - abort(); - } - - /* Unpin the held pages. */ - if (!parentsplit) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - } - - /* If the root page was split, make it look right. */ - if (sp->pgno == P_ROOT && - (ISSET(t, R_RECNO) ? - bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) - goto err1; - - mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); - mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); - } - - /* Unpin the held pages. */ - mpool_put(t->bt_mp, l, MPOOL_DIRTY); - mpool_put(t->bt_mp, r, MPOOL_DIRTY); - - /* Clear any pages left on the stack. */ - return (RET_SUCCESS); - - /* - * If something fails in the above loop we were already walking back - * up the tree and the tree is now inconsistent. Nothing much we can - * do about it but release any memory we're holding. - */ -err1: mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); - mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); - -err2: mpool_put(t->bt_mp, l, 0); - mpool_put(t->bt_mp, r, 0); - __dbpanic(t->bt_dbp); - return (RET_ERROR); -} - -/* - * BT_PAGE -- Split a non-root page of a btree. - * - * Parameters: - * t: tree - * h: root page - * lp: pointer to left page pointer - * rp: pointer to right page pointer - * skip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert or NULL on error. - */ -static PAGE * -bt_page(t, h, lp, rp, skip, ilen) - BTREE *t; - PAGE *h, **lp, **rp; - u_int *skip; - size_t ilen; -{ - PAGE *l, *r, *tp; - pgno_t npg; - -#ifdef STATISTICS - ++bt_split; -#endif - /* Put the new right page for the split into place. */ - if ((r = __bt_new(t, &npg)) == NULL) - return (NULL); - r->pgno = npg; - r->lower = BTDATAOFF; - r->upper = t->bt_psize; - r->nextpg = h->nextpg; - r->prevpg = h->pgno; - r->flags = h->flags & P_TYPE; - - /* - * If we're splitting the last page on a level because we're appending - * a key to it (skip is NEXTINDEX()), it's likely that the data is - * sorted. Adding an empty page on the side of the level is less work - * and can push the fill factor much higher than normal. If we're - * wrong it's no big deal, we'll just do the split the right way next - * time. It may look like it's equally easy to do a similar hack for - * reverse sorted data, that is, split the tree left, but it's not. - * Don't even try. - */ - if (h->nextpg == P_INVALID && *skip == NEXTINDEX(h)) { -#ifdef STATISTICS - ++bt_sortsplit; -#endif - h->nextpg = r->pgno; - r->lower = BTDATAOFF + sizeof(indx_t); - *skip = 0; - *lp = h; - *rp = r; - return (r); - } - - /* Put the new left page for the split into place. */ - if ((l = malloc(t->bt_psize)) == NULL) { - mpool_put(t->bt_mp, r, 0); - return (NULL); - } - l->pgno = h->pgno; - l->nextpg = r->pgno; - l->prevpg = h->prevpg; - l->lower = BTDATAOFF; - l->upper = t->bt_psize; - l->flags = h->flags & P_TYPE; - - /* Fix up the previous pointer of the page after the split page. */ - if (h->nextpg != P_INVALID) { - if ((tp = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) { - free(l); - /* XXX mpool_free(t->bt_mp, r->pgno); */ - return (NULL); - } - tp->prevpg = r->pgno; - mpool_put(t->bt_mp, tp, 0); - } - - /* - * Split right. The key/data pairs aren't sorted in the btree page so - * it's simpler to copy the data from the split page onto two new pages - * instead of copying half the data to the right page and compacting - * the left page in place. Since the left page can't change, we have - * to swap the original and the allocated left page after the split. - */ - tp = bt_psplit(t, h, l, r, skip, ilen); - - /* Move the new left page onto the old left page. */ - memmove(h, l, t->bt_psize); - if (tp == l) - tp = h; - free(l); - - *lp = h; - *rp = r; - return (tp); -} - -/* - * BT_ROOT -- Split the root page of a btree. - * - * Parameters: - * t: tree - * h: root page - * lp: pointer to left page pointer - * rp: pointer to right page pointer - * skip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert or NULL on error. - */ -static PAGE * -bt_root(t, h, lp, rp, skip, ilen) - BTREE *t; - PAGE *h, **lp, **rp; - u_int *skip; - size_t ilen; -{ - PAGE *l, *r, *tp; - pgno_t lnpg, rnpg; - -#ifdef STATISTICS - ++bt_split; - ++bt_rootsplit; -#endif - /* Put the new left and right pages for the split into place. */ - if ((l = __bt_new(t, &lnpg)) == NULL || - (r = __bt_new(t, &rnpg)) == NULL) - return (NULL); - l->pgno = lnpg; - r->pgno = rnpg; - l->nextpg = r->pgno; - r->prevpg = l->pgno; - l->prevpg = r->nextpg = P_INVALID; - l->lower = r->lower = BTDATAOFF; - l->upper = r->upper = t->bt_psize; - l->flags = r->flags = h->flags & P_TYPE; - - /* Split the root page. */ - tp = bt_psplit(t, h, l, r, skip, ilen); - - *lp = l; - *rp = r; - return (tp); -} - -/* - * BT_RROOT -- Fix up the recno root page after it has been split. - * - * Parameters: - * t: tree - * h: root page - * l: left page - * r: right page - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_rroot(t, h, l, r) - BTREE *t; - PAGE *h, *l, *r; -{ - char *dest; - - /* Insert the left and right keys, set the header information. */ - h->linp[0] = h->upper = t->bt_psize - NRINTERNAL; - dest = (char *)h + h->upper; - WR_RINTERNAL(dest, - l->flags & P_RLEAF ? NEXTINDEX(l) : rec_total(l), l->pgno); - - h->linp[1] = h->upper -= NRINTERNAL; - dest = (char *)h + h->upper; - WR_RINTERNAL(dest, - r->flags & P_RLEAF ? NEXTINDEX(r) : rec_total(r), r->pgno); - - h->lower = BTDATAOFF + 2 * sizeof(indx_t); - - /* Unpin the root page, set to recno internal page. */ - h->flags &= ~P_TYPE; - h->flags |= P_RINTERNAL; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} - -/* - * BT_BROOT -- Fix up the btree root page after it has been split. - * - * Parameters: - * t: tree - * h: root page - * l: left page - * r: right page - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_broot(t, h, l, r) - BTREE *t; - PAGE *h, *l, *r; -{ - BINTERNAL *bi; - BLEAF *bl; - size_t nbytes; - char *dest; - - /* - * If the root page was a leaf page, change it into an internal page. - * We copy the key we split on (but not the key's data, in the case of - * a leaf page) to the new root page. - * - * The btree comparison code guarantees that the left-most key on any - * level of the tree is never used, so it doesn't need to be filled in. - */ - nbytes = NBINTERNAL(0); - h->linp[0] = h->upper = t->bt_psize - nbytes; - dest = (char *)h + h->upper; - WR_BINTERNAL(dest, 0, l->pgno, 0); - - switch(h->flags & P_TYPE) { - case P_BLEAF: - bl = GETBLEAF(r, 0); - nbytes = NBINTERNAL(bl->ksize); - h->linp[1] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_BINTERNAL(dest, bl->ksize, r->pgno, 0); - memmove(dest, bl->bytes, bl->ksize); - - /* - * If the key is on an overflow page, mark the overflow chain - * so it isn't deleted when the leaf copy of the key is deleted. - */ - if (bl->flags & P_BIGKEY && - bt_preserve(t, *(pgno_t *)bl->bytes) == RET_ERROR) - return (RET_ERROR); - break; - case P_BINTERNAL: - bi = GETBINTERNAL(r, 0); - nbytes = NBINTERNAL(bi->ksize); - h->linp[1] = h->upper -= nbytes; - dest = (char *)h + h->upper; - memmove(dest, bi, nbytes); - ((BINTERNAL *)dest)->pgno = r->pgno; - break; - default: - abort(); - } - - /* There are two keys on the page. */ - h->lower = BTDATAOFF + 2 * sizeof(indx_t); - - /* Unpin the root page, set to btree internal page. */ - h->flags &= ~P_TYPE; - h->flags |= P_BINTERNAL; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} - -/* - * BT_PSPLIT -- Do the real work of splitting the page. - * - * Parameters: - * t: tree - * h: page to be split - * l: page to put lower half of data - * r: page to put upper half of data - * pskip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert. - */ -static PAGE * -bt_psplit(t, h, l, r, pskip, ilen) - BTREE *t; - PAGE *h, *l, *r; - u_int *pskip; - size_t ilen; -{ - BINTERNAL *bi; - BLEAF *bl; - RLEAF *rl; - EPGNO *c; - PAGE *rval; - void *src; - indx_t full, half, nxt, off, skip, top, used; - size_t nbytes; - int bigkeycnt, isbigkey; - - /* - * Split the data to the left and right pages. Leave the skip index - * open. Additionally, make some effort not to split on an overflow - * key. This makes internal page processing faster and can save - * space as overflow keys used by internal pages are never deleted. - */ - bigkeycnt = 0; - skip = *pskip; - full = t->bt_psize - BTDATAOFF; - half = full / 2; - used = 0; - for (nxt = off = 0, top = NEXTINDEX(h); nxt < top; ++off) { - if (skip == off) { - nbytes = ilen; - isbigkey = 0; /* XXX: not really known. */ - } else - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - src = bi = GETBINTERNAL(h, nxt); - nbytes = NBINTERNAL(bi->ksize); - isbigkey = bi->flags & P_BIGKEY; - break; - case P_BLEAF: - src = bl = GETBLEAF(h, nxt); - nbytes = NBLEAF(bl); - isbigkey = bl->flags & P_BIGKEY; - break; - case P_RINTERNAL: - src = GETRINTERNAL(h, nxt); - nbytes = NRINTERNAL; - isbigkey = 0; - break; - case P_RLEAF: - src = rl = GETRLEAF(h, nxt); - nbytes = NRLEAF(rl); - isbigkey = 0; - break; - default: - abort(); - } - - /* - * If the key/data pairs are substantial fractions of the max - * possible size for the page, it's possible to get situations - * where we decide to try and copy too much onto the left page. - * Make sure that doesn't happen. - */ - if (skip <= off && used + nbytes >= full) { - --off; - break; - } - - /* Copy the key/data pair, if not the skipped index. */ - if (skip != off) { - ++nxt; - - l->linp[off] = l->upper -= nbytes; - memmove((char *)l + l->upper, src, nbytes); - } - - used += nbytes; - if (used >= half) { - if (!isbigkey || bigkeycnt == 3) - break; - else - ++bigkeycnt; - } - } - - /* - * Off is the last offset that's valid for the left page. - * Nxt is the first offset to be placed on the right page. - */ - l->lower += (off + 1) * sizeof(indx_t); - - /* - * If splitting the page that the cursor was on, the cursor has to be - * adjusted to point to the same record as before the split. If the - * cursor is at or past the skipped slot, the cursor is incremented by - * one. If the cursor is on the right page, it is decremented by the - * number of records split to the left page. - * - * Don't bother checking for the B_SEQINIT flag, the page number will - * be P_INVALID. - */ - c = &t->bt_bcursor; - if (c->pgno == h->pgno) { - if (c->index >= skip) - ++c->index; - if (c->index < nxt) /* Left page. */ - c->pgno = l->pgno; - else { /* Right page. */ - c->pgno = r->pgno; - c->index -= nxt; - } - } - - /* - * If the skipped index was on the left page, just return that page. - * Otherwise, adjust the skip index to reflect the new position on - * the right page. - */ - if (skip <= off) { - skip = 0; - rval = l; - } else { - rval = r; - *pskip -= nxt; - } - - for (off = 0; nxt < top; ++off) { - if (skip == nxt) { - ++off; - skip = 0; - } - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - src = bi = GETBINTERNAL(h, nxt); - nbytes = NBINTERNAL(bi->ksize); - break; - case P_BLEAF: - src = bl = GETBLEAF(h, nxt); - nbytes = NBLEAF(bl); - break; - case P_RINTERNAL: - src = GETRINTERNAL(h, nxt); - nbytes = NRINTERNAL; - break; - case P_RLEAF: - src = rl = GETRLEAF(h, nxt); - nbytes = NRLEAF(rl); - break; - default: - abort(); - } - ++nxt; - r->linp[off] = r->upper -= nbytes; - memmove((char *)r + r->upper, src, nbytes); - } - r->lower += off * sizeof(indx_t); - - /* If the key is being appended to the page, adjust the index. */ - if (skip == top) - r->lower += sizeof(indx_t); - - return (rval); -} - -/* - * BT_PRESERVE -- Mark a chain of pages as used by an internal node. - * - * Chains of indirect blocks pointed to by leaf nodes get reclaimed when the - * record that references them gets deleted. Chains pointed to by internal - * pages never get deleted. This routine marks a chain as pointed to by an - * internal page. - * - * Parameters: - * t: tree - * pg: page number of first page in the chain. - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -static int -bt_preserve(t, pg) - BTREE *t; - pgno_t pg; -{ - PAGE *h; - - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - h->flags |= P_PRESERVE; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -/* - * REC_TOTAL -- Return the number of recno entries below a page. - * - * Parameters: - * h: page - * - * Returns: - * The number of recno entries below a page. - * - * XXX - * These values could be set by the bt_psplit routine. The problem is that the - * entry has to be popped off of the stack etc. or the values have to be passed - * all the way back to bt_split/bt_rroot and it's not very clean. - */ -static recno_t -rec_total(h) - PAGE *h; -{ - recno_t recs; - indx_t nxt, top; - - for (recs = 0, nxt = 0, top = NEXTINDEX(h); nxt < top; ++nxt) - recs += GETRINTERNAL(h, nxt)->nrecs; - return (recs); -} diff --git a/lib/libc/DB/btree/bt_stack.c b/lib/libc/DB/btree/bt_stack.c deleted file mode 100644 index c1f2bb97ea2e..000000000000 --- a/lib/libc/DB/btree/bt_stack.c +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_stack.c 5.4 (Berkeley) 2/11/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * When a page splits, a new record has to be inserted into its parent page. - * This page may have to split as well, all the way up to the root. Since - * parent pointers in each page would be expensive, we maintain a stack of - * parent pages as we descend the tree. - * - * XXX - * This is a concurrency problem -- if user a builds a stack, then user b - * splits the tree, then user a tries to split the tree, there's a new level - * in the tree that user a doesn't know about. - */ - -/* - * __BT_PUSH -- Push parent page info onto the stack (LIFO). - * - * Parameters: - * t: tree - * pgno: page - * index: page index - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_push(t, pgno, index) - BTREE *t; - pgno_t pgno; - int index; -{ - if (t->bt_sp == t->bt_maxstack) { - t->bt_maxstack += 50; - if ((t->bt_stack = realloc(t->bt_stack, - t->bt_maxstack * sizeof(EPGNO))) == NULL) { - t->bt_maxstack -= 50; - return (RET_ERROR); - } - } - - t->bt_stack[t->bt_sp].pgno = pgno; - t->bt_stack[t->bt_sp].index = index; - ++t->bt_sp; - return (RET_SUCCESS); -} diff --git a/lib/libc/DB/btree/bt_utils.c b/lib/libc/DB/btree/bt_utils.c deleted file mode 100644 index 09b9a7ac9b4a..000000000000 --- a/lib/libc/DB/btree/bt_utils.c +++ /dev/null @@ -1,227 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bt_utils.c 5.11 (Berkeley) 5/1/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "btree.h" - -/* - * __BT_RET -- Build return key/data pair as a result of search or scan. - * - * Parameters: - * t: tree - * d: LEAF to be returned to the user. - * key: user's key structure (NULL if not to be filled in) - * data: user's data structure - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_ret(t, e, key, data) - BTREE *t; - EPG *e; - DBT *key, *data; -{ - register BLEAF *bl; - register void *p; - - bl = GETBLEAF(e->page, e->index); - - if (bl->flags & P_BIGDATA) { - if (__ovfl_get(t, bl->bytes + bl->ksize, - &data->size, &t->bt_dbuf, &t->bt_dbufsz)) - return (RET_ERROR); - } else { - /* Use +1 in case the first record retrieved is 0 length. */ - if (bl->dsize + 1 > t->bt_dbufsz) { - if ((p = realloc(t->bt_dbuf, bl->dsize + 1)) == NULL) - return (RET_ERROR); - t->bt_dbuf = p; - t->bt_dbufsz = bl->dsize + 1; - } - memmove(t->bt_dbuf, bl->bytes + bl->ksize, bl->dsize); - data->size = bl->dsize; - } - data->data = t->bt_dbuf; - - if (key == NULL) - return (RET_SUCCESS); - - if (bl->flags & P_BIGKEY) { - if (__ovfl_get(t, bl->bytes, - &key->size, &t->bt_kbuf, &t->bt_kbufsz)) - return (RET_ERROR); - } else { - if (bl->ksize > t->bt_kbufsz) { - if ((p = realloc(t->bt_kbuf, bl->ksize)) == NULL) - return (RET_ERROR); - t->bt_kbuf = p; - t->bt_kbufsz = bl->ksize; - } - memmove(t->bt_kbuf, bl->bytes, bl->ksize); - key->size = bl->ksize; - } - key->data = t->bt_kbuf; - return (RET_SUCCESS); -} - -/* - * __BT_CMP -- Compare a key to a given record. - * - * Parameters: - * t: tree - * k1: DBT pointer of first arg to comparison - * e: pointer to EPG for comparison - * - * Returns: - * < 0 if k1 is < record - * = 0 if k1 is = record - * > 0 if k1 is > record - */ -int -__bt_cmp(t, k1, e) - BTREE *t; - const DBT *k1; - EPG *e; -{ - BINTERNAL *bi; - BLEAF *bl; - DBT k2; - PAGE *h; - void *bigkey; - - /* - * The left-most key on internal pages, at any level of the tree, is - * guaranteed by the following code to be less than any user key. - * This saves us from having to update the leftmost key on an internal - * page when the user inserts a new key in the tree smaller than - * anything we've yet seen. - */ - h = e->page; - if (e->index == 0 && h->prevpg == P_INVALID && !(h->flags & P_BLEAF)) - return (1); - - bigkey = NULL; - if (h->flags & P_BLEAF) { - bl = GETBLEAF(h, e->index); - if (bl->flags & P_BIGKEY) - bigkey = bl->bytes; - else { - k2.data = bl->bytes; - k2.size = bl->ksize; - } - } else { - bi = GETBINTERNAL(h, e->index); - if (bi->flags & P_BIGKEY) - bigkey = bi->bytes; - else { - k2.data = bi->bytes; - k2.size = bi->ksize; - } - } - - if (bigkey) { - if (__ovfl_get(t, bigkey, - &k2.size, &t->bt_dbuf, &t->bt_dbufsz)) - return (RET_ERROR); - k2.data = t->bt_dbuf; - } - return ((*t->bt_cmp)(k1, &k2)); -} - -/* - * __BT_DEFCMP -- Default comparison routine. - * - * Parameters: - * a: DBT #1 - * b: DBT #2 - * - * Returns: - * < 0 if a is < b - * = 0 if a is = b - * > 0 if a is > b - */ -int -__bt_defcmp(a, b) - const DBT *a, *b; -{ - register u_char *p1, *p2; - register int diff, len; - - len = MIN(a->size, b->size); - for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2) - if (diff = *p1 - *p2) - return (diff); - return (a->size - b->size); -} - -/* - * __BT_DEFPFX -- Default prefix routine. - * - * Parameters: - * a: DBT #1 - * b: DBT #2 - * - * Returns: - * Number of bytes needed to distinguish b from a. - */ -int -__bt_defpfx(a, b) - const DBT *a, *b; -{ - register u_char *p1, *p2; - register int len; - int cnt; - - cnt = 1; - len = MIN(a->size, b->size); - for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2, ++cnt) - if (*p1 != *p2) - return (cnt); - - /* a->size must be <= b->size, or they wouldn't be in this order. */ - return (a->size < b->size ? a->size + 1 : a->size); -} diff --git a/lib/libc/DB/btree/btree.h b/lib/libc/DB/btree/btree.h deleted file mode 100644 index 3262d116ac2c..000000000000 --- a/lib/libc/DB/btree/btree.h +++ /dev/null @@ -1,345 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)btree.h 5.15 (Berkeley) 5/22/93 - */ - -#include - -#define DEFMINKEYPAGE (2) /* Minimum keys per page */ -#define MINCACHE (5) /* Minimum cached pages */ -#define MINPSIZE (512) /* Minimum page size */ - -/* - * Page 0 of a btree file contains a copy of the meta-data. This page is also - * used as an out-of-band page, i.e. page pointers that point to nowhere point - * to page 0. Page 1 is the root of the btree. - */ -#define P_INVALID 0 /* Invalid tree page number. */ -#define P_META 0 /* Tree metadata page number. */ -#define P_ROOT 1 /* Tree root page number. */ - -/* - * There are five page layouts in the btree: btree internal pages (BINTERNAL), - * btree leaf pages (BLEAF), recno internal pages (RINTERNAL), recno leaf pages - * (RLEAF) and overflow pages. All five page types have a page header (PAGE). - * This implementation requires that longs within structures are NOT padded. - * (ANSI C permits random padding.) If your compiler pads randomly you'll have - * to do some work to get this package to run. - */ -typedef struct PAGE { - pgno_t pgno; /* this page's page number */ - pgno_t prevpg; /* left sibling */ - pgno_t nextpg; /* right sibling */ - -#define P_BINTERNAL 0x01 /* btree internal page */ -#define P_BLEAF 0x02 /* leaf page */ -#define P_OVERFLOW 0x04 /* overflow page */ -#define P_RINTERNAL 0x08 /* recno internal page */ -#define P_RLEAF 0x10 /* leaf page */ -#define P_TYPE 0x1f /* type mask */ - -#define P_PRESERVE 0x20 /* never delete this chain of pages */ - u_long flags; - - indx_t lower; /* lower bound of free space on page */ - indx_t upper; /* upper bound of free space on page */ - indx_t linp[1]; /* long-aligned VARIABLE LENGTH DATA */ -} PAGE; - -/* First and next index. */ -#define BTDATAOFF (sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \ - sizeof(u_long) + sizeof(indx_t) + sizeof(indx_t)) -#define NEXTINDEX(p) (((p)->lower - BTDATAOFF) / sizeof(indx_t)) - -/* - * For pages other than overflow pages, there is an array of offsets into the - * rest of the page immediately following the page header. Each offset is to - * an item which is unique to the type of page. The h_lower offset is just - * past the last filled-in index. The h_upper offset is the first item on the - * page. Offsets are from the beginning of the page. - * - * If an item is too big to store on a single page, a flag is set and the item - * is a { page, size } pair such that the page is the first page of an overflow - * chain with size bytes of item. Overflow pages are simply bytes without any - * external structure. - * - * The size and page number fields in the items are long aligned so they can be - * manipulated without copying. - */ -#define LALIGN(n) (((n) + sizeof(u_long) - 1) & ~(sizeof(u_long) - 1)) -#define NOVFLSIZE (sizeof(pgno_t) + sizeof(size_t)) - -/* - * For the btree internal pages, the item is a key. BINTERNALs are {key, pgno} - * pairs, such that the key compares less than or equal to all of the records - * on that page. For a tree without duplicate keys, an internal page with two - * consecutive keys, a and b, will have all records greater than or equal to a - * and less than b stored on the page associated with a. Duplicate keys are - * somewhat special and can cause duplicate internal and leaf page records and - * some minor modifications of the above rule. - */ -typedef struct BINTERNAL { - size_t ksize; /* key size */ - pgno_t pgno; /* page number stored on */ -#define P_BIGDATA 0x01 /* overflow data */ -#define P_BIGKEY 0x02 /* overflow key */ - u_char flags; - char bytes[1]; /* data */ -} BINTERNAL; - -/* Get the page's BINTERNAL structure at index indx. */ -#define GETBINTERNAL(pg, indx) \ - ((BINTERNAL *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NBINTERNAL(len) \ - LALIGN(sizeof(size_t) + sizeof(pgno_t) + sizeof(u_char) + (len)) - -/* Copy a BINTERNAL entry to the page. */ -#define WR_BINTERNAL(p, size, pgno, flags) { \ - *(size_t *)p = size; \ - p += sizeof(size_t); \ - *(pgno_t *)p = pgno; \ - p += sizeof(pgno_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ -} - -/* - * For the recno internal pages, the item is a page number with the number of - * keys found on that page and below. - */ -typedef struct RINTERNAL { - recno_t nrecs; /* number of records */ - pgno_t pgno; /* page number stored below */ -} RINTERNAL; - -/* Get the page's RINTERNAL structure at index indx. */ -#define GETRINTERNAL(pg, indx) \ - ((RINTERNAL *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NRINTERNAL \ - LALIGN(sizeof(recno_t) + sizeof(pgno_t)) - -/* Copy a RINTERAL entry to the page. */ -#define WR_RINTERNAL(p, nrecs, pgno) { \ - *(recno_t *)p = nrecs; \ - p += sizeof(recno_t); \ - *(pgno_t *)p = pgno; \ -} - -/* For the btree leaf pages, the item is a key and data pair. */ -typedef struct BLEAF { - size_t ksize; /* size of key */ - size_t dsize; /* size of data */ - u_char flags; /* P_BIGDATA, P_BIGKEY */ - char bytes[1]; /* data */ -} BLEAF; - -/* Get the page's BLEAF structure at index indx. */ -#define GETBLEAF(pg, indx) \ - ((BLEAF *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NBLEAF(p) NBLEAFDBT((p)->ksize, (p)->dsize) - -/* Get the number of bytes in the user's key/data pair. */ -#define NBLEAFDBT(ksize, dsize) \ - LALIGN(sizeof(size_t) + sizeof(size_t) + sizeof(u_char) + \ - (ksize) + (dsize)) - -/* Copy a BLEAF entry to the page. */ -#define WR_BLEAF(p, key, data, flags) { \ - *(size_t *)p = key->size; \ - p += sizeof(size_t); \ - *(size_t *)p = data->size; \ - p += sizeof(size_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ - memmove(p, key->data, key->size); \ - p += key->size; \ - memmove(p, data->data, data->size); \ -} - -/* For the recno leaf pages, the item is a data entry. */ -typedef struct RLEAF { - size_t dsize; /* size of data */ - u_char flags; /* P_BIGDATA */ - char bytes[1]; -} RLEAF; - -/* Get the page's RLEAF structure at index indx. */ -#define GETRLEAF(pg, indx) \ - ((RLEAF *)((char *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NRLEAF(p) NRLEAFDBT((p)->dsize) - -/* Get the number of bytes from the user's data. */ -#define NRLEAFDBT(dsize) \ - LALIGN(sizeof(size_t) + sizeof(u_char) + (dsize)) - -/* Copy a RLEAF entry to the page. */ -#define WR_RLEAF(p, data, flags) { \ - *(size_t *)p = data->size; \ - p += sizeof(size_t); \ - *(u_char *)p = flags; \ - p += sizeof(u_char); \ - memmove(p, data->data, data->size); \ -} - -/* - * A record in the tree is either a pointer to a page and an index in the page - * or a page number and an index. These structures are used as a cursor, stack - * entry and search returns as well as to pass records to other routines. - * - * One comment about searches. Internal page searches must find the largest - * record less than key in the tree so that descents work. Leaf page searches - * must find the smallest record greater than key so that the returned index - * is the record's correct position for insertion. - * - * One comment about cursors. The cursor key is never removed from the tree, - * even if deleted. This is because it is quite difficult to decide where the - * cursor should be when other keys have been inserted/deleted in the tree; - * duplicate keys make it impossible. This scheme does require extra work - * though, to make sure that we don't perform an operation on a deleted key. - */ -typedef struct EPGNO { - pgno_t pgno; /* the page number */ - indx_t index; /* the index on the page */ -} EPGNO; - -typedef struct EPG { - PAGE *page; /* the (pinned) page */ - indx_t index; /* the index on the page */ -} EPG; - -/* - * The metadata of the tree. The m_nrecs field is used only by the RECNO code. - * This is because the btree doesn't really need it and it requires that every - * put or delete call modify the metadata. - */ -typedef struct BTMETA { - u_long m_magic; /* magic number */ - u_long m_version; /* version */ - u_long m_psize; /* page size */ - u_long m_free; /* page number of first free page */ - u_long m_nrecs; /* R: number of records */ -#define SAVEMETA (B_NODUPS | R_RECNO) - u_long m_flags; /* bt_flags & SAVEMETA */ - u_long m_unused; /* unused */ -} BTMETA; - -/* The in-memory btree/recno data structure. */ -typedef struct BTREE { - MPOOL *bt_mp; /* memory pool cookie */ - - DB *bt_dbp; /* pointer to enclosing DB */ - - EPGNO bt_bcursor; /* B: btree cursor */ - recno_t bt_rcursor; /* R: recno cursor (1-based) */ - -#define BT_POP(t) (t->bt_sp ? t->bt_stack + --t->bt_sp : NULL) -#define BT_CLR(t) (t->bt_sp = 0) - EPGNO *bt_stack; /* stack of parent pages */ - u_int bt_sp; /* current stack pointer */ - u_int bt_maxstack; /* largest stack */ - - char *bt_kbuf; /* key buffer */ - size_t bt_kbufsz; /* key buffer size */ - char *bt_dbuf; /* data buffer */ - size_t bt_dbufsz; /* data buffer size */ - - int bt_fd; /* tree file descriptor */ - - pgno_t bt_free; /* next free page */ - u_long bt_psize; /* page size */ - indx_t bt_ovflsize; /* cut-off for key/data overflow */ - int bt_lorder; /* byte order */ - /* sorted order */ - enum { NOT, BACK, FORWARD, } bt_order; - EPGNO bt_last; /* last insert */ - - /* B: key comparison function */ - int (*bt_cmp) __P((const DBT *, const DBT *)); - /* B: prefix comparison function */ - int (*bt_pfx) __P((const DBT *, const DBT *)); - /* R: recno input function */ - int (*bt_irec) __P((struct BTREE *, recno_t)); - - FILE *bt_rfp; /* R: record FILE pointer */ - int bt_rfd; /* R: record file descriptor */ - - caddr_t bt_cmap; /* R: current point in mapped space */ - caddr_t bt_smap; /* R: start of mapped space */ - caddr_t bt_emap; /* R: end of mapped space */ - size_t bt_msize; /* R: size of mapped region. */ - - recno_t bt_nrecs; /* R: number of records */ - size_t bt_reclen; /* R: fixed record length */ - u_char bt_bval; /* R: delimiting byte/pad character */ - -/* - * NB: - * B_NODUPS and R_RECNO are stored on disk, and may not be changed. - */ -#define B_DELCRSR 0x00001 /* cursor has been deleted */ -#define B_INMEM 0x00002 /* in-memory tree */ -#define B_METADIRTY 0x00004 /* need to write metadata */ -#define B_MODIFIED 0x00008 /* tree modified */ -#define B_NEEDSWAP 0x00010 /* if byte order requires swapping */ -#define B_NODUPS 0x00020 /* no duplicate keys permitted */ -#define B_RDONLY 0x00040 /* read-only tree */ -#define B_SEQINIT 0x00100 /* sequential scan initialized */ - -#define R_CLOSEFP 0x00200 /* opened a file pointer */ -#define R_EOF 0x00400 /* end of input file reached. */ -#define R_FIXLEN 0x00800 /* fixed length records */ -#define R_MEMMAPPED 0x01000 /* memory mapped file. */ -#define R_RECNO 0x00080 /* record oriented tree */ -#define R_INMEM 0x02000 /* in-memory file */ -#define R_MODIFIED 0x04000 /* modified file */ -#define R_RDONLY 0x08000 /* read-only file */ - - u_long bt_flags; /* btree state */ -} BTREE; - -#define SET(t, f) ((t)->bt_flags |= (f)) -#define CLR(t, f) ((t)->bt_flags &= ~(f)) -#define ISSET(t, f) ((t)->bt_flags & (f)) - -#include "extern.h" diff --git a/lib/libc/DB/btree/extern.h b/lib/libc/DB/btree/extern.h deleted file mode 100644 index 84666b547920..000000000000 --- a/lib/libc/DB/btree/extern.h +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)extern.h 5.8 (Berkeley) 5/24/93 - */ - -int __bt_close __P((DB *)); -int __bt_cmp __P((BTREE *, const DBT *, EPG *)); -int __bt_crsrdel __P((BTREE *, EPGNO *)); -int __bt_defcmp __P((const DBT *, const DBT *)); -int __bt_defpfx __P((const DBT *, const DBT *)); -int __bt_delete __P((const DB *, const DBT *, u_int)); -int __bt_dleaf __P((BTREE *, PAGE *, int)); -int __bt_fd __P((const DB *)); -EPG *__bt_first __P((BTREE *, const DBT *, int *)); -int __bt_free __P((BTREE *, PAGE *)); -int __bt_get __P((const DB *, const DBT *, DBT *, u_int)); -PAGE *__bt_new __P((BTREE *, pgno_t *)); -DB *__bt_open __P((const char *, int, int, const BTREEINFO *)); -void __bt_pgin __P((void *, pgno_t, void *)); -void __bt_pgout __P((void *, pgno_t, void *)); -int __bt_push __P((BTREE *, pgno_t, int)); -int __bt_put __P((const DB *dbp, DBT *, const DBT *, u_int)); -int __bt_ret __P((BTREE *, EPG *, DBT *, DBT *)); -EPG *__bt_search __P((BTREE *, const DBT *, int *)); -int __bt_seq __P((const DB *, DBT *, DBT *, u_int)); -int __bt_split __P((BTREE *, PAGE *, - const DBT *, const DBT *, u_long, size_t, u_int)); -int __bt_sync __P((const DB *, u_int)); - -int __ovfl_delete __P((BTREE *, void *)); -int __ovfl_get __P((BTREE *, void *, size_t *, char **, size_t *)); -int __ovfl_put __P((BTREE *, const DBT *, pgno_t *)); - -#ifdef DEBUG -void __bt_dnpage __P((DB *, pgno_t)); -void __bt_dpage __P((PAGE *)); -void __bt_dump __P((DB *)); -#endif -#ifdef STATISTICS -void __bt_stat __P((DB *)); -#endif diff --git a/lib/libc/DB/hash/hash_buf.c b/lib/libc/DB/hash/hash_buf.c deleted file mode 100644 index ce8649dc0613..000000000000 --- a/lib/libc/DB/hash/hash_buf.c +++ /dev/null @@ -1,344 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_buf.c 5.12 (Berkeley) 2/11/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * PACKAGE: hash - * - * DESCRIPTION: - * Contains buffer management - * - * ROUTINES: - * External - * __buf_init - * __get_buf - * __buf_free - * __reclaim_buf - * Internal - * newbuf - */ - -#include - -#include -#include -#include -#ifdef DEBUG -#include -#endif - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static BUFHEAD *newbuf __P((HTAB *, u_int, BUFHEAD *)); - -/* Unlink B from its place in the lru */ -#define BUF_REMOVE(B) { \ - (B)->prev->next = (B)->next; \ - (B)->next->prev = (B)->prev; \ -} - -/* Insert B after P */ -#define BUF_INSERT(B, P) { \ - (B)->next = (P)->next; \ - (B)->prev = (P); \ - (P)->next = (B); \ - (B)->next->prev = (B); \ -} - -#define MRU hashp->bufhead.next -#define LRU hashp->bufhead.prev - -#define MRU_INSERT(B) BUF_INSERT((B), &hashp->bufhead) -#define LRU_INSERT(B) BUF_INSERT((B), LRU) - -/* - * We are looking for a buffer with address "addr". If prev_bp is NULL, then - * address is a bucket index. If prev_bp is not NULL, then it points to the - * page previous to an overflow page that we are trying to find. - * - * CAVEAT: The buffer header accessed via prev_bp's ovfl field may no longer - * be valid. Therefore, you must always verify that its address matches the - * address you are seeking. - */ -extern BUFHEAD * -__get_buf(hashp, addr, prev_bp, newpage) - HTAB *hashp; - u_int addr; - BUFHEAD *prev_bp; - int newpage; /* If prev_bp set, indicates a new overflow page. */ -{ - register BUFHEAD *bp; - register u_int is_disk_mask; - register int is_disk, segment_ndx; - SEGMENT segp; - - is_disk = 0; - is_disk_mask = 0; - if (prev_bp) { - bp = prev_bp->ovfl; - if (!bp || (bp->addr != addr)) - bp = NULL; - if (!newpage) - is_disk = BUF_DISK; - } else { - /* Grab buffer out of directory */ - segment_ndx = addr & (hashp->SGSIZE - 1); - - /* valid segment ensured by __call_hash() */ - segp = hashp->dir[addr >> hashp->SSHIFT]; -#ifdef DEBUG - assert(segp != NULL); -#endif - bp = PTROF(segp[segment_ndx]); - is_disk_mask = ISDISK(segp[segment_ndx]); - is_disk = is_disk_mask || !hashp->new_file; - } - - if (!bp) { - bp = newbuf(hashp, addr, prev_bp); - if (!bp || - __get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0)) - return (NULL); - if (!prev_bp) - segp[segment_ndx] = - (BUFHEAD *)((u_int)bp | is_disk_mask); - } else { - BUF_REMOVE(bp); - MRU_INSERT(bp); - } - return (bp); -} - -/* - * We need a buffer for this page. Either allocate one, or evict a resident - * one (if we have as many buffers as we're allowed) and put this one in. - * - * If newbuf finds an error (returning NULL), it also sets errno. - */ -static BUFHEAD * -newbuf(hashp, addr, prev_bp) - HTAB *hashp; - u_int addr; - BUFHEAD *prev_bp; -{ - register BUFHEAD *bp; /* The buffer we're going to use */ - register BUFHEAD *xbp; /* Temp pointer */ - register BUFHEAD *next_xbp; - SEGMENT segp; - int segment_ndx; - u_short oaddr, *shortp; - - oaddr = 0; - bp = LRU; - /* - * If LRU buffer is pinned, the buffer pool is too small. We need to - * allocate more buffers. - */ - if (hashp->nbufs || (bp->flags & BUF_PIN)) { - /* Allocate a new one */ - bp = malloc(sizeof(struct _bufhead)); - if (!bp || !(bp->page = malloc(hashp->BSIZE))) - return (NULL); - if (hashp->nbufs) - hashp->nbufs--; - } else { - /* Kick someone out */ - BUF_REMOVE(bp); - /* - * If this is an overflow page with addr 0, it's already been - * flushed back in an overflow chain and initialized. - */ - if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) { - /* - * Set oaddr before __put_page so that you get it - * before bytes are swapped. - */ - shortp = (u_short *)bp->page; - if (shortp[0]) - oaddr = shortp[shortp[0] - 1]; - if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page, - bp->addr, (int)IS_BUCKET(bp->flags), 0)) - return (NULL); - /* - * Update the pointer to this page (i.e. invalidate it). - * - * If this is a new file (i.e. we created it at open - * time), make sure that we mark pages which have been - * written to disk so we retrieve them from disk later, - * rather than allocating new pages. - */ - if (IS_BUCKET(bp->flags)) { - segment_ndx = bp->addr & (hashp->SGSIZE - 1); - segp = hashp->dir[bp->addr >> hashp->SSHIFT]; -#ifdef DEBUG - assert(segp != NULL); -#endif - - if (hashp->new_file && - ((bp->flags & BUF_MOD) || - ISDISK(segp[segment_ndx]))) - segp[segment_ndx] = (BUFHEAD *)BUF_DISK; - else - segp[segment_ndx] = NULL; - } - /* - * Since overflow pages can only be access by means of - * their bucket, free overflow pages associated with - * this bucket. - */ - for (xbp = bp; xbp->ovfl;) { - next_xbp = xbp->ovfl; - xbp->ovfl = 0; - xbp = next_xbp; - - /* Check that ovfl pointer is up date. */ - if (IS_BUCKET(xbp->flags) || - (oaddr != xbp->addr)) - break; - - shortp = (u_short *)xbp->page; - if (shortp[0]) - /* set before __put_page */ - oaddr = shortp[shortp[0] - 1]; - if ((xbp->flags & BUF_MOD) && __put_page(hashp, - xbp->page, xbp->addr, 0, 0)) - return (NULL); - xbp->addr = 0; - xbp->flags = 0; - BUF_REMOVE(xbp); - LRU_INSERT(xbp); - } - } - } - - /* Now assign this buffer */ - bp->addr = addr; -#ifdef DEBUG1 - (void)fprintf(stderr, "NEWBUF1: %d->ovfl was %d is now %d\n", - bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0); -#endif - bp->ovfl = NULL; - if (prev_bp) { - /* - * If prev_bp is set, this is an overflow page, hook it in to - * the buffer overflow links. - */ -#ifdef DEBUG1 - (void)fprintf(stderr, "NEWBUF2: %d->ovfl was %d is now %d\n", - prev_bp->addr, (prev_bp->ovfl ? bp->ovfl->addr : 0), - (bp ? bp->addr : 0)); -#endif - prev_bp->ovfl = bp; - bp->flags = 0; - } else - bp->flags = BUF_BUCKET; - MRU_INSERT(bp); - return (bp); -} - -extern void -__buf_init(hashp, nbytes) - HTAB *hashp; - int nbytes; -{ - BUFHEAD *bfp; - int npages; - - bfp = &(hashp->bufhead); - npages = (nbytes + hashp->BSIZE - 1) >> hashp->BSHIFT; - npages = MAX(npages, MIN_BUFFERS); - - hashp->nbufs = npages; - bfp->next = bfp; - bfp->prev = bfp; - /* - * This space is calloc'd so these are already null. - * - * bfp->ovfl = NULL; - * bfp->flags = 0; - * bfp->page = NULL; - * bfp->addr = 0; - */ -} - -extern int -__buf_free(hashp, do_free, to_disk) - HTAB *hashp; - int do_free, to_disk; -{ - BUFHEAD *bp; - - /* Need to make sure that buffer manager has been initialized */ - if (!LRU) - return (0); - for (bp = LRU; bp != &hashp->bufhead;) { - /* Check that the buffer is valid */ - if (bp->addr || IS_BUCKET(bp->flags)) { - if (to_disk && (bp->flags & BUF_MOD) && - __put_page(hashp, bp->page, - bp->addr, IS_BUCKET(bp->flags), 0)) - return (-1); - } - /* Check if we are freeing stuff */ - if (do_free) { - if (bp->page) - free(bp->page); - BUF_REMOVE(bp); - free(bp); - bp = LRU; - } else - bp = bp->prev; - } - return (0); -} - -extern void -__reclaim_buf(hashp, bp) - HTAB *hashp; - BUFHEAD *bp; -{ - bp->ovfl = 0; - bp->addr = 0; - bp->flags = 0; - BUF_REMOVE(bp); - LRU_INSERT(bp); -} diff --git a/lib/libc/DB/hash/hash_func.c b/lib/libc/DB/hash/hash_func.c deleted file mode 100644 index 5a24af55f69b..000000000000 --- a/lib/libc/DB/hash/hash_func.c +++ /dev/null @@ -1,191 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_func.c 5.4 (Berkeley) 2/11/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static int hash1 __P((u_char *, int)); -static int hash2 __P((u_char *, int)); -static int hash3 __P((u_char *, int)); -static int hash4 __P((u_char *, int)); - -/* Global default hash function */ -int (*__default_hash) __P((u_char *, int)) = hash4; - -/******************************* HASH FUNCTIONS **************************/ -/* - * Assume that we've already split the bucket to which this key hashes, - * calculate that bucket, and check that in fact we did already split it. - * - * This came from ejb's hsearch. - */ - -#define PRIME1 37 -#define PRIME2 1048583 - -static int -hash1(key, len) - register u_char *key; - register int len; -{ - register int h; - - h = 0; - /* Convert string to integer */ - while (len--) - h = h * PRIME1 ^ (*key++ - ' '); - h %= PRIME2; - return (h); -} - -/* - * Phong's linear congruential hash - */ -#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c)) - -static int -hash2(key, len) - register u_char *key; - int len; -{ - register u_char *e, c; - register int h; - - e = key + len; - for (h = 0; key != e;) { - c = *key++; - if (!c && key > e) - break; - dcharhash(h, c); - } - return (h); -} - -/* - * This is INCREDIBLY ugly, but fast. We break the string up into 8 byte - * units. On the first time through the loop we get the "leftover bytes" - * (strlen % 8). On every other iteration, we perform 8 HASHC's so we handle - * all 8 bytes. Essentially, this saves us 7 cmp & branch instructions. If - * this routine is heavily used enough, it's worth the ugly coding. - * - * OZ's original sdbm hash - */ -static int -hash3(key, len) - register u_char *key; - register int len; -{ - register int n, loop; - -#define HASHC n = *key++ + 65599 * n - - n = 0; - if (len > 0) { - loop = (len + 8 - 1) >> 3; - - switch (len & (8 - 1)) { - case 0: - do { /* All fall throughs */ - HASHC; - case 7: - HASHC; - case 6: - HASHC; - case 5: - HASHC; - case 4: - HASHC; - case 3: - HASHC; - case 2: - HASHC; - case 1: - HASHC; - } while (--loop); - } - - } - return (n); -} - -/* Hash function from Chris Torek. */ -static int -hash4(key, len) - register u_char *key; - register int len; -{ - register int h, loop; - -#define HASH4a h = (h << 5) - h + *key++; -#define HASH4b h = (h << 5) + h + *key++; -#define HASH4 HASH4b - - h = 0; - if (len > 0) { - loop = (len + 8 - 1) >> 3; - - switch (len & (8 - 1)) { - case 0: - do { /* All fall throughs */ - HASH4; - case 7: - HASH4; - case 6: - HASH4; - case 5: - HASH4; - case 4: - HASH4; - case 3: - HASH4; - case 2: - HASH4; - case 1: - HASH4; - } while (--loop); - } - - } - return (h); -} diff --git a/lib/libc/DB/hash/hash_log2.c b/lib/libc/DB/hash/hash_log2.c deleted file mode 100644 index daf624c149a3..000000000000 --- a/lib/libc/DB/hash/hash_log2.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_log2.c 5.4 (Berkeley) 9/26/91"; -#endif /* LIBC_SCCS and not lint */ - -#include - -u_int -__log2(num) - u_int num; -{ - register u_int i, limit; - - limit = 1; - for (i = 0; limit < num; limit = limit << 1, i++); - return (i); -} diff --git a/lib/libc/DB/hash/hash_page.c b/lib/libc/DB/hash/hash_page.c deleted file mode 100644 index ff79a3d9bccc..000000000000 --- a/lib/libc/DB/hash/hash_page.c +++ /dev/null @@ -1,941 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_page.c 5.25 (Berkeley) 2/16/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * PACKAGE: hashing - * - * DESCRIPTION: - * Page manipulation for hashing package. - * - * ROUTINES: - * - * External - * __get_page - * __add_ovflpage - * Internal - * overflow_page - * open_temp - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#ifdef DEBUG -#include -#endif - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static u_long *fetch_bitmap __P((HTAB *, int)); -static u_long first_free __P((u_long)); -static int open_temp __P((HTAB *)); -static u_short overflow_page __P((HTAB *)); -static void putpair __P((char *, const DBT *, const DBT *)); -static void squeeze_key __P((u_short *, const DBT *, const DBT *)); -static int ugly_split - __P((HTAB *, u_int, BUFHEAD *, BUFHEAD *, int, int)); - -#define PAGE_INIT(P) { \ - ((u_short *)(P))[0] = 0; \ - ((u_short *)(P))[1] = hashp->BSIZE - 3 * sizeof(u_short); \ - ((u_short *)(P))[2] = hashp->BSIZE; \ -} - -/* - * This is called AFTER we have verified that there is room on the page for - * the pair (PAIRFITS has returned true) so we go right ahead and start moving - * stuff on. - */ -static void -putpair(p, key, val) - char *p; - const DBT *key, *val; -{ - register u_short *bp, n, off; - - bp = (u_short *)p; - - /* Enter the key first. */ - n = bp[0]; - - off = OFFSET(bp) - key->size; - memmove(p + off, key->data, key->size); - bp[++n] = off; - - /* Now the data. */ - off -= val->size; - memmove(p + off, val->data, val->size); - bp[++n] = off; - - /* Adjust page info. */ - bp[0] = n; - bp[n + 1] = off - ((n + 3) * sizeof(u_short)); - bp[n + 2] = off; -} - -/* - * Returns: - * 0 OK - * -1 error - */ -extern int -__delpair(hashp, bufp, ndx) - HTAB *hashp; - BUFHEAD *bufp; - register int ndx; -{ - register u_short *bp, newoff; - register int n; - u_short pairlen; - - bp = (u_short *)bufp->page; - n = bp[0]; - - if (bp[ndx + 1] < REAL_KEY) - return (__big_delete(hashp, bufp)); - if (ndx != 1) - newoff = bp[ndx - 1]; - else - newoff = hashp->BSIZE; - pairlen = newoff - bp[ndx + 1]; - - if (ndx != (n - 1)) { - /* Hard Case -- need to shuffle keys */ - register int i; - register char *src = bufp->page + (int)OFFSET(bp); - register char *dst = src + (int)pairlen; - memmove(dst, src, bp[ndx + 1] - OFFSET(bp)); - - /* Now adjust the pointers */ - for (i = ndx + 2; i <= n; i += 2) { - if (bp[i + 1] == OVFLPAGE) { - bp[i - 2] = bp[i]; - bp[i - 1] = bp[i + 1]; - } else { - bp[i - 2] = bp[i] + pairlen; - bp[i - 1] = bp[i + 1] + pairlen; - } - } - } - /* Finally adjust the page data */ - bp[n] = OFFSET(bp) + pairlen; - bp[n - 1] = bp[n + 1] + pairlen + 2 * sizeof(u_short); - bp[0] = n - 2; - hashp->NKEYS--; - - bufp->flags |= BUF_MOD; - return (0); -} -/* - * Returns: - * 0 ==> OK - * -1 ==> Error - */ -extern int -__split_page(hashp, obucket, nbucket) - HTAB *hashp; - u_int obucket, nbucket; -{ - register BUFHEAD *new_bufp, *old_bufp; - register u_short *ino; - register char *np; - DBT key, val; - int n, ndx, retval; - u_short copyto, diff, off, moved; - char *op; - - copyto = (u_short)hashp->BSIZE; - off = (u_short)hashp->BSIZE; - old_bufp = __get_buf(hashp, obucket, NULL, 0); - if (old_bufp == NULL) - return (-1); - new_bufp = __get_buf(hashp, nbucket, NULL, 0); - if (new_bufp == NULL) - return (-1); - - old_bufp->flags |= (BUF_MOD | BUF_PIN); - new_bufp->flags |= (BUF_MOD | BUF_PIN); - - ino = (u_short *)(op = old_bufp->page); - np = new_bufp->page; - - moved = 0; - - for (n = 1, ndx = 1; n < ino[0]; n += 2) { - if (ino[n + 1] < REAL_KEY) { - retval = ugly_split(hashp, obucket, old_bufp, new_bufp, - (int)copyto, (int)moved); - old_bufp->flags &= ~BUF_PIN; - new_bufp->flags &= ~BUF_PIN; - return (retval); - - } - key.data = (u_char *)op + ino[n]; - key.size = off - ino[n]; - - if (__call_hash(hashp, key.data, key.size) == obucket) { - /* Don't switch page */ - diff = copyto - off; - if (diff) { - copyto = ino[n + 1] + diff; - memmove(op + copyto, op + ino[n + 1], - off - ino[n + 1]); - ino[ndx] = copyto + ino[n] - ino[n + 1]; - ino[ndx + 1] = copyto; - } else - copyto = ino[n + 1]; - ndx += 2; - } else { - /* Switch page */ - val.data = (u_char *)op + ino[n + 1]; - val.size = ino[n] - ino[n + 1]; - putpair(np, &key, &val); - moved += 2; - } - - off = ino[n + 1]; - } - - /* Now clean up the page */ - ino[0] -= moved; - FREESPACE(ino) = copyto - sizeof(u_short) * (ino[0] + 3); - OFFSET(ino) = copyto; - -#ifdef DEBUG3 - (void)fprintf(stderr, "split %d/%d\n", - ((u_short *)np)[0] / 2, - ((u_short *)op)[0] / 2); -#endif - /* unpin both pages */ - old_bufp->flags &= ~BUF_PIN; - new_bufp->flags &= ~BUF_PIN; - return (0); -} - -/* - * Called when we encounter an overflow or big key/data page during split - * handling. This is special cased since we have to begin checking whether - * the key/data pairs fit on their respective pages and because we may need - * overflow pages for both the old and new pages. - * - * The first page might be a page with regular key/data pairs in which case - * we have a regular overflow condition and just need to go on to the next - * page or it might be a big key/data pair in which case we need to fix the - * big key/data pair. - * - * Returns: - * 0 ==> success - * -1 ==> failure - */ -static int -ugly_split(hashp, obucket, old_bufp, new_bufp, copyto, moved) - HTAB *hashp; - u_int obucket; /* Same as __split_page. */ - BUFHEAD *old_bufp, *new_bufp; - int copyto; /* First byte on page which contains key/data values. */ - int moved; /* Number of pairs moved to new page. */ -{ - register BUFHEAD *bufp; /* Buffer header for ino */ - register u_short *ino; /* Page keys come off of */ - register u_short *np; /* New page */ - register u_short *op; /* Page keys go on to if they aren't moving */ - - BUFHEAD *last_bfp; /* Last buf header OVFL needing to be freed */ - DBT key, val; - SPLIT_RETURN ret; - u_short n, off, ov_addr, scopyto; - char *cino; /* Character value of ino */ - - bufp = old_bufp; - ino = (u_short *)old_bufp->page; - np = (u_short *)new_bufp->page; - op = (u_short *)old_bufp->page; - last_bfp = NULL; - scopyto = (u_short)copyto; /* ANSI */ - - n = ino[0] - 1; - while (n < ino[0]) { - if (ino[2] < REAL_KEY && ino[2] != OVFLPAGE) { - /* - * Ov_addr gets set before reaching this point; there's - * always an overflow page before a big key/data page. - */ - if (__big_split(hashp, old_bufp, - new_bufp, bufp, ov_addr, obucket, &ret)) - return (-1); - old_bufp = ret.oldp; - if (!old_bufp) - return (-1); - op = (u_short *)old_bufp->page; - new_bufp = ret.newp; - if (!new_bufp) - return (-1); - np = (u_short *)new_bufp->page; - bufp = ret.nextp; - if (!bufp) - return (0); - cino = (char *)bufp->page; - ino = (u_short *)cino; - last_bfp = ret.nextp; - } else if (ino[n + 1] == OVFLPAGE) { - ov_addr = ino[n]; - /* - * Fix up the old page -- the extra 2 are the fields - * which contained the overflow information. - */ - ino[0] -= (moved + 2); - FREESPACE(ino) = - scopyto - sizeof(u_short) * (ino[0] + 3); - OFFSET(ino) = scopyto; - - bufp = __get_buf(hashp, ov_addr, bufp, 0); - if (!bufp) - return (-1); - - ino = (u_short *)bufp->page; - n = 1; - scopyto = hashp->BSIZE; - moved = 0; - - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - last_bfp = bufp; - } - /* Move regular sized pairs of there are any */ - off = hashp->BSIZE; - for (n = 1; (n < ino[0]) && (ino[n + 1] >= REAL_KEY); n += 2) { - cino = (char *)ino; - key.data = (u_char *)cino + ino[n]; - key.size = off - ino[n]; - val.data = (u_char *)cino + ino[n + 1]; - val.size = ino[n] - ino[n + 1]; - off = ino[n + 1]; - - if (__call_hash(hashp, key.data, key.size) == obucket) { - /* Keep on old page */ - if (PAIRFITS(op, (&key), (&val))) - putpair((char *)op, &key, &val); - else { - old_bufp = - __add_ovflpage(hashp, old_bufp); - if (!old_bufp) - return (-1); - op = (u_short *)old_bufp->page; - putpair((char *)op, &key, &val); - } - old_bufp->flags |= BUF_MOD; - } else { - /* Move to new page */ - if (PAIRFITS(np, (&key), (&val))) - putpair((char *)np, &key, &val); - else { - new_bufp = - __add_ovflpage(hashp, new_bufp); - if (!new_bufp) - return (-1); - np = (u_short *)new_bufp->page; - putpair((char *)np, &key, &val); - } - new_bufp->flags |= BUF_MOD; - } - } - } - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - return (0); -} - -/* - * Add the given pair to the page - * - * Returns: - * 0 ==> OK - * 1 ==> failure - */ -extern int -__addel(hashp, bufp, key, val) - HTAB *hashp; - BUFHEAD *bufp; - const DBT *key, *val; -{ - register u_short *bp, *sop; - int do_expand; - - bp = (u_short *)bufp->page; - do_expand = 0; - while (bp[0] && (bp[bp[0]] < REAL_KEY)) - /* Exception case */ - if (bp[2] < REAL_KEY && bp[bp[0]] != OVFLPAGE) { - /* This is a big-keydata pair */ - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - bp = (u_short *)bufp->page; - } else - /* Try to squeeze key on this page */ - if (FREESPACE(bp) > PAIRSIZE(key, val)) { - squeeze_key(bp, key, val); - return (0); - } else { - bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (u_short *)bufp->page; - } - - if (PAIRFITS(bp, key, val)) - putpair(bufp->page, key, val); - else { - do_expand = 1; - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - sop = (u_short *)bufp->page; - - if (PAIRFITS(sop, key, val)) - putpair((char *)sop, key, val); - else - if (__big_insert(hashp, bufp, key, val)) - return (-1); - } - bufp->flags |= BUF_MOD; - /* - * If the average number of keys per bucket exceeds the fill factor, - * expand the table. - */ - hashp->NKEYS++; - if (do_expand || - (hashp->NKEYS / (hashp->MAX_BUCKET + 1) > hashp->FFACTOR)) - return (__expand_table(hashp)); - return (0); -} - -/* - * - * Returns: - * pointer on success - * NULL on error - */ -extern BUFHEAD * -__add_ovflpage(hashp, bufp) - HTAB *hashp; - BUFHEAD *bufp; -{ - register u_short *sp; - u_short ndx, ovfl_num; -#ifdef DEBUG1 - int tmp1, tmp2; -#endif - sp = (u_short *)bufp->page; - - /* Check if we are dynamically determining the fill factor */ - if (hashp->FFACTOR == DEF_FFACTOR) { - hashp->FFACTOR = sp[0] >> 1; - if (hashp->FFACTOR < MIN_FFACTOR) - hashp->FFACTOR = MIN_FFACTOR; - } - bufp->flags |= BUF_MOD; - ovfl_num = overflow_page(hashp); -#ifdef DEBUG1 - tmp1 = bufp->addr; - tmp2 = bufp->ovfl ? bufp->ovfl->addr : 0; -#endif - if (!ovfl_num || !(bufp->ovfl = __get_buf(hashp, ovfl_num, bufp, 1))) - return (NULL); - bufp->ovfl->flags |= BUF_MOD; -#ifdef DEBUG1 - (void)fprintf(stderr, "ADDOVFLPAGE: %d->ovfl was %d is now %d\n", - tmp1, tmp2, bufp->ovfl->addr); -#endif - ndx = sp[0]; - /* - * Since a pair is allocated on a page only if there's room to add - * an overflow page, we know that the OVFL information will fit on - * the page. - */ - sp[ndx + 4] = OFFSET(sp); - sp[ndx + 3] = FREESPACE(sp) - OVFLSIZE; - sp[ndx + 1] = ovfl_num; - sp[ndx + 2] = OVFLPAGE; - sp[0] = ndx + 2; -#ifdef HASH_STATISTICS - hash_overflows++; -#endif - return (bufp->ovfl); -} - -/* - * Returns: - * 0 indicates SUCCESS - * -1 indicates FAILURE - */ -extern int -__get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap) - HTAB *hashp; - char *p; - u_int bucket; - int is_bucket, is_disk, is_bitmap; -{ - register int fd, page, size; - int rsize; - u_short *bp; - - fd = hashp->fp; - size = hashp->BSIZE; - - if ((fd == -1) || !is_disk) { - PAGE_INIT(p); - return (0); - } - if (is_bucket) - page = BUCKET_TO_PAGE(bucket); - else - page = OADDR_TO_PAGE(bucket); - if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || - ((rsize = read(fd, p, size)) == -1)) - return (-1); - bp = (u_short *)p; - if (!rsize) - bp[0] = 0; /* We hit the EOF, so initialize a new page */ - else - if (rsize != size) { - errno = EFTYPE; - return (-1); - } - if (!is_bitmap && !bp[0]) { - PAGE_INIT(p); - } else - if (hashp->LORDER != BYTE_ORDER) { - register int i, max; - - if (is_bitmap) { - max = hashp->BSIZE >> 2; /* divide by 4 */ - for (i = 0; i < max; i++) - BLSWAP(((long *)p)[i]); - } else { - BSSWAP(bp[0]); - max = bp[0] + 2; - for (i = 1; i <= max; i++) - BSSWAP(bp[i]); - } - } - return (0); -} - -/* - * Write page p to disk - * - * Returns: - * 0 ==> OK - * -1 ==>failure - */ -extern int -__put_page(hashp, p, bucket, is_bucket, is_bitmap) - HTAB *hashp; - char *p; - u_int bucket; - int is_bucket, is_bitmap; -{ - register int fd, page, size; - int wsize; - - size = hashp->BSIZE; - if ((hashp->fp == -1) && open_temp(hashp)) - return (-1); - fd = hashp->fp; - - if (hashp->LORDER != BYTE_ORDER) { - register int i; - register int max; - - if (is_bitmap) { - max = hashp->BSIZE >> 2; /* divide by 4 */ - for (i = 0; i < max; i++) - BLSWAP(((long *)p)[i]); - } else { - max = ((u_short *)p)[0] + 2; - for (i = 0; i <= max; i++) - BSSWAP(((u_short *)p)[i]); - } - } - if (is_bucket) - page = BUCKET_TO_PAGE(bucket); - else - page = OADDR_TO_PAGE(bucket); - if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || - ((wsize = write(fd, p, size)) == -1)) - /* Errno is set */ - return (-1); - if (wsize != size) { - errno = EFTYPE; - return (-1); - } - return (0); -} - -#define BYTE_MASK ((1 << INT_BYTE_SHIFT) -1) -/* - * Initialize a new bitmap page. Bitmap pages are left in memory - * once they are read in. - */ -extern int -__init_bitmap(hashp, pnum, nbits, ndx) - HTAB *hashp; - int pnum, nbits, ndx; -{ - u_long *ip; - int clearbytes, clearints; - - if (!(ip = malloc(hashp->BSIZE))) - return (1); - hashp->nmaps++; - clearints = ((nbits - 1) >> INT_BYTE_SHIFT) + 1; - clearbytes = clearints << INT_TO_BYTE; - (void)memset((char *)ip, 0, clearbytes); - (void)memset(((char *)ip) + clearbytes, 0xFF, - hashp->BSIZE - clearbytes); - ip[clearints - 1] = ALL_SET << (nbits & BYTE_MASK); - SETBIT(ip, 0); - hashp->BITMAPS[ndx] = (u_short)pnum; - hashp->mapp[ndx] = ip; - return (0); -} - -static u_long -first_free(map) - u_long map; -{ - register u_long i, mask; - - mask = 0x1; - for (i = 0; i < BITS_PER_MAP; i++) { - if (!(mask & map)) - return (i); - mask = mask << 1; - } - return (i); -} - -static u_short -overflow_page(hashp) - HTAB *hashp; -{ - register u_long *freep; - register int max_free, offset, splitnum; - u_short addr; - int bit, first_page, free_bit, free_page, i, in_use_bits, j; -#ifdef DEBUG2 - int tmp1, tmp2; -#endif - splitnum = hashp->OVFL_POINT; - max_free = hashp->SPARES[splitnum]; - - free_page = (max_free - 1) >> (hashp->BSHIFT + BYTE_SHIFT); - free_bit = (max_free - 1) & ((hashp->BSIZE << BYTE_SHIFT) - 1); - - /* Look through all the free maps to find the first free block */ - first_page = hashp->LAST_FREED >>(hashp->BSHIFT + BYTE_SHIFT); - for ( i = first_page; i <= free_page; i++ ) { - if (!(freep = (u_long *)hashp->mapp[i]) && - !(freep = fetch_bitmap(hashp, i))) - return (NULL); - if (i == free_page) - in_use_bits = free_bit; - else - in_use_bits = (hashp->BSIZE << BYTE_SHIFT) - 1; - - if (i == first_page) { - bit = hashp->LAST_FREED & - ((hashp->BSIZE << BYTE_SHIFT) - 1); - j = bit / BITS_PER_MAP; - bit = bit & ~(BITS_PER_MAP - 1); - } else { - bit = 0; - j = 0; - } - for (; bit <= in_use_bits; j++, bit += BITS_PER_MAP) - if (freep[j] != ALL_SET) - goto found; - } - - /* No Free Page Found */ - hashp->LAST_FREED = hashp->SPARES[splitnum]; - hashp->SPARES[splitnum]++; - offset = hashp->SPARES[splitnum] - - (splitnum ? hashp->SPARES[splitnum - 1] : 0); - -#define OVMSG "HASH: Out of overflow pages. Increase page size\n" - if (offset > SPLITMASK) { - if (++splitnum >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - return (NULL); - } - hashp->OVFL_POINT = splitnum; - hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1]; - hashp->SPARES[splitnum-1]--; - offset = 1; - } - - /* Check if we need to allocate a new bitmap page */ - if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) { - free_page++; - if (free_page >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - return (NULL); - } - /* - * This is tricky. The 1 indicates that you want the new page - * allocated with 1 clear bit. Actually, you are going to - * allocate 2 pages from this map. The first is going to be - * the map page, the second is the overflow page we were - * looking for. The init_bitmap routine automatically, sets - * the first bit of itself to indicate that the bitmap itself - * is in use. We would explicitly set the second bit, but - * don't have to if we tell init_bitmap not to leave it clear - * in the first place. - */ - if (__init_bitmap(hashp, (int)OADDR_OF(splitnum, offset), - 1, free_page)) - return (NULL); - hashp->SPARES[splitnum]++; -#ifdef DEBUG2 - free_bit = 2; -#endif - offset++; - if (offset > SPLITMASK) { - if (++splitnum >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, - sizeof(OVMSG) - 1); - return (NULL); - } - hashp->OVFL_POINT = splitnum; - hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1]; - hashp->SPARES[splitnum-1]--; - offset = 0; - } - } else { - /* - * Free_bit addresses the last used bit. Bump it to address - * the first available bit. - */ - free_bit++; - SETBIT(freep, free_bit); - } - - /* Calculate address of the new overflow page */ - addr = OADDR_OF(splitnum, offset); -#ifdef DEBUG2 - (void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", - addr, free_bit, free_page); -#endif - return (addr); - -found: - bit = bit + first_free(freep[j]); - SETBIT(freep, bit); -#ifdef DEBUG2 - tmp1 = bit; - tmp2 = i; -#endif - /* - * Bits are addressed starting with 0, but overflow pages are addressed - * beginning at 1. Bit is a bit addressnumber, so we need to increment - * it to convert it to a page number. - */ - bit = 1 + bit + (i * (hashp->BSIZE << BYTE_SHIFT)); - if (bit >= hashp->LAST_FREED) - hashp->LAST_FREED = bit - 1; - - /* Calculate the split number for this page */ - for (i = 0; (i < splitnum) && (bit > hashp->SPARES[i]); i++); - offset = (i ? bit - hashp->SPARES[i - 1] : bit); - if (offset >= SPLITMASK) - return (NULL); /* Out of overflow pages */ - addr = OADDR_OF(i, offset); -#ifdef DEBUG2 - (void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", - addr, tmp1, tmp2); -#endif - - /* Allocate and return the overflow page */ - return (addr); -} - -/* - * Mark this overflow page as free. - */ -extern void -__free_ovflpage(hashp, obufp) - HTAB *hashp; - BUFHEAD *obufp; -{ - register u_short addr; - u_long *freep; - int bit_address, free_page, free_bit; - u_short ndx; - - addr = obufp->addr; -#ifdef DEBUG1 - (void)fprintf(stderr, "Freeing %d\n", addr); -#endif - ndx = (((u_short)addr) >> SPLITSHIFT); - bit_address = - (ndx ? hashp->SPARES[ndx - 1] : 0) + (addr & SPLITMASK) - 1; - if (bit_address < hashp->LAST_FREED) - hashp->LAST_FREED = bit_address; - free_page = (bit_address >> (hashp->BSHIFT + BYTE_SHIFT)); - free_bit = bit_address & ((hashp->BSIZE << BYTE_SHIFT) - 1); - - if (!(freep = hashp->mapp[free_page])) - freep = fetch_bitmap(hashp, free_page); -#ifdef DEBUG - /* - * This had better never happen. It means we tried to read a bitmap - * that has already had overflow pages allocated off it, and we - * failed to read it from the file. - */ - if (!freep) - assert(0); -#endif - CLRBIT(freep, free_bit); -#ifdef DEBUG2 - (void)fprintf(stderr, "FREE_OVFLPAGE: ADDR: %d BIT: %d PAGE %d\n", - obufp->addr, free_bit, free_page); -#endif - __reclaim_buf(hashp, obufp); -} - -/* - * Returns: - * 0 success - * -1 failure - */ -static int -open_temp(hashp) - HTAB *hashp; -{ - sigset_t set, oset; - static char namestr[] = "_hashXXXXXX"; - - /* Block signals; make sure file goes away at process exit. */ - (void)sigfillset(&set); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - if ((hashp->fp = mkstemp(namestr)) != -1) { - (void)unlink(namestr); - (void)fcntl(hashp->fp, F_SETFD, 1); - } - (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); - return (hashp->fp != -1 ? 0 : -1); -} - -/* - * We have to know that the key will fit, but the last entry on the page is - * an overflow pair, so we need to shift things. - */ -static void -squeeze_key(sp, key, val) - u_short *sp; - const DBT *key, *val; -{ - register char *p; - u_short free_space, n, off, pageno; - - p = (char *)sp; - n = sp[0]; - free_space = FREESPACE(sp); - off = OFFSET(sp); - - pageno = sp[n - 1]; - off -= key->size; - sp[n - 1] = off; - memmove(p + off, key->data, key->size); - off -= val->size; - sp[n] = off; - memmove(p + off, val->data, val->size); - sp[0] = n + 2; - sp[n + 1] = pageno; - sp[n + 2] = OVFLPAGE; - FREESPACE(sp) = free_space - PAIRSIZE(key, val); - OFFSET(sp) = off; -} - -static u_long * -fetch_bitmap(hashp, ndx) - HTAB *hashp; - int ndx; -{ - if (ndx >= hashp->nmaps || - !(hashp->mapp[ndx] = malloc(hashp->BSIZE)) || - __get_page(hashp, (char *)hashp->mapp[ndx], - hashp->BITMAPS[ndx], 0, 1, 1)) - return (NULL); - return (hashp->mapp[ndx]); -} - -#ifdef DEBUG4 -int -print_chain(addr) - int addr; -{ - BUFHEAD *bufp; - short *bp, oaddr; - - (void)fprintf(stderr, "%d ", addr); - bufp = __get_buf(hashp, addr, NULL, 0); - bp = (short *)bufp->page; - while (bp[0] && ((bp[bp[0]] == OVFLPAGE) || - ((bp[0] > 2) && bp[2] < REAL_KEY))) { - oaddr = bp[bp[0] - 1]; - (void)fprintf(stderr, "%d ", (int)oaddr); - bufp = __get_buf(hashp, (int)oaddr, bufp, 0); - bp = (short *)bufp->page; - } - (void)fprintf(stderr, "\n"); -} -#endif diff --git a/lib/libc/DB/hash/hsearch.c b/lib/libc/DB/hash/hsearch.c deleted file mode 100644 index a09e41e2c3ac..000000000000 --- a/lib/libc/DB/hash/hsearch.c +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hsearch.c 5.8 (Berkeley) 2/11/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include - -#define __DBINTERFACE_PRIVATE -#include -#include "search.h" - -static DB *dbp = NULL; -static ENTRY retval; - -extern int -hcreate(nel) - u_int nel; -{ - HASHINFO info; - - info.nelem = nel; - info.bsize = 256; - info.ffactor = 8; - info.cachesize = NULL; - info.hash = NULL; - info.lorder = 0; - dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info); - return ((int)dbp); -} - -extern ENTRY * -hsearch(item, action) - ENTRY item; - ACTION action; -{ - DBT key, val; - int status; - - if (!dbp) - return (NULL); - key.data = (u_char *)item.key; - key.size = strlen(item.key) + 1; - - if (action == ENTER) { - val.data = (u_char *)item.data; - val.size = strlen(item.data) + 1; - status = (dbp->put)(dbp, &key, &val, R_NOOVERWRITE); - if (status) - return (NULL); - } else { - /* FIND */ - status = (dbp->get)(dbp, &key, &val, 0); - if (status) - return (NULL); - else - item.data = (char *)val.data; - } - retval.key = item.key; - retval.data = item.data; - return (&retval); -} - -extern void -hdestroy() -{ - if (dbp) { - (void)(dbp->close)(dbp); - dbp = NULL; - } -} diff --git a/lib/libc/DB/hash/ndbm.c b/lib/libc/DB/hash/ndbm.c deleted file mode 100644 index 5b66bcf3385a..000000000000 --- a/lib/libc/DB/hash/ndbm.c +++ /dev/null @@ -1,202 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ndbm.c 5.14 (Berkeley) 5/23/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * This package provides a dbm compatible interface to the new hashing - * package described in db(3). - */ - -#include - -#include -#include -#include - -#include "hash.h" - -/* - * Returns: - * *DBM on success - * NULL on failure - */ -extern DBM * -dbm_open(file, flags, mode) - const char *file; - int flags, mode; -{ - HASHINFO info; - char path[MAXPATHLEN]; - - info.bsize = 4096; - info.ffactor = 40; - info.nelem = 1; - info.cachesize = NULL; - info.hash = NULL; - info.lorder = 0; - (void)strcpy(path, file); - (void)strcat(path, DBM_SUFFIX); - return ((DBM *)__hash_open(path, flags, mode, &info)); -} - -extern void -dbm_close(db) - DBM *db; -{ - (void)(db->close)(db); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -extern datum -dbm_fetch(db, key) - DBM *db; - datum key; -{ - datum retval; - int status; - - status = (db->get)(db, (DBT *)&key, (DBT *)&retval, 0); - if (status) { - retval.dptr = NULL; - retval.dsize = 0; - } - return (retval); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -extern datum -dbm_firstkey(db) - DBM *db; -{ - int status; - datum retdata, retkey; - - status = (db->seq)(db, (DBT *)&retkey, (DBT *)&retdata, R_FIRST); - if (status) - retkey.dptr = NULL; - return (retkey); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -extern datum -dbm_nextkey(db) - DBM *db; -{ - int status; - datum retdata, retkey; - - status = (db->seq)(db, (DBT *)&retkey, (DBT *)&retdata, R_NEXT); - if (status) - retkey.dptr = NULL; - return (retkey); -} -/* - * Returns: - * 0 on success - * <0 failure - */ -extern int -dbm_delete(db, key) - DBM *db; - datum key; -{ - int status; - - status = (db->del)(db, (DBT *)&key, 0); - if (status) - return (-1); - else - return (0); -} - -/* - * Returns: - * 0 on success - * <0 failure - * 1 if DBM_INSERT and entry exists - */ -extern int -dbm_store(db, key, content, flags) - DBM *db; - datum key, content; - int flags; -{ - return ((db->put)(db, (DBT *)&key, (DBT *)&content, - (flags == DBM_INSERT) ? R_NOOVERWRITE : 0)); -} - -extern int -dbm_error(db) - DBM *db; -{ - HTAB *hp; - - hp = (HTAB *)db->internal; - return (hp->errno); -} - -extern int -dbm_clearerr(db) - DBM *db; -{ - HTAB *hp; - - hp = (HTAB *)db->internal; - hp->errno = 0; - return (0); -} - -extern int -dbm_dirfno(db) - DBM *db; -{ - return(((HTAB *)db->internal)->fp); -} diff --git a/lib/libc/DB/hash/page.h b/lib/libc/DB/hash/page.h deleted file mode 100644 index 20d4e6d13ae4..000000000000 --- a/lib/libc/DB/hash/page.h +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)page.h 5.2 (Berkeley) 9/4/91 - */ - -/* - * Definitions for hashing page file format. - */ - -/* - * routines dealing with a data page - * - * page format: - * +------------------------------+ - * p | n | keyoff | datoff | keyoff | - * +------------+--------+--------+ - * | datoff | free | ptr | --> | - * +--------+---------------------+ - * | F R E E A R E A | - * +--------------+---------------+ - * | <---- - - - | data | - * +--------+-----+----+----------+ - * | key | data | key | - * +--------+----------+----------+ - * - * Pointer to the free space is always: p[p[0] + 2] - * Amount of free space on the page is: p[p[0] + 1] - */ - -/* - * How many bytes required for this pair? - * 2 shorts in the table at the top of the page + room for the - * key and room for the data - * - * We prohibit entering a pair on a page unless there is also room to append - * an overflow page. The reason for this it that you can get in a situation - * where a single key/data pair fits on a page, but you can't append an - * overflow page and later you'd have to split the key/data and handle like - * a big pair. - * You might as well do this up front. - */ - -#define PAIRSIZE(K,D) (2*sizeof(u_short) + (K)->size + (D)->size) -#define BIGOVERHEAD (4*sizeof(u_short)) -#define KEYSIZE(K) (4*sizeof(u_short) + (K)->size); -#define OVFLSIZE (2*sizeof(u_short)) -#define FREESPACE(P) ((P)[(P)[0]+1]) -#define OFFSET(P) ((P)[(P)[0]+2]) -#define PAIRFITS(P,K,D) \ - (((P)[2] >= REAL_KEY) && \ - (PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P))) -#define PAGE_META(N) (((N)+3) * sizeof(u_short)) - -typedef struct { - BUFHEAD *newp; - BUFHEAD *oldp; - BUFHEAD *nextp; - u_short next_addr; -} SPLIT_RETURN; diff --git a/lib/libc/DB/hash/search.h b/lib/libc/DB/hash/search.h deleted file mode 100644 index f18926c063d4..000000000000 --- a/lib/libc/DB/hash/search.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)search.h 5.2 (Berkeley) 9/4/91 - */ - -/* Backward compatibility to hsearch interface. */ -typedef struct entry { - char *key; - char *data; -} ENTRY; - -typedef enum { - FIND, ENTER -} ACTION; - -int hcreate __P((unsigned int)); -void hdestroy __P((void)); -ENTRY *hsearch __P((ENTRY, ACTION)); diff --git a/lib/libc/DB/hash/tests/tseq.c b/lib/libc/DB/hash/tests/tseq.c deleted file mode 100644 index 76f01b29929c..000000000000 --- a/lib/libc/DB/hash/tests/tseq.c +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -char copyright[] = -"@(#) Copyright (c) 1991 The Regents of the University of California.\n\ - All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tseq.c 5.4 (Berkeley) 9/11/91"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - - -char wp[8192]; -char cp[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key, res; - DB *dbp; - FILE *fp; - int stat; - - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, NULL))) { - /* create table */ - fprintf(stderr, "cannot open: hash table\n" ); - exit(1); - } - -/* -* put info in structure, and structure in the item -*/ - for ( stat = (dbp->seq) (dbp, &res, &item, 1 ); - stat == 0; - stat = (dbp->seq) (dbp, &res, &item, 0 ) ) { - - bcopy ( res.data, wp, res.size ); - wp[res.size] = 0; - bcopy ( item.data, cp, item.size ); - cp[item.size] = 0; - - printf ( "%s %s\n", wp, cp ); - } - (dbp->close)(dbp); - exit(0); -} diff --git a/lib/libc/DB/hash/tests/tverify.c b/lib/libc/DB/hash/tests/tverify.c deleted file mode 100644 index 3c8d0b609a65..000000000000 --- a/lib/libc/DB/hash/tests/tverify.c +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -char copyright[] = -"@(#) Copyright (c) 1991 The Regents of the University of California.\n\ - All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tverify.c 5.5 (Berkeley) 9/11/91"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -typedef struct { /* info to be stored */ - int num, siz; -} info; - -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT key, res; - DB *dbp; - HASHINFO ctl; - int trash; - int stat; - - int i = 0; - - ctl.nelem = INITIAL; - ctl.hash = NULL; - ctl.bsize = 64; - ctl.ffactor = 1; - ctl.cachesize = 1024 * 1024; /* 1 MEG */ - ctl.lorder = 0; - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) { - /* create table */ - fprintf(stderr, "cannot open: hash table\n" ); - exit(1); - } - - key.data = wp1; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - - stat = (dbp->get)(dbp, &key, &res,0); - if (stat < 0) { - fprintf ( stderr, "Error retrieving %s\n", key.data ); - exit(1); - } else if ( stat > 0 ) { - fprintf ( stderr, "%s not found\n", key.data ); - exit(1); - } - if ( memcmp ( res.data, wp2, res.size ) ) { - fprintf ( stderr, "data for %s is incorrect. Data was %s. Should have been %s\n", key.data, res.data, wp2 ); - } - } - (dbp->close)(dbp); - exit(0); -} diff --git a/lib/libc/DB/recno/rec_open.c b/lib/libc/DB/recno/rec_open.c deleted file mode 100644 index 9339dcd1dbbe..000000000000 --- a/lib/libc/DB/recno/rec_open.c +++ /dev/null @@ -1,229 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_open.c 5.20 (Berkeley) 5/24/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include "recno.h" - -DB * -__rec_open(fname, flags, mode, openinfo) - const char *fname; - int flags, mode; - const RECNOINFO *openinfo; -{ - BTREE *t; - BTREEINFO btopeninfo; - DB *dbp; - PAGE *h; - struct stat sb; - int rfd, sverrno; - - /* Open the user's file -- if this fails, we're done. */ - if (fname != NULL && (rfd = open(fname, flags, mode)) < 0) - return (NULL); - - /* Create a btree in memory (backed by disk). */ - dbp = NULL; - if (openinfo) { - if (openinfo->flags & ~(R_FIXEDLEN | R_NOKEY | R_SNAPSHOT)) - goto einval; - btopeninfo.flags = 0; - btopeninfo.cachesize = openinfo->cachesize; - btopeninfo.maxkeypage = 0; - btopeninfo.minkeypage = 0; - btopeninfo.psize = openinfo->psize; - btopeninfo.compare = NULL; - btopeninfo.prefix = NULL; - btopeninfo.lorder = openinfo->lorder; - dbp = __bt_open(openinfo->bfname, - O_RDWR, S_IRUSR | S_IWUSR, &btopeninfo); - } else - dbp = __bt_open(NULL, O_RDWR, S_IRUSR | S_IWUSR, NULL); - if (dbp == NULL) - goto err; - - /* - * Some fields in the tree structure are recno specific. Fill them - * in and make the btree structure look like a recno structure. We - * don't change the bt_ovflsize value, it's close enough and slightly - * bigger. - */ - t = dbp->internal; - if (openinfo) { - if (openinfo->flags & R_FIXEDLEN) { - SET(t, R_FIXLEN); - t->bt_reclen = openinfo->reclen; - if (t->bt_reclen == 0) - goto einval; - } - t->bt_bval = openinfo->bval; - } else - t->bt_bval = '\n'; - - SET(t, R_RECNO); - if (fname == NULL) - SET(t, R_EOF | R_INMEM); - else - t->bt_rfd = rfd; - t->bt_rcursor = 0; - - /* - * In 4.4BSD stat(2) returns true for ISSOCK on pipes. Until - * then, this is fairly close. Pipes are read-only. - */ - if (fname != NULL) { - if (lseek(rfd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) { - switch (flags & O_ACCMODE) { - case O_RDONLY: - SET(t, R_RDONLY); - break; - default: - goto einval; - } -slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL) - goto err; - SET(t, R_CLOSEFP); - t->bt_irec = - ISSET(t, R_FIXLEN) ? __rec_fpipe : __rec_vpipe; - } else { - switch (flags & O_ACCMODE) { - case O_RDONLY: - SET(t, R_RDONLY); - break; - case O_RDWR: - break; - default: - goto einval; - } - - if (fstat(rfd, &sb)) - goto err; - /* - * Kludge -- but we don't know what size an off_t - * is or what size a size_t is, although we do - * know that the former is signed and the latter - * unsigned. - */ - if (sizeof(sb.st_size) > sizeof(size_t)) { - if (sb.st_size > (off_t)INT_MAX) { - errno = EFBIG; - goto err; - } - } else { - if ((size_t)sb.st_size > INT_MAX) { - errno = EFBIG; - goto err; - } - } - if (sb.st_size == 0) - SET(t, R_EOF); - else { - t->bt_msize = sb.st_size; - if ((t->bt_smap = - mmap(NULL, t->bt_msize, PROT_READ, 0, rfd, - (off_t)0)) == (caddr_t)-1) - goto slow; - t->bt_cmap = t->bt_smap; - t->bt_emap = t->bt_smap + sb.st_size; - t->bt_irec = ISSET(t, R_FIXLEN) ? - __rec_fmap : __rec_vmap; - SET(t, R_MEMMAPPED); - } - } - } - - /* Use the recno routines. */ - dbp->close = __rec_close; - dbp->del = __rec_delete; - dbp->fd = __rec_fd; - dbp->get = __rec_get; - dbp->put = __rec_put; - dbp->seq = __rec_seq; - dbp->sync = __rec_sync; - - /* If the root page was created, reset the flags. */ - if ((h = mpool_get(t->bt_mp, P_ROOT, 0)) == NULL) - goto err; - if ((h->flags & P_TYPE) == P_BLEAF) { - h->flags = h->flags & ~P_TYPE | P_RLEAF; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - } else - mpool_put(t->bt_mp, h, 0); - - if (openinfo && openinfo->flags & R_SNAPSHOT && - !ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - goto err; - return (dbp); - -einval: errno = EINVAL; -err: sverrno = errno; - if (dbp != NULL) - (void)__bt_close(dbp); - if (fname != NULL) - (void)close(rfd); - errno = sverrno; - return (NULL); -} - -int -__rec_fd(dbp) - const DB *dbp; -{ - BTREE *t; - - t = dbp->internal; - - if (ISSET(t, R_INMEM)) { - errno = ENOENT; - return (-1); - } - return (t->bt_rfd); -} diff --git a/lib/libc/DB/recno/rec_put.c b/lib/libc/DB/recno/rec_put.c deleted file mode 100644 index 43f7ee860656..000000000000 --- a/lib/libc/DB/recno/rec_put.c +++ /dev/null @@ -1,237 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_put.c 5.13 (Berkeley) 5/16/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_PUT -- Add a recno item to the tree. - * - * Parameters: - * dbp: pointer to access method - * key: key - * data: data - * flag: R_CURSOR, R_IAFTER, R_IBEFORE, R_NOOVERWRITE - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is - * already in the tree and R_NOOVERWRITE specified. - */ -int -__rec_put(dbp, key, data, flags) - const DB *dbp; - DBT *key; - const DBT *data; - u_int flags; -{ - BTREE *t; - DBT tdata; - recno_t nrec; - int status; - - t = dbp->internal; - - switch (flags) { - case R_CURSOR: - if (!ISSET(t, B_SEQINIT)) - goto einval; - nrec = t->bt_rcursor; - break; - case R_SETCURSOR: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_IAFTER: - if ((nrec = *(recno_t *)key->data) == 0) { - nrec = 1; - flags = R_IBEFORE; - } - break; - case 0: - case R_IBEFORE: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_NOOVERWRITE: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - if (nrec <= t->bt_nrecs) - return (RET_SPECIAL); - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - /* - * Make sure that records up to and including the put record are - * already in the database. If skipping records, create empty ones. - */ - if (nrec > t->bt_nrecs) { - if (!ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, nrec) == RET_ERROR) - return (RET_ERROR); - if (nrec > t->bt_nrecs + 1) { - tdata.data = NULL; - tdata.size = 0; - while (nrec > t->bt_nrecs + 1) - if (__rec_iput(t, - t->bt_nrecs, &tdata, 0) != RET_SUCCESS) - return (RET_ERROR); - } - } - - if ((status = __rec_iput(t, nrec - 1, data, flags)) != RET_SUCCESS) - return (status); - - if (flags == R_SETCURSOR) - t->bt_rcursor = nrec; - - SET(t, R_MODIFIED); - return (__rec_ret(t, NULL, nrec, key, NULL)); -} - -/* - * __REC_IPUT -- Add a recno item to the tree. - * - * Parameters: - * t: tree - * nrec: record number - * data: data - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_iput(t, nrec, data, flags) - BTREE *t; - recno_t nrec; - const DBT *data; - u_int flags; -{ - DBT tdata; - EPG *e; - PAGE *h; - indx_t index, nxtindex; - pgno_t pg; - size_t nbytes; - int dflags, status; - char *dest, db[NOVFLSIZE]; - - /* - * If the data won't fit on a page, store it on indirect pages. - * - * XXX - * If the insert fails later on, these pages aren't recovered. - */ - if (data->size > t->bt_ovflsize) { - if (__ovfl_put(t, data, &pg) == RET_ERROR) - return (RET_ERROR); - tdata.data = db; - tdata.size = NOVFLSIZE; - *(pgno_t *)db = pg; - *(size_t *)(db + sizeof(pgno_t)) = data->size; - dflags = P_BIGDATA; - data = &tdata; - } else - dflags = 0; - - /* __rec_search pins the returned page. */ - if ((e = __rec_search(t, nrec, - nrec > t->bt_nrecs || flags == R_IAFTER || flags == R_IBEFORE ? - SINSERT : SEARCH)) == NULL) - return (RET_ERROR); - - h = e->page; - index = e->index; - - /* - * Add the specified key/data pair to the tree. The R_IAFTER and - * R_IBEFORE flags insert the key after/before the specified key. - * - * Pages are split as required. - */ - switch (flags) { - case R_IAFTER: - ++index; - break; - case R_IBEFORE: - break; - default: - if (nrec < t->bt_nrecs && - __rec_dleaf(t, h, index) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - break; - } - - /* - * If not enough room, split the page. The split code will insert - * the key and data and unpin the current page. If inserting into - * the offset array, shift the pointers up. - */ - nbytes = NRLEAFDBT(data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - status = __bt_split(t, h, NULL, data, dflags, nbytes, index); - if (status == RET_SUCCESS) - ++t->bt_nrecs; - return (status); - } - - if (index < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + index + 1, h->linp + index, - (nxtindex - index) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - - h->linp[index] = h->upper -= nbytes; - dest = (char *)h + h->upper; - WR_RLEAF(dest, data, dflags); - - ++t->bt_nrecs; - SET(t, B_MODIFIED); - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} diff --git a/lib/libc/DB/recno/rec_search.c b/lib/libc/DB/recno/rec_search.c deleted file mode 100644 index b9af738b9404..000000000000 --- a/lib/libc/DB/recno/rec_search.c +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_search.c 5.8 (Berkeley) 2/14/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include - -#include -#include "recno.h" - -/* - * __REC_SEARCH -- Search a btree for a key. - * - * Parameters: - * t: tree to search - * recno: key to find - * op: search operation - * - * Returns: - * EPG for matching record, if any, or the EPG for the location of the - * key, if it were inserted into the tree. - * - * Warnings: - * The EPG returned is in static memory, and will be overwritten by the - * next search of any kind in any tree. - */ -EPG * -__rec_search(t, recno, op) - BTREE *t; - recno_t recno; - enum SRCHOP op; -{ - static EPG e; - register indx_t index; - register PAGE *h; - EPGNO *parent; - RINTERNAL *r; - pgno_t pg; - indx_t top; - recno_t total; - int serrno; - - BT_CLR(t); - for (pg = P_ROOT, total = 0;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - goto err; - if (h->flags & P_RLEAF) { - e.page = h; - e.index = recno - total; - return (&e); - } - for (index = 0, top = NEXTINDEX(h);;) { - r = GETRINTERNAL(h, index); - if (++index == top || total + r->nrecs > recno) - break; - total += r->nrecs; - } - - if (__bt_push(t, pg, index - 1) == RET_ERROR) - return (NULL); - - pg = r->pgno; - switch (op) { - case SDELETE: - --GETRINTERNAL(h, (index - 1))->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - case SINSERT: - ++GETRINTERNAL(h, (index - 1))->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - case SEARCH: - mpool_put(t->bt_mp, h, 0); - break; - } - - } - /* Try and recover the tree. */ -err: serrno = errno; - if (op != SEARCH) - while ((parent = BT_POP(t)) != NULL) { - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - break; - if (op == SINSERT) - --GETRINTERNAL(h, parent->index)->nrecs; - else - ++GETRINTERNAL(h, parent->index)->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - } - errno = serrno; - return (NULL); -} diff --git a/lib/libc/DB/recno/rec_seq.c b/lib/libc/DB/recno/rec_seq.c deleted file mode 100644 index 6e44e05ebb19..000000000000 --- a/lib/libc/DB/recno/rec_seq.c +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)rec_seq.c 5.9 (Berkeley) 5/16/93"; -#endif /* not lint */ - -#include - -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_SEQ -- Recno sequential scan interface. - * - * Parameters: - * dbp: pointer to access method - * key: key for positioning and return value - * data: data return value - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -int -__rec_seq(dbp, key, data, flags) - const DB *dbp; - DBT *key, *data; - u_int flags; -{ - BTREE *t; - EPG *e; - recno_t nrec; - int status; - - t = dbp->internal; - switch(flags) { - case R_CURSOR: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_NEXT: - if (ISSET(t, B_SEQINIT)) { - nrec = t->bt_rcursor + 1; - break; - } - /* FALLTHROUGH */ - case R_FIRST: - nrec = 1; - break; - case R_PREV: - if (ISSET(t, B_SEQINIT)) { - if ((nrec = t->bt_rcursor - 1) == 0) - return (RET_SPECIAL); - break; - } - /* FALLTHROUGH */ - case R_LAST: - if (!ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - return (RET_ERROR); - nrec = t->bt_nrecs; - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) { - if (!ISSET(t, R_EOF | R_INMEM) && - (status = t->bt_irec(t, nrec)) != RET_SUCCESS) - return (status); - if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) - return (RET_SPECIAL); - } - - if ((e = __rec_search(t, nrec - 1, SEARCH)) == NULL) - return (RET_ERROR); - - SET(t, B_SEQINIT); - t->bt_rcursor = nrec; - - status = __rec_ret(t, e, nrec, key, data); - - mpool_put(t->bt_mp, e->page, 0); - return (status); -} diff --git a/lib/libc/DB/recno/rec_utils.c b/lib/libc/DB/recno/rec_utils.c deleted file mode 100644 index 84b23e935b89..000000000000 --- a/lib/libc/DB/recno/rec_utils.c +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rec_utils.c 5.7 (Berkeley) 2/16/93"; -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_RET -- Build return data as a result of search or scan. - * - * Parameters: - * t: tree - * d: LEAF to be returned to the user. - * data: user's data structure - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__rec_ret(t, e, nrec, key, data) - BTREE *t; - EPG *e; - recno_t nrec; - DBT *key, *data; -{ - register RLEAF *rl; - register void *p; - - if (data == NULL) - goto retkey; - - rl = GETRLEAF(e->page, e->index); - - if (rl->flags & P_BIGDATA) { - if (__ovfl_get(t, rl->bytes, - &data->size, &t->bt_dbuf, &t->bt_dbufsz)) - return (RET_ERROR); - } else { - /* Use +1 in case the first record retrieved is 0 length. */ - if (rl->dsize + 1 > t->bt_dbufsz) { - if ((p = realloc(t->bt_dbuf, rl->dsize + 1)) == NULL) - return (RET_ERROR); - t->bt_dbuf = p; - t->bt_dbufsz = rl->dsize + 1; - } - memmove(t->bt_dbuf, rl->bytes, rl->dsize); - data->size = rl->dsize; - } - data->data = t->bt_dbuf; - -retkey: if (key == NULL) - return (RET_SUCCESS); - - if (sizeof(recno_t) > t->bt_kbufsz) { - if ((p = realloc(t->bt_kbuf, sizeof(recno_t))) == NULL) - return (RET_ERROR); - t->bt_kbuf = p; - t->bt_kbufsz = sizeof(recno_t); - } - memmove(t->bt_kbuf, &nrec, sizeof(recno_t)); - key->size = sizeof(recno_t); - key->data = t->bt_kbuf; - return (RET_SUCCESS); -} diff --git a/lib/libc/DB/recno/recno.h b/lib/libc/DB/recno/recno.h deleted file mode 100644 index 0899fc3cb7b3..000000000000 --- a/lib/libc/DB/recno/recno.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)recno.h 5.1 (Berkeley) 9/11/91 - */ - -enum SRCHOP { SDELETE, SINSERT, SEARCH}; /* Rec_search operation. */ - -#include "../btree/btree.h" -#include "extern.h" diff --git a/lib/libc/arch/hp300/gen/cmpdf2.S b/lib/libc/arch/hp300/gen/cmpdf2.S deleted file mode 100644 index d82c2d8985f0..000000000000 --- a/lib/libc/arch/hp300/gen/cmpdf2.S +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)cmpdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: cmpdf2.S,v 1.1 1993/10/07 00:17:38 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double > double: 1 */ -/* double < double: -1 */ -/* double == double: 0 */ -ENTRY(__cmpdf2) - fmoved sp@(4),fp0 - fcmpd sp@(12),fp0 - fbgt Lagtb - fslt d0 - extbl d0 - rts -Lagtb: - moveq #1,d0 - rts diff --git a/lib/libc/arch/hp300/gen/cmpdf2.s b/lib/libc/arch/hp300/gen/cmpdf2.s deleted file mode 100644 index 704e39238c3f..000000000000 --- a/lib/libc/arch/hp300/gen/cmpdf2.s +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)cmpdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: cmpdf2.s,v 1.1 1993/10/07 00:17:38 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double > double: 1 */ -/* double < double: -1 */ -/* double == double: 0 */ -ENTRY(__cmpdf2) - fmoved sp@(4),fp0 - fcmpd sp@(12),fp0 - fbgt Lagtb - fslt d0 - extbl d0 - rts -Lagtb: - moveq #1,d0 - rts diff --git a/lib/libc/arch/hp300/gen/cmpsf2.S b/lib/libc/arch/hp300/gen/cmpsf2.S deleted file mode 100644 index 52f8043df8f3..000000000000 --- a/lib/libc/arch/hp300/gen/cmpsf2.S +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)cmpsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: cmpsf2.S,v 1.1 1993/10/07 00:17:39 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single > single: 1 */ -/* single < single: -1 */ -/* single == single: 0 */ -ENTRY(__cmpsf2) - fmoves sp@(4),fp0 - fcmps sp@(8),fp0 - fbgt Lagtb - fslt d0 - extbl d0 - rts -Lagtb: - moveq #1,d0 - rts diff --git a/lib/libc/arch/hp300/gen/cmpsf2.s b/lib/libc/arch/hp300/gen/cmpsf2.s deleted file mode 100644 index a14c705c7902..000000000000 --- a/lib/libc/arch/hp300/gen/cmpsf2.s +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)cmpsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: cmpsf2.s,v 1.1 1993/10/07 00:17:39 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single > single: 1 */ -/* single < single: -1 */ -/* single == single: 0 */ -ENTRY(__cmpsf2) - fmoves sp@(4),fp0 - fcmps sp@(8),fp0 - fbgt Lagtb - fslt d0 - extbl d0 - rts -Lagtb: - moveq #1,d0 - rts diff --git a/lib/libc/arch/hp300/gen/divdf3.S b/lib/libc/arch/hp300/gen/divdf3.S deleted file mode 100644 index facadf5eafe5..000000000000 --- a/lib/libc/arch/hp300/gen/divdf3.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divdf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divdf3.S,v 1.1 1993/10/07 00:17:40 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double / double */ -ENTRY(__divdf3) - fmoved sp@(4),fp0 - fdivd sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/divdf3.s b/lib/libc/arch/hp300/gen/divdf3.s deleted file mode 100644 index 4ef93a5acfa9..000000000000 --- a/lib/libc/arch/hp300/gen/divdf3.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divdf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divdf3.s,v 1.1 1993/10/07 00:17:40 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double / double */ -ENTRY(__divdf3) - fmoved sp@(4),fp0 - fdivd sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/divsf3.S b/lib/libc/arch/hp300/gen/divsf3.S deleted file mode 100644 index acb6f25683fb..000000000000 --- a/lib/libc/arch/hp300/gen/divsf3.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divsf3.S,v 1.1 1993/10/07 00:17:41 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single / single */ -ENTRY(__divsf3) - fmoves sp@(4),fp0 - fdivs sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/hp300/gen/divsf3.s b/lib/libc/arch/hp300/gen/divsf3.s deleted file mode 100644 index 37c7a51e0641..000000000000 --- a/lib/libc/arch/hp300/gen/divsf3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divsf3.s,v 1.1 1993/10/07 00:17:41 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single / single */ -ENTRY(__divsf3) - fmoves sp@(4),fp0 - fdivs sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/hp300/gen/divsi3.S b/lib/libc/arch/hp300/gen/divsi3.S deleted file mode 100644 index 9ba60dd88eca..000000000000 --- a/lib/libc/arch/hp300/gen/divsi3.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divsi3.S,v 1.1 1993/10/07 00:17:42 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int / int */ -ENTRY(__divsi3) - movel sp@(4),d0 - divsl sp@(8),d0 - rts diff --git a/lib/libc/arch/hp300/gen/divsi3.s b/lib/libc/arch/hp300/gen/divsi3.s deleted file mode 100644 index a396bdf89fd7..000000000000 --- a/lib/libc/arch/hp300/gen/divsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divsi3.s,v 1.1 1993/10/07 00:17:42 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int / int */ -ENTRY(__divsi3) - movel sp@(4),d0 - divsl sp@(8),d0 - rts diff --git a/lib/libc/arch/hp300/gen/extendsfdf2.S b/lib/libc/arch/hp300/gen/extendsfdf2.S deleted file mode 100644 index 307caee0425e..000000000000 --- a/lib/libc/arch/hp300/gen/extendsfdf2.S +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)extendsfdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: extendsfdf2.S,v 1.1 1993/10/07 00:17:43 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (double) float */ -ENTRY(__extendsfdf2) - fmoves sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/extendsfdf2.s b/lib/libc/arch/hp300/gen/extendsfdf2.s deleted file mode 100644 index 80872ca8a29b..000000000000 --- a/lib/libc/arch/hp300/gen/extendsfdf2.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)extendsfdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: extendsfdf2.s,v 1.1 1993/10/07 00:17:43 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (double) float */ -ENTRY(__extendsfdf2) - fmoves sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/fabs.S b/lib/libc/arch/hp300/gen/fabs.S deleted file mode 100644 index 3d794cac5b7a..000000000000 --- a/lib/libc/arch/hp300/gen/fabs.S +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fabs.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: fabs.S,v 1.1 1993/10/07 00:17:44 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* fabs - floating absolute value */ - -#include "DEFS.h" - -ENTRY(fabs) - fmoved sp@(4),fp0 - fjnlt L1 - fnegx fp0 -L1: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/fabs.s b/lib/libc/arch/hp300/gen/fabs.s deleted file mode 100644 index e55c8c5d517f..000000000000 --- a/lib/libc/arch/hp300/gen/fabs.s +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fabs.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: fabs.s,v 1.1 1993/10/07 00:17:44 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* fabs - floating absolute value */ - -#include "DEFS.h" - -ENTRY(fabs) - fmoved sp@(4),fp0 - fjnlt L1 - fnegx fp0 -L1: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/fixdfsi.S b/lib/libc/arch/hp300/gen/fixdfsi.S deleted file mode 100644 index 877cc9463210..000000000000 --- a/lib/libc/arch/hp300/gen/fixdfsi.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fixdfsi.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: fixdfsi.S,v 1.1 1993/10/07 00:17:45 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (int) double */ -ENTRY(__fixdfsi) - fintrzd sp@(4),fp0 - fmovel fp0,d0 - rts diff --git a/lib/libc/arch/hp300/gen/fixdfsi.s b/lib/libc/arch/hp300/gen/fixdfsi.s deleted file mode 100644 index 5006c9b0ece3..000000000000 --- a/lib/libc/arch/hp300/gen/fixdfsi.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fixdfsi.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: fixdfsi.s,v 1.1 1993/10/07 00:17:45 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (int) double */ -ENTRY(__fixdfsi) - fintrzd sp@(4),fp0 - fmovel fp0,d0 - rts diff --git a/lib/libc/arch/hp300/gen/fixunsdfsi.S b/lib/libc/arch/hp300/gen/fixunsdfsi.S deleted file mode 100644 index f1bfc1e31395..000000000000 --- a/lib/libc/arch/hp300/gen/fixunsdfsi.S +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fixunsdfsi.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: fixunsdfsi.S,v 1.1 1993/10/07 00:17:46 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (unsigned) double */ -ENTRY(__fixunsdfsi) - fintrzd sp@(4),fp0 - fcmpd #0r2147483648.0,fp0 - fbge Lwaybig - fmovel fp0,d0 - rts -Lwaybig: - fsubd #0r2147483648.0,fp0 - fmovel fp0,d0 - bset #31,d0 - rts diff --git a/lib/libc/arch/hp300/gen/fixunsdfsi.s b/lib/libc/arch/hp300/gen/fixunsdfsi.s deleted file mode 100644 index 88486a4d8eaf..000000000000 --- a/lib/libc/arch/hp300/gen/fixunsdfsi.s +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fixunsdfsi.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: fixunsdfsi.s,v 1.1 1993/10/07 00:17:46 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (unsigned) double */ -ENTRY(__fixunsdfsi) - fintrzd sp@(4),fp0 - fcmpd #0r2147483648.0,fp0 - fbge Lwaybig - fmovel fp0,d0 - rts -Lwaybig: - fsubd #0r2147483648.0,fp0 - fmovel fp0,d0 - bset #31,d0 - rts diff --git a/lib/libc/arch/hp300/gen/floatsidf.S b/lib/libc/arch/hp300/gen/floatsidf.S deleted file mode 100644 index 5af9135265cb..000000000000 --- a/lib/libc/arch/hp300/gen/floatsidf.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)floatsidf.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: floatsidf.S,v 1.1 1993/10/07 00:17:47 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (double) int */ -ENTRY(__floatsidf) - fmovel sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - diff --git a/lib/libc/arch/hp300/gen/floatsidf.s b/lib/libc/arch/hp300/gen/floatsidf.s deleted file mode 100644 index ed4964cc8d6a..000000000000 --- a/lib/libc/arch/hp300/gen/floatsidf.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)floatsidf.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: floatsidf.s,v 1.1 1993/10/07 00:17:47 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (double) int */ -ENTRY(__floatsidf) - fmovel sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - diff --git a/lib/libc/arch/hp300/gen/frexp.c b/lib/libc/arch/hp300/gen/frexp.c deleted file mode 100644 index eacb0a5ab6a3..000000000000 --- a/lib/libc/arch/hp300/gen/frexp.c +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "from: @(#)frexp.c 5.1 (Berkeley) 3/6/91";*/ -static char rcsid[] = "$Id: frexp.c,v 1.1 1993/10/07 00:17:48 cgd Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -double -frexp(value, eptr) - double value; - int *eptr; -{ - union { - double v; - struct { - u_int u_sign : 1; - u_int u_exp : 11; - u_int u_mant1 : 20; - u_int u_mant2 : 32; - } s; - } u; - - if (value) { - u.v = value; - *eptr = u.s.u_exp - 1022; - u.s.u_exp = 1022; - return(u.v); - } else { - *eptr = 0; - return((double)0); - } -} diff --git a/lib/libc/arch/hp300/gen/infinity.c b/lib/libc/arch/hp300/gen/infinity.c deleted file mode 100644 index 7879e8b35475..000000000000 --- a/lib/libc/arch/hp300/gen/infinity.c +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef lint -static char rcsid[] = "$Id: infinity.c,v 1.1 1993/10/07 00:17:49 cgd Exp $"; -#endif /* not lint */ - -/* infinity.c */ - -#include - -/* bytes for +Infinity on a 68k */ -char __infinity[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }; diff --git a/lib/libc/arch/hp300/gen/isinf.c b/lib/libc/arch/hp300/gen/isinf.c deleted file mode 100644 index 043899c74a8b..000000000000 --- a/lib/libc/arch/hp300/gen/isinf.c +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "from: @(#)isinf.c 5.1 (Berkeley) 3/18/91";*/ -static char rcsid[] = "$Id: isinf.c,v 1.1 1993/10/07 00:17:50 cgd Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include - -isnan(d) - double d; -{ - register struct IEEEdp { - u_int sign : 1; - u_int exp : 11; - u_int manh : 20; - u_int manl : 32; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && (p->manh || p->manl)); -} - -isinf(d) - double d; -{ - register struct IEEEdp { - u_int sign : 1; - u_int exp : 11; - u_int manh : 20; - u_int manl : 32; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && !p->manh && !p->manl); -} diff --git a/lib/libc/arch/hp300/gen/ldexp.S b/lib/libc/arch/hp300/gen/ldexp.S deleted file mode 100644 index 85d9c7cd1d37..000000000000 --- a/lib/libc/arch/hp300/gen/ldexp.S +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)ldexp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: ldexp.S,v 1.1 1993/10/07 00:17:51 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * double ldexp(val, exp) - * returns: val * (2**exp), for integer exp - */ -ENTRY(ldexp) - fmoved sp@(4),fp0 - fbeq Ldone - ftwotoxl sp@(12),fp1 - fmulx fp1,fp0 -Ldone: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/ldexp.s b/lib/libc/arch/hp300/gen/ldexp.s deleted file mode 100644 index 53c5abbe2b1f..000000000000 --- a/lib/libc/arch/hp300/gen/ldexp.s +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)ldexp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: ldexp.s,v 1.1 1993/10/07 00:17:51 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * double ldexp(val, exp) - * returns: val * (2**exp), for integer exp - */ -ENTRY(ldexp) - fmoved sp@(4),fp0 - fbeq Ldone - ftwotoxl sp@(12),fp1 - fmulx fp1,fp0 -Ldone: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/lshlsi3.S b/lib/libc/arch/hp300/gen/lshlsi3.S deleted file mode 100644 index 9f22401c39a5..000000000000 --- a/lib/libc/arch/hp300/gen/lshlsi3.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)lshlsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: lshlsi3.S,v 1.1 1993/10/07 00:17:52 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned << unsigned */ -ENTRY(__lshlsi3) - movel sp@(8),d1 - movel sp@(4),d0 - lsll d1,d0 - rts diff --git a/lib/libc/arch/hp300/gen/lshlsi3.s b/lib/libc/arch/hp300/gen/lshlsi3.s deleted file mode 100644 index 32fa7396d566..000000000000 --- a/lib/libc/arch/hp300/gen/lshlsi3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)lshlsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: lshlsi3.s,v 1.1 1993/10/07 00:17:52 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned << unsigned */ -ENTRY(__lshlsi3) - movel sp@(8),d1 - movel sp@(4),d0 - lsll d1,d0 - rts diff --git a/lib/libc/arch/hp300/gen/lshrsi3.S b/lib/libc/arch/hp300/gen/lshrsi3.S deleted file mode 100644 index b10554bbe9d4..000000000000 --- a/lib/libc/arch/hp300/gen/lshrsi3.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)lshrsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: lshrsi3.S,v 1.1 1993/10/07 00:17:53 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned >> unsigned */ -ENTRY(__lshrsi3) - movel sp@(8),d1 - movel sp@(4),d0 - lsrl d1,d0 - rts diff --git a/lib/libc/arch/hp300/gen/lshrsi3.s b/lib/libc/arch/hp300/gen/lshrsi3.s deleted file mode 100644 index 5419f4543298..000000000000 --- a/lib/libc/arch/hp300/gen/lshrsi3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)lshrsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: lshrsi3.s,v 1.1 1993/10/07 00:17:53 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned >> unsigned */ -ENTRY(__lshrsi3) - movel sp@(8),d1 - movel sp@(4),d0 - lsrl d1,d0 - rts diff --git a/lib/libc/arch/hp300/gen/modf.S b/lib/libc/arch/hp300/gen/modf.S deleted file mode 100644 index ab01af2a0feb..000000000000 --- a/lib/libc/arch/hp300/gen/modf.S +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)modf.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: modf.S,v 1.1 1993/10/07 00:17:54 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * double modf(val, iptr) - * returns: xxx and n (in *iptr) where val == n.xxx - */ -ENTRY(modf) - fmoved sp@(4),fp0 - movel sp@(12),a0 - fintrzx fp0,fp1 - fmoved fp1,a0@ - fsubx fp1,fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/modf.s b/lib/libc/arch/hp300/gen/modf.s deleted file mode 100644 index 205d94c0352e..000000000000 --- a/lib/libc/arch/hp300/gen/modf.s +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)modf.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: modf.s,v 1.1 1993/10/07 00:17:54 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * double modf(val, iptr) - * returns: xxx and n (in *iptr) where val == n.xxx - */ -ENTRY(modf) - fmoved sp@(4),fp0 - movel sp@(12),a0 - fintrzx fp0,fp1 - fmoved fp1,a0@ - fsubx fp1,fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/modsi3.S b/lib/libc/arch/hp300/gen/modsi3.S deleted file mode 100644 index 56b29490ef8a..000000000000 --- a/lib/libc/arch/hp300/gen/modsi3.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)modsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: modsi3.S,v 1.1 1993/10/07 00:17:55 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int % int */ -ENTRY(__modsi3) - movel sp@(4),d1 - divsll sp@(8),d0:d1 - rts diff --git a/lib/libc/arch/hp300/gen/modsi3.s b/lib/libc/arch/hp300/gen/modsi3.s deleted file mode 100644 index 6909f646a4fa..000000000000 --- a/lib/libc/arch/hp300/gen/modsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)modsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: modsi3.s,v 1.1 1993/10/07 00:17:55 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int % int */ -ENTRY(__modsi3) - movel sp@(4),d1 - divsll sp@(8),d0:d1 - rts diff --git a/lib/libc/arch/hp300/gen/muldf3.S b/lib/libc/arch/hp300/gen/muldf3.S deleted file mode 100644 index 956eb4dc5bcb..000000000000 --- a/lib/libc/arch/hp300/gen/muldf3.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)muldf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: muldf3.S,v 1.1 1993/10/07 00:17:56 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double * double */ -ENTRY(__muldf3) - fmoved sp@(4),fp0 - fmuld sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/muldf3.s b/lib/libc/arch/hp300/gen/muldf3.s deleted file mode 100644 index 925fbdc5303e..000000000000 --- a/lib/libc/arch/hp300/gen/muldf3.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)muldf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: muldf3.s,v 1.1 1993/10/07 00:17:56 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double * double */ -ENTRY(__muldf3) - fmoved sp@(4),fp0 - fmuld sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/mulsf3.S b/lib/libc/arch/hp300/gen/mulsf3.S deleted file mode 100644 index 1b69bc2f9a5b..000000000000 --- a/lib/libc/arch/hp300/gen/mulsf3.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)mulsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: mulsf3.S,v 1.1 1993/10/07 00:17:57 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single * single */ -ENTRY(__mulsf3) - fmoves sp@(4),fp0 - fmuls sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/hp300/gen/mulsf3.s b/lib/libc/arch/hp300/gen/mulsf3.s deleted file mode 100644 index 9b6bd2cc965a..000000000000 --- a/lib/libc/arch/hp300/gen/mulsf3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)mulsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: mulsf3.s,v 1.1 1993/10/07 00:17:57 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single * single */ -ENTRY(__mulsf3) - fmoves sp@(4),fp0 - fmuls sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/hp300/gen/mulsi3.S b/lib/libc/arch/hp300/gen/mulsi3.S deleted file mode 100644 index 4aa161c637b4..000000000000 --- a/lib/libc/arch/hp300/gen/mulsi3.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)mulsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: mulsi3.S,v 1.1 1993/10/07 00:17:58 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int * int */ -ENTRY(__mulsi3) - movel sp@(4),d0 - mulsl sp@(8),d0 - rts diff --git a/lib/libc/arch/hp300/gen/mulsi3.s b/lib/libc/arch/hp300/gen/mulsi3.s deleted file mode 100644 index 9331e2cdd88e..000000000000 --- a/lib/libc/arch/hp300/gen/mulsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)mulsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: mulsi3.s,v 1.1 1993/10/07 00:17:58 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int * int */ -ENTRY(__mulsi3) - movel sp@(4),d0 - mulsl sp@(8),d0 - rts diff --git a/lib/libc/arch/hp300/gen/negdf2.S b/lib/libc/arch/hp300/gen/negdf2.S deleted file mode 100644 index 2326f8e4248a..000000000000 --- a/lib/libc/arch/hp300/gen/negdf2.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)negdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: negdf2.S,v 1.1 1993/10/07 00:17:59 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* -double */ -ENTRY(__negdf2) - movel sp@(4),d0 - movel sp@(8),d1 - bchg #31,d0 - rts diff --git a/lib/libc/arch/hp300/gen/negdf2.s b/lib/libc/arch/hp300/gen/negdf2.s deleted file mode 100644 index 7dbce31da5fb..000000000000 --- a/lib/libc/arch/hp300/gen/negdf2.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)negdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: negdf2.s,v 1.1 1993/10/07 00:17:59 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* -double */ -ENTRY(__negdf2) - movel sp@(4),d0 - movel sp@(8),d1 - bchg #31,d0 - rts diff --git a/lib/libc/arch/hp300/gen/negsf2.S b/lib/libc/arch/hp300/gen/negsf2.S deleted file mode 100644 index 2b51ab21aa90..000000000000 --- a/lib/libc/arch/hp300/gen/negsf2.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)negsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: negsf2.S,v 1.1 1993/10/07 00:18:00 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* -single */ -ENTRY(__negsf2) - movel sp@(4),d0 - bchg #31,d0 - rts diff --git a/lib/libc/arch/hp300/gen/negsf2.s b/lib/libc/arch/hp300/gen/negsf2.s deleted file mode 100644 index e988d90b7e6d..000000000000 --- a/lib/libc/arch/hp300/gen/negsf2.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)negsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: negsf2.s,v 1.1 1993/10/07 00:18:00 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* -single */ -ENTRY(__negsf2) - movel sp@(4),d0 - bchg #31,d0 - rts diff --git a/lib/libc/arch/hp300/gen/saveregs.c b/lib/libc/arch/hp300/gen/saveregs.c deleted file mode 100644 index f5ec7354e265..000000000000 --- a/lib/libc/arch/hp300/gen/saveregs.c +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "from: @(#)saveregs.c 5.2 (Berkeley) 6/22/90";*/ -static char rcsid[] = "$Id: saveregs.c,v 1.1 1993/10/07 00:18:01 cgd Exp $"; -#endif /* LIBC_SCCS and not lint */ - -__builtin_saveregs() -{ - abort(); -} diff --git a/lib/libc/arch/hp300/gen/setjmp.S b/lib/libc/arch/hp300/gen/setjmp.S deleted file mode 100644 index 1111865474fb..000000000000 --- a/lib/libc/arch/hp300/gen/setjmp.S +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)setjmp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: setjmp.S,v 1.1 1993/10/07 00:18:02 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#include "DEFS.h" - -ENTRY(setjmp) - subql #8,sp /* space for sigstack args/rvals */ - clrl sp@ /* don't change it... */ - movl sp,sp@(4) /* ...but return the current val */ - jsr _sigstack /* note: onstack returned in sp@(4) */ - clrl sp@ /* don't change mask, just return */ - jsr _sigblock /* old value */ - movl sp@(4),d1 /* old onstack value */ - addql #8,sp - movl sp@(4),a0 /* save area pointer */ - movl d1,a0@+ /* save old onstack value */ - movl d0,a0@+ /* save old signal mask */ - lea sp@(4),a1 /* adjust saved SP since we won't rts */ - movl a1,a0@+ /* save old SP */ - movl a6,a0@+ /* save old FP */ - clrl a0@+ /* no AP */ - movl sp@,a0@+ /* save old PC */ - clrl a0@+ /* clean PS */ - moveml #0x3CFC,a0@ /* save remaining non-scratch regs */ - clrl d0 /* return 0 */ - rts - -ENTRY(longjmp) - movl sp@(4),a0 /* save area pointer */ - tstl a0@(8) /* ensure non-zero SP */ - jeq botch /* oops! */ - movl sp@(8),d0 /* grab return value */ - jne ok /* non-zero ok */ - moveq #1,d0 /* else make non-zero */ -ok: - moveml a0@(28),#0x3CFC /* restore non-scratch regs */ - movl a0,sp@- /* let sigreturn */ - jsr _sigreturn /* finish for us */ - -botch: - jsr _longjmperror - stop #0 diff --git a/lib/libc/arch/hp300/gen/setjmp.s b/lib/libc/arch/hp300/gen/setjmp.s deleted file mode 100644 index 8d45a0e443d8..000000000000 --- a/lib/libc/arch/hp300/gen/setjmp.s +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)setjmp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: setjmp.s,v 1.1 1993/10/07 00:18:02 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#include "DEFS.h" - -ENTRY(setjmp) - subql #8,sp /* space for sigstack args/rvals */ - clrl sp@ /* don't change it... */ - movl sp,sp@(4) /* ...but return the current val */ - jsr _sigstack /* note: onstack returned in sp@(4) */ - clrl sp@ /* don't change mask, just return */ - jsr _sigblock /* old value */ - movl sp@(4),d1 /* old onstack value */ - addql #8,sp - movl sp@(4),a0 /* save area pointer */ - movl d1,a0@+ /* save old onstack value */ - movl d0,a0@+ /* save old signal mask */ - lea sp@(4),a1 /* adjust saved SP since we won't rts */ - movl a1,a0@+ /* save old SP */ - movl a6,a0@+ /* save old FP */ - clrl a0@+ /* no AP */ - movl sp@,a0@+ /* save old PC */ - clrl a0@+ /* clean PS */ - moveml #0x3CFC,a0@ /* save remaining non-scratch regs */ - clrl d0 /* return 0 */ - rts - -ENTRY(longjmp) - movl sp@(4),a0 /* save area pointer */ - tstl a0@(8) /* ensure non-zero SP */ - jeq botch /* oops! */ - movl sp@(8),d0 /* grab return value */ - jne ok /* non-zero ok */ - moveq #1,d0 /* else make non-zero */ -ok: - moveml a0@(28),#0x3CFC /* restore non-scratch regs */ - movl a0,sp@- /* let sigreturn */ - jsr _sigreturn /* finish for us */ - -botch: - jsr _longjmperror - stop #0 diff --git a/lib/libc/arch/hp300/gen/subdf3.S b/lib/libc/arch/hp300/gen/subdf3.S deleted file mode 100644 index 5e21b47b87a1..000000000000 --- a/lib/libc/arch/hp300/gen/subdf3.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)subdf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: subdf3.S,v 1.1 1993/10/07 00:18:03 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double - double */ -ENTRY(__subdf3) - fmoved sp@(4),fp0 - fsubd sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/subdf3.s b/lib/libc/arch/hp300/gen/subdf3.s deleted file mode 100644 index ff3a58502306..000000000000 --- a/lib/libc/arch/hp300/gen/subdf3.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)subdf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: subdf3.s,v 1.1 1993/10/07 00:18:03 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double - double */ -ENTRY(__subdf3) - fmoved sp@(4),fp0 - fsubd sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/hp300/gen/subsf3.S b/lib/libc/arch/hp300/gen/subsf3.S deleted file mode 100644 index ff76633696a5..000000000000 --- a/lib/libc/arch/hp300/gen/subsf3.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)subsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: subsf3.S,v 1.1 1993/10/07 00:18:04 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single - single */ -ENTRY(__subsf3) - fmoves sp@(4),fp0 - fsubs sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/hp300/gen/subsf3.s b/lib/libc/arch/hp300/gen/subsf3.s deleted file mode 100644 index fa0f423c099d..000000000000 --- a/lib/libc/arch/hp300/gen/subsf3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)subsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: subsf3.s,v 1.1 1993/10/07 00:18:04 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single - single */ -ENTRY(__subsf3) - fmoves sp@(4),fp0 - fsubs sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/hp300/gen/truncdfsf2.S b/lib/libc/arch/hp300/gen/truncdfsf2.S deleted file mode 100644 index 3a432abac8ce..000000000000 --- a/lib/libc/arch/hp300/gen/truncdfsf2.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)truncdfsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: truncdfsf2.S,v 1.1 1993/10/07 00:18:05 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (float) double */ -ENTRY(__truncdfsf2) - fmoved sp@(4),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/hp300/gen/truncdfsf2.s b/lib/libc/arch/hp300/gen/truncdfsf2.s deleted file mode 100644 index c72a9ed52bfa..000000000000 --- a/lib/libc/arch/hp300/gen/truncdfsf2.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)truncdfsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: truncdfsf2.s,v 1.1 1993/10/07 00:18:05 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (float) double */ -ENTRY(__truncdfsf2) - fmoved sp@(4),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/hp300/gen/udivsi3.S b/lib/libc/arch/hp300/gen/udivsi3.S deleted file mode 100644 index 9f1ed0f5904f..000000000000 --- a/lib/libc/arch/hp300/gen/udivsi3.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)udivsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: udivsi3.S,v 1.1 1993/10/07 00:18:06 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned / unsigned */ -ENTRY(__udivsi3) - movel sp@(4),d0 - divul sp@(8),d0 - rts diff --git a/lib/libc/arch/hp300/gen/udivsi3.s b/lib/libc/arch/hp300/gen/udivsi3.s deleted file mode 100644 index 3d15afa452eb..000000000000 --- a/lib/libc/arch/hp300/gen/udivsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)udivsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: udivsi3.s,v 1.1 1993/10/07 00:18:06 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned / unsigned */ -ENTRY(__udivsi3) - movel sp@(4),d0 - divul sp@(8),d0 - rts diff --git a/lib/libc/arch/hp300/gen/umodsi3.S b/lib/libc/arch/hp300/gen/umodsi3.S deleted file mode 100644 index b65ce97ac319..000000000000 --- a/lib/libc/arch/hp300/gen/umodsi3.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)umodsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: umodsi3.S,v 1.1 1993/10/07 00:18:07 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned % unsigned */ -ENTRY(__umodsi3) - movel sp@(4),d1 - divull sp@(8),d0:d1 - rts diff --git a/lib/libc/arch/hp300/gen/umodsi3.s b/lib/libc/arch/hp300/gen/umodsi3.s deleted file mode 100644 index 37b84c1a65c7..000000000000 --- a/lib/libc/arch/hp300/gen/umodsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)umodsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: umodsi3.s,v 1.1 1993/10/07 00:18:07 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned % unsigned */ -ENTRY(__umodsi3) - movel sp@(4),d1 - divull sp@(8),d0:d1 - rts diff --git a/lib/libc/arch/hp300/gen/umulsi3.S b/lib/libc/arch/hp300/gen/umulsi3.S deleted file mode 100644 index b95e0bca7761..000000000000 --- a/lib/libc/arch/hp300/gen/umulsi3.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)umulsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: umulsi3.S,v 1.1 1993/10/07 00:18:09 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned * unsigned */ -ENTRY(__umulsi3) - movel sp@(4),d0 - mulul sp@(8),d0 - rts diff --git a/lib/libc/arch/hp300/gen/umulsi3.s b/lib/libc/arch/hp300/gen/umulsi3.s deleted file mode 100644 index 1ae5a6b44503..000000000000 --- a/lib/libc/arch/hp300/gen/umulsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)umulsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: umulsi3.s,v 1.1 1993/10/07 00:18:09 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned * unsigned */ -ENTRY(__umulsi3) - movel sp@(4),d0 - mulul sp@(8),d0 - rts diff --git a/lib/libc/arch/hp300/string/strcpy.S b/lib/libc/arch/hp300/string/strcpy.S deleted file mode 100644 index b5fa3aa1b183..000000000000 --- a/lib/libc/arch/hp300/string/strcpy.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strcpy.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strcpy.S,v 1.1 1993/10/07 00:18:30 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strcpy) - movl sp@(8),a0 /* a0 = fromaddr */ - movl sp@(4),d0 /* return value is toaddr */ - movl d0,a1 /* a1 = toaddr */ -scloop: - movb a0@+,a1@+ /* copy a byte */ - jne scloop /* copied non-null, keep going */ - rts diff --git a/lib/libc/arch/hp300/string/strcpy.s b/lib/libc/arch/hp300/string/strcpy.s deleted file mode 100644 index ad6b572eda4f..000000000000 --- a/lib/libc/arch/hp300/string/strcpy.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strcpy.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strcpy.s,v 1.1 1993/10/07 00:18:30 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strcpy) - movl sp@(8),a0 /* a0 = fromaddr */ - movl sp@(4),d0 /* return value is toaddr */ - movl d0,a1 /* a1 = toaddr */ -scloop: - movb a0@+,a1@+ /* copy a byte */ - jne scloop /* copied non-null, keep going */ - rts diff --git a/lib/libc/arch/hp300/string/strlen.S b/lib/libc/arch/hp300/string/strlen.S deleted file mode 100644 index 91fd809968de..000000000000 --- a/lib/libc/arch/hp300/string/strlen.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strlen.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strlen.S,v 1.1 1993/10/07 00:18:31 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strlen) - moveq #-1,d0 - movl sp@(4),a0 /* string */ -slloop: - addql #1,d0 /* increment count */ - tstb a0@+ /* null? */ - jne slloop /* no, keep going */ - rts diff --git a/lib/libc/arch/hp300/string/strlen.s b/lib/libc/arch/hp300/string/strlen.s deleted file mode 100644 index 062fa6bd729f..000000000000 --- a/lib/libc/arch/hp300/string/strlen.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strlen.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strlen.s,v 1.1 1993/10/07 00:18:31 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strlen) - moveq #-1,d0 - movl sp@(4),a0 /* string */ -slloop: - addql #1,d0 /* increment count */ - tstb a0@+ /* null? */ - jne slloop /* no, keep going */ - rts diff --git a/lib/libc/arch/hp300/string/strncmp.S b/lib/libc/arch/hp300/string/strncmp.S deleted file mode 100644 index bb8279b1c083..000000000000 --- a/lib/libc/arch/hp300/string/strncmp.S +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strncmp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strncmp.S,v 1.1 1993/10/07 00:18:32 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * NOTE: this guy returns result compatible with the VAX assembly version. - * The C version on the portable gen directory returns different results - * (different signs!) when comparing chars with the high bit on. Who is - * right?? - */ -ENTRY(strncmp) - movl sp@(12),d1 /* count */ - jeq scdone /* nothing to do */ - movl sp@(4),a0 /* a0 = string1 */ - movl sp@(8),a1 /* a1 = string2 */ -scloop: - movb a0@+,d0 /* get *string1 */ - cmpb a1@+,d0 /* compare a byte */ - jne scexit /* not equal, break out */ - tstb d0 /* at end of string1? */ - jeq scdone /* yes, all done */ - subql #1,d1 /* no, adjust count */ - jne scloop /* more to do, keep going */ -scdone: - moveq #0,d0 /* strings are equal */ - rts -scexit: - subb a1@-,d0 /* *string1 - *string2 */ - extbl d0 - rts diff --git a/lib/libc/arch/hp300/string/strncmp.s b/lib/libc/arch/hp300/string/strncmp.s deleted file mode 100644 index 0e3ea977269b..000000000000 --- a/lib/libc/arch/hp300/string/strncmp.s +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strncmp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strncmp.s,v 1.1 1993/10/07 00:18:32 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * NOTE: this guy returns result compatible with the VAX assembly version. - * The C version on the portable gen directory returns different results - * (different signs!) when comparing chars with the high bit on. Who is - * right?? - */ -ENTRY(strncmp) - movl sp@(12),d1 /* count */ - jeq scdone /* nothing to do */ - movl sp@(4),a0 /* a0 = string1 */ - movl sp@(8),a1 /* a1 = string2 */ -scloop: - movb a0@+,d0 /* get *string1 */ - cmpb a1@+,d0 /* compare a byte */ - jne scexit /* not equal, break out */ - tstb d0 /* at end of string1? */ - jeq scdone /* yes, all done */ - subql #1,d1 /* no, adjust count */ - jne scloop /* more to do, keep going */ -scdone: - moveq #0,d0 /* strings are equal */ - rts -scexit: - subb a1@-,d0 /* *string1 - *string2 */ - extbl d0 - rts diff --git a/lib/libc/arch/hp300/string/strncpy.S b/lib/libc/arch/hp300/string/strncpy.S deleted file mode 100644 index c79fbe048c58..000000000000 --- a/lib/libc/arch/hp300/string/strncpy.S +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strncpy.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strncpy.S,v 1.1 1993/10/07 00:18:33 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strncpy) - movl sp@(4),d0 /* return value is toaddr */ - movl sp@(12),d1 /* count */ - jeq scdone /* nothing to do */ - movl sp@(8),a0 /* a0 = fromaddr */ - movl d0,a1 /* a1 = toaddr */ -scloop: - movb a0@+,a1@+ /* copy a byte */ - jeq scploop /* copied null, go pad if necessary */ - subql #1,d1 /* adjust count */ - jne scloop /* more room, keep going */ -scdone: - rts -scploop: - subql #1,d1 /* adjust count */ - jeq scdone /* no more room, all done */ - clrb a1@+ /* clear a byte */ - jra scploop /* keep going */ diff --git a/lib/libc/arch/hp300/string/strncpy.s b/lib/libc/arch/hp300/string/strncpy.s deleted file mode 100644 index 37e3ffaabb1f..000000000000 --- a/lib/libc/arch/hp300/string/strncpy.s +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strncpy.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strncpy.s,v 1.1 1993/10/07 00:18:33 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strncpy) - movl sp@(4),d0 /* return value is toaddr */ - movl sp@(12),d1 /* count */ - jeq scdone /* nothing to do */ - movl sp@(8),a0 /* a0 = fromaddr */ - movl d0,a1 /* a1 = toaddr */ -scloop: - movb a0@+,a1@+ /* copy a byte */ - jeq scploop /* copied null, go pad if necessary */ - subql #1,d1 /* adjust count */ - jne scloop /* more room, keep going */ -scdone: - rts -scploop: - subql #1,d1 /* adjust count */ - jeq scdone /* no more room, all done */ - clrb a1@+ /* clear a byte */ - jra scploop /* keep going */ diff --git a/lib/libc/arch/hp300/sys/reboot.S b/lib/libc/arch/hp300/sys/reboot.S deleted file mode 100644 index be79e4395c59..000000000000 --- a/lib/libc/arch/hp300/sys/reboot.S +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)reboot.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: reboot.S,v 1.1 1993/10/07 00:18:43 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - stop #0 - diff --git a/lib/libc/arch/hp300/sys/reboot.s b/lib/libc/arch/hp300/sys/reboot.s deleted file mode 100644 index 744a7db632e0..000000000000 --- a/lib/libc/arch/hp300/sys/reboot.s +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)reboot.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: reboot.s,v 1.1 1993/10/07 00:18:43 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - stop #0 - diff --git a/lib/libc/arch/hp300/sys/sbrk.S b/lib/libc/arch/hp300/sys/sbrk.S deleted file mode 100644 index 8a2c60bf4831..000000000000 --- a/lib/libc/arch/hp300/sys/sbrk.S +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sbrk.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: sbrk.S,v 1.1 1993/10/07 00:18:44 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -#define SYS_brk 17 - - .globl _end - .globl minbrk - .globl curbrk - - .data -minbrk: .long _end -curbrk: .long _end - .text - -ENTRY(sbrk) - movl curbrk,d0 - addl d0,sp@(4) - movl #SYS_brk,d0 - trap #0 - jcs err - movl curbrk,d0 - movl sp@(4),curbrk - rts -err: - jmp cerror diff --git a/lib/libc/arch/hp300/sys/sbrk.s b/lib/libc/arch/hp300/sys/sbrk.s deleted file mode 100644 index 03f02e175fc7..000000000000 --- a/lib/libc/arch/hp300/sys/sbrk.s +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sbrk.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: sbrk.s,v 1.1 1993/10/07 00:18:44 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -#define SYS_brk 17 - - .globl _end - .globl minbrk - .globl curbrk - - .data -minbrk: .long _end -curbrk: .long _end - .text - -ENTRY(sbrk) - movl curbrk,d0 - addl d0,sp@(4) - movl #SYS_brk,d0 - trap #0 - jcs err - movl curbrk,d0 - movl sp@(4),curbrk - rts -err: - jmp cerror diff --git a/lib/libc/arch/hp300/sys/setlogin.S b/lib/libc/arch/hp300/sys/setlogin.S deleted file mode 100644 index 1b8ed1c00a98..000000000000 --- a/lib/libc/arch/hp300/sys/setlogin.S +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)setlogin.s 5.1 (Berkeley) 5/6/91"*/ - .asciz "$Id: setlogin.S,v 1.1 1993/10/07 00:18:45 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -.globl __logname_valid /* in getlogin() */ - -SYSCALL(setlogin) - movl #0,__logname_valid - rts /* setlogin(name) */ diff --git a/lib/libc/arch/hp300/sys/setlogin.s b/lib/libc/arch/hp300/sys/setlogin.s deleted file mode 100644 index a8e56812406a..000000000000 --- a/lib/libc/arch/hp300/sys/setlogin.s +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)setlogin.s 5.1 (Berkeley) 5/6/91"*/ - .asciz "$Id: setlogin.s,v 1.1 1993/10/07 00:18:45 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -.globl __logname_valid /* in getlogin() */ - -SYSCALL(setlogin) - movl #0,__logname_valid - rts /* setlogin(name) */ diff --git a/lib/libc/arch/hp300/sys/sigpending.S b/lib/libc/arch/hp300/sys/sigpending.S deleted file mode 100644 index 0b67682fd4d7..000000000000 --- a/lib/libc/arch/hp300/sys/sigpending.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigpending.s 5.2 (Berkeley) 8/6/90"*/ - .asciz "$Id: sigpending.S,v 1.1 1993/10/07 00:18:46 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(sigpending) - movl sp@(4),a0 - movl d0,a0@ - clrl d0 - rts diff --git a/lib/libc/arch/hp300/sys/sigpending.s b/lib/libc/arch/hp300/sys/sigpending.s deleted file mode 100644 index 9f95139e4baf..000000000000 --- a/lib/libc/arch/hp300/sys/sigpending.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigpending.s 5.2 (Berkeley) 8/6/90"*/ - .asciz "$Id: sigpending.s,v 1.1 1993/10/07 00:18:46 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(sigpending) - movl sp@(4),a0 - movl d0,a0@ - clrl d0 - rts diff --git a/lib/libc/arch/hp300/sys/sigprocmask.S b/lib/libc/arch/hp300/sys/sigprocmask.S deleted file mode 100644 index adb01b59d1f8..000000000000 --- a/lib/libc/arch/hp300/sys/sigprocmask.S +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigprocmask.s 5.2 (Berkeley) 6/6/90"*/ - .asciz "$Id: sigprocmask.S,v 1.1 1993/10/07 00:18:47 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - - .even -err: - jmp cerror - -ENTRY(sigprocmask) - tstl sp@(8) /* check new sigset pointer */ - jne gotptr /* if not null, indirect */ -/* movl #0,sp@(8) /* null mask pointer: block empty set */ - movl #1,sp@(4) /* SIG_BLOCK */ - jra doit -gotptr: - movl sp@(8),a0 - movl a0@,sp@(8) /* indirect to new mask arg */ -doit: - movl #SYS_sigprocmask,d0 - trap #0 - jcs err - tstl sp@(12) /* test if old mask requested */ - jeq out - movl sp@(12),a0 - movl d0,a0@ /* store old mask */ -out: - clrl d0 - rts diff --git a/lib/libc/arch/hp300/sys/sigprocmask.s b/lib/libc/arch/hp300/sys/sigprocmask.s deleted file mode 100644 index ce3ce151f690..000000000000 --- a/lib/libc/arch/hp300/sys/sigprocmask.s +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigprocmask.s 5.2 (Berkeley) 6/6/90"*/ - .asciz "$Id: sigprocmask.s,v 1.1 1993/10/07 00:18:47 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - - .even -err: - jmp cerror - -ENTRY(sigprocmask) - tstl sp@(8) /* check new sigset pointer */ - jne gotptr /* if not null, indirect */ -/* movl #0,sp@(8) /* null mask pointer: block empty set */ - movl #1,sp@(4) /* SIG_BLOCK */ - jra doit -gotptr: - movl sp@(8),a0 - movl a0@,sp@(8) /* indirect to new mask arg */ -doit: - movl #SYS_sigprocmask,d0 - trap #0 - jcs err - tstl sp@(12) /* test if old mask requested */ - jeq out - movl sp@(12),a0 - movl d0,a0@ /* store old mask */ -out: - clrl d0 - rts diff --git a/lib/libc/arch/hp300/sys/sigreturn.S b/lib/libc/arch/hp300/sys/sigreturn.S deleted file mode 100644 index 6a3e19467689..000000000000 --- a/lib/libc/arch/hp300/sys/sigreturn.S +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigreturn.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: sigreturn.S,v 1.1 1993/10/07 00:18:48 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef PROF -#undef ENTRY -#define ENTRY(x) \ - .globl _/**/x; .even; _/**/x:; moveml #0xC0C0,sp@-; .data; \ - PROF/**/x:; .long 0; .text; lea PROF/**/x,a0; jbsr mcount; \ - moveml sp@+,#0x0303 -#endif PROF - -ENTRY(sigreturn) - trap #1 /* signals sigreturn() */ - jmp cerror diff --git a/lib/libc/arch/hp300/sys/sigreturn.s b/lib/libc/arch/hp300/sys/sigreturn.s deleted file mode 100644 index c172d5006ef6..000000000000 --- a/lib/libc/arch/hp300/sys/sigreturn.s +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigreturn.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: sigreturn.s,v 1.1 1993/10/07 00:18:48 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef PROF -#undef ENTRY -#define ENTRY(x) \ - .globl _/**/x; .even; _/**/x:; moveml #0xC0C0,sp@-; .data; \ - PROF/**/x:; .long 0; .text; lea PROF/**/x,a0; jbsr mcount; \ - moveml sp@+,#0x0303 -#endif PROF - -ENTRY(sigreturn) - trap #1 /* signals sigreturn() */ - jmp cerror diff --git a/lib/libc/arch/hp300/sys/sigsuspend.S b/lib/libc/arch/hp300/sys/sigsuspend.S deleted file mode 100644 index 15fdf652bd60..000000000000 --- a/lib/libc/arch/hp300/sys/sigsuspend.S +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigsuspend.s 5.2 (Berkeley) 6/6/90"*/ - .asciz "$Id: sigsuspend.S,v 1.1 1993/10/07 00:18:49 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - - .even -err: - jmp cerror - -ENTRY(sigsuspend) - movl sp@(4),a0 - movl a0@,sp@(4) /* indirect to mask arg */ - movl #SYS_sigsuspend,d0 - trap #0 - jcs err - clrl d0 /* shouldn't happen */ - rts diff --git a/lib/libc/arch/hp300/sys/sigsuspend.s b/lib/libc/arch/hp300/sys/sigsuspend.s deleted file mode 100644 index a3a6010161da..000000000000 --- a/lib/libc/arch/hp300/sys/sigsuspend.s +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigsuspend.s 5.2 (Berkeley) 6/6/90"*/ - .asciz "$Id: sigsuspend.s,v 1.1 1993/10/07 00:18:49 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - - .even -err: - jmp cerror - -ENTRY(sigsuspend) - movl sp@(4),a0 - movl a0@,sp@(4) /* indirect to mask arg */ - movl #SYS_sigsuspend,d0 - trap #0 - jcs err - clrl d0 /* shouldn't happen */ - rts diff --git a/lib/libc/arch/hp300/sys/syscall.S b/lib/libc/arch/hp300/sys/syscall.S deleted file mode 100644 index 7c7371b1cc4b..000000000000 --- a/lib/libc/arch/hp300/sys/syscall.S +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)syscall.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: syscall.S,v 1.1 1993/10/07 00:18:50 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(syscall) - clrl d0 - trap #0 - jcs err - rts -err: - jmp cerror diff --git a/lib/libc/arch/hp300/sys/syscall.s b/lib/libc/arch/hp300/sys/syscall.s deleted file mode 100644 index f71d18301116..000000000000 --- a/lib/libc/arch/hp300/sys/syscall.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)syscall.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: syscall.s,v 1.1 1993/10/07 00:18:50 cgd Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(syscall) - clrl d0 - trap #0 - jcs err - rts -err: - jmp cerror diff --git a/lib/libc/arch/i386/gen/modf.s b/lib/libc/arch/i386/gen/modf.s deleted file mode 100644 index bad09be95cea..000000000000 --- a/lib/libc/arch/i386/gen/modf.s +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * 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, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)modf.s 5.5 (Berkeley) 3/18/91 - * $Id: modf.s,v 1.2 1993/10/21 01:40:01 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: modf.s,v 1.2 1993/10/21 01:40:01 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * 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. */ -ENTRY(modf) - pushl %ebp - movl %esp,%ebp - subl $16,%esp - fnstcw -12(%ebp) - movw -12(%ebp),%dx - orw $3072,%dx - movw %dx,-16(%ebp) - fldcw -16(%ebp) - fldl 8(%ebp) - frndint - fstpl -8(%ebp) - fldcw -12(%ebp) - movl 16(%ebp),%eax - movl -8(%ebp),%edx - movl -4(%ebp),%ecx - movl %edx,(%eax) - movl %ecx,4(%eax) - fldl 8(%ebp) - fsubl -8(%ebp) - jmp L1 -L1: - leave - ret diff --git a/lib/libc/arch/i386/gen/setjmp.s b/lib/libc/arch/i386/gen/setjmp.s deleted file mode 100644 index c6009b4a8433..000000000000 --- a/lib/libc/arch/i386/gen/setjmp.s +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 - * $Id: setjmp.s,v 1.4 1993/10/21 01:48:16 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: setjmp.s,v 1.4 1993/10/21 01:48:16 jtc Exp $" -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -#include "DEFS.h" -#include "SYS.h" - -ENTRY(setjmp) - pushl $0 - call PIC_PLT(_sigblock) - popl %edx - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - movl %eax,24(%ecx) - xorl %eax,%eax - ret - -ENTRY(longjmp) - movl 4(%esp),%edx - pushl 24(%edx) - call PIC_PLT(_sigsetmask) - popl %eax - movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/arch/i386/gen/sigsetjmp.s b/lib/libc/arch/i386/gen/sigsetjmp.s deleted file mode 100644 index 82ed3491b157..000000000000 --- a/lib/libc/arch/i386/gen/sigsetjmp.s +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90" - * $Id: sigsetjmp.s,v 1.5 1993/10/21 01:59:44 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: sigsetjmp.s,v 1.5 1993/10/21 01:59:44 jtc Exp $" -#endif - -#include "DEFS.h" -#include "SYS.h" - -ENTRY(sigsetjmp) - movl 8(%esp),%eax - movl 4(%esp),%ecx - movl %eax,24(%ecx) - testl %eax,%eax - jz 1f - pushl $0 - call PIC_PLT(_sigblock) - addl $4,%esp - movl 4(%esp),%ecx - movl %eax,28(%ecx) -1: movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - xorl %eax,%eax - ret - -ENTRY(siglongjmp) - movl 4(%esp),%edx - cmpl $0,24(%edx) - jz 1f - pushl 28(%edx) - call PIC_PLT(_sigsetmask) - addl $4,%esp -1: movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - testl %eax,%eax - jne 2f - incl %eax -2: movl %ecx,0(%esp) - ret diff --git a/lib/libc/arch/i386/gen/udivsi3.s b/lib/libc/arch/i386/gen/udivsi3.s deleted file mode 100644 index a0af1a085481..000000000000 --- a/lib/libc/arch/i386/gen/udivsi3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)udivsi3.s 5.1 (Berkeley) 5/15/90 - * $Id: udivsi3.s,v 1.3 1993/10/21 02:03:40 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: udivsi3.s,v 1.3 1993/10/21 02:03:40 jtc Exp $" -#endif - -#include "DEFS.h" - -ENTRY(__udivsi3) - movl 4(%esp),%eax - xorl %edx,%edx - divl 8(%esp) - ret diff --git a/lib/libc/arch/i386/string/memmove.s b/lib/libc/arch/i386/string/memmove.s deleted file mode 100644 index cd582701ae63..000000000000 --- a/lib/libc/arch/i386/string/memmove.s +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from locore.s. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id: memmove.s,v 1.2 1993/10/21 01:40:34 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: memmove.s,v 1.2 1993/10/21 01:40:34 jtc Exp $" -#endif - -#include "DEFS.h" - - /* - * (ov)bcopy (src,dst,cnt) - * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 - */ - -TWOENTRY(memmove,memcpy) - pushl %esi - pushl %edi - movl 12(%esp),%edi - pushl %edi - movl 20(%esp),%esi - movl 24(%esp),%ecx - cmpl %esi,%edi /* potentially overlapping? */ - jnb 1f - cld /* nope, copy forwards. */ - shrl $2,%ecx /* copy by words */ - rep - movsl - movl 24(%esp),%ecx - andl $3,%ecx /* any bytes left? */ - rep - movsb - popl %eax - popl %edi - popl %esi - ret -1: - addl %ecx,%edi /* copy backwards. */ - addl %ecx,%esi - std - andl $3,%ecx /* any fractional bytes? */ - decl %edi - decl %esi - rep - movsb - movl 24(%esp),%ecx /* copy remainder by words */ - shrl $2,%ecx - subl $3,%esi - subl $3,%edi - rep - movsl - popl %eax - popl %edi - popl %esi - cld - ret diff --git a/lib/libc/arch/i386/string/memset.s b/lib/libc/arch/i386/string/memset.s deleted file mode 100644 index 9d511935d693..000000000000 --- a/lib/libc/arch/i386/string/memset.s +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: memset.s,v 1.3 1993/10/21 01:48:33 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: memset.s,v 1.3 1993/10/21 01:48:33 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * memset(void *b, int c, size_t len) - * write len bytes of value c (converted to an unsigned char) to - * the string b. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(memset) - pushl %edi - pushl %ebx - movl 12(%esp),%edi - movzbl 16(%esp),%eax /* unsigned char, zero extend */ - movl 20(%esp),%ecx - pushl %edi /* push address of buffer */ - - cld /* set fill direction forward */ - - /* - * if the string is too short, it's really not worth the overhead - * of aligning to word boundries, etc. So we jump to a plain - * unaligned set. - */ - cmpl $0x0f,%ecx - jle L1 - - movl %eax,%edx /* copy value to all bytes in word */ - sall $8,%edx /* XXX is there a better way? */ - orl %edx,%eax - movl %eax,%edx - sall $16,%edx - orl %edx,%eax - - movl %edi,%edx /* compute misalignment */ - negl %edx - andl $3,%edx - movl %ecx,%ebx - subl %edx,%ebx - - movl %edx,%ecx /* set until word aligned */ - rep - stosb - - movl %ebx,%ecx - shrl $2,%ecx /* set by words */ - rep - stosl - - movl %ebx,%ecx /* set remainder by bytes */ - andl $3,%ecx -L1: rep - stosb - - popl %eax /* pop address of buffer */ - popl %ebx - popl %edi - ret diff --git a/lib/libc/arch/i386/string/rindex.s b/lib/libc/arch/i386/string/rindex.s deleted file mode 100644 index 69ff23c4aaea..000000000000 --- a/lib/libc/arch/i386/string/rindex.s +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: rindex.s,v 1.3 1993/10/21 01:48:34 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: rindex.s,v 1.3 1993/10/21 01:48:34 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * rindex(s, c) - * return a pointer to the last occurance of the character c in - * string s, or NULL if c does not occur in the string. - * - * %edx - pointer iterating through string - * %eax - pointer to last occurance of 'c' - * %cl - character we're comparing against - * %bl - character at %edx - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(rindex) - pushl %ebx - movl 8(%esp),%edx - movb 12(%esp),%cl - xorl %eax,%eax /* init pointer to null */ - .align 2,0x90 -L1: - movb (%edx),%bl - cmpb %bl,%cl - jne L2 - movl %edx,%eax -L2: - incl %edx - testb %bl,%bl /* null terminator??? */ - jne L1 - popl %ebx - ret diff --git a/lib/libc/arch/i386/string/strcat.s b/lib/libc/arch/i386/string/strcat.s deleted file mode 100644 index dd4d620d4f94..000000000000 --- a/lib/libc/arch/i386/string/strcat.s +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcat.s,v 1.2 1993/10/21 01:40:37 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcat.s,v 1.2 1993/10/21 01:40:37 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strcat(s, append) - * append a copy of the null-terminated string "append" to the end - * of the null-terminated string s, then add a terminating `\0'. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcat) - pushl %edi /* save edi */ - movl 8(%esp),%edi /* dst address */ - movl 12(%esp),%edx /* src address */ - pushl %edi /* push destination address */ - - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - - leal -1(%edi),%ecx /* correct dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - je L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - je L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - je L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - je L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - je L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - je L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - je L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jne L1 -L2: popl %eax /* pop destination address */ - popl %edi /* restore edi */ - ret diff --git a/lib/libc/arch/i386/string/strchr.s b/lib/libc/arch/i386/string/strchr.s deleted file mode 100644 index 767f17021ac3..000000000000 --- a/lib/libc/arch/i386/string/strchr.s +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strchr.s,v 1.2 1993/10/21 01:40:38 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strchr.s,v 1.2 1993/10/21 01:40:38 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strchr(s, c) - * return a pointer to the first occurance of the character c in - * string s, or NULL if c does not occur in the string. - * - * %edx - pointer iterating through string - * %eax - pointer to first occurance of 'c' - * %cl - character we're comparing against - * %bl - character at %edx - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strchr) - pushl %ebx - movl 8(%esp),%eax - movb 12(%esp),%cl - .align 2,0x90 -L1: - movb (%eax),%bl - cmpb %bl,%cl /* found char??? */ - je L2 - incl %eax - testb %bl,%bl /* null terminator??? */ - jne L1 - xorl %eax,%eax -L2: - popl %ebx - ret diff --git a/lib/libc/arch/i386/string/strcmp.s b/lib/libc/arch/i386/string/strcmp.s deleted file mode 100644 index 9a7011e1cdd9..000000000000 --- a/lib/libc/arch/i386/string/strcmp.s +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcmp.s,v 1.4 1993/10/21 01:48:35 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcmp.s,v 1.4 1993/10/21 01:48:35 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strcmp(s1, s2) - * return an integer greater than, equal to, or less than 0, - * according as string s1 is greater than, equal to, or less - * than the string s2. - * - * %eax - pointer to s1 - * %edx - pointer to s2 - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcmp) - movl 0x04(%esp),%eax - movl 0x08(%esp),%edx - jmp L2 /* Jump into the loop! */ - - .align 2,0x90 -L1: incl %eax - incl %edx -L2: movb (%eax),%cl - testb %cl,%cl /* null terminator??? */ - je L3 - cmpb %cl,(%edx) /* chars match??? */ - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - je L1 - .align 2, 0x90 -L3: movsbl (%eax),%eax /* unsigned comparison */ - movsbl (%edx),%edx - subl %edx,%eax - ret diff --git a/lib/libc/arch/i386/string/strcpy.s b/lib/libc/arch/i386/string/strcpy.s deleted file mode 100644 index 0b57b75b0334..000000000000 --- a/lib/libc/arch/i386/string/strcpy.s +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcpy.s,v 1.2 1993/10/21 01:40:40 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcpy.s,v 1.2 1993/10/21 01:40:40 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strcpy (dst, src) - * copy the string src to dst. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcpy) - movl 4(%esp),%ecx /* dst address */ - movl 8(%esp),%edx /* src address */ - pushl %ecx /* push dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - je L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - je L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - je L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - je L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - je L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - je L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - je L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jne L1 -L2: popl %eax /* pop dst address */ - ret diff --git a/lib/libc/arch/i386/string/strlen.s b/lib/libc/arch/i386/string/strlen.s deleted file mode 100644 index 8fa3180ed709..000000000000 --- a/lib/libc/arch/i386/string/strlen.s +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strlen.s,v 1.2 1993/10/21 01:40:41 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strlen.s,v 1.2 1993/10/21 01:40:41 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strlen (s) - * compute the length of the string s. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strlen) - pushl %edi - movl 8(%esp),%edi /* string address */ - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - notl %ecx /* get length by taking complement */ - leal -1(%ecx),%eax /* and subtracting one */ - popl %edi - ret diff --git a/lib/libc/arch/i386/string/strncmp.s b/lib/libc/arch/i386/string/strncmp.s deleted file mode 100644 index 3ff0a2f7aa02..000000000000 --- a/lib/libc/arch/i386/string/strncmp.s +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strncmp.s,v 1.4 1993/10/21 01:48:36 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strncmp.s,v 1.4 1993/10/21 01:48:36 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strncmp(s1, s2, n) - * return an integer greater than, equal to, or less than 0, - * according as the first n characters of string s1 is greater - * than, equal to, or less than the string s2. - * - * %eax - pointer to s1 - * %ecx - pointer to s2 - * %edx - length - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strncmp) - pushl %ebx - movl 8(%esp),%eax - movl 12(%esp),%ecx - movl 16(%esp),%edx - jmp L2 /* Jump into the loop! */ - - .align 2,0x90 -L1: incl %eax - incl %ecx - decl %edx -L2: testl %edx,%edx /* Have we compared n chars yet? */ - jle L4 /* Yes, strings are equal */ - movb (%eax),%bl - testb %bl,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - testb %bl,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - testb %bl,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - testb %bl,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - testb %bl,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - testb %bl,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - testb %bl,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - testb %bl,%bl - je L3 - cmpb %bl,(%ecx) - je L1 - .align 2,0x90 -L3: movsbl (%eax),%eax /* unsigned comparision */ - movsbl (%ecx),%ecx - subl %ecx,%eax - popl %ebx - ret - .align 2,0x90 -L4: xorl %eax,%eax - popl %ebx - ret diff --git a/lib/libc/arch/i386/string/strrchr.s b/lib/libc/arch/i386/string/strrchr.s deleted file mode 100644 index 2867823882bb..000000000000 --- a/lib/libc/arch/i386/string/strrchr.s +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strrchr.s,v 1.3 1993/10/21 01:48:37 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strrchr.s,v 1.3 1993/10/21 01:48:37 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strrchr(s, c) - * return a pointer to the last occurance of the character c in - * string s, or NULL if c does not occur in the string. - * - * %edx - pointer iterating through string - * %eax - pointer to last occurance of 'c' - * %cl - character we're comparing against - * %bl - character at %edx - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strrchr) - pushl %ebx - movl 8(%esp),%edx - movb 12(%esp),%cl - xorl %eax,%eax /* init pointer to null */ - .align 2,0x90 -L1: - movb (%edx),%bl - cmpb %bl,%cl - jne L2 - movl %edx,%eax -L2: - incl %edx - testb %bl,%bl /* null terminator??? */ - jne L1 - popl %ebx - ret diff --git a/lib/libc/arch/i386/string/swab.s b/lib/libc/arch/i386/string/swab.s deleted file mode 100644 index 0b307c18da01..000000000000 --- a/lib/libc/arch/i386/string/swab.s +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: swab.s,v 1.4 1993/11/25 01:18:24 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: swab.s,v 1.4 1993/11/25 01:18:24 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * void - * swab (const void *src, void *dst, size_t len) - * copy len bytes from src to dst, swapping adjacent bytes - * - * On the i486, this code is negligibly faster than the code generated - * by gcc at about half the size. If my i386 databook is correct, it - * should be considerably faster than the gcc code on a i386. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(swab) - pushl %esi - pushl %edi - movl 12(%esp),%esi - movl 16(%esp),%edi - movl 20(%esp),%ecx - - cld # set direction forward - - shrl $1,%ecx - testl $7,%ecx # copy first group of 1 to 7 words - jz L2 # while swaping alternate bytes. - .align 2,0x90 -L1: lodsw - xchgb %al,%ah - stosw - decl %ecx - testl $7,%ecx - jnz L1 - -L2: shrl $3,%ecx # copy remainder 8 words at a time - jz L4 # while swapping alternate bytes. - .align 2,0x90 -L3: lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - decl %ecx - jnz L3 - -L4: - popl %edi - popl %esi - ret diff --git a/lib/libc/arch/i386/sys/reboot.s b/lib/libc/arch/i386/sys/reboot.s deleted file mode 100644 index f95d888a5300..000000000000 --- a/lib/libc/arch/i386/sys/reboot.s +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)reboot.s 5.1 (Berkeley) 4/23/90 - * $Id: reboot.s,v 1.2 1993/10/21 02:19:34 jtc Exp $ - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - .asciz "$Id: reboot.s,v 1.2 1993/10/21 02:19:34 jtc Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - iret diff --git a/lib/libc/arch/i386/sys/sbrk.s b/lib/libc/arch/i386/sys/sbrk.s deleted file mode 100644 index 5a6d02c273d8..000000000000 --- a/lib/libc/arch/i386/sys/sbrk.s +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sbrk.s 5.1 (Berkeley) 4/23/90 - * $Id: sbrk.s,v 1.2 1993/10/21 02:19:36 jtc Exp $ - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - .asciz "$Id: sbrk.s,v 1.2 1993/10/21 02:19:36 jtc Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#define SYS_brk 17 - - .globl _end - .globl minbrk - .globl curbrk - - .data -minbrk: .long _end -curbrk: .long _end - .text - -ENTRY(sbrk) -#ifdef PIC - movl 4(%esp),%ecx - PIC_PROLOGUE - movl PIC_GOT(curbrk),%edx - movl (%edx),%eax - PIC_EPILOGUE - addl %eax,4(%esp) - lea SYS_brk,%eax - LCALL(7,0) - jb err - PIC_PROLOGUE - movl PIC_GOT(curbrk),%edx - movl (%edx),%eax - addl %ecx,(%edx) - PIC_EPILOGUE - ret -err: - jmp PIC_PLT(cerror) - -#else - - movl 4(%esp),%ecx - movl curbrk,%eax - addl %eax,4(%esp) - lea SYS_brk,%eax - LCALL(7,0) - jb err - movl curbrk,%eax - addl %ecx,curbrk - ret -err: - jmp cerror -#endif diff --git a/lib/libc/arch/i386/sys/setlogin.s b/lib/libc/arch/i386/sys/setlogin.s deleted file mode 100644 index 2b4420c89e5c..000000000000 --- a/lib/libc/arch/i386/sys/setlogin.s +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)setlogin.s 5.2 (Berkeley) 4/12/91 - * $Id: setlogin.s,v 1.3 1993/10/21 02:19:37 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: setlogin.s,v 1.3 1993/10/21 02:19:37 jtc Exp $" -#endif - -#include "SYS.h" - -.globl __logname_valid /* in getlogin() */ - -SYSCALL(setlogin) -#ifdef PIC - PIC_PROLOGUE - pushl %eax - movl PIC_GOT(__logname_valid),%eax - movl $0,(%eax) - popl %eax - PIC_EPILOGUE -#else - movl $0,__logname_valid -#endif - ret /* setlogin(name) */ diff --git a/lib/libc/arch/i386/sys/sigpending.s b/lib/libc/arch/i386/sys/sigpending.s deleted file mode 100644 index 7fb94bd79029..000000000000 --- a/lib/libc/arch/i386/sys/sigpending.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sigpending.s 5.1 (Berkeley) 7/1/90 - * $Id: sigpending.s,v 1.2 1993/10/21 02:19:38 jtc Exp $ - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - .asciz "$Id: sigpending.s,v 1.2 1993/10/21 02:19:38 jtc Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(sigpending) - movl 4(%esp),%ecx # fetch pointer to... - movl %eax,(%ecx) # store old mask - xorl %eax,%eax - ret diff --git a/lib/libc/arch/i386/sys/sigprocmask.s b/lib/libc/arch/i386/sys/sigprocmask.s deleted file mode 100644 index abb5dc08be4c..000000000000 --- a/lib/libc/arch/i386/sys/sigprocmask.s +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sigprocmask.s 5.2 (Berkeley) 12/17/90 - * $Id: sigprocmask.s,v 1.2 1993/10/21 02:19:39 jtc Exp $ - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - .asciz "$Id: sigprocmask.s,v 1.2 1993/10/21 02:19:39 jtc Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -err: - jmp cerror - -ENTRY(sigprocmask) - movl 8(%esp),%ecx # fetch new sigset pointer - cmpl $0,%ecx # check new sigset pointer - jne 1f # if not null, indirect -/* movl $0,8(%esp) # null mask pointer: block empty set */ - movl $1,4(%esp) # SIG_BLOCK - jmp 2f -1: movl (%ecx),%ecx # fetch indirect ... - movl %ecx,8(%esp) # to new mask arg -2: movl $/**/SYS_sigprocmask , %eax - LCALL(0x7,0) - jb err - movl 12(%esp),%ecx # fetch old mask requested - cmpl $0,%ecx # test if old mask requested - je out - movl %eax,(%ecx) # store old mask -out: - xorl %eax,%eax - ret diff --git a/lib/libc/arch/i386/sys/sigreturn.s b/lib/libc/arch/i386/sys/sigreturn.s deleted file mode 100644 index 594395561c4a..000000000000 --- a/lib/libc/arch/i386/sys/sigreturn.s +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90" - * $Id: sigreturn.s,v 1.2 1993/10/21 02:19:40 jtc Exp $ - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - .asciz "$Id: sigreturn.s,v 1.2 1993/10/21 02:19:40 jtc Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef PROF -#undef ENTRY -#define ENTRY(x) \ - .globl _/**/x; .align 2; _/**/x: pusha ; \ - .data; 1:; .long 0; .text; movl $1b,%eax; call mcount; popa ; nop -#endif /* PROF */ - -SYSCALL(sigreturn) - ret diff --git a/lib/libc/arch/i386/sys/sigsuspend.s b/lib/libc/arch/i386/sys/sigsuspend.s deleted file mode 100644 index 77aa2ac40977..000000000000 --- a/lib/libc/arch/i386/sys/sigsuspend.s +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sigsuspend.s 5.2 (Berkeley) 12/17/90 - * $Id: sigsuspend.s,v 1.2 1993/10/21 02:19:41 jtc Exp $ - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - .asciz "$Id: sigsuspend.s,v 1.2 1993/10/21 02:19:41 jtc Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -err: - jmp cerror - -ENTRY(sigsuspend) - movl 4(%esp),%eax # fetch mask arg - movl (%eax),%eax # indirect to mask arg - movl %eax,4(%esp) - movl $/**/SYS_sigsuspend ,%eax - LCALL(0x7,0) - jb err - xorl %eax,%eax # shouldn t happen - ret diff --git a/lib/libc/arch/i386/sys/syscall.s b/lib/libc/arch/i386/sys/syscall.s deleted file mode 100644 index 626277eccaec..000000000000 --- a/lib/libc/arch/i386/sys/syscall.s +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90 - * $Id: syscall.s,v 1.2 1993/10/21 02:19:43 jtc Exp $ - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - .asciz "$Id: syscall.s,v 1.2 1993/10/21 02:19:43 jtc Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(syscall) - pop %ecx /* rta */ - pop %eax /* syscall number */ - push %ecx - LCALL(7,0) - push %ecx /* Keep stack frame consistant */ - jb 1f - ret -1: - jmp cerror diff --git a/lib/libc/arch/m68k/gen/cmpdf2.s b/lib/libc/arch/m68k/gen/cmpdf2.s deleted file mode 100644 index e492177a72f4..000000000000 --- a/lib/libc/arch/m68k/gen/cmpdf2.s +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)cmpdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: cmpdf2.s,v 1.1 1993/11/25 23:36:53 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double > double: 1 */ -/* double < double: -1 */ -/* double == double: 0 */ -ENTRY(__cmpdf2) - fmoved sp@(4),fp0 - fcmpd sp@(12),fp0 - fbgt Lagtb - fslt d0 - extbl d0 - rts -Lagtb: - moveq #1,d0 - rts diff --git a/lib/libc/arch/m68k/gen/cmpsf2.s b/lib/libc/arch/m68k/gen/cmpsf2.s deleted file mode 100644 index 0b862c9dd45d..000000000000 --- a/lib/libc/arch/m68k/gen/cmpsf2.s +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)cmpsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: cmpsf2.s,v 1.1 1993/11/25 23:36:54 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single > single: 1 */ -/* single < single: -1 */ -/* single == single: 0 */ -ENTRY(__cmpsf2) - fmoves sp@(4),fp0 - fcmps sp@(8),fp0 - fbgt Lagtb - fslt d0 - extbl d0 - rts -Lagtb: - moveq #1,d0 - rts diff --git a/lib/libc/arch/m68k/gen/divdf3.s b/lib/libc/arch/m68k/gen/divdf3.s deleted file mode 100644 index e6b3a332879f..000000000000 --- a/lib/libc/arch/m68k/gen/divdf3.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divdf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divdf3.s,v 1.1 1993/11/25 23:36:55 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double / double */ -ENTRY(__divdf3) - fmoved sp@(4),fp0 - fdivd sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/m68k/gen/divsf3.s b/lib/libc/arch/m68k/gen/divsf3.s deleted file mode 100644 index 605e9ea5a13c..000000000000 --- a/lib/libc/arch/m68k/gen/divsf3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divsf3.s,v 1.1 1993/11/25 23:36:56 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single / single */ -ENTRY(__divsf3) - fmoves sp@(4),fp0 - fdivs sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/m68k/gen/divsi3.s b/lib/libc/arch/m68k/gen/divsi3.s deleted file mode 100644 index bf8ca6f8ac16..000000000000 --- a/lib/libc/arch/m68k/gen/divsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divsi3.s,v 1.1 1993/11/25 23:36:57 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int / int */ -ENTRY(__divsi3) - movel sp@(4),d0 - divsl sp@(8),d0 - rts diff --git a/lib/libc/arch/m68k/gen/extendsfdf2.s b/lib/libc/arch/m68k/gen/extendsfdf2.s deleted file mode 100644 index a2d1d96c5b9b..000000000000 --- a/lib/libc/arch/m68k/gen/extendsfdf2.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)extendsfdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: extendsfdf2.s,v 1.1 1993/11/25 23:36:58 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (double) float */ -ENTRY(__extendsfdf2) - fmoves sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/m68k/gen/fabs.s b/lib/libc/arch/m68k/gen/fabs.s deleted file mode 100644 index d69e6c3a684f..000000000000 --- a/lib/libc/arch/m68k/gen/fabs.s +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fabs.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: fabs.s,v 1.1 1993/11/25 23:36:59 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* fabs - floating absolute value */ - -#include "DEFS.h" - -ENTRY(fabs) - fmoved sp@(4),fp0 - fjnlt L1 - fnegx fp0 -L1: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/m68k/gen/fixdfsi.s b/lib/libc/arch/m68k/gen/fixdfsi.s deleted file mode 100644 index a43db8e06dd6..000000000000 --- a/lib/libc/arch/m68k/gen/fixdfsi.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fixdfsi.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: fixdfsi.s,v 1.1 1993/11/25 23:37:00 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (int) double */ -ENTRY(__fixdfsi) - fintrzd sp@(4),fp0 - fmovel fp0,d0 - rts diff --git a/lib/libc/arch/m68k/gen/fixunsdfsi.s b/lib/libc/arch/m68k/gen/fixunsdfsi.s deleted file mode 100644 index 34462fbfe0e0..000000000000 --- a/lib/libc/arch/m68k/gen/fixunsdfsi.s +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fixunsdfsi.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: fixunsdfsi.s,v 1.1 1993/11/25 23:37:02 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (unsigned) double */ -ENTRY(__fixunsdfsi) - fintrzd sp@(4),fp0 - fcmpd #0r2147483648.0,fp0 - fbge Lwaybig - fmovel fp0,d0 - rts -Lwaybig: - fsubd #0r2147483648.0,fp0 - fmovel fp0,d0 - bset #31,d0 - rts diff --git a/lib/libc/arch/m68k/gen/floatsidf.s b/lib/libc/arch/m68k/gen/floatsidf.s deleted file mode 100644 index 91cab0f20df2..000000000000 --- a/lib/libc/arch/m68k/gen/floatsidf.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)floatsidf.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: floatsidf.s,v 1.1 1993/11/25 23:37:03 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (double) int */ -ENTRY(__floatsidf) - fmovel sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - diff --git a/lib/libc/arch/m68k/gen/ldexp.s b/lib/libc/arch/m68k/gen/ldexp.s deleted file mode 100644 index 00eee1da919b..000000000000 --- a/lib/libc/arch/m68k/gen/ldexp.s +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)ldexp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: ldexp.s,v 1.1 1993/11/25 23:37:07 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * double ldexp(val, exp) - * returns: val * (2**exp), for integer exp - */ -ENTRY(ldexp) - fmoved sp@(4),fp0 - fbeq Ldone - ftwotoxl sp@(12),fp1 - fmulx fp1,fp0 -Ldone: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/m68k/gen/lshlsi3.s b/lib/libc/arch/m68k/gen/lshlsi3.s deleted file mode 100644 index 7cf122f15fc9..000000000000 --- a/lib/libc/arch/m68k/gen/lshlsi3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)lshlsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: lshlsi3.s,v 1.1 1993/11/25 23:37:08 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned << unsigned */ -ENTRY(__lshlsi3) - movel sp@(8),d1 - movel sp@(4),d0 - lsll d1,d0 - rts diff --git a/lib/libc/arch/m68k/gen/lshrsi3.s b/lib/libc/arch/m68k/gen/lshrsi3.s deleted file mode 100644 index 74e2756b6586..000000000000 --- a/lib/libc/arch/m68k/gen/lshrsi3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)lshrsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: lshrsi3.s,v 1.1 1993/11/25 23:37:09 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned >> unsigned */ -ENTRY(__lshrsi3) - movel sp@(8),d1 - movel sp@(4),d0 - lsrl d1,d0 - rts diff --git a/lib/libc/arch/m68k/gen/modf.s b/lib/libc/arch/m68k/gen/modf.s deleted file mode 100644 index 463a52abf4e8..000000000000 --- a/lib/libc/arch/m68k/gen/modf.s +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)modf.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: modf.s,v 1.1 1993/11/25 23:37:10 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * double modf(val, iptr) - * returns: xxx and n (in *iptr) where val == n.xxx - */ -ENTRY(modf) - fmoved sp@(4),fp0 - movel sp@(12),a0 - fintrzx fp0,fp1 - fmoved fp1,a0@ - fsubx fp1,fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/m68k/gen/modsi3.s b/lib/libc/arch/m68k/gen/modsi3.s deleted file mode 100644 index cd532824ae42..000000000000 --- a/lib/libc/arch/m68k/gen/modsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)modsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: modsi3.s,v 1.1 1993/11/25 23:37:12 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int % int */ -ENTRY(__modsi3) - movel sp@(4),d1 - divsll sp@(8),d0:d1 - rts diff --git a/lib/libc/arch/m68k/gen/muldf3.s b/lib/libc/arch/m68k/gen/muldf3.s deleted file mode 100644 index 9c41a9ebf0d3..000000000000 --- a/lib/libc/arch/m68k/gen/muldf3.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)muldf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: muldf3.s,v 1.1 1993/11/25 23:37:13 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double * double */ -ENTRY(__muldf3) - fmoved sp@(4),fp0 - fmuld sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/m68k/gen/mulsf3.s b/lib/libc/arch/m68k/gen/mulsf3.s deleted file mode 100644 index 42c5d03b4ab9..000000000000 --- a/lib/libc/arch/m68k/gen/mulsf3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)mulsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: mulsf3.s,v 1.1 1993/11/25 23:37:14 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single * single */ -ENTRY(__mulsf3) - fmoves sp@(4),fp0 - fmuls sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/m68k/gen/mulsi3.s b/lib/libc/arch/m68k/gen/mulsi3.s deleted file mode 100644 index 8150e2053623..000000000000 --- a/lib/libc/arch/m68k/gen/mulsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)mulsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: mulsi3.s,v 1.1 1993/11/25 23:37:15 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int * int */ -ENTRY(__mulsi3) - movel sp@(4),d0 - mulsl sp@(8),d0 - rts diff --git a/lib/libc/arch/m68k/gen/negdf2.s b/lib/libc/arch/m68k/gen/negdf2.s deleted file mode 100644 index 554d95cabc5a..000000000000 --- a/lib/libc/arch/m68k/gen/negdf2.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)negdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: negdf2.s,v 1.1 1993/11/25 23:37:16 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* -double */ -ENTRY(__negdf2) - movel sp@(4),d0 - movel sp@(8),d1 - bchg #31,d0 - rts diff --git a/lib/libc/arch/m68k/gen/negsf2.s b/lib/libc/arch/m68k/gen/negsf2.s deleted file mode 100644 index ee177f230e5b..000000000000 --- a/lib/libc/arch/m68k/gen/negsf2.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)negsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: negsf2.s,v 1.1 1993/11/25 23:37:17 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* -single */ -ENTRY(__negsf2) - movel sp@(4),d0 - bchg #31,d0 - rts diff --git a/lib/libc/arch/m68k/gen/setjmp.s b/lib/libc/arch/m68k/gen/setjmp.s deleted file mode 100644 index 8be2a0212548..000000000000 --- a/lib/libc/arch/m68k/gen/setjmp.s +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)setjmp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: setjmp.s,v 1.1 1993/11/25 23:37:19 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#include "DEFS.h" - -ENTRY(setjmp) - subql #8,sp /* space for sigstack args/rvals */ - clrl sp@ /* don't change it... */ - movl sp,sp@(4) /* ...but return the current val */ - jbsr _sigstack /* note: onstack returned in sp@(4) */ - clrl sp@ /* don't change mask, just return */ - jbsr _sigblock /* old value */ - movl sp@(4),d1 /* old onstack value */ - addql #8,sp - movl sp@(4),a0 /* save area pointer */ - movl d1,a0@+ /* save old onstack value */ - movl d0,a0@+ /* save old signal mask */ - lea sp@(4),a1 /* adjust saved SP since we won't rts */ - movl a1,a0@+ /* save old SP */ - movl a6,a0@+ /* save old FP */ - clrl a0@+ /* no AP */ - movl sp@,a0@+ /* save old PC */ - clrl a0@+ /* clean PS */ - moveml #0x3CFC,a0@ /* save remaining non-scratch regs */ - clrl d0 /* return 0 */ - rts - -ENTRY(longjmp) - movl sp@(4),a0 /* save area pointer */ - tstl a0@(8) /* ensure non-zero SP */ - jeq botch /* oops! */ - movl sp@(8),d0 /* grab return value */ - jne ok /* non-zero ok */ - moveq #1,d0 /* else make non-zero */ -ok: - moveml a0@(28),#0x3CFC /* restore non-scratch regs */ - movl a0,sp@- /* let sigreturn */ - jbsr _sigreturn /* finish for us */ - -botch: - jbsr _longjmperror - stop #0 diff --git a/lib/libc/arch/m68k/gen/subdf3.s b/lib/libc/arch/m68k/gen/subdf3.s deleted file mode 100644 index 025b11b34295..000000000000 --- a/lib/libc/arch/m68k/gen/subdf3.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)subdf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: subdf3.s,v 1.1 1993/11/25 23:37:20 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double - double */ -ENTRY(__subdf3) - fmoved sp@(4),fp0 - fsubd sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/arch/m68k/gen/subsf3.s b/lib/libc/arch/m68k/gen/subsf3.s deleted file mode 100644 index 26896ea53bbb..000000000000 --- a/lib/libc/arch/m68k/gen/subsf3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)subsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: subsf3.s,v 1.1 1993/11/25 23:37:21 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single - single */ -ENTRY(__subsf3) - fmoves sp@(4),fp0 - fsubs sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/m68k/gen/truncdfsf2.s b/lib/libc/arch/m68k/gen/truncdfsf2.s deleted file mode 100644 index f203262d5b09..000000000000 --- a/lib/libc/arch/m68k/gen/truncdfsf2.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)truncdfsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: truncdfsf2.s,v 1.1 1993/11/25 23:37:22 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (float) double */ -ENTRY(__truncdfsf2) - fmoved sp@(4),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/arch/m68k/gen/udivsi3.s b/lib/libc/arch/m68k/gen/udivsi3.s deleted file mode 100644 index bcd7c3c38e65..000000000000 --- a/lib/libc/arch/m68k/gen/udivsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)udivsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: udivsi3.s,v 1.1 1993/11/25 23:37:23 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned / unsigned */ -ENTRY(__udivsi3) - movel sp@(4),d0 - divul sp@(8),d0 - rts diff --git a/lib/libc/arch/m68k/gen/umodsi3.s b/lib/libc/arch/m68k/gen/umodsi3.s deleted file mode 100644 index 54c1836b6d0e..000000000000 --- a/lib/libc/arch/m68k/gen/umodsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)umodsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: umodsi3.s,v 1.1 1993/11/25 23:37:24 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned % unsigned */ -ENTRY(__umodsi3) - movel sp@(4),d1 - divull sp@(8),d0:d1 - rts diff --git a/lib/libc/arch/m68k/gen/umulsi3.s b/lib/libc/arch/m68k/gen/umulsi3.s deleted file mode 100644 index 871f07868b7e..000000000000 --- a/lib/libc/arch/m68k/gen/umulsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)umulsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: umulsi3.s,v 1.1 1993/11/25 23:37:25 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned * unsigned */ -ENTRY(__umulsi3) - movel sp@(4),d0 - mulul sp@(8),d0 - rts diff --git a/lib/libc/arch/m68k/string/strcpy.s b/lib/libc/arch/m68k/string/strcpy.s deleted file mode 100644 index 5bdfaf0ba8f9..000000000000 --- a/lib/libc/arch/m68k/string/strcpy.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strcpy.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strcpy.s,v 1.1 1993/11/25 23:38:33 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strcpy) - movl sp@(8),a0 /* a0 = fromaddr */ - movl sp@(4),d0 /* return value is toaddr */ - movl d0,a1 /* a1 = toaddr */ -scloop: - movb a0@+,a1@+ /* copy a byte */ - jne scloop /* copied non-null, keep going */ - rts diff --git a/lib/libc/arch/m68k/string/strlen.s b/lib/libc/arch/m68k/string/strlen.s deleted file mode 100644 index 72ec428ce036..000000000000 --- a/lib/libc/arch/m68k/string/strlen.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strlen.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strlen.s,v 1.1 1993/11/25 23:38:34 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strlen) - moveq #-1,d0 - movl sp@(4),a0 /* string */ -slloop: - addql #1,d0 /* increment count */ - tstb a0@+ /* null? */ - jne slloop /* no, keep going */ - rts diff --git a/lib/libc/arch/m68k/string/strncmp.s b/lib/libc/arch/m68k/string/strncmp.s deleted file mode 100644 index 2bb6b1b8add4..000000000000 --- a/lib/libc/arch/m68k/string/strncmp.s +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strncmp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strncmp.s,v 1.1 1993/11/25 23:38:35 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * NOTE: this guy returns result compatible with the VAX assembly version. - * The C version on the portable gen directory returns different results - * (different signs!) when comparing chars with the high bit on. Who is - * right?? - */ -ENTRY(strncmp) - movl sp@(12),d1 /* count */ - jeq scdone /* nothing to do */ - movl sp@(4),a0 /* a0 = string1 */ - movl sp@(8),a1 /* a1 = string2 */ -scloop: - movb a0@+,d0 /* get *string1 */ - cmpb a1@+,d0 /* compare a byte */ - jne scexit /* not equal, break out */ - tstb d0 /* at end of string1? */ - jeq scdone /* yes, all done */ - subql #1,d1 /* no, adjust count */ - jne scloop /* more to do, keep going */ -scdone: - moveq #0,d0 /* strings are equal */ - rts -scexit: - subb a1@-,d0 /* *string1 - *string2 */ - extbl d0 - rts diff --git a/lib/libc/arch/m68k/string/strncpy.s b/lib/libc/arch/m68k/string/strncpy.s deleted file mode 100644 index 4c5a83ae9dfb..000000000000 --- a/lib/libc/arch/m68k/string/strncpy.s +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strncpy.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strncpy.s,v 1.1 1993/11/25 23:38:36 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strncpy) - movl sp@(4),d0 /* return value is toaddr */ - movl sp@(12),d1 /* count */ - jeq scdone /* nothing to do */ - movl sp@(8),a0 /* a0 = fromaddr */ - movl d0,a1 /* a1 = toaddr */ -scloop: - movb a0@+,a1@+ /* copy a byte */ - jeq scploop /* copied null, go pad if necessary */ - subql #1,d1 /* adjust count */ - jne scloop /* more room, keep going */ -scdone: - rts -scploop: - subql #1,d1 /* adjust count */ - jeq scdone /* no more room, all done */ - clrb a1@+ /* clear a byte */ - jra scploop /* keep going */ diff --git a/lib/libc/arch/m68k/sys/reboot.s b/lib/libc/arch/m68k/sys/reboot.s deleted file mode 100644 index ce1122940b80..000000000000 --- a/lib/libc/arch/m68k/sys/reboot.s +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)reboot.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: reboot.s,v 1.1 1993/11/25 23:39:31 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - stop #0 - diff --git a/lib/libc/arch/m68k/sys/sbrk.s b/lib/libc/arch/m68k/sys/sbrk.s deleted file mode 100644 index ceec583a7439..000000000000 --- a/lib/libc/arch/m68k/sys/sbrk.s +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sbrk.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: sbrk.s,v 1.1 1993/11/25 23:39:32 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -#define SYS_brk 17 - - .globl _end - .globl minbrk - .globl curbrk - - .data -minbrk: .long _end -curbrk: .long _end - .text - -ENTRY(sbrk) -#ifdef PIC - movl #__GLOBAL_OFFSET_TABLE_,a1 - lea pc@(0,a1:l),a1 - movl a1@(curbrk:w),a1 - movl a1@,d0 -#else - movl curbrk,d0 -#endif - addl d0,sp@(4) - movl #SYS_brk,d0 - trap #0 - jcs err -#ifdef PIC - movl a1@,d0 - movl sp@(4),a1@ -#else - movl curbrk,d0 - movl sp@(4),curbrk -#endif - rts -err: -#ifdef PIC - movl d0,sp@- -#endif - jra cerror diff --git a/lib/libc/arch/m68k/sys/setlogin.s b/lib/libc/arch/m68k/sys/setlogin.s deleted file mode 100644 index f59c38458202..000000000000 --- a/lib/libc/arch/m68k/sys/setlogin.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)setlogin.s 5.1 (Berkeley) 5/6/91"*/ - .asciz "$Id: setlogin.s,v 1.1 1993/11/25 23:39:33 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -.globl __logname_valid /* in getlogin() */ - -SYSCALL(setlogin) -#ifdef PIC - movl #__GLOBAL_OFFSET_TABLE_,a1 - lea pc@(0,a1:l),a1 - movl a1@(__logname_valid:w),a1 - clrl a1@ -#else - movl #0,__logname_valid -#endif - rts /* setlogin(name) */ diff --git a/lib/libc/arch/m68k/sys/sigpending.s b/lib/libc/arch/m68k/sys/sigpending.s deleted file mode 100644 index 3007f5e86b3c..000000000000 --- a/lib/libc/arch/m68k/sys/sigpending.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigpending.s 5.2 (Berkeley) 8/6/90"*/ - .asciz "$Id: sigpending.s,v 1.1 1993/11/25 23:39:34 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(sigpending) - movl sp@(4),a0 - movl d0,a0@ - clrl d0 - rts diff --git a/lib/libc/arch/m68k/sys/sigprocmask.s b/lib/libc/arch/m68k/sys/sigprocmask.s deleted file mode 100644 index 57ffc9ac1743..000000000000 --- a/lib/libc/arch/m68k/sys/sigprocmask.s +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigprocmask.s 5.2 (Berkeley) 6/6/90"*/ - .asciz "$Id: sigprocmask.s,v 1.1 1993/11/25 23:39:35 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - - .even -err: -#ifdef PIC - movl d0,sp@- -#endif - jra cerror - -ENTRY(sigprocmask) - tstl sp@(8) /* check new sigset pointer */ - jne gotptr /* if not null, indirect */ -/* movl #0,sp@(8) /* null mask pointer: block empty set */ - movl #1,sp@(4) /* SIG_BLOCK */ - jra doit -gotptr: - movl sp@(8),a0 - movl a0@,sp@(8) /* indirect to new mask arg */ -doit: - movl #SYS_sigprocmask,d0 - trap #0 - jcs err - tstl sp@(12) /* test if old mask requested */ - jeq out - movl sp@(12),a0 - movl d0,a0@ /* store old mask */ -out: - clrl d0 - rts diff --git a/lib/libc/arch/m68k/sys/sigreturn.s b/lib/libc/arch/m68k/sys/sigreturn.s deleted file mode 100644 index 9cc8f86d51de..000000000000 --- a/lib/libc/arch/m68k/sys/sigreturn.s +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigreturn.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: sigreturn.s,v 1.1 1993/11/25 23:39:36 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef PROF -#undef ENTRY -#define ENTRY(x) \ - .globl _/**/x; .even; _/**/x:; moveml #0xC0C0,sp@-; .data; \ - PROF/**/x:; .long 0; .text; lea PROF/**/x,a0; jbsr mcount; \ - moveml sp@+,#0x0303 -#endif PROF - -ENTRY(sigreturn) - trap #1 /* signals sigreturn() */ -#ifdef PIC - movl d0,sp@- -#endif - jra cerror diff --git a/lib/libc/arch/m68k/sys/sigsuspend.s b/lib/libc/arch/m68k/sys/sigsuspend.s deleted file mode 100644 index 4f16621f2dbb..000000000000 --- a/lib/libc/arch/m68k/sys/sigsuspend.s +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigsuspend.s 5.2 (Berkeley) 6/6/90"*/ - .asciz "$Id: sigsuspend.s,v 1.1 1993/11/25 23:39:37 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - - .even -err: -#ifdef PIC - movl d0,sp@- -#endif - jra cerror - -ENTRY(sigsuspend) - movl sp@(4),a0 - movl a0@,sp@(4) /* indirect to mask arg */ - movl #SYS_sigsuspend,d0 - trap #0 - jcs err - clrl d0 /* shouldn't happen */ - rts diff --git a/lib/libc/arch/m68k/sys/syscall.s b/lib/libc/arch/m68k/sys/syscall.s deleted file mode 100644 index de4b5e17c32a..000000000000 --- a/lib/libc/arch/m68k/sys/syscall.s +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)syscall.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: syscall.s,v 1.1 1993/11/25 23:39:38 paulus Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(syscall) - clrl d0 - trap #0 - jcs err - rts -err: -#ifdef PIC - movl d0,sp@- -#endif - jra cerror diff --git a/lib/libc/arch/mips/gen/_setjmp.s b/lib/libc/arch/mips/gen/_setjmp.s deleted file mode 100644 index 0b78bb252e6c..000000000000 --- a/lib/libc/arch/mips/gen/_setjmp.s +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)_setjmp.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: _setjmp.s,v 1.3 1994/12/15 17:24:46 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * _setjmp(a) - * by restoring registers from the stack, - * The previous signal state is NOT restored. - */ - - .set noreorder - -LEAF(_setjmp) - li v0, 0xACEDBADE # sigcontext magic number - sw ra, (2 * 4)(a0) # sc_pc = return address - sw v0, (3 * 4)(a0) # saved in sc_regs[0] - sw s0, ((S0 + 3) * 4)(a0) - sw s1, ((S1 + 3) * 4)(a0) - sw s2, ((S2 + 3) * 4)(a0) - sw s3, ((S3 + 3) * 4)(a0) - sw s4, ((S4 + 3) * 4)(a0) - sw s5, ((S5 + 3) * 4)(a0) - sw s6, ((S6 + 3) * 4)(a0) - sw s7, ((S7 + 3) * 4)(a0) - sw sp, ((SP + 3) * 4)(a0) - sw s8, ((S8 + 3) * 4)(a0) - cfc1 v0, $31 # too bad cant check if FP used - swc1 $f20, ((20 + 38) * 4)(a0) - swc1 $f21, ((21 + 38) * 4)(a0) - swc1 $f22, ((22 + 38) * 4)(a0) - swc1 $f23, ((23 + 38) * 4)(a0) - swc1 $f24, ((24 + 38) * 4)(a0) - swc1 $f25, ((25 + 38) * 4)(a0) - swc1 $f26, ((26 + 38) * 4)(a0) - swc1 $f27, ((27 + 38) * 4)(a0) - swc1 $f28, ((28 + 38) * 4)(a0) - swc1 $f29, ((29 + 38) * 4)(a0) - swc1 $f30, ((30 + 38) * 4)(a0) - swc1 $f31, ((31 + 38) * 4)(a0) - sw v0, ((32 + 38) * 4)(a0) - j ra - move v0, zero -END(_setjmp) - -LEAF(_longjmp) - lw v0, (3 * 4)(a0) # get magic number - lw ra, (2 * 4)(a0) - bne v0, 0xACEDBADE, botch # jump if error - lw s0, ((S0 + 3) * 4)(a0) - lw s1, ((S1 + 3) * 4)(a0) - lw s2, ((S2 + 3) * 4)(a0) - lw s3, ((S3 + 3) * 4)(a0) - lw s4, ((S4 + 3) * 4)(a0) - lw s5, ((S5 + 3) * 4)(a0) - lw s6, ((S6 + 3) * 4)(a0) - lw s7, ((S7 + 3) * 4)(a0) - lw v0, ((32 + 38) * 4)(a0) # get fpu status - lw sp, ((SP + 3) * 4)(a0) - lw s8, ((S8 + 3) * 4)(a0) - ctc1 v0, $31 - lwc1 $f20, ((20 + 38) * 4)(a0) - lwc1 $f21, ((21 + 38) * 4)(a0) - lwc1 $f22, ((22 + 38) * 4)(a0) - lwc1 $f23, ((23 + 38) * 4)(a0) - lwc1 $f24, ((24 + 38) * 4)(a0) - lwc1 $f25, ((25 + 38) * 4)(a0) - lwc1 $f26, ((26 + 38) * 4)(a0) - lwc1 $f27, ((27 + 38) * 4)(a0) - lwc1 $f28, ((28 + 38) * 4)(a0) - lwc1 $f29, ((29 + 38) * 4)(a0) - lwc1 $f30, ((30 + 38) * 4)(a0) - lwc1 $f31, ((31 + 38) * 4)(a0) - j ra - move v0, a1 -botch: - jal _C_LABEL(longjmperror) - nop - jal _C_LABEL(abort) - nop -END(_longjmp) diff --git a/lib/libc/arch/mips/gen/fabs.s b/lib/libc/arch/mips/gen/fabs.s deleted file mode 100644 index def35361b8f9..000000000000 --- a/lib/libc/arch/mips/gen/fabs.s +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)fabs.s 8.1 (Berkeley) 2/16/94") - ASMSTR("$Id: fabs.s,v 1.3 1994/12/15 17:24:47 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - - .set noreorder - -/* - * fabs(x) - * double x; - * - * Return absolute value of x. - */ -LEAF(fabs) - j ra - abs.d $f0, $f12 # compute absolute value of x -END(fabs) diff --git a/lib/libc/arch/mips/gen/isinf.s b/lib/libc/arch/mips/gen/isinf.s deleted file mode 100644 index 290c0db98028..000000000000 --- a/lib/libc/arch/mips/gen/isinf.s +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)isinf.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: isinf.s,v 1.3 1994/12/15 17:24:48 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - - -#define DEXP_INF 0x7ff - - .set noreorder - -/* - * isnan(x) - * double x; - * - * Return true if x is a NAN. - */ -LEAF(isnan) - mfc1 v1, $f13 # get MSW of x - mfc1 t3, $f12 # get LSW of x - sll t1, v1, 1 # get x exponent - srl t1, t1, 32 - 11 - bne t1, DEXP_INF, 2f # is it a finite number? - sll t2, v1, 32 - 20 # get x fraction - bne t3, zero, 1f # is it a NAN? - nop - beq t2, zero, 2f # its infinity - nop -1: - j ra - li v0, 1 # x is a NAN -2: - j ra - move v0, zero # x is NOT a NAN -END(isnan) - -/* - * isinf(x) - * double x; - * - * Return true if x is infinity. - */ -LEAF(isinf) - mfc1 v1, $f13 # get MSW of x - mfc1 t3, $f12 # get LSW of x - sll t1, v1, 1 # get x exponent - srl t1, t1, 32 - 11 - bne t1, DEXP_INF, 1f # is it a finite number? - sll t2, v1, 32 - 20 # get x fraction - bne t3, zero, 1f # is it a NAN? - nop - bne t2, zero, 1f # is it a NAN? - nop - j ra - li v0, 1 # x is infinity -1: - j ra - move v0, zero # x is NOT infinity -END(isinf) diff --git a/lib/libc/arch/mips/gen/ldexp.s b/lib/libc/arch/mips/gen/ldexp.s deleted file mode 100644 index d2a0b54c3c6d..000000000000 --- a/lib/libc/arch/mips/gen/ldexp.s +++ /dev/null @@ -1,216 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)ldexp.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: ldexp.s,v 1.3 1994/12/15 17:24:49 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -#define DEXP_INF 0x7ff -#define DEXP_BIAS 1023 -#define DEXP_MIN -1022 -#define DEXP_MAX 1023 -#define DFRAC_BITS 52 -#define DIMPL_ONE 0x00100000 -#define DLEAD_ZEROS 31 - 20 -#define STICKYBIT 1 -#define GUARDBIT 0x80000000 -#define DSIGNAL_NAN 0x00040000 -#define DQUIET_NAN0 0x0007ffff -#define DQUIET_NAN1 0xffffffff - -/* - * double ldexp(x, N) - * double x; int N; - * - * Return x * (2**N), for integer values N. - */ -LEAF(ldexp) - mfc1 v1, $f13 # get MSW of x - mfc1 t3, $f12 # get LSW of x - sll t1, v1, 1 # get x exponent - srl t1, t1, 32 - 11 - beq t1, DEXP_INF, 9f # is it a NAN or infinity? - beq t1, zero, 1f # zero or denormalized number? - addu t1, t1, a2 # scale exponent - sll v0, a2, 20 # position N for addition - bge t1, DEXP_INF, 8f # overflow? - addu v0, v0, v1 # multiply by (2**N) - ble t1, zero, 4f # underflow? - mtc1 v0, $f1 # save MSW of result - mtc1 t3, $f0 # save LSW of result - j ra -1: - sll t2, v1, 32 - 20 # get x fraction - srl t2, t2, 32 - 20 - srl t0, v1, 31 # get x sign - bne t2, zero, 1f - beq t3, zero, 9f # result is zero -1: -/* - * Find out how many leading zero bits are in t2,t3 and put in t9. - */ - move v0, t2 - move t9, zero - bne t2, zero, 1f - move v0, t3 - addu t9, 32 -1: - srl t4, v0, 16 - bne t4, zero, 1f - addu t9, 16 - sll v0, 16 -1: - srl t4, v0, 24 - bne t4, zero, 1f - addu t9, 8 - sll v0, 8 -1: - srl t4, v0, 28 - bne t4, zero, 1f - addu t9, 4 - sll v0, 4 -1: - srl t4, v0, 30 - bne t4, zero, 1f - addu t9, 2 - sll v0, 2 -1: - srl t4, v0, 31 - bne t4, zero, 1f - addu t9, 1 -/* - * Now shift t2,t3 the correct number of bits. - */ -1: - subu t9, t9, DLEAD_ZEROS # dont count normal leading zeros - li t1, DEXP_MIN + DEXP_BIAS - subu t1, t1, t9 # adjust exponent - addu t1, t1, a2 # scale exponent - li v0, 32 - blt t9, v0, 1f - subu t9, t9, v0 # shift fraction left >= 32 bits - sll t2, t3, t9 - move t3, zero - b 2f -1: - subu v0, v0, t9 # shift fraction left < 32 bits - sll t2, t2, t9 - srl t4, t3, v0 - or t2, t2, t4 - sll t3, t3, t9 -2: - bge t1, DEXP_INF, 8f # overflow? - ble t1, zero, 4f # underflow? - sll t2, t2, 32 - 20 # clear implied one bit - srl t2, t2, 32 - 20 -3: - sll t1, t1, 31 - 11 # reposition exponent - sll t0, t0, 31 # reposition sign - or t0, t0, t1 # put result back together - or t0, t0, t2 - mtc1 t0, $f1 # save MSW of result - mtc1 t3, $f0 # save LSW of result - j ra -4: - li v0, 0x80000000 - ble t1, -52, 7f # is result too small for denorm? - sll t2, v1, 31 - 20 # clear exponent, extract fraction - or t2, t2, v0 # set implied one bit - blt t1, -30, 2f # will all bits in t3 be shifted out? - srl t2, t2, 31 - 20 # shift fraction back to normal position - subu t1, t1, 1 - sll t4, t2, t1 # shift right t2,t3 based on exponent - srl t8, t3, t1 # save bits shifted out - negu t1 - srl t3, t3, t1 - or t3, t3, t4 - srl t2, t2, t1 - bge t8, zero, 1f # does result need to be rounded? - addu t3, t3, 1 # round result - sltu t4, t3, 1 - sll t8, t8, 1 - addu t2, t2, t4 - bne t8, zero, 1f # round result to nearest - and t3, t3, ~1 -1: - mtc1 t3, $f0 # save denormalized result (LSW) - mtc1 t2, $f1 # save denormalized result (MSW) - bge v1, zero, 1f # should result be negative? - neg.d $f0, $f0 # negate result -1: - j ra -2: - mtc1 zero, $f1 # exponent and upper fraction - addu t1, t1, 20 # compute amount to shift right by - sll t8, t2, t1 # save bits shifted out - negu t1 - srl t3, t2, t1 - bge t8, zero, 1f # does result need to be rounded? - addu t3, t3, 1 # round result - sltu t4, t3, 1 - sll t8, t8, 1 - mtc1 t4, $f1 # exponent and upper fraction - bne t8, zero, 1f # round result to nearest - and t3, t3, ~1 -1: - mtc1 t3, $f0 - bge v1, zero, 1f # is result negative? - neg.d $f0, $f0 # negate result -1: - j ra -7: - mtc1 zero, $f0 # result is zero - mtc1 zero, $f1 - beq t0, zero, 1f # is result positive? - neg.d $f0, $f0 # negate result -1: - j ra -8: - li t1, 0x7ff00000 # result is infinity (MSW) - mtc1 t1, $f1 - mtc1 zero, $f0 # result is infinity (LSW) - bge v1, zero, 1f # should result be negative infinity? - neg.d $f0, $f0 # result is negative infinity -1: - add.d $f0, $f0 # cause overflow faults if enabled - j ra -9: - mov.d $f0, $f12 # yes, result is just x - j ra -END(ldexp) diff --git a/lib/libc/arch/mips/gen/modf.s b/lib/libc/arch/mips/gen/modf.s deleted file mode 100644 index 1acb53f3ae44..000000000000 --- a/lib/libc/arch/mips/gen/modf.s +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)modf.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: modf.s,v 1.3 1994/12/15 17:24:50 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * double modf(val, iptr) - * double val, *iptr; - * returns: xxx and n (in *iptr) where val == n.xxx - */ -LEAF(modf) - cfc1 t0, $31 # get the control register - cfc1 t0, $31 # get the control register - or t1, t0, 0x3 # set rounding mode to round to zero - xor t1, t1, 0x2 # (i.e., 01) - ctc1 t1, $31 - cvt.w.d $f0, $f12 # convert val to integer - cvt.d.w $f0, $f0 # convert back to double - ctc1 t0, $31 # restore old rounding mode - s.d $f0, 0(a2) # save the integer part - sub.d $f0, $f12, $f0 # subtract val - integer part - j ra -END(modf) diff --git a/lib/libc/arch/mips/gen/setjmp.s b/lib/libc/arch/mips/gen/setjmp.s deleted file mode 100644 index 6b0f96d1e6c5..000000000000 --- a/lib/libc/arch/mips/gen/setjmp.s +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)setjmp.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: setjmp.s,v 1.3 1994/12/15 17:24:51 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#define SETJMP_FRAME_SIZE (STAND_FRAME_SIZE + 12) - -NON_LEAF(setjmp, SETJMP_FRAME_SIZE, ra) - subu sp, sp, SETJMP_FRAME_SIZE # allocate stack frame - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - sw ra, STAND_RA_OFFSET(sp) # save state - sw a0, SETJMP_FRAME_SIZE(sp) - move a0, zero # get current signal mask - jal _C_LABEL(sigblock) - lw v1, SETJMP_FRAME_SIZE(sp) # v1 = jmpbuf - sw v0, (1 * 4)(v1) # save sc_mask = sigblock(0) - move a0, zero - addu a1, sp, STAND_FRAME_SIZE # pointer to struct sigaltstack - jal _C_LABEL(sigaltstack) - lw a0, SETJMP_FRAME_SIZE(sp) # restore jmpbuf - lw v1, STAND_FRAME_SIZE+8(sp) # get old ss_onstack - and v1, v1, 1 # extract onstack flag - sw v1, 0(a0) # save it in sc_onstack - lw ra, STAND_RA_OFFSET(sp) - addu sp, sp, SETJMP_FRAME_SIZE - blt v0, zero, botch # check for sigstack() error - sw ra, (2 * 4)(a0) # sc_pc = return address - li v0, 0xACEDBADE # sigcontext magic number - sw v0, ((ZERO + 3) * 4)(a0) # saved in sc_regs[0] - sw s0, ((S0 + 3) * 4)(a0) - sw s1, ((S1 + 3) * 4)(a0) - sw s2, ((S2 + 3) * 4)(a0) - sw s3, ((S3 + 3) * 4)(a0) - sw s4, ((S4 + 3) * 4)(a0) - sw s5, ((S5 + 3) * 4)(a0) - sw s6, ((S6 + 3) * 4)(a0) - sw s7, ((S7 + 3) * 4)(a0) - sw gp, ((GP + 3) * 4)(a0) - sw sp, ((SP + 3) * 4)(a0) - sw s8, ((S8 + 3) * 4)(a0) - li v0, 1 # be nice if we could tell - sw v0, (37 * 4)(a0) # sc_fpused = 1 - cfc1 v0, $31 - swc1 $f20, ((20 + 38) * 4)(a0) - swc1 $f21, ((21 + 38) * 4)(a0) - swc1 $f22, ((22 + 38) * 4)(a0) - swc1 $f23, ((23 + 38) * 4)(a0) - swc1 $f24, ((24 + 38) * 4)(a0) - swc1 $f25, ((25 + 38) * 4)(a0) - swc1 $f26, ((26 + 38) * 4)(a0) - swc1 $f27, ((27 + 38) * 4)(a0) - swc1 $f28, ((28 + 38) * 4)(a0) - swc1 $f29, ((29 + 38) * 4)(a0) - swc1 $f30, ((30 + 38) * 4)(a0) - swc1 $f31, ((31 + 38) * 4)(a0) - sw v0, ((32 + 38) * 4)(a0) - move v0, zero - j ra -END(setjmp) - -LEAF(longjmp) - sw a1, ((V0 + 3) * 4)(a0) # save return value in sc_regs[V0] - li v0, SYS_sigreturn - syscall -botch: - jal _C_LABEL(longjmperror) - jal _C_LABEL(abort) -END(longjmp) diff --git a/lib/libc/arch/mips/net/htonl.s b/lib/libc/arch/mips/net/htonl.s deleted file mode 100644 index 3e488dcb489c..000000000000 --- a/lib/libc/arch/mips/net/htonl.s +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)htonl.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: htonl.s,v 1.3 1994/12/15 17:24:52 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * netorder = htonl(hostorder) - * hostorder = ntohl(netorder) - */ -NLEAF(htonl) # a0 = 0x11223344, return 0x44332211 -ALEAF(ntohl) -#ifdef MIPSEL - srl v1, a0, 24 # v1 = 0x00000011 - sll v0, a0, 24 # v0 = 0x44000000 - or v0, v0, v1 - and v1, a0, 0xff00 - sll v1, v1, 8 # v1 = 0x00330000 - or v0, v0, v1 - srl v1, a0, 8 - and v1, v1, 0xff00 # v1 = 0x00002200 - or v0, v0, v1 -#else -#ifdef MIPSEB - move v0, a0 -#else - ERROR -#endif -#endif - j ra -END(htonl) diff --git a/lib/libc/arch/mips/net/htons.s b/lib/libc/arch/mips/net/htons.s deleted file mode 100644 index d987cd7da028..000000000000 --- a/lib/libc/arch/mips/net/htons.s +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)htons.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: htons.s,v 1.3 1994/12/15 17:24:55 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * netorder = htons(hostorder) - * hostorder = ntohs(netorder) - */ -NLEAF(htons) -ALEAF(ntohs) -#ifdef MIPSEL - srl v0, a0, 8 - and v0, v0, 0xff - sll v1, a0, 8 - and v1, v1, 0xff00 - or v0, v0, v1 -#else -#ifdef MIPSEB - move v0, a0 -#else - ERROR -#endif -#endif - j ra -END(htons) diff --git a/lib/libc/arch/mips/string/bcmp.s b/lib/libc/arch/mips/string/bcmp.s deleted file mode 100644 index e6b64da54f6e..000000000000 --- a/lib/libc/arch/mips/string/bcmp.s +++ /dev/null @@ -1,133 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)bcmp.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: bcmp.s,v 1.3 1994/12/15 17:24:57 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* bcmp(s1, s2, n) */ - -#ifdef MIPSEL -# define LWHI lwr -# define LWLO lwl -# define SWHI swr -# define SWLO swl -#endif -#ifdef MIPSEB -# define LWHI lwl -# define LWLO lwr -# define SWHI swl -# define SWLO swr -#endif - -LEAF(bcmp) - .set noreorder - blt a2, 16, small # is it worth any trouble? - xor v0, a0, a1 # compare low two bits of addresses - and v0, v0, 3 - subu a3, zero, a1 # compute # bytes to word align address - bne v0, zero, unaligned # not possible to align addresses - and a3, a3, 3 - - beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count - move v0, v1 # init v0,v1 so unmodified bytes match - LWHI v0, 0(a0) # read 1, 2, or 3 bytes - LWHI v1, 0(a1) - addu a1, a1, a3 - bne v0, v1, nomatch - addu a0, a0, a3 -1: - and a3, a2, ~3 # compute number of whole words left - subu a2, a2, a3 # which has to be >= (16-3) & ~3 - addu a3, a3, a0 # compute ending address -2: - lw v0, 0(a0) # compare words - lw v1, 0(a1) - addu a0, a0, 4 - bne v0, v1, nomatch - addu a1, a1, 4 - bne a0, a3, 2b - nop - b small # finish remainder - nop -unaligned: - beq a3, zero, 2f - subu a2, a2, a3 # subtract from remaining count - addu a3, a3, a0 # compute ending address -1: - lbu v0, 0(a0) # compare bytes until a1 word aligned - lbu v1, 0(a1) - addu a0, a0, 1 - bne v0, v1, nomatch - addu a1, a1, 1 - bne a0, a3, 1b - nop -2: - and a3, a2, ~3 # compute number of whole words left - subu a2, a2, a3 # which has to be >= (16-3) & ~3 - addu a3, a3, a0 # compute ending address -3: - LWHI v0, 0(a0) # compare words a0 unaligned, a1 aligned - LWLO v0, 3(a0) - lw v1, 0(a1) - addu a0, a0, 4 - bne v0, v1, nomatch - addu a1, a1, 4 - bne a0, a3, 3b - nop -small: - ble a2, zero, match - addu a3, a2, a0 # compute ending address -1: - lbu v0, 0(a0) - lbu v1, 0(a1) - addu a0, a0, 1 - bne v0, v1, nomatch - addu a1, a1, 1 - bne a0, a3, 1b - nop -match: - j ra - move v0, zero -nomatch: - j ra - li v0, 1 - .set reorder -END(bcmp) diff --git a/lib/libc/arch/mips/string/bcopy.s b/lib/libc/arch/mips/string/bcopy.s deleted file mode 100644 index a3dd9e83029b..000000000000 --- a/lib/libc/arch/mips/string/bcopy.s +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)bcopy.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: bcopy.s,v 1.3 1994/12/15 17:24:57 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* bcopy(s1, s2, n) */ - -#ifdef MIPSEL -# define LWHI lwr -# define LWLO lwl -# define SWHI swr -# define SWLO swl -#endif -#ifdef MIPSEB -# define LWHI lwl -# define LWLO lwr -# define SWHI swl -# define SWLO swr -#endif - -LEAF(bcopy) - .set noreorder - addu t0, a0, a2 # t0 = end of s1 region - sltu t1, a1, t0 - sltu t2, a0, a1 - and t1, t1, t2 # t1 = true if from < to < (from+len) - beq t1, zero, forward # non overlapping, do forward copy - slt t2, a2, 12 # check for small copy - - ble a2, zero, 2f - addu t1, a1, a2 # t1 = end of to region -1: - lb v0, -1(t0) # copy bytes backwards, - subu t0, t0, 1 # doesnt happen often so do slow way - subu t1, t1, 1 - bne t0, a0, 1b - sb v0, 0(t1) -2: - j ra - nop -forward: - bne t2, zero, smallcpy # do a small bcopy - xor v0, a0, a1 # compare low two bits of addresses - and v0, v0, 3 - subu a3, zero, a1 # compute # bytes to word align address - beq v0, zero, aligned # addresses can be word aligned - and a3, a3, 3 - - beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count - LWHI v0, 0(a0) # get next 4 bytes (unaligned) - LWLO v0, 3(a0) - addu a0, a0, a3 - SWHI v0, 0(a1) # store 1, 2, or 3 bytes to align a1 - addu a1, a1, a3 -1: - and v0, a2, 3 # compute number of words left - subu a3, a2, v0 - move a2, v0 - addu a3, a3, a0 # compute ending address -2: - LWHI v0, 0(a0) # copy words a0 unaligned, a1 aligned - LWLO v0, 3(a0) - addu a0, a0, 4 - addu a1, a1, 4 - bne a0, a3, 2b - sw v0, -4(a1) - b smallcpy - nop -aligned: - beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count - LWHI v0, 0(a0) # copy 1, 2, or 3 bytes to align - addu a0, a0, a3 - SWHI v0, 0(a1) - addu a1, a1, a3 -1: - and v0, a2, 3 # compute number of whole words left - subu a3, a2, v0 - move a2, v0 - addu a3, a3, a0 # compute ending address -2: - lw v0, 0(a0) # copy words - addu a0, a0, 4 - addu a1, a1, 4 - bne a0, a3, 2b - sw v0, -4(a1) -smallcpy: - ble a2, zero, 2f - addu a3, a2, a0 # compute ending address -1: - lbu v0, 0(a0) # copy bytes - addu a0, a0, 1 - addu a1, a1, 1 - bne a0, a3, 1b - sb v0, -1(a1) -2: - j ra - nop - .set reorder -END(bcopy) diff --git a/lib/libc/arch/mips/string/bzero.s b/lib/libc/arch/mips/string/bzero.s deleted file mode 100644 index 56d9097eef8d..000000000000 --- a/lib/libc/arch/mips/string/bzero.s +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)bzero.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: bzero.s,v 1.3 1994/12/15 17:24:58 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* bzero(s1, n) */ - -LEAF(bzero) - .set noreorder - blt a1, 12, smallclr # small amount to clear? - subu a3, zero, a0 # compute # bytes to word align address - and a3, a3, 3 - beq a3, zero, 1f # skip if word aligned - subu a1, a1, a3 # subtract from remaining count - swr zero, 0(a0) # clear 1, 2, or 3 bytes to align - addu a0, a0, a3 -1: - and v0, a1, 3 # compute number of words left - subu a3, a1, v0 - move a1, v0 - addu a3, a3, a0 # compute ending address -2: - addu a0, a0, 4 # clear words - bne a0, a3, 2b # unrolling loop doesnt help - sw zero, -4(a0) # since we are limited by memory speed -smallclr: - ble a1, zero, 2f - addu a3, a1, a0 # compute ending address -1: - addu a0, a0, 1 # clear bytes - bne a0, a3, 1b - sb zero, -1(a0) -2: - j ra - nop -END(bzero) diff --git a/lib/libc/arch/mips/string/ffs.s b/lib/libc/arch/mips/string/ffs.s deleted file mode 100644 index 3da55e77858e..000000000000 --- a/lib/libc/arch/mips/string/ffs.s +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)ffs.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: ffs.s,v 1.3 1994/12/15 17:24:59 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* bit = ffs(value) */ - -LEAF(ffs) - move v0, zero - beq a0, zero, done -1: - and v1, a0, 1 # bit set? - addu v0, v0, 1 - srl a0, a0, 1 - beq v1, zero, 1b # no, continue -done: - j ra -END(ffs) diff --git a/lib/libc/arch/mips/string/index.s b/lib/libc/arch/mips/string/index.s deleted file mode 100644 index 077a8ef64457..000000000000 --- a/lib/libc/arch/mips/string/index.s +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)index.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: index.s,v 1.3 1994/12/15 17:25:01 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(index) - lbu a2, 0(a0) # get a byte - addu a0, a0, 1 - beq a2, a1, fnd - bne a2, zero, _C_LABEL(index) -notfnd: - move v0, zero - j ra -fnd: - subu v0, a0, 1 - j ra -END(index) diff --git a/lib/libc/arch/mips/string/rindex.s b/lib/libc/arch/mips/string/rindex.s deleted file mode 100644 index 50549e7513ed..000000000000 --- a/lib/libc/arch/mips/string/rindex.s +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)rindex.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: rindex.s,v 1.3 1994/12/15 17:25:02 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(rindex) - move v0, zero # default if not found -1: - lbu a3, 0(a0) # get a byte - addu a0, a0, 1 - bne a3, a1, 2f - subu v0, a0, 1 # save address of last match -2: - bne a3, zero, 1b # continue if not end - j ra -END(rindex) diff --git a/lib/libc/arch/mips/string/strcmp.s b/lib/libc/arch/mips/string/strcmp.s deleted file mode 100644 index cec0393d8b83..000000000000 --- a/lib/libc/arch/mips/string/strcmp.s +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)strcmp.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: strcmp.s,v 1.3 1994/12/15 17:25:04 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * NOTE: this version assumes unsigned chars in order to be "8 bit clean". - */ -LEAF(strcmp) -1: - lbu t0, 0(a0) # get two bytes and compare them - lbu t1, 0(a1) - beq t0, zero, LessOrEq # end of first string? - bne t0, t1, NotEq - lbu t0, 1(a0) # unroll loop - lbu t1, 1(a1) - add a0, a0, 2 - beq t0, zero, LessOrEq # end of first string? - add a1, a1, 2 - beq t0, t1, 1b -NotEq: - subu v0, t0, t1 - j ra -LessOrEq: - subu v0, zero, t1 - j ra -END(strcmp) diff --git a/lib/libc/arch/mips/string/strlen.s b/lib/libc/arch/mips/string/strlen.s deleted file mode 100644 index 0aeaaebe6de4..000000000000 --- a/lib/libc/arch/mips/string/strlen.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)strlen.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: strlen.s,v 1.3 1994/12/15 17:25:05 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(strlen) - addu v1, a0, 1 -1: - lb v0, 0(a0) # get byte from string - addu a0, a0, 1 # increment pointer - bne v0, zero, 1b # continue if not end - subu v0, a0, v1 # compute length - 1 for '\0' char - j ra -END(strlen) diff --git a/lib/libc/arch/mips/sys/Ovfork.s b/lib/libc/arch/mips/sys/Ovfork.s deleted file mode 100644 index f34fb29751bd..000000000000 --- a/lib/libc/arch/mips/sys/Ovfork.s +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)Ovfork.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: Ovfork.s,v 1.3 1994/12/15 17:25:07 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * pid = vfork(); - * - * v1 == 0 in parent process, v1 == 1 in child process. - * v0 == pid of child in parent, v0 == pid of parent in child. - */ - -LEAF(vfork) - li v0, SYS_vfork # system call number for vfork - syscall - beq a3, zero, 1f # jump if no errors - j _C_LABEL(cerror) -1: - beq v1, zero, 2f # parent process ? - move v0, zero # return zero in child -2: - j ra -END(vfork) diff --git a/lib/libc/arch/mips/sys/brk.s b/lib/libc/arch/mips/sys/brk.s deleted file mode 100644 index 8524c18d5319..000000000000 --- a/lib/libc/arch/mips/sys/brk.s +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)brk.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: brk.s,v 1.3 1994/12/15 17:25:08 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -#define SYS_brk 17 - -LEAF(brk) - lw v0, minbrk - bgeu a0, v0, _C_LABEL(brk) - move a0, v0 # dont allow break < minbrk -ALEAF(_brk) - li v0, SYS_brk - syscall - bne a3, zero, 1f - sw a0, curbrk - move v0, zero - j ra -1: - j _C_LABEL(cerror) -END(brk) diff --git a/lib/libc/arch/mips/sys/cerror.s b/lib/libc/arch/mips/sys/cerror.s deleted file mode 100644 index 38cd8854cf55..000000000000 --- a/lib/libc/arch/mips/sys/cerror.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)cerror.s 8.1 (Berkeley) 6/16/93") - ASMSTR("$Id: cerror.s,v 1.3 1994/12/15 17:25:09 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - - .globl _C_LABEL(errno) -LEAF(cerror) - .set noreorder - sw v0, _C_LABEL(errno) - li v0, -1 - j ra - li v1, -1 -END(cerror) diff --git a/lib/libc/arch/mips/sys/exect.s b/lib/libc/arch/mips/sys/exect.s deleted file mode 100644 index 447eeca2aee7..000000000000 --- a/lib/libc/arch/mips/sys/exect.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)exect.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: exect.s,v 1.3 1994/12/15 17:25:10 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(exect) - li v0, SYS_execve - syscall - bne a3, zero, 1f - j ra -1: - j _C_LABEL(cerror) -END(exect) diff --git a/lib/libc/arch/mips/sys/fork.s b/lib/libc/arch/mips/sys/fork.s deleted file mode 100644 index 641e11b75820..000000000000 --- a/lib/libc/arch/mips/sys/fork.s +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)fork.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: fork.s,v 1.3 1994/12/15 17:25:11 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(fork) - li v0, SYS_fork # pid = fork() - syscall - bne a3, zero, 2f - beq v1, zero, 1f # v1 == 0 in parent, 1 in child - move v0, zero -1: - j ra -2: - j _C_LABEL(cerror) -END(fork) diff --git a/lib/libc/arch/mips/sys/pipe.s b/lib/libc/arch/mips/sys/pipe.s deleted file mode 100644 index 0c40e2864b84..000000000000 --- a/lib/libc/arch/mips/sys/pipe.s +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)pipe.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: pipe.s,v 1.3 1994/12/15 17:25:12 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(pipe) - li v0, SYS_pipe # pipe(fildes) int fildes[2]; - syscall - bne a3, zero, 1f - sw v0, 0(a0) # store the two file descriptors - sw v1, 4(a0) - move v0, zero - j ra -1: - j _C_LABEL(cerror) -END(pipe) diff --git a/lib/libc/arch/mips/sys/ptrace.s b/lib/libc/arch/mips/sys/ptrace.s deleted file mode 100644 index 4e070476de9a..000000000000 --- a/lib/libc/arch/mips/sys/ptrace.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)ptrace.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: ptrace.s,v 1.3 1994/12/15 17:25:13 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(ptrace) - sw zero, _C_LABEL(errno) - li v0, SYS_ptrace - syscall - bne a3, zero, 1f - j ra -1: - j _C_LABEL(cerror) -END(ptrace) diff --git a/lib/libc/arch/mips/sys/reboot.s b/lib/libc/arch/mips/sys/reboot.s deleted file mode 100644 index 2f1521a4e162..000000000000 --- a/lib/libc/arch/mips/sys/reboot.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)reboot.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: reboot.s,v 1.3 1994/12/15 17:25:15 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(reboot) - li v0, SYS_reboot - syscall - bne a3, zero, 1f - jal _C_LABEL(abort) -1: - j _C_LABEL(cerror) -END(reboot) diff --git a/lib/libc/arch/mips/sys/sbrk.s b/lib/libc/arch/mips/sys/sbrk.s deleted file mode 100644 index a6988f987e4f..000000000000 --- a/lib/libc/arch/mips/sys/sbrk.s +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)sbrk.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: sbrk.s,v 1.4 1994/12/15 17:25:16 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -#define SYS_brk 17 - - .data - .globl minbrk -minbrk: - .word _C_LABEL(end) - .globl curbrk -curbrk: - .word _C_LABEL(end) - .text - -LEAF(sbrk) - lw v1, curbrk - li v0, SYS_brk - addu a0, a0, v1 # compute current break - syscall - bne a3, zero, 1f - move v0, v1 # return old val of curbrk from above - sw a0, curbrk # save current val of curbrk from above - j ra -1: - j _C_LABEL(cerror) -END(sbrk) diff --git a/lib/libc/arch/mips/sys/setlogin.s b/lib/libc/arch/mips/sys/setlogin.s deleted file mode 100644 index 3e2efeadb442..000000000000 --- a/lib/libc/arch/mips/sys/setlogin.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)setlogin.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: setlogin.s,v 1.3 1994/12/15 17:25:17 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(setlogin) - li v0, SYS_setlogin # setlogin(name) - syscall - bne a3, zero, 1f - sw zero, _C_LABEL(__logname_valid) # in getlogin() - j ra -1: - j _C_LABEL(cerror) -END(setlogin) diff --git a/lib/libc/arch/mips/sys/sigpending.s b/lib/libc/arch/mips/sys/sigpending.s deleted file mode 100644 index df8b970c0490..000000000000 --- a/lib/libc/arch/mips/sys/sigpending.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)sigpending.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: sigpending.s,v 1.3 1994/12/15 17:25:18 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(sigpending) - li v0, SYS_sigpending # setlogin(name) - syscall - bne a3, zero, 1f - sw v0, 0(a0) - move v0, zero - j ra -1: - j _C_LABEL(cerror) -END(sigpending) diff --git a/lib/libc/arch/mips/sys/sigprocmask.s b/lib/libc/arch/mips/sys/sigprocmask.s deleted file mode 100644 index 8fb6333f06f7..000000000000 --- a/lib/libc/arch/mips/sys/sigprocmask.s +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)sigprocmask.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: sigprocmask.s,v 1.3 1994/12/15 17:25:19 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(sigprocmask) # sigprocmask(how, new, old) sigset_t *new, *old; - bne a1, zero, gotptr # if new sigset pointer not null - li a0, 1 # how = SIG_BLOCK - b doit # mask = zero -gotptr: - lw a1, 0(a1) # indirect to new mask arg -doit: - li v0, SYS_sigprocmask - syscall - bne a3, zero, err - beq a2, zero, out # test if old mask requested - sw v0, 0(a2) # store old mask -out: - move v0, zero - j ra -err: - j _C_LABEL(cerror) -END(sigprocmask) diff --git a/lib/libc/arch/mips/sys/sigreturn.s b/lib/libc/arch/mips/sys/sigreturn.s deleted file mode 100644 index aab912f3c640..000000000000 --- a/lib/libc/arch/mips/sys/sigreturn.s +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)sigreturn.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: sigreturn.s,v 1.1 1994/05/24 07:13:26 glass Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * We must preserve the state of the registers as the user has set them up. - */ - -RSYSCALL(sigreturn) diff --git a/lib/libc/arch/mips/sys/sigsuspend.s b/lib/libc/arch/mips/sys/sigsuspend.s deleted file mode 100644 index 2424fee0bb27..000000000000 --- a/lib/libc/arch/mips/sys/sigsuspend.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)sigsuspend.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: sigsuspend.s,v 1.3 1994/12/15 17:25:20 mycroft Exp $") -#endif /* LIBC_SCCS and not lint */ - -LEAF(sigsuspend) - lw a0, 0(a0) # indirect to mask arg - li v0, SYS_sigsuspend - syscall - bne a3, zero, 1f - move v0, zero # should not happen - j ra -1: - j _C_LABEL(cerror) -END(sigsuspend) diff --git a/lib/libc/arch/mips/sys/syscall.s b/lib/libc/arch/mips/sys/syscall.s deleted file mode 100644 index c4cffd42636a..000000000000 --- a/lib/libc/arch/mips/sys/syscall.s +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - ASMSTR("from: @(#)syscall.s 8.1 (Berkeley) 6/4/93") - ASMSTR("$Id: syscall.s,v 1.1 1994/05/24 07:13:29 glass Exp $") -#endif /* LIBC_SCCS and not lint */ - -#define SYS_syscall 0 - -RSYSCALL(syscall) diff --git a/lib/libc/arch/ns32k/gen/_setjmp.s b/lib/libc/arch/ns32k/gen/_setjmp.s deleted file mode 100644 index e72721d1aec3..000000000000 --- a/lib/libc/arch/ns32k/gen/_setjmp.s +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: _setjmp.s,v 1.1 1993/10/07 00:20:14 cgd Exp $ - * - */ - -#include -#include - -ENTRY(_setjmp) - movd 4(sp), r2 /* jmp_buf */ - movd 0(sp), JMP_BUF_PC(r2) /* pc of caller */ - - sprd sp, JMP_BUF_SP(r2) - sprd fp, JMP_BUF_FP(r2) - sprd sb, JMP_BUF_SB(r2) - movd r3, JMP_BUF_R3(r2) /* save registers r3-r7 */ - movd r4, JMP_BUF_R4(r2) - movd r5, JMP_BUF_R5(r2) - movd r6, JMP_BUF_R6(r2) - movd r7, JMP_BUF_R7(r2) - - movqd 0, r0 - ret 0 - -ENTRY(_longjmp) - movd 4(sp), r2 /* jmp_buf */ - movd 8(sp), r0 /* value */ - - lprd sp, JMP_BUF_SP(r2) - lprd fp, JMP_BUF_FP(r2) - lprd sb, JMP_BUF_SB(r2) - movd JMP_BUF_R3(r2), r3 /* load registers r3-r7 */ - movd JMP_BUF_R4(r2), r4 - movd JMP_BUF_R5(r2), r5 - movd JMP_BUF_R6(r2), r6 - movd JMP_BUF_R7(r2), r7 - - movd JMP_BUF_PC(r2), 0(sp) /* patch return pc */ - - cmpqd 0, r0 - bne nonzero - movqd 1, r0 -nonzero: - ret 0 - diff --git a/lib/libc/arch/ns32k/gen/alloca.s b/lib/libc/arch/ns32k/gen/alloca.s deleted file mode 100644 index 400a31b12291..000000000000 --- a/lib/libc/arch/ns32k/gen/alloca.s +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: alloca.s,v 1.1 1993/10/07 00:20:15 cgd Exp $ - */ -/* - * Note: Saved registers are accessed through the frame pointer so - * no special magic is required here. - */ - -#include - -ENTRY(alloca) - movd tos,r2 /* get return address */ - movd tos,r1 /* get length */ - sprd sp,r0 - subd r1,r0 - lprd sp,r0 - movd r1,tos - jump 0(r2) diff --git a/lib/libc/arch/ns32k/gen/fabs.s b/lib/libc/arch/ns32k/gen/fabs.s deleted file mode 100644 index 6d1841c7197d..000000000000 --- a/lib/libc/arch/ns32k/gen/fabs.s +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: fabs.s,v 1.1 1993/10/07 00:20:16 cgd Exp $ - */ - -#include - -ENTRY(fabs) - absl S_ARG0,f0 - ret 0 diff --git a/lib/libc/arch/ns32k/gen/frexp.s b/lib/libc/arch/ns32k/gen/frexp.s deleted file mode 100644 index 02b4dc404a94..000000000000 --- a/lib/libc/arch/ns32k/gen/frexp.s +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Tero Kivinen (kivinen) at Helsinki University of Technology - * Created. - * - * $Id: frexp.s,v 1.1 1993/10/07 00:20:17 cgd Exp $ - */ - -/* - double frexp(value, eptr) - double value; - int *eptr; - - The frexp subroutine returns the mantissa of a double value - as a double quantity, x, of magnitude less than one and - greater than or equal to 0.5 (0.5 <= |x| < 1) and stores an - integer n such that value = x*2**n indirectly through eptr. - - One exception: if the given value is 0, then x and *eptr are made - zero. -*/ - -#include - -ENTRY(frexp) - enter [],8 - movd 12(fp),r1 /* value, high 32 bit */ - cmpd 0,r1 /* check if 0 */ - beq frexp_zero /* we do not support denormalized values */ - movd r1,r2 - bicd 0x7ff00000,r2 /* clear exponent */ - ord 0x3fe00000,r2 /* set it to 1024 == exponent -11 == .5-1 */ - lshd -20,r1 /* extract exponent */ - andd 0x7ff,r1 /* 11 lower bits */ - subd 1022,r1 /* unbias exponent */ - movd r1,0(16(fp)) - movd 8(fp),-8(fp) /* value, low 32 bit */ - movd r2,-4(fp) /* value without exponent, high 32 bit */ - movl -8(fp),f0 /* load return value */ - exit [] - ret 0 -frexp_zero: - movqd 0,0(16(fp)) /* return exp = 0, mantissa = 9 */ - movdl 0,f0 - exit [] - ret 0 - diff --git a/lib/libc/arch/ns32k/gen/ldexp.s b/lib/libc/arch/ns32k/gen/ldexp.s deleted file mode 100644 index 011014e42f70..000000000000 --- a/lib/libc/arch/ns32k/gen/ldexp.s +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Tero Kivinen (kivinen) at Helsinki University of Technology - * Created. - * - * $Id: ldexp.s,v 1.1 1993/10/07 00:20:21 cgd Exp $ - */ - -/* - * double ldexp (value, exp) - * double value; - * int exp; - * - * Ldexp returns value*2**exp, if that result is in range. - * If underflow occurs, it returns zero. If overflow occurs, - * it returns a value of appropriate sign and largest - * possible magnitude. In case of either overflow or underflow, - * errno is set to ERANGE. Note that errno is not modified if - * no error occurs. - */ - -#include - -#define ERANGE 34 - - .globl EX(errno) - -ENTRY(ldexp) - enter [],8 - movd 12(fp),r1 /* get value, high 32 bit */ - lshd -20,r1 /* extract exponent */ - andd 0x7ff,r1 /* 11 lower bits */ - subd 1023,r1 /* unbias exponent */ - movd 16(fp),r0 /* get exp */ - addd r1,r0 /* add exponents */ - cmpd r0,1023 /* most positive exponent */ - bgt ldexp_overflow /* too large */ - cmpd r0,-1022 /* most negative exponent */ - blt ldexp_underflow /* too small */ - addd 1023,r0 /* bias exponent */ - lshd 20,r0 /* convert exponent back to its place */ - movd 12(fp),r1 /* get value high 32 bit */ - bicd 0x7ff00000,r1 /* clear exponent */ - ord r0,r1 /* insert exponent */ - movd r1,-4(fp) /* put high 32 bit to local variable */ - movd 8(fp),-8(fp) /* value low 32 bit to local variable */ - movl -8(fp),f0 /* return value * 2**exp */ - exit [] - ret 0 /* neither */ -ldexp_underflow: - movdl 0d0e0,f0 /* if underflow return 0, set errno */ - movd ERANGE,@EX(errno) - exit [] - ret 0 -ldexp_overflow: - movl @huge,f0 /* if overflow return HUGE */ - movdl 0d0e0,f2 - cmpl f2,8(fp) /* check original sign */ - bgt ldexp_positive - negl f0,f0 /* if negative, return -HUGE */ -ldexp_positive: - movd ERANGE,@EX(errno) /* set errno */ - exit [] - ret 0 - -huge: .long 0xffffffff /* the largest number that can */ - .long 0x7fefffff /* be represented in a long floating */ - /* number. This is given in hex in order */ - /* to avoid floating conversions */ diff --git a/lib/libc/arch/ns32k/gen/modf.s b/lib/libc/arch/ns32k/gen/modf.s deleted file mode 100644 index 5ff045204724..000000000000 --- a/lib/libc/arch/ns32k/gen/modf.s +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Tero Kivinen (kivinen) at Helsinki University of Technology - * Created. - * - * $Id: modf.s,v 1.1 1993/10/07 00:20:22 cgd Exp $ - */ - -/* - * double modf (value, iptr) - * double value, *iptr; - * - * Modf returns the fractional part of "value", - * and stores the integer part indirectly through "iptr". - */ - -#include - -ENTRY(modf) - FRAME - movl 8(fp),f0 /* value */ - movd 12(fp),r0 /* higher 32 bit of value */ - lshd -20,r0 /* extract exponent */ - andd 0x7ff,r0 /* 11 lower bits */ - cmpd r0,1023+30 /* compare if it's int part can fit in int */ - bgt modf_overflow /* nope else it's ok to truncld it to int*/ - truncld f0,r0 /* get integer part */ - movdl r0,f2 /* convert back to float */ - movl f2,0(16(fp)) /* move integer part to *iptr */ - subl f2,f0 /* return fract. part = value - *iptr */ - EMARF - ret 0 -modf_overflow: - subd 1023+20,r0 /* bias 1023, and upper part of - floating point mantissa part */ - movqd -1,r2 /* generate mask to get fract. part */ - cmpd r0,32 /* if value > 2^52 (20+32) then all int part */ - bhi modf_all_ip - negd r0,r0 /* shift right */ - lshd r0,r2 /* here */ - comd r2,r2 /* get fractional part complement mask */ - movd 8(fp),r1 /* get lower 32 bit of value */ - andd r2,r1 /* mask fractional part off leave ip part */ - movd r1,0(16(fp)) /* store ip part to *iptr */ - movd 12(fp),4(16(fp)) /* store other half to *iptr */ - subl 0(16(fp)),f0 /* return fract. part = value - *iptr */ - EMARF - ret 0 -modf_all_ip: - movl 8(fp),0(16(fp)) /* copy value to *iptr */ - movdl 0,f0 /* return 0 for fract. part */ - EMARF - ret 0 diff --git a/lib/libc/arch/ns32k/gen/setjmp.s b/lib/libc/arch/ns32k/gen/setjmp.s deleted file mode 100644 index 5ee44cb937fd..000000000000 --- a/lib/libc/arch/ns32k/gen/setjmp.s +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: setjmp.s,v 1.1 1993/10/07 00:20:24 cgd Exp $ - */ - -#include -#include - -ENTRY(setjmp) - movqd 0, tos - bsr EX(sigblock) - adjspb -4 - movd 4(sp), r2 /* jmp_buf */ - movd 0(sp), JMP_BUF_PC(r2) /* pc of caller */ - movd r0, JMP_BUF_SIGMASK(r2) /* save mask */ - - sprd sp, JMP_BUF_SP(r2) - sprd fp, JMP_BUF_FP(r2) - sprd sb, JMP_BUF_SB(r2) - movd r3, JMP_BUF_R3(r2) /* save registers r3-r7 */ - movd r4, JMP_BUF_R4(r2) - movd r5, JMP_BUF_R5(r2) - movd r6, JMP_BUF_R6(r2) - movd r7, JMP_BUF_R7(r2) - - movqd 0, r0 - ret 0 - -ENTRY(longjmp) - movd 4(sp),r2 /* jmp_buf */ - movd JMP_BUF_SIGMASK(r2), tos /* restore mask */ - bsr EX(sigsetmask) - adjspb -4 - movd 4(sp), r2 /* jmp_buf */ - movd 8(sp), r0 /* value */ - - lprd sp, JMP_BUF_SP(r2) - lprd fp, JMP_BUF_FP(r2) - lprd sb, JMP_BUF_SB(r2) - movd JMP_BUF_R3(r2), r3 /* load registers r3-r7 */ - movd JMP_BUF_R4(r2), r4 - movd JMP_BUF_R5(r2), r5 - movd JMP_BUF_R6(r2), r6 - movd JMP_BUF_R7(r2), r7 - movd JMP_BUF_PC(r2), 0(sp) /* patch return pc */ - - cmpqd 0, r0 - bne nonzero - movqd 1, r0 -nonzero: - ret 0 - diff --git a/lib/libc/arch/ns32k/net/ntoh.S b/lib/libc/arch/ns32k/net/ntoh.S deleted file mode 100644 index 24216c7b81c1..000000000000 --- a/lib/libc/arch/ns32k/net/ntoh.S +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992 Carnegie Mellon University - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON AND HELSINKI UNIVERSITY OF TECHNOLOGY ALLOW FREE USE - * OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON AND - * HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIM ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * HISTORY - * 11-May-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: ntoh.S,v 1.1 1993/10/07 00:20:29 cgd Exp $ - */ - -#include - - .text -Entry(ntohl) -ENTRY(htonl) - movd S_ARG0,r0 - rotw 8,r0 - rotd 16,r0 - rotw 8,r0 - ret 0 - - -Entry(ntohs) -ENTRY(htons) - movzwd S_ARG0,r0 - rotw 8,r0 - ret 0 diff --git a/lib/libc/arch/ns32k/net/ntoh.s b/lib/libc/arch/ns32k/net/ntoh.s deleted file mode 100644 index 8a68eac2ff91..000000000000 --- a/lib/libc/arch/ns32k/net/ntoh.s +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992 Carnegie Mellon University - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON AND HELSINKI UNIVERSITY OF TECHNOLOGY ALLOW FREE USE - * OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON AND - * HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIM ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * HISTORY - * 11-May-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: ntoh.s,v 1.1 1993/10/07 00:20:29 cgd Exp $ - */ - -#include - - .text -Entry(ntohl) -ENTRY(htonl) - movd S_ARG0,r0 - rotw 8,r0 - rotd 16,r0 - rotw 8,r0 - ret 0 - - -Entry(ntohs) -ENTRY(htons) - movzwd S_ARG0,r0 - rotw 8,r0 - ret 0 diff --git a/lib/libc/arch/ns32k/stdlib/abs.s b/lib/libc/arch/ns32k/stdlib/abs.s deleted file mode 100644 index 021ca7efacc4..000000000000 --- a/lib/libc/arch/ns32k/stdlib/abs.s +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: abs.s,v 1.1 1993/10/07 00:20:37 cgd Exp $ - */ - -#include - -ENTRY(abs) - absd S_ARG0,r0 - ret 0 diff --git a/lib/libc/arch/ns32k/sys/Ovfork.s b/lib/libc/arch/ns32k/sys/Ovfork.s deleted file mode 100644 index f83ab8a00c5a..000000000000 --- a/lib/libc/arch/ns32k/sys/Ovfork.s +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: Ovfork.s,v 1.1 1993/10/07 00:20:49 cgd Exp $ - */ - -#include -#include "SYS.h" - -/* - * r0 = pid of child in parent / pid of parent in child - * r1 = 0 in parent, 1 in child - */ -SYSCALL(vfork) - cmpqd 0,r1 - beq parent - movqd 0,r0 -parent: - ret 0 diff --git a/lib/libc/arch/ns32k/sys/brk.s b/lib/libc/arch/ns32k/sys/brk.s deleted file mode 100644 index 39f469a0b643..000000000000 --- a/lib/libc/arch/ns32k/sys/brk.s +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 11-May-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: brk.s,v 1.1 1993/10/07 00:20:51 cgd Exp $ - */ - -#include -#include "SYS.h" - - .globl _curbrk - .globl _minbrk - -ENTRY(_brk) - br ok - -ENTRY(brk) - cmpd S_ARG0, _minbrk(pc) - bge ok - movd _minbrk(pc), S_ARG0 -ok: - movd SYS_break,r0 - SVC - bcs cerror - movd S_ARG0, _curbrk(pc) - movqd 0, r0 - ret 0 diff --git a/lib/libc/arch/ns32k/sys/cerror.s b/lib/libc/arch/ns32k/sys/cerror.s deleted file mode 100644 index a901e3988691..000000000000 --- a/lib/libc/arch/ns32k/sys/cerror.s +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: cerror.s,v 1.1 1993/10/07 00:20:52 cgd Exp $ - */ - -#include "SYS.h" - - .globl cerror - .globl _errno - -cerror: - movd r0,_errno(pc) - movd -1,r0 - ret 0 diff --git a/lib/libc/arch/ns32k/sys/exect.s b/lib/libc/arch/ns32k/sys/exect.s deleted file mode 100644 index ec7d57b7c0cd..000000000000 --- a/lib/libc/arch/ns32k/sys/exect.s +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: exect.s,v 1.1 1993/10/07 00:20:53 cgd Exp $ - */ - -#include "SYS.h" -#include - -ENTRY(exect) - sprb us,r0 - orb PSR_T,r0 - lprb us,r0 - movd SYS_execve,r0 - SVC - bcs cerror - ret 0 diff --git a/lib/libc/arch/ns32k/sys/fork.s b/lib/libc/arch/ns32k/sys/fork.s deleted file mode 100644 index 29ac351092d6..000000000000 --- a/lib/libc/arch/ns32k/sys/fork.s +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: fork.s,v 1.1 1993/10/07 00:20:56 cgd Exp $ - */ - -#include -#include "SYS.h" - -/* r0 = pid. r1 = 0 in parent, 1 in child */ - -SYSCALL(fork) - cmpqd 0, r1 - beq parent - movqd 0, r0 -parent: - ret 0 /* pid = fork() */ diff --git a/lib/libc/arch/ns32k/sys/mount.s b/lib/libc/arch/ns32k/sys/mount.s deleted file mode 100644 index c476e9a72c81..000000000000 --- a/lib/libc/arch/ns32k/sys/mount.s +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: mount.s,v 1.1 1993/10/07 00:20:57 cgd Exp $ - */ - -#include -#include "SYS.h" - -SYSCALL(mount) - movqd 0,r0 - ret 0 diff --git a/lib/libc/arch/ns32k/sys/pipe.s b/lib/libc/arch/ns32k/sys/pipe.s deleted file mode 100644 index 760d7e3b655b..000000000000 --- a/lib/libc/arch/ns32k/sys/pipe.s +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: pipe.s,v 1.1 1993/10/07 00:20:57 cgd Exp $ - */ - -#include -#include - -SYSCALL(pipe) - movd S_ARG0, r2 - movd r0, 0(r2) - movd r1, 4(r2) - movqd 0, r0 - ret 0 diff --git a/lib/libc/arch/ns32k/sys/ptrace.s b/lib/libc/arch/ns32k/sys/ptrace.s deleted file mode 100644 index 690b5ad51c5e..000000000000 --- a/lib/libc/arch/ns32k/sys/ptrace.s +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: ptrace.s,v 1.1 1993/10/07 00:20:58 cgd Exp $ - */ - -/* - * This is included for the NetBSD version! - */ - -#include -#include "SYS.h" - - .globl EX(errno) - .globl cerror - -ENTRY(ptrace) - movqd 0, EX(errno) - movd SYS_ptrace, r0 - SVC - bcs cerror - ret 0 diff --git a/lib/libc/arch/ns32k/sys/reboot.s b/lib/libc/arch/ns32k/sys/reboot.s deleted file mode 100644 index 975a687eddfa..000000000000 --- a/lib/libc/arch/ns32k/sys/reboot.s +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ - -/* This is a modified copy of mount.s. Phil Nelson - * - * $Id: reboot.s,v 1.1 1993/10/07 00:20:59 cgd Exp $ - */ - -#include -#include "SYS.h" - -SYSCALL(reboot) - dia - diff --git a/lib/libc/arch/ns32k/sys/sbrk.s b/lib/libc/arch/ns32k/sys/sbrk.s deleted file mode 100644 index 85203d4f87d8..000000000000 --- a/lib/libc/arch/ns32k/sys/sbrk.s +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sbrk.s,v 1.1 1993/10/07 00:21:01 cgd Exp $ - */ - -#include -#include "SYS.h" - - .globl _end - .globl _curbrk - .globl _minbrk - - .data -_curbrk: .long _end -_minbrk: .long _end - .text - -ENTRY(sbrk) - addd _curbrk(pc), S_ARG0 - movd SYS_break,r0 - SVC - bcs cerror - movd _curbrk(pc), r0 - movd S_ARG0,_curbrk(pc) /* XXX check this b*/ - ret 0 diff --git a/lib/libc/arch/ns32k/sys/setlogin.s b/lib/libc/arch/ns32k/sys/setlogin.s deleted file mode 100644 index cdc330adbe9e..000000000000 --- a/lib/libc/arch/ns32k/sys/setlogin.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: setlogin.s,v 1.1 1993/10/07 00:21:02 cgd Exp $ - */ - -#include -#include "SYS.h" - -.globl EX(_logname_valid) /* in getlogin() */ - -SYSCALL(setlogin) - movqd 0, EX(_logname_valid) - ret 0 /* setlogin(name) */ diff --git a/lib/libc/arch/ns32k/sys/sigpending.s b/lib/libc/arch/ns32k/sys/sigpending.s deleted file mode 100644 index efd2f44dc4df..000000000000 --- a/lib/libc/arch/ns32k/sys/sigpending.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigpending.s,v 1.1 1993/10/07 00:21:03 cgd Exp $ - */ - -#include -#include "SYS.h" - -SYSCALL(sigpending) - movd S_ARG1, r1 /* fetch pointer to... */ - movd r0, 0(r1) /* store old mask */ - movqd 0, r0 - ret 0 diff --git a/lib/libc/arch/ns32k/sys/sigprocmask.s b/lib/libc/arch/ns32k/sys/sigprocmask.s deleted file mode 100644 index 15aedac8f2de..000000000000 --- a/lib/libc/arch/ns32k/sys/sigprocmask.s +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigprocmask.s,v 1.1 1993/10/07 00:21:04 cgd Exp $ - */ - -/* - * Note: Has never been tested. Debug before use. - */ - - -#include -#include "SYS.h" - -ENTRY(sigprocmask) - movd S_ARG1, r1 /* fetch new sigset pointer */ - cmpqd 0, r1 /* check new sigset pointer */ - bne L1 /* if not null, indirect */ -/* movqd 0, S_ARG1 /* null mask pointer: block empty set */ - movqd 1, S_ARG0 /* SIG_BLOCK */ - br L2 -L1: movd 0(r1), r1 /* fetch indirect ... */ - movd r1, S_ARG1 /* to new mask arg */ -L2: movd SYS_sigprocmask, r0 - SVC - bcs cerror - movd S_ARG2, r1 /* fetch old mask requested */ - cmpqd 0, r1 /* test if old mask requested */ - beq out - movd r0, 0(r1) /* store old mask */ -out: - movqd 0, r0 - ret 0 diff --git a/lib/libc/arch/ns32k/sys/sigreturn.s b/lib/libc/arch/ns32k/sys/sigreturn.s deleted file mode 100644 index e961f1791239..000000000000 --- a/lib/libc/arch/ns32k/sys/sigreturn.s +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigreturn.s,v 1.1 1993/10/07 00:21:05 cgd Exp $ - */ - -#include -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef PROF -#undef ENTRY -#define ENTRY(x) \ - .globl EX(x); .align ALIGN; EX(x): save [r0,r1,r2]; \ - .data; LB(sigr,1):; .long 0; .text; addr @LBb(sigr,1),r1; bsr mcount; restore [r0,r1,r2] -#endif PROF - -SYSCALL(sigreturn) - ret 0 diff --git a/lib/libc/arch/ns32k/sys/sigsuspend.s b/lib/libc/arch/ns32k/sys/sigsuspend.s deleted file mode 100644 index 4e76011300e7..000000000000 --- a/lib/libc/arch/ns32k/sys/sigsuspend.s +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigsuspend.s,v 1.1 1993/10/07 00:21:06 cgd Exp $ - */ - -#include -#include "SYS.h" - -ENTRY(sigsuspend) - movd S_ARG0, r0 /* fetch mask arg */ - movd 0(r0), r0 /* indirect to mask arg */ - movd r0, S_ARG0 - movd SYS_sigsuspend, r0 - SVC - bcs cerror - movqd 0, r0 /* shouldn t happen */ - ret 0 diff --git a/lib/libc/arch/ns32k/sys/syscall.s b/lib/libc/arch/ns32k/sys/syscall.s deleted file mode 100644 index 8076cfb9ba1e..000000000000 --- a/lib/libc/arch/ns32k/sys/syscall.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: syscall.s,v 1.1 1993/10/07 00:21:07 cgd Exp $ - */ - -#include -#include "SYS.h" - -ENTRY(syscall) - movqd 0, r0 /* Tell system this is syscall! */ - SVC - bcs cerror - ret 0 diff --git a/lib/libc/arch/pc532/gen/ldexp.S b/lib/libc/arch/pc532/gen/ldexp.S deleted file mode 100644 index 3159d428ae18..000000000000 --- a/lib/libc/arch/pc532/gen/ldexp.S +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Tero Kivinen (kivinen) at Helsinki University of Technology - * Created. - * - * $Id: ldexp.S,v 1.1 1993/10/07 00:20:21 cgd Exp $ - */ - -/* - * double ldexp (value, exp) - * double value; - * int exp; - * - * Ldexp returns value*2**exp, if that result is in range. - * If underflow occurs, it returns zero. If overflow occurs, - * it returns a value of appropriate sign and largest - * possible magnitude. In case of either overflow or underflow, - * errno is set to ERANGE. Note that errno is not modified if - * no error occurs. - */ - -#include - -#define ERANGE 34 - - .globl EX(errno) - -ENTRY(ldexp) - enter [],8 - movd 12(fp),r1 /* get value, high 32 bit */ - lshd -20,r1 /* extract exponent */ - andd 0x7ff,r1 /* 11 lower bits */ - subd 1023,r1 /* unbias exponent */ - movd 16(fp),r0 /* get exp */ - addd r1,r0 /* add exponents */ - cmpd r0,1023 /* most positive exponent */ - bgt ldexp_overflow /* too large */ - cmpd r0,-1022 /* most negative exponent */ - blt ldexp_underflow /* too small */ - addd 1023,r0 /* bias exponent */ - lshd 20,r0 /* convert exponent back to its place */ - movd 12(fp),r1 /* get value high 32 bit */ - bicd 0x7ff00000,r1 /* clear exponent */ - ord r0,r1 /* insert exponent */ - movd r1,-4(fp) /* put high 32 bit to local variable */ - movd 8(fp),-8(fp) /* value low 32 bit to local variable */ - movl -8(fp),f0 /* return value * 2**exp */ - exit [] - ret 0 /* neither */ -ldexp_underflow: - movdl 0d0e0,f0 /* if underflow return 0, set errno */ - movd ERANGE,@EX(errno) - exit [] - ret 0 -ldexp_overflow: - movl @huge,f0 /* if overflow return HUGE */ - movdl 0d0e0,f2 - cmpl f2,8(fp) /* check original sign */ - bgt ldexp_positive - negl f0,f0 /* if negative, return -HUGE */ -ldexp_positive: - movd ERANGE,@EX(errno) /* set errno */ - exit [] - ret 0 - -huge: .long 0xffffffff /* the largest number that can */ - .long 0x7fefffff /* be represented in a long floating */ - /* number. This is given in hex in order */ - /* to avoid floating conversions */ diff --git a/lib/libc/arch/pc532/gen/modf.S b/lib/libc/arch/pc532/gen/modf.S deleted file mode 100644 index cabf162ed341..000000000000 --- a/lib/libc/arch/pc532/gen/modf.S +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Tero Kivinen (kivinen) at Helsinki University of Technology - * Created. - * - * $Id: modf.S,v 1.1 1993/10/07 00:20:22 cgd Exp $ - */ - -/* - * double modf (value, iptr) - * double value, *iptr; - * - * Modf returns the fractional part of "value", - * and stores the integer part indirectly through "iptr". - */ - -#include - -ENTRY(modf) - FRAME - movl 8(fp),f0 /* value */ - movd 12(fp),r0 /* higher 32 bit of value */ - lshd -20,r0 /* extract exponent */ - andd 0x7ff,r0 /* 11 lower bits */ - cmpd r0,1023+30 /* compare if it's int part can fit in int */ - bgt modf_overflow /* nope else it's ok to truncld it to int*/ - truncld f0,r0 /* get integer part */ - movdl r0,f2 /* convert back to float */ - movl f2,0(16(fp)) /* move integer part to *iptr */ - subl f2,f0 /* return fract. part = value - *iptr */ - EMARF - ret 0 -modf_overflow: - subd 1023+20,r0 /* bias 1023, and upper part of - floating point mantissa part */ - movqd -1,r2 /* generate mask to get fract. part */ - cmpd r0,32 /* if value > 2^52 (20+32) then all int part */ - bhi modf_all_ip - negd r0,r0 /* shift right */ - lshd r0,r2 /* here */ - comd r2,r2 /* get fractional part complement mask */ - movd 8(fp),r1 /* get lower 32 bit of value */ - andd r2,r1 /* mask fractional part off leave ip part */ - movd r1,0(16(fp)) /* store ip part to *iptr */ - movd 12(fp),4(16(fp)) /* store other half to *iptr */ - subl 0(16(fp)),f0 /* return fract. part = value - *iptr */ - EMARF - ret 0 -modf_all_ip: - movl 8(fp),0(16(fp)) /* copy value to *iptr */ - movdl 0,f0 /* return 0 for fract. part */ - EMARF - ret 0 diff --git a/lib/libc/arch/pc532/gen/setjmp.S b/lib/libc/arch/pc532/gen/setjmp.S deleted file mode 100644 index 401e6cd7d525..000000000000 --- a/lib/libc/arch/pc532/gen/setjmp.S +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: setjmp.S,v 1.1 1993/10/07 00:20:24 cgd Exp $ - */ - -#include -#include - -ENTRY(setjmp) - movqd 0, tos - bsr EX(sigblock) - adjspb -4 - movd 4(sp), r2 /* jmp_buf */ - movd 0(sp), JMP_BUF_PC(r2) /* pc of caller */ - movd r0, JMP_BUF_SIGMASK(r2) /* save mask */ - - sprd sp, JMP_BUF_SP(r2) - sprd fp, JMP_BUF_FP(r2) - sprd sb, JMP_BUF_SB(r2) - movd r3, JMP_BUF_R3(r2) /* save registers r3-r7 */ - movd r4, JMP_BUF_R4(r2) - movd r5, JMP_BUF_R5(r2) - movd r6, JMP_BUF_R6(r2) - movd r7, JMP_BUF_R7(r2) - - movqd 0, r0 - ret 0 - -ENTRY(longjmp) - movd 4(sp),r2 /* jmp_buf */ - movd JMP_BUF_SIGMASK(r2), tos /* restore mask */ - bsr EX(sigsetmask) - adjspb -4 - movd 4(sp), r2 /* jmp_buf */ - movd 8(sp), r0 /* value */ - - lprd sp, JMP_BUF_SP(r2) - lprd fp, JMP_BUF_FP(r2) - lprd sb, JMP_BUF_SB(r2) - movd JMP_BUF_R3(r2), r3 /* load registers r3-r7 */ - movd JMP_BUF_R4(r2), r4 - movd JMP_BUF_R5(r2), r5 - movd JMP_BUF_R6(r2), r6 - movd JMP_BUF_R7(r2), r7 - movd JMP_BUF_PC(r2), 0(sp) /* patch return pc */ - - cmpqd 0, r0 - bne nonzero - movqd 1, r0 -nonzero: - ret 0 - diff --git a/lib/libc/arch/pc532/sys/reboot.S b/lib/libc/arch/pc532/sys/reboot.S deleted file mode 100644 index 544ee27ac912..000000000000 --- a/lib/libc/arch/pc532/sys/reboot.S +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ - -/* This is a modified copy of mount.s. Phil Nelson - * - * $Id: reboot.S,v 1.1 1993/10/07 00:20:59 cgd Exp $ - */ - -#include -#include "SYS.h" - -SYSCALL(reboot) - dia - diff --git a/lib/libc/arch/pc532/sys/reboot.s b/lib/libc/arch/pc532/sys/reboot.s deleted file mode 100644 index 975a687eddfa..000000000000 --- a/lib/libc/arch/pc532/sys/reboot.s +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ - -/* This is a modified copy of mount.s. Phil Nelson - * - * $Id: reboot.s,v 1.1 1993/10/07 00:20:59 cgd Exp $ - */ - -#include -#include "SYS.h" - -SYSCALL(reboot) - dia - diff --git a/lib/libc/arch/pc532/sys/sbrk.S b/lib/libc/arch/pc532/sys/sbrk.S deleted file mode 100644 index 5090eadb2295..000000000000 --- a/lib/libc/arch/pc532/sys/sbrk.S +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sbrk.S,v 1.1 1993/10/07 00:21:01 cgd Exp $ - */ - -#include -#include "SYS.h" - - .globl _end - .globl _curbrk - .globl _minbrk - - .data -_curbrk: .long _end -_minbrk: .long _end - .text - -ENTRY(sbrk) - addd _curbrk(pc), S_ARG0 - movd SYS_break,r0 - SVC - bcs cerror - movd _curbrk(pc), r0 - movd S_ARG0,_curbrk(pc) /* XXX check this b*/ - ret 0 diff --git a/lib/libc/arch/pc532/sys/sbrk.s b/lib/libc/arch/pc532/sys/sbrk.s deleted file mode 100644 index 85203d4f87d8..000000000000 --- a/lib/libc/arch/pc532/sys/sbrk.s +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sbrk.s,v 1.1 1993/10/07 00:21:01 cgd Exp $ - */ - -#include -#include "SYS.h" - - .globl _end - .globl _curbrk - .globl _minbrk - - .data -_curbrk: .long _end -_minbrk: .long _end - .text - -ENTRY(sbrk) - addd _curbrk(pc), S_ARG0 - movd SYS_break,r0 - SVC - bcs cerror - movd _curbrk(pc), r0 - movd S_ARG0,_curbrk(pc) /* XXX check this b*/ - ret 0 diff --git a/lib/libc/arch/pc532/sys/setlogin.S b/lib/libc/arch/pc532/sys/setlogin.S deleted file mode 100644 index cfa765010bb9..000000000000 --- a/lib/libc/arch/pc532/sys/setlogin.S +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: setlogin.S,v 1.1 1993/10/07 00:21:02 cgd Exp $ - */ - -#include -#include "SYS.h" - -.globl EX(_logname_valid) /* in getlogin() */ - -SYSCALL(setlogin) - movqd 0, EX(_logname_valid) - ret 0 /* setlogin(name) */ diff --git a/lib/libc/arch/pc532/sys/setlogin.s b/lib/libc/arch/pc532/sys/setlogin.s deleted file mode 100644 index cdc330adbe9e..000000000000 --- a/lib/libc/arch/pc532/sys/setlogin.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: setlogin.s,v 1.1 1993/10/07 00:21:02 cgd Exp $ - */ - -#include -#include "SYS.h" - -.globl EX(_logname_valid) /* in getlogin() */ - -SYSCALL(setlogin) - movqd 0, EX(_logname_valid) - ret 0 /* setlogin(name) */ diff --git a/lib/libc/arch/pc532/sys/sigpending.S b/lib/libc/arch/pc532/sys/sigpending.S deleted file mode 100644 index 0a7abd2e5b73..000000000000 --- a/lib/libc/arch/pc532/sys/sigpending.S +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigpending.S,v 1.1 1993/10/07 00:21:03 cgd Exp $ - */ - -#include -#include "SYS.h" - -SYSCALL(sigpending) - movd S_ARG1, r1 /* fetch pointer to... */ - movd r0, 0(r1) /* store old mask */ - movqd 0, r0 - ret 0 diff --git a/lib/libc/arch/pc532/sys/sigpending.s b/lib/libc/arch/pc532/sys/sigpending.s deleted file mode 100644 index efd2f44dc4df..000000000000 --- a/lib/libc/arch/pc532/sys/sigpending.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigpending.s,v 1.1 1993/10/07 00:21:03 cgd Exp $ - */ - -#include -#include "SYS.h" - -SYSCALL(sigpending) - movd S_ARG1, r1 /* fetch pointer to... */ - movd r0, 0(r1) /* store old mask */ - movqd 0, r0 - ret 0 diff --git a/lib/libc/arch/pc532/sys/sigprocmask.S b/lib/libc/arch/pc532/sys/sigprocmask.S deleted file mode 100644 index a23c458c7de9..000000000000 --- a/lib/libc/arch/pc532/sys/sigprocmask.S +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigprocmask.S,v 1.1 1993/10/07 00:21:04 cgd Exp $ - */ - -/* - * Note: Has never been tested. Debug before use. - */ - - -#include -#include "SYS.h" - -ENTRY(sigprocmask) - movd S_ARG1, r1 /* fetch new sigset pointer */ - cmpqd 0, r1 /* check new sigset pointer */ - bne L1 /* if not null, indirect */ -/* movqd 0, S_ARG1 /* null mask pointer: block empty set */ - movqd 1, S_ARG0 /* SIG_BLOCK */ - br L2 -L1: movd 0(r1), r1 /* fetch indirect ... */ - movd r1, S_ARG1 /* to new mask arg */ -L2: movd SYS_sigprocmask, r0 - SVC - bcs cerror - movd S_ARG2, r1 /* fetch old mask requested */ - cmpqd 0, r1 /* test if old mask requested */ - beq out - movd r0, 0(r1) /* store old mask */ -out: - movqd 0, r0 - ret 0 diff --git a/lib/libc/arch/pc532/sys/sigprocmask.s b/lib/libc/arch/pc532/sys/sigprocmask.s deleted file mode 100644 index 15aedac8f2de..000000000000 --- a/lib/libc/arch/pc532/sys/sigprocmask.s +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigprocmask.s,v 1.1 1993/10/07 00:21:04 cgd Exp $ - */ - -/* - * Note: Has never been tested. Debug before use. - */ - - -#include -#include "SYS.h" - -ENTRY(sigprocmask) - movd S_ARG1, r1 /* fetch new sigset pointer */ - cmpqd 0, r1 /* check new sigset pointer */ - bne L1 /* if not null, indirect */ -/* movqd 0, S_ARG1 /* null mask pointer: block empty set */ - movqd 1, S_ARG0 /* SIG_BLOCK */ - br L2 -L1: movd 0(r1), r1 /* fetch indirect ... */ - movd r1, S_ARG1 /* to new mask arg */ -L2: movd SYS_sigprocmask, r0 - SVC - bcs cerror - movd S_ARG2, r1 /* fetch old mask requested */ - cmpqd 0, r1 /* test if old mask requested */ - beq out - movd r0, 0(r1) /* store old mask */ -out: - movqd 0, r0 - ret 0 diff --git a/lib/libc/arch/pc532/sys/sigreturn.S b/lib/libc/arch/pc532/sys/sigreturn.S deleted file mode 100644 index edfdeee359df..000000000000 --- a/lib/libc/arch/pc532/sys/sigreturn.S +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigreturn.S,v 1.1 1993/10/07 00:21:05 cgd Exp $ - */ - -#include -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef PROF -#undef ENTRY -#define ENTRY(x) \ - .globl EX(x); .align ALIGN; EX(x): save [r0,r1,r2]; \ - .data; LB(sigr,1):; .long 0; .text; addr @LBb(sigr,1),r1; bsr mcount; restore [r0,r1,r2] -#endif PROF - -SYSCALL(sigreturn) - ret 0 diff --git a/lib/libc/arch/pc532/sys/sigreturn.s b/lib/libc/arch/pc532/sys/sigreturn.s deleted file mode 100644 index e961f1791239..000000000000 --- a/lib/libc/arch/pc532/sys/sigreturn.s +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigreturn.s,v 1.1 1993/10/07 00:21:05 cgd Exp $ - */ - -#include -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef PROF -#undef ENTRY -#define ENTRY(x) \ - .globl EX(x); .align ALIGN; EX(x): save [r0,r1,r2]; \ - .data; LB(sigr,1):; .long 0; .text; addr @LBb(sigr,1),r1; bsr mcount; restore [r0,r1,r2] -#endif PROF - -SYSCALL(sigreturn) - ret 0 diff --git a/lib/libc/arch/pc532/sys/sigsuspend.S b/lib/libc/arch/pc532/sys/sigsuspend.S deleted file mode 100644 index 201abfa42d59..000000000000 --- a/lib/libc/arch/pc532/sys/sigsuspend.S +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigsuspend.S,v 1.1 1993/10/07 00:21:06 cgd Exp $ - */ - -#include -#include "SYS.h" - -ENTRY(sigsuspend) - movd S_ARG0, r0 /* fetch mask arg */ - movd 0(r0), r0 /* indirect to mask arg */ - movd r0, S_ARG0 - movd SYS_sigsuspend, r0 - SVC - bcs cerror - movqd 0, r0 /* shouldn t happen */ - ret 0 diff --git a/lib/libc/arch/pc532/sys/sigsuspend.s b/lib/libc/arch/pc532/sys/sigsuspend.s deleted file mode 100644 index 4e76011300e7..000000000000 --- a/lib/libc/arch/pc532/sys/sigsuspend.s +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigsuspend.s,v 1.1 1993/10/07 00:21:06 cgd Exp $ - */ - -#include -#include "SYS.h" - -ENTRY(sigsuspend) - movd S_ARG0, r0 /* fetch mask arg */ - movd 0(r0), r0 /* indirect to mask arg */ - movd r0, S_ARG0 - movd SYS_sigsuspend, r0 - SVC - bcs cerror - movqd 0, r0 /* shouldn t happen */ - ret 0 diff --git a/lib/libc/arch/pc532/sys/syscall.S b/lib/libc/arch/pc532/sys/syscall.S deleted file mode 100644 index ca53b87ab48c..000000000000 --- a/lib/libc/arch/pc532/sys/syscall.S +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: syscall.S,v 1.1 1993/10/07 00:21:07 cgd Exp $ - */ - -#include -#include "SYS.h" - -ENTRY(syscall) - movqd 0, r0 /* Tell system this is syscall! */ - SVC - bcs cerror - ret 0 diff --git a/lib/libc/arch/pc532/sys/syscall.s b/lib/libc/arch/pc532/sys/syscall.s deleted file mode 100644 index 8076cfb9ba1e..000000000000 --- a/lib/libc/arch/pc532/sys/syscall.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: syscall.s,v 1.1 1993/10/07 00:21:07 cgd Exp $ - */ - -#include -#include "SYS.h" - -ENTRY(syscall) - movqd 0, r0 /* Tell system this is syscall! */ - SVC - bcs cerror - ret 0 diff --git a/lib/libc/arch/sparc/gen/umul.s b/lib/libc/arch/sparc/gen/umul.s deleted file mode 100644 index 617a5ec19ede..000000000000 --- a/lib/libc/arch/sparc/gen/umul.s +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: umul.s,v 1.4 92/06/25 13:24:05 torek Exp - * $Id: umul.s,v 1.1 1993/10/07 00:21:41 cgd Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)umul.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* - * Unsigned multiply. Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the - * upper 32 bits of the 64-bit product). - * - * This code optimizes short (less than 13-bit) multiplies. Short - * multiplies require 25 instruction cycles, and long ones require - * 45 instruction cycles. - * - * On return, overflow has occurred (%o1 is not zero) if and only if - * the Z condition code is clear, allowing, e.g., the following: - * - * call .umul - * nop - * bnz overflow (or tnz) - */ - -#include "DEFS.h" -FUNC(.umul) - or %o0, %o1, %o4 - mov %o0, %y ! multiplier -> Y - andncc %o4, 0xfff, %g0 ! test bits 12..31 of *both* args - be Lmul_shortway ! if zero, can do it the short way - andcc %g0, %g0, %o4 ! zero the partial product and clear N and V - - /* - * Long multiply. 32 steps, followed by a final shift step. - */ - mulscc %o4, %o1, %o4 ! 1 - mulscc %o4, %o1, %o4 ! 2 - mulscc %o4, %o1, %o4 ! 3 - mulscc %o4, %o1, %o4 ! 4 - mulscc %o4, %o1, %o4 ! 5 - mulscc %o4, %o1, %o4 ! 6 - mulscc %o4, %o1, %o4 ! 7 - mulscc %o4, %o1, %o4 ! 8 - mulscc %o4, %o1, %o4 ! 9 - mulscc %o4, %o1, %o4 ! 10 - mulscc %o4, %o1, %o4 ! 11 - mulscc %o4, %o1, %o4 ! 12 - mulscc %o4, %o1, %o4 ! 13 - mulscc %o4, %o1, %o4 ! 14 - mulscc %o4, %o1, %o4 ! 15 - mulscc %o4, %o1, %o4 ! 16 - mulscc %o4, %o1, %o4 ! 17 - mulscc %o4, %o1, %o4 ! 18 - mulscc %o4, %o1, %o4 ! 19 - mulscc %o4, %o1, %o4 ! 20 - mulscc %o4, %o1, %o4 ! 21 - mulscc %o4, %o1, %o4 ! 22 - mulscc %o4, %o1, %o4 ! 23 - mulscc %o4, %o1, %o4 ! 24 - mulscc %o4, %o1, %o4 ! 25 - mulscc %o4, %o1, %o4 ! 26 - mulscc %o4, %o1, %o4 ! 27 - mulscc %o4, %o1, %o4 ! 28 - mulscc %o4, %o1, %o4 ! 29 - mulscc %o4, %o1, %o4 ! 30 - mulscc %o4, %o1, %o4 ! 31 - mulscc %o4, %o1, %o4 ! 32 - mulscc %o4, %g0, %o4 ! final shift - - - /* - * Normally, with the shift-and-add approach, if both numbers are - * positive you get the correct result. WIth 32-bit two's-complement - * numbers, -x is represented as - * - * x 32 - * ( 2 - ------ ) mod 2 * 2 - * 32 - * 2 - * - * (the `mod 2' subtracts 1 from 1.bbbb). To avoid lots of 2^32s, - * we can treat this as if the radix point were just to the left - * of the sign bit (multiply by 2^32), and get - * - * -x = (2 - x) mod 2 - * - * Then, ignoring the `mod 2's for convenience: - * - * x * y = xy - * -x * y = 2y - xy - * x * -y = 2x - xy - * -x * -y = 4 - 2x - 2y + xy - * - * For signed multiplies, we subtract (x << 32) from the partial - * product to fix this problem for negative multipliers (see mul.s). - * Because of the way the shift into the partial product is calculated - * (N xor V), this term is automatically removed for the multiplicand, - * so we don't have to adjust. - * - * But for unsigned multiplies, the high order bit wasn't a sign bit, - * and the correction is wrong. So for unsigned multiplies where the - * high order bit is one, we end up with xy - (y << 32). To fix it - * we add y << 32. - */ - tst %o1 - bl,a 1f ! if %o1 < 0 (high order bit = 1), - add %o4, %o0, %o4 ! %o4 += %o0 (add y to upper half) -1: rd %y, %o0 ! get lower half of product - retl - addcc %o4, %g0, %o1 ! put upper half in place and set Z for %o1==0 - -Lmul_shortway: - /* - * Short multiply. 12 steps, followed by a final shift step. - * The resulting bits are off by 12 and (32-12) = 20 bit positions, - * but there is no problem with %o0 being negative (unlike above), - * and overflow is impossible (the answer is at most 24 bits long). - */ - mulscc %o4, %o1, %o4 ! 1 - mulscc %o4, %o1, %o4 ! 2 - mulscc %o4, %o1, %o4 ! 3 - mulscc %o4, %o1, %o4 ! 4 - mulscc %o4, %o1, %o4 ! 5 - mulscc %o4, %o1, %o4 ! 6 - mulscc %o4, %o1, %o4 ! 7 - mulscc %o4, %o1, %o4 ! 8 - mulscc %o4, %o1, %o4 ! 9 - mulscc %o4, %o1, %o4 ! 10 - mulscc %o4, %o1, %o4 ! 11 - mulscc %o4, %o1, %o4 ! 12 - mulscc %o4, %g0, %o4 ! final shift - - /* - * %o4 has 20 of the bits that should be in the result; %y has - * the bottom 12 (as %y's top 12). That is: - * - * %o4 %y - * +----------------+----------------+ - * | -12- | -20- | -12- | -20- | - * +------(---------+------)---------+ - * -----result----- - * - * The 12 bits of %o4 left of the `result' area are all zero; - * in fact, all top 20 bits of %o4 are zero. - */ - - rd %y, %o5 - sll %o4, 12, %o0 ! shift middle bits left 12 - srl %o5, 20, %o5 ! shift low bits right 20 - or %o5, %o0, %o0 - retl - addcc %g0, %g0, %o1 ! %o1 = zero, and set Z diff --git a/lib/libc/arch/sparc/sys/reboot.s b/lib/libc/arch/sparc/sys/reboot.s deleted file mode 100644 index 25f988c871b9..000000000000 --- a/lib/libc/arch/sparc/sys/reboot.s +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: reboot.s,v 1.1 91/07/06 13:05:59 torek Exp - * $Id: reboot.s,v 1.1 1993/10/07 00:22:22 cgd Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)reboot.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - unimp 0 diff --git a/lib/libc/arch/sparc/sys/sbrk.s b/lib/libc/arch/sparc/sys/sbrk.s deleted file mode 100644 index e81718c494cc..000000000000 --- a/lib/libc/arch/sparc/sys/sbrk.s +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: sbrk.s,v 1.3 92/07/02 00:56:49 torek Exp - * $Id: sbrk.s,v 1.1 1993/10/07 00:22:24 cgd Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)sbrk.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _end - .globl curbrk - - .data -curbrk: .long _end - .text - -ENTRY(sbrk) - sethi %hi(curbrk), %o2 - ld [%o2 + %lo(curbrk)], %o3 ! %o3 = old break - add %o3, %o0, %o4 ! %o4 = new break - mov %o4, %o0 ! copy for syscall - mov SYS_break, %g1 - t ST_SYSCALL ! break(new_break) - bcc,a 1f ! if success, - mov %o3, %o0 ! set return value - ERROR() -1: - retl ! and update curbrk - st %o4, [%o2 + %lo(curbrk)] diff --git a/lib/libc/arch/sparc/sys/setlogin.s b/lib/libc/arch/sparc/sys/setlogin.s deleted file mode 100644 index 0ff95251741b..000000000000 --- a/lib/libc/arch/sparc/sys/setlogin.s +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: setlogin.s,v 1.1 91/07/06 13:06:00 torek Exp - * $Id: setlogin.s,v 1.1 1993/10/07 00:22:26 cgd Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)setlogin.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl __logname_valid /* in getlogin() */ - -SYSCALL(setlogin) - sethi %hi(__logname_valid), %g1 - retl - st %g0, [%g1 + %lo(__logname_valid)] diff --git a/lib/libc/arch/sparc/sys/sigpending.s b/lib/libc/arch/sparc/sys/sigpending.s deleted file mode 100644 index ebe601882a9a..000000000000 --- a/lib/libc/arch/sparc/sys/sigpending.s +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: sigpending.s,v 1.1 91/07/06 13:06:00 torek Exp - * $Id: sigpending.s,v 1.1 1993/10/07 00:22:27 cgd Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)sigpending.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(sigpending) - mov %o0, %o2 ! save pointer - mov SYS_sigpending, %g1 - t ST_SYSCALL ! sigpending() - bcc,a 1f ! if success, - st %o0, [%o2] ! store return value - ERROR() -1: - retl ! and return 0 - clr %o0 diff --git a/lib/libc/arch/sparc/sys/sigprocmask.s b/lib/libc/arch/sparc/sys/sigprocmask.s deleted file mode 100644 index 9bb1c104a461..000000000000 --- a/lib/libc/arch/sparc/sys/sigprocmask.s +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: sigprocmask.s,v 1.1 91/07/06 13:06:01 torek Exp - * $Id: sigprocmask.s,v 1.1 1993/10/07 00:22:27 cgd Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)sigprocmask.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * sigprocmask(int how, sigset_t *set, sigset_t *oset) - */ -ENTRY(sigprocmask) - tst %o1 ! set == NULL? - bne,a 1f ! if not, - ld [%o1], %o1 ! replace it in %o1 with *set -! clr %o1 ! else block no signals ... - mov 1, %o0 ! ... using sigprocmask(SIG_BLOCK) -1: - mov SYS_sigprocmask, %g1 - t ST_SYSCALL - bcc 2f ! if success, - tst %o2 ! check to see if oset requested - ERROR() -2: - bne,a 3f ! if oset != NULL, - st %o0, [%o2] ! *oset = oldmask -3: - retl ! in any case, return 0 - clr %o0 diff --git a/lib/libc/arch/sparc/sys/sigreturn.s b/lib/libc/arch/sparc/sys/sigreturn.s deleted file mode 100644 index 3689c260335c..000000000000 --- a/lib/libc/arch/sparc/sys/sigreturn.s +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: sigreturn.s,v 1.1 91/07/06 13:06:01 torek Exp - * $Id: sigreturn.s,v 1.1 1993/10/07 00:22:28 cgd Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)sigreturn.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(sigreturn) - mov SYS_sigreturn, %g1 - t ST_SYSCALL - ERROR() diff --git a/lib/libc/arch/sparc/sys/sigsuspend.s b/lib/libc/arch/sparc/sys/sigsuspend.s deleted file mode 100644 index eaf0f738628a..000000000000 --- a/lib/libc/arch/sparc/sys/sigsuspend.s +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: sigsuspend.s,v 1.1 91/07/06 13:06:01 torek Exp - * $Id: sigsuspend.s,v 1.1 1993/10/07 00:22:30 cgd Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)sigsuspend.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(sigsuspend) - ld [%o0], %o0 ! indirect to mask argument - mov SYS_sigsuspend, %g1 - t ST_SYSCALL - ERROR() ! always terminates with EINTR diff --git a/lib/libc/arch/sparc/sys/syscall.s b/lib/libc/arch/sparc/sys/syscall.s deleted file mode 100644 index 4159e6ad8638..000000000000 --- a/lib/libc/arch/sparc/sys/syscall.s +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: syscall.s,v 1.1 91/07/06 13:06:02 torek Exp - * $Id: syscall.s,v 1.1 1993/10/07 00:22:31 cgd Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)syscall.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(syscall) - mov 0|SYSCALL_G2RFLAG, %g1 ! 0 == indir - add %o7, 8, %g2 - t ST_SYSCALL - ERROR() diff --git a/lib/libc/compat-43/creat.2 b/lib/libc/compat-43/creat.2 deleted file mode 100644 index 1bea9674f050..000000000000 --- a/lib/libc/compat-43/creat.2 +++ /dev/null @@ -1,69 +0,0 @@ -.\" Copyright (c) 1989, 1990 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)creat.2 6.10 (Berkeley) 6/23/91 -.\" $Id: creat.2,v 1.7 1994/05/18 14:31:43 jtc Exp $ -.\" -.Dd June 23, 1991 -.Dt CREAT 2 -.Os BSD 4 -.Sh NAME -.Nm creat -.Nd create a new file -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft int -.Fn creat "const char *path" "mode_t mode" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by: -.Ef -.Xr open 2 . -.Pp -.Fn Creat -is the same as: -.Bd -literal -offset indent -open(path, O_CREAT | O_TRUNC | O_WRONLY, mode); -.Ed -.Sh SEE ALSO -.Xr open 2 -.Sh STANDARDS -The -.Fn creat -function call conforms to -.St -p1003.1-90 . -.Sh HISTORY -The -.Fn creat -function call appeared in -.At v6 . diff --git a/lib/libc/compat-43/killpg.2 b/lib/libc/compat-43/killpg.2 deleted file mode 100644 index ca44d36db071..000000000000 --- a/lib/libc/compat-43/killpg.2 +++ /dev/null @@ -1,96 +0,0 @@ -.\" Copyright (c) 1980, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)killpg.2 6.5 (Berkeley) 3/10/91 -.\" $Id: killpg.2,v 1.3 1993/12/01 18:49:52 jtc Exp $ -.\" -.Dd March 10, 1991 -.Dt KILLPG 2 -.Os BSD 4 -.Sh NAME -.Nm killpg -.Nd send signal to a process group -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn killpg "pid_t pgrp" "int sig" -.Sh DESCRIPTION -.Fn Killpg -sends the signal -.Fa sig -to the process group -.Fa pgrp . -See -.Xr sigaction 2 -for a list of signals. -If -.Fa pgrp -is 0, -.Fn killpg -sends the signal to the sending process's process group. -.Pp -The sending process and members of the process group must -have the same effective user ID, or -the sender must be the super-user. -As a single special case the continue signal SIGCONT may be sent -to any process that is a descendant of the current process. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. Otherwise, -a value of -1 is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn Killpg -will fail and no signal will be sent if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa Sig -is not a valid signal number. -.It Bq Er ESRCH -No process can be found in the process group specified by -.Fa pgrp . -.It Bq Er ESRCH -The process group was given as 0 -but the sending process does not have a process group. -.It Bq Er EPERM -The sending process is not the super-user and one or more -of the target processes has an effective user ID different from that -of the sending process. -.El -.Sh SEE ALSO -.Xr kill 2 , -.Xr getpgrp 2 , -.Xr sigaction 2 -.Sh HISTORY -The -.Fn killpg -function call appeared in -.Bx 4.0 . diff --git a/lib/libc/compat-43/setregid.2 b/lib/libc/compat-43/setregid.2 deleted file mode 100644 index 4e3774383827..000000000000 --- a/lib/libc/compat-43/setregid.2 +++ /dev/null @@ -1,93 +0,0 @@ -.\" Copyright (c) 1983, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)setregid.2 6.4 (Berkeley) 3/10/91 -.\" $Id: setregid.2,v 1.1 1994/04/06 23:28:40 cgd Exp $ -.\" -.Dd March 10, 1991 -.Dt SETREGID 2 -.Os BSD 4.2 -.Sh NAME -.Nm setregid -.Nd set real and effective group ID's -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn setregid "int rgid" "int egid" -.Sh DESCRIPTION -The real and effective group ID's of the current process -are set to the arguments. -Unprivileged users may change the real group -ID to the effective group ID and vice-versa; only the super-user may -make other changes. -.Pp -Supplying a value of -1 for either the real or effective -group ID forces the system to substitute the current -ID in place of the -1 parameter. -.Pp -The -.Fn setregid -function was intended to allow swapping the real and -effective group IDs in set-group-ID programs to temporarily relinquish -the set-group-ID value. This function did not work correctly, and its -purpose is now better served by the use of the -.Fn setegid -function (see -.Xr setuid 2 ). -.Pp -When setting the real and effective group IDs to the same value, the -standard -.Fn setgid -function is preferred. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. Otherwise, -a value of -1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -.Bl -tag -width Er -.It Bq Er EPERM -The current process is not the super-user and a change -other than changing the effective group-id to the real group-id -was specified. -.El -.Sh SEE ALSO -.Xr getgid 2 , -.Xr setegid 2 , -.Xr setgid 2 , -.Xr setuid 2 -.Sh HISTORY -The -.Fn setregid -function call appeared in -.Bx 4.2 -and was dropped in -.Bx 4.4 . diff --git a/lib/libc/compat-43/setreuid.2 b/lib/libc/compat-43/setreuid.2 deleted file mode 100644 index 44ea599278a3..000000000000 --- a/lib/libc/compat-43/setreuid.2 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Copyright (c) 1980, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)setreuid.2 6.4 (Berkeley) 3/10/91 -.\" $Id: setreuid.2,v 1.1 1994/04/06 23:28:44 cgd Exp $ -.\" -.Dd March 10, 1991 -.Dt SETREUID 2 -.Os BSD 4 -.Sh NAME -.Nm setreuid -.Nd set real and effective user ID's -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn setreuid "int ruid" "int euid" -.Sh DESCRIPTION -The real and effective user ID's of the -current process are set according to the arguments. -If -.Fa ruid -or -.Fa euid -is -1, the current uid is filled in by the system. -Unprivileged users may change the real user -ID to the effective user ID and vice-versa; only the super-user may -make other changes. -.Pp -The -.Fn setreuid -function has been used to swap the real and effective user -IDs in set-user-ID programs to temporarily relinquish the set-user-ID -value. This purpose is now better served by the use of the -.Fn seteuid -function (see -.Xr setuid 2 ). -.Pp -When setting the real and effective user IDs to the same value, the standard -.Fn setuid -function is preferred. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. Otherwise, -a value of -1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -.Bl -tag -width Er -.It Bq Er EPERM -The current process is not the super-user and a change -other than changing the effective user-id to the real user-id -was specified. -.El -.Sh SEE ALSO -.Xr getuid 2 , -.Xr seteuid 2 , -.Xr setuid 2 -.Sh HISTORY -The -.Fn setreuid -function call appeared in -.Bx 4.2 -and was dropped in -.Bx 4.4 . diff --git a/lib/libc/compat-43/sigblock.2 b/lib/libc/compat-43/sigblock.2 deleted file mode 100644 index 22545861b608..000000000000 --- a/lib/libc/compat-43/sigblock.2 +++ /dev/null @@ -1,85 +0,0 @@ -.\" Copyright (c) 1983, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)sigblock.2 6.7 (Berkeley) 3/10/91 -.\" $Id: sigblock.2,v 1.3 1993/12/01 18:49:54 jtc Exp $ -.\" -.Dd March 10, 1991 -.Dt SIGBLOCK 2 -.Os BSD 4.2 -.Sh NAME -.Nm sigblock -.Nd block signals -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sigblock "int mask" -.Ft int -.Fn sigmask signum -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by: -.Ef -.Xr sigprocmask 2 . -.Pp -.Fn Sigblock -adds the signals specified in -.Fa mask -to the set of signals currently -being blocked from delivery. -Signals are blocked if the -corresponding bit in -.Fa mask -is a 1; the macro -.Fn sigmask -is provided to construct the mask for a given -.Fa signum . -.Pp -It is not possible to block -.Dv SIGKILL -or -.Dv SIGSTOP ; -this restriction is silently -imposed by the system. -.Sh RETURN VALUES -The previous set of masked signals is returned. -.Sh SEE ALSO -.Xr kill 2 , -.Xr sigprocmask 2 , -.Xr sigaction 2 , -.Xr sigsetmask 2 , -.Xr sigsetops 3 -.Sh HISTORY -The -.Fn sigblock -function call appeared in -.Bx 4.2 -and has been deprecated. diff --git a/lib/libc/compat-43/sigpause.2 b/lib/libc/compat-43/sigpause.2 deleted file mode 100644 index 555360dfdcc8..000000000000 --- a/lib/libc/compat-43/sigpause.2 +++ /dev/null @@ -1,75 +0,0 @@ -.\" Copyright (c) 1983, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)sigpause.2 6.6 (Berkeley) 3/10/91 -.\" $Id: sigpause.2,v 1.3 1993/12/01 18:49:56 jtc Exp $ -.\" -.Dd March 10, 1991 -.Dt SIGPAUSE 2 -.Os BSD 4 -.Sh NAME -.Nm sigpause -.Nd atomically release blocked signals and wait for interrupt -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sigpause "int sigmask" -.Sh DESCRIPTION -.Sy This interface is made obsolete by -.Xr sigsuspend 2 . -.Pp -.Fn Sigpause -assigns -.Fa sigmask -to the set of masked signals -and then waits for a signal to arrive; -on return the set of masked signals is restored. -.Fa Sigmask -is usually 0 to indicate that no -signals are to be blocked. -.Fn Sigpause -always terminates by being interrupted, returning -1 with -.Va errno -set to -.Dv EINTR -.Sh SEE ALSO -.Xr sigsuspend 2 , -.Xr kill 2 , -.Xr sigaction 2 , -.Xr sigprocmask 2 , -.Xr sigblock 2 , -.Xr sigvec 2 -.Sh HISTORY -The -.Fn sigpause -function call appeared in -.Bx 4.2 -and has been deprecated. diff --git a/lib/libc/compat-43/sigsetmask.2 b/lib/libc/compat-43/sigsetmask.2 deleted file mode 100644 index f206a726bc18..000000000000 --- a/lib/libc/compat-43/sigsetmask.2 +++ /dev/null @@ -1,83 +0,0 @@ -.\" Copyright (c) 1983, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)sigsetmask.2 6.7 (Berkeley) 3/10/91 -.\" $Id: sigsetmask.2,v 1.3 1993/12/01 18:49:57 jtc Exp $ -.\" -.Dd March 10, 1991 -.Dt SIGSETMASK 2 -.Os BSD 4.2 -.Sh NAME -.Nm sigsetmask -.Nd set current signal mask -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn sigsetmask "int mask" -.Fn sigmask signum -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsoleted by: -.Ef -.Xr sigprocmask 2 . -.Pp -.Fn Sigsetmask -sets the current signal mask -Signals are blocked from delivery if the -corresponding bit in -.Fa mask -is a 1; the macro -.Fn sigmask -is provided to construct the mask for a given -.Fa signum . -.Pp -The system -quietly disallows -.Dv SIGKILL -or -.Dv SIGSTOP -to be blocked. -.Sh RETURN VALUES -The previous set of masked signals is returned. -.Sh SEE ALSO -.Xr sigprocmask 2 , -.Xr kill 2 , -.Xr sigaction 2 , -.Xr sigsuspend 2 , -.Xr sigvec 2 , -.Xr sigblock 2 , -.Xr sigsetops 3 -.Sh HISTORY -The -.Fn sigsetmask -function call appeared in -.Bx 4.2 -and has been deprecated. diff --git a/lib/libc/compat-43/sigvec.2 b/lib/libc/compat-43/sigvec.2 deleted file mode 100644 index 60fab67f49fd..000000000000 --- a/lib/libc/compat-43/sigvec.2 +++ /dev/null @@ -1,326 +0,0 @@ -.\" Copyright (c) 1980, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)sigvec.2 6.7 (Berkeley) 4/29/91 -.\" $Id: sigvec.2,v 1.4 1994/01/11 00:13:27 jtc Exp $ -.\" -.Dd April 29, 1991 -.Dt SIGVEC 2 -.Os BSD 4 -.Sh NAME -.Nm sigvec -.Nd software signal facilities -.Sh SYNOPSIS -.Fd #include -.Bd -literal -struct sigvec { - void (*sv_handler)(); - sigset_t sv_mask; - int sv_flags; -}; -.Ed -.Fn sigvec "int sig" "struct sigvec *vec" "struct sigvec *ovec" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by sigaction(2). -.Ef -.Pp -The system defines a set of signals that may be delivered to a process. -Signal delivery resembles the occurrence of a hardware interrupt: -the signal is blocked from further occurrence, the current process -context is saved, and a new one is built. A process may specify a -.Em handler -to which a signal is delivered, or specify that a signal is to be -.Em blocked -or -.Em ignored . -A process may also specify that a default action is to be taken -by the system when a signal occurs. -Normally, signal handlers execute on the current stack -of the process. This may be changed, on a per-handler basis, -so that signals are taken on a special -.Em "signal stack" . -.Pp -All signals have the same -.Em priority . -Signal routines execute with the signal that caused their -invocation -.Em blocked , -but other signals may yet occur. -A global -.Em "signal mask" -defines the set of signals currently blocked from delivery -to a process. The signal mask for a process is initialized -from that of its parent (normally 0). It -may be changed with a -.Xr sigblock 2 -or -.Xr sigsetmask 2 -call, or when a signal is delivered to the process. -.Pp -When a signal -condition arises for a process, the signal is added to a set of -signals pending for the process. If the signal is not currently -.Em blocked -by the process then it is delivered to the process. When a signal -is delivered, the current state of the process is saved, -a new signal mask is calculated (as described below), -and the signal handler is invoked. The call to the handler -is arranged so that if the signal handling routine returns -normally the process will resume execution in the context -from before the signal's delivery. -If the process wishes to resume in a different context, then it -must arrange to restore the previous context itself. -.Pp -When a signal is delivered to a process a new signal mask is -installed for the duration of the process' signal handler -(or until a -.Xr sigblock -or -.Xr sigsetmask -call is made). -This mask is formed by taking the current signal mask, -adding the signal to be delivered, and -.Em or Ns 'ing -in the signal mask associated with the handler to be invoked. -.Pp -.Fn Sigvec -assigns a handler for a specific signal. If -.Fa vec -is non-zero, it -specifies a handler routine and mask -to be used when delivering the specified signal. -Further, if the -.Dv SV_ONSTACK -bit is set in -.Fa sv_flags , -the system will deliver the signal to the process on a -.Em "signal stack" , -specified with -.Xr sigstack 2 . -If -.Fa ovec -is non-zero, the previous handling information for the signal -is returned to the user. -.Pp -The following is a list of all signals -with names as in the include file -.Aq Pa signal.h : -.Bl -column SIGVTALARMXX "create core imagexxx" -.It Sy " NAME " " Default Action " " Description" -.It Dv SIGHUP No " terminate process" " terminal line hangup" -.It Dv SIGINT No " terminate process" " interrupt program" -.It Dv SIGQUIT No " create core image" " quit program" -.It Dv SIGILL No " create core image" " illegal instruction" -.It Dv SIGTRAP No " create core image" " trace trap" -.It Dv SIGABRT No " create core image" Xr abort 2 -call (formerly -.Dv SIGIOT ) -.It Dv SIGEMT No " create core image" " emulate instruction executed" -.It Dv SIGFPE No " create core image" " floating-point exception" -.It Dv SIGKILL No " terminate process" " kill program" -.It Dv SIGBUS No " create core image" " bus error" -.It Dv SIGSEGV No " create core image" " segmentation violation" -.It Dv SIGSYS No " create core image" " system call given invalid argument" -.It Dv SIGPIPE No " terminate process" " write on a pipe with no reader" -.It Dv SIGALRM No " terminate process" " real-time timer expired" -.It Dv SIGTERM No " terminate process" " software termination signal" -.It Dv SIGURG No " discard signal" " urgent condition present on socket" -.It Dv SIGSTOP No " stop process" " stop (cannot be caught or ignored)" -.It Dv SIGTSTP No " stop process" " stop signal generated from keyboard" -.It Dv SIGCONT No " discard signal" " continue after stop" -.It Dv SIGCHLD No " discard signal" " child status has changed" -.It Dv SIGTTIN No " stop process" " background read attempted from control terminal" -.It Dv SIGTTOU No " stop process" " background write attempted to control terminal" -.It Dv SIGIO No " discard signal" Tn " I/O" -is possible on a descriptor (see -.Xr fcntl 2 ) -.It Dv SIGXCPU No " terminate process" " cpu time limit exceeded (see" -.Xr setrlimit 2 ) -.It Dv SIGXFSZ No " terminate process" " file size limit exceeded (see" -.Xr setrlimit 2 ) -.It Dv SIGVTALRM No " terminate process" " virtual time alarm (see" -.Xr setitimer 2 ) -.It Dv SIGPROF No " terminate process" " profiling timer alarm (see" -.Xr setitimer 2 ) -.It Dv SIGWINCH No " discard signal" " Window size change" -.It Dv SIGINFO No " discard signal" " status request from keyboard" -.It Dv SIGUSR1 No " terminate process" " User defined signal 1" -.It Dv SIGUSR2 No " terminate process" " User defined signal 2" -.El -.Pp -Once a signal handler is installed, it remains installed -until another -.Fn sigvec -call is made, or an -.Xr execve 2 -is performed. -A signal-specific default action may be reset by -setting -.Fa sv_handler -to -.Dv SIG_DFL . -The defaults are process termination, possibly with core dump; -no action; stopping the process; or continuing the process. -See the above signal list for each signal's default action. -If -.Fa sv_handler -is -.Dv SIG_IGN -current and pending instances -of the signal are ignored and discarded. -.Pp -If a signal is caught during the system calls listed below, -the call is normally restarted. -The call can be forced to terminate prematurely with an -.Dv EINTR -error return by setting the -.Dv SV_INTERRUPT -bit in -.Fa sv_flags . -The affected system calls include -.Xr read 2 , -.Xr write 2 , -.Xr sendto 2 , -.Xr recvfrom 2 , -.Xr sendmsg 2 -and -.Xr recvmsg 2 -on a communications channel or a slow device (such as a terminal, -but not a regular file) -and during a -.Xr wait 2 -or -.Xr ioctl 2 . -However, calls that have already committed are not restarted, -but instead return a partial success (for example, a short read count). -.Pp -After a -.Xr fork 2 -or -.Xr vfork 2 -all signals, the signal mask, the signal stack, -and the restart/interrupt flags are inherited by the child. -.Pp -.Xr Execve 2 -reinstates the default -action for all signals which were caught and -resets all signals to be caught on the user stack. -Ignored signals remain ignored; -the signal mask remains the same; -signals that interrupt system calls continue to do so. -.Sh NOTES -The mask specified in -.Fa vec -is not allowed to block -.Dv SIGKILL -or -.Dv SIGSTOP . -This is done silently by the system. -.Pp -The -.Dv SV_INTERRUPT -flag is not available in -.Bx 4.2 , -hence it should not be used if backward compatibility is needed. -.Sh RETURN VALUES -A 0 value indicated that the call succeeded. A \-1 return value -indicates an error occurred and -.Va errno -is set to indicated the reason. -.Sh ERRORS -.Fn Sigvec -will fail and no new signal handler will be installed if one -of the following occurs: -.Bl -tag -width Er -.It Bq Er EFAULT -Either -.Fa vec -or -.Fa ovec -points to memory that is not a valid part of the process -address space. -.It Bq Er EINVAL -.Fa Sig -is not a valid signal number. -.It Bq Er EINVAL -An attempt is made to ignore or supply a handler for -.Dv SIGKILL -or -.Dv SIGSTOP . -.El -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr kill 1 , -.Xr ptrace 2 , -.Xr kill 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 , -.Xr sigblock 2 , -.Xr sigsetmask 2 , -.Xr sigpause 2 , -.Xr sigstack 2 , -.Xr sigvec 2 , -.Xr sigsetops 3 , -.Xr setjmp 3 , -.Xr siginterrupt 3 , -.Xr tty 4 -.Sh EXAMPLE -On the -.Tn VAX\-11 -The handler routine can be declared: -.Bd -literal -offset indent -void handler(sig, code, scp) -int sig, code; -struct sigcontext *scp; -.Ed -.Pp -Here -.Fa sig -is the signal number, into which the hardware faults and traps are -mapped as defined below. -.Fa Code -is a parameter that is either a constant -as given below or, for compatibility mode faults, the code provided by -the hardware (Compatibility mode faults are distinguished from the -other -.Dv SIGILL -traps by having -.Dv PSL_CM -set in the psl). -.Fa Scp -is a pointer to the -.Fa sigcontext -structure (defined in -.Aq Pa signal.h ) , -used to restore the context from before the signal. -.Sh BUGS -This manual page is still confusing. diff --git a/lib/libc/db/btree/lrucache.c b/lib/libc/db/btree/lrucache.c deleted file mode 100644 index 567ba08a1880..000000000000 --- a/lib/libc/db/btree/lrucache.c +++ /dev/null @@ -1,377 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -char sccsid[] = "@(#)lrucache.c 5.3 (Berkeley) 2/22/91"; -#endif /* LIBC_SCCS and not lint */ - -/* - * lrucache.c -- LRU cache for disk-based btree pages. - * - * This file implements an LRU cache in user space for disk-based - * btrees. - */ -#include -#include -#include -#include -#include "lrucache.h" - -/* - * LRUINIT -- Initialize a new LRU cache. - * - * There's a separate LRU cache for every open file descriptor on which - * the user wants caching. The desired cache size and logical page - * size are passed in. We try to avoid growing the cache beyond the - * limit specified by the user, but if we cannot satisfy a block request - * without growing the cache, we do so. - * - * Note that the page size passed in is the logical page size for - * use with this file descriptor, and doesn't necessarily have anything - * to do with the underlying hardware page size. - * - * Parameters: - * fd -- file descriptor for this cache - * cachesz -- number of buffers in cache (suggested) - * pagesz -- logical page size inside this file - * inproc -- routine to call when a buffer is read - * outproc -- routine to call when a buffer is written - * - * Returns: - * Opaque pointer to the LRU cache on success, NULL on failure. - * - * Side Effects: - * Allocates memory for the hash table and LRU cache. Buffers - * are allocated on demand, later. - */ -LRU -lruinit(fd, cachesz, pagesz, opaque, inproc, outproc) - int fd; - int cachesz; - int pagesz; - char *opaque; - int (*inproc)(); - int (*outproc)(); -{ - register LRUCACHE *l; - int nbytes; - - /* allocate the LRU cache struct */ - if ((l = (LRUCACHE *) malloc((unsigned) sizeof(LRUCACHE))) - == (LRUCACHE *) NULL) - return ((LRU) NULL); - - /* allocate the hash table */ - nbytes = cachesz * sizeof(CACHE_ENT *); - if ((l->lru_cache = (CACHE_ENT **) malloc((unsigned) nbytes)) - == (CACHE_ENT **) NULL) { - (void) free((char *) l); - return ((LRU) NULL); - } - - /* init memory */ - bzero((char *) (l->lru_cache), (size_t) nbytes); - l->lru_fd = fd; - l->lru_psize = pagesz; - l->lru_csize = cachesz; - l->lru_cursz = 0; - l->lru_opaque = opaque; - l->lru_head = l->lru_tail = (LRU_ENT *) NULL; - l->lru_inproc = inproc; - l->lru_outproc = outproc; - - return ((LRU) l); -} - -/* - * LRUGET -- Get a buffer from an LRU cache. - * - * If the buffer is not in the cache at present, this routine will - * instantiate it from the file. This REQUIRES that the desired - * block actually be on disk; we don't do non-blocking reads, so - * if it's not actually out there, this routine won't return for - * a very long time. In order to instantiate a new buffer, use - * lrugetnew(). - * - * Parameters: - * lru -- the LRU cache to use. - * pgno -- the logical block number to get. - * nread -- pointer to an int, in which the number of bytes - * read is returned. - * - * Returns: - * (char *) pointer to the buffer for the desired block. The - * number of bytes actually read is returned in *nread. - * - * Warnings: - * The requested buffer is locked down until the user does - * an explicit lrurelease() on it. - */ - -char * -lruget(lru, pgno, nread) - LRU lru; - int pgno; - int *nread; -{ - LRUCACHE *l = (LRUCACHE *) lru; - CACHE_ENT *ce; - LRU_ENT *lruent; - char *buffer; - long pos; - - /* is it already in the cache? */ - if ((ce = lruhashget(l, pgno)) != (CACHE_ENT *) NULL) { - - /* yes, move it to the head and return it */ - lruent = ce->c_lruent; - lruent->l_flags &= ~F_FREE; - lruhead(l, ce->c_lruent); - *nread = l->lru_psize; - return (ce->c_lruent->l_buffer); - } - - /* not there, get a free page */ - if ((buffer = lrugetpg(l, pgno, nread, lruget)) == (char *) NULL) - return ((char *) NULL); - - /* okay, got a buffer -- fill it */ - pos = (long) (l->lru_psize * pgno); - if (lseek(l->lru_fd, pos, L_SET) != pos) - return ((char *) NULL); - - *nread = read(l->lru_fd, buffer, l->lru_psize); - - if (l->lru_inproc) - (*(l->lru_inproc))(buffer, l->lru_opaque); - - return (buffer); -} - -/* - * LRUGETNEW -- Get a page for a new block in an LRU cache. - * - * This routine allows users to instantiate pages for a file if they - * don't exist on disk yet. It's used to make a file bigger. - * - * Parameters: - * lru -- the LRU cache to use - * pgno -- the (new) logical page number to instantiate - * nread -- ptr to int to get number of bytes read (this is - * guaranteed to be zero, since the page isn't on disk) - * - * Returns: - * Pointer to a buffer for the associated page, or NULL on - * failure. - * - * Warnings: - * The associated buffer is locked down until the user - * explicitly does an lrurelease() on it. - */ - -char * -lrugetnew(lru, pgno, nread) - LRU lru; - int pgno; - int *nread; -{ - LRUCACHE *l = (LRUCACHE *) lru; - - *nread = 0; - return (lrugetpg(l, pgno, nread, lrugetnew)); -} - -/* - * LRUFLUSH -- flush an LRU page to disk. - * - * This routine forces a page to disk. Users should use lruwrite(), - * which simply marks a page dirty and does late writing. - * - * Parameters: - * l -- LRU cache - * lruent -- the LRU cache entry whose page we should flush - * - * Returns: - * Zero on success, -1 on failure. - */ - -lruflush(l, lruent) - LRUCACHE *l; - LRU_ENT *lruent; -{ - long pos; - - if (l->lru_outproc) - (*(l->lru_outproc))(lruent->l_buffer, l->lru_opaque); - - pos = (long) (l->lru_psize * lruent->l_pgno); - if (lseek(l->lru_fd, pos, L_SET) != pos) - return (-1); - if (write(l->lru_fd, lruent->l_buffer, l->lru_psize) != l->lru_psize) - return (-1); - - if (l->lru_inproc) - (*(l->lru_inproc))(lruent->l_buffer, l->lru_opaque); - - lruent->l_flags &= ~F_DIRTY; - return (0); -} - -/* - * LRUWRITE -- Mark an LRU cache buffer dirty - * - * This routine is how users should move their changes to disk. The - * cache code marks the associated buffer dirty, and flushes it to - * disk if we need to reuse the buffer for some other page. - * - * Parameters: - * lru -- LRU cache - * pgno -- page number to flush - * - * Returns: - * Zero on success, -1 on failure. - */ - -int -lruwrite(lru, pgno) - LRU lru; - int pgno; -{ - LRUCACHE *l = (LRUCACHE *) lru; - CACHE_ENT *ce; - - if ((ce = lruhashget(l, pgno)) == (CACHE_ENT *) NULL) - return (-1); - - /* mark the entry dirty */ - ce->c_lruent->l_flags |= F_DIRTY; - - return (0); -} - -/* - * LRUSYNC -- Flush all changes to disk - * - * This routine allows users to force all changes to buffers currently - * in memory to disk. This is expensive. - * - * Parameters: - * lru -- LRU cache to flush - * - * Returns: - * Zero on success, -1 on failure - * - * Side Effects: - * After this call, all buffers are clean. - */ - -int -lrusync(lru) - LRU lru; -{ - LRUCACHE *l = (LRUCACHE *) lru; - LRU_ENT *le; - - for (le = l->lru_head; le != (LRU_ENT *) NULL; le = le->l_next) - if (le->l_flags & F_DIRTY) - if (lruflush(l, le) < 0) - return (-1); - return (0); -} - -/* - * LRURELEASE -- Release a buffer in the LRU cache for reuse - * - * When the user does an lruget() or lrugetnew(), the buffer we return - * is locked down, to guarantee that it's not reused while the user - * still needs it. Once a buffer is no longer needed, it should be - * released (via this routine) so that we can use it for other pages - * if necessary. - * - * Parameters: - * lru -- LRU cache - * pgno -- page number of buffer to release - * - * Returns: - * Zero on success, -1 on failure - */ - -int -lrurelease(lru, pgno) - LRU lru; - int pgno; -{ - LRUCACHE *l = (LRUCACHE *) lru; - CACHE_ENT *ce; - - if ((ce = lruhashget(l, pgno)) == (CACHE_ENT *) NULL) - return (-1); - ce->c_lruent->l_flags |= F_FREE; - return (0); -} - -/* - * LRUFREE -- Free an entire LRU cache - * - * This routine releases an LRU cache. The cache should not be - * used again. - * - * Parameters: - * lru -- LRU cache to free - * - * Returns: - * None. - * - * Side Effects: - * Frees a lot of memory. - */ - -void -lrufree(lru) - LRU lru; -{ - LRUCACHE *l = (LRUCACHE *) lru; - LRU_ENT *le; - LRU_ENT *sle; - - for (le = l->lru_head; le != (LRU_ENT *) NULL; ) { - free((char *) (le->l_buffer)); - sle = le; - le = le->l_next; - free((char *) sle); - } - free ((char *) l); -} diff --git a/lib/libc/db/btree/lrucache.h b/lib/libc/db/btree/lrucache.h deleted file mode 100644 index 9a446136369b..000000000000 --- a/lib/libc/db/btree/lrucache.h +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * @(#)lrucache.h 5.1 (Berkeley) 1/23/91 - */ - -/* - * LRU list entries. The head of the list is the most-recently requested - * block; the tail is the least-recently requested one. - */ - -typedef struct LRU_ENT { - char *l_buffer; /* buffer we return to user */ - int l_pgno; /* logical page number */ - int l_flags; /* FREE and DIRTY bits */ - struct LRU_ENT *l_prev; /* predecessor in LRU list */ - struct LRU_ENT *l_next; /* successor in LRU list */ -} LRU_ENT; - -/* - * Cache entries. We use a hash table to avoid a linear walk of the LRU - * list when we need to look up blocks by number. The hash table is - * chained. - */ - -typedef struct CACHE_ENT { - int c_pgno; - LRU_ENT *c_lruent; - struct CACHE_ENT *c_chain; -} CACHE_ENT; - -/* - * The LRU cache structure. The cache size (lru_csize) is the largest size - * the user wants us to grow to; current size (lru_cursz) is always less than - * or equal to lru_csize. Note that we will grow the cache (lru_csize) if - * it's the only way that we can satisfy a user's block request. - */ - -typedef struct LRUCACHE { - int lru_fd; - int lru_csize; - int lru_psize; - int lru_cursz; - char *lru_opaque; /* passed to inproc, outproc */ - int (*lru_inproc)(); - int (*lru_outproc)(); - LRU_ENT *lru_head; - LRU_ENT *lru_tail; - CACHE_ENT **lru_cache; -} LRUCACHE; - -#ifndef NULL -#define NULL 0 -#endif /* ndef NULL */ - -/* this is the opaque type we return for LRU caches */ -typedef char *LRU; - -/* bits for l_flags in LRU_ENT structure */ -#define F_DIRTY (1 << 0) -#define F_FREE (1 << 1) - -/* lru module routines */ -extern CACHE_ENT *lruhashget(); -extern CACHE_ENT *lruhashput(); -extern int lruhashdel(); -extern void lruhead(); -extern int lrugrow(); -extern LRU lruinit(); -extern int lruwrite(); -extern int lrusync(); -extern char *lruget(); -extern char *lrugetnew(); -extern char *lrugetpg(); -extern int lrurelease(); -extern void lrufree(); diff --git a/lib/libc/db/btree/lruhash.c b/lib/libc/db/btree/lruhash.c deleted file mode 100644 index 91a9fdbb2d12..000000000000 --- a/lib/libc/db/btree/lruhash.c +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)lruhash.c 5.2 (Berkeley) 2/22/91"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include "lrucache.h" - -#define HASH(l, pgno) (pgno % l->lru_csize) - -/* - * LRUHASHGET -- Look up a block in the LRU cache by page number. - * - * Parameters: - * l -- LRU cache - * pgno -- number of the logical page to get - * - * Returns: - * (CACHE_ENT *) pointer to the associated hash table entry - * (if any), or NULL (if none). - */ - -CACHE_ENT * -lruhashget(l, pgno) - LRUCACHE *l; - int pgno; -{ - int hashind; - CACHE_ENT *ce; - - hashind = HASH(l, pgno); - - /* walk the chain */ - for (ce = l->lru_cache[hashind]; - ce != (CACHE_ENT *) NULL; - ce = ce->c_chain) { - if (ce->c_pgno == pgno) - return (ce); - } - - return ((CACHE_ENT *) NULL); -} - -/* - * LRUHASHPUT -- Add an entry for a given page to the cache hash table. - * - * This routine assumes that the given page does not yet have an entry - * in the table. - * - * Parameters: - * l -- LRU cache - * pgno -- logical page number for this entry - * lruent -- LRU list entry at which hash table entry should - * point - * - * Returns: - * (CACHE_ENT *) pointer to the new hash table entry on success, - * or NULL on failure. - * - * Side Effects: - * Allocates memory which should be freed when the hash table - * entry is removed. - */ - -CACHE_ENT * -lruhashput(l, pgno, lruent) - LRUCACHE *l; - int pgno; - LRU_ENT *lruent; -{ - int hashind; - CACHE_ENT *ce; - - if ((ce = (CACHE_ENT *) malloc((unsigned) sizeof(CACHE_ENT))) - == (CACHE_ENT *) NULL) - return ((CACHE_ENT *) NULL); - - hashind = HASH(l, pgno); - - ce->c_pgno = pgno; - ce->c_lruent = lruent; - ce->c_chain = l->lru_cache[hashind]; - l->lru_cache[hashind] = ce; - - return (ce); -} - -/* - * LRUHASHDEL -- Delete the entry for a given page from the LRU cache - * hash table. - * - * Parameters: - * l -- LRU cache - * pgno -- page number for which we should delete htable entry - * - * Returns: - * Zero on success, -1 on failure. - * - * Side Effects: - * Releases the memory occupied by the hash table entry. - */ - -int -lruhashdel(l, pgno) - LRUCACHE *l; - int pgno; -{ - CACHE_ENT *ce; - CACHE_ENT *sce; - int hashind; - - sce = (CACHE_ENT *) NULL; - hashind = HASH(l, pgno); - - /* find the entry we want to delete */ - for (ce = l->lru_cache[hashind]; - ce != (CACHE_ENT *) NULL; - ce = ce->c_chain) { - if (ce->c_pgno == pgno) - break; - sce = ce; - } - - if (ce == (CACHE_ENT *) NULL) - return (-1); - - /* remove it from the chain */ - if (sce == (CACHE_ENT *) NULL) - l->lru_cache[hashind] = ce->c_chain; - else - sce->c_chain = ce->c_chain; - - /* release it */ - free ((char *) ce); - - /* success */ - return (0); -} diff --git a/lib/libc/db/btree/lrutils.c b/lib/libc/db/btree/lrutils.c deleted file mode 100644 index a8a016bc7598..000000000000 --- a/lib/libc/db/btree/lrutils.c +++ /dev/null @@ -1,244 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)lrutils.c 5.2 (Berkeley) 2/22/91"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include "lrucache.h" - -/* - * LRUGETPG -- Get a free page from the LRU cache. - * - * This routine grows the cache if necessary, finds an unused page if - * it can, and handles flushing dirty buffers to disk. - * - * One of the parameters to this routine (f) is the routine that called - * us. If we have to grow the cache, we call this routine recursively - * in order to fill the buffer. The reason for this is that we have - * two interfaces that call lrugetpg(). Lruget() fills a page from disk, - * and lrugetnew() just allocates a new (empty) page. - * - * Parameters: - * l -- LRU cache to use. - * pgno -- page number for which we want a buffer - * nread -- pointer to an int to get number of bytes read - * f -- who called us - * - * Returns: - * (char *) pointer to buffer to use, or NULL on failure. - * - * Warnings: - * The buffer returned is locked down until the user does an - * explicit lrurelease() on it. - */ - -char * -lrugetpg(l, pgno, nread, f) - LRUCACHE *l; - int pgno; - int *nread; - char *(*f)(); -{ - CACHE_ENT *ce; - LRU_ENT *lruent; - char *buffer; - - /* if we're allowed to grow the cache, do so */ - if (l->lru_cursz < l->lru_csize) { - - /* get a buffer */ - if ((buffer = (char *) malloc((unsigned) l->lru_psize)) - == (char *) NULL) - return ((char *) NULL); - - /* get and LRU list entry */ - if ((lruent = (LRU_ENT *) malloc((unsigned) sizeof(LRU_ENT))) - == (LRU_ENT *) NULL) - return ((char *) NULL); - lruent->l_buffer = buffer; - lruent->l_pgno = pgno; - lruent->l_flags = NULL; - - /* manage spaghetti */ - lruent->l_prev = (LRU_ENT *) NULL; - lruent->l_next = l->lru_head; - if (l->lru_head != (LRU_ENT *) NULL) - l->lru_head->l_prev = lruent; - l->lru_head = lruent; - if (l->lru_tail == (LRU_ENT *) NULL) - l->lru_tail = lruent; - - /* add it to the hash table */ - ce = lruhashput(l, pgno, lruent); - l->lru_cursz++; - } else { - lruent = l->lru_tail; - - /* find the oldest unused buffer */ - while (lruent != (LRU_ENT *) NULL - && !(lruent->l_flags & F_FREE)) - lruent = lruent->l_prev; - - /* if no free buffer was found, we have to grow the cache */ - if (lruent == (LRU_ENT *) NULL) { - if (lrugrow(l) < 0) - return ((char *) NULL); - return ((*f)((LRU) l, pgno, nread)); - } - - /* okay, found a free buffer -- update hash table and list */ - ce = lruhashget(l, lruent->l_pgno); - if (lruhashdel(l, lruent->l_pgno) < 0) - return ((char *) NULL); - - /* flush the old page to disk, if necessary */ - if (lruent->l_flags & F_DIRTY) - if (lruflush(l, lruent) < 0) - return ((char *) NULL); - - /* update stats, hash table, and list */ - lruent->l_pgno = pgno; - lruhead(l, lruent); - ce = lruhashput(l, pgno, lruent); - buffer = lruent->l_buffer; - } -#ifdef lint - ce = ce; -#endif /* lint */ - - /* lock this page down */ - lruent->l_flags &= ~F_FREE; - - return (buffer); -} - -/* - * LRUHEAD -- Move an LRU list entry to the head of the list. - * - * The head of the list is where the most recently used item goes. - * - * Parameters: - * l -- LRU cache - * lruent -- entry to move to the head of the list - * - * Returns: - * None - * - * Side Effects: - * Updates the cache's head and tail pointers as required. - */ - -void -lruhead(l, lruent) - LRUCACHE *l; - LRU_ENT *lruent; -{ - LRU_ENT *next; - LRU_ENT *prev; - - if (l->lru_head == lruent) - return; - - next = lruent->l_next; - prev = lruent->l_prev; - lruent->l_prev = (LRU_ENT *) NULL; - lruent->l_next = l->lru_head; - l->lru_head->l_prev = lruent; - l->lru_head = lruent; - - prev->l_next = next; - if (next != (LRU_ENT *) NULL) - next->l_prev = prev; - - if (l->lru_tail == lruent) - l->lru_tail = prev; -} - -/* - * LRUGROW -- Grow the LRU cache - * - * This routine is called only if we can't satisfy a user's get() request - * using an existing buffer. We need to rebuild the hash table so that - * subsequent lookups work correctly, since the cache size is used to - * compute hash keys. - * - * Parameters: - * l -- LRU cache to grow - * - * Returns: - * Zero on success, -1 on failure - */ - -int -lrugrow(l) - LRUCACHE *l; -{ - int oldsz, newsz; - CACHE_ENT **new; - CACHE_ENT *ce, *nce; - int h; - int i; - - oldsz = l->lru_csize; - newsz = l->lru_csize + 1; - - /* get a new hash table */ - if ((new = (CACHE_ENT **) malloc((unsigned)newsz * sizeof(CACHE_ENT *))) - == (CACHE_ENT **) NULL) - return (-1); - - /* build the new hash table */ - bzero((char *) new, (size_t) (newsz * sizeof(CACHE_ENT *))); - for (i = oldsz; --i >= 0; ) { - for (ce = l->lru_cache[i]; ce != (CACHE_ENT *) NULL; ) { - nce = ce->c_chain; - h = ce->c_pgno % newsz; - ce->c_chain = new[h]; - new[h] = ce; - ce = nce; - } - } - - /* get rid of the old hash table, and update the cache */ - free ((char *) (l->lru_cache)); - l->lru_cache = new; - l->lru_csize = newsz; - - return (0); -} diff --git a/lib/libc/db/btree/search.c b/lib/libc/db/btree/search.c deleted file mode 100644 index 300688807146..000000000000 --- a/lib/libc/db/btree/search.c +++ /dev/null @@ -1,296 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)search.c 5.2 (Berkeley) 4/8/91"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include "btree.h" - -/* - * _BT_FIRST -- Find the first item in the tree that matches the supplied - * key. - * - * This routine supports deletion. When the user supplies a key to - * be deleted, we find the first one, and iteratively delete all the - * matching ones that follow it. - * - * Parameters: - * t -- btree in which to find first occurrence - * key -- key to find - * - * Returns: - * The BTITEM for the matching item. If there's no match, - * this may point to the first item > than the supplied key, - * or off the end of the page. - * - * Warnings: - * The BTITEM returned is in static space and will be overwritten - * by the next search of any kind in any btree. - */ - -BTITEM * -_bt_first(t, key) - BTREE_P t; - DBT *key; -{ - BTHEADER *h; - BTITEM *item; - index_t next; - int r; - - /* find any matching item */ - item = _bt_search(t, key); - h = t->bt_curpage; - next = NEXTINDEX(h); - - /* if we're off the end of the page, search failed and we're done */ - if (item->bti_index >= next) - return (item); - - /* as long as we have an exact match, walk backwards */ - while ((r = _bt_cmp(t, key->data, item->bti_index)) == 0) { - - /* at start of page? */ - if (item->bti_index == 0) { - - /* if no prev page, we're done */ - if (h->h_prevpg == P_NONE) - return (item); - - /* walk backward, skipping empty pages */ - do { - if (_bt_getpage(t, h->h_prevpg) == RET_ERROR) - return ((BTITEM *) NULL); - h = t->bt_curpage; - } while (NEXTINDEX(h) == 0 && h->h_prevpg != P_NONE); - - if (NEXTINDEX(h) != 0) - item->bti_index = NEXTINDEX(h) - 1; - else - item->bti_index = 0; - - item->bti_pgno = h->h_pgno; - } else { - item->bti_index--; - } - } - - /* if we went too far backwards, step forward one entry */ - if (r > 0) { - if (++(item->bti_index) >= NEXTINDEX(h) - && h->h_nextpg != P_NONE) { - - /* walk forward, skipping empty pages */ - do { - if (_bt_getpage(t, h->h_nextpg) == RET_ERROR) - return ((BTITEM *) NULL); - h = t->bt_curpage; - } while (h->h_nextpg != P_NONE && NEXTINDEX(h) == 0); - - item->bti_index = 0; - item->bti_pgno = h->h_pgno; - } - } - - /* got it */ - return (item); -} - -/* - * _BT_SEARCH, _BT_SEARCHR -- Search for a particular key in the tree. - * - * Parameters: - * t -- btree in which to search - * key -- key to find - * - * Returns: - * BTITEM for matching item, if any, or the BTITEM for the - * location of the key, if it were in the tree. - * - * Warnings: - * The BTITEM returned is in static memory, and will be - * overwritten by the next search of any kind in any tree. - */ - -BTITEM * -_bt_search(t, key) - BTREE_P t; - DBT *key; -{ - /* we want to start all of our searches at the root */ - if (_bt_getpage(t, (pgno_t) P_ROOT) == RET_ERROR) - return ((BTITEM *) NULL); - - return (_bt_searchr(t, key)); -} - -BTITEM * -_bt_searchr(t, key) - BTREE_P t; - DBT *key; -{ - BTHEADER *h = t->bt_curpage; - index_t index; - IDATUM *id; - DATUM *d; - static BTITEM item; - - /* do a binary search on the current page */ - index = _bt_binsrch(t, key->data); - - /* - * At this point, the binary search terminated because the endpoints - * got too close together, or we have a match. Figure out which - * case applies and decide what to do based on the page type. - */ - if (h->h_flags & F_LEAF) { - item.bti_pgno = h->h_pgno; - item.bti_index = index; - if (index < NEXTINDEX(h)) - d = (DATUM *) GETDATUM(h,index); - else - d = (DATUM *) NULL; - - item.bti_datum = d; - return(&item); - } else { - id = (IDATUM *) GETDATUM(h, index); - if (_bt_push(t, h->h_pgno) == RET_ERROR) - return ((BTITEM *) NULL); - if (_bt_getpage(t, id->i_pgno) == RET_ERROR) - return ((BTITEM *) NULL); - return (_bt_searchr(t, key)); - } -} - -/* - * _BT_BINSRCH -- Do a binary search for a given key on the current page. - * - * Searches on internal pages are handled slightly differently from - * searches on leaf pages. This is because internal page searches - * find the largest item <= key in the tree, and leaf searches find - * the smallest item >= key. This guarantees that leaf page searches - * leave us pointing at the item's correct position, and internal - * searches descend the tree correctly. - * - * Parameters: - * t -- tree to search - * key -- key we're looking for - * - * Returns: - * Index of the line pointer array entry for the (closest) - * match to key on the current page, with "closest" as defined - * above. - */ - -index_t -_bt_binsrch(t, key) - BTREE_P t; - char *key; -{ - index_t lbound, ubound, cur; - BTHEADER *h = t->bt_curpage; - int match = 0; - int r; - - lbound = 0; - ubound = NEXTINDEX(h); - if (ubound > 0) - --ubound; - - /* do a binary search on the current page */ - while ((ubound - lbound) > 1) { - cur = lbound + ((ubound - lbound) / 2); - r = _bt_cmp(t, key, cur); - - if (r > 0) - lbound = cur + 1; - else if (r < 0) - ubound = cur; - else { - match++; - break; - } - } - - /* - * At this point, the binary search terminated because the endpoints - * got too close together, or we have a match. Figure out which - * case applies, decide what to do based on the page type (leaf or - * internal), and do the right thing. - */ - if (match) { - return (cur); - } else if (ubound != lbound) { - if (h->h_flags & F_LEAF) { - r = _bt_cmp(t, key, lbound); - if (r <= 0) { - return (lbound); - } - } else { - r = _bt_cmp(t, key, ubound); - - /* for internal nodes, move as far left as possible */ - if (r < 0) { - r = _bt_cmp(t, key, lbound); - if (r < 0 && lbound > 0) - --lbound; - return (lbound); - } else { - return (ubound); - } - } - } - - if (h->h_flags & F_LEAF) { - if (ubound < NEXTINDEX(h)) { - r = _bt_cmp(t, key, ubound); - if (r > 0) - ubound++; - } - } else { - /* for internal pages, move as far left as possible */ - if (ubound == NEXTINDEX(h)) - ubound--; - - while (_bt_cmp(t, key, ubound) < 0) - ubound--; - } - return (ubound); -} diff --git a/lib/libc/db/btree/seq.c b/lib/libc/db/btree/seq.c deleted file mode 100644 index 2ce111c2c2bf..000000000000 --- a/lib/libc/db/btree/seq.c +++ /dev/null @@ -1,318 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)seq.c 5.4 (Berkeley) 3/3/91"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include "btree.h" - -/* - * _BT_SEQINIT -- Initialize a sequential scan on the btree. - * - * Sets the tree's notion of the current scan location correctly - * given a key and a direction. - * - * Parameters: - * t -- tree in which to initialize scan - * key -- key for initial scan position - * flags -- R_NEXT, R_PREV - * - * Returns: - * RET_SUCCESS, RET_ERROR, or RET_SPECIAL if there's no data - * in the tree to scan. - * - * Side Effects: - * Changes current scan position for the tree. Almost certainly - * changes current page, as well. Sets BTF_SEQINIT bit in tree - * flags, so that we know we've initialized a scan. - */ - -int -_bt_seqinit(t, key, flags) - BTREE_P t; - DBT *key; - int flags; -{ - BTITEM *item; - BTHEADER *h; - CURSOR *c; - IDATUM *id; - index_t last; - - /* - * Figure out if we really have to search for the key that the - * user supplied. If key is null, then this is an unkeyed scan - * and we can just start from an endpoint. - */ - - c = &(t->bt_cursor); - - if (flags == R_CURSOR) { - if (key->data != (u_char *) NULL) { - - /* key supplied, find first instance of it */ - item = _bt_first(t, key); - c->c_index = item->bti_index; - c->c_pgno = t->bt_curpage->h_pgno; - } else { - errno = EINVAL; - return (RET_ERROR); - } - - } else { - - /* - * Unkeyed scan. For backward scans, find the last item - * in the tree; for forward scans, find the first item. - */ - - if (_bt_getpage(t, (pgno_t) P_ROOT) == RET_ERROR) - return (RET_ERROR); - h = t->bt_curpage; - if (flags == R_LAST || flags == R_PREV) { - - /* backward scan */ - while (!(h->h_flags & F_LEAF)) { - last = NEXTINDEX(h) - 1; - id = (IDATUM *) GETDATUM(h,last); - if (_bt_getpage(t, id->i_pgno) == RET_ERROR) - return (RET_ERROR); - h = t->bt_curpage; - } - - /* skip empty pages */ - while (NEXTINDEX(h) == 0 && h->h_prevpg != P_NONE) { - if (_bt_getpage(t, h->h_prevpg) == RET_ERROR) - return (RET_ERROR); - h = t->bt_curpage; - } - - c->c_pgno = h->h_pgno; - if (NEXTINDEX(h) > 0) - c->c_index = NEXTINDEX(h) - 1; - else - c->c_index = 0; - } else if (flags == R_FIRST || flags == R_NEXT) { - /* forward scan */ - while (!(h->h_flags & F_LEAF)) { - id = (IDATUM *) GETDATUM(h,0); - if (_bt_getpage(t, id->i_pgno) == RET_ERROR) - return (RET_ERROR); - h = t->bt_curpage; - } - - /* skip empty pages */ - while (NEXTINDEX(h) == 0 && h->h_nextpg != P_NONE) { - if (_bt_getpage(t, h->h_nextpg) == RET_ERROR) - return (RET_ERROR); - h = t->bt_curpage; - } - - c->c_pgno = h->h_pgno; - c->c_index = 0; - } else { - /* no flags passed in */ - errno = EINVAL; - return (RET_ERROR); - } - } - - /* okay, scan is initialized */ - t->bt_flags |= BTF_SEQINIT; - - /* don't need the descent stack anymore */ - while (_bt_pop(t) != P_NONE) - continue; - - if (c->c_index == NEXTINDEX(t->bt_curpage)) - return (RET_SPECIAL); - - return (RET_SUCCESS); -} - -/* - * _BT_SEQADVANCE -- Advance the sequential scan on this tree. - * - * Moves the current location pointer for the scan on this tree one - * spot in the requested direction. - * - * Parameters: - * t -- btree being scanned - * flags -- for R_NEXT, R_PREV - * - * Returns: - * RET_SUCCESS, RET_ERROR, or RET_SPECIAL if there is no - * more data in the specified direction. - * - * Side Effects: - * May change current page. - */ - -int -_bt_seqadvance(t, flags) - BTREE_P t; - int flags; -{ - BTHEADER *h; - CURSOR *c; - index_t index; - - c = &(t->bt_cursor); - index = c->c_index; - - if (_bt_getpage(t, c->c_pgno) == RET_ERROR) - return (RET_ERROR); - h = t->bt_curpage; - - /* by the time we get here, don't need the cursor key anymore */ - if (c->c_key != (char *) NULL) - (void) free(c->c_key); - - if (flags == R_NEXT) { - - /* - * This is a forward scan. If the cursor is pointing - * at a virtual record (that is, it was pointing at - * a record that got deleted), then we should return - * the record it's pointing at now. Otherwise, we - * should advance the scan. In either case, we need - * to be careful not to run off the end of the current - * page. - */ - - if (c->c_flags & CRSR_BEFORE) { - - if (index >= NEXTINDEX(h)) { - /* out of items on this page, get next page */ - if (h->h_nextpg == P_NONE) { - /* tell caller we're done... */ - c->c_index = NEXTINDEX(h); - return (RET_SPECIAL); - } - - /* skip empty pages */ - do { - if (_bt_getpage(t, h->h_nextpg) - == RET_ERROR) { - c->c_index = NEXTINDEX(h); - return (RET_ERROR); - } - h = t->bt_curpage; - c->c_pgno = h->h_pgno; - } while (NEXTINDEX(h) == 0 - && h->h_nextpg != P_NONE); - - if (NEXTINDEX(h) == 0) { - /* tell caller we're done */ - c->c_index = NEXTINDEX(h); - return (RET_SPECIAL); - } - index = 0; - } - c->c_flags &= ~CRSR_BEFORE; - - } else if (++index >= NEXTINDEX(h)) { - - /* out of items on this page, get next page */ - if (h->h_nextpg == P_NONE) { - /* tell caller we're done... */ - c->c_index = NEXTINDEX(h); - return (RET_SPECIAL); - } - - /* skip empty pages */ - do { - if (_bt_getpage(t, h->h_nextpg) == RET_ERROR) { - c->c_index = NEXTINDEX(h); - return (RET_ERROR); - } - h = t->bt_curpage; - c->c_pgno = h->h_pgno; - } while (NEXTINDEX(h) == 0 && h->h_nextpg != P_NONE); - - if (NEXTINDEX(h) == 0) { - /* tell caller we're done */ - c->c_index = NEXTINDEX(h); - return (RET_SPECIAL); - } - index = 0; - } - } else if (flags == R_PREV) { - - /* for backward scans, life is substantially easier */ - c->c_flags &= ~CRSR_BEFORE; - if (c->c_key != (char *) NULL) { - (void) free(c->c_key); - c->c_key = (char *) NULL; - } - - if (index == 0) { - - /* we may be done */ - c->c_index = 0; - - /* out of items on this page, get next page */ - if (h->h_prevpg == P_NONE) - return (RET_SPECIAL); - - /* skip empty pages */ - do { - if (_bt_getpage(t, h->h_prevpg) == RET_ERROR) - return (RET_ERROR); - h = t->bt_curpage; - c->c_pgno = h->h_pgno; - } while (NEXTINDEX(h) == 0 && h->h_prevpg != P_NONE); - - if (NEXTINDEX(h) == 0) - return (RET_SPECIAL); - - index = NEXTINDEX(h) - 1; - } else - --index; - } else { - /* must specify a direction */ - errno = EINVAL; - return (RET_ERROR); - } - - c->c_index = index; - return (RET_SUCCESS); -} diff --git a/lib/libc/db/btree/split.c b/lib/libc/db/btree/split.c deleted file mode 100644 index 3dd34868e0e5..000000000000 --- a/lib/libc/db/btree/split.c +++ /dev/null @@ -1,691 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)split.c 5.2 (Berkeley) 2/22/91"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include "btree.h" - -/* - * _BT_SPLIT -- Split a page into two pages. - * - * Splits are caused by insertions, and propogate up the tree in - * the usual way. The root page is always page 1 in the file on - * disk, so root splits are handled specially. On entry to this - * routine, t->bt_curpage is the page to be split. - * - * Parameters: - * t -- btree in which to do split. - * - * Returns: - * RET_SUCCESS, RET_ERROR. - * - * Side Effects: - * Changes the notion of the current page. - */ - -int -_bt_split(t) - BTREE_P t; -{ - BTHEADER *h; - BTHEADER *left, *right; - pgno_t nextpgno, parent; - int nbytes, len; - IDATUM *id; - DATUM *d; - char *src; - IDATUM *new; - pgno_t oldchain; - u_char flags; - - h = (BTHEADER *) t->bt_curpage; - - /* split root page specially, since it must remain page 1 */ - if (h->h_pgno == P_ROOT) { - return (_bt_splitroot(t)); - } - - /* - * This is a little complicated. We go to some trouble to - * figure out which of the three possible cases -- in-memory tree, - * disk tree (no cache), and disk tree (cache) -- we have, in order - * to avoid unnecessary copying. If we have a disk cache, then we - * have to do some extra copying, though, since the cache code - * manages buffers externally to this code. - */ - - if (ISDISK(t) && ISCACHE(t)) { - if ((left = (BTHEADER *) malloc((unsigned) t->bt_psize)) - == (BTHEADER *) NULL) - return (RET_ERROR); - left->h_pgno = left->h_prevpg = left->h_nextpg = P_NONE; - left->h_flags = t->bt_curpage->h_flags; - left->h_lower = (index_t) - (((char *) &(left->h_linp[0])) - ((char *) left)); - left->h_upper = t->bt_psize; - - } else { - if ((left = _bt_allocpg(t)) == (BTHEADER *) NULL) - return (RET_ERROR); - } - left->h_pgno = h->h_pgno; - - if ((right = _bt_allocpg(t)) == (BTHEADER *) NULL) - return (RET_ERROR); - right->h_pgno = ++(t->bt_npages); - - /* now do the split */ - if (_bt_dopsplit(t, left, right) == RET_ERROR) - return (RET_ERROR); - - right->h_prevpg = left->h_pgno; - nextpgno = right->h_nextpg = h->h_nextpg; - left->h_nextpg = right->h_pgno; - left->h_prevpg = h->h_prevpg; - - /* okay, now use the left half of the page as the new page */ - if (ISDISK(t) && ISCACHE(t)) { - (void) bcopy((char *) left, (char *) t->bt_curpage, - (int) t->bt_psize); - (void) free ((char *) left); - left = t->bt_curpage; - } else { - (void) free((char *) t->bt_curpage); - t->bt_curpage = left; - } - - /* - * Write the new pages out. We need them to stay where they are - * until we're done updating the parent pages. - */ - - if (_bt_write(t, left, NORELEASE) == RET_ERROR) - return (RET_ERROR); - if (_bt_write(t, right, NORELEASE) == RET_ERROR) - return (RET_ERROR); - - /* update 'prev' pointer of old neighbor of left */ - if (nextpgno != P_NONE) { - if (_bt_getpage(t, nextpgno) == RET_ERROR) - return (RET_ERROR); - h = t->bt_curpage; - h->h_prevpg = right->h_pgno; - h->h_flags |= F_DIRTY; - } - - if ((parent = _bt_pop(t)) != P_NONE) { - if (right->h_flags & F_LEAF) { - d = (DATUM *) GETDATUM(right, 0); - len = d->d_ksize; - if (d->d_flags & D_BIGKEY) { - bcopy(&(d->d_bytes[0]), - (char *) &oldchain, - sizeof(oldchain)); - if (_bt_markchain(t, oldchain) == RET_ERROR) - return (RET_ERROR); - src = (char *) &oldchain; - flags = D_BIGKEY; - } else { - src = (char *) &(d->d_bytes[0]); - flags = 0; - } - } else { - id = (IDATUM *) GETDATUM(right, 0); - len = id->i_size; - flags = id->i_flags; - src = (char *) &(id->i_bytes[0]); - } - nbytes = len + (sizeof(IDATUM) - sizeof(char)); - new = (IDATUM *) malloc((unsigned) nbytes); - if (new == (IDATUM *) NULL) - return (RET_ERROR); - new->i_size = len; - new->i_pgno = right->h_pgno; - new->i_flags = flags; - if (len > 0) - (void) bcopy(src, (char *) &(new->i_bytes[0]), len); - - nbytes = LONGALIGN(nbytes) + sizeof(index_t); - if (_bt_getpage(t, parent) == RET_ERROR) - return (RET_ERROR); - - h = t->bt_curpage; - - /* - * Split the parent if we need to, then reposition the - * tree's current page pointer for the new datum. - */ - if ((h->h_upper - h->h_lower) < nbytes) { - if (_bt_split(t) == RET_ERROR) - return (RET_ERROR); - if (_bt_reposition(t, new, parent, right->h_prevpg) - == RET_ERROR) - return (RET_ERROR); - } - - /* okay, now insert the new idatum */ - if (_bt_inserti(t, new, right->h_prevpg) == RET_ERROR) - return (RET_ERROR); - } - - /* - * Okay, split is done; don't need right page stapled down anymore. - * The page we call 'left' above is the new version of the old - * (split) page, so we can't release it. - */ - - if (_bt_release(t, right) == RET_ERROR) - return (RET_ERROR); - if (ISDISK(t) && !ISCACHE(t)) - (void) free((char *) right); - - return (RET_SUCCESS); -} - -/* - * _BT_REPOSITION -- Reposition the current page pointer of a btree. - * - * After splitting a node in the tree in order to make room for - * an insertion, we need to figure out which page after the split - * should get the item we want to insert. This routine positions - * the tree's current page pointer appropriately. - * - * Parameters: - * t -- tree to position - * new -- the item we want to insert - * parent -- parent of the node that we just split - * prev -- page number of item directly to the left of - * new's position in the tree. - * - * Returns: - * RET_SUCCESS, RET_ERROR. - * - * Side Effects: - * None. - */ - -int -_bt_reposition(t, new, parent, prev) - BTREE_P t; - IDATUM *new; - pgno_t parent; - pgno_t prev; -{ - index_t i, next; - IDATUM *idx; - - if (parent == P_ROOT) { - - /* - * If we just split the root page, then there are guaranteed - * to be exactly two IDATUMs on it. Look at both of them - * to see if they point to the page that we want. - */ - - if (_bt_getpage(t, parent) == RET_ERROR) - return (RET_ERROR); - - next = NEXTINDEX(t->bt_curpage); - for (i = 0; i < next; i++) { - idx = (IDATUM *) GETDATUM(t->bt_curpage, i); - if (_bt_getpage(t, idx->i_pgno) == RET_ERROR) - return (RET_ERROR); - if (_bt_isonpage(t, new, prev) == RET_SUCCESS) - return (RET_SUCCESS); - if (_bt_getpage(t, parent) == RET_ERROR) - return (RET_ERROR); - } - } else { - - /* - * Get the parent page -- which is where the new item would - * have gone -- and figure out whether the new item now goes - * on the parent, or the page immediately to the right of - * the parent. - */ - - if (_bt_getpage(t, parent) == RET_ERROR) - return (RET_ERROR); - if (_bt_isonpage(t, new, prev) == RET_SUCCESS) - return (RET_SUCCESS); - if (_bt_getpage(t, t->bt_curpage->h_nextpg) == RET_ERROR) - return (RET_ERROR); - if (_bt_isonpage(t, new, prev) == RET_SUCCESS) - return (RET_SUCCESS); - } - return (RET_ERROR); -} - -/* - * _BT_ISONPAGE -- Is the IDATUM for a given page number on the current page? - * - * This routine is used by _bt_reposition to decide whether the current - * page is the correct one on which to insert a new item. - * - * Parameters: - * t -- tree to check - * new -- the item that will be inserted (used for binary search) - * prev -- page number of page whose IDATUM is immediately to - * the left of new's position in the tree. - * - * Returns: - * RET_SUCCESS, RET_ERROR (corresponding to TRUE, FALSE). - */ - -int -_bt_isonpage(t, new, prev) - BTREE_P t; - IDATUM *new; - pgno_t prev; -{ - BTHEADER *h = (BTHEADER *) t->bt_curpage; - index_t i, next; - IDATUM *idx; - - i = _bt_binsrch(t, &(new->i_bytes[0])); - while (i != 0 && _bt_cmp(t, &(new->i_bytes[0]), i) == 0) - --i; - next = NEXTINDEX(h); - idx = (IDATUM *) GETDATUM(h, i); - while (i < next && idx->i_pgno != prev) { - i++; - idx = (IDATUM *) GETDATUM(h, i); - } - if (idx->i_pgno == prev) - return (RET_SUCCESS); - else - return (RET_ERROR); -} - -/* - * _BT_SPLITROOT -- Split the root of a btree. - * - * The root page for a btree is always page one. This means that in - * order to split the root, we need to do extra work. - * - * Parameters: - * t -- tree to split - * - * Returns: - * RET_SUCCESS, RET_ERROR. - * - * Side Effects: - * Splits root upward in the usual way, adding two new pages - * to the tree (rather than just one, as in usual splits). - */ - -int -_bt_splitroot(t) - BTREE_P t; -{ - BTHEADER *h = t->bt_curpage; - BTHEADER *left, *right; - IDATUM *id; - BTHEADER *where_h; - char *src, *dest; - int len, nbytes; - u_long was_leaf; - pgno_t oldchain; - u_char flags; - - /* get two new pages for the split */ - if ((left = _bt_allocpg(t)) == (BTHEADER *) NULL) - return (RET_ERROR); - left->h_pgno = ++(t->bt_npages); - if ((right = _bt_allocpg(t)) == (BTHEADER *) NULL) - return (RET_ERROR); - right->h_pgno = ++(t->bt_npages); - - /* do the split */ - if (_bt_dopsplit(t, left, right) == RET_ERROR) - return (RET_ERROR); - - /* connect the new pages correctly */ - right->h_prevpg = left->h_pgno; - left->h_nextpg = right->h_pgno; - - /* - * Write the child pages out now. We need them to remain - * where they are until we finish updating parent pages, - * however. - */ - - if (_bt_write(t, left, NORELEASE) == RET_ERROR) - return (RET_ERROR); - if (_bt_write(t, right, NORELEASE) == RET_ERROR) - return (RET_ERROR); - - /* now change the root page into an internal page */ - was_leaf = (h->h_flags & F_LEAF); - h->h_flags &= ~F_LEAF; - h->h_lower = (index_t) (((char *) (&(h->h_linp[0]))) - ((char *) h)); - h->h_upper = (index_t) t->bt_psize; - (void) bzero((char *) &(h->h_linp[0]), (int) (h->h_upper - h->h_lower)); - - /* put two new keys on root page */ - where_h = left; - while (where_h) { - DATUM *data; - IDATUM *idata; - - if (was_leaf) { - data = (DATUM *) GETDATUM(where_h, 0); - - if (where_h == left) { - len = 0; /* first key in tree is null */ - } else { - if (data->d_flags & D_BIGKEY) { - bcopy(&(data->d_bytes[0]), - (char *) &oldchain, - sizeof(oldchain)); - if (_bt_markchain(t, oldchain) == RET_ERROR) - return (RET_ERROR); - src = (char *) &oldchain; - flags = D_BIGKEY; - } else { - src = (char *) &(data->d_bytes[0]); - flags = 0; - } - len = data->d_ksize; - } - } else { - idata = (IDATUM *) GETDATUM(where_h, 0); - len = idata->i_size; - flags = idata->i_flags; - src = &(idata->i_bytes[0]); - } - dest = ((char *) h) + h->h_upper; - nbytes = len + (sizeof (IDATUM) - sizeof(char)); - dest -= LONGALIGN(nbytes); - id = (IDATUM *) dest; - id->i_size = len; - id->i_pgno = where_h->h_pgno; - id->i_flags = flags; - if (len > 0) - (void) bcopy((char *) src, (char *) &(id->i_bytes[0]), len); - dest -= ((int) h); - h->h_linp[NEXTINDEX(h)] = (index_t) dest; - h->h_upper = (index_t) dest; - h->h_lower += sizeof(index_t); - - /* next page */ - if (where_h == left) - where_h = right; - else - where_h = (BTHEADER *) NULL; - } - - if (_bt_release(t, left) == RET_ERROR) - return (RET_ERROR); - if (_bt_release(t, right) == RET_ERROR) - return (RET_ERROR); - - /* - * That's it, split is done. If we're doing a non-cached disk - * btree, we can free up the pages we allocated, as they're on - * disk, now. - */ - - if (ISDISK(t) && !ISCACHE(t)) { - (void) free ((char *) left); - (void) free ((char *) right); - } - - h->h_flags |= F_DIRTY; - - return (RET_SUCCESS); -} - -/* - * _BT_DOPSPLIT -- Do the work of splitting a page - * - * This routine takes two page pointers and splits the data on the - * current page of the btree between them. - * - * We do a lot of work here to handle duplicate keys on a page; we - * have to place these keys carefully to guarantee that later searches - * will find them correctly. See comments in the code below for details. - * - * Parameters: - * t -- tree to split - * left -- pointer to page to get left half of the data - * right -- pointer to page to get right half of the data - * - * Returns: - * None. - */ - -int -_bt_dopsplit(t, left, right) - BTREE_P t; - BTHEADER *left; - BTHEADER *right; -{ - BTHEADER *h = t->bt_curpage; - size_t psize; - char *where; - BTHEADER *where_h; - index_t where_i; - int nbytes, dsize, fixedsize, freespc; - index_t i; - index_t save_lower, save_upper, save_i; - index_t switch_i; - char *save_key; - DATUM *d; - CURSOR *c; - index_t top; - int free_save; - pgno_t chain; - int ignore; - - /* - * Our strategy is to put half the bytes on each page. We figure - * out how many bytes we have total, and then move items until - * the last item moved put at least 50% of the data on the left - * page. - */ - save_key = (char *) NULL; - psize = (int) t->bt_psize; - where = ((char *) left) + psize; - where_h = left; - where_i = 0; - nbytes = psize - (int) ((char *) &(h->h_linp[0]) - ((char *) h)); - freespc = nbytes; - - top = NEXTINDEX(h); - if (h->h_flags & F_LEAF) - fixedsize = (sizeof(DATUM) - sizeof(char)); - else - fixedsize = (sizeof(IDATUM) - sizeof(char)); - - save_key = (char *) NULL; - - /* move data */ - for (i = 0; i < top; i++) { - - /* - * Internal and leaf pages have different layouts for - * data items, but in both cases the first entry in the - * data item is a size_t. - */ - d = (DATUM *) GETDATUM(h,i); - if (h->h_flags & F_LEAF) { - dsize = d->d_ksize + d->d_dsize + fixedsize; - } else { - dsize = d->d_ksize + fixedsize; - } - - /* - * If a page contains duplicate keys, we have to be - * careful about splits. A sequence of duplicate keys - * may not begin in the middle of one page and end in - * the middle of another; it must begin on a page boundary, - * in order for searches on the internal nodes to work - * correctly. - */ - if (where_h == left) { - if (save_key == (char *) NULL) { - if (h->h_flags & F_LEAF) { - if (d->d_flags & D_BIGKEY) { - free_save = TRUE; - bcopy(&(d->d_bytes[0]), - (char *) &chain, - sizeof(chain)); - if (_bt_getbig(t, chain, - &save_key, - &ignore) - == RET_ERROR) - return (RET_ERROR); - } else { - free_save = FALSE; - save_key = (char *) &(d->d_bytes[0]); - } - } else { - IDATUM *id = (IDATUM *) d; - - if (id->i_flags & D_BIGKEY) { - free_save = TRUE; - bcopy(&(id->i_bytes[0]), - (char *) &chain, - sizeof(chain)); - if (_bt_getbig(t, chain, - &save_key, - &ignore) - == RET_ERROR) - return (RET_ERROR); - } else { - free_save = FALSE; - save_key = (char *) - &(id->i_bytes[0]); - } - } - save_i = 0; - save_lower = where_h->h_lower; - save_upper = where_h->h_upper; - } else { - if (_bt_cmp(t, save_key, i) != 0) { - save_lower = where_h->h_lower; - save_upper = where_h->h_upper; - save_i = i; - } - if (h->h_flags & F_LEAF) { - if (free_save) - (void) free(save_key); - if (d->d_flags & D_BIGKEY) { - free_save = TRUE; - bcopy(&(d->d_bytes[0]), - (char *) &chain, - sizeof(chain)); - if (_bt_getbig(t, chain, - &save_key, - &ignore) - == RET_ERROR) - return (RET_ERROR); - } else { - free_save = FALSE; - save_key = (char *) &(d->d_bytes[0]); - } - } else { - IDATUM *id = (IDATUM *) d; - - if (id->i_flags & D_BIGKEY) { - free_save = TRUE; - bcopy(&(id->i_bytes[0]), - (char *) &chain, - sizeof(chain)); - if (_bt_getbig(t, chain, - &save_key, - &ignore) - == RET_ERROR) - return (RET_ERROR); - } else { - free_save = FALSE; - save_key = (char *) - &(id->i_bytes[0]); - } - } - } - } - - /* copy data and update page state */ - where -= LONGALIGN(dsize); - (void) bcopy((char *) d, (char *) where, dsize); - where_h->h_upper = where_h->h_linp[where_i] = - (index_t) (where - (int) where_h); - where_h->h_lower += sizeof(index_t); - where_i++; - - /* if we've moved half, switch to the right-hand page */ - nbytes -= LONGALIGN(dsize) + sizeof(index_t); - if ((freespc - nbytes) > nbytes) { - nbytes = 2 * freespc; - - /* identical keys go on the same page */ - if (save_i > 0) { - /* i gets incremented at loop bottom... */ - i = save_i - 1; - where_h->h_lower = save_lower; - where_h->h_upper = save_upper; - } - where = ((char *) right) + psize; - where_h = right; - switch_i = where_i; - where_i = 0; - } - } - - /* - * If there was an active scan on the database, and we just - * split the page that the cursor was on, we may need to - * adjust the cursor to point to the same entry as before the - * split. - */ - - c = &(t->bt_cursor); - if ((t->bt_flags & BTF_SEQINIT) - && (c->c_pgno == h->h_pgno) - && (c->c_index >= switch_i)) { - c->c_pgno = where_h->h_pgno; - c->c_index -= where_i; - } - return (RET_SUCCESS); -} diff --git a/lib/libc/db/btree/storage.c b/lib/libc/db/btree/storage.c deleted file mode 100644 index 963d16c066c9..000000000000 --- a/lib/libc/db/btree/storage.c +++ /dev/null @@ -1,664 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)storage.c 5.2 (Berkeley) 2/22/91"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include "btree.h" - -/* - * BT_GETPAGE -- Make pgno the current page of the btree. - * - * This routine is just a wrapper that decides whether to call the - * memory or disk-based routine to do the work. - * - * Parameters: - * t -- btree in which to get page - * pgno -- page number to get - * - * Returns: - * RET_SUCCESS or RET_ERROR. - */ - -int -_bt_getpage(t, pgno) - BTREE_P t; - pgno_t pgno; -{ -#ifdef DEBUG - if (pgno == P_NONE) - _punt(); -#endif /* DEBUG */ - - /* see if we can get away without doing any work */ - if (t->bt_curpage != (BTHEADER *) NULL) { - if (t->bt_curpage->h_pgno == pgno) - return (RET_SUCCESS); - } - - if (t->bt_fname == (char *) NULL) - return (_bt_getmpage(t, pgno)); - else - return (_bt_getdpage(t, pgno)); -} - -/* - * _BT_GETMPAGE -- Make pgno the current page of the btree. - * - * This routine gets pages for in-memory btrees. - * - * Parameters: - * t -- btree in which to get page - * pgno -- page number to get - * - * Returns: - * RET_SUCCESS or RET_ERROR. - */ - -int -_bt_getmpage(t, pgno) - register BTREE_P t; - pgno_t pgno; -{ - int htindex; - BTHEADER *h; - HTBUCKET *b; - - if (t->bt_curpage == (BTHEADER *) NULL) { - if (pgno != P_ROOT) { - errno = EBADF; - return (RET_ERROR); - } - - t->bt_npages++; - h = (BTHEADER *) malloc((unsigned) t->bt_psize); - if (h == (BTHEADER *) NULL) - return (RET_ERROR); - - h->h_pgno = P_ROOT; - h->h_flags = F_LEAF; - h->h_lower = (index_t) - (((char *) &(h->h_linp[0])) - ((char *) h)); - h->h_upper = t->bt_psize; - h->h_prevpg = h->h_nextpg = P_NONE; - - t->bt_curpage = h; - - /* get the root page into the hash table */ - if (_bt_write(t, h, RELEASE) == RET_ERROR) - return (RET_ERROR); - } - - htindex = HASHKEY(pgno); - - for (b = t->bt_s.bt_ht[htindex]; - b != (HTBUCKET *) NULL; - b = b->ht_next) { - if (b->ht_pgno == pgno) { - t->bt_curpage = b->ht_page; - return (RET_SUCCESS); - } - } - return (RET_ERROR); -} - -/* - * _BT_GETDPAGE -- Make pgno the current page of the btree. - * - * This routine gets pages for disk btrees. - * - * Because disk btree pages must be readable across machine architectures, - * the btree code writes integers out in network format. This routine - * converts them back to host format before returning the page. - * - * Parameters: - * t -- btree in which to get page - * pgno -- page number to get - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ - -int -_bt_getdpage(t, pgno) - register BTREE_P t; - pgno_t pgno; -{ - BTHEADER *h; - char *cache; - long pos; - int n, nbytes; - - /* if we have an lru cache, let the cache code do the work */ - if (ISCACHE(t)) { - cache = t->bt_s.bt_d.d_cache; - - /* release the old page */ - if (t->bt_curpage != (BTHEADER *) NULL) { - pgno_t opgno = t->bt_curpage->h_pgno; - t->bt_curpage->h_flags &= ~F_DIRTY; - - if (lruwrite(cache, (int) opgno) < 0) - return (RET_ERROR); - - if (lrurelease(cache, (int) opgno) < 0) - return (RET_ERROR); - } - - if (pgno > t->bt_npages) { - if ((h = (BTHEADER *) lrugetnew(cache, (int)pgno, &nbytes)) - == (BTHEADER *) NULL) - return (RET_ERROR); - t->bt_npages = pgno; - } else { - if ((h = (BTHEADER *) lruget(cache, (int)pgno, &nbytes)) - == (BTHEADER *) NULL) - return (RET_ERROR); - } - - /* init this page, if necessary */ - if (nbytes == 0) { - h->h_pgno = pgno; - h->h_flags = F_LEAF; - h->h_lower = (index_t) - (((char *) &(h->h_linp[0])) - ((char *) h)); - h->h_upper = t->bt_psize; - h->h_prevpg = h->h_nextpg = P_NONE; - } - - t->bt_curpage = h; - - return (RET_SUCCESS); - } - - /* sync the current page, if necessary */ - if (t->bt_curpage != (BTHEADER *) NULL) { - if (t->bt_curpage->h_flags & F_DIRTY) - if (_bt_write(t, t->bt_curpage, RELEASE) == RET_ERROR) - return (RET_ERROR); - } else { - if (t->bt_npages == 0) - t->bt_npages = 1; - - /* if no current page, get space for one */ - if ((t->bt_curpage = (BTHEADER *) malloc((unsigned) t->bt_psize)) - == (BTHEADER *) NULL) { - return (RET_ERROR); - } - } - - n = t->bt_psize; - pos = (long) (pgno * n); - - /* seek to correct location in file */ - if (lseek(t->bt_s.bt_d.d_fd, pos, L_SET) != pos) { - return (RET_ERROR); - } - - /* read the page */ - if ((nbytes = read(t->bt_s.bt_d.d_fd, t->bt_curpage, n)) < n) { - - /* - * If we didn't get a full page, we must have gotten no - * data at all -- in which case we're trying to read a - * root page that doesn't exist yet. This is the only - * case in which this is okay. If this happens, construct - * an empty root page by hand. - */ - if (nbytes != 0 || pgno != P_ROOT) { - errno = EBADF; - return (RET_ERROR); - } - - h = (BTHEADER *) t->bt_curpage; - h->h_pgno = pgno; - h->h_flags = F_LEAF; - h->h_lower = (index_t) - (((char *) &(h->h_linp[0])) - ((char *) h)); - h->h_upper = t->bt_psize; - h->h_prevpg = h->h_nextpg = P_NONE; - } else - (void) _bt_pgin(t->bt_curpage, (char *) t->bt_lorder); - - return (RET_SUCCESS); -} - -/* - * _BT_PGOUT, _BT_PGIN -- Convert host-specific number layout to/from - * the host-independent format stored on disk. - * - * Parameters: - * h -- page to convert - * _lorder -- byte order for pages (stored as a char * in the - * cache, and passed around as a magic cookie). - * - * Returns: - * RET_SUCCESS (lru code requires a return value). - * - * Side Effects: - * Layout of tree metadata on the page is changed in place. - * - * Warnings: - * Everywhere else in the code, the types pgno_t and index_t - * are opaque. These two routines know what they really - * are. - */ - -int -_bt_pgout(h, _lorder) - BTHEADER *h; - char *_lorder; -{ - int i; - int top; - int lorder; - DATUM *d; - IDATUM *id; - size_t chain; - - lorder = (int) _lorder; - if (lorder == BYTE_ORDER) - return (RET_SUCCESS); - - if (h->h_flags & F_LEAF) { - if (h->h_flags & F_CONT) { - if (h->h_prevpg == P_NONE) { - size_t longsz; - - (void) bcopy((char *) &(h->h_linp[0]), - (char *) &longsz, - sizeof(longsz)); - BLSWAP(longsz); - (void) bcopy((char *) &longsz, - (char *) &(h->h_linp[0]), - sizeof(longsz)); - } - } else { - top = NEXTINDEX(h); - for (i = 0; i < top; i++) { - d = (DATUM *) GETDATUM(h, i); - if (d->d_flags & D_BIGKEY) { - (void) bcopy((char *) &(d->d_bytes[0]), - (char *) &chain, - sizeof(chain)); - BLSWAP(chain); - (void) bcopy((char *) &chain, - (char *) &(d->d_bytes[0]), - sizeof(chain)); - } - if (d->d_flags & D_BIGDATA) { - (void) bcopy((char *) &(d->d_bytes[d->d_ksize]), - (char *) &chain, - sizeof(chain)); - BLSWAP(chain); - (void) bcopy((char *) &chain, - (char *) &(d->d_bytes[d->d_ksize]), - sizeof(chain)); - } - BLSWAP(d->d_dsize); - BLSWAP(d->d_ksize); - BLSWAP(d->d_flags); - BLSWAP(h->h_linp[i]); - } - } - } else { - top = NEXTINDEX(h); - for (i = 0; i < top; i++) { - id = (IDATUM *) GETDATUM(h, i); - BLSWAP(id->i_size); - BLSWAP(id->i_pgno); - BLSWAP(id->i_flags); - if (id->i_flags & D_BIGKEY) { - (void) bcopy((char *) &(id->i_bytes[0]), - (char *) &chain, - sizeof(chain)); - BLSWAP(chain); - (void) bcopy((char *) &chain, - (char *) &(id->i_bytes[0]), - sizeof(chain)); - } - BLSWAP(h->h_linp[i]); - } - } - BLSWAP(h->h_flags); - BLSWAP(h->h_pgno); - BLSWAP(h->h_prevpg); - BLSWAP(h->h_nextpg); - BLSWAP(h->h_lower); - BLSWAP(h->h_upper); - - return (RET_SUCCESS); -} - -int -_bt_pgin(h, _lorder) - BTHEADER *h; - char *_lorder; -{ - int i; - int top; - int lorder; - DATUM *d; - IDATUM *id; - size_t chain; - - /* - * If btree pages are to be stored in the host byte order, don't - * bother swapping. - */ - lorder = (int) _lorder; - if (lorder == BYTE_ORDER) - return (RET_SUCCESS); - - BLSWAP(h->h_upper); - BLSWAP(h->h_lower); - BLSWAP(h->h_nextpg); - BLSWAP(h->h_prevpg); - BLSWAP(h->h_pgno); - BLSWAP(h->h_flags); - - if (h->h_flags & F_LEAF) { - if (h->h_flags & F_CONT) { - if (h->h_prevpg == P_NONE) { - size_t longsz; - - (void) bcopy((char *) &(h->h_linp[0]), - (char *) &longsz, - sizeof(longsz)); - BLSWAP(longsz); - (void) bcopy((char *) &longsz, - (char *) &(h->h_linp[0]), - sizeof(longsz)); - } - } else { - top = NEXTINDEX(h); - for (i = 0; i < top; i++) { - BLSWAP(h->h_linp[i]); - d = (DATUM *) GETDATUM(h, i); - BLSWAP(d->d_dsize); - BLSWAP(d->d_ksize); - BLSWAP(d->d_flags); - if (d->d_flags & D_BIGKEY) { - (void) bcopy((char *) &(d->d_bytes[0]), - (char *) &chain, - sizeof(chain)); - BLSWAP(chain); - (void) bcopy((char *) &chain, - (char *) &(d->d_bytes[0]), - sizeof(chain)); - } - if (d->d_flags & D_BIGDATA) { - (void) bcopy((char *) &(d->d_bytes[d->d_ksize]), - (char *) &chain, - sizeof(chain)); - BLSWAP(chain); - (void) bcopy((char *) &chain, - (char *) &(d->d_bytes[d->d_ksize]), - sizeof(chain)); - } - } - } - } else { - top = NEXTINDEX(h); - for (i = 0; i < top; i++) { - BLSWAP(h->h_linp[i]); - id = (IDATUM *) GETDATUM(h, i); - BLSWAP(id->i_size); - BLSWAP(id->i_pgno); - BLSWAP(id->i_flags); - if (id->i_flags & D_BIGKEY) { - (void) bcopy((char *) &(id->i_bytes[0]), - (char *) &chain, - sizeof(chain)); - BLSWAP(chain); - (void) bcopy((char *) &chain, - (char *) &(id->i_bytes[0]), - sizeof(chain)); - } - } - } - return (RET_SUCCESS); -} - -/* - * _BT_ALLOCPG -- allocate a new page in the btree. - * - * This is called when we split a page, to get space to do the split. - * For disk btrees, these pages are released when the split is done. - * For memory btrees, they are not. - * - * Parameters: - * t -- tree in which to do split - * - * Returns: - * Pointer to the newly-allocated page - */ - -BTHEADER * -_bt_allocpg(t) - BTREE_P t; -{ - BTHEADER *h = t->bt_curpage; - BTHEADER *nh; - int nbytes; - - /* if we have a cache, let the cache code do the work */ - if (ISDISK(t) && ISCACHE(t)) { - nh = (BTHEADER *) lrugetnew(t->bt_s.bt_d.d_cache, - (int) (t->bt_npages + 1), - &nbytes); - } else { - nh = (BTHEADER *) malloc((unsigned) t->bt_psize); - } - - if (nh != (BTHEADER *) NULL) { - nh->h_pgno = nh->h_prevpg = nh->h_nextpg = P_NONE; - nh->h_flags = h->h_flags; - nh->h_lower = (index_t) - (((char *) &(nh->h_linp[0])) - ((char *) nh)); - nh->h_upper = t->bt_psize; - } - - return (nh); -} - -/* - * _BT_WRITE -- Write a specific page to a btree file. - * - * Parameters: - * t -- btree to get the page - * h -- page to write - * relflag -- (int) this page may/may not be released - * - * Returns: - * RET_SUCCESS, RET_ERROR. - * - * Side Effects: - * Writes a metadata page if none has been written yet. - */ - -int -_bt_write(t, h, relflag) - BTREE_P t; - BTHEADER *h; - int relflag; -{ - long pos; - int htindex; - HTBUCKET *b; - char *cache; - pgno_t pgno; - - h->h_flags &= ~F_DIRTY; - if (ISDISK(t)) { - - /* if we haven't done so yet, write the metadata */ - if (!(t->bt_flags & BTF_METAOK)) { - if (_bt_wrtmeta(t) == RET_ERROR) - return (RET_ERROR); - } - - pgno = h->h_pgno; - - - /* if we have a cache, let the cache code do the work */ - if ((cache = t->bt_s.bt_d.d_cache) != (char *) NULL) { - if (lruwrite(cache, (int) pgno) < 0) - return (RET_ERROR); - if (relflag && lrurelease(cache, (int) pgno) < 0) - return (RET_ERROR); - - } else { - (void) _bt_pgout(h, (char *) t->bt_lorder); - /* now write the current page */ - pos = (long) (pgno * t->bt_psize); - if (lseek(t->bt_s.bt_d.d_fd, pos, L_SET) != pos) - return (RET_ERROR); - if (write(t->bt_s.bt_d.d_fd, (char *) h, (int) t->bt_psize) - < t->bt_psize) - return (RET_ERROR); - if (!relflag) - (void) _bt_pgin(h, (char *) t->bt_lorder); - } - } else { - /* in-memory btree */ - htindex = HASHKEY(h->h_pgno); - - /* see if we need to overwrite existing entry */ - for (b = t->bt_s.bt_ht[htindex]; - b != (HTBUCKET *) NULL; - b = b->ht_next) { - if (b->ht_pgno == h->h_pgno) { - b->ht_page = h; - return (RET_SUCCESS); - } - } - - /* new entry, write it */ - b = (HTBUCKET *) malloc((unsigned) sizeof (HTBUCKET)); - if (b == (HTBUCKET *) NULL) - return (RET_ERROR); - - b->ht_pgno = h->h_pgno; - b->ht_page = h; - b->ht_next = t->bt_s.bt_ht[htindex]; - t->bt_s.bt_ht[htindex] = b; - } - return (RET_SUCCESS); -} - -/* - * _BT_RELEASE -- Release a locked-down cache page - * - * During page splits, we want to force pages out to the cache - * before we actually release them, in some cases. This routine - * releases such a page when it is no longer needed. - * - * Parameters: - * t -- btree in which to release page - * h -- page to release - * - * Returns: - * RET_SUCCESS, RET_ERROR. - * - * Side Effects: - * None. - */ - -int -_bt_release(t, h) - BTREE_P t; - BTHEADER *h; -{ - if (ISDISK(t) && ISCACHE(t)) { - if (lrurelease(t->bt_s.bt_d.d_cache, (int) (h->h_pgno)) < 0) - return (RET_ERROR); - } - return (RET_SUCCESS); -} - -/* - * _BT_WRTMETA -- Write metadata to the btree. - * - * Parameters: - * t -- tree to which to write - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ - -int -_bt_wrtmeta(t) - BTREE_P t; -{ - BTMETA m; - - if (lseek(t->bt_s.bt_d.d_fd, 0l, L_SET) != 0l) - return (RET_ERROR); - - /* lorder has to be in host-independent format */ - m.m_lorder = (u_long) htonl((long) t->bt_lorder); - - m.m_magic = BTREEMAGIC; - m.m_version = BTREEVERSION; - m.m_psize = t->bt_psize; - m.m_free = t->bt_free; - m.m_flags = t->bt_flags & BTF_NODUPS; - - if (t->bt_lorder != BYTE_ORDER) { - BLSWAP(m.m_magic); - BLSWAP(m.m_version); - BLSWAP(m.m_psize); - BLSWAP(m.m_free); - BLSWAP(m.m_flags); - } - - if (write(t->bt_s.bt_d.d_fd, (char *) &m, sizeof(m)) - != sizeof(m)) { - return (RET_ERROR); - } - - t->bt_flags |= BTF_METAOK; - - return (RET_SUCCESS); -} diff --git a/lib/libc/db/btree/updutils.c b/lib/libc/db/btree/updutils.c deleted file mode 100644 index 8ed87fbf2e5d..000000000000 --- a/lib/libc/db/btree/updutils.c +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)updutils.c 5.2 (Berkeley) 2/22/91"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include "btree.h" - -/* - * _BT_FIXSCAN -- Adjust a scan to cope with a change in tree structure. - * - * If the user has an active scan on the database, and we delete an - * item from the page the cursor is pointing at, we need to figure - * out what to do about it. Basically, the solution is to point - * "between" keys in the tree, using the CRSR_BEFORE flag. The - * requirement is that the user should not miss any data in the - * tree during a scan, just because he happened to do some deletions - * or insertions while it was active. - * - * In order to guarantee that the scan progresses properly, we need - * to save the key of any deleted item we were pointing at, so that - * we can check later insertions against it. - * - * Parameters: - * t -- tree to adjust - * index -- index of item at which change was made - * newd -- new datum (for insertions only) - * op -- operation (DELETE or INSERT) causing change - * - * Returns: - * RET_SUCCESS, RET_ERROR (errno is set). - * - * Side Effects: - * None. - */ - -int -_bt_fixscan(t, index, newd, op) - BTREE_P t; - index_t index; - DATUM *newd; - int op; -{ - CURSOR *c; - DATUM *d; - - c = &(t->bt_cursor); - - if (op == DELETE) { - if (index < c->c_index) - c->c_index--; - else if (index == c->c_index) { - if (!(c->c_flags & CRSR_BEFORE)) { - if (_bt_crsrkey(t) == RET_ERROR) - return (RET_ERROR); - c->c_flags |= CRSR_BEFORE; - } - } - } else { - /* - * If we previously deleted the object at this location, - * and now we're inserting a new one, we need to do the - * right thing -- the cursor should come either before - * or after the new item, depending on the key that was - * here, and the new one. - */ - - if (c->c_flags & CRSR_BEFORE) { - if (index <= c->c_index) { - char *tmp; - int itmp; - pgno_t chain; - int r; - - d = (DATUM *) GETDATUM(t->bt_curpage, index); - if (d->d_flags & D_BIGKEY) { - bcopy(&(newd->d_bytes[0]), - (char *) &chain, - sizeof(chain)); - if (_bt_getbig(t, chain, &tmp, &itmp) - == RET_ERROR) - return (RET_ERROR); - } else - tmp = &(newd->d_bytes[0]); - - r = (*(t->bt_compare))(tmp, c->c_key); - if (r < 0) - c->c_index++; - - if (d->d_flags & D_BIGKEY) - (void) free (tmp); - } - } else if (index <= c->c_index) - c->c_index++; - } - return (RET_SUCCESS); -} - -/* - * _BT_CRSRKEY -- Save a copy of the key of the record that the cursor - * is pointing to. The record is about to be deleted. - * - * Parameters: - * t -- btree - * - * Returns: - * RET_SUCCESS, RET_ERROR. - * - * Side Effects: - * Allocates memory for the copy which should be released when - * it is no longer needed. - */ - -int -_bt_crsrkey(t) - BTREE_P t; -{ - CURSOR *c; - DATUM *d; - pgno_t pgno; - int ignore; - - c = &(t->bt_cursor); - d = (DATUM *) GETDATUM(t->bt_curpage, c->c_index); - - if (d->d_flags & D_BIGKEY) { - bcopy(&(d->d_bytes[0]), (char *) &pgno, sizeof(pgno)); - return (_bt_getbig(t, pgno, &(c->c_key), &ignore)); - } else { - if ((c->c_key = (char *) malloc(d->d_ksize)) == (char *) NULL) - return (RET_ERROR); - - bcopy(&(d->d_bytes[0]), c->c_key, (size_t) (d->d_ksize)); - } - return (RET_SUCCESS); -} diff --git a/lib/libc/db/btree/utils.c b/lib/libc/db/btree/utils.c deleted file mode 100644 index 58b499995df5..000000000000 --- a/lib/libc/db/btree/utils.c +++ /dev/null @@ -1,350 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)utils.c 5.3 (Berkeley) 3/3/91"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include "btree.h" - -/* - * _BT_BUILDRET -- Build return key/data pair as a result of search or scan. - * - * This routine manages the statically allocated buffers in which we - * return data to the user. - * - * Parameters: - * t -- btree from which to return datum - * d -- DATUM to be returned to the user. - * data -- data argument supplied by user for return - * key -- key argument supplied by user for return - * - * Returns: - * RET_SUCCESS, RET_ERROR. - * - * Side Effects: - * May free and reallocate static buffers, if the data - * we want to return is bigger than the space we have to - * do so. - */ - -int -_bt_buildret(t, d, data, key) - BTREE_P t; - DATUM *d; - DBT *data; - DBT *key; -{ - static int _data_s = 0; - static int _key_s = 0; - static char *_data = (char *) NULL; - static char *_key = (char *) NULL; - pgno_t chain; - - if (d->d_flags & D_BIGKEY) { - if (_key != (char *) NULL) - (void) free(_key); - (void) bcopy((char *) &(d->d_bytes[0]), - (char *) &chain, - sizeof(chain)); - if (_bt_getbig(t, chain, &_key, &_key_s) == RET_ERROR) - return (RET_ERROR); - key->data = (u_char *)_key; - key->size = _key_s; - } else { - /* need more space for key? */ - if (d->d_ksize > _key_s) { - if (_key != (char *) NULL) - (void) free (_key); - if ((_key = (char *) malloc((unsigned) d->d_ksize)) - == (char *) NULL) - return (RET_ERROR); - _key_s = d->d_ksize; - } - - key->data = (u_char *)_key; - if ((key->size = d->d_ksize) > 0) - (void) bcopy(&(d->d_bytes[0]), - _key, - (int) d->d_ksize); - } - - if (d->d_flags & D_BIGDATA) { - if (_data != (char *) NULL) - (void) free(_data); - (void) bcopy(&(d->d_bytes[d->d_ksize]), - (char *) &chain, - sizeof(chain)); - if (_bt_getbig(t, chain, &_data, &_data_s) == RET_ERROR) - return (RET_ERROR); - data->data = (u_char *)_data; - data->size = _data_s; - } else { - /* need more space for data? */ - if (d->d_dsize > _data_s) { - if (_data != (char *) NULL) - (void) free (_data); - if ((_data = (char *) malloc((unsigned) d->d_dsize)) - == (char *) NULL) - return (RET_ERROR); - _data_s = d->d_dsize; - } - - data->data = (u_char *)_data; - - if ((data->size = d->d_dsize) > 0) - (void) bcopy(&(d->d_bytes[d->d_ksize]), - _data, - (size_t) (d->d_dsize)); - } - - return (RET_SUCCESS); -} - -/* - * _BT_CMP -- Compare a key to a given item on the current page. - * - * This routine is a wrapper for the user's comparison function. - * - * Parameters: - * t -- tree in which to do comparison - * p -- pointer to one argument for the comparison function - * n -- index of item to supply second arg to comparison function - * - * Returns: - * < 0 if p is < item at n - * = 0 if p is = item at n - * > 0 if p is > item at n - */ - -int -_bt_cmp(t, p, n) - BTREE_P t; - char *p; - index_t n; -{ - BTHEADER *h; - IDATUM *id; - DATUM *d; - char *arg; - int ignore; - int free_arg; - pgno_t chain; - int r; - - h = t->bt_curpage; - - /* - * The left-most key at any level of the tree on internal pages - * is guaranteed (artificially, by the code here) to be less than - * any user key. This saves us from having to update the leftmost - * key when the user inserts a new key in the tree smaller than - * anything we've seen yet. - */ - - if (h->h_prevpg == P_NONE && !(h->h_flags & F_LEAF) && n == 0) - return (1); - - if (h->h_flags & F_LEAF) { - d = (DATUM *) GETDATUM(h,n); - if (d->d_flags & D_BIGKEY) { - free_arg = TRUE; - bcopy(&(d->d_bytes[0]), (char *) &chain, sizeof(chain)); - if (_bt_getbig(t, chain, &arg, &ignore) == RET_ERROR) - return (RET_ERROR); - } else { - free_arg = FALSE; - arg = &(d->d_bytes[0]); - } - } else { - id = (IDATUM *) GETDATUM(h,n); - if (id->i_flags & D_BIGKEY) { - free_arg = TRUE; - bcopy(&(id->i_bytes[0]), - (char *) &chain, - sizeof(chain)); - if (_bt_getbig(t, chain, &arg, &ignore) == RET_ERROR) - return (RET_ERROR); - } else { - free_arg = FALSE; - arg = &(id->i_bytes[0]); - } - } - r = (*(t->bt_compare))(p, arg); - - if (free_arg) - (void) free(arg); - - return (r); -} - -/* - * _BT_PUSH/_BT_POP -- Push/pop a parent page number on the parent stack. - * - * When we descend the tree, we keep track of parent pages in order - * to handle splits on insertions. - * - * Parameters: - * t -- tree for which to push parent - * pgno -- page number to push (_bt_push only) - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ - -int -_bt_push(t, pgno) - BTREE_P t; - pgno_t pgno; -{ - BTSTACK *new; - - if ((new = (BTSTACK *) malloc((unsigned) sizeof(BTSTACK))) - == (BTSTACK *) NULL) - return (RET_ERROR); - new->bts_pgno = pgno; - new->bts_next = t->bt_stack; - t->bt_stack = new; - - return (RET_SUCCESS); -} - -pgno_t -_bt_pop(t) - BTREE_P t; -{ - BTSTACK *s; - pgno_t p = P_NONE; - - if ((s = t->bt_stack) != (BTSTACK *) NULL) { - p = s->bts_pgno; - t->bt_stack = s->bts_next; - (void) free ((char *) s); - } - return (p); -} - -#ifdef DEBUG -void -_btdump(tree) - BTREE tree; -{ - BTREE_P t = (BTREE_P) tree; - DATUM *d; - IDATUM *id; - BTHEADER *h; - pgno_t npages; - pgno_t i; - index_t cur, top; - - npages = t->bt_npages; - (void) printf("\"%s\" fd %d pgsz %d curpg %d @ 0x%lx", - t->bt_fname, t->bt_s.bt_d.d_fd, - t->bt_psize, t->bt_curpage); - (void) printf("npg %d cmp 0x%lx flags=(", npages, t->bt_compare); - if (t->bt_flags & BTF_SEQINIT) - (void) printf("BTF_SEQINIT"); - (void) printf(")\n"); - - for (i = P_ROOT; i <= npages; i++) { - if (_bt_getpage(t, i) == RET_ERROR) - _punt(); - h = t->bt_curpage; - top = NEXTINDEX(h); - (void) printf(" page %d:\n", i); - (void) printf("\tpgno %d prev %d next %d\n", - h->h_pgno, h->h_prevpg, h->h_nextpg); - (void) printf("\tlower %d upper %d nextind %d flags (", - h->h_lower, h->h_upper, top); - if (h->h_flags & F_LEAF) - (void) printf("F_LEAF"); - else - (void) printf(""); - if (h->h_flags & F_DIRTY) - (void) printf("|F_DIRTY"); - if (h->h_flags & F_PRESERVE) - (void) printf("|F_PRESERVE"); - if (h->h_flags & F_CONT) { - (void) printf("|F_CONT)"); - if (h->h_prevpg == P_NONE) { - size_t longsz; - (void) bcopy((char *) &(h->h_linp[0]), - (char *) &longsz, - sizeof(longsz)); - printf("\n\t\t(chain start, data length %ld)", - longsz); - } - printf("\n"); - continue; - } - (void) printf(")\n"); - for (cur = 0; cur < top; cur++) { - (void) printf("\t [%d] off %d ", cur, h->h_linp[cur]); - if (h->h_flags & F_LEAF) { - d = (DATUM *) GETDATUM(h,cur); - (void) printf("ksize %d", d->d_ksize); - if (d->d_flags & D_BIGKEY) - (void) printf(" (indirect)"); - (void) printf("; dsize %d", d->d_dsize); - if (d->d_flags & D_BIGDATA) - (void) printf(" (indirect)"); - } else { - id = (IDATUM *) GETDATUM(h,cur); - (void) printf("size %d pgno %d", - id->i_size, id->i_pgno); - if (id->i_flags & D_BIGKEY) - (void) printf(" (indirect)"); - } - (void) printf("\n"); - } - (void) printf("\n"); - } -} -#endif /* DEBUG */ - -#ifdef DEBUG -_punt() -{ - int pid; - - pid = getpid(); - (void) kill(pid, SIGILL); -} -#endif /* DEBUG */ diff --git a/lib/libc/db/hash/hfunc.c b/lib/libc/db/hash/hfunc.c deleted file mode 100644 index de622f49d424..000000000000 --- a/lib/libc/db/hash/hfunc.c +++ /dev/null @@ -1,179 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hfunc.c 5.1 (Berkeley) 2/12/91"; -#endif /* LIBC_SCCS and not lint */ - -/* Global default hash function */ -static int hash1(); -static int hash2(); -static int hash3(); -static int hash4(); - -int (*default_hash)() = hash4; - -/******************************* HASH FUNCTIONS **************************/ -/* - Assume that we've already split the bucket to which this - key hashes, calculate that bucket, and check that in fact - we did already split it. - - This came from ejb's hsearch. -*/ - -# define PRIME1 37 -# define PRIME2 1048583 - -static int -hash1(key,len) -char *key; -int len; -{ - register int h; - register int l = len; - register unsigned char *k = (unsigned char *) key; - - h = 0; - /* - * Convert string to integer - */ - while (l--) h = h * PRIME1 ^ (*k++ - ' '); - h %= PRIME2; - - return (h); -} - -/* - Phong's linear congruential hash -*/ -#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c)) - -static int -hash2(str, n) - register unsigned char *str; - int n; -{ - register unsigned char *e, c; - register int h; - - e = str + n; - for (h = 0; str != e;) { - c = *str++; - if (!c && str > e) - break; - dcharhash(h,c); - } - return(h); -} - -/* - * This is INCREDIBLY ugly, but fast. - * We break the string up into 8 byte units. On the first time - * through the loop we get the "leftover bytes" (strlen % 8). - * On every other iteration, we perform 8 HASHC's so we handle - * all 8 bytes. Essentially, this saves us 7 cmp & branch - * instructions. If this routine is heavily used enough, it's - * worth the ugly coding - * - * OZ's original sdbm hash - */ -static int -hash3(key,nbytes) -char *key; -int nbytes; -{ - register int n = 0; - register char *str = key; - register int loop; - register int len = nbytes; - -#define HASHC n = *str++ + 65599 * n - - if (len > 0) { - loop = (len + 8 - 1) >> 3; - - switch(len & (8 - 1)) { - case 0: do { /* All fall throughs */ - HASHC; - case 7: HASHC; - case 6: HASHC; - case 5: HASHC; - case 4: HASHC; - case 3: HASHC; - case 2: HASHC; - case 1: HASHC; - } while (--loop); - } - - } - return(n); -} - -/* Hash function from Chris Torek */ -static int -hash4(key,nbytes) -char *key; -int nbytes; -{ - register int h = 0; - register char *p = key; - register int loop; - register int len = nbytes; - -#define HASH4a h = (h << 5) - h + *p++; -#define HASH4b h = (h << 5) + h + *p++; -#define HASH4 HASH4b - - if (len > 0) { - loop = (len + 8 - 1) >> 3; - - switch(len & (8 - 1)) { - case 0: do { /* All fall throughs */ - HASH4; - case 7: HASH4; - case 6: HASH4; - case 5: HASH4; - case 4: HASH4; - case 3: HASH4; - case 2: HASH4; - case 1: HASH4; - } while (--loop); - } - - } - return(h); -} diff --git a/lib/libc/db/hash/log2.c b/lib/libc/db/hash/log2.c deleted file mode 100644 index 4d2a4c3d0228..000000000000 --- a/lib/libc/db/hash/log2.c +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)log2.c 5.1 (Berkeley) 2/12/91"; -#endif /* LIBC_SCCS and not lint */ - -__log2( num ) -int num; -{ - register int i; - register int limit = 1; - - for ( i = 0; limit < num; limit = limit << 1, i++ ); - return (i); -} diff --git a/lib/libc/db/hash/page.c b/lib/libc/db/hash/page.c deleted file mode 100644 index e577d658b55d..000000000000 --- a/lib/libc/db/hash/page.c +++ /dev/null @@ -1,905 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)page.c 5.13 (Berkeley) 6/17/91"; -#endif /* LIBC_SCCS and not lint */ - -/****************************************************************************** -PACKAGE: hashing - -DESCRIPTION: - Page manipulation for hashing package. - -ROUTINES: - External - __get_page - __add_ovflpage - Internal - overflow_page - open_temp -******************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "hash.h" -#include "page.h" - -/* Externals */ -/* buf.c */ -extern BUFHEAD *__get_buf(); -extern void __reclaim_buf(); - -/* big.c */ -extern int __big_split(); -extern int __big_insert(); -extern int __big_delete(); -extern int __find_bigpair(); - -/* dynahash.c */ -extern u_int __call_hash(); -extern int __expand_table(); - -/* my externals */ -extern int __get_page(); -extern BUFHEAD *__add_ovflpage(); -extern int __split_page(); -extern int __addel(); - -/* my internals */ -static u_short overflow_page(); -static int open_temp(); -static int ugly_split(); -static void squeeze_key(); -static void putpair(); -static u_long *fetch_bitmap(); - -#ifdef HASH_STATISTICS -extern long hash_accesses, hash_collisions, hash_expansions, hash_overflows; -#endif -#define PAGE_INIT(P) \ -{ \ - ((u_short *)P)[0] = 0; \ - ((u_short *)P)[1] = hashp->BSIZE - 3 * sizeof(u_short); \ - ((u_short *)P)[2] = hashp->BSIZE; \ -} - -/* - This is called AFTER we have verified that there is room on the - page for the pair (PAIRFITS has returned true) so we go right - ahead and start moving stuff on. -*/ -static void -putpair(p, key, val) -char *p; -DBT *key; -DBT *val; -{ - register u_short n; - register u_short off; - register u_short *bp = (u_short *) p; - -/* enter the key first */ - n = bp[0]; - - off = OFFSET(bp) - key->size; - bcopy( key->data, p+off, key->size ); - bp[++n] = off; - -/* now the data */ - off -= val->size; - bcopy(val->data, p + off, val->size); - bp[++n] = off; - -/* adjust page info */ - bp[0] = n; - bp[n+1] = off - ((n+3)*sizeof(u_short)); - bp[n+2] = off; - return; -} -/* - 0 OK - -1 error -*/ -extern int -__delpair(bufp, ndx) -BUFHEAD *bufp; -register int ndx; -{ - register u_short *bp = (u_short *) bufp->page; - register int n = bp[0]; - register u_short newoff; - u_short pairlen; - - if ( bp[ndx+1] < REAL_KEY ) return ( __big_delete ( bufp, ndx ) ); - if ( ndx != 1 ) newoff = bp[ndx-1]; - else newoff = hashp->BSIZE; - pairlen = newoff - bp[ndx+1]; - - if ( ndx != (n-1) ) { - /* Hard Case -- need to shuffle keys */ - register int i; - register char *src = bufp->page + (int)OFFSET(bp); - register char *dst = src + (int)pairlen; - bcopy ( src, dst, bp[ndx+1] - OFFSET(bp) ); - - /* Now adjust the pointers */ - for ( i = ndx+2; i <= n; i += 2 ) { - if ( bp[i+1] == OVFLPAGE ) { - bp[i-2] = bp[i]; - bp[i-1] = bp[i+1]; - } else { - bp[i-2] = bp[i] + pairlen; - bp[i-1] = bp[i+1] + pairlen; - } - } - } - - /* Finally adjust the page data */ - bp[n] = OFFSET(bp) + pairlen; - bp[n-1] = bp[n+1] + pairlen + 2 * sizeof(u_short); - bp[0] = n-2; - hashp->NKEYS--; - - bufp->flags |= BUF_MOD; - return (0); -} -/* - -1 ==> Error - 0 ==> OK -*/ -extern int -__split_page(obucket, nbucket) -u_int obucket; -u_int nbucket; -{ - DBT key; - DBT val; - - register BUFHEAD *new_bufp; - register BUFHEAD *old_bufp; - register u_short *ino; - register char *np; - int n; - int ndx; - int retval; - char *op; - - u_short copyto = (u_short)hashp->BSIZE; - u_short diff; - u_short off = (u_short)hashp->BSIZE; - u_short moved; - - old_bufp = __get_buf ( obucket, NULL, 0 ); - new_bufp = __get_buf ( nbucket, NULL, 0 ); - - old_bufp->flags |= (BUF_MOD|BUF_PIN); - new_bufp->flags |= (BUF_MOD|BUF_PIN); - - ino = (u_short *)(op = old_bufp->page); - np = new_bufp->page; - - moved = 0; - - for (n = 1, ndx = 1; n < ino[0]; n+=2) { - if ( ino[n+1] < REAL_KEY ) { - retval = ugly_split( obucket, old_bufp, new_bufp, - copyto, moved ); - old_bufp->flags &= ~BUF_PIN; - new_bufp->flags &= ~BUF_PIN; - return(retval); - - } - key.data = (u_char *)op + ino[n]; - key.size = off - ino[n]; - - if ( __call_hash ( key.data, key.size ) == obucket ) { - /* Don't switch page */ - diff = copyto - off; - if ( diff ) { - copyto = ino[n+1] + diff; - bcopy ( op + ino[n+1], op + copyto, off-ino[n+1]); - ino[ndx] = copyto + ino[n] - ino[n+1]; - ino[ndx+1] = copyto; - } else copyto = ino[n+1]; - ndx += 2; - } else { - /* Switch page */ - val.data = (u_char *)op + ino[n+1]; - val.size = ino[n] - ino[n+1]; - putpair( np, &key, &val); - moved +=2; - } - - off = ino[n+1]; - } - - /* Now clean up the page */ - ino[0] -= moved; - FREESPACE(ino) = copyto - sizeof(u_short) * (ino[0]+3); - OFFSET(ino) = copyto; - -#ifdef DEBUG3 - fprintf(stderr, "split %d/%d\n", - ((u_short *) np)[0] / 2, - ((u_short *) op)[0] / 2); -#endif - /* unpin both pages */ - old_bufp->flags &= ~BUF_PIN; - new_bufp->flags &= ~BUF_PIN; - return(0); -} -/* - 0 ==> success - -1 ==> failure - - Called when we encounter an overflow or big key/data page during - split handling. - This is special cased since we have to begin checking whether - the key/data pairs fit on their respective pages and because - we may need overflow pages for both the old and new pages - - The first page might be a page with regular key/data pairs - in which case we have a regular overflow condition and just - need to go on to the next page or it might be a big key/data - pair in which case we need to fix the big key/data pair. -*/ -static int -ugly_split( obucket, old_bufp, new_bufp, copyto, moved ) -u_int obucket; /* Same as __split_page */ -BUFHEAD *old_bufp; -BUFHEAD *new_bufp; -u_short copyto; /* First byte on page which contains key/data values */ -int moved; /* number of pairs moved to new page */ -{ - register BUFHEAD *bufp = old_bufp; /* Buffer header for ino */ - register u_short *ino = (u_short *)old_bufp->page; - /* Page keys come off of */ - register u_short *np = (u_short *)new_bufp->page; /* New page */ - register u_short *op = (u_short *)old_bufp->page; - /* Page keys go on to if they - aren't moving */ - - char *cino; /* Character value of ino */ - BUFHEAD *last_bfp = NULL; /* Last buffer header OVFL which - needs to be freed */ - u_short ov_addr, last_addr = 0; - u_short n; - u_short off; - - DBT key, val; - SPLIT_RETURN ret; - - n = ino[0]-1; - while ( n < ino[0] ) { - if ( ino[2] < REAL_KEY && ino[2] != OVFLPAGE ) { - if (__big_split (old_bufp, new_bufp, bufp, ov_addr, obucket, &ret)) { - return(-1); - } - old_bufp = ret.oldp; - if ( !old_bufp ) return(-1); - op = (u_short *)old_bufp->page; - new_bufp = ret.newp; - if ( !new_bufp ) return(-1); - np = (u_short *)new_bufp->page; - bufp = ret.nextp; - if ( !bufp ) return(0); - cino = (char *)bufp->page; - ino = (u_short *)cino; - last_bfp = ret.nextp; - } else if ( ino[n+1] == OVFLPAGE ) { - ov_addr = ino[n]; - /* - Fix up the old page -- the extra 2 are the fields which - contained the overflow information - */ - ino[0] -= (moved + 2); - FREESPACE(ino) = copyto - sizeof(u_short) * (ino[0]+3); - OFFSET(ino) = copyto; - - bufp = __get_buf ( ov_addr, bufp, 0 ); - if ( !bufp ) return(-1); - - ino = (u_short *)bufp->page; - n = 1; - copyto = hashp->BSIZE; - moved = 0; - - if ( last_bfp ) { - __free_ovflpage( last_bfp); - } - last_bfp = bufp; - } - - - /* Move regular sized pairs of there are any */ - off = hashp->BSIZE; - for ( n = 1; (n < ino[0]) && (ino[n+1] >= REAL_KEY); n += 2 ) { - cino = (char *)ino; - key.data = (u_char *)cino + ino[n]; - key.size = off - ino[n]; - val.data = (u_char *)cino + ino[n+1]; - val.size = ino[n] - ino[n+1]; - off = ino[n+1]; - - if ( __call_hash ( key.data, key.size ) == obucket ) { - /* Keep on old page */ - if (PAIRFITS(op,(&key),(&val))) putpair((char *)op, &key, &val); - else { - old_bufp = __add_ovflpage ( old_bufp ); - if ( !old_bufp ) return(-1); - op = (u_short *)old_bufp->page; - putpair ((char *)op, &key, &val); - } - old_bufp->flags |= BUF_MOD; - } else { - /* Move to new page */ - if (PAIRFITS(np,(&key),(&val))) putpair((char *)np, &key, &val); - else { - new_bufp = __add_ovflpage ( new_bufp ); - if ( !new_bufp )return(-1); - np = (u_short *)new_bufp->page; - putpair ((char *)np, &key, &val); - } - new_bufp->flags |= BUF_MOD; - } - } - } - if ( last_bfp ) { - __free_ovflpage(last_bfp); - } - - return (0); -} -/* - Add the given pair to the page - 1 ==> failure - 0 ==> OK -*/ -extern int -__addel(bufp, key, val) -BUFHEAD *bufp; -DBT *key; -DBT *val; -{ - register u_short *bp = (u_short *)bufp->page; - register u_short *sop; - int do_expand; - - do_expand = 0; - while ( bp[0] && (bp[bp[0]] < REAL_KEY) ) { - /* Exception case */ - if ( bp[2] < REAL_KEY ) { - /* This is a big-keydata pair */ - bufp = __add_ovflpage(bufp); - if ( !bufp ) { - return(-1); - } - bp = (u_short *)bufp->page; - } else { - /* Try to squeeze key on this page */ - if ( FREESPACE(bp) > PAIRSIZE(key,val) ) { - squeeze_key ( bp, key, val ); - return(0); - } else { - bufp = __get_buf ( bp[bp[0]-1], bufp, 0 ); - if (!bufp) { - return(-1); - } - bp = (u_short *)bufp->page; - } - } - } - - if ( PAIRFITS(bp,key,val) ) putpair (bufp->page, key, val); - else { - do_expand = 1; - bufp = __add_ovflpage ( bufp ); - if (!bufp)return(-1); - sop = (u_short *) bufp->page; - - if ( PAIRFITS(sop, key, val) ) putpair ( (char *)sop, key, val ); - else if ( __big_insert ( bufp, key, val ) ) { - return(-1); - } - } - bufp->flags |= BUF_MOD; - /* - If the average number of keys per bucket exceeds the fill factor, - expand the table - */ - hashp->NKEYS++; - if (do_expand || - (hashp->NKEYS / (hashp->MAX_BUCKET+1) > hashp->FFACTOR) ) { - return(__expand_table()); - } - return(0); -} - -/* - returns a pointer, NULL on error -*/ -extern BUFHEAD * -__add_ovflpage ( bufp ) -BUFHEAD *bufp; -{ - register u_short *sp = (u_short *)bufp->page; - - u_short ovfl_num; - u_short ndx, newoff; - char *op; - DBT okey, oval; -#ifdef DEBUG1 - int tmp1, tmp2; -#endif - - bufp->flags |= BUF_MOD; - ovfl_num = overflow_page (); -#ifdef DEBUG1 - tmp1 = bufp->addr; - tmp2 = bufp->ovfl?bufp->ovfl->addr:0; -#endif - if (!ovfl_num || !(bufp->ovfl = __get_buf ( ovfl_num, bufp, 1 ))) { - return(NULL); - } - bufp->ovfl->flags |= BUF_MOD; -#ifdef DEBUG1 - fprintf ( stderr, "ADDOVFLPAGE: %d->ovfl was %d is now %d\n", tmp1, tmp2, - bufp->ovfl->addr ); -#endif - ndx = sp[0]; - /* - Since a pair is allocated on a page only if there's room - to add an overflow page, we know that the OVFL information - will fit on the page - */ - sp[ndx+4] = OFFSET(sp); - sp[ndx+3] = FREESPACE(sp) - OVFLSIZE; - sp[ndx+1] = ovfl_num; - sp[ndx+2] = OVFLPAGE; - sp[0] = ndx+2; -#ifdef HASH_STATISTICS - hash_overflows++; -#endif - return(bufp->ovfl); -} - -/* - 0 indicates SUCCESS - -1 indicates FAILURE -*/ -extern int -__get_page ( p, bucket, is_bucket, is_disk, is_bitmap ) -char *p; -u_int bucket; -int is_bucket; -int is_disk; -int is_bitmap; -{ - register int size; - register int fd; - register int page; - u_short *bp; - int rsize; - - fd = hashp->fp; - size = hashp->BSIZE; - - if ( (fd == -1) || !is_disk ) { - PAGE_INIT(p); - return(0); - } - - if ( is_bucket) page = BUCKET_TO_PAGE (bucket); - else page = OADDR_TO_PAGE (bucket); - if ((lseek ( fd, page << hashp->BSHIFT, SEEK_SET ) == -1) || - ((rsize = read ( fd, p, size )) == -1 )) { - return(-1); - } - bp = (u_short *)p; - if ( !rsize ) { - bp[0] = 0; /* We hit the EOF, so initialize a new page */ - } else if ( rsize != size ) { - errno = EFTYPE; - return(-1); - } - if (!bp[0]) { - PAGE_INIT(p); - } else if ( hashp->LORDER != BYTE_ORDER ) { - register int i; - register int max; - - if ( is_bitmap ) { - max = hashp->BSIZE >> 2; /* divide by 4 */ - for ( i=0; i < max; i++ ) { - BLSWAP(((long *)p)[i]); - } - } else { - BSSWAP(bp[0]); - max = bp[0] + 2; - for ( i=1; i <= max; i++ ) { - BSSWAP(bp[i]); - } - } - } - return (0); -} - -/* - Write page p to disk - -1==>failure - 0==> OK -*/ -extern int -__put_page ( p, bucket, is_bucket, is_bitmap ) -char *p; -u_int bucket; -int is_bucket; -int is_bitmap; -{ - register int size; - register int fd; - register int page; - int wsize; - - size = hashp->BSIZE; - if ( (hashp->fp == -1) && open_temp() ) return (1); - fd = hashp->fp; - - if ( hashp->LORDER != BYTE_ORDER ) { - register int i; - register int max; - - if ( is_bitmap ) { - max = hashp->BSIZE >> 2; /* divide by 4 */ - for ( i=0; i < max; i++ ) { - BLSWAP(((long *)p)[i]); - } - } else { - max = ((u_short *)p)[0] + 2; - for ( i=0; i <= max; i++ ) { - BSSWAP(((u_short *)p)[i]); - } - } - } - if (is_bucket ) page = BUCKET_TO_PAGE (bucket); - else page = OADDR_TO_PAGE ( bucket ); - if ((lseek ( fd, page << hashp->BSHIFT, SEEK_SET ) == -1) || - ((wsize = write ( fd, p, size )) == -1 )) { - /* Errno is set */ - return(-1); - } - if ( wsize != size ) { - errno = EFTYPE; - return(-1); - } - return(0); -} -#define BYTE_MASK ((1 << INT_BYTE_SHIFT) -1) -/* - Initialize a new bitmap page. Bitmap pages are left in memory - once they are read in. -*/ -extern u_long * -__init_bitmap(pnum, nbits, ndx) -u_short pnum; -int nbits; -int ndx; -{ - u_long *ip; - int clearints; - int clearbytes; - - if ( !(ip = (u_long *)malloc (hashp->BSIZE)) ) return (NULL); - hashp->nmaps++; - clearints = ((nbits - 1) >> INT_BYTE_SHIFT) + 1; - clearbytes = clearints << INT_TO_BYTE; - memset ((char *)ip, 0, clearbytes ); - memset ( ((char *) ip) + clearbytes, 0xFF, - hashp->BSIZE-clearbytes ); - ip[clearints-1] = ALL_SET << (nbits & BYTE_MASK); - SETBIT(ip, 0); - hashp->BITMAPS[ndx] = pnum; - hashp->mapp[ndx] = ip; - return(ip); -} -static int -first_free ( map ) -u_long map; -{ - register u_long mask; - register u_long i; - - mask = 0x1; - for ( i=0; i < BITS_PER_MAP; i++ ) { - if ( !(mask & map) ) return(i); - mask = mask << 1; - } - return ( i ); -} - -static u_short -overflow_page ( ) -{ - register int max_free; - register int splitnum; - register u_long *freep; - register int offset; - u_short addr; - int in_use_bits; - int free_page, free_bit; - int i, j, bit; -#ifdef DEBUG2 - int tmp1, tmp2; -#endif - - splitnum = __log2(hashp->MAX_BUCKET); - max_free = hashp->SPARES[splitnum]; - - free_page = (max_free-1) >> (hashp->BSHIFT + BYTE_SHIFT); - free_bit = (max_free-1) & ((hashp->BSIZE << BYTE_SHIFT) - 1); - - /* Look through all the free maps to find the first free block */ - for ( i = 0; i <= free_page; i++ ) { - if (!(freep = (u_long *)hashp->mapp[i]) && - !(freep = fetch_bitmap(i)) ) { - return ( NULL ); - } - if ( i == free_page ) in_use_bits = free_bit; - else in_use_bits = (hashp->BSIZE << BYTE_SHIFT) -1; - - for (j = 0, bit = 0; bit <= in_use_bits; j++, bit += BITS_PER_MAP ) { - if ( freep[j] != ALL_SET ) goto found; - } - } - /* No Free Page Found */ - hashp->SPARES[splitnum]++; - offset = hashp->SPARES[splitnum] - - (splitnum ? hashp->SPARES[splitnum-1] : 0); - - /* Check if we need to allocate a new bitmap page */ - if ( free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1 ) { - free_page++; -#define OVMSG "hash: out of overflow pages; increase page size\n" - if ( free_page >= NCACHED ) { - (void) write (STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - return(NULL); - } - /* - This is tricky. The 1 indicates that you want the - new page allocated with 1 clear bit. Actually, you - are going to allocate 2 pages from this map. The first - is going to be the map page, the second is the overflow - page we were looking for. The init_bitmap routine - automatically, sets the first bit of itself to indicate - that the bitmap itself is in use. We would explicitly - set the second bit, but don't have to if we tell init_bitmap - not to leave it clear in the first place. - */ - __init_bitmap ( OADDR_OF(splitnum, offset), 1, free_page ); - hashp->SPARES[splitnum]++; -#ifdef DEBUG2 - free_bit = 2; -#endif - offset++; - } else { - /* - Free_bit addresses the last used bit. Bump it to - address the first available bit. - */ - free_bit++; - SETBIT ( freep, free_bit ); - } - - /* Calculate address of the new overflow page */ - if ( offset > SPLITMASK ) { - (void) write (STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - return(NULL); - } - addr = OADDR_OF(splitnum, offset); -#ifdef DEBUG2 - fprintf ( stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", - addr, free_bit, free_page ); -#endif - return(addr); - -found: - bit = bit + first_free(freep[j]); - SETBIT(freep,bit); -#ifdef DEBUG2 - tmp1 = bit; - tmp2 = i; -#endif - /* - Bits are addressed starting with 0, but overflow pages are - addressed beginning at 1. Bit is a bit addressnumber, so we - need to increment it to convert it to a page number. - */ - bit = 1 + bit + (i * (hashp->BSIZE << BYTE_SHIFT)); - - /* Calculate the split number for this page */ - for ( i = 0; (i < splitnum) && (bit > hashp->SPARES[i]); i++ ); - offset =(i ? bit - hashp->SPARES[i-1] : bit ); - if ( offset >= SPLITMASK ) return(NULL);/* Out of overflow pages */ - addr = OADDR_OF(i, offset); -#ifdef DEBUG2 - fprintf ( stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", - addr, tmp1, tmp2 ); -#endif - - /* Allocate and return the overflow page */ - return (addr); -} - -/* - Mark this overflow page as free. -*/ -__free_ovflpage ( obufp ) -BUFHEAD *obufp; -{ - register u_short addr = obufp->addr; - int free_page, free_bit; - int bit_address; - u_short ndx; - u_long *freep; - int j; - -#ifdef DEBUG1 - fprintf ( stderr, "Freeing %d\n", addr ); -#endif - ndx = (((u_short)addr) >> SPLITSHIFT); - bit_address = (ndx ? hashp->SPARES[ndx-1] : 0) + (addr & SPLITMASK) - 1; - free_page = (bit_address >> (hashp->BSHIFT + BYTE_SHIFT)); - free_bit = bit_address & ((hashp->BSIZE << BYTE_SHIFT) - 1); - - if ( !(freep = hashp->mapp[free_page]) && - !(freep = fetch_bitmap( free_page )) ) { - /* - This had better never happen. It means we tried to - read a bitmap that has already had overflow pages allocated - off it, and we failed to read it from the file - */ - assert(0); - } - CLRBIT(freep, free_bit); -#ifdef DEBUG2 - fprintf ( stderr, "FREE_OVFLPAGE: ADDR: %d BIT: %d PAGE %d\n", - obufp->addr, free_bit, free_page ); -#endif - __reclaim_buf ( obufp ); - return; -} - -/* -0 success --1 failure -*/ -static int -open_temp() -{ - sigset_t set, oset; - static char namestr[] = "_hashXXXXXX"; - - /* Block signals; make sure file goes away at process exit. */ - sigemptyset(&set); - sigaddset(&set, SIGHUP); - sigaddset(&set, SIGINT); - sigaddset(&set, SIGQUIT); - sigaddset(&set, SIGTERM); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - if ((hashp->fp = mkstemp ( namestr )) != -1) { - (void)unlink(namestr); - (void)fcntl(hashp->fp, F_SETFD, 1); - } - (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); - return(hashp->fp != -1 ? 0 : -1); -} - -/* - We have to know that the key will fit, but the - last entry on the page is an overflow pair, so we - need to shift things. -*/ -static void -squeeze_key ( sp, key, val ) -u_short *sp; -DBT *key; -DBT *val; -{ - register char *p = (char *)sp; - u_short free_space, off; - u_short pageno, n; - - n = sp[0]; - free_space = FREESPACE(sp); - off = OFFSET(sp); - - pageno = sp[n-1]; - off -= key->size; - sp[n-1] = off; - bcopy ( key->data, p + off, key->size ); - off -= val->size; - sp[n] = off; - bcopy ( val->data, p + off, val->size ); - sp[0] = n+2; - sp[n+1] = pageno; - sp[n+2] = OVFLPAGE; - FREESPACE(sp) = free_space - PAIRSIZE(key,val); - OFFSET(sp) = off; -} - -static u_long * -fetch_bitmap ( ndx ) -int ndx; -{ - if ( ndx >= hashp->nmaps || - !(hashp->mapp[ndx] = (u_long *)malloc ( hashp->BSIZE )) || - __get_page ((char *)hashp->mapp[ndx], hashp->BITMAPS[ndx], 0, 1, 1)) { - - return(NULL); - } - return ( hashp->mapp[ndx] ); -} -#ifdef DEBUG4 -print_chain ( addr ) -short addr; -{ - BUFHEAD *bufp; - short *bp; - short oaddr; - - fprintf ( stderr, "%d ", addr ); - bufp = __get_buf ( (int)addr, NULL, 0 ); - bp = (short *)bufp->page; - while ( bp[0] && - ((bp[bp[0]] == OVFLPAGE) || - ((bp[0] > 2) && bp[2] < REAL_KEY))) { - oaddr = bp[bp[0]-1]; - fprintf ( stderr, "%d ", (int)oaddr ); - bufp = __get_buf ( (int)oaddr, bufp, 0 ); - bp = (short *)bufp->page; - } - fprintf ( stderr, "\n" ); -} -#endif diff --git a/lib/libc/gen/regexp/regmagic.h b/lib/libc/gen/regexp/regmagic.h deleted file mode 100644 index cebb828af11a..000000000000 --- a/lib/libc/gen/regexp/regmagic.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $Id: regmagic.h,v 1.2 1993/08/02 17:49:32 mycroft Exp $ */ - -/* - * The first byte of the regexp internal "program" is actually this magic - * number; the start node begins in the second byte. - */ -#define MAGIC 0234 diff --git a/lib/libc/gen/regexp/regsub.c b/lib/libc/gen/regexp/regsub.c deleted file mode 100644 index dff19c08d393..000000000000 --- a/lib/libc/gen/regexp/regsub.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * regsub - * - * Copyright (c) 1986 by University of Toronto. - * Written by Henry Spencer. Not derived from licensed software. - * - * Permission is granted to anyone to use this software for any - * purpose on any computer system, and to redistribute it freely, - * subject to the following restrictions: - * - * 1. The author is not responsible for the consequences of use of - * this software, no matter how awful, even if they arise - * from defects in it. - * - * 2. The origin of this software must not be misrepresented, either - * by explicit claim or by omission. - * - * 3. Altered versions must be plainly marked as such, and must not - * be misrepresented as being the original software. - */ - -#ifndef lint -static char *rcsid = "$Id: regsub.c,v 1.3 1993/08/26 00:45:37 jtc Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include "regmagic.h" - -#ifndef CHARBITS -#define UCHARAT(p) ((int)*(unsigned char *)(p)) -#else -#define UCHARAT(p) ((int)*(p)&CHARBITS) -#endif - -/* - - regsub - perform substitutions after a regexp match - */ -void -regsub(prog, source, dest) -const regexp *prog; -const char *source; -char *dest; -{ - register char *src; - register char *dst; - register char c; - register int no; - register int len; - extern char *strncpy(); - - if (prog == NULL || source == NULL || dest == NULL) { - regerror("NULL parm to regsub"); - return; - } - if (UCHARAT(prog->program) != MAGIC) { - regerror("damaged regexp fed to regsub"); - return; - } - - src = (char *)source; - dst = dest; - while ((c = *src++) != '\0') { - if (c == '&') - no = 0; - else if (c == '\\' && '0' <= *src && *src <= '9') - no = *src++ - '0'; - else - no = -1; - if (no < 0) { /* Ordinary character. */ - if (c == '\\' && (*src == '\\' || *src == '&')) - c = *src++; - *dst++ = c; - } else if (prog->startp[no] != NULL && prog->endp[no] != NULL) { - len = prog->endp[no] - prog->startp[no]; - (void) strncpy(dst, prog->startp[no], len); - dst += len; - if (len != 0 && *(dst-1) == '\0') { /* strncpy hit NUL. */ - regerror("damaged match string"); - return; - } - } - } - *dst++ = '\0'; -} diff --git a/lib/libc/gen/semget.c b/lib/libc/gen/semget.c deleted file mode 100644 index 743a77ad3f79..000000000000 --- a/lib/libc/gen/semget.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * $Id: semget.c,v 1.1 1993/11/14 12:40:33 cgd Exp $ - */ - -#include -#include -#include - -#if __STDC__ -int semget(key_t key, int nsems, int semflg) -#else -int semget(key, nsems, semflg) - key_t key; - int nsems; - int semflg; -#endif -{ - return (semsys(1, key, nsems, semflg)); -} diff --git a/lib/libc/gen/semop.c b/lib/libc/gen/semop.c deleted file mode 100644 index 2efaf5873a7f..000000000000 --- a/lib/libc/gen/semop.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * $Id: semop.c,v 1.1 1993/11/14 12:40:34 cgd Exp $ - */ - -#include -#include -#include - -#if __STDC__ -int semop(int semid, struct sembuf *sops, unsigned nsops) -#else -int semop(semid, sops, nsops) - int semid; - struct sembuf *sops; - unsigned nsops; -#endif -{ - return (semsys(2, semid, sops, nsops, 0)); -} diff --git a/lib/libc/gen/shmat.c b/lib/libc/gen/shmat.c deleted file mode 100644 index 1a425e2c7dc0..000000000000 --- a/lib/libc/gen/shmat.c +++ /dev/null @@ -1,19 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$Id: shmat.c,v 1.6 1994/05/29 00:35:59 hpeyerl Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#if __STDC__ -void *shmat(int shmid, void *shmaddr, int shmflg) -#else -void *shmat(shmid, shmaddr, shmflg) - int shmid; - void *shmaddr; - int shmflg; -#endif -{ - return ((void *) shmsys(0, shmid, shmaddr, shmflg)); -} diff --git a/lib/libc/gen/shmctl.c b/lib/libc/gen/shmctl.c deleted file mode 100644 index a5c3ce25e0e6..000000000000 --- a/lib/libc/gen/shmctl.c +++ /dev/null @@ -1,19 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$Id: shmctl.c,v 1.5 1994/05/29 00:36:01 hpeyerl Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#if __STDC__ -int shmctl(int shmid, int cmd, struct shmid_ds *buf) -#else -int shmctl(shmid, cmd, buf) - int shmid; - int cmd; - struct shmid_ds *buf; -#endif -{ - return (shmsys(1, shmid, cmd, buf)); -} diff --git a/lib/libc/gen/shmdt.c b/lib/libc/gen/shmdt.c deleted file mode 100644 index 7c12f844c52c..000000000000 --- a/lib/libc/gen/shmdt.c +++ /dev/null @@ -1,17 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$Id: shmdt.c,v 1.5 1994/05/29 00:36:06 hpeyerl Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#if __STDC__ -int shmdt(void *shmaddr) -#else -int shmdt(shmaddr) - void *shmaddr; -#endif -{ - return (shmsys(2, shmaddr)); -} diff --git a/lib/libc/gen/shmget.c b/lib/libc/gen/shmget.c deleted file mode 100644 index 7927a034ee1b..000000000000 --- a/lib/libc/gen/shmget.c +++ /dev/null @@ -1,19 +0,0 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$Id: shmget.c,v 1.4 1994/05/29 00:36:08 hpeyerl Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#if __STDC__ -int shmget(key_t key, int size, int shmflg) -#else -int shmget(key, size, shmflg) - key_t key; - int size; - int shmflg; -#endif -{ - return (shmsys(3, key, size, shmflg)); -} diff --git a/lib/libc/hp300/gen/cmpdf2.s b/lib/libc/hp300/gen/cmpdf2.s deleted file mode 100644 index 06dd510b9982..000000000000 --- a/lib/libc/hp300/gen/cmpdf2.s +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)cmpdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: cmpdf2.s,v 1.3 1993/08/26 02:11:58 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double > double: 1 */ -/* double < double: -1 */ -/* double == double: 0 */ -ENTRY(__cmpdf2) - fmoved sp@(4),fp0 - fcmpd sp@(12),fp0 - fbgt Lagtb - fslt d0 - extbl d0 - rts -Lagtb: - moveq #1,d0 - rts diff --git a/lib/libc/hp300/gen/cmpsf2.s b/lib/libc/hp300/gen/cmpsf2.s deleted file mode 100644 index c751b3d5aeab..000000000000 --- a/lib/libc/hp300/gen/cmpsf2.s +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)cmpsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: cmpsf2.s,v 1.3 1993/08/26 02:11:58 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single > single: 1 */ -/* single < single: -1 */ -/* single == single: 0 */ -ENTRY(__cmpsf2) - fmoves sp@(4),fp0 - fcmps sp@(8),fp0 - fbgt Lagtb - fslt d0 - extbl d0 - rts -Lagtb: - moveq #1,d0 - rts diff --git a/lib/libc/hp300/gen/divdf3.s b/lib/libc/hp300/gen/divdf3.s deleted file mode 100644 index b41936dea9b3..000000000000 --- a/lib/libc/hp300/gen/divdf3.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divdf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divdf3.s,v 1.3 1993/08/26 02:12:00 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double / double */ -ENTRY(__divdf3) - fmoved sp@(4),fp0 - fdivd sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/hp300/gen/divsf3.s b/lib/libc/hp300/gen/divsf3.s deleted file mode 100644 index 56477851ddb2..000000000000 --- a/lib/libc/hp300/gen/divsf3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divsf3.s,v 1.3 1993/08/26 02:12:01 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single / single */ -ENTRY(__divsf3) - fmoves sp@(4),fp0 - fdivs sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/hp300/gen/divsi3.s b/lib/libc/hp300/gen/divsi3.s deleted file mode 100644 index a4ef8784cb79..000000000000 --- a/lib/libc/hp300/gen/divsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)divsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: divsi3.s,v 1.3 1993/08/26 02:12:01 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int / int */ -ENTRY(__divsi3) - movel sp@(4),d0 - divsl sp@(8),d0 - rts diff --git a/lib/libc/hp300/gen/extendsfdf2.s b/lib/libc/hp300/gen/extendsfdf2.s deleted file mode 100644 index 0c822ad0e120..000000000000 --- a/lib/libc/hp300/gen/extendsfdf2.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)extendsfdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: extendsfdf2.s,v 1.3 1993/08/26 02:12:02 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (double) float */ -ENTRY(__extendsfdf2) - fmoves sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/hp300/gen/fabs.s b/lib/libc/hp300/gen/fabs.s deleted file mode 100644 index 33e83cc85011..000000000000 --- a/lib/libc/hp300/gen/fabs.s +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fabs.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: fabs.s,v 1.3 1993/08/26 02:12:03 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* fabs - floating absolute value */ - -#include "DEFS.h" - -ENTRY(fabs) - fmoved sp@(4),fp0 - fjnlt L1 - fnegx fp0 -L1: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/hp300/gen/fixdfsi.s b/lib/libc/hp300/gen/fixdfsi.s deleted file mode 100644 index baca42145fd2..000000000000 --- a/lib/libc/hp300/gen/fixdfsi.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fixdfsi.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: fixdfsi.s,v 1.3 1993/08/26 02:12:04 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (int) double */ -ENTRY(__fixdfsi) - fintrzd sp@(4),fp0 - fmovel fp0,d0 - rts diff --git a/lib/libc/hp300/gen/fixunsdfsi.s b/lib/libc/hp300/gen/fixunsdfsi.s deleted file mode 100644 index eaa789592020..000000000000 --- a/lib/libc/hp300/gen/fixunsdfsi.s +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)fixunsdfsi.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: fixunsdfsi.s,v 1.3 1993/08/26 02:12:05 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (unsigned) double */ -ENTRY(__fixunsdfsi) - fintrzd sp@(4),fp0 - fcmpd #0r2147483648.0,fp0 - fbge Lwaybig - fmovel fp0,d0 - rts -Lwaybig: - fsubd #0r2147483648.0,fp0 - fmovel fp0,d0 - bset #31,d0 - rts diff --git a/lib/libc/hp300/gen/floatsidf.s b/lib/libc/hp300/gen/floatsidf.s deleted file mode 100644 index 5e9f9f677d3c..000000000000 --- a/lib/libc/hp300/gen/floatsidf.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)floatsidf.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: floatsidf.s,v 1.3 1993/08/26 02:12:05 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (double) int */ -ENTRY(__floatsidf) - fmovel sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - diff --git a/lib/libc/hp300/gen/frexp.c b/lib/libc/hp300/gen/frexp.c deleted file mode 100644 index 60bf95da1087..000000000000 --- a/lib/libc/hp300/gen/frexp.c +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "from: @(#)frexp.c 5.1 (Berkeley) 3/6/91";*/ -static char rcsid[] = "$Id: frexp.c,v 1.2 1993/08/01 18:42:43 mycroft Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -double -frexp(value, eptr) - double value; - int *eptr; -{ - union { - double v; - struct { - u_int u_sign : 1; - u_int u_exp : 11; - u_int u_mant1 : 20; - u_int u_mant2 : 32; - } s; - } u; - - if (value) { - u.v = value; - *eptr = u.s.u_exp - 1022; - u.s.u_exp = 1022; - return(u.v); - } else { - *eptr = 0; - return((double)0); - } -} diff --git a/lib/libc/hp300/gen/infinity.c b/lib/libc/hp300/gen/infinity.c deleted file mode 100644 index e627272a8955..000000000000 --- a/lib/libc/hp300/gen/infinity.c +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef lint -static char rcsid[] = "$Id: infinity.c,v 1.1 1993/08/09 04:47:11 mycroft Exp $"; -#endif /* not lint */ - -/* infinity.c */ - -#include - -/* bytes for +Infinity on a 68k */ -char __infinity[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }; diff --git a/lib/libc/hp300/gen/isinf.c b/lib/libc/hp300/gen/isinf.c deleted file mode 100644 index 1fea64b300b1..000000000000 --- a/lib/libc/hp300/gen/isinf.c +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "from: @(#)isinf.c 5.1 (Berkeley) 3/18/91";*/ -static char rcsid[] = "$Id: isinf.c,v 1.2 1993/08/01 18:42:42 mycroft Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include - -isnan(d) - double d; -{ - register struct IEEEdp { - u_int sign : 1; - u_int exp : 11; - u_int manh : 20; - u_int manl : 32; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && (p->manh || p->manl)); -} - -isinf(d) - double d; -{ - register struct IEEEdp { - u_int sign : 1; - u_int exp : 11; - u_int manh : 20; - u_int manl : 32; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && !p->manh && !p->manl); -} diff --git a/lib/libc/hp300/gen/ldexp.s b/lib/libc/hp300/gen/ldexp.s deleted file mode 100644 index 15d443e61a6e..000000000000 --- a/lib/libc/hp300/gen/ldexp.s +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)ldexp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: ldexp.s,v 1.3 1993/08/26 02:12:06 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * double ldexp(val, exp) - * returns: val * (2**exp), for integer exp - */ -ENTRY(ldexp) - fmoved sp@(4),fp0 - fbeq Ldone - ftwotoxl sp@(12),fp1 - fmulx fp1,fp0 -Ldone: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/hp300/gen/lshlsi3.s b/lib/libc/hp300/gen/lshlsi3.s deleted file mode 100644 index 939ab4943608..000000000000 --- a/lib/libc/hp300/gen/lshlsi3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)lshlsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: lshlsi3.s,v 1.3 1993/08/26 02:12:07 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned << unsigned */ -ENTRY(__lshlsi3) - movel sp@(8),d1 - movel sp@(4),d0 - lsll d1,d0 - rts diff --git a/lib/libc/hp300/gen/lshrsi3.s b/lib/libc/hp300/gen/lshrsi3.s deleted file mode 100644 index 86662f525498..000000000000 --- a/lib/libc/hp300/gen/lshrsi3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)lshrsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: lshrsi3.s,v 1.3 1993/08/26 02:12:08 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned >> unsigned */ -ENTRY(__lshrsi3) - movel sp@(8),d1 - movel sp@(4),d0 - lsrl d1,d0 - rts diff --git a/lib/libc/hp300/gen/modf.s b/lib/libc/hp300/gen/modf.s deleted file mode 100644 index a26c591e9096..000000000000 --- a/lib/libc/hp300/gen/modf.s +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)modf.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: modf.s,v 1.3 1993/08/26 02:12:09 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * double modf(val, iptr) - * returns: xxx and n (in *iptr) where val == n.xxx - */ -ENTRY(modf) - fmoved sp@(4),fp0 - movel sp@(12),a0 - fintrzx fp0,fp1 - fmoved fp1,a0@ - fsubx fp1,fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/hp300/gen/modsi3.s b/lib/libc/hp300/gen/modsi3.s deleted file mode 100644 index 4d1adb8aa3bf..000000000000 --- a/lib/libc/hp300/gen/modsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)modsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: modsi3.s,v 1.3 1993/08/26 02:12:10 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int % int */ -ENTRY(__modsi3) - movel sp@(4),d1 - divsll sp@(8),d0:d1 - rts diff --git a/lib/libc/hp300/gen/muldf3.s b/lib/libc/hp300/gen/muldf3.s deleted file mode 100644 index de05af05a60e..000000000000 --- a/lib/libc/hp300/gen/muldf3.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)muldf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: muldf3.s,v 1.3 1993/08/26 02:12:11 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double * double */ -ENTRY(__muldf3) - fmoved sp@(4),fp0 - fmuld sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/hp300/gen/mulsf3.s b/lib/libc/hp300/gen/mulsf3.s deleted file mode 100644 index 78e41bbf48cd..000000000000 --- a/lib/libc/hp300/gen/mulsf3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)mulsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: mulsf3.s,v 1.3 1993/08/26 02:12:11 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single * single */ -ENTRY(__mulsf3) - fmoves sp@(4),fp0 - fmuls sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/hp300/gen/mulsi3.s b/lib/libc/hp300/gen/mulsi3.s deleted file mode 100644 index dae34dd66432..000000000000 --- a/lib/libc/hp300/gen/mulsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)mulsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: mulsi3.s,v 1.3 1993/08/26 02:12:12 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* int * int */ -ENTRY(__mulsi3) - movel sp@(4),d0 - mulsl sp@(8),d0 - rts diff --git a/lib/libc/hp300/gen/negdf2.s b/lib/libc/hp300/gen/negdf2.s deleted file mode 100644 index 36d381364446..000000000000 --- a/lib/libc/hp300/gen/negdf2.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)negdf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: negdf2.s,v 1.3 1993/08/26 02:12:13 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* -double */ -ENTRY(__negdf2) - movel sp@(4),d0 - movel sp@(8),d1 - bchg #31,d0 - rts diff --git a/lib/libc/hp300/gen/negsf2.s b/lib/libc/hp300/gen/negsf2.s deleted file mode 100644 index df7848a5a8ae..000000000000 --- a/lib/libc/hp300/gen/negsf2.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)negsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: negsf2.s,v 1.3 1993/08/26 02:12:14 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* -single */ -ENTRY(__negsf2) - movel sp@(4),d0 - bchg #31,d0 - rts diff --git a/lib/libc/hp300/gen/saveregs.c b/lib/libc/hp300/gen/saveregs.c deleted file mode 100644 index f22c6bac158f..000000000000 --- a/lib/libc/hp300/gen/saveregs.c +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "from: @(#)saveregs.c 5.2 (Berkeley) 6/22/90";*/ -static char rcsid[] = "$Id: saveregs.c,v 1.2 1993/08/01 18:42:22 mycroft Exp $"; -#endif /* LIBC_SCCS and not lint */ - -__builtin_saveregs() -{ - abort(); -} diff --git a/lib/libc/hp300/gen/setjmp.s b/lib/libc/hp300/gen/setjmp.s deleted file mode 100644 index b29854374d5e..000000000000 --- a/lib/libc/hp300/gen/setjmp.s +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)setjmp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: setjmp.s,v 1.3 1993/08/26 02:12:14 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#include "DEFS.h" - -ENTRY(setjmp) - subql #8,sp /* space for sigstack args/rvals */ - clrl sp@ /* don't change it... */ - movl sp,sp@(4) /* ...but return the current val */ - jsr _sigstack /* note: onstack returned in sp@(4) */ - clrl sp@ /* don't change mask, just return */ - jsr _sigblock /* old value */ - movl sp@(4),d1 /* old onstack value */ - addql #8,sp - movl sp@(4),a0 /* save area pointer */ - movl d1,a0@+ /* save old onstack value */ - movl d0,a0@+ /* save old signal mask */ - lea sp@(4),a1 /* adjust saved SP since we won't rts */ - movl a1,a0@+ /* save old SP */ - movl a6,a0@+ /* save old FP */ - clrl a0@+ /* no AP */ - movl sp@,a0@+ /* save old PC */ - clrl a0@+ /* clean PS */ - moveml #0x3CFC,a0@ /* save remaining non-scratch regs */ - clrl d0 /* return 0 */ - rts - -ENTRY(longjmp) - movl sp@(4),a0 /* save area pointer */ - tstl a0@(8) /* ensure non-zero SP */ - jeq botch /* oops! */ - movl sp@(8),d0 /* grab return value */ - jne ok /* non-zero ok */ - moveq #1,d0 /* else make non-zero */ -ok: - moveml a0@(28),#0x3CFC /* restore non-scratch regs */ - movl a0,sp@- /* let sigreturn */ - jsr _sigreturn /* finish for us */ - -botch: - jsr _longjmperror - stop #0 diff --git a/lib/libc/hp300/gen/subdf3.s b/lib/libc/hp300/gen/subdf3.s deleted file mode 100644 index 17283906e6d6..000000000000 --- a/lib/libc/hp300/gen/subdf3.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)subdf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: subdf3.s,v 1.3 1993/08/26 02:12:15 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* double - double */ -ENTRY(__subdf3) - fmoved sp@(4),fp0 - fsubd sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libc/hp300/gen/subsf3.s b/lib/libc/hp300/gen/subsf3.s deleted file mode 100644 index 9e75ea7f4966..000000000000 --- a/lib/libc/hp300/gen/subsf3.s +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)subsf3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: subsf3.s,v 1.3 1993/08/26 02:12:16 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* single - single */ -ENTRY(__subsf3) - fmoves sp@(4),fp0 - fsubs sp@(8),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/hp300/gen/truncdfsf2.s b/lib/libc/hp300/gen/truncdfsf2.s deleted file mode 100644 index 650372d049f1..000000000000 --- a/lib/libc/hp300/gen/truncdfsf2.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)truncdfsf2.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: truncdfsf2.s,v 1.3 1993/08/26 02:12:17 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* (float) double */ -ENTRY(__truncdfsf2) - fmoved sp@(4),fp0 - fmoves fp0,d0 - rts diff --git a/lib/libc/hp300/gen/udivsi3.s b/lib/libc/hp300/gen/udivsi3.s deleted file mode 100644 index a547667c9e75..000000000000 --- a/lib/libc/hp300/gen/udivsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)udivsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: udivsi3.s,v 1.3 1993/08/26 02:12:18 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned / unsigned */ -ENTRY(__udivsi3) - movel sp@(4),d0 - divul sp@(8),d0 - rts diff --git a/lib/libc/hp300/gen/umodsi3.s b/lib/libc/hp300/gen/umodsi3.s deleted file mode 100644 index 9bcae7313b8c..000000000000 --- a/lib/libc/hp300/gen/umodsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)umodsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: umodsi3.s,v 1.3 1993/08/26 02:12:18 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned % unsigned */ -ENTRY(__umodsi3) - movel sp@(4),d1 - divull sp@(8),d0:d1 - rts diff --git a/lib/libc/hp300/gen/umulsi3.s b/lib/libc/hp300/gen/umulsi3.s deleted file mode 100644 index 101ebbacdd2a..000000000000 --- a/lib/libc/hp300/gen/umulsi3.s +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)umulsi3.s 5.1 (Berkeley) 6/7/90"*/ - .asciz "$Id: umulsi3.s,v 1.3 1993/08/26 02:12:19 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* unsigned * unsigned */ -ENTRY(__umulsi3) - movel sp@(4),d0 - mulul sp@(8),d0 - rts diff --git a/lib/libc/hp300/string/strcpy.s b/lib/libc/hp300/string/strcpy.s deleted file mode 100644 index 6f17c6a2f76d..000000000000 --- a/lib/libc/hp300/string/strcpy.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strcpy.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strcpy.s,v 1.3 1993/08/26 02:12:54 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strcpy) - movl sp@(8),a0 /* a0 = fromaddr */ - movl sp@(4),d0 /* return value is toaddr */ - movl d0,a1 /* a1 = toaddr */ -scloop: - movb a0@+,a1@+ /* copy a byte */ - jne scloop /* copied non-null, keep going */ - rts diff --git a/lib/libc/hp300/string/strlen.s b/lib/libc/hp300/string/strlen.s deleted file mode 100644 index f53b4535bdde..000000000000 --- a/lib/libc/hp300/string/strlen.s +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strlen.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strlen.s,v 1.3 1993/08/26 02:12:54 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strlen) - moveq #-1,d0 - movl sp@(4),a0 /* string */ -slloop: - addql #1,d0 /* increment count */ - tstb a0@+ /* null? */ - jne slloop /* no, keep going */ - rts diff --git a/lib/libc/hp300/string/strncmp.s b/lib/libc/hp300/string/strncmp.s deleted file mode 100644 index 0aa6fb07a91b..000000000000 --- a/lib/libc/hp300/string/strncmp.s +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strncmp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strncmp.s,v 1.3 1993/08/26 02:12:55 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * NOTE: this guy returns result compatible with the VAX assembly version. - * The C version on the portable gen directory returns different results - * (different signs!) when comparing chars with the high bit on. Who is - * right?? - */ -ENTRY(strncmp) - movl sp@(12),d1 /* count */ - jeq scdone /* nothing to do */ - movl sp@(4),a0 /* a0 = string1 */ - movl sp@(8),a1 /* a1 = string2 */ -scloop: - movb a0@+,d0 /* get *string1 */ - cmpb a1@+,d0 /* compare a byte */ - jne scexit /* not equal, break out */ - tstb d0 /* at end of string1? */ - jeq scdone /* yes, all done */ - subql #1,d1 /* no, adjust count */ - jne scloop /* more to do, keep going */ -scdone: - moveq #0,d0 /* strings are equal */ - rts -scexit: - subb a1@-,d0 /* *string1 - *string2 */ - extbl d0 - rts diff --git a/lib/libc/hp300/string/strncpy.s b/lib/libc/hp300/string/strncpy.s deleted file mode 100644 index 994917afa017..000000000000 --- a/lib/libc/hp300/string/strncpy.s +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strncpy.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strncpy.s,v 1.3 1993/08/26 02:12:56 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strncpy) - movl sp@(4),d0 /* return value is toaddr */ - movl sp@(12),d1 /* count */ - jeq scdone /* nothing to do */ - movl sp@(8),a0 /* a0 = fromaddr */ - movl d0,a1 /* a1 = toaddr */ -scloop: - movb a0@+,a1@+ /* copy a byte */ - jeq scploop /* copied null, go pad if necessary */ - subql #1,d1 /* adjust count */ - jne scloop /* more room, keep going */ -scdone: - rts -scploop: - subql #1,d1 /* adjust count */ - jeq scdone /* no more room, all done */ - clrb a1@+ /* clear a byte */ - jra scploop /* keep going */ diff --git a/lib/libc/i386/gen/frexp.c b/lib/libc/i386/gen/frexp.c deleted file mode 100644 index b914dbb34c7f..000000000000 --- a/lib/libc/i386/gen/frexp.c +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "from: @(#)frexp.c 5.1 (Berkeley) 3/7/91";*/ -static char rcsid[] = "$Id: frexp.c,v 1.2 1993/08/01 18:40:50 mycroft Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -double -frexp(value, eptr) - double value; - int *eptr; -{ - union { - double v; - struct { - u_int u_mant2 : 32; - u_int u_mant1 : 20; - u_int u_exp : 11; - u_int u_sign : 1; - } s; - } u; - - if (value) { - u.v = value; - *eptr = u.s.u_exp - 1022; - u.s.u_exp = 1022; - return(u.v); - } else { - *eptr = 0; - return((double)0); - } -} diff --git a/lib/libc/i386/gen/infinity.c b/lib/libc/i386/gen/infinity.c deleted file mode 100644 index e99fc9985204..000000000000 --- a/lib/libc/i386/gen/infinity.c +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef lint -static char rcsid[] = "$Id: infinity.c,v 1.2 1993/08/02 17:49:36 mycroft Exp $"; -#endif /* not lint */ - -/* infinity.c */ - -#include - -/* bytes for +Infinity on a 387 */ -char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; diff --git a/lib/libc/i386/gen/isinf.c b/lib/libc/i386/gen/isinf.c deleted file mode 100644 index bf7b400cf80d..000000000000 --- a/lib/libc/i386/gen/isinf.c +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "from: @(#)isinf.c 5.1 (Berkeley) 3/18/91";*/ -static char rcsid[] = "$Id: isinf.c,v 1.2 1993/08/01 18:40:49 mycroft Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include - -isnan(d) - double d; -{ - register struct IEEEdp { - u_int manl : 32; - u_int manh : 20; - u_int exp : 11; - u_int sign : 1; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && (p->manh || p->manl)); -} - -isinf(d) - double d; -{ - register struct IEEEdp { - u_int manl : 32; - u_int manh : 20; - u_int exp : 11; - u_int sign : 1; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && !p->manh && !p->manl); -} diff --git a/lib/libc/i386/gen/ldexp.c b/lib/libc/i386/gen/ldexp.c deleted file mode 100644 index f0bc7d907ebf..000000000000 --- a/lib/libc/i386/gen/ldexp.c +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Charles Hannum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "from: @(#)ldexp.c 5.1 (Berkeley) 4/23/90";*/ -static char rcsid[] = "$Id: ldexp.c,v 1.3 1993/08/01 18:40:48 mycroft Exp $"; -#endif /* LIBC_SCCS and not lint */ - -/* - * ldexp(value, exp): return value * (2 ** exp). - */ - -double -ldexp (double value, int exp) -{ - double temp; -#if __GNUC__ >= 2 - asm ("fscale" - : "=t" (temp) - : "0" (value), "u" ((double)exp) - : "u"); -#else - asm ("fscale; fstp %%st(1)" - : "=f" (temp) - : "f" (value), "0" ((double)exp)); -#endif - return (temp); -} diff --git a/lib/libc/i386/gen/modf.s b/lib/libc/i386/gen/modf.s deleted file mode 100644 index 9bca79ccc8f5..000000000000 --- a/lib/libc/i386/gen/modf.s +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * 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, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)modf.s 5.5 (Berkeley) 3/18/91"*/ - .asciz "$Id: modf.s,v 1.5 1993/08/26 02:13:27 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * 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. */ -ENTRY(modf) - pushl %ebp - movl %esp,%ebp - subl $16,%esp - fnstcw -12(%ebp) - movw -12(%ebp),%dx - orw $3072,%dx - movw %dx,-16(%ebp) - fldcw -16(%ebp) - fldl 8(%ebp) - frndint - fstpl -8(%ebp) - fldcw -12(%ebp) - movl 16(%ebp),%eax - movl -8(%ebp),%edx - movl -4(%ebp),%ecx - movl %edx,(%eax) - movl %ecx,4(%eax) - fldl 8(%ebp) - fsubl -8(%ebp) - jmp L1 -L1: - leave - ret diff --git a/lib/libc/i386/gen/setjmp.s b/lib/libc/i386/gen/setjmp.s deleted file mode 100644 index 33d06a3e0b6c..000000000000 --- a/lib/libc/i386/gen/setjmp.s +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90"*/ - .asciz "$Id: setjmp.s,v 1.4 1993/09/28 21:04:39 pk Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -#include "DEFS.h" -#include "SYS.h" - -ENTRY(setjmp) - pushl $0 - call PIC_PLT(_sigblock) - popl %edx - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - movl %eax,24(%ecx) - movl $0,%eax - ret - -ENTRY(longjmp) - movl 4(%esp),%edx - pushl 24(%edx) - call PIC_PLT(_sigsetmask) - popl %eax - movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - cmpl $0,%eax - jne 1f - movl $1,%eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/i386/gen/udivsi3.s b/lib/libc/i386/gen/udivsi3.s deleted file mode 100644 index 790a2c03f9a9..000000000000 --- a/lib/libc/i386/gen/udivsi3.s +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)udivsi3.s 5.1 (Berkeley) 5/15/90"*/ - .asciz "$Id: udivsi3.s,v 1.3 1993/08/26 02:13:30 mycroft Exp $" -#endif /* LIBC_SCCS and not lint */ - - .globl ___udivsi3 -___udivsi3: - movl 4(%esp),%eax - xorl %edx,%edx - divl 8(%esp) - ret diff --git a/lib/libc/i386/string/memmove.s b/lib/libc/i386/string/memmove.s deleted file mode 100644 index 74dea159a744..000000000000 --- a/lib/libc/i386/string/memmove.s +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from locore.s. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id: memmove.s,v 1.10 1993/09/19 19:16:28 brezak Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: memmove.s,v 1.10 1993/09/19 19:16:28 brezak Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - - /* - * (ov)bcopy (src,dst,cnt) - * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 - */ - -TWOENTRY(memmove,memcpy) - pushl %esi - pushl %edi - movl 12(%esp),%edi - pushl %edi - movl 20(%esp),%esi - movl 24(%esp),%ecx - cmpl %esi,%edi /* potentially overlapping? */ - jnb 1f - cld /* nope, copy forwards. */ - shrl $2,%ecx /* copy by words */ - rep - movsl - movl 24(%esp),%ecx - andl $3,%ecx /* any bytes left? */ - rep - movsb - popl %eax - popl %edi - popl %esi - ret -1: - addl %ecx,%edi /* copy backwards. */ - addl %ecx,%esi - std - andl $3,%ecx /* any fractional bytes? */ - decl %edi - decl %esi - rep - movsb - movl 24(%esp),%ecx /* copy remainder by words */ - shrl $2,%ecx - subl $3,%esi - subl $3,%edi - rep - movsl - popl %eax - popl %edi - popl %esi - cld - ret diff --git a/lib/libc/i386/string/memset.s b/lib/libc/i386/string/memset.s deleted file mode 100644 index 5d4d255d4968..000000000000 --- a/lib/libc/i386/string/memset.s +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: memset.s,v 1.4 1993/08/26 02:13:53 mycroft Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: memset.s,v 1.4 1993/08/26 02:13:53 mycroft Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * memset(void *b, int c, size_t len) - * write len bytes of value c (converted to an unsigned char) to - * the string b. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(memset) - pushl %edi - pushl %ebx - movl 12(%esp),%edi - movzbl 16(%esp),%eax /* unsigned char, zero extend */ - movl 20(%esp),%ecx - pushl %edi /* push address of buffer */ - - cld /* set fill direction forward */ - - /* - * if the string is too short, it's really not worth the overhead - * of aligning to word boundries, etc. So we jump to a plain - * unaligned set. - */ - cmpl $0x0f,%ecx - jle L1 - - movl %eax,%edx /* copy value to all bytes in word */ - sall $8,%edx /* XXX is there a better way? */ - orl %edx,%eax - movl %eax,%edx - sall $16,%edx - orl %edx,%eax - - movl %edi,%edx /* compute misalignment */ - negl %edx - andl $3,%edx - movl %ecx,%ebx - subl %edx,%ebx - - movl %edx,%ecx /* set until word aligned */ - rep - stosb - - movl %ebx,%ecx - shrl $2,%ecx /* set by words */ - rep - stosl - - movl %ebx,%ecx /* set remainder by bytes */ - andl $3,%ecx -L1: rep - stosb - - popl %eax /* pop address of buffer */ - popl %ebx - popl %edi - ret diff --git a/lib/libc/i386/string/rindex.s b/lib/libc/i386/string/rindex.s deleted file mode 100644 index ac315d7200d3..000000000000 --- a/lib/libc/i386/string/rindex.s +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: rindex.s,v 1.5 1993/08/26 02:13:55 mycroft Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: rindex.s,v 1.5 1993/08/26 02:13:55 mycroft Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * rindex(s, c) - * return a pointer to the last occurance of the character c in - * string s, or NULL if c does not occur in the string. - * - * %edx - pointer iterating through string - * %eax - pointer to last occurance of 'c' - * %cl - character we're comparing against - * %bl - character at %edx - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(rindex) - pushl %ebx - movl 8(%esp),%edx - movb 12(%esp),%cl - xorl %eax,%eax /* init pointer to null */ - .align 2,0x90 -L1: - movb (%edx),%bl - cmpb %bl,%cl - jne L2 - movl %edx,%eax -L2: - incl %edx - testb %bl,%bl /* null terminator??? */ - jne L1 - popl %ebx - ret diff --git a/lib/libc/i386/string/strcat.s b/lib/libc/i386/string/strcat.s deleted file mode 100644 index 2752307c413a..000000000000 --- a/lib/libc/i386/string/strcat.s +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcat.s,v 1.6 1993/08/26 02:13:55 mycroft Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: strcat.s,v 1.6 1993/08/26 02:13:55 mycroft Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strcat(s, append) - * append a copy of the null-terminated string "append" to the end - * of the null-terminated string s, then add a terminating `\0'. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcat) - pushl %edi /* save edi */ - movl 8(%esp),%edi /* dst address */ - movl 12(%esp),%edx /* src address */ - pushl %edi /* push destination address */ - - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - - leal -1(%edi),%ecx /* correct dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - je L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - je L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - je L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - je L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - je L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - je L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - je L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jne L1 -L2: popl %eax /* pop destination address */ - popl %edi /* restore edi */ - ret diff --git a/lib/libc/i386/string/strchr.s b/lib/libc/i386/string/strchr.s deleted file mode 100644 index f3eab69b30e0..000000000000 --- a/lib/libc/i386/string/strchr.s +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strchr.s,v 1.5 1993/08/26 02:13:56 mycroft Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: strchr.s,v 1.5 1993/08/26 02:13:56 mycroft Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strchr(s, c) - * return a pointer to the first occurance of the character c in - * string s, or NULL if c does not occur in the string. - * - * %edx - pointer iterating through string - * %eax - pointer to first occurance of 'c' - * %cl - character we're comparing against - * %bl - character at %edx - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strchr) - pushl %ebx - movl 8(%esp),%eax - movb 12(%esp),%cl - .align 2,0x90 -L1: - movb (%eax),%bl - cmpb %bl,%cl /* found char??? */ - je L2 - incl %eax - testb %bl,%bl /* null terminator??? */ - jne L1 - xorl %eax,%eax -L2: - popl %ebx - ret diff --git a/lib/libc/i386/string/strcmp.s b/lib/libc/i386/string/strcmp.s deleted file mode 100644 index de7ba11d8d3d..000000000000 --- a/lib/libc/i386/string/strcmp.s +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcmp.s,v 1.5 1993/08/26 02:13:57 mycroft Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: strcmp.s,v 1.5 1993/08/26 02:13:57 mycroft Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strcmp(s1, s2) - * return an integer greater than, equal to, or less than 0, - * according as string s1 is greater than, equal to, or less - * than the string s2. - * - * %eax - pointer to s1 - * %edx - pointer to s2 - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcmp) - movl 0x04(%esp),%eax - movl 0x08(%esp),%edx - jmp L2 /* Jump into the loop! */ - - .align 2,0x90 -L1: incl %eax - incl %edx -L2: movb (%eax),%cl - cmpb $0,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - cmpb $0,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - cmpb $0,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - cmpb $0,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - cmpb $0,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - cmpb $0,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - cmpb $0,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - cmpb $0,%cl - je L3 - cmpb %cl,(%edx) - je L1 - .align 2, 0x90 -L3: movsbl (%eax),%eax /* unsigned comparison */ - movsbl (%edx),%edx - subl %edx,%eax - ret diff --git a/lib/libc/i386/string/strcpy.s b/lib/libc/i386/string/strcpy.s deleted file mode 100644 index 98361d493e69..000000000000 --- a/lib/libc/i386/string/strcpy.s +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcpy.s,v 1.5 1993/08/26 02:13:58 mycroft Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: strcpy.s,v 1.5 1993/08/26 02:13:58 mycroft Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strcpy (dst, src) - * copy the string src to dst. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcpy) - movl 4(%esp),%ecx /* dst address */ - movl 8(%esp),%edx /* src address */ - pushl %ecx /* push dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - je L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - je L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - je L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - je L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - je L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - je L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - je L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jne L1 -L2: popl %eax /* pop dst address */ - ret diff --git a/lib/libc/i386/string/strlen.s b/lib/libc/i386/string/strlen.s deleted file mode 100644 index 82ba98025c78..000000000000 --- a/lib/libc/i386/string/strlen.s +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strlen.s,v 1.5 1993/09/07 16:50:29 jtc Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: strlen.s,v 1.5 1993/09/07 16:50:29 jtc Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strlen (s) - * compute the length of the string s. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strlen) - pushl %edi - movl 8(%esp),%edi /* string address */ - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - notl %ecx /* get length by taking complement */ - leal -1(%ecx),%eax /* and subtracting one */ - popl %edi - ret diff --git a/lib/libc/i386/string/strncmp.s b/lib/libc/i386/string/strncmp.s deleted file mode 100644 index 7588948ac54b..000000000000 --- a/lib/libc/i386/string/strncmp.s +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strncmp.s,v 1.5 1993/08/26 02:14:00 mycroft Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: strncmp.s,v 1.5 1993/08/26 02:14:00 mycroft Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strncmp(s1, s2, n) - * return an integer greater than, equal to, or less than 0, - * according as the first n characters of string s1 is greater - * than, equal to, or less than the string s2. - * - * %eax - pointer to s1 - * %ecx - pointer to s2 - * %edx - length - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strncmp) - pushl %ebx - movl 8(%esp),%eax - movl 12(%esp),%ecx - movl 16(%esp),%edx - jmp L2 /* Jump into the loop! */ - - .align 2,0x90 -L1: incl %eax - incl %ecx - decl %edx -L2: testl %edx,%edx /* Have we compared n chars yet? */ - jle L4 /* Yes, strings are equal */ - movb (%eax),%bl - cmpb $0,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - cmpb $0,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - cmpb $0,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - cmpb $0,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - cmpb $0,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - cmpb $0,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - cmpb $0,%bl - je L3 - cmpb %bl,(%ecx) - jne L3 - incl %eax - incl %ecx - decl %edx - testl %edx,%edx - jle L4 - movb (%eax),%bl - cmpb $0,%bl - je L3 - cmpb %bl,(%ecx) - je L1 - .align 2,0x90 -L3: movsbl (%eax),%eax /* unsigned comparision */ - movsbl (%ecx),%ecx - subl %ecx,%eax - popl %ebx - ret - .align 2,0x90 -L4: xorl %eax,%eax - popl %ebx - ret diff --git a/lib/libc/i386/string/strrchr.s b/lib/libc/i386/string/strrchr.s deleted file mode 100644 index 7bf97ee46ecd..000000000000 --- a/lib/libc/i386/string/strrchr.s +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strrchr.s,v 1.5 1993/08/26 02:14:01 mycroft Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: strrchr.s,v 1.5 1993/08/26 02:14:01 mycroft Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * strrchr(s, c) - * return a pointer to the last occurance of the character c in - * string s, or NULL if c does not occur in the string. - * - * %edx - pointer iterating through string - * %eax - pointer to last occurance of 'c' - * %cl - character we're comparing against - * %bl - character at %edx - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strrchr) - pushl %ebx - movl 8(%esp),%edx - movb 12(%esp),%cl - xorl %eax,%eax /* init pointer to null */ - .align 2,0x90 -L1: - movb (%edx),%bl - cmpb %bl,%cl - jne L2 - movl %edx,%eax -L2: - incl %edx - testb %bl,%bl /* null terminator??? */ - jne L1 - popl %ebx - ret diff --git a/lib/libc/i386/string/swab.s b/lib/libc/i386/string/swab.s deleted file mode 100644 index abaea87366de..000000000000 --- a/lib/libc/i386/string/swab.s +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: swab.s,v 1.1 1993/10/05 18:35:10 jtc Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: swab.s,v 1.1 1993/10/05 18:35:10 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * void - * swab (const void *src, void *dst, size_t len) - * copy len bytes from src to dst, swapping adjacent bytes - * - * On the i486, this code is negligibly faster than the code generated - * by gcc at about half the size. If my i386 databook is correct, it - * should be considerably faster than the gcc code on a i386. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(swab) - pushl %esi - pushl %edi - movl 12(%esp),%esi - movl 16(%esp),%edi - movl 20(%esp),%ecx - shrl $1,%ecx - jz L4 # len = 0, jmp to func exit - - cld # set direction forward - - testl $7,%ecx # copy first group of 1 to 7 words - je L2 # while swaping alternate bytes. - .align 2,0x90 -L1: lodsw - xchgb %al,%ah - stosw - decl %ecx - testl $7,%ecx - jne L1 - -L2: shrl $3,%ecx # copy remainder 8 words at a time - jz L4 # while swapping alternate bytes. - .align 2,0x90 -L3: lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - lodsw - xchgb %al,%ah - stosw - decl %ecx - jnz L3 - -L4: - popl %edi - popl %esi - ret diff --git a/lib/libc/i386/sys/reboot.s b/lib/libc/i386/sys/reboot.s deleted file mode 100644 index 447933595fd1..000000000000 --- a/lib/libc/i386/sys/reboot.s +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)reboot.s 5.1 (Berkeley) 4/23/90"*/ - .asciz "$Id: reboot.s,v 1.3 1993/08/26 02:14:17 mycroft Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - iret diff --git a/lib/libc/i386/sys/sbrk.s b/lib/libc/i386/sys/sbrk.s deleted file mode 100644 index dbd6c72abe14..000000000000 --- a/lib/libc/i386/sys/sbrk.s +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sbrk.s 5.1 (Berkeley) 4/23/90"*/ - .asciz "$Id: sbrk.s,v 1.4 1993/09/28 21:04:56 pk Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#define SYS_brk 17 - - .globl _end - .globl minbrk - .globl curbrk - - .data -minbrk: .long _end -curbrk: .long _end - .text - -ENTRY(sbrk) -#ifdef PIC - movl 4(%esp),%ecx - PIC_PROLOGUE - movl PIC_GOT(curbrk),%edx - movl (%edx),%eax - PIC_EPILOGUE - addl %eax,4(%esp) - lea SYS_brk,%eax - LCALL(7,0) - jb err - PIC_PROLOGUE - movl PIC_GOT(curbrk),%edx - movl (%edx),%eax - addl %ecx,(%edx) - PIC_EPILOGUE - ret -err: - jmp PIC_PLT(cerror) - -#else - - movl 4(%esp),%ecx - movl curbrk,%eax - addl %eax,4(%esp) - lea SYS_brk,%eax - LCALL(7,0) - jb err - movl curbrk,%eax - addl %ecx,curbrk - ret -err: - jmp cerror -#endif diff --git a/lib/libc/i386/sys/setlogin.s b/lib/libc/i386/sys/setlogin.s deleted file mode 100644 index 2839c1eb9989..000000000000 --- a/lib/libc/i386/sys/setlogin.s +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)setlogin.s 5.2 (Berkeley) 4/12/91"*/ - .asciz "$Id: setlogin.s,v 1.4 1993/09/28 21:04:57 pk Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -.globl __logname_valid /* in getlogin() */ - -SYSCALL(setlogin) -#ifdef PIC - PIC_PROLOGUE - pushl %eax - movl PIC_GOT(__logname_valid),%eax - movl $0,(%eax) - popl %eax - PIC_EPILOGUE -#else - movl $0,__logname_valid -#endif - ret /* setlogin(name) */ diff --git a/lib/libc/i386/sys/sigpending.s b/lib/libc/i386/sys/sigpending.s deleted file mode 100644 index 1ee96c7dccd0..000000000000 --- a/lib/libc/i386/sys/sigpending.s +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigpending.s 5.1 (Berkeley) 7/1/90"*/ - .asciz "$Id: sigpending.s,v 1.3 1993/08/26 02:14:20 mycroft Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(sigpending) - movl 4(%esp),%ecx # fetch pointer to... - movl %eax,(%ecx) # store old mask - xorl %eax,%eax - ret diff --git a/lib/libc/i386/sys/sigprocmask.s b/lib/libc/i386/sys/sigprocmask.s deleted file mode 100644 index 6c6919cc083c..000000000000 --- a/lib/libc/i386/sys/sigprocmask.s +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigprocmask.s 5.2 (Berkeley) 12/17/90"*/ - .asciz "$Id: sigprocmask.s,v 1.5 1993/08/26 02:14:20 mycroft Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -err: - jmp cerror - -ENTRY(sigprocmask) - movl 8(%esp),%ecx # fetch new sigset pointer - cmpl $0,%ecx # check new sigset pointer - jne 1f # if not null, indirect -/* movl $0,8(%esp) # null mask pointer: block empty set */ - movl $1,4(%esp) # SIG_BLOCK - jmp 2f -1: movl (%ecx),%ecx # fetch indirect ... - movl %ecx,8(%esp) # to new mask arg -2: movl $/**/SYS_sigprocmask , %eax - LCALL(0x7,0) - jb err - movl 12(%esp),%ecx # fetch old mask requested - cmpl $0,%ecx # test if old mask requested - je out - movl %eax,(%ecx) # store old mask -out: - xorl %eax,%eax - ret diff --git a/lib/libc/i386/sys/sigreturn.s b/lib/libc/i386/sys/sigreturn.s deleted file mode 100644 index e2d50d70ac78..000000000000 --- a/lib/libc/i386/sys/sigreturn.s +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90"*/ - .asciz "$Id: sigreturn.s,v 1.3 1993/08/26 02:14:21 mycroft Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef PROF -#undef ENTRY -#define ENTRY(x) \ - .globl _/**/x; .align 2; _/**/x: pusha ; \ - .data; 1:; .long 0; .text; movl $1b,%eax; call mcount; popa ; nop -#endif /* PROF */ - -SYSCALL(sigreturn) - ret diff --git a/lib/libc/i386/sys/sigsuspend.s b/lib/libc/i386/sys/sigsuspend.s deleted file mode 100644 index 5c384ecad0fc..000000000000 --- a/lib/libc/i386/sys/sigsuspend.s +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)sigsuspend.s 5.2 (Berkeley) 12/17/90"*/ - .asciz "$Id: sigsuspend.s,v 1.5 1993/08/26 02:14:22 mycroft Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -err: - jmp cerror - -ENTRY(sigsuspend) - movl 4(%esp),%eax # fetch mask arg - movl (%eax),%eax # indirect to mask arg - movl %eax,4(%esp) - movl $/**/SYS_sigsuspend ,%eax - LCALL(0x7,0) - jb err - xorl %eax,%eax # shouldn t happen - ret diff --git a/lib/libc/i386/sys/syscall.s b/lib/libc/i386/sys/syscall.s deleted file mode 100644 index 8e5bec0242a7..000000000000 --- a/lib/libc/i386/sys/syscall.s +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(SYSLIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)syscall.s 5.1 (Berkeley) 4/23/90"*/ - .asciz "$Id: syscall.s,v 1.4 1993/08/26 02:14:23 mycroft Exp $" -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(syscall) - pop %ecx /* rta */ - pop %eax /* syscall number */ - push %ecx - LCALL(7,0) - push %ecx /* Keep stack frame consistant */ - jb 1f - ret -1: - jmp cerror diff --git a/lib/libc/pc532/gen/ldexp.s b/lib/libc/pc532/gen/ldexp.s deleted file mode 100644 index 79fbae29285d..000000000000 --- a/lib/libc/pc532/gen/ldexp.s +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Tero Kivinen (kivinen) at Helsinki University of Technology - * Created. - * - * $Id: ldexp.s,v 1.1.1.1 1993/09/17 18:43:47 phil Exp $ - */ - -/* - * double ldexp (value, exp) - * double value; - * int exp; - * - * Ldexp returns value*2**exp, if that result is in range. - * If underflow occurs, it returns zero. If overflow occurs, - * it returns a value of appropriate sign and largest - * possible magnitude. In case of either overflow or underflow, - * errno is set to ERANGE. Note that errno is not modified if - * no error occurs. - */ - -#include - -#define ERANGE 34 - - .globl EX(errno) - -ENTRY(ldexp) - enter [],8 - movd 12(fp),r1 /* get value, high 32 bit */ - lshd -20,r1 /* extract exponent */ - andd 0x7ff,r1 /* 11 lower bits */ - subd 1023,r1 /* unbias exponent */ - movd 16(fp),r0 /* get exp */ - addd r1,r0 /* add exponents */ - cmpd r0,1023 /* most positive exponent */ - bgt ldexp_overflow /* too large */ - cmpd r0,-1022 /* most negative exponent */ - blt ldexp_underflow /* too small */ - addd 1023,r0 /* bias exponent */ - lshd 20,r0 /* convert exponent back to its place */ - movd 12(fp),r1 /* get value high 32 bit */ - bicd 0x7ff00000,r1 /* clear exponent */ - ord r0,r1 /* insert exponent */ - movd r1,-4(fp) /* put high 32 bit to local variable */ - movd 8(fp),-8(fp) /* value low 32 bit to local variable */ - movl -8(fp),f0 /* return value * 2**exp */ - exit [] - ret 0 /* neither */ -ldexp_underflow: - movdl 0d0e0,f0 /* if underflow return 0, set errno */ - movd ERANGE,@EX(errno) - exit [] - ret 0 -ldexp_overflow: - movl @huge,f0 /* if overflow return HUGE */ - movdl 0d0e0,f2 - cmpl f2,8(fp) /* check original sign */ - bgt ldexp_positive - negl f0,f0 /* if negative, return -HUGE */ -ldexp_positive: - movd ERANGE,@EX(errno) /* set errno */ - exit [] - ret 0 - -huge: .long 0xffffffff /* the largest number that can */ - .long 0x7fefffff /* be represented in a long floating */ - /* number. This is given in hex in order */ - /* to avoid floating conversions */ diff --git a/lib/libc/pc532/gen/modf.s b/lib/libc/pc532/gen/modf.s deleted file mode 100644 index 097b2e75e2e8..000000000000 --- a/lib/libc/pc532/gen/modf.s +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Tero Kivinen (kivinen) at Helsinki University of Technology - * Created. - * - * $Id: modf.s,v 1.1.1.1 1993/09/17 18:43:47 phil Exp $ - */ - -/* - * double modf (value, iptr) - * double value, *iptr; - * - * Modf returns the fractional part of "value", - * and stores the integer part indirectly through "iptr". - */ - -#include - -ENTRY(modf) - FRAME - movl 8(fp),f0 /* value */ - movd 12(fp),r0 /* higher 32 bit of value */ - lshd -20,r0 /* extract exponent */ - andd 0x7ff,r0 /* 11 lower bits */ - cmpd r0,1023+30 /* compare if it's int part can fit in int */ - bgt modf_overflow /* nope else it's ok to truncld it to int*/ - truncld f0,r0 /* get integer part */ - movdl r0,f2 /* convert back to float */ - movl f2,0(16(fp)) /* move integer part to *iptr */ - subl f2,f0 /* return fract. part = value - *iptr */ - EMARF - ret 0 -modf_overflow: - subd 1023+20,r0 /* bias 1023, and upper part of - floating point mantissa part */ - movqd -1,r2 /* generate mask to get fract. part */ - cmpd r0,32 /* if value > 2^52 (20+32) then all int part */ - bhi modf_all_ip - negd r0,r0 /* shift right */ - lshd r0,r2 /* here */ - comd r2,r2 /* get fractional part complement mask */ - movd 8(fp),r1 /* get lower 32 bit of value */ - andd r2,r1 /* mask fractional part off leave ip part */ - movd r1,0(16(fp)) /* store ip part to *iptr */ - movd 12(fp),4(16(fp)) /* store other half to *iptr */ - subl 0(16(fp)),f0 /* return fract. part = value - *iptr */ - EMARF - ret 0 -modf_all_ip: - movl 8(fp),0(16(fp)) /* copy value to *iptr */ - movdl 0,f0 /* return 0 for fract. part */ - EMARF - ret 0 diff --git a/lib/libc/pc532/gen/setjmp.s b/lib/libc/pc532/gen/setjmp.s deleted file mode 100644 index 235c98f5eb45..000000000000 --- a/lib/libc/pc532/gen/setjmp.s +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: setjmp.s,v 1.1.1.1 1993/09/17 18:43:47 phil Exp $ - */ - -#include -#include - -ENTRY(setjmp) - movqd 0, tos - bsr EX(sigblock) - adjspb -4 - movd 4(sp), r2 /* jmp_buf */ - movd 0(sp), JMP_BUF_PC(r2) /* pc of caller */ - movd r0, JMP_BUF_SIGMASK(r2) /* save mask */ - - sprd sp, JMP_BUF_SP(r2) - sprd fp, JMP_BUF_FP(r2) - sprd sb, JMP_BUF_SB(r2) - movd r3, JMP_BUF_R3(r2) /* save registers r3-r7 */ - movd r4, JMP_BUF_R4(r2) - movd r5, JMP_BUF_R5(r2) - movd r6, JMP_BUF_R6(r2) - movd r7, JMP_BUF_R7(r2) - - movqd 0, r0 - ret 0 - -ENTRY(longjmp) - movd 4(sp),r2 /* jmp_buf */ - movd JMP_BUF_SIGMASK(r2), tos /* restore mask */ - bsr EX(sigsetmask) - adjspb -4 - movd 4(sp), r2 /* jmp_buf */ - movd 8(sp), r0 /* value */ - - lprd sp, JMP_BUF_SP(r2) - lprd fp, JMP_BUF_FP(r2) - lprd sb, JMP_BUF_SB(r2) - movd JMP_BUF_R3(r2), r3 /* load registers r3-r7 */ - movd JMP_BUF_R4(r2), r4 - movd JMP_BUF_R5(r2), r5 - movd JMP_BUF_R6(r2), r6 - movd JMP_BUF_R7(r2), r7 - movd JMP_BUF_PC(r2), 0(sp) /* patch return pc */ - - cmpqd 0, r0 - bne nonzero - movqd 1, r0 -nonzero: - ret 0 - diff --git a/lib/libc/pc532/sys/reboot.s b/lib/libc/pc532/sys/reboot.s deleted file mode 100644 index 13c5868caf60..000000000000 --- a/lib/libc/pc532/sys/reboot.s +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ - -/* This is a modified copy of mount.s. Phil Nelson - * - * $Id: reboot.s,v 1.1.1.1 1993/09/17 18:43:51 phil Exp $ - */ - -#include -#include "SYS.h" - -SYSCALL(reboot) - dia - diff --git a/lib/libc/pc532/sys/sbrk.s b/lib/libc/pc532/sys/sbrk.s deleted file mode 100644 index da7468cb5eb5..000000000000 --- a/lib/libc/pc532/sys/sbrk.s +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sbrk.s,v 1.1.1.1 1993/09/17 18:43:50 phil Exp $ - */ - -#include -#include "SYS.h" - - .globl _end - .globl _curbrk - .globl _minbrk - - .data -_curbrk: .long _end -_minbrk: .long _end - .text - -ENTRY(sbrk) - addd _curbrk(pc), S_ARG0 - movd SYS_break,r0 - SVC - bcs cerror - movd _curbrk(pc), r0 - movd S_ARG0,_curbrk(pc) /* XXX check this b*/ - ret 0 diff --git a/lib/libc/pc532/sys/setlogin.s b/lib/libc/pc532/sys/setlogin.s deleted file mode 100644 index fdfc8735f4e4..000000000000 --- a/lib/libc/pc532/sys/setlogin.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: setlogin.s,v 1.1.1.1 1993/09/17 18:43:49 phil Exp $ - */ - -#include -#include "SYS.h" - -.globl EX(_logname_valid) /* in getlogin() */ - -SYSCALL(setlogin) - movqd 0, EX(_logname_valid) - ret 0 /* setlogin(name) */ diff --git a/lib/libc/pc532/sys/sigpending.s b/lib/libc/pc532/sys/sigpending.s deleted file mode 100644 index 200a21b3f3e0..000000000000 --- a/lib/libc/pc532/sys/sigpending.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigpending.s,v 1.1.1.1 1993/09/17 18:43:49 phil Exp $ - */ - -#include -#include "SYS.h" - -SYSCALL(sigpending) - movd S_ARG1, r1 /* fetch pointer to... */ - movd r0, 0(r1) /* store old mask */ - movqd 0, r0 - ret 0 diff --git a/lib/libc/pc532/sys/sigprocmask.s b/lib/libc/pc532/sys/sigprocmask.s deleted file mode 100644 index 88995cd630bd..000000000000 --- a/lib/libc/pc532/sys/sigprocmask.s +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigprocmask.s,v 1.1.1.1 1993/09/17 18:43:51 phil Exp $ - */ - -/* - * Note: Has never been tested. Debug before use. - */ - - -#include -#include "SYS.h" - -ENTRY(sigprocmask) - movd S_ARG1, r1 /* fetch new sigset pointer */ - cmpqd 0, r1 /* check new sigset pointer */ - bne L1 /* if not null, indirect */ -/* movqd 0, S_ARG1 /* null mask pointer: block empty set */ - movqd 1, S_ARG0 /* SIG_BLOCK */ - br L2 -L1: movd 0(r1), r1 /* fetch indirect ... */ - movd r1, S_ARG1 /* to new mask arg */ -L2: movd SYS_sigprocmask, r0 - SVC - bcs cerror - movd S_ARG2, r1 /* fetch old mask requested */ - cmpqd 0, r1 /* test if old mask requested */ - beq out - movd r0, 0(r1) /* store old mask */ -out: - movqd 0, r0 - ret 0 diff --git a/lib/libc/pc532/sys/sigreturn.s b/lib/libc/pc532/sys/sigreturn.s deleted file mode 100644 index a9c299c7ca63..000000000000 --- a/lib/libc/pc532/sys/sigreturn.s +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigreturn.s,v 1.1.1.1 1993/09/17 18:43:51 phil Exp $ - */ - -#include -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef PROF -#undef ENTRY -#define ENTRY(x) \ - .globl EX(x); .align ALIGN; EX(x): save [r0,r1,r2]; \ - .data; LB(sigr,1):; .long 0; .text; addr @LBb(sigr,1),r1; bsr mcount; restore [r0,r1,r2] -#endif PROF - -SYSCALL(sigreturn) - ret 0 diff --git a/lib/libc/pc532/sys/sigsuspend.s b/lib/libc/pc532/sys/sigsuspend.s deleted file mode 100644 index 2192f3931708..000000000000 --- a/lib/libc/pc532/sys/sigsuspend.s +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: sigsuspend.s,v 1.1.1.1 1993/09/17 18:43:51 phil Exp $ - */ - -#include -#include "SYS.h" - -ENTRY(sigsuspend) - movd S_ARG0, r0 /* fetch mask arg */ - movd 0(r0), r0 /* indirect to mask arg */ - movd r0, S_ARG0 - movd SYS_sigsuspend, r0 - SVC - bcs cerror - movqd 0, r0 /* shouldn t happen */ - ret 0 diff --git a/lib/libc/pc532/sys/syscall.s b/lib/libc/pc532/sys/syscall.s deleted file mode 100644 index 8b6e4f8eaaad..000000000000 --- a/lib/libc/pc532/sys/syscall.s +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: syscall.s,v 1.1.1.1 1993/09/17 18:43:51 phil Exp $ - */ - -#include -#include "SYS.h" - -ENTRY(syscall) - movqd 0, r0 /* Tell system this is syscall! */ - SVC - bcs cerror - ret 0 diff --git a/lib/libc/regex/regcomp.ih b/lib/libc/regex/regcomp.ih deleted file mode 100644 index fe74ba61e22c..000000000000 --- a/lib/libc/regex/regcomp.ih +++ /dev/null @@ -1,51 +0,0 @@ -/* ========= begin header generated by ./mkh ========= */ -#ifdef __cplusplus -extern "C" { -#endif - -/* === regcomp.c === */ -static void p_ere __P((register struct parse *p, int stop)); -static void p_ere_exp __P((register struct parse *p)); -static void p_str __P((register struct parse *p)); -static void p_bre __P((register struct parse *p, register int end1, register int end2)); -static int p_simp_re __P((register struct parse *p, int starordinary)); -static int p_count __P((register struct parse *p)); -static void p_bracket __P((register struct parse *p)); -static void p_b_term __P((register struct parse *p, register cset *cs)); -static void p_b_cclass __P((register struct parse *p, register cset *cs)); -static void p_b_eclass __P((register struct parse *p, register cset *cs)); -static char p_b_symbol __P((register struct parse *p)); -static char p_b_coll_elem __P((register struct parse *p, int endc)); -static char othercase __P((int ch)); -static void bothcases __P((register struct parse *p, int ch)); -static void ordinary __P((register struct parse *p, register int ch)); -static void nonnewline __P((register struct parse *p)); -static void repeat __P((register struct parse *p, sopno start, int from, int to)); -static int seterr __P((register struct parse *p, int e)); -static cset *allocset __P((register struct parse *p)); -static void freeset __P((register struct parse *p, register cset *cs)); -static int freezeset __P((register struct parse *p, register cset *cs)); -static int firstch __P((register struct parse *p, register cset *cs)); -static int nch __P((register struct parse *p, register cset *cs)); -static void mcadd __P((register struct parse *p, register cset *cs, register char *cp)); -static void mcsub __P((register cset *cs, register char *cp)); -static int mcin __P((register cset *cs, register char *cp)); -static char *mcfind __P((register cset *cs, register char *cp)); -static void mcinvert __P((register struct parse *p, register cset *cs)); -static void mccase __P((register struct parse *p, register cset *cs)); -static int isinsets __P((register struct re_guts *g, int c)); -static int samesets __P((register struct re_guts *g, int c1, int c2)); -static void categorize __P((struct parse *p, register struct re_guts *g)); -static sopno dupl __P((register struct parse *p, sopno start, sopno finish)); -static void doemit __P((register struct parse *p, sop op, size_t opnd)); -static void doinsert __P((register struct parse *p, sop op, size_t opnd, sopno pos)); -static void dofwd __P((register struct parse *p, sopno pos, sop value)); -static void enlarge __P((register struct parse *p, sopno size)); -static void stripsnug __P((register struct parse *p, register struct re_guts *g)); -static void findmust __P((register struct parse *p, register struct re_guts *g)); -static sopno pluscount __P((register struct parse *p, register struct re_guts *g)); - -#ifdef __cplusplus -} -#endif -/* ========= end header generated by ./mkh ========= */ diff --git a/lib/libc/regex/regerror.ih b/lib/libc/regex/regerror.ih deleted file mode 100644 index 1e89809d7aa8..000000000000 --- a/lib/libc/regex/regerror.ih +++ /dev/null @@ -1,12 +0,0 @@ -/* ========= begin header generated by ./mkh ========= */ -#ifdef __cplusplus -extern "C" { -#endif - -/* === regerror.c === */ -static char *regatoi __P((const regex_t *preg, char *localbuf)); - -#ifdef __cplusplus -} -#endif -/* ========= end header generated by ./mkh ========= */ diff --git a/lib/libc/regex/regex.h b/lib/libc/regex/regex.h deleted file mode 100644 index 79b1adc582fe..000000000000 --- a/lib/libc/regex/regex.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _REGEX_H_ -#define _REGEX_H_ /* never again */ -/* ========= begin header generated by ./mkh ========= */ -#ifdef __cplusplus -extern "C" { -#endif - -/* === regex2.h === */ -typedef off_t regoff_t; -typedef struct { - int re_magic; - size_t re_nsub; /* number of parenthesized subexpressions */ - const char *re_endp; /* end pointer for REG_PEND */ - struct re_guts *re_g; /* none of your business :-) */ -} regex_t; -typedef struct { - regoff_t rm_so; /* start of match */ - regoff_t rm_eo; /* end of match */ -} regmatch_t; - - -/* === regcomp.c === */ -extern int regcomp __P((regex_t *, const char *, int)); -#define REG_BASIC 0000 -#define REG_EXTENDED 0001 -#define REG_ICASE 0002 -#define REG_NOSUB 0004 -#define REG_NEWLINE 0010 -#define REG_NOSPEC 0020 -#define REG_PEND 0040 -#define REG_DUMP 0200 - - -/* === regerror.c === */ -#define REG_NOMATCH 1 -#define REG_BADPAT 2 -#define REG_ECOLLATE 3 -#define REG_ECTYPE 4 -#define REG_EESCAPE 5 -#define REG_ESUBREG 6 -#define REG_EBRACK 7 -#define REG_EPAREN 8 -#define REG_EBRACE 9 -#define REG_BADBR 10 -#define REG_ERANGE 11 -#define REG_ESPACE 12 -#define REG_BADRPT 13 -#define REG_EMPTY 14 -#define REG_ASSERT 15 -#define REG_INVARG 16 -#define REG_ATOI 255 /* convert name to number (!) */ -#define REG_ITOA 0400 /* convert number to name (!) */ -extern size_t regerror __P((int, const regex_t *, char *, size_t)); - - -/* === regexec.c === */ -extern int regexec __P((const regex_t *, const char *, size_t, regmatch_t [], int)); -#define REG_NOTBOL 00001 -#define REG_NOTEOL 00002 -#define REG_STARTEND 00004 -#define REG_TRACE 00400 /* tracing of execution */ -#define REG_LARGE 01000 /* force large representation */ -#define REG_BACKR 02000 /* force use of backref code */ - - -/* === regfree.c === */ -extern void regfree __P((regex_t *)); - -#ifdef __cplusplus -} -#endif -/* ========= end header generated by ./mkh ========= */ -#endif diff --git a/lib/libc/regex/split.c b/lib/libc/regex/split.c deleted file mode 100644 index 188bdb775b9f..000000000000 --- a/lib/libc/regex/split.c +++ /dev/null @@ -1,316 +0,0 @@ -#include -#include - -/* - - split - divide a string into fields, like awk split() - = int split(char *string, char *fields[], int nfields, char *sep); - */ -int /* number of fields, including overflow */ -split(string, fields, nfields, sep) -char *string; -char *fields[]; /* list is not NULL-terminated */ -int nfields; /* number of entries available in fields[] */ -char *sep; /* "" white, "c" single char, "ab" [ab]+ */ -{ - register char *p = string; - register char c; /* latest character */ - register char sepc = sep[0]; - register char sepc2; - register int fn; - register char **fp = fields; - register char *sepp; - register int trimtrail; - - /* white space */ - if (sepc == '\0') { - while ((c = *p++) == ' ' || c == '\t') - continue; - p--; - trimtrail = 1; - sep = " \t"; /* note, code below knows this is 2 long */ - sepc = ' '; - } else - trimtrail = 0; - sepc2 = sep[1]; /* now we can safely pick this up */ - - /* catch empties */ - if (*p == '\0') - return(0); - - /* single separator */ - if (sepc2 == '\0') { - fn = nfields; - for (;;) { - *fp++ = p; - fn--; - if (fn == 0) - break; - while ((c = *p++) != sepc) - if (c == '\0') - return(nfields - fn); - *(p-1) = '\0'; - } - /* we have overflowed the fields vector -- just count them */ - fn = nfields; - for (;;) { - while ((c = *p++) != sepc) - if (c == '\0') - return(fn); - fn++; - } - /* not reached */ - } - - /* two separators */ - if (sep[2] == '\0') { - fn = nfields; - for (;;) { - *fp++ = p; - fn--; - while ((c = *p++) != sepc && c != sepc2) - if (c == '\0') { - if (trimtrail && **(fp-1) == '\0') - fn++; - return(nfields - fn); - } - if (fn == 0) - break; - *(p-1) = '\0'; - while ((c = *p++) == sepc || c == sepc2) - continue; - p--; - } - /* we have overflowed the fields vector -- just count them */ - fn = nfields; - while (c != '\0') { - while ((c = *p++) == sepc || c == sepc2) - continue; - p--; - fn++; - while ((c = *p++) != '\0' && c != sepc && c != sepc2) - continue; - } - /* might have to trim trailing white space */ - if (trimtrail) { - p--; - while ((c = *--p) == sepc || c == sepc2) - continue; - p++; - if (*p != '\0') { - if (fn == nfields+1) - *p = '\0'; - fn--; - } - } - return(fn); - } - - /* n separators */ - fn = 0; - for (;;) { - if (fn < nfields) - *fp++ = p; - fn++; - for (;;) { - c = *p++; - if (c == '\0') - return(fn); - sepp = sep; - while ((sepc = *sepp++) != '\0' && sepc != c) - continue; - if (sepc != '\0') /* it was a separator */ - break; - } - if (fn < nfields) - *(p-1) = '\0'; - for (;;) { - c = *p++; - sepp = sep; - while ((sepc = *sepp++) != '\0' && sepc != c) - continue; - if (sepc == '\0') /* it wasn't a separator */ - break; - } - p--; - } - - /* not reached */ -} - -#ifdef TEST_SPLIT - - -/* - * test program - * pgm runs regression - * pgm sep splits stdin lines by sep - * pgm str sep splits str by sep - * pgm str sep n splits str by sep n times - */ -int -main(argc, argv) -int argc; -char *argv[]; -{ - char buf[512]; - register int n; -# define MNF 10 - char *fields[MNF]; - - if (argc > 4) - for (n = atoi(argv[3]); n > 0; n--) { - (void) strcpy(buf, argv[1]); - } - else if (argc > 3) - for (n = atoi(argv[3]); n > 0; n--) { - (void) strcpy(buf, argv[1]); - (void) split(buf, fields, MNF, argv[2]); - } - else if (argc > 2) - dosplit(argv[1], argv[2]); - else if (argc > 1) - while (fgets(buf, sizeof(buf), stdin) != NULL) { - buf[strlen(buf)-1] = '\0'; /* stomp newline */ - dosplit(buf, argv[1]); - } - else - regress(); - - exit(0); -} - -dosplit(string, seps) -char *string; -char *seps; -{ -# define NF 5 - char *fields[NF]; - register int nf; - - nf = split(string, fields, NF, seps); - print(nf, NF, fields); -} - -print(nf, nfp, fields) -int nf; -int nfp; -char *fields[]; -{ - register int fn; - register int bound; - - bound = (nf > nfp) ? nfp : nf; - printf("%d:\t", nf); - for (fn = 0; fn < bound; fn++) - printf("\"%s\"%s", fields[fn], (fn+1 < nf) ? ", " : "\n"); -} - -#define RNF 5 /* some table entries know this */ -struct { - char *str; - char *seps; - int nf; - char *fi[RNF]; -} tests[] = { - "", " ", 0, { "" }, - " ", " ", 2, { "", "" }, - "x", " ", 1, { "x" }, - "xy", " ", 1, { "xy" }, - "x y", " ", 2, { "x", "y" }, - "abc def g ", " ", 5, { "abc", "def", "", "g", "" }, - " a bcd", " ", 4, { "", "", "a", "bcd" }, - "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" }, - " a b c d ", " ", 6, { "", "a", "b", "c", "d " }, - - "", " _", 0, { "" }, - " ", " _", 2, { "", "" }, - "x", " _", 1, { "x" }, - "x y", " _", 2, { "x", "y" }, - "ab _ cd", " _", 2, { "ab", "cd" }, - " a_b c ", " _", 5, { "", "a", "b", "c", "" }, - "a b c_d e f", " _", 6, { "a", "b", "c", "d", "e f" }, - " a b c d ", " _", 6, { "", "a", "b", "c", "d " }, - - "", " _~", 0, { "" }, - " ", " _~", 2, { "", "" }, - "x", " _~", 1, { "x" }, - "x y", " _~", 2, { "x", "y" }, - "ab _~ cd", " _~", 2, { "ab", "cd" }, - " a_b c~", " _~", 5, { "", "a", "b", "c", "" }, - "a b_c d~e f", " _~", 6, { "a", "b", "c", "d", "e f" }, - "~a b c d ", " _~", 6, { "", "a", "b", "c", "d " }, - - "", " _~-", 0, { "" }, - " ", " _~-", 2, { "", "" }, - "x", " _~-", 1, { "x" }, - "x y", " _~-", 2, { "x", "y" }, - "ab _~- cd", " _~-", 2, { "ab", "cd" }, - " a_b c~", " _~-", 5, { "", "a", "b", "c", "" }, - "a b_c-d~e f", " _~-", 6, { "a", "b", "c", "d", "e f" }, - "~a-b c d ", " _~-", 6, { "", "a", "b", "c", "d " }, - - "", " ", 0, { "" }, - " ", " ", 2, { "", "" }, - "x", " ", 1, { "x" }, - "xy", " ", 1, { "xy" }, - "x y", " ", 2, { "x", "y" }, - "abc def g ", " ", 4, { "abc", "def", "g", "" }, - " a bcd", " ", 3, { "", "a", "bcd" }, - "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" }, - " a b c d ", " ", 6, { "", "a", "b", "c", "d " }, - - "", "", 0, { "" }, - " ", "", 0, { "" }, - "x", "", 1, { "x" }, - "xy", "", 1, { "xy" }, - "x y", "", 2, { "x", "y" }, - "abc def g ", "", 3, { "abc", "def", "g" }, - "\t a bcd", "", 2, { "a", "bcd" }, - " a \tb\t c ", "", 3, { "a", "b", "c" }, - "a b c d e ", "", 5, { "a", "b", "c", "d", "e" }, - "a b\tc d e f", "", 6, { "a", "b", "c", "d", "e f" }, - " a b c d e f ", "", 6, { "a", "b", "c", "d", "e f " }, - - NULL, NULL, 0, { NULL }, -}; - -regress() -{ - char buf[512]; - register int n; - char *fields[RNF+1]; - register int nf; - register int i; - register int printit; - register char *f; - - for (n = 0; tests[n].str != NULL; n++) { - (void) strcpy(buf, tests[n].str); - fields[RNF] = NULL; - nf = split(buf, fields, RNF, tests[n].seps); - printit = 0; - if (nf != tests[n].nf) { - printf("split `%s' by `%s' gave %d fields, not %d\n", - tests[n].str, tests[n].seps, nf, tests[n].nf); - printit = 1; - } else if (fields[RNF] != NULL) { - printf("split() went beyond array end\n"); - printit = 1; - } else { - for (i = 0; i < nf && i < RNF; i++) { - f = fields[i]; - if (f == NULL) - f = "(NULL)"; - if (strcmp(f, tests[n].fi[i]) != 0) { - printf("split `%s' by `%s', field %d is `%s', not `%s'\n", - tests[n].str, tests[n].seps, - i, fields[i], tests[n].fi[i]); - printit = 1; - } - } - } - if (printit) - print(nf, RNF, fields); - } -} -#endif diff --git a/lib/libc/regex/tests b/lib/libc/regex/tests deleted file mode 100644 index c05846177f59..000000000000 --- a/lib/libc/regex/tests +++ /dev/null @@ -1,475 +0,0 @@ -# regular expression test set -# Lines are at least three fields, separated by one or more tabs. "" stands -# for an empty field. First field is an RE. Second field is flags. If -# C flag given, regcomp() is expected to fail, and the third field is the -# error name (minus the leading REG_). -# -# Otherwise it is expected to succeed, and the third field is the string to -# try matching it against. If there is no fourth field, the match is -# expected to fail. If there is a fourth field, it is the substring that -# the RE is expected to match. If there is a fifth field, it is a comma- -# separated list of what the subexpressions should match, with - indicating -# no match for that one. In both the fourth and fifth fields, a (sub)field -# starting with @ indicates that the (sub)expression is expected to match -# a null string followed by the stuff after the @; this provides a way to -# test where null strings match. The character `N' in REs and strings -# is newline, `S' is space, `T' is tab, `Z' is NUL. -# -# The full list of flags: -# - placeholder, does nothing -# b RE is a BRE, not an ERE -# & try it as both an ERE and a BRE -# C regcomp() error expected, third field is error name -# i REG_ICASE -# m ("mundane") REG_NOSPEC -# s REG_NOSUB (not really testable) -# n REG_NEWLINE -# ^ REG_NOTBOL -# $ REG_NOTEOL -# # REG_STARTEND (see below) -# p REG_PEND -# -# For REG_STARTEND, the start/end offsets are those of the substring -# enclosed in (). - -# basics -a & a a -abc & abc abc -abc|de - abc abc -a|b|c - abc a - -# parentheses and perversions thereof -a(b)c - abc abc -a\(b\)c b abc abc -a( C EPAREN -a( b a( a( -a\( - a( a( -a\( bC EPAREN -a\(b bC EPAREN -a(b C EPAREN -a(b b a(b a(b -# gag me with a right parenthesis -- 1003.2 goofed here (my fault, partly) -a) - a) a) -) - ) ) -# end gagging (in a just world, those *should* give EPAREN) -a) b a) a) -a\) bC EPAREN -\) bC EPAREN -a()b - ab ab -a\(\)b b ab ab - -# anchoring and REG_NEWLINE -^abc$ & abc abc -a^b - a^b -a^b b a^b a^b -a$b - a$b -a$b b a$b a$b -^ & abc @abc -$ & abc @ -^$ & "" @ -$^ - "" @ -\($\)\(^\) b "" @ -# stop retching, those are legitimate (although disgusting) -^^ - "" @ -$$ - "" @ -b$ & abNc -b$ &n abNc b -^b$ & aNbNc -^b$ &n aNbNc b -^$ &n aNNb @Nb -^$ n abc -^$ n abcN @ -$^ n aNNb @Nb -\($\)\(^\) bn aNNb @Nb -^^ n^ aNNb @Nb -$$ n aNNb @NN -^a ^ a -a$ $ a -^a ^n aNb -^b ^n aNb b -a$ $n bNa -b$ $n bNa b -a*(^b$)c* - b b -a*\(^b$\)c* b b b - -# certain syntax errors and non-errors -| C EMPTY -| b | | -* C BADRPT -* b * * -+ C BADRPT -? C BADRPT -"" &C EMPTY -() - abc @abc -\(\) b abc @abc -a||b C EMPTY -|ab C EMPTY -ab| C EMPTY -(|a)b C EMPTY -(a|)b C EMPTY -(*a) C BADRPT -(+a) C BADRPT -(?a) C BADRPT -({1}a) C BADRPT -\(\{1\}a\) bC BADRPT -(a|*b) C BADRPT -(a|+b) C BADRPT -(a|?b) C BADRPT -(a|{1}b) C BADRPT -^* C BADRPT -^* b * * -^+ C BADRPT -^? C BADRPT -^{1} C BADRPT -^\{1\} bC BADRPT - -# metacharacters, backslashes -a.c & abc abc -a[bc]d & abd abd -a\*c & a*c a*c -a\\b & a\b a\b -a\\\*b & a\*b a\*b -a\bc & abc abc -a\ &C EESCAPE -a\\bc & a\bc a\bc -\{ bC BADRPT -a\[b & a[b a[b -a[b &C EBRACK -# trailing $ is a peculiar special case for the BRE code -a$ & a a -a$ & a$ -a\$ & a -a\$ & a$ a$ -a\\$ & a -a\\$ & a$ -a\\$ & a\$ -a\\$ & a\ a\ - -# back references, ugh -a\(b\)\2c bC ESUBREG -a\(b\1\)c bC ESUBREG -a\(b*\)c\1d b abbcbbd abbcbbd bb -a\(b*\)c\1d b abbcbd -a\(b*\)c\1d b abbcbbbd -^\(.\)\1 b abc -a\([bc]\)\1d b abcdabbd abbd b -a\(\([bc]\)\2\)*d b abbccd abbccd -a\(\([bc]\)\2\)*d b abbcbd -# actually, this next one probably ought to fail, but the spec is unclear -a\(\(b\)*\2\)*d b abbbd abbbd -# here is a case that no NFA implementation does right -\(ab*\)[ab]*\1 b ababaaa ababaaa a -# check out normal matching in the presence of back refs -\(a\)\1bcd b aabcd aabcd -\(a\)\1bc*d b aabcd aabcd -\(a\)\1bc*d b aabd aabd -\(a\)\1bc*d b aabcccd aabcccd -\(a\)\1bc*[ce]d b aabcccd aabcccd -^\(a\)\1b\(c\)*cd$ b aabcccd aabcccd - -# ordinary repetitions -ab*c & abc abc -ab+c - abc abc -ab?c - abc abc -a\(*\)b b a*b a*b -a\(**\)b b ab ab -a\(***\)b bC BADRPT -*a b *a *a -**a b a a -***a bC BADRPT - -# the dreaded bounded repetitions -{ & { { -{abc & {abc {abc -{1 C BADRPT -{1} C BADRPT -a{b & a{b a{b -a{1}b - ab ab -a\{1\}b b ab ab -a{1,}b - ab ab -a\{1,\}b b ab ab -a{1,2}b - aab aab -a\{1,2\}b b aab aab -a{1 C EBRACE -a\{1 bC EBRACE -a{1a C EBRACE -a\{1a bC EBRACE -a{1a} C BADBR -a\{1a\} bC BADBR -a{,2} - a{,2} a{,2} -a\{,2\} bC BADBR -a{,} - a{,} a{,} -a\{,\} bC BADBR -a{1,x} C BADBR -a\{1,x\} bC BADBR -a{1,x C EBRACE -a\{1,x bC EBRACE -a{300} C BADBR -a\{300\} bC BADBR -a{1,0} C BADBR -a\{1,0\} bC BADBR -ab{0,0}c - abcac ac -ab\{0,0\}c b abcac ac -ab{0,1}c - abcac abc -ab\{0,1\}c b abcac abc -ab{0,3}c - abbcac abbc -ab\{0,3\}c b abbcac abbc -ab{1,1}c - acabc abc -ab\{1,1\}c b acabc abc -ab{1,3}c - acabc abc -ab\{1,3\}c b acabc abc -ab{2,2}c - abcabbc abbc -ab\{2,2\}c b abcabbc abbc -ab{2,4}c - abcabbc abbc -ab\{2,4\}c b abcabbc abbc -((a{1,10}){1,10}){1,10} - a a a,a - -# multiple repetitions -a** &C BADRPT -a++ C BADRPT -a?? C BADRPT -a*+ C BADRPT -a*? C BADRPT -a+* C BADRPT -a+? C BADRPT -a?* C BADRPT -a?+ C BADRPT -a{1}{1} C BADRPT -a*{1} C BADRPT -a+{1} C BADRPT -a?{1} C BADRPT -a{1}* C BADRPT -a{1}+ C BADRPT -a{1}? C BADRPT -a*{b} - a{b} a{b} -a\{1\}\{1\} bC BADRPT -a*\{1\} bC BADRPT -a\{1\}* bC BADRPT - -# brackets, and numerous perversions thereof -a[b]c & abc abc -a[ab]c & abc abc -a[^ab]c & adc adc -a[]b]c & a]c a]c -a[[b]c & a[c a[c -a[-b]c & a-c a-c -a[^]b]c & adc adc -a[^-b]c & adc adc -a[b-]c & a-c a-c -a[b &C EBRACK -a[] &C EBRACK -a[1-3]c & a2c a2c -a[3-1]c &C ERANGE -a[1-3-5]c &C ERANGE -a[[.-.]--]c & a-c a-c -a[1- &C ERANGE -a[[. &C EBRACK -a[[.x &C EBRACK -a[[.x. &C EBRACK -a[[.x.] &C EBRACK -a[[.x.]] & ax ax -a[[.x,.]] &C ECOLLATE -a[[.one.]]b & a1b a1b -a[[.notdef.]]b &C ECOLLATE -a[[.].]]b & a]b a]b -a[[:alpha:]]c & abc abc -a[[:notdef:]]c &C ECTYPE -a[[: &C EBRACK -a[[:alpha &C EBRACK -a[[:alpha:] &C EBRACK -a[[:alpha,:] &C ECTYPE -a[[:]:]]b &C ECTYPE -a[[:-:]]b &C ECTYPE -a[[:alph:]] &C ECTYPE -a[[:alphabet:]] &C ECTYPE -[[:alnum:]]+ - -%@a0X- a0X -[[:alpha:]]+ - -%@aX0- aX -[[:blank:]]+ - aSSTb SST -[[:cntrl:]]+ - aNTb NT -[[:digit:]]+ - a019b 019 -[[:graph:]]+ - Sa%bS a%b -[[:lower:]]+ - AabC ab -[[:print:]]+ - NaSbN aSb -[[:punct:]]+ - S%-&T %-& -[[:space:]]+ - aSNTb SNT -[[:upper:]]+ - aBCd BC -[[:xdigit:]]+ - p0f3Cq 0f3C -a[[=b=]]c & abc abc -a[[= &C EBRACK -a[[=b &C EBRACK -a[[=b= &C EBRACK -a[[=b=] &C EBRACK -a[[=b,=]] &C ECOLLATE -a[[=one=]]b & a1b a1b - -# complexities -a(((b)))c - abc abc -a(b|(c))d - abd abd -a(b*|c)d - abbd abbd -# just gotta have one DFA-buster, of course -a[ab]{20} - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab -# and an inline expansion in case somebody gets tricky -a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab -# and in case somebody just slips in an NFA... -a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) - aaaaabaaaabaaaabaaaabweeknights aaaaabaaaabaaaabaaaabweeknights -# fish for anomalies as the number of states passes 32 -12345678901234567890123456789 - a12345678901234567890123456789b 12345678901234567890123456789 -123456789012345678901234567890 - a123456789012345678901234567890b 123456789012345678901234567890 -1234567890123456789012345678901 - a1234567890123456789012345678901b 1234567890123456789012345678901 -12345678901234567890123456789012 - a12345678901234567890123456789012b 12345678901234567890123456789012 -123456789012345678901234567890123 - a123456789012345678901234567890123b 123456789012345678901234567890123 -# and one really big one, beyond any plausible word width -1234567890123456789012345678901234567890123456789012345678901234567890 - a1234567890123456789012345678901234567890123456789012345678901234567890b 1234567890123456789012345678901234567890123456789012345678901234567890 -# fish for problems as brackets go past 8 -[ab][cd][ef][gh][ij][kl][mn] - xacegikmoq acegikm -[ab][cd][ef][gh][ij][kl][mn][op] - xacegikmoq acegikmo -[ab][cd][ef][gh][ij][kl][mn][op][qr] - xacegikmoqy acegikmoq -[ab][cd][ef][gh][ij][kl][mn][op][q] - xacegikmoqy acegikmoq - -# subtleties of matching -abc & xabcy abc -a\(b\)?c\1d b acd -aBc i Abc Abc -a[Bc]*d i abBCcd abBCcd -0[[:upper:]]1 &i 0a1 0a1 -0[[:lower:]]1 &i 0A1 0A1 -a[^b]c &i abc -a[^b]c &i aBc -a[^b]c &i adc adc -[a]b[c] - abc abc -[a]b[a] - aba aba -[abc]b[abc] - abc abc -[abc]b[abd] - abd abd -a(b?c)+d - accd accd -(wee|week)(knights|night) - weeknights weeknights -(we|wee|week|frob)(knights|night|day) - weeknights weeknights -a[bc]d - xyzaaabcaababdacd abd -a[ab]c - aaabc abc -abc s abc abc -a* & b @b - -# Let's have some fun -- try to match a C comment. -# first the obvious, which looks okay at first glance... -/\*.*\*/ - /*x*/ /*x*/ -# but... -/\*.*\*/ - /*x*/y/*z*/ /*x*/y/*z*/ -# okay, we must not match */ inside; try to do that... -/\*([^*]|\*[^/])*\*/ - /*x*/ /*x*/ -/\*([^*]|\*[^/])*\*/ - /*x*/y/*z*/ /*x*/ -# but... -/\*([^*]|\*[^/])*\*/ - /*x**/y/*z*/ /*x**/y/*z*/ -# and a still fancier version, which does it right (I think)... -/\*([^*]|\*+[^*/])*\*+/ - /*x*/ /*x*/ -/\*([^*]|\*+[^*/])*\*+/ - /*x*/y/*z*/ /*x*/ -/\*([^*]|\*+[^*/])*\*+/ - /*x**/y/*z*/ /*x**/ -/\*([^*]|\*+[^*/])*\*+/ - /*x****/y/*z*/ /*x****/ -/\*([^*]|\*+[^*/])*\*+/ - /*x**x*/y/*z*/ /*x**x*/ -/\*([^*]|\*+[^*/])*\*+/ - /*x***x/y/*z*/ /*x***x/y/*z*/ - -# subexpressions -a(b)(c)d - abcd abcd b,c -a(((b)))c - abc abc b,b,b -a(b|(c))d - abd abd b,- -a(b*|c|e)d - abbd abbd bb -a(b*|c|e)d - acd acd c -a(b*|c|e)d - ad ad @d -a(b?)c - abc abc b -a(b?)c - ac ac @c -a(b+)c - abc abc b -a(b+)c - abbbc abbbc bbb -a(b*)c - ac ac @c -(a|ab)(bc([de]+)f|cde) - abcdef abcdef a,bcdef,de -# the regression tester only asks for 9 subexpressions -a(b)(c)(d)(e)(f)(g)(h)(i)(j)k - abcdefghijk abcdefghijk b,c,d,e,f,g,h,i,j -a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l - abcdefghijkl abcdefghijkl b,c,d,e,f,g,h,i,j,k -a([bc]?)c - abc abc b -a([bc]?)c - ac ac @c -a([bc]+)c - abc abc b -a([bc]+)c - abcc abcc bc -a([bc]+)bc - abcbc abcbc bc -a(bb+|b)b - abb abb b -a(bbb+|bb+|b)b - abb abb b -a(bbb+|bb+|b)b - abbb abbb bb -a(bbb+|bb+|b)bb - abbb abbb b -(.*).* - abcdef abcdef abcdef -(a*)* - bc @b @b - -# do we get the right subexpression when it is used more than once? -a(b|c)*d - ad ad - -a(b|c)*d - abcd abcd c -a(b|c)+d - abd abd b -a(b|c)+d - abcd abcd c -a(b|c?)+d - ad ad @d -a(b|c?)+d - abcd abcd @d -a(b|c){0,0}d - ad ad - -a(b|c){0,1}d - ad ad - -a(b|c){0,1}d - abd abd b -a(b|c){0,2}d - ad ad - -a(b|c){0,2}d - abcd abcd c -a(b|c){0,}d - ad ad - -a(b|c){0,}d - abcd abcd c -a(b|c){1,1}d - abd abd b -a(b|c){1,1}d - acd acd c -a(b|c){1,2}d - abd abd b -a(b|c){1,2}d - abcd abcd c -a(b|c){1,}d - abd abd b -a(b|c){1,}d - abcd abcd c -a(b|c){2,2}d - acbd acbd b -a(b|c){2,2}d - abcd abcd c -a(b|c){2,4}d - abcd abcd c -a(b|c){2,4}d - abcbd abcbd b -a(b|c){2,4}d - abcbcd abcbcd c -a(b|c){2,}d - abcd abcd c -a(b|c){2,}d - abcbd abcbd b -a(b+|((c)*))+d - abd abd @d,@d,- -a(b+|((c)*))+d - abcd abcd @d,@d,- - -# check out the STARTEND option -[abc] &# a(b)c b -[abc] &# a(d)c -[abc] &# a(bc)d b -[abc] &# a(dc)d c -. &# a()c -b.*c &# b(bc)c bc -b.* &# b(bc)c bc -.*c &# b(bc)c bc - -# plain strings, with the NOSPEC flag -abc m abc abc -abc m xabcy abc -abc m xyz -a*b m aba*b a*b -a*b m ab -"" mC EMPTY - -# cases involving NULs -aZb & a a -aZb &p a -aZb &p# (aZb) aZb -aZ*b &p# (ab) ab -a.b &# (aZb) aZb -a.* &# (aZb)c aZb - -# word boundaries (ick) -[[:<:]]a & a a -[[:<:]]a & ba -[[:<:]]a & -a a -a[[:>:]] & a a -a[[:>:]] & ab -a[[:>:]] & a- a -[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc abc -[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc-q abc -[[:<:]]a.c[[:>:]] & axc-dayc-dazce-abc axc -[[:<:]]b.c[[:>:]] & a_bxc-byc_d-bzc-q bzc -[[:<:]].x..[[:>:]] & y_xa_-_xb_y-_xc_-axdc _xc_ -[[:<:]]a_b[[:>:]] & x_a_b - -# past problems, and suspected problems -(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A]) - A1 A1 -abcdefghijklmnop i abcdefghijklmnop abcdefghijklmnop -abcdefghijklmnopqrstuv i abcdefghijklmnopqrstuv abcdefghijklmnopqrstuv -(ALAK)|(ALT[AB])|(CC[123]1)|(CM[123]1)|(GAMC)|(LC[23][EO ])|(SEM[1234])|(SL[ES][12])|(SLWW)|(SLF )|(SLDT)|(VWH[12])|(WH[34][EW])|(WP1[ESN]) - CC11 CC11 -CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a - CC11 CC11 -Char \([a-z0-9_]*\)\[.* b Char xyz[k Char xyz[k xyz -a?b - ab ab --\{0,1\}[0-9]*$ b -5 -5 diff --git a/lib/libc/sparc/gen/isnan.c b/lib/libc/sparc/gen/isnan.c deleted file mode 100644 index cb41ac48fafc..000000000000 --- a/lib/libc/sparc/gen/isnan.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: isnan.c,v 1.1 91/07/08 19:03:34 torek Exp - * $Id: isnan.c,v 1.1 1993/09/05 22:22:24 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)isnan.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -isnan(d) - double d; -{ - register struct ieee_double *p = (struct ieee_double *)&d; - - return (p->dbl_exp == DBL_EXP_INFNAN && - (p->dbl_frach != 0 || p->dbl_fracl != 0)); -} diff --git a/lib/libc/sparc/gen/ldexp.c b/lib/libc/sparc/gen/ldexp.c deleted file mode 100644 index 7cac76773de0..000000000000 --- a/lib/libc/sparc/gen/ldexp.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: ldexp.c,v 1.1 91/07/07 04:28:19 torek Exp - * $Id: ldexp.c,v 1.1 1993/09/05 22:22:25 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static const char sccsid[] = "@(#)ldexp.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * double ldexp(double val, int exp) - * returns: val * (2**exp) - */ -double -ldexp(val, exp) - double val; - int exp; -{ - register int oldexp, newexp, mulexp; - union doub { - double v; - struct ieee_double s; - } u, mul; - - /* - * If input is zero, or no change, just return input. - * Likewise, if input is Inf or NaN, just return it. - */ - u.v = val; - oldexp = u.s.dbl_exp; - if (val == 0 || exp == 0 || oldexp == DBL_EXP_INFNAN) - return (val); - - /* - * Compute new exponent and check for over/under flow. - * Underflow, unfortunately, could mean switching to denormal. - * If result out of range, set ERANGE and return 0 if too small - * or Inf if too big, with the same sign as the input value. - */ - newexp = oldexp + exp; - if (newexp >= DBL_EXP_INFNAN) { - /* u.s.dbl_sign = val < 0; -- already set */ - u.s.dbl_exp = DBL_EXP_INFNAN; - u.s.dbl_frach = u.s.dbl_fracl = 0; - errno = ERANGE; - return (u.v); /* Inf */ - } - if (newexp <= 0) { - /* - * The output number is either a denormal or underflows - * (see comments in machine/ieee.h). - */ - if (newexp <= -DBL_FRACBITS) { - /* u.s.dbl_sign = val < 0; -- already set */ - u.s.dbl_exp = 0; - u.s.dbl_frach = u.s.dbl_fracl = 0; - errno = ERANGE; - return (u.v); /* zero */ - } - /* - * We are going to produce a denorm. Our `exp' argument - * might be as small as -2097, and we cannot compute - * 2^-2097, so we may have to do this as many as three - * steps (not just two, as for positive `exp's below). - */ - mul.v = 0; - while (exp <= -DBL_EXP_BIAS) { - mul.s.dbl_exp = 1; - val *= mul.v; - exp += DBL_EXP_BIAS - 1; - } - mul.s.dbl_exp = exp + DBL_EXP_BIAS; - val *= mul.v; - return (val); - } - - /* - * Newexp is positive. - * - * If oldexp is zero, we are starting with a denorm, and simply - * adjusting the exponent will produce bogus answers. We need - * to fix that first. - */ - if (oldexp == 0) { - /* - * Multiply by 2^mulexp to make the number normalizable. - * We cannot multiply by more than 2^1023, but `exp' - * argument might be as large as 2046. A single - * adjustment, however, will normalize the number even - * for huge `exp's, and then we can use exponent - * arithmetic just as for normal `double's. - */ - mulexp = exp <= DBL_EXP_BIAS ? exp : DBL_EXP_BIAS; - mul.v = 0; - mul.s.dbl_exp = mulexp + DBL_EXP_BIAS; - val *= mul.v; - if (mulexp == exp) - return (val); - u.v = val; - newexp -= mulexp; - } - - /* - * Both oldexp and newexp are positive; just replace the - * old exponent with the new one. - */ - u.s.dbl_exp = newexp; - return (u.v); -} diff --git a/lib/libc/sparc/gen/modf.s b/lib/libc/sparc/gen/modf.s deleted file mode 100644 index 3c753eeb3791..000000000000 --- a/lib/libc/sparc/gen/modf.s +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: modf.s,v 1.3 92/06/20 00:00:54 torek Exp - * $Id: modf.s,v 1.1 1993/09/05 22:17:57 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)modf.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" -#include - -/* - * double modf(double val, double *iptr) - * - * Returns the fractional part of `val', storing the integer part of - * `val' in *iptr. Both *iptr and the return value have the same sign - * as `val'. - * - * Method: - * - * We use the fpu's normalization hardware to compute the integer portion - * of the double precision argument. Sun IEEE double precision numbers - * have 52 bits of mantissa, 11 bits of exponent, and one bit of sign, - * with the sign occupying bit 31 of word 0, and the exponent bits 30:20 - * of word 0. Thus, values >= 2^52 are by definition integers. - * - * If we take a value that is in the range [+0..2^52) and add 2^52, all - * of the fractional bits fall out and all of the integer bits are summed - * with 2^52. If we then subtract 2^52, we get those integer bits back. - * This must be done with rounding set to `towards 0' or `towards -inf'. - * `Toward -inf' fails when the value is 0 (we get -0 back).... - * - * Note that this method will work anywhere, but is machine dependent in - * various aspects. - * - * Stack usage: - * 4@[%fp - 4] saved %fsr - * 4@[%fp - 8] new %fsr with rounding set to `towards 0' - * 8@[%fp - 16] space for moving between %i and %f registers - * Register usage: - * %i0%i1 double val; - * %l0 scratch - * %l1 sign bit (0x80000000) - * %i2 double *iptr; - * %f2:f3 `magic number' 2^52, in fpu registers - * %f4:f5 double v, in fpu registers - */ - - .align 8 -Lmagic: - .word 0x43300000 ! sign = 0, exponent = 52 + 1023, mantissa = 0 - .word 0 ! (i.e., .double 0r4503599627370496e+00) - -L0: - .word 0 ! 0.0 - .word 0 - -ENTRY(modf) - save %sp, -64-16, %sp - - /* - * First, compute v = abs(val) by clearing sign bit, - * and then set up the fpu registers. This would be - * much easier if we could do alu operations on fpu registers! - */ - sethi 0x80000000, %l1 ! sign bit - andn %i0, %l1, %l0 - st %l0, [%fp - 16] - sethi %hi(Lmagic), %l0 - ldd [%l0 + %lo(Lmagic)], %f2 - st %i1, [%fp - 12] - ldd [%fp - 16], %f4 ! %f4:f5 = v - - /* - * Is %f4:f5 >= %f2:f3 ? If so, it is all integer bits. - * It is probably less, though. - */ - fcmped %f4, %f2 - nop ! fpop2 delay - fbuge Lbig ! if >= (or unordered), go out - nop - - /* - * v < 2^52, so add 2^52, then subtract 2^52, but do it all - * with rounding set towards zero. We leave any enabled - * traps enabled, but change the rounding mode. This might - * not be so good. Oh well.... - */ - st %fsr, [%fp - 4] ! %l5 = current FSR mode - set FSR_RD, %l3 ! %l3 = rounding direction mask - ld [%fp - 4], %l5 - set FSR_RD_RZ << FSR_RD_SHIFT, %l4 - andn %l5, %l3, %l6 - or %l6, %l4, %l6 ! round towards zero, please - and %l5, %l3, %l5 ! save original rounding mode - st %l6, [%fp - 8] - ld [%fp - 8], %fsr - - faddd %f4, %f2, %f4 ! %f4:f5 += 2^52 - fsubd %f4, %f2, %f4 ! %f4:f5 -= 2^52 - - /* - * Restore %fsr, but leave exceptions accrued. - */ - st %fsr, [%fp - 4] - ld [%fp - 4], %l6 - andn %l6, %l3, %l6 ! %l6 = %fsr & ~FSR_RD; - or %l5, %l6, %l5 ! %l5 |= %l6; - st %l5, [%fp - 4] - ld [%fp - 4], %fsr ! restore %fsr, leaving accrued stuff - - /* - * Now insert the original sign in %f4:f5. - * This is a lot of work, so it is conditional here. - */ - btst %l1, %i0 - be 1f - nop - st %f4, [%fp - 16] - ld [%fp - 16], %g1 - or %l1, %g1, %g1 - st %g1, [%fp - 16] - ld [%fp - 16], %f4 -1: - - /* - * The value in %f4:f5 is now the integer portion of the original - * argument. We need to store this in *ival (%i2), subtract it - * from the original value argument (%i0:i1), and return the result. - */ - std %f4, [%i2] ! *ival = %f4:f5; - std %i0, [%fp - 16] - ldd [%fp - 16], %f0 ! %f0:f1 = val; - fsubd %f0, %f4, %f0 ! %f0:f1 -= %f4:f5; - ret - restore - -Lbig: - /* - * We get here if the original comparison of %f4:f5 (v) to - * %f2:f3 (2^52) came out `greater or unordered'. In this - * case the integer part is the original value, and the - * fractional part is 0. - */ - sethi %hi(L0), %l0 - std %f0, [%i2] ! *ival = val; - ldd [%l0 + %lo(L0)], %f0 ! return 0.0; - ret - restore diff --git a/lib/libc/sparc/gen/mul.s b/lib/libc/sparc/gen/mul.s deleted file mode 100644 index a87ffdafc274..000000000000 --- a/lib/libc/sparc/gen/mul.s +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: mul.s,v 1.5 92/06/25 13:24:03 torek Exp - * $Id: mul.s,v 1.1 1993/09/05 22:17:59 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)mul.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* - * Signed multiply, from Appendix E of the Sparc Version 8 - * Architecture Manual. - * - * Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the upper 32 bits of - * the 64-bit product). - * - * This code optimizes short (less than 13-bit) multiplies. - */ - -#include "DEFS.h" -FUNC(.mul) - mov %o0, %y ! multiplier -> Y - andncc %o0, 0xfff, %g0 ! test bits 12..31 - be Lmul_shortway ! if zero, can do it the short way - andcc %g0, %g0, %o4 ! zero the partial product and clear N and V - - /* - * Long multiply. 32 steps, followed by a final shift step. - */ - mulscc %o4, %o1, %o4 ! 1 - mulscc %o4, %o1, %o4 ! 2 - mulscc %o4, %o1, %o4 ! 3 - mulscc %o4, %o1, %o4 ! 4 - mulscc %o4, %o1, %o4 ! 5 - mulscc %o4, %o1, %o4 ! 6 - mulscc %o4, %o1, %o4 ! 7 - mulscc %o4, %o1, %o4 ! 8 - mulscc %o4, %o1, %o4 ! 9 - mulscc %o4, %o1, %o4 ! 10 - mulscc %o4, %o1, %o4 ! 11 - mulscc %o4, %o1, %o4 ! 12 - mulscc %o4, %o1, %o4 ! 13 - mulscc %o4, %o1, %o4 ! 14 - mulscc %o4, %o1, %o4 ! 15 - mulscc %o4, %o1, %o4 ! 16 - mulscc %o4, %o1, %o4 ! 17 - mulscc %o4, %o1, %o4 ! 18 - mulscc %o4, %o1, %o4 ! 19 - mulscc %o4, %o1, %o4 ! 20 - mulscc %o4, %o1, %o4 ! 21 - mulscc %o4, %o1, %o4 ! 22 - mulscc %o4, %o1, %o4 ! 23 - mulscc %o4, %o1, %o4 ! 24 - mulscc %o4, %o1, %o4 ! 25 - mulscc %o4, %o1, %o4 ! 26 - mulscc %o4, %o1, %o4 ! 27 - mulscc %o4, %o1, %o4 ! 28 - mulscc %o4, %o1, %o4 ! 29 - mulscc %o4, %o1, %o4 ! 30 - mulscc %o4, %o1, %o4 ! 31 - mulscc %o4, %o1, %o4 ! 32 - mulscc %o4, %g0, %o4 ! final shift - - ! If %o0 was negative, the result is - ! (%o0 * %o1) + (%o1 << 32)) - ! We fix that here. - - tst %o0 - bge 1f - rd %y, %o0 - - ! %o0 was indeed negative; fix upper 32 bits of result by subtracting - ! %o1 (i.e., return %o4 - %o1 in %o1). - retl - sub %o4, %o1, %o1 - -1: - retl - mov %o4, %o1 - -Lmul_shortway: - /* - * Short multiply. 12 steps, followed by a final shift step. - * The resulting bits are off by 12 and (32-12) = 20 bit positions, - * but there is no problem with %o0 being negative (unlike above). - */ - mulscc %o4, %o1, %o4 ! 1 - mulscc %o4, %o1, %o4 ! 2 - mulscc %o4, %o1, %o4 ! 3 - mulscc %o4, %o1, %o4 ! 4 - mulscc %o4, %o1, %o4 ! 5 - mulscc %o4, %o1, %o4 ! 6 - mulscc %o4, %o1, %o4 ! 7 - mulscc %o4, %o1, %o4 ! 8 - mulscc %o4, %o1, %o4 ! 9 - mulscc %o4, %o1, %o4 ! 10 - mulscc %o4, %o1, %o4 ! 11 - mulscc %o4, %o1, %o4 ! 12 - mulscc %o4, %g0, %o4 ! final shift - - /* - * %o4 has 20 of the bits that should be in the low part of the - * result; %y has the bottom 12 (as %y's top 12). That is: - * - * %o4 %y - * +----------------+----------------+ - * | -12- | -20- | -12- | -20- | - * +------(---------+------)---------+ - * --hi-- ----low-part---- - * - * The upper 12 bits of %o4 should be sign-extended to form the - * high part of the product (i.e., highpart = %o4 >> 20). - */ - - rd %y, %o5 - sll %o4, 12, %o0 ! shift middle bits left 12 - srl %o5, 20, %o5 ! shift low bits right 20, zero fill at left - or %o5, %o0, %o0 ! construct low part of result - retl - sra %o4, 20, %o1 ! ... and extract high part of result diff --git a/lib/libc/sparc/gen/saveregs.s b/lib/libc/sparc/gen/saveregs.s deleted file mode 100644 index 80fea4adcc39..000000000000 --- a/lib/libc/sparc/gen/saveregs.s +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: saveregs.s,v 1.1 91/07/06 17:22:33 torek Exp - * $Id: saveregs.s,v 1.1 1993/09/05 22:18:01 deraadt Exp $ - */ - -/* - * Save register arguments in caller's `arg dump' area, so that - * stdarg functions work. - * - * This really should be done with a pointer to the arg dump area; - * our caller should allocate that area, not our caller's caller. - * But then, they did not let me invent the calling sequence.... - * - * We assume the caller has executed a `save' instruction. - */ -#include "DEFS.h" - -ENTRY(__builtin_saveregs) - st %i0, [%fp + 0x44] ! fr->fr_argd[0] - st %i1, [%fp + 0x48] ! fr->fr_argd[1] - st %i2, [%fp + 0x4c] ! fr->fr_argd[2] - st %i3, [%fp + 0x50] ! fr->fr_argd[3] - st %i4, [%fp + 0x54] ! fr->fr_argd[4] - retl - st %i5, [%fp + 0x58] ! fr->fr_argd[5] diff --git a/lib/libc/sparc/gen/setjmp.s b/lib/libc/sparc/gen/setjmp.s deleted file mode 100644 index 65baf74e9828..000000000000 --- a/lib/libc/sparc/gen/setjmp.s +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: setjmp.s,v 1.2 92/06/25 03:18:43 torek Exp - * $Id: setjmp.s,v 1.1 1993/09/05 22:18:02 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#include "SYS.h" - -ENTRY(setjmp) - /* - * We use the caller's `arg dump' area (%sp+0x44; there are 6 ints - * reserved there for us) to avoid having to allocate stack space - * here. - */ - mov %o0, %o2 /* build sigcontext in [%o2] */ - mov 1, %o0 /* SIG_BLOCK */ - mov SYS_sigprocmask, %g1 - clr %o1 /* sigprocmask(SIG_BLOCK, (sigset_t *)NULL) */ - t ST_SYSCALL - st %o0, [%o2 + 4] /* sc.sc_mask = current mask; */ - mov SYS_sigaltstack, %g1 - clr %o0 /* sigstack(NULL, &foo) */ - add %sp, 0x48, %o1 /* (foo being in arg dump area) */ - t ST_SYSCALL - ld [%sp + 0x50], %o0 /* foo.ss_flags */ - and %o0, 1, %o1 /* onstack = foo.ss_flags & 1; */ - st %o0, [%o2 + 0] /* sc.sc_onstack = current onstack; */ - st %sp, [%o2 + 8] /* sc.sc_sp = sp (both ours and caller's) */ - add %o7, 8, %o0 - st %o0, [%o2 + 12] /* sc.sc_pc = return_pc */ - add %o7, 12, %o0 - st %o0, [%o2 + 16] /* sc.sc_npc = return_pc + 4 */ - st %g0, [%o2 + 20] /* sc.sc_psr = (clean psr) */ - st %fp, [%o2 + 24] /* sc.sc_g1 = %fp (misuse, but what the heck) */ - /* sc.sc_o0 = random(), set in longjmp */ - retl /* return 0 */ - clr %o0 - -/* - * All we need to do here is force sigreturn to load a new stack pointer, - * new , and appropriate %o0 return value from the sigcontext built - * in setjmp. The %i and %l registers will be reloaded from the place to - * which %sp points, due to sigreturn() semantics (sigreturn does not modify - * the window pointer in the psr, hence it must force all windows to reload). - */ -ENTRY(longjmp) - save %sp, -96, %sp - ld [%i0 + 8], %o2 /* make sure sc->sc_sp, sc->sc_fp nonzero */ - ld [%i0 + 24], %o3 - orcc %o2, %o3, %g0 - bz Lbotch - tst %i1 /* if (v == 0) v = 1; */ - bz,a 1f - mov 1, %i1 -1: - st %i1, [%i0 + 28] /* sc.sc_o0 = v; */ - mov SYS_sigreturn, %g1 - mov %i0, %o0 - t ST_SYSCALL /* sigreturn(scp); */ - -Lbotch: - /* oops, caller botched it */ - call _longjmperror - nop - unimp 0 diff --git a/lib/libc/sparc/gen/umul.s b/lib/libc/sparc/gen/umul.s deleted file mode 100644 index e7a020cd3f82..000000000000 --- a/lib/libc/sparc/gen/umul.s +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: umul.s,v 1.4 92/06/25 13:24:05 torek Exp - * $Id: umul.s,v 1.1 1993/09/05 22:18:04 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)umul.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* - * Unsigned multiply. Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the - * upper 32 bits of the 64-bit product). - * - * This code optimizes short (less than 13-bit) multiplies. Short - * multiplies require 25 instruction cycles, and long ones require - * 45 instruction cycles. - * - * On return, overflow has occurred (%o1 is not zero) if and only if - * the Z condition code is clear, allowing, e.g., the following: - * - * call .umul - * nop - * bnz overflow (or tnz) - */ - -#include "DEFS.h" -FUNC(.umul) - or %o0, %o1, %o4 - mov %o0, %y ! multiplier -> Y - andncc %o4, 0xfff, %g0 ! test bits 12..31 of *both* args - be Lmul_shortway ! if zero, can do it the short way - andcc %g0, %g0, %o4 ! zero the partial product and clear N and V - - /* - * Long multiply. 32 steps, followed by a final shift step. - */ - mulscc %o4, %o1, %o4 ! 1 - mulscc %o4, %o1, %o4 ! 2 - mulscc %o4, %o1, %o4 ! 3 - mulscc %o4, %o1, %o4 ! 4 - mulscc %o4, %o1, %o4 ! 5 - mulscc %o4, %o1, %o4 ! 6 - mulscc %o4, %o1, %o4 ! 7 - mulscc %o4, %o1, %o4 ! 8 - mulscc %o4, %o1, %o4 ! 9 - mulscc %o4, %o1, %o4 ! 10 - mulscc %o4, %o1, %o4 ! 11 - mulscc %o4, %o1, %o4 ! 12 - mulscc %o4, %o1, %o4 ! 13 - mulscc %o4, %o1, %o4 ! 14 - mulscc %o4, %o1, %o4 ! 15 - mulscc %o4, %o1, %o4 ! 16 - mulscc %o4, %o1, %o4 ! 17 - mulscc %o4, %o1, %o4 ! 18 - mulscc %o4, %o1, %o4 ! 19 - mulscc %o4, %o1, %o4 ! 20 - mulscc %o4, %o1, %o4 ! 21 - mulscc %o4, %o1, %o4 ! 22 - mulscc %o4, %o1, %o4 ! 23 - mulscc %o4, %o1, %o4 ! 24 - mulscc %o4, %o1, %o4 ! 25 - mulscc %o4, %o1, %o4 ! 26 - mulscc %o4, %o1, %o4 ! 27 - mulscc %o4, %o1, %o4 ! 28 - mulscc %o4, %o1, %o4 ! 29 - mulscc %o4, %o1, %o4 ! 30 - mulscc %o4, %o1, %o4 ! 31 - mulscc %o4, %o1, %o4 ! 32 - mulscc %o4, %g0, %o4 ! final shift - - - /* - * Normally, with the shift-and-add approach, if both numbers are - * positive you get the correct result. WIth 32-bit two's-complement - * numbers, -x is represented as - * - * x 32 - * ( 2 - ------ ) mod 2 * 2 - * 32 - * 2 - * - * (the `mod 2' subtracts 1 from 1.bbbb). To avoid lots of 2^32s, - * we can treat this as if the radix point were just to the left - * of the sign bit (multiply by 2^32), and get - * - * -x = (2 - x) mod 2 - * - * Then, ignoring the `mod 2's for convenience: - * - * x * y = xy - * -x * y = 2y - xy - * x * -y = 2x - xy - * -x * -y = 4 - 2x - 2y + xy - * - * For signed multiplies, we subtract (x << 32) from the partial - * product to fix this problem for negative multipliers (see mul.s). - * Because of the way the shift into the partial product is calculated - * (N xor V), this term is automatically removed for the multiplicand, - * so we don't have to adjust. - * - * But for unsigned multiplies, the high order bit wasn't a sign bit, - * and the correction is wrong. So for unsigned multiplies where the - * high order bit is one, we end up with xy - (y << 32). To fix it - * we add y << 32. - */ - tst %o1 - bl,a 1f ! if %o1 < 0 (high order bit = 1), - add %o4, %o0, %o4 ! %o4 += %o0 (add y to upper half) -1: rd %y, %o0 ! get lower half of product - retl - addcc %o4, %g0, %o1 ! put upper half in place and set Z for %o1==0 - -Lmul_shortway: - /* - * Short multiply. 12 steps, followed by a final shift step. - * The resulting bits are off by 12 and (32-12) = 20 bit positions, - * but there is no problem with %o0 being negative (unlike above), - * and overflow is impossible (the answer is at most 24 bits long). - */ - mulscc %o4, %o1, %o4 ! 1 - mulscc %o4, %o1, %o4 ! 2 - mulscc %o4, %o1, %o4 ! 3 - mulscc %o4, %o1, %o4 ! 4 - mulscc %o4, %o1, %o4 ! 5 - mulscc %o4, %o1, %o4 ! 6 - mulscc %o4, %o1, %o4 ! 7 - mulscc %o4, %o1, %o4 ! 8 - mulscc %o4, %o1, %o4 ! 9 - mulscc %o4, %o1, %o4 ! 10 - mulscc %o4, %o1, %o4 ! 11 - mulscc %o4, %o1, %o4 ! 12 - mulscc %o4, %g0, %o4 ! final shift - - /* - * %o4 has 20 of the bits that should be in the result; %y has - * the bottom 12 (as %y's top 12). That is: - * - * %o4 %y - * +----------------+----------------+ - * | -12- | -20- | -12- | -20- | - * +------(---------+------)---------+ - * -----result----- - * - * The 12 bits of %o4 left of the `result' area are all zero; - * in fact, all top 20 bits of %o4 are zero. - */ - - rd %y, %o5 - sll %o4, 12, %o0 ! shift middle bits left 12 - srl %o5, 20, %o5 ! shift low bits right 20 - or %o5, %o0, %o0 - retl - addcc %g0, %g0, %o1 ! %o1 = zero, and set Z diff --git a/lib/libc/sparc/sys/reboot.s b/lib/libc/sparc/sys/reboot.s deleted file mode 100644 index 56f8f2e1beac..000000000000 --- a/lib/libc/sparc/sys/reboot.s +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: reboot.s,v 1.1 91/07/06 13:05:59 torek Exp - * $Id: reboot.s,v 1.1 1993/09/05 22:18:55 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)reboot.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - unimp 0 diff --git a/lib/libc/sparc/sys/sbrk.s b/lib/libc/sparc/sys/sbrk.s deleted file mode 100644 index 77ff3bbd53a4..000000000000 --- a/lib/libc/sparc/sys/sbrk.s +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: sbrk.s,v 1.3 92/07/02 00:56:49 torek Exp - * $Id: sbrk.s,v 1.1 1993/09/05 22:18:57 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)sbrk.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _end - .globl curbrk - - .data -curbrk: .long _end - .text - -ENTRY(sbrk) - sethi %hi(curbrk), %o2 - ld [%o2 + %lo(curbrk)], %o3 ! %o3 = old break - add %o3, %o0, %o4 ! %o4 = new break - mov %o4, %o0 ! copy for syscall - mov SYS_break, %g1 - t ST_SYSCALL ! break(new_break) - bcc,a 1f ! if success, - mov %o3, %o0 ! set return value - ERROR() -1: - retl ! and update curbrk - st %o4, [%o2 + %lo(curbrk)] diff --git a/lib/libc/sparc/sys/setlogin.s b/lib/libc/sparc/sys/setlogin.s deleted file mode 100644 index 7f5dea3435af..000000000000 --- a/lib/libc/sparc/sys/setlogin.s +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: setlogin.s,v 1.1 91/07/06 13:06:00 torek Exp - * $Id: setlogin.s,v 1.1 1993/09/05 22:18:58 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)setlogin.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl __logname_valid /* in getlogin() */ - -SYSCALL(setlogin) - sethi %hi(__logname_valid), %g1 - retl - st %g0, [%g1 + %lo(__logname_valid)] diff --git a/lib/libc/sparc/sys/sigpending.s b/lib/libc/sparc/sys/sigpending.s deleted file mode 100644 index 1f0b7ec29783..000000000000 --- a/lib/libc/sparc/sys/sigpending.s +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: sigpending.s,v 1.1 91/07/06 13:06:00 torek Exp - * $Id: sigpending.s,v 1.1 1993/09/05 22:19:00 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)sigpending.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(sigpending) - mov %o0, %o2 ! save pointer - mov SYS_sigpending, %g1 - t ST_SYSCALL ! sigpending() - bcc,a 1f ! if success, - st %o0, [%o2] ! store return value - ERROR() -1: - retl ! and return 0 - clr %o0 diff --git a/lib/libc/sparc/sys/sigprocmask.s b/lib/libc/sparc/sys/sigprocmask.s deleted file mode 100644 index fb277dcc2683..000000000000 --- a/lib/libc/sparc/sys/sigprocmask.s +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: sigprocmask.s,v 1.1 91/07/06 13:06:01 torek Exp - * $Id: sigprocmask.s,v 1.1 1993/09/05 22:19:02 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)sigprocmask.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * sigprocmask(int how, sigset_t *set, sigset_t *oset) - */ -ENTRY(sigprocmask) - tst %o1 ! set == NULL? - bne,a 1f ! if not, - ld [%o1], %o1 ! replace it in %o1 with *set -! clr %o1 ! else block no signals ... - mov 1, %o0 ! ... using sigprocmask(SIG_BLOCK) -1: - mov SYS_sigprocmask, %g1 - t ST_SYSCALL - bcc 2f ! if success, - tst %o2 ! check to see if oset requested - ERROR() -2: - bne,a 3f ! if oset != NULL, - st %o0, [%o2] ! *oset = oldmask -3: - retl ! in any case, return 0 - clr %o0 diff --git a/lib/libc/sparc/sys/sigreturn.s b/lib/libc/sparc/sys/sigreturn.s deleted file mode 100644 index bc4b47bab9fe..000000000000 --- a/lib/libc/sparc/sys/sigreturn.s +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: sigreturn.s,v 1.1 91/07/06 13:06:01 torek Exp - * $Id: sigreturn.s,v 1.1 1993/09/05 22:19:04 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)sigreturn.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(sigreturn) - mov SYS_sigreturn, %g1 - t ST_SYSCALL - ERROR() diff --git a/lib/libc/sparc/sys/sigsuspend.s b/lib/libc/sparc/sys/sigsuspend.s deleted file mode 100644 index f5cf2499bcfc..000000000000 --- a/lib/libc/sparc/sys/sigsuspend.s +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: sigsuspend.s,v 1.1 91/07/06 13:06:01 torek Exp - * $Id: sigsuspend.s,v 1.1 1993/09/05 22:19:05 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)sigsuspend.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(sigsuspend) - ld [%o0], %o0 ! indirect to mask argument - mov SYS_sigsuspend, %g1 - t ST_SYSCALL - ERROR() ! always terminates with EINTR diff --git a/lib/libc/sparc/sys/syscall.s b/lib/libc/sparc/sys/syscall.s deleted file mode 100644 index 572ec1ffd021..000000000000 --- a/lib/libc/sparc/sys/syscall.s +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: syscall.s,v 1.1 91/07/06 13:06:02 torek Exp - * $Id: syscall.s,v 1.1 1993/09/05 22:19:07 deraadt Exp $ - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)syscall.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(syscall) - mov 0|SYSCALL_G2RFLAG, %g1 ! 0 == indir - add %o7, 8, %g2 - t ST_SYSCALL - ERROR() diff --git a/lib/libc/sys/uname.2 b/lib/libc/sys/uname.2 deleted file mode 100644 index 0963da3210b2..000000000000 --- a/lib/libc/sys/uname.2 +++ /dev/null @@ -1,101 +0,0 @@ -.\" Copyright (c) 1983, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)uname.2 6.6 (Berkeley) 3/10/91 -.\" $Id: uname.2,v 1.5 1993/12/15 20:40:38 jtc Exp $ -.\" -.Dd March 29, 1993 -.Dt UNAME 2 -.Os -.Sh NAME -.Nm uname -.Nd get host information -.Sh SYNOPSIS -.Fd #include -.Ft int -.Fn uname "struct utsname *name" -.Sh DESCRIPTION -.Fn Uname -returns the information identifying the current UNIX system -in the structure pointed to by -.Fa name. -.Pp -.Fn Uname -uses the structure defined in -.Aq Pa sys/utsname.h -whose members are: -.Bd -literal -struct utsname { - char sysname[SYS_NMLN]; - char nodename[SYS_NMLN]; - char release[SYS_NMLN]; - char version[SYS_NMLN]; - char machine[SYS_NMLN]; -}; -.Ed -.Pp -.Fn Uname -returns a null-terminated character string naming the -current UNIX system in the character array -.Fa sysname . -Similarly, -.Fa nodename -contains the name that the system is known by on a -communication network. -.Fa Release -and -.Fa version -further identify the operating system. -.Fa Machine -contains the standard name that identifies the hardware -that the UNIX system is running on. -.Sh RETURN VALUE -Upon successful completion a value of 0 is returned. -Otherwise, a value of -1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -.Bl -tag -width Er -.It Bq Er EFAULT -.Fn Uname -will fail if -.Fa name -points to an invalid address. -.El -.Sh SEE ALSO -.Xr hostname 1 , -.Xr machine 1 , -.Xr gethostname 2 -.Sh HISTORY -The -.Nm uname -function call appeared in -.At V.2 . diff --git a/lib/libcompat/4.3/m68k/insque.s b/lib/libcompat/4.3/m68k/insque.s deleted file mode 100644 index 6a3ce3274278..000000000000 --- a/lib/libcompat/4.3/m68k/insque.s +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)insque.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* insque(new, pred) */ - -#include "DEFS.h" - -ENTRY(insque) - movl sp@(8),a0 - movl sp@(4),a1 - movl a0@,a1@ - movl a0,a1@(4) - movl a1,a0@ - movl a1@,a0 - movl a1,a0@(4) - rts diff --git a/lib/libcompat/4.3/m68k/remque.s b/lib/libcompat/4.3/m68k/remque.s deleted file mode 100644 index a6502e1d7406..000000000000 --- a/lib/libcompat/4.3/m68k/remque.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)remque.s 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* remque(entry) */ - -#include "DEFS.h" - -ENTRY(remque) - movl sp@(4),a0 - movl a0@,a1 - movl a0@(4),a0 - movl a0,a1@(4) - movl a1,a0@ - rts diff --git a/lib/libm/common_source/atan.c b/lib/libm/common_source/atan.c deleted file mode 100644 index 8cadb7c385bb..000000000000 --- a/lib/libm/common_source/atan.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)atan.c 5.5 (Berkeley) 10/9/90";*/ -static char rcsid[] = "$Id: atan.c,v 1.3 1993/08/14 13:42:31 mycroft Exp $"; -#endif /* not lint */ - -/* ATAN(X) - * RETURNS ARC TANGENT OF X - * DOUBLE PRECISION (IEEE DOUBLE 53 bits, VAX D FORMAT 56 bits) - * CODED IN C BY K.C. NG, 4/16/85, REVISED ON 6/10/85. - * - * Required kernel function: - * atan2(y,x) - * - * Method: - * atan(x) = atan2(x,1.0). - * - * Special case: - * if x is NaN, return x itself. - * - * Accuracy: - * 1) If atan2() uses machine PI, then - * - * atan(x) returns (PI/pi) * (the exact arc tangent of x) nearly rounded; - * and PI is the exact pi rounded to machine precision (see atan2 for - * details): - * - * in decimal: - * pi = 3.141592653589793 23846264338327 ..... - * 53 bits PI = 3.141592653589793 115997963 ..... , - * 56 bits PI = 3.141592653589793 227020265 ..... , - * - * in hexadecimal: - * pi = 3.243F6A8885A308D313198A2E.... - * 53 bits PI = 3.243F6A8885A30 = 2 * 1.921FB54442D18 error=.276ulps - * 56 bits PI = 3.243F6A8885A308 = 4 * .C90FDAA22168C2 error=.206ulps - * - * In a test run with more than 200,000 random arguments on a VAX, the - * maximum observed error in ulps (units in the last place) was - * 0.86 ulps. (comparing against (PI/pi)*(exact atan(x))). - * - * 2) If atan2() uses true pi, then - * - * atan(x) returns the exact atan(x) with error below about 2 ulps. - * - * In a test run with more than 1,024,000 random arguments on a VAX, the - * maximum observed error in ulps (units in the last place) was - * 0.85 ulps. - */ - -double atan(x) -double x; -{ - double atan2(),one=1.0; - return(atan2(x,one)); -} diff --git a/lib/libm/common_source/atan2.3 b/lib/libm/common_source/atan2.3 deleted file mode 100644 index 79b0277d8f60..000000000000 --- a/lib/libm/common_source/atan2.3 +++ /dev/null @@ -1,189 +0,0 @@ -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)atan2.3 5.1 (Berkeley) 5/2/91 -.\" $Id: atan2.3,v 1.3 1993/08/14 13:42:32 mycroft Exp $ -.\" -.Dd May 2, 1991 -.Dt ATAN2 3 -.Os -.Sh NAME -.Nm atan2 -.Nd arc tangent function of two variables -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn atan2 "double y" "double x" -.Sh DESCRIPTION -The -.Xr atan2 -function computes the principal value of the arc tangent of -.Ar y/ Ns Ar x , -using the signs of both arguments to determine the quadrant of -the return value. -.Sh RETURN VALUES -The -.Xr atan2 -function, if successful, -returns the arc tangent of -.Ar y/ Ns Ar x -in the range -.Bk -words -.Bq \&- Ns \*(Pi , \&+ Ns \*(Pi -.Ek -radians. -If both -.Ar x -and -.Ar y -are zero, the global variable -.Va errno -is set to -.Er EDOM . -On the -.Tn VAX : -.Bl -column atan_(y,x)_:=____ sign(y)_(Pi_atan2(Xy_xX))___ -.It Fn atan2 y x No := Ta -.Fn atan y/x Ta -if -.Ar x -> 0, -.It Ta sign( Ns Ar y Ns )*(\*(Pi - -.Fn atan "\\*(Bay/x\\*(Ba" ) Ta -if -.Ar x -< 0, -.It Ta -.No 0 Ta -if x = y = 0, or -.It Ta -.Pf sign( Ar y Ns )*\\*(Pi/2 Ta -if -.Ar x -= 0 \*(!= -.Ar y . -.El -.Sh NOTES -The function -.Fn atan2 -defines "if x > 0," -.Fn atan2 0 0 -= 0 on a -.Tn VAX -despite that previously -.Fn atan2 0 0 -may have generated an error message. -The reasons for assigning a value to -.Fn atan2 0 0 -are these: -.Bl -enum -offset indent -.It -Programs that test arguments to avoid computing -.Fn atan2 0 0 -must be indifferent to its value. -Programs that require it to be invalid are vulnerable -to diverse reactions to that invalidity on diverse computer systems. -.It -The -.Fn atan2 -function is used mostly to convert from rectangular (x,y) -to polar -.if n\ -(r,theta) -.if t\ -(r,\(*h) -coordinates that must satisfy x = -.if n\ -r\(**cos theta -.if t\ -r\(**cos\(*h -and y = -.if n\ -r\(**sin theta. -.if t\ -r\(**sin\(*h. -These equations are satisfied when (x=0,y=0) -is mapped to -.if n \ -(r=0,theta=0) -.if t \ -(r=0,\(*h=0) -on a VAX. In general, conversions to polar coordinates -should be computed thus: -.Bd -unfilled -offset indent -.if n \{\ -r := hypot(x,y); ... := sqrt(x\(**x+y\(**y) -theta := atan2(y,x). -.\} -.if t \{\ -r := hypot(x,y); ... := \(sr(x\u\s82\s10\d+y\u\s82\s10\d) -\(*h := atan2(y,x). -.\} -.Ed -.It -The foregoing formulas need not be altered to cope in a -reasonable way with signed zeros and infinities -on a machine that conforms to -.Tn IEEE 754 ; -the versions of -.Xr hypot 3 -and -.Fn atan2 -provided for -such a machine are designed to handle all cases. -That is why -.Fn atan2 \(+-0 \-0 -= \(+-\*(Pi -for instance. -In general the formulas above are equivalent to these: -.Bd -unfilled -offset indent -.if n \ -r := sqrt(x\(**x+y\(**y); if r = 0 then x := copysign(1,x); -.if t \ -r := \(sr(x\(**x+y\(**y);\0\0if r = 0 then x := copysign(1,x); -.Ed -.El -.Sh SEE ALSO -.Xr acos 3 , -.Xr asin 3 , -.Xr atan 3 , -.Xr cos 3 , -.Xr cosh 3 , -.Xr sin 3 , -.Xr sinh 3 , -.Xr tan 3 , -.Xr tanh 3 , -.Xr math 3 , -.Sh STANDARDS -The -.Fn atan2 -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/atanh.3 b/lib/libm/common_source/atanh.3 deleted file mode 100644 index 51318bca2120..000000000000 --- a/lib/libm/common_source/atanh.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" Copyright (c) 1985, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)atanh.3 5.2 (Berkeley) 5/6/91 -.\" $Id: atanh.3,v 1.4 1993/10/29 22:57:24 jtc Exp $ -.\" -.Dd May 6, 1991 -.Dt ATANH 3 -.Os BSD 4.3 -.Sh NAME -.Nm atanh -.Nd inverse hyperbolic tangent function -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn atanh "double x" -.Sh DESCRIPTION -The -.Fn atanh -function computes the inverse hyperbolic tangent -of the real -argument -.Ar x . -For a discussion of error due to roundoff, see -.Xr math 3 . -.Sh RETURN VALUES -The -.Fn atanh -function -returns the inverse hyperbolic tangent of -.Ar x -if successful. -On the -.Tn VAX -and -.Tn Tahoe , -if the argument has absolute value -bigger than or equal to 1, -.Fn atanh -sets the global variable -.Va errno -to -.Er EDOM -and -a reserved operand fault is generated. -.Sh SEE ALSO -.Xr acosh 3 , -.Xr asinh 3 , -.Xr exp 3 , -.Xr infnan 3 , -.Xr math 3 -.Sh HISTORY -The -.Fn atanh -function appeared in -.Bx 4.3 . diff --git a/lib/libm/common_source/atanh.c b/lib/libm/common_source/atanh.c deleted file mode 100644 index 0baf27839ee7..000000000000 --- a/lib/libm/common_source/atanh.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)atanh.c 5.6 (Berkeley) 10/9/90";*/ -static char rcsid[] = "$Id: atanh.c,v 1.3 1993/08/14 13:42:34 mycroft Exp $"; -#endif /* not lint */ - -/* ATANH(X) - * RETURN THE HYPERBOLIC ARC TANGENT OF X - * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 1/8/85; - * REVISED BY K.C. NG on 2/7/85, 3/7/85, 8/18/85. - * - * Required kernel function: - * log1p(x) ...return log(1+x) - * - * Method : - * Return - * 1 2x x - * atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) - * 2 1 - x 1 - x - * - * Special cases: - * atanh(x) is NaN if |x| > 1 with signal; - * atanh(NaN) is that NaN with no signal; - * atanh(+-1) is +-INF with signal. - * - * Accuracy: - * atanh(x) returns the exact hyperbolic arc tangent of x nearly rounded. - * In a test run with 512,000 random arguments on a VAX, the maximum - * observed error was 1.87 ulps (units in the last place) at - * x= -3.8962076028810414000e-03. - */ -#include "mathimpl.h" - -#if defined(vax)||defined(tahoe) -#include -#endif /* defined(vax)||defined(tahoe) */ - -double atanh(x) -double x; -{ - double z; - z = copysign(0.5,x); - x = copysign(x,1.0); -#if defined(vax)||defined(tahoe) - if (x == 1.0) { - return(copysign(1.0,z)*infnan(ERANGE)); /* sign(x)*INF */ - } -#endif /* defined(vax)||defined(tahoe) */ - x = x/(1.0-x); - return( z*log1p(x+x) ); -} diff --git a/lib/libm/common_source/ceil.3 b/lib/libm/common_source/ceil.3 deleted file mode 100644 index 60ad4f95f80b..000000000000 --- a/lib/libm/common_source/ceil.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)ceil.3 5.1 (Berkeley) 5/2/91 -.\" $Id: ceil.3,v 1.5 1993/10/29 17:10:08 jtc Exp $ -.\" -.Dd May 2, 1991 -.Dt CEIL 3 -.Os -.Sh NAME -.Nm ceil -.Nd smallest integral value not greater than x -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn ceil "double x" -.Sh DESCRIPTION -The -.Fn ceil -function computes the smallest integral value not less than -.Fa x . -.Sh RETURN VALUES -The -.Fn ceil -function returns the smallest integral value -expressed as a double. -.Sh SEE ALSO -.Xr abs 3 , -.Xr fabs 3 , -.Xr floor 3 , -.Xr ieee 3 , -.Xr rint 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn ceil -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/cos.3 b/lib/libm/common_source/cos.3 deleted file mode 100644 index b53c006b3531..000000000000 --- a/lib/libm/common_source/cos.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)cos.3 5.1 (Berkeley) 5/2/91 -.\" $Id: cos.3,v 1.5 1993/10/29 22:57:25 jtc Exp $ -.\" -.Dd May 2, 1991 -.Dt COS 3 -.Os -.Sh NAME -.Nm cos -.Nd cosine function -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn cos "double x" -.Sh DESCRIPTION -The -.Fn cos -function computes the cosine of -.Fa x -(measured in radians). -A large magnitude argument may yield a result with little or no -significance. -For a discussion of error due to roundoff, see -.Xr math 3 . -.Sh RETURN VALUES -The -.Fn cos -function returns the cosine value. -.Sh SEE ALSO -.Xr sin 3 , -.Xr tan 3 , -.Xr asin 3 , -.Xr acos 3 , -.Xr atan 3 , -.Xr atan2 3 , -.Xr sinh 3 , -.Xr cosh 3 , -.Xr tanh 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn cos -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/cosh.3 b/lib/libm/common_source/cosh.3 deleted file mode 100644 index 33cc9495e8d1..000000000000 --- a/lib/libm/common_source/cosh.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" Copyright (c) 1989, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)cosh.3 5.1 (Berkeley) 5/2/91 -.\" $Id: cosh.3,v 1.4 1993/10/29 22:57:26 jtc Exp $ -.\" -.Dd May 2, 1991 -.Dt COSH 3 -.Os -.Sh NAME -.Nm cosh -.Nd hyperbolic cosine function -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn cosh "double x" -.Sh DESCRIPTION -The -.Fn cosh -function computes the hyperbolic cosine of -.Fa x . -.Sh RETURN VALUES -The -.Fn cosh -function returns the hyperbolic cosine unless the magnitude -of -.Fa x -is too large; in this event, the global variable -.Va errno -is set to -.Er ERANGE . -.Sh SEE ALSO -.Xr acos 3 , -.Xr asin 3 , -.Xr atan 3 , -.Xr atan2 3 , -.Xr cos 3 , -.Xr sin 3 , -.Xr sinh 3 , -.Xr tan 3 , -.Xr tanh 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn cosh -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/cosh.c b/lib/libm/common_source/cosh.c deleted file mode 100644 index 4d775f5c7bdc..000000000000 --- a/lib/libm/common_source/cosh.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)cosh.c 5.6 (Berkeley) 10/9/90";*/ -static char rcsid[] = "$Id: cosh.c,v 1.3 1993/08/14 13:42:37 mycroft Exp $"; -#endif /* not lint */ - -/* COSH(X) - * RETURN THE HYPERBOLIC COSINE OF X - * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 1/8/85; - * REVISED BY K.C. NG on 2/8/85, 2/23/85, 3/7/85, 3/29/85, 4/16/85. - * - * Required system supported functions : - * copysign(x,y) - * scalb(x,N) - * - * Required kernel function: - * exp(x) - * exp__E(x,c) ...return exp(x+c)-1-x for |x|<0.3465 - * - * Method : - * 1. Replace x by |x|. - * 2. - * [ exp(x) - 1 ]^2 - * 0 <= x <= 0.3465 : cosh(x) := 1 + ------------------- - * 2*exp(x) - * - * exp(x) + 1/exp(x) - * 0.3465 <= x <= 22 : cosh(x) := ------------------- - * 2 - * 22 <= x <= lnovfl : cosh(x) := exp(x)/2 - * lnovfl <= x <= lnovfl+log(2) - * : cosh(x) := exp(x)/2 (avoid overflow) - * log(2)+lnovfl < x < INF: overflow to INF - * - * Note: .3465 is a number near one half of ln2. - * - * Special cases: - * cosh(x) is x if x is +INF, -INF, or NaN. - * only cosh(0)=1 is exact for finite x. - * - * Accuracy: - * cosh(x) returns the exact hyperbolic cosine of x nearly rounded. - * In a test run with 768,000 random arguments on a VAX, the maximum - * observed error was 1.23 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(mln2hi, 8.8029691931113054792E1 ,0f33,43b0,2bdb,c7e2, 7, .B00F33C7E22BDB) -vc(mln2lo,-4.9650192275318476525E-16 ,1b60,a70f,582a,279e, -50,-.8F1B60279E582A) -vc(lnovfl, 8.8029691931113053016E1 ,0f33,43b0,2bda,c7e2, 7, .B00F33C7E22BDA) - -ic(mln2hi, 7.0978271289338397310E2, 10, 1.62E42FEFA39EF) -ic(mln2lo, 2.3747039373786107478E-14, -45, 1.ABC9E3B39803F) -ic(lnovfl, 7.0978271289338397310E2, 9, 1.62E42FEFA39EF) - -#ifdef vccast -#define mln2hi vccast(mln2hi) -#define mln2lo vccast(mln2lo) -#define lnovfl vccast(lnovfl) -#endif - -#if defined(vax)||defined(tahoe) -static max = 126 ; -#else /* defined(vax)||defined(tahoe) */ -static max = 1023 ; -#endif /* defined(vax)||defined(tahoe) */ - -double cosh(x) -double x; -{ - static const double half=1.0/2.0, - one=1.0, small=1.0E-18; /* fl(1+small)==1 */ - double t; - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - if((x=copysign(x,one)) <= 22) - if(x<0.3465) - if(x -.Ft double -.Fn erf "double x" -.Ft double -.Fn erfc "double x" -.Sh DESCRIPTION -These functions calculate the error function of -.Fa x . -.Pp -The -.Fn erf -calculates the error function of x; where -.Bd -filled -offset indent -.if n \{\ -erf(x) = 2/sqrt(pi)\(**\|integral from 0 to x of exp(\-t\(**t) dt. \} -.if t \{\ -erf\|(x) := -(2/\(sr\(*p)\|\(is\d\s8\z0\s10\u\u\s8x\s10\d\|exp(\-t\u\s82\s10\d)\|dt. \} -.Ed -.Pp -The -.Fn erfc -function calculates the complementary error function of -.Fa x ; -that is -.Fn erfc -subtracts the result of the error function -.Fn erf x -from 1.0. -This is useful, since for large -.Fa x -places disappear. -.Sh SEE ALSO -.Xr math 3 -.Sh HISTORY -The -.Fn erf -and -.Fn erfc -functions appeared in -.Bx 4.3 . diff --git a/lib/libm/common_source/erf.c b/lib/libm/common_source/erf.c deleted file mode 100644 index 7367d963d52d..000000000000 --- a/lib/libm/common_source/erf.c +++ /dev/null @@ -1,397 +0,0 @@ -/*- - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)erf.c 5.7 (Berkeley) 12/16/92";*/ -static char rcsid[] = "$Id: erf.c,v 1.1 1993/08/14 13:42:39 mycroft Exp $"; -#endif /* not lint */ - -/* Modified Nov 30, 1992 P. McILROY: - * Replaced expansions for x >= 1.25 (error 1.7ulp vs ~6ulp) - * Replaced even+odd with direct calculation for x < .84375, - * to avoid destructive cancellation. - * - * Performance of erfc(x): - * In 300000 trials in the range [.83, .84375] the - * maximum observed error was 3.6ulp. - * - * In [.84735,1.25] the maximum observed error was <2.5ulp in - * 100000 runs in the range [1.2, 1.25]. - * - * In [1.25,26] (Not including subnormal results) - * the error is < 1.7ulp. - */ - -/* double erf(double x) - * double erfc(double x) - * x - * 2 |\ - * erf(x) = --------- | exp(-t*t)dt - * sqrt(pi) \| - * 0 - * - * erfc(x) = 1-erf(x) - * - * Method: - * 1. Reduce x to |x| by erf(-x) = -erf(x) - * 2. For x in [0, 0.84375] - * erf(x) = x + x*P(x^2) - * erfc(x) = 1 - erf(x) if x<=0.25 - * = 0.5 + ((0.5-x)-x*P) if x in [0.25,0.84375] - * where - * 2 2 4 20 - * P = P(x ) = (p0 + p1 * x + p2 * x + ... + p10 * x ) - * is an approximation to (erf(x)-x)/x with precision - * - * -56.45 - * | P - (erf(x)-x)/x | <= 2 - * - * - * Remark. The formula is derived by noting - * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) - * and that - * 2/sqrt(pi) = 1.128379167095512573896158903121545171688 - * is close to one. The interval is chosen because the fixed - * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is - * near 0.6174), and by some experiment, 0.84375 is chosen to - * guarantee the error is less than one ulp for erf. - * - * 3. For x in [0.84375,1.25], let s = x - 1, and - * c = 0.84506291151 rounded to single (24 bits) - * erf(x) = c + P1(s)/Q1(s) - * erfc(x) = (1-c) - P1(s)/Q1(s) - * |P1/Q1 - (erf(x)-c)| <= 2**-59.06 - * Remark: here we use the taylor series expansion at x=1. - * erf(1+s) = erf(1) + s*Poly(s) - * = 0.845.. + P1(s)/Q1(s) - * That is, we use rational approximation to approximate - * erf(1+s) - (c = (single)0.84506291151) - * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25] - * where - * P1(s) = degree 6 poly in s - * Q1(s) = degree 6 poly in s - * - * 4. For x in [1.25, 2]; [2, 4] - * erf(x) = 1.0 - tiny - * erfc(x) = (1/x)exp(-x*x-(.5*log(pi) -.5z + R(z)/S(z)) - * - * Where z = 1/(x*x), R is degree 9, and S is degree 3; - * - * 5. For x in [4,28] - * erf(x) = 1.0 - tiny - * erfc(x) = (1/x)exp(-x*x-(.5*log(pi)+eps + zP(z)) - * - * Where P is degree 14 polynomial in 1/(x*x). - * - * Notes: - * Here 4 and 5 make use of the asymptotic series - * exp(-x*x) - * erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) ); - * x*sqrt(pi) - * - * where for z = 1/(x*x) - * P(z) ~ z/2*(-1 + z*3/2*(1 + z*5/2*(-1 + z*7/2*(1 +...)))) - * - * Thus we use rational approximation to approximate - * erfc*x*exp(x*x) ~ 1/sqrt(pi); - * - * The error bound for the target function, G(z) for - * the interval - * [4, 28]: - * |eps + 1/(z)P(z) - G(z)| < 2**(-56.61) - * for [2, 4]: - * |R(z)/S(z) - G(z)| < 2**(-58.24) - * for [1.25, 2]: - * |R(z)/S(z) - G(z)| < 2**(-58.12) - * - * 6. For inf > x >= 28 - * erf(x) = 1 - tiny (raise inexact) - * erfc(x) = tiny*tiny (raise underflow) - * - * 7. Special cases: - * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1, - * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2, - * erfc/erf(NaN) is NaN - */ - -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#define TRUNC(x) (double) (float) (x) -#else -#define _IEEE 1 -#define TRUNC(x) *(((int *) &x) + 1) &= 0xf8000000 -#define infnan(x) 0.0 -#endif - -#ifdef _IEEE_LIBM -/* - * redefining "___function" to "function" in _IEEE_LIBM mode - */ -#include "ieee_libm.h" -#endif - -static double -tiny = 1e-300, -half = 0.5, -one = 1.0, -two = 2.0, -c = 8.45062911510467529297e-01, /* (float)0.84506291151 */ -/* - * Coefficients for approximation to erf in [0,0.84375] - */ -p0t8 = 1.02703333676410051049867154944018394163280, -p0 = 1.283791670955125638123339436800229927041e-0001, -p1 = -3.761263890318340796574473028946097022260e-0001, -p2 = 1.128379167093567004871858633779992337238e-0001, -p3 = -2.686617064084433642889526516177508374437e-0002, -p4 = 5.223977576966219409445780927846432273191e-0003, -p5 = -8.548323822001639515038738961618255438422e-0004, -p6 = 1.205520092530505090384383082516403772317e-0004, -p7 = -1.492214100762529635365672665955239554276e-0005, -p8 = 1.640186161764254363152286358441771740838e-0006, -p9 = -1.571599331700515057841960987689515895479e-0007, -p10= 1.073087585213621540635426191486561494058e-0008; -/* - * Coefficients for approximation to erf in [0.84375,1.25] - */ -static double -pa0 = -2.362118560752659485957248365514511540287e-0003, -pa1 = 4.148561186837483359654781492060070469522e-0001, -pa2 = -3.722078760357013107593507594535478633044e-0001, -pa3 = 3.183466199011617316853636418691420262160e-0001, -pa4 = -1.108946942823966771253985510891237782544e-0001, -pa5 = 3.547830432561823343969797140537411825179e-0002, -pa6 = -2.166375594868790886906539848893221184820e-0003, -qa1 = 1.064208804008442270765369280952419863524e-0001, -qa2 = 5.403979177021710663441167681878575087235e-0001, -qa3 = 7.182865441419627066207655332170665812023e-0002, -qa4 = 1.261712198087616469108438860983447773726e-0001, -qa5 = 1.363708391202905087876983523620537833157e-0002, -qa6 = 1.198449984679910764099772682882189711364e-0002; -/* - * log(sqrt(pi)) for large x expansions. - * The tail (lsqrtPI_lo) is included in the rational - * approximations. -*/ -static double - lsqrtPI_hi = .5723649429247000819387380943226; -/* - * lsqrtPI_lo = .000000000000000005132975581353913; - * - * Coefficients for approximation to erfc in [2, 4] -*/ -static double -rb0 = -1.5306508387410807582e-010, /* includes lsqrtPI_lo */ -rb1 = 2.15592846101742183841910806188e-008, -rb2 = 6.24998557732436510470108714799e-001, -rb3 = 8.24849222231141787631258921465e+000, -rb4 = 2.63974967372233173534823436057e+001, -rb5 = 9.86383092541570505318304640241e+000, -rb6 = -7.28024154841991322228977878694e+000, -rb7 = 5.96303287280680116566600190708e+000, -rb8 = -4.40070358507372993983608466806e+000, -rb9 = 2.39923700182518073731330332521e+000, -rb10 = -6.89257464785841156285073338950e-001, -sb1 = 1.56641558965626774835300238919e+001, -sb2 = 7.20522741000949622502957936376e+001, -sb3 = 9.60121069770492994166488642804e+001; -/* - * Coefficients for approximation to erfc in [1.25, 2] -*/ -static double -rc0 = -2.47925334685189288817e-007, /* includes lsqrtPI_lo */ -rc1 = 1.28735722546372485255126993930e-005, -rc2 = 6.24664954087883916855616917019e-001, -rc3 = 4.69798884785807402408863708843e+000, -rc4 = 7.61618295853929705430118701770e+000, -rc5 = 9.15640208659364240872946538730e-001, -rc6 = -3.59753040425048631334448145935e-001, -rc7 = 1.42862267989304403403849619281e-001, -rc8 = -4.74392758811439801958087514322e-002, -rc9 = 1.09964787987580810135757047874e-002, -rc10 = -1.28856240494889325194638463046e-003, -sc1 = 9.97395106984001955652274773456e+000, -sc2 = 2.80952153365721279953959310660e+001, -sc3 = 2.19826478142545234106819407316e+001; -/* - * Coefficients for approximation to erfc in [4,28] - */ -static double -rd0 = -2.1491361969012978677e-016, /* includes lsqrtPI_lo */ -rd1 = -4.99999999999640086151350330820e-001, -rd2 = 6.24999999772906433825880867516e-001, -rd3 = -1.54166659428052432723177389562e+000, -rd4 = 5.51561147405411844601985649206e+000, -rd5 = -2.55046307982949826964613748714e+001, -rd6 = 1.43631424382843846387913799845e+002, -rd7 = -9.45789244999420134263345971704e+002, -rd8 = 6.94834146607051206956384703517e+003, -rd9 = -5.27176414235983393155038356781e+004, -rd10 = 3.68530281128672766499221324921e+005, -rd11 = -2.06466642800404317677021026611e+006, -rd12 = 7.78293889471135381609201431274e+006, -rd13 = -1.42821001129434127360582351685e+007; - -double erf(x) - double x; -{ - double R,S,P,Q,ax,s,y,z,r,fabs(),exp(); - if(!finite(x)) { /* erf(nan)=nan */ - if (isnan(x)) - return(x); - return (x > 0 ? one : -one); /* erf(+/-inf)= +/-1 */ - } - if ((ax = x) < 0) - ax = - ax; - if (ax < .84375) { - if (ax < 3.7e-09) { - if (ax < 1.0e-308) - return 0.125*(8.0*x+p0t8*x); /*avoid underflow */ - return x + p0*x; - } - y = x*x; - r = y*(p1+y*(p2+y*(p3+y*(p4+y*(p5+ - y*(p6+y*(p7+y*(p8+y*(p9+y*p10))))))))); - return x + x*(p0+r); - } - if (ax < 1.25) { /* 0.84375 <= |x| < 1.25 */ - s = fabs(x)-one; - P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); - Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); - if (x>=0) - return (c + P/Q); - else - return (-c - P/Q); - } - if (ax >= 6.0) { /* inf>|x|>=6 */ - if (x >= 0.0) - return (one-tiny); - else - return (tiny-one); - } - /* 1.25 <= |x| < 6 */ - z = -ax*ax; - s = -one/z; - if (ax < 2.0) { - R = rc0+s*(rc1+s*(rc2+s*(rc3+s*(rc4+s*(rc5+ - s*(rc6+s*(rc7+s*(rc8+s*(rc9+s*rc10))))))))); - S = one+s*(sc1+s*(sc2+s*sc3)); - } else { - R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+ - s*(rb6+s*(rb7+s*(rb8+s*(rb9+s*rb10))))))))); - S = one+s*(sb1+s*(sb2+s*sb3)); - } - y = (R/S -.5*s) - lsqrtPI_hi; - z += y; - z = exp(z)/ax; - if (x >= 0) - return (one-z); - else - return (z-one); -} - -double erfc(x) - double x; -{ - double R,S,P,Q,s,ax,y,z,r,fabs(),exp__D(); - if (!finite(x)) { - if (isnan(x)) /* erfc(NaN) = NaN */ - return(x); - else if (x > 0) /* erfc(+-inf)=0,2 */ - return 0.0; - else - return 2.0; - } - if ((ax = x) < 0) - ax = -ax; - if (ax < .84375) { /* |x|<0.84375 */ - if (ax < 1.38777878078144568e-17) /* |x|<2**-56 */ - return one-x; - y = x*x; - r = y*(p1+y*(p2+y*(p3+y*(p4+y*(p5+ - y*(p6+y*(p7+y*(p8+y*(p9+y*p10))))))))); - if (ax < .0625) { /* |x|<2**-4 */ - return (one-(x+x*(p0+r))); - } else { - r = x*(p0+r); - r += (x-half); - return (half - r); - } - } - if (ax < 1.25) { /* 0.84375 <= |x| < 1.25 */ - s = ax-one; - P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); - Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); - if (x>=0) { - z = one-c; return z - P/Q; - } else { - z = c+P/Q; return one+z; - } - } - if (ax >= 28) /* Out of range */ - if (x>0) - return (tiny*tiny); - else - return (two-tiny); - z = ax; - TRUNC(z); - y = z - ax; y *= (ax+z); - z *= -z; /* Here z + y = -x^2 */ - s = one/(-z-y); /* 1/(x*x) */ - if (ax >= 4) { /* 6 <= ax */ - R = s*(rd1+s*(rd2+s*(rd3+s*(rd4+s*(rd5+ - s*(rd6+s*(rd7+s*(rd8+s*(rd9+s*(rd10 - +s*(rd11+s*(rd12+s*rd13)))))))))))); - y += rd0; - } else if (ax >= 2) { - R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+ - s*(rb6+s*(rb7+s*(rb8+s*(rb9+s*rb10))))))))); - S = one+s*(sb1+s*(sb2+s*sb3)); - y += R/S; - R = -.5*s; - } else { - R = rc0+s*(rc1+s*(rc2+s*(rc3+s*(rc4+s*(rc5+ - s*(rc6+s*(rc7+s*(rc8+s*(rc9+s*rc10))))))))); - S = one+s*(sc1+s*(sc2+s*sc3)); - y += R/S; - R = -.5*s; - } - /* return exp(-x^2 - lsqrtPI_hi + R + y)/x; */ - s = ((R + y) - lsqrtPI_hi) + z; - y = (((z-s) - lsqrtPI_hi) + R) + y; - r = exp__D(s, y)/x; - if (x>0) - return r; - else - return two-r; -} diff --git a/lib/libm/common_source/exp.3 b/lib/libm/common_source/exp.3 deleted file mode 100644 index 329e662263b2..000000000000 --- a/lib/libm/common_source/exp.3 +++ /dev/null @@ -1,299 +0,0 @@ -.\" Copyright (c) 1985, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)exp.3 6.12 (Berkeley) 7/31/91 -.\" $Id: exp.3,v 1.6 1994/01/11 00:46:50 jtc Exp $ -.\" -.Dd July 31, 1991 -.Dt EXP 3 -.Os BSD 4 -.Sh NAME -.Nm exp , -.Nm exp2 , -.Nm exp10 , -.Nm expm1 , -.Nm log , -.Nm log2 , -.Nm log10 , -.Nm log1p , -.Nm pow -.Nd exponential, logarithm, power functions -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn exp "double x" -.Ft double -.Fn exp2 "double x" -.Ft double -.Fn exp10 "double x" -.Ft double -.Fn expm1 "double x" -.Ft double -.Fn log "double x" -.Ft double -.Fn log2 "double x" -.Ft double -.Fn log10 "double x" -.Ft double -.Fn log1p "double x" -.Ft double -.Fn pow "double x" "double y" -.Sh DESCRIPTION -The -.Fn exp -function computes the exponential value of the given argument -.Fa x . -.Pp -The -.Fn expm1 -function computes the value exp(x)\-1 accurately even for tiny argument -.Fa x . -.Pp -The -.Fn log -function computes the value of the natural logarithm of argument -.Fa x. -.Pp -The -.Fn log2 -function computes the value of the logarithm of argument -.Fa x -to base 2. -.Pp -The -.Fn log10 -function computes the value of the logarithm of argument -.Fa x -to base 10. -.Pp -The -.Fn log1p -function computes -the value of log(1+x) accurately even for tiny argument -.Fa x . -.Pp -The -.Fn pow -computes the value -of -.Ar x -to the exponent -.Ar y . -.Sh ERROR (due to Roundoff etc.) -exp(x), log(x), expm1(x) and log1p(x) are accurate to within -an -.Em ulp , -and log10(x) to within about 2 -.Em ulps ; -an -.Em ulp -is one -.Em Unit -in the -.Em Last -.Em Place . -The error in -.Fn pow x y -is below about 2 -.Em ulps -when its -magnitude is moderate, but increases as -.Fn pow x y -approaches -the over/underflow thresholds until almost as many bits could be -lost as are occupied by the floating\-point format's exponent -field; that is 8 bits for -.Tn "VAX D" -and 11 bits for IEEE 754 Double. -No such drastic loss has been exposed by testing; the worst -errors observed have been below 20 -.Em ulps -for -.Tn "VAX D" , -300 -.Em ulps -for -.Tn IEEE -754 Double. -Moderate values of -.Fn pow -are accurate enough that -.Fn pow integer integer -is exact until it is bigger than 2**56 on a -.Tn VAX , -2**53 for -.Tn IEEE -754. -.Sh RETURN VALUES -These functions will return the appropriate computation unless an error -occurs or an argument is out of range. -The functions -.Fn exp , -.Fn expm1 -and -.Fn pow -detect if the computed value will overflow, -set the global variable -.Va errno to -.Er ERANGE -and cause a reserved operand fault on a -.Tn VAX -or -.Tn Tahoe . -The function -.Fn pow x y -checks to see if -.Fa x -< 0 and -.Fa y -is not an integer, in the event this is true, -the global variable -.Va errno -is set to -.Er EDOM -and on the -.Tn VAX -and -.Tn Tahoe -generate a reserved operand fault. -On a -.Tn VAX -and -.Tn Tahoe , -.Va errno -is set to -.Er EDOM -and the reserved operand is returned -by log unless -.Fa x -> 0, by -.Fn log1p -unless -.Fa x -> \-1. -.Sh NOTES -The functions exp(x)\-1 and log(1+x) are called -expm1 and logp1 in -.Tn BASIC -on the Hewlett\-Packard -.Tn HP Ns \-71B -and -.Tn APPLE -Macintosh, -.Tn EXP1 -and -.Tn LN1 -in Pascal, exp1 and log1 in C -on -.Tn APPLE -Macintoshes, where they have been provided to make -sure financial calculations of ((1+x)**n\-1)/x, namely -expm1(n\(**log1p(x))/x, will be accurate when x is tiny. -They also provide accurate inverse hyperbolic functions. -.Pp -The function -.Fn pow x 0 -returns x**0 = 1 for all x including x = 0, -.if n \ -Infinity -.if t \ -\(if -(not found on a -.Tn VAX ) , -and -.Em NaN -(the reserved -operand on a -.Tn VAX ) . Previous implementations of pow may -have defined x**0 to be undefined in some or all of these -cases. Here are reasons for returning x**0 = 1 always: -.Bl -enum -width indent -.It -Any program that already tests whether x is zero (or -infinite or \*(Na) before computing x**0 cannot care -whether 0**0 = 1 or not. Any program that depends -upon 0**0 to be invalid is dubious anyway since that -expression's meaning and, if invalid, its consequences -vary from one computer system to another. -.It -Some Algebra texts (e.g. Sigler's) define x**0 = 1 for -all x, including x = 0. -This is compatible with the convention that accepts a[0] -as the value of polynomial -.Bd -literal -offset indent -p(x) = a[0]\(**x**0 + a[1]\(**x**1 + a[2]\(**x**2 +...+ a[n]\(**x**n -.Ed -.Pp -at x = 0 rather than reject a[0]\(**0**0 as invalid. -.It -Analysts will accept 0**0 = 1 despite that x**y can -approach anything or nothing as x and y approach 0 -independently. -The reason for setting 0**0 = 1 anyway is this: -.Bd -filled -offset indent -If x(z) and y(z) are -.Em any -functions analytic (expandable -in power series) in z around z = 0, and if there -x(0) = y(0) = 0, then x(z)**y(z) \(-> 1 as z \(-> 0. -.Ed -.It -If 0**0 = 1, then -.if n \ -infinity**0 = 1/0**0 = 1 too; and -.if t \ -\(if**0 = 1/0**0 = 1 too; and -then \*(Na**0 = 1 too because x**0 = 1 for all finite -and infinite x, i.e., independently of x. -.El -.Sh SEE ALSO -.Xr math 3 , -.Xr infnan 3 -.Sh HISTORY -A -.Fn exp , -.Fn log -and -.Fn pow -functions -appeared in -.At v6 . -A -.Fn log10 -function -appeared in -.At v7 . -The -.Fn log1p -and -.Fn expm1 -functions appeared in -.Bx 4.3 . diff --git a/lib/libm/common_source/exp.c b/lib/libm/common_source/exp.c deleted file mode 100644 index 8fe5ff29074e..000000000000 --- a/lib/libm/common_source/exp.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)exp.c 5.7 (Berkeley) 12/2/92";*/ -static char rcsid[] = "$Id: exp.c,v 1.5 1993/08/14 19:31:23 mycroft Exp $"; -#endif /* not lint */ - -/* EXP(X) - * RETURN THE EXPONENTIAL OF X - * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS) - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. NG on 2/6/85, 2/15/85, 3/7/85, 3/24/85, 4/16/85, 6/14/86. - * - * Required system supported functions: - * scalb(x,n) - * copysign(x,y) - * finite(x) - * - * Method: - * 1. Argument Reduction: given the input x, find r and integer k such - * that - * x = k*ln2 + r, |r| <= 0.5*ln2 . - * r will be represented as r := z+c for better accuracy. - * - * 2. Compute exp(r) by - * - * exp(r) = 1 + r + r*R1/(2-R1), - * where - * R1 = x - x^2*(p1+x^2*(p2+x^2*(p3+x^2*(p4+p5*x^2)))). - * - * 3. exp(x) = 2^k * exp(r) . - * - * Special cases: - * exp(INF) is INF, exp(NaN) is NaN; - * exp(-INF)= 0; - * for finite argument, only exp(0)=1 is exact. - * - * Accuracy: - * exp(x) returns the exponential of x nearly rounded. In a test run - * with 1,156,000 random arguments on a VAX, the maximum observed - * error was 0.869 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010) -vc(lntiny,-9.5654310917272452386E1 ,4f01,c3bf,33af,d72e, 7,-.BF4F01D72E33AF) -vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1) -vc(p1, 1.6666666666666602251E-1 ,aaaa,3f2a,a9f1,aaaa, -2, .AAAAAAAAAAA9F1) -vc(p2, -2.7777777777015591216E-3 ,0b60,bc36,ec94,b5f5, -8,-.B60B60B5F5EC94) -vc(p3, 6.6137563214379341918E-5 ,b355,398a,f15f,792e, -13, .8AB355792EF15F) -vc(p4, -1.6533902205465250480E-6 ,ea0e,b6dd,5f84,2e93, -19,-.DDEA0E2E935F84) -vc(p5, 4.1381367970572387085E-8 ,bb4b,3431,2683,95f5, -24, .B1BB4B95F52683) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define lnhuge vccast(lnhuge) -#define lntiny vccast(lntiny) -#define invln2 vccast(invln2) -#define p1 vccast(p1) -#define p2 vccast(p2) -#define p3 vccast(p3) -#define p4 vccast(p4) -#define p5 vccast(p5) -#endif - -ic(p1, 1.6666666666666601904E-1, -3, 1.555555555553E) -ic(p2, -2.7777777777015593384E-3, -9, -1.6C16C16BEBD93) -ic(p3, 6.6137563214379343612E-5, -14, 1.1566AAF25DE2C) -ic(p4, -1.6533902205465251539E-6, -20, -1.BBD41C5D26BF1) -ic(p5, 4.1381367970572384604E-8, -25, 1.6376972BEA4D0) -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76) -ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2) -ic(lntiny,-7.5137154372698068983E2, 9, -1.77AF8EBEAE354) -ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE) - -double exp(x) -double x; -{ - double z, hi, lo, t; - int k; - -#if !defined(vax)&&!defined(tahoe) - if (x != x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - - if (x <= lnhuge) { - if (x >= lntiny) { - - /* argument reduction : x --> x - k*ln2 */ - z = invln2 * x; - k = z + copysign(.5, x); - - /* express (x+c)-k*ln2 as hi-lo and let x=hi-lo rounded */ - hi = x - k * ln2hi; /* Exact. */ - x = hi - (lo = k * ln2lo); - - /* return 2^k*[1+x+x*c/(2+c)] */ - z = x * x; - t = x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5)))); - t = (x * t) / (2. - t); - - return scalb(1. + (hi - (lo - t)), k); - } - /* end of x > lntiny */ - - else - /* exp(-big#) underflows to zero */ - if (finite(x)) - return(scalb(1.0, -5000)); - - /* exp(-INF) is zero */ - else - return(0.0); - } - /* end of x < lnhuge */ - - else - /* exp(INF) is INF, exp(+big#) overflows to INF */ - if (finite(x)) - return(scalb(1.0, 5000)); - else - return(x); -} diff --git a/lib/libm/common_source/exp__D.c b/lib/libm/common_source/exp__D.c deleted file mode 100644 index 11b7b1c73590..000000000000 --- a/lib/libm/common_source/exp__D.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)exp.c 5.7 (Berkeley) 12/2/92";*/ -static char rcsid[] = "$Id: exp__D.c,v 1.2 1993/08/14 19:31:25 mycroft Exp $"; -#endif /* not lint */ - -/* EXP(X) - * RETURN THE EXPONENTIAL OF X - * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS) - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. NG on 2/6/85, 2/15/85, 3/7/85, 3/24/85, 4/16/85, 6/14/86. - * - * Required system supported functions: - * scalb(x,n) - * copysign(x,y) - * finite(x) - * - * Method: - * 1. Argument Reduction: given the input x, find r and integer k such - * that - * x = k*ln2 + r, |r| <= 0.5*ln2 . - * r will be represented as r := z+c for better accuracy. - * - * 2. Compute exp(r) by - * - * exp(r) = 1 + r + r*R1/(2-R1), - * where - * R1 = x - x^2*(p1+x^2*(p2+x^2*(p3+x^2*(p4+p5*x^2)))). - * - * 3. exp(x) = 2^k * exp(r) . - * - * Special cases: - * exp(INF) is INF, exp(NaN) is NaN; - * exp(-INF)= 0; - * for finite argument, only exp(0)=1 is exact. - * - * Accuracy: - * exp(x) returns the exponential of x nearly rounded. In a test run - * with 1,156,000 random arguments on a VAX, the maximum observed - * error was 0.869 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010) -vc(lntiny,-9.5654310917272452386E1 ,4f01,c3bf,33af,d72e, 7,-.BF4F01D72E33AF) -vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1) -vc(p1, 1.6666666666666602251E-1 ,aaaa,3f2a,a9f1,aaaa, -2, .AAAAAAAAAAA9F1) -vc(p2, -2.7777777777015591216E-3 ,0b60,bc36,ec94,b5f5, -8,-.B60B60B5F5EC94) -vc(p3, 6.6137563214379341918E-5 ,b355,398a,f15f,792e, -13, .8AB355792EF15F) -vc(p4, -1.6533902205465250480E-6 ,ea0e,b6dd,5f84,2e93, -19,-.DDEA0E2E935F84) -vc(p5, 4.1381367970572387085E-8 ,bb4b,3431,2683,95f5, -24, .B1BB4B95F52683) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define lnhuge vccast(lnhuge) -#define lntiny vccast(lntiny) -#define invln2 vccast(invln2) -#define p1 vccast(p1) -#define p2 vccast(p2) -#define p3 vccast(p3) -#define p4 vccast(p4) -#define p5 vccast(p5) -#endif - -ic(p1, 1.6666666666666601904E-1, -3, 1.555555555553E) -ic(p2, -2.7777777777015593384E-3, -9, -1.6C16C16BEBD93) -ic(p3, 6.6137563214379343612E-5, -14, 1.1566AAF25DE2C) -ic(p4, -1.6533902205465251539E-6, -20, -1.BBD41C5D26BF1) -ic(p5, 4.1381367970572384604E-8, -25, 1.6376972BEA4D0) -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76) -ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2) -ic(lntiny,-7.5137154372698068983E2, 9, -1.77AF8EBEAE354) -ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE) - -/* returns exp(r = x + c) for |c| < |x| with no overlap. */ - -double exp__D(x, c) -double x, c; -{ - double z, hi, lo, t; - int k; - -#if !defined(vax)&&!defined(tahoe) - if (x != x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - - if (x <= lnhuge) { - if (x >= lntiny) { - - /* argument reduction : x --> x - k*ln2 */ - z = invln2 * x; - k = z + copysign(.5, x); - - /* express (x+c)-k*ln2 as hi-lo and let x=hi-lo rounded */ - hi = x - k * ln2hi; /* Exact. */ - x = hi - (lo = k * ln2lo - c); - - /* return 2^k*[1+x+x*c/(2+c)] */ - z = x * x; - t = x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5)))); - t = (x * t) / (2. - t); - - return scalb(1. + (hi - (lo - t)), k); - } - /* end of x > lntiny */ - - else - /* exp(-big#) underflows to zero */ - if (finite(x)) - return(scalb(1.0, -5000)); - - /* exp(-INF) is zero */ - else - return(0.0); - } - /* end of x < lnhuge */ - - else - /* exp(INF) is INF, exp(+big#) overflows to INF */ - if (finite(x)) - return(scalb(1.0, 5000)); - else - return(x); -} diff --git a/lib/libm/common_source/exp__E.c b/lib/libm/common_source/exp__E.c deleted file mode 100644 index 260daf569993..000000000000 --- a/lib/libm/common_source/exp__E.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)exp__E.c 5.6 (Berkeley) 10/9/90";*/ -static char rcsid[] = "$Id: exp__E.c,v 1.3 1993/08/14 13:42:42 mycroft Exp $"; -#endif /* not lint */ - -/* exp__E(x,c) - * ASSUMPTION: c << x SO THAT fl(x+c)=x. - * (c is the correction term for x) - * exp__E RETURNS - * - * / exp(x+c) - 1 - x , 1E-19 < |x| < .3465736 - * exp__E(x,c) = | - * \ 0 , |x| < 1E-19. - * - * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS) - * KERNEL FUNCTION OF EXP, EXPM1, POW FUNCTIONS - * CODED IN C BY K.C. NG, 1/31/85; - * REVISED BY K.C. NG on 3/16/85, 4/16/85. - * - * Required system supported function: - * copysign(x,y) - * - * Method: - * 1. Rational approximation. Let r=x+c. - * Based on - * 2 * sinh(r/2) - * exp(r) - 1 = ---------------------- , - * cosh(r/2) - sinh(r/2) - * exp__E(r) is computed using - * x*x (x/2)*W - ( Q - ( 2*P + x*P ) ) - * --- + (c + x*[---------------------------------- + c ]) - * 2 1 - W - * where P := p1*x^2 + p2*x^4, - * Q := q1*x^2 + q2*x^4 (for 56 bits precision, add q3*x^6) - * W := x/2-(Q-x*P), - * - * (See the listing below for the values of p1,p2,q1,q2,q3. The poly- - * nomials P and Q may be regarded as the approximations to sinh - * and cosh : - * sinh(r/2) = r/2 + r * P , cosh(r/2) = 1 + Q . ) - * - * The coefficients were obtained by a special Remez algorithm. - * - * Approximation error: - * - * | exp(x) - 1 | 2**(-57), (IEEE double) - * | ------------ - (exp__E(x,0)+x)/x | <= - * | x | 2**(-69). (VAX D) - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(p1, 1.5150724356786683059E-2 ,3abe,3d78,066a,67e1, -6, .F83ABE67E1066A) -vc(p2, 6.3112487873718332688E-5 ,5b42,3984,0173,48cd, -13, .845B4248CD0173) -vc(q1, 1.1363478204690669916E-1 ,b95a,3ee8,ec45,44a2, -3, .E8B95A44A2EC45) -vc(q2, 1.2624568129896839182E-3 ,7905,3ba5,f5e7,72e4, -9, .A5790572E4F5E7) -vc(q3, 1.5021856115869022674E-6 ,9eb4,36c9,c395,604a, -19, .C99EB4604AC395) - -ic(p1, 1.3887401997267371720E-2, -7, 1.C70FF8B3CC2CF) -ic(p2, 3.3044019718331897649E-5, -15, 1.15317DF4526C4) -ic(q1, 1.1110813732786649355E-1, -4, 1.C719538248597) -ic(q2, 9.9176615021572857300E-4, -10, 1.03FC4CB8C98E8) - -#ifdef vccast -#define p1 vccast(p1) -#define p2 vccast(p2) -#define q1 vccast(q1) -#define q2 vccast(q2) -#define q3 vccast(q3) -#endif - -double exp__E(x,c) -double x,c; -{ - const static double zero=0.0, one=1.0, half=1.0/2.0, small=1.0E-19; - double z,p,q,xp,xh,w; - if(copysign(x,one)>small) { - z = x*x ; - p = z*( p1 +z* p2 ); -#if defined(vax)||defined(tahoe) - q = z*( q1 +z*( q2 +z* q3 )); -#else /* defined(vax)||defined(tahoe) */ - q = z*( q1 +z* q2 ); -#endif /* defined(vax)||defined(tahoe) */ - xp= x*p ; - xh= x*half ; - w = xh-(q-xp) ; - p = p+p; - c += x*((xh*w-(q-(p+xp)))/(one-w)+c); - return(z*half+c); - } - /* end of |x| > small */ - - else { - if(x!=zero) one+small; /* raise the inexact flag */ - return(copysign(zero,x)); - } -} diff --git a/lib/libm/common_source/expm1.c b/lib/libm/common_source/expm1.c deleted file mode 100644 index 25f2230588cc..000000000000 --- a/lib/libm/common_source/expm1.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)expm1.c 5.6 (Berkeley) 10/9/90";*/ -static char rcsid[] = "$Id: expm1.c,v 1.3 1993/08/14 13:42:43 mycroft Exp $"; -#endif /* not lint */ - -/* EXPM1(X) - * RETURN THE EXPONENTIAL OF X MINUS ONE - * DOUBLE PRECISION (IEEE 53 BITS, VAX D FORMAT 56 BITS) - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. NG on 2/6/85, 3/7/85, 3/21/85, 4/16/85. - * - * Required system supported functions: - * scalb(x,n) - * copysign(x,y) - * finite(x) - * - * Kernel function: - * exp__E(x,c) - * - * Method: - * 1. Argument Reduction: given the input x, find r and integer k such - * that - * x = k*ln2 + r, |r| <= 0.5*ln2 . - * r will be represented as r := z+c for better accuracy. - * - * 2. Compute EXPM1(r)=exp(r)-1 by - * - * EXPM1(r=z+c) := z + exp__E(z,c) - * - * 3. EXPM1(x) = 2^k * ( EXPM1(r) + 1-2^-k ). - * - * Remarks: - * 1. When k=1 and z < -0.25, we use the following formula for - * better accuracy: - * EXPM1(x) = 2 * ( (z+0.5) + exp__E(z,c) ) - * 2. To avoid rounding error in 1-2^-k where k is large, we use - * EXPM1(x) = 2^k * { [z+(exp__E(z,c)-2^-k )] + 1 } - * when k>56. - * - * Special cases: - * EXPM1(INF) is INF, EXPM1(NaN) is NaN; - * EXPM1(-INF)= -1; - * for finite argument, only EXPM1(0)=0 is exact. - * - * Accuracy: - * EXPM1(x) returns the exact (exp(x)-1) nearly rounded. In a test run with - * 1,166,000 random arguments on a VAX, the maximum observed error was - * .872 ulps (units of the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010) -vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1) - -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) -ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2) -ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define lnhuge vccast(lnhuge) -#define invln2 vccast(invln2) -#endif - -double expm1(x) -double x; -{ - const static double one=1.0, half=1.0/2.0; - double z,hi,lo,c; - int k; -#if defined(vax)||defined(tahoe) - static prec=56; -#else /* defined(vax)||defined(tahoe) */ - static prec=53; -#endif /* defined(vax)||defined(tahoe) */ - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - - if( x <= lnhuge ) { - if( x >= -40.0 ) { - - /* argument reduction : x - k*ln2 */ - k= invln2 *x+copysign(0.5,x); /* k=NINT(x/ln2) */ - hi=x-k*ln2hi ; - z=hi-(lo=k*ln2lo); - c=(hi-z)-lo; - - if(k==0) return(z+exp__E(z,c)); - if(k==1) - if(z< -0.25) - {x=z+half;x +=exp__E(z,c); return(x+x);} - else - {z+=exp__E(z,c); x=half+z; return(x+x);} - /* end of k=1 */ - - else { - if(k<=prec) - { x=one-scalb(one,-k); z += exp__E(z,c);} - else if(k<100) - { x = exp__E(z,c)-scalb(one,-k); x+=z; z=one;} - else - { x = exp__E(z,c)+z; z=one;} - - return (scalb(x+z,k)); - } - } - /* end of x > lnunfl */ - - else - /* expm1(-big#) rounded to -1 (inexact) */ - if(finite(x)) - { ln2hi+ln2lo; return(-one);} - - /* expm1(-INF) is -1 */ - else return(-one); - } - /* end of x < lnhuge */ - - else - /* expm1(INF) is INF, expm1(+big#) overflows to INF */ - return( finite(x) ? scalb(one,5000) : x); -} diff --git a/lib/libm/common_source/fabs.3 b/lib/libm/common_source/fabs.3 deleted file mode 100644 index 58d440091ff7..000000000000 --- a/lib/libm/common_source/fabs.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" @(#)fabs.3 5.1 (Berkeley) 5/2/91 -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)fabs.3 5.1 (Berkeley) 5/2/91 -.\" $Id: fabs.3,v 1.4 1993/10/04 18:04:34 jtc Exp $ -.\" -.Dd May 2, 1991 -.Dt FABS 3 -.Os -.Sh NAME -.Nm fabs -.Nd floating-point absolute value function -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn fabs "double x" -.Sh DESCRIPTION -The -.Fn fabs -function computes the absolute value of a floating-point number -.Fa x . -.Sh RETURN VALUES -The -.Fn fabs -function returns the absolute value of -.Fa x . -.Sh SEE ALSO -.Xr abs 3 , -.Xr ceil 3 , -.Xr floor 3 , -.Xr rint 3 , -.Xr ieee 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn fabs -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/floor.3 b/lib/libm/common_source/floor.3 deleted file mode 100644 index 81207ff6dc29..000000000000 --- a/lib/libm/common_source/floor.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" Copyright (c) 1985, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)floor.3 6.5 (Berkeley) 4/19/91 -.\" $Id: floor.3,v 1.4 1993/10/29 17:10:11 jtc Exp $ -.\" -.Dd April 19, 1991 -.Dt FLOOR 3 -.Os -.Sh NAME -.Nm floor -.Nd largest integral value not greater than x -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn floor "double x" -.Sh DESCRIPTION -The -.Fn floor -function computes the largest integral value not greater than -.Fa x . -.Sh RETURN VALUES -The -.Fn floor -function returns the largest integral value -expressed as a double. -.Sh SEE ALSO -.Xr abs 3 , -.Xr ceil 3 , -.Xr fabs 3 , -.Xr ieee 3 , -.Xr rint 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn floor -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/floor.c b/lib/libm/common_source/floor.c deleted file mode 100644 index 86dd53aa9eca..000000000000 --- a/lib/libm/common_source/floor.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)floor.c 5.8 (Berkeley) 10/1/92";*/ -static char rcsid[] = "$Id: floor.c,v 1.5 1993/08/14 13:42:45 mycroft Exp $"; -#endif /* not lint */ - -#include "mathimpl.h" - -vc(L, 4503599627370496.0E0 ,0000,5c00,0000,0000, 55, 1.0) /* 2**55 */ - -ic(L, 4503599627370496.0E0, 52, 1.0) /* 2**52 */ - -#ifdef vccast -#define L vccast(L) -#endif - -/* - * floor(x) := the largest integer no larger than x; - * ceil(x) := -floor(-x), for all real x. - * - * Note: Inexact will be signaled if x is not an integer, as is - * customary for IEEE 754. No other signal can be emitted. - */ -double -floor(x) -double x; -{ - volatile double y; - - if ( -#if !defined(vax)&&!defined(tahoe) - x != x || /* NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - x >= L) /* already an even integer */ - return x; - else if (x < (double)0) - return -ceil(-x); - else { /* now 0 <= x < L */ - y = L+x; /* destructive store must be forced */ - y -= L; /* an integer, and |x-y| < 1 */ - return x < y ? y-(double)1 : y; - } -} - -double -ceil(x) -double x; -{ - volatile double y; - - if ( -#if !defined(vax)&&!defined(tahoe) - x != x || /* NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - x >= L) /* already an even integer */ - return x; - else if (x < (double)0) - return -floor(-x); - else { /* now 0 <= x < L */ - y = L+x; /* destructive store must be forced */ - y -= L; /* an integer, and |x-y| < 1 */ - return x > y ? y+(double)1 : y; - } -} - -#ifndef ns32000 /* rint() is in ./NATIONAL/support.s */ -/* - * algorithm for rint(x) in pseudo-pascal form ... - * - * real rint(x): real x; - * ... delivers integer nearest x in direction of prevailing rounding - * ... mode - * const L = (last consecutive integer)/2 - * = 2**55; for VAX D - * = 2**52; for IEEE 754 Double - * real s,t; - * begin - * if x != x then return x; ... NaN - * if |x| >= L then return x; ... already an integer - * s := copysign(L,x); - * t := x + s; ... = (x+s) rounded to integer - * return t - s - * end; - * - * Note: Inexact will be signaled if x is not an integer, as is - * customary for IEEE 754. No other signal can be emitted. - */ -double -rint(x) -double x; -{ - double s; - volatile double t; - const double one = 1.0; - -#if !defined(vax)&&!defined(tahoe) - if (x != x) /* NaN */ - return (x); -#endif /* !defined(vax)&&!defined(tahoe) */ - if (copysign(x,one) >= L) /* already an integer */ - return (x); - s = copysign(L,x); - t = x + s; /* x+s rounded to integer */ - return (t - s); -} -#endif /* not national */ diff --git a/lib/libm/common_source/fmod.3 b/lib/libm/common_source/fmod.3 deleted file mode 100644 index 51526029adaf..000000000000 --- a/lib/libm/common_source/fmod.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)fmod.3 5.1 (Berkeley) 5/2/91 -.\" $Id: fmod.3,v 1.3 1993/08/14 13:42:46 mycroft Exp $ -.\" -.Dd May 2, 1991 -.Dt FMOD 3 -.Os -.Sh NAME -.Nm fmod -.Nd floating-point remainder function -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn fmod "double x" "double y" -.Sh DESCRIPTION -The -.Fn fmod -function computes the floating-point remainder of -.Fa x Ns / Fa y . -.Sh RETURN VALUES -The -.Fn fmod -function returns the value -.Sm off -.Fa x - Em i * Fa y , -.Sm on -for some integer -.Em i -such that, if -.Fa y -is non-zero, the result has the same sign as -.Fa x -and magnitude less than the magnitude of -.Fa y . -If -.Fa y -is zero, whether a domain error occurs or the -.Fn fmod -function returns zero is implementation-defined. -.Sh SEE ALSO -.Xr math 3 -.Sh STANDARDS -The -.Fn fmod -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/fmod.c b/lib/libm/common_source/fmod.c deleted file mode 100644 index 219591b00ee6..000000000000 --- a/lib/libm/common_source/fmod.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)fmod.c 5.2 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$Id: fmod.c,v 1.3 1993/08/14 13:42:47 mycroft Exp $"; -#endif /* not lint */ - -/* fmod.c - * - * SYNOPSIS - * - * #include - * double fmod(double x, double y) - * - * DESCRIPTION - * - * The fmod function computes the floating-point remainder of x/y. - * - * RETURNS - * - * The fmod function returns the value x-i*y, for some integer i - * such that, if y is nonzero, the result has the same sign as x and - * magnitude less than the magnitude of y. - * - * On a VAX or CCI, - * - * fmod(x,0) traps/faults on floating-point divided-by-zero. - * - * On IEEE-754 conforming machines with "isnan()" primitive, - * - * fmod(x,0), fmod(INF,y) are invalid operations and NaN is returned. - * - */ -#if !defined(vax) && !defined(tahoe) -extern int isnan(),finite(); -#endif /* !defined(vax) && !defined(tahoe) */ -extern double frexp(),ldexp(),fabs(); - -#ifdef TEST_FMOD -static double -_fmod(x,y) -#else /* TEST_FMOD */ -double -fmod(x,y) -#endif /* TEST_FMOD */ -double x,y; -{ - int ir,iy; - double r,w; - - if (y == (double)0 -#if !defined(vax) && !defined(tahoe) /* per "fmod" manual entry, SunOS 4.0 */ - || isnan(y) || !finite(x) -#endif /* !defined(vax) && !defined(tahoe) */ - ) - return (x*y)/(x*y); - - r = fabs(x); - y = fabs(y); - (void)frexp(y,&iy); - while (r >= y) { - (void)frexp(r,&ir); - w = ldexp(y,ir-iy); - r -= w <= r ? w : w*(double)0.5; - } - return x >= (double)0 ? r : -r; -} - -#ifdef TEST_FMOD -extern long random(); -extern double fmod(); - -#define NTEST 10000 -#define NCASES 3 - -static int nfail = 0; - -static void -doit(x,y) -double x,y; -{ - double ro = fmod(x,y),rn = _fmod(x,y); - if (ro != rn) { - (void)printf(" x = 0x%08.8x %08.8x (%24.16e)\n",x,x); - (void)printf(" y = 0x%08.8x %08.8x (%24.16e)\n",y,y); - (void)printf(" fmod = 0x%08.8x %08.8x (%24.16e)\n",ro,ro); - (void)printf("_fmod = 0x%08.8x %08.8x (%24.16e)\n",rn,rn); - (void)printf("\n"); - } -} - -main() -{ - register int i,cases; - double x,y; - - srandom(12345); - for (i = 0; i < NTEST; i++) { - x = (double)random(); - y = (double)random(); - for (cases = 0; cases < NCASES; cases++) { - switch (cases) { - case 0: - break; - case 1: - y = (double)1/y; break; - case 2: - x = (double)1/x; break; - default: - abort(); break; - } - doit(x,y); - doit(x,-y); - doit(-x,y); - doit(-x,-y); - } - } - if (nfail) - (void)printf("Number of failures: %d (out of a total of %d)\n", - nfail,NTEST*NCASES*4); - else - (void)printf("No discrepancies were found\n"); - exit(0); -} -#endif /* TEST_FMOD */ diff --git a/lib/libm/common_source/gamma.c b/lib/libm/common_source/gamma.c deleted file mode 100644 index 16cd2864126d..000000000000 --- a/lib/libm/common_source/gamma.c +++ /dev/null @@ -1,337 +0,0 @@ -/*- - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)gamma.c 5.3 (Berkeley) 12/16/92";*/ -static char rcsid[] = "$Id: gamma.c,v 1.1 1993/08/14 13:42:47 mycroft Exp $"; -#endif /* not lint */ - -/* - * This code by P. McIlroy, Oct 1992; - * - * The financial support of UUNET Communications Services is greatfully - * acknowledged. - */ - -#include -#include "mathimpl.h" -#include - -/* METHOD: - * x < 0: Use reflection formula, G(x) = pi/(sin(pi*x)*x*G(x)) - * At negative integers, return +Inf, and set errno. - * - * x < 6.5: - * Use argument reduction G(x+1) = xG(x) to reach the - * range [1.066124,2.066124]. Use a rational - * approximation centered at the minimum (x0+1) to - * ensure monotonicity. - * - * x >= 6.5: Use the asymptotic approximation (Stirling's formula) - * adjusted for equal-ripples: - * - * log(G(x)) ~= (x-.5)*(log(x)-1) + .5(log(2*pi)-1) + 1/x*P(1/(x*x)) - * - * Keep extra precision in multiplying (x-.5)(log(x)-1), to - * avoid premature round-off. - * - * Special values: - * non-positive integer: Set overflow trap; return +Inf; - * x > 171.63: Set overflow trap; return +Inf; - * NaN: Set invalid trap; return NaN - * - * Accuracy: Gamma(x) is accurate to within - * x > 0: error provably < 0.9ulp. - * Maximum observed in 1,000,000 trials was .87ulp. - * x < 0: - * Maximum observed error < 4ulp in 1,000,000 trials. - */ - -static double neg_gam __P((double)); -static double small_gam __P((double)); -static double smaller_gam __P((double)); -static struct Double large_gam __P((double)); -static struct Double ratfun_gam __P((double, double)); - -/* - * Rational approximation, A0 + x*x*P(x)/Q(x), on the interval - * [1.066.., 2.066..] accurate to 4.25e-19. - */ -#define LEFT -.3955078125 /* left boundary for rat. approx */ -#define x0 .461632144968362356785 /* xmin - 1 */ - -#define a0_hi 0.88560319441088874992 -#define a0_lo -.00000000000000004996427036469019695 -#define P0 6.21389571821820863029017800727e-01 -#define P1 2.65757198651533466104979197553e-01 -#define P2 5.53859446429917461063308081748e-03 -#define P3 1.38456698304096573887145282811e-03 -#define P4 2.40659950032711365819348969808e-03 -#define Q0 1.45019531250000000000000000000e+00 -#define Q1 1.06258521948016171343454061571e+00 -#define Q2 -2.07474561943859936441469926649e-01 -#define Q3 -1.46734131782005422506287573015e-01 -#define Q4 3.07878176156175520361557573779e-02 -#define Q5 5.12449347980666221336054633184e-03 -#define Q6 -1.76012741431666995019222898833e-03 -#define Q7 9.35021023573788935372153030556e-05 -#define Q8 6.13275507472443958924745652239e-06 -/* - * Constants for large x approximation (x in [6, Inf]) - * (Accurate to 2.8*10^-19 absolute) - */ -#define lns2pi_hi 0.418945312500000 -#define lns2pi_lo -.000006779295327258219670263595 -#define Pa0 8.33333333333333148296162562474e-02 -#define Pa1 -2.77777777774548123579378966497e-03 -#define Pa2 7.93650778754435631476282786423e-04 -#define Pa3 -5.95235082566672847950717262222e-04 -#define Pa4 8.41428560346653702135821806252e-04 -#define Pa5 -1.89773526463879200348872089421e-03 -#define Pa6 5.69394463439411649408050664078e-03 -#define Pa7 -1.44705562421428915453880392761e-02 - -static const double zero = 0., one = 1.0, tiny = 1e-300; -static int endian; -/* - * TRUNC sets trailing bits in a floating-point number to zero. - * is a temporary variable. - */ -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#define TRUNC(x) x = (double) (float) (x) -#else -#define _IEEE 1 -#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000 -#define infnan(x) 0.0 -#endif - -double -gamma(x) - double x; -{ - struct Double u; - endian = (*(int *) &one) ? 1 : 0; - - if (x >= 6) { - if(x > 171.63) - return(one/zero); - u = large_gam(x); - return(exp__D(u.a, u.b)); - } else if (x >= 1.0 + LEFT + x0) - return (small_gam(x)); - else if (x > 1.e-17) - return (smaller_gam(x)); - else if (x > -1.e-17) { - if (x == 0.0) - if (!_IEEE) return (infnan(ERANGE)); - else return (one/x); - one+1e-20; /* Raise inexact flag. */ - return (one/x); - } else if (!finite(x)) { - if (_IEEE) /* x = NaN, -Inf */ - return (x*x); - else - return (infnan(EDOM)); - } else - return (neg_gam(x)); -} -/* - * Accurate to max(ulp(1/128) absolute, 2^-66 relative) error. - */ -static struct Double -large_gam(x) - double x; -{ - double z, p; - int i; - struct Double t, u, v; - - z = one/(x*x); - p = Pa0+z*(Pa1+z*(Pa2+z*(Pa3+z*(Pa4+z*(Pa5+z*(Pa6+z*Pa7)))))); - p = p/x; - - u = log__D(x); - u.a -= one; - v.a = (x -= .5); - TRUNC(v.a); - v.b = x - v.a; - t.a = v.a*u.a; /* t = (x-.5)*(log(x)-1) */ - t.b = v.b*u.a + x*u.b; - /* return t.a + t.b + lns2pi_hi + lns2pi_lo + p */ - t.b += lns2pi_lo; t.b += p; - u.a = lns2pi_hi + t.b; u.a += t.a; - u.b = t.a - u.a; - u.b += lns2pi_hi; u.b += t.b; - return (u); -} -/* - * Good to < 1 ulp. (provably .90 ulp; .87 ulp on 1,000,000 runs.) - * It also has correct monotonicity. - */ -static double -small_gam(x) - double x; -{ - double y, ym1, t, x1; - struct Double yy, r; - y = x - one; - ym1 = y - one; - if (y <= 1.0 + (LEFT + x0)) { - yy = ratfun_gam(y - x0, 0); - return (yy.a + yy.b); - } - r.a = y; - TRUNC(r.a); - yy.a = r.a - one; - y = ym1; - yy.b = r.b = y - yy.a; - /* Argument reduction: G(x+1) = x*G(x) */ - for (ym1 = y-one; ym1 > LEFT + x0; y = ym1--, yy.a--) { - t = r.a*yy.a; - r.b = r.a*yy.b + y*r.b; - r.a = t; - TRUNC(r.a); - r.b += (t - r.a); - } - /* Return r*gamma(y). */ - yy = ratfun_gam(y - x0, 0); - y = r.b*(yy.a + yy.b) + r.a*yy.b; - y += yy.a*r.a; - return (y); -} -/* - * Good on (0, 1+x0+LEFT]. Accurate to 1ulp. - */ -static double -smaller_gam(x) - double x; -{ - double t, d; - struct Double r, xx; - if (x < x0 + LEFT) { - t = x, TRUNC(t); - d = (t+x)*(x-t); - t *= t; - xx.a = (t + x), TRUNC(xx.a); - xx.b = x - xx.a; xx.b += t; xx.b += d; - t = (one-x0); t += x; - d = (one-x0); d -= t; d += x; - x = xx.a + xx.b; - } else { - xx.a = x, TRUNC(xx.a); - xx.b = x - xx.a; - t = x - x0; - d = (-x0 -t); d += x; - } - r = ratfun_gam(t, d); - d = r.a/x, TRUNC(d); - r.a -= d*xx.a; r.a -= d*xx.b; r.a += r.b; - return (d + r.a/x); -} -/* - * returns (z+c)^2 * P(z)/Q(z) + a0 - */ -static struct Double -ratfun_gam(z, c) - double z, c; -{ - int i; - double p, q; - struct Double r, t; - - q = Q0 +z*(Q1+z*(Q2+z*(Q3+z*(Q4+z*(Q5+z*(Q6+z*(Q7+z*Q8))))))); - p = P0 + z*(P1 + z*(P2 + z*(P3 + z*P4))); - - /* return r.a + r.b = a0 + (z+c)^2*p/q, with r.a truncated to 26 bits. */ - p = p/q; - t.a = z, TRUNC(t.a); /* t ~= z + c */ - t.b = (z - t.a) + c; - t.b *= (t.a + z); - q = (t.a *= t.a); /* t = (z+c)^2 */ - TRUNC(t.a); - t.b += (q - t.a); - r.a = p, TRUNC(r.a); /* r = P/Q */ - r.b = p - r.a; - t.b = t.b*p + t.a*r.b + a0_lo; - t.a *= r.a; /* t = (z+c)^2*(P/Q) */ - r.a = t.a + a0_hi, TRUNC(r.a); - r.b = ((a0_hi-r.a) + t.a) + t.b; - return (r); /* r = a0 + t */ -} - -static double -neg_gam(x) - double x; -{ - int sgn = 1; - struct Double lg, lsine; - double y, z; - - y = floor(x + .5); - if (y == x) /* Negative integer. */ - if(!_IEEE) - return (infnan(ERANGE)); - else - return (one/zero); - z = fabs(x - y); - y = .5*ceil(x); - if (y == ceil(y)) - sgn = -1; - if (z < .25) - z = sin(M_PI*z); - else - z = cos(M_PI*(0.5-z)); - /* Special case: G(1-x) = Inf; G(x) may be nonzero. */ - if (x < -170) { - if (x < -190) - return ((double)sgn*tiny*tiny); - y = one - x; /* exact: 128 < |x| < 255 */ - lg = large_gam(y); - lsine = log__D(M_PI/z); /* = TRUNC(log(u)) + small */ - lg.a -= lsine.a; /* exact (opposite signs) */ - lg.b -= lsine.b; - y = -(lg.a + lg.b); - z = (y + lg.a) + lg.b; - y = exp__D(y, z); - if (sgn < 0) y = -y; - return (y); - } - y = one-x; - if (one-y == x) - y = gamma(y); - else /* 1-x is inexact */ - y = -x*gamma(-x); - if (sgn < 0) y = -y; - return (M_PI / (y*z)); -} diff --git a/lib/libm/common_source/hypot.3 b/lib/libm/common_source/hypot.3 deleted file mode 100644 index 009817046a1a..000000000000 --- a/lib/libm/common_source/hypot.3 +++ /dev/null @@ -1,125 +0,0 @@ -.\" Copyright (c) 1985, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)hypot.3 6.7 (Berkeley) 5/6/91 -.\" $Id: hypot.3,v 1.3 1993/08/14 13:42:48 mycroft Exp $ -.\" -.Dd May 6, 1991 -.Dt HYPOT 3 -.Os BSD 4 -.Sh NAME -.Nm hypot , -.Nm cabs -.Nd euclidean distance and complex absolute value functions -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn hypot "double x" "double y" -.Fd struct {double x, y;} z; -.Ft double -.Fn cabs z -.Sh DESCRIPTION -The -.Fn hypot -and -.Fn cabs -functions -computes the -sqrt(x*x+y*y) -in such a way that underflow will not happen, and overflow -occurs only if the final result deserves it. -.Pp -.Fn hypot "\*(If" "v" -= -.Fn hypot "v" "\*(If" -= +\*(If for all -.Ar v , -including \*(Na. -.Sh ERROR (due to Roundoff, etc.) -Below 0.97 -.Em ulps . -Consequently -.Fn hypot "5.0" "12.0" -= 13.0 -exactly; -in general, hypot and cabs return an integer whenever an -integer might be expected. -.Pp -The same cannot be said for the shorter and faster version of hypot -and cabs that is provided in the comments in cabs.c; its error can -exceed 1.2 -.Em ulps . -.Sh NOTES -As might be expected, -.Fn hypot "v" "\*(Na" -and -.Fn hypot "\*(Na" "v" -are \*(Na for all -.Em finite -.Ar v ; -with "reserved operand" in place of "\*(Na", the -same is true on a -.Tn VAX . -But programmers on machines other than a -.Tn VAX -(if has no \*(If) -might be surprised at first to discover that -.Fn hypot "\(+-\*(If" "\*(Na" -= +\*(If. -This is intentional; it happens because -.Fn hypot "\*(If" "v" -= +\*(If -for -.Em all -.Ar v , -finite or infinite. -Hence -.Fn hypot "\*(If" "v" -is independent of -.Ar v . -Unlike the reserved operand fault on a -.Tn VAX , -the -.Tn IEEE -\*(Na is designed to -disappear when it turns out to be irrelevant, as it does in -.Fn hypot "\*(If" "\*(Na" . -.Sh SEE ALSO -.Xr math 3 , -.Xr sqrt 3 -.Sh HISTORY -Both a -.Fn hypot -function and a -.Fn cabs -function -appeared in -.At v7 . diff --git a/lib/libm/common_source/ieee.3 b/lib/libm/common_source/ieee.3 deleted file mode 100644 index 15c342b1470c..000000000000 --- a/lib/libm/common_source/ieee.3 +++ /dev/null @@ -1,268 +0,0 @@ -.\" Copyright (c) 1985, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91 -.\" $Id: ieee.3,v 1.5 1993/10/29 17:10:12 jtc Exp $ -.\" -.Dd May 6, 1991 -.Dt IEEE 3 -.Os BSD 4.3 -.Sh NAME -.Nm copysign , -.Nm drem , -.Nm finite , -.Nm logb , -.Nm scalb -.Nd exponent manipulations -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn copysign "double x" "double y" -.Ft double -.Fn drem "double x" "double y" -.Ft int -.Fn finite "double x" -.Ft double -.Fn logb "double x" -.Ft double -.Fn scalb "double x" "int n" -.Sh DESCRIPTION -These functions are required for, or recommended by the -.Tn IEEE -standard -754 for floating\-point arithmetic. -.Pp -The -.Fn copysign -function -returns -.Fa x -with its sign changed to -.Fa y Ns 's. -.Pp -The -.Fn drem -function -returns the remainder -.Fa r -:= -.Fa x -\- -.Fa n\(**y -where -.Fa n -is the integer nearest the exact value of -.Bk -words -.Fa x Ns / Ns Fa y ; -.Ek -moreover if -.Pf \\*(Ba Fa n -\- -.Sm off -.Fa x No / Fa y No \\*(Ba -.Sm on -= -1/2 -then -.Fa n -is even. Consequently -the remainder is computed exactly and -.Sm off -.Pf \\*(Ba Fa r No \\*(Ba -.Sm on -\*(Le -.Sm off -.Pf \\*(Ba Fa y No \\*(Ba/2. -.Sm on -But -.Fn drem x 0 -is exceptional. -(See below under -.Sx DIAGNOSTICS . ) -.Pp -The -.Fn finite -function returns the value 1 just when -\-\*(If \*(Lt -.Fa x -\*(Lt +\*(If; -otherwise a -zero is returned -(when -.Pf \\*(Ba Ns Fa x Ns \\*(Ba -= \*(If or -.Fa x -is \*(Na or -is the -.Tn VAX Ns 's -reserved operand). -.Pp -The -.Fn logb -function returns -.Fa x Ns 's exponent -.Fa n , -a signed integer converted to double\-precision floating\-point and so -chosen that -1 (<= -.Pf \\*(Ba Ns Fa x Ns \\*(Ba2** Ns Fa n -< 2 -unless -.Fa x -= 0 or -(only on machines that conform to -.Tn IEEE -754) -.Pf \\*(Ba Fa x Ns \\*(Ba -= \*(If -or -.Fa x -lies between 0 and the Underflow Threshold. -(See below under -.Sx BUGS . ) -.Pp -The -Fn scalb -returns -.Fa x Ns \(**(2** Ns Fa n ) -computed, for integer n, without first computing -.Pf 2\(** Fa n . -.Sh RETURN VALUES -The -.Tn IEEE -standard -754 defines -.Fn drem x 0 -and -.Fn drem \\*(If y -to be invalid operations that produce a \*(Na. -On the -.Tn VAX , -.Fn drem x 0 -generates a reserved operand fault. No \*(If -exists on a -.Tn VAX . -.Pp -.Tn IEEE -754 defines -.if n \ -.Fn logb \(+-\\*(If -= \*(If and -.Fn logb 0 -= \-\*(If, and -requires the latter to signal Division\-by\-Zero. -But on a -.Tn VAX , -.Fn logb 0 -= 1.0 \- 2.0**31 = \-2,147,483,647.0. -And if the correct value of -.Fn scalb -would overflow on a -.Tn VAX , -it generates a reserved operand fault and sets the global variable -.Va errno -to -.Dv ERANGE . -.Sh SEE ALSO -.Xr floor 3 , -.Xr math 3 , -.Xr infnan 3 -.Sh HISTORY -The -.Nm ieee -functions appeared in -.Bx 4.3 . -.Sh BUGS -Should -.Fn drem x 0 -and -.Fn logb 0 -on a -.Tn VAX -signal invalidity -by setting -.Va errno No = Dv EDOM ? -Should -.Fn logb 0 -return \-1.7e38? -.Pp -.Tn IEEE -754 currently specifies that -.Fn logb "denormalized no." -= -.Fn logb "tiniest normalized no. > 0" -but the consensus has changed to the specification in the new -proposed -.Tn IEEE -standard p854, namely that -.Fn logb x -satisfy -.Bd -filled -offset indent -1 \(<= -.Fn scalb \\*(Bax\\*(Ba \-logb(x) -< -Radix\0 ... = 2 -for -.Tn IEEE -754 -.Ed -.Pp -for every x except 0, -\*(If -and \*(Na. -Almost every program that assumes 754's specification will work -correctly if -.Fn logb -follows 854's specification instead. -.Pp -.Tn IEEE -754 requires -.Fn copysign x \\*(Na) -= -.Pf \(+- Ns Fa x -but says nothing -else about the sign of a \*(Na. A \*(Na -.Em N Ns ot -.Em a -.Em N Ns umber ) -is -similar in spirit to the -.Tn VAX Ns 's -reserved operand, but very -different in important details. Since the sign bit of a -reserved operand makes it look negative, -.Bd -filled -offset indent -.Fn copysign x "reserved operand" -= -.Pf \- Fa x ; -.Ed -.Pp -should this return the reserved operand instead? diff --git a/lib/libm/common_source/infnan.3 b/lib/libm/common_source/infnan.3 deleted file mode 100644 index 1bc63451e5bf..000000000000 --- a/lib/libm/common_source/infnan.3 +++ /dev/null @@ -1,181 +0,0 @@ -.\" Copyright (c) 1985, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)infnan.3 6.5 (Berkeley) 4/19/91 -.\" $Id: infnan.3,v 1.3 1993/08/14 13:42:50 mycroft Exp $ -.\" -.Dd April 19, 1991 -.Dt INFNAN 3 -.Os BSD 4.3 -.Sh NAME -.Nm infnan -.Nd signals invalid floating\-point operations on a -.Tn VAX -(temporary) -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn infnan "int iarg" -.Sh DESCRIPTION -At some time in the future, some of the useful properties of -the Infinities and \*(Nas in the -.Tn IEEE -standard 754 for Binary -Floating\-Point Arithmetic will be simulated in -.Tn UNIX -on the -.Tn DEC VAX -by using its Reserved Operands. Meanwhile, the -Invalid, Overflow and Divide\-by\-Zero exceptions of the -.Tn IEEE -standard are being approximated on a -.Tn VAX -by calls to a -procedure -.Fn infnan -in appropriate places in -.Xr libm 3 . -When -better exception\-handling is implemented in -.Tn UNIX , -only -.Fn infnan -among the codes in -.Xr libm -will have to be changed. -And users of -.Xr libm -can design their own -.Fn infnan -now to -insulate themselves from future changes. -.Pp -Whenever an elementary function code in -.Xr libm -has to -simulate one of the aforementioned -.Tn IEEE -exceptions, it calls -.Fn infnan iarg -with an appropriate value of -.Fa iarg . -Then a -reserved operand fault stops computation. But -.Fn infnan -could -be replaced by a function with the same name that returns -some plausible value, assigns an apt value to the global -variable -.Va errno , -and allows computation to resume. -Alternatively, the Reserved Operand Fault Handler could be -changed to respond by returning that plausible value, etc. -instead of aborting. -.Pp -In the table below, the first two columns show various -exceptions signaled by the -.Tn IEEE -standard, and the default -result it prescribes. The third column shows what value is -given to -.Fa iarg -by functions in -.Xr libm -when they -invoke -.Fn infnan iarg -under analogous circumstances on a -.Tn VAX . -Currently -.Fn infnan -stops computation under all those -circumstances. The last two columns offer an alternative; -they suggest a setting for -.Va errno -and a value for a -revised -.Fn infnan -to return. And a C program to -implement that suggestion follows. -.sp 0.5 -.Bd -filled -offset indent -.Bl -column "IEEE Signal" "IEEE Default" XXERANGE ERANGEXXorXXEDOM -.It IEEE Signal IEEE Default Ta -.Fa iarg Ta -.Va errno Ta -.Fn infnan -.It Invalid \*(Na Ta -.Dv EDOM EDOM 0 -.It Overflow \(+-\*(If Ta -.Dv ERANGE ERANGE HUGE -.It Div\-by\-0 \(+-Infinity Ta -.Dv \(+-ERANGE ERANGE or EDOM \(+-HUGE -.It ( Ns Dv HUGE No "= 1.7e38 ... nearly 2.0**127)" -.El -.Ed -.Pp -ALTERNATIVE -.Fn infnan : -.Bd -literal -offset indent -#include -#include -extern int errno ; -double infnan(iarg) -int iarg ; -{ - switch(iarg) { - case \0ERANGE: errno = ERANGE; return(HUGE); - case \-ERANGE: errno = EDOM; return(\-HUGE); - default: errno = EDOM; return(0); - } -} -.Ed -.Sh SEE ALSO -.Xr math 3 , -.Xr intro 2 , -.Xr signal 3 . -.Pp -.Dv ERANGE -and -.Dv EDOM -are defined in -.Aq Pa errno.h . -(See -.Xr intro 2 -for explanation of -.Dv EDOM -and -.Dv ERANGE . ) -.Sh HISTORY -The -.Fn infnan -function appeared in -.Bx 4.3 . diff --git a/lib/libm/common_source/j0.3 b/lib/libm/common_source/j0.3 deleted file mode 100644 index 4b18e858b835..000000000000 --- a/lib/libm/common_source/j0.3 +++ /dev/null @@ -1,128 +0,0 @@ -.\" Copyright (c) 1985, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)j0.3 6.7 (Berkeley) 4/19/91 -.\" $Id: j0.3,v 1.5 1994/01/11 00:46:54 jtc Exp $ -.\" -.Dd April 19, 1991 -.Dt J0 3 -.Os BSD 4 -.Sh NAME -.Nm j0 , -.Nm j1 , -.Nm jn , -.Nm y0 , -.Nm y1 , -.Nm yn -.Nd bessel functions of first and second kind -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn j0 "double x" -.Ft double -.Fn j1 "double x" -.Ft double -.Fn jn "int n" "double x" -.Ft double -.Fn y0 "double x" -.Ft double -.Fn y1 "double x" -.Ft double -.Fn yn "int n" "double x" -.Sh DESCRIPTION -The functions -.Fn j0 -and -.Fn j1 -compute the -.Em Bessel function of the first kind of the order -0 and the -.Em order -1, respectively, -for the -real value -.Fa x ; -the function -.Fn jn -computes the -.Em Bessel function of the first kind of the integer order -.Fa n -for the real value -.Fa x . -.Pp -The functions -.Fn y0 -and -.Fn y1 -compute the linearly independent -.Em Bessel function of the second kind of the order -0 and the -.Em order -1, respectively, -for the -positive -.Em integer -value -.Fa x -(expressed as a double); -the function -.Fn yn -computes the -.Em Bessel function of the second kind for the integer order -.Fa n -for the positive -.Em integer -value -.Fa x -(expressed as a double). -.Sh RETURN VALUES -If these functions are successful, -the computed value is returned. On the -.Tn VAX -and -.Tn Tahoe -architectures, -a negative -.Fa x -value -results in an error; the global -variable -.Va errno -is set to -.Er EDOM -and a reserve operand fault is generated. -.Sh SEE ALSO -.Xr math 3 , -.Xr infnan 3 -.Sh HISTORY -This set of functions -appeared in -.At v7 . diff --git a/lib/libm/common_source/j0.c b/lib/libm/common_source/j0.c deleted file mode 100644 index 45650cbfcffc..000000000000 --- a/lib/libm/common_source/j0.c +++ /dev/null @@ -1,440 +0,0 @@ -/*- - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)j0.c 5.5 (Berkeley) 12/16/92";*/ -static char rcsid[] = "$Id: j0.c,v 1.2 1994/02/06 18:48:00 chopps Exp $"; -#endif /* not lint */ - -/* - * 16 December 1992 - * Minor modifications by Peter McIlroy to adapt non-IEEE architecture. - */ - -/* - * ==================================================== - * Copyright (C) 1992 by Sun Microsystems, Inc. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - * ******************* WARNING ******************** - * This is an alpha version of SunPro's FDLIBM (Freely - * Distributable Math Library) for IEEE double precision - * arithmetic. FDLIBM is a basic math library written - * in C that runs on machines that conform to IEEE - * Standard 754/854. This alpha version is distributed - * for testing purpose. Those who use this software - * should report any bugs to - * - * fdlibm-comments@sunpro.eng.sun.com - * - * -- K.C. Ng, Oct 12, 1992 - * ************************************************ - */ - -/* double j0(double x), y0(double x) - * Bessel function of the first and second kinds of order zero. - * Method -- j0(x): - * 1. For tiny x, we use j0(x) = 1 - x^2/4 + x^4/64 - ... - * 2. Reduce x to |x| since j0(x)=j0(-x), and - * for x in (0,2) - * j0(x) = 1-z/4+ z^2*R0/S0, where z = x*x; - * (precision: |j0-1+z/4-z^2R0/S0 |<2**-63.67 ) - * for x in (2,inf) - * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0)) - * where x0 = x-pi/4. It is better to compute sin(x0),cos(x0) - * as follow: - * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) - * = 1/sqrt(2) * (cos(x) + sin(x)) - * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4) - * = 1/sqrt(2) * (sin(x) - cos(x)) - * (To avoid cancellation, use - * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) - * to compute the worse one.) - * - * 3 Special cases - * j0(nan)= nan - * j0(0) = 1 - * j0(inf) = 0 - * - * Method -- y0(x): - * 1. For x<2. - * Since - * y0(x) = 2/pi*(j0(x)*(ln(x/2)+Euler) + x^2/4 - ...) - * therefore y0(x)-2/pi*j0(x)*ln(x) is an even function. - * We use the following function to approximate y0, - * y0(x) = U(z)/V(z) + (2/pi)*(j0(x)*ln(x)), z= x^2 - * where - * U(z) = u0 + u1*z + ... + u6*z^6 - * V(z) = 1 + v1*z + ... + v4*z^4 - * with absolute approximation error bounded by 2**-72. - * Note: For tiny x, U/V = u0 and j0(x)~1, hence - * y0(tiny) = u0 + (2/pi)*ln(tiny), (choose tiny<2**-27) - * 2. For x>=2. - * y0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)+q0(x)*sin(x0)) - * where x0 = x-pi/4. It is better to compute sin(x0),cos(x0) - * by the method mentioned above. - * 3. Special cases: y0(0)=-inf, y0(x<0)=NaN, y0(inf)=0. - */ - -#include -#include -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#else -#define _IEEE 1 -#define infnan(x) (0.0) -#endif - -static double pzero __P((double)), qzero __P((double)); - -static double -huge = 1e300, -zero = 0.0, -one = 1.0, -invsqrtpi= 5.641895835477562869480794515607725858441e-0001, -tpi = 0.636619772367581343075535053490057448, - /* R0/S0 on [0, 2.00] */ -r02 = 1.562499999999999408594634421055018003102e-0002, -r03 = -1.899792942388547334476601771991800712355e-0004, -r04 = 1.829540495327006565964161150603950916854e-0006, -r05 = -4.618326885321032060803075217804816988758e-0009, -s01 = 1.561910294648900170180789369288114642057e-0002, -s02 = 1.169267846633374484918570613449245536323e-0004, -s03 = 5.135465502073181376284426245689510134134e-0007, -s04 = 1.166140033337900097836930825478674320464e-0009; - -double -j0(x) - double x; -{ - double z, s,c,ss,cc,r,u,v; - - if (!finite(x)) - if (_IEEE) return one/(x*x); - else return (0); - x = fabs(x); - if (x >= 2.0) { /* |x| >= 2.0 */ - s = sin(x); - c = cos(x); - ss = s-c; - cc = s+c; - if (x < .5 * DBL_MAX) { /* make sure x+x not overflow */ - z = -cos(x+x); - if ((s*c) 6.80564733841876927e+38) /* 2^129 */ - z = (invsqrtpi*cc)/sqrt(x); - else { - u = pzero(x); v = qzero(x); - z = invsqrtpi*(u*cc-v*ss)/sqrt(x); - } - return z; - } - if (x < 1.220703125e-004) { /* |x| < 2**-13 */ - if (huge+x > one) { /* raise inexact if x != 0 */ - if (x < 7.450580596923828125e-009) /* |x|<2**-27 */ - return one; - else return (one - 0.25*x*x); - } - } - z = x*x; - r = z*(r02+z*(r03+z*(r04+z*r05))); - s = one+z*(s01+z*(s02+z*(s03+z*s04))); - if (x < one) { /* |x| < 1.00 */ - return (one + z*(-0.25+(r/s))); - } else { - u = 0.5*x; - return ((one+u)*(one-u)+z*(r/s)); - } -} - -static double -u00 = -7.380429510868722527422411862872999615628e-0002, -u01 = 1.766664525091811069896442906220827182707e-0001, -u02 = -1.381856719455968955440002438182885835344e-0002, -u03 = 3.474534320936836562092566861515617053954e-0004, -u04 = -3.814070537243641752631729276103284491172e-0006, -u05 = 1.955901370350229170025509706510038090009e-0008, -u06 = -3.982051941321034108350630097330144576337e-0011, -v01 = 1.273048348341237002944554656529224780561e-0002, -v02 = 7.600686273503532807462101309675806839635e-0005, -v03 = 2.591508518404578033173189144579208685163e-0007, -v04 = 4.411103113326754838596529339004302243157e-0010; - -double -y0(x) - double x; -{ - double z, s,c,ss,cc,u,v; - /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */ - if (!finite(x)) - if (_IEEE) - return (one/(x+x*x)); - else - return (0); - if (x == 0) - if (_IEEE) return (-one/zero); - else return(infnan(-ERANGE)); - if (x<0) - if (_IEEE) return (zero/zero); - else return (infnan(EDOM)); - if (x >= 2.00) { /* |x| >= 2.0 */ - /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0)) - * where x0 = x-pi/4 - * Better formula: - * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) - * = 1/sqrt(2) * (sin(x) + cos(x)) - * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) - * = 1/sqrt(2) * (sin(x) - cos(x)) - * To avoid cancellation, use - * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) - * to compute the worse one. - */ - s = sin(x); - c = cos(x); - ss = s-c; - cc = s+c; - /* - * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) - * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) - */ - if (x < .5 * DBL_MAX) { /* make sure x+x not overflow */ - z = -cos(x+x); - if ((s*c) 6.80564733841876927e+38) /* > 2^129 */ - z = (invsqrtpi*ss)/sqrt(x); - else { - u = pzero(x); v = qzero(x); - z = invsqrtpi*(u*ss+v*cc)/sqrt(x); - } - return z; - } - if (x <= 7.450580596923828125e-009) { /* x < 2**-27 */ - return (u00 + tpi*log(x)); - } - z = x*x; - u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06))))); - v = one+z*(v01+z*(v02+z*(v03+z*v04))); - return (u/v + tpi*(j0(x)*log(x))); -} - -/* The asymptotic expansions of pzero is - * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. - * For x >= 2, We approximate pzero by - * pzero(x) = 1 + (R/S) - * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 - * S = 1 + ps0*s^2 + ... + ps4*s^10 - * and - * | pzero(x)-1-R/S | <= 2 ** ( -60.26) - */ -static double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ - 0.0, - -7.031249999999003994151563066182798210142e-0002, - -8.081670412753498508883963849859423939871e+0000, - -2.570631056797048755890526455854482662510e+0002, - -2.485216410094288379417154382189125598962e+0003, - -5.253043804907295692946647153614119665649e+0003, -}; -static double ps8[5] = { - 1.165343646196681758075176077627332052048e+0002, - 3.833744753641218451213253490882686307027e+0003, - 4.059785726484725470626341023967186966531e+0004, - 1.167529725643759169416844015694440325519e+0005, - 4.762772841467309430100106254805711722972e+0004, -}; - -static double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ - -1.141254646918944974922813501362824060117e-0011, - -7.031249408735992804117367183001996028304e-0002, - -4.159610644705877925119684455252125760478e+0000, - -6.767476522651671942610538094335912346253e+0001, - -3.312312996491729755731871867397057689078e+0002, - -3.464333883656048910814187305901796723256e+0002, -}; -static double ps5[5] = { - 6.075393826923003305967637195319271932944e+0001, - 1.051252305957045869801410979087427910437e+0003, - 5.978970943338558182743915287887408780344e+0003, - 9.625445143577745335793221135208591603029e+0003, - 2.406058159229391070820491174867406875471e+0003, -}; - -static double pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ - -2.547046017719519317420607587742992297519e-0009, - -7.031196163814817199050629727406231152464e-0002, - -2.409032215495295917537157371488126555072e+0000, - -2.196597747348830936268718293366935843223e+0001, - -5.807917047017375458527187341817239891940e+0001, - -3.144794705948885090518775074177485744176e+0001, -}; -static double ps3[5] = { - 3.585603380552097167919946472266854507059e+0001, - 3.615139830503038919981567245265266294189e+0002, - 1.193607837921115243628631691509851364715e+0003, - 1.127996798569074250675414186814529958010e+0003, - 1.735809308133357510239737333055228118910e+0002, -}; - -static double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ - -8.875343330325263874525704514800809730145e-0008, - -7.030309954836247756556445443331044338352e-0002, - -1.450738467809529910662233622603401167409e+0000, - -7.635696138235277739186371273434739292491e+0000, - -1.119316688603567398846655082201614524650e+0001, - -3.233645793513353260006821113608134669030e+0000, -}; -static double ps2[5] = { - 2.222029975320888079364901247548798910952e+0001, - 1.362067942182152109590340823043813120940e+0002, - 2.704702786580835044524562897256790293238e+0002, - 1.538753942083203315263554770476850028583e+0002, - 1.465761769482561965099880599279699314477e+0001, -}; - -static double pzero(x) - double x; -{ - double *p,*q,z,r,s; - if (x >= 8.00) {p = pr8; q= ps8;} - else if (x >= 4.54545211791992188) {p = pr5; q= ps5;} - else if (x >= 2.85714149475097656) {p = pr3; q= ps3;} - else if (x >= 2.00) {p = pr2; q= ps2;} - z = one/(x*x); - r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); - s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); - return one+ r/s; -} - - -/* For x >= 8, the asymptotic expansions of qzero is - * -1/8 s + 75/1024 s^3 - ..., where s = 1/x. - * We approximate pzero by - * qzero(x) = s*(-1.25 + (R/S)) - * where R = qr0 + qr1*s^2 + qr2*s^4 + ... + qr5*s^10 - * S = 1 + qs0*s^2 + ... + qs5*s^12 - * and - * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) - */ -static double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ - 0.0, - 7.324218749999350414479738504551775297096e-0002, - 1.176820646822526933903301695932765232456e+0001, - 5.576733802564018422407734683549251364365e+0002, - 8.859197207564685717547076568608235802317e+0003, - 3.701462677768878501173055581933725704809e+0004, -}; -static double qs8[6] = { - 1.637760268956898345680262381842235272369e+0002, - 8.098344946564498460163123708054674227492e+0003, - 1.425382914191204905277585267143216379136e+0005, - 8.033092571195144136565231198526081387047e+0005, - 8.405015798190605130722042369969184811488e+0005, - -3.438992935378666373204500729736454421006e+0005, -}; - -static double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ - 1.840859635945155400568380711372759921179e-0011, - 7.324217666126847411304688081129741939255e-0002, - 5.835635089620569401157245917610984757296e+0000, - 1.351115772864498375785526599119895942361e+0002, - 1.027243765961641042977177679021711341529e+0003, - 1.989977858646053872589042328678602481924e+0003, -}; -static double qs5[6] = { - 8.277661022365377058749454444343415524509e+0001, - 2.077814164213929827140178285401017305309e+0003, - 1.884728877857180787101956800212453218179e+0004, - 5.675111228949473657576693406600265778689e+0004, - 3.597675384251145011342454247417399490174e+0004, - -5.354342756019447546671440667961399442388e+0003, -}; - -static double qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ - 4.377410140897386263955149197672576223054e-0009, - 7.324111800429115152536250525131924283018e-0002, - 3.344231375161707158666412987337679317358e+0000, - 4.262184407454126175974453269277100206290e+0001, - 1.708080913405656078640701512007621675724e+0002, - 1.667339486966511691019925923456050558293e+0002, -}; -static double qs3[6] = { - 4.875887297245871932865584382810260676713e+0001, - 7.096892210566060535416958362640184894280e+0002, - 3.704148226201113687434290319905207398682e+0003, - 6.460425167525689088321109036469797462086e+0003, - 2.516333689203689683999196167394889715078e+0003, - -1.492474518361563818275130131510339371048e+0002, -}; - -static double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ - 1.504444448869832780257436041633206366087e-0007, - 7.322342659630792930894554535717104926902e-0002, - 1.998191740938159956838594407540292600331e+0000, - 1.449560293478857407645853071687125850962e+0001, - 3.166623175047815297062638132537957315395e+0001, - 1.625270757109292688799540258329430963726e+0001, -}; -static double qs2[6] = { - 3.036558483552191922522729838478169383969e+0001, - 2.693481186080498724211751445725708524507e+0002, - 8.447837575953201460013136756723746023736e+0002, - 8.829358451124885811233995083187666981299e+0002, - 2.126663885117988324180482985363624996652e+0002, - -5.310954938826669402431816125780738924463e+0000, -}; - -static double qzero(x) - double x; -{ - double *p,*q, s,r,z; - if (x >= 8.00) {p = qr8; q= qs8;} - else if (x >= 4.54545211791992188) {p = qr5; q= qs5;} - else if (x >= 2.85714149475097656) {p = qr3; q= qs3;} - else if (x >= 2.00) {p = qr2; q= qs2;} - z = one/(x*x); - r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); - s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); - return (-.125 + r/s)/x; -} diff --git a/lib/libm/common_source/j1.c b/lib/libm/common_source/j1.c deleted file mode 100644 index e66a0dc8354a..000000000000 --- a/lib/libm/common_source/j1.c +++ /dev/null @@ -1,447 +0,0 @@ -/*- - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)j1.c 5.5 (Berkeley) 12/16/92";*/ -static char rcsid[] = "$Id: j1.c,v 1.2 1994/02/06 18:48:02 chopps Exp $"; -#endif /* not lint */ - -/* - * 16 December 1992 - * Minor modifications by Peter McIlroy to adapt non-IEEE architecture. - */ - -/* - * ==================================================== - * Copyright (C) 1992 by Sun Microsystems, Inc. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - * ******************* WARNING ******************** - * This is an alpha version of SunPro's FDLIBM (Freely - * Distributable Math Library) for IEEE double precision - * arithmetic. FDLIBM is a basic math library written - * in C that runs on machines that conform to IEEE - * Standard 754/854. This alpha version is distributed - * for testing purpose. Those who use this software - * should report any bugs to - * - * fdlibm-comments@sunpro.eng.sun.com - * - * -- K.C. Ng, Oct 12, 1992 - * ************************************************ - */ - -/* double j1(double x), y1(double x) - * Bessel function of the first and second kinds of order zero. - * Method -- j1(x): - * 1. For tiny x, we use j1(x) = x/2 - x^3/16 + x^5/384 - ... - * 2. Reduce x to |x| since j1(x)=-j1(-x), and - * for x in (0,2) - * j1(x) = x/2 + x*z*R0/S0, where z = x*x; - * (precision: |j1/x - 1/2 - R0/S0 |<2**-61.51 ) - * for x in (2,inf) - * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1)) - * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1)) - * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1) - * as follows: - * cos(x1) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) - * = 1/sqrt(2) * (sin(x) - cos(x)) - * sin(x1) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) - * = -1/sqrt(2) * (sin(x) + cos(x)) - * (To avoid cancellation, use - * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) - * to compute the worse one.) - * - * 3 Special cases - * j1(nan)= nan - * j1(0) = 0 - * j1(inf) = 0 - * - * Method -- y1(x): - * 1. screen out x<=0 cases: y1(0)=-inf, y1(x<0)=NaN - * 2. For x<2. - * Since - * y1(x) = 2/pi*(j1(x)*(ln(x/2)+Euler)-1/x-x/2+5/64*x^3-...) - * therefore y1(x)-2/pi*j1(x)*ln(x)-1/x is an odd function. - * We use the following function to approximate y1, - * y1(x) = x*U(z)/V(z) + (2/pi)*(j1(x)*ln(x)-1/x), z= x^2 - * where for x in [0,2] (abs err less than 2**-65.89) - * U(z) = u0 + u1*z + ... + u4*z^4 - * V(z) = 1 + v1*z + ... + v5*z^5 - * Note: For tiny x, 1/x dominate y1 and hence - * y1(tiny) = -2/pi/tiny, (choose tiny<2**-54) - * 3. For x>=2. - * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1)) - * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1) - * by method mentioned above. - */ - -#include -#include - -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#else -#define _IEEE 1 -#define infnan(x) (0.0) -#endif - -static double pone(), qone(); - -static double -huge = 1e300, -zero = 0.0, -one = 1.0, -invsqrtpi= 5.641895835477562869480794515607725858441e-0001, -tpi = 0.636619772367581343075535053490057448, - - /* R0/S0 on [0,2] */ -r00 = -6.250000000000000020842322918309200910191e-0002, -r01 = 1.407056669551897148204830386691427791200e-0003, -r02 = -1.599556310840356073980727783817809847071e-0005, -r03 = 4.967279996095844750387702652791615403527e-0008, -s01 = 1.915375995383634614394860200531091839635e-0002, -s02 = 1.859467855886309024045655476348872850396e-0004, -s03 = 1.177184640426236767593432585906758230822e-0006, -s04 = 5.046362570762170559046714468225101016915e-0009, -s05 = 1.235422744261379203512624973117299248281e-0011; - -#define two_129 6.80564733841876926e+038 /* 2^129 */ -#define two_m54 5.55111512312578270e-017 /* 2^-54 */ -double j1(x) - double x; -{ - double z, s,c,ss,cc,r,u,v,y; - y = fabs(x); - if (!finite(x)) /* Inf or NaN */ - if (_IEEE && x != x) - return(x); - else - return (copysign(x, zero)); - y = fabs(x); - if (y >= 2) /* |x| >= 2.0 */ - { - s = sin(y); - c = cos(y); - ss = -s-c; - cc = s-c; - if (y < .5*DBL_MAX) { /* make sure y+y not overflow */ - z = cos(y+y); - if ((s*c) two_129) /* x > 2^129 */ - z = (invsqrtpi*cc)/sqrt(y); - else -#endif /* defined(vax) || defined(tahoe) */ - { - u = pone(y); v = qone(y); - z = invsqrtpi*(u*cc-v*ss)/sqrt(y); - } - if (x < 0) return -z; - else return z; - } - if (y < 7.450580596923828125e-009) { /* |x|<2**-27 */ - if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */ - } - z = x*x; - r = z*(r00+z*(r01+z*(r02+z*r03))); - s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05)))); - r *= x; - return (x*0.5+r/s); -} - -static double u0[5] = { - -1.960570906462389484206891092512047539632e-0001, - 5.044387166398112572026169863174882070274e-0002, - -1.912568958757635383926261729464141209569e-0003, - 2.352526005616105109577368905595045204577e-0005, - -9.190991580398788465315411784276789663849e-0008, -}; -static double v0[5] = { - 1.991673182366499064031901734535479833387e-0002, - 2.025525810251351806268483867032781294682e-0004, - 1.356088010975162198085369545564475416398e-0006, - 6.227414523646214811803898435084697863445e-0009, - 1.665592462079920695971450872592458916421e-0011, -}; - -double y1(x) - double x; -{ - double z, s,c,ss,cc,u,v; - /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ - if (!finite(x)) - if (!_IEEE) return (infnan(EDOM)); - else if (x < 0) - return(zero/zero); - else if (x > 0) - return (0); - else - return(x); - if (x <= 0) { - if (_IEEE && x == 0) return -one/zero; - else if(x == 0) return(infnan(-ERANGE)); - else if(_IEEE) return (zero/zero); - else return(infnan(EDOM)); - } - if (x >= 2) /* |x| >= 2.0 */ - { - s = sin(x); - c = cos(x); - ss = -s-c; - cc = s-c; - if (x < .5 * DBL_MAX) /* make sure x+x not overflow */ - { - z = cos(x+x); - if ((s*c)>zero) cc = z/ss; - else ss = z/cc; - } - /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) - * where x0 = x-3pi/4 - * Better formula: - * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) - * = 1/sqrt(2) * (sin(x) - cos(x)) - * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) - * = -1/sqrt(2) * (cos(x) + sin(x)) - * To avoid cancellation, use - * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) - * to compute the worse one. - */ - if (_IEEE && x>two_129) - z = (invsqrtpi*ss)/sqrt(x); - else { - u = pone(x); v = qone(x); - z = invsqrtpi*(u*ss+v*cc)/sqrt(x); - } - return z; - } - if (x <= two_m54) { /* x < 2**-54 */ - return (-tpi/x); - } - z = x*x; - u = u0[0]+z*(u0[1]+z*(u0[2]+z*(u0[3]+z*u0[4]))); - v = one+z*(v0[0]+z*(v0[1]+z*(v0[2]+z*(v0[3]+z*v0[4])))); - return (x*(u/v) + tpi*(j1(x)*log(x)-one/x)); -} - -/* For x >= 8, the asymptotic expansions of pone is - * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. - * We approximate pone by - * pone(x) = 1 + (R/S) - * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 - * S = 1 + ps0*s^2 + ... + ps4*s^10 - * and - * | pone(x)-1-R/S | <= 2 ** ( -60.06) - */ - -static double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ - 0.0, - 1.171874999999886486643746274751925399540e-0001, - 1.323948065930735690925827997575471527252e+0001, - 4.120518543073785433325860184116512799375e+0002, - 3.874745389139605254931106878336700275601e+0003, - 7.914479540318917214253998253147871806507e+0003, -}; -static double ps8[5] = { - 1.142073703756784104235066368252692471887e+0002, - 3.650930834208534511135396060708677099382e+0003, - 3.695620602690334708579444954937638371808e+0004, - 9.760279359349508334916300080109196824151e+0004, - 3.080427206278887984185421142572315054499e+0004, -}; - -static double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ - 1.319905195562435287967533851581013807103e-0011, - 1.171874931906140985709584817065144884218e-0001, - 6.802751278684328781830052995333841452280e+0000, - 1.083081829901891089952869437126160568246e+0002, - 5.176361395331997166796512844100442096318e+0002, - 5.287152013633375676874794230748055786553e+0002, -}; -static double ps5[5] = { - 5.928059872211313557747989128353699746120e+0001, - 9.914014187336144114070148769222018425781e+0002, - 5.353266952914879348427003712029704477451e+0003, - 7.844690317495512717451367787640014588422e+0003, - 1.504046888103610723953792002716816255382e+0003, -}; - -static double pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ - 3.025039161373736032825049903408701962756e-0009, - 1.171868655672535980750284752227495879921e-0001, - 3.932977500333156527232725812363183251138e+0000, - 3.511940355916369600741054592597098912682e+0001, - 9.105501107507812029367749771053045219094e+0001, - 4.855906851973649494139275085628195457113e+0001, -}; -static double ps3[5] = { - 3.479130950012515114598605916318694946754e+0001, - 3.367624587478257581844639171605788622549e+0002, - 1.046871399757751279180649307467612538415e+0003, - 8.908113463982564638443204408234739237639e+0002, - 1.037879324396392739952487012284401031859e+0002, -}; - -static double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ - 1.077108301068737449490056513753865482831e-0007, - 1.171762194626833490512746348050035171545e-0001, - 2.368514966676087902251125130227221462134e+0000, - 1.224261091482612280835153832574115951447e+0001, - 1.769397112716877301904532320376586509782e+0001, - 5.073523125888185399030700509321145995160e+0000, -}; -static double ps2[5] = { - 2.143648593638214170243114358933327983793e+0001, - 1.252902271684027493309211410842525120355e+0002, - 2.322764690571628159027850677565128301361e+0002, - 1.176793732871470939654351793502076106651e+0002, - 8.364638933716182492500902115164881195742e+0000, -}; - -static double pone(x) - double x; -{ - double *p,*q,z,r,s; - if (x >= 8.0) {p = pr8; q= ps8;} - else if (x >= 4.54545211791992188) {p = pr5; q= ps5;} - else if (x >= 2.85714149475097656) {p = pr3; q= ps3;} - else /* if (x >= 2.0) */ {p = pr2; q= ps2;} - z = one/(x*x); - r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); - s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); - return (one + r/s); -} - - -/* For x >= 8, the asymptotic expansions of qone is - * 3/8 s - 105/1024 s^3 - ..., where s = 1/x. - * We approximate pone by - * qone(x) = s*(0.375 + (R/S)) - * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10 - * S = 1 + qs1*s^2 + ... + qs6*s^12 - * and - * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) - */ - -static double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ - 0.0, - -1.025390624999927207385863635575804210817e-0001, - -1.627175345445899724355852152103771510209e+0001, - -7.596017225139501519843072766973047217159e+0002, - -1.184980667024295901645301570813228628541e+0004, - -4.843851242857503225866761992518949647041e+0004, -}; -static double qs8[6] = { - 1.613953697007229231029079421446916397904e+0002, - 7.825385999233484705298782500926834217525e+0003, - 1.338753362872495800748094112937868089032e+0005, - 7.196577236832409151461363171617204036929e+0005, - 6.666012326177764020898162762642290294625e+0005, - -2.944902643038346618211973470809456636830e+0005, -}; - -static double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ - -2.089799311417640889742251585097264715678e-0011, - -1.025390502413754195402736294609692303708e-0001, - -8.056448281239359746193011295417408828404e+0000, - -1.836696074748883785606784430098756513222e+0002, - -1.373193760655081612991329358017247355921e+0003, - -2.612444404532156676659706427295870995743e+0003, -}; -static double qs5[6] = { - 8.127655013843357670881559763225310973118e+0001, - 1.991798734604859732508048816860471197220e+0003, - 1.746848519249089131627491835267411777366e+0004, - 4.985142709103522808438758919150738000353e+0004, - 2.794807516389181249227113445299675335543e+0004, - -4.719183547951285076111596613593553911065e+0003, -}; - -static double qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ - -5.078312264617665927595954813341838734288e-0009, - -1.025378298208370901410560259001035577681e-0001, - -4.610115811394734131557983832055607679242e+0000, - -5.784722165627836421815348508816936196402e+0001, - -2.282445407376317023842545937526967035712e+0002, - -2.192101284789093123936441805496580237676e+0002, -}; -static double qs3[6] = { - 4.766515503237295155392317984171640809318e+0001, - 6.738651126766996691330687210949984203167e+0002, - 3.380152866795263466426219644231687474174e+0003, - 5.547729097207227642358288160210745890345e+0003, - 1.903119193388108072238947732674639066045e+0003, - -1.352011914443073322978097159157678748982e+0002, -}; - -static double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ - -1.783817275109588656126772316921194887979e-0007, - -1.025170426079855506812435356168903694433e-0001, - -2.752205682781874520495702498875020485552e+0000, - -1.966361626437037351076756351268110418862e+0001, - -4.232531333728305108194363846333841480336e+0001, - -2.137192117037040574661406572497288723430e+0001, -}; -static double qs2[6] = { - 2.953336290605238495019307530224241335502e+0001, - 2.529815499821905343698811319455305266409e+0002, - 7.575028348686454070022561120722815892346e+0002, - 7.393932053204672479746835719678434981599e+0002, - 1.559490033366661142496448853793707126179e+0002, - -4.959498988226281813825263003231704397158e+0000, -}; - -static double qone(x) - double x; -{ - double *p,*q, s,r,z; - if (x >= 8.0) {p = qr8; q= qs8;} - else if (x >= 4.54545211791992188) {p = qr5; q= qs5;} - else if (x >= 2.85714149475097656) {p = qr3; q= qs3;} - else /* if (x >= 2.0) */ {p = qr2; q= qs2;} - z = one/(x*x); - r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); - s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); - return (.375 + r/s)/x; -} diff --git a/lib/libm/common_source/jn.c b/lib/libm/common_source/jn.c deleted file mode 100644 index afff34b1d690..000000000000 --- a/lib/libm/common_source/jn.c +++ /dev/null @@ -1,313 +0,0 @@ -/*- - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)jn.c 5.5 (Berkeley) 12/16/92";*/ -static char rcsid[] = "$Id: jn.c,v 1.1 1993/08/14 13:42:54 mycroft Exp $"; -#endif /* not lint */ - -/* - * 16 December 1992 - * Minor modifications by Peter McIlroy to adapt non-IEEE architecture. - */ - -/* - * ==================================================== - * Copyright (C) 1992 by Sun Microsystems, Inc. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - * - * ******************* WARNING ******************** - * This is an alpha version of SunPro's FDLIBM (Freely - * Distributable Math Library) for IEEE double precision - * arithmetic. FDLIBM is a basic math library written - * in C that runs on machines that conform to IEEE - * Standard 754/854. This alpha version is distributed - * for testing purpose. Those who use this software - * should report any bugs to - * - * fdlibm-comments@sunpro.eng.sun.com - * - * -- K.C. Ng, Oct 12, 1992 - * ************************************************ - */ - -/* - * jn(int n, double x), yn(int n, double x) - * floating point Bessel's function of the 1st and 2nd kind - * of order n - * - * Special cases: - * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; - * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. - * Note 2. About jn(n,x), yn(n,x) - * 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 -#include -#include - -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#else -#define _IEEE 1 -#define infnan(x) (0.0) -#endif - -extern double j0(),j1(),log(),fabs(),sqrt(),cos(),sin(),y0(),y1(); -static double -invsqrtpi= 5.641895835477562869480794515607725858441e-0001, -two = 2.0, -zero = 0.0, -one = 1.0; - -double jn(n,x) - int n; double x; -{ - int i, sgn; - double a, b, temp; - double z, w; - - /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) - * Thus, J(-n,x) = J(n,-x) - */ - /* if J(n,NaN) is NaN */ - if (_IEEE && isnan(x)) return x+x; - if (n<0){ - n = -n; - x = -x; - } - if (n==0) return(j0(x)); - if (n==1) return(j1(x)); - sgn = (n&1)&(x < zero); /* even n -- 0, odd n -- sign(x) */ - x = fabs(x); - if (x == 0 || !finite (x)) /* if x is 0 or inf */ - b = zero; - else if ((double) n <= x) { - /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ - if (_IEEE && x >= 8.148143905337944345e+090) { - /* x >= 2**302 */ - /* (x >> n**2) - * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) - * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) - * Let s=sin(x), c=cos(x), - * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then - * - * n sin(xn)*sqt2 cos(xn)*sqt2 - * ---------------------------------- - * 0 s-c c+s - * 1 -s-c -c+s - * 2 -s+c -c-s - * 3 s+c c-s - */ - switch(n&3) { - case 0: temp = cos(x)+sin(x); break; - case 1: temp = -cos(x)+sin(x); break; - case 2: temp = -cos(x)-sin(x); break; - case 3: temp = cos(x)-sin(x); break; - } - b = invsqrtpi*temp/sqrt(x); - } else { - a = j0(x); - b = j1(x); - for(i=1;i 33) /* underflow */ - b = zero; - else { - temp = x*0.5; b = temp; - for (a=one,i=2;i<=n;i++) { - a *= (double)i; /* a = n! */ - b *= temp; /* b = (x/2)^n */ - } - b = b/a; - } - } else { - /* use backward recurrence */ - /* x x^2 x^2 - * J(n,x)/J(n-1,x) = ---- ------ ------ ..... - * 2n - 2(n+1) - 2(n+2) - * - * 1 1 1 - * (for large x) = ---- ------ ------ ..... - * 2n 2(n+1) 2(n+2) - * -- - ------ - ------ - - * x x x - * - * Let w = 2n/x and h=2/x, then the above quotient - * is equal to the continued fraction: - * 1 - * = ----------------------- - * 1 - * w - ----------------- - * 1 - * w+h - --------- - * w+2h - ... - * - * To determine how many terms needed, let - * Q(0) = w, Q(1) = w(w+h) - 1, - * Q(k) = (w+k*h)*Q(k-1) - Q(k-2), - * When Q(k) > 1e4 good for single - * When Q(k) > 1e9 good for double - * When Q(k) > 1e17 good for quadruple - */ - /* determine k */ - double t,v; - double q0,q1,h,tmp; int k,m; - w = (n+n)/(double)x; h = 2.0/(double)x; - q0 = w; z = w+h; q1 = w*z - 1.0; k=1; - while (q1<1.0e9) { - k += 1; z += h; - tmp = z*q1 - q0; - q0 = q1; - q1 = tmp; - } - m = n+n; - for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t); - a = t; - b = one; - /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) - * Hence, if n*(log(2n/x)) > ... - * single 8.8722839355e+01 - * double 7.09782712893383973096e+02 - * long double 1.1356523406294143949491931077970765006170e+04 - * then recurrent value may overflow and the result will - * likely underflow to zero - */ - tmp = n; - v = two/x; - tmp = tmp*log(fabs(v*tmp)); - for (i=n-1;i>0;i--){ - temp = b; - b = ((i+i)/x)*b - a; - a = temp; - /* scale b to avoid spurious overflow */ -# if defined(vax) || defined(tahoe) -# define BMAX 1e13 -# else -# define BMAX 1e100 -# endif /* defined(vax) || defined(tahoe) */ - if (b > BMAX) { - a /= b; - t /= b; - b = one; - } - } - b = (t*j0(x)/b); - } - } - return ((sgn == 1) ? -b : b); -} -double yn(n,x) - int n; double x; -{ - int i, sign; - double a, b, temp; - - /* Y(n,NaN), Y(n, x < 0) is NaN */ - if (x <= 0 || (_IEEE && x != x)) - if (_IEEE && x < 0) return zero/zero; - else if (x < 0) return (infnan(EDOM)); - else if (_IEEE) return -one/zero; - else return(infnan(-ERANGE)); - else if (!finite(x)) return(0); - sign = 1; - if (n<0){ - n = -n; - sign = 1 - ((n&1)<<2); - } - if (n == 0) return(y0(x)); - if (n == 1) return(sign*y1(x)); - if(_IEEE && x >= 8.148143905337944345e+090) { /* x > 2**302 */ - /* (x >> n**2) - * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) - * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) - * Let s=sin(x), c=cos(x), - * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then - * - * n sin(xn)*sqt2 cos(xn)*sqt2 - * ---------------------------------- - * 0 s-c c+s - * 1 -s-c -c+s - * 2 -s+c -c-s - * 3 s+c c-s - */ - switch (n&3) { - case 0: temp = sin(x)-cos(x); break; - case 1: temp = -sin(x)-cos(x); break; - case 2: temp = -sin(x)+cos(x); break; - case 3: temp = sin(x)+cos(x); break; - } - b = invsqrtpi*temp/sqrt(x); - } else { - a = y0(x); - b = y1(x); - /* quit if b is -inf */ - for (i = 1; i < n && !finite(b); i++){ - temp = b; - b = ((double)(i+i)/x)*b - a; - a = temp; - } - } - if (!_IEEE && !finite(b)) - return (infnan(-sign * ERANGE)); - return ((sign > 0) ? b : -b); -} diff --git a/lib/libm/common_source/lgamma.3 b/lib/libm/common_source/lgamma.3 deleted file mode 100644 index 02bd1ad306db..000000000000 --- a/lib/libm/common_source/lgamma.3 +++ /dev/null @@ -1,124 +0,0 @@ -.\" Copyright (c) 1985, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)lgamma.3 6.6 (Berkeley) 12/3/92 -.\" $Id: lgamma.3,v 1.6 1994/01/11 00:46:56 jtc Exp $ -.\" -.Dd December 3, 1992 -.Dt LGAMMA 3 -.Os BSD 4.3 -.Sh NAME -.Nm lgamma , -.Nm gamma -.Nd log gamma function, gamma function -.Sh SYNOPSIS -.Fd #include -.Ft extern int -.Fa signgam ; -.sp -.Ft double -.Fn lgamma "double x" -.Ft double -.Fn gamma "double x" -.Sh DESCRIPTION -.Fn Lgamma x -.if t \{\ -returns ln\||\(*G(x)| where -.Bd -unfilled -offset indent -\(*G(x) = \(is\d\s8\z0\s10\u\u\s8\(if\s10\d t\u\s8x\-1\s10\d e\u\s8\-t\s10\d dt for x > 0 and -.br -\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. -.Ed -.\} -.if n \ -returns ln\||\(*G(x)|. -.Pp -The external integer -.Fa signgam -returns the sign of \(*G(x). -.Pp -.Fn Gamma x -returns \(*G(x), with no effect on -.Fa signgam . -.Sh IDIOSYNCRASIES -Do not use the expression -.Dq Li signgam\(**exp(lgamma(x)) -to compute g := \(*G(x). -Instead use a program like this (in C): -.Bd -literal -offset indent -lg = lgamma(x); g = signgam\(**exp(lg); -.Ed -.Pp -Only after -.Fn lgamma -has returned can signgam be correct. -.Pp -For arguments in its range, -.Fn gamma -is preferred, as for positive arguments -it is accurate to within one unit in the last place. -Exponentiation of -.Fn lgamma -will lose up to 10 significant bits. -.Sh RETURN VALUES -.Fn Gamma -and -.Fn lgamma -return appropriate values unless an argument is out of range. -Overflow will occur for sufficiently large positive values, and -non-positive integers. -On the -.Tn VAX, -the reserved operator is returned, -and -.Va errno -is set to -.Er ERANGE -For large non-integer negative values, -.Fn gamma -will underflow. -.Sh SEE ALSO -.Xr math 3 , -.Xr infnan 3 -.Sh HISTORY -The -.Nm lgamma -function appeared in -.Bx 4.3 . -The -.Nm gamma -function appeared in -.Bx 4.4 . -The name -.Fn gamma -was originally dedicated to the -.Fn lgamma -function, so some old code may no longer be compatible. diff --git a/lib/libm/common_source/lgamma.c b/lib/libm/common_source/lgamma.c deleted file mode 100644 index 83b6d5d03ddb..000000000000 --- a/lib/libm/common_source/lgamma.c +++ /dev/null @@ -1,308 +0,0 @@ -/*- - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)lgamma.c 5.11 (Berkeley) 12/16/92";*/ -static char rcsid[] = "$Id: lgamma.c,v 1.2 1994/02/06 18:48:04 chopps Exp $"; -#endif /* not lint */ - -/* - * Coded by Peter McIlroy, Nov 1992; - * - * The financial support of UUNET Communications Services is greatfully - * acknowledged. - */ - -#include -#include - -#include "mathimpl.h" - -/* Log gamma function. - * Error: x > 0 error < 1.3ulp. - * x > 4, error < 1ulp. - * x > 9, error < .6ulp. - * x < 0, all bets are off. (When G(x) ~ 1, log(G(x)) ~ 0) - * Method: - * x > 6: - * Use the asymptotic expansion (Stirling's Formula) - * 0 < x < 6: - * Use gamma(x+1) = x*gamma(x) for argument reduction. - * Use rational approximation in - * the range 1.2, 2.5 - * Two approximations are used, one centered at the - * minimum to ensure monotonicity; one centered at 2 - * to maintain small relative error. - * x < 0: - * Use the reflection formula, - * G(1-x)G(x) = PI/sin(PI*x) - * Special values: - * non-positive integer returns +Inf. - * NaN returns NaN -*/ -static int endian; -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -/* double and float have same size exponent field */ -#define TRUNC(x) x = (double) (float) (x) -#else -#define _IEEE 1 -#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000 -#define infnan(x) 0.0 -#endif - -static double small_lgam(double); -static double large_lgam(double); -static double neg_lgam(double); -static double zero = 0.0, one = 1.0; -int signgam; - -#define UNDERFL (1e-1020 * 1e-1020) - -#define LEFT (1.0 - (x0 + .25)) -#define RIGHT (x0 - .218) -/* -/* Constants for approximation in [1.244,1.712] -*/ -#define x0 0.461632144968362356785 -#define x0_lo -.000000000000000015522348162858676890521 -#define a0_hi -0.12148629128932952880859 -#define a0_lo .0000000007534799204229502 -#define r0 -2.771227512955130520e-002 -#define r1 -2.980729795228150847e-001 -#define r2 -3.257411333183093394e-001 -#define r3 -1.126814387531706041e-001 -#define r4 -1.129130057170225562e-002 -#define r5 -2.259650588213369095e-005 -#define s0 1.714457160001714442e+000 -#define s1 2.786469504618194648e+000 -#define s2 1.564546365519179805e+000 -#define s3 3.485846389981109850e-001 -#define s4 2.467759345363656348e-002 -/* - * Constants for approximation in [1.71, 2.5] -*/ -#define a1_hi 4.227843350984671344505727574870e-01 -#define a1_lo 4.670126436531227189e-18 -#define p0 3.224670334241133695662995251041e-01 -#define p1 3.569659696950364669021382724168e-01 -#define p2 1.342918716072560025853732668111e-01 -#define p3 1.950702176409779831089963408886e-02 -#define p4 8.546740251667538090796227834289e-04 -#define q0 1.000000000000000444089209850062e+00 -#define q1 1.315850076960161985084596381057e+00 -#define q2 6.274644311862156431658377186977e-01 -#define q3 1.304706631926259297049597307705e-01 -#define q4 1.102815279606722369265536798366e-02 -#define q5 2.512690594856678929537585620579e-04 -#define q6 -1.003597548112371003358107325598e-06 -/* - * Stirling's Formula, adjusted for equal-ripple. x in [6,Inf]. -*/ -#define lns2pi .418938533204672741780329736405 -#define pb0 8.33333333333333148296162562474e-02 -#define pb1 -2.77777777774548123579378966497e-03 -#define pb2 7.93650778754435631476282786423e-04 -#define pb3 -5.95235082566672847950717262222e-04 -#define pb4 8.41428560346653702135821806252e-04 -#define pb5 -1.89773526463879200348872089421e-03 -#define pb6 5.69394463439411649408050664078e-03 -#define pb7 -1.44705562421428915453880392761e-02 - -__pure double -lgamma(double x) -{ - double r; - - signgam = 1; - endian = ((*(int *) &one)) ? 1 : 0; - - if (!finite(x)) - if (_IEEE) - return (x+x); - else return (infnan(EDOM)); - - if (x > 6 + RIGHT) { - r = large_lgam(x); - return (r); - } else if (x > 1e-16) - return (small_lgam(x)); - else if (x > -1e-16) { - if (x < 0) - signgam = -1, x = -x; - return (-log(x)); - } else - return (neg_lgam(x)); -} - -static double -large_lgam(double x) -{ - double z, p, x1; - int i; - struct Double t, u, v; - u = log__D(x); - u.a -= 1.0; - if (x > 1e15) { - v.a = x - 0.5; - TRUNC(v.a); - v.b = (x - v.a) - 0.5; - t.a = u.a*v.a; - t.b = x*u.b + v.b*u.a; - if (_IEEE == 0 && !finite(t.a)) - return(infnan(ERANGE)); - return(t.a + t.b); - } - x1 = 1./x; - z = x1*x1; - p = pb0+z*(pb1+z*(pb2+z*(pb3+z*(pb4+z*(pb5+z*(pb6+z*pb7)))))); - /* error in approximation = 2.8e-19 */ - - p = p*x1; /* error < 2.3e-18 absolute */ - /* 0 < p < 1/64 (at x = 5.5) */ - v.a = x = x - 0.5; - TRUNC(v.a); /* truncate v.a to 26 bits. */ - v.b = x - v.a; - t.a = v.a*u.a; /* t = (x-.5)*(log(x)-1) */ - t.b = v.b*u.a + x*u.b; - t.b += p; t.b += lns2pi; /* return t + lns2pi + p */ - return (t.a + t.b); -} - -static double -small_lgam(double x) -{ - int x_int; - double y, z, t, r = 0, p, q, hi, lo; - struct Double rr; - x_int = (x + .5); - y = x - x_int; - if (x_int <= 2 && y > RIGHT) { - t = y - x0; - y--; x_int++; - goto CONTINUE; - } else if (y < -LEFT) { - t = y +(1.0-x0); -CONTINUE: - z = t - x0_lo; - p = r0+z*(r1+z*(r2+z*(r3+z*(r4+z*r5)))); - q = s0+z*(s1+z*(s2+z*(s3+z*s4))); - r = t*(z*(p/q) - x0_lo); - t = .5*t*t; - z = 1.0; - switch (x_int) { - case 6: z = (y + 5); - case 5: z *= (y + 4); - case 4: z *= (y + 3); - case 3: z *= (y + 2); - rr = log__D(z); - rr.b += a0_lo; rr.a += a0_hi; - return(((r+rr.b)+t+rr.a)); - case 2: return(((r+a0_lo)+t)+a0_hi); - case 0: r -= log1p(x); - default: rr = log__D(x); - rr.a -= a0_hi; rr.b -= a0_lo; - return(((r - rr.b) + t) - rr.a); - } - } else { - p = p0+y*(p1+y*(p2+y*(p3+y*p4))); - q = q0+y*(q1+y*(q2+y*(q3+y*(q4+y*(q5+y*q6))))); - p = p*(y/q); - t = (double)(float) y; - z = y-t; - hi = (double)(float) (p+a1_hi); - lo = a1_hi - hi; lo += p; lo += a1_lo; - r = lo*y + z*hi; /* q + r = y*(a0+p/q) */ - q = hi*t; - z = 1.0; - switch (x_int) { - case 6: z = (y + 5); - case 5: z *= (y + 4); - case 4: z *= (y + 3); - case 3: z *= (y + 2); - rr = log__D(z); - r += rr.b; r += q; - return(rr.a + r); - case 2: return (q+ r); - case 0: rr = log__D(x); - r -= rr.b; r -= log1p(x); - r += q; r-= rr.a; - return(r); - default: rr = log__D(x); - r -= rr.b; - q -= rr.a; - return (r+q); - } - } -} - -static double -neg_lgam(double x) -{ - int xi; - double y, z, one = 1.0, zero = 0.0; - extern double gamma(); - - /* avoid destructive cancellation as much as possible */ - if (x > -170) { - xi = x; - if (xi == x) - if (_IEEE) - return(one/zero); - else - return(infnan(ERANGE)); - y = gamma(x); - if (y < 0) - y = -y, signgam = -1; - return (log(y)); - } - z = floor(x + .5); - if (z == x) { /* convention: G(-(integer)) -> +Inf */ - if (_IEEE) - return (one/zero); - else - return (infnan(ERANGE)); - } - y = .5*ceil(x); - if (y == ceil(y)) - signgam = -1; - x = -x; - z = fabs(x + z); /* 0 < z <= .5 */ - if (z < .25) - z = sin(M_PI*z); - else - z = cos(M_PI*(0.5-z)); - z = log(M_PI/(z*x)); - y = large_lgam(x); - return (z - y); -} diff --git a/lib/libm/common_source/log.c b/lib/libm/common_source/log.c deleted file mode 100644 index fed2a06a4bcc..000000000000 --- a/lib/libm/common_source/log.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)log.c 5.10 (Berkeley) 1/10/93";*/ -static char rcsid[] = "$Id: log.c,v 1.5 1993/08/14 19:31:25 mycroft Exp $"; -#endif /* not lint */ - -#include -#include - -#include "log.h" - -/* Table-driven natural logarithm. - * - * This code was derived, with minor modifications, from: - * Peter Tang, "Table-Driven Implementation of the - * Logarithm in IEEE Floating-Point arithmetic." ACM Trans. - * Math Software, vol 16. no 4, pp 378-400, Dec 1990). - * - * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256, - * where F = j/128 for j an integer in [0, 128]. - * - * log(2^m) = log2_hi*m + log2_tail*m - * since m is an integer, the dominant term is exact. - * m has at most 10 digits (for subnormal numbers), - * and log2_hi has 11 trailing zero bits. - * - * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h - * logF_hi[] + 512 is exact. - * - * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ... - * the leading term is calculated to extra precision in two - * parts, the larger of which adds exactly to the dominant - * m and F terms. - * There are two cases: - * 1. when m, j are non-zero (m | j), use absolute - * precision for the leading term. - * 2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1). - * In this case, use a relative precision of 24 bits. - * (This is done differently in the original paper) - * - * Special cases: - * 0 return signalling -Inf - * neg return signalling NaN - * +Inf return +Inf -*/ - -double -#ifdef _ANSI_SOURCE -log(double x) -#else -log(x) double x; -#endif -{ - int m, j; - double F, f, g, q, u, u2, v, zero = 0.0, one = 1.0; - double logb(), ldexp(); - volatile double u1; - - /* Catch special cases */ - if (x <= 0) - if (_IEEE && x == zero) /* log(0) = -Inf */ - return (-one/zero); - else if (_IEEE) /* log(neg) = NaN */ - return (zero/zero); - else if (x == zero) /* NOT REACHED IF _IEEE */ - return (infnan(-ERANGE)); - else - return (infnan(EDOM)); - else if (!finite(x)) - if (_IEEE) /* x = NaN, Inf */ - return (x+x); - else - return (infnan(ERANGE)); - - /* Argument reduction: 1 <= g < 2; x/2^m = g; */ - /* y = F*(1 + f/F) for |f| <= 2^-8 */ - - m = logb(x); - g = ldexp(x, -m); - if (_IEEE && m == -1022) { - j = logb(g), m += j; - g = ldexp(g, -j); - } - j = N*(g-1) + .5; - F = (1.0/N) * j + 1; /* F*128 is an integer in [128, 512] */ - f = g - F; - - /* Approximate expansion for log(1+f/F) ~= u + q */ - g = 1/(2*F+f); - u = 2*f*g; - v = u*u; - q = u*v*(__log_A1 + v*(__log_A2 + v*(__log_A3 + v*__log_A4))); - - /* case 1: u1 = u rounded to 2^-43 absolute. Since u < 2^-8, - * u1 has at most 35 bits, and F*u1 is exact, as F has < 8 bits. - * It also adds exactly to |m*log2_hi + log_F_head[j] | < 750 - */ - if (m | j) - u1 = u + 513, u1 -= 513; - - /* case 2: |1-x| < 1/256. The m- and j- dependent terms are zero; - * u1 = u to 24 bits. - */ - else - u1 = u, TRUNC(u1); - u2 = (2.0*(f - F*u1) - u1*f) * g; - /* u1 + u2 = 2f/(2F+f) to extra precision. */ - - /* log(x) = log(2^m*F*(1+f/F)) = */ - /* (m*log2_hi+__logF_head[j]+u1) + (m*log2_lo+__logF_tail[j]+q);*/ - /* (exact) + (tiny) */ - - u1 += m*__logF_head[N] + __logF_head[j]; /* exact */ - u2 = (u2 + __logF_tail[j]) + q; /* tiny */ - u2 += __logF_tail[N]*m; - return (u1 + u2); -} diff --git a/lib/libm/common_source/log.h b/lib/libm/common_source/log.h deleted file mode 100644 index 89d3f14f89de..000000000000 --- a/lib/libm/common_source/log.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)log.c 5.10 (Berkeley) 1/10/93 - * $Id: log.h,v 1.2 1993/08/14 19:31:26 mycroft Exp $ - */ - -#include -#include - -#include "mathimpl.h" - -/* Table-driven natural logarithm. - * - * This code was derived, with minor modifications, from: - * Peter Tang, "Table-Driven Implementation of the - * Logarithm in IEEE Floating-Point arithmetic." ACM Trans. - * Math Software, vol 16. no 4, pp 378-400, Dec 1990). - * - * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256, - * where F = j/128 for j an integer in [0, 128]. - * - * log(2^m) = log2_hi*m + log2_tail*m - * since m is an integer, the dominant term is exact. - * m has at most 10 digits (for subnormal numbers), - * and log2_hi has 11 trailing zero bits. - * - * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h - * logF_hi[] + 512 is exact. - * - * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ... - * the leading term is calculated to extra precision in two - * parts, the larger of which adds exactly to the dominant - * m and F terms. - * There are two cases: - * 1. when m, j are non-zero (m | j), use absolute - * precision for the leading term. - * 2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1). - * In this case, use a relative precision of 24 bits. - * (This is done differently in the original paper) - * - * Special cases: - * 0 return signalling -Inf - * neg return signalling NaN - * +Inf return +Inf -*/ - -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#define TRUNC(x) x = (double) (float) (x) -#else -#define _IEEE 1 -#define endian (((*(int *) &one)) ? 1 : 0) -#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000 -#define infnan(x) 0.0 -#endif - -#define N 128 - -extern double __log_A1, __log_A2, __log_A3, __log_A4, - __logF_head[], __logF_tail[]; diff --git a/lib/libm/common_source/log10.c b/lib/libm/common_source/log10.c deleted file mode 100644 index 6257f2748f8d..000000000000 --- a/lib/libm/common_source/log10.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)log10.c 5.6 (Berkeley) 10/9/90";*/ -static char rcsid[] = "$Id: log10.c,v 1.3 1993/08/14 13:42:57 mycroft Exp $"; -#endif /* not lint */ - -/* LOG10(X) - * RETURN THE BASE 10 LOGARITHM OF x - * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 1/20/85; - * REVISED BY K.C. NG on 1/23/85, 3/7/85, 4/16/85. - * - * Required kernel function: - * log(x) - * - * Method : - * log(x) - * log10(x) = --------- or [1/log(10)]*log(x) - * log(10) - * - * Note: - * [log(10)] rounded to 56 bits has error .0895 ulps, - * [1/log(10)] rounded to 53 bits has error .198 ulps; - * therefore, for better accuracy, in VAX D format, we divide - * log(x) by log(10), but in IEEE Double format, we multiply - * log(x) by [1/log(10)]. - * - * Special cases: - * log10(x) is NaN with signal if x < 0; - * log10(+INF) is +INF with no signal; log10(0) is -INF with signal; - * log10(NaN) is that NaN with no signal. - * - * Accuracy: - * log10(X) returns the exact log10(x) nearly rounded. In a test run - * with 1,536,000 random arguments on a VAX, the maximum observed - * error was 1.74 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(ln10hi, 2.3025850929940456790E0 ,5d8d,4113,a8ac,ddaa, 2, .935D8DDDAAA8AC) - -ic(ivln10, 4.3429448190325181667E-1, -2, 1.BCB7B1526E50E) - -#ifdef vccast -#define ln10hi vccast(ln10hi) -#endif - - -double log10(x) -double x; -{ -#if defined(vax)||defined(tahoe) - return(log(x)/ln10hi); -#else /* defined(vax)||defined(tahoe) */ - return(ivln10*log(x)); -#endif /* defined(vax)||defined(tahoe) */ -} diff --git a/lib/libm/common_source/log1p.c b/lib/libm/common_source/log1p.c deleted file mode 100644 index 4a415e9a489a..000000000000 --- a/lib/libm/common_source/log1p.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)log1p.c 5.6 (Berkeley) 10/9/90";*/ -static char rcsid[] = "$Id: log1p.c,v 1.3 1993/08/14 13:42:58 mycroft Exp $"; -#endif /* not lint */ - -/* LOG1P(x) - * RETURN THE LOGARITHM OF 1+x - * DOUBLE PRECISION (VAX D FORMAT 56 bits, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. NG on 2/6/85, 3/7/85, 3/24/85, 4/16/85. - * - * Required system supported functions: - * scalb(x,n) - * copysign(x,y) - * logb(x) - * finite(x) - * - * Required kernel function: - * log__L(z) - * - * Method : - * 1. Argument Reduction: find k and f such that - * 1+x = 2^k * (1+f), - * where sqrt(2)/2 < 1+f < sqrt(2) . - * - * 2. Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) - * = 2s + 2/3 s**3 + 2/5 s**5 + ....., - * log(1+f) is computed by - * - * log(1+f) = 2s + s*log__L(s*s) - * where - * log__L(z) = z*(L1 + z*(L2 + z*(... (L6 + z*L7)...))) - * - * See log__L() for the values of the coefficients. - * - * 3. Finally, log(1+x) = k*ln2 + log(1+f). - * - * Remarks 1. In step 3 n*ln2 will be stored in two floating point numbers - * n*ln2hi + n*ln2lo, where ln2hi is chosen such that the last - * 20 bits (for VAX D format), or the last 21 bits ( for IEEE - * double) is 0. This ensures n*ln2hi is exactly representable. - * 2. In step 1, f may not be representable. A correction term c - * for f is computed. It follows that the correction term for - * f - t (the leading term of log(1+f) in step 2) is c-c*x. We - * add this correction term to n*ln2lo to attenuate the error. - * - * - * Special cases: - * log1p(x) is NaN with signal if x < -1; log1p(NaN) is NaN with no signal; - * log1p(INF) is +INF; log1p(-1) is -INF with signal; - * only log1p(0)=0 is exact for finite argument. - * - * Accuracy: - * log1p(x) returns the exact log(1+x) nearly rounded. In a test run - * with 1,536,000 random arguments on a VAX, the maximum observed - * error was .846 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include -#include "mathimpl.h" - -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(sqrt2, 1.4142135623730950622E0 ,04f3,40b5,de65,33f9, 1, .B504F333F9DE65) - -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) -ic(sqrt2, 1.4142135623730951455E0, 0, 1.6A09E667F3BCD) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define sqrt2 vccast(sqrt2) -#endif - -double log1p(x) -double x; -{ - const static double zero=0.0, negone= -1.0, one=1.0, - half=1.0/2.0, small=1.0E-20; /* 1+small == 1 */ - double z,s,t,c; - int k; - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - - if(finite(x)) { - if( x > negone ) { - - /* argument reduction */ - if(copysign(x,one)= sqrt2 ) - { k += 1 ; z *= half; t *= half; } - t += negone; x = z + t; - c = (t-x)+z ; /* correction term for x */ - - /* compute log(1+x) */ - s = x/(2+x); t = x*x*half; - c += (k*ln2lo-c*x); - z = c+s*(t+log__L(s*s)); - x += (z - t) ; - - return(k*ln2hi+x); - } - /* end of if (x > negone) */ - - else { -#if defined(vax)||defined(tahoe) - if ( x == negone ) - return (infnan(-ERANGE)); /* -INF */ - else - return (infnan(EDOM)); /* NaN */ -#else /* defined(vax)||defined(tahoe) */ - /* x = -1, return -INF with signal */ - if ( x == negone ) return( negone/zero ); - - /* negative argument for log, return NaN with signal */ - else return ( zero / zero ); -#endif /* defined(vax)||defined(tahoe) */ - } - } - /* end of if (finite(x)) */ - - /* log(-INF) is NaN */ - else if(x<0) - return(zero/zero); - - /* log(+INF) is INF */ - else return(x); -} diff --git a/lib/libm/common_source/log__D.c b/lib/libm/common_source/log__D.c deleted file mode 100644 index 1ad36fa5a5f9..000000000000 --- a/lib/libm/common_source/log__D.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)log.c 5.10 (Berkeley) 1/10/93";*/ -static char rcsid[] = "$Id: log__D.c,v 1.3 1994/02/06 18:48:06 chopps Exp $"; -#endif /* not lint */ - -#include -#include - -#include "log.h" - -/* Table-driven natural logarithm. - * - * This code was derived, with minor modifications, from: - * Peter Tang, "Table-Driven Implementation of the - * Logarithm in IEEE Floating-Point arithmetic." ACM Trans. - * Math Software, vol 16. no 4, pp 378-400, Dec 1990). - * - * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256, - * where F = j/128 for j an integer in [0, 128]. - * - * log(2^m) = log2_hi*m + log2_tail*m - * since m is an integer, the dominant term is exact. - * m has at most 10 digits (for subnormal numbers), - * and log2_hi has 11 trailing zero bits. - * - * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h - * logF_hi[] + 512 is exact. - * - * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ... - * the leading term is calculated to extra precision in two - * parts, the larger of which adds exactly to the dominant - * m and F terms. - * There are two cases: - * 1. when m, j are non-zero (m | j), use absolute - * precision for the leading term. - * 2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1). - * In this case, use a relative precision of 24 bits. - * (This is done differently in the original paper) - * - * Special cases: - * 0 return signalling -Inf - * neg return signalling NaN - * +Inf return +Inf -*/ - -/* - * Extra precision variant, returning struct {double a, b;}; - * log(x) = a+b to 63 bits, with a is rounded to 26 bits. - */ -struct Double -#ifdef _ANSI_SOURCE -log__D(double x) -#else -log__D(x) double x; -#endif -{ - int m, j; - double F, f, g, q, u, u2, v, zero = 0.0, one = 1.0; - struct Double r; - volatile double u1; - - /* Argument reduction: 1 <= g < 2; x/2^m = g; */ - /* y = F*(1 + f/F) for |f| <= 2^-8 */ - - m = logb(x); - g = ldexp(x, -m); - if (_IEEE && m == -1022) { - j = logb(g), m += j; - g = ldexp(g, -j); - } - j = N*(g-1) + .5; - F = (1.0/N) * j + 1; /* F*128 is an integer in [128, 512] */ - f = g - F; - - /* Approximate expansion for log(1+f/F) ~= u + q */ - g = 1/(2*F+f); - u = 2*f*g; - v = u*u; - q = u*v*(__log_A1 + v*(__log_A2 + v*(__log_A3 + v*__log_A4))); - - /* case 1: u1 = u rounded to 2^-43 absolute. Since u < 2^-8, - * u1 has at most 35 bits, and F*u1 is exact, as F has < 8 bits. - * It also adds exactly to |m*log2_hi + log_F_head[j] | < 750 - */ - if (m | j) - u1 = u + 513, u1 -= 513; - - /* case 2: |1-x| < 1/256. The m- and j- dependent terms are zero; - * u1 = u to 24 bits. - */ - else - u1 = u, TRUNC(u1); - u2 = (2.0*(f - F*u1) - u1*f) * g; - /* u1 + u2 = 2f/(2F+f) to extra precision. */ - - /* log(x) = log(2^m*F*(1+f/F)) = */ - /* (m*log2_hi+__logF_head[j]+u1) + (m*log2_lo+__logF_tail[j]+q);*/ - /* (exact) + (tiny) */ - - u1 += m*__logF_head[N] + __logF_head[j]; /* exact */ - u2 = (u2 + __logF_tail[j]) + q; /* tiny */ - u2 += __logF_tail[N]*m; - r.a = u1 + u2; /* Only difference is here */ - TRUNC(r.a); - r.b = (u1 - r.a) + u2; - return (r); -} diff --git a/lib/libm/common_source/log__L.c b/lib/libm/common_source/log__L.c deleted file mode 100644 index 8d4bd2082f5b..000000000000 --- a/lib/libm/common_source/log__L.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)log__L.c 5.6 (Berkeley) 10/9/90";*/ -static char rcsid[] = "$Id: log__L.c,v 1.3 1993/08/14 13:42:59 mycroft Exp $"; -#endif /* not lint */ - -/* log__L(Z) - * LOG(1+X) - 2S X - * RETURN --------------- WHERE Z = S*S, S = ------- , 0 <= Z <= .0294... - * S 2 + X - * - * DOUBLE PRECISION (VAX D FORMAT 56 bits or IEEE DOUBLE 53 BITS) - * KERNEL FUNCTION FOR LOG; TO BE USED IN LOG1P, LOG, AND POW FUNCTIONS - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. Ng, 2/3/85, 4/16/85. - * - * Method : - * 1. Polynomial approximation: let s = x/(2+x). - * Based on log(1+x) = log(1+s) - log(1-s) - * = 2s + 2/3 s**3 + 2/5 s**5 + ....., - * - * (log(1+x) - 2s)/s is computed by - * - * z*(L1 + z*(L2 + z*(... (L7 + z*L8)...))) - * - * where z=s*s. (See the listing below for Lk's values.) The - * coefficients are obtained by a special Remez algorithm. - * - * Accuracy: - * Assuming no rounding error, the maximum magnitude of the approximation - * error (absolute) is 2**(-58.49) for IEEE double, and 2**(-63.63) - * for VAX D format. - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(L1, 6.6666666666666703212E-1 ,aaaa,402a,aac5,aaaa, 0, .AAAAAAAAAAAAC5) -vc(L2, 3.9999999999970461961E-1 ,cccc,3fcc,2684,cccc, -1, .CCCCCCCCCC2684) -vc(L3, 2.8571428579395698188E-1 ,4924,3f92,5782,92f8, -1, .92492492F85782) -vc(L4, 2.2222221233634724402E-1 ,8e38,3f63,af2c,39b7, -2, .E38E3839B7AF2C) -vc(L5, 1.8181879517064680057E-1 ,2eb4,3f3a,655e,cc39, -2, .BA2EB4CC39655E) -vc(L6, 1.5382888777946145467E-1 ,8551,3f1d,781d,e8c5, -2, .9D8551E8C5781D) -vc(L7, 1.3338356561139403517E-1 ,95b3,3f08,cd92,907f, -2, .8895B3907FCD92) -vc(L8, 1.2500000000000000000E-1 ,0000,3f00,0000,0000, -2, .80000000000000) - -ic(L1, 6.6666666666667340202E-1, -1, 1.5555555555592) -ic(L2, 3.9999999999416702146E-1, -2, 1.999999997FF24) -ic(L3, 2.8571428742008753154E-1, -2, 1.24924941E07B4) -ic(L4, 2.2222198607186277597E-1, -3, 1.C71C52150BEA6) -ic(L5, 1.8183562745289935658E-1, -3, 1.74663CC94342F) -ic(L6, 1.5314087275331442206E-1, -3, 1.39A1EC014045B) -ic(L7, 1.4795612545334174692E-1, -3, 1.2F039F0085122) - -#ifdef vccast -#define L1 vccast(L1) -#define L2 vccast(L2) -#define L3 vccast(L3) -#define L4 vccast(L4) -#define L5 vccast(L5) -#define L6 vccast(L6) -#define L7 vccast(L7) -#define L8 vccast(L8) -#endif - -double log__L(z) -double z; -{ -#if defined(vax)||defined(tahoe) - return(z*(L1+z*(L2+z*(L3+z*(L4+z*(L5+z*(L6+z*(L7+z*L8)))))))); -#else /* defined(vax)||defined(tahoe) */ - return(z*(L1+z*(L2+z*(L3+z*(L4+z*(L5+z*(L6+z*L7))))))); -#endif /* defined(vax)||defined(tahoe) */ -} diff --git a/lib/libm/common_source/logtab.c b/lib/libm/common_source/logtab.c deleted file mode 100644 index 9dbc4b4ef7c8..000000000000 --- a/lib/libm/common_source/logtab.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)log.c 5.10 (Berkeley) 1/10/93";*/ -static char rcsid[] = "$Id: logtab.c,v 1.2 1993/08/14 19:31:28 mycroft Exp $"; -#endif /* not lint */ - -#include -#include - -#include "log.h" - -/* Table-driven natural logarithm. - * - * This code was derived, with minor modifications, from: - * Peter Tang, "Table-Driven Implementation of the - * Logarithm in IEEE Floating-Point arithmetic." ACM Trans. - * Math Software, vol 16. no 4, pp 378-400, Dec 1990). - * - * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256, - * where F = j/128 for j an integer in [0, 128]. - * - * log(2^m) = log2_hi*m + log2_tail*m - * since m is an integer, the dominant term is exact. - * m has at most 10 digits (for subnormal numbers), - * and log2_hi has 11 trailing zero bits. - * - * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h - * logF_hi[] + 512 is exact. - * - * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ... - * the leading term is calculated to extra precision in two - * parts, the larger of which adds exactly to the dominant - * m and F terms. - * There are two cases: - * 1. when m, j are non-zero (m | j), use absolute - * precision for the leading term. - * 2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1). - * In this case, use a relative precision of 24 bits. - * (This is done differently in the original paper) - * - * Special cases: - * 0 return signalling -Inf - * neg return signalling NaN - * +Inf return +Inf -*/ - -/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128. - * Used for generation of extend precision logarithms. - * The constant 35184372088832 is 2^45, so the divide is exact. - * It ensures correct reading of logF_head, even for inaccurate - * decimal-to-binary conversion routines. (Everybody gets the - * right answer for integers less than 2^53.) - * Values for log(F) were generated using error < 10^-57 absolute - * with the bc -l package. -*/ -double __log_A1 = .08333333333333178827; -double __log_A2 = .01250000000377174923; -double __log_A3 = .002232139987919447809; -double __log_A4 = .0004348877777076145742; - -double __logF_head[N+1] = { - 0., - .007782140442060381246, - .015504186535963526694, - .023167059281547608406, - .030771658666765233647, - .038318864302141264488, - .045809536031242714670, - .053244514518837604555, - .060624621816486978786, - .067950661908525944454, - .075223421237524235039, - .082443669210988446138, - .089612158689760690322, - .096729626458454731618, - .103796793681567578460, - .110814366340264314203, - .117783035656430001836, - .124703478501032805070, - .131576357788617315236, - .138402322859292326029, - .145182009844575077295, - .151916042025732167530, - .158605030176659056451, - .165249572895390883786, - .171850256926518341060, - .178407657472689606947, - .184922338493834104156, - .191394852999565046047, - .197825743329758552135, - .204215541428766300668, - .210564769107350002741, - .216873938300523150246, - .223143551314024080056, - .229374101064877322642, - .235566071312860003672, - .241719936886966024758, - .247836163904594286577, - .253915209980732470285, - .259957524436686071567, - .265963548496984003577, - .271933715484010463114, - .277868451003087102435, - .283768173130738432519, - .289633292582948342896, - .295464212893421063199, - .301261330578199704177, - .307025035294827830512, - .312755710004239517729, - .318453731118097493890, - .324119468654316733591, - .329753286372579168528, - .335355541920762334484, - .340926586970454081892, - .346466767346100823488, - .351976423156884266063, - .357455888922231679316, - .362905493689140712376, - .368325561158599157352, - .373716409793814818840, - .379078352934811846353, - .384411698910298582632, - .389716751140440464951, - .394993808240542421117, - .400243164127459749579, - .405465108107819105498, - .410659924985338875558, - .415827895143593195825, - .420969294644237379543, - .426084395310681429691, - .431173464818130014464, - .436236766774527495726, - .441274560805140936281, - .446287102628048160113, - .451274644139630254358, - .456237433481874177232, - .461175715122408291790, - .466089729924533457960, - .470979715219073113985, - .475845904869856894947, - .480688529345570714212, - .485507815781602403149, - .490303988045525329653, - .495077266798034543171, - .499827869556611403822, - .504556010751912253908, - .509261901790523552335, - .513945751101346104405, - .518607764208354637958, - .523248143765158602036, - .527867089620485785417, - .532464798869114019908, - .537041465897345915436, - .541597282432121573947, - .546132437597407260909, - .550647117952394182793, - .555141507540611200965, - .559615787935399566777, - .564070138285387656651, - .568504735352689749561, - .572919753562018740922, - .577315365035246941260, - .581691739635061821900, - .586049045003164792433, - .590387446602107957005, - .594707107746216934174, - .599008189645246602594, - .603290851438941899687, - .607555250224322662688, - .611801541106615331955, - .616029877215623855590, - .620240409751204424537, - .624433288012369303032, - .628608659422752680256, - .632766669570628437213, - .636907462236194987781, - .641031179420679109171, - .645137961373620782978, - .649227946625615004450, - .653301272011958644725, - .657358072709030238911, - .661398482245203922502, - .665422632544505177065, - .669430653942981734871, - .673422675212350441142, - .677398823590920073911, - .681359224807238206267, - .685304003098281100392, - .689233281238557538017, - .693147180560117703862 -}; - -double __logF_tail[N+1] = { - 0., - -.00000000000000543229938420049, - .00000000000000172745674997061, - -.00000000000001323017818229233, - -.00000000000001154527628289872, - -.00000000000000466529469958300, - .00000000000005148849572685810, - -.00000000000002532168943117445, - -.00000000000005213620639136504, - -.00000000000001819506003016881, - .00000000000006329065958724544, - .00000000000008614512936087814, - -.00000000000007355770219435028, - .00000000000009638067658552277, - .00000000000007598636597194141, - .00000000000002579999128306990, - -.00000000000004654729747598444, - -.00000000000007556920687451336, - .00000000000010195735223708472, - -.00000000000017319034406422306, - -.00000000000007718001336828098, - .00000000000010980754099855238, - -.00000000000002047235780046195, - -.00000000000008372091099235912, - .00000000000014088127937111135, - .00000000000012869017157588257, - .00000000000017788850778198106, - .00000000000006440856150696891, - .00000000000016132822667240822, - -.00000000000007540916511956188, - -.00000000000000036507188831790, - .00000000000009120937249914984, - .00000000000018567570959796010, - -.00000000000003149265065191483, - -.00000000000009309459495196889, - .00000000000017914338601329117, - -.00000000000001302979717330866, - .00000000000023097385217586939, - .00000000000023999540484211737, - .00000000000015393776174455408, - -.00000000000036870428315837678, - .00000000000036920375082080089, - -.00000000000009383417223663699, - .00000000000009433398189512690, - .00000000000041481318704258568, - -.00000000000003792316480209314, - .00000000000008403156304792424, - -.00000000000034262934348285429, - .00000000000043712191957429145, - -.00000000000010475750058776541, - -.00000000000011118671389559323, - .00000000000037549577257259853, - .00000000000013912841212197565, - .00000000000010775743037572640, - .00000000000029391859187648000, - -.00000000000042790509060060774, - .00000000000022774076114039555, - .00000000000010849569622967912, - -.00000000000023073801945705758, - .00000000000015761203773969435, - .00000000000003345710269544082, - -.00000000000041525158063436123, - .00000000000032655698896907146, - -.00000000000044704265010452446, - .00000000000034527647952039772, - -.00000000000007048962392109746, - .00000000000011776978751369214, - -.00000000000010774341461609578, - .00000000000021863343293215910, - .00000000000024132639491333131, - .00000000000039057462209830700, - -.00000000000026570679203560751, - .00000000000037135141919592021, - -.00000000000017166921336082431, - -.00000000000028658285157914353, - -.00000000000023812542263446809, - .00000000000006576659768580062, - -.00000000000028210143846181267, - .00000000000010701931762114254, - .00000000000018119346366441110, - .00000000000009840465278232627, - -.00000000000033149150282752542, - -.00000000000018302857356041668, - -.00000000000016207400156744949, - .00000000000048303314949553201, - -.00000000000071560553172382115, - .00000000000088821239518571855, - -.00000000000030900580513238244, - -.00000000000061076551972851496, - .00000000000035659969663347830, - .00000000000035782396591276383, - -.00000000000046226087001544578, - .00000000000062279762917225156, - .00000000000072838947272065741, - .00000000000026809646615211673, - -.00000000000010960825046059278, - .00000000000002311949383800537, - -.00000000000058469058005299247, - -.00000000000002103748251144494, - -.00000000000023323182945587408, - -.00000000000042333694288141916, - -.00000000000043933937969737844, - .00000000000041341647073835565, - .00000000000006841763641591466, - .00000000000047585534004430641, - .00000000000083679678674757695, - -.00000000000085763734646658640, - .00000000000021913281229340092, - -.00000000000062242842536431148, - -.00000000000010983594325438430, - .00000000000065310431377633651, - -.00000000000047580199021710769, - -.00000000000037854251265457040, - .00000000000040939233218678664, - .00000000000087424383914858291, - .00000000000025218188456842882, - -.00000000000003608131360422557, - -.00000000000050518555924280902, - .00000000000078699403323355317, - -.00000000000067020876961949060, - .00000000000016108575753932458, - .00000000000058527188436251509, - -.00000000000035246757297904791, - -.00000000000018372084495629058, - .00000000000088606689813494916, - .00000000000066486268071468700, - .00000000000063831615170646519, - .00000000000025144230728376072, - -.00000000000017239444525614834 -}; diff --git a/lib/libm/common_source/math.3 b/lib/libm/common_source/math.3 deleted file mode 100644 index 00e496cf2ce9..000000000000 --- a/lib/libm/common_source/math.3 +++ /dev/null @@ -1,633 +0,0 @@ -.\" Copyright (c) 1985 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)math.3 6.10 (Berkeley) 5/6/91 -.\" $Id: math.3,v 1.3 1993/08/14 13:43:00 mycroft Exp $ -.\" -.TH MATH 3M "May 6, 1991" -.UC 4 -.ds up \fIulp\fR -.ds nn \fINaN\fR -.de If -.if n \\ -\\$1Infinity\\$2 -.if t \\ -\\$1\\(if\\$2 -.. -.SH NAME -math \- introduction to mathematical library functions -.SH DESCRIPTION -These functions constitute the C math library, -.I libm. -The link editor searches this library under the \*(lq\-lm\*(rq option. -Declarations for these functions may be obtained from the include file -.RI < math.h >. -The Fortran math library is described in ``man 3f intro''. -.SH "LIST OF FUNCTIONS" -.sp 2 -.nf -.ta \w'copysign'u+2n +\w'infnan.3m'u+10n +\w'inverse trigonometric func'u -\fIName\fP \fIAppears on Page\fP \fIDescription\fP \fIError Bound (ULPs)\fP -.ta \w'copysign'u+4n +\w'infnan.3m'u+4n +\w'inverse trigonometric function'u+6nC -.sp 5p -acos sin.3m inverse trigonometric function 3 -acosh asinh.3m inverse hyperbolic function 3 -asin sin.3m inverse trigonometric function 3 -asinh asinh.3m inverse hyperbolic function 3 -atan sin.3m inverse trigonometric function 1 -atanh asinh.3m inverse hyperbolic function 3 -atan2 sin.3m inverse trigonometric function 2 -cabs hypot.3m complex absolute value 1 -cbrt sqrt.3m cube root 1 -ceil floor.3m integer no less than 0 -copysign ieee.3m copy sign bit 0 -cos sin.3m trigonometric function 1 -cosh sinh.3m hyperbolic function 3 -drem ieee.3m remainder 0 -erf erf.3m error function ??? -erfc erf.3m complementary error function ??? -exp exp.3m exponential 1 -expm1 exp.3m exp(x)\-1 1 -fabs floor.3m absolute value 0 -floor floor.3m integer no greater than 0 -hypot hypot.3m Euclidean distance 1 -infnan infnan.3m signals exceptions -j0 j0.3m bessel function ??? -j1 j0.3m bessel function ??? -jn j0.3m bessel function ??? -lgamma lgamma.3m log gamma function; (formerly gamma.3m) -log exp.3m natural logarithm 1 -logb ieee.3m exponent extraction 0 -log10 exp.3m logarithm to base 10 3 -log1p exp.3m log(1+x) 1 -pow exp.3m exponential x**y 60\-500 -rint floor.3m round to nearest integer 0 -scalb ieee.3m exponent adjustment 0 -sin sin.3m trigonometric function 1 -sinh sinh.3m hyperbolic function 3 -sqrt sqrt.3m square root 1 -tan sin.3m trigonometric function 3 -tanh sinh.3m hyperbolic function 3 -y0 j0.3m bessel function ??? -y1 j0.3m bessel function ??? -yn j0.3m bessel function ??? -.ta -.fi -.SH NOTES -In 4.3 BSD, distributed from the University of California -in late 1985, most of the foregoing functions come in two -versions, one for the double\-precision "D" format in the -DEC VAX\-11 family of computers, another for double\-precision -arithmetic conforming to the IEEE Standard 754 for Binary -Floating\-Point Arithmetic. The two versions behave very -similarly, as should be expected from programs more accurate -and robust than was the norm when UNIX was born. For -instance, the programs are accurate to within the numbers -of \*(ups tabulated above; an \*(up is one \fIU\fRnit in the \fIL\fRast -\fIP\fRlace. And the programs have been cured of anomalies that -afflicted the older math library \fIlibm\fR in which incidents like -the following had been reported: -.RS -sqrt(\-1.0) = 0.0 and log(\-1.0) = \-1.7e38. -.br -cos(1.0e\-11) > cos(0.0) > 1.0. -.br -pow(x,1.0) -.if n \ -!= -.if t \ -\(!= -x when x = 2.0, 3.0, 4.0, ..., 9.0. -.br -pow(\-1.0,1.0e10) trapped on Integer Overflow. -.br -sqrt(1.0e30) and sqrt(1.0e\-30) were very slow. -.RE -However the two versions do differ in ways that have to be -explained, to which end the following notes are provided. -.PP -\fBDEC VAX\-11 D_floating\-point:\fR -.PP -This is the format for which the original math library \fIlibm\fR -was developed, and to which this manual is still principally -dedicated. It is \fIthe\fR double\-precision format for the PDP\-11 -and the earlier VAX\-11 machines; VAX\-11s after 1983 were -provided with an optional "G" format closer to the IEEE -double\-precision format. The earlier DEC MicroVAXs have no -D format, only G double\-precision. (Why? Why not?) -.PP -Properties of D_floating\-point: -.RS -Wordsize: 64 bits, 8 bytes. Radix: Binary. -.br -Precision: 56 -.if n \ -sig. -.if t \ -significant -bits, roughly like 17 -.if n \ -sig. -.if t \ -significant -decimals. -.RS -If x and x' are consecutive positive D_floating\-point -numbers (they differ by 1 \*(up), then -.br -1.3e\-17 < 0.5**56 < (x'\-x)/x \(<= 0.5**55 < 2.8e\-17. -.RE -.nf -.ta \w'Range:'u+1n +\w'Underflow threshold'u+1n +\w'= 2.0**127'u+1n -Range: Overflow threshold = 2.0**127 = 1.7e38. - Underflow threshold = 0.5**128 = 2.9e\-39. - NOTE: THIS RANGE IS COMPARATIVELY NARROW. -.ta -.fi -.RS -Overflow customarily stops computation. -.br -Underflow is customarily flushed quietly to zero. -.br -CAUTION: -.RS -It is possible to have x -.if n \ -!= -.if t \ -\(!= -y and yet -x\-y = 0 because of underflow. Similarly -x > y > 0 cannot prevent either x\(**y = 0 -or y/x = 0 from happening without warning. -.RE -.RE -Zero is represented ambiguously. -.RS -Although 2**55 different representations of zero are accepted by -the hardware, only the obvious representation is ever produced. -There is no \-0 on a VAX. -.RE -.If -is not part of the VAX architecture. -.br -Reserved operands: -.RS -of the 2**55 that the hardware -recognizes, only one of them is ever produced. -Any floating\-point operation upon a reserved -operand, even a MOVF or MOVD, customarily stops -computation, so they are not much used. -.RE -Exceptions: -.RS -Divisions by zero and operations that -overflow are invalid operations that customarily -stop computation or, in earlier machines, produce -reserved operands that will stop computation. -.RE -Rounding: -.RS -Every rational operation (+, \-, \(**, /) on a -VAX (but not necessarily on a PDP\-11), if not an -over/underflow nor division by zero, is rounded to -within half an \*(up, and when the rounding error is -exactly half an \*(up then rounding is away from 0. -.RE -.RE -.PP -Except for its narrow range, D_floating\-point is one of the -better computer arithmetics designed in the 1960's. -Its properties are reflected fairly faithfully in the elementary -functions for a VAX distributed in 4.3 BSD. -They over/underflow only if their results have to lie out of range -or very nearly so, and then they behave much as any rational -arithmetic operation that over/underflowed would behave. -Similarly, expressions like log(0) and atanh(1) behave -like 1/0; and sqrt(\-3) and acos(3) behave like 0/0; -they all produce reserved operands and/or stop computation! -The situation is described in more detail in manual pages. -.RS -.ll -0.5i -\fIThis response seems excessively punitive, so it is destined -to be replaced at some time in the foreseeable future by a -more flexible but still uniform scheme being developed to -handle all floating\-point arithmetic exceptions neatly. -See infnan(3M) for the present state of affairs.\fR -.ll +0.5i -.RE -.PP -How do the functions in 4.3 BSD's new \fIlibm\fR for UNIX -compare with their counterparts in DEC's VAX/VMS library? -Some of the VMS functions are a little faster, some are -a little more accurate, some are more puritanical about -exceptions (like pow(0.0,0.0) and atan2(0.0,0.0)), -and most occupy much more memory than their counterparts in -\fIlibm\fR. -The VMS codes interpolate in large table to achieve -speed and accuracy; the \fIlibm\fR codes use tricky formulas -compact enough that all of them may some day fit into a ROM. -.PP -More important, DEC regards the VMS codes as proprietary -and guards them zealously against unauthorized use. But the -\fIlibm\fR codes in 4.3 BSD are intended for the public domain; -they may be copied freely provided their provenance is always -acknowledged, and provided users assist the authors in their -researches by reporting experience with the codes. -Therefore no user of UNIX on a machine whose arithmetic resembles -VAX D_floating\-point need use anything worse than the new \fIlibm\fR. -.PP -\fBIEEE STANDARD 754 Floating\-Point Arithmetic:\fR -.PP -This standard is on its way to becoming more widely adopted -than any other design for computer arithmetic. -VLSI chips that conform to some version of that standard have been -produced by a host of manufacturers, among them ... -.nf -.ta 0.5i +\w'Intel i8070, i80287'u+6n - Intel i8087, i80287 National Semiconductor 32081 - Motorola 68881 Weitek WTL-1032, ... , -1165 - Zilog Z8070 Western Electric (AT&T) WE32106. -.ta -.fi -Other implementations range from software, done thoroughly -in the Apple Macintosh, through VLSI in the Hewlett\-Packard -9000 series, to the ELXSI 6400 running ECL at 3 Megaflops. -Several other companies have adopted the formats -of IEEE 754 without, alas, adhering to the standard's way -of handling rounding and exceptions like over/underflow. -The DEC VAX G_floating\-point format is very similar to the IEEE -754 Double format, so similar that the C programs for the -IEEE versions of most of the elementary functions listed -above could easily be converted to run on a MicroVAX, though -nobody has volunteered to do that yet. -.PP -The codes in 4.3 BSD's \fIlibm\fR for machines that conform to -IEEE 754 are intended primarily for the National Semi. 32081 -and WTL 1164/65. To use these codes with the Intel or Zilog -chips, or with the Apple Macintosh or ELXSI 6400, is to -forego the use of better codes provided (perhaps freely) by -those companies and designed by some of the authors of the -codes above. -Except for \fIatan\fR, \fIcabs\fR, \fIcbrt\fR, \fIerf\fR, -\fIerfc\fR, \fIhypot\fR, \fIj0\-jn\fR, \fIlgamma\fR, \fIpow\fR -and \fIy0\-yn\fR, -the Motorola 68881 has all the functions in \fIlibm\fR on chip, -and faster and more accurate; -it, Apple, the i8087, Z8070 and WE32106 all use 64 -.if n \ -sig. -.if t \ -significant -bits. -The main virtue of 4.3 BSD's -\fIlibm\fR codes is that they are intended for the public domain; -they may be copied freely provided their provenance is always -acknowledged, and provided users assist the authors in their -researches by reporting experience with the codes. -Therefore no user of UNIX on a machine that conforms to -IEEE 754 need use anything worse than the new \fIlibm\fR. -.PP -Properties of IEEE 754 Double\-Precision: -.RS -Wordsize: 64 bits, 8 bytes. Radix: Binary. -.br -Precision: 53 -.if n \ -sig. -.if t \ -significant -bits, roughly like 16 -.if n \ -sig. -.if t \ -significant -decimals. -.RS -If x and x' are consecutive positive Double\-Precision -numbers (they differ by 1 \*(up), then -.br -1.1e\-16 < 0.5**53 < (x'\-x)/x \(<= 0.5**52 < 2.3e\-16. -.RE -.nf -.ta \w'Range:'u+1n +\w'Underflow threshold'u+1n +\w'= 2.0**1024'u+1n -Range: Overflow threshold = 2.0**1024 = 1.8e308 - Underflow threshold = 0.5**1022 = 2.2e\-308 -.ta -.fi -.RS -Overflow goes by default to a signed -.If "" . -.br -Underflow is \fIGradual,\fR rounding to the nearest -integer multiple of 0.5**1074 = 4.9e\-324. -.RE -Zero is represented ambiguously as +0 or \-0. -.RS -Its sign transforms correctly through multiplication or -division, and is preserved by addition of zeros -with like signs; but x\-x yields +0 for every -finite x. The only operations that reveal zero's -sign are division by zero and copysign(x,\(+-0). -In particular, comparison (x > y, x \(>= y, etc.) -cannot be affected by the sign of zero; but if -finite x = y then -.If -\&= 1/(x\-y) -.if n \ -!= -.if t \ -\(!= -\-1/(y\-x) = -.If \- . -.RE -.If -is signed. -.RS -it persists when added to itself -or to any finite number. Its sign transforms -correctly through multiplication and division, and -.If (finite)/\(+- \0=\0\(+-0 -(nonzero)/0 = -.If \(+- . -But -.if n \ -Infinity\-Infinity, Infinity\(**0 and Infinity/Infinity -.if t \ -\(if\-\(if, \(if\(**0 and \(if/\(if -are, like 0/0 and sqrt(\-3), -invalid operations that produce \*(nn. ... -.RE -Reserved operands: -.RS -there are 2**53\-2 of them, all -called \*(nn (\fIN\fRot \fIa N\fRumber). -Some, called Signaling \*(nns, trap any floating\-point operation -performed upon them; they are used to mark missing -or uninitialized values, or nonexistent elements -of arrays. The rest are Quiet \*(nns; they are -the default results of Invalid Operations, and -propagate through subsequent arithmetic operations. -If x -.if n \ -!= -.if t \ -\(!= -x then x is \*(nn; every other predicate -(x > y, x = y, x < y, ...) is FALSE if \*(nn is involved. -.br -NOTE: Trichotomy is violated by \*(nn. -.RS -Besides being FALSE, predicates that entail ordered -comparison, rather than mere (in)equality, -signal Invalid Operation when \*(nn is involved. -.RE -.RE -Rounding: -.RS -Every algebraic operation (+, \-, \(**, /, -.if n \ -sqrt) -.if t \ -\(sr) -is rounded by default to within half an \*(up, and -when the rounding error is exactly half an \*(up then -the rounded value's least significant bit is zero. -This kind of rounding is usually the best kind, -sometimes provably so; for instance, for every -x = 1.0, 2.0, 3.0, 4.0, ..., 2.0**52, we find -(x/3.0)\(**3.0 == x and (x/10.0)\(**10.0 == x and ... -despite that both the quotients and the products -have been rounded. Only rounding like IEEE 754 -can do that. But no single kind of rounding can be -proved best for every circumstance, so IEEE 754 -provides rounding towards zero or towards -.If + -or towards -.If \- -at the programmer's option. And the -same kinds of rounding are specified for -Binary\-Decimal Conversions, at least for magnitudes -between roughly 1.0e\-10 and 1.0e37. -.RE -Exceptions: -.RS -IEEE 754 recognizes five kinds of floating\-point exceptions, -listed below in declining order of probable importance. -.RS -.nf -.ta \w'Invalid Operation'u+6n +\w'Gradual Underflow'u+2n -Exception Default Result -.tc \(ru - -.tc -Invalid Operation \*(nn, or FALSE -.if n \{\ -Overflow \(+-Infinity -Divide by Zero \(+-Infinity \} -.if t \{\ -Overflow \(+-\(if -Divide by Zero \(+-\(if \} -Underflow Gradual Underflow -Inexact Rounded value -.ta -.fi -.RE -NOTE: An Exception is not an Error unless handled -badly. What makes a class of exceptions exceptional -is that no single default response can be satisfactory -in every instance. On the other hand, if a default -response will serve most instances satisfactorily, -the unsatisfactory instances cannot justify aborting -computation every time the exception occurs. -.RE -.PP -For each kind of floating\-point exception, IEEE 754 -provides a Flag that is raised each time its exception -is signaled, and stays raised until the program resets -it. Programs may also test, save and restore a flag. -Thus, IEEE 754 provides three ways by which programs -may cope with exceptions for which the default result -might be unsatisfactory: -.IP 1) \w'\0\0\0\0'u -Test for a condition that might cause an exception -later, and branch to avoid the exception. -.IP 2) \w'\0\0\0\0'u -Test a flag to see whether an exception has occurred -since the program last reset its flag. -.IP 3) \w'\0\0\0\0'u -Test a result to see whether it is a value that only -an exception could have produced. -.RS -CAUTION: The only reliable ways to discover -whether Underflow has occurred are to test whether -products or quotients lie closer to zero than the -underflow threshold, or to test the Underflow -flag. (Sums and differences cannot underflow in -IEEE 754; if x -.if n \ -!= -.if t \ -\(!= -y then x\-y is correct to -full precision and certainly nonzero regardless of -how tiny it may be.) Products and quotients that -underflow gradually can lose accuracy gradually -without vanishing, so comparing them with zero -(as one might on a VAX) will not reveal the loss. -Fortunately, if a gradually underflowed value is -destined to be added to something bigger than the -underflow threshold, as is almost always the case, -digits lost to gradual underflow will not be missed -because they would have been rounded off anyway. -So gradual underflows are usually \fIprovably\fR ignorable. -The same cannot be said of underflows flushed to 0. -.RE -.PP -At the option of an implementor conforming to IEEE 754, -other ways to cope with exceptions may be provided: -.IP 4) \w'\0\0\0\0'u -ABORT. This mechanism classifies an exception in -advance as an incident to be handled by means -traditionally associated with error\-handling -statements like "ON ERROR GO TO ...". Different -languages offer different forms of this statement, -but most share the following characteristics: -.IP \(em \w'\0\0\0\0'u -No means is provided to substitute a value for -the offending operation's result and resume -computation from what may be the middle of an -expression. An exceptional result is abandoned. -.IP \(em \w'\0\0\0\0'u -In a subprogram that lacks an error\-handling -statement, an exception causes the subprogram to -abort within whatever program called it, and so -on back up the chain of calling subprograms until -an error\-handling statement is encountered or the -whole task is aborted and memory is dumped. -.IP 5) \w'\0\0\0\0'u -STOP. This mechanism, requiring an interactive -debugging environment, is more for the programmer -than the program. It classifies an exception in -advance as a symptom of a programmer's error; the -exception suspends execution as near as it can to -the offending operation so that the programmer can -look around to see how it happened. Quite often -the first several exceptions turn out to be quite -unexceptionable, so the programmer ought ideally -to be able to resume execution after each one as if -execution had not been stopped. -.IP 6) \w'\0\0\0\0'u -\&... Other ways lie beyond the scope of this document. -.RE -.PP -The crucial problem for exception handling is the problem of -Scope, and the problem's solution is understood, but not -enough manpower was available to implement it fully in time -to be distributed in 4.3 BSD's \fIlibm\fR. Ideally, each -elementary function should act as if it were indivisible, or -atomic, in the sense that ... -.IP i) \w'iii)'u+2n -No exception should be signaled that is not deserved by -the data supplied to that function. -.IP ii) \w'iii)'u+2n -Any exception signaled should be identified with that -function rather than with one of its subroutines. -.IP iii) \w'iii)'u+2n -The internal behavior of an atomic function should not -be disrupted when a calling program changes from -one to another of the five or so ways of handling -exceptions listed above, although the definition -of the function may be correlated intentionally -with exception handling. -.PP -Ideally, every programmer should be able \fIconveniently\fR to -turn a debugged subprogram into one that appears atomic to -its users. But simulating all three characteristics of an -atomic function is still a tedious affair, entailing hosts -of tests and saves\-restores; work is under way to ameliorate -the inconvenience. -.PP -Meanwhile, the functions in \fIlibm\fR are only approximately -atomic. They signal no inappropriate exception except -possibly ... -.RS -Over/Underflow -.RS -when a result, if properly computed, might have lain barely within range, and -.RE -Inexact in \fIcabs\fR, \fIcbrt\fR, \fIhypot\fR, \fIlog10\fR and \fIpow\fR -.RS -when it happens to be exact, thanks to fortuitous cancellation of errors. -.RE -.RE -Otherwise, ... -.RS -Invalid Operation is signaled only when -.RS -any result but \*(nn would probably be misleading. -.RE -Overflow is signaled only when -.RS -the exact result would be finite but beyond the overflow threshold. -.RE -Divide\-by\-Zero is signaled only when -.RS -a function takes exactly infinite values at finite operands. -.RE -Underflow is signaled only when -.RS -the exact result would be nonzero but tinier than the underflow threshold. -.RE -Inexact is signaled only when -.RS -greater range or precision would be needed to represent the exact result. -.RE -.RE -.SH BUGS -When signals are appropriate, they are emitted by certain -operations within the codes, so a subroutine\-trace may be -needed to identify the function with its signal in case -method 5) above is in use. And the codes all take the -IEEE 754 defaults for granted; this means that a decision to -trap all divisions by zero could disrupt a code that would -otherwise get correct results despite division by zero. -.SH SEE ALSO -An explanation of IEEE 754 and its proposed extension p854 -was published in the IEEE magazine MICRO in August 1984 under -the title "A Proposed Radix\- and Word\-length\-independent -Standard for Floating\-point Arithmetic" by W. J. Cody et al. -The manuals for Pascal, C and BASIC on the Apple Macintosh -document the features of IEEE 754 pretty well. -Articles in the IEEE magazine COMPUTER vol. 14 no. 3 (Mar. -1981), and in the ACM SIGNUM Newsletter Special Issue of -Oct. 1979, may be helpful although they pertain to -superseded drafts of the standard. diff --git a/lib/libm/common_source/mathimpl.h b/lib/libm/common_source/mathimpl.h deleted file mode 100644 index ff4be6bff29e..000000000000 --- a/lib/libm/common_source/mathimpl.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 1988 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)mathimpl.h 5.5 (Berkeley) 12/2/92 - * $Id: mathimpl.h,v 1.4 1993/08/14 13:43:01 mycroft Exp $ - */ - -#include -#include - -#if defined(vax)||defined(tahoe) - -/* Deal with different ways to concatenate in cpp */ -# ifdef __STDC__ -# define cat3(a,b,c) a ## b ## c -# else -# define cat3(a,b,c) a/**/b/**/c -# endif - -/* Deal with vax/tahoe byte order issues */ -# ifdef vax -# define cat3t(a,b,c) cat3(a,b,c) -# else -# define cat3t(a,b,c) cat3(a,c,b) -# endif - -# define vccast(name) (*(const double *)(cat3(name,,x))) - - /* - * Define a constant to high precision on a Vax or Tahoe. - * - * Args are the name to define, the decimal floating point value, - * four 16-bit chunks of the float value in hex - * (because the vax and tahoe differ in float format!), the power - * of 2 of the hex-float exponent, and the hex-float mantissa. - * Most of these arguments are not used at compile time; they are - * used in a post-check to make sure the constants were compiled - * correctly. - * - * People who want to use the constant will have to do their own - * #define foo vccast(foo) - * since CPP cannot do this for them from inside another macro (sigh). - * We define "vccast" if this needs doing. - */ -# define vc(name, value, x1,x2,x3,x4, bexp, xval) \ - const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)}; - -# define ic(name, value, bexp, xval) ; - -#else /* vax or tahoe */ - - /* Hooray, we have an IEEE machine */ -# undef vccast -# define vc(name, value, x1,x2,x3,x4, bexp, xval) ; - -# define ic(name, value, bexp, xval) \ - const static double name = value; - -#endif /* defined(vax)||defined(tahoe) */ - - -/* - * Functions internal to the math package, yet not static. - */ -extern double exp__E(); -extern double log__L(); - -struct Double {double a, b;}; -double exp__D __P((double, double)); -struct Double log__D __P((double)); diff --git a/lib/libm/common_source/pow.c b/lib/libm/common_source/pow.c deleted file mode 100644 index 9b797270292f..000000000000 --- a/lib/libm/common_source/pow.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)pow.c 5.9 (Berkeley) 12/16/92";*/ -static char rcsid[] = "$Id: pow.c,v 1.4 1993/10/19 01:31:09 cgd Exp $"; -#endif /* not lint */ - -/* POW(X,Y) - * RETURN X**Y - * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 1/8/85; - * REVISED BY K.C. NG on 7/10/85. - * KERNEL pow_P() REPLACED BY P. McILROY 7/22/92. - * Required system supported functions: - * scalb(x,n) - * logb(x) - * copysign(x,y) - * finite(x) - * drem(x,y) - * - * Required kernel functions: - * exp__D(a,c) exp(a + c) for |a| << |c| - * struct d_double dlog(x) r.a + r.b, |r.b| < |r.a| - * - * Method - * 1. Compute and return log(x) in three pieces: - * log(x) = n*ln2 + hi + lo, - * where n is an integer. - * 2. Perform y*log(x) by simulating muti-precision arithmetic and - * return the answer in three pieces: - * y*log(x) = m*ln2 + hi + lo, - * where m is an integer. - * 3. Return x**y = exp(y*log(x)) - * = 2^m * ( exp(hi+lo) ). - * - * Special cases: - * (anything) ** 0 is 1 ; - * (anything) ** 1 is itself; - * (anything) ** NaN is NaN; - * NaN ** (anything except 0) is NaN; - * +(anything > 1) ** +INF is +INF; - * -(anything > 1) ** +INF is NaN; - * +-(anything > 1) ** -INF is +0; - * +-(anything < 1) ** +INF is +0; - * +(anything < 1) ** -INF is +INF; - * -(anything < 1) ** -INF is NaN; - * +-1 ** +-INF is NaN and signal INVALID; - * +0 ** +(anything except 0, NaN) is +0; - * -0 ** +(anything except 0, NaN, odd integer) is +0; - * +0 ** -(anything except 0, NaN) is +INF and signal DIV-BY-ZERO; - * -0 ** -(anything except 0, NaN, odd integer) is +INF with signal; - * -0 ** (odd integer) = -( +0 ** (odd integer) ); - * +INF ** +(anything except 0,NaN) is +INF; - * +INF ** -(anything except 0,NaN) is +0; - * -INF ** (odd integer) = -( +INF ** (odd integer) ); - * -INF ** (even integer) = ( +INF ** (even integer) ); - * -INF ** -(anything except integer,NaN) is NaN with signal; - * -(x=anything) ** (k=integer) is (-1)**k * (x ** k); - * -(anything except 0) ** (non-integer) is NaN with signal; - * - * Accuracy: - * pow(x,y) returns x**y nearly rounded. In particular, on a SUN, a VAX, - * and a Zilog Z8000, - * pow(integer,integer) - * always returns the correct integer provided it is representable. - * In a test run with 100,000 random arguments with 0 < x, y < 20.0 - * on a VAX, the maximum observed error was 1.79 ulps (units in the - * last place). - * - * Constants : - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include -#include - -#include "mathimpl.h" - -#if (defined(vax) || defined(tahoe)) -#define TRUNC(x) x = (double) (float) x -#define _IEEE 0 -#else -#define _IEEE 1 -#define endian (((*(int *) &one)) ? 1 : 0) -#define TRUNC(x) *(((int *) &x)+endian) &= 0xf8000000 -#define infnan(x) 0.0 -#endif /* vax or tahoe */ - -const static double zero=0.0, one=1.0, two=2.0, negone= -1.0; - -static double pow_P __P((double, double)); - -double pow(x,y) -double x,y; -{ - double t; - if (y==zero) - return (one); - else if (y==one || (_IEEE && x != x)) - return (x); /* if x is NaN or y=1 */ - else if (_IEEE && y!=y) /* if y is NaN */ - return (y); - else if (!finite(y)) /* if y is INF */ - if ((t=fabs(x))==one) /* +-1 ** +-INF is NaN */ - return (y - y); - else if (t>one) - return ((y<0)? zero : ((x0)? zero : ((x<0)? y-y : -y)); - else if (y==two) - return (x*x); - else if (y==negone) - return (one/x); - /* x > 0, x == +0 */ - else if (copysign(one, x) == one) - return (pow_P(x, y)); - - /* sign(x)= -1 */ - /* if y is an even integer */ - else if ( (t=drem(y,two)) == zero) - return (pow_P(-x, y)); - - /* if y is an odd integer */ - else if (copysign(t,one) == one) - return (-pow_P(-x, y)); - - /* Henceforth y is not an integer */ - else if (x==zero) /* x is -0 */ - return ((y>zero)? -x : one/(-x)); - else if (_IEEE) - return (zero/zero); - else - return (infnan(EDOM)); -} -/* kernel function for x >= 0 */ -static double -#ifdef _ANSI_SOURCE -pow_P(double x, double y) -#else -pow_P(x, y) double x, y; -#endif -{ - struct Double s, t, log__D(); - double exp__D(), huge = 1e300, tiny = 1e-300; - - if (x == zero) - if (y > zero) - return (zero); - else if (_IEEE) - return (huge*huge); - else - return (infnan(ERANGE)); - if (x == one) - return (one); - if (!finite(x)) - if (y < zero) - return (zero); - else if (_IEEE) - return (huge*huge); - else - return (infnan(ERANGE)); - if (y >= 7e18) /* infinity */ - if (x < 1) - return(tiny*tiny); - else if (_IEEE) - return (huge*huge); - else - return (infnan(ERANGE)); - - /* Return exp(y*log(x)), using simulated extended */ - /* precision for the log and the multiply. */ - - s = log__D(x); - t.a = y; - TRUNC(t.a); - t.b = y - t.a; - t.b = s.b*y + t.b*s.a; - t.a *= s.a; - s.a = t.a + t.b; - s.b = (t.a - s.a) + t.b; - return (exp__D(s.a, s.b)); -} diff --git a/lib/libm/common_source/rint.3 b/lib/libm/common_source/rint.3 deleted file mode 100644 index 127b4adfa999..000000000000 --- a/lib/libm/common_source/rint.3 +++ /dev/null @@ -1,116 +0,0 @@ -.\" Copyright (c) 1985, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)rint.3 5.1 (Berkeley) 5/2/91 -.\" $Id: rint.3,v 1.3 1993/08/14 13:43:02 mycroft Exp $ -.\" -.Dd May 2, 1991 -.Dt RINT 3 -.Os -.Sh NAME -.Nm rint -.Nd and round-to-closest integer functions -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn rint "double x" -.Sh DESCRIPTION -The -.Fn rint -function finds the integer (represented as a double precision number) -nearest to -.Fa x -in the direction of the prevailing rounding mode. -.Sh NOTES -On a -.Tn VAX , -.Fn rint x -is equivalent to adding half to the magnitude -and then rounding towards zero. -.Pp -In the default rounding mode, to nearest, -on a machine that conforms to -.Tn IEEE -754, -.Fn rint x -is the integer nearest -.Fa x -with the additional stipulation -that if -.Li |rint(x)\-x|=1/2 -then -.Fn rint x -is even. -Other rounding modes can make -.Fn rint -act like -.Fn floor , -or like -.Fn ceil , -or round towards zero. -.Pp -Another way to obtain an integer near -.Fa x -is to declare (in C) -.Bd -literal -offset indent -double x;\0\0\0\0 int k;\0\0\0\0k\0=\0x; -.Ed -.Pp -Most C compilers round -.Fa x -towards 0 to get the integer -.Fa k , -but -some do otherwise. -If in doubt, use -.Fn floor , -.Fn ceil , -or -.Fn rint -first, whichever you intend. -Also note that, if x is larger than -.Fa k -can accommodate, the value of -.Fa k -and the presence or absence of an integer overflow are hard to -predict. -.Sh SEE ALSO -.Xr abs 3 , -.Xr fabs 3 , -.Xr ceil 3 , -.Xr floor 3 , -.Xr ieee 3 , -.Xr math 3 -.Sh HISTORY -A -.Fn rint -function appeared in -.At v6 . diff --git a/lib/libm/common_source/sin.3 b/lib/libm/common_source/sin.3 deleted file mode 100644 index 4274a0f38cc4..000000000000 --- a/lib/libm/common_source/sin.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" @(#)sin.3 6.7 (Berkeley) 4/19/91 -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)sin.3 6.7 (Berkeley) 4/19/91 -.\" $Id: sin.3,v 1.4 1993/10/29 22:57:28 jtc Exp $ -.\" -.Dd April 19, 1991 -.Dt SIN 3 -.Os -.Sh NAME -.Nm sin -.Nd sine function -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn sin "double x" -.Sh DESCRIPTION -The -.Fn sin -function computes the sine of -.Fa x -(measured in radians). -A large magnitude argument may yield a result with little -or no significance. -.Sh RETURN VALUES -The -.Fn sin -function returns the sine value. -.Sh SEE ALSO -.Xr acos 3 , -.Xr asin 3 , -.Xr atan 3 , -.Xr atan2 3 , -.Xr cos 3 , -.Xr cosh 3 , -.Xr sinh 3 , -.Xr tan 3 , -.Xr tanh 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn sin -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/sinh.3 b/lib/libm/common_source/sinh.3 deleted file mode 100644 index 39e0a1fa4822..000000000000 --- a/lib/libm/common_source/sinh.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)sinh.3 6.6 (Berkeley) 4/19/91 -.\" $Id: sinh.3,v 1.4 1993/10/29 22:57:30 jtc Exp $ -.Dd April 19, 1991 -.Dt SINH 3 -.Os -.Sh NAME -.Nm sinh -.Nd hyperbolic sine function -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn sinh "double x" -.Sh DESCRIPTION -The -.Fn sinh -function computes the hyperbolic sine of -.Fa x . -.Sh RETURN VALUES -The -.Fn sinh -function returns the hyperbolic sine value unless -the magnitude -of -.Fa x -is too large; in this event, the global variable -.Va errno -is set to -.Er ERANGE . -.Sh SEE ALSO -.Xr acos 3 , -.Xr asin 3 , -.Xr atan 3 , -.Xr atan2 3 , -.Xr cos 3 , -.Xr cosh 3 , -.Xr sin 3 , -.Xr tan 3 , -.Xr tanh 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn sinh -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/sinh.c b/lib/libm/common_source/sinh.c deleted file mode 100644 index 0d9876c09594..000000000000 --- a/lib/libm/common_source/sinh.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)sinh.c 5.6 (Berkeley) 10/9/90";*/ -static char rcsid[] = "$Id: sinh.c,v 1.3 1993/08/14 13:43:05 mycroft Exp $"; -#endif /* not lint */ - -/* SINH(X) - * RETURN THE HYPERBOLIC SINE OF X - * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 1/8/85; - * REVISED BY K.C. NG on 2/8/85, 3/7/85, 3/24/85, 4/16/85. - * - * Required system supported functions : - * copysign(x,y) - * scalb(x,N) - * - * Required kernel functions: - * expm1(x) ...return exp(x)-1 - * - * Method : - * 1. reduce x to non-negative by sinh(-x) = - sinh(x). - * 2. - * - * expm1(x) + expm1(x)/(expm1(x)+1) - * 0 <= x <= lnovfl : sinh(x) := -------------------------------- - * 2 - * lnovfl <= x <= lnovfl+ln2 : sinh(x) := expm1(x)/2 (avoid overflow) - * lnovfl+ln2 < x < INF : overflow to INF - * - * - * Special cases: - * sinh(x) is x if x is +INF, -INF, or NaN. - * only sinh(0)=0 is exact for finite argument. - * - * Accuracy: - * sinh(x) returns the exact hyperbolic sine of x nearly rounded. In - * a test run with 1,024,000 random arguments on a VAX, the maximum - * observed error was 1.93 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(mln2hi, 8.8029691931113054792E1 ,0f33,43b0,2bdb,c7e2, 7, .B00F33C7E22BDB) -vc(mln2lo,-4.9650192275318476525E-16 ,1b60,a70f,582a,279e, -50,-.8F1B60279E582A) -vc(lnovfl, 8.8029691931113053016E1 ,0f33,43b0,2bda,c7e2, 7, .B00F33C7E22BDA) - -ic(mln2hi, 7.0978271289338397310E2, 10, 1.62E42FEFA39EF) -ic(mln2lo, 2.3747039373786107478E-14, -45, 1.ABC9E3B39803F) -ic(lnovfl, 7.0978271289338397310E2, 9, 1.62E42FEFA39EF) - -#ifdef vccast -#define mln2hi vccast(mln2hi) -#define mln2lo vccast(mln2lo) -#define lnovfl vccast(lnovfl) -#endif - -#if defined(vax)||defined(tahoe) -static max = 126 ; -#else /* defined(vax)||defined(tahoe) */ -static max = 1023 ; -#endif /* defined(vax)||defined(tahoe) */ - - -double sinh(x) -double x; -{ - static const double one=1.0, half=1.0/2.0 ; - double t, sign; -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - sign=copysign(one,x); - x=copysign(x,one); - if(x -.Ft double -.Fn cbrt "double x" -.Ft double -.Fn sqrt "double x" -.Sh DESCRIPTION -The -.Fn cbrt -function computes -the cube root of -.Ar x . -.Pp -The -.Fn sqrt -computes the -non-negative square root of x. -.Sh RETURN VALUES -The -.Fn cbrt -function returns the requested cube root. -The -.Fn sqrt -function returns the requested square root -unless an error occurs. -On the -.Tn VAX -or -.Tn Tahoe -processor an attempt to take the -.Fn sqrt -of negative -.Fa x -causes an error; in this event, -the global variable -.Va errno -is set to -.Dv EDOM -and a reserved operand fault is generated. -.Sh ERROR (due to Roundoff etc.) -The -.Fn cbrt -function -is accurate to within 0.7 -.Em ulps . -.Pp -The -.Fn sqrt -function on a -.Tn VAX -is accurate to within 0.501 -.Em ulps . -Sqrt on a machine that conforms to -.Tn IEEE -754 is correctly rounded -in accordance with the rounding mode in force; the error is less than -half an -.Em ulp -in the default mode (round\-to\-nearest). -An -.Em ulp -is one -.Em U Ns nit -in the -.Em L Ns ast -.Em P Ns lace -carried. -.Sh SEE ALSO -.Xr math 3 , -.Xr infnan 3 -.Sh STANDARDS -The -.Nm sqrt -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Nm cbrt -function appeared in -.Bx 4.3 . diff --git a/lib/libm/common_source/tan.3 b/lib/libm/common_source/tan.3 deleted file mode 100644 index c1acb480aee6..000000000000 --- a/lib/libm/common_source/tan.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)tan.3 5.1 (Berkeley) 5/2/91 -.\" $Id: tan.3,v 1.4 1993/10/05 16:33:47 jtc Exp $ -.\" -.Dd May 2, 1991 -.Dt TAN 3 -.Os -.Sh NAME -.Nm tan -.Nd tangent function -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn tan "double x" -.Sh DESCRIPTION -The -.Fn tan -function computes the tangent of -.Fa x -(measured in radians). -A large magnitude argument may yield a result -with little or no significance. -For a discussion of error due to roundoff, see -.Xr math 3 . -.Sh RETURN VALUES -The -.Fn tan -function returns the tangent value. -.Sh SEE ALSO -.Xr acos 3 , -.Xr asin 3 , -.Xr atan 3 , -.Xr atan2 3 , -.Xr cos 3 , -.Xr cosh 3 , -.Xr sin 3 , -.Xr sinh 3 , -.Xr tanh 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn tan -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/tanh.3 b/lib/libm/common_source/tanh.3 deleted file mode 100644 index 2f1e27fc88c8..000000000000 --- a/lib/libm/common_source/tanh.3 +++ /dev/null @@ -1,71 +0,0 @@ -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)tanh.3 5.1 (Berkeley) 5/2/91 -.\" $Id: tanh.3,v 1.4 1993/10/05 16:33:49 jtc Exp $ -.\" -.Dd May 2, 1991 -.Dt TANH 3 -.Os -.Sh NAME -.Nm tanh -.Nd hyperbolic tangent function -.Sh SYNOPSIS -.Fd #include -.Ft double -.Fn tanh "double x" -.Sh DESCRIPTION -The -.Fn tanh -function computes the hyperbolic tangent of -.Fa x . -For a discussion of error due to roundoff, see -.Xr math 3 . -.Sh RETURN VALUES -The -.Fn tanh -function returns the hyperbolic tangent value. -.Sh SEE ALSO -.Xr acos 3 , -.Xr asin 3 , -.Xr atan 3 , -.Xr atan2 3 , -.Xr cos 3 , -.Xr cosh 3 , -.Xr sin 3 , -.Xr sinh 3 , -.Xr tan 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn tanh -function conforms to -.St -ansiC . diff --git a/lib/libm/common_source/tanh.c b/lib/libm/common_source/tanh.c deleted file mode 100644 index e621754fbe3c..000000000000 --- a/lib/libm/common_source/tanh.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)tanh.c 5.5 (Berkeley) 10/9/90";*/ -static char rcsid[] = "$Id: tanh.c,v 1.3 1993/08/14 13:43:08 mycroft Exp $"; -#endif /* not lint */ - -/* TANH(X) - * RETURN THE HYPERBOLIC TANGENT OF X - * DOUBLE PRECISION (VAX D FORMAT 56 BITS, IEEE DOUBLE 53 BITS) - * CODED IN C BY K.C. NG, 1/8/85; - * REVISED BY K.C. NG on 2/8/85, 2/11/85, 3/7/85, 3/24/85. - * - * Required system supported functions : - * copysign(x,y) - * finite(x) - * - * Required kernel function: - * expm1(x) ...exp(x)-1 - * - * Method : - * 1. reduce x to non-negative by tanh(-x) = - tanh(x). - * 2. - * 0 < x <= 1.e-10 : tanh(x) := x - * -expm1(-2x) - * 1.e-10 < x <= 1 : tanh(x) := -------------- - * expm1(-2x) + 2 - * 2 - * 1 <= x <= 22.0 : tanh(x) := 1 - --------------- - * expm1(2x) + 2 - * 22.0 < x <= INF : tanh(x) := 1. - * - * Note: 22 was chosen so that fl(1.0+2/(expm1(2*22)+2)) == 1. - * - * Special cases: - * tanh(NaN) is NaN; - * only tanh(0)=0 is exact for finite argument. - * - * Accuracy: - * tanh(x) returns the exact hyperbolic tangent of x nealy rounded. - * In a test run with 1,024,000 random arguments on a VAX, the maximum - * observed error was 2.22 ulps (units in the last place). - */ - -double tanh(x) -double x; -{ - static double one=1.0, two=2.0, small = 1.0e-10, big = 1.0e10; - double expm1(), t, copysign(), sign; - int finite(); - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - - sign=copysign(one,x); - x=copysign(x,one); - if(x < 22.0) - if( x > one ) - return(copysign(one-two/(expm1(x+x)+two),sign)); - else if ( x > small ) - {t= -expm1(-(x+x)); return(copysign(t/(two-t),sign));} - else /* raise the INEXACT flag for non-zero x */ - {big+x; return(copysign(x,sign));} - else if(finite(x)) - return (sign+1.0E-37); /* raise the INEXACT flag */ - else - return(sign); /* x is +- INF */ -} diff --git a/lib/libm/i387/exp.S b/lib/libm/i387/exp.S deleted file mode 100644 index 5a9439cc2eb9..000000000000 --- a/lib/libm/i387/exp.S +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include -#include "errno.h" - -/* e^x = 2^(x * log2(e)) */ -ENTRY(exp) - fldl 4(%esp) -#ifdef notyet - fxam - fstsw %ax - testw $0x0100,%ax /* Nan */ - jne Lnan - testw $0x0500,%ax /* Inf */ - jne Linf - testw $0x????,%ax /* Zero */ - jne Lzero -#endif - fldl2e - fmulp /* x * log2(e) */ - fstl %st(1) - frndint /* int(x * log2(e)) */ - fstl %st(2) - fsubrp /* fract(x * log2(e)) */ - f2xm1 /* 2^(fract(x * log2(e))) - 1 */ - fld1 - faddp /* 2^(fract(x * log2(e))) */ - fscale /* e^x */ - ret - -#ifdef notyet -Lnan: - movl EDOM,_errno - ret -Linf: - movl ERANGE,_errno - ftst - fstsw %ax - testw $0x0100,%ax - jne Lminf - ret -Lminf: - fldz - fstpl st,st(%1) - ret -Lzero: - fld1 - fstpl st,%st(1) - ret -#endif diff --git a/lib/libm/i387/exp10.S b/lib/libm/i387/exp10.S deleted file mode 100644 index 98da34f01be6..000000000000 --- a/lib/libm/i387/exp10.S +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include -#include "errno.h" - -/* 10^x = 2^(x * log2(10)) */ -ENTRY(exp10) - fldl 4(%ebp) -#ifdef notyet - fxam - fstsw %ax - testw $0x0100,%ax /* Nan */ - jne Lnan - testw $0x0500,%ax /* Inf */ - jne Linf - testw $0x????,%ax /* Zero */ - jne Lzero -#endif - fldl2t - fmulp /* x * log2(10) */ - fstl %st(1) - frndint /* int(x * log2(10)) */ - fstl %st(2) - fsubrp /* fract(x * log2(10)) */ - f2xm1 /* 2^(fract(x * log2(10))) - 1 */ - fld1 - faddp /* 2^(fract(x * log2(10))) */ - fscale /* 10^x */ - ret - -#ifdef notyet -Lnan: - movl EDOM,_errno - ret -Linf: /* +-Inf */ - movl ERANGE,_errno - ftst - fstsw %ax - testw $0x0100,%ax - jne Lminf - ret -Lminf: /* -Inf */ - fldz - fstpl st,st(%1) - ret -Lzero: - fld1 - fstpl st,st(%1) - ret -#endif diff --git a/lib/libm/i387/exp10.s b/lib/libm/i387/exp10.s deleted file mode 100644 index f9c33382e88e..000000000000 --- a/lib/libm/i387/exp10.s +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include -#include "errno.h" - -/* 10^x = 2^(x * log2(10)) */ -ENTRY(exp10) - fldl 4(%ebp) -#ifdef notyet - fxam - fstsw %ax - testw $0x0100,%ax /* Nan */ - jne Lnan - testw $0x0500,%ax /* Inf */ - jne Linf - testw $0x????,%ax /* Zero */ - jne Lzero -#endif - fldl2t - fmulp /* x * log2(10) */ - fstl %st(1) - frndint /* int(x * log2(10)) */ - fstl %st(2) - fsubrp /* fract(x * log2(10)) */ - f2xm1 /* 2^(fract(x * log2(10))) - 1 */ - fld1 - faddp /* 2^(fract(x * log2(10))) */ - fscale /* 10^x */ - ret - -#ifdef notyet -Lnan: - movl EDOM,_errno - ret -Linf: /* +-Inf */ - movl ERANGE,_errno - ftst - fstsw %ax - testw $0x0100,%ax - jne Lminf - ret -Lminf: /* -Inf */ - fldz - fstpl st,st(%1) - ret -Lzero: - fld1 - fstpl st,st(%1) - ret -#endif diff --git a/lib/libm/i387/exp2.S b/lib/libm/i387/exp2.S deleted file mode 100644 index 708ed47885d7..000000000000 --- a/lib/libm/i387/exp2.S +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include -#include "errno.h" - -ENTRY(exp2) - fldl 4(%esp) -#ifdef notyet - fxam - fstsw %ax - testw $0x0100,%ax /* Nan */ - jne Lnan - testw $0x0500,%ax /* Inf */ - jne Linf - testw $0x????,%ax /* Zero */ - jne Lzero -#endif - fstl %st(1) - frndint /* int(x) */ - fstl %st(2) - fsubrp /* fract(x) */ - f2xm1 /* 2^(fract(x)) - 1 */ - fld1 - faddp /* 2^(fract(x)) */ - fscale /* 2^(fract(x)) * 2^(int(x)) = 2^x */ - ret - -#ifdef notyet -Lnan: - movl EDOM,_errno - ret -Linf: - movl ERANGE,_errno - ftst - fstsw %ax - testw $0x0100,%ax - jne Lminf - ret -Lminf: - fldz - fstpl st,st(%1) - ret -Lzero: - fld1 - fstpl st,st(%1) - ret -#endif diff --git a/lib/libm/i387/exp2.s b/lib/libm/i387/exp2.s deleted file mode 100644 index db4d6d614f7f..000000000000 --- a/lib/libm/i387/exp2.s +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include -#include "errno.h" - -ENTRY(exp2) - fldl 4(%esp) -#ifdef notyet - fxam - fstsw %ax - testw $0x0100,%ax /* Nan */ - jne Lnan - testw $0x0500,%ax /* Inf */ - jne Linf - testw $0x????,%ax /* Zero */ - jne Lzero -#endif - fstl %st(1) - frndint /* int(x) */ - fstl %st(2) - fsubrp /* fract(x) */ - f2xm1 /* 2^(fract(x)) - 1 */ - fld1 - faddp /* 2^(fract(x)) */ - fscale /* 2^(fract(x)) * 2^(int(x)) = 2^x */ - ret - -#ifdef notyet -Lnan: - movl EDOM,_errno - ret -Linf: - movl ERANGE,_errno - ftst - fstsw %ax - testw $0x0100,%ax - jne Lminf - ret -Lminf: - fldz - fstpl st,st(%1) - ret -Lzero: - fld1 - fstpl st,st(%1) - ret -#endif diff --git a/lib/libm/i387/finite.S b/lib/libm/i387/finite.S deleted file mode 100644 index 6e77d8e49c14..000000000000 --- a/lib/libm/i387/finite.S +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(finite) - movl 8(%esp),%eax - andl $0x7ff00000, %eax - cmpl $0x7ff00000, %eax - setnel %al - andl $0x000000ff, %eax - ret diff --git a/lib/libm/i387/finite.s b/lib/libm/i387/finite.s deleted file mode 100644 index e968b0caba90..000000000000 --- a/lib/libm/i387/finite.s +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(finite) - movl 8(%esp),%eax - andl $0x7ff00000, %eax - cmpl $0x7ff00000, %eax - setnel %al - andl $0x000000ff, %eax - ret diff --git a/lib/libm/i387/floor.S b/lib/libm/i387/floor.S deleted file mode 100644 index b7f38698a001..000000000000 --- a/lib/libm/i387/floor.S +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(floor) - pushl %ebp - movl %esp,%ebp - subl $8,%esp - - fstcw -12(%ebp) /* store fpu control word */ - movw -12(%ebp),%dx - orw $0x0400,%dx /* round towards -oo */ - andw $0xf7ff,%dx - movw %dx,-16(%ebp) - fldcw -16(%ebp) /* load modfied control word */ - - fldl 8(%ebp); /* round */ - frndint - - fldcw -12(%ebp) /* restore original control word */ - - leave - ret diff --git a/lib/libm/i387/floor.s b/lib/libm/i387/floor.s deleted file mode 100644 index 27dfc8f3a4ea..000000000000 --- a/lib/libm/i387/floor.s +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(floor) - pushl %ebp - movl %esp,%ebp - subl $8,%esp - - fstcw -12(%ebp) /* store fpu control word */ - movw -12(%ebp),%dx - orw $0x0400,%dx /* round towards -oo */ - andw $0xf7ff,%dx - movw %dx,-16(%ebp) - fldcw -16(%ebp) /* load modfied control word */ - - fldl 8(%ebp); /* round */ - frndint - - fldcw -12(%ebp) /* restore original control word */ - - leave - ret diff --git a/lib/libm/i387/log.S b/lib/libm/i387/log.S deleted file mode 100644 index 35e102f821fc..000000000000 --- a/lib/libm/i387/log.S +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(log) - fldln2 - fldl 4(%ebp) - fyl2x - ret diff --git a/lib/libm/i387/log.s b/lib/libm/i387/log.s deleted file mode 100644 index 61d1ccc2b84d..000000000000 --- a/lib/libm/i387/log.s +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(log) - fldln2 - fldl 4(%ebp) - fyl2x - ret diff --git a/lib/libm/i387/log10.S b/lib/libm/i387/log10.S deleted file mode 100644 index 2c9fcdd1e768..000000000000 --- a/lib/libm/i387/log10.S +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(log10) - fldln2 - fldl 4(%ebp) - fyl2x - ret diff --git a/lib/libm/i387/log10.s b/lib/libm/i387/log10.s deleted file mode 100644 index e83bf2e184da..000000000000 --- a/lib/libm/i387/log10.s +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(log10) - fldln2 - fldl 4(%ebp) - fyl2x - ret diff --git a/lib/libm/i387/log1p.S b/lib/libm/i387/log1p.S deleted file mode 100644 index 93d6d7003869..000000000000 --- a/lib/libm/i387/log1p.S +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(log1p) - fldln2 - fldl 4(%ebp) - fyl2xp1 - ret diff --git a/lib/libm/i387/log1p.s b/lib/libm/i387/log1p.s deleted file mode 100644 index d0116480d004..000000000000 --- a/lib/libm/i387/log1p.s +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(log1p) - fldln2 - fldl 4(%ebp) - fyl2xp1 - ret diff --git a/lib/libm/i387/log2.S b/lib/libm/i387/log2.S deleted file mode 100644 index 47f82e0411b5..000000000000 --- a/lib/libm/i387/log2.S +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(log2) - fld1 - fldl 4(%ebp) - fyl2x - ret diff --git a/lib/libm/i387/log2.s b/lib/libm/i387/log2.s deleted file mode 100644 index fba38a3275e7..000000000000 --- a/lib/libm/i387/log2.s +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(log2) - fld1 - fldl 4(%ebp) - fyl2x - ret diff --git a/lib/libm/i387/logb.S b/lib/libm/i387/logb.S deleted file mode 100644 index 933f2d926b94..000000000000 --- a/lib/libm/i387/logb.S +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(logb) - fldl 4(%esp) - fxtract - fstpl %st - ret diff --git a/lib/libm/i387/logb.s b/lib/libm/i387/logb.s deleted file mode 100644 index 3c88c2f76d97..000000000000 --- a/lib/libm/i387/logb.s +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(logb) - fldl 4(%esp) - fxtract - fstpl %st - ret diff --git a/lib/libm/i387/rint.S b/lib/libm/i387/rint.S deleted file mode 100644 index 741e7621d823..000000000000 --- a/lib/libm/i387/rint.S +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(rint) - fldl 4(%esp) - frndint - ret diff --git a/lib/libm/i387/rint.s b/lib/libm/i387/rint.s deleted file mode 100644 index 859e40e714a8..000000000000 --- a/lib/libm/i387/rint.s +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(rint) - fldl 4(%esp) - frndint - ret diff --git a/lib/libm/i387/scalb.S b/lib/libm/i387/scalb.S deleted file mode 100644 index 8ed554feedc7..000000000000 --- a/lib/libm/i387/scalb.S +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(scalb) - fildl 12(%esp) - fldl 4(%esp) - fscale - fstpl %st(1) /* fixup stack */ - ret diff --git a/lib/libm/i387/scalb.s b/lib/libm/i387/scalb.s deleted file mode 100644 index e8903c2f410e..000000000000 --- a/lib/libm/i387/scalb.s +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(scalb) - fildl 12(%esp) - fldl 4(%esp) - fscale - fstpl %st(1) /* fixup stack */ - ret diff --git a/lib/libm/i387/sin.S b/lib/libm/i387/sin.S deleted file mode 100644 index f56ce90b1ec3..000000000000 --- a/lib/libm/i387/sin.S +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(sin) - fldpi /* Pi */ - fadd %st(0),%st /* 2 Pi */ - fldl 4(%esp) /* Theta */ -1: fprem1 - fstswl %ax - sahf - jp 1b - fstpl %st(1) - fsin - ret diff --git a/lib/libm/i387/sin.s b/lib/libm/i387/sin.s deleted file mode 100644 index 8ca1c46b59d5..000000000000 --- a/lib/libm/i387/sin.s +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(sin) - fldpi /* Pi */ - fadd %st(0),%st /* 2 Pi */ - fldl 4(%esp) /* Theta */ -1: fprem1 - fstswl %ax - sahf - jp 1b - fstpl %st(1) - fsin - ret diff --git a/lib/libm/i387/sqrt.S b/lib/libm/i387/sqrt.S deleted file mode 100644 index 90db43739398..000000000000 --- a/lib/libm/i387/sqrt.S +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(sqrt) - fldl 4(%esp) - fsqrt - ret diff --git a/lib/libm/i387/sqrt.s b/lib/libm/i387/sqrt.s deleted file mode 100644 index a52f5b900e21..000000000000 --- a/lib/libm/i387/sqrt.s +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(sqrt) - fldl 4(%esp) - fsqrt - ret diff --git a/lib/libm/i387/tan.S b/lib/libm/i387/tan.S deleted file mode 100644 index b1403e0a2449..000000000000 --- a/lib/libm/i387/tan.S +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(tan) - fldpi /* Pi */ - fadd %st(0),%st /* 2 Pi */ - fldl 4(%esp) /* Theta */ -1: fprem1 - fstswl %ax - sahf - jp 1b - fstpl %st(1) - fptan - fstpl %st(0) - ret diff --git a/lib/libm/i387/tan.s b/lib/libm/i387/tan.s deleted file mode 100644 index 2e3881560ea3..000000000000 --- a/lib/libm/i387/tan.s +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -#include - -ENTRY(tan) - fldpi /* Pi */ - fadd %st(0),%st /* 2 Pi */ - fldl 4(%esp) /* Theta */ -1: fprem1 - fstswl %ax - sahf - jp 1b - fstpl %st(1) - fptan - fstpl %st(0) - ret diff --git a/lib/libm/mc68881/floor.S b/lib/libm/mc68881/floor.S deleted file mode 100644 index 68f9bcd3dd42..000000000000 --- a/lib/libm/mc68881/floor.S +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)floor.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: floor.S,v 1.1 1993/08/14 13:43:36 mycroft Exp $" - - .text - .globl _floor,_ceil,_rint - -| floor(x) -| the largest integer no larger than x -_floor: - fmovel fpcr,d0 | save old FPCR - fmoved sp@(4),fp0 | get argument - fbun Lret | if NaN, return NaN - fboge Lrtz | >=0, round to zero - fmovel #0x20,fpcr | <0, round to -inf - jra Ldoit - -| ceil(x) -| -floor(-x), for all real x -_ceil: - fmovel fpcr,d0 | save old FPCR - fmoved sp@(4),fp0 | get argument - fbun Lret | if NaN, return NaN - fbolt Lrtz | <0, round to zero - fmovel #0x30,fpcr | >=0, round to inf - jra Ldoit - -Lrtz: - fmovel #0x10,fpcr -Ldoit: - fintd sp@(4),fp0 | truncate - fmovel d0,fpcr | restore old FPCR -Lret: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - -| rint(x) -| delivers integer nearest x in direction of prevailing rounding mode -_rint: - fintd sp@(4),fp0 | use prevailing rounding mode - jra Lret diff --git a/lib/libm/mc68881/log.S b/lib/libm/mc68881/log.S deleted file mode 100644 index e7ab25863c51..000000000000 --- a/lib/libm/mc68881/log.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)log.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: log.S,v 1.1 1993/08/14 13:43:37 mycroft Exp $" - -/* log(x) */ - - .text - .globl _log - -_log: - flognd sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/log10.S b/lib/libm/mc68881/log10.S deleted file mode 100644 index 967b48e13165..000000000000 --- a/lib/libm/mc68881/log10.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)log10.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: log10.S,v 1.1 1993/08/14 13:43:39 mycroft Exp $" - -/* log10(x) */ - - .text - .globl _log10 - -_log10: - flog10d sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/log10.s b/lib/libm/mc68881/log10.s deleted file mode 100644 index e28160b78eb4..000000000000 --- a/lib/libm/mc68881/log10.s +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)log10.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: log10.s,v 1.1 1993/08/14 13:43:39 mycroft Exp $" - -/* log10(x) */ - - .text - .globl _log10 - -_log10: - flog10d sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/log1p.S b/lib/libm/mc68881/log1p.S deleted file mode 100644 index 0ba9decacd61..000000000000 --- a/lib/libm/mc68881/log1p.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)log1p.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: log1p.S,v 1.1 1993/08/14 13:43:40 mycroft Exp $" - -/* log1p(x) */ - - .text - .globl _log1p - -_log1p: - flognp1d sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/log1p.s b/lib/libm/mc68881/log1p.s deleted file mode 100644 index cfadecf000fb..000000000000 --- a/lib/libm/mc68881/log1p.s +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)log1p.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: log1p.s,v 1.1 1993/08/14 13:43:40 mycroft Exp $" - -/* log1p(x) */ - - .text - .globl _log1p - -_log1p: - flognp1d sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/mcount.sed b/lib/libm/mc68881/mcount.sed deleted file mode 100644 index 286b7b75753b..000000000000 --- a/lib/libm/mc68881/mcount.sed +++ /dev/null @@ -1,8 +0,0 @@ -# $Id: mcount.sed,v 1.1 1993/08/14 13:43:41 mycroft Exp $ -s/^\(_[a-z_].*\):$/&\ - .data\ -X\1:\ - .long 0\ - .text\ - movel #X\1,a0\ - jsr mcount/ diff --git a/lib/libm/mc68881/sincos.S b/lib/libm/mc68881/sincos.S deleted file mode 100644 index f7241ef3f53d..000000000000 --- a/lib/libm/mc68881/sincos.S +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)sincos.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: sincos.S,v 1.1 1993/08/14 13:43:42 mycroft Exp $" - -/* sin(x) and cos(x) */ - - .text - .globl _sin, _cos - -_sin: - fsind sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - -_cos: - fcosd sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/sincos.s b/lib/libm/mc68881/sincos.s deleted file mode 100644 index 779e5398b5ec..000000000000 --- a/lib/libm/mc68881/sincos.s +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)sincos.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: sincos.s,v 1.1 1993/08/14 13:43:42 mycroft Exp $" - -/* sin(x) and cos(x) */ - - .text - .globl _sin, _cos - -_sin: - fsind sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - -_cos: - fcosd sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/sinh.S b/lib/libm/mc68881/sinh.S deleted file mode 100644 index 3a35942f811a..000000000000 --- a/lib/libm/mc68881/sinh.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)sinh.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: sinh.S,v 1.1 1993/08/14 13:43:43 mycroft Exp $" - -/* sinh(x) */ - - .text - .globl _sinh - -_sinh: - fsinhd sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/sinh.s b/lib/libm/mc68881/sinh.s deleted file mode 100644 index c556f52e73db..000000000000 --- a/lib/libm/mc68881/sinh.s +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)sinh.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: sinh.s,v 1.1 1993/08/14 13:43:43 mycroft Exp $" - -/* sinh(x) */ - - .text - .globl _sinh - -_sinh: - fsinhd sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/sqrt.S b/lib/libm/mc68881/sqrt.S deleted file mode 100644 index fb7600db4a3c..000000000000 --- a/lib/libm/mc68881/sqrt.S +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)sqrt.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: sqrt.S,v 1.1 1993/08/14 13:43:44 mycroft Exp $" - -/* - * sqrt(x) - * returns the square root of x correctly rounded according - * to the rounding mode. - */ - - .text - .globl _sqrt - -_sqrt: - fsqrtd sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/sqrt.s b/lib/libm/mc68881/sqrt.s deleted file mode 100644 index 6928e4502a2c..000000000000 --- a/lib/libm/mc68881/sqrt.s +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)sqrt.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: sqrt.s,v 1.1 1993/08/14 13:43:44 mycroft Exp $" - -/* - * sqrt(x) - * returns the square root of x correctly rounded according - * to the rounding mode. - */ - - .text - .globl _sqrt - -_sqrt: - fsqrtd sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/support.S b/lib/libm/mc68881/support.S deleted file mode 100644 index 4ce773a44e63..000000000000 --- a/lib/libm/mc68881/support.S +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)support.s 5.2 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: support.S,v 1.1 1993/08/14 13:43:45 mycroft Exp $" - - .text - .globl _copysign, _finite, _scalb, _logb, _drem, _pow_p, _atan2__A - -| copysign(x,y) -| returns x with the sign of y. -_copysign: - movl sp@(4),d0 - movl sp@(8),d1 - tstw sp@(12) - jmi Lneg - bclr #31,d0 - rts -Lneg: - bset #31,d0 - rts - -| finite(x) -| returns the value TRUE if -INF < x < +INF and returns FALSE otherwise. -_finite: - movw #0x7FF0,d0 - movw sp@(4),d1 - andw d0,d1 - cmpw d0,d1 - beq Lnotfin - moveq #1,d0 - rts -Lnotfin: - clrl d0 - rts - -| scalb(x, N) -| returns x * (2**N), for integer values N. -_scalb: - fmoved sp@(4),fp0 - fbeq Ldone - fscalel sp@(12),fp0 -Ldone: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - -| logb(x) -| returns the unbiased exponent of x, a signed integer in double precision, -| except that logb(0) is -INF, logb(INF) is +INF, and logb(NAN) is that NAN. -_logb: - movw sp@(4),d0 - movw #0x7FF0,d1 | exponent bits - andw d1,d0 | mask off all else - cmpw d1,d0 | max exponent? - bne Lfinite | no, is finite - fmoved sp@(4),fp0 | yes, infinite or NaN - fbun Ldone | NaN returns NaN - fabsx fp0 | +-inf returns inf - jra Ldone -Lfinite: - fmoved sp@(4),fp0 | get entire number - fbne Lnonz | zero? - flog2x fp0 | yes, log(0) a convenient source of -inf - jra Ldone -Lnonz: - fgetexpx fp0 | get exponent - jra Ldone - -| drem(x,y) -| returns x REM y = x - [x/y]*y , where [x/y] is the integer nearest x/y; -| in half way case, choose the even one. -_drem: - fmoved sp@(4),fp0 - fremd sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - -| pow_p(x,y) -| return x**y for x with sign=1 and finite y -_pow_p: - flognd sp@(4),fp0 - fmuld sp@(12),fp0 - fetoxx fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - -| atan2__A(y,x) -| compute atan2(y,x) where x,y are finite and non-zero -| called by atan2() after weeding out all the special cases -_atan2__A: - moveq #0,d0 | sign of result - fmoved sp@(4),fp0 | get y - fboge Lypos | <0? - moveq #1,d0 | yes, result is neg - fnegx fp0 | make y pos -Lypos: - fmoved sp@(12),fp1 | get x - fboge Lxpos | <0? - fnegx fp1 | yes, make x pos - fdivx fp1,fp0 | y/x - fatanx fp0,fp1 | atan(y/x) - fmovecr #0,fp0 | get pi - fsubx fp1,fp0 | pi - atan(y/x) - jra Lsetsign -Lxpos: - fdivx fp1,fp0 | y/x - fatanx fp0 | atan(y/x) -Lsetsign: - tstl d0 | should be neg? - jeq Lrpos | no, all done - fnegx fp0 | yes, negate -Lrpos: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/support.s b/lib/libm/mc68881/support.s deleted file mode 100644 index e582754f4191..000000000000 --- a/lib/libm/mc68881/support.s +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)support.s 5.2 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: support.s,v 1.1 1993/08/14 13:43:45 mycroft Exp $" - - .text - .globl _copysign, _finite, _scalb, _logb, _drem, _pow_p, _atan2__A - -| copysign(x,y) -| returns x with the sign of y. -_copysign: - movl sp@(4),d0 - movl sp@(8),d1 - tstw sp@(12) - jmi Lneg - bclr #31,d0 - rts -Lneg: - bset #31,d0 - rts - -| finite(x) -| returns the value TRUE if -INF < x < +INF and returns FALSE otherwise. -_finite: - movw #0x7FF0,d0 - movw sp@(4),d1 - andw d0,d1 - cmpw d0,d1 - beq Lnotfin - moveq #1,d0 - rts -Lnotfin: - clrl d0 - rts - -| scalb(x, N) -| returns x * (2**N), for integer values N. -_scalb: - fmoved sp@(4),fp0 - fbeq Ldone - fscalel sp@(12),fp0 -Ldone: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - -| logb(x) -| returns the unbiased exponent of x, a signed integer in double precision, -| except that logb(0) is -INF, logb(INF) is +INF, and logb(NAN) is that NAN. -_logb: - movw sp@(4),d0 - movw #0x7FF0,d1 | exponent bits - andw d1,d0 | mask off all else - cmpw d1,d0 | max exponent? - bne Lfinite | no, is finite - fmoved sp@(4),fp0 | yes, infinite or NaN - fbun Ldone | NaN returns NaN - fabsx fp0 | +-inf returns inf - jra Ldone -Lfinite: - fmoved sp@(4),fp0 | get entire number - fbne Lnonz | zero? - flog2x fp0 | yes, log(0) a convenient source of -inf - jra Ldone -Lnonz: - fgetexpx fp0 | get exponent - jra Ldone - -| drem(x,y) -| returns x REM y = x - [x/y]*y , where [x/y] is the integer nearest x/y; -| in half way case, choose the even one. -_drem: - fmoved sp@(4),fp0 - fremd sp@(12),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - -| pow_p(x,y) -| return x**y for x with sign=1 and finite y -_pow_p: - flognd sp@(4),fp0 - fmuld sp@(12),fp0 - fetoxx fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts - -| atan2__A(y,x) -| compute atan2(y,x) where x,y are finite and non-zero -| called by atan2() after weeding out all the special cases -_atan2__A: - moveq #0,d0 | sign of result - fmoved sp@(4),fp0 | get y - fboge Lypos | <0? - moveq #1,d0 | yes, result is neg - fnegx fp0 | make y pos -Lypos: - fmoved sp@(12),fp1 | get x - fboge Lxpos | <0? - fnegx fp1 | yes, make x pos - fdivx fp1,fp0 | y/x - fatanx fp0,fp1 | atan(y/x) - fmovecr #0,fp0 | get pi - fsubx fp1,fp0 | pi - atan(y/x) - jra Lsetsign -Lxpos: - fdivx fp1,fp0 | y/x - fatanx fp0 | atan(y/x) -Lsetsign: - tstl d0 | should be neg? - jeq Lrpos | no, all done - fnegx fp0 | yes, negate -Lrpos: - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/tan.S b/lib/libm/mc68881/tan.S deleted file mode 100644 index 5efb94798d33..000000000000 --- a/lib/libm/mc68881/tan.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)tan.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: tan.S,v 1.1 1993/08/14 13:43:46 mycroft Exp $" - -/* tan(x) */ - - .text - .globl _tan - -_tan: - ftand sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/tan.s b/lib/libm/mc68881/tan.s deleted file mode 100644 index d095eea58503..000000000000 --- a/lib/libm/mc68881/tan.s +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)tan.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: tan.s,v 1.1 1993/08/14 13:43:46 mycroft Exp $" - -/* tan(x) */ - - .text - .globl _tan - -_tan: - ftand sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/tanh.S b/lib/libm/mc68881/tanh.S deleted file mode 100644 index 1f08ad5d2095..000000000000 --- a/lib/libm/mc68881/tanh.S +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)tanh.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: tanh.S,v 1.1 1993/08/14 13:43:46 mycroft Exp $" - -/* tanh(x) */ - - .text - .globl _tanh - -_tanh: - ftanhd sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/mc68881/tanh.s b/lib/libm/mc68881/tanh.s deleted file mode 100644 index 40f6de9a5862..000000000000 --- a/lib/libm/mc68881/tanh.s +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)tanh.s 5.1 (Berkeley) 5/17/90" -_rcsid: -.asciz "$Id: tanh.s,v 1.1 1993/08/14 13:43:46 mycroft Exp $" - -/* tanh(x) */ - - .text - .globl _tanh - -_tanh: - ftanhd sp@(4),fp0 - fmoved fp0,sp@- - movel sp@+,d0 - movel sp@+,d1 - rts diff --git a/lib/libm/vax/sqrt.S b/lib/libm/vax/sqrt.S deleted file mode 100644 index fde2a0ef4548..000000000000 --- a/lib/libm/vax/sqrt.S +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright (c) 1985 Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)sqrt.s 1.1 (Berkeley) 8/21/85; 5.4 (ucb.elefunt) 10/9/90" -_rcsid: -.asciz "$Id: sqrt.S,v 1.1 1993/08/14 13:44:14 mycroft Exp $" - -/* - * double sqrt(arg) revised August 15,1982 - * double arg; - * if(arg<0.0) { _errno = EDOM; return(); } - * if arg is a reserved operand it is returned as it is - * W. Kahan's magic square root - * coded by Heidi Stettner and revised by Emile LeBlanc 8/18/82 - * - * entry points:_d_sqrt address of double arg is on the stack - * _sqrt double arg is on the stack - */ - .text - .align 1 - .globl _sqrt - .globl _d_sqrt - .globl libm$dsqrt_r5 - .set EDOM,33 - -_d_sqrt: - .word 0x003c # save r5,r4,r3,r2 - movq *4(ap),r0 - jmp dsqrt2 -_sqrt: - .word 0x003c # save r5,r4,r3,r2 - movq 4(ap),r0 -dsqrt2: bicw3 $0x807f,r0,r2 # check exponent of input - jeql noexp # biased exponent is zero -> 0.0 or reserved - bsbb libm$dsqrt_r5 -noexp: ret - -/* **************************** internal procedure */ - -libm$dsqrt_r5: # ENTRY POINT FOR cdabs and cdsqrt - # returns double square root scaled by - # 2^r6 - - movd r0,r4 - jleq nonpos # argument is not positive - movzwl r4,r2 - ashl $-1,r2,r0 - addw2 $0x203c,r0 # r0 has magic initial approximation -/* - * Do two steps of Heron's rule - * ((arg/guess) + guess) / 2 = better guess - */ - divf3 r0,r4,r2 - addf2 r2,r0 - subw2 $0x80,r0 # divide by two - - divf3 r0,r4,r2 - addf2 r2,r0 - subw2 $0x80,r0 # divide by two - -/* Scale argument and approximation to prevent over/underflow */ - - bicw3 $0x807f,r4,r1 - subw2 $0x4080,r1 # r1 contains scaling factor - subw2 r1,r4 - movl r0,r2 - subw2 r1,r2 - -/* Cubic step - * - * b = a + 2*a*(n-a*a)/(n+3*a*a) where b is better approximation, - * a is approximation, and n is the original argument. - * (let s be scale factor in the following comments) - */ - clrl r1 - clrl r3 - muld2 r0,r2 # r2:r3 = a*a/s - subd2 r2,r4 # r4:r5 = n/s - a*a/s - addw2 $0x100,r2 # r2:r3 = 4*a*a/s - addd2 r4,r2 # r2:r3 = n/s + 3*a*a/s - muld2 r0,r4 # r4:r5 = a*n/s - a*a*a/s - divd2 r2,r4 # r4:r5 = a*(n-a*a)/(n+3*a*a) - addw2 $0x80,r4 # r4:r5 = 2*a*(n-a*a)/(n+3*a*a) - addd2 r4,r0 # r0:r1 = a + 2*a*(n-a*a)/(n+3*a*a) - rsb # DONE! -nonpos: - jneq negarg - ret # argument and root are zero -negarg: - pushl $EDOM - calls $1,_infnan # generate the reserved op fault - ret diff --git a/lib/libm/vax/support.S b/lib/libm/vax/support.S deleted file mode 100644 index ed6574e15375..000000000000 --- a/lib/libm/vax/support.S +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)support.s 1.3 (Berkeley) 8/21/85; 5.5 (ucb.elefunt) 10/9/90" -_rcsid: -.asciz "$Id: support.S,v 1.1 1993/08/14 13:44:15 mycroft Exp $" - -/* - * copysign(x,y), - * logb(x), - * scalb(x,N), - * finite(x), - * drem(x,y), - * Coded in vax assembly language by K.C. Ng, 3/14/85. - * Revised by K.C. Ng on 4/9/85. - */ - -/* - * double copysign(x,y) - * double x,y; - */ - .globl _copysign - .text - .align 1 -_copysign: - .word 0x4 - movq 4(ap),r0 # load x into r0 - bicw3 $0x807f,r0,r2 # mask off the exponent of x - beql Lz # if zero or reserved op then return x - bicw3 $0x7fff,12(ap),r2 # copy the sign bit of y into r2 - bicw2 $0x8000,r0 # replace x by |x| - bisw2 r2,r0 # copy the sign bit of y to x -Lz: ret - -/* - * double logb(x) - * double x; - */ - .globl _logb - .text - .align 1 -_logb: - .word 0x0 - bicl3 $0xffff807f,4(ap),r0 # mask off the exponent of x - beql Ln - ashl $-7,r0,r0 # get the bias exponent - subl2 $129,r0 # get the unbias exponent - cvtld r0,r0 # return the answer in double - ret -Ln: movq 4(ap),r0 # r0:1 = x (zero or reserved op) - bneq 1f # simply return if reserved op - movq $0x0000fe00ffffcfff,r0 # -2147483647.0 -1: ret - -/* - * long finite(x) - * double x; - */ - .globl _finite - .text - .align 1 -_finite: - .word 0x0000 - bicw3 $0x7f,4(ap),r0 # mask off the mantissa - cmpw r0,$0x8000 # to see if x is the reserved op - beql 1f # if so, return FALSE (0) - movl $1,r0 # else return TRUE (1) - ret -1: clrl r0 - ret - -/* - * double scalb(x,N) - * double x; int N; - */ - .globl _scalb - .set ERANGE,34 - .text - .align 1 -_scalb: - .word 0xc - movq 4(ap),r0 - bicl3 $0xffff807f,r0,r3 - beql ret1 # 0 or reserved operand - movl 12(ap),r2 - cmpl r2,$0x12c - bgeq ovfl - cmpl r2,$-0x12c - bleq unfl - ashl $7,r2,r2 - addl2 r2,r3 - bleq unfl - cmpl r3,$0x8000 - bgeq ovfl - addl2 r2,r0 - ret -ovfl: pushl $ERANGE - calls $1,_infnan # if it returns - bicw3 $0x7fff,4(ap),r2 # get the sign of input arg - bisw2 r2,r0 # re-attach the sign to r0/1 - ret -unfl: movq $0,r0 -ret1: ret - -/* - * DREM(X,Y) - * RETURN X REM Y =X-N*Y, N=[X/Y] ROUNDED (ROUNDED TO EVEN IN THE HALF WAY CASE) - * DOUBLE PRECISION (VAX D format 56 bits) - * CODED IN VAX ASSEMBLY LANGUAGE BY K.C. NG, 4/8/85. - */ - .globl _drem - .set EDOM,33 - .text - .align 1 -_drem: - .word 0xffc - subl2 $12,sp - movq 4(ap),r0 #r0=x - movq 12(ap),r2 #r2=y - jeql Rop #if y=0 then generate reserved op fault - bicw3 $0x007f,r0,r4 #check if x is Rop - cmpw r4,$0x8000 - jeql Ret #if x is Rop then return Rop - bicl3 $0x007f,r2,r4 #check if y is Rop - cmpw r4,$0x8000 - jeql Ret #if y is Rop then return Rop - bicw2 $0x8000,r2 #y := |y| - movw $0,-4(fp) #-4(fp) = nx := 0 - cmpw r2,$0x1c80 #yexp ? 57 - bgtr C1 #if yexp > 57 goto C1 - addw2 $0x1c80,r2 #scale up y by 2**57 - movw $0x1c80,-4(fp) #nx := 57 (exponent field) -C1: - movw -4(fp),-8(fp) #-8(fp) = nf := nx - bicw3 $0x7fff,r0,-12(fp) #-12(fp) = sign of x - bicw2 $0x8000,r0 #x := |x| - movq r2,r10 #y1 := y - bicl2 $0xffff07ff,r11 #clear the last 27 bits of y1 -loop: - cmpd r0,r2 #x ? y - bleq E1 #if x <= y goto E1 - /* begin argument reduction */ - movq r2,r4 #t =y - movq r10,r6 #t1=y1 - bicw3 $0x807f,r0,r8 #xexp= exponent of x - bicw3 $0x807f,r2,r9 #yexp= exponent fo y - subw2 r9,r8 #xexp-yexp - subw2 $0x0c80,r8 #k=xexp-yexp-25(exponent bit field) - blss C2 #if k<0 goto C2 - addw2 r8,r4 #t +=k - addw2 r8,r6 #t1+=k, scale up t and t1 -C2: - divd3 r4,r0,r8 #x/t - cvtdl r8,r8 #n=[x/t] truncated - cvtld r8,r8 #float(n) - subd2 r6,r4 #t:=t-t1 - muld2 r8,r4 #n*(t-t1) - muld2 r8,r6 #n*t1 - subd2 r6,r0 #x-n*t1 - subd2 r4,r0 #(x-n*t1)-n*(t-t1) - brb loop -E1: - movw -4(fp),r6 #r6=nx - beql C3 #if nx=0 goto C3 - addw2 r6,r0 #x:=x*2**57 scale up x by nx - movw $0,-4(fp) #clear nx - brb loop -C3: - movq r2,r4 #r4 = y - subw2 $0x80,r4 #r4 = y/2 - cmpd r0,r4 #x:y/2 - blss E2 #if x < y/2 goto E2 - bgtr C4 #if x > y/2 goto C4 - cvtdl r8,r8 #ifix(float(n)) - blbc r8,E2 #if the last bit is zero, goto E2 -C4: - subd2 r2,r0 #x-y -E2: - xorw2 -12(fp),r0 #x^sign (exclusive or) - movw -8(fp),r6 #r6=nf - bicw3 $0x807f,r0,r8 #r8=exponent of x - bicw2 $0x7f80,r0 #clear the exponent of x - subw2 r6,r8 #r8=xexp-nf - bgtr C5 #if xexp-nf is positive goto C5 - movw $0,r8 #clear r8 - movq $0,r0 #x underflow to zero -C5: - bisw2 r8,r0 #put r8 into x's exponent field - ret -Rop: #Reserved operand - pushl $EDOM - calls $1,_infnan #generate reserved op fault - ret -Ret: - movq $0x8000,r0 #propagate reserved op - ret diff --git a/lib/libm/vax/support.s b/lib/libm/vax/support.s deleted file mode 100644 index 0c3582ec673d..000000000000 --- a/lib/libm/vax/support.s +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)support.s 1.3 (Berkeley) 8/21/85; 5.5 (ucb.elefunt) 10/9/90" -_rcsid: -.asciz "$Id: support.s,v 1.1 1993/08/14 13:44:15 mycroft Exp $" - -/* - * copysign(x,y), - * logb(x), - * scalb(x,N), - * finite(x), - * drem(x,y), - * Coded in vax assembly language by K.C. Ng, 3/14/85. - * Revised by K.C. Ng on 4/9/85. - */ - -/* - * double copysign(x,y) - * double x,y; - */ - .globl _copysign - .text - .align 1 -_copysign: - .word 0x4 - movq 4(ap),r0 # load x into r0 - bicw3 $0x807f,r0,r2 # mask off the exponent of x - beql Lz # if zero or reserved op then return x - bicw3 $0x7fff,12(ap),r2 # copy the sign bit of y into r2 - bicw2 $0x8000,r0 # replace x by |x| - bisw2 r2,r0 # copy the sign bit of y to x -Lz: ret - -/* - * double logb(x) - * double x; - */ - .globl _logb - .text - .align 1 -_logb: - .word 0x0 - bicl3 $0xffff807f,4(ap),r0 # mask off the exponent of x - beql Ln - ashl $-7,r0,r0 # get the bias exponent - subl2 $129,r0 # get the unbias exponent - cvtld r0,r0 # return the answer in double - ret -Ln: movq 4(ap),r0 # r0:1 = x (zero or reserved op) - bneq 1f # simply return if reserved op - movq $0x0000fe00ffffcfff,r0 # -2147483647.0 -1: ret - -/* - * long finite(x) - * double x; - */ - .globl _finite - .text - .align 1 -_finite: - .word 0x0000 - bicw3 $0x7f,4(ap),r0 # mask off the mantissa - cmpw r0,$0x8000 # to see if x is the reserved op - beql 1f # if so, return FALSE (0) - movl $1,r0 # else return TRUE (1) - ret -1: clrl r0 - ret - -/* - * double scalb(x,N) - * double x; int N; - */ - .globl _scalb - .set ERANGE,34 - .text - .align 1 -_scalb: - .word 0xc - movq 4(ap),r0 - bicl3 $0xffff807f,r0,r3 - beql ret1 # 0 or reserved operand - movl 12(ap),r2 - cmpl r2,$0x12c - bgeq ovfl - cmpl r2,$-0x12c - bleq unfl - ashl $7,r2,r2 - addl2 r2,r3 - bleq unfl - cmpl r3,$0x8000 - bgeq ovfl - addl2 r2,r0 - ret -ovfl: pushl $ERANGE - calls $1,_infnan # if it returns - bicw3 $0x7fff,4(ap),r2 # get the sign of input arg - bisw2 r2,r0 # re-attach the sign to r0/1 - ret -unfl: movq $0,r0 -ret1: ret - -/* - * DREM(X,Y) - * RETURN X REM Y =X-N*Y, N=[X/Y] ROUNDED (ROUNDED TO EVEN IN THE HALF WAY CASE) - * DOUBLE PRECISION (VAX D format 56 bits) - * CODED IN VAX ASSEMBLY LANGUAGE BY K.C. NG, 4/8/85. - */ - .globl _drem - .set EDOM,33 - .text - .align 1 -_drem: - .word 0xffc - subl2 $12,sp - movq 4(ap),r0 #r0=x - movq 12(ap),r2 #r2=y - jeql Rop #if y=0 then generate reserved op fault - bicw3 $0x007f,r0,r4 #check if x is Rop - cmpw r4,$0x8000 - jeql Ret #if x is Rop then return Rop - bicl3 $0x007f,r2,r4 #check if y is Rop - cmpw r4,$0x8000 - jeql Ret #if y is Rop then return Rop - bicw2 $0x8000,r2 #y := |y| - movw $0,-4(fp) #-4(fp) = nx := 0 - cmpw r2,$0x1c80 #yexp ? 57 - bgtr C1 #if yexp > 57 goto C1 - addw2 $0x1c80,r2 #scale up y by 2**57 - movw $0x1c80,-4(fp) #nx := 57 (exponent field) -C1: - movw -4(fp),-8(fp) #-8(fp) = nf := nx - bicw3 $0x7fff,r0,-12(fp) #-12(fp) = sign of x - bicw2 $0x8000,r0 #x := |x| - movq r2,r10 #y1 := y - bicl2 $0xffff07ff,r11 #clear the last 27 bits of y1 -loop: - cmpd r0,r2 #x ? y - bleq E1 #if x <= y goto E1 - /* begin argument reduction */ - movq r2,r4 #t =y - movq r10,r6 #t1=y1 - bicw3 $0x807f,r0,r8 #xexp= exponent of x - bicw3 $0x807f,r2,r9 #yexp= exponent fo y - subw2 r9,r8 #xexp-yexp - subw2 $0x0c80,r8 #k=xexp-yexp-25(exponent bit field) - blss C2 #if k<0 goto C2 - addw2 r8,r4 #t +=k - addw2 r8,r6 #t1+=k, scale up t and t1 -C2: - divd3 r4,r0,r8 #x/t - cvtdl r8,r8 #n=[x/t] truncated - cvtld r8,r8 #float(n) - subd2 r6,r4 #t:=t-t1 - muld2 r8,r4 #n*(t-t1) - muld2 r8,r6 #n*t1 - subd2 r6,r0 #x-n*t1 - subd2 r4,r0 #(x-n*t1)-n*(t-t1) - brb loop -E1: - movw -4(fp),r6 #r6=nx - beql C3 #if nx=0 goto C3 - addw2 r6,r0 #x:=x*2**57 scale up x by nx - movw $0,-4(fp) #clear nx - brb loop -C3: - movq r2,r4 #r4 = y - subw2 $0x80,r4 #r4 = y/2 - cmpd r0,r4 #x:y/2 - blss E2 #if x < y/2 goto E2 - bgtr C4 #if x > y/2 goto C4 - cvtdl r8,r8 #ifix(float(n)) - blbc r8,E2 #if the last bit is zero, goto E2 -C4: - subd2 r2,r0 #x-y -E2: - xorw2 -12(fp),r0 #x^sign (exclusive or) - movw -8(fp),r6 #r6=nf - bicw3 $0x807f,r0,r8 #r8=exponent of x - bicw2 $0x7f80,r0 #clear the exponent of x - subw2 r6,r8 #r8=xexp-nf - bgtr C5 #if xexp-nf is positive goto C5 - movw $0,r8 #clear r8 - movq $0,r0 #x underflow to zero -C5: - bisw2 r8,r0 #put r8 into x's exponent field - ret -Rop: #Reserved operand - pushl $EDOM - calls $1,_infnan #generate reserved op fault - ret -Ret: - movq $0x8000,r0 #propagate reserved op - ret diff --git a/lib/libm/vax/tan.S b/lib/libm/vax/tan.S deleted file mode 100644 index 79faaeee79bc..000000000000 --- a/lib/libm/vax/tan.S +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (c) 1985 Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)tan.s 1.1 (Berkeley) 8/21/85; 5.4 (ucb.elefunt) 10/9/90" -_rcsid: -.asciz "$Id: tan.S,v 1.1 1993/08/14 13:44:15 mycroft Exp $" - -# This is the implementation of Peter Tang's double precision -# tangent for the VAX using Bob Corbett's argument reduction. -# -# Notes: -# under 1,024,000 random arguments testing on [0,2*pi] -# tan() observed maximum error = 2.15 ulps -# -# double tan(arg) -# double arg; -# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett -# S. McDonald, April 4, 1985 -# - .globl _tan - .text - .align 1 - -_tan: .word 0xffc # save r2-r11 - movq 4(ap),r0 - bicw3 $0x807f,r0,r2 - beql 1f # if x is zero or reserved operand then return x -# -# Save the PSL's IV & FU bits on the stack. -# - movpsl r2 - bicw3 $0xff9f,r2,-(sp) -# -# Clear the IV & FU bits. -# - bicpsw $0x0060 - jsb libm$argred -# -# At this point, -# r0 contains the quadrant number, 0, 1, 2, or 3; -# r2/r1 contains the reduced argument as a D-format number; -# r3 contains a F-format extension to the reduced argument; -# -# Save r3/r0 so that we can call cosine after calling sine. -# - movq r2,-(sp) - movq r0,-(sp) -# -# Call sine. r4 = 0 implies sine. -# - movl $0,r4 - jsb libm$sincos -# -# Save sin(x) in r11/r10 . -# - movd r0,r10 -# -# Call cosine. r4 = 1 implies cosine. -# - movq (sp)+,r0 - movq (sp)+,r2 - movl $1,r4 - jsb libm$sincos - divd3 r0,r10,r0 - bispsw (sp)+ -1: ret diff --git a/lib/libm/vax/tan.s b/lib/libm/vax/tan.s deleted file mode 100644 index 94f472d1a3b3..000000000000 --- a/lib/libm/vax/tan.s +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright (c) 1985 Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - .data - .align 2 -;_sccsid: -;.asciz "from: @(#)tan.s 1.1 (Berkeley) 8/21/85; 5.4 (ucb.elefunt) 10/9/90" -_rcsid: -.asciz "$Id: tan.s,v 1.1 1993/08/14 13:44:15 mycroft Exp $" - -# This is the implementation of Peter Tang's double precision -# tangent for the VAX using Bob Corbett's argument reduction. -# -# Notes: -# under 1,024,000 random arguments testing on [0,2*pi] -# tan() observed maximum error = 2.15 ulps -# -# double tan(arg) -# double arg; -# method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett -# S. McDonald, April 4, 1985 -# - .globl _tan - .text - .align 1 - -_tan: .word 0xffc # save r2-r11 - movq 4(ap),r0 - bicw3 $0x807f,r0,r2 - beql 1f # if x is zero or reserved operand then return x -# -# Save the PSL's IV & FU bits on the stack. -# - movpsl r2 - bicw3 $0xff9f,r2,-(sp) -# -# Clear the IV & FU bits. -# - bicpsw $0x0060 - jsb libm$argred -# -# At this point, -# r0 contains the quadrant number, 0, 1, 2, or 3; -# r2/r1 contains the reduced argument as a D-format number; -# r3 contains a F-format extension to the reduced argument; -# -# Save r3/r0 so that we can call cosine after calling sine. -# - movq r2,-(sp) - movq r0,-(sp) -# -# Call sine. r4 = 0 implies sine. -# - movl $0,r4 - jsb libm$sincos -# -# Save sin(x) in r11/r10 . -# - movd r0,r10 -# -# Call cosine. r4 = 1 implies cosine. -# - movq (sp)+,r0 - movq (sp)+,r2 - movl $1,r4 - jsb libm$sincos - divd3 r0,r10,r0 - bispsw (sp)+ -1: ret diff --git a/lib/librpc/rpc/bindresvport.c b/lib/librpc/rpc/bindresvport.c deleted file mode 100644 index f3093a8e8f4c..000000000000 --- a/lib/librpc/rpc/bindresvport.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)bindresvport.c 1.8 88/02/08 SMI";*/ -/*static char *sccsid = "from: @(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: bindresvport.c,v 1.3 1993/08/26 00:53:14 jtc Exp $"; -#endif - -/* - * Copyright (c) 1987 by Sun Microsystems, Inc. - */ - -#include -#include -#include -#include - -/* - * Bind a socket to a privileged IP port - */ -bindresvport(sd, sin) - int sd; - struct sockaddr_in *sin; -{ - int res; - static short port; - struct sockaddr_in myaddr; - extern int errno; - int i; - -#define STARTPORT 600 -#define ENDPORT (IPPORT_RESERVED - 1) -#define NPORTS (ENDPORT - STARTPORT + 1) - - if (sin == (struct sockaddr_in *)0) { - sin = &myaddr; - bzero(sin, sizeof (*sin)); - sin->sin_family = AF_INET; - } else if (sin->sin_family != AF_INET) { - errno = EPFNOSUPPORT; - return (-1); - } - if (port == 0) { - port = (getpid() % NPORTS) + STARTPORT; - } - res = -1; - errno = EADDRINUSE; - for (i = 0; i < NPORTS && res < 0 && errno == EADDRINUSE; i++) { - sin->sin_port = htons(port++); - if (port > ENDPORT) { - port = STARTPORT; - } - res = bind(sd, - (struct sockaddr *)sin, sizeof(struct sockaddr_in)); - } - return (res); -} diff --git a/lib/librpc/rpc/clnt_generic.c b/lib/librpc/rpc/clnt_generic.c deleted file mode 100644 index 3689350c6e07..000000000000 --- a/lib/librpc/rpc/clnt_generic.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";*/ -/*static char *sccsid = "from: @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: clnt_generic.c,v 1.4 1993/08/26 00:53:15 jtc Exp $"; -#endif - -/* - * Copyright (C) 1987, Sun Microsystems, Inc. - */ -#include -#include -#include -#include - -/* - * Generic client creation: takes (hostname, program-number, protocol) and - * returns client handle. Default options are set, which the user can - * change using the rpc equivalent of ioctl()'s. - */ -CLIENT * -clnt_create(hostname, prog, vers, proto) - char *hostname; - u_long prog; - u_long vers; - char *proto; -{ - struct hostent *h; - struct protoent *p; - struct sockaddr_in sin; - int sock; - struct timeval tv; - CLIENT *client; - - h = gethostbyname(hostname); - if (h == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNHOST; - return (NULL); - } - if (h->h_addrtype != AF_INET) { - /* - * Only support INET for now - */ - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = EAFNOSUPPORT; - return (NULL); - } - sin.sin_family = h->h_addrtype; - sin.sin_port = 0; - bzero(sin.sin_zero, sizeof(sin.sin_zero)); - bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length); - p = getprotobyname(proto); - if (p == NULL) { - rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; - rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; - return (NULL); - } - sock = RPC_ANYSOCK; - switch (p->p_proto) { - case IPPROTO_UDP: - tv.tv_sec = 5; - tv.tv_usec = 0; - client = clntudp_create(&sin, prog, vers, tv, &sock); - if (client == NULL) { - return (NULL); - } - tv.tv_sec = 25; - clnt_control(client, CLSET_TIMEOUT, &tv); - break; - case IPPROTO_TCP: - client = clnttcp_create(&sin, prog, vers, &sock, 0, 0); - if (client == NULL) { - return (NULL); - } - tv.tv_sec = 25; - tv.tv_usec = 0; - clnt_control(client, CLSET_TIMEOUT, &tv); - break; - default: - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; - return (NULL); - } - return (client); -} diff --git a/lib/librpc/rpc/clnt_perror.c b/lib/librpc/rpc/clnt_perror.c deleted file mode 100644 index 303923ae141b..000000000000 --- a/lib/librpc/rpc/clnt_perror.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: clnt_perror.c,v 1.4 1993/08/26 00:53:16 jtc Exp $"; -#endif - -/* - * clnt_perror.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - */ -#include -#include -#include -#include -#include -#include - -static char *auth_errmsg(); - -static char *buf; - -static char * -_buf() -{ - - if (buf == 0) - buf = (char *)malloc(256); - return (buf); -} - -/* - * Print reply error info - */ -char * -clnt_sperror(rpch, s) - CLIENT *rpch; - char *s; -{ - struct rpc_err e; - void clnt_perrno(); - char *err; - char *str = _buf(); - char *strstart = str; - - if (str == 0) - return (0); - CLNT_GETERR(rpch, &e); - - (void) sprintf(str, "%s: ", s); - str += strlen(str); - - (void) strcpy(str, clnt_sperrno(e.re_status)); - str += strlen(str); - - switch (e.re_status) { - case RPC_SUCCESS: - case RPC_CANTENCODEARGS: - case RPC_CANTDECODERES: - case RPC_TIMEDOUT: - case RPC_PROGUNAVAIL: - case RPC_PROCUNAVAIL: - case RPC_CANTDECODEARGS: - case RPC_SYSTEMERROR: - case RPC_UNKNOWNHOST: - case RPC_UNKNOWNPROTO: - case RPC_PMAPFAILURE: - case RPC_PROGNOTREGISTERED: - case RPC_FAILED: - break; - - case RPC_CANTSEND: - case RPC_CANTRECV: - (void) sprintf(str, "; errno = %s", - strerror(e.re_errno)); - str += strlen(str); - break; - - case RPC_VERSMISMATCH: - (void) sprintf(str, - "; low version = %lu, high version = %lu", - e.re_vers.low, e.re_vers.high); - str += strlen(str); - break; - - case RPC_AUTHERROR: - err = auth_errmsg(e.re_why); - (void) sprintf(str,"; why = "); - str += strlen(str); - if (err != NULL) { - (void) sprintf(str, "%s",err); - } else { - (void) sprintf(str, - "(unknown authentication error - %d)", - (int) e.re_why); - } - str += strlen(str); - break; - - case RPC_PROGVERSMISMATCH: - (void) sprintf(str, - "; low version = %lu, high version = %lu", - e.re_vers.low, e.re_vers.high); - str += strlen(str); - break; - - default: /* unknown */ - (void) sprintf(str, - "; s1 = %lu, s2 = %lu", - e.re_lb.s1, e.re_lb.s2); - str += strlen(str); - break; - } - (void) sprintf(str, "\n"); - return(strstart) ; -} - -void -clnt_perror(rpch, s) - CLIENT *rpch; - char *s; -{ - (void) fprintf(stderr,"%s",clnt_sperror(rpch,s)); -} - - -struct rpc_errtab { - enum clnt_stat status; - char *message; -}; - -static struct rpc_errtab rpc_errlist[] = { - { RPC_SUCCESS, - "RPC: Success" }, - { RPC_CANTENCODEARGS, - "RPC: Can't encode arguments" }, - { RPC_CANTDECODERES, - "RPC: Can't decode result" }, - { RPC_CANTSEND, - "RPC: Unable to send" }, - { RPC_CANTRECV, - "RPC: Unable to receive" }, - { RPC_TIMEDOUT, - "RPC: Timed out" }, - { RPC_VERSMISMATCH, - "RPC: Incompatible versions of RPC" }, - { RPC_AUTHERROR, - "RPC: Authentication error" }, - { RPC_PROGUNAVAIL, - "RPC: Program unavailable" }, - { RPC_PROGVERSMISMATCH, - "RPC: Program/version mismatch" }, - { RPC_PROCUNAVAIL, - "RPC: Procedure unavailable" }, - { RPC_CANTDECODEARGS, - "RPC: Server can't decode arguments" }, - { RPC_SYSTEMERROR, - "RPC: Remote system error" }, - { RPC_UNKNOWNHOST, - "RPC: Unknown host" }, - { RPC_UNKNOWNPROTO, - "RPC: Unknown protocol" }, - { RPC_PMAPFAILURE, - "RPC: Port mapper failure" }, - { RPC_PROGNOTREGISTERED, - "RPC: Program not registered"}, - { RPC_FAILED, - "RPC: Failed (unspecified error)"} -}; - - -/* - * This interface for use by clntrpc - */ -char * -clnt_sperrno(stat) - enum clnt_stat stat; -{ - int i; - - for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) { - if (rpc_errlist[i].status == stat) { - return (rpc_errlist[i].message); - } - } - return ("RPC: (unknown error code)"); -} - -void -clnt_perrno(num) - enum clnt_stat num; -{ - (void) fprintf(stderr,"%s",clnt_sperrno(num)); -} - - -char * -clnt_spcreateerror(s) - char *s; -{ - extern int sys_nerr; - char *str = _buf(); - - if (str == 0) - return(0); - (void) sprintf(str, "%s: ", s); - (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat)); - switch (rpc_createerr.cf_stat) { - case RPC_PMAPFAILURE: - (void) strcat(str, " - "); - (void) strcat(str, - clnt_sperrno(rpc_createerr.cf_error.re_status)); - break; - - case RPC_SYSTEMERROR: - (void) strcat(str, " - "); - if (rpc_createerr.cf_error.re_errno > 0 - && rpc_createerr.cf_error.re_errno < sys_nerr) - (void) strcat(str, - strerror(rpc_createerr.cf_error.re_errno)); - else - (void) sprintf(&str[strlen(str)], "Error %d", - rpc_createerr.cf_error.re_errno); - break; - } - (void) strcat(str, "\n"); - return (str); -} - -void -clnt_pcreateerror(s) - char *s; -{ - (void) fprintf(stderr,"%s",clnt_spcreateerror(s)); -} - -struct auth_errtab { - enum auth_stat status; - char *message; -}; - -static struct auth_errtab auth_errlist[] = { - { AUTH_OK, - "Authentication OK" }, - { AUTH_BADCRED, - "Invalid client credential" }, - { AUTH_REJECTEDCRED, - "Server rejected credential" }, - { AUTH_BADVERF, - "Invalid client verifier" }, - { AUTH_REJECTEDVERF, - "Server rejected verifier" }, - { AUTH_TOOWEAK, - "Client credential too weak" }, - { AUTH_INVALIDRESP, - "Invalid server verifier" }, - { AUTH_FAILED, - "Failed (unspecified error)" }, -}; - -static char * -auth_errmsg(stat) - enum auth_stat stat; -{ - int i; - - for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) { - if (auth_errlist[i].status == stat) { - return(auth_errlist[i].message); - } - } - return(NULL); -} diff --git a/lib/librpc/rpc/clnt_raw.c b/lib/librpc/rpc/clnt_raw.c deleted file mode 100644 index bb042e25ee6d..000000000000 --- a/lib/librpc/rpc/clnt_raw.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: clnt_raw.c,v 1.3 1993/08/26 00:53:17 jtc Exp $"; -#endif - -/* - * clnt_raw.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * Memory based rpc for simple testing and timing. - * Interface to create an rpc client and server in the same process. - * This lets us similate rpc and get round trip overhead, without - * any interference from the kernal. - */ - -#include - -#define MCALL_MSG_SIZE 24 - -/* - * This is the "network" we will be moving stuff over. - */ -static struct clntraw_private { - CLIENT client_object; - XDR xdr_stream; - char _raw_buf[UDPMSGSIZE]; - char mashl_callmsg[MCALL_MSG_SIZE]; - u_int mcnt; -} *clntraw_private; - -static enum clnt_stat clntraw_call(); -static void clntraw_abort(); -static void clntraw_geterr(); -static bool_t clntraw_freeres(); -static bool_t clntraw_control(); -static void clntraw_destroy(); - -static struct clnt_ops client_ops = { - clntraw_call, - clntraw_abort, - clntraw_geterr, - clntraw_freeres, - clntraw_destroy, - clntraw_control -}; - -void svc_getreq(); - -/* - * Create a client handle for memory based rpc. - */ -CLIENT * -clntraw_create(prog, vers) - u_long prog; - u_long vers; -{ - register struct clntraw_private *clp = clntraw_private; - struct rpc_msg call_msg; - XDR *xdrs = &clp->xdr_stream; - CLIENT *client = &clp->client_object; - - if (clp == 0) { - clp = (struct clntraw_private *)calloc(1, sizeof (*clp)); - if (clp == 0) - return (0); - clntraw_private = clp; - } - /* - * pre-serialize the staic part of the call msg and stash it away - */ - call_msg.rm_direction = CALL; - call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - call_msg.rm_call.cb_prog = prog; - call_msg.rm_call.cb_vers = vers; - xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE); - if (! xdr_callhdr(xdrs, &call_msg)) { - perror("clnt_raw.c - Fatal header serialization error."); - } - clp->mcnt = XDR_GETPOS(xdrs); - XDR_DESTROY(xdrs); - - /* - * Set xdrmem for client/server shared buffer - */ - xdrmem_create(xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE); - - /* - * create client handle - */ - client->cl_ops = &client_ops; - client->cl_auth = authnone_create(); - return (client); -} - -static enum clnt_stat -clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout) - CLIENT *h; - u_long proc; - xdrproc_t xargs; - caddr_t argsp; - xdrproc_t xresults; - caddr_t resultsp; - struct timeval timeout; -{ - register struct clntraw_private *clp = clntraw_private; - register XDR *xdrs = &clp->xdr_stream; - struct rpc_msg msg; - enum clnt_stat status; - struct rpc_err error; - - if (clp == 0) - return (RPC_FAILED); -call_again: - /* - * send request - */ - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, 0); - ((struct rpc_msg *)clp->mashl_callmsg)->rm_xid ++ ; - if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) || - (! XDR_PUTLONG(xdrs, (long *)&proc)) || - (! AUTH_MARSHALL(h->cl_auth, xdrs)) || - (! (*xargs)(xdrs, argsp))) { - return (RPC_CANTENCODEARGS); - } - (void)XDR_GETPOS(xdrs); /* called just to cause overhead */ - - /* - * We have to call server input routine here because this is - * all going on in one process. Yuk. - */ - svc_getreq(1); - - /* - * get results - */ - xdrs->x_op = XDR_DECODE; - XDR_SETPOS(xdrs, 0); - msg.acpted_rply.ar_verf = _null_auth; - msg.acpted_rply.ar_results.where = resultsp; - msg.acpted_rply.ar_results.proc = xresults; - if (! xdr_replymsg(xdrs, &msg)) - return (RPC_CANTDECODERES); - _seterr_reply(&msg, &error); - status = error.re_status; - - if (status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { - status = RPC_AUTHERROR; - } - } /* end successful completion */ - else { - if (AUTH_REFRESH(h->cl_auth)) - goto call_again; - } /* end of unsuccessful completion */ - - if (status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { - status = RPC_AUTHERROR; - } - if (msg.acpted_rply.ar_verf.oa_base != NULL) { - xdrs->x_op = XDR_FREE; - (void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf)); - } - } - - return (status); -} - -static void -clntraw_geterr() -{ -} - - -static bool_t -clntraw_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - caddr_t res_ptr; -{ - register struct clntraw_private *clp = clntraw_private; - register XDR *xdrs = &clp->xdr_stream; - bool_t rval; - - if (clp == 0) - { - rval = (bool_t) RPC_FAILED; - return (rval); - } - xdrs->x_op = XDR_FREE; - return ((*xdr_res)(xdrs, res_ptr)); -} - -static void -clntraw_abort() -{ -} - -static bool_t -clntraw_control() -{ - return (FALSE); -} - -static void -clntraw_destroy() -{ -} diff --git a/lib/librpc/rpc/clnt_simple.c b/lib/librpc/rpc/clnt_simple.c deleted file mode 100644 index baff3727be1e..000000000000 --- a/lib/librpc/rpc/clnt_simple.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: clnt_simple.c,v 1.4 1993/08/26 00:53:19 jtc Exp $"; -#endif - -/* - * clnt_simple.c - * Simplified front end to rpc. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include - -static struct callrpc_private { - CLIENT *client; - int socket; - int oldprognum, oldversnum, valid; - char *oldhost; -} *callrpc_private; - -callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) - char *host; - xdrproc_t inproc, outproc; - char *in, *out; -{ - register struct callrpc_private *crp = callrpc_private; - struct sockaddr_in server_addr; - enum clnt_stat clnt_stat; - struct hostent *hp; - struct timeval timeout, tottimeout; - - if (crp == 0) { - crp = (struct callrpc_private *)calloc(1, sizeof (*crp)); - if (crp == 0) - return (0); - callrpc_private = crp; - } - if (crp->oldhost == NULL) { - crp->oldhost = malloc(256); - crp->oldhost[0] = 0; - crp->socket = RPC_ANYSOCK; - } - if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum - && strcmp(crp->oldhost, host) == 0) { - /* reuse old client */ - } else { - crp->valid = 0; - (void)close(crp->socket); - crp->socket = RPC_ANYSOCK; - if (crp->client) { - clnt_destroy(crp->client); - crp->client = NULL; - } - if ((hp = gethostbyname(host)) == NULL) - return ((int) RPC_UNKNOWNHOST); - timeout.tv_usec = 0; - timeout.tv_sec = 5; - bcopy(hp->h_addr, (char *)&server_addr.sin_addr, hp->h_length); - server_addr.sin_family = AF_INET; - server_addr.sin_port = 0; - if ((crp->client = clntudp_create(&server_addr, (u_long)prognum, - (u_long)versnum, timeout, &crp->socket)) == NULL) - return ((int) rpc_createerr.cf_stat); - crp->valid = 1; - crp->oldprognum = prognum; - crp->oldversnum = versnum; - (void) strcpy(crp->oldhost, host); - } - tottimeout.tv_sec = 25; - tottimeout.tv_usec = 0; - clnt_stat = clnt_call(crp->client, procnum, inproc, in, - outproc, out, tottimeout); - /* - * if call failed, empty cache - */ - if (clnt_stat != RPC_SUCCESS) - crp->valid = 0; - return ((int) clnt_stat); -} diff --git a/lib/librpc/rpc/clnt_tcp.c b/lib/librpc/rpc/clnt_tcp.c deleted file mode 100644 index 602a37223c11..000000000000 --- a/lib/librpc/rpc/clnt_tcp.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: clnt_tcp.c,v 1.3 1993/08/26 00:53:20 jtc Exp $"; -#endif - -/* - * clnt_tcp.c, Implements a TCP/IP based, client side RPC. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * TCP based RPC supports 'batched calls'. - * A sequence of calls may be batched-up in a send buffer. The rpc call - * return immediately to the client even though the call was not necessarily - * sent. The batching occurs if the results' xdr routine is NULL (0) AND - * the rpc timeout value is zero (see clnt.h, rpc). - * - * Clients should NOT casually batch calls that in fact return results; that is, - * the server side should be aware that a call is batched and not produce any - * return message. Batched calls that produce many result messages can - * deadlock (netlock) the client and the server.... - * - * Now go hang yourself. - */ - -#include -#include -#include -#include -#include -#include - -#define MCALL_MSG_SIZE 24 - -extern int errno; - -static int readtcp(); -static int writetcp(); - -static enum clnt_stat clnttcp_call(); -static void clnttcp_abort(); -static void clnttcp_geterr(); -static bool_t clnttcp_freeres(); -static bool_t clnttcp_control(); -static void clnttcp_destroy(); - -static struct clnt_ops tcp_ops = { - clnttcp_call, - clnttcp_abort, - clnttcp_geterr, - clnttcp_freeres, - clnttcp_destroy, - clnttcp_control -}; - -struct ct_data { - int ct_sock; - bool_t ct_closeit; - struct timeval ct_wait; - bool_t ct_waitset; /* wait set by clnt_control? */ - struct sockaddr_in ct_addr; - struct rpc_err ct_error; - char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */ - u_int ct_mpos; /* pos after marshal */ - XDR ct_xdrs; -}; - -/* - * Create a client handle for a tcp/ip connection. - * If *sockp<0, *sockp is set to a newly created TCP socket and it is - * connected to raddr. If *sockp non-negative then - * raddr is ignored. The rpc/tcp package does buffering - * similar to stdio, so the client must pick send and receive buffer sizes,]; - * 0 => use the default. - * If raddr->sin_port is 0, then a binder on the remote machine is - * consulted for the right port number. - * NB: *sockp is copied into a private area. - * NB: It is the clients responsibility to close *sockp. - * NB: The rpch->cl_auth is set null authentication. Caller may wish to set this - * something more useful. - */ -CLIENT * -clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) - struct sockaddr_in *raddr; - u_long prog; - u_long vers; - register int *sockp; - u_int sendsz; - u_int recvsz; -{ - CLIENT *h; - register struct ct_data *ct; - struct timeval now; - struct rpc_msg call_msg; - - h = (CLIENT *)mem_alloc(sizeof(*h)); - if (h == NULL) { - (void)fprintf(stderr, "clnttcp_create: out of memory\n"); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - ct = (struct ct_data *)mem_alloc(sizeof(*ct)); - if (ct == NULL) { - (void)fprintf(stderr, "clnttcp_create: out of memory\n"); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - - /* - * If no port number given ask the pmap for one - */ - if (raddr->sin_port == 0) { - u_short port; - if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP)) == 0) { - mem_free((caddr_t)ct, sizeof(struct ct_data)); - mem_free((caddr_t)h, sizeof(CLIENT)); - return ((CLIENT *)NULL); - } - raddr->sin_port = htons(port); - } - - /* - * If no socket given, open one - */ - if (*sockp < 0) { - *sockp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - (void)bindresvport(*sockp, (struct sockaddr_in *)0); - if ((*sockp < 0) - || (connect(*sockp, (struct sockaddr *)raddr, - sizeof(*raddr)) < 0)) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - (void)close(*sockp); - goto fooy; - } - ct->ct_closeit = TRUE; - } else { - ct->ct_closeit = FALSE; - } - - /* - * Set up private data struct - */ - ct->ct_sock = *sockp; - ct->ct_wait.tv_usec = 0; - ct->ct_waitset = FALSE; - ct->ct_addr = *raddr; - - /* - * Initialize call message - */ - (void)gettimeofday(&now, (struct timezone *)0); - call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec; - call_msg.rm_direction = CALL; - call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - call_msg.rm_call.cb_prog = prog; - call_msg.rm_call.cb_vers = vers; - - /* - * pre-serialize the staic part of the call msg and stash it away - */ - xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, - XDR_ENCODE); - if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { - if (ct->ct_closeit) { - (void)close(*sockp); - } - goto fooy; - } - ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs)); - XDR_DESTROY(&(ct->ct_xdrs)); - - /* - * Create a client handle which uses xdrrec for serialization - * and authnone for authentication. - */ - xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, - (caddr_t)ct, readtcp, writetcp); - h->cl_ops = &tcp_ops; - h->cl_private = (caddr_t) ct; - h->cl_auth = authnone_create(); - return (h); - -fooy: - /* - * Something goofed, free stuff and barf - */ - mem_free((caddr_t)ct, sizeof(struct ct_data)); - mem_free((caddr_t)h, sizeof(CLIENT)); - return ((CLIENT *)NULL); -} - -static enum clnt_stat -clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) - register CLIENT *h; - u_long proc; - xdrproc_t xdr_args; - caddr_t args_ptr; - xdrproc_t xdr_results; - caddr_t results_ptr; - struct timeval timeout; -{ - register struct ct_data *ct = (struct ct_data *) h->cl_private; - register XDR *xdrs = &(ct->ct_xdrs); - struct rpc_msg reply_msg; - u_long x_id; - u_long *msg_x_id = (u_long *)(ct->ct_mcall); /* yuk */ - register bool_t shipnow; - int refreshes = 2; - - if (!ct->ct_waitset) { - ct->ct_wait = timeout; - } - - shipnow = - (xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0 - && timeout.tv_usec == 0) ? FALSE : TRUE; - -call_again: - xdrs->x_op = XDR_ENCODE; - ct->ct_error.re_status = RPC_SUCCESS; - x_id = ntohl(--(*msg_x_id)); - if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || - (! XDR_PUTLONG(xdrs, (long *)&proc)) || - (! AUTH_MARSHALL(h->cl_auth, xdrs)) || - (! (*xdr_args)(xdrs, args_ptr))) { - if (ct->ct_error.re_status == RPC_SUCCESS) - ct->ct_error.re_status = RPC_CANTENCODEARGS; - (void)xdrrec_endofrecord(xdrs, TRUE); - return (ct->ct_error.re_status); - } - if (! xdrrec_endofrecord(xdrs, shipnow)) - return (ct->ct_error.re_status = RPC_CANTSEND); - if (! shipnow) - return (RPC_SUCCESS); - /* - * Hack to provide rpc-based message passing - */ - if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { - return(ct->ct_error.re_status = RPC_TIMEDOUT); - } - - - /* - * Keep receiving until we get a valid transaction id - */ - xdrs->x_op = XDR_DECODE; - while (TRUE) { - reply_msg.acpted_rply.ar_verf = _null_auth; - reply_msg.acpted_rply.ar_results.where = NULL; - reply_msg.acpted_rply.ar_results.proc = xdr_void; - if (! xdrrec_skiprecord(xdrs)) - return (ct->ct_error.re_status); - /* now decode and validate the response header */ - if (! xdr_replymsg(xdrs, &reply_msg)) { - if (ct->ct_error.re_status == RPC_SUCCESS) - continue; - return (ct->ct_error.re_status); - } - if (reply_msg.rm_xid == x_id) - break; - } - - /* - * process header - */ - _seterr_reply(&reply_msg, &(ct->ct_error)); - if (ct->ct_error.re_status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) { - ct->ct_error.re_status = RPC_AUTHERROR; - ct->ct_error.re_why = AUTH_INVALIDRESP; - } else if (! (*xdr_results)(xdrs, results_ptr)) { - if (ct->ct_error.re_status == RPC_SUCCESS) - ct->ct_error.re_status = RPC_CANTDECODERES; - } - /* free verifier ... */ - if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { - xdrs->x_op = XDR_FREE; - (void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf)); - } - } /* end successful completion */ - else { - /* maybe our credentials need to be refreshed ... */ - if (refreshes-- && AUTH_REFRESH(h->cl_auth)) - goto call_again; - } /* end of unsuccessful completion */ - return (ct->ct_error.re_status); -} - -static void -clnttcp_geterr(h, errp) - CLIENT *h; - struct rpc_err *errp; -{ - register struct ct_data *ct = - (struct ct_data *) h->cl_private; - - *errp = ct->ct_error; -} - -static bool_t -clnttcp_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - caddr_t res_ptr; -{ - register struct ct_data *ct = (struct ct_data *)cl->cl_private; - register XDR *xdrs = &(ct->ct_xdrs); - - xdrs->x_op = XDR_FREE; - return ((*xdr_res)(xdrs, res_ptr)); -} - -static void -clnttcp_abort() -{ -} - -static bool_t -clnttcp_control(cl, request, info) - CLIENT *cl; - int request; - char *info; -{ - register struct ct_data *ct = (struct ct_data *)cl->cl_private; - - switch (request) { - case CLSET_TIMEOUT: - ct->ct_wait = *(struct timeval *)info; - ct->ct_waitset = TRUE; - break; - case CLGET_TIMEOUT: - *(struct timeval *)info = ct->ct_wait; - break; - case CLGET_SERVER_ADDR: - *(struct sockaddr_in *)info = ct->ct_addr; - break; - default: - return (FALSE); - } - return (TRUE); -} - - -static void -clnttcp_destroy(h) - CLIENT *h; -{ - register struct ct_data *ct = - (struct ct_data *) h->cl_private; - - if (ct->ct_closeit) { - (void)close(ct->ct_sock); - } - XDR_DESTROY(&(ct->ct_xdrs)); - mem_free((caddr_t)ct, sizeof(struct ct_data)); - mem_free((caddr_t)h, sizeof(CLIENT)); -} - -/* - * Interface between xdr serializer and tcp connection. - * Behaves like the system calls, read & write, but keeps some error state - * around for the rpc level. - */ -static int -readtcp(ct, buf, len) - register struct ct_data *ct; - caddr_t buf; - register int len; -{ -#ifdef FD_SETSIZE - fd_set mask; - fd_set readfds; - - if (len == 0) - return (0); - FD_ZERO(&mask); - FD_SET(ct->ct_sock, &mask); -#else - register int mask = 1 << (ct->ct_sock); - int readfds; - - if (len == 0) - return (0); - -#endif /* def FD_SETSIZE */ - while (TRUE) { - readfds = mask; - switch (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL, - &(ct->ct_wait))) { - case 0: - ct->ct_error.re_status = RPC_TIMEDOUT; - return (-1); - - case -1: - if (errno == EINTR) - continue; - ct->ct_error.re_status = RPC_CANTRECV; - ct->ct_error.re_errno = errno; - return (-1); - } - break; - } - switch (len = read(ct->ct_sock, buf, len)) { - - case 0: - /* premature eof */ - ct->ct_error.re_errno = ECONNRESET; - ct->ct_error.re_status = RPC_CANTRECV; - len = -1; /* it's really an error */ - break; - - case -1: - ct->ct_error.re_errno = errno; - ct->ct_error.re_status = RPC_CANTRECV; - break; - } - return (len); -} - -static int -writetcp(ct, buf, len) - struct ct_data *ct; - caddr_t buf; - int len; -{ - register int i, cnt; - - for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = write(ct->ct_sock, buf, cnt)) == -1) { - ct->ct_error.re_errno = errno; - ct->ct_error.re_status = RPC_CANTSEND; - return (-1); - } - } - return (len); -} diff --git a/lib/librpc/rpc/clnt_udp.c b/lib/librpc/rpc/clnt_udp.c deleted file mode 100644 index 9bbaa711deb2..000000000000 --- a/lib/librpc/rpc/clnt_udp.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: clnt_udp.c,v 1.3 1993/08/26 00:53:21 jtc Exp $"; -#endif - -/* - * clnt_udp.c, Implements a UDP/IP based, client side RPC. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include - -extern int errno; - -/* - * UDP bases client side rpc operations - */ -static enum clnt_stat clntudp_call(); -static void clntudp_abort(); -static void clntudp_geterr(); -static bool_t clntudp_freeres(); -static bool_t clntudp_control(); -static void clntudp_destroy(); - -static struct clnt_ops udp_ops = { - clntudp_call, - clntudp_abort, - clntudp_geterr, - clntudp_freeres, - clntudp_destroy, - clntudp_control -}; - -/* - * Private data kept per client handle - */ -struct cu_data { - int cu_sock; - bool_t cu_closeit; - struct sockaddr_in cu_raddr; - int cu_rlen; - struct timeval cu_wait; - struct timeval cu_total; - struct rpc_err cu_error; - XDR cu_outxdrs; - u_int cu_xdrpos; - u_int cu_sendsz; - char *cu_outbuf; - u_int cu_recvsz; - char cu_inbuf[1]; -}; - -/* - * Create a UDP based client handle. - * If *sockp<0, *sockp is set to a newly created UPD socket. - * If raddr->sin_port is 0 a binder on the remote machine - * is consulted for the correct port number. - * NB: It is the clients responsibility to close *sockp. - * NB: The rpch->cl_auth is initialized to null authentication. - * Caller may wish to set this something more useful. - * - * wait is the amount of time used between retransmitting a call if - * no response has been heard; retransmition occurs until the actual - * rpc call times out. - * - * sendsz and recvsz are the maximum allowable packet sizes that can be - * sent and received. - */ -CLIENT * -clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) - struct sockaddr_in *raddr; - u_long program; - u_long version; - struct timeval wait; - register int *sockp; - u_int sendsz; - u_int recvsz; -{ - CLIENT *cl; - register struct cu_data *cu; - struct timeval now; - struct rpc_msg call_msg; - - cl = (CLIENT *)mem_alloc(sizeof(CLIENT)); - if (cl == NULL) { - (void) fprintf(stderr, "clntudp_create: out of memory\n"); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - sendsz = ((sendsz + 3) / 4) * 4; - recvsz = ((recvsz + 3) / 4) * 4; - cu = (struct cu_data *)mem_alloc(sizeof(*cu) + sendsz + recvsz); - if (cu == NULL) { - (void) fprintf(stderr, "clntudp_create: out of memory\n"); - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - cu->cu_outbuf = &cu->cu_inbuf[recvsz]; - - (void)gettimeofday(&now, (struct timezone *)0); - if (raddr->sin_port == 0) { - u_short port; - if ((port = - pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) { - goto fooy; - } - raddr->sin_port = htons(port); - } - cl->cl_ops = &udp_ops; - cl->cl_private = (caddr_t)cu; - cu->cu_raddr = *raddr; - cu->cu_rlen = sizeof (cu->cu_raddr); - cu->cu_wait = wait; - cu->cu_total.tv_sec = -1; - cu->cu_total.tv_usec = -1; - cu->cu_sendsz = sendsz; - cu->cu_recvsz = recvsz; - call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec; - call_msg.rm_direction = CALL; - call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - call_msg.rm_call.cb_prog = program; - call_msg.rm_call.cb_vers = version; - xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, - sendsz, XDR_ENCODE); - if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) { - goto fooy; - } - cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); - if (*sockp < 0) { - int dontblock = 1; - - *sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (*sockp < 0) { - rpc_createerr.cf_stat = RPC_SYSTEMERROR; - rpc_createerr.cf_error.re_errno = errno; - goto fooy; - } - /* attempt to bind to prov port */ - (void)bindresvport(*sockp, (struct sockaddr_in *)0); - /* the sockets rpc controls are non-blocking */ - (void)ioctl(*sockp, FIONBIO, (char *) &dontblock); - cu->cu_closeit = TRUE; - } else { - cu->cu_closeit = FALSE; - } - cu->cu_sock = *sockp; - cl->cl_auth = authnone_create(); - return (cl); -fooy: - if (cu) - mem_free((caddr_t)cu, sizeof(*cu) + sendsz + recvsz); - if (cl) - mem_free((caddr_t)cl, sizeof(CLIENT)); - return ((CLIENT *)NULL); -} - -CLIENT * -clntudp_create(raddr, program, version, wait, sockp) - struct sockaddr_in *raddr; - u_long program; - u_long version; - struct timeval wait; - register int *sockp; -{ - - return(clntudp_bufcreate(raddr, program, version, wait, sockp, - UDPMSGSIZE, UDPMSGSIZE)); -} - -static enum clnt_stat -clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) - register CLIENT *cl; /* client handle */ - u_long proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - caddr_t argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - caddr_t resultsp; /* pointer to results */ - struct timeval utimeout; /* seconds to wait before giving up */ -{ - register struct cu_data *cu = (struct cu_data *)cl->cl_private; - register XDR *xdrs; - register int outlen; - register int inlen; - int fromlen; -#ifdef FD_SETSIZE - fd_set readfds; - fd_set mask; -#else - int readfds; - register int mask; -#endif /* def FD_SETSIZE */ - struct sockaddr_in from; - struct rpc_msg reply_msg; - XDR reply_xdrs; - struct timeval time_waited; - bool_t ok; - int nrefreshes = 2; /* number of times to refresh cred */ - struct timeval timeout; - - if (cu->cu_total.tv_usec == -1) { - timeout = utimeout; /* use supplied timeout */ - } else { - timeout = cu->cu_total; /* use default timeout */ - } - - time_waited.tv_sec = 0; - time_waited.tv_usec = 0; -call_again: - xdrs = &(cu->cu_outxdrs); - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, cu->cu_xdrpos); - /* - * the transaction is the first thing in the out buffer - */ - (*(u_short *)(cu->cu_outbuf))++; - if ((! XDR_PUTLONG(xdrs, (long *)&proc)) || - (! AUTH_MARSHALL(cl->cl_auth, xdrs)) || - (! (*xargs)(xdrs, argsp))) - return (cu->cu_error.re_status = RPC_CANTENCODEARGS); - outlen = (int)XDR_GETPOS(xdrs); - -send_again: - if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0, - (struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen) - != outlen) { - cu->cu_error.re_errno = errno; - return (cu->cu_error.re_status = RPC_CANTSEND); - } - - /* - * Hack to provide rpc-based message passing - */ - if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { - return (cu->cu_error.re_status = RPC_TIMEDOUT); - } - /* - * sub-optimal code appears here because we have - * some clock time to spare while the packets are in flight. - * (We assume that this is actually only executed once.) - */ - reply_msg.acpted_rply.ar_verf = _null_auth; - reply_msg.acpted_rply.ar_results.where = resultsp; - reply_msg.acpted_rply.ar_results.proc = xresults; -#ifdef FD_SETSIZE - FD_ZERO(&mask); - FD_SET(cu->cu_sock, &mask); -#else - mask = 1 << cu->cu_sock; -#endif /* def FD_SETSIZE */ - for (;;) { - readfds = mask; - switch (select(_rpc_dtablesize(), &readfds, (int *)NULL, - (int *)NULL, &(cu->cu_wait))) { - - case 0: - time_waited.tv_sec += cu->cu_wait.tv_sec; - time_waited.tv_usec += cu->cu_wait.tv_usec; - while (time_waited.tv_usec >= 1000000) { - time_waited.tv_sec++; - time_waited.tv_usec -= 1000000; - } - if ((time_waited.tv_sec < timeout.tv_sec) || - ((time_waited.tv_sec == timeout.tv_sec) && - (time_waited.tv_usec < timeout.tv_usec))) - goto send_again; - return (cu->cu_error.re_status = RPC_TIMEDOUT); - - /* - * buggy in other cases because time_waited is not being - * updated. - */ - case -1: - if (errno == EINTR) - continue; - cu->cu_error.re_errno = errno; - return (cu->cu_error.re_status = RPC_CANTRECV); - } - do { - fromlen = sizeof(struct sockaddr); - inlen = recvfrom(cu->cu_sock, cu->cu_inbuf, - (int) cu->cu_recvsz, 0, - (struct sockaddr *)&from, &fromlen); - } while (inlen < 0 && errno == EINTR); - if (inlen < 0) { - if (errno == EWOULDBLOCK) - continue; - cu->cu_error.re_errno = errno; - return (cu->cu_error.re_status = RPC_CANTRECV); - } - if (inlen < sizeof(u_long)) - continue; - /* see if reply transaction id matches sent id */ - if (*((u_long *)(cu->cu_inbuf)) != *((u_long *)(cu->cu_outbuf))) - continue; - /* we now assume we have the proper reply */ - break; - } - - /* - * now decode and validate the response - */ - xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int)inlen, XDR_DECODE); - ok = xdr_replymsg(&reply_xdrs, &reply_msg); - /* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */ - if (ok) { - _seterr_reply(&reply_msg, &(cu->cu_error)); - if (cu->cu_error.re_status == RPC_SUCCESS) { - if (! AUTH_VALIDATE(cl->cl_auth, - &reply_msg.acpted_rply.ar_verf)) { - cu->cu_error.re_status = RPC_AUTHERROR; - cu->cu_error.re_why = AUTH_INVALIDRESP; - } - if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { - xdrs->x_op = XDR_FREE; - (void)xdr_opaque_auth(xdrs, - &(reply_msg.acpted_rply.ar_verf)); - } - } /* end successful completion */ - else { - /* maybe our credentials need to be refreshed ... */ - if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth)) { - nrefreshes--; - goto call_again; - } - } /* end of unsuccessful completion */ - } /* end of valid reply message */ - else { - cu->cu_error.re_status = RPC_CANTDECODERES; - } - return (cu->cu_error.re_status); -} - -static void -clntudp_geterr(cl, errp) - CLIENT *cl; - struct rpc_err *errp; -{ - register struct cu_data *cu = (struct cu_data *)cl->cl_private; - - *errp = cu->cu_error; -} - - -static bool_t -clntudp_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - caddr_t res_ptr; -{ - register struct cu_data *cu = (struct cu_data *)cl->cl_private; - register XDR *xdrs = &(cu->cu_outxdrs); - - xdrs->x_op = XDR_FREE; - return ((*xdr_res)(xdrs, res_ptr)); -} - -static void -clntudp_abort(/*h*/) - /*CLIENT *h;*/ -{ -} - -static bool_t -clntudp_control(cl, request, info) - CLIENT *cl; - int request; - char *info; -{ - register struct cu_data *cu = (struct cu_data *)cl->cl_private; - - switch (request) { - case CLSET_TIMEOUT: - cu->cu_total = *(struct timeval *)info; - break; - case CLGET_TIMEOUT: - *(struct timeval *)info = cu->cu_total; - break; - case CLSET_RETRY_TIMEOUT: - cu->cu_wait = *(struct timeval *)info; - break; - case CLGET_RETRY_TIMEOUT: - *(struct timeval *)info = cu->cu_wait; - break; - case CLGET_SERVER_ADDR: - *(struct sockaddr_in *)info = cu->cu_raddr; - break; - default: - return (FALSE); - } - return (TRUE); -} - -static void -clntudp_destroy(cl) - CLIENT *cl; -{ - register struct cu_data *cu = (struct cu_data *)cl->cl_private; - - if (cu->cu_closeit) { - (void)close(cu->cu_sock); - } - XDR_DESTROY(&(cu->cu_outxdrs)); - mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz)); - mem_free((caddr_t)cl, sizeof(CLIENT)); -} diff --git a/lib/librpc/rpc/get_myaddress.c b/lib/librpc/rpc/get_myaddress.c deleted file mode 100644 index 409191430f16..000000000000 --- a/lib/librpc/rpc/get_myaddress.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: get_myaddress.c,v 1.4 1993/08/26 00:53:22 jtc Exp $"; -#endif - -/* - * get_myaddress.c - * - * Get client's IP address via ioctl. This avoids using the yellowpages. - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * don't use gethostbyname, which would invoke yellow pages - */ -get_myaddress(addr) - struct sockaddr_in *addr; -{ - int s; - char buf[BUFSIZ]; - struct ifconf ifc; - struct ifreq ifreq, *ifr; - int len, slop; - - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("get_myaddress: socket"); - exit(1); - } - ifc.ifc_len = sizeof (buf); - ifc.ifc_buf = buf; - if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { - perror("get_myaddress: ioctl (get interface configuration)"); - exit(1); - } - ifr = ifc.ifc_req; - for (len = ifc.ifc_len; len; len -= sizeof ifreq) { - ifreq = *ifr; - if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) { - perror("get_myaddress: ioctl"); - exit(1); - } - if ((ifreq.ifr_flags & IFF_UP) && - ifr->ifr_addr.sa_family == AF_INET) { - *addr = *((struct sockaddr_in *)&ifr->ifr_addr); - addr->sin_port = htons(PMAPPORT); - break; - } - /* - * Deal with variable length addresses - */ - slop = ifr->ifr_addr.sa_len - sizeof (struct sockaddr); - if (slop) { - ifr = (struct ifreq *) ((caddr_t)ifr + slop); - len -= slop; - } - ifr++; - } - (void) close(s); -} diff --git a/lib/librpc/rpc/getrpcent.c b/lib/librpc/rpc/getrpcent.c deleted file mode 100644 index 5252f2a8c1f5..000000000000 --- a/lib/librpc/rpc/getrpcent.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user or with the express written consent of - * Sun Microsystems, Inc. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)getrpcent.c 1.14 91/03/11 Copyr 1984 Sun Micro";*/ -static char *rcsid = "$Id: getrpcent.c,v 1.7 1993/08/26 00:53:23 jtc Exp $"; -#endif - -/* - * Copyright (c) 1984 by Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#ifdef YP -#include -#include -#endif - -/* - * Internet version. - */ -struct rpcdata { - FILE *rpcf; - int stayopen; -#define MAXALIASES 35 - char *rpc_aliases[MAXALIASES]; - struct rpcent rpc; - char line[BUFSIZ+1]; -#ifdef YP - char *domain; - char *current; - int currentlen; -#endif -} *rpcdata; - -#ifdef YP -static int __yp_nomap = 0; -#endif /* YP */ - -static struct rpcent *interpret(); -struct hostent *gethostent(); -char *inet_ntoa(); - -static char RPCDB[] = "/etc/rpc"; - -static struct rpcdata * -_rpcdata() -{ - register struct rpcdata *d = rpcdata; - - if (d == 0) { - d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata)); - rpcdata = d; - } - return (d); -} - -struct rpcent * -getrpcbynumber(number) - register int number; -{ - register struct rpcdata *d = _rpcdata(); - register struct rpcent *p; -#ifdef YP - int reason; - char adrstr[16]; -#endif - - if (d == 0) - return (0); -#ifdef YP - if (!__yp_nomap && _yp_check(&d->domain)) { - sprintf(adrstr, "%d", number); - reason = yp_match(d->domain, "rpc.bynumber", adrstr, strlen(adrstr), - &d->current, &d->currentlen); - switch(reason) { - case 0: - break; - case YPERR_MAP: - __yp_nomap = 1; - goto no_yp; - break; - default: - return(0); - break; - } - d->current[d->currentlen] = '\0'; - p = interpret(d->current, d->currentlen); - (void) free(d->current); - return p; - } -no_yp: -#endif /* YP */ - setrpcent(0); - while (p = getrpcent()) { - if (p->r_number == number) - break; - } - endrpcent(); - return (p); -} - -struct rpcent * -getrpcbyname(name) - char *name; -{ - struct rpcent *rpc; - char **rp; - - setrpcent(0); - while (rpc = getrpcent()) { - if (strcmp(rpc->r_name, name) == 0) - return (rpc); - for (rp = rpc->r_aliases; *rp != NULL; rp++) { - if (strcmp(*rp, name) == 0) - return (rpc); - } - } - endrpcent(); - return (NULL); -} - -void -setrpcent(f) - int f; -{ - register struct rpcdata *d = _rpcdata(); - - if (d == 0) - return; -#ifdef YP - if (!__yp_nomap && _yp_check(NULL)) { - if (d->current) - free(d->current); - d->current = NULL; - d->currentlen = 0; - return; - } - __yp_nomap = 0; -#endif /* YP */ - if (d->rpcf == NULL) - d->rpcf = fopen(RPCDB, "r"); - else - rewind(d->rpcf); - d->stayopen |= f; -} - -void -endrpcent() -{ - register struct rpcdata *d = _rpcdata(); - - if (d == 0) - return; -#ifdef YP - if (!__yp_nomap && _yp_check(NULL)) { - if (d->current && !d->stayopen) - free(d->current); - d->current = NULL; - d->currentlen = 0; - return; - } - __yp_nomap = 0; -#endif /* YP */ - if (d->rpcf && !d->stayopen) { - fclose(d->rpcf); - d->rpcf = NULL; - } -} - -struct rpcent * -getrpcent() -{ - struct rpcent *hp; - int reason; - register struct rpcdata *d = _rpcdata(); -#ifdef YP - char *key = NULL, *val = NULL; - int keylen, vallen; -#endif - - if (d == 0) - return(NULL); -#ifdef YP - if (!__yp_nomap && _yp_check(&d->domain)) { - if (d->current == NULL && d->currentlen == 0) { - reason = yp_first(d->domain, "rpc.bynumber", - &d->current, &d->currentlen, - &val, &vallen); - } else { - reason = yp_next(d->domain, "rpc.bynumber", - d->current, d->currentlen, - &d->current, &d->currentlen, - &val, &vallen); - } - switch(reason) { - case 0: - break; - case YPERR_MAP: - __yp_nomap = 1; - goto no_yp; - break; - default: - return(0); - break; - } - val[vallen] = '\0'; - hp = interpret(val, vallen); - (void) free(val); - return hp; - } -no_yp: -#endif /* YP */ - if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL) - return (NULL); - if (fgets(d->line, BUFSIZ, d->rpcf) == NULL) - return (NULL); - return (interpret(d->line, strlen(d->line))); -} - -static struct rpcent * -interpret(val, len) - char *val; - int len; -{ - register struct rpcdata *d = _rpcdata(); - char *p; - register char *cp, **q; - - if (d == 0) - return (0); - (void) strncpy(d->line, val, len); - p = d->line; - d->line[len] = '\n'; - if (*p == '#') - return (getrpcent()); - cp = strpbrk(p, "#\n"); - if (cp == NULL) - return (getrpcent()); - *cp = '\0'; - cp = strpbrk(p, " \t"); - if (cp == NULL) - return (getrpcent()); - *cp++ = '\0'; - /* THIS STUFF IS INTERNET SPECIFIC */ - d->rpc.r_name = d->line; - while (*cp == ' ' || *cp == '\t') - cp++; - d->rpc.r_number = atoi(cp); - q = d->rpc.r_aliases = d->rpc_aliases; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &(d->rpc_aliases[MAXALIASES - 1])) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - *q = NULL; - return (&d->rpc); -} - diff --git a/lib/librpc/rpc/getrpcport.c b/lib/librpc/rpc/getrpcport.c deleted file mode 100644 index 755c61747cc4..000000000000 --- a/lib/librpc/rpc/getrpcport.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)getrpcport.c 1.3 87/08/11 SMI";*/ -/*static char *sccsid = "from: @(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: getrpcport.c,v 1.3 1993/08/26 00:53:24 jtc Exp $"; -#endif - -/* - * Copyright (c) 1985 by Sun Microsystems, Inc. - */ - -#include -#include -#include -#include - -getrpcport(host, prognum, versnum, proto) - char *host; -{ - struct sockaddr_in addr; - struct hostent *hp; - - if ((hp = gethostbyname(host)) == NULL) - return (0); - bcopy(hp->h_addr, (char *) &addr.sin_addr, hp->h_length); - addr.sin_family = AF_INET; - addr.sin_port = 0; - return (pmap_getport(&addr, prognum, versnum, proto)); -} diff --git a/lib/librpc/rpc/pmap_clnt.c b/lib/librpc/rpc/pmap_clnt.c deleted file mode 100644 index de36b21785e0..000000000000 --- a/lib/librpc/rpc/pmap_clnt.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: pmap_clnt.c,v 1.3 1993/08/26 00:53:25 jtc Exp $"; -#endif - -/* - * pmap_clnt.c - * Client interface to pmap rpc service. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include - -static struct timeval timeout = { 5, 0 }; -static struct timeval tottimeout = { 60, 0 }; - -void clnt_perror(); - - -/* - * Set a mapping between program,version and port. - * Calls the pmap service remotely to do the mapping. - */ -bool_t -pmap_set(program, version, protocol, port) - u_long program; - u_long version; - int protocol; - u_short port; -{ - struct sockaddr_in myaddress; - int socket = -1; - register CLIENT *client; - struct pmap parms; - bool_t rslt; - - get_myaddress(&myaddress); - client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, - timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client == (CLIENT *)NULL) - return (FALSE); - parms.pm_prog = program; - parms.pm_vers = version; - parms.pm_prot = protocol; - parms.pm_port = port; - if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt, - tottimeout) != RPC_SUCCESS) { - clnt_perror(client, "Cannot register service"); - return (FALSE); - } - CLNT_DESTROY(client); - (void)close(socket); - return (rslt); -} - -/* - * Remove the mapping between program,version and port. - * Calls the pmap service remotely to do the un-mapping. - */ -bool_t -pmap_unset(program, version) - u_long program; - u_long version; -{ - struct sockaddr_in myaddress; - int socket = -1; - register CLIENT *client; - struct pmap parms; - bool_t rslt; - - get_myaddress(&myaddress); - client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, - timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client == (CLIENT *)NULL) - return (FALSE); - parms.pm_prog = program; - parms.pm_vers = version; - parms.pm_port = parms.pm_prot = 0; - CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt, - tottimeout); - CLNT_DESTROY(client); - (void)close(socket); - return (rslt); -} diff --git a/lib/librpc/rpc/pmap_getmaps.c b/lib/librpc/rpc/pmap_getmaps.c deleted file mode 100644 index 4c172e62a68a..000000000000 --- a/lib/librpc/rpc/pmap_getmaps.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: pmap_getmaps.c,v 1.3 1993/08/26 00:53:27 jtc Exp $"; -#endif - -/* - * pmap_getmap.c - * Client interface to pmap rpc service. - * contains pmap_getmaps, which is only tcp service involved - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define NAMELEN 255 -#define MAX_BROADCAST_SIZE 1400 - -extern int errno; - -/* - * Get a copy of the current port maps. - * Calls the pmap service remotely to do get the maps. - */ -struct pmaplist * -pmap_getmaps(address) - struct sockaddr_in *address; -{ - struct pmaplist *head = (struct pmaplist *)NULL; - int socket = -1; - struct timeval minutetimeout; - register CLIENT *client; - - minutetimeout.tv_sec = 60; - minutetimeout.tv_usec = 0; - address->sin_port = htons(PMAPPORT); - client = clnttcp_create(address, PMAPPROG, - PMAPVERS, &socket, 50, 500); - if (client != (CLIENT *)NULL) { - if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL, xdr_pmaplist, - &head, minutetimeout) != RPC_SUCCESS) { - clnt_perror(client, "pmap_getmaps rpc problem"); - } - CLNT_DESTROY(client); - } - (void)close(socket); - address->sin_port = 0; - return (head); -} diff --git a/lib/librpc/rpc/pmap_getport.c b/lib/librpc/rpc/pmap_getport.c deleted file mode 100644 index c8b3d166ca57..000000000000 --- a/lib/librpc/rpc/pmap_getport.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: pmap_getport.c,v 1.3 1993/08/26 00:53:28 jtc Exp $"; -#endif - -/* - * pmap_getport.c - * Client interface to pmap rpc service. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include - -static struct timeval timeout = { 5, 0 }; -static struct timeval tottimeout = { 60, 0 }; - -/* - * Find the mapped port for program,version. - * Calls the pmap service remotely to do the lookup. - * Returns 0 if no map exists. - */ -u_short -pmap_getport(address, program, version, protocol) - struct sockaddr_in *address; - u_long program; - u_long version; - u_int protocol; -{ - u_short port = 0; - int socket = -1; - register CLIENT *client; - struct pmap parms; - - address->sin_port = htons(PMAPPORT); - client = clntudp_bufcreate(address, PMAPPROG, - PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); - if (client != (CLIENT *)NULL) { - parms.pm_prog = program; - parms.pm_vers = version; - parms.pm_prot = protocol; - parms.pm_port = 0; /* not needed or used */ - if (CLNT_CALL(client, PMAPPROC_GETPORT, xdr_pmap, &parms, - xdr_u_short, &port, tottimeout) != RPC_SUCCESS){ - rpc_createerr.cf_stat = RPC_PMAPFAILURE; - clnt_geterr(client, &rpc_createerr.cf_error); - } else if (port == 0) { - rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; - } - CLNT_DESTROY(client); - } - (void)close(socket); - address->sin_port = 0; - return (port); -} diff --git a/lib/librpc/rpc/pmap_prot.c b/lib/librpc/rpc/pmap_prot.c deleted file mode 100644 index e38d35a6853b..000000000000 --- a/lib/librpc/rpc/pmap_prot.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)pmap_prot.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: pmap_prot.c,v 1.3 1993/08/26 00:53:29 jtc Exp $"; -#endif - -/* - * pmap_prot.c - * Protocol for the local binder service, or pmap. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include - - -bool_t -xdr_pmap(xdrs, regs) - XDR *xdrs; - struct pmap *regs; -{ - - if (xdr_u_long(xdrs, ®s->pm_prog) && - xdr_u_long(xdrs, ®s->pm_vers) && - xdr_u_long(xdrs, ®s->pm_prot)) - return (xdr_u_long(xdrs, ®s->pm_port)); - return (FALSE); -} diff --git a/lib/librpc/rpc/pmap_prot2.c b/lib/librpc/rpc/pmap_prot2.c deleted file mode 100644 index dcdce8e1a2b7..000000000000 --- a/lib/librpc/rpc/pmap_prot2.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)pmap_prot2.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: pmap_prot2.c,v 1.3 1993/08/26 00:53:30 jtc Exp $"; -#endif - -/* - * pmap_prot2.c - * Protocol for the local binder service, or pmap. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include - - -/* - * What is going on with linked lists? (!) - * First recall the link list declaration from pmap_prot.h: - * - * struct pmaplist { - * struct pmap pml_map; - * struct pmaplist *pml_map; - * }; - * - * Compare that declaration with a corresponding xdr declaration that - * is (a) pointer-less, and (b) recursive: - * - * typedef union switch (bool_t) { - * - * case TRUE: struct { - * struct pmap; - * pmaplist_t foo; - * }; - * - * case FALSE: struct {}; - * } pmaplist_t; - * - * Notice that the xdr declaration has no nxt pointer while - * the C declaration has no bool_t variable. The bool_t can be - * interpreted as ``more data follows me''; if FALSE then nothing - * follows this bool_t; if TRUE then the bool_t is followed by - * an actual struct pmap, and then (recursively) by the - * xdr union, pamplist_t. - * - * This could be implemented via the xdr_union primitive, though this - * would cause a one recursive call per element in the list. Rather than do - * that we can ``unwind'' the recursion - * into a while loop and do the union arms in-place. - * - * The head of the list is what the C programmer wishes to past around - * the net, yet is the data that the pointer points to which is interesting; - * this sounds like a job for xdr_reference! - */ -bool_t -xdr_pmaplist(xdrs, rp) - register XDR *xdrs; - register struct pmaplist **rp; -{ - /* - * more_elements is pre-computed in case the direction is - * XDR_ENCODE or XDR_FREE. more_elements is overwritten by - * xdr_bool when the direction is XDR_DECODE. - */ - bool_t more_elements; - register int freeing = (xdrs->x_op == XDR_FREE); - register struct pmaplist **next; - - while (TRUE) { - more_elements = (bool_t)(*rp != NULL); - if (! xdr_bool(xdrs, &more_elements)) - return (FALSE); - if (! more_elements) - return (TRUE); /* we are done */ - /* - * the unfortunate side effect of non-recursion is that in - * the case of freeing we must remember the next object - * before we free the current object ... - */ - if (freeing) - next = &((*rp)->pml_next); - if (! xdr_reference(xdrs, (caddr_t *)rp, - (u_int)sizeof(struct pmaplist), xdr_pmap)) - return (FALSE); - rp = (freeing) ? next : &((*rp)->pml_next); - } -} diff --git a/lib/librpc/rpc/pmap_rmt.c b/lib/librpc/rpc/pmap_rmt.c deleted file mode 100644 index 599dc8e0b31b..000000000000 --- a/lib/librpc/rpc/pmap_rmt.c +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: pmap_rmt.c,v 1.3 1993/08/26 00:53:32 jtc Exp $"; -#endif - -/* - * pmap_rmt.c - * Client interface to pmap rpc service. - * remote call and broadcast service - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define MAX_BROADCAST_SIZE 1400 - -extern int errno; -static struct timeval timeout = { 3, 0 }; - - -/* - * pmapper remote-call-service interface. - * This routine is used to call the pmapper remote call service - * which will look up a service program in the port maps, and then - * remotely call that routine with the given parameters. This allows - * programs to do a lookup and call in one step. -*/ -enum clnt_stat -pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_ptr) - struct sockaddr_in *addr; - u_long prog, vers, proc; - xdrproc_t xdrargs, xdrres; - caddr_t argsp, resp; - struct timeval tout; - u_long *port_ptr; -{ - int socket = -1; - register CLIENT *client; - struct rmtcallargs a; - struct rmtcallres r; - enum clnt_stat stat; - - addr->sin_port = htons(PMAPPORT); - client = clntudp_create(addr, PMAPPROG, PMAPVERS, timeout, &socket); - if (client != (CLIENT *)NULL) { - a.prog = prog; - a.vers = vers; - a.proc = proc; - a.args_ptr = argsp; - a.xdr_args = xdrargs; - r.port_ptr = port_ptr; - r.results_ptr = resp; - r.xdr_results = xdrres; - stat = CLNT_CALL(client, PMAPPROC_CALLIT, xdr_rmtcall_args, &a, - xdr_rmtcallres, &r, tout); - CLNT_DESTROY(client); - } else { - stat = RPC_FAILED; - } - (void)close(socket); - addr->sin_port = 0; - return (stat); -} - - -/* - * XDR remote call arguments - * written for XDR_ENCODE direction only - */ -bool_t -xdr_rmtcall_args(xdrs, cap) - register XDR *xdrs; - register struct rmtcallargs *cap; -{ - u_int lenposition, argposition, position; - - if (xdr_u_long(xdrs, &(cap->prog)) && - xdr_u_long(xdrs, &(cap->vers)) && - xdr_u_long(xdrs, &(cap->proc))) { - lenposition = XDR_GETPOS(xdrs); - if (! xdr_u_long(xdrs, &(cap->arglen))) - return (FALSE); - argposition = XDR_GETPOS(xdrs); - if (! (*(cap->xdr_args))(xdrs, cap->args_ptr)) - return (FALSE); - position = XDR_GETPOS(xdrs); - cap->arglen = (u_long)position - (u_long)argposition; - XDR_SETPOS(xdrs, lenposition); - if (! xdr_u_long(xdrs, &(cap->arglen))) - return (FALSE); - XDR_SETPOS(xdrs, position); - return (TRUE); - } - return (FALSE); -} - -/* - * XDR remote call results - * written for XDR_DECODE direction only - */ -bool_t -xdr_rmtcallres(xdrs, crp) - register XDR *xdrs; - register struct rmtcallres *crp; -{ - caddr_t port_ptr; - - port_ptr = (caddr_t)crp->port_ptr; - if (xdr_reference(xdrs, &port_ptr, sizeof (u_long), - xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { - crp->port_ptr = (u_long *)port_ptr; - return ((*(crp->xdr_results))(xdrs, crp->results_ptr)); - } - return (FALSE); -} - - -/* - * The following is kludged-up support for simple rpc broadcasts. - * Someday a large, complicated system will replace these trivial - * routines which only support udp/ip . - */ - -static int -getbroadcastnets(addrs, sock, buf) - struct in_addr *addrs; - int sock; /* any valid socket will do */ - char *buf; /* why allocxate more when we can use existing... */ -{ - struct ifconf ifc; - struct ifreq ifreq, *ifr; - struct sockaddr_in *sin; - char *cp, *cplim; - int n, i = 0; - - ifc.ifc_len = UDPMSGSIZE; - ifc.ifc_buf = buf; - if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { - perror("broadcast: ioctl (get interface configuration)"); - return (0); - } -#define max(a, b) (a > b ? a : b) -#define size(p) max((p).sa_len, sizeof(p)) - cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */ - for (cp = buf; cp < cplim; - cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) { - ifr = (struct ifreq *)cp; - if (ifr->ifr_addr.sa_family != AF_INET) - continue; - ifreq = *ifr; - if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) { - perror("broadcast: ioctl (get interface flags)"); - continue; - } - if ((ifreq.ifr_flags & IFF_BROADCAST) && - (ifreq.ifr_flags & IFF_UP)) { - sin = (struct sockaddr_in *)&ifr->ifr_addr; -#ifdef SIOCGIFBRDADDR /* 4.3BSD */ - if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { - addrs[i++] = - inet_makeaddr(inet_netof(sin->sin_addr), - INADDR_ANY); - } else { - addrs[i++] = ((struct sockaddr_in*) - &ifreq.ifr_addr)->sin_addr; - } -#else /* 4.2 BSD */ - addrs[i++] = inet_makeaddr(inet_netof(sin->sin_addr), - INADDR_ANY); -#endif - } - } - return (i); -} - -typedef bool_t (*resultproc_t)(); - -enum clnt_stat -clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) - u_long prog; /* program number */ - u_long vers; /* version number */ - u_long proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - caddr_t argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - caddr_t resultsp; /* pointer to results */ - resultproc_t eachresult; /* call with each result obtained */ -{ - enum clnt_stat stat; - AUTH *unix_auth = authunix_create_default(); - XDR xdr_stream; - register XDR *xdrs = &xdr_stream; - int outlen, inlen, fromlen, nets; - register int sock; - int on = 1; -#ifdef FD_SETSIZE - fd_set mask; - fd_set readfds; -#else - int readfds; - register int mask; -#endif /* def FD_SETSIZE */ - register int i; - bool_t done = FALSE; - register u_long xid; - u_long port; - struct in_addr addrs[20]; - struct sockaddr_in baddr, raddr; /* broadcast and response addresses */ - struct rmtcallargs a; - struct rmtcallres r; - struct rpc_msg msg; - struct timeval t; - char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE]; - - /* - * initialization: create a socket, a broadcast address, and - * preserialize the arguments into a send buffer. - */ - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - perror("Cannot create socket for broadcast rpc"); - stat = RPC_CANTSEND; - goto done_broad; - } -#ifdef SO_BROADCAST - if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { - perror("Cannot set socket option SO_BROADCAST"); - stat = RPC_CANTSEND; - goto done_broad; - } -#endif /* def SO_BROADCAST */ -#ifdef FD_SETSIZE - FD_ZERO(&mask); - FD_SET(sock, &mask); -#else - mask = (1 << sock); -#endif /* def FD_SETSIZE */ - nets = getbroadcastnets(addrs, sock, inbuf); - bzero((char *)&baddr, sizeof (baddr)); - baddr.sin_family = AF_INET; - baddr.sin_port = htons(PMAPPORT); - baddr.sin_addr.s_addr = htonl(INADDR_ANY); -/* baddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY); */ - (void)gettimeofday(&t, (struct timezone *)0); - msg.rm_xid = xid = getpid() ^ t.tv_sec ^ t.tv_usec; - t.tv_usec = 0; - msg.rm_direction = CALL; - msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - msg.rm_call.cb_prog = PMAPPROG; - msg.rm_call.cb_vers = PMAPVERS; - msg.rm_call.cb_proc = PMAPPROC_CALLIT; - msg.rm_call.cb_cred = unix_auth->ah_cred; - msg.rm_call.cb_verf = unix_auth->ah_verf; - a.prog = prog; - a.vers = vers; - a.proc = proc; - a.xdr_args = xargs; - a.args_ptr = argsp; - r.port_ptr = &port; - r.xdr_results = xresults; - r.results_ptr = resultsp; - xdrmem_create(xdrs, outbuf, MAX_BROADCAST_SIZE, XDR_ENCODE); - if ((! xdr_callmsg(xdrs, &msg)) || (! xdr_rmtcall_args(xdrs, &a))) { - stat = RPC_CANTENCODEARGS; - goto done_broad; - } - outlen = (int)xdr_getpos(xdrs); - xdr_destroy(xdrs); - /* - * Basic loop: broadcast a packet and wait a while for response(s). - * The response timeout grows larger per iteration. - */ - for (t.tv_sec = 4; t.tv_sec <= 14; t.tv_sec += 2) { - for (i = 0; i < nets; i++) { - baddr.sin_addr = addrs[i]; - if (sendto(sock, outbuf, outlen, 0, - (struct sockaddr *)&baddr, - sizeof (struct sockaddr)) != outlen) { - perror("Cannot send broadcast packet"); - stat = RPC_CANTSEND; - goto done_broad; - } - } - if (eachresult == NULL) { - stat = RPC_SUCCESS; - goto done_broad; - } - recv_again: - msg.acpted_rply.ar_verf = _null_auth; - msg.acpted_rply.ar_results.where = (caddr_t)&r; - msg.acpted_rply.ar_results.proc = xdr_rmtcallres; - readfds = mask; - switch (select(_rpc_dtablesize(), &readfds, (int *)NULL, - (int *)NULL, &t)) { - - case 0: /* timed out */ - stat = RPC_TIMEDOUT; - continue; - - case -1: /* some kind of error */ - if (errno == EINTR) - goto recv_again; - perror("Broadcast select problem"); - stat = RPC_CANTRECV; - goto done_broad; - - } /* end of select results switch */ - try_again: - fromlen = sizeof(struct sockaddr); - inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0, - (struct sockaddr *)&raddr, &fromlen); - if (inlen < 0) { - if (errno == EINTR) - goto try_again; - perror("Cannot receive reply to broadcast"); - stat = RPC_CANTRECV; - goto done_broad; - } - if (inlen < sizeof(u_long)) - goto recv_again; - /* - * see if reply transaction id matches sent id. - * If so, decode the results. - */ - xdrmem_create(xdrs, inbuf, (u_int)inlen, XDR_DECODE); - if (xdr_replymsg(xdrs, &msg)) { - if ((msg.rm_xid == xid) && - (msg.rm_reply.rp_stat == MSG_ACCEPTED) && - (msg.acpted_rply.ar_stat == SUCCESS)) { - raddr.sin_port = htons((u_short)port); - done = (*eachresult)(resultsp, &raddr); - } - /* otherwise, we just ignore the errors ... */ - } else { -#ifdef notdef - /* some kind of deserialization problem ... */ - if (msg.rm_xid == xid) - fprintf(stderr, "Broadcast deserialization problem"); - /* otherwise, just random garbage */ -#endif - } - xdrs->x_op = XDR_FREE; - msg.acpted_rply.ar_results.proc = xdr_void; - (void)xdr_replymsg(xdrs, &msg); - (void)(*xresults)(xdrs, resultsp); - xdr_destroy(xdrs); - if (done) { - stat = RPC_SUCCESS; - goto done_broad; - } else { - goto recv_again; - } - } -done_broad: - (void)close(sock); - AUTH_DESTROY(unix_auth); - return (stat); -} - diff --git a/lib/librpc/rpc/rpc.h b/lib/librpc/rpc/rpc.h deleted file mode 100644 index cd403b73510e..000000000000 --- a/lib/librpc/rpc/rpc.h +++ /dev/null @@ -1,80 +0,0 @@ -/* @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC; from 1.9 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * rpc.h, Just includes the billions of rpc header files necessary to - * do remote procedure calling. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ -#ifndef __RPC_HEADER__ -#define __RPC_HEADER__ - -#include /* some typedefs */ -#include - -/* external data representation interfaces */ -#include /* generic (de)serializer */ - -/* Client side only authentication */ -#include /* generic authenticator (client side) */ - -/* Client side (mostly) remote procedure call */ -#include /* generic rpc stuff */ - -/* semi-private protocol headers */ -#include /* protocol for rpc messages */ -#include /* protocol for unix style cred */ -/* - * Uncomment-out the next line if you are building the rpc library with - * DES Authentication (see the README file in the secure_rpc/ directory). - */ -/*#include /* protocol for des style cred */ - -/* Server side only remote procedure callee */ -#include /* service manager and multiplexer */ -#include /* service side authenticator */ - -/* - * COMMENT OUT THE NEXT INCLUDE (or add to the #ifndef) IF RUNNING ON - * A VERSION OF UNIX THAT USES SUN'S NFS SOURCE. These systems will - * already have the structures defined by included in . - */ -/* routines for parsing /etc/rpc */ - -struct rpcent { - char *r_name; /* name of server for this rpc program */ - char **r_aliases; /* alias list */ - int r_number; /* rpc program number */ -}; - -struct rpcent *getrpcbyname(), *getrpcbynumber(), *getrpcent(); - -#endif /* ndef __RPC_HEADER__ */ diff --git a/lib/librpc/rpc/rpc_callmsg.c b/lib/librpc/rpc/rpc_callmsg.c deleted file mode 100644 index 509a32e0fffb..000000000000 --- a/lib/librpc/rpc/rpc_callmsg.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: rpc_callmsg.c,v 1.3 1993/08/26 00:53:33 jtc Exp $"; -#endif - -/* - * rpc_callmsg.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - */ - -#include - -#include - -/* - * XDR a call message - */ -bool_t -xdr_callmsg(xdrs, cmsg) - register XDR *xdrs; - register struct rpc_msg *cmsg; -{ - register long *buf; - register struct opaque_auth *oa; - - if (xdrs->x_op == XDR_ENCODE) { - if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT - + RNDUP(cmsg->rm_call.cb_cred.oa_length) - + 2 * BYTES_PER_XDR_UNIT - + RNDUP(cmsg->rm_call.cb_verf.oa_length)); - if (buf != NULL) { - IXDR_PUT_LONG(buf, cmsg->rm_xid); - IXDR_PUT_ENUM(buf, cmsg->rm_direction); - if (cmsg->rm_direction != CALL) { - return (FALSE); - } - IXDR_PUT_LONG(buf, cmsg->rm_call.cb_rpcvers); - if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) { - return (FALSE); - } - IXDR_PUT_LONG(buf, cmsg->rm_call.cb_prog); - IXDR_PUT_LONG(buf, cmsg->rm_call.cb_vers); - IXDR_PUT_LONG(buf, cmsg->rm_call.cb_proc); - oa = &cmsg->rm_call.cb_cred; - IXDR_PUT_ENUM(buf, oa->oa_flavor); - IXDR_PUT_LONG(buf, oa->oa_length); - if (oa->oa_length) { - bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length); - buf += RNDUP(oa->oa_length) / sizeof (long); - } - oa = &cmsg->rm_call.cb_verf; - IXDR_PUT_ENUM(buf, oa->oa_flavor); - IXDR_PUT_LONG(buf, oa->oa_length); - if (oa->oa_length) { - bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length); - /* no real need.... - buf += RNDUP(oa->oa_length) / sizeof (long); - */ - } - return (TRUE); - } - } - if (xdrs->x_op == XDR_DECODE) { - buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT); - if (buf != NULL) { - cmsg->rm_xid = IXDR_GET_LONG(buf); - cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type); - if (cmsg->rm_direction != CALL) { - return (FALSE); - } - cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG(buf); - if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) { - return (FALSE); - } - cmsg->rm_call.cb_prog = IXDR_GET_LONG(buf); - cmsg->rm_call.cb_vers = IXDR_GET_LONG(buf); - cmsg->rm_call.cb_proc = IXDR_GET_LONG(buf); - oa = &cmsg->rm_call.cb_cred; - oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); - oa->oa_length = IXDR_GET_LONG(buf); - if (oa->oa_length) { - if (oa->oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - if (oa->oa_base == NULL) { - oa->oa_base = (caddr_t) - mem_alloc(oa->oa_length); - } - buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); - if (buf == NULL) { - if (xdr_opaque(xdrs, oa->oa_base, - oa->oa_length) == FALSE) { - return (FALSE); - } - } else { - bcopy((caddr_t)buf, oa->oa_base, - oa->oa_length); - /* no real need.... - buf += RNDUP(oa->oa_length) / - sizeof (long); - */ - } - } - oa = &cmsg->rm_call.cb_verf; - buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE || - xdr_u_int(xdrs, &oa->oa_length) == FALSE) { - return (FALSE); - } - } else { - oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); - oa->oa_length = IXDR_GET_LONG(buf); - } - if (oa->oa_length) { - if (oa->oa_length > MAX_AUTH_BYTES) { - return (FALSE); - } - if (oa->oa_base == NULL) { - oa->oa_base = (caddr_t) - mem_alloc(oa->oa_length); - } - buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); - if (buf == NULL) { - if (xdr_opaque(xdrs, oa->oa_base, - oa->oa_length) == FALSE) { - return (FALSE); - } - } else { - bcopy((caddr_t)buf, oa->oa_base, - oa->oa_length); - /* no real need... - buf += RNDUP(oa->oa_length) / - sizeof (long); - */ - } - } - return (TRUE); - } - } - if ( - xdr_u_long(xdrs, &(cmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) && - (cmsg->rm_direction == CALL) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && - (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_proc)) && - xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) ) - return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf))); - return (FALSE); -} - diff --git a/lib/librpc/rpc/rpc_commondata.c b/lib/librpc/rpc/rpc_commondata.c deleted file mode 100644 index 212b7f7a02f4..000000000000 --- a/lib/librpc/rpc/rpc_commondata.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)rpc_commondata.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: rpc_commondata.c,v 1.3 1993/08/26 00:53:34 jtc Exp $"; -#endif - -#include -/* - * This file should only contain common data (global data) that is exported - * by public interfaces - */ -struct opaque_auth _null_auth; -#ifdef FD_SETSIZE -fd_set svc_fdset; -#else -int svc_fds; -#endif /* def FD_SETSIZE */ -struct rpc_createerr rpc_createerr; diff --git a/lib/librpc/rpc/rpc_dtablesize.c b/lib/librpc/rpc/rpc_dtablesize.c deleted file mode 100644 index 982f2e39e9e1..000000000000 --- a/lib/librpc/rpc/rpc_dtablesize.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";*/ -/*static char *sccsid = "from: @(#)rpc_dtablesize.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: rpc_dtablesize.c,v 1.3 1993/08/26 00:53:35 jtc Exp $"; -#endif - -/* - * Cache the result of getdtablesize(), so we don't have to do an - * expensive system call every time. - */ -_rpc_dtablesize() -{ - static int size; - - if (size == 0) { - size = getdtablesize(); - } - return (size); -} diff --git a/lib/librpc/rpc/rpc_msg.h b/lib/librpc/rpc/rpc_msg.h deleted file mode 100644 index b78872b6a8d6..000000000000 --- a/lib/librpc/rpc/rpc_msg.h +++ /dev/null @@ -1,187 +0,0 @@ -/* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)rpc_msg.h 1.7 86/07/16 SMI */ - -/* - * rpc_msg.h - * rpc message definition - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#define RPC_MSG_VERSION ((u_long) 2) -#define RPC_SERVICE_PORT ((u_short) 2048) - -/* - * Bottom up definition of an rpc message. - * NOTE: call and reply use the same overall stuct but - * different parts of unions within it. - */ - -enum msg_type { - CALL=0, - REPLY=1 -}; - -enum reply_stat { - MSG_ACCEPTED=0, - MSG_DENIED=1 -}; - -enum accept_stat { - SUCCESS=0, - PROG_UNAVAIL=1, - PROG_MISMATCH=2, - PROC_UNAVAIL=3, - GARBAGE_ARGS=4, - SYSTEM_ERR=5 -}; - -enum reject_stat { - RPC_MISMATCH=0, - AUTH_ERROR=1 -}; - -/* - * Reply part of an rpc exchange - */ - -/* - * Reply to an rpc request that was accepted by the server. - * Note: there could be an error even though the request was - * accepted. - */ -struct accepted_reply { - struct opaque_auth ar_verf; - enum accept_stat ar_stat; - union { - struct { - u_long low; - u_long high; - } AR_versions; - struct { - caddr_t where; - xdrproc_t proc; - } AR_results; - /* and many other null cases */ - } ru; -#define ar_results ru.AR_results -#define ar_vers ru.AR_versions -}; - -/* - * Reply to an rpc request that was rejected by the server. - */ -struct rejected_reply { - enum reject_stat rj_stat; - union { - struct { - u_long low; - u_long high; - } RJ_versions; - enum auth_stat RJ_why; /* why authentication did not work */ - } ru; -#define rj_vers ru.RJ_versions -#define rj_why ru.RJ_why -}; - -/* - * Body of a reply to an rpc request. - */ -struct reply_body { - enum reply_stat rp_stat; - union { - struct accepted_reply RP_ar; - struct rejected_reply RP_dr; - } ru; -#define rp_acpt ru.RP_ar -#define rp_rjct ru.RP_dr -}; - -/* - * Body of an rpc request call. - */ -struct call_body { - u_long cb_rpcvers; /* must be equal to two */ - u_long cb_prog; - u_long cb_vers; - u_long cb_proc; - struct opaque_auth cb_cred; - struct opaque_auth cb_verf; /* protocol specific - provided by client */ -}; - -/* - * The rpc message - */ -struct rpc_msg { - u_long rm_xid; - enum msg_type rm_direction; - union { - struct call_body RM_cmb; - struct reply_body RM_rmb; - } ru; -#define rm_call ru.RM_cmb -#define rm_reply ru.RM_rmb -}; -#define acpted_rply ru.RM_rmb.ru.RP_ar -#define rjcted_rply ru.RM_rmb.ru.RP_dr - - -/* - * XDR routine to handle a rpc message. - * xdr_callmsg(xdrs, cmsg) - * XDR *xdrs; - * struct rpc_msg *cmsg; - */ -extern bool_t xdr_callmsg(); - -/* - * XDR routine to pre-serialize the static part of a rpc message. - * xdr_callhdr(xdrs, cmsg) - * XDR *xdrs; - * struct rpc_msg *cmsg; - */ -extern bool_t xdr_callhdr(); - -/* - * XDR routine to handle a rpc reply. - * xdr_replymsg(xdrs, rmsg) - * XDR *xdrs; - * struct rpc_msg *rmsg; - */ -extern bool_t xdr_replymsg(); - -/* - * Fills in the error part of a reply message. - * _seterr_reply(msg, error) - * struct rpc_msg *msg; - * struct rpc_err *error; - */ -extern void _seterr_reply(); diff --git a/lib/librpc/rpc/rpc_prot.c b/lib/librpc/rpc/rpc_prot.c deleted file mode 100644 index 646d638c99cd..000000000000 --- a/lib/librpc/rpc/rpc_prot.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC";*/ -static char *rcsid = "$Id: rpc_prot.c,v 1.3 1993/08/26 00:53:36 jtc Exp $"; -#endif - -/* - * rpc_prot.c - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * This set of routines implements the rpc message definition, - * its serializer and some common rpc utility routines. - * The routines are meant for various implementations of rpc - - * they are NOT for the rpc client or rpc service implementations! - * Because authentication stuff is easy and is part of rpc, the opaque - * routines are also in this program. - */ - -#include - -#include - -/* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */ - -struct opaque_auth _null_auth; - -/* - * XDR an opaque authentication struct - * (see auth.h) - */ -bool_t -xdr_opaque_auth(xdrs, ap) - register XDR *xdrs; - register struct opaque_auth *ap; -{ - - if (xdr_enum(xdrs, &(ap->oa_flavor))) - return (xdr_bytes(xdrs, &ap->oa_base, - &ap->oa_length, MAX_AUTH_BYTES)); - return (FALSE); -} - -/* - * XDR a DES block - */ -bool_t -xdr_des_block(xdrs, blkp) - register XDR *xdrs; - register des_block *blkp; -{ - return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block))); -} - -/* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */ - -/* - * XDR the MSG_ACCEPTED part of a reply message union - */ -bool_t -xdr_accepted_reply(xdrs, ar) - register XDR *xdrs; - register struct accepted_reply *ar; -{ - - /* personalized union, rather than calling xdr_union */ - if (! xdr_opaque_auth(xdrs, &(ar->ar_verf))) - return (FALSE); - if (! xdr_enum(xdrs, (enum_t *)&(ar->ar_stat))) - return (FALSE); - switch (ar->ar_stat) { - - case SUCCESS: - return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where)); - - case PROG_MISMATCH: - if (! xdr_u_long(xdrs, &(ar->ar_vers.low))) - return (FALSE); - return (xdr_u_long(xdrs, &(ar->ar_vers.high))); - } - return (TRUE); /* TRUE => open ended set of problems */ -} - -/* - * XDR the MSG_DENIED part of a reply message union - */ -bool_t -xdr_rejected_reply(xdrs, rr) - register XDR *xdrs; - register struct rejected_reply *rr; -{ - - /* personalized union, rather than calling xdr_union */ - if (! xdr_enum(xdrs, (enum_t *)&(rr->rj_stat))) - return (FALSE); - switch (rr->rj_stat) { - - case RPC_MISMATCH: - if (! xdr_u_long(xdrs, &(rr->rj_vers.low))) - return (FALSE); - return (xdr_u_long(xdrs, &(rr->rj_vers.high))); - - case AUTH_ERROR: - return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why))); - } - return (FALSE); -} - -static struct xdr_discrim reply_dscrm[3] = { - { (int)MSG_ACCEPTED, xdr_accepted_reply }, - { (int)MSG_DENIED, xdr_rejected_reply }, - { __dontcare__, NULL_xdrproc_t } }; - -/* - * XDR a reply message - */ -bool_t -xdr_replymsg(xdrs, rmsg) - register XDR *xdrs; - register struct rpc_msg *rmsg; -{ - if ( - xdr_u_long(xdrs, &(rmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) && - (rmsg->rm_direction == REPLY) ) - return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat), - (caddr_t)&(rmsg->rm_reply.ru), reply_dscrm, NULL_xdrproc_t)); - return (FALSE); -} - - -/* - * Serializes the "static part" of a call message header. - * The fields include: rm_xid, rm_direction, rpcvers, prog, and vers. - * The rm_xid is not really static, but the user can easily munge on the fly. - */ -bool_t -xdr_callhdr(xdrs, cmsg) - register XDR *xdrs; - register struct rpc_msg *cmsg; -{ - - cmsg->rm_direction = CALL; - cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION; - if ( - (xdrs->x_op == XDR_ENCODE) && - xdr_u_long(xdrs, &(cmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) ) - return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers))); - return (FALSE); -} - -/* ************************** Client utility routine ************* */ - -static void -accepted(acpt_stat, error) - register enum accept_stat acpt_stat; - register struct rpc_err *error; -{ - - switch (acpt_stat) { - - case PROG_UNAVAIL: - error->re_status = RPC_PROGUNAVAIL; - return; - - case PROG_MISMATCH: - error->re_status = RPC_PROGVERSMISMATCH; - return; - - case PROC_UNAVAIL: - error->re_status = RPC_PROCUNAVAIL; - return; - - case GARBAGE_ARGS: - error->re_status = RPC_CANTDECODEARGS; - return; - - case SYSTEM_ERR: - error->re_status = RPC_SYSTEMERROR; - return; - - case SUCCESS: - error->re_status = RPC_SUCCESS; - return; - } - /* something's wrong, but we don't know what ... */ - error->re_status = RPC_FAILED; - error->re_lb.s1 = (long)MSG_ACCEPTED; - error->re_lb.s2 = (long)acpt_stat; -} - -static void -rejected(rjct_stat, error) - register enum reject_stat rjct_stat; - register struct rpc_err *error; -{ - - switch (rjct_stat) { - - case RPC_VERSMISMATCH: - error->re_status = RPC_VERSMISMATCH; - return; - - case AUTH_ERROR: - error->re_status = RPC_AUTHERROR; - return; - } - /* something's wrong, but we don't know what ... */ - error->re_status = RPC_FAILED; - error->re_lb.s1 = (long)MSG_DENIED; - error->re_lb.s2 = (long)rjct_stat; -} - -/* - * given a reply message, fills in the error - */ -void -_seterr_reply(msg, error) - register struct rpc_msg *msg; - register struct rpc_err *error; -{ - - /* optimized for normal, SUCCESSful case */ - switch (msg->rm_reply.rp_stat) { - - case MSG_ACCEPTED: - if (msg->acpted_rply.ar_stat == SUCCESS) { - error->re_status = RPC_SUCCESS; - return; - }; - accepted(msg->acpted_rply.ar_stat, error); - break; - - case MSG_DENIED: - rejected(msg->rjcted_rply.rj_stat, error); - break; - - default: - error->re_status = RPC_FAILED; - error->re_lb.s1 = (long)(msg->rm_reply.rp_stat); - break; - } - switch (error->re_status) { - - case RPC_VERSMISMATCH: - error->re_vers.low = msg->rjcted_rply.rj_vers.low; - error->re_vers.high = msg->rjcted_rply.rj_vers.high; - break; - - case RPC_AUTHERROR: - error->re_why = msg->rjcted_rply.rj_why; - break; - - case RPC_PROGVERSMISMATCH: - error->re_vers.low = msg->acpted_rply.ar_vers.low; - error->re_vers.high = msg->acpted_rply.ar_vers.high; - break; - } -} diff --git a/lib/librpc/rpc/svc.c b/lib/librpc/rpc/svc.c deleted file mode 100644 index 1a2cb79664ea..000000000000 --- a/lib/librpc/rpc/svc.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)svc.c 2.4 88/08/11 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc.c,v 1.3 1993/08/26 00:53:37 jtc Exp $"; -#endif - -/* - * svc.c, Server-side remote procedure call interface. - * - * There are two sets of procedures here. The xprt routines are - * for handling transport handles. The svc routines handle the - * list of service routines. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include - -extern int errno; - -#ifdef FD_SETSIZE -static SVCXPRT **xports; -#else -#define NOFILE 32 - -static SVCXPRT *xports[NOFILE]; -#endif /* def FD_SETSIZE */ - -#define NULL_SVC ((struct svc_callout *)0) -#define RQCRED_SIZE 400 /* this size is excessive */ - -/* - * The services list - * Each entry represents a set of procedures (an rpc program). - * The dispatch routine takes request structs and runs the - * apropriate procedure. - */ -static struct svc_callout { - struct svc_callout *sc_next; - u_long sc_prog; - u_long sc_vers; - void (*sc_dispatch)(); -} *svc_head; - -static struct svc_callout *svc_find(); - -/* *************** SVCXPRT related stuff **************** */ - -/* - * Activate a transport handle. - */ -void -xprt_register(xprt) - SVCXPRT *xprt; -{ - register int sock = xprt->xp_sock; - -#ifdef FD_SETSIZE - if (xports == NULL) { - xports = (SVCXPRT **) - mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *)); - } - if (sock < _rpc_dtablesize()) { - xports[sock] = xprt; - FD_SET(sock, &svc_fdset); - } -#else - if (sock < NOFILE) { - xports[sock] = xprt; - svc_fds |= (1 << sock); - } -#endif /* def FD_SETSIZE */ - -} - -/* - * De-activate a transport handle. - */ -void -xprt_unregister(xprt) - SVCXPRT *xprt; -{ - register int sock = xprt->xp_sock; - -#ifdef FD_SETSIZE - if ((sock < _rpc_dtablesize()) && (xports[sock] == xprt)) { - xports[sock] = (SVCXPRT *)0; - FD_CLR(sock, &svc_fdset); - } -#else - if ((sock < NOFILE) && (xports[sock] == xprt)) { - xports[sock] = (SVCXPRT *)0; - svc_fds &= ~(1 << sock); - } -#endif /* def FD_SETSIZE */ -} - - -/* ********************** CALLOUT list related stuff ************* */ - -/* - * Add a service program to the callout list. - * The dispatch routine will be called when a rpc request for this - * program number comes in. - */ -bool_t -svc_register(xprt, prog, vers, dispatch, protocol) - SVCXPRT *xprt; - u_long prog; - u_long vers; - void (*dispatch)(); - int protocol; -{ - struct svc_callout *prev; - register struct svc_callout *s; - - if ((s = svc_find(prog, vers, &prev)) != NULL_SVC) { - if (s->sc_dispatch == dispatch) - goto pmap_it; /* he is registering another xptr */ - return (FALSE); - } - s = (struct svc_callout *)mem_alloc(sizeof(struct svc_callout)); - if (s == (struct svc_callout *)0) { - return (FALSE); - } - s->sc_prog = prog; - s->sc_vers = vers; - s->sc_dispatch = dispatch; - s->sc_next = svc_head; - svc_head = s; -pmap_it: - /* now register the information with the local binder service */ - if (protocol) { - return (pmap_set(prog, vers, protocol, xprt->xp_port)); - } - return (TRUE); -} - -/* - * Remove a service program from the callout list. - */ -void -svc_unregister(prog, vers) - u_long prog; - u_long vers; -{ - struct svc_callout *prev; - register struct svc_callout *s; - - if ((s = svc_find(prog, vers, &prev)) == NULL_SVC) - return; - if (prev == NULL_SVC) { - svc_head = s->sc_next; - } else { - prev->sc_next = s->sc_next; - } - s->sc_next = NULL_SVC; - mem_free((char *) s, (u_int) sizeof(struct svc_callout)); - /* now unregister the information with the local binder service */ - (void)pmap_unset(prog, vers); -} - -/* - * Search the callout list for a program number, return the callout - * struct. - */ -static struct svc_callout * -svc_find(prog, vers, prev) - u_long prog; - u_long vers; - struct svc_callout **prev; -{ - register struct svc_callout *s, *p; - - p = NULL_SVC; - for (s = svc_head; s != NULL_SVC; s = s->sc_next) { - if ((s->sc_prog == prog) && (s->sc_vers == vers)) - goto done; - p = s; - } -done: - *prev = p; - return (s); -} - -/* ******************* REPLY GENERATION ROUTINES ************ */ - -/* - * Send a reply to an rpc request - */ -bool_t -svc_sendreply(xprt, xdr_results, xdr_location) - register SVCXPRT *xprt; - xdrproc_t xdr_results; - caddr_t xdr_location; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = SUCCESS; - rply.acpted_rply.ar_results.where = xdr_location; - rply.acpted_rply.ar_results.proc = xdr_results; - return (SVC_REPLY(xprt, &rply)); -} - -/* - * No procedure error reply - */ -void -svcerr_noproc(xprt) - register SVCXPRT *xprt; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = PROC_UNAVAIL; - SVC_REPLY(xprt, &rply); -} - -/* - * Can't decode args error reply - */ -void -svcerr_decode(xprt) - register SVCXPRT *xprt; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = GARBAGE_ARGS; - SVC_REPLY(xprt, &rply); -} - -/* - * Some system error - */ -void -svcerr_systemerr(xprt) - register SVCXPRT *xprt; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = SYSTEM_ERR; - SVC_REPLY(xprt, &rply); -} - -/* - * Authentication error reply - */ -void -svcerr_auth(xprt, why) - SVCXPRT *xprt; - enum auth_stat why; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_DENIED; - rply.rjcted_rply.rj_stat = AUTH_ERROR; - rply.rjcted_rply.rj_why = why; - SVC_REPLY(xprt, &rply); -} - -/* - * Auth too weak error reply - */ -void -svcerr_weakauth(xprt) - SVCXPRT *xprt; -{ - - svcerr_auth(xprt, AUTH_TOOWEAK); -} - -/* - * Program unavailable error reply - */ -void -svcerr_noprog(xprt) - register SVCXPRT *xprt; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = PROG_UNAVAIL; - SVC_REPLY(xprt, &rply); -} - -/* - * Program version mismatch error reply - */ -void -svcerr_progvers(xprt, low_vers, high_vers) - register SVCXPRT *xprt; - u_long low_vers; - u_long high_vers; -{ - struct rpc_msg rply; - - rply.rm_direction = REPLY; - rply.rm_reply.rp_stat = MSG_ACCEPTED; - rply.acpted_rply.ar_verf = xprt->xp_verf; - rply.acpted_rply.ar_stat = PROG_MISMATCH; - rply.acpted_rply.ar_vers.low = low_vers; - rply.acpted_rply.ar_vers.high = high_vers; - SVC_REPLY(xprt, &rply); -} - -/* ******************* SERVER INPUT STUFF ******************* */ - -/* - * Get server side input from some transport. - * - * Statement of authentication parameters management: - * This function owns and manages all authentication parameters, specifically - * the "raw" parameters (msg.rm_call.cb_cred and msg.rm_call.cb_verf) and - * the "cooked" credentials (rqst->rq_clntcred). - * However, this function does not know the structure of the cooked - * credentials, so it make the following assumptions: - * a) the structure is contiguous (no pointers), and - * b) the cred structure size does not exceed RQCRED_SIZE bytes. - * In all events, all three parameters are freed upon exit from this routine. - * The storage is trivially management on the call stack in user land, but - * is mallocated in kernel land. - */ - -void -svc_getreq(rdfds) - int rdfds; -{ -#ifdef FD_SETSIZE - fd_set readfds; - - FD_ZERO(&readfds); - readfds.fds_bits[0] = rdfds; - svc_getreqset(&readfds); -#else - int readfds = rdfds & svc_fds; - - svc_getreqset(&readfds); -#endif /* def FD_SETSIZE */ -} - -void -svc_getreqset(readfds) -#ifdef FD_SETSIZE - fd_set *readfds; -{ -#else - int *readfds; -{ - int readfds_local = *readfds; -#endif /* def FD_SETSIZE */ - enum xprt_stat stat; - struct rpc_msg msg; - int prog_found; - u_long low_vers; - u_long high_vers; - struct svc_req r; - register SVCXPRT *xprt; - register u_long mask; - register int bit; - register u_long *maskp; - register int setsize; - register int sock; - char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE]; - msg.rm_call.cb_cred.oa_base = cred_area; - msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]); - r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]); - - -#ifdef FD_SETSIZE - setsize = _rpc_dtablesize(); - maskp = (u_long *)readfds->fds_bits; - for (sock = 0; sock < setsize; sock += NFDBITS) { - for (mask = *maskp++; bit = ffs(mask); mask ^= (1 << (bit - 1))) { - /* sock has input waiting */ - xprt = xports[sock + bit - 1]; -#else - for (sock = 0; readfds_local != 0; sock++, readfds_local >>= 1) { - if ((readfds_local & 1) != 0) { - /* sock has input waiting */ - xprt = xports[sock]; -#endif /* def FD_SETSIZE */ - /* now receive msgs from xprtprt (support batch calls) */ - do { - if (SVC_RECV(xprt, &msg)) { - - /* now find the exported program and call it */ - register struct svc_callout *s; - enum auth_stat why; - - r.rq_xprt = xprt; - r.rq_prog = msg.rm_call.cb_prog; - r.rq_vers = msg.rm_call.cb_vers; - r.rq_proc = msg.rm_call.cb_proc; - r.rq_cred = msg.rm_call.cb_cred; - /* first authenticate the message */ - if ((why= _authenticate(&r, &msg)) != AUTH_OK) { - svcerr_auth(xprt, why); - goto call_done; - } - /* now match message with a registered service*/ - prog_found = FALSE; - low_vers = 0 - 1; - high_vers = 0; - for (s = svc_head; s != NULL_SVC; s = s->sc_next) { - if (s->sc_prog == r.rq_prog) { - if (s->sc_vers == r.rq_vers) { - (*s->sc_dispatch)(&r, xprt); - goto call_done; - } /* found correct version */ - prog_found = TRUE; - if (s->sc_vers < low_vers) - low_vers = s->sc_vers; - if (s->sc_vers > high_vers) - high_vers = s->sc_vers; - } /* found correct program */ - } - /* - * if we got here, the program or version - * is not served ... - */ - if (prog_found) - svcerr_progvers(xprt, - low_vers, high_vers); - else - svcerr_noprog(xprt); - /* Fall through to ... */ - } - call_done: - if ((stat = SVC_STAT(xprt)) == XPRT_DIED){ - SVC_DESTROY(xprt); - break; - } - } while (stat == XPRT_MOREREQS); - } - } -} diff --git a/lib/librpc/rpc/svc.h b/lib/librpc/rpc/svc.h deleted file mode 100644 index 3cb07ef3f310..000000000000 --- a/lib/librpc/rpc/svc.h +++ /dev/null @@ -1,280 +0,0 @@ -/* @(#)svc.h 2.2 88/07/29 4.0 RPCSRC; from 1.20 88/02/08 SMI */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * svc.h, Server-side remote procedure call interface. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef __SVC_HEADER__ -#define __SVC_HEADER__ - -/* - * This interface must manage two items concerning remote procedure calling: - * - * 1) An arbitrary number of transport connections upon which rpc requests - * are received. The two most notable transports are TCP and UDP; they are - * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; - * they in turn call xprt_register and xprt_unregister. - * - * 2) An arbitrary number of locally registered services. Services are - * described by the following four data: program number, version number, - * "service dispatch" function, a transport handle, and a boolean that - * indicates whether or not the exported program should be registered with a - * local binder service; if true the program's number and version and the - * port number from the transport handle are registered with the binder. - * These data are registered with the rpc svc system via svc_register. - * - * A service's dispatch function is called whenever an rpc request comes in - * on a transport. The request's program and version numbers must match - * those of the registered service. The dispatch function is passed two - * parameters, struct svc_req * and SVCXPRT *, defined below. - */ - -enum xprt_stat { - XPRT_DIED, - XPRT_MOREREQS, - XPRT_IDLE -}; - -/* - * Server side transport handle - */ -typedef struct { - int xp_sock; - u_short xp_port; /* associated port number */ - struct xp_ops { - bool_t (*xp_recv)(); /* receive incomming requests */ - enum xprt_stat (*xp_stat)(); /* get transport status */ - bool_t (*xp_getargs)(); /* get arguments */ - bool_t (*xp_reply)(); /* send reply */ - bool_t (*xp_freeargs)();/* free mem allocated for args */ - void (*xp_destroy)(); /* destroy this struct */ - } *xp_ops; - int xp_addrlen; /* length of remote address */ - struct sockaddr_in xp_raddr; /* remote address */ - struct opaque_auth xp_verf; /* raw response verifier */ - caddr_t xp_p1; /* private */ - caddr_t xp_p2; /* private */ -} SVCXPRT; - -/* - * Approved way of getting address of caller - */ -#define svc_getcaller(x) (&(x)->xp_raddr) - -/* - * Operations defined on an SVCXPRT handle - * - * SVCXPRT *xprt; - * struct rpc_msg *msg; - * xdrproc_t xargs; - * caddr_t argsp; - */ -#define SVC_RECV(xprt, msg) \ - (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) -#define svc_recv(xprt, msg) \ - (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) - -#define SVC_STAT(xprt) \ - (*(xprt)->xp_ops->xp_stat)(xprt) -#define svc_stat(xprt) \ - (*(xprt)->xp_ops->xp_stat)(xprt) - -#define SVC_GETARGS(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) -#define svc_getargs(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) - -#define SVC_REPLY(xprt, msg) \ - (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) -#define svc_reply(xprt, msg) \ - (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) - -#define SVC_FREEARGS(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) -#define svc_freeargs(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) - -#define SVC_DESTROY(xprt) \ - (*(xprt)->xp_ops->xp_destroy)(xprt) -#define svc_destroy(xprt) \ - (*(xprt)->xp_ops->xp_destroy)(xprt) - - -/* - * Service request - */ -struct svc_req { - u_long rq_prog; /* service program number */ - u_long rq_vers; /* service protocol version */ - u_long rq_proc; /* the desired procedure */ - struct opaque_auth rq_cred; /* raw creds from the wire */ - caddr_t rq_clntcred; /* read only cooked cred */ - SVCXPRT *rq_xprt; /* associated transport */ -}; - - -/* - * Service registration - * - * svc_register(xprt, prog, vers, dispatch, protocol) - * SVCXPRT *xprt; - * u_long prog; - * u_long vers; - * void (*dispatch)(); - * int protocol; /* like TCP or UDP, zero means do not register - */ -extern bool_t svc_register(); - -/* - * Service un-registration - * - * svc_unregister(prog, vers) - * u_long prog; - * u_long vers; - */ -extern void svc_unregister(); - -/* - * Transport registration. - * - * xprt_register(xprt) - * SVCXPRT *xprt; - */ -extern void xprt_register(); - -/* - * Transport un-register - * - * xprt_unregister(xprt) - * SVCXPRT *xprt; - */ -extern void xprt_unregister(); - - - - -/* - * When the service routine is called, it must first check to see if it - * knows about the procedure; if not, it should call svcerr_noproc - * and return. If so, it should deserialize its arguments via - * SVC_GETARGS (defined above). If the deserialization does not work, - * svcerr_decode should be called followed by a return. Successful - * decoding of the arguments should be followed the execution of the - * procedure's code and a call to svc_sendreply. - * - * Also, if the service refuses to execute the procedure due to too- - * weak authentication parameters, svcerr_weakauth should be called. - * Note: do not confuse access-control failure with weak authentication! - * - * NB: In pure implementations of rpc, the caller always waits for a reply - * msg. This message is sent when svc_sendreply is called. - * Therefore pure service implementations should always call - * svc_sendreply even if the function logically returns void; use - * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows - * for the abuse of pure rpc via batched calling or pipelining. In the - * case of a batched call, svc_sendreply should NOT be called since - * this would send a return message, which is what batching tries to avoid. - * It is the service/protocol writer's responsibility to know which calls are - * batched and which are not. Warning: responding to batch calls may - * deadlock the caller and server processes! - */ - -extern bool_t svc_sendreply(); -extern void svcerr_decode(); -extern void svcerr_weakauth(); -extern void svcerr_noproc(); -extern void svcerr_progvers(); -extern void svcerr_auth(); -extern void svcerr_noprog(); -extern void svcerr_systemerr(); - -/* - * Lowest level dispatching -OR- who owns this process anyway. - * Somebody has to wait for incoming requests and then call the correct - * service routine. The routine svc_run does infinite waiting; i.e., - * svc_run never returns. - * Since another (co-existant) package may wish to selectively wait for - * incoming calls or other events outside of the rpc architecture, the - * routine svc_getreq is provided. It must be passed readfds, the - * "in-place" results of a select system call (see select, section 2). - */ - -/* - * Global keeper of rpc service descriptors in use - * dynamic; must be inspected before each call to select - */ -#ifdef FD_SETSIZE -extern fd_set svc_fdset; -#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ -#else -extern int svc_fds; -#endif /* def FD_SETSIZE */ - -/* - * a small program implemented by the svc_rpc implementation itself; - * also see clnt.h for protocol numbers. - */ -extern void rpctest_service(); - -extern void svc_getreq(); -extern void svc_getreqset(); /* takes fdset instead of int */ -extern void svc_run(); /* never returns */ - -/* - * Socket to use on svcxxx_create call to get default socket - */ -#define RPC_ANYSOCK -1 - -/* - * These are the existing service side transport implementations - */ - -/* - * Memory based rpc for testing and timing. - */ -extern SVCXPRT *svcraw_create(); - -/* - * Udp based rpc. - */ -extern SVCXPRT *svcudp_create(); -extern SVCXPRT *svcudp_bufcreate(); - -/* - * Tcp based rpc. - */ -extern SVCXPRT *svctcp_create(); - - - -#endif !__SVC_HEADER__ diff --git a/lib/librpc/rpc/svc_auth.c b/lib/librpc/rpc/svc_auth.c deleted file mode 100644 index 833dd9f06f65..000000000000 --- a/lib/librpc/rpc/svc_auth.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)svc_auth.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc_auth.c,v 1.3 1993/08/26 00:53:38 jtc Exp $"; -#endif - -/* - * svc_auth_nodes.c, Server-side rpc authenticator interface, - * *WITHOUT* DES authentication. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include - -/* - * svcauthsw is the bdevsw of server side authentication. - * - * Server side authenticators are called from authenticate by - * using the client auth struct flavor field to index into svcauthsw. - * The server auth flavors must implement a routine that looks - * like: - * - * enum auth_stat - * flavorx_auth(rqst, msg) - * register struct svc_req *rqst; - * register struct rpc_msg *msg; - * - */ - -enum auth_stat _svcauth_null(); /* no authentication */ -enum auth_stat _svcauth_unix(); /* unix style (uid, gids) */ -enum auth_stat _svcauth_short(); /* short hand unix style */ - -static struct { - enum auth_stat (*authenticator)(); -} svcauthsw[] = { - _svcauth_null, /* AUTH_NULL */ - _svcauth_unix, /* AUTH_UNIX */ - _svcauth_short, /* AUTH_SHORT */ -}; -#define AUTH_MAX 2 /* HIGHEST AUTH NUMBER */ - - -/* - * The call rpc message, msg has been obtained from the wire. The msg contains - * the raw form of credentials and verifiers. authenticate returns AUTH_OK - * if the msg is successfully authenticated. If AUTH_OK then the routine also - * does the following things: - * set rqst->rq_xprt->verf to the appropriate response verifier; - * sets rqst->rq_client_cred to the "cooked" form of the credentials. - * - * NB: rqst->rq_cxprt->verf must be pre-alloctaed; - * its length is set appropriately. - * - * The caller still owns and is responsible for msg->u.cmb.cred and - * msg->u.cmb.verf. The authentication system retains ownership of - * rqst->rq_client_cred, the cooked credentials. - * - * There is an assumption that any flavour less than AUTH_NULL is - * invalid. - */ -enum auth_stat -_authenticate(rqst, msg) - register struct svc_req *rqst; - struct rpc_msg *msg; -{ - register int cred_flavor; - - rqst->rq_cred = msg->rm_call.cb_cred; - rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor; - rqst->rq_xprt->xp_verf.oa_length = 0; - cred_flavor = rqst->rq_cred.oa_flavor; - if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL)) { - return ((*(svcauthsw[cred_flavor].authenticator))(rqst, msg)); - } - - return (AUTH_REJECTEDCRED); -} - -enum auth_stat -_svcauth_null(/*rqst, msg*/) - /*struct svc_req *rqst; - struct rpc_msg *msg;*/ -{ - - return (AUTH_OK); -} diff --git a/lib/librpc/rpc/svc_auth.h b/lib/librpc/rpc/svc_auth.h deleted file mode 100644 index a36a01aba8eb..000000000000 --- a/lib/librpc/rpc/svc_auth.h +++ /dev/null @@ -1,42 +0,0 @@ -/* @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)svc_auth.h 1.6 86/07/16 SMI */ - -/* - * svc_auth.h, Service side of rpc authentication. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - - -/* - * Server side authenticator - */ -extern enum auth_stat _authenticate(); diff --git a/lib/librpc/rpc/svc_auth_unix.c b/lib/librpc/rpc/svc_auth_unix.c deleted file mode 100644 index c2f7066e9d51..000000000000 --- a/lib/librpc/rpc/svc_auth_unix.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc_auth_unix.c,v 1.3 1993/08/26 00:53:39 jtc Exp $"; -#endif - -/* - * svc_auth_unix.c - * Handles UNIX flavor authentication parameters on the service side of rpc. - * There are two svc auth implementations here: AUTH_UNIX and AUTH_SHORT. - * _svcauth_unix does full blown unix style uid,gid+gids auth, - * _svcauth_short uses a shorthand auth to index into a cache of longhand auths. - * Note: the shorthand has been gutted for efficiency. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include - -/* - * Unix longhand authenticator - */ -enum auth_stat -_svcauth_unix(rqst, msg) - register struct svc_req *rqst; - register struct rpc_msg *msg; -{ - register enum auth_stat stat; - XDR xdrs; - register struct authunix_parms *aup; - register long *buf; - struct area { - struct authunix_parms area_aup; - char area_machname[MAX_MACHINE_NAME+1]; - int area_gids[NGRPS]; - } *area; - u_int auth_len; - int str_len, gid_len; - register int i; - - area = (struct area *) rqst->rq_clntcred; - aup = &area->area_aup; - aup->aup_machname = area->area_machname; - aup->aup_gids = area->area_gids; - auth_len = (u_int)msg->rm_call.cb_cred.oa_length; - xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE); - buf = XDR_INLINE(&xdrs, auth_len); - if (buf != NULL) { - aup->aup_time = IXDR_GET_LONG(buf); - str_len = IXDR_GET_U_LONG(buf); - if (str_len > MAX_MACHINE_NAME) { - stat = AUTH_BADCRED; - goto done; - } - bcopy((caddr_t)buf, aup->aup_machname, (u_int)str_len); - aup->aup_machname[str_len] = 0; - str_len = RNDUP(str_len); - buf += str_len / sizeof (long); - aup->aup_uid = IXDR_GET_LONG(buf); - aup->aup_gid = IXDR_GET_LONG(buf); - gid_len = IXDR_GET_U_LONG(buf); - if (gid_len > NGRPS) { - stat = AUTH_BADCRED; - goto done; - } - aup->aup_len = gid_len; - for (i = 0; i < gid_len; i++) { - aup->aup_gids[i] = IXDR_GET_LONG(buf); - } - /* - * five is the smallest unix credentials structure - - * timestamp, hostname len (0), uid, gid, and gids len (0). - */ - if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) { - (void) printf("bad auth_len gid %d str %d auth %d\n", - gid_len, str_len, auth_len); - stat = AUTH_BADCRED; - goto done; - } - } else if (! xdr_authunix_parms(&xdrs, aup)) { - xdrs.x_op = XDR_FREE; - (void)xdr_authunix_parms(&xdrs, aup); - stat = AUTH_BADCRED; - goto done; - } - rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL; - rqst->rq_xprt->xp_verf.oa_length = 0; - stat = AUTH_OK; -done: - XDR_DESTROY(&xdrs); - return (stat); -} - - -/* - * Shorthand unix authenticator - * Looks up longhand in a cache. - */ -/*ARGSUSED*/ -enum auth_stat -_svcauth_short(rqst, msg) - struct svc_req *rqst; - struct rpc_msg *msg; -{ - return (AUTH_REJECTEDCRED); -} diff --git a/lib/librpc/rpc/svc_raw.c b/lib/librpc/rpc/svc_raw.c deleted file mode 100644 index 62a45133bf71..000000000000 --- a/lib/librpc/rpc/svc_raw.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)svc_raw.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc_raw.c,v 1.3 1993/08/26 00:53:41 jtc Exp $"; -#endif - -/* - * svc_raw.c, This a toy for simple testing and timing. - * Interface to create an rpc client and server in the same UNIX process. - * This lets us similate rpc and get rpc (round trip) overhead, without - * any interference from the kernal. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include - - -/* - * This is the "network" that we will be moving data over - */ -static struct svcraw_private { - char _raw_buf[UDPMSGSIZE]; - SVCXPRT server; - XDR xdr_stream; - char verf_body[MAX_AUTH_BYTES]; -} *svcraw_private; - -static bool_t svcraw_recv(); -static enum xprt_stat svcraw_stat(); -static bool_t svcraw_getargs(); -static bool_t svcraw_reply(); -static bool_t svcraw_freeargs(); -static void svcraw_destroy(); - -static struct xp_ops server_ops = { - svcraw_recv, - svcraw_stat, - svcraw_getargs, - svcraw_reply, - svcraw_freeargs, - svcraw_destroy -}; - -SVCXPRT * -svcraw_create() -{ - register struct svcraw_private *srp = svcraw_private; - - if (srp == 0) { - srp = (struct svcraw_private *)calloc(1, sizeof (*srp)); - if (srp == 0) - return (0); - } - srp->server.xp_sock = 0; - srp->server.xp_port = 0; - srp->server.xp_ops = &server_ops; - srp->server.xp_verf.oa_base = srp->verf_body; - xdrmem_create(&srp->xdr_stream, srp->_raw_buf, UDPMSGSIZE, XDR_FREE); - return (&srp->server); -} - -static enum xprt_stat -svcraw_stat() -{ - - return (XPRT_IDLE); -} - -static bool_t -svcraw_recv(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - register struct svcraw_private *srp = svcraw_private; - register XDR *xdrs; - - if (srp == 0) - return (0); - xdrs = &srp->xdr_stream; - xdrs->x_op = XDR_DECODE; - XDR_SETPOS(xdrs, 0); - if (! xdr_callmsg(xdrs, msg)) - return (FALSE); - return (TRUE); -} - -static bool_t -svcraw_reply(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; -{ - register struct svcraw_private *srp = svcraw_private; - register XDR *xdrs; - - if (srp == 0) - return (FALSE); - xdrs = &srp->xdr_stream; - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, 0); - if (! xdr_replymsg(xdrs, msg)) - return (FALSE); - (void)XDR_GETPOS(xdrs); /* called just for overhead */ - return (TRUE); -} - -static bool_t -svcraw_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - register struct svcraw_private *srp = svcraw_private; - - if (srp == 0) - return (FALSE); - return ((*xdr_args)(&srp->xdr_stream, args_ptr)); -} - -static bool_t -svcraw_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - register struct svcraw_private *srp = svcraw_private; - register XDR *xdrs; - - if (srp == 0) - return (FALSE); - xdrs = &srp->xdr_stream; - xdrs->x_op = XDR_FREE; - return ((*xdr_args)(xdrs, args_ptr)); -} - -static void -svcraw_destroy() -{ -} diff --git a/lib/librpc/rpc/svc_run.c b/lib/librpc/rpc/svc_run.c deleted file mode 100644 index 160a307c1276..000000000000 --- a/lib/librpc/rpc/svc_run.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc_run.c,v 1.3 1993/08/26 00:53:42 jtc Exp $"; -#endif - -/* - * This is the rpc server side idle loop - * Wait for input, call server program. - */ -#include -#include - -void -svc_run() -{ -#ifdef FD_SETSIZE - fd_set readfds; -#else - int readfds; -#endif /* def FD_SETSIZE */ - extern int errno; - - for (;;) { -#ifdef FD_SETSIZE - readfds = svc_fdset; -#else - readfds = svc_fds; -#endif /* def FD_SETSIZE */ - switch (select(_rpc_dtablesize(), &readfds, (int *)0, (int *)0, - (struct timeval *)0)) { - case -1: - if (errno == EINTR) { - continue; - } - perror("svc_run: - select failed"); - return; - case 0: - continue; - default: - svc_getreqset(&readfds); - } - } -} diff --git a/lib/librpc/rpc/svc_simple.c b/lib/librpc/rpc/svc_simple.c deleted file mode 100644 index 25585177be89..000000000000 --- a/lib/librpc/rpc/svc_simple.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)svc_simple.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc_simple.c,v 1.3 1993/08/26 00:53:43 jtc Exp $"; -#endif - -/* - * svc_simple.c - * Simplified front end to rpc. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include - -static struct proglst { - char *(*p_progname)(); - int p_prognum; - int p_procnum; - xdrproc_t p_inproc, p_outproc; - struct proglst *p_nxt; -} *proglst; -static void universal(); -static SVCXPRT *transp; -struct proglst *pl; - -registerrpc(prognum, versnum, procnum, progname, inproc, outproc) - char *(*progname)(); - xdrproc_t inproc, outproc; -{ - - if (procnum == NULLPROC) { - (void) fprintf(stderr, - "can't reassign procedure number %d\n", NULLPROC); - return (-1); - } - if (transp == 0) { - transp = svcudp_create(RPC_ANYSOCK); - if (transp == NULL) { - (void) fprintf(stderr, "couldn't create an rpc server\n"); - return (-1); - } - } - (void) pmap_unset((u_long)prognum, (u_long)versnum); - if (!svc_register(transp, (u_long)prognum, (u_long)versnum, - universal, IPPROTO_UDP)) { - (void) fprintf(stderr, "couldn't register prog %d vers %d\n", - prognum, versnum); - return (-1); - } - pl = (struct proglst *)malloc(sizeof(struct proglst)); - if (pl == NULL) { - (void) fprintf(stderr, "registerrpc: out of memory\n"); - return (-1); - } - pl->p_progname = progname; - pl->p_prognum = prognum; - pl->p_procnum = procnum; - pl->p_inproc = inproc; - pl->p_outproc = outproc; - pl->p_nxt = proglst; - proglst = pl; - return (0); -} - -static void -universal(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; -{ - int prog, proc; - char *outdata; - char xdrbuf[UDPMSGSIZE]; - struct proglst *pl; - - /* - * enforce "procnum 0 is echo" convention - */ - if (rqstp->rq_proc == NULLPROC) { - if (svc_sendreply(transp, xdr_void, (char *)NULL) == FALSE) { - (void) fprintf(stderr, "xxx\n"); - exit(1); - } - return; - } - prog = rqstp->rq_prog; - proc = rqstp->rq_proc; - for (pl = proglst; pl != NULL; pl = pl->p_nxt) - if (pl->p_prognum == prog && pl->p_procnum == proc) { - /* decode arguments into a CLEAN buffer */ - bzero(xdrbuf, sizeof(xdrbuf)); /* required ! */ - if (!svc_getargs(transp, pl->p_inproc, xdrbuf)) { - svcerr_decode(transp); - return; - } - outdata = (*(pl->p_progname))(xdrbuf); - if (outdata == NULL && pl->p_outproc != xdr_void) - /* there was an error */ - return; - if (!svc_sendreply(transp, pl->p_outproc, outdata)) { - (void) fprintf(stderr, - "trouble replying to prog %d\n", - pl->p_prognum); - exit(1); - } - /* free the decoded arguments */ - (void)svc_freeargs(transp, pl->p_inproc, xdrbuf); - return; - } - (void) fprintf(stderr, "never registered prog %d\n", prog); - exit(1); -} - diff --git a/lib/librpc/rpc/svc_tcp.c b/lib/librpc/rpc/svc_tcp.c deleted file mode 100644 index df1c68c23da1..000000000000 --- a/lib/librpc/rpc/svc_tcp.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc_tcp.c,v 1.3 1993/08/26 00:53:44 jtc Exp $"; -#endif - -/* - * svc_tcp.c, Server side for TCP/IP based RPC. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * Actually implements two flavors of transporter - - * a tcp rendezvouser (a listner and connection establisher) - * and a record/tcp stream. - */ - -#include -#include -#include -#include -extern bool_t abort(); -extern errno; - -/* - * Ops vector for TCP/IP based rpc service handle - */ -static bool_t svctcp_recv(); -static enum xprt_stat svctcp_stat(); -static bool_t svctcp_getargs(); -static bool_t svctcp_reply(); -static bool_t svctcp_freeargs(); -static void svctcp_destroy(); - -static struct xp_ops svctcp_op = { - svctcp_recv, - svctcp_stat, - svctcp_getargs, - svctcp_reply, - svctcp_freeargs, - svctcp_destroy -}; - -/* - * Ops vector for TCP/IP rendezvous handler - */ -static bool_t rendezvous_request(); -static enum xprt_stat rendezvous_stat(); - -static struct xp_ops svctcp_rendezvous_op = { - rendezvous_request, - rendezvous_stat, - abort, - abort, - abort, - svctcp_destroy -}; - -static int readtcp(), writetcp(); -static SVCXPRT *makefd_xprt(); - -struct tcp_rendezvous { /* kept in xprt->xp_p1 */ - u_int sendsize; - u_int recvsize; -}; - -struct tcp_conn { /* kept in xprt->xp_p1 */ - enum xprt_stat strm_stat; - u_long x_id; - XDR xdrs; - char verf_body[MAX_AUTH_BYTES]; -}; - -/* - * Usage: - * xprt = svctcp_create(sock, send_buf_size, recv_buf_size); - * - * Creates, registers, and returns a (rpc) tcp based transporter. - * Once *xprt is initialized, it is registered as a transporter - * see (svc.h, xprt_register). This routine returns - * a NULL if a problem occurred. - * - * If sock<0 then a socket is created, else sock is used. - * If the socket, sock is not bound to a port then svctcp_create - * binds it to an arbitrary port. The routine then starts a tcp - * listener on the socket's associated port. In any (successful) case, - * xprt->xp_sock is the registered socket number and xprt->xp_port is the - * associated port number. - * - * Since tcp streams do buffered io similar to stdio, the caller can specify - * how big the send and receive buffers are via the second and third parms; - * 0 => use the system default. - */ -SVCXPRT * -svctcp_create(sock, sendsize, recvsize) - register int sock; - u_int sendsize; - u_int recvsize; -{ - bool_t madesock = FALSE; - register SVCXPRT *xprt; - register struct tcp_rendezvous *r; - struct sockaddr_in addr; - int len = sizeof(struct sockaddr_in); - - if (sock == RPC_ANYSOCK) { - if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - perror("svctcp_.c - udp socket creation problem"); - return ((SVCXPRT *)NULL); - } - madesock = TRUE; - } - bzero((char *)&addr, sizeof (addr)); - addr.sin_family = AF_INET; - if (bindresvport(sock, &addr)) { - addr.sin_port = 0; - (void)bind(sock, (struct sockaddr *)&addr, len); - } - if ((getsockname(sock, (struct sockaddr *)&addr, &len) != 0) || - (listen(sock, 2) != 0)) { - perror("svctcp_.c - cannot getsockname or listen"); - if (madesock) - (void)close(sock); - return ((SVCXPRT *)NULL); - } - r = (struct tcp_rendezvous *)mem_alloc(sizeof(*r)); - if (r == NULL) { - (void) fprintf(stderr, "svctcp_create: out of memory\n"); - return (NULL); - } - r->sendsize = sendsize; - r->recvsize = recvsize; - xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); - if (xprt == NULL) { - (void) fprintf(stderr, "svctcp_create: out of memory\n"); - return (NULL); - } - xprt->xp_p2 = NULL; - xprt->xp_p1 = (caddr_t)r; - xprt->xp_verf = _null_auth; - xprt->xp_ops = &svctcp_rendezvous_op; - xprt->xp_port = ntohs(addr.sin_port); - xprt->xp_sock = sock; - xprt_register(xprt); - return (xprt); -} - -/* - * Like svtcp_create(), except the routine takes any *open* UNIX file - * descriptor as its first input. - */ -SVCXPRT * -svcfd_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - - return (makefd_xprt(fd, sendsize, recvsize)); -} - -static SVCXPRT * -makefd_xprt(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; -{ - register SVCXPRT *xprt; - register struct tcp_conn *cd; - - xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); - if (xprt == (SVCXPRT *)NULL) { - (void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n"); - goto done; - } - cd = (struct tcp_conn *)mem_alloc(sizeof(struct tcp_conn)); - if (cd == (struct tcp_conn *)NULL) { - (void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n"); - mem_free((char *) xprt, sizeof(SVCXPRT)); - xprt = (SVCXPRT *)NULL; - goto done; - } - cd->strm_stat = XPRT_IDLE; - xdrrec_create(&(cd->xdrs), sendsize, recvsize, - (caddr_t)xprt, readtcp, writetcp); - xprt->xp_p2 = NULL; - xprt->xp_p1 = (caddr_t)cd; - xprt->xp_verf.oa_base = cd->verf_body; - xprt->xp_addrlen = 0; - xprt->xp_ops = &svctcp_op; /* truely deals with calls */ - xprt->xp_port = 0; /* this is a connection, not a rendezvouser */ - xprt->xp_sock = fd; - xprt_register(xprt); - done: - return (xprt); -} - -static bool_t -rendezvous_request(xprt) - register SVCXPRT *xprt; -{ - int sock; - struct tcp_rendezvous *r; - struct sockaddr_in addr; - int len; - - r = (struct tcp_rendezvous *)xprt->xp_p1; - again: - len = sizeof(struct sockaddr_in); - if ((sock = accept(xprt->xp_sock, (struct sockaddr *)&addr, - &len)) < 0) { - if (errno == EINTR) - goto again; - return (FALSE); - } - /* - * make a new transporter (re-uses xprt) - */ - xprt = makefd_xprt(sock, r->sendsize, r->recvsize); - xprt->xp_raddr = addr; - xprt->xp_addrlen = len; - return (FALSE); /* there is never an rpc msg to be processed */ -} - -static enum xprt_stat -rendezvous_stat() -{ - - return (XPRT_IDLE); -} - -static void -svctcp_destroy(xprt) - register SVCXPRT *xprt; -{ - register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1; - - xprt_unregister(xprt); - (void)close(xprt->xp_sock); - if (xprt->xp_port != 0) { - /* a rendezvouser socket */ - xprt->xp_port = 0; - } else { - /* an actual connection socket */ - XDR_DESTROY(&(cd->xdrs)); - } - mem_free((caddr_t)cd, sizeof(struct tcp_conn)); - mem_free((caddr_t)xprt, sizeof(SVCXPRT)); -} - -/* - * All read operations timeout after 35 seconds. - * A timeout is fatal for the connection. - */ -static struct timeval wait_per_try = { 35, 0 }; - -/* - * reads data from the tcp conection. - * any error is fatal and the connection is closed. - * (And a read of zero bytes is a half closed stream => error.) - */ -static int -readtcp(xprt, buf, len) - register SVCXPRT *xprt; - caddr_t buf; - register int len; -{ - register int sock = xprt->xp_sock; -#ifdef FD_SETSIZE - fd_set mask; - fd_set readfds; - - FD_ZERO(&mask); - FD_SET(sock, &mask); -#else - register int mask = 1 << sock; - int readfds; -#endif /* def FD_SETSIZE */ - do { - readfds = mask; - if (select(_rpc_dtablesize(), &readfds, (int*)NULL, (int*)NULL, - &wait_per_try) <= 0) { - if (errno == EINTR) { - continue; - } - goto fatal_err; - } -#ifdef FD_SETSIZE - } while (!FD_ISSET(sock, &readfds)); -#else - } while (readfds != mask); -#endif /* def FD_SETSIZE */ - if ((len = read(sock, buf, len)) > 0) { - return (len); - } -fatal_err: - ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED; - return (-1); -} - -/* - * writes data to the tcp connection. - * Any error is fatal and the connection is closed. - */ -static int -writetcp(xprt, buf, len) - register SVCXPRT *xprt; - caddr_t buf; - int len; -{ - register int i, cnt; - - for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = write(xprt->xp_sock, buf, cnt)) < 0) { - ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = - XPRT_DIED; - return (-1); - } - } - return (len); -} - -static enum xprt_stat -svctcp_stat(xprt) - SVCXPRT *xprt; -{ - register struct tcp_conn *cd = - (struct tcp_conn *)(xprt->xp_p1); - - if (cd->strm_stat == XPRT_DIED) - return (XPRT_DIED); - if (! xdrrec_eof(&(cd->xdrs))) - return (XPRT_MOREREQS); - return (XPRT_IDLE); -} - -static bool_t -svctcp_recv(xprt, msg) - SVCXPRT *xprt; - register struct rpc_msg *msg; -{ - register struct tcp_conn *cd = - (struct tcp_conn *)(xprt->xp_p1); - register XDR *xdrs = &(cd->xdrs); - - xdrs->x_op = XDR_DECODE; - (void)xdrrec_skiprecord(xdrs); - if (xdr_callmsg(xdrs, msg)) { - cd->x_id = msg->rm_xid; - return (TRUE); - } - return (FALSE); -} - -static bool_t -svctcp_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - - return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs), args_ptr)); -} - -static bool_t -svctcp_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - register XDR *xdrs = - &(((struct tcp_conn *)(xprt->xp_p1))->xdrs); - - xdrs->x_op = XDR_FREE; - return ((*xdr_args)(xdrs, args_ptr)); -} - -static bool_t -svctcp_reply(xprt, msg) - SVCXPRT *xprt; - register struct rpc_msg *msg; -{ - register struct tcp_conn *cd = - (struct tcp_conn *)(xprt->xp_p1); - register XDR *xdrs = &(cd->xdrs); - register bool_t stat; - - xdrs->x_op = XDR_ENCODE; - msg->rm_xid = cd->x_id; - stat = xdr_replymsg(xdrs, msg); - (void)xdrrec_endofrecord(xdrs, TRUE); - return (stat); -} diff --git a/lib/librpc/rpc/svc_udp.c b/lib/librpc/rpc/svc_udp.c deleted file mode 100644 index 826e638a18de..000000000000 --- a/lib/librpc/rpc/svc_udp.c +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)svc_udp.c 2.2 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc_udp.c,v 1.4 1993/08/26 00:53:45 jtc Exp $"; -#endif - -/* - * svc_udp.c, - * Server side for UDP/IP based RPC. (Does some caching in the hopes of - * achieving execute-at-most-once semantics.) - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#include -#include -#include -#include -#include - - -#define rpc_buffer(xprt) ((xprt)->xp_p1) -#define MAX(a, b) ((a > b) ? a : b) - -static bool_t svcudp_recv(); -static bool_t svcudp_reply(); -static enum xprt_stat svcudp_stat(); -static bool_t svcudp_getargs(); -static bool_t svcudp_freeargs(); -static void svcudp_destroy(); - -static struct xp_ops svcudp_op = { - svcudp_recv, - svcudp_stat, - svcudp_getargs, - svcudp_reply, - svcudp_freeargs, - svcudp_destroy -}; - -extern int errno; - -/* - * kept in xprt->xp_p2 - */ -struct svcudp_data { - u_int su_iosz; /* byte size of send.recv buffer */ - u_long su_xid; /* transaction id */ - XDR su_xdrs; /* XDR handle */ - char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */ - char * su_cache; /* cached data, NULL if no cache */ -}; -#define su_data(xprt) ((struct svcudp_data *)(xprt->xp_p2)) - -/* - * Usage: - * xprt = svcudp_create(sock); - * - * If sock<0 then a socket is created, else sock is used. - * If the socket, sock is not bound to a port then svcudp_create - * binds it to an arbitrary port. In any (successful) case, - * xprt->xp_sock is the registered socket number and xprt->xp_port is the - * associated port number. - * Once *xprt is initialized, it is registered as a transporter; - * see (svc.h, xprt_register). - * The routines returns NULL if a problem occurred. - */ -SVCXPRT * -svcudp_bufcreate(sock, sendsz, recvsz) - register int sock; - u_int sendsz, recvsz; -{ - bool_t madesock = FALSE; - register SVCXPRT *xprt; - register struct svcudp_data *su; - struct sockaddr_in addr; - int len = sizeof(struct sockaddr_in); - - if (sock == RPC_ANYSOCK) { - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - perror("svcudp_create: socket creation problem"); - return ((SVCXPRT *)NULL); - } - madesock = TRUE; - } - bzero((char *)&addr, sizeof (addr)); - addr.sin_family = AF_INET; - if (bindresvport(sock, &addr)) { - addr.sin_port = 0; - (void)bind(sock, (struct sockaddr *)&addr, len); - } - if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) { - perror("svcudp_create - cannot getsockname"); - if (madesock) - (void)close(sock); - return ((SVCXPRT *)NULL); - } - xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); - if (xprt == NULL) { - (void)fprintf(stderr, "svcudp_create: out of memory\n"); - return (NULL); - } - su = (struct svcudp_data *)mem_alloc(sizeof(*su)); - if (su == NULL) { - (void)fprintf(stderr, "svcudp_create: out of memory\n"); - return (NULL); - } - su->su_iosz = ((MAX(sendsz, recvsz) + 3) / 4) * 4; - if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL) { - (void)fprintf(stderr, "svcudp_create: out of memory\n"); - return (NULL); - } - xdrmem_create( - &(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_DECODE); - su->su_cache = NULL; - xprt->xp_p2 = (caddr_t)su; - xprt->xp_verf.oa_base = su->su_verfbody; - xprt->xp_ops = &svcudp_op; - xprt->xp_port = ntohs(addr.sin_port); - xprt->xp_sock = sock; - xprt_register(xprt); - return (xprt); -} - -SVCXPRT * -svcudp_create(sock) - int sock; -{ - - return(svcudp_bufcreate(sock, UDPMSGSIZE, UDPMSGSIZE)); -} - -static enum xprt_stat -svcudp_stat(xprt) - SVCXPRT *xprt; -{ - - return (XPRT_IDLE); -} - -static bool_t -svcudp_recv(xprt, msg) - register SVCXPRT *xprt; - struct rpc_msg *msg; -{ - register struct svcudp_data *su = su_data(xprt); - register XDR *xdrs = &(su->su_xdrs); - register int rlen; - char *reply; - u_long replylen; - static int cache_get(); - - again: - xprt->xp_addrlen = sizeof(struct sockaddr_in); - rlen = recvfrom(xprt->xp_sock, rpc_buffer(xprt), (int) su->su_iosz, - 0, (struct sockaddr *)&(xprt->xp_raddr), &(xprt->xp_addrlen)); - if (rlen == -1 && errno == EINTR) - goto again; - if (rlen < 4*sizeof(u_long)) - return (FALSE); - xdrs->x_op = XDR_DECODE; - XDR_SETPOS(xdrs, 0); - if (! xdr_callmsg(xdrs, msg)) - return (FALSE); - su->su_xid = msg->rm_xid; - if (su->su_cache != NULL) { - if (cache_get(xprt, msg, &reply, &replylen)) { - (void) sendto(xprt->xp_sock, reply, (int) replylen, 0, - (struct sockaddr *) &xprt->xp_raddr, xprt->xp_addrlen); - return (TRUE); - } - } - return (TRUE); -} - -static bool_t -svcudp_reply(xprt, msg) - register SVCXPRT *xprt; - struct rpc_msg *msg; -{ - register struct svcudp_data *su = su_data(xprt); - register XDR *xdrs = &(su->su_xdrs); - register int slen; - register bool_t stat = FALSE; - static void cache_set(); - - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, 0); - msg->rm_xid = su->su_xid; - if (xdr_replymsg(xdrs, msg)) { - slen = (int)XDR_GETPOS(xdrs); - if (sendto(xprt->xp_sock, rpc_buffer(xprt), slen, 0, - (struct sockaddr *)&(xprt->xp_raddr), xprt->xp_addrlen) - == slen) { - stat = TRUE; - if (su->su_cache && slen >= 0) { - cache_set(xprt, (u_long) slen); - } - } - } - return (stat); -} - -static bool_t -svcudp_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - - return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr)); -} - -static bool_t -svcudp_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - caddr_t args_ptr; -{ - register XDR *xdrs = &(su_data(xprt)->su_xdrs); - - xdrs->x_op = XDR_FREE; - return ((*xdr_args)(xdrs, args_ptr)); -} - -static void -svcudp_destroy(xprt) - register SVCXPRT *xprt; -{ - register struct svcudp_data *su = su_data(xprt); - - xprt_unregister(xprt); - (void)close(xprt->xp_sock); - XDR_DESTROY(&(su->su_xdrs)); - mem_free(rpc_buffer(xprt), su->su_iosz); - mem_free((caddr_t)su, sizeof(struct svcudp_data)); - mem_free((caddr_t)xprt, sizeof(SVCXPRT)); -} - - -/***********this could be a separate file*********************/ - -/* - * Fifo cache for udp server - * Copies pointers to reply buffers into fifo cache - * Buffers are sent again if retransmissions are detected. - */ - -#define SPARSENESS 4 /* 75% sparse */ - -#define CACHE_PERROR(msg) \ - (void) fprintf(stderr,"%s\n", msg) - -#define ALLOC(type, size) \ - (type *) mem_alloc((unsigned) (sizeof(type) * (size))) - -#define BZERO(addr, type, size) \ - bzero((char *) addr, sizeof(type) * (int) (size)) - -/* - * An entry in the cache - */ -typedef struct cache_node *cache_ptr; -struct cache_node { - /* - * Index into cache is xid, proc, vers, prog and address - */ - u_long cache_xid; - u_long cache_proc; - u_long cache_vers; - u_long cache_prog; - struct sockaddr_in cache_addr; - /* - * The cached reply and length - */ - char * cache_reply; - u_long cache_replylen; - /* - * Next node on the list, if there is a collision - */ - cache_ptr cache_next; -}; - - - -/* - * The entire cache - */ -struct udp_cache { - u_long uc_size; /* size of cache */ - cache_ptr *uc_entries; /* hash table of entries in cache */ - cache_ptr *uc_fifo; /* fifo list of entries in cache */ - u_long uc_nextvictim; /* points to next victim in fifo list */ - u_long uc_prog; /* saved program number */ - u_long uc_vers; /* saved version number */ - u_long uc_proc; /* saved procedure number */ - struct sockaddr_in uc_addr; /* saved caller's address */ -}; - - -/* - * the hashing function - */ -#define CACHE_LOC(transp, xid) \ - (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size)) - - -/* - * Enable use of the cache. - * Note: there is no disable. - */ -svcudp_enablecache(transp, size) - SVCXPRT *transp; - u_long size; -{ - struct svcudp_data *su = su_data(transp); - struct udp_cache *uc; - - if (su->su_cache != NULL) { - CACHE_PERROR("enablecache: cache already enabled"); - return(0); - } - uc = ALLOC(struct udp_cache, 1); - if (uc == NULL) { - CACHE_PERROR("enablecache: could not allocate cache"); - return(0); - } - uc->uc_size = size; - uc->uc_nextvictim = 0; - uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS); - if (uc->uc_entries == NULL) { - CACHE_PERROR("enablecache: could not allocate cache data"); - return(0); - } - BZERO(uc->uc_entries, cache_ptr, size * SPARSENESS); - uc->uc_fifo = ALLOC(cache_ptr, size); - if (uc->uc_fifo == NULL) { - CACHE_PERROR("enablecache: could not allocate cache fifo"); - return(0); - } - BZERO(uc->uc_fifo, cache_ptr, size); - su->su_cache = (char *) uc; - return(1); -} - - -/* - * Set an entry in the cache - */ -static void -cache_set(xprt, replylen) - SVCXPRT *xprt; - u_long replylen; -{ - register cache_ptr victim; - register cache_ptr *vicp; - register struct svcudp_data *su = su_data(xprt); - struct udp_cache *uc = (struct udp_cache *) su->su_cache; - u_int loc; - char *newbuf; - - /* - * Find space for the new entry, either by - * reusing an old entry, or by mallocing a new one - */ - victim = uc->uc_fifo[uc->uc_nextvictim]; - if (victim != NULL) { - loc = CACHE_LOC(xprt, victim->cache_xid); - for (vicp = &uc->uc_entries[loc]; - *vicp != NULL && *vicp != victim; - vicp = &(*vicp)->cache_next) - ; - if (*vicp == NULL) { - CACHE_PERROR("cache_set: victim not found"); - return; - } - *vicp = victim->cache_next; /* remote from cache */ - newbuf = victim->cache_reply; - } else { - victim = ALLOC(struct cache_node, 1); - if (victim == NULL) { - CACHE_PERROR("cache_set: victim alloc failed"); - return; - } - newbuf = mem_alloc(su->su_iosz); - if (newbuf == NULL) { - CACHE_PERROR("cache_set: could not allocate new rpc_buffer"); - return; - } - } - - /* - * Store it away - */ - victim->cache_replylen = replylen; - victim->cache_reply = rpc_buffer(xprt); - rpc_buffer(xprt) = newbuf; - xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_ENCODE); - victim->cache_xid = su->su_xid; - victim->cache_proc = uc->uc_proc; - victim->cache_vers = uc->uc_vers; - victim->cache_prog = uc->uc_prog; - victim->cache_addr = uc->uc_addr; - loc = CACHE_LOC(xprt, victim->cache_xid); - victim->cache_next = uc->uc_entries[loc]; - uc->uc_entries[loc] = victim; - uc->uc_fifo[uc->uc_nextvictim++] = victim; - uc->uc_nextvictim %= uc->uc_size; -} - -/* - * Try to get an entry from the cache - * return 1 if found, 0 if not found - */ -static -cache_get(xprt, msg, replyp, replylenp) - SVCXPRT *xprt; - struct rpc_msg *msg; - char **replyp; - u_long *replylenp; -{ - u_int loc; - register cache_ptr ent; - register struct svcudp_data *su = su_data(xprt); - register struct udp_cache *uc = (struct udp_cache *) su->su_cache; - -# define EQADDR(a1, a2) (bcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0) - - loc = CACHE_LOC(xprt, su->su_xid); - for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) { - if (ent->cache_xid == su->su_xid && - ent->cache_proc == uc->uc_proc && - ent->cache_vers == uc->uc_vers && - ent->cache_prog == uc->uc_prog && - EQADDR(ent->cache_addr, uc->uc_addr)) { - *replyp = ent->cache_reply; - *replylenp = ent->cache_replylen; - return(1); - } - } - /* - * Failed to find entry - * Remember a few things so we can do a set later - */ - uc->uc_proc = msg->rm_call.cb_proc; - uc->uc_vers = msg->rm_call.cb_vers; - uc->uc_prog = msg->rm_call.cb_prog; - uc->uc_addr = xprt->xp_raddr; - return(0); -} - diff --git a/lib/librpc/rpc/types.h b/lib/librpc/rpc/types.h deleted file mode 100644 index 06d22bf8006a..000000000000 --- a/lib/librpc/rpc/types.h +++ /dev/null @@ -1,63 +0,0 @@ -/* @(#)types.h 2.3 88/08/15 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)types.h 1.18 87/07/24 SMI */ - -/* - * Rpc additions to - */ -#ifndef __TYPES_RPC_HEADER__ -#define __TYPES_RPC_HEADER__ - -#define bool_t int -#define enum_t int -#define FALSE (0) -#define TRUE (1) -#define __dontcare__ -1 -#ifndef NULL -# define NULL 0 -#endif - -void *malloc(); -#define mem_alloc(bsize) malloc(bsize) -#define mem_free(ptr, bsize) free(ptr) - -#ifndef makedev /* ie, we haven't already included it */ -#include -#endif -#include - -#ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK (u_long)0x7F000001 -#endif -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -#endif /* ndef __TYPES_RPC_HEADER__ */ diff --git a/lib/librpc/rpc/xdr.c b/lib/librpc/rpc/xdr.c deleted file mode 100644 index 736e621935c2..000000000000 --- a/lib/librpc/rpc/xdr.c +++ /dev/null @@ -1,578 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)xdr.c 1.35 87/08/12";*/ -/*static char *sccsid = "from: @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr.c,v 1.3 1993/08/26 00:53:46 jtc Exp $"; -#endif - -/* - * xdr.c, Generic XDR routines implementation. - * - * Copyright (C) 1986, Sun Microsystems, Inc. - * - * These are the "generic" xdr routines used to serialize and de-serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include - -#include -#include - -/* - * constants specific to the xdr "protocol" - */ -#define XDR_FALSE ((long) 0) -#define XDR_TRUE ((long) 1) -#define LASTUNSIGNED ((u_int) 0-1) - -/* - * for unit alignment - */ -static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; - -/* - * Free a data structure using XDR - * Not a filter, but a convenient utility nonetheless - */ -void -xdr_free(proc, objp) - xdrproc_t proc; - char *objp; -{ - XDR x; - - x.x_op = XDR_FREE; - (*proc)(&x, objp); -} - -/* - * XDR nothing - */ -bool_t -xdr_void(/* xdrs, addr */) - /* XDR *xdrs; */ - /* caddr_t addr; */ -{ - - return (TRUE); -} - -/* - * XDR integers - */ -bool_t -xdr_int(xdrs, ip) - XDR *xdrs; - int *ip; -{ - -#ifdef lint - (void) (xdr_short(xdrs, (short *)ip)); - return (xdr_long(xdrs, (long *)ip)); -#else - if (sizeof (int) == sizeof (long)) { - return (xdr_long(xdrs, (long *)ip)); - } else { - return (xdr_short(xdrs, (short *)ip)); - } -#endif -} - -/* - * XDR unsigned integers - */ -bool_t -xdr_u_int(xdrs, up) - XDR *xdrs; - u_int *up; -{ - -#ifdef lint - (void) (xdr_short(xdrs, (short *)up)); - return (xdr_u_long(xdrs, (u_long *)up)); -#else - if (sizeof (u_int) == sizeof (u_long)) { - return (xdr_u_long(xdrs, (u_long *)up)); - } else { - return (xdr_short(xdrs, (short *)up)); - } -#endif -} - -/* - * XDR long integers - * same as xdr_u_long - open coded to save a proc call! - */ -bool_t -xdr_long(xdrs, lp) - register XDR *xdrs; - long *lp; -{ - - if (xdrs->x_op == XDR_ENCODE) - return (XDR_PUTLONG(xdrs, lp)); - - if (xdrs->x_op == XDR_DECODE) - return (XDR_GETLONG(xdrs, lp)); - - if (xdrs->x_op == XDR_FREE) - return (TRUE); - - return (FALSE); -} - -/* - * XDR unsigned long integers - * same as xdr_long - open coded to save a proc call! - */ -bool_t -xdr_u_long(xdrs, ulp) - register XDR *xdrs; - u_long *ulp; -{ - - if (xdrs->x_op == XDR_DECODE) - return (XDR_GETLONG(xdrs, (long *)ulp)); - if (xdrs->x_op == XDR_ENCODE) - return (XDR_PUTLONG(xdrs, (long *)ulp)); - if (xdrs->x_op == XDR_FREE) - return (TRUE); - return (FALSE); -} - -/* - * XDR short integers - */ -bool_t -xdr_short(xdrs, sp) - register XDR *xdrs; - short *sp; -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long) *sp; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *sp = (short) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -/* - * XDR unsigned short integers - */ -bool_t -xdr_u_short(xdrs, usp) - register XDR *xdrs; - u_short *usp; -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long) *usp; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *usp = (u_short) l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - - -/* - * XDR a char - */ -bool_t -xdr_char(xdrs, cp) - XDR *xdrs; - char *cp; -{ - int i; - - i = (*cp); - if (!xdr_int(xdrs, &i)) { - return (FALSE); - } - *cp = i; - return (TRUE); -} - -/* - * XDR an unsigned char - */ -bool_t -xdr_u_char(xdrs, cp) - XDR *xdrs; - char *cp; -{ - u_int u; - - u = (*cp); - if (!xdr_u_int(xdrs, &u)) { - return (FALSE); - } - *cp = u; - return (TRUE); -} - -/* - * XDR booleans - */ -bool_t -xdr_bool(xdrs, bp) - register XDR *xdrs; - bool_t *bp; -{ - long lb; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - lb = *bp ? XDR_TRUE : XDR_FALSE; - return (XDR_PUTLONG(xdrs, &lb)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &lb)) { - return (FALSE); - } - *bp = (lb == XDR_FALSE) ? FALSE : TRUE; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -/* - * XDR enumerations - */ -bool_t -xdr_enum(xdrs, ep) - XDR *xdrs; - enum_t *ep; -{ -#ifndef lint - enum sizecheck { SIZEVAL }; /* used to find the size of an enum */ - - /* - * enums are treated as ints - */ - if (sizeof (enum sizecheck) == sizeof (long)) { - return (xdr_long(xdrs, (long *)ep)); - } else if (sizeof (enum sizecheck) == sizeof (short)) { - return (xdr_short(xdrs, (short *)ep)); - } else { - return (FALSE); - } -#else - (void) (xdr_short(xdrs, (short *)ep)); - return (xdr_long(xdrs, (long *)ep)); -#endif -} - -/* - * XDR opaque data - * Allows the specification of a fixed size sequence of opaque bytes. - * cp points to the opaque object and cnt gives the byte length. - */ -bool_t -xdr_opaque(xdrs, cp, cnt) - register XDR *xdrs; - caddr_t cp; - register u_int cnt; -{ - register u_int rndup; - static crud[BYTES_PER_XDR_UNIT]; - - /* - * if no data we are done - */ - if (cnt == 0) - return (TRUE); - - /* - * round byte count to full xdr units - */ - rndup = cnt % BYTES_PER_XDR_UNIT; - if (rndup > 0) - rndup = BYTES_PER_XDR_UNIT - rndup; - - if (xdrs->x_op == XDR_DECODE) { - if (!XDR_GETBYTES(xdrs, cp, cnt)) { - return (FALSE); - } - if (rndup == 0) - return (TRUE); - return (XDR_GETBYTES(xdrs, crud, rndup)); - } - - if (xdrs->x_op == XDR_ENCODE) { - if (!XDR_PUTBYTES(xdrs, cp, cnt)) { - return (FALSE); - } - if (rndup == 0) - return (TRUE); - return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); - } - - if (xdrs->x_op == XDR_FREE) { - return (TRUE); - } - - return (FALSE); -} - -/* - * XDR counted bytes - * *cpp is a pointer to the bytes, *sizep is the count. - * If *cpp is NULL maxsize bytes are allocated - */ -bool_t -xdr_bytes(xdrs, cpp, sizep, maxsize) - register XDR *xdrs; - char **cpp; - register u_int *sizep; - u_int maxsize; -{ - register char *sp = *cpp; /* sp is the actual string pointer */ - register u_int nodesize; - - /* - * first deal with the length since xdr bytes are counted - */ - if (! xdr_u_int(xdrs, sizep)) { - return (FALSE); - } - nodesize = *sizep; - if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) { - return (FALSE); - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) { - - case XDR_DECODE: - if (nodesize == 0) { - return (TRUE); - } - if (sp == NULL) { - *cpp = sp = (char *)mem_alloc(nodesize); - } - if (sp == NULL) { - (void) fprintf(stderr, "xdr_bytes: out of memory\n"); - return (FALSE); - } - /* fall into ... */ - - case XDR_ENCODE: - return (xdr_opaque(xdrs, sp, nodesize)); - - case XDR_FREE: - if (sp != NULL) { - mem_free(sp, nodesize); - *cpp = NULL; - } - return (TRUE); - } - return (FALSE); -} - -/* - * Implemented here due to commonality of the object. - */ -bool_t -xdr_netobj(xdrs, np) - XDR *xdrs; - struct netobj *np; -{ - - return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ)); -} - -/* - * XDR a descriminated union - * Support routine for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * an entry with a null procedure pointer. The routine gets - * the discriminant value and then searches the array of xdrdiscrims - * looking for that value. It calls the procedure given in the xdrdiscrim - * to handle the discriminant. If there is no specific routine a default - * routine may be called. - * If there is no specific or default routine an error is returned. - */ -bool_t -xdr_union(xdrs, dscmp, unp, choices, dfault) - register XDR *xdrs; - enum_t *dscmp; /* enum to decide which arm to work on */ - char *unp; /* the union itself */ - struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ - xdrproc_t dfault; /* default xdr routine */ -{ - register enum_t dscm; - - /* - * we deal with the discriminator; it's an enum - */ - if (! xdr_enum(xdrs, dscmp)) { - return (FALSE); - } - dscm = *dscmp; - - /* - * search choices for a value that matches the discriminator. - * if we find one, execute the xdr routine for that value. - */ - for (; choices->proc != NULL_xdrproc_t; choices++) { - if (choices->value == dscm) - return ((*(choices->proc))(xdrs, unp, LASTUNSIGNED)); - } - - /* - * no match - execute the default xdr routine if there is one - */ - return ((dfault == NULL_xdrproc_t) ? FALSE : - (*dfault)(xdrs, unp, LASTUNSIGNED)); -} - - -/* - * Non-portable xdr primitives. - * Care should be taken when moving these routines to new architectures. - */ - - -/* - * XDR null terminated ASCII strings - * xdr_string deals with "C strings" - arrays of bytes that are - * terminated by a NULL character. The parameter cpp references a - * pointer to storage; If the pointer is null, then the necessary - * storage is allocated. The last parameter is the max allowed length - * of the string as specified by a protocol. - */ -bool_t -xdr_string(xdrs, cpp, maxsize) - register XDR *xdrs; - char **cpp; - u_int maxsize; -{ - register char *sp = *cpp; /* sp is the actual string pointer */ - u_int size; - u_int nodesize; - - /* - * first deal with the length since xdr strings are counted-strings - */ - switch (xdrs->x_op) { - case XDR_FREE: - if (sp == NULL) { - return(TRUE); /* already free */ - } - /* fall through... */ - case XDR_ENCODE: - size = strlen(sp); - break; - } - if (! xdr_u_int(xdrs, &size)) { - return (FALSE); - } - if (size > maxsize) { - return (FALSE); - } - nodesize = size + 1; - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) { - - case XDR_DECODE: - if (nodesize == 0) { - return (TRUE); - } - if (sp == NULL) - *cpp = sp = (char *)mem_alloc(nodesize); - if (sp == NULL) { - (void) fprintf(stderr, "xdr_string: out of memory\n"); - return (FALSE); - } - sp[size] = 0; - /* fall into ... */ - - case XDR_ENCODE: - return (xdr_opaque(xdrs, sp, size)); - - case XDR_FREE: - mem_free(sp, nodesize); - *cpp = NULL; - return (TRUE); - } - return (FALSE); -} - -/* - * Wrapper for xdr_string that can be called directly from - * routines like clnt_call - */ -bool_t -xdr_wrapstring(xdrs, cpp) - XDR *xdrs; - char **cpp; -{ - if (xdr_string(xdrs, cpp, LASTUNSIGNED)) { - return (TRUE); - } - return (FALSE); -} diff --git a/lib/librpc/rpc/xdr.h b/lib/librpc/rpc/xdr.h deleted file mode 100644 index 6cd3e6fe0397..000000000000 --- a/lib/librpc/rpc/xdr.h +++ /dev/null @@ -1,270 +0,0 @@ -/* @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC */ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* @(#)xdr.h 1.19 87/04/22 SMI */ - -/* - * xdr.h, External Data Representation Serialization Routines. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef __XDR_HEADER__ -#define __XDR_HEADER__ - -/* - * XDR provides a conventional way for converting between C data - * types and an external bit-string representation. Library supplied - * routines provide for the conversion on built-in C data types. These - * routines and utility routines defined here are used to help implement - * a type encode/decode routine for each user-defined type. - * - * Each data type provides a single procedure which takes two arguments: - * - * bool_t - * xdrproc(xdrs, argresp) - * XDR *xdrs; - * *argresp; - * - * xdrs is an instance of a XDR handle, to which or from which the data - * type is to be converted. argresp is a pointer to the structure to be - * converted. The XDR handle contains an operation field which indicates - * which of the operations (ENCODE, DECODE * or FREE) is to be performed. - * - * XDR_DECODE may allocate space if the pointer argresp is null. This - * data can be freed with the XDR_FREE operation. - * - * We write only one procedure per data type to make it easy - * to keep the encode and decode procedures for a data type consistent. - * In many cases the same code performs all operations on a user defined type, - * because all the hard work is done in the component type routines. - * decode as a series of calls on the nested data types. - */ - -/* - * Xdr operations. XDR_ENCODE causes the type to be encoded into the - * stream. XDR_DECODE causes the type to be extracted from the stream. - * XDR_FREE can be used to release the space allocated by an XDR_DECODE - * request. - */ -enum xdr_op { - XDR_ENCODE=0, - XDR_DECODE=1, - XDR_FREE=2 -}; - -/* - * This is the number of bytes per unit of external data. - */ -#define BYTES_PER_XDR_UNIT (4) -#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ - * BYTES_PER_XDR_UNIT) - -/* - * A xdrproc_t exists for each data type which is to be encoded or decoded. - * - * The second argument to the xdrproc_t is a pointer to an opaque pointer. - * The opaque pointer generally points to a structure of the data type - * to be decoded. If this pointer is 0, then the type routines should - * allocate dynamic storage of the appropriate size and return it. - * bool_t (*xdrproc_t)(XDR *, caddr_t *); - */ -typedef bool_t (*xdrproc_t)(); - -/* - * The XDR handle. - * Contains operation which is being applied to the stream, - * an operations vector for the paticular implementation (e.g. see xdr_mem.c), - * and two private fields for the use of the particular impelementation. - */ -typedef struct { - enum xdr_op x_op; /* operation; fast additional param */ - struct xdr_ops { - bool_t (*x_getlong)(); /* get a long from underlying stream */ - bool_t (*x_putlong)(); /* put a long to " */ - bool_t (*x_getbytes)();/* get some bytes from " */ - bool_t (*x_putbytes)();/* put some bytes to " */ - u_int (*x_getpostn)();/* returns bytes off from beginning */ - bool_t (*x_setpostn)();/* lets you reposition the stream */ - long * (*x_inline)(); /* buf quick ptr to buffered data */ - void (*x_destroy)(); /* free privates of this xdr_stream */ - } *x_ops; - caddr_t x_public; /* users' data */ - caddr_t x_private; /* pointer to private data */ - caddr_t x_base; /* private used for position info */ - int x_handy; /* extra private word */ -} XDR; - -/* - * Operations defined on a XDR handle - * - * XDR *xdrs; - * long *longp; - * caddr_t addr; - * u_int len; - * u_int pos; - */ -#define XDR_GETLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) -#define xdr_getlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) - -#define XDR_PUTLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) -#define xdr_putlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) - -#define XDR_GETBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) -#define xdr_getbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) - -#define XDR_PUTBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) -#define xdr_putbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) - -#define XDR_GETPOS(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) -#define xdr_getpos(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) - -#define XDR_SETPOS(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) -#define xdr_setpos(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) - -#define XDR_INLINE(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) -#define xdr_inline(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) - -#define XDR_DESTROY(xdrs) \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs) -#define xdr_destroy(xdrs) \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs) - -/* - * Support struct for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * a entry with a null procedure pointer. The xdr_union routine gets - * the discriminant value and then searches the array of structures - * for a matching value. If a match is found the associated xdr routine - * is called to handle that part of the union. If there is - * no match, then a default routine may be called. - * If there is no match and no default routine it is an error. - */ -#define NULL_xdrproc_t ((xdrproc_t)0) -struct xdr_discrim { - int value; - xdrproc_t proc; -}; - -/* - * In-line routines for fast encode/decode of primitve data types. - * Caveat emptor: these use single memory cycles to get the - * data from the underlying buffer, and will fail to operate - * properly if the data is not aligned. The standard way to use these - * is to say: - * if ((buf = XDR_INLINE(xdrs, count)) == NULL) - * return (FALSE); - * <<< macro calls >>> - * where ``count'' is the number of bytes of data occupied - * by the primitive data types. - * - * N.B. and frozen for all time: each data type here uses 4 bytes - * of external representation. - */ -#define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++)) -#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((u_long)v)) - -#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) -#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) -#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) - -#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) - -/* - * These are the "generic" xdr routines. - */ -extern bool_t xdr_void(); -extern bool_t xdr_int(); -extern bool_t xdr_u_int(); -extern bool_t xdr_long(); -extern bool_t xdr_u_long(); -extern bool_t xdr_short(); -extern bool_t xdr_u_short(); -extern bool_t xdr_bool(); -extern bool_t xdr_enum(); -extern bool_t xdr_array(); -extern bool_t xdr_bytes(); -extern bool_t xdr_opaque(); -extern bool_t xdr_string(); -extern bool_t xdr_union(); -extern bool_t xdr_char(); -extern bool_t xdr_u_char(); -extern bool_t xdr_vector(); -extern bool_t xdr_float(); -extern bool_t xdr_double(); -extern bool_t xdr_reference(); -extern bool_t xdr_pointer(); -extern bool_t xdr_wrapstring(); - -/* - * Common opaque bytes objects used by many rpc protocols; - * declared here due to commonality. - */ -#define MAX_NETOBJ_SZ 1024 -struct netobj { - u_int n_len; - char *n_bytes; -}; -typedef struct netobj netobj; -extern bool_t xdr_netobj(); - -/* - * These are the public routines for the various implementations of - * xdr streams. - */ -extern void xdrmem_create(); /* XDR using memory buffers */ -extern void xdrstdio_create(); /* XDR using stdio library */ -extern void xdrrec_create(); /* XDR pseudo records for tcp */ -extern bool_t xdrrec_endofrecord(); /* make end of xdr record */ -extern bool_t xdrrec_skiprecord(); /* move to beginning of next record */ -extern bool_t xdrrec_eof(); /* true if no more input */ - -#endif !__XDR_HEADER__ diff --git a/lib/librpc/rpc/xdr_array.c b/lib/librpc/rpc/xdr_array.c deleted file mode 100644 index 0e90d8fc710c..000000000000 --- a/lib/librpc/rpc/xdr_array.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr_array.c,v 1.4 1993/08/26 00:53:47 jtc Exp $"; -#endif - -/* - * xdr_array.c, Generic XDR routines impelmentation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "non-trivial" xdr primitives used to serialize and de-serialize - * arrays. See xdr.h for more info on the interface to xdr. - */ - -#include -#include -#include -#include - -#define LASTUNSIGNED ((u_int)0-1) - - -/* - * XDR an array of arbitrary elements - * *addrp is a pointer to the array, *sizep is the number of elements. - * If addrp is NULL (*sizep * elsize) bytes are allocated. - * elsize is the size (in bytes) of each element, and elproc is the - * xdr procedure to call to handle each element of the array. - */ -bool_t -xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) - register XDR *xdrs; - caddr_t *addrp; /* array pointer */ - u_int *sizep; /* number of elements */ - u_int maxsize; /* max numberof elements */ - u_int elsize; /* size in bytes of each element */ - xdrproc_t elproc; /* xdr routine to handle each element */ -{ - register u_int i; - register caddr_t target = *addrp; - register u_int c; /* the actual element count */ - register bool_t stat = TRUE; - register u_int nodesize; - - /* like strings, arrays are really counted arrays */ - if (! xdr_u_int(xdrs, sizep)) { - return (FALSE); - } - c = *sizep; - if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) { - return (FALSE); - } - nodesize = c * elsize; - - /* - * if we are deserializing, we may need to allocate an array. - * We also save time by checking for a null array if we are freeing. - */ - if (target == NULL) - switch (xdrs->x_op) { - case XDR_DECODE: - if (c == 0) - return (TRUE); - *addrp = target = mem_alloc(nodesize); - if (target == NULL) { - (void) fprintf(stderr, - "xdr_array: out of memory\n"); - return (FALSE); - } - bzero(target, nodesize); - break; - - case XDR_FREE: - return (TRUE); - } - - /* - * now we xdr each element of array - */ - for (i = 0; (i < c) && stat; i++) { - stat = (*elproc)(xdrs, target, LASTUNSIGNED); - target += elsize; - } - - /* - * the array may need freeing - */ - if (xdrs->x_op == XDR_FREE) { - mem_free(*addrp, nodesize); - *addrp = NULL; - } - return (stat); -} - -/* - * xdr_vector(): - * - * XDR a fixed length array. Unlike variable-length arrays, - * the storage of fixed length arrays is static and unfreeable. - * > basep: base of the array - * > size: size of the array - * > elemsize: size of each element - * > xdr_elem: routine to XDR each element - */ -bool_t -xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem) - register XDR *xdrs; - register char *basep; - register u_int nelem; - register u_int elemsize; - register xdrproc_t xdr_elem; -{ - register u_int i; - register char *elptr; - - elptr = basep; - for (i = 0; i < nelem; i++) { - if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) { - return(FALSE); - } - elptr += elemsize; - } - return(TRUE); -} - diff --git a/lib/librpc/rpc/xdr_float.c b/lib/librpc/rpc/xdr_float.c deleted file mode 100644 index 71dc31145b0d..000000000000 --- a/lib/librpc/rpc/xdr_float.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr_float.c,v 1.6 1993/08/26 00:53:49 jtc Exp $"; -#endif - -/* - * xdr_float.c, Generic XDR routines impelmentation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "floating point" xdr routines used to (de)serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include -#include -#include -#include -#include - -/* - * NB: Not portable. - * This routine works on Suns (Sky / 68000's), i386's, MIPS, NS32k and Vaxen. - */ - -#if defined(mc68000)||defined(sparc)||defined(i386)||defined(mips)||defined(ns32000) -#define IEEEFP -#endif - -#ifdef vax - -/* What IEEE single precision floating point looks like on a Vax */ -struct ieee_single { - unsigned int mantissa: 23; - unsigned int exp : 8; - unsigned int sign : 1; -}; - -/* Vax single precision floating point */ -struct vax_single { - unsigned int mantissa1 : 7; - unsigned int exp : 8; - unsigned int sign : 1; - unsigned int mantissa2 : 16; -}; - -#define VAX_SNG_BIAS 0x81 -#define IEEE_SNG_BIAS 0x7f - -static struct sgl_limits { - struct vax_single s; - struct ieee_single ieee; -} sgl_limits[2] = { - {{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */ - { 0x0, 0xff, 0x0 }}, /* Max IEEE */ - {{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */ - { 0x0, 0x0, 0x0 }} /* Min IEEE */ -}; -#endif /* vax */ - -bool_t -xdr_float(xdrs, fp) - register XDR *xdrs; - register float *fp; -{ -#ifndef IEEEFP - struct ieee_single is; - struct vax_single vs, *vsp; - struct sgl_limits *lim; - int i; -#endif - switch (xdrs->x_op) { - - case XDR_ENCODE: -#ifdef IEEEFP - return (XDR_PUTLONG(xdrs, (long *)fp)); -#else - vs = *((struct vax_single *)fp); - for (i = 0, lim = sgl_limits; - i < sizeof(sgl_limits)/sizeof(struct sgl_limits); - i++, lim++) { - if ((vs.mantissa2 == lim->s.mantissa2) && - (vs.exp == lim->s.exp) && - (vs.mantissa1 == lim->s.mantissa1)) { - is = lim->ieee; - goto shipit; - } - } - is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; - is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2; - shipit: - is.sign = vs.sign; - return (XDR_PUTLONG(xdrs, (long *)&is)); -#endif - - case XDR_DECODE: -#ifdef IEEEFP - return (XDR_GETLONG(xdrs, (long *)fp)); -#else - vsp = (struct vax_single *)fp; - if (!XDR_GETLONG(xdrs, (long *)&is)) - return (FALSE); - for (i = 0, lim = sgl_limits; - i < sizeof(sgl_limits)/sizeof(struct sgl_limits); - i++, lim++) { - if ((is.exp == lim->ieee.exp) && - (is.mantissa == lim->ieee.mantissa)) { - *vsp = lim->s; - goto doneit; - } - } - vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; - vsp->mantissa2 = is.mantissa; - vsp->mantissa1 = (is.mantissa >> 16); - doneit: - vsp->sign = is.sign; - return (TRUE); -#endif - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -/* - * This routine works on Suns (Sky / 68000's), i386's, MIPS and Vaxen. - */ - -#ifdef vax -/* What IEEE double precision floating point looks like on a Vax */ -struct ieee_double { - unsigned int mantissa1 : 20; - unsigned int exp : 11; - unsigned int sign : 1; - unsigned int mantissa2 : 32; -}; - -/* Vax double precision floating point */ -struct vax_double { - unsigned int mantissa1 : 7; - unsigned int exp : 8; - unsigned int sign : 1; - unsigned int mantissa2 : 16; - unsigned int mantissa3 : 16; - unsigned int mantissa4 : 16; -}; - -#define VAX_DBL_BIAS 0x81 -#define IEEE_DBL_BIAS 0x3ff -#define MASK(nbits) ((1 << nbits) - 1) - -static struct dbl_limits { - struct vax_double d; - struct ieee_double ieee; -} dbl_limits[2] = { - {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */ - { 0x0, 0x7ff, 0x0, 0x0 }}, /* Max IEEE */ - {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */ - { 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */ -}; - -#endif /* vax */ - - -bool_t -xdr_double(xdrs, dp) - register XDR *xdrs; - double *dp; -{ - register long *lp; -#ifndef IEEEFP - struct ieee_double id; - struct vax_double vd; - register struct dbl_limits *lim; - int i; -#endif - - switch (xdrs->x_op) { - - case XDR_ENCODE: -#ifdef IEEEFP - lp = (long *)dp; -#if BYTE_ORDER == BIG_ENDIAN - return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp)); -#else - return (XDR_PUTLONG(xdrs, lp+1) && XDR_PUTLONG(xdrs, lp)); -#endif -#else - vd = *((struct vax_double *)dp); - for (i = 0, lim = dbl_limits; - i < sizeof(dbl_limits)/sizeof(struct dbl_limits); - i++, lim++) { - if ((vd.mantissa4 == lim->d.mantissa4) && - (vd.mantissa3 == lim->d.mantissa3) && - (vd.mantissa2 == lim->d.mantissa2) && - (vd.mantissa1 == lim->d.mantissa1) && - (vd.exp == lim->d.exp)) { - id = lim->ieee; - goto shipit; - } - } - id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS; - id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3); - id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) | - (vd.mantissa3 << 13) | - ((vd.mantissa4 >> 3) & MASK(13)); - shipit: - id.sign = vd.sign; - lp = (long *)&id; - return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp)); -#endif - - case XDR_DECODE: -#ifdef IEEEFP - lp = (long *)dp; -#if BYTE_ORDER == BIG_ENDIAN - return (XDR_GETLONG(xdrs, lp++) && XDR_GETLONG(xdrs, lp)); -#else - return (XDR_GETLONG(xdrs, lp+1) && XDR_GETLONG(xdrs, lp)); -#endif -#else - lp = (long *)&id; - if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp)) - return (FALSE); - for (i = 0, lim = dbl_limits; - i < sizeof(dbl_limits)/sizeof(struct dbl_limits); - i++, lim++) { - if ((id.mantissa2 == lim->ieee.mantissa2) && - (id.mantissa1 == lim->ieee.mantissa1) && - (id.exp == lim->ieee.exp)) { - vd = lim->d; - goto doneit; - } - } - vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; - vd.mantissa1 = (id.mantissa1 >> 13); - vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) | - (id.mantissa2 >> 29); - vd.mantissa3 = (id.mantissa2 >> 13); - vd.mantissa4 = (id.mantissa2 << 3); - doneit: - vd.sign = id.sign; - *dp = *((double *)&vd); - return (TRUE); -#endif - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} diff --git a/lib/librpc/rpc/xdr_mem.c b/lib/librpc/rpc/xdr_mem.c deleted file mode 100644 index 9c8376aba5fe..000000000000 --- a/lib/librpc/rpc/xdr_mem.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr_mem.c,v 1.3 1993/08/26 00:53:50 jtc Exp $"; -#endif - -/* - * xdr_mem.h, XDR implementation using memory buffers. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * If you have some data to be interpreted as external data representation - * or to be converted to external data representation in a memory buffer, - * then this is the package for you. - * - */ - - -#include -#include -#include - -static bool_t xdrmem_getlong(); -static bool_t xdrmem_putlong(); -static bool_t xdrmem_getbytes(); -static bool_t xdrmem_putbytes(); -static u_int xdrmem_getpos(); -static bool_t xdrmem_setpos(); -static long * xdrmem_inline(); -static void xdrmem_destroy(); - -static struct xdr_ops xdrmem_ops = { - xdrmem_getlong, - xdrmem_putlong, - xdrmem_getbytes, - xdrmem_putbytes, - xdrmem_getpos, - xdrmem_setpos, - xdrmem_inline, - xdrmem_destroy -}; - -/* - * The procedure xdrmem_create initializes a stream descriptor for a - * memory buffer. - */ -void -xdrmem_create(xdrs, addr, size, op) - register XDR *xdrs; - caddr_t addr; - u_int size; - enum xdr_op op; -{ - - xdrs->x_op = op; - xdrs->x_ops = &xdrmem_ops; - xdrs->x_private = xdrs->x_base = addr; - xdrs->x_handy = size; -} - -static void -xdrmem_destroy(/*xdrs*/) - /*XDR *xdrs;*/ -{ -} - -static bool_t -xdrmem_getlong(xdrs, lp) - register XDR *xdrs; - long *lp; -{ - - if ((xdrs->x_handy -= sizeof(long)) < 0) - return (FALSE); - *lp = (long)ntohl((u_long)(*((long *)(xdrs->x_private)))); - xdrs->x_private += sizeof(long); - return (TRUE); -} - -static bool_t -xdrmem_putlong(xdrs, lp) - register XDR *xdrs; - long *lp; -{ - - if ((xdrs->x_handy -= sizeof(long)) < 0) - return (FALSE); - *(long *)xdrs->x_private = (long)htonl((u_long)(*lp)); - xdrs->x_private += sizeof(long); - return (TRUE); -} - -static bool_t -xdrmem_getbytes(xdrs, addr, len) - register XDR *xdrs; - caddr_t addr; - register u_int len; -{ - - if ((xdrs->x_handy -= len) < 0) - return (FALSE); - bcopy(xdrs->x_private, addr, len); - xdrs->x_private += len; - return (TRUE); -} - -static bool_t -xdrmem_putbytes(xdrs, addr, len) - register XDR *xdrs; - caddr_t addr; - register u_int len; -{ - - if ((xdrs->x_handy -= len) < 0) - return (FALSE); - bcopy(addr, xdrs->x_private, len); - xdrs->x_private += len; - return (TRUE); -} - -static u_int -xdrmem_getpos(xdrs) - register XDR *xdrs; -{ - - return ((u_int)xdrs->x_private - (u_int)xdrs->x_base); -} - -static bool_t -xdrmem_setpos(xdrs, pos) - register XDR *xdrs; - u_int pos; -{ - register caddr_t newaddr = xdrs->x_base + pos; - register caddr_t lastaddr = xdrs->x_private + xdrs->x_handy; - - if ((long)newaddr > (long)lastaddr) - return (FALSE); - xdrs->x_private = newaddr; - xdrs->x_handy = (int)lastaddr - (int)newaddr; - return (TRUE); -} - -static long * -xdrmem_inline(xdrs, len) - register XDR *xdrs; - int len; -{ - long *buf = 0; - - if (xdrs->x_handy >= len) { - xdrs->x_handy -= len; - buf = (long *) xdrs->x_private; - xdrs->x_private += len; - } - return (buf); -} diff --git a/lib/librpc/rpc/xdr_rec.c b/lib/librpc/rpc/xdr_rec.c deleted file mode 100644 index 057c6cc51b4b..000000000000 --- a/lib/librpc/rpc/xdr_rec.c +++ /dev/null @@ -1,586 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr_rec.c,v 1.4 1993/08/26 00:53:51 jtc Exp $"; -#endif - -/* - * xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking" - * layer above tcp (for rpc's use). - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These routines interface XDRSTREAMS to a tcp/ip connection. - * There is a record marking layer between the xdr stream - * and the tcp transport level. A record is composed on one or more - * record fragments. A record fragment is a thirty-two bit header followed - * by n bytes of data, where n is contained in the header. The header - * is represented as a htonl(u_long). Thegh order bit encodes - * whether or not the fragment is the last fragment of the record - * (1 => fragment is last, 0 => more fragments to follow. - * The other 31 bits encode the byte length of the fragment. - */ - -#include -#include -#include -#include -#include - -extern long lseek(); - -static u_int fix_buf_size(); -static bool_t flush_out(); -static bool_t get_input_bytes(); -static bool_t set_input_fragment(); -static bool_t skip_input_bytes(); - -static bool_t xdrrec_getlong(); -static bool_t xdrrec_putlong(); -static bool_t xdrrec_getbytes(); -static bool_t xdrrec_putbytes(); -static u_int xdrrec_getpos(); -static bool_t xdrrec_setpos(); -static long * xdrrec_inline(); -static void xdrrec_destroy(); - -static struct xdr_ops xdrrec_ops = { - xdrrec_getlong, - xdrrec_putlong, - xdrrec_getbytes, - xdrrec_putbytes, - xdrrec_getpos, - xdrrec_setpos, - xdrrec_inline, - xdrrec_destroy -}; - -/* - * A record is composed of one or more record fragments. - * A record fragment is a two-byte header followed by zero to - * 2**32-1 bytes. The header is treated as a long unsigned and is - * encode/decoded to the network via htonl/ntohl. The low order 31 bits - * are a byte count of the fragment. The highest order bit is a boolean: - * 1 => this fragment is the last fragment of the record, - * 0 => this fragment is followed by more fragment(s). - * - * The fragment/record machinery is not general; it is constructed to - * meet the needs of xdr and rpc based on tcp. - */ - -#define LAST_FRAG ((u_long)(1 << 31)) - -typedef struct rec_strm { - caddr_t tcp_handle; - caddr_t the_buffer; - /* - * out-goung bits - */ - int (*writeit)(); - caddr_t out_base; /* output buffer (points to frag header) */ - caddr_t out_finger; /* next output position */ - caddr_t out_boundry; /* data cannot up to this address */ - u_long *frag_header; /* beginning of curren fragment */ - bool_t frag_sent; /* true if buffer sent in middle of record */ - /* - * in-coming bits - */ - int (*readit)(); - u_long in_size; /* fixed size of the input buffer */ - caddr_t in_base; - caddr_t in_finger; /* location of next byte to be had */ - caddr_t in_boundry; /* can read up to this location */ - long fbtbc; /* fragment bytes to be consumed */ - bool_t last_frag; - u_int sendsize; - u_int recvsize; -} RECSTREAM; - - -/* - * Create an xdr handle for xdrrec - * xdrrec_create fills in xdrs. Sendsize and recvsize are - * send and recv buffer sizes (0 => use default). - * tcp_handle is an opaque handle that is passed as the first parameter to - * the procedures readit and writeit. Readit and writeit are read and - * write respectively. They are like the system - * calls expect that they take an opaque handle rather than an fd. - */ -void -xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit) - register XDR *xdrs; - register u_int sendsize; - register u_int recvsize; - caddr_t tcp_handle; - int (*readit)(); /* like read, but pass it a tcp_handle, not sock */ - int (*writeit)(); /* like write, but pass it a tcp_handle, not sock */ -{ - register RECSTREAM *rstrm = - (RECSTREAM *)mem_alloc(sizeof(RECSTREAM)); - - if (rstrm == NULL) { - (void)fprintf(stderr, "xdrrec_create: out of memory\n"); - /* - * This is bad. Should rework xdrrec_create to - * return a handle, and in this case return NULL - */ - return; - } - /* - * adjust sizes and allocate buffer quad byte aligned - */ - rstrm->sendsize = sendsize = fix_buf_size(sendsize); - rstrm->recvsize = recvsize = fix_buf_size(recvsize); - rstrm->the_buffer = mem_alloc(sendsize + recvsize + BYTES_PER_XDR_UNIT); - if (rstrm->the_buffer == NULL) { - (void)fprintf(stderr, "xdrrec_create: out of memory\n"); - return; - } - for (rstrm->out_base = rstrm->the_buffer; - (u_int)rstrm->out_base % BYTES_PER_XDR_UNIT != 0; - rstrm->out_base++); - rstrm->in_base = rstrm->out_base + sendsize; - /* - * now the rest ... - */ - xdrs->x_ops = &xdrrec_ops; - xdrs->x_private = (caddr_t)rstrm; - rstrm->tcp_handle = tcp_handle; - rstrm->readit = readit; - rstrm->writeit = writeit; - rstrm->out_finger = rstrm->out_boundry = rstrm->out_base; - rstrm->frag_header = (u_long *)rstrm->out_base; - rstrm->out_finger += sizeof(u_long); - rstrm->out_boundry += sendsize; - rstrm->frag_sent = FALSE; - rstrm->in_size = recvsize; - rstrm->in_boundry = rstrm->in_base; - rstrm->in_finger = (rstrm->in_boundry += recvsize); - rstrm->fbtbc = 0; - rstrm->last_frag = TRUE; -} - - -/* - * The reoutines defined below are the xdr ops which will go into the - * xdr handle filled in by xdrrec_create. - */ - -static bool_t -xdrrec_getlong(xdrs, lp) - XDR *xdrs; - long *lp; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register long *buflp = (long *)(rstrm->in_finger); - long mylong; - - /* first try the inline, fast case */ - if ((rstrm->fbtbc >= sizeof(long)) && - (((int)rstrm->in_boundry - (int)buflp) >= sizeof(long))) { - *lp = (long)ntohl((u_long)(*buflp)); - rstrm->fbtbc -= sizeof(long); - rstrm->in_finger += sizeof(long); - } else { - if (! xdrrec_getbytes(xdrs, (caddr_t)&mylong, sizeof(long))) - return (FALSE); - *lp = (long)ntohl((u_long)mylong); - } - return (TRUE); -} - -static bool_t -xdrrec_putlong(xdrs, lp) - XDR *xdrs; - long *lp; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register long *dest_lp = ((long *)(rstrm->out_finger)); - - if ((rstrm->out_finger += sizeof(long)) > rstrm->out_boundry) { - /* - * this case should almost never happen so the code is - * inefficient - */ - rstrm->out_finger -= sizeof(long); - rstrm->frag_sent = TRUE; - if (! flush_out(rstrm, FALSE)) - return (FALSE); - dest_lp = ((long *)(rstrm->out_finger)); - rstrm->out_finger += sizeof(long); - } - *dest_lp = (long)htonl((u_long)(*lp)); - return (TRUE); -} - -static bool_t /* must manage buffers, fragments, and records */ -xdrrec_getbytes(xdrs, addr, len) - XDR *xdrs; - register caddr_t addr; - register u_int len; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register int current; - - while (len > 0) { - current = rstrm->fbtbc; - if (current == 0) { - if (rstrm->last_frag) - return (FALSE); - if (! set_input_fragment(rstrm)) - return (FALSE); - continue; - } - current = (len < current) ? len : current; - if (! get_input_bytes(rstrm, addr, current)) - return (FALSE); - addr += current; - rstrm->fbtbc -= current; - len -= current; - } - return (TRUE); -} - -static bool_t -xdrrec_putbytes(xdrs, addr, len) - XDR *xdrs; - register caddr_t addr; - register u_int len; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register int current; - - while (len > 0) { - current = (u_int)rstrm->out_boundry - (u_int)rstrm->out_finger; - current = (len < current) ? len : current; - bcopy(addr, rstrm->out_finger, current); - rstrm->out_finger += current; - addr += current; - len -= current; - if (rstrm->out_finger == rstrm->out_boundry) { - rstrm->frag_sent = TRUE; - if (! flush_out(rstrm, FALSE)) - return (FALSE); - } - } - return (TRUE); -} - -static u_int -xdrrec_getpos(xdrs) - register XDR *xdrs; -{ - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - register long pos; - - pos = lseek((int)rstrm->tcp_handle, (long) 0, 1); - if (pos != -1) - switch (xdrs->x_op) { - - case XDR_ENCODE: - pos += rstrm->out_finger - rstrm->out_base; - break; - - case XDR_DECODE: - pos -= rstrm->in_boundry - rstrm->in_finger; - break; - - default: - pos = (u_int) -1; - break; - } - return ((u_int) pos); -} - -static bool_t -xdrrec_setpos(xdrs, pos) - register XDR *xdrs; - u_int pos; -{ - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - u_int currpos = xdrrec_getpos(xdrs); - int delta = currpos - pos; - caddr_t newpos; - - if ((int)currpos != -1) - switch (xdrs->x_op) { - - case XDR_ENCODE: - newpos = rstrm->out_finger - delta; - if ((newpos > (caddr_t)(rstrm->frag_header)) && - (newpos < rstrm->out_boundry)) { - rstrm->out_finger = newpos; - return (TRUE); - } - break; - - case XDR_DECODE: - newpos = rstrm->in_finger - delta; - if ((delta < (int)(rstrm->fbtbc)) && - (newpos <= rstrm->in_boundry) && - (newpos >= rstrm->in_base)) { - rstrm->in_finger = newpos; - rstrm->fbtbc -= delta; - return (TRUE); - } - break; - } - return (FALSE); -} - -static long * -xdrrec_inline(xdrs, len) - register XDR *xdrs; - int len; -{ - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - long * buf = NULL; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - if ((rstrm->out_finger + len) <= rstrm->out_boundry) { - buf = (long *) rstrm->out_finger; - rstrm->out_finger += len; - } - break; - - case XDR_DECODE: - if ((len <= rstrm->fbtbc) && - ((rstrm->in_finger + len) <= rstrm->in_boundry)) { - buf = (long *) rstrm->in_finger; - rstrm->fbtbc -= len; - rstrm->in_finger += len; - } - break; - } - return (buf); -} - -static void -xdrrec_destroy(xdrs) - register XDR *xdrs; -{ - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - - mem_free(rstrm->the_buffer, - rstrm->sendsize + rstrm->recvsize + BYTES_PER_XDR_UNIT); - mem_free((caddr_t)rstrm, sizeof(RECSTREAM)); -} - - -/* - * Exported routines to manage xdr records - */ - -/* - * Before reading (deserializing from the stream, one should always call - * this procedure to guarantee proper record alignment. - */ -bool_t -xdrrec_skiprecord(xdrs) - XDR *xdrs; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - - while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { - if (! skip_input_bytes(rstrm, rstrm->fbtbc)) - return (FALSE); - rstrm->fbtbc = 0; - if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) - return (FALSE); - } - rstrm->last_frag = FALSE; - return (TRUE); -} - -/* - * Look ahead fuction. - * Returns TRUE iff there is no more input in the buffer - * after consuming the rest of the current record. - */ -bool_t -xdrrec_eof(xdrs) - XDR *xdrs; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - - while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { - if (! skip_input_bytes(rstrm, rstrm->fbtbc)) - return (TRUE); - rstrm->fbtbc = 0; - if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) - return (TRUE); - } - if (rstrm->in_finger == rstrm->in_boundry) - return (TRUE); - return (FALSE); -} - -/* - * The client must tell the package when an end-of-record has occurred. - * The second paraemters tells whether the record should be flushed to the - * (output) tcp stream. (This let's the package support batched or - * pipelined procedure calls.) TRUE => immmediate flush to tcp connection. - */ -bool_t -xdrrec_endofrecord(xdrs, sendnow) - XDR *xdrs; - bool_t sendnow; -{ - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register u_long len; /* fragment length */ - - if (sendnow || rstrm->frag_sent || - ((u_long)rstrm->out_finger + sizeof(u_long) >= - (u_long)rstrm->out_boundry)) { - rstrm->frag_sent = FALSE; - return (flush_out(rstrm, TRUE)); - } - len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->frag_header) - - sizeof(u_long); - *(rstrm->frag_header) = htonl((u_long)len | LAST_FRAG); - rstrm->frag_header = (u_long *)rstrm->out_finger; - rstrm->out_finger += sizeof(u_long); - return (TRUE); -} - - -/* - * Internal useful routines - */ -static bool_t -flush_out(rstrm, eor) - register RECSTREAM *rstrm; - bool_t eor; -{ - register u_long eormask = (eor == TRUE) ? LAST_FRAG : 0; - register u_long len = (u_long)(rstrm->out_finger) - - (u_long)(rstrm->frag_header) - sizeof(u_long); - - *(rstrm->frag_header) = htonl(len | eormask); - len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->out_base); - if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len) - != (int)len) - return (FALSE); - rstrm->frag_header = (u_long *)rstrm->out_base; - rstrm->out_finger = (caddr_t)rstrm->out_base + sizeof(u_long); - return (TRUE); -} - -static bool_t /* knows nothing about records! Only about input buffers */ -fill_input_buf(rstrm) - register RECSTREAM *rstrm; -{ - register caddr_t where; - u_int i; - register int len; - - where = rstrm->in_base; - i = (u_int)rstrm->in_boundry % BYTES_PER_XDR_UNIT; - where += i; - len = rstrm->in_size - i; - if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1) - return (FALSE); - rstrm->in_finger = where; - where += len; - rstrm->in_boundry = where; - return (TRUE); -} - -static bool_t /* knows nothing about records! Only about input buffers */ -get_input_bytes(rstrm, addr, len) - register RECSTREAM *rstrm; - register caddr_t addr; - register int len; -{ - register int current; - - while (len > 0) { - current = (int)rstrm->in_boundry - (int)rstrm->in_finger; - if (current == 0) { - if (! fill_input_buf(rstrm)) - return (FALSE); - continue; - } - current = (len < current) ? len : current; - bcopy(rstrm->in_finger, addr, current); - rstrm->in_finger += current; - addr += current; - len -= current; - } - return (TRUE); -} - -static bool_t /* next two bytes of the input stream are treated as a header */ -set_input_fragment(rstrm) - register RECSTREAM *rstrm; -{ - u_long header; - - if (! get_input_bytes(rstrm, (caddr_t)&header, sizeof(header))) - return (FALSE); - header = (long)ntohl(header); - rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE; - rstrm->fbtbc = header & (~LAST_FRAG); - return (TRUE); -} - -static bool_t /* consumes input bytes; knows nothing about records! */ -skip_input_bytes(rstrm, cnt) - register RECSTREAM *rstrm; - long cnt; -{ - register int current; - - while (cnt > 0) { - current = (int)rstrm->in_boundry - (int)rstrm->in_finger; - if (current == 0) { - if (! fill_input_buf(rstrm)) - return (FALSE); - continue; - } - current = (cnt < current) ? cnt : current; - rstrm->in_finger += current; - cnt -= current; - } - return (TRUE); -} - -static u_int -fix_buf_size(s) - register u_int s; -{ - - if (s < 100) - s = 4000; - return (RNDUP(s)); -} diff --git a/lib/librpc/rpc/xdr_reference.c b/lib/librpc/rpc/xdr_reference.c deleted file mode 100644 index b78719411f12..000000000000 --- a/lib/librpc/rpc/xdr_reference.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)xdr_reference.c 1.11 87/08/11 SMI";*/ -/*static char *sccsid = "from: @(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr_reference.c,v 1.3 1993/08/26 00:53:53 jtc Exp $"; -#endif - -/* - * xdr_reference.c, Generic XDR routines impelmentation. - * - * Copyright (C) 1987, Sun Microsystems, Inc. - * - * These are the "non-trivial" xdr primitives used to serialize and de-serialize - * "pointers". See xdr.h for more info on the interface to xdr. - */ - -#include -#include -#include - -#define LASTUNSIGNED ((u_int)0-1) - -/* - * XDR an indirect pointer - * xdr_reference is for recursively translating a structure that is - * referenced by a pointer inside the structure that is currently being - * translated. pp references a pointer to storage. If *pp is null - * the necessary storage is allocated. - * size is the sizeof the referneced structure. - * proc is the routine to handle the referenced structure. - */ -bool_t -xdr_reference(xdrs, pp, size, proc) - register XDR *xdrs; - caddr_t *pp; /* the pointer to work on */ - u_int size; /* size of the object pointed to */ - xdrproc_t proc; /* xdr routine to handle the object */ -{ - register caddr_t loc = *pp; - register bool_t stat; - - if (loc == NULL) - switch (xdrs->x_op) { - case XDR_FREE: - return (TRUE); - - case XDR_DECODE: - *pp = loc = (caddr_t) mem_alloc(size); - if (loc == NULL) { - (void) fprintf(stderr, - "xdr_reference: out of memory\n"); - return (FALSE); - } - bzero(loc, (int)size); - break; - } - - stat = (*proc)(xdrs, loc, LASTUNSIGNED); - - if (xdrs->x_op == XDR_FREE) { - mem_free(loc, size); - *pp = NULL; - } - return (stat); -} - - -/* - * xdr_pointer(): - * - * XDR a pointer to a possibly recursive data structure. This - * differs with xdr_reference in that it can serialize/deserialiaze - * trees correctly. - * - * What's sent is actually a union: - * - * union object_pointer switch (boolean b) { - * case TRUE: object_data data; - * case FALSE: void nothing; - * } - * - * > objpp: Pointer to the pointer to the object. - * > obj_size: size of the object. - * > xdr_obj: routine to XDR an object. - * - */ -bool_t -xdr_pointer(xdrs,objpp,obj_size,xdr_obj) - register XDR *xdrs; - char **objpp; - u_int obj_size; - xdrproc_t xdr_obj; -{ - - bool_t more_data; - - more_data = (*objpp != NULL); - if (! xdr_bool(xdrs,&more_data)) { - return (FALSE); - } - if (! more_data) { - *objpp = NULL; - return (TRUE); - } - return (xdr_reference(xdrs,objpp,obj_size,xdr_obj)); -} diff --git a/lib/librpc/rpc/xdr_stdio.c b/lib/librpc/rpc/xdr_stdio.c deleted file mode 100644 index 6bdebe72709e..000000000000 --- a/lib/librpc/rpc/xdr_stdio.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)xdr_stdio.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr_stdio.c,v 1.3 1993/08/26 00:53:54 jtc Exp $"; -#endif - -/* - * xdr_stdio.c, XDR implementation on standard i/o file. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * This set of routines implements a XDR on a stdio stream. - * XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes - * from the stream. - */ - -#include -#include -#include - -static bool_t xdrstdio_getlong(); -static bool_t xdrstdio_putlong(); -static bool_t xdrstdio_getbytes(); -static bool_t xdrstdio_putbytes(); -static u_int xdrstdio_getpos(); -static bool_t xdrstdio_setpos(); -static long * xdrstdio_inline(); -static void xdrstdio_destroy(); - -/* - * Ops vector for stdio type XDR - */ -static struct xdr_ops xdrstdio_ops = { - xdrstdio_getlong, /* deseraialize a long int */ - xdrstdio_putlong, /* seraialize a long int */ - xdrstdio_getbytes, /* deserialize counted bytes */ - xdrstdio_putbytes, /* serialize counted bytes */ - xdrstdio_getpos, /* get offset in the stream */ - xdrstdio_setpos, /* set offset in the stream */ - xdrstdio_inline, /* prime stream for inline macros */ - xdrstdio_destroy /* destroy stream */ -}; - -/* - * Initialize a stdio xdr stream. - * Sets the xdr stream handle xdrs for use on the stream file. - * Operation flag is set to op. - */ -void -xdrstdio_create(xdrs, file, op) - register XDR *xdrs; - FILE *file; - enum xdr_op op; -{ - - xdrs->x_op = op; - xdrs->x_ops = &xdrstdio_ops; - xdrs->x_private = (caddr_t)file; - xdrs->x_handy = 0; - xdrs->x_base = 0; -} - -/* - * Destroy a stdio xdr stream. - * Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create. - */ -static void -xdrstdio_destroy(xdrs) - register XDR *xdrs; -{ - (void)fflush((FILE *)xdrs->x_private); - /* xx should we close the file ?? */ -}; - -static bool_t -xdrstdio_getlong(xdrs, lp) - XDR *xdrs; - register long *lp; -{ - - if (fread((caddr_t)lp, sizeof(long), 1, (FILE *)xdrs->x_private) != 1) - return (FALSE); -#ifndef mc68000 - *lp = ntohl(*lp); -#endif - return (TRUE); -} - -static bool_t -xdrstdio_putlong(xdrs, lp) - XDR *xdrs; - long *lp; -{ - -#ifndef mc68000 - long mycopy = htonl(*lp); - lp = &mycopy; -#endif - if (fwrite((caddr_t)lp, sizeof(long), 1, (FILE *)xdrs->x_private) != 1) - return (FALSE); - return (TRUE); -} - -static bool_t -xdrstdio_getbytes(xdrs, addr, len) - XDR *xdrs; - caddr_t addr; - u_int len; -{ - - if ((len != 0) && (fread(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1)) - return (FALSE); - return (TRUE); -} - -static bool_t -xdrstdio_putbytes(xdrs, addr, len) - XDR *xdrs; - caddr_t addr; - u_int len; -{ - - if ((len != 0) && (fwrite(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1)) - return (FALSE); - return (TRUE); -} - -static u_int -xdrstdio_getpos(xdrs) - XDR *xdrs; -{ - - return ((u_int) ftell((FILE *)xdrs->x_private)); -} - -static bool_t -xdrstdio_setpos(xdrs, pos) - XDR *xdrs; - u_int pos; -{ - - return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ? - FALSE : TRUE); -} - -static long * -xdrstdio_inline(xdrs, len) - XDR *xdrs; - u_int len; -{ - - /* - * Must do some work to implement this: must insure - * enough data in the underlying stdio buffer, - * that the buffer is aligned so that we can indirect through a - * long *, and stuff this pointer in xdrs->x_buf. Doing - * a fread or fwrite to a scratch buffer would defeat - * most of the gains to be had here and require storage - * management on this buffer, so we don't do this. - */ - return (NULL); -} diff --git a/lib/librpcsvc/src/rex.x b/lib/librpcsvc/src/rex.x deleted file mode 100644 index a5a7b2392cd6..000000000000 --- a/lib/librpcsvc/src/rex.x +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Remote execution (rex) protocol specification - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)rex.x 1.3 87/09/18 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)rex.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: rex.x,v 1.1 1993/10/08 05:26:56 cgd Exp $"; -%#endif /* not lint */ -#endif - -const STRINGSIZE = 1024; -typedef string rexstring<1024>; - -/* - * values to pass to REXPROC_SIGNAL - */ -const SIGINT = 2; /* interrupt */ - -/* - * Values for rst_flags, below - */ -const REX_INTERACTIVE = 1; /* interactive mode */ - -struct rex_start { - rexstring rst_cmd<>; /* list of command and args */ - rexstring rst_host; /* working directory host name */ - rexstring rst_fsname; /* working directory file system name */ - rexstring rst_dirwithin;/* working directory within file system */ - rexstring rst_env<>; /* list of environment */ - unsigned int rst_port0; /* port for stdin */ - unsigned int rst_port1; /* port for stdout */ - unsigned int rst_port2; /* port for stderr */ - unsigned int rst_flags; /* options - see const above */ -}; - -struct rex_result { - int rlt_stat; /* integer status code */ - rexstring rlt_message; /* string message for human consumption */ -}; - - -struct sgttyb { - unsigned four; /* always equals 4 */ - opaque chars[4]; - /* chars[0] == input speed */ - /* chars[1] == output speed */ - /* chars[2] == kill character */ - /* chars[3] == erase character */ - unsigned flags; -}; -/* values for speeds above (baud rates) */ -const B0 = 0; -const B50 = 1; -const B75 = 2; -const B110 = 3; -const B134 = 4; -const B150 = 5; -const B200 = 6; -const B300 = 7; -const B600 = 8; -const B1200 = 9; -const B1800 = 10; -const B2400 = 11; -const B4800 = 12; -const B9600 = 13; -const B19200 = 14; -const B38400 = 15; - -/* values for flags above */ -const TANDEM = 0x00000001; /* send stopc on out q full */ -const CBREAK = 0x00000002; /* half-cooked mode */ -const LCASE = 0x00000004; /* simulate lower case */ -const ECHO = 0x00000008; /* echo input */ -const CRMOD = 0x00000010; /* map \r to \r\n on output */ -const RAW = 0x00000020; /* no i/o processing */ -const ODDP = 0x00000040; /* get/send odd parity */ -const EVENP = 0x00000080; /* get/send even parity */ -const ANYP = 0x000000c0; /* get any parity/send none */ -const NLDELAY = 0x00000300; /* \n delay */ -const NL0 = 0x00000000; -const NL1 = 0x00000100; /* tty 37 */ -const NL2 = 0x00000200; /* vt05 */ -const NL3 = 0x00000300; -const TBDELAY = 0x00000c00; /* horizontal tab delay */ -const TAB0 = 0x00000000; -const TAB1 = 0x00000400; /* tty 37 */ -const TAB2 = 0x00000800; -const XTABS = 0x00000c00; /* expand tabs on output */ -const CRDELAY = 0x00003000; /* \r delay */ -const CR0 = 0x00000000; -const CR1 = 0x00001000; /* tn 300 */ -const CR2 = 0x00002000; /* tty 37 */ -const CR3 = 0x00003000; /* concept 100 */ -const VTDELAY = 0x00004000; /* vertical tab delay */ -const FF0 = 0x00000000; -const FF1 = 0x00004000; /* tty 37 */ -const BSDELAY = 0x00008000; /* \b delay */ -const BS0 = 0x00000000; -const BS1 = 0x00008000; -const CRTBS = 0x00010000; /* do backspacing for crt */ -const PRTERA = 0x00020000; /* \ ... / erase */ -const CRTERA = 0x00040000; /* " \b " to wipe out char */ -const TILDE = 0x00080000; /* hazeltine tilde kludge */ -const MDMBUF = 0x00100000; /* start/stop output on carrier intr */ -const LITOUT = 0x00200000; /* literal output */ -const TOSTOP = 0x00400000; /* SIGTTOU on background output */ -const FLUSHO = 0x00800000; /* flush output to terminal */ -const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */ -const L001000 = 0x02000000; -const CRTKIL = 0x04000000; /* kill line with " \b " */ -const PASS8 = 0x08000000; -const CTLECH = 0x10000000; /* echo control chars as ^X */ -const PENDIN = 0x20000000; /* tp->t_rawq needs reread */ -const DECCTQ = 0x40000000; /* only ^Q starts after ^S */ -const NOFLSH = 0x80000000; /* no output flush on signal */ - -struct tchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == interrupt char */ - /* chars[1] == quit char */ - /* chars[2] == start output char */ - /* chars[3] == stop output char */ - /* chars[4] == end-of-file char */ - /* chars[5] == input delimeter (like nl) */ -}; - -struct ltchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == stop process signal */ - /* chars[1] == delayed stop process signal */ - /* chars[2] == reprint line */ - /* chars[3] == flush output */ - /* chars[4] == word erase */ - /* chars[5] == literal next character */ - unsigned mode; -}; - -struct rex_ttysize { - int ts_lines; - int ts_cols; -}; - -struct rex_ttymode { - sgttyb basic; /* standard unix tty flags */ - tchars more; /* interrupt, kill characters, etc. */ - ltchars yetmore; /* special Berkeley characters */ - unsigned andmore; /* and Berkeley modes */ -}; - -/* values for andmore above */ -const LCRTBS = 0x0001; /* do backspacing for crt */ -const LPRTERA = 0x0002; /* \ ... / erase */ -const LCRTERA = 0x0004; /* " \b " to wipe out char */ -const LTILDE = 0x0008; /* hazeltine tilde kludge */ -const LMDMBUF = 0x0010; /* start/stop output on carrier intr */ -const LLITOUT = 0x0020; /* literal output */ -const LTOSTOP = 0x0040; /* SIGTTOU on background output */ -const LFLUSHO = 0x0080; /* flush output to terminal */ -const LNOHANG = 0x0100; /* no SIGHUP on carrier drop */ -const LL001000 = 0x0200; -const LCRTKIL = 0x0400; /* kill line with " \b " */ -const LPASS8 = 0x0800; -const LCTLECH = 0x1000; /* echo control chars as ^X */ -const LPENDIN = 0x2000; /* needs reread */ -const LDECCTQ = 0x4000; /* only ^Q starts after ^S */ -const LNOFLSH = 0x8000; /* no output flush on signal */ - -program REXPROG { - version REXVERS { - - /* - * Start remote execution - */ - rex_result - REXPROC_START(rex_start) = 1; - - /* - * Wait for remote execution to terminate - */ - rex_result - REXPROC_WAIT(void) = 2; - - /* - * Send tty modes - */ - void - REXPROC_MODES(rex_ttymode) = 3; - - /* - * Send window size change - */ - void - REXPROC_WINCH(rex_ttysize) = 4; - - /* - * Send other signal - */ - void - REXPROC_SIGNAL(int) = 5; - } = 1; -} = 100017; diff --git a/lib/librpcsvc/src/rnusers.x b/lib/librpcsvc/src/rnusers.x deleted file mode 100644 index be504941bbed..000000000000 --- a/lib/librpcsvc/src/rnusers.x +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Find out about remote users - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)rnusers.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: rnusers.x,v 1.3 1993/11/21 20:17:49 brezak Exp $"; -%#endif /* not lint */ -#endif - - -#ifdef RPC_HDR -%/* -% * The following structures are used by version 2 of the rusersd protocol. -% * They were not developed with rpcgen, so they do not appear as RPCL. -% */ -% -%#define RUSERSVERS_ORIG 1 /* original version */ -%#define RUSERSVERS_IDLE 2 -%#define MAXUSERS 100 -% -%/* -% * This is the structure used in version 2 of the rusersd RPC service. -% * It corresponds to the utmp structure for BSD sytems. -% */ -%struct ru_utmp { -% char ut_line[8]; /* tty name */ -% char ut_name[8]; /* user id */ -% char ut_host[16]; /* host name, if remote */ -% long ut_time; /* time on */ -%}; -%typedef struct ru_utmp rutmp; -% -%struct utmparr { -% struct utmp **uta_arr; -% int uta_cnt; -%}; -%typedef struct utmparr utmparr; -%int xdr_utmparr(); -% -%struct utmpidle { -% struct ru_utmp ui_utmp; -% unsigned ui_idle; -%}; -% -%struct utmpidlearr { -% struct utmpidle **uia_arr; -% int uia_cnt; -%}; -%typedef struct utmpidlearr utmpidlearr; -%int xdr_utmpidlearr(); -% -%#define RUSERSVERS_1 ((u_long)1) -%#define RUSERSVERS_2 ((u_long)2) -%#ifndef RUSERSPROG -%#define RUSERSPROG ((u_long)100002) -%#endif -%#ifndef RUSERSPROC_NUM -%#define RUSERSPROC_NUM ((u_long)1) -%#endif -%#ifndef RUSERSPROC_NAMES -%#define RUSERSPROC_NAMES ((u_long)2) -%#endif -%#ifndef RUSERSPROC_ALLNAMES -%#define RUSERSPROC_ALLNAMES ((u_long)3) -%#endif -% -#endif /* RPC_HDR */ - -#ifdef RPC_XDR -%bool_t -%xdr_utmp(xdrs, objp) -% XDR *xdrs; -% struct ru_utmp *objp; -%{ -% char *ptr; -% int size; -% -% ptr = objp->ut_line; -% size = sizeof(objp->ut_line); -% if (!xdr_bytes(xdrs, &ptr, &size, size)) { -% return (FALSE); -% } -% ptr = objp->ut_name; -% size = sizeof(objp->ut_line); -% if (!xdr_bytes(xdrs, &ptr, &size, size)) { -% return (FALSE); -% } -% ptr = objp->ut_host; -% size = sizeof(objp->ut_host); -% if (!xdr_bytes(xdrs, &ptr, &size, size)) { -% return (FALSE); -% } -% if (!xdr_long(xdrs, &objp->ut_time)) { -% return (FALSE); -% } -% return (TRUE); -%} -% -%bool_t -%xdr_utmpptr(xdrs, objpp) -% XDR *xdrs; -% struct utmp **objpp; -%{ -% if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct ru_utmp), -% xdr_utmp)) { -% return (FALSE); -% } -% return (TRUE); -%} -% -%bool_t -%xdr_utmparr(xdrs, objp) -% XDR *xdrs; -% struct utmparr *objp; -%{ -% if (!xdr_array(xdrs, (char **)&objp->uta_arr, (u_int *)&objp->uta_cnt, -% MAXUSERS, sizeof(struct utmp *), xdr_utmpptr)) { -% return (FALSE); -% } -% return (TRUE); -%} -% -%bool_t -%xdr_utmpidle(xdrs, objp) -% XDR *xdrs; -% struct utmpidle *objp; -%{ -% if (!xdr_utmp(xdrs, &objp->ui_utmp)) { -% return (FALSE); -% } -% if (!xdr_u_int(xdrs, &objp->ui_idle)) { -% return (FALSE); -% } -% return (TRUE); -%} -% -%bool_t -%xdr_utmpidleptr(xdrs, objpp) -% XDR *xdrs; -% struct utmpidle **objpp; -%{ -% if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct utmpidle), -% xdr_utmpidle)) { -% return (FALSE); -% } -% return (TRUE); -%} -% -%bool_t -%xdr_utmpidlearr(xdrs, objp) -% XDR *xdrs; -% struct utmpidlearr *objp; -%{ -% if (!xdr_array(xdrs, (char **)&objp->uia_arr, (u_int *)&objp->uia_cnt, -% MAXUSERS, sizeof(struct utmpidle *), xdr_utmpidleptr)) { -% return (FALSE); -% } -% return (TRUE); -%} -#endif diff --git a/lib/librpcsvc/src/rquota.x b/lib/librpcsvc/src/rquota.x deleted file mode 100644 index 1ec3c44c6aa2..000000000000 --- a/lib/librpcsvc/src/rquota.x +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Remote quota protocol - * Requires unix authentication - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)rquota.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)rquota.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: rquota.x,v 1.1 1993/10/08 05:26:58 cgd Exp $"; -%#endif /* not lint */ -#endif - -const RQ_PATHLEN = 1024; - -struct getquota_args { - string gqa_pathp; /* path to filesystem of interest */ - int gqa_uid; /* inquire about quota for uid */ -}; - -/* - * remote quota structure - */ -struct rquota { - int rq_bsize; /* block size for block counts */ - bool rq_active; /* indicates whether quota is active */ - unsigned int rq_bhardlimit; /* absolute limit on disk blks alloc */ - unsigned int rq_bsoftlimit; /* preferred limit on disk blks */ - unsigned int rq_curblocks; /* current block count */ - unsigned int rq_fhardlimit; /* absolute limit on allocated files */ - unsigned int rq_fsoftlimit; /* preferred file limit */ - unsigned int rq_curfiles; /* current # allocated files */ - unsigned int rq_btimeleft; /* time left for excessive disk use */ - unsigned int rq_ftimeleft; /* time left for excessive files */ -}; - -enum gqr_status { - Q_OK = 1, /* quota returned */ - Q_NOQUOTA = 2, /* noquota for uid */ - Q_EPERM = 3 /* no permission to access quota */ -}; - -union getquota_rslt switch (gqr_status status) { -case Q_OK: - rquota gqr_rquota; /* valid if status == Q_OK */ -case Q_NOQUOTA: - void; -case Q_EPERM: - void; -}; - -program RQUOTAPROG { - version RQUOTAVERS { - /* - * Get all quotas - */ - getquota_rslt - RQUOTAPROC_GETQUOTA(getquota_args) = 1; - - /* - * Get active quotas only - */ - getquota_rslt - RQUOTAPROC_GETACTIVEQUOTA(getquota_args) = 2; - } = 1; -} = 100011; diff --git a/lib/librpcsvc/src/rstat.x b/lib/librpcsvc/src/rstat.x deleted file mode 100644 index cb7c75286bf1..000000000000 --- a/lib/librpcsvc/src/rstat.x +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Gather statistics on remote machines - */ - -#ifdef RPC_HDR - -%#ifndef FSCALE -%/* -% * Scale factor for scaled integers used to count load averages. -% */ -%#define FSHIFT 8 /* bits to right of fixed binary point */ -%#define FSCALE (1<; /* aka ut_name */ - string ut_line; /* device */ - string ut_host; /* host user logged on from */ - int ut_type; /* type of entry */ - int ut_time; /* time entry was made */ - unsigned int ut_idle; /* minutes idle */ -}; - -typedef rusers_utmp utmp_array<>; - -#ifdef RPC_HDR -% -%/* -% * Values for ut_type field above. -% */ -#endif -const RUSERS_EMPTY = 0; -const RUSERS_RUN_LVL = 1; -const RUSERS_BOOT_TIME = 2; -const RUSERS_OLD_TIME = 3; -const RUSERS_NEW_TIME = 4; -const RUSERS_INIT_PROCESS = 5; -const RUSERS_LOGIN_PROCESS = 6; -const RUSERS_USER_PROCESS = 7; -const RUSERS_DEAD_PROCESS = 8; -const RUSERS_ACCOUNTING = 9; - -program RUSERSPROG { - - version RUSERSVERS_3 { - int - RUSERSPROC_NUM(void) = 1; - - utmp_array - RUSERSPROC_NAMES(void) = 2; - - utmp_array - RUSERSPROC_ALLNAMES(void) = 3; - } = 3; - -} = 100002; diff --git a/lib/librpcsvc/src/rwall.x b/lib/librpcsvc/src/rwall.x deleted file mode 100644 index b2331429e421..000000000000 --- a/lib/librpcsvc/src/rwall.x +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 1993 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * rpc protocol definition for (remote) wall protocol - * - * this has to be compatible with sun's definition - */ - -#ifndef RPC_HDR -%#ifndef lint -%static char rcsid[] = "$Id: rwall.x,v 1.1 1993/10/08 05:26:59 cgd Exp $"; -%#endif /* not lint */ -#endif - -program WALLPROG { - version WALLVERS { - void WALLPROC_WALL(string) = 2; - } = 1; -} = 100008; diff --git a/lib/librpcsvc/src/sm_inter.x b/lib/librpcsvc/src/sm_inter.x deleted file mode 100644 index 674796e04633..000000000000 --- a/lib/librpcsvc/src/sm_inter.x +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Status monitor protocol specification - * Copyright (C) 1986 Sun Microsystems, Inc. - * - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)sm_inter.x 1.7 87/06/24 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)sm_inter.x 2.2 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: sm_inter.x,v 1.2 1994/12/13 16:19:46 glass Exp $"; -%#endif /* not lint */ -#endif - -program SM_PROG { - version SM_VERS { - /* res_stat = stat_succ if status monitor agrees to monitor */ - /* res_stat = stat_fail if status monitor cannot monitor */ - /* if res_stat == stat_succ, state = state number of site sm_name */ - struct sm_stat_res SM_STAT(struct sm_name) = 1; - - /* res_stat = stat_succ if status monitor agrees to monitor */ - /* res_stat = stat_fail if status monitor cannot monitor */ - /* stat consists of state number of local site */ - struct sm_stat_res SM_MON(struct mon) = 2; - - /* stat consists of state number of local site */ - struct sm_stat SM_UNMON(struct mon_id) = 3; - - /* stat consists of state number of local site */ - struct sm_stat SM_UNMON_ALL(struct my_id) = 4; - - void SM_SIMU_CRASH(void) = 5; - - void SM_NOTIFY(struct stat_chge) = 6; - - } = 1; -} = 100024; - -const SM_MAXSTRLEN = 1024; - -struct sm_name { - string mon_name; -}; - -struct my_id { - string my_name; /* name of the site iniates the monitoring request*/ - int my_prog; /* rpc program # of the requesting process */ - int my_vers; /* rpc version # of the requesting process */ - int my_proc; /* rpc procedure # of the requesting process */ -}; - -struct mon_id { - string mon_name; /* name of the site to be monitored */ - struct my_id my_id; -}; - - -struct mon { - struct mon_id mon_id; - opaque priv[16]; /* private information to store at monitor for requesting process */ -}; - -struct stat_chge { - string mon_name; /* name of the site that had the state change */ - int state; -}; - -/* - * state # of status monitor monitonically increases each time - * status of the site changes: - * an even number (>= 0) indicates the site is down and - * an odd number (> 0) indicates the site is up; - */ -struct sm_stat { - int state; /* state # of status monitor */ -}; - -enum res { - stat_succ = 0, /* status monitor agrees to monitor */ - stat_fail = 1 /* status monitor cannot monitor */ -}; - -struct sm_stat_res { - res res_stat; - int state; -}; - -/* - * structure of the status message sent back by the status monitor - * when monitor site status changes - */ -struct status { - string mon_name; - int state; - opaque priv[16]; /* stored private information */ -}; diff --git a/lib/librpcsvc/src/spray.x b/lib/librpcsvc/src/spray.x deleted file mode 100644 index 830a8805dd5e..000000000000 --- a/lib/librpcsvc/src/spray.x +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Spray a server with packets - * Useful for testing flakiness of network interfaces - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)spray.x 1.2 87/09/18 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)spray.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: spray.x,v 1.2 1993/12/03 00:32:30 jtc Exp $"; -%#endif /* not lint */ -#endif - -#ifdef RPC_HDR -%#ifndef _RPCSVC_SPRAY_H_ -%#define _RPCSVC_SPRAY_H_ -% -#endif - -const SPRAYOVERHEAD = 86; /* size of rpc packet when size=0 */ -const SPRAYMAX = 8845; /* max amount can spray */ - - -/* - * GMT since 0:00, 1 January 1970 - */ -struct spraytimeval { - unsigned int sec; - unsigned int usec; -}; - -/* - * spray statistics - */ -struct spraycumul { - unsigned int counter; - spraytimeval clock; -}; - -/* - * spray data - */ -typedef opaque sprayarr; - -program SPRAYPROG { - version SPRAYVERS { - /* - * Just throw away the data and increment the counter - * This call never returns, so the client should always - * time it out. - */ - void - SPRAYPROC_SPRAY(sprayarr) = 1; - - /* - * Get the value of the counter and elapsed time since - * last CLEAR. - */ - spraycumul - SPRAYPROC_GET(void) = 2; - - /* - * Clear the counter and reset the elapsed time - */ - void - SPRAYPROC_CLEAR(void) = 3; - } = 1; -} = 100012; - - -#ifdef RPC_HDR -% -%#endif /* _RPCSVC_SPRAY_H_ */ -#endif diff --git a/lib/librpcsvc/src/yp.x b/lib/librpcsvc/src/yp.x deleted file mode 100644 index 8a8ef9368f80..000000000000 --- a/lib/librpcsvc/src/yp.x +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Protocol description file for the Yellow Pages Service - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)yp.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: yp.x,v 1.1 1993/10/08 05:27:02 cgd Exp $"; -%#endif /* not lint */ -#endif - -const YPMAXRECORD = 1024; -const YPMAXDOMAIN = 64; -const YPMAXMAP = 64; -const YPMAXPEER = 64; - - -enum ypstat { - YP_TRUE = 1, - YP_NOMORE = 2, - YP_FALSE = 0, - YP_NOMAP = -1, - YP_NODOM = -2, - YP_NOKEY = -3, - YP_BADOP = -4, - YP_BADDB = -5, - YP_YPERR = -6, - YP_BADARGS = -7, - YP_VERS = -8 -}; - - -enum ypxfrstat { - YPXFR_SUCC = 1, - YPXFR_AGE = 2, - YPXFR_NOMAP = -1, - YPXFR_NODOM = -2, - YPXFR_RSRC = -3, - YPXFR_RPC = -4, - YPXFR_MADDR = -5, - YPXFR_YPERR = -6, - YPXFR_BADARGS = -7, - YPXFR_DBM = -8, - YPXFR_FILE = -9, - YPXFR_SKEW = -10, - YPXFR_CLEAR = -11, - YPXFR_FORCE = -12, - YPXFR_XFRERR = -13, - YPXFR_REFUSED = -14 -}; - - -typedef string domainname; -typedef string mapname; -typedef string peername; -typedef opaque keydat; -typedef opaque valdat; - - -struct ypmap_parms { - domainname domain; - mapname map; - unsigned int ordernum; - peername peer; -}; - -struct ypreq_key { - domainname domain; - mapname map; - keydat key; -}; - -struct ypreq_nokey { - domainname domain; - mapname map; -}; - -struct ypreq_xfr { - ypmap_parms map_parms; - unsigned int transid; - unsigned int prog; - unsigned int port; -}; - - -struct ypresp_val { - ypstat stat; - valdat val; -}; - -struct ypresp_key_val { - ypstat stat; - keydat key; - valdat val; -}; - - -struct ypresp_master { - ypstat stat; - peername peer; -}; - -struct ypresp_order { - ypstat stat; - unsigned int ordernum; -}; - -union ypresp_all switch (bool more) { -case TRUE: - ypresp_key_val val; -case FALSE: - void; -}; - -struct ypresp_xfr { - unsigned int transid; - ypxfrstat xfrstat; -}; - -struct ypmaplist { - mapname map; - ypmaplist *next; -}; - -struct ypresp_maplist { - ypstat stat; - ypmaplist *maps; -}; - -enum yppush_status { - YPPUSH_SUCC = 1, /* Success */ - YPPUSH_AGE = 2, /* Master's version not newer */ - YPPUSH_NOMAP = -1, /* Can't find server for map */ - YPPUSH_NODOM = -2, /* Domain not supported */ - YPPUSH_RSRC = -3, /* Local resource alloc failure */ - YPPUSH_RPC = -4, /* RPC failure talking to server */ - YPPUSH_MADDR = -5, /* Can't get master address */ - YPPUSH_YPERR = -6, /* YP server/map db error */ - YPPUSH_BADARGS = -7, /* Request arguments bad */ - YPPUSH_DBM = -8, /* Local dbm operation failed */ - YPPUSH_FILE = -9, /* Local file I/O operation failed */ - YPPUSH_SKEW = -10, /* Map version skew during transfer */ - YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */ - YPPUSH_FORCE = -12, /* No local order number in map use -f flag. */ - YPPUSH_XFRERR = -13, /* ypxfr error */ - YPPUSH_REFUSED = -14 /* Transfer request refused by ypserv */ -}; - -struct yppushresp_xfr { - unsigned transid; - yppush_status status; -}; - -/* - * Response structure and overall result status codes. Success and failure - * represent two separate response message types. - */ - -enum ypbind_resptype { - YPBIND_SUCC_VAL = 1, - YPBIND_FAIL_VAL = 2 -}; - -struct ypbind_binding { - opaque ypbind_binding_addr[4]; /* In network order */ - opaque ypbind_binding_port[2]; /* In network order */ -}; - -union ypbind_resp switch (ypbind_resptype ypbind_status) { -case YPBIND_FAIL_VAL: - unsigned ypbind_error; -case YPBIND_SUCC_VAL: - ypbind_binding ypbind_bindinfo; -}; - -/* Detailed failure reason codes for response field ypbind_error*/ - -const YPBIND_ERR_ERR = 1; /* Internal error */ -const YPBIND_ERR_NOSERV = 2; /* No bound server for passed domain */ -const YPBIND_ERR_RESC = 3; /* System resource allocation failure */ - - -/* - * Request data structure for ypbind "Set domain" procedure. - */ -struct ypbind_setdom { - domainname ypsetdom_domain; - ypbind_binding ypsetdom_binding; - unsigned ypsetdom_vers; -}; - - -/* - * YP access protocol - */ -program YPPROG { - version YPVERS { - void - YPPROC_NULL(void) = 0; - - bool - YPPROC_DOMAIN(domainname) = 1; - - bool - YPPROC_DOMAIN_NONACK(domainname) = 2; - - ypresp_val - YPPROC_MATCH(ypreq_key) = 3; - - ypresp_key_val - YPPROC_FIRST(ypreq_key) = 4; - - ypresp_key_val - YPPROC_NEXT(ypreq_key) = 5; - - ypresp_xfr - YPPROC_XFR(ypreq_xfr) = 6; - - void - YPPROC_CLEAR(void) = 7; - - ypresp_all - YPPROC_ALL(ypreq_nokey) = 8; - - ypresp_master - YPPROC_MASTER(ypreq_nokey) = 9; - - ypresp_order - YPPROC_ORDER(ypreq_nokey) = 10; - - ypresp_maplist - YPPROC_MAPLIST(domainname) = 11; - } = 2; -} = 100004; - - -/* - * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR - */ -program YPPUSH_XFRRESPPROG { - version YPPUSH_XFRRESPVERS { - void - YPPUSHPROC_NULL(void) = 0; - - yppushresp_xfr - YPPUSHPROC_XFRRESP(void) = 1; - } = 1; -} = 0x40000000; /* transient: could be anything up to 0x5fffffff */ - - -/* - * YP binding protocol - */ -program YPBINDPROG { - version YPBINDVERS { - void - YPBINDPROC_NULL(void) = 0; - - ypbind_resp - YPBINDPROC_DOMAIN(domainname) = 1; - - void - YPBINDPROC_SETDOM(ypbind_setdom) = 2; - } = 2; -} = 100007; - - diff --git a/lib/librpcsvc/src/yppasswd.x b/lib/librpcsvc/src/yppasswd.x deleted file mode 100644 index 02959a059e8d..000000000000 --- a/lib/librpcsvc/src/yppasswd.x +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * YP password update protocol - * Requires unix authentication - */ - -#ifndef RPC_HDR -%#ifndef lint -%/*static char sccsid[] = "from: @(#)yppasswd.x 1.1 87/04/13 Copyr 1987 Sun Micro";*/ -%/*static char sccsid[] = "from: @(#)yppasswd.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$Id: yppasswd.x,v 1.1 1993/10/08 05:27:05 cgd Exp $"; -%#endif /* not lint */ -#endif - -program YPPASSWDPROG { - version YPPASSWDVERS { - /* - * Update my passwd entry - */ - int - YPPASSWDPROC_UPDATE(yppasswd) = 1; - } = 1; -} = 100009; - - -struct x_passwd { - string pw_name<>; /* username */ - string pw_passwd<>; /* encrypted password */ - int pw_uid; /* user id */ - int pw_gid; /* group id */ - string pw_gecos<>; /* in real life name */ - string pw_dir<>; /* home directory */ - string pw_shell<>; /* default shell */ -}; - -struct yppasswd { - string oldpass<>; /* unencrypted old password */ - x_passwd newpw; /* new passwd entry */ -}; - - diff --git a/lib/libtelnet/krb_des.c b/lib/libtelnet/krb_des.c deleted file mode 100644 index cda5f3868a5a..000000000000 --- a/lib/libtelnet/krb_des.c +++ /dev/null @@ -1,558 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)krb_des.c 5.1 (Berkeley) 2/28/91";*/ -static char rcsid[] = "$Id: krb_des.c,v 1.2 1993/08/01 18:32:31 mycroft Exp $"; -#endif /* not lint */ - -/* - * Copyright (C) 1990 by the Massachusetts Institute of Technology - * - * Export of this software from the United States of America is assumed - * to require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#if defined(AUTHENTICATE) && defined(ENCRYPT) && defined(KRBDES_ENCRYPT) -#include -#include -#ifdef __STDC__ -#include -#endif - -#include "encrypt.h" -#include "key-proto.h" -#include "misc-proto.h" - -extern encrypt_debug_mode; - -static Block krbdes_key = { 0 }; -static Schedule krbdes_sched = { 0 }; -static Block input_feed = { 0 }; -static Block output_feed = { 0 }; -static Block temp_feed = { 0 }; - -static unsigned char str_feed[64] = { IAC, SB, TELOPT_ENCRYPT, - ENCRYPT_IS, - ENCTYPE_KRBDES, }; - - void -krbdes_init(server) - int server; -{ - bzero((void *)krbdes_key, sizeof(Block)); - bzero((void *)krbdes_sched, sizeof(Schedule)); - bzero((void *)input_feed, sizeof(Block)); - bzero((void *)output_feed, sizeof(Block)); -} - -#define KRBDES_FEED_INIT 1 -#define KRBDES_FEED_VRFY 2 -#define KRBDES_FEED_FAIL 3 -#define KRBDES_FEED_OK 4 -#define KRBDES_FEED_VRFY_FAIL 5 - -/* - * Returns: - * -1: some error. Negotiation is done, encryption not ready. - * 0: Successful, initial negotiation all done. - * 1: successful, negotiation not done yet. - * 2: Not yet. Other things (like getting the key from - * Kerberos) have to happen before we can continue. - */ - - -#define NOT_YET 2 -#define IN_PROGRESS 1 -#define SUCCESS 0 -#define FAILED -1 - -int state[2] = { NOT_YET, NOT_YET }; -#define ENCRYPT_STATE 0 -#define DECRYPT_STATE 1 - -/* - * This is where we keep track of the fact that there has been a - * call to krbdes_start(), but we haven't gotten a valid key from - * kerberos, so that when (if) it does come in, we can continue with - * the initial encryption startup. - */ -static int need_start; - - int -krbdes_start(dir, server) - int dir; - int server; -{ - Block b; - int x; - unsigned char *p; - - switch (dir) { - case DIR_DECRYPT: - /* - * This is simply a request to have the other side - * start output (our input). He will negotiate a - * feed so we need not look for it. - */ - if (!VALIDKEY(krbdes_key)) - return(state[DECRYPT_STATE]); - if (state[DECRYPT_STATE] == NOT_YET) - state[DECRYPT_STATE] = IN_PROGRESS; - return(state[DECRYPT_STATE]); - - case DIR_ENCRYPT: - if (!VALIDKEY(krbdes_key)) { - need_start = 1; - return(state[ENCRYPT_STATE]); - } - if (state[ENCRYPT_STATE] == IN_PROGRESS) - return(IN_PROGRESS); - if (VALIDKEY(output_feed)) - return(SUCCESS); - if (encrypt_debug_mode) - printf("Creating new feed\r\n"); - /* - * Create a random feed and send it over encrypted. - * The other side will decrypt it, xor in 'KRBDES' - * and then recrypt it and send it back. - */ - des_new_random_key(temp_feed); - des_ecb_encrypt(temp_feed, b, krbdes_sched, 1); - str_feed[3] = ENCRYPT_IS; - p = str_feed + 5; - *p++ = KRBDES_FEED_INIT; - for (x = 0; x < sizeof(Block); ++x) { - if ((*p++ = b[x]) == IAC) - *p++ = IAC; - } - *p++ = IAC; - *p++ = SE; - printsub('>', &str_feed[2], p - &str_feed[2]); - net_write(str_feed, p - str_feed); - temp_feed[0] ^= 'K'; - temp_feed[1] ^= 'R'; - temp_feed[2] ^= 'B'; - temp_feed[3] ^= 'D'; - temp_feed[4] ^= 'E'; - temp_feed[5] ^= 'S'; - state[ENCRYPT_STATE] = IN_PROGRESS; - return(IN_PROGRESS); - default: - return(FAILED); - } -} - -/* - * Returns: - * -1: some error. Negotiation is done, encryption not ready. - * 0: Successful, initial negotiation all done. - * 1: successful, negotiation not done yet. - */ - - int -krbdes_is(data, cnt) - unsigned char *data; - int cnt; -{ - int x; - unsigned char *p; - unsigned char *why = 0; - Block b; - - if (cnt-- < 1) { - why = (unsigned char *)"Bad IS suboption"; - goto failure; - } - - switch (*data++) { - case KRBDES_FEED_INIT: - if (cnt != sizeof(Block)) { - if (encrypt_debug_mode) - printf("Use Feed failed on size\r\n"); - why = (unsigned char *)"Bad block size"; - goto failure; - } - if (!VALIDKEY(krbdes_key)) { - if (encrypt_debug_mode) - printf("Use Feed failed on key\r\n"); - why = (unsigned char *)"Invalid key"; - goto failure; - } - if (encrypt_debug_mode) - printf("Have a Use Feed\r\n"); - - bcopy((void *)data, (void *)b, sizeof(Block)); - des_ecb_encrypt(b, input_feed, krbdes_sched, 0); - - input_feed[0] ^= 'K'; - input_feed[1] ^= 'R'; - input_feed[2] ^= 'B'; - input_feed[3] ^= 'D'; - input_feed[4] ^= 'E'; - input_feed[5] ^= 'S'; - - des_ecb_encrypt(input_feed, b, krbdes_sched, 1); - str_feed[3] = ENCRYPT_REPLY; - p = str_feed + 5; - *p++ = KRBDES_FEED_VRFY; - for (x = 0; x < sizeof(Block); ++x) { - if ((*p++ = b[x]) == IAC) - *p++ = IAC; - } - *p++ = IAC; - *p++ = SE; - printsub('>', &str_feed[2], p - &str_feed[2]); - net_write(str_feed, p - str_feed); - if (encrypt_debug_mode) - printf("Initializing Decrypt stream\r\n"); - key_stream_init(krbdes_key, input_feed, DIR_DECRYPT); - state[DECRYPT_STATE] = IN_PROGRESS; - return(IN_PROGRESS); - - case KRBDES_FEED_OK: - state[DECRYPT_STATE] = SUCCESS; - return(SUCCESS); - - case KRBDES_FEED_FAIL: - state[DECRYPT_STATE] = FAILED; - return(FAILED); - - default: - if (encrypt_debug_mode) { - printf("Unknown option type: %d\r\n", data[-1]); - printd(data, cnt); - printf("\r\n"); - } - why = (unsigned char *)"Unknown sub-suboption"; - failure: - /* - * We failed. Send an empty KRBDES_FEED_VRFY option - * to the other side so it will know that things - * failed. - */ - str_feed[3] = ENCRYPT_REPLY; - p = str_feed + 5; - *p++ = KRBDES_FEED_VRFY_FAIL; - if (why) { - while (*why) { - if ((*p++ = *why++) == IAC) - *p++ = IAC; - } - } - *p++ = IAC; - *p++ = SE; - printsub('>', &str_feed[2], p - &str_feed[2]); - net_write(str_feed, p - str_feed); - state[DECRYPT_STATE] = FAILED; - return(FAILED); - } -} - -/* - * Returns: - * -1: some error. Negotiation is done, encryption not ready. - * 0: Successful, initial negotiation all done. - * 1: successful, negotiation not done yet. - */ - - int -krbdes_reply(data, cnt) - unsigned char *data; - int cnt; -{ - int x; - unsigned char *p; - unsigned char *why = 0; - Block b; - - if (cnt-- < 1) { - why = (unsigned char *)"Bad REPLY suboption"; - goto failure; - } - - switch (*data++) { - case KRBDES_FEED_VRFY: - if (cnt != sizeof(Block)) { - if (encrypt_debug_mode) - printf("Have Feed failed on size\r\n"); - why = (unsigned char *)"Bad block size"; - goto failure; - } - if (!VALIDKEY(krbdes_key)) { - if (encrypt_debug_mode) - printf("Have Feed failed on key\r\n"); - why = (unsigned char *)"Invalid key"; - goto failure; - } - if (encrypt_debug_mode) - printf("Have a Test Feed\r\n"); - - bcopy((void *)data, (void *)b, sizeof(Block)); - des_ecb_encrypt(b, output_feed, krbdes_sched, 0); - if (!SAMEKEY(output_feed, temp_feed)) { - if (encrypt_debug_mode) - printf("Have Feed failed on challange\r\n"); - bzero((void *)output_feed, sizeof(Block)); - why = (unsigned char*)"Challange decrypt failed"; - goto failure; - } - if (encrypt_debug_mode) - printf("Initializing Encrypt stream\r\n"); - key_stream_init(krbdes_key, output_feed, DIR_ENCRYPT); - - str_feed[3] = ENCRYPT_IS; - p = str_feed + 5; - *p++ = KRBDES_FEED_OK; - *p++ = IAC; - *p++ = SE; - printsub('>', &str_feed[2], p - &str_feed[2]); - net_write(str_feed, p - str_feed); - state[ENCRYPT_STATE] = SUCCESS; - return(SUCCESS); - - default: - if (encrypt_debug_mode) { - printf("Unknown option type: %d\r\n", data[-1]); - printd(data, cnt); - printf("\r\n"); - } - why = (unsigned char *)"Unknown sub-suboption"; - failure: - str_feed[3] = ENCRYPT_IS; - p = str_feed + 5; - *p++ = KRBDES_FEED_FAIL; - if (why) { - while (*why) { - if ((*p++ = *why++) == IAC) - *p++ = IAC; - } - } - *p++ = IAC; - *p++ = SE; - printsub('>', &str_feed[2], p - &str_feed[2]); - net_write(str_feed, p - str_feed); - state[ENCRYPT_STATE] = FAILED; - return(FAILED); - } -} - - void -krbdes_encrypt(s, c) - unsigned char *s; - int c; -{ - while (c-- > 0) { - *s = key_stream(DIR_ENCRYPT, *s); - ++s; - } -} - - int -krbdes_decrypt(c) - int c; -{ - return(key_stream(DIR_DECRYPT, c)); -#ifdef ndef - - if (c == -1) { - ++use; - return(0); - } - if (use) { - use = 0; - } else { - last = key_stream(DIR_DECRYPT, c); - } - - return(last ^ c); -#endif -} - - void -krbdes_session(key, server) - Session_Key *key; - int server; -{ - static once = 1; - - if (!key || key->type != SK_DES) { - if (encrypt_debug_mode) - printf("Can't set krbdes's session key (%d != %d)\r\n", - key ? key->type : -1, SK_DES); - return; - } - bcopy((void *)key->data, (void *)krbdes_key, sizeof(Block)); - if (once) { - des_set_random_generator_seed(krbdes_key); - once = 0; - } - des_key_sched(krbdes_key, krbdes_sched); - /* - * Now look to see if krbdes_start() was was waiting for - * the key to show up. If so, go ahead an call it now - * that we have the key. - */ - if (need_start) { - krbdes_start(DIR_ENCRYPT, server); - need_start = 0; - } -} - - void -krbdes_printsub(data, cnt, buf, buflen) - unsigned char *data, *buf; - int cnt, buflen; -{ - char lbuf[32]; - register int i; - char *cp; - - buf[buflen-1] = '\0'; /* make sure it's NULL terminated */ - buflen -= 1; - - switch(data[2]) { - case KRBDES_FEED_OK: - cp = "FEED_OK"; - goto common1; - case KRBDES_FEED_FAIL: - cp = "FEED_FAIL"; - common1: - for (; (buflen > 0) && (*buf = *cp++); buf++) - buflen--; - if (cnt > 3) { - if (buflen <= 0) - break; - *buf++ = ' '; - if (--buflen <= 0) - break; - *buf++ = '"'; - for (i = 3; i < cnt && buflen > 0; i++, buflen--) - *buf++ = data[i]; - if (buflen <= 0) - break; - *buf++ = '"'; - --buflen; - } - if (buflen <= 0) - break; - *buf++ = '\0'; - break; - - case KRBDES_FEED_INIT: - cp = "FEED_INIT "; - goto common2; - - case KRBDES_FEED_VRFY: - cp = "FEED_VRFY "; - goto common2; - - default: - sprintf(lbuf, " %d (unknown)", data[2]); - cp = lbuf; - common2: - for (; (buflen > 0) && (*buf = *cp++); buf++) - buflen--; - for (i = 3; i < cnt; i++) { - sprintf(lbuf, " %d", data[i]); - for (cp = lbuf; (buflen > 0) && (*buf = *cp++); buf++) - buflen--; - } - break; - } -} - -static Block stream_output[2]; -static Block stream_feed[2]; -static Schedule stream_sched[2]; -static int stream_index[2]; - - void -key_stream_init(key, seed, dir) - Block key; - Block seed; - int dir; -{ - des_key_sched(key, stream_sched[--dir]); - bcopy((void *)seed, (void *)stream_output[dir], sizeof(Block)); - stream_index[dir] = sizeof(Block); -} - - unsigned char -key_stream(dir, data) - int dir; - int data; /* data de/encrypting */ -{ - int index; - - if (data == -1) { - /* Backpeddle */ - if (stream_index[--dir]) - --stream_index[dir]; - return(0); - } - if ((index = stream_index[--dir]++) == sizeof(Block)) { - Block b; - des_ecb_encrypt(stream_output[dir], - b, - stream_sched[dir], 1); - bcopy((void *)b, (void *)stream_feed[dir], sizeof(Block)); - stream_index[dir] = 1; /* Next time will be 1 */ - index = 0; /* But now use 0 */ - } - - /* - * On encryption, we store (feed ^ data) which is cypher - * On decryption we store (data) which is cypher - */ - if (dir == DIR_DECRYPT) - return(stream_output[dir][index] = - (stream_feed[dir][index] ^ data)); - else - return((stream_output[dir][index] = data) ^ - stream_feed[dir][index]); -} -#endif diff --git a/lib/libutil/pwcache.c b/lib/libutil/pwcache.c deleted file mode 100644 index 330e134db834..000000000000 --- a/lib/libutil/pwcache.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "from: @(#)pwcache.c 5.4 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$Id: pwcache.c,v 1.3 1994/01/19 21:15:46 jtc Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -#define NCACHE 64 /* power of 2 */ -#define MASK NCACHE - 1 /* bits to store with */ - -static int pwopen = 0; -static int gropen = 0; - -char * -user_from_uid(uid, nouser) - uid_t uid; - int nouser; -{ - static struct ncache { - uid_t uid; - char name[UT_NAMESIZE + 1]; - } c_uid[NCACHE]; - static char nbuf[15]; /* 32 bits == 10 digits */ - register struct passwd *pw; - register struct ncache *cp; - - cp = c_uid + (uid & MASK); - if (cp->uid != uid || !*cp->name) { - if (pwopen == 0) { - setpassent(1); - pwopen++; - } - if (!(pw = getpwuid(uid))) { - if (nouser) - return((char *)NULL); - (void)sprintf(nbuf, "%u", uid); - return(nbuf); - } - cp->uid = uid; - (void)strncpy(cp->name, pw->pw_name, UT_NAMESIZE); - cp->name[UT_NAMESIZE] = '\0'; - } - return(cp->name); -} - -char * -group_from_gid(gid, nogroup) - gid_t gid; - int nogroup; -{ - static struct ncache { - gid_t gid; - char name[UT_NAMESIZE + 1]; - } c_gid[NCACHE]; - static char nbuf[15]; /* 32 bits == 10 digits */ - register struct group *gr; - register struct ncache *cp; - - cp = c_gid + (gid & MASK); - if (cp->gid != gid || !*cp->name) { - if (gropen == 0) { - setgroupent(1); - gropen++; - } - if (!(gr = getgrgid(gid))) { - if (nogroup) - return((char *)NULL); - (void)sprintf(nbuf, "%u", gid); - return(nbuf); - } - cp->gid = gid; - (void)strncpy(cp->name, gr->gr_name, UT_NAMESIZE); - cp->name[UT_NAMESIZE] = '\0'; - } - return(cp->name); -} diff --git a/libexec/bootpd/Installation b/libexec/bootpd/Installation deleted file mode 100644 index 466cabce0cdb..000000000000 --- a/libexec/bootpd/Installation +++ /dev/null @@ -1,29 +0,0 @@ - -Installation instructions for SunOS - -Compile the executable: -For SunOS 4.X: - make sunos4 -For SunOS 5.X: (Solaris) - make sunos5 - -Install the executables: - - make install - -Edit (or create) the bootptab: -(See bootptab.sample and bootptab.5 manual entry) - edit /etc/bootptab - -Edit /etc/services to add these two lines: -bootps 67/udp bootp # BOOTP Server -bootpc 68/udp # BOOTP Client - -Edit /etc/inetd.conf to add the line: -bootp dgram udp wait root /usr/etc/bootpd bootpd -i - -If you compiled report.c with LOG_LOCAL2 (defined in the Makefile) -then you may want to capture syslog messages from BOOTP by changing -your syslog.conf file. (See the sample syslog.conf file here). -Test the change with: logger -t test -p local2.info "message" - diff --git a/libexec/bootpd/Makefile b/libexec/bootpd/Makefile deleted file mode 100644 index a3cd2c07394c..000000000000 --- a/libexec/bootpd/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# bootpd/Makefile -# $Id: Makefile,v 1.4 1994/05/30 20:08:05 gwr Exp $ - -PROG= bootpd -CFLAGS+= -DETC_ETHERS -DSYSLOG -DDEBUG -DVEND_CMU - -SRCS= bootpd.c dovend.c readfile.c hash.c dumptab.c \ - lookup.c getif.c hwaddr.c report.c tzone.c - -MAN5= bootptab.0 -MAN8= bootpd.0 -MLINKS= bootpd.8 bootpgw.8 - -.include diff --git a/libexec/bootpd/NewMake b/libexec/bootpd/NewMake deleted file mode 100644 index ca9e8eb9644950173418030b618571b39881ccf6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8468 zcmeI0&5zqe6u@6f`B4A|Wcro+MU29F6VG zwpCXMaR31~j&MQz1)TU3IB`Tm;?^tTFW|r%C)p;Ew$ZK}tt#13G&9fdy%~?+{QPDP z?LO;x0|pzs2qA{15x`PW^|&O)tV9`6@&+NgZYo;dkX02Wx}Mj7Y;Z`a>)8z4ByHah z$GO8<97s3GcE#N#H8v5V+s8zq@sB8X?r1q#L+m0iu)&FiE);iP;rCfkx^wf0Mu zMq%pCofh56vJIy!QpX z1FxPa3fBP!0M}6b&6g;9eaN^I@kaoekH16V3Bai?Y)kA|*nWj=L$n(V%>aJD_P~F|Ci%@rK z;I+BUJ%(}%<^Nz`PlayP8}$QlC=L?EKm8|kyKZ~t*l3~r2I`(-oWIqMyn&lls7#$~ z$2&n^F4|;n14v>Ht`8kQfFQI{b`LVI{Vc{91)K)X?AQn^`tSZ>}gH!N&epIX)W0ai-o{gx;{Dc4F5i-#?etq8knX|Gf&P?`%u&N%lu z^`(>+_pXu_@t4It`?RbEQzGqkw8(2nh-q$NnudnzrmX2{Zjs33uW>S`#Y!Ap8W=~7 z`axl9>J1Z)M$wwLs6$-;n2lVlaAvzAqs3~^4tnBNG#rO^8*86QTV&w-{b-DhE(^Vm z(3;q;%dx`Q*ykZu!pHsy?Ir1OucpuX5DsJ^*g5MIo7GC~BWs@Y(4BeOLw8owoH6&i zagvkf7U$#^@q1;RjpAZ0EyV64riEsxI_^q{iRng4i!}>9k=skOScropa3QuG3%p=r z*eaETZ~fXo") - -[ From the NetBSD README file: ] - -BOOTPD is a useful adjunct to the nfs diskless boot EPROM code. - -The alternatives for initiating a boot of a kernel across a network -are to use RARP protocol, or BOOTP protocol. BOOTP is more flexible; -it allows additional items of information to be returned to the -booting client; it also supports booting across gateways. - -[ From the CMU README file: ] - -Notes: -1) BOOTP was originally designed and implemented by Bill Croft at Stanford. - Much of the credit for the ideas and the code goes to him. We've added - code to support the vendor specific area of the packet as specified in - RFC1048. We've also improved the host lookup algorithm and added some - extra logging. - -2) The server now uses syslog to do logging. Specifically it uses the 4.3bsd - version. I've #ifdef'd all of these calls. If you are running 4.2 you - should compile without the -DSYSLOG switch. - -3) You must update your /etc/services file to contain the following two lines: - bootps 67/udp bootp # BOOTP Server - bootpc 68/udp # BOOTP Client - -4) Edit the bootptab. It has some explanitory comments, and there - is a manual entry describing its format (bootptab.5) - If you have any questions, just let us know. - -Construction: - [ See the file Installation which is more up-to-date. -gwr ] - - Make sure all of the files exist first. If anything is missing, - please contact either Walt Wimer or Drew Perkins by E-mail or phone. - Addresses and phone numbers are listed below. - - Type 'make'. The options at present are: -DSYSLOG which enables logging - code, -DDEBUG which enables table dumping via signals, and -DVEND_CMU - which enables the CMU extensions for CMU PC/IP. - - Edit the bootptab. The man page and the comments in the file should - explain how to go about doing so. If you have any problems, let me know. - - Type 'make install'. This should put all of the files in the right place. - - Edit your /etc/rc.local or /etc/inetd.conf file to start up bootpd upon - reboot. The following is a sample /etc/inetd.conf entry: - # BOOTP server - bootps dgram udp wait root /usr/etc/bootpd bootpd -i - -Care and feeding: - If you change the interface cards on your host or add new hosts you will - need to update /etc/bootptab. Just edit it as before. Once you write - it back out, bootpd will notice that there is a new copy and will - reread it the next time it gets a request. - - If your bootp clients don't get a response then several things might be - wrong. Most often, the entry for that host is not in the database. - Check the hardware address and then check the entry and make sure - everything is right. Other problems include the server machine crashing, - bad cables, and the like. If your network is very congested you should - try making your bootp clients send additional requests before giving up. - - -November 7, 1988 - - -Walter L. Wimer Drew D. Perkins -ww0n@andrew.cmu.edu ddp@andrew.cmu.edu -(412) 268-6252 (412) 268-8576 - -4910 Forbes Ave -Pittsburgh, PA 15213 - -[ Contents description by file: ] - -Announce* Text of release announcements -Installation Instructions for building and installing -Makefile* for "make" -README This file -bootp.h The protocol header file -bootpd.8 Manual page for bootpd, boopgw -bootpd.c BOOTP server main module -bootpd.h header for above (and others) -bootpef.8 Manual page for bootpef -bootpef.c BOOTP extension file compiler -bootpgw.c BOOTP gateway main module -bootptab.5 A manual describing the bootptab format -bootptab.cmu A sample database file for the server -bootptab.mcs Another sample from -bootptest.8 Manual page for bootptest -bootptest.c BOOTP test program (fake client) -bootptest.h header for above -dovend.c Vendor Option builder (for bootpd, bootpef) -dovend.h header for above -dumptab.c Implements debugging dump for bootpd -getether.c For bootptest (not used yet) -getif.c Get network interface info. -getif.h header for above -hash.c The hash table module -hash.h header for above -hwaddr.c Hardware address support -hwaddr.h header for above -lookup.c Internet Protocol address lookup -lookup.h header for above -patchlevel.h Holds version numbers -print-bootp.c Prints BOOTP packets (taken from BSD tcpdump) -readfile.c The configuration file-reading routines -readfile.h header for above -report.c Does syslog-style messages -report.h header for above -strerror.c Library errno-to-string (for systems lacking it) -syslog.conf Sample config file for syslogd(8) -syslog.h For systems that lack syslog(3) -try*.c Test programs (for debugging) -tzone.c Get timezone offset -tzone.h header for above diff --git a/libexec/bootpd/bootp.h b/libexec/bootpd/bootp.h deleted file mode 100644 index 912d1f6c02f2..000000000000 --- a/libexec/bootpd/bootp.h +++ /dev/null @@ -1,144 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU 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. -************************************************************************/ - -/* - * Bootstrap Protocol (BOOTP). RFC951 and RFC1395. - * - * $Header: /cvsroot/src/libexec/bootpd/Attic/bootp.h,v 1.2 1994/05/24 15:20:08 gwr Exp $ - * - * - * This file specifies the "implementation-independent" BOOTP protocol - * information which is common to both client and server. - * - */ - -#include "bptypes.h" /* for int32, u_int32 */ - -#define BP_CHADDR_LEN 16 -#define BP_SNAME_LEN 64 -#define BP_FILE_LEN 128 -#define BP_VEND_LEN 64 -#define BP_MINPKTSZ 300 /* to check sizeof(struct bootp) */ - -struct bootp { - unsigned char bp_op; /* packet opcode type */ - unsigned char bp_htype; /* hardware addr type */ - unsigned char bp_hlen; /* hardware addr length */ - unsigned char bp_hops; /* gateway hops */ - unsigned int32 bp_xid; /* transaction ID */ - unsigned short bp_secs; /* seconds since boot began */ - unsigned short bp_unused; - struct in_addr bp_ciaddr; /* client IP address */ - struct in_addr bp_yiaddr; /* 'your' IP address */ - struct in_addr bp_siaddr; /* server IP address */ - struct in_addr bp_giaddr; /* gateway IP address */ - unsigned char bp_chaddr[BP_CHADDR_LEN]; /* client hardware address */ - char bp_sname[BP_SNAME_LEN]; /* server host name */ - char bp_file[BP_FILE_LEN]; /* boot file name */ - unsigned char bp_vend[BP_VEND_LEN]; /* vendor-specific area */ - /* note that bp_vend can be longer, extending to end of packet. */ -}; - -/* - * UDP port numbers, server and client. - */ -#define IPPORT_BOOTPS 67 -#define IPPORT_BOOTPC 68 - -#define BOOTREPLY 2 -#define BOOTREQUEST 1 - -/* - * Hardware types from Assigned Numbers RFC. - */ -#define HTYPE_ETHERNET 1 -#define HTYPE_EXP_ETHERNET 2 -#define HTYPE_AX25 3 -#define HTYPE_PRONET 4 -#define HTYPE_CHAOS 5 -#define HTYPE_IEEE802 6 -#define HTYPE_ARCNET 7 - -/* - * Vendor magic cookie (v_magic) for CMU - */ -#define VM_CMU "CMU" - -/* - * Vendor magic cookie (v_magic) for RFC1048 - */ -#define VM_RFC1048 { 99, 130, 83, 99 } - - - -/* - * Tag values used to specify what information is being supplied in - * the vendor (options) data area of the packet. - */ -/* RFC 1048 */ -#define TAG_END ((unsigned char) 255) -#define TAG_PAD ((unsigned char) 0) -#define TAG_SUBNET_MASK ((unsigned char) 1) -#define TAG_TIME_OFFSET ((unsigned char) 2) -#define TAG_GATEWAY ((unsigned char) 3) -#define TAG_TIME_SERVER ((unsigned char) 4) -#define TAG_NAME_SERVER ((unsigned char) 5) -#define TAG_DOMAIN_SERVER ((unsigned char) 6) -#define TAG_LOG_SERVER ((unsigned char) 7) -#define TAG_COOKIE_SERVER ((unsigned char) 8) -#define TAG_LPR_SERVER ((unsigned char) 9) -#define TAG_IMPRESS_SERVER ((unsigned char) 10) -#define TAG_RLP_SERVER ((unsigned char) 11) -#define TAG_HOST_NAME ((unsigned char) 12) -#define TAG_BOOT_SIZE ((unsigned char) 13) -/* RFC 1395 */ -#define TAG_DUMP_FILE ((unsigned char) 14) -#define TAG_DOMAIN_NAME ((unsigned char) 15) -#define TAG_SWAP_SERVER ((unsigned char) 16) -#define TAG_ROOT_PATH ((unsigned char) 17) -/* RFC 1497 */ -#define TAG_EXTEN_FILE ((unsigned char) 18) -/* RFC 1533 */ -#define TAG_NIS_DOMAIN ((unsigned char) 40) -#define TAG_NIS_SERVER ((unsigned char) 41) -#define TAG_NTP_SERVER ((unsigned char) 42) -/* XXX - Add new tags here */ - - -/* - * "vendor" data permitted for CMU bootp clients. - */ - -struct cmu_vend { - char v_magic[4]; /* magic number */ - unsigned int32 v_flags; /* flags/opcodes, etc. */ - struct in_addr v_smask; /* Subnet mask */ - struct in_addr v_dgate; /* Default gateway */ - struct in_addr v_dns1, v_dns2; /* Domain name servers */ - struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */ - struct in_addr v_ts1, v_ts2; /* Time servers */ - int32 v_unused[6]; /* currently unused */ -}; - - -/* v_flags values */ -#define VF_SMASK 1 /* Subnet mask field contains valid data */ diff --git a/libexec/bootpd/bootpd.8 b/libexec/bootpd/bootpd.8 deleted file mode 100644 index cca20b94570b..000000000000 --- a/libexec/bootpd/bootpd.8 +++ /dev/null @@ -1,305 +0,0 @@ -.\" Copyright (c) 1988, 1989, 1991 Carnegie Mellon University -.\" -.\" $Header: /cvsroot/src/libexec/bootpd/Attic/bootpd.8,v 1.2 1994/05/24 15:20:09 gwr Exp $ -.\" -.TH BOOTPD 8 "November 06, 1993" "Carnegie Mellon University" -.SH NAME -bootpd, bootpgw \- Internet Boot Protocol server/gateway -.SH SYNOPSIS -.B bootpd -[ -.B \-i -.B \-s -.B \-t -timeout -.B \-d -level -.B \-c -chdir\-path -] -[ -.I bootptab -[ -.I dumpfile -] ] -.br -.B bootpgw -[ -.B \-i -.B \-s -.B \-t -timeout -.B \-d -level -] server -.SH DESCRIPTION -.I Bootpd -implements an Internet Bootstrap Protocol (BOOTP) server as defined in -RFC951, RFC1532, and RFC1533. -.I Bootpgw -implements a simple BOOTP gateway which can be used to forward -requests and responses between clients on one subnet and a -BOOTP server (i.e. -.IR bootpd ) -on another subnet. While either -.I bootpd -or -.I bootpgw -will forward BOOTREPLY packets, only -.I bootpgw -will forward BOOTREQUEST packets. -.PP -One host on each network segment is normally configured to run either -.I bootpd -or -.I bootpgw -from -.I inetd -by including one of the following lines in the file -.IR /etc/inetd.conf : -.IP -bootps dgram udp wait root /etc/bootpd bootpd bootptab -.br -bootps dgram udp wait root /etc/bootpgw bootpgw server -.PP -This mode of operation is referred to as "inetd mode" and causes -.I bootpd -(or -.IR bootpgw ) -to be started only when a boot request arrives. If it does not -receive another packet within fifteen minutes of the last one -it received, it will exit to conserve system resources. The -.B \-t -option controls this timeout (see OPTIONS). -.PP -It is also possible to run -.I bootpd -(or -.IR bootpgw ) -in "standalone mode" (without -.IR inetd ) -by simply invoking it from a shell like any other regular command. -Standalone mode is particularly useful when -.I bootpd -is used with a large configuration database, where the start up -delay might otherwise prevent timely response to client requests. -(Automatic start up in standalone mode can be done by invoking -.I bootpd -from within -.IR /etc/rc.local , -for example.) -Standalone mode is less useful for -.I bootgw -which -has very little start up delay because -it does not read a configuration file. -.PP -Either program automatically detects whether it was invoked from inetd -or from a shell and automatically selects the appropriate mode. -The -.B \-s -or -.B \-i -option may be used to force standalone or inetd mode respectively -(see OPTIONS). -.SH OPTIONS -.TP -.BI \-t \ timeout -Specifies the -.I timeout -value (in minutes) that a -.I bootpd -or -.I bootpgw -process will wait for a BOOTP packet before exiting. -If no packets are recieved for -.I timeout -seconds, then the program will exit. -A timeout value of zero means "run forever". -In standalone mode, this option is forced to zero. -.TP -.BI \-d \ debug\-level -Sets the -.I debug\-level -variable that controls the amount of debugging messages generated. -For example, -d4 or -d 4 will set the debugging level to 4. -For compatibility with older versions of -.IR bootpd , -omitting the numeric parameter (i.e. just -d) will -simply increment the debug level by one. -.TP -.BI \-c \ chdir\-path -Sets the current directory used by -.I bootpd -while checking the existence and size of client boot files. This is -useful when client boot files are specified as relative pathnames, and -.I bootpd -needs to use the same current directory as the TFTP server -(typically /tftpboot). This option is not recoginzed by -.IR bootpgw . -.TP -.B \-i -Force inetd mode. This option is obsolete, but remains for -compatibility with older versions of -.IR bootpd . -.TP -.B \-s -Force standalone mode. This option is obsolete, but remains for -compatibility with older versions of -.IR bootpd . -.TP -.I bootptab -Specifies the name of the configuration file from which -.I bootpd -loads its database of known clients and client options -.RI ( bootpd -only). -.TP -.I dumpfile -Specifies the name of the file that -.I bootpd -will dump its internal database into when it receives a -SIGUSR1 signal -.RI ( bootpd -only). This option is only recognized if -.I bootpd -was compiled with the -DDEBUG flag. -.TP -.I server -Specifies the name of a BOOTP server to which -.I bootpgw -will forward all BOOTREQUEST packets it receives -.RI ( bootpgw -only). -.SH OPERATION -.PP -Both -.I bootpd -and -.I bootpgw -operate similarly in that both listen for any packets sent to the -.I bootps -port, and both simply forward any BOOTREPLY packets. -They differ in their handling of BOOTREQUEST packets. -.PP -When -.I bootpgw -is started, it determines the address of a BOOTP server -whose name is provided as a command line parameter. When -.I bootpgw -receives a BOOTREQUEST packet, it sets the "gateway address" -and "hop count" fields in the packet and forwards the packet -to the BOOTP server at the address determined earlier. -Requests are forwarded only if they indicate that -the client has been waiting for at least three seconds. -.PP -When -.I bootpd -is started it reads a configuration file, (normally -.IR /etc/bootptab ) -that initializes the internal database of known clients and client -options. This internal database is reloaded -from the configuration file when -.I bootpd -receives a hangup signal (SIGHUP) or when it discovers that the -configuration file has changed. -.PP -When -.I bootpd -receives a BOOTREQUEST packet, it -.\" checks the modification time of the -.\" configuration file and reloads the database if necessary. Then it -looks for a database entry matching the client request. -If the client is known, -.I bootpd -composes a BOOTREPLY packet using the database entry found above, -and sends the reply to the client (possibly using a gateway). -If the client is unknown, the request is discarded -(with a notice if debug > 0). -.PP -If -.I bootpd -is compiled with the -DDEBUG option, receipt of a SIGUSR1 signal causes -it to dump its internal database to the file -.I /etc/bootpd.dump -or the dumpfile specified as a command line parameter. -.PP -During initialization, both programs -determine the UDP port numbers to be used by calling -.I getservbyname -(which nomally uses -.IR /etc/services). -Two service names (and port numbers) are used: -.IP -bootps \- BOOTP Server listening port -.br -bootpc \- BOOTP Client destination port -.LP -If the port numbers cannot -be determined using -.I getservbyname -then the values default to boopts=67 and bootpc=68. -.SH FILES -.TP 20 -/etc/bootptab -Database file read by -.IR bootpd . -.TP -/etc/bootpd.dump -Debugging dump file created by -.IR bootpd . -.TP -/etc/services -Internet service numbers. -.TP -/tftpboot -Current directory typically used by the TFTP server and -.IR bootpd . - -.SH BUGS -Individual host entries must not exceed 1024 characters. - -.SH CREDITS -.PP -This distribution is currently maintained by -Walter L. Wimer . -.PP -The original BOOTP server was created by -Bill Croft at Stanford University in January 1986. -.PP -The current version of -.I bootpd -is primarily the work of David Kovar, -Drew D. Perkins, and Walter L. Wimer, -at Carnegie Mellon University. -.TP -Enhancements and bug\-fixes have been contributed by: -(in alphabetical order) -.br -Danny Backx -.br -John Brezak -.br -Frank da Cruz -.br -David R. Linn -.br -Jim McKim -.br -Gordon W. Ross -.br -Jason Zions -.SH "SEE ALSO" -.LP -bootptab(5), inetd(8), tftpd(8) -.LP -DARPA Internet Request For Comments: -.TP 10 -RFC951 -Bootstrap Protocol -.TP 10 -RFC1532 -Clarifications and Extensions for the Bootstrap Protocol -.TP 10 -RFC1533 -DHCP Options and BOOTP Vendor Extensions diff --git a/libexec/bootpd/bootpd.c b/libexec/bootpd/bootpd.c deleted file mode 100644 index 35f9c700251c..000000000000 --- a/libexec/bootpd/bootpd.c +++ /dev/null @@ -1,1334 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU 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. -************************************************************************/ - -#ifndef lint -static char rcsid[] = "$Id: bootpd.c,v 1.2 1994/05/24 15:20:10 gwr Exp $"; -#endif - -/* - * BOOTP (bootstrap protocol) server daemon. - * - * Answers BOOTP request packets from booting client machines. - * See [SRI-NIC]RFC951.TXT for a description of the protocol. - * See [SRI-NIC]RFC1048.TXT for vendor-information extensions. - * See RFC 1395 for option tags 14-17. - * See accompanying man page -- bootpd.8 - * - * HISTORY - * See ./Changes - * - * BUGS - * See ./ToDo - */ - - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include /* inet_ntoa */ - -#ifndef NO_UNISTD -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef NO_SETSID -# include /* for O_RDONLY, etc */ -#endif - -#ifdef SVR4 -/* Using sigset() avoids the need to re-arm each time. */ -#define signal sigset -#endif - -#ifndef USE_BFUNCS -# include -/* Yes, memcpy is OK here (no overlapped copies). */ -# define bcopy(a,b,c) memcpy(b,a,c) -# define bzero(p,l) memset(p,0,l) -# define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bootp.h" -#include "hash.h" -#include "hwaddr.h" -#include "bootpd.h" -#include "dovend.h" -#include "getif.h" -#include "readfile.h" -#include "report.h" -#include "tzone.h" -#include "patchlevel.h" - -/* Local definitions: */ -#define MAXPKT (3*512) /* Maximum packet size */ - -#ifndef CONFIG_FILE -#define CONFIG_FILE "/etc/bootptab" -#endif -#ifndef DUMPTAB_FILE -#define DUMPTAB_FILE "/tmp/bootpd.dump" -#endif - - - -/* - * Externals, forward declarations, and global variables - */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern void dumptab P((char *)); - -PRIVATE void catcher P((int)); -PRIVATE int chk_access P((char *, int32 *)); -#ifdef VEND_CMU -PRIVATE void dovend_cmu P((struct bootp *, struct host *)); -#endif -PRIVATE void dovend_rfc1048 P((struct bootp *, struct host *, int32)); -PRIVATE void handle_reply P((void)); -PRIVATE void handle_request P((void)); -PRIVATE void sendreply P((int forward, int32 dest_override)); -PRIVATE void usage P((void)); - -#undef P - -/* - * IP port numbers for client and server obtained from /etc/services - */ - -u_short bootps_port, bootpc_port; - - -/* - * Internet socket and interface config structures - */ - -struct sockaddr_in bind_addr; /* Listening */ -struct sockaddr_in recv_addr; /* Packet source */ -struct sockaddr_in send_addr; /* destination */ - - -/* - * option defaults - */ -int debug = 0; /* Debugging flag (level) */ -struct timeval actualtimeout = -{ /* fifteen minutes */ - 15 * 60L, /* tv_sec */ - 0 /* tv_usec */ -}; - -/* - * General - */ - -int s; /* Socket file descriptor */ -char *pktbuf; /* Receive packet buffer */ -int pktlen; -char *progname; -char *chdir_path; -char hostname[MAXHOSTNAMELEN]; /* System host name */ -struct in_addr my_ip_addr; -#ifdef YORK_EX_OPTION -char *exec_file_name; -#endif - -/* Flags set by signal catcher. */ -PRIVATE int do_readtab = 0; -PRIVATE int do_dumptab = 0; - -/* - * Globals below are associated with the bootp database file (bootptab). - */ - -char *bootptab = CONFIG_FILE; -char *bootpd_dump = DUMPTAB_FILE; - - - -/* - * Initialization such as command-line processing is done and then the - * main server loop is started. - */ - -void -main(argc, argv) - int argc; - char **argv; -{ - struct timeval *timeout; - struct bootp *bp; - struct servent *servp; - struct hostent *hep; - char *stmp; - int n, ba_len, ra_len; - int nfound, readfds; - int standalone; - - progname = strrchr(argv[0], '/'); - if (progname) progname++; - else progname = argv[0]; - - /* - * Initialize logging. - */ - report_init(0); /* uses progname */ - - /* - * Log startup - */ - report(LOG_INFO, "version %s.%d", VERSION, PATCHLEVEL); - - /* Debugging for compilers with struct padding. */ - assert(sizeof(struct bootp) == BP_MINPKTSZ); - - /* Get space for receiving packets and composing replies. */ - pktbuf = malloc(MAXPKT); - if (!pktbuf) { - report(LOG_ERR, "malloc failed"); - exit(1); - } - bp = (struct bootp *) pktbuf; - - /* - * Check to see if a socket was passed to us from inetd. - * - * Use getsockname() to determine if descriptor 0 is indeed a socket - * (and thus we are probably a child of inetd) or if it is instead - * something else and we are running standalone. - */ - s = 0; - ba_len = sizeof(bind_addr); - bzero((char *) &bind_addr, ba_len); - errno = 0; - standalone = TRUE; - if (getsockname(s, (struct sockaddr *) &bind_addr, &ba_len) == 0) { - /* - * Descriptor 0 is a socket. Assume we are a child of inetd. - */ - if (bind_addr.sin_family == AF_INET) { - standalone = FALSE; - bootps_port = ntohs(bind_addr.sin_port); - } else { - /* Some other type of socket? */ - report(LOG_ERR, "getsockname: not an INET socket"); - } - } - - /* - * Set defaults that might be changed by option switches. - */ - stmp = NULL; - timeout = &actualtimeout; - - /* - * Read switches. - */ - for (argc--, argv++; argc > 0; argc--, argv++) { - if (argv[0][0] != '-') - break; - switch (argv[0][1]) { - - case 'c': /* chdir_path */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (stmp[0] != '/')) { - fprintf(stderr, - "bootpd: invalid chdir specification\n"); - break; - } - chdir_path = stmp; - break; - - case 'd': /* debug level */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else if (argv[1] && argv[1][0] == '-') { - /* - * Backwards-compatible behavior: - * no parameter, so just increment the debug flag. - */ - debug++; - break; - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) { - fprintf(stderr, - "%s: invalid debug level\n", progname); - break; - } - debug = n; - break; - - case 'i': /* inetd mode */ - standalone = FALSE; - break; - - case 's': /* standalone mode */ - standalone = TRUE; - break; - - case 't': /* timeout */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) { - fprintf(stderr, - "%s: invalid timeout specification\n", progname); - break; - } - actualtimeout.tv_sec = (int32) (60 * n); - /* - * If the actual timeout is zero, pass a NULL pointer - * to select so it blocks indefinitely, otherwise, - * point to the actual timeout value. - */ - timeout = (n > 0) ? &actualtimeout : NULL; - break; - -#ifdef YORK_EX_OPTION - case 'x': - if (argc < 2) { - fprintf(stderr, "missing exec_file_name\n"); - break; - } - argc--; argv++; - exec_file_name = argv[1]; - break; -#endif /* YORK_EX_OPTION */ - - default: - fprintf(stderr, "%s: unknown switch: -%c\n", - progname, argv[0][1]); - usage(); - break; - - } /* switch */ - } /* for args */ - - /* - * Override default file names if specified on the command line. - */ - if (argc > 0) - bootptab = argv[0]; - - if (argc > 1) - bootpd_dump = argv[1]; - - /* - * Get my hostname and IP address. - */ - if (gethostname(hostname, sizeof(hostname)) == -1) { - fprintf(stderr, "bootpd: can't get hostname\n"); - exit(1); - } - hep = gethostbyname(hostname); - if (!hep) { - fprintf(stderr, "Can not get my IP address\n"); - exit(1); - } - bcopy(hep->h_addr, (char *)&my_ip_addr, sizeof(my_ip_addr)); - - if (standalone) { - /* - * Go into background and disassociate from controlling terminal. - */ - if (debug < 3) { - if (fork()) - exit(0); -#ifdef NO_SETSID - setpgrp(0,0); -#ifdef TIOCNOTTY - n = open("/dev/tty", O_RDWR); - if (n >= 0) { - ioctl(n, TIOCNOTTY, (char *) 0); - (void) close(n); - } -#endif /* TIOCNOTTY */ -#else /* SETSID */ - if (setsid() < 0) - perror("setsid"); -#endif /* SETSID */ - } /* if debug < 3 */ - - /* - * Nuke any timeout value - */ - timeout = NULL; - - } /* if standalone (1st) */ - - /* Set the cwd (i.e. to /tftpboot) */ - if (chdir_path) { - if (chdir(chdir_path) < 0) - report(LOG_ERR, "%s: chdir failed", chdir_path); - } - - /* Get the timezone. */ - tzone_init(); - - /* Allocate hash tables. */ - rdtab_init(); - - /* - * Read the bootptab file. - */ - readtab(1); /* force read */ - - if (standalone) { - - /* - * Create a socket. - */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - report(LOG_ERR, "socket: %s", get_network_errmsg()); - exit(1); - } - - /* - * Get server's listening port number - */ - servp = getservbyname("bootps", "udp"); - if (servp) { - bootps_port = ntohs((u_short) servp->s_port); - } else { - bootps_port = (u_short) IPPORT_BOOTPS; - report(LOG_ERR, - "udp/bootps: unknown service -- assuming port %d", - bootps_port); - } - - /* - * Bind socket to BOOTPS port. - */ - bind_addr.sin_family = AF_INET; - bind_addr.sin_addr.s_addr = INADDR_ANY; - bind_addr.sin_port = htons(bootps_port); - if (bind(s, (struct sockaddr *) &bind_addr, - sizeof(bind_addr)) < 0) - { - report(LOG_ERR, "bind: %s", get_network_errmsg()); - exit(1); - } - } /* if standalone (2nd)*/ - - /* - * Get destination port number so we can reply to client - */ - servp = getservbyname("bootpc", "udp"); - if (servp) { - bootpc_port = ntohs(servp->s_port); - } else { - report(LOG_ERR, - "udp/bootpc: unknown service -- assuming port %d", - IPPORT_BOOTPC); - bootpc_port = (u_short) IPPORT_BOOTPC; - } - - /* - * Set up signals to read or dump the table. - */ - if ((int) signal(SIGHUP, catcher) < 0) { - report(LOG_ERR, "signal: %s", get_errmsg()); - exit(1); - } - if ((int) signal(SIGUSR1, catcher) < 0) { - report(LOG_ERR, "signal: %s", get_errmsg()); - exit(1); - } - - /* - * Process incoming requests. - */ - for (;;) { - readfds = 1 << s; - nfound = select(s + 1, (fd_set *)&readfds, NULL, NULL, timeout); - if (nfound < 0) { - if (errno != EINTR) { - report(LOG_ERR, "select: %s", get_errmsg()); - } - /* - * Call readtab() or dumptab() here to avoid the - * dangers of doing I/O from a signal handler. - */ - if (do_readtab) { - do_readtab = 0; - readtab(1); /* force read */ - } - if (do_dumptab) { - do_dumptab = 0; - dumptab(bootpd_dump); - } - continue; - } - if (!(readfds & (1 << s))) { - if (debug > 1) - report(LOG_INFO, "exiting after %ld minutes of inactivity", - actualtimeout.tv_sec / 60); - exit(0); - } - ra_len = sizeof(recv_addr); - n = recvfrom(s, pktbuf, MAXPKT, 0, - (struct sockaddr *) &recv_addr, &ra_len); - if (n <= 0) { - continue; - } - if (debug > 1) { - report(LOG_INFO, "recvd pkt from IP addr %s", - inet_ntoa(recv_addr.sin_addr)); - } - if (n < sizeof(struct bootp)) { - if (debug) { - report(LOG_INFO, "received short packet"); - } - continue; - } - pktlen = n; - - readtab(0); /* maybe re-read bootptab */ - - switch (bp->bp_op) { - case BOOTREQUEST: - handle_request(); - break; - case BOOTREPLY: - handle_reply(); - break; - } - } -} - - - - -/* - * Print "usage" message and exit - */ - -PRIVATE void -usage() -{ - fprintf(stderr, - "usage: bootpd [-d level] [-i] [-s] [-t timeout] [configfile [dumpfile]]\n"); - fprintf(stderr, "\t -c n\tset current directory\n"); - fprintf(stderr, "\t -d n\tset debug level\n"); - fprintf(stderr, "\t -i\tforce inetd mode (run as child of inetd)\n"); - fprintf(stderr, "\t -s\tforce standalone mode (run without inetd)\n"); - fprintf(stderr, "\t -t n\tset inetd exit timeout to n minutes\n"); - exit(1); -} - -/* Signal catchers */ -PRIVATE void -catcher(sig) - int sig; -{ - if (sig == SIGHUP) - do_readtab = 1; - if (sig == SIGUSR1) - do_dumptab = 1; -#ifdef SYSV - /* For older "System V" derivatives with no sigset(). */ - /* XXX - Should just do it the POSIX way (sigaction). */ - signal(sig, catcher); -#endif -} - - - -/* - * Process BOOTREQUEST packet. - * - * Note: This version of the bootpd.c server never forwards - * a request to another server. That is the job of a gateway - * program such as the "bootpgw" program included here. - * - * (Also this version does not interpret the hostname field of - * the request packet; it COULD do a name->address lookup and - * forward the request there.) - */ -PRIVATE void -handle_request() -{ - struct bootp *bp = (struct bootp *) pktbuf; - struct host *hp = NULL; - struct host dummyhost; - int32 bootsize = 0; - unsigned hlen, hashcode; - int32 dest; -#ifdef CHECK_FILE_ACCESS - char realpath[1024]; - char *path; - int n; -#endif - - /* XXX - SLIP init: Set bp_ciaddr = recv_addr here? */ - - /* - * If the servername field is set, compare it against us. - * If we're not being addressed, ignore this request. - * If the server name field is null, throw in our name. - */ - if (strlen(bp->bp_sname)) { - if (strcmp(bp->bp_sname, hostname)) { - if (debug) - report(LOG_INFO, "\ -ignoring request for server %s from client at %s address %s", - bp->bp_sname, netname(bp->bp_htype), - haddrtoa(bp->bp_chaddr, bp->bp_hlen)); - /* XXX - Is it correct to ignore such a request? -gwr */ - return; - } - } else { - strcpy(bp->bp_sname, hostname); - } - - bp->bp_op = BOOTREPLY; - if (bp->bp_ciaddr.s_addr == 0) { - /* - * client doesnt know his IP address, - * search by hardware address. - */ - if (debug > 1) { - report(LOG_INFO, "request from %s address %s", - netname(bp->bp_htype), - haddrtoa(bp->bp_chaddr, bp->bp_hlen)); - } - hlen = haddrlength(bp->bp_htype); - if (hlen != bp->bp_hlen) { - report(LOG_NOTICE, "bad addr len from from %s address %s", - netname(bp->bp_htype), - haddrtoa(bp->bp_chaddr, hlen)); - } - dummyhost.htype = bp->bp_htype; - bcopy(bp->bp_chaddr, dummyhost.haddr, hlen); - hashcode = hash_HashFunction(bp->bp_chaddr, hlen); - hp = (struct host *) hash_Lookup(hwhashtable, hashcode, hwlookcmp, - &dummyhost); - if (hp == NULL && - bp->bp_htype == HTYPE_IEEE802) - { - /* Try again with address in "canonical" form. */ - haddr_conv802(bp->bp_chaddr, dummyhost.haddr, hlen); - if (debug > 1) { - report(LOG_INFO, "\ -HW addr type is IEEE 802. convert to %s and check again\n", - haddrtoa(dummyhost.haddr, bp->bp_hlen)); - } - hashcode = hash_HashFunction(dummyhost.haddr, hlen); - hp = (struct host *) hash_Lookup(hwhashtable, hashcode, - hwlookcmp, &dummyhost); - } - if (hp == NULL) { - /* - * XXX - Add dynamic IP address assignment? - */ - if (debug > 1) - report(LOG_INFO, "unknown client %s address %s", - netname(bp->bp_htype), - haddrtoa(bp->bp_chaddr, bp->bp_hlen)); - return; /* not found */ - } - (bp->bp_yiaddr).s_addr = hp->iaddr.s_addr; - - } else { - - /* - * search by IP address. - */ - if (debug > 1) { - report(LOG_INFO, "request from IP addr %s", - inet_ntoa(bp->bp_ciaddr)); - } - dummyhost.iaddr.s_addr = bp->bp_ciaddr.s_addr; - hashcode = hash_HashFunction((u_char *) &(bp->bp_ciaddr.s_addr), 4); - hp = (struct host *) hash_Lookup(iphashtable, hashcode, iplookcmp, - &dummyhost); - if (hp == NULL) { - if (debug > 1) { - report(LOG_NOTICE, "IP address not found: %s", - inet_ntoa(bp->bp_ciaddr)); - } - return; - } - } - - if (debug) { - report(LOG_INFO, "found %s (%s)", inet_ntoa(hp->iaddr), - hp->hostname->string); - } - -#ifdef YORK_EX_OPTION - /* - * The need for the "ex" tag arose out of the need to empty - * shared networked drives on diskless PCs. This solution is - * not very clean but it does work fairly well. - * Written by Edmund J. Sutcliffe - */ - /* Run a program, passing the client name as a parameter. */ - if (exec_file_name) { - char tst[100]; - strcpy (tst, exec_file_name); - strcat (tst, " "); - strcat (tst, hp->hostname->string); - strcat (tst, " &"); - if (debug) - report(LOG_INFO, "executing %s", tst); - system(tst); /* Hope this finishes soon... */ - } -#endif /* YORK_EX_OPTION */ - - /* - * If a specific TFTP server address was specified in the bootptab file, - * fill it in, otherwise zero it. - * XXX - Rather than zero it, should it be the bootpd address? -gwr - */ - (bp->bp_siaddr).s_addr = (hp->flags.bootserver) ? - hp->bootserver.s_addr : 0L; - -#ifdef STANFORD_PROM_COMPAT - /* - * Stanford bootp PROMs (for a Sun?) have no way to leave - * the boot file name field blank (because the boot file - * name is automatically generated from some index). - * As a work-around, this little hack allows those PROMs to - * specify "sunboot14" with the same effect as a NULL name. - * (The user specifies boot device 14 or some such magic.) - */ - if (strcmp(bp->bp_file, "sunboot14") == 0) - bp->bp_file[0] = '\0'; /* treat it as unspecified */ -#endif - - /* - * Fill in the client's proper bootfile. - * - * If the client specifies an absolute path, try that file with a - * ".host" suffix and then without. If the file cannot be found, no - * reply is made at all. - * - * If the client specifies a null or relative file, use the following - * table to determine the appropriate action: - * - * Homedir Bootfile Client's file - * specified? specified? specification Action - * ------------------------------------------------------------------- - * No No Null Send null filename - * No No Relative Discard request - * No Yes Null Send if absolute else null - * No Yes Relative Discard request *XXX - * Yes No Null Send null filename - * Yes No Relative Lookup with ".host" - * Yes Yes Null Send home/boot or bootfile - * Yes Yes Relative Lookup with ".host" *XXX - * - */ - - /* - * XXX - I think the above policy is too complicated. When the - * boot file is missing, it is not obvious why bootpd will not - * respond to client requests. Define CHECK_FILE_ACCESS if you - * want the original complicated policy, otherwise bootpd will - * no longer check for existence of the boot file. -gwr - */ - -#ifdef CHECK_FILE_ACCESS - - if (hp->flags.tftpdir) { - strcpy(realpath, hp->tftpdir->string); - path = &realpath[strlen(realpath)]; - } else { - path = realpath; - } - - if (bp->bp_file[0]) { - /* - * The client specified a file. - */ - if (bp->bp_file[0] == '/') { - strcpy(path, bp->bp_file); /* Absolute pathname */ - } else { - if (hp->flags.homedir) { - strcpy(path, hp->homedir->string); - strcat(path, "/"); - strcat(path, bp->bp_file); - } else { - report(LOG_NOTICE, - "requested file \"%s\" not found: hd unspecified", - bp->bp_file); - return; - } - } - } else { - /* - * No file specified by the client. - */ - if (hp->flags.bootfile && ((hp->bootfile->string)[0] == '/')) { - strcpy(path, hp->bootfile->string); - } else if (hp->flags.homedir && hp->flags.bootfile) { - strcpy(path, hp->homedir->string); - strcat(path, "/"); - strcat(path, hp->bootfile->string); - } else { - bzero(bp->bp_file, sizeof(bp->bp_file)); - goto skip_file; /* Don't bother trying to access the file */ - } - } - - /* - * First try to find the file with a ".host" suffix - */ - n = strlen(path); - strcat(path, "."); - strcat(path, hp->hostname->string); - if (chk_access(realpath, &bootsize) < 0) { - path[n] = 0; /* Try it without the suffix */ - if (chk_access(realpath, &bootsize) < 0) { - if (bp->bp_file[0]) { - /* - * Client wanted specific file - * and we didn't have it. - */ - report(LOG_NOTICE, - "requested file not found: \"%s\"", path); - return; - } else { - /* - * Client didn't ask for a specific file and we couldn't - * access the default file, so just zero-out the bootfile - * field in the packet and continue processing the reply. - */ - bzero(bp->bp_file, sizeof(bp->bp_file)); - goto skip_file; - } - } - } - strcpy(bp->bp_file, path); - - skip_file: - ; - -#else /* CHECK_FILE_ACCESS */ - - /* - * This implements a simple response policy, where bootpd - * will fail to respond only if it knows nothing about - * the client that sent the request. This plugs in the - * boot file name but does not demand that it exist. - * - * If either the client or the server specifies a boot file, - * build the path name for it. Server boot file preferred. - */ - if (bp->bp_file[0] || hp->flags.bootfile) { - char requested_file[BP_FILE_LEN]; - char *given_file; - char *p = bp->bp_file; - int space = BP_FILE_LEN; - int n; - - /* Save client's requested file name. */ - strncpy(requested_file, bp->bp_file, BP_FILE_LEN); - - /* If tftpdir is set, insert it. */ - if (hp->flags.tftpdir) { - n = strlen(hp->tftpdir->string); - if ((n+1) >= space) - goto nospc; - strcpy(p, hp->tftpdir->string); - p += n; - space -= n; - } - - /* If homedir is set, insert it. */ - if (hp->flags.homedir) { - n = strlen(hp->homedir->string); - if ((n+1) >= space) - goto nospc; - strcpy(p, hp->homedir->string); - p += n; - space -= n; - } - - /* Finally, append the boot file name. */ - if (hp->flags.bootfile) - given_file = hp->bootfile->string; - else - given_file = requested_file; - assert(given_file); - n = strlen(given_file); - if ((n+1) >= space) - goto nospc; - strcpy(p, given_file); - p += n; - space -= n; - *p = '\0'; - - if (space <= 0) { - nospc: - report(LOG_ERR, "boot file path too long (%s)", - hp->hostname->string); - } - } - - /* Determine boot file size if requested. */ - if (hp->flags.bootsize_auto) { - if (bp->bp_file[0] == '\0' || - chk_access(bp->bp_file, &bootsize) < 0) - { - report(LOG_ERR, "can not determine boot file size for %s", - hp->hostname->string); - } - } - -#endif /* CHECK_FILE_ACCESS */ - - - if (debug > 1) { - report(LOG_INFO, "vendor magic field is %d.%d.%d.%d", - (int) ((bp->bp_vend)[0]), - (int) ((bp->bp_vend)[1]), - (int) ((bp->bp_vend)[2]), - (int) ((bp->bp_vend)[3])); - } - /* - * If this host isn't set for automatic vendor info then copy the - * specific cookie into the bootp packet, thus forcing a certain - * reply format. Only force reply format if user specified it. - */ - if (hp->flags.vm_cookie) { - /* Slam in the user specified magic number. */ - bcopy(hp->vm_cookie, bp->bp_vend, 4); - } - /* - * Figure out the format for the vendor-specific info. - * Note that bp->bp_vend may have been set above. - */ - if (!bcmp(bp->bp_vend, vm_rfc1048, 4)) { - /* RFC1048 conformant bootp client */ - dovend_rfc1048(bp, hp, bootsize); - if (debug > 1) { - report(LOG_INFO, "sending reply (with RFC1048 options)"); - } - } -#ifdef VEND_CMU - else if (!bcmp(bp->bp_vend, vm_cmu, 4)) { - dovend_cmu(bp, hp); - if (debug > 1) { - report(LOG_INFO, "sending reply (with CMU options)"); - } - } -#endif - else { - if (debug > 1) { - report(LOG_INFO, "sending reply (with no options)"); - } - } - - dest = (hp->flags.reply_addr) ? - hp->reply_addr.s_addr : 0L; - - /* not forwarded */ - sendreply(0, dest); -} - - -/* - * Process BOOTREPLY packet. - */ -PRIVATE void -handle_reply() -{ - if (debug) { - report(LOG_INFO, "processing boot reply"); - } - /* forwarded, no destination override */ - sendreply(1, 0); -} - - -/* - * Send a reply packet to the client. 'forward' flag is set if we are - * not the originator of this reply packet. - */ -PRIVATE void -sendreply(forward, dst_override) - int forward; - int32 dst_override; -{ - struct bootp *bp = (struct bootp *) pktbuf; - struct in_addr dst; - u_short port = bootpc_port; -#if 0 - u_char canon_haddr[MAXHADDRLEN]; -#endif - unsigned char *ha; - int len; - - /* - * If the destination address was specified explicitly - * (i.e. the broadcast address for HP compatiblity) - * then send the response to that address. Otherwise, - * act in accordance with RFC951: - * If the client IP address is specified, use that - * else if gateway IP address is specified, use that - * else make a temporary arp cache entry for the client's - * NEW IP/hardware address and use that. - */ - if (dst_override) { - dst.s_addr = dst_override; - if (debug > 1) { - report(LOG_INFO, "reply address override: %s", - inet_ntoa(dst)); - } - } else if (bp->bp_ciaddr.s_addr) { - dst = bp->bp_ciaddr; - } else if (bp->bp_giaddr.s_addr && forward == 0) { - dst = bp->bp_giaddr; - port = bootps_port; - if (debug > 1) { - report(LOG_INFO, "sending reply to gateway %s", - inet_ntoa(dst)); - } - } else { - dst = bp->bp_yiaddr; - ha = bp->bp_chaddr; - len = bp->bp_hlen; - if (len > MAXHADDRLEN) - len = MAXHADDRLEN; -#if 0 - /* - * XXX - Is this necessary, given that the HW address - * in bp_chaddr was left as the client provided it? - * Does some DEC version of TCP/IP need this? -gwr - */ - if (bp->bp_htype == HTYPE_IEEE802) { - haddr_conv802(ha, canon_haddr, len); - ha = canon_haddr; - } -#endif - if (debug > 1) - report(LOG_INFO, "setarp %s - %s", - inet_ntoa(dst), haddrtoa(ha, len)); - setarp(s, &dst, ha, len); - } - - if ((forward == 0) && - (bp->bp_siaddr.s_addr == 0)) - { - struct ifreq *ifr; - struct in_addr siaddr; - /* - * If we are originating this reply, we - * need to find our own interface address to - * put in the bp_siaddr field of the reply. - * If this server is multi-homed, pick the - * 'best' interface (the one on the same net - * as the client). Of course, the client may - * be on the other side of a BOOTP gateway... - */ - ifr = getif(s, &dst); - if (ifr) { - struct sockaddr_in *sip; - sip = (struct sockaddr_in *) &(ifr->ifr_addr); - siaddr = sip->sin_addr; - } else { - /* Just use my "official" IP address. */ - siaddr = my_ip_addr; - } - - /* XXX - No need to set bp_giaddr here. */ - - /* Finally, set the server address field. */ - bp->bp_siaddr = siaddr; - } - /* Set up socket address for send. */ - send_addr.sin_family = AF_INET; - send_addr.sin_port = htons(port); - send_addr.sin_addr = dst; - - /* Send reply with same size packet as request used. */ - if (sendto(s, pktbuf, pktlen, 0, - (struct sockaddr *) &send_addr, - sizeof(send_addr)) < 0) - { - report(LOG_ERR, "sendto: %s", get_network_errmsg()); - } -} /* sendreply */ - - -/* nmatch() - now in getif.c */ -/* setarp() - now in hwaddr.c */ - - -/* - * This call checks read access to a file. It returns 0 if the file given - * by "path" exists and is publically readable. A value of -1 is returned if - * access is not permitted or an error occurs. Successful calls also - * return the file size in bytes using the long pointer "filesize". - * - * The read permission bit for "other" users is checked. This bit must be - * set for tftpd(8) to allow clients to read the file. - */ - -PRIVATE int -chk_access(path, filesize) - char *path; - int32 *filesize; -{ - struct stat st; - - if ((stat(path, &st) == 0) && (st.st_mode & (S_IREAD >> 6))) { - *filesize = (int32) st.st_size; - return 0; - } else { - return -1; - } -} - - -/* - * Now in dumptab.c : - * dumptab() - * dump_host() - * list_ipaddresses() - */ - -#ifdef VEND_CMU - -/* - * Insert the CMU "vendor" data for the host pointed to by "hp" into the - * bootp packet pointed to by "bp". - */ - -PRIVATE void -dovend_cmu(bp, hp) - struct bootp *bp; - struct host *hp; -{ - struct cmu_vend *vendp; - struct in_addr_list *taddr; - - /* - * Initialize the entire vendor field to zeroes. - */ - bzero(bp->bp_vend, sizeof(bp->bp_vend)); - - /* - * Fill in vendor information. Subnet mask, default gateway, - * domain name server, ien name server, time server - */ - vendp = (struct cmu_vend *) bp->bp_vend; - strcpy(vendp->v_magic, (char *)vm_cmu); - if (hp->flags.subnet_mask) { - (vendp->v_smask).s_addr = hp->subnet_mask.s_addr; - (vendp->v_flags) |= VF_SMASK; - if (hp->flags.gateway) { - (vendp->v_dgate).s_addr = hp->gateway->addr->s_addr; - } - } - if (hp->flags.domain_server) { - taddr = hp->domain_server; - if (taddr->addrcount > 0) { - (vendp->v_dns1).s_addr = (taddr->addr)[0].s_addr; - if (taddr->addrcount > 1) { - (vendp->v_dns2).s_addr = (taddr->addr)[1].s_addr; - } - } - } - if (hp->flags.name_server) { - taddr = hp->name_server; - if (taddr->addrcount > 0) { - (vendp->v_ins1).s_addr = (taddr->addr)[0].s_addr; - if (taddr->addrcount > 1) { - (vendp->v_ins2).s_addr = (taddr->addr)[1].s_addr; - } - } - } - if (hp->flags.time_server) { - taddr = hp->time_server; - if (taddr->addrcount > 0) { - (vendp->v_ts1).s_addr = (taddr->addr)[0].s_addr; - if (taddr->addrcount > 1) { - (vendp->v_ts2).s_addr = (taddr->addr)[1].s_addr; - } - } - } - /* Log message now done by caller. */ -} /* dovend_cmu */ - -#endif /* VEND_CMU */ - - - -/* - * Insert the RFC1048 vendor data for the host pointed to by "hp" into the - * bootp packet pointed to by "bp". - */ -#define NEED(LEN, MSG) do \ - if (bytesleft < (LEN)) { \ - report(LOG_NOTICE, noroom, \ - hp->hostname->string, MSG); \ - return; \ - } while (0) -PRIVATE void -dovend_rfc1048(bp, hp, bootsize) - struct bootp *bp; - struct host *hp; - int32 bootsize; -{ - int bytesleft, len; - byte *vp; - char *tmpstr; - - static char noroom[] = "%s: No room for \"%s\" option"; - - vp = bp->bp_vend; - bytesleft = sizeof(bp->bp_vend); /* Initial vendor area size */ - bcopy(vm_rfc1048, vp, 4); /* Copy in the magic cookie */ - vp += 4; - bytesleft -= 4; - - if (hp->flags.subnet_mask) { - /* always enough room here. */ - *vp++ = TAG_SUBNET_MASK;/* -1 byte */ - *vp++ = 4; /* -1 byte */ - insert_u_long(hp->subnet_mask.s_addr, &vp); /* -4 bytes */ - bytesleft -= 6; /* Fix real count */ - if (hp->flags.gateway) { - (void) insert_ip(TAG_GATEWAY, - hp->gateway, - &vp, &bytesleft); - } - } - if (hp->flags.bootsize) { - /* always enough room here */ - bootsize = (hp->flags.bootsize_auto) ? - ((bootsize + 511) / 512) : (hp->bootsize); /* Round up */ - *vp++ = TAG_BOOT_SIZE; - *vp++ = 2; - *vp++ = (byte) ((bootsize >> 8) & 0xFF); - *vp++ = (byte) (bootsize & 0xFF); - bytesleft -= 4; /* Tag, length, and 16 bit blocksize */ - } - /* - * This one is special: Remaining options go in the ext file. - * Only the subnet_mask, bootsize, and gateway should precede. - */ - if (hp->flags.exten_file) { - /* - * Check for room for exten_file. Add 3 to account for - * TAG_EXTEN_FILE, length, and TAG_END. - */ - len = strlen(hp->exten_file->string); - NEED((len + 3), "ef"); - *vp++ = TAG_EXTEN_FILE; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->exten_file->string, vp, len); - vp += len; - *vp++ = TAG_END; - bytesleft -= len + 3; - return; /* no more options here. */ - } - /* - * The remaining options are inserted by the following - * function (which is shared with bootpef.c). - * Keep back one byte for the TAG_END. - */ - len = dovend_rfc1497(hp, vp, bytesleft - 1); - vp += len; - bytesleft -= len; - - /* There should be at least one byte left. */ - NEED(1, "(end)"); - *vp++ = TAG_END; - bytesleft--; - - /* Log message done by caller. */ - if (bytesleft > 0) { - /* - * Zero out any remaining part of the vendor area. - */ - bzero(vp, bytesleft); - } -} /* dovend_rfc1048 */ -#undef NEED - - -/* - * Now in readfile.c: - * hwlookcmp() - * iplookcmp() - */ - -/* haddrtoa() - now in hwaddr.c */ -/* - * Now in dovend.c: - * insert_ip() - * insert_generic() - * insert_u_long() - */ - -/* get_errmsg() - now in report.c */ - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/bootpd.h b/libexec/bootpd/bootpd.h deleted file mode 100644 index 716204a10d40..000000000000 --- a/libexec/bootpd/bootpd.h +++ /dev/null @@ -1,202 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU 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. -************************************************************************/ - - -/* - * bootpd.h -- common header file for all the modules of the bootpd program. - */ - -#include "bptypes.h" -#include "hash.h" -#include "hwaddr.h" - -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef PRIVATE -#define PRIVATE static -#endif - -#ifndef SIGUSR1 -#define SIGUSR1 30 /* From 4.3 */ -#endif - -#define MAXSTRINGLEN 80 /* Max string length */ - - -/* - * Return pointer to static string which gives full network error message. - */ -#define get_network_errmsg get_errmsg - - -/* - * Data structure used to hold an arbitrary-lengthed list of IP addresses. - * The list may be shared among multiple hosts by setting the linkcount - * appropriately. - */ - -struct in_addr_list { - unsigned int linkcount, addrcount; - struct in_addr addr[1]; /* Dynamically extended */ -}; - - -/* - * Data structures used to hold shared strings and shared binary data. - * The linkcount must be set appropriately. - */ - -struct shared_string { - unsigned int linkcount; - char string[1]; /* Dynamically extended */ -}; - -struct shared_bindata { - unsigned int linkcount, length; - byte data[1]; /* Dynamically extended */ -}; - - -/* - * Flag structure which indicates which symbols have been defined for a - * given host. This information is used to determine which data should or - * should not be reported in the bootp packet vendor info field. - */ - -struct flag { - unsigned bootfile :1, - bootserver :1, - bootsize :1, - bootsize_auto :1, - cookie_server :1, - domain_server :1, - gateway :1, - generic :1, - haddr :1, - homedir :1, - htype :1, - impress_server :1, - iaddr :1, - log_server :1, - lpr_server :1, - name_server :1, - name_switch :1, - rlp_server :1, - send_name :1, - subnet_mask :1, - tftpdir :1, - time_offset :1, - time_server :1, - dump_file :1, - domain_name :1, - swap_server :1, - root_path :1, - exten_file :1, - reply_addr :1, - nis_domain :1, - nis_server :1, - ntp_server :1, - /* XXX - Add new tags here */ - vm_cookie :1; -}; - - - -/* - * The flags structure contains TRUE flags for all the fields which - * are considered valid, regardless of whether they were explicitly - * specified or indirectly inferred from another entry. - * - * The gateway and the various server fields all point to a shared list of - * IP addresses. - * - * The hostname, home directory, and bootfile are all shared strings. - * - * The generic data field is a shared binary data structure. It is used to - * hold future RFC1048 vendor data until bootpd is updated to understand it. - * - * The vm_cookie field specifies the four-octet vendor magic cookie to use - * if it is desired to always send the same response to a given host. - * - * Hopefully, the rest is self-explanatory. - */ - -struct host { - unsigned linkcount; /* hash list inserts */ - struct flag flags; /* ALL valid fields */ - struct in_addr_list *cookie_server, - *domain_server, - *gateway, - *impress_server, - *log_server, - *lpr_server, - *name_server, - *rlp_server, - *time_server, - *nis_server, - *ntp_server; - struct shared_string *bootfile, - *hostname, - *domain_name, - *homedir, - *tftpdir, - *dump_file, - *exten_file, - *root_path, - *nis_domain; - struct shared_bindata *generic; - byte vm_cookie[4], - htype, /* RFC826 says this should be 16-bits but - RFC951 only allocates 1 byte. . . */ - haddr[MAXHADDRLEN]; - int32 time_offset; - unsigned int bootsize; - struct in_addr bootserver, - iaddr, - swap_server, - reply_addr, - subnet_mask; - /* XXX - Add new tags here (or above as appropriate) */ -}; - - - -/* - * Variables shared among modules. - */ - -extern int debug; -extern char *bootptab; -extern char *progname; - -extern u_char vm_cmu[4]; -extern u_char vm_rfc1048[4]; - -extern hash_tbl *hwhashtable; -extern hash_tbl *iphashtable; -extern hash_tbl *nmhashtable; - diff --git a/libexec/bootpd/bootpef.8 b/libexec/bootpd/bootpef.8 deleted file mode 100644 index 0f0b1fc7b437..000000000000 --- a/libexec/bootpd/bootpef.8 +++ /dev/null @@ -1,52 +0,0 @@ -.\" bootpef.8 -.TH BOOTPEF 8 "4 Dec 1993" "MAINTENANCE COMMANDS" -.SH NAME -bootpef \- BOOTP Extension File compiler -.SH SYNOPSIS -.LP -.B bootpef -.RI [ "-c chdir" ] -.RI [ "-d debug-level" ] -.RI [ "-f config-file" ] -.RI [ client-name " [...]]" -.SH DESCRIPTION -.B bootpef -builds the -.I Extension Path -files described by RFC 1497 (tag 18). -If any -.I client-name -arguments are specified, then -.I bootpef -compiles the extension files for only those clients. -.SH OPTIONS -.TP -.BI \-c \ chdir\-path -Sets the current directory used by -.I bootpef -while creating extension files. This is useful when the -extension file names are specified as relative pathnames, and -.I bootpef -needs to use the same current directory as the TFTP server -(typically /tftpboot). -.TP -.BI \-d \ debug\-level -Sets the -.I debug\-level -variable that controls the amount of debugging messages generated. -For example, -d4 or -d 4 will set the debugging level to 4. -.TP -.BI \-f \ config\-file -Set the name of the config file that specifies the option -data to be sent to each client. -.SH "SEE ALSO" -bootpd(8), tftpd(8) -.SH REFERENCES -.TP -RFC951 -BOOTSTRAP PROTOCOL (BOOTP) -.TP -RFC1497 -BOOTP Vendor Information Extensions - - diff --git a/libexec/bootpd/bootpef.c b/libexec/bootpd/bootpef.c deleted file mode 100644 index a769b5e899db..000000000000 --- a/libexec/bootpd/bootpef.c +++ /dev/null @@ -1,347 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU 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. -************************************************************************/ - -#ifndef lint -static char rcsid[] = "$Header: /cvsroot/src/libexec/bootpd/Attic/bootpef.c,v 1.1.1.1 1994/05/27 21:45:11 gwr Exp $"; -#endif - - -/* - * bootpef - BOOTP Extension File generator - * Makes an "Extension File" for each host entry that - * defines an and Extension File. (See RFC1497, tag 18.) - * - * HISTORY - * See ./Changes - * - * BUGS - * See ./ToDo - */ - - - -#ifdef __STDC__ -#include -#else -#include -#endif - -#include -#include - -#include -#include /* inet_ntoa */ - -#ifndef NO_UNISTD -#include -#endif -#include -#include -#include -#include -#include -#include - -#ifndef USE_BFUNCS -#include -/* Yes, memcpy is OK here (no overlapped copies). */ -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bootp.h" -#include "hash.h" -#include "hwaddr.h" -#include "bootpd.h" -#include "dovend.h" -#include "readfile.h" -#include "report.h" -#include "tzone.h" -#include "patchlevel.h" - -#define BUFFERSIZE 0x4000 - -#ifndef CONFIG_FILE -#define CONFIG_FILE "/etc/bootptab" -#endif - - - -/* - * Externals, forward declarations, and global variables - */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -static void dovend_rfc1048 P((struct bootp *, struct host *, int32)); -static void mktagfile P((struct host *)); -static void usage P((void)); - -#undef P - - -/* - * General - */ - -char *progname; -char *chdir_path; -int debug = 0; /* Debugging flag (level) */ -byte *buffer; - -/* - * Globals below are associated with the bootp database file (bootptab). - */ - -char *bootptab = CONFIG_FILE; - - -/* - * Print "usage" message and exit - */ -static void -usage() -{ - fprintf(stderr, - "usage: $s [ -c chdir ] [-d level] [-f configfile] [host...]\n"); - fprintf(stderr, "\t -c n\tset current directory\n"); - fprintf(stderr, "\t -d n\tset debug level\n"); - fprintf(stderr, "\t -f n\tconfig file name\n"); - exit(1); -} - - -/* - * Initialization such as command-line processing is done and then the - * main server loop is started. - */ -void -main(argc, argv) - int argc; - char **argv; -{ - struct host *hp; - char *stmp; - int n; - - progname = strrchr(argv[0], '/'); - if (progname) progname++; - else progname = argv[0]; - - /* Get work space for making tag 18 files. */ - buffer = (byte *) malloc(BUFFERSIZE); - if (!buffer) { - report(LOG_ERR, "malloc failed"); - exit(1); - } - /* - * Set defaults that might be changed by option switches. - */ - stmp = NULL; - - /* - * Read switches. - */ - for (argc--, argv++; argc > 0; argc--, argv++) { - if (argv[0][0] != '-') - break; - switch (argv[0][1]) { - - case 'c': /* chdir_path */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (stmp[0] != '/')) { - fprintf(stderr, - "bootpd: invalid chdir specification\n"); - break; - } - chdir_path = stmp; - break; - - case 'd': /* debug */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else if (argv[1] && argv[1][0] == '-') { - /* - * Backwards-compatible behavior: - * no parameter, so just increment the debug flag. - */ - debug++; - break; - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) { - fprintf(stderr, - "bootpd: invalid debug level\n"); - break; - } - debug = n; - break; - - case 'f': /* config file */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - bootptab = stmp; - break; - - default: - fprintf(stderr, "bootpd: unknown switch: -%c\n", - argv[0][1]); - usage(); - break; - } - } - - /* Get the timezone. */ - tzone_init(); - - /* Allocate hash tables. */ - rdtab_init(); - - /* - * Read the bootptab file. - */ - readtab(1); /* force read */ - - /* Set the cwd (i.e. to /tftpboot) */ - if (chdir_path) { - if (chdir(chdir_path) < 0) - report(LOG_ERR, "%s: chdir failed", chdir_path); - } - /* If there are host names on the command line, do only those. */ - if (argc > 0) { - unsigned int tlen, hashcode; - - while (argc) { - tlen = strlen(argv[0]); - hashcode = hash_HashFunction((u_char *)argv[0], tlen); - hp = (struct host *) hash_Lookup(nmhashtable, - hashcode, - nmcmp, argv[0]); - if (!hp) { - printf("%s: no matching entry\n", argv[0]); - exit(1); - } - if (!hp->flags.exten_file) { - printf("%s: no extension file\n", argv[0]); - exit(1); - } - mktagfile(hp); - argv++; - argc--; - } - exit(0); - } - /* No host names specified. Do them all. */ - hp = (struct host *) hash_FirstEntry(nmhashtable); - while (hp != NULL) { - mktagfile(hp); - hp = (struct host *) hash_NextEntry(nmhashtable); - } -} - - - -/* - * Make a "TAG 18" file for this host. - * (Insert the RFC1497 options.) - */ - -static void -mktagfile(hp) - struct host *hp; -{ - FILE *fp; - int bytesleft, len; - byte *vp; - char *tmpstr; - - if (!hp->flags.exten_file) - return; - - vp = buffer; - bytesleft = BUFFERSIZE; - bcopy(vm_rfc1048, vp, 4); /* Copy in the magic cookie */ - vp += 4; - bytesleft -= 4; - - /* - * The "extension file" options are appended by the following - * function (which is shared with bootpd.c). - */ - len = dovend_rfc1497(hp, vp, bytesleft); - vp += len; - bytesleft -= len; - - if (bytesleft < 1) { - report(LOG_ERR, "%s: too much option data", - hp->exten_file->string); - return; - } - *vp++ = TAG_END; - bytesleft--; - - /* Write the buffer to the extension file. */ - printf("Updating \"%s\"\n", hp->exten_file->string); - if ((fp = fopen(hp->exten_file->string, "w")) == NULL) { - report(LOG_ERR, "error opening \"%s\": %s", - hp->exten_file->string, get_errmsg()); - return; - } - len = vp - buffer; - if (len != fwrite(buffer, 1, len, fp)) { - report(LOG_ERR, "write failed on \"%s\" : %s", - hp->exten_file->string, get_errmsg()); - } - fclose(fp); - -} /* dovend_rfc1048 */ - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/bootpgw.c b/libexec/bootpd/bootpgw.c deleted file mode 100644 index 6097babbdde9..000000000000 --- a/libexec/bootpd/bootpgw.c +++ /dev/null @@ -1,675 +0,0 @@ -/* - * bootpgw.c - BOOTP GateWay - * This program forwards BOOTP Request packets to a BOOTP server. - */ - -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU 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. -************************************************************************/ - -#ifndef lint -static char rcsid[] = "$Header: /cvsroot/src/libexec/bootpd/Attic/bootpgw.c,v 1.1.1.1 1994/05/27 21:45:13 gwr Exp $"; -#endif - -/* - * BOOTPGW is typically used to forward BOOTP client requests from - * one subnet to a BOOTP server on a different subnet. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include /* inet_ntoa */ - -#ifndef NO_UNISTD -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef NO_SETSID -# include /* for O_RDONLY, etc */ -#endif - -#ifndef USE_BFUNCS -# include -/* Yes, memcpy is OK here (no overlapped copies). */ -# define bcopy(a,b,c) memcpy(b,a,c) -# define bzero(p,l) memset(p,0,l) -# define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bootp.h" -#include "getif.h" -#include "hwaddr.h" -#include "report.h" -#include "patchlevel.h" - -/* Local definitions: */ -#define MAXPKT (3*512) /* Maximum packet size */ -#define TRUE 1 -#define FALSE 0 -#define get_network_errmsg get_errmsg - - - -/* - * Externals, forward declarations, and global variables - */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -static void usage P((void)); -static void handle_reply P((void)); -static void handle_request P((void)); - -#undef P - -/* - * IP port numbers for client and server obtained from /etc/services - */ - -u_short bootps_port, bootpc_port; - - -/* - * Internet socket and interface config structures - */ - -struct sockaddr_in bind_addr; /* Listening */ -struct sockaddr_in recv_addr; /* Packet source */ -struct sockaddr_in send_addr; /* destination */ - - -/* - * option defaults - */ -int debug = 0; /* Debugging flag (level) */ -struct timeval actualtimeout = -{ /* fifteen minutes */ - 15 * 60L, /* tv_sec */ - 0 /* tv_usec */ -}; -u_int maxhops = 4; /* Number of hops allowed for requests. */ -u_int minwait = 3; /* Number of seconds client must wait before - its bootrequest packets are forwarded. */ - -/* - * General - */ - -int s; /* Socket file descriptor */ -char *pktbuf; /* Receive packet buffer */ -int pktlen; -char *progname; -char *servername; -int32 server_ipa; /* Real server IP address, network order. */ - -char myhostname[64]; -struct in_addr my_ip_addr; - - - - -/* - * Initialization such as command-line processing is done and then the - * main server loop is started. - */ - -void -main(argc, argv) - int argc; - char **argv; -{ - struct timeval *timeout; - struct bootp *bp; - struct servent *servp; - struct hostent *hep; - char *stmp; - int n, ba_len, ra_len; - int nfound, readfds; - int standalone; - - progname = strrchr(argv[0], '/'); - if (progname) progname++; - else progname = argv[0]; - - /* - * Initialize logging. - */ - report_init(0); /* uses progname */ - - /* - * Log startup - */ - report(LOG_INFO, "version %s.%d", VERSION, PATCHLEVEL); - - /* Debugging for compilers with struct padding. */ - assert(sizeof(struct bootp) == BP_MINPKTSZ); - - /* Get space for receiving packets and composing replies. */ - pktbuf = malloc(MAXPKT); - if (!pktbuf) { - report(LOG_ERR, "malloc failed"); - exit(1); - } - bp = (struct bootp *) pktbuf; - - /* - * Check to see if a socket was passed to us from inetd. - * - * Use getsockname() to determine if descriptor 0 is indeed a socket - * (and thus we are probably a child of inetd) or if it is instead - * something else and we are running standalone. - */ - s = 0; - ba_len = sizeof(bind_addr); - bzero((char *) &bind_addr, ba_len); - errno = 0; - standalone = TRUE; - if (getsockname(s, (struct sockaddr *) &bind_addr, &ba_len) == 0) { - /* - * Descriptor 0 is a socket. Assume we are a child of inetd. - */ - if (bind_addr.sin_family == AF_INET) { - standalone = FALSE; - bootps_port = ntohs(bind_addr.sin_port); - } else { - /* Some other type of socket? */ - report(LOG_INFO, "getsockname: not an INET socket"); - } - } - /* - * Set defaults that might be changed by option switches. - */ - stmp = NULL; - timeout = &actualtimeout; - gethostname(myhostname, sizeof(myhostname)); - hep = gethostbyname(myhostname); - if (!hep) { - printf("Can not get my IP address\n"); - exit(1); - } - bcopy(hep->h_addr, (char *)&my_ip_addr, sizeof(my_ip_addr)); - - /* - * Read switches. - */ - for (argc--, argv++; argc > 0; argc--, argv++) { - if (argv[0][0] != '-') - break; - switch (argv[0][1]) { - - case 'd': /* debug level */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else if (argv[1] && argv[1][0] == '-') { - /* - * Backwards-compatible behavior: - * no parameter, so just increment the debug flag. - */ - debug++; - break; - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) { - fprintf(stderr, - "%s: invalid debug level\n", progname); - break; - } - debug = n; - break; - - case 'h': /* hop count limit */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || - (n < 0) || (n > 16)) - { - fprintf(stderr, - "bootpgw: invalid hop count limit\n"); - break; - } - maxhops = (u_int)n; - break; - - case 'i': /* inetd mode */ - standalone = FALSE; - break; - - case 's': /* standalone mode */ - standalone = TRUE; - break; - - case 't': /* timeout */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) { - fprintf(stderr, - "%s: invalid timeout specification\n", progname); - break; - } - actualtimeout.tv_sec = (int32) (60 * n); - /* - * If the actual timeout is zero, pass a NULL pointer - * to select so it blocks indefinitely, otherwise, - * point to the actual timeout value. - */ - timeout = (n > 0) ? &actualtimeout : NULL; - break; - - case 'w': /* wait time */ - if (argv[0][2]) { - stmp = &(argv[0][2]); - } else { - argc--; - argv++; - stmp = argv[0]; - } - if (!stmp || (sscanf(stmp, "%d", &n) != 1) || - (n < 0) || (n > 60)) - { - fprintf(stderr, - "bootpgw: invalid wait time\n"); - break; - } - minwait = (u_int)n; - break; - - default: - fprintf(stderr, "%s: unknown switch: -%c\n", - progname, argv[0][1]); - usage(); - break; - - } /* switch */ - } /* for args */ - - /* Make sure server name argument is suplied. */ - servername = argv[0]; - if (!servername) { - fprintf(stderr, "bootpgw: missing server name\n"); - usage(); - } - /* - * Get address of real bootp server. - */ - if (isdigit(servername[0])) - server_ipa = inet_addr(servername); - else { - hep = gethostbyname(servername); - if (!hep) { - fprintf(stderr, "bootpgw: can't get addr for %s\n", servername); - exit(1); - } - bcopy(hep->h_addr, (char *)&server_ipa, sizeof(server_ipa)); - } - - if (standalone) { - /* - * Go into background and disassociate from controlling terminal. - * XXX - This is not the POSIX way (Should use setsid). -gwr - */ - if (debug < 3) { - if (fork()) - exit(0); -#ifdef NO_SETSID - setpgrp(0,0); -#ifdef TIOCNOTTY - n = open("/dev/tty", O_RDWR); - if (n >= 0) { - ioctl(n, TIOCNOTTY, (char *) 0); - (void) close(n); - } -#endif /* TIOCNOTTY */ -#else /* SETSID */ - if (setsid() < 0) - perror("setsid"); -#endif /* SETSID */ - } /* if debug < 3 */ - /* - * Nuke any timeout value - */ - timeout = NULL; - - /* - * Here, bootpd would do: - * chdir - * tzone_init - * rdtab_init - * readtab - */ - - /* - * Create a socket. - */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - report(LOG_ERR, "socket: %s", get_network_errmsg()); - exit(1); - } - /* - * Get server's listening port number - */ - servp = getservbyname("bootps", "udp"); - if (servp) { - bootps_port = ntohs((u_short) servp->s_port); - } else { - bootps_port = (u_short) IPPORT_BOOTPS; - report(LOG_ERR, - "udp/bootps: unknown service -- assuming port %d", - bootps_port); - } - - /* - * Bind socket to BOOTPS port. - */ - bind_addr.sin_family = AF_INET; - bind_addr.sin_port = htons(bootps_port); - bind_addr.sin_addr.s_addr = INADDR_ANY; - if (bind(s, (struct sockaddr *) &bind_addr, - sizeof(bind_addr)) < 0) - { - report(LOG_ERR, "bind: %s", get_network_errmsg()); - exit(1); - } - } /* if standalone */ - /* - * Get destination port number so we can reply to client - */ - servp = getservbyname("bootpc", "udp"); - if (servp) { - bootpc_port = ntohs(servp->s_port); - } else { - report(LOG_ERR, - "udp/bootpc: unknown service -- assuming port %d", - IPPORT_BOOTPC); - bootpc_port = (u_short) IPPORT_BOOTPC; - } - - /* no signal catchers */ - - /* - * Process incoming requests. - */ - for (;;) { - readfds = 1 << s; - nfound = select(s + 1, (fd_set *)&readfds, NULL, NULL, timeout); - if (nfound < 0) { - if (errno != EINTR) { - report(LOG_ERR, "select: %s", get_errmsg()); - } - continue; - } - if (!(readfds & (1 << s))) { - report(LOG_INFO, "exiting after %ld minutes of inactivity", - actualtimeout.tv_sec / 60); - exit(0); - } - ra_len = sizeof(recv_addr); - n = recvfrom(s, pktbuf, MAXPKT, 0, - (struct sockaddr *) &recv_addr, &ra_len); - if (n <= 0) { - continue; - } - if (debug > 3) { - report(LOG_INFO, "recvd pkt from IP addr %s", - inet_ntoa(recv_addr.sin_addr)); - } - if (n < sizeof(struct bootp)) { - if (debug) { - report(LOG_INFO, "received short packet"); - } - continue; - } - pktlen = n; - - switch (bp->bp_op) { - case BOOTREQUEST: - handle_request(); - break; - case BOOTREPLY: - handle_reply(); - break; - } - } -} - - - - -/* - * Print "usage" message and exit - */ - -static void -usage() -{ - fprintf(stderr, - "usage: bootpgw [-d level] [-i] [-s] [-t timeout] server\n"); - fprintf(stderr, "\t -d n\tset debug level\n"); - fprintf(stderr, "\t -h n\tset max hop count\n"); - fprintf(stderr, "\t -i\tforce inetd mode (run as child of inetd)\n"); - fprintf(stderr, "\t -s\tforce standalone mode (run without inetd)\n"); - fprintf(stderr, "\t -t n\tset inetd exit timeout to n minutes\n"); - fprintf(stderr, "\t -w n\tset min wait time (secs)\n"); - exit(1); -} - - - -/* - * Process BOOTREQUEST packet. - * - * Note, this just forwards the request to a real server. - */ -static void -handle_request() -{ - struct bootp *bp = (struct bootp *) pktbuf; - struct ifreq *ifr; - u_short secs, hops; - - /* XXX - SLIP init: Set bp_ciaddr = recv_addr here? */ - - if (debug) { - report(LOG_INFO, "request from %s", - inet_ntoa(recv_addr.sin_addr)); - } - /* Has the client been waiting long enough? */ - secs = ntohs(bp->bp_secs); - if (secs < minwait) - return; - - /* Has this packet hopped too many times? */ - hops = ntohs(bp->bp_hops); - if (++hops > maxhops) { - report(LOG_NOTICE, "reqest from %s reached hop limit", - inet_ntoa(recv_addr.sin_addr)); - return; - } - bp->bp_hops = htons(hops); - - /* - * Here one might discard a request from the same subnet as the - * real server, but we can assume that the real server will send - * a reply to the client before it waits for minwait seconds. - */ - - /* If gateway address is not set, put in local interface addr. */ - if (bp->bp_giaddr.s_addr == 0) { -#if 0 /* BUG */ - struct sockaddr_in *sip; - /* - * XXX - This picks the wrong interface when the receive addr - * is the broadcast address. There is no portable way to - * find out which interface a broadcast was received on. -gwr - * (Thanks to for finding this bug!) - */ - ifr = getif(s, &recv_addr.sin_addr); - if (!ifr) { - report(LOG_NOTICE, "no interface for request from %s", - inet_ntoa(recv_addr.sin_addr)); - return; - } - sip = (struct sockaddr_in *) &(ifr->ifr_addr); - bp->bp_giaddr = sip->sin_addr; -#else /* BUG */ - /* - * XXX - Just set "giaddr" to our "official" IP address. - * RFC 1532 says giaddr MUST be set to the address of the - * interface on which the request was received. Setting - * it to our "default" IP address is not strictly correct, - * but is good enough to allow the real BOOTP server to - * get the reply back here. Then, before we forward the - * reply to the client, the giaddr field is corrected. - * (In case the client uses giaddr, which it should not.) - * See handle_reply() - */ - bp->bp_giaddr = my_ip_addr; -#endif /* BUG */ - - /* - * XXX - DHCP says to insert a subnet mask option into the - * options area of the request (if vendor magic == std). - */ - } - /* Set up socket address for send. */ - send_addr.sin_family = AF_INET; - send_addr.sin_port = htons(bootps_port); - send_addr.sin_addr.s_addr = server_ipa; - - /* Send reply with same size packet as request used. */ - if (sendto(s, pktbuf, pktlen, 0, - (struct sockaddr *) &send_addr, - sizeof(send_addr)) < 0) - { - report(LOG_ERR, "sendto: %s", get_network_errmsg()); - } -} - - - -/* - * Process BOOTREPLY packet. - */ -static void -handle_reply() -{ - struct bootp *bp = (struct bootp *) pktbuf; - struct ifreq *ifr; - struct sockaddr_in *sip; - u_char canon_haddr[MAXHADDRLEN]; - unsigned char *ha; - int len; - - if (debug) { - report(LOG_INFO, " reply for %s", - inet_ntoa(bp->bp_yiaddr)); - } - /* Make sure client is directly accessible. */ - ifr = getif(s, &(bp->bp_yiaddr)); - if (!ifr) { - report(LOG_NOTICE, "no interface for reply to %s", - inet_ntoa(bp->bp_yiaddr)); - return; - } -#if 1 /* Experimental (see BUG above) */ -/* #ifdef CATER_TO_OLD_CLIENTS ? */ - /* - * The giaddr field has been set to our "default" IP address - * which might not be on the same interface as the client. - * In case the client looks at giaddr, (which it should not) - * giaddr is now set to the address of the correct interface. - */ - sip = (struct sockaddr_in *) &(ifr->ifr_addr); - bp->bp_giaddr = sip->sin_addr; -#endif - - /* Set up socket address for send to client. */ - send_addr.sin_family = AF_INET; - send_addr.sin_addr = bp->bp_yiaddr; - send_addr.sin_port = htons(bootpc_port); - - /* Create an ARP cache entry for the client. */ - ha = bp->bp_chaddr; - len = bp->bp_hlen; - if (len > MAXHADDRLEN) - len = MAXHADDRLEN; - if (bp->bp_htype == HTYPE_IEEE802) { - haddr_conv802(ha, canon_haddr, len); - ha = canon_haddr; - } - if (debug > 1) - report(LOG_INFO, "setarp %s - %s", - inet_ntoa(bp->bp_yiaddr), haddrtoa(ha, len)); - setarp(s, &bp->bp_yiaddr, ha, len); - - /* Send reply with same size packet as request used. */ - if (sendto(s, pktbuf, pktlen, 0, - (struct sockaddr *) &send_addr, - sizeof(send_addr)) < 0) - { - report(LOG_ERR, "sendto: %s", get_network_errmsg()); - } -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/bootptab.5 b/libexec/bootpd/bootptab.5 deleted file mode 100644 index 9ccd6cbf6c98..000000000000 --- a/libexec/bootpd/bootptab.5 +++ /dev/null @@ -1,395 +0,0 @@ -.\" Copyright (c) 1988, 1989, 1991 Carnegie Mellon University -.\" -.\" $Header: /cvsroot/src/libexec/bootpd/Attic/bootptab.5,v 1.2 1994/05/24 15:20:19 gwr Exp $ -.\" -.TH BOOTPTAB 5 "October 31, 1991" "Carnegie Mellon University" -.UC 6 - -.SH NAME -bootptab \- Internet Bootstrap Protocol server database -.SH DESCRIPTION -The -.I bootptab -file is the configuration database file for -.IR bootpd , -the Internet Bootstrap Protocol server. -It's format is similar to that of -.IR termcap (5) -in which two-character case-sensitive tag symbols are used to -represent host parameters. These parameter declarations are separated by -colons (:), with a general format of: -.PP -.I " hostname:tg=value. . . :tg=value. . . :tg=value. . . ." -.PP -where -.I hostname -is the actual name of a bootp client (or a "dummy entry"), and -.I tg -is a two-character tag symbol. Dummy entries have an invalid hostname -(one with a "." as the first character) and are used to provide -default values used by other entries via the -.B tc=.dummy-entry -mechanism. Most tags must be followed by an equals-sign -and a value as above. Some may also appear in a boolean form with no -value (i.e. -.RI : tg :). -The currently recognized tags are: -.PP -.br - bf Bootfile -.br - bs Bootfile size in 512-octet blocks -.br - cs Cookie server address list -.br - df Merit dump file -.br - dn Domain name -.br - ds Domain name server address list -.br - ef Extension file -.br - gw Gateway address list -.br - ha Host hardware address -.br - hd Bootfile home directory -.br - hn Send client's hostname to client -.br - ht Host hardware type (see Assigned Numbers RFC) -.br - im Impress server address list -.br - ip Host IP address -.br - lg Log server address list -.br - lp LPR server address list -.br - ns IEN-116 name server address list -.br - nt NTP (time) Server (RFC 1129) -.br - ra Reply address override -.br - rl Resource location protocol server address list -.br - rp Root path to mount as root -.br - sa TFTP server address client should use -.br - sm Host subnet mask -.br - sw Swap server address -.br - tc Table continuation (points to similar "template" host entry) -.br - td TFTP root directory used by "secure" TFTP servers -.br - to Time offset in seconds from UTC -.br - ts Time server address list -.br - vm Vendor magic cookie selector -.br - yd YP (NIS) domain name -.br - ys YP (NIS) server address - -.PP -There is also a generic tag, -.RI T n , -where -.I n -is an RFC1084 vendor field tag number. Thus it is possible to immediately -take advantage of future extensions to RFC1084 without being forced to modify -.I bootpd -first. Generic data may be represented as either a stream of hexadecimal -numbers or as a quoted string of ASCII characters. The length of the generic -data is automatically determined and inserted into the proper field(s) of the -RFC1084-style bootp reply. -.PP -The following tags take a whitespace-separated list of IP addresses: -.BR cs , -.BR ds , -.BR gw , -.BR im , -.BR lg , -.BR lp , -.BR ns , -.BR nt , -.BR ra , -.BR rl , -and -.BR ts . -The -.BR ip , -.BR sa , -.BR sw , -.BR sm , -and -.B ys -tags each take a single IP address. -All IP addresses are specified in standard Internet "dot" notation -and may use decimal, octal, or hexadecimal numbers -(octal numbers begin with 0, hexadecimal numbers begin with '0x' or '0X'). -Any IP addresses may alternatively be specified as a hostname, causing -.I bootpd -to lookup the IP address for that host name using gethostbyname(3). -If the -.B ip -tag is not specified, -.I bootpd -will determine the IP address using the entry name as the host name. -(Dummy entries use an invalid host name to avoid automatic IP lookup.) -.PP -The -.B ht -tag specifies the hardware type code as either an unsigned decimal, octal, or -hexadecimal integer or one of the following symbolic names: -.B ethernet -or -.B ether -for 10Mb Ethernet, -.B ethernet3 -or -.B ether3 -for 3Mb experimental Ethernet, -.BR ieee802 , -.BR tr , -or -.B token-ring -for IEEE 802 networks, -.B pronet -for Proteon ProNET Token Ring, or -.BR chaos , -.BR arcnet , -or -.B ax.25 -for Chaos, ARCNET, and AX.25 Amateur Radio networks, respectively. -The -.B ha -tag takes a hardware address which may be specified as a host name -or in numeric form. Note that the numeric form -.I must -be specified in hexadecimal; optional periods and/or a leading '0x' may be -included for readability. The -.B ha -tag must be preceded by the -.B ht -tag (either explicitly or implicitly; see -.B tc -below). -If the hardware address is not specified and the type is specified -as either "ethernet" or "ieee802", then -.I bootpd -will try to determine the hardware address using ether_hton(3). -.PP -The hostname, home directory, and bootfile are ASCII strings which may be -optionally surrounded by double quotes ("). The client's request and the -values of the -.B hd -and -.B bf -symbols determine how the server fills in the bootfile field of the bootp -reply packet. -.PP -If the client provides a file name it is left as is. -Otherwise, if the -.B bf -option is specified its value is copied into the reply packet. -If the -.B hd -option is specified as well, its value is prepended to the -boot file copied into the reply packet. -The existence of the boot file is checked only if the -.BR bs =auto -option is used (to determine the boot file size). -A reply may be sent whether or not the boot file exists. -.PP -Some newer versions of -.I tftpd -provide a security feature to change their root directory using -the -.IR chroot (2) -system call. -The -.B td -tag may be used to inform -.I bootpd -of this special root directory used by -.IR tftpd . -(One may alternatively use the -.I bootpd -"-c chdir" option.) -The -.B hd -tag is actually relative to the root directory specified by the -.B td -tag. -For example, if the real absolute path to your BOOTP client bootfile is -/tftpboot/bootfiles/bootimage, and -.IR tftpd -uses /tftpboot as its "secure" directory, then specify the following in -.IR bootptab : -.PP -.br - :td=/tftpboot:hd=/bootfiles:bf=bootimage: -.PP -If your bootfiles are located directly in /tftpboot, use: -.PP -.br - :td=/tftpboot:hd=/:bf=bootimage: -.PP -The -.B sa -tag may be used to specify the IP address of the particular TFTP server -you wish the client to use. In the absence of this tag, -.I bootpd -will tell the client to perform TFTP to the same machine -.I bootpd -is running on. -.PP -The time offset -.B to -may be either a signed decimal integer specifying the client's -time zone offset in seconds from UTC, or the keyword -.B auto -which uses the server's time zone offset. Specifying the -.B to -symbol as a boolean has the same effect as specifying -.B auto -as its value. -.PP -The bootfile size -.B bs -may be either a decimal, octal, or hexadecimal integer specifying the size of -the bootfile in 512-octet blocks, or the keyword -.B auto -which causes the server to automatically calculate the bootfile size at each -request. As with the time offset, specifying the -.B bs -symbol as a boolean has the same effect as specifying -.B auto -as its value. -.PP -The vendor magic cookie selector (the -.B vm -tag) may take one of the following keywords: -.B auto -(indicating that vendor information is determined by the client's request), -.B rfc1048 -or -.B rfc1084 -(which always forces an RFC1084-style reply), or -.B cmu -(which always forces a CMU-style reply). -.PP -The -.B hn -tag is strictly a boolean tag; it does not take the usual equals-sign and -value. It's presence indicates that the hostname should be sent to RFC1084 -clients. -.I Bootpd -attempts to send the entire hostname as it is specified in the configuration -file; if this will not fit into the reply packet, the name is shortened to -just the host field (up to the first period, if present) and then tried. -In no case is an arbitrarily-truncated hostname sent (if nothing reasonable -will fit, nothing is sent). -.PP -Often, many host entries share common values for certain tags (such as name -servers, etc.). Rather than repeatedly specifying these tags, a full -specification can be listed for one host entry and shared by others via the -.B tc -(table continuation) mechanism. -Often, the template entry is a dummy host which doesn't actually exist and -never sends bootp requests. This feature is similar to the -.B tc -feature of -.IR termcap (5) -for similar terminals. Note that -.I bootpd -allows the -.B tc -tag symbol to appear anywhere in the host entry, unlike -.I termcap -which requires it to be the last tag. Information explicitly specified for a -host always overrides information implied by a -.B tc -tag symbol, regardless of its location within the entry. The -value of the -.B tc -tag may be the hostname or IP address of any host entry -previously listed in the configuration file. -.PP -Sometimes it is necessary to delete a specific tag after it has been inferred -via -.BR tc . -This can be done using the construction -.IB tag @ -which removes the effect of -.I tag -as in -.IR termcap (5). -For example, to completely undo an IEN-116 name server specification, use -":ns@:" at an appropriate place in the configuration entry. After removal -with -.BR @ , -a tag is eligible to be set again through the -.B tc -mechanism. -.PP -Blank lines and lines beginning with "#" are ignored in the configuration -file. Host entries are separated from one another by newlines; a single host -entry may be extended over multiple lines if the lines end with a backslash -(\\). It is also acceptable for lines to be longer than 80 characters. Tags -may appear in any order, with the following exceptions: the hostname must be -the very first field in an entry, and the hardware type must precede the -hardware address. -.PP -An example -.I /etc/bootptab -file follows: -.PP -.nf - # Sample bootptab file (domain=andrew.cmu.edu) - - .default:\\ - :hd=/usr/boot:bf=null:\\ - :ds=netserver, lancaster:\\ - :ns=pcs2, pcs1:\\ - :ts=pcs2, pcs1:\\ - :sm=255.255.255.0:\\ - :gw=gw.cs.cmu.edu:\\ - :hn:to=-18000: - - carnegie:ht=6:ha=7FF8100000AF:tc=.default: - baldwin:ht=1:ha=0800200159C3:tc=.default: - wylie:ht=1:ha=00DD00CADF00:tc=.default: - arnold:ht=1:ha=0800200102AD:tc=.default: - bairdford:ht=1:ha=08002B02A2F9:tc=.default: - bakerstown:ht=1:ha=08002B0287C8:tc=.default: - - # Special domain name server and option tags for next host - butlerjct:ha=08002001560D:ds=128.2.13.42:\\ - :T37=0x12345927AD3BCF:\\ - :T99="Special ASCII string":\\ - :tc=.default: - - gastonville:ht=6:ha=7FFF81000A47:tc=.default: - hahntown:ht=6:ha=7FFF81000434:tc=.default: - hickman:ht=6:ha=7FFF810001BA:tc=.default: - lowber:ht=1:ha=00DD00CAF000:tc=.default: - mtoliver:ht=1:ha=00DD00FE1600:tc=.default: - -.fi -.SH FILES -/etc/bootptab - -.SH "SEE ALSO" -.br -bootpd(8), tftpd(8), -.br -DARPA Internet Request For Comments RFC951, RFC1048, RFC1084, Assigned Numbers diff --git a/libexec/bootpd/bootptab.cmu b/libexec/bootpd/bootptab.cmu deleted file mode 100644 index 66212d421a23..000000000000 --- a/libexec/bootpd/bootptab.cmu +++ /dev/null @@ -1,124 +0,0 @@ -# /etc/bootptab: database for bootp server (/etc/bootpd) -# (I've hacked on this but can't test it... -gwr) - -# Blank lines and lines beginning with '#' are ignored. -# -# Legend: (see bootptab.5) -# first field -- hostname (not indented) -# bf -- bootfile -# bs -- bootfile size in 512-octet blocks -# cs -- cookie servers -# df -- dump file name -# dn -- domain name -# ds -- domain name servers -# ef -- extension file -# gw -- gateways -# ha -- hardware address -# hd -- home directory for bootfiles -# hn -- host name set for client -# ht -- hardware type -# im -- impress servers -# ip -- host IP address -# lg -- log servers -# lp -- LPR servers -# ns -- IEN-116 name servers -# ra -- reply address -# rl -- resource location protocol servers -# rp -- root path -# sa -- boot server address -# sm -- subnet mask -# sw -- swap server -# tc -- template host (points to similar host entry) -# td -- TFTP directory -# to -- time offset (seconds) -# ts -- time servers -# vm -- vendor magic number -# Tn -- generic option tag n -# -# Be careful about including backslashes where they're needed. Weird (bad) -# things can happen when a backslash is omitted where one is intended. -# Also, note that generic option data must be either a string or a -# sequence of bytes where each byte is a two-digit hex value. - -# First, we define a global entry which specifies the stuff every host uses. -# (Host name lookups are relative to the domain: andrew.cmu.edu) -.default:\ - :hn:dn=cmu.edu:\ - :hd=/usr/boot:\ - :ds=netserver, lancaster:\ - :ns=pcs2, pcs1:\ - :ts=pcs2, pcs1:\ - :sm=255.255.0.0:\ - :gw=gw.cs.cmu.edu:\ - to=auto: - - -# Next, we can define different master entries for each subnet. . . -.subnet13 :sm=255.255.255.0:gw=128.2.13.1 :tc=.default: -.subnet19 :sm=255.255.255.0:gw=128.2.19.1 :tc=.default: -.subnet232 :sm=255.255.255.0:gw=128.2.232.1 :tc=.default: - -# -# We should be able to use as many levels of indirection as desired. Use -# your imagination. . . -# - - -# Individual entries (could also have different servers for some/all of these -# hosts, but we don't really use this feature at CMU): - -carnegie:tc=.subnet13:ht=ieee802:ha=7FF8100000AF: -baldwin:tc=.subnet19:ha=0800200159C3: -wylie:tc=.subnet232:ha=00DD00CADF00: -arnold:tc=.subnet19:ha=0800200102AD: -bairdford:tc=.subnet19:ha=08002B02A2F9: -bakerstown:tc=.subnet19:ha=08002B0287C8: -butlerjct:tc=.subnet232:ha=08002001560D: -gastonville:tc=.subnet232:ht=ieee802:ha=7FFF81000A47: -hahntown:tc=.subnet13:ht=ieee802:ha=7FFF81000434: -hickman:tc=.subnet19:ht=ieee802:ha=7FFF810001BA: -lowber:tc=.subnet13:ha=00DD00CAF000: -mtoliver:tc=.subnet19:ha=00DD00FE1600: -osborne:tc=.subnet232:ha=00DD00CAD600: -russelton:tc=.subnet232:ha=080020017FC3: -thornburg:tc=.subnet13:ha=080020012A33: - - -# Hmmm. . . Let's throw in some whitespace for readability. . . . - -andrew: tc=.subnet19:ha=00DD00C88900: -birdville: tc=.subnet19:ha=00DD00FE2D00: -coudersport: tc=.subnet13:ha=00DD00CB1E00: -bridgeville: tc=.subnet232:ha=080020011394: -franklin: tc=.subnet19:ha=08002B02A5D5: -hollidaysburg: tc=.subnet19:ht=ieee802:ha=7FFF810002C8: -honesdale: tc=.subnet19:ha=08002B02F83F: -huntingdon: tc=.subnet19:ha=08002B02E410: -indiana: tc=.subnet13:ha=08002B029BEC: -jimthorpe: tc=.subnet232:ha=08002B02FBBA: -kittanning: tc=.subnet232:ha=08002B0273FC: -lebanon: tc=.subnet232:ha=08002B037F67: -lewisburg: tc=.subnet19:ha=50005A1A0DE4: -middleburg: tc=.subnet232:ha=00DD00FE1200: -aspinwall: tc=.subnet13:ha=08002B03C163: -berlin: tc=.subnet13:ha=00DD000A4400: -norristown: tc=.subnet13:ha=08002001455B: -pottsville: tc=.subnet13:ha=00DD000A3700: -ridgway: tc=.subnet19:ha=08002B029425: -scranton: tc=.subnet232:ha=0800200113A1: -chalfont: tc=.subnet13:ha=08002001124B: -washington: tc=.subnet19:ha=00DD00656E00: -wellsboro: tc=.subnet13:ha=00DD00CB1C00: -bb1: tc=.subnet19:ha=00DD000A1F00: -adamstown: tc=.subnet13:ha=08002B02D0E6: -beta: tc=.subnet19:ha=02070100B197: -carbondale: tc=.subnet232:ha=08002B022A73: -clairton: tc=.subnet19:ha=080020010FD1: -egypt: tc=.subnet13:ha=00DD00847B00: -fairchance: tc=.subnet232:ha=00DD000AB100: -fairhope: tc=.subnet232:ha=00DD00CB0800: -galeton: tc=.subnet232:ha=08002001138C: -imperial: tc=.subnet232:ha=08002001130C: -kingston: tc=.subnet232:ha=080020011382: -knox: tc=.subnet232:ha=50005A1A0D2A: -lakecity: tc=.subnet13:ha=080020011380: diff --git a/libexec/bootpd/bootptab.mcs b/libexec/bootpd/bootptab.mcs deleted file mode 100644 index c12ef71d6fdf..000000000000 --- a/libexec/bootpd/bootptab.mcs +++ /dev/null @@ -1,93 +0,0 @@ -# /etc/bootptab: database for bootp server (/etc/bootpd) -# Last update: gwr, Sun Dec 12 19:00:00 EDT 1993 -# Blank lines and lines beginning with '#' are ignored. -# -# Legend: (see bootptab.5) -# first field -- hostname (not indented) -# bf -- bootfile -# bs -- bootfile size in 512-octet blocks -# cs -- cookie servers -# df -- dump file name -# dn -- domain name -# ds -- domain name servers -# ef -- extension file -# gw -- gateways -# ha -- hardware address -# hd -- home directory for bootfiles -# hn -- host name set for client -# ht -- hardware type -# im -- impress servers -# ip -- host IP address -# lg -- log servers -# lp -- LPR servers -# ns -- IEN-116 name servers -# ra -- reply address -# rl -- resource location protocol servers -# rp -- root path -# sa -- boot server address -# sm -- subnet mask -# sw -- swap server -# tc -- template host (points to similar host entry) -# td -- TFTP directory -# to -- time offset (seconds) -# ts -- time servers -# vm -- vendor magic number -# Tn -- generic option tag n -# -# Be careful about including backslashes where they're needed. Weird (bad) -# things can happen when a backslash is omitted where one is intended. -# Also, note that generic option data must be either a string or a -# sequence of bytes where each byte is a two-digit hex value. - -# First, we define a global entry which specifies the stuff every host uses. - -# If you leave "td" and "hd" unset, run bootpd with the "-c /tftpboot" -# switch so path names (boot files) will be interpreted relative to -# the same directory as tftpd will use as its CWD. -.default:\ - :hn:dn="mc.com":\ - :td=/tftpboot:\ - :ds=merlin, jericho:\ - :to=auto: - -# Next, we can define different master entries for each subnet. . . - -.subnet16:\ - :tc=.default:\ - :sm=255.255.255.0:\ - :gw=merlin:\ - :sa=merlin: - -.subnet17:\ - :tc=.default:\ - :sm=255.255.255.0:\ - :gw=merlin-gw:\ - :sa=merlin-gw: - -# -# We should be able to use as many levels of indirection as desired. Use -# your imagination. . . -# - -# Individual entries (could also have different servers for some/all of these -# hosts, but we don't really use this feature at CMU): - -# Emulex terminal server -emulex: tc=.subnet16:ha=00.00.C9.00.42.E0:bf=P4KTL0E: - -# Lantronix eps1 -eps1: tc=.subnet16:ha=00.80.A3.04.1D.78: - -# Tadpole 885 board. -tp885: tc=.subnet17:ha=08.00.4C.00.2F.74:bf=tp885sys2.cfe: - -# MVME147 VxWorks board. -mvme147:tc=.subnet17:ha=08.00.3e.20.da.47:bf=mv147vxw.st: - -# These are just for testing - -walnut:tc=.subnet16:ha=walnut:sa=merlin-gw:\ - :td@:hd=/export/walnut/: - -banana:tc=.subnet17:ha=banana:bf=boot.sun4c: -thor:tc=.subnet17:ha=thor:bf=boot.sun4e: diff --git a/libexec/bootpd/bootptest.8 b/libexec/bootpd/bootptest.8 deleted file mode 100644 index a564bcf0a337..000000000000 --- a/libexec/bootpd/bootptest.8 +++ /dev/null @@ -1,56 +0,0 @@ -.\" bootptest.8 -.TH BOOTPTEST 8 "10 June 1993" "MAINTENANCE COMMANDS" -.SH NAME -bootptest \- send BOOTP queries and print responses -.SH SYNOPSIS -.LP -.B bootptest -[ -.B \-h -] -.I server\-name -.RI [ template-file ] -.SH DESCRIPTION -.B bootptest -sends BOOTP requests to the host specified as -.I server\-name -at one\-second intervals until either a response is received, -or until ten requests have gone unanswered. -After a response is received, -.B bootptest -will wait one more second listening for additional responses. -.SH OPTIONS -.TP -.B \-h -Use the hardware (Ethernet) address to identify the client. -By default, the IP address is copied into the request -indicating that this client already knows its IP address. -.LP -A -.I template-file -may be specified, in which case -.B bootptest -uses the (binary) contents of this file to initialize the -.I options -area of the request packet. -.SH CREDITS -.LP -The bootptest program is a combination of original and derived works. -The main program module (bootptest.c) is original work by -Gordon W. Ross . -The packet printing module (print-bootp.c) is a slightly modified -version of a file from the BSD tcpdump program. -.LP -This program includes software developed by the University of -California, Lawrence Berkeley Laboratory and its contributors. -(See the copyright notice in print-bootp.c) -.SH "SEE ALSO" -.LP -bootpd(8) -.SH REFERENCES -.TP -RFC951 -BOOTSTRAP PROTOCOL (BOOTP) -.TP -RFC1048 -BOOTP Vendor Information Extensions diff --git a/libexec/bootpd/bootptest.c b/libexec/bootpd/bootptest.c deleted file mode 100644 index b288641232ef..000000000000 --- a/libexec/bootpd/bootptest.c +++ /dev/null @@ -1,484 +0,0 @@ -/* - * bootptest.c - Test out a bootp server. - * - * This simple program was put together from pieces taken from - * various places, including the CMU BOOTP client and server. - * The packet printing routine is from the Berkeley "tcpdump" - * program with some enhancements I added. The print-bootp.c - * file is shared with my copy of "tcpdump" and therefore uses - * some unusual utility routines that would normally be provided - * by various parts of the tcpdump program. - * - * Boilerplate: - * - * This program includes software developed by the University of - * California, Lawrence Berkeley Laboratory and its contributors. - * (See the copyright notice in print-bootp.c) - * - * The remainder of this program is public domain. You may do - * whatever you like with it except claim that you wrote it. - * - * 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. - * - * HISTORY: - * - * 12/02/93 Released version 1.4 (with bootp-2.3.2) - * 11/05/93 Released version 1.3 - * 10/14/93 Released version 1.2 - * 10/11/93 Released version 1.1 - * 09/28/93 Released version 1.0 - * 09/93 Original developed by Gordon W. Ross - */ - -char *usage = "bootptest [-h] server-name [vendor-data-template-file]"; - -#include -#include -#include -#include -#include -#include - -#include -#include -#include /* inet_ntoa */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bootp.h" -#include "bootptest.h" -#include "getif.h" -#include "patchlevel.h" - -#define LOG_ERR 1 -#define BUFLEN 1024 -#define WAITSECS 1 -#define MAXWAIT 10 - -int vflag = 1; -int tflag = 0; -int thiszone; -char *progname; -unsigned char *packetp; -unsigned char *snapend; -int snaplen; - - -/* - * IP port numbers for client and server obtained from /etc/services - */ - -u_short bootps_port, bootpc_port; - - -/* - * Internet socket and interface config structures - */ - -struct sockaddr_in sin_server; /* where to send requests */ -struct sockaddr_in sin_client; /* for bind and listen */ -struct sockaddr_in sin_from; /* Packet source */ -u_char eaddr[16]; /* Ethernet address */ - -/* - * General - */ - -int debug = 1; /* Debugging flag (level) */ -char hostname[64]; -char *sndbuf; /* Send packet buffer */ -char *rcvbuf; /* Receive packet buffer */ - -/* - * Vendor magic cookies for CMU and RFC1048 - */ - -unsigned char vm_cmu[4] = VM_CMU; -unsigned char vm_rfc1048[4] = VM_RFC1048; -short secs; /* How long client has waited */ - -char *get_errmsg(); -extern void bootp_print(); - -/* - * Initialization such as command-line processing is done, then - * the receiver loop is started. Die when interrupted. - */ - -main(argc, argv) - int argc; - char **argv; -{ - struct bootp *bp; - struct servent *sep; - struct hostent *hep; - - char *servername = NULL; - char *vendor_file = NULL; - char *bp_file = NULL; - int32 server_addr; /* inet addr, network order */ - int s; /* Socket file descriptor */ - int n, tolen, fromlen, recvcnt; - int use_hwa = 0; - int32 xid; - - progname = strrchr(argv[0], '/'); - if (progname) - progname++; - else - progname = argv[0]; - argc--; - argv++; - - if (debug) - printf("%s: version %s.%d\n", progname, VERSION, PATCHLEVEL); - - /* Debugging for compilers with struct padding. */ - assert(sizeof(struct bootp) == BP_MINPKTSZ); - - sndbuf = malloc(BUFLEN); - rcvbuf = malloc(BUFLEN); - if (!sndbuf || !rcvbuf) { - printf("malloc failed\n"); - exit(1); - } - /* Handle option switches. */ - while (argc > 0) { - if (argv[0][0] != '-') - break; - switch (argv[0][1]) { - - case 'f': /* File name to reqest. */ - if (argc < 2) - goto error; - argc--; argv++; - bp_file = *argv; - break; - - case 'h': /* Use hardware address. */ - use_hwa = 1; - break; - - error: - default: - puts(usage); - exit(1); - - } - argc--; - argv++; - } - - /* Get server name (or address) for query. */ - if (argc > 0) { - servername = *argv; - argc--; - argv++; - } - /* Get optional vendor-data-template-file. */ - if (argc > 0) { - vendor_file = *argv; - argc--; - argv++; - } - if (!servername) { - printf("missing server name.\n"); - puts(usage); - exit(1); - } - /* - * Create a socket. - */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("socket"); - exit(1); - } - /* - * Get server's listening port number - */ - sep = getservbyname("bootps", "udp"); - if (sep) { - bootps_port = ntohs((u_short) sep->s_port); - } else { - fprintf(stderr, "udp/bootps: unknown service -- using port %d\n", - IPPORT_BOOTPS); - bootps_port = (u_short) IPPORT_BOOTPS; - } - - /* - * Set up server socket address (for send) - */ - if (servername) { - if (isdigit(servername[0])) - server_addr = inet_addr(servername); - else { - hep = gethostbyname(servername); - if (!hep) { - fprintf(stderr, "%s: unknown host\n", servername); - exit(1); - } - bcopy(hep->h_addr, &server_addr, sizeof(server_addr)); - } - } else { - /* Get broadcast address */ - /* XXX - not yet */ - server_addr = INADDR_ANY; - } - sin_server.sin_family = AF_INET; - sin_server.sin_port = htons(bootps_port); - sin_server.sin_addr.s_addr = server_addr; - - /* - * Get client's listening port number - */ - sep = getservbyname("bootpc", "udp"); - if (sep) { - bootpc_port = ntohs(sep->s_port); - } else { - fprintf(stderr, "udp/bootpc: unknown service -- using port %d\n", - IPPORT_BOOTPC); - bootpc_port = (u_short) IPPORT_BOOTPC; - } - - /* - * Set up client socket address (for listen) - */ - sin_client.sin_family = AF_INET; - sin_client.sin_port = htons(bootpc_port); - sin_client.sin_addr.s_addr = INADDR_ANY; - - /* - * Bind client socket to BOOTPC port. - */ - if (bind(s, (struct sockaddr *) &sin_client, sizeof(sin_client)) < 0) { - perror("bind BOOTPC port"); - if (errno == EACCES) - fprintf(stderr, "You need to run this as root\n"); - exit(1); - } - /* - * Build a request. - */ - bp = (struct bootp *) sndbuf; - bzero(bp, sizeof(*bp)); - bp->bp_op = BOOTREQUEST; - xid = (int32) getpid(); - bp->bp_xid = (u_int32) htonl(xid); - if (bp_file) - strncpy(bp->bp_file, bp_file, BP_FILE_LEN); - - /* - * Fill in the hardware address (or client IP address) - */ - if (use_hwa) { - struct ifreq *ifr; - - ifr = getif(s, &sin_server.sin_addr); - if (!ifr) { - printf("No interface for %s\n", servername); - exit(1); - } - if (getether(ifr->ifr_name, eaddr)) { - printf("Can not get ether addr for %s\n", ifr->ifr_name); - exit(1); - } - /* Copy Ethernet address into request packet. */ - bp->bp_htype = 1; - bp->bp_hlen = 6; - bcopy(eaddr, bp->bp_chaddr, bp->bp_hlen); - } else { - /* Fill in the client IP address. */ - gethostname(hostname, sizeof(hostname)); - hep = gethostbyname(hostname); - if (!hep) { - printf("Can not get my IP address\n"); - exit(1); - } - bcopy(hep->h_addr, &bp->bp_ciaddr, hep->h_length); - } - - /* - * Copy in the default vendor data. - */ - bcopy(vm_rfc1048, bp->bp_vend, sizeof(vm_rfc1048)); - bp->bp_vend[4] = TAG_END; - - /* - * Read in the "options" part of the request. - * This also determines the size of the packet. - */ - snaplen = sizeof(*bp); - if (vendor_file) { - int fd = open(vendor_file, 0); - if (fd < 0) { - perror(vendor_file); - exit(1); - } - /* Compute actual space for options. */ - n = BUFLEN - sizeof(*bp) + BP_VEND_LEN; - n = read(fd, bp->bp_vend, n); - close(fd); - if (n < 0) { - perror(vendor_file); - exit(1); - } - printf("read %d bytes of vendor template\n", n); - if (n > BP_VEND_LEN) { - printf("warning: extended options in use (len > %d)\n", - BP_VEND_LEN); - snaplen += (n - BP_VEND_LEN); - } - } - /* - * Set globals needed by print_bootp - * (called by send_request) - */ - packetp = (unsigned char *) eaddr; - snapend = (unsigned char *) sndbuf + snaplen; - - /* Send a request once per second while waiting for replies. */ - recvcnt = 0; - bp->bp_secs = secs = 0; - send_request(s); - while (1) { - struct timeval tv; - int readfds; - - tv.tv_sec = WAITSECS; - tv.tv_usec = 0L; - readfds = (1 << s); - n = select(s + 1, (fd_set *) & readfds, NULL, NULL, &tv); - if (n < 0) { - perror("select"); - break; - } - if (n == 0) { - /* - * We have not received a response since the last send. - * If we have ever received any responses, exit now. - * Otherwise, bump the "wait time" field and re-send. - */ - if (recvcnt > 0) - exit(0); - secs += WAITSECS; - if (secs > MAXWAIT) - break; - bp->bp_secs = htons(secs); - send_request(s); - continue; - } - fromlen = sizeof(sin_from); - n = recvfrom(s, rcvbuf, BUFLEN, 0, - (struct sockaddr *) &sin_from, &fromlen); - if (n <= 0) { - continue; - } - if (n < sizeof(struct bootp)) { - printf("received short packet\n"); - continue; - } - recvcnt++; - - /* Print the received packet. */ - printf("Recvd from %s", inet_ntoa(sin_from.sin_addr)); - /* set globals needed by bootp_print() */ - snaplen = n; - snapend = (unsigned char *) rcvbuf + snaplen; - bootp_print(rcvbuf, n, sin_from.sin_port, 0); - putchar('\n'); - /* - * This no longer exits immediately after receiving - * one response because it is useful to know if the - * client might get multiple responses. This code - * will now listen for one second after a response. - */ - } - fprintf(stderr, "no response from %s\n", servername); - exit(1); -} - -send_request(s) - int s; -{ - /* Print the request packet. */ - printf("Sending to %s", inet_ntoa(sin_server.sin_addr)); - bootp_print(sndbuf, snaplen, sin_from.sin_port, 0); - putchar('\n'); - - /* Send the request packet. */ - if (sendto(s, sndbuf, snaplen, 0, - (struct sockaddr *) &sin_server, - sizeof(sin_server)) < 0) - { - perror("sendto server"); - exit(1); - } -} - -/* - * Print out a filename (or other ascii string). - * Return true if truncated. - */ -int -printfn(s, ep) - register u_char *s, *ep; -{ - register u_char c; - - putchar('"'); - while (c = *s++) { - if (s > ep) { - putchar('"'); - return (1); - } - if (!isascii(c)) { - c = toascii(c); - putchar('M'); - putchar('-'); - } - if (!isprint(c)) { - c ^= 0x40; /* DEL to ?, others to alpha */ - putchar('^'); - } - putchar(c); - } - putchar('"'); - return (0); -} - -/* - * Convert an IP addr to a string. - * (like inet_ntoa, but ina is a pointer) - */ -char * -ipaddr_string(ina) - struct in_addr *ina; -{ - static char b[24]; - u_char *p; - - p = (u_char *) ina; - sprintf(b, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); - return (b); -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/bootptest.h b/libexec/bootpd/bootptest.h deleted file mode 100644 index 27f78ba963b7..000000000000 --- a/libexec/bootpd/bootptest.h +++ /dev/null @@ -1,30 +0,0 @@ -/* bootptest.h */ -/* - * Hacks for sharing print-bootp.c between tcpdump and bootptest. - */ -#define ESRC(p) (p) -#define EDST(p) (p) - -#ifndef USE_BFUNCS -/* Use mem/str functions */ -/* There are no overlapped copies, so memcpy is OK. */ -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -extern int vflag; /* verbose flag */ - -/* global pointers to beginning and end of current packet (during printing) */ -extern unsigned char *packetp; -extern unsigned char *snapend; - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern char *ipaddr_string P((struct in_addr *)); - -#undef P diff --git a/libexec/bootpd/bptypes.h b/libexec/bootpd/bptypes.h deleted file mode 100644 index 537da4e5e57f..000000000000 --- a/libexec/bootpd/bptypes.h +++ /dev/null @@ -1,23 +0,0 @@ -/* bptypes.h */ - -#ifndef BPTYPES_H -#define BPTYPES_H - -/* - * 32 bit integers are different types on various architectures - */ - -#ifndef int32 -#define int32 long -#endif -typedef unsigned int32 u_int32; - -/* - * Nice typedefs. . . - */ - -typedef int boolean; -typedef unsigned char byte; - - -#endif /* BPTYPES_H */ diff --git a/libexec/bootpd/dovend.c b/libexec/bootpd/dovend.c deleted file mode 100644 index ba6ab288b8b3..000000000000 --- a/libexec/bootpd/dovend.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * dovend.c : Inserts all but the first few vendor options. - */ - -#include - -#include -#include /* inet_ntoa */ - -#include -#include -#include -#include -#include - -#ifndef USE_BFUNCS -# include -/* Yes, memcpy is OK here (no overlapped copies). */ -# define bcopy(a,b,c) memcpy(b,a,c) -# define bzero(p,l) memset(p,0,l) -# define bcmp(a,b,c) memcmp(a,b,c) -# define index strchr -#endif - -#include "bootp.h" -#include "bootpd.h" -#include "report.h" -#include "dovend.h" - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -PRIVATE int insert_generic P((struct shared_bindata *, byte **, int *)); - -/* - * Insert the 2nd part of the options into an option buffer. - * Return amount of space used. - * - * This inserts everything EXCEPT: - * magic cookie, subnet mask, gateway, bootsize, extension file - * Those are handled separately (in bootpd.c) to allow this function - * to be shared between bootpd and bootpef. - * - * When an "extension file" is in use, the options inserted by - * this function go into the exten_file, not the bootp response. - */ - -int -dovend_rfc1497(hp, buf, len) - struct host *hp; - byte *buf; - int len; -{ - int bytesleft = len; - byte *vp = buf; - char *tmpstr; - - static char noroom[] = "%s: No room for \"%s\" option"; -#define NEED(LEN, MSG) do \ - if (bytesleft < (LEN)) { \ - report(LOG_NOTICE, noroom, \ - hp->hostname->string, MSG); \ - return (vp - buf); \ - } while (0) - - /* - * Note that the following have already been inserted: - * magic_cookie, subnet_mask, gateway, bootsize - * - * The remaining options are inserted in order of importance. - * (Of course the importance of each is a matter of opinion.) - * The option insertion order should probably be configurable. - * - * This is the order used in the NetBSD version. Can anyone - * explain why the time_offset and swap_server are first? - * Also, why is the hostname so far down the list? -gwr - */ - - if (hp->flags.time_offset) { - NEED(6, "to"); - *vp++ = TAG_TIME_OFFSET;/* -1 byte */ - *vp++ = 4; /* -1 byte */ - insert_u_long(htonl(hp->time_offset), &vp); /* -4 bytes */ - bytesleft -= 6; - } - /* - * swap server, root path, dump path - */ - if (hp->flags.swap_server) { - NEED(6, "sw"); - /* There is just one SWAP_SERVER, so it is not an iplist. */ - *vp++ = TAG_SWAP_SERVER;/* -1 byte */ - *vp++ = 4; /* -1 byte */ - insert_u_long(hp->swap_server.s_addr, &vp); /* -4 bytes */ - bytesleft -= 6; /* Fix real count */ - } - if (hp->flags.root_path) { - /* - * Check for room for root_path. Add 2 to account for - * TAG_ROOT_PATH and length. - */ - len = strlen(hp->root_path->string); - NEED((len + 2), "rp"); - *vp++ = TAG_ROOT_PATH; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->root_path->string, vp, len); - vp += len; - bytesleft -= len + 2; - } - if (hp->flags.dump_file) { - /* - * Check for room for dump_file. Add 2 to account for - * TAG_DUMP_FILE and length. - */ - len = strlen(hp->dump_file->string); - NEED((len + 2), "df"); - *vp++ = TAG_DUMP_FILE; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->dump_file->string, vp, len); - vp += len; - bytesleft -= len + 2; - } - /* - * DNS server and domain - */ - if (hp->flags.domain_server) { - if (insert_ip(TAG_DOMAIN_SERVER, - hp->domain_server, - &vp, &bytesleft)) - NEED(8, "ds"); - } - if (hp->flags.domain_name) { - /* - * Check for room for domain_name. Add 2 to account for - * TAG_DOMAIN_NAME and length. - */ - len = strlen(hp->domain_name->string); - NEED((len + 2), "dn"); - *vp++ = TAG_DOMAIN_NAME; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->domain_name->string, vp, len); - vp += len; - bytesleft -= len + 2; - } - /* - * NIS (YP) server and domain - */ - if (hp->flags.nis_server) { - if (insert_ip(TAG_NIS_SERVER, - hp->nis_server, - &vp, &bytesleft)) - NEED(8, "ds"); - } - if (hp->flags.nis_domain) { - /* - * Check for room for nis_domain. Add 2 to account for - * TAG_NIS_DOMAIN and length. - */ - len = strlen(hp->nis_domain->string); - NEED((len + 2), "dn"); - *vp++ = TAG_NIS_DOMAIN; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->nis_domain->string, vp, len); - vp += len; - bytesleft -= len + 2; - } - /* IEN 116 name server */ - if (hp->flags.name_server) { - if (insert_ip(TAG_NAME_SERVER, - hp->name_server, - &vp, &bytesleft)) - NEED(8, "ns"); - } - if (hp->flags.rlp_server) { - if (insert_ip(TAG_RLP_SERVER, - hp->rlp_server, - &vp, &bytesleft)) - NEED(8, "rl"); - } - /* Time server (RFC 868) */ - if (hp->flags.time_server) { - if (insert_ip(TAG_TIME_SERVER, - hp->time_server, - &vp, &bytesleft)) - NEED(8, "ts"); - } - /* NTP (time) Server (RFC 1129) */ - if (hp->flags.ntp_server) { - if (insert_ip(TAG_NTP_SERVER, - hp->ntp_server, - &vp, &bytesleft)) - NEED(8, "ts"); - } - /* - * I wonder: If the hostname were "promoted" into the BOOTP - * response part, might these "extension" files possibly be - * shared between several clients? - * - * Also, why not just use longer BOOTP packets with all the - * additional length used as option data. This bootpd version - * already supports that feature by replying with the same - * packet length as the client request packet. -gwr - */ - if (hp->flags.name_switch && hp->flags.send_name) { - /* - * Check for room for hostname. Add 2 to account for - * TAG_HOST_NAME and length. - */ - len = strlen(hp->hostname->string); -#if 0 - /* - * XXX - Too much magic. The user can always set the hostname - * to the short version in the bootptab file. -gwr - */ - if ((len + 2) > bytesleft) { - /* - * Not enough room for full (domain-qualified) hostname, try - * stripping it down to just the first field (host). - */ - tmpstr = hp->hostname->string; - len = 0; - while (*tmpstr && (*tmpstr != '.')) { - tmpstr++; - len++; - } - } -#endif - NEED((len + 2), "hn"); - *vp++ = TAG_HOST_NAME; - *vp++ = (byte) (len & 0xFF); - bcopy(hp->hostname->string, vp, len); - vp += len; - bytesleft -= len + 2; - } - /* - * The rest of these are less important, so they go last. - */ - if (hp->flags.lpr_server) { - if (insert_ip(TAG_LPR_SERVER, - hp->lpr_server, - &vp, &bytesleft)) - NEED(8, "lp"); - } - if (hp->flags.cookie_server) { - if (insert_ip(TAG_COOKIE_SERVER, - hp->cookie_server, - &vp, &bytesleft)) - NEED(8, "cs"); - } - if (hp->flags.log_server) { - if (insert_ip(TAG_LOG_SERVER, - hp->log_server, - &vp, &bytesleft)) - NEED(8, "lg"); - } - /* - * XXX - Add new tags here (to insert options) - */ - if (hp->flags.generic) { - if (insert_generic(hp->generic, &vp, &bytesleft)) - NEED(64, "(generic)"); - } - /* - * The end marker is inserted by the caller. - */ - return (vp - buf); -#undef NEED -} /* dovend_rfc1497 */ - - - -/* - * Insert a tag value, a length value, and a list of IP addresses into the - * memory buffer indirectly pointed to by "dest". "tag" is the RFC1048 tag - * number to use, "iplist" is a pointer to a list of IP addresses - * (struct in_addr_list), and "bytesleft" points to an integer which - * indicates the size of the "dest" buffer. - * - * Return zero if everything fits. - * - * This is used to fill the vendor-specific area of a bootp packet in - * conformance to RFC1048. - */ - -int -insert_ip(tag, iplist, dest, bytesleft) - byte tag; - struct in_addr_list *iplist; - byte **dest; - int *bytesleft; -{ - struct in_addr *addrptr; - unsigned addrcount = 1; - byte *d; - - if (iplist == NULL) - return (0); - - if (*bytesleft >= 6) { - d = *dest; /* Save pointer for later */ - **dest = tag; - (*dest) += 2; - (*bytesleft) -= 2; /* Account for tag and length */ - addrptr = iplist->addr; - addrcount = iplist->addrcount; - while ((*bytesleft >= 4) && (addrcount > 0)) { - insert_u_long(addrptr->s_addr, dest); - addrptr++; - addrcount--; - (*bytesleft) -= 4; /* Four bytes per address */ - } - d[1] = (byte) ((*dest - d - 2) & 0xFF); - } - return (addrcount); -} - - - -/* - * Insert generic data into a bootp packet. The data is assumed to already - * be in RFC1048 format. It is inserted using a first-fit algorithm which - * attempts to insert as many tags as possible. Tags and data which are - * too large to fit are skipped; any remaining tags are tried until they - * have all been exhausted. - * Return zero if everything fits. - */ - -static int -insert_generic(gendata, buff, bytesleft) - struct shared_bindata *gendata; - byte **buff; - int *bytesleft; -{ - byte *srcptr; - int length, numbytes; - int skipped = 0; - - if (gendata == NULL) - return (0); - - srcptr = gendata->data; - length = gendata->length; - while ((length > 0) && (*bytesleft > 0)) { - switch (*srcptr) { - case TAG_END: - length = 0; /* Force an exit on next iteration */ - break; - case TAG_PAD: - *(*buff)++ = *srcptr++; - (*bytesleft)--; - length--; - break; - default: - numbytes = srcptr[1] + 2; - if (*bytesleft < numbytes) - skipped += numbytes; - else { - bcopy(srcptr, *buff, numbytes); - (*buff) += numbytes; - (*bytesleft) -= numbytes; - } - srcptr += numbytes; - length -= numbytes; - break; - } - } /* while */ - return (skipped); -} - -/* - * Insert the unsigned long "value" into memory starting at the byte - * pointed to by the byte pointer (*dest). (*dest) is updated to - * point to the next available byte. - * - * Since it is desirable to internally store network addresses in network - * byte order (in struct in_addr's), this routine expects longs to be - * passed in network byte order. - * - * However, due to the nature of the main algorithm, the long must be in - * host byte order, thus necessitating the use of ntohl() first. - */ - -void -insert_u_long(value, dest) - u_int32 value; - byte **dest; -{ - byte *temp; - int n; - - value = ntohl(value); /* Must use host byte order here */ - temp = (*dest += 4); - for (n = 4; n > 0; n--) { - *--temp = (byte) (value & 0xFF); - value >>= 8; - } - /* Final result is network byte order */ -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/dovend.h b/libexec/bootpd/dovend.h deleted file mode 100644 index b30c982d8e23..000000000000 --- a/libexec/bootpd/dovend.h +++ /dev/null @@ -1,13 +0,0 @@ -/* dovend.h */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern int dovend_rfc1497 P((struct host *hp, u_char *buf, int len)); -extern int insert_ip P((int, struct in_addr_list *, u_char **, int *)); -extern void insert_u_long P((u_int32, u_char **)); - -#undef P diff --git a/libexec/bootpd/dumptab.c b/libexec/bootpd/dumptab.c deleted file mode 100644 index da2ece2b2948..000000000000 --- a/libexec/bootpd/dumptab.c +++ /dev/null @@ -1,370 +0,0 @@ -/* - * dumptab.c - handles dumping the database - */ - -#include -#include -#include /* inet_ntoa */ - -#include -#include -#include -#include - -#ifndef USE_BFUNCS -#include -/* Yes, memcpy is OK here (no overlapped copies). */ -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bootp.h" -#include "hash.h" -#include "hwaddr.h" -#include "report.h" -#include "patchlevel.h" -#include "bootpd.h" - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -static void dump_generic P((FILE *, struct shared_bindata *)); -static void dump_host P((FILE *, struct host *)); -static void list_ipaddresses P((FILE *, struct in_addr_list *)); - -#undef P - -#ifndef DEBUG -void -dumptab(filename) - char *filename; -{ - report(LOG_INFO, "No dumptab support!"); -} - -#else /* DEBUG */ - -/* - * Dump the internal memory database to bootpd_dump. - */ - -void -dumptab(filename) - char *filename; -{ - int n; - struct host *hp; - FILE *fp; - long t; - /* Print symbols in alphabetical order for reader's convenience. */ - static char legend[] = "#\n# Legend:\t(see bootptab.5)\n\ -#\tfirst field -- hostname (not indented)\n\ -#\tbf -- bootfile\n\ -#\tbs -- bootfile size in 512-octet blocks\n\ -#\tcs -- cookie servers\n\ -#\tdf -- dump file name\n\ -#\tdn -- domain name\n\ -#\tds -- domain name servers\n\ -#\tef -- extension file\n\ -#\tgw -- gateways\n\ -#\tha -- hardware address\n\ -#\thd -- home directory for bootfiles\n\ -#\thn -- host name set for client\n\ -#\tht -- hardware type\n\ -#\tim -- impress servers\n\ -#\tip -- host IP address\n\ -#\tlg -- log servers\n\ -#\tlp -- LPR servers\n\ -#\tns -- IEN-116 name servers\n\ -#\tnt -- NTP servers (RFC 1129)\n\ -#\tra -- reply address override\n\ -#\trl -- resource location protocol servers\n\ -#\trp -- root path\n\ -#\tsa -- boot server address\n\ -#\tsm -- subnet mask\n\ -#\tsw -- swap server\n\ -#\ttc -- template host (points to similar host entry)\n\ -#\ttd -- TFTP directory\n\ -#\tto -- time offset (seconds)\n\ -#\tts -- time servers\n\ -#\tvm -- vendor magic number\n\ -#\tyd -- YP (NIS) domain\n\ -#\tys -- YP (NIS) servers\n\ -#\tTn -- generic option tag n\n\ -\n"; - - /* - * Open bootpd.dump file. - */ - if ((fp = fopen(filename, "w")) == NULL) { - report(LOG_ERR, "error opening \"%s\": %s", - filename, get_errmsg()); - exit(1); - } - t = time(NULL); - fprintf(fp, "\n# %s %s.%d\n", progname, VERSION, PATCHLEVEL); - fprintf(fp, "# %s: dump of bootp server database.\n", filename); - fprintf(fp, "# Dump taken %s", ctime(&t)); - fwrite(legend, 1, sizeof(legend) - 1, fp); - - n = 0; - for (hp = (struct host *) hash_FirstEntry(nmhashtable); hp != NULL; - hp = (struct host *) hash_NextEntry(nmhashtable)) { - dump_host(fp, hp); - fprintf(fp, "\n"); - n++; - } - fclose(fp); - - report(LOG_INFO, "dumped %d entries to \"%s\".", n, filename); -} - - - -/* - * Dump all the available information on the host pointed to by "hp". - * The output is sent to the file pointed to by "fp". - */ - -static void -dump_host(fp, hp) - FILE *fp; - struct host *hp; -{ - /* Print symbols in alphabetical order for reader's convenience. */ - if (hp) { - fprintf(fp, "%s:", (hp->hostname ? - hp->hostname->string : "?")); - if (hp->flags.bootfile) { - fprintf(fp, "\\\n\t:bf=%s:", hp->bootfile->string); - } - if (hp->flags.bootsize) { - fprintf(fp, "\\\n\t:bs="); - if (hp->flags.bootsize_auto) { - fprintf(fp, "auto:"); - } else { - fprintf(fp, "%d:", hp->bootsize); - } - } - if (hp->flags.cookie_server) { - fprintf(fp, "\\\n\t:cs="); - list_ipaddresses(fp, hp->cookie_server); - fprintf(fp, ":"); - } - if (hp->flags.dump_file) { - fprintf(fp, "\\\n\t:df=%s:", hp->dump_file->string); - } - if (hp->flags.domain_name) { - fprintf(fp, "\\\n\t:dn=%s:", hp->domain_name->string); - } - if (hp->flags.domain_server) { - fprintf(fp, "\\\n\t:ds="); - list_ipaddresses(fp, hp->domain_server); - fprintf(fp, ":"); - } - if (hp->flags.exten_file) { - fprintf(fp, "\\\n\t:ef=%s:", hp->exten_file->string); - } - if (hp->flags.gateway) { - fprintf(fp, "\\\n\t:gw="); - list_ipaddresses(fp, hp->gateway); - fprintf(fp, ":"); - } - /* FdC: swap_server (see below) */ - if (hp->flags.homedir) { - fprintf(fp, "\\\n\t:hd=%s:", hp->homedir->string); - } - /* FdC: dump_file (see above) */ - /* FdC: domain_name (see above) */ - /* FdC: root_path (see below) */ - if (hp->flags.name_switch && hp->flags.send_name) { - fprintf(fp, "\\\n\t:hn:"); - } - if (hp->flags.htype) { - int hlen = haddrlength(hp->htype); - fprintf(fp, "\\\n\t:ht=%u:", (unsigned) hp->htype); - if (hp->flags.haddr) { - fprintf(fp, "ha=\"%s\":", - haddrtoa(hp->haddr, hlen)); - } - } - if (hp->flags.impress_server) { - fprintf(fp, "\\\n\t:im="); - list_ipaddresses(fp, hp->impress_server); - fprintf(fp, ":"); - } - /* NetBSD: swap_server (see below) */ - if (hp->flags.iaddr) { - fprintf(fp, "\\\n\t:ip=%s:", inet_ntoa(hp->iaddr)); - } - if (hp->flags.log_server) { - fprintf(fp, "\\\n\t:lg="); - list_ipaddresses(fp, hp->log_server); - fprintf(fp, ":"); - } - if (hp->flags.lpr_server) { - fprintf(fp, "\\\n\t:lp="); - list_ipaddresses(fp, hp->lpr_server); - fprintf(fp, ":"); - } - if (hp->flags.name_server) { - fprintf(fp, "\\\n\t:ns="); - list_ipaddresses(fp, hp->name_server); - fprintf(fp, ":"); - } - if (hp->flags.ntp_server) { - fprintf(fp, "\\\n\t:nt="); - list_ipaddresses(fp, hp->ntp_server); - fprintf(fp, ":"); - } - if (hp->flags.reply_addr) { - fprintf(fp, "\\\n\t:ra=%s:", inet_ntoa(hp->reply_addr)); - } - if (hp->flags.rlp_server) { - fprintf(fp, "\\\n\t:rl="); - list_ipaddresses(fp, hp->rlp_server); - fprintf(fp, ":"); - } - if (hp->flags.root_path) { - fprintf(fp, "\\\n\t:rp=%s:", hp->root_path->string); - } - if (hp->flags.bootserver) { - fprintf(fp, "\\\n\t:sa=%s:", inet_ntoa(hp->bootserver)); - } - if (hp->flags.subnet_mask) { - fprintf(fp, "\\\n\t:sm=%s:", inet_ntoa(hp->subnet_mask)); - } - if (hp->flags.swap_server) { - fprintf(fp, "\\\n\t:sw=%s:", inet_ntoa(hp->subnet_mask)); - } - if (hp->flags.tftpdir) { - fprintf(fp, "\\\n\t:td=%s:", hp->tftpdir->string); - } - /* NetBSD: rootpath (see above) */ - /* NetBSD: domainname (see above) */ - /* NetBSD: dumpfile (see above) */ - if (hp->flags.time_offset) { - fprintf(fp, "\\\n\t:to=%ld:", hp->time_offset); - } - if (hp->flags.time_server) { - fprintf(fp, "\\\n\t:ts="); - list_ipaddresses(fp, hp->time_server); - fprintf(fp, ":"); - } - if (hp->flags.vm_cookie) { - fprintf(fp, "\\\n\t:vm="); - if (!bcmp(hp->vm_cookie, vm_rfc1048, 4)) { - fprintf(fp, "rfc1048:"); - } else if (!bcmp(hp->vm_cookie, vm_cmu, 4)) { - fprintf(fp, "cmu:"); - } else { - fprintf(fp, "%d.%d.%d.%d:", - (int) ((hp->vm_cookie)[0]), - (int) ((hp->vm_cookie)[1]), - (int) ((hp->vm_cookie)[2]), - (int) ((hp->vm_cookie)[3])); - } - } - if (hp->flags.nis_domain) { - fprintf(fp, "\\\n\t:yd=%s:", - hp->nis_domain->string); - } - if (hp->flags.nis_server) { - fprintf(fp, "\\\n\t:ys="); - list_ipaddresses(fp, hp->nis_server); - fprintf(fp, ":"); - } - /* - * XXX - Add new tags here (or above, - * so they print in alphabetical order). - */ - - if (hp->flags.generic) { - dump_generic(fp, hp->generic); - } - } -} - - -static void -dump_generic(fp, generic) - FILE *fp; - struct shared_bindata *generic; -{ - u_char *bp = generic->data; - u_char *ep = bp + generic->length; - u_char tag; - int len; - - while (bp < ep) { - tag = *bp++; - if (tag == TAG_PAD) - continue; - if (tag == TAG_END) - return; - len = *bp++; - if (bp + len > ep) { - fprintf(fp, " #junk in generic! :"); - return; - } - fprintf(fp, "\\\n\t:T%d=", tag); - while (len) { - fprintf(fp, "%02X", *bp); - bp++; - len--; - if (len) - fprintf(fp, "."); - } - fprintf(fp, ":"); - } -} - - - -/* - * Dump an entire struct in_addr_list of IP addresses to the indicated file. - * - * The addresses are printed in standard ASCII "dot" notation and separated - * from one another by a single space. A single leading space is also - * printed before the first adddress. - * - * Null lists produce no output (and no error). - */ - -static void -list_ipaddresses(fp, ipptr) - FILE *fp; - struct in_addr_list *ipptr; -{ - unsigned count; - struct in_addr *addrptr; - - if (ipptr) { - count = ipptr->addrcount; - addrptr = ipptr->addr; - while (count > 0) { - fprintf(fp, "%s", inet_ntoa(*addrptr++)); - count--; - if (count) - fprintf(fp, ", "); - } - } -} - -#endif /* DEBUG */ - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/getether.c b/libexec/bootpd/getether.c deleted file mode 100644 index d131b50f7f89..000000000000 --- a/libexec/bootpd/getether.c +++ /dev/null @@ -1,374 +0,0 @@ -/* - * getether.c : get the ethernet address of an interface - * - * All of this code is quite system-specific. As you may well - * guess, it took a good bit of detective work to figure out! - * - * If you figure out how to do this on another system, - * please let me know. - */ - -#include -#include - -#include -#include - -#include "report.h" -#define EALEN 6 - -#if defined(ultrix) || (defined(__osf__) && defined(__alpha)) -/* - * This is really easy on Ultrix! Thanks to - * Harald Lundberg for this code. - * - * The code here is not specific to the Alpha, but that was the - * only symbol we could find to identify DEC's version of OSF. - * (Perhaps we should just define DEC in the Makefile... -gwr) - */ - -#include -#include /* struct ifdevea */ - -getether(ifname, eap) - char *ifname, *eap; -{ - int rc = -1; - int fd; - struct ifdevea phys; - bzero(&phys, sizeof(phys)); - strcpy(phys.ifr_name, ifname); - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - report(LOG_ERR, "getether: socket(INET,DGRAM) failed"); - return -1; - } - if (ioctl(fd, SIOCRPHYSADDR, &phys) < 0) { - report(LOG_ERR, "getether: ioctl SIOCRPHYSADDR failed"); - } else { - bcopy(&phys.current_pa[0], eap, EALEN); - rc = 0; - } - close(fd); - return rc; -} - -#define GETETHER -#endif /* ultrix|osf1 */ - - -#ifdef SUNOS - -#include -#include /* needed by net_if.h */ -#include /* for NIOCBIND */ -#include /* for struct ifreq */ - -getether(ifname, eap) - char *ifname; /* interface name from ifconfig structure */ - char *eap; /* Ether address (output) */ -{ - int rc = -1; - - struct ifreq ifrnit; - int nit; - - bzero((char *) &ifrnit, sizeof(ifrnit)); - strncpy(&ifrnit.ifr_name[0], ifname, IFNAMSIZ); - - nit = open("/dev/nit", 0); - if (nit < 0) { - report(LOG_ERR, "getether: open /dev/nit: %s", - get_errmsg()); - return rc; - } - do { - if (ioctl(nit, NIOCBIND, &ifrnit) < 0) { - report(LOG_ERR, "getether: NIOCBIND on nit"); - break; - } - if (ioctl(nit, SIOCGIFADDR, &ifrnit) < 0) { - report(LOG_ERR, "getether: SIOCGIFADDR on nit"); - break; - } - bcopy(&ifrnit.ifr_addr.sa_data[0], eap, EALEN); - rc = 0; - } while (0); - close(nit); - return rc; -} - -#define GETETHER -#endif /* SUNOS */ - - -#if defined(__386BSD__) || defined(__NetBSD__) -/* Thanks to John Brezak for this code. */ -#include -#include -#include -#include - -getether(ifname, eap) - char *ifname; /* interface name from ifconfig structure */ - char *eap; /* Ether address (output) */ -{ - int fd, rc = -1; - register int n; - struct ifreq ibuf[16], ifr; - struct ifconf ifc; - register struct ifreq *ifrp, *ifend; - - /* Fetch the interface configuration */ - fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) { - report(LOG_ERR, "getether: socket %s: %s", ifname, get_errmsg()); - return (fd); - } - ifc.ifc_len = sizeof(ibuf); - ifc.ifc_buf = (caddr_t) ibuf; - if (ioctl(fd, SIOCGIFCONF, (char *) &ifc) < 0 || - ifc.ifc_len < sizeof(struct ifreq)) { - report(LOG_ERR, "getether: SIOCGIFCONF: %s", get_errmsg); - goto out; - } - /* Search interface configuration list for link layer address. */ - ifrp = ibuf; - ifend = (struct ifreq *) ((char *) ibuf + ifc.ifc_len); - while (ifrp < ifend) { - /* Look for interface */ - if (strcmp(ifname, ifrp->ifr_name) == 0 && - ifrp->ifr_addr.sa_family == AF_LINK && - ((struct sockaddr_dl *) &ifrp->ifr_addr)->sdl_type == IFT_ETHER) { - bcopy(LLADDR((struct sockaddr_dl *) &ifrp->ifr_addr), eap, EALEN); - rc = 0; - break; - } - /* Bump interface config pointer */ - n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name); - if (n < sizeof(*ifrp)) - n = sizeof(*ifrp); - ifrp = (struct ifreq *) ((char *) ifrp + n); - } - - out: - close(fd); - return (rc); -} - -#define GETETHER -#endif /* __NetBSD__ */ - - -#ifdef SVR4 -/* - * This is for "Streams TCP/IP" by Lachman Associates. - * They sure made this cumbersome! -gwr - */ - -#include -#include -#include -#ifndef NULL -#define NULL 0 -#endif - -getether(ifname, eap) - char *ifname; /* interface name from ifconfig structure */ - char *eap; /* Ether address (output) */ -{ - int rc = -1; - char devname[32]; - char tmpbuf[sizeof(union DL_primitives) + 16]; - struct strbuf cbuf; - int fd, flags; - union DL_primitives *dlp; - char *enaddr; - int unit = -1; /* which unit to attach */ - - sprintf(devname, "/dev/%s", ifname); - fd = open(devname, 2); - if (fd < 0) { - /* Try without the trailing digit. */ - char *p = devname + 5; - while (isalpha(*p)) - p++; - if (isdigit(*p)) { - unit = *p - '0'; - *p = '\0'; - } - fd = open(devname, 2); - if (fd < 0) { - report(LOG_ERR, "getether: open %s: %s", - devname, get_errmsg()); - return rc; - } - } -#ifdef DL_ATTACH_REQ - /* - * If this is a "Style 2" DLPI, then we must "attach" first - * to tell the driver which unit (board, port) we want. - * For now, decide this based on the device name. - * (Should do "info_req" and check dl_provider_style ...) - */ - if (unit >= 0) { - memset(tmpbuf, 0, sizeof(tmpbuf)); - dlp = (union DL_primitives *) tmpbuf; - dlp->dl_primitive = DL_ATTACH_REQ; - dlp->attach_req.dl_ppa = unit; - cbuf.buf = tmpbuf; - cbuf.len = DL_ATTACH_REQ_SIZE; - if (putmsg(fd, &cbuf, NULL, 0) < 0) { - report(LOG_ERR, "getether: attach: putmsg: %s", get_errmsg()); - goto out; - } - /* Recv the ack. */ - cbuf.buf = tmpbuf; - cbuf.maxlen = sizeof(tmpbuf); - flags = 0; - if (getmsg(fd, &cbuf, NULL, &flags) < 0) { - report(LOG_ERR, "getether: attach: getmsg: %s", get_errmsg()); - goto out; - } - /* - * Check the type, etc. - */ - if (dlp->dl_primitive == DL_ERROR_ACK) { - report(LOG_ERR, "getether: attach: dlpi_errno=%d, unix_errno=%d", - dlp->error_ack.dl_errno, - dlp->error_ack.dl_unix_errno); - goto out; - } - if (dlp->dl_primitive != DL_OK_ACK) { - report(LOG_ERR, "getether: attach: not OK or ERROR"); - goto out; - } - } /* unit >= 0 */ -#endif /* DL_ATTACH_REQ */ - - /* - * Get the Ethernet address the same way the ARP module - * does when it is pushed onto a new stream (bind). - * One should instead be able just do an dl_info_req - * but many drivers do not supply the hardware address - * in the response to dl_info_req (they MUST supply it - * for dl_bind_ack because the ARP module requires it). - */ - memset(tmpbuf, 0, sizeof(tmpbuf)); - dlp = (union DL_primitives *) tmpbuf; - dlp->dl_primitive = DL_BIND_REQ; - dlp->bind_req.dl_sap = 0x8FF; /* XXX - Unused SAP */ - cbuf.buf = tmpbuf; - cbuf.len = DL_BIND_REQ_SIZE; - if (putmsg(fd, &cbuf, NULL, 0) < 0) { - report(LOG_ERR, "getether: bind: putmsg: %s", get_errmsg()); - goto out; - } - /* Recv the ack. */ - cbuf.buf = tmpbuf; - cbuf.maxlen = sizeof(tmpbuf); - flags = 0; - if (getmsg(fd, &cbuf, NULL, &flags) < 0) { - report(LOG_ERR, "getether: bind: getmsg: %s", get_errmsg()); - goto out; - } - /* - * Check the type, etc. - */ - if (dlp->dl_primitive == DL_ERROR_ACK) { - report(LOG_ERR, "getether: bind: dlpi_errno=%d, unix_errno=%d", - dlp->error_ack.dl_errno, - dlp->error_ack.dl_unix_errno); - goto out; - } - if (dlp->dl_primitive != DL_BIND_ACK) { - report(LOG_ERR, "getether: bind: not OK or ERROR"); - goto out; - } - if (dlp->bind_ack.dl_addr_offset == 0) { - report(LOG_ERR, "getether: bind: ack has no address"); - goto out; - } - if (dlp->bind_ack.dl_addr_length < EALEN) { - report(LOG_ERR, "getether: bind: ack address truncated"); - goto out; - } - /* - * Copy the Ethernet address out of the message. - */ - enaddr = tmpbuf + dlp->bind_ack.dl_addr_offset; - memcpy(eap, enaddr, EALEN); - rc = 0; - - out: - close(fd); - return rc; -} - -#define GETETHER -#endif /* SVR4 */ - - -#ifdef linux -/* - * This is really easy on Linux! This version (for linux) - * written by Nigel Metheringham - * - * The code is almost identical to the Ultrix code - however - * the names are different to confuse the innocent :-) - * Most of this code was stolen from the Ultrix bit above. - */ - -#include -#include /* struct ifreq */ - -/* In a properly configured system this should be either sys/socketio.h - or sys/sockios.h, but on my distribution these don't line up correctly */ -#include /* Needed for IOCTL defs */ - -getether(ifname, eap) - char *ifname, *eap; -{ - int rc = -1; - int fd; - struct ifreq phys; - bzero(&phys, sizeof(phys)); - strcpy(phys.ifr_name, ifname); - if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - report(LOG_ERR, "getether: socket(INET,DGRAM) failed"); - return -1; - } - if (ioctl(fd, SIOCGIFHWADDR, &phys) < 0) { - report(LOG_ERR, "getether: ioctl SIOCGIFHWADDR failed"); - } else { - bcopy(phys.ifr_hwaddr, eap, EALEN); - rc = 0; - } - close(fd); - return rc; -} - -#define GETETHER -#endif /* linux */ - - -/* If we don't know how on this system, just return an error. */ -#ifndef GETETHER -getether(ifname, eap) - char *ifname, *eap; -{ - return -1; -} - -#endif /* !GETETHER */ - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/getif.c b/libexec/bootpd/getif.c deleted file mode 100644 index 6cc16496ae46..000000000000 --- a/libexec/bootpd/getif.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * getif.c : get an interface structure - */ - -#include -#include -#include - -#if defined(SUNOS) || defined(SVR4) -#include -#endif -#ifdef SVR4 -#include -#endif - -#include /* for struct ifreq */ -#include - -#ifndef NO_UNISTD -#include -#endif -#include -#include -#include - -#include "getif.h" -#include "report.h" - -#ifdef __bsdi__ -#define BSD 43 -#endif - -static struct ifreq ifreq[10]; /* Holds interface configuration */ -static struct ifconf ifconf; /* points to ifreq */ - -static int nmatch(); - -/* Return a pointer to the interface struct for the passed address. */ -struct ifreq * -getif(s, addrp) - int s; /* socket file descriptor */ - struct in_addr *addrp; /* destination address on interface */ -{ - int maxmatch; - int len, m, incr; - struct ifreq *ifrq, *ifrmax; - struct sockaddr_in *sip; - char *p; - - /* If no address was supplied, just return NULL. */ - if (!addrp) - return (struct ifreq *) 0; - - /* Get the interface config if not done already. */ - if (ifconf.ifc_len == 0) { -#ifdef SVR4 - /* - * SysVr4 returns garbage if you do this the obvious way! - * This one took a while to figure out... -gwr - */ - struct strioctl ioc; - ioc.ic_cmd = SIOCGIFCONF; - ioc.ic_timout = 0; - ioc.ic_len = sizeof(ifreq); - ioc.ic_dp = (char *) ifreq; - m = ioctl(s, I_STR, (char *) &ioc); - ifconf.ifc_len = ioc.ic_len; - ifconf.ifc_req = ifreq; -#else /* SVR4 */ - ifconf.ifc_len = sizeof(ifreq); - ifconf.ifc_req = ifreq; - m = ioctl(s, SIOCGIFCONF, (caddr_t) & ifconf); -#endif /* SVR4 */ - if ((m < 0) || (ifconf.ifc_len <= 0)) { - report(LOG_ERR, "ioctl SIOCGIFCONF"); - return (struct ifreq *) 0; - } - } - maxmatch = 7; /* this many bits or less... */ - ifrmax = (struct ifreq *) 0;/* ... is not a valid match */ - p = (char *) ifreq; - len = ifconf.ifc_len; - while (len > 0) { - ifrq = (struct ifreq *) p; - sip = (struct sockaddr_in *) &ifrq->ifr_addr; - m = nmatch(addrp, &(sip->sin_addr)); - if (m > maxmatch) { - maxmatch = m; - ifrmax = ifrq; - } - /* XXX - Could this be just #ifndef IFNAMSIZ instead? -gwr */ -#if (BSD - 0) < 43 - /* BSD not defined or earlier than 4.3 */ - incr = sizeof(*ifrq); -#else /* NetBSD */ - incr = ifrq->ifr_addr.sa_len + IFNAMSIZ; -#endif /* NetBSD */ - - p += incr; - len -= incr; - } - - return ifrmax; -} - -/* - * Return the number of leading bits matching in the - * internet addresses supplied. - */ -static int -nmatch(ca, cb) - u_char *ca, *cb; /* ptrs to IP address, network order */ -{ - u_int m = 0; /* count of matching bits */ - u_int n = 4; /* bytes left, then bitmask */ - - /* Count matching bytes. */ - while (n && (*ca == *cb)) { - ca++; - cb++; - m += 8; - n--; - } - /* Now count matching bits. */ - if (n) { - n = 0x80; - while (n && ((*ca & n) == (*cb & n))) { - m++; - n >>= 1; - } - } - return (m); -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/getif.h b/libexec/bootpd/getif.h deleted file mode 100644 index c51dafd2095a..000000000000 --- a/libexec/bootpd/getif.h +++ /dev/null @@ -1,7 +0,0 @@ -/* getif.h */ - -#ifdef __STDC__ -extern struct ifreq *getif(int, struct in_addr *); -#else -extern struct ifreq *getif(); -#endif diff --git a/libexec/bootpd/hash.c b/libexec/bootpd/hash.c deleted file mode 100644 index e78001b732a2..000000000000 --- a/libexec/bootpd/hash.c +++ /dev/null @@ -1,425 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU 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. -************************************************************************/ - -#ifndef lint -static char rcsid[] = "$Header: /cvsroot/src/libexec/bootpd/Attic/hash.c,v 1.2 1994/05/24 15:20:37 gwr Exp $"; -#endif - - -/* - * Generalized hash table ADT - * - * Provides multiple, dynamically-allocated, variable-sized hash tables on - * various data and keys. - * - * This package attempts to follow some of the coding conventions suggested - * by Bob Sidebotham and the AFS Clean Code Committee of the - * Information Technology Center at Carnegie Mellon. - */ - - -#include -#include - -#ifndef USE_BFUNCS -#include -/* Yes, memcpy is OK here (no overlapped copies). */ -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "hash.h" - -#define TRUE 1 -#define FALSE 0 -#ifndef NULL -#define NULL 0 -#endif - -/* - * This can be changed to make internal routines visible to debuggers, etc. - */ -#ifndef PRIVATE -#define PRIVATE static -#endif - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -PRIVATE void hashi_FreeMembers P((hash_member *, hash_freefp)); - -#undef P - - - -/* - * Hash table initialization routine. - * - * This routine creates and intializes a hash table of size "tablesize" - * entries. Successful calls return a pointer to the hash table (which must - * be passed to other hash routines to identify the hash table). Failed - * calls return NULL. - */ - -hash_tbl * -hash_Init(tablesize) - unsigned tablesize; -{ - register hash_tbl *hashtblptr; - register unsigned totalsize; - - if (tablesize > 0) { - totalsize = sizeof(hash_tbl) - + sizeof(hash_member *) * (tablesize - 1); - hashtblptr = (hash_tbl *) malloc(totalsize); - if (hashtblptr) { - bzero((char *) hashtblptr, totalsize); - hashtblptr->size = tablesize; /* Success! */ - hashtblptr->bucketnum = 0; - hashtblptr->member = (hashtblptr->table)[0]; - } - } else { - hashtblptr = NULL; /* Disallow zero-length tables */ - } - return hashtblptr; /* NULL if failure */ -} - - - -/* - * Frees an entire linked list of bucket members (used in the open - * hashing scheme). Does nothing if the passed pointer is NULL. - */ - -PRIVATE void -hashi_FreeMembers(bucketptr, free_data) - hash_member *bucketptr; - hash_freefp free_data; -{ - hash_member *nextbucket; - while (bucketptr) { - nextbucket = bucketptr->next; - (*free_data) (bucketptr->data); - free((char *) bucketptr); - bucketptr = nextbucket; - } -} - - - - -/* - * This routine re-initializes the hash table. It frees all the allocated - * memory and resets all bucket pointers to NULL. - */ - -void -hash_Reset(hashtable, free_data) - hash_tbl *hashtable; - hash_freefp free_data; -{ - hash_member **bucketptr; - unsigned i; - - bucketptr = hashtable->table; - for (i = 0; i < hashtable->size; i++) { - hashi_FreeMembers(*bucketptr, free_data); - *bucketptr++ = NULL; - } - hashtable->bucketnum = 0; - hashtable->member = (hashtable->table)[0]; -} - - - -/* - * Generic hash function to calculate a hash code from the given string. - * - * For each byte of the string, this function left-shifts the value in an - * accumulator and then adds the byte into the accumulator. The contents of - * the accumulator is returned after the entire string has been processed. - * It is assumed that this result will be used as the "hashcode" parameter in - * calls to other functions in this package. These functions automatically - * adjust the hashcode for the size of each hashtable. - * - * This algorithm probably works best when the hash table size is a prime - * number. - * - * Hopefully, this function is better than the previous one which returned - * the sum of the squares of all the bytes. I'm still open to other - * suggestions for a default hash function. The programmer is more than - * welcome to supply his/her own hash function as that is one of the design - * features of this package. - */ - -unsigned -hash_HashFunction(string, len) - unsigned char *string; - register unsigned len; -{ - register unsigned accum; - - accum = 0; - for (; len > 0; len--) { - accum <<= 1; - accum += (unsigned) (*string++ & 0xFF); - } - return accum; -} - - - -/* - * Returns TRUE if at least one entry for the given key exists; FALSE - * otherwise. - */ - -int -hash_Exists(hashtable, hashcode, compare, key) - hash_tbl *hashtable; - unsigned hashcode; - hash_cmpfp compare; - hash_datum *key; -{ - register hash_member *memberptr; - - memberptr = (hashtable->table)[hashcode % (hashtable->size)]; - while (memberptr) { - if ((*compare) (key, memberptr->data)) { - return TRUE; /* Entry does exist */ - } - memberptr = memberptr->next; - } - return FALSE; /* Entry does not exist */ -} - - - -/* - * Insert the data item "element" into the hash table using "hashcode" - * to determine the bucket number, and "compare" and "key" to determine - * its uniqueness. - * - * If the insertion is successful 0 is returned. If a matching entry - * already exists in the given bucket of the hash table, or some other error - * occurs, -1 is returned and the insertion is not done. - */ - -int -hash_Insert(hashtable, hashcode, compare, key, element) - hash_tbl *hashtable; - unsigned hashcode; - hash_cmpfp compare; - hash_datum *key, *element; -{ - hash_member *temp; - - hashcode %= hashtable->size; - if (hash_Exists(hashtable, hashcode, compare, key)) { - return -1; /* At least one entry already exists */ - } - temp = (hash_member *) malloc(sizeof(hash_member)); - if (!temp) - return -1; /* malloc failed! */ - - temp->data = element; - temp->next = (hashtable->table)[hashcode]; - (hashtable->table)[hashcode] = temp; - return 0; /* Success */ -} - - - -/* - * Delete all data elements which match the given key. If at least one - * element is found and the deletion is successful, 0 is returned. - * If no matching elements can be found in the hash table, -1 is returned. - */ - -int -hash_Delete(hashtable, hashcode, compare, key, free_data) - hash_tbl *hashtable; - unsigned hashcode; - hash_cmpfp compare; - hash_datum *key; - hash_freefp free_data; -{ - hash_member *memberptr, *tempptr; - hash_member *previous = NULL; - int retval; - - retval = -1; - hashcode %= hashtable->size; - - /* - * Delete the first member of the list if it matches. Since this moves - * the second member into the first position we have to keep doing this - * over and over until it no longer matches. - */ - memberptr = (hashtable->table)[hashcode]; - while (memberptr && (*compare) (key, memberptr->data)) { - (hashtable->table)[hashcode] = memberptr->next; - /* - * Stop hashi_FreeMembers() from deleting the whole list! - */ - memberptr->next = NULL; - hashi_FreeMembers(memberptr, free_data); - memberptr = (hashtable->table)[hashcode]; - retval = 0; - } - - /* - * Now traverse the rest of the list - */ - if (memberptr) { - previous = memberptr; - memberptr = memberptr->next; - } - while (memberptr) { - if ((*compare) (key, memberptr->data)) { - tempptr = memberptr; - previous->next = memberptr = memberptr->next; - /* - * Put the brakes on hashi_FreeMembers(). . . . - */ - tempptr->next = NULL; - hashi_FreeMembers(tempptr, free_data); - retval = 0; - } else { - previous = memberptr; - memberptr = memberptr->next; - } - } - return retval; -} - - - -/* - * Locate and return the data entry associated with the given key. - * - * If the data entry is found, a pointer to it is returned. Otherwise, - * NULL is returned. - */ - -hash_datum * -hash_Lookup(hashtable, hashcode, compare, key) - hash_tbl *hashtable; - unsigned hashcode; - hash_cmpfp compare; - hash_datum *key; -{ - hash_member *memberptr; - - memberptr = (hashtable->table)[hashcode % (hashtable->size)]; - while (memberptr) { - if ((*compare) (key, memberptr->data)) { - return (memberptr->data); - } - memberptr = memberptr->next; - } - return NULL; -} - - - -/* - * Return the next available entry in the hashtable for a linear search - */ - -hash_datum * -hash_NextEntry(hashtable) - hash_tbl *hashtable; -{ - register unsigned bucket; - register hash_member *memberptr; - - /* - * First try to pick up where we left off. - */ - memberptr = hashtable->member; - if (memberptr) { - hashtable->member = memberptr->next; /* Set up for next call */ - return memberptr->data; /* Return the data */ - } - /* - * We hit the end of a chain, so look through the array of buckets - * until we find a new chain (non-empty bucket) or run out of buckets. - */ - bucket = hashtable->bucketnum + 1; - while ((bucket < hashtable->size) && - !(memberptr = (hashtable->table)[bucket])) { - bucket++; - } - - /* - * Check to see if we ran out of buckets. - */ - if (bucket >= hashtable->size) { - /* - * Reset to top of table for next call. - */ - hashtable->bucketnum = 0; - hashtable->member = (hashtable->table)[0]; - /* - * But return end-of-table indication to the caller this time. - */ - return NULL; - } - /* - * Must have found a non-empty bucket. - */ - hashtable->bucketnum = bucket; - hashtable->member = memberptr->next; /* Set up for next call */ - return memberptr->data; /* Return the data */ -} - - - -/* - * Return the first entry in a hash table for a linear search - */ - -hash_datum * -hash_FirstEntry(hashtable) - hash_tbl *hashtable; -{ - hashtable->bucketnum = 0; - hashtable->member = (hashtable->table)[0]; - return hash_NextEntry(hashtable); -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/hash.h b/libexec/bootpd/hash.h deleted file mode 100644 index 51d0a5ebd33b..000000000000 --- a/libexec/bootpd/hash.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef HASH_H -#define HASH_H -/* hash.h */ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU 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. -************************************************************************/ - -/* - * Generalized hash table ADT - * - * Provides multiple, dynamically-allocated, variable-sized hash tables on - * various data and keys. - * - * This package attempts to follow some of the coding conventions suggested - * by Bob Sidebotham and the AFS Clean Code Committee. - */ - - -/* - * The user must supply the following: - * - * 1. A comparison function which is declared as: - * - * int compare(data1, data2) - * hash_datum *data1, *data2; - * - * This function must compare the desired fields of data1 and - * data2 and return TRUE (1) if the data should be considered - * equivalent (i.e. have the same key value) or FALSE (0) - * otherwise. This function is called through a pointer passed to - * the various hashtable functions (thus pointers to different - * functions may be passed to effect different tests on different - * hash tables). - * - * Internally, all the functions of this package always call the - * compare function with the "key" parameter as the first parameter, - * and a full data element as the second parameter. Thus, the key - * and element arguments to functions such as hash_Lookup() may - * actually be of different types and the programmer may provide a - * compare function which compares the two different object types - * as desired. - * - * Example: - * - * int compare(key, element) - * char *key; - * struct some_complex_structure *element; - * { - * return !strcmp(key, element->name); - * } - * - * key = "John C. Doe" - * element = &some_complex_structure - * hash_Lookup(table, hashcode, compare, key); - * - * 2. A hash function yielding an unsigned integer value to be used - * as the hashcode (index into the hashtable). Thus, the user - * may hash on whatever data is desired and may use several - * different hash functions for various different hash tables. - * The actual hash table index will be the passed hashcode modulo - * the hash table size. - * - * A generalized hash function, hash_HashFunction(), is included - * with this package to make things a little easier. It is not - * guarenteed to use the best hash algorithm in existence. . . . - */ - - - -/* - * Various hash table definitions - */ - - -/* - * Define "hash_datum" as a universal data type - */ -#ifdef __STDC__ -typedef void hash_datum; -#else -typedef char hash_datum; -#endif - -typedef struct hash_memberstruct hash_member; -typedef struct hash_tblstruct hash_tbl; -typedef struct hash_tblstruct_hdr hash_tblhdr; - -struct hash_memberstruct { - hash_member *next; - hash_datum *data; -}; - -struct hash_tblstruct_hdr { - unsigned size, bucketnum; - hash_member *member; -}; - -struct hash_tblstruct { - unsigned size, bucketnum; - hash_member *member; /* Used for linear dump */ - hash_member *table[1]; /* Dynamically extended */ -}; - -/* ANSI function prototypes or empty arg list? */ -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -typedef int (*hash_cmpfp) P((hash_datum *, hash_datum *)); -typedef void (*hash_freefp) P((hash_datum *)); - -extern hash_tbl *hash_Init P((u_int tablesize)); - -extern void hash_Reset P((hash_tbl *tbl, hash_freefp)); - -extern unsigned hash_HashFunction P((u_char *str, u_int len)); - -extern int hash_Exists P((hash_tbl *, u_int code, - hash_cmpfp, hash_datum *key)); - -extern int hash_Insert P((hash_tbl *, u_int code, - hash_cmpfp, hash_datum *key, - hash_datum *element)); - -extern int hash_Delete P((hash_tbl *, u_int code, - hash_cmpfp, hash_datum *key, - hash_freefp)); - -extern hash_datum *hash_Lookup P((hash_tbl *, u_int code, - hash_cmpfp, hash_datum *key)); - -extern hash_datum *hash_FirstEntry P((hash_tbl *)); - -extern hash_datum *hash_NextEntry P((hash_tbl *)); - -#undef P - -#endif /* HASH_H */ diff --git a/libexec/bootpd/hwaddr.c b/libexec/bootpd/hwaddr.c deleted file mode 100644 index 7540fbfea87c..000000000000 --- a/libexec/bootpd/hwaddr.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * hwaddr.c - routines that deal with hardware addresses. - * (i.e. Ethernet) - */ - -#include -#include -#include -#include - -#if defined(SUNOS) || defined(SVR4) -#include -#endif -#ifdef SVR4 -#include -#include -#include -#endif - -#include -#include -#include -#ifndef NO_UNISTD -#include -#endif -#include - -#ifndef USE_BFUNCS -/* Yes, memcpy is OK here (no overlapped copies). */ -#include -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bptypes.h" -#include "hwaddr.h" -#include "report.h" - -extern int debug; - -/* - * Hardware address lengths (in bytes) and network name based on hardware - * type code. List in order specified by Assigned Numbers RFC; Array index - * is hardware type code. Entries marked as zero are unknown to the author - * at this time. . . . - */ - -struct hwinfo hwinfolist[] = -{ - {0, "Reserved"}, /* Type 0: Reserved (don't use this) */ - {6, "Ethernet"}, /* Type 1: 10Mb Ethernet (48 bits) */ - {1, "3Mb Ethernet"}, /* Type 2: 3Mb Ethernet (8 bits) */ - {0, "AX.25"}, /* Type 3: Amateur Radio AX.25 */ - {1, "ProNET"}, /* Type 4: Proteon ProNET Token Ring */ - {0, "Chaos"}, /* Type 5: Chaos */ - {6, "IEEE 802"}, /* Type 6: IEEE 802 Networks */ - {0, "ARCNET"} /* Type 7: ARCNET */ -}; -int hwinfocnt = sizeof(hwinfolist) / sizeof(hwinfolist[0]); - - -/* - * Setup the arp cache so that IP address 'ia' will be temporarily - * bound to hardware address 'ha' of length 'len'. - */ -void -setarp(s, ia, ha, len) - int s; /* socket fd */ - struct in_addr *ia; - u_char *ha; - int len; -{ -#ifdef SIOCSARP - struct arpreq arpreq; /* Arp request ioctl block */ - struct sockaddr_in *si; -#ifdef SVR4 - int fd; - struct strioctl iocb; -#endif /* SVR4 */ - - bzero((caddr_t) & arpreq, sizeof(arpreq)); - arpreq.arp_flags = ATF_INUSE | ATF_COM; - - /* Set up the protocol address. */ - arpreq.arp_pa.sa_family = AF_INET; - si = (struct sockaddr_in *) &arpreq.arp_pa; - si->sin_addr = *ia; - - /* Set up the hardware address. */ - bcopy(ha, arpreq.arp_ha.sa_data, len); - -#ifdef SVR4 - /* - * And now the stuff for System V Rel 4.x which does not - * appear to allow SIOCxxx ioctls on a socket descriptor. - * Thanks to several people: (all sent the same fix) - * Barney Wolff , - * bear@upsys.se (Bj|rn Sj|holm), - * Michael Kuschke , - */ - if ((fd=open("/dev/arp", O_RDWR)) < 0) { - report(LOG_ERR, "open /dev/arp: %s\n", get_errmsg()); - } - iocb.ic_cmd = SIOCSARP; - iocb.ic_timout = 0; - iocb.ic_dp = (char *)&arpreq; - iocb.ic_len = sizeof(arpreq); - if (ioctl(fd, I_STR, (caddr_t)&iocb) < 0) { - report(LOG_ERR, "ioctl I_STR: %s\n", get_errmsg()); - } - close (fd); - -#else /* SVR4 */ - /* - * On SunOS, the ioctl sometimes returns ENXIO, and it - * appears to happen when the ARP cache entry you tried - * to add is already in the cache. (Sigh...) - * XXX - Should this error simply be ignored? -gwr - */ - if (ioctl(s, SIOCSARP, (caddr_t) & arpreq) < 0) { - report(LOG_ERR, "ioctl SIOCSARP: %s", get_errmsg()); - } -#endif /* SVR4 */ -#else /* SIOCSARP */ - /* - * Oh well, SIOCSARP is not defined. Just run arp(8). - * XXX - Gag! - */ - char buf[256]; - int status; - - sprintf(buf, "arp -s %s %s temp", - inet_ntoa(ia), haddrtoa(ha, len)); - if (debug > 2) - report(LOG_INFO, buf); - status = system(buf); - if (status) - report(LOG_ERR, "arp failed, exit code=0x%x", status); - return; -#endif /* SIOCSARP */ -} - - -/* - * Convert a hardware address to an ASCII string. - */ -char * -haddrtoa(haddr, hlen) - u_char *haddr; - int hlen; -{ - static char haddrbuf[3 * MAXHADDRLEN + 1]; - char *bufptr; - - if (hlen > MAXHADDRLEN) - hlen = MAXHADDRLEN; - - bufptr = haddrbuf; - while (hlen > 0) { - sprintf(bufptr, "%02X:", (unsigned) (*haddr++ & 0xFF)); - bufptr += 3; - hlen--; - } - bufptr[-1] = 0; - return (haddrbuf); -} - - -/* - * haddr_conv802() - * -------------- - * - * Converts a backwards address to a canonical address and a canonical address - * to a backwards address. - * - * INPUTS: - * adr_in - pointer to six byte string to convert (unsigned char *) - * addr_len - how many bytes to convert - * - * OUTPUTS: - * addr_out - The string is updated to contain the converted address. - * - * CALLER: - * many - * - * DATA: - * Uses conv802table to bit-reverse the address bytes. - */ - -static u_char conv802table[256] = -{ - /* 0x00 */ 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, - /* 0x08 */ 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, - /* 0x10 */ 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, - /* 0x18 */ 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, - /* 0x20 */ 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, - /* 0x28 */ 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, - /* 0x30 */ 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, - /* 0x38 */ 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, - /* 0x40 */ 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, - /* 0x48 */ 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, - /* 0x50 */ 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, - /* 0x58 */ 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, - /* 0x60 */ 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, - /* 0x68 */ 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, - /* 0x70 */ 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, - /* 0x78 */ 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, - /* 0x80 */ 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, - /* 0x88 */ 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, - /* 0x90 */ 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, - /* 0x98 */ 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, - /* 0xA0 */ 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, - /* 0xA8 */ 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, - /* 0xB0 */ 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, - /* 0xB8 */ 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, - /* 0xC0 */ 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, - /* 0xC8 */ 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, - /* 0xD0 */ 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, - /* 0xD8 */ 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, - /* 0xE0 */ 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, - /* 0xE8 */ 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, - /* 0xF0 */ 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, - /* 0xF8 */ 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF, -}; - -void -haddr_conv802(addr_in, addr_out, len) - register u_char *addr_in, *addr_out; - int len; -{ - u_char *lim; - - lim = addr_out + len; - while (addr_out < lim) - *addr_out++ = conv802table[*addr_in++]; -} - -#if 0 -/* - * For the record, here is a program to generate the - * bit-reverse table above. - */ -static int -bitrev(n) - int n; -{ - int i, r; - - r = 0; - for (i = 0; i < 8; i++) { - r <<= 1; - r |= (n & 1); - n >>= 1; - } - return r; -} - -main() -{ - int i; - for (i = 0; i <= 0xFF; i++) { - if ((i & 7) == 0) - printf("/* 0x%02X */", i); - printf(" 0x%02X,", bitrev(i)); - if ((i & 7) == 7) - printf("\n"); - } -} - -#endif - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/hwaddr.h b/libexec/bootpd/hwaddr.h deleted file mode 100644 index dea7158be8c7..000000000000 --- a/libexec/bootpd/hwaddr.h +++ /dev/null @@ -1,39 +0,0 @@ -/* hwaddr.h */ -#ifndef HWADDR_H -#define HWADDR_H - -#define MAXHADDRLEN 8 /* Max hw address length in bytes */ - -/* - * This structure holds information about a specific network type. The - * length of the network hardware address is stored in "hlen". - * The string pointed to by "name" is the cononical name of the network. - */ -struct hwinfo { - unsigned int hlen; - char *name; -}; - -extern struct hwinfo hwinfolist[]; -extern int hwinfocnt; - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern void setarp P((int, struct in_addr *, u_char *, int)); -extern char *haddrtoa P((u_char *, int)); -extern void haddr_conv802 P((u_char *, u_char *, int)); - -#undef P - -/* - * Return the length in bytes of a hardware address of the given type. - * Return the canonical name of the network of the given type. - */ -#define haddrlength(type) ((hwinfolist[(int) (type)]).hlen) -#define netname(type) ((hwinfolist[(int) (type)]).name) - -#endif /* HWADDR_H */ diff --git a/libexec/bootpd/lookup.c b/libexec/bootpd/lookup.c deleted file mode 100644 index 2a30a59b2c39..000000000000 --- a/libexec/bootpd/lookup.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * lookup.c - Lookup IP address, HW address, netmask - */ - -#include -#include - -#include -#include - -#ifdef ETC_ETHERS -#include -extern int ether_hostton(); -#endif - -#include -#include - -#ifndef USE_BFUNCS -#include -/* Yes, memcpy is OK here (no overlapped copies). */ -#define bcopy(a,b,c) memcpy(b,a,c) -#endif - -#include "bootp.h" -#include "lookup.h" -#include "report.h" - -/* - * Lookup an Ethernet address and return it. - * Return NULL if addr not found. - */ -u_char * -lookup_hwa(hostname, htype) - char *hostname; - int htype; -{ - switch (htype) { - - /* XXX - How is this done on other systems? -gwr */ -#ifdef ETC_ETHERS - case HTYPE_ETHERNET: - case HTYPE_IEEE802: - { - static struct ether_addr ea; - /* This does a lookup in /etc/ethers */ - if (ether_hostton(hostname, &ea)) { - report(LOG_ERR, "no HW addr for host \"%s\"", - hostname); - return (u_char *) 0; - } - return (u_char *) & ea; - } -#endif /* ETC_ETHERS */ - - default: - report(LOG_ERR, "no lookup for HW addr type %d", htype); - } /* switch */ - - /* If the system can't do it, just return an error. */ - return (u_char *) 0; -} - - -/* - * Lookup an IP address. - * Return non-zero on failure. - */ -int -lookup_ipa(hostname, result) - char *hostname; - u_int32 *result; -{ - struct hostent *hp; - hp = gethostbyname(hostname); - if (!hp) - return -1; - bcopy(hp->h_addr, result, sizeof(*result)); - return 0; -} - - -/* - * Lookup a netmask - * Return non-zero on failure. - * - * XXX - This is OK as a default, but to really make this automatic, - * we would need to get the subnet mask from the ether interface. - * If this is wrong, specify the correct value in the bootptab. - */ -int -lookup_netmask(addr, result) - u_int32 addr; /* both in network order */ - u_int32 *result; -{ - int32 m, a; - - a = ntohl(addr); - m = 0; - - if (IN_CLASSA(a)) - m = IN_CLASSA_NET; - - if (IN_CLASSB(a)) - m = IN_CLASSB_NET; - - if (IN_CLASSC(a)) - m = IN_CLASSC_NET; - - if (!m) - return -1; - *result = htonl(m); - return 0; -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/lookup.h b/libexec/bootpd/lookup.h deleted file mode 100644 index 04805d8915c6..000000000000 --- a/libexec/bootpd/lookup.h +++ /dev/null @@ -1,15 +0,0 @@ -/* lookup.h */ - -#include "bptypes.h" /* for int32, u_int32 */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern u_char *lookup_hwa P((char *hostname, int htype)); -extern int lookup_ipa P((char *hostname, u_int32 *addr)); -extern int lookup_netmask P((u_int32 addr, u_int32 *mask)); - -#undef P diff --git a/libexec/bootpd/patchlevel.h b/libexec/bootpd/patchlevel.h deleted file mode 100644 index d48f9d2ec9ec..000000000000 --- a/libexec/bootpd/patchlevel.h +++ /dev/null @@ -1,3 +0,0 @@ -/* patchlevel.h */ -#define VERSION "2.3" -#define PATCHLEVEL 7 diff --git a/libexec/bootpd/print-bootp.c b/libexec/bootpd/print-bootp.c deleted file mode 100644 index 2facac5b27d5..000000000000 --- a/libexec/bootpd/print-bootp.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright (c) 1988-1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' 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. - * - * Format and print bootp packets. - * - * This file was copied from tcpdump-2.1.1 and modified. - * There is an e-mail list for tcpdump: - */ -#ifndef lint -static char rcsid[] = -"@(#) $Header: /cvsroot/src/libexec/bootpd/Attic/print-bootp.c,v 1.1.1.1 1994/05/27 21:46:01 gwr Exp $"; -/* 93/10/10 New data-driven option print routine. */ -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "bootp.h" - -#ifdef BOOTPTEST -#include "bootptest.h" -#else /* BOOTPTEST */ -#include "interface.h" -#include "addrtoname.h" -#endif /* BOOTPTEST */ - -/* These decode the vendor data. */ -static void rfc1048_print(); -static void cmu_print(); -static void other_print(); -static void dump_hex(); - -/* - * Print bootp requests - */ -void -bootp_print(bp, length, sport, dport) - struct bootp *bp; - int length; - u_short sport, dport; -{ - static char tstr[] = " [|bootp]"; - static unsigned char vm_cmu[4] = VM_CMU; - static unsigned char vm_rfc1048[4] = VM_RFC1048; - u_char *ep; - int vdlen; - -#define TCHECK(var, l) if ((u_char *)&(var) > ep - l) goto trunc - - /* Note funny sized packets */ - if (length != sizeof(struct bootp)) - (void) printf(" [len=%d]", length); - - /* 'ep' points to the end of avaible data. */ - ep = (u_char *) snapend; - - switch (bp->bp_op) { - - case BOOTREQUEST: - /* Usually, a request goes from a client to a server */ - if (sport != IPPORT_BOOTPC || dport != IPPORT_BOOTPS) - printf(" (request)"); - break; - - case BOOTREPLY: - /* Usually, a reply goes from a server to a client */ - if (sport != IPPORT_BOOTPS || dport != IPPORT_BOOTPC) - printf(" (reply)"); - break; - - default: - printf(" bootp-#%d", bp->bp_op); - } - - /* The usual hardware address type is 1 (10Mb Ethernet) */ - if (bp->bp_htype != 1) - printf(" htype:%d", bp->bp_htype); - - /* The usual length for 10Mb Ethernet address is 6 bytes */ - if (bp->bp_hlen != 6) - printf(" hlen:%d", bp->bp_hlen); - - /* Client's Hardware address */ - if (bp->bp_hlen) { - register struct ether_header *eh; - register char *e; - - TCHECK(bp->bp_chaddr[0], 6); - eh = (struct ether_header *) packetp; - if (bp->bp_op == BOOTREQUEST) - e = (char *) ESRC(eh); - else if (bp->bp_op == BOOTREPLY) - e = (char *) EDST(eh); - else - e = 0; - if (e == 0 || bcmp((char *) bp->bp_chaddr, e, 6)) - dump_hex(bp->bp_chaddr, bp->bp_hlen); - } - /* Only print interesting fields */ - if (bp->bp_hops) - printf(" hops:%d", bp->bp_hops); - - if (bp->bp_xid) - printf(" xid:%d", ntohl(bp->bp_xid)); - - if (bp->bp_secs) - printf(" secs:%d", ntohs(bp->bp_secs)); - - /* Client's ip address */ - TCHECK(bp->bp_ciaddr, sizeof(bp->bp_ciaddr)); - if (bp->bp_ciaddr.s_addr) - printf(" C:%s", ipaddr_string(&bp->bp_ciaddr)); - - /* 'your' ip address (bootp client) */ - TCHECK(bp->bp_yiaddr, sizeof(bp->bp_yiaddr)); - if (bp->bp_yiaddr.s_addr) - printf(" Y:%s", ipaddr_string(&bp->bp_yiaddr)); - - /* Server's ip address */ - TCHECK(bp->bp_siaddr, sizeof(bp->bp_siaddr)); - if (bp->bp_siaddr.s_addr) - printf(" S:%s", ipaddr_string(&bp->bp_siaddr)); - - /* Gateway's ip address */ - TCHECK(bp->bp_giaddr, sizeof(bp->bp_giaddr)); - if (bp->bp_giaddr.s_addr) - printf(" G:%s", ipaddr_string(&bp->bp_giaddr)); - - TCHECK(bp->bp_sname[0], sizeof(bp->bp_sname)); - if (*bp->bp_sname) { - printf(" sname:"); - if (printfn(bp->bp_sname, ep)) { - fputs(tstr + 1, stdout); - return; - } - } - TCHECK(bp->bp_file[0], sizeof(bp->bp_file)); - if (*bp->bp_file) { - printf(" file:"); - if (printfn(bp->bp_file, ep)) { - fputs(tstr + 1, stdout); - return; - } - } - /* Don't try to decode the vendor buffer unless we're verbose */ - if (vflag <= 0) - return; - - vdlen = sizeof(bp->bp_vend); - /* Vendor data can extend to the end of the packet. */ - if (vdlen < (ep - bp->bp_vend)) - vdlen = (ep - bp->bp_vend); - - TCHECK(bp->bp_vend[0], vdlen); - printf(" vend"); - if (!bcmp(bp->bp_vend, vm_rfc1048, sizeof(u_int32))) - rfc1048_print(bp->bp_vend, vdlen); - else if (!bcmp(bp->bp_vend, vm_cmu, sizeof(u_int32))) - cmu_print(bp->bp_vend, vdlen); - else - other_print(bp->bp_vend, vdlen); - - return; - trunc: - fputs(tstr, stdout); -#undef TCHECK -} - -/* - * Option description data follows. - * These are decribed in: RFC-1048, RFC-1395, RFC-1497, RFC-1533 - * - * The first char of each option string encodes the data format: - * ?: unknown - * a: ASCII - * b: byte (8-bit) - * i: inet address - * l: int32 - * s: short (16-bit) - */ -char * -rfc1048_opts[] = { - /* Originally from RFC-1048: */ - "?PAD", /* 0: Padding - special, no data. */ - "iSM", /* 1: subnet mask (RFC950)*/ - "lTZ", /* 2: time offset, seconds from UTC */ - "iGW", /* 3: gateways (or routers) */ - "iTS", /* 4: time servers (RFC868) */ - "iINS", /* 5: IEN name servers (IEN116) */ - "iDNS", /* 6: domain name servers (RFC1035)(1034?) */ - "iLOG", /* 7: MIT log servers */ - "iCS", /* 8: cookie servers (RFC865) */ - "iLPR", /* 9: lpr server (RFC1179) */ - "iIPS", /* 10: impress servers (Imagen) */ - "iRLP", /* 11: resource location servers (RFC887) */ - "aHN", /* 12: host name (ASCII) */ - "sBFS", /* 13: boot file size (in 512 byte blocks) */ - - /* Added by RFC-1395: */ - "aDUMP", /* 14: Merit Dump File */ - "aDNAM", /* 15: Domain Name (for DNS) */ - "iSWAP", /* 16: Swap Server */ - "aROOT", /* 17: Root Path */ - - /* Added by RFC-1497: */ - "aEXTF", /* 18: Extensions Path (more options) */ - - /* Added by RFC-1533: (many, many options...) */ -#if 1 /* These might not be worth recognizing by name. */ - - /* IP Layer Parameters, per-host (RFC-1533, sect. 4) */ - "bIP-forward", /* 19: IP Forwarding flag */ - "bIP-srcroute", /* 20: IP Source Routing Enable flag */ - "iIP-filters", /* 21: IP Policy Filter (addr pairs) */ - "sIP-maxudp", /* 22: IP Max-UDP reassembly size */ - "bIP-ttlive", /* 23: IP Time to Live */ - "lIP-pmtuage", /* 24: IP Path MTU aging timeout */ - "sIP-pmtutab", /* 25: IP Path MTU plateau table */ - - /* IP parameters, per-interface (RFC-1533, sect. 5) */ - "sIP-mtu-sz", /* 26: IP MTU size */ - "bIP-mtu-sl", /* 27: IP MTU all subnets local */ - "bIP-bcast1", /* 28: IP Broadcast Addr ones flag */ - "bIP-mask-d", /* 29: IP do mask discovery */ - "bIP-mask-s", /* 30: IP do mask supplier */ - "bIP-rt-dsc", /* 31: IP do router discovery */ - "iIP-rt-sa", /* 32: IP router solicitation addr */ - "iIP-routes", /* 33: IP static routes (dst,router) */ - - /* Link Layer parameters, per-interface (RFC-1533, sect. 6) */ - "bLL-trailer", /* 34: do tralier encapsulation */ - "lLL-arp-tmo", /* 35: ARP cache timeout */ - "bLL-ether2", /* 36: Ethernet version 2 (IEEE 802.3) */ - - /* TCP parameters (RFC-1533, sect. 7) */ - "bTCP-def-ttl", /* 37: default time to live */ - "lTCP-KA-tmo", /* 38: keepalive time interval */ - "bTCP-KA-junk", /* 39: keepalive sends extra junk */ - - /* Application and Service Parameters (RFC-1533, sect. 8) */ - "aNISDOM", /* 40: NIS Domain (Sun YP) */ - "iNISSRV", /* 41: NIS Servers */ - "iNTPSRV", /* 42: NTP (time) Servers (RFC 1129) */ - "?VSINFO", /* 43: Vendor Specific Info (encapsulated) */ - "iNBiosNS", /* 44: NetBIOS Name Server (RFC-1001,1..2) */ - "iNBiosDD", /* 45: NetBIOS Datagram Dist. Server. */ - "bNBiosNT", /* 46: NetBIOS Note Type */ - "?NBiosS", /* 47: NetBIOS Scope */ - "iXW-FS", /* 48: X Window System Font Servers */ - "iXW-DM", /* 49: X Window System Display Managers */ - - /* DHCP extensions (RFC-1533, sect. 9) */ -#endif -}; -#define KNOWN_OPTIONS (sizeof(rfc1048_opts) / sizeof(rfc1048_opts[0])) - -static void print_string(); - -static void -rfc1048_print(bp, length) - register u_char *bp; - int length; -{ - u_char tag; - u_char *ep; - register int len, j; - u_int32 ul; - u_short us; - struct in_addr ia; - char *optstr; - - printf("-rfc1395"); - - /* Step over magic cookie */ - bp += sizeof(int32); - /* Setup end pointer */ - ep = bp + length; - while (bp < ep) { - tag = *bp++; - /* Check for tags with no data first. */ - if (tag == TAG_PAD) - continue; - if (tag == TAG_END) - return; - if (tag < KNOWN_OPTIONS) { - optstr = rfc1048_opts[tag]; - printf(" %s:", optstr + 1); - } else { - printf(" T%d:", tag); - optstr = "?"; - } - /* Now scan the length byte. */ - len = *bp++; - if (bp + len > ep) { - /* truncated option */ - printf(" |(%d>%d)", len, ep - bp); - return; - } - /* Print the option value(s). */ - switch (optstr[0]) { - - case 'a': /* ASCII string */ - printfn(bp, bp + len); - bp += len; - len = 0; - break; - - case 's': /* Word formats */ - while (len >= 2) { - bcopy((char *) bp, (char *) &us, 2); - printf("%d", ntohs(us)); - bp += 2; - len -= 2; - if (len) printf(","); - } - if (len) printf("(junk=%d)", len); - break; - - case 'l': /* Long words */ - while (len >= 4) { - bcopy((char *) bp, (char *) &ul, 4); - printf("%d", ntohl(ul)); - bp += 4; - len -= 4; - if (len) printf(","); - } - if (len) printf("(junk=%d)", len); - break; - - case 'i': /* INET addresses */ - while (len >= 4) { - bcopy((char *) bp, (char *) &ia, 4); - printf("%s", ipaddr_string(&ia)); - bp += 4; - len -= 4; - if (len) printf(","); - } - if (len) printf("(junk=%d)", len); - break; - - case 'b': - default: - break; - - } /* switch */ - - /* Print as characters, if appropriate. */ - if (len) { - dump_hex(bp, len); - if (isascii(*bp) && isprint(*bp)) { - printf("("); - printfn(bp, bp + len); - printf(")"); - } - bp += len; - len = 0; - } - } /* while bp < ep */ -} - -static void -cmu_print(bp, length) - register u_char *bp; - int length; -{ - struct cmu_vend *v; - u_char *ep; - - printf("-cmu"); - - v = (struct cmu_vend *) bp; - if (length < sizeof(*v)) { - printf(" |L=%d", length); - return; - } - /* Setup end pointer */ - ep = bp + length; - - /* Subnet mask */ - if (v->v_flags & VF_SMASK) { - printf(" SM:%s", ipaddr_string(&v->v_smask)); - } - /* Default gateway */ - if (v->v_dgate.s_addr) - printf(" GW:%s", ipaddr_string(&v->v_dgate)); - - /* Domain name servers */ - if (v->v_dns1.s_addr) - printf(" DNS1:%s", ipaddr_string(&v->v_dns1)); - if (v->v_dns2.s_addr) - printf(" DNS2:%s", ipaddr_string(&v->v_dns2)); - - /* IEN-116 name servers */ - if (v->v_ins1.s_addr) - printf(" INS1:%s", ipaddr_string(&v->v_ins1)); - if (v->v_ins2.s_addr) - printf(" INS2:%s", ipaddr_string(&v->v_ins2)); - - /* Time servers */ - if (v->v_ts1.s_addr) - printf(" TS1:%s", ipaddr_string(&v->v_ts1)); - if (v->v_ts2.s_addr) - printf(" TS2:%s", ipaddr_string(&v->v_ts2)); - -} - - -/* - * Print out arbitrary, unknown vendor data. - */ - -static void -other_print(bp, length) - register u_char *bp; - int length; -{ - u_char *ep; /* end pointer */ - u_char *zp; /* points one past last non-zero byte */ - register int i, j; - - /* Setup end pointer */ - ep = bp + length; - - /* Find the last non-zero byte. */ - for (zp = ep; zp > bp; zp--) { - if (zp[-1] != 0) - break; - } - - /* Print the all-zero case in a compact representation. */ - if (zp == bp) { - printf("-all-zero"); - return; - } - printf("-unknown"); - - /* Are there enough trailing zeros to make "00..." worthwhile? */ - if (zp + 2 > ep) - zp = ep; /* print them all normally */ - - /* Now just print all the non-zero data. */ - while (bp < zp) { - printf(".%02X", *bp); - bp++; - } - - if (zp < ep) - printf(".00..."); - - return; -} - -static void -dump_hex(bp, len) - u_char *bp; - int len; -{ - while (len > 0) { - printf("%02X", *bp); - bp++; - len--; - if (len) printf("."); - } -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/readfile.c b/libexec/bootpd/readfile.c deleted file mode 100644 index f39502689482..000000000000 --- a/libexec/bootpd/readfile.c +++ /dev/null @@ -1,2048 +0,0 @@ -/************************************************************************ - Copyright 1988, 1991 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name of Carnegie Mellon University not be used -in advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL CMU 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. -************************************************************************/ - -#ifndef lint -static char rcsid[] = "$Header: /cvsroot/src/libexec/bootpd/Attic/readfile.c,v 1.2 1994/05/24 15:20:47 gwr Exp $"; -#endif - - -/* - * bootpd configuration file reading code. - * - * The routines in this file deal with reading, interpreting, and storing - * the information found in the bootpd configuration file (usually - * /etc/bootptab). - */ - - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifndef USE_BFUNCS -#include -/* Yes, memcpy is OK here (no overlapped copies). */ -#define bcopy(a,b,c) memcpy(b,a,c) -#define bzero(p,l) memset(p,0,l) -#define bcmp(a,b,c) memcmp(a,b,c) -#endif - -#include "bootp.h" -#include "hash.h" -#include "hwaddr.h" -#include "lookup.h" -#include "readfile.h" -#include "report.h" -#include "tzone.h" -#include "bootpd.h" - -#define HASHTABLESIZE 257 /* Hash table size (prime) */ - -/* Non-standard hardware address type (see bootp.h) */ -#define HTYPE_DIRECT 0 - -/* Error codes returned by eval_symbol: */ -#define SUCCESS 0 -#define E_END_OF_ENTRY (-1) -#define E_SYNTAX_ERROR (-2) -#define E_UNKNOWN_SYMBOL (-3) -#define E_BAD_IPADDR (-4) -#define E_BAD_HWADDR (-5) -#define E_BAD_LONGWORD (-6) -#define E_BAD_HWATYPE (-7) -#define E_BAD_PATHNAME (-8) - -/* Tag idendities. */ -#define SYM_NULL 0 -#define SYM_BOOTFILE 1 -#define SYM_COOKIE_SERVER 2 -#define SYM_DOMAIN_SERVER 3 -#define SYM_GATEWAY 4 -#define SYM_HWADDR 5 -#define SYM_HOMEDIR 6 -#define SYM_HTYPE 7 -#define SYM_IMPRESS_SERVER 8 -#define SYM_IPADDR 9 -#define SYM_LOG_SERVER 10 -#define SYM_LPR_SERVER 11 -#define SYM_NAME_SERVER 12 -#define SYM_RLP_SERVER 13 -#define SYM_SUBNET_MASK 14 -#define SYM_TIME_OFFSET 15 -#define SYM_TIME_SERVER 16 -#define SYM_VENDOR_MAGIC 17 -#define SYM_SIMILAR_ENTRY 18 -#define SYM_NAME_SWITCH 19 -#define SYM_BOOTSIZE 20 -#define SYM_BOOT_SERVER 22 -#define SYM_TFTPDIR 23 -#define SYM_DUMP_FILE 24 -#define SYM_DOMAIN_NAME 25 -#define SYM_SWAP_SERVER 26 -#define SYM_ROOT_PATH 27 -#define SYM_EXTEN_FILE 28 -#define SYM_REPLY_ADDR 29 -#define SYM_NIS_DOMAIN 30 /* RFC 1533 */ -#define SYM_NIS_SERVER 31 /* RFC 1533 */ -#define SYM_NTP_SERVER 32 /* RFC 1533 */ -/* XXX - Add new tags here */ - -#define OP_ADDITION 1 /* Operations on tags */ -#define OP_DELETION 2 -#define OP_BOOLEAN 3 - -#define MAXINADDRS 16 /* Max size of an IP address list */ -#define MAXBUFLEN 64 /* Max temp buffer space */ -#define MAXENTRYLEN 2048 /* Max size of an entire entry */ - - - -/* - * Structure used to map a configuration-file symbol (such as "ds") to a - * unique integer. - */ - -struct symbolmap { - char *symbol; - int symbolcode; -}; - - -struct htypename { - char *name; - byte htype; -}; - - -PRIVATE int nhosts; /* Number of hosts (/w hw or IP address) */ -PRIVATE int nentries; /* Total number of entries */ -PRIVATE int32 modtime = 0; /* Last modification time of bootptab */ -PRIVATE char *current_hostname; /* Name of the current entry. */ -PRIVATE char current_tagname[8]; - -/* - * List of symbolic names used in the bootptab file. The order and actual - * values of the symbol codes (SYM_. . .) are unimportant, but they must - * all be unique. - */ - -PRIVATE struct symbolmap symbol_list[] = { - {"bf", SYM_BOOTFILE}, - {"bs", SYM_BOOTSIZE}, - {"cs", SYM_COOKIE_SERVER}, - {"df", SYM_DUMP_FILE}, - {"dn", SYM_DOMAIN_NAME}, - {"ds", SYM_DOMAIN_SERVER}, - {"ef", SYM_EXTEN_FILE}, - {"gw", SYM_GATEWAY}, - {"ha", SYM_HWADDR}, - {"hd", SYM_HOMEDIR}, - {"hn", SYM_NAME_SWITCH}, - {"ht", SYM_HTYPE}, - {"im", SYM_IMPRESS_SERVER}, - {"ip", SYM_IPADDR}, - {"lg", SYM_LOG_SERVER}, - {"lp", SYM_LPR_SERVER}, - {"ns", SYM_NAME_SERVER}, - {"nt", SYM_NTP_SERVER}, - {"ra", SYM_REPLY_ADDR}, - {"rl", SYM_RLP_SERVER}, - {"rp", SYM_ROOT_PATH}, - {"sa", SYM_BOOT_SERVER}, - {"sm", SYM_SUBNET_MASK}, - {"sw", SYM_SWAP_SERVER}, - {"tc", SYM_SIMILAR_ENTRY}, - {"td", SYM_TFTPDIR}, - {"to", SYM_TIME_OFFSET}, - {"ts", SYM_TIME_SERVER}, - {"vm", SYM_VENDOR_MAGIC}, - {"yd", SYM_NIS_DOMAIN}, - {"ys", SYM_NIS_SERVER}, - /* XXX - Add new tags here */ -}; - - -/* - * List of symbolic names for hardware types. Name translates into - * hardware type code listed with it. Names must begin with a letter - * and must be all lowercase. This is searched linearly, so put - * commonly-used entries near the beginning. - */ - -PRIVATE struct htypename htnamemap[] = { - {"ethernet", HTYPE_ETHERNET}, - {"ethernet3", HTYPE_EXP_ETHERNET}, - {"ether", HTYPE_ETHERNET}, - {"ether3", HTYPE_EXP_ETHERNET}, - {"ieee802", HTYPE_IEEE802}, - {"tr", HTYPE_IEEE802}, - {"token-ring", HTYPE_IEEE802}, - {"pronet", HTYPE_PRONET}, - {"chaos", HTYPE_CHAOS}, - {"arcnet", HTYPE_ARCNET}, - {"ax.25", HTYPE_AX25}, - {"direct", HTYPE_DIRECT}, - {"serial", HTYPE_DIRECT}, - {"slip", HTYPE_DIRECT}, - {"ppp", HTYPE_DIRECT} -}; - - - -/* - * Externals and forward declarations. - */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern boolean iplookcmp(); -boolean nmcmp P((hash_datum *, hash_datum *)); - -PRIVATE void - adjust P((char **)); -PRIVATE void - del_string P((struct shared_string *)); -PRIVATE void - del_bindata P((struct shared_bindata *)); -PRIVATE void - del_iplist P((struct in_addr_list *)); -PRIVATE void - eat_whitespace P((char **)); -PRIVATE int - eval_symbol P((char **, struct host *)); -PRIVATE void - fill_defaults P((struct host *, char **)); -PRIVATE void - free_host P((hash_datum *)); -PRIVATE struct in_addr_list * - get_addresses P((char **)); -PRIVATE struct shared_string * - get_shared_string P((char **)); -PRIVATE char * - get_string P((char **, char *, u_int *)); -PRIVATE u_int32 - get_u_long P((char **)); -PRIVATE boolean - goodname P((char *)); -PRIVATE boolean - hwinscmp P((hash_datum *, hash_datum *)); -PRIVATE int - interp_byte P((char **, byte *)); -PRIVATE void - makelower P((char *)); -PRIVATE boolean - nullcmp P((hash_datum *, hash_datum *)); -PRIVATE int - process_entry P((struct host *, char *)); -PRIVATE int - process_generic P((char **, struct shared_bindata **, u_int)); -PRIVATE byte * - prs_haddr P((char **, u_int)); -PRIVATE int - prs_inetaddr P((char **, u_int32 *)); -PRIVATE void - read_entry P((FILE *, char *, u_int *)); -PRIVATE char * - smalloc P((u_int)); - -#undef P - - -/* - * Vendor magic cookies for CMU and RFC1048 - */ -u_char vm_cmu[4] = VM_CMU; -u_char vm_rfc1048[4] = VM_RFC1048; - -/* - * Main hash tables - */ -hash_tbl *hwhashtable; -hash_tbl *iphashtable; -hash_tbl *nmhashtable; - -/* - * Allocate hash tables for hardware address, ip address, and hostname - * (shared by bootpd and bootpef) - */ -void -rdtab_init() -{ - hwhashtable = hash_Init(HASHTABLESIZE); - iphashtable = hash_Init(HASHTABLESIZE); - nmhashtable = hash_Init(HASHTABLESIZE); - if (!(hwhashtable && iphashtable && nmhashtable)) { - report(LOG_ERR, "Unable to allocate hash tables."); - exit(1); - } -} - - -/* - * Read bootptab database file. Avoid rereading the file if the - * write date hasn't changed since the last time we read it. - */ - -void -readtab(force) - int force; -{ - struct host *hp; - FILE *fp; - struct stat st; - unsigned hashcode, buflen; - static char buffer[MAXENTRYLEN]; - - /* - * Check the last modification time. - */ - if (stat(bootptab, &st) < 0) { - report(LOG_ERR, "stat on \"%s\": %s", - bootptab, get_errmsg()); - return; - } -#ifdef DEBUG - if (debug > 3) { - char timestr[28]; - strcpy(timestr, ctime(&(st.st_mtime))); - /* zap the newline */ - timestr[24] = '\0'; - report(LOG_INFO, "bootptab mtime: %s", - timestr); - } -#endif - if ((force == 0) && - (st.st_mtime == modtime) && - st.st_nlink) { - /* - * hasn't been modified or deleted yet. - */ - return; - } - if (debug) - report(LOG_INFO, "reading %s\"%s\"", - (modtime != 0L) ? "new " : "", - bootptab); - - /* - * Open bootptab file. - */ - if ((fp = fopen(bootptab, "r")) == NULL) { - report(LOG_ERR, "error opening \"%s\": %s", bootptab, get_errmsg()); - return; - } - /* - * Record file modification time. - */ - if (fstat(fileno(fp), &st) < 0) { - report(LOG_ERR, "fstat: %s", get_errmsg()); - fclose(fp); - return; - } - modtime = st.st_mtime; - - /* - * Entirely erase all hash tables. - */ - hash_Reset(hwhashtable, free_host); - hash_Reset(iphashtable, free_host); - hash_Reset(nmhashtable, free_host); - - nhosts = 0; - nentries = 0; - while (TRUE) { - buflen = sizeof(buffer); - read_entry(fp, buffer, &buflen); - if (buflen == 0) { /* More entries? */ - break; - } - hp = (struct host *) smalloc(sizeof(struct host)); - bzero((char *) hp, sizeof(*hp)); - /* the link count it zero */ - - /* - * Get individual info - */ - if (process_entry(hp, buffer) < 0) { - hp->linkcount = 1; - free_host((hash_datum *) hp); - continue; - } - /* - * If this is not a dummy entry, and the IP or HW - * address is not yet set, try to get them here. - * Dummy entries have . as first char of name. - */ - if (goodname(hp->hostname->string)) { - char *hn = hp->hostname->string; - u_int32 value; - if (hp->flags.iaddr == 0) { - if (lookup_ipa(hn, &value)) { - report(LOG_ERR, "can not get IP addr for %s", hn); - report(LOG_ERR, "(dummy names should start with '.')"); - } else { - hp->iaddr.s_addr = value; - hp->flags.iaddr = TRUE; - } - } - /* Set default subnet mask. */ - if (hp->flags.subnet_mask == 0) { - if (lookup_netmask(hp->iaddr.s_addr, &value)) { - report(LOG_ERR, "can not get netmask for %s", hn); - } else { - hp->subnet_mask.s_addr = value; - hp->flags.subnet_mask = TRUE; - } - } - } - if (hp->flags.iaddr) { - nhosts++; - } - /* Register by HW addr if known. */ - if (hp->flags.htype && hp->flags.haddr) { - /* We will either insert it or free it. */ - hp->linkcount++; - hashcode = hash_HashFunction(hp->haddr, haddrlength(hp->htype)); - if (hash_Insert(hwhashtable, hashcode, hwinscmp, hp, hp) < 0) { - report(LOG_NOTICE, "duplicate %s address: %s", - netname(hp->htype), - haddrtoa(hp->haddr, hp->htype)); - free_host((hash_datum *) hp); - continue; - } - } - /* Register by IP addr if known. */ - if (hp->flags.iaddr) { - hashcode = hash_HashFunction((u_char *) & (hp->iaddr.s_addr), 4); - if (hash_Insert(iphashtable, hashcode, nullcmp, hp, hp) < 0) { - report(LOG_ERR, - "hash_Insert() failed on IP address insertion"); - } else { - /* Just inserted the host struct in a new hash list. */ - hp->linkcount++; - } - } - /* Register by Name (always known) */ - hashcode = hash_HashFunction((u_char *) hp->hostname->string, - strlen(hp->hostname->string)); - if (hash_Insert(nmhashtable, hashcode, nullcmp, - hp->hostname->string, hp) < 0) { - report(LOG_ERR, - "hash_Insert() failed on insertion of hostname: \"%s\"", - hp->hostname->string); - } else { - /* Just inserted the host struct in a new hash list. */ - hp->linkcount++; - } - - nentries++; - } - - fclose(fp); - if (debug) - report(LOG_INFO, "read %d entries (%d hosts) from \"%s\"", - nentries, nhosts, bootptab); - return; -} - - - -/* - * Read an entire host entry from the file pointed to by "fp" and insert it - * into the memory pointed to by "buffer". Leading whitespace and comments - * starting with "#" are ignored (removed). Backslashes (\) always quote - * the next character except that newlines preceeded by a backslash cause - * line-continuation onto the next line. The entry is terminated by a - * newline character which is not preceeded by a backslash. Sequences - * surrounded by double quotes are taken literally (including newlines, but - * not backslashes). - * - * The "bufsiz" parameter points to an unsigned int which specifies the - * maximum permitted buffer size. Upon return, this value will be replaced - * with the actual length of the entry (not including the null terminator). - * - * This code is a little scary. . . . I don't like using gotos in C - * either, but I first wrote this as an FSM diagram and gotos seemed like - * the easiest way to implement it. Maybe later I'll clean it up. - */ - -PRIVATE void -read_entry(fp, buffer, bufsiz) - FILE *fp; - char *buffer; - unsigned *bufsiz; -{ - int c, length; - - length = 0; - - /* - * Eat whitespace, blank lines, and comment lines. - */ - top: - c = fgetc(fp); - if (c < 0) { - goto done; /* Exit if end-of-file */ - } - if (isspace(c)) { - goto top; /* Skip over whitespace */ - } - if (c == '#') { - while (TRUE) { /* Eat comments after # */ - c = fgetc(fp); - if (c < 0) { - goto done; /* Exit if end-of-file */ - } - if (c == '\n') { - goto top; /* Try to read the next line */ - } - } - } - ungetc(c, fp); /* Other character, push it back to reprocess it */ - - - /* - * Now we're actually reading a data entry. Get each character and - * assemble it into the data buffer, processing special characters like - * double quotes (") and backslashes (\). - */ - - mainloop: - c = fgetc(fp); - switch (c) { - case EOF: - case '\n': - goto done; /* Exit on EOF or newline */ - case '\\': - c = fgetc(fp); /* Backslash, read a new character */ - if (c < 0) { - goto done; /* Exit on EOF */ - } - *buffer++ = c; /* Store the literal character */ - length++; - if (length < *bufsiz - 1) { - goto mainloop; - } else { - goto done; - } - case '"': - *buffer++ = '"'; /* Store double-quote */ - length++; - if (length >= *bufsiz - 1) { - goto done; - } - while (TRUE) { /* Special quote processing loop */ - c = fgetc(fp); - switch (c) { - case EOF: - goto done; /* Exit on EOF . . . */ - case '"': - *buffer++ = '"';/* Store matching quote */ - length++; - if (length < *bufsiz - 1) { - goto mainloop; /* And continue main loop */ - } else { - goto done; - } - case '\\': - if ((c = fgetc(fp)) < 0) { /* Backslash */ - goto done; /* EOF. . . .*/ - } /* else fall through */ - default: - *buffer++ = c; /* Other character, store it */ - length++; - if (length >= *bufsiz - 1) { - goto done; - } - } - } - case ':': - *buffer++ = c; /* Store colons */ - length++; - if (length >= *bufsiz - 1) { - goto done; - } - do { /* But remove whitespace after them */ - c = fgetc(fp); - if ((c < 0) || (c == '\n')) { - goto done; - } - } while (isspace(c)); /* Skip whitespace */ - - if (c == '\\') { /* Backslash quotes next character */ - c = fgetc(fp); - if (c < 0) { - goto done; - } - if (c == '\n') { - goto top; /* Backslash-newline continuation */ - } - } - /* fall through if "other" character */ - default: - *buffer++ = c; /* Store other characters */ - length++; - if (length >= *bufsiz - 1) { - goto done; - } - } - goto mainloop; /* Keep going */ - - done: - *buffer = '\0'; /* Terminate string */ - *bufsiz = length; /* Tell the caller its length */ -} - - - -/* - * Parse out all the various tags and parameters in the host entry pointed - * to by "src". Stuff all the data into the appropriate fields of the - * host structure pointed to by "host". If there is any problem with the - * entry, an error message is reported via report(), no further processing - * is done, and -1 is returned. Successful calls return 0. - * - * (Some errors probably shouldn't be so completely fatal. . . .) - */ - -PRIVATE int -process_entry(host, src) - struct host *host; - char *src; -{ - int retval; - char *msg; - - if (!host || *src == '\0') { - return -1; - } - host->hostname = get_shared_string(&src); -#if 0 - /* Be more liberal for the benefit of dummy tag names. */ - if (!goodname(host->hostname->string)) { - report(LOG_ERR, "bad hostname: \"%s\"", host->hostname->string); - del_string(host->hostname); - return -1; - } -#endif - current_hostname = host->hostname->string; - adjust(&src); - while (TRUE) { - retval = eval_symbol(&src, host); - if (retval == SUCCESS) { - adjust(&src); - continue; - } - if (retval == E_END_OF_ENTRY) { - /* The default subnet mask is set in readtab() */ - return 0; - } - /* Some kind of error. */ - switch (retval) { - case E_SYNTAX_ERROR: - msg = "bad syntax"; - break; - case E_UNKNOWN_SYMBOL: - msg = "unknown symbol"; - break; - case E_BAD_IPADDR: - msg = "bad INET address"; - break; - case E_BAD_HWADDR: - msg = "bad hardware address"; - break; - case E_BAD_LONGWORD: - msg = "bad longword value"; - break; - case E_BAD_HWATYPE: - msg = "bad HW address type"; - break; - case E_BAD_PATHNAME: - msg = "bad pathname (need leading '/')"; - default: - msg = "unkown error"; - break; - } /* switch */ - report(LOG_ERR, "in entry named \"%s\", symbol \"%s\": %s", - current_hostname, current_tagname, msg); - return -1; - } -} - - -/* - * Macros for use in the function below: - */ - -/* Parse one INET address stored directly in MEMBER. */ -#define PARSE_IA1(MEMBER) do \ -{ \ - if (optype == OP_BOOLEAN) \ - return E_SYNTAX_ERROR; \ - hp->flags.MEMBER = FALSE; \ - if (optype == OP_ADDITION) { \ - if (prs_inetaddr(symbol, &value) < 0) \ - return E_BAD_IPADDR; \ - hp->MEMBER.s_addr = value; \ - hp->flags.MEMBER = TRUE; \ - } \ -} while (0) - -/* Parse a list of INET addresses pointed to by MEMBER */ -#define PARSE_IAL(MEMBER) do \ -{ \ - if (optype == OP_BOOLEAN) \ - return E_SYNTAX_ERROR; \ - if (hp->flags.MEMBER) { \ - hp->flags.MEMBER = FALSE; \ - assert(hp->MEMBER); \ - del_iplist(hp->MEMBER); \ - hp->MEMBER = NULL; \ - } \ - if (optype == OP_ADDITION) { \ - hp->MEMBER = get_addresses(symbol); \ - if (hp->MEMBER == NULL) \ - return E_SYNTAX_ERROR; \ - hp->flags.MEMBER = TRUE; \ - } \ -} while (0) - -/* Parse a shared string pointed to by MEMBER */ -#define PARSE_STR(MEMBER) do \ -{ \ - if (optype == OP_BOOLEAN) \ - return E_SYNTAX_ERROR; \ - if (hp->flags.MEMBER) { \ - hp->flags.MEMBER = FALSE; \ - assert(hp->MEMBER); \ - del_string(hp->MEMBER); \ - hp->MEMBER = NULL; \ - } \ - if (optype == OP_ADDITION) { \ - hp->MEMBER = get_shared_string(symbol); \ - if (hp->MEMBER == NULL) \ - return E_SYNTAX_ERROR; \ - hp->flags.MEMBER = TRUE; \ - } \ -} while (0) - -/* - * Evaluate the two-character tag symbol pointed to by "symbol" and place - * the data in the structure pointed to by "hp". The pointer pointed to - * by "symbol" is updated to point past the source string (but may not - * point to the next tag entry). - * - * Obviously, this need a few more comments. . . . - */ -PRIVATE int -eval_symbol(symbol, hp) - char **symbol; - struct host *hp; -{ - char tmpstr[MAXSTRINGLEN]; - byte *tmphaddr; - struct shared_string *ss; - struct symbolmap *symbolptr; - u_int32 value; - int32 timeoff; - int i, numsymbols; - unsigned len; - int optype; /* Indicates boolean, addition, or deletion */ - - eat_whitespace(symbol); - - /* Make sure this is set before returning. */ - current_tagname[0] = (*symbol)[0]; - current_tagname[1] = (*symbol)[1]; - current_tagname[2] = 0; - - if ((*symbol)[0] == '\0') { - return E_END_OF_ENTRY; - } - if ((*symbol)[0] == ':') { - return SUCCESS; - } - if ((*symbol)[0] == 'T') { /* generic symbol */ - (*symbol)++; - value = get_u_long(symbol); - sprintf(current_tagname, "T%d", value); - eat_whitespace(symbol); - if ((*symbol)[0] != '=') { - return E_SYNTAX_ERROR; - } - (*symbol)++; - if (!(hp->generic)) { - hp->generic = (struct shared_bindata *) - smalloc(sizeof(struct shared_bindata)); - } - if (process_generic(symbol, &(hp->generic), (byte) (value & 0xFF))) - return E_SYNTAX_ERROR; - hp->flags.generic = TRUE; - return SUCCESS; - } - /* - * Determine the type of operation to be done on this symbol - */ - switch ((*symbol)[2]) { - case '=': - optype = OP_ADDITION; - break; - case '@': - optype = OP_DELETION; - break; - case ':': - case '\0': - optype = OP_BOOLEAN; - break; - default: - return E_SYNTAX_ERROR; - } - - symbolptr = symbol_list; - numsymbols = sizeof(symbol_list) / sizeof(struct symbolmap); - for (i = 0; i < numsymbols; i++) { - if (((symbolptr->symbol)[0] == (*symbol)[0]) && - ((symbolptr->symbol)[1] == (*symbol)[1])) { - break; - } - symbolptr++; - } - if (i >= numsymbols) { - return E_UNKNOWN_SYMBOL; - } - /* - * Skip past the = or @ character (to point to the data) if this - * isn't a boolean operation. For boolean operations, just skip - * over the two-character tag symbol (and nothing else. . . .). - */ - (*symbol) += (optype == OP_BOOLEAN) ? 2 : 3; - - eat_whitespace(symbol); - - /* The cases below are in order by symbolcode value. */ - switch (symbolptr->symbolcode) { - - case SYM_BOOTFILE: - PARSE_STR(bootfile); - break; - - case SYM_COOKIE_SERVER: - PARSE_IAL(cookie_server); - break; - - case SYM_DOMAIN_SERVER: - PARSE_IAL(domain_server); - break; - - case SYM_GATEWAY: - PARSE_IAL(gateway); - break; - - case SYM_HWADDR: - if (optype == OP_BOOLEAN) - return E_SYNTAX_ERROR; - hp->flags.haddr = FALSE; - if (optype == OP_ADDITION) { - /* Default the HW type to Ethernet */ - if (hp->flags.htype == 0) { - hp->flags.htype = TRUE; - hp->htype = HTYPE_ETHERNET; - } - tmphaddr = prs_haddr(symbol, hp->htype); - if (!tmphaddr) - return E_BAD_HWADDR; - bcopy(tmphaddr, hp->haddr, haddrlength(hp->htype)); - hp->flags.haddr = TRUE; - } - break; - - case SYM_HOMEDIR: - PARSE_STR(homedir); - if ((hp->homedir != NULL) && - (hp->homedir->string[0] != '/')) - return E_BAD_PATHNAME; - break; - - case SYM_HTYPE: - if (optype == OP_BOOLEAN) - return E_SYNTAX_ERROR; - hp->flags.htype = FALSE; - if (optype == OP_ADDITION) { - value = 0L; /* Assume an illegal value */ - eat_whitespace(symbol); - if (isdigit(**symbol)) { - value = get_u_long(symbol); - } else { - len = sizeof(tmpstr); - (void) get_string(symbol, tmpstr, &len); - makelower(tmpstr); - numsymbols = sizeof(htnamemap) / - sizeof(struct htypename); - for (i = 0; i < numsymbols; i++) { - if (!strcmp(htnamemap[i].name, tmpstr)) { - break; - } - } - if (i < numsymbols) { - value = htnamemap[i].htype; - } - } - if (value >= hwinfocnt) { - return E_BAD_HWATYPE; - } - hp->htype = (byte) (value & 0xFF); - hp->flags.htype = TRUE; - } - break; - - case SYM_IMPRESS_SERVER: - PARSE_IAL(impress_server); - break; - - case SYM_IPADDR: - PARSE_IA1(iaddr); - break; - - case SYM_LOG_SERVER: - PARSE_IAL(log_server); - break; - - case SYM_LPR_SERVER: - PARSE_IAL(lpr_server); - break; - - case SYM_NAME_SERVER: - PARSE_IAL(name_server); - break; - - case SYM_RLP_SERVER: - PARSE_IAL(rlp_server); - break; - - case SYM_SUBNET_MASK: - PARSE_IA1(subnet_mask); - break; - - case SYM_TIME_OFFSET: - if (optype == OP_BOOLEAN) - return E_SYNTAX_ERROR; - hp->flags.time_offset = FALSE; - if (optype == OP_ADDITION) { - len = sizeof(tmpstr); - (void) get_string(symbol, tmpstr, &len); - if (!strncmp(tmpstr, "auto", 4)) { - hp->time_offset = secondswest; - } else { - if (sscanf(tmpstr, "%d", &timeoff) != 1) - return E_BAD_LONGWORD; - hp->time_offset = timeoff; - } - hp->flags.time_offset = TRUE; - } - break; - - case SYM_TIME_SERVER: - PARSE_IAL(time_server); - break; - - case SYM_VENDOR_MAGIC: - if (optype == OP_BOOLEAN) - return E_SYNTAX_ERROR; - hp->flags.vm_cookie = FALSE; - if (optype == OP_ADDITION) { - if (strncmp(*symbol, "auto", 4)) { - /* The string is not "auto" */ - if (!strncmp(*symbol, "rfc", 3)) { - bcopy(vm_rfc1048, hp->vm_cookie, 4); - } else if (!strncmp(*symbol, "cmu", 3)) { - bcopy(vm_cmu, hp->vm_cookie, 4); - } else { - if (!isdigit(**symbol)) - return E_BAD_IPADDR; - if (prs_inetaddr(symbol, &value) < 0) - return E_BAD_IPADDR; - bcopy(&value, hp->vm_cookie, 4); - } - hp->flags.vm_cookie = TRUE; - } - } - break; - - case SYM_SIMILAR_ENTRY: - switch (optype) { - case OP_ADDITION: - fill_defaults(hp, symbol); - break; - default: - return E_SYNTAX_ERROR; - } - break; - - case SYM_NAME_SWITCH: - switch (optype) { - case OP_ADDITION: - return E_SYNTAX_ERROR; - case OP_DELETION: - hp->flags.send_name = FALSE; - hp->flags.name_switch = FALSE; - break; - case OP_BOOLEAN: - hp->flags.send_name = TRUE; - hp->flags.name_switch = TRUE; - break; - } - break; - - case SYM_BOOTSIZE: - switch (optype) { - case OP_ADDITION: - if (!strncmp(*symbol, "auto", 4)) { - hp->flags.bootsize = TRUE; - hp->flags.bootsize_auto = TRUE; - } else { - hp->bootsize = (unsigned int) get_u_long(symbol); - hp->flags.bootsize = TRUE; - hp->flags.bootsize_auto = FALSE; - } - break; - case OP_DELETION: - hp->flags.bootsize = FALSE; - break; - case OP_BOOLEAN: - hp->flags.bootsize = TRUE; - hp->flags.bootsize_auto = TRUE; - break; - } - break; - - case SYM_BOOT_SERVER: - PARSE_IA1(bootserver); - break; - - case SYM_TFTPDIR: - PARSE_STR(tftpdir); - if ((hp->tftpdir != NULL) && - (hp->tftpdir->string[0] != '/')) - return E_BAD_PATHNAME; - break; - - case SYM_DUMP_FILE: - PARSE_STR(dump_file); - break; - - case SYM_DOMAIN_NAME: - PARSE_STR(domain_name); - break; - - case SYM_SWAP_SERVER: - PARSE_IA1(swap_server); - break; - - case SYM_ROOT_PATH: - PARSE_STR(root_path); - break; - - case SYM_EXTEN_FILE: - PARSE_STR(exten_file); - break; - - case SYM_REPLY_ADDR: - PARSE_IA1(reply_addr); - break; - - case SYM_NIS_DOMAIN: - PARSE_STR(nis_domain); - break; - - case SYM_NIS_SERVER: - PARSE_IAL(nis_server); - break; - - case SYM_NTP_SERVER: - PARSE_IAL(ntp_server); - break; - - /* XXX - Add new tags here */ - - default: - return E_UNKNOWN_SYMBOL; - - } /* switch symbolcode */ - - return SUCCESS; -} -#undef PARSE_IA1 -#undef PARSE_IAL -#undef PARSE_STR - - - - -/* - * Read a string from the buffer indirectly pointed to through "src" and - * move it into the buffer pointed to by "dest". A pointer to the maximum - * allowable length of the string (including null-terminator) is passed as - * "length". The actual length of the string which was read is returned in - * the unsigned integer pointed to by "length". This value is the same as - * that which would be returned by applying the strlen() function on the - * destination string (i.e the terminating null is not counted as a - * character). Trailing whitespace is removed from the string. For - * convenience, the function returns the new value of "dest". - * - * The string is read until the maximum number of characters, an unquoted - * colon (:), or a null character is read. The return string in "dest" is - * null-terminated. - */ - -PRIVATE char * -get_string(src, dest, length) - char **src, *dest; - unsigned *length; -{ - int n, len, quoteflag; - - quoteflag = FALSE; - n = 0; - len = *length - 1; - while ((n < len) && (**src)) { - if (!quoteflag && (**src == ':')) { - break; - } - if (**src == '"') { - (*src)++; - quoteflag = !quoteflag; - continue; - } - if (**src == '\\') { - (*src)++; - if (!**src) { - break; - } - } - *dest++ = *(*src)++; - n++; - } - - /* - * Remove that troublesome trailing whitespace. . . - */ - while ((n > 0) && isspace(dest[-1])) { - dest--; - n--; - } - - *dest = '\0'; - *length = n; - return dest; -} - - - -/* - * Read the string indirectly pointed to by "src", update the caller's - * pointer, and return a pointer to a malloc'ed shared_string structure - * containing the string. - * - * The string is read using the same rules as get_string() above. - */ - -PRIVATE struct shared_string * -get_shared_string(src) - char **src; -{ - char retstring[MAXSTRINGLEN]; - struct shared_string *s; - unsigned length; - - length = sizeof(retstring); - (void) get_string(src, retstring, &length); - - s = (struct shared_string *) smalloc(sizeof(struct shared_string) - + length); - s->linkcount = 1; - strcpy(s->string, retstring); - - return s; -} - - - -/* - * Load RFC1048 generic information directly into a memory buffer. - * - * "src" indirectly points to the ASCII representation of the generic data. - * "dest" points to a string structure which is updated to point to a new - * string with the new data appended to the old string. The old string is - * freed. - * - * The given tag value is inserted with the new data. - * - * The data may be represented as either a stream of hexadecimal numbers - * representing bytes (any or all bytes may optionally start with '0x' and - * be separated with periods ".") or as a quoted string of ASCII - * characters (the quotes are required). - */ - -PRIVATE int -process_generic(src, dest, tagvalue) - char **src; - struct shared_bindata **dest; - u_int tagvalue; -{ - byte tmpbuf[MAXBUFLEN]; - byte *str; - struct shared_bindata *bdata; - u_int newlength, oldlength; - - str = tmpbuf; - *str++ = (tagvalue & 0xFF); /* Store tag value */ - str++; /* Skip over length field */ - if ((*src)[0] == '"') { /* ASCII data */ - newlength = sizeof(tmpbuf) - 2; /* Set maximum allowed length */ - (void) get_string(src, (char *) str, &newlength); - newlength++; /* null terminator */ - } else { /* Numeric data */ - newlength = 0; - while (newlength < sizeof(tmpbuf) - 2) { - if (interp_byte(src, str++) < 0) - break; - newlength++; - if (**src == '.') { - (*src)++; - } - } - } - if ((*src)[0] != ':') - return -1; - - tmpbuf[1] = (newlength & 0xFF); - oldlength = ((*dest)->length); - bdata = (struct shared_bindata *) smalloc(sizeof(struct shared_bindata) - + oldlength + newlength + 1); - if (oldlength > 0) { - bcopy((*dest)->data, bdata->data, oldlength); - } - bcopy(tmpbuf, bdata->data + oldlength, newlength + 2); - bdata->length = oldlength + newlength + 2; - bdata->linkcount = 1; - if (*dest) { - del_bindata(*dest); - } - *dest = bdata; - return 0; -} - - - -/* - * Verify that the given string makes sense as a hostname (according to - * Appendix 1, page 29 of RFC882). - * - * Return TRUE for good names, FALSE otherwise. - */ - -PRIVATE boolean -goodname(hostname) - register char *hostname; -{ - do { - if (!isalpha(*hostname++)) { /* First character must be a letter */ - return FALSE; - } - while (isalnum(*hostname) || - (*hostname == '-') || - (*hostname == '_') ) - { - hostname++; /* Alphanumeric or a hyphen */ - } - if (!isalnum(hostname[-1])) { /* Last must be alphanumeric */ - return FALSE; - } - if (*hostname == '\0') {/* Done? */ - return TRUE; - } - } while (*hostname++ == '.'); /* Dot, loop for next label */ - - return FALSE; /* If it's not a dot, lose */ -} - - - -/* - * Null compare function -- always returns FALSE so an element is always - * inserted into a hash table (i.e. there is never a collision with an - * existing element). - */ - -PRIVATE boolean -nullcmp(d1, d2) - hash_datum *d1, *d2; -{ - return FALSE; -} - - -/* - * Function for comparing a string with the hostname field of a host - * structure. - */ - -boolean -nmcmp(d1, d2) - hash_datum *d1, *d2; -{ - char *name = (char *) d1; /* XXX - OK? */ - struct host *hp = (struct host *) d2; - - return !strcmp(name, hp->hostname->string); -} - - -/* - * Compare function to determine whether two hardware addresses are - * equivalent. Returns TRUE if "host1" and "host2" are equivalent, FALSE - * otherwise. - * - * If the hardware addresses of "host1" and "host2" are identical, but - * they are on different IP subnets, this function returns FALSE. - * - * This function is used when inserting elements into the hardware address - * hash table. - */ - -PRIVATE boolean -hwinscmp(d1, d2) - hash_datum *d1, *d2; -{ - struct host *host1 = (struct host *) d1; - struct host *host2 = (struct host *) d2; - - if (host1->htype != host2->htype) { - return FALSE; - } - if (bcmp(host1->haddr, host2->haddr, haddrlength(host1->htype))) { - return FALSE; - } - /* XXX - Is the subnet_mask field set yet? */ - if ((host1->subnet_mask.s_addr) == (host2->subnet_mask.s_addr)) { - if (((host1->iaddr.s_addr) & (host1->subnet_mask.s_addr)) != - ((host2->iaddr.s_addr) & (host2->subnet_mask.s_addr))) - { - return FALSE; - } - } - return TRUE; -} - - -/* - * Macros for use in the function below: - */ - -#define DUP_COPY(MEMBER) do \ -{ \ - if (!hp->flags.MEMBER) { \ - if ((hp->flags.MEMBER = hp2->flags.MEMBER) != 0) { \ - hp->MEMBER = hp2->MEMBER; \ - } \ - } \ -} while (0) - -#define DUP_LINK(MEMBER) do \ -{ \ - if (!hp->flags.MEMBER) { \ - if ((hp->flags.MEMBER = hp2->flags.MEMBER) != 0) { \ - assert(hp2->MEMBER); \ - hp->MEMBER = hp2->MEMBER; \ - (hp->MEMBER->linkcount)++; \ - } \ - } \ -} while (0) - -/* - * Process the "similar entry" symbol. - * - * The host specified as the value of the "tc" symbol is used as a template - * for the current host entry. Symbol values not explicitly set in the - * current host entry are inferred from the template entry. - */ -PRIVATE void -fill_defaults(hp, src) - struct host *hp; - char **src; -{ - unsigned int tlen, hashcode; - struct host *hp2; - char tstring[MAXSTRINGLEN]; - - tlen = sizeof(tstring); - (void) get_string(src, tstring, &tlen); - hashcode = hash_HashFunction((u_char *) tstring, tlen); - hp2 = (struct host *) hash_Lookup(nmhashtable, hashcode, nmcmp, tstring); - - if (hp2 == NULL) { - report(LOG_ERR, "can't find tc=\"%s\"", tstring); - return; - } - DUP_LINK(bootfile); - DUP_LINK(cookie_server); - DUP_LINK(domain_server); - DUP_LINK(gateway); - /* haddr not copied */ - DUP_LINK(homedir); - DUP_COPY(htype); - - DUP_LINK(impress_server); - /* iaddr not copied */ - DUP_LINK(log_server); - DUP_LINK(lpr_server); - DUP_LINK(name_server); - DUP_LINK(rlp_server); - - DUP_COPY(subnet_mask); - DUP_COPY(time_offset); - DUP_LINK(time_server); - - if (!hp->flags.vm_cookie) { - if ((hp->flags.vm_cookie = hp2->flags.vm_cookie)) { - bcopy(hp2->vm_cookie, hp->vm_cookie, 4); - } - } - if (!hp->flags.name_switch) { - if ((hp->flags.name_switch = hp2->flags.name_switch)) { - hp->flags.send_name = hp2->flags.send_name; - } - } - if (!hp->flags.bootsize) { - if ((hp->flags.bootsize = hp2->flags.bootsize)) { - hp->flags.bootsize_auto = hp2->flags.bootsize_auto; - hp->bootsize = hp2->bootsize; - } - } - DUP_COPY(bootserver); - - DUP_LINK(tftpdir); - DUP_LINK(dump_file); - DUP_LINK(domain_name); - - DUP_COPY(swap_server); - DUP_LINK(root_path); - DUP_LINK(exten_file); - - DUP_COPY(reply_addr); - - DUP_LINK(nis_domain); - DUP_LINK(nis_server); - DUP_LINK(ntp_server); - - /* XXX - Add new tags here */ - - DUP_LINK(generic); - -} -#undef DUP_COPY -#undef DUP_LINK - - - -/* - * This function adjusts the caller's pointer to point just past the - * first-encountered colon. If it runs into a null character, it leaves - * the pointer pointing to it. - */ - -PRIVATE void -adjust(s) - char **s; -{ - register char *t; - - t = *s; - while (*t && (*t != ':')) { - t++; - } - if (*t) { - t++; - } - *s = t; -} - - - - -/* - * This function adjusts the caller's pointer to point to the first - * non-whitespace character. If it runs into a null character, it leaves - * the pointer pointing to it. - */ - -PRIVATE void -eat_whitespace(s) - char **s; -{ - register char *t; - - t = *s; - while (*t && isspace(*t)) { - t++; - } - *s = t; -} - - - -/* - * This function converts the given string to all lowercase. - */ - -PRIVATE void -makelower(s) - char *s; -{ - while (*s) { - if (isupper(*s)) { - *s = tolower(*s); - } - s++; - } -} - - - -/* - * - * N O T E : - * - * In many of the functions which follow, a parameter such as "src" or - * "symbol" is passed as a pointer to a pointer to something. This is - * done for the purpose of letting the called function update the - * caller's copy of the parameter (i.e. to effect call-by-reference - * parameter passing). The value of the actual parameter is only used - * to locate the real parameter of interest and then update this indirect - * parameter. - * - * I'm sure somebody out there won't like this. . . . - * (Yea, because it usually makes code slower... -gwr) - * - */ - - - -/* - * "src" points to a character pointer which points to an ASCII string of - * whitespace-separated IP addresses. A pointer to an in_addr_list - * structure containing the list of addresses is returned. NULL is - * returned if no addresses were found at all. The pointer pointed to by - * "src" is updated to point to the first non-address (illegal) character. - */ - -PRIVATE struct in_addr_list * -get_addresses(src) - char **src; -{ - struct in_addr tmpaddrlist[MAXINADDRS]; - struct in_addr *address1, *address2; - struct in_addr_list *result; - unsigned addrcount, totalsize; - - address1 = tmpaddrlist; - for (addrcount = 0; addrcount < MAXINADDRS; addrcount++) { - while (isspace(**src) || (**src == ',')) { - (*src)++; - } - if (!**src) { /* Quit if nothing more */ - break; - } - if (prs_inetaddr(src, &(address1->s_addr)) < 0) { - break; - } - address1++; /* Point to next address slot */ - } - if (addrcount < 1) { - result = NULL; - } else { - totalsize = sizeof(struct in_addr_list) - + (addrcount - 1) * sizeof(struct in_addr); - result = (struct in_addr_list *) smalloc(totalsize); - result->linkcount = 1; - result->addrcount = addrcount; - address1 = tmpaddrlist; - address2 = result->addr; - for (; addrcount > 0; addrcount--) { - address2->s_addr = address1->s_addr; - address1++; - address2++; - } - } - return result; -} - - - -/* - * prs_inetaddr(src, result) - * - * "src" is a value-result parameter; the pointer it points to is updated - * to point to the next data position. "result" points to an unsigned long - * in which an address is returned. - * - * This function parses the IP address string in ASCII "dot notation" pointed - * to by (*src) and places the result (in network byte order) in the unsigned - * long pointed to by "result". For malformed addresses, -1 is returned, - * (*src) points to the first illegal character, and the unsigned long pointed - * to by "result" is unchanged. Successful calls return 0. - */ - -PRIVATE int -prs_inetaddr(src, result) - char **src; - u_int32 *result; -{ - char tmpstr[MAXSTRINGLEN]; - register u_int32 value; - u_int32 parts[4], *pp; - int n; - char *s, *t; - -#if 1 /* XXX - experimental */ - /* Leading alpha char causes IP addr lookup. */ - if (isalpha(**src)) { - /* Lookup IP address. */ - s = *src; - t = tmpstr; - while ((isalnum(*s) || (*s == '.') || - (*s == '-') || (*s == '_') ) && - (t < &tmpstr[MAXSTRINGLEN - 1]) ) - *t++ = *s++; - *t = '\0'; - *src = s; - - n = lookup_ipa(tmpstr, result); - if (n < 0) - report(LOG_ERR, "can not get IP addr for %s", tmpstr); - return n; - } -#endif - - /* - * Parse an address in Internet format: - * a.b.c.d - * a.b.c (with c treated as 16-bits) - * a.b (with b treated as 24 bits) - */ - pp = parts; - loop: - /* If it's not a digit, return error. */ - if (!isdigit(**src)) - return -1; - *pp++ = get_u_long(src); - if (**src == '.') { - if (pp < (parts + 4)) { - (*src)++; - goto loop; - } - return (-1); - } -#if 0 - /* This is handled by the caller. */ - if (**src && !(isspace(**src) || (**src == ':'))) { - return (-1); - } -#endif - - /* - * Construct the address according to - * the number of parts specified. - */ - n = pp - parts; - switch (n) { - case 1: /* a -- 32 bits */ - value = parts[0]; - break; - case 2: /* a.b -- 8.24 bits */ - value = (parts[0] << 24) | (parts[1] & 0xFFFFFF); - break; - case 3: /* a.b.c -- 8.8.16 bits */ - value = (parts[0] << 24) | ((parts[1] & 0xFF) << 16) | - (parts[2] & 0xFFFF); - break; - case 4: /* a.b.c.d -- 8.8.8.8 bits */ - value = (parts[0] << 24) | ((parts[1] & 0xFF) << 16) | - ((parts[2] & 0xFF) << 8) | (parts[3] & 0xFF); - break; - default: - return (-1); - } - *result = htonl(value); - return (0); -} - - - -/* - * "src" points to a pointer which in turn points to a hexadecimal ASCII - * string. This string is interpreted as a hardware address and returned - * as a pointer to the actual hardware address, represented as an array of - * bytes. - * - * The ASCII string must have the proper number of digits for the specified - * hardware type (e.g. twelve digits for a 48-bit Ethernet address). - * Two-digit sequences (bytes) may be separated with periods (.) and/or - * prefixed with '0x' for readability, but this is not required. - * - * For bad addresses, the pointer which "src" points to is updated to point - * to the start of the first two-digit sequence which was bad, and the - * function returns a NULL pointer. - */ - -PRIVATE byte * -prs_haddr(src, htype) - char **src; - u_int htype; -{ - static byte haddr[MAXHADDRLEN]; - byte *hap; - char tmpstr[MAXSTRINGLEN]; - u_int tmplen; - unsigned hal; - char *p; - - hal = haddrlength(htype); /* Get length of this address type */ - if (hal <= 0) { - report(LOG_ERR, "Invalid addr type for HW addr parse"); - return NULL; - } - tmplen = sizeof(tmpstr); - get_string(src, tmpstr, &tmplen); - p = tmpstr; - -#if 1 /* XXX - experimental */ - /* If it's a valid host name, try to lookup the HW address. */ - if (goodname(p)) { - /* Lookup Hardware Address for hostname. */ - if ((hap = lookup_hwa(p, htype)) != NULL) - return hap; /* success */ - report(LOG_ERR, "Add 0x prefix if hex value starts with A-F"); - /* OK, assume it must be numeric. */ - } -#endif - - hap = haddr; - while (hap < haddr + hal) { - if (*p == '.') - p++; - if (interp_byte(&p, hap++) < 0) { - return NULL; - } - } - return haddr; -} - - - -/* - * "src" is a pointer to a character pointer which in turn points to a - * hexadecimal ASCII representation of a byte. This byte is read, the - * character pointer is updated, and the result is deposited into the - * byte pointed to by "retbyte". - * - * The usual '0x' notation is allowed but not required. The number must be - * a two digit hexadecimal number. If the number is invalid, "src" and - * "retbyte" are left untouched and -1 is returned as the function value. - * Successful calls return 0. - */ - -PRIVATE int -interp_byte(src, retbyte) - char **src; - byte *retbyte; -{ - int v; - - if ((*src)[0] == '0' && - ((*src)[1] == 'x' || - (*src)[1] == 'X')) { - (*src) += 2; /* allow 0x for hex, but don't require it */ - } - if (!isxdigit((*src)[0]) || !isxdigit((*src)[1])) { - return -1; - } - if (sscanf(*src, "%2x", &v) != 1) { - return -1; - } - (*src) += 2; - *retbyte = (byte) (v & 0xFF); - return 0; -} - - - -/* - * The parameter "src" points to a character pointer which points to an - * ASCII string representation of an unsigned number. The number is - * returned as an unsigned long and the character pointer is updated to - * point to the first illegal character. - */ - -PRIVATE u_int32 -get_u_long(src) - char **src; -{ - register u_int32 value, base; - char c; - - /* - * Collect number up to first illegal character. Values are specified - * as for C: 0x=hex, 0=octal, other=decimal. - */ - value = 0; - base = 10; - if (**src == '0') { - base = 8; - (*src)++; - } - if (**src == 'x' || **src == 'X') { - base = 16; - (*src)++; - } - while ((c = **src)) { - if (isdigit(c)) { - value = (value * base) + (c - '0'); - (*src)++; - continue; - } - if (base == 16 && isxdigit(c)) { - value = (value << 4) + ((c & ~32) + 10 - 'A'); - (*src)++; - continue; - } - break; - } - return value; -} - - - -/* - * Routines for deletion of data associated with the main data structure. - */ - - -/* - * Frees the entire host data structure given. Does nothing if the passed - * pointer is NULL. - */ - -PRIVATE void -free_host(hmp) - hash_datum *hmp; -{ - struct host *hostptr = (struct host *) hmp; - if (hostptr == NULL) - return; - assert(hostptr->linkcount > 0); - if (--(hostptr->linkcount)) - return; /* Still has references */ - del_iplist(hostptr->cookie_server); - del_iplist(hostptr->domain_server); - del_iplist(hostptr->gateway); - del_iplist(hostptr->impress_server); - del_iplist(hostptr->log_server); - del_iplist(hostptr->lpr_server); - del_iplist(hostptr->name_server); - del_iplist(hostptr->rlp_server); - del_iplist(hostptr->time_server); - del_iplist(hostptr->nis_server); - del_iplist(hostptr->ntp_server); - - /* - * XXX - Add new tags here - * (if the value is an IP list) - */ - - del_string(hostptr->hostname); - del_string(hostptr->homedir); - del_string(hostptr->bootfile); - del_string(hostptr->tftpdir); - del_string(hostptr->root_path); - del_string(hostptr->domain_name); - del_string(hostptr->dump_file); - del_string(hostptr->exten_file); - del_string(hostptr->nis_domain); - - /* - * XXX - Add new tags here - * (if it is a shared string) - */ - - del_bindata(hostptr->generic); - free((char *) hostptr); -} - - - -/* - * Decrements the linkcount on the given IP address data structure. If the - * linkcount goes to zero, the memory associated with the data is freed. - */ - -PRIVATE void -del_iplist(iplist) - struct in_addr_list *iplist; -{ - if (iplist) { - if (!(--(iplist->linkcount))) { - free((char *) iplist); - } - } -} - - - -/* - * Decrements the linkcount on a string data structure. If the count - * goes to zero, the memory associated with the string is freed. Does - * nothing if the passed pointer is NULL. - */ - -PRIVATE void -del_string(stringptr) - struct shared_string *stringptr; -{ - if (stringptr) { - if (!(--(stringptr->linkcount))) { - free((char *) stringptr); - } - } -} - - - -/* - * Decrements the linkcount on a shared_bindata data structure. If the - * count goes to zero, the memory associated with the data is freed. Does - * nothing if the passed pointer is NULL. - */ - -PRIVATE void -del_bindata(dataptr) - struct shared_bindata *dataptr; -{ - if (dataptr) { - if (!(--(dataptr->linkcount))) { - free((char *) dataptr); - } - } -} - - - - -/* smalloc() -- safe malloc() - * - * Always returns a valid pointer (if it returns at all). The allocated - * memory is initialized to all zeros. If malloc() returns an error, a - * message is printed using the report() function and the program aborts - * with a status of 1. - */ - -PRIVATE char * -smalloc(nbytes) - unsigned nbytes; -{ - char *retvalue; - - retvalue = malloc(nbytes); - if (!retvalue) { - report(LOG_ERR, "malloc() failure -- exiting"); - exit(1); - } - bzero(retvalue, nbytes); - return retvalue; -} - - -/* - * Compare function to determine whether two hardware addresses are - * equivalent. Returns TRUE if "host1" and "host2" are equivalent, FALSE - * otherwise. - * - * This function is used when retrieving elements from the hardware address - * hash table. - */ - -boolean -hwlookcmp(d1, d2) - hash_datum *d1, *d2; -{ - struct host *host1 = (struct host *) d1; - struct host *host2 = (struct host *) d2; - - if (host1->htype != host2->htype) { - return FALSE; - } - if (bcmp(host1->haddr, host2->haddr, haddrlength(host1->htype))) { - return FALSE; - } - return TRUE; -} - - -/* - * Compare function for doing IP address hash table lookup. - */ - -boolean -iplookcmp(d1, d2) - hash_datum *d1, *d2; -{ - struct host *host1 = (struct host *) d1; - struct host *host2 = (struct host *) d2; - - return (host1->iaddr.s_addr == host2->iaddr.s_addr); -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/readfile.h b/libexec/bootpd/readfile.h deleted file mode 100644 index 3913455857c3..000000000000 --- a/libexec/bootpd/readfile.h +++ /dev/null @@ -1,19 +0,0 @@ -/* readfile.h */ - -#include "bptypes.h" -#include "hash.h" - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern boolean hwlookcmp P((hash_datum *, hash_datum *)); -extern boolean iplookcmp P((hash_datum *, hash_datum *)); -extern boolean nmcmp P((hash_datum *, hash_datum *)); -extern void readtab P((int)); -extern void rdtab_init P((void)); - -#undef P - diff --git a/libexec/bootpd/report.c b/libexec/bootpd/report.c deleted file mode 100644 index 4f7f03616a2a..000000000000 --- a/libexec/bootpd/report.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * report() - calls syslog - */ - -#ifdef __STDC__ -#include -#else -#include -#endif - -#include -#include - -#include "report.h" - -#ifndef LOG_NDELAY -#define LOG_NDELAY 0 -#endif -#ifndef LOG_DAEMON -#define LOG_DAEMON 0 -#endif -#ifndef LOG_BOOTP -#define LOG_BOOTP LOG_DAEMON -#endif - -extern int debug; -extern char *progname; - -/* - * This is initialized so you get stderr until you call - * report_init() - */ -static int stderr_only = 1; - -void -report_init(nolog) - int nolog; -{ - stderr_only = nolog; -#ifdef SYSLOG - if (!stderr_only) { - openlog(progname, LOG_PID | LOG_NDELAY, LOG_BOOTP); - } -#endif -} - -/* - * This routine reports errors and such via stderr and syslog() if - * appopriate. It just helps avoid a lot of "#ifdef SYSLOG" constructs - * from being scattered throughout the code. - * - * The syntax is identical to syslog(3), but %m is not considered special - * for output to stderr (i.e. you'll see "%m" in the output. . .). Also, - * control strings should normally end with \n since newlines aren't - * automatically generated for stderr output (whereas syslog strips out all - * newlines and adds its own at the end). - */ - -static char *levelnames[] = { -#ifdef LOG_SALERT - "level(0): ", - "alert(1): ", - "alert(2): ", - "emerg(3): ", - "error(4): ", - "crit(5): ", - "warn(6): ", - "note(7): ", - "info(8): ", - "debug(9): ", - "level(?): " -#else - "emerg(0): ", - "alert(1): ", - "crit(2): ", - "error(3): ", - "warn(4): ", - "note(5): ", - "info(6): ", - "debug(7): ", - "level(?): " -#endif -}; -static int numlevels = sizeof(levelnames) / sizeof(levelnames[0]); - - -/* - * Print a log message using syslog(3) and/or stderr. - * The message passed in should not include a newline. - */ -#ifdef __STDC__ -void -report(int priority, char *fmt,...) -#else -/*VARARGS2*/ -void -report(priority, fmt, va_alist) - int priority; - char *fmt; - va_dcl -#endif -{ - va_list ap; - static char buf[128]; - - if ((priority < 0) || (priority >= numlevels)) { - priority = numlevels - 1; - } -#ifdef __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - vsprintf(buf, fmt, ap); - va_end(ap); - - /* - * Print the message - */ - if (stderr_only || (debug > 2)) { - fprintf(stderr, "%s: %s %s\n", - progname, levelnames[priority], buf); - } -#ifdef SYSLOG - if (!stderr_only) - syslog((priority | LOG_BOOTP), "%s", buf); -#endif -} - - - -/* - * Return pointer to static string which gives full filesystem error message. - */ -char * -get_errmsg() -{ - extern int errno; - extern char *strerror(); - - return strerror(errno); -} - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-argdecl-indent: 4 - * c-continued-statement-offset: 4 - * c-continued-brace-offset: -4 - * c-label-offset: -4 - * c-brace-offset: 0 - * End: - */ diff --git a/libexec/bootpd/report.h b/libexec/bootpd/report.h deleted file mode 100644 index 0bf63d60fbb1..000000000000 --- a/libexec/bootpd/report.h +++ /dev/null @@ -1,13 +0,0 @@ -/* report.h */ - -#ifdef __STDC__ -#define P(args) args -#else -#define P(args) () -#endif - -extern void report_init P((int nolog)); -extern void report P((int, char *, ...)); -extern char *get_errmsg P((void)); - -#undef P diff --git a/libexec/bootpd/syslog.conf b/libexec/bootpd/syslog.conf deleted file mode 100644 index 2c135af4974e..000000000000 --- a/libexec/bootpd/syslog.conf +++ /dev/null @@ -1,63 +0,0 @@ -# -# syslog configuration file for SunOS 4.X -# (modified to do local2 separately) -# -# This file is processed by m4 so be careful to quote (`') names -# that match m4 reserved words. Also, within ifdef's, arguments -# containing commas must be quoted. -# -# Note: Have to exclude user from most lines so that user.alert -# and user.emerg are not included, because old sendmails -# will generate them for debugging information. If you -# have no 4.2BSD based systems doing network logging, you -# can remove all the special cases for "user" logging. - -#*.err;kern.debug;auth.notice;user.none /dev/console -kern.debug;user,mail.crit;auth.notice /dev/console -daemon,syslog,lpr,news,uucp,cron.err /dev/console - -#*.err;kern.debug;daemon,auth.notice;mail.crit;user.none /var/adm/messages -kern.debug;user,mail.crit;auth.notice /var/adm/messages -daemon.notice;syslog,news,uucp,cron.err /var/adm/messages - -lpr.debug /var/adm/lpd-errs - -*.alert;kern.err;daemon.err;user.none operator -*.alert;user.none root - -*.emerg;user.none * - -# for loghost machines, to have authentication messages (su, login, etc.) -# logged to a file, un-comment out the following line and adjust the file name -# as appropriate. -# -# if a non-loghost machine chooses to have such messages -# sent to the loghost machine, un-comment out the following line. -# -#auth.notice ifdef(`LOGHOST', /var/log/authlog, @loghost) - -mail.debug ifdef(`LOGHOST', /var/log/syslog, @loghost) - -# following line for compatibility with old sendmails. they will send -# messages with no facility code, which will be turned into "user" messages -# by the local syslog daemon. only the "loghost" machine needs the following -# line, to cause these old sendmail log messages to be logged in the -# mail syslog file. -# -ifdef(`LOGHOST', -user.alert /var/log/syslog -) -# -# non-loghost machines will use the following lines to cause "user" -# log messages to be logged locally. -# -ifdef(`LOGHOST', , -user.err /dev/console -user.err /var/adm/messages -user.alert `root, operator' -user.emerg * -) - -# Local2: (bootpd, pppd) -local2.debug /dev/console -#local2.debug /var/log/local2 diff --git a/libexec/bootpd/syslog.h b/libexec/bootpd/syslog.h deleted file mode 100644 index 90d233fe6126..000000000000 --- a/libexec/bootpd/syslog.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Fake syslog.h for systems without it (just defines priorities). - * To use this, compile with: -I/usr/include -I. - */ - -/* - * Copyright (c) 1982, 1986 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. - */ - -/* - * Priorities (these are ordered) - */ -#define LOG_EMERG 0 /* system is unusable */ -#define LOG_ALERT 1 /* action must be taken immediately */ -#define LOG_CRIT 2 /* critical conditions */ -#define LOG_ERR 3 /* error conditions */ -#define LOG_WARNING 4 /* warning conditions */ -#define LOG_NOTICE 5 /* normal but signification condition */ -#define LOG_INFO 6 /* informational */ -#define LOG_DEBUG 7 /* debug-level messages */ - -/* XXX - Just in case: */ -#define openlog fake_syslog_openlog diff --git a/libexec/bootpd/trygetea.c b/libexec/bootpd/trygetea.c deleted file mode 100644 index e9314aede96d..000000000000 --- a/libexec/bootpd/trygetea.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * trygetea.c - test program for getether.c - */ - -#include -#include - -#if defined(SUNOS) || defined(SVR4) -#include -#endif - -#include /* for struct ifreq */ -#include -#include /* inet_ntoa */ - -#include -#include -#include -#include - -int debug = 0; -char *progname; - -main(argc, argv) - char **argv; -{ - u_char ea[16]; /* Ethernet address */ - int i; - - progname = argv[0]; /* for report */ - - if (argc < 2) { - printf("need interface name\n"); - exit(1); - } - if ((i = getether(argv[1], ea)) < 0) { - printf("Could not get Ethernet address (rc=%d)\n", i); - exit(1); - } - printf("Ether-addr"); - for (i = 0; i < 6; i++) - printf(":%x", ea[i] & 0xFF); - printf("\n"); - - exit(0); -} diff --git a/libexec/bootpd/trygetif.c b/libexec/bootpd/trygetif.c deleted file mode 100644 index c6bb098ab03b..000000000000 --- a/libexec/bootpd/trygetif.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * trygetif.c - test program for getif.c - */ - -#include -#include - -#if defined(SUNOS) || defined(SVR4) -#include -#endif - -#include /* for struct ifreq */ -#include -#include /* inet_ntoa */ - -#include -#include -#include -#include - -#include "getif.h" - -int debug = 0; -char *progname; - -main(argc, argv) - char **argv; -{ - struct hostent *hep; - struct sockaddr ea; /* Ethernet address */ - struct sockaddr_in *sip; /* Interface address */ - struct ifreq *ifr; - struct in_addr dst_addr; - struct in_addr *dap; - int i, s; - - progname = argv[0]; /* for report */ - - dap = NULL; - if (argc > 1) { - dap = &dst_addr; - if (isdigit(argv[1][0])) - dst_addr.s_addr = inet_addr(argv[1]); - else { - hep = gethostbyname(argv[1]); - if (!hep) { - printf("gethostbyname(%s)\n", argv[1]); - exit(1); - } - memcpy(&dst_addr, hep->h_addr, sizeof(dst_addr)); - } - } - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s < 0) { - perror("socket open"); - exit(1); - } - ifr = getif(s, dap); - if (!ifr) { - printf("no interface for address\n"); - exit(1); - } - printf("Intf-name:%s\n", ifr->ifr_name); - sip = (struct sockaddr_in *) &(ifr->ifr_addr); - printf("Intf-addr:%s\n", inet_ntoa(sip->sin_addr)); - - exit(0); -} diff --git a/libexec/bootpd/trylook.c b/libexec/bootpd/trylook.c deleted file mode 100644 index 40652a21159b..000000000000 --- a/libexec/bootpd/trylook.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * trylook.c - test program for lookup.c - */ - -#include -#include -#include - -#include "report.h" -#include "lookup.h" - -extern char *ether_ntoa(); -extern char *inet_ntoa(); - -int debug = 0; -char *progname; - -main(argc, argv) - char **argv; -{ - int i; - struct in_addr in; - char *a; - u_char *hwa; - - progname = argv[0]; /* for report */ - - for (i = 1; i < argc; i++) { - - /* Host name */ - printf("%s:", argv[i]); - - /* IP addr */ - if (lookup_ipa(argv[i], &in.s_addr)) - a = "?"; - else - a = inet_ntoa(in); - printf(" ipa=%s", a); - - /* Ether addr */ - hwa = lookup_hwa(argv[i], 1); - if (!hwa) - a = "?"; - else - a = ether_ntoa(hwa); - printf(" hwa=%s\n", a); - - } - exit(0); -} diff --git a/libexec/bootpd/tzone.c b/libexec/bootpd/tzone.c deleted file mode 100644 index 4adc4ae25c63..000000000000 --- a/libexec/bootpd/tzone.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * tzone.c - get the timezone - * - * This is shared by bootpd and bootpef - */ - -#ifdef SVR4 -/* XXX - Is this really SunOS specific? -gwr */ -/* This is in but only visible if (__STDC__ == 1). */ -extern long timezone; -#else /* SVR4 */ -/* BSD or SunOS */ -# include -# include -#endif /* SVR4 */ - -#include "bptypes.h" -#include "report.h" -#include "tzone.h" - -/* This is what other modules use. */ -int32 secondswest; - -/* - * Get our timezone offset so we can give it to clients if the - * configuration file doesn't specify one. - */ -void -tzone_init() -{ -#ifdef SVR4 - /* XXX - Is this really SunOS specific? -gwr */ - secondswest = timezone; -#else /* SVR4 */ - struct timezone tzp; /* Time zone offset for clients */ - struct timeval tp; /* Time (extra baggage) */ - if (gettimeofday(&tp, &tzp) < 0) { - secondswest = 0; /* Assume GMT for lack of anything better */ - report(LOG_ERR, "gettimeofday: %s", get_errmsg()); - } else { - secondswest = 60L * tzp.tz_minuteswest; /* Convert to seconds */ - } -#endif /* SVR4 */ -} diff --git a/libexec/bootpd/tzone.h b/libexec/bootpd/tzone.h deleted file mode 100644 index ddd67c4b625c..000000000000 --- a/libexec/bootpd/tzone.h +++ /dev/null @@ -1,3 +0,0 @@ -/* tzone.h */ -extern int32 secondswest; -extern void tzone_init(); diff --git a/libexec/bugfiler/gethead.c b/libexec/bugfiler/gethead.c deleted file mode 100644 index 1d9527bcdfed..000000000000 --- a/libexec/bugfiler/gethead.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 1986, 1987 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)gethead.c 5.10 (Berkeley) 3/7/91";*/ -static char rcsid[] = "$Id: gethead.c,v 1.2 1993/08/01 18:31:24 mycroft Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include "pathnames.h" -#include "bug.h" - -static int chk1(), pbuf(); - -#define ENT(X) sizeof(X) - 1, X -HEADER mailhead[] = { /* mail headers */ - { NO, YES, NULL, ENT("Date:"), }, - { NO, NO, NULL, ENT("From "), }, - { NO, YES, NULL, ENT("From:"), }, - { NO, NO, chk1, ENT("Index:"), }, - { NO, YES, NULL, ENT("Message-Id:"), }, - { NO, YES, NULL, ENT("Reply-To:"), }, - { NO, YES, NULL, ENT("Return-Path:"), }, - { NO, NO, pbuf, ENT("Subject:"), }, - { NO, YES, NULL, ENT("To:"), }, - { NO, NO, NULL, ENT("Apparently-To:"), }, - { ERR, } -}; - -FILE *dfp; /* distf file pointer */ -char dir[MAXNAMLEN], /* subject and folder */ - folder[MAXNAMLEN]; - -/* - * gethead -- - * read mail and bug headers from bug report, construct redist headers - */ -gethead(redist) - int redist; -{ - register HEADER *hp; /* mail header pointer */ - - if (redist) { - int fd; - char *distf; - - distf = strdup(_PATH_TMP); - if (!(fd = mkstemp(distf)) || !(dfp = fdopen(fd, "w+"))) - error("can't create redistribution file %s.", distf); - /* disappear after last reference is closed */ - (void)unlink(distf); - free(distf); - } - if (!freopen(tmpname, "r", stdin)) - error("can't read temporary bug file %s.", tmpname); - - while (fgets(bfr, sizeof(bfr), stdin)) { - for (hp = mailhead; hp->found != ERR; ++hp) - if (!hp->found) - if (!strncmp(hp->tag, bfr, hp->len)) { - if (hp->valid && !((*(hp->valid))(bfr))) - break; - if (!(hp->line = malloc((u_int)(strlen(bfr) + 1)))) - error("malloc failed.", CHN); - (void)strcpy(hp->line, bfr); - hp->found = YES; - break; - } - if ((hp->found == ERR || hp->redist) && redist) - fputs(bfr, dfp); - } - - if (!mailhead[INDX_TAG].found) - error("no readable \"Index:\" header in bug report.", CHN); -} - -/* - * chk1 -- - * parse the "Index:" line into folder and directory - */ -static -chk1(line) - char *line; -{ - register char *C; /* tmp pointer */ - struct stat sbuf; /* existence check */ - char *index(); - - if (sscanf(line, " Index: %s %s ", folder, dir) != 2) - return(NO); - if (C = index(folder, '/')) { /* deal with "bin/from.c" */ - if (C == folder) - return(NO); - *C = EOS; - } - if (stat(dir, &sbuf) || (sbuf.st_mode & S_IFMT) != S_IFDIR) - return(NO); - (void)pbuf(line); - return(YES); -} - -/* - * pbuf -- - * kludge so that summary file looks pretty - */ -static -pbuf(line) - char *line; -{ - register char *rp, /* tmp pointers */ - *wp; - - for (rp = line; *rp == ' ' || *rp == '\t'; ++rp); - for (wp = line; *rp; ++wp) { - if ((*wp = *rp++) != ' ' && *wp != '\t') - continue; - *wp = ' '; - while (*rp == ' ' || *rp == '\t') - ++rp; - } - if (wp[-1] == ' ') /* wp can't == line */ - --wp; - *wp = EOS; - return(YES); -} diff --git a/libexec/bugfiler/pathnames.h b/libexec/bugfiler/pathnames.h deleted file mode 100644 index 8a8bdc7f283d..000000000000 --- a/libexec/bugfiler/pathnames.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)pathnames.h 5.4 (Berkeley) 3/7/91 - * $Id: pathnames.h,v 1.2 1993/08/01 18:31:28 mycroft Exp $ - */ - -#define MAIL_CMD "/usr/sbin/sendmail -i -t -F \"Bugs Bunny\" -f owner-bugs" -#undef _PATH_TMP -#define _PATH_TMP "/tmp/BUG_XXXXXX" diff --git a/libexec/bugfiler/process.c b/libexec/bugfiler/process.c deleted file mode 100644 index faeee2262677..000000000000 --- a/libexec/bugfiler/process.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 1986, 1987 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)process.c 5.9 (Berkeley) 2/25/91";*/ -static char rcsid[] = "$Id: process.c,v 1.2 1993/08/01 18:31:23 mycroft Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "bug.h" - -char pfile[MAXPATHLEN]; /* permanent file name */ - -/* - * process -- - * copy report to permanent file, - * update summary file. - */ -process() -{ - register int rval; /* read return value */ - struct timeval tp; /* time of day */ - int lfd; /* lock file descriptor */ - static int getnext(); - - if (access(LOCK_FILE, R_OK) || (lfd = open(LOCK_FILE, O_RDONLY, 0)) < 0) - error("can't find lock file %s.", LOCK_FILE); - if (flock(lfd, LOCK_EX)) - error("can't get lock.", CHN); - sprintf(pfile, "%s/%s/%d", dir, folder, getnext()); - fprintf(stderr, "\t%s\n", pfile); - if (!(freopen(pfile, "w", stdout))) - error("can't create %s.", pfile); - rewind(stdin); - while ((rval = read(fileno(stdin), bfr, sizeof(bfr))) != ERR && rval) - if (write(fileno(stdout), bfr, rval) != rval) - error("write to %s failed.", pfile); - - /* append information to the summary file */ - sprintf(bfr, "%s/%s", dir, SUMMARY_FILE); - if (!(freopen(bfr, "a", stdout))) - error("can't append to summary file %s.", bfr); - if (gettimeofday(&tp, (struct timezone *)NULL)) - error("can't get time of day.", CHN); - printf("\n%s\t\t%s\t%s\t%s\tOwner: Bugs Bunny\n\tStatus: Received\n", pfile, ctime(&tp.tv_sec), mailhead[INDX_TAG].line, mailhead[SUBJ_TAG].found ? mailhead[SUBJ_TAG].line : "Subject:\n"); - (void)flock(lfd, LOCK_UN); - (void)fclose(stdout); -} - -/* - * getnext -- - * get next file name (number) - */ -static int -getnext() -{ - register struct dirent *d; /* directory structure */ - register DIR *dirp; /* directory pointer */ - register int highval, newval; - register char *p; - - (void)sprintf(bfr, "%s/%s", dir, folder); - if (!(dirp = opendir(bfr))) - error("can't read folder directory %s.", bfr); - for (highval = -1; d = readdir(dirp);) { - for (p = d->d_name; *p && isdigit(*p); ++p); - if (!*p && (newval = atoi(d->d_name)) > highval) - highval = newval; - } - closedir(dirp); - return(++highval); -} diff --git a/libexec/bugfiler/redist.c b/libexec/bugfiler/redist.c deleted file mode 100644 index 322ac234b731..000000000000 --- a/libexec/bugfiler/redist.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 1986, 1987 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)redist.c 5.12 (Berkeley) 4/1/91";*/ -static char rcsid[] = "$Id: redist.c,v 1.2 1993/08/01 18:31:22 mycroft Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include "bug.h" -#include "pathnames.h" - -/* - * redist -- - * Redistribute a bug report to those people indicated in the - * redistribution list file. - */ -redist() -{ - extern FILE *dfp; /* dist file fp */ - extern char pfile[]; /* permanent bug file */ - register char *C1, *C2; - FILE *pf, *popen(); - int group; - char *p, *index(); - - (void)sprintf(bfr, "%s/%s", dir, DIST_FILE); - if (!freopen(bfr, "r", stdin)) - return; - for (pf = NULL, group = 0; fgets(bfr, sizeof(bfr), stdin);) { - if (C1 = index(bfr, '\n')) - *C1 = '\0'; -nextline: if (*bfr == COMMENT || isspace(*bfr) || !(C1 = index(bfr, ':'))) - continue; - *C1 = EOS; - if (!strcmp(bfr, folder) || !strcmp(bfr, "all")) { - for (++C1; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); - if (!*C1) /* if empty list */ - continue; - if (!pf) { - if (!(pf = popen(MAIL_CMD, "w"))) - error("sendmail pipe failed.", CHN); - if (mailhead[SUBJ_TAG].found) - fprintf(pf, - "%s", mailhead[SUBJ_TAG].line); - else - fprintf(pf, - "Subject: Untitled Bug Report\n"); - if (!mailhead[TO_TAG].line) { - if (mailhead[APPAR_TO_TAG].line) - fprintf(pf, "To%s", - index(mailhead[APPAR_TO_TAG].line, - ':')); - else - fprintf(pf, "To: %s\n", BUGS_ID); - } - fputs("Resent-To: ", pf); - } - /* - * write out first entry, then succeeding entries - * backward compatible, handles back slashes at end - * of line - */ - if (group++) - fputs(", ", pf); - for (;;) { - if (C2 = index(C1, '\\')) - *C2 = EOS; - fputs(C1, pf); - if (!fgets(bfr, sizeof(bfr), stdin)) - break; - if (C1 = index(bfr, '\n')) - *C1 = '\0'; - if (*bfr != ' ' && *bfr != '\t') - goto nextline; - for (C1 = bfr; - *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1); - } - } - } - if (!pf) - return; - - putc('\n', pf); - - rewind(dfp); - /* add Reference header and copy bug report out */ - while (fgets(bfr, sizeof(bfr), dfp) && *bfr != '\n') - fputs(bfr, pf); - fprintf(pf, "\n%sReference: %s\n\n", mailhead[INDX_TAG].line, pfile); - while (fgets(bfr, sizeof(bfr), dfp)) - fputs(bfr, pf); - (void)pclose(pf); -} diff --git a/libexec/bugfiler/reply.c b/libexec/bugfiler/reply.c deleted file mode 100644 index 96bd900dc68e..000000000000 --- a/libexec/bugfiler/reply.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 1986, 1987 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)reply.c 5.9 (Berkeley) 2/25/91";*/ -static char rcsid[] = "$Id: reply.c,v 1.2 1993/08/01 18:31:19 mycroft Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include "bug.h" -#include "pathnames.h" - -/* - * reply -- - * tell the user we got their silly little bug report - */ -reply() -{ - register char *C, /* traveling pointer */ - *to; /* who we're replying to */ - register int afd, /* ack file descriptor */ - rval; /* return value */ - FILE *pf, /* pipe pointer */ - *popen(); - char *index(); - - if (mailhead[RPLY_TAG].found) { - for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); - if (*C) - goto gotone; - } - if (mailhead[FROM_TAG].found) { - for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); - if (*C) - goto gotone; - } - if (mailhead[CFROM_TAG].found) { - for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;*C != '\n' && (*C == ' ' || *C == '\t');++C); - if (*C) - goto gotone; - } - return; - - /* if it's a foo , get the XXX, else get foo (first string) */ -gotone: if (to = index(C, '<')) - for (C = ++to;*C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C); - else { - to = C; - for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C); - } - *C = EOS; - - if (!(pf = popen(MAIL_CMD, "w"))) - error("sendmail pipe failed.", CHN); - - fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n", BUGS_HOME, BUGS_HOME, to); - if (mailhead[SUBJ_TAG].found) - fprintf(pf, "Subject: Re:%s", mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len); - else - fputs("Subject: Bug report acknowledgement.\n", pf); - if (mailhead[DATE_TAG].found) - fprintf(pf, "In-Acknowledgement-Of: Your message of %s", mailhead[DATE_TAG].line + mailhead[DATE_TAG].len); - if (mailhead[MSG_TAG].found) - fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line); - fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */ - fflush(pf); - - (void)sprintf(bfr, "%s/%s", dir, ACK_FILE); - if ((afd = open(bfr, O_RDONLY, 0)) >= 0) { - while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval) - (void)write(fileno(pf), bfr, rval); - (void)close(afd); - } - pclose(pf); -} diff --git a/libexec/bugfiler/sendbug.1 b/libexec/bugfiler/sendbug.1 deleted file mode 100644 index 53658776e2de..000000000000 --- a/libexec/bugfiler/sendbug.1 +++ /dev/null @@ -1,86 +0,0 @@ -.\" Copyright (c) 1983, 1990 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)sendbug.1 6.8 (Berkeley) 5/9/91 -.\" $Id: sendbug.1,v 1.2 1993/08/01 07:40:29 mycroft Exp $ -.\" -.Dd May 9, 1991 -.Dt SENDBUG 1 -.Os BSD 4.2 -.Sh NAME -.Nm sendbug -.Nd mail a system bug report to 4bsd-bugs -.Sh SYNOPSIS -.Nm sendbug -.Op Ar address -.Sh DESCRIPTION -Bug reports sent to `4bsd-bugs@Berkeley.EDU' are intercepted -by a program which expects bug reports to conform to a standard format. -.Nm Sendbug -is a shell script to help the user compose and mail bug reports -in the correct format. -.Nm Sendbug -works by invoking the editor specified by the environment variable -.Ev EDITOR -on a temporary copy of the bug report format outline. The user must fill in the -appropriate fields and exit the editor. -.Nm Sendbug -then mails the completed report to `4bsd-bugs@Berkeley.EDU' or the -.Ar address -specified on the command line. -.Sh ENVIRONMENT -.Nm Sendbug -will utilize the following environment variable if it exists: -.Bl -tag -width EDITOR -.It Ev EDITOR -Specifies the preferred editor. If -.Ev EDITOR -is not set, -.Nm -defaults to -.Xr vi 1 . -.El -.Sh FILES -.Bl -tag -width /usr/share/misc/bugformat -compact -.It Pa /usr/share/misc/bugformat -Contains the bug report outline. -.El -.Sh SEE ALSO -.Xr vi 1 , -.Xr environ 7 , -.Xr bugfiler 8 , -.Xr sendmail 8 -.Sh HISTORY -The -.Nm sendbug -command -appeared in -.Bx 4.2 . diff --git a/libexec/bugfiler/sendbug.sh b/libexec/bugfiler/sendbug.sh deleted file mode 100644 index 7f616825cf64..000000000000 --- a/libexec/bugfiler/sendbug.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 1983 The Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# @(#)sendbug.sh 5.11 (Berkeley) 7/25/90 -# -# Modified to support 386bsd bugfiler running at sun-lamp.cs.berkeley.edu -# by Rodney W. Grimes on April 1, 1993. -# - -# create a bug report and mail it to 'bugs'. - -PATH=/bin:/sbin:/usr/sbin:/usr/bin -export PATH - -TEMP=/tmp/bug$$ -FORMAT=/usr/share/misc/bugformat - -# uucp sites should use: -# ": ${BUGADDR=sun-lamp!386bsd_bugs}" with a suitable path. -: ${BUGADDR=386bsd_bugs@sun-lamp.cs.berkeley.edu} -: ${EDITOR=vi} - -trap 'rm -f $TEMP ; exit 1' 1 2 3 13 15 - -cp $FORMAT $TEMP -chmod u+w $TEMP -if $EDITOR $TEMP -then - if cmp -s $FORMAT $TEMP - then - echo "File not changed, no bug report submitted." - exit - fi - case "$#" in - 0) (echo "To: $BUGADDR"; cat $TEMP) | sendmail -t -oi ;; - *) (echo "To: $@"; cat $TEMP ) | sendmail -t -oi ;; - esac -fi - -rm -f $TEMP diff --git a/libexec/cron/THANKS b/libexec/cron/THANKS deleted file mode 100644 index 3787c2943d7a..000000000000 --- a/libexec/cron/THANKS +++ /dev/null @@ -1,29 +0,0 @@ -15 January 1990 -Paul Vixie - -Many people have contributed to cron. Many more than I can remember, in fact. -Rich Salz and Carl Gutekunst were each of enormous help to me in V1; Carl for -helping me understand UNIX well enough to write it, and Rich for helping me -get the features right. - -John Gilmore wrote me a wonderful review of V2, which took me a whole year to -answer even though it made me clean up some really awful things in the code. -(According to John the most awful things are still in here, of course.) - -Paul Close made a suggestion which led to /etc/crond.pid and the mutex locking -on it. Kevin Braunsdorf of Purdue made a suggestion that led to @reboot and -its brothers and sisters; he also sent some diffs that lead cron toward compil- -ability with System V, though without at(1) capabilities, this cron isn't going -to be that useful on System V. Bob Alverson fixed a silly bug in the line -number counting. Brian Reid made suggestions which led to the run queue and -the source-file labelling in installed crontabs. - -Scott Narveson ported V2 to a Sequent, and sent in the most useful single batch -of diffs I got from anybody. Changes attributable to Scott are: - -> sendmail won't time out if the command is slow to generate output - -> day-of-week names aren't off by one anymore - -> crontab says the right thing if you do something you shouldn't do - -> crontab(5) man page is longer and more informative - -> misc changes related to the side effects of fclose() - -> Sequent "universe" support added (may also help on Pyramids) - -> null pw_shell is dealt with now; default is /bin/sh diff --git a/libexec/cron/crontab.1 b/libexec/cron/crontab.1 deleted file mode 100644 index 9666a868249f..000000000000 --- a/libexec/cron/crontab.1 +++ /dev/null @@ -1,100 +0,0 @@ -.\"/* Copyright 1988,1990,1993 by Paul Vixie -.\" * All rights reserved -.\" * -.\" * Distribute freely, except: don't remove my name from the source or -.\" * documentation (don't take credit for my work), mark your changes (don't -.\" * get me blamed for your possible bugs), don't alter or remove this -.\" * notice. May be sold if buildable source is provided to buyer. No -.\" * warrantee of any kind, express or implied, is included with this -.\" * software; use at your own risk, responsibility for damages (if any) to -.\" * anyone resulting from the use of this software rests entirely with the -.\" * user. -.\" * -.\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and -.\" * I'll try to keep a version up to date. I can be reached as follows: -.\" * Paul Vixie uunet!decwrl!vixie!paul -.\" */ -.\" -.\" $Id: crontab.1,v 1.1.1.1 1994/01/05 20:40:13 jtc Exp $ -.\" -.TH CRONTAB 1 "29 December 1993" -.UC 4 -.SH NAME -crontab \- maintain crontab files for individual users (V3) -.SH SYNOPSIS -crontab [ -u user ] file -.br -crontab [ -u user ] { -l | -r | -e } -.SH DESCRIPTION -.I Crontab -is the program used to install, deinstall or list the tables -used to drive the -.IR cron (8) -daemon in Vixie Cron. Each user can have their own crontab, and though -these are files in /var, they are not intended to be edited directly. -.PP -If the -.I allow -file exists, then you must be listed therein in order to be allowed to use -this command. If the -.I allow -file does not exist but the -.I deny -file does exist, then you must \fBnot\fR be listed in the -.I deny -file in order to use this command. If neither of these files exists, then -depending on site-dependent configuration parameters, only the super user -will be allowed to use this command, or all users will be able to use this -command. -.PP -If the -.I -u -option is given, it specifies the name of the user whose crontab is to be -tweaked. If this option is not given, -.I crontab -examines "your" crontab, i.e., the crontab of the person executing the -command. Note that -.IR su (8) -can confuse -.I crontab -and that if you are running inside of -.IR su (8) -you should always use the -.I -u -option for safety's sake. -.PP -The first form of this command is used to install a new crontab from some -named file or standard input if the pseudo-filename ``-'' is given. -.PP -The -.I -l -option causes the current crontab to be displayed on standard output. -.PP -The -.I -r -option causes the current crontab to be removed. -.PP -The -.I -e -option is used to edit the current crontab using the editor specified by -the \s-1VISUAL\s+1 or \s-1EDITOR\s+1 environment variables. After you exit -from the editor, the modified crontab will be installed automatically. -.SH "SEE ALSO" -crontab(5), cron(8) -.SH FILES -.nf -/var/cron/allow -/var/cron/deny -.fi -.SH STANDARDS -The -.I crontab -command conforms to IEEE Std1003.2-1992 (``POSIX''). This new command syntax -differs from previous versions of Vixie Cron, as well as from the classic -SVR3 syntax. -.SH DIAGNOSTICS -A fairly informative usage message appears if you run it with a bad command -line. -.SH AUTHOR -.nf -Paul Vixie diff --git a/libexec/cron/crontab.5 b/libexec/cron/crontab.5 deleted file mode 100644 index 941f19069f42..000000000000 --- a/libexec/cron/crontab.5 +++ /dev/null @@ -1,187 +0,0 @@ -.\"/* Copyright 1988,1990,1993,1994 by Paul Vixie -.\" * All rights reserved -.\" * -.\" * Distribute freely, except: don't remove my name from the source or -.\" * documentation (don't take credit for my work), mark your changes (don't -.\" * get me blamed for your possible bugs), don't alter or remove this -.\" * notice. May be sold if buildable source is provided to buyer. No -.\" * warrantee of any kind, express or implied, is included with this -.\" * software; use at your own risk, responsibility for damages (if any) to -.\" * anyone resulting from the use of this software rests entirely with the -.\" * user. -.\" * -.\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and -.\" * I'll try to keep a version up to date. I can be reached as follows: -.\" * Paul Vixie uunet!decwrl!vixie!paul -.\" */ -.\" -.\" $Id: crontab.5,v 1.1.1.3 1994/01/12 18:36:59 jtc Exp $ -.\" -.TH CRONTAB 5 "7 January 1994" -.UC 4 -.SH NAME -crontab \- tables for driving cron -.SH DESCRIPTION -A -.I crontab -file contains instructions to the -.IR cron (8) -daemon of the general form: ``run this command at this time on this date''. -Each user has their own crontab, and commands in any given crontab will be -executed as the user who owns the crontab. Uucp and News will usually have -their own crontabs, eliminating the need for explicitly running -.IR su (1) -as part of a cron command. -.PP -Blank lines and leading spaces and tabs are ignored. Lines whose first -non-space character is a pound-sign (#) are comments, and are ignored. -Note that comments are not allowed on the same line as cron commands, since -they will be taken to be part of the command. Similarly, comments are not -allowed on the same line as environment variable settings. -.PP -An active line in a crontab will be either an environment setting or a cron -command. An environment setting is of the form, -.PP - name = value -.PP -where the spaces around the equal-sign (=) are optional, and any subsequent -non-leading spaces in -.I value -will be part of the value assigned to -.IR name . -The -.I value -string may be placed in quotes (single or double, but matching) to preserve -leading or trailing blanks. -.PP -Several environment variables are set up -automatically by the -.IR cron (8) -daemon. -SHELL is set to /bin/sh, and LOGNAME and HOME are set from the /etc/passwd -line of the crontab's owner. -HOME and SHELL may be overridden by settings in the crontab; LOGNAME may not. -.PP -(Another note: the LOGNAME variable is sometimes called USER on BSD systems... -on these systems, USER will be set also.) -.PP -In addition to LOGNAME, HOME, and SHELL, -.IR cron (8) -will look at MAILTO if it has any reason to send mail as a result of running -commands in ``this'' crontab. If MAILTO is defined (and non-empty), mail is -sent to the user so named. If MAILTO is defined but empty (MAILTO=""), no -mail will be sent. Otherwise mail is sent to the owner of the crontab. This -option is useful if you decide on /bin/mail instead of /usr/lib/sendmail as -your mailer when you install cron -- /bin/mail doesn't do aliasing, and UUCP -usually doesn't read its mail. -.PP -The format of a cron command is very much the V7 standard, with a number of -upward-compatible extensions. Each line has five time and date fields, -followed by a command. Commands are executed by -.IR cron (8) -when the minute, hour, and month of year fields match the current time, -.I and -when at least one of the two day fields (day of month, or day of week) -match the current time (see ``Note'' below). -.IR cron (8) -examines cron entries once every minute. -The time and date fields are: -.IP -.ta 1.5i -field allowed values -.br ------ -------------- -.br -minute 0-59 -.br -hour 0-23 -.br -day of month 0-31 -.br -month 0-12 (or names, see below) -.br -day of week 0-7 (0 or 7 is Sun, or use names) -.br -.PP -A field may be an asterisk (*), which always stands for ``first\-last''. -.PP -Ranges of numbers are allowed. Ranges are two numbers separated -with a hyphen. The specified range is inclusive. For example, -8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10 -and 11. -.PP -Lists are allowed. A list is a set of numbers (or ranges) -separated by commas. Examples: ``1,2,5,9'', ``0-4,8-12''. -.PP -Step values can be used in conjunction with ranges. Following -a range with ``/'' specifies skips of the number's value -through the range. For example, ``0-23/2'' can be used in the hours -field to specify command execution every other hour (the alternative -in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are -also permitted after an asterisk, so if you want to say ``every two -hours'', just use ``*/2''. -.PP -Names can also be used for the ``month'' and ``day of week'' -fields. Use the first three letters of the particular -day or month (case doesn't matter). Ranges or -lists of names are not allowed. -.PP -The ``sixth'' field (the rest of the line) specifies the command to be -run. -The entire command portion of the line, up to a newline or % -character, will be executed by the user's login shell or by the shell -specified in the SHELL variable of the cronfile. -Percent-signs (%) in the command, unless escaped with backslash -(\\), will be changed into newline characters, and all data -after the first % will be sent to the command as standard -input. -.PP -Note: The day of a command's execution can be specified by two -fields \(em day of month, and day of week. If both fields are -restricted (ie, aren't *), the command will be run when -.I either -field matches the current time. For example, -.br -``30 4 1,15 * 5'' -would cause a command to be run at 4:30 am on the 1st and 15th of each -month, plus every Friday. -.SH EXAMPLE CRON FILE -.nf - -# use /bin/sh to run commands, no matter what /etc/passwd says -SHELL=/bin/sh -# mail any output to `paul', no matter whose crontab this is -MAILTO=paul -# -# run five minutes after midnight, every day -5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1 -# run at 2:15pm on the first of every month -- output mailed to paul -15 14 1 * * $HOME/bin/monthly -# run at 10 pm on weekdays, annoy Joe -0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?% -23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday" -5 4 * * sun echo "run at 5 after 4 every sunday" -.fi -.SH SEE ALSO -cron(8), crontab(1) -.SH EXTENSIONS -When specifying day of week, both day 0 and day 7 will be considered Sunday. -BSD and ATT seem to disagree about this. -.PP -Lists and ranges are allowed to co-exist in the same field. "1-3,7-9" would -be rejected by ATT or BSD cron -- they want to see "1-3" or "7,8,9" ONLY. -.PP -Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9". -.PP -Names of months or days of the week can be specified by name. -.PP -Environment variables can be set in the crontab. In BSD or ATT, the -environment handed to child processes is basically the one from /etc/rc. -.PP -Command output is mailed to the crontab owner (BSD can't do this), can be -mailed to a person other than the crontab owner (SysV can't do this), or the -feature can be turned off and no mail will be sent at all (SysV can't do this -either). -.SH AUTHOR -.nf -Paul Vixie diff --git a/libexec/cron/crontab.c b/libexec/cron/crontab.c deleted file mode 100644 index 005b0a0fc8ba..000000000000 --- a/libexec/cron/crontab.c +++ /dev/null @@ -1,574 +0,0 @@ -/* Copyright 1988,1990,1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie uunet!decwrl!vixie!paul - */ - -#if !defined(lint) && !defined(LINT) -static char rcsid[] = "$Id: crontab.c,v 1.1.1.3 1994/01/12 18:37:20 jtc Exp $"; -#endif - -/* crontab - install and manage per-user crontab files - * vix 02may87 [RCS has the rest of the log] - * vix 26jan87 [original] - */ - - -#define MAIN_PROGRAM - - -#include "cron.h" -#include -#include -#include -#include -#ifdef USE_UTIMES -# include -#else -# include -# include -#endif -#if defined(POSIX) -# include -#endif - - -static PID_T Pid; -static char User[MAX_UNAME], RealUser[MAX_UNAME]; -static char Filename[MAX_FNAME]; -static FILE *NewCrontab; -static int CheckErrorCount; -static enum { opt_unknown, opt_list, opt_delete, opt_edit, opt_replace } - Option; -static struct passwd *pw; -static void list_cmd __P((void)), - delete_cmd __P((void)), - edit_cmd __P((void)), - replace_cmd __P((void)), - poke_daemon __P((void)), - check_error __P((char *)), - parse_args __P((int c, char *v[])); - - -#define NHEADER_LINES 3 - - -#if DEBUGGING -static char *Options[] = { "???", "list", "delete", "edit", "replace" }; -#endif - - -static void -usage(msg) - char *msg; -{ - fprintf(stderr, "%s: usage error: %s\n", ProgramName, msg); - fprintf(stderr, "usage:\t%s [-u user] file\n", ProgramName); - fprintf(stderr, "\t%s [-u user] { -e | -l | -r }\n", ProgramName); - fprintf(stderr, "\t\t(default operation is replace, per 1003.2)\n"); - fprintf(stderr, "\t-e\t(edit user's crontab)\n"); - fprintf(stderr, "\t-l\t(list user's crontab)\n"); - fprintf(stderr, "\t-r\t(delete user's crontab)\n"); - exit(ERROR_EXIT); -} - - -int -main(argc, argv) - int argc; - char *argv[]; -{ - Pid = getpid(); - ProgramName = argv[0]; - -#if defined(POSIX) - setlocale(LC_ALL, ""); -#endif - -#if defined(BSD) - setlinebuf(stderr); -#endif - parse_args(argc, argv); /* sets many globals, opens a file */ - set_cron_uid(); - set_cron_cwd(); - if (!allowed(User)) { - fprintf(stderr, - "You (%s) are not allowed to use this program (%s)\n", - User, ProgramName); - fprintf(stderr, "See crontab(1) for more information\n"); - log_it(RealUser, Pid, "AUTH", "crontab command not allowed"); - exit(ERROR_EXIT); - } - switch (Option) - { - case opt_list: list_cmd(); - break; - case opt_delete: delete_cmd(); - break; - case opt_edit: edit_cmd(); - break; - case opt_replace: replace_cmd(); - break; - } - exit(0); - /*NOTREACHED*/ -} - - -static void -parse_args(argc, argv) - int argc; - char *argv[]; -{ - int argch; - - if (!(pw = getpwuid(getuid()))) { - fprintf(stderr, "%s: your UID isn't in the passwd file.\n", - ProgramName); - fprintf(stderr, "bailing out.\n"); - exit(ERROR_EXIT); - } - strcpy(User, pw->pw_name); - strcpy(RealUser, User); - Filename[0] = '\0'; - Option = opt_unknown; - while (EOF != (argch = getopt(argc, argv, "u:lerx:"))) { - switch (argch) { - case 'x': - if (!set_debug_flags(optarg)) - usage("bad debug option"); - break; - case 'u': - if (getuid() != ROOT_UID) - { - fprintf(stderr, - "must be privileged to use -u\n"); - exit(ERROR_EXIT); - } - if (!(pw = getpwnam(optarg))) - { - fprintf(stderr, "%s: user `%s' unknown\n", - ProgramName, optarg); - exit(ERROR_EXIT); - } - (void) strcpy(User, optarg); - break; - case 'l': - if (Option != opt_unknown) - usage("only one operation permitted"); - Option = opt_list; - break; - case 'r': - if (Option != opt_unknown) - usage("only one operation permitted"); - Option = opt_delete; - break; - case 'e': - if (Option != opt_unknown) - usage("only one operation permitted"); - Option = opt_edit; - break; - default: - usage("unrecognized option"); - } - } - - endpwent(); - - if (Option != opt_unknown) { - if (argv[optind] != NULL) { - usage("no arguments permitted after this option"); - } - } else { - if (argv[optind] != NULL) { - Option = opt_replace; - (void) strcpy (Filename, argv[optind]); - } else { - usage("file name must be specified for replace"); - } - } - - if (Option == opt_replace) { - /* we have to open the file here because we're going to - * chdir(2) into /var/cron before we get around to - * reading the file. - */ - if (!strcmp(Filename, "-")) { - NewCrontab = stdin; - } else { - /* relinquish the setuid status of the binary during - * the open, lest nonroot users read files they should - * not be able to read. we can't use access() here - * since there's a race condition. thanks go out to - * Arnt Gulbrandsen for spotting - * the race. - */ - - if (swap_uids() < OK) { - perror("swapping uids"); - exit(ERROR_EXIT); - } - if (!(NewCrontab = fopen(Filename, "r"))) { - perror(Filename); - exit(ERROR_EXIT); - } - if (swap_uids() < OK) { - perror("swapping uids back"); - exit(ERROR_EXIT); - } - } - } - - Debug(DMISC, ("user=%s, file=%s, option=%s\n", - User, Filename, Options[(int)Option])) -} - - -static void -list_cmd() { - char n[MAX_FNAME]; - FILE *f; - int ch; - - log_it(RealUser, Pid, "LIST", User); - (void) sprintf(n, CRON_TAB(User)); - if (!(f = fopen(n, "r"))) { - if (errno == ENOENT) - fprintf(stderr, "no crontab for %s\n", User); - else - perror(n); - exit(ERROR_EXIT); - } - - /* file is open. copy to stdout, close. - */ - Set_LineNum(1) - while (EOF != (ch = get_char(f))) - putchar(ch); - fclose(f); -} - - -static void -delete_cmd() { - char n[MAX_FNAME]; - - log_it(RealUser, Pid, "DELETE", User); - (void) sprintf(n, CRON_TAB(User)); - if (unlink(n)) { - if (errno == ENOENT) - fprintf(stderr, "no crontab for %s\n", User); - else - perror(n); - exit(ERROR_EXIT); - } - poke_daemon(); -} - - -static void -check_error(msg) - char *msg; -{ - CheckErrorCount += 1; - fprintf(stderr, "\"%s\", line %d: %s\n", Filename, LineNumber, msg); -} - - -static void -edit_cmd() { - char n[MAX_FNAME], *editor; - FILE *f; - int ch, t, x; - struct stat statbuf; - time_t mtime; - WAIT_T waiter; - PID_T pid, xpid; - - log_it(RealUser, Pid, "BEGIN EDIT", User); - NewCrontab = NULL; - (void) sprintf(n, CRON_TAB(User)); - if (!(f = fopen(n, "r"))) { - if (errno != ENOENT) { - perror(n); - exit(ERROR_EXIT); - } - fprintf(stderr, "no crontab for %s - using an empty one\n", - User); - if (!(f = fopen("/dev/null", "r"))) { - perror("/dev/null"); - exit(ERROR_EXIT); - } - } - - (void) sprintf(Filename, "/tmp/crontab.%d", Pid); - if (-1 == (t = open(Filename, O_CREAT|O_EXCL|O_RDWR, 0700))) { - perror(Filename); - goto fatal; - } -#ifdef HAS_FCHOWN - if (fchown(t, getuid(), getgid()) < 0) { -#else - if (chown(Filename, getuid(), getgid()) < 0) { -#endif - perror("fchown"); - goto fatal; - } - if (!(NewCrontab = fdopen(t, "r+"))) { - perror("fdopen"); - goto fatal; - } - - Set_LineNum(1) - - /* ignore the top few comments since we probably put them there. - */ - for (x = 0; x < NHEADER_LINES; x++) { - ch = get_char(f); - if (EOF == ch) - break; - if ('#' != ch) { - putc(ch, NewCrontab); - break; - } - while (EOF != (ch = get_char(f))) - if (ch == '\n') - break; - if (EOF == ch) - break; - } - - /* copy the rest of the crontab (if any) to the temp file. - */ - if (EOF != ch) - while (EOF != (ch = get_char(f))) - putc(ch, NewCrontab); - fclose(f); - fflush(NewCrontab); rewind(NewCrontab); - if (ferror(NewCrontab)) { - fprintf(stderr, "%s: error while writing new crontab to %s\n", - ProgramName, Filename); - fatal: if (NewCrontab) fclose(NewCrontab); - unlink(Filename); - exit(ERROR_EXIT); - } - if (fstat(t, &statbuf) < 0) { - perror("fstat"); - goto fatal; - } - mtime = statbuf.st_mtime; - - if ((!(editor = getenv("VISUAL"))) - && (!(editor = getenv("EDITOR"))) - ) { - editor = EDITOR; - } - - /* we still have the file open. editors will generally rewrite the - * original file rather than renaming/unlinking it and starting a - * new one; even backup files are supposed to be made by copying - * rather than by renaming. if some editor does not support this, - * then don't use it. the security problems are more severe if we - * close and reopen the file around the edit. - */ - - switch (pid = fork()) { - case -1: - perror("fork"); - goto fatal; - case 0: - /* child */ - if (setuid(getuid()) < 0) { - perror("setuid(getuid())"); - exit(ERROR_EXIT); - } - if (chdir("/tmp") < 0) { - perror("chdir(/tmp)"); - exit(ERROR_EXIT); - } - execlp(editor, editor, Filename, NULL); - perror(editor); - exit(ERROR_EXIT); - /*NOTREACHED*/ - default: - /* parent */ - break; - } - - /* parent */ - xpid = wait(&waiter); - if (xpid != pid) { - fprintf(stderr, "%s: wrong PID (%d != %d) from \"%s\"\n", - ProgramName, xpid, pid, editor); - goto fatal; - } - if (WIFEXITED(waiter) && WEXITSTATUS(waiter)) { - fprintf(stderr, "%s: \"%s\" exited with status %d\n", - ProgramName, editor, WEXITSTATUS(waiter)); - goto fatal; - } - if (WIFSIGNALED(waiter)) { - fprintf(stderr, - "%s: \"%s\" killed; signal %d (%score dumped)\n", - ProgramName, editor, WTERMSIG(waiter), - WCOREDUMP(waiter) ?"" :"no "); - goto fatal; - } - if (fstat(t, &statbuf) < 0) { - perror("fstat"); - goto fatal; - } - if (mtime == statbuf.st_mtime) { - fprintf(stderr, "%s: no changes made to crontab\n", - ProgramName); - } else { - fprintf(stderr, "%s: installing new crontab\n", - ProgramName); - replace_cmd(); - } - fclose(NewCrontab); unlink(Filename); - log_it(RealUser, Pid, "END EDIT", User); -} - - -static void -replace_cmd() { - char n[MAX_FNAME], envstr[MAX_ENVSTR], tn[MAX_FNAME]; - FILE *tmp; - int ch, eof; - entry *e; - time_t now = time(NULL); - char **envp = env_init(); - - (void) sprintf(n, "tmp.%d", Pid); - (void) sprintf(tn, CRON_TAB(n)); - if (!(tmp = fopen(tn, "w+"))) { - perror(tn); - exit(ERROR_EXIT); - } - - /* write a signature at the top of the file. - * - * VERY IMPORTANT: make sure NHEADER_LINES agrees with this code. - */ - fprintf(tmp, "# DO NOT EDIT THIS FILE - edit the master and reinstall.\n"); - fprintf(tmp, "# (%s installed on %-24.24s)\n", Filename, ctime(&now)); - fprintf(tmp, "# (Cron version -- %s)\n", rcsid); - - /* copy the crontab to the tmp - */ - Set_LineNum(1) - while (EOF != (ch = get_char(NewCrontab))) - putc(ch, tmp); - fclose(NewCrontab); - ftruncate(fileno(tmp), ftell(tmp)); - fflush(tmp); rewind(tmp); - - if (ferror(tmp)) { - fprintf(stderr, "%s: error while writing new crontab to %s\n", - ProgramName, tn); - fclose(tmp); unlink(tn); - exit(ERROR_EXIT); - } - - /* check the syntax of the file being installed. - */ - - /* BUG: was reporting errors after the EOF if there were any errors - * in the file proper -- kludged it by stopping after first error. - * vix 31mar87 - */ - Set_LineNum(1) - CheckErrorCount = 0; eof = FALSE; - while (!CheckErrorCount && !eof) { - switch (load_env(envstr, tmp)) { - case ERR: - eof = TRUE; - break; - case FALSE: - e = load_entry(tmp, check_error, pw, envp); - if (e) free(e); - break; - case TRUE: - break; - } - } - - if (CheckErrorCount != 0) { - fprintf(stderr, "errors in crontab file, can't install.\n"); - fclose(tmp); unlink(tn); - exit(ERROR_EXIT); - } - -#ifdef HAS_FCHOWN - if (fchown(fileno(tmp), ROOT_UID, -1) < OK) { -#else - if (chown(tn, ROOT_UID, -1) < OK) { -#endif - perror("chown"); - fclose(tmp); unlink(tn); - exit(ERROR_EXIT); - } - -#ifdef HAS_FCHMOD - if (fchmod(fileno(tmp), 0600) < OK) { -#else - if (chmod(tn, 0600) < OK) { -#endif - perror("chown"); - fclose(tmp); unlink(tn); - exit(ERROR_EXIT); - } - - if (fclose(tmp) == EOF) { - perror("fclose"); - unlink(tn); - exit(ERROR_EXIT); - } - - (void) sprintf(n, CRON_TAB(User)); - if (rename(tn, n)) { - fprintf(stderr, "%s: error renaming %s to %s\n", - ProgramName, tn, n); - perror("rename"); - unlink(tn); - exit(ERROR_EXIT); - } - log_it(RealUser, Pid, "REPLACE", User); - - poke_daemon(); -} - - -static void -poke_daemon() { -#ifdef USE_UTIMES - struct timeval tvs[2]; - struct timezone tz; - - (void) gettimeofday(&tvs[0], &tz); - tvs[1] = tvs[0]; - if (utimes(SPOOL_DIR, tvs) < OK) { - fprintf(stderr, "crontab: can't update mtime on spooldir\n"); - perror(SPOOL_DIR); - return; - } -#else - if (utime(SPOOL_DIR, NULL) < OK) { - fprintf(stderr, "crontab: can't update mtime on spooldir\n"); - perror(SPOOL_DIR); - return; - } -#endif /*USE_UTIMES*/ -} diff --git a/libexec/cron/database.c b/libexec/cron/database.c deleted file mode 100644 index d523bff41acb..000000000000 --- a/libexec/cron/database.c +++ /dev/null @@ -1,261 +0,0 @@ -/* Copyright 1988,1990,1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie uunet!decwrl!vixie!paul - */ - -#if !defined(lint) && !defined(LINT) -static char rcsid[] = "$Id: database.c,v 1.1.1.3 1994/01/12 18:37:31 jtc Exp $"; -#endif - -/* vix 26jan87 [RCS has the log] - */ - - -#include "cron.h" -#include -#include -#include - - -#define TMAX(a,b) ((a)>(b)?(a):(b)) - - -static void process_crontab __P((char *, char *, char *, - struct stat *, - cron_db *, cron_db *)); - - -void -load_database(old_db) - cron_db *old_db; -{ - DIR *dir; - struct stat statbuf; - struct stat syscron_stat; - DIR_T *dp; - cron_db new_db; - user *u, *nu; - - Debug(DLOAD, ("[%d] load_database()\n", getpid())) - - /* before we start loading any data, do a stat on SPOOL_DIR - * so that if anything changes as of this moment (i.e., before we've - * cached any of the database), we'll see the changes next time. - */ - if (stat(SPOOL_DIR, &statbuf) < OK) { - log_it("CRON", getpid(), "STAT FAILED", SPOOL_DIR); - (void) exit(ERROR_EXIT); - } - - /* track system crontab file - */ - if (stat(SYSCRONTAB, &syscron_stat) < OK) - syscron_stat.st_mtime = 0; - - /* if spooldir's mtime has not changed, we don't need to fiddle with - * the database. - * - * Note that old_db->mtime is initialized to 0 in main(), and - * so is guaranteed to be different than the stat() mtime the first - * time this function is called. - */ - if (old_db->mtime == TMAX(statbuf.st_mtime, syscron_stat.st_mtime)) { - Debug(DLOAD, ("[%d] spool dir mtime unch, no load needed.\n", - getpid())) - return; - } - - /* something's different. make a new database, moving unchanged - * elements from the old database, reloading elements that have - * actually changed. Whatever is left in the old database when - * we're done is chaff -- crontabs that disappeared. - */ - new_db.mtime = TMAX(statbuf.st_mtime, syscron_stat.st_mtime); - new_db.head = new_db.tail = NULL; - - if (syscron_stat.st_mtime) { - process_crontab("root", "*system*", - SYSCRONTAB, &syscron_stat, - &new_db, old_db); - } - - /* we used to keep this dir open all the time, for the sake of - * efficiency. however, we need to close it in every fork, and - * we fork a lot more often than the mtime of the dir changes. - */ - if (!(dir = opendir(SPOOL_DIR))) { - log_it("CRON", getpid(), "OPENDIR FAILED", SPOOL_DIR); - (void) exit(ERROR_EXIT); - } - - while (NULL != (dp = readdir(dir))) { - char fname[MAXNAMLEN+1], - tabname[MAXNAMLEN+1]; - - /* avoid file names beginning with ".". this is good - * because we would otherwise waste two guaranteed calls - * to getpwnam() for . and .., and also because user names - * starting with a period are just too nasty to consider. - */ - if (dp->d_name[0] == '.') - continue; - - (void) strcpy(fname, dp->d_name); - sprintf(tabname, CRON_TAB(fname)); - - process_crontab(fname, fname, tabname, - &statbuf, &new_db, old_db); - } - closedir(dir); - - /* if we don't do this, then when our children eventually call - * getpwnam() in do_command.c's child_process to verify MAILTO=, - * they will screw us up (and v-v). - */ - endpwent(); - - /* whatever's left in the old database is now junk. - */ - Debug(DLOAD, ("unlinking old database:\n")) - for (u = old_db->head; u != NULL; u = nu) { - Debug(DLOAD, ("\t%s\n", u->name)) - nu = u->next; - unlink_user(old_db, u); - free_user(u); - } - - /* overwrite the database control block with the new one. - */ - *old_db = new_db; - Debug(DLOAD, ("load_database is done\n")) -} - - -void -link_user(db, u) - cron_db *db; - user *u; -{ - if (db->head == NULL) - db->head = u; - if (db->tail) - db->tail->next = u; - u->prev = db->tail; - u->next = NULL; - db->tail = u; -} - - -void -unlink_user(db, u) - cron_db *db; - user *u; -{ - if (u->prev == NULL) - db->head = u->next; - else - u->prev->next = u->next; - - if (u->next == NULL) - db->tail = u->prev; - else - u->next->prev = u->prev; -} - - -user * -find_user(db, name) - cron_db *db; - char *name; -{ - char *env_get(); - user *u; - - for (u = db->head; u != NULL; u = u->next) - if (!strcmp(u->name, name)) - break; - return u; -} - - -static void -process_crontab(uname, fname, tabname, statbuf, new_db, old_db) - char *uname; - char *fname; - char *tabname; - struct stat *statbuf; - cron_db *new_db; - cron_db *old_db; -{ - struct passwd *pw = NULL; - int crontab_fd = OK - 1; - user *u; - - if (strcmp(fname, "*system*") && !(pw = getpwnam(uname))) { - /* file doesn't have a user in passwd file. - */ - log_it(fname, getpid(), "ORPHAN", "no passwd entry"); - goto next_crontab; - } - - if ((crontab_fd = open(tabname, O_RDONLY, 0)) < OK) { - /* crontab not accessible? - */ - log_it(fname, getpid(), "CAN'T OPEN", tabname); - goto next_crontab; - } - - if (fstat(crontab_fd, statbuf) < OK) { - log_it(fname, getpid(), "FSTAT FAILED", tabname); - goto next_crontab; - } - - Debug(DLOAD, ("\t%s:", fname)) - u = find_user(old_db, fname); - if (u != NULL) { - /* if crontab has not changed since we last read it - * in, then we can just use our existing entry. - */ - if (u->mtime == statbuf->st_mtime) { - Debug(DLOAD, (" [no change, using old data]")) - unlink_user(old_db, u); - link_user(new_db, u); - goto next_crontab; - } - - /* before we fall through to the code that will reload - * the user, let's deallocate and unlink the user in - * the old database. This is more a point of memory - * efficiency than anything else, since all leftover - * users will be deleted from the old database when - * we finish with the crontab... - */ - Debug(DLOAD, (" [delete old data]")) - unlink_user(old_db, u); - free_user(u); - log_it(fname, getpid(), "RELOAD", tabname); - } - u = load_user(crontab_fd, pw, fname); - if (u != NULL) { - u->mtime = statbuf->st_mtime; - link_user(new_db, u); - } - -next_crontab: - if (crontab_fd >= OK) { - Debug(DLOAD, (" [done]\n")) - close(crontab_fd); - } -} diff --git a/libexec/cron/do_command.c b/libexec/cron/do_command.c deleted file mode 100644 index 443a696813aa..000000000000 --- a/libexec/cron/do_command.c +++ /dev/null @@ -1,501 +0,0 @@ -/* Copyright 1988,1990,1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie uunet!decwrl!vixie!paul - */ - -#if !defined(lint) && !defined(LINT) -static char rcsid[] = "$Id: do_command.c,v 1.1.1.3 1994/01/12 18:37:36 jtc Exp $"; -#endif - - -#include "cron.h" -#include -#if defined(sequent) -# include -#endif -#if defined(SYSLOG) -# include -#endif - - -static void child_process __P((entry *, user *)), - do_univ __P((user *)); - - -void -do_command(e, u) - entry *e; - user *u; -{ - Debug(DPROC, ("[%d] do_command(%s, (%s,%d,%d))\n", - getpid(), e->cmd, u->name, e->uid, e->gid)) - - /* fork to become asynchronous -- parent process is done immediately, - * and continues to run the normal cron code, which means return to - * tick(). the child and grandchild don't leave this function, alive. - * - * vfork() is unsuitable, since we have much to do, and the parent - * needs to be able to run off and fork other processes. - */ - switch (fork()) { - case -1: - log_it("CRON",getpid(),"error","can't fork"); - break; - case 0: - /* child process */ - acquire_daemonlock(1); - child_process(e, u); - Debug(DPROC, ("[%d] child process done, exiting\n", getpid())) - _exit(OK_EXIT); - break; - default: - /* parent process */ - break; - } - Debug(DPROC, ("[%d] main process returning to work\n", getpid())) -} - - -static void -child_process(e, u) - entry *e; - user *u; -{ - int stdin_pipe[2], stdout_pipe[2]; - register char *input_data; - char *usernm, *mailto; - int children = 0; - - Debug(DPROC, ("[%d] child_process('%s')\n", getpid(), e->cmd)) - - /* mark ourselves as different to PS command watchers by upshifting - * our program name. This has no effect on some kernels. - */ - /*local*/{ - register char *pch; - - for (pch = ProgramName; *pch; pch++) - *pch = MkUpper(*pch); - } - - /* discover some useful and important environment settings - */ - usernm = env_get("LOGNAME", e->envp); - mailto = env_get("MAILTO", e->envp); - -#ifdef USE_SIGCHLD - /* our parent is watching for our death by catching SIGCHLD. we - * do not care to watch for our children's deaths this way -- we - * use wait() explictly. so we have to disable the signal (which - * was inherited from the parent). - */ - (void) signal(SIGCHLD, SIG_IGN); -#else - /* on system-V systems, we are ignoring SIGCLD. we have to stop - * ignoring it now or the wait() in cron_pclose() won't work. - * because of this, we have to wait() for our children here, as well. - */ - (void) signal(SIGCLD, SIG_DFL); -#endif /*BSD*/ - - /* create some pipes to talk to our future child - */ - pipe(stdin_pipe); /* child's stdin */ - pipe(stdout_pipe); /* child's stdout */ - - /* since we are a forked process, we can diddle the command string - * we were passed -- nobody else is going to use it again, right? - * - * if a % is present in the command, previous characters are the - * command, and subsequent characters are the additional input to - * the command. Subsequent %'s will be transformed into newlines, - * but that happens later. - */ - /*local*/{ - register int escaped = FALSE; - register int ch; - - for (input_data = e->cmd; ch = *input_data; input_data++) { - if (escaped) { - escaped = FALSE; - continue; - } - if (ch == '\\') { - escaped = TRUE; - continue; - } - if (ch == '%') { - *input_data++ = '\0'; - break; - } - } - } - - /* fork again, this time so we can exec the user's command. - */ - switch (vfork()) { - case -1: - log_it("CRON",getpid(),"error","can't vfork"); - exit(ERROR_EXIT); - /*NOTREACHED*/ - case 0: - Debug(DPROC, ("[%d] grandchild process Vfork()'ed\n", - getpid())) - - /* write a log message. we've waited this long to do it - * because it was not until now that we knew the PID that - * the actual user command shell was going to get and the - * PID is part of the log message. - */ - /*local*/{ - char *x = mkprints((u_char *)e->cmd, strlen(e->cmd)); - - log_it(usernm, getpid(), "CMD", x); - free(x); - } - - /* that's the last thing we'll log. close the log files. - */ -#ifdef SYSLOG - closelog(); -#endif - - /* get new pgrp, void tty, etc. - */ - (void) setsid(); - - /* close the pipe ends that we won't use. this doesn't affect - * the parent, who has to read and write them; it keeps the - * kernel from recording us as a potential client TWICE -- - * which would keep it from sending SIGPIPE in otherwise - * appropriate circumstances. - */ - close(stdin_pipe[WRITE_PIPE]); - close(stdout_pipe[READ_PIPE]); - - /* grandchild process. make std{in,out} be the ends of - * pipes opened by our daddy; make stderr go to stdout. - */ - close(STDIN); dup2(stdin_pipe[READ_PIPE], STDIN); - close(STDOUT); dup2(stdout_pipe[WRITE_PIPE], STDOUT); - close(STDERR); dup2(STDOUT, STDERR); - - /* close the pipes we just dup'ed. The resources will remain. - */ - close(stdin_pipe[READ_PIPE]); - close(stdout_pipe[WRITE_PIPE]); - - /* set our login universe. Do this in the grandchild - * so that the child can invoke /usr/lib/sendmail - * without surprises. - */ - do_univ(u); - - /* set our directory, uid and gid. Set gid first, since once - * we set uid, we've lost root privledges. - */ - setgid(e->gid); -# if defined(BSD) - initgroups(env_get("LOGNAME", e->envp), e->gid); -# endif - setuid(e->uid); /* we aren't root after this... */ - chdir(env_get("HOME", e->envp)); - - /* exec the command. - */ - { - char *shell = env_get("SHELL", e->envp); - -# if DEBUGGING - if (DebugFlags & DTEST) { - fprintf(stderr, - "debug DTEST is on, not exec'ing command.\n"); - fprintf(stderr, - "\tcmd='%s' shell='%s'\n", e->cmd, shell); - _exit(OK_EXIT); - } -# endif /*DEBUGGING*/ - execle(shell, shell, "-c", e->cmd, (char *)0, e->envp); - fprintf(stderr, "execl: couldn't exec `%s'\n", shell); - perror("execl"); - _exit(ERROR_EXIT); - } - break; - default: - /* parent process */ - break; - } - - children++; - - /* middle process, child of original cron, parent of process running - * the user's command. - */ - - Debug(DPROC, ("[%d] child continues, closing pipes\n", getpid())) - - /* close the ends of the pipe that will only be referenced in the - * grandchild process... - */ - close(stdin_pipe[READ_PIPE]); - close(stdout_pipe[WRITE_PIPE]); - - /* - * write, to the pipe connected to child's stdin, any input specified - * after a % in the crontab entry. while we copy, convert any - * additional %'s to newlines. when done, if some characters were - * written and the last one wasn't a newline, write a newline. - * - * Note that if the input data won't fit into one pipe buffer (2K - * or 4K on most BSD systems), and the child doesn't read its stdin, - * we would block here. thus we must fork again. - */ - - if (*input_data && fork() == 0) { - register FILE *out = fdopen(stdin_pipe[WRITE_PIPE], "w"); - register int need_newline = FALSE; - register int escaped = FALSE; - register int ch; - - Debug(DPROC, ("[%d] child2 sending data to grandchild\n", getpid())) - - /* close the pipe we don't use, since we inherited it and - * are part of its reference count now. - */ - close(stdout_pipe[READ_PIPE]); - - /* translation: - * \% -> % - * % -> \n - * \x -> \x for all x != % - */ - while (ch = *input_data++) { - if (escaped) { - if (ch != '%') - putc('\\', out); - } else { - if (ch == '%') - ch = '\n'; - } - - if (!(escaped = (ch == '\\'))) { - putc(ch, out); - need_newline = (ch != '\n'); - } - } - if (escaped) - putc('\\', out); - if (need_newline) - putc('\n', out); - - /* close the pipe, causing an EOF condition. fclose causes - * stdin_pipe[WRITE_PIPE] to be closed, too. - */ - fclose(out); - - Debug(DPROC, ("[%d] child2 done sending to grandchild\n", getpid())) - exit(0); - } - - /* close the pipe to the grandkiddie's stdin, since its wicked uncle - * ernie back there has it open and will close it when he's done. - */ - close(stdin_pipe[WRITE_PIPE]); - - children++; - - /* - * read output from the grandchild. it's stderr has been redirected to - * it's stdout, which has been redirected to our pipe. if there is any - * output, we'll be mailing it to the user whose crontab this is... - * when the grandchild exits, we'll get EOF. - */ - - Debug(DPROC, ("[%d] child reading output from grandchild\n", getpid())) - - /*local*/{ - register FILE *in = fdopen(stdout_pipe[READ_PIPE], "r"); - register int ch = getc(in); - - if (ch != EOF) { - register FILE *mail; - register int bytes = 1; - int status = 0; - - Debug(DPROC|DEXT, - ("[%d] got data (%x:%c) from grandchild\n", - getpid(), ch, ch)) - - /* get name of recipient. this is MAILTO if set to a - * valid local username; USER otherwise. - */ - if (mailto) { - /* MAILTO was present in the environment - */ - if (!*mailto) { - /* ... but it's empty. set to NULL - */ - mailto = NULL; - } - } else { - /* MAILTO not present, set to USER. - */ - mailto = usernm; - } - - /* if we are supposed to be mailing, MAILTO will - * be non-NULL. only in this case should we set - * up the mail command and subjects and stuff... - */ - - if (mailto) { - register char **env; - auto char mailcmd[MAX_COMMAND]; - auto char hostname[MAXHOSTNAMELEN]; - - (void) gethostname(hostname, MAXHOSTNAMELEN); - (void) sprintf(mailcmd, MAILARGS, - MAILCMD, mailto); - if (!(mail = cron_popen(mailcmd, "w"))) { - perror(MAILCMD); - (void) _exit(ERROR_EXIT); - } - fprintf(mail, "From: root (Cron Daemon)\n"); - fprintf(mail, "To: %s\n", mailto); - fprintf(mail, "Subject: Cron <%s@%s> %s\n", - usernm, first_word(hostname, "."), - e->cmd); -# if defined(MAIL_DATE) - fprintf(mail, "Date: %s\n", - arpadate(&TargetTime)); -# endif /* MAIL_DATE */ - for (env = e->envp; *env; env++) - fprintf(mail, "X-Cron-Env: <%s>\n", - *env); - fprintf(mail, "\n"); - - /* this was the first char from the pipe - */ - putc(ch, mail); - } - - /* we have to read the input pipe no matter whether - * we mail or not, but obviously we only write to - * mail pipe if we ARE mailing. - */ - - while (EOF != (ch = getc(in))) { - bytes++; - if (mailto) - putc(ch, mail); - } - - /* only close pipe if we opened it -- i.e., we're - * mailing... - */ - - if (mailto) { - Debug(DPROC, ("[%d] closing pipe to mail\n", - getpid())) - /* Note: the pclose will probably see - * the termination of the grandchild - * in addition to the mail process, since - * it (the grandchild) is likely to exit - * after closing its stdout. - */ - status = cron_pclose(mail); - } - - /* if there was output and we could not mail it, - * log the facts so the poor user can figure out - * what's going on. - */ - if (mailto && status) { - char buf[MAX_TEMPSTR]; - - sprintf(buf, - "mailed %d byte%s of output but got status 0x%04x\n", - bytes, (bytes==1)?"":"s", - status); - log_it(usernm, getpid(), "MAIL", buf); - } - - } /*if data from grandchild*/ - - Debug(DPROC, ("[%d] got EOF from grandchild\n", getpid())) - - fclose(in); /* also closes stdout_pipe[READ_PIPE] */ - } - - /* wait for children to die. - */ - for (; children > 0; children--) - { - WAIT_T waiter; - PID_T pid; - - Debug(DPROC, ("[%d] waiting for grandchild #%d to finish\n", - getpid(), children)) - pid = wait(&waiter); - if (pid < OK) { - Debug(DPROC, ("[%d] no more grandchildren--mail written?\n", - getpid())) - break; - } - Debug(DPROC, ("[%d] grandchild #%d finished, status=%04x", - getpid(), pid, WEXITSTATUS(waiter))) - if (WIFSIGNALED(waiter) && WCOREDUMP(waiter)) - Debug(DPROC, (", dumped core")) - Debug(DPROC, ("\n")) - } -} - - -static void -do_univ(u) - user *u; -{ -#if defined(sequent) -/* Dynix (Sequent) hack to put the user associated with - * the passed user structure into the ATT universe if - * necessary. We have to dig the gecos info out of - * the user's password entry to see if the magic - * "universe(att)" string is present. - */ - - struct passwd *p; - char *s; - int i; - - p = getpwuid(u->uid); - (void) endpwent(); - - if (p == NULL) - return; - - s = p->pw_gecos; - - for (i = 0; i < 4; i++) - { - if ((s = strchr(s, ',')) == NULL) - return; - s++; - } - if (strcmp(s, "universe(att)")) - return; - - (void) universe(U_ATT); -#endif -} diff --git a/libexec/cron/entry.c b/libexec/cron/entry.c deleted file mode 100644 index 283786f29724..000000000000 --- a/libexec/cron/entry.c +++ /dev/null @@ -1,526 +0,0 @@ -/* Copyright 1988,1990,1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie uunet!decwrl!vixie!paul - */ - -#if !defined(lint) && !defined(LINT) -static char rcsid[] = "$Id: entry.c,v 1.1.1.3 1994/01/12 18:37:40 jtc Exp $"; -#endif - -/* vix 26jan87 [RCS'd; rest of log is in RCS file] - * vix 01jan87 [added line-level error recovery] - * vix 31dec86 [added /step to the from-to range, per bob@acornrc] - * vix 30dec86 [written] - */ - - -#include "cron.h" - - -typedef enum ecode { - e_none, e_minute, e_hour, e_dom, e_month, e_dow, - e_cmd, e_timespec, e_username -} ecode_e; - -static char get_list __P((bitstr_t *, int, int, char *[], int, FILE *)), - get_range __P((bitstr_t *, int, int, char *[], int, FILE *)), - get_number __P((int *, int, char *[], int, FILE *)); -static int set_element __P((bitstr_t *, int, int, int)); - -static char *ecodes[] = - { - "no error", - "bad minute", - "bad hour", - "bad day-of-month", - "bad month", - "bad day-of-week", - "bad command", - "bad time specifier", - "bad username", - }; - - -void -free_entry(e) - entry *e; -{ - free(e->cmd); - env_free(e->envp); - free(e); -} - - -entry * -load_entry(file, error_func, pw, envp) - FILE *file; - void (*error_func)(); - struct passwd *pw; - char **envp; -{ - /* this function reads one crontab entry -- the next -- from a file. - * it skips any leading blank lines, ignores comments, and returns - * EOF if for any reason the entry can't be read and parsed. - * - * the entry is also parsed here. - * - * syntax: - * user crontab: - * minutes hours doms months dows cmd\n - * system crontab (/etc/crontab): - * minutes hours doms months dows USERNAME cmd\n - */ - - ecode_e ecode = e_none; - entry *e; - int ch; - char cmd[MAX_COMMAND]; - char envstr[MAX_ENVSTR]; - - Debug(DPARS, ("load_entry()...about to eat comments\n")) - - skip_comments(file); - - ch = get_char(file); - if (ch == EOF) - return NULL; - - /* ch is now the first useful character of a useful line. - * it may be an @special or it may be the first character - * of a list of minutes. - */ - - e = (entry *) calloc(sizeof(entry), sizeof(char)); - - if (ch == '@') { - /* all of these should be flagged and load-limited; i.e., - * instead of @hourly meaning "0 * * * *" it should mean - * "close to the front of every hour but not 'til the - * system load is low". Problems are: how do you know - * what "low" means? (save me from /etc/cron.conf!) and: - * how to guarantee low variance (how low is low?), which - * means how to we run roughly every hour -- seems like - * we need to keep a history or let the first hour set - * the schedule, which means we aren't load-limited - * anymore. too much for my overloaded brain. (vix, jan90) - * HINT - */ - ch = get_string(cmd, MAX_COMMAND, file, " \t\n"); - if (!strcmp("reboot", cmd)) { - e->flags |= WHEN_REBOOT; - } else if (!strcmp("yearly", cmd) || !strcmp("annually", cmd)){ - bit_set(e->minute, 0); - bit_set(e->hour, 0); - bit_set(e->dom, 0); - bit_set(e->month, 0); - bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1)); - } else if (!strcmp("monthly", cmd)) { - bit_set(e->minute, 0); - bit_set(e->hour, 0); - bit_set(e->dom, 0); - bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1)); - bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1)); - } else if (!strcmp("weekly", cmd)) { - bit_set(e->minute, 0); - bit_set(e->hour, 0); - bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1)); - bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1)); - bit_set(e->dow, 0); - } else if (!strcmp("daily", cmd) || !strcmp("midnight", cmd)) { - bit_set(e->minute, 0); - bit_set(e->hour, 0); - bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1)); - bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1)); - bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1)); - } else if (!strcmp("hourly", cmd)) { - bit_set(e->minute, 0); - bit_set(e->hour, (LAST_HOUR-FIRST_HOUR+1)); - bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1)); - bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1)); - bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1)); - } else { - ecode = e_timespec; - goto eof; - } - } else { - Debug(DPARS, ("load_entry()...about to parse numerics\n")) - - ch = get_list(e->minute, FIRST_MINUTE, LAST_MINUTE, - PPC_NULL, ch, file); - if (ch == EOF) { - ecode = e_minute; - goto eof; - } - - /* hours - */ - - ch = get_list(e->hour, FIRST_HOUR, LAST_HOUR, - PPC_NULL, ch, file); - if (ch == EOF) { - ecode = e_hour; - goto eof; - } - - /* DOM (days of month) - */ - - if (ch == '*') - e->flags |= DOM_STAR; - ch = get_list(e->dom, FIRST_DOM, LAST_DOM, - PPC_NULL, ch, file); - if (ch == EOF) { - ecode = e_dom; - goto eof; - } - - /* month - */ - - ch = get_list(e->month, FIRST_MONTH, LAST_MONTH, - MonthNames, ch, file); - if (ch == EOF) { - ecode = e_month; - goto eof; - } - - /* DOW (days of week) - */ - - if (ch == '*') - e->flags |= DOW_STAR; - ch = get_list(e->dow, FIRST_DOW, LAST_DOW, - DowNames, ch, file); - if (ch == EOF) { - ecode = e_dow; - goto eof; - } - } - - /* make sundays equivilent */ - if (bit_test(e->dow, 0) || bit_test(e->dow, 7)) { - bit_set(e->dow, 0); - bit_set(e->dow, 7); - } - - /* ch is the first character of a command, or a username */ - unget_char(ch, file); - - if (!pw) { - char *username = cmd; /* temp buffer */ - - Debug(DPARS, ("load_entry()...about to parse username\n")) - ch = get_string(username, MAX_COMMAND, file, " \t"); - - Debug(DPARS, ("load_entry()...got %s\n",username)) - if (ch == EOF) { - ecode = e_cmd; - goto eof; - } - - pw = getpwnam(username); - if (pw == NULL) { - ecode = e_username; - goto eof; - } - Debug(DPARS, ("load_entry()...uid %d, gid %d\n",e->uid,e->gid)) - } - - e->uid = pw->pw_uid; - e->gid = pw->pw_gid; - - /* copy and fix up environment. some variables are just defaults and - * others are overrides. - */ - e->envp = env_copy(envp); - if (!env_get("SHELL", e->envp)) { - sprintf(envstr, "SHELL=%s", _PATH_BSHELL); - e->envp = env_set(e->envp, envstr); - } - if (!env_get("HOME", e->envp)) { - sprintf(envstr, "HOME=%s", pw->pw_dir); - e->envp = env_set(e->envp, envstr); - } - if (!env_get("PATH", e->envp)) { - sprintf(envstr, "PATH=%s", _PATH_DEFPATH); - e->envp = env_set(e->envp, envstr); - } - sprintf(envstr, "%s=%s", "LOGNAME", pw->pw_name); - e->envp = env_set(e->envp, envstr); -#if defined(BSD) - sprintf(envstr, "%s=%s", "USER", pw->pw_name); - e->envp = env_set(e->envp, envstr); -#endif - - Debug(DPARS, ("load_entry()...about to parse command\n")) - - /* Everything up to the next \n or EOF is part of the command... - * too bad we don't know in advance how long it will be, since we - * need to malloc a string for it... so, we limit it to MAX_COMMAND. - * XXX - should use realloc(). - */ - ch = get_string(cmd, MAX_COMMAND, file, "\n"); - - /* a file without a \n before the EOF is rude, so we'll complain... - */ - if (ch == EOF) { - ecode = e_cmd; - goto eof; - } - - /* got the command in the 'cmd' string; save it in *e. - */ - e->cmd = strdup(cmd); - - Debug(DPARS, ("load_entry()...returning successfully\n")) - - /* success, fini, return pointer to the entry we just created... - */ - return e; - -eof: /* if we want to return EOF, we have to jump down here and - * free the entry we've been building. - * - * now, in some cases, a parse routine will have returned EOF to - * indicate an error, but the file is not actually done. since, in - * that case, we only want to skip the line with the error on it, - * we'll do that here. - * - * many, including the author, see what's below as evil programming - * practice: since I didn't want to change the structure of this - * whole function to support this error recovery, I recurse. Cursed! - * (At least it's tail-recursion, as if it matters in C - vix/8feb88) - * I'm seriously considering using (another) GOTO... argh! - * (this does not get less disgusting over time. vix/15nov88) - * (indeed not. vix/20dec93) - */ - - (void) free(e); - - if (feof(file)) - return NULL; - - if (error_func) - (*error_func)(ecodes[(int)ecode]); - do {ch = get_char(file);} - while (ch != EOF && ch != '\n'); - if (ch == EOF) - return NULL; - return load_entry(file, error_func, pw, envp); -} - - -static char -get_list(bits, low, high, names, ch, file) - bitstr_t *bits; /* one bit per flag, default=FALSE */ - int low, high; /* bounds, impl. offset for bitstr */ - char *names[]; /* NULL or *[] of names for these elements */ - int ch; /* current character being processed */ - FILE *file; /* file being read */ -{ - register int done; - - /* we know that we point to a non-blank character here; - * must do a Skip_Blanks before we exit, so that the - * next call (or the code that picks up the cmd) can - * assume the same thing. - */ - - Debug(DPARS|DEXT, ("get_list()...entered\n")) - - /* list = range {"," range} - */ - - /* clear the bit string, since the default is 'off'. - */ - bit_nclear(bits, 0, (high-low+1)); - - /* process all ranges - */ - done = FALSE; - while (!done) { - ch = get_range(bits, low, high, names, ch, file); - if (ch == ',') - ch = get_char(file); - else - done = TRUE; - } - - /* exiting. skip to some blanks, then skip over the blanks. - */ - Skip_Nonblanks(ch, file) - Skip_Blanks(ch, file) - - Debug(DPARS|DEXT, ("get_list()...exiting w/ %02x\n", ch)) - - return ch; -} - - -static char -get_range(bits, low, high, names, ch, file) - bitstr_t *bits; /* one bit per flag, default=FALSE */ - int low, high; /* bounds, impl. offset for bitstr */ - char *names[]; /* NULL or names of elements */ - int ch; /* current character being processed */ - FILE *file; /* file being read */ -{ - /* range = number | number "-" number [ "/" number ] - */ - - register int i; - auto int num1, num2, num3; - - Debug(DPARS|DEXT, ("get_range()...entering, exit won't show\n")) - - if (ch == '*') { - /* '*' means "first-last" but can still be modified by /step - */ - num1 = low; - num2 = high; - ch = get_char(file); - if (ch == EOF) - return EOF; - } else { - if (EOF == (ch = get_number(&num1, low, names, ch, file))) - return EOF; - - if (ch != '-') { - /* not a range, it's a single number. - */ - if (EOF == set_element(bits, low, high, num1)) - return EOF; - return ch; - } else { - /* eat the dash - */ - ch = get_char(file); - if (ch == EOF) - return EOF; - - /* get the number following the dash - */ - ch = get_number(&num2, low, names, ch, file); - if (ch == EOF) - return EOF; - } - } - - /* check for step size - */ - if (ch == '/') { - /* eat the slash - */ - ch = get_char(file); - if (ch == EOF) - return EOF; - - /* get the step size -- note: we don't pass the - * names here, because the number is not an - * element id, it's a step size. 'low' is - * sent as a 0 since there is no offset either. - */ - ch = get_number(&num3, 0, PPC_NULL, ch, file); - if (ch == EOF) - return EOF; - } else { - /* no step. default==1. - */ - num3 = 1; - } - - /* range. set all elements from num1 to num2, stepping - * by num3. (the step is a downward-compatible extension - * proposed conceptually by bob@acornrc, syntactically - * designed then implmented by paul vixie). - */ - for (i = num1; i <= num2; i += num3) - if (EOF == set_element(bits, low, high, i)) - return EOF; - - return ch; -} - - -static char -get_number(numptr, low, names, ch, file) - int *numptr; /* where does the result go? */ - int low; /* offset applied to result if symbolic enum used */ - char *names[]; /* symbolic names, if any, for enums */ - int ch; /* current character */ - FILE *file; /* source */ -{ - char temp[MAX_TEMPSTR], *pc; - int len, i, all_digits; - - /* collect alphanumerics into our fixed-size temp array - */ - pc = temp; - len = 0; - all_digits = TRUE; - while (isalnum(ch)) { - if (++len >= MAX_TEMPSTR) - return EOF; - - *pc++ = ch; - - if (!isdigit(ch)) - all_digits = FALSE; - - ch = get_char(file); - } - *pc = '\0'; - - /* try to find the name in the name list - */ - if (names) { - for (i = 0; names[i] != NULL; i++) { - Debug(DPARS|DEXT, - ("get_num, compare(%s,%s)\n", names[i], temp)) - if (!strcasecmp(names[i], temp)) { - *numptr = i+low; - return ch; - } - } - } - - /* no name list specified, or there is one and our string isn't - * in it. either way: if it's all digits, use its magnitude. - * otherwise, it's an error. - */ - if (all_digits) { - *numptr = atoi(temp); - return ch; - } - - return EOF; -} - - -static int -set_element(bits, low, high, number) - bitstr_t *bits; /* one bit per flag, default=FALSE */ - int low; - int high; - int number; -{ - Debug(DPARS|DEXT, ("set_element(?,%d,%d,%d)\n", low, high, number)) - - if (number < low || number > high) - return EOF; - - bit_set(bits, (number-low)); - return OK; -} diff --git a/libexec/cron/env.c b/libexec/cron/env.c deleted file mode 100644 index 61d465bc153a..000000000000 --- a/libexec/cron/env.c +++ /dev/null @@ -1,174 +0,0 @@ -/* Copyright 1988,1990,1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie uunet!decwrl!vixie!paul - */ - -#if !defined(lint) && !defined(LINT) -static char rcsid[] = "$Id: env.c,v 1.1.1.3 1994/01/12 18:37:43 jtc Exp $"; -#endif - - -#include "cron.h" - - -char ** -env_init() -{ - register char **p = (char **) malloc(sizeof(char **)); - - p[0] = NULL; - return p; -} - - -void -env_free(envp) - char **envp; -{ - char **p; - - for (p = envp; *p; p++) - free(*p); - free(envp); -} - - -char ** -env_copy(envp) - register char **envp; -{ - register int count, i; - register char **p; - - for (count = 0; envp[count] != NULL; count++) - ; - p = (char **) malloc((count+1) * sizeof(char *)); /* 1 for the NULL */ - for (i = 0; i < count; i++) - p[i] = strdup(envp[i]); - p[count] = NULL; - return p; -} - - -char ** -env_set(envp, envstr) - char **envp; - char *envstr; -{ - register int count, found; - register char **p; - - /* - * count the number of elements, including the null pointer; - * also set 'found' to -1 or index of entry if already in here. - */ - found = -1; - for (count = 0; envp[count] != NULL; count++) { - if (!strcmp_until(envp[count], envstr, '=')) - found = count; - } - count++; /* for the NULL */ - - if (found != -1) { - /* - * it exists already, so just free the existing setting, - * save our new one there, and return the existing array. - */ - free(envp[found]); - envp[found] = strdup(envstr); - return envp; - } - - /* - * it doesn't exist yet, so resize the array, move null pointer over - * one, save our string over the old null pointer, and return resized - * array. - */ - p = (char **) realloc((void *) envp, - (unsigned) ((count+1) * sizeof(char **))); - p[count] = p[count-1]; - p[count-1] = strdup(envstr); - return p; -} - - -/* return ERR = end of file - * FALSE = not an env setting (file was repositioned) - * TRUE = was an env setting - */ -int -load_env(envstr, f) - char *envstr; - FILE *f; -{ - long filepos; - int fileline; - char name[MAX_TEMPSTR], val[MAX_ENVSTR]; - int fields; - - filepos = ftell(f); - fileline = LineNumber; - skip_comments(f); - if (EOF == get_string(envstr, MAX_ENVSTR, f, "\n")) - return ERR; - - Debug(DPARS, ("load_env, read <%s>\n", envstr)) - - name[0] = val[0] = '\0'; - fields = sscanf(envstr, "%[^ =] = %[^\n#]", name, val); - if (fields != 2) { - Debug(DPARS, ("load_env, not 2 fields (%d)\n", fields)) - fseek(f, filepos, 0); - Set_LineNum(fileline); - return FALSE; - } - - /* 2 fields from scanf; looks like an env setting - */ - - /* - * process value string - */ - /*local*/{ - int len = strdtb(val); - - if (len >= 2) { - if (val[0] == '\'' || val[0] == '"') { - if (val[len-1] == val[0]) { - val[len-1] = '\0'; - (void) strcpy(val, val+1); - } - } - } - } - - (void) sprintf(envstr, "%s=%s", name, val); - Debug(DPARS, ("load_env, <%s> <%s> -> <%s>\n", name, val, envstr)) - return TRUE; -} - - -char * -env_get(name, envp) - register char *name; - register char **envp; -{ - for (; *envp; envp++) { - register char *p = strchr(*envp, '='); - if (p && !strncmp(*envp, name, p - *envp)) - return p+1; - } - return NULL; -} diff --git a/libexec/cron/externs.h b/libexec/cron/externs.h deleted file mode 100644 index 3efe605897ec..000000000000 --- a/libexec/cron/externs.h +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright 1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie uunet!decwrl!vixie!paul - */ - -#if defined(POSIX) || defined(ATT) -# include -# include -# include -# include -# define DIR_T struct dirent -# define WAIT_T int -# define WAIT_IS_INT 1 -extern char *tzname[2]; -# define TZONE(tm) tzname[(tm).tm_isdst] -#endif - -#if defined(UNIXPC) -# undef WAIT_T -# undef WAIT_IS_INT -# define WAIT_T union wait -#endif - -#if defined(POSIX) -# define SIG_T sig_t -# define TIME_T time_t -# define PID_T pid_t -#endif - -#if defined(ATT) -# define SIG_T void -# define TIME_T long -# define PID_T int -#endif - -#if !defined(POSIX) && !defined(ATT) -/* classic BSD */ -extern time_t time(); -extern unsigned sleep(); -extern struct tm *localtime(); -extern struct passwd *getpwnam(); -extern int errno; -extern void perror(), exit(), free(); -extern char *getenv(), *strcpy(), *strchr(), *strtok(); -extern void *malloc(), *realloc(); -# define SIG_T void -# define TIME_T long -# define PID_T int -# define WAIT_T union wait -# define DIR_T struct direct -# include -# define TZONE(tm) (tm).tm_zone -#endif - -/* getopt() isn't part of POSIX. some systems define it in anyway. - * of those that do, some complain that our definition is different and some - * do not. to add to the misery and confusion, some systems define getopt() - * in ways that we cannot predict or comprehend, yet do not define the adjunct - * external variables needed for the interface. - */ -#if (!defined(BSD) || (BSD < 198911)) && !defined(ATT) && !defined(UNICOS) -int getopt __P((int, char * const *, const char *)); -#endif - -#if (!defined(BSD) || (BSD < 199103)) -extern char *optarg; -extern int optind, opterr, optopt; -#endif - -#if WAIT_IS_INT -# ifndef WEXITSTATUS -# define WEXITSTATUS(x) (((x) >> 8) & 0xff) -# endif -# ifndef WTERMSIG -# define WTERMSIG(x) ((x) & 0x7f) -# endif -# ifndef WCOREDUMP -# define WCOREDUMP(x) ((x) & 0x80) -# endif -#else /*WAIT_IS_INT*/ -# ifndef WEXITSTATUS -# define WEXITSTATUS(x) ((x).w_retcode) -# endif -# ifndef WTERMSIG -# define WTERMSIG(x) ((x).w_termsig) -# endif -# ifndef WCOREDUMP -# define WCOREDUMP(x) ((x).w_coredump) -# endif -#endif /*WAIT_IS_INT*/ - -#ifndef WIFSIGNALED -#define WIFSIGNALED(x) (WTERMSIG(x) != 0) -#endif -#ifndef WIFEXITED -#define WIFEXITED(x) (WTERMSIG(x) == 0) -#endif - -#ifdef NEED_STRCASECMP -extern int strcasecmp __P((char *, char *)); -#endif - -#ifdef NEED_STRDUP -extern char *strdup __P((char *)); -#endif - -#ifdef NEED_STRERROR -extern char *strerror __P((int)); -#endif - -#ifdef NEED_FLOCK -extern int flock __P((int, int)); -# define LOCK_SH 1 -# define LOCK_EX 2 -# define LOCK_NB 4 -# define LOCK_UN 8 -#endif - -#ifdef NEED_SETSID -extern int setsid __P((void)); -#endif - -#ifdef NEED_GETDTABLESIZE -extern int getdtablesize __P((void)); -#endif - -#ifdef NEED_SETENV -extern int setenv __P((char *, char *, int)); -#endif - -#ifdef NEED_VFORK -extern PID_T vfork __P((void)); -#endif diff --git a/libexec/cron/job.c b/libexec/cron/job.c deleted file mode 100644 index 7f26212266d7..000000000000 --- a/libexec/cron/job.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 1988,1990,1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie uunet!decwrl!vixie!paul - */ - -#if !defined(lint) && !defined(LINT) -static char rcsid[] = "$Id: job.c,v 1.1.1.2 1994/01/12 18:37:50 jtc Exp $"; -#endif - - -#include "cron.h" - - -typedef struct _job { - struct _job *next; - entry *e; - user *u; -} job; - - -static job *jhead = NULL, *jtail = NULL; - - -void -job_add(e, u) - register entry *e; - register user *u; -{ - register job *j; - - /* if already on queue, keep going */ - for (j=jhead; j; j=j->next) - if (j->e == e && j->u == u) { return; } - - /* build a job queue element */ - j = (job*)malloc(sizeof(job)); - j->next = (job*) NULL; - j->e = e; - j->u = u; - - /* add it to the tail */ - if (!jhead) { jhead=j; } - else { jtail->next=j; } - jtail = j; -} - - -int -job_runqueue() -{ - register job *j, *jn; - register int run = 0; - - for (j=jhead; j; j=jn) { - do_command(j->e, j->u); - jn = j->next; - free(j); - run++; - } - jhead = jtail = NULL; - return run; -} diff --git a/libexec/cron/misc.c b/libexec/cron/misc.c deleted file mode 100644 index 03c41610e56c..000000000000 --- a/libexec/cron/misc.c +++ /dev/null @@ -1,664 +0,0 @@ -/* Copyright 1988,1990,1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie uunet!decwrl!vixie!paul - */ - -#if !defined(lint) && !defined(LINT) -static char rcsid[] = "$Id: misc.c,v 1.1.1.2 1994/01/12 18:37:54 jtc Exp $"; -#endif - -/* vix 26jan87 [RCS has the rest of the log] - * vix 30dec86 [written] - */ - - -#include "cron.h" -#if SYS_TIME_H -# include -#else -# include -#endif -#include -#include -#include -#include -#include -#if defined(SYSLOG) -# include -#endif - - -#if defined(LOG_DAEMON) && !defined(LOG_CRON) -#define LOG_CRON LOG_DAEMON -#endif - - -static int LogFD = ERR; - - -int -strcmp_until(left, right, until) - char *left; - char *right; - int until; -{ - register int diff; - - while (*left && *left != until && *left == *right) { - left++; - right++; - } - - if ((*left=='\0' || *left == until) && - (*right=='\0' || *right == until)) { - diff = 0; - } else { - diff = *left - *right; - } - - return diff; -} - - -/* strdtb(s) - delete trailing blanks in string 's' and return new length - */ -int -strdtb(s) - char *s; -{ - char *x = s; - - /* scan forward to the null - */ - while (*x) - x++; - - /* scan backward to either the first character before the string, - * or the last non-blank in the string, whichever comes first. - */ - do {x--;} - while (x >= s && isspace(*x)); - - /* one character beyond where we stopped above is where the null - * goes. - */ - *++x = '\0'; - - /* the difference between the position of the null character and - * the position of the first character of the string is the length. - */ - return x - s; -} - - -int -set_debug_flags(flags) - char *flags; -{ - /* debug flags are of the form flag[,flag ...] - * - * if an error occurs, print a message to stdout and return FALSE. - * otherwise return TRUE after setting ERROR_FLAGS. - */ - -#if !DEBUGGING - - printf("this program was compiled without debugging enabled\n"); - return FALSE; - -#else /* DEBUGGING */ - - char *pc = flags; - - DebugFlags = 0; - - while (*pc) { - char **test; - int mask; - - /* try to find debug flag name in our list. - */ - for ( test = DebugFlagNames, mask = 1; - *test && strcmp_until(*test, pc, ','); - test++, mask <<= 1 - ) - ; - - if (!*test) { - fprintf(stderr, - "unrecognized debug flag <%s> <%s>\n", - flags, pc); - return FALSE; - } - - DebugFlags |= mask; - - /* skip to the next flag - */ - while (*pc && *pc != ',') - pc++; - if (*pc == ',') - pc++; - } - - if (DebugFlags) { - int flag; - - fprintf(stderr, "debug flags enabled:"); - - for (flag = 0; DebugFlagNames[flag]; flag++) - if (DebugFlags & (1 << flag)) - fprintf(stderr, " %s", DebugFlagNames[flag]); - fprintf(stderr, "\n"); - } - - return TRUE; - -#endif /* DEBUGGING */ -} - - -void -set_cron_uid() -{ -#if defined(BSD) || defined(POSIX) - if (seteuid(ROOT_UID) < OK) { - perror("seteuid"); - exit(ERROR_EXIT); - } -#else - if (setuid(ROOT_UID) < OK) { - perror("setuid"); - exit(ERROR_EXIT); - } -#endif -} - - -void -set_cron_cwd() -{ - struct stat sb; - - /* first check for CRONDIR ("/var/cron" or some such) - */ - if (stat(CRONDIR, &sb) < OK && errno == ENOENT) { - perror(CRONDIR); - if (OK == mkdir(CRONDIR, 0700)) { - fprintf(stderr, "%s: created\n", CRONDIR); - stat(CRONDIR, &sb); - } else { - fprintf(stderr, "%s: ", CRONDIR); - perror("mkdir"); - exit(ERROR_EXIT); - } - } - if (!(sb.st_mode & S_IFDIR)) { - fprintf(stderr, "'%s' is not a directory, bailing out.\n", - CRONDIR); - exit(ERROR_EXIT); - } - if (chdir(CRONDIR) < OK) { - fprintf(stderr, "cannot chdir(%s), bailing out.\n", CRONDIR); - perror(CRONDIR); - exit(ERROR_EXIT); - } - - /* CRONDIR okay (now==CWD), now look at SPOOL_DIR ("tabs" or some such) - */ - if (stat(SPOOL_DIR, &sb) < OK && errno == ENOENT) { - perror(SPOOL_DIR); - if (OK == mkdir(SPOOL_DIR, 0700)) { - fprintf(stderr, "%s: created\n", SPOOL_DIR); - stat(SPOOL_DIR, &sb); - } else { - fprintf(stderr, "%s: ", SPOOL_DIR); - perror("mkdir"); - exit(ERROR_EXIT); - } - } - if (!(sb.st_mode & S_IFDIR)) { - fprintf(stderr, "'%s' is not a directory, bailing out.\n", - SPOOL_DIR); - exit(ERROR_EXIT); - } -} - - -/* acquire_daemonlock() - write our PID into /etc/cron.pid, unless - * another daemon is already running, which we detect here. - * - * note: main() calls us twice; once before forking, once after. - * we maintain static storage of the file pointer so that we - * can rewrite our PID into the PIDFILE after the fork. - * - * it would be great if fflush() disassociated the file buffer. - */ -void -acquire_daemonlock(closeflag) - int closeflag; -{ - static FILE *fp = NULL; - - if (closeflag && fp) { - fclose(fp); - fp = NULL; - return; - } - - if (!fp) { - char pidfile[MAX_FNAME]; - char buf[MAX_TEMPSTR]; - int fd, otherpid; - - (void) sprintf(pidfile, PIDFILE, PIDDIR); - if ((-1 == (fd = open(pidfile, O_RDWR|O_CREAT, 0644))) - || (NULL == (fp = fdopen(fd, "r+"))) - ) { - sprintf(buf, "can't open or create %s: %s", - pidfile, strerror(errno)); - fprintf(stderr, "%s: %s\n", ProgramName, buf); - log_it("CRON", getpid(), "DEATH", buf); - exit(ERROR_EXIT); - } - - if (flock(fd, LOCK_EX|LOCK_NB) < OK) { - int save_errno = errno; - - fscanf(fp, "%d", &otherpid); - sprintf(buf, "can't lock %s, otherpid may be %d: %s", - pidfile, otherpid, strerror(save_errno)); - fprintf(stderr, "%s: %s\n", ProgramName, buf); - log_it("CRON", getpid(), "DEATH", buf); - exit(ERROR_EXIT); - } - - (void) fcntl(fd, F_SETFD, 1); - } - - rewind(fp); - fprintf(fp, "%d\n", getpid()); - fflush(fp); - (void) ftruncate(fileno(fp), ftell(fp)); - - /* abandon fd and fp even though the file is open. we need to - * keep it open and locked, but we don't need the handles elsewhere. - */ -} - -/* get_char(file) : like getc() but increment LineNumber on newlines - */ -int -get_char(file) - FILE *file; -{ - int ch; - - ch = getc(file); - if (ch == '\n') - Set_LineNum(LineNumber + 1) - return ch; -} - - -/* unget_char(ch, file) : like ungetc but do LineNumber processing - */ -void -unget_char(ch, file) - int ch; - FILE *file; -{ - ungetc(ch, file); - if (ch == '\n') - Set_LineNum(LineNumber - 1) -} - - -/* get_string(str, max, file, termstr) : like fgets() but - * (1) has terminator string which should include \n - * (2) will always leave room for the null - * (3) uses get_char() so LineNumber will be accurate - * (4) returns EOF or terminating character, whichever - */ -int -get_string(string, size, file, terms) - char *string; - int size; - FILE *file; - char *terms; -{ - int ch; - - while (EOF != (ch = get_char(file)) && !strchr(terms, ch)) { - if (size > 1) { - *string++ = (char) ch; - size--; - } - } - - if (size > 0) - *string = '\0'; - - return ch; -} - - -/* skip_comments(file) : read past comment (if any) - */ -void -skip_comments(file) - FILE *file; -{ - int ch; - - while (EOF != (ch = get_char(file))) { - /* ch is now the first character of a line. - */ - - while (ch == ' ' || ch == '\t') - ch = get_char(file); - - if (ch == EOF) - break; - - /* ch is now the first non-blank character of a line. - */ - - if (ch != '\n' && ch != '#') - break; - - /* ch must be a newline or comment as first non-blank - * character on a line. - */ - - while (ch != '\n' && ch != EOF) - ch = get_char(file); - - /* ch is now the newline of a line which we're going to - * ignore. - */ - } - if (ch != EOF) - unget_char(ch, file); -} - - -/* int in_file(char *string, FILE *file) - * return TRUE if one of the lines in file matches string exactly, - * FALSE otherwise. - */ -static int -in_file(string, file) - char *string; - FILE *file; -{ - char line[MAX_TEMPSTR]; - - rewind(file); - while (fgets(line, MAX_TEMPSTR, file)) { - if (line[0] != '\0') - line[strlen(line)-1] = '\0'; - if (0 == strcmp(line, string)) - return TRUE; - } - return FALSE; -} - - -/* int allowed(char *username) - * returns TRUE if (ALLOW_FILE exists and user is listed) - * or (DENY_FILE exists and user is NOT listed) - * or (neither file exists but user=="root" so it's okay) - */ -int -allowed(username) - char *username; -{ - static int init = FALSE; - static FILE *allow, *deny; - - if (!init) { - init = TRUE; -#if defined(ALLOW_FILE) && defined(DENY_FILE) - allow = fopen(ALLOW_FILE, "r"); - deny = fopen(DENY_FILE, "r"); - Debug(DMISC, ("allow/deny enabled, %d/%d\n", !!allow, !!deny)) -#else - allow = NULL; - deny = NULL; -#endif - } - - if (allow) - return (in_file(username, allow)); - if (deny) - return (!in_file(username, deny)); - -#if defined(ALLOW_ONLY_ROOT) - return (strcmp(username, ROOT_USER) == 0); -#else - return TRUE; -#endif -} - - -void -log_it(username, xpid, event, detail) - char *username; - int xpid; - char *event; - char *detail; -{ - PID_T pid = xpid; -#if defined(LOG_FILE) - char *msg; - TIME_T now = time((TIME_T) 0); - register struct tm *t = localtime(&now); -#endif /*LOG_FILE*/ - -#if defined(SYSLOG) - static int syslog_open = 0; -#endif - -#if defined(LOG_FILE) - /* we assume that MAX_TEMPSTR will hold the date, time, &punctuation. - */ - msg = malloc(strlen(username) - + strlen(event) - + strlen(detail) - + MAX_TEMPSTR); - - if (LogFD < OK) { - LogFD = open(LOG_FILE, O_WRONLY|O_APPEND|O_CREAT, 0600); - if (LogFD < OK) { - fprintf(stderr, "%s: can't open log file\n", - ProgramName); - perror(LOG_FILE); - } else { - (void) fcntl(LogFD, F_SETFD, 1); - } - } - - /* we have to sprintf() it because fprintf() doesn't always write - * everything out in one chunk and this has to be atomically appended - * to the log file. - */ - sprintf(msg, "%s (%02d/%02d-%02d:%02d:%02d-%d) %s (%s)\n", - username, - t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, pid, - event, detail); - - /* we have to run strlen() because sprintf() returns (char*) on old BSD - */ - if (LogFD < OK || write(LogFD, msg, strlen(msg)) < OK) { - if (LogFD >= OK) - perror(LOG_FILE); - fprintf(stderr, "%s: can't write to log file\n", ProgramName); - write(STDERR, msg, strlen(msg)); - } - - free(msg); -#endif /*LOG_FILE*/ - -#if defined(SYSLOG) - if (!syslog_open) { - /* we don't use LOG_PID since the pid passed to us by - * our client may not be our own. therefore we want to - * print the pid ourselves. - */ -# ifdef LOG_DAEMON - openlog(ProgramName, LOG_PID, LOG_CRON); -# else - openlog(ProgramName, LOG_PID); -# endif - syslog_open = TRUE; /* assume openlog success */ - } - - syslog(LOG_INFO, "(%s) %s (%s)\n", username, event, detail); - -#endif /*SYSLOG*/ - -#if DEBUGGING - if (DebugFlags) { - fprintf(stderr, "log_it: (%s %d) %s (%s)\n", - username, pid, event, detail); - } -#endif -} - - -void -log_close() { - if (LogFD != ERR) { - close(LogFD); - LogFD = ERR; - } -} - - -/* two warnings: - * (1) this routine is fairly slow - * (2) it returns a pointer to static storage - */ -char * -first_word(s, t) - register char *s; /* string we want the first word of */ - register char *t; /* terminators, implicitly including \0 */ -{ - static char retbuf[2][MAX_TEMPSTR + 1]; /* sure wish C had GC */ - static int retsel = 0; - register char *rb, *rp; - - /* select a return buffer */ - retsel = 1-retsel; - rb = &retbuf[retsel][0]; - rp = rb; - - /* skip any leading terminators */ - while (*s && (NULL != strchr(t, *s))) { - s++; - } - - /* copy until next terminator or full buffer */ - while (*s && (NULL == strchr(t, *s)) && (rp < &rb[MAX_TEMPSTR])) { - *rp++ = *s++; - } - - /* finish the return-string and return it */ - *rp = '\0'; - return rb; -} - - -/* warning: - * heavily ascii-dependent. - */ -void -mkprint(dst, src, len) - register char *dst; - register unsigned char *src; - register int len; -{ - while (len-- > 0) - { - register unsigned char ch = *src++; - - if (ch < ' ') { /* control character */ - *dst++ = '^'; - *dst++ = ch + '@'; - } else if (ch < 0177) { /* printable */ - *dst++ = ch; - } else if (ch == 0177) { /* delete/rubout */ - *dst++ = '^'; - *dst++ = '?'; - } else { /* parity character */ - sprintf(dst, "\\%03o", ch); - dst += 4; - } - } - *dst = '\0'; -} - - -/* warning: - * returns a pointer to malloc'd storage, you must call free yourself. - */ -char * -mkprints(src, len) - register unsigned char *src; - register unsigned int len; -{ - register char *dst = malloc(len*4 + 1); - - mkprint(dst, src, len); - - return dst; -} - - -#ifdef MAIL_DATE -/* Sat, 27 Feb 93 11:44:51 CST - * 123456789012345678901234567 - */ -char * -arpadate(clock) - time_t *clock; -{ - time_t t = clock ?*clock :time(0L); - struct tm *tm = localtime(&t); - static char ret[30]; /* zone name might be >3 chars */ - - (void) sprintf(ret, "%s, %2d %s %2d %02d:%02d:%02d %s", - DowNames[tm->tm_wday], - tm->tm_mday, - MonthNames[tm->tm_mon], - tm->tm_year, - tm->tm_hour, - tm->tm_min, - tm->tm_sec, - TZONE(*tm)); - return ret; -} -#endif /*MAIL_DATE*/ - - -#ifdef HAVE_SAVED_SUIDS -static int save_euid; -int swap_uids() { save_euid = geteuid(); return seteuid(getuid()); } -int swap_uids_back() { return seteuid(save_euid); } -#else /*HAVE_SAVED_UIDS*/ -int swap_uids() { return setreuid(geteuid(), getuid()); } -int swap_uids_back() { return swap_uids(); } -#endif /*HAVE_SAVED_UIDS*/ diff --git a/libexec/cron/pathnames.h b/libexec/cron/pathnames.h deleted file mode 100644 index 0462a0425484..000000000000 --- a/libexec/cron/pathnames.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright 1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie uunet!decwrl!vixie!paul - */ - -/* - * $Id: pathnames.h,v 1.1.1.2 1994/01/12 18:37:56 jtc Exp $ - */ - -#if (defined(BSD)) && (BSD >= 199103) || defined(__linux) || defined(AIX) -# include -#endif /*BSD*/ - -#ifndef CRONDIR - /* CRONDIR is where crond(8) and crontab(1) both chdir - * to; SPOOL_DIR, ALLOW_FILE, DENY_FILE, and LOG_FILE - * are all relative to this directory. - */ -#define CRONDIR "/var/cron" -#endif - - /* SPOOLDIR is where the crontabs live. - * This directory will have its modtime updated - * whenever crontab(1) changes a crontab; this is - * the signal for crond(8) to look at each individual - * crontab file and reload those whose modtimes are - * newer than they were last time around (or which - * didn't exist last time around...) - */ -#define SPOOL_DIR "tabs" - - /* undefining these turns off their features. note - * that ALLOW_FILE and DENY_FILE must both be defined - * in order to enable the allow/deny code. If neither - * LOG_FILE or SYSLOG is defined, we don't log. If - * both are defined, we log both ways. - */ -#define ALLOW_FILE "allow" /*-*/ -#define DENY_FILE "deny" /*-*/ -#define LOG_FILE "log" /*-*/ - - /* where should the daemon stick its PID? - */ -#ifdef _PATH_VARRUN -# define PIDDIR _PATH_VARRUN -#else -# define PIDDIR "/etc/" -#endif -#define PIDFILE "%scron.pid" - - /* 4.3BSD-style crontab */ -#define SYSCRONTAB "/etc/crontab" - - /* what editor to use if no EDITOR or VISUAL - * environment variable specified. - */ -#if defined(_PATH_VI) -# define EDITOR _PATH_VI -#else -# define EDITOR "/usr/ucb/vi" -#endif - -#ifndef _PATH_BSHELL -# define _PATH_BSHELL "/bin/sh" -#endif - -#ifndef _PATH_DEFPATH -# define _PATH_DEFPATH "/usr/bin:/bin" -#endif diff --git a/libexec/cron/popen.c b/libexec/cron/popen.c deleted file mode 100644 index 1035a5b06fdc..000000000000 --- a/libexec/cron/popen.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 1988 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software written by Ken Arnold and - * published in UNIX Review, Vol. 6, No. 8. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - */ - -/* this came out of the ftpd sources; it's been modified to avoid the - * globbing stuff since we don't need it. also execvp instead of execv. - */ - -#ifndef lint -static char rcsid[] = "$Id: popen.c,v 1.1.1.2 1994/01/12 18:38:01 jtc Exp $"; -static char sccsid[] = "@(#)popen.c 5.7 (Berkeley) 2/14/89"; -#endif /* not lint */ - -#include "cron.h" -#include - - -#define WANT_GLOBBING 0 - -/* - * Special version of popen which avoids call to shell. This insures noone - * may create a pipe to a hidden program as a side effect of a list or dir - * command. - */ -static PID_T *pids; -static int fds; - -FILE * -cron_popen(program, type) - char *program, *type; -{ - register char *cp; - FILE *iop; - int argc, pdes[2]; - PID_T pid; - char *argv[100]; -#if WANT_GLOBBING - char **pop, *vv[2]; - int gargc; - char *gargv[1000]; - extern char **glob(), **copyblk(); -#endif - - if (*type != 'r' && *type != 'w' || type[1]) - return(NULL); - - if (!pids) { - if ((fds = getdtablesize()) <= 0) - return(NULL); - if (!(pids = (PID_T *)malloc((u_int)(fds * sizeof(PID_T))))) - return(NULL); - bzero((char *)pids, fds * sizeof(PID_T)); - } - if (pipe(pdes) < 0) - return(NULL); - - /* break up string into pieces */ - for (argc = 0, cp = program;; cp = NULL) - if (!(argv[argc++] = strtok(cp, " \t\n"))) - break; - -#if WANT_GLOBBING - /* glob each piece */ - gargv[0] = argv[0]; - for (gargc = argc = 1; argv[argc]; argc++) { - if (!(pop = glob(argv[argc]))) { /* globbing failed */ - vv[0] = argv[argc]; - vv[1] = NULL; - pop = copyblk(vv); - } - argv[argc] = (char *)pop; /* save to free later */ - while (*pop && gargc < 1000) - gargv[gargc++] = *pop++; - } - gargv[gargc] = NULL; -#endif - - iop = NULL; - switch(pid = vfork()) { - case -1: /* error */ - (void)close(pdes[0]); - (void)close(pdes[1]); - goto pfree; - /* NOTREACHED */ - case 0: /* child */ - if (*type == 'r') { - if (pdes[1] != 1) { - dup2(pdes[1], 1); - dup2(pdes[1], 2); /* stderr, too! */ - (void)close(pdes[1]); - } - (void)close(pdes[0]); - } else { - if (pdes[0] != 0) { - dup2(pdes[0], 0); - (void)close(pdes[0]); - } - (void)close(pdes[1]); - } -#if WANT_GLOBBING - execvp(gargv[0], gargv); -#else - execvp(argv[0], argv); -#endif - _exit(1); - } - /* parent; assume fdopen can't fail... */ - if (*type == 'r') { - iop = fdopen(pdes[0], type); - (void)close(pdes[1]); - } else { - iop = fdopen(pdes[1], type); - (void)close(pdes[0]); - } - pids[fileno(iop)] = pid; - -pfree: -#if WANT_GLOBBING - for (argc = 1; argv[argc] != NULL; argc++) { -/* blkfree((char **)argv[argc]); */ - free((char *)argv[argc]); - } -#endif - return(iop); -} - -int -cron_pclose(iop) - FILE *iop; -{ - register int fdes; - int omask; - WAIT_T stat_loc; - PID_T pid; - - /* - * pclose returns -1 if stream is not associated with a - * `popened' command, or, if already `pclosed'. - */ - if (pids == 0 || pids[fdes = fileno(iop)] == 0) - return(-1); - (void)fclose(iop); - omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP)); - while ((pid = wait(&stat_loc)) != pids[fdes] && pid != -1) - ; - (void)sigsetmask(omask); - pids[fdes] = 0; - return (pid == -1 ? -1 : WEXITSTATUS(stat_loc)); -} diff --git a/libexec/cron/user.c b/libexec/cron/user.c deleted file mode 100644 index 83074e5c84e7..000000000000 --- a/libexec/cron/user.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright 1988,1990,1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie uunet!decwrl!vixie!paul - */ - -#if !defined(lint) && !defined(LINT) -static char rcsid[] = "$Id: user.c,v 1.1.1.3 1994/01/12 18:38:09 jtc Exp $"; -#endif - -/* vix 26jan87 [log is in RCS file] - */ - - -#include "cron.h" - - -void -free_user(u) - user *u; -{ - entry *e, *ne; - - free(u->name); - for (e = u->crontab; e != NULL; e = ne) { - ne = e->next; - free_entry(e); - } - free(u); -} - - -user * -load_user(crontab_fd, pw, name) - int crontab_fd; - struct passwd *pw; /* NULL implies syscrontab */ - char *name; -{ - char envstr[MAX_ENVSTR]; - FILE *file; - user *u; - entry *e; - int status; - char **envp; - - if (!(file = fdopen(crontab_fd, "r"))) { - perror("fdopen on crontab_fd in load_user"); - return NULL; - } - - Debug(DPARS, ("load_user()\n")) - - /* file is open. build user entry, then read the crontab file. - */ - u = (user *) malloc(sizeof(user)); - u->name = strdup(name); - u->crontab = NULL; - - /* - * init environment. this will be copied/augmented for each entry. - */ - envp = env_init(); - - /* - * load the crontab - */ - while ((status = load_env(envstr, file)) >= OK) { - switch (status) { - case ERR: - free_user(u); - u = NULL; - goto done; - case FALSE: - e = load_entry(file, NULL, pw, envp); - if (e) { - e->next = u->crontab; - u->crontab = e; - } - break; - case TRUE: - envp = env_set(envp, envstr); - break; - } - } - - done: - env_free(envp); - fclose(file); - Debug(DPARS, ("...load_user() done\n")) - return u; -} diff --git a/libexec/crond/Makefile.vixie b/libexec/crond/Makefile.vixie deleted file mode 100644 index c9dd0d7bc755..000000000000 --- a/libexec/crond/Makefile.vixie +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright 1988,1990,1993 by Paul Vixie -# All rights reserved -# -# Distribute freely, except: don't remove my name from the source or -# documentation (don't take credit for my work), mark your changes (don't -# get me blamed for your possible bugs), don't alter or remove this -# notice. May be sold if buildable source is provided to buyer. No -# warrantee of any kind, express or implied, is included with this -# software; use at your own risk, responsibility for damages (if any) to -# anyone resulting from the use of this software rests entirely with the -# user. -# -# Send bug reports, bug fixes, enhancements, requests, flames, etc., and -# I'll try to keep a version up to date. I can be reached as follows: -# paul@vix.com || {hoptoad,pacbell,decwrl}!vixie!paul -# -# $Id: Makefile.vixie,v 1.3 1993/08/02 17:50:19 mycroft Exp $ - -# NOTES: -# 'make' can be done by anyone -# 'make install' must be done by root -# -# this package needs getopt(3), bitstring(3), and BSD install(8). -# -# the configurable stuff in this makefile consists of compilation -# options (use -O, cron runs forever) and destination directories. -# SHELL is for the 'augumented make' systems where 'make' imports -# SHELL from the environment and then uses it to run its commands. -# if your environment SHELL variable is /bin/csh, make goes real -# slow and sometimes does the wrong thing. -# -# this package needs the 'bitstring macros' library, which is -# available from me or from the comp.sources.unix archive. if you -# put 'bitstring.h' in a non-standard place (i.e., not intuited by -# cc(1)), you will have to define INCLUDE to set the include -# directory for cc. INCLUDE should be `-Isomethingorother'. -# -# there's more configuration info in config.h; edit that first! - -#################################### begin configurable stuff -#<> -DESTROOT = $(DESTDIR)/usr/local -#<> -CRONDIR = /var/cron -#<> -INCLUDE = -I. -#INCLUDE = -#<> -#LIBS = /usr/local/lib/getopt.o -LIBS = -#<> -#OPTIM = -O -OPTIM = -g -#<> -DEBUGGING = -DDEBUGGING=1 -#DEBUGGING = -DDEBUGGING=0 -#<> -# (ATT untested) -#COMPAT = -DATT -COMPAT = -DBSD -#<> -LINTFLAGS = -hbxa $(INCLUDE) $(COMPAT) $(DEBUGGING) -#<> -#CC = vcc -#<> -DEFS = '-DCRONDIR="$(CRONDIR)"' -#################################### end configurable stuff - -SHELL = /bin/sh -CFLAGS = $(OPTIM) $(INCLUDE) $(COMPAT) $(DEBUGGING) $(DEFS) - -INFOS = README CHANGES.V2 FEATURES INSTALL CONVERSION THANKS -MANPAGES = bitstring.3 crontab.5 crontab.1 crond.8 -HEADERS = bitstring.h cron.h config.h -SOURCES = crond.c crontab.c database.c do_command.c \ - entry.c env.c job.c misc.c user.c arpadate.c -SHAR_SOURCE = $(INFOS) $(MANPAGES) Makefile $(HEADERS) $(SOURCES) -LINT_CROND = crond.c database.c user.c entry.c \ - misc.c job.c do_command.c env.c arpadate.c -LINT_CRONTAB = crontab.c misc.c entry.c env.c -CRON_OBJ = crond.o database.o user.o entry.o \ - misc.o job.o do_command.o env.o -CRONTAB_OBJ = crontab.o misc.o entry.o env.o - -all : crond crontab - -lint : - lint $(LINTFLAGS) $(LINT_CROND) $(LIBS) \ - |grep -v "constant argument to NOT" 2>&1 - lint $(LINTFLAGS) $(LINT_CRONTAB) $(LIBS) \ - |grep -v "constant argument to NOT" 2>&1 - -crond : $(CRON_OBJ) - $(CC) -o crond $(CRON_OBJ) $(LIBS) - -crontab : $(CRONTAB_OBJ) - $(CC) -o crontab $(CRONTAB_OBJ) $(LIBS) - -install : all - install -c -m 111 -o root -s crond $(DESTROOT)/etc/ - install -c -m 4111 -o root -s crontab $(DESTROOT)/bin/ - install -c crontab.1 $(DESTROOT)/man/man1/crontab.1 - install -c crond.8 $(DESTROOT)/man/man8/crond.8 - install -c crontab.5 $(DESTROOT)/man/man5/crontab.5 - -clean :; rm -f *.o crond crontab a.out core tags *~ #* - -kit : $(SHAR_SOURCE) - makekit -m -s50k $(SHAR_SOURCE) - -$(CRON_OBJ) : cron.h config.h Makefile -$(CRONTAB_OBJ) : cron.h config.h Makefile diff --git a/libexec/crond/README b/libexec/crond/README deleted file mode 100644 index ca7915bc3123..000000000000 --- a/libexec/crond/README +++ /dev/null @@ -1,96 +0,0 @@ -Vixie's Cron V3.0 -May 29, 1993 -[V2.1 was May 29, 1991] -[V2.0 was July 5, 1990] -[V2.0-beta was December 9, 1988] -[V1.0 was May 6, 1987] -Paul Vixie - -This is a version of 'cron' that is known to run on BSD 4.x systems. It is -functionally based on the SysV cron, which means that each user can have -their own crontab file (all crontab files are stored in a read-protected -directory, usually /var/cron/tabs). No direct support is provided for 'at'; -you can continue to run 'atrun' from the crontab as you have been doing. If -you don't have atrun (i.e., System V) you might be in trouble. (I don't use -'at' myself so I don't care.) - -A message is logged each time a command is executed; also, the files "allow" -and "deny" in /var/cron can be used to control access to the "crontab" -command (which installs crontabs). It hasn't been tested on SysV, although -some effort has gone into making the port an easy one. - -The code was all written by me, and is (quoted from Makefile): - -#/* Copyright 1988,1990,1991,1993 by Paul Vixie -# * All rights reserved -# * -# * Distribute freely, except: don't remove my name from the source or -# * documentation (don't take credit for my work), mark your changes (don't -# * get me blamed for your possible bugs), don't alter or remove this -# * notice. May be sold if buildable source is provided to buyer. No -# * warrantee of any kind, express or implied, is included with this -# * software; use at your own risk, responsibility for damages (if any) to -# * anyone resulting from the use of this software rests entirely with the -# * user. -# * -# * Send bug reports, bug fixes, enhancements, requests, flames, etc., and -# * I'll try to keep a version up to date. I can be reached as follows: -# * paul@vix.com || {hoptoad,pacbell,decwrl}!vixie!paul -# */ - -This is more or less the copyright that USENET contributed software usually -has. Since ATT couldn't use this version if they had to freely distribute -source, and since I'd love to see them use it, I'll offer some ridiculously -low license fee just to have them take it. In the unlikely event that they -do this, I will continue to support and distribute the pseudo-PD version, so -please, don't flame me for wanting my work to see a wider distribution. - -This version of cron has appeared in BSD 4.4, BSD/386, 386BSD, and Linux. - -To use this: Sorry, folks, there is no cutesy 'Configure' script. You'll -have to go edit a couple of files... So, here's the checklist: - - Read all the FEATURES, INSTALL, and CONVERSION files - Edit Makefile - Edit config.h - (both of these files have instructions inside; note that - some things in config.h are definable in Makefile and are - therefore surrounded by #ifndef...#endif) - 'make' - 'su' and 'make install' - (you may have to install the man pages by hand) - kill your existing cron process - (actually you can run your existing cron if you want, but why?) - build new crontabs using /usr/lib/{crontab,crontab.local} - (either put them all in "root"'s crontab, or divide it up - and rip out all the 'su' commands, collapse the lengthy - lists into ranges with steps -- basically, this step is - as much work as you want to make it) - start up the new cron - (must be done as root) - watch it. test it with 'crontab -r' and watch the daemon track your - changes. - if you like it, change your /etc/{rc,rc.local} to use it instead of - the old one. - -$Header: /cvsroot/src/libexec/crond/Attic/README,v 1.2 1993/05/28 08:34:05 cgd Exp $ -$Source: /cvsroot/src/libexec/crond/Attic/README,v $ -$Revision: 1.2 $ -$Log: README,v $ -Revision 1.2 1993/05/28 08:34:05 cgd -update for newest version of vixie's cron, as of May 27 1993 - -Revision 2.2 1991/05/29 11:37:38 vixie -vixie - -Revision 2.1 90/07/18 00:23:54 vixie -Baseline for 4.4BSD release - -Revision 2.0 88/12/10 04:57:50 vixie -V2 Beta - -Revision 1.2 87/07/10 11:36:45 paul -misc - -Revision 1.1 87/07/10 11:15:05 paul -Initial revision diff --git a/libexec/crond/THANKS b/libexec/crond/THANKS deleted file mode 100644 index 3787c2943d7a..000000000000 --- a/libexec/crond/THANKS +++ /dev/null @@ -1,29 +0,0 @@ -15 January 1990 -Paul Vixie - -Many people have contributed to cron. Many more than I can remember, in fact. -Rich Salz and Carl Gutekunst were each of enormous help to me in V1; Carl for -helping me understand UNIX well enough to write it, and Rich for helping me -get the features right. - -John Gilmore wrote me a wonderful review of V2, which took me a whole year to -answer even though it made me clean up some really awful things in the code. -(According to John the most awful things are still in here, of course.) - -Paul Close made a suggestion which led to /etc/crond.pid and the mutex locking -on it. Kevin Braunsdorf of Purdue made a suggestion that led to @reboot and -its brothers and sisters; he also sent some diffs that lead cron toward compil- -ability with System V, though without at(1) capabilities, this cron isn't going -to be that useful on System V. Bob Alverson fixed a silly bug in the line -number counting. Brian Reid made suggestions which led to the run queue and -the source-file labelling in installed crontabs. - -Scott Narveson ported V2 to a Sequent, and sent in the most useful single batch -of diffs I got from anybody. Changes attributable to Scott are: - -> sendmail won't time out if the command is slow to generate output - -> day-of-week names aren't off by one anymore - -> crontab says the right thing if you do something you shouldn't do - -> crontab(5) man page is longer and more informative - -> misc changes related to the side effects of fclose() - -> Sequent "universe" support added (may also help on Pyramids) - -> null pw_shell is dealt with now; default is /bin/sh diff --git a/libexec/crond/arpadate.c b/libexec/crond/arpadate.c deleted file mode 100644 index 3e164133eb9a..000000000000 --- a/libexec/crond/arpadate.c +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef lint -static char rcsid[] = "$Id: arpadate.c,v 1.2 1993/08/02 17:50:20 mycroft Exp $"; -#endif /* not lint */ - -#include - -#include "cron.h" - -/* Sat, 27 Feb 93 11:44:51 CST - * 123456789012345678901234567 - */ - -char * -arpadate( - time_t *clock -) { - time_t t = clock ?*clock :time(); - struct tm *tm = localtime(&t); - static char ret[30]; /* zone name might be >3 chars */ - - (void) sprintf(ret, "%s, %2d %s %2d %02d:%02d:%02d %s", - DowNames[tm->tm_wday], - tm->tm_mday, - MonthNames[tm->tm_mon], - tm->tm_year, - tm->tm_hour, - tm->tm_min, - tm->tm_sec, - tm->tm_zone); - return ret; -} diff --git a/libexec/crond/config.h b/libexec/crond/config.h deleted file mode 100644 index c2c73b5757bb..000000000000 --- a/libexec/crond/config.h +++ /dev/null @@ -1,158 +0,0 @@ -/* Copyright 1988,1990,1993 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie, 329 Noe Street, San Francisco, CA, 94114, (415) 864-7013, - * paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl,crash}!vixie!paul - * - * $Id: config.h,v 1.5 1993/08/02 17:50:20 mycroft Exp $ - */ - -#ifndef _CONFIG_FLAG -#define _CONFIG_FLAG - -#if defined(BSD) -# define OLDBSD BSD -# undef BSD -# include -# if !defined(BSD) -# define BSD OLDBSD -# endif /*BSD*/ -# undef OLDBSD -#endif /*BSD*/ - -#if (defined(BSD)) && (BSD >= 199103) -# include -#endif /*BSD*/ - -#if !defined(_PATH_SENDMAIL) -# define _PATH_SENDMAIL "/usr/lib/sendmail" -#endif /*SENDMAIL*/ - -/* - * these are site-dependent - */ - /* - * choose one of these MAILCMD commands. I use - * /bin/mail for speed; it makes biff bark but doesn't - * do aliasing. /usr/lib/sendmail does aliasing but is - * a hog for short messages. aliasing is not needed - * if you make use of the MAILTO= feature in crontabs. - * (hint: MAILTO= was added for this reason). - */ - -#define MAILCMD _PATH_SENDMAIL /*-*/ -#define MAILARGS "%s -F\"Cron Daemon\" -odi -oem -or0s -t" /*-*/ - /* -Fx = set full-name of sender - * -odi = Option Deliverymode Interactive - * -oem = Option Errors Mailedtosender - * -or0s = Option Readtimeout -- don't time out - * -t = recipients are in To: headers - */ - -/* #define MAILCMD "/bin/mail" /*-*/ -/* #define MAILARGS "%s -d \"%s\"" /*-*/ - /* -d = undocumented but common flag: deliver locally? - */ - -/* #define MAIL_DATE /*-*/ - /* should we include an ersatz Date: header in - * generated mail? if you are using sendmail - * for MAILCMD, it is better to let sendmail - * generate the Date: header. - */ - -#ifndef CRONDIR - /* CRONDIR is where crond(8) and crontab(1) both chdir - * to; SPOOL_DIR, ALLOW_FILE, DENY_FILE, and LOG_FILE - * are all relative to this directory. - * - * this can and should be set in the Makefile. - */ -# define CRONDIR "/var/cron" -#endif - - /* SPOOLDIR is where the crontabs live. - * This directory will have its modtime updated - * whenever crontab(1) changes a crontab; this is - * the signal for crond(8) to look at each individual - * crontab file and reload those whose modtimes are - * newer than they were last time around (or which - * didn't exist last time around...) - */ -#define SPOOL_DIR "tabs" - - /* undefining these turns off their features. note - * that ALLOW_FILE and DENY_FILE must both be defined - * in order to enable the allow/deny code. If neither - * LOG_FILE or SYSLOG is defined, we don't log. If - * both are defined, we log both ways. - */ -#define ALLOW_FILE "allow" /*-*/ -#define DENY_FILE "deny" /*-*/ -/*#define LOG_FILE "log" /*-*/ - - /* if ALLOW_FILE and DENY_FILE are not defined or are - * defined but neither exists, should crontab(1) be - * usable only by root? - */ -/*#define ALLOW_ONLY_ROOT /*-*/ - - /* if you want to use syslog(3) instead of appending - * to CRONDIR/LOG_FILE (/var/cron/log, e.g.), define - * SYSLOG here. Note that quite a bit of logging - * info is written, and that you probably don't want - * to use this on 4.2bsd since everything goes in - * /usr/spool/mqueue/syslog. On 4.[34]bsd you can - * tell /etc/syslog.conf to send cron's logging to - * a separate file. - */ -#define SYSLOG /*-*/ - - /* this is the name of the environment variable - * that contains the user name. it isn't read by - * cron, but it is SET by crond in the environments - * it creates for subprocesses. on BSD, it will - * always be USER; on SysV it could be LOGNAME or - * something else. - */ -#if defined(BSD) -# define USERENV "USER" -#endif -#if defined(ATT) -# define USERENV "LOGNAME" -#endif - - /* where should the daemon stick its PID? - */ -#ifdef _PATH_VARRUN -# define PIDDIR _PATH_VARRUN -#else -# define PIDDIR "/etc/" -#endif -#if defined(BSD) && (BSD > 199103) -# define PIDFILE "%scron.pid" -#else -# define PIDFILE "%scrond.pid" -#endif - - /* what editor to use if no EDITOR or VISUAL - * environment variable specified. - */ -#if defined(_PATH_VI) -# define EDITOR _PATH_VI -#else -# define EDITOR "/usr/ucb/vi" -#endif - -#endif /*CONFIG_FLAG*/ diff --git a/libexec/crond/cron.h b/libexec/crond/cron.h deleted file mode 100644 index 2ea143a665a8..000000000000 --- a/libexec/crond/cron.h +++ /dev/null @@ -1,237 +0,0 @@ -/* cron.h - header for vixie's cron - * - * Copyright 1988,1990,1993 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie, 329 Noe Street, San Francisco, CA, 94114, (415) 864-7013, - * paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl,crash}!vixie!paul - */ - -#ifndef _CRON_FLAG -#define _CRON_FLAG - -#include -#include -#include -#include -#include - -#include "config.h" - - /* these are really immutable, and are - * defined for symbolic convenience only - * TRUE, FALSE, and ERR must be distinct - */ -#define TRUE 1 -#define FALSE 0 - /* system calls return this on success */ -#define OK 0 - /* or this on error */ -#define ERR (-1) - - /* meaningless cookie for smart compilers that will pick their - * own register variables; this makes the code neater. - */ -#define local /**/ - - /* turn this on to get '-x' code */ -#ifndef DEBUGGING -#define DEBUGGING FALSE -#endif - -#define READ_PIPE 0 /* which end of a pipe pair do you read? */ -#define WRITE_PIPE 1 /* or write to? */ -#define STDIN 0 /* what is stdin's file descriptor? */ -#define STDOUT 1 /* stdout's? */ -#define STDERR 2 /* stderr's? */ -#define ERROR_EXIT 1 /* exit() with this will scare the shell */ -#define OK_EXIT 0 /* exit() with this is considered 'normal' */ -#define MAX_FNAME 100 /* max length of internally generated fn */ -#define MAX_COMMAND 1000 /* max length of internally generated cmd */ -#define MAX_ENVSTR 1000 /* max length of envvar=value\0 strings */ -#define MAX_TEMPSTR 100 /* obvious */ -#define MAX_UNAME 20 /* max length of username, should be overkill */ -#define ROOT_UID 0 /* don't change this, it really must be root */ -#define ROOT_USER "root" /* ditto */ - - /* NOTE: these correspond to DebugFlagNames, - * defined below. - */ -#define DEXT 0x0001 /* extend flag for other debug masks */ -#define DSCH 0x0002 /* scheduling debug mask */ -#define DPROC 0x0004 /* process control debug mask */ -#define DPARS 0x0008 /* parsing debug mask */ -#define DLOAD 0x0010 /* database loading debug mask */ -#define DMISC 0x0020 /* misc debug mask */ -#define DTEST 0x0040 /* test mode: don't execute any commands */ - - /* the code does not depend on any of vfork's - * side-effects; it just uses it as a quick - * fork-and-exec. - */ -#if defined(BSD) -# define VFORK vfork -#endif -#if defined(ATT) -# define VFORK fork -#endif - -#define CRON_TAB(u) "%s/%s", SPOOL_DIR, u -#define REG register -#define PPC_NULL ((char **)NULL) - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -#define Skip_Blanks(c, f) \ - while (c == '\t' || c == ' ') \ - c = get_char(f); - -#define Skip_Nonblanks(c, f) \ - while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \ - c = get_char(f); - -#define Skip_Line(c, f) \ - do {c = get_char(f);} while (c != '\n' && c != EOF); - -#if DEBUGGING -# define Debug(mask, message) \ - if ( (DebugFlags & (mask) ) == (mask) ) \ - printf message; -#else /* !DEBUGGING */ -# define Debug(mask, message) \ - ; -#endif /* DEBUGGING */ - -#define MkLower(ch) (isupper(ch) ? tolower(ch) : ch) -#define MkUpper(ch) (islower(ch) ? toupper(ch) : ch) -#define Set_LineNum(ln) {Debug(DPARS|DEXT,("linenum=%d\n",ln)); \ - LineNumber = ln; \ - } - -#define FIRST_MINUTE 0 -#define LAST_MINUTE 59 -#define MINUTE_COUNT (LAST_MINUTE - FIRST_MINUTE + 1) - -#define FIRST_HOUR 0 -#define LAST_HOUR 23 -#define HOUR_COUNT (LAST_HOUR - FIRST_HOUR + 1) - -#define FIRST_DOM 1 -#define LAST_DOM 31 -#define DOM_COUNT (LAST_DOM - FIRST_DOM + 1) - -#define FIRST_MONTH 1 -#define LAST_MONTH 12 -#define MONTH_COUNT (LAST_MONTH - FIRST_MONTH + 1) - -/* note on DOW: 0 and 7 are both Sunday, for compatibility reasons. */ -#define FIRST_DOW 0 -#define LAST_DOW 7 -#define DOW_COUNT (LAST_DOW - FIRST_DOW + 1) - - /* each user's crontab will be held as a list of - * the following structure. - * - * These are the cron commands. - */ - -typedef struct _entry - { - struct _entry *next; - char *cmd; - bitstr_t bit_decl(minute, MINUTE_COUNT); - bitstr_t bit_decl(hour, HOUR_COUNT); - bitstr_t bit_decl(dom, DOM_COUNT); - bitstr_t bit_decl(month, MONTH_COUNT); - bitstr_t bit_decl(dow, DOW_COUNT); - int flags; -# define DOM_STAR 0x1 -# define DOW_STAR 0x2 -# define WHEN_REBOOT 0x4 - } - entry; - - /* the crontab database will be a list of the - * following structure, one element per user. - * - * These are the crontabs. - */ - -typedef struct _user - { - struct _user *next, *prev; /* links */ - uid_t uid; /* uid from passwd file */ - gid_t gid; /* gid from passwd file */ - char **envp; /* environ for commands */ - time_t mtime; /* last modtime of crontab */ - entry *crontab; /* this person's crontab */ - } - user; - -typedef struct _cron_db - { - user *head, *tail; /* links */ - time_t mtime; /* last modtime on spooldir */ - } - cron_db; - - /* in the C tradition, we only create - * variables for the main program, just - * extern them elsewhere. - */ - -#ifdef MAIN_PROGRAM - -# if !defined(LINT) && !defined(lint) - static char *copyright[] = { - "@(#) Copyright (C) 1988, 1989, 1990 by Paul Vixie", - "@(#) All rights reserved" - }; -# endif - - char *MonthNames[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", - NULL}; - char *DowNames[] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", - NULL}; - char *ProgramName; - int LineNumber; - time_t TargetTime; - -# if DEBUGGING - int DebugFlags; - char *DebugFlagNames[] = { /* sync with #defines */ - "ext", "sch", "proc", "pars", "load", "misc", "test", - NULL}; /* NULL must be last element */ -# endif /* DEBUGGING */ - -#else /* !MAIN_PROGRAM */ - - extern char *MonthNames[]; - extern char *DowNames[]; - extern char *ProgramName; - extern int LineNumber; - extern time_t TargetTime; -# if DEBUGGING - extern int DebugFlags; - extern char *DebugFlagNames[]; -# endif /* DEBUGGING */ -#endif /* MAIN_PROGRAM */ - - -#endif /* _CRON_FLAG */ diff --git a/libexec/crond/crond.8 b/libexec/crond/crond.8 deleted file mode 100644 index 7c7dd632e7d2..000000000000 --- a/libexec/crond/crond.8 +++ /dev/null @@ -1,58 +0,0 @@ -.\" -*- nroff -*- -.\" -.\" Copyright 1988,1990 by Paul Vixie -.\" All rights reserved -.\" -.\" Distribute freely, except: don't remove my name from the source or -.\" documentation (don't take credit for my work), mark your changes (don't -.\" get me blamed for your possible bugs), don't alter or remove this -.\" notice. May be sold if buildable source is provided to buyer. No -.\" warrantee of any kind, express or implied, is included with this -.\" software; use at your own risk, responsibility for damages (if any) to -.\" anyone resulting from the use of this software rests entirely with the -.\" user. -.\" -.\" Send bug reports, bug fixes, enhancements, requests, flames, etc., and -.\" I'll try to keep a version up to date. I can be reached as follows: -.\" Paul Vixie, 329 Noe Street, San Francisco, CA, 94114, (415) 864-7013, -.\" paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl,crash}!vixie!paul -.\" -.\" $Id: crond.8,v 1.3 1993/08/02 17:50:21 mycroft Exp $ -.\" -.TH CROND 8 "15 Nov 1988" -.UC 4 -.SH NAME -crond \- daemon to execute scheduled commands (Vixie Cron) -.SH SYNOPSIS -crond -.SH DESCRIPTION -.I Crond -should be started from /etc/rc or /etc/rc.local. It will return immediately, -so you don't need to start it with '&'. -.PP -.I Crond -searches /var/cron/tabs for crontab files which are named after accounts in -/etc/passwd; crontabs found are loaded into memory. -.I Crond -then wakes up every minute, examining all stored crontabs, checking each -command to see if it should be run in the current minute. When executing -commands, any output is mailed to the owner of the crontab (or to the user -named in the MAILTO environment variable in the crontab, if such exists). -.PP -Additionally, -.I crond -checks each minute to see if its spool directory's modtime has changed, and -if it has, -.I crond -will then examine the modtime on all crontabs and reload those which have -changed. Thus -.I crond -need not be restarted whenever a crontab file is modified. Note that the -.IR Crontab (1) -command updates the modtime of the spool directory whenever it changes a -crontab. -.SH "SEE ALSO" -crontab(1), crontab(5) -.SH AUTHOR -.nf -Paul Vixie, paul@vixie.sf.ca.us diff --git a/libexec/crond/crond.c b/libexec/crond/crond.c deleted file mode 100644 index da616d3137f2..000000000000 --- a/libexec/crond/crond.c +++ /dev/null @@ -1,309 +0,0 @@ -/* Copyright 1988,1990 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie, 329 Noe Street, San Francisco, CA, 94114, (415) 864-7013, - * paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl,crash}!vixie!paul - */ - -#ifndef lint -static char rcsid[] = "$Id: crond.c,v 1.5 1993/09/17 03:46:44 cgd Exp $"; -#endif /* not lint */ - - -#define MAIN_PROGRAM - - -#include "cron.h" -#include -#include -#include -#if defined(BSD) -# include -# include -#endif /*BSD*/ - -/*extern int fprintf(), fork(), unlink(); -extern time_t time(); -extern void exit(); -extern unsigned sleep();*/ - -void -usage() -{ - (void) fprintf(stderr, "usage: %s [-x debugflag[,...]]\n", ProgramName); - (void) exit(ERROR_EXIT); -} - - -int -main(argc, argv) - int argc; - char *argv[]; -{ - extern void set_cron_uid(), be_different(), load_database(), - set_cron_cwd(), open_logfile(); - - static void cron_tick(), cron_sleep(), cron_sync(), - sigchld_handler(), parse_args(), run_reboot_jobs(); - - auto cron_db database; - - ProgramName = argv[0]; - -#if defined(BSD) - setlinebuf(stdout); - setlinebuf(stderr); -#endif - - parse_args(argc, argv); - -# if DEBUGGING - /* if there are no debug flags turned on, fork as a daemon should. - */ - if (DebugFlags) - { - (void) fprintf(stderr, "[%d] crond started\n", getpid()); - } - else -# endif /*DEBUGGING*/ - { - switch (fork()) - { - case -1: - log_it("CROND",getpid(),"DEATH","can't fork"); - exit(0); - break; - case 0: - /* child process */ - be_different(); - break; - default: - /* parent process should just die */ - _exit(0); - } - } - -#if defined(BSD) - (void) signal(SIGCHLD, sigchld_handler); -#endif /*BSD*/ - -#if defined(ATT) - (void) signal(SIGCLD, SIG_IGN); -#endif /*ATT*/ - - acquire_daemonlock(); - set_cron_uid(); - set_cron_cwd(); - database.head = NULL; - database.tail = NULL; - database.mtime = (time_t) 0; - load_database(&database); - run_reboot_jobs(&database); - cron_sync(); - while (TRUE) - { -# if DEBUGGING - if (!(DebugFlags & DTEST)) -# endif /*DEBUGGING*/ - cron_sleep(); - - load_database(&database); - - /* do this iteration - */ - cron_tick(&database); - - /* sleep 1 minute - */ - TargetTime += 60; - } -} - - -static void -run_reboot_jobs(db) - cron_db *db; -{ - extern void job_add(); - extern int job_runqueue(); - register user *u; - register entry *e; - - for (u = db->head; u != NULL; u = u->next) { - for (e = u->crontab; e != NULL; e = e->next) { - if (e->flags & WHEN_REBOOT) { - job_add(e->cmd, u); - } - } - } - (void) job_runqueue(); -} - - -static void -cron_tick(db) - cron_db *db; -{ - extern void job_add(); - extern char *env_get(); - extern struct tm *localtime(); - register struct tm *tm = localtime(&TargetTime); - local int minute, hour, dom, month, dow; - register user *u; - register entry *e; - - /* make 0-based values out of these so we can use them as indicies - */ - minute = tm->tm_min -FIRST_MINUTE; - hour = tm->tm_hour -FIRST_HOUR; - dom = tm->tm_mday -FIRST_DOM; - month = tm->tm_mon +1 /* 0..11 -> 1..12 */ -FIRST_MONTH; - dow = tm->tm_wday -FIRST_DOW; - - Debug(DSCH, ("[%d] tick(%d,%d,%d,%d,%d)\n", - getpid(), minute, hour, dom, month, dow)) - - /* the dom/dow situation is odd. '* * 1,15 * Sun' will run on the - * first and fifteenth AND every Sunday; '* * * * Sun' will run *only* - * on Sundays; '* * 1,15 * *' will run *only* the 1st and 15th. this - * is why we keep 'e->dow_star' and 'e->dom_star'. yes, it's bizarre. - * like many bizarre things, it's the standard. - */ - for (u = db->head; u != NULL; u = u->next) { - Debug(DSCH|DEXT, ("user [%s:%d:%d:...]\n", - env_get(USERENV,u->envp), u->uid, u->gid)) - for (e = u->crontab; e != NULL; e = e->next) { - Debug(DSCH|DEXT, ("entry [%s]\n", e->cmd)) - if (bit_test(e->minute, minute) - && bit_test(e->hour, hour) - && bit_test(e->month, month) - && ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR)) - ? (bit_test(e->dow,dow) && bit_test(e->dom,dom)) - : (bit_test(e->dow,dow) || bit_test(e->dom,dom)) - ) - ) { - job_add(e->cmd, u); - } - } - } -} - - -/* the task here is to figure out how long it's going to be until :00 of the - * following minute and initialize TargetTime to this value. TargetTime - * will subsequently slide 60 seconds at a time, with correction applied - * implicitly in cron_sleep(). it would be nice to let crond execute in - * the "current minute" before going to sleep, but by restarting cron you - * could then get it to execute a given minute's jobs more than once. - * instead we have the chance of missing a minute's jobs completely, but - * that's something sysadmin's know to expect what with crashing computers.. - */ -static void -cron_sync() -{ - extern struct tm *localtime(); - register struct tm *tm; - - TargetTime = time((time_t*)0); - tm = localtime(&TargetTime); - TargetTime += (60 - tm->tm_sec); -} - - -static void -cron_sleep() -{ - extern void do_command(); - extern int job_runqueue(); - register int seconds_to_wait; - - do { - seconds_to_wait = (int) (TargetTime - time((time_t*)0)); - Debug(DSCH, ("[%d] TargetTime=%ld, sec-to-wait=%d\n", - getpid(), TargetTime, seconds_to_wait)) - - /* if we intend to sleep, this means that it's finally - * time to empty the job queue (execute it). - * - * if we run any jobs, we'll probably screw up our timing, - * so go recompute. - * - * note that we depend here on the left-to-right nature - * of &&, and the short-circuiting. - */ - } while (seconds_to_wait > 0 && job_runqueue()); - - if (seconds_to_wait > 0) - { - Debug(DSCH, ("[%d] sleeping for %d seconds\n", - getpid(), seconds_to_wait)) - (void) sleep((unsigned int) seconds_to_wait); - } -} - - -#if defined(BSD) -static void -sigchld_handler() -{ - union wait waiter; - int pid; - - for (;;) - { - pid = wait3((int *)&waiter, WNOHANG, (struct rusage *)0); - switch (pid) - { - case -1: - Debug(DPROC, - ("[%d] sigchld...no children\n", getpid())) - return; - case 0: - Debug(DPROC, - ("[%d] sigchld...no dead kids\n", getpid())) - return; - default: - Debug(DPROC, - ("[%d] sigchld...pid #%d died, stat=%d\n", - getpid(), pid, waiter.w_status)) - } - } -} -#endif /*BSD*/ - - -static void -parse_args(argc, argv) - int argc; - char *argv[]; -{ - extern int optind, getopt(); - extern void usage(); - extern char *optarg; - - int argch; - - while (EOF != (argch = getopt(argc, argv, "x:"))) - { - switch (argch) - { - default: - usage(); - case 'x': - if (!set_debug_flags(optarg)) - usage(); - break; - } - } -} diff --git a/libexec/crond/database.c b/libexec/crond/database.c deleted file mode 100644 index 29a848ecdf26..000000000000 --- a/libexec/crond/database.c +++ /dev/null @@ -1,271 +0,0 @@ -/* Copyright 1988,1990 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie, 329 Noe Street, San Francisco, CA, 94114, (415) 864-7013, - * paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl,crash}!vixie!paul - */ - -#ifndef lint -static char rcsid[] = "$Id: database.c,v 1.4 1993/12/15 16:58:01 jtc Exp $"; -#endif - - -#include "cron.h" -#include -#if defined(__NetBSD__) -# include -# include -# define direct dirent -#elif defined(BSD) -# include -# include -#elif defined(ATT) -# include -# include -# include -#endif - - -extern void perror(), exit(); - - -void -load_database(old_db) - cron_db *old_db; -{ - extern void link_user(), unlink_user(), free_user(); - extern user *load_user(), *find_user(); - extern char *env_get(); - - DIR *dir; - struct stat statbuf; - struct direct *dp; - cron_db new_db; - user *u; - - Debug(DLOAD, ("[%d] load_database()\n", getpid())) - - /* before we start loading any data, do a stat on SPOOL_DIR - * so that if anything changes as of this moment (i.e., before we've - * cached any of the database), we'll see the changes next time. - */ - if (stat(SPOOL_DIR, &statbuf) < OK) - { - log_it("CROND", getpid(), "STAT FAILED", SPOOL_DIR); - (void) exit(ERROR_EXIT); - } - - /* if spooldir's mtime has not changed, we don't need to fiddle with - * the database. Note that if /etc/passwd changes (like, someone's - * UID/GID/HOME/SHELL, we won't see it. Maybe we should - * keep an mtime for the passwd file? HINT - * - * Note that old_db->mtime is initialized to 0 in main(), and - * so is guaranteed to be different than the stat() mtime the first - * time this function is called. - */ - if (old_db->mtime == statbuf.st_mtime) - { - Debug(DLOAD, ("[%d] spool dir mtime unch, no load needed.\n", - getpid())) - return; - } - - /* we used to keep this dir open all the time, for the sake of - * efficiency. however, we need to close it in every fork, and - * we fork a lot more often than the mtime of the dir changes. - */ - if (!(dir = opendir(SPOOL_DIR))) - { - log_it("CROND", getpid(), "OPENDIR FAILED", SPOOL_DIR); - (void) exit(ERROR_EXIT); - } - - /* something's different. make a new database, moving unchanged - * elements from the old database, reloading elements that have - * actually changed. Whatever is left in the old database when - * we're done is chaff -- crontabs that disappeared. - */ - new_db.mtime = statbuf.st_mtime; - new_db.head = new_db.tail = NULL; - - while (NULL != (dp = readdir(dir))) - { - extern struct passwd *getpwnam(); - struct passwd *pw; - int crontab_fd = -1; - char fname[MAXNAMLEN+1], - tabname[MAXNAMLEN+1]; - - (void) strncpy(fname, dp->d_name, (int) dp->d_namlen); - fname[dp->d_namlen] = '\0'; - - /* avoid file names beginning with ".". this is good - * because we would otherwise waste two guaranteed calls - * to getpwnam() for . and .., and also because user names - * starting with a period are just too nasty to consider. - */ - if (fname[0] == '.') - goto next_crontab; - - if (NULL == (pw = getpwnam(fname))) - { - /* file doesn't have a user in passwd file. - */ - log_it(fname, getpid(), "ORPHAN", "no passwd entry"); - goto next_crontab; - } - - sprintf(tabname, CRON_TAB(fname)); - if ((crontab_fd = open(tabname, O_RDONLY, 0)) < OK) - { - /* crontab not accessible? - */ - log_it(fname, getpid(), "CAN'T OPEN", tabname); - goto next_crontab; - } - - if (fstat(crontab_fd, &statbuf) < OK) - { - log_it(fname, getpid(), "FSTAT FAILED", tabname); - goto next_crontab; - } - - Debug(DLOAD, ("\t%s:", fname)) - u = find_user(old_db, fname); - if (u != NULL) - { - /* if crontab has not changed since we last read it - * in, then we can just use our existing entry. - * note that we do not check for changes in the - * passwd entry (uid, home dir, etc). HINT - */ - if (u->mtime == statbuf.st_mtime) - { - Debug(DLOAD, (" [no change, using old data]")) - unlink_user(old_db, u); - link_user(&new_db, u); - goto next_crontab; - } - - /* before we fall through to the code that will reload - * the user, let's deallocate and unlink the user in - * the old database. This is more a point of memory - * efficiency than anything else, since all leftover - * users will be deleted from the old database when - * we finish with the crontab... - */ - Debug(DLOAD, (" [delete old data]")) - unlink_user(old_db, u); - free_user(u); - } - u = load_user( - crontab_fd, - pw->pw_name, - pw->pw_uid, - pw->pw_gid, - pw->pw_dir, - pw->pw_shell - ); - if (u != NULL) - { - u->mtime = statbuf.st_mtime; - link_user(&new_db, u); - } -next_crontab: - if (crontab_fd >= OK) { - Debug(DLOAD, (" [done]\n")) - close(crontab_fd); - } - } - closedir(dir); - - /* if we don't do this, then when our children eventually call - * getpwnam() in do_command.c's child_process to verify MAILTO=, - * they will screw us up (and v-v). - * - * (this was lots of fun to find...) - */ - endpwent(); - - /* whatever's left in the old database is now junk. - */ - Debug(DLOAD, ("unlinking old database:\n")) - for (u = old_db->head; u != NULL; u = u->next) - { - Debug(DLOAD, ("\t%s\n", env_get(USERENV, u->envp))) - unlink_user(old_db, u); - free_user(u); - } - - /* overwrite the database control block with the new one. - */ - Debug(DLOAD, ("installing new database\n")) -#if defined(BSD) - /* BSD has structure assignments */ - *old_db = new_db; -#endif -#if defined(ATT) - /* ATT, well, I don't know. Use memcpy(). */ - memcpy(old_db, &new_db, sizeof(cron_db)); -#endif - Debug(DLOAD, ("load_database is done\n")) -} - - -void -link_user(db, u) - cron_db *db; - user *u; -{ - if (db->head == NULL) - db->head = u; - if (db->tail) - db->tail->next = u; - u->prev = db->tail; - u->next = NULL; - db->tail = u; -} - - -void -unlink_user(db, u) - cron_db *db; - user *u; -{ - if (u->prev == NULL) - db->head = u->next; - else - u->prev->next = u->next; - - if (u->next == NULL) - db->tail = u->prev; - else - u->next->prev = u->prev; -} - - -user * -find_user(db, name) - cron_db *db; - char *name; -{ - char *env_get(); - user *u; - - for (u = db->head; u != NULL; u = u->next) - if (!strcmp(env_get(USERENV, u->envp), name)) - break; - return u; -} diff --git a/libexec/crond/do_command.c b/libexec/crond/do_command.c deleted file mode 100644 index fcf89122fb2c..000000000000 --- a/libexec/crond/do_command.c +++ /dev/null @@ -1,571 +0,0 @@ -/* Copyright 1988,1990 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie, 329 Noe Street, San Francisco, CA, 94114, (415) 864-7013, - * paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl,crash}!vixie!paul - */ - -#ifndef lint -static char rcsid[] = "$Id: do_command.c,v 1.10 1993/12/06 23:57:11 cgd Exp $"; -#endif - - -#include "cron.h" -#include -#include -#if defined(BSD) -# include -#endif /*BSD*/ -#if defined(sequent) -# include -# include -#endif - -static void child_process(); - -void -do_command(cmd, u) - char *cmd; - user *u; -{ - extern int fork(); - extern void log_it(); - extern char *env_get(), arpadate(); - - Debug(DPROC, ("[%d] do_command(%s, (%s,%d,%d))\n", - getpid(), cmd, env_get(USERENV, u->envp), u->uid, u->gid)) - - /* fork to become asynchronous -- parent process is done immediately, - * and continues to run the normal cron code, which means return to - * tick(). the child and grandchild don't leave this function, alive. - * - * vfork() is unsuitable, since we have much to do, and the parent - * needs to be able to run off and fork other processes. - */ - switch (fork()) - { - case -1: - log_it("CROND",getpid(),"error","can't fork"); - break; - case 0: - /* child process */ - child_process(cmd, u); - Debug(DPROC, ("[%d] child process done, exiting\n", getpid())) - _exit(OK_EXIT); - break; - } - Debug(DPROC, ("[%d] main process returning to work\n", getpid())) -} - - -static void -child_process(cmd, u) - char *cmd; - user *u; -{ - extern struct passwd *getpwnam(); - extern void sigpipe_func(), be_different(), log_it(); - extern int VFORK(); - extern char *index(), *env_get(); - - auto int stdin_pipe[2], stdout_pipe[2]; - register char *input_data, *usernm, *mailto; - auto int children = 0; -#if defined(sequent) - extern void do_univ(); -#endif - - Debug(DPROC, ("[%d] child_process('%s')\n", getpid(), cmd)) - - /* mark ourselves as different to PS command watchers by upshifting - * our program name. This has no effect on some kernels. - */ - { - register char *pch; - - for (pch = ProgramName; *pch; pch++) - *pch = MkUpper(*pch); - } - - /* discover some useful and important environment settings - */ - usernm = env_get(USERENV, u->envp); - mailto = env_get("MAILTO", u->envp); - -#if defined(BSD) - /* our parent is watching for our death by catching SIGCHLD. we - * do not care to watch for our children's deaths this way -- we - * use wait() explictly. so we have to disable the signal (which - * was inherited from the parent). - * - * this isn't needed for system V, since our parent is already - * SIG_IGN on SIGCLD -- which, hopefully, will cause children to - * simply vanish when they die. - */ - (void) signal(SIGCHLD, SIG_IGN); -#endif /*BSD*/ - - /* create some pipes to talk to our future child - */ - pipe(stdin_pipe); /* child's stdin */ - pipe(stdout_pipe); /* child's stdout */ - - /* since we are a forked process, we can diddle the command string - * we were passed -- nobody else is going to use it again, right? - * - * if a % is present in the command, previous characters are the - * command, and subsequent characters are the additional input to - * the command. Subsequent %'s will be transformed into newlines, - * but that happens later. - */ - if (NULL == (input_data = index(cmd, '%'))) - { - /* no %. point input_data at a null string. - */ - input_data = ""; - } - else - { - /* % found. replace with a null (remember, we're a forked - * process and the string won't be reused), and increment - * input_data to point at the following character. - */ - *input_data++ = '\0'; - } - - /* set our directory, uid and gid. Set gid first, since once - * we set uid, we've lost root privledges. (oops!) - */ - setgid(u->gid); -# if defined(BSD) - initgroups(env_get(USERENV, u->envp), u->gid); -# endif - setuid(u->uid); /* you aren't root after this... */ - chdir(env_get("HOME", u->envp)); - - /* fork again, this time so we can exec the user's command. Vfork() - * is okay this time, since we are going to exec() pretty quickly. - * I'm assuming that closing pipe ends &whatnot will not affect our - * suspended pseudo-parent/alter-ego. - */ - if (VFORK() == 0) - { - Debug(DPROC, ("[%d] grandchild process VFORK()'ed\n", getpid())) - - /* write a log message. we've waited this long to do it - * because it was not until now that we knew the PID that - * the actual user command shell was going to get and the - * PID is part of the log message. - */ -#if defined(LOG_FILE) || defined(SYSLOG) - { - extern char *mkprints(); - char *x = mkprints(cmd, strlen(cmd)); - - log_it(usernm, getpid(), "CMD", x); - free(x); - } -#endif - - /* get new pgrp, void tty, etc. - */ - be_different(); - - /* close the pipe ends that we won't use. this doesn't affect - * the parent, who has to read and write them; it keeps the - * kernel from recording us as a potential client TWICE -- - * which would keep it from sending SIGPIPE in otherwise - * appropriate circumstances. - */ - close(stdin_pipe[WRITE_PIPE]); - close(stdout_pipe[READ_PIPE]); - - /* grandchild process. make std{in,out} be the ends of - * pipes opened by our daddy; make stderr go to stdout. - */ - close(STDIN); dup2(stdin_pipe[READ_PIPE], STDIN); - close(STDOUT); dup2(stdout_pipe[WRITE_PIPE], STDOUT); - close(STDERR); dup2(STDOUT, STDERR); - - /* close the pipes we just dup'ed. The resources will remain, - * since they've been dup'ed... :-)... - */ - close(stdin_pipe[READ_PIPE]); - close(stdout_pipe[WRITE_PIPE]); - -# if defined(sequent) - /* set our login universe. Do this in the grandchild - * so that the child can invoke /usr/lib/sendmail - * without surprises. - */ - do_univ(u); -# endif - - /* exec the command. - */ - { - char *shell = env_get("SHELL", u->envp); - -# if DEBUGGING - if (DebugFlags & DTEST) { - fprintf(stderr, - "debug DTEST is on, not exec'ing command.\n"); - fprintf(stderr, - "\tcmd='%s' shell='%s'\n", cmd, shell); - _exit(OK_EXIT); - } -# endif /*DEBUGGING*/ - /* normally you can't put debugging stuff here because - * it gets mailed with the command output. - */ - /* - Debug(DPROC, ("[%d] execle('%s', '%s', -c, '%s')\n", - getpid(), shell, shell, cmd)) - */ - - /* files writable by non-owner are a no-no, if we are - * running with privileges. - */ - if (u->uid == ROOT_UID) { - struct stat sb; - char *filename, *fp; - - filename = (char *)malloc(strlen(cmd)+1); - /* they're checked nowhere else! */ - - strcpy(filename,cmd); - fp = filename; - while (*fp && !isspace(*fp)) - fp++; - *fp = '\0'; - - if (0 != stat(filename, &sb)) { - fputs("crond: stat(2): ", stderr); - perror(filename); - _exit(ERROR_EXIT); - } else if (sb.st_mode & 022) { - fprintf(stderr, - "crond: %s writable by nonowner\n", - filename); - _exit(ERROR_EXIT); - } else if (sb.st_uid != u->uid) { - fprintf(stderr, - "crond: %s owned by uid %d\n", - filename, sb.st_uid); - _exit(ERROR_EXIT); - } - - free(filename); - } - - execle(shell, shell, "-c", cmd, (char *)0, u->envp); - fprintf(stderr, "execl: couldn't exec `%s'\n", shell); - perror("execl"); - _exit(ERROR_EXIT); - } - } - - children++; - - /* middle process, child of original cron, parent of process running - * the user's command. - */ - - Debug(DPROC, ("[%d] child continues, closing pipes\n", getpid())) - - /* close the ends of the pipe that will only be referenced in the - * grandchild process... - */ - close(stdin_pipe[READ_PIPE]); - close(stdout_pipe[WRITE_PIPE]); - - /* - * write, to the pipe connected to child's stdin, any input specified - * after a % in the crontab entry. while we copy, convert any - * additional %'s to newlines. when done, if some characters were - * written and the last one wasn't a newline, write a newline. - * - * Note that if the input data won't fit into one pipe buffer (2K - * or 4K on most BSD systems), and the child doesn't read its stdin, - * we would block here. the solution, of course, is to fork again. - */ - - if (*input_data && fork() == 0) { - register FILE *out = fdopen(stdin_pipe[WRITE_PIPE], "w"); - register int need_newline = FALSE; - register int escaped = FALSE; - register int ch; - - Debug(DPROC, ("[%d] child2 sending data to grandchild\n", getpid())) - - /* close the pipe we don't use, since we inherited it and - * are part of its reference count now. - */ - close(stdout_pipe[READ_PIPE]); - - /* translation: - * \% -> % - * % -> \n - * \x -> \x for all x != % - */ - while (ch = *input_data++) - { - if (escaped) { - if (ch != '%') - putc('\\', out); - } else { - if (ch == '%') - ch = '\n'; - } - - if (!(escaped = (ch == '\\'))) { - putc(ch, out); - need_newline = (ch != '\n'); - } - } - if (escaped) - putc('\\', out); - if (need_newline) - putc('\n', out); - - /* close the pipe, causing an EOF condition. fclose causes - * stdin_pipe[WRITE_PIPE] to be closed, too. - */ - fclose(out); - - Debug(DPROC, ("[%d] child2 done sending to grandchild\n", getpid())) - exit(0); - } - - /* close the pipe to the grandkiddie's stdin, since its wicked uncle - * ernie back there has it open and will close it when he's done. - */ - close(stdin_pipe[WRITE_PIPE]); - - children++; - - /* - * read output from the grandchild. it's stderr has been redirected to - * it's stdout, which has been redirected to our pipe. if there is any - * output, we'll be mailing it to the user whose crontab this is... - * when the grandchild exits, we'll get EOF. - */ - - Debug(DPROC, ("[%d] child reading output from grandchild\n", getpid())) - - { - register FILE *in = fdopen(stdout_pipe[READ_PIPE], "r"); - register int ch = getc(in); - - if (ch != EOF) - { - register FILE *mail; - register int bytes = 1; - union wait status; - - Debug(DPROC|DEXT, - ("[%d] got data (%x:%c) from grandchild\n", - getpid(), ch, ch)) - - /* get name of recipient. this is MAILTO if set to a - * valid local username; USER otherwise. - */ - if (mailto) - { - /* MAILTO was present in the environment - */ - if (!*mailto) - { - /* ... but it's empty. set to NULL - */ - mailto = NULL; - } - } - else - { - /* MAILTO not present, set to USER. - */ - mailto = usernm; - } - - /* if we are supposed to be mailing, MAILTO will - * be non-NULL. only in this case should we set - * up the mail command and subjects and stuff... - */ - - if (mailto) - { - extern FILE *popen(); - extern char *print_cmd(); - register char **env; - auto char mailcmd[MAX_COMMAND]; - auto char hostname[MAXHOSTNAMELEN]; - - (void) gethostname(hostname, MAXHOSTNAMELEN); - (void) sprintf(mailcmd, MAILARGS, - MAILCMD, mailto); - if (!(mail = popen(mailcmd, "w"))) - { - perror(MAILCMD); - (void) _exit(ERROR_EXIT); - } - fprintf(mail, "From: root (Cron Daemon)\n"); - fprintf(mail, "To: %s\n", mailto); - fprintf(mail, - "Subject: cron for %s@%s said this\n", - usernm, first_word(hostname, ".") - ); -# if defined(MAIL_DATE) - fprintf(mail, "Date: %s", - arpadate(&TargetTime)); -# endif /* MAIL_DATE */ - fprintf(mail, "X-Cron-Cmd: <%s>\n", cmd); - for (env = u->envp; *env; env++) - fprintf(mail, "X-Cron-Env: <%s>\n", - *env); - fprintf(mail, "\n"); - - /* this was the first char from the pipe - */ - putc(ch, mail); - } - - /* we have to read the input pipe no matter whether - * we mail or not, but obviously we only write to - * mail pipe if we ARE mailing. - */ - - while (EOF != (ch = getc(in))) - { - bytes++; - if (mailto) - putc(ch, mail); - } - - /* if the cron job output ended on something other - * than a newline, add a newline here. this helps - * keep mailboxes from being corrupted; apparently - * /bin/mail versions that use \n\nFrom as a marker - * do not guarantee that messages end on newlines, - * which causes follow-on messages to glue together. - */ - if (mailto && (ch != '\n')) { - bytes++; - putc('\n', mail); - } - - /* only close pipe if we opened it -- i.e., we're - * mailing... - */ - - if (mailto) { - Debug(DPROC, ("[%d] closing pipe to mail\n", - getpid())) - /* Note: the pclose will probably see - * the termination of the grandchild - * in addition to the mail process, since - * it (the grandchild) is likely to exit - * after closing its stdout. - */ - status.w_status = pclose(mail); - } - - /* if there was output and we could not mail it, - * log the facts so the poor user can figure out - * what's going on. - */ - if (mailto && status.w_status) { - char buf[MAX_TEMPSTR]; - - sprintf(buf, - "mailed %d byte%s of output but got status 0x%04x\n", - bytes, (bytes==1)?"":"s", - status.w_status); - log_it(usernm, getpid(), "MAIL", buf); - } - - } /*if data from grandchild*/ - - Debug(DPROC, ("[%d] got EOF from grandchild\n", getpid())) - - fclose(in); /* also closes stdout_pipe[READ_PIPE] */ - } - -#if defined(BSD) - /* wait for children to die. - */ - for (; children > 0; children--) - { - int pid; - union wait waiter; - - Debug(DPROC, ("[%d] waiting for grandchild #%d to finish\n", - getpid(), children)) - pid = wait((int *)&waiter); - if (pid < OK) { - Debug(DPROC, ("[%d] no more grandchildren--mail written?\n", - getpid())) - break; - } - Debug(DPROC, ("[%d] grandchild #%d finished, status=%04x", - getpid(), pid, waiter.w_status)) - if (waiter.w_coredump) - Debug(DPROC, (", dumped core")) - Debug(DPROC, ("\n")) - } -#endif /*BSD*/ -} - - -#if defined(sequent) -/* Dynix (Sequent) hack to put the user associated with - * the passed user structure into the ATT universe if - * necessary. We have to dig the gecos info out of - * the user's password entry to see if the magic - * "universe(att)" string is present. If we do change - * the universe, also set "LOGNAME". - */ - -void -do_univ(u) - user *u; -{ - struct passwd *p; - char *s; - int i; - char envstr[MAX_ENVSTR], **env_set(); - - p = getpwuid(u->uid); - (void) endpwent(); - - if (p == NULL) - return; - - s = p->pw_gecos; - - for (i = 0; i < 4; i++) - { - if ((s = index(s, ',')) == NULL) - return; - s++; - } - if (strcmp(s, "universe(att)")) - return; - - (void) sprintf(envstr, "LOGNAME=%s", p->pw_name); - u->envp = env_set(u->envp, envstr); - - (void) universe(U_ATT); -} -#endif diff --git a/libexec/crond/entry.c b/libexec/crond/entry.c deleted file mode 100644 index e835cf3f5e11..000000000000 --- a/libexec/crond/entry.c +++ /dev/null @@ -1,479 +0,0 @@ -/* Copyright 1988,1990 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie, 329 Noe Street, San Francisco, CA, 94114, (415) 864-7013, - * paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl,crash}!vixie!paul - */ - -#ifndef lint -static char rcsid[] = "$Id: entry.c,v 1.3 1993/08/02 17:50:24 mycroft Exp $"; -#endif - - -#include "cron.h" - -typedef enum - {e_none, e_minute, e_hour, e_dom, e_month, e_dow, e_cmd, e_timespec} - ecode_e; -static char *ecodes[] = - { - "no error", - "bad minute", - "bad hour", - "bad day-of-month", - "bad month", - "bad day-of-week", - "bad command", - "bad time specifier" - }; - -void -free_entry(e) - entry *e; -{ - int free(); - - (void) free(e->cmd); - (void) free(e); -} - - -entry * -load_entry(file, error_func) - FILE *file; - void (*error_func)(); -{ - /* this function reads one crontab entry -- the next -- from a file. - * it skips any leading blank lines, ignores comments, and returns - * EOF if for any reason the entry can't be read and parsed. - * - * the entry IS parsed here, btw. - * - * syntax: - * minutes hours doms months dows cmd\n - */ - - extern int free(); - extern char *malloc(), *savestr(); - extern void unget_char(); - static char get_list(); - - ecode_e ecode = e_none; - entry *e; - int ch; - void skip_comments(); - char cmd[MAX_COMMAND]; - - e = (entry *) calloc(sizeof(entry), sizeof(char)); - - Debug(DPARS, ("load_entry()...about to eat comments\n")) - - skip_comments(file); - - ch = get_char(file); - - /* ch is now the first useful character of a useful line. - * it may be an @special or it may be the first character - * of a list of minutes. - */ - - if (ch == '@') - { - /* all of these should be flagged and load-limited; i.e., - * instead of @hourly meaning "0 * * * *" it should mean - * "close to the front of every hour but not 'til the - * system load is low". Problems are: how do you know - * what "low" means? (save me from /etc/crond.conf!) and: - * how to guarantee low variance (how low is low?), which - * means how to we run roughly every hour -- seems like - * we need to keep a history or let the first hour set - * the schedule, which means we aren't load-limited - * anymore. too much for my overloaded brain. (vix, jan90) - * HINT - */ - ch = get_string(cmd, MAX_COMMAND, file, " \t\n"); - if (!strcmp("reboot", cmd)) { - e->flags |= WHEN_REBOOT; - } else if (!strcmp("yearly", cmd) || !strcmp("annually", cmd)){ - bit_set(e->minute, 0); - bit_set(e->hour, 0); - bit_set(e->dom, 0); - bit_set(e->month, 0); - bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1)); - } else if (!strcmp("monthly", cmd)) { - bit_set(e->minute, 0); - bit_set(e->hour, 0); - bit_set(e->dom, 0); - bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1)); - bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1)); - } else if (!strcmp("weekly", cmd)) { - bit_set(e->minute, 0); - bit_set(e->hour, 0); - bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1)); - bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1)); - bit_set(e->dow, 0); - } else if (!strcmp("daily", cmd) || !strcmp("midnight", cmd)) { - bit_set(e->minute, 0); - bit_set(e->hour, 0); - bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1)); - bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1)); - bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1)); - } else if (!strcmp("hourly", cmd)) { - bit_set(e->minute, 0); - bit_set(e->hour, (LAST_HOUR-FIRST_HOUR+1)); - bit_nset(e->dom, 0, (LAST_DOM-FIRST_DOM+1)); - bit_nset(e->month, 0, (LAST_MONTH-FIRST_MONTH+1)); - bit_nset(e->dow, 0, (LAST_DOW-FIRST_DOW+1)); - } else { - ecode = e_timespec; - goto eof; - } - } - else - { - Debug(DPARS, ("load_entry()...about to parse numerics\n")) - - ch = get_list(e->minute, FIRST_MINUTE, LAST_MINUTE, - PPC_NULL, ch, file); - if (ch == EOF) - { - ecode = e_minute; - goto eof; - } - - /* hours - */ - - ch = get_list(e->hour, FIRST_HOUR, LAST_HOUR, - PPC_NULL, ch, file); - if (ch == EOF) - { - ecode = e_hour; - goto eof; - } - - /* DOM (days of month) - */ - - if (ch == '*') e->flags |= DOM_STAR; - ch = get_list(e->dom, FIRST_DOM, LAST_DOM, PPC_NULL, ch, file); - if (ch == EOF) - { - ecode = e_dom; - goto eof; - } - - /* month - */ - - ch = get_list(e->month, FIRST_MONTH, LAST_MONTH, - MonthNames, ch, file); - if (ch == EOF) - { - ecode = e_month; - goto eof; - } - - /* DOW (days of week) - */ - - if (ch == '*') e->flags |= DOW_STAR; - ch = get_list(e->dow, FIRST_DOW, LAST_DOW, - DowNames, ch, file); - if (ch == EOF) - { - ecode = e_dow; - goto eof; - } - } - - /* make sundays equivilent */ - if (bit_test(e->dow, 0) || bit_test(e->dow, 7)) - { - bit_set(e->dow, 0); - bit_set(e->dow, 7); - } - - Debug(DPARS, ("load_entry()...about to parse command\n")) - - /* ch is first character of a command. everything up to the next - * \n or EOF is part of the command... too bad we don't know in - * advance how long it will be, since we need to malloc a string - * for it... so, we limit it to MAX_COMMAND - */ - unget_char(ch, file); - ch = get_string(cmd, MAX_COMMAND, file, "\n"); - - /* a file without a \n before the EOF is rude, so we'll complain... - */ - if (ch == EOF) - { - ecode = e_cmd; - goto eof; - } - - /* got the command in the 'cmd' string; save it in *e. - */ - e->cmd = savestr(cmd); - - Debug(DPARS, ("load_entry()...returning successfully\n")) - - /* success, fini, return pointer to the entry we just created... - */ - return e; - -eof: /* if we want to return EOF, we have to jump down here and - * free the entry we've been building. - * - * now, in some cases, a parse routine will have returned EOF to - * indicate an error, but the file is not actually done. since, in - * that case, we only want to skip the line with the error on it, - * we'll do that here. - * - * many, including the author, see what's below as evil programming - * practice: since I didn't want to change the structure of this - * whole function to support this error recovery, I recurse. Cursed! - * (At least it's tail-recursion, as if it matters in C - vix/8feb88) - * I'm seriously considering using (another) GOTO... argh! - * (this does not get less disgusting over time. vix/15nov88) - */ - - (void) free(e); - - if (feof(file)) - return NULL; - - if (error_func) - (*error_func)(ecodes[(int)ecode]); - do {ch = get_char(file);} - while (ch != EOF && ch != '\n'); - if (ch == EOF) - return NULL; - return load_entry(file, error_func); -} - - -static char -get_list(bits, low, high, names, ch, file) - bitstr_t *bits; /* one bit per flag, default=FALSE */ - int low, high; /* bounds, impl. offset for bitstr */ - char *names[]; /* NULL or *[] of names for these elements */ - int ch; /* current character being processed */ - FILE *file; /* file being read */ -{ - static char get_range(); - register int done; - - /* we know that we point to a non-blank character here; - * must do a Skip_Blanks before we exit, so that the - * next call (or the code that picks up the cmd) can - * assume the same thing. - */ - - Debug(DPARS|DEXT, ("get_list()...entered\n")) - - /* list = "*" | range {"," range} - */ - - if (ch == '*') - { - /* '*' means 'all elements'. - */ - bit_nset(bits, 0, (high-low+1)); - goto exit; - } - - /* clear the bit string, since the default is 'off'. - */ - bit_nclear(bits, 0, (high-low+1)); - - /* process all ranges - */ - done = FALSE; - while (!done) - { - ch = get_range(bits, low, high, names, ch, file); - if (ch == ',') - ch = get_char(file); - else - done = TRUE; - } - -exit: /* exiting. skip to some blanks, then skip over the blanks. - */ - Skip_Nonblanks(ch, file) - Skip_Blanks(ch, file) - - Debug(DPARS|DEXT, ("get_list()...exiting w/ %02x\n", ch)) - - return ch; -} - - -static char -get_range(bits, low, high, names, ch, file) - bitstr_t *bits; /* one bit per flag, default=FALSE */ - int low, high; /* bounds, impl. offset for bitstr */ - char *names[]; /* NULL or names of elements */ - int ch; /* current character being processed */ - FILE *file; /* file being read */ -{ - /* range = number | number "-" number [ "/" number ] - */ - - static int set_element(); - static char get_number(); - register int i; - auto int num1, num2, num3; - - Debug(DPARS|DEXT, ("get_range()...entering, exit won't show\n")) - - if (EOF == (ch = get_number(&num1, low, names, ch, file))) - return EOF; - - if (ch != '-') - { - /* not a range, it's a single number. - */ - if (EOF == set_element(bits, low, high, num1)) - return EOF; - } - else - { - /* eat the dash - */ - ch = get_char(file); - if (ch == EOF) - return EOF; - - /* get the number following the dash - */ - ch = get_number(&num2, low, names, ch, file); - if (ch == EOF) - return EOF; - - /* check for step size - */ - if (ch == '/') - { - /* eat the slash - */ - ch = get_char(file); - if (ch == EOF) - return EOF; - - /* get the step size -- note: we don't pass the - * names here, because the number is not an - * element id, it's a step size. 'low' is - * sent as a 0 since there is no offset either. - */ - ch = get_number(&num3, 0, PPC_NULL, ch, file); - if (ch == EOF) - return EOF; - } - else - { - /* no step. default==1. - */ - num3 = 1; - } - - /* range. set all elements from num1 to num2, stepping - * by num3. (the step is a downward-compatible extension - * proposed conceptually by bob@acornrc, syntactically - * designed then implmented by paul vixie). - */ - for (i = num1; i <= num2; i += num3) - if (EOF == set_element(bits, low, high, i)) - return EOF; - } - return ch; -} - - -static char -get_number(numptr, low, names, ch, file) - int *numptr; - int low; - char *names[]; - char ch; - FILE *file; -{ - char temp[MAX_TEMPSTR], *pc; - int len, i, all_digits; - - /* collect alphanumerics into our fixed-size temp array - */ - pc = temp; - len = 0; - all_digits = TRUE; - while (isalnum(ch)) - { - if (++len >= MAX_TEMPSTR) - return EOF; - - *pc++ = ch; - - if (!isdigit(ch)) - all_digits = FALSE; - - ch = get_char(file); - } - *pc = '\0'; - - /* try to find the name in the name list - */ - if (names) - for (i = 0; names[i] != NULL; i++) - { - Debug(DPARS|DEXT, - ("get_num, compare(%s,%s)\n", names[i], temp)) - if (!nocase_strcmp(names[i], temp)) - { - *numptr = i+low; - return ch; - } - } - - /* no name list specified, or there is one and our string isn't - * in it. either way: if it's all digits, use its magnitude. - * otherwise, it's an error. - */ - if (all_digits) - { - *numptr = atoi(temp); - return ch; - } - - return EOF; -} - - -static int -set_element(bits, low, high, number) - bitstr_t *bits; /* one bit per flag, default=FALSE */ - int low; - int high; - int number; -{ - Debug(DPARS|DEXT, ("set_element(?,%d,%d,%d)\n", low, high, number)) - - if (number < low || number > high) - return EOF; - - Debug(DPARS|DEXT, ("bit_set(%x,%d)\n",bits,(number-low))) - bit_set(bits, (number-low)); - Debug(DPARS|DEXT, ("bit_set succeeded\n")) - return OK; -} diff --git a/libexec/crond/env.c b/libexec/crond/env.c deleted file mode 100644 index f9813c8ce667..000000000000 --- a/libexec/crond/env.c +++ /dev/null @@ -1,155 +0,0 @@ -/* Copyright 1988,1990 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie, 329 Noe Street, San Francisco, CA, 94114, (415) 864-7013, - * paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl,crash}!vixie!paul - */ - -#ifndef lint -static char rcsid[] = "$Id: env.c,v 1.5 1993/09/17 03:46:49 cgd Exp $"; -#endif - - -#include "cron.h" - - -char ** -env_init() -{ - extern char *malloc(); - register char **p = (char **) malloc(sizeof(char **)); - - p[0] = NULL; - return p; -} - - -char ** -env_set(envp, envstr) - char **envp; - char *envstr; -{ - extern char *realloc(), *savestr(); - register int count, found; - register char **p; - - /* - * count the number of elements, including the null pointer; - * also set 'found' to -1 or index of entry if already in here. - */ - found = -1; - for (count = 0; envp[count] != NULL; count++) - { - if (!strcmp_until(envp[count], envstr, '=')) - found = count; - } - count++; /* for the null pointer - */ - - if (found != -1) - { - /* - * it exists already, so just free the existing setting, - * save our new one there, and return the existing array. - */ - free(envp[found]); - envp[found] = savestr(envstr); - return envp; - } - - /* - * it doesn't exist yet, so resize the array, move null pointer over - * one, save our string over the old null pointer, and return resized - * array. - */ - p = (char **) realloc( - (char *) envp, - (unsigned) ((count+1) * sizeof(char **)) - ); - p[count] = p[count-1]; - p[count-1] = savestr(envstr); - return p; -} - - -int -load_env(envstr, f) - char *envstr; - FILE *f; -{ - /* return ERR = end of file - * FALSE = not an env setting (file was repositioned) - * TRUE = was an env setting - */ - char *strcpy(); - long filepos; - int fileline; - char name[MAX_TEMPSTR], val[MAX_ENVSTR]; - int fields, strdtb(); - void skip_comments(); - - filepos = ftell(f); - fileline = LineNumber; - skip_comments(f); - if (EOF == get_string(envstr, MAX_ENVSTR, f, "\n")) - return ERR; - - Debug(DPARS, ("load_env, read <%s>\n", envstr)) - - name[0] = val[0] = '\0'; - fields = sscanf(envstr, "%[^ =] = %[^\n#]", name, val); - if (fields != 2) - { - Debug(DPARS, ("load_env, not 2 fields (%d)\n", fields)) - fseek(f, filepos, 0); - Set_LineNum(fileline); - return FALSE; - } - - /* 2 fields from scanf; looks like an env setting - */ - - /* - * process value string - */ - { - int len = strdtb(val); - - if (len >= 2) - if (val[0] == '\'' || val[0] == '"') - if (val[len-1] == val[0]) - { - val[len-1] = '\0'; - (void) strcpy(val, val+1); - } - } - - (void) sprintf(envstr, "%s=%s", name, val); - Debug(DPARS, ("load_env, <%s> <%s> -> <%s>\n", name, val, envstr)) - return TRUE; -} - - -char * -env_get(name, envp) - char *name; - char **envp; -{ - char *index(); - - for (; *envp; envp++) - if (!strcmp_until(*envp, name, '=')) - return index(*envp, '=') + 1; - return NULL; -} diff --git a/libexec/crond/job.c b/libexec/crond/job.c deleted file mode 100644 index 051f254e865a..000000000000 --- a/libexec/crond/job.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 1988,1990 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie, 329 Noe Street, San Francisco, CA, 94114, (415) 864-7013, - * paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl,crash}!vixie!paul - */ - -#ifndef lint -static char rcsid[] = "$Id: job.c,v 1.3 1993/08/02 17:50:26 mycroft Exp $"; -#endif - - -#include "cron.h" - - -typedef struct _job - { - struct _job *next; - char *cmd; - user *u; - } - job; - - -static job *jhead = NULL, *jtail = NULL; - - -void -job_add(cmd, u) - register char *cmd; - register user *u; -{ - register job *j; - - /* if already on queue, keep going */ - for (j=jhead; j; j=j->next) - if (j->cmd == cmd && j->u == u) { return; } - - /* build a job queue element */ - j = (job*)malloc(sizeof(job)); - j->next = (job*) NULL; - j->cmd = cmd; - j->u = u; - - /* add it to the tail */ - if (!jhead) { jhead=j; } - else { jtail->next=j; } - jtail = j; -} - - -int -job_runqueue() -{ - register job *j; - register int run = 0; - - for (j=jhead; j; j=j->next) { - do_command(j->cmd, j->u); - free(j); - run++; - } - jhead = jtail = NULL; - return run; -} diff --git a/libexec/crond/misc.c b/libexec/crond/misc.c deleted file mode 100644 index 5fe069421279..000000000000 --- a/libexec/crond/misc.c +++ /dev/null @@ -1,729 +0,0 @@ -/* Copyright 1988,1990,1993 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie, 3477 South Court, Palo Alto, CA, 94306, USA, +1 415 858 2736 - * paul@vix.com || paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl}!vixie!paul - */ - -#ifndef lint -static char rcsid[] = "$Id: misc.c,v 1.8 1993/12/06 03:36:04 cgd Exp $"; -#endif /* not lint */ - - -#include "cron.h" -#include -#include -#include -#include -#include -#if defined(ATT) -# include -#endif -#if defined(SYSLOG) -# include -#endif - - -void log_it(), be_different(), acquire_daemonlock(); - - -char * -savestr(str) - char *str; -{ - extern char *malloc(), *strcpy(); - /**/ char *temp; - - temp = malloc((unsigned) (strlen(str) + 1)); - (void) strcpy(temp, str); - return temp; -} - - -int -nocase_strcmp(left, right) - char *left; - char *right; -{ - while (*left && (MkLower(*left) == MkLower(*right))) - { - left++; - right++; - } - return MkLower(*left) - MkLower(*right); -} - - -int -strcmp_until(left, right, until) - char *left; - char *right; - char until; -{ - register int diff; - - Debug(DPARS|DEXT, ("strcmp_until(%s,%s,%c) ... ", left, right, until)) - - while (*left && *left != until && *left == *right) - { - left++; - right++; - } - - if ( (*left=='\0' || *left == until) - && (*right=='\0' || *right == until) - ) - diff = 0; - else - diff = *left - *right; - - Debug(DPARS|DEXT, ("%d\n", diff)) - - return diff; -} - - -/* strdtb(s) - delete trailing blanks in string 's' and return new length - */ -int -strdtb(s) - register char *s; -{ - register char *x = s; - - /* scan forward to the null - */ - while (*x) - x++; - - /* scan backward to either the first character before the string, - * or the last non-blank in the string, whichever comes first. - */ - do {x--;} - while (x >= s && isspace(*x)); - - /* one character beyond where we stopped above is where the null - * goes. - */ - *++x = '\0'; - - /* the difference between the position of the null character and - * the position of the first character of the string is the length. - */ - return x - s; -} - - -int -set_debug_flags(flags) - char *flags; -{ - /* debug flags are of the form flag[,flag ...] - * - * if an error occurs, print a message to stdout and return FALSE. - * otherwise return TRUE after setting ERROR_FLAGS. - */ - -#if !DEBUGGING - - printf("this program was compiled without debugging enabled\n"); - return FALSE; - -#else /* DEBUGGING */ - - char *pc = flags; - - DebugFlags = 0; - - while (*pc) - { - char **test; - int mask; - - /* try to find debug flag name in our list. - */ - for ( test = DebugFlagNames, mask = 1; - *test && strcmp_until(*test, pc, ','); - test++, mask <<= 1 - ) - ; - - if (!*test) - { - fprintf(stderr, - "unrecognized debug flag <%s> <%s>\n", - flags, pc); - return FALSE; - } - - DebugFlags |= mask; - - /* skip to the next flag - */ - while (*pc && *pc != ',') - pc++; - if (*pc == ',') - pc++; - } - - if (DebugFlags) - { - int flag; - - fprintf(stderr, "debug flags enabled:"); - - for (flag = 0; DebugFlagNames[flag]; flag++) - if (DebugFlags & (1 << flag)) - fprintf(stderr, " %s", DebugFlagNames[flag]); - fprintf(stderr, "\n"); - } - - return TRUE; - -#endif /* DEBUGGING */ -} - - -#if defined(BSD) -void -set_cron_uid() -{ - int seteuid(); - - if (seteuid(ROOT_UID) < OK) - { - perror("seteuid"); - exit(ERROR_EXIT); - } -} -#endif - -#if defined(ATT) -void -set_cron_uid() -{ - int setuid(); - - if (setuid(ROOT_UID) < OK) - { - perror("setuid"); - exit(ERROR_EXIT); - } -} -#endif - -void -set_cron_cwd() -{ - extern int errno; - struct stat sb; - - /* first check for CRONDIR ("/var/cron" or some such) - */ - if (stat(CRONDIR, &sb) < OK && errno == ENOENT) { - perror(CRONDIR); - if (OK == mkdir(CRONDIR, 0700)) { - fprintf(stderr, "%s: created\n", CRONDIR); - stat(CRONDIR, &sb); - } else { - fprintf(stderr, "%s: ", CRONDIR); - perror("mkdir"); - exit(ERROR_EXIT); - } - } - if (!(sb.st_mode & S_IFDIR)) { - fprintf(stderr, "'%s' is not a directory, bailing out.\n", - CRONDIR); - exit(ERROR_EXIT); - } - if (chdir(CRONDIR) < OK) { - fprintf(stderr, "cannot chdir(%s), bailing out.\n", CRONDIR); - perror(CRONDIR); - exit(ERROR_EXIT); - } - - /* CRONDIR okay (now==CWD), now look at SPOOL_DIR ("tabs" or some such) - */ - if (stat(SPOOL_DIR, &sb) < OK && errno == ENOENT) { - perror(SPOOL_DIR); - if (OK == mkdir(SPOOL_DIR, 0700)) { - fprintf(stderr, "%s: created\n", SPOOL_DIR); - stat(SPOOL_DIR, &sb); - } else { - fprintf(stderr, "%s: ", SPOOL_DIR); - perror("mkdir"); - exit(ERROR_EXIT); - } - } - if (!(sb.st_mode & S_IFDIR)) { - fprintf(stderr, "'%s' is not a directory, bailing out.\n", - SPOOL_DIR); - exit(ERROR_EXIT); - } -} - - -#if defined(BSD) -void -be_different() -{ - /* release the control terminal: - * get new pgrp (name after our PID) - * do an IOCTL to void tty association - */ - - extern int getpid(), setpgrp(), close(); - auto int fd; - - (void) setpgrp(0, getpid()); - - if ((fd = open("/dev/tty", 2)) >= 0) - { - (void) ioctl(fd, TIOCNOTTY, (char*)0); - (void) close(fd); - } -} -#endif /*BSD*/ - -#if defined(ATT) -void -be_different() -{ - /* not being a system V wiz, I don't know if this is what you have - * to do to release your control terminal. what I want to accomplish - * is to keep this process from getting any signals from the tty. - * - * some system V person should let me know if this works... (vixie) - */ - int setpgrp(), close(), open(); - - (void) setpgrp(); - - (void) close(STDIN); (void) open("/dev/null", 0); - (void) close(STDOUT); (void) open("/dev/null", 1); - (void) close(STDERR); (void) open("/dev/null", 2); -} -#endif /*ATT*/ - - -/* acquire_daemonlock() - write our PID into /etc/crond.pid, unless - * another daemon is already running, which we detect here. - */ -void -acquire_daemonlock() -{ - char pidfile[MAX_FNAME]; - FILE *fp; - int fd, pid = getpid(), otherpid; - char buf[MAX_TEMPSTR]; - - (void) sprintf(pidfile, PIDFILE, PIDDIR); - if ((-1 == (fd = open(pidfile, O_RDWR|O_CREAT, 0644))) - || (NULL == (fp = fdopen(fd, "r+"))) - ) { - sprintf(buf, "can't open or create %s: %s", - pidfile, strerror(errno)); - log_it("CROND", pid, "DEATH", buf); - exit(ERROR_EXIT); - } - - if (flock(fd, LOCK_EX|LOCK_NB) < OK) { - int save_errno = errno; - - fscanf(fp, "%d", &otherpid); - sprintf(buf, "can't lock %s, otherpid may be %d: %s", - pidfile, otherpid, strerror(save_errno)); - log_it("CROND", pid, "DEATH", buf); - exit(ERROR_EXIT); - } - - rewind(fp); - fprintf(fp, "%d\n", pid); - fflush(fp); - (void) ftruncate(fd, ftell(fp)); - (void) fcntl(fd, F_SETFD, 1); - - /* abandon fd and fp even though the file is open. we need to - * keep it open and locked, but we don't need the handles elsewhere. - */ -} - -/* get_char(file) : like getc() but increment LineNumber on newlines - */ -int -get_char(file) - FILE *file; -{ - int ch; - - ch = getc(file); - if (ch == '\n') - Set_LineNum(LineNumber + 1) - return ch; -} - - -/* unget_char(ch, file) : like ungetc but do LineNumber processing - */ -void -unget_char(ch, file) - int ch; - FILE *file; -{ - ungetc(ch, file); - if (ch == '\n') - Set_LineNum(LineNumber - 1) -} - - -/* get_string(str, max, file, termstr) : like fgets() but - * (1) has terminator string which should include \n - * (2) will always leave room for the null - * (3) uses get_char() so LineNumber will be accurate - * (4) returns EOF or terminating character, whichever - */ -int -get_string(string, size, file, terms) - char *string; - int size; - FILE *file; - char *terms; -{ - int ch; - char *index(); - - while (EOF != (ch = get_char(file)) && !index(terms, ch)) - if (size > 1) - { - *string++ = (char) ch; - size--; - } - - if (size > 0) - *string = '\0'; - - return ch; -} - - -/* skip_comments(file) : read past comment (if any) - */ -void -skip_comments(file) - FILE *file; -{ - int ch; - - while (EOF != (ch = get_char(file))) - { - /* ch is now the first character of a line. - */ - - while (ch == ' ' || ch == '\t') - ch = get_char(file); - - if (ch == EOF) - break; - - /* ch is now the first non-blank character of a line. - */ - - if (ch != '\n' && ch != '#') - break; - - /* ch must be a newline or comment as first non-blank - * character on a line. - */ - - while (ch != '\n' && ch != EOF) - ch = get_char(file); - - /* ch is now the newline of a line which we're going to - * ignore. - */ - } - unget_char(ch, file); -} - -/* int in_file(char *string, FILE *file) - * return TRUE if one of the lines in file matches string exactly, - * FALSE otherwise. - */ -int -in_file(string, file) - char *string; - FILE *file; -{ - char line[MAX_TEMPSTR]; - - /* let's be persnickety today. - */ - if (!file) { - if (!string) - string = "0x0"; - fprintf(stderr, - "in_file(\"%s\", 0x%x): called with NULL file--botch", - string, file); - exit(ERROR_EXIT); - } - - rewind(file); - while (fgets(line, MAX_TEMPSTR, file)) { - if (line[0] != '\0') - line[strlen(line)-1] = '\0'; - if (0 == strcmp(line, string)) - return TRUE; - } - return FALSE; -} - - -/* int allowed(char *username) - * returns TRUE if (ALLOW_FILE exists and user is listed) - * or (DENY_FILE exists and user is NOT listed) - * or (neither file exists but user=="root" so it's okay) - */ -int -allowed(username) - char *username; -{ - static int init = FALSE; - static FILE *allow, *deny; - - if (!init) { - init = TRUE; -#if defined(ALLOW_FILE) && defined(DENY_FILE) - allow = fopen(ALLOW_FILE, "r"); - deny = fopen(DENY_FILE, "r"); - Debug(DMISC, ("allow/deny enabled, %d/%d\n", !!allow, !!deny)) -#else - allow = NULL; - deny = NULL; -#endif - } - - if (allow) - return (in_file(username, allow)); - if (deny) - return (!in_file(username, deny)); - -#if defined(ALLOW_ONLY_ROOT) - return (strcmp(username, ROOT_USER) == 0); -#else - return TRUE; -#endif -} - - -void -log_it(username, pid, event, detail) - char *username; - int pid; - char *event; - char *detail; -{ -#if defined(LOG_FILE) - extern struct tm *localtime(); - extern long time(); - extern char *malloc(); - auto char *msg; - auto long now = time((long *) 0); - register struct tm *t = localtime(&now); - static int log_fd = -1; -#endif /*LOG_FILE*/ - -#if defined(SYSLOG) - static int syslog_open = 0; -#endif - - -#if defined(LOG_FILE) - /* we assume that MAX_TEMPSTR will hold the date, time, &punctuation. - */ - msg = malloc(strlen(username) - + strlen(event) - + strlen(detail) - + MAX_TEMPSTR); - - if (log_fd < OK) { - log_fd = open(LOG_FILE, O_WRONLY|O_APPEND|O_CREAT, 0600); - if (log_fd < OK) { - fprintf(stderr, "%s: can't open log file\n", - ProgramName); - perror(LOG_FILE); - } else { - (void) fcntl(log_fd, F_SETFD, 1); - } - } - - /* we have to sprintf() it because fprintf() doesn't always write - * everything out in one chunk and this has to be atomically appended - * to the log file. - */ - sprintf(msg, "%s (%02d/%02d-%02d:%02d:%02d-%d) %s (%s)\n", - username, - t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, pid, - event, detail); - - /* we have to run strlen() because sprintf() returns (char*) on BSD - */ - if (log_fd < OK || write(log_fd, msg, strlen(msg)) < OK) { - fprintf(stderr, "%s: can't write to log file\n", ProgramName); - if (log_fd >= OK) - perror(LOG_FILE); - write(STDERR, msg, strlen(msg)); - } - - /* I suppose we could use alloca()... - */ - free(msg); -#endif /*LOG_FILE*/ - -#if defined(SYSLOG) - if (!syslog_open) { - /* we don't use LOG_PID since the pid passed to us by - * our client may not be our own. therefore we want to - * print the pid ourselves. - */ -# ifdef LOG_CRON - openlog(ProgramName, 0, LOG_CRON); -# else -# ifdef LOG_DAEMON - openlog(ProgramName, 0, LOG_DAEMON); -# else - openlog(ProgramName, 0); -# endif /*LOG_DAEMON*/ -# endif /*LOG_CRON*/ - syslog_open = TRUE; /* assume openlog success */ - } - - syslog(LOG_INFO, "(%s %d) %s (%s)\n", - username, pid, event, detail); - -#endif /*SYSLOG*/ - -#if DEBUGGING - if (DebugFlags) { - fprintf(stderr, "log_it: (%s %d) %s (%s)", - username, pid, event, detail); - } -#endif -} - - -/* two warnings: - * (1) this routine is fairly slow - * (2) it returns a pointer to static storage - */ -char * -first_word(s, t) - local char *s; /* string we want the first word of */ - local char *t; /* terminators, implicitly including \0 */ -{ - static char retbuf[2][MAX_TEMPSTR + 1]; /* sure wish I had GC */ - static int retsel = 0; - local char *rb, *rp; - extern char *index(); - - /* select a return buffer */ - retsel = 1-retsel; - rb = &retbuf[retsel][0]; - rp = rb; - - /* skip any leading terminators */ - while (*s && (NULL != index(t, *s))) {s++;} - - /* copy until next terminator or full buffer */ - while (*s && (NULL == index(t, *s)) && (rp < &rb[MAX_TEMPSTR])) { - *rp++ = *s++; - } - - /* finish the return-string and return it */ - *rp = '\0'; - return rb; -} - - -/* warning: - * heavily ascii-dependent. - */ - -void -mkprint(dst, src, len) - register char *dst; - register unsigned char *src; - register int len; -{ - while (len-- > 0) - { - register unsigned char ch = *src++; - - if (ch < ' ') { /* control character */ - *dst++ = '^'; - *dst++ = ch + '@'; - } else if (ch < 0177) { /* printable */ - *dst++ = ch; - } else if (ch == 0177) { /* delete/rubout */ - *dst++ = '^'; - *dst++ = '?'; - } else { /* parity character */ - sprintf(dst, "\\%03o", ch); - dst += 4; - } - } - *dst = NULL; -} - - -/* warning: - * returns a pointer to malloc'd storage, you must call free yourself. - */ - -char * -mkprints(src, len) - register unsigned char *src; - register unsigned int len; -{ - extern char *malloc(); - register char *dst = malloc(len*4 + 1); - - mkprint(dst, src, len); - - return dst; -} - - -/* Sat, 27 Feb 93 11:44:51 CST - * 123456789012345678901234567 - */ - -char * -arpadate( - time_t *clock -) { - time_t t = clock ?*clock :time(NULL); - struct tm *tm = localtime(&t); - static char ret[30]; /* zone name might be >3 chars */ - - (void) sprintf(ret, "%s, %2d %s %2d %02d:%02d:%02d %s", - DowNames[tm->tm_wday], - tm->tm_mday, - MonthNames[tm->tm_mon], - tm->tm_year, - tm->tm_hour, - tm->tm_min, - tm->tm_sec, - tm->tm_zone); - return ret; -} diff --git a/libexec/crond/user.c b/libexec/crond/user.c deleted file mode 100644 index 05101802f0e8..000000000000 --- a/libexec/crond/user.c +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright 1988,1990 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie, 329 Noe Street, San Francisco, CA, 94114, (415) 864-7013, - * paul@vixie.sf.ca.us || {hoptoad,pacbell,decwrl,crash}!vixie!paul - */ - -#ifndef lint -static char rcsid[] = "$Id: user.c,v 1.5 1993/09/17 03:46:54 cgd Exp $"; -#endif /* not lint */ - - -#include "cron.h" - - -void -free_user(u) - user *u; -{ - void free_entry(); - int free(); - entry *e; - char **env; - - for (e = u->crontab; e != NULL; e = e->next) - free_entry(e); - for (env = u->envp; *env; env++) - (void) free(*env); - (void) free(u->envp); - (void) free(u); -} - - -user * -load_user(crontab_fd, name, uid, gid, dir, shell) - int crontab_fd; - char *name; - int uid; - int gid; - char *dir; - char *shell; -{ - char *malloc(), **env_init(), **env_set(); - int load_env(); - entry *load_entry(); - - char envstr[MAX_ENVSTR]; - FILE *file; - user *u; - entry *e; - int status; - - if (!(file = fdopen(crontab_fd, "r"))) - { - perror("fdopen on crontab_fd in load_user"); - return NULL; - } - - Debug(DPARS, ("load_user()\n")) - - /* file is open. build user entry, then read the crontab file. - */ - u = (user *) malloc(sizeof(user)); - u->uid = uid; - u->gid = gid; - u->envp = env_init(); - u->crontab = NULL; - - /* - * do auto env settings that the user could reset in the cron tab - */ - sprintf(envstr, "SHELL=%s", (*shell) ?shell :"/bin/sh"); - u->envp = env_set(u->envp, envstr); - - sprintf(envstr, "HOME=%s", dir); - u->envp = env_set(u->envp, envstr); - - /* load the crontab - */ - while ((status = load_env(envstr, file)) >= OK) - { - if (status == TRUE) - { - u->envp = env_set(u->envp, envstr); - } - else - { - if (NULL != (e = load_entry(file, NULL))) - { - e->next = u->crontab; - u->crontab = e; - } - } - } - - /* - * do automatic env settings that should have precedence over any - * set in the cron tab. - */ - (void) sprintf(envstr, "%s=%s", USERENV, name); - u->envp = env_set(u->envp, envstr); - - /* - * done. close file, return pointer to 'user' structure - */ - fclose(file); - - Debug(DPARS, ("...load_user() done\n")) - - return u; -} diff --git a/regress/lib/libc/db/hash.tests/tseq.c b/regress/lib/libc/db/hash.tests/tseq.c deleted file mode 100644 index a6e810663f2d..000000000000 --- a/regress/lib/libc/db/hash.tests/tseq.c +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)tseq.c 8.1 (Berkeley) 6/4/93";*/ -static char rcsid[] = "$Id: tseq.c,v 1.3 1993/08/01 18:28:36 mycroft Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - - -char wp[8192]; -char cp[8192]; -main(argc, argv) -char **argv; -{ - DBT item, key, res; - DB *dbp; - FILE *fp; - int stat; - - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, NULL))) { - /* create table */ - fprintf(stderr, "cannot open: hash table\n" ); - exit(1); - } - -/* -* put info in structure, and structure in the item -*/ - for ( stat = (dbp->seq) (dbp, &res, &item, 1 ); - stat == 0; - stat = (dbp->seq) (dbp, &res, &item, 0 ) ) { - - bcopy ( res.data, wp, res.size ); - wp[res.size] = 0; - bcopy ( item.data, cp, item.size ); - cp[item.size] = 0; - - printf ( "%s %s\n", wp, cp ); - } - (dbp->close)(dbp); - exit(0); -} diff --git a/regress/lib/libc/db/hash.tests/tverify.c b/regress/lib/libc/db/hash.tests/tverify.c deleted file mode 100644 index 00d86a0d1df8..000000000000 --- a/regress/lib/libc/db/hash.tests/tverify.c +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1991, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)tverify.c 8.1 (Berkeley) 6/4/93";*/ -static char rcsid[] = "$Id: tverify.c,v 1.3 1993/08/01 18:28:33 mycroft Exp $"; -#endif /* not lint */ - -#include -#include -#include -#include - -#define INITIAL 25000 -#define MAXWORDS 25000 /* # of elements in search table */ - -typedef struct { /* info to be stored */ - int num, siz; -} info; - -char wp1[8192]; -char wp2[8192]; -main(argc, argv) -char **argv; -{ - DBT key, res; - DB *dbp; - HASHINFO ctl; - int trash; - int stat; - - int i = 0; - - ctl.nelem = INITIAL; - ctl.hash = NULL; - ctl.bsize = 64; - ctl.ffactor = 1; - ctl.cachesize = 1024 * 1024; /* 1 MEG */ - ctl.lorder = 0; - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) { - /* create table */ - fprintf(stderr, "cannot open: hash table\n" ); - exit(1); - } - - key.data = wp1; - while ( fgets(wp1, 8192, stdin) && - fgets(wp2, 8192, stdin) && - i++ < MAXWORDS) { -/* -* put info in structure, and structure in the item -*/ - key.size = strlen(wp1); - - stat = (dbp->get)(dbp, &key, &res,0); - if (stat < 0) { - fprintf ( stderr, "Error retrieving %s\n", key.data ); - exit(1); - } else if ( stat > 0 ) { - fprintf ( stderr, "%s not found\n", key.data ); - exit(1); - } - if ( memcmp ( res.data, wp2, res.size ) ) { - fprintf ( stderr, "data for %s is incorrect. Data was %s. Should have been %s\n", key.data, res.data, wp2 ); - } - } - (dbp->close)(dbp); - exit(0); -} diff --git a/sbin/dump/rdump.8 b/sbin/dump/rdump.8 deleted file mode 100644 index 4ff572c7454f..000000000000 --- a/sbin/dump/rdump.8 +++ /dev/null @@ -1,78 +0,0 @@ -.\" Copyright (c) 1983, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)rdump.8 6.3 (Berkeley) 3/16/91 -.\" $Id: rdump.8,v 1.4 1993/08/01 07:39:24 mycroft Exp $ -.\" -.Dd March 16, 1991 -.Dt RDUMP 8 -.Os BSD 4.2 -.Sh NAME -.Nm rdump -.Nd file system dump across the network -.Sh SYNOPSIS -.Nm rdump -.Oo -.Ar flags -.Op Ar argument ... -.Ar filesystem -.Oc -.Sh DESCRIPTION -.Nm Rdump -remotely backs up files across a network in the same manner as -.Xr dump 8 -locally backs up files. -The command is identical in operation to -.Xr dump 8 -except the -.Cm f -key must be specified and the file -.Ar argument -supplied should be of the form -.Pa machine:device . -.Pp -.Nm Rdump -creates a remote server, -.Xr rmt , -on the client machine to access the tape -device. -.Sh SEE ALSO -.Xr dump 8 , -.Xr rmt 8 -.Sh DIAGNOSTICS -Same as -.Xr dump 8 -with a few extra related to the network. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.2 . diff --git a/sbin/mount_miscfs/Makefile b/sbin/mount_miscfs/Makefile deleted file mode 100644 index 7e9bbc820ddd..000000000000 --- a/sbin/mount_miscfs/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -PROG= mount_miscfs -NOMAN= mount_miscfs.0 -LINKS= ${BINDIR}/mount_miscfs ${BINDIR}/mount_devfs \ - ${BINDIR}/mount_miscfs ${BINDIR}/mount_fdesc \ - ${BINDIR}/mount_miscfs ${BINDIR}/mount_kernfs - -.include diff --git a/sbin/mount_miscfs/mount_fdesc.8 b/sbin/mount_miscfs/mount_fdesc.8 deleted file mode 100644 index 5242690b95b8..000000000000 --- a/sbin/mount_miscfs/mount_fdesc.8 +++ /dev/null @@ -1,145 +0,0 @@ -.\" -.\" Copyright (c) 1992 Jan-Simon Pendry -.\" All rights reserved. -.\" -.\" This code is derived from software donated to Berkeley by -.\" Jan-Simon Pendry. -.\" -.\" (Modified for use in NetBSD by cgd) -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $Id: mount_fdesc.8,v 1.1 1993/07/19 23:49:27 cgd Exp $ -.\" -.\" -.Dd March 28, 1993 -.Dt MOUNT_FDESC 8 -.Os NetBSD 0.8a -.Sh NAME -.Nm mount_fdesc -.Nd mount the file-descriptor file system -.Sh SYNOPSIS -.Nm mount_fdesc -.Op Fl F Ar fsoptions -.Pa fdesc -.Pa mount_point -.Sh DESCRIPTION -The -.Nm mount_fdesc -command attaches an instance of the per-process file descriptor -namespace to the global filesystem namespace. -The conventional mount point is -.Pa /dev -and the filesystem should be union mounted in order to augment, -rather than replace, the existing entries in -.Pa /dev . -This command is normally executed by -.Xr mount 8 -at boot time. -.Pp -The contents of the mount point are -.Pa fd , -.Pa stderr , -.Pa stdin , -.Pa stdout -and -.Pa tty . -.Pp -.Pa fd -is a directory whose contents -appear as a list of numbered files -which correspond to the open files of the process reading the -directory. -The files -.Pa /dev/fd/0 -through -.Pa /dev/fd/# -refer to file descriptors which can be accessed through the file -system. -If the file descriptor is open and the mode the file is being opened -with is a subset of the mode of the existing descriptor, the call: -.Bd -literal -offset indent -fd = open("/dev/fd/0", mode); -.Ed -.Pp -and the call: -.Bd -literal -offset indent -fd = fcntl(0, F_DUPFD, 0); -.Ed -.Pp -are equivalent. -.Pp -The files -.Pa /dev/stdin , -.Pa /dev/stdout -and -.Pa /dev/stderr -appear as symlinks to the relevant entry in the -.Pa /dev/fd -sub-directory. -Opening them is equivalent to the following calls: -.Bd -literal -offset indent -fd = fcntl(STDIN_FILENO, F_DUPFD, 0); -fd = fcntl(STDOUT_FILENO, F_DUPFD, 0); -fd = fcntl(STDERR_FILENO, F_DUPFD, 0); -.Ed -.Pp -Flags to the -.Xr open 2 -call other than -.Dv O_RDONLY , -.Dv O_WRONLY -and -.Dv O_RDWR -are ignored. -.Pp -The -.Pa /dev/tty -entry is an indirect reference to the current process's controlling terminal. -It appears as a named pipe (FIFO) but behaves in exactly the same way as -the real controlling terminal device. -.Sh FILES -.Bl -tag -width /dev/stderr -compact -.It Pa /dev/fd/# -.It Pa /dev/stdin -.It Pa /dev/stdout -.It Pa /dev/stderr -.It Pa /dev/tty -.El -.Sh SEE ALSO -.Xr mount 2 , -.Xr unmount 2 , -.Xr tty 4 , -.Xr fstab 5 -.Sh CAVEATS -This filesystem may not be NFS-exported. -.Sh HISTORY -The -.Nm mount_fdesc -utility first appeared in NetBSD 0.8a. diff --git a/sbin/mount_miscfs/mount_kernfs.8 b/sbin/mount_miscfs/mount_kernfs.8 deleted file mode 100644 index 51355a21db5e..000000000000 --- a/sbin/mount_miscfs/mount_kernfs.8 +++ /dev/null @@ -1,115 +0,0 @@ -.\" -.\" Copyright (c) 1992 Jan-Simon Pendry -.\" All rights reserved. -.\" -.\" This code is derived from software donated to Berkeley by -.\" Jan-Simon Pendry. -.\" -.\" (Modified for use in NetBSD by cgd) -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $Id: mount_kernfs.8,v 1.1 1993/07/19 23:49:40 cgd Exp $ -.\" -.Dd March 28, 1993 -.Dt MOUNT_KERNFS 8 -.Os NetBSD 0.8a -.Sh NAME -.Nm mount_kernfs -.Nd mount the /kern file system -.Sh SYNOPSIS -.Nm mount_kernfs -.Op Fl F Ar fsoptions -.Pa /kern -.Pa mount_point -.Sh DESCRIPTION -The -.Nm mount_kern -command attaches an instance of the kernel parameter -namespace to the global filesystem namespace. -The conventional mount point is -.Pa /kern . -This command is normally executed by -.Xr mount 8 -at boot time. -.Pp -The filesystem includes several regular files which can be read, -some of which can also be written. -The contents of the files is in a machine-independent format, -either a string, or an integer in decimal ASCII. -Where numbers are returned, a trailing newline character is also added. -.Sh FILES -.Bl -tag -width copyright -compact -.It Pa copyright -kernel copyright message. -.It Pa hostname -the hostname, with a trailing newline. -The hostname can be changed by writing to this file. -A trailing newline will be stripped from the hostname being written. -.It Pa hz -the frequency of the system clock (decimal ASCII). -.It Pa loadavg -the 1, 5 and 15 minute load average in kernel fixed-point format. -The final integer is the fix-point scaling factor. -All numbers are in decimal ASCII. -.It Pa physmem -the number of pages of physical memory in the machine (decimal ASCII). -.It Pa root -the system root directory. -In a chroot'ed environment, -.Nm -can be used to create a new -.Pa /kern -mount point. -.Pa /kern/root -will then refer to the system global root, not the current process root. -.It Pa rootdev -the root device. -.It Pa rrootdev -the raw root device. -.It Pa time -the second and microsecond value of the system clock. -Both numbers are in decimal ASCII. -.It Pa version -the kernel version string. -The head line for -.Pa /etc/motd -can be generated by running: -.Dq Ic "sed 1q /kern/version" -.El -.Sh SEE ALSO -.Xr mount 2 , -.Xr unmount 2 , -.Xr fstab 5 -.Sh CAVEATS -This filesystem may not be NFS-exported. -.Sh HISTORY -The -.Nm mount_kernfs -utility first appeared in NetBSD 0.8a. diff --git a/sbin/mount_miscfs/mount_miscfs.c b/sbin/mount_miscfs/mount_miscfs.c deleted file mode 100644 index 30b74aca4ebe..000000000000 --- a/sbin/mount_miscfs/mount_miscfs.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 1993 Christoher G. Demetriou - * Copyright (c) 1990, 1992 Jan-Simon Pendry - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id: mount_miscfs.c,v 1.1 1993/03/28 03:19:41 cgd Exp $ - */ - -#include -#include -#include -#include -#include - -main(c, v) -int c; -char *v[]; -{ - extern char *optarg; - extern int optind; - int ch; - int usage = 0; - int mounttype, mntflags; - char *dummy; - char *mountpt; - int rc; - char *pname; - - pname = strrchr(v[0], '/'); - if (pname == NULL) - pname = v[0]; - else - pname++; - -#ifdef MOUNT_DEVFS - if (!strcmp(pname, "devfs")) - mounttype = MOUNT_DEVFS; - else -#endif -#ifdef MOUNT_FDESC - if (!strcmp(pname, "fdesc")) - mounttype = MOUNT_FDESC; - else -#endif -#ifdef MOUNT_KERNFS - if (!strcmp(pname, "kernfs")) - mounttype = MOUNT_KERNFS; - else -#endif - usage++; - - /* - * Crack -F option - */ - while ((ch = getopt(c, v, "F:")) != EOF) - switch (ch) { - case 'F': - mntflags = atoi(optarg); - break; - default: - case '?': - usage++; - break; - } - - /* - * Need two more arguments - */ - if (optind != (c - 2)) - usage++; - - if (usage) { - fputs("usage:\n", stderr); -#if defined(MOUNT_DEVFS) || defined(MOUNT_FDESC) || defined(MOUNT_KERNFS) -#ifdef MOUNT_DEVFS - fputs(" mount_devfs [ fsoptions ] devfs mount-point\n", stderr); -#endif -#ifdef MOUNT_FDESC - fputs(" mount_fdesc [ fsoptions ] fdesc mount-point\n", stderr); -#endif -#ifdef MOUNT_KERNFS - fputs(" mount_kernfs [ fsoptions ] kernfs mount-point\n", stderr); -#endif -#else /* none of the filesystem types defined */ - fputs(" no valid uses!!!\n", stderr); -#endif - exit(1); - } - - /* - * Get target and mount point - */ - dummy = v[optind]; - mountpt = v[optind+1]; - - rc = mount(mounttype, mountpt, mntflags, (caddr_t) 0); - if (rc < 0) { - perror(pname); - exit(1); - } - exit(0); -} diff --git a/share/doc/ps1/04.pascal/comments.p b/share/doc/ps1/04.pascal/comments.p deleted file mode 100644 index b07ddfc6bd22..000000000000 --- a/share/doc/ps1/04.pascal/comments.p +++ /dev/null @@ -1,18 +0,0 @@ -{ This is a left marginal comment. } -program hello(output); -var i : integer; {This is a trailing comment} -j : integer; {This is a right marginal comment} -k : array [ 1..10] of array [1..10] of integer; {Marginal, but past the margin} -{ - An aligned, multi-line comment - which explains what this program is - all about -} -begin -i := 1; {Trailing i comment} -{A left marginal comment} - {An aligned comment} -j := 1; {Right marginal comment} -k[1] := 1; -writeln(i, j, k[1]) -end. diff --git a/share/doc/ps1/04.pascal/copydata.p b/share/doc/ps1/04.pascal/copydata.p deleted file mode 100644 index ecf237c0525e..000000000000 --- a/share/doc/ps1/04.pascal/copydata.p +++ /dev/null @@ -1,15 +0,0 @@ -program copydata(data, output); -var - ch: char; - data: text; -begin - reset(data); - while not eof(data) do begin - while not eoln(data) do begin - read(data, ch); - write(ch) - end; - readln(data); - writeln - end -end { copydata }. diff --git a/share/doc/ps1/04.pascal/csfix.c b/share/doc/ps1/04.pascal/csfix.c deleted file mode 100644 index 14485536c6e9..000000000000 --- a/share/doc/ps1/04.pascal/csfix.c +++ /dev/null @@ -1,219 +0,0 @@ -/*- - * Copyright (c) 1980 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -char copyright[] = -"@(#) Copyright (c) 1980 The Regents of the University of California.\n\ - All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -/*static char sccsid[] = "from: @(#)csfix.c 6.3 (Berkeley) 4/17/91";*/ -static char rcsid[] = "$Id: csfix.c,v 1.2 1993/08/01 18:23:36 mycroft Exp $"; -#endif /* not lint */ - -#include -/* - * csfix - fix constant spacing for error message flags in troff - * - * Bill Joy UCB September 11, 1977 - * - * This would be better written in snobol! - * - * Normally fixes error flags in a pi listing - * Optional - causes fixing of '---' and initial blank widthin a pxp profile. - */ - -char flag, dflag; - -main(argc, argv) - int argc; - char *argv[]; -{ - - argc--, argv++; - if (argc > 0 && argv[0][0] == '-' && argv[0][1] == 'd') - dflag++, argc--, argv++; - if (argc > 0 && argv[0][0] == '-') - flag++, argc--, argv++; - if (argc != 0) { - write(2, "Usage: csfix\n", 13); - exit(1); - } - while (getline()) { - if (errline()) { - flag ? fixpxp() : reformat(); - continue; - } - if (flag) { - fixdigits(); - continue; - } - if (spwarn()) - continue; - if (nontriv()) - save(); - if (dflag) - fixdigits(); - else - putline(); - } - exit(0); -} - -char line[160], flagee[160], *digitty(); - -getline() -{ - register char *cp, c; - - for (cp = line, c = getchar(); c != '\n' && c != EOF; c = getchar()) - *cp++ = c; - if (c == EOF) - return (0); - *cp = 0; - return (1); -} - -errline() -{ - register int i; - register char *cp; - - for (cp = line; cp[0] && cp[1] && cp[2]; cp++) - if (cp[0] == '-' && cp[1] == '-' && cp[2] == '-') - return (1); - return (0); -} - -reformat() -{ - register char *cp, c, *tail; - - printf("%2.2s", line); - if (line[0] != 'w') - printf("\\l'\\w`w `u-\\w`%2.2s`u '", line); - for (cp = line; *cp != 0 && *cp != '^'; cp++) - continue; - tail = cp + 1; - if (cp[-1] == '\b' && cp[-2] == '|') - cp -= 2; - c = flagee[cp - line]; - flagee[cp - line] = 0; - printf("\\l'\\w`%s`u-\\w`w `u\\&\\(rh'", flagee); - flagee[cp - line] = c; - if (c == '\0') - c = flagee[cp - line - 1]; - printf("\\l'(\\w`%c`u-\\w`^`u)/2 '", c); - printf("\\(ua"); - printf("\\l'(\\w`%c`u-\\w`^`u)/2 '", c); - printf("\\l'\\w`---`u\\&\\(rh'%s\n", tail+3); -} - -nontriv() -{ - - switch (line[0]) { - case 'E': - case 'e': - case 'w': - case 's': - case 0: - return (0); - } - return (1); -} - -save() -{ - - strcpy(flagee, line); -} - -putline() -{ - - printf("%s\n", flag ? digitty(0) : line); -} - -spwarn() -{ - - if (line[0] != ' ' || line[1] != ' ' || line[2] != 'w') - return (0); - printf(" \\l'(\\w`E`u-\\w`w`u)/2 'w\\l'(\\w`E`u-\\w`w`u)/2 '"); - printf(&line[3]); - printf("\n"); - return (1); -} - -fixpxp() -{ - register char *cp; - - for (cp = line; *cp != '-'; cp++) - continue; - *cp = 0; - printf("%s\\l'\\w`\\0\\0\\0\\0`u-\\w`.`u\\&\\(rh'%s\n", digitty(1), cp + 3); -} - -char * -digitty(yup) - char yup; -{ - register char *cp, *dp, *lp; - - for (lp = line; *lp && *lp != '|'; lp++) - continue; - if (yup == 0 && !*lp) - return (line); - for (cp = line, dp = flagee; cp < lp; cp++) - if (*cp == ' ') - *dp++ = '\\', *dp++ = '0'; - else - *dp++ = *cp; - strcpy(dp, cp); - return (flagee); -} - -fixdigits() -{ - register char *cp, c; - - for (cp = line; *cp == ' ' || *cp >= '0' && *cp <= '9'; cp++) - continue; - c = *cp, *cp = 0; - digitty(1); - *cp = c; - printf("%s%s\n", flagee, cp); -} diff --git a/share/doc/ps1/04.pascal/data b/share/doc/ps1/04.pascal/data deleted file mode 100644 index 3f9cfb50caaf..000000000000 --- a/share/doc/ps1/04.pascal/data +++ /dev/null @@ -1,3 +0,0 @@ -line one. -line two. -line three is the end. diff --git a/share/doc/ps1/04.pascal/digits.p b/share/doc/ps1/04.pascal/digits.p deleted file mode 100644 index 1e59d8dafbca..000000000000 --- a/share/doc/ps1/04.pascal/digits.p +++ /dev/null @@ -1,9 +0,0 @@ -program digits(output); -var r: real; -begin -r := 0.; -r := .0; -r := 1.e10; -r := .05e-10; -writeln(r) -end. diff --git a/share/doc/ps1/04.pascal/expr.p b/share/doc/ps1/04.pascal/expr.p deleted file mode 100644 index 60109af8c75b..000000000000 --- a/share/doc/ps1/04.pascal/expr.p +++ /dev/null @@ -1,21 +0,0 @@ -program x(output); -var - a: set of char; - b: Boolean; - c: (red, green, blue); - p: ^ integer; - A: alfa; - B: packed array [1..5] of char; -begin - b := true; - c := red; - new(p); - a := []; - A := 'Hello, yellow'; - b := a and b; - a := a * 3; - if input < 2 then writeln('boo'); - if p <= 2 then writeln('sure nuff'); - if A = B then writeln('same'); - if c = true then writeln('hue''s and color''s') -end. diff --git a/share/doc/ps1/04.pascal/first.p b/share/doc/ps1/04.pascal/first.p deleted file mode 100644 index 19196944e848..000000000000 --- a/share/doc/ps1/04.pascal/first.p +++ /dev/null @@ -1,4 +0,0 @@ -program first(output) -begin - writeln('Hello, world!') -end. diff --git a/share/doc/ps1/04.pascal/fixcomments b/share/doc/ps1/04.pascal/fixcomments deleted file mode 100644 index 5201c8f7eb0a..000000000000 --- a/share/doc/ps1/04.pascal/fixcomments +++ /dev/null @@ -1,6 +0,0 @@ -1i -.ta 3.25i -. -g/ *{/s// {/ -w -q diff --git a/share/doc/ps1/04.pascal/fixkatscript b/share/doc/ps1/04.pascal/fixkatscript deleted file mode 100644 index 73948198de1c..000000000000 --- a/share/doc/ps1/04.pascal/fixkatscript +++ /dev/null @@ -1,6 +0,0 @@ -1t1 -1s/.*/\\*b&\\fR/ -3t3 -3s/.*/\\*b&\\fR/ -w -q diff --git a/share/doc/ps1/04.pascal/kat.p b/share/doc/ps1/04.pascal/kat.p deleted file mode 100644 index 6d804533e089..000000000000 --- a/share/doc/ps1/04.pascal/kat.p +++ /dev/null @@ -1,13 +0,0 @@ -program kat(input, output); -var - ch: char; -begin - while not eof do begin - while not eoln do begin - read(ch); - write(ch) - end; - readln; - writeln - end -end { kat }. diff --git a/share/doc/ps1/04.pascal/kat2.p b/share/doc/ps1/04.pascal/kat2.p deleted file mode 100644 index 0dbc01a125d1..000000000000 --- a/share/doc/ps1/04.pascal/kat2.p +++ /dev/null @@ -1,23 +0,0 @@ -program kat(input, output); -var - ch: char; - i: integer; - name: packed array [1..100] of char; -begin - i := 1; - repeat - if i < argc then begin - argv(i, name); - reset(input, name); - i := i + 1 - end; - while not eof do begin - while not eoln do begin - read(ch); - write(ch) - end; - readln; - writeln - end - until i >= argc -end { kat }. diff --git a/share/doc/ps1/04.pascal/kat3.p b/share/doc/ps1/04.pascal/kat3.p deleted file mode 100644 index 411205caf745..000000000000 --- a/share/doc/ps1/04.pascal/kat3.p +++ /dev/null @@ -1,23 +0,0 @@ -program kat(input, output); -var - ch: char; - i: integer; - name: packed array [1..100] of char; -begin - i := 1; - repeat - if i < argc then begin - argv(i, name); - reset(input, name); - i := i + 1 - end; - while not eof do begin - while not eoln do begin - read(ch); - write(ch) - end; - readln; - writeln - end - until i >= argc -end { kat }. diff --git a/share/doc/ps1/04.pascal/katin b/share/doc/ps1/04.pascal/katin deleted file mode 100644 index 220793bf91ae..000000000000 --- a/share/doc/ps1/04.pascal/katin +++ /dev/null @@ -1,2 +0,0 @@ -This is a line of text. -The next line contains only an end-of-file (an invisible control-d!) diff --git a/share/doc/ps1/04.pascal/mism.p b/share/doc/ps1/04.pascal/mism.p deleted file mode 100644 index a690b1e7d3a1..000000000000 --- a/share/doc/ps1/04.pascal/mism.p +++ /dev/null @@ -1,5 +0,0 @@ -program mismatch(output) -begin - writeln('***'); - { The next line is the last line in the file } - writeln diff --git a/share/doc/ps1/04.pascal/primes.p b/share/doc/ps1/04.pascal/primes.p deleted file mode 100644 index d840390159f7..000000000000 --- a/share/doc/ps1/04.pascal/primes.p +++ /dev/null @@ -1,30 +0,0 @@ -program primes(output); -const n = 50; n1 = 7; (*n1 = sqrt(n)*) -var i,k,x,inc,lim,square,l: integer; - prim: boolean; - p,v: array[1..n1] of integer; -begin - write(2:6, 3:6); l := 2; - x := 1; inc := 4; lim := 1; square := 9; - for i := 3 to n do - begin (*find next prime*) - repeat x := x + inc; inc := 6-inc; - if square <= x then - begin lim := lim+1; - v[lim] := square; square := sqr(p[lim+1]) - end ; - k := 2; prim := true; - while prim and (k v[k] - end - until prim; - if i <= n1 then p[i] := x; - write(x:6); l := l+1; - if l = 10 then - begin writeln; l := 0 - end - end ; - writeln; -end . diff --git a/share/doc/ps1/04.pascal/primes2.p b/share/doc/ps1/04.pascal/primes2.p deleted file mode 100644 index 7693de81c485..000000000000 --- a/share/doc/ps1/04.pascal/primes2.p +++ /dev/null @@ -1,30 +0,0 @@ -program primes(output); -const n = 50; n1 = 6; (*n1 = sqrt(n)*) -var i,k,x,inc,lim,square,l: integer; - prim: boolean; - p,v: array[1..n1] of integer; -begin - write(2:6, 3:6); l := 2; - x := 1; inc := 4; lim := 1; square := 9; - for i := 3 to n do - begin (*find next prime*) - repeat x := x + inc; inc := 6-inc; - if square <= x then - begin lim := lim+1; - v[lim] := square; square := sqr(p[lim+1]) - end ; - k := 2; prim := true; - while prim and (k v[k] - end - until prim; - if i <= n1 then p[i] := x; - write(x:6); l := l+1; - if l = 10 then - begin writeln; l := 0 - end - end ; - writeln; -end . diff --git a/share/doc/ps1/04.pascal/puman0.n b/share/doc/ps1/04.pascal/puman0.n deleted file mode 100644 index 3967371d4788..000000000000 --- a/share/doc/ps1/04.pascal/puman0.n +++ /dev/null @@ -1,154 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)puman0.n 6.3 (Berkeley) 4/17/91 -.\" -.so tmac.p -.EH 'PS1:4-%''Berkeley Pascal User\'s Manual' -.OH 'Berkeley Pascal User\'s Manual''PS1:4-%' -.TL -Berkeley Pascal User's Manual -.br -Version 3.1 \- April 1986 -.AU -William N. Joy\(dd, Susan L. Graham, Charles B. Haley\(dd, -Marshall Kirk McKusick, and Peter B. Kessler\(dd -.AI -Computer Science Division -.if n Department of Electrical Engineering -.if n and Computer Science -.if t Department of Electrical Engineering and Computer Science -University of California, Berkeley -Berkeley, California 94720 -...AI -...MH -.AB -.FS -Copyright 1977, 1979, 1980, 1983 -W. N. Joy, S. L. Graham, C. B. Haley, M. K. McKusick, P. B. Kessler -.FE -.FS -\(ddAuthor's current addresses: -William Joy: Sun Microsystems, 2550 Garcia Ave., Mountain View, CA 94043; -Charles Haley: S & B Associates, 1110 Centennial Ave., Piscataway, NJ 08854; -Peter Kessler: Xerox Research Park, Palo Alto, CA -.FE -.PP -Berkeley -Pascal -is designed for interactive instructional use -and runs on the \s-2PDP\s0/11 and \s-2VAX\s0/11 computers. -Interpretive code is produced, -providing fast translation at the expense of slower execution speed. -There is also a fully compatible compiler for the \s-2VAX\s0/11. -An execution profiler and -Wirth's cross reference program are also -available with the system. -.PP -The system supports full Pascal. -The language accepted is -`standard' Pascal, -and a small number of extensions. -There is an option to suppress the extensions. -The extensions include a separate compilation facility -and the ability to link to object modules -produced from other source languages. -.PP -The -.UM -gives a list of sources relating to the -.UX -system, the Pascal language, and the -.UP -system. -Basic usage examples are provided for the Pascal components -.PI , -.X , -.IX , -.PC , -and -.XP . -Errors commonly encountered in these programs are discussed. -Details are given of special considerations due to the -interactive implementation. -A number of examples are provided including many dealing with -input/output. An appendix supplements Wirth's -.I "Pascal Report" -to form the full definition of the Berkeley implementation of the language. -.AE -.sp -.SH -'if n 'ND -Introduction -.PP -The -.UP -.UM -consists of five major sections and an appendix. -In section 1 we give sources of information about -.UX , -about the programming -language Pascal, and about the -Berkeley -implementation of the language. -Section 2 introduces the -Berkeley -implementation and provides a number of tutorial examples. -Section 3 discusses the error diagnostics produced by the translators -.PC -and -.PI , -and the runtime interpreter -.X . -Section 4 describes input/output with special attention given to features -of the interactive implementation and to features unique to -.UX . -Section 5 gives details on the components of the system -and explanation of all relevant options. -The -.UM -concludes with an appendix to Wirth's -.I "Pascal Report" -with which it forms a precise definition of the implementation. -.SH -History of the implementation -.PP -The first -Berkeley -system was written by Ken Thompson in early 1976. -The main features of the present system were implemented by -Charles Haley and William Joy during the latter half of 1976. -Earlier versions of this system have been in use since January, 1977. -.PP -The system was moved to the \s-2VAX\s0-11 -by Peter Kessler and Kirk McKusick -with the porting of the interpreter in the spring of 1979, -and the implementation of the compiler in the summer of 1980. diff --git a/share/doc/ps1/04.pascal/puman1.n b/share/doc/ps1/04.pascal/puman1.n deleted file mode 100644 index f4a72f31d3b4..000000000000 --- a/share/doc/ps1/04.pascal/puman1.n +++ /dev/null @@ -1,449 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)puman1.n 6.2 (Berkeley) 4/17/91 -.\" -.if !\n(xx \{\ -.so tmac.p \} -.if n 'ND -'nr H1 0 -.NH -Sources of information -.PP -This section lists the resources available -for information about -general features of -.UX , -text editing, -the Pascal language, -and the -.UP -implementation, -concluding with a list of references. -The available documents include both so-called standard documents \- -those distributed with all -.UX -system \- -and documents (such as this one) written at Berkeley. -.NH 2 -Where to get documentation -.PP -Current documentation for most of the -.UX -system is available ``on line'' at your terminal. -Details on getting such documentation interactively are given -in section 1.3. -.NH 2 -Documentation describing UNIX -.PP -The following documents are those recommended as tutorial and -reference material about the -.UX -system. -We give the documents with the introductory and tutorial materials -first, the reference materials last. -.SH -UNIX For Beginners \- Second Edition -.PP -This document is the basic tutorial for -.UX -available with the standard system. -.SH -Communicating with UNIX -.PP -This is also a basic tutorial on the system and assumes -no previous familiarity -with computers; it was written at Berkeley. -.SH -An introduction to the C shell -.PP -This document introduces -.I csh, -the shell in common use at Berkeley, and provides a good deal of general -description about the way in which the system functions. -It provides a useful glossary of terms used in discussing the system. -.SH -UNIX Programmer's Manual -.PP -This manual is the major source of details on the components of the -.UX -system. -It consists of an Introduction, -a permuted index, -and eight command sections. -Section 1 consists of descriptions of most of the ``commands'' -of -.UX . -Most of the other sections have limited relevance to the user -of -Berkeley -Pascal, being of interest mainly to system programmers. -.PP -U\s-2NIX\s0 -documentation often refers the reader to sections of the manual. -Such a reference consists of a command name and a section number or name. -An example of such a reference would be: -.I ed -(1). -Here -.I ed -is a command name \- the standard -.UX -text editor, and `(1)' indicates that its documentation is in section 1 of the -manual. -.PP -The pieces of the -Berkeley -Pascal system are -.I pi -(1), -.X -(1), -the combined Pascal translator and interpretive executor -.IX -(1), -the Pascal compiler -.PC -(1), -the Pascal execution profiler -.XP -(1), -and -the Pascal cross-reference generator -.I pxref -(1). -.PP -It is possible to obtain a copy of a manual section -by using the -.I man -(1) command. -To get the Pascal documentation just described one could issue the -command: -.LS -% \*bman pi\fP -.LE -to the shell. -The user input here is shown in -.B "bold face" ; -the `% ', -which was printed by the shell as a prompt, -is not. -Similarly the command: -.LS -% \*bman man\fP -.LE -asks the -.I man -command to describe itself. -.NH 2 -Text editing documents -.PP -The following documents introduce the various -.UX -text editors. -Most Berkeley users use a version of the text editor -.I ex; -either -.I edit, -which is a version of -.I ex -for new and casual users, -.I ex -itself, -or -.I vi -(visual) which focuses on the display editing portion of -.I ex. -.SH -A Tutorial Introduction to the UNIX Text Editor -.PP -This document, written by Brian Kernighan of Bell Laboratories, -is a tutorial for the standard -.UX -text editor -.I ed. -It introduces you to the basics of text editing, -and provides enough information to meet day-to-day editing needs, -for -.I ed -users. -.SH -Edit: A tutorial -.PP -This introduces the use of -.I edit, -an editor similar to -.I ed -which provides a more hospitable environment for beginning users. -.SH -Ex/edit Command Summary -.PP -This summarizes the features of the editors -.I ex -and -.I edit -in a concise form. If you have used a line oriented editor before -this summary alone may be enough to get you started. -.SH -Ex Reference Manual \- Version 3.7 -.PP -A complete reference on the features of -.I ex -and -.I edit. -.SH -An Introduction to Display Editing with Vi -.PP -.I Vi -is a display oriented text editor. It can be used on most any \s-2CRT\s0 -terminal, -and uses the screen as a window into the file you are editing. Changes -you make to the file are reflected in what you see. This manual serves -both as an introduction to editing with -.I vi -and a reference manual. -.SH -Vi Quick Reference -.PP -This reference card is a handy quick guide to -.I vi; -you should get one when you get the introduction to -.I vi. -.NH 2 -Pascal documents \- The language -.PP -This section describes the documents on the Pascal language -which are likely to be most useful to the -Berkeley -Pascal user. -Complete references for these documents are given in section 1.7. -.SH -Pascal User Manual -.PP -By Kathleen Jensen and Niklaus Wirth, the -.I "User Manual" -provides a tutorial introduction to the features -of the language Pascal, -and serves as an excellent quick-reference to the language. -The reader with no familiarity with Algol-like languages -may prefer one of the Pascal text books listed below, -as they provide more examples and explanation. -Particularly important here are pages 116-118 which define the syntax -of the language. -Sections 13 and 14 and Appendix F pertain only to the -6000-3.4 implementation of Pascal. -.SH -Pascal Report -.PP -By Niklaus Wirth, this document is bound with the -.I "User Manual." -It is the guiding reference for implementors and the fundamental -definition of the language. -Some programmers find this report too concise to be of practical use, -preferring the -.I "User Manual" -as a reference. -.SH -Books on Pascal -.PP -Several good books which teach Pascal or use it as a medium are -available. -The books by Wirth -.I "Systematic Programming" -and -.I "Algorithms + Data Structures = Programs" -use Pascal as a vehicle for teaching programming and data structure -concepts respectively. -They are both recommended. -Other books on Pascal are listed in the references below. -.NH 2 -Pascal documents \- The Berkeley Implementation -.PP -This section describes the documentation which is available -describing the -Berkeley -implementation of Pascal. -.SH -User's Manual -.PP -The document you are reading is the -.I "User's Manual" -for -.UP . -We often refer the reader to the -Jensen-Wirth -.I "User Manual" -mentioned above, -a different document with a similar name. -.SH -Manual sections -.PP -The sections relating to Pascal in the -.I "UNIX Programmer's Manual" -are -.IX -(1), -.PI -(1), -.PC -(1), -.X -(1), -.I pxp -(1), -and -.I pxref -(1). -These sections give a description of each program, -summarize the available options, -indicate files used by the program, -give basic information on the diagnostics produced -and include a list of known bugs. -.SH -Implementation notes -.PP -For those interested in the internal organization of the -Berkeley -Pascal system there are a series of -.I "Implementation Notes" -describing these details. -The -.I "Berkeley Pascal PXP Implementation Notes" -describe the Pascal interpreter -.X \|; -and the -.I "Berkeley Pascal PX Implementation Notes" -describe the structure of the -execution profiler -.I pxp . -.br -.ne 8 -.NH 2 -References -.de re -.sp -.IP -'nf -.. -.SH -UNIX Documents -.re -.I "Communicating With UNIX" -Computer Center -University of California, Berkeley -January, 1978. -.re -Ricki Blau and James Joyce -.I "Edit: a tutorial" -UNIX User's Supplementary Documents (USD), 14 -University of California, Berkeley, CA. 94720 -April, 1986. -.re -.I "Ex/edit Command Summary" -Computer Center -University of California, Berkeley -August, 1978. -.re -William Joy -.I "Ex Reference Manual \- Version 3.7" -UNIX User's Supplementary Documents (USD), 16 -University of California, Berkeley, CA. 94720 -April, 1986. -.re -William Joy -.I "An Introduction to Display Editing with Vi" -UNIX User's Supplementary Documents (USD), 15 -University of California, Berkeley, CA. 94720 -April, 1986. -.re -William Joy -.I "An Introduction to the C shell (Revised)" -UNIX User's Supplementary Documents (USD), 4 -University of California, Berkeley, CA. 94720 -April, 1986. -.re -Brian W. Kernighan -.I "UNIX for Beginners \- Second Edition" -UNIX User's Supplementary Documents (USD), 1 -University of California, Berkeley, CA. 94720 -April, 1986. -.re -Brian W. Kernighan -.I "A Tutorial Introduction to the UNIX Text Editor" -UNIX User's Supplementary Documents (USD), 12 -University of California, Berkeley, CA. 94720 -April, 1986. -.re -Dennis M. Ritchie and Ken Thompson -.I "The UNIX Time Sharing System" -Reprinted from Communications of the ACM July 1974 in -UNIX Programmer's Supplementary Documents, Volume 2 (PS2), 1 -University of California, Berkeley, CA. 94720 -April, 1986. -.SH -Pascal Language Documents -.re -Cooper and Clancy -.I "Oh! Pascal!, 2nd Edition" -W. W. Norton & Company, Inc. -500 Fifth Ave., NY, NY. 10110 -1985, 475 pp. -.re -Cooper -.I "Standard Pascal User Reference Manual" -W. W. Norton & Company, Inc. -500 Fifth Ave., NY, NY. 10110 -1983, 176 pp. -.re -Kathleen Jensen and Niklaus Wirth -.I "Pascal \- User Manual and Report" -Springer-Verlag, New York. -1975, 167 pp. -.re -Niklaus Wirth -.I "Algorithms + Data structures = Programs" -Prentice-Hall, New York. -1976, 366 pp. -.SH -Berkeley Pascal documents -.PP -The following documents are available from the Computer Center Library -at the University of California, Berkeley. -.nf -.re -William N. Joy -.I "Berkeley Pascal PX Implementation Notes" -Version 1.1, April 1979. -(Vax-11 Version 2.0 By Kirk McKusick, December, 1979) -.re -William N. Joy -.I "Berkeley Pascal PXP Implementation Notes" -Version 1.1, April 1979. diff --git a/share/doc/ps1/04.pascal/puman2.n b/share/doc/ps1/04.pascal/puman2.n deleted file mode 100644 index 3d9b6966c18a..000000000000 --- a/share/doc/ps1/04.pascal/puman2.n +++ /dev/null @@ -1,858 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)puman2.n 6.3 (Berkeley) 4/17/91 -.\" -.if !\n(xx \{\ -.so tmac.p \} -'if n 'ND -.nr H1 1 -.NH -Basic UNIX Pascal -.PP -The following sections -explain the basics of using -.UP . -In examples here we use the text editor -.I ex -(1). -Users of the text editor -.I ed -should have little trouble following these examples, -as -.I ex -is similar to -.I ed . -We use -.I ex -because it -allows us to make clearer examples.\(dg -.FS -\(dg Users with \s-2CRT\s0 terminals should find the editor -.I vi -more pleasant to use; -we do not show its use here because its display oriented nature -makes it difficult to illustrate. -.FE -The new -.UX -user will find it helpful to read one of the text editor documents -described in section 1.4 before continuing with this section. -.NH 2 -A first program -.PP -To prepare a program for -.UP -we first need to have an account on -.UX -and to `login' -to the system on this account. -These procedures are described in the documents -.I "Communicating with UNIX" -and -.I "UNIX for Beginners". -.PP -Once we are logged in we need to choose a name for our program; -let us call it `first' as this is the first example. -We must also choose a name for the file in which the program will be stored. -The -.UP -system requires that programs reside in files which have names ending with -the sequence `.p' so we will call our file `first.p'. -.PP -A sample editing session to create this file would begin: -.LS -% \*bex first.p\fR -"first.p" [New file] -: -.LE -We didn't expect the file to exist, so the error diagnostic doesn't -bother us. -The editor now knows the name of the file we are creating. -The `:' prompt indicates that it is ready for command input. -We can add the text for our program using the `append' -command as follows. -.LS -:\*bappend\fR -.B -program first(output) -begin - writeln('Hello, world!') -end. -\&. -.R -: -.LE -The line containing the single `\*b.\fR' character here indicated -the end of the appended text. -The `:' prompt indicates that -.I ex -is ready for another command. -As the editor operates in a temporary work space we must now store the contents -of this work space in the file `first.p' -so we can use the Pascal -translator and executor -.IX -on it. -.LS -:\*bwrite\fR -"first.p" [New file] 4 lines, 59 characters -:\*bquit\fR -% -.LE -We wrote out the file from the edit buffer here with the -`write' -command, and -.I ex -indicated the number of lines and characters written. -We then quit the editor, and now have a prompt from the shell.\(dd -.FS -\(dd Our examples here assume you are using -.I csh. -.FE -.KS -.PP -We are ready to try -to translate and execute our program. -.DS -.tr '\(aa^\(ua -% \*bpix first.p\fR -.so firstout -.tr ''^^ -% -.DE -.KE -.PP -The translator first printed a syntax error diagnostic. -The number 2 here indicates that the rest of the line is an image -of the second line of our program. -The translator is saying that it expected to find a `;' before the -keyword -.B begin -on this line. -If we look at the Pascal syntax charts in the Jensen-Wirth -.I "User Manual" , -or at some of the sample programs therein, we will see that -we have omitted the terminating `;' of the -.B program -statement on the first -line of our program. -.PP -One other thing to notice about the error diagnostic is the letter `e' -at the beginning. -It stands for `error', -indicating that our input was not legal Pascal. -The fact that it is an `e' rather than an `E' -indicates that the translator managed to recover from this error well -enough that generation of code and execution could take place. -Execution is possible whenever no fatal `E' errors -occur during translation. -The other classes of diagnostics are `w' warnings, -which do not necessarily indicate errors in the program, -but point out inconsistencies which are likely to be due to program bugs, -and `s' standard-Pascal violations.\*(dg -.FS -\*(dgThe standard Pascal warnings occur only when the associated -.B s -translator option is enabled. -The -.B s -option is discussed in sections 5.1 and A.6 below. -Warning diagnostics are discussed at the end of section 3.2, -the associated -.B w -option is described in section 5.2. -.FE -.PP -After completing the translation of the program to interpretive code, -the Pascal system indicates that execution of the translated program began. -The output from the execution of the program then appeared. -At program termination, the Pascal runtime system indicated the -number of statements executed, and the amount of cpu time -used, with the resolution of the latter being 1/60'th of a second. -.PP -Let us now fix the error in the program and translate it to a permanent -object code file -.I obj -using -.PI . -The program -.PI -translates Pascal programs but stores the object code instead of executing it\*(dd. -.FS -\*(ddThis script indicates some other useful approaches to debugging -Pascal programs. -As in -.I ed -we can shorten commands in -.I ex -to an initial prefix of the command name as we did -with the -.I substitute -command here. -We have also used the `!' shell escape command here to execute other -commands with a shell without leaving the editor. -.FE -.LS -% \*bex first.p\fR -"first.p" 4 lines, 59 characters -:\*b1 print\fR -program first(output) -:\*bs/$/;\fR -program first(output); -:\*bwrite\fR -"first.p" 4 lines, 60 characters -:\*bquit\fR -% \*bpi first.p\fR -% -.LE -If we now use the -.UX -.I ls -list files command we can see what files we have: -.LS -% \*bls\fR -first.p -obj -% -.LE -The file `obj' here contains the Pascal interpreter code. -We can execute this by typing: -.LS -% \*bpx obj\fR -.so firstobjout -% -.LE -Alternatively, the command: -.LS -% \*bobj\fR -.LE -will have the same effect. -Some examples of different ways to execute the program follow. -.LS -% \*bpx\fR -.so firstobjout -% \*bpi -p first.p\fR -% \*bpx obj\fR -.so firstobjout2 -% \*bpix -p first.p\fR -.so firstobjout2 -% -.LE -.PP -Note that -.I px -will assume that `obj' is the file we wish to execute -if we don't tell it otherwise. -The last two translations use the -.B \-p -no-post-mortem option to eliminate -execution statistics and -`Execution begins' -and -`Execution terminated' -messages. -See section 5.2 for more details. -If we now look at the files in our directory we will see: -.LS -% \*bls\fR -first.p -obj -% -.LE -We can give our object program a name other than `obj' by using the move -command -.I mv -(1). -Thus to name our program `hello': -.LS -% \*bmv obj hello\fR -% \*bhello\fR -Hello, world! -% \*bls\fR -first.p -hello -% -.LE -Finally we can get rid of the Pascal object code by using the -.I rm -(1) remove file command, e.g.: -.LS -% \*brm hello\fR -% \*bls\fR -first.p -% -.LE -.PP -For small programs which are being developed -.IX -tends to be more convenient to use than -.PI -and -.X . -Except for absence of the -.I obj -file after a -.IX -run, -a -.IX -command is equivalent to a -.PI -command followed by a -.X -command. -For larger programs, -where a number of runs testing different parts of the program are -to be made, -.PI -is useful as this -.I obj -file can be executed any desired number of times. -.. >>> INSERT SECTION FOR PC <<< -.NH 2 -A larger program -.PP -Suppose that we have used the editor to put a larger program -in the file `bigger.p'. -We can list this program with line numbers by using the program -.I cat -n -i.e.: -.LS -% \*bcat -n bigger.p\fR -.so bigger3.p -% -.LE -This program is similar to program 4.9 on page 30 of the -Jensen-Wirth -.I "User Manual" . -A number of problems have been introduced into this example for -pedagogical reasons. -.br -.PP -If we attempt to translate and execute the program using -.IX -we get the following response: -.LS -% \*bpix bigger.p\fR -.so bigout1 -% -.LE -.PP -Since there were fatal `E' errors in our program, -no code was generated and execution was necessarily suppressed. -One thing which would be useful at this point is a listing of the -program with the error messages. -We can get this by using the command: -.LS -% \*bpi -l bigger.p\fR -.LE -There is no point in using -.IX -here, since we know there are fatal errors in the program. -This command will produce the output at our terminal. -If we are at a terminal which does not produce a hard copy -we may wish to print this -listing off-line on a line printer. -We can do this with the command: -.LS -% \*bpi -l bigger.p | lpr\fR -.LE -.PP -In the next few sections we will illustrate various aspects of the -Berkeley -Pascal system by correcting this program. -.NH 2 -Correcting the first errors -.PP -Most of the errors which occurred in this program were -.I syntactic -errors, those in the format and structure of the program rather than -its content. -Syntax errors are flagged by printing the offending line, and then a line -which flags the location at which an error was detected. -The flag line also gives an explanation -stating either a possible cause of the error, -a simple action which can be taken to recover from the error so -as to be able to continue the analysis, -a symbol which was expected at the point of error, -or an indication that the input was `malformed'. -In the last case, the recovery may skip ahead in the input -to a point where analysis of the program can continue. -.PP -In this example, -the first error diagnostic indicates that the translator detected -a comment within a comment. -While this is not considered an error in `standard' -Pascal, it usually corresponds to an error in the program which -is being translated. -In this case, we have accidentally omitted the trailing `*)' of the comment -on line 8. -We can begin an editor session to correct this problem by doing: -.LS -% \*bex bigger.p\fR -"bigger.p" 24 lines, 512 characters -:\*b8s/$/ *)\fR - s = 32; (* 32 character width for interval [x, x+1] *) -: -.LE -.PP -The second diagnostic, given after line 16, -indicates that the keyword -.B do -was expected before the keyword -.B begin -in the -.B for -statement. -If we examine the -.I statement -syntax chart on page 118 of the -Jensen-Wirth -.I "User Manual" -we will discover that -.B do -is a necessary part of the -.B for -statement. -Similarly, we could have referred to section C.3 of the -Jensen-Wirth -.I "User Manual" -to learn about the -.B for -statement and gotten the same information there. -It is often useful to refer to these syntax charts and to the -relevant sections of this book. -.PP -We can correct this problem by first scanning for the keyword -.B for -in the file and then substituting the keyword -.B do -to appear in front of the keyword -.B begin -there. -Thus: -.LS -:\*b/for\fR - for i := 0 to lim begin -:\*bs/begin/do &\fR - for i := 0 to lim do begin -: -.LE -The next error in the program is easy to pinpoint. -On line 18, we didn't hit the shift key and got a `9' -instead of a `)'. -The translator diagnosed that `x9' -was an undefined variable and, later, -that a `)' was missing in the statement. -It should be stressed that -.PI -is not suggesting that you should insert a `)' before the `;'. -It is only indicating that making this change will help it to be able to -continue analyzing the program so as to be able to diagnose further -errors. -You must then determine the true cause of the error and make the -appropriate correction to the source text. -.PP -This error also illustrates the fact that one error in the input may lead -to multiple error diagnostics. -.I Pi -attempts -to give only one diagnostic for each error, -but single errors in the input sometimes appear to be more than -one error. -It is also the case that -.PI -may not detect an error when it occurs, but may detect it later in -the input. -This would have happened -in this example if we had typed `x' instead of `x9'. -.PP -The translator next detected, on line 19, that the function -.I Round -and the variable -.I h -were undefined. -It does not know about -.I Round -because -.UP -normally distinguishes between upper and lower case.\*(dg -.FS -\*(dgIn ``standard'' Pascal no distinction is made based on case. -.FE -On -.UX -lower-case is preferred\*(dd, -.FS -\*(ddOne good reason for using lower-case is that it is easier to type. -.FE -and all keywords and built-in -.B procedure -and -.B function -names are composed of lower-case letters, -just as they are in the Jensen-Wirth -.I "Pascal Report" . -Thus we need to use the function -.I round -here. -As far as -.I h -is concerned, -we can see why it is undefined if we look back to line 9 -and note that its definition was lost in the non-terminated -comment. -This diagnostic need not, therefore, concern us. -.PP -The next error which occurred in the program caused the translator -to insert a `;' before the statement calling -.I writeln -on line 23. -If we examine the program around the point of error we will see -that the actual error is that the keyword -.B until -and an associated expression have been omitted here. -Note that the diagnostic from the translator does not indicate the actual -error, and is somewhat misleading. -The translator made the correction which seemed to be most plausible. -As the omission of a `;' character is a common mistake, -the translator chose to indicate this as a possible fix here. -It later detected that the keyword -.B until -was missing, but not until it saw the keyword -.B end -on line 24. -The combination of these diagnostics indicate to us the true problem. -.PP -The final syntactic error message indicates that the translator needed an -.B end -keyword to match the -.B begin -at line 15. -Since the -.B end -at line 24 is supposed to match this -.B begin , -we can infer that another -.B begin -must have been mismatched, and have matched this -.B end . -Thus we see that we need an -.B end -to match the -.B begin -at line 16, -and to appear before the final -.B end . -We can make these corrections: -.LS -:\*b/x9/s//x)\fR - y := exp(-x) * sin(i * x); -:\*b+s/Round/round\fR - n := round(s * y) + h; -:\*b/write\fR - write(' '); -:\*b/\fR - writeln('*') -:\*binsert\fR - \*buntil n = 0;\fR -\&\*b.\fR -:\*b$\fR -end. -:\*binsert\fR - \*bend\fR -\&\*b.\fR -: -.LE -.PP -At the end of each -.B procedure -or -.B function -and the end of the -.B program -the translator summarizes references to undefined variables -and improper usages of variables. -It also gives -warnings about potential errors. -In our program, the summary errors do not indicate any further problems -but the warning that -.I c -is unused is somewhat suspicious. -Examining the program we see that the constant was intended -to be used in the expression which is an argument to -.I sin , -so we can correct this expression, and translate the program. -We have now made a correction for each diagnosed error -in our program. -.LS -:\*b?i ?s//c /\fR - y := exp(-x) * sin(c * x); -:\*bwrite\fR -"bigger.p" 26 lines, 538 characters -:\*bquit\fR -% \*bpi bigger.p\fR -% -.LE -It should be noted that the translator suppresses warning -diagnostics for a particular -.B procedure , -.B function -or the main -.B program -when it finds severe syntax errors in that part of the source -text. -This is to prevent possibly confusing and -incorrect warning diagnostics from being produced. -Thus these warning diagnostics may not appear in a program with -bad syntax errors until these errors are corrected. -.KS -.PP -We are now ready to execute our program for the first -time. -We will do so in the next section after giving a listing -of the corrected program for reference purposes. -.LS -% \*bcat -n bigger.p\fR -.so bigger6.p -% -.LE -.NH 2 -Executing the second example -.PP -We are now ready to execute the second example. -The following output was produced by our first run. -.LS -% \*bpx\fR -.so bigout2 -% -.LE -Here the interpreter is presenting us with a runtime error diagnostic. -It detected a `division by zero' at line 17. -Examining line 17, we see that we have written -the statement `x := d / i' instead of `x := d * i'. -We can correct this and rerun the program: -.LS -% \*bex bigger.p\fR -"bigger.p" 26 lines, 538 characters -:\*b17\fR - x := d / i -:\*bs'/'*\fR - x := d * i -:\*bwrite\fR -"bigger.p" 26 lines, 538 characters -:\*bq\fR -% \*bpix bigger.p\fR -.so bigout3 -% -.LE -.KS -.PP -This appears to be the output we wanted. -We could now save the output in a file if we wished by using the shell -to redirect the output: -.LS -% \*bpx > graph\fR -.LE -.KE -We can use -.I cat -(1) to see the contents of the file graph. -We can also make a listing of the graph on the line printer without -putting it into a file, e.g. -.LS -% \*bpx | lpr\fR -.so bigout4 -% -.LE -Note here that the statistics lines came out on our terminal. -The statistics line comes out on the diagnostic output (unit 2.) -There are two ways to get rid of the statistics line. -We can redirect the statistics message to the printer using the -syntax `|\|&' to the shell rather than `|', i.e.: -.LS -% \*bpx |\|& lpr\fR -% -.LE -or we can translate the program with the -.B p -option disabled on the command line as we did above. -This will disable all post-mortem dumping including the statistics line, -thus: -.LS -% \*bpi -p bigger.p\fR -% \*bpx | lpr\fR -% -.LE -This option also disables the statement limit which normally guards -against infinite looping. -You should not use it until your program is debugged. -Also if -.B p -is specified and an error occurs, you will -not get run time diagnostic information to help you -determine what the problem is. -.NH 2 -Formatting the program listing -.PP -It is possible to use special lines within the source text of a program -to format the program listing. -An empty line (one with no characters on it) corresponds to a -`space' macro in an assembler, leaving a completely blank line -without a line number. -A line containing only a control-l (form-feed) character -will cause a page eject in the listing with the corresponding line number -suppressed. -This corresponds to an `eject' pseudo-instruction. -See also section 5.2 for details on the -.B n -and -.B i -options of -.PI . -.NH 2 -Execution profiling -.PP -An execution profile consists of a structured listing of (all or part of) -a program with information about the number of times each statement in -the program was executed for a particular run of the program. -These profiles can be used for several purposes. -In a program which was abnormally terminated due to excessive looping -or recursion or by a program fault, the counts can facilitate location -of the error. -Zero counts mark portions of the program which were not executed; -during the early debugging stages they should prompt new test data or -a re-examination of the program logic. -The profile is perhaps most valuable, however, in drawing -attention to the (typically small) -portions of the program that dominate execution time. -This information can be used for source level optimization. -.SH -An example -.PP -A prime number is a number which is divisible only by itself and the -number one. -The program -.I primes , -written by Niklaus Wirth, -determines the first few prime numbers. -In translating the program we have specified the -.B z -option to -.IX . -This option causes the translator to generate counters and count instructions -sufficient in number to determine the number of times each statement in the -program was executed.\*(dg -.FS -\*(dgThe counts -are completely accurate only in the absence of runtime errors and nonlocal -.B goto -statements. -This is not generally a problem, however, as in structured programs -nonlocal -.B goto -statements occur infrequently, -and counts are incorrect after abnormal termination only when the -.I "upward look" -described below to get a count passes a suspended call point. -.FE -When execution of the program completes, either normally or abnormally, -this count data is written to the file -.I pmon.out -in the current directory.\*(dd -.FS -\*(dd\c -.I Pmon.out -has a name similar to -.I mon.out -the monitor file produced by the profiling facility of the C compiler -.I cc -(1). -See -.I prof -(1) for a discussion of the C compiler profiling facilities. -.FE -It is then possible to prepare an execution profile by giving -.XP -the name of the file associated with this data, as was done in the following -example. -.LS -% \*bpix -l -z primes.p\fR -.so primeout1 -% -.LE -.SH -Discussion -.PP -The header lines of the outputs of -.IX -and -.XP -in this example indicate the version of the translator and execution -profiler in use at the time this example was prepared. -The time given with the file name (also on the header line) -indicates the time of last modification of the program source file. -This time serves to -.I "version stamp" -the input program. -.I Pxp -also indicates the time at which the profile data was gathered. -.LS -% \*bpxp -z primes.p\fR -.so primeout2 -% -.LE -.KE -.PP -To determine the number of times a statement was executed, -one looks to the left of the statement and finds the corresponding -vertical bar `|'. -If this vertical bar is labelled with a count then that count gives the -number of times the statement was executed. -If the bar is not labelled, we look up in the listing to find the first -`|' which directly above the original one which has a count and that -is the answer. -Thus, in our example, -.I k -was incremented 157 times on line 18, -while the -.I write -procedure call on line 24 was executed 48 times as given by the count -on the -.B repeat . -.PP -More information on -.I pxp -can be found in its manual section -.XP -(1) -and in sections 5.4, 5.5 and 5.10. diff --git a/share/doc/ps1/04.pascal/puman3.n b/share/doc/ps1/04.pascal/puman3.n deleted file mode 100644 index d1da2e8a58bb..000000000000 --- a/share/doc/ps1/04.pascal/puman3.n +++ /dev/null @@ -1,753 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)puman3.n 6.3 (Berkeley) 4/17/91 -.\" -.if !\n(xx \{\ -.so tmac.p \} -.if n 'ND -.nr H1 2 -.NH -Error diagnostics -.PP -This section of the -.UM -discusses the error diagnostics of the programs -.PI , -.PC -and -.X . -.I Pix -is a simple but useful program which invokes -.PI -and -.X -to do all the real processing. -See its manual section -.IX -(1) -and section 5.2 below for more details. -All the diagnostics given by -.PI -will also be given by -.PC . -.NH 2 -Translator syntax errors -.PP -A few comments on the general nature of the syntax errors usually -made by Pascal programmers -and the recovery mechanisms of the current translator may help in using -the system. -.SH -Illegal characters -.PP -Characters such as `$', `!', and `@' are not part of the language Pascal. -If they are found in the source program, -and are not part of a constant string, a constant character, or a comment, -they are considered to be -`illegal characters'. -This can happen if you leave off an opening string quote `\(aa'. -Note that the character `"', although used in English to quote strings, -is not used to quote strings in Pascal. -Most non-printing characters in your input are also illegal except -in character constants and character strings. -Except for the tab and form feed characters, -which are used to ease formatting of the program, -non-printing characters in the input file print as the character `?' -so that they will show in your listing. -.SH -String errors -.PP -There is no character string of length 0 in Pascal. -Consequently the input `\(aa\(aa' is not acceptable. -Similarly, encountering an end-of-line after an opening string quote `\(aa' -without encountering the matching closing quote yields the diagnostic -``Unmatched \(aa for string''. -It is permissible to use the character `#' -instead of `\'' -to delimit character and constant strings for portability reasons. -For this reason, a spuriously placed `#' sometimes causes the diagnostic -about unbalanced quotes. -Similarly, a `#' in column one is used when preparing programs which are to -be kept in multiple files. -See section 5.11 for details. -.SH -Comments in a comment, non-terminated comments -.PP -As we saw above, these errors are usually caused by leaving off a comment -delimiter. -You can convert parts of your program to comments -without generating this diagnostic -since there are two different kinds of comments \- those delimited by -`{' and `}', and those delimited by `(*' and `*)'. -Thus consider: -.LS -{ This is a comment enclosing a piece of program -a := functioncall; (* comment within comment *) -procedurecall; -lhs := rhs; (* another comment *) -} -.LE -.PP -By using one kind of comment exclusively in your program you can use -the other delimiters when you need to -``comment out'' -parts of your program\*(dg. -.FS -\*(dgIf you wish to transport your program, -especially to the 6000-3.4 implementation, -you should use the character sequence `(*' to delimit comments. -For transportation over the -.I rcslink -to Pascal 6000-3.4, the character `#' should be used to delimit characters -and constant strings. -.FE -In this way you will also allow the translator to help by detecting -statements accidentally placed within comments. -.PP -If a comment does not terminate before the end of the input file, -the translator will point to the beginning of the comment, -indicating that the comment is not terminated. -In this case processing will terminate immediately. -See the discussion of ``QUIT'' below. -.SH -Digits in numbers -.PP -This part of the language is a minor nuisance. -Pascal requires digits in real numbers both before and after the decimal -point. -Thus the following statements, which look quite reasonable to -.SM -FORTRAN -.NL -users, generate diagnostics in Pascal: -.LS -.so digitsout -.LE -These same constructs are also illegal as input to the Pascal interpreter -.I px . -.SH -Replacements, insertions, and deletions -.PP -When a syntax error is encountered in the input text, -the parser invokes an error recovery procedure. -This procedure examines the input text immediately after the point -of error and considers a set of simple corrections to see whether they -will allow the analysis to continue. -These corrections involve replacing an input token with a different -token, -inserting a token, -or replacing an input token with a different token. -Most of these changes will not cause fatal syntax errors. -The exception is the insertion of or replacement with a symbol -such as an identifier or a number; -in this case the recovery makes no attempt to determine -.I which -identifier or -.I what -number should be inserted, -hence these are considered fatal syntax errors. -.PP -Consider the following example. -.LS -% \*bpix -l synerr.p\fR -.tr -- -.so synerrout -% -.LE -The only surprise here may be that Pascal does not have an exponentiation -operator, hence the complaint about `**'. -This error illustrates that, if you assume that the language has a feature -which it does not, the translator diagnostic may not indicate this, -as the translator is unlikely to recognize the construct you supply. -.SH -Undefined or improper identifiers -.PP -If an identifier is encountered in the input but is undefined, -the error recovery will replace it with an identifier of the -appropriate class. -Further references to this identifier will be summarized at the -end of the containing -.B procedure -or -.B function -or at the end of the -.B program -if the reference occurred in the main program. -Similarly, -if an identifier is used in an inappropriate way, -e.g. if a -.B type -identifier is used in an assignment statement, -or if a simple variable -is used where a -.B record -variable is required, -a diagnostic will be produced and an identifier of the appropriate -type inserted. -Further incorrect references to this identifier will be flagged only -if they involve incorrect use in a different way, -with all incorrect uses being summarized in the same way as undefined -variable uses are. -.SH -Expected symbols, malformed constructs -.PP -If none of the above mentioned corrections appear reasonable, the -error recovery will examine the input -to the left of the point of error to see if there is only one symbol -which can follow this input. -If this is the case, the recovery will print a diagnostic which -indicates that the given symbol was `Expected'. -.PP -In cases where none of these corrections resolve the problems -in the input, -the recovery may issue a diagnostic that indicates that the -input is ``malformed''. -If necessary, the translator may then skip forward in the input to -a place where analysis can continue. -This process may cause some errors in the text to be missed. -.PP -Consider the following example: -.LS -% \*bpix -l synerr2.p\fR -.so synerr2out -% -.LE -Here we misspelled -.I output -and gave a -.SM FORTRAN -style variable declaration -which the translator diagnosed as a `Malformed declaration'. -When, on line 6, we used `(' and `)' for subscripting -(as in -.SM FORTRAN ) -rather than the `[' and `]' which are used in Pascal, -the translator noted that -.I a -was not defined as a -.B procedure . -This occurred because -.B procedure -and -.B function -argument lists are delimited by parentheses in Pascal. -As it is not permissible to assign to procedure calls the translator -diagnosed a malformed statement at the point of assignment. -.SH -Expected and unexpected end-of-file, ``QUIT'' -.PP -If the translator finds a complete program, but there is more non-comment text -in the input file, then it will indicate that an end-of-file was expected. -This situation may occur after a bracketing error, or if too many -.B end s -are present in the input. -The message may appear -after the recovery says that it -``Expected \`.\'\|'' -since `.' is the symbol that terminates a program. -.PP -If severe errors in the input prohibit further processing -the translator may produce a diagnostic followed by ``QUIT''. -One example of this was given above \- -a non-terminated comment; -another example is a line which is longer than 160 -characters. -Consider also the following example. -.LS -% \*bpix -l mism.p\fR -.so mismout -% -.LE -.NH 2 -Translator semantic errors -.PP -The extremely large number of semantic diagnostic messages which the translator -produces make it unreasonable to discuss each message or group of messages -in detail. -The messages are, however, very informative. -We will here explain the typical formats and the terminology used in the error -messages so that you will be able to make sense out of them. -In any case in which a diagnostic is not completely comprehensible you can -refer to the -.I "User Manual" -by Jensen and Wirth for examples. -.SH -Format of the error diagnostics -.PP -As we saw in the example program above, the error diagnostics from -the Pascal translator include the number of a line in the text of the program -as well as the text of the error message. -While this number is most often the line where the error occurred, it -is occasionally the number of a line containing a bracketing keyword -like -.B end -or -.B until . -In this case, the diagnostic may refer to the previous statement. -This occurs because of the method the translator uses for sampling line -numbers. -The absence of a trailing `;' in the previous statement causes the line -number corresponding to the -.B end -or -.B until . -to become associated with the statement. -As Pascal is a free-format language, the line number associations -can only be approximate and may seem arbitrary to some users. -This is the only notable exception, however, to reasonable associations. -.SH -Incompatible types -.PP -Since Pascal is a strongly typed language, many semantic errors manifest -themselves as type errors. -These are called `type clashes' by the translator. -The types allowed for various operators in the language are summarized on page -108 of the -Jensen-Wirth -.I "User Manual" . -It is important to know that the Pascal translator, in its diagnostics, -distinguishes between the following type `classes': -.br -.ne 8 -.TS -center; -lew(10) le le le le. -array Boolean char file integer -pointer real record scalar string -.TE -These words are plugged into a great number of error messages. -Thus, if you tried to assign an -.I integer -value to a -.I char -variable you would receive a diagnostic like the following: -.LS -.so clashout -.LE -In this case, one error produced a two line error message. -If the same error occurs more than once, the same explanatory -diagnostic will be given each time. -.SH -Scalar -.PP -The only class whose meaning is not self-explanatory is -`scalar'. -Scalar has a precise meaning in the -Jensen-Wirth -.I "User Manual" -where, in fact, it refers to -.I char , -.I integer , -.I real , -and -.I Boolean -types as well as the enumerated types. -For the purposes of the Pascal translator, -scalar -in an error message refers to a user-defined, enumerated -type, such as -.I ops -in the example above or -.I color -in -.LS -\*btype\fP color = (red, green, blue) -.LE -For integers, the more explicit denotation -.I integer -is used. -Although it would be correct, in the context of the -.I "User Manual" -to refer to an integer variable as a -.I scalar -variable -.PI -prefers the more specific identification. -.SH -Function and procedure type errors -.PP -For built-in procedures and functions, two kinds of errors occur. -If the routines are called with the wrong number of arguments a message similar to: -.LS -.so sinout1 -.LE -is given. -If the type of the argument is wrong, a message like -.LS -.so sinout2 -.LE -is produced. -A few functions and procedures implemented in Pascal 6000-3.4 are -diagnosed as unimplemented in -Berkeley -Pascal, notably those related to -.B segmented -files. -.SH -Can't read and write scalars, etc. -.PP -The messages which state that scalar (user-defined) types -cannot be written to and from files are often mysterious. -It is in fact the case that if you define -.LS -\*btype\fP color = (red, green, blue) -.LE -``standard'' Pascal does not associate these constants with the strings -`red', `green', and `blue' in any way. -An extension has been added which allows enumerated types -to be read and written, -however if the program is to be portable, -you will have to write your own routines to perform these functions. -Standard Pascal only allows the reading of characters, integers and real -numbers from text files. -You cannot read strings or Booleans. -It is possible to make a -.LS -\*bfile of\fP color -.LE -but the representation is binary rather than string. -.SH -Expression diagnostics -.PP -The diagnostics for semantically ill-formed expressions are very explicit. -Consider this sample translation: -.LS -% \*bpi -l expr.p\fP -.so exprout -% -.LE -This example is admittedly far-fetched, but illustrates that the error -messages are sufficiently clear to allow easy determination of the -problem in the expressions. -.SH -Type equivalence -.PP -Several diagnostics produced by the Pascal translator complain about -`non-equivalent types'. -In general, -Berkeley -Pascal considers variables to have the same type only if they were -declared with the same constructed type or with the same type identifier. -Thus, the variables -.I x -and -.I y -declared as -.LS -\*bvar\fP - x: ^ integer; - y: ^ integer; -.LE -do not have the same type. -The assignment -.LS -x := y -.LE -thus produces the diagnostics: -.LS -.so typequout -.LE -Thus it is always necessary to declare a type such as -.LS -\*btype\fP intptr = ^ integer; -.LE -and use it to declare -.LS -\*bvar\fP x: intptr; y: intptr; -.LE -Note that if we had initially declared -.LS -\*bvar\fP x, y: ^ integer; -.LE -then the assignment statement would have worked. -The statement -.LS -x^ := y^ -.LE -is allowed in either case. -Since the parameter to a -.B procedure -or -.B function -must be declared with a -type identifier rather than a constructed type, -it is always necessary, in practice, -to declare any type which will be used in this way. -.SH -Unreachable statements -.PP -Berkeley -Pascal flags unreachable statements. -Such statements usually correspond to errors in the program logic. -Note that a statement is considered to be reachable -if there is a potential path of control, -even if it can never be taken. -Thus, no diagnostic is produced for the statement: -.LS -\*bif\fP false \*bthen\fP - writeln('impossible!') -.LE -.SH -Goto's into structured statements -.PP -The translator detects and complains about -.B goto -statements which transfer control into structured statements (\c -.B for , -.B while , -etc.) -It does not allow such jumps, nor does it allow branching from the -.B then -part of an -.B if -statement into the -.B else -part. -Such checks are made only within the body of a single procedure or -function. -.SH -Unused variables, never set variables -.PP -Although -.PI -always clears variables to 0 at -.B procedure -and -.B function -entry, -.PC -does not unless runtime checking is enabled using the -.B C -option. -It is -.B not -good programming practice to rely on this initialization. -To discourage this practice, and to help detect errors in program logic, -.PI -flags as a `w' warning error: -.IP -.RS -.HP 1) -Use of a variable which is never assigned a value. -.IP 2) -A variable which is declared but never used, distinguishing -between those variables for which values are computed but which are never -used, and those completely unused. -.RE -.LP -In fact, these diagnostics are applied to all declared items. -Thus a -.B const -or a -.B procedure -which is declared but never used is flagged. -The -.B w -option of -.PI -may be used to suppress these warnings; -see sections 5.1 and 5.2. -.NH 2 -Translator panics, i/o errors -.SH -Panics -.PP -One class of error which rarely occurs, but which causes termination -of all processing when it does is a panic. -A panic indicates a translator-detected internal inconsistency. -A typical panic message is: -.LS -snark (rvalue) line=110 yyline=109 -Snark in pi -.LE -If you receive such a message, the translation will be quickly and perhaps -ungracefully terminated. -You should contact a teaching assistant or a member of the system staff, -after saving a copy of your program for later inspection. -If you were making changes to an existing program when the problem -occurred, you may -be able to work around the problem by ascertaining which change caused the -.I snark -and making a different change or correcting an error in the program. -A small number of panics are possible in -.X . -All panics should be reported to a teaching assistant or systems -staff so that they can be fixed. -.SH -Out of memory -.PP -The only other error which will abort translation when no errors are -detected is running out of memory. -All tables in the translator, with the exception of the parse stack, -are dynamically allocated, and can grow to take up the full available -process space of 64000 bytes on the \s-2PDP\s0-11. On the \s-2VAX\s0-11, -table sizes are extremely generous and very large (25000) line programs -have been easily accommodated. For the \s-2PDP\s0\-11, it is -generally true that -the size of the largest translatable program is directly related to -.B procedure -and -.B function -size. -A number of non-trivial Pascal programs, including -some with more than 2000 lines and 2500 statements -have been translated and interpreted using -Berkeley -Pascal on \s-2PDP\s0-11's. -Notable among these are the Pascal-S -interpreter, -a large set of programs for automated generation of -code generators, -and a general context-free parsing program which has been used to -parse sentences with a grammar for a superset of English. -In general, -very large programs should be translated using -.PC -and the separate compilation facility. -.PP -If you receive an out of space message from the translator -during translation of a large -.B procedure -or -.B function -or one containing a large number of string constants -you may yet be able -to translate your program if you break this one -.B procedure -or -.B function -into several routines. -.SH -I/O errors -.PP -Other errors which you may encounter when running -.PI -relate to input-output. -If -.PI -cannot open the file you specify, -or if the file is empty, -you will be so informed. -.NH 2 -Run-time errors -.PP -We saw, in our second example, a run-time error. -We here give the general description of run-time errors. -The more unusual interpreter error messages are explained -briefly in the manual section for -.I px -(1). -.SH -Start-up errors -.PP -These errors occur when the object file to be executed is not available -or appropriate. -Typical errors here are caused by the specified object file not existing, -not being a Pascal object, or being inaccessible to the user. -.SH -Program execution errors -.PP -These errors occur when the program interacts with the Pascal runtime -environment in an inappropriate way. -Typical errors are values or subscripts out of range, -bad arguments to built-in functions, -exceeding the statement limit because of an infinite loop, -or running out of memory\*(dd. -.FS -\*(ddThe checks for running out of memory are not foolproof and there -is a chance that the interpreter will fault, producing a core image -when it runs out of memory. -This situation occurs very rarely. -.FE -The interpreter will produce a backtrace after the error occurs, -showing all the active routine calls, -unless the -.B p -option was disabled when the program was translated. -Unfortunately, no variable values are given and no way of extracting them -is available.* -.FS -* On the \s-2VAX\s0-11, each variable -is restricted to allocate at most 65000 bytes of storage (this is a -\s-2PDP\s0-11ism that has survived to the \s-2VAX\s0.) -.FE -.PP -As an example of such an error, assume that we have accidentally -declared the constant -.I n1 -to be 6, instead of 7 -on line 2 of the program primes as given in section 2.6 above. -If we run this program we get the following response. -.LS -% \*bpix primes.p\fP -.so primeout3 -% -.LE -.PP -Here the interpreter indicates that the program terminated -abnormally due to a subscript out of range near line 14, -which is eight lines into the body of the program primes. -.SH -Interrupts -.PP -If the program is interrupted while executing -and the -.B p -option was not specified, -then a backtrace will be printed.\*(dg -.FS -\*(dgOccasionally, the Pascal system will be in an inconsistent -state when this occurs, -e.g. when an interrupt terminates a -.B procedure -or -.B function -entry or exit. -In this case, the backtrace will only contain the current line. -A reverse call order list of procedures will not be given. -.FE -The file -.I pmon.out -of profile information will be written if the program was translated -with the -.B z -option enabled to -.PI -or -.IX . -.SH -I/O interaction errors -.PP -The final class of interpreter errors results from inappropriate -interactions with files, including the user's terminal. -Included here are bad formats for integer and real numbers (such as -no digits after the decimal point) when reading. diff --git a/share/doc/ps1/04.pascal/puman4.n b/share/doc/ps1/04.pascal/puman4.n deleted file mode 100644 index 3f809911cef6..000000000000 --- a/share/doc/ps1/04.pascal/puman4.n +++ /dev/null @@ -1,609 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)puman4.n 6.3 (Berkeley) 4/17/91 -.\" -.if !\n(xx \{\ -.so tmac.p \} -.nr H1 3 -.if n 'ND -.NH -Input/output -.PP -This section describes features of the Pascal input/output environment, -with special consideration of the features peculiar to an -interactive implementation. -.NH 2 -Introduction -.PP -Our first sample programs, in section 2, used the file -.I output . -We gave examples there of redirecting the output to a file and to the line -printer using the shell. -Similarly, we can read the input from a file or another program. -Consider the following Pascal program which is similar to the program -.I cat -(1). -.LS -% \*bpix -l kat.p clean.p\fR -.LE -Note that since the shell creates the output file `clean.p' before -.XP -executes, so `clean.p' and `dirty.p' must not be the same file. -.PP -.I Pxp -automatically paragraphs the program, performing housekeeping -chores such as comment alignment, and -treating blank lines, lines containing exactly one blank -and lines containing only a form-feed character as though they -were comments, preserving their vertical spacing effect in the output. -.I Pxp -distinguishes between four kinds of comments: -.HP -.RS -.IP 1) -Left marginal comments, which begin in the first column of the -input line and are placed in the first column of an output line. -.IP 2) -Aligned comments, which are preceded by no input tokens on the -input line. -These are aligned in the output with the running program text. -.IP 3) -Trailing comments, which are preceded in the input line by a token with -no more than two spaces separating the token from the comment. -.IP 4) -Right marginal comments, which are preceded in the input line -by a token from which they are separated by at least three spaces or a tab. -These are aligned down the right margin of the output, -currently to the first tab stop after the 40th column from the current -``left margin''. -.RE -.LP -Consider the following program. -.LS -% \*bcat comments.p\fR -.so comments1.p -.LE -When formatted by -.XP -the following output is produced. -.LS -% \*bpxp comments.p\fR -.so commentsout -% -.LE -The following formatting related options are currently available in -.XP . -The options -.B f -and -.B j -described in the previous section may also be of interest. -.SH -Strip comments \-s -.PP -The -.B s -option causes -.XP -to remove all comments from the input text. -.SH -Underline keywords \- \_ -.PP -A command line argument of the form -.B \-\_ -as in -.LS -% \*bpxp -_ dirty.p\fR -.LE -can be used to cause -.XP -to underline all keywords in the output for enhanced readability. -.SH -Specify indenting unit \- [23456789] -.PP -The normal unit which -.XP -uses to indent a structure statement level is 4 spaces. -By giving an argument of the form -\fB\-\fId\fR -with -.I d -a digit, -2 \(<= -.I d -\(<= 9 -you can specify that -.I d -spaces are to be used per level instead. -.NH 2 -Pxref -.PP -The cross-reference program -.I pxref -may be used to make cross-referenced listings of Pascal -programs. -To produce a cross-reference of the program in the file -`foo.p' -one can execute the command: -.LS -% \*bpxref foo.p\fR -.LE -The cross-reference is, unfortunately, not block structured. -Full details on -.I pxref -are given in its manual section -.I pxref -(1). -.NH 2 -Multi-file programs -.PP -A text inclusion facility is available with -.UP . -This facility allows the interpolation of source text from other -files into the source stream of the translator. -It can be used to divide large programs into more manageable pieces -for ease in editing, listing, and maintenance. -.PP -The -.B include -facility is based on that of the -.SM -UNIX -.NL -C compiler. -To trigger it you can place the character `#' in the first portion of -a line and then, after an arbitrary number of blanks or tabs, -the word -`include' -followed by a filename enclosed in single `\(aa' or double `"' quotation -marks. -The file name may be followed by a semicolon `;' if you wish to treat -this as a pseudo-Pascal statement. -The filenames of included files must end in `.i'. -An example of the use of included files in a main program would be: -.LS -\*bprogram\fR compiler(input, output, obj); - -#\*binclude\fR "globals.i" -#\*binclude\fR "scanner.i" -#\*binclude\fR "parser.i" -#\*binclude\fR "semantics.i" - -\*bbegin\fR - { main program } -\*bend\fR. -.LE -.PP -At the point the -.B include -pseudo-statement is encountered in the input, the lines from -the included file are interpolated into the input stream. -For the purposes of translation and runtime diagnostics and -statement numbers in the listings and post-mortem backtraces, -the lines in the included file are numbered from 1. -Nested includes are possible up to 10 deep. -.PP -See the descriptions of the -.B i -option of -.PI -in section 5.2 -above; -this can be used to control listing when -.B include -files are present. -.PP -When a non-trivial line is encountered in the source text after an -.B include -finishes, the -`popped' filename is printed, in the same manner as above. -.PP -For the purposes of error diagnostics when not making a listing, the filename -will be printed before each diagnostic if the current -filename has changed since the last -filename was printed. -.NH 2 -Separate Compilation with Pc -.PP -A separate compilation facility is provided with the Berkeley Pascal compiler, -.PC . -This facility allows programs to be divided into a number of files and -the pieces to be compiled individually, -to be linked together at some later time. -This is especially useful for large programs, -where small changes would otherwise require -time-consuming re-compilation of the entire program. -.PP -Normally, -.PC -expects to be given entire Pascal programs. -However, if given the -.B \-c -option on the command line, it will accept a sequence of definitions and -declarations, and compile them into a -.B .o -file, to be linked with a Pascal program at a later time. -In order that procedures and functions be available across -separately compiled files, they must be declared with the directive -.B external . -This directive is similar to the directive -.B forward -in that it must precede the resolution of the function or procedure, -and formal parameters and function result types must be specified -at the -.B external -declaration and may not be specified at the resolution. -.PP -Type checking is performed across separately compiled files. -Since Pascal type defintions define unique types, -any types which are shared between separately compiled files -must be the same definition. -This seemingly impossible problem is solved using a facility similar -to the -.B include -facility discussed above. -Definitions may be placed in files with the extension -.B .h -and the files included by separately compiled files. -Each definition from a -.B .h -file defines a unique type, and all uses of a definition from the same -.B .h -file define the same type. -Similarly, the facility is extended to allow the definition of -.B const s -and the declaration of -.B label s, -.B var s, -and -.B external -.B function s -and -.B procedure s. -Thus -.B procedure s -and -.B function s -which are used between separately compiled files must be declared -.B external , -and must be so declared in a -.B .h -file included by any file which calls or resolves the -.B function -or -.B procedure . -Conversely, -.B function s -and -.B procedure s -declared -.B external -may only be so declared in -.B .h -files. -These files may be included only at the outermost level, -and thus define or declare global objects. -Note that since only -.B external -.B function -and -.B procedure -declarations (and not resolutions) are allowed in -.B .h -files, statically nested -.B function s -and -.B procedure s -can not be declared -.B external . -.PP -An example of the use of included -.B .h -files in a program would be: -.LS -\*bprogram\fR compiler(input, output, obj); - -#\*binclude\fR "globals.h" -#\*binclude\fR "scanner.h" -#\*binclude\fR "parser.h" -#\*binclude\fR "semantics.h" - -\*bbegin\fR - { main program } -\*bend\fR. -.LE -.PP -This might include in the main program -the definitions and declarations of all the global -.B label s, -.B const s, -.B type s and -.B var s -from the file globals.h, -and the -.B external -.B function -and -.B procedure -declarations for each of the -separately compiled files for the scanner, parser and semantics. -The header file -.I scanner.h -would contain declarations of the form: -.LS -\*btype\fR - token = \*brecord\fR - { token fields } - \*bend\fR; - -\*bfunction\fR scan(\*bvar\fR inputfile: text): token; - \*bexternal\fR; -.LE -.ne 15 -Then the scanner might be in a separately compiled file containing: -.LS -#\*binclude\fR "globals.h" -#\*binclude\fR "scanner.h" - -\*bfunction\fR scan; -\*bbegin\fR - { scanner code } -\*bend\fR; -.LE -which includes the same global definitions and declarations -and resolves the scanner functions and procedures declared -.B external -in the file scanner.h. diff --git a/share/doc/ps1/04.pascal/pumanA.n b/share/doc/ps1/04.pascal/pumanA.n deleted file mode 100644 index b3320f492ddf..000000000000 --- a/share/doc/ps1/04.pascal/pumanA.n +++ /dev/null @@ -1,965 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)pumanA.n 6.3 (Berkeley) 4/17/91 -.\" -.if !\n(xx \{\ -.so tmac.p \} -.ND -.nr H1 0 -.af H1 A -.NH -Appendix to Wirth's Pascal Report -.PP -This section is an appendix to -the definition of the Pascal language in Niklaus Wirth's -.I "Pascal Report" -and, with that Report, precisely defines the -Berkeley -implementation. -This appendix includes a summary of extensions to the language, -gives the ways in which the undefined specifications were resolved, -gives limitations and restrictions of the current implementation, -and lists the added functions and procedures available. -It concludes with a list of differences with the commonly available -Pascal 6000\-3.4 implementation, -and some comments on standard and portable Pascal. -.NH 2 -Extensions to the language Pascal -.PP -This section defines non-standard language constructs available in -.UP . -The -.B s -standard Pascal option of the translators -.PI -and -.PC -can be used to detect these extensions in programs which are to be transported. -.SH -String padding -.PP -.UP -will pad constant strings with blanks in expressions and as -value parameters to make them as long as is required. -The following is a legal -.UP -program: -.LS -\*bprogram\fP x(output); -\*bvar\fP z : \*bpacked\fP \*barray\fP [ 1 .. 13 ] \*bof\fP char; -\*bbegin\fP - z := 'red'; - writeln(z) -\*bend\fP; -.LE -The padded blanks are added on the right. -Thus the assignment above is equivalent to: -.LS -z := 'red ' -.LE -which is standard Pascal. -.SH -Octal constants, octal and hexadecimal write -.PP -Octal constants may be given as a sequence of octal digits followed -by the character `b' or `B'. -The forms -.LS -write(a:n \*boct\fP) -.LE -and -.LS -write(a:n \*bhex\fP) -.LE -cause the internal representation of -expression -.I a, -which must be Boolean, character, integer, pointer, or a user-defined enumerated -type, -to be written in octal or hexadecimal respectively. -.SH -Assert statement -.PP -An -.B assert -statement causes a -.I Boolean -expression to be evaluated -each time the statement is executed. -A runtime error results if any of the expressions evaluates to be -.I false . -The -.B assert -statement is treated as a comment if run-time tests are disabled. -The syntax for -.B assert -is: -.LS -\*bassert\fP -.LE -.SH -Enumerated type input-output -.PP -Enumerated types may be read and written. -On output the string name associated with the enumerated -value is output. -If the value is out of range, -a runtime error occurs. -On input an identifier is read and looked up -in a table of names associated with the -type of the variable, and -the appropriate internal value is assigned to the variable being -read. -If the name is not found in the table -a runtime error occurs. -.SH -Structure returning functions -.PP -An extension has been added which allows functions -to return arbitrary sized structures rather than just -scalars as in the standard. -.SH -Separate compilation -.PP -The compiler -.PC -has been extended to allow separate compilation of programs. -Procedures and functions declared at the global level -may be compiled separately. -Type checking of calls to separately compiled routines is performed -at load time to insure that the program as a whole -is consistent. -See section 5.10 for details. -.NH 2 -Resolution of the undefined specifications -.SH -File name \- file variable associations -.PP -Each Pascal file variable is associated with a named -.UX -file. -Except for -.I input -and -.I output, -which are -exceptions to some of the rules, a name can become associated -with a file in any of three ways: -.IP "\ \ \ \ \ 1)" 10 -If a global Pascal file variable appears in the -.B program -statement -then it is associated with -.UX -file of the same name. -.IP "\ \ \ \ \ 2)" -If a file was reset or rewritten using the -extended two-argument form of -.I reset -or -.I rewrite -then the given name -is associated. -.IP "\ \ \ \ \ 3)" -If a file which has never had -.UX -name associated -is reset or rewritten without specifying a name -via the second argument, then a temporary name -of the form `tmp.x' -is associated with the file. -Temporary names start with -`tmp.1' and continue by incrementing the last character in the -.SM -USASCII -.NL -ordering. -Temporary files are removed automatically -when their scope is exited. -.SH -The program statement -.PP -The syntax of the -.B program -statement is: -.LS -\*bprogram\fP ( { , } ) ; -.LE -The file identifiers (other than -.I input -and -.I output ) -must be declared as variables of -.B file -type in the global declaration part. -.SH -The files input and output -.PP -The formal parameters -.I input -and -.I output -are associated with the -.UX -standard input and output and have a -somewhat special status. -The following rules must be noted: -.IP "\ \ \ \ \ 1)" 10 -The program heading -.B must -contains the formal parameter -.I output. -If -.I input -is used, explicitly or implicitly, then it must -also be declared here. -.IP "\ \ \ \ \ 2)" -Unlike all other files, the -Pascal files -.I input -and -.I output -must not be defined in a declaration, -as their declaration is automatically: -.LS -\*bvar\fP input, output: text -.LE -.IP "\ \ \ \ \ 3)" -The procedure -.I reset -may be used on -.I input. -If no -.UX -file name has ever been associated with -.I input, -and no file name is given, then an attempt will be made -to `rewind' -.I input. -If this fails, a run time -error will occur. -.I Rewrite -calls to output act as for any other file, except that -.I output -initially has no associated file. -This means that a simple -.LS -rewrite(output) -.LE -associates a temporary name with -.I output. -.SH -Details for files -.PP -If a file other than -.I input -is to be read, -then reading must be initiated by a call to the -procedure -.I reset -which causes the Pascal system to attempt to open the -associated -.UX -file for reading. -If this fails, then a runtime error occurs. -Writing of a file other than -.I output -must be initiated by a -.I rewrite -call, -which causes the Pascal system to create the associated -.UX -file and -to then open the file for writing only. -.SH -Buffering -.PP -The buffering for -.I output -is determined by the value of the -.B b -option -at the end of the -.B program -statement. -If it has its default value 1, -then -.I output -is -buffered in blocks of up to 512 characters, -flushed whenever a writeln occurs -and at each reference to the file -.I input. -If it has the value 0, -.I output -is unbuffered. -Any value of -2 or more gives block buffering without line or -.I input -reference flushing. -All other output files are always buffered in blocks of 512 characters. -All output buffers are flushed when the files are closed at scope exit, -whenever the procedure -.I message -is called, and can be flushed using the -built-in procedure -.I flush. -.PP -An important point for an interactive implementation is the definition -of `input\(ua'. -If -.I input -is a teletype, and the Pascal system reads a character at the beginning -of execution to define `input\(ua', then no prompt could be printed -by the program before the user is required to type some input. -For this reason, `input\(ua' is not defined by the system until its definition -is needed, reading from a file occurring only when necessary. -.SH -The character set -.PP -Seven bit -.SM USASCII -is the character set used on -.UX . -The standard Pascal -symbols `and', 'or', 'not', '<=', '>=', '<>', -and the uparrow `\(ua' (for pointer qualification) -are recognized.\*(dg -.FS -\*(dgOn many terminals and printers, the up arrow is represented -as a circumflex `^'. -These are not distinct characters, but rather different graphic -representations of the same internal codes. -.FE -Less portable are the -synonyms tilde `~' -for -.B not , -`&' for -.B and , -and `|' for -.B or . -.PP -Upper and lower case are considered to be distinct.\*(st -.FS -\*(stThe proposed standard for Pascal considers them to be the same. -.FE -Keywords and built-in -.B procedure -and -.B function -names are -composed of all lower case letters. -Thus the identifiers GOTO and GOto are distinct both from each other and -from the keyword -\*bgoto\fP. -The standard type `boolean' is also available as `Boolean'. -.PP -Character strings and constants may be delimited by the character -`\'' -or by the character `#'; -the latter is sometimes convenient when programs are to be transported. -Note that the `#' character has special meaning -.up -when it is the first character on a line \- see -.I "Multi-file programs" -below. -.SH -The standard types -.PP -The standard type -.I integer -is conceptually defined as -.LS -\*btype\fP integer = minint .. maxint; -.LE -.I Integer -is implemented with 32 bit twos complement arithmetic. -Predefined constants of type -.I integer -are: -.LS -\*bconst\fP maxint = 2147483647; minint = -2147483648; -.LE -.PP -The standard type -.I char -is conceptually defined as -.LS -\*btype\fP char = minchar .. maxchar; -.LE -Built-in character constants are `minchar' and `maxchar', `bell' and `tab'; -ord(minchar) = 0, ord(maxchar) = 127. -.PP -The type -.I real -is implemented using 64 bit floating point arithmetic. -The floating point arithmetic is done in `rounded' mode, and -provides approximately 17 digits of precision -with numbers as small as 10 to the negative 38th power and as large as -10 to the 38th power. -.SH -Comments -.PP -Comments can be delimited by either `{' and `}' or by `(*' and `*)'. -If the character `{' appears in a comment delimited by `{' and `}', -a warning diagnostic is printed. -A similar warning will be printed if the sequence `(*' appears in -a comment delimited by `(*' and `*)'. -The restriction implied by this warning is not part of standard Pascal, -but detects many otherwise subtle errors. -.SH -Option control -.PP -Options of the translators may be controlled -in two distinct ways. -A number of options may appear on the command line invoking the translator. -These options are given as one or more strings of letters preceded by the -character `\-' and cause the default setting of -each given option to be changed. -This method of communication of options is expected to predominate -for -.UX . -Thus the command -.LS -% \*bpi \-l \-s foo.p\fR -.LE -translates the file foo.p with the listing option enabled (as it normally -is off), and with only standard Pascal features available. -.PP -If more control over the portions of the program where options are enabled is -required, then option control in comments can and should be used. -The -format for option control in comments is identical to that used in Pascal -6000\-3.4. -One places the character `$' as the first character of the comment -and follows it by a comma separated list of directives. -Thus an equivalent to the command line example given above would be: -.LS -{$l+,s+ listing on, standard Pascal} -.LE -as the first line of the program. -The `l' -option is more appropriately specified on the command line, -since it is extremely unlikely in an interactive environment -that one wants a listing of the program each time it is translated. -.PP -Directives consist of a letter designating the option, -followed either by a `+' to turn the option on, or by a `\-' to turn the -option off. -The -.B b -option takes a single digit instead of -a `+' or `\-'. -.SH -Notes on the listings -.PP -The first page of a listing -includes a banner line indicating the version and date of generation of -.PI -or -.PC . -It also -includes the -.UX -path name supplied for the source file and the date of -last modification of that file. -.PP -Within the body of the listing, lines are numbered consecutively and -correspond to the line numbers for the editor. -Currently, two special -kinds of lines may be used to format the listing: -a line consisting of a form-feed -character, control-l, which causes a page -eject in the listing, and a line with -no characters which causes the line number to be suppressed in the listing, -creating a truly blank line. -These lines thus correspond to `eject' and `space' macros found in many -assemblers. -Non-printing characters are printed as the character `?' in the listing.\*(dg -.FS -\*(dgThe character generated by a control-i indents -to the next `tab stop'. -Tab stops are set every 8 columns in -.UX . -Tabs thus provide a quick way of indenting in the program. -.FE -.SH -The standard procedure write -.PP -If no minimum field length parameter is specified -for a -.I write, -the following default -values are assumed: -.KS -.TS -center; -l n. -integer 10 -real 22 -Boolean length of `true' or `false' -char 1 -string length of the string -oct 11 -hex 8 -.TE -.KE -The end of each line in a text file should be explicitly -indicated by `writeln(f)', where `writeln(output)' may be written -simply as `writeln'. -For -.UX , -the built-in function `page(f)' puts a single -.SM ASCII -form-feed character on the output file. -For programs which are to be transported the filter -.I pcc -can be used to interpret carriage control, as -.UX -does not normally do so. -.NH 2 -Restrictions and limitations -.SH -Files -.PP -Files cannot be members of files or members of dynamically -allocated structures. -.SH -Arrays, sets and strings -.PP -The calculations involving array subscripts and set elements -are done with 16 bit arithmetic. -This -restricts the types over which arrays and sets may be defined. -The lower bound of such a range must be greater than or equal to -\-32768, and the upper bound less than 32768. -In particular, strings may have any length from 1 to 65535 characters, -and sets may contain no more than 65535 elements. -.SH -Line and symbol length -.PP -There is no intrinsic limit on the length of identifiers. -Identifiers -are considered to be distinct if they differ -in any single position over their entire length. -There is a limit, however, on the maximum input -line length. -This limit is quite generous however, currently exceeding 160 -characters. -.SH -Procedure and function nesting and program size -.PP -At most 20 levels of -.B procedure -and -.B function -nesting are allowed. -There is no fundamental, translator defined limit on the size of the -program which can be translated. -The ultimate limit is supplied by the -hardware and thus, on the \s-2PDP\s0-11, -by the 16 bit address space. -If -one runs up against the `ran out of memory' diagnostic the program may yet -translate if smaller procedures are used, as a lot of space is freed -by the translator at the completion of each -.B procedure -or -.B function -in the current -implementation. -.PP -On the \s-2VAX\s0-11, there is an implementation defined limit -of 65536 bytes per variable. -There is no limit on the number of variables. -.SH -Overflow -.PP -There is currently no checking for overflow on arithmetic operations at -run-time on the \s-2PDP\s0-11. -Overflow checking is performed on the \s-2VAX\s0-11 by the hardware. -.br -.ne 15 -.NH 2 -Added types, operators, procedures and functions -.SH -Additional predefined types -.PP -The type -.I alfa -is predefined as: -.LS -\*btype\fP alfa = \*bpacked\fP \*barray\fP [ 1..10 ] \*bof\fP \*bchar\fP -.LE -.PP -The type -.I intset -is predefined as: -.LS -\*btype\fP intset = \*bset of\fP 0..127 -.LE -In most cases the context of an expression involving a constant -set allows the translator to determine the type of the set, even though the -constant set itself may not uniquely determine this type. -In the -cases where it is not possible to determine the type of the set from -local context, the expression type defaults to a set over the entire base -type unless the base type is integer\*(dg. -.FS -\*(dgThe current translator makes a special case of the construct -`if ... in [ ... ]' and enforces only the more lax restriction -on 16 bit arithmetic given above in this case. -.FE -In the latter case the type defaults to the current -binding of -.I intset, -which must be ``type set of (a subrange of) integer'' at that point. -.PP -Note that if -.I intset -is redefined via: -.LS -\*btype\fP intset = \*bset of\fP 0..58; -.LE -then the default integer set is the implicit -.I intset -of -Pascal 6000\-3.4 -.SH -Additional predefined operators -.PP -The relationals `<' and `>' of proper set -inclusion are available. -With -.I a -and -.I b -sets, note that -.LS -(\*bnot\fR (\fIa\fR < \fIb\fR)) <> (\fIa\fR >= \fIb\fR) -.LE -As an example consider the sets -.I a -= [0,2] -and -.I b -= [1]. -The only relation true between these sets is `<>'. -.SH -Non-standard procedures -.IP argv(i,a) 25 -where -.I i -is an integer and -.I a -is a string variable -assigns the (possibly truncated or blank padded) -.I i \|'th -argument -of the invocation of the current -.UX -process to the variable -.I a . -The range of valid -.I i -is -.I 0 -to -.I argc\-1 . -.IP date(a) -assigns the current date to the alfa variable -.I a -in the format `dd mmm yy ', where `mmm' is the first -three characters of the month, i.e. `Apr'. -.IP flush(f) -writes the output buffered for Pascal file -.I f -into the associated -.UX -file. -.IP halt -terminates the execution of the program with -a control flow backtrace. -.IP linelimit(f,x)\*(dd -.FS -\*(ddCurrently ignored by pdp-11 -.X . -.FE -with -.I f -a textfile and -.I x -an integer expression -causes -the program to be abnormally terminated if more than -.I x -lines are -written on file -.I f . -If -.I x -is less than 0 then no limit is imposed. -.IP message(x,...) -causes the parameters, which have the format of those -to the -built-in -.B procedure -.I write, -to be written unbuffered on the diagnostic unit 2, -almost always the user's terminal. -.IP null -a procedure of no arguments which does absolutely nothing. -It is useful as a place holder, -and is generated by -.XP -in place of the invisible empty statement. -.IP remove(a) -where -.I a -is a string causes the -.UX -file whose -name is -.I a, -with trailing blanks eliminated, to be removed. -.IP reset(f,a) -where -.I a -is a string causes the file whose name -is -.I a -(with blanks trimmed) to be associated with -.I f -in addition -to the normal function of -.I reset. -.IP rewrite(f,a) -is analogous to `reset' above. -.IP stlimit(i) -where -.I i -is an integer sets the statement limit to be -.I i -statements. -Specifying the -.B p -option to -.I pc -disables statement limit counting. -.IP time(a) -causes the current time in the form `\ hh:mm:ss\ ' to be -assigned to the alfa variable -.I a. -.SH -Non-standard functions -.IP argc 25 -returns the count of arguments when the Pascal program -was invoked. -.I Argc -is always at least 1. -.IP card(x) -returns the cardinality of the set -.I x, -i.e. the -number of elements contained in the set. -.IP clock -returns an integer which is the number of central processor -milliseconds of user time used by this process. -.IP expo(x) -yields the integer valued exponent of the floating-point -representation of -.I x ; -expo(\fIx\fP) = entier(log2(abs(\fIx\fP))). -.IP random(x) -where -.I x -is a real parameter, evaluated but otherwise -ignored, invokes a linear congruential random number generator. -Successive seeds are generated as (seed*a + c) mod m and -the new random number is a normalization of the seed to the range 0.0 to 1.0; -a is 62605, c is 113218009, and m is -536870912. -The initial seed -is 7774755. -.IP seed(i) -where -.I i -is an integer sets the random number generator seed -to -.I i -and returns the previous seed. -Thus seed(seed(i)) -has no effect except to yield value -.I i. -.IP sysclock -an integer function of no arguments returns the number of central processor -milliseconds of system time used by this process. -.IP undefined(x) -a Boolean function. -Its argument is a real number and -it always returns false. -.IP wallclock -an integer function of no arguments returns the time -in seconds since 00:00:00 GMT January 1, 1970. -.NH 2 -Remarks on standard and portable Pascal -.PP -It is occasionally desirable to prepare Pascal programs which will be -acceptable at other Pascal installations. -While certain system dependencies are bound to creep in, -judicious design and programming practice can usually eliminate -most of the non-portable usages. -Wirth's -.I "Pascal Report" -concludes with a standard for implementation and program exchange. -.PP -In particular, the following differences may cause trouble when attempting -to transport programs between this implementation and Pascal 6000\-3.4. -Using the -.B s -translator option may serve to indicate many problem areas.\*(dg -.FS -\*(dgThe -.B s -option does not, however, check that identifiers differ -in the first 8 characters. -.I Pi -and -.PC -also do not check the semantics of -.B packed . -.FE -.SH -Features not available in Berkeley Pascal -.IP -Segmented files and associated functions and procedures. -.IP -The function -.I trunc -with two arguments. -.IP -Arrays whose indices exceed the capacity of 16 bit arithmetic. -.SH -Features available in Berkeley Pascal but not in Pascal 6000-3.4 -.IP -The procedures -.I reset -and -.I rewrite -with file names. -.IP -The functions -.I argc, -.I seed, -.I sysclock, -and -.I wallclock. -.IP -The procedures -.I argv, -.I flush, -and -.I remove. -.IP -.I Message -with arguments other than character strings. -.IP -.I Write -with keyword -.B hex . -.IP -The -.B assert -statement. -.IP -Reading and writing of enumerated types. -.IP -Allowing functions to return structures. -.IP -Separate compilation of programs. -.IP -Comparison of records. -.SH -Other problem areas -.PP -Sets and strings are more general in \* -.UP ; -see the restrictions given in -the -Jensen-Wirth -.I "User Manual" -for details on the 6000\-3.4 restrictions. -.PP -The character set differences may cause problems, -especially the use of the function -.I chr, -characters as arguments to -.I ord, -and comparisons of characters, -since the character set ordering -differs between the two machines. -.PP -The Pascal 6000\-3.4 compiler uses a less strict notion of type equivalence. -In -.UP , -types are considered identical only if they are represented -by the same type identifier. -Thus, in particular, unnamed types are unique -to the variables/fields declared with them. -.PP -Pascal 6000\-3.4 doesn't recognize our option -flags, so it is wise to -put the control of -.UP -options to the end of option lists or, better -yet, restrict the option list length to one. -.PP -For Pascal 6000\-3.4 the ordering of files in the program statement has -significance. -It is desirable to place -.I input -and -.I output -as the first two files in the -.B program -statement. -.sp 2 -.SH -Acknowledgments -.PP -The financial support of William Joy and Susan Graham by -the National Science Foundation under grants -MCS74-07644-A04, MCS78-07291, and MCS80-05144, -and the William Joy by an -.SM IBM -Graduate Fellowship are gratefully acknowledged. diff --git a/share/doc/ps1/04.pascal/sin1.p b/share/doc/ps1/04.pascal/sin1.p deleted file mode 100644 index 21248836fe04..000000000000 --- a/share/doc/ps1/04.pascal/sin1.p +++ /dev/null @@ -1,13 +0,0 @@ -program sinout(output); -begin - - - - - - - - - -write(sin(1,2)); -end. diff --git a/share/doc/ps1/04.pascal/sin2.p b/share/doc/ps1/04.pascal/sin2.p deleted file mode 100644 index 4a2cc3177e8b..000000000000 --- a/share/doc/ps1/04.pascal/sin2.p +++ /dev/null @@ -1,13 +0,0 @@ -program sinout(output); -begin - - - - - - - - - -write(sin('*')); -end. diff --git a/share/doc/ps1/04.pascal/synerr.p b/share/doc/ps1/04.pascal/synerr.p deleted file mode 100644 index ff9b2379f2a6..000000000000 --- a/share/doc/ps1/04.pascal/synerr.p +++ /dev/null @@ -1,9 +0,0 @@ -program syn(output); -var i, j are integer; -begin - for j :* 1 to 20 begin - write(j); - i = 2 ** j; - writeln(i)) - end -end. diff --git a/share/doc/ps1/04.pascal/synerr2.p b/share/doc/ps1/04.pascal/synerr2.p deleted file mode 100644 index 4b7be594dbcb..000000000000 --- a/share/doc/ps1/04.pascal/synerr2.p +++ /dev/null @@ -1,7 +0,0 @@ -program synerr2(input,outpu); -integer a(10) -begin - read(b); - for c := 1 to 10 do - a(c) := b * c; -end. diff --git a/share/doc/ps1/04.pascal/tmac.p b/share/doc/ps1/04.pascal/tmac.p deleted file mode 100644 index 066bcd535a8f..000000000000 --- a/share/doc/ps1/04.pascal/tmac.p +++ /dev/null @@ -1,79 +0,0 @@ -'so /usr/lib/tmac/tmac.s -.if t .tr \(rh- -.if t .tr *\(**=\(eq/\(sl+\(pl -.bd S B 3 -.de SM -.if "\\$1"" .ps -2 -.if !"\\$1"" \s-2\\$1\s0\\$2 -.. -.de LG -.if "\\$1"" .ps +2 -.if !"\\$1"" \s+2\\$a\s0\\$2 -.. -.de HP -.nr pd \\n(PD -.nr PD 0 -.if \\n(.$=0 .IP -.if \\n(.$=1 .IP "\\$1" -.if \\n(.$>=2 .IP "\\$1" "\\$2" -.nr PD \\n(pd -.rm pd -.. -.de LS \"LS - Literal display, ASCII, constant spaced DS -.XD -.ID -.nf -.if t .tr '\'`\`^\(ua-\(mi -.if t .tr _\(ul -.. -.de LE \"LE - End literal display -.DE -.tr ''``__--^^ -.. -.de UP -Berkeley Pascal\\$1 -.. -.de PD -\s-2PDP\s0 -.if \\n(.$=0 11/70 -.if \\n(.$>0 11/\\$1 -.. -.de DK -Digital Equipment Corporation\\$1 -.. -.de IN -.I -.if \\n(.$<2 \\$1 1.0 Implementation Notes -.if \\n(.$>=2 \\$1 1.0 Implementation Notes\\c -.R -.if \\n(.$>=2 \\$2 -.. -.de UM -.I -User's Manual -.R -.. -.de PC -.I pc \\$1 -.. -.de PI -.I pi \\$1 -.. -.de XP -.I pxp \\$1 -.. -.de IX -.I pix \\$1 -.. -.de X -.I px \\$1 -.. -.if n .ds dg + -.if t .ds dg \(dg -.if n .ds dd * -.if t .ds dd \(dd -.if n .nr FM 1.12i -.if t .ds b \\fB -.if n .ds b \\fI -.ds i \\fI -.nr xx 1 diff --git a/share/doc/ps1/04.pascal/typequ.p b/share/doc/ps1/04.pascal/typequ.p deleted file mode 100644 index 7d080dc50d8b..000000000000 --- a/share/doc/ps1/04.pascal/typequ.p +++ /dev/null @@ -1,10 +0,0 @@ -program x(output); -var - x: ^ integer; - y: ^ integer; -begin - new(y); - x := y; - x^ := 1; - x := x; -end. diff --git a/share/doc/ps1/06.sysman/2.1.t b/share/doc/ps1/06.sysman/2.1.t deleted file mode 100644 index 428c53fed9a4..000000000000 --- a/share/doc/ps1/06.sysman/2.1.t +++ /dev/null @@ -1,138 +0,0 @@ -.\" Copyright (c) 1983 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)2.1.t 6.3 (Berkeley) 4/17/91 -.\" -.sh "Generic operations -.PP -.PP -Many system abstractions support the -operations \fIread\fP, \fIwrite\fP and \fIioctl\fP. We describe -the basics of these common primitives here. -Similarly, the mechanisms whereby normally synchronous operations -may occur in a non-blocking or asynchronous fashion are -common to all system-defined abstractions and are described here. -.NH 3 -Read and write -.PP -The \fIread\fP and \fIwrite\fP system calls can be applied -to communications channels, files, terminals and devices. -They have the form: -.DS -cc = read(fd, buf, nbytes); -result int cc; int fd; result caddr_t buf; int nbytes; - -cc = write(fd, buf, nbytes); -result int cc; int fd; caddr_t buf; int nbytes; -.DE -The \fIread\fP call transfers as much data as possible from the -object defined by \fIfd\fP to the buffer at address \fIbuf\fP of -size \fInbytes\fP. The number of bytes transferred is -returned in \fIcc\fP, which is \-1 if a return occurred before -any data was transferred because of an error or use of non-blocking -operations. -.PP -The \fIwrite\fP call transfers data from the buffer to the -object defined by \fIfd\fP. Depending on the type of \fIfd\fP, -it is possible that the \fIwrite\fP call will accept some portion -of the provided bytes; the user should resubmit the other bytes -in a later request in this case. -Error returns because of interrupted or otherwise incomplete operations -are possible. -.PP -Scattering of data on input or gathering of data for output -is also possible using an array of input/output vector descriptors. -The type for the descriptors is defined in \fI\fP as: -.DS -._f -struct iovec { - caddr_t iov_msg; /* base of a component */ - int iov_len; /* length of a component */ -}; -.DE -The calls using an array of descriptors are: -.DS -cc = readv(fd, iov, iovlen); -result int cc; int fd; struct iovec *iov; int iovlen; - -cc = writev(fd, iov, iovlen); -result int cc; int fd; struct iovec *iov; int iovlen; -.DE -Here \fIiovlen\fP is the count of elements in the \fIiov\fP array. -.NH 3 -Input/output control -.PP -Control operations on an object are performed by the \fIioctl\fP -operation: -.DS -ioctl(fd, request, buffer); -int fd, request; caddr_t buffer; -.DE -This operation causes the specified \fIrequest\fP to be performed -on the object \fIfd\fP. The \fIrequest\fP parameter specifies -whether the argument buffer is to be read, written, read and written, -or is not needed, and also the size of the buffer, as well as the -request. -Different descriptor types and subtypes within descriptor types -may use distinct \fIioctl\fP requests. For example, -operations on terminals control flushing of input and output -queues and setting of terminal parameters; operations on -disks cause formatting operations to occur; operations on tapes -control tape positioning. -.PP -The names for basic control operations are defined in \fI\fP. -.NH 3 -Non-blocking and asynchronous operations -.PP -A process that wishes to do non-blocking operations on one of -its descriptors sets the descriptor in non-blocking mode as -described in section 1.5.4. Thereafter the \fIread\fP call will -return a specific EWOULDBLOCK error indication if there is no data to be -\fIread\fP. The process may -\fIselect\fP the associated descriptor to determine when a read is -possible. -.PP -Output attempted when a descriptor can accept less than is requested -will either accept some of the provided data, returning a shorter than normal -length, or return an error indicating that the operation would block. -More output can be performed as soon as a \fIselect\fP call indicates -the object is writeable. -.PP -Operations other than data input or output -may be performed on a descriptor in a non-blocking fashion. -These operations will return with a characteristic error indicating -that they are in progress -if they cannot complete immediately. The descriptor -may then be \fIselect\fPed for \fIwrite\fP to find out -when the operation has been completed. When \fIselect\fP indicates -the descriptor is writeable, the operation has completed. -Depending on the nature of the descriptor and the operation, -additional activity may be started or the new state may be tested. diff --git a/share/doc/ps1/06.sysman/2.2.t b/share/doc/ps1/06.sysman/2.2.t deleted file mode 100644 index 7b4a17b5ceee..000000000000 --- a/share/doc/ps1/06.sysman/2.2.t +++ /dev/null @@ -1,470 +0,0 @@ -.\" Copyright (c) 1983 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)2.2.t 6.4 (Berkeley) 4/17/91 -.\" -.sh "File system -.NH 3 -Overview -.PP -The file system abstraction provides access to a hierarchical -file system structure. -The file system contains directories (each of which may contain -other sub-directories) as well as files and references to other -objects such as devices and inter-process communications sockets. -.PP -Each file is organized as a linear array of bytes. No record -boundaries or system related information is present in -a file. -Files may be read and written in a random-access fashion. -The user may read the data in a directory as though -it were an ordinary file to determine the names of the contained files, -but only the system may write into the directories. -The file system stores only a small amount of ownership, protection and usage -information with a file. -.NH 3 -Naming -.PP -The file system calls take \fIpath name\fP arguments. -These consist of a zero or more component \fIfile names\fP -separated by ``/\^'' characters, where each file name -is up to 255 ASCII characters excluding null and ``/\^''. -.PP -Each process always has two naming contexts: one for the -root directory of the file system and one for the -current working directory. These are used -by the system in the filename translation process. -If a path name begins with a ``/\^'', it is called -a full path name and interpreted relative to the root directory context. -If the path name does not begin with a ``/\^'' it is called -a relative path name and interpreted relative to the current directory -context. -.PP -The system limits -the total length of a path name to 1024 characters. -.PP -The file name ``..'' in each directory refers to -the parent directory of that directory. -The parent directory of the root of the file system is always that directory. -.PP -The calls -.DS -chdir(path); -char *path; - -chroot(path) -char *path; -.DE -change the current working directory and root directory context of a process. -Only the super-user can change the root directory context of a process. -.NH 3 -Creation and removal -.PP -The file system allows directories, files, special devices, -and ``portals'' to be created and removed from the file system. -.NH 4 -Directory creation and removal -.PP -A directory is created with the \fImkdir\fP system call: -.DS -mkdir(path, mode); -char *path; int mode; -.DE -where the mode is defined as for files (see below). -Directories are removed with the \fIrmdir\fP system call: -.DS -rmdir(path); -char *path; -.DE -A directory must be empty if it is to be deleted. -.NH 4 -File creation -.PP -Files are created with the \fIopen\fP system call, -.DS -fd = open(path, oflag, mode); -result int fd; char *path; int oflag, mode; -.DE -The \fIpath\fP parameter specifies the name of the -file to be created. The \fIoflag\fP parameter must -include O_CREAT from below to cause the file to be created. -Bits for \fIoflag\fP are -defined in \fI\fP: -.DS -._d -#define O_RDONLY 000 /* open for reading */ -#define O_WRONLY 001 /* open for writing */ -#define O_RDWR 002 /* open for read & write */ -#define O_NDELAY 004 /* non-blocking open */ -#define O_APPEND 010 /* append on each write */ -#define O_CREAT 01000 /* open with file create */ -#define O_TRUNC 02000 /* open with truncation */ -#define O_EXCL 04000 /* error on create if file exists */ -.DE -.PP -One of O_RDONLY, O_WRONLY and O_RDWR should be specified, -indicating what types of operations are desired to be performed -on the open file. The operations will be checked against the user's -access rights to the file before allowing the \fIopen\fP to succeed. -Specifying O_APPEND causes writes to automatically append to the -file. -The flag O_CREAT causes the file to be created if it does not -exist, owned by the current user -and the group of the containing directory. -The protection for the new file is specified in \fImode\fP. -The file mode is used as a three digit octal number. -Each digit encodes read access as 4, write access as 2 and execute -access as 1, or'ed together. The 0700 bits describe owner -access, the 070 bits describe the access rights for processes in the same -group as the file, and the 07 bits describe the access rights -for other processes. -.PP -If the open specifies to create the file with O_EXCL -and the file already exists, then the \fIopen\fP will fail -without affecting the file in any way. This provides a -simple exclusive access facility. -If the file exists but is a symbolic link, the open will fail -regardless of the existence of the file specified by the link. -.NH 4 -Creating references to devices -.PP -The file system allows entries which reference peripheral devices. -Peripherals are distinguished as \fIblock\fP or \fIcharacter\fP -devices according by their ability to support block-oriented -operations. -Devices are identified by their ``major'' and ``minor'' -device numbers. The major device number determines the kind -of peripheral it is, while the minor device number indicates -one of possibly many peripherals of that kind. -Structured devices have all operations performed internally -in ``block'' quantities while -unstructured devices often have a number of -special \fIioctl\fP operations, and may have input and output -performed in varying units. -The \fImknod\fP call creates special entries: -.DS -mknod(path, mode, dev); -char *path; int mode, dev; -.DE -where \fImode\fP is formed from the object type -and access permissions. The parameter \fIdev\fP is a configuration -dependent parameter used to identify specific character or -block I/O devices. -.NH 4 -Portal creation\(dg -.PP -.FS -\(dg The \fIportal\fP call is not implemented in 4.3BSD. -.FE -The call -.DS -fd = portal(name, server, param, dtype, protocol, domain, socktype) -result int fd; char *name, *server, *param; int dtype, protocol; -int domain, socktype; -.DE -places a \fIname\fP in the file system name space that causes connection to a -server process when the name is used. -The portal call returns an active portal in \fIfd\fP as though an -access had occurred to activate an inactive portal, as now described. -.PP -When an inactive portal is accessed, the system sets up a socket -of the specified \fIsocktype\fP in the specified communications -\fIdomain\fP (see section 2.3), and creates the \fIserver\fP process, -giving it the specified \fIparam\fP as argument to help it identify -the portal, and also giving it the newly created socket as descriptor -number 0. The accessor of the portal will create a socket in the same -\fIdomain\fP and \fIconnect\fP to the server. The user will then -\fIwrap\fP the socket in the specified \fIprotocol\fP to create an object of -the required descriptor type \fIdtype\fP and proceed with the -operation which was in progress before the portal was encountered. -.PP -While the server process holds the socket (which it received as \fIfd\fP -from the \fIportal\fP call on descriptor 0 at activation) further references -will result in connections being made to the same socket. -.NH 4 -File, device, and portal removal -.PP -A reference to a file, special device or portal may be removed with the -\fIunlink\fP call, -.DS -unlink(path); -char *path; -.DE -The caller must have write access to the directory in which -the file is located for this call to be successful. -.NH 3 -Reading and modifying file attributes -.PP -Detailed information about the attributes of a file -may be obtained with the calls: -.DS -#include - -stat(path, stb); -char *path; result struct stat *stb; - -fstat(fd, stb); -int fd; result struct stat *stb; -.DE -The \fIstat\fP structure includes the file -type, protection, ownership, access times, -size, and a count of hard links. -If the file is a symbolic link, then the status of the link -itself (rather than the file the link references) -may be found using the \fIlstat\fP call: -.DS -lstat(path, stb); -char *path; result struct stat *stb; -.DE -.PP -Newly created files are assigned the user id of the -process that created it and the group id of the directory -in which it was created. The ownership of a file may -be changed by either of the calls -.DS -chown(path, owner, group); -char *path; int owner, group; - -fchown(fd, owner, group); -int fd, owner, group; -.DE -.PP -In addition to ownership, each file has three levels of access -protection associated with it. These levels are owner relative, -group relative, and global (all users and groups). Each level -of access has separate indicators for read permission, write -permission, and execute permission. -The protection bits associated with a file may be set by either -of the calls: -.DS -chmod(path, mode); -char *path; int mode; - -fchmod(fd, mode); -int fd, mode; -.DE -where \fImode\fP is a value indicating the new protection -of the file, as listed in section 2.2.3.2. -.PP -Finally, the access and modify times on a file may be set by the call: -.DS -utimes(path, tvp) -char *path; struct timeval *tvp[2]; -.DE -This is particularly useful when moving files between media, to -preserve relationships between the times the file was modified. -.NH 3 -Links and renaming -.PP -Links allow multiple names for a file -to exist. Links exist independently of the file linked to. -.PP -Two types of links exist, \fIhard\fP links and \fIsymbolic\fP -links. A hard link is a reference counting mechanism that -allows a file to have multiple names within the same file -system. Symbolic links cause string substitution -during the pathname interpretation process. -.PP -Hard links and symbolic links have different -properties. A hard link insures the target -file will always be accessible, even after its original -directory entry is removed; no such guarantee exists for a symbolic link. -Symbolic links can span file systems boundaries. -.PP -The following calls create a new link, named \fIpath2\fP, -to \fIpath1\fP: -.DS -link(path1, path2); -char *path1, *path2; - -symlink(path1, path2); -char *path1, *path2; -.DE -The \fIunlink\fP primitive may be used to remove -either type of link. -.PP -If a file is a symbolic link, the ``value'' of the -link may be read with the \fIreadlink\fP call, -.DS -len = readlink(path, buf, bufsize); -result int len; result char *path, *buf; int bufsize; -.DE -This call returns, in \fIbuf\fP, the null-terminated string -substituted into pathnames passing through \fIpath\fP\|. -.PP -Atomic renaming of file system resident objects is possible -with the \fIrename\fP call: -.DS -rename(oldname, newname); -char *oldname, *newname; -.DE -where both \fIoldname\fP and \fInewname\fP must be -in the same file system. -If \fInewname\fP exists and is a directory, then it must be empty. -.NH 3 -Extension and truncation -.PP -Files are created with zero length and may be extended -simply by writing or appending to them. While a file is -open the system maintains a pointer into the file -indicating the current location in the file associated with -the descriptor. This pointer may be moved about in the -file in a random access fashion. -To set the current offset into a file, the \fIlseek\fP -call may be used, -.DS -oldoffset = lseek(fd, offset, type); -result off_t oldoffset; int fd; off_t offset; int type; -.DE -where \fItype\fP is given in \fI\fP as one of: -.DS -._d -#define L_SET 0 /* set absolute file offset */ -#define L_INCR 1 /* set file offset relative to current position */ -#define L_XTND 2 /* set offset relative to end-of-file */ -.DE -The call ``lseek(fd, 0, L_INCR)'' -returns the current offset into the file. -.PP -Files may have ``holes'' in them. Holes are void areas in the -linear extent of the file where data has never been -written. These may be created by seeking to -a location in a file past the current end-of-file and writing. -Holes are treated by the system as zero valued bytes. -.PP -A file may be truncated with either of the calls: -.DS -truncate(path, length); -char *path; int length; - -ftruncate(fd, length); -int fd, length; -.DE -reducing the size of the specified file to \fIlength\fP bytes. -.NH 3 -Checking accessibility -.PP -A process running with -different real and effective user ids -may interrogate the accessibility of a file to the -real user by using -the \fIaccess\fP call: -.DS -accessible = access(path, how); -result int accessible; char *path; int how; -.DE -Here \fIhow\fP is constructed by or'ing the following bits, defined -in \fI\fP: -.DS -._d -#define F_OK 0 /* file exists */ -#define X_OK 1 /* file is executable */ -#define W_OK 2 /* file is writable */ -#define R_OK 4 /* file is readable */ -.DE -The presence or absence of advisory locks does not affect the -result of \fIaccess\fP\|. -.NH 3 -Locking -.PP -The file system provides basic facilities that allow cooperating processes -to synchronize their access to shared files. A process may -place an advisory \fIread\fP or \fIwrite\fP lock on a file, -so that other cooperating processes may avoid interfering -with the process' access. This simple mechanism -provides locking with file granularity. More granular -locking can be built using the IPC facilities to provide a lock -manager. -The system does not force processes to obey the locks; -they are of an advisory nature only. -.PP -Locking is performed after an \fIopen\fP call by applying the -\fIflock\fP primitive, -.DS -flock(fd, how); -int fd, how; -.DE -where the \fIhow\fP parameter is formed from bits defined in \fI\fP: -.DS -._d -#define LOCK_SH 1 /* shared lock */ -#define LOCK_EX 2 /* exclusive lock */ -#define LOCK_NB 4 /* don't block when locking */ -#define LOCK_UN 8 /* unlock */ -.DE -Successive lock calls may be used to increase or -decrease the level of locking. If an object is currently -locked by another process when a \fIflock\fP call is made, -the caller will be blocked until the current lock owner -releases the lock; this may be avoided by including LOCK_NB -in the \fIhow\fP parameter. -Specifying LOCK_UN removes all locks associated with the descriptor. -Advisory locks held by a process are automatically deleted when -the process terminates. -.NH 3 -Disk quotas -.PP -As an optional facility, each file system may be requested to -impose limits on a user's disk usage. -Two quantities are limited: the total amount of disk space which -a user may allocate in a file system and the total number of files -a user may create in a file system. Quotas are expressed as -\fIhard\fP limits and \fIsoft\fP limits. A hard limit is -always imposed; if a user would exceed a hard limit, the operation -which caused the resource request will fail. A soft limit results -in the user receiving a warning message, but with allocation succeeding. -Facilities are provided to turn soft limits into hard limits if a -user has exceeded a soft limit for an unreasonable period of time. -.PP -To enable disk quotas on a file system the \fIsetquota\fP call -is used: -.DS -setquota(special, file) -char *special, *file; -.DE -where \fIspecial\fP refers to a structured device file where -a mounted file system exists, and -\fIfile\fP refers to a disk quota file (residing on the file -system associated with \fIspecial\fP) from which user quotas -should be obtained. The format of the disk quota file is -implementation dependent. -.PP -To manipulate disk quotas the \fIquota\fP call is provided: -.DS -#include - -quota(cmd, uid, arg, addr) -int cmd, uid, arg; caddr_t addr; -.DE -The indicated \fIcmd\fP is applied to the user ID \fIuid\fP. -The parameters \fIarg\fP and \fIaddr\fP are command specific. -The file \fI\fP contains definitions pertinent to the -use of this call. diff --git a/share/doc/ps1/06.sysman/2.3.t b/share/doc/ps1/06.sysman/2.3.t deleted file mode 100644 index 349371942a67..000000000000 --- a/share/doc/ps1/06.sysman/2.3.t +++ /dev/null @@ -1,412 +0,0 @@ -.\" Copyright (c) 1983 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)2.3.t 6.4 (Berkeley) 4/17/91 -.\" -.sh "Interprocess communications -.NH 3 -Interprocess communication primitives -.NH 4 -Communication domains -.PP -The system provides access to an extensible set of -communication \fIdomains\fP. A communication domain -is identified by a manifest constant defined in the -file \fI\fP. -Important standard domains supported by the system are the ``unix'' -domain, AF_UNIX, for communication within the system, the ``Internet'' -domain for communication in the DARPA Internet, AF_INET, -and the ``NS'' domain, AF_NS, for communication -using the Xerox Network Systems protocols. -Other domains can be added to the system. -.NH 4 -Socket types and protocols -.PP -Within a domain, communication takes place between communication endpoints -known as \fIsockets\fP. Each socket has the potential to exchange -information with other sockets of an appropriate type within the domain. -.PP -Each socket has an associated -abstract type, which describes the semantics of communication using that -socket. Properties such as reliability, ordering, and prevention -of duplication of messages are determined by the type. -The basic set of socket types is defined in \fI\fP: -.DS -/* Standard socket types */ -._d -#define SOCK_DGRAM 1 /* datagram */ -#define SOCK_STREAM 2 /* virtual circuit */ -#define SOCK_RAW 3 /* raw socket */ -#define SOCK_RDM 4 /* reliably-delivered message */ -#define SOCK_SEQPACKET 5 /* sequenced packets */ -.DE -The SOCK_DGRAM type models the semantics of datagrams in network communication: -messages may be lost or duplicated and may arrive out-of-order. -A datagram socket may send messages to and receive messages from multiple -peers. -The SOCK_RDM type models the semantics of reliable datagrams: messages -arrive unduplicated and in-order, the sender is notified if -messages are lost. -The \fIsend\fP and \fIreceive\fP operations (described below) -generate reliable/unreliable datagrams. -The SOCK_STREAM type models connection-based virtual circuits: two-way -byte streams with no record boundaries. -Connection setup is required before data communication may begin. -The SOCK_SEQPACKET type models a connection-based, -full-duplex, reliable, sequenced packet exchange; -the sender is notified if messages are lost, and messages are never -duplicated or presented out-of-order. -Users of the last two abstractions may use the facilities for -out-of-band transmission to send out-of-band data. -.PP -SOCK_RAW is used for unprocessed access to internal network layers -and interfaces; it has no specific semantics. -.PP -Other socket types can be defined. -.PP -Each socket may have a specific \fIprotocol\fP associated with it. -This protocol is used within the domain to provide the semantics -required by the socket type. -Not all socket types are supported by each domain; -support depends on the existence and the implementation -of a suitable protocol within the domain. -For example, within the ``Internet'' domain, the SOCK_DGRAM type may be -implemented by the UDP user datagram protocol, and the SOCK_STREAM -type may be implemented by the TCP transmission control protocol, while -no standard protocols to provide SOCK_RDM or SOCK_SEQPACKET sockets exist. -.NH 4 -Socket creation, naming and service establishment -.PP -Sockets may be \fIconnected\fP or \fIunconnected\fP. An unconnected -socket descriptor is obtained by the \fIsocket\fP call: -.DS -s = socket(domain, type, protocol); -result int s; int domain, type, protocol; -.DE -The socket domain and type are as described above, -and are specified using the definitions from \fI\fP. -The protocol may be given as 0, meaning any suitable protocol. -One of several possible protocols may be selected using identifiers -obtained from a library routine, \fIgetprotobyname\fP. -.PP -An unconnected socket descriptor of a connection-oriented type -may yield a connected socket descriptor -in one of two ways: either by actively connecting to another socket, -or by becoming associated with a name in the communications domain and -\fIaccepting\fP a connection from another socket. -Datagram sockets need not establish connections before use. -.PP -To accept connections or to receive datagrams, -a socket must first have a binding -to a name (or address) within the communications domain. -Such a binding may be established by a \fIbind\fP call: -.DS -bind(s, name, namelen); -int s; struct sockaddr *name; int namelen; -.DE -Datagram sockets may have default bindings established when first -sending data if not explicitly bound earlier. -In either case, -a socket's bound name may be retrieved with a \fIgetsockname\fP call: -.DS -getsockname(s, name, namelen); -int s; result struct sockaddr *name; result int *namelen; -.DE -while the peer's name can be retrieved with \fIgetpeername\fP: -.DS -getpeername(s, name, namelen); -int s; result struct sockaddr *name; result int *namelen; -.DE -Domains may support sockets with several names. -.NH 4 -Accepting connections -.PP -Once a binding is made to a connection-oriented socket, -it is possible to \fIlisten\fP for connections: -.DS -listen(s, backlog); -int s, backlog; -.DE -The \fIbacklog\fP specifies the maximum count of connections -that can be simultaneously queued awaiting acceptance. -.PP -An \fIaccept\fP call: -.DS -t = accept(s, name, anamelen); -result int t; int s; result struct sockaddr *name; result int *anamelen; -.DE -returns a descriptor for a new, connected, socket -from the queue of pending connections on \fIs\fP. -If no new connections are queued for acceptance, -the call will wait for a connection unless non-blocking I/O has been enabled. -.NH 4 -Making connections -.PP -An active connection to a named socket is made by the \fIconnect\fP call: -.DS -connect(s, name, namelen); -int s; struct sockaddr *name; int namelen; -.DE -Although datagram sockets do not establish connections, -the \fIconnect\fP call may be used with such sockets -to create an \fIassociation\fP with the foreign address. -The address is recorded for use in future \fIsend\fP calls, -which then need not supply destination addresses. -Datagrams will be received only from that peer, -and asynchronous error reports may be received. -.PP -It is also possible to create connected pairs of sockets without -using the domain's name space to rendezvous; this is done with the -\fIsocketpair\fP call\(dg: -.FS -\(dg 4.3BSD supports \fIsocketpair\fP creation only in the ``unix'' -communication domain. -.FE -.DS -socketpair(domain, type, protocol, sv); -int domain, type, protocol; result int sv[2]; -.DE -Here the returned \fIsv\fP descriptors correspond to those obtained with -\fIaccept\fP and \fIconnect\fP. -.PP -The call -.DS -pipe(pv) -result int pv[2]; -.DE -creates a pair of SOCK_STREAM sockets in the UNIX domain, -with pv[0] only writable and pv[1] only readable. -.NH 4 -Sending and receiving data -.PP -Messages may be sent from a socket by: -.DS -cc = sendto(s, buf, len, flags, to, tolen); -result int cc; int s; caddr_t buf; int len, flags; caddr_t to; int tolen; -.DE -if the socket is not connected or: -.DS -cc = send(s, buf, len, flags); -result int cc; int s; caddr_t buf; int len, flags; -.DE -if the socket is connected. -The corresponding receive primitives are: -.DS -msglen = recvfrom(s, buf, len, flags, from, fromlenaddr); -result int msglen; int s; result caddr_t buf; int len, flags; -result caddr_t from; result int *fromlenaddr; -.DE -and -.DS -msglen = recv(s, buf, len, flags); -result int msglen; int s; result caddr_t buf; int len, flags; -.DE -.PP -In the unconnected case, -the parameters \fIto\fP and \fItolen\fP -specify the destination or source of the message, while -the \fIfrom\fP parameter stores the source of the message, -and \fI*fromlenaddr\fP initially gives the size of the \fIfrom\fP -buffer and is updated to reflect the true length of the \fIfrom\fP -address. -.PP -All calls cause the message to be received in or sent from -the message buffer of length \fIlen\fP bytes, starting at address \fIbuf\fP. -The \fIflags\fP specify -peeking at a message without reading it or sending or receiving -high-priority out-of-band messages, as follows: -.DS -._d -#define MSG_PEEK 0x1 /* peek at incoming message */ -#define MSG_OOB 0x2 /* process out-of-band data */ -.DE -.NH 4 -Scatter/gather and exchanging access rights -.PP -It is possible scatter and gather data and to exchange access rights -with messages. When either of these operations is involved, -the number of parameters to the call becomes large. -Thus the system defines a message header structure, in \fI\fP, -which can be -used to conveniently contain the parameters to the calls: -.DS -.if t .ta .5i 1.25i 2i 2.7i -.if n ._f -struct msghdr { - caddr_t msg_name; /* optional address */ - int msg_namelen; /* size of address */ - struct iov *msg_iov; /* scatter/gather array */ - int msg_iovlen; /* # elements in msg_iov */ - caddr_t msg_accrights; /* access rights sent/received */ - int msg_accrightslen; /* size of msg_accrights */ -}; -.DE -Here \fImsg_name\fP and \fImsg_namelen\fP specify the source or destination -address if the socket is unconnected; \fImsg_name\fP may be given as -a null pointer if no names are desired or required. -The \fImsg_iov\fP and \fImsg_iovlen\fP describe the scatter/gather -locations, as described in section 2.1.3. -Access rights to be sent along with the message are specified -in \fImsg_accrights\fP, which has length \fImsg_accrightslen\fP. -In the ``unix'' domain these are an array of integer descriptors, -taken from the sending process and duplicated in the receiver. -.PP -This structure is used in the operations \fIsendmsg\fP and \fIrecvmsg\fP: -.DS -sendmsg(s, msg, flags); -int s; struct msghdr *msg; int flags; - -msglen = recvmsg(s, msg, flags); -result int msglen; int s; result struct msghdr *msg; int flags; -.DE -.NH 4 -Using read and write with sockets -.PP -The normal UNIX \fIread\fP and \fIwrite\fP calls may be -applied to connected sockets and translated into \fIsend\fP and \fIreceive\fP -calls from or to a single area of memory and discarding any rights -received. A process may operate on a virtual circuit socket, a terminal -or a file with blocking or non-blocking input/output -operations without distinguishing the descriptor type. -.NH 4 -Shutting down halves of full-duplex connections -.PP -A process that has a full-duplex socket such as a virtual circuit -and no longer wishes to read from or write to this socket can -give the call: -.DS -shutdown(s, direction); -int s, direction; -.DE -where \fIdirection\fP is 0 to not read further, 1 to not -write further, or 2 to completely shut the connection down. -If the underlying protocol supports unidirectional or bidirectional shutdown, -this indication will be passed to the peer. -For example, a shutdown for writing might produce an end-of-file -condition at the remote end. -.NH 4 -Socket and protocol options -.PP -Sockets, and their underlying communication protocols, may -support \fIoptions\fP. These options may be used to manipulate -implementation- or protocol-specific facilities. -The \fIgetsockopt\fP -and \fIsetsockopt\fP calls are used to control options: -.DS -getsockopt(s, level, optname, optval, optlen) -int s, level, optname; result caddr_t optval; result int *optlen; - -setsockopt(s, level, optname, optval, optlen) -int s, level, optname; caddr_t optval; int optlen; -.DE -The option \fIoptname\fP is interpreted at the indicated -protocol \fIlevel\fP for socket \fIs\fP. If a value is specified -with \fIoptval\fP and \fIoptlen\fP, it is interpreted by -the software operating at the specified \fIlevel\fP. The \fIlevel\fP -SOL_SOCKET is reserved to indicate options maintained -by the socket facilities. Other \fIlevel\fP values indicate -a particular protocol which is to act on the option request; -these values are normally interpreted as a ``protocol number''. -.NH 3 -UNIX domain -.PP -This section describes briefly the properties of the UNIX communications -domain. -.NH 4 -Types of sockets -.PP -In the UNIX domain, -the SOCK_STREAM abstraction provides pipe-like -facilities, while SOCK_DGRAM provides (usually) -reliable message-style communications. -.NH 4 -Naming -.PP -Socket names are strings and may appear in the UNIX file -system name space through portals\(dg. -.FS -\(dg The 4.3BSD implementation of the UNIX domain embeds -bound sockets in the UNIX file system name space; -this may change in future releases. -.FE -.NH 4 -Access rights transmission -.PP -The ability to pass UNIX descriptors with messages in this domain -allows migration of service within the system and allows -user processes to be used in building system facilities. -.NH 3 -INTERNET domain -.PP -This section describes briefly how the Internet domain is -mapped to the model described in this section. More -information will be found in the document describing the -network implementation in 4.3BSD. -.NH 4 -Socket types and protocols -.PP -SOCK_STREAM is supported by the Internet TCP protocol; -SOCK_DGRAM by the UDP protocol. -Each is layered atop the transport-level Internet Protocol (IP). -The Internet Control Message Protocol is implemented atop/beside IP -and is accessible via a raw socket. -The SOCK_SEQPACKET -has no direct Internet family analogue; a protocol -based on one from the XEROX NS family and layered on -top of IP could be implemented to fill this gap. -.NH 4 -Socket naming -.PP -Sockets in the Internet domain have names composed of the 32 bit -Internet address, and a 16 bit port number. -Options may be used to -provide IP source routing or security options. -The 32-bit address is composed of network and host parts; -the network part is variable in size and is frequency encoded. -The host part may optionally be interpreted as a subnet field -plus the host on subnet; this is is enabled by setting a network address -mask at boot time. -.NH 4 -Access rights transmission -.PP -No access rights transmission facilities are provided in the Internet domain. -.NH 4 -Raw access -.PP -The Internet domain allows the super-user access to the raw facilities -of IP. -These interfaces are modeled as SOCK_RAW sockets. -Each raw socket is associated with one IP protocol number, -and receives all traffic received for that protocol. -This allows administrative and debugging -functions to occur, -and enables user-level implementations of special-purpose protocols -such as inter-gateway routing protocols. diff --git a/share/doc/ps1/06.sysman/2.4.t b/share/doc/ps1/06.sysman/2.4.t deleted file mode 100644 index 76580853cf24..000000000000 --- a/share/doc/ps1/06.sysman/2.4.t +++ /dev/null @@ -1,174 +0,0 @@ -.\" Copyright (c) 1983 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)2.4.t 6.3 (Berkeley) 4/17/91 -.\" -.sh "Terminals and Devices -.NH 3 -Terminals -.PP -Terminals support \fIread\fP and \fIwrite\fP I/O operations, -as well as a collection of terminal specific \fIioctl\fP operations, -to control input character interpretation and editing, -and output format and delays. -.NH 4 -Terminal input -.PP -Terminals are handled according to the underlying communication -characteristics such as baud rate and required delays, -and a set of software parameters. -.NH 5 -Input modes -.PP -A terminal is in one of three possible modes: \fIraw\fP, \fIcbreak\fP, -or \fIcooked\fP. -In raw mode all input is passed through to the -reading process immediately and without interpretation. -In cbreak mode, the handler interprets input only by looking -for characters that cause interrupts or output flow control; -all other characters are made available as in raw mode. -In cooked mode, input -is processed to provide standard line-oriented local editing functions, -and input is presented on a line-by-line basis. -.NH 5 -Interrupt characters -.PP -Interrupt characters are interpreted by the terminal handler only in -cbreak and cooked modes, and -cause a software interrupt to be sent to all processes in the process -group associated with the terminal. Interrupt characters exist -to send SIGINT -and SIGQUIT signals, -and to stop a process group -with the SIGTSTP signal either immediately, or when -all input up to the stop character has been read. -.NH 5 -Line editing -.PP -When the terminal is in cooked mode, editing of an input line -is performed. Editing facilities allow deletion of the previous -character or word, or deletion of the current input line. -In addition, a special character may be used to reprint the current -input line after some number of editing operations have been applied. -.PP -Certain other characters are interpreted specially when a process is -in cooked mode. The \fIend of line\fP character determines -the end of an input record. The \fIend of file\fP character simulates -an end of file occurrence on terminal input. Flow control is provided -by \fIstop output\fP and \fIstart output\fP control characters. Output -may be flushed with the \fIflush output\fP character; and a \fIliteral -character\fP may be used to force literal input of the immediately -following character in the input line. -.PP -Input characters may be echoed to the terminal as they are received. -Non-graphic ASCII input characters may be echoed as a two-character -printable representation, ``^character.'' -.NH 4 -Terminal output -.PP -On output, the terminal handler provides some simple formatting services. -These include converting the carriage return character to the -two character return-linefeed sequence, -inserting delays after certain standard control characters, -expanding tabs, and providing translations -for upper-case only terminals. -.NH 4 -Terminal control operations -.PP -When a terminal is first opened it is initialized to a standard -state and configured with a set of standard control, editing, -and interrupt characters. A process -may alter this configuration with certain -control operations, specifying parameters in a standard structure:\(dg -.FS -\(dg The control interface described here is an internal interface only -in 4.3BSD. Future releases will probably use a modified interface -based on currently-proposed standards. -.FE -.DS -._f -struct ttymode { - short tt_ispeed; /* input speed */ - int tt_iflags; /* input flags */ - short tt_ospeed; /* output speed */ - int tt_oflags; /* output flags */ -}; -.DE -and ``special characters'' are specified with the -\fIttychars\fP structure, -.DS -._f -struct ttychars { - char tc_erasec; /* erase char */ - char tc_killc; /* erase line */ - char tc_intrc; /* interrupt */ - char tc_quitc; /* quit */ - char tc_startc; /* start output */ - char tc_stopc; /* stop output */ - char tc_eofc; /* end-of-file */ - char tc_brkc; /* input delimiter (like nl) */ - char tc_suspc; /* stop process signal */ - char tc_dsuspc; /* delayed stop process signal */ - char tc_rprntc; /* reprint line */ - char tc_flushc; /* flush output (toggles) */ - char tc_werasc; /* word erase */ - char tc_lnextc; /* literal next character */ -}; -.DE -.NH 4 -Terminal hardware support -.PP -The terminal handler allows a user to access basic -hardware related functions; e.g. line speed, -modem control, parity, and stop bits. A special signal, -SIGHUP, is automatically -sent to processes in a terminal's process -group when a carrier transition is detected. This is -normally associated with a user hanging up on a modem -controlled terminal line. -.NH 3 -Structured devices -.PP -Structures devices are typified by disks and magnetic -tapes, but may represent any random-access device. -The system performs read-modify-write type buffering actions on block -devices to allow them to be read and written in a totally random -access fashion like ordinary files. -File systems are normally created in block devices. -.NH 3 -Unstructured devices -.PP -Unstructured devices are those devices which -do not support block structure. Familiar unstructured devices -are raw communications lines (with -no terminal handler), raster plotters, magnetic tape and disks unfettered -by buffering and permitting large block input/output and positioning -and formatting commands. diff --git a/share/doc/ps1/06.sysman/2.5.t b/share/doc/ps1/06.sysman/2.5.t deleted file mode 100644 index 0d0f03b824c1..000000000000 --- a/share/doc/ps1/06.sysman/2.5.t +++ /dev/null @@ -1,39 +0,0 @@ -.\" Copyright (c) 1983 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)2.5.t 6.3 (Berkeley) 4/17/91 -.\" -.sh "Process and kernel descriptors -.PP -The status of the facilities in this section is still under discussion. -The \fIptrace\fP facility of earlier UNIX systems -remains in 4.3BSD. -Planned enhancements would allow a descriptor-based process control facility. diff --git a/share/doc/ps1/06.sysman/Makefile b/share/doc/ps1/06.sysman/Makefile deleted file mode 100644 index 00972488f99c..000000000000 --- a/share/doc/ps1/06.sysman/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# from: @(#)Makefile 6.2 (Berkeley) 6/30/90 -# $Id: Makefile,v 1.6 1994/01/24 22:36:41 cgd Exp $ - -DIR= ps1/06.sysman -DOC= 06.sysman - -SRCS= 0.t 1.0.t 1.1.t 1.2.t 1.3.t 1.4.t 1.5.t 1.6.t 1.7.t \ - 2.0.t 2.1.t 2.2.t 2.3.t 2.4.t 2.5.t a.t -MACROS= -ms - -.include - -${DOC}.${PRINTER_TYPE}: ${SRCS} - ( cd ${.CURDIR} ; ${TBL} ${SRCS} ) | ${ROFF} > ${.TARGET} diff --git a/share/doc/ps1/06.sysman/a.t b/share/doc/ps1/06.sysman/a.t deleted file mode 100644 index c6e482a56278..000000000000 --- a/share/doc/ps1/06.sysman/a.t +++ /dev/null @@ -1,242 +0,0 @@ -.\" Copyright (c) 1983 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)a.t 6.6 (Berkeley) 4/17/91 -.\" -.ds RH Summary of facilities -.bp -.SH -\s+2I. Summary of facilities\s0 -.PP -.de h -.br -.if n .ne 8 -\fB\\$1 \\$2\fP -.br -.. -.nr H1 0 -.NH -Kernel primitives -.LP -.h 1.1. "Process naming and protection -.in +5 -.TS -lw(1.6i) aw(3i). -sethostid set UNIX host id -gethostid get UNIX host id -sethostname set UNIX host name -gethostname get UNIX host name -getpid get process id -fork create new process -exit terminate a process -execve execute a different process -getuid get user id -geteuid get effective user id -setreuid set real and effective user id's -getgid get accounting group id -getegid get effective accounting group id -getgroups get access group set -setregid set real and effective group id's -setgroups set access group set -getpgrp get process group -setpgrp set process group -.TE -.in -5 -.h 1.2 "Memory management -.in +5 -.TS -lw(1.6i) aw(3i). - memory management definitions -sbrk change data section size -sstk\(dg change stack section size -.FS -\(dg Not supported in 4.3BSD. -.FE -getpagesize get memory page size -mmap\(dg map pages of memory -msync\(dg flush modified mapped pages to filesystem -munmap\(dg unmap memory -mprotect\(dg change protection of pages -madvise\(dg give memory management advice -mincore\(dg determine core residency of pages -msleep\(dg sleep on a lock -mwakeup\(dg wakeup process sleeping on a lock -.TE -.in -5 -.h 1.3 "Signals -.in +5 -.TS -lw(1.6i) aw(3i). - signal definitions -sigvec set handler for signal -kill send signal to process -killpgrp send signal to process group -sigblock block set of signals -sigsetmask restore set of blocked signals -sigpause wait for signals -sigstack set software stack for signals -.TE -.in -5 -.h 1.4 "Timing and statistics -.in +5 -.TS -lw(1.6i) aw(3i). - time-related definitions -gettimeofday get current time and timezone -settimeofday set current time and timezone -getitimer read an interval timer -setitimer get and set an interval timer -profil profile process -.TE -.in -5 -.h 1.5 "Descriptors -.in +5 -.TS -lw(1.6i) aw(3i). -getdtablesize descriptor reference table size -dup duplicate descriptor -dup2 duplicate to specified index -close close descriptor -select multiplex input/output -fcntl control descriptor options -wrap\(dg wrap descriptor with protocol -.FS -\(dg Not supported in 4.3BSD. -.FE -.TE -.in -5 -.h 1.6 "Resource controls -.in +5 -.TS -lw(1.6i) aw(3i). - resource-related definitions -getpriority get process priority -setpriority set process priority -getrusage get resource usage -getrlimit get resource limitations -setrlimit set resource limitations -.TE -.in -5 -.h 1.7 "System operation support -.in +5 -.TS -lw(1.6i) aw(3i). -mount mount a device file system -swapon add a swap device -umount umount a file system -sync flush system caches -reboot reboot a machine -acct specify accounting file -.TE -.in -5 -.NH -System facilities -.LP -.h 2.1 "Generic operations -.in +5 -.TS -lw(1.6i) aw(3i). -read read data -write write data - scatter-gather related definitions -readv scattered data input -writev gathered data output - standard control operations -ioctl device control operation -.TE -.in -5 -.h 2.2 "File system -.PP -Operations marked with a * exist in two forms: as shown, -operating on a file name, and operating on a file descriptor, -when the name is preceded with a ``f''. -.in +5 -.TS -lw(1.6i) aw(3i). - file system definitions -chdir change directory -chroot change root directory -mkdir make a directory -rmdir remove a directory -open open a new or existing file -mknod make a special file -portal\(dg make a portal entry -unlink remove a link -stat* return status for a file -lstat returned status of link -chown* change owner -chmod* change mode -utimes change access/modify times -link make a hard link -symlink make a symbolic link -readlink read contents of symbolic link -rename change name of file -lseek reposition within file -truncate* truncate file -access determine accessibility -flock lock a file -.TE -.in -5 -.h 2.3 "Communications -.in +5 -.TS -lw(1.6i) aw(3i). - standard definitions -socket create socket -bind bind socket to name -getsockname get socket name -listen allow queuing of connections -accept accept a connection -connect connect to peer socket -socketpair create pair of connected sockets -sendto send data to named socket -send send data to connected socket -recvfrom receive data on unconnected socket -recv receive data on connected socket -sendmsg send gathered data and/or rights -recvmsg receive scattered data and/or rights -shutdown partially close full-duplex connection -getsockopt get socket option -setsockopt set socket option -.TE -.in -5 -.h 2.4 "Terminals, block and character devices -.in +5 -.TS -lw(1.6i) aw(3i). -.TE -.in -5 -.h 2.5 "Processes and kernel hooks -.in +5 -.TS -lw(1.6i) aw(3i). -.TE -.in -5 diff --git a/share/doc/ps1/06.sysman/spell.ok b/share/doc/ps1/06.sysman/spell.ok deleted file mode 100644 index b0cbd9ce9cf5..000000000000 --- a/share/doc/ps1/06.sysman/spell.ok +++ /dev/null @@ -1,332 +0,0 @@ -AF -ANON -AUTOBOOT -Behav -CLR -DEF -DGRAM -DONTNEED -Datagram -Datagrams -EINPROGRESS -EWOULDBLOCK -EXCL -FD -FSIZE -Fabry -GETFL -GETOWN -HASSEMAPHORE -HASSEMPHORE -IGN -INCR -INET -IP -IPC -ISSET -ITIMER -Karels -Leffler -MADV -MAXHOSTNAMELEN -MSG -Manual''PS1:6 -McKusick -Mclear -Mset -NB -NDELAY -NGROUPS -NLIMITS -NOEXTEND -NS -OOB -PGRP -PRIO -PROT -PS1:6 -RB -RDM -RDONLY -RDWR -RH -RLIM -RLIMIT -RSS -RUSAGE -SEQPACKET -SETFL -SETOWN -SIG -SIGALRM -SIGBUS -SIGCHLD -SIGCONT -SIGEMT -SIGFPE -SIGHUP -SIGILL -SIGINT -SIGIO -SIGIOT -SIGKILL -SIGPROF -SIGQUIT -SIGSEGV -SIGSTOP -SIGTERM -SIGTRAP -SIGTSTP -SIGTTIN -SIGTTOU -SIGURG -SIGUSR1 -SIGUSR2 -SIGVTALRM -SIGXCPU -SIGXFSZ -Sem -Sv -TCP -TRUNC -UDP -VAX -WILLNEED -WRONLY -XTND -accessor -accrights -accrightslen -addr -anamelen -arg -argv -arusage -astatus -behav -blkdev -brkc -bu -buf -buflen -bufsize -caddr -cbreak -chroot -cmd -datagram -datagrams -dev -dopt -dprop -ds -dst -dsttime -dsuspc -dtype -dup2 -egid -envp -eofc -erasec -errno -euid -fchmod -fchown -fcntl -fd -fdset -file.h -filename -filesystem -flushc -fromlenaddr -fs -fstat -ftruncate -getdtablesize -getegid -geteuid -getgid -getgroups -gethostid -gethostname -getitimer -getpagesize -getpeername -getpriority -getprotobyname -getrlimit -getrusage -getsockname -getsockopt -gettimeofday -gid -gidset -gidsetsize -hostid -idrss -iflags -inblock -incr -intrc -ioctl.h -iov -iovec -iovlen -ispeed -isrss -itimerval -ixrss -kbytes -killc -killpgrp -len -linefeed -lnextc -lstat -maddr -madvise -majflt -maxrss -mclear -mincore -minflt -minuteswest -mman.h -mmap -mprotect -mremap -mset -msg -msghdr -msglen -msgrcv -msgsnd -msleep -msync -munmap -mwakeup -namelen -nbytes -nd -nds -newname -ngroups -nivcsw -nl -nsignals -nswap -nvcsw -oflag -oflags -oldmask -oldname -oldoffset -onstack -optlen -optname -optval -or'ed -or'ing -ospeed -oss -osv -oublock -ovalue -pagesize -param -param.h -path1 -path2 -pathname -pathnames -pgrp -pid -pos -prio -prot -proto -pv -quitc -quota.h -readlink -readv -reboot.h -recv -recvfrom -recvmsg -resource.h -rgid -rlim -rlimit -rlp -ronly -rprntc -ru -ruid -rusage -sbrk -scp -sem -sendmsg -sendto -setgroups -sethostid -sethostname -setitimer -setpriority -setquota -setregid -setreuid -setrlimit -setsockopt -settimeofday -sigblock -sigcontext -sigmask -signal.h -signo -sigpause -sigsetmask -sigstack -sigvec -sockaddr -socket.h -socketpair -socktype -sp -ss -sstk -startc -stat.h -stb -stopc -suspc -sv -sw -symlink -ta -time.h -timeval -timezone -tolen -tt -ttychars -ttymode -tv -tvp -tvsec -types.h -tz -tzp -uid -uio.h -umount -usec -vec -wait.h -waitstatus -werasc -writeable -writev diff --git a/share/doc/ps1/07.ipctut/pipe.grn b/share/doc/ps1/07.ipctut/pipe.grn deleted file mode 100644 index e87237be5bd6..000000000000 --- a/share/doc/ps1/07.ipctut/pipe.grn +++ /dev/null @@ -1,405 +0,0 @@ -gremlinfile -1 208.00 256.00 -3 -208.00 256.00 -432.00 256.00 --1.00 -1.00 -1 0 -0 - 0 -384.00 244.00 -384.00 244.00 -402.00 244.00 -420.00 244.00 --1.00 -1.00 -1 1 -5 child - 0 -232.00 244.00 -232.00 244.00 -253.00 244.00 -274.00 244.00 --1.00 -1.00 -1 1 -6 parent - 0 -232.00 468.00 -232.00 468.00 -253.00 468.00 -274.00 468.00 --1.00 -1.00 -1 1 -6 parent - 3 -340.00 104.00 -339.45 115.65 -336.67 108.99 -329.46 108.99 -340.00 104.00 --1.00 -1.00 -6 0 -0 - 3 -300.00 100.00 -309.84 106.26 -302.68 105.37 -299.11 111.63 -300.00 100.00 --1.00 -1.00 -6 0 -0 - 4 -376.80 169.60 -373.60 169.60 -376.80 172.80 -376.80 166.40 -380.00 169.60 -373.60 169.60 --1.00 -1.00 -6 0 -0 - 4 -376.80 156.80 -373.60 156.80 -376.80 160.00 -376.80 153.60 -380.00 156.80 -373.60 156.80 --1.00 -1.00 -6 0 -0 - 3 -368.00 163.20 -419.20 163.20 -419.20 150.40 -368.00 150.40 -368.00 137.60 -419.20 137.60 -419.20 124.80 -368.00 124.80 --1.00 -1.00 -6 0 -0 - 3 -393.60 176.00 -393.60 192.00 --1.00 -1.00 -6 0 -0 - 3 -368.00 176.00 -368.00 112.00 -419.20 112.00 -419.20 176.00 -368.00 176.00 --1.00 -1.00 -6 0 -0 - 4 -393.60 214.40 -416.00 214.40 -393.60 236.80 -393.60 192.00 -416.00 214.40 -371.20 214.40 --1.00 -1.00 -6 0 -0 - 3 -358.40 108.80 -359.12 118.10 -356.25 113.09 -350.53 113.81 -358.40 108.80 --1.00 -1.00 -6 0 -0 - 5 -272.00 169.60 -297.60 169.60 -323.20 160.00 -358.40 108.80 --1.00 -1.00 -6 0 -0 - 4 -268.80 169.60 -265.60 169.60 -268.80 172.80 -268.80 166.40 -272.00 169.60 -265.60 169.60 --1.00 -1.00 -6 0 -0 - 3 -352.00 51.20 -249.60 51.20 --1.00 -1.00 -6 0 -0 - 3 -249.60 83.20 -352.00 83.20 --1.00 -1.00 -6 0 -0 - 4 -352.00 67.20 -352.00 51.20 -352.00 83.20 --1.00 -1.00 -6 180 -0 - 4 -249.60 67.20 -249.60 83.20 -249.60 83.20 -249.60 51.20 -265.60 67.20 -233.60 67.20 --1.00 -1.00 -6 0 -0 - 3 -275.20 92.80 -284.25 95.06 -278.59 96.19 -277.46 101.85 -275.20 92.80 --1.00 -1.00 -6 0 -0 - 5 -272.00 156.80 -297.60 153.60 -300.80 128.00 -284.80 102.40 -275.20 92.80 --1.00 -1.00 -6 0 -0 - 4 -268.80 156.80 -265.60 156.80 -268.80 160.00 -268.80 153.60 -272.00 156.80 -265.60 156.80 --1.00 -1.00 -6 0 -0 - 3 -224.00 163.20 -275.20 163.20 -275.20 150.40 -224.00 150.40 -224.00 137.60 -275.20 137.60 -275.20 124.80 -224.00 124.80 --1.00 -1.00 -6 0 -0 - 3 -249.60 176.00 -249.60 192.00 --1.00 -1.00 -6 0 -0 - 3 -224.00 176.00 -224.00 112.00 -275.20 112.00 -275.20 176.00 -224.00 176.00 --1.00 -1.00 -6 0 -0 - 4 -249.60 214.40 -272.00 214.40 -249.60 236.80 -249.60 192.00 -272.00 214.40 -227.20 214.40 --1.00 -1.00 -6 0 -0 - 3 -358.40 332.80 -359.12 342.10 -356.25 337.09 -350.53 337.81 -358.40 332.80 --1.00 -1.00 -6 0 -0 - 5 -272.00 393.60 -297.60 393.60 -323.20 384.00 -358.40 332.80 --1.00 -1.00 -6 0 -0 - 4 -268.80 393.60 -265.60 393.60 -268.80 396.80 -268.80 390.40 -272.00 393.60 -265.60 393.60 --1.00 -1.00 -6 0 -0 - 3 -352.00 275.20 -249.60 275.20 --1.00 -1.00 -6 0 -0 - 3 -249.60 307.20 -352.00 307.20 --1.00 -1.00 -6 0 -0 - 4 -352.00 291.20 -352.00 275.20 -352.00 307.20 --1.00 -1.00 -6 180 -0 - 4 -249.60 291.20 -249.60 307.20 -249.60 307.20 -249.60 275.20 -265.60 291.20 -233.60 291.20 --1.00 -1.00 -6 0 -0 - 3 -275.20 316.80 -284.25 319.06 -278.59 320.19 -277.46 325.85 -275.20 316.80 --1.00 -1.00 -6 0 -0 - 5 -272.00 380.80 -297.60 377.60 -300.80 352.00 -284.80 326.40 -275.20 316.80 --1.00 -1.00 -6 0 -0 - 4 -268.80 380.80 -265.60 380.80 -268.80 384.00 -268.80 377.60 -272.00 380.80 -265.60 380.80 --1.00 -1.00 -6 0 -0 - 3 -224.00 387.20 -275.20 387.20 -275.20 374.40 -224.00 374.40 -224.00 361.60 -275.20 361.60 -275.20 348.80 -224.00 348.80 --1.00 -1.00 -6 0 -0 - 3 -249.60 400.00 -249.60 416.00 --1.00 -1.00 -6 0 -0 - 3 -224.00 400.00 -224.00 336.00 -275.20 336.00 -275.20 400.00 -224.00 400.00 --1.00 -1.00 -6 0 -0 - 4 -249.60 438.40 -272.00 438.40 -249.60 460.80 -249.60 416.00 -272.00 438.40 -227.20 438.40 --1.00 -1.00 -6 0 -0 - 3 -272.00 292.00 -284.00 300.00 -284.00 296.00 -304.00 296.00 -304.00 288.00 -284.00 288.00 -284.00 284.00 -272.00 292.00 --1.00 -1.00 -6 0 -0 - 3 -272.00 68.00 -284.00 76.00 -284.00 72.00 -304.00 72.00 -304.00 64.00 -284.00 64.00 -284.00 60.00 -272.00 68.00 --1.00 -1.00 -6 0 -0 - 0 -316.00 64.00 -316.00 64.00 -331.00 64.00 -346.00 64.00 --1.00 -1.00 -1 1 -4 PIPE - 0 -316.00 288.00 -316.00 288.00 -331.00 288.00 -346.00 288.00 --1.00 -1.00 -1 1 -4 PIPE - 5 -372.00 156.00 -348.00 156.00 -300.00 100.00 --1.00 -1.00 -6 0 -0 - 5 -372.00 168.00 -332.00 160.00 -324.00 136.00 -340.00 104.00 --1.00 -1.00 -6 0 -0 - -1 diff --git a/share/doc/ps1/07.ipctut/socketpair.c b/share/doc/ps1/07.ipctut/socketpair.c deleted file mode 100644 index f85bbb603f23..000000000000 --- a/share/doc/ps1/07.ipctut/socketpair.c +++ /dev/null @@ -1,78 +0,0 @@ -.\" Copyright (c) 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)socketpair.c 6.4 (Berkeley) 4/17/91 -.\" $Id: socketpair.c,v 1.2 1993/08/01 18:23:29 mycroft Exp $ -.\" -#include -#include -#include - -#define DATA1 "In Xanadu, did Kublai Khan . . ." -#define DATA2 "A stately pleasure dome decree . . ." - -/* - * This program creates a pair of connected sockets then forks and - * communicates over them. This is very similar to communication with pipes, - * however, socketpairs are two-way communications objects. Therefore I can - * send messages in both directions. - */ - -main() -{ - int sockets[2], child; - char buf[1024]; - - if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0) { - perror("opening stream socket pair"); - exit(1); - } - - if ((child = fork()) == -1) - perror("fork"); - else if (child) { /* This is the parent. */ - close(sockets[0]); - if (read(sockets[1], buf, 1024, 0) < 0) - perror("reading stream message"); - printf("-->%s\en", buf); - if (write(sockets[1], DATA2, sizeof(DATA2)) < 0) - perror("writing stream message"); - close(sockets[1]); - } else { /* This is the child. */ - close(sockets[1]); - if (write(sockets[0], DATA1, sizeof(DATA1)) < 0) - perror("writing stream message"); - if (read(sockets[0], buf, 1024, 0) < 0) - perror("reading stream message"); - printf("-->%s\en", buf); - close(sockets[0]); - } -} diff --git a/share/doc/ps1/07.ipctut/socketpair.grn b/share/doc/ps1/07.ipctut/socketpair.grn deleted file mode 100644 index 7314df99aca4..000000000000 --- a/share/doc/ps1/07.ipctut/socketpair.grn +++ /dev/null @@ -1,407 +0,0 @@ -gremlinfile -1 208.00 256.00 -3 -208.00 256.00 -432.00 256.00 --1.00 -1.00 -1 0 -0 - 3 -332.00 284.00 -320.33 291.00 -325.00 284.00 -320.33 277.00 -332.00 284.00 --1.00 -1.00 -6 0 -0 - 3 -272.00 296.00 -282.00 290.00 -278.00 296.00 -282.00 302.00 -272.00 296.00 --1.00 -1.00 -6 0 -0 - 3 -264.00 284.00 -328.00 284.00 --1.00 -1.00 -4 0 -0 - 3 -272.00 296.00 -336.00 296.00 --1.00 -1.00 -4 0 -0 - 3 -332.00 60.00 -320.33 67.00 -325.00 60.00 -320.33 53.00 -332.00 60.00 --1.00 -1.00 -6 0 -0 - 3 -272.00 72.00 -282.00 66.00 -278.00 72.00 -282.00 78.00 -272.00 72.00 --1.00 -1.00 -6 0 -0 - 3 -264.00 60.00 -328.00 60.00 --1.00 -1.00 -4 0 -0 - 3 -272.00 72.00 -336.00 72.00 --1.00 -1.00 -4 0 -0 - 0 -384.00 244.00 -384.00 244.00 -402.00 244.00 -420.00 244.00 --1.00 -1.00 -1 1 -5 child - 4 -353.60 67.20 -353.60 83.20 -353.60 83.20 -353.60 51.20 -369.60 67.20 -337.60 67.20 --1.00 -1.00 -6 0 -0 - 4 -249.60 67.20 -249.60 83.20 -249.60 83.20 -249.60 51.20 -265.60 67.20 -233.60 67.20 --1.00 -1.00 -6 0 -0 - 4 -353.60 291.20 -353.60 307.20 -353.60 307.20 -353.60 275.20 -369.60 291.20 -337.60 291.20 --1.00 -1.00 -6 0 -0 - 0 -232.00 244.00 -232.00 244.00 -253.00 244.00 -274.00 244.00 --1.00 -1.00 -1 1 -6 parent - 0 -232.00 468.00 -232.00 468.00 -253.00 468.00 -274.00 468.00 --1.00 -1.00 -1 1 -6 parent - 3 -340.00 104.00 -339.45 115.65 -336.67 108.99 -329.46 108.99 -340.00 104.00 --1.00 -1.00 -6 0 -0 - 3 -300.00 100.00 -309.84 106.26 -302.68 105.37 -299.11 111.63 -300.00 100.00 --1.00 -1.00 -6 0 -0 - 4 -376.80 169.60 -373.60 169.60 -376.80 172.80 -376.80 166.40 -380.00 169.60 -373.60 169.60 --1.00 -1.00 -6 0 -0 - 4 -376.80 156.80 -373.60 156.80 -376.80 160.00 -376.80 153.60 -380.00 156.80 -373.60 156.80 --1.00 -1.00 -6 0 -0 - 3 -368.00 163.20 -419.20 163.20 -419.20 150.40 -368.00 150.40 -368.00 137.60 -419.20 137.60 -419.20 124.80 -368.00 124.80 --1.00 -1.00 -6 0 -0 - 3 -393.60 176.00 -393.60 192.00 --1.00 -1.00 -6 0 -0 - 3 -368.00 176.00 -368.00 112.00 -419.20 112.00 -419.20 176.00 -368.00 176.00 --1.00 -1.00 -6 0 -0 - 4 -393.60 214.40 -416.00 214.40 -393.60 236.80 -393.60 192.00 -416.00 214.40 -371.20 214.40 --1.00 -1.00 -6 0 -0 - 3 -358.40 108.80 -359.12 118.10 -356.25 113.09 -350.53 113.81 -358.40 108.80 --1.00 -1.00 -6 0 -0 - 5 -272.00 169.60 -297.60 169.60 -323.20 160.00 -358.40 108.80 --1.00 -1.00 -6 0 -0 - 4 -268.80 169.60 -265.60 169.60 -268.80 172.80 -268.80 166.40 -272.00 169.60 -265.60 169.60 --1.00 -1.00 -6 0 -0 - 3 -275.20 92.80 -284.25 95.06 -278.59 96.19 -277.46 101.85 -275.20 92.80 --1.00 -1.00 -6 0 -0 - 5 -272.00 156.80 -297.60 153.60 -300.80 128.00 -284.80 102.40 -275.20 92.80 --1.00 -1.00 -6 0 -0 - 4 -268.80 156.80 -265.60 156.80 -268.80 160.00 -268.80 153.60 -272.00 156.80 -265.60 156.80 --1.00 -1.00 -6 0 -0 - 3 -224.00 163.20 -275.20 163.20 -275.20 150.40 -224.00 150.40 -224.00 137.60 -275.20 137.60 -275.20 124.80 -224.00 124.80 --1.00 -1.00 -6 0 -0 - 3 -249.60 176.00 -249.60 192.00 --1.00 -1.00 -6 0 -0 - 3 -224.00 176.00 -224.00 112.00 -275.20 112.00 -275.20 176.00 -224.00 176.00 --1.00 -1.00 -6 0 -0 - 4 -249.60 214.40 -272.00 214.40 -249.60 236.80 -249.60 192.00 -272.00 214.40 -227.20 214.40 --1.00 -1.00 -6 0 -0 - 3 -358.40 332.80 -359.12 342.10 -356.25 337.09 -350.53 337.81 -358.40 332.80 --1.00 -1.00 -6 0 -0 - 5 -272.00 393.60 -297.60 393.60 -323.20 384.00 -358.40 332.80 --1.00 -1.00 -6 0 -0 - 4 -268.80 393.60 -265.60 393.60 -268.80 396.80 -268.80 390.40 -272.00 393.60 -265.60 393.60 --1.00 -1.00 -6 0 -0 - 4 -249.60 291.20 -249.60 307.20 -249.60 307.20 -249.60 275.20 -265.60 291.20 -233.60 291.20 --1.00 -1.00 -6 0 -0 - 3 -275.20 316.80 -284.25 319.06 -278.59 320.19 -277.46 325.85 -275.20 316.80 --1.00 -1.00 -6 0 -0 - 5 -272.00 380.80 -297.60 377.60 -300.80 352.00 -284.80 326.40 -275.20 316.80 --1.00 -1.00 -6 0 -0 - 4 -268.80 380.80 -265.60 380.80 -268.80 384.00 -268.80 377.60 -272.00 380.80 -265.60 380.80 --1.00 -1.00 -6 0 -0 - 3 -224.00 387.20 -275.20 387.20 -275.20 374.40 -224.00 374.40 -224.00 361.60 -275.20 361.60 -275.20 348.80 -224.00 348.80 --1.00 -1.00 -6 0 -0 - 3 -249.60 400.00 -249.60 416.00 --1.00 -1.00 -6 0 -0 - 3 -224.00 400.00 -224.00 336.00 -275.20 336.00 -275.20 400.00 -224.00 400.00 --1.00 -1.00 -6 0 -0 - 4 -249.60 438.40 -272.00 438.40 -249.60 460.80 -249.60 416.00 -272.00 438.40 -227.20 438.40 --1.00 -1.00 -6 0 -0 - 5 -372.00 168.00 -332.00 164.00 -324.00 140.00 -340.00 104.00 --1.00 -1.00 -6 0 -0 - 5 -372.00 156.00 -344.00 156.00 -300.00 100.00 --1.00 -1.00 -6 0 -0 - -1 diff --git a/share/doc/ps1/07.ipctut/strchkread.c b/share/doc/ps1/07.ipctut/strchkread.c deleted file mode 100644 index 5c5a0b2850c5..000000000000 --- a/share/doc/ps1/07.ipctut/strchkread.c +++ /dev/null @@ -1,107 +0,0 @@ -.\" Copyright (c) 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)strchkread.c 6.4 (Berkeley) 4/17/91 -.\" $Id: strchkread.c,v 1.2 1993/08/01 18:23:29 mycroft Exp $ -.\" -#include -#include -#include -#include -#include -#include -#define TRUE 1 - -/* - * This program uses select() to check that someone is trying to connect - * before calling accept(). - */ - -main() -{ - int sock, length; - struct sockaddr_in server; - int msgsock; - char buf[1024]; - int rval; - fd_set ready; - struct timeval to; - - /* Create socket */ - sock = socket(AF_INET, SOCK_STREAM, 0); - if (sock < 0) { - perror("opening stream socket"); - exit(1); - } - /* Name socket using wildcards */ - server.sin_family = AF_INET; - server.sin_addr.s_addr = INADDR_ANY; - server.sin_port = 0; - if (bind(sock, &server, sizeof(server))) { - perror("binding stream socket"); - exit(1); - } - /* Find out assigned port number and print it out */ - length = sizeof(server); - if (getsockname(sock, &server, &length)) { - perror("getting socket name"); - exit(1); - } - printf("Socket has port #%d\en", ntohs(server.sin_port)); - - /* Start accepting connections */ - listen(sock, 5); - do { - FD_ZERO(&ready); - FD_SET(sock, &ready); - to.tv_sec = 5; - if (select(sock + 1, &ready, 0, 0, &to) < 0) { - perror("select"); - continue; - } - if (FD_ISSET(sock, &ready)) { - msgsock = accept(sock, (struct sockaddr *)0, (int *)0); - if (msgsock == -1) - perror("accept"); - else do { - bzero(buf, sizeof(buf)); - if ((rval = read(msgsock, buf, 1024)) < 0) - perror("reading stream message"); - else if (rval == 0) - printf("Ending connection\en"); - else - printf("-->%s\en", buf); - } while (rval > 0); - close(msgsock); - } else - printf("Do something else\en"); - } while (TRUE); -} diff --git a/share/doc/ps1/07.ipctut/streamread.c b/share/doc/ps1/07.ipctut/streamread.c deleted file mode 100644 index e32822476360..000000000000 --- a/share/doc/ps1/07.ipctut/streamread.c +++ /dev/null @@ -1,103 +0,0 @@ -.\" Copyright (c) 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)streamread.c 6.4 (Berkeley) 4/17/91 -.\" $Id: streamread.c,v 1.2 1993/08/01 18:23:27 mycroft Exp $ -.\" -#include -#include -#include -#include -#include -#define TRUE 1 - -/* - * This program creates a socket and then begins an infinite loop. Each time - * through the loop it accepts a connection and prints out messages from it. - * When the connection breaks, or a termination message comes through, the - * program accepts a new connection. - */ - -main() -{ - int sock, length; - struct sockaddr_in server; - int msgsock; - char buf[1024]; - int rval; - int i; - - /* Create socket */ - sock = socket(AF_INET, SOCK_STREAM, 0); - if (sock < 0) { - perror("opening stream socket"); - exit(1); - } - /* Name socket using wildcards */ - server.sin_family = AF_INET; - server.sin_addr.s_addr = INADDR_ANY; - server.sin_port = 0; - if (bind(sock, &server, sizeof(server))) { - perror("binding stream socket"); - exit(1); - } - /* Find out assigned port number and print it out */ - length = sizeof(server); - if (getsockname(sock, &server, &length)) { - perror("getting socket name"); - exit(1); - } - printf("Socket has port #%d\en", ntohs(server.sin_port)); - - /* Start accepting connections */ - listen(sock, 5); - do { - msgsock = accept(sock, 0, 0); - if (msgsock == -1) - perror("accept"); - else do { - bzero(buf, sizeof(buf)); - if ((rval = read(msgsock, buf, 1024)) < 0) - perror("reading stream message"); - i = 0; - if (rval == 0) - printf("Ending connection\en"); - else - printf("-->%s\en", buf); - } while (rval != 0); - close(msgsock); - } while (TRUE); - /* - * Since this program has an infinite loop, the socket "sock" is - * never explicitly closed. However, all sockets will be closed - * automatically when a process is killed or terminates normally. - */ -} diff --git a/share/doc/ps1/07.ipctut/streamwrite.c b/share/doc/ps1/07.ipctut/streamwrite.c deleted file mode 100644 index 5459cabbf45b..000000000000 --- a/share/doc/ps1/07.ipctut/streamwrite.c +++ /dev/null @@ -1,82 +0,0 @@ -.\" Copyright (c) 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)streamwrite.c 6.4 (Berkeley) 4/17/91 -.\" $Id: streamwrite.c,v 1.2 1993/08/01 18:23:28 mycroft Exp $ -.\" -#include -#include -#include -#include -#include - -#define DATA "Half a league, half a league . . ." - -/* - * This program creates a socket and initiates a connection with the socket - * given in the command line. One message is sent over the connection and - * then the socket is closed, ending the connection. The form of the command - * line is streamwrite hostname portnumber - */ - -main(argc, argv) - int argc; - char *argv[]; -{ - int sock; - struct sockaddr_in server; - struct hostent *hp, *gethostbyname(); - char buf[1024]; - - /* Create socket */ - sock = socket(AF_INET, SOCK_STREAM, 0); - if (sock < 0) { - perror("opening stream socket"); - exit(1); - } - /* Connect socket using name specified by command line. */ - server.sin_family = AF_INET; - hp = gethostbyname(argv[1]); - if (hp == 0) { - fprintf(stderr, "%s: unknown host\n", argv[1]); - exit(2); - } - bcopy(hp->h_addr, &server.sin_addr, hp->h_length); - server.sin_port = htons(atoi(argv[2])); - - if (connect(sock, &server, sizeof(server)) < 0) { - perror("connecting stream socket"); - exit(1); - } - if (write(sock, DATA, sizeof(DATA)) < 0) - perror("writing on stream socket"); - close(sock); -} diff --git a/share/doc/ps1/07.ipctut/tutor.me b/share/doc/ps1/07.ipctut/tutor.me deleted file mode 100644 index 87aec33fbb24..000000000000 --- a/share/doc/ps1/07.ipctut/tutor.me +++ /dev/null @@ -1,950 +0,0 @@ -.\" Copyright (c) 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)tutor.me 6.8 (Berkeley) 4/17/91 -.\" -.oh 'Introductory 4.3BSD IPC''PS1:7-%' -.eh 'PS1:7-%''Introductory 4.3BSD IPC' -.rs -.sp 2 -.sz 14 -.ft B -.ce 2 -An Introductory 4.3BSD -Interprocess Communication Tutorial -.sz 10 -.sp 2 -.ce -.i "Stuart Sechrest" -.ft -.sp -.ce 4 -Computer Science Research Group -Computer Science Division -Department of Electrical Engineering and Computer Science -University of California, Berkeley -.sp 2 -.ce -.i ABSTRACT -.sp -.(c -.pp -Berkeley UNIX\(dg 4.3BSD offers several choices for interprocess communication. -To aid the programmer in developing programs which are comprised of -cooperating -processes, the different choices are discussed and a series of example -programs are presented. These programs -demonstrate in a simple way the use of pipes, socketpairs, sockets -and the use of datagram and stream communication. The intent of this -document is to present a few simple example programs, not to describe the -networking system in full. -.)c -.sp 2 -.(f -\(dg\|UNIX is a trademark of AT&T Bell Laboratories. -.)f -.b -.sh 1 "Goals" -.r -.pp -Facilities for interprocess communication (IPC) and networking -were a major addition to UNIX in the Berkeley UNIX 4.2BSD release. -These facilities required major additions and some changes -to the system interface. -The basic idea of this interface is to make IPC similar to file I/O. -In UNIX a process has a set of I/O descriptors, from which one reads -and to which one writes. -Descriptors may refer to normal files, to devices (including terminals), -or to communication channels. -The use of a descriptor has three phases: its creation, -its use for reading and writing, and its destruction. By using descriptors -to write files, rather than simply naming the target file in the write -call, one gains a surprising amount of flexibility. Often, the program that -creates a descriptor will be different from the program that uses the -descriptor. For example the shell can create a descriptor for the output -of the `ls' -command that will cause the listing to appear in a file rather than -on a terminal. -Pipes are another form of descriptor that have been used in UNIX -for some time. -Pipes allow one-way data transmission from one process -to another; the two processes and the pipe must be set up by a common -ancestor. -.pp -The use of descriptors is not the only communication interface -provided by UNIX. -The signal mechanism sends a tiny amount of information from one -process to another. -The signaled process receives only the signal type, -not the identity of the sender, -and the number of possible signals is small. -The signal semantics limit the flexibility of the signaling mechanism -as a means of interprocess communication. -.pp -The identification of IPC with I/O is quite longstanding in UNIX and -has proved quite successful. At first, however, IPC was limited to -processes communicating within a single machine. With Berkeley UNIX -4.2BSD this expanded to include IPC between machines. This expansion -has necessitated some change in the way that descriptors are created. -Additionally, new possibilities for the meaning of read and write have -been admitted. Originally the meanings, or semantics, of these terms -were fairly simple. When you wrote something it was delivered. When -you read something, you were blocked until the data arrived. -Other possibilities exist, -however. One can write without full assurance of delivery if one can -check later to catch occasional failures. Messages can be kept as -discrete units or merged into a stream. -One can ask to read, but insist on not waiting if nothing is immediately -available. These new possibilities are allowed in the Berkeley UNIX IPC -interface. -.pp -Thus Berkeley UNIX 4.3BSD offers several choices for IPC. -This paper presents simple examples that illustrate some of -the choices. -The reader is presumed to be familiar with the C programming language -[Kernighan & Ritchie 1978], -but not necessarily with the system calls of the UNIX system or with -processes and interprocess communication. -The paper reviews the notion of a process and the types of -communication that are supported by Berkeley UNIX 4.3BSD. -A series of examples are presented that create processes that communicate -with one another. The programs show different ways of establishing -channels of communication. -Finally, the calls that actually transfer data are reviewed. -To clearly present how communication can take place, -the example programs have been cleared of anything that -might be construed as useful work. -They can, therefore, serve as models -for the programmer trying to construct programs which are comprised of -cooperating processes. -.b -.sh 1 "Processes" -.pp -A \fIprogram\fP is both a sequence of statements and a rough way of referring -to the computation that occurs when the compiled statements are run. -A \fIprocess\fP can be thought of as a single line of control in a program. -Most programs execute some statements, go through a few loops, branch in -various directions and then end. These are single process programs. -Programs can also have a point where control splits into two independent lines, -an action called \fIforking.\fP -In UNIX these lines can never join again. A call to the system routine -\fIfork()\fP, causes a process to split in this way. -The result of this call is that two independent processes will be -running, executing exactly the same code. -Memory values will be the same for all values set before the fork, but, -subsequently, each version will be able to change only the -value of its own copy of each variable. -Initially, the only difference between the two will be the value returned by -\fIfork().\fP The parent will receive a process id for the child, -the child will receive a zero. -Calls to \fIfork(),\fP -therefore, typically precede, or are included in, an if-statement. -.pp -A process views the rest of the system through a private table of descriptors. -The descriptors can represent open files or sockets (sockets are communication -objects that will be discussed below). Descriptors are referred to -by their index numbers in the table. The first three descriptors are often -known by special names, \fI stdin, stdout\fP and \fIstderr\fP. -These are the standard input, output and error. -When a process forks, its descriptor table is copied to the child. -Thus, if the parent's standard input is being taken from a terminal -(devices are also treated as files in UNIX), the child's input will -be taken from the -same terminal. Whoever reads first will get the input. If, before forking, -the parent changes its standard input so that it is reading from a -new file, the child will take its input from the new file. It is -also possible to take input from a socket, rather than from a file. -.b -.sh 1 "Pipes" -.r -.pp -Most users of UNIX know that they can pipe the output of a -program ``prog1'' to the input of another, ``prog2,'' by typing the command -\fI``prog1 | prog2.''\fP -This is called ``piping'' the output of one program -to another because the mechanism used to transfer the output is called a -pipe. -When the user types a command, the command is read by the shell, which -decides how to execute it. If the command is simple, for example, -.i "``prog1,''" -the shell forks a process, which executes the program, prog1, and then dies. -The shell waits for this termination and then prompts for the next -command. -If the command is a compound command, -.i "``prog1 | prog2,''" -the shell creates two processes connected by a pipe. One process -runs the program, prog1, the other runs prog2. The pipe is an I/O -mechanism with two ends, or sockets. Data that is written into one socket -can be read from the other. -.(z -.ft CW -.so pipe.c -.ft -.ce 1 -Figure 1\ \ Use of a pipe -.)z -.pp -Since a program specifies its input and output only by the descriptor table -indices, which appear as variables or constants, -the input source and output destination can be changed without -changing the text of the program. -It is in this way that the shell is able to set up pipes. Before executing -prog1, the process can close whatever is at \fIstdout\fP -and replace it with one -end of a pipe. Similarly, the process that will execute prog2 can substitute -the opposite end of the pipe for -\fIstdin.\fP -.pp -Let us now examine a program that creates a pipe for communication between -its child and itself (Figure 1). -A pipe is created by a parent process, which then forks. -When a process forks, the parent's descriptor table is copied into -the child's. -.pp -In Figure 1, the parent process makes a call to the system routine -\fIpipe().\fP -This routine creates a pipe and places descriptors for the sockets -for the two ends of the pipe in the process's descriptor table. -\fIPipe()\fP -is passed an array into which it places the index numbers of the -sockets it created. -The two ends are not equivalent. The socket whose index is -returned in the low word of the array is opened for reading only, -while the socket in the high end is opened only for writing. -This corresponds to the fact that the standard input is the first -descriptor of a process's descriptor table and the standard output -is the second. After creating the pipe, the parent creates the child -with which it will share the pipe by calling \fIfork().\fP -Figure 2 illustrates the effect of a fork. -The parent process's descriptor table points to both ends of the pipe. -After the fork, both parent's and child's descriptor tables point to -the pipe. -The child can then use the pipe to send a message to the parent. -.(z -.ns -.GS C -height 6i -file pipe.grn -.GE -.sp -.ce 1 -Figure 2\ \ Sharing a pipe between parent and child -.)z -.pp -Just what is a pipe? -It is a one-way communication mechanism, with one end opened -for reading and the other end for writing. -Therefore, parent and child need to agree on which way to turn -the pipe, from parent to child or the other way around. -Using the same pipe for communication both from parent to child and -from child to parent would be possible (since both processes have -references to both ends), but very complicated. -If the parent and child are to have a two-way conversation, -the parent creates two pipes, one for use in each direction. -(In accordance with their plans, both parent and child in the example above -close the socket that they will not use. It is not required that unused -descriptors be closed, but it is good practice.) -A pipe is also a \fIstream\fP communication mechanism; that -is, all messages sent through the pipe are placed in order -and reliably delivered. When the reader asks for a certain -number of bytes from this -stream, he is given as many bytes as are available, up -to the amount of the request. Note that these bytes may have come from -the same call to \fIwrite()\fR or from several calls to \fIwrite()\fR -which were concatenated. -.b -.sh 1 "Socketpairs" -.r -.pp -Berkeley UNIX 4.3BSD provides a slight generalization of pipes. A pipe is a -pair of connected sockets for one-way stream communication. One may -obtain a pair of connected sockets for two-way stream communication -by calling the routine \fIsocketpair().\fP -The program in Figure 3 calls \fIsocketpair()\fP -to create such a connection. The program uses the link for -communication in both directions. Since socketpairs are -an extension of pipes, their use resembles that of pipes. -Figure 4 illustrates the result of a fork following a call to -\fIsocketpair().\fP -.pp -\fISocketpair()\fP -takes as -arguments a specification of a domain, a style of communication, and a -protocol. -These are the parameters shown in the example. -Domains and protocols will be discussed in the next section. -Briefly, -a domain is a space of names that may be bound -to sockets and implies certain other conventions. -Currently, socketpairs have only been implemented for one -domain, called the UNIX domain. -The UNIX domain uses UNIX path names for naming sockets. -It only allows communication -between sockets on the same machine. -.pp -Note that the header files -.i "" -and -.i "." -are required in this program. -The constants AF_UNIX and SOCK_STREAM are defined in -.i "," -which in turn requires the file -.i "" -for some of its definitions. -.(z -.ft CW -.so socketpair.c -.ft -.ce 1 -Figure 3\ \ Use of a socketpair -.)z -.(z -.GS C -height 6i -file socketpair.grn -.GE -.sp -.ce 1 -Figure 4\ \ Sharing a socketpair between parent and child -.)z -.b -.sh 1 "Domains and Protocols" -.r -.pp -Pipes and socketpairs are a simple solution for communicating between -a parent and child or between child processes. -What if we wanted to have processes that have no common ancestor -with whom to set up communication? -Neither standard UNIX pipes nor socketpairs are -the answer here, since both mechanisms require a common ancestor to -set up the communication. -We would like to have two processes separately create sockets -and then have messages sent between them. This is often the -case when providing or using a service in the system. This is -also the case when the communicating processes are on separate machines. -In Berkeley UNIX 4.3BSD one can create individual sockets, give them names and -send messages between them. -.pp -Sockets created by different programs use names to refer to one another; -names generally must be translated into addresses for use. -The space from which an address is drawn is referred to as a -.i domain. -There are several domains for sockets. -Two that will be used in the examples here are the UNIX domain (or AF_UNIX, -for Address Format UNIX) and the Internet domain (or AF_INET). -UNIX domain IPC is an experimental facility in 4.2BSD and 4.3BSD. -In the UNIX domain, a socket is given a path name within the file system -name space. -A file system node is created for the socket and other processes may -then refer to the socket by giving the proper pathname. -UNIX domain names, therefore, allow communication between any two processes -that work in the same file system. -The Internet domain is the UNIX implementation of the DARPA Internet -standard protocols IP/TCP/UDP. -Addresses in the Internet domain consist of a machine network address -and an identifying number, called a port. -Internet domain names allow communication between machines. -.pp -Communication follows some particular ``style.'' -Currently, communication is either through a \fIstream\fP -or by \fIdatagram.\fP -Stream communication implies several things. Communication takes -place across a connection between two sockets. The communication -is reliable, error-free, and, as in pipes, no message boundaries are -kept. Reading from a stream may result in reading the data sent from -one or several calls to \fIwrite()\fP -or only part of the data from a single call, if there is not enough room -for the entire message, or if not all the data from a large message -has been transferred. -The protocol implementing such a style will retransmit messages -received with errors. It will also return error messages if one tries to -send a message after the connection has been broken. -Datagram communication does not use connections. Each message is -addressed individually. If the address is correct, it will generally -be received, although this is not guaranteed. Often datagrams are -used for requests that require a response from the -recipient. If no response -arrives in a reasonable amount of time, the request is repeated. -The individual datagrams will be kept separate when they are read, that -is, message boundaries are preserved. -.pp -The difference in performance between the two styles of communication is -generally less important than the difference in semantics. The -performance gain that one might find in using datagrams must be weighed -against the increased complexity of the program, which must now concern -itself with lost or out of order messages. If lost messages may simply be -ignored, the quantity of traffic may be a consideration. The expense -of setting up a connection is best justified by frequent use of the connection. -Since the performance of a protocol changes as it is tuned for different -situations, it is best to seek the most up-to-date information when -making choices for a program in which performance is crucial. -.pp -A protocol is a set of rules, data formats and conventions that regulate the -transfer of data between participants in the communication. -In general, there is one protocol for each socket type (stream, -datagram, etc.) within each domain. -The code that implements a protocol -keeps track of the names that are bound to sockets, -sets up connections and transfers data between sockets, -perhaps sending the data across a network. -This code also keeps track of the names that are bound to sockets. -It is possible for several protocols, differing only in low level -details, to implement the same style of communication within -a particular domain. Although it is possible to select -which protocol should be used, for nearly all uses it is sufficient to -request the default protocol. This has been done in all of the example -programs. -.pp -One specifies the domain, style and protocol of a socket when -it is created. For example, in Figure 5a the call to \fIsocket()\fP -causes the creation of a datagram socket with the default protocol -in the UNIX domain. -.b -.sh 1 "Datagrams in the UNIX Domain" -.r -.(z -.ft CW -.so udgramread.c -.ft -.ce 1 -Figure 5a\ \ Reading UNIX domain datagrams -.)z -.pp -Let us now look at two programs that create sockets separately. -The programs in Figures 5a and 5b use datagram communication -rather than a stream. -The structure used to name UNIX domain sockets is defined -in the file \fI.\fP -The definition has also been included in the example for clarity. -.pp -Each program creates a socket with a call to \fIsocket().\fP -These sockets are in the UNIX domain. -Once a name has been decided upon it is attached to a socket by the -system call \fIbind().\fP -The program in Figure 5a uses the name ``socket'', -which it binds to its socket. -This name will appear in the working directory of the program. -The routines in Figure 5b use its -socket only for sending messages. It does not create a name for -the socket because no other process has to refer to it. -.(z -.ft CW -.so udgramsend.c -.ft -.ce 1 -Figure 5b\ \ Sending a UNIX domain datagrams -.)z -.pp -Names in the UNIX domain are path names. Like file path names they may -be either absolute (e.g. ``/dev/imaginary'') or relative (e.g. ``socket''). -Because these names are used to allow processes to rendezvous, relative -path names can pose difficulties and should be used with care. -When a name is bound into the name space, a file (inode) is allocated in the -file system. If -the inode is not deallocated, the name will continue to exist even after -the bound socket is closed. This can cause subsequent runs of a program -to find that a name is unavailable, and can cause -directories to fill up with these -objects. The names are removed by calling \fIunlink()\fP or using -the \fIrm\fP\|(1) command. -Names in the UNIX domain are only used for rendezvous. They are not used -for message delivery once a connection is established. Therefore, in -contrast with the Internet domain, unbound sockets need not be (and are -not) automatically given addresses when they are connected. -.pp -There is no established means of communicating names to interested -parties. In the example, the program in Figure 5b gets the -name of the socket to which it will send its message through its -command line arguments. Once a line of communication has been created, -one can send the names of additional, perhaps new, sockets over the link. -Facilities will have to be built that will make the distribution of -names less of a problem than it now is. -.b -.sh 1 "Datagrams in the Internet Domain" -.r -.(z -.ft CW -.so dgramread.c -.ft -.ce 1 -Figure 6a\ \ Reading Internet domain datagrams -.)z -.pp -The examples in Figure 6a and 6b are very close to the previous example -except that the socket is in the Internet domain. -The structure of Internet domain addresses is defined in the file -\fI\fP. -Internet addresses specify a host address (a 32-bit number) -and a delivery slot, or port, on that -machine. These ports are managed by the system routines that implement -a particular protocol. -Unlike UNIX domain names, Internet socket names are not entered into -the file system and, therefore, -they do not have to be unlinked after the socket has been closed. -When a message must be sent between machines it is sent to -the protocol routine on the destination machine, which interprets the -address to determine to which socket the message should be delivered. -Several different protocols may be active on -the same machine, but, in general, they will not communicate with one another. -As a result, different protocols are allowed to use the same port numbers. -Thus, implicitly, an Internet address is a triple including a protocol as -well as the port and machine address. -An \fIassociation\fP is a temporary or permanent specification -of a pair of communicating sockets. -An association is thus identified by the tuple -<\fIprotocol, local machine address, local port, -remote machine address, remote port\fP>. -An association may be transient when using datagram sockets; -the association actually exists during a \fIsend\fP operation. -.(z -.ft CW -.so dgramsend.c -.ft -.ce 1 -Figure 6b\ \ Sending an Internet domain datagram -.)z -.pp -The protocol for a socket is chosen when the socket is created. The -local machine address for a socket can be any valid network address of the -machine, if it has more than one, or it can be the wildcard value -INADDR_ANY. -The wildcard value is used in the program in Figure 6a. -If a machine has several network addresses, it is likely -that messages sent to any of the addresses should be deliverable to -a socket. This will be the case if the wildcard value has been chosen. -Note that even if the wildcard value is chosen, a program sending messages -to the named socket must specify a valid network address. One can be willing -to receive from ``anywhere,'' but one cannot send a message ``anywhere.'' -The program in Figure 6b is given the destination host name as a command -line argument. -To determine a network address to which it can send the message, it looks -up -the host address by the call to \fIgethostbyname()\fP. -The returned structure includes the host's network address, -which is copied into the structure specifying the -destination of the message. -.pp -The port number can be thought of as the number of a mailbox, into -which the protocol places one's messages. Certain daemons, offering -certain advertised services, have reserved -or ``well-known'' port numbers. These fall in the range -from 1 to 1023. Higher numbers are available to general users. -Only servers need to ask for a particular number. -The system will assign an unused port number when an address -is bound to a socket. -This may happen when an explicit \fIbind\fP -call is made with a port number of 0, or -when a \fIconnect\fP or \fIsend\fP -is performed on an unbound socket. -Note that port numbers are not automatically reported back to the user. -After calling \fIbind(),\fP asking for port 0, one may call -\fIgetsockname()\fP to discover what port was actually assigned. -The routine \fIgetsockname()\fP -will not work for names in the UNIX domain. -.pp -The format of the socket address is specified in part by standards within the -Internet domain. The specification includes the order of the bytes in -the address. Because machines differ in the internal representation -they ordinarily use -to represent integers, printing out the port number as returned by -\fIgetsockname()\fP may result in a misinterpretation. To -print out the number, it is necessary to use the routine \fIntohs()\fP -(for \fInetwork to host: short\fP) to convert the number from the -network representation to the host's representation. On some machines, -such as 68000-based machines, this is a null operation. On others, -such as VAXes, this results in a swapping of bytes. Another routine -exists to convert a short integer from the host format to the network format, -called \fIhtons()\fP; similar routines exist for long integers. -For further information, refer to the -entry for \fIbyteorder\fP in section 3 of the manual. -.b -.sh 1 "Connections" -.r -.pp -To send data between stream sockets (having communication style SOCK_STREAM), -the sockets must be connected. -Figures 7a and 7b show two programs that create such a connection. -The program in 7a is relatively simple. -To initiate a connection, this program simply creates -a stream socket, then calls \fIconnect()\fP, -specifying the address of the socket to which -it wishes its socket connected. Provided that the target socket exists and -is prepared to handle a connection, connection will be complete, -and the program can begin to send -messages. Messages will be delivered in order without message -boundaries, as with pipes. The connection is destroyed when either -socket is closed (or soon thereafter). If a process persists -in sending messages after the connection is closed, a SIGPIPE signal -is sent to the process by the operating system. Unless explicit action -is taken to handle the signal (see the manual page for \fIsignal\fP -or \fIsigvec\fP), -the process will terminate and the shell -will print the message ``broken pipe.'' -.(z -.ft CW -.so streamwrite.c -.ft -.ce 1 -Figure 7a\ \ Initiating an Internet domain stream connection -.)z -.(z -.ft CW -.so streamread.c -.ft -.ce 1 -Figure 7b\ \ Accepting an Internet domain stream connection -.sp 2 -.ft CW -.so strchkread.c -.ft -.ce 1 -Figure 7c\ \ Using select() to check for pending connections -.)z -.(z -.GS C -height 6i -file accept.grn -.GE -.sp -.ce 1 -Figure 8\ \ Establishing a stream connection -.)z -.pp -Forming a connection is asymmetrical; one process, such as the -program in Figure 7a, requests a connection with a particular socket, -the other process accepts connection requests. -Before a connection can be accepted a socket must be created and an address -bound to it. This -situation is illustrated in the top half of Figure 8. Process 2 -has created a socket and bound a port number to it. Process 1 has created an -unnamed socket. -The address bound to process 2's socket is then made known to process 1 and, -perhaps to several other potential communicants as well. -If there are several possible communicants, -this one socket might receive several requests for connections. -As a result, a new socket is created for each connection. This new socket -is the endpoint for communication within this process for this connection. -A connection may be destroyed by closing the corresponding socket. -.pp -The program in Figure 7b is a rather trivial example of a server. It -creates a socket to which it binds a name, which it then advertises. -(In this case it prints out the socket number.) The program then calls -\fIlisten()\fP for this socket. -Since several clients may attempt to connect more or less -simultaneously, a queue of pending connections is maintained in the system -address space. \fIListen()\fP -marks the socket as willing to accept connections and initializes the queue. -When a connection is requested, it is listed in the queue. If the -queue is full, an error status may be returned to the requester. -The maximum length of this queue is specified by the second argument of -\fIlisten()\fP; the maximum length is limited by the system. -Once the listen call has been completed, the program enters -an infinite loop. On each pass through the loop, a new connection is -accepted and removed from the queue, and, hence, a new socket for the -connection is created. The bottom half of Figure 8 shows the result of -Process 1 connecting with the named socket of Process 2, and Process 2 -accepting the connection. After the connection is created, the -service, in this case printing out the messages, is performed and the -connection socket closed. The \fIaccept()\fP -call will take a pending connection -request from the queue if one is available, or block waiting for a request. -Messages are read from the connection socket. -Reads from an active connection will normally block until data is available. -The number of bytes read is returned. When a connection is destroyed, -the read call returns immediately. The number of bytes returned will -be zero. -.pp -The program in Figure 7c is a slight variation on the server in Figure 7b. -It avoids blocking when there are no pending connection requests by -calling \fIselect()\fP -to check for pending requests before calling \fIaccept().\fP -This strategy is useful when connections may be received -on more than one socket, or when data may arrive on other connected -sockets before another connection request. -.pp -The programs in Figures 9a and 9b show a program using stream communication -in the UNIX domain. Streams in the UNIX domain can be used for this sort -of program in exactly the same way as Internet domain streams, except for -the form of the names and the restriction of the connections to a single -file system. There are some differences, however, in the functionality of -streams in the two domains, notably in the handling of -\fIout-of-band\fP data (discussed briefly below). These differences -are beyond the scope of this paper. -.(z -.ft CW -.so ustreamwrite.c -.ft -.ce 1 -Figure 9a\ \ Initiating a UNIX domain stream connection -.sp 2 -.ft CW -.so ustreamread.c -.ft -.ce 1 -Figure 9b\ \ Accepting a UNIX domain stream connection -.)z -.b -.sh 1 "Reads, Writes, Recvs, etc." -.r -.pp -UNIX 4.3BSD has several system calls for reading and writing information. -The simplest calls are \fIread() \fP and \fIwrite().\fP \fIWrite()\fP -takes as arguments the index of a descriptor, a pointer to a buffer -containing the data and the size of the data. -The descriptor may indicate either a file or a connected socket. -``Connected'' can mean either a connected stream socket (as described -in Section 8) or a datagram socket for which a \fIconnect()\fP -call has provided a default destination (see the \fIconnect()\fP manual page). -\fIRead()\fP also takes a descriptor that indicates either a file or a socket. -\fIWrite()\fP requires a connected socket since no destination is -specified in the parameters of the system call. -\fIRead()\fP can be used for either a connected or an unconnected socket. -These calls are, therefore, quite flexible and may be used to -write applications that require no assumptions about the source of -their input or the destination of their output. -There are variations on \fIread() \fP and \fIwrite()\fP -that allow the source and destination of the input and output to use -several separate buffers, while retaining the flexibility to handle -both files and sockets. These are \fIreadv()\fP and \fI writev(),\fP -for read and write \fIvector.\fP -.pp -It is sometimes necessary to send high priority data over a -connection that may have unread low priority data at the -other end. For example, a user interface process may be interpreting -commands and sending them on to another process through a stream connection. -The user interface may have filled the stream with as yet unprocessed -requests when the user types -a command to cancel all outstanding requests. -Rather than have the high priority data wait -to be processed after the low priority data, it is possible to -send it as \fIout-of-band\fP -(OOB) data. The notification of pending OOB data results in the generation of -a SIGURG signal, if this signal has been enabled (see the manual -page for \fIsignal\fP or \fIsigvec\fP). -See [Leffler 1986] for a more complete description of the OOB mechanism. -There are a pair of calls similar to \fIread\fP and \fIwrite\fP -that allow options, including sending -and receiving OOB information; these are \fI send()\fP -and \fIrecv().\fP -These calls are used only with sockets; specifying a descriptor for a file will -result in the return of an error status. These calls also allow -\fIpeeking\fP at data in a stream. -That is, they allow a process to read data without removing the data from -the stream. One use of this facility is to read ahead in a stream -to determine the size of the next item to be read. -When not using these options, these calls have the same functions as -\fIread()\fP and \fIwrite().\fP -.pp -To send datagrams, one must be allowed to specify the destination. -The call \fIsendto()\fP -takes a destination address as an argument and is therefore used for -sending datagrams. The call \fIrecvfrom()\fP -is often used to read datagrams, since this call returns the address -of the sender, if it is available, along with the data. -If the identity of the sender does not matter, one may use \fIread()\fP -or \fIrecv().\fP -.pp -Finally, there are a pair of calls that allow the sending and -receiving of messages from multiple buffers, when the address of the -recipient must be specified. These are \fIsendmsg()\fP and -\fIrecvmsg().\fP -These calls are actually quite general and have other uses, -including, in the UNIX domain, the transmission of a file descriptor from one -process to another. -.pp -The various options for reading and writing are shown in Figure 10, -together with their parameters. The parameters for each system call -reflect the differences in function of the different calls. -In the examples given in this paper, the calls \fIread()\fP and -\fIwrite()\fP have been used whenever possible. -.(z -.ft CW - /* - * The variable descriptor may be the descriptor of either a file - * or of a socket. - */ - cc = read(descriptor, buf, nbytes) - int cc, descriptor; char *buf; int nbytes; - - /* - * An iovec can include several source buffers. - */ - cc = readv(descriptor, iov, iovcnt) - int cc, descriptor; struct iovec *iov; int iovcnt; - - cc = write(descriptor, buf, nbytes) - int cc, descriptor; char *buf; int nbytes; - - cc = writev(descriptor, iovec, ioveclen) - int cc, descriptor; struct iovec *iovec; int ioveclen; - - /* - * The variable ``sock'' must be the descriptor of a socket. - * Flags may include MSG_OOB and MSG_PEEK. - */ - cc = send(sock, msg, len, flags) - int cc, sock; char *msg; int len, flags; - - cc = sendto(sock, msg, len, flags, to, tolen) - int cc, sock; char *msg; int len, flags; - struct sockaddr *to; int tolen; - - cc = sendmsg(sock, msg, flags) - int cc, sock; struct msghdr msg[]; int flags; - - cc = recv(sock, buf, len, flags) - int cc, sock; char *buf; int len, flags; - - cc = recvfrom(sock, buf, len, flags, from, fromlen) - int cc, sock; char *buf; int len, flags; - struct sockaddr *from; int *fromlen; - - cc = recvmsg(sock, msg, flags) - int cc, socket; struct msghdr msg[]; int flags; -.ft -.sp 1 -.ce 1 -Figure 10\ \ Varieties of read and write commands -.)z -.b -.sh 1 "Choices" -.r -.pp -This paper has presented examples of some of the forms -of communication supported by -Berkeley UNIX 4.3BSD. These have been presented in an order chosen for -ease of presentation. It is useful to review these options emphasizing the -factors that make each attractive. -.pp -Pipes have the advantage of portability, in that they are supported in all -UNIX systems. They also are relatively -simple to use. Socketpairs share this simplicity and have the additional -advantage of allowing bidirectional communication. The major shortcoming -of these mechanisms is that they require communicating processes to be -descendants of a common process. They do not allow intermachine communication. -.pp -The two communication domains, UNIX and Internet, allow processes with no common -ancestor to communicate. -Of the two, only the Internet domain allows -communication between machines. -This makes the Internet domain a necessary -choice for processes running on separate machines. -.pp -The choice between datagrams and stream communication is best made by -carefully considering the semantic and performance -requirements of the application. -Streams can be both advantageous and disadvantageous. One disadvantage -is that a process is only allowed a limited number of open streams, -as there are usually only 64 entries available in the open descriptor -table. This can cause problems if a single server must talk with a large -number of clients. -Another is that for delivering a short message the stream setup and -teardown time can be unnecessarily long. Weighed against this are -the reliability built into the streams. This will often be the -deciding factor in favor of streams. -.b -.sh 1 "What to do Next" -.r -.pp -Many of the examples presented here can serve as models for multiprocess -programs and for programs distributed across several machines. -In developing a new multiprocess program, it is often easiest to -first write the code to create the processes and communication paths. -After this code is debugged, the code specific to the application can -be added. -.pp -An introduction to the UNIX system and programming using UNIX system calls -can be found in [Kernighan and Pike 1984]. -Further documentation of the Berkeley UNIX 4.3BSD IPC mechanisms can be -found in [Leffler et al. 1986]. -More detailed information about particular calls and protocols -is provided in sections -2, 3 and 4 of the -UNIX Programmer's Manual [CSRG 1986]. -In particular the following manual pages are relevant: -.(b -.TS -l l. -creating and naming sockets socket(2), bind(2) -establishing connections listen(2), accept(2), connect(2) -transferring data read(2), write(2), send(2), recv(2) -addresses inet(4F) -protocols tcp(4P), udp(4P). -.TE -.)b -.(b -.sp -.b -Acknowledgements -.pp -I would like to thank Sam Leffler and Mike Karels for their help in -understanding the IPC mechanisms and all the people whose comments -have helped in writing and improving this report. -.pp -This work was sponsored by the Defense Advanced Research Projects Agency -(DoD), ARPA Order No. 4031, monitored by the Naval Electronics Systems -Command under contract No. N00039-C-0235. -The views and conclusions contained in this document are those of the -author and should not be interpreted as representing official policies, -either expressed or implied, of the Defense Research Projects Agency -or of the US Government. -.)b -.(b -.sp -.b -References -.r -.sp -.ls 1 -B.W. Kernighan & R. Pike, 1984, -.i "The UNIX Programming Environment." -Englewood Cliffs, N.J.: Prentice-Hall. -.sp -.ls 1 -B.W. Kernighan & D.M. Ritchie, 1978, -.i "The C Programming Language," -Englewood Cliffs, N.J.: Prentice-Hall. -.sp -.ls 1 -S.J. Leffler, R.S. Fabry, W.N. Joy, P. Lapsley, S. Miller & C. Torek, 1986, -.i "An Advanced 4.3BSD Interprocess Communication Tutorial." -Computer Systems Research Group, -Department of Electrical Engineering and Computer Science, -University of California, Berkeley. -.sp -.ls 1 -Computer Systems Research Group, 1986, -.i "UNIX Programmer's Manual, 4.3 Berkeley Software Distribution." -Computer Systems Research Group, -Department of Electrical Engineering and Computer Science, -University of California, Berkeley. -.)b diff --git a/share/doc/ps1/07.ipctut/udgramread.c b/share/doc/ps1/07.ipctut/udgramread.c deleted file mode 100644 index a73edb4587e4..000000000000 --- a/share/doc/ps1/07.ipctut/udgramread.c +++ /dev/null @@ -1,81 +0,0 @@ -.\" Copyright (c) 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)udgramread.c 6.5 (Berkeley) 4/17/91 -.\" $Id: udgramread.c,v 1.2 1993/08/01 18:23:26 mycroft Exp $ -.\" -#include -#include -#include - -/* - * In the included file a sockaddr_un is defined as follows - * struct sockaddr_un { - * short sun_family; - * char sun_path[108]; - * }; - */ - -#include - -#define NAME "socket" - -/* - * This program creates a UNIX domain datagram socket, binds a name to it, - * then reads from the socket. - */ -main() -{ - int sock, length; - struct sockaddr_un name; - char buf[1024]; - - /* Create socket from which to read. */ - sock = socket(AF_UNIX, SOCK_DGRAM, 0); - if (sock < 0) { - perror("opening datagram socket"); - exit(1); - } - /* Create name. */ - name.sun_family = AF_UNIX; - strcpy(name.sun_path, NAME); - if (bind(sock, &name, sizeof(struct sockaddr_un))) { - perror("binding name to datagram socket"); - exit(1); - } - printf("socket -->%s\en", NAME); - /* Read from the socket */ - if (read(sock, buf, 1024) < 0) - perror("receiving datagram packet"); - printf("-->%s\en", buf); - close(sock); - unlink(NAME); -} diff --git a/share/doc/ps1/07.ipctut/udgramsend.c b/share/doc/ps1/07.ipctut/udgramsend.c deleted file mode 100644 index d344de4c838e..000000000000 --- a/share/doc/ps1/07.ipctut/udgramsend.c +++ /dev/null @@ -1,69 +0,0 @@ -.\" Copyright (c) 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)udgramsend.c 6.4 (Berkeley) 4/17/91 -.\" $Id: udgramsend.c,v 1.2 1993/08/01 18:23:25 mycroft Exp $ -.\" -#include -#include -#include -#include - -#define DATA "The sea is calm tonight, the tide is full . . ." - -/* - * Here I send a datagram to a receiver whose name I get from the command - * line arguments. The form of the command line is udgramsend pathname - */ - -main(argc, argv) - int argc; - char *argv[]; -{ - int sock; - struct sockaddr_un name; - - /* Create socket on which to send. */ - sock = socket(AF_UNIX, SOCK_DGRAM, 0); - if (sock < 0) { - perror("opening datagram socket"); - exit(1); - } - /* Construct name of socket to send to. */ - name.sun_family = AF_UNIX; - strcpy(name.sun_path, argv[1]); - /* Send message. */ - if (sendto(sock, DATA, sizeof(DATA), 0, - &name, sizeof(struct sockaddr_un)) < 0) { - perror("sending datagram message"); - } - close(sock); -} diff --git a/share/doc/ps1/07.ipctut/ustreamread.c b/share/doc/ps1/07.ipctut/ustreamread.c deleted file mode 100644 index db856e339feb..000000000000 --- a/share/doc/ps1/07.ipctut/ustreamread.c +++ /dev/null @@ -1,97 +0,0 @@ -.\" Copyright (c) 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)ustreamread.c 6.5 (Berkeley) 4/17/91 -.\" $Id: ustreamread.c,v 1.2 1993/08/01 18:23:24 mycroft Exp $ -.\" -#include -#include -#include -#include - -#define NAME "socket" - -/* - * This program creates a socket in the UNIX domain and binds a name to it. - * After printing the socket's name it begins a loop. Each time through the - * loop it accepts a connection and prints out messages from it. When the - * connection breaks, or a termination message comes through, the program - * accepts a new connection. - */ -main() -{ - int sock, msgsock, rval; - struct sockaddr_un server; - char buf[1024]; - - /* Create socket */ - sock = socket(AF_UNIX, SOCK_STREAM, 0); - if (sock < 0) { - perror("opening stream socket"); - exit(1); - } - /* Name socket using file system name */ - server.sun_family = AF_UNIX; - strcpy(server.sun_path, NAME); - if (bind(sock, &server, sizeof(struct sockaddr_un))) { - perror("binding stream socket"); - exit(1); - } - printf("Socket has name %s\en", server.sun_path); - /* Start accepting connections */ - listen(sock, 5); - for (;;) { - msgsock = accept(sock, 0, 0); - if (msgsock == -1) - perror("accept"); - else do { - bzero(buf, sizeof(buf)); - if ((rval = read(msgsock, buf, 1024)) < 0) - perror("reading stream message"); - else if (rval == 0) - printf("Ending connection\en"); - else - printf("-->%s\en", buf); - } while (rval > 0); - close(msgsock); - } - /* - * The following statements are not executed, because they follow an - * infinite loop. However, most ordinary programs will not run - * forever. In the UNIX domain it is necessary to tell the file - * system that one is through using NAME. In most programs one uses - * the call unlink() as below. Since the user will have to kill this - * program, it will be necessary to remove the name by a command from - * the shell. - */ - close(sock); - unlink(NAME); -} diff --git a/share/doc/ps1/07.ipctut/ustreamwrite.c b/share/doc/ps1/07.ipctut/ustreamwrite.c deleted file mode 100644 index d221f1fb4f09..000000000000 --- a/share/doc/ps1/07.ipctut/ustreamwrite.c +++ /dev/null @@ -1,72 +0,0 @@ -.\" Copyright (c) 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)ustreamwrite.c 6.5 (Berkeley) 4/17/91 -.\" $Id: ustreamwrite.c,v 1.2 1993/08/01 18:23:22 mycroft Exp $ -.\" -#include -#include -#include -#include - -#define DATA "Half a league, half a league . . ." - -/* - * This program connects to the socket named in the command line and sends a - * one line message to that socket. The form of the command line is - * ustreamwrite pathname - */ -main(argc, argv) - int argc; - char *argv[]; -{ - int sock; - struct sockaddr_un server; - char buf[1024]; - - /* Create socket */ - sock = socket(AF_UNIX, SOCK_STREAM, 0); - if (sock < 0) { - perror("opening stream socket"); - exit(1); - } - /* Connect socket using name specified by command line. */ - server.sun_family = AF_UNIX; - strcpy(server.sun_path, argv[1]); - - if (connect(sock, &server, sizeof(struct sockaddr_un)) < 0) { - close(sock); - perror("connecting stream socket"); - exit(1); - } - if (write(sock, DATA, sizeof(DATA)) < 0) - perror("writing on stream socket"); -} diff --git a/share/doc/ps1/13.rcs/man/rcsintro.1 b/share/doc/ps1/13.rcs/man/rcsintro.1 deleted file mode 100644 index b58c7de38310..000000000000 --- a/share/doc/ps1/13.rcs/man/rcsintro.1 +++ /dev/null @@ -1,24 +0,0 @@ -.\" $Id: rcsintro.1,v 1.2 1993/08/02 17:51:26 mycroft Exp $ -*- nroff -*- -.TH RCSINTRO 1 "June 29, 1983" "Purdue University" -.SH NAME -rcsintro \- introduction to RCS commands -.SH DESCRIPTION -The Revision Control System (RCS) manages multiple revisions of text files. -RCS automates the storing, retrieval, logging, identification, and merging -of revisions. RCS is useful for text that is revised frequently, for example -programs, documentation, graphics, papers, form letters, etc. -.PP -The basic user interface is extremely simple. The novice only needs -to learn two commands: -.I ci -and -.I co. -\fICi\fR, short for "checkin", deposits the contents of a -text file into an archival file called an RCS file. An RCS file -contains all revisions of a particular text file. -\fICo\fR, short for "checkout", retrieves revisions from an RCS file. -.SH SEE ALSO -ci(1), co(1), ident(1), merge(1), rcs(1), rcsdiff(1), rcsmerge(1), rlog(1), rcsfile(5). -.br -Walter F. Tichy, ``An Introduction to the Revision Control System'', -Programmer Supplementary Documents, Volume 1 (PS1), #13 diff --git a/share/doc/ps1/13.rcs/man/rcsmerge.1 b/share/doc/ps1/13.rcs/man/rcsmerge.1 deleted file mode 100644 index 79b8262b8b1c..000000000000 --- a/share/doc/ps1/13.rcs/man/rcsmerge.1 +++ /dev/null @@ -1,72 +0,0 @@ -.\" $Id: rcsmerge.1,v 1.2 1993/08/02 17:51:27 mycroft Exp $ -*- nroff -*- -.TH RCSMERGE 1 6/29/83 "Purdue University" -.SH NAME -rcsmerge \- merge RCS revisions -.SH SYNOPSIS -\fBrcsmerge\fR \fB-r\fIrev1\fR [ \fB-r\fIrev2\fR ] [ \fB-p\fR ] file -.SH DESCRIPTION -.I Rcsmerge -incorporates the changes between \fIrev1\fR and \fIrev2\fR of an -RCS file into the corresponding working file. If \fB-p\fR is given, the result -is printed on the std. output, otherwise the result overwrites the -working file. -.PP -A file name ending in ',v' is an RCS file name, otherwise a -working file name. \fIMerge\fR derives the working file name from the RCS -file name and vice versa, as explained in \fIco\fR (1). A pair consisting -of both an RCS and a working file name may also be specified. -.PP -\fIRev1\fR may not be omitted. If \fIrev2\fR is omitted, the latest -revision on the trunk is assumed. -Both \fIrev1\fR and \fIrev2\fR may be given numerically or symbolically. -.PP -\fIRcsmerge\fR prints a warning if there are overlaps, and delimits -the overlapping regions as explained in \fIco -j\fR. -The command is useful for incorporating changes into a checked-out revision. -.SH EXAMPLES -Suppose you have released revision 2.8 of f.c. Assume -furthermore that you just completed revision 3.4, when you receive -updates to release 2.8 from someone else. -To combine the updates to 2.8 and your changes between 2.8 and 3.4, -put the updates to 2.8 into file f.c and execute -.sp - rcsmerge -p -r2.8 -r3.4 f.c >f.merged.c -.sp -Then examine f.merged.c. -Alternatively, if you want to save the updates to 2.8 in the RCS file, -check them in as revision 2.8.1.1 and execute \fIco -j\fR: -.sp - ci -r2.8.1.1 f.c - co -r3.4 -j2.8:2.8.1.1 f.c -.sp -As another example, the following command undoes the changes -between revision 2.4 and 2.8 in your currently checked out revision -in f.c. -.sp - rcsmerge -r2.8 -r2.4 f.c -.sp -Note the order of the arguments, and that f.c will be -overwritten. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.2 $ -; Release Date: -.VL $Date: 1993/08/02 17:51:27 $ -\&. -.sp 0 -Copyright \(co 1982 by Walter F. Tichy. -.SH SEE ALSO -ci (1), co (1), merge (1), ident (1), rcs (1), rcsdiff (1), rlog (1), rcsfile (5). -.sp 0 -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. -.SH BUGS -\fIRcsmerge\fR does not work for -files that contain lines with a single `.'. diff --git a/share/doc/ps1/13.rcs/man/rlog.1 b/share/doc/ps1/13.rcs/man/rlog.1 deleted file mode 100644 index a2db440f4fc5..000000000000 --- a/share/doc/ps1/13.rcs/man/rlog.1 +++ /dev/null @@ -1,132 +0,0 @@ -.\" $Id: rlog.1,v 1.2 1993/08/02 17:51:28 mycroft Exp $ -*- nroff -*- -.TH RLOG 1 6/29/83 "Purdue University" -.SH NAME -rlog \- print log messages and other information about RCS files -.SH SYNOPSIS -.B rlog -[ options ] -file ... -.SH DESCRIPTION -.I Rlog -prints information about RCS files. -Files ending in `,v' are RCS files, all others are working files. If -a working file is given, \fIrlog\fR tries to find the corresponding -RCS file first in directory ./RCS and then in the current directory, -as explained in \fIco\fR (1). -.PP -\fIRlog\fR prints the following information for each -RCS file: RCS file name, working file name, head (i.e., the number -of the latest revision on the trunk), access list, locks, -symbolic names, suffix, total number of revisions, -number of revisions selected for printing, and -descriptive text. This is followed by entries for the selected revisions in -reverse chronological order for each branch. For each revision, -\fIrlog\fR prints revision number, author, date/time, state, number of -lines added/deleted (with respect to the previous revision), -locker of the revision (if any), and log message. -Without options, \fIrlog\fR prints complete information. -The options below restrict this output. -.TP 10 -.B \-L -ignores RCS files that have no locks set; convenient in combination with -\fB-R\fR, \fB-h\fR, or \fB-l\fR. -.TP 10 -.B \-R -only prints the name of the RCS file; convenient for translating a -working file name into an RCS file name. -.TP 10 -.B \-h -prints only RCS file name, working file name, head, -access list, locks, -symbolic names, and suffix. -.TP 10 -.B \-t -prints the same as \fB-h\fR, plus the descriptive text. -.TP 10 -.BI \-d "dates" -prints information about revisions with a checkin date/time in the ranges given by -the semicolon-separated list of \fIdates\fR. -A range of the form \fId1d1\fR -selects the revisions that were deposited between -\fId1\fR and \fId2\fR, (inclusive). -A range of the form \fI\fR selects -all revisions dated -\fId\fR or earlier. -A range of the form \fId<\fR or \fI>d\fR selects -all revisions dated \fId\fR or later. -A range of the form \fId\fR selects the single, latest revision dated \fId\fR or -earlier. -The date/time strings \fId, d1, \fRand \fId2\fR -are in the free format explained in \fIco\fR (1). -Quoting is normally necessary, especially for \fI<\fR and \fI>\fR. Note that the separator is -a semicolon. -.TP 10 -.B \-l\fR[\fIlockers\fR] -prints information about locked revisions. -If the comma-separated list \fIlockers\fR of login names is given, -only the revisions locked by the given login names are printed. -If the list is omitted, all locked revisions are printed. -.TP 10 -.BI \-r "revisions" -prints information about revisions given in the comma-separated list -\fIrevisions\fR of revisions and ranges. A range \fIrev1\-rev2\fR means revisions -\fIrev1\fR to \fIrev2\fR on the same branch, \fI\-rev\fR means revisions -from the beginning of the branch up to and including \fIrev\fR, -and \fIrev\-\fR means revisions starting with \fIrev\fR to the end of the -branch containing \fIrev\fR. An argument that is a branch means all -revisions on that branch. A range of branches means all revisions -on the branches in that range. -.TP 10 -.BI \-s "states" -prints information about revisions whose state attributes match one of the -states given in the comma-separated list \fIstates\fR. -.TP 10 -.B \-w\fR[\fIlogins\fR] -prints information about revisions checked in by users with -login names appearing in the comma-separated list \fIlogins\fR. -If \fIlogins\fR is omitted, the user's login is assumed. -.PP -\fIRlog\fR prints the intersection of the revisions selected with -the options \fB-d\fR, \fB-l\fR, \fB-s\fR, \fB-w\fR, intersected -with the union of the revisions selected by \fB-b\fR and \fB-r\fR. -.SH EXAMPLES -.nf -.sp - rlog -L -R RCS/*,v - rlog -L -h RCS/*,v - rlog -L -l RCS/*,v - rlog RCS/*,v -.sp -.fi -The first command prints the names of all RCS files in the subdirectory `RCS' -which have locks. The second command prints the headers of those files, -and the third prints the headers plus the log messages of the locked revisions. -The last command prints complete information. -.SH DIAGNOSTICS -The exit status always refers to the last RCS file operated upon, -and is 0 if the operation was successful, 1 otherwise. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.2 $ -; Release Date: -.VL $Date: 1993/08/02 17:51:28 $ -\&. -.sp 0 -Copyright \(co 1982 by Walter F. Tichy. -.SH SEE ALSO -ci (1), co (1), ident(1), rcs (1), rcsdiff (1), rcsintro (1), rcsmerge (1), rcsfile (5), sccstorcs (8). -.sp 0 -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. -.SH BUGS - - - - diff --git a/share/doc/ps1/13.rcs/man/sccstorcs.1 b/share/doc/ps1/13.rcs/man/sccstorcs.1 deleted file mode 100644 index 058bdfd9bc0b..000000000000 --- a/share/doc/ps1/13.rcs/man/sccstorcs.1 +++ /dev/null @@ -1,52 +0,0 @@ -.\" $Id: sccstorcs.1,v 1.2 1993/08/02 17:51:29 mycroft Exp $ -*- nroff -*- -.TH SCCSTORCS 8 "29 June 1983" -.UC 4 -.SH NAME -sccstorcs \- build RCS file from SCCS file -.SH SYNOPSIS -\fBsccstorcs\fR [\fB\-t\fR] [\fB\-v\fR] \fIs.file\fR ... -.SH DESCRIPTION -.I Sccstorcs -builds an RCS file from each SCCS file argument. -The deltas and comments for each delta are preserved and installed into -the new RCS file in order. -Also preserved are -the user access list and descriptive text, if any, -from the SCCS file. -.PP -The following flags are meaningful: -.TP -\fB\-t\fR -Trace only. -Prints detailed information about the SCCS file and lists the -commands that would be executed to produce the RCS file. -No commands are actually executed and no RCS file is made. -.TP -\fB\-v\fR -Verbose. -Prints each command that is run while it is building the RCS file. -.SH FILES -For each s.\fIsomefile\fR, -.I Sccstorcs -writes the files \fIsomefile\fR and \fIsomefile\fR,v -which should not already exist. -.I Sccstorcs -will abort, rather than overwrite those files if they do exist. -.SH SEE ALSO -ci (1), co (1), rcs (1). -.br -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision -Control System," in \fIProceedings of the 6th International Conference -on Software Engineering\fR, IEEE, Tokyo, Sept. 1982. -.SH DIAGNOSTICS -All diagnostics are written to stderr. -Non-zero exit status on error. -.SH BUGS -.I Sccstorcs -does not preserve all SCCS options specified in the SCCS file. -Most notably, it does not preserve removed deltas, MR numbers, -and cutoff points. -.SH AUTHOR -Ken Greer - -Copyright \(co 1983 by Kenneth L. Greer diff --git a/share/doc/ps1/18.curses/doc.III b/share/doc/ps1/18.curses/doc.III deleted file mode 100644 index c2daa5a31c85..000000000000 --- a/share/doc/ps1/18.curses/doc.III +++ /dev/null @@ -1,343 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)doc.III 6.3 (Berkeley) 4/17/91 -.\" -.Ds -.Fd baudrate "" \*m -.De -Returns the output baud rate of the terminal. -This is a system dependent constant -(defined in -.b -on BSD systems, -which is included by -.b ). -.Ds -.Fd delwin win -WINDOW *win; -.De -Deletes the window from existence. -All resources are freed for future use by -.b calloc (3). -If a window has a -.Fn subwin -allocated window inside of it, -deleting the outer window -the subwindow is not affected, -even though this does invalidate it. -Therefore, -subwindows should be deleted before their -outer windows are. -.Ds -.Fd endwin -.De -Finish up window routines before exit. -This restores the terminal to the state it was before -.Fn initscr -(or -.Fn gettmode -and -.Fn setterm ) -was called. -It should always be called before exiting. -It does not exit. -This is especially useful for resetting tty stats -when trapping rubouts via -.b signal (2). -.Ds -.Fd erasechar "" \*m -.De -Returns the erase character -for the terminal, -.i i.e. , -the character used by the user to erase a single character from the input. -.Ds -.Fd getcap str "" "char *" -char *str; -.De -Return a pointer to the -.b termcap -capability described by -.Vn str -(see -.b termcap (5) -for details). -.Ds -.Fd getyx win\*,y\*,x \*m -WINDOW *win; -int y\*,x; -.De -Puts the current \*y of -.Vn win -in the variables -.Vn y -and -.Vn x . -Since it is a macro, -not a function, -you do not pass the address -of -.Vn y -and -.Vn x . -.Ds -.Fd inch "" \*m -.Fd winch win \*m -WINDOW *win; -.De -Returns the character at the current \*(y -on the given window. -This does not make any changes to the window. -.Ds -.Fd initscr -.De -Initialize the screen routines. -This must be called before any of the screen routines are used. -It initializes the terminal-type data and such, -and without it none of the routines can operate. -If standard input is not a tty, -it sets the specifications to the terminal -whose name is pointed to by -.Vn Def\*_term -(initialy "dumb"). -If the boolean -.Vn My\*_term -is true, -.Vn Def\*_term -is always used. -If the system supports the -.b TIOCGWINSZ -.Fn ioctl "" "" 2 -call, -it is used to get the number of lines and columns for the terminal, -otherwise it is taken from the -.b termcap -description. -.Ds -.Fd killchar "" \*m -.De -Returns the line kill character -for the terminal, -.i i.e. , -the character used by the user to erase an entire line from the input. -.Ds -.Fd leaveok win\*,boolf \*m -WINDOW *win; -bool boolf; -.De -Sets the boolean flag for leaving the cursor after the last change. -If -.Vn boolf -is TRUE, -the cursor will be left after the last update on the terminal, -and the current \*y for -.Vn win -will be changed accordingly. -If it is FALSE, -it will be moved to the current \*y. -This flag -(initialy FALSE) -retains its value until changed by the user. -.Ds -.Fd longname termbuf\*,name -char *termbuf\*,*name; -.Fd fullname termbuf\*,name -char *termbuf\*,*name; -.De -.Fn longname -fills in -.Vn name -with the long name of the terminal described by the -.b termcap -entry in -.Vn termbuf . -It is generally of little use, -but is nice for telling the user in a readable format what terminal -we think he has. -This is available in the global variable -.Vn ttytype . -.Vn termbuf -is usually set via the termlib routine -.Fn tgetent . -.Fn fullname -is the same as -.Fn longname , -except that it gives the fullest name given in the entry, -which can be quite verbose. -.Ds -.Fd mvwin win\*,y\*,x -WINDOW *win; -int y, x; -.De -Move the home position of the window -.Vn win -from its current starting coordinates -to -.Vn y\*,x ). ( -If that would put part or all of the window -off the edge of the terminal screen, -.Fn mvwin -returns ERR and does not change anything. -For subwindows, -.Fn mvwin -also returns ERR if you attempt to move it off its main window. -If you move a main window, -all subwindows are moved along with it. -.Ds -.Fd newwin lines\*,cols\*,begin\*_y\*,begin\*_x "" "WINDOW *" -int lines\*,cols\*,begin\*_y\*,begin\*_x; -.De -Create a new window with -.Vn lines -lines and -.Vn cols -columns starting at position -.Vn begin\*_y\*,begin\*_x ). ( -If either -.Vn lines -or -.Vn cols -is 0 (zero), -that dimension will be set to -.Vn "LINES \- begin\*_y" ) ( -or -.Vn "COLS \- begin\*_x" ) ( -respectively. -Thus, to get a new window of dimensions -.Vn LINES -\(mu -.Vn COLS , -use -.Fn newwin . "" 0\*,0\*,0\*,0 -.Ds -.Fd nl "" \*m -.Fd nonl "" \*m -.De -Set or unset the terminal to/from nl mode, -.i i.e. , -start/stop the system from mapping -.b -to -.b . -If the mapping is not done, -.Fn refresh -can do more optimization, -so it is recommended, but not required, to turn it off. -.Ds -.Fd scrollok win\*,boolf \*m -WINDOW *win; -bool boolf; -.De -Set the scroll flag for the given window. -If -.Vn boolf -is FALSE, scrolling is not allowed. -This is its default setting. -.Ds -.Fd touchline win\*,y\*,startx\*,endx -WINDOW *win; -int y\*,startx\*,endx; -.De -This function performs a function similar to -.Fn touchwin -on a single line. -It marks the first change for the given line -to be -.Vn startx , -if it is before the current first change mark, -and -the last change mark is set to be -.Vn endx -if it is currently less than -.Vn endx . -.Ds -.Fd touchoverlap win1\*,win2 -WINDOW *win1, *win2; -.De -Touch the window -.Vn win2 -in the area which overlaps with -.Vn win1 . -If they do not overlap, -no changes are made. -.Ds -.Fd touchwin win -WINDOW *win; -.De -Make it appear that the every location on the window -has been changed. -This is usually only needed for refreshes with overlapping windows. -.Ds -.Fd subwin win\*,lines\*,cols\*,begin\*_y\*,begin\*_x "" "WINDOW *" -WINDOW *win; -int lines\*,cols\*,begin\*_y\*,begin\*_x; -.De -Create a new window with -.Vn lines -lines and -.Vn cols -columns starting at position -.Vn begin\*_y\*,begin\*_x ) ( -inside the window -.i win . -This means that any change made to either window -in the area covered -by the subwindow will be made on both windows. -.Vn begin\*_y\*,begin\*_x -are specified relative to the overall screen, -not the relative (0\*,0) of -.Vn win . -If either -.Vn lines -or -.Vn cols -is 0 (zero), -that dimension will be set to -.Vn "LINES \- begin\*_y" ) ( -or -.Vn "COLS \- begin\*_x" ) ( -respectively. -.Ds -.Fd unctrl ch \*m -char ch; -.De -This is actually a debug function for the library, -but it is of general usefulness. -It returns a string which is a representation of -.Vn ch . -Control characters become their upper-case equivalents preceded by a "^". -Other letters stay just as they are. -To use -.Fn unctrl , -you may have to have -.b #include\ -in your file. diff --git a/share/doc/ps1/18.curses/doc.IV b/share/doc/ps1/18.curses/doc.IV deleted file mode 100644 index a726ad35125d..000000000000 --- a/share/doc/ps1/18.curses/doc.IV +++ /dev/null @@ -1,110 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)doc.IV 6.3 (Berkeley) 4/17/91 -.\" -.Ds -.Fd gettmode -.De -Get the tty stats. -This is normally called by -.Fn initscr . -.Ds -.Fd mvcur lasty\*,lastx\*,newy\*,newx -int lasty\*,lastx\*,newy\*,newx; -.De -Moves the terminal's cursor from -.Vn lasty\*,lastx ) ( -to -.Vn newy\*,newx ) ( -in an approximation of optimal fashion. -This routine uses the functions borrowed from -.i ex -version 2.6. -It is possible to use this optimization -without the benefit of the screen routines. -With the screen routines, this should not be called by the user. -.Fn move -and -.Fn refresh -should be used to move the cursor position, -so that the routines know what's going on. -.Ds -.Fd scroll win -WINDOW *win; -.De -Scroll the window upward one line. -This is normally not used by the user. -.Ds -.Fd savetty "" \*m -.Fd resetty "" \*m -.De -.Fn savetty -saves the current tty characteristic flags. -.Fn resetty -restores them to what -.Fn savetty -stored. -These functions are performed automatically by -.Fn initscr -and -.Fn endwin . -.Ds -.Fd setterm name -char *name; -.De -Set the terminal characteristics to be those of the terminal named -.Vn name , -getting the terminal size from the -.b TIOCGWINSZ -.Fn ioctl "" "" 2 -if it exists, -otherwise from the environment. -This is normally called by -.Fn initscr . -.Ds -.Fd tstp -.De -If the new -.b tty (4) -driver is in use, -this function -will save the current tty state -and then put the process to sleep. -When the process gets restarted, -it restores the tty state -and then calls -.Fn wrefresh "" "" curscr -to redraw the screen. -.Fn initscr -sets the signal -SIGTSTP -to trap to this routine. diff --git a/share/doc/ps1/18.curses/intro.0 b/share/doc/ps1/18.curses/intro.0 deleted file mode 100644 index e307ea4b0964..000000000000 --- a/share/doc/ps1/18.curses/intro.0 +++ /dev/null @@ -1,97 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)intro.0 6.3 (Berkeley) 4/17/91 -.\" $Id: intro.0,v 1.2 1993/08/01 07:37:57 mycroft Exp $ -.\" -.tp -.(l C -.ps 12 -.ft B -Screen Updating and Cursor Movement Optimization: -.fl -A Library Package -.ft -.ps -.sp -.i "Kenneth C. R. C. Arnold" -.sp -Computer Science Division -Department of Electrical Engineering and Computer Science -University of California, Berkeley -Berkeley, California 94720 -.sp 3 -.bi ABSTRACT -.sp 2 -.)l -.(q -.pp -This document describes a package of C library functions -which allow the user to: -.ie t .ip \ \ \ \(bu -.el .ip 1) -update a screen with reasonable optimization, -.ie t .ip \ \ \ \(bu -.el .ip 2) -get input from the terminal -in a screen-oriented fashion, -and -.ie t .ip \ \ \ \(bu -.el .ip 3) -independent from the above, move the cursor optimally -from one point to another. -.pp -These routines all use the -\*(tc \*(db to describe the capabilities of the terminal. -.)q -.b Acknowledgements -.pp -This package would not exist -without the work of Bill Joy, -who, -in writing his editor, -created the capability to generally describe terminals, -wrote the routines which read this \*(db, -and, most importantly, -those which implement optimal cursor movement, -which routines I have simply lifted nearly intact. -Doug Merritt and Kurt Shoens also were extremely important, -as were both willing to waste time listening to me rant and rave. -The help and/or support of -Ken Abrams, -Alan Char, -Mark Horton, -and -Joe Kalash, -was, and is, -also greatly appreciated. -.sp 2 -Revised 16 April 1986 diff --git a/share/doc/ps1/18.curses/intro.1 b/share/doc/ps1/18.curses/intro.1 deleted file mode 100644 index cd39eba5252d..000000000000 --- a/share/doc/ps1/18.curses/intro.1 +++ /dev/null @@ -1,282 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)intro.1 6.3 (Berkeley) 4/17/91 -.\" $Id: intro.1,v 1.2 1993/08/01 07:37:56 mycroft Exp $ -.\" -.bp -.sh 1 Overview -.pp -In making available the generalized terminal descriptions in \*(tc, -much information was made available to the programmer, -but little work was taken out of one's hands. -The purpose of this package is to allow the C programmer -to do the most common type of terminal dependent functions, -those of movement optimization and optimal screen updating, -without doing any of the dirty work, -and (hopefully) with nearly as much ease as is necessary to simply print -or read things. -.pp -The package is split into three parts: -(1) Screen updating; -(2) Screen updating with user input; -and -(3) Cursor motion optimization. -.pp -It is possible to use the motion optimization -without using either of the other two, -and screen updating and input can be done -without any programmer knowledge of the motion optimization, -or indeed the \*(et \*(db itself. -.sh 2 "Terminology (or, Words You Can Say to Sound Brilliant)" -.pp -In this document, -the following terminology is kept to with reasonable consistency: -.de Ip -.sp -.in 5n -.ti 0n -.bi "\\$1" : -.. -.Ip window -An internal representation -containing an image of what a section of the terminal screen may look like -at some point in time. -This subsection can either encompass the entire terminal screen, -or any smaller portion down to a single character within that screen. -.Ip "terminal" -Sometimes called -.bi terminal -.bi screen . -The package's idea of what the terminal's screen currently looks like, -.i i.e. , -what the user sees now. -This is a special -.i screen : -.Ip screen -This is a subset of windows which are as large as the terminal screen, -.i i.e. , -they start at the upper left hand corner -and encompass the lower right hand corner. -One of these, -.Vn stdscr , -is automatically provided for the programmer. -.rm Ip -.sh 2 "Compiling Things" -.pp -In order to use the library, -it is necessary to have certain types and variables defined. -Therefore, the programmer must have a line: -.(l -.b "#include " -.)l -at the top of the program source. -The header file -.b -needs to include -.b , -so the one should not do so oneself\**. -.(f -\** -The screen package also uses the Standard I/O library, -so -.b -includes -.b . -It is redundant -(but harmless) -for the programmer to do it, too. -.)f -Also, -compilations should have the following form: -.(l -.ie t \fBcc\fR [ \fIflags\fR ] file ... \fB\-lcurses \-ltermcap\fR -.el \fIcc\fR [ flags ] file ... \fI\-lcurses \-ltermcap\fR -.)l -.sh 2 "Screen Updating" -.pp -In order to update the screen optimally, -it is necessary for the routines to know what the screen currently looks like -and what the programmer wants it to look like next. -For this purpose, -a data type -(structure) -named -.Vn WINDOW -is defined -which describes a window image to the routines, -including its starting position on the screen -(the \*y of the upper left hand corner) -and its size. -One of these -(called -.Vn curscr -for -.i "current screen" ) -is a screen image of what the terminal currently looks like. -Another screen -(called -.Vn stdscr , -for -.i "standard screen" ) -is provided -by default -to make changes on. -.pp -A window is a purely internal representation. -It is used to build and store -a potential image of a portion of the terminal. -It doesn't bear any necessary relation -to what is really on the terminal screen. -It is more like an array of characters on which to make changes. -.pp -When one has a window which describes -what some part the terminal should look like, -the routine -.Fn refresh -(or -.Fn wrefresh -if the window is not -.Vn stdscr ) -is called. -.Fn refresh -makes the terminal, -in the area covered by the window, -look like that window. -Note, therefore, that changing something on a window -.i does -.bi not -.i "change the terminal" . -Actual updates to the terminal screen -are made only by calling -.Fn refresh -or -.Fn wrefresh . -This allows the programmer to maintain several different ideas -of what a portion of the terminal screen should look like. -Also, changes can be made to windows in any order, -without regard to motion efficiency. -Then, at will, -the programmer can effectively say -.q "make it look like this" , -and let the package worry about the best way to do this. -.sh 2 "Naming Conventions" -.pp -As hinted above, -the routines can use several windows, -but two are automatically given: -.Vn curscr , -which knows what the terminal looks like, -and -.Vn stdscr , -which is what the programmer wants the terminal to look like next. -The user should never really access -.Vn curscr -directly. -Changes should be made to -the appropriate screen, -and then the routine -.Fn refresh -(or -.Fn wrefresh ) -should be called. -.pp -Many functions are set up to deal with -.Vn stdscr -as a default screen. -For example, to add a character to -.Vn stdscr , -one calls -.Fn addch -with the desired character. -If a different window is to be used, -the routine -.Fn waddch -(for -.b w indow-specific -.Fn addch ) -is provided\**. -.(f -\** -Actually, -.Fn addch -is really a -.q #define -macro with arguments, -as are most of the "functions" which deal with -.Vn stdscr -as a default. -.)f -This convention of prepending function names with a -.Bq w -when they are to be applied to specific windows -is consistent. -The only routines which do -.i not -do this are those -to which a window must always be specified. -.pp -In order to move the current \*y from one point to another, -the routines -.Fn move -and -.Fn wmove -are provided. -However, -it is often desirable to first move and then perform some I/O operation. -In order to avoid clumsyness, -most I/O routines can be preceded by the prefix -.Bq mv -and the desired \*y then can be added to the arguments to the function. -For example, -the calls -.(l -move(y\*,x); -addch(ch); -.)l -can be replaced by -.(l -mvaddch(y\*,x\*,ch); -.)l -and -.(l -wmove(win\*,y\*,x); -waddch(win\*,ch); -.)l -can be replaced by -.(l -mvwaddch(win\*,y\*,x\*,ch); -.)l -Note that the window description pointer -.Vn win ) ( -comes before the added \*y. -If such pointers are need, -they are always the first parameters passed. diff --git a/share/doc/ps1/18.curses/intro.2 b/share/doc/ps1/18.curses/intro.2 deleted file mode 100644 index b54f2fca4d8f..000000000000 --- a/share/doc/ps1/18.curses/intro.2 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)intro.2 6.3 (Berkeley) 4/17/91 -.\" $Id: intro.2,v 1.2 1993/08/01 07:37:55 mycroft Exp $ -.\" -.sh 1 Variables -.pp -Many variables which are used to describe the terminal environment -are available to the programmer. They are: -.TS -expand; -lw(6m) lw(8n) lw(50n). -type name description -_ -WINDOW * curscr T{ -.fi -current version of the screen (terminal screen). -T} -WINDOW * stdscr T{ -standard screen. Most updates are usually done here. -T} -char * Def\*_term T{ -default terminal type if type cannot be determined -T} -bool My\*_term T{ -use the terminal specification in \fIDef\*_term\fR as terminal, -irrelevant of real terminal type -T} -char * ttytype T{ -full name of the current terminal. -T} -int LINES T{ -number of lines on the terminal -T} -int COLS T{ -number of columns on the terminal -T} -int ERR T{ -error flag returned by routines on a fail. -T} -int OK T{ -error flag returned by routines when things go right. -T} -.TE -.pp -There are also several -.q #define -constants and types -which are of general usefulness: -.sp -.ev 1 -.ta 11n -.(b L -.nf -reg storage class ``register'' (\fIe.g.\fP, \fIreg int i;\fR\|) -bool boolean type, actually a ``char'' (\fIe.g.\fP, \fIbool doneit;\fR\|) -TRUE boolean ``true'' flag (1). -FALSE boolean ``false'' flag (0). -.fi -.ev -.)b -.lp diff --git a/share/doc/ps1/18.curses/intro.3 b/share/doc/ps1/18.curses/intro.3 deleted file mode 100644 index 2736c97dca38..000000000000 --- a/share/doc/ps1/18.curses/intro.3 +++ /dev/null @@ -1,231 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)intro.3 6.3 (Berkeley) 4/17/91 -.\" $Id: intro.3,v 1.2 1993/08/01 07:37:54 mycroft Exp $ -.\" -.sh 1 Usage -.pp -This is a description of how to actually use the screen package. -In it, we assume all updating, reading, etc. -is applied to -.Vn stdscr . -All instructions will work on any window, -with changing the function name and parameters as mentioned above. -.sh 2 "Starting up" -.pp -In order to use the screen package, -the routines must know about terminal characteristics, -and the space for -.Vn curscr -and -.Vn stdscr -must be allocated. -These functions are performed by -.Fn initscr . -Since it must allocate space for the windows, -it can overflow core when attempting to do so. -On this rather rare occasion, -.Fn initscr -returns ERR. -.Fn initscr -must -.bi always -be called before any of the routines which affect windows are used. -If it is not, -the program will core dump as soon as either -.Vn curscr -or -.Vn stdscr -are referenced. -However, it is usually best to wait to call it -until after you are sure you will need it, -like after checking for startup errors. -Terminal status changing routines -like -.Fn nl -and -.Fn cbreak -should be called after -.Fn initscr . -.pp -Now that the screen windows have been allocated, -you can set them up for the run. -If you want to, say, allow the window to scroll, -use -.Fn scrollok . -If you want the cursor to be left after the last change, use -.Fn leaveok . -If this isn't done, -.Fn refresh -will move the cursor to the window's current \*y after updating it. -New windows of your own can be created, too, by using the functions -.Fn newwin -and -.Fn subwin . -.Fn delwin -will allow you to get rid of old windows. -If you wish to change the official size of the terminal by hand, -just set the variables -.Vn LINES -and -.Vn COLS -to be what you want, -and then call -.Fn initscr . -This is best done before, -but can be done either before or after, -the first call to -.Fn initscr , -as it will always delete any existing -.Vn stdscr -and/or -.Vn curscr -before creating new ones. -.pp -.sh 2 "The Nitty-Gritty" -.sh 3 Output -.pp -Now that we have set things up, -we will want to actually update the terminal. -The basic functions -used to change what will go on a window are -.Fn addch -and -.Fn move . -.Fn addch -adds a character at the current \*y, -returning ERR if it would cause the window to illegally scroll, -.i i.e. , -printing a character in the lower right-hand corner -of a terminal which automatically scrolls -if scrolling is not allowed. -.Fn move -changes the current \*y to whatever you want them to be. -It returns ERR if you try to move off the window when scrolling is not allowed. -As mentioned above, you can combine the two into -.Fn mvaddch -to do both things in one fell swoop. -.pp -The other output functions, -such as -.Fn addstr -and -.Fn printw , -all call -.Fn addch -to add characters to the window. -.pp -After you have put on the window what you want there, -when you want the portion of the terminal covered by the window -to be made to look like it, -you must call -.Fn refresh . -In order to optimize finding changes, -.Fn refresh -assumes that any part of the window not changed -since the last -.Fn refresh -of that window has not been changed on the terminal, -.i i.e. , -that you have not refreshed a portion of the terminal -with an overlapping window. -If this is not the case, -the routines -.Fn touchwin , -.Fn touchline , -and -.Fn touchoverlap -are provided to make it look like a desired part of window has been changed, -thus forcing -.Fn refresh -check that whole subsection of the terminal for changes. -.pp -If you call -.Fn wrefresh -with -.Vn curscr , -it will make the screen look like -.Vn curscr -thinks it looks like. -This is useful for implementing a command -which would redraw the screen in case it get messed up. -.sh 3 Input -.pp -Input is essentially a mirror image of output. -The complementary function to -.Fn addch -is -.Fn getch -which, -if echo is set, -will call -.Fn addch -to echo the character. -Since the screen package needs to know what is on the terminal at all times, -if characters are to be echoed, -the tty must be in raw or cbreak mode. -If it is not, -.Fn getch -sets it to be cbreak, -and then reads in the character. -.sh 3 Miscellaneous -.pp -All sorts of fun functions exists for maintaining and changing information -about the windows. -For the most part, -the descriptions in section 5.4. should suffice. -.sh 2 "Finishing up" -.pp -In order to do certain optimizations, -and, -on some terminals, -to work at all, -some things must be done -before the screen routines start up. -These functions are performed in -.Fn getttmode -and -.Fn setterm , -which are called by -.Fn initscr . -In order to clean up after the routines, -the routine -.Fn endwin -is provided. -It restores tty modes to what they were -when -.Fn initscr -was first called. -Thus, -anytime after the call to initscr, -.Fn endwin -should be called before exiting. diff --git a/share/doc/ps1/18.curses/intro.4 b/share/doc/ps1/18.curses/intro.4 deleted file mode 100644 index 957e99d6e8ec..000000000000 --- a/share/doc/ps1/18.curses/intro.4 +++ /dev/null @@ -1,250 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)intro.4 6.3 (Berkeley) 4/17/91 -.\" $Id: intro.4,v 1.2 1993/08/01 07:37:53 mycroft Exp $ -.\" -.sh 1 "Cursor Motion Optimization: Standing Alone" -.pp -It is possible to use the cursor optimization functions of this screen package -without the overhead and additional size of the screen updating functions. -The screen updating functions are designed for uses -where parts of the screen are changed, -but the overall image remains the same. -This includes such programs as -.b rogue -and -.b vi \**. -.(f -\** -.b rogue -actually uses these functions, -.b vi -does not. -.)f -Certain other programs -will find it difficult to use these functions in this manner -without considerable unnecessary program overhead. -For such applications, -such as some -.q "\fIcrt hacks\fR\|" \** -.(f -\** -Graphics programs designed to run on character-oriented terminals. -I could name many, -but they come and go, -so the list would be quickly out of date. -Recently, there have been programs such as -.b rain , -.b rocket , -and -.b gun . -.)f -and optimizing -.b more (1)-type -programs, -all that is needed is the motion optimizations. -This, therefore, is a description -of what some of what goes on at the lower levels of this screen package. -The descriptions assume a certain amount of familiarity -with programming problems and some finer points of C. -None of it is terribly difficult, -but you should be forewarned. -.sh 2 "Terminal Information" -.pp -In order to use a terminal's -features to the best of a program's abilities, -it must first know what they are\**. -.(f -\** -If this comes as any surprise to you, -there's this tower in Paris they're thinking of junking -that I can let you have for a song. -.)f -The \*(tc \*(db describes these, -but a certain amount of decoding is necessary, -and there are, of course, -both efficient and inefficient ways of reading them in. -The algorithm that the uses is taken from -.b vi -and is hideously efficient. -It reads them -in a tight loop -into a set of variables -whose names are two uppercase letters with some mnemonic value. -For example, -.Vn HO -is a string which moves the cursor to the "home" position\**. -.(f -\** -These names are identical to those variables -used in the -.b termcap (5) -\*(db to describe each capability. -See Appendix A for a complete list of those read, -and the -.b termcap (5) -manual page -for a full description. -.)f -As there are two types of variables involving ttys, -there are two routines. -The first, -.Fn gettmode , -sets some variables based upon the tty modes accessed by -.b gtty (2) -and -.b stty (2) . -The second, -.Fn setterm , -a larger task by reading in the descriptions from the \*(tc \*(db. -This is the way these routines are used by -.Fn initscr : -.(b -.(l I -\*fif\fP (isatty(0)) { - gettmode(); - \*fif\fP ((sp=getenv("TERM")) != NULL) - setterm(sp); - \*felse\fP - setterm(Def\*_term); -} -\*felse\fP - setterm(Def\*_term); -\*_puts(TI); -\*_puts(VS); -.)l -.)b -.pp -.Fn isatty -checks to see if file descriptor 0 is a terminal\**. -.(f -\** -.Fn isatty -is defined in the default C library function routines. -It does a -.b gtty (2) -on the descriptor and checks the return value. -.)f -If it is, -.Fn gettmode -sets the terminal description modes from a -.b gtty (2) . -.Fn getenv -is then called to get the name of the terminal, -and that value (if there is one) is passed to -.Fn setterm , -which reads in the variables from \*(tc -associated with that terminal. -.Fn getenv "" ( -returns a pointer to a string containing the name of the terminal, -which we save in the character pointer -.Vn sp .) -If -.Fn isatty -returns false, -the default terminal -.Vn Def\*_term -is used. -The -.Vn TI -and -.Vn VS -sequences initialize the terminal -.Fn \*_puts "" ( -is a macro which uses -.Fn tputs -(see -.b termcap (3)) -and -.Fn \*_putchar "" -to put out a string). -.Fn endwin -undoes these things. -.sh 2 "Movement Optimizations, or, Getting Over Yonder" -.pp -Now that we have all this useful information, -it would be nice to do something with it\**. -.(f -\** -Actually, -it -.i can -be emotionally fulfilling just to get the information. -This is usually only true, however, -if you have the social life of a kumquat. -.)f -The most difficult thing to do properly is motion optimization. -When you consider how many different features various terminals have -(tabs, backtabs, non-destructive space, home sequences, absolute tabs, .....) -you can see that deciding how to get from here to there -can be a decidedly non-trivial task. -The editor -.b vi -uses many of these features, -and the routines it uses to do this take up many pages of code. -Fortunately, I was able to liberate them with the author's permission, -and use them here. -.pp -After using -.Fn gettmode -and -.Fn setterm -to get the terminal descriptions, -the function -.Fn mvcur -deals with this task. -It usage is simple: -you simply tell it where you are now and where you want to go. -For example -.(l -mvcur(0\*,0\*,LINES/2\*,COLS/2) -.)l -.lp -would move the cursor from the home position (0\*,0) -to the middle of the screen. -If you wish to force absolute addressing, -you can use the function -.Fn tgoto -from the -.b termlib (7) -routines, -or you can tell -.Fn mvcur -that you are impossibly far away, -like Cleveland. -For example, -to absolutely address the lower left hand corner of the screen -from anywhere -just claim that you are in the upper right hand corner: -.(l -mvcur(0\*,COLS\-1\*,LINES\-1\*,0) -.)l diff --git a/share/doc/ps1/18.curses/intro.5 b/share/doc/ps1/18.curses/intro.5 deleted file mode 100644 index 780c61ccf682..000000000000 --- a/share/doc/ps1/18.curses/intro.5 +++ /dev/null @@ -1,61 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)intro.5 6.3 (Berkeley) 4/17/91 -.\" $Id: intro.5,v 1.2 1993/08/01 07:37:51 mycroft Exp $ -.\" -.sh 1 "The Functions" -.pp -In the following definitions, -.q \*m -means that the -.q function -is really a -.q #define -macro with arguments. -This means that it will not show up in stack traces in the debugger, -or, in the case of such functions as -.Fn addch , -it will show up as it's -.Bq w -counterpart. -The arguments are given to show the order and type of each. -Their names are not mandatory, -just suggestive. -.ta 11m,17m,25m,33m,41m,49m,57m,65m,73m -.sh 2 "Output Functions" -.so doc.I -.sh 2 "Input Functions" -.so doc.II -.sh 2 "Miscellaneous Functions" -.so doc.III -.sh 2 Details -.so doc.IV diff --git a/share/doc/ps1/18.curses/life.c b/share/doc/ps1/18.curses/life.c deleted file mode 100644 index 6ae9f608c4dd..000000000000 --- a/share/doc/ps1/18.curses/life.c +++ /dev/null @@ -1,164 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)life.c 6.3 (Berkeley) 4/17/91 -.\" $Id: life.c,v 1.2 1993/08/01 18:23:17 mycroft Exp $ -.\" -# include -# include - -/* - * Run a life game. This is a demonstration program for - * the Screen Updating section of the -lcurses cursor package. - */ - -typedef struct lst_st { /* linked list element */ - int y, x; /* (y, x) position of piece */ - struct lst_st *next, *last; /* doubly linked */ -} LIST; - -LIST *Head; /* head of linked list */ - -int die(); - -main(ac, av) -int ac; -char *av[]; -{ - evalargs(ac, av); /* evaluate arguments */ - - initscr(); /* initialize screen package */ - signal(SIGINT, die); /* set to restore tty stats */ - cbreak(); /* set for char-by-char */ - noecho(); /* input */ - nonl(); /* for optimization */ - - getstart(); /* get starting position */ - for (;;) { - prboard(); /* print out current board */ - update(); /* update board position */ - } -} - -/* - * This is the routine which is called when rubout is hit. - * It resets the tty stats to their original values. This - * is the normal way of leaving the program. - */ -die() -{ - signal(SIGINT, SIG_IGN); /* ignore rubouts */ - mvcur(0, COLS - 1, LINES - 1, 0); /* go to bottom of screen */ - endwin(); /* set terminal to good state */ - exit(0); -} - -/* - * Get the starting position from the user. They keys u, i, o, j, l, - * m, ,, and . are used for moving their relative directions from the - * k key. Thus, u move diagonally up to the left, , moves directly down, - * etc. x places a piece at the current position, " " takes it away. - * The input can also be from a file. The list is built after the - * board setup is ready. - */ -getstart() -{ - reg char c; - reg int x, y; - auto char buf[100]; - - box(stdscr, '|', '_'); /* box in the screen */ - move(1, 1); /* move to upper left corner */ - - for (;;) { - refresh(); /* print current position */ - if ((c = getch()) == 'q') - break; - switch (c) { - case 'u': - case 'i': - case 'o': - case 'j': - case 'l': - case 'm': - case ',': - case '.': - adjustyx(c); - break; - case 'f': - mvaddstr(0, 0, "File name: "); - getstr(buf); - readfile(buf); - break; - case 'x': - addch('X'); - break; - case ' ': - addch(' '); - break; - } - } - - if (Head != NULL) /* start new list */ - dellist(Head); - Head = malloc(sizeof (LIST)); - - /* - * loop through the screen looking for 'x's, and add a list - * element for each one - */ - for (y = 1; y < LINES - 1; y++) - for (x = 1; x < COLS - 1; x++) { - move(y, x); - if (inch() == 'x') - addlist(y, x); - } -} - -/* - * Print out the current board position from the linked list - */ -prboard() { - - reg LIST *hp; - - erase(); /* clear out last position */ - box(stdscr, '|', '_'); /* box in the screen */ - - /* - * go through the list adding each piece to the newly - * blank board - */ - for (hp = Head; hp; hp = hp->next) - mvaddch(hp->y, hp->x, 'X'); - - refresh(); -} diff --git a/share/doc/ps1/18.curses/macros b/share/doc/ps1/18.curses/macros deleted file mode 100644 index 2634451095db..000000000000 --- a/share/doc/ps1/18.curses/macros +++ /dev/null @@ -1,110 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)macros 6.3 (Berkeley) 4/17/91 -.\" -.\" this is the uncommented version. The commented one is in "macros.coms" -.ie t .ds _ \d\(mi\u -.el .ds _ _ -.ds , ,\ -.ds y (y\*,x) co-ordinates -.ds db database -.ie n .ds f \fI -.el .ds f \fB -.ds tc \*ftermcap\fP(5) -.ds Es This returns ERR if it would cause the screen to scroll illegally. -.ds Nm This has no associated \*(lq\fBmv\fP\*(rq command. -.ie t .ds m \fB\s-2\(dg\s+2\fP -.el .ds m [*] -.hy WINDOW -.\".he ''\*(Ln'' -.\".fo ''\- % \-'' -.oh '\*(Ln''PS1:18-%' -.eh 'PS1:18-%''\*(Ln' -.de Un -.b -\s-2\\$2UNIX\\$1\s+2 -.ft -.. -.de Ds -.sp -.lp -.ev 1 -.nf -.ft I -.in 0 -.di Df -.. -.de De -.di -.ne \n(dn+2 -.Df -.ev -.ip -.. -.de Fd -.br -\&\\$4 -.fi -.b -\&\\$1(\\$2) -.ft -\&\\$3 -.br -.nf -.. -.de Vn -\&\\$3\c -.i "\\$1" \\$2 -.. -.de Fn -\&\\$3\c -.i "\\$1(\\$4)" \\$2 -.. -.de Bq -.ie t \&\*(lq\fB\\$1\fP\*(rq -.el \&\*(lq\fI\\$1\fP\*(rq -.. -.de $0 -.(x -.in \\n(Xs -\\*($n \\$1 -.)x -.. -.de $1 -.nr Xs 0 -.. -.de $2 -.nr Xs 3 -.. -.de $3 -.nr Xs 6 -.. diff --git a/share/doc/ps1/18.curses/twinkle1.c b/share/doc/ps1/18.curses/twinkle1.c deleted file mode 100644 index 6fbd85f4a8b4..000000000000 --- a/share/doc/ps1/18.curses/twinkle1.c +++ /dev/null @@ -1,158 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)twinkle1.c 6.3 (Berkeley) 4/17/91 -.\" $Id: twinkle1.c,v 1.2 1993/08/01 18:23:15 mycroft Exp $ -.\" -# include -# include - -/* - * the idea for this program was a product of the imagination of - * Kurt Schoens. Not responsible for minds lost or stolen. - */ - -# define NCOLS 80 -# define NLINES 24 -# define MAXPATTERNS 4 - -typedef struct { - int y, x; -} LOCS; - -LOCS Layout[NCOLS * NLINES]; /* current board layout */ - -int Pattern, /* current pattern number */ - Numstars; /* number of stars in pattern */ - -char *getenv(); - -int die(); - -main() -{ - srand(getpid()); /* initialize random sequence */ - - initscr(); - signal(SIGINT, die); - noecho(); - nonl(); - leaveok(stdscr, TRUE); - scrollok(stdscr, FALSE); - - for (;;) { - makeboard(); /* make the board setup */ - puton('*'); /* put on '*'s */ - puton(' '); /* cover up with ' 's */ - } -} - -/* - * On program exit, move the cursor to the lower left corner by - * direct addressing, since current location is not guaranteed. - * We lie and say we used to be at the upper right corner to guarantee - * absolute addressing. - */ -die() -{ - signal(SIGINT, SIG_IGN); - mvcur(0, COLS - 1, LINES - 1, 0); - endwin(); - exit(0); -} - - -/* - * Make the current board setup. It picks a random pattern and - * calls ison() to determine if the character is on that pattern - * or not. - */ -makeboard() -{ - reg int y, x; - reg LOCS *lp; - - Pattern = rand() % MAXPATTERNS; - lp = Layout; - for (y = 0; y < NLINES; y++) - for (x = 0; x < NCOLS; x++) - if (ison(y, x)) { - lp->y = y; - lp->x = x; - lp++; - } - Numstars = lp - Layout; -} - -/* - * Return TRUE if (y, x) is on the current pattern. - */ -ison(y, x) -reg int y, x; { - - switch (Pattern) { - case 0: /* alternating lines */ - return !(y & 01); - case 1: /* box */ - if (x >= LINES && y >= NCOLS) - return FALSE; - if (y < 3 || y >= NLINES - 3) - return TRUE; - return (x < 3 || x >= NCOLS - 3); - case 2: /* holy pattern! */ - return ((x + y) & 01); - case 3: /* bar across center */ - return (y >= 9 && y <= 15); - } - /* NOTREACHED */ -} - -puton(ch) -reg char ch; -{ - reg LOCS *lp; - reg int r; - reg LOCS *end; - LOCS temp; - - end = &Layout[Numstars]; - for (lp = Layout; lp < end; lp++) { - r = rand() % Numstars; - temp = *lp; - *lp = Layout[r]; - Layout[r] = temp; - } - - for (lp = Layout; lp < end; lp++) { - mvaddch(lp->y, lp->x, ch); - refresh(); - } -} diff --git a/share/doc/ps1/18.curses/twinkle2.c b/share/doc/ps1/18.curses/twinkle2.c deleted file mode 100644 index 450cec0b50b3..000000000000 --- a/share/doc/ps1/18.curses/twinkle2.c +++ /dev/null @@ -1,97 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)twinkle2.c 6.3 (Berkeley) 4/17/91 -.\" $Id: twinkle2.c,v 1.2 1993/08/01 18:23:14 mycroft Exp $ -.\" -extern int _putchar(); - -main() -{ - reg char *sp; - - srand(getpid()); /* initialize random sequence */ - - if (isatty(0)) { - gettmode(); - if ((sp = getenv("TERM")) != NULL) - setterm(sp); - signal(SIGINT, die); - } - else { - printf("Need a terminal on %d\n", _tty_ch); - exit(1); - } - _puts(TI); - _puts(VS); - - noecho(); - nonl(); - tputs(CL, NLINES, _putchar); - for (;;) { - makeboard(); /* make the board setup */ - puton('*'); /* put on '*'s */ - puton(' '); /* cover up with ' 's */ - } -} - -puton(ch) -char ch; -{ - reg LOCS *lp; - reg int r; - reg LOCS *end; - LOCS temp; - static int lasty, lastx; - - end = &Layout[Numstars]; - for (lp = Layout; lp < end; lp++) { - r = rand() % Numstars; - temp = *lp; - *lp = Layout[r]; - Layout[r] = temp; - } - - for (lp = Layout; lp < end; lp++) - /* prevent scrolling */ - if (!AM || (lp->y < NLINES - 1 || lp->x < NCOLS - 1)) { - mvcur(lasty, lastx, lp->y, lp->x); - putchar(ch); - lasty = lp->y; - if ((lastx = lp->x + 1) >= NCOLS) - if (AM) { - lastx = 0; - lasty++; - } - else - lastx = NCOLS - 1; - } -} diff --git a/share/doc/ps1/18.curses/win_st.c b/share/doc/ps1/18.curses/win_st.c deleted file mode 100644 index 21c1f3f6c3fd..000000000000 --- a/share/doc/ps1/18.curses/win_st.c +++ /dev/null @@ -1,59 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)win_st.c 6.3 (Berkeley) 4/17/91 -.\" $Id: win_st.c,v 1.2 1993/08/01 18:23:13 mycroft Exp $ -.\" -# define WINDOW struct _win_st - -struct _win_st { - short _cury, _curx; - short _maxy, _maxx; - short _begy, _begx; - short _flags; - short _ch_off; - bool _clear; - bool _leave; - bool _scroll; - char **_y; - short *_firstch; - short *_lastch; - struct _win_st *_nextp, *_orig; -}; - -# define _ENDLINE 001 -# define _FULLWIN 002 -# define _SCROLLWIN 004 -# define _FLUSH 010 -# define _FULLLINE 020 -# define _IDLINE 040 -# define _STANDOUT 0200 -# define _NOCHANGE -1 diff --git a/share/doc/smm/02.config/spell.ok b/share/doc/smm/02.config/spell.ok deleted file mode 100644 index 41324523022f..000000000000 --- a/share/doc/smm/02.config/spell.ok +++ /dev/null @@ -1,306 +0,0 @@ -ACC -ANSEL -ARP -Autoconfiguration -BUFPAGES -CANTWAIT -CH -COMPAT -CSS -Co -Config -Config''SMM:2 -DCLR -DFLDSIZ -DFLSSIZ -DFUNNY -DHAHA -DMA -Dev -Dquot -ECC -EMULEX -Emulex -Ethernet -FPNUMBER -FUNNY,HAHA -HAVEBDP -ICMP -IDP -IE -INET -IP -IPC -IPFORWARDING -IPL -IPSENDREDIRECTS -Info -Karels -LH -Leffler -MAKEDEV -MAKEDEV.local -MASSBUS -MAXDSIZ -MAXTSIZ -Makefile -Mb -MicroVAX -Mkopt -Mkoption -NBUF -NEED16 -NEEDBDP -NINODE -NMOUNT -NOFILE -NPROC -NS -NSC -NSIP -NUP -PST -RCS -RDY -RH -RK07 -RK611 -SCCS -SITENAME -SMM:2 -SUBNETSARELOCAL -SYSPTSIZE -TCP -THREEWAYSHAKE -Timezone -UCBVAX -UDP -UNIBUS -UPAGES -UPCS2 -USRPTSIZE -VAX -VAX630 -VAX730 -VAX750 -VAX780 -VAX8600 -VAXWELL -VAXen -Vax -Vaxwell -acc0 -accrint -accxint -addr -arg -args -assym.s -autoconfiguration -autoconfigure -autoconfigured -backpointer -badaddr -blkno -br -br5 -buf -bufpages -buses -caddr -callout -catchall -cmap.h -cmd -conf -conf.c -config -csr -ct.c -ctlr -cvec -datagrams -define''s -dev -devices.machine -dgo -dh.c -dh0 -dh1 -dh2 -dhreg.h -dhrint -dhxint -dinfo -dk -dk.h -dm0 -dmintr -dname -dquot -dst -dumpdev -dumplo -dumpmagic -dumpsize -dz.c -dz0 -dzrint -dzxint -ec0 -eccollide -ecrint -ecxint -endif -es -files.machine -filesystem -foo -foo.c -genvmunix -gettimeofday -gigabytes -gprof -hardwired -hd -hk -hk0 -hkvmunix -howmany -hp0 -hp0b -hp1 -hp2 -hp3 -hpvmunix -ht0 -hz -ident -ifdef -ifndef -il0 -ilcint -ilrint -info -intr -ioconf.c -kgmon -linterrs -loopback -machdep.c -machparam.h -makefile -makelinks -makeoptions -maxusers -mba -mba0 -mba1 -mbuf.h -mcount.c -memsize -minfo -mname -moniker -mspw -nbuf -ncallout -nclist -ndquot -ndrive -netimp -netinet -netns -netstat -nexi -nexus -nfile -ninode -nmbclusters -nnn.ddd -nproc -nquota -nsip -ntext -optionlist -param.c -param.h -pathnames -pg -physaddr -pty -rc -reg -rk.c -rk0 -rk1 -rkintr -savecore -sc -sc0 -sc1 -scdriver -setrlimit -sizeof -softc -source.c -subr -swapxxx.c -sysname -te0 -te1 -timezone -tm0 -tmintr -tu0 -uba -uba.c -uba0 -ubago -uballoc -ubamem -ubanum -ubareg.h -ubarelse -ubavar.h -ubglue.s -ubinfo -ud -ui -um -up.c -up0 -up1 -up2 -upaddr -upattach -upba -upcs1 -upcs2 -updevice -updgo -updinfo -updtab -upintr -upip -upmaptype -upminfo -upprobe -upslave -upstd -upvmunix -upwatch -upwstart -value,name2 -value2 -vax -vaxif -vaxmba -vaxuba -vmparam.h -vmunix -wildcard -wildcarded -wildcarding -xclu -xxx diff --git a/share/doc/smm/11.named/manage.me b/share/doc/smm/11.named/manage.me deleted file mode 100644 index 0e659472cd56..000000000000 --- a/share/doc/smm/11.named/manage.me +++ /dev/null @@ -1,243 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)manage.me 6.9 (Berkeley) 4/22/91 -.\" -.sh 1 "Domain Management" -.pp -This section contains information for starting, -controlling and debugging \fInamed\fP. -.sh 2 /etc/rc.local -.pp -The hostname should be set to the full domain style name in \fI/etc/rc.local\fP -using \fIhostname\|(1)\fP. -The following entry should be added to \fI/etc/rc.local\fP to start -up \fInamed\fP at system boot time: -.(b l -\fIif [ -f /etc/named ]; then - /etc/named\fP [options] \fI& echo -n ' named' >/dev/console\fP -\fIfi\fP -.)b -This usually directly follows the lines that start \fIsyslogd\fP. -\fBDo Not\fP attempt to run \fInamed\fP from \fIinetd\fP. -This will -continuously restart the name server and defeat the purpose of having a cache. -.sh 2 /etc/named.pid -.pp -When \fInamed\fP is successfully started up it writes its process id -into the file \fI/etc/named.pid\fP. This is useful to programs -that want to send signals to \fInamed\fP. The name of this file may be changed -by defining \fIPIDFILE\fP to the new name when compiling \fInamed\fP. -.sh 2 /etc/hosts -.pp -The \fIgethostbyname\|()\fP library call can detect if \fInamed\fP is running. -If it is determined that \fInamed\fP is not running it will look in -\fI/etc/hosts\fP to resolve an address. -This option was added to allow \fIifconfig\|(8C)\fP to configure the machines -local interfaces and to enable a system manager to access the network -while the system is in single user mode. -It is advisable to put the local machines interface addresses and a couple of -machine names and address in -\fI/etc/hosts\fP so the system manager can rcp files from another machine -when the system is in single user mode. -The format of \fI/etc/host\fP has not changed. See \fIhosts\|(5)\fP -for more information. -Since the process of reading \fI/etc/hosts\fP is slow, -it is not advised to use this option when the system is in multi user mode. - -.sh 2 Signals -.pp -There are several signals that can be sent to the \fInamed\fP process -to have it do tasks without restarting the process. -.sh 3 Reload -.pp -SIGHUP - -Causes \fInamed\fP to read \fInamed.boot\fP and reload the database. -All previously cached data is lost. -This is useful when you have made a change to a data file -and you want \fInamed\fP\|'s internal database to reflect the change. -.sh 3 Debugging -.pp -When \fInamed\fP is running incorrectly, look first in -\fI/usr/adm/messages\fP and check for any messages logged by \fIsyslog\fP. -Next send it a signal to see what is happening. -.pp -SIGINT - -Dumps the current data base and cache to -\fI/usr/\|tmp/\|named_dump\|.\|db\fP -This should give you an indication to whether the data base was loaded -correctly. -The name of the dump file may be changed -by defining \fIDUMPFILE\fP to the new name when compiling \fInamed\fP. - -\fINote:\fP the following two signals only work when \fInamed\fP is built with -\fIDEBUG\fP defined. -.pp -SIGUSR1 - -Turns on debugging. Each following USR1 increments the debug level. -The output goes to \fI/usr/tmp/named.run\fP -The name of this debug file may be changed -by defining \fIDEBUGFILE\fP to the new name before compiling \fInamed\fP. -.pp -SIGUSR2 - -Turns off debugging completely. - -For more detailed debugging, define DEBUG when compiling the resolver -routines into \fI/lib/libc.a\fP. -.sx 0 -.sp 2 -.ce -.b ACKNOWLEDGEMENTS -.pp -Many thanks to the users at U.C. Berkeley for falling into many of the -holes involved with integrating BIND into the system so that others -would be spared the trauma. I would also like to extend gratitude to -Jim McGinness and Digital Equipment Corporation for permitting -me to spend most of my time on this project. -.pp -Ralph Campbell, Doug Kingston, Craig Partridge, Smoot Carl-Mitchell, -Mike Muuss and everyone else on the DARPA Internet who has contributed -to the development of BIND. -To the members of the original BIND project, Douglas Terry, Mark Painter, -David Riggle and Songnian Zhou. -.pp -Anne Hughes, Jim Bloom and Kirk McKusick and the many others who have -reviewed this paper giving considerable advice. -.pp -This work was sponsored by the Defense Advanced Research Projects Agency -(DoD), Arpa Order No. 4871 monitored by the Naval Electronics Systems -Command under contract No. N00039-84-C-0089. -The views and conclusions contained in this document are those of the -authors and should not be interpreted as representing official policies, -either expressed or implied, of the Defense Research Projects Agency, -of the US Government, or of Digital Equipment Corporation. -.bp -.ba 0 -.in 0 -.sp 2 -.ce -.b REFERENCES -.sp -.nr ii 1i -.ip [Birrell] -Birrell, A. D., -Levin, R., -Needham, R. M., -and Schroeder, M.D., -.q "Grapevine: An Exercise in Distributed Computing." -In -.ul -Comm. A.C.M. 25, -4:260-274 -April 1982. -.ip [RFC819] -Su, Z. -Postel, J., -.q "The Domain Naming Convention for Internet User Applications." -.ul -Internet Request For Comment 819 -Network Information Center, -SRI International, -Menlo Park, California. -August 1982. -.ip [RFC974] -Partridge, C., -.q "Mail Routing and The Domain System." -.ul -Internet Request For Comment 974 -Network Information Center, -SRI International, -Menlo Park, California. -February 1986. -.ip [RFC1032] -Stahl, M., -.q "Domain Administrators Guide" -.ul -Internet Request For Comment 1032 -Network Information Center, -SRI International, -Menlo Park, California. -November 1987. -.ip [RFC1033] -Lottor, M., -.q "Domain Administrators Guide" -.ul -Internet Request For Comment 1033 -Network Information Center, -SRI International, -Menlo Park, California. -November 1987. -.ip [RFC1034] -Mockapetris, P., -.q "Domain Names - Concept and Facilities." -.ul -Internet Request For Comment 1034 -Network Information Center, -SRI International, -Menlo Park, California. -November 1987. -.ip [RFC1035] -Mockapetris, P., -.q "Domain Names - Implementation and Specification." -.ul -Internet Request For Comment 1035 -Network Information Center, -SRI International, -Menlo Park, California. -November 1987. -.ip [RFC1101] -Mockapetris, P., -.q "DNS Encoding of Network Names and Other Types." -.ul -Internet Request For Comment 1101 -Network Information Center, -SRI International, -Menlo Park, California. -April 1989. -.ip [Terry] -Terry, D. B., -Painter, M., -Riggle, D. W., -and -Zhou, S., -.ul -The Berkeley Internet Name Domain Server. -Proceedings USENIX Summer Conference, -Salt Lake City, Utah. -June 1984, pages 23-31. -.ip [Zhou] -Zhou, S., -.ul -The Design and Implementation of the Berkeley Internet Name Domain (BIND) Servers. -UCB/CSD 84/177. -University of California, Berkeley, -Computer Science Division. -May 1984. diff --git a/share/doc/smm/11.named/named.boot.cache b/share/doc/smm/11.named/named.boot.cache deleted file mode 100644 index eafad2a7e03b..000000000000 --- a/share/doc/smm/11.named/named.boot.cache +++ /dev/null @@ -1,52 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)named.boot.cache 6.5 (Berkeley) 4/17/91 -.\" -.sh 4 "Caching Only Server" -.(b L -.TS -l. -; -; Boot file for Caching Only Name Server -; -.TE -.TS -l l l -l -l l l. -; type domain source file or host -; -directory /usr/local/domain -cache \fB.\fP root\fB.\fPcache -primary 0\fB.\fP0\fB.\fP127\fB.\fPin-addr\fB.\fParpa /etc/named\fB.\fPlocal -.TE -.)b diff --git a/share/doc/smm/11.named/named.boot.primary b/share/doc/smm/11.named/named.boot.primary deleted file mode 100644 index e45a45680c12..000000000000 --- a/share/doc/smm/11.named/named.boot.primary +++ /dev/null @@ -1,55 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)named.boot.primary 6.5 (Berkeley) 4/17/91 -.\" -.sh 3 "Boot File" -.sh 4 "Primary Master Server" -.(b L -.TS -l. -; -; Boot file for Primary Master Name Server -; -.TE -.TS -l l l -l -l l l. -; type domain source file or host -; -directory /usr/local/domain -primary Berkeley\fB.\fPEdu ucbhosts -primary 32\fB.\fP128\fB.\fPin-addr\fB.\fParpa ucbhosts\fB.\fPrev -primary 0\fB.\fP0\fB.\fP127\fB.\fPin-addr\fB.\fParpa named\fB.\fPlocal -cache \fB.\fP root\fB.\fPcache -.TE -.)b diff --git a/share/doc/smm/11.named/named.boot.secondary b/share/doc/smm/11.named/named.boot.secondary deleted file mode 100644 index 50906fc1d499..000000000000 --- a/share/doc/smm/11.named/named.boot.secondary +++ /dev/null @@ -1,54 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)named.boot.secondary 6.6 (Berkeley) 4/22/91 -.\" -.sh 4 "Secondary Master Server" -.(b L -.TS -l. -; -; Boot file for Secondary Master Name Server -; -.TE -.TS -l l l -l -l l l. -; type domain source file or host -; -directory /usr/local/domain -secondary Berkeley\fB.\fPEdu 128\fB.\fP32\fB.\fP0\fB.\fP4 128\fB.\fP32\fB.\fP0\fB.\fP10 ucbhosts.bak -secondary 32\fB.\fP128\fB.\fPin-addr\fB.\fParpa 128\fB.\fP32\fB.\fP0\fB.\fP4 128\fB.\fP32\fB.\fP0\fB.\fP10 ucbhosts.rev.bak -primary 0\fB.\fP0\fB.\fP127\fB.\fPin-addr\fB.\fParpa named\fB.\fPlocal -cache \fB.\fP root\fB.\fPcache -.TE -.)b diff --git a/share/doc/smm/11.named/named.local b/share/doc/smm/11.named/named.local deleted file mode 100644 index 45de227de762..000000000000 --- a/share/doc/smm/11.named/named.local +++ /dev/null @@ -1,48 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)named.local 6.4 (Berkeley) 4/17/91 -.\" -.sh 3 "named.local" -.(b L - -.TS -l l l l. -@ IN SOA ucbvax\fB.\fPBerkeley\fB.\fPEdu. kjd\fB.\fPucbvax\fB.\fPBerkeley\fB.\fPEdu\fB.\fP ( - 1 ; Serial - 10800 ; Refresh - 1800 ; Retry - 3600000 ; Expire - 86400 ) ; Minimum - IN NS ucbvax\fB.\fPBerkeley\fB.\fPEdu\fB.\fP -1 IN PTR localhost\fB.\fP -.TE -.)b diff --git a/share/doc/smm/11.named/resolv.conf b/share/doc/smm/11.named/resolv.conf deleted file mode 100644 index 89c57bab68b8..000000000000 --- a/share/doc/smm/11.named/resolv.conf +++ /dev/null @@ -1,43 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)resolv.conf 6.3 (Berkeley) 4/17/91 -.\" -.bp -.sh 3 "Remote Server" -.sh 4 "/etc/resolv.conf" -.(b L - -domain Berkeley\fB.\fPEdu -nameserver 128\fB.\fP32\fB.\fP0\fB.\fP4 -nameserver 128\fB.\fP32\fB.\fP0\fB.\fP10 - -.)b diff --git a/share/doc/smm/11.named/root.cache b/share/doc/smm/11.named/root.cache deleted file mode 100644 index 904872995114..000000000000 --- a/share/doc/smm/11.named/root.cache +++ /dev/null @@ -1,67 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)root.cache 6.5 (Berkeley) 4/17/91 -.\" -.sh 3 "root.cache" -.(b L - -; -; -; Initial cache data for root domain servers. -; - -.TS -l l l l l. -\fB.\fP 99999999 IN NS NS\fB.\fPNIC\fB.\fPDDN\fB.\fPMIL\fB.\fP - 99999999 IN NS NS\fB.\fPNASA\fB.\fPGOV\fB.\fP - 99999999 IN NS TERP\fB.\fPUMD\fB.\fPEDU\fB.\fP - 99999999 IN NS A\fB.\fPISI\fB.\fPEDU\fB.\fP - 99999999 IN NS AOS\fB.\fPBRL\fB.\fPMIL\fB.\fP - 99999999 IN NS GUNTER-ADAM\fB.\fPAF\fB.\fPMIL\fB.\fP - 99999999 IN NS C\fB.\fPNYSER\fB.\fPNET\fB.\fP - -.T& -l s s s s -l l l l l. -; Prep the cache (hotwire the addresses)\fB.\fP -ns\fB.\fPNIC\fB.\fPDDN\fB.\fPMIL\fB.\fP 99999999 IN A 192\fB.\fP67\fB.\fP67\fB.\fP53 -NS\fB.\fPNASA\fB.\fPGOV\fB.\fP 99999999 IN A 128\fB.\fP102\fB.\fP16\fB.\fP10 -NS\fB.\fPNASA\fB.\fPGOV\fB.\fP 99999999 IN A 192\fB.\fP52\fB.\fP195\fB.\fP10 -A\fB.\fPISI\fB.\fPEDU\fB.\fP 99999999 IN A 26\fB.\fP3\fB.\fP0\fB.\fP103 -A\fB.\fPISI\fB.\fPEDU\fB.\fP 99999999 IN A 128\fB.\fP9\fB.\fP0\fB.\fP107 -AOS\fB.\fPBRL\fB.\fPMIL\fB.\fP 99999999 IN A 128\fB.\fP20\fB.\fP1\fB.\fP2 -AOS\fB.\fPBRL\fB.\fPMIL\fB.\fP 99999999 IN A 192\fB.\fP5\fB.\fP25\fB.\fP82 -GUNTER-ADAM\fB.\fPAF\fB.\fPMIL\fB.\fP 99999999 IN A 26\fB.\fP1\fB.\fP0\fB.\fP13 -C\fB.\fPNYSER\fB.\fPNET\fB.\fP 99999999 IN A 192\fB.\fP33\fB.\fP4\fB.\fP12 -TERP\fB.\fPUMD\fB.\fPEDU\fB.\fP 99999999 IN A 128\fB.\fP8\fB.\fP10\fB.\fP90 -.TE -.)b diff --git a/share/doc/smm/11.named/setup.me b/share/doc/smm/11.named/setup.me deleted file mode 100644 index 1d80a2097d32..000000000000 --- a/share/doc/smm/11.named/setup.me +++ /dev/null @@ -1,71 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)setup.me 6.6 (Berkeley) 4/22/91 -.\" -.sh 1 "Setting up Your Own Domain" -.pp -When setting up a domain that is going to be on a public -network the site administrator should contact the organization -in charge of the network and request the appropriate domain registration form. -An organization that belongs to multiple networks (such as \fICSNET\fP, -\fIDARPA Internet\fP and \fIBITNET\fP) should register with only one network. - -The contacts are as follows: -.sh 2 "DARPA Internet" -.pp -Sites that are already on the DARPA Internet and need information on -setting up a domain should contact HOSTMASTER@NIC\fB\|.\|\fPDDN\fB\|.\|\fPMIL\fB\|.\fP -You may also want to be placed on the BIND mailing list, -which is a mail group for people on the DARPA Internet running BIND. -The group discusses future design decisions, operational problems, -and other related topics. -The address to request being placed on this mailing list is: -.(b l -\fIbind-request\|@\|ucbarpa\fP\fB\|.\|\fP\fIBerkeley\fP\fB\|.\|\fP\fIEDU\fP\fB.\fP -.)b -.sh 2 CSNET -.pp -A \fICSNET\fP member organization that has not registered its domain -name should contact the \fICSNET\fP Coordination and Information Center -(\fICIC\fP) for an application and information about setting up a domain. -.pp -An organization that already has a registered domain name should -keep the \fICIC\fP informed about how it would like its mail routed. In -general, the \fICSNET\fP relay will prefer to send mail via \fICSNET\fP (as -opposed to \fIBITNET\fP or the \fIInternet\fP) if possible. -For an organization on multiple networks, this may not always be the -preferred behavior. -The \fICIC\fP can be reached via electronic mail at -\fIcic\|@\|sh\fP\fB\|.\|\fP\fIcs\fP\fB\|.\|\fP\fInet\fP, or by phone at (617) 873-2777. -.sh 2 BITNET -.pp -If you are on the BITNET and need to set up a domain, contact INFO@BITNIC. diff --git a/share/doc/smm/11.named/spell.ok b/share/doc/smm/11.named/spell.ok deleted file mode 100644 index 334cf5874f02..000000000000 --- a/share/doc/smm/11.named/spell.ok +++ /dev/null @@ -1,161 +0,0 @@ -A.C.M -AF -AOS -AU -Arpa -BIND''SMM:11 -BITNIC -BOOTFILE -BRL -Birrell -CIC -CNAME -COM -CS -CSD -CSRG -CSS -Com -DDD -DDN -DEBUGFILE -DNS -DUMPFILE -DoD -EDU -Edu -GOV -GUNTER -HINFO -HOSTLOOKUP -HOSTMASTER -IP -ISI -Karels -Lottor -M.D -MB -MG -MIL -MINFO -MX -Makefile -Masterfile -McGinness -McKusick -Mockapetris -Munnari -Muuss -NIC -NYSER -OS -OZ -PIDFILE -PTR -Postel -Postmistress -Pro350 -RELAY.CS.NET -RFC1032 -RFC1033 -RFC1034 -RFC1035 -RFC819 -RFC974 -RR -RR's -RT11 -Riggle -SIGHUP -SIGINT -SIGUSR1 -SIGUSR2 -SMM:11 -SOA -Seismo -Smoot -Songnian -TCP -TERP -U.C -UCB -UDP -UMD -USENIX -USR1 -Ultrix -VAX -WKS -Wildcard -Zhou -adm -aka -arpa -auth -berkeley -bi -bootfile -chargen -cic -conf -cs -csdiv -db -dev -doc -ernie -fi -filename -host.rev -hosts.rev -hotwire -ifconfg -kjd -lib -libc -libc.a -localhost -loopback -meta -miriam -monet -monet.Berkeley.Edu -mtp -named.boot -named.local -named.pid -named.run -nameserver -nameservers -nic.ddn.mil -nntp -nr -postmistress -qotd -rc.local -resolv -resolv.conf -rje -root.cache -sftp -si -smtp -src -sunrpc -supdup -tmp -toybox -ttl -ucb -ucbarpa -ucbernie -ucbhosts -ucbhosts.bak -ucbhosts.rev.bak -ucbmonet -ucbvax -vax -vineyd -vineyd.DEC.COM -wildcard -wildcarding diff --git a/share/doc/smm/11.named/types.me b/share/doc/smm/11.named/types.me deleted file mode 100644 index 3b7e9f9f31eb..000000000000 --- a/share/doc/smm/11.named/types.me +++ /dev/null @@ -1,100 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)types.me 6.5 (Berkeley) 4/17/91 -.\" -.sh 1 "Types of Servers" -.pp -There are several types of servers: Master, Caching, Remote, and Slave. -.sh 2 "Master Servers" -.pp -A Master Server for a domain is the authority for that domain. -This server maintains all the data corresponding to its domain. -Each domain should have at least two master servers, a primary master and -some secondary masters to provide backup service if the primary -is unavailable or overloaded. -A server may be a master for multiple domains, being primary for -some domains and secondary for others. -.sh 3 Primary -.pp -A Primary Master Server is a server that loads its data from a file on disk. -This server may also delegate authority to other servers in its domain. -.sh 3 Secondary -.pp -A Secondary Master Server is a server that is delegated authority and receives -its data for a domain from a primary master server. -At boot time, the secondary server requests -all the data for the given zone from the primary master server. -This server then periodically checks with the primary server to see -if it needs to update its data. -.sh 2 "Caching Only Server" -.pp -All servers are caching servers. This means that the server -caches the information that it receives for use until the data expires. -A \fICaching Only Server\fP is a server that is not authoritative for any domain. -This server services queries and asks other servers, -who have the authority, for the information needed. -All servers keep data in their cache until the data expires, -based on a time to live field attached to the data when it is received -from another server. -.sh 2 "Remote Server" -.pp -A Remote Server is an option given to people who would like to use -a name server on their workstation or on a machine that has a limited -amount of memory and CPU cycles. -With this option you can run all of the networking programs that use -the name server without the name server running on the local machine. -All of the queries are serviced by a name server that is running on another -machine on the network. -.sh 2 "Slave Server" -.pp -A Slave Server is a server that always forwards queries it cannot -satisfy locally to a fixed list of \fIforwarding\fP servers -instead of interacting -with the master nameservers for the root and other domains. -The queries to the \fIforwarding servers\fP are recursive queries. -There may be one or more forwarding servers, and they are tried in turn -until the list is exhausted. -A Slave and forwarder configuration is typically used when you do not -wish all the servers at a give site to be interacting with the rest -of the Internet servers. A typically scenario would involve a number of -workstations and a departmental timesharing machine with Internet -access. The workstations might be -administratively prohibited from having Internet access. -To give the workstations the appearance of access to the Internet -domain system, the workstations could be Slave servers to the timesharing -machine which would forward the queries and interact with other -nameservers to resolve the query before returning the answer. -An added benefit of using the forwarding feature is that the central -machine develops a much more complete cache of information that -all the workstations can take advantage of. Slave mode -and forwarding is discussed further under the description of -the named bootfile commands. diff --git a/share/doc/smm/11.named/ucbhosts b/share/doc/smm/11.named/ucbhosts deleted file mode 100644 index da3773f06a6e..000000000000 --- a/share/doc/smm/11.named/ucbhosts +++ /dev/null @@ -1,90 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ucbhosts 6.4 (Berkeley) 4/17/91 -.\" -.bp -.sh 3 "Hosts" -.(b L -; -; @(#)ucb-hosts 1.2 (berkeley) 88/02/05 -; -.TS -l l l l s. -@ IN SOA ucbvax\fB.\fPBerkeley\fB.\fPEdu\fB.\fP kjd\fB.\fPmonet\fB.\fPBerkeley\fB.\fPEdu\fB.\fP ( - 1\fB.\fP2 ; Serial - 10800 ; Refresh - 1800 ; Retry - 3600000 ; Expire - 86400 ) ; Minimum - IN NS ucbarpa\fB.\fPBerkeley\fB.\fPEdu\fB.\fP - IN NS ucbvax\fB.\fPBerkeley\fB.\fPEdu\fB.\fP -localhost IN A 127\fB.\fP1 -ucbarpa IN A 128\fB.\fP32\fB.\fP4 - IN A 10\fB.\fP0\fB.\fP0\fB.\fP78 - IN HINFO VAX-11/780 UNIX -arpa IN CNAME ucbarpa -ernie IN A 128\fB.\fP32\fB.\fP6 - IN HINFO VAX-11/780 UNIX -ucbernie IN CNAME ernie -monet IN A 128\fB.\fP32\fB.\fP7 - IN A 128\fB.\fP32\fB.\fP130\fB.\fP6 - IN HINFO VAX-11/750 UNIX -ucbmonet IN CNAME monet -ucbvax IN A 10\fB.\fP2\fB.\fP0\fB.\fP78 - IN A 128\fB.\fP32\fB.\fP10 - IN HINFO VAX-11/750 UNIX - IN WKS 128\fB.\fP32\fB.\fP0\fB.\fP10 UDP syslog route timed domain - IN WKS 128\fB.\fP32\fB.\fP0\fB.\fP10 TCP ( echo telnet - discard sunrpc sftp - uucp-path systat daytime - netstat qotd nntp - link chargen ftp - auth time whois mtp - pop rje finger smtp - supdup hostnames - domain - nameserver ) -vax IN CNAME ucbvax -toybox IN A 128\fB.\fP32\fB.\fP131\fB.\fP119 - IN HINFO Pro350 RT11 -toybox IN MX 0 monet.Berkeley.Edu -miriam IN MB vineyd.DEC.COM. -postmistress IN MR Miriam -Bind IN MINFO Bind-Request kjd\fB\|.\|\fPBerkeley\fB\|.\|\fPEdu\fB\|.\fP - IN MG Ralph\fB\|.\|\fPBerkeley\fB\|.\|\fPEdu\fB\|.\fP - IN MG Zhou\fB\|.\|\fPBerkeley\fB\|.\|\fPEdu\fB\|.\fP - IN MG Painter\fB\|.\|\fPBerkeley\fB\|.\|\fPEdu\fB\|.\fP - IN MG Riggle\fB\|.\|\fPBerkeley\fB\|.\|\fPEdu\fB\|.\fP - IN MG Terry\fB\|.\|\fPpa\fB\|.\|\fPXerox\fB\|.\|\fPCom\fB\|.\fP -.TE -.)b -.bp diff --git a/share/doc/smm/11.named/ucbhosts.rev b/share/doc/smm/11.named/ucbhosts.rev deleted file mode 100644 index 67cd459aba67..000000000000 --- a/share/doc/smm/11.named/ucbhosts.rev +++ /dev/null @@ -1,62 +0,0 @@ -.\" Copyright (c) 1986, 1988 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ucbhosts.rev 6.4 (Berkeley) 4/17/91 -.\" -.sh 3 "host.rev" -.(b L - -; -; @(#)ucb-hosts.rev 1.1 (Berkeley) 86/02/05 -; -.TS -l l l l s. -@ IN SOA ucbvax\fB.\fPBerkeley\fB.\fPEdu\fB.\fP kjd\fB.\fPmonet\fB.\fPBerkeley\fB.\fPEdu\fB.\fP ( - 1\fB.\fP1 ; Serial - 10800 ; Refresh - 1800 ; Retry - 3600000 ; Expire - 86400 ) ; Minimum - IN NS ucbarpa\fB.\fPBerkeley\fB.\fPEdu\fB.\fP - IN NS ucbvax\fB.\fPBerkeley\fB.\fPEdu\fB.\fP -0\fB.\fP0 IN PTR Berkeley-net\fB.\fPBerkeley\fB.\fPEDU\fB.\fP - IN A 255\fB.\fP255\fB.\fP255\fB.\fP0 -0\fB.\fP130 IN PTR csdiv-net\fB.\fPBerkeley\fB.\fPEDU\fB.\fP -4\fB.\fP0 IN PTR ucbarpa\fB.\fPBerkeley\fB.\fPEdu\fB.\fP -6\fB.\fP0 IN PTR ernie\fB.\fPBerkeley\fB.\fPEdu\fB.\fP -7\fB.\fP0 IN PTR monet\fB.\fPBerkeley\fB.\fPEdu\fB.\fP -10\fB.\fP0 IN PTR ucbvax\fB.\fPBerkeley\fB.\fPEdu\fB.\fP -6\fB.\fP130 IN PTR monet\fB.\fPBerkeley\fB.\fPEdu\fB.\fP -.TE -.)b - - - diff --git a/share/doc/smm/15.net/d.t b/share/doc/smm/15.net/d.t deleted file mode 100644 index 7c93cf340f07..000000000000 --- a/share/doc/smm/15.net/d.t +++ /dev/null @@ -1,73 +0,0 @@ -.\" Copyright (c) 1983, 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)d.t 6.5 (Berkeley) 4/17/91 -.\" -.nr H2 1 -.\".ds RH "Out of band data -.br -.ne 2i -.NH -\s+2Out of band data\s0 -.PP -Out of band data is a facility peculiar to the stream socket -abstraction defined. Little agreement appears to exist as -to what its semantics should be. TCP defines the notion of -``urgent data'' as in-line, while the NBS protocols [Burruss81] -and numerous others provide a fully independent logical -transmission channel along which out of band data is to be -sent. -In addition, the amount of the data which may be sent as an out -of band message varies from protocol to protocol; everything -from 1 bit to 16 bytes or more. -.PP -A stream socket's notion of out of band data has been defined -as the lowest reasonable common denominator (at least reasonable -in our minds); -clearly this is subject to debate. Out of band data is expected -to be transmitted out of the normal sequencing and flow control -constraints of the data stream. A minimum of 1 byte of out of -band data and one outstanding out of band message are expected to -be supported by the protocol supporting a stream socket. -It is a protocol's prerogative to support larger-sized messages, or -more than one outstanding out of band message at a time. -.PP -Out of band data is maintained by the protocol and is usually not -stored in the socket's receive queue. -A socket-level option, SO_OOBINLINE, -is provided to force out-of-band data to be placed in the normal -receive queue when urgent data is received; -this sometimes amelioriates problems due to loss of data -when multiple out-of-band -segments are received before the first has been passed to the user. -The PRU_SENDOOB and PRU_RCVOOB -requests to the \fIpr_usrreq\fP routine are used in sending and -receiving data. diff --git a/share/doc/smm/15.net/e.t b/share/doc/smm/15.net/e.t deleted file mode 100644 index 05bad943bb2c..000000000000 --- a/share/doc/smm/15.net/e.t +++ /dev/null @@ -1,129 +0,0 @@ -.\" Copyright (c) 1983, 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)e.t 6.5 (Berkeley) 4/17/91 -.\" -.nr H2 1 -.\".ds RH "Trailer protocols -.br -.ne 2i -.NH -\s+2Trailer protocols\s0 -.PP -Core to core copies can be expensive. -Consequently, a great deal of effort was spent -in minimizing such operations. The VAX architecture -provides virtual memory hardware organized in -page units. To cut down on copy operations, data -is kept in page-sized units on page-aligned -boundaries whenever possible. This allows data -to be moved in memory simply by remapping the page -instead of copying. The mbuf and network -interface routines perform page table manipulations -where needed, hiding the complexities of the VAX -virtual memory hardware from higher level code. -.PP -Data enters the system in two ways: from the user, -or from the network (hardware interface). When data -is copied from the user's address space -into the system it is deposited in pages (if sufficient -data is present). -This encourages the user to transmit information in -messages which are a multiple of the system page size. -.PP -Unfortunately, performing a similar operation when taking -data from the network is very difficult. -Consider the format of an incoming packet. A packet -usually contains a local network header followed by -one or more headers used by the high level protocols. -Finally, the data, if any, follows these headers. Since -the header information may be variable length, DMA'ing the eventual -data for the user into a page aligned area of -memory is impossible without -\fIa priori\fP knowledge of the format (e.g., by supporting -only a single protocol header format). -.PP -To allow variable length header information to -be present and still ensure page alignment of data, -a special local network encapsulation may be used. -This encapsulation, termed a \fItrailer protocol\fP [Leffler84], -places the variable length header information after -the data. A fixed size local network -header is then prepended to the resultant packet. -The local network header contains the size of the -data portion (in units of 512 bytes), and a new \fItrailer protocol -header\fP, inserted before the variable length -information, contains the size of the variable length -header information. The following trailer -protocol header is used to store information -regarding the variable length protocol header: -.DS -._f -struct { - short protocol; /* original protocol no. */ - short length; /* length of trailer */ -}; -.DE -.PP -The processing of the trailer protocol is very -simple. On output, the local network header indicates that -a trailer encapsulation is being used. -The header also includes an indication -of the number of data pages present before the trailer -protocol header. The trailer protocol header is -initialized to contain the actual protocol identifier and the -variable length header size, and is appended to the data -along with the variable length header information. -.PP -On input, the interface routines identify the -trailer encapsulation -by the protocol type stored in the local network header, -then calculate the number of -pages of data to find the beginning of the trailer. -The trailing information is copied into a separate -mbuf and linked to the front of the resultant packet. -.PP -Clearly, trailer protocols require cooperation between -source and destination. In addition, they are normally -cost effective only when sizable packets are used. The -current scheme works because the local network encapsulation -header is a fixed size, allowing DMA operations -to be performed at a known offset from the first data page -being received. Should the local network header be -variable length this scheme fails. -.PP -Statistics collected indicate that as much as 200Kb/s -can be gained by using a trailer protocol with -1Kbyte packets. The average size of the variable -length header was 40 bytes (the size of a -minimal TCP/IP packet header). If hardware -supports larger sized packets, even greater gains -may be realized. diff --git a/share/doc/smm/15.net/f.t b/share/doc/smm/15.net/f.t deleted file mode 100644 index ea4ed355aca1..000000000000 --- a/share/doc/smm/15.net/f.t +++ /dev/null @@ -1,117 +0,0 @@ -.\" Copyright (c) 1983, 1986 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)f.t 6.5 (Berkeley) 4/17/91 -.\" -.nr H2 1 -.\".ds RH Acknowledgements -.br -.ne 2i -.SH -\s+2Acknowledgements\s0 -.PP -The internal structure of the system is patterned -after the Xerox PUP architecture [Boggs79], while in certain -places the Internet -protocol family has had a great deal of influence in the design. -The use of software interrupts for process invocation -is based on similar facilities found in -the VMS operating system. -Many of the -ideas related to protocol modularity, memory management, and network -interfaces are based on Rob Gurwitz's TCP/IP implementation for the -4.1BSD version of UNIX on the VAX [Gurwitz81]. -Greg Chesson explained his use of trailer encapsulations in Datakit, -instigating their use in our system. -.\".ds RH References -.nr H2 1 -.sp 2 -.ne 2i -.SH -\s+2References\s0 -.LP -.IP [Boggs79] 20 -Boggs, D. R., J. F. Shoch, E. A. Taft, and R. M. Metcalfe; -\fIPUP: An Internetwork Architecture\fP. Report CSL-79-10. -XEROX Palo Alto Research Center, July 1979. -.IP [BBN78] 20 -Bolt Beranek and Newman; -Specification for the Interconnection of Host and IMP. -BBN Technical Report 1822. May 1978. -.IP [Cerf78] 20 -Cerf, V. G.; The Catenet Model for Internetworking. -Internet Working Group, IEN 48. July 1978. -.IP [Clark82] 20 -Clark, D. D.; Window and Acknowledgement Strategy in TCP, RFC-813. -Network Information Center, SRI International. July 1982. -.IP [DEC80] 20 -Digital Equipment Corporation; \fIDECnet DIGITAL Network -Architecture \- General Description\fP. Order No. -AA-K179A-TK. October 1980. -.IP [Gurwitz81] 20 -Gurwitz, R. F.; VAX-UNIX Networking Support Project \- Implementation -Description. Internetwork Working Group, IEN 168. -January 1981. -.IP [ISO81] 20 -International Organization for Standardization. -\fIISO Open Systems Interconnection \- Basic Reference Model\fP. -ISO/TC 97/SC 16 N 719. August 1981. -.IP [Joy86] 20 -Joy, W.; Fabry, R.; Leffler, S.; McKusick, M.; and Karels, M.; -Berkeley Software Architecture Manual, 4.3BSD Edition. -\fIUNIX Programmer's Supplementary Documents\fP, Vol. 1 (PS1:6). -Computer Systems Research Group, -University of California, Berkeley. -May, 1986. -.IP [Leffler84] 20 -Leffler, S.J. and Karels, M.J.; Trailer Encapsulations, RFC-893. -Network Information Center, SRI International. -April 1984. -.IP [Postel80] 20 -Postel, J. User Datagram Protocol, RFC-768. -Network Information Center, SRI International. May 1980. -.IP [Postel81a] 20 -Postel, J., ed. Internet Protocol, RFC-791. -Network Information Center, SRI International. September 1981. -.IP [Postel81b] 20 -Postel, J., ed. Transmission Control Protocol, RFC-793. -Network Information Center, SRI International. September 1981. -.IP [Postel81c] 20 -Postel, J. Internet Control Message Protocol, RFC-792. -Network Information Center, SRI International. September 1981. -.IP [Xerox81] 20 -Xerox Corporation. \fIInternet Transport Protocols\fP. -Xerox System Integration Standard 028112. December 1981. -.IP [Zimmermann80] 20 -Zimmermann, H. OSI Reference Model \- The ISO Model of -Architecture for Open Systems Interconnection. -\fIIEEE Transactions on Communications\fP. Com-28(4); 425-432. -April 1980. diff --git a/share/doc/smm/15.net/spell.ok b/share/doc/smm/15.net/spell.ok deleted file mode 100644 index f9a387bc75d8..000000000000 --- a/share/doc/smm/15.net/spell.ok +++ /dev/null @@ -1,307 +0,0 @@ -A,1986A -AA -ACCEPTCONN -ADDR -ARPANET -ASYNC -BBN -BBN78 -Beranek -Boggs -Boggs78 -Boggs79 -Burruss81 -CANTRCVMORE -CANTSENDMORE -CLSIZE -COLL -CONNECT2 -CONNREQUIRED -COPYALL -CSL -Catenet -Cerf -Cerf78 -Chesson -Clark82 -Com -DEC80 -DECnet -DEQUEUE -DEQUEUEIF -DETATCH -DMA -DMA'ing -DMR -DONTWAIT -Datagram -Datakit -EGP -EWOULDBLOCK -Ethernet -FADDR -FASTTIMO -Fabry -GETOPT -Gurwitz -Gurwitz's -Gurwitz81 -HASCL -HOSTDEAD -HOSTUNREACH -ICMP -IEN -IFDOWN -IFF -IFRW -INTRANS -IP -IP's -ISCONNECTED -ISCONNECTING -ISDISCONNECTING -ISO -ISO81 -Ircb -Joy86 -K179A -Karels -LADDR -LOOPBACK -Leffler -Leffler84 -M.J -MAXNUBAMR -MCLGET -MFREE -MGET -MLEN -MSG -MSGSIZE -MSIZE -Mbufs -McKusick -Metcalfe -NBIO -NEEDFRAG -NOARP -NOFDREF -NOTRAILERS -NS -Notes''SMM:15 -OOBINLINE -OSI -PARAMPROB -PEERADDR -PF -POINTOPOINT -PRC -PRCO -PRIV -PROTORCV -PROTOSEND -PRU -PS1:6 -Postel -Postel80 -Postel81a -Postel81b -Postel81c -QFULL -RCVATMARK -RCVD -RCVOOB -RFC -RH -ROUTEDEAD -RTF -S.J -SB -SEL -SENDOOB -SETOPT -SIGIO -SIOCADDRT -SIOCDELRT -SIOCGIFCONF -SIOCSIFADDR -SIOCSIFDSTADDR -SIOCSIFFLAGS -SIOGSIFFLAGS -SLOWTIMO -SMM:15 -SOCKADDR -SRCFAIL -SS -Shoch -TCP -TIMXCEED -TOSHOST -TOSNET -UDP -UNIBUS -VAX -VMS -Vol -WANTRCVD -Xerox81 -Xerox82 -Zimmermann -Zimmermann80 -addr -addrlist -adj -amelioriates -async -bdp -broadaddr -caddr -csma -ctlinput -ctloutput -daemon -dat -datagram -decapsulation -dequeuing -dev -dma'd -dom -dst -dstaddr -dtom -faddr -fastimo -fasttimo -fcntl -freem -fstat -getsockopt -hardwired -hiwat -hlen -ierrors -ifa -ifaddr -iff -ifnet -ifp -ifq -ifqueue -ifr -ifrw -ifrw.ifrw -ifu -ifu.ifu -ifuba -ifubinfo -ifw -ifx -ifxmt -info -info.iff -init -inp -inpcb -inq -ip -ipackets -ipintrq -laddr -len -loopback -lowat -m,n -mb -mbcnt -mbmax -mbuf -mbuf's -mbufs -mp -mr -mtod -mtu -netstat -nmr -nr -nx -oerrors -off0 -ontrol -oob -oobmark -op -opackets -ops -optname -pcb -pgrp -prev -proc -proto -protosw -protoswNPROTOSW -pte -pullup -q0len -qlen -qlimit -rawcb -rcb -rcv -recvmsg -ref -refcnt -regs -req -rerouted -ro -rotocol -rt -rtalloc -rtentry -rtfree -rtredirect -rubaget -sb -sel -sendmsg -setsockopt -slowtimo -snd -sockaddr -sockbuf -socketpair -sockproto -sonewconn -soshutdown -src -ta -ternet -timeo -totlen -uba -ubaalloc -ubaget -ubainit -uballoc's -ubaminit -uban -ubaput -ubinfo -udp -unibus -usrreq -virt -vm -wildcard -wmap -wubaput -x,t -xmt -xmt.ifrw -xmt.ifw -xswapd -xtofree -xxx diff --git a/share/doc/usd/07.Mail/mail6.nr b/share/doc/usd/07.Mail/mail6.nr deleted file mode 100644 index 0c3d402666db..000000000000 --- a/share/doc/usd/07.Mail/mail6.nr +++ /dev/null @@ -1,125 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)mail6.nr 6.3 (Berkeley) 4/17/91 -.\" -.bp -.sh 1 "Command line options" -.pp -This section describes command line options for -.i Mail -and what they are used for. -.ip \-N -Suppress the initial printing of headers. -.ip \-d -Turn on debugging information. Not of general interest. -.ip "\-f file\ \ " -Show the messages in -.i file -instead of your system mailbox. If -.i file -is omitted, -.i Mail -reads -.i mbox -in your home directory. -.ip \-i -Ignore tty interrupt signals. Useful on noisy phone lines, which -generate spurious RUBOUT or DELETE characters. It's usually -more effective to change your interrupt character to control\-c, -for which see the -.i stty -shell command. -.ip \-n -Inhibit reading of /usr/lib/Mail.rc. Not generally useful, since -/usr/lib/Mail.rc is usually empty. -.ip "\-s string" -Used for sending mail. -.i String -is used as the subject of the message being composed. If -.i string -contains blanks, you must surround it with quote marks. -.ip "\-u name" -Read -.i names's -mail instead of your own. Unwitting others often neglect to protect -their mailboxes, but discretion is advised. Essentially, -.b "\-u user" -is a shorthand way of doing -.b "\-f /usr/spool/mail/user". -.ip "\-v" -Use the -.b \-v -flag when invoking sendmail. This feature may also be enabled -by setting the the option "verbose". -.pp -The following command line flags are also recognized, but are -intended for use by programs invoking -.i Mail -and not for people. -.ip "\-T file" -Arrange to print on -.i file -the contents of the -.i article-id -fields of all messages that were either read or deleted. -.b \-T -is for the -.i readnews -program and should NOT be used for reading your mail. -.ip "\-h number" -Pass on hop count information. -.i Mail -will take the number, increment it, and pass it with -.b \-h -to the mail delivery system. -.b \-h -only has effect when sending mail and is used for network mail -forwarding. -.ip "\-r name" -Used for network mail forwarding: interpret -.i name -as the sender of the message. The -.i name -and -.b \-r -are simply sent along to the mail delivery system. Also, -.i Mail -will wait for the message to be sent and return the exit status. -Also restricts formatting of message. -.pp -Note that -.b \-h -and -.b \-r , -which are for network mail forwarding, are not used in practice -since mail forwarding is now handled separately. They may -disappear soon. diff --git a/share/doc/usd/07.Mail/mail7.nr b/share/doc/usd/07.Mail/mail7.nr deleted file mode 100644 index 165946172a8f..000000000000 --- a/share/doc/usd/07.Mail/mail7.nr +++ /dev/null @@ -1,107 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)mail7.nr 6.3 (Berkeley) 4/17/91 -.\" -.sh 1 "Format of messages" -.pp -This section describes the format of messages. -Messages begin with a -.i from -line, which consists of the word -.q From -followed by a user name, followed by anything, followed by -a date in the format returned by the -.i ctime -library routine described in section 3 of the Unix Programmer's -Manual. A possible -.i ctime -format date is: -.(l -Tue Dec 1 10:58:23 1981 -.)l -The -.i ctime -date may be optionally followed by a single space and a -time zone indication, which -should be three capital letters, such as PDT. -.pp -Following the -.i from -line are zero or more -.i "header field" -lines. -Each header field line is of the form: -.(l -name: information -.)l -.i Name -can be anything, but only certain header fields are recognized as -having any meaning. The recognized header fields are: -.i article-id , -.i bcc , -.i cc , -.i from , -.i reply-to , -.i sender , -.i subject , -and -.i to . -Other header fields are also significant to other systems; see, -for example, the current Arpanet message standard for much more -information on this topic. -A header field can be continued onto following lines by making the -first character on the following line a space or tab character. -.pp -If any headers are present, they must be followed by a blank line. -The part that follows is called the -.i body -of the message, and must be ASCII text, not containing null characters. -Each line in the message body must be no longer than 512 characters and -terminated with an ASCII newline character. -If binary data must be passed through the mail system, it is suggested -that this data be encoded in a system which encodes six bits into -a printable character (i.e.: uuencode). -For example, one could use the upper and lower case letters, the digits, -and the characters comma and period to make up the 64 characters. -Then, one can send a 16-bit binary number -as three characters. These characters should be packed into lines, -preferably lines about 70 characters long as long lines are transmitted -more efficiently. -.pp -The message delivery system always adds a blank line to the end of -each message. This blank line must not be deleted. -.pp -The UUCP message delivery system sometimes adds a blank line to -the end of a message each time it is forwarded through a machine. -.pp -It should be noted that some network transport protocols enforce -limits to the lengths of messages. diff --git a/share/doc/usd/07.Mail/mail8.nr b/share/doc/usd/07.Mail/mail8.nr deleted file mode 100644 index 4c48e059f03f..000000000000 --- a/share/doc/usd/07.Mail/mail8.nr +++ /dev/null @@ -1,75 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)mail8.nr 6.2 (Berkeley) 4/17/91 -.\" -.bp -.sh 1 "Glossary" -.pp -This section contains the definitions of a few phrases -peculiar to -.i Mail . -.ip "\fIalias\fP" -An alternative name for a person or list of people. -.ip "\fIflag\fP" -An option, given on the command line of -.i Mail , -prefaced with a \-. For example, -.b \-f -is a flag. -.ip "\fIheader field\fP" -At the beginning of a message, a line which contains information -that is part of the structure of the message. Popular header fields -include -.i to , -.i cc , -and -.i subject . -.ip "\fImail\ \ \fP" -A collection of messages. Often used in the phrase, -.q "Have you read your mail?" -.ip "\fImailbox\fP" -The place where your mail is stored, typically in the directory -/usr/spool/mail. -.ip "\fImessage\fP" -A single letter from someone, initially stored in your -.i mailbox . -.ip "\fImessage list\fP" -A string used in -.i Mail -command mode to describe a sequence of messages. -.ip "\fIoption\fP" -A piece of special purpose information used to tailor -.i Mail -to your taste. -Options are specified with the -.b set -command. diff --git a/share/doc/usd/07.Mail/mail9.nr b/share/doc/usd/07.Mail/mail9.nr deleted file mode 100644 index 975cac45fcd7..000000000000 --- a/share/doc/usd/07.Mail/mail9.nr +++ /dev/null @@ -1,203 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)mail9.nr 6.3 (Berkeley) 4/17/91 -.\" -.bp -.sh 1 "Summary of commands, options, and escapes" -.pp -This section gives a quick summary of the -.i Mail -commands, binary and valued options, and tilde escapes. -.pp -The following table describes the commands: -.TS -center ; -c ci -lb l. -Command Description -_ -+ Same as \fBnext\fP -- Back up to previous message -? Print brief summary of \fIMail\fP commands -! Single command escape to shell -Print Type message with ignored fields -Reply Reply to author of message only -Respond Same as \fBReply\fP -Type Type message with ignored fields -alias Define an alias as a set of user names -alternates List other names you are known by -chdir Change working directory, home by default -copy Copy a message to a file or folder -delete Delete a list of messages -dp Same as \fBdt\fP -dt Delete current message, type next message -edit Edit a list of messages -else Start of else part of conditional; see \fBif\fP -endif End of conditional statement; see \fBif\fP -exit Leave mail without changing anything -file Interrogate/change current mail file -folder Same as \fBfile\fP -folders List the folders in your folder directory -from List headers of a list of messages -headers List current window of messages -help Same as \fB?\fP -hold Same as \fBpreserve\fP -if Conditional execution of \fIMail\fP commands -ignore Set/examine list of ignored header fields -list List valid \fIMail\fP commands -local List other names for the local host -mail Send mail to specified names -mbox Arrange to save a list of messages in \fImbox\fP -next Go to next message and type it -preserve Arrange to leave list of messages in system mailbox -print Print messages -quit Leave \fIMail\fP; update system mailbox, \fImbox\fP as appropriate -reply Compose a reply to a message -respond Same as \fBreply\fP -retain Supersedes \fBignore\fP -save Append messages, headers included, on a file -set Set binary or valued options -shell Invoke an interactive shell -size Prints out size of message list -source Read \fImail\fP commands from a file -top Print first so many (5 by default) lines of list of messages -type Same as \fBprint\fP -undelete Undelete list of messages -unread Marks list of messages as not been read -unset Undo the operation of a \fBset\fP -visual Invoke visual editor on a list of messages -write Append messages to a file, don't include headers -xit Same as \fBexit\fP -z Scroll to next/previous screenful of headers -.TE -.bp -.(b -.pp -The following table describes the options. Each option is -shown as being either a binary or valued option. -.TS -center; -c ci ci -l ci l. -Option Type Description -_ -EDITOR valued Pathname of editor for ~e and \fBedit\fP -PAGER valued Pathname of paginator for \fBPrint\fP, \fBprint\fP, \fBType\fP and \fBtype\fP -SHELL valued Pathname of shell for \fBshell\fP, ~! and \fB!\fP -VISUAL valued Pathname of screen editor for ~v, \fBvisual\fP -append binary Always append messages to end of \fImbox\fP -ask binary Prompt user for Subject: field when sending -askcc binary Prompt user for additional Cc's at end of message -autoprint binary Print next message after \fBdelete\fP -crt valued Minimum number of lines before using \fBPAGER\fP -debug binary Print out debugging information -dot binary Accept . alone on line to terminate message input -escape valued Escape character to be used instead of\ \ ~ -folder valued Directory to store folders in -hold binary Hold messages in system mailbox by default -ignore binary Ignore \s-2RUBOUT\s0 while sending mail -ignoreeof binary Don't terminate letters/command input with \fB\(uaD\fP -keep binary Don't unlink system mailbox when empty -keepsave binary Don't delete \fBsave\fPd messages by default -metoo binary Include sending user in aliases -noheader binary Suppress initial printing of version and headers -nosave binary Don't save partial letter in \fIdead.letter\fP -quiet binary Suppress printing of \fIMail\fP version and message numbers -record valued File to save all outgoing mail in -screen valued Size of window of message headers for \fBz\fP, etc. -sendmail valued Choose alternate mail delivery system -toplines valued Number of lines to print in \fBtop\fP -verbose binary Invoke sendmail with the \fB\-v\fP flag -.TE -.)b -.(b -.pp -The following table summarizes the tilde escapes available -while sending mail. -.TS -center; -c ci ci -l li l. -Escape Arguments Description -_ -~! command Execute shell command -~b name ... Add names to "blind" Cc: list -~c name ... Add names to Cc: field -~d Read \fIdead.letter\fP into message -~e Invoke text editor on partial message -~f messages Read named messages -~h Edit the header fields -~m messages Read named messages, right shift by tab -~p Print message entered so far -~q Abort entry of letter; like \s-2RUBOUT\s0 -~r filename Read file into message -~s string Set Subject: field to \fIstring\fP -~t name ... Add names to To: field -~v Invoke screen editor on message -~w filename Write message on file -~| command Pipe message through \fIcommand\fP -~: Mail command Execute a \fIMail\fP command -~~ string Quote a ~ in front of \fIstring\fP -.TE -.)b -.(b -.pp -The following table shows the command line flags that -.i Mail -accepts: -.TS -center; -c c -l a. -Flag Description -_ -\-N Suppress the initial printing of headers -\-T \fIfile\fP Article-id's of read/deleted messages to \fIfile\fP -\-d Turn on debugging -\-f \fIfile\fP Show messages in \fIfile\fP or \fI~/mbox\fP -\-h \fInumber\fP Pass on hop count for mail forwarding -\-i Ignore tty interrupt signals -\-n Inhibit reading of /usr/lib/Mail.rc -\-r \fIname\fP Pass on \fIname\fP for mail forwarding -\-s \fIstring\fP Use \fIstring\fP as subject in outgoing mail -\-u \fIname\fP Read \fIname's\fP mail instead of your own -\-v Invoke sendmail with the \fB\-v\fP flag -.TE -.)b -.lp -Notes: -.b \-T , -.b \-d , -.b \-h , -and -.b \-r -are not for human use. diff --git a/share/doc/usd/07.Mail/maila.nr b/share/doc/usd/07.Mail/maila.nr deleted file mode 100644 index 04b76f51cbf7..000000000000 --- a/share/doc/usd/07.Mail/maila.nr +++ /dev/null @@ -1,33 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)maila.nr 6.2 (Berkeley) 4/17/91 -.\" diff --git a/share/doc/usd/11.notes/4.7 b/share/doc/usd/11.notes/4.7 deleted file mode 100644 index ce10bbddc869..000000000000 --- a/share/doc/usd/11.notes/4.7 +++ /dev/null @@ -1,81 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)4.7 6.2 (Berkeley) 4/17/91 -.\" $Id: 4.7,v 1.2 1993/08/01 07:37:23 mycroft Exp $ -.\" -.se "Modifying Access Rights for Many Notesfiles" - - It is convenient to add entries to a large number of -access lists simultaneously. -The nfaccess program adds an access specification to each of -a specified list of notesfiles. -Nfaccess functions similarly to chmod(1). -Nfaccess is invoked as: - - nfaccess notesfile [notesfile ...] - -The ``access-right'' is formatted as: ``type:name=mode''. -Type can be any of ``user'', ``group'', or ``system''; -capitalized variants are also valid. -The ``type:'' specification can be omitted. -``User'' is assumed in these cases. -The ``mode'' field consists of a sequence of the -characters ``d'', ``r'', ``w'', ``a'' and ``n''. -These indicate director, read, write, answer (respond) and null -access respectively. - - Nfaccess requires user and group entries to be valid -by looking for them in /etc/passwd and /etc/group. -System entries are not checked for validity. -Nfaccess will add the entry to the access list of the specified -notesfiles. -If an entry for that particular user, group or system exists, -the new access right replaces the old access rights. -The computed mode is an absolute mode; the previous value in -the access list (if any) is replaced with the new mode. - - Any user can run the nfaccess program. -Nfaccess refuses to modify access lists for any notesfile -where the user is not a director. -The nfaccess program is stored in the notesfile utility -directory, typically ``/usr/spool/notes/.utilities''. - - Nfaccess is often used to remedy missing permissions -in a number of notesfiles. -One example is when the notesfile administrator is replaced; -nfaccess is used to grant director access to the appropriate -notesfiles (usually most of them). -As new notesfiles are created, the access list can be tuned -by placing lists of access-rights in the file -``/usr/spool/notes/.utilities/access-template''. -These access-rights are added to the default access list -of newly created notesfiles. diff --git a/share/doc/usd/11.notes/5 b/share/doc/usd/11.notes/5 deleted file mode 100644 index 96ec36de93d6..000000000000 --- a/share/doc/usd/11.notes/5 +++ /dev/null @@ -1,153 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)5 6.2 (Berkeley) 4/17/91 -.\" -.ls 1 -.bp -.de CP -.rt -.po 4i -.. -.ch "Summary" -.nf -.ls 1 -.mk -notes [-sxi] [-a subsequencer] [-t type] nf-list - -.ft B -Everywhere: -.ft P - -? help -q,k quit -Q,K Quit w/out save -\(uaD Leave \fBNOW\fP w/out sequencer -! Fork Shell -B Register suggestion - -.ft B -Index Page: -.ft P - -+ Forward -* Last page -- Backward -= First page -13 Read note 13 (requires RETURN) -a,A Search for author -d Director options -j,J Jump to first unread note -l,L Like j,J; leave if nothing unread -n Nest notesfiles -N Nest to this notesfile's archive -o Set oldest date for sequencing -O Set sequencer for today's notes -p Read policy note -r Replot the screen -w Write a note -x,X Search for title -z like \(uaD but update sequencer - -.ft B -Reading anything: -.ft P - -spc Next page of current text -- Previous page of text -; Next text -+ Next text -ret Next note -7 Forward 7 responses (15 = 8 + 7) -= Goto base note -* Last Response -a,A Search backwards (author) -c,C Copy text to notesfile (C = w/editing) -d Toggle director msg. -D Delete (if yours) -e Edit title -E Edit text -f,F Forward notestring to notesfile (F= w/editing) -.CP -i Index page -j Next unread text -J Next unread base note -l,L Like j,J; leave if nothing unread -m Mail to anyone -M Mail w/text -n Nest notesfiles -N Nest to this notesfile's archive -p,P Personal note to author (P = w/text) -r,\(uaL Replot current text -R Rotate text (simple decryption) -s Save text -S Save entire note string -t Talk to author -w Write response -x,X Search backwards (title) -z like \(uaD but update sequencer -Z Delete (directors only!) - -.ft B -Director Options: -.ft P - -a Toggle anonymous -A Toggle archive status -c Compress notesfile -D Change expire w/dirmsg flag -e Change expiration threshold -E Change expiration action -l Change maximum text/article -m Change director message -n Toggle network availability -o Toggle open status -t Change notesfile title -u Un-delete lots of notes -w Write policy -W Change working set size -z Zap lots of notes -p Access (permission) List: - i insert - d delete - m modify - u user - g group - s system - - r read access - a answer access - d director options - w write access - n null access -.po -.ls -.fi diff --git a/share/doc/usd/11.notes/Makefile b/share/doc/usd/11.notes/Makefile deleted file mode 100644 index 5e9263b6a20e..000000000000 --- a/share/doc/usd/11.notes/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -# from: @(#)Makefile 6.1 (Berkeley) 5/26/86 -# $Id: Makefile,v 1.2 1993/07/31 15:30:23 mycroft Exp $ -# -# Makefile for the notesfile reference manual -# March 29, 1982 -# Ray Essick, University of Illinois -# uiucdcs!essick uiucdcs!notes -# -# Note that the macros are set up for two-sided copying. -# The page numbers alternate between the left and right -# sides of the page. -# See the file "macros" and the macro "hh" to modify this -# -# This copy of everything has been modified to run with troff -# and a typesetter. Hopefully the only changes to make it -# run again under nroff will be in page length/width statements. - -DISTDIR = p:/usr/src/uiuc/notesfiles -DCP= rcp -NROPTS = -TROPTS = -PRINTER = -Pdp -# ditroff actually prints the mother -TROFF = ditroff -NROFF = nroff -NOUT = qprx -FILES= 0.long 0.short \ - 1 2.1 2.2 3.1 3.2 \ - 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 \ - 5 \ - a.checklist b.interface c.changes -LONGFILES= 0.long \ - 1 2.1 2.2 3.1 3.2 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 \ - 5 a.checklist b.interface c.changes -SHORTFILES= 0.short \ - 1 2.1 2.2 4.0 4.1 4.2 4.3 4.4 4.5 -OTHERS = macros vtoc Makefile acks - -man: shortman -all: longman shortman - -longman: $(LONGFILES) macros vtoc acks - $(TROFF) $(TROPTS) $(PRINTER) macros $(LONGFILES) vtoc acks - -shortman: $(SHORTFILES) macros vtoc - $(TROFF) $(TROPTS) $(PRINTER) macros $(SHORTFILES) vtoc - -longout: $(LONGFILES) macros vtoc acks - $(NROFF) $(NROPTS) macros $(LONGFILES) vtoc acks > longout - -shortout: $(SHORTFILES) macros vtoc - $(NROFF) $(NROPTS) macros $(SHORTFILES) vtoc > shortout - -print: longout - $(NOUT) longout - -printsh: shortout - $(NOUT) shortout - -help: - @echo "make longman/shortman for long/abridged user man via ditroff" - @echo "make longout/shortout for long/abridged user man via nroff" - @echo "make print prints long nroff output" - -# -# Maintainence. -# - -spell: $(FILES) - sp $? - touch spell - -diction: out - diction out > diction - -style: out - style out > style - -dist: $(FILES) $(OTHERS) - ${DCP} $? $(DISTDIR)/doc/. - touch dist - -clean: - rm -f man out Make.errs - rm -f diction style spell sp.* - -install: diff --git a/share/doc/usd/11.notes/a.checklist b/share/doc/usd/11.notes/a.checklist deleted file mode 100644 index 016926ec13d9..000000000000 --- a/share/doc/usd/11.notes/a.checklist +++ /dev/null @@ -1,504 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)a.checklist 6.2 (Berkeley) 4/17/91 -.\" -.ls 1 -.ap A "Notesfile Installation Checklist" - -.a1 "Installing Notesfile Code" - - You can be sure that you have modified all necessary constants -in the notesfile system by following this simple checklist. - -.bz -.iz -change to the notesfile source directory -.iz -tar x -[reads the notesfile tape] -.iz -cd src -.iz -[edit] parms.h -.iz -ARCHTIME. -Default for how long unmodified note strings hang around. -.iz -WORKSETSIZE. -The default number of notes to leave in a notesfile when archiving. -.iz -DFLTSH. -This should be left as the Bourne shell, /bin/sh -RBE -.iz -DFLTED. -The editor to use if no NFED or EDITOR environment variable -exists. -.iz -SEQFILE. -This is the name of a file in the utility directory which contains -a list of notesfiles for users without an NFSEQ environment variable. -The default is probably just fine. -.iz -DFLTSEQ. -For users without an NFSEQ environment variable and when the file -specified by the SEQFILE definition above doesn't exist, we -finally fall back to using the notesfiles specified by this string. -The nice thing about having things in SEQFILE is that you don't -have to recompile the notesfile software everytime you wish to -change the default set of notesfiles; instead you edit a file. -.iz -MAILER. -The program which will do mailing. -If you are in a networked environment, this mailer should -manage to route letters to far away places for you. -The notesfile system only retains the name of the destination site; -a path to that site is not kept. -.iz -SUPERMAILER. -This should be defined if you have an intelligent mail program. -Intelligent here means that you can edit the letter and other -fun things. -.iz -PAGER. -A program which shows 1 screenful of information at a time. -.iz -WRITE. -A program which allows online user-user communication -(such as /bin/write). -.iz -FULLDOMAIN. -This defines the domain name of your local systems. For many -USENET sites, this should be ``UUCP''. -Other examples include ``ARPA'' and ``Uiuc.ARPA''. -This should not include the system name. -In the UIUC Computer Science Department, we have machines named -``uiucdcs'', ``uiucdcsb'', and so on; -our value for FULLDOMAIN is ``Uiuc.ARPA''. -The notesfile code puts -things together to yield ``uiucdcsb.Uiuc.ARPA'' as a -full domain name for one of our machines. -Note that you do NOT need to place a ``.'' at the beginning of -the domain name; the notesfile software does this for you. -.ix -IDDOMAIN. -This switch is (for now) undefined. -When defined it indicates the the unique id's associated with -notes are to have a system component containing the system -name and the string defined by FULLDOMAIN. -The eventual goal is that this will be defined. -Currently, there are problems with using long strings -for unique identifiers. This is related to the old notesfile -structure which used a 10 character maximum and didn't check for -overflow. -.br -So for now, leave this undefined. -I'm not sure when it will be good to enable this option. -.iz -Select a kernel type for your machine. -If no kernel is selected, the code may compile but most -likely will not run. -.iz -PROMPT. -If you wish the system to give a command prompt. -Otherwise the notesfile system is promptless. -.iz -USERHOST. -If this is defined, the notesfile system uses the convention -``user@host'' to indicate where an article originated. -If undefined, the notesfile system uses a ``host!user'' -notation. -If you are running in an environment which supports Internet -style names, you may choose to use this. -.iz -DYNADIR. -When defined, the notesfile system will determine the default -spool directory notesfiles from /etc/passwd. -The home directory for the user ``notes'' (actually whatever is -specified in the Makefile) is read from /etc/passwd and the -parent directory is used as the default spool directory. -Thus if notes' home directory is ``/usr/spool/notes/.utilities'', -the default directory is ``/usr/spool/notes''. -This assumes that notes' home directory is in the .utilities -directory. -.sp -This is useful for the case where a single binary will be run -on several machines with differing disk layouts. -On one, the database might live in /usr/spool/notes; another -host might have the data base in /mnt/notes. -By using DYNADIR and moving the ``notes'' home directory -on various machines, only one binary is needed. -.sp -If the notes database lives in the same place on all of your -machines, a better approach is to use the MSTDIR definition -in the Makefile. -.iz -K_KEY. -When defined, the ``k'' and ``K'' keys act similarly to the -``q'' and ``Q' keys respectively. -The choice is up to you. -Defining them allows reading of notes with one hand. -However some people get aggravated when the miss the ``j'' key -and hit the ``k'' key. -All the documentation considers the ``k'' key to be active. -.iz -BIGTEXT. -Define this is you want to allow notes longer than 65000 bytes. -Note that if you have old notesfiles, you will have to dump and -reload them with the ``nfdump'' and ``nfload'' programs before -the new code will work on them. -.iz -.ft B -The following definitions are pretty much ``stock'' and -usually aren't changed. -.ft P -.iz -NFMAINT. -This is the name of the notesfile which receives control messages, -error reports and other notesfile logging functions. -I do not recommend #undef'ing this. -.iz -AUTOCREATE. -When defined, network receptions of previously undefined notesfiles -will cause the creation of that notesfile. -If undefined, the reception will fail if the notesfile doesn't -exist. -This is used in environments such as USENET where new notesfiles -are often created remotely. -.iz -STATS. -If defined, the statistics keeping code is enabled. If undefined, -the notesfile system will not keep statistics. -Keeping statistics involves no space overhead and relatively -little time overhead; I recommend leaving this defined. -.iz -FASTSEQ. -Enables code which ``fails-quickly'' by determining in an -inexpensive operation if there can't be any new articles. -When there might be new articles, -a more thorough and time consuming algorithm -is used. -.iz -DUMPCORE. -This defines a subdirectory of the notesfile utility directory -where core images generated by internal consistency checks are -placed. If undefined, the errors will be logged but no core -image is generated. -.iz -FASTFORK. -This definition enables a quick forking algorithm which -exec's the desired program immediately instead of going through -the system(III) interface. -It avoids an extra fork()/execl() and shell startup costs. -However some functionality is lost. -.iz -[finished editing parms.h] -.iz -[edit] Makefile -.iz -select BIN. -The directory where user commands are kept. -The Makefile will NOT create this directory. -At UIUC, we use /usr/bin. Another common choice is -/usr/local. -.iz -MSTDIR. -The default directory for notesfiles. -The Makefile WILL make this directory for you. -This is typically /usr/spool/notes. -.iz -ARCHDIR. -Old notes never die, they go here instead; -the Makefile WILL make this directory for you. -.iz -NET. -This is the directory where the notesfile networking programs -``nfxmit'' and ``nfrcv'' will be placed. -In most cases, ``/usr/bin'' is a good choice. -You may wish to change it if your UUCP or other networking -mechanisms use other directories. -This directory must already exist; -the Makefile will not create it. -.iz -AUTOSEQ. -The invocation name for the automatic sequencer. -For multiple names like `autoseq', `readnotes' and `autonotes', -make links to the file ``/usr/bin/notes'' with the appropriate -names (assuming that BIN = `/usr/bin'). -.iz -NOTES. -The username of the user who ``owns'' all the notesfiles. -.iz -NOTESUID. -The numeric userid of the notesfile ``owner''. -For example NOTES = notes, NOTESUID = 10. -.iz -NOTESGRP. -The name of the group to which the ``NOTES'' signon belongs. -.ft B -It is strongly recommended that this be a special group -just for the notes database and programs. -.ft P -.iz -ANON. -The name of the ``anonymous'' user. -.iz -ANONUID. -The numeric userid of the ``anonymous'' user; -this should be an idle user id since it is not allowed to -run the notesfile program. -.iz -LIBDIR. -The directory to contain ``libnfcom.a'', a user accessible library -of routines. -This is distributed as /usr/local/lib. -.iz -CFLAGS. -You may wish to arrange for split I/D loading on a PDP-11 -(the -i flag). -It may also be prudent to optimize the code (-O flag). -If code size is an issue, remove the RCSIDENT definition; -when defined, version control information is included in the -binaries and they are correspondingly larger. -.iz -[finished editing] -Makefile -.iz -[may need to become super-user at this point] -.iz -type ``make base'' -and assess its completion. -It will tell you if all went well. -.ft B -If you are merely installing a new version of the notesfile code, -you should type ``touch base'' instead of ``make base''. -.ft P -.iz -Signon as notesfile ``owner''. -While remaining super-user isn't a fatal flaw at this point, it -does mean that several default notesfiles won't be generated. -These can be created by hand if you forget. -Nothing from this point on (including future code updates) requires -super-user privileges. -.iz -cd src -.iz -.ft B -If you are merely installing a new version of the code, -type ``touch spool'' now. This tells the makefile that the spool -directories already exist. -.ft P -.iz -make boot. -This is the final step, it should complete with a message -that the system is installed. -An error message when doing the ``mknf -on nfmaint nfgripes'' -probaby means you are still super-user. -Don't sweat it; just become notes and type the ``mknf'' command -line over. Everything is now fine. -.iz -You may have to be Super-User for the next step depending on the -modes of your manual directory, /usr/man. -.iz -cd ../man. -[the man page directory for notesfiles] -.iz -make install. -to install the man(I) pages for the notesfile system. -They are placed, by default, in the directories /usr/man/man1, -/usr/man/man3, and /usr/man/man8. -.iz -Examine the ``Samples'' directory for templates of files normally -in the notesfile utility directory. -These files include shell scripts to run through cron(8) which -queue network transmissions, expire old notes, and -map between notesfiles and news. -.iz -Modify UUCP's ``uuxqt.c'' to allow remote execution of ``nfrcv''. -This is unnecessary if no notesfile networking will be done -or if another remote execution mechanism will be used. -Some versions of UUCP have a file ``/usr/lib/uucp/L.cmds'' -which contains names of permitted commands. -.iz -Modify /etc/rc to remove notesfile locks at boot time. -[4.2 BSD machines might prefer to use /etc/rc.local.] -Add the command ``rm -f /usr/spool/notes/.locks/*''. -.ez - -.a1 "Upgrading Existing Notesfile Databases" - - Revision 1.7 of the notesfile system requires converting -existing notesfile databases to a new format. -A set of programs to accomplish this task are included in the -distribution. -The ``nfdump'' program converts notesfiles into an ASCII representation. -The ``nfload'' program converts this ASCII representation back -into a properly formatted notesfile. -To convert an existing notesfile database, these steps are what I -follow: - -.bz -.iz -Compile ``nfdump'' with the OLD notes distribution. -If your version of the software is old enough not to have a copy -of nfdump, -I suggest you either try to adapt the version in the current -distribution or using the networking programs ``nfxmit'' and ``nfrcv'' -to get the information between the old and new databases. -.iz -Compile ``nfload'' with the NEW notes distribution. -.iz -cd /usr/spool/notes -.iz -mkdir .OLD -.iz -mv * .OLD -.iz -run the following script: -.nf -.br -#! /bin/csh -f -foreach i (`ls .OLD`) - echo $i start - nfdump-old /usr/spool/notes/.OLD/$i - | nfload-new $i - echo $i done -end -echo ALL DONE -.fi -.iz -rm -rf .OLD -.ez - - You will also have to convert the sequencer information. -In the ``utility/seq-cvt'' directory there are a pair of programs -``seqtoascii'' and ``seqtobinary''. -To convert the sequencer information: - -.bz -.iz -make ``seqtoascii'' using the OLD structs.h and parms.h. -.iz -make ``seqtobinary'' using the NEW structs.h and parms.h. -.iz -cd /usr/spool/notes/.sequencer -.iz -mkdir .OLD -.iz -mv * .OLD -.iz -run this shell script: -.nf -.br -#!/bin/csh -f -foreach i (`ls .OLD`) - echo $i - seqtoascii .OLD/$i | seqtobinary $i -end -echo ALL DONE -.fi -.iz -rm -rf .OLD -.iz -If you are going to use the FULLDOMAIN option, you may want -to go ahead and perform the following steps: -.iz -run this shell script, appropriately modified to reflect -your domain setup. -This one reflects the naming at UIUC. -.nf -.br -#!/bin/csh -f -foreach i (Sy:*) - echo $i - ln $i $i.UUCP - ln $i $i.Uiuc.ARPA -end -echo ALL DONE -.fi -.iz -You have now converted your notesfile database to 1.7 format. -Install the new binaries and fire away. -.ex - - -.a1 "Hints on Installing Notesfiles on Multiple Systems" - - Notesfile binaries are portable across similar machines. -User-id's and hostnames are determined by examining /etc/passwd -and through system calls. - - To install the Notesfile system on a network of like machines -(a collection of 68000 workstations for example) -one machine must go through the procedure detailed above. -A shell script ``rinstall'' is included in the notesfile -source directory. -This shell script will propagate copies across the network. -Rinstall is a simple script that assumes the correct -hierarchies exist on the target machines. -It was written to use the 4.2 BSD ``rcp'' and ``rsh'' programs -to copy files and remotely execute commands. -Different networking commands will require changes to the shell -script. - - To generate the proper hierarchies on other systems, -copy the Makefile to each of the machines and make both -``base'' and ``spool''. This will create the proper files -and directories for the notesfile system. -Then return to the master machine and run the rinstall script -to send binaries to each of the other machines. - - The ``Samples'' directory of the Notesfile distribution -contains example cron scripts for sending information between -a network of systems running notesfiles. -These shell scripts can prove helpful in setting up notesfile -transmissions around your local network. - -.a1 "Mail to Notesfiles" - - To use the nfmail program with the 4.1 BSD /etc/delivermail -or the 4.2 BSD /usr/lib/sendmail -insert lines of the following form in the file /usr/lib/aliases. - -.in +1i -.nf -somenotes: ``|/usr/spool/notes/.utilities/nfmail somenotes'' -gripes: ``|/usr/spool/notes/.utilities/nfmail problems'' -.fi -.in - -.a1 "The Notesfiles/News Gateway" - - The notesfile/news gateway may need a little more tickling to -convince it to work properly. For more information on how to set this -up properly, see section 3.5 (``Interfacing to News'') and look at -the file `Src/newsgate.h'. -Appendix B (``Interfacing Notesfiles to News'') -is another source of information for connecting the two systems. diff --git a/share/doc/usd/11.notes/acks b/share/doc/usd/11.notes/acks deleted file mode 100644 index 52baead3f3c6..000000000000 --- a/share/doc/usd/11.notes/acks +++ /dev/null @@ -1,63 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)acks 6.2 (Berkeley) 4/17/91 -.\" -.rm PA -.bp -\ \ -.sp |3i -.ce 99 -Acknowledgments -.ce 0 - - A number of people have been very helpful in bringing -the notesfile syste to its current state. -Rob Kolstad first brought up the idea of implementing notesfiles -on UNIX. -Malcolm Slaney and Brian Redman -both used the program before it was close to being ready and -offered numerous suggestions and corrections. -Lou Salkind and Rick Spickelmier -put much effort into -generalizing the command parsing and adding -features I've forgotten to mention. -Tw Cook first implemented USENET-compatible headers for -the notesfile/news gateway. - - To all of these people, I give my hearty thanks for helping -to make this system what it is: -a convenient tool for -user communications, -personal notebooks, -project workbooks, -and -discussion management. diff --git a/share/doc/usd/11.notes/b.interface b/share/doc/usd/11.notes/b.interface deleted file mode 100644 index 9e765db0073a..000000000000 --- a/share/doc/usd/11.notes/b.interface +++ /dev/null @@ -1,462 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)b.interface 6.2 (Berkeley) 4/17/91 -.\" -.ls 1 -.ap B "Interfacing Notesfiles to News" - - The News system provides functions similar to -those provided by the Notesfile system. -It is possible to gateway articles between the two systems. -In USENET, a common configuration is for several notesfiles -sites to form a subnetwork of USENET and -gateway articles between the local notesfile network and -the rest of USENET. -These articles propogate across USENET in the news system. -Article originating in the news system are gatewayed into -the notesfile network. -When several notesfile networks exist as subnetworks of -a larger news network (such as USENET), articles written -in one notesfile network will be correctly interpreted -when arriving at another notesfile network. -``Correctly'' interpreted includes proper linking of -responses to their true parents; -this is sometimes not possible with articles written in the -news system. - - The notesfile gateway code recognizes articles meeting -the USENET standards. -Additionally, the A-news protocol and older B-news protocols -are recognized. -Incoming (news \(-> notes) articles are parsed and placed in the -appropriate notesfiles. -Articles written within a notesfile subnetwork are formatted according -to USENET standards and transmitted to the news system. - -.a1 "Configurations for Sites without News" - - Sites running notesfiles without the news program have -several possible configuations. -If your site is part of a notesfile subnetwork and you wish to -have your articles gatewayed to the news system and the -rest of USENET, you must find a site who will act as a -gateway for your articles. -The gateway code performs its task in such a way as to allow -several sites to gateway the same article into the news system; -the multiple copies will have identical unique identifiers -and one copy will be canceled when they meet on a remote system. - -.a2 "Sites with no News Neighbors" - - If you have no immediate neighbor running news, there is -no particular action you should take other than to reassure -yourself that some site in the notesfile subnetwork is gatewaying -notes-generated articles to the news system. -This can be done in one of several ways. -If the site wants to gateway articles specifically from your -machine, the following command should be executed on that site -occasionally. This is typically done through cron(8). - - newsoutput -syoursite notesfile-list - -A more typical arrangement is where the gateway site sends all -notes-generated articles that arrive on its system into the -news system. -In this case, the gateway site will execute a command such as -the following: - - newsoutput -a notesfile-list - -A site gate using this command line will automatically gateway -articles written at your site and eliminates the need of running -a command similar to the first command line. - - -.a2 "Sites with Neighbors running News" - - If a neighboring system runs both notes and news, you -have the option of gatewaying your own articles or allowing -the neighbor to gateway articles for you. -If the neighbor does not run the notesfile system, you must -provide your own gateway functions. - - Gatewaying can be done similarly to the site without -a news neighbor. You can let your articles propogate across -a notesfile network to a gateway site which will send them -to the news system. -Another option is to gateway your articles, -and possibly any notesfile-generated articles, -into the news system at the neighboring site. -This gets your articles into USENET as quickly as possible. -The two options are not mutually exclusive; -you can gateway your own articles and allow another site to -gateway them. -When copies of the same article meet on a news system, the -extra copy will be removed from the network. - - To gateway articles into news, you must modify the -file -/usr/spool/notes/.utilities/net.how -to tell the newsoutput -program how to get to the news system. -More information on this can be found in the section -``Copying Notesfiles to News'' later in this appendix. - - To gateway from the news system to the notesfile -system, you must arrange to have the news system at the remote -site send articles as standard input to the program -/usr/spool/notes/.utilities/newsinput -on your system. - - Information on mapping functions between notesfiles -and news, how to configure a news system to send articles to -a notesfile system, -and -how to have a notesfile system send articles to a news system -can be found later in this appendix. - -.a1 "Configurations for Sites running News" - - A site running both notesfiles and news will typically -perform gateway functions in both directions, -from the notesfile system to the news system -and -from the news system to the notesfile system. -In these cases all the operations are local. - -.a1 "Gatewaying between Notesfiles and News" - - The two notesfile programs ``newsoutput'' and ``newsinput'' -perform gatewaying between notesfile and news systems. -Newsoutput takes notesfile-generated articles, formats them, -and hands them to the news system. -Newsinput takes articles from the news system and inserts -them in the notesfile system. - -.a2 "Copying News to Notesfiles" - - The news system maintains ``subscription lists'' for -each neighboring system. -The subscription list is stored in the file /usr/lib/news/sys -on a B-news system. -On an A-news system, the subscription list is in -/usr/spool/news/.sys - - News feeds articles to neighboring systems as they -arrive. -In many cases, the article is queued for transmission. -In other cases, the article is given to a batching program -which collects a number of articles for transfer -and sends them to an appropriate un-batching program at -the receiving end. - - In the case where the notesfile system resides on another -machine, the news subscription line should be generated similarly -to that for a normal news feed with several exceptions. -The first is that the newsinput program does not understand about -batching; articles must be sent one at a time. -Also, one must specify the method of transmitting the article. -To feed the system ``somesite'' with news, the -neighbor will add a line of the following form to his /usr/lib/news/sys: - - somesite:subscription::uux - -n somesite!/usr/spool/notes/.utilities/newsinput - -Of course, networks other than UUCP can be used. - - To forward to a notesfile system on the same machine as the -news system, create a pseudo site which doesn't exist elsewhere -(a sitename such as ``nf_sys'' works), and add a line like: - - nf_sys:subscription::/usr/spool/notes/.utilities/newsinput - -Articles arriving at the local system will now be forwarded to -the notesfile system. -By default, news articles are placed in notesfiles with the -same name. -To map newsgroups to particular notesfiles, see the later -section ``Naming Notesfiles and Newsgroups''. - -.a2 "Copying Notesfiles to News" - - The newsoutput program transfers notesfile-generated -articles from the notesfile system to a news system. -The news system does not have to be on the same machine. - - Newsoutput accepts parameters telling it to gateway -articles from specific systems or any system. -Additional options allow backwards compatible -headers for older versions of the notesfile software. -A typical newsoutput invocation looks like: - - newsoutput -a notesfile-list - -The -a parameter indicates that notesfile generated articles -from any site are to be sent to the news system. -Under no circumstances will newsoutput transfer an article -to the news system if it has passed through the news system -before. -Thus if a notes generated article passes from one notesfile -subnetwork to another through the news system, the -article will not be sent into the news system by anyone in -the second notesfile subnetwork. - - The ``notesfile-list'' can contain a mixture of -specific notesfiles, wild-card specifications (net.*), -or ``-f file'' parameters which specifies a file -containing a list of notesfiles to send. - - Alternatively, articles for only one system can be -gatewayed with a command line of the form: - - newsoutput -ssitename notesfile-list - -This invocation method maintains a sequencer for each system; -the -a option maintains a single global sequencer. - - A third invocation method of newsoutput uses the -``-c'' option and specifies a specific set of systems to -gateway articles for. The command looks like: - - newsoutput -c gateway-site-file notesfile-list - -The ``gateway-site-file'' specifies a file containing a list -of sitenames. -Articles written at any of these sites are gatewayed to the -news system. -Thus newsoutput has the ability to send articles to news -for a single system, several systems, or any system. - - Newsoutput assumes that a news system is installed -on the local system. -If the news system is in a non-standard location on the -local system or -the news system is on a different machine, newsoutput -can be told where to send articles. -The file /usr/spool/notes/.utilities/net.how contains -command templates for notesfile networking. -To specify a non-standard place for the ``rnews'' program, -add a line of the form: - - Usenet:x:::uux - -n myneighbor!/usr/bin/rnews - -Non-UUCP connections and the like can be specified. - -.a2 "Naming Notesfiles and Newsgroups" - - Notesfiles and newsgroups for the same topic can have -different names. -Notesfiles are currently limited in the last component of -their name to the length of a filename; -under V7, System III, System V, and 4.1 Bsd this is 14 -characters. 4.2 Bsd extends the length of a filename -to a maximum of 255 characters per component. -Newsgroup names are no longer limited in total length; -the only restriction in current news versions is -that each component (between .'s) is unique in -the first 14 characters. - - The file ``/usr/spool/notes/.utilities/newsgroups'' -defines the relationships between notesfiles and newsgroups. -Lines in the file have the general form: - - notesfile:base_newsgroup:respone_newsgroup - -Lines beginning with the ``#'' character are considered -comment lines. -The ``response_newsgroup'' field and the colon separating -it from the base_newsgroup field are optional. - - Entries in this file need be made for only a few reasons: -(1) The newsgroup which matches the notesfile is longer than fourteen -characters, -(2) the notesfile and the newsgroup are different names -(e.g. the notesfile `Bnews' can be linked to the newsgroup `net.news.b' -with an entry of `Bnews:net.news.b'), -(3) you want several newsgroups linked to a single notesfile, -and -(4) notes and responses from a notesfile should go to -different newsgroups (net.general/net.followup is one example). -The file is scanned from the beginning until EOF or a match is found. -When no match is found, the code returns the original argument as if -it had matched itself. -The process is similar to having placed a sentinel line of the -form: - - myarg:myarg - -at the end of the file. - - The optional third field in the line is used to send -notes and responses from a notesfile to separate newsgroups. -The net.general/net.followup convention is an example of -how this would be used. -Typically the net.general and net.followup newsgroups are -mapped into the same notesfile. -To preserve peace with news users, responses written in a -notesfile `net.general' should go to the newsgroup `net.followup'. -The following pair of lines will map all news from net.general -and net.followup into the notesfile net.general. -Base notes from the notesfile net.general will go to the newsgroup -net.general; -responses in the net.general notesfile will be sent to -the net.followup newsgroup. - -.nf - net.general:net.general:net.followup - net.general:net.followup -.fi - -The first line maps news in net.general to the notesfile net.general. -It also does the mapping from notesfiles to newsgroups. -The second line maps news from net.followup into the notesfile -net.general. -Note that the response field is not used in the mapping from -newsgroups to notesfiles; it is used only for mapping notesfile -responses into a different newsgroup. - - To map several newsgroups into the same notesfile, -place lines of the following form in the ``newsgroups'' file: - -.nf - somenotesfile:newsgroup1 - somenotesfile:newsgroup2 -.fi - -If you wish to have articles from the notesfile ``somenotesfile'' -go to both of the newsgroups, insert a line before the above lines -to map articles going to notesfiles. -The result would look like: - -.nf - somenotesfile:newsgroup1,newsgroup2 - somenotesfile:newsgroup1 - somenotesfile:newsgroup2 -.fi - -The first line is the one used for articles going from notesfiles -to news; the newsgroups specification ``newsgroup1,newsgroup2'' -is used on those articles. -Articles coming from the newsgroup ``newsgroup1'' will fail to -match the first line, since the program expects exact matching. -They will match the second line and be mapped to the -notesfile ``somenotesfile''. - -.a1 "Typical Configurations" - - A typical notesfile subnetwork contains a number of -pure notesfile sites and several sites running both news and -notesfiles. -In these situations, some subset of the sites running -both notes and news -act as gateway sites. -The pure notesfile sites don't concern themselves with -gateway operations. -The gateway sites typically gateway all notes-generated -articles to news. -Duplicate articles, gatewayed at several sites, -will propogate across the news network. -When two or more of these articles meet at some site, the -superflous copy will be removed from the network. - - If none of the sites in the notesfile subnetwork -run the news program, -the gateway site will be one or more of the sites having -neighbors that do run news. -These gateway sites will run newsoutput and direct the -output to the news site by making the appropriate -entry in /usr/spool/notes/.utilities/net.how -for the pseudo-site ``Usenet''. - -.a1 "News Gateway Installation Checklist" - - The following checklist covers the variables in the -``newsgate.h'' file which may need to be changed on your system. -It also mentions which files to modify to automate the transfer -of articles between the two systems. - -.bz -.iz -[edit] src/newsgate.h -.iz -MYDOMAIN. -This should be set to the domain your site is in. -Typical domains are ``UUCP'' and ``ARPA''. -.iz -DFLTRNEWS. -The news receiving program. -This can normally be left as is; -alternate news insertion methods can be specified -with more flexibility through the net.how file. -.iz -EXPANDPATH. -If defined, the code looks in the file specified -by PATHMAP for a route to an author's system. -The code which does this is in ``src/newspath.c'' -and expects a particular format in the PATHMAP -file. -You may wish to replace it with code of your own if -your data base is in a different format. -.iz -PATHMAP. -This is the full pathname of the routing tables -used if EXPANDPATH is defined. -.iz -[finished editing] src/newsgate.h -.iz -make newsouput newsinput. -This will recompile the notesfile/news gateway programs. -.iz -Check /usr/lib/news/sys -to see that news will be forwarded to the notesfile system. -.iz -Make entries in /usr/lib/crontab to -invoke newsoutput occcasionally. -We use every 6 hours. -.iz -If the news system is on another machine or in a non-standard -place, -modify -/usr/spool/notes/.utilities/net.how. -Add a pseudo-site ``Usenet'' which specifies how to -get to the remote machine. One example is: -.br - Usenet:x:::uux - -z neighbor!/usr/bin/rnews -.iz -Check /usr/spool/notes/.utilities/newsgroups. -A sample of how this file will look is included in the -``Samples'' directory of the distribution. -.iz -Everything should be configured now. -You will probably want to run several tests on local -or limited distribution newsgroups to satisfy yourself -that it works. -.ez diff --git a/share/doc/usd/11.notes/c.changes b/share/doc/usd/11.notes/c.changes deleted file mode 100644 index d7b7fabbd202..000000000000 --- a/share/doc/usd/11.notes/c.changes +++ /dev/null @@ -1,412 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)c.changes 6.2 (Berkeley) 4/17/91 -.\" -.ls 1 -.ap C "Distributed Revisions of the Notesfile System" - - Several revisions of the Notesfile System are available. -This appendix attempts to describe the differences between -each revision and the previous one. - -.a1 "Previous Revisions" - - The Notesfile System was first distributed in June 1982. -Since then it has gone through a number of internal revisions -and several major revisions. -The initial 1.0 revision had numerous bugs in the code and -inadequacies for interfacing with the news system. -Release 1.3 (the most recently ``announced'' release) -became available in March 1983. - - Revisions are maintained with the RCS system. -Major releases are number 1.1, 1.2, 1.3 ... 1.x. -Internal modifications are numbered off of the base revision. -Internal revisions between 1.2 and 1.3 are of the form -1.2.1.x. -All files in a distribution will have the same major -revision number; files modified since the major -release will an internal revision number based off the major -revision number. - -.a1 "Revision 1.5" - - Revision 1.5 is an intermediate revision. -Revision 1.4 was stillborn. -It's primary purpose was to integrate a number of useful -modifications sent in by notesfile users. -A number of recent 1.5+ distributions have almost the same -functional differences from previous revisions as the newer -revision 1.6 code. - -.a1 "Revision 1.6" - - Revisions 1.6 of the Notesfile system includes a number -of changes. Numerous bugs in the code were repaired. -Several functional differences are also evident in -this revision of the code. -Major changes are listed below in chronological order. -To see what has changed since you received your copy of the code, -find the first date after you received your distribution -and read from there. - -Fall 1983: - -.bx -.ix -Archival techniques are more refined. -Previous revisions determined the age at which to expire notesfiles -from the nfarchive command line. -Each notesfile now contains its own `expiration threshold'. -This threshold can be set to an arbitrary time (3 days), -default to the value specified on the nfarchive command line, -or -specify never to archive the notesfile. -These options allow expiration of the entire ``net.*'' collection -of notesfiles with the single command line `nfarchive net.*'. -Shorter duration notesfiles (maybe net.jokes) can be explicitly -set to a few days; notesfiles like net.bugs can be set to `never'. -The remaining notesfiles might be set to `default'. -A program `expirechange' is provided in the utility subdirectory -of the distribution to initialize the expiration threshold of -existing notesfiles. -This is recommended because the previously -unused field may contain garbage values. -.ix -A simple program `namechange' is included in the utility -directory to change the name within the data base. If you -pick up copies of the data base and set them down on -other systems this program will change the name of the system -the data base thinks it is on for you. -.ix -Alignment within the notesfile descriptor structure caused -me to remove 6 bytes of filler when adding a `long' to the -structure. -The size of the structure must be constant. -The program in utility/structsizes.c prints the sizes of -each of the possibly affected structures. -It would be prudent to compile and execute this program -once with the old structure definitions and once with the -new definitions to ensure that the structures are the same size. -Someday a notesfile dump/load program will be written that -makes this worry disappear. -.ix -Mapping notes out to the news system is more sophisticated. -The new scheme allows a notesfile to send base notes to -one newsgroup and responses to another newsgroup. -This is solely for the net.general/net.followup pair. -See the section ``Copying Notesfiles to News'' for a -more detailed explanation of this feature. -.ix -Binaries are portable. -With Unix kernels supporting the ``uname'' or ``gethostname'' -system call the code determines the host at runtime. -The code now also looks for the notesfile owner in /etc/passwd -to dynamically determine the `notesuid'. -As an example, a local network of Vaxen all running 4.1a Bsd -can run the same binary even if the `notes' user id -varies between machines. -Eventually it would be nice to have a single binary handle all -4.1a Vaxen, another for all 4.2 Vaxen, a third be adequate -for all USG 5.0 3b-20's. -(This does not mean that distributions will be binary only -but rather that a local administrator will be able to compile -once and ship copies of the binaries around with a simple shell -script). -.ix -The ``rinstall'' shell script updates the notesfile binaries -on a remote system. -It assumes that the local binaries will work on the remote -machine (don't rinstall from a Vax to a PDP-11). -The script uses the 4.1a `rcp' and `rsh' facilities to -perform the FTP and set modes on the remote files. -.ex - -December 1983: - -.bx -.ix -Notesfiles can be specified as absolute pathnames. -Commands such as ``notes /some/place/mynotes'' -are now legal. -An anticipated modification will allow search rules for -notesfiles similar to those command search rules used -by many shells. -.ix -Archives are stored as notesfiles. -Now that a notesfile can be specified by an absolute -pathname, archives are stored in notesfile format. -Access to archives can be either by explicit reference -or through the new ``N'' command which automatically -nests to the archive of the current notesfile. -.ix -Nfarchive now understands about ``working sets''. -The working set is the minimum number of notes left in -the active notesfile after an archive run. -.ix -Archive destinations are mapped. -A file in the notes utility directory (.utilities/net.aliases/Archive-into) -maps from active notesfiles to their respective archives. -This file contains absolute pathnames. -(/usr/spool/notes/somenotes instead of somenotes). -.ix -The beginnings of permission modes for an archive are there. -Currently only directors are allowed to write in an -archive notesfile. -Some more work on copying permission lists and -other information particular to the notesfile must be done. -.ix -The director page now contains information about -the number of ``holes'' (deleted notes and responses) -in a notesfile. -This is useful for determining the need to compress a -notesfile. -.ex - -January 1984: - -.bx -.ix -Each notesfile can now override the nfarchive command line options -for archiving/deleting expired notes and for expiring notes -on the basis of the director message status. -The director options page offers options to modify these fields. -The ``default'' value specifies using the value supplied on -the nfarchive command line. -.ix -The director option page has been rearranged. More information is -displayed, more options are processed. -Many of the changes are cosmetic and oriented towards helping -the user figure out what is happening. -.ix -The 4.2 Bsd release of Unix now has its own kernel definition. -Some of the new features of 4.2 Bsd are thus included. -This includes longer filenames and (faster) advisory locking. -.ix -4.2 Bsd (and 4.1a) allow processes to belong to -multiple groups. -The notesfile code now uses all of these groups to -determine access rights. -For example, a user belongs to -groups ``alpha'', ``beta'' and ``gamma''. -Group ``alpha'' has read permission, group ``beta'' has -write permission, and group ``gamma'' has no specific -permissions (it's covered in the ``Other'' clause). -The user is given the inclusive OR of his permissions: -in this case he is given read/write privileges. -The default ``Other'' group is used only when none of the -user's groups are explicitly named in the permission list. -Explicit permissions for users still takes precedence -over group permissions. -.ex - -February 1984: - -.bx -.ix -The networking software and the statistics printing package -now keep track of how many orphans are adopted by their true -parent. -This lets us determine how many base notes are actually lost -and how many show up behind their children. -.ix -The nfaccess program -allows simple and quick editing of access lists for a number -of notesfiles. -Nfaccess functions similarly to chmod(1), -you supply an access right and a list of notesfiles to apply it -to. -The new access right is placed in the access list of each notesfile -specified. -In the event of an existing access right, the new right replaces -the old one. -.ix -The code now understands about the extra work it must to -to function properly under the 4.2 Bsd signal semantics. -.ix -Nfabort provides user programs with a means of -leaving core dumps in specified places and logging -the fact with an arbitrary message in a notesfile. -The notesfile code itself uses this routine when trapping -internal errors. -.ix -Finally added the `l', `L' and `z' commands from Lou Salkind -and Rick Spickelmier. -The `l'-`L' pair mimic the `j'-`J' pair with the exception that -when no unread notes are left, the l/L commands leave the notesfile. -Thus `l' is almost a `jq' command. -.ix -The ! notesfile exclusion feature first implemented by Salkind -and Spickelmier is now in this revision. -Constructs like: -.br - notes ``net.*'' !net.general -.br -are possible. -This example specifies all ``net.'' notesfiles except net.general. -.ix -Alternate sequencers are now available. An alternate -sequencer allows users sharing the same signon to maintain -separate sequencer files. -.ex - -March 1984: - -.bx -.ix -Revision 1.6.2 created. Needed some distinction since 1.6 was -getting rather long lived and we weren't ready to call it -1.7 yet. -.ix -Each notesfile now enforces its own -limit on the size of single notes and responses. -This is initialized to a default value when the notesfile is -created and can be changed from the director options page. -Articles longer than the permitted maximum are truncated and -have a message appended detailing how many bytes were ignored -and the name of the site where it occurred. -.ix -Customized access lists are generated when each notesfile is created. -The file `/usr/spool/notes/.utilities/access-template', if it -exists, is used to modify the default access list when a notesfile -is created. This file contains ASCII specifications of access rights -in the same form as used on the nfaccess command line. Lines in -this file beginning with `#' are considered comments. -.ix -Author searching now understands about substrings. You no longer -have to match exactly an author. -Thus an author search would find articles written by -a user ``mark'' on any machine, -a user ``hallmark'' on any machine, -and -any user on the ``market'' machine. -.ix -The notes/news interface has been rewritten. -The news->notes code now understands all of the USENET standards -for B-news 2.10. -Newsinput understands about the References line. -The notes->news code generates articles acceptable to the -rest of USENET. -.ex - -December 1984: - -.bx -.ix -The nfmail -program has been re-written to understand about how to link -responses into a notesfile. This means nfmail is now a viable -way to have your incoming mail handled. After a little -more work is done, it will handle outgoing mail via the ``p'' -command equaly well. -.ix -Notes now runs set-gid. This solves some privilege problems -with set-uid programs such as signal delivery. It also -makes it easier for users to kill their jobs. -Thanks go to Lou Salkind for pointing this out long ago; I -just took a long time to realize it. -.ex - -.a1 "Revision 1.7" - - The long ago promised revision 1.7 of the notesfile -code is finally a reality. -This version incorporates many of -the features promised, and a few that weren't. -I thought about merely changing things from revision 1.6.2 to -1.6.3, but there was a change in the database format and I -decided a more drastic change in name was called for to match -the database format change. - - To upgrade to revision 1.7 from a previous revision (even -the last 1.6.2 revisions) requires a dump/load sequence with -the ``nfdump'' and ``nfload'' programs. The man pages for -these programs give more information on how to carry out this -procedure. - - In addition to changing the format of the notesfile -database, you must convert the format of the sequencer files. -To do this, look at the programs ``seqtoascii'' and ``seqtobinary'' -in the ``utility/seq-cvt'' directory of the notesfile distribution. -Appendix A also contains information on how to convert the -sequencer files and database. - - These changes took place during December of 1984 and -include the following differences from the 1.6.2 revision of -the notesfile code. - -.bx -.ix -The author structure for a note/response now contains the home system -name. -This provides the ability for gateway machines -to assign message-id's as needed without worrying about corrupting -the author's home system. -It also comes in handy within the context of the nfmail -program: nfmail can now report a true author for letters -and still assign a unique identifier based on the local system. -.ix -Timestamps for articles are now stored in the standard UNIX -format: seconds since 00:00 GMT, January 1, 1970. -The code recognizes (and stores) both formats and will present -either format as needed. -.ix -Notes now supports full domain based addressing. -The nfxmit program expects a full doman address (e.g., ``uiucdcs.uiuc.arpa''), -unique id and system information is generated with full domain -information, -and -the notesfile/news gateway now generates complete domain addressing -information. -.ft B -These changes require some care in upgrading from previous releases -of the notesfile system. -.ft P -.ex - -.a1 "On the Blackboard" - - The primary motivation for more work on the code -is to eliminate known bugs. -Integrating other's modifications into my code has taken -a lower priority. - - Sometime down the road, I hope to gather up all the -lessons learned from this first version -and -design a second implementation. -Issues to be considered in the second implementation include: -shared notesfile data bases between several hosts, -different user-interfaces (notes-like, readnews-like), -notesfile servers, -and -interfacing with extant systems. diff --git a/share/doc/usd/11.notes/macros b/share/doc/usd/11.notes/macros deleted file mode 100644 index 982a4d948dbf..000000000000 --- a/share/doc/usd/11.notes/macros +++ /dev/null @@ -1,320 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)macros 6.2 (Berkeley) 4/17/91 -.\" -.hw algo-rithm va-lid-ity mech-a-nism orga-nize per-cent-age jeop-ar-dizing un-known com-mu-ni-ca-tion en-a-bling re-stric-tion -.nr BT 1 -\" BT determines whether to leave white space at bottom of page -.nr TP 1 -\" TP determines whether to leave white space at the top of page -.ls 1 -.ie t \{\ -\" .ll 6.25i -\" .lt 6.25i -.po 1i -.pl 11i \} -.el \{\ -.ll 78 -.lt 78 -.pl 66 \} -.if \n(BT .wh -1i JP -.de JP -'bp -.. -.ds PA "USD:11-% -.\".fp 1 R -.\".fp 2 I -.\".fp 3 B -.\".fp 4 S -.nh -.de ch -.br -.ne 8 -.sp 2 -.ft B -.nr a +1 -\\na\\ \\ -.nr b 0 -\\$1. -.ft P - -.ds Rk " -.if 10-\\n% .ds Rk ". -.am vt - -\\fB\\na\\ \\ \\$1\\fP.\\*(Rk\\n% -\\.. -.. -.de ap -.nr b 0 -.am va -\\fB\\$1\\ \\ \\$2\\fP -\\.. -.ds PA "SMM:10-\\$1-% -.ds AP "\\$1 -.pn 1 -.bp -.ce 2 -.ft B -APPENDIX \\$1 -\\$2 -.ft P - -.. -.de se -.br -.ne 6 -.sp 1 -.ft B -.nr b +1 -.nr c 0 -\\na.\\nb\\ \\ -\\$1. -.ft P -.ds Rk " -.if 10-\\n% .ds Rk ". -.am vt -\\ \\ \\ \\na.\\nb\\ \\ \\$1.\\*(Rk\\n% -\\.. -.. -.de a1 -.br -.ne 6 -.sp 1 -.ft B -.nr b +1 -.nr c 0 -\\*(AP.\\nb\\ \\ -\\$1. -.ft P -.. -.de ss -.br -.ne 6 -.nr c +1 -.nr d 0 -.ft B -\\na.\\nb.\\nc\\ \\ -\\$1. -.ft P -.ds rk " -.if 10-\\nc .ds rk " -.ds Rk " -.if 10-\\n% .ds Rk ". -.am vt -\\ \\ \\ \\ \\ \\ \\ \\ \\na.\\nb.\\nc\\*(rk\\ \\ \\$1.\\*(Rk\\n% -\\.. -.. -.de a2 -.br -.ne 6 -.nr c +1 -.nr d 0 -.ft B -\\*(AP.\\nb.\\nc\\ \\ -\\$1. -.ft P -.. -.de s2 -.br -.ne 4 -.nr d +1 -.ft B -\\na.\\nb.\\nc.\\nd\\ \\ -\\$1. -.ft P -.ds rl " -.if 10-\\nc .ds rl " -.am vt -\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\na.\\nb.\\nc.\\nd\\*(rk\\ \\ \\$1. \\n% -\\.. -.. -.de s2 -.br -.ne 4 -.sp 1 -.nr d +1 -.ft B -\\na.\\nb.\\nc.\\nd\\ \\ -\\$1. -.ft P -.ds rl " -.if 10-\\nc .ds rl " -.. -.de hh -'if \n(TP 'sp |.5i -.if \\n%>1 \{\ -.ie e .tl '\\*(TI''\\*(PA' -.el .tl '\\*(PA''\\*(TI' \} -'sp 1 -'ns -.ev 2 -.ls 1 -.nf -.if \\n(SW .KK -.fi -.ev -.. -.de lz -.br -.ls 1 -.nf -.. -.de lq -.br -.fi -.sp 1 -.ls -.. -.de KS -.br -.di KK -.nr FK 0 -\!.nr SW 0 -.ev 1 -.ls 1 -.. -.de KF -.br -.di KK -.nr FK 1 -\!.nr SW 0 -.ev 1 -.ls 1 -.. -.de KE -.br -.sp 1 -.di -.nf -.nr SW 1 -.if \\n(.p-\\n(nl-\\n(dn+1 .nr SW 0 -.in 0 -.if !\\n(SW .KK -.in -.ev -.if !\\n(FK .if \\n(SW .bp -.fi -.. -.ev 1 -.ie t \{\ -.ll 6.25i -.lt 6.25i -.po 1i -.pl 11i \} -.el \{\ -.ll 78 -.lt 78 -.pl 66 \} -.if \n(BT .wh -1i JP -.hy 14 -.ev -.ev 2 -.hy 14 -.ie t \{\ -.ll 6.25i -.lt 6.25i -.po 1i -.pl 11i \} -.el \{\ -.ll 78 -.lt 78 -.pl 66 \} -.if \n(BT .wh -1i JP -.ev -.hy 14 -.if \n(mo-0 .ds mo January -.if \n(mo-1 .ds mo February -.if \n(mo-2 .ds mo March -.if \n(mo-3 .ds mo April -.if \n(mo-4 .ds mo May -.if \n(mo-5 .ds mo June -.if \n(mo-6 .ds mo July -.if \n(mo-7 .ds mo August -.if \n(mo-8 .ds mo September -.if \n(mo-9 .ds mo October -.if \n(mo-10 .ds mo November -.if \n(mo-11 .ds mo December -.if \n(dw-0 .ds dw Sunday -.if \n(dw-1 .ds dw Monday -.if \n(dw-2 .ds dw Tuesday -.if \n(dw-3 .ds dw Wednesday -.if \n(dw-4 .ds dw Thursday -.if \n(dw-5 .ds dw Friday -.if \n(dw-6 .ds dw Saturday -.ds DA \*(mo \n(dy, 19\n(yr -.de RS -.ls 1 -.in +5 -.. -.de rf -.br -.ne 4 -.ti -5 -.. -.de RE -.in -5 -.ls -.. -.de ix -.ti -4 -\(bu\ \c -.. -.de bx -.in +10 -.ls 1 -.. -.de ex -.br -.ls -.in -10 -.. -.de bz -.in +5 -.ll -5 -.ls 1 -.. -.de iz -.ti -5 -____ \c -.. -.de ez -.ls -.ll -.in -.. -.de TA -.ta 0.5i 1.0i 1.5i 2.0i 2.5i 3.0i 3.5i 4.0i 4.5i 5i 5.5i 6i 6.5i -.. -.ds TI "Notesfile Reference Manual -.if \n(TP .sp |1i -.wh 0 hh diff --git a/share/doc/usd/11.notes/vtoc b/share/doc/usd/11.notes/vtoc deleted file mode 100644 index 0101c932cfd7..000000000000 --- a/share/doc/usd/11.notes/vtoc +++ /dev/null @@ -1,76 +0,0 @@ -.\" Copyright (c) 1980 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)vtoc 6.2 (Berkeley) 4/17/91 -.\" -.de hh -'sp |1i -.. -.bp -# -.bp -.ev 1 -.ls 1 -.ce 1 -.ft B -TABLE OF CONTENTS -.ft P -.sp 1 -.ta 6i -.nf -\*(vt - -.ft B -APPENDICES -.ft P -.nf -.sp -\*(va -.ig -.bp -.sp 5 -.ce 1 -.ft B -List of Figures -.ft P - -\*(f1 - - -.ig -.ce 1 -.ft B -List of Tables -.ft P - -\*(t1 -.. -.ev diff --git a/sys/arch/amiga/README.CHOPPS-CONSOLE2 b/sys/arch/amiga/README.CHOPPS-CONSOLE2 deleted file mode 100644 index 967617b6b141..000000000000 --- a/sys/arch/amiga/README.CHOPPS-CONSOLE2 +++ /dev/null @@ -1,54 +0,0 @@ -12/6/93 7:12am. - -Ok here are the latest patches to the CC console and graphics subsystem. - -- iteconfig: is a configuration program that can dynamically change - your console's settings. It has been placed under GNU - Copyleft so the source is included. You will have to whip - a Makefile together to build it---I use the bsd system, - and mine just wouldn't make (no pun intended) sense to include. - -- cc-fixes.diff: these are the diffs necsessary to use the iteconfig program - and you should probably apply them to your 713 kernel sources. - I expect Markus will include them in the next release. - - -Enjoy. - -: Whats fixed - -overscan: it works but is a little korny sometimes sorry. The only -bug I found so far is with an width of 642 it just doesn't center correctly. -I also am not happy that my overscan abilities do not match that of C='s. -I will perhaps look into there method at some later time. If your curious -C= is offseting the bitmap pointers by -2 bytes and doing funky things with -the ddfstart under 2.0+ so that they can get a tighter fit. You'll probably -notice that I have to move the screen left at certain widths (644+,674+,708+) -This is becuase datafetch must be a multiple of 4 and must also not cross the -$d8 boundry, what C= is doing is offseting the bitmap pointers by -2 and -delaying display so they can get widths of multiples of 2 (word). I suppose -I have just figured out how to do it while typeing this README...so next time -we should have this ability. - -colors: not that anyone noticed but the /dev/view device's colormap functions -were disabled by Markus. They are now implemented in a cleaner fashion so -they can be used. iteconfig uses them to allow you to change the screen -colors. - -2024: 1024x800 sorry this mode still appears to be dead. I haven't had the time -to look into it. It is enabled however and a quasi-functioning 1024x800x2 (NOTE -only depths of 2) can be made to display through iteconfig if your kernel allows. - -AGA: someone send me a newer computer :^) - -ECS: ECS PAL is now working so that people with NTSC machinces can use it. - -X: Why is it that as the author of the Custom chips code I haven't received one -letter from these people? I wonder if they relize that using the view device -as it was designed will allow people to have a console open and X at the same -time... HEY X PEOPLE. there is no need to use the /dev/console for X try -/dev/view01. (Actually I did receive one from Philip asking for my source -which I gave. no questions asked. no replies received.) - -Again Enjoy, -Chris. \ No newline at end of file diff --git a/sys/arch/amiga/README.scsi b/sys/arch/amiga/README.scsi deleted file mode 100644 index 64d26960fdf8..000000000000 --- a/sys/arch/amiga/README.scsi +++ /dev/null @@ -1,14 +0,0 @@ -Changes in SCSI drivers ------------------------ - -The disk and tape drivers (sd.c - sddriver, and st.c - stdriver) have -been changed to make all calls to the controller driver (scsi.c - -33C93 driver, and siop.c - 53C710 driver) indirectly via a table -in the controller driver. This allows the use of a single disk and -tape driver for all scsi controller drivers. The rzdriver and tzdriver -have been elimintated (along with all the rz* and tz* devices). - -The 33C93-based drivers have been reworked a bit to remove some unused -code and to merge the DMA routine data into the controller data. The -DMA routines should now be able to work with multiple controllers, -although the autoconf routines don't allow this yet. diff --git a/sys/arch/amiga/README.st b/sys/arch/amiga/README.st deleted file mode 100644 index 679c6dde6b3b..000000000000 --- a/sys/arch/amiga/README.st +++ /dev/null @@ -1,96 +0,0 @@ -From leland@wacky.acet.org Mon Nov 22 17:48:45 1993 -Received: from mwunix.mitre.org by chsun.eunet.ch (8.6.4/1.34) - id RAA09132; Mon, 22 Nov 1993 17:48:41 +0100 -Received: from wacky.acet.org.acet.org ([192.188.104.18]) by mwunix.mitre.org (5.65c/SMI-2.2) - id AA13343; Mon, 22 Nov 1993 11:46:42 -0500 -Received: by wacky.acet.org.acet.org (4.1/SMI-4.1) - id AA06945; Sun, 21 Nov 93 16:30:44 EST -Date: Sun, 21 Nov 93 16:30:44 EST -From: leland@wacky.acet.org (Robert Leland - PSI) -Message-Id: <9311212130.AA06945@wacky.acet.org.acet.org> -To: mw@chsun -Subject: SCSI tape driver. -Cc: leland@wacky.acet.org -Status: OR - -I would like to change the way scsi tape /dev/rst maps the minor device. -This will allow for the selection of more than just one density of tape. - -Also though my Archive Viper 2525 drive can Read QIC-24 Tapes generated by -a sun tape drive, it has to do this by traversing the tape several times -until it figures it is a QIC-24, I would rather not wear out my tapes! -This change would allow all type drive types to specify 3 additional densities, other than -the default. ------------------------------ The Bottom Line(first)------------------------------ -People currently using - /dev/rst0, rts1 .... rst15 -would remain uneffected, regardless of tape drive type. - -People using the Exabyte type tape drives including Python that normally use - /dev/rst16 , /dev/rst32 -would use instead: - /dev/rst32, /dev/rst64 -(See below for more details) -------------------------------------------------------------------------------------- -Current - * Specific to Exabyte: - * minor bit 4 [b1bbbb] (aka /dev/rst16) selects short filemarks - * Specific to 8mm Drives. - * minor bit 5 [1bbbbb] (aka /dev/rst32) selects fix block mode, 1k blocks. - * - - Minor Device: --------------------------------+ - | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | - +---+---+---+---+---+---+---+---+ - ^ ^ ^ ^ ^ ^ ^ ^ - | | | | | | |___|_____ Unit Number - | | | | | |_____________ NoRewind - | | | | |_________________ HiDensity - | | | |_____________________ Short FileMarks - |_________________________ Fix block mode 1K - -- - - - - - - - - - - - - - - - - - - - - - - -Proposed - * Specific to Exabyte: - * minor bit 5 [bb1bbbbb] (aka /dev/rst32) selects short filemarks - * Specific to 8mm Drives. - * minor bit 6 [bb1bbbbb] (aka /dev/rst64) selects fix block mode, 1k blocks. - - Minor Device: --------------------------------+ - | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | - +---+---+---+---+---+---+---+---+ - ^ ^ ^ ^ ^ ^ ^ ^ - | | | | | | |___|_____ Unit Number - | | | | | |_____________ NoRewind - | | | |___|_________________ HiDensity - | |_________________________ Short FileMarks - |_____________________________ Fix block mode 1K - - -Advantages: More similar to sun mapping, Keeps bits together. -Disadvantages: Possiblely some initial confusion. -- - - - - - - - - - - - - - - - - - - - - - - -Alternate Proposed - I would rather keep the density bits together but we could... - Split the bits used for density Use bits 3 and 6: - - Minor Device: --------------------------------+ - | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | - +---+---+---+---+---+---+---+---+ - ^ ^ ^ ^ ^ ^ ^ ^ - | | | | | | |___|_____ Unit Number - | | | | | |_____________ NoRewind - | | | | |___________________________________ HiDensity - | | | |_____________________ Short FileMarks | - | |_________________________ Fix block mode 1K | - |_________________________________________________| - -This would mean that other users would remain uneffected. ------------------------------------------------------------------------------------------ -This change will also benefit other tape drives, so that specific densities can be specified. -Could really use three bits for density, however It's nice to have a spare bit for the future. - - --Rob - - diff --git a/sys/arch/amiga/amiga/cc_blitter.h b/sys/arch/amiga/amiga/cc_blitter.h deleted file mode 100644 index cc8455873d5f..000000000000 --- a/sys/arch/amiga/amiga/cc_blitter.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: cc_blitter.h,v 1.2 1994/01/29 06:58:40 chopps Exp $ - */ - -#if ! defined (_CC_BLITTER_H) -#define _CC_BLITTER_H - -#include "cc.h" - -/* MACROS */ -#define BLT_SHIFT_MASK(shift) \ - (0xf&shift) - -#define MAKEBOOL(val) \ - (val ? 1 : 0) - -#define DMAADDR(lng) \ - (u_long)(((0x7 & lng) << 16)|(lng & 0xffff)) - -#define MAKE_BLTCON0(shift_a, use_a, use_b, use_c, use_d, minterm) \ - ((0x0000) | (BLT_SHIFT_MASK(shift_a) << 12) | \ - (use_a << 11) | (use_b << 10) | (use_c << 9) | (use_d << 8) | \ - (minterm)) - -#define MAKE_BLTCON1(shift_b, efe, ife, fc, desc) \ - ((0x0000) | (BLT_SHIFT_MASK(shift_b) << 12) | (efe << 4) | \ - (ife << 3) | (fc << 2) | (desc << 1)) - -void cc_init_blitter (void); - -#if defined (AMIGA_TEST) -void cc_deinit_blitter (void); -#endif - - -#endif /* _CC_BLITTER_H */ diff --git a/sys/arch/amiga/amiga/cc_chipmem.c b/sys/arch/amiga/amiga/cc_chipmem.c deleted file mode 100644 index 013ba7e8a8f1..000000000000 --- a/sys/arch/amiga/amiga/cc_chipmem.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: cc_chipmem.c,v 1.4 1994/02/01 11:49:59 chopps Exp $ - */ -#include "types.h" -#include "cc_chipmem.h" -#include "param.h" - -mem_list_t chip; - -static void * -allocate (mem_list_t *m, u_long size) -{ - int s = splhigh(); /* disable everything. */ - void *mem = NULL; - if (size) { - dll_node_t *n; - - if (size & ~(CM_BLOCKMASK)) { - size = (size & CM_BLOCKMASK) + CM_BLOCKSIZE; - } - - /* walk list of available nodes. */ - for (n = chip.free_list.head; n->next; n = n->next) { - mem_node_t *mn = MNODE_FROM_FREE (n); - if (size == mn->size) { - dremove (n); /* remove from avail list. */ - n->next = NULL; /* mark as removed. */ - n->prev = NULL; /* mark as removed. */ - m->free_nodes--; - m->alloc_nodes++; - m->total -= mn->size; - mem = (void *)&mn[1]; - break; - } else if (size < mn->size) { - if ((mn->size - size) <= sizeof (mem_node_t)) { - /* our allocation wouldnot leave room for a new node in between. */ - size = mn->size; /* increase size. */ - dremove (n); /* remove from avail list. */ - n->next = NULL; /* mark as removed. */ - n->prev = NULL; /* mark as removed. */ - m->free_nodes--; - m->alloc_nodes++; - m->total -= mn->size; - mem = (void *)&mn[1]; - break; - } else { - /* split the node's memory. */ -#if 0 - mem_node_t *new = (mem_node_t *)(MNODES_MEM(mn) + size); - new->size = mn->size - (size + sizeof (mem_node_t)); - mn->size = size; /* this node is now exactly size big. */ - - dappend (&mn->node, &new->node); /* add the new node to big list */ - dappend (&mn->free, &new->free); /* add the new node to free list */ -#else - mem_node_t *new = mn; - new->size -= size + sizeof (mem_node_t); - mn = (mem_node_t *)(MNODES_MEM(new) + new->size); - mn->size = size; /* this node is now exactly size big. */ - n = &mn->free; - - dappend (&new->node, &mn->node); /* add the new node to big list */ - dappend (&new->free, &mn->free); /* add the new node to free list */ -#endif - - dremove (&mn->free); /* remove the old node from free list. */ - n->next = NULL; /* mark as removed. */ - n->prev = NULL; /* mark as removed. */ - - m->alloc_nodes++; /* increase the number of allocated nodes. */ - m->total -= (size + sizeof (mem_node_t)); - mem = (void *)&mn[1]; - break; - } - } - } - } - splx (s); - return (mem); -} - -static void -deallocate (mem_list_t *m, void *mem) -{ - int s = splhigh(); /* disable everything. */ - mem_node_t *mn = mem; /* point to the memory. */ - mem_node_t *next, *prev; - int added = 0; /* flag */ - mn--; /* now points to the node struct. */ - - /* check ahead of us. */ - next = (mem_node_t *)mn->node.next; - prev = (mem_node_t *)mn->node.prev; - if (next->node.next && next->free.next) { - /* if next is: a valid node and a free node. ==> merge */ - dinsert (&next->free, &mn->free); /* add onto free list */ - m->free_nodes++; - - dremove (&next->node); /* remove next from main list. */ - dremove (&next->free); /* remove next from free list. */ - m->free_nodes--; - m->alloc_nodes--; - m->total += mn->size + sizeof (mem_node_t); /* add our helpings to the pool. */ - added = 1; - mn->size += next->size + sizeof (mem_node_t); /* adjust to new size. */ - } - if (prev->node.prev && prev->free.prev) { - /* if prev is: a valid node and a free node. ==> merge */ - if (mn->free.next) { /* if we are on free list. */ - dremove (&mn->free); /* remove us from free list. */ - m->free_nodes--; - } - dremove (&mn->node); /* remove us from main list. */ - m->alloc_nodes--; - prev->size += mn->size + sizeof (mem_node_t); - if (added) { - m->total += sizeof (mem_node_t); - } else { - m->total += mn->size + sizeof (mem_node_t); /* add our helpings to the pool. */ - } - } else if (NULL == mn->free.next) { - /* we still are not on free list and we need to be. */ - while (next->node.next && prev->node.prev) { - if (next->free.next) { - dinsert (&next->free, &mn->free); - m->free_nodes++; - break; - } - if (prev->free.prev) { - dappend (&prev->free, &mn->free); - m->free_nodes++; - break; - } - prev = (mem_node_t *)prev->node.prev; - next = (mem_node_t *)next->node.next; - } - if (NULL == mn->free.next) { - if (NULL == next->node.next) { - /* we are not on list so we can add ourselves to the tail. (we walked to it.) */ - dadd_tail (&m->free_list, &mn->free); - } else { - dadd_head (&m->free_list, &mn->free); - } - m->free_nodes++; - } - m->total += mn->size; /* add our helpings to the pool. */ - } - splx (s); -} - -u_long -sizeof_chipmem (void *m) -{ - if (m) { - mem_node_t *mn = m; - mn--; - return (mn->size); - } - return (0); -} - -void * -alloc_chipmem (u_long size) -{ - u_long *mem; - - return (allocate (&chip, size)); -} - -void -free_chipmem (void *m) -{ - if (m) { - deallocate (&chip, m); - } -} - -u_long -avail_chipmem (int largest) -{ - u_long val = 0; - if (largest) { - int s = splhigh (); - dll_node_t *n; - - for (n = chip.free_list.head; n->next; n = n->next) { - mem_node_t *mn = MNODE_FROM_FREE (n); - if (mn->size > val) { - val = mn->size; - } - } - splx (s); - } else { - val = chip.total; - } - return (val); -} - - - -#if ! defined (AMIGA_TEST) -void -cc_init_chipmem (void) -{ - int s = splhigh (); - mem_node_t *mem; - extern u_byte *chipmem_end, *chipmem_start; - - chip.size = chipmem_end - (chipmem_start+NBPG); - chip.memory = (u_byte *)chipmem_steal (chip.size); - - chip.free_nodes = 1; - chip.alloc_nodes = 0; - chip.total = chip.size - sizeof (mem_node_t); - - mem = (mem_node_t *)chip.memory; - mem->size = chip.total; - - dinit_list (&chip.node_list); - dinit_list (&chip.free_list); - - dadd_head (&chip.node_list, &mem->node); - dadd_head (&chip.free_list, &mem->free); - splx (s); -} - -#else /* AMIGA_TEST */ -#include -#include - -void -cc_init_chipmem (void) -{ - mem_node_t *mem; - extern u_byte *chipmem_end, *chipmem_start; - - chip.size = 0x64000; /* allocate 400k */ - chip.memory = AllocMem (chip.size, MEMF_CHIP); - if (!chip.memory) { - panic ("no chip mem"); - } - chip.free_nodes = 1; - chip.alloc_nodes = 0; - chip.total = chip.size - sizeof (mem_node_t); - - mem = (mem_node_t *)chip.memory; - mem->size = chip.total; - - dinit_list (&chip.node_list); - dinit_list (&chip.free_list); - - dadd_head (&chip.node_list, &mem->node); - dadd_head (&chip.free_list, &mem->free); -} - -void -cc_deinit_chipmem (void) -{ - FreeMem (chip.memory, chip.size); -} -#endif /* AMIGA_TEST */ diff --git a/sys/arch/amiga/amiga/cc_chipmem.h b/sys/arch/amiga/amiga/cc_chipmem.h deleted file mode 100644 index 1b2c3b01d1fa..000000000000 --- a/sys/arch/amiga/amiga/cc_chipmem.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: cc_chipmem.h,v 1.2 1994/01/29 06:58:42 chopps Exp $ - */ -#if ! defined (_CC_CHIPMEM_H) -#define _CC_CHIPMEM_H - -#include "cc_types.h" -#include "dlists.h" - -typedef struct mem_node { - dll_node_t node; /* allways set. */ - dll_node_t free; /* only set when nodes are available */ - u_long size; /* indicates size of memory following node. */ -} mem_node_t; - -typedef struct mem_list { - dll_list_t free_list; - dll_list_t node_list; - u_long free_nodes; - u_long alloc_nodes; - u_long total; /* total free. */ - u_long size; /* size of it all. */ - u_byte *memory; /* all the memory. */ -} mem_list_t; - -#define CM_BLOCKSIZE 0x4 -#define CM_BLOCKMASK (~(CM_BLOCKSIZE - 1)) - -#define MNODE_FROM_FREE(n) ((mem_node_t *)(((u_long)n) - offsetof (mem_node_t, free))) -#define MNODES_MEM(mn) ((u_byte *)(&mn[1])) - -#if ! defined (AMIGA_TEST) -extern caddr_t CHIPMEMADDR; -#define PREP_DMA_MEM(mem) (void *)((caddr_t)mem - CHIPMEMADDR) -#else -#define PREP_DMA_MEM(mem) (mem) -#endif - -/* allocate chip memory. returns NULL if not enough available. */ -void * alloc_chipmem (u_long size); - -/* the memory to free or NULL. */ -void free_chipmem (void *m); - -/* returns total available or returns largest if ``largest'' not 0 */ -u_long avail_chipmem (int largest); - -/* returns the size of the given block of memory. */ -u_long sizeof_chipmem (void *m); - -void cc_init_chipmem (void); - -#if defined (AMIGA_TEST) -void cc_deinit_chipmem (void); -#endif - -#if ! defined (NULL) -#define NULL ((void *)0U) -#endif - -#endif /* _CC_CHIPMEM_H */ diff --git a/sys/arch/amiga/amiga/cc_copper.c b/sys/arch/amiga/amiga/cc_copper.c deleted file mode 100644 index 41f1ef9de382..000000000000 --- a/sys/arch/amiga/amiga/cc_copper.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: cc_copper.c,v 1.2 1994/01/29 06:58:44 chopps Exp $ - */ - -#include "cc_copper.h" - -/* Wait till end of frame. We should probably better use the - * sleep/wakeup system newly introduced in the vbl manager (ch?) */ -void -wait_tof (void) -{ - while (!(custom.vposr & 0x0007)) { /* wait until bottom of frame. - ; - } - while (custom.vposr & 0x0007) { /* wait until until top of frame. */ - ; - } - - if (!custom.vposr & 0x8000) { /* we are on short frame. */ - while (!(custom.vposr & 0x8000)) { /* wait for long frame bit set. */ - ; - } - } -} - -cop_t * -find_copper_inst (cop_t *l, u_word inst) -{ - cop_t *r = NULL; - while ((l->cp.data & 0xff01ff01) != 0xff01ff00) { - if (l->cp.inst.opcode == inst) { - r = l; - break; - } - l++; - } - return (r); -} - -void -install_copper_list (struct copper_list *l) -{ - wait_tof (); - wait_tof (); - custom.cop1lc = l; -} - - -#if ! defined (AMIGA_TEST) -void -cc_init_copper (void) -{ - -} - -#else /* AMIGA_TEST */ -#define HARDWARE_CUSTOM_H -#include -#include -#include -#include -#include -#include -#include -#include - -struct View *old; -struct Task *t; -extern struct GfxBase *GfxBase; -void -cc_init_copper (void) -{ - - old = GfxBase->ActiView; - t = FindTask (NULL); - SetTaskPri (t, 127); - LoadView (NULL); - WaitTOF (); - WaitTOF (); -} - -void -cc_deinit_copper (void) -{ - if (t) { - if (old) { - LoadView (old); - WaitTOF (); - WaitTOF (); - custom.cop1lc = GfxBase->copinit; - RethinkDisplay (); - } - SetTaskPri (t, 0); - } -} - -#endif - -/* level 3 interrupt */ -void -copper_handler (void) -{ - custom.intreq = INTF_COPER; -} diff --git a/sys/arch/amiga/amiga/cc_copper.h b/sys/arch/amiga/amiga/cc_copper.h deleted file mode 100644 index 67b3dcc8c80f..000000000000 --- a/sys/arch/amiga/amiga/cc_copper.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: cc_copper.h,v 1.3 1994/01/30 08:50:19 chopps Exp $ - */ -#if ! defined (_CC_COPPER_H) -#define _CC_COPPER_H - -#include "cc.h" - -typedef struct copper_list { - union j { - struct k { - u_word opcode; - u_word operand; - } inst; - u_long data; - } cp; -} cop_t; - -#define CI_MOVE(x) (0x7ffe & x) -#define CI_WAIT(h,v) (((0x7f&v)<<8)|(0xfe&h)|(0x0001)) -#define CI_SKIP(x) (((0x7f&v)<<8)|(0xfe&h)|(0x0001)) - -#define CD_MOVE(x) (x) -#define CD_WAIT(x) (x & 0xfffe) -#define CD_SKIP(x) (x|0x0001) - - -#define CBUMP(c) (c++) - -#define CMOVE(c,r,v) do { \ - c->cp.data=((CI_MOVE(r)<<16)|(CD_MOVE(v))); \ - CBUMP (c); \ - } while(0) -#define CWAIT(c,h,v) do { \ - c->cp.data=((CI_WAIT(h,v) << 16)|CD_WAIT(0xfffe)); \ - CBUMP (c); \ - } while(0) -#define CSKIP(c,h,v) do { \ - c->cp.data=((CI_SKIP(h,v)<<16)|CD_SKIP(0xffff)); \ - CBUMP (c); \ - } while(0) -#define CEND(c) do { \ - c->cp.data=0xfffffffe; \ - CBUMP (c); \ - } while(0) - -void install_copper_list (cop_t *l); -cop_t *find_copper_inst (cop_t *l, u_word inst); -void cc_init_copper (void); -void copper_handler (void); - -#if defined (AMIGA_TEST) -void cc_deinit_copper (void); -#endif - -#endif /* _CC_COPPER_H */ - diff --git a/sys/arch/amiga/amiga/cc_types.h b/sys/arch/amiga/amiga/cc_types.h deleted file mode 100644 index dc350b13c554..000000000000 --- a/sys/arch/amiga/amiga/cc_types.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: cc_types.h,v 1.2 1994/01/29 06:58:53 chopps Exp $ - */ - -#if ! defined (_TYPES_H) -#define _TYPES_H - -#if ! defined (_UWORD_T) -typedef unsigned short u_word; -#endif -#if ! defined (_UBYTE_T) -typedef unsigned char u_byte; -#endif -#if ! defined (_WORD_T) -typedef signed short word; -#endif -#if ! defined (_BYTE_T) -typedef signed char byte; -#endif -#if ! defined (_BOOL_T) -typedef enum boolean { false, true } bool_t; -#endif - -#endif /* _TYPES_H */ diff --git a/sys/arch/amiga/amiga/cc_vbl.c b/sys/arch/amiga/amiga/cc_vbl.c deleted file mode 100644 index c7e1f93c3d96..000000000000 --- a/sys/arch/amiga/amiga/cc_vbl.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: cc_vbl.c,v 1.2 1994/01/29 06:58:54 chopps Exp $ - */ - -/* structure for a vbl_function. */ -struct vbl_node; /* shut gcc up about no structure. */ - -#define CC_VBL_C -#include "types.h" -#include "cc_types.h" -#include "cc_vbl.h" - -/*================================================== - * Internal structures. - *==================================================*/ - -/* Vertical Blank */ -struct vbl_node { - dll_node_t node; /* Private. */ - short priority; /* Private. */ - short flags; /* Private. */ - void (*function)(register void *); /* put your function pointer here. */ - void *data; /* functions data. */ -}; - -enum vbl_node_bits { - VBLNB_OFF, /* don't call me right now. */ - VBLNB_TURNOFF, /* turn function off. */ - VBLNB_REMOVE, /* remove me on next vbl round and clear flag. */ -}; - -enum vlb_node_flags { - VBLNF_OFF = 1 << VBLNB_OFF, - VBLNF_TURNOFF = 1 << VBLNB_TURNOFF, - VBLNF_REMOVE = 1 << VBLNB_REMOVE, -}; - - -/*================================================== - * Global structures - *==================================================*/ - -/* - vbl_list */ -/* the actual vbl list only the vbl handler allowed to touch this list. */ -static dll_list_t vbl_list; - -/* - vbl_sync */ -/* if this is set to 1 when the vbl handler is called, it resets it to zero when done. */ -static int vbl_sync_flag; - -/* - vbl enabled */ -/* if this is set to 1 then the vbl handler will perform, otherwise will only reset the */ -/* vbl_sync flag. */ -static int vbl_disabled; - -/*================================================== - * INLINES - *==================================================*/ -/* this function will return as soon as the vertical blank has finished. */ -void inline -vbl_sync (void) -{ - vbl_sync_flag = 1; - while (vbl_sync_flag) - ; -} - -void inline -vbl_disable (void) -{ - vbl_disabled++; -} - -void inline -vbl_enable (void) -{ - if (vbl_disabled) { - vbl_disabled--; - } else { - /* probably should panic */ - } -} - -/*================================================== - * VERTICAL BLANK HANDLERS - *==================================================*/ - -void vbl_handler (void); -/* structure for a vbl_function. */ - -struct vbl_node *add_node; /* function to add to the list. */ - - -void -wait_for_vbl_function_removal (struct vbl_node *n) -{ - if (n->node.next) { - while (n->flags & VBLNF_REMOVE) - ; - } else { - /* probably should panic */ - } -} - -void -turn_vbl_function_off (struct vbl_node *n) -{ - if (!(n->flags & VBLNF_OFF)) { - n->flags |= VBLNF_TURNOFF; /* mark to turn off. */ - while (!(n->flags & VBLNF_OFF)) /* wait for this to occur. */ - ; - } -} - -/* allow function to be called on next vbl interrupt. */ -void -turn_vbl_function_on (struct vbl_node *n) -{ - n->flags &= (short) ~(VBLNF_OFF); -} - -/* walk list search for correct spot to place node. */ -/* WARNING: do not call this function from interrupts that have a */ -/* higher priority than VBL (HL3) */ -void -add_vbl_function (struct vbl_node *add, short priority, void *data) -{ - /* we are executing in top half of kernel and so we are syncronous. */ - u_word ie = custom.intenar; - struct vbl_node *n; - - add->data = data; - if (ie & INTF_INTEN) { - /* master interrupts enabled. */ - vbl_disable (); /* disable the handler. */ - if (ie & INTF_VERTB) { - /* vertical blank interrupts enabled */ - vbl_enable (); /* enable the handler. */ - add_node = add; /* set add node it will be added on next vbl. */ - - while (add_node) { /* wait for vbl it will clear add node after */ - ; /* doing this. then exit. */ - } - return; - } - } - /* NOTE: if master interrupts are enabled but VBL are not, our handler */ - /* will be disabled so that no chance of a interupted list manipulation */ - /* is possible. this could happen IF poor interrupt coding practices have */ - /* been implemented and a interrupt occurs that upstages us and */ - /* re-enables VBL interrupts. (ICK) I don't think this is the case but */ - /* I might as well guard against it. (its only 3 inline C instructions.)*/ - - for (n = (struct vbl_node *)vbl_list.head; n->node.next; n = (struct vbl_node *)n->node.next) { - if (add->priority > n->priority) { - dinsert (&n->node, &add->node); /* insert add_node before. */ - add = NULL; - break; - } - } - if (add) { - dadd_tail (&vbl_list, &add->node); /* add node to tail. */ - } - if (ie & INTF_VERTB) { - vbl_enable (); /* enable handler if nec. */ - } -} - -void -remove_vbl_function (struct vbl_node *n) -{ - n->flags |= VBLNF_REMOVE; -} - - -/* This is executing in bottom half of kernel. (read: anytime.) */ -void inline -vbl_call_function (struct vbl_node *n) -{ - /* handle case of NULL */ - if (n && !(n->flags & VBLNF_OFF)) { - n->function (n->data); - } -} - -/* This is executing in bottom half of kernel. (read: anytime.) */ -/* Level 3 hardware interrupt */ -void -vbl_handler (void) -{ - struct vbl_node *n, *tmp; - - vbl_sync_flag = 0; /* always written to. */ - - /* if not enabled skip everything. */ - if (vbl_disabled) { - goto ret_int; /* NOTE: end of function. */ - } - - /* handle all vbl functions */ - for (n = (struct vbl_node *)vbl_list.head; n->node.next; n = tmp) { - if (add_node && add_node->priority > n->priority) { - dinsert (&n->node, &add_node->node); /* insert add_node before. */ - n = add_node; /* process add_node first. */ - add_node = NULL; /* and signal we are done with add_node. */ - } - tmp = (struct vbl_node *)n->node.next; - if (n->flags & VBLNF_REMOVE) { - dremove (&n->node); /* remove the node. */ - n->flags &= ~(VBLNF_REMOVE); /* mark as removed. */ - n->node.next = NULL; /* for sanity checks. */ - } else if (n->flags & VBLNF_TURNOFF) { - n->flags |= VBLNF_OFF; - n->flags &= ~(VBLNF_TURNOFF); - } else { - vbl_call_function (n); /* execute the interrupt. */ - } - } - if (add_node) { - dadd_tail (&vbl_list, &add_node->node); /* add node to tail. */ - vbl_call_function (add_node); /* call it. */ - add_node = NULL; /* signal we are done with it. */ - } - ret_int: - custom.intreq = INTF_VERTB; -} - -#if ! defined (AMIGA_TEST) -void -cc_init_vbl (void) -{ - dinit_list (&vbl_list); - custom.intena = INTF_SETCLR | INTF_VERTB; /* init vertical blank interrupts */ -} - -#else /* AMIGA_TEST */ -#include -#include - -void -test_vbl_handler (void) -{ - vbl_handler (); -} - -struct Interrupt test_vbl; - -void -cc_init_vbl (void) -{ - test_vbl.is_Code = vbl_handler; - dinit_list (&vbl_list); - AddIntServer (INTB_VERTB, &test_vbl); -} - -void -cc_deinit_vbl (void) -{ - vbl_disable (); - vbl_sync (); - RemIntServer (INTB_VERTB, &test_vbl); -} -#endif /*AMIGA_TEST*/ diff --git a/sys/arch/amiga/amiga/cc_vbl.h b/sys/arch/amiga/amiga/cc_vbl.h deleted file mode 100644 index 60812c175fc5..000000000000 --- a/sys/arch/amiga/amiga/cc_vbl.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: cc_vbl.h,v 1.2 1994/01/29 06:58:56 chopps Exp $ - */ -#if ! defined (_CC_VBL_H) -#define _CC_VBL_H - -#include "cc.h" - -#if ! defined (CC_VBL_C) -/* structure for a vbl_function. */ -struct vbl_node { - dll_node_t resv0; /* Private. */ - short resv1; /* Private. */ - short resv2; /* Private. */ - void (*function)(void *); /* put your function pointer here. */ - void *resv3; -}; -#endif /* CC_MISC_C */ - -void cc_init_vbl (void); - -#if defined (AMIGA_TEST) -void cc_deinit_vbl (void); -#endif - -/* function only returns after it has added the vbl function. */ -void add_vbl_function (struct vbl_node *n, short priority, void *data); - -/* this functon returns immediatly. */ -void remove_vbl_function (struct vbl_node *n); - -/* this function returns when the function has actually been removed. */ -void wait_for_vbl_function_removal (struct vbl_node *n); - -/* this function returns when vbl function is off. */ -void turn_vbl_function_off (struct vbl_node *n); - -/* this function returns immediatley. */ -void turn_vbl_function_on (struct vbl_node *n); - -#endif /* _CC_MISC_H */ diff --git a/sys/arch/amiga/amiga/pte.h b/sys/arch/amiga/amiga/pte.h deleted file mode 100644 index f93db3ad7f22..000000000000 --- a/sys/arch/amiga/amiga/pte.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: pte.h 1.11 89/09/03$ - * - * @(#)pte.h 7.3 (Berkeley) 5/8/91 - * $Id: pte.h,v 1.5 1994/02/11 06:59:55 chopps Exp $ - */ - -#ifndef _PTE_H -#define _PTE_H -/* - * AMIGA hardware segment/page table entries - */ - -struct ste { - unsigned int sg_pfnum:20; /* page table frame number */ - unsigned int :8; /* reserved at 0 */ - unsigned int :1; /* reserved at 1 */ - unsigned int sg_prot:1; /* write protect bit */ - unsigned int sg_v:2; /* valid bits */ -}; - -struct pte { - unsigned int pg_pfnum:20; /* page frame number or 0 */ - unsigned int :3; - unsigned int pg_w:1; /* is wired */ - unsigned int :1; /* reserved at zero */ - unsigned int pg_ci:1; /* cache inhibit bit */ - unsigned int pg_cm1:1; /* cache mode, lsb (68040) */ - unsigned int pg_m:1; /* hardware modified (dirty) bit */ - unsigned int pg_u:1; /* hardware used (reference) bit */ - unsigned int pg_prot:1; /* write protect bit */ - unsigned int pg_v:2; /* valid bit */ -}; - -typedef struct ste st_entry_t; /* segment table entry */ -typedef struct pte pt_entry_t; /* Mach page table entry */ - -#define PT_ENTRY_NULL ((pt_entry_t *) 0) -#define ST_ENTRY_NULL ((st_entry_t *) 0) - -#define SG_V 0x00000002 /* segment is valid */ -#define SG_NV 0x00000000 -#define SG_PROT 0x00000004 /* access protection mask */ -#define SG_RO 0x00000004 -#define SG_RW 0x00000000 -#define SG_FRAME 0xffffe000 -#define SG_IMASK1 0xfe000000 -#define SG_IMASK2 0x01fc0000 -#define SG_040IMASK 0xfffc0000 -#define SG_040PMASK 0x0003e000 -#define SG_ISHIFT1 25 -#define SG_040ISHIFT 18 -#define SG_IMASK 0xff000000 -#define SG_PMASK 0x00ffe000 -#define SG_ISHIFT 24 -#define SG_PSHIFT 13 - - -#define PG_V 0x00000001 -#define PG_NV 0x00000000 -#define PG_PROT 0x00000004 -#define PG_U 0x00000008 -#define PG_M 0x00000010 -#define PG_W 0x00000100 -#define PG_RO 0x00000004 -#define PG_RW 0x00000000 -#define PG_CI 0x00000040 -#define PG_CC 0x00000020 /* Cachable, copyback */ -#define PG_CIN 0x00000060 /* Cache inhibited, nonserialized */ -#define PG_FRAME 0xffffe000 -#define PG_SHIFT 13 -#define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT) - -#define AMIGA_040RTSIZE 512 /* root (level 1) table size */ -#define AMIGA_040STSIZE 512 /* segment (level 2) table size */ -#define AMIGA_040PTSIZE 128 /* page (level 3) table size */ -#define AMIGA_STSIZE 1024 /* segment table size */ -#define AMIGA_MAX_PTSIZE (2*1024*1024) /* max size of UPT */ -/* XXX probably have to reduce this to 512k */ -#define AMIGA_MAX_KPTSIZE 0x100000 /* max memory to allocate to KPT */ -#define AMIGA_PTBASE 0x10000000 /* UPT map base address */ -#define AMIGA_PTMAXSIZE 0x70000000 /* UPT map maximum size */ - -/* - * Kernel virtual address to page table entry and to physical address. - */ -#define kvtopte(va) \ - (&Sysmap[((unsigned)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT]) -#define ptetokv(pt) \ - ((((pt_entry_t *)(pt) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS) -#define kvtophys(va) \ - ((kvtopte(va)->pg_pfnum << PGSHIFT) | ((int)(va) & PGOFSET)) - - -#endif /* _PTE_H */ diff --git a/sys/arch/amiga/compile/AMIGA/ioconf.c b/sys/arch/amiga/compile/AMIGA/ioconf.c deleted file mode 100644 index 233b8d1e4121..000000000000 --- a/sys/arch/amiga/compile/AMIGA/ioconf.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "sys/param.h" -#include "sys/buf.h" - -#include "arch/amiga/dev/device.h" - - -#define C (caddr_t) -#define D (struct driver *) - -extern struct driver scsidriver; -extern struct driver serdriver; -extern struct driver sddriver; -extern struct driver sddriver; -extern struct driver sddriver; -extern struct driver sddriver; -extern struct driver sddriver; -extern struct driver sddriver; -extern struct driver sddriver; -extern struct driver stdriver; -extern struct driver stdriver; -extern struct driver grfdriver; - -struct amiga_ctlr amiga_cinit[] = { -/* driver, unit, alive, addr, flags */ - { &scsidriver, 0, 0, C 0x10001, 0x0 }, - 0 -}; - -struct amiga_device amiga_dinit[] = { -/*driver, cdriver, unit, ctlr, slave, addr, dk, flags*/ -{ &serdriver, D 0x0, 0, -1, -1, C 0x10003, 0, 0x0 }, -{ &sddriver, &scsidriver, 0, 0, 0, C 0x0, 1, 0x0 }, -{ &sddriver, &scsidriver, 1, 0, 1, C 0x0, 1, 0x0 }, -{ &sddriver, &scsidriver, 2, 0, 2, C 0x0, 1, 0x0 }, -{ &sddriver, &scsidriver, 3, 0, 3, C 0x0, 1, 0x0 }, -{ &sddriver, &scsidriver, 4, 0, 4, C 0x0, 1, 0x0 }, -{ &sddriver, &scsidriver, 5, 0, 5, C 0x0, 1, 0x0 }, -{ &sddriver, &scsidriver, 6, 0, 6, C 0x0, 1, 0x0 }, -{ &stdriver, &scsidriver, 0, 0, 4, C 0x0, 0, 0x0 }, -{ &stdriver, &scsidriver, 1, 0, 5, C 0x0, 0, 0x0 }, -{ &grfdriver, D 0x0, 0, -1, -1, C 0x10007, 0, 0x0 }, -0 -}; diff --git a/sys/arch/amiga/compile/AMIGA/ite.X b/sys/arch/amiga/compile/AMIGA/ite.X deleted file mode 100644 index 25aa6042a4eb..000000000000 --- a/sys/arch/amiga/compile/AMIGA/ite.X +++ /dev/null @@ -1,129 +0,0 @@ -/* compiled from: . */ -/* ../../../../sys/ucred.h:54:OC */ extern struct ucred *crget (/* ??? */); -/* ../../../../sys/ucred.h:55:OC */ extern struct ucred *crcopy (/* ??? */); -/* ../../../../sys/ucred.h:56:OC */ extern struct ucred *crdup (/* ??? */); -/* ../../../../sys/signal.h:102:NC */ extern int sigaddset (sigset_t *, int); -/* ../../../../sys/signal.h:103:NC */ extern int sigdelset (sigset_t *, int); -/* ../../../../sys/signal.h:104:NC */ extern int sigemptyset (sigset_t *); -/* ../../../../sys/signal.h:105:NC */ extern int sigfillset (sigset_t *); -/* ../../../../sys/signal.h:106:NC */ extern int sigismember (const sigset_t *, int); -/* ./machine/param.h:182:OC */ extern void DELAY (/* ??? */); -/* ./machine/endian.h:51:NC */ extern long unsigned int htonl (long unsigned int); -/* ./machine/endian.h:52:NC */ extern short unsigned int htons (short unsigned int); -/* ./machine/endian.h:53:NC */ extern long unsigned int ntohl (long unsigned int); -/* ./machine/endian.h:54:NC */ extern short unsigned int ntohs (short unsigned int); -/* ../../../../sys/select.h:44:NC */ extern void selrecord (struct proc *, struct selinfo *); -/* ../../../../sys/select.h:47:NC */ extern void selwakeup (struct selinfo *); -/* ../../../../sys/proc.h:232:OC */ extern struct proc *pfind (/* ??? */); -/* ../../../../sys/proc.h:234:OC */ extern struct pgrp *pgfind (/* ??? */); -/* ../../../../sys/systm.h:82:NC */ extern int nullop (void); -/* ../../../../sys/systm.h:83:NC */ extern int enodev (void); -/* ../../../../sys/systm.h:84:NC */ extern int enoioctl (void); -/* ../../../../sys/systm.h:85:NC */ extern int enxio (void); -/* ../../../../sys/systm.h:86:NC */ extern int eopnotsupp (void); -/* ../../../../sys/systm.h:88:NC */ extern int selscan (struct proc *, fd_set *, fd_set *, int, int *); -/* ../../../../sys/systm.h:89:NC */ extern int seltrue (dev_t, int, struct proc *); -/* ../../../../sys/systm.h:95:NC */ extern void panic (char *); -/* ../../../../sys/systm.h:96:NC */ extern void tablefull (char *); -/* ../../../../sys/systm.h:97:NC */ extern void addlog (const char *, ...); -/* ../../../../sys/systm.h:98:NC */ extern void log (int, const char *, ...); -/* ../../../../sys/systm.h:99:NC */ extern void printf (const char *, ...); -/* ../../../../sys/systm.h:100:NC */ extern int sprintf (char *, const char *, ...); -/* ../../../../sys/systm.h:101:NC */ extern void ttyprintf (struct tty *, const char *, ...); -/* ../../../../sys/systm.h:103:NC */ extern void bcopy (void *, void *, u_int); -/* ../../../../sys/systm.h:104:NC */ extern void ovbcopy (void *, void *, u_int); -/* ../../../../sys/systm.h:105:NC */ extern void bzero (void *, u_int); -/* ../../../../sys/systm.h:106:NC */ extern int bcmp (void *, void *, u_int); -/* ../../../../sys/systm.h:107:NC */ extern int strlen (const char *); -/* ../../../../sys/systm.h:109:NC */ extern int copystr (void *, void *, u_int, u_int *); -/* ../../../../sys/systm.h:110:NC */ extern int copyinstr (void *, void *, u_int, u_int *); -/* ../../../../sys/systm.h:111:NC */ extern int copyoutstr (void *, void *, u_int, u_int *); -/* ../../../../sys/systm.h:112:NC */ extern int copyin (void *, void *, u_int); -/* ../../../../sys/systm.h:113:NC */ extern int copyout (void *, void *, u_int); -/* ../../../../sys/systm.h:115:NC */ extern int fubyte (void *); -/* ../../../../sys/systm.h:119:NC */ extern int subyte (void *, int); -/* ../../../../sys/systm.h:120:NC */ extern int suibyte (void *, int); -/* ../../../../sys/systm.h:121:NC */ extern int fuword (void *); -/* ../../../../sys/systm.h:122:NC */ extern int fuiword (void *); -/* ../../../../sys/systm.h:123:NC */ extern int suword (void *, int); -/* ../../../../sys/systm.h:124:NC */ extern int suiword (void *, int); -/* ../../../../sys/systm.h:126:NC */ extern int scanc (unsigned int, u_char *, u_char *, int); -/* ../../../../sys/systm.h:127:NC */ extern int skpc (int, int, char *); -/* ../../../../sys/systm.h:128:NC */ extern int locc (int, char *, unsigned int); -/* ../../../../sys/systm.h:129:NC */ extern int ffs (long int); -/* ../../../../sys/malloc.h:270:NC */ extern void *malloc (long unsigned int, int, int); -/* ../../../../sys/malloc.h:271:NC */ extern void free (void *, int); -/* ../../../../arch/amiga/dev/ite.c:74:OC */ extern int nodev (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:76:OC */ extern int customc_scroll (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:76:OC */ extern int customc_init (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:76:OC */ extern int customc_deinit (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:77:OC */ extern int customc_clear (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:77:OC */ extern int customc_putc (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:77:OC */ extern int customc_cursor (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:79:OC */ extern int tiga_scroll (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:79:OC */ extern int tiga_init (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:79:OC */ extern int tiga_deinit (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:80:OC */ extern int tiga_clear (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:80:OC */ extern int tiga_putc (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:80:OC */ extern int tiga_cursor (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:106:OC */ extern int itestart (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:107:OC */ extern int ttrstrt (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:125:OF */ extern int iteon (dev_t dev, int flag); /* (dev, flag) dev_t dev; int flag; */ -/* ../../../../arch/amiga/dev/ite.c:149:IC */ extern int kbdenable (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:151:IC */ extern int iteinit (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:156:OF */ extern int iteinit (dev_t dev); /* (dev) dev_t dev; */ -/* ../../../../arch/amiga/dev/ite.c:197:OF */ extern int iteoff (dev_t dev, int flag); /* (dev, flag) dev_t dev; int flag; */ -/* ../../../../arch/amiga/dev/ite.c:221:NF */ extern int iteopen (dev_t dev, int mode, int devtype, struct proc *p); /* (dev, mode, devtype, p) dev_t dev; int mode; int devtype; struct proc *p; */ -/* ../../../../arch/amiga/dev/ite.c:248:IC */ extern int ttychars (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:257:IC */ extern int ttsetwater (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:270:OF */ extern int iteclose (dev_t dev, int flag, int mode, struct proc *p); /* (dev, flag, mode, p) dev_t dev; int flag; int mode; struct proc *p; */ -/* ../../../../arch/amiga/dev/ite.c:277:IC */ extern int ttyclose (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:288:OF */ extern int iteread (dev_t dev, struct uio *uio, int flag); /* (dev, uio, flag) dev_t dev; struct uio *uio; int flag; */ -/* ../../../../arch/amiga/dev/ite.c:299:OF */ extern int itewrite (dev_t dev, struct uio *uio, int flag); /* (dev, uio, flag) dev_t dev; struct uio *uio; int flag; */ -/* ../../../../arch/amiga/dev/ite.c:312:OF */ extern int iteioctl (dev_t dev, int cmd, caddr_t addr, int flag); /* (dev, cmd, addr, flag) dev_t dev; int cmd; caddr_t addr; int flag; */ -/* ../../../../arch/amiga/dev/ite.c:321:IC */ extern int ttioctl (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:328:OF */ extern int itestart (register struct tty *tp); /* (tp) register struct tty *tp; */ -/* ../../../../arch/amiga/dev/ite.c:335:IC */ extern int spl0 (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:343:IC */ extern int wakeup (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:358:IC */ extern int getc (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:368:IC */ extern int spl0 (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:369:IC */ extern int iteputchar (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:374:IC */ extern int timeout (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:377:IC */ extern int spl0 (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:386:OF */ static void repeat_handler (int a0, int a1); /* (a0, a1) int a0; int a1; */ -/* ../../../../arch/amiga/dev/ite.c:391:IC */ extern int itefilter (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:397:OF */ extern int itefilter (register u_char c, enum caller caller); /* (c, caller) register u_char c; enum caller caller; */ -/* ../../../../arch/amiga/dev/ite.c:475:IC */ extern int untimeout (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:524:IC */ extern int timeout (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:530:IC */ extern int timeout (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:589:OF */ static void ite_dchar (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:602:OF */ static void ite_ichar (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:615:OF */ static void ite_clrtoeol (struct ite_softc *ip, struct itesw *sp, int y, int x); /* (ip, sp, y, x) struct ite_softc *ip; struct itesw *sp; int y; int x; */ -/* ../../../../arch/amiga/dev/ite.c:626:OF */ static void ite_clrtobol (struct ite_softc *ip, struct itesw *sp, int y, int x); /* (ip, sp, y, x) struct ite_softc *ip; struct itesw *sp; int y; int x; */ -/* ../../../../arch/amiga/dev/ite.c:637:OF */ static void ite_clrline (struct ite_softc *ip, struct itesw *sp, int y, int x); /* (ip, sp, y, x) struct ite_softc *ip; struct itesw *sp; int y; int x; */ -/* ../../../../arch/amiga/dev/ite.c:650:OF */ static void ite_clrtoeos (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:660:OF */ static void ite_clrtobos (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:670:OF */ static void ite_clrscreen (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:682:OF */ static void ite_dline (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:693:OF */ static void ite_iline (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:704:OF */ static void ite_lf (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:720:OF */ static void ite_crlf (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:729:OF */ static void ite_cr (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:741:OF */ static void ite_rlf (struct ite_softc *ip, struct itesw *sp); /* (ip, sp) struct ite_softc *ip; struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:756:OF */ static int atoi (const char *cp); /* (cp) const char *cp; */ -/* ../../../../arch/amiga/dev/ite.c:768:OF */ static char *index (const char *cp, char ch); /* (cp, ch) const char *cp; char ch; */ -/* ../../../../arch/amiga/dev/ite.c:779:OF */ static int ite_argnum (struct ite_softc *ip); /* (ip) struct ite_softc *ip; */ -/* ../../../../arch/amiga/dev/ite.c:797:OF */ static int ite_zargnum (struct ite_softc *ip); /* (ip) struct ite_softc *ip; */ -/* ../../../../arch/amiga/dev/ite.c:815:OF */ static void ite_sendstr (struct ite_softc *ip, char *str); /* (ip, str) struct ite_softc *ip; char *str; */ -/* ../../../../arch/amiga/dev/ite.c:824:OF */ static int strncmp (const char *a, const char *b, int l); /* (a, b, l) const char *a; const char *b; int l; */ -/* ../../../../arch/amiga/dev/ite.c:835:OF */ extern int iteputchar (register int c, dev_t dev); /* (c, dev) register int c; dev_t dev; */ -/* ../../../../arch/amiga/dev/ite.c:1495:IC */ extern int itecheckwrap (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:1500:IC */ extern int kbdbell (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:1597:OF */ extern int itecheckwrap (register struct ite_softc *ip, register struct itesw *sp); /* (ip, sp) register struct ite_softc *ip; register struct itesw *sp; */ -/* ../../../../arch/amiga/dev/ite.c:1630:OF */ extern int itecnprobe (struct consdev *cp); /* (cp) struct consdev *cp; */ -/* ../../../../arch/amiga/dev/ite.c:1641:IC */ extern int grfconfig (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:1684:OF */ extern int itecninit (struct consdev *cp); /* (cp) struct consdev *cp; */ -/* ../../../../arch/amiga/dev/ite.c:1692:IC */ extern int kbdenable (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:1697:OF */ extern int itecngetc (dev_t dev); /* (dev) dev_t dev; */ -/* ../../../../arch/amiga/dev/ite.c:1703:IC */ extern int kbdgetcn (/* ??? */); -/* ../../../../arch/amiga/dev/ite.c:1712:OF */ extern int itecnputc (dev_t dev, int c); /* (dev, c) dev_t dev; int c; */ diff --git a/sys/arch/amiga/compile/AMIGA/ite.h b/sys/arch/amiga/compile/AMIGA/ite.h deleted file mode 100644 index 939ccb7df9c4..000000000000 --- a/sys/arch/amiga/compile/AMIGA/ite.h +++ /dev/null @@ -1 +0,0 @@ -#define NITE 1 diff --git a/sys/arch/amiga/compile/AMIGA/loop.h b/sys/arch/amiga/compile/AMIGA/loop.h deleted file mode 100644 index 15a837a81005..000000000000 --- a/sys/arch/amiga/compile/AMIGA/loop.h +++ /dev/null @@ -1 +0,0 @@ -#define NLOOP 1 diff --git a/sys/arch/amiga/compile/AMIGA/param.c b/sys/arch/amiga/compile/AMIGA/param.c deleted file mode 100644 index 1a9c36db9933..000000000000 --- a/sys/arch/amiga/compile/AMIGA/param.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 1980, 1986, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)param.c 7.20 (Berkeley) 6/27/91 - * $Id: param.c,v 1.2 1993/08/01 19:22:57 mycroft Exp $ - */ - -#include "sys/param.h" -#include "sys/systm.h" -#include "sys/socket.h" -#include "sys/proc.h" -#include "sys/vnode.h" -#include "sys/file.h" -#include "sys/callout.h" -#include "sys/clist.h" -#include "sys/mbuf.h" -#include "ufs/quota.h" -#include "sys/kernel.h" -#include "sys/utsname.h" -#ifdef SYSVSHM -#include "machine/vmparam.h" -#include "sys/shm.h" -#endif - -/* - * System parameter formulae. - * - * This file is copied into each directory where we compile - * the kernel; it should be modified there to suit local taste - * if necessary. - * - * Compiled with -DHZ=xx -DTIMEZONE=x -DDST=x -DMAXUSERS=xx -DMAXFDESCS=xx - */ - -#ifndef HZ -#define HZ 100 -#endif -int hz = HZ; -int tick = 1000000 / HZ; -int tickadj = 240000 / (60 * HZ); /* can adjust 240ms in 60s */ -struct timezone tz = { TIMEZONE, DST }; -#define NPROC (20 + 16 * MAXUSERS) -int maxproc = NPROC; -#define NTEXT (80 + NPROC / 8) /* actually the object cache */ -#define NVNODE (NPROC + NTEXT + 100) -long desiredvnodes = NVNODE; -int maxfdescs = MAXFDESCS; -int maxfiles = 3 * (NPROC + MAXUSERS) + 80; -int ncallout = 16 + NPROC; -int nclist = 60 + 12 * MAXUSERS; -int nmbclusters = NMBCLUSTERS; -int fscale = FSCALE; /* kernel uses `FSCALE', user uses `fscale' */ - -/* - * Values in support of System V compatible shared memory. XXX - */ -#ifdef SYSVSHM -#define SHMMAX (SHMMAXPGS*NBPG) -#define SHMMIN 1 -#define SHMMNI 32 /* <= SHMMMNI in shm.h */ -#define SHMSEG 8 -#define SHMALL (SHMMAXPGS/CLSIZE) - -struct shminfo shminfo = { - SHMMAX, - SHMMIN, - SHMMNI, - SHMSEG, - SHMALL -}; -#endif - -/* - * These are initialized at bootstrap time - * to values dependent on memory size - */ -int nbuf, nswbuf; - -/* - * These have to be allocated somewhere; allocating - * them here forces loader errors if this file is omitted - * (if they've been externed everywhere else; hah!). - */ -struct callout *callout; -struct cblock *cfree; -struct buf *buf, *swbuf; -char *buffers; - -/* - * Proc/pgrp hashing. - * Here so that hash table sizes can depend on MAXUSERS/NPROC. - * Hash size must be a power of two. - * NOW omission of this file will cause loader errors! - */ - -#if NPROC > 1024 -#define PIDHSZ 512 -#else -#if NPROC > 512 -#define PIDHSZ 256 -#else -#if NPROC > 256 -#define PIDHSZ 128 -#else -#define PIDHSZ 64 -#endif -#endif -#endif - -struct proc *pidhash[PIDHSZ]; -struct pgrp *pgrphash[PIDHSZ]; -int pidhashmask = PIDHSZ - 1; - -struct utsname utsname; diff --git a/sys/arch/amiga/compile/AMIGA/ppp.h b/sys/arch/amiga/compile/AMIGA/ppp.h deleted file mode 100644 index 8468e441c10a..000000000000 --- a/sys/arch/amiga/compile/AMIGA/ppp.h +++ /dev/null @@ -1 +0,0 @@ -#define NPPP 4 diff --git a/sys/arch/amiga/compile/AMIGA/pty.h b/sys/arch/amiga/compile/AMIGA/pty.h deleted file mode 100644 index 3f5c54e28d46..000000000000 --- a/sys/arch/amiga/compile/AMIGA/pty.h +++ /dev/null @@ -1 +0,0 @@ -#define NPTY 1 diff --git a/sys/arch/amiga/compile/AMIGA/scsi.h b/sys/arch/amiga/compile/AMIGA/scsi.h deleted file mode 100644 index 77375b11043c..000000000000 --- a/sys/arch/amiga/compile/AMIGA/scsi.h +++ /dev/null @@ -1 +0,0 @@ -#define NSCSI 1 diff --git a/sys/arch/amiga/compile/AMIGA/sd.h b/sys/arch/amiga/compile/AMIGA/sd.h deleted file mode 100644 index 316f1ed6c244..000000000000 --- a/sys/arch/amiga/compile/AMIGA/sd.h +++ /dev/null @@ -1 +0,0 @@ -#define NSD 7 diff --git a/sys/arch/amiga/compile/AMIGA/ser.h b/sys/arch/amiga/compile/AMIGA/ser.h deleted file mode 100644 index 6e65844daaed..000000000000 --- a/sys/arch/amiga/compile/AMIGA/ser.h +++ /dev/null @@ -1 +0,0 @@ -#define NSER 1 diff --git a/sys/arch/amiga/compile/AMIGA/sl.h b/sys/arch/amiga/compile/AMIGA/sl.h deleted file mode 100644 index b3bbcbf7adee..000000000000 --- a/sys/arch/amiga/compile/AMIGA/sl.h +++ /dev/null @@ -1 +0,0 @@ -#define NSL 4 diff --git a/sys/arch/amiga/compile/AMIGA/st.h b/sys/arch/amiga/compile/AMIGA/st.h deleted file mode 100644 index a61c1734f682..000000000000 --- a/sys/arch/amiga/compile/AMIGA/st.h +++ /dev/null @@ -1 +0,0 @@ -#define NST 7 diff --git a/sys/arch/amiga/compile/AMIGA/swappager.h b/sys/arch/amiga/compile/AMIGA/swappager.h deleted file mode 100644 index f7fc14c0b89f..000000000000 --- a/sys/arch/amiga/compile/AMIGA/swappager.h +++ /dev/null @@ -1 +0,0 @@ -#define NSWAPPAGER 1 diff --git a/sys/arch/amiga/compile/AMIGA/swapvmunix.c b/sys/arch/amiga/compile/AMIGA/swapvmunix.c deleted file mode 100644 index 9d8d2e17c3ef..000000000000 --- a/sys/arch/amiga/compile/AMIGA/swapvmunix.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "sys/param.h" -#include "sys/conf.h" - -dev_t rootdev = makedev(4, 48); -dev_t dumpdev = makedev(4, 49); - -struct swdevt swdevt[] = { - { makedev(4, 49), 0, 0 }, /* sd6b */ - { 0, 0, 0 } -}; diff --git a/sys/arch/amiga/compile/AMIGA/tb.h b/sys/arch/amiga/compile/AMIGA/tb.h deleted file mode 100644 index 5799b0ab1819..000000000000 --- a/sys/arch/amiga/compile/AMIGA/tb.h +++ /dev/null @@ -1 +0,0 @@ -#define NTB 0 diff --git a/sys/arch/amiga/compile/AMIGA/tun.h b/sys/arch/amiga/compile/AMIGA/tun.h deleted file mode 100644 index e87ab5825ac2..000000000000 --- a/sys/arch/amiga/compile/AMIGA/tun.h +++ /dev/null @@ -1 +0,0 @@ -#define NTUN 0 diff --git a/sys/arch/amiga/compile/AMIGA/vers.c b/sys/arch/amiga/compile/AMIGA/vers.c deleted file mode 100644 index 915b0d8319d5..000000000000 --- a/sys/arch/amiga/compile/AMIGA/vers.c +++ /dev/null @@ -1 +0,0 @@ -char version[] = "NetBSD 0.8a () #390: Monday 05-Jul-93 06:55:18\n mw@amiga:/IBAEM4/NetBSD/usr/src/sys/arch/amiga/compile/AMIGA\n"; diff --git a/sys/arch/amiga/compile/AMIGA/version b/sys/arch/amiga/compile/AMIGA/version deleted file mode 100644 index 6f8a8c5efaa6..000000000000 --- a/sys/arch/amiga/compile/AMIGA/version +++ /dev/null @@ -1 +0,0 @@ -390 diff --git a/sys/arch/amiga/compile/AMIGA/vn.h b/sys/arch/amiga/compile/AMIGA/vn.h deleted file mode 100644 index a6caaabf21cb..000000000000 --- a/sys/arch/amiga/compile/AMIGA/vn.h +++ /dev/null @@ -1 +0,0 @@ -#define NVN 10 diff --git a/sys/arch/amiga/compile/AMIGA/vnodepager.h b/sys/arch/amiga/compile/AMIGA/vnodepager.h deleted file mode 100644 index 492143ce5c25..000000000000 --- a/sys/arch/amiga/compile/AMIGA/vnodepager.h +++ /dev/null @@ -1 +0,0 @@ -#define NVNODEPAGER 1 diff --git a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_h_mode.c b/sys/arch/amiga/dev/grf/grf_cc/grf_cc_h_mode.c deleted file mode 100644 index 829e542ec466..000000000000 --- a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_h_mode.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_cc_h_mode.c,v 1.3 1994/01/30 08:25:05 chopps Exp $ - */ - -#if defined (GRF_NTSC) - -#include "grf_cc_priv.h" - -static void hires_mode_vbl_handler (dmode_t *d); -static void display_hires_view (view_t *v); -static view_t *get_current_view (dmode_t *d); - -enum frame_numbers { - F_LONG, - F_STORE_LONG, - F_TOTAL -}; - -static dmode_t hires_mode; -static dmdata_t hires_mode_data; -static cop_t *hires_frames[F_TOTAL]; -static dmode_t *this; -static dmdata_t *this_data; - -dmode_t * -cc_init_ntsc_hires (void) -{ - /* this function should only be called once. */ - if (!this) { - u_word len = std_copper_list_len; - cop_t *cp; - - this = &hires_mode; - this_data = &hires_mode_data; - bzero (this, sizeof (dmode_t)); - bzero (this_data, sizeof (dmdata_t)); - - this->name = "ntsc: hires interlace"; - this->nominal_size.width = 640; - this->nominal_size.height = 200; - this_data->max_size.width = 724; - this_data->max_size.height = 242; - this_data->min_size.width = 320; - this_data->min_size.height = 100; - this_data->min_depth = 1; - this_data->max_depth = 4; - this->data = this_data; - - this->get_monitor = cc_get_monitor; - this->alloc_view = cc_alloc_view; - this->get_current_view = get_current_view; - - this_data->use_colormap = cc_use_colormap; - this_data->get_colormap = cc_get_colormap; - this_data->alloc_colormap = cc_alloc_colormap; - this_data->display_view = display_hires_view; - this_data->monitor = cc_monitor; - - this_data->frames = hires_frames; - this_data->frames[F_LONG] = alloc_chipmem (std_copper_list_size*F_TOTAL); - if (!this_data->frames[F_LONG]) { - panic ("couldn't get chipmem for copper list"); - } - - this_data->frames[F_STORE_LONG] = &this_data->frames[F_LONG][len]; - - bcopy (std_copper_list, this_data->frames[F_STORE_LONG], std_copper_list_size); - bcopy (std_copper_list, this_data->frames[F_LONG], std_copper_list_size); - - this_data->bplcon0 = 0x8200|USE_CON3; /* hires, color composite enable, lace. */ - this_data->std_start_x = STANDARD_VIEW_X; - this_data->std_start_y = STANDARD_VIEW_Y; - this_data->vbl_handler = (vbl_handler_func *) hires_mode_vbl_handler; -#if defined (GRF_ECS) - this_data->beamcon0 = STANDARD_NTSC_BEAMCON; -#endif - - dadd_head (&MDATA(cc_monitor)->modes, &this->node); - } - return (this); -} - -static void -display_hires_view (view_t *v) -{ - if (this_data->current_view != v) { - vdata_t *vd = VDATA(v); - monitor_t *monitor = this_data->monitor; - cop_t *cp = this_data->frames[F_STORE_LONG], *tmp; - int depth = v->bitmap->depth, i; - int hstart, hstop, vstart, vstop, j; - int x, y, w = v->display.width, h = v->display.height; - u_word ddfstart, ddfwidth, con1; - - /* round down to nearest even width */ - /* w &= 0xfffe; */ - - - /* calculate datafetch width. */ - - ddfwidth = ((v->bitmap->bytes_per_row>>1)-2)<<2; - - /* This will center the any overscanned display */ - /* and allow user to modify. */ - x = v->display.x + this_data->std_start_x - ((w - 640) >> 2); - y = v->display.y + this_data->std_start_y - ((h - 200) >> 1); - - if (y&1) - y--; - - if (!(x&1)) - x--; - - hstart = x; - hstop = x+(w>>1); - vstart = y; - vstop = y+h; - ddfstart = (hstart-9) >> 1; - - /* check for hardware limits, AGA may allow more..? */ - /* anyone got a 4000 I can borrow :^) -ch */ - if ((ddfstart&0xfffc) + ddfwidth > 0xd8) { - int d=0; - - /* XXX anyone know the equality properties of intermixed logial AND's */ - /* XXX and arithmetic operators? */ - while (((ddfstart&0xfffc)+ddfwidth-d) > 0xd8) { - d++; - } - - ddfstart -= d; - hstart -= d<<1; - hstop -= d<<1; - } - - /* correct the datafetch to proper limits. */ - /* delay the actual display of the data until we need it. */ - ddfstart &= 0xfffc; - con1 = ((hstart-9)-(ddfstart<<1)) | (((hstart-9)-(ddfstart<<1))<<4); - - if (this_data->current_view) { - VDATA(this_data->current_view)->flags &= ~VF_DISPLAY; /* mark as no longer */ - /* displayed. */ - } - this_data->current_view = v; - - cp = this_data->frames[F_STORE_LONG]; -#if defined GRF_ECS - tmp = find_copper_inst (cp, CI_MOVE(R_BEAMCON0)); - tmp->cp.inst.operand = this_data->beamcon0; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWHIGH)); - tmp->cp.inst.operand = CALC_DIWHIGH (hstart, vstart, hstop, vstop); -#endif /* ECS */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON0)); - tmp->cp.inst.operand = this_data->bplcon0 | ((depth & 0x7) << 12); - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON1)); - tmp->cp.inst.operand = con1; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTART)); - tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTOP)); - tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTART)); - tmp->cp.inst.operand = ddfstart; - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTOP)); - tmp->cp.inst.operand = ddfstart + ddfwidth; - - tmp = find_copper_inst (cp, CI_MOVE(R_BPL0PTH)); - for (i = 0, j = 0; i < depth; j+=2, i++) { - /* update the plane pointers */ - tmp[j].cp.inst.operand = HIADDR (PREP_DMA_MEM (v->bitmap->plane[i])); - tmp[j+1].cp.inst.operand = LOADDR (PREP_DMA_MEM (v->bitmap->plane[i])); - } - - /* set mods correctly. */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPL1MOD)); - tmp[0].cp.inst.operand = v->bitmap->row_mod; - tmp[1].cp.inst.operand = v->bitmap->row_mod; - - /* set next pointers correctly */ - tmp = find_copper_inst (cp, CI_MOVE(R_COP1LCH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - - cp = this_data->frames[F_LONG]; - this_data->frames[F_LONG] = this_data->frames[F_STORE_LONG]; - this_data->frames[F_STORE_LONG] = cp; - - vd->flags |= VF_DISPLAY; - - cc_use_colormap (v, vd->colormap); - } - cc_load_mode (this); -} - -static view_t * -get_current_view (dmode_t *d) -{ - return (this_data->current_view); -} - - -static void -hires_mode_vbl_handler (dmode_t *d) -{ - u_word vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8); - - if (vp < 12) { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[F_LONG]); - custom.copjmp1 = 0; - } -} - -#endif /* GRF_NTSC */ diff --git a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_hdl_mode.c b/sys/arch/amiga/dev/grf/grf_cc/grf_cc_hdl_mode.c deleted file mode 100644 index 980fedd692ac..000000000000 --- a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_hdl_mode.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_cc_hdl_mode.c,v 1.3 1994/01/30 08:25:06 chopps Exp $ - */ - -#if defined (GRF_A2024) && defined (GRF_NTSC) - -#include "grf_cc_priv.h" -#include "../../../amiga/cc_2024.h" - -#if defined (AMIGA_TEST) -#define DEBUG -#include -#else -#define D(x) -#endif - -static void hires_dlace_mode_vbl_handler (dmode_t *d); -static void display_hires_dlace_view (view_t *v); -static view_t *get_current_view (dmode_t *d); - -enum frame_numbers { - F_LONG, - F_SHORT, - F_STORE_LONG, - F_STORE_SHORT, - F_TOTAL -}; - -static dmode_t hires_dlace_mode; -static dmdata_t hires_dlace_mode_data; -static cop_t *hires_dlace_frames[F_TOTAL]; -static dmode_t *this; -static dmdata_t *this_data; - -dmode_t * -cc_init_ntsc_hires_dlace (void) -{ - /* this function should only be called once. */ - if (!this) { - u_word len = std_dlace_copper_list_len; - cop_t *cp; - - this = &hires_dlace_mode; - this_data = &hires_dlace_mode_data; - bzero (this, sizeof (dmode_t)); - bzero (this_data, sizeof (dmdata_t)); - - this->name = "ntsc: hires double interlace"; - this->nominal_size.width = 640; - this->nominal_size.height = 800; - this_data->max_size.width = 724; - this_data->max_size.height = 800; - this_data->min_size.width = 320; - this_data->min_size.height = 400; - this_data->min_depth = 1; - this_data->max_depth = 2; - this->data = this_data; - - this->get_monitor = cc_get_monitor; - this->alloc_view = cc_alloc_view; - this->get_current_view = get_current_view; - - this_data->use_colormap = cc_a2024_use_colormap; - this_data->get_colormap = cc_a2024_get_colormap; - this_data->alloc_colormap = cc_a2024_alloc_colormap; - this_data->display_view = display_hires_dlace_view; - this_data->monitor = cc_monitor; - - this_data->flags |= DMF_INTERLACE; - - this_data->frames = hires_dlace_frames; - this_data->frames[F_LONG] = alloc_chipmem (std_dlace_copper_list_size*F_TOTAL); - if (!this_data->frames[F_LONG]) { - panic ("couldn't get chipmem for copper list"); - } - - this_data->frames[F_SHORT] = &this_data->frames[F_LONG][len]; - this_data->frames[F_STORE_LONG] = &this_data->frames[F_SHORT][len]; - this_data->frames[F_STORE_SHORT] = &this_data->frames[F_STORE_LONG][len]; - - bcopy (std_dlace_copper_list, this_data->frames[F_STORE_LONG], std_dlace_copper_list_size); - bcopy (std_dlace_copper_list, this_data->frames[F_STORE_SHORT], std_dlace_copper_list_size); - bcopy (std_dlace_copper_list, this_data->frames[F_LONG], std_dlace_copper_list_size); - bcopy (std_dlace_copper_list, this_data->frames[F_SHORT], std_dlace_copper_list_size); - - this_data->bplcon0 = 0x8204|USE_CON3; /* hires, color composite enable, dlace. */ - this_data->std_start_x = STANDARD_VIEW_X; - this_data->std_start_y = STANDARD_VIEW_Y; - this_data->vbl_handler = (vbl_handler_func *) hires_dlace_mode_vbl_handler; -#if defined (GRF_ECS) - this_data->beamcon0 = STANDARD_NTSC_BEAMCON; -#endif - dadd_head (&MDATA(cc_monitor)->modes, &this->node); - } - return (this); -} - -static void -display_hires_dlace_view (view_t *v) -{ - if (this_data->current_view != v) { - vdata_t *vd = VDATA(v); - monitor_t *monitor = this_data->monitor; - cop_t *cp = this_data->frames[F_STORE_LONG], *tmp; - int depth = v->bitmap->depth, i; - int hstart, hstop, vstart, vstop, j; - int x, y, w = v->display.width, h = v->display.height; - u_word ddfstart, ddfwidth, con1; - u_word mod1l, mod2l; - - /* round down to nearest even width */ - /* w &= 0xfffe; */ - - /* calculate datafetch width. */ - - ddfwidth = ((v->bitmap->bytes_per_row>>1)-2)<<2; - - /* This will center the any overscanned display */ - /* and allow user to modify. */ - x = v->display.x + this_data->std_start_x - ((w - 640) >> 2); - y = v->display.y + this_data->std_start_y - ((h - 800) >> 3); - - if (y&1) - y--; - - if (!(x&1)) - x--; - - hstart = x; - hstop = x+(w>>1); - vstart = y; - vstop = y+(h>>2); - - ddfstart = (hstart-9) >> 1; - - /* check for hardware limits, AGA may allow more..? */ - /* anyone got a 4000 I can borrow :^) -ch */ - if ((ddfstart&0xfffc) + ddfwidth > 0xd8) { - int d=0; - - /* XXX anyone know the equality properties of intermixed logial AND's */ - /* XXX and arithmetic operators? */ - while (((ddfstart&0xfffc)+ddfwidth-d) > 0xd8) { - d++; - } - - ddfstart -= d; - hstart -= d<<1; - hstop -= d<<1; - } - - /* correct the datafetch to proper limits. */ - /* delay the actual display of the data until we need it. */ - ddfstart &= 0xfffc; - con1 = ((hstart-9)-(ddfstart<<1)) | (((hstart-9)-(ddfstart<<1))<<4); - - if (this_data->current_view) { - VDATA(this_data->current_view)->flags &= ~VF_DISPLAY; /* mark as no longer */ - /* displayed. */ - } - this_data->current_view = v; - - cp = this_data->frames[F_STORE_LONG]; -#if defined GRF_ECS - tmp = find_copper_inst (cp, CI_MOVE(R_BEAMCON0)); - tmp->cp.inst.operand = this_data->beamcon0; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWHIGH)); - tmp->cp.inst.operand = CALC_DIWHIGH (hstart, vstart, hstop, vstop); -#endif /* ECS */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON0)); - tmp->cp.inst.operand = this_data->bplcon0 | ((depth & 0x7) << 13); /* times two. */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON1)); - tmp->cp.inst.operand = con1; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTART)); - tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTOP)); - tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTART)); - tmp->cp.inst.operand = ddfstart; - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTOP)); - tmp->cp.inst.operand = ddfstart + ddfwidth; - - mod1l = v->bitmap->bytes_per_row + v->bitmap->row_mod; - mod2l = mod1l << 1; - - /* update plane pointers. */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPL0PTH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[0][0])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[0][0])); - tmp[2].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod1l])); - tmp[3].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod1l])); - if (depth == 2) { - tmp[4].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[1][0])); - tmp[5].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[1][0])); - tmp[6].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod1l])); - tmp[7].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod1l])); - } - - /* set modulos. */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPL1MOD)); - tmp[0].cp.inst.operand = mod2l + mod1l; - tmp[1].cp.inst.operand = mod2l + mod1l; - - - /* set next coper list pointers */ - tmp = find_copper_inst (cp, CI_MOVE(R_COP1LCH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_SHORT])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_SHORT])); - - bcopy (this_data->frames[F_STORE_LONG], this_data->frames[F_STORE_SHORT], - std_dlace_copper_list_size); - - /* these are the only ones that are different from long frame. */ - cp = this_data->frames[F_STORE_SHORT]; - /* update plane pointers. */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPL0PTH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod2l])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod2l])); - tmp[2].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod2l+mod1l])); - tmp[3].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod2l+mod1l])); - if (depth == 2) { - tmp[4].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod2l])); - tmp[5].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod2l])); - tmp[6].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod2l+mod1l])); - tmp[7].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod2l+mod1l])); - } - - /* set next copper list pointers */ - tmp = find_copper_inst (cp, CI_MOVE(R_COP1LCH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - - cp = this_data->frames[F_LONG]; - this_data->frames[F_LONG] = this_data->frames[F_STORE_LONG]; - this_data->frames[F_STORE_LONG] = cp; - - cp = this_data->frames[F_SHORT]; - this_data->frames[F_SHORT] = this_data->frames[F_STORE_SHORT]; - this_data->frames[F_STORE_SHORT] = cp; - - vd->flags |= VF_DISPLAY; - cc_a2024_use_colormap (v, vd->colormap); - } - cc_load_mode (this); -} - -static view_t * -get_current_view (dmode_t *d) -{ - return (this_data->current_view); -} - -static void -hires_dlace_mode_vbl_handler (dmode_t *d) -{ - u_word vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8); - - if (vp < 12) { - if (custom.vposr & 0x8000) { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[F_LONG]); - } else { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[F_SHORT]); - } - custom.copjmp1 = 0; - } -} - -#endif /* GRF_A2024 && GRF_NTSC */ diff --git a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_hl_mode.c b/sys/arch/amiga/dev/grf/grf_cc/grf_cc_hl_mode.c deleted file mode 100644 index c8d167c3ca03..000000000000 --- a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_hl_mode.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_cc_hl_mode.c,v 1.3 1994/01/30 08:25:08 chopps Exp $ - */ -#if defined (GRF_NTSC) - -#include "grf_cc_priv.h" - -static void hires_lace_mode_vbl_handler (dmode_t *d); -static void display_hires_lace_view (view_t *v); -static view_t *get_current_view (dmode_t *d); - -enum frame_numbers { - F_LONG, - F_SHORT, - F_STORE_LONG, - F_STORE_SHORT, - F_TOTAL -}; - -static dmode_t hires_lace_mode; -static dmdata_t hires_lace_mode_data; -static cop_t *hires_lace_frames[F_TOTAL]; -static dmode_t *this; -static dmdata_t *this_data; - -dmode_t * -cc_init_ntsc_hires_lace (void) -{ - /* this function should only be called once. */ - if (!this) { - u_word len = std_copper_list_len; - cop_t *cp; - - this = &hires_lace_mode; - this_data = &hires_lace_mode_data; - bzero (this, sizeof (dmode_t)); - bzero (this_data, sizeof (dmdata_t)); - - this->name = "ntsc: hires interlace"; - this->nominal_size.width = 640; - this->nominal_size.height = 400; - this_data->max_size.width = 724; - this_data->max_size.height = 482; - this_data->min_size.width = 320; - this_data->min_size.height = 200; - this_data->min_depth = 1; - this_data->max_depth = 4; - this->data = this_data; - - this->get_monitor = cc_get_monitor; - this->alloc_view = cc_alloc_view; - this->get_current_view = get_current_view; - - this_data->use_colormap = cc_use_colormap; - this_data->get_colormap = cc_get_colormap; - this_data->alloc_colormap = cc_alloc_colormap; - this_data->display_view = display_hires_lace_view; - this_data->monitor = cc_monitor; - - this_data->flags |= DMF_INTERLACE; - - this_data->frames = hires_lace_frames; - this_data->frames[F_LONG] = alloc_chipmem (std_copper_list_size*F_TOTAL); - if (!this_data->frames[F_LONG]) { - panic ("couldn't get chipmem for copper list"); - } - - this_data->frames[F_SHORT] = &this_data->frames[F_LONG][len]; - this_data->frames[F_STORE_LONG] = &this_data->frames[F_SHORT][len]; - this_data->frames[F_STORE_SHORT] = &this_data->frames[F_STORE_LONG][len]; - - bcopy (std_copper_list, this_data->frames[F_STORE_LONG], std_copper_list_size); - bcopy (std_copper_list, this_data->frames[F_STORE_SHORT], std_copper_list_size); - bcopy (std_copper_list, this_data->frames[F_LONG], std_copper_list_size); - bcopy (std_copper_list, this_data->frames[F_SHORT], std_copper_list_size); - - this_data->bplcon0 = 0x8204|USE_CON3; /* hires, color composite enable, lace. */ - this_data->std_start_x = STANDARD_VIEW_X; - this_data->std_start_y = STANDARD_VIEW_Y; - this_data->vbl_handler = (vbl_handler_func *) hires_lace_mode_vbl_handler; -#if defined (GRF_ECS) - this_data->beamcon0 = STANDARD_NTSC_BEAMCON; -#endif - - dadd_head (&MDATA(cc_monitor)->modes, &this->node); - } - return (this); -} - -static void -display_hires_lace_view (view_t *v) -{ - if (this_data->current_view != v) { - vdata_t *vd = VDATA(v); - monitor_t *monitor = this_data->monitor; - cop_t *cp = this_data->frames[F_STORE_LONG], *tmp; - int depth = v->bitmap->depth, i; - int hstart, hstop, vstart, vstop, j; - int x, y, w = v->display.width, h = v->display.height; - u_word ddfstart, ddfwidth, con1; - - /* round down to nearest even width */ - /* w &= 0xfffe; */ - - - /* calculate datafetch width. */ - - ddfwidth = ((v->bitmap->bytes_per_row>>1)-2)<<2; - - /* This will center the any overscanned display */ - /* and allow user to modify. */ - x = v->display.x + this_data->std_start_x - ((w - 640) >> 2); - y = v->display.y + this_data->std_start_y - ((h - 400) >> 2); - - if (y&1) - y--; - - if (!(x&1)) - x--; - - hstart = x; - hstop = x+(w>>1); - vstart = y; - vstop = y+(h>>1); - ddfstart = (hstart-9) >> 1; - - /* check for hardware limits, AGA may allow more..? */ - /* anyone got a 4000 I can borrow :^) -ch */ - if ((ddfstart&0xfffc) + ddfwidth > 0xd8) { - int d=0; - - /* XXX anyone know the equality properties of intermixed logial AND's */ - /* XXX and arithmetic operators? */ - while (((ddfstart&0xfffc)+ddfwidth-d) > 0xd8) { - d++; - } - - ddfstart -= d; - hstart -= d<<1; - hstop -= d<<1; - } - - /* correct the datafetch to proper limits. */ - /* delay the actual display of the data until we need it. */ - ddfstart &= 0xfffc; - con1 = ((hstart-9)-(ddfstart<<1)) | (((hstart-9)-(ddfstart<<1))<<4); - - if (this_data->current_view) { - VDATA(this_data->current_view)->flags &= ~VF_DISPLAY; /* mark as no longer */ - /* displayed. */ - } - this_data->current_view = v; - - cp = this_data->frames[F_STORE_LONG]; -#if defined GRF_ECS - tmp = find_copper_inst (cp, CI_MOVE(R_BEAMCON0)); - tmp->cp.inst.operand = this_data->beamcon0; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWHIGH)); - tmp->cp.inst.operand = CALC_DIWHIGH (hstart, vstart, hstop, vstop); -#endif /* ECS */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON0)); - tmp->cp.inst.operand = this_data->bplcon0 | ((depth & 0x7) << 12); - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON1)); - tmp->cp.inst.operand = con1; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTART)); - tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTOP)); - tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTART)); - tmp->cp.inst.operand = ddfstart; - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTOP)); - tmp->cp.inst.operand = ddfstart + ddfwidth; - - tmp = find_copper_inst (cp, CI_MOVE(R_BPL0PTH)); - for (i = 0, j = 0; i < depth; j+=2, i++) { - /* update the plane pointers */ - tmp[j].cp.inst.operand = HIADDR (PREP_DMA_MEM (v->bitmap->plane[i])); - tmp[j+1].cp.inst.operand = LOADDR (PREP_DMA_MEM (v->bitmap->plane[i])); - } - - /* set mods correctly. */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPL1MOD)); - tmp[0].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod; - tmp[1].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod; - - /* set next pointers correctly */ - tmp = find_copper_inst (cp, CI_MOVE(R_COP1LCH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_SHORT])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_SHORT])); - - - bcopy (this_data->frames[F_STORE_LONG], this_data->frames[F_STORE_SHORT], std_copper_list_size); - - /* these are the only ones that are different from long frame. */ - cp = this_data->frames[F_STORE_SHORT]; - tmp = find_copper_inst (cp, CI_MOVE(R_BPL0PTH)); - for (i=0, j=0; i < depth; j+=2, i++) { - u_word mod = v->bitmap->bytes_per_row + v->bitmap->row_mod; - /* update plane pointers. high and low. */ - tmp[j].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[i][mod])); - tmp[j+1].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[i][mod])); - } - - /* set next pointers correctly */ - tmp = find_copper_inst (cp, CI_MOVE(R_COP1LCH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - - - cp = this_data->frames[F_LONG]; - this_data->frames[F_LONG] = this_data->frames[F_STORE_LONG]; - this_data->frames[F_STORE_LONG] = cp; - - cp = this_data->frames[F_SHORT]; - this_data->frames[F_SHORT] = this_data->frames[F_STORE_SHORT]; - this_data->frames[F_STORE_SHORT] = cp; - - vd->flags |= VF_DISPLAY; - - cc_use_colormap (v, vd->colormap); - } - cc_load_mode (this); -} - -static view_t * -get_current_view (dmode_t *d) -{ - return (this_data->current_view); -} - - -static void -hires_lace_mode_vbl_handler (dmode_t *d) -{ - u_word vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8); - - if (vp < 12) { - if (custom.vposr & 0x8000) { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[F_LONG]); - } else { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[F_SHORT]); - } - custom.copjmp1 = 0; - } -} - -#endif /* GRF_NTSC */ diff --git a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_mode.c b/sys/arch/amiga/dev/grf/grf_cc/grf_cc_mode.c deleted file mode 100644 index 234559ff861a..000000000000 --- a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_mode.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_cc_mode.c,v 1.3 1994/01/30 08:25:09 chopps Exp $ - */ -#include "errno.h" -#include "grf_cc_priv.h" - -#if defined (GRF_A2024) -#include "../../../amiga/cc_2024.h" -#endif /* GRF_A2024 */ - -#include "sys/cdefs.h" -#include "machine/param.h" - -dmode_t *(*mode_init_funcs[])(void) = { -#if defined (GRF_NTSC) -#if defined (GRF_A2024) - cc_init_ntsc_a2024, - cc_init_ntsc_hires_dlace, -#endif /* GRF_A2024 */ - cc_init_ntsc_hires_lace, - cc_init_ntsc_hires, -#endif /* GRF_NTSC */ -#if defined (GRF_PAL) -#if defined (GRF_A2024) - cc_init_pal_a2024, - cc_init_pal_hires_dlace, -#endif /* GRF_A2024 */ - cc_init_pal_hires_lace, - cc_init_pal_hires, -#endif /* GRF_PAL */ - NULL -}; - -int -cc_init_modes (void) -{ - int i = 0; - int error = 0; - while (mode_init_funcs[i]) { - mode_init_funcs[i] (); - i++; - } - return (error); -} - -/* - * Mode functions. - */ - - -monitor_t * -cc_get_monitor (dmode_t *d) -{ - return (DMDATA(d)->monitor); -} - -view_t * -cc_get_current_view (dmode_t *d) -{ - return (DMDATA(d)->current_view); -} - -void -cc_mode_vbl_handler (dmode_t *m) -{ -} - -view_t * -cc_alloc_view (dmode_t *mode, dimen_t *dim, u_byte depth) -{ - view_t *v = alloc_chipmem (sizeof (*v) + sizeof (vdata_t)); - if (v) { - bmap_t *bm = cc_monitor->alloc_bitmap (dim->width, dim->height, depth, BMF_CLEAR); - if (bm) { - int i; - box_t box; - - v->data = &v[1]; /* at the end of view */ - VDATA(v)->colormap = DMDATA(mode)->alloc_colormap (depth); - if (VDATA(v)->colormap) { - INIT_BOX (&box, 0, 0, dim->width, dim->height); - cc_init_view (v, bm, mode, &box); - return (v); - } - cc_monitor->free_bitmap (bm); - } - free_chipmem (v); - } - return (NULL); -} - -u_word cc_default_colors[32] = { - 0xAAA, 0x000, 0x68B, 0xFFF, - 0x369, 0x963, 0x639, 0x936, - 0x000, 0x00F, 0x0F0, 0xF00, - 0x0FF, 0xFF0, 0xF0F, 0xFFF, - 0x000, 0x111, 0x222, 0x333, - 0x444, 0x555, 0x666, 0x777, - 0x888, 0x999, 0xAAA, 0xBBB, - 0xCCC, 0xDDD, 0xEEE, 0xFFF -}; - -#if defined (GRF_A2024) -u_word cc_a2024_default_colors[4] = { - 0x0, /* BLACK */ - 0x3, /* WHITE */ - 0x2, /* LGREY */ - 0x1 /* DGREY */ -}; -#endif /* GRF_A2024 */ - -colormap_t * -cc_alloc_colormap (int depth) -{ - u_long size = 1u << depth, i; - colormap_t *cm = alloc_chipmem (sizeof (u_long)*size + sizeof (*cm)); - - if (cm) { - cm->type = CM_COLOR; - cm->red_mask = 0x0F; - cm->green_mask = 0x0F; - cm->blue_mask = 0x0F; - cm->first = 0; - cm->size = size; - cm->entry = (u_long *) &cm[1]; /* table directly after. */ - for (i=0; i < min(size,32); i++) { - cm->entry[i] = CM_WTOL(cc_default_colors[i]); - } - return (cm); - } - return (NULL); -} - -#if defined (GRF_A2024) -colormap_t * -cc_a2024_alloc_colormap (int depth) -{ - u_long size = 1u << depth, i; - colormap_t *cm = alloc_chipmem (sizeof (u_long)*size + sizeof (*cm)); - - if (cm) { - cm->type = CM_GREYSCALE; - cm->grey_mask = 0x03; - cm->first = 0; - cm->size = size; - cm->entry = (u_long *) &cm[1]; /* table directly after. */ - for (i=0; i < size; i++) { - cm->entry[i] = CM_WTOL(cc_a2024_default_colors[i]); - } - return (cm); - } - return (NULL); -} -#endif /* GRF_A2024 */ - -int -cc_colormap_checkvals (colormap_t *vcm, colormap_t *cm, int use) -{ - if (use) { - /* check to see if its the view's colormap, if so just do update. */ - if (vcm != cm) { - if (cm->first >= vcm->size || (cm->first + cm->size) > (cm->first + vcm->size) || - cm->type != vcm->type) { - return (0); - } - - switch (vcm->type) { - case CM_COLOR: - if (cm->red_mask != vcm->red_mask || - cm->green_mask != vcm->green_mask || - cm->blue_mask != vcm->blue_mask) { - return (0); - } - break; - case CM_GREYSCALE: - if (cm->grey_mask != vcm->grey_mask) { - return (0); - } - break; - } - } - } else { - if (cm->first >= vcm->size || (cm->first + cm->size) > (cm->first + vcm->size)) { - return (0); - } - } - return (1); -} - -/* does sanity check on values */ -int -cc_get_colormap (view_t *v, colormap_t *cm) -{ - colormap_t *vcm = VDATA(v)->colormap; - int i; - - if (!cc_colormap_checkvals (vcm, cm, 0)) { - return (EINVAL); - } - - cm->type = vcm->type; - - switch (vcm->type) { - case CM_COLOR: - cm->red_mask = vcm->red_mask; - cm->green_mask = vcm->green_mask; - cm->blue_mask = vcm->blue_mask; - break; - case CM_GREYSCALE: - cm->grey_mask = vcm->grey_mask; - break; - } - - /* copy entries into colormap. */ - for (i = cm->first; i < (cm->first+cm->size); i++) { - cm->entry[i] = vcm->entry[i]; - } - return (0); -} - -#if defined (GRF_A2024) -int -cc_a2024_get_colormap (view_t *v, colormap_t *cm) -{ - /* there are no differences (yet) in the way the cm's are stored */ - return (cc_get_colormap (v,cm)); -} -#endif /* GRF_A2024 */ - -/* does sanity check on values */ -int -cc_use_colormap (view_t *v, colormap_t *cm) -{ - colormap_t *vcm = VDATA(v)->colormap; - int s, i; - - if (!cc_colormap_checkvals (vcm, cm, 1)) { - return (EINVAL); - } - - /* check to see if its the view's colormap, if so just do update. */ - if (vcm != cm) { - /* copy entries into colormap. */ - for (i = cm->first; i < (cm->first+cm->size); i++) { - vcm->entry[i] = cm->entry[i]; - } - } - s = spltty (); - - /* is view currently being displayed? */ - if (VDATA(v)->flags & VF_DISPLAY) { - /* yes, update the copper lists */ - cop_t *tmp, *cp; - int nframes = 1, j; - - if (DMDATA(VDATA(v)->mode)->flags & DMF_INTERLACE) { - nframes = 2; - } - - for (i = 0; i < nframes; i++) { - cp = DMDATA(VDATA(v)->mode)->frames[i]; - - tmp = find_copper_inst (cp, CI_MOVE(R_COLOR07)); - tmp -= 7; - - for (j=0; j<16; j++) { - CMOVE (tmp, R_COLOR00+(j<<1), CM_LTOW (vcm->entry[j])); - } - } - } - - splx (s); - return (0); -} - -#if defined (GRF_A2024) -int -cc_a2024_use_colormap (view_t *v, colormap_t *cm) -{ - colormap_t *vcm = VDATA(v)->colormap; - int s, i; - - if (!cc_colormap_checkvals (vcm, cm, 1)) { - return (EINVAL); - } - - /* check to see if its the view's colormap, if so just do update. */ - if (vcm != cm) { - /* copy entries into colormap. */ - for (i = cm->first; i < (cm->first+cm->size); i++) { - vcm->entry[i] = cm->entry[i]; - } - } - s = spltty (); - - /* is view currently being displayed? */ - if (VDATA(v)->flags & VF_DISPLAY) { - /* yes, update the copper lists */ - cop_t *tmp, *cp; - int nframes = 2, nregs = cm->size == 4 ? 16 : 8, j; - - if (DMDATA(VDATA(v)->mode)->flags & DMF_HEDLEY_EXP) { - nframes = 4; - } - - for (i = 0; i < nframes; i++) { - cp = DMDATA(VDATA(v)->mode)->frames[i]; - - tmp = find_copper_inst (cp, CI_MOVE(R_COLOR07)); - tmp -= 7; - - for (j=0; j -#else -#define D(x) -#endif - -static void pal_a2024_mode_vbl_handler (dmode_t *d); -static void display_pal_a2024_view (view_t *v); -static view_t *get_current_view (dmode_t *d); - -/* ------- - * |0 |1 | - * |------ - * |2 |3 | - * ------- - */ - -#define QUAD0_ID 0x0001 -#define QUAD1_ID 0x00f1 -#define QUAD2_ID 0x0f01 -#define QUAD3_ID 0x0ff1 - -/* display order Q0 -> Q2 -> Q1 -> Q3 ---> */ - -enum frame_numbers { - F_QUAD0, F_QUAD1, F_QUAD2, F_QUAD3, - F_STORE_QUAD0, F_STORE_QUAD1, F_STORE_QUAD2, F_STORE_QUAD3, - F_TOTAL -}; - -static dmode_t pal_a2024_mode; -static dmdata_t pal_a2024_mode_data; -static cop_t *pal_a2024_frames[F_TOTAL]; -static u_byte *hedley_init; /* init bitplane. */ -static dmode_t *this; -static dmdata_t *this_data; - -dmode_t * -cc_init_pal_a2024 (void) -{ - /* this function should only be called once. */ - if (!this) { - int i; - u_word len = std_pal_a2024_copper_list_len; - cop_t *cp; - - this = &pal_a2024_mode; - this_data = &pal_a2024_mode_data; - bzero (this, sizeof (dmode_t)); - bzero (this_data, sizeof (dmdata_t)); - - this->name = "pal: A2024 15khz"; - this->nominal_size.width = 1024; - this->nominal_size.height = 1024; - this_data->max_size.width = 1024; - this_data->max_size.height = 1024; - this_data->min_size.width = 1024; - this_data->min_size.height = 1024; - this_data->min_depth = 1; - this_data->max_depth = 2; - this->data = this_data; - - this->get_monitor = cc_get_monitor; - this->alloc_view = cc_alloc_view; - this->get_current_view = get_current_view; - - this_data->use_colormap = cc_a2024_use_colormap; - this_data->get_colormap = cc_a2024_get_colormap; - this_data->display_view = display_pal_a2024_view; - this_data->alloc_colormap = cc_a2024_alloc_colormap; - this_data->monitor = cc_monitor; - - this_data->flags |= DMF_HEDLEY_EXP; - - this_data->frames = pal_a2024_frames; - this_data->frames[F_QUAD0] = alloc_chipmem (std_pal_a2024_copper_list_size*F_TOTAL); - if (!this_data->frames[F_QUAD0]) { - panic ("couldn't get chipmem for copper list"); - } - - /* setup the hedley init bitplane. */ - hedley_init = alloc_chipmem (128); - if (!hedley_init) { - panic ("couldn't get chipmem for hedley init bitplane"); - } - for (i = 1; i < 128; i++) hedley_init[i] = 0xff; - hedley_init[0] = 0x03; - - /* copy image of standard copper list. */ - bcopy (std_pal_a2024_copper_list, this_data->frames[0], std_pal_a2024_copper_list_size); - - /* set the init plane pointer. */ - cp = find_copper_inst (this_data->frames[F_QUAD0], CI_MOVE(R_BPL0PTH)); - cp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (hedley_init)); - cp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (hedley_init)); - - for (i = 1; i < F_TOTAL; i++) { - this_data->frames[i] = &this_data->frames[i-1][len]; - bcopy (this_data->frames[0], this_data->frames[i], std_pal_a2024_copper_list_size); - } - - this_data->bplcon0 = 0x8200; /* hires */ - this_data->vbl_handler = (vbl_handler_func *) pal_a2024_mode_vbl_handler; - - - dadd_head (&MDATA(cc_monitor)->modes, &this->node); - } - return (this); -} - -static void -display_pal_a2024_view (view_t *v) -{ - if (this_data->current_view != v) { - vdata_t *vd = VDATA(v); - monitor_t *monitor = this_data->monitor; - cop_t *cp, *tmp; - u_byte *inst_plane[2]; - u_byte **plane = inst_plane; - u_long full_line = v->bitmap->bytes_per_row+v->bitmap->row_mod; - u_long half_plane = full_line * v->bitmap->rows / 2; - - int line_mod = 0xbc; /* standard 2024 15khz mod. */ - int depth = v->bitmap->depth, i, j; - - plane[0] = v->bitmap->plane[0]; - if (depth == 2) { - plane[1] = v->bitmap->plane[1]; - } - - if (this_data->current_view) { - VDATA(this_data->current_view)->flags &= ~VF_DISPLAY; /* mark as no longer displayed. */ - } - - cp = this_data->frames[F_STORE_QUAD0]; - tmp = find_copper_inst (cp, CI_MOVE(R_COLOR1F)); - tmp = find_copper_inst (tmp, CI_MOVE(R_BPLCON0)); /* grab third one. */ - tmp->cp.inst.operand = this_data->bplcon0 | ((depth & 0x7) << 13); /* times 2 */ - - bcopy (this_data->frames[F_STORE_QUAD0], this_data->frames[F_STORE_QUAD1], std_pal_a2024_copper_list_size); - bcopy (this_data->frames[F_STORE_QUAD0], this_data->frames[F_STORE_QUAD2], std_pal_a2024_copper_list_size); - bcopy (this_data->frames[F_STORE_QUAD0], this_data->frames[F_STORE_QUAD3], std_pal_a2024_copper_list_size); - - /* - * Mark Id's - */ - tmp = find_copper_inst (this_data->frames[F_STORE_QUAD1], CI_WAIT (126,29)); - CBUMP(tmp); - CMOVE (tmp, R_COLOR01, QUAD1_ID); - tmp = find_copper_inst (this_data->frames[F_STORE_QUAD2], CI_WAIT (126,29)); - CBUMP(tmp); - CMOVE (tmp, R_COLOR01, QUAD2_ID); - tmp = find_copper_inst (this_data->frames[F_STORE_QUAD3], CI_WAIT (126,29)); - CBUMP(tmp); - CMOVE (tmp, R_COLOR01, QUAD3_ID); - - -#define HALF_2024_LINE (512>>3) - - plane[0]--; - plane[0]--; - if (depth == 2) { - plane[1]--; - plane[1]--; - } - - /* - * Set bitplane pointers. - */ - tmp = find_copper_inst (this_data->frames[F_STORE_QUAD0], CI_MOVE (R_BPLMOD2)); - CBUMP(tmp); - CMOVE (tmp, R_BPL0PTH, HIADDR (PREP_DMA_MEM (&plane[0][0]))); - CMOVE (tmp, R_BPL0PTL, LOADDR (PREP_DMA_MEM (&plane[0][0]))); - CMOVE (tmp, R_BPL1PTH, HIADDR (PREP_DMA_MEM (&plane[0][full_line]))); - CMOVE (tmp, R_BPL1PTL, LOADDR (PREP_DMA_MEM (&plane[0][full_line]))); - if (depth == 2) { - CMOVE (tmp, R_BPL2PTH, HIADDR (PREP_DMA_MEM (&plane[1][0]))); - CMOVE (tmp, R_BPL2PTL, LOADDR (PREP_DMA_MEM (&plane[1][0]))); - CMOVE (tmp, R_BPL3PTH, HIADDR (PREP_DMA_MEM (&plane[1][full_line]))); - CMOVE (tmp, R_BPL3PTL, LOADDR (PREP_DMA_MEM (&plane[1][full_line]))); - } -#if defined (GRF_ECS) - CMOVE (tmp, R_DIWHIGH, 0x2100); -#endif - CMOVE (tmp, R_COP1LCH, HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_QUAD1]))); - CMOVE (tmp, R_COP1LCL, LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_QUAD1]))); - CEND (tmp); CEND (tmp); - - tmp = find_copper_inst (this_data->frames[F_STORE_QUAD1], CI_MOVE (R_BPLMOD2)); - CBUMP(tmp); - CMOVE (tmp, R_BPL0PTH, HIADDR (PREP_DMA_MEM (&plane[0][HALF_2024_LINE]))); - CMOVE (tmp, R_BPL0PTL, LOADDR (PREP_DMA_MEM (&plane[0][HALF_2024_LINE]))); - CMOVE (tmp, R_BPL1PTH, HIADDR (PREP_DMA_MEM (&plane[0][full_line+HALF_2024_LINE]))); - CMOVE (tmp, R_BPL1PTL, LOADDR (PREP_DMA_MEM (&plane[0][full_line+HALF_2024_LINE]))); - if (depth == 2) { - CMOVE (tmp, R_BPL2PTH, HIADDR (PREP_DMA_MEM (&plane[1][HALF_2024_LINE]))); - CMOVE (tmp, R_BPL2PTL, LOADDR (PREP_DMA_MEM (&plane[1][HALF_2024_LINE]))); - CMOVE (tmp, R_BPL3PTH, HIADDR (PREP_DMA_MEM (&plane[1][full_line+HALF_2024_LINE]))); - CMOVE (tmp, R_BPL3PTL, LOADDR (PREP_DMA_MEM (&plane[1][full_line+HALF_2024_LINE]))); - } -#if defined (GRF_ECS) - CMOVE (tmp, R_DIWHIGH, 0x2100); -#endif - CMOVE (tmp, R_COP1LCH, HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_QUAD2]))); - CMOVE (tmp, R_COP1LCL, LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_QUAD2]))); - CEND (tmp); CEND (tmp); - - tmp = find_copper_inst (this_data->frames[F_STORE_QUAD2], CI_MOVE (R_BPLMOD2)); - CBUMP(tmp); - CMOVE (tmp, R_BPL0PTH, HIADDR (PREP_DMA_MEM (&plane[0][half_plane]))); - CMOVE (tmp, R_BPL0PTL, LOADDR (PREP_DMA_MEM (&plane[0][half_plane]))); - CMOVE (tmp, R_BPL1PTH, HIADDR (PREP_DMA_MEM (&plane[0][half_plane+full_line]))); - CMOVE (tmp, R_BPL1PTL, LOADDR (PREP_DMA_MEM (&plane[0][half_plane+full_line]))); - if (depth == 2) { - CMOVE (tmp, R_BPL2PTH, HIADDR (PREP_DMA_MEM (&plane[1][half_plane]))); - CMOVE (tmp, R_BPL2PTL, LOADDR (PREP_DMA_MEM (&plane[1][half_plane]))); - CMOVE (tmp, R_BPL3PTH, HIADDR (PREP_DMA_MEM (&plane[1][half_plane+full_line]))); - CMOVE (tmp, R_BPL3PTL, LOADDR (PREP_DMA_MEM (&plane[1][half_plane+full_line]))); - } -#if defined (GRF_ECS) - CMOVE (tmp, R_DIWHIGH, 0x2100); -#endif - CMOVE (tmp, R_COP1LCH, HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_QUAD3]))); - CMOVE (tmp, R_COP1LCL, LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_QUAD3]))); - CEND (tmp); CEND (tmp); - - tmp = find_copper_inst (this_data->frames[F_STORE_QUAD3], CI_MOVE (R_BPLMOD2)); - CBUMP(tmp); - CMOVE (tmp, R_BPL0PTH, HIADDR (PREP_DMA_MEM (&plane[0][half_plane+HALF_2024_LINE]))); - CMOVE (tmp, R_BPL0PTL, LOADDR (PREP_DMA_MEM (&plane[0][half_plane+HALF_2024_LINE]))); - CMOVE (tmp, R_BPL1PTH, HIADDR (PREP_DMA_MEM (&plane[0][half_plane+full_line+HALF_2024_LINE]))); - CMOVE (tmp, R_BPL1PTL, LOADDR (PREP_DMA_MEM (&plane[0][half_plane+full_line+HALF_2024_LINE]))); - if (depth == 2) { - CMOVE (tmp, R_BPL2PTH, HIADDR (PREP_DMA_MEM (&plane[1][half_plane+HALF_2024_LINE]))); - CMOVE (tmp, R_BPL2PTL, LOADDR (PREP_DMA_MEM (&plane[1][half_plane+HALF_2024_LINE]))); - CMOVE (tmp, R_BPL3PTH, HIADDR (PREP_DMA_MEM (&plane[1][half_plane+full_line+HALF_2024_LINE]))); - CMOVE (tmp, R_BPL3PTL, LOADDR (PREP_DMA_MEM (&plane[1][half_plane+full_line+HALF_2024_LINE]))); - } -#if defined (GRF_ECS) - CMOVE (tmp, R_DIWHIGH, 0x2100); -#endif - CMOVE (tmp, R_COP1LCH, HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_QUAD0]))); - CMOVE (tmp, R_COP1LCL, LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_QUAD0]))); - CEND (tmp); CEND (tmp); - - /* swap new pointers in. */ - for (i = F_STORE_QUAD0, j = F_QUAD0; - i <= F_STORE_QUAD3; i++, j++) { - cp = this_data->frames[j]; - this_data->frames[j] = this_data->frames[i]; - this_data->frames[i] = cp; - } - - this_data->current_view = v; - vd->flags |= VF_DISPLAY; - - cc_a2024_use_colormap (v, vd->colormap); - } - cc_load_mode (this); -} - -static view_t * -get_current_view (dmode_t *d) -{ - return (this_data->current_view); -} - -static void -pal_a2024_mode_vbl_handler (dmode_t *d) -{ - u_word vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8); - - if (vp < 20) { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[this_data->hedley_current]); - custom.copjmp1 = 0; - } - this_data->hedley_current++; - this_data->hedley_current &= 0x3; /* if 4 then 0. */ -} - -#endif /* GRF_A2024 & GRF_PAL */ - diff --git a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_ph_mode.c b/sys/arch/amiga/dev/grf/grf_cc/grf_cc_ph_mode.c deleted file mode 100644 index 8ed482a1cb51..000000000000 --- a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_ph_mode.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_cc_ph_mode.c,v 1.3 1994/01/30 08:25:11 chopps Exp $ - */ -#if defined (GRF_PAL) - -#include "grf_cc_priv.h" - -static void pal_hires_mode_vbl_handler (dmode_t *d); -static void display_pal_hires_view (view_t *v); -static view_t *get_current_view (dmode_t *d); - -enum frame_numbers { - F_LONG, - F_STORE_LONG, - F_TOTAL -}; - -static dmode_t pal_hires_mode; -static dmdata_t pal_hires_mode_data; -static cop_t *pal_hires_frames[F_TOTAL]; -static dmode_t *this; -static dmdata_t *this_data; - -dmode_t * -cc_init_pal_hires (void) -{ - /* this function should only be called once. */ - if (!this) { - u_word len = std_copper_list_len; - cop_t *cp; - - this = &pal_hires_mode; - this_data = &pal_hires_mode_data; - bzero (this, sizeof (dmode_t)); - bzero (this_data, sizeof (dmdata_t)); - - this->name = "pal: pal_hires interlace"; - this->nominal_size.width = 640; - this->nominal_size.height = 256; - this_data->max_size.width = 724; - this_data->max_size.height = 289; - this_data->min_size.width = 320; - this_data->min_size.height = 244; - this_data->min_depth = 1; - this_data->max_depth = 4; - this->data = this_data; - - this->get_monitor = cc_get_monitor; - this->alloc_view = cc_alloc_view; - this->get_current_view = get_current_view; - - this_data->use_colormap = cc_use_colormap; - this_data->get_colormap = cc_get_colormap; - this_data->alloc_colormap = cc_alloc_colormap; - this_data->display_view = display_pal_hires_view; - this_data->monitor = cc_monitor; - - this_data->frames = pal_hires_frames; - this_data->frames[F_LONG] = alloc_chipmem (std_copper_list_size*F_TOTAL); - if (!this_data->frames[F_LONG]) { - panic ("couldn't get chipmem for copper list"); - } - - this_data->frames[F_STORE_LONG] = &this_data->frames[F_LONG][len]; - - bcopy (std_copper_list, this_data->frames[F_STORE_LONG], std_copper_list_size); - bcopy (std_copper_list, this_data->frames[F_LONG], std_copper_list_size); - - this_data->bplcon0 = 0x8200|USE_CON3; /* pal_hires, color composite enable, lace. */ - this_data->std_start_x = STANDARD_VIEW_X; - this_data->std_start_y = STANDARD_VIEW_Y; - this_data->vbl_handler = (vbl_handler_func *) pal_hires_mode_vbl_handler; -#if defined (GRF_ECS) - this_data->beamcon0 = STANDARD_PAL_BEAMCON; -#endif - - dadd_head (&MDATA(cc_monitor)->modes, &this->node); - } - return (this); -} - -static void -display_pal_hires_view (view_t *v) -{ - if (this_data->current_view != v) { - vdata_t *vd = VDATA(v); - monitor_t *monitor = this_data->monitor; - cop_t *cp = this_data->frames[F_STORE_LONG], *tmp; - int depth = v->bitmap->depth, i; - int hstart, hstop, vstart, vstop, j; - int x, y, w = v->display.width, h = v->display.height; - u_word ddfstart, ddfwidth, con1; - - /* round down to nearest even width */ - /* w &= 0xfffe; */ - - /* calculate datafetch width. */ - ddfwidth = ((v->bitmap->bytes_per_row>>1)-2)<<2; - - /* This will center the any overscanned display */ - /* and allow user to modify. */ - x = v->display.x + this_data->std_start_x - ((w - 640) >> 2); - y = v->display.y + this_data->std_start_y - ((h - 256) >> 1); - - if (y&1) - y--; - - if (!(x&1)) - x--; - - hstart = x; - hstop = x+(w>>1); - vstart = y; - vstop = y+h; - ddfstart = (hstart-9) >> 1; - /* check for hardware limits, AGA may allow more..? */ - /* anyone got a 4000 I can borrow :^) -ch */ - if ((ddfstart&0xfffc) + ddfwidth > 0xd8) { - int d=0; - - /* XXX anyone know the equality properties of intermixed logial AND's */ - /* XXX and arithmetic operators? */ - while (((ddfstart&0xfffc)+ddfwidth-d) > 0xd8) { - d++; - } - - ddfstart -= d; - hstart -= d<<1; - hstop -= d<<1; - } - - /* correct the datafetch to proper limits. */ - /* delay the actual display of the data until we need it. */ - ddfstart &= 0xfffc; - con1 = ((hstart-9)-(ddfstart<<1)) | (((hstart-9)-(ddfstart<<1))<<4); - - if (this_data->current_view) { - VDATA(this_data->current_view)->flags &= ~VF_DISPLAY; /* mark as no longer */ - /* displayed. */ - } - this_data->current_view = v; - - cp = this_data->frames[F_STORE_LONG]; -#if defined GRF_ECS - tmp = find_copper_inst (cp, CI_MOVE(R_BEAMCON0)); - tmp->cp.inst.operand = this_data->beamcon0; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWHIGH)); - tmp->cp.inst.operand = CALC_DIWHIGH (hstart, vstart, hstop, vstop); -#endif /* ECS */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON0)); - tmp->cp.inst.operand = this_data->bplcon0 | ((depth & 0x7) << 12); - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON1)); - tmp->cp.inst.operand = con1; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTART)); - tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTOP)); - tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTART)); - tmp->cp.inst.operand = ddfstart; - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTOP)); - tmp->cp.inst.operand = ddfstart + ddfwidth; - - tmp = find_copper_inst (cp, CI_MOVE(R_BPL0PTH)); - for (i = 0, j = 0; i < depth; j+=2, i++) { - /* update the plane pointers */ - tmp[j].cp.inst.operand = HIADDR (PREP_DMA_MEM (v->bitmap->plane[i])); - tmp[j+1].cp.inst.operand = LOADDR (PREP_DMA_MEM (v->bitmap->plane[i])); - } - - /* set mods correctly. */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPL1MOD)); - tmp[0].cp.inst.operand = v->bitmap->row_mod; - tmp[1].cp.inst.operand = v->bitmap->row_mod; - - /* set next pointers correctly */ - tmp = find_copper_inst (cp, CI_MOVE(R_COP1LCH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - - cp = this_data->frames[F_LONG]; - this_data->frames[F_LONG] = this_data->frames[F_STORE_LONG]; - this_data->frames[F_STORE_LONG] = cp; - - vd->flags |= VF_DISPLAY; - cc_use_colormap (v, vd->colormap); - } - cc_load_mode (this); -} - -static view_t * -get_current_view (dmode_t *d) -{ - return (this_data->current_view); -} - - -static void -pal_hires_mode_vbl_handler (dmode_t *d) -{ - u_word vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8); - - if (vp < 12) { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[F_LONG]); - custom.copjmp1 = 0; - } -} - -#endif /* GRF_PAL */ diff --git a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_phdl_mode.c b/sys/arch/amiga/dev/grf/grf_cc/grf_cc_phdl_mode.c deleted file mode 100644 index 32a5215da8c0..000000000000 --- a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_phdl_mode.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_cc_phdl_mode.c,v 1.3 1994/01/30 08:25:12 chopps Exp $ - */ -#if defined (GRF_A2024) && defined (GRF_PAL) - -#include "grf_cc_priv.h" -#include "../../../amiga/cc_2024.h" - -#if defined (AMIGA_TEST) -#define DEBUG -#include -#else -#define D(x) -#endif - -static void pal_hires_dlace_mode_vbl_handler (dmode_t *d); -static void display_pal_hires_dlace_view (view_t *v); -static view_t *get_current_view (dmode_t *d); - -enum frame_numbers { - F_LONG, - F_SHORT, - F_STORE_LONG, - F_STORE_SHORT, - F_TOTAL -}; - -static dmode_t pal_hires_dlace_mode; -static dmdata_t pal_hires_dlace_mode_data; -static cop_t *pal_hires_dlace_frames[F_TOTAL]; -static dmode_t *this; -static dmdata_t *this_data; - -dmode_t * -cc_init_pal_hires_dlace (void) -{ - /* this function should only be called once. */ - if (!this) { - u_word len = std_dlace_copper_list_len; - cop_t *cp; - - this = &pal_hires_dlace_mode; - this_data = &pal_hires_dlace_mode_data; - bzero (this, sizeof (dmode_t)); - bzero (this_data, sizeof (dmdata_t)); - - this->name = "pal: hires double interlace"; - this->nominal_size.width = 640; - this->nominal_size.height = 1024; - this_data->max_size.width = 724; - this_data->max_size.height = 1024; - this_data->min_size.width = 320; - this_data->min_size.height = 512; - this_data->min_depth = 1; - this_data->max_depth = 2; - this->data = this_data; - - this->get_monitor = cc_get_monitor; - this->alloc_view = cc_alloc_view; - this->get_current_view = get_current_view; - - this_data->use_colormap = cc_a2024_use_colormap; - this_data->get_colormap = cc_a2024_get_colormap; - this_data->alloc_colormap = cc_a2024_alloc_colormap; - this_data->display_view = display_pal_hires_dlace_view; - this_data->monitor = cc_monitor; - - this_data->flags |= DMF_INTERLACE; - - this_data->frames = pal_hires_dlace_frames; - this_data->frames[F_LONG] = alloc_chipmem (std_dlace_copper_list_size*F_TOTAL); - if (!this_data->frames[F_LONG]) { - panic ("couldn't get chipmem for copper list"); - } - - this_data->frames[F_SHORT] = &this_data->frames[F_LONG][len]; - this_data->frames[F_STORE_LONG] = &this_data->frames[F_SHORT][len]; - this_data->frames[F_STORE_SHORT] = &this_data->frames[F_STORE_LONG][len]; - - bcopy (std_dlace_copper_list, this_data->frames[F_STORE_LONG], std_dlace_copper_list_size); - bcopy (std_dlace_copper_list, this_data->frames[F_STORE_SHORT], std_dlace_copper_list_size); - bcopy (std_dlace_copper_list, this_data->frames[F_LONG], std_dlace_copper_list_size); - bcopy (std_dlace_copper_list, this_data->frames[F_SHORT], std_dlace_copper_list_size); - - this_data->bplcon0 = 0x8204|USE_CON3; /* hires, color composite enable, dlace. */ - this_data->std_start_x = STANDARD_VIEW_X; - this_data->std_start_y = STANDARD_VIEW_Y; - this_data->vbl_handler = (vbl_handler_func *) pal_hires_dlace_mode_vbl_handler; -#if defined (GRF_ECS) - this_data->beamcon0 = STANDARD_PAL_BEAMCON; -#endif - - dadd_head (&MDATA(cc_monitor)->modes, &this->node); - } - return (this); -} - -static void -display_pal_hires_dlace_view (view_t *v) -{ - if (this_data->current_view != v) { - vdata_t *vd = VDATA(v); - monitor_t *monitor = this_data->monitor; - cop_t *cp = this_data->frames[F_STORE_LONG], *tmp; - int depth = v->bitmap->depth, i; - int hstart, hstop, vstart, vstop, j; - int x, y, w = v->display.width, h = v->display.height; - u_word ddfstart, ddfwidth, con1; - u_word mod1l, mod2l; - - /* round down to nearest even width */ - /* w &= 0xfffe; */ - - /* calculate datafetch width. */ - ddfwidth = ((v->bitmap->bytes_per_row>>1)-2)<<2; - - /* This will center the any overscanned display */ - /* and allow user to modify. */ - x = v->display.x + this_data->std_start_x - ((w - 640) >> 2); - y = v->display.y + this_data->std_start_y - ((h - 1024) >> 3); - - if (y&1) - y--; - - if (!(x&1)) - x--; - - hstart = x; - hstop = x+(w>>1); - vstart = y; - vstop = y+(h>>2); - ddfstart = (hstart-9) >> 1; - - /* check for hardware limits, AGA may allow more..? */ - /* anyone got a 4000 I can borrow :^) -ch */ - if ((ddfstart&0xfffc) + ddfwidth > 0xd8) { - int d=0; - - /* XXX anyone know the equality properties of intermixed logial AND's */ - /* XXX and arithmetic operators? */ - while (((ddfstart&0xfffc)+ddfwidth-d) > 0xd8) { - d++; - } - - ddfstart -= d; - hstart -= d<<1; - hstop -= d<<1; - } - - /* correct the datafetch to proper limits. */ - /* delay the actual display of the data until we need it. */ - ddfstart &= 0xfffc; - con1 = ((hstart-9)-(ddfstart<<1)) | (((hstart-9)-(ddfstart<<1))<<4); - - if (this_data->current_view) { - VDATA(this_data->current_view)->flags &= ~VF_DISPLAY; /* mark as no longer */ - /* displayed. */ - } - this_data->current_view = v; - - cp = this_data->frames[F_STORE_LONG]; -#if defined GRF_ECS - tmp = find_copper_inst (cp, CI_MOVE(R_BEAMCON0)); - tmp->cp.inst.operand = this_data->beamcon0; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWHIGH)); - tmp->cp.inst.operand = CALC_DIWHIGH (hstart, vstart, hstop, vstop); -#endif /* ECS */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON0)); - tmp->cp.inst.operand = this_data->bplcon0 | ((depth & 0x7) << 13); /* times two. */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON1)); - tmp->cp.inst.operand = con1; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTART)); - tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTOP)); - tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTART)); - tmp->cp.inst.operand = ddfstart; - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTOP)); - tmp->cp.inst.operand = ddfstart + ddfwidth; - - mod1l = v->bitmap->bytes_per_row + v->bitmap->row_mod; - mod2l = mod1l << 1; - - tmp = find_copper_inst (cp, CI_MOVE(R_BPL0PTH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[0][0])); /* update plane pointers. */ - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[0][0])); /* high and low. */ - tmp[2].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod1l])); /* update plane pointers. */ - tmp[3].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod1l])); /* high and low. */ - if (depth == 2) { - tmp[4].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[1][0])); /* update plane pointers. */ - tmp[5].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[1][0])); /* high and low. */ - tmp[6].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod1l])); /* update plane pointers. */ - tmp[7].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod1l])); /* high and low. */ - } - - /* set mods correctly. */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPL1MOD)); - tmp[0].cp.inst.operand = mod2l + mod1l; - tmp[1].cp.inst.operand = mod2l + mod1l; - - /* set next pointers correctly */ - tmp = find_copper_inst (cp, CI_MOVE(R_COP1LCH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_SHORT])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_SHORT])); - - bcopy (this_data->frames[F_STORE_LONG], this_data->frames[F_STORE_SHORT], std_dlace_copper_list_size); - - /* these are the only ones that are different from long frame. */ - cp = this_data->frames[F_STORE_SHORT]; - tmp = find_copper_inst (cp, CI_MOVE(R_BPL0PTH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod2l])); /* update plane pointers. */ - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod2l])); /* high and low. */ - tmp[2].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod2l+mod1l])); /* update plane pointers. */ - tmp[3].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[0][mod2l+mod1l])); /* high and low. */ - if (depth == 2) { - tmp[4].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod2l])); /* update plane pointers. */ - tmp[5].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod2l])); /* high and low. */ - tmp[6].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod2l+mod1l])); /* update plane pointers. */ - tmp[7].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[1][mod2l+mod1l])); /* high and low. */ - } - - /* set next pointers correctly */ - tmp = find_copper_inst (cp, CI_MOVE(R_COP1LCH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - - cp = this_data->frames[F_LONG]; - this_data->frames[F_LONG] = this_data->frames[F_STORE_LONG]; - this_data->frames[F_STORE_LONG] = cp; - - cp = this_data->frames[F_SHORT]; - this_data->frames[F_SHORT] = this_data->frames[F_STORE_SHORT]; - this_data->frames[F_STORE_SHORT] = cp; - - vd->flags |= VF_DISPLAY; - - cc_a2024_use_colormap (v, vd->colormap); - } - cc_load_mode (this); -} - -static view_t * -get_current_view (dmode_t *d) -{ - return (this_data->current_view); -} - -static void -pal_hires_dlace_mode_vbl_handler (dmode_t *d) -{ - u_word vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8); - - if (vp < 12) { - if (custom.vposr & 0x8000) { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[F_LONG]); - } else { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[F_SHORT]); - } - custom.copjmp1 = 0; - } -} - -#endif /* GRF_A2024 && GRF_PAL */ diff --git a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_phl_mode.c b/sys/arch/amiga/dev/grf/grf_cc/grf_cc_phl_mode.c deleted file mode 100644 index 5048dae62524..000000000000 --- a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_phl_mode.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_cc_phl_mode.c,v 1.3 1994/01/30 08:25:14 chopps Exp $ - */ -#if defined (GRF_PAL) - -#include "grf_cc_priv.h" - -static void pal_hires_lace_mode_vbl_handler (dmode_t *d); -static void display_pal_hires_lace_view (view_t *v); -static view_t *get_current_view (dmode_t *d); - -enum frame_numbers { - F_LONG, - F_SHORT, - F_STORE_LONG, - F_STORE_SHORT, - F_TOTAL -}; - -static dmode_t pal_hires_lace_mode; -static dmdata_t pal_hires_lace_mode_data; -static cop_t *pal_hires_lace_frames[F_TOTAL]; -static dmode_t *this; -static dmdata_t *this_data; - -dmode_t * -cc_init_pal_hires_lace (void) -{ - /* this function should only be called once. */ - if (!this) { - u_word len = std_copper_list_len; - cop_t *cp; - - this = &pal_hires_lace_mode; - this_data = &pal_hires_lace_mode_data; - bzero (this, sizeof (dmode_t)); - bzero (this_data, sizeof (dmdata_t)); - - this->name = "pal: hires interlace"; - this->nominal_size.width = 640; - this->nominal_size.height = 512; - this_data->max_size.width = 724; - this_data->max_size.height = 578; - this_data->min_size.width = 320; - this_data->min_size.height = 484; - this_data->min_depth = 1; - this_data->max_depth = 4; - this->data = this_data; - - this->get_monitor = cc_get_monitor; - this->alloc_view = cc_alloc_view; - this->get_current_view = get_current_view; - - this_data->use_colormap = cc_use_colormap; - this_data->get_colormap = cc_get_colormap; - this_data->alloc_colormap = cc_alloc_colormap; - this_data->display_view = display_pal_hires_lace_view; - this_data->monitor = cc_monitor; - - this_data->flags |= DMF_INTERLACE; - - this_data->frames = pal_hires_lace_frames; - this_data->frames[F_LONG] = alloc_chipmem (std_copper_list_size*F_TOTAL); - if (!this_data->frames[F_LONG]) { - panic ("couldn't get chipmem for copper list"); - } - - this_data->frames[F_SHORT] = &this_data->frames[F_LONG][len]; - this_data->frames[F_STORE_LONG] = &this_data->frames[F_SHORT][len]; - this_data->frames[F_STORE_SHORT] = &this_data->frames[F_STORE_LONG][len]; - - bcopy (std_copper_list, this_data->frames[F_STORE_LONG], std_copper_list_size); - bcopy (std_copper_list, this_data->frames[F_STORE_SHORT], std_copper_list_size); - bcopy (std_copper_list, this_data->frames[F_LONG], std_copper_list_size); - bcopy (std_copper_list, this_data->frames[F_SHORT], std_copper_list_size); - - this_data->bplcon0 = 0x8204|USE_CON3; /* hires, color composite enable, lace. */ - this_data->std_start_x = STANDARD_VIEW_X; - this_data->std_start_y = STANDARD_VIEW_Y; - this_data->vbl_handler = (vbl_handler_func *) pal_hires_lace_mode_vbl_handler; -#if defined (GRF_ECS) - this_data->beamcon0 = STANDARD_PAL_BEAMCON; -#endif - - dadd_head (&MDATA(cc_monitor)->modes, &this->node); - } - return (this); -} - -static void -display_pal_hires_lace_view (view_t *v) -{ - if (this_data->current_view != v) { - vdata_t *vd = VDATA(v); - monitor_t *monitor = this_data->monitor; - cop_t *cp = this_data->frames[F_STORE_LONG], *tmp; - int depth = v->bitmap->depth, i; - int hstart, hstop, vstart, vstop, j; - int x, y, w = v->display.width, h = v->display.height; - u_word ddfstart, ddfwidth, con1; - - /* round down to nearest even width */ - /* w &= 0xfffe; */ - - /* calculate datafetch width. */ - ddfwidth = ((v->bitmap->bytes_per_row>>1)-2)<<2; - - /* This will center the any overscanned display */ - /* and allow user to modify. */ - x = v->display.x + this_data->std_start_x - ((w - 640) >> 2); - y = v->display.y + this_data->std_start_y - ((h - 512) >> 2); - - if (y&1) - y--; - - if (!(x&1)) - x--; - - hstart = x; - hstop = x+(w>>1); - vstart = y; - vstop = y+(h>>1); - ddfstart = (hstart-9) >> 1; - - /* check for hardware limits, AGA may allow more..? */ - /* anyone got a 4000 I can borrow :^) -ch */ - if ((ddfstart&0xfffc) + ddfwidth > 0xd8) { - int d=0; - - /* XXX anyone know the equality properties of intermixed logial AND's */ - /* XXX and arithmetic operators? */ - while (((ddfstart&0xfffc)+ddfwidth-d) > 0xd8) { - d++; - } - - ddfstart -= d; - hstart -= d<<1; - hstop -= d<<1; - } - - /* correct the datafetch to proper limits. */ - /* delay the actual display of the data until we need it. */ - ddfstart &= 0xfffc; - con1 = ((hstart-9)-(ddfstart<<1)) | (((hstart-9)-(ddfstart<<1))<<4); - - if (this_data->current_view) { - VDATA(this_data->current_view)->flags &= ~VF_DISPLAY; /* mark as no longer */ - /* displayed. */ - } - this_data->current_view = v; - - cp = this_data->frames[F_STORE_LONG]; -#if defined GRF_ECS - tmp = find_copper_inst (cp, CI_MOVE(R_BEAMCON0)); - tmp->cp.inst.operand = this_data->beamcon0; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWHIGH)); - tmp->cp.inst.operand = CALC_DIWHIGH (hstart, vstart, hstop, vstop); -#endif /* ECS */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON0)); - tmp->cp.inst.operand = this_data->bplcon0 | ((depth & 0x7) << 12); - tmp = find_copper_inst (cp, CI_MOVE(R_BPLCON1)); - tmp->cp.inst.operand = con1; - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTART)); - tmp->cp.inst.operand = ((vstart & 0xff) << 8) | (hstart & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DIWSTOP)); - tmp->cp.inst.operand = ((vstop & 0xff) << 8) | (hstop & 0xff); - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTART)); - tmp->cp.inst.operand = ddfstart; - tmp = find_copper_inst (cp, CI_MOVE(R_DDFSTOP)); - tmp->cp.inst.operand = ddfstart + ddfwidth; - - tmp = find_copper_inst (cp, CI_MOVE(R_BPL0PTH)); - for (i = 0, j = 0; i < depth; j+=2, i++) { - /* update the plane pointers */ - tmp[j].cp.inst.operand = HIADDR (PREP_DMA_MEM (v->bitmap->plane[i])); - tmp[j+1].cp.inst.operand = LOADDR (PREP_DMA_MEM (v->bitmap->plane[i])); - } - - /* set mods correctly. */ - tmp = find_copper_inst (cp, CI_MOVE(R_BPL1MOD)); - tmp[0].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod; - tmp[1].cp.inst.operand = v->bitmap->bytes_per_row + v->bitmap->row_mod; - - /* set next pointers correctly */ - tmp = find_copper_inst (cp, CI_MOVE(R_COP1LCH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_SHORT])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_SHORT])); - - - bcopy (this_data->frames[F_STORE_LONG], this_data->frames[F_STORE_SHORT], std_copper_list_size); - - /* these are the only ones that are different from long frame. */ - cp = this_data->frames[F_STORE_SHORT]; - tmp = find_copper_inst (cp, CI_MOVE(R_BPL0PTH)); - for (i=0, j=0; i < depth; j+=2, i++) { - u_word mod = v->bitmap->bytes_per_row + v->bitmap->row_mod; - /* update plane pointers. high and low. */ - tmp[j].cp.inst.operand = HIADDR (PREP_DMA_MEM (&v->bitmap->plane[i][mod])); - tmp[j+1].cp.inst.operand = LOADDR (PREP_DMA_MEM (&v->bitmap->plane[i][mod])); - } - - /* set next pointers correctly */ - tmp = find_copper_inst (cp, CI_MOVE(R_COP1LCH)); - tmp[0].cp.inst.operand = HIADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - tmp[1].cp.inst.operand = LOADDR (PREP_DMA_MEM (this_data->frames[F_STORE_LONG])); - - - cp = this_data->frames[F_LONG]; - this_data->frames[F_LONG] = this_data->frames[F_STORE_LONG]; - this_data->frames[F_STORE_LONG] = cp; - - cp = this_data->frames[F_SHORT]; - this_data->frames[F_SHORT] = this_data->frames[F_STORE_SHORT]; - this_data->frames[F_STORE_SHORT] = cp; - - vd->flags |= VF_DISPLAY; - cc_use_colormap (v, vd->colormap); - } - cc_load_mode (this); -} - -static view_t * -get_current_view (dmode_t *d) -{ - return (this_data->current_view); -} - - -static void -pal_hires_lace_mode_vbl_handler (dmode_t *d) -{ - u_word vp = ((custom.vposr & 0x0007) << 8) | ((custom.vhposr) >> 8); - - if (vp < 12) { - if (custom.vposr & 0x8000) { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[F_LONG]); - } else { - custom.cop1lc = PREP_DMA_MEM (this_data->frames[F_SHORT]); - } - custom.copjmp1 = 0; - } -} - -#endif /* GRF_PAL */ diff --git a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_priv.h b/sys/arch/amiga/dev/grf/grf_cc/grf_cc_priv.h deleted file mode 100644 index b06361e771bd..000000000000 --- a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_priv.h +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_cc_priv.h,v 1.3 1994/01/30 08:25:16 chopps Exp $ - */ - -#if ! defined (_GRF_CCPRIV_H) -#define _GRF_CCPRIV_H - -#include "../../../amiga/cc.h" -#include "../../../amiga/cc_chipmem.h" -#include "../../../amiga/cc_copper.h" -#include "../../../amiga/cc_registers.h" -#include "../../../amiga/dlists.h" -#include "../grf_types.h" -#include "../grf_bitmap.h" -#include "../grf_view.h" -#include "../grf_mode.h" -#include "../grf_monitor.h" -#include "../grf_colormap.h" -#include "../grf_draw.h" -#include "grf_cc_custom.h" - -typedef colormap_t *alloc_colormap_func (int); - -typedef struct monitor_data { - dll_list_t modes; /* a list of supported modes. */ - dmode_t *current_mode; - u_long flags; /* monitor flags. */ -} mdata_t; - -typedef struct display_mode_data { - monitor_t * monitor; /* the monitor that owns this mode. */ - view_t * current_view; /* current view to be displayed. */ - cop_t **frames; - u_word hedley_current; /* current hedley quadrent. */ - u_word bplcon0; /* bplcon0 data. */ - u_word std_start_x; - u_word std_start_y; -#if defined (GRF_ECS) - /* ECS registers. */ - u_word beamcon0; - u_word hbstart; /* no modes use the rest of these */ - u_word hbstop; /* ECS registers. */ - u_word hsstart; - u_word hsstop; - u_word vbstart; - u_word vbstop; - u_word vsstart; - u_word vsstop; -#endif - /* some limit stuff. */ - dimen_t max_size; /* largest fit. */ - dimen_t min_size; /* smallest fit. */ - u_word min_depth; - u_word max_depth; - u_long flags; /* mode specific flags. */ - use_colormap_func *use_colormap; - get_colormap_func *get_colormap; - alloc_colormap_func *alloc_colormap; - display_view_func *display_view; - vbl_handler_func *vbl_handler; /* gets called every vertical blank. */ - /* when this is the current mode.*/ -} dmdata_t; - -enum dmode_flag_bits { - DMB_INTERLACE, - DMB_HEDLEY_EXP -}; - -enum dmode_flags { - DMF_INTERLACE = 1 << DMB_INTERLACE, - DMF_HEDLEY_EXP = 1 << DMB_HEDLEY_EXP -}; - -typedef struct view_data { - dmode_t *mode; /* the mode for this view */ - colormap_t *colormap; - u_long flags; /* view specific flags. */ -} vdata_t; - -enum view_flag_bits { - VB_DISPLAY, -}; - -enum view_flags { - VF_DISPLAY = 1 << VB_DISPLAY, /* set if view is being displayed */ -}; - -/* mode locally public functions */ -int cc_init_modes (void); -#if defined (GRF_NTSC) -#if defined (GRF_A2024) -dmode_t *cc_init_ntsc_a2024 (void); -dmode_t *cc_init_ntsc_hires_dlace (void); -#endif -dmode_t *cc_init_ntsc_hires_lace (void); -dmode_t *cc_init_ntsc_hires (void); -#endif -#if defined (GRF_PAL) -#if defined (GRF_A2024) -dmode_t *cc_init_pal_a2024 (void); -dmode_t *cc_init_pal_hires_dlace (void); -#endif -dmode_t *cc_init_pal_hires (void); -dmode_t *cc_init_pal_hires_lace (void); -#endif - -monitor_t *cc_get_monitor (dmode_t *d); - -view_t *cc_get_current_view (dmode_t *m); -view_t *cc_alloc_view (dmode_t *mode, dimen_t *dim, u_byte depth); -void cc_mode_vbl_handler (dmode_t *m); -void cc_init_view (view_t *v, bmap_t *bm, dmode_t *mode, box_t *dbox); -void cc_free_view (view_t *v); -int cc_use_colormap (view_t *v, colormap_t *); -int cc_get_colormap (view_t *v, colormap_t *); -void cc_remove_view (view_t *v); -void cc_load_mode (dmode_t *d); -colormap_t * cc_alloc_colormap (int); - -#if defined (GRF_A2024) -int cc_a2024_use_colormap (view_t *v, colormap_t *); -int cc_a2024_get_colormap (view_t *v, colormap_t *); -colormap_t * cc_a2024_alloc_colormap (int); - -#if defined (GRF_PAL) -extern cop_t std_pal_a2024_copper_list[]; -extern int std_pal_a2024_copper_list_len; -extern int std_pal_a2024_copper_list_size; -#endif - -extern cop_t std_a2024_copper_list[]; -extern int std_a2024_copper_list_len; -extern int std_a2024_copper_list_size; - -extern cop_t std_dlace_copper_list[]; -extern int std_dlace_copper_list_len; -extern int std_dlace_copper_list_size; - -#endif /* GRF_A2024 */ - -extern cop_t std_copper_list[]; -extern int std_copper_list_len; -extern int std_copper_list_size; -extern monitor_t *cc_monitor; - -#define MDATA(m) ((mdata_t *)(m->data)) -#define DMDATA(d) ((dmdata_t *)(d->data)) -#define VDATA(v) ((vdata_t *)(v->data)) -#define RWDATA(r) ((rwdata_t *)(r->data)) - -#if defined (GRF_ECS) -#define CALC_DIWHIGH(hs, vs, he, ve) \ - ((u_word)((he&0x100)<<5)|(ve&0x700)|((hs&0x100)>>3)|((vs&0x700)>>8)) -#define USE_CON3 0x0001 -#else -#define USE_CON3 0x0 -#endif - -#endif /* _GRF_CCPRIV_H */ diff --git a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_view.c b/sys/arch/amiga/dev/grf/grf_cc/grf_cc_view.c deleted file mode 100644 index c0ee0dcced2e..000000000000 --- a/sys/arch/amiga/dev/grf/grf_cc/grf_cc_view.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_cc_view.c,v 1.2 1994/01/29 07:00:36 chopps Exp $ - */ - -#include "grf_cc_priv.h" - -static dmode_t *get_display_mode (view_t *v); - -void -cc_init_view (view_t *v, bmap_t *bm, dmode_t *mode, box_t *dbox) -{ - vdata_t *vd = VDATA(v); - v->bitmap = bm; - vd->mode = mode; - bcopy (dbox, &v->display, sizeof (box_t)); - - v->display_view = DMDATA(vd->mode)->display_view; - v->use_colormap = DMDATA(vd->mode)->use_colormap; - v->get_colormap = DMDATA(vd->mode)->get_colormap; - v->free_view = cc_free_view; - v->get_display_mode = get_display_mode; - v->remove_view = cc_remove_view; -} - -void -cc_free_view (view_t *v) -{ - if (v) { - vdata_t *vd = VDATA(v); - dmode_t *md = vd->mode; - v->remove_view (v); - cc_monitor->free_bitmap (v->bitmap); - free_chipmem (v); - } -} - -void -cc_remove_view (view_t *v) -{ - dmode_t *mode = VDATA (v)->mode; - - if (MDATA(cc_monitor)->current_mode == mode) { - if (DMDATA(mode)->current_view == v) { - cc_load_mode (NULL); - } - } - if (DMDATA(mode)->current_view == v) { - DMDATA(mode)->current_view = NULL; - } - - VDATA (v)->flags &= ~VF_DISPLAY; -} - -static dmode_t * -get_display_mode (view_t *v) -{ - return (VDATA(v)->mode); -} - diff --git a/sys/arch/amiga/dev/grf/grf_cc/grf_ccc.c b/sys/arch/amiga/dev/grf/grf_cc/grf_ccc.c deleted file mode 100644 index 7efe247309ad..000000000000 --- a/sys/arch/amiga/dev/grf/grf_cc/grf_ccc.c +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_ccc.c,v 1.2 1994/01/29 07:00:38 chopps Exp $ - */ -#include "sys/param.h" -#include "grf_cc_priv.h" - -/* local prototypes */ -static void monitor_vbl_handler (monitor_t *m); -static dmode_t *get_next_mode (dmode_t *d); -static dmode_t *get_current_mode (void); -static dmode_t *get_best_mode (dimen_t *size, u_byte depth); -static void cc_set_flags (mdata_t *md); - -/* bitmap functions */ -static bmap_t *alloc_bitmap (u_word width, u_word height, u_word depth, u_word flags); -static void free_bitmap (bmap_t *bm); -void scroll_bitmap (bmap_t *bm, u_word x, u_word y, u_word width, u_word height, word dx, word dy, u_byte mask); - -/* a pointer to us. */ -static monitor_t *this; -static mdata_t *this_data; - -/* the monitor name */ -static char *monitor_name = "CCMONITOR"; - -/* the custom chip monitor structure. */ -static monitor_t monitor; -static mdata_t monitor_data; - -/* our simple copper blanker copper list */ -static cop_t *null_mode_copper_list; - -extern dll_list_t *monitors; - -/* monitor functions. */ -monitor_t * -cc_init_monitor (void) -{ - if (!this) { - cop_t *cp; - cc_monitor = this = &monitor; - - /* turn sprite DMA off. we don't support them yet. */ - custom.dmacon = DMAF_SPRITE; - - this->node.next = this->node.prev = NULL; - this->name = monitor_name; - this_data = this->data = &monitor_data; - - this->get_current_mode = get_current_mode; - this->vbl_handler = (vbl_handler_func *) monitor_vbl_handler; - this->get_next_mode = get_next_mode; - this->get_best_mode = get_best_mode; - - this->alloc_bitmap = alloc_bitmap; - this->free_bitmap = free_bitmap; - - this_data->current_mode = NULL; - dinit_list (&this_data->modes); - - cp = null_mode_copper_list = alloc_chipmem (sizeof (cop_t) * 4); - if (!cp) { - panic ("no chipmem for grf."); - } - CMOVE (cp, R_COLOR00, 0x0000); /* background is black */ - CMOVE (cp, R_BPLCON0, 0x0000); /* no planes to fetch from */ - CWAIT (cp, 255, 255); /* COPEND */ - CWAIT (cp, 255, 255); /* COPEND really */ - - /* install this list and turn DMA on */ - custom.cop1lc = PREP_DMA_MEM (null_mode_copper_list); - custom.copjmp1 = 0; - custom.dmacon = DMAF_SETCLR | DMAF_MASTER | DMAF_RASTER \ - | DMAF_COPPER; - - cc_init_modes(); - dadd_tail (monitors, &this->node); - } - return (this); -} - -static void -monitor_vbl_handler (monitor_t *m) -{ - if (this_data->current_mode) { - DMDATA(this_data->current_mode)->vbl_handler (this_data->current_mode); - } -} - -static dmode_t * -get_current_mode (void) -{ - if (this_data->current_mode) { - return (this_data->current_mode); - } else { - return (NULL); - } -} - -static dmode_t * -get_next_mode (dmode_t *d) -{ - if (d) { - if (d->node.next->next) { - return ((dmode_t *)d->node.next); - } - } else if (this_data->modes.head->next) { - return ((dmode_t *)this_data->modes.head); - } else { - return (NULL); - } -} - -static dmode_t * -get_best_mode (dimen_t *size, u_byte depth) -{ - /* FIX: */ - dmode_t *save = NULL; - dmode_t *m = (dmode_t *)this_data->modes.head; - long dt; - - while (m->node.next) { - long dx, dy, ct; - dmdata_t *dmd = m->data; - - if (depth > dmd->max_depth || depth < dmd->min_depth) { - m = (dmode_t *)m->node.next; - continue; - } - if (size->width > dmd->max_size.width || size->height > dmd->max_size.height) { - m = (dmode_t *)m->node.next; - continue; - } - if (size->width < dmd->min_size.width || size->height < dmd->min_size.height) { - m = (dmode_t *)m->node.next; - continue; - } - - dx = abs (m->nominal_size.width - size->width); - dy = abs (m->nominal_size.height - size->height); - ct = dx + dy; - - if (ct < dt || save == NULL) { - save = m; - dt = ct; - } - - m = (dmode_t *)m->node.next; - } - return (save); -} - -/* bitmap functions */ -static bmap_t * -alloc_bitmap (u_word width, u_word height, u_word depth, u_word flags) -{ - int i; - u_long total_size; - u_word lwpr = (width+31)/32; - u_word wpr = lwpr << 1; - u_word bpr = wpr << 1; - u_word array_size = sizeof (u_byte *) * depth; - u_long plane_size = bpr*height; - u_word temp_size = bpr + sizeof (u_long); - bmap_t *bm; - - /* note the next allocation will give everything, also note that - * all the stuff we want (including bitmaps) will be long word - * aligned. This is a function of the data being allocated and - * the fact that alloc_chipmem() returns long word aligned data. - * note also that each row of the bitmap is long word aligned and - * made of exactly n longwords. - * -ch - */ - - /* Sigh, it seems for mapping to work we need the bitplane data to - * 1: be aligned on a page boundry. - * 2: be n pages large. - * - * why? becuase the user gets a page aligned address, if this is - * before your allocation, too bad. Also it seems that the mapping - * routines do not watch to closely to the allowable length. so if - * you go over n pages by less than another page, the user gets to write - * all over the entire page. Since you did not allocate up to a page - * boundry (or more) the user writes into someone elses memory. - * -ch - */ - total_size = amiga_round_page (plane_size*depth)+ /* for length */ - (temp_size) + (array_size) + sizeof (bmap_t) + - NBPG; /* for alignment */ - bm = alloc_chipmem (total_size); - if (bm) { - if (flags & BMF_CLEAR) { - bzero (bm, total_size); - } - bm->bytes_per_row = bpr; - bm->rows = height; - bm->depth = depth; - bm->flags = flags; - bm->plane = (u_byte **)&bm[1]; - bm->blit_temp = ((u_byte *)bm->plane) + array_size; - bm->plane[0] = (u_byte *)amiga_round_page ((u_long)(bm->blit_temp+temp_size)); - if (flags & BMF_INTERLEAVED) { - bm->row_mod = bm->bytes_per_row * (depth-1); - for (i = 1; i < depth; i++) { - bm->plane[i] = bm->plane[i-1] + bpr; - } - } else { - bm->row_mod = 0; - for (i = 1; i < depth; i++) { - bm->plane[i] = bm->plane[i-1] + plane_size; - } - } - bm->hardware_address = PREP_DMA_MEM (bm->plane[0]); - return (bm); - } - return (NULL); -} - - -static void -free_bitmap (bmap_t *bm) -{ - if (bm) { - free_chipmem (bm); - } -} - -/* load a new mode into the current display, if NULL shut display off. */ -void -cc_load_mode (dmode_t *d) -{ - if (d) { - this_data->current_mode = d; - return; - } - /* turn off display */ - this_data->current_mode = NULL; - wait_tof (); - wait_tof (); - custom.cop1lc = PREP_DMA_MEM (null_mode_copper_list); -} diff --git a/sys/arch/amiga/dev/grf/grf_monitor.c b/sys/arch/amiga/dev/grf/grf_monitor.c deleted file mode 100644 index ea472ef79ece..000000000000 --- a/sys/arch/amiga/dev/grf/grf_monitor.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_monitor.c,v 1.2 1994/01/29 06:59:57 chopps Exp $ - */ -#include "grf_types.h" -#include "grf_monitor.h" - -dmode_t * -grf_get_next_mode (monitor_t *m, dmode_t *d) -{ - return (m->get_next_mode (d)); -} - -dmode_t * -grf_get_current_mode (monitor_t *m) -{ - return (m->get_current_mode ()); -} - -dmode_t * -grf_get_best_mode (monitor_t *m, dimen_t *size, u_byte depth) -{ - return (m->get_best_mode (size, depth)); -} - -bmap_t * -grf_alloc_bitmap (monitor_t *m, u_word w, u_word h, u_word d, u_word f) -{ - return (m->alloc_bitmap (w, h, d, f)); -} - -void -grf_free_bitmap (monitor_t *m, bmap_t *bm) -{ - m->free_bitmap (bm); -} - diff --git a/sys/arch/amiga/dev/grf/grf_monitor.h b/sys/arch/amiga/dev/grf/grf_monitor.h deleted file mode 100644 index 6aca4fc2c291..000000000000 --- a/sys/arch/amiga/dev/grf/grf_monitor.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_monitor.h,v 1.2 1994/01/29 06:59:58 chopps Exp $ - */ - -#if ! defined (_GRF_MONITOR_H) -#define _GRF_MONITOR_H - -/* monitor functions */ - -/* this function will be called for every (maybe) VB if the mode is - * the active one */ -typedef void vbl_handler_func (void *); - -/* returns the next mode given a mode or the first if NULL */ -typedef dmode_t *get_next_mode_func (dmode_t *); - -/* returns the currently active mode this can be NULL if none are active */ -typedef dmode_t *get_current_mode_func (void); - -/* returns the mode that best fits the parameters, or NULL if none fit */ -typedef dmode_t *get_best_mode_func (dimen_t *size, u_byte depth); - -/* allocate a bitmap for use with this monitor see notes on restrictions */ -typedef bmap_t *alloc_bitmap_func (u_word w, u_word h, u_word d, u_word f); - -/* free a bitmap that was allocated with this monitors alloc_bitmap() - * function. */ -typedef void free_bitmap_func (bmap_t *bm); - -/* monitor: support different graphic boards and viewmodes. */ -struct monitor { - dll_node_t node; /* a link into the database. */ - u_byte *name; /* a logical name for this monitor. */ - void *data; /* monitor specific data. */ - - /* funciton interface to this monitor. */ - vbl_handler_func *vbl_handler; /* gets called on every vbl if not NULL */ - get_next_mode_func *get_next_mode; /* return next mode in list */ - get_current_mode_func *get_current_mode; /* return active mode or NULL */ - get_best_mode_func *get_best_mode; /* return mode that best fits */ - - alloc_bitmap_func *alloc_bitmap; /* allocate a bitmap for use with this monitor */ - free_bitmap_func *free_bitmap; /* free a bitmap */ -}; - -dmode_t * grf_get_next_mode (monitor_t *m, dmode_t *d); -dmode_t * grf_get_current_mode (monitor_t *); -dmode_t * grf_get_best_mode (monitor_t *m, dimen_t *size, u_byte depth); -bmap_t * grf_alloc_bitmap (monitor_t *m, u_word w, u_word h, u_word d, u_word f); -void grf_free_bitmap (monitor_t *m, bmap_t *bm); - -#endif /* _GRF_MONITOR_H */ - diff --git a/sys/arch/amiga/dev/grf/grf_types.h b/sys/arch/amiga/dev/grf/grf_types.h deleted file mode 100644 index 723ce9f12e77..000000000000 --- a/sys/arch/amiga/dev/grf/grf_types.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_types.h,v 1.2 1994/01/29 07:00:00 chopps Exp $ - */ - - -#if ! defined (_GRF_TYPES_H) -#define _GRF_TYPES_H - -#include "sys/types.h" -#include "../../amiga/cc_types.h" /* the user should not have to request these */ -#include "../../amiga/dlists.h" /* just to use the graphics stuff. */ - -typedef struct point { - long x; - long y; -} point_t; - -typedef struct dimension { - u_long width; - u_long height; -} dimen_t; - -typedef struct box { - long x; - long y; - u_long width; - u_long height; -} box_t; - -typedef struct rectangle { - long left; - long top; - long right; - long bottom; -} rect_t; - -/* these are defined on a need to know basis (in their respective files */ -typedef struct bitmap bmap_t; -typedef struct colormap colormap_t; -typedef struct display_mode dmode_t; -typedef struct view view_t; -typedef struct monitor monitor_t; - -#endif /* _GRF_TYPES_H */ diff --git a/sys/arch/amiga/dev/grf/grf_view.c b/sys/arch/amiga/dev/grf/grf_view.c deleted file mode 100644 index 064d157ce446..000000000000 --- a/sys/arch/amiga/dev/grf/grf_view.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_view.c,v 1.2 1994/01/29 07:00:02 chopps Exp $ - */ -#include "grf_types.h" -#include "grf_view.h" -#include "grf_mode.h" - -/* defined in grf.c */ -dmode_t *get_best_display_mode (u_long width, u_long height, u_byte depth); - -void -grf_display_view (view_t *v) -{ - v->display_view (v); -} - -view_t * -grf_alloc_view (dmode_t *d, dimen_t *dim, u_byte depth) -{ - if (!d) { - d = get_best_display_mode (dim->width, dim->height, depth); - } - if (d) { - return (d->alloc_view (d, dim, depth)); - } - return (NULL); -} - -void -grf_remove_view (view_t *v) -{ - v->remove_view (v); -} - -void -grf_free_view (view_t *v) -{ - v->free_view (v); -} - -dmode_t * -grf_get_display_mode (view_t *v) -{ - return (v->get_display_mode (v)); -} - -int -grf_get_colormap (view_t *v, colormap_t *cm) -{ - return (v->get_colormap (v, cm)); -} - -int -grf_use_colormap (view_t *v, colormap_t *cm) -{ - return (v->use_colormap (v, cm)); -} - - diff --git a/sys/arch/amiga/dev/grf/grf_view.h b/sys/arch/amiga/dev/grf/grf_view.h deleted file mode 100644 index 93fa4609b603..000000000000 --- a/sys/arch/amiga/dev/grf/grf_view.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grf_view.h,v 1.2 1994/01/29 07:00:05 chopps Exp $ - */ - -#if ! defined (_GRF_VIEW_H) -#define _GRF_VIEW_H - -/* removes the view if displaying */ -typedef void remove_view_func (view_t *v); - -/* free's the memory for this view and removes it if displaying */ -typedef void free_view_func (view_t *v); - -/* displays this view */ -typedef void display_view_func (view_t *v); - -/* returns mode of this view */ -typedef dmode_t *get_mode_func (view_t *v); - -/* fills in color map structure with requested registers */ -typedef int get_colormap_func (view_t *v, colormap_t *); - -/* sets this views colors according to the color map structure. */ -typedef int use_colormap_func (view_t *v, colormap_t *); - -struct view { - bmap_t *bitmap; /* bitmap. */ - box_t display; /* viewable area. */ - void *data; /* view specific data. */ - - /* functions */ - display_view_func *display_view; /* make this view active */ - remove_view_func *remove_view; /* remove this view if active */ - free_view_func *free_view; /* free this view */ - get_mode_func *get_display_mode; /* get the mode this view belongs to */ - get_colormap_func *get_colormap; /* get a color map for registers */ - use_colormap_func *use_colormap; /* use color map to load registers */ -}; - -view_t * grf_alloc_view (dmode_t *d, dimen_t *dim, u_byte depth); -void grf_display_view (view_t *v); -void grf_remove_view (view_t *v); -void grf_free_view (view_t *v); -dmode_t *grf_get_display_mode (view_t *v); -int grf_get_colormap (view_t *v, colormap_t *cm); -int grf_use_colormap (view_t *v, colormap_t *cm); - -#define VDISPLAY_LINE(v, p, l) ((v)->bitmap->plane[p] +\ - (((v)->bitmap->bytes_per_row+(v)->bitmap->row_mod)*l)) - -#endif /* _GRF_VIEW_H */ - diff --git a/sys/arch/amiga/dev/grf/grfcc.c b/sys/arch/amiga/dev/grf/grfcc.c deleted file mode 100644 index 560c55bec30c..000000000000 --- a/sys/arch/amiga/dev/grf/grfcc.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1994 Christian E. Hopps - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christian E. Hopps. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: grfcc.c,v 1.2 1994/01/29 07:00:08 chopps Exp $ - */ - -#include - -#include "../../amiga/cc_vbl.h" -#include "grf_types.h" -#include "grf_mode.h" -#include "grf_monitor.h" - -/* add your monitor here. */ -monitor_t *cc_init_monitor (void); -/* and here. */ -monitor_t *(*init_monitor[])(void) = { - cc_init_monitor, - NULL -}; - -dll_list_t instance_monitors; -dll_list_t *monitors; - -struct vbl_node grf_vbl_node; - -void -grf_vbl_function (void * data) -{ - dll_node_t *n = monitors->head; - - while (n->next) { - monitor_t *m = (monitor_t *)n; - if (m->vbl_handler) { - m->vbl_handler (m); - } - n = n->next; - } -} - -/* - * XXX: called from ite console init routine. - * Does just what configure will do later but without printing anything. - */ - - -int -grfcc_probe () -{ - int i = 0; - - grf_vbl_node.function = grf_vbl_function; - - if (NULL == monitors) { - dinit_list (&instance_monitors); - monitors = &instance_monitors; - - while (init_monitor[i]) { - init_monitor[i] (); - i++; - } - if (i) { - add_vbl_function (&grf_vbl_node, 1, 0); - return (1); - } - return (0); - } - return (1); -} - -void -grfcc_config (void) -{ - grfprobe (); -} - -dmode_t * -get_best_display_mode (u_long width, u_long height, u_byte depth) -{ - dmode_t *save = NULL; - monitor_t *m = (monitor_t *)monitors->head; - long dt; - - while (m->node.next) { - dimen_t dim; - dmode_t *d; - long dx, dy, ct; - - dim.width = width; - dim.height = height; - d = m->get_best_mode (&dim, depth); - if (d) { - dx = abs (d->nominal_size.width - width); - dy = abs (d->nominal_size.height - height); - ct = dx + dy; - - if (ct < dt || save == NULL) { - save = d; - dt = ct; - } - } - m = (monitor_t *)m->node.next; - } - return (save); -} - diff --git a/sys/arch/amiga/dev/grf_tg.c b/sys/arch/amiga/dev/grf_tg.c deleted file mode 100644 index 2c41711eca52..000000000000 --- a/sys/arch/amiga/dev/grf_tg.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * $Id: grf_tg.c,v 1.5 1994/02/13 21:10:29 chopps Exp $ - */ - -#include - -/* to be written.. */ - -tg_init (gp, ad) - struct grf_softc *gp; - struct amiga_device *ad; -{ - return 0; -} - -tg_mode (gp, cmd) - register struct grf_softc *gp; - int cmd; -{ - return EINVAL; -} diff --git a/sys/arch/amiga/dev/gvp11dma.c b/sys/arch/amiga/dev/gvp11dma.c deleted file mode 100644 index d8db495e18c4..000000000000 --- a/sys/arch/amiga/dev/gvp11dma.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)dma.c - * $Id: gvp11dma.c,v 1.7 1994/04/18 04:09:14 chopps Exp $ - */ - -/* - * GVP11 (Series II) DMA driver - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include "gvp11scsi.h" -#include -#include - -#include - -extern void timeout(); - -static void dmafree (register struct scsi_softc *dev); -static int dmago (struct scsi_softc *dev, char *addr, register int count, register int flags); -static int dmanext (struct scsi_softc *dev); -static void dmastop (struct scsi_softc *dev); -int gvp11dmaintr (void); - -extern int scsi_nscsi; /* number of 33C93 controllers configured */ -extern struct scsi_softc scsi_softc[]; - -int gvp11dmaintr(); - -int gvp11_max_dma = MAXPHYS; /* Maximum size per DMA transfer */ - -#ifdef DEBUG -int dmagvp11debug = 0; - -void gvp11dmatimeout(); -#endif - -void -gvp11dmainit (ac, dev) - struct amiga_ctlr *ac; - struct scsi_softc *dev; -{ - register struct sdmac *dma; - register int i; - char rev; - - dma = (struct sdmac *) ac->amiga_addr; - - dma->CNTR = 0; /* disable interrupts from dma/scsi */ - dma->bank = 0; /* reset DMA bank register */ - - dev->sc_cmd = 0; - dev->sc_hwaddr = dma; - i = ac->amiga_unit; -#ifdef DEBUG - /* make sure timeout is really not needed */ - timeout(gvp11dmatimeout, 0, 30 * hz); -#endif - - dev->dmafree = (dmafree_t) dmafree; - dev->dmago = (dmago_t) dmago; - dev->dmanext = (dmanext_t) dmanext; - dev->dmastop = (dmastop_t) dmastop; - - - printf("dma%d: GVPII DMA\n", i); -} - -static void -dmafree(dev) - register struct scsi_softc *dev; -{ - int unit = dev->sc_ac->amiga_unit; - register int s; - - s = splbio(); -#ifdef DEBUG - dev->dmatimo = 0; -#endif - if (dev->sc_cmd) - { - ((struct sdmac *)dev->sc_hwaddr)->CNTR &= ~GVP_CNTR_INT_P; /* clear possible interrupt */ - ((struct sdmac *)dev->sc_hwaddr)->SP_DMA = 1; /* stop dma */ - dev->sc_cmd = 0; - } - ((struct sdmac *)dev->sc_hwaddr)->CNTR = 0; /* disable interrupts from dma/scsi */ - dev->sc_flags &= ~SCSI_INTR; - - splx(s); -} - -static int -dmago(dev, addr, count, flags) - register struct scsi_softc *dev; - register char *addr; - register int count; - register int flags; -{ - int unit = dev->sc_ac->amiga_unit; - - /* - * Set up the command word based on flags - */ - dev->sc_cmd = GVP_CNTR_INTEN; - if ((flags & DMAGO_READ) == 0) - dev->sc_cmd |= GVP_CNTR_DDIR; -#ifdef DEBUG - if (dmagvp11debug & DDB_IO) - { - printf("dmago: cmd %x\n", dev->sc_cmd); - } - dev->dmatimo = 1; -#endif - - ((struct sdmac *)dev->sc_hwaddr)->CNTR = dev->sc_cmd; - dev->sc_flags |= SCSI_INTR; - ((struct sdmac *)dev->sc_hwaddr)->ACR = (u_int) dev->sc_cur->dc_addr; - if (dev->bankmask) - ((struct sdmac *)dev->sc_hwaddr)->bank = dev->bankmask & - (((u_int) dev->sc_cur->dc_addr) >> 18); - ((struct sdmac *)dev->sc_hwaddr)->ST_DMA = 1; - - if (dev->sc_tc > gvp11_max_dma) - dev->sc_tc = gvp11_max_dma; /* restrict transfer count to maximum */ - return dev->sc_tc; -} - -static void -dmastop(dev) - register struct scsi_softc *dev; -{ - register struct devqueue *dq; - int unit = dev->sc_ac->amiga_unit; - int s; - -#ifdef DEBUG - if (dmagvp11debug & DDB_FOLLOW) - printf("dmastop()\n"); - dev->dmatimo = 0; -#endif - if (dev->sc_cmd) - { - s = splbio (); - ((struct sdmac *)dev->sc_hwaddr)->CNTR &= ~GVP_CNTR_INT_P; /* clear possible interrupt */ - ((struct sdmac *)dev->sc_hwaddr)->SP_DMA = 1; /* stop dma */ - dev->sc_cmd = 0; - splx (s); - } - - /* - * We may get this interrupt after a device service routine - * has freed the dma channel. So, ignore the intr if there's - * nothing on the queue. - */ -#if 0 /* XXX - not needed anymore? */ - dq = dev->sc_sq.dq_forw; - if (dq != &dmachan[unit]) - (dq->dq_driver->d_done)(unit); -#endif -} - -int -gvp11dmaintr() -{ - register struct scsi_softc *dev; - register int i, stat; - int found = 0; - - for (i = 0, dev = scsi_softc; i < scsi_nscsi; i++, dev++) - { - if (dev->dmago != (dmago_t) dmago) - continue; /* This controller isn't ours */ - stat = ((struct sdmac *)dev->sc_hwaddr)->CNTR; - - if (! (stat & GVP_CNTR_INT_P)) - continue; - -#ifdef DEBUG - if (dmagvp11debug & DDB_FOLLOW) - printf("dmaintr (%d, 0x%x)\n", i, stat); -#endif - - if (dev->sc_flags & SCSI_INTR) - found += scsiintr (i); - } - - return found; -} - - -static int -dmanext (dev) - register struct scsi_softc *dev; -{ - register int unit = dev->sc_ac->amiga_unit; - register int i, stat; - - if (dev->sc_cur <= dev->sc_last) - { -#ifdef DEBUG - dev->dmatimo = 1; -#endif - ((struct sdmac *)dev->sc_hwaddr)->CNTR &= ~GVP_CNTR_INT_P; /* clear possible interrupt */ - ((struct sdmac *)dev->sc_hwaddr)->SP_DMA = 1; /* stop dma */ - ((struct sdmac *)dev->sc_hwaddr)->CNTR = dev->sc_cmd; - ((struct sdmac *)dev->sc_hwaddr)->ACR = (u_int) dev->sc_cur->dc_addr; - if (dev->bankmask) - ((struct sdmac *)dev->sc_hwaddr)->bank = dev->bankmask & - (((u_int) dev->sc_cur->dc_addr) >> 18); - ((struct sdmac *)dev->sc_hwaddr)->ST_DMA = 1; - - dev->sc_tc = dev->sc_cur->dc_count << 1; - if (dev->sc_tc > gvp11_max_dma) - dev->sc_tc = gvp11_max_dma; - return dev->sc_tc; - } - else - { - /* shouldn't happen !! */ - printf ("dmanext at end !!!\n"); - dmastop (dev); - return 0; - } -} - - - - -#ifdef DEBUG -void -gvp11dmatimeout() -{ - register int i, s; - - for (i = 0; i < scsi_nscsi; i++) - { - if (scsi_softc[i].dmago != (dmago_t) dmago) - continue; - s = splbio(); - if (scsi_softc[i].dmatimo) - { - if (scsi_softc[i].dmatimo > 1) - printf("dma%d: timeout #%d\n", i, scsi_softc[i].dmatimo-1); - scsi_softc[i].dmatimo++; - } - splx(s); - } - timeout (gvp11dmatimeout, (caddr_t)0, 30 * hz); -} -#endif diff --git a/sys/arch/amiga/dev/gvp11dmareg.h b/sys/arch/amiga/dev/gvp11dmareg.h deleted file mode 100644 index 5dc11ba888e0..000000000000 --- a/sys/arch/amiga/dev/gvp11dmareg.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)gvp11_dmareg.h - * $Id: gvp11dmareg.h,v 1.2 1994/02/11 07:01:47 chopps Exp $ - */ - -/* Hardware layout of the GVP Series II SDMAC. This also contains the - registers for the sbic chip, but in favor of separating DMA and - scsi, the scsi-driver doesn't make use of this dependency */ - -#define v_int volatile int -#define vu_char volatile u_char -#define vu_short volatile u_short -#define vu_int volatile u_int - -struct sdmac { - u_short _____________pad0[32]; - vu_short CNTR; - u_short _____________pad1[15]; - u_char _____________pad2; - vu_char SASR; - u_char _____________pad3; - vu_char SCMD; - u_short _____________pad4[2]; - vu_short bank; - u_short _____________pad5[3]; - vu_int ACR; - vu_short secret1; /* Initially store 0 here */ - vu_short ST_DMA; /* strobe */ - vu_short SP_DMA; /* strobe */ - vu_short secret2; /* Initially store 1 here */ - vu_short secret3; /* " 15 " */ -}; - -#define GVP_CNTR_BUSY (1<<0) -#define GVP_CNTR_INT_P (1<<1) -#define GVP_CNTR_INTEN (1<<3) -#define GVP_CNTR_DDIR (1<<4) - diff --git a/sys/arch/amiga/dev/ite_tg.c b/sys/arch/amiga/dev/ite_tg.c deleted file mode 100644 index 2692a0c92911..000000000000 --- a/sys/arch/amiga/dev/ite_tg.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * $Id: ite_tg.c,v 1.5 1994/02/17 09:10:50 chopps Exp $ - */ - -#include -#include - -tiga_cnprobe () -{ - return (CN_DEAD); -} - -tiga_init () -{ -} - -tiga_scroll () -{ -} - -tiga_deinit () -{ -} - -tiga_clear () -{ -} - -tiga_putc () -{ -} - -tiga_cursor () -{ -} diff --git a/sys/arch/amiga/dev/ivsdma.c b/sys/arch/amiga/dev/ivsdma.c deleted file mode 100644 index 1102af31e99d..000000000000 --- a/sys/arch/amiga/dev/ivsdma.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ivsdma.c - * $Id: ivsdma.c,v 1.1 1994/02/28 06:06:20 chopps Exp $ - */ - -/* - * dummy IVS 5380 DMA driver - */ - -#include "ivsscsi.h" - -#if NIVSSCSI > 0 - -void -ivsdmainit () -{ -} -#endif diff --git a/sys/arch/amiga/dev/magnumdma.c b/sys/arch/amiga/dev/magnumdma.c deleted file mode 100644 index c405edef6814..000000000000 --- a/sys/arch/amiga/dev/magnumdma.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)dma.c - * $Id: magnumdma.c,v 1.2 1994/02/11 07:02:01 chopps Exp $ - */ - -/* - * dummy CSA Magnum DMA driver - */ - -#include "magnumscsi.h" - -#if NMAGNUMSCSI > 0 - -void -magnumdmainit () -{ -} -#endif - diff --git a/sys/arch/amiga/dev/mlhdma.c b/sys/arch/amiga/dev/mlhdma.c deleted file mode 100644 index 2e0870da5d04..000000000000 --- a/sys/arch/amiga/dev/mlhdma.c +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)mlhdma.c - * $Id: mlhdma.c,v 1.2 1994/03/25 16:32:29 chopps Exp $ - */ - -/* - * dummy MLH 5380 DMA driver - */ - -#include "mlhscsi.h" - -#if NMLHSCSI > 0 - -#include - -#include -#include -#include - -#define QPRINTF -#ifdef DEBUG -extern int sci_debug; -#endif -#define HIST(h,w) - -extern int sci_data_wait; - -static int dma_xfer_in __P((struct sci_softc *dev, int len, - register u_char *buf, int phase)); -static int dma_xfer_out __P((struct sci_softc *dev, int len, - register u_char *buf, int phase)); - -void -mlhdmainit (dev) - struct sci_softc *dev; -{ - dev->dma_xfer_in = dma_xfer_in; - dev->dma_xfer_out = dma_xfer_out; -} - -static int -dma_xfer_in (dev, len, buf, phase) - struct sci_softc *dev; - int len; - register u_char *buf; - int phase; -{ - int wait = sci_data_wait; - u_char csr; - u_char *obp = buf; -#if 1 - volatile register u_char *sci_dma = dev->sci_data + 16; -#else - volatile register u_char *sci_dma = dev->sci_data + 12; -#endif - volatile register u_char *sci_csr = dev->sci_csr; - volatile register u_char *sci_icmd = dev->sci_icmd; - - csr = *dev->sci_bus_csr; - - QPRINTF(("mlhdma_in %d, csr=%02x\n", len, csr)); - - *dev->sci_tcmd = phase; - *dev->sci_mode |= SCI_MODE_DMA; - *dev->sci_icmd = 0; - *dev->sci_irecv = 0; - while (len > 128) { - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) != - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) { - if (!(*sci_csr & SCI_CSR_PHASE_MATCH) - || !(*dev->sci_bus_csr & SCI_BUS_BSY) - || --wait < 0) { -#ifdef DEBUG - if (sci_debug) - printf("mlhdma_in fail: l%d i%x w%d\n", - len, csr, wait); -#endif - HIST(ixin_wait, wait) - *dev->sci_mode &= ~SCI_MODE_DMA; - return 0; - } - } - - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - *buf++ = *sci_dma; - len -= 128; - } - while (len > 0) { - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) != - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) { - if (!(*sci_csr & SCI_CSR_PHASE_MATCH) - || !(*dev->sci_bus_csr & SCI_BUS_BSY) - || --wait < 0) { -#ifdef DEBUG - if (sci_debug) - printf("mlhdma_in fail: l%d i%x w%d\n", - len, csr, wait); -#endif - HIST(ixin_wait, wait) - *dev->sci_mode &= ~SCI_MODE_DMA; - return 0; - } - } - - *buf++ = *sci_dma; - len--; - } - - QPRINTF(("mlhdma_in {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5], - obp[6], obp[7], obp[8], obp[9])); - - HIST(ixin_wait, wait) - *dev->sci_mode &= ~SCI_MODE_DMA; - return 0; -} - -static int -dma_xfer_out (dev, len, buf, phase) - struct sci_softc *dev; - int len; - register u_char *buf; - int phase; -{ - int wait = sci_data_wait; - u_char csr; - u_char *obp = buf; - volatile register u_char *sci_dma = dev->sci_data + 16; - volatile register u_char *sci_csr = dev->sci_csr; - volatile register u_char *sci_icmd = dev->sci_icmd; - - csr = *dev->sci_bus_csr; - - QPRINTF(("mlhdma_xfer %d, csr=%02x\n", len, csr)); - - QPRINTF(("mlhgdma_out {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - len, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], - buf[6], buf[7], buf[8], buf[9])); - - *dev->sci_tcmd = phase; - *dev->sci_mode |= SCI_MODE_DMA; - *dev->sci_icmd = SCI_ICMD_DATA; - *dev->sci_dma_send = 0; - while (len > 64) { - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) != - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) { - if (!(*sci_csr & SCI_CSR_PHASE_MATCH) - || !(*dev->sci_bus_csr & SCI_BUS_BSY) - || --wait < 0) { -#ifdef DEBUG - if (sci_debug) - printf("mlhdma_out fail: l%d i%x w%d\n", - len, csr, wait); -#endif - HIST(ixin_wait, wait) - *dev->sci_mode &= ~SCI_MODE_DMA; - return 0; - } - } - - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - *sci_dma = *buf++; - len -= 64; - } - while (len > 0) { - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) != - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) { - if (!(*sci_csr & SCI_CSR_PHASE_MATCH) - || !(*dev->sci_bus_csr & SCI_BUS_BSY) - || --wait < 0) { -#ifdef DEBUG - if (sci_debug) - printf("mlhdma_out fail: l%d i%x w%d\n", - len, csr, wait); -#endif - HIST(ixin_wait, wait) - *dev->sci_mode &= ~SCI_MODE_DMA; - return 0; - } - } - - *sci_dma = *buf++; - len--; - } - - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) == - SCI_CSR_PHASE_MATCH && --wait); - - HIST(ixin_wait, wait) - *dev->sci_mode &= ~SCI_MODE_DMA; - return 0; -} -#endif diff --git a/sys/arch/amiga/dev/retina-mondefs.c b/sys/arch/amiga/dev/retina-mondefs.c deleted file mode 100644 index cea7ec5e7be4..000000000000 --- a/sys/arch/amiga/dev/retina-mondefs.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - * $Id: retina-mondefs.c,v 1.3 1994/04/22 01:35:27 chopps Exp $ - */ - -static struct MonDef monitor_defs[] = { - /* FQ, FLG, MW, MH - HBS, HSS, HSE, HBE, HT, VBS, VSS, VSE, VBE, VT - Depth, PAL, TX, TY, XY, FX, FY, FontData, FLo, FHi*/ - - /* 80x50 (640x400) 31.5kHz 60Hz */ - { 28322000, 16, 640, 400, - 80, 91, 99, 110, 110, 401, 445, 504, 522, 522, - 4, NCRStdPalette, 80, 50, 4000, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 80x50 (640x400) 35.0kHz 72Hz */ - { 63000000, 16, 640, 400, - 80, 89, 98, 110, 110, 401, 411, 483, 483, 483, - 4, NCRStdPalette, 80, 50, 4000, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 80x50 (640x400) 37.1kHz 69Hz */ - { 65000000, 16, 640, 400, - 80, 88, 94, 107, 107, 401, 411, 530, 530, 530, - 4, NCRStdPalette, 80, 50, 4000, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 100x75 (800x600) 31.5kHz 50Hz */ - { 80000000, 16, 800, 600, - 100, 113, 148, 156, 156, 601, 602, 612, 628, 628, - 4, NCRStdPalette, 100, 75, 7500, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 100x75 (800x600) 35.0kHz 57Hz */ - { 75000000, 16, 800, 600, - 100, 110, 120, 132, 131, 601, 602, 603, 603, 603, - 4, NCRStdPalette, 100, 75, 7500, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 100x75 (800x600) 37.2kHz 60Hz */ - { 80000000, 16, 800, 600, - 100, 110, 121, 132, 132, 601, 603, 613, 613, 613, - 4, NCRStdPalette, 100, 75, 7500, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 100x75 (800x600) 57.1kHz 90Hz */ - { 56644000, 16, 800, 600, - 100, 106, 107, 122, 121, 601, 607, 617, 629, 629, - 4, NCRStdPalette, 100, 75, 7500, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 31.5kHz 78Hz interlace */ - { 80000000, 22, 1024, 768, - 128, 134, 140, 156, 156, 385, 385, 386, 401, 401, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 35.0kHz 86Hz interlace */ - { 90000000, 22, 1024, 768, - 128, 135, 143, 158, 158, 385, 385, 386, 401, 401, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 38.1kHz 89Hz interlace */ - { 50000000, 18, 1024, 768, - 128, 135, 146, 162, 161, 385, 399, 400, 423, 423, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 57.0kHz 71Hz */ - { 75000000, 16, 1024, 768, - 128, 129, 141, 162, 162, 769, 770, 771, 798, 798, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 71.2kHz 85Hz */ - { 90000000, 16, 1024, 768, - 128, 136, 141, 156, 155, 769, 793, 806, 832, 832, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 80x100 (640x800) 31.9kHz 75Hz interlace */ - { 28322000, 18, 640, 800, - 80, 81, 88, 109, 108, 401, 402, 409, 418, 418, - 4, NCRStdPalette, 80, 100, 8000, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 80x100 (640x800) 35.5kHz 84Hz interlace */ - { 63000000, 22, 640, 800, - 80, 81, 88, 109, 108, 401, 402, 409, 418, 418, - 4, NCRStdPalette, 80, 100, 8000, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 80x50 (640x400) 36.6kHz 87Hz */ - { 65000000, 16, 640, 400, - 80, 88, 95, 109, 108, 401, 402, 409, 418, 418, - 4, NCRStdPalette, 80, 50, 4000, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 96x64 (768x512) 36.9kHz 68Hz */ - { 36000000, 16, 768, 512, - 96, 103, 111, 120, 119, 513, 521, 529, 535, 535, - 4, NCRStdPalette, 96, 64, 6144, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 96x64 (768x512) 38.4kHz 71Hz */ - { 75000000, 16, 768, 512, - 96, 103, 111, 120, 119, 513, 521, 529, 535, 535, - 4, NCRStdPalette, 96, 64, 6144, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 96x64 (768x512) 41.0kHz 76Hz */ - { 80000000, 16, 768, 512, - 96, 103, 111, 120, 119, 513, 521, 529, 535, 535, - 4, NCRStdPalette, 96, 64, 6144, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 96x64 (768x512) 46.0kHz 85Hz */ - { 44900000, 16, 768, 512, - 96, 103, 110, 120, 119, 513, 522, 530, 535, 535, - 4, NCRStdPalette, 96, 64, 6144, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 96x64 (768x512) 46.1kHz 85Hz */ - { 90000000, 16, 768, 512, - 96, 103, 110, 120, 119, 513, 522, 530, 535, 535, - 4, NCRStdPalette, 96, 64, 6144, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 100x75 (800x600) 47.3kHz 75Hz */ - { 50000000, 16, 800, 600, - 100, 108, 116, 130, 129, 601, 602, 612, 628, 628, - 4, NCRStdPalette, 100, 75, 7500, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 100x75 (800x600) 53.6kHz 85Hz */ - { 56644000, 16, 800, 600, - 100, 109, 118, 130, 129, 601, 602, 612, 628, 628, - 4, NCRStdPalette, 100, 75, 7500, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 48.5kHz 60Hz */ - { 63000000, 16, 1024, 768, - 128, 129, 139, 160, 160, 769, 774, 787, 805, 805, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 50.0kHz 61Hz */ - { 65000000, 16, 1024, 768, - 128, 129, 139, 160, 160, 769, 774, 787, 805, 805, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 55.4kHz 68Hz */ - { 72000000, 16, 1024, 768, - 128, 137, 147, 160, 160, 769, 785, 798, 805, 805, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 57.7kHz 71Hz */ - { 75000000, 16, 1024, 768, - 128, 128, 138, 160, 160, 769, 780, 793, 805, 805, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 61.5kHz 76Hz */ - { 80000000, 16, 1024, 768, - 128, 131, 141, 160, 160, 769, 780, 793, 805, 805, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x96 (1024x768) 69.2kHz 85Hz */ - { 90000000, 16, 1024, 768, - 128, 138, 148, 160, 160, 769, 780, 793, 805, 805, - 4, NCRStdPalette, 128, 96, 12288, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x128 (1024x1024) 71.8kHz 66Hz ***EXCEEDS CHIP LIMIT!!!*** */ - { 100000000, 16, 1024, 1024, - 128, 129, 140, 172, 171, 1025, 1026, 1043, 1073, 1073, - 4, NCRStdPalette, 128, 128, 16384, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x128 (1024x1024) 79.0kHz 73Hz ***EXCEEDS CHIP LIMIT!!!*** */ - { 110000000, 16, 1024, 1024, - 128, 129, 140, 172, 171, 1025, 1026, 1043, 1073, 1073, - 4, NCRStdPalette, 128, 128, 16384, 8, 8, kernel_font_8x8, 32, 255 }, - - /* 128x128 (1024x1024) 86.2kHz 80Hz ***EXCEEDS CHIP LIMIT!!!*** */ - { 120000000, 16, 1024, 1024, - 128, 129, 140, 172, 171, 1025, 1026, 1043, 1073, 1073, - 4, NCRStdPalette, 128, 128, 16384, 8, 8, kernel_font_8x8, 32, 255 }, - -}; - -static const char *monitor_descr[] = { - "80x50 (640x400) 31.5kHz 60Hz", - "80x50 (640x400) 35.0kHz 72Hz", - "80x50 (640x400) 37.1kHz 69Hz", - "100x75 (800x600) 31.5kHz 50Hz", - "100x75 (800x600) 35.0kHz 57Hz", - "100x75 (800x600) 37.2kHz 60Hz", - "100x75 (800x600) 57.1kHz 90Hz", - "128x96 (1024x768) 31.5kHz 78Hz interlace", - "128x96 (1024x768) 35.0kHz 86Hz interlace", - "128x96 (1024x768) 38.1kHz 89Hz interlace", - "128x96 (1024x768) 57.0kHz 71Hz", - "128x96 (1024x768) 71.2kHz 85Hz", - "80x100 (640x800) 31.9kHz 75Hz interlace", - "80x100 (640x800) 35.5kHz 84Hz interlace", - "80x50 (640x400) 36.6kHz 87Hz", - "96x64 (768x512) 36.9kHz 68Hz", - "96x64 (768x512) 38.4kHz 71Hz", - "96x64 (768x512) 41.0kHz 76Hz", - "96x64 (768x512) 46.0kHz 85Hz", - "96x64 (768x512) 46.1kHz 85Hz", - "100x75 (800x600) 47.3kHz 75Hz", - "100x75 (800x600) 53.6kHz 85Hz", - "128x96 (1024x768) 48.5kHz 60Hz", - "128x96 (1024x768) 50.0kHz 61Hz", - "128x96 (1024x768) 55.4kHz 68Hz", - "128x96 (1024x768) 57.7kHz 71Hz", - "128x96 (1024x768) 61.5kHz 76Hz", - "128x96 (1024x768) 69.2kHz 85Hz", - "128x128 (1024x1024) 71.8kHz 66Hz ***EXCEEDS CHIP LIMIT!!!***", - "128x128 (1024x1024) 79.0kHz 73Hz ***EXCEEDS CHIP LIMIT!!!***", - "128x128 (1024x1024) 86.2kHz 80Hz ***EXCEEDS CHIP LIMIT!!!***", -}; - diff --git a/sys/arch/amiga/dev/retina-monitors b/sys/arch/amiga/dev/retina-monitors deleted file mode 100644 index c5688fbed006..000000000000 --- a/sys/arch/amiga/dev/retina-monitors +++ /dev/null @@ -1,71 +0,0 @@ -; 640 × 200, 4 Bit, 31609 Hz, 75 Hz d -ID 759528833 FQ 28322000 MD 0 FLG 9 -SW 640 SH 200 MW 640 MH 200 -HBS 81 HSS 82 HSE 89 HBE 110 HT 107 -VBS 401 VSS 402 VSE 409 VBE 418 VT 418 - -; 640 × 400, 4 Bit, 31609 Hz, 75 Hz -ID 759528046 FQ 28322000 MD 0 FLG 8 -SW 640 SH 400 MW 640 MH 400 -HBS 81 HSS 82 HSE 89 HBE 110 HT 107 -VBS 401 VSS 402 VSE 409 VBE 418 VT 418 - -; 600 × 480, 4 Bit, 31250 Hz, 62 Hz -ID 759528276 FQ 50000000 MD 0 FLG 8 -SW 600 SH 480 MW 600 MH 480 -HBS 76 HSS 77 HSE 84 HBE 98 HT 95 -VBS 481 VSS 482 VSE 490 VBE 502 VT 502 - -; 800 × 600, 4 Bit, 31500 Hz, 50 Hz -ID 759528122 FQ 63000000 MD 0 FLG 8 -SW 800 SH 600 MW 800 MH 600 -HBS 101 HSS 102 HSE 110 HBE 123 HT 120 -VBS 601 VSS 602 VSE 612 VBE 628 VT 628 - -; 800 × 600, 4 Bit, 37878 Hz, 60 Hz -ID 759528140 FQ 80000000 MD 0 FLG 8 -SW 800 SH 600 MW 800 MH 600 -HBS 101 HSS 102 HSE 111 HBE 130 HT 127 -VBS 601 VSS 602 VSE 612 VBE 628 VT 628 - -; 1024 × 768, 4 Bit, 45646 Hz, 56 Hz -ID 759528453 FQ 65000000 MD 0 FLG 8 -SW 1024 SH 768 MW 1024 MH 768 -HBS 129 HSS 130 HSE 141 HBE 176 HT 173 -VBS 769 VSS 770 VSE 783 VBE 805 VT 805 - -; 800 × 600, 4 Bit, 48828 Hz, 77 Hz -ID 759528343 FQ 50000000 MD 0 FLG 8 -SW 800 SH 600 MW 800 MH 600 -HBS 101 HSS 102 HSE 110 HBE 126 HT 123 -VBS 601 VSS 602 VSE 612 VBE 628 VT 628 - -; 1280 × 1024, 4 Bit, 48309 Hz, 89 Hz i -ID 759528707 FQ 80000000 MD 0 FLG 10 -SW 1280 SH 1024 MW 1280 MH 1024 -HBS 161 HSS 162 HSE 175 HBE 205 HT 202 -VBS 513 VSS 514 VSE 522 VBE 535 VT 535 - -; 1440 × 1280, 4 Bit, 49559 Hz, 73 Hz i -ID 759528770 FQ 90000000 MD 0 FLG 10 -SW 1440 SH 1280 MW 1440 MH 1280 -HBS 181 HSS 182 HSE 196 HBE 225 HT 222 -VBS 641 VSS 642 VSE 653 VBE 670 VT 670 - -; 800 × 600, 4 Bit, 55316 Hz, 87 Hz -ID 759528365 FQ 56644000 MD 0 FLG 8 -SW 800 SH 600 MW 800 MH 600 -HBS 101 HSS 102 HSE 110 HBE 126 HT 123 -VBS 601 VSS 602 VSE 612 VBE 628 VT 628 - -; 1024 × 768, 4 Bit, 56179 Hz, 69 Hz -ID 759528500 FQ 80000000 MD 0 FLG 8 -SW 1024 SH 768 MW 1024 MH 768 -HBS 129 HSS 130 HSE 141 HBE 176 HT 173 -VBS 769 VSS 770 VSE 783 VBE 805 VT 805 - -; 1024 × 768, 4 Bit, 63202 Hz, 78 Hz -ID 759528561 FQ 90000000 MD 0 FLG 8 -SW 1024 SH 768 MW 1024 MH 768 -HBS 129 HSS 130 HSE 141 HBE 176 HT 173 -VBS 769 VSS 770 VSE 783 VBE 805 VT 805 diff --git a/sys/arch/amiga/dev/rtclocka.c b/sys/arch/amiga/dev/rtclocka.c deleted file mode 100644 index 60ed397ee9bc..000000000000 --- a/sys/arch/amiga/dev/rtclocka.c +++ /dev/null @@ -1,207 +0,0 @@ -/* this provides a device interface to the realtime clock - used on the A3000. - - To support different clocks: the config file defines a - realtime clock "rtclock". Write your own driver that if - matched by existing hardware returns 1 from its init - function, and set the function pointer "gettod" to - a function returning the number of seconds elapsed since - 1970-1-1. - - TODO: could add read-write interface to turn this into - a real /dev/rtclock device, that would allow reading - and setting of the clock very easily. - * - * $Id: rtclocka.c,v 1.4 1994/02/13 21:10:53 chopps Exp $ - */ - -#include "rtclocka.h" -#if NRTCLOCKA > 0 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -int rtclockainit (register struct amiga_device *ad); - -static long rtgettod (); -static int rtsettod (); - -/* amiga/clock.c calls thru this vector, if it is set, to read - the realtime clock */ -extern long (*gettod)(); -extern int (*settod)(); - -/* since there's only one such clock on the A3000, we can - savely store its address in a static variable */ -static struct rtclock3000 *rt = 0; - -struct driver rtclockadriver = { - (int (*)(void *))rtclockainit, "rtclock", -}; - - -int -rtclockainit (register struct amiga_device *ad) -{ - /* verify we're indeed present */ - if (ad->amiga_addr) - { - rt = (struct rtclock3000 *) ad->amiga_addr; - if (rtgettod ()) - { - gettod = rtgettod; - settod = rtsettod; - printf ("Realtime clock A3000\n"); - return 1; - } - else - printf ("Realtime clock A3000 malfunctioning, ignored.\n"); - } - - return 0; -} - - -static int month_days[12] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - -static long -rtgettod () -{ - register int i; - register u_long tmp; - int year, month, day, hour, min, sec; - - /* hold clock */ - rt->control1 = CONTROL1_HOLD_CLOCK; - - /* read it */ - sec = rt->second1 * 10 + rt->second2; - min = rt->minute1 * 10 + rt->minute2; - hour = rt->hour1 * 10 + rt->hour2; - day = rt->day1 * 10 + rt->day2; - month = rt->month1 * 10 + rt->month2; - year = rt->year1 * 10 + rt->year2 + 1900; - - /* let it run again.. */ - rt->control1 = CONTROL1_FREE_CLOCK; - -#if 0 - printf ("rt: sec=%d, min=%d, hour=%d, day=%d, mon=%d, year=%d\n", - sec, min, hour, day, month, year); -#endif - - range_test(hour, 0, 23); - range_test(day, 1, 31); - range_test(month, 1, 12); - range_test(year, STARTOFTIME, 2000); - - tmp = 0; - - for (i = STARTOFTIME; i < year; i++) - tmp += days_in_year(i); - if (leapyear(year) && month > FEBRUARY) - tmp++; - - for (i = 1; i < month; i++) - tmp += days_in_month(i); - - tmp += (day - 1); - tmp = ((tmp * 24 + hour) * 60 + min) * 60 + sec; - - return tmp; -} - - -int -rtsettod (tim) - long tim; -{ - /* I don't know if setting the clock is analogous - to reading it, I don't have demo-code for setting. - just give it a try.. */ - - register int i; - register long hms, day; - u_char sec1, sec2; - u_char min1, min2; - u_char hour1, hour2; - u_char day1, day2; - u_char mon1, mon2; - u_char year1, year2; - - /* there seem to be problems with the bitfield addressing - currently used.. */ - return 0; - - if (! rt) - return 0; - - /* prepare values to be written to clock */ - day = tim / SECDAY; - hms = tim % SECDAY; - - - hour2 = hms / 3600; - hour1 = hour2 / 10; - hour2 %= 10; - - min2 = (hms % 3600) / 60; - min1 = min2 / 10; - min2 %= 10; - - - sec2 = (hms % 3600) % 60; - sec1 = sec2 / 10; - sec2 %= 10; - - /* Number of years in days */ - for (i = STARTOFTIME - 1900; day >= days_in_year(i); i++) - day -= days_in_year(i); - year1 = i / 10; - year2 = i % 10; - - /* Number of months in days left */ - if (leapyear(i)) - days_in_month(FEBRUARY) = 29; - for (i = 1; day >= days_in_month(i); i++) - day -= days_in_month(i); - days_in_month(FEBRUARY) = 28; - - mon1 = i / 10; - mon2 = i % 10; - - /* Days are what is left over (+1) from all that. */ - day ++; - day1 = day / 10; - day2 = day % 10; - - rt->control1 = CONTROL1_HOLD_CLOCK; - rt->second1 = sec1; - rt->second2 = sec2; - rt->minute1 = min1; - rt->minute2 = min2; - rt->hour1 = hour1; - rt->hour2 = hour2; - rt->day1 = day1; - rt->day2 = day2; - rt->month1 = mon1; - rt->month2 = mon2; - rt->year1 = year1; - rt->year2 = year2; - rt->control2 = CONTROL1_FREE_CLOCK; - - return 1; -} -#endif /* NRTCLOCKA */ diff --git a/sys/arch/amiga/dev/rtclocka_var.h b/sys/arch/amiga/dev/rtclocka_var.h deleted file mode 100644 index 9831cf832fec..000000000000 --- a/sys/arch/amiga/dev/rtclocka_var.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * $Id: rtclocka_var.h,v 1.3 1994/02/11 07:02:06 chopps Exp $ - */ - -#ifndef _RTCLOCKA_H_ -#define _RTCLOCKA_H_ - -/* this seems to be what the battery backed up clock looks like - on the A3000. I think different clock chips are used in other Amiga - models, so we'll probably have to differentiate between them. - - Thanks ALOT to Holger Emden for sending me demo-code on how - to read the clock!! */ - - - -struct rtclock3000 { - u_int :28, second2:4; /* 0x03 lower digit */ - u_int :28, second1:4; /* 0x07 upper digit */ - u_int :28, minute2:4; /* 0x0b lower digit */ - u_int :28, minute1:4; /* 0x0f upper digit */ - u_int :28, hour2:4; /* 0x13 lower digit */ - u_int :28, hour1:4; /* 0x17 upper digit */ - u_int :28, weekday:4; /* 0x1b */ - u_int :28, day2:4; /* 0x1f lower digit */ - u_int :28, day1:4; /* 0x23 upper digit */ - u_int :28, month2:4; /* 0x27 lower digit */ - u_int :28, month1:4; /* 0x2b upper digit */ - u_int :28, year2:4; /* 0x2f lower digit */ - u_int :28, year1:4; /* 0x33 upper digit */ - u_int :28, control1:4; /* 0x37 control-byte 1 */ - u_int :28, control2:4; /* 0x3b control-byte 2 */ - u_int :28, control3:4; /* 0x3f control-byte 3 */ -}; - - -/* commands written to control1, HOLD before reading the clock, - FREE after done reading. */ - -#define CONTROL1_HOLD_CLOCK 0 -#define CONTROL1_FREE_CLOCK 9 - -#define FEBRUARY 2 -#define STARTOFTIME 1970 -#define SECDAY 86400L -#define SECYR (SECDAY * 365) - -#define BBC_SET_REG 0xe0 -#define BBC_WRITE_REG 0xc2 -#define BBC_READ_REG 0xc3 -#define NUM_BBC_REGS 12 - -#define leapyear(y) (((y)%4)==0 && ((y)%100)!=0 || ((y)%400) == 0) -#define range_test(n, l, h) if ((n) < (l) || (n) > (h)) return(0) -#define days_in_year(a) (leapyear(a) ? 366 : 365) -#define days_in_month(a) (month_days[(a) - 1]) - -#endif /* _RTCLOCKA_H_ */ diff --git a/sys/arch/amiga/dev/rtclockb.c b/sys/arch/amiga/dev/rtclockb.c deleted file mode 100644 index 86f435f5b30b..000000000000 --- a/sys/arch/amiga/dev/rtclockb.c +++ /dev/null @@ -1,219 +0,0 @@ -/* this provides a device interface to the realtime clock - used on the A2000. - - To support different clocks: the config file defines a - realtime clock "rtclock". Write your own driver that if - matched by existing hardware returns 1 from its init - function, and set the function pointer "gettod" to - a function returning the number of seconds elapsed since - 1970-1-1. - - TODO: could add read-write interface to turn this into - a real /dev/rtclock device, that would allow reading - and setting of the clock very easily. - * - * $Id: rtclockb.c,v 1.4 1994/02/13 21:10:54 chopps Exp $ - */ - -#include "rtclockb.h" -#if NRTCLOCKB > 0 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -int rtclockbinit (register struct amiga_device *ad); - -static long rtgettod (); -static int rtsettod (); - -/* amiga/clock.c calls thru this vector, if it is set, to read - the realtime clock */ -extern long (*gettod)(); -extern int (*settod)(); - -/* since there's only one such clock on the A2000, we can - savely store its address in a static variable */ -static struct rtclock2000 *rt = 0; - -struct driver rtclockbdriver = { - (int (*)(void *)) rtclockbinit, "rtclock", -}; - - -int -rtclockbinit (register struct amiga_device *ad) -{ - /* verify we're indeed present */ - if (ad->amiga_addr) - { - rt = (struct rtclock2000 *) ad->amiga_addr; - if (rtgettod ()) - { - gettod = rtgettod; - settod = rtsettod; - printf ("Realtime clock A2000\n"); - return 1; - } - else - printf ("Realtime clock A2000 malfunctioning, ignored.\n"); - } - - return 0; -} - - -static int month_days[12] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - -static long -rtgettod () -{ - register int i; - register u_long tmp; - int year, month, day, hour, min, sec; - - /* hold clock */ - rt->control1 |= CONTROL1_HOLD; - while (rt->control1 & CONTROL1_BUSY) ; - - /* read it */ - sec = rt->second1 * 10 + rt->second2; - min = rt->minute1 * 10 + rt->minute2; - hour = (rt->hour1 & 3) * 10 + rt->hour2; - day = rt->day1 * 10 + rt->day2; - month = rt->month1 * 10 + rt->month2; - year = rt->year1 * 10 + rt->year2 + 1900; - - if (! (rt->control3 & CONTROL3_24HMODE)) - { - if (!(rt->hour1 & HOUR1_PM) && hour == 12) - hour = 0; - else if ((rt->hour1 & HOUR1_PM) && hour != 12) - hour += 12; - } - - - /* let it run again.. */ - rt->control1 &= ~CONTROL1_HOLD; - -#if 0 - printf ("rt: sec=%d, min=%d, hour=%d, day=%d, mon=%d, year=%d\n", - sec, min, hour, day, month, year); -#endif - - range_test(hour, 0, 23); - range_test(day, 1, 31); - range_test(month, 1, 12); - range_test(year, STARTOFTIME, 2000); - - tmp = 0; - - for (i = STARTOFTIME; i < year; i++) - tmp += days_in_year(i); - if (leapyear(year) && month > FEBRUARY) - tmp++; - - for (i = 1; i < month; i++) - tmp += days_in_month(i); - - tmp += (day - 1); - tmp = ((tmp * 24 + hour) * 60 + min) * 60 + sec; - - return tmp; -} - - -int -rtsettod (tim) - long tim; -{ - /* I don't know if setting the clock is analogous - to reading it, I don't have demo-code for setting. - just give it a try.. */ - - register int i; - register long hms, day; - u_char sec1, sec2; - u_char min1, min2; - u_char hour1, hour2; - u_char day1, day2; - u_char mon1, mon2; - u_char year1, year2; - - /* there seem to be problems with the bitfield addressing - currently used.. */ - return 0; - -#if 0 - if (! rt) - return 0; - - /* prepare values to be written to clock */ - day = tim / SECDAY; - hms = tim % SECDAY; - - - hour2 = hms / 3600; - hour1 = hour2 / 10; - hour2 %= 10; - - min2 = (hms % 3600) / 60; - min1 = min2 / 10; - min2 %= 10; - - - sec2 = (hms % 3600) % 60; - sec1 = sec2 / 10; - sec2 %= 10; - - /* Number of years in days */ - for (i = STARTOFTIME - 1900; day >= days_in_year(i); i++) - day -= days_in_year(i); - year1 = i / 10; - year2 = i % 10; - - /* Number of months in days left */ - if (leapyear(i)) - days_in_month(FEBRUARY) = 29; - for (i = 1; day >= days_in_month(i); i++) - day -= days_in_month(i); - days_in_month(FEBRUARY) = 28; - - mon1 = i / 10; - mon2 = i % 10; - - /* Days are what is left over (+1) from all that. */ - day ++; - day1 = day / 10; - day2 = day % 10; - - rt->control1 = CONTROL1_HOLD_CLOCK; - rt->second1 = sec1; - rt->second2 = sec2; - rt->minute1 = min1; - rt->minute2 = min2; - rt->hour1 = hour1; - rt->hour2 = hour2; - rt->day1 = day1; - rt->day2 = day2; - rt->month1 = mon1; - rt->month2 = mon2; - rt->year1 = year1; - rt->year2 = year2; - rt->control2 = CONTROL1_FREE_CLOCK; - - return 1; -#endif -} -#endif /* NRTCLOCKB */ diff --git a/sys/arch/amiga/dev/rtclockb_var.h b/sys/arch/amiga/dev/rtclockb_var.h deleted file mode 100644 index d92020097659..000000000000 --- a/sys/arch/amiga/dev/rtclockb_var.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * $Id: rtclockb_var.h,v 1.3 1994/02/11 07:02:07 chopps Exp $ - */ - -#ifndef _RTCLOCKB_H_ -#define _RTCLOCKB_H_ - -/* clock used in the A2000, according to info I got from - Harald Backert. */ - - - -struct rtclock2000 { - u_int :28, second2:4; /* lower digit */ - u_int :28, second1:4; /* upper digit */ - u_int :28, minute2:4; /* lower digit */ - u_int :28, minute1:4; /* upper digit */ - u_int :28, hour2:4; /* lower digit */ - u_int :28, hour1:4; /* upper digit */ - u_int :28, day2:4; /* lower digit */ - u_int :28, day1:4; /* upper digit */ - u_int :28, month2:4; /* lower digit */ - u_int :28, month1:4; /* upper digit */ - u_int :28, year2:4; /* lower digit */ - u_int :28, year1:4; /* upper digit */ - u_int :28, week:4; /* week */ - u_int :28, control1:4; /* control-byte 1 */ - u_int :28, control2:4; /* control-byte 2 */ - u_int :28, control3:4; /* control-byte 3 */ -}; - - -/* commands written to control1, HOLD before reading the clock, - FREE after done reading. */ - -#define CONTROL1_HOLD (1<<0) -#define CONTROL1_BUSY (1<<1) -#define CONTROL3_24HMODE (1<<2) -#define HOUR1_PM (1<<2) - -#define FEBRUARY 2 -#define STARTOFTIME 1970 -#define SECDAY 86400L -#define SECYR (SECDAY * 365) - -#define leapyear(y) (((y)%4)==0 && ((y)%100)!=0 || ((y)%400) == 0) -#define range_test(n, l, h) if ((n) < (l) || (n) > (h)) return(0) -#define days_in_year(a) (leapyear(a) ? 366 : 365) -#define days_in_month(a) (month_days[(a) - 1]) - -#endif /* _RTCLOCKB_H_ */ diff --git a/sys/arch/amiga/dev/scsi.c b/sys/arch/amiga/dev/scsi.c deleted file mode 100644 index c8fc12290827..000000000000 --- a/sys/arch/amiga/dev/scsi.c +++ /dev/null @@ -1,1954 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Van Jacobson of Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)scsi.c 7.5 (Berkeley) 5/4/91 - * $Id: scsi.c,v 1.11 1994/04/18 04:09:17 chopps Exp $ - * - * MULTICONTROLLER support only working for multiple controllers of the - * same kind at the moment !! - * - */ - -/* - * AMIGA AMD 33C93 scsi adaptor driver - */ -#include "a3000scsi.h" -#include "a2091scsi.h" -#include "gvp11scsi.h" - -/* - * Define NSCSI to be the largest of all the 33C93 controllers configured - */ -#define NSCSI NA3000SCSI -#if NA2091SCSI > NSCSI -#undef NSCSI -#define NSCSI NA2091SCSI -#endif -#if NGVP11SCSI > NSCSI -#undef NSCSI -#define NSCSI NGVP11SCSI -#endif - -#if NSCSI > 0 - -#ifndef lint -static char rcsid[] = "$Header: /cvsroot/src/sys/arch/amiga/dev/Attic/scsi.c,v 1.11 1994/04/18 04:09:17 chopps Exp $"; -#endif - -/* need to know if any tapes have been configured */ -#include "st.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include - -extern u_int kvtop(); - -static int sbic_wait __P((volatile sbic_padded_regmap_t *regs, char until, - int timeo, int line)); -static void scsiabort __P((register struct scsi_softc *dev, - register volatile sbic_padded_regmap_t *regs, char *where)); -static void scsierror __P((register struct scsi_softc *dev, - register volatile sbic_padded_regmap_t *regs, u_char csr)); -static int issue_select __P((register struct scsi_softc *dev, - register volatile sbic_padded_regmap_t *regs, u_char target, - u_char our_addr)); -static int wait_for_select __P((register struct scsi_softc *dev, - register volatile sbic_padded_regmap_t *regs)) ; -static int ixfer_start __P((register volatile sbic_padded_regmap_t *regs, - int len, u_char phase, register int wait)); -static int ixfer_out __P((register volatile sbic_padded_regmap_t *regs, - int len, register u_char *buf, int phase)); -static void ixfer_in __P((register volatile sbic_padded_regmap_t *regs, - int len, register u_char *buf)); -static int scsiicmd __P((struct scsi_softc *dev, int target, u_char *cbuf, - int clen, u_char *buf, int len, u_char xferphase)); -static void finishxfer __P((struct scsi_softc *dev, - register volatile sbic_padded_regmap_t *regs, int target)); -static int check_dma_buf __P((char *buffer, u_long len, u_long mask)); - -/* - * SCSI delays - * In u-seconds, primarily for state changes on the SPC. - */ -#define SCSI_CMD_WAIT 50000 /* wait per step of 'immediate' cmds */ -#define SCSI_DATA_WAIT 50000 /* wait per data in/out step */ -#define SCSI_INIT_WAIT 50000 /* wait per step (both) during init */ - -extern void _insque(); -extern void _remque(); - - -void scsistart __P((int unit)); -void scsidone __P((int unit)); -void scsifree __P((register struct devqueue *dq)); -void scsireset __P((int unit)); -void scsi_delay __P((int delay)); -int scsigo __P((int ctlr, int slave, int unit, struct buf *bp, - struct scsi_fmt_cdb *cdb, int pad)); -int scsiintr __P((int unit)); -int scsiustart __P((int unit)); -int scsireq __P((register struct devqueue *dq)); -int scsi_test_unit_rdy __P((int ctlr, int slave, int unit)); -int scsi_start_stop_unit __P((int ctlr, int slave, int unit, int start)); -int scsi_request_sense __P((int ctlr, int slave, int unit, u_char *buf, - unsigned int len)); -int scsi_immed_command __P((int ctlr, int slave, int unit, - struct scsi_fmt_cdb *cdb, u_char *buf, unsigned int len, int rd)); -int scsi_immed_command_nd __P((int ctlr, int slave, int unit, - struct scsi_fmt_cdb *cdb)); -int scsi_tt_read __P((int ctlr, int slave, int unit, u_char *buf, - u_int len, daddr_t blk, int bshift)); -int scsi_tt_write __P((int ctlr, int slave, int unit, u_char *buf, - u_int len, daddr_t blk, int bshift)); -#if NST > 0 -int scsi_tt_oddio __P((int ctlr, int slave, int unit, u_char *buf, - u_int len, int b_flags, int freedma)); -#endif - - -#if NA3000SCSI > 0 -int a3000scsiinit (); - -struct driver a3000scsidriver = { - (int (*)(void *)) a3000scsiinit, "a3000scsi", (int (*)(int)) scsistart, - (int (*)(int,...)) scsigo, (int (*)(int,int)) scsiintr, - (int (*)())scsidone, scsiustart, scsireq, scsifree, scsireset, - scsi_delay, scsi_test_unit_rdy, scsi_start_stop_unit, - scsi_request_sense, scsi_immed_command, scsi_immed_command_nd, - scsi_tt_read, scsi_tt_write, -#if NST > 0 - scsi_tt_oddio -#else - NULL -#endif -}; -#endif - -#if NA2091SCSI > 0 -int a2091scsiinit (); - -struct driver a2091scsidriver = { - (int (*)(void *)) a2091scsiinit, "a2091scsi", (int (*)(int)) scsistart, - (int (*)(int,...)) scsigo, (int (*)(int,int)) scsiintr, - (int (*)())scsidone, scsiustart, scsireq, scsifree, scsireset, - scsi_delay, scsi_test_unit_rdy, scsi_start_stop_unit, - scsi_request_sense, scsi_immed_command, scsi_immed_command_nd, - scsi_tt_read, scsi_tt_write, -#if NST > 0 - scsi_tt_oddio -#else - NULL -#endif -}; - -int a2091_dmabounce = 1; /* default to use bounce buffer */ -#endif - -#if NGVP11SCSI > 0 -int gvp11scsiinit (); - -struct driver gvp11scsidriver = { - (int (*)(void *)) gvp11scsiinit, "GVPIIscsi", (int (*)(int)) scsistart, - (int (*)(int,...)) scsigo, (int (*)(int,int)) scsiintr, - (int (*)())scsidone, scsiustart, scsireq, scsifree, scsireset, - scsi_delay, scsi_test_unit_rdy, scsi_start_stop_unit, - scsi_request_sense, scsi_immed_command, scsi_immed_command_nd, - scsi_tt_read, scsi_tt_write, -#if NST > 0 - scsi_tt_oddio -#else - NULL -#endif -}; - -int gvp11_dmabounce = 1; /* default to use bounce buffer */ -u_long gvp11_dma_mask = 0; /* default to use controller-specific mask */ -#endif - - -struct scsi_softc scsi_softc[NSCSI]; -int scsi_nscsi = NSCSI; /* DMA routines need table size */ - -int scsi_cmd_wait = SCSI_CMD_WAIT; -int scsi_data_wait = SCSI_DATA_WAIT; -int scsi_init_wait = SCSI_INIT_WAIT; - -/* - * Synch xfer parameters, and timing conversions - */ -static int sbic_min_period = SBIC_SYN_MIN_PERIOD; /* in cycles = f(ICLK,FSn) */ -static int sbic_max_offset = SBIC_SYN_MAX_OFFSET; /* pure number */ - -static int -sbic_to_scsi_period(dev, regs, a) - struct scsi_softc *dev; - sbic_padded_regmap_t *regs; -{ - unsigned int fs; - - /* cycle = DIV / (2*CLK) */ - /* DIV = FS+2 */ - /* best we can do is 200ns at 20Mhz, 2 cycles */ - - GET_SBIC_myid(regs,fs); - fs = (fs >>6) + 2; /* DIV */ - fs = (fs * 10000) / (dev->sc_clock_freq<<1); /* Cycle, in ns */ - if (a < 2) a = 8; /* map to Cycles */ - return ((fs*a)>>2); /* in 4 ns units */ -} - -static int -scsi_period_to_sbic(dev, regs, p) - struct scsi_softc *dev; - sbic_padded_regmap_t *regs; -{ - register unsigned int fs, ret; - - /* Just the inverse of the above */ - - GET_SBIC_myid(regs,fs); - fs = (fs >>6) + 2; /* DIV */ - fs = (fs * 10000) / (dev->sc_clock_freq<<1); /* Cycle, in ns */ - - ret = p << 2; /* in ns units */ - ret = ret / fs; /* in Cycles */ - if (ret < sbic_min_period) - return sbic_min_period; - /* verify rounding */ - if (sbic_to_scsi_period(dev, regs, ret) < p) - ret++; - return (ret >= 8) ? 0 : ret; -} - -/* default to not inhibit sync negotiation on any drive */ -u_char inhibit_sync[NSCSI][8] = { 1, 1, 1, 1, 1, 1, 1 }; /* initialize, so patchable */ -int scsi_no_dma = 0; - -#ifdef DEBUG -int scsi_debug = 0; -int sync_debug = 0; -int scsi_dma_debug = 0; -#define WAITHIST -#define QUASEL - -static long dmahits[NSCSI]; -static long dmamisses[NSCSI]; -#endif - -#ifdef QUASEL -#define QPRINTF(a) if (scsi_debug > 1) printf a -#else -#define QPRINTF -#endif - -#ifdef WAITHIST -#define MAXWAIT 1022 -u_int ixstart_wait[MAXWAIT+2]; -u_int ixin_wait[MAXWAIT+2]; -u_int ixout_wait[MAXWAIT+2]; -u_int mxin_wait[MAXWAIT+2]; -u_int mxin2_wait[MAXWAIT+2]; -u_int cxin_wait[MAXWAIT+2]; -u_int fxfr_wait[MAXWAIT+2]; -u_int sgo_wait[MAXWAIT+2]; -#define HIST(h,w) (++h[((w)>MAXWAIT? MAXWAIT : ((w) < 0 ? -1 : (w))) + 1]); -#else -#define HIST(h,w) -#endif - -#define b_cylin b_resid - -static sbic_wait (regs, until, timeo, line) - volatile sbic_padded_regmap_t *regs; - char until; - int timeo; - int line; -{ - register unsigned char val; - - if (! timeo) - timeo = 1000000; /* some large value.. */ - - GET_SBIC_asr (regs,val); - while ((val & until) == 0) - { - if (!timeo--) - { - int csr; - GET_SBIC_csr (regs, csr); - printf("sbic_wait TIMEO @%d with asr=x%x csr=x%x\n", line, val, csr); - break; - } - DELAY(1); - GET_SBIC_asr(regs,val); - } - return val; -} - -#define SBIC_WAIT(regs, until, timeo) sbic_wait (regs, until, timeo, __LINE__) - - -static void -scsiabort(dev, regs, where) - register struct scsi_softc *dev; - volatile register sbic_padded_regmap_t *regs; - char *where; -{ - u_char csr, asr; - - GET_SBIC_csr (regs, csr); - GET_SBIC_asr (regs, asr); - - printf ("scsi%d: abort %s: csr = 0x%02x, asr = 0x%02x\n", - dev->sc_ac->amiga_unit, - where, csr, asr); - - if (dev->sc_flags & SCSI_SELECTED) - { - SET_SBIC_cmd (regs, SBIC_CMD_ABORT); - WAIT_CIP (regs); - - GET_SBIC_asr (regs, asr); - if (asr & (SBIC_ASR_BSY|SBIC_ASR_LCI)) - { - /* ok, get more drastic.. */ - - SET_SBIC_cmd (regs, SBIC_CMD_RESET); - DELAY(25); - SBIC_WAIT(regs, SBIC_ASR_INT, 0); - GET_SBIC_csr (regs, csr); /* clears interrupt also */ - - dev->sc_flags &= ~SCSI_SELECTED; - return; - } - - do - { - SBIC_WAIT (regs, SBIC_ASR_INT, 0); - GET_SBIC_csr (regs, csr); - } - while ((csr != SBIC_CSR_DISC) && (csr != SBIC_CSR_DISC_1) - && (csr != SBIC_CSR_CMD_INVALID)); - - /* lets just hope it worked.. */ - dev->sc_flags &= ~SCSI_SELECTED; - } -} - -/* - * XXX Set/reset long delays. - * - * if delay == 0, reset default delays - * if delay < 0, set both delays to default long initialization values - * if delay > 0, set both delays to this value - * - * Used when a devices is expected to respond slowly (e.g. during - * initialization). - */ -void -scsi_delay(delay) - int delay; -{ - static int saved_cmd_wait, saved_data_wait; - - if (delay) { - saved_cmd_wait = scsi_cmd_wait; - saved_data_wait = scsi_data_wait; - if (delay > 0) - scsi_cmd_wait = scsi_data_wait = delay; - else - scsi_cmd_wait = scsi_data_wait = scsi_init_wait; - } else { - scsi_cmd_wait = saved_cmd_wait; - scsi_data_wait = saved_data_wait; - } -} - -static int initialized[NSCSI]; -int scsi_clock_override = 0; - -#if NA3000SCSI > 0 -int -a3000scsiinit(ac) - register struct amiga_ctlr *ac; -{ - register struct scsi_softc *dev = &scsi_softc[ac->amiga_unit]; - register sbic_padded_regmap_t *regs; - - if (! ac->amiga_addr) - return 0; - - if (initialized[ac->amiga_unit]) - return 0; - - initialized[ac->amiga_unit] = 1; - - /* initialize dma */ - a3000dmainit (ac, dev); - dev->dmamask = 0; /* A3000 can DMA to all memory */ - - /* advance ac->amiga_addr to point to the real sbic-registers */ - ac->amiga_addr = (caddr_t) ((int)ac->amiga_addr + 0x41); - regs = (sbic_padded_regmap_t *) ac->amiga_addr; - dev->sc_clock_freq = scsi_clock_override ? scsi_clock_override : 143; - - - /* hardwired IPL */ - ac->amiga_ipl = 2; - dev->sc_ac = ac; - dev->sc_sq.dq_forw = dev->sc_sq.dq_back = &dev->sc_sq; - scsireset (ac->amiga_unit); - - /* make sure IPL2 interrupts are delivered to the cpu when the sbic - generates some. Note that this does not yet enable sbic-interrupts, - this is handled in dma.c, which selectively enables interrupts only - while DMA requests are pending. - - Note that enabling PORTS interrupts also enables keyboard interrupts - as soon as the corresponding int-enable bit in CIA-A is set. */ - - custom.intreq = INTF_PORTS; - custom.intena = INTF_SETCLR | INTF_PORTS; - return(1); -} -#endif - -#if NA2091SCSI > 0 -int -a2091scsiinit(ac) - register struct amiga_ctlr *ac; -{ - register struct scsi_softc *dev = &scsi_softc[ac->amiga_unit]; - register sbic_padded_regmap_t *regs; - - if (! ac->amiga_addr) - return 0; - - if (initialized[ac->amiga_unit]) - return 0; - - initialized[ac->amiga_unit] = 1; - - /* initialize dma */ - a2091dmainit (ac, dev); - dev->sc_flags |= SCSI_DMA24; /* can only DMA in ZorroII memory */ - dev->dmamask = 0xff000000; /* set invalid DMA mask */ - if (a2091_dmabounce) { - /* XXX should do this dynamically when needed? */ - dev->dmabuffer = (char *) alloc_z2mem (MAXPHYS); -#ifdef DEBUG - printf ("a2091scsi: dma bounce buffer at %08x\n", dev->dmabuffer); -#endif - } - - /* advance ac->amiga_addr to point to the real sbic-registers */ - ac->amiga_addr = (caddr_t) ((int)ac->amiga_addr + 0x91); - regs = (sbic_padded_regmap_t *) ac->amiga_addr; - dev->sc_clock_freq = scsi_clock_override ? scsi_clock_override : 77; - - - /* hardwired IPL */ - ac->amiga_ipl = 2; - dev->sc_ac = ac; - dev->sc_sq.dq_forw = dev->sc_sq.dq_back = &dev->sc_sq; - scsireset (ac->amiga_unit); - - /* make sure IPL2 interrupts are delivered to the cpu when the sbic - generates some. Note that this does not yet enable sbic-interrupts, - this is handled in dma.c, which selectively enables interrupts only - while DMA requests are pending. - - Note that enabling PORTS interrupts also enables keyboard interrupts - as soon as the corresponding int-enable bit in CIA-A is set. */ - - custom.intreq = INTF_PORTS; - custom.intena = INTF_SETCLR | INTF_PORTS; - return(1); -} -#endif - -#if NGVP11SCSI > 0 -int -gvp11scsiinit(ac) - register struct amiga_ctlr *ac; -{ - register struct scsi_softc *dev = &scsi_softc[ac->amiga_unit]; - register sbic_padded_regmap_t *regs; - u_char *id_reg; - - if (! ac->amiga_addr) - return 0; - - if (initialized[ac->amiga_unit]) - return 0; - - initialized[ac->amiga_unit] = 1; - - /* initialize dma */ - gvp11dmainit (ac, dev); - /* XXX add Series I support !!! */ - id_reg = (u_char *)ac->amiga_addr + 0x8001; - dev->sc_flags |= SCSI_DMA24; /* can only DMA in ZorroII memory */ - if (gvp11_dma_mask) /* XXX use specified DMA mask */ - dev->dmamask = ~gvp11_dma_mask; /* XXX should validate mask? */ - else - switch (*id_reg & 0xf8) { - case PROD_GVP_X_GF40_SCSI: /* G-Force '040 SCSI */ - dev->dmamask = ~0x07ffffff; - break; - case PROD_GVP_X_GF30_SCSI: /* G-Force '030 SCSI */ - case PROD_GVP_X_COMBO4: - dev->dmamask = ~0x01ffffff; /* Combo '030 rev 4 SCSI */ - break; - case PROD_GVP_X_COMBO3: /* Combo '030 rev 3 SCSI */ - case PROD_GVP_X_SCSI_II: /* Impact Series-II SCSI */ - dev->dmamask = ~0x00ffffff; - break; - default: - dev->dmamask = ~0x00000000; /* shouldn't be any others */ - } - dev->bankmask = (~dev->dmamask >> 18) & 0x01c0; - if (gvp11_dmabounce) { - /* XXX should do this dynamically when needed? */ - dev->dmabuffer = (char *) alloc_z2mem (MAXPHYS); -#ifdef DEBUG - printf ("gvp11scsi: dma bounce buffer at %08x\n", dev->dmabuffer); -#endif - } - - /* advance ac->amiga_addr to point to the real sbic-registers */ - ac->amiga_addr = (caddr_t) ((int)ac->amiga_addr + 0x61); - regs = (sbic_padded_regmap_t *) ac->amiga_addr; - dev->sc_clock_freq = scsi_clock_override ? scsi_clock_override : 77; - - - /* hardwired IPL */ - ac->amiga_ipl = 2; - dev->sc_ac = ac; - dev->sc_sq.dq_forw = dev->sc_sq.dq_back = &dev->sc_sq; - scsireset (ac->amiga_unit); - - /* make sure IPL2 interrupts are delivered to the cpu when the sbic - generates some. Note that this does not yet enable sbic-interrupts, - this is handled in dma.c, which selectively enables interrupts only - while DMA requests are pending. - - Note that enabling PORTS interrupts also enables keyboard interrupts - as soon as the corresponding int-enable bit in CIA-A is set. */ - - custom.intreq = INTF_PORTS; - custom.intena = INTF_SETCLR | INTF_PORTS; - return(1); -} -#endif - - -void -scsireset(unit) - register int unit; -{ - register struct scsi_softc *dev = &scsi_softc[unit]; - volatile register sbic_padded_regmap_t *regs = - (sbic_padded_regmap_t *)dev->sc_ac->amiga_addr; - u_int i, s; - u_char my_id, csr; - - if (dev->sc_flags & SCSI_ALIVE) - scsiabort(dev, regs, "reset"); - - printf("scsi%d: ", unit); - - s = splbio(); - /* preserve our ID for now */ - GET_SBIC_myid (regs, my_id); - my_id &= SBIC_ID_MASK; - - if (dev->sc_clock_freq < 110) - my_id |= SBIC_ID_FS_8_10; - else if (dev->sc_clock_freq < 160) - my_id |= SBIC_ID_FS_12_15; - else if (dev->sc_clock_freq < 210) - my_id |= SBIC_ID_FS_16_20; - - my_id |= SBIC_ID_EAF/* |SBIC_ID_EHP*/; - - SET_SBIC_myid (regs, my_id); - - /* - * Disable interrupts (in dmainit) then reset the chip - */ - SET_SBIC_cmd (regs, SBIC_CMD_RESET); - DELAY(25); - SBIC_WAIT(regs, SBIC_ASR_INT, 0); - GET_SBIC_csr (regs, csr); /* clears interrupt also */ - - /* - * Set up various chip parameters - */ - SET_SBIC_control (regs, (/*SBIC_CTL_HHP |*/ SBIC_CTL_EDI | SBIC_CTL_IDI | - /* | SBIC_CTL_HSP | */ SBIC_MACHINE_DMA_MODE)); - /* don't allow (re)selection (SBIC_RID_ES) until we can handle target mode!! */ - SET_SBIC_rselid (regs, 0 /* | SBIC_RID_ER | SBIC_RID_ES | SBIC_RID_DSP */); - SET_SBIC_syn (regs, 0); /* asynch for now */ - - /* anything else was zeroed by reset */ - -#if 0 - /* go async for now */ - dev->sc_sync = 0; - printf ("async, "); -#endif - - splx (s); - - printf("scsi id %d\n", my_id & SBIC_ID_MASK); - dev->sc_flags |= SCSI_ALIVE; - dev->sc_flags &= ~SCSI_SELECTED; -} - -static void -scsierror(dev, regs, csr) - register struct scsi_softc *dev; - volatile register sbic_padded_regmap_t *regs; - u_char csr; -{ - int unit = dev->sc_ac->amiga_unit; - char *sep = ""; - - printf("scsi%d: ", unit); -#if 0 - if (ints & INTS_RST) { - DELAY(100); - if (regs->scsi_aconf & HCONF_SD) - printf("spurious RST interrupt"); - else - printf("hardware error - check fuse"); - sep = ", "; - } - if ((ints & INTS_HARD_ERR) || regs->scsi_serr) { - if (regs->scsi_serr & SERR_SCSI_PAR) { - printf("%sparity err", sep); - sep = ", "; - } - if (regs->scsi_serr & SERR_SPC_PAR) { - printf("%sSPC parity err", sep); - sep = ", "; - } - if (regs->scsi_serr & SERR_TC_PAR) { - printf("%sTC parity err", sep); - sep = ", "; - } - if (regs->scsi_serr & SERR_PHASE_ERR) { - printf("%sphase err", sep); - sep = ", "; - } - if (regs->scsi_serr & SERR_SHORT_XFR) { - printf("%ssync short transfer err", sep); - sep = ", "; - } - if (regs->scsi_serr & SERR_OFFSET) { - printf("%ssync offset error", sep); - sep = ", "; - } - } - if (ints & INTS_TIMEOUT) - printf("%sSPC select timeout error", sep); - if (ints & INTS_SRV_REQ) - printf("%sspurious SRV_REQ interrupt", sep); - if (ints & INTS_CMD_DONE) - printf("%sspurious CMD_DONE interrupt", sep); - if (ints & INTS_DISCON) - printf("%sspurious disconnect interrupt", sep); - if (ints & INTS_RESEL) - printf("%sspurious reselect interrupt", sep); - if (ints & INTS_SEL) - printf("%sspurious select interrupt", sep); -#else - printf ("csr == 0x%02x", csr); /* XXX */ -#endif - printf("\n"); -} - -static int -issue_select(dev, regs, target, our_addr) - register struct scsi_softc *dev; - volatile register sbic_padded_regmap_t *regs; - u_char target, our_addr; -{ - u_char asr, csr; - - QPRINTF (("issue_select %d\n", target)); - - /* if we're already selected, return */ - if (dev->sc_flags & SCSI_SELECTED) /* XXXX */ - return 1; - - SBIC_TC_PUT (regs, 0); - SET_SBIC_selid (regs, target); - SET_SBIC_timeo (regs, SBIC_TIMEOUT(250,dev->sc_clock_freq)); - if (dev->sc_sync[target].state == SYNC_DONE) - { - /* set to negotiated values */ - SET_SBIC_syn (regs, SBIC_SYN (dev->sc_sync[target].offset, - dev->sc_sync[target].period)); - } - else - { - /* set to async */ - SET_SBIC_syn (regs, SBIC_SYN (0, sbic_min_period)); - } - SET_SBIC_cmd (regs, SBIC_CMD_SEL_ATN); - - return (0); -} - -static int -wait_for_select(dev, regs) - register struct scsi_softc *dev; - volatile register sbic_padded_regmap_t *regs; -{ - u_char asr, csr; - - QPRINTF (("wait_for_select: ")); - - WAIT_CIP (regs); - do - { - SBIC_WAIT (regs, SBIC_ASR_INT, 0); - GET_SBIC_csr (regs, csr); - QPRINTF (("%02x ", csr)); - } - while (csr != (SBIC_CSR_MIS_2|MESG_OUT_PHASE) - && csr != (SBIC_CSR_MIS_2|CMD_PHASE) - && csr != SBIC_CSR_SEL_TIMEO); - - /* Send identify message (SCSI-2 requires an identify msg (?)) */ - if (csr == (SBIC_CSR_MIS_2|MESG_OUT_PHASE)) - { - u_char id; - GET_SBIC_selid (regs, id); - - /* handle drives that don't want to be asked whether to go - sync at all. */ - if (inhibit_sync[dev->sc_ac->amiga_unit][id] - && dev->sc_sync[id].state == SYNC_START) - { -#ifdef DEBUG - if (sync_debug) - printf ("Forcing target %d asynchronous.\n", id); -#endif - dev->sc_sync[id].offset = 0; - dev->sc_sync[id].period = sbic_min_period; - dev->sc_sync[id].state = SYNC_DONE; - } - - - if (dev->sc_sync[id].state == SYNC_START) - { - /* then try to initiate a sync transfer. - - So compose the sync message we're going to send to the target */ - -#ifdef DEBUG - if (sync_debug) - printf ("Sending sync request to target %d ... ", id); -#endif - dev->sc_msg[0] = MSG_IDENTIFY; /* no MSG_IDENTIFY_DR yet */ - dev->sc_msg[1] = MSG_EXT_MESSAGE; /* sync request is extended message */ - dev->sc_msg[2] = 3; /* length */ - dev->sc_msg[3] = MSG_SYNC_REQ; - dev->sc_msg[4] = sbic_to_scsi_period (dev, regs, sbic_min_period); - dev->sc_msg[5] = sbic_max_offset; - - if (ixfer_start (regs, 6, MESG_OUT_PHASE, scsi_cmd_wait)) - ixfer_out (regs, 6, dev->sc_msg, MESG_OUT_PHASE); - - dev->sc_sync[id].state = SYNC_SENT; -#ifdef DEBUG - if (sync_debug) - printf ("sent\n"); -#endif - } - else - { - /* just send identify then */ - SEND_BYTE (regs, MSG_IDENTIFY); - } - - SBIC_WAIT (regs, SBIC_ASR_INT, 0); - GET_SBIC_csr (regs, csr); - QPRINTF (("[%02x]", csr)); -#ifdef DEBUG - if (sync_debug && dev->sc_sync[id].state == SYNC_SENT) - printf ("csr-result of last msgout: 0x%x\n", csr); -#endif - - if (csr != SBIC_CSR_SEL_TIMEO) - dev->sc_flags |= SCSI_SELECTED; - } - else if (csr == (SBIC_CSR_MIS_2|CMD_PHASE)) - dev->sc_flags |= SCSI_SELECTED; /* device ignored ATN */ - - QPRINTF(("\n")); - - return csr == SBIC_CSR_SEL_TIMEO; -} - -static int -ixfer_start(regs, len, phase, wait) - volatile register sbic_padded_regmap_t *regs; - int len; - u_char phase; - register int wait; -{ -#if 0 - regs->scsi_tch = len >> 16; - regs->scsi_tcm = len >> 8; - regs->scsi_tcl = len; - regs->scsi_pctl = phase; - regs->scsi_tmod = 0; /*XXX*/ - regs->scsi_scmd = SCMD_XFR | SCMD_PROG_XFR; - - /* wait for xfer to start or svc_req interrupt */ - while ((regs->scsi_ssts & SSTS_BUSY) == 0) { - if (regs->scsi_ints || --wait < 0) { -#ifdef DEBUG - if (scsi_debug) - printf("ixfer_start fail: i%x, w%d\n", - regs->scsi_ints, wait); -#endif - HIST(ixstart_wait, wait) - return (0); - } - DELAY(1); - } - HIST(ixstart_wait, wait) - return (1); -#else - if (phase == DATA_IN_PHASE || phase == MESG_IN_PHASE) - { - u_char id; - - GET_SBIC_selid (regs, id); - id |= SBIC_SID_FROM_SCSI; - SET_SBIC_selid (regs, id); - - SBIC_TC_PUT (regs, (unsigned)len); - } - else if (phase == DATA_OUT_PHASE || phase == MESG_OUT_PHASE - || phase == CMD_PHASE ) - { - SBIC_TC_PUT (regs, (unsigned)len); - } - else - { - SBIC_TC_PUT (regs, 0); - } - - QPRINTF(("ixfer_start %d, %d, %d\n", len, phase, wait)); - - return 1; -#endif -} - -static int -ixfer_out(regs, len, buf, phase) - volatile register sbic_padded_regmap_t *regs; - int len; - register u_char *buf; - int phase; -{ - register int wait = scsi_data_wait; - u_char orig_csr, csr, asr; - - QPRINTF(("ixfer_out {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - len, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], - buf[6], buf[7], buf[8], buf[9])); - - GET_SBIC_csr (regs, orig_csr); - - /* sigh.. WD-PROTO strikes again.. sending the command in one go causes - the chip to lock up if talking to certain (misbehaving?) targets. - Anyway, this procedure should work for all targets, but it's slightly - slower due to the overhead */ -#if 0 - if (phase == CMD_PHASE) - { - WAIT_CIP (regs); -#if 0 - for (; len > 0; len--) - { - /* clear possible last interrupt */ - GET_SBIC_csr (regs, csr); - - /* send the byte, and expect an interrupt afterwards */ - SEND_BYTE (regs, *buf); - buf++; - SBIC_WAIT (regs, SBIC_ASR_INT, 0); /* XXX */ - } -#else - SET_SBIC_cmd (regs, SBIC_CMD_XFER_INFO); - for (;len > 0; len--) - { - WAIT_CIP (regs); - GET_SBIC_csr (regs, csr); - SET_SBIC_cmd (regs, SBIC_CMD_XFER_INFO | SBIC_CMD_SBT); - GET_SBIC_asr (regs, asr); - while (!(asr & SBIC_ASR_DBR)) - { - DELAY(1); - GET_SBIC_asr (regs, asr); - } - - SET_SBIC_data (regs, *buf); - buf++; - while (!(asr & SBIC_ASR_INT)) - { - DELAY(1); - GET_SBIC_asr (regs, asr); - } - - } - -#endif - } - else -#endif - { - WAIT_CIP (regs); - SET_SBIC_cmd (regs, SBIC_CMD_XFER_INFO); - for (;len > 0; len--) - { - GET_SBIC_asr (regs, asr); - while (!(asr & SBIC_ASR_DBR)) - { - if ((asr & SBIC_ASR_INT) || --wait < 0) - { -#ifdef DEBUG - if (scsi_debug) - printf("ixfer_out fail: l%d i%x w%d\n", - len, asr, wait); -#endif - HIST(ixout_wait, wait) - return (len); - } - DELAY(1); - GET_SBIC_asr (regs, asr); - } - - SET_SBIC_data (regs, *buf); - buf++; - } - } - - QPRINTF(("ixfer_out done\n")); - /* this leaves with one csr to be read */ - HIST(ixout_wait, wait) - return (0); -} - -static void -ixfer_in(regs, len, buf) - volatile register sbic_padded_regmap_t *regs; - int len; - register u_char *buf; -{ - register int wait = scsi_data_wait; - u_char *obp = buf; - u_char orig_csr, csr, asr; - - GET_SBIC_csr (regs, orig_csr); - - QPRINTF(("ixfer_in %d, csr=%02x\n", len, orig_csr)); - - WAIT_CIP (regs); - SET_SBIC_cmd (regs, SBIC_CMD_XFER_INFO); - for (;len > 0; len--) - { - GET_SBIC_asr (regs, asr); - while (!(asr & SBIC_ASR_DBR)) - { - if ((asr & SBIC_ASR_INT) || --wait < 0) - { -#ifdef DEBUG - if (scsi_debug) - printf("ixfer_in fail: l%d i%x w%d\n", - len, asr, wait); -#endif - HIST(ixin_wait, wait) - return; - } - - DELAY(1); - GET_SBIC_asr (regs, asr); - } - - GET_SBIC_data (regs, *buf); - buf++; - } - - QPRINTF(("ixfer_in {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5], - obp[6], obp[7], obp[8], obp[9])); - - /* this leaves with one csr to be read */ - HIST(ixin_wait, wait) -} - - -/* - * SCSI 'immediate' command: issue a command to some SCSI device - * and get back an 'immediate' response (i.e., do programmed xfer - * to get the response data). 'cbuf' is a buffer containing a scsi - * command of length clen bytes. 'buf' is a buffer of length 'len' - * bytes for data. The transfer direction is determined by the device - * (i.e., by the scsi bus data xfer phase). If 'len' is zero, the - * command must supply no data. 'xferphase' is the bus phase the - * caller expects to happen after the command is issued. It should - * be one of DATA_IN_PHASE, DATA_OUT_PHASE or STATUS_PHASE. - */ -static int -scsiicmd(dev, target, cbuf, clen, buf, len, xferphase) - struct scsi_softc *dev; - int target; - u_char *cbuf; - int clen; - u_char *buf; - int len; - u_char xferphase; -{ - volatile register sbic_padded_regmap_t *regs = - (sbic_padded_regmap_t *)dev->sc_ac->amiga_addr; - u_char phase, csr, asr; - register int wait; - - - /* set the sbic into non-DMA mode */ - SET_SBIC_control (regs, (/*SBIC_CTL_HHP |*/ SBIC_CTL_EDI | SBIC_CTL_IDI | - /* | SBIC_CTL_HSP | */ 0)); - -retry_selection: - /* select the SCSI bus (it's an error if bus isn't free) */ - if (issue_select (dev, regs, target, dev->sc_scsi_addr)) - return -1; - if (wait_for_select (dev, regs)) - return -1; - /* - * Wait for a phase change (or error) then let the device - * sequence us through the various SCSI phases. - */ - dev->sc_stat[0] = 0xff; - dev->sc_msg[0] = 0xff; - phase = CMD_PHASE; - while (1) - { - wait = scsi_cmd_wait; - - GET_SBIC_csr (regs, csr); - QPRINTF((">CSR:%02x<", csr)); - - HIST(cxin_wait, wait); - if ((csr != 0xff) && (csr & 0xf0) && (csr & 0x08)) /* requesting some new phase */ - phase = csr & PHASE; - else if ((csr == SBIC_CSR_DISC) || (csr == SBIC_CSR_DISC_1) - || (csr == SBIC_CSR_S_XFERRED)) - { - dev->sc_flags &= ~SCSI_SELECTED; - GET_SBIC_cmd_phase (regs, phase); - if (phase == 0x60) - GET_SBIC_tlun (regs, dev->sc_stat[0]); - else - return -1; - - goto out; - } - else - { - scsierror(dev, regs, csr); - goto abort; - } - - switch (phase) - { - case CMD_PHASE: - if (ixfer_start (regs, clen, phase, wait)) - if (ixfer_out (regs, clen, cbuf, phase)) - goto abort; - phase = xferphase; - break; - - case DATA_IN_PHASE: - if (len <= 0) - goto abort; - wait = scsi_data_wait; - if (ixfer_start (regs, len, phase, wait)) - ixfer_in (regs, len, buf); - phase = STATUS_PHASE; - break; - - case MESG_IN_PHASE: - if (ixfer_start (regs, sizeof (dev->sc_msg), phase, wait)) - { - dev->sc_msg[0] = 0xff; - ixfer_in (regs, sizeof (dev->sc_msg), dev->sc_msg); - /* get the command completion interrupt, or we can't send - a new command (LCI) */ - SBIC_WAIT (regs, SBIC_ASR_INT, wait); - GET_SBIC_csr (regs, csr); -#ifdef DEBUG - if (sync_debug) - printf ("msgin finished with csr 0x%x\n", csr); -#endif - /* test whether this is a reply to our sync request */ - if (dev->sc_msg[0] == MSG_EXT_MESSAGE - && dev->sc_msg[1] == 3 - && dev->sc_msg[2] == MSG_SYNC_REQ) - { - dev->sc_sync[target].period = scsi_period_to_sbic (dev, regs, dev->sc_msg[3]); - dev->sc_sync[target].offset = dev->sc_msg[4]; - dev->sc_sync[target].state = SYNC_DONE; - SET_SBIC_syn (regs, SBIC_SYN (dev->sc_sync[target].offset, - dev->sc_sync[target].period)); - /* ACK the message */ - SET_SBIC_cmd (regs, SBIC_CMD_CLR_ACK); - WAIT_CIP (regs); - phase = CMD_PHASE; /* or whatever */ - printf ("scsi%d: target %d now synchronous, period=%dns, offset=%d.\n", - dev->sc_ac->amiga_unit, target, - dev->sc_msg[3] * 4, dev->sc_msg[4]); - } - else if (dev->sc_msg[0] == MSG_REJECT - && dev->sc_sync[target].state == SYNC_SENT) - { -#ifdef DEBUG - if (sync_debug) - printf ("target %d rejected sync, going async\n", target); -#endif - dev->sc_sync[target].period = sbic_min_period; - dev->sc_sync[target].offset = 0; - dev->sc_sync[target].state = SYNC_DONE; - SET_SBIC_syn (regs, SBIC_SYN (dev->sc_sync[target].offset, - dev->sc_sync[target].period)); - /* ACK the message */ - SET_SBIC_cmd (regs, SBIC_CMD_CLR_ACK); - WAIT_CIP (regs); - phase = CMD_PHASE; /* or whatever */ - } - else if (dev->sc_msg[0] == MSG_REJECT) - { - /* coming to think of it, we'll never REJECt a REJECT - message.. :-) */ - - /* ACK the message */ - SET_SBIC_cmd (regs, SBIC_CMD_CLR_ACK); - WAIT_CIP (regs); - phase = CMD_PHASE; /* or whatever */ - } - else if (dev->sc_msg[0] == MSG_CMD_COMPLETE) - { - /* !! KLUDGE ALERT !! - - quite a few drives don't seem to really like the current - way of sending the sync-handshake together with the - ident-message, and they react by sending command-complete - and disconnecting right after returning the valid sync - handshake. So, all I can do is reselect the drive, and - hope it won't disconnect again. I don't think this is valid - behavior, but I can't help fixing a problem that apparently - exists. - - Note: we should not get here on `normal' command completion, - as that condition is handled by the high-level sel&xfer resume - command used to walk thru status/cc-phase. */ - -#ifdef DEBUG - if (sync_debug) - printf ("GOT CMD-COMPLETE! %d acting weird.. waiting for disconnect...\n", target); -#endif - /* ACK the message */ - SET_SBIC_cmd (regs, SBIC_CMD_CLR_ACK); - WAIT_CIP (regs); - - /* wait for disconnect */ - while ((csr != SBIC_CSR_DISC) && (csr != SBIC_CSR_DISC_1)) - { - DELAY (1); - GET_SBIC_csr (regs, csr); - } -#ifdef DEBUG - if (sync_debug) - printf ("ok.\nRetrying selection.\n"); -#endif - dev->sc_flags &= ~SCSI_SELECTED; - goto retry_selection; - } - else - { -#ifdef DEBUG - if (scsi_debug || sync_debug) - printf ("Rejecting message 0x%02x\n", dev->sc_msg[0]); -#endif - /* prepare to reject the message, NACK */ - SET_SBIC_cmd (regs, SBIC_CMD_SET_ATN); - WAIT_CIP (regs); - SET_SBIC_cmd (regs, SBIC_CMD_CLR_ACK); - WAIT_CIP (regs); - phase = MESG_OUT_PHASE; - } - } - break; - - case MESG_OUT_PHASE: -#ifdef DEBUG - if (sync_debug) - printf ("Sending REJECT message to last received message.\n"); -#endif - /* should only get here on reject, since it's always US that - initiate a sync transfer */ - SEND_BYTE (regs, MSG_REJECT); - phase = STATUS_PHASE; - break; - - case DATA_OUT_PHASE: - if (len <= 0) - goto abort; - wait = scsi_data_wait; - if (ixfer_start (regs, len, phase, wait)) - { - if (ixfer_out (regs, len, buf, phase)) - goto abort; - } - phase = STATUS_PHASE; - break; - - case STATUS_PHASE: - /* the sbic does the status/cmd-complete reading ok, so do this - with its hi-level commands. */ - SBIC_TC_PUT (regs, 0); - SET_SBIC_cmd_phase (regs, 0x46); - SET_SBIC_cmd (regs, SBIC_CMD_SEL_ATN_XFER); - phase = BUS_FREE_PHASE; - break; - - case BUS_FREE_PHASE: - goto out; - - default: - printf("scsi: unexpected phase %d in icmd from %d\n", - phase, target); - goto abort; - } - - /* make sure the last command was taken, ie. we're not hunting after - an ignored command.. */ - GET_SBIC_asr (regs, asr); - if (asr & SBIC_ASR_LCI) - goto abort; - - /* tapes may take a loooong time.. */ - while (asr & SBIC_ASR_BSY) - { - DELAY(1); - GET_SBIC_asr (regs, asr); - } - -#if 0 - if (wait <= 0) - goto abort; -#endif - - /* wait for last command to complete */ - SBIC_WAIT (regs, SBIC_ASR_INT, wait); - } - -abort: - scsiabort(dev, regs, "icmd"); -out: - QPRINTF(("=STS:%02x=", dev->sc_stat[0])); - return (dev->sc_stat[0]); -} - -/* - * Finish SCSI xfer command: After the completion interrupt from - * a read/write operation, sequence through the final phases in - * programmed i/o. This routine is a lot like scsiicmd except we - * skip (and don't allow) the select, cmd out and data in/out phases. - */ -static void -finishxfer(dev, regs, target) - struct scsi_softc *dev; - volatile register sbic_padded_regmap_t *regs; - int target; -{ - u_char phase, csr; - int s; - - QPRINTF(("{")); - s = splbio(); - /* have the sbic complete on its own */ - SBIC_TC_PUT (regs, 0); - SET_SBIC_cmd_phase (regs, 0x46); - SET_SBIC_cmd (regs, SBIC_CMD_SEL_ATN_XFER); - - do - { - SBIC_WAIT (regs, SBIC_ASR_INT, 0); - GET_SBIC_csr (regs, csr); - QPRINTF(("%02x:", csr)); - } - while ((csr != SBIC_CSR_DISC) && (csr != SBIC_CSR_DISC_1) - && (csr != SBIC_CSR_S_XFERRED)); - - dev->sc_flags &= ~SCSI_SELECTED; - GET_SBIC_cmd_phase (regs, phase); - QPRINTF(("}%02x", phase)); - if (phase == 0x60) - GET_SBIC_tlun (regs, dev->sc_stat[0]); - else - scsierror (dev, regs, csr); - - QPRINTF(("=STS:%02x=\n", dev->sc_stat[0])); - splx (s); -} - -int -scsi_test_unit_rdy(ctlr, slave, unit) - int ctlr, slave, unit; -{ - register struct scsi_softc *dev = &scsi_softc[ctlr]; - static struct scsi_cdb6 cdb = { CMD_TEST_UNIT_READY }; - - cdb.lun = unit; - return (scsiicmd(dev, slave, (u_char *)&cdb, sizeof(cdb), (u_char *)0, 0, - STATUS_PHASE)); -} - -int -scsi_start_stop_unit (ctlr, slave, unit, start) - int ctlr, slave, unit; -{ - register struct scsi_softc *dev = &scsi_softc[ctlr]; - static struct scsi_cdb6 cdb = { CMD_LOADUNLOAD }; - - cdb.lun = unit; - /* we don't set the immediate bit, so we wait for the - command to succeed. - We also don't touch the LoEj bit, which is primarily meant - for floppies. */ - cdb.len = start & 0x01; - return (scsiicmd(dev, slave, (u_char *)&cdb, sizeof(cdb), (u_char *)0, 0, - STATUS_PHASE)); -} - -int -scsi_request_sense(ctlr, slave, unit, buf, len) - int ctlr, slave, unit; - u_char *buf; - unsigned len; -{ - static struct scsi_cdb6 cdb = { CMD_REQUEST_SENSE }; - struct scsi_softc *dev; - - dev = &scsi_softc[ctlr]; - cdb.lun = unit; - cdb.len = len; - - return(scsiicmd(dev, slave, (u_char *)&cdb, sizeof(cdb), buf, len, - DATA_IN_PHASE)); -} - -int -scsi_immed_command_nd(ctlr, slave, unit, cdb) - int ctlr, slave, unit; - struct scsi_fmt_cdb *cdb; -{ - register struct scsi_softc *dev = &scsi_softc[ctlr]; - - cdb->cdb[1] |= (unit << 5); - return(scsiicmd(dev, slave, (u_char *) cdb->cdb, cdb->len, - 0, 0, STATUS_PHASE)); -} - -int -scsi_immed_command(ctlr, slave, unit, cdb, buf, len, rd) - int ctlr, slave, unit; - struct scsi_fmt_cdb *cdb; - u_char *buf; - unsigned len; -{ - register struct scsi_softc *dev = &scsi_softc[ctlr]; - - cdb->cdb[1] |= (unit << 5); - return (scsiicmd(dev, slave, (u_char *) cdb->cdb, cdb->len, buf, len, - rd != 0? DATA_IN_PHASE : DATA_OUT_PHASE)); -} - -/* - * The following routines are test-and-transfer i/o versions of read/write - * for things like reading disk labels and writing core dumps. The - * routine scsigo should be used for normal data transfers, NOT these - * routines. - */ -int -scsi_tt_read(ctlr, slave, unit, buf, len, blk, bshift) - int ctlr, slave, unit; - u_char *buf; - u_int len; - daddr_t blk; - int bshift; -{ - register struct scsi_softc *dev = &scsi_softc[ctlr]; - struct scsi_cdb10 cdb; - int stat; - int old_wait = scsi_data_wait; - - scsi_data_wait = 300000; - bzero(&cdb, sizeof(cdb)); - cdb.cmd = CMD_READ_EXT; - cdb.lun = unit; - blk >>= bshift; - cdb.lbah = blk >> 24; - cdb.lbahm = blk >> 16; - cdb.lbalm = blk >> 8; - cdb.lbal = blk; - cdb.lenh = len >> (8 + DEV_BSHIFT + bshift); - cdb.lenl = len >> (DEV_BSHIFT + bshift); - stat = scsiicmd(dev, slave, (u_char *) &cdb, sizeof(cdb), buf, len, DATA_IN_PHASE); - scsi_data_wait = old_wait; - return (stat); -} - -int -scsi_tt_write(ctlr, slave, unit, buf, len, blk, bshift) - int ctlr, slave, unit; - u_char *buf; - u_int len; - daddr_t blk; - int bshift; -{ - register struct scsi_softc *dev = &scsi_softc[ctlr]; - struct scsi_cdb10 cdb; - int stat; - int old_wait = scsi_data_wait; - - scsi_data_wait = 300000; - - bzero(&cdb, sizeof(cdb)); - cdb.cmd = CMD_WRITE_EXT; - cdb.lun = unit; - blk >>= bshift; - cdb.lbah = blk >> 24; - cdb.lbahm = blk >> 16; - cdb.lbalm = blk >> 8; - cdb.lbal = blk; - cdb.lenh = len >> (8 + DEV_BSHIFT + bshift); - cdb.lenl = len >> (DEV_BSHIFT + bshift); - stat = scsiicmd(dev, slave, (u_char *) &cdb, sizeof(cdb), buf, len, DATA_OUT_PHASE); - scsi_data_wait = old_wait; - return (stat); -} - -int -scsireq(dq) - register struct devqueue *dq; -{ - register struct devqueue *hq; - - hq = &scsi_softc[dq->dq_ctlr].sc_sq; - insque(dq, hq->dq_back); - if (dq->dq_back == hq) - return(1); - return(0); -} - -int -scsiustart (int unit) -{ - register struct scsi_softc *dev = &scsi_softc[unit]; - - /* If we got here, this controller is not busy - Since each controller has it's own DMA, we don't - need to queue up DMA requests, so we are ready to - accept a comment - */ - return(1); -} - -void -scsistart (int unit) -{ - register struct devqueue *dq; - - dq = scsi_softc[unit].sc_sq.dq_forw; - (dq->dq_driver->d_go)(dq->dq_unit); -} - -int -scsigo(ctlr, slave, unit, bp, cdb, pad) - int ctlr, slave, unit; - struct buf *bp; - struct scsi_fmt_cdb *cdb; - int pad; -{ - register struct scsi_softc *dev = &scsi_softc[ctlr]; - volatile register sbic_padded_regmap_t *regs = - (sbic_padded_regmap_t *)dev->sc_ac->amiga_addr; - int i, dmaflags; - u_char phase, csr, asr, cmd; - char *addr; - int count; - register struct dma_chain *dcp; - register char *dmaend = NULL; - register int tcount; - - cdb->cdb[1] |= unit << 5; - - addr = bp->b_un.b_addr; - count = bp->b_bcount; - - /* this should only happen on character devices, and there only if user - programs have not been written taking care of not passing odd aligned - buffers. dd was a bad example of this sin.. */ - -/* XXXX do all with polled I/O */ - - if (scsi_no_dma || (((int)addr & 3) || (count & 1)) - || (dev->sc_flags & SCSI_DMA24 && check_dma_buf (addr, count, dev->dmamask) - && dev->dmabuffer == NULL)) - { - register struct devqueue *dq; - - dev->dmafree(dev); - - /* in this case do the transfer with programmed I/O :-( This is - probably still faster than doing the transfer with DMA into a - buffer and copying it later to its final destination, comments? */ - scsiicmd (dev, slave, (u_char *) cdb->cdb, cdb->len, - addr, count, - bp->b_flags & B_READ ? DATA_IN_PHASE : DATA_OUT_PHASE); - - dq = dev->sc_sq.dq_forw; - dev->sc_flags &=~ (SCSI_IO | SCSI_READ24); - (dq->dq_driver->d_intr)(dq->dq_unit, dev->sc_stat[0]); - return dev->sc_stat[0]; - } - - /* set the sbic into DMA mode */ - SET_SBIC_control (regs, (/*SBIC_CTL_HHP |*/ SBIC_CTL_EDI | SBIC_CTL_IDI | - /* | SBIC_CTL_HSP | */ SBIC_MACHINE_DMA_MODE)); - - /* select the SCSI bus (it's an error if bus isn't free) */ - if (issue_select(dev, regs, slave, dev->sc_scsi_addr) || wait_for_select(dev, regs)) - { - dev->dmafree(dev); - return (1); - } - /* - * Wait for a phase change (or error) then let the device - * sequence us through command phase (we may have to take - * a msg in/out before doing the command). If the disk has - * to do a seek, it may be a long time until we get a change - * to data phase so, in the absense of an explicit phase - * change, we assume data phase will be coming up and tell - * the SPC to start a transfer whenever it does. We'll get - * a service required interrupt later if this assumption is - * wrong. Otherwise we'll get a service required int when - * the transfer changes to status phase. - */ - phase = CMD_PHASE; - while (1) - { - register int wait = scsi_cmd_wait; - register struct devqueue *dq; - - switch (phase) - { - case CMD_PHASE: - if (ixfer_start(regs, cdb->len, phase, wait)) - if (ixfer_out(regs, cdb->len, cdb->cdb, phase)) - goto abort; - break; - - case MESG_IN_PHASE: - if (ixfer_start (regs, sizeof (dev->sc_msg), phase, wait)) - { - ixfer_in (regs, sizeof (dev->sc_msg), dev->sc_msg); - /* prepare to reject any mesgin, no matter what it might be.. */ - SET_SBIC_cmd (regs, SBIC_CMD_SET_ATN); - WAIT_CIP (regs); - SET_SBIC_cmd (regs, SBIC_CMD_CLR_ACK); - phase = MESG_OUT_PHASE; - } - break; - - case MESG_OUT_PHASE: - SEND_BYTE (regs, MSG_REJECT); - phase = STATUS_PHASE; - break; - - case DATA_IN_PHASE: - case DATA_OUT_PHASE: - goto out; - - /* status phase can happen, if the issued read/write command is - illegal (for example, reading after EOT on tape) and the device - doesn't even go to data in/out phase. So handle this here - normally, instead of going thru abort-handling. */ - case STATUS_PHASE: - dev->dmafree(dev); - finishxfer (dev, regs, slave); - dq = dev->sc_sq.dq_forw; - dev->sc_flags &=~ (SCSI_IO | SCSI_READ24); - (dq->dq_driver->d_intr)(dq->dq_unit, dev->sc_stat[0]); - return 0; - - default: - printf("scsi: unexpected phase %d in go from %d\n", - phase, slave); - goto abort; - } - - /* make sure the last command was taken, ie. we're not hunting after - an ignored command.. */ - GET_SBIC_asr (regs, asr); - if (asr & SBIC_ASR_LCI) - goto abort; - - /* tapes may take a loooong time.. */ - while (asr & SBIC_ASR_BSY) - { - DELAY(1); - GET_SBIC_asr (regs, asr); - } - - if (wait <= 0) - goto abort; - - /* wait for last command to complete */ - SBIC_WAIT (regs, SBIC_ASR_INT, wait); - - GET_SBIC_csr (regs, csr); - QPRINTF((">CSR:%02x<", csr)); - - HIST(sgo_wait, wait); - if ((csr != 0xff) && (csr & 0xf0) && (csr & 0x08)) /* requesting some new phase */ - phase = csr & PHASE; - else - { - scsierror(dev, regs, csr); - goto abort; - } - } - -out: - dmaflags = 0; - if (bp->b_flags & B_READ) - dmaflags |= DMAGO_READ; - if ((int)addr & 3) - panic ("not long-aligned buffer address in scsi_go"); - if (count & 1) - panic ("odd transfer count in scsi_go"); - if (count > MAXPHYS) - printf ("scsigo: bp->b_bcount > MAXPHYS %08x\n", count); - if (dev->sc_flags & SCSI_DMA24 && check_dma_buf (addr, count, dev->dmamask)) { - if (dmaflags & DMAGO_READ) { - dev->sc_flags |= SCSI_READ24; /* need to copy after read */ - dev->dmausrbuf = addr; /* save address */ - dev->dmausrlen = count; /* and length */ - } - else { /* write: copy to dma buffer */ - bcopy (addr, dev->dmabuffer, count); - } - addr = dev->dmabuffer; /* and use dma buffer */ - } - -#ifdef DEBUG - if (scsi_dma_debug & DDB_FOLLOW) - printf("dmago(%d, %x, %x, %x)\n", ctlr, addr, count, dmaflags); -#endif - /* - * Build the DMA chain - */ - for (dcp = dev->sc_chain; count > 0; dcp++) - { -#ifdef DEBUG - if (! pmap_extract(pmap_kernel(), (vm_offset_t)addr)) - panic ("dmago: no physical page for address!"); -#endif - - dcp->dc_addr = (char *) kvtop(addr); - if (count < (tcount = NBPG - ((int)addr & PGOFSET))) - tcount = count; - dcp->dc_count = tcount; - addr += tcount; - count -= tcount; - tcount >>= 1; /* number of words (the sdmac wants 16bit values here) */ - if (dcp->dc_addr == dmaend) - { -#ifdef DEBUG - dmahits[ctlr]++; -#endif - dmaend += dcp->dc_count; - (--dcp)->dc_count += tcount; - } - else - { -#ifdef DEBUG - dmamisses[ctlr]++; -#endif - dmaend = dcp->dc_addr + dcp->dc_count; - dcp->dc_count = tcount; - } - } - - dev->sc_cur = dev->sc_chain; - dev->sc_last = --dcp; - dev->sc_tc = dev->sc_cur->dc_count << 1; - -#ifdef DEBUG - if (scsi_dma_debug & DDB_IO) - { - for (dcp = dev->sc_chain; dcp <= dev->sc_last; dcp++) - printf(" %d: %d@%x\n", dcp-dev->sc_chain, - dcp->dc_count, dcp->dc_addr); - } -#endif - - DCIS(); /* push data cache */ - - /* dmago() also enables interrupts for the sbic */ - i = dev->dmago(dev, addr, bp->b_bcount, dmaflags); - - SBIC_TC_PUT (regs, (unsigned)i); - SET_SBIC_cmd (regs, SBIC_CMD_XFER_INFO); - - return (0); - -abort: - scsiabort(dev, regs, "go"); - dev->dmafree(dev); - return (1); -} - -void -scsidone (int unit) -{ - volatile register sbic_padded_regmap_t *regs = - (sbic_padded_regmap_t *)scsi_softc[unit].sc_ac->amiga_addr; - -#ifdef DEBUG - if (scsi_debug) - printf("scsi%d: done called!\n", unit); -#endif -} - -int -scsiintr (int unit) -{ - register struct scsi_softc *dev = &scsi_softc[unit]; - volatile register sbic_padded_regmap_t *regs = - (sbic_padded_regmap_t *)dev->sc_ac->amiga_addr; - register u_char asr, csr, phase; - register struct devqueue *dq; - int i; - - GET_SBIC_asr (regs, asr); - if (! (asr & SBIC_ASR_INT)) - return 0; - - GET_SBIC_csr (regs, csr); -QPRINTF(("[0x%x]", csr)); - - if (csr == (SBIC_CSR_XFERRED|STATUS_PHASE) - || csr == (SBIC_CSR_MIS|STATUS_PHASE) - || csr == (SBIC_CSR_MIS_1|STATUS_PHASE) - || csr == (SBIC_CSR_MIS_2|STATUS_PHASE)) - { - /* - * this should be the normal i/o completion case. - * get the status & cmd complete msg then let the - * device driver look at what happened. - */ - dq = dev->sc_sq.dq_forw; - finishxfer(dev, regs, dq->dq_slave); - if (dev->sc_flags & SCSI_READ24) - bcopy (dev->dmabuffer, dev->dmausrbuf, dev->dmausrlen); - dev->sc_flags &=~ (SCSI_IO | SCSI_READ24); - dev->dmafree (dev); - (dq->dq_driver->d_intr)(dq->dq_unit, dev->sc_stat[0]); - } - else if (csr == (SBIC_CSR_XFERRED|DATA_OUT_PHASE) || csr == (SBIC_CSR_XFERRED|DATA_IN_PHASE) - || csr == (SBIC_CSR_MIS|DATA_OUT_PHASE) || csr == (SBIC_CSR_MIS|DATA_IN_PHASE) - || csr == (SBIC_CSR_MIS_1|DATA_OUT_PHASE) || csr == (SBIC_CSR_MIS_1|DATA_IN_PHASE) - || csr == (SBIC_CSR_MIS_2|DATA_OUT_PHASE) || csr == (SBIC_CSR_MIS_2|DATA_IN_PHASE)) - { - /* do scatter-gather dma hacking the controller chip, ouch.. */ -#ifdef DEBUG - if (scsi_dma_debug & DDB_IO) - { - printf("dmanext(%d): next %d\n", unit, (dev->sc_cur-dev->sc_chain)+1); - } -#endif - dev->sc_cur->dc_addr += dev->sc_tc; /* next dma address */ - dev->sc_cur->dc_count -= (dev->sc_tc >> 1); /* decrement count */ - if (dev->sc_cur->dc_count == 0) - ++dev->sc_cur; /* advance to next segment */ - i = dev->dmanext (dev); - SBIC_TC_PUT (regs, (unsigned)i); - SET_SBIC_cmd (regs, SBIC_CMD_XFER_INFO); - } - else - { - /* Something unexpected happened -- deal with it. */ - dev->dmastop (dev); - scsierror(dev, regs, csr); - scsiabort(dev, regs, "intr"); - if (dev->sc_flags & SCSI_IO) - { - dev->sc_flags &=~ (SCSI_IO| SCSI_READ24); - dev->dmafree (dev); - dq = dev->sc_sq.dq_forw; - (dq->dq_driver->d_intr)(dq->dq_unit, -1); - } - } - - return 1; -} - -void -scsifree(dq) - register struct devqueue *dq; -{ - register struct devqueue *hq; - - hq = &scsi_softc[dq->dq_ctlr].sc_sq; - remque(dq); - if ((dq = hq->dq_forw) != hq) - (dq->dq_driver->d_start)(dq->dq_unit); -} - -/* - * Check if DMA can not be used with specified buffer - */ - -static int -check_dma_buf (char *buffer, u_long len, u_long mask) -{ - u_long phy_buf; - u_long phy_len; - - if (len == 0) - return (0); - while (len) { - phy_buf = kvtop(buffer); - if (len < (phy_len = NBPG - ((int) buffer & PGOFSET))) - phy_len = len; - if (phy_buf & mask) - return (1); /* can't use DMA here */ - buffer += phy_len; - len -= phy_len; - } - return (0); /* DMA is ok */ -} - -/* - * (XXX) The following routine is needed for the SCSI tape driver - * to read odd-size records. - */ - -#if NST > 0 -int -scsi_tt_oddio(ctlr, slave, unit, buf, len, b_flags, freedma) - int ctlr, slave, unit, b_flags; - u_char *buf; - u_int len; -{ - register struct scsi_softc *dev = &scsi_softc[ctlr]; - struct scsi_cdb6 cdb; - u_char iphase; - int stat; - - /* - * First free any DMA channel that was allocated. - * We can't use DMA to do this transfer. - */ - if (freedma) - dev->dmafree(dev); - /* - * Initialize command block - */ - bzero(&cdb, sizeof(cdb)); - cdb.lun = unit; - cdb.lbam = (len >> 16) & 0xff; - cdb.lbal = (len >> 8) & 0xff; - cdb.len = len & 0xff; - if (buf == 0) { - cdb.cmd = CMD_SPACE; - cdb.lun |= 0x00; - len = 0; - iphase = MESG_IN_PHASE; - } else if (b_flags & B_READ) { - cdb.cmd = CMD_READ; - iphase = DATA_IN_PHASE; - } else { - cdb.cmd = CMD_WRITE; - iphase = DATA_OUT_PHASE; - } - /* - * Perform command (with very long delays) - */ - scsi_delay(30000000); - stat = scsiicmd(dev, slave, (u_char *) &cdb, sizeof(cdb), buf, len, iphase); - scsi_delay(0); - return (stat); -} -#endif -#endif diff --git a/sys/arch/amiga/dev/scsireg.h b/sys/arch/amiga/dev/scsireg.h deleted file mode 100644 index ce16fd0de02b..000000000000 --- a/sys/arch/amiga/dev/scsireg.h +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Van Jacobson of Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)scsireg.h 7.3 (Berkeley) 2/5/91 - * $Id: scsireg.h,v 1.7 1994/02/11 07:02:11 chopps Exp $ - */ - -/* - * AMD AM33C93A SCSI interface hardware description. - * - * Using parts of the Mach scsi driver for the 33C93 - */ - -#define SBIC_myid 0 -#define SBIC_cdbsize 0 -#define SBIC_control 1 -#define SBIC_timeo 2 -#define SBIC_cdb1 3 -#define SBIC_tsecs 3 -#define SBIC_cdb2 4 -#define SBIC_theads 4 -#define SBIC_cdb3 5 -#define SBIC_tcyl_hi 5 -#define SBIC_cdb4 6 -#define SBIC_tcyl_lo 6 -#define SBIC_cdb5 7 -#define SBIC_addr_hi 7 -#define SBIC_cdb6 8 -#define SBIC_addr_2 8 -#define SBIC_cdb7 9 -#define SBIC_addr_3 9 -#define SBIC_cdb8 10 -#define SBIC_addr_lo 10 -#define SBIC_cdb9 11 -#define SBIC_secno 11 -#define SBIC_cdb10 12 -#define SBIC_headno 12 -#define SBIC_cdb11 13 -#define SBIC_cylno_hi 13 -#define SBIC_cdb12 14 -#define SBIC_cylno_lo 14 -#define SBIC_tlun 15 -#define SBIC_cmd_phase 16 -#define SBIC_syn 17 -#define SBIC_count_hi 18 -#define SBIC_count_med 19 -#define SBIC_count_lo 20 -#define SBIC_selid 21 -#define SBIC_rselid 22 -#define SBIC_csr 23 -#define SBIC_cmd 24 -#define SBIC_data 25 -/* sbic_asr is addressed directly */ - -/* - * Register defines - */ - -/* - * Auxiliary Status Register - */ - -#define SBIC_ASR_INT 0x80 /* Interrupt pending */ -#define SBIC_ASR_LCI 0x40 /* Last command ignored */ -#define SBIC_ASR_BSY 0x20 /* Busy, only cmd/data/asr readable */ -#define SBIC_ASR_CIP 0x10 /* Busy, cmd unavail also */ -#define SBIC_ASR_xxx 0x0c -#define SBIC_ASR_PE 0x02 /* Parity error (even) */ -#define SBIC_ASR_DBR 0x01 /* Data Buffer Ready */ - -/* - * My ID register, and/or CDB Size - */ - -#define SBIC_ID_FS_8_10 0x00 /* Input clock is 8-10 Mhz */ - /* 11 Mhz is invalid */ -#define SBIC_ID_FS_12_15 0x40 /* Input clock is 12-15 Mhz */ -#define SBIC_ID_FS_16_20 0x80 /* Input clock is 16-20 Mhz */ -#define SBIC_ID_EHP 0x10 /* Enable host parity */ -#define SBIC_ID_EAF 0x08 /* Enable Advanced Features */ -#define SBIC_ID_MASK 0x07 -#define SBIC_ID_CBDSIZE_MASK 0x0f /* if unk SCSI cmd group */ - -/* - * Control register - */ - -#define SBIC_CTL_DMA 0x80 /* Single byte dma */ -#define SBIC_CTL_DBA_DMA 0x40 /* direct buffer acces (bus master)*/ -#define SBIC_CTL_BURST_DMA 0x20 /* continuous mode (8237) */ -#define SBIC_CTL_NO_DMA 0x00 /* Programmed I/O */ -#define SBIC_CTL_HHP 0x10 /* Halt on host parity error */ -#define SBIC_CTL_EDI 0x08 /* Ending disconnect interrupt */ -#define SBIC_CTL_IDI 0x04 /* Intermediate disconnect interrupt*/ -#define SBIC_CTL_HA 0x02 /* Halt on ATN */ -#define SBIC_CTL_HSP 0x01 /* Halt on SCSI parity error */ - -/* - * Timeout period register - * [val in msecs, input clk in 0.1 Mhz] - */ - -#define SBIC_TIMEOUT(val,clk) ((((val)*(clk))/800)+1) - -/* - * CDBn registers, note that - * cdb11 is used for status byte in target mode (send-status-and-cc) - * cdb12 sez if linked command complete, and w/flag if so - */ - -/* - * Target LUN register - * [holds target status when select-and-xfer] - */ - -#define SBIC_TLUN_VALID 0x80 /* did we receive an Identify msg */ -#define SBIC_TLUN_DOK 0x40 /* Disconnect OK */ -#define SBIC_TLUN_xxx 0x38 -#define SBIC_TLUN_MASK 0x07 - -/* - * Command Phase register - */ - -#define SBIC_CPH_MASK 0x7f /* values/restarts are cmd specific */ -#define SBIC_CPH(p) ((p)&SBIC_CPH_MASK) - -/* - * FIFO register - */ - -#define SBIC_FIFO_DEEP 12 - -/* - * maximum possible size in TC registers. Since this is 24 bit, it's easy - */ -#define SBIC_TC_MAX ((1<<24) - 1) - -/* - * Synchronous xfer register - */ - -#define SBIC_SYN_OFF_MASK 0x0f -#define SBIC_SYN_MAX_OFFSET SBIC_FIFO_DEEP -#define SBIC_SYN_PER_MASK 0x70 -#define SBIC_SYN_MIN_PERIOD 2 /* upto 8, encoded as 0 */ - -#define SBIC_SYN(o,p) (((o)&SBIC_SYN_OFF_MASK)|(((p)<<4)&SBIC_SYN_PER_MASK)) - -/* - * Transfer count register - * optimal access macros depend on addressing - */ - -/* - * Destination ID (selid) register - */ - -#define SBIC_SID_SCC 0x80 /* Select command chaining (tgt) */ -#define SBIC_SID_DPD 0x40 /* Data phase direction (inittor) */ -# define SBIC_SID_FROM_SCSI 0x40 -# define SBIC_SID_TO_SCSI 0x00 -#define SBIC_SID_xxx 0x38 -#define SBIC_SID_IDMASK 0x07 - -/* - * Source ID (rselid) register - */ - -#define SBIC_RID_ER 0x80 /* Enable reselection */ -#define SBIC_RID_ES 0x40 /* Enable selection */ -#define SBIC_RID_DSP 0x20 /* Disable select parity */ -#define SBIC_RID_SIV 0x08 /* Source ID valid */ -#define SBIC_RID_MASK 0x07 - -/* - * Status register - */ - -#define SBIC_CSR_CAUSE 0xf0 -# define SBIC_CSR_RESET 0x00 /* chip was reset */ -# define SBIC_CSR_CMD_DONE 0x10 /* cmd completed */ -# define SBIC_CSR_CMD_STOPPED 0x20 /* interrupted or abrted*/ -# define SBIC_CSR_CMD_ERR 0x40 /* end with error */ -# define SBIC_CSR_BUS_SERVICE 0x80 /* REQ pending on the bus */ - -#define SBIC_CSR_QUALIFIER 0x0f - - /* Reset State Interrupts */ -# define SBIC_CSR_RESET 0x00 /* reset w/advanced features*/ -# define SBIC_CSR_RESET_AM 0x01 /* reset w/advanced features*/ - - /* Successful Completion Interrupts */ -# define SBIC_CSR_TARGET 0x10 /* reselect complete */ -# define SBIC_CSR_INITIATOR 0x11 /* select complete */ -# define SBIC_CSR_WO_ATN 0x13 /* tgt mode completion */ -# define SBIC_CSR_W_ATN 0x14 /* ditto */ -# define SBIC_CSR_XLATED 0x15 /* translate address cmd */ -# define SBIC_CSR_S_XFERRED 0x16 /* initiator mode completion*/ -# define SBIC_CSR_XFERRED 0x18 /* phase in low bits */ - - /* Paused or Aborted Interrupts */ -# define SBIC_CSR_MSGIN_W_ACK 0x20 /* (I) msgin, ACK asserted*/ -# define SBIC_CSR_SDP 0x21 /* (I) SDP msg received */ -# define SBIC_CSR_SEL_ABRT 0x22 /* sel/resel aborted */ -# define SBIC_CSR_XFR_PAUSED 0x23 /* (T) no ATN */ -# define SBIC_CSR_XFR_PAUSED_ATN 0x24 /* (T) ATN is asserted */ -# define SBIC_CSR_RSLT_AM 0x27 /* (I) lost selection (AM) */ -# define SBIC_CSR_MIS 0x28 /* (I) xfer aborted, ph mis */ - - /* Terminated Interrupts */ -# define SBIC_CSR_CMD_INVALID 0x40 -# define SBIC_CSR_DISC 0x41 /* (I) tgt disconnected */ -# define SBIC_CSR_SEL_TIMEO 0x42 -# define SBIC_CSR_PE 0x43 /* parity error */ -# define SBIC_CSR_PE_ATN 0x44 /* ditto, ATN is asserted */ -# define SBIC_CSR_XLATE_TOOBIG 0x45 -# define SBIC_CSR_RSLT_NOAM 0x46 /* (I) lost sel, no AM mode */ -# define SBIC_CSR_BAD_STATUS 0x47 /* status byte was nok */ -# define SBIC_CSR_MIS_1 0x48 /* ph mis, see low bits */ - - /* Service Required Interrupts */ -# define SBIC_CSR_RSLT_NI 0x80 /* reselected, no ify msg */ -# define SBIC_CSR_RSLT_IFY 0x81 /* ditto, AM mode, got ify */ -# define SBIC_CSR_SLT 0x82 /* selected, no ATN */ -# define SBIC_CSR_SLT_ATN 0x83 /* selected with ATN */ -# define SBIC_CSR_ATN 0x84 /* (T) ATN asserted */ -# define SBIC_CSR_DISC_1 0x85 /* (I) bus is free */ -# define SBIC_CSR_UNK_GROUP 0x87 /* strange CDB1 */ -# define SBIC_CSR_MIS_2 0x88 /* (I) ph mis, see low bits */ - -#define SBIC_PHASE(csr) SCSI_PHASE(csr) - -/* - * Command register (command codes) - */ - -#define SBIC_CMD_SBT 0x80 /* Single byte xfer qualifier */ -#define SBIC_CMD_MASK 0x7f - - /* Miscellaneous */ -#define SBIC_CMD_RESET 0x00 /* (DTI) lev I */ -#define SBIC_CMD_ABORT 0x01 /* (DTI) lev I */ -#define SBIC_CMD_DISC 0x04 /* ( TI) lev I */ -#define SBIC_CMD_SSCC 0x0d /* ( TI) lev I */ -#define SBIC_CMD_SET_IDI 0x0f /* (DTI) lev I */ -#define SBIC_CMD_XLATE 0x18 /* (DT ) lev II */ - - /* Initiator state */ -#define SBIC_CMD_SET_ATN 0x02 /* ( I) lev I */ -#define SBIC_CMD_CLR_ACK 0x03 /* ( I) lev I */ -#define SBIC_CMD_XFER_PAD 0x19 /* ( I) lev II */ -#define SBIC_CMD_XFER_INFO 0x20 /* ( I) lev II */ - - /* Target state */ -#define SBIC_CMD_SND_DISC 0x0e /* ( T ) lev II */ -#define SBIC_CMD_RCV_CMD 0x10 /* ( T ) lev II */ -#define SBIC_CMD_RCV_DATA 0x11 /* ( T ) lev II */ -#define SBIC_CMD_RCV_MSG_OUT 0x12 /* ( T ) lev II */ -#define SBIC_CMD_RCV 0x13 /* ( T ) lev II */ -#define SBIC_CMD_SND_STATUS 0x14 /* ( T ) lev II */ -#define SBIC_CMD_SND_DATA 0x15 /* ( T ) lev II */ -#define SBIC_CMD_SND_MSG_IN 0x16 /* ( T ) lev II */ -#define SBIC_CMD_SND 0x17 /* ( T ) lev II */ - - /* Disconnected state */ -#define SBIC_CMD_RESELECT 0x05 /* (D ) lev II */ -#define SBIC_CMD_SEL_ATN 0x06 /* (D ) lev II */ -#define SBIC_CMD_SEL 0x07 /* (D ) lev II */ -#define SBIC_CMD_SEL_ATN_XFER 0x08 /* (D I) lev II */ -#define SBIC_CMD_SEL_XFER 0x09 /* (D I) lev II */ -#define SBIC_CMD_RESELECT_RECV 0x0a /* (DT ) lev II */ -#define SBIC_CMD_RESELECT_SEND 0x0b /* (DT ) lev II */ -#define SBIC_CMD_WAIT_SEL_RECV 0x0c /* (DT ) lev II */ - -/* approximate, but we won't do SBT on selects */ -#define sbic_isa_select(cmd) (((cmd)>0x5)&&((cmd)<0xa)) - -#define PAD(n) char n; -#define SBIC_MACHINE_DMA_MODE SBIC_CTL_DMA - -typedef struct { - volatile unsigned char sbic_asr; /* r : Aux Status Register */ -#define sbic_address sbic_asr /* w : desired register no */ - PAD(pad1); - volatile unsigned char sbic_value; /* rw: register value */ -} sbic_padded_ind_regmap_t; - - -typedef sbic_padded_ind_regmap_t sbic_padded_regmap_t; - -#define sbic_read_reg(regs,regno,val) do { \ - (regs)->sbic_address = (regno); \ - (val) = (regs)->sbic_value; \ - } while (0) - -#define sbic_write_reg(regs,regno,val) do { \ - (regs)->sbic_address = (regno); \ - (regs)->sbic_value = (val); \ - } while (0) - -#define SET_SBIC_myid(regs,val) sbic_write_reg(regs,SBIC_myid,val) -#define GET_SBIC_myid(regs,val) sbic_read_reg(regs,SBIC_myid,val) -#define SET_SBIC_cdbsize(regs,val) sbic_write_reg(regs,SBIC_cdbsize,val) -#define GET_SBIC_cdbsize(regs,val) sbic_read_reg(regs,SBIC_cdbsize,val) -#define SET_SBIC_control(regs,val) sbic_write_reg(regs,SBIC_control,val) -#define GET_SBIC_control(regs,val) sbic_read_reg(regs,SBIC_control,val) -#define SET_SBIC_timeo(regs,val) sbic_write_reg(regs,SBIC_timeo,val) -#define GET_SBIC_timeo(regs,val) sbic_read_reg(regs,SBIC_timeo,val) -#define SET_SBIC_cdb1(regs,val) sbic_write_reg(regs,SBIC_cdb1,val) -#define GET_SBIC_cdb1(regs,val) sbic_read_reg(regs,SBIC_cdb1,val) -#define SET_SBIC_cdb2(regs,val) sbic_write_reg(regs,SBIC_cdb2,val) -#define GET_SBIC_cdb2(regs,val) sbic_read_reg(regs,SBIC_cdb2,val) -#define SET_SBIC_cdb3(regs,val) sbic_write_reg(regs,SBIC_cdb3,val) -#define GET_SBIC_cdb3(regs,val) sbic_read_reg(regs,SBIC_cdb3,val) -#define SET_SBIC_cdb4(regs,val) sbic_write_reg(regs,SBIC_cdb4,val) -#define GET_SBIC_cdb4(regs,val) sbic_read_reg(regs,SBIC_cdb4,val) -#define SET_SBIC_cdb5(regs,val) sbic_write_reg(regs,SBIC_cdb5,val) -#define GET_SBIC_cdb5(regs,val) sbic_read_reg(regs,SBIC_cdb5,val) -#define SET_SBIC_cdb6(regs,val) sbic_write_reg(regs,SBIC_cdb6,val) -#define GET_SBIC_cdb6(regs,val) sbic_read_reg(regs,SBIC_cdb6,val) -#define SET_SBIC_cdb7(regs,val) sbic_write_reg(regs,SBIC_cdb7,val) -#define GET_SBIC_cdb7(regs,val) sbic_read_reg(regs,SBIC_cdb7,val) -#define SET_SBIC_cdb8(regs,val) sbic_write_reg(regs,SBIC_cdb8,val) -#define GET_SBIC_cdb8(regs,val) sbic_read_reg(regs,SBIC_cdb8,val) -#define SET_SBIC_cdb9(regs,val) sbic_write_reg(regs,SBIC_cdb9,val) -#define GET_SBIC_cdb9(regs,val) sbic_read_reg(regs,SBIC_cdb9,val) -#define SET_SBIC_cdb10(regs,val) sbic_write_reg(regs,SBIC_cdb10,val) -#define GET_SBIC_cdb10(regs,val) sbic_read_reg(regs,SBIC_cdb10,val) -#define SET_SBIC_cdb11(regs,val) sbic_write_reg(regs,SBIC_cdb11,val) -#define GET_SBIC_cdb11(regs,val) sbic_read_reg(regs,SBIC_cdb11,val) -#define SET_SBIC_cdb12(regs,val) sbic_write_reg(regs,SBIC_cdb12,val) -#define GET_SBIC_cdb12(regs,val) sbic_read_reg(regs,SBIC_cdb12,val) -#define SET_SBIC_tlun(regs,val) sbic_write_reg(regs,SBIC_tlun,val) -#define GET_SBIC_tlun(regs,val) sbic_read_reg(regs,SBIC_tlun,val) -#define SET_SBIC_cmd_phase(regs,val) sbic_write_reg(regs,SBIC_cmd_phase,val) -#define GET_SBIC_cmd_phase(regs,val) sbic_read_reg(regs,SBIC_cmd_phase,val) -#define SET_SBIC_syn(regs,val) sbic_write_reg(regs,SBIC_syn,val) -#define GET_SBIC_syn(regs,val) sbic_read_reg(regs,SBIC_syn,val) -#define SET_SBIC_count_hi(regs,val) sbic_write_reg(regs,SBIC_count_hi,val) -#define GET_SBIC_count_hi(regs,val) sbic_read_reg(regs,SBIC_count_hi,val) -#define SET_SBIC_count_med(regs,val) sbic_write_reg(regs,SBIC_count_med,val) -#define GET_SBIC_count_med(regs,val) sbic_read_reg(regs,SBIC_count_med,val) -#define SET_SBIC_count_lo(regs,val) sbic_write_reg(regs,SBIC_count_lo,val) -#define GET_SBIC_count_lo(regs,val) sbic_read_reg(regs,SBIC_count_lo,val) -#define SET_SBIC_selid(regs,val) sbic_write_reg(regs,SBIC_selid,val) -#define GET_SBIC_selid(regs,val) sbic_read_reg(regs,SBIC_selid,val) -#define SET_SBIC_rselid(regs,val) sbic_write_reg(regs,SBIC_rselid,val) -#define GET_SBIC_rselid(regs,val) sbic_read_reg(regs,SBIC_rselid,val) -#define SET_SBIC_csr(regs,val) sbic_write_reg(regs,SBIC_csr,val) -#define GET_SBIC_csr(regs,val) sbic_read_reg(regs,SBIC_csr,val) -#define SET_SBIC_cmd(regs,val) sbic_write_reg(regs,SBIC_cmd,val) -#define GET_SBIC_cmd(regs,val) sbic_read_reg(regs,SBIC_cmd,val) -#define SET_SBIC_data(regs,val) sbic_write_reg(regs,SBIC_data,val) -#define GET_SBIC_data(regs,val) sbic_read_reg(regs,SBIC_data,val) - -#define SBIC_TC_PUT(regs,val) { \ - sbic_write_reg(regs,SBIC_count_hi,((val)>>16)); \ - (regs)->sbic_value = (val)>>8; \ - (regs)->sbic_value = (val); \ - } -#define SBIC_TC_GET(regs,val) { \ - sbic_read_reg(regs,SBIC_count_hi,(val)); \ - (val) = ((val)<<8) | (regs)->sbic_value; \ - (val) = ((val)<<8) | (regs)->sbic_value; \ - } - -#define SBIC_LOAD_COMMAND(regs,cmd,cmdsize) { \ - register int n=cmdsize-1; \ - register char *ptr = (char*)(cmd); \ - sbic_write_reg(regs,SBIC_cdb1,*ptr++); \ - while (n-- > 0) (regs)->sbic_value = *ptr++; \ - } - -#define GET_SBIC_asr(regs,val) (val) = (regs)->sbic_asr - -#define WAIT_CIP(regs) do ; while ((regs)->sbic_asr & SBIC_ASR_CIP) - -/* transmit a byte in programmed I/O mode */ -#define SEND_BYTE(regs, ch) \ - WAIT_CIP (regs); \ - SET_SBIC_cmd (regs, SBIC_CMD_SBT | SBIC_CMD_XFER_INFO); \ - SBIC_WAIT (regs, SBIC_ASR_DBR, 0); \ - SET_SBIC_data (regs, ch); - -/* receive a byte in programmed I/O mode */ -#define RECV_BYTE(regs, ch) \ - WAIT_CIP (regs); \ - SET_SBIC_cmd (regs, SBIC_CMD_SBT | SBIC_CMD_XFER_INFO); \ - SBIC_WAIT (regs, SBIC_ASR_DBR, 0); \ - GET_SBIC_data (regs, ch); diff --git a/sys/arch/amiga/dev/scsivar.h b/sys/arch/amiga/dev/scsivar.h deleted file mode 100644 index aa15b24fd9ee..000000000000 --- a/sys/arch/amiga/dev/scsivar.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Van Jacobson of Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)scsivar.h 7.1 (Berkeley) 5/8/90 - * $Id: scsivar.h,v 1.8 1994/02/28 06:06:29 chopps Exp $ - */ - -/* - * The largest single request will be MAXPHYS bytes which will require - * at most MAXPHYS/NBPG+1 chain elements to describe, i.e. if none of - * the buffer pages are physically contiguous (MAXPHYS/NBPG) and the - * buffer is not page aligned (+1). - */ -#define DMAMAXIO (MAXPHYS/NBPG+1) - -struct dma_chain { - int dc_count; - char *dc_addr; -}; - -struct scsi_softc { - struct amiga_ctlr *sc_ac; - struct devqueue sc_dq; - struct devqueue sc_sq; - dmafree_t dmafree; - dmago_t dmago; - dmanext_t dmanext; - dmastop_t dmastop; - char *dmabuffer; - char *dmausrbuf; - u_long dmausrlen; - u_long dmamask; - u_short bankmask; - u_char sc_flags; - u_long sc_clock_freq; - /* one for each target */ - struct syncpar { - u_char state; - u_char period, offset; - } sc_sync[8]; - u_char sc_scsi_addr; - u_char sc_stat[2]; - u_char sc_msg[7]; - void *sc_hwaddr; /* pointer to controller-specific DMA registers */ - u_short dmatimo; - u_short sc_cmd; - int sc_tc; - struct dma_chain *sc_cur; - struct dma_chain *sc_last; - struct dma_chain sc_chain[DMAMAXIO]; -}; - -/* sc_flags */ -#define SCSI_IO 0x80 /* DMA I/O in progress */ -#define SCSI_ALIVE 0x01 /* controller initialized */ -#ifdef DEBUG -#define SCSI_PAD 0x02 /* 'padded' transfer in progress */ -#endif -#define SCSI_SELECTED 0x04 /* bus is in selected state. Needed for - correct abort procedure. */ -#define SCSI_DMA24 0x10 /* controller can only DMA to ZorroII - address space */ -#define SCSI_READ24 0x20 /* DMA input needs to be copied from - ZorroII buffer to real buffer */ -#define SCSI_INTR 0x40 /* SCSI interrupt expected */ - -/* sync states */ -#define SYNC_START 0 /* no sync handshake started */ -#define SYNC_SENT 1 /* we sent sync request, no answer yet */ -#define SYNC_DONE 2 /* target accepted our (or inferior) settings, - or it rejected the request and we stay async */ -#ifdef DEBUG -#define DDB_FOLLOW 0x04 -#define DDB_IO 0x08 -#endif diff --git a/sys/arch/amiga/dev/supradma.c b/sys/arch/amiga/dev/supradma.c deleted file mode 100644 index 5c22c9c05dc9..000000000000 --- a/sys/arch/amiga/dev/supradma.c +++ /dev/null @@ -1,497 +0,0 @@ -/* - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)supradma.c - * $Id: supradma.c,v 1.3 1994/03/28 06:16:23 chopps Exp $ - */ - -/* - * dummy Supra 5380 DMA driver - */ - -#include "suprascsi.h" - -#if NSUPRASCSI > 0 - -#include - -#include -#include -#include - -int supradma_pseudo = 0; /* 0=none, 1=byte, 2=word */ - -#ifdef DEBUG -extern int sci_debug; -#define QUASEL -#endif -#define HIST(h,w) - -#ifdef QUASEL -#define QPRINTF(a) if (sci_debug > 1) printf a -#else -#define QPRINTF -#endif - -extern int sci_data_wait; - -static int dma_xfer_in __P((struct sci_softc *dev, int len, - register u_char *buf, int phase)); -static int dma_xfer_out __P((struct sci_softc *dev, int len, - register u_char *buf, int phase)); -static int dma_xfer_in2 __P((struct sci_softc *dev, int len, - register u_short *buf, int phase)); -static int dma_xfer_out2 __P((struct sci_softc *dev, int len, - register u_short *buf, int phase)); -static int supra_intr __P((struct sci_softc *dev)); - -void -supradmainit (dev) - struct sci_softc *dev; -{ - if (supradma_pseudo == 2) { - dev->dma_xfer_in = dma_xfer_in2; - dev->dma_xfer_out = dma_xfer_out2; - } else if (supradma_pseudo == 1) { - dev->dma_xfer_in = dma_xfer_in; - dev->dma_xfer_out = dma_xfer_out; - } - dev->dma_intr = supra_intr; -} - -static int -dma_xfer_in (dev, len, buf, phase) - struct sci_softc *dev; - int len; - register u_char *buf; - int phase; -{ - int wait = sci_data_wait; - u_char csr; - u_char *obp = (u_char *) buf; - volatile register u_char *sci_dma = dev->sci_idata; - volatile register u_char *sci_csr = dev->sci_csr; - - QPRINTF(("supradma_in %d, csr=%02x\n", len, *dev->sci_bus_csr)); - - *dev->sci_tcmd = phase; - *dev->sci_icmd = 0; - *dev->sci_mode = SCI_MODE_DMA; - *dev->sci_irecv = 0; - - while (len >= 128) { - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) != - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) { - if (!(*sci_csr & SCI_CSR_PHASE_MATCH) - || !(*dev->sci_bus_csr & SCI_BUS_BSY) - || --wait < 0) { -#ifdef DEBUG - if (sci_debug | 1) - printf("supradma2_in fail: l%d i%x w%d\n", - len, *dev->sci_bus_csr, wait); -#endif - HIST(ixin_wait, wait) - *dev->sci_mode = 0; - return 0; - } - } - - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - len -= 128; - } - - while (len > 0) { - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) != - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) { - if (!(*sci_csr & SCI_CSR_PHASE_MATCH) - || !(*dev->sci_bus_csr & SCI_BUS_BSY) - || --wait < 0) { -#ifdef DEBUG - if (sci_debug | 1) - printf("supradma1_in fail: l%d i%x w%d\n", - len, *dev->sci_bus_csr, wait); -#endif - HIST(ixin_wait, wait) - *dev->sci_mode = 0; - return 0; - } - } - - *buf++ = *sci_dma; - len--; - } - - QPRINTF(("supradma_in {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5], - obp[6], obp[7], obp[8], obp[9])); - - HIST(ixin_wait, wait) - *dev->sci_mode = 0; - return 0; -} - -static int -dma_xfer_out (dev, len, buf, phase) - struct sci_softc *dev; - int len; - register u_char *buf; - int phase; -{ - int wait = sci_data_wait; - u_char csr; - u_char *obp = buf; - volatile register u_char *sci_dma = dev->sci_data; - volatile register u_char *sci_csr = dev->sci_csr; - - QPRINTF(("supradma_out %d, csr=%02x\n", len, *dev->sci_bus_csr)); - - QPRINTF(("supradma_out {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - len, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], - buf[6], buf[7], buf[8], buf[9])); - - *dev->sci_tcmd = phase; - *dev->sci_mode = SCI_MODE_DMA; - *dev->sci_icmd = SCI_ICMD_DATA; - *dev->sci_dma_send = 0; - while (len > 0) { - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) != - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) { - if (!(*sci_csr & SCI_CSR_PHASE_MATCH) - || !(*dev->sci_bus_csr & SCI_BUS_BSY) - || --wait < 0) { -#ifdef DEBUG - if (sci_debug) - printf("supradma_out fail: l%d i%x w%d\n", - len, csr, wait); -#endif - HIST(ixin_wait, wait) - *dev->sci_mode = 0; - return 0; - } - } - - *sci_dma = *buf++; - len--; - } - - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) == - SCI_CSR_PHASE_MATCH && --wait); - - - HIST(ixin_wait, wait) - *dev->sci_mode = 0; - *dev->sci_icmd = 0; - return 0; -} - - -static int -dma_xfer_in2 (dev, len, buf, phase) - struct sci_softc *dev; - int len; - register u_short *buf; - int phase; -{ - int wait = sci_data_wait; - u_char csr; - u_char *obp = (u_char *) buf; - volatile register u_short *sci_dma = (u_short *)(dev->sci_idata + 0x10); - volatile register u_char *sci_csr = dev->sci_csr + 0x10; - - QPRINTF(("supradma_in2 %d, csr=%02x\n", len, *dev->sci_bus_csr)); - - *dev->sci_tcmd = phase; - *dev->sci_mode = SCI_MODE_DMA; - *dev->sci_icmd = 0; - *(dev->sci_irecv + 16) = 0; - while (len >= 128) { -#if 0 - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) != - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) { - if (!(*sci_csr & SCI_CSR_PHASE_MATCH) - || !(*dev->sci_bus_csr & SCI_BUS_BSY) - || --wait < 0) { -#ifdef DEBUG - if (sci_debug | 1) - printf("supradma2_in2 fail: l%d i%x w%d\n", - len, *dev->sci_bus_csr, wait); -#endif - HIST(ixin_wait, wait) - *dev->sci_mode &= ~SCI_MODE_DMA; - return 0; - } - } -#else - while (!(*sci_csr & SCI_CSR_DREQ)) - ; -#endif - - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - *buf++ = *sci_dma; *buf++ = *sci_dma; - len -= 128; - } - while (len > 0) { -#if 0 - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) != - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) { - if (!(*sci_csr & SCI_CSR_PHASE_MATCH) - || !(*dev->sci_bus_csr & SCI_BUS_BSY) - || --wait < 0) { -#ifdef DEBUG - if (sci_debug | 1) - printf("supradma1_in2 fail: l%d i%x w%d\n", - len, *dev->sci_bus_csr, wait); -#endif - HIST(ixin_wait, wait) - *dev->sci_mode &= ~SCI_MODE_DMA; - return 0; - } - } -#else - while (!(*sci_csr * SCI_CSR_DREQ)) - ; -#endif - - *buf++ = *sci_dma; - len -= 2; - } - - QPRINTF(("supradma_in2 {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5], - obp[6], obp[7], obp[8], obp[9])); - - HIST(ixin_wait, wait) - *dev->sci_irecv = 0; - *dev->sci_mode = 0; - return 0; -} - -static int -dma_xfer_out2 (dev, len, buf, phase) - struct sci_softc *dev; - int len; - register u_short *buf; - int phase; -{ - int wait = sci_data_wait; - u_char csr; - u_char *obp = (u_char *) buf; - volatile register u_short *sci_dma = (ushort *)(dev->sci_data + 0x10); - volatile register u_char *sci_bus_csr = dev->sci_bus_csr; - - QPRINTF(("supradma_out2 %d, csr=%02x\n", len, *dev->sci_bus_csr)); - - QPRINTF(("supradma_out2 {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5], - obp[6], obp[7], obp[8], obp[9])); - - *dev->sci_tcmd = phase; - *dev->sci_mode = SCI_MODE_DMA; - *dev->sci_icmd = SCI_ICMD_DATA; - *dev->sci_dma_send = 0; - while (len > 0) { -#if 0 - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) != - (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) { - if (!(*sci_csr & SCI_CSR_PHASE_MATCH) - || !(*dev->sci_bus_csr & SCI_BUS_BSY) - || --wait < 0) { -#ifdef DEBUG - if (sci_debug) - printf("supradma_out2 fail: l%d i%x w%d\n", - len, csr, wait); -#endif - HIST(ixin_wait, wait) - *dev->sci_mode = 0; - return 0; - } - } -#else - *dev->sci_mode = 0; - *dev->sci_icmd &= ~SCI_ICMD_ACK; - while (!(*sci_bus_csr & SCI_BUS_REQ)) - ; - *dev->sci_mode = SCI_MODE_DMA; - *dev->sci_dma_send = 0; -#endif - - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - *sci_dma = *buf++; *sci_dma = *buf++; - if (*(sci_bus_csr + 0x10) & SCI_BUS_REQ) - ; - len -= 64; - } - -#if 0 - wait = sci_data_wait; - while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) == - SCI_CSR_PHASE_MATCH && --wait); -#endif - - - HIST(ixin_wait, wait) - *dev->sci_irecv = 0; - *dev->sci_icmd &= ~SCI_ICMD_ACK; - *dev->sci_mode = 0; - *dev->sci_icmd = 0; - return 0; -} - -static int -supra_intr (dev) - struct sci_softc *dev; -{ - if (*(dev->sci_csr + 0x10) & SCI_CSR_INT) { - char dummy; -#if 0 -printf ("supra_intr\n"); -#endif - dummy = *(dev->sci_iack + 0x10); - return (1); - } - return (0); -} -#endif diff --git a/sys/arch/amiga/dev/zeusdma.c b/sys/arch/amiga/dev/zeusdma.c deleted file mode 100644 index 655a8785df61..000000000000 --- a/sys/arch/amiga/dev/zeusdma.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1982, 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)dma.c - * $Id: zeusdma.c,v 1.2 1994/02/11 07:02:24 chopps Exp $ - */ - -/* - * dummy PPI Zeus DMA driver - */ - -#include "zeusscsi.h" - -#if NZEUSSCSI > 0 - -void -zeusdmainit () -{ -} -#endif diff --git a/sys/arch/amiga/fpsp/README b/sys/arch/amiga/fpsp/README deleted file mode 100644 index 453413134d18..000000000000 --- a/sys/arch/amiga/fpsp/README +++ /dev/null @@ -1,1232 +0,0 @@ -SECTION 1 FLOATING POINT SOFTWARE PACKAGE TERMS. - -From: Microprocessor & Memory Technologies Group - Semiconductor Products Sector - 6501 William Cannon Drive West, - Mail Station OE33, Austin, Texas 78735-8598 - -To: FLOATING POINT SOFTWARE PACKAGE USERS - -Date: August 27, 1993 - - -1.1 TITLE TO FLOATING POINT SOFTWARE PACKAGE FPSP - -Title to the 68040 Floating Point Software Package, all copies -thereof (in whole or in part and in any form), and all rights -therein, including all rights in patents, and copyrights, -applicable thereto, shall remain vested in MOTOROLA. All -rights, title and interest in the resulting modifications belong -to MOTOROLA except where such modifications (a) are made -solely for use with computer systems manufactured or -distributed by user; (b) are themselves copyrightable; and (c) -would not constitute a copyright infringement if not licensed -hereunder. - - -1.2 DISCLAIMER OF WARRANTY. - -THE 68040 FLOATING POINT SOFTWARE PACKAGE is provided on an -"AS IS" basis and without other warranty except as stated herein. - -IN NO EVENT SHALL MOTOROLA BE LIABLE FOR INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING FROM USE OF THE 68040 -FLOATING POINT SOFTWARE PACKAGE. THIS DISCLAIMER OF -WARRANTY EXTENDS TO ALL USERS OF THE THE 68040 FLOATING -POINT SOFTWARE PACKAGE AND IS IN LIEU OF ALL WARRANTIES -WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING -IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR -PARTICULAR PURPOSE. - - -SECTION 2 Release 2.3 Errata - -As of this release, the following may be considered an -errata of the 040 (Mask 20D43B Mask 4D50D and Mask 5D98D) FPSP: - - 1. INEX1 reported by inexact conversion of packed source - operand for a dyadic instruction will not be reported - by the 040 upon completion of that instruction. This - errata corresponds to errata "F5" on the 68040 Errata Sheet. - Fixed in D98D. - - 2. FREM and FMOD with packed operands will occasionally - differ from the 881/2 results by one ulp in the conversion - of the packed source operand. - - 3. INEX2/AINEX are not calculated in the same manner as in the - 881/882 for some cases in which the result is overflowed. - Currently, if the operation was an integer move-out, INEX2/AINEX - is not set for any case. - In some cases of fscale with integer input, the INEX2 bit will not - be set on inex calculation. - Under extended rounding precision, FSCALE results which underflow - and are inexact may be incorrectly rounded. Inaddition, INEX2 - is not signaled in these cases. - - 4. If an Fmove FPn,FPM(this also applies to the FNEG and FABS), is preceded by any floating point operation with a denorm source operand , the FMOVE - destination (FPm) is incorrectly tagged and may result in silent data - corruption. A software fix in release 2.2. - - - -SECTION 3 Software Specification for an MC68040 Floating- - Point Software Package - -The purpose of this section is to provide an overview of -the floating-point software package (FPSP) for the -MC68040. The FPSP emulates the floating-point -instructions of the MC68881/MC68882 which are not provided -by the MC68040. - - -3.1 DEFINITIONS, ACRONYMS, AND ABBREVIATIONS - -FPn - Floating-Point Data Register Source -FPSP - Floating-Point Software Package -FPU - Floating-Point Unit -FPx - Floating-Point Data Register -See the Glossary of Reference 1 for additional -definitions. - - -3.2 PRODUCT OVERVIEW - -The FPSP adds additional floating-point capabilities to -the MC68040. A subset of the MC6888x instruction set is -executed by the MC68040 on-chip FPU. The remaining -floating-point instructions are emulated in software by -the FPSP (see Reference 2). There are two types of FPSP: -one for applications compiled for the MC68881/MC68882 and -another for applications compiled for the MC68040 (see -3.8.2 Packaging). - -The FPSP provides: -* Arithmetic and Transcendental Instructions -* Decimal Conversions -* Exception Handlers -* MC68040 Unimplemented Data Type and Data Format Handlers -There are two types of users: 1) end users who are running -applications and 2) system integrators who will install -the package (see 3.8.3 Site Adaptations). - - -3.3 GENERAL CONSTRAINTS - -The FPSP satisfies the requirements of the ANSI IEEE -Standard for Binary Floating-Point Arithmetic 754. The -FPSP runs old user code unchanged and is transparent for -old code. The FPSP is easy to modify and install. The -performance of the transcendental function routines is -equivalent or superior to that of a 33-MHz -MC68881/MC68882. The error bound is equivalent or -superior to the MC68881/MC68882 (see 3.7.2 Accuracy). - - -3.4 ASSUMPTIONS AND DEPENDENCIES - -The FPSP can be installed into any operating system. The -MC68040 FPU shall be implemented as described in Reference -2. Table 3-1 Lists the functions provided by the MC68040. - - -3.5.2 Exceptions - -The main goal of the FPSP exception handlers is to provide -the user with an easy path to port over existing MC68882 -exception handlers for use with the MC68040. The end -result is that the FPSP provides an entry point so that -once this point is reached, there is an indication that -an IEEE-defined trap condition exist. - - -3.5.2.1 BSUN Ñ BRANCH/SET ON UNORDERED. - -On a trap-enabled condition, the FPSP updates the floating-point -instruction address register (FPIAR) by copying the PC -value in the pre-instruction stack frame to the FPIAR. -Once this is done, the exceptional frame is restored -without clearing the exception, and the program flow goes -to the FPSP provided entry point. At the entry point the -MC68040 is in an exceptional state, ready to execute the -user-supplied exception handler. - - -3.5.2.2 SNAN Ñ SIGNALING NOT-A-NUMBER. - -On a trap-disabled condition, and if the destination format is B, -W,or L, then the FPSP stores the most significant 8, 16, or -32 bits, respectively, of the SNAN mantissa, with the SNAN -bit set, to the destination. The FPSP discards the -exceptional frame, then returns to the main program flow -without entering the FPSP provided entry point, hence the -user-provided exception handler is not executed. - -On a trap-enabled condition, the FPSP checks if the -destination format is B, W, or L. Then, the FPSP stores -the most significant 8, 16, or 32 bits, respectively, of -the SNAN mantissa, with the SNAN bit set, to the -destination. The FPSP then restores the exceptional frame -without clearing the exception, and branches to the FPSP -provided entry point. At the entry point, the MC68040 is -in an exceptional state, ready to execute the user- -supplied exception handler. - - -3.5.2.3 OPERR Ñ OPERAND ERROR. - -This exception traps through vector number 52. -Table 3-3 shows the operand errors generated by the MC68040. -Table 3-4 shows the operand errors generated by the FPSP. -Note that the FPSP Unimplemented Instruction Handler -detects and adds to the cases in which OPERR exceptions -occur. Refer to Table 3-4 for these specific exception- -causing conditions. - -On a trap-disabled condition, the FPSP checks if the -operand error is caused by an FMOVE to a B, W, or L memory -or integer data register destination. If it is caused by -an integer overflow or if the floating-point data register -to be stored contains infinity, the FPSP stores the -largest positive or negative integer that can fit in the -specified destination format size. If the destination is -integer and the floating-point number to be stored is a -NAN, then the 8, 16, or 32 most significant bits of the -NAN significand is stored as a result. -Next the FPSP checks for a false OPERR condition for an -FMOVE to memory or integer data register. This condition -occurs if the operand is equal to the largest negative -integer representable in its format. The FPSP then stores -the proper result, discards the exceptional frame, and -returns to the main program flow without executing the -user-supplied exception handler. - -On a trap-enabled condition, the FPSP does the same -functions as the above trap-disabled condition, with the -exception that in the end, the FPSP restores the -exceptional frame without clearing the exception and -branches to the FPSP supplied entry point instead of -returning to the main program flow. At the FPSP supplied -entry point, the MC68040 is in an exceptional state, ready -to execute the user-supplied exception handler. - - - -3.5.2.4 OVFL Ñ OVERFLOW. - -This exception traps through vector number 53. - -On a trap-disabled case, the FPSP stores the result in the -destination as determined by the rounding mode at the -destination as follows: - -Rounding Mode Result - RN Infinity, with the sign of the intermediate result - RZ Largest magnitude number, with the sign of the - intermediate result. - RM For positive overflow, largest positive - number - For negative overflow, infinity - RP For positive overflow, infinity - For negative overflow, largest negative - number - -The FPSP then clears the appropriate exception bit in -the frame and restores the non-exceptional frame into -the MC68040, and then returns to the main program flow. - -On a trap-enabled case, the FPSP actions are identical to -those found in the trap-disabled case, with the exception -that instead of restoring a non-exceptional frame, the -original exceptional frame is restored to the MC68040 and -the FPSP branches to the FPSP supplied entry point. At -this entry point, the MC68040 is in an exceptional state, -ready to execute the user-supplied exception handler. - - -3.5.2.5 UNFL Ñ UNDERFLOW. - -This exception traps through vector number 51. - -On a trap-disabled case, the FPSP stores the result in the -destination as determined by the rounding mode at the -destination as follows: - - RN Zero with the sign of the intermediate result. - RZ Zero with the sign of the intermediate result. - RM For positive underflow, +zero. For negative - underflow, the smallest denormalized - negative number. - RP For positive underflow, the smallest denormalized - positive number. For negative underflow, -zero. - -The FPSP then clears the appropriate exception bit in the -frame and restores the non-exceptional frame into the -MC68040, and then returns to the main program flow. - -On a trap-enabled case, the FPSP actions are identical to -those found in the trap-disabled case, with the exception -that instead of restoring a non-exceptional frame, the -original exceptional frame is restored to the MC68040 and -the FPSP branches to the FPSP supplied entry point. At -this entry point, the MC68040 is in an exceptional state, -ready to execute the user-supplied exception handler. - - -3.5.2.6 DZ Ñ DIVIDE BY ZERO. - -Note that the FPSP Unimplemented Instruction Handler detects -and adds to the cases in which DZ exceptions occur. Refer to -Table 3-5 for these specific exception-causing conditions. -Table 3-6 lists the DZ exceptions generated by the MC68040. - -The FPSP is not needed for this exception. The user- -supplied exception handler is always entered. A system -call is provided by the FPSP to calculate the exceptional -operand. - - -3.5.2.7 INEX1/INEX2 Ñ INEXACT RESULT 1/2. - -Note that the FPSP Unimplemented Instruction Handler detects -and allows INEX1 exceptions to occur. Furthermore, many new -cases of INEX2 exceptions may be generated by the FPSP -Unimplemented Instruction Handler as well. The INEX1 -exception traps into this handler as well as INEX2 -exceptions. - -The FPSP is not needed for this exception. The user- -supplied exception handler is always entered. - - -3.5.3 Instructions - -The following paragraphs describe the arithmetic and -transcendental instructions supported by the FPSP. - - -3.5.3.1 ARITHMETIC. - -Table 3-7 shows the arithmetic instructions supported by the FPSP. - - -3.5.3.2 TRANSCENDENTAL. - -Table 3-8 shows the transcendental instructions supported by the FPSP. - - -3.6 EXTERNAL INTERFACE REQUIREMENTS - -For end users the FPSP is transparent; system Integrators -will integrate the FPSP into their system. (See 3.8.3. -Site Adaptations) - -For applications compiled for the MC68881/MC68882 the FPSP -provides kernel routines to support the MC68040 -unimplemented instructions. The MC68040 uses vector -number 11 for the unimplemented instructions. The MC68040 -stack frames are different for unimplemented -MC68881/MC68882 instructions and other F-line traps. For -applications compiled for the MC68040 the unimplemented -instructions are contained in a library (to avoid the -F_line trap overhead at runtime). - -For both applications the FPSP provides kernel routines to -support exceptions (vectors 48Ñ54) and unsupported data -types (vector 55). - - -3.7 PERFORMANCE REQUIREMENTS - -The following paragraphs describe the speed, accuracy, and -compatibility requirements for the FPSP. - - -3.7.1 Speed - -The performance of the transcendental function routines is -equivalent or superior to that of a 33-MHz -MC68881/MC68882. - - -3.7.2 Accuracy - -The following paragraphs describe the arithmetic -instructions, transcendental instructions, and decimal -conversions for the FPSP. - - -3.7.2.1 ARITHMETIC INSTRUCTIONS. - -The error bound is one-half unit in the last place of the -destination format in the round-to-nearest mode, and one -unit in the last place in the other rounding modes. - - -3.7.2.2 TRANSCENDENTAL INSTRUCTIONS. - -The error bound is less than 0.502 ulp of double precision. - - -3.7.2.3 DECIMAL CONVERSIONS. - -The error bound is 0.97 unit in the last digit of the -destination precision for the round-to-nearest mode; and -1.47 units in the last digit of the destination precision for -the other rounding modes. - - -3.7.3 Compatibility - -The FPSP transcendental calculation results are not the -same as for the MC68881/MC68882. This is because the -algorithms used by the MC68881/MC68882 (CORDIC) cannot be -effectively implemented in software. All other -calculations are identical. The error bound is equivalent -or superior to the MC68881/MC68882. - - -3.8 OTHER REQUIREMENTS - -The following paragraphs describe other requirements for -the FPSP, such as maintainability, packaging, and site -adaptations. - - -3.8.1 Maintainability - -The speed requirements have forced writing most of the -package in assembly language. - - -3.8.2 Packaging - -There are two versions of the FPSP. The FPSP Kernel -Version is used to execute pre-existing user object code -written for the MC68882. This is installed as part of the -operating system. User applications need not be recompiled -or modified in any way once the FPSP Kernel Version is -installed. - -The FPSP Library Version is used to compile code that uses -only the MC68040-implemented floating point instructions. -The library version provides less overhead than the FPSP -Kernel Version. Other features of this library includes -ABI compliance as well as IEEE exception-reporting -compliant. It is not however, UNIX exception-reporting -compliant. The FPSP is not yet available in library -format. - - -3.8.3 Site Adaptations - -Some of the entries in the vector table needs to point to -entry points within the FPSP Kernel Version. For those -vectors the FPSP displaces, an entry point is provided to -replace that which it takes. Note that former MC68882 -floating-point exception handlers need to go through minor -modifications to account for the differences between the -MC68040 and MC68882 floating point exceptional state -frames. The FPSP provides skeleton code for each floating- -point exception handler to aid in porting the MC68882 -floating-point exception handlers. - -For systems and applications that never set any of the -exception bits in the FPCR, or if the former MC68882 -floating-point exception handlers only contain minimum -code needed to clear the exception and return, no work is -needed and the FPSP is a drop-in package. - -The FPSP Library Version needs to "intercept" the -appropriate math library calls which use MC68882 -transcendental instructions. Since each site has different -naming conventions, the FPSP subroutines need to be -renamed accordingly and recompiled. The resident compiler -also needs to provide a library path search pattern such -that the FPSP is given a chance to resolve those -trancendentals instructions. - - -3.8.4 Stack Area Usage - -To achieve code re-entrace, the FPSP allocates context- -sensitive variables on the stack. The FPSP does not -require more than 512 bytes on the stack per context. This -may be an installation concern for UNIX applications in -which there is a limited UBLOCK area, and that the system -stack resides there. - - -3.8.5 ROM-based applications - -One of the goals of the FPSP Kernel Version is to be able -to fit in a read-only space of no more than 64 KBytes. -There are two main sections that need to reside in ROM. -The text section, and the initialized data section. The -text section accounts for 65% while the initialized data -section accounts for 35%. - - -3.9 FPSP KERNEL VERSION INSTALLATION NOTES - -The following paragraphs provide the MC68882 users with an -understanding of the issues involved in porting over the -FPSP into existing MC68030/MC68882 systems. Once these -issues are understood, then the actual installation is -explained. - - -3.9.1 Differences between the MC68040 and MC68882 - Floating-point Exception Handling - -The main reason for providing the FPSP is to provide -MC68882 compatibility. If the installer understands the -main differences between the MC68882 and MC68040 in the -area of floating-point exception handlers, skip this -section and go to the next section. - -There are three areas that differ between the MC68040 and -MC68882. - -The first difference is that of unimplemented -instructions. The FPSP handles this by means of the F-line -exception handling. This means that if there is an -existing F-line handler, the FPSP replaces the existing F- -line exception handler, but provides an alternate entry -point for the existing F-line handler. - -The second difference is unsupported data types. The -MC68040 provides a new entry point in the vector table, -therefore no existing handler is replaced by the FPSP. -There are no installation issues here. - -The third difference is that of floating point exception -differences. This issue is more involved and requires -further explanations. - -The IEEE standard allows the user to enable or disable -each floating point exception individually. If an -exceptional condition occurs, the IEEE defines a specific -action for the trap-disabled condition, and it also -defines certain specific actions for a trap-enabled -condition. The IEEE standard however, does not constrain -the implementation of exception handling; both software -and hardware can be used. - -The MC68882 supports the IEEE exception handling -compliance totally in hardware. For example, a user- -disabled (trap disabled) exception will cause the -specified IEEE defined actions for user-disabled exception -handling to occur. Similarly, user-enabled exceptions -will cause the MC68882 to take the exception as defined by -the IEEE trap enabled case. - -The MC68040 provides full IEEE trap-disabled exception -handling compliance for the INEX and DZ exceptions. Just -as the MC68882, the MC68040 takes these exceptions only -for an IEEE trap-enabled condition. Existing MC68882 -handlers have a minimum code requirement as defined by the -MC68882 User's Manual. As the MC68882 handlers, the -MC68040 handlers have a minimum code requirement as well. -The FPSP provides this minimum code requirement. - -The MC68040 does not provide full IEEE exception -compliance on IEEE defined trap-disabled conditions for -the following exceptions: OVFL, UNFL, OPERR, SNAN. For -these exceptions, the MC68040 may take an exception even -on an IEEE-defined trap-disabled condition. The FPSP -provided exception handlers decide if its job is to -implement IEEE trap-disabled exception compliance, (and -therefore not execute the user supplied exception handler) -or to implement IEEE trap-enabled exception compliance, -(hence executing the user supplied exception handler). The -FPSP provides a user entry point so that when this entry -point is taken an IEEE-defined trap-enabled condition has -definitely occurred. At this specified entry point, an -exception handler written for the MC68882 needs to be -modified to account for MC68040 stack differences, and -then placed at the user entry point. - -As with the MC68882, there is a minimum code requirement -for the MC68040 handler, but this minimum code is provided -by the FPSP. - -From an installation perspective, the OVFL, UNFL, OPERR, -SNAN exception handlers are replaced by the FPSP handlers, -but the FPSP provides an entry point so that MC68882-like -exception handlers may be written. Furthermore, minimum -code is provided by the FPSP and can be used as a -template. - -The BSUN exception is different in that unlike the -previous exception handlers, the difference between the -MC68882 and MC68040 resides in the IEEE-defined trap -enabled case. The FPSP handles this by performing the -patch needed for MC68882 compatibility, and then restoring -the exception to the MC68040 without performing the -necessary steps to clear the BSUN exception. The -exceptional frame is restored into the MC68040 and the -FPSP branches to the user entry point provided. At this -entry point, an MC68882-like exception handler written for -the MC68040 is executed without having to worry about the -built-in incompatibility. Although this method incurs a -performance hit, it frees the user-defined exception -handler from having to write the code needed to implement -MC68882 code compatibility. As with the other exception -handlers, the FPSP provides the minimum code needed. - -In summary, the FPSP replaces the following exception -handlers and provides an entry-point for MC68882-like -exception handlers for these exceptions: OVFL, UNFL, -OPERR, SNAN, BSUN, F-line. - -The FPSP is not needed for the INEX and DZ exception -handlers, and these exception handlers just need to be -MC68882-like. - - -3.9.2 Vector Table - -The entry point into the FPSP is achieved by having the -appropriate vector table offset point to a specified entry -point within the FPSP. For simplicity, all of the FPSP -main entry points are found in the file skeleton.sa. -Table 3-9 shows the vector table offset and the -appropriate labels within the file skeleton.sa that it -needs to point to. Figure 3-1 shows a flowchart of the -entry points. - -Once the entry point is reached, the user may add some -user-specific code prior to jumping to the FPSP routines ( -FPSP routines are prefixed by "fpsp_"). After the jump to -the FPSP routines, the FPSP performs its function and then -jumps to the FPSP supplied entry points (if needed) found -in the file skeleton.sa. - - -3.9.3 FPSP Supplied Entry Points - -To replace the vector table entries it displaces, the FPSP -provides an alternate entry point. For simplicity, all of -the FPSP supplied entry points are found in the file -skeleton.sa. The FPSP supplied F-line exception entry -point is straight-forward. An F-line exception handler -written for an MC68030 can be placed here without -modifications. The Unsupported Data Type exception handler -is newly-defined, it does not displace any MC68030/MC68882 -exception handler. Therefore, the FPSP does not provide an -alternate entry point for this exception. - -The alternate entry points have the naming convention such -that the specified exception handler is prefixed by -"real_". For instance, the entry point for user-supplied -BSUN exception handler is named "real_bsun". - -For the floating-point exception handlers (BSUN, OPERR, -SNAN, DZ, OVFL, and UNFL) previously written for an -MC68882 based system, these handlers need to be modified -slightly for use with the MC68040. Once these handlers are -modified, they are then placed in the FPSP provided entry -points. - - -3.9.4 Extract the Hardware Independent portion of -the MC68882 handlers - -To modify the existing MC68882 handlers, all of the code -used in accessing the MC68882 generated frame needs to be -stripped off. The code used in clearing an MC68882 -exception (setting bit 27 of the BIU Flag) needs to be -stripped off as well. Only the hardware independent -portions of the MC68882 handlers may be used. - -To aid the installer in rewriting the MC68882 exception -handlers, the file skeleton.sa provides the minimum code -necessary to clear the exception once the specific handler -is entered. - -Once the hardware-independent portion is written, the -modified MC68882 handlers need to be integrated into the -portion of the code which is hardware dependent. The -minimum code needed by each exception handler is already -provided by the FPSP within the file skeleton.sa. The -following section describes the mechanics behind the -written code. - - -3.9.5 MC68040 Minimum Exception Code - -This section describes the minimum requirements for the -user-supplied exception handlers. As mentioned in the -previous sections, these minimum handlers are provided as -part of the package, and this section is strictly for the -user's information only. - -As with the MC68882, if all exceptions are always -disabled, no minimum code is necessary since the FPSP -guarantees that these FPSP provided entry points are never -entered on trap-disabled condition. Therefore, for -existing systems that do not provide exception handlers -for the MC68882, it is likely that the assumption that all -exceptions are always disabled is valid, and therefore no -user-defined MC68040 exception handlers are needed either. - -The above paragraph should not be interpreted to mean that -the FPSP provided exception handlers are unnecessary. On -the contrary, the FPSP provided exception handlers are -needed, and that these FPSP exception handlers provide the -entry points for user-defined exception handlers. Whether -or not the user-defined MC68040 exception handers are -needed is the issue being discussed. - -Assuming that it is possible that the exceptions are -enabled at some point, the minimum exception handler is -similar to that defined for an MC68882. As with the -MC68882, the MC68040 requires that the first floating -point instruction be an FSAVE. Unlike the -MC68882, the MC68040 does not always require an equivalent -FRESTORE. For an E1 exception, only the FSAVE requirement -is needed, the state frame may be discarded. The E3 -exception is more similar to that found in an MC68882. As -with the MC68882, the E3 exception requires an FSAVE, an -instruction that clears the exception in the resulting -FSAVE stack, followed by an FRESTORE. - -If both E3 and E1 exceptions exist at the same time, then -the exception is handled as though it were an E3 -exception. After which, the MC68040 re-traps to handle the -E1 exception. - -The E3 exception can only be reported by the following -exception handlers: OVFL, UNFL, INEX. For these exception -handlers, this is the minimum code requirement: - 1) FSAVE - 2) if E3 bit set, goto (4), else goto (3) - 3) E1 exception, throw away stack and RTE - 4) Clear E3 bit, FRESTORE, RTE - -The E3 exception cannot be reported by the following -exception handlers: SNAN, OPERR and DZ. Since only an E1 -exception needs to be handled here, this is the minimum -code requirement: - 1) FSAVE - 2) throw away stack and RTE - -For the BSUN exception handler, the minimum code -requirement is: - 1) FSAVE - 2) Do one of 4 methods described in MC68040 User's - Manual - 3) throw away stack and RTE - -If the above minimum code requirements are not met, then, -an infinitely looping exception sequence occurs. - - -3.9.6 Mem_read and Mem_write - -The mem_write and mem_read subroutines are used by the -FPSP to read and write from user space. These routines -perform a UNIX system call to lcopyin and lcopyout. The -FPSP provides a simple version of lcopyin and lcopyout for -non-UNIX applications. Installation to UNIX-based systems -requires that the FPSP provided lcopyin and lcopyout be -deleted or commented out. For simplicity, these -subroutines are found in the file skeleton.sa. - -The production version of the FPSP is fully re-entrant. If -a page fault occurs on either a mem_read or mem_write, the -operating system may perform a page-in operation and still -allow other processes to use the FPSP. - - -3.9.7 Increasing F-line Handler Performance - -The FPSP was written to handle all possible cases of -MC68040 vs MC68030/MC68882 problem areas. Any performance -improvement in this handler increases floating-point -performance. The F-line handling may be made quicker by -pointing the vector table entry directly into the label -"fpsp_unimp" found in the file x_unimp.sa, if these -conditions are met: - - 1) That the system never has to execute an FMOVECR - instruction in which bits 0 to 5 of the F-line word are - non-zero. - - 2) An alternate F-line entry point is unnecessary. - This optimization saves a total of three instructions. ( 1 - bra, 1 cmpi, 1 beq). - - -3.10 REFERENCES - -1. MC68881UM/AD, MC68881/MC68882 Motorola Floating-Point - Coprocessor User's Manual. Motorola Inc., 1989 -2. M68040UM/AD M68040 32-Bit Microprocessor User's - Manual, Motorola, Inc.,1992, -3. MC68020UM/AD, MC68020 32-Bit Microprocessor User's - Manual, Motorola, Inc., 1990. -4. MC68030UM/AD, MC68030 Enhanced 32-Bit Microprocessor - User's Manual, Motorola Inc., 1990 -5. ANSI/IEEE Std. 754,1985 Standard for Binary Floating- - Point Arithmetic -6. M68000PM/AD REV. 1 Programmer's Reference Manual. Motorola Inc., 1992 - - -3.11 Tables and Figures - - Table 3-1. Functions Provided by MC68040 - ------------------------------------------------------------------ - Name | Description - ------------------------------------------------------------------ - FMOVE Move to FPU - FMOVEM Move Multiple Registers - FSMOVE Single-Precision Move - FDMOVE Double-Precision Move - FCMP Compare - FABS Absolute Value - FSABS Single-Precision Absolute Value - FDABS Double-Precision Absolute Value - FTST Test - FNEG Negate - FSNEG Single-Precision Negate - FDNEG Double-Precision Negate - FADD Add - FSUB Subtract - FDIV Divide - FMUL Multiply - FBcc Branch Conditionally - FScc Set According to Condition - FDBcc Test Cond, Dec and Branch - FTRAPcc Trap Conditionally - FSADD Single-Precision Add - FSSUB Single-Precision Subtract - FSMUL Single-Precision Multiply - FSDIV Single-Precision Divide - FDADD Double-Precision Add - FDSUB Double-Precision Subtract - FDMUL Double-Precision Multiply - FDDIV Double-Precision Divide - FSQRT Square Root - FSSQRT Single-Precision Square Root - FDSQRT Double-Precision Square Root - FNOP No Operation - FSAVE Save Internal State - FRESTORE Restore Internal State - FSGLDIV Single-Precision Divide (68882 compatible) - FSGLMUL Single-Precision Multiply (68882 compatible) - ------------------------------------------------------------------ - - - Table 3-2. Support for Data Types and Data Formats - ------------------------------------------------------------------ - | Data Formats - |---------------------------------------------------- - Data Types | SGL | DBL | EXT | Dec | Byte | Word | Long - ------------------------------------------------------------------ - Norm * * * @ * * * - Zero * * * @ * * * - Infinity * * * @ - NaN * * * @ - Denorm # # @ @ - Unnorm @ @ - ------------------------------------------------------------------ -Notes: - @ = supported by FPSP - * = supported by the MC68040 FPU - # = supported by FPSP after being converted to extended precision by - MC68040 - - - Table 3-3. Operand Errors Handled by the MC68040 - ------------------------------------------------------------------ - Instruction | Conditions Causing Operand Error - ------------------------------------------------------------------ - FADD ( + inf )+( - inf ) or (- inf )+( + inf ) - FSUB ( + inf )-( + inf ) or (- inf )-(- inf ) - FMUL ( 0 ) x ( inf ) or ( inf ) x ( 0 ) - FDIV 0 / 0 or inf / inf - FMOVE.BWL Integer overflow, Source is NaN, or Source is inf - FSQRT Source < 0, Source = - inf - ------------------------------------------------------------------ - - - - Table 3-4. Operand Errors Generated by the FPSP - ------------------------------------------------------------------ - Instruction | Condition Causing Operand Error - ------------------------------------------------------------------ - FSADD ( + inf )+( - inf ) or ( - inf )+( + inf ) - FDADD ( + inf )+( - inf ) or ( - inf )+( + inf ) - FSSUB ( + inf )-( + inf ) or ( - inf )-( - inf ) - FDSUB ( + inf )-( + inf ) or ( - inf )-( - inf ) - FSMUL ( 0 ) x ( inf ) or ( inf ) x ( 0 ) - FDMUL ( 0 ) x ( inf ) or ( inf ) x ( 0 ) - FSDIV 0 / 0 or inf / inf - FDDIV 0 / 0 or inf / inf - FCOS Source is +/- inf - FSIN Source is +/- inf - FTAN Source is +/- inf - FACOS Source is +/- inf, > +1, or < -1 - FASIN Source is +/- inf, > +1, or < -1 - FATANH Source is > +1, or < -1, Source = ± inf - FSINCOS Source is +/- inf - FGETEXP Source is +/- inf - FGETMAN Source is +/- inf - FLOG10 Source is < 0, Source = - inf - FLOG2 Source is +/- inf, > +1, or < -1 - FLOGN Source is +/- inf, > +1, or < -1 - FLOGNP1 Source is < -1, Source is = - inf - FMOD FPx is +/- inf or Source is 0, Other Operand is not a - NaN - FMOVE to P Result Exponent > 999 (Decimal) or k-Factor > +17 - FREM FPx is +/- inf or Source, Other Operand is not a NaN - FSCALE Source is +/- inf, Other Operand is not a NaN - ------------------------------------------------------------------ - - Table 3-5. DZ Exceptions Generated by the FPSWP - ------------------------------------------------------------------ -Ê Instruction | Condition Causing DZ Exception - ------------------------------------------------------------------ - FATANH Source Operand = $ + -$1 - FLOG10 Source Operand = 0 - FLOG2 Source Operand = 0 - FLOGN Source Operand = 0 - FLOGNP1 Source Operand = -1 - FSGLDIV Source Operand = 0 and FPn is not a NaN, Infinity, - or 0 - ------------------------------------------------------------------ - - - Table 3-6. DZ Exceptions Generated by the MC68040 - ------------------------------------------------------------------ - Instruction | Condition Causing DZ Exception - ------------------------------------------------------------------ - FDIV Source Operand = 0 and FPn is not a NaN, Infinity, - or 0 - FSDIV Source Operand = 0 and FPn is not a NaN, Infinity, - or 0 - FDDIV Source Operand = 0 and FPn is not a NaN, Infinity, - or 0 - ------------------------------------------------------------------ - - - Table 3-7. Arithmetic Instructions - ------------------------------------------------------------------ - Name | Description - ------------------------------------------------------------------ - FADD* Add - FSUB* Subtract - FSADD*+ Single-Precision Add - FSSUB*+ Single-Precision Subtract - FDADD*+ Double-Precision Add - FDSUB*+ Double-Precision Subtract - FMUL* Multiply - FDIV* Divide - FSMUL*+ Single-Precision Multiply - FSDIV*+ Single-Precision Divide - FDMUL*+ Double-Precision Multiply - FDDIV*+ Double-Precision Divide - FINT Integer Part - FINTRZ Integer Part (Truncated) - FABS* Absolute Value - FNEG* Negate - FGETEXP Get Exponent - FGETMAN Get Mantissa - FTST* Test Operand - FCMP* Compare - FREM IEEE Remainder - FSCALE Scale Exponent - FMOVE* Move FP data register - FSMOVE* Single-Precision Move - FDMOVE* Double-Precision Move - FSQRT* Square Root - FSSQRT* Single-Precision Square Root - FTWOTOX 2 to the X Power - FMOD Modulo Remainder - FDSQRT* Double-Precision Square Root - FDMOD Double-Precision Modulo Remainder - FSMOD Single-Precision Modulo Remainder - ------------------------------------------------------------------ -Notes: - * The FPSP provides these functions for all decimal data formats, - single, double, and extended denormalized data types, and extended - unnormalized data types. The MC68040 provides these functions - for the remaining formats and types (See page 11 of Reference 2). - + Additional functions which are not provided by the MC68881/MC68882. - - - Table 3-8. Transcendental Instructions - ------------------------------------------------------------------ - Name | Description - ------------------------------------------------------------------ - FCOS Cosine - FSIN Sine - FACOS Arc Cosine - FASIN Arc Sine - FCOSH Hyperbolic Cosine - FSINH Hyperbolic Sine - FSINCOS Simultaneous Sine & Cosine - FATAN Arc Tangent - FTAN Tangent - FATANH Hyperbolic Arc Tan - FTANH Hyperbolic Tangent - FLOG10 Log Base 10 - FLOG2 Log Base 2 - FLOGNP1 Log Base e of (x+1) - FLOGN Log Base e - FETOXM1 (e to the x Power) -1 - FETOX e to the x Power - FTWOTOX 2 to the x Power - FTENTOX 10 to the x Power - ------------------------------------------------------------------ - - - Table 3-9. FPSP Provided Entry Points - ------------------------------------------------------------------ - Exception Type | Vector Table | FPSP entry | User entry - | (offset) | point | point - ------------------------------------------------------------------ - F-line unimplemented vector 11 ($2C) fline real_fline - float instruction - ------------------------------------------------------------------ - Branch or set on vector 48 ($20) bsun real_bsun - unordered - ------------------------------------------------------------------ - Inexact vector 49 ($C4) inex real_inex - ------------------------------------------------------------------ - Divide-by-zero vector 50 ($C8) dz real_dz - ------------------------------------------------------------------ - Underflow vector 51 ($CC) unfl real_unfl - ------------------------------------------------------------------ - Operand error vector 52 ($D0) operr real_operr - ------------------------------------------------------------------ - Overflow vector 53 ($D4) ovfl real_ovfl - ------------------------------------------------------------------ - Signalling Not-A- vector 54 ($D8) snan real_snan - Number - ------------------------------------------------------------------ - Unsupported data type vector 55 ($DC) unsupp - ------------------------------------------------------------------ - - - File: skeleton.sa - |---------------------| - | | File: x_unfl.sa - | | |----------------------| - VECTOR | | | | - TABLE | | /->|fpsp_unfl: | - |------------| /->|unfl: | | | . | - | | | | jmp fpsp_unfl ----|-/ | . | - | | | | | | . | -vbr+$cc |addr of unfl|-/ | | | HANDLE NON-MASKABLE | - | | |real_unfl: <--------|--\ | EXCEPTION CONDITION | - | | | . | | | . | - | | | . | | | . | - | | | . | | | . | - | | | USER TRAP HANDLER | | | | - |------------| | . | | | if FPCR Exception | - | . | | | Byte UNFL bit set,| - | . | \-|-- jmp real_unfl | - |rte . | | else rte | - | | |----------------------| - |---------------------| - Figure 3-1 FPSP Entry Points - - - -SECTION 4 FPSP Library Version - -4.1 When to use the FPSP Library Version. - -The FPSP Library Version is intended to provide better performance for -trancendental instructions. It gets its performance by avoiding the -overhead involved in F-line trap emulation, as used by the Unimplemented -Instruction Handler. The FPSP Library Version is optional, and user code -needs to be recompiled to make use of it. - - -4.2 Installation Notes - -The library version of the FPSP can be built by running 'make libFPSP.a' -from either the Makefile (for asm syntax) or fpsp.mk (for as syntax). -The 'make convert' step in Makefile will build both kernel and library .s -files from the .sa sources. Change the SYS= and PREFIX= variables -in Makefile BEFORE running 'make convert'. Three templates are supplied -for building the library version: GEN, CI5 and R3V6. The GEN templates -generate entry points for single, double and extended precision routines and -provide the closest emulation of the kernel FPSP. The CI5 and R3V6 -templates are faster, but discard most of the condition code and control -register handling, and only provide the double precision entry points. - -The entry point names are contained in L_LIST. Change the first 3 -entries of each line to suit your system. - - -4.3 Differences in the library version: - - 1.) Single and Double precision SNAN's will not generate an SNAN - exception because they are converted to extended precision - and doing so causes them to turn into non-signalling NAN's. - - Example: facos.d 7ff7_ffff_ffff_ffff snan - - 2.) An enabled Inexact exception may not be taken in all cases. - - Example: facos.x 000000000000000000000001 d inex2 - fint.x 403d_0000_aaaa_aaaa_aaaa_ffff inex2 - - 3.) The return value in fp0 is undefined when an enabled OPERR or DZ - exception ocurrs. In the kernel FPSP, the destination register - is unchanged. - - 4.)fscale does not return the right result when an underflow ocurrs. - The problem is that the t_unfl code in the l_support.sa file - cannot exactly mimic the kernel FPSP version because the incoming - FPCR is not in the same place every time. - - -4.4 Changes in the library version of FPSP rel 2.3: - - A floating point exception occurs when a transcendentals called twice. - example: main() - { double d; - d= 0.0; - x = facosd(0.0); - y = facosd(d); - } - This is fixed in release 2.2 of FPSP. - A followup on the above bug was to restore the fpcr beforw it unlinks. - This is fixed in release 2.3 of FPSP. - - -4.5 Performance - -Overall, the library version is twice as fast as the kernel code. - - -APPENDIX A BUG TEMPLATE - -Use the template below when reporting bugs. - -Any fields designated with an asterick (*) can be left blank. -When complete, please fax the report to the following -phone number : - - (800) 248-8567 - -To assist you in filling out this form, a description of each field follows -the template. -Should you have any questions, please fax us at the above number. ----------------------------------------------------------------------------- - -Problem# (0-0000) - -Key Words - -Severity (1,2,3) - -Customer Description - -Long Description - -System Description - -Date Reported - -Reported By - -Phone - -*Resolved? - -*Date Resolved - -*Who fixed - -*Correction Description - -*Modules Affected - -Problem Release/Load - -*Test suite passed - -*sccs version control - ---------------------------------------------------------------------------- - -The following is a brief description of how to use the bug report template. - ---------------------------------------------------------------------------- - -Problem# (0-0000) You may include a number that you will use internally - to track this bug. We will log it but assign our own - # to track your bug repair. Please choose one person - as the individual to send in all bug reports for your - firm. This should help avoid confusion and ensure a - smooth working relationship. - -Key Words Indicate the key terms associated with this bug - report. For example: fpcr, denorm - -Severity (1,2,3,4,5) This indicates the severity of the bug. - The following descriptions are taken from AT&T test - document: - 1: an error that causes the FPSP to crash and no - further work can be done. An error that causes gross - deviations of results. Non-waiverable compliance - violations are also severity 1. - 2: an error that represents a substantial deviation in - the functionality of the FPSP or deviation from - IEEE 754 standard. - 3: an error that represents a deviation in the - functionality. However, the customer is able to - implement a workaround to this problem. - 4: an error that represents a minor deviation or - incorrect documentation. - 5: a request for product enhancement. - - -Customer Description This is a brief description of the problem. - -Long Description This is a more detailed description of the problem. - This could contain a short code fragment, a - suggested fix for the bug or reference a longer - file with this type of information in it. - -System Description This is a brief description of your system. - -Date Reported MM/DD/YY - -Reported By Your name - -Phone Enter your telephone number including the - area code. - -*Resolved? Enter "yes" or "no" only. - -*Date Resolved When the bug is fixed the date it was fixed - will be entered by us in this field. - -*Who fixed Name of the person who fixed the bug. - -*Correction Description When the bug is fixed we will enter a - description of the fix in this field. - -*Modules Affected When the bug is fixed we will enter the - module name. - - -Problem Release/Load Enter the release or load information in this - field. This information should be on the label - for the tape that was sent to you. - -*Test suite passed You do not need to fill out this field. This is - the test suite file that we use to verify bugs - and/or fixes. - -*sccs version control You do not need to fill out this field. This is - the sccs version that contains the fix. - diff --git a/sys/arch/amiga/fpsp/README.source b/sys/arch/amiga/fpsp/README.source deleted file mode 100644 index 62e44b38ffc1..000000000000 --- a/sys/arch/amiga/fpsp/README.source +++ /dev/null @@ -1,5 +0,0 @@ -The source for the Motorola FPSP (Floating Point Software Package) was ported -to gas by Eric Norum at the University of Saskatchewan. It is available -by anonymous ftp from: - ftp.usask.ca /pub/software/fpsp/fpsp_gas.tar.gz - diff --git a/sys/arch/amiga/fpsp/README_FIRST b/sys/arch/amiga/fpsp/README_FIRST deleted file mode 100644 index d2961a60496f..000000000000 --- a/sys/arch/amiga/fpsp/README_FIRST +++ /dev/null @@ -1,40 +0,0 @@ -I got the FPSP source from the Motorola BBS and have converted it -to GNU GAS format. - -The three subdirectories are: - src_asm FPSP source from the Motorola BBS. - src_as FPSP source from the Motorola BBS. - src_gas FPSP source in GNU GAS format. I did this by - running some `flex' lexical analyzers on the - src_asm files. - -A big thanks goes out to Michael Hitch (osymh@gemini.oscs.montana.edu) for -solving the problem I had with some operations locking up. The problem -was that there were some branch instructions in gen_except.s that -were `word' when they should have been `long'. - -I had to make a little tweak to gas version 2.1.1 to get it to assemble. -Around line 2190 of tc-m68k.c you have to change a `#if 0' to `#if 1': -============================================================================= - /* We gotta put out some float */ -#if 1 - if (seg (opP->con1) != SEG_BIG) - { - int_to_gen (nextword); - gen_to_words (words, baseo, (long int) outro); - for (wordp = words; baseo--; wordp++) - addword (*wordp); - break; - } /* Its BIG */ -#else - if (seg (opP->con1) != big_section) - { - abort (); - } -#endif -============================================================================= - -Eric Norum eric@skatter.usask.ca -Saskatchewan Accelerator Laboratory -University of Saskatchewan -Saskatoon, Canada. NeXTMail accepted. diff --git a/sys/arch/amiga/fpsp/fpsp.o.uu b/sys/arch/amiga/fpsp/fpsp.o.uu deleted file mode 100644 index efd92bb9cd41..000000000000 --- a/sys/arch/amiga/fpsp/fpsp.o.uu +++ /dev/null @@ -1,4494 +0,0 @@ -begin 644 fpsp.o -M```!!P``E7P````````````!6`0````````9`````#^```````````````````!````````````` -M````````02```````````````````$6:*````````````````````````P," -M`@,"`@,"`P,"2.<_(/(GX`?R/)``````("U0_[`N`$(N_[4P+O\8`D#@`&<` -M`#`P$`)`?_\B*``$)"@`"%-`XXKCD4J!;/9*0&X$4.[_M0)`?_\P@"%!``0A -M0@`(+5#_G"UH``3_H"UH``C_I`*N?_____^<2B[_M6<(+#S__^R[8#@P+O^< -M/7P___^<\BY(`/^A" -M@^*(9`;R,4BC.``&@P````Q*@&;L\CR(``````#R/)``````$/(02`#R```8 -M2D5F!O(`!"!@7$HN_[5G0O(GX`(O*``(+R@`!"\0=A)"IU'+__P>KO^['WP` -M8``!'WP`$`!$/WP`(P!`'WP`_@`(\U_R*4@C`"3R*4@C`#!@%$I"9PSR*4@C -M`"3R*4@C`##R``0C\@"H`/(N:`#_G$7N_YP(```)9PX`J@````$`"/(N2`#_ -MG"UN_X#_K`*N````,/^`2.?`P"\N_ZPO+O^P0>[_G/(0:`!*KO^P;`8`D(`` -M```O+O^$80!*!!U7_X18CRU?_[`M7_^L3-\#`RUN_[#_G"UN_ZS_@$A%2D5F -M``""\CI%`/T\(`13@$*#XHAD!O(Q22,X``:#````#$J`9NQ*+O^U9PCR```8 -M8```)O(``!CR``@X\I,`&E.&.CP``?(\D``````@\CI%(_T48`#]_/(Z12/] -M"O(`"#CRE`!<\I(`#/(Z1"#\^%*&8$Q2ACH\``'R/)``````(&``_<[R.D4` -M_+P@!$*#XHAD!O(Q22,X``:#````#$J`9NSR```8\@`(./*.`!+R.D0@_+)2 -MAE*$\CI%(_RH\CR0`````!#R``@@0>[_C/(0:``D*``$)B@`"$*H``1"J``( -M(!!(0&<4!(```#_]2H!N"D2`XHKBDU'(__I*@F8$2H-G$$*!!H,```"`U8$" -M@____X`@!%:(80``VDHN_[5G*/(``#KR@0`,\@9``/(``!A@+DJ';0CR.D0` -M_#A@(O(&0`#R```88!CR```Z\HX`"O(Z1`#[[F`(\@9``/(``!CR*4@@`!CR -M+F@`_YPD*@`$)BH`"#`29PX$0#_]1$#BBN*34[_ -MC""N_S0A;O\X``0A;O\\``@H$$*!3#P0``````KIQ`C$TH!8`U'*_^X(!``> -M9P)$@02!````$&P.1($`A$``````D$`````M0?^L<@'R.D0`_YCIT`<$\@!8 -M(B@P'`!V`'0'\CI$(_^*Z<0(Q/(`6")8`U'*_^Y2@0R!`````F\`_]H($``? -M9P3R```:(B[_K`R!````&V\``.`($``>9G)"@2@0Z<0'!&8D4H%Z`2@P7`!F -M"%"!4H4H,%P`0H-T!^G$",1F"%B#4H%1RO_T(`$B+O^LDH!L$$2!*!``A$`` -M````D$`````B?```$2A"@_(Z1(#^^'0#XH!D!O(Q2*,X``:#````#$J`9NSR -M``0C8&9"@7H"*#!<`&8(4X50@2@P7`!V''0'Z<0(Q&8(68-2@5'*__0@`2(N -M_ZR2@&X01($H$`*$O____P*0O____R)\```1*$*#\CI$@/Z0=`/B@&0&\C%( -MHS@`!H,````,2H!F[/(`!"`F+O^`Z<,F@B@0Y8+IQ``"U(!#^OY,$#$H`$*# -M[\,&@O(#D`#B@&0(0_D``!*H8!+B@&0(0_D``!'H8`9#^0``$2@@`6H(1(`` -MD$````!"@_(Z1(#^(.*`9`;R,4BC.``&@P````Q*@&;L"!``'F<&\@`$(&`$ -M\@`$(_(`J``(@``)\@"(`&<(`*X```$(_X1,WP`\3G4``#__``"````````` -M`+__``"``````````````````````````(```````````````'__```````` -M`````/__`````````````'__``#__________S__``#)#]JB(6C"-;__``#) -M#]JB(6C"-4(N_[KI[@`&_QP,@````!=F!D[Y``!::#`N_QP"@````'\,@``` -M`#AL+.GN$`/_&.>(T(%#^0``><0B<00`0>[_-"(N_X`"@0```/_R/)`````` -M`$[14.[_M$YU""@`!P``9@AA``0.8``1!F$`!!9@`!#^""@`!P``9@`$"&`` -M`_0(*``'``!F``/"8``#K@@H``<``&8``\Q@``/`""@`!P``9@`#A&```W8( -M*``'``!F``/`8``#A`@H``<``&8`#W!@``-V\A#0@/(\6#C___*24(3R@0[L -M\CR(``````!@``].""@`!P``9@`#=F```TH(*``'``!F``\V#&@__P``9@!. -MM`RH@``````$9@!.J$JH``AF`$Z@\CI(`/Z,3G4(*``'``!G`$X$8``/`@@H -M``<``&8`#O@,:#__``!F`$3$#*B```````1F`$2X2J@`"&8`1+#R.D@`_DY. -M=0@H``<``&<`1()@``[$""@`!P``9@`.N@QH/_\``&8`1+X,J(``````!&8` -M1+)*J``(9@!$JO(Z2`#^$$YU""@`!P``9P!$?&``#H8``%O(```)[```"A(` -M``GD```)\```">P```GP```)Y```">P```GL```)[```">0```GH```)Z``` -M">@```GH0B[_A>GN``/_&.GN$`/_(`B```((@0`"Y0F"`$/Z_Z(B<10`3M%@ -M``_R8``/>&``#A02+O\T$"[_*+$!"`$`!V<&".X`!_^%"```!V<``CA@``)$ -M$B[_-!`N_RBQ`0@!``=G!@CN``?_A4HN_R!J"$'N_RA@`!`2\BZ0`/^`\BY( -M`/\H3G4``%O2```*L@``"M@```JJ```*M@``"K(```JV```*J@``"K(```JR -M```*L@``"JH```JN```*K@``"JX```JN0B[_A>GN``/_&.GN$`/_(`B```(( -M@0`"Y0F"`$/Z_Z(B<10`3M%@``\L8``.LF``#4X2+O\T$"[_*+$!"`$`!V<& -M".X`!_^%"```!V<``7)@``%^$B[_-!`N_RBQ`0@!``=G!@CN``?_A4HN_R!J -M"$'N_RA@``],\BZ0`/^`\BY(`/\H3G4``%YD``!>9```"VP```N0```+=``` -M"W0```ML```+D```"X(```N"```+;```"Y````MP```+<```"W````MPZ>X` -M`_\8Z>X0`_\@"(```@B!``+E"8(`0_K_IB)Q%`!.T6``#)1@``WP""X`!_\H -M9P``R&```-0(+@`'_RAG``""8```CF``#D8(+@`'_S1G"/(Z2`#[Z&`&\CI( -M`/O4\CG00```!V1@`&:,\CI(@/OR80!F@O(Z2`#[Z&``##HM;O\T_XPM;O\X -M_Y`M;O\\_Y0([@`&_Y#R+M!`_XQA`&968``-ZO(Z2`#[Q&``#4CR.D@`^\8` -MK@@```#_A&``#3;R.D@`^X0`K@(```#_A$YU\CI(`/N``*X*````_X1.=?(Z -M2`#[-$YU\CI(`/LX`*X(````_X1.=?(Z2`#[-`"N!````/^$3G7R.D@`^S`` -MK@P```#_A$YU```-C@``#9(```V2```.+```#BP```V2```-G```#9P```WT -M#"\````!9P``J@PO`"@``6=P#"\`,``!9V@,+P!@``%F____\U9#[P$D(V[_ -M-/\T(V[_./\X(V[_//\\(V[_'/\<("[_'`*``\,``.GN$T'_'.N)2$&`@>GN -M$H/_'.6)2$&`@2-`_Q#R`*@`@:[_A"-N_X3_``"I`8```/\D8``!Z@PO`"@` -M`68&0^\`[&`0#"\`,``!9O____+@0^\`]"-N_QS_'/(`J`"!KO^$8``!NEB/ -M\@"H`(&N_X0,+P!@``%F'$)N_Q0(+@`%_QQF'"UN_X3_``"N`8```/\D8`P, -M+P`H``%G!$)N_Q00+O^"P"[_ANW`%@A!^O[B!`$`&"!P%`!.T&```6(([@`" -M_R1@``!02B[_N680".X``?\D"*X``O\D8```.DHN_[=F!@CN``'_)`BN``+_ -M)"`N_QP"@`/#``#I[A-!_QSKB4A!@('I[A*#_QSEB4A!@($M0/\0"*X`!?\E -M8``!``@N``'_@F<*""X`!/^&9P)@)DHN_[EG"$HN_[=F``#@3.X#`_]`\B[0 -M\/]0\BZ<`/^`3EY@``%&2B[_N6KO^['WP`8``!(V[_C/[T(V[_ -MD/[X(V[_E/[\Z>X$1/^$[^D!!/\5(V[_A/\``*D!@```_R1,[@,#_T#R+M#P -M_U#R+IP`_X#S7THN_[=G```&80``2DY>"!<`!V8,"!<`!F8&8/____""Z.\` -M!``&9@``(%E/+J\`!"]O``@`!)[\`&3S%_(OI```;/-7WOP`9#]\("0`!F#_ -M___P3DY5``#S)PP7`$%G```N;@``7DHO``%F``!*0I:Q`````DUV-W:JH -MK!<__P``@`````````!``@``H`````````!`!0``R`````````!`#```G$`` -M``````!`&0``OKP@``````!`-```CAO)OP0```!`:0``G<6MJ"MPM9Y`TP`` -MPG@?2?_/IM5!J```D[I'R8#IC.!#40``JG[K^YWYWHY&HP``XQF@KJ8.D<=- -M2```R79UAH%U#!=:D@``GHL[7<4]7>5U)0``Q&!2`HH@EYL__@``L7(7]]'/ -M>:M`````DUV-W:JHK!8__P``@`````````!``@``H`````````!`!0``R``` -M``````!`#```G$````````!`&0``OKP@``````!`-```CAO)OP0```!`:0`` -MG<6MJ"MPM9U`TP``PG@?2?_/IM5!J```D[I'R8#IC-]#40``JG[K^YWYWHU& -MHP``XQF@KJ8.D<9-2```R79UAH%U#!=:D@``GHL[7<4]7>5U)0``Q&!2`HH@ -MEYH__@``L7(7]]'/>:Q`````DUV-W:JHK!<__P``@`````````!``@``H``` -M``````!`!0``R`````````!`#```G$````````!`&0``OKP@``````!`-``` -MCAO)OP0```!`:0``G<6MJ"MPM9Y`TP``PG@?2?_/IM9!J```D[I'R8#IC.!# -M40``JG[K^YWYWHY&HP``XQF@KJ8.D<=-2```R79UAH%U#!A:D@``GHL[7<4] -M7>9U)0``Q&!2`HH@EYM"+O^X2B[_N6X` -MP_\<#````V<``-AA``$\2B[_N&=<""X`!_\@9U1@.NGN``;_'`R`````%V8` -M``1.=0@N``+_)&8``*@0+O\8@"[_(&L"3G4(+@`'_R!G(F$``/A*+O^X9Q@P -M+O\H`D!__V<.0>[_*&$``08=;O^L_R`(+@`'_QAG``#.""X`!?\89APP+O\T -M`D!__V<``+I![O\T80``VAUN_ZS_&$YU""X`!/\<9@8R/#^!8`0R/#P!""X` -M!_\T9P0(P0`//4'_-#(N_QP"0>/_`$$(`#U!_QQ![O\T80``F!UN_ZS_&$YU -M+6[_,/\T80``8&$``2!*+O^X9U+I[@&#_QQR!Y*`0H`#P/(N^`#_*`@N``?_ -M(&8`_T@0+O\@`@``\$H`9B@P+O\H`D!__PQ`/_]L&@`N`!#_(&`20B[_N.GN -M`0+_'`P```-F`/\^3G4P+O\<"```!6<6"```!&<*`D``?PQ``#AF!E#N_[A. -M=4(N_[A.=4*N_ZP(J``'``!6Z``"#"X`+``+9@9A``!J8!((+@`%_QQF!F$` -M`$!@!&$``"`,:#__``!N!@CN``3_K.SH``@``F<&".@`!P``3G5A`!TH""@` -M!P`$9@P`;@"`_ZP([@`#_X9.=6$`'0X(*``'``1G"``N``#_K$YU`"X`@/^L -M3G5A`!SR""@`!P`$9P@`+@``_ZQ.=0`N`(#_K$YU,"[_'`)``#MG``"F,"[_ -M-.G`%0P,00__9C#IP!1##$$`!V8F2J[_.&8*2J[_/&8$8``!7@@N``;_.&8` -M`50`K@$`0(#_A&```4@P+O\V`D``#TI`9@``/$JN_SAF```T2J[_/&8``"Q* -MKO\T;!0M?(````#_-$*N_SA"KO\\8``!$$*N_S1"KO\X0J[_/&```0#R)^`# -M80#O0/(N:`#_-/(?T,#R/(@``````&```.(P+O\TZ<`5#`Q!#_]FX``O^#"*@`!P``5N@``F$`;';LZ``( -M``)G#`CH``<```CN``?_C/(0T(!.=0"N```02/^$+6[_-/^,+6[_./^0+6[_ -M//^4$"[_@P(``,!G```^#```0&862B[_/&8>("[_.`*`````_V828```(B`N -M_SP"@```!_]G```4`*X```(`_X1@"`"N```22/^$""X`!/^"9R1"KO^,0J[_ -MD$*N_Y3L[@%#_Q@(K@`$_R$([@`'_QD(K@`"_R1A`&@B[.X`"/\V9PP([@`' -M_S0([@`'_XSR+M"`_S1.=0"N```""/^$3G4`K@```@C_A`@N``/_AF<&".X` -M!?^'3G4(+@`'_RAG!@CN``/_A`@N``;_+&X``O^#9A`(*``'``!G)`CN``/_ -MA&`<"*@`!P``5N@``F$`:ACLZ``(``)G!@CH``<``/(0T(!.=4Y2_T#S)THO -M``%G``"*""H``O\D9P``>@@J``?_(&K_*`@H``<``%;H``((J@`'_R!A -M`!>>"*@`!P``[.@`"``"9P8(Z``'```(*@`'_QAG/$'J_S0(*``'``!6Z``" -M"*H`!_\880`7:@BH``<``.SH``@``F<&".@`!P``%7P`_O[D0FK_%`BJ``+_ -M)/-?3EI.=5B/3EI.=0``/X%`?C]J```\`4/^.\T``$(N_[9"+O^W0B[_NDHN -M_[AG0`@N``?_(&[_*`BH``<``%;H``)A`!;\"*@`!P``[.@`"``"9P8( -MZ``'``#L[@`$_R`([@`$_R``+@`/_[9![O\T""X`!?\<9@`.D@@N``?_&&8` -M`M9*+O^X9@`#(#`N_QP"@````'\(````9@`##E#N_[HP+O\<`@``.TH`9_\` -M``">#```&&?_````;@P``!IG_P```'@P*```"(``#U;H``)G"`"N"````/^$ -M#$!__V8F2J@`!&802J@`"&8*`*X"````_X1.=0"N`0```/^$+6[_-/\H3G5* -MJ``$9O\````62J@`"&;_````#`"N!````/^$3G40+O\8"```!68`#,`(J``' -M``!@$A`N_Q@(```%9@`,K`AH``<``!`N_Q@"``#@9@`,F@@N``+_'68``"`( -M+@`&_QUF``!HZ>X``O^#2@!G``&X#````6<``%1P`C(H```"07__#$$\`6,` -M`)CI[A""_X,`@0`"``!"@`BH``<``%;H``)A_P``$X+LZ``(``)G!@CH``<` -M`#(H```"07__#$%#_VP``%1@``%><`$R*````D%__PQ!/X%C``!&Z>X0@O^# -M`($``0``0H`(J``'``!6Z``"8?\``!,P[.@`"``"9P8(Z``'```R*````D%_ -M_PQ!0']M``$080#[3&```0@(J``'``!6Z``"80`59.SH``@``F<&".@`!P`` -MZ>X0@O^#""X``O\=9@``&@@N``;_'68``!I(01(N_X/L"4A!8```$@"!``(` -M`&````@`@0`!```(J``'``!6Z``"8?\``!*F[.@`"``"9P8(Z``'```(+@`! -M_X9G"`"N````(/^$2J@`!&9F2J@`"&9@("[_@`*`````,`R`````(&TX9A!* -M:```;#`(+@`'_X-G'&`.2F@``&T@""X`!_^#9PP`J```"```"&```"0`J``` -M`0``!&```!@`K@0```#_A!`N_Q@"``#@#```0&<(`*X```@`_X0M4/\T+6@` -M!/\X+6@`"/\\2F@``&<(#&B`````9@@`K@0```#_A$IH``!J``JF`*X(```` -M_X1@``J:2B[_N&88,"[_'`*`````?P@```!F"%#N_[I@``!4"*@`!P``5N@` -M`F$`$[X(J``'``#LZ``(``)G!@CH``<``.SN``3_&`CN``3_&``N`/#_MDHN -M_[9F``)J'7P`_O[D"*X``O\D0F[_%%#N_[=.=5#N_[HP+O\<`@``.TH`9_\` -M``"&#```&&?_````;@P``!IG_P```&PP*```"(``#U;H``)G"`"N"````/^$ -M#$!__V8F2J@`!&802J@`"&8*`*X"````_X1.=0"N`0```/^$+6[_-/\H3G5* -MJ``$9O\````62J@`"&;_````#`"N!````/^$3G4(J``'``!@!@AH``<```@N -M``+_'68``"`(+@`&_QUF```ZZ>X``O^#2@!G``!2#````6<``";I[A""_X-* -M:```;0P,`0`#9@``4F```'(,`0`"9@``BF```++I[A""_X-*:```;0P,`0`# -M9@``QF```.8,`0`"9@``_F```28`K@``"`#_A$IH``!G``D4`*X(````_X1@ -M``D((7P\`0````!"J``$0J@`"`"N!````/^$`*X```HH_X1@``CD(7P\`0`` -M``!"J``$(7P```@```@`K@``"BC_A&``",0A?+P!`````$*H``1"J``(`*X$ -M````_X0`K@@```#_A`"N```**/^$8``(F"%\O`$`````0J@`!"%\```(```( -M`*X(````_X0`K@``"BC_A&``"'`A?#^!`````$*H``1"J``(`*X$````_X0` -MK@``"BC_A&``"$PA?#^!`````"%\```!```$0J@`"`"N```**/^$8``(+"%\ -MOX$`````0J@`!$*H``@`K@0```#_A`"N"````/^$`*X```HH_X1@``@`(7R_ -M@0`````A?````0``!$*H``@`K@@```#_A`"N```**/^$8``'V&<`_98P+O\< -M`D``.PQ``")G``$D#$``*&<``W0,0``C9P`&/`Q``#AG``7`#"X`__^V9P#] -M9`PN``__MF9P8?\````^9@#]4NGN`$__-.ON$$__*)"!#(```'__;0#].D(N -M_O8P+O\T,B[_*+-``D"``&<`!CA0[O[V8``&,!`N_QA@```&$"[_(`(``&`, -M``!`9P``%@P``&!G```.#```(&<```9"@$YUX``O^#8?\``%].[.X`"/[V9P`&+@CN``?^]&``!B0,+@#__[9G`/Q:#"X` -M#_^V9B9A_____S1F`/Q(Z>X`3_\TZ^X03_\HD($,@```@`!M`/PP8```)&'_ -M____%F8`_"+I[@!/_RCK[A!/_S20@0R```"``&T`_`HP+O\T,B[_*+-``D"` -M`&<``/(,+@`/_[9F=#`N_R@"0(```$`__SU`_R@@+O^``H`````P\@"0`/(N -M2`#_-/(N2"+_*$'N_O3R`:@`@Z[_A/(N:`#^].B((B[_@`*!````P.R)2$&" -M@$*`"*X`!_[T5N[^]F'_```-#NSN``C^]F<`!/X([@`'_O1@``3T,"[_-`)` -M@```0#__/4#_-"`N_X`"@````##R`)``\BY(`/\T\BY((O\H\@&H`(.N_X1! -M[O[T\BYH`/[TZ(@B+O^``H$```#`[(E(08*`0H`(K@`'_O16[O[V8?\```R: -M[.X`"/[V9P`$B@CN``?^]&``!(`,+@`/_[9F;$'N_S0@+O^``H`````PZ(@B -M+O^``H$```#`[(E(08*`(#P@````"*X`!_\T5N[_-F'_```,2.SN``C_-F<& -M".X`!_\T0>[^]""N_S0A;O\X``0A;O\\``A*;O\T;@``=@"N"````/^$8``` -M:D'N_R@@+O^``H`````PZ(@B+O^``H$```#`[(E(08*`(#P@````"*X`!_\H -M5N[_*F'_```+W.SN``C_*F<&".X`!_\H0>[^]""N_R@A;O\L``0A;O\P``A* -M;O\H;@``"@"N"````/^$,"[^]`)`?_\,0'__9@`#E`"N`@`02/^$0J@`!&`` -M`X0,+@#__[9G`/H"#"X`#_^V9B9A_____-QF`/GPZ>X`3_\TZ^X03_\HD($, -M@```@`!M`/G88```)&'____\OF8`^[^]/(N:`#^].B( -M(B[_@`*!````P.R)2$&"@$*`"*X`!_[T5N[^]F'_```*MNSN``C^]F<``J8( -M[@`'_O1@``*<,"[_-`)`@```0#__/4#_-"`N_X`"@````##R`)``\BY(`/\H -M\BY(*/\T\@&H`(.N_X1![O[T\BYH`/[TZ(@B+O^``H$```#`[(E(08*`0H`( -MK@`'_O16[O[V8?\```I"[.X`"/[V9P`",@CN``?^]&```B@,+@`/_[9F<$'N -M_S0@+O^``H`````PZ(@B+O^``H$```#`[(E(08*`(#P@````"FZ``/\T2F[_ -M-&X(`*X(````_X0(K@`'_S16[O\V8?\```G<[.X`"/\V9P8([@`'_S1![O[T -M(*[_-"%N_S@`!"%N_SP`"&```&I![O\H("[_@`*`````,.B((B[_@`*!```` -MP.R)2$&"@"`\(`````BN``?_*%;N_RIA_P``"8#L[@`(_RIG!@CN``?_*$'N -M_O0@KO\H(6[_+``$(6[_,``(2F[_*&X```H`K@@```#_A#`N_O0"0'__#$!_ -M_V8``3@`K@(`$$C_A$*H``1@``$H#"X`__^V9P#WI@PN``__MF8L8?____J` -M9@#WE.GN`$__-.ON$$__*)"!#(```(``;0#W?$IN_S1L```P3G5A____^EQF -M`/=HZ>X`3_\HZ^X03_\TD($,@```@`!M`/=02F[_*&T```1.=0"N"````/^$ -M3G4,+@#__[9G``!&#"X`#_^V9B!A____^@QF`/<@Z>X`3_\TZ^X03_\HT(%N -M`/<.8```'F'____Y]&8`]P#I[@!/_RCK[A!/_S30@6X`]NX(K@`"_R0`K@`` -M"BC_A$)N_Q1"+O[V,"[_-#(N_RBS0`)`@`!G!%#N_O9![O[T,"[_'`@```9G -M#@@```)F!'`!8`IP`F`&Z>X``O^#8?\``%Q:[.X`"/[V9U(([@`'_O1@``!* -M,"[_'`@```9G#@@```)F!'`!8`YP`F`*Z>X``O^#2@!G)@BN``?^]%;N_O9A -M_P``62[L[@`(_O9G!@CN``?^]`"N```22/^$Z>X!@_\<#````V\0<@>2@$*` -M`\#R+M@`_O1.=0P```!G2`P```%G+@P```)G%"UN_O3_="UN_OC_>"UN_OS_ -M?$YU+6[^]/]H+6[^^/]L+6[^_/]P3G4M;O[T_UPM;O[X_V`M;O[\_V1.=2UN -M_O3_4"UN_OC_5"UN_OS_6$YU""X`!O^&9R`(+@`&_X)G&"UN_S3_*$HN_S1M -M`DYU`*X````#_X1.=4)N_Q0(K@`"_R00+O\8`@``X`P``$!F&@"N`@```/^$ -M2F@``&Q.`*X(````_X1@``!$#```8&8@`*X!````_X0M;O\T_RA*:```;"@` -MK@@```#_A&```!X,```@9A8`K@0```#_A$IH``!L"`"N"````/^$Z>X!@_\< -M#````V\0<@>2@$*``\#R+M@`_S1.=0P```!G2`P```%G+@P```)G%"UN_S3_ -M="UN_SC_>"UN_SS_?$YU+6[_-/]H+6[_./]L+6[_//]P3G4M;O\T_UPM;O\X -M_V`M;O\\_V1.=2UN_S3_4"UN_SC_5"UN_SS_6$YU4.[_NC`N_QP"0`P`#$`, -M`&<`!5A@```B```K*@``+78``"U:```JT```*[P``"VH```L.@``*M#I[A## -M_QQ!^O_8('`<`$[0""X``?^&9PX(+@`#_X9G!@CN``7_AT)N_Q0(K@`"_R3R -M/(@``````.SN``C_-F<&".X`!_\T3G5";O\4"*X``O\D\CR(``````#L[@`( -M_S9G!@CN``?_-$YU<`0(+@`'_QAF``&$\B[0@/\T\CQ4.$'?____P```\I,` -M,O(\5#C!X````````/*5`$(B+O^``H$````P\@&0`/(N8`#_K/(!J`"#KO^$ -M8``!DBU\?_____^L\H$!AO(\5#A!W____^```/*3`6A@``%:+7R`````_ZSR -M@0%F\CQ4.,'@````$```\I0!2&```3IP`@@N``?_&&8``/+R+M"`_S3R/$0X -M3HW__/*3`"[R/$0XSF0``/*5`#PB+O^``H$````P\@&0`/(N<`#_K/(!J`"# -MKO^$8``!"#U\?___K/*!`/[R/$0X3HW__O*3`.1@``#6/7R``/^L\H$`Y/(\ -M1#C.8__^\I0`RF```+QP`0@N``?_&&8``'3R+M"`_S3R/$0X3H7\`/*3`"[R -M/$0XSG0``/*5`#PB+O^``H$````P\@&0`/(N>`#_K/(!J`"#KO^$8```BAU\ -M`'__K/*!`(#R/$0X3H7^`/*3`&9@``!8'7P`@/^L\H$`9O(\1#C.<_X`\I0` -M3&```#XM?`````#_K.GN$(+_@PP!``)K*&802F[_-&H@+7S______ZQ@%DIN -M_S1K$$/N_ZS3P)/\`````0C1````K@```@C_A&`.\B[P@/\H`*X``""`_X0B -M;@`,2HEG#D'N_ZQA____TN9@`/WH+P!A_P``5@H"0``'(A\,@0````1G$`R! -M`````F8.`(`````(8`8`@````!`B`&'_``!9-F``_;!![O\T"*@`!P``5N@` -M`@@N``?_&&8``*Q"@&!B0>[_-`BH``<``%;H``((+@`'_QAF``$$,"@``$/Z -M[?2P46T``**P:0`";@`!2G`!8#!![O\T"*@`!P``5N@``@@N``?_&&8``0`P -M*```0_KMRK!1;0``FK!I``)N``%4<`+I[A""_X-(0-*`0H!A_P```L8B2"!N -M``SI[A##_QP,`0`";A9F"F'_``!B`&``_,IA_P``889@`/S`8?\``&$,8`#\ -MMF$``7@([@`$_R$B2"!N``QA_P``8=(([@`#_X9@`/R6".X`!/\8L&D`!&U( -M<`$B/```/X%A_P```1)A_P``83@([@`#_X9@`/QL".X`!/\8L&D`!&U,(CP` -M`#P!<`)A_P```.AA_P``8)X([@`#_X9@`/Q"+R[_A'`!8?\``%94+5__A'`! -MD6@``")((&X`#&'_``!@X@"N```**/^$8`#\%"\N_X1P`F'_``!6)BU?_X1P -M`9%H```B2"!N``QA_P``8$0`K@``"BC_A&``^^8O+O^$<`%![O^,(*[_-"%N -M_S@`!"%N_SP`"&'_``!2_"U?_X0B2"!N``QA_P``8'@`K@``$DC_A&``^ZHO -M+O^$<`)![O^,(*[_-"%N_S@`!"%N_SP`"&'_``!2P"U?_X0B2"!N``QA_P`` -M7\P`K@``$DC_A&``^VXO`$*`8?\```1,Z>X0@O^#2$$R+P`"2$%A_P```2XP -M/``!D6@``")((&X`#-[\``1.=2UH``#^]"UH``3^^"UH``C^_.SN``C^]F<& -M".X`!_[T[.X!1/\83G4``#`<```P4```,&0``#!X```P'```,(0``#"*```P -MD```,)0``#"8```PG```,*```#"F0?K_RC`N_QCIP`0#('`$`$[0<`PB;@`, -M80#/]!U\``#^Y.SN``/_($YU,"[_'`@```QG#NG`!D-!^O^F('`,`$[0`D`` -M?^O`!D=![O\T8?___]`N0>[_C&#_____N$'N_S1":``"0J@`!$*H``A@`/^B -M\CR(``````!![O\T0F@``F``_XY![O\T0F@``F``_X(@+O]`8*H@+O]$8*0@ -M`F"@(`-@G"`$8)@@!6"4(`9@`/^0(`=@`/^*87I*@&8```A(06```80`K@`` -M`@C_A$/Y```PSB)Q%`!.T0``,10``#$.```P]@``,-Y(04HH``)K``%6.` -M9``!(D/Y```QB")Q%`!.T4A!#$$``&8"8%)(YS``#$$``68BZ>@V`@`$=![E -MJR0H``0"@@```#]F*$JH``AF(DJ`9AY@(.GH-4(`"'0>Y:LD*``(`H(```'_ -M9@9*@&8"8`0(PP`=(`-,WP`,2$%.=0``,<8``#&8```Q\@``,?(&J````0`` -M!&0,Y.@`!.3H``92:```2H!F!@)H_@``!@*H____```$0J@`"$YU4J@`"&0: -M4J@`!&04Y.@`!.3H``;DZ``(Y.@`"E)H``!*@&8&`B@`_@`+3G4&J```"``` -M"&0:4J@`!&04Y.@`!.3H``;DZ``(Y.@`"E)H``!*@&8&`FCP```*`JC___@` -M``A.=4YU```R1@``,;@``#(@```R($/Z_^XB<10`3M%.=3`H```,0`!`:P9A -M``!J3G5(YS8`(B@`!"0H``CMP3``9S"P0VL*80``3DS?`&Q.=2P"X:KAJ7H@ -MFH#JKH*&<``Q0```(4$`!"%"``A,WP!L3G7MPC``9Q(&0P`@L$-KT&$``!1, -MWP!L3G4Q?`````!,WP!L3G4O!^WH<```!&&J(`(D'RUH``C_I"U`_Z@@`9)H``!O$`Q!`"!M$@Q! -M`$!M8&```+Y"`2`N_ZA.=2\",4```'`@D$'IZ"@```#IPBA@Z>@8```$Z>X( -M`/^D(4(`!"%!``A"`>C``)YG!@C``!U0P20N_Z@"@N````!*@F<&`(`@```` -M`H#@````)!].=2\",4````1!`"!P()!!Z>@H````Z<(H8.GH&```!.C!`)YF -M#NCN"`#_I&8&(`%"`6`((`$(P``=4,%"J``$(4(`""0N_Z@"@N````!*@F<& -M`(`@`````H#@````)!].=3%```!*:``";`@`J(````````Q!`$!G&`Q!`$%G -M(D*H``1"J``((#P@````4,%.=2`H``3IP!">`H#`````8!`@*``$Z<`07P*` -M@````.*(2H%F$$JH``AF"DHN_ZAF!$(!8`8(P``=4,%"J``$0J@`"$YU0``` -M`,D/VJ(A:,(U`````#__``#)#]JB(6C"-0````#R`9``\CI(`/_H8`#C_O(0 -M2``@$#`H``0"@'____\,@#__@`!L./(\1(!.?@``\@``HO(``!KR/$0B3GX` -M`/(`!"#R```$\A#P@"\!0H%A``FL\A^0`/(``")@`..N\@``&/(\1#A.?@`` -M\I+B5B`0,"@`!`R``````&X6\CI(`/]@\@&0`/(\1")+````8`#C>O(!D`#R -M/$0``````$YU/_\``,D/VJ(A:,(U`````&``Y$KR$$@`(!`P*``$`H!_____ -M#(`__X``;#CR/$2`3GX``/(``*CR)^`$\CQ%`$Y^``#R``$B\@`(H_(?T"#R -M``2$\@`$(/(0\(!A``C^8`#C"/(``!CR/$0X3GX``/*2X;#R.D@`_X@@$`*` -M@`````"`/X```"\`\@&0`/(?1"-@`.+6```_^X``0`+__S^`````````O_9H -M?C%)A]A``JQI-*)ML[_"1V].':*./[-$1'^':8F_MT3N?Z]%VS^\<<9&E`(@ -MO\))))(8X/\F9F9F6)CZ_U5555555-C__``#)#]JB(6C"-0````"__P``R0_:HB%H -MPC4```````$``(```````````````(`!``"````````````````_^P``@]%2 -MQ08+>E$`````/_L``(O(5$5E28N+`````#_[``"3OD!@%V)K#0`````_^P`` -MF[,'C36NP@(`````/_L``*.FFE)=W.?>`````#_[``"KF.E#8G96&0`````_ -M^P``LXGE`OG%F&(`````/_L``+MY?D-K">;[`````#_[``##9Z7'.>7T1@`` -M```_^P``RU1,8<_WU<8`````/_L``-,_8O@DB%,^`````#_[``#;*-J!8D!, -M=P`````_^P``XQ"D!XK33Q@`````/_L``.KVL*@8CN'K`````#_[``#RVO&4 -MG;YYU0`````_^P``^KU8$V'4?CX`````/_P``(-&K"$)6>S$`````#_\``"+ -M(RH(,$*"V``````__```DOMPN-*:XOD`````/_P``)K/1V]]%/I`.I0`````__```P:A?',=>/J4`````/_P``,E=&^@H$XWF -M`````#_\``#1"_,`A`TMY``````__```V+2RNFO`7GH`````/_P``.!7*FNT -M(S7V`````#_\``#G\RIPZIRJCP`````__```[XB$,F3L[ZH`````/_P``/<7 -M"BCLP&9F`````#_]``"!+]*(,RVM,@`````__0``B*C1L2&.360`````/_T` -M`)`2JS\CY*[H`````#_]``"7;,/4$>?QN0`````__0``GK:)23B)HB<````` -M/_T``*7OS$L``````__@``ND2\?=1P>"\`````/_X``+ZI043]!)JL`````#_^``#" -MZTJ[9A8HM@`````__@``QPO53.8"[A0`````/_X``,T`!4FM['%9`````#_^ -M``#4A%?2V.I.HP`````__@``VY2-IQ+>SCL`````/_X``.(X5?EIZ`EJ```` -M`#_^``#H=Q$IQ#4R60`````__@``[E?!;@TWG`T`````/_X``//A`A&H?#=Y -M`````#_^``#Y&0.==8N-00`````__@``_@6+CV237[,`````/_\``(%5^TE[ -M:%T$`````#__``"#B)XU2=$(X0`````__P``A9SZ=E$=5 -M+L__@3'G`````#__``")+JY2@0`````__P``DBVGUY&(A(<````` -M/_\``)31G\O>WU)!`````#__``"7.KE$&=*@BP`````__P``F6_P#@CA"Y8` -M````/_\``)MW/Y42,AVG`````#__``"=5LH:V@`````__P``MS:NIZ:26#@`````/_\``+?/JRA^GWLV`````#__ -M``"X7LQFRR&8-0`````__P``N.3]6B"ED]H`````/_\``+F?0?9*_YNU```` -M`#__``"Z?QX7A"N^>P`````__P``NT<2A78WX7T`````/_\``+OZOHI'B-]O -M`````#__``"\G0^M*VB=>0`````__P``O3!J.4<>S88`````/_\``+VVQS&% -M:O&*`````#__``"^,:G`````&``VP+R$$@`(!`P*``$\BYH`/^,`H!_____#(`_ -M^X``;`1@``#,#(!``O__;P1@``%$/7P``/^.`J[X````_Y``K@0```#_D"U\ -M`````/^4\@``@/(N2*/_C/(N2"C_C/(\1*).?@``\@`$("\")``"@```>``" -M@G__```$@C_[``#B@M""[H!#^O=VT\`M6?^<+5G_H"U9_Z0@+O^,`H"````` -M@:[_G"0?\@``@/(`!*/R.E4`]IKR``4B\@`%(_(``*/R.E4B]I#R.E2C]I+R -M``BC\@`$(O(!D`#R+D@B_YQ@`-DN#(`__X``;@``A@R`/]>``&T``&CR```C -M/7P``/^.\@``@/(`!*/R.E4`]ECR.E6`]EKR``4C\@`%H_(Z52+V5/(Z5:+V -M5O(`!2/R``RC\CI5(O90\CI4HO92\@`!(_(N2"/_C/(`"*+R``0C\@&0`/(N -M2"+_C&``V+0]?```_X[R`9``\BY(`/^,8`#8H`R`0&.``&X``(3R/$2`SH$` -M`/(``*#R``0`\@``(_(N:(#_C/(``(#R``2C\CI5@/7T\CI5`/7V\@`%H_(` -M!2/R.E6B]?#R.E4B]?+R``RC\@`!(_(Z5*+U[/(N2"/_C/(`"*+R``0C\BY( -M(O^,\@&0``@0``=G"O(Z2"+UX&``V![R.D@B]<9@`-@4"!``!V<4\CI(`/7& -M\@&0`/(Z2"CUW&``U_KR.D@`]:+R`9``\CI(*/6X8`#7Y@``8`#8TB`0,"@` -M!`*`?____PR`/_^``&Q$\A!(&/(``(#R``2:\@``(O(\1*).?@``\@`$("`0 -M`H"``````(`_````+P#R$/"`+P%"@6$`%W+R'Y``\A]$(V``UXCR$$@8\CQ$ -M.$Y^``#RDM8P8`#5UD#&+3C3UD8T/6^0KK'G7,=_^P``@``````````````` -M\CQ$`$Y^``#R`9``\CQ$(DL```!@`-<\\A!(`"`0,"@`!`*`?____PR`0`RQ -M9VXR\@``&"\!0H'R$/"`80`%/O(\1"-.?```(A_R/$2`3GH``/(``*#R`9`` -M\@`$(F``UO(,@$`,LK-N*O(``!CR.E0H_V[R.E0H_W`O`4*!\A#P@&$`!/CR -M'Y``\CI((_]B8`#6P/(\B```````")``!_(0T(!@`-9./]P``(+C"&5#8<3& -M`````#^E5555540Q/\5555550!A__@``__________\```````$``/______ -M____`````#^!$1$1%T.%/Z5555553UH_Q555555550``````````/L<=XZ5W -M1H(^^@&@&=?+:#\J`:`:`9WS/U;!;!;!<.(_@1$1$1$1$3^E55555555/_P` -M`*JJJJJJJJJK`````$BP````````-S`````````__P``@``````````````` -M/_\``(%DT?.\`P=TGX0:FS__``""S8:8K"NAV)_!U;D__P``A#HHPZS>0$B@ -M0@6F/:/_\``(ZD.8M%S5/`'K<`43__``"0,=Q#%&:QW!]NL"D__P`` -MD!24/_\``)-:*R\3YNDLGK,9L#__``"4].^H_O<)8"`717T_ -M_P``EI0M-R`86@`?$=4W/_\``)@W\%&-N*EPG[E2W3__``"9X$63(+?Z9!_D -M,(<__P``FXTYN=5.53@?HJ@8/_\``)T^V:]3)@D:$1 -MK"!02)`__P``H+!1#[EQ3\2@:`H*!Y<28__P``I?[6J;%1..R@<:%`/_\``*?-D[3I935H($]BVC__``"I -MH5JTZGP.^!\H/$H__P``JWHYM:D^TSB?FG_ -MYIHO/_\``-F=%<)XK]>T(']#GS__``#;^[>7VO(W5"`>P@<__P``WF#T@EX. -MD22>B^%U/_\``.#,WNPJE.$0(`,L2S__``#C/XEROHI:4"`$W_4__P``Y;D& -MYWR#2*@>='/(Z22/ZLO(` -M!"+R``@B\@``@/(`!*/R/$4`3FK8+O(`!2/R``6`\CQ%HTYP(B+R.E4B^I3R -M.E6B^I;R``4C/4#_C$)N_XXM?(````#_D$*N_Y3R``6C\CQ%(DY\``#R``&C -M\@`%(_(`#"+R&4B`\@`((O(`!"/R']`P\A%$(O(`!"(@+O^P2H!G!O(N2"/_ -MG/(!D`#R+D@C_XQ@`-#$\A#0@/(!D`#R/$0B3GX``&``T+`,@$`,LGQN:O(0 -M2`#R``"`\CQ$(TZ%<53R)^`,+7P````!_[#R`&``0_KZBO(`0``M0/^L`H`` -M```_Z8C3P"`N_ZSL@"U`_ZSB@)&N_ZP&0#__/4#_G$)N_YXM?(````#_H$*N -M_Z0@+O^L!D`__V``_M+R`9``(!`(D``'#(``````;0#/`F``S\A@`-$4(!`" -M@'__```,@#_]``!L!&```5@P*``$#(!`!,(5;P1@``):\A!(`/(``(#R/$0C -M3H5Q5/(GX`SR`&``0_KYZ/(`0``M0/^L`H`````_Z8C3P"`N_ZSL@"U`_ZSR -M``$`\CQ$(\Z'G1SR.DDC^0KR``0B\@`((@9`/__R``"`\@`$H_(\10!.94`F -M\@`%(_(`!8#R/$6C3FK8+O(Z52+Y&/(Z5:+Y&CU`_\!";O_"+7R`````_\1" -MKO_(\@`%(R`N_ZQ$0/(`!:,&0#__\CI5(OCV\CQ%HDY\``#R``4C`$"``#U` -M_]!";O_2+7R`````_]1"KO_8\@`,H_(``2/R``0B\@`((O(?T##R$4@C("[_ -MK`R`````/V\6\BE$@``,\BY(HO_0\@`$(O(12")@+`R`_____6P2\BE$(@`, -M\A%((O(N2"+_T&`2\AE(@/(11"+R+DBB_]#R``0B\@&0`/(N2"/_P&``SK@, -M@#^^``!L8`R``#,``&TF+7R``0``_\`M?(````#_Q$*N_\CR$$@`\@&0`/(N -M2"+_P&``SH+R$$@`\CI4(_AN+7R``0``_\`M?(````#_Q$*N_\CR+D@B_\#R -M`9``\CI4(_A28`#.4/(02`#R```C\B?@#/(\1(!./,,K\@``H_(\10!.1#X* -M\CQ$HDY+7,GR``$C\@``H_(\12).4D_*\CI4HO?(\@`!(_(``*/R.E4B]\+R -M.E2B]\3R``$C\@``H_(Z52+WOO(Z5*+WP/(``2/R``"C\CI5(O>Z\CI(HO>\ -M\@`!(_(``*/R``$C\A!(H_(\1"-.?```\@`(HO(?T##R``0B\@&0`/(02")@ -M`,VF(!`,@`````!N`/O8\CQ$`,Z!``#R`9``\CQ$(DL```!@`,V"```P*``` -M"(``#P1`/__R`%``3G4(J``'``!A`.;8,"@```1`/__R`%``3G4@+O^``H#_ -M__\`\@"0`#`H````0'__"(``#C%```#R$$@`3G4@*``$(B@`"&$```PA0``$ -M(4$`"&#&2H!F%$J!9@)@*"\#P4'MP#``YZ@F'V`:2.<6`.W`,`#GJ"P!YZEZ -M()J#ZJZ`ADS?`&A.=>GN$(+_@RU!_ZQ@5@@N``7_@V<`N[0(+@`$_X-G$`@H -M``<``&8@80"_H&``S+`(*``'``!G"&$`OYA@`,R@80"_H&``S)AA`+^H8`#, -MD"U\`````?^L8`KI[A""_X,M0?^L"*@`!P``5N@``@QH0#X``&Y>#&@__0`` -M;@``?`@N``'_KVP`/(\D```````\BA(````\A^0`$YU0H`B/```0#YA -M`.90(B[_K&$`XSYA`.5,[.@`"``"9P8(Z``'``#R)[``\CR0``````#R*$@` -M``#R'Y``3G4``#_]``#>6]BI-RAQE0`````__P``N*H[*5P7\+P`````(!!M -M``":+P%"@6$`"3CR'Y``\CI((__*8`#+="`0;0``?B\!0H%A``FF\A^0`/(Z -M2"/_KF``RU@@$&T``&(O`4*!80`)`/(?D`#R.D@C_Z)@`,L\(!!M``!&("@` -M"&8H("@`!`*`?____TJ`9AHP$`*```!__P2````___(!D`#R`$``8`#+""\! -M0H%A``E`\A^0`/(Z2"/_6&``RO)@`,FF```__O!]/_^(03_^@``__\``/_X` -M`+%R%_?1SWFL`````#^`````````?X```+^````_PDF:M>0$"[_%5;6$C+?; -M/\F9F9A]AS"_S____V]^ES_55555556DO^````````@_%U26K=?:UC\\<<+^ -M@,?@/V))))*+S/\_B9F9F9F5[#^U555555550``````````_F0``@``````` -M````````/_X``/X#^`_@/X#^`````#_W``#_`5-8@SQ'X@`````__@``^B,L -M\E(3BL``````/_D``+W(V#ZMB-5)`````#_^``#V8#V8#V8#V@`````_^@`` -MG/0]S_7J_4@`````/_X``/*YUD@/*YUE`````#_Z``#:%NN(RXWV%``````_ -M_@``[RZW'\0T4C@`````/_L``(LIMW4;UP=#`````#_^``#KO;*EP6&.ABO`````#_^``#A_'@. -M'\>`X@`````_^P``_V2)CM]5U5$`````/_X``-[I7$R@-[I7`````#_\``"- -MN5:I>ST!2``````__@``V^MA[M&<65@`````/_P``)N/X0#T>Z'>`````#_^ -M``#9`;(#9`;(#@`````__```J3%#.A;&:Q4``````__@``RX]#4:]@`````__@``O6D01P=F -M&J,`````/_T``)H^[-3#ZJ:R`````#_^``"[/N@`````/_X``+DA0_HV]>`N`````#_]``"E\ORKN\4&V@`````__@`` -MMP^[6AF^-ED`````/_T``*NSN+HJTV*E`````#_^``"U">:*FY2"'P`````_ -M_0``L607EZ]/FUJ:YX`````/_X``*,&7C^N?-#@ -M`````#_]``#G#7A<+Y];W``````__@``H6LQ+JC\-WT`````/_T``.P?.2Q1 -M>?*#`````#_^``"?V`G]@)_8"@`````__0``\21`T^-A,.8`````/_X``)Y, -MK2/=7SH@`````#_]``#V',Z2-&8`NP`````__@``G,CA8,/[&;D`````/_T` -M`/L)'].!16,*`````#_^``";3&^>\#H\J@`````__0``_^EP0K^DPJT````` -M/_X``)G7(MJ]Y8\&`````#_^``""7OSM23:3,``````__@``F&C("8:,@)@` -M````/_X``(3#>GJYJ07)`````#_^``"7`2X"7`2X"0`````__@``AR),+HYD -M7[<`````/_X``)6@)6@)6@)7`````#_^``")>XRLGWWBF``````__@``E$6` -ME$6`E$8`````/_X``(O/5=[$S07^`````#_^``"2\1.$!)>(G``````__@`` -MCAW`^XGA)>4`````/_X``)&BL\35YO@)`````#_^``"09N:,E5MLFP`````_ -M_@``D%HX8SX&Q#L`````/_X``)*JWG3'OEG@`````#_^``"/%WG9_<.B&0`` -M```__@``E.F_]A6$5D,`````/_X``(W:4@(W:4@)`````#_^``"7(Z&W(!-" -M`P`````__@``C**A+:`````#_^ -M``"']X"']X"'^``````__@``H?S_%\YS.]0`````/_X``(;9!41Z-*S&```` -M`#_^``"D&IZ/5$;[GP`````__@``A;\W82SN/)L`````/_X``*8SS7YG<8`M#6EX`````/_X``(.9,%(_ -MOC-H`````#_^``"J62,\S*2]20`````__@``@HR_OKF@(*,`````/_X``*QE -M;:YKS$F%`````#_^``"!A(VH^O#2=P`````__@``KFV.XV"[)&@`````/_X` -M`("`@("`@("!`````#_^``"P<9>B/$;&5``````M?/___YS_K$CG/P!V`"@H -M``0J*``(0H)*A&8R*`5"A70@0H;MQ&``[:S4ABU#_XPM1/^0+47_E$2"+4+_ -MK/(N2`#_C$S?`/Q![O^,8$A"ANW$8``D!NVL+@7MK42&!H8````@[*^(ARU# -M_XPM1/^0+47_E$2"+4+_K/(N2`#_C$S?`/Q![O^,8`SR$$@`+7P`````_ZP@ -M$#`H``0M4/^,+6@`!/^0+6@`"/^4#(``````;0`!;`3Z``#VIF0``.#@@."` -M!(```#__T*[_K$'Z]S#R`$"`+7P__P``_XPM;O^0_Z`"KOX```#_H`"N`0`` -M`/^@("[_H`*`?@```."`X(#H@-'`\BY(`/^,+7P__P``_YQ"KO^D\BY(*/^< -M\B?@#/(02"/R.DBC]D;R``$`\@`)(_(N:(#_P/(`"8#R``B`\CI4H_9*\CI5 -M(_9,\CI4HO9.\CI5(O90\@`,H_(`#2/R.E2B]DKR.E4B]DSR``RCT?P````0 -M\@`-(_(``*/R``@B\A!(HO(?T##R``0B\@&0`/(N2"+_P&``P*[R``"`\CI$ -MJ/7:\CI$(O74\@`$HO(``*#R)^`,\@`$`/(``"/R+FB`_]#R``"`\@`$H_(Z -M58#U[/(Z50#U[O(`!:/R``4C\CI5HO7H\CI5(O7J\@`,H_(``2/R.E2B]>3R -M+D@C_]#R``BB\A_0,/(`!"/R`9``\BY((O_08`#`+DYU8`"^X&``P1;R$$@` -M\@``&/(Z2#CUO/*2`!;R/(@``````/(!D`#R$$@`8`"__O(02``M?`````#_ -MK/(``(#R.D0B]1[R+F@`_XP];O^0_XX@+O^,#(``````;P``Q`3Z``#TYF4` -M_CH$^@``]-1E#O(`!*+R.D0B].A@`/\6+6[_D/^@`J[^````_Z``K@$```#_ -MH`R`/_^``&Q$\CI$`/4H+7P__P``_YQ"KO^D\BY(*/^<("[_H`*`?@```."` -MX(#H@/(`!*+R)^`,\@`$(D'Z]0[1P/(Z1(#TDF``_B3R.D0`]'PM?#__``#_ -MG$*N_Z3R+D@H_YP@+O^@`H!^````X(#@@.B`\@`$(O(GX`Q!^O3.T<#R.D2` -M]$I@`/WD#(``````;0[R.D0`]$#R`9``8`"]6/(Z1`#T*O(!D`!@`+V@```` -M`.GN`D?_'.GN%H+_@$H`9R(,```*;Q0,```.;SX,```O;P@,```_;P``>/(Z -M1`#_SDYU2@%G$`P!``-G%$'Y```0.&```+9!^0``$"Q@``"L0?D``!!$8``` -MH@2`````"TH!9Q@,`0`#9R1!^0``$(P,```";P``A&```(A!^0``$%`,```" -M;P``[_C`@H``<``%;H``)A`-3Z[.@`"``"9P8(Z``'``#R$-"`3G4M?`````#_ -MO&`(+7P````!_[Q(YS\`-A`]0__$`H,``'__*"@`!"HH``A*@V8\)CP``#_^ -M2H1F%B@%0H4$@P```"!"ANW$8`#MK):&8")"ANW$8`"6ANVL+@7MK42&!H8` -M```@[*^(AV`&!H,``#_^,"C_]#U`_\@R+O_$L8$"@0``@``]0?_,`H```'__ -M(BC_^"0H__Q*@&8\(#P``#_^2H%F%B("0H($@````"!"ANW!8`#MJ9"&8")" -MANW!8`"0ANVI+@+MJD2&!H8````@[*^"AV`&!H```#_^+4/_K"U`_["0@T*& -M0H,B?`````!*@&P(("[_L&```&A*AFX.LH1F"+2%9@1@``%(90B4A9.$0H92 -M@TJ`9P[6@]2"XY%5QE*)4X!@U"`N_ZQ*@686(@)"@@2`````($*&[<%@`.VI -MD(9@'$*&[<%@`&L4D(;MJ2X"[:I$A@:&````(.RO@H<,@```0?YL-#U`_YQ" -M;O^>+4'_H"U"_Z0L+O^L/4;_C$)N_XXM1/^0+47_E/(N2`#_G"U\`````?_0 -M8#XM0?^@+4+_I`2````__CU`_YQ";O^>+"[_K`2&```__BU&_ZSR+D@`_YP] -M1O^,+43_D"U%_Y0M?`````#_T"PN_[QG(BPN_ZQ3AK"&;1AN#K*$9@BTA68$ -M8```?F4(\BY(*/^,4H,\+O_(;`3R```:0H8\+O_,?@CNK@*#````?X:&2$/R -M!J@``H;_`/__C(/R!H@`3-\`_/(ND`#_@"`N_]!G"O(Z2"/]NF``O-CR```` -M3G52@PR`````"&P$X:M@`D*#\CQ$```````M?`````#_T&``_Y`L`P*&```` -M`4J&9P#_@E*#/"[_R`J&``"``#U&_\A@`/]N/_]`#/(\D```````0H$R+O\H -M6^[_K`*!``!__S`N_S0"0'__`OH``/_89#8,0$`,;``"[!`N_R`"``#@2@!G -M%%#N_[0`K@``"`#_A$'N_RA@`+N4\BZ0`/^`\BY(`/\H3G7R+D@`_S3R/)`` -M````$/(`8`#R/(@``````$IN_S1M``"22D%G``(&TH!G1`R!``!__VP<2B[_ -MK&<$`$&``#U!_RCR+I``_X#R+D@`_RA.=4HN_ZQG!`!!@``];O\H_S0M;O\L -M_S@M;O\P_SQ@`+EB2B[_K&<$`$&``$JN_RQM(#U!_S0M;O\L_S@M;O\P_SP` -MK@````/_A$'N_S1@`+KF/4'_*/(ND`#_@/(N2`#_*$YUTH!GNFT<2B[_K&<$ -M`$&``#U!_RCR+I``_X#R+D@`_RA.=0Q!_\!M``#,,`$O`B(N_RPD+O\P0J[_ -ML%)`XHGBDF0$4.[_L$I`;?!*+O^P9P@`K@``""C_A$)N_RA*+O^L9P8`;H`` -M_R@M0?\L+4+_,"0?2H%F9DJN_S!F8`@N``7_@V[_-&``MG0_UX``0`2\?C_D7S!MRJZ-H;Y:YD4J$8KD/L<=XZ4T%3&_*@&@&@&+60``````````/_@``(B( -MB(B(B%FO`````+_\``"JJJJJJJJJF0`````]*L30U@$>X[VI.6^?1:P9/B'N -MV082R7*^DGY/MYV?SS[Z`:`:`=0C``````````"_]0``M@M@M@MAU#@````` -M/_H``*JJJJJJJJM>OP```#_\``"B^8-N3D05*D`!``#)#]JB```````````_ -MWP``A:,(U```````````8`"WKO(\1`!.?@``\CR(``````!@`+:H+7P````` -M_[Q@""U\`````?^\\A!(`"`0,"@`!/(N:`#_X`*`?____PR`/]>``&P$8``! -M7@R`0`2\?FT$8``!BO(``(#R.E2C_LQ#^0``;!3R+F"`_[`@+O^PZ8#3P/(9 -M2"CR$40H("[_L-"N_[SBF`R``````&T``'[R+F@`_^#R```C\CI5@/Z4\CI5 -M`/Z6\@``@/(`!*/BF`*`@````+&N_^#R``6C\@`%(_(Z5:+^?/(Z52+^?O(` -M!:/R``4C\CI5HOYX\CI)(OZ"\@`,H_(``2/R.DBB_H3R+D@C_^#R``BB\@`$ -M(_(!D`#R+D@B_^!@`+6R\@``(_(Z50#^;O(Z58#^+7S)#]JB_Z!"KO^D\BY%*/^L!H```#_= -M/4#_P$)N_\(M?(6C"-/_Q$*N_\@@+O^P\@`*`/(N2B/_G/(`"H#R+DJC_\#R -M`!&`\@`5HO(`#BCR``PH\@`6(O(``8#R`!"H\@`$(@R``````&X```[R``&H -M\@`,HF``_O[R+F$`_[`D'_(?T#P@+O^\#(`````$;0#]%F!L\CQ$@$Y^``!A -M``P^8`"T-BU\````!/^\\A!(`"`0,"@`!/(N:`#_X`*`?____PR`/]>``&P$ -M8``"/@R`0`2\?FT$8`#^,/(``(#R.E2C^W)#^0``;!3R+F"`_[`@+O^PZ8#3 -MP/(92"CR$40H("[_L.*8#(``````;``!!O(N:`#_C/(``"/R.E2`^S[R.E4` -M^XCR``"C+P(D`/(``2/BF@*"@````/(Z5*+[)K&"`H*`````\CI5(OMH\@`` -MH[6N_XPD'_(``2/BF`*`@````/(Z5*+[!"U\/X```/^LL:[_K/(Z52+[0O(` -M`*/R``$C\BYH`/^<\CI4HOKFL:[_G/(Z52+[+/(``*/R``$C\CI4HOK6\CI5 -M(OL@\@``H_(``2/R.DBB^M+R.DDB^QSR``"C\@`!(_(Z2*+ZSO(Z22+[&/(` -M`*/R``@C\BY(H_^,\CI$(OL0\BY((_^<+P$"@0```/_R`9``\BY(HO^,80`* -MV/(?D`#R+D0B_ZQ@`+'4\BYH`/^,\@``(_(Z5(#ZBO(Z50#Z-/(``*/R+F@` -M_YSR``$CXI@"@(````#R.E2B^G#R.E4B^AJQKO^,L:[_G/(``*,`@#^````M -M0/^L\@`!(_(Z5*+Z4O(Z52+Y_/(``*/R``$C\CI4HOI&\CI5(OGP\@``H_(` -M`2/R.E2B^CKR.E4B^>3R``"C\@`!(_(Z2*+Z-O(Z22+YX/(``*/R``$C\CI( -MHOHR\CI)(OG<\@``H_(`""/R.D2B^BKR+D@C_XSR+DBC_YPO`0*!````__(! -MD`#R+D2B_ZQA``GL\A^0`/(N2"+_C&``L.@,@#__@`!N`/P`/7P``/_B\CQ$ -M@$Y^```O`0*!````__(!D`#R/$2H2P```&$`":[R'Y``\BY(`/_@8`"PJ@`` -M0,8M.-/61C0];Y"NL>=(NY&\``A2```P`0``*_MWTW=.ZGNH2```,`$ -M``"II6!XS#!CW2'\``#`!```HUSAH[LE'YH5@` -M`,`$``"6R^/YF0Z1J"'@``#`!```D(-E)(@#2Y8@L```P`0``(HZYD]V^`6$ -MH8@``,`$``"#\F=Z9>R_Z$P``#``P``U:#83$-_3EB?P```P`,``,D/ -MVJ(A:,(U(0```,`#``"\?MSW_U(V$:%H``#``P``K^W?3=T[J>Z@H```P`,` -M`*-Z"P``#``@``R0_:HB%HPC4@ -M@```P`(``*_MWTW=.ZGNH"```,`"``"6R^/YF0Z1J"#@``#``0``^U/12JG" -M\L(?````P`$``,D/VJ(A:,(U(````,`!``"6R^/YF0Z1J"!@``#`````R0_: -MHB%HPC4?@```O_\``,D/VJ(A:,(U'P`````````````````````````__P`` -MR0_:HB%HPC6?````0````,D/VJ(A:,(UGX```$`!``"6R^/YF0Z1J*!@``!` -M`0``R0_:HB%HPC6@````0`$``/M3T4JIPO+"GP```$`"``"6R^/YF0Z1J*#@ -M``!``@``K^W?3=T[J>X@(```0`(``,D/VJ(A:,(UH(```$`"``#B,=7V997: -M>R"P``!``@``^U/12JG"\L*?@```0`,``(HZYD]V^`6$(0@``$`#``"6R^/Y -MF0Z1J*%@``!``P``HUSAH[LE'R$P``!``P``[L+3H(>L9I^A.```0`,``/M3T4JIPO+"H``` -M`$`$``"#\F=Z9>R_XA(```0`0``+8V -M7B+N1O``H4@``$`$``"\?MSW_U(V$2'H``!`!```PL=;S1!=?",@T```0`0` -M`,D/VJ(A:,(UH8```&``K!;R$$@`(!`P*``$`H!_____#(`_UX``;`1@``$D -M#(!`!+Q^;01@``$H\@``@/(Z5*/[)$/Z_;CR`&"`Z8#3P/(92"CR$40HZI@" -M@(`````,@`````!M``!L\@``@/(`!*/R.E6`^OCR.E4`^OKR``6C\@`%(_(Z -M5:+Z]/(Z22+Z_O(`!:/R``4C\CI)HOL`\CI)(OL*\@`%H_(`!2/R.DFB^PSR -M``$C\@`,H_(`""+R/$2B3GX``/(!D`#R``0@8`"J8O(``(#R```C\CI5@/J. -M\CI5`/J0\@`!H_(``2/R.E6B^HKR.DDB^I3R``&C\@`!(_(Z2:+ZEO(Z22+Z -MH/(``:/R``$C\CI)HOJB\@`%(_(`#"/R``BB\CQ$(DY^``#R)VB`"I>````` -M\@&0`/(?2"!@`*GN#(`__X``;A#R)V@`\@&0`/(?2`!@`*G6\B?@/"\"\CQ$ -M@``````,@'_^__]F5BU\?_X``/^<+7S)#]JB_Z!"KO^D\@``.BU\?]P``/_` -M+7R%HPC3_\1"KO_(\I0`#@!N@`#_G`!N@`#_P/(N2"+_G/(``(#R+D@B_\#R -M``"H\BY(HO_`\BYH`/_0,"[_T")``H```'__!(```#__#(`````<;Q`$@``` -M`!LM?`````#_L&`*0H`M?`````'_L"0\```__I2`+7RB^8-N_Y`M?$Y$%2K_ -ME#U"_XSR``$`\BY)(_^,)`E(0@*"@`````""7P```"U"_ZPD``:"```___(N -M12+_K#U"_YQ";O^>+7S)#]JB_Z!"KO^D\BY%*/^L!H```#_=/4#_P$)N_\(M -M?(6C"-/_Q$*N_\@@+O^P\@`*`/(N2B/_G/(`"H#R+DJC_\#R`!&`\@`5HO(` -M#BCR``PH\@`6(O(``8#R`!"H\@`$(@R``````&X```[R``&H\@`,HF``_O[R -M+F$`_[PD'_(?T#P@+O^\XIA@`/U\8`"I/O(02`#R+F@`_^`@$#`H``0M0/_@ -M`H!_____!/H``/_>95P@+O_@+4#_O`*`?_\```:```$``"U`_^`"KH````#_ -MO/(N2`#_X"\!0H'R$/"`80#7V"(?\@``@/(\1*).@```("[_O/(N:(#_\+&N -M__#R`9``\BY((/_P8`"GS@R`/_^``&T``'@,@$`$BJ%N``""("[_X"U`_[P" -M@'__```&@``!```M0/_@`JZ`````_[P@+O^\\BY(`/_@+P%"@?(0\(!A`-6N -M(A\@+O^\\CQ$(DY^```*@,````#R`$2`\@``H"`N_[P`@#^```#R`$0`\@&0 -M`/(`!")@`*=./7P``/_B\@&0`/(N2`#_X&``ISH@+O_@`H"``````(`_@``` -M\@!$``*`@`````J`@(```/(!D`#R`$0B8`"G#@``Z>X#0_\<#````V\2\B?@ -M`G('DH!"@`/`\A_8`$YU#````&2@$*``\#R -M']@`3G4,````9R0,```!9Q8,```"9PCR+O"`_W1.=?(N\(#_:$YU\B[P@/]< -M3G7R+O"`_U!.=3^Y@`!`#8#`/[F``$`+FP=`:I-/"7FC<3]S1!-0GX``O\T` -M`,`AG<':F4_2`````$````"378W=JJBL%P`````__@``L7(7]]'/>:P````` -M/U;!;6][T+(_@1$2,"QQ+#^E555554S!/\5555552E0_X``````````````` -M````?_X``/__________```````!``#__________P`````__P``@``````` -M```_0$8_O-?)/_\``(6JPV?,2'L5O[WHVC__``"''V&6GHT0$#^]Z%P__P`` -MB)@.@)+:A2<_OKOQ/_\``(H4U75);OV:/[N`RC__``"+E<'CZHO6Y[^Z@W,_ -M_P``C1K?6WY;J>:_OI9P/_\``(ZD.8M%S5/`/[VW`#__``"0,=Q#%&:QW#^^ -M[K`__P``D -M]3)@D:$1KK^^OMT__P``H+!1#[EQ3\(_O,EN/_\``*)P0P,,26@9O[[)"S__ -M``"D-16N">:`GC^[T=L__P``I?[6J;%1..H_O.7K/_\``*?-D[3I935JO[[" -M=#__``"IH5JTZGP.^#^^J#P__P``JWHYM:D^TS<_OLL`/_\``*U8/NI"H4K& -M/[Z3`3__``"O.WBM:0I#=;^]@V<__P``L2/U@=*L)9"_OO!?/_\``+,1Q!*I -M$22)/[W[/#__``"U!/,S^=YDA#^^LOL__P``MOV1XRC1=Y$_NN++/_\``+C[ -MKT=B^Y[I/[S::/_\``-F=%<)XK]>VO[B\83__``#;^[>7VO(W53^]]A`__P`` -MWF#T@EX.D22_O8OA/_\``.#,WNPJE.$1/[K+$C__``#C/XEROHI:43^[F_X_ -M_P``Y;D&YWR#2*@_O/+T/_\``.@Y:E`\2]QH/[[R+S__``#JP,;GW20Y+[^] -MOTH__P``[4\P'MF4*X0_OL`:/_\``._DN9O+7R` -M````_Z!"KO^D\BY((_^<8`"?B```6F@``%IH``!::```6F@``%IH``!::``` -M6F@``%IH``!,9```"$0```A2```9V```3'````@F```()@``""8``&BX```( -M1```"%(``!G8``!HM```""8```@F```()@``3+(```A$```(4@``&=@```@L -M```()@``""8```@F```()@``""8```@F```()@``""8```@F```()@``""8` -M``@F```()@``""8```@F```()@``""8```@F```()@``")@```A$```(B@`` -M&=@``%DD```()@``""8```@F```()@``""8```@F```()@``""8```@F```( -M)@``""8``$DJ```(1```"+8``!G8``!))@``""8```@F```()@``<0````A$ -M```(8```&=@``'#\```()@``""8```@F```_/```"$0```AN```9V```/S@` -M``@F```()@``""8```@F```()@``""8```@F```()@``""8```@F```()@`` -M-?0```A$```8`@``&=@``#7P```()@``""8```@F``!!;```"$0``!@"```9 -MV```06@```@F```()@``""8``&*D```(1```&`(``!G8``!BC```""8```@F -M```()@``;B@```A$```8`@``&=@``&XD```()@``""8```@F``!'=```#"P` -M``A\```9V```1U````@F```()@``""8``'><```,+```"'P``!G8``!W@``` -M""8```@F```()@``>)H```PL```(?```&=@``'A^```()@``""8```@F```( -M)@``""8```@F```()@``""8```@F```()@``""8```C$```7E```"(H``!G8 -M```(]```""8```@F```()@``"0(``!>4```(B@``&=@```DR```()@``""8` -M``@F```)0```%Y0```B*```9V```"7````@F```()@``""8```@F```()@`` -M""8```@F```()@``""8```@F```()@``""8```@F```()@``""8```@F```( -M)@``""8```@F``!"$```#"P```P,```9V```0?@```@F```()@``""8```@F -M```()@``""8```@F```()@``""8```@F```()@``""8```@F```()@``""8` -M``@F```()@``""8```@F```U3@``"_```!@"```9V```-4````@F```()@`` -M""8``&*N```,+```&`(``!G8``!BD```""8```@F```()@``2\P```A$```8 -M`@``&=@``$O>```()@``""8```@F``!+]@``"$0``!@"```9V```3!H```@F -M```()@``""8```@F```()@``""8```@F```()@``""8```@F```()@``";X` -M``F^```)O@``";X```F^```()@``""8```@F```()@``""8```@F```()@`` -M""8```@F```()@``""8```@F```()@``""8```@F```()@``""8```@F```( -M)@``""8```@F```()@``""8```@F```()@``""8```@F```*A```"H0```J$ -M```*A```"H0```@F```()@``""8```M*```+2@``"TH```M*```+2@``""8` -M``@F```()@``""8```@F```()@``""8```@F```()@``""8```@F```()@`` -M""8```@F```()@``""8```@F```()@``""8```@F```()@``""8```@F```( -M)@``""8```@F```()@``""8```@F```()@``""8```@F```()@``""8```@F -M```()@``""8```@F```()@``""8```@F```()@``""8```@F```()@``""8` -M``@F```()@``""8```@F```()@``""8```@F```()@``""8```@F```()@`` -M""8```@F```()@``""8```@F```()@``""8```@F```()@``""8```@F```( -M)@``""8```@F```()@``""8```@F```()@``9@@```N4```+M@``"\H``&7X -M```()@``""8```@F``!F"```"Y0```NV```+R@``9?@```@F```()@``""8` -M`&8(```+E```"[8```O*``!E^```""8```@F```()@``9@@```N4```+M@`` -M"\H``&7X```()@``""8```@F``!F"```"Y0```NV```+R@``9?@```@F```( -M)@``""8``&8(```+E```"[8```O*``!E^```""8```@F```()@``9@@```N4 -M```+M@``"\H``&7X```()@``""8```@F``!F"```"Y0```NV```+R@``9?@` -M``@F```()@``""9__P``````````````````?_X``/__________`````$!^ -M``#___\```````````!#_@``________^`````````""&```@B8``((N``"" -M3```@L0``(+0``""U@``@O```()N``""?```@H0``(*B``"#+@``@RX``(,N -M``"#+D'N_S0(K@`'_S16[O\V""X``?\D9_\```!*,"[_$`)``&`,@````$!G -M_P```((,@````&!G_P```'HP+O\0`H````!_#(`````S9_\```!<#(`````P -M9_\```!08```5C`N_QP"@````$0,@````$!G_P```#H,@````$1G_P```#(P -M+O\<`H````!_#(`````G9_\````4#(`````D9_\````(8```#D*`8!1P`6`0 -M<`)@#.GN``+_@V`$80`"'N6(Z>X0@O^#@(%#^O[T(G$,`$[10_K^J@CN``'_ -MA&```.I#^OZL8```XDHH``)G$$/Z_HX`K@H```#_A&```-A#^OZ.8```T$HH -M``)G#D/Z_H`([@`#_X1@``"\0_K^8@CN``'_A&```*Y#^OY4".X``?^$8``` -ME$/Z_G9@``",2B@``F<00_K^.`"N"@```/^$8```@D/Z_EA@``!Z2B@``F<. -M0_K^2@CN``/_A&```&9#^OX,".X``?^$8```6$/Z_?X([@`!_X1@/D/Z_A)@ -M.$HH``)G#D/Z_>8`K@H```#_A&`P0_K]^&`J2B@``F<,0_K][`CN``/_A&`8 -M0_K]P`CN``'_A&`,2B@``F<&".X``_^$,6D`````(6D`!``$(6D`"``(3G5. -M=2!N_X@O/`````!#[P`"<`)A____?+X@'TYU80``O@Q```-F!F$``,I.=0@N -M``'_)&?_````2B`N_Q#IP`)"#(`````"9_\```!^#(`````#9_\```!V,"[_ -M$`*`````?PR`````,V?_````9`R`````,&?_````6&```%8@+O\<`H``1``` -M#(``0```9_\````V#(``1```9_\````N("[_'`*``'\```R``"<``&?_```` -M'`R``"0``&?_````$&````YP`4YU<`).=7``3G4@+O^`Z<`&`DYU""X``?\D -M9P1"@$YU("[_'.G```-.=0@N``'_)&<$0H!.=2`N_QSIP`###````68$<`%. -M=0P```5F!'`"3G5"@$YU`````````````````````#^!```````````````` -M```\`0`````````````````````````````````!`````#^!``````$````` -M```````\`0``````````"`````````"%````A0X``(4<``"%/@``A;@``(7$ -M``"%T```A>X``(5<``"%:@``A7@``(6:``"%7```A6H``(5X``"%FN6(Z>X0 -M@O^#@(%#^O^T(G$,`$[10_K_2@CN``+_A&```/Q#^O\\".X``O^$8```[DHH -M``)G#D/Z_U@([@`#_X1@``#F0_K_&@CN``+_A&```-A**``"9Q!#^O\&`*X, -M````_X1@``#"0_K_)F```+I#^O\.".X``O^$8```H$/Z_P`([@`"_X1@``"2 -M2B@``F<.0_K_'`CN``/_A&```(I#^O[>".X``O^$8```?$HH``)G$$/Z_LH` -MK@P```#_A&```&9#^O[J8```7D/Z_J(([@`"_X1@1$/Z_I8([@`"_X1@.$HH -M``)G#$/Z_K0([@`#_X1@,D/Z_G@([@`"_X1@)DHH``)G#D/Z_F8`K@P```#_ -MA&`20_K^B&`,2B@``F<&".X``_^$,6D`````(6D`!``$(6D`"``(3G4``(:2 -M``"&F@``AJ(``(:H``"&K@``AK0``(:Z``"&P```AL8``(;.``"&U@``AMP` -M`(;B``"&Z```ANX``(;T``"&^@``AP(``(<*``"'$```AQ8``(<<``"'(@`` -MARA!^O^>('`<`$[0'6[_K/]#3G4=;O^L_T=.=10N_ZQ.=18N_ZQ.=1@N_ZQ. -M=1HN_ZQ.=1PN_ZQ.=1XN_ZQ.=3UN_ZS_0DYU/6[_K/]&3G4T+O^L3G4V+O^L -M3G4X+O^L3G4Z+O^L3G4\+O^L3G4^+O^L3G4M;O^L_T!.=2UN_ZS_1$YU)"[_ -MK$YU)B[_K$YU*"[_K$YU*B[_K$YU+"[_K$YU+B[_K$YU``!.5O]`\R=([@,# -M_T#R+O#P_U#R+KP`_X`M;@`&_XA,[@,#_T#R+M#P_U#R+IP`_X#S7TY>8/__ -M_WB:```,;R`L``9G_P``"GA9CTY6_T#S)TCN`P/_0"!N``I#[O^L<`18CF'_ -M__]X;%F.("[_K.G`$0,,`0`!9@``A.G`%`8,`0`79@``>`P7`$!F%I_\```` -M*!Z\`$`??``H``%";P`"8!X,%P!!9O___W@HG_P````P'KP`01]\`#```4)O -M``(];@`(``0M;@`*``;R+H0```9R!-.N``8]?"`L``I"K@`,/4#_'$*N_R0( -M[@`%_R5,[@,#_T!@_P``"6(]@____=\8``$Y6_T#S)TCN -M`P/_0/(N\/#_4/(NO`#_@`@N``3_)6<@("[_'.G``,,,````9P``.@P```1G -M``"^#```!F<``00([@`%_X8([@`'_X=,[@,#_T#R+M#P_U#R+IP`_X#S7TY> -M8/___W=<<@00+O\8`@``X`P``&!G``$8#*Z`````_S!F%F$``:Y*@&8.(#R` -M````80`!3F```>(P+O\H`D!__PQ`/_YF#"`N_S!A``$T8``!R#`N_R@"0'__ -M#$!``&0``.(@+O\P`H!__P``#(!__P``9])*KO\P:@X,KO______+&?"8``` -MO$JN_RQGN&```+)R`A`N_Q@"``#@#```8&<``(P,KO__@`#_,&8680`!(DJ` -M9@X@/(````!A``#"8``!5C`N_R@"0'__#$`__F9P("[_,$A`80``IF```3IR -M`1`N_Q@"``#@#```8&<^#*[___^`_S!F%F$``-9*@&8.(#R`````80``=F`` -M`0HP+O\H`D!__PQ`/_YF)"`N_S#A@$A`80``6&```.P`K@``((#_A"`N_SAA -M``!$8```M`"N```@@/^$"*X``?^&"*X``_^'\CR(``````!*;O\H;0X@/'__ -M__]A```48```A"`\@````&$```9@``!V+4#_K"\!8?____D&(A_HP`:#9BP" -M@`````<,@0````1G$`R!`````F8.`(`````(8`8`@````!`B`&#____\*D'N -M_ZPB;@`,(`%A____=9).=0RN______\L9A`,;L``_RAG#`QNO___*&<$<`%. -M=4*`3G4(+@`%_X)G'$SN`P/_0/(NT/#_4/(NG`#_@/-?3EY@____=4H0+O^" -MP"[_A@(```-G```R'7P`Q``++6[_A/\``*X!@```_R1,[@,#_T#R+M#P_U#R -M+IP`_X#S7TY>8/___W4*3.X#`_]`\B[0\/]0\BZ<`/^`3EY@____=/!.5O]` -M\R=([@,#_T#R+O#P_U#R+KP`_X`([@`#_X=A_P```/H(+@`$_X)G0@@N``'_ -M)&<>Z>X!@_\0`:[^Y6'_```'@"UN_X3_``"N`8```/\D3.X#`_]`\B[0\/]0 -M\BZ<`/^`\U].7F#___]T@@@N``'_@F=(""X``?\D9Q[I[@&#_Q`!KO[E8?\` -M`` -M8/___W0R"*X``?\D9SKI[@&#_Q`!KO[E8?\```;N+6[_A/\``*X!@```_R1, -M[@,#_T#R+M#P_U#R+IP`_X#S7TY>8/___W/P3.X#`_]`\B[0\/]0\BZ<`/^` -M3EY@____<]8(+@`!_R1G!D'N_O1@!$'N_S0(J``'``!6Z``"8?____>^#$`` -M`V88'6[_A/^L8?____6B'6[_K/^$8/\```(>8?____3B8/\```(2``!.5O]` -M\R=([@,#_T#R+O#P_U#R+KP`_X`(+@`&_X)F.&'_````Y!`N_X+`+O^&`@`` -M`V<``(`=?`#$``M,[@,#_T#R+M#P_U#R+IP`_X#S7TY>8/___W,P""X`!?\< -M9P`!:&'_````HAU7_[L,%P!`9@1P#6`"<`M"ET*G4KO^['WP`8``!+6[_A/\``*X! -M@```_R1,[@,#_T#R+M#P_U#R+IP`_X#S7TY>8/___W*"(&X`#.GN`,/_'`R` -M`````&<2#(`````$9R@,@`````9G/DYU(B[_.'`$",$`'DJ(9TPO`2)(($]A -M____#````V<` -M``P@+O\&I(T$`!"(I``CI -MP0`5@:D`!'`(P4EA____<'9.=4*`,"D```1`/_\,0$``9Q0&0`!_2$#OB$HI -M``)G&`C``!]@$B`\?X```$HI``)G$`C``!]@"B(I``3IP1!7@($M0/^L<`1* -MB&<.P4E![O^L8?___W`>3G5A____\T8"0``'(@``@0```!!@____]HQ**0`" -M9P8(Z0`'``!"*0`"<`S!26'___]OZDYU3E;_0/,G2.X#`_]`\B[P\/]0\BZ\ -M`/^`8?\```$`""X``_^"9T((+@`!_R1G'NGN`8/_$`&N_N5A_P```GXM;O^$ -M_P``K@&```#_)$SN`P/_0/(NT/#_4/(NG`#_@/-?3EY@____;X`0+O^"P"[_ -MA@(```-G2`@N``'_)&<>Z>X!@_\0`:[^Y6'_```"+BUN_X3_``"N`8```/\D -M'7P`Q``+3.X#`_]`\B[0\/]0\BZ<`/^`\U].7F#___]O*@BN``'_)&X! -M@_\0`:[^Y6'_```!YBUN_X3_``"N`8```/\D3.X#`_]`\B[0\/]0\BZ<`/^` -M\U].7F#___]NZ$SN`P/_0/(NT/#_4/(NG`#_@$Y>8/___V[.8?____(2/SP` -M`#\`""X``?\D9R!![O[T,B[_$`)!`'\,00`P9P8,00`S9@Q"@#Z\``%@!$'N -M_R@(J``'``!6Z``"8?___Z&X0@O^#TI]A____GR1A____\GP,```#9AQA -M____\H9*`&<*2B@`!&L$4V@``&'____\VF`F8?____S22J@`!&8,2J@`"&8& -M".X``O^$""@`!P``9P8([@`#_X0(+@`!_X9G!@CN``7_ATYU``!.5O]`\R=( -M[@,#_T#R+O#P_U#R+KP`_X`0%P(``/`,``!`9O___VWP("[_A`*``/\`_RU` -M_X3R/(@``````/(\D```````0B[_N6'___^!#$(N_[1A____=8[S)THN_[1F -M!F'____@0&#___]Z,@``3E;_0/,G2.X#`_]`\B[P\/]0\BZ\`/^`'5?_NQ`7 -M`@``\`P``$!F____;7SR/(@``````/(\D```````(B[_A`@N``7_'&8```H" -M@0#_`/]@!@*!#_]`_RU!_X10[O^Y8?___X"&8?___XC40J<>KO^[8/___WFX -M#"\`0``$9@`"G!`N_N0"``#^9P`"D#`N_QP"0.``9@`!1.GN`,/_'.GN$8/_ -M$+(`9R3I[@&#_QRR`&<:Z>X1@_\,L@!G3.GN`,/_'+(`9P``0F8``E#I[@## -M_QQR!Y*`0H`#P/(N^`#_-!`\`!+O[@`&_QP(+@`&_S1G```,"*X`!/\88``" -M'@CN``3_&&```A0M;O\8_ZPM;O\<_[`M;O\@_[P"KN````#_O!U\``#^Y"(? -M\U_S)PQ70&!G``"@Z>X!@_\,#(`````#;BIG(@R``````6T29PCR+O`@_VA@ -M%O(N\$#_7&`.\B[P@/]08`;R+O`0_W1P%D*70J=1R/_\+SQ`8```+6[_K/\8 -M+6[_L/\<+6[_O/\@'7P`!O[D+P'I[@##_QQR!Y*`0H`#P/(N^`#_-!`\`!+O -M[@`&_QP(+@`&_S1G```,"*X`!/\88``!4@CN``3_&&```4A.^0`````P+O\< -M`D#\``Q`1`!F``$RZ>X!@_\X1@_\0L@!G``#&Z>X1@_\,L@!F``$4+6[_ -M&/^L+6[_'/^P+6[_(/^\`J[@````_[P=?```_N0M;O\T_YPM;O\X_Z`M;O\\ -M_Z0B'_-?\R<,5T!@9P``SNGN`8/_#`R``````VXJ9R(,@`````%M$F<(\B[P -M(/]H8!;R+O!`_UQ@#O(N\(#_4&`&\B[P$/]T```$H```"68```2@```)>```!*````E\```$H```"7X```1````)@@`` -M!$````F&```$0```"8H```1````)C@``!$````F2```$0```"98```1````) -MF@``!$````F>```$0```":(```1````)I@``!$````FJ```$0```":X```1` -M```)L@``!$````FV```$0```";H```1````)Y@``!*````GJ```$H```">X` -M``2@```*-```!*````I$```$0```"D@```1````*3```!$````I0```$0``` -M"E0```1````*6```!$````I<```$0```"F````1````*9```!$````IH```$ -M0```"FP```1````*<```!$````IT```$0```"G@```1````*?```!$````J` -M```$0```"JP```2@```*L```!*````JT```$H```"OH```2@```+"@``!$`` -M``L.```$0```"Q(```1````+%@``!$````L:```$0```"QX```1````+(@`` -M!$````LF```$0```"RH```1````++@``!$````LR```$0```"S8```1````+ -M.@``!$````L^```$0```"T(```1````+1@``!$````MN```$H```"W(```2@ -M```+D@``!*````NN```$0```"[0```2@```+O@``!*````O(```$H```"^H` -M``2@```+[@``!*````OX```$H```#`H```2@```,9```!$````QH```$0``` -M#&P```1````,<```!$````QT```$0```#'@```1````,?```!$````R````$ -M0```#(0```1````,J@`<+]````T@`!POT```#H(`'"_0```/?@`!@``!,```!\````$H```(K8```3` -M```CG@``!,```"02```$P```)&0```3````DT```!,```"7V```$P```)FH` -M``3````FT```!,```"```$0```+^(```1````OY@``!$```"_J```$0```+^X` -M``1````P#`````$H```1W(```2@``!(A@``!*```$B:```$H``` -M22````2@``!))```!*```$DH```$H```2I(```2@``!*R```!*```$KZ```$ -MH```2Z0```2@``!+R```!*```$OF```$H```3'@```2@``!,C```!*```$R0 -M```$H```3)P```2@``!,H```!*```$RD```$H```3*@```2@``!,K```!*`` -M`$RP```$H```3/H```2@``!,_@``!*```$T"```$H```308```2@``!-$@`` -M!*```$T6```$H```31H```2@``!-'@``!*```$TH```$H```32P```2@``!- -M,```!*```$TT```$H```368```2@``!-;@``!*```$UR```$H```3<@```2@ -M``!-U@``!*```$WD```$H```3?(```2@``!.````!*```$X.```$H```3D(` -M``2@``!.2@``!*```$Y8```$H```3EP```2@``!8G```!*```%D<```$H``` -M62(```2@``!9)@``!*```%E,```$H```6E0```2@``!:8@``!*```%JF```$ -M0```6K````1```!:N@``!$```%K4```$0```6N8```1```!:^```!$```%L: -M```$0```6S0```1```!;3@``!$```%NR```$H```7A(```2@``!>L@``!*`` -M`%\P```$H```7V````2@``!@3@``!*```&%\```$H```8:(```2@``!AK@`` -M!*```&*.```$H```8J(```2@``!B\```!$```&.8```$H```9"H```2@``!D -M4@``!*```&1J```$H```9@(```2@``!F!@``!*```&9*```$0```9V@```2@ -M``!G=@``!*```&A4```$H```:&(```2@``!HD@``!*```&B@```$H```:+8` -M``2@``!HX@``!*```&DB```$H```:2P```2@``!I9```!*```&EP```$H``` -M;B8```2@``!NZ```!*```&]<```$H```;W0```2@``!P_@``!*```'%2```$ -MH```<7P```2@``!QQ@``!*```''\```$H```: -M```$H```>&````2@``!X=```!*```'A\```$H```>)@```2@``!YP@``!*`` -M`'G$```$0```><@```1```!YS```!$```'G0```$0```>=0```1```!YV``` -M!$```'G<```$0```>>````1```!YY```!$```'GH```$0```>>P```1```!Y -M\```!$```'GT```$0```>?@```1```!Y_```!$```'H````$0```>@0```1` -M``!Z"```!$```'H,```$0```>A````1```!Z%```!$```'H8```$0```>AP` -M``1```!Z(```!$```'HD```$0```>B@```1```!Z+```!$```'HP```$0``` -M>C0```1```!Z.```!$```'H\```$0```>D````1```!Z1```!$```'I(```$ -M0```>DP```1```!Z4```!$```'I4```$0```>E@```1```!Z7```!$```'I@ -M```$0```>F0```1```!Z:```!$```'IL```$0```>G````1```!Z=```!$`` -M`'IX```$0```>GP```1```!Z@```!$```'J$```$0```>H@```1```!ZC``` -M!$```'J0```$0```>I0```1```!ZF```!$```'J<```$0```>J````1```!Z -MI```!$```'JH```$0```>JP```1```!ZL```!$```'JT```$0```>K@```1` -M``!ZO```!$```'K````$0```>L0```1```!ZR```!$```'K,```$0```>M`` -M``1```!ZU```!$```'K8```$0```>MP```1```!ZX```!$```'KD```$0``` -M>N@```1```!Z[```!$```'KP```$0```>O0```1```!Z^```!$```'K\```$ -M0```>P````1```![!```!$```'L(```$0```>PP```1```![$```!$```'L4 -M```$0```>Q@```1```!['```!$```'L@```$0```>R0```1```![*```!$`` -M`'LL```$0```>S````1```![-```!$```'LX```$0```>SP```1```![0``` -M!$```'M$```$0```>T@```1```![3```!$```'M0```$0```>U0```1```![ -M6```!$```'M<```$0```>V````1```![9```!$```'MH```$0```>VP```1` -M``![<```!$```'MT```$0```>W@```1```![?```!$```'N````$0```>X0` -M``1```![B```!$```'N,```$0```>Y````1```![E```!$```'N8```$0``` -M>YP```1```![H```!$```'ND```$0```>Z@```1```![K```!$```'NP```$ -M0```>[0```1```![N```!$```'N\```$0```>\````1```![Q```!$```'O( -M```$0```>\P```1```![T```!$```'O4```$0```>]@```1```![W```!$`` -M`'O@```$0```>^0```1```![Z```!$```'OL```$0```>_````1```![]``` -M!$```'OX```$0```>_P```1```!\````!$```'P$```$0```?`@```1```!\ -M#```!$```'P0```$0```?!0```1```!\&```!$```'P<```$0```?"````1` -M``!\)```!$```'PH```$0```?"P```1```!\,```!$```'PT```$0```?#@` -M``1```!\/```!$```'Q````$0```?$0```1```!\2```!$```'Q,```$0``` -M?%````1```!\5```!$```'Q8```$0```?%P```1```!\8```!$```'QD```$ -M0```?&@```1```!\;```!$```'QP```$0```?'0```1```!\>```!$```'Q\ -M```$0```?(````1```!\A```!$```'R(```$0```?(P```1```!\D```!$`` -M`'R4```$0```?)@```1```!\G```!$```'R@```$0```?*0```1```!\J``` -M!$```'RL```$0```?+````1```!\M```!$```'RX```$0```?+P```1```!\ -MP```!$```'S$```$0```?,@```1```!\S```!$```'S0```$0```?-0```1` -M``!\V```!$```'S<```$0```?.````1```!\Y```!$```'SH```$0```?.P` -M``1```!\\```!$```'ST```$0```?/@```1```!\_```!$```'T````$0``` -M?00```1```!]"```!$```'T,```$0```?1````1```!]%```!$```'T8```$ -M0```?1P```1```!](```!$```'TD```$0```?2@```1```!]+```!$```'TP -M```$0```?30```1```!].```!$```'T\```$0```?4````1```!]1```!$`` -M`'U(```$0```?4P```1```!]4```!$```'U4```$0```?5@```1```!]7``` -M!$```'U@```$0```?60```1```!]:```!$```'UL```$0```?7````1```!] -M=```!$```'UX```$0```?7P```1```!]@```!$```'V$```$0```?8@```1` -M``!]C```!$```'V0```$0```?90```1```!]F```!$```'V<```$0```?:`` -M``1```!]I```!$```'VH```$0```?:P```1```!]L```!$```'VT```$0``` -M?;@```1```!]O```!$```'W````$0```?<0```1```!]R```!$```'W,```$ -M0```?=````1```!]U```!$```'W8```$0```?=P```1```!]X```!$```'WD -M```$0```?>@```1```!][```!$```'WP```$0```??0```1```!]^```!$`` -M`'W\```$0```?@````1```!^!```!$```'X(```$0```?@P```1```!^$``` -M!$```'X4```$0```?A@```1```!^'```!$```'X@```$0```?B0```1```!^ -M*```!$```'XL```$0```?C````1```!^-```!$```'XX```$0```?CP```1` -M``!^0```!$```'Y$```$0```?D@```1```!^3```!$```'Y0```$0```?E0` -M``1```!^6```!$```'Y<```$0```?F````1```!^9```!$```'YH```$0``` -M?FP```1```!^<```!$```'YT```$0```?G@```1```!^?```!$```'Z````$ -M0```?H0```1```!^B```!$```'Z,```$0```?I````1```!^E```!$```'Z8 -M```$0```?IP```1```!^H```!$```'ZD```$0```?J@```1```!^K```!$`` -M`'ZP```$0```?K0```1```!^N```!$```'Z\```$0```?L````1```!^Q``` -M!$```'[(```$0```?LP```1```!^T```!$```'[4```$0```?M@```1```!^ -MW```!$```'[@```$0```?N0```1```!^Z```!$```'[L```$0```?O````1` -M``!^]```!$```'[X```$0```?OP```1```!_````!$```'\$```$0```?P@` -M``1```!_#```!$```'\0```$0```?Q0```1```!_&```!$```'\<```$0``` -M?R````1```!_)```!$```'\H```$0```?RP```1```!_,```!$```'\T```$ -M0```?S@```1```!_/```!$```']````$0```?T0```1```!_2```!$```'], -M```$0```?U````1```!_5```!$```']8```$0```?UP```1```!_8```!$`` -M`']D```$0```?V@```1```!_;```!$```']P```$0```?W0```1```!_>``` -M!$```']\```$0```?X````1```!_A```!$```'^(```$0```?XP```1```!_ -MD```!$```'^4```$0```?Y@```1```!_G```!$```'^@```$0```?Z0```1` -M``!_J```!$```'^L```$0```?[````1```!_M```!$```'^X```$0```?[P` -M``1```!_P```!$```'_$```$0```?\@```1```!_S```!$```'_0```$0``` -M?]0```1```!_V```!$```'_<```$0```?^````1```!_Y```!$```'_H```$ -M0```?^P```1```!_\```!$```'_T```$0```?_@```1```!__```!$```(`` -M```$0```@`0```1```"`"```!$```(`,```$0```@!````1```"`%```!$`` -M`(`8```$0```@!P```1```"`(```!$```(`D```$0```@"@```1```"`+``` -M!$```(`P```$0```@#0```1```"`.```!$```(`\```$0```@$````1```"` -M1```!$```(!(```$0```@$P```1```"`4```!$```(!4```$0```@%@```1` -M``"`7```!$```(!@```$0```@&0```1```"`:```!$```(!L```$0```@'`` -M``1```"`=```!$```(!X```$0```@'P```1```"`@```!$```("$```$0``` -M@(@```1```"`C```!$```("0```$0```@)0```1```"`F```!$```("<```$ -M0```@*````1```"`I```!$```("H```$0```@*P```1```"`L```!$```("T -M```$0```@+@```1```"`O```!$```(#````$0```@00```1```"!"```!$`` -M`($,```$0```@1````1```"!%```!$```($8```$0```@1P```1```"!(``` -M!$```($D```$0```@2@```1```"!+```!$```($P```$0```@30```1```"! -M.```!$```($\```$0```@4````1```"#0@`<2M```(2L```$0```A+````1` -M``"$M```!$```(2X```$0```A+P```1```"$P```!$```(3$```$0```A,@` -M``1```"$S```!$```(30```$0```A-0```1```"$V```!$```(3<```$0``` -MA.````1```"$Y```!$```(3H```$0```AB@```1```"&+```!$```(8P```$ -M0```AC0```1```"&.```!$```(8\```$0```AD````1```"&1```!$```(9( -M```$0```ADP```1```"&4```!$```(94```$0```AE@```1```"&7```!$`` -M`(9@```$0```AF0```1```"&:```!$```(9L```$0```AG````1```"&=``` -M!$```(9X```$0```AGP```1```"&@```!$```(:$```$0```AV8`'(O0``"' -M=```!,```(>4`!Q*T```A]@`'"_0``"(*```!,```(@Z`!Q4T```B*0`'$+0 -M``"**@``!,```(I>```$P```BFX`'(30``"*M@`<0M```(KV`!R-T```BQ`` -M')#0``"+5```!,```(M^`!Q]T```BYX```3```"+S@`0(```#___^$````@P(```#___^$````BP(```#___^%```` -ME@(```#___^&````H@(```#___^'````KP(```#___^(````N@(```#___^, -M````P@(```#___^<````R@(```#___^T````U`(```#___^U````WP(```#_ -M__^V````Z`(```#___^W````\`(```#___^X````^@(```#___^Y```!`P(` -M``#___^Z```!"P(```#___^[```!$P(```#____````!&P(```#____0```! -M(P(```#____@```!*P(```#____P```!,P(```#___[D```!/0(```#___[E -M```!3`(```#___[T```!4P(```#___[T```!70(```#___[X```!9P(```#_ -M__[\```!<0(```#___[V```!?`(```#___\````!B`(```#___\$```!D`(` -M``#___\,```!F0(```#___\0```!H@(```#___\4```!J0(````````!```! -MMP(````````````!Q`(```#___\5```!RP(````````'```!V0(````````& -M```!Y@(````````%```!\P(````````$```"`0(````````#```"#@(````` -M```"```"'`(````````!```"*0(````````````"-@(```#___\8```".P(` -M``#___\8```"1@(````````!```"4`(````````````"6@(```````#@```" -M9`(````````'```";P(````````$```">P(````````"```"B`(````````! -M```"E`(````````````"H`(```#___\9```"IP(````````'```"L@(```#_ -M__\<```"NP(````````,```"Q0(```#___\=```"S0(````````%```"VP(` -M```````,```"Y0(```#___\@```"Z@(```````#@```"]`(````````$```# -M`0(```#___\A```#"0(````````$```#%@(```#___\D```#'0(````````" -M```#(`(````````!```#(P(````````````#*0(```#___\E```#,`(````` -M```'```#-@(````````%```#/`(````````$```#0@(```#___\H```#20(` -M``#___\H```#4P(```#___\L```#70(```#___\P```#9P(```#___\J```# -M<@(```#___\T```#>`(```#___\T```#@0(```#___\X```#B@(```#___\\ -M```#DP(```#___\V```#G0(````````$```#I`(````````&```#JP(````` -M```*```#LP(````````,```#N@(````````#```#P@(````````"```#R`(` -M```````!```#T`(````````````#V`(````````'```#X0(````````'```# -MZ@(````````&```#\P(````````%```#_0(````````$```$!@(````````# -M```$#P(````````"```$%@(````````!```$(`(````````````$*@(````` -M```'```$,P(````````&```$/0(````````%```$1P(````````$```$3P(` -M```````#```$60(````(```````$8@(````$```````$:0(````"```````$ -M<@(````!```````$>P(``````(`````$A0(``````$`````$CP(``````"`` -M```$F@(``````!`````$I`(```````@````$K@(```````0````$M@(````` -M``(````$P0(```````$````$S`(```````"````$U@(```````!````$X0(` -M```````@```$[`(````````0```$]0(````````(```%``(````"``00```% -M"P(````!`""````%%@(````!____```%'P(```````HH```%*P(```````H( -M```%.`(``````!)(```%1`(```````$(```%3P(```````((```%6@(````! -M`$"````%9P(````!``"````%```'L`0```````*$```'MP0```````*2```'O@0```````*R -M```'Q@0```````+8```'S00```````-@```'U`0```````+L```'VP0````` -M``+V```'X@0```````,.```'Z@0```````,R```'\00```````.:```'^`0` -M``````-.```'_P0```````-J```(!@0```````-T```(#00```````/8```( -M%`0```````/0```(&P0```````/@```((00```````/P```()P0```````/X -M```(+@0```````0F```(.00```````00```(0@0```````0^```(200````` -M``0<```(4@0```````0V```(6P0```````1D```(9@0```````1<```(;00` -M``````2@```(=`0```````2P```(>P0```````2V```(@A\```````30```( -MBP(```#___]````(DP(```#___]````(FP(```#___]$```(HP(```#___]( -M```(JP(```#___],```(LP(```#___]0```(O`(```#___]<```(Q0(```#_ -M__]H```(S@(```#___]T```(UP(```#___^````(X0(```#___^"```([0(` -M``#___^#```(]P(```#___^$```)`0(```#___^$```)"0(```#___^%```) -M%`(```#___^&```)(`(```#___^'```)+0(```#___^(```).`(```#___^, -M```)0`(```#___^<```)2`(```#___^T```)4@(```#___^U```)70(```#_ -M__^V```)9@(```#___^W```);@(```#___^X```)>`(```#___^Y```)@0(` -M``#___^Z```)B0(```#___^[```)D0(```#____````)F0(```#____0```) -MH0(```#____@```)J0(```#____P```)L0(```#___[D```)NP(```#___[E -M```)R@(```#___[T```)T0(```#___[T```)VP(```#___[X```)Y0(```#_ -M__[\```)[P(```#___[V```)^@(```#___\````*!@(```#___\$```*#@(` -M``#___\,```*%P(```#___\0```*(`(```#___\4```*)P(````````!```* -M-0(````````````*0@(```#___\5```*20(````````'```*5P(````````& -M```*9`(````````%```*<0(````````$```*?P(````````#```*C`(````` -M```"```*F@(````````!```*IP(````````````*M`(```#___\8```*N0(` -M``#___\8```*Q`(````````!```*S@(````````````*V`(```````#@```* -MX@(````````'```*[0(````````$```*^0(````````"```+!@(````````! -M```+$@(````````````+'@(```#___\9```+)0(````````'```+,`(```#_ -M__\<```+.0(````````,```+0P(```#___\=```+2P(````````%```+60(` -M```````,```+8P(```#___\@```+:`(```````#@```+<@(````````$```+ -M?P(```#___\A```+AP(````````$```+E`(```#___\D```+FP(````````" -M```+G@(````````!```+H0(````````````+IP(```#___\E```+K@(````` -M```'```+M`(````````%```+N@(````````$```+P`(```#___\H```+QP(` -M``#___\H```+T0(```#___\L```+VP(```#___\P```+Y0(```#___\J```+ -M\`(```#___\T```+]@(```#___\T```+_P(```#___\X```,"`(```#___\\ -M```,$0(```#___\V```,&P(````````$```,(@(````````&```,*0(````` -M```*```,,0(````````,```,.`(````````#```,0`(````````"```,1@(` -M```````!```,3@(````````````,5@(````````'```,7P(````````'```, -M:`(````````&```,<0(````````%```,>P(````````$```,A`(````````# -M```,C0(````````"```,E`(````````!```,G@(````````````,J`(````` -M```'```,L0(````````&```,NP(````````%```,Q0(````````$```,S0(` -M```````#```,UP(````(```````,X`(````$```````,YP(````"```````, -M\`(````!```````,^0(``````(`````-`P(``````$`````-#0(``````"`` -M```-&`(``````!`````-(@(```````@````-+`(```````0````--`(````` -M``(````-/P(```````$````-2@(```````"````-5`(```````!````-7P(` -M```````@```-:@(````````0```-P(````````'```.A`(````````=```.D0(````!@``````.F0(` -M```````````.H@(````````@```.JP(```````!````.LP(```````!@```. -MNP(```````"````.Q`(```````!````.R@(```````!````.T0(```````!! -M```.V`(```````!D```.X@(```#___[<```.[0(````````L```.^P(````` -M```T```/"0(````````$```/$P(```#___\\```/'@(``````"`D```/*`(` -M```````L```/,@(``````"`L```//`(```````#$```/10(``````#P!```/ -M4`(``````#^!```/6P0```````38```/8`0```````44```/:`0```````4" -M```/;@0```````4F```/=Q\```````4L```/@`(```#___]````/B`(```#_ -M__]````/D`(```#___]$```/F`(```#___](```/H`(```#___],```/J`(` -M``#___]0```/L0(```#___]<```/N@(```#___]H```/PP(```#___]T```/ -MS`(```#___^````/U@(```#___^"```/X@(```#___^#```/[`(```#___^$ -M```/]@(```#___^$```/_@(```#___^%```0"0(```#___^&```0%0(```#_ -M__^'```0(@(```#___^(```0+0(```#___^,```0-0(```#___^<```0/0(` -M``#___^T```01P(```#___^U```04@(```#___^V```06P(```#___^W```0 -M8P(```#___^X```0;0(```#___^Y```0=@(```#___^Z```0?@(```#___^[ -M```0A@(```#____````0C@(```#____0```0E@(```#____@```0G@(```#_ -M___P```0I@(```#___[D```0L`(```#___[E```0OP(```#___[T```0Q@(` -M``#___[T```0T`(```#___[X```0V@(```#___[\```0Y`(```#___[V```0 -M[P(```#___\````0^P(```#___\$```1`P(```#___\,```1#`(```#___\0 -M```1%0(```#___\4```1'`(````````!```1*@(````````````1-P(```#_ -M__\5```1/@(````````'```13`(````````&```160(````````%```19@(` -M```````$```1=`(````````#```1@0(````````"```1CP(````````!```1 -MG`(````````````1J0(```#___\8```1K@(```#___\8```1N0(````````! -M```1PP(````````````1S0(```````#@```1UP(````````'```1X@(````` -M```$```1[@(````````"```1^P(````````!```2!P(````````````2$P(` -M``#___\9```2&@(````````'```2)0(```#___\<```2+@(````````,```2 -M.`(```#___\=```20`(````````%```23@(````````,```26`(```#___\@ -M```270(```````#@```29P(````````$```2=`(```#___\A```2?`(````` -M```$```2B0(```#___\D```2D`(````````"```2DP(````````!```2E@(` -M```````````2G`(```#___\E```2HP(````````'```2J0(````````%```2 -MKP(````````$```2M0(```#___\H```2O`(```#___\H```2Q@(```#___\L -M```2T`(```#___\P```2V@(```#___\J```2Y0(```#___\T```2ZP(```#_ -M__\T```2]`(```#___\X```2_0(```#___\\```3!@(```#___\V```3$`(` -M```````$```3%P(````````&```3'@(````````*```3)@(````````,```3 -M+0(````````#```3-0(````````"```3.P(````````!```30P(````````` -M```32P(````````'```35`(````````'```370(````````&```39@(````` -M```%```3<`(````````$```3>0(````````#```3@@(````````"```3B0(` -M```````!```3DP(````````````3G0(````````'```3I@(````````&```3 -ML`(````````%```3N@(````````$```3P@(````````#```3S`(````(```` -M```3U0(````$```````3W`(````"```````3Y0(````!```````3[@(````` -M`(`````3^`(``````$`````4`@(``````"`````4#0(``````!`````4%P(` -M``````@````4(0(```````0````4*0(```````(````4-`(```````$````4 -M/P(```````"````420(```````!````45`(````````@```47P(````````0 -M```4:`(````````(```40(````````=```5A@(````!@``````5C@(````````````5EP(````````@ -M```5H`(```````!````5J`(```````!@```5L`(```````"````5N0(````` -M``!````5OP(```````!````5Q@(```````!!```5S0(```````!D```5UP(` -M``#___[<```5X@(````````L```5\`(````````T```5_@(````````$```6 -M"`(```#___\\```6$P(``````"`D```6'0(````````L```6)P(``````"`L -M```6,0(```````#$```6.@(``````#P!```610(``````#^!```64`0````` -M``4L```65P(````````'```670(````````````68P(````````$```6:0(` -M```````"```6<00```````4\```6=P0```````5````6?`0```````5$```6 -M@0(````````*```6A00```````5H```6B@0```````6$```6D`0```````6: -M```6EP0```````6N```6G@0```````6V```6HP0```````7*```6J@0````` -M``76```6L00```````8B```6N00```````80```6P00```````84```6R00` -M``````8\```6T00```````9,```6V00```````96```6X00```````9X```6 -MZ00```````9\```6\00```````:*```6^00```````:D```7`00```````:T -M```7"00```````:^```7$00```````;\```7&`0```````<.```7'P0````` -M``<(```7)@0```````<:```7+00```````@(```#____@```8@@(```#____P -M```8B@(```#___[D```8E`(```#___[E```8HP(```#___[T```8J@(```#_ -M__[T```8M`(```#___[X```8O@(```#___[\```8R`(```#___[V```8TP(` -M``#___\````8WP(```#___\$```8YP(```#___\,```8\`(```#___\0```8 -M^0(```#___\4```9``(````````!```9#@(````````````9&P(```#___\5 -M```9(@(````````'```9,`(````````&```9/0(````````%```92@(````` -M```$```96`(````````#```990(````````"```9@(````` -M```````:@`(```#___\E```:AP(````````'```:C0(````````%```:DP(` -M```````$```:F0(```#___\H```:H`(```#___\H```:J@(```#___\L```: -MM`(```#___\P```:O@(```#___\J```:R0(```#___\T```:SP(```#___\T -M```:V`(```#___\X```:X0(```#___\\```:Z@(```#___\V```:]`(````` -M```$```:^P(````````&```;`@(````````*```;"@(````````,```;$0(` -M```````#```;&0(````````"```;'P(````````!```;)P(````````````; -M+P(````````'```;.`(````````'```;00(````````&```;2@(````````% -M```;5`(````````$```;70(````````#```;9@(````````"```;;0(````` -M```!```;=P(````````````;@0(````````'```;B@(````````&```;E`(` -M```````%```;G@(````````$```;I@(````````#```;L`(````(```````; -MN0(````$```````;P`(````"```````;R0(````!```````;T@(``````(`` -M```;W`(``````$`````;Y@(``````"`````;\0(``````!`````;^P(````` -M``@````P(````````@```= -MA`(```````!````=C`(```````!@```=E`(```````"````=G0(```````!` -M```=HP(```````!````=J@(```````!!```=L0(```````!D```=NP(```#_ -M__[<```=Q@(````````L```=U`(````````T```=X@(````````$```=[`(` -M``#___\\```=]P(``````"`D```>`0(````````L```>"P(``````"`L```> -M%0(```````#$```>'@(``````#P!```>*0(``````#^!```>-`0```````=D -M```>.00```````=P```>/@0```````=\```>1`0```````>(```>2@0````` -M``>4```>3P0```````>@```>5`0```````>L```>600```````>X```>8`0` -M``````?$```>9P0```````?H```>?`0```````E^```> -M@@0```````GL```>C`0```````H2```>E00```````GD```>GP0```````GP -M```>J`0```````GH```>L@0```````H&```>NP0```````HH```>Q`0````` -M``HV```>S00```````I$```>TP0```````JR```>W00```````K8```>Y@0` -M``````JJ```>\`0```````JV```>^00```````JN```?`P0```````K,```? -M#`0```````KN```?%00```````K\```?'@0```````L*```?)@0```````ML -M```?+@0```````N0```?-P0```````MT```?/P0```````N"```?1P0````` -M``MP```?4`0```````ND```?6`0```````NJ```?8A\```````QD```?;P0` -M``````QD```?>@(```#___]````?@@(```#___]````?B@(```#___]$```? -MD@(```#___](```?F@(```#___],```?H@(```#___]0```?JP(```#___]< -M```?M`(```#___]H```?O0(```#___]T```?Q@(```#___^````?T`(```#_ -M__^"```?W`(```#___^#```?Y@(```#___^$```?\`(```#___^$```?^`(` -M``#___^%```@`P(```#___^&```@#P(```#___^'```@'`(```#___^(```@ -M)P(```#___^,```@+P(```#___^<```@-P(```#___^T```@00(```#___^U -M```@3`(```#___^V```@50(```#___^W```@70(```#___^X```@9P(```#_ -M__^Y```@<`(```#___^Z```@>`(```#___^[```@@`(```#____````@B`(` -M``#____0```@D`(```#____@```@F`(```#____P```@H`(```#___[D```@ -MJ@(```#___[E```@N0(```#___[T```@P`(```#___[T```@R@(```#___[X -M```@U`(```#___[\```@W@(```#___[V```@Z0(```#___\````@]0(```#_ -M__\$```@_0(```#___\,```A!@(```#___\0```A#P(```#___\4```A%@(` -M```````!```A)`(````````````A,0(```#___\5```A.`(````````'```A -M1@(````````&```A4P(````````%```A8`(````````$```A;@(````````# -M```A>P(````````"```AB0(````````!```AE@(````````````AHP(```#_ -M__\8```AJ`(```#___\8```ALP(````````!```AO0(````````````AQP(` -M``````#@```AT0(````````'```AW`(````````$```AZ`(````````"```A -M]0(````````!```B`0(````````````B#0(```#___\9```B%`(````````' -M```B'P(```#___\<```B*`(````````,```B,@(```#___\=```B.@(````` -M```%```B2`(````````,```B4@(```#___\@```B5P(```````#@```B80(` -M```````$```B;@(```#___\A```B=@(````````$```B@P(```#___\D```B -MB@(````````"```BC0(````````!```BD`(````````````BE@(```#___\E -M```BG0(````````'```BHP(````````%```BJ0(````````$```BKP(```#_ -M__\H```BM@(```#___\H```BP`(```#___\L```BR@(```#___\P```BU`(` -M``#___\J```BWP(```#___\T```BY0(```#___\T```B[@(```#___\X```B -M]P(```#___\\```C``(```#___\V```C"@(````````$```C$0(````````& -M```C&`(````````*```C(`(````````,```C)P(````````#```C+P(````` -M```"```C-0(````````!```C/0(````````````C10(````````'```C3@(` -M```````'```C5P(````````&```C8`(````````%```C:@(````````$```C -M`(````!`""````D@P(````!____```DC`(```````HH```D -MF`(```````H(```DI0(``````!)(```DL0(```````$(```DO`(```````(( -M```DQP(````!`$"````DU`(````!``"````DX`(````*```````D[`(````" -M``"````D^0(````,```````E`P(``````""````E#@(```````@H```E'`(` -M`````!!(```E*@(````````````E,0(```````!````E.`(```````"````E -M/P(````````````E1P(````````0```E3P(````````@```E5P(````````P -M```E7P(````````&```E:@(````````'```E`0``````!`D```G?@0```````_(```GAP0``````!`8```GCP0````` -M``_0```GE@0```````_:```GG00```````_X```GI`0``````!`"```GJQ\` -M`````!`L```GM`0``````!`L```GNP(```#___]````GPP(```#___]````G -MRP(```#___]$```GTP(```#___](```GVP(```#___],```GXP(```#___]0 -M```G[`(```#___]<```G]0(```#___]H```G_@(```#___]T```H!P(```#_ -M__^````H$0(```#___^"```H'0(```#___^#```H)P(```#___^$```H,0(` -M``#___^$```H.0(```#___^%```H1`(```#___^&```H4`(```#___^'```H -M70(```#___^(```H:`(```#___^,```H<`(```#___^<```H>`(```#___^T -M```H@@(```#___^U```HC0(```#___^V```HE@(```#___^W```HG@(```#_ -M__^X```HJ`(```#___^Y```HL0(```#___^Z```HN0(```#___^[```HP0(` -M``#____````HR0(```#____0```HT0(```#____@```HV0(```#____P```H -MX0(```#___[D```HZP(```#___[E```H^@(```#___[T```I`0(```#___[T -M```I"P(```#___[X```I%0(```#___[\```I'P(```#___[V```I*@(```#_ -M__\````I-@(```#___\$```I/@(```#___\,```I1P(```#___\0```I4`(` -M``#___\4```I5P(````````!```I90(````````````I<@(```#___\5```I -M>0(````````'```IAP(````````&```IE`(````````%```IH0(````````$ -M```IKP(````````#```IO`(````````"```IR@(````````!```IUP(````` -M```````IY`(```#___\8```IZ0(```#___\8```I]`(````````!```I_@(` -M```````````J"`(```````#@```J$@(````````'```J'0(````````$```J -M*0(````````"```J-@(````````!```J0@(````````````J3@(```#___\9 -M```J50(````````'```J8`(```#___\<```J:0(````````,```JP(````````%```JB0(````````,```JDP(```#___\@```JF`(` -M``````#@```JH@(````````$```JKP(```#___\A```JMP(````````$```J -MQ`(```#___\D```JRP(````````"```JS@(````````!```JT0(````````` -M```JUP(```#___\E```JW@(````````'```JY`(````````%```JZ@(````` -M```$```J\`(```#___\H```J]P(```#___\H```K`0(```#___\L```K"P(` -M``#___\P```K%0(```#___\J```K(`(```#___\T```K)@(```#___\T```K -M+P(```#___\X```K.`(```#___\\```K00(```#___\V```K2P(````````$ -M```K4@(````````&```K60(````````*```K80(````````,```K:`(````` -M```#```K<`(````````"```K=@(````````!```K?@(````````````KA@(` -M```````'```KCP(````````'```KF`(````````&```KH0(````````%```K -MJP(````````$```KM`(````````#```KO0(````````"```KQ`(````````! -M```KS@(````````````KV`(````````'```KX0(````````&```KZP(````` -M```%```K]0(````````$```K_0(````````#```L!P(````(```````L$`(` -M```$```````L%P(````"```````L(`(````!```````L*0(``````(`````L -M,P(``````$`````L/0(``````"`````L2`(``````!`````L4@(```````@` -M```L7`(```````0````L9`(```````(````L;P(```````$````L>@(````` -M``"````LA`(```````!````LCP(````````@```LF@(````````0```LHP(` -M```````(```LK@(````"``00```LN0(````!`""````LQ`(````!____```L -MS0(```````HH```LV0(```````H(```LY@(``````!)(```L\@(```````$( -M```L_0(```````((```M"`(````!`$"````M%0(````!``"````M(0(````* -M```````M+0(````"``"````M.@(````,```````M1`(``````""````M3P(` -M``````@H```M70(``````!!(```M:P(````````````M<@(```````!````M -M>0(```````"````M@`(````````````MB`(````````0```MD`(````````@ -M```MF`(````````P```MH`(````````&```MJP(````````'```MM`(````` -M```=```MP0(````!@``````MR0(````````````MT@(````````@```MVP(` -M``````!````MXP(```````!@```MZP(```````"````M]`(```````!````M -M^@(```````!````N`0(```````!!```N"`(```````!D```N$@(```#___[< -M```N'0(````````L```N*P(````````T```N.0(````````$```N0P(```#_ -M__\\```N3@(``````"`D```N6`(````````L```N8@(``````"`L```N;`(` -M``````#$```N=0(``````#P!```N@`(``````#^!```NBP0``````!28```N -ME`0``````!-N```NH@0``````!1$```NK@0``````!2L```NN`0``````!/4 -M```NP@0``````!.\```NS@0``````!.4```NV@0``````!.J```NY00````` -M`!32```N[00``````!2J```N]P0``````!0"```O`P0``````!/F```O#P0` -M`````!00```O&00``````!0*```O(P0``````!04```O*@0``````!0@```O -M+@0``````!5P```O-00``````!18```O/@0``````!3,```O1@0``````!3& -M```O3@0``````!3N```O5P0``````!54```O8`0``````!4````O9P0````` -M`!3\```O;P0``````!4X```O=P0``````!4>```O?P0``````!4.```OA@0` -M`````!4<```OD00``````!4V```OF00``````!4J```OH@0``````!5,```O -MJ@0``````!5$```OL@0``````!5H```ON@0``````!5@```OP@0``````!8@ -M```OS@0``````!6Z```OUP0``````!6D```OWP0``````!<````OY@0````` -M`!8"```O[P0``````!7R```O^`0``````!:@```P`@0``````!9@```P"P0` -M`````!:,```P$P0``````!;N```P'00``````!;8```P)P0``````!<,```P -M,`0``````!```P<@0``````!=@```P>A\``````!=D```PA@0``````!=D```PD`(` -M``#___]````PF`(```#___]````PH`(```#___]$```PJ`(```#___](```P -ML`(```#___],```PN`(```#___]0```PP0(```#___]<```PR@(```#___]H -M```PTP(```#___]T```PW`(```#___^````PY@(```#___^"```P\@(```#_ -M__^#```P_`(```#___^$```Q!@(```#___^$```Q#@(```#___^%```Q&0(` -M``#___^&```Q)0(```#___^'```Q,@(```#___^(```Q/0(```#___^,```Q -M10(```#___^<```Q30(```#___^T```Q5P(```#___^U```Q8@(```#___^V -M```Q:P(```#___^W```Q`(````````(```U@P(````"``00```UC@(` -M```!`""````UF0(````!____```UH@(```````HH```UK@(```````H(```U -MNP(``````!)(```UQP(```````$(```UT@(```````((```UW0(````!`$"` -M```UZ@(````!``"````U]@(````*```````V`@(````"``"````V#P(````, -M```````V&0(``````""````V)`(```````@H```V,@(``````!!(```V0`(` -M```````````V1P(```````!````V3@(```````"````V50(````````````V -M70(````````0```V90(````````@```V;0(````````P```V=0(````````& -M```V@`(````````'```VB0(````````=```VE@(````!@``````VG@(````` -M```````VIP(````````@```VL`(```````!````VN`(```````!@```VP`(` -M``````"````VR0(```````!````VSP(```````!````VU@(```````!!```V -MW0(```````!D```VYP(```#___[<```V\@(````````L```W``(````````T -M```W#@(````````$```W&`(```#___\\```W(P(``````"`D```W+0(````` -M```L```W-P(``````"`L```W00(```````#$```W2@(``````#P!```W50(` -M`````#^!```W8`0``````!=D```W:`0``````!=P```W<`0``````!=\```W -M=`0``````!>(```W>00``````!?T```WA`0``````!?$```WB@0``````!?F -M```WD00``````!?4```WEP0``````!?<```WH`0``````!@<```WIP0````` -M`!@X```WLP0``````!A$```WO`0``````!AD```WQ00``````!A,```WS@0` -M`````!B,```WUP0``````!CT```WW@0``````!C4```WY`0``````!B^```W -MZ@0``````!CB```W]`0``````!D@```W_`0``````!C\```X!`0``````!DX -M```X#`0``````!E@```X%00``````!EP```X'00``````!FB```X)@0````` -M`!F@```X+@0``````!F^```X-@0``````!GF```X/@0``````!GZ```X1P0` -M`````!HB```X3P0``````!I.```X600``````!JP```X8P0``````!I6```X -M;00``````!J"```X=@0``````!J6```X>P0``````!K(```X@P0``````!JX -M```XB@0``````!KD```XE@0``````!N````XGP0``````!MZ```XJ`0````` -M`!L^```XL`0``````!LV```XNP0``````!MJ```XPQ\``````!N(```XS@0` -M`````!N(```XUP(```#___]````XWP(```#___]````XYP(```#___]$```X -M[P(```#___](```X]P(```#___],```X_P(```#___]0```Y"`(```#___]< -M```Y$0(```#___]H```Y&@(```#___]T```Y(P(```#___^````Y+0(```#_ -M__^"```Y.0(```#___^#```Y0P(```#___^$```Y30(```#___^$```Y50(` -M``#___^%```Y8`(```#___^&```Y;`(```#___^'```Y>0(```#___^(```Y -MA`(```#___^,```YC`(```#___^<```YE`(```#___^T```YG@(```#___^U -M```YJ0(```#___^V```YL@(```#___^W```YN@(```#___^X```YQ`(```#_ -M__^Y```YS0(```#___^Z```YU0(```#___^[```YW0(```#____````YY0(` -M``#____0```Y[0(```#____@```Y]0(```#____P```Y_0(```#___[D```Z -M!P(```#___[E```Z%@(```#___[T```Z'0(```#___[T```Z)P(```#___[X -M```Z,0(```#___[\```Z.P(```#___[V```Z1@(```#___\````Z4@(```#_ -M__\$```Z6@(```#___\,```Z8P(```#___\0```Z;`(```#___\4```Z`(```````0` -M```]@`(```````(````]BP(```````$````]E@(```````"````]H`(````` -M``!````]JP(````````@```]M@(````````0```]OP(````````(```]R@(` -M```"``00```]U0(````!`""````]X`(````!____```]Z0(```````HH```] -M]0(```````H(```^`@(``````!)(```^#@(```````$(```^&0(```````(( -M```^)`(````!`$"````^,0(````!``"````^/0(````*```````^20(````" -M``"````^5@(````,```````^8`(``````""````^:P(```````@H```^>0(` -M`````!!(```^AP(````````````^C@(```````!````^E0(```````"````^ -MG`(````````````^I`(````````0```^K`(````````@```^M`(````````P -M```^O`(````````&```^QP(````````'```^T`(````````=```^W0(````! -M@``````^Y0(````````````^[@(````````@```^]P(```````!````^_P(` -M``````!@```_!P(```````"````_$`(```````!````_%@(```````!````_ -M'0(```````!!```_)`(```````!D```_+@(```#___[<```_.0(````````L -M```_1P(````````T```_50(````````$```_7P(```#___\\```_:@(````` -M`"`D```_=`(````````L```_?@(``````"`L```_B`(```````#$```_D0(` -M`````#P!```_G`(``````#^!```_IP0``````!N(```_KP0``````!N0```_ -MMP0``````!OJ```_OP0``````!NJ```_Q@0``````!O8```_RP0``````"J( -M```_U`0``````![6```_W00``````!\H```_Y`0``````!P<```_[`0````` -M`!S*```_]00``````!RD```__00``````!RX``!`!00``````!Q$``!`#00` -M`````!Q:``!`%00``````!R&``!`'00``````!QV``!`)`0``````!RB``!` -M+`0``````"EN``!`-00``````!S^``!`/00``````!U0``!`100``````!SJ -M``!`300``````!ZL``!`5@0``````!VF``!`7P0``````!T\``!`:`0````` -M`!V>``!`<00``````!V.``!`>@0``````!W"``!`A`0``````!WJ``!`BP0` -M`````!WT``!`D@0``````!WZ``!`F@0``````!X8``!`HP0``````!XH``!` -MK00``````!Z4``!`MP0``````!Y^``!`OP0``````!Y8``!`Q@0``````!Y( -M``!`S00``````!YR``!`U@0``````!YF``!`WP0``````!Z<``!`YP0````` -M`!ZZ``!`\00``````!["``!`^@0``````![T``!!`@0``````!]&``!!"@0` -M`````!\6``!!#P0``````"&8``!!%P0``````!\P``!!'P0``````!_<``!! -M*`0``````!_.``!!,`0``````!_6``!!.`0``````!]N``!!0`0``````!^$ -M``!!2`0``````!^P``!!4`0``````!^@``!!5P0``````!_,``!!7P0````` -M`"`$``!!9P0``````"`H``!!;P0``````!_P``!!=P0``````"!,``!!@`0` -M`````"`<``!!B`0``````"!H``!!CP0``````"",``!!EP0``````""L``!! -MG@0``````"#8``!!I@0``````"!```!!K@0``````"$```!!M00``````"$D -M``!!O00``````"%$``!!Q`0``````"%P``!!S`(````````B``!!U`(````` -M```H``!!W`(````````C``!!Y`(````````@``!![`(````````X``!!]`0` -M`````"+.``!!_00``````"4F``!"!@0``````"?V``!"#P0``````">"``!" -M&`0``````"'$``!"(00``````")&``!"*@0``````"'6``!"-`0``````"(6 -M``!"/00``````"A$``!"1P0``````"(B``!"400``````"(>``!"6@0````` -M`")"``!"900``````"*```!";P0``````"*N``!">P0``````"*J``!"A@0` -M`````"*T``!"D00``````"CP``!"F`0``````",&``!"H00``````"+@``!" -MJP0``````",H``!"M`0``````"0J``!"O00``````".V``!"R`0``````"BH -M``!"T`0``````"2>``!"VP0``````"0R``!"YP0``````"1V``!"\@0````` -M`"4&``!"_`0``````"3B``!#!P0``````"5>``!#$`0``````"4X``!#&@0` -M`````"6```!#(P0``````":"``!#+`0``````"8.``!#-P0``````";Z``!# -M0@0``````":*``!#3@0``````";$``!#6`0``````";B``!#8P0``````"=B -M``!#;00``````"<^``!#>`0``````"?```!#@00``````">4``!#BP0````` -M`"?L``!#E`0``````"@H``!#G00``````"@(``!#IP0``````"AN``!#L@0` -M`````"B*``!#O@0``````"B&``!#R00``````"B0``!#U`0``````"C```!# -MX`0``````"B\``!#ZP0``````"C*``!#]@0``````"CH``!$`00``````"D, -M``!$"00``````"E:``!$$@0``````"E&``!$&P0``````"DR``!$)`0````` -M`"D>``!$+00``````"F6``!$-@0``````"F,``!$/P0``````"G(``!$2@0` -M`````"H*``!$5`0``````"GN``!$8`0``````"HF``!$9P0``````"IT``!$ -M;P0``````"I@``!$=P0``````"I,``!$?P0``````"HX``!$AP0``````"_R -M``!$D`0``````"K```!$EP0``````"J@``!$G@0``````"LJ``!$H00````` -M`"UV``!$I00``````"U:``!$J`0``````"K0``!$L@0``````"N\``!$M00` -M`````"VH``!$N`0``````"PZ``!$NP0``````"KF``!$PP0``````"L&``!$ -MS00``````"L(``!$V`0``````"LH``!$XP0``````"RX``!$[`0``````"M\ -M``!$]`0``````"N<``!$_`0``````"T,``!%!`0``````"S^``!%#@0````` -M`"ST``!%%@0``````"P&``!%'@0``````"P@``!%)@0``````"R$``!%+@0` -M`````"R>``!%-@0``````"S>``!%/00``````"TB``!%1`0``````"U(``!% -M3`0``````"U.``!%4P0``````"X<``!%600``````"W8``!%7P0``````"Z0 -M``!%:`0``````"X\``!%<00``````"[L``!%>00``````"Z^``!%@@0````` -M`"YF``!%BP0``````"\H``!%DP0``````"X2``!%F`0``````"X(``!%G00` -M`````"W^``!%H@0``````"^6``!%J@0``````"]D``!%LP0``````"^V``!% -MN`0``````"^^``!%P`0``````#!0``!%R`0``````#!D``!%T`0``````#!X -M``!%V`0``````"_2``!%WP0``````#"$``!%Y@0``````#"*``!%[00````` -M`#"0``!%]`0``````#"4``!%^P0``````#"8``!&`@0``````#"<``!&"00` -M`````#"@``!&$`0``````#"F``!&%P0``````#`$``!&'P0``````#`T``!& -M)P0``````#`F``!&,!\``````#"L``!&.`(```#___]```!&0`(```#___]` -M``!&2`(```#___]$``!&4`(```#___](``!&6`(```#___],``!&8`(```#_ -M__]0``!&:0(```#___]<``!&<@(```#___]H``!&>P(```#___]T``!&A`(` -M``#___^```!&C@(```#___^"``!&F@(```#___^#``!&I`(```#___^$``!& -MK@(```#___^$``!&M@(```#___^%``!&P0(```#___^&``!&S0(```#___^' -M``!&V@(```#___^(``!&Y0(```#___^,``!&[0(```#___^<``!&]0(```#_ -M__^T``!&_P(```#___^U``!'"@(```#___^V``!'$P(```#___^W``!'&P(` -M``#___^X``!')0(```#___^Y``!'+@(```#___^Z``!'-@(```#___^[``!' -M/@(```#____```!'1@(```#____0``!'3@(```#____@``!'5@(```#____P -M``!'7@(```#___[D``!':`(```#___[E``!'=P(```#___[T``!'?@(```#_ -M__[T``!'B`(```#___[X``!'D@(```#___[\``!'G`(```#___[V``!'IP(` -M``#___\```!'LP(```#___\$``!'NP(```#___\,``!'Q`(```#___\0``!' -MS0(```#___\4``!'U`(````````!``!'X@(```````````!'[P(```#___\5 -M``!']@(````````'``!(!`(````````&``!($0(````````%``!('@(````` -M```$``!(+`(````````#``!(.0(````````"``!(1P(````````!``!(5`(` -M``````````!(80(```#___\8``!(9@(```#___\8``!(<0(````````!``!( -M>P(```````````!(A0(```````#@``!(CP(````````'``!(F@(````````$ -M``!(I@(````````"``!(LP(````````!``!(OP(```````````!(RP(```#_ -M__\9``!(T@(````````'``!(W0(```#___\<``!(Y@(````````,``!(\`(` -M``#___\=``!(^`(````````%``!)!@(````````,``!)$`(```#___\@``!) -M%0(```````#@``!)'P(````````$``!)+`(```#___\A``!)-`(````````$ -M``!)00(```#___\D``!)2`(````````"``!)2P(````````!``!)3@(````` -M``````!)5`(```#___\E``!)6P(````````'``!)80(````````%``!)9P(` -M```````$``!);0(```#___\H``!)=`(```#___\H``!)?@(```#___\L``!) -MB`(```#___\P``!)D@(```#___\J``!)G0(```#___\T``!)HP(```#___\T -M``!)K`(```#___\X``!)M0(```#___\\``!)O@(```#___\V``!)R`(````` -M```$``!)SP(````````&``!)U@(````````*``!)W@(````````,``!)Y0(` -M```````#``!)[0(````````"``!)\P(````````!``!)^P(```````````!* -M`P(````````'``!*#`(````````'``!*%0(````````&``!*'@(````````% -M``!**`(````````$``!*,0(````````#``!*.@(````````"``!*00(````` -M```!``!*2P(```````````!*50(````````'``!*7@(````````&``!*:`(` -M```````%``!*<@(````````$``!*>@(````````#``!*A`(````(``````!* -MC0(````$``````!*E`(````"``````!*G0(````!``````!*I@(``````(`` -M``!*L`(``````$````!*N@(``````"````!*Q0(``````!````!*SP(````` -M``@```!*V0(```````0```!*X0(```````(```!*[`(```````$```!*]P(` -M``````"```!+`0(```````!```!+#`(````````@``!+%P(````````0``!+ -M(`(````````(``!+*P(````"``00``!+-@(````!`""```!+00(````!____ -M``!+2@(```````HH``!+5@(```````H(``!+8P(``````!)(``!+;P(````` -M``$(``!+>@(```````((``!+A0(````!`$"```!+D@(````!``"```!+G@(` -M```*``````!+J@(````"``"```!+MP(````,``````!+P0(``````""```!+ -MS`(```````@H``!+V@(``````!!(``!+Z`(```````````!+[P(```````!` -M``!+]@(```````"```!+_0(```````````!,!0(````````0``!,#0(````` -M```@``!,%0(````````P``!,'0(````````&``!,*`(````````'``!,,0(` -M```````=``!,/@(````!@`````!,1@(```````````!,3P(````````@``!, -M6`(```````!```!,8`(```````!@``!,:`(```````"```!,<0(```````!` -M``!,=P(```````!```!,?@(```````!!``!,A0(```````!D``!,CP(```#_ -M__[<``!,F@(````````L``!,J`(````````T``!,M@(````````$``!,P`(` -M``#___\\``!,RP(``````"`D``!,U0(````````L``!,WP(``````"`L``!, -MZ0(```````#$``!,\@(``````#P!``!,_0(``````#^!``!-"`0``````#$H -M``!-$`0``````#"Z``!-&00``````#(\``!-(@0``````##.``!-*P0````` -M`#$4``!--`0``````#$.``!-/00``````##V``!-1@0``````##>``!-3P0` -M`````#&(``!-6`0``````#$R``!-8P0``````#&$``!-;P0``````#%>``!- -M=P0``````#$\``!-?P0``````#%Z``!-AP0``````#%^``!-C@(```````$` -M``!-EP(```````@```!-H`0``````#'&``!-J`0``````#&8``!-L`0````` -M`#'R``!-N`0``````#&N``!-P`0``````#&X``!-R00``````#'F``!-T00` -M`````#'P``!-W@0``````#(6``!-Y@0``````#(@``!-[P0``````#(J``!- -M]00``````#(L``!-_`0``````#)&``!.!`0``````#)8``!.#`0``````#*: -M``!.$P0``````#)X``!.&P0``````#*R``!.(P0``````#+R``!.*00````` -M`#,D``!.-`0``````#,Z``!./`0``````#.T``!.1`0``````#.L``!.3@0` -M`````#->``!.5P0``````#-"``!.8`0``````#-Z``!.:00``````#.(``!. -M<@0``````#.6``!.>P0``````#/,``!.@@0``````#/P``!.B`0``````#/X -M``!.CP0``````#1,``!.E@0``````#2L``!.G00``````#0N``!.I00````` -M`#1"``!.KP0``````#1^``!.N`0``````#2&``!.OP0``````#2B``!.R00` -M`````#2^``!.SP0``````#2V``!.U00``````#3<``!.X`0``````#3L``!. -MZP0``````#3\``!.\00``````#40``!.^P0``````#46``!/`1\``````#4@ -M``!/"00``````#4@``!/#`0``````#4P``!/$@0``````#6>``!/&@0````` -M`#72``!/(1\``````#7@``!/*00``````#7@``!/+P0``````#9$``!/-Q\` -M`````#9X``!//P(```#___]```!/1P(```#___]```!/3P(```#___]$``!/ -M5P(```#___](``!/7P(```#___],``!/9P(```#___]0``!/<`(```#___]< -M``!/>0(```#___]H``!/@@(```#___]T``!/BP(```#___^```!/E0(```#_ -M__^"``!/H0(```#___^#``!/JP(```#___^$``!/M0(```#___^$``!/O0(` -M``#___^%``!/R`(```#___^&``!/U`(```#___^'``!/X0(```#___^(``!/ -M[`(```#___^,``!/]`(```#___^<``!/_`(```#___^T``!0!@(```#___^U -M``!0$0(```#___^V``!0&@(```#___^W``!0(@(```#___^X``!0+`(```#_ -M__^Y``!0-0(```#___^Z``!0/0(```#___^[``!010(```#____```!030(` -M``#____0``!050(```#____@``!070(```#____P``!090(```#___[D``!0 -M;P(```#___[E``!0?@(```#___[T``!0A0(```#___[T``!0CP(```#___[X -M``!0F0(```#___[\``!0HP(```#___[V``!0K@(```#___\```!0N@(```#_ -M__\$``!0P@(```#___\,``!0RP(```#___\0``!0U`(```#___\4``!0VP(` -M```````!``!0Z0(```````````!0]@(```#___\5``!0_0(````````'``!1 -M"P(````````&``!1&`(````````%``!1)0(````````$``!1,P(````````# -M``!10`(````````"``!13@(````````!``!16P(```````````!1:`(```#_ -M__\8``!1;0(```#___\8``!1>`(````````!``!1@@(```````````!1C`(` -M``````#@``!1E@(````````'``!1H0(````````$``!1K0(````````"``!1 -MN@(````````!``!1Q@(```````````!1T@(```#___\9``!1V0(````````' -M``!1Y`(```#___\<``!1[0(````````,``!1]P(```#___\=``!1_P(````` -M```%``!2#0(````````,``!2%P(```#___\@``!2'`(```````#@``!2)@(` -M```````$``!2,P(```#___\A``!2.P(````````$``!22`(```#___\D``!2 -M3P(````````"``!24@(````````!``!250(```````````!26P(```#___\E -M``!28@(````````'``!2:`(````````%``!2;@(````````$``!2=`(```#_ -M__\H``!2>P(```#___\H``!2A0(```#___\L``!2CP(```#___\P``!2F0(` -M``#___\J``!2I`(```#___\T``!2J@(```#___\T``!2LP(```#___\X``!2 -MO`(```#___\\``!2Q0(```#___\V``!2SP(````````$``!2U@(````````& -M``!2W0(````````*``!2Y0(````````,``!2[`(````````#``!2]`(````` -M```"``!2^@(````````!``!3`@(```````````!3"@(````````'``!3$P(` -M```````'``!3'`(````````&``!3)0(````````%``!3+P(````````$``!3 -M.`(````````#``!300(````````"``!32`(````````!``!34@(````````` -M``!37`(````````'``!390(````````&``!3;P(````````%``!3>0(````` -M```$``!3@0(````````#``!3BP(````(``````!3E`(````$``````!3FP(` -M```"``````!3I`(````!``````!3K0(``````(````!3MP(``````$````!3 -MP0(``````"````!3S`(``````!````!3U@(```````@```!3X`(```````0` -M``!3Z`(```````(```!3\P(```````$```!3_@(```````"```!4"`(````` -M``!```!4$P(````````@``!4'@(````````0``!4)P(````````(``!4,@(` -M```"``00``!4/0(````!`""```!42`(````!____``!440(```````HH``!4 -M70(```````H(``!4:@(``````!)(``!4=@(```````$(``!4@0(```````(( -M``!4C`(````!`$"```!4F0(````!``"```!4I0(````*``````!4L0(````" -M``"```!4O@(````,``````!4R`(``````""```!4TP(```````@H``!4X0(` -M`````!!(``!4[P(```````````!4]@(```````!```!4_0(```````"```!5 -M!`(```````````!5#`(````````0``!5%`(````````@``!5'`(````````P -M``!5)`(````````&``!5+P(````````'``!5.`(````````=``!510(````! -M@`````!530(```````````!55@(````````@``!57P(```````!```!59P(` -M``````!@``!5;P(```````"```!5>`(```````!```!5?@(```````!```!5 -MA0(```````!!``!5C`(```````!D``!5E@(```#___[<``!5H0(````````L -M``!5KP(````````T``!5O0(````````$``!5QP(```#___\\``!5T@(````` -M`"`D``!5W`(````````L``!5Y@(``````"`L``!5\`(```````#$``!5^0(` -M`````#P!``!6!`(``````#^!``!6#P0``````#9X``!6%P0``````#:```!6 -M&P0``````#:(``!6(@0``````#:0``!6*00``````#:8``!6,`0``````#:@ -M``!6-P0``````#:H``!6/@0``````#:P``!6100``````#:X``!63`0````` -M`#;```!64P0``````#;(``!66@0``````#;0``!6800``````#;8``!6:`0` -M`````#;@``!6;P0``````#;H``!6=@0``````#;P``!6?00``````#;X``!6 -MA`0``````#<(``!6BP0``````#<8``!6D00``````#``!6U`0``````$`H``!6VP0``````#]J``!6Y`0``````$"L``!6 -M[`0``````$`>``!6]00``````$"8``!6_@0``````$$X``!7!P0``````$$N -M``!7#P0``````$$D``!7%P0``````$%2``!7(`0``````$$^``!7*1\````` -M`$%H``!7,@0``````$'$``!7.Q\``````$'8``!70P0``````$'8``!71@0` -M`````$'@``!7200``````$'H``!74@0``````$):``!76@0``````$*,``!7 -M8Q\``````$*@``!7:P(```#___]```!7P(```#___]$ -M``!7@P(```#___](``!7BP(```#___],``!7DP(```#___]0``!7G`(```#_ -M__]<``!7I0(```#___]H``!7K@(```#___]T``!7MP(```#___^```!7P0(` -M``#___^"``!7S0(```#___^#``!7UP(```#___^$``!7X0(```#___^$``!7 -MZ0(```#___^%``!7]`(```#___^&``!8``(```#___^'``!8#0(```#___^( -M``!8&`(```#___^,``!8(`(```#___^<``!8*`(```#___^T``!8,@(```#_ -M__^U``!8/0(```#___^V``!81@(```#___^W``!83@(```#___^X``!86`(` -M``#___^Y``!880(```#___^Z``!8:0(```#___^[``!8<0(```#____```!8 -M>0(```#____0``!8@0(```#____@``!8B0(```#____P``!8D0(```#___[D -M``!8FP(```#___[E``!8J@(```#___[T``!8L0(```#___[T``!8NP(```#_ -M__[X``!8Q0(```#___[\``!8SP(```#___[V``!8V@(```#___\```!8Y@(` -M``#___\$``!8[@(```#___\,``!8]P(```#___\0``!9``(```#___\4``!9 -M!P(````````!``!9%0(```````````!9(@(```#___\5``!9*0(````````' -M``!9-P(````````&``!91`(````````%``!940(````````$``!97P(````` -M```#``!9;`(````````"``!9>@(````````!``!9AP(```````````!9E`(` -M``#___\8``!9F0(```#___\8``!9I`(````````!``!9K@(```````````!9 -MN`(```````#@``!9P@(````````'``!9S0(````````$``!9V0(````````" -M``!9Y@(````````!``!9\@(```````````!9_@(```#___\9``!:!0(````` -M```'``!:$`(```#___\<``!:&0(````````,``!:(P(```#___\=``!:*P(` -M```````%``!:.0(````````,``!:0P(```#___\@``!:2`(```````#@``!: -M4@(````````$``!:7P(```#___\A``!:9P(````````$``!:=`(```#___\D -M``!:>P(````````"``!:?@(````````!``!:@0(```````````!:AP(```#_ -M__\E``!:C@(````````'``!:E`(````````%``!:F@(````````$``!:H`(` -M``#___\H``!:IP(```#___\H``!:L0(```#___\L``!:NP(```#___\P``!: -MQ0(```#___\J``!:T`(```#___\T``!:U@(```#___\T``!:WP(```#___\X -M``!:Z`(```#___\\``!:\0(```#___\V``!:^P(````````$``!;`@(````` -M```&``!;"0(````````*``!;$0(````````,``!;&`(````````#``!;(`(` -M```````"``!;)@(````````!``!;+@(```````````!;-@(````````'``!; -M/P(````````'``!;2`(````````&``!;40(````````%``!;6P(````````$ -M``!;9`(````````#``!;;0(````````"``!;=`(````````!``!;?@(````` -M``````!;B`(````````'``!;D0(````````&``!;FP(````````%``!;I0(` -M```````$``!;K0(````````#``!;MP(````(``````!;P`(````$``````!; -MQP(````"``````!;T`(````!``````!;V0(``````(````!;XP(``````$`` -M``!;[0(``````"````!;^`(``````!````!<`@(```````@```!<#`(````` -M``0```!<%`(```````(```!<'P(```````$```!<*@(```````"```!<-`(` -M``````!```!0(```````````!=@@(````````@``!=BP(```````!```!= -MDP(```````!@``!=FP(```````"```!=I`(```````!```!=J@(```````!` -M``!=L0(```````!!``!=N`(```````!D``!=P@(```#___[<``!=S0(````` -M```L``!=VP(````````T``!=Z0(````````$``!=\P(```#___\\``!=_@(` -M`````"`D``!>"`(````````L``!>$@(``````"`L``!>'`(```````#$``!> -M)0(``````#P!``!>,`(``````#^!``!>.P0``````$*P``!>000``````$*X -M``!>1P0``````$+```!>3`0``````$+0``!>400``````$+@``!>5P0````` -M`$+H``!>700``````$+P``!>8P0``````$,```!>:00``````$,(``!>;P0` -M`````$,0``!>=00``````$,8``!>>P0``````$,@``!>@00``````$,H``!> -MAP0``````$,P``!>C00``````$-```!>E`0``````$-(``!>G`0``````$-0 -M``!>HP(```#___^P``!>JP(```#___^,``!>L0(```#___^<``!>N@(```#_ -M___```!>O0(```#____0``!>Q00``````$>(``!>RP0``````$B(``!>T00` -M`````$>8``!>V00``````$B<``!>X`0``````$?>``!>Z00``````$AZ``!> -M\`0``````$AT``!>]P0``````$D.``!>_P0``````$D^``!?!P0``````$J4 -M``!?#00``````$E.``!?%00``````$NF``!?'`0``````$I:``!?(@0````` -M`$J&``!?*P0``````$IT``!?,00``````$IB``!?-P0``````$K\``!?/P0` -M`````$J<``!?1P0``````$K*``!?4!\``````$O,``!?60(```#___]```!? -M80(```#___]```!?:0(```#___]$``!?<0(```#___](``!?>0(```#___], -M``!?@0(```#___]0``!?B@(```#___]<``!?DP(```#___]H``!?G`(```#_ -M__]T``!?I0(```#___^```!?KP(```#___^"``!?NP(```#___^#``!?Q0(` -M``#___^$``!?SP(```#___^$``!?UP(```#___^%``!?X@(```#___^&``!? -M[@(```#___^'``!?^P(```#___^(``!@!@(```#___^,``!@#@(```#___^< -M``!@%@(```#___^T``!@(`(```#___^U``!@*P(```#___^V``!@-`(```#_ -M__^W``!@/`(```#___^X``!@1@(```#___^Y``!@3P(```#___^Z``!@5P(` -M``#___^[``!@7P(```#____```!@9P(```#____0``!@;P(```#____@``!@ -M=P(```#____P``!@?P(```#___[D``!@B0(```#___[E``!@F`(```#___[T -M``!@GP(```#___[T``!@J0(```#___[X``!@LP(```#___[\``!@O0(```#_ -M__[V``!@R`(```#___\```!@U`(```#___\$``!@W`(```#___\,``!@Y0(` -M``#___\0``!@[@(```#___\4``!@]0(````````!``!A`P(```````````!A -M$`(```#___\5``!A%P(````````'``!A)0(````````&``!A,@(````````% -M``!A/P(````````$``!A30(````````#``!A6@(````````"``!A:`(````` -M```!``!A=0(```````````!A@@(```#___\8``!AAP(```#___\8``!AD@(` -M```````!``!AG`(```````````!AI@(```````#@``!AL`(````````'``!A -MNP(````````$``!AQP(````````"``!AU`(````````!``!AX`(````````` -M``!A[`(```#___\9``!A\P(````````'``!A_@(```#___\<``!B!P(````` -M```,``!B$0(```#___\=``!B&0(````````%``!B)P(````````,``!B,0(` -M``#___\@``!B-@(```````#@``!B0`(````````$``!B30(```#___\A``!B -M50(````````$``!B8@(```#___\D``!B:0(````````"``!B;`(````````! -M``!B;P(```````````!B=0(```#___\E``!B?`(````````'``!B@@(````` -M```%``!BB`(````````$``!BC@(```#___\H``!BE0(```#___\H``!BGP(` -M``#___\L``!BJ0(```#___\P``!BLP(```#___\J``!BO@(```#___\T``!B -MQ`(```#___\T``!BS0(```#___\X``!BU@(```#___\\``!BWP(```#___\V -M``!BZ0(````````$``!B\`(````````&``!B]P(````````*``!B_P(````` -M```,``!C!@(````````#``!C#@(````````"``!C%`(````````!``!C'`(` -M``````````!C)`(````````'``!C+0(````````'``!C-@(````````&``!C -M/P(````````%``!C20(````````$``!C4@(````````#``!C6P(````````" -M``!C8@(````````!``!C;`(```````````!C=@(````````'``!C?P(````` -M```&``!CB0(````````%``!CDP(````````$``!CFP(````````#``!CI0(` -M```(``````!CK@(````$``````!CM0(````"``````!CO@(````!``````!C -MQP(``````(````!CT0(``````$````!CVP(``````"````!CY@(``````!`` -M``!C\`(```````@```!C^@(```````0```!D`@(```````(```!D#0(````` -M``$```!D&`(```````"```!D(@(```````!```!D+0(````````@``!D.`(` -M```````0``!D00(````````(``!D3`(````"``00``!D5P(````!`""```!D -M8@(````!____``!D:P(```````HH``!D=P(```````H(``!DA`(``````!)( -M``!DD`(```````$(``!DFP(```````((``!DI@(````!`$"```!DLP(````! -M``"```!DOP(````*``````!DRP(````"``"```!DV`(````,``````!DX@(` -M`````""```!D[0(```````@H``!D^P(``````!!(``!E"0(```````````!E -M$`(```````!```!E%P(```````"```!E'@(```````````!E)@(````````0 -M``!E+@(````````@``!E-@(````````P``!E/@(````````&``!E20(````` -M```'``!E4@(````````=``!E7P(````!@`````!E9P(```````````!E<`(` -M```````@``!E>0(```````!```!E@0(```````!@``!EB0(```````"```!E -MD@(```````!```!EF`(```````!```!EGP(```````!!``!EI@(```````!D -M``!EL`(```#___[<``!ENP(````````L``!ER0(````````T``!EUP(````` -M```$``!EX0(```#___\\``!E[`(``````"`D``!E]@(````````L``!F``(` -M`````"`L``!F"@(```````#$``!F$P(``````#P!``!F'@(``````#^!``!F -M*00``````$PP``!F+@0``````$Q(``!F-`0``````$PZ``!F.00``````$QB -M``!F0A\``````$QD``!F20(```#___]```!F40(```#___]```!F60(```#_ -M__]$``!F80(```#___](``!F:0(```#___],``!F<0(```#___]0``!F>@(` -M``#___]<``!F@P(```#___]H``!FC`(```#___]T``!FE0(```#___^```!F -MGP(```#___^"``!FJP(```#___^#``!FM0(```#___^$``!FOP(```#___^$ -M``!FQP(```#___^%``!FT@(```#___^&``!FW@(```#___^'``!FZP(```#_ -M__^(``!F]@(```#___^,``!F_@(```#___^<``!G!@(```#___^T``!G$`(` -M``#___^U``!G&P(```#___^V``!G)`(```#___^W``!G+`(```#___^X``!G -M-@(```#___^Y``!G/P(```#___^Z``!G1P(```#___^[``!G3P(```#____` -M``!G5P(```#____0``!G7P(```#____@``!G9P(```#____P``!G;P(```#_ -M__[D``!G>0(```#___[E``!GB`(```#___[T``!GCP(```#___[T``!GF0(` -M``#___[X``!GHP(```#___[\``!GK0(```#___[V``!GN`(```#___\```!G -MQ`(```#___\$``!GS`(```#___\,``!GU0(```#___\0``!GW@(```#___\4 -M``!GY0(````````!``!G\P(```````````!H``(```#___\5``!H!P(````` -M```'``!H%0(````````&``!H(@(````````%``!H+P(````````$``!H/0(` -M```````#``!H2@(````````"``!H6`(````````!``!H90(```````````!H -M<@(```#___\8``!H=P(```#___\8``!H@@(````````!``!HC`(````````` -M``!HE@(```````#@``!HH`(````````'``!HJP(````````$``!HMP(````` -M```"``!HQ`(````````!``!HT`(```````````!HW`(```#___\9``!HXP(` -M```````'``!H[@(```#___\<``!H]P(````````,``!I`0(```#___\=``!I -M"0(````````%``!I%P(````````,``!I(0(```#___\@``!I)@(```````#@ -M``!I,`(````````$``!I/0(```#___\A``!I10(````````$``!I4@(```#_ -M__\D``!I60(````````"``!I7`(````````!``!I7P(```````````!I90(` -M``#___\E``!I;`(````````'``!I<@(````````%``!I>`(````````$``!I -M?@(```#___\H``!IA0(```#___\H``!ICP(```#___\L``!IF0(```#___\P -M``!IHP(```#___\J``!IK@(```#___\T``!IM`(```#___\T``!IO0(```#_ -M__\X``!IQ@(```#___\\``!ISP(```#___\V``!IV0(````````$``!IX`(` -M```````&``!IYP(````````*``!I[P(````````,``!I]@(````````#``!I -M_@(````````"``!J!`(````````!``!J#`(```````````!J%`(````````' -M``!J'0(````````'``!J)@(````````&``!J+P(````````%``!J.0(````` -M```$``!J0@(````````#``!J2P(````````"``!J4@(````````!``!J7`(` -M``````````!J9@(````````'``!J;P(````````&``!J>0(````````%``!J -M@P(````````$``!JBP(````````#``!JE0(````(``````!JG@(````$```` -M``!JI0(````"``````!JK@(````!``````!JMP(``````(````!JP0(````` -M`$````!JRP(``````"````!JU@(``````!````!JX`(```````@```!JZ@(` -M``````0```!J\@(```````(```!J_0(```````$```!K"`(```````"```!K -M$@(```````!```!K'0(````````@``!K*`(````````0``!K,0(````````( -M``!K/`(````"``00``!K1P(````!`""```!K4@(````!____``!K6P(````` -M``HH``!K9P(```````H(``!K=`(``````!)(``!K@`(```````$(``!KBP(` -M``````((``!KE@(````!`$"```!KHP(````!``"```!KKP(````*``````!K -MNP(````"``"```!KR`(````,``````!KT@(``````""```!KW0(```````@H -M``!KZP(``````!!(``!K^0(```````````!L``(```````!```!L!P(````` -M``"```!L#@(```````````!L%@(````````0``!L'@(````````@``!L)@(` -M```````P``!L+@(````````&``!L.0(````````'``!L0@(````````=``!L -M3P(````!@`````!L5P(```````````!L8`(````````@``!L:0(```````!` -M``!L<0(```````!@``!L>0(```````"```!L@@(```````!```!LB`(````` -M``!```!LCP(```````!!``!LE@(```````!D``!LH`(```#___[<``!LJP(` -M```````L``!LN0(````````T``!LQP(````````$``!LT0(```#___\\``!L -MW`(``````"`D``!LY@(````````L``!L\`(``````"`L``!L^@(```````#$ -M``!M`P(``````#P!``!M#@(``````#^!``!M&00``````$S&``!M(00````` -M`$R2``!M*00``````$R"``!M,00``````$RJ``!M.`0``````$RB``!M/P0` -M`````$TV``!M2`0``````$U<``!M4`0``````$SB``!M6`0``````$T@``!M -M8`0``````$T(``!M;`0``````$T```!M=@0``````$T8``!M@`0``````$TN -M``!MC`0``````$U$``!MD@0``````$V"``!MFA\``````$V<``!MH@0````` -M`$V<``!MJ@0``````$VL``!ML00``````$Y:``!MN00``````$Y$``!MPA\` -M`````$Y@``!MR@(```#___]```!MT@(```#___]```!MV@(```#___]$``!M -MX@(```#___](``!MZ@(```#___],``!M\@(```#___]0``!M^P(```#___]< -M``!N!`(```#___]H``!N#0(```#___]T``!N%@(```#___^```!N(`(```#_ -M__^"``!N+`(```#___^#``!N-@(```#___^$``!N0`(```#___^$``!N2`(` -M``#___^%``!N4P(```#___^&``!N7P(```#___^'``!N;`(```#___^(``!N -M=P(```#___^,``!N?P(```#___^<``!NAP(```#___^T``!ND0(```#___^U -M``!NG`(```#___^V``!NI0(```#___^W``!NK0(```#___^X``!NMP(```#_ -M__^Y``!NP`(```#___^Z``!NR`(```#___^[``!NT`(```#____```!NV`(` -M``#____0``!NX`(```#____@``!NZ`(```#____P``!N\`(```#___[D``!N -M^@(```#___[E``!O"0(```#___[T``!O$`(```#___[T``!O&@(```#___[X -M``!O)`(```#___[\``!O+@(```#___[V``!O.0(```#___\```!O10(```#_ -M__\$``!O30(```#___\,``!O5@(```#___\0``!O7P(```#___\4``!O9@(` -M```````!``!O=`(```````````!O@0(```#___\5``!OB`(````````'``!O -ME@(````````&``!OHP(````````%``!OL`(````````$``!OO@(````````# -M``!ORP(````````"``!OV0(````````!``!OY@(```````````!O\P(```#_ -M__\8``!O^`(```#___\8``!P`P(````````!``!P#0(```````````!P%P(` -M``````#@``!P(0(````````'``!P+`(````````$``!P.`(````````"``!P -M10(````````!``!P40(```````````!P70(```#___\9``!P9`(````````' -M``!P;P(```#___\<``!P>`(````````,``!P@@(```#___\=``!PB@(````` -M```%``!PF`(````````,``!PH@(```#___\@``!PIP(```````#@``!PL0(` -M```````$``!PO@(```#___\A``!PQ@(````````$``!PTP(```#___\D``!P -MV@(````````"``!PW0(````````!``!PX`(```````````!PY@(```#___\E -M``!P[0(````````'``!P\P(````````%``!P^0(````````$``!P_P(```#_ -M__\H``!Q!@(```#___\H``!Q$`(```#___\L``!Q&@(```#___\P``!Q)`(` -M``#___\J``!Q+P(```#___\T``!Q-0(```#___\T``!Q/@(```#___\X``!Q -M1P(```#___\\``!Q4`(```#___\V``!Q6@(````````$``!Q80(````````& -M``!Q:`(````````*``!Q<`(````````,``!Q=P(````````#``!Q?P(````` -M```"``!QA0(````````!``!QC0(```````````!QE0(````````'``!QG@(` -M```````'``!QIP(````````&``!QL`(````````%``!QN@(````````$``!Q -MPP(````````#``!QS`(````````"``!QTP(````````!``!QW0(````````` -M``!QYP(````````'``!Q\`(````````&``!Q^@(````````%``!R!`(````` -M```$``!R#`(````````#``!R%@(````(``````!R'P(````$``````!R)@(` -M```"``````!R+P(````!``````!R.`(``````(````!R0@(``````$````!R -M3`(``````"````!R5P(``````!````!R80(```````@```!R:P(```````0` -M``!R@(```````````!S@0(```````!```!SB`(```````"```!S -MCP(```````````!SEP(````````0``!SGP(````````@``!SIP(````````P -M``!SKP(````````&``!SN@(````````'``!SPP(````````=``!ST`(````! -M@`````!SV`(```````````!SX0(````````@``!SZ@(```````!```!S\@(` -M``````!@``!S^@(```````"```!T`P(```````!```!T"0(```````!```!T -M$`(```````!!``!T%P(```````!D``!T(0(```#___[<``!T+`(````````L -M``!T.@(````````T``!T2`(````````$``!T4@(```#___\\``!T70(````` -M`"`D``!T9P(````````L``!T<0(``````"`L``!T>P(```````#$``!TA`(` -M`````#P!``!TCP(``````#^!``!TF@0``````$Y@``!TH@0``````$YH``!T -MJ@0``````$Z```!TK@0``````$Z$``!TLP0``````$Z(``!TN00``````$Z, -M``!TP`0``````$[H``!TQ`(```#___^L``!TR0(```#___^,``!TRP(```#_ -M__^.``!TT@(```#___^0``!TV`(```#___^<``!TV@(```#___^@``!TX`(` -M``#____```!TY@(```#____0``!T[`0``````%=.``!T]00``````%<<``!T -M^P0``````%H```!U`P0``````%F\``!U"Q\``````%ID``!U%0(```#___]` -M``!U'0(```#___]```!U)0(```#___]$``!U+0(```#___](``!U-0(```#_ -M__],``!U/0(```#___]0``!U1@(```#___]<``!U3P(```#___]H``!U6`(` -M``#___]T``!U80(```#___^```!U:P(```#___^"``!U=P(```#___^#``!U -M@0(```#___^$``!UBP(```#___^$``!UDP(```#___^%``!UG@(```#___^& -M``!UJ@(```#___^'``!UMP(```#___^(``!UP@(```#___^,``!UR@(```#_ -M__^<``!UT@(```#___^T``!UW`(```#___^U``!UYP(```#___^V``!U\`(` -M``#___^W``!U^`(```#___^X``!V`@(```#___^Y``!V"P(```#___^Z``!V -M$P(```#___^[``!V&P(```#____```!V(P(```#____0``!V*P(```#____@ -M``!V,P(```#____P``!V.P(```#___[D``!V10(```#___[E``!V5`(```#_ -M__[T``!V6P(```#___[T``!V90(```#___[X``!V;P(```#___[\``!V>0(` -M``#___[V``!VA`(```#___\```!VD`(```#___\$``!VF`(```#___\,``!V -MH0(```#___\0``!VJ@(```#___\4``!VL0(````````!``!VOP(````````` -M``!VS`(```#___\5``!VTP(````````'``!VX0(````````&``!V[@(````` -M```%``!V^P(````````$``!W"0(````````#``!W%@(````````"``!W)`(` -M```````!``!W,0(```````````!W/@(```#___\8``!W0P(```#___\8``!W -M3@(````````!``!W6`(```````````!W8@(```````#@``!W;`(````````' -M``!W=P(````````$``!W@P(````````"``!WD`(````````!``!WG`(````` -M``````!WJ`(```#___\9``!WKP(````````'``!WN@(```#___\<``!WPP(` -M```````,``!WS0(```#___\=``!WU0(````````%``!WXP(````````,``!W -M[0(```#___\@``!W\@(```````#@``!W_`(````````$``!X"0(```#___\A -M``!X$0(````````$``!X'@(```#___\D``!X)0(````````"``!X*`(````` -M```!``!X*P(```````````!X,0(```#___\E``!X.`(````````'``!X/@(` -M```````%``!X1`(````````$``!X2@(```#___\H``!X40(```#___\H``!X -M6P(```#___\L``!X90(```#___\P``!X;P(```#___\J``!X>@(```#___\T -M``!X@`(```#___\T``!XB0(```#___\X``!XD@(```#___\\``!XFP(```#_ -M__\V``!XI0(````````$``!XK`(````````&``!XLP(````````*``!XNP(` -M```````,``!XP@(````````#``!XR@(````````"``!XT`(````````!``!X -MV`(```````````!XX`(````````'``!XZ0(````````'``!X\@(````````& -M``!X^P(````````%``!Y!0(````````$``!Y#@(````````#``!Y%P(````` -M```"``!Y'@(````````!``!Y*`(```````````!Y,@(````````'``!Y.P(` -M```````&``!Y10(````````%``!Y3P(````````$``!Y5P(````````#``!Y -M80(````(``````!Y:@(````$``````!Y<0(````"``````!Y>@(````!```` -M``!Y@P(``````(````!YC0(``````$````!YEP(``````"````!YH@(````` -M`!````!YK`(```````@```!YM@(```````0```!YO@(```````(```!YR0(` -M``````$```!YU`(```````"```!YW@(```````!```!YZ0(````````@``!Y -M]`(````````0``!Y_0(````````(``!Z"`(````"``00``!Z$P(````!`""` -M``!Z'@(````!____``!Z)P(```````HH``!Z,P(```````H(``!Z0`(````` -M`!)(``!Z3`(```````$(``!Z5P(```````((``!Z8@(````!`$"```!Z;P(` -M```!``"```!Z>P(````*``````!ZAP(````"``"```!ZE`(````,``````!Z -MG@(``````""```!ZJ0(```````@H``!ZMP(``````!!(``!ZQ0(````````` -M``!ZS`(```````!```!ZTP(```````"```!ZV@(```````````!ZX@(````` -M```0``!ZZ@(````````@``!Z\@(````````P``!Z^@(````````&``![!0(` -M```````'``![#@(````````=``![&P(````!@`````![(P(```````````![ -M+`(````````@``![-0(```````!```![/0(```````!@``![10(```````"` -M``![3@(```````!```![5`(```````!```![6P(```````!!``![8@(````` -M``!D``![;`(```#___[<``![=P(````````L``![A0(````````T``![DP(` -M```````$``![G0(```#___\\``![J`(``````"`D``![L@(````````L``![ -MO`(``````"`L``![Q@(```````#$``![SP(``````#P!``![V@(``````#^! -M``![Y00``````%ID``![ZP0``````%J:``![\@0``````%J2``![^`0````` -M`%K"``![_P0``````%L(``!\!@0``````%JN``!\#`0``````%JX``!\$@0` -M`````%JD``!\&@0``````%MB``!\(P0``````%KD``!\*00``````%KV``!\ -M+P0``````%K2``!\-P0``````%MJ``!\/P0``````%LR``!\100``````%M, -M``!\2P0``````%L8``!\4P0``````%N(``!\6P0``````%O"``!\8Q\````` -M`%O(``!\;@0``````%O(``!\=P(```#___]```!\?P(```#___]```!\AP(` -M``#___]$``!\CP(```#___](``!\EP(```#___],``!\GP(```#___]0``!\ -MJ`(```#___]<``!\L0(```#___]H``!\N@(```#___]T``!\PP(```#___^` -M``!\S0(```#___^"``!\V0(```#___^#``!\XP(```#___^$``!\[0(```#_ -M__^$``!\]0(```#___^%``!]``(```#___^&``!]#`(```#___^'``!]&0(` -M``#___^(``!])`(```#___^,``!]+`(```#___^<``!]-`(```#___^T``!] -M/@(```#___^U``!]20(```#___^V``!]4@(```#___^W``!]6@(```#___^X -M``!]9`(```#___^Y``!];0(```#___^Z``!]=0(```#___^[``!]?0(```#_ -M___```!]A0(```#____0``!]C0(```#____@``!]E0(```#____P``!]G0(` -M``#___[D``!]IP(```#___[E``!]M@(```#___[T``!]O0(```#___[T``!] -MQP(```#___[X``!]T0(```#___[\``!]VP(```#___[V``!]Y@(```#___\` -M``!]\@(```#___\$``!]^@(```#___\,``!^`P(```#___\0``!^#`(```#_ -M__\4``!^$P(````````!``!^(0(```````````!^+@(```#___\5``!^-0(` -M```````'``!^0P(````````&``!^4`(````````%``!^70(````````$``!^ -M:P(````````#``!^>`(````````"``!^A@(````````!``!^DP(````````` -M``!^H`(```#___\8``!^I0(```#___\8``!^L`(````````!``!^N@(````` -M``````!^Q`(```````#@``!^S@(````````'``!^V0(````````$``!^Y0(` -M```````"``!^\@(````````!``!^_@(```````````!_"@(```#___\9``!_ -M$0(````````'``!_'`(```#___\<``!_)0(````````,``!_+P(```#___\= -M``!_-P(````````%``!_10(````````,``!_3P(```#___\@``!_5`(````` -M``#@``!_7@(````````$``!_:P(```#___\A``!_0(````````"``"`@`(````````!``"` -MB@(```````````"`E`(````````'``"`G0(````````&``"`IP(````````% -M``"`L0(````````$``"`N0(````````#``"`PP(````(``````"`S`(````$ -M``````"`TP(````"``````"`W`(````!``````"`Y0(``````(````"`[P(` -M`````$````"`^0(``````"````"!!`(``````!````"!#@(```````@```"! -M&`(```````0```"!(`(```````(```"!*P(```````$```"!-@(```````"` -M``"!0`(```````!```"!2P(````````@``"!5@(````````0``"!7P(````` -M```(``"!:@(````"``00``"!=0(````!`""```"!@`(````!____``"!B0(` -M``````HH``"!E0(```````H(``"!H@(``````!)(``"!K@(```````$(``"! -MN0(```````((``"!Q`(````!`$"```"!T0(````!``"```"!W0(````*```` -M``"!Z0(````"``"```"!]@(````,``````""``(``````""```"""P(````` -M``@H``""&0(``````!!(``"")P(```````````""+@(```````!```""-0(` -M``````"```""/`(```````````""1`(````````0``""3`(````````@``"" -M5`(````````P``""7`(````````&``""9P(````````'``""<`(````````= -M``""?0(````!@`````""A0(```````````""C@(````````@``""EP(````` -M``!```""GP(```````!@``""IP(```````"```""L`(```````!```""M@(` -M``````!```""O0(```````!!``""Q`(```````!D``""S@(```#___[<``"" -MV0(````````L``""YP(````````T``""]0(````````$``""_P(```#___\\ -M``"#"@(``````"`D``"#%`(````````L``"#'@(``````"`L``"#*`(````` -M``#$``"#,0(``````#P!``"#/`(``````#^!``"#1P(```#___^\``"#4`(` -M``#____$``"#5@(```#____(``"#7`(```#____,``"#8@(```#____0``"# -M:@(```#___^,``"#;`(```#___^0``"#<0(```#___^4``"#=@(```#___^< -M``"#>`(```#___^@``"#?0(```#___^D``"#@@0``````%O(``"#B`0````` -M`%O:``"#D`0``````%PR``"#F00``````%P6``"#H@0``````%P```"#J`0` -M`````%PX``"#K@0``````%R>``"#MP0``````%R"``"#P`0``````%QL``"# -MQ@0``````%RD``"#RP0``````%S$``"#U`0``````%TJ``"#W`0``````%S6 -M``"#XP0``````%S4``"#Z@0``````%X:``"#\P0``````%S>``"#^@0````` -M`%SP``"$`P0``````%T.``"$#`0``````%SX``"$$@0``````%UF``"$&P0` -M`````%TR``"$)`0``````%VD``"$+00``````%W,``"$-@0``````%W"``"$ -M/00``````%X^``"$1@0``````%W6``"$3`0``````%WZ``"$5`0``````%X4 -M``"$6P0``````%XH``"$800``````%XJ``"$:1\``````%Y@``"$<0(```#_ -M__]```"$>0(```#___]```"$@0(```#___]$``"$B0(```#___](``"$D0(` -M``#___],``"$F0(```#___]0``"$H@(```#___]<``"$JP(```#___]H``"$ -MM`(```#___]T``"$O0(```#___^```"$QP(```#___^"``"$TP(```#___^# -M``"$W0(```#___^$``"$YP(```#___^$``"$[P(```#___^%``"$^@(```#_ -M__^&``"%!@(```#___^'``"%$P(```#___^(``"%'@(```#___^,``"%)@(` -M``#___^<``"%+@(```#___^T``"%.`(```#___^U``"%0P(```#___^V``"% -M3`(```#___^W``"%5`(```#___^X``"%7@(```#___^Y``"%9P(```#___^Z -M``"%;P(```#___^[``"%=P(```#____```"%?P(```#____0``"%AP(```#_ -M___@``"%CP(```#____P``"%EP(```#___[D``"%H0(```#___[E``"%L`(` -M``#___[T``"%MP(```#___[T``"%P0(```#___[X``"%RP(```#___[\``"% -MU0(```#___[V``"%X`(```#___\```"%[`(```#___\$``"%]`(```#___\, -M``"%_0(```#___\0``"&!@(```#___\4``"�(````````!``"&&P(````` -M``````"&*`(```#___\5``"&+P(````````'``"&/0(````````&``"&2@(` -M```````%``"&5P(````````$``"&90(````````#``"&<@(````````"``"& -M@`(````````!``"&C0(```````````"&F@(```#___\8``"&GP(```#___\8 -M``"&J@(````````!``"&M`(```````````"&O@(```````#@``"&R`(````` -M```'``"&TP(````````$``"&WP(````````"``"&[`(````````!``"&^`(` -M``````````"'!`(```#___\9``"'"P(````````'``"'%@(```#___\<``"' -M'P(````````,``"'*0(```#___\=``"',0(````````%``"'/P(````````, -M``"'20(```#___\@``"'3@(```````#@``"'6`(````````$``"'90(```#_ -M__\A``"';0(````````$``"'>@(```#___\D``"'@0(````````"``"'A`(` -M```````!``"'AP(```````````"'C0(```#___\E``"'E`(````````'``"' -MF@(````````%``"'H`(````````$``"'I@(```#___\H``"'K0(```#___\H -M``"'MP(```#___\L``"'P0(```#___\P``"'RP(```#___\J``"'U@(```#_ -M__\T``"'W`(```#___\T``"'Y0(```#___\X``"'[@(```#___\\``"']P(` -M``#___\V``"(`0(````````$``"("`(````````&``"(#P(````````*``"( -M%P(````````,``"('@(````````#``"()@(````````"``"(+`(````````! -M``"(-`(```````````"(/`(````````'``"(10(````````'``"(3@(````` -M```&``"(5P(````````%``"(80(````````$``"(:@(````````#``"(@(````````!``"(A`(```````````"(C@(````````'``"( -MEP(````````&``"(H0(````````%``"(JP(````````$``"(LP(````````# -M``"(O0(````(``````"(Q@(````$``````"(S0(````"``````"(U@(````! -M``````"(WP(``````(````"(Z0(``````$````"(\P(``````"````"(_@(` -M`````!````")"`(```````@```")$@(```````0```")&@(```````(```") -M)0(```````$```"),`(```````"```").@(```````!```")10(````````@ -M``")4`(````````0``")60(````````(``")9`(````"``00``");P(````! -M`""```")>@(````!____``")@P(```````HH``")CP(```````H(``")G`(` -M`````!)(``")J`(```````$(``")LP(```````((``")O@(````!`$"```") -MRP(````!``"```")UP(````*``````")XP(````"``"```")\`(````,```` -M``")^@(``````""```"*!0(```````@H``"*$P(``````!!(``"*(0(````` -M``````"**`(```````!```"*+P(```````"```"*-@(```````````"*/@(` -M```````0``"*1@(````````@``"*3@(````````P``"*5@(````````&``"* -M80(````````'``"*:@(````````=``"*=P(````!@`````"*?P(````````` -M``"*B`(````````@``"*D0(```````!```"*F0(```````!@``"*H0(````` -M``"```"*J@(```````!```"*L`(```````!```"*MP(```````!!``"*O@(` -M``````!D``"*R`(```#___[<``"*TP(````````L``"*X0(````````T``"* -M[P(````````$``"*^0(```#___\\``"+!`(``````"`D``"+#@(````````L -M``"+&`(``````"`L``"+(@(```````#$``"+*P(``````#P!``"+-@(````` -M`#^!``"+000``````%Y@``"+2@0``````%["``"+400``````&%^``"+600` -M`````%Z4``"+8P0``````%ZT``"+;00``````%ZL``"+=@0``````%]T``"+ -M?@0``````%[D``"+A@0``````&#N``"+CP0``````%\R``"+E@0``````%\2 -M``"+FP0``````%\```"+I`0``````%\<``"+K00``````%\\``"+M00````` -M`%]B``"+OP0``````%^6``"+R`0``````%^$``"+T00``````&!H``"+V@0` -M`````%^N``"+XP0``````%^Z``"+[`0``````%_,``"+]00``````%_<``"+ -M_00``````&!0``",!@0``````&`H``",#00``````&`0``",%`0``````&`` -M``",&P0``````&`V``",(P0``````&!F``",+`0``````&"\``",-`0````` -M`&"8``",/`0``````&"```",1`0````````",300``````&#"``",5@0` -M`````&#^``",7P0``````&$2``",:`0``````&%$``",<`0``````&$@``", -M>00``````&%8``",@@0``````&&*``",BP0``````&&D``",DP0``````&&< -M``",FQ\``````&&P``",H@(```#___]```",J@(```#___]```",L@(```#_ -M__]$``",N@(```#___](``",P@(```#___],``",R@(```#___]0``",TP(` -M``#___]<``",W`(```#___]H``",Y0(```#___]T``",[@(```#___^```", -M^`(```#___^"``"-!`(```#___^#``"-#@(```#___^$``"-&`(```#___^$ -M``"-(`(```#___^%``"-*P(```#___^&``"--P(```#___^'``"-1`(```#_ -M__^(``"-3P(```#___^,``"-5P(```#___^<``"-7P(```#___^T``"-:0(` -M``#___^U``"-=`(```#___^V``"-?0(```#___^W``"-A0(```#___^X``"- -MCP(```#___^Y``"-F`(```#___^Z``"-H`(```#___^[``"-J`(```#____` -M``"-L`(```#____0``"-N`(```#____@``"-P`(```#____P``"-R`(```#_ -M__[D``"-T@(```#___[E``"-X0(```#___[T``"-Z`(```#___[T``"-\@(` -M``#___[X``"-_`(```#___[\``".!@(```#___[V``".$0(```#___\```". -M'0(```#___\$``".)0(```#___\,``".+@(```#___\0``".-P(```#___\4 -M``"./@(````````!``".3`(```````````".60(```#___\5``".8`(````` -M```'``".;@(````````&``".>P(````````%``".B`(````````$``".E@(` -M```````#``".HP(````````"``".L0(````````!``".O@(```````````". -MRP(```#___\8``".T`(```#___\8``".VP(````````!``".Y0(````````` -M``".[P(```````#@``".^0(````````'``"/!`(````````$``"/$`(````` -M```"``"/'0(````````!``"/*0(```````````"/-0(```#___\9``"//`(` -M```````'``"/1P(```#___\<``"/4`(````````,``"/6@(```#___\=``"/ -M8@(````````%``"/<`(````````,``"/>@(```#___\@``"/?P(```````#@ -M``"/B0(````````$``"/E@(```#___\A``"/G@(````````$``"/JP(```#_ -M__\D``"/L@(````````"``"/M0(````````!``"/N`(```````````"/O@(` -M``#___\E``"/Q0(````````'``"/RP(````````%``"/T0(````````$``"/ -MUP(```#___\H``"/W@(```#___\H``"/Z`(```#___\L``"/\@(```#___\P -M``"/_`(```#___\J``"0!P(```#___\T``"0#0(```#___\T``"0%@(```#_ -M__\X``"0'P(```#___\\``"0*`(```#___\V``"0,@(````````$``"0.0(` -M```````&``"00`(````````*``"02`(````````,``"03P(````````#``"0 -M5P(````````"``"070(````````!``"090(```````````"0;0(````````' -M``"0=@(````````'``"0?P(````````&``"0B`(````````%``"0D@(````` -M```$``"0FP(````````#``"0I`(````````"``"0JP(````````!``"0M0(` -M``````````"0OP(````````'``"0R`(````````&``"0T@(````````%``"0 -MW`(````````$``"0Y`(````````#``"0[@(````(``````"0]P(````$```` -M``"0_@(````"``````"1!P(````!``````"1$`(``````(````"1&@(````` -M`$````"1)`(``````"````"1+P(``````!````"1.0(```````@```"10P(` -M``````0```"12P(```````(```"15@(```````$```"180(```````"```"1 -M:P(```````!```"1=@(````````@``"1@0(````````0``"1B@(````````( -M``"1E0(````"``00``"1H`(````!`""```"1JP(````!____``"1M`(````` -M``HH``"1P`(```````H(``"1S0(``````!)(``"1V0(```````$(``"1Y`(` -M``````((``"1[P(````!`$"```"1_`(````!``"```"2"`(````*``````"2 -M%`(````"``"```"2(0(````,``````"2*P(``````""```"2-@(```````@H -M``"21`(``````!!(``"24@(```````````"260(```````!```"28`(````` -M``"```"29P(```````````"2;P(````````0``"2=P(````````@``"2?P(` -M```````P``"2AP(````````&``"2D@(````````'``"2FP(````````=``"2 -MJ`(````!@`````"2L`(```````````"2N0(````````@``"2P@(```````!` -M``"2R@(```````!@``"2T@(```````"```"2VP(```````!```"2X0(````` -M``!```"2Z`(```````!!``"2[P(```````!D``"2^0(```#___[<``"3!`(` -M```````L``"3$@(````````T``"3(`(````````$``"3*@(```#___\\``"3 -M-0(``````"`D``"3/P(````````L``"320(``````"`L``"34P(```````#$ -M``"37`(``````#P!``"39P(``````#^!``"3<@0``````&&P``"3>@0````` -M`&&X``"3@@0``````&'```"3B`0``````&'(``"3C@0``````&'0``"3E`0` -M`````&'8``"3F@0``````&'@``"3H`0``````&'P``"3I@0``````&(```"3 -MK`0``````&(0``"3L@0``````&(8``"3N`0``````&(@``"3O@0``````&(H -M``"3Q`0``````&(P``"3R@0``````&)```"3T`0``````&)0``"3U@0````` -M`&)<``"3W`0``````&)@``"3Y00``````&)L``"3[`0``````&)\``"3\P(` -M``#____0``"3^0(```#____@``"3^P(```#____B``"4`@(```#____D``"4 -M"`(```#___^,``"4#P(```#___^<``"4%@(```#___^L``"4'@(```#___^L -M``"4)@(```#___^P``"4+@(```#___^P``"4,`(```#___^\``"4-00````` -M`&*V``"4/`0``````&+8``"4000``````&0T``"41P0``````&+D``"43P0` -M`````&1L``"45P0``````&,*``"47P0``````&.:``"49P0``````&,>``"4 -M;P0``````&0L``"4=P0``````&14``"4?P0``````&1```"4AP0``````&2^ -M``"4CP0``````&3X``"4F`0``````&42``"4G00``````&7<``"4I00````` -M`&9D``"4K`0``````&8R``"4L@0``````&AN``"4MP0``````&8^``"4O@0` -M`````&=X``"4Q`0``````&9T``"4R00``````&AD``"4T!\``````&BD``"4 -MV`0``````&BD``"4VP0``````&BL``"4W@0``````&DD``"4YA\``````&ET -M``"4[0(```#___]```"4]0(```#___]```"4_0(```#___]$``"5!0(```#_ -M__](``"5#0(```#___],``"5%0(```#___]0``"5'@(```#___]<``"5)P(` -M``#___]H``"5,`(```#___]T``"5.0(```#___^```"50P(```#___^"``"5 -M3P(```#___^#``"560(```#___^$``"58P(```#___^$``"5:P(```#___^% -M``"5=@(```#___^&``"5@@(```#___^'``"5CP(```#___^(``"5F@(```#_ -M__^,``"5H@(```#___^<``"5J@(```#___^T``"5M`(```#___^U``"5OP(` -M``#___^V``"5R`(```#___^W``"5T`(```#___^X``"5V@(```#___^Y``"5 -MXP(```#___^Z``"5ZP(```#___^[``"5\P(```#____```"5^P(```#____0 -M``"6`P(```#____@``"6"P(```#____P``"6$P(```#___[D``"6'0(```#_ -M__[E``"6+`(```#___[T``"6,P(```#___[T``"6/0(```#___[X``"61P(` -M``#___[\``"640(```#___[V``"67`(```#___\```"6:`(```#___\$``"6 -M<`(```#___\,``"6>0(```#___\0``"6@@(```#___\4``"6B0(````````! -M``"6EP(```````````"6I`(```#___\5``"6JP(````````'``"6N0(````` -M```&``"6Q@(````````%``"6TP(````````$``"6X0(````````#``"6[@(` -M```````"``"6_`(````````!``"7"0(```````````"7%@(```#___\8``"7 -M&P(```#___\8``"7)@(````````!``"7,`(```````````"7.@(```````#@ -M``"71`(````````'``"73P(````````$``"76P(````````"``"7:`(````` -M```!``"7=`(```````````"7@`(```#___\9``"7AP(````````'``"7D@(` -M``#___\<``"7FP(````````,``"7I0(```#___\=``"7K0(````````%``"7 -MNP(````````,``"7Q0(```#___\@``"7R@(```````#@``"7U`(````````$ -M``"7X0(```#___\A``"7Z0(````````$``"7]@(```#___\D``"7_0(````` -M```"``"8``(````````!``"8`P(```````````"8"0(```#___\E``"8$`(` -M```````'``"8%@(````````%``"8'`(````````$``"8(@(```#___\H``"8 -M*0(```#___\H``"8,P(```#___\L``"8/0(```#___\P``"81P(```#___\J -M``"84@(```#___\T``"86`(```#___\T``"880(```#___\X``"8:@(```#_ -M__\\``"8@(``````!````"9A`(```````@```"9C@(```````0```"9E@(` -M``````(```"9H0(```````$```"9K`(```````"```"9M@(```````!```"9 -MP0(````````@``"9S`(````````0``"9U0(````````(``"9X`(````"``00 -M``"9ZP(````!`""```"9]@(````!____``"9_P(```````HH``":"P(````` -M``H(``":&`(``````!)(``":)`(```````$(``":+P(```````((``":.@(` -M```!`$"```":1P(````!``"```":4P(````*``````":7P(````"``"```": -M;`(````,``````":=@(``````""```":@0(```````@H``":CP(``````!!( -M``":G0(```````````":I`(```````!```":JP(```````"```":L@(````` -M``````":N@(````````0``":P@(````````@``":R@(````````P``":T@(` -M```````&``":W0(````````'``":Y@(````````=``":\P(````!@`````": -M^P(```````````";!`(````````@``";#0(```````!```";%0(```````!@ -M``";'0(```````"```";)@(```````!```";+`(```````!```";,P(````` -M``!!``";.@(```````!D``";1`(```#___[<``";3P(````````L``";70(` -M```````T``";:P(````````$``";=0(```#___\\``";@`(``````"`D``"; -MB@(````````L``";E`(``````"`L``";G@(```````#$``";IP(``````#P! -M``";L@(``````#^!``";O00``````&ET``";Q00``````&E\``";S00````` -M`&F$``";TP0``````&F,``";V00``````&F4``";WP0``````&FD``";Y00` -M`````&FT``";ZP0``````&G$``";\00``````&G4``";]P0``````&GD``"< -M``0``````>``"``"<6`0``````&_(``"<8`0``````'`"``"< -M:00``````'`<``"<;@0``````'#F``"<=A\``````'#\``"`0(```#___\,``"> -M"@(```#___\0``">$P(```#___\4``">&@(````````!``">*`(````````` -M``">-0(```#___\5``">/`(````````'``">2@(````````&``">5P(````` -M```%``">9`(````````$``"><@(````````#``">?P(````````"``">C0(` -M```````!``">F@(```````````">IP(```#___\8``">K`(```#___\8``"> -MMP(````````!``">P0(```````````">RP(```````#@``">U0(````````' -M``">X`(````````$``">[`(````````"``">^0(````````!``"?!0(````` -M``````"?$0(```#___\9``"?&`(````````'``"?(P(```#___\<``"?+`(` -M```````,``"?-@(```#___\=``"?/@(````````%``"?3`(````````,``"? -M5@(```#___\@``"?6P(```````#@``"?90(````````$``"?<@(```#___\A -M``"?>@(````````$``"?AP(```#___\D``"?C@(````````"``"?D0(````` -M```!``"?E`(```````````"?F@(```#___\E``"?H0(````````'``"?IP(` -M```````%``"?K0(````````$``"?LP(```#___\H``"?N@(```#___\H``"? -MQ`(```#___\L``"?S@(```#___\P``"?V`(```#___\J``"?XP(```#___\T -M``"?Z0(```#___\T``"?\@(```#___\X``"?^P(```#___\\``"@!`(```#_ -M__\V``"@#@(````````$``"@%0(````````&``"@'`(````````*``"@)`(` -M```````,``"@*P(````````#``"@,P(````````"``"@.0(````````!``"@ -M00(```````````"@20(````````'``"@4@(````````'``"@6P(````````& -M``"@9`(````````%``"@;@(````````$``"@=P(````````#``"@@`(````` -M```"``"@AP(````````!``"@D0(```````````"@FP(````````'``"@I`(` -M```````&``"@K@(````````%``"@N`(````````$``"@P`(````````#``"@ -MR@(````(``````"@TP(````$``````"@V@(````"``````"@XP(````!```` -M``"@[`(``````(````"@]@(``````$````"A``(``````"````"A"P(````` -M`!````"A%0(```````@```"A'P(```````0```"A)P(```````(```"A,@(` -M``````$```"A/0(```````"```"A1P(```````!```"A4@(````````@``"A -M70(````````0``"A9@(````````(``"A<0(````"``00``"A?`(````!`""` -M``"AAP(````!____``"AD`(```````HH``"AG`(```````H(``"AJ0(````` -M`!)(``"AM0(```````$(``"AP`(```````((``"ARP(````!`$"```"AV`(` -M```!``"```"AY`(````*``````"A\`(````"``"```"A_0(````,``````"B -M!P(``````""```"B$@(```````@H``"B(`(``````!!(``"B+@(````````` -M``"B-0(```````!```"B/`(```````"```"B0P(```````````"B2P(````` -M```0``"B4P(````````@``"B6P(````````P``"B8P(````````&``"B;@(` -M```````'``"B=P(````````=``"BA`(````!@`````"BC`(```````````"B -ME0(````````@``"BG@(```````!```"BI@(```````!@``"BK@(```````"` -M``"BMP(```````!```"BO0(```````!```"BQ`(```````!!``"BRP(````` -M``!D``"BU0(```#___[<``"BX`(````````L``"B[@(````````T``"B_`(` -M```````$``"C!@(```#___\\``"C$0(``````"`D``"C&P(````````L``"C -M)0(``````"`L``"C+P(```````#$``"C.`(``````#P!``"C0P(``````#^! -M``"C3@(```#____@``"C4`(```#____B``"C5P(```#____D``"C70(```#_ -M__^\``"C80(```#____P``"C8P0``````'#\``"C:P0``````'%^``"C=`0` -M`````''^``"C>P0``````'(2``"CA!\``````')```"CC@0``````')```"C -ME@(```#___]```"CG@(```#___]```"CI@(```#___]$``"CK@(```#___]( -M``"CM@(```#___],``"CO@(```#___]0``"CQP(```#___]<``"CT`(```#_ -M__]H``"CV0(```#___]T``"CX@(```#___^```"C[`(```#___^"``"C^`(` -M``#___^#``"D`@(```#___^$``"D#`(```#___^$``"D%`(```#___^%``"D -M'P(```#___^&``"D*P(```#___^'``"D.`(```#___^(``"D0P(```#___^, -M``"D2P(```#___^<``"D4P(```#___^T``"D70(```#___^U``"D:`(```#_ -M__^V``"D<0(```#___^W``"D>0(```#___^X``"D@P(```#___^Y``"DC`(` -M``#___^Z``"DE`(```#___^[``"DG`(```#____```"DI`(```#____0``"D -MK`(```#____@``"DM`(```#____P``"DO`(```#___[D``"DQ@(```#___[E -M``"DU0(```#___[T``"DW`(```#___[T``"DY@(```#___[X``"D\`(```#_ -M__[\``"D^@(```#___[V``"E!0(```#___\```"E$0(```#___\$``"E&0(` -M``#___\,``"E(@(```#___\0``"E*P(```#___\4``"E,@(````````!``"E -M0`(```````````"E30(```#___\5``"E5`(````````'``"E8@(````````& -M``"E;P(````````%``"E?`(````````$``"EB@(````````#``"EEP(````` -M```"``"EI0(````````!``"EL@(```````````"EOP(```#___\8``"EQ`(` -M``#___\8``"ESP(````````!``"EV0(```````````"EXP(```````#@``"E -M[0(````````'``"E^`(````````$``"F!`(````````"``"F$0(````````! -M``"F'0(```````````"F*0(```#___\9``"F,`(````````'``"F.P(```#_ -M__\<``"F1`(````````,``"F3@(```#___\=``"F5@(````````%``"F9`(` -M```````,``"F;@(```#___\@``"FP(````` -M```&``"IA@(````````'``"ICP(````````=``"IG`(````!@`````"II`(` -M``````````"IK0(````````@``"IM@(```````!```"IO@(```````!@``"I -MQ@(```````"```"ISP(```````!```"IU0(```````!```"IW`(```````!! -M``"IXP(```````!D``"I[0(```#___[<``"I^`(````````L``"J!@(````` -M```T``"J%`(````````$``"J'@(```#___\\``"J*0(``````"`D``"J,P(` -M```````L``"J/0(``````"`L``"J1P(```````#$``"J4`(``````#P!``"J -M6P(``````#^!``"J9@0``````')>``"J;P0``````'*(``"J>`0``````'*` -M``"J@00``````')X``"JB@0``````')P``"JDP0``````'*N``"JF@0````` -M`'+8``"JH00``````'+0``"JJ`0``````'+(``"JKP0``````'+```"JMA\` -M`````'+@``"JP`(```#___]```"JR`(```#___]```"JT`(```#___]$``"J -MV`(```#___](``"JX`(```#___],``"JZ`(```#___]0``"J\0(```#___]< -M``"J^@(```#___]H``"K`P(```#___]T``"K#`(```#___^```"K%@(```#_ -M__^"``"K(@(```#___^#``"K+`(```#___^$``"K-@(```#___^$``"K/@(` -M``#___^%``"K20(```#___^&``"K50(```#___^'``"K8@(```#___^(``"K -M;0(```#___^,``"K=0(```#___^<``"K?0(```#___^T``"KAP(```#___^U -M``"KD@(```#___^V``"KFP(```#___^W``"KHP(```#___^X``"KK0(```#_ -M__^Y``"KM@(```#___^Z``"KO@(```#___^[``"KQ@(```#____```"KS@(` -M``#____0``"KU@(```#____@``"KW@(```#____P``"KY@(```#___[D``"K -M\`(```#___[E``"K_P(```#___[T``"L!@(```#___[T``"L$`(```#___[X -M``"L&@(```#___[\``"L)`(```#___[V``"L+P(```#___\```"L.P(```#_ -M__\$``"L0P(```#___\,``"L3`(```#___\0``"L50(```#___\4``"L7`(` -M```````!``"L:@(```````````"L=P(```#___\5``"L?@(````````'``"L -MC`(````````&``"LF0(````````%``"LI@(````````$``"LM`(````````# -M``"LP0(````````"``"LSP(````````!``"LW`(```````````"LZ0(```#_ -M__\8``"L[@(```#___\8``"L^0(````````!``"M`P(```````````"M#0(` -M``````#@``"M%P(````````'``"M(@(````````$``"M+@(````````"``"M -M.P(````````!``"M1P(```````````"M4P(```#___\9``"M6@(````````' -M``"M90(```#___\<``"M;@(````````,``"M>`(```#___\=``"M@`(````` -M```%``"MC@(````````,``"MF`(```#___\@``"MG0(```````#@``"MIP(` -M```````$``"MM`(```#___\A``"MO`(````````$``"MR0(```#___\D``"M -MT`(````````"``"MTP(````````!``"MU@(```````````"MW`(```#___\E -M``"MXP(````````'``"MZ0(````````%``"M[P(````````$``"M]0(```#_ -M__\H``"M_`(```#___\H``"N!@(```#___\L``"N$`(```#___\P``"N&@(` -M``#___\J``"N)0(```#___\T``"N*P(```#___\T``"N-`(```#___\X``"N -M/0(```#___\\``"N1@(```#___\V``"N4`(````````$``"N5P(````````& -M``"N7@(````````*``"N9@(````````,``"N;0(````````#``"N=0(````` -M```"``"N>P(````````!``"N@P(```````````"NBP(````````'``"NE`(` -M```````'``"NG0(````````&``"NI@(````````%``"NL`(````````$``"N -MN0(````````#``"NP@(````````"``"NR0(````````!``"NTP(````````` -M``"NW0(````````'``"NY@(````````&``"N\`(````````%``"N^@(````` -M```$``"O`@(````````#``"O#`(````(``````"O%0(````$``````"O'`(` -M```"``````"O)0(````!``````"O+@(``````(````"O.`(``````$````"O -M0@(``````"````"O30(``````!````"O5P(```````@```"O80(```````0` -M``"O:0(```````(```"O=`(```````$```"O?P(```````"```"OB0(````` -M``!```"OE`(````````@``"OGP(````````0``"OJ`(````````(``"OLP(` -M```"``00``"OO@(````!`""```"OR0(````!____``"OT@(```````HH``"O -MW@(```````H(``"OZP(``````!)(``"O]P(```````$(``"P`@(```````(( -M``"P#0(````!`$"```"P&@(````!``"```"P)@(````*``````"P,@(````" -M``"```"P/P(````,``````"P20(``````""```"P5`(```````@H``"P8@(` -M`````!!(``"P<`(```````````"P=P(```````!```"P?@(```````"```"P -MA0(```````````"PC0(````````0``"PE0(````````@``"PG0(````````P -M``"PI0(````````&``"PL`(````````'``"PN0(````````=``"PQ@(````! -M@`````"PS@(```````````"PUP(````````@``"PX`(```````!```"PZ`(` -M``````!@``"P\`(```````"```"P^0(```````!```"P_P(```````!```"Q -M!@(```````!!``"Q#0(```````!D``"Q%P(```#___[<``"Q(@(````````L -M``"Q,`(````````T``"Q/@(````````$``"Q2`(```#___\\``"Q4P(````` -M`"`D``"Q70(````````L``"Q9P(``````"`L``"Q<0(```````#$``"Q>@(` -M`````#P!``"QA0(``````#^!``"QD`0``````'+@``"QF`0``````'+H``"Q -MH`0``````',P``"QI@0``````',X``"QK`0``````'-```"QL@0``````'-( -M``"QN`0``````'-0``"QO@0``````'-@``"QPP0``````'-P``"QR`0````` -M`'.```"QSP(```#___^L``"QT0(```#___^,``"QTP(```#___^.``"QV@(` -M``#___^0``"QX`(```#___^<``"QZ`(```#____```"Q[@(```#____$``"Q -M]@(```#____(``"Q_P(```#____0``"R!0(```#____4``"R#0(```#____8 -M``"R%@0``````'>^``"R'00``````'A*``"R)00``````'?*``"R+00````` -M`'E.``"R,@0``````'AB``"R.00``````'A2``"R/P0``````'AV``"R1@0` -M`````'B\``"R300``````'C(``"R51\``````'G$``"R71\``````(#$``"R -M9`(```#___]```"R;`(```#___]```"R=`(```#___]$``"R?`(```#___]( -M``"RA`(```#___],``"RC`(```#___]0``"RE0(```#___]<``"RG@(```#_ -M__]H``"RIP(```#___]T``"RL`(```#___^```"RN@(```#___^"``"RQ@(` -M``#___^#``"RT`(```#___^$``"RV@(```#___^$``"RX@(```#___^%``"R -M[0(```#___^&``"R^0(```#___^'``"S!@(```#___^(``"S$0(```#___^, -M``"S&0(```#___^<``"S(0(```#___^T``"S*P(```#___^U``"S-@(```#_ -M__^V``"S/P(```#___^W``"S1P(```#___^X``"S40(```#___^Y``"S6@(` -M``#___^Z``"S8@(```#___^[``"S:@(```#____```"S<@(```#____0``"S -M>@(```#____@``"S@@(```#____P``"SB@(```#___[D``"SE`(```#___[E -M``"SHP(```#___[T``"SJ@(```#___[T``"SM`(```#___[X``"SO@(```#_ -M__[\``"SR`(```#___[V``"STP(```#___\```"SWP(```#___\$``"SYP(` -M``#___\,``"S\`(```#___\0``"S^0(```#___\4``"T``(````````!``"T -M#@(```````````"T&P(```#___\5``"T(@(````````'``"T,`(````````& -M``"T/0(````````%``"T2@(````````$``"T6`(````````#``"T90(````` -M```"``"T@(```````````"U@`(```#___\E``"UAP(````` -M```'``"UC0(````````%``"UDP(````````$``"UF0(```#___\H``"UH`(` -M``#___\H``"UJ@(```#___\L``"UM`(```#___\P``"UO@(```#___\J``"U -MR0(```#___\T``"USP(```#___\T``"UV`(```#___\X``"UX0(```#___\\ -M``"UZ@(```#___\V``"U]`(````````$``"U^P(````````&``"V`@(````` -M```*``"V"@(````````,``"V$0(````````#``"V&0(````````"``"V'P(` -M```````!``"V)P(```````````"V+P(````````'``"V.`(````````'``"V -M00(````````&``"V2@(````````%``"V5`(````````$``"V70(````````# -M``"V9@(````````"``"V;0(````````!``"V=P(```````````"V@0(````` -M```'``"VB@(````````&``"VE`(````````%``"VG@(````````$``"VI@(` -M```````#``"VL`(````(``````"VN0(````$``````"VP`(````"``````"V -MR0(````!``````"VT@(``````(````"VW`(``````$````"VY@(``````"`` -M``"V\0(``````!````"V^P(```````@```"W!0(```````0```"W#0(````` -M``(```"W&`(```````$```"W(P(```````"```"W+0(```````!```"W.`(` -M```````@``"W0P(````````0``"W3`(````````(``"W5P(````"``00``"W -M8@(````!`""```"W;0(````!____``"W=@(```````HH``"W@@(```````H( -M``"WCP(``````!)(``"WFP(```````$(``"WI@(```````((``"WL0(````! -M`$"```"WO@(````!``"```"WR@(````*``````"WU@(````"``"```"WXP(` -M```,``````"W[0(``````""```"W^`(```````@H``"X!@(``````!!(``"X -M%`(```````````"X&P(```````!```"X(@(```````"```"X*0(````````` -M``"X,0(````````0``"X.0(````````@``"X00(````````P``"X20(````` -M```&``"X5`(````````'``"X70(````````=``"X:@(````!@`````"X<@(` -M``````````"X>P(````````@``"XA`(```````!```"XC`(```````!@``"X -ME`(```````"```"XG0(```````!```"XHP(```````!```"XJ@(```````!! -M``"XL0(```````!D``"XNP(```#___[<``"XQ@(````````L``"XU`(````` -M```T``"XX@(````````$``"X[`(```#___\\``"X]P(``````"`D``"Y`0(` -M```````L``"Y"P(``````"`L``"Y%0(```````#$``"Y'@(``````#P!``"Y -M*0(``````#^!``"Y-`0``````(#$``"Y/00``````(#4``"Y1@0``````(#D -M``"Y3P0``````(#T``"Y6`0``````($$``"Y8`0``````((8``"Y9P0````` -M`((F``"Y;@0``````((N``"Y=00``````(),``"Y?`0``````(+$``"Y@P0` -M`````(+0``"YB@0``````(+6``"YD00``````(+P``"YF`0``````()N``"Y -MGP0``````()\``"YI@0``````(*$``"YK00``````(*B``"YM`0``````(,N -M``"YN@0``````(&D``"YQ00``````(%>``"YT`0``````('P``"YV00````` -M`('T``"YX@0``````('L``"YZP0``````('X``"Y]`0``````(,.``"Y_00` -M`````()$``"Z!@0``````((T``"Z#P0``````(,:``"Z&`0``````()@``"Z -M(00``````()2``"Z*@0``````(*:``"Z,P0``````(**``"Z/`0``````(*V -M``"Z100``````(*H``"Z3@0``````(+J``"Z5P0``````(+<``"Z8`0````` -M`(,"``"Z:00``````(+V``"Z<@0``````(,4``"Z>P0``````(-:``"Z@@0` -M`````(.L``"ZC00``````(-F``"ZF`0``````(/T``"ZH00``````(/X``"Z -MJ@0``````(/\``"ZLP0``````(0```"ZO`0``````(06``"ZPP0``````(02 -M``"ZR@0``````(0L``"ZT`0``````(0^``"ZV`0``````(1(``"ZX`0````` -M`(1,``"ZZ00``````(1<``"Z\@0``````(1L``"Z^P0``````(1\``"[!`0` -M`````(2,``"[#00``````(2<``"[%@0``````(2L``"['00``````(4```"[ -M)00``````(4.``"[+00``````(4<``"[-00``````(4^``"[/00``````(6X -M``"[100``````(7$``"[300``````(70``"[500``````(7N``"[700````` -M`(5<``"[900``````(5J``"[;00``````(5X``"[=00``````(6:``"[?00` -M`````(8(``"[AP0``````(4P``"[D00``````(4B``"[FP0``````(84``"[ -MI`0``````(54``"[K@0``````(5$``"[N`0``````(6,``"[P@0``````(5^ -M``"[S`0``````(6P``"[U@0``````(6@``"[X`0``````(7B``"[Z@0````` -M`(76``"[]`0``````(8"``"[_@0``````(7T``"\"`0``````(8.``"\$@0` -M`````(8H``"\&@0``````(:2``"\(@0``````(::``"\*@0``````(:B``"\ -M,@0``````(:H``"\.@0``````(:N``"\0@0``````(:T``"\2@0``````(:Z -M``"\4@0``````(;```"\6@0``````(;&``"\8@0``````(;.``"\:@0````` -M`(;6``"\<@0``````(;<``"\>@0``````(;B``"\@@0``````(;H``"\B@0` -M`````(;N``"\D@0``````(;T``"\F@0``````(;Z``"\H@0``````(<"``"\ -MJ@0``````(<*``"\L@0``````(<0``"\N@0``````(<6``"\P@0``````(<< -M``"\R@0``````(@(````````$``#`@0(````````&``#` -MB`(````````*``#`D`(````````,``#`EP(````````#``#`GP(````````" -M``#`I0(````````!``#`K0(```````````#`M0(````````'``#`O@(````` -M```'``#`QP(````````&``#`T`(````````%``#`V@(````````$``#`XP(` -M```````#``#`[`(````````"``#`\P(````````!``#`_0(```````````#! -M!P(````````'``#!$`(````````&``#!&@(````````%``#!)`(````````$ -M``#!+`(````````#``#!-@(````(``````#!/P(````$``````#!1@(````" -M``````#!3P(````!``````#!6`(``````(````#!8@(``````$````#!;`(` -M`````"````#!=P(``````!````#!@0(```````@```#!BP(```````0```#! -MDP(```````(```#!G@(```````$```#!J0(```````"```#!LP(```````!` -M``#!O@(````````@``#!R0(````````0``#!T@(````````(``#!W0(````" -M``00``#!Z`(````!`""```#!\P(````!____``#!_`(```````HH``#""`(` -M``````H(``#"%0(``````!)(``#"(0(```````$(``#"+`(```````((``#" -M-P(````!`$"```#"1`(````!``"```#"4`(````*``````#"7`(````"``"` -M``#":0(````,``````#"0(```#___^,``#$ -M@0(```#___^<``#$B0(```#___^T``#$DP(```#___^U``#$G@(```#___^V -M``#$IP(```#___^W``#$KP(```#___^X``#$N0(```#___^Y``#$P@(```#_ -M__^Z``#$R@(```#___^[``#$T@(```#____```#$V@(```#____0``#$X@(` -M``#____@``#$Z@(```#____P``#$\@(```#___[D``#$_`(```#___[E``#% -M"P(```#___[T``#%$@(```#___[T``#%'`(```#___[X``#%)@(```#___[\ -M``#%,`(```#___[V``#%.P(```#___\```#%1P(```#___\$``#%3P(```#_ -M__\,``#%6`(```#___\0``#%80(```#___\4``#%:`(````````!``#%=@(` -M``````````#%@P(```#___\5``#%B@(````````'``#%F`(````````&``#% -MI0(````````%``#%L@(````````$``#%P`(````````#``#%S0(````````" -M``#%VP(````````!``#%Z`(```````````#%]0(```#___\8``#%^@(```#_ -M__\8``#&!0(````````!``#&#P(```````````#&&0(```````#@``#&(P(` -M```````'``#&+@(````````$``#&.@(````````"``#&1P(````````!``#& -M4P(```````````#&7P(```#___\9``#&9@(````````'``#&<0(```#___\< -M``#&>@(````````,``#&A`(```#___\=``#&C`(````````%``#&F@(````` -M```,``#&I`(```#___\@``#&J0(```````#@``#&LP(````````$``#&P`(` -M``#___\A``#&R`(````````$``#&U0(```#___\D``#&W`(````````"``#& -MWP(````````!``#&X@(```````````#&Z`(```#___\E``#&[P(````````' -M``#&]0(````````%``#&^P(````````$``#'`0(```#___\H``#'"`(```#_ -M__\H``#'$@(```#___\L``#''`(```#___\P``#')@(```#___\J``#',0(` -M``#___\T``#'-P(```#___\T``#'0`(```#___\X``#'20(```#___\\``#' -M4@(```#___\V``#'7`(````````$``#'8P(````````&``#':@(````````* -M``#'<@(````````,``#'>0(````````#``#'@0(````````"``#'AP(````` -M```!``#'CP(```````````#'EP(````````'``#'H`(````````'``#'J0(` -M```````&``#'L@(````````%``#'O`(````````$``#'Q0(````````#``#' -MS@(````````"``#'U0(````````!``#'WP(```````````#'Z0(````````' -M``#'\@(````````&``#'_`(````````%``#(!@(````````$``#(#@(````` -M```#``#(&`(````(``````#((0(````$``````#(*`(````"``````#(,0(` -M```!``````#(.@(``````(````#(1`(``````$````#(3@(``````"````#( -M60(``````!````#(8P(```````@```#(;0(```````0```#(=0(```````(` -M``#(@`(```````$```#(BP(```````"```#(E0(```````!```#(H`(````` -M```@``#(JP(````````0``#(M`(````````(``#(OP(````"``00``#(R@(` -M```!`""```#(U0(````!____``#(W@(```````HH``#(Z@(```````H(``#( -M]P(``````!)(``#)`P(```````$(``#)#@(```````((``#)&0(````!`$"` -M``#))@(````!``"```#),@(````*``````#)/@(````"``"```#)2P(````, -M``````#)50(``````""```#)8`(```````@H``#);@(``````!!(``#)?`(` -M``````````#)@P(```````!```#)B@(```````"```#)D0(```````````#) -MF0(````````0``#)H0(````````@``#)J0(````````P``#)L0(````````& -M``#)O`(````````'``#)Q0(````````=``#)T@(````!@`````#)V@(````` -M``````#)XP(````````@``#)[`(```````!```#)]`(```````!@``#)_`(` -M``````"```#*!0(```````!```#*"P(```````!```#*$@(```````!!``#* -M&0(```````!D``#*(P(```#___[<``#*+@(````````L``#*/`(````````T -M``#*2@(````````$``#*5`(```#___\\``#*7P(``````"`D``#*:0(````` -M```L``#*V``#*KP0``````(?2``#* -MM@0``````(?P``#*OA\``````(A```#*R`0``````(A```#*T`(```#___]` -M``#*V`(```#___]```#*X`(```#___]$``#*Z`(```#___](``#*\`(```#_ -M__],``#*^`(```#___]0``#+`0(```#___]<``#+"@(```#___]H``#+$P(` -M``#___]T``#+'`(```#___^```#+)@(```#___^"``#+,@(```#___^#``#+ -M/`(```#___^$``#+1@(```#___^$``#+3@(```#___^%``#+60(```#___^& -M``#+90(```#___^'``#+<@(```#___^(``#+?0(```#___^,``#+A0(```#_ -M__^<``#+C0(```#___^T``#+EP(```#___^U``#+H@(```#___^V``#+JP(` -M``#___^W``#+LP(```#___^X``#+O0(```#___^Y``#+Q@(```#___^Z``#+ -MS@(```#___^[``#+U@(```#____```#+W@(```#____0``#+Y@(```#____@ -M``#+[@(```#____P``#+]@(```#___[D``#,``(```#___[E``#,#P(```#_ -M__[T``#,%@(```#___[T``#,(`(```#___[X``#,*@(```#___[\``#,-`(` -M``#___[V``#,/P(```#___\```#,2P(```#___\$``#,4P(```#___\,``#, -M7`(```#___\0``#,90(```#___\4``#,;`(````````!``#,>@(````````` -M``#,AP(```#___\5``#,C@(````````'``#,G`(````````&``#,J0(````` -M```%``#,M@(````````$``#,Q`(````````#``#,T0(````````"``#,WP(` -M```````!``#,[`(```````````#,^0(```#___\8``#,_@(```#___\8``#- -M"0(````````!``#-$P(```````````#-'0(```````#@``#-)P(````````' -M``#-,@(````````$``#-/@(````````"``#-2P(````````!``#-5P(````` -M``````#-8P(```#___\9``#-:@(````````'``#-=0(```#___\<``#-?@(` -M```````,``#-B`(```#___\=``#-D`(````````%``#-G@(````````,``#- -MJ`(```#___\@``#-K0(```````#@``#-MP(````````$``#-Q`(```#___\A -M``#-S`(````````$``#-V0(```#___\D``#-X`(````````"``#-XP(````` -M```!``#-Y@(```````````#-[`(```#___\E``#-\P(````````'``#-^0(` -M```````%``#-_P(````````$``#.!0(```#___\H``#.#`(```#___\H``#. -M%@(```#___\L``#.(`(```#___\P``#.*@(```#___\J``#.-0(```#___\T -M``#..P(```#___\T``#.1`(```#___\X``#.30(```#___\\``#.5@(```#_ -M__\V``#.8`(````````$``#.9P(````````&``#.;@(````````*``#.=@(` -M```````,``#.?0(````````#``#.A0(````````"``#.BP(````````!``#. -MDP(```````````#.FP(````````'``#.I`(````````'``#.K0(````````& -M``#.M@(````````%``#.P`(````````$``#.R0(````````#``#.T@(````` -M```"``#.V0(````````!``#.XP(```````````#.[0(````````'``#.]@(` -M```````&``#/``(````````%``#/"@(````````$``#/$@(````````#``#/ -M'`(````(``````#/)0(````$``````#/+`(````"``````#/-0(````!```` -M``#//@(``````(````#/2`(``````$````#/4@(``````"````#/70(````` -M`!````#/9P(```````@```#/<0(```````0```#/>0(```````(```#/A`(` -M``````$```#/CP(```````"```#/F0(```````!```#/I`(````````@``#/ -MKP(````````0``#/N`(````````(``#/PP(````"``00``#/S@(````!`""` -M``#/V0(````!____``#/X@(```````HH``#/[@(```````H(``#/^P(````` -M`!)(``#0!P(```````$(``#0$@(```````((``#0'0(````!`$"```#0*@(` -M```!``"```#0-@(````*``````#00@(````"``"```#03P(````,``````#0 -M60(``````""```#09`(```````@H``#0<@(``````!!(``#0@`(````````` -M``#0AP(```````!```#0C@(```````"```#0E0(```````````#0G0(````` -M```0``#0I0(````````@``#0K0(````````P``#0M0(````````&``#0P`(` -M```````'``#0R0(````````=``#0U@(````!@`````#0W@(```````````#0 -MYP(````````@``#0\`(```````!```#0^`(```````!@``#1``(```````"` -M``#1"0(```````!```#1#P(```````!```#1%@(```````!!``#1'0(````` -M``!D``#1)P(```#___[<``#1,@(````````L``#10`(````````T``#13@(` -M```````$``#16`(```#___\\``#18P(``````"`D``#1;0(````````L``#1 -M=P(``````"`L``#1@0(```````#$``#1B@(``````#P!``#1E0(``````#^! -M``#1H`0``````(B```#1J@0``````(BH``#1M00``````(DT``#1P`0````` -M`(F"``#1RP0``````(G0``#1U00``````(C:``#1W00``````(IT``#1Z00` -M`````(HB``#1]00``````(JZ``#2`00``````(CT``#2"@0``````(CH``#2 -M$@0``````(GD``#2'`0``````(DJ``#2)00``````(EF``#2+00``````(FR -M``#2-00``````(J6``#2/P0``````(H4``#22`0``````(IB``#2400````` -M`(I4``#2600``````(I:``#28`0``````(J.``#2:P0``````(J2``#2>@0` -M`````(J>``#2@@0``````(JZ``#2B@0``````(KZ``#2E00``````(K*``#2 -MGQ\``````(L4``#2J`0``````(L4``#2KP(```#___]```#2MP(```#___]` -M``#2OP(```#___]$``#2QP(```#___](``#2SP(```#___],``#2UP(```#_ -M__]0``#2X`(```#___]<``#2Z0(```#___]H``#2\@(```#___]T``#2^P(` -M``#___^```#3!0(```#___^"``#3$0(```#___^#``#3&P(```#___^$``#3 -M)0(```#___^$``#3+0(```#___^%``#3.`(```#___^&``#31`(```#___^' -M``#340(```#___^(``#37`(```#___^,``#39`(```#___^<``#3;`(```#_ -M__^T``#3=@(```#___^U``#3@0(```#___^V``#3B@(```#___^W``#3D@(` -M``#___^X``#3G`(```#___^Y``#3I0(```#___^Z``#3K0(```#___^[``#3 -MM0(```#____```#3O0(```#____0``#3Q0(```#____@``#3S0(```#____P -M``#3U0(```#___[D``#3WP(```#___[E``#3[@(```#___[T``#3]0(```#_ -M__[T``#3_P(```#___[X``#4"0(```#___[\``#4$P(```#___[V``#4'@(` -M``#___\```#4*@(```#___\$``#4,@(```#___\,``#4.P(```#___\0``#4 -M1`(```#___\4``#42P(````````!``#460(```````````#49@(```#___\5 -M``#4;0(````````'``#4>P(````````&``#4B`(````````%``#4E0(````` -M```$``#4HP(````````#``#4L`(````````"``#4O@(````````!``#4RP(` -M``````````#4V`(```#___\8``#4W0(```#___\8``#4Z`(````````!``#4 -M\@(```````````#4_`(```````#@``#5!@(````````'``#5$0(````````$ -M``#5'0(````````"``#5*@(````````!``#5-@(```````````#50@(```#_ -M__\9``#520(````````'``#55`(```#___\<``#570(````````,``#59P(` -M``#___\=``#5;P(````````%``#5?0(````````,``#5AP(```#___\@``#5 -MC`(```````#@``#5E@(````````$``#5HP(```#___\A``#5JP(````````$ -M``#5N`(```#___\D``#5OP(````````"``#5P@(````````!``#5Q0(````` -M``````#5RP(```#___\E``#5T@(````````'``#5V`(````````%``#5W@(` -M```````$``#5Y`(```#___\H``#5ZP(```#___\H``#5]0(```#___\L``#5 -M_P(```#___\P``#6"0(```#___\J``#6%`(```#___\T``#6&@(```#___\T -M``#6(P(```#___\X``#6+`(```#___\\``#6-0(```#___\V``#6/P(````` -M```$``#61@(````````&``#630(````````*``#650(````````,``#67`(` -M```````#``#69`(````````"``#6:@(````````!``#6<@(```````````#6 -M>@(````````'``#6@P(````````'``#6C`(````````&``#6E0(````````% -M``#6GP(````````$``#6J`(````````#``#6L0(````````"``#6N`(````` -M```!``#6P@(```````````#6S`(````````'``#6U0(````````&``#6WP(` -M```````%``#6Z0(````````$``#6\0(````````#``#6^P(````(``````#7 -M!`(````$``````#7"P(````"``````#7%`(````!``````#7'0(``````(`` -M``#7)P(``````$````#7,0(``````"````#7/`(``````!````#71@(````` -M``@```#74`(```````0```#76`(```````(```#78P(```````$```#7;@(` -M``````"```#7>`(```````!```#7@P(````````@``#7C@(````````0``#7 -MEP(````````(``#7H@(````"``00``#7K0(````!`""```#7N`(````!____ -M``#7P0(```````HH``#7S0(```````H(``#7V@(``````!)(``#7Y@(````` -M``$(``#7\0(```````((``#7_`(````!`$"```#8"0(````!``"```#8%0(` -M```*``````#8(0(````"``"```#8+@(````,``````#8.`(``````""```#8 -M0P(```````@H``#840(``````!!(``#87P(```````````#89@(```````!` -M``#8;0(```````"```#8=`(```````````#8?`(````````0``#8A`(````` -M```@``#8C`(````````P``#8E`(````````&``#8GP(````````'``#8J`(` -M```````=``#8M0(````!@`````#8O0(```````````#8Q@(````````@``#8 -MSP(```````!```#8UP(```````!@``#8WP(```````"```#8Z`(```````!` -M``#8[@(```````!```#8]0(```````!!``#8_`(```````!D``#9!@(```#_ -M__[<``#9$0(````````L``#9'P(````````T``#9+0(````````$``#9-P(` -M``#___\\``#90@(``````"`D``#93`(````````L``#95@(``````"`L``#9 -M8`(```````#$``#9:0(``````#P!``#9=`(``````#^!``#9?P0``````(PN -M``#9AP0``````(N"``#9CP0``````(MF``#9EP0``````(O2``#9H00````` -M`(N*``#9JP0``````(NP``#9LP0``````(P4``#9N@0``````(P\``#9P00` -M`````(Q```#9R00``````(QN``#9U!\``````(Q\``#9W00``````(Q\``#9 -MY`(```#___]```#9[`(```#___]```#9]`(```#___]$``#9_`(```#___]( -M``#:!`(```#___],``#:#`(```#___]0``#:%0(```#___]<``#:'@(```#_ -M__]H``#:)P(```#___]T``#:,`(```#___^```#:.@(```#___^"``#:1@(` -M``#___^#``#:4`(```#___^$``#:6@(```#___^$``#:8@(```#___^%``#: -M;0(```#___^&``#:>0(```#___^'``#:A@(```#___^(``#:D0(```#___^, -M``#:F0(```#___^<``#:H0(```#___^T``#:JP(```#___^U``#:M@(```#_ -M__^V``#:OP(```#___^W``#:QP(```#___^X``#:T0(```#___^Y``#:V@(` -M``#___^Z``#:X@(```#___^[``#:Z@(```#____```#:\@(```#____0``#: -M^@(```#____@``#;`@(```#____P``#;"@(```#___[D``#;%`(```#___[E -M``#;(P(```#___[T``#;*@(```#___[T``#;-`(```#___[X``#;/@(```#_ -M__[\``#;2`(```#___[V``#;4P(```#___\```#;7P(```#___\$``#;9P(` -M``#___\,``#;<`(```#___\0``#;>0(```#___\4``#;@`(````````!``#; -MC@(```````````#;FP(```#___\5``#;H@(````````'``#;L`(````````& -M``#;O0(````````%``#;R@(````````$``#;V`(````````#``#;Y0(````` -M```"``#;\P(````````!``#<``(```````````#<#0(```#___\8``#<$@(` -M``#___\8``#<'0(````````!``#<)P(```````````#<,0(```````#@``#< -M.P(````````'``#<1@(````````$``#<4@(````````"``#<7P(````````! -M``#<:P(```````````#<=P(```#___\9``#P(````````&``#=@@(````` -M```*``#=B@(````````,``#=D0(````````#``#=F0(````````"``#=GP(` -M```````!``#=IP(```````````#=KP(````````'``#=N`(````````'``#= -MP0(````````&``#=R@(````````%``#=U`(````````$``#=W0(````````# -M``#=Y@(````````"``#=[0(````````!``#=]P(```````````#>`0(````` -M```'``#>"@(````````&``#>%`(````````%``#>'@(````````$``#>)@(` -M```````#``#>,`(````(``````#>.0(````$``````#>0`(````"``````#> -M20(````!``````#>4@(``````(````#>7`(``````$````#>9@(``````"`` -M``#><0(``````!````#>>P(```````@```#>A0(```````0```#>C0(````` -M``(```#>F`(```````$```#>HP(```````"```#>K0(```````!```#>N`(` -M```````@``#>PP(````````0``#>S`(````````(``#>UP(````"``00``#> -MX@(````!`""```#>[0(````!____``#>]@(```````HH``#?`@(```````H( -M``#?#P(``````!)(``#?&P(```````$(``#?)@(```````((``#?,0(````! -M`$"```#?/@(````!``"```#?2@(````*``````#?5@(````"``"```#?8P(` -M```,``````#?;0(``````""```#?>`(```````@H``#?A@(``````!!(``#? -ME`(```````````#?FP(```````!```#?H@(```````"```#?J0(````````` -M``#?L0(````````0``#?N0(````````@``#?P0(````````P``#?R0(````` -M```&``#?U`(````````'``#?W0(````````=``#?Z@(````!@`````#?\@(` -M``````````#?^P(````````@``#@!`(```````!```#@#`(```````!@``#@ -M%`(```````"```#@'0(```````!```#@(P(```````!```#@*@(```````!! -M``#@,0(```````!D``#@.P(```#___[<``#@1@(````````L``#@5`(````` -M```T``#@8@(````````$``#@;`(```#___\\``#@=P(``````"`D``#@@0(` -M```````L``#@BP(``````"`L``#@E0(```````#$``#@G@(``````#P!``#@ -MJ0(``````#^!``#@M`0``````(S4``#@N`0``````(V"``#@P00``````(RB -M``#@R00``````(TP``#@T@0``````(RR``#@W`0``````(Y$``#@Y`0````` -M`(SD``#@\`0``````(SR``#@]P0``````(ST``#@_P0``````(SV``#A!00` -M`````(U$``#A#00``````(U&``#A%@0``````(U(``#A'`0``````(VF``#A -M)00``````(W$``#A+@0``````(WB``#A-P0``````(X```#A/@0``````(XR -M``#A1P0``````(X^``#A4`0``````(XF``#A600``````(Y@``#A7P0````` -M`(Y2``#A9P0``````(YD``#A;`0``````(YT``#A=!\``````(Z```#A?@0` -M`````(Z```#AA@0``````(Z```#AD0(```#___]```#AF0(```#___]```#A -MH0(```#___]$``#AJ0(```#___](``#AL0(```#___],``#AN0(```#___]0 -M``#AP@(```#___]<``#ARP(```#___]H``#AU`(```#___]T``#AW0(```#_ -M__^```#AYP(```#___^"``#A\P(```#___^#``#A_0(```#___^$``#B!P(` -M``#___^$``#B#P(```#___^%``#B&@(```#___^&``#B)@(```#___^'``#B -M,P(```#___^(``#B/@(```#___^,``#B1@(```#___^<``#B3@(```#___^T -M``#B6`(```#___^U``#B8P(```#___^V``#B;`(```#___^W``#B=`(```#_ -M__^X``#B?@(```#___^Y``#BAP(```#___^Z``#BCP(```#___^[``#BEP(` -M``#____```#BGP(```#____0``#BIP(```#____@``#BKP(```#____P``#B -MMP(```#___[D``#BP0(```#___[E``#BT`(```#___[T``#BUP(```#___[T -M``#BX0(```#___[X``#BZP(```#___[\``#B]0(```#___[V``#C``(```#_ -M__\```#C#`(```#___\$``#C%`(```#___\,``#C'0(```#___\0``#C)@(` -M``#___\4``#C+0(````````!``#C.P(```````````#C2`(```#___\5``#C -M3P(````````'``#C70(````````&``#C:@(````````%``#C=P(````````$ -M``#CA0(````````#``#CD@(````````"``#CH`(````````!``#CK0(````` -M``````#CN@(```#___\8``#COP(```#___\8``#CR@(````````!``#CU`(` -M``````````#CW@(```````#@``#CZ`(````````'``#C\P(````````$``#C -M_P(````````"``#D#`(````````!``#D&`(```````````#D)`(```#___\9 -M``#D*P(````````'``#D-@(```#___\<``#D/P(````````,``#D20(```#_ -M__\=``#D40(````````%``#D7P(````````,``#D:0(```#___\@``#D;@(` -M``````#@``#D>`(````````$``#DA0(```#___\A``#DC0(````````$``#D -MF@(```#___\D``#DH0(````````"``#DI`(````````!``#DIP(````````` -M``#DK0(```#___\E``#DM`(````````'``#DN@(````````%``#DP`(````` -M```$``#DQ@(```#___\H``#DS0(```#___\H``#DUP(```#___\L``#DX0(` -M``#___\P``#DZP(```#___\J``#D]@(```#___\T``#D_`(```#___\T``#E -M!0(```#___\X``#E#@(```#___\\``#E%P(```#___\V``#E(0(````````$ -M``#E*`(````````&``#E+P(````````*``#E-P(````````,``#E/@(````` -M```#``#E1@(````````"``#E3`(````````!``#E5`(```````````#E7`(` -M```````'``#E90(````````'``#E;@(````````&``#E=P(````````%``#E -M@0(````````$``#EB@(````````#``#EDP(````````"``#EF@(````````! -M``#EI`(```````````#EK@(````````'``#EMP(````````&``#EP0(````` -M```%``#ERP(````````$``#ETP(````````#``#EW0(````(``````#EY@(` -M```$``````#E[0(````"``````#E]@(````!``````#E_P(``````(````#F -M"0(``````$````#F$P(``````"````#F'@(``````!````#F*`(```````@` -M``#F,@(```````0```#F.@(```````(```#F10(```````$```#F4`(````` -M``"```#F6@(```````!```#F90(````````@``#F<`(````````0``#F>0(` -M```````(``#FA`(````"``00``#FCP(````!`""```#FF@(````!____``#F -MHP(```````HH``#FKP(```````H(``#FO`(``````!)(``#FR`(```````$( -M``#FTP(```````((``#FW@(````!`$"```#FZP(````!``"```#F]P(````* -M``````#G`P(````"``"```#G$`(````,``````#G&@(``````""```#G)0(` -M``````@H``#G,P(``````!!(``#G00(```````````#G2`(```````!```#G -M3P(```````"```#G5@(```````````#G7@(````````0``#G9@(````````@ -M``#G;@(````````P``#G=@(````````&``#G@0(````````'``#GB@(````` -M```=``#GEP(````!@`````#GGP(```````````#GJ`(````````@``#GL0(` -M``````!```#GN0(```````!@``#GP0(```````"```#GR@(```````!```#G -MT`(```````!```#GUP(```````!!``#GW@(```````!D``#GZ`(```#___[< -M``#G\P(````````L``#H`0(````````T``#H#P(````````$``#H&0(```#_ -M__\\``#H)`(``````"`D``#H+@(````````L``#H.`(``````"`L``#H0@(` -M``````#$``#H2P(``````#P!``#H5@(``````#^!``#H800``````([J``#H -M:`0``````(Z0``#H;P0``````(Z8``#H=@0``````(ZL``#H?00``````(Z^ -M``#HA00``````([,``#HC00``````([:``#HE00``````([H``#HG00````` -M`(\"``#HI`0``````(]$``#HJ`0``````(]>``#HL00``````(]8``#HN00` -M`````(^$``#HP00``````(^T``#HQ@0``````(_&``#HSP0``````(_0``#H -MUP0``````(_H``#HW@0``````)`,``#HZ!\``````)`<``#H\00``````)`< -M``#H^`(```#___]```#I``(```#___]```#I"`(```#___]$``#I$`(```#_ -M__](``#I&`(```#___],``#I(`(```#___]0``#I*0(```#___]<``#I,@(` -M``#___]H``#I.P(```#___]T``#I1`(```#___^```#I3@(```#___^"``#I -M6@(```#___^#``#I9`(```#___^$``#I;@(```#___^$``#I=@(```#___^% -M``#I@0(```#___^&``#IC0(```#___^'``#IF@(```#___^(``#II0(```#_ -M__^,``#IK0(```#___^<``#IM0(```#___^T``#IOP(```#___^U``#IR@(` -M``#___^V``#ITP(```#___^W``#IVP(```#___^X``#IY0(```#___^Y``#I -M[@(```#___^Z``#I]@(```#___^[``#I_@(```#____```#J!@(```#____0 -M``#J#@(```#____@``#J%@(```#____P``#J'@(```#___[D``#J*`(```#_ -M__[E``#J-P(```#___[T``#J/@(```#___[T``#J2`(```#___[X``#J4@(` -M``#___[\``#J7`(```#___[V``#J9P(```#___\```#JP(```#___\,``#JA`(```#___\0``#JC0(```#___\4``#JE`(````````! -M``#JH@(```````````#JKP(```#___\5``#JM@(````````'``#JQ`(````` -M```&``#JT0(````````%``#JW@(````````$``#J[`(````````#``#J^0(` -M```````"``#K!P(````````!``#K%`(```````````#K(0(```#___\8``#K -M)@(```#___\8``#K,0(````````!``#K.P(```````````#K10(```````#@ -M``#K3P(````````'``#K6@(````````$``#K9@(````````"``#K@(````` -M`"````#MA0(``````!````#MCP(```````@```#MF0(```````0```#MH0(` -M``````(```#MK`(```````$```#MMP(```````"```#MP0(```````!```#M -MS`(````````@``#MUP(````````0``#MX`(````````(``#MZP(````"``00 -M``#M]@(````!`""```#N`0(````!____``#N"@(```````HH``#N%@(````` -M``H(``#N(P(``````!)(``#N+P(```````$(``#N.@(```````((``#N10(` -M```!`$"```#N4@(````!``"```#N7@(````*``````#N:@(````"``"```#N -M=P(````,``````#N@0(``````""```#NC`(```````@H``#NF@(``````!!( -M``#NJ`(```````````#NKP(```````!```#NM@(```````"```#NO0(````` -M``````#NQ0(````````0``#NS0(````````@``#NU0(````````P``#NW0(` -M```````&``#NZ`(````````'``#N\0(````````=``#N_@(````!@`````#O -M!@(```````````#O#P(````````@``#O&`(```````!```#O(`(```````!@ -M``#O*`(```````"```#O,0(```````!```#O-P(```````!```#O/@(````` -M``!!``#O10(```````!D``#O3P(```#___[<``#O6@(````````L``#O:`(` -M```````T``#O=@(````````$``#O@`(```#___\\``#OBP(``````"`D``#O -ME0(````````L``#OGP(``````"`L``#OJ0(```````#$``#OL@(``````#P! -M``#OO0(``````#^!``#OR`0``````)$V``#OT`0``````)"$``#OV`0````` -M`)!H``#OX`0``````)#:``#OZ@0``````)"2``#O]`0``````)"X``#O_`0` -M`````)$<``#P`P0``````)%J``#P"@0``````)%*``#P$00``````)%B``#P -M&00``````)%N``#P(@0``````)&,``#P+`0``````)&T``#P-P0``````)&8 -M``#P/@0``````)&L``#P200``````)':``#P4@0``````)',``#P600````` -M`)'H``#P8A\``````)'L``#P;`0``````)'L``#P=`(```#___]```#P?`(` -M``#___]```#PA`(```#___]$``#PC`(```#___](``#PE`(```#___],``#P -MG`(```#___]0``#PI0(```#___]<``#PK@(```#___]H``#PMP(```#___]T -M``#PP`(```#___^```#PR@(```#___^"``#PU@(```#___^#``#PX`(```#_ -M__^$``#PZ@(```#___^$``#P\@(```#___^%``#P_0(```#___^&``#Q"0(` -M``#___^'``#Q%@(```#___^(``#Q(0(```#___^,``#Q*0(```#___^<``#Q -M,0(```#___^T``#Q.P(```#___^U``#Q1@(```#___^V``#Q3P(```#___^W -M``#Q5P(```#___^X``#Q80(```#___^Y``#Q:@(```#___^Z``#Q<@(```#_ -M__^[``#Q>@(```#____```#Q@@(```#____0``#QB@(```#____@``#QD@(` -M``#____P``#QF@(```#___[D``#QI`(```#___[E``#QLP(```#___[T``#Q -MN@(```#___[T``#QQ`(```#___[X``#QS@(```#___[\``#QV`(```#___[V -M``#QXP(```#___\```#Q[P(```#___\$``#Q]P(```#___\,``#R``(```#_ -M__\0``#R"0(```#___\4``#R$`(````````!``#R'@(```````````#R*P(` -M``#___\5``#R,@(````````'``#R0`(````````&``#R30(````````%``#R -M6@(````````$``#R:`(````````#``#R=0(````````"``#R@P(````````! -M``#RD`(```````````#RG0(```#___\8``#RH@(```#___\8``#RK0(````` -M```!``#RMP(```````````#RP0(```````#@``#RRP(````````'``#RU@(` -M```````$``#RX@(````````"``#R[P(````````!``#R^P(```````````#S -M!P(```#___\9``#S#@(````````'``#S&0(```#___\<``#S(@(````````, -M``#S+`(```#___\=``#S-`(````````%``#S0@(````````,``#S3`(```#_ -M__\@``#S40(```````#@``#S6P(````````$``#S:`(```#___\A``#S<`(` -M```````$``#S?0(```#___\D``#SA`(````````"``#SAP(````````!``#S -MB@(```````````#SD`(```#___\E``#SEP(````````'``#SG0(````````% -M``#SHP(````````$``#SJ0(```#___\H``#SL`(```#___\H``#SN@(```#_ -M__\L``#SQ`(```#___\P``#SS@(```#___\J``#SV0(```#___\T``#SWP(` -M``#___\T``#SZ`(```#___\X``#S\0(```#___\\``#S^@(```#___\V``#T -M!`(````````$``#T"P(````````&``#T$@(````````*``#T&@(````````, -M``#T(0(````````#``#T*0(````````"``#T+P(````````!``#T-P(````` -M``````#T/P(````````'``#T2`(````````'``#T40(````````&``#T6@(` -M```````%``#T9`(````````$``#T;0(````````#``#T=@(````````"``#T -M?0(````````!``#TAP(```````````#TD0(````````'``#TF@(````````& -M``#TI`(````````%``#TK@(````````$``#TM@(````````#``#TP`(````( -M``````#TR0(````$``````#TT`(````"``````#TV0(````!``````#TX@(` -M`````(````#T[`(``````$````#T]@(``````"````#U`0(``````!````#U -M"P(```````@```#U%0(```````0```#U'0(```````(```#U*`(```````$` -M``#U,P(```````"```#U/0(```````!```#U2`(````````@``#U4P(````` -M```0``#U7`(````````(``#U9P(````"``00``#U<@(````!`""```#U?0(` -M```!____``#UA@(```````HH``#UD@(```````H(``#UGP(``````!)(``#U -MJP(```````$(``#UM@(```````((``#UP0(````!`$"```#US@(````!``"` -M``#UV@(````*``````#UY@(````"``"```#U\P(````,``````#U_0(````` -M`""```#V"`(```````@H``#V%@(``````!!(``#V)`(```````````#V*P(` -M``````!```#V,@(```````"```#V.0(```````````#V00(````````0``#V -M20(````````@``#V40(````````P``#V60(````````&``#V9`(````````' -M``#V;0(````````=``#V>@(````!@`````#V@@(```````````#VBP(````` -M```@``#VE`(```````!```#VG`(```````!@``#VI`(```````"```#VK0(` -M``````!```#VLP(```````!```#VN@(```````!!``#VP0(```````!D``#V -MRP(```#___[<``#VU@(````````L``#VY`(````````T``#V\@(````````$ -M``#V_`(```#___\\``#W!P(``````"`D``#W$0(````````L``#W&P(````` -M`"`L``#W)0(```````#$``#W+@(``````#P!``#W.0(``````#^!``#W1`0` -M`````))4``#W31\``````))<``#W6`0``````))<``#W80(```#___]```#W -M:0(```#___]```#W<0(```#___]$``#W>0(```#___](``#W@0(```#___], -M``#WB0(```#___]0``#WD@(```#___]<``#WFP(```#___]H``#WI`(```#_ -M__]T``#WK0(```#___^```#WMP(```#___^"``#WPP(```#___^#``#WS0(` -M``#___^$``#WUP(```#___^$``#WWP(```#___^%``#WZ@(```#___^&``#W -M]@(```#___^'``#X`P(```#___^(``#X#@(```#___^,``#X%@(```#___^< -M``#X'@(```#___^T``#X*`(```#___^U``#X,P(```#___^V``#X/`(```#_ -M__^W``#X1`(```#___^X``#X3@(```#___^Y``#X5P(```#___^Z``#X7P(` -M``#___^[``#X9P(```#____```#X;P(```#____0``#X=P(```#____@``#X -M?P(```#____P``#XAP(```#___[D``#XD0(```#___[E``#XH`(```#___[T -M``#XIP(```#___[T``#XL0(```#___[X``#XNP(```#___[\``#XQ0(```#_ -M__[V``#XT`(```#___\```#XW`(```#___\$``#XY`(```#___\,``#X[0(` -M``#___\0``#X]@(```#___\4``#X_0(````````!``#Y"P(```````````#Y -M&`(```#___\5``#Y'P(````````'``#Y+0(````````&``#Y.@(````````% -M``#Y1P(````````$``#Y50(````````#``#Y8@(````````"``#Y<`(````` -M```!``#Y?0(```````````#YB@(```#___\8``#YCP(```#___\8``#YF@(` -M```````!``#YI`(```````````#YK@(```````#@``#YN`(````````'``#Y -MPP(````````$``#YSP(````````"``#YW`(````````!``#YZ`(````````` -M``#Y]`(```#___\9``#Y^P(````````'``#Z!@(```#___\<``#Z#P(````` -M```,``#Z&0(```#___\=``#Z(0(````````%``#Z+P(````````,``#Z.0(` -M``#___\@``#Z/@(```````#@``#Z2`(````````$``#Z50(```#___\A``#Z -M70(````````$``#Z:@(```#___\D``#Z<0(````````"``#Z=`(````````! -M``#Z=P(```````````#Z?0(```#___\E``#ZA`(````````'``#ZB@(````` -M```%``#ZD`(````````$``#ZE@(```#___\H``#ZG0(```#___\H``#ZIP(` -M``#___\L``#ZL0(```#___\P``#ZNP(```#___\J``#ZQ@(```#___\T``#Z -MS`(```#___\T``#ZU0(```#___\X``#ZW@(```#___\\``#ZYP(```#___\V -M``#Z\0(````````$``#Z^`(````````&``#Z_P(````````*``#[!P(````` -M```,``#[#@(````````#``#[%@(````````"``#['`(````````!``#[)`(` -M``````````#[+`(````````'``#[-0(````````'``#[/@(````````&``#[ -M1P(````````%``#[40(````````$``#[6@(````````#``#[8P(````````" -M``#[:@(````````!``#[=`(```````````#[?@(````````'``#[AP(````` -M```&``#[D0(````````%``#[FP(````````$``#[HP(````````#``#[K0(` -M```(``````#[M@(````$``````#[O0(````"``````#[Q@(````!``````#[ -MSP(``````(````#[V0(``````$````#[XP(``````"````#[[@(``````!`` -M``#[^`(```````@```#\`@(```````0```#\"@(```````(```#\%0(````` -M``$```#\(`(```````"```#\*@(```````!```#\-0(````````@``#\0`(` -M```````0``#\20(````````(``#\5`(````"``00``#\7P(````!`""```#\ -M:@(````!____``#\`(` -M```````@``#]@0(```````!```#]B0(```````!@``#]D0(```````"```#] -MF@(```````!```#]H`(```````!```#]IP(```````!!``#]K@(```````!D -M``#]N`(```#___[<``#]PP(````````L``#]T0(````````T``#]WP(````` -M```$``#]Z0(```#___\\``#]]`(``````"`D``#]_@(````````L``#^"`(` -M`````"`L``#^$@(```````#$``#^&P(``````#P!``#^)@(``````#^!``#^ -M,00``````)*8``#^/`0``````)*N``#^1@0``````)*T``#^3A\``````)+4 -M``#^5P(```#___]```#^7P(```#___]```#^9P(```#___]$``#^;P(```#_ -M__](``#^=P(```#___],``#^?P(```#___]0``#^B`(```#___]<``#^D0(` -M``#___]H``#^F@(```#___]T``#^HP(```#___^```#^K0(```#___^"``#^ -MN0(```#___^#``#^PP(```#___^$``#^S0(```#___^$``#^U0(```#___^% -M``#^X`(```#___^&``#^[`(```#___^'``#^^0(```#___^(``#_!`(```#_ -M__^,``#_#`(```#___^<``#_%`(```#___^T``#_'@(```#___^U``#_*0(` -M``#___^V``#_,@(```#___^W``#_.@(```#___^X``#_1`(```#___^Y``#_ -M30(```#___^Z``#_50(```#___^[``#_70(```#____```#_90(```#____0 -M``#_;0(```#____@``#_=0(```#____P``#_?0(```#___[D``#_AP(```#_ -M__[E``#_E@(```#___[T``#_G0(```#___[T``#_IP(```#___[X``#_L0(` -M``#___[\``#_NP(```#___[V``#_Q@(```#___\```#_T@(```#___\$``#_ -MV@(```#___\,``#_XP(```#___\0``#_[`(```#___\4``#_\P(````````! -M``$``0(```````````$`#@(```#___\5``$`%0(````````'``$`(P(````` -M```&``$`,`(````````%``$`/0(````````$``$`2P(````````#``$`6`(` -M```````"``$`9@(````````!``$`@(` -M```````'``$!@`(````````%``$!A@(````````$``$!C`(```#___\H``$! -MDP(```#___\H``$!G0(```#___\L``$!IP(```#___\P``$!L0(```#___\J -M``$!O`(```#___\T``$!P@(```#___\T``$!RP(```#___\X``$!U`(```#_ -M__\\``$!W0(```#___\V``$!YP(````````$``$![@(````````&``$!]0(` -M```````*``$!_0(````````,``$"!`(````````#``$"#`(````````"``$" -M$@(````````!``$"&@(```````````$"(@(````````'``$"*P(````````' -M``$"-`(````````&``$"/0(````````%``$"1P(````````$``$"4`(````` -M```#``$"60(````````"``$"8`(````````!``$":@(```````````$"=`(` -M```````'``$"?0(````````&``$"AP(````````%``$"D0(````````$``$" -MF0(````````#``$"HP(````(``````$"K`(````$``````$"LP(````"```` -M``$"O`(````!``````$"Q0(``````(````$"SP(``````$````$"V0(````` -M`"````$"Y`(``````!````$"[@(```````@```$"^`(```````0```$#``(` -M``````(```$#"P(```````$```$#%@(```````"```$#(`(```````!```$# -M*P(````````@``$#-@(````````0``$#/P(````````(``$#2@(````"``00 -M``$#50(````!`""```$#8`(````!____``$#:0(```````HH``$#=0(````` -M``H(``$#@@(``````!)(``$#C@(```````$(``$#F0(```````((``$#I`(` -M```!`$"```$#L0(````!``"```$#O0(````*``````$#R0(````"``"```$# -MU@(````,``````$#X`(``````""```$#ZP(```````@H``$#^0(``````!!( -M``$$!P(```````````$$#@(```````!```$$%0(```````"```$$'`(````` -M``````$$)`(````````0``$$+`(````````@``$$-`(````````P``$$/`(` -M```````&``$$1P(````````'``$$4`(````````=``$$70(````!@`````$$ -M90(```````````$$;@(````````@``$$=P(```````!```$$?P(```````!@ -M``$$AP(```````"```$$D`(```````!```$$E@(```````!```$$G0(````` -M``!!``$$I`(```````!D``$$K@(```#___[<``$$N0(````````L``$$QP(` -M```````T``$$U0(````````$``$$WP(```#___\\``$$Z@(``````"`D``$$ -M]`(````````L``$$_@(``````"`L``$%"`(```````#$``$%$0(``````#P! -M``$%'`(``````#^!``$%)P0``````)5X``$%,`0``````)0X``$%-P0````` -M`),J``$%.P0``````)-F``$%0@0``````)-<``$%2P0``````)5X``$%4@0` -M`````)0R``$%600``````)/,``$%8`0``````)/&``$%:`0``````).^``$% -M<`0``````).V``$%>`0``````).N``$%@`0``````)/0``$%B00``````)0H -M``$%E`0``````)4>``$%G`0``````)1F``$%HP0``````)5R``$%J@0````` -M`)3>``$%L00``````)38``$%N00``````)30``$%P00``````)3(``$%R00` -M`````)3```$%T00``````)3B``$%V@0``````)4Z``$%X`0``````)5,``$% -MY@0``````)5>``$%[`4``````!EB``$%]`4``````(:(``$%_04```````P< -M``$&!04``````%DD``$&#@4```````PT``$&%@4```````5,``$&'04````` -M``6>``$&)`4```````OZ``$&+`4```````@L``$&-`4``````$V\``$&/`4` -M`````!H\``$&1@4``````#,6``$&304```````!P``$&5`4``````!E*``$& -M704``````(%$``$&904``````!*H``$&;`4``````#*^``$&=`4``````)+4 -M``$&?@4``````!-$``$&A04``````!'H``$&C`4``````!$H``$&DP4````` -M`'A^``$&G`4``````!>4``$&H@4```````B8``$&JP4```````OP``$&LP4` -M`````$O,``$&NP4``````$OV``$&PP4```````30``$&R@4``````)'R``$& -MT`4```````5(``$&UP4```````B*``$&X`$```````````$&ZP4``````$X0 -M``$&\04``````&*0``$&]P4``````(($``$&_P4``````#5.``$'!04````` -M`$(0``$'"P4```````P,``$'$P4``````!KJ``$'(@4```````PL``$'*@4` -M`````!-.``$'-`4``````#"L``$'.@4``````&7X``$'0P$```````````$' -M4@4```````NV``$'6P4``````#\\``$'804``````#7T``$'9P4``````(0@ -M``$'<`4``````$QP``$'=@4``````%>*``$'?`4```````N4``$'A04````` -M`!E```$'C`4```````9F``$'E`4```````Q4``$'G04```````7@``$'I04` -M`````$=T``$'JP4``````!CL``$'L@4``````!!0``$'N04``````(%2``$' -MP@4``````((```$'RP4``````#)(``$'U`4``````#.V``$'W`$````````` -M``$'YP4``````$DJ``$'[P4``````(3L``$']P4```````AN``$'_04````` -M``Q$``$(!@4``````!#(``$(#04``````!`X``$(%`4``````'$```$(&@$` -M``````````$((P4``````&XD``$(*04``````(Z(``$(+P4``````&*,``$( -M-04``````&BX``$(.P4``````#`<``$(0@4``````!@B``$(204``````$%H -M``$(404``````!",``$(6@4``````)````$(8P$```````````$(;@4````` -M``A$``$(=`4``````(\@``$(?04``````!N8``$(A@4``````%DH``$(C@4` -M`````$W8``$(E0$```````````$(GP4```````L``$(W`4``````#5```$(XP$````` -M``````$([04``````$O>``$(]@4```````A2``$(^P4```````CT``$)`P4` -M`````$P:``$)#`4```````F^``$)$04``````$QD``$)%@4``````%O(``$) -M&P4```````A@``$)(`4``````'G$``$))P4``````&8(``$)+P4``````!I& -M``$).04``````&*N``$)/@4``````'>```$)1P4``````(0*``$)3P4````` -M`%IH``$)5@4``````(=L``$)804``````!@"``$):04```````EP``$)<04` -M``````O*``$)?`4``````$=0``$)@P4``````&H4``$)B04```````@F``$) -MD`4``````&XH``$)E04``````&*D``$)F@$```````````$)I`4``````$RR -M``$)JP4```````J$``$)L`4``````%O2``$)M04```````R(``$)P`4````` -M`$%L``$)QP4``````))<``$)TP$```````````$)W04``````#\X``$)Y`4` -M`````!B2``$)[`4``````#7P``$)\P4``````$R\``$)^@4``````%<```$* -M`04```````D"``$*"0$```````````$*$P4``````!'$``$*&P$````````` -M``$*)04```````M*``$*+`4``````&BT``$*,P$```````````$*/04````` -M`'#\``$*1`4```````C$``$*2P4``````(L4``$*504``````!`L``$*6@4` -M`````!!$``$*7P4``````$DF``$*:`4```````BV``$*<04``````'*0``$* -M>04``````(<``$*DP4``````(,P -M``$*G04```````E```$*I`4``````!*$``$*J@4``````%YD``$*L04````` -M``A\``$*N04``````)'L``$*Q`4``````)`<``$*S@4``````!G8``$*U@4` -M`````!$$``$*W`4```````;,``$*XP4``````')```$*ZP4```````(&``$* -M\@4``````(-*``$*^@4``````!."``$+!`4``````(Q\``$+#F)I;F1E8RYO -M`%5315)?1$$`55-%4E]$,`!54T527T0Q`%5315)?03``55-%4E]!,0!54T52 -M7T90,`!54T527T90,0!54T527T90,@!54T527T90,P!54T527T900U(`1E!# -M4E]%3D%"3$4`1E!#4E]-3T1%`%5315)?1E!34@!&4%-27T-#`$904U)?44)9 -M5$4`1E!34E]%6$-%4%0`1E!34E]!15A#15!4`%5315)?1E!)05(`1E!?4T-2 -M,0!&4%]30U(R`%-43U)%7T9,1P!"24Y$14-?1DQ'`$1.4DU?1DQ'`%)%4U]& -M3$<`1%E?34]?1DQ'`%5&3$=?5$U0`$-57T].3%D`5D527U1-4`!&4%]30U(S -M`$907U-#4C0`1E!?4T-2-0!&4%]30U(V`$-57U-!5D500P!&4%)?1$E25%E? -M0DE44P!70E1%35``5T)414U07T58`%="5$5-4%](20!70E1%35!?3$\`5T)4 -M14U07U-'3@!&4%-27U-(041/5P!&4$E!4D-5`$--1%)%1S)"`$--1%)%1S-" -M`$Y-3D580P!N;6Y?=6YS=7!?8FET`&YM;E]S;F%N7V)I=`!.34-%6$,`;FUN -M7V]P97)R7V)I=`!N;6Y?;W9F;%]B:70`;FUN7W5N9FQ?8FET`&YM8U]U;G-U -M<%]B:70`;FUC7W-N86Y?8FET`&YM8U]O<&5R5]B -M:70`0TU$4D5',4(`:V9A8W1?8FET`$--1%=/4D0`9&ER96-T:6]N7V)I=`!S -M:7IE7V)I=#(`1%1!1P!D=&%G7VUA#%?8FET`&%I;W!?8FET`&%O=F9L7V)I=`!A=6YF;%]B -M:70`861Z7V)I=`!A:6YE>%]B:70`;F5G7VUAE]M87-K`&EN9E]M87-K -M`&YA;E]M87-K`&)S=6Y?;6%S:P!S;F%N7VUA#)?;6%S:P!I;F5X,5]M87-K -M`&%I;W!?;6%S:P!A;W9F;%]M87-K`&%U;F9L7VUAFEN9E]M87-K`&]P;F%N7VUA%]M87-K`&]V9FEN>%]M87-K`&EN>#%A7VUAF5R;U]T86<`:6YF7W1A -M9P!N86Y?=&%G`&1N'``03-?8V]N=`!!-%]S='(`<&]S7W)EG(`;%]L;V]P`&Q?;F5X=`!!,3-?8V]N`'1E'0`;F]?F5R;P!C;VYV%]L;V]P7V9I;@!X7VQO;W``03$V7W-T`&UA;G1?<`!W -MF5?8FET,@!$5$%'`&1T86=?;6%S:P!F<'1E;7`Q -M-5]B:70`5T)?0EE410!W8G1E;7`Q-5]B:70`15]"651%`$4Q`$4S`%-&3$%' -M`%1?0EE410!81DQ!1P!51DQ!1P!41DQ!1P!&4%1%35``1E!414U07T58`$90 -M5$5-4%](20!&4%1%35!?3$\`1E!414U07U-'3@!%5$5-4`!%5$5-4%]%6`!% -M5$5-4%](20!%5$5-4%],3P!%5$5-4%]31TX`15A#7U-2`$580U]00P!%6$-? -M5D5#`$580U]%00!N96=?8FET`'I?8FET`&EN9E]B:70`;F%N7V)I=`!Q7W-N -M7V)I=`!B%]M87-K`&1Z:6YF7VUAFE?;6%S:P!U;F9I;GA?;6%S:P!U;F8R:6YX7VUAE]M87-K`&]P86]P7VUA -M%]M87-K`'A?;6]D90!S7VUO9&4` -M9%]M;V1E`')N7VUO9&4`5]B:70`E]B:70`:6YF7V)I=`!N86Y?8FET`'%?E]B:70`:6YE>#)? -M8FET`&EN97@Q7V)I=`!A:6]P7V)I=`!A;W9F;%]B:70`875N9FQ?8FET`&%D -M>E]B:70`86EN97A?8FET`&YE9U]M87-K`'I?;6%S:P!I;F9?;6%S:P!N86Y? -M;6%S:P!BE]M87-K`&EN97@R7VUA#%?;6%S:P!A:6]P -M7VUAE]M87-K`&%I;F5X7VUA -M%]M87-K -M`'5N9C)I;GA?;6%S:P!O=F9I;GA?;6%S:P!I;G@Q85]M87-K`&EN>#)A7VUA -M%]M87-K`&]V -M9FQ?:6YX7VUA%]M;V1E`'-?;6]D90!D7VUO9&4`E]M -M;V1E`')M7VUO9&4`%]M87-K`&YO&,`9&]?9G5N8RYO`$1/7T953D,`55-%4E]$00!5 -M4T527T0P`%5315)?1#$`55-%4E]!,`!54T527T$Q`%5315)?1E`P`%5315)? -M1E`Q`%5315)?1E`R`%5315)?1E`S`%5315)?1E!#4@!&4$-27T5.04),10!& -M4$-27TU/1$4`55-%4E]&4%-2`$904U)?0T,`1E!34E]10EE410!&4%-27T58 -M0T505`!&4%-27T%%6$-%4%0`55-%4E]&4$E!4@!&4%]30U(Q`$907U-#4C(` -M4U1/4D5?1DQ'`$))3D1%0U]&3$<`1$Y235]&3$<`4D537T9,1P!$65]-3U]& -M3$<`549,1U]435``0U5?3TY,60!615)?5$U0`$907U-#4C,`1E!?4T-2-`!& -M4%]30U(U`$907U-#4C8`0U5?4T%615!#`$904E]$25)465]"2513`%="5$5- -M4`!70E1%35!?15@`5T)414U07TA)`%="5$5-4%],3P!70E1%35!?4T=.`$90 -M4U)?4TA!1$]7`$9024%20U4`0TU$4D5',D(`0TU$4D5',T(`3DU.15A#`&YM -M;E]U;G-U<%]B:70`;FUN7W-N86Y?8FET`$Y-0T580P!N;6Y?;W!EF5?8FET,@!$ -M5$%'`&1T86=?;6%S:P!F<'1E;7`Q-5]B:70`5T)?0EE410!W8G1E;7`Q-5]B -M:70`15]"651%`$4Q`$4S`%-&3$%'`%1?0EE410!81DQ!1P!51DQ!1P!41DQ! -M1P!&4%1%35``1E!414U07T58`$905$5-4%](20!&4%1%35!?3$\`1E!414U0 -M7U-'3@!%5$5-4`!%5$5-4%]%6`!%5$5-4%](20!%5$5-4%],3P!%5$5-4%]3 -M1TX`15A#7U-2`$580U]00P!%6$-?5D5#`$580U]%00!N96=?8FET`'I?8FET -M`&EN9E]B:70`;F%N7V)I=`!Q7W-N7V)I=`!B%]M87-K`&1Z -M:6YF7VUAFE?;6%S:P!U;F9I;GA?;6%S:P!U;F8R -M:6YX7VUAE]M87-K`&]P86]P7VUA%]M87-K`'A?;6]D90!S7VUO9&4`9%]M;V1E`')N7VUO9&4`5]B -M:70`G-N`'-M;V1?9G-N`'-M;V1?;G)M`'!R -M96UT`'-R96U?;W!E<@!SG-N`'-R96U?9G-N`'-R96U?;G)M`'!S8V%L970`G)O`'-C;%]I;F8`F5?8FET,@!$ -M5$%'`&1T86=?;6%S:P!F<'1E;7`Q-5]B:70`5T)?0EE410!W8G1E;7`Q-5]B -M:70`15]"651%`$4Q`$4S`%-&3$%'`%1?0EE410!81DQ!1P!51DQ!1P!41DQ! -M1P!&4%1%35``1E!414U07T58`$905$5-4%](20!&4%1%35!?3$\`1E!414U0 -M7U-'3@!%5$5-4`!%5$5-4%]%6`!%5$5-4%](20!%5$5-4%],3P!%5$5-4%]3 -M1TX`15A#7U-2`$580U]00P!%6$-?5D5#`$580U]%00!N96=?8FET`'I?8FET -M`&EN9E]B:70`;F%N7V)I=`!Q7W-N7V)I=`!B%]M87-K`&1Z -M:6YF7VUAFE?;6%S:P!U;F9I;GA?;6%S:P!U;F8R -M:6YX7VUAE]M87-K`&]P86]P7VUA%]M87-K`'A?;6]D90!S7VUO9&4`9%]M;V1E`')N7VUO9&4`5]B -M:70`&,`8V]M -M;6]N13$`;W9F;%]U;F9L`&-O;6UO;D4S`&YO7VUA=&-H`&1O7V-H96-K`'5N -M:6UP7W@`9&]?8VQE86X`=&5S=%]R978`=6YI;7!?8V]N`&-H96-K7V9R`&9R -M86UE7V-O;0!C;VUM;VY%`'5N&,`=6YI7VYO7V5X8P!U;G-?;F]?97AC`&9I;FES:%]U<`!O9G5F7V-O -M;@!B=7-Y7V9R`'1R>5\T,0!O9G5F7V9I;@!L;V]P,0!D;U]C;VX`9&]?8G5I -M;&0`9&]?5]B:70`0TU$4D5',4(` -M:V9A8W1?8FET`$--1%=/4D0`9&ER96-T:6]N7V)I=`!S:7IE7V)I=#(`1%1! -M1P!D=&%G7VUA#%?8FET`&%I;W!?8FET`&%O=F9L7V)I=`!A=6YF;%]B:70`861Z7V)I=`!A -M:6YE>%]B:70`;F5G7VUAE]M87-K`&EN9E]M87-K`&YA;E]M87-K`&)S -M=6Y?;6%S:P!S;F%N7VUA#)?;6%S:P!I;F5X,5]M87-K`&%I;W!?;6%S:P!A -M;W9F;%]M87-K`&%U;F9L7VUAFEN -M9E]M87-K`&]P;F%N7VUA%]M87-K`&]V9FEN>%]M87-K`&EN>#%A7VUAF5R;U]T86<`:6YF7W1A9P!N86Y?=&%G`&1N -M5]M;P!S5]Z97)O`&9I>%]N -M86X`9FEN:7-H`&YO=%]S<&5C`'!OF5R;P!M9FEX7VYA -M;@!M;E]S;F%N`&UN;W1?E]OG)O`'-E=%]B:70Q-0!E;F1? -M:7-?;G)M`&5N9%]F:7@`96YD7V=E=`!K97)N96Q?97@N;P!+15).14Q?15@` -M55-%4E]$00!54T527T0P`%5315)?1#$`55-%4E]!,`!54T527T$Q`%5315)? -M1E`P`%5315)?1E`Q`%5315)?1E`R`%5315)?1E`S`%5315)?1E!#4@!&4$-2 -M7T5.04),10!&4$-27TU/1$4`55-%4E]&4%-2`$904U)?0T,`1E!34E]10EE4 -M10!&4%-27T580T505`!&4%-27T%%6$-%4%0`55-%4E]&4$E!4@!&4%]30U(Q -M`$907U-#4C(`4U1/4D5?1DQ'`$))3D1%0U]&3$<`1$Y235]&3$<`4D537T9, -M1P!$65]-3U]&3$<`549,1U]435``0U5?3TY,60!615)?5$U0`$907U-#4C,` -M1E!?4T-2-`!&4%]30U(U`$907U-#4C8`0U5?4T%615!#`$904E]$25)465]" -M2513`%="5$5-4`!70E1%35!?15@`5T)414U07TA)`%="5$5-4%],3P!70E1% -M35!?4T=.`$904U)?4TA!1$]7`$9024%20U4`0TU$4D5',D(`0TU$4D5',T(` -M3DU.15A#`&YM;E]U;G-U<%]B:70`;FUN7W-N86Y?8FET`$Y-0T580P!N;6Y? -M;W!EF5?8FET,@!$5$%'`&1T86=?;6%S:P!F<'1E;7`Q-5]B:70`5T)?0EE410!W -M8G1E;7`Q-5]B:70`15]"651%`$4Q`$4S`%-&3$%'`%1?0EE410!81DQ!1P!5 -M1DQ!1P!41DQ!1P!&4%1%35``1E!414U07T58`$905$5-4%](20!&4%1%35!? -M3$\`1E!414U07U-'3@!%5$5-4`!%5$5-4%]%6`!%5$5-4%](20!%5$5-4%], -M3P!%5$5-4%]31TX`15A#7U-2`$580U]00P!%6$-?5D5#`$580U]%00!N96=? -M8FET`'I?8FET`&EN9E]B:70`;F%N7V)I=`!Q7W-N7V)I=`!B%]M87-K`&1Z:6YF7VUAFE?;6%S:P!U;F9I;GA? -M;6%S:P!U;F8R:6YX7VUAE]M87-K`&]P86]P7VUA%]M87-K`'A?;6]D90!S7VUO9&4`9%]M;V1E`')N7VUO9&4` -M5]B:70`E]E;F%?96YD`&U?:6YF`&1Z7V5N80!P7VEN9@!S -M971?9G!S<@!O<%]E;F$`=6YF;%]S:6=N;VL`=6YF;%]C;VX`=6YF;%]D:7,` -M=6YF;%]E;F$`=6YF;%]F:6X`=%]W;W)K`'1?9&)L`'1?&1N&1N&1E -M<`!N;W1?97AT`&ES7V5X=`!X9&YR;5]S=&]R90!I9&QE7V5N9`!E;F1?879U -M;@!S5]B:70`0TU$4D5',4(`:V9A8W1?8FET`$--1%=/4D0`9&ER96-T:6]N7V)I -M=`!S:7IE7V)I=#(`1%1!1P!D=&%G7VUA#%?8FET`&%I;W!?8FET`&%O=F9L7V)I=`!A=6YF -M;%]B:70`861Z7V)I=`!A:6YE>%]B:70`;F5G7VUAE]M87-K`&EN9E]M -M87-K`&YA;E]M87-K`&)S=6Y?;6%S:P!S;F%N7VUA#)?;6%S:P!I;F5X,5]M -M87-K`&%I;W!?;6%S:P!A;W9F;%]M87-K`&%U;F9L7VUAFEN9E]M87-K`&]P;F%N7VUA%]M87-K`&]V9FEN>%]M87-K`&EN>#%A7VUAF5R;U]T86<`:6YF -M7W1A9P!N86Y?=&%G`&1N6%D:6,`9'!O&X`8W5?;G5N9FP`8W5? -M;FUR9&,`8W5?;F]V9FP`8W5?;FURG)O`&-U7VYZ -MF5R;P!C=5]W%]S=&L`8W5?9&UO=F4`8W5?9&%BF5R;P!F<#`Q,C,`9G`P7V1S -M=`!F<#%?9'-T`&9P,E]D5]P;')G`&)Y7VYLE]L;VYG`'-Z -M7V-O;@!X9&YR;0!D;U]F<`!S<%]C871A'0`&]P`'!?;6]V970`<%]M;W9E>@!P7VUO=F5I`'!?;6]V -M96X`<%]R96=D`'!?9'ED,`!P7V1Y9#$`<%]D>60R`'!?9'ED,P!P7V1Y9#0` -M<%]D>60U`'!?9'ED-@!P7V1Y9#<`<%]WF5?8FET,@!$5$%'`&1T86=?;6%S:P!F<'1E;7`Q-5]B:70` -M5T)?0EE410!W8G1E;7`Q-5]B:70`15]"651%`$4Q`$4S`%-&3$%'`%1?0EE4 -M10!81DQ!1P!51DQ!1P!41DQ!1P!&4%1%35``1E!414U07T58`$905$5-4%]( -M20!&4%1%35!?3$\`1E!414U07U-'3@!%5$5-4`!%5$5-4%]%6`!%5$5-4%]( -M20!%5$5-4%],3P!%5$5-4%]31TX`15A#7U-2`$580U]00P!%6$-?5D5#`$58 -M0U]%00!N96=?8FET`'I?8FET`&EN9E]B:70`;F%N7V)I=`!Q7W-N7V)I=`!B -M%]M87-K`&1Z:6YF7VUAFE?;6%S -M:P!U;F9I;GA?;6%S:P!U;F8R:6YX7VUAE]M87-K`&]P86]P7VUA%]M87-K`'A?;6]D90!S7VUO9&4`9%]M;V1E -M`')N7VUO9&4`5]B:70`0!E;F1?'1?9&]N90!D8V-?8VQR`&1B;%]D -M;VYE`&5R'0`;F]?:6YE>`!D -M;G)M7VEN97@`;&]A9%]S9VP`;&]A9%]D8FP`8VAK7W-T:WD`5]B:70`0TU$4D5',4(`:V9A8W1?8FET -M`$--1%=/4D0`9&ER96-T:6]N7V)I=`!S:7IE7V)I=#(`1%1!1P!D=&%G7VUA -M#%?8FET`&%I -M;W!?8FET`&%O=F9L7V)I=`!A=6YF;%]B:70`861Z7V)I=`!A:6YE>%]B:70` -M;F5G7VUAE]M87-K`&EN9E]M87-K`&YA;E]M87-K`&)S=6Y?;6%S:P!S -M;F%N7VUA#)?;6%S:P!I;F5X,5]M87-K`&%I;W!?;6%S:P!A;W9F;%]M87-K -M`&%U;F9L7VUAFEN9E]M87-K`&]P -M;F%N7VUA%]M87-K`&]V -M9FEN>%]M87-K`&EN>#%A7VUAF5R;U]T86<`:6YF7W1A9P!N86Y?=&%G`&1NE]B:70`:6YF7V)I=`!N86Y?8FET`'%?E]B:70` -M:6YE>#)?8FET`&EN97@Q7V)I=`!A:6]P7V)I=`!A;W9F;%]B:70`875N9FQ? -M8FET`&%D>E]B:70`86EN97A?8FET`&YE9U]M87-K`'I?;6%S:P!I;F9?;6%S -M:P!N86Y?;6%S:P!BE]M87-K`&EN97@R7VUA#%?;6%S -M:P!A:6]P7VUAE]M87-K`&%I -M;F5X7VUA%]M87-K`'5N9C)I;GA?;6%S:P!O=F9I;GA?;6%S:P!I;G@Q85]M87-K`&EN -M>#)A7VUA%]M -M87-K`&]V9FQ?:6YX7VUA%]M;V1E`'-?;6]D90!D7VUO9&4`E]M;V1E`')M7VUO9&4`%]M87-K`&YO5]B:70`0TU$4D5',4(`:V9A8W1?8FET`$--1%=/4D0`9&ER96-T:6]N -M7V)I=`!S:7IE7V)I=#(`1%1!1P!D=&%G7VUA#%?8FET`&%I;W!?8FET`&%O=F9L7V)I=`!A -M=6YF;%]B:70`861Z7V)I=`!A:6YE>%]B:70`;F5G7VUAE]M87-K`&EN -M9E]M87-K`&YA;E]M87-K`&)S=6Y?;6%S:P!S;F%N7VUA#)?;6%S:P!I;F5X -M,5]M87-K`&%I;W!?;6%S:P!A;W9F;%]M87-K`&%U;F9L7VUAFEN9E]M87-K`&]P;F%N7VUA%]M87-K`&]V9FEN>%]M87-K`&EN>#%A7VUA -MF5R;U]T86<` -M:6YF7W1A9P!N86Y?=&%G`&1N#%?8FET -M`&%I;W!?8FET`&%O=F9L7V)I=`!A=6YF;%]B:70`861Z7V)I=`!A:6YE>%]B -M:70`;F5G7VUAE]M87-K`&EN9E]M87-K`&YA;E]M87-K`&)S=6Y?;6%S -M:P!S;F%N7VUA#)?;6%S:P!I;F5X,5]M87-K`&%I;W!?;6%S:P!A;W9F;%]M -M87-K`&%U;F9L7VUAFEN9E]M87-K -M`&]P;F%N7VUA%]M87-K -M`&]V9FEN>%]M87-K`&EN>#%A7VUAF5R;U]T86<`:6YF7W1A9P!N86Y?=&%G`&1NE]N96<`:6YT -M<',`;G)ME]B:70`:6YF7V)I=`!N86Y?8FET`'%?E]B:70`:6YE>#)?8FET`&EN97@Q7V)I=`!A:6]P7V)I=`!A;W9F -M;%]B:70`875N9FQ?8FET`&%D>E]B:70`86EN97A?8FET`&YE9U]M87-K`'I? -M;6%S:P!I;F9?;6%S:P!N86Y?;6%S:P!BE]M87-K`&EN97@R7VUA -M#%?;6%S:P!A:6]P7VUAE]M87-K`&%I;F5X7VUA%]M87-K`'5N9C)I;GA?;6%S:P!O=F9I;GA?;6%S:P!I -M;G@Q85]M87-K`&EN>#)A7VUA%]M87-K`&]V9FQ?:6YX7VUA%]M;V1E`'-?;6]D90!D -M7VUO9&4`E]M;V1E`')M7VUO9&4`%]M87-K`&YOF5?8FET,@!$ -M5$%'`&1T86=?;6%S:P!F<'1E;7`Q-5]B:70`5T)?0EE410!W8G1E;7`Q-5]B -M:70`15]"651%`$4Q`$4S`%-&3$%'`%1?0EE410!81DQ!1P!51DQ!1P!41DQ! -M1P!&4%1%35``1E!414U07T58`$905$5-4%](20!&4%1%35!?3$\`1E!414U0 -M7U-'3@!%5$5-4`!%5$5-4%]%6`!%5$5-4%](20!%5$5-4%],3P!%5$5-4%]3 -M1TX`15A#7U-2`$580U]00P!%6$-?5D5#`$580U]%00!N96=?8FET`'I?8FET -M`&EN9E]B:70`;F%N7V)I=`!Q7W-N7V)I=`!B%]M87-K`&1Z -M:6YF7VUAFE?;6%S:P!U;F9I;GA?;6%S:P!U;F8R -M:6YX7VUAE]M87-K`&]P86]P7VUA%]M87-K`'A?;6]D90!S7VUO9&4`9%]M;V1E`')N7VUO9&4`5]B -M:70`F5?8FET,@!$ -M5$%'`&1T86=?;6%S:P!F<'1E;7`Q-5]B:70`5T)?0EE410!W8G1E;7`Q-5]B -M:70`15]"651%`$4Q`$4S`%-&3$%'`%1?0EE410!81DQ!1P!51DQ!1P!41DQ! -M1P!&4%1%35``1E!414U07T58`$905$5-4%](20!&4%1%35!?3$\`1E!414U0 -M7U-'3@!%5$5-4`!%5$5-4%]%6`!%5$5-4%](20!%5$5-4%],3P!%5$5-4%]3 -M1TX`15A#7U-2`$580U]00P!%6$-?5D5#`$580U]%00!N96=?8FET`'I?8FET -M`&EN9E]B:70`;F%N7V)I=`!Q7W-N7V)I=`!B%]M87-K`&1Z -M:6YF7VUAFE?;6%S:P!U;F9I;GA?;6%S:P!U;F8R -M:6YX7VUAE]M87-K`&]P86]P7VUA%]M87-K`'A?;6]D90!S7VUO9&4`9%]M;V1E`')N7VUO9&4`5]B -M:70`E]B:70`:6YF7V)I=`!N86Y?8FET`'%?E]B:70`:6YE>#)?8FET`&EN97@Q7V)I=`!A:6]P7V)I=`!A;W9F;%]B:70` -M875N9FQ?8FET`&%D>E]B:70`86EN97A?8FET`&YE9U]M87-K`'I?;6%S:P!I -M;F9?;6%S:P!N86Y?;6%S:P!BE]M87-K`&EN97@R7VUA#%?;6%S:P!A:6]P7VUAE]M -M87-K`&%I;F5X7VUA%]M87-K`'5N9C)I;GA?;6%S:P!O=F9I;GA?;6%S:P!I;G@Q85]M -M87-K`&EN>#)A7VUA%]M87-K`&]V9FQ?:6YX7VUA%]M;V1E`'-?;6]D90!D7VUO9&4` -ME]M;V1E`')M7VUO9&4`%]M87-K`&YOF5R;P!N;U]D:7(`>F5R7W)M`'IE%]E>&ET`&YO7V1IF5R7W)M,@!Z97)?E]B:70` -M:6YF7V)I=`!N86Y?8FET`'%?E]B:70`:6YE>#)?8FET`&EN -M97@Q7V)I=`!A:6]P7V)I=`!A;W9F;%]B:70`875N9FQ?8FET`&%D>E]B:70` -M86EN97A?8FET`&YE9U]M87-K`'I?;6%S:P!I;F9?;6%S:P!N86Y?;6%S:P!B -ME]M87-K`&EN97@R7VUA#%?;6%S:P!A:6]P7VUAE]M87-K`&%I;F5X7VUA%]M87-K`'5N9C)I -M;GA?;6%S:P!O=F9I;GA?;6%S:P!I;G@Q85]M87-K`&EN>#)A7VUA%]M87-K`&]V9FQ?:6YX -M7VUA%]M;V1E`'-?;6]D90!D7VUO9&4`E]M;V1E`')M -M7VUO9&4`%]M87-K`&YO5]B:70` -M0TU$4D5',4(`:V9A8W1?8FET`$--1%=/4D0`9&ER96-T:6]N7V)I=`!S:7IE -M7V)I=#(`1%1!1P!D=&%G7VUA#%?8FET`&%I;W!?8FET`&%O=F9L7V)I=`!A=6YF;%]B:70` -M861Z7V)I=`!A:6YE>%]B:70`;F5G7VUAE]M87-K`&EN9E]M87-K`&YA -M;E]M87-K`&)S=6Y?;6%S:P!S;F%N7VUA#)?;6%S:P!I;F5X,5]M87-K`&%I -M;W!?;6%S:P!A;W9F;%]M87-K`&%U;F9L7VUAFEN9E]M87-K`&]P;F%N7VUA%]M87-K`&]V9FEN>%]M87-K`&EN>#%A7VUAF5R;U]T86<`:6YF7W1A9P!N -M86Y?=&%G`&1NF5?8FET,@!$5$%'`&1T86=?;6%S:P!F<'1E;7`Q-5]B:70`5T)?0EE410!W -M8G1E;7`Q-5]B:70`15]"651%`$4Q`$4S`%-&3$%'`%1?0EE410!81DQ!1P!5 -M1DQ!1P!41DQ!1P!&4%1%35``1E!414U07T58`$905$5-4%](20!&4%1%35!? -M3$\`1E!414U07U-'3@!%5$5-4`!%5$5-4%]%6`!%5$5-4%](20!%5$5-4%], -M3P!%5$5-4%]31TX`15A#7U-2`$580U]00P!%6$-?5D5#`$580U]%00!N96=? -M8FET`'I?8FET`&EN9E]B:70`;F%N7V)I=`!Q7W-N7V)I=`!B%]M87-K`&1Z:6YF7VUAFE?;6%S:P!U;F9I;GA? -M;6%S:P!U;F8R:6YX7VUAE]M87-K`&]P86]P7VUA%]M87-K`'A?;6]D90!S7VUO9&4`9%]M;V1E`')N7VUO9&4` -M5]B:70`5]B:70`0TU$4D5',4(`:V9A8W1?8FET`$--1%=/4D0` -M9&ER96-T:6]N7V)I=`!S:7IE7V)I=#(`1%1!1P!D=&%G7VUAE]B:70`:6YF7V)I=`!N86Y?8FET`'%?E]B -M:70`:6YE>#)?8FET`&EN97@Q7V)I=`!A:6]P7V)I=`!A;W9F;%]B:70`875N -M9FQ?8FET`&%D>E]B:70`86EN97A?8FET`&YE9U]M87-K`'I?;6%S:P!I;F9? -M;6%S:P!N86Y?;6%S:P!BE]M87-K`&EN97@R7VUA#%? -M;6%S:P!A:6]P7VUAE]M87-K -M`&%I;F5X7VUA%]M87-K`'5N9C)I;GA?;6%S:P!O=F9I;GA?;6%S:P!I;G@Q85]M87-K -M`&EN>#)A7VUA%]M87-K`&]V9FQ?:6YX7VUA%]M;V1E`'-?;6]D90!D7VUO9&4`E]M;V1E`')M7VUO9&4`%]M87-K`&YOE]B:70`:6YF7V)I=`!N -M86Y?8FET`'%?E]B:70`:6YE>#)?8FET`&EN97@Q7V)I=`!A -M:6]P7V)I=`!A;W9F;%]B:70`875N9FQ?8FET`&%D>E]B:70`86EN97A?8FET -M`&YE9U]M87-K`'I?;6%S:P!I;F9?;6%S:P!N86Y?;6%S:P!BE]M -M87-K`&EN97@R7VUA#%?;6%S:P!A:6]P7VUAE]M87-K`&%I;F5X7VUA%]M87-K`'5N9C)I;GA?;6%S:P!O -M=F9I;GA?;6%S:P!I;G@Q85]M87-K`&EN>#)A7VUA%]M87-K`&]V9FQ?:6YX7VUA%]M -M;V1E`'-?;6]D90!D7VUO9&4`E]M;V1E`')M7VUO9&4`%]M87-K -M`&YO&,`;W9F9E]S9VP` -M;W9F9E]D8FP`;W9F7V9S9VP`;W9F7V9P8W(`&,` -M=6YF7V4S7V5X8P!U;F9F7W-G;`!U;F9F7V1B;`!U;F9?9G-G;`!U;F9?9G!C -M<@!O<&-?,6(`;W!C7S-B`&]P,#$Q`&YO=%]S9VP`;F]T7V1B;`!%6%1?4%I2 -M3P!31TQ?4%I23P!$0DQ?4%I23P!%6%1?4%--3`!31TQ?4%--3`!$0DQ?4%-- -M3`!T8FQU;F8`=4585%]23@!U15A47U):`'5%6%1?4DT`=4585%]24`!U4T=, -M7U).`'531TQ?4EH`=5-'3%]230!U4T=,7U)0`'5$0DQ?4DX`=41"3%]26@!U -M1$),7U)-`'5$0DQ?4E``=7-E=%]S:6=N`'5E7W)M7W!O71E7V0R`&)Y=&5?9#,`8GET95]D-`!B>71E7V0U`&)Y=&5? -M9#8`8GET95]D-P!W;W)D7V0P`'=OE]B:70`:6YF7V)I=`!N86Y?8FET -M`'%?E]B:70`:6YE>#)?8FET`&EN97@Q7V)I=`!A:6]P7V)I -M=`!A;W9F;%]B:70`875N9FQ?8FET`&%D>E]B:70`86EN97A?8FET`&YE9U]M -M87-K`'I?;6%S:P!I;F9?;6%S:P!N86Y?;6%S:P!BE]M87-K`&EN -M97@R7VUA#%?;6%S:P!A:6]P7VUAE]M87-K`&%I;F5X7VUA%]M87-K`'5N9C)I;GA?;6%S:P!O=F9I;GA? -M;6%S:P!I;G@Q85]M87-K`&EN>#)A7VUA%]M87-K`&]V9FQ?:6YX7VUA%]M;V1E`'-? -M;6]D90!D7VUO9&4`E]M;V1E`')M7VUO9&4`%]M87-K`&YO%]F;&EN92YO`%A?1DQ)3D4`55-%4E]$00!54T527T0P`%53 -M15)?1#$`55-%4E]!,`!54T527T$Q`%5315)?1E`P`%5315)?1E`Q`%5315)? -M1E`R`%5315)?1E`S`%5315)?1E!#4@!&4$-27T5.04),10!&4$-27TU/1$4` -M55-%4E]&4%-2`$904U)?0T,`1E!34E]10EE410!&4%-27T580T505`!&4%-2 -M7T%%6$-%4%0`55-%4E]&4$E!4@!&4%]30U(Q`$907U-#4C(`4U1/4D5?1DQ' -M`$))3D1%0U]&3$<`1$Y235]&3$<`4D537T9,1P!$65]-3U]&3$<`549,1U]4 -M35``0U5?3TY,60!615)?5$U0`$907U-#4C,`1E!?4T-2-`!&4%]30U(U`$90 -M7U-#4C8`0U5?4T%615!#`$904E]$25)465]"2513`%="5$5-4`!70E1%35!? -M15@`5T)414U07TA)`%="5$5-4%],3P!70E1%35!?4T=.`$904U)?4TA!1$]7 -M`$9024%20U4`0TU$4D5',D(`0TU$4D5',T(`3DU.15A#`&YM;E]U;G-U<%]B -M:70`;FUN7W-N86Y?8FET`$Y-0T580P!N;6Y?;W!EF5?8FET,@!$5$%'`&1T86=? -M;6%S:P!F<'1E;7`Q-5]B:70`5T)?0EE410!W8G1E;7`Q-5]B:70`15]"651% -M`$4Q`$4S`%-&3$%'`%1?0EE410!81DQ!1P!51DQ!1P!41DQ!1P!&4%1%35`` -M1E!414U07T58`$905$5-4%](20!&4%1%35!?3$\`1E!414U07U-'3@!%5$5- -M4`!%5$5-4%]%6`!%5$5-4%](20!%5$5-4%],3P!%5$5-4%]31TX`15A#7U-2 -M`$580U]00P!%6$-?5D5#`$580U]%00!N96=?8FET`'I?8FET`&EN9E]B:70` -M;F%N7V)I=`!Q7W-N7V)I=`!B%]M87-K`&1Z:6YF7VUAFE?;6%S:P!U;F9I;GA?;6%S:P!U;F8R:6YX7VUAE]M -M87-K`&]P86]P7VUA%]M87-K`'A? -M;6]D90!S7VUO9&4`9%]M;V1E`')N7VUO9&4`5]B:70`%]S=&%C:P!C:U]R978`9FEX -M7V-O;@!X7V]P97)R+F\`6%]/4$524@!54T527T1!`%5315)?1#``55-%4E]$ -M,0!54T527T$P`%5315)?03$`55-%4E]&4#``55-%4E]&4#$`55-%4E]&4#(` -M55-%4E]&4#,`55-%4E]&4$-2`$900U)?14Y!0DQ%`$900U)?34]$10!54T52 -M7T904U(`1E!34E]#0P!&4%-27U%"651%`$904U)?15A#15!4`$904U)?0458 -M0T505`!54T527T9024%2`$907U-#4C$`1E!?4T-2,@!35$]215]&3$<`0DE. -M1$5#7T9,1P!$3E)-7T9,1P!215-?1DQ'`$197TU/7T9,1P!51DQ'7U1-4`!# -M55]/3DQ9`%9%4E]435``1E!?4T-2,P!&4%]30U(T`$907U-#4C4`1E!?4T-2 -M-@!#55]3059%4$,`1E!27T1)4E197T))5%,`5T)414U0`%="5$5-4%]%6`!7 -M0E1%35!?2$D`5T)414U07TQ/`%="5$5-4%]31TX`1E!34E]32$%$3U<`1E!) -M05)#50!#341214E]B:70`:6YF7V)I=`!N86Y? -M8FET`'%?E]B:70`:6YE>#)?8FET`&EN97@Q7V)I=`!A:6]P -M7V)I=`!A;W9F;%]B:70`875N9FQ?8FET`&%D>E]B:70`86EN97A?8FET`&YE -M9U]M87-K`'I?;6%S:P!I;F9?;6%S:P!N86Y?;6%S:P!BE]M87-K -M`&EN97@R7VUA#%?;6%S:P!A:6]P7VUAE]M87-K`&%I;F5X7VUA%]M87-K`'5N9C)I;GA?;6%S:P!O=F9I -M;GA?;6%S:P!I;G@Q85]M87-K`&EN>#)A7VUA%]M87-K`&]V9FQ?:6YX7VUA%]M;V1E -M`'-?;6]D90!D7VUO9&4`E]M;V1E`')M7VUO9&4`%]M87-K`&YO -M71E`&]P97)R7VYA;@!C:&ML97)R`&-H96-K7W5P<&5R`&]P97)R -M7W-T;W)E`&YO=%]E;F%B;&5D`&-H:VQE&QO;F<`%]O -M=F9L+F\`6%]/5D9,`%5315)?1$$`55-%4E]$,`!54T527T0Q`%5315)?03`` -M55-%4E]!,0!54T527T90,`!54T527T90,0!54T527T90,@!54T527T90,P!5 -M4T527T900U(`1E!#4E]%3D%"3$4`1E!#4E]-3T1%`%5315)?1E!34@!&4%-2 -M7T-#`$904U)?44)95$4`1E!34E]%6$-%4%0`1E!34E]!15A#15!4`%5315)? -M1E!)05(`1E!?4T-2,0!&4%]30U(R`%-43U)%7T9,1P!"24Y$14-?1DQ'`$1. -M4DU?1DQ'`%)%4U]&3$<`1%E?34]?1DQ'`%5&3$=?5$U0`$-57T].3%D`5D52 -M7U1-4`!&4%]30U(S`$907U-#4C0`1E!?4T-2-0!&4%]30U(V`$-57U-!5D50 -M0P!&4%)?1$E25%E?0DE44P!70E1%35``5T)414U07T58`%="5$5-4%](20!7 -M0E1%35!?3$\`5T)414U07U-'3@!&4%-27U-(041/5P!&4$E!4D-5`$--1%)% -M1S)"`$--1%)%1S-"`$Y-3D580P!N;6Y?=6YS=7!?8FET`&YM;E]S;F%N7V)I -M=`!.34-%6$,`;FUN7V]P97)R7V)I=`!N;6Y?;W9F;%]B:70`;FUN7W5N9FQ? -M8FET`&YM8U]U;G-U<%]B:70`;FUC7W-N86Y?8FET`&YM8U]O<&5R5]B:70`0TU$4D5',4(`:V9A8W1?8FET`$--1%=/4D0`9&ER -M96-T:6]N7V)I=`!S:7IE7V)I=#(`1%1!1P!D=&%G7VUA5]B:70`0TU$4D5',4(`:V9A8W1?8FET`$--1%=/4D0`9&ER -M96-T:6]N7V)I=`!S:7IE7V)I=#(`1%1!1P!D=&%G7VUA5]B:70` -M0TU$4D5',4(`:V9A8W1?8FET`$--1%=/4D0`9&ER96-T:6]N7V)I=`!S:7IE -M7V)I=#(`1%1!1P!D=&%G7VUA#%?8FET`&%I;W!?8FET`&%O=F9L7V)I=`!A=6YF;%]B:70` -M861Z7V)I=`!A:6YE>%]B:70`;F5G7VUAE]M87-K`&EN9E]M87-K`&YA -M;E]M87-K`&)S=6Y?;6%S:P!S;F%N7VUA#)?;6%S:P!I;F5X,5]M87-K`&%I -M;W!?;6%S:P!A;W9F;%]M87-K`&%U;F9L7VUAFEN9E]M87-K`&]P;F%N7VUA%]M87-K`&]V9FEN>%]M87-K`&EN>#%A7VUAF5R;U]T86<`:6YF7W1A9P!N -M86Y?=&%G`&1NF5?8FET,@!$5$%'`&1T86=?;6%S:P!F<'1E;7`Q-5]B:70`5T)?0EE4 -M10!W8G1E;7`Q-5]B:70`15]"651%`$4Q`$4S`%-&3$%'`%1?0EE410!81DQ! -M1P!51DQ!1P!41DQ!1P!&4%1%35``1E!414U07T58`$905$5-4%](20!&4%1% -M35!?3$\`1E!414U07U-'3@!%5$5-4`!%5$5-4%]%6`!%5$5-4%](20!%5$5- -M4%],3P!%5$5-4%]31TX`15A#7U-2`$580U]00P!%6$-?5D5#`$580U]%00!N -M96=?8FET`'I?8FET`&EN9E]B:70`;F%N7V)I=`!Q7W-N7V)I=`!B%]M87-K`&1Z:6YF7VUAFE?;6%S:P!U;F9I -M;GA?;6%S:P!U;F8R:6YX7VUAE]M87-K`&]P86]P7VUA%]M87-K`'A?;6]D90!S7VUO9&4`9%]M;V1E`')N7VUO -M9&4`5]B:70``!N;U]E,U\Q`'5N9FQ?9&]N90!T86ME7VEN97@`;F]?93-?,@!E -M,5]S970`=6YF7T4Q`'5N9E]%,P!U;F9?'1?;W!C,#$Q`'5N9E]D;VYE`&-K7W-G -M;@!N;U]A=6YF;`!X7W5N:6UP+F\`6%]53DE-4`!54T527T1!`%5315)?1#`` -M55-%4E]$,0!54T527T$P`%5315)?03$`55-%4E]&4#``55-%4E]&4#$`55-% -M4E]&4#(`55-%4E]&4#,`55-%4E]&4$-2`$900U)?14Y!0DQ%`$900U)?34]$ -M10!54T527T904U(`1E!34E]#0P!&4%-27U%"651%`$904U)?15A#15!4`$90 -M4U)?04580T505`!54T527T9024%2`$907U-#4C$`1E!?4T-2,@!35$]215]& -M3$<`0DE.1$5#7T9,1P!$3E)-7T9,1P!215-?1DQ'`$197TU/7T9,1P!51DQ' -M7U1-4`!#55]/3DQ9`%9%4E]435``1E!?4T-2,P!&4%]30U(T`$907U-#4C4` -M1E!?4T-2-@!#55]3059%4$,`1E!27T1)4E197T))5%,`5T)414U0`%="5$5- -M4%]%6`!70E1%35!?2$D`5T)414U07TQ/`%="5$5-4%]31TX`1E!34E]32$%$ -M3U<`1E!)05)#50!#341214E]B:70`:6YF7V)I -M=`!N86Y?8FET`'%?E]B:70`:6YE>#)?8FET`&EN97@Q7V)I -M=`!A:6]P7V)I=`!A;W9F;%]B:70`875N9FQ?8FET`&%D>E]B:70`86EN97A? -M8FET`&YE9U]M87-K`'I?;6%S:P!I;F9?;6%S:P!N86Y?;6%S:P!BE]M87-K`&EN97@R7VUA#%?;6%S:P!A:6]P7VUAE]M87-K`&%I;F5X7VUA%]M87-K`'5N9C)I;GA?;6%S -M:P!O=F9I;GA?;6%S:P!I;G@Q85]M87-K`&EN>#)A7VUA%]M87-K`&]V9FQ?:6YX7VUA%]M;V1E`'-?;6]D90!D7VUO9&4`E]M;V1E`')M7VUO9&4` -M%]M -M87-K`&YO%]U;G-U<'`N;P!87U5.4U50 -M4`!54T527T1!`%5315)?1#``55-%4E]$,0!54T527T$P`%5315)?03$`55-% -M4E]&4#``55-%4E]&4#$`55-%4E]&4#(`55-%4E]&4#,`55-%4E]&4$-2`$90 -M0U)?14Y!0DQ%`$900U)?34]$10!54T527T904U(`1E!34E]#0P!&4%-27U%" -M651%`$904U)?15A#15!4`$904U)?04580T505`!54T527T9024%2`$907U-# -M4C$`1E!?4T-2,@!35$]215]&3$<`0DE.1$5#7T9,1P!$3E)-7T9,1P!215-? -M1DQ'`$197TU/7T9,1P!51DQ'7U1-4`!#55]/3DQ9`%9%4E]435``1E!?4T-2 -M,P!&4%]30U(T`$907U-#4C4`1E!?4T-2-@!#55]3059%4$,`1E!27T1)4E19 -M7T))5%,`5T)414U0`%="5$5-4%]%6`!70E1%35!?2$D`5T)414U07TQ/`%=" -M5$5-4%]31TX`1E!34E]32$%$3U<`1E!)05)#50!#341214E]B:70`:6YF7V)I=`!N86Y?8FET`'%?E]B:70` -M:6YE>#)?8FET`&EN97@Q7V)I=`!A:6]P7V)I=`!A;W9F;%]B:70`875N9FQ? -M8FET`&%D>E]B:70`86EN97A?8FET`&YE9U]M87-K`'I?;6%S:P!I;F9?;6%S -M:P!N86Y?;6%S:P!BE]M87-K`&EN97@R7VUA#%?;6%S -M:P!A:6]P7VUAE]M87-K`&%I -M;F5X7VUA%]M87-K`'5N9C)I;GA?;6%S:P!O=F9I;GA?;6%S:P!I;G@Q85]M87-K`&EN -M>#)A7VUA%]M -M87-K`&]V9FQ?:6YX7VUA%]M;V1E`'-?;6]D90!D7VUO9&4`E]M;V1E`')M7VUO9&4`%]M87-K`&YO`!B=6=F:7@N;P!54T527T1!`%5315)?1#`` -M55-%4E]$,0!54T527T$P`%5315)?03$`55-%4E]&4#``55-%4E]&4#$`55-% -M4E]&4#(`55-%4E]&4#,`55-%4E]&4$-2`$900U)?14Y!0DQ%`$900U)?34]$ -M10!54T527T904U(`1E!34E]#0P!&4%-27U%"651%`$904U)?15A#15!4`$90 -M4U)?04580T505`!54T527T9024%2`$907U-#4C$`1E!?4T-2,@!35$]215]& -M3$<`0DE.1$5#7T9,1P!$3E)-7T9,1P!215-?1DQ'`$197TU/7T9,1P!51DQ' -M7U1-4`!#55]/3DQ9`%9%4E]435``1E!?4T-2,P!&4%]30U(T`$907U-#4C4` -M1E!?4T-2-@!#55]3059%4$,`1E!27T1)4E197T))5%,`5T)414U0`%="5$5- -M4%]%6`!70E1%35!?2$D`5T)414U07TQ/`%="5$5-4%]31TX`1E!34E]32$%$ -M3U<`1E!)05)#50!#341214E]B:70`:6YF7V)I -M=`!N86Y?8FET`'%?E]B:70`:6YE>#)?8FET`&EN97@Q7V)I -M=`!A:6]P7V)I=`!A;W9F;%]B:70`875N9FQ?8FET`&%D>E]B:70`86EN97A? -M8FET`&YE9U]M87-K`'I?;6%S:P!I;F9?;6%S:P!N86Y?;6%S:P!BE]M87-K`&EN97@R7VUA#%?;6%S:P!A:6]P7VUAE]M87-K`&%I;F5X7VUA%]M87-K`'5N9C)I;GA?;6%S -M:P!O=F9I;GA?;6%S:P!I;G@Q85]M87-K`&EN>#)A7VUA%]M87-K`&]V9FQ?:6YX7VUA%]M;V1E`'-?;6]D90!D7VUO9&4`E]M;V1E`')M7VUO9&4` -M%]M -M87-K`&YO'4` -M&D`;W`P7V9P,P!O<#!?9G`P -M`&]P,%]F<#$`;W`P7V9P,@!O<#!?;&]O<`!O<#!?&D`;W`R7V9P,P!O<#)?9G`P`&]P,E]F<#$` -M;W`R7V9P,@!O<#)?;&]O<`!C87-E,@!C87-E,P!C87-E-`!D`!S;&]G,3!D`'1?97AT9&YR;0!D96YO@!S971O>`!T7V]V9FP`4TU!3%). -M`&]V9E]R7W@R`&]V9E]R7W@S`&YR;5]Z97)O`&1N&TQ`'5N9E]S=6(`'0`F5R;P!D97-T7V1B;`!R97-?9G5N8P!S;&]G;G`Q`'-L;V&0`9U]O<&-L -M&0`4$E40DP``!G971?9FQI;F4`G)? -M:6YF`&9P that come in handy later. - - NOTE: This is the only thing different than what's in - kern/exec_aout.c ! Perhaps the two files could merge somehow? */ - -/* suns keep data seg aligned to SEGSIZ because of sun custom mmu */ -#define SEGSIZ 0x20000 -#define N_TXTADDR(x,m) __LDPGSZ -#define N_DATADDR(x,m) (((m)==OMAGIC) ? (N_TXTADDR(x,m) + (x).a_text) \ - : (SEGSIZ + ((N_TXTADDR(x,m) + (x).a_text - 1) \ - & ~(SEGSIZ-1)))) -#define N_BSSADDR(x,m) (N_DATADDR(x,m)+(x).a_data) - -#define N_TXTOFF(x,m) ((m)==ZMAGIC ? 0 : sizeof (struct exec)) -#define N_DATOFF(x,m) (N_TXTOFF(x,m) + (x).a_text) - -/* - * sun_exec_aout_prep_zmagic(): Prepare a SunOS ZMAGIC binary's exec package - * - * First, set of the various offsets/lengths in the exec package. - * - * Then, mark the text image busy (so it can be demand paged) or error - * out if this is not possible. Finally, set up vmcmds for the - * text, data, bss, and stack segments. - */ - -int -sun_exec_aout_prep_zmagic(p, epp) - struct proc *p; - struct exec_package *epp; -{ - struct exec *execp = epp->ep_execp; - struct exec_vmcmd *ccmdp; - - epp->ep_taddr = N_TXTADDR (*execp, ZMAGIC); - epp->ep_tsize = execp->a_text; - epp->ep_daddr = N_DATADDR (*execp, ZMAGIC); - epp->ep_dsize = execp->a_data + execp->a_bss; - epp->ep_entry = execp->a_entry; - - /* - * check if vnode is in open for writing, because we want to - * demand-page out of it. if it is, don't do it, for various - * reasons - */ - if ((execp->a_text != 0 || execp->a_data != 0) && - (epp->ep_vp->v_flag & VTEXT) == 0 && epp->ep_vp->v_writecount != 0) { -#ifdef DIAGNOSTIC - if (epp->ep_vp->v_flag & VTEXT) - panic("exec: a VTEXT vnode has writecount != 0\n"); -#endif - epp->ep_vcp = NULL; - return ETXTBSY; - } - epp->ep_vp->v_flag |= VTEXT; - - /* set up command for text segment */ - epp->ep_vcp = new_vmcmd(vmcmd_map_pagedvn, - execp->a_text, - epp->ep_taddr, - epp->ep_vp, - N_TXTOFF(*execp, ZMAGIC), - VM_PROT_READ | VM_PROT_EXECUTE); - ccmdp = epp->ep_vcp; - - /* set up command for data segment */ - ccmdp->ev_next = new_vmcmd(vmcmd_map_pagedvn, - execp->a_data, - epp->ep_daddr, - epp->ep_vp, - N_DATOFF(*execp, ZMAGIC), - VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); - ccmdp = ccmdp->ev_next; - - /* set up command for bss segment */ - ccmdp->ev_next = new_vmcmd(vmcmd_map_zero, - execp->a_bss, - epp->ep_daddr + execp->a_data, - 0, - 0, - VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); - ccmdp = ccmdp->ev_next; - - return exec_aout_setup_stack(p, epp, ccmdp); -} - -/* - * sun_exec_aout_prep_nmagic(): Prepare a SunOS NMAGIC binary's exec package - */ - -int -sun_exec_aout_prep_nmagic(p, epp) - struct proc *p; - struct exec_package *epp; -{ - struct exec *execp = epp->ep_execp; - struct exec_vmcmd *ccmdp; - long bsize, baddr; - - epp->ep_taddr = N_TXTADDR(*execp, NMAGIC); - epp->ep_tsize = execp->a_text; - epp->ep_daddr = N_DATADDR(*execp, NMAGIC); - epp->ep_dsize = execp->a_data + execp->a_bss; - epp->ep_entry = execp->a_entry; - - /* set up command for text segment */ - epp->ep_vcp = new_vmcmd(vmcmd_map_readvn, - execp->a_text, - epp->ep_taddr, - epp->ep_vp, - N_TXTOFF(*execp, NMAGIC), - VM_PROT_READ | VM_PROT_EXECUTE); - ccmdp = epp->ep_vcp; - - /* set up command for data segment */ - ccmdp->ev_next = new_vmcmd(vmcmd_map_readvn, - execp->a_data, - epp->ep_daddr, - epp->ep_vp, - N_DATOFF(*execp, NMAGIC), - VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); - ccmdp = ccmdp->ev_next; - - /* set up command for bss segment */ - baddr = roundup(epp->ep_daddr + execp->a_data, NBPG); - bsize = epp->ep_daddr + epp->ep_dsize - baddr; - if (bsize > 0) { - ccmdp->ev_next = new_vmcmd(vmcmd_map_zero, bsize, baddr, - 0, 0, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); - ccmdp = ccmdp->ev_next; - } - - return exec_aout_setup_stack(p, epp, ccmdp); -} - -/* - * sun_exec_aout_prep_omagic(): Prepare a SunOS OMAGIC binary's exec package - */ - -int -sun_exec_aout_prep_omagic(p, epp) - struct proc *p; - struct exec_package *epp; -{ - struct exec *execp = epp->ep_execp; - struct exec_vmcmd *ccmdp; - long bsize, baddr; - - epp->ep_taddr = N_TXTADDR(*execp, OMAGIC); - epp->ep_tsize = execp->a_text; - epp->ep_daddr = N_DATADDR(*execp, OMAGIC); - epp->ep_dsize = execp->a_data + execp->a_bss; - epp->ep_entry = execp->a_entry; - - /* set up command for text and data segments */ - epp->ep_vcp = new_vmcmd(vmcmd_map_readvn, - execp->a_text + execp->a_data, - epp->ep_taddr, - epp->ep_vp, - N_TXTOFF(*execp, OMAGIC), - VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); - ccmdp = epp->ep_vcp; - - /* set up command for bss segment */ - baddr = roundup(epp->ep_daddr + execp->a_data, __LDPGSZ); - bsize = epp->ep_daddr + epp->ep_dsize - baddr; - if (bsize > 0) { - ccmdp->ev_next = new_vmcmd(vmcmd_map_zero, bsize, baddr, - 0, 0, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE); - ccmdp = ccmdp->ev_next; - } - - return exec_aout_setup_stack(p, epp, ccmdp); -} - diff --git a/sys/arch/amiga/sunos/sun_ioctl.c b/sys/arch/amiga/sunos/sun_ioctl.c deleted file mode 100644 index 324e29a7283a..000000000000 --- a/sys/arch/amiga/sunos/sun_ioctl.c +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)sun_ioctl.c 8.1 (Berkeley) 6/11/93 - * - * from: Header: sun_ioctl.c,v 1.7 93/05/28 04:40:43 torek Exp - * $Id: sun_ioctl.c,v 1.1 1993/10/30 23:42:23 mw Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include - -/* - * SunOS ioctl calls. - * This file is something of a hodge-podge. - * Support gets added as things turn up.... - */ - -struct sun_ttysize { - int ts_row; - int ts_col; -}; - -struct sun_termio { - u_short c_iflag; - u_short c_oflag; - u_short c_cflag; - u_short c_lflag; - char c_line; - unsigned char c_cc[8]; -}; -#define SUN_TCGETA _IOR('T', 1, struct sun_termio) -#define SUN_TCSETA _IOW('T', 2, struct sun_termio) -#define SUN_TCSETAW _IOW('T', 3, struct sun_termio) -#define SUN_TCSETAF _IOW('T', 4, struct sun_termio) -#define SUN_TCSBRK _IO('T', 5) - -struct sun_termios { - u_long c_iflag; - u_long c_oflag; - u_long c_cflag; - u_long c_lflag; - char c_line; - u_char c_cc[17]; -}; -#define SUN_TCXONC _IO('T', 6) -#define SUN_TCFLSH _IO('T', 7) -#define SUN_TCGETS _IOR('T', 8, struct sun_termios) -#define SUN_TCSETS _IOW('T', 9, struct sun_termios) -#define SUN_TCSETSW _IOW('T', 10, struct sun_termios) -#define SUN_TCSETSF _IOW('T', 11, struct sun_termios) -#define SUN_TCSNDBRK _IO('T', 12) -#define SUN_TCDRAIN _IO('T', 13) - -static struct speedtab sptab[] = { - { 0, 0 }, { 50, 1 }, { 75, 2 }, { 110, 3 }, - { 134, 4 }, { 135, 4 }, { 150, 5 }, { 200, 6 }, - { 300, 7 }, { 600, 8 }, { 1200, 9 }, { 1800, 10 }, - { 2400, 11 }, { 4800, 12 }, { 9600, 13 }, - { 19200, 14 }, { 38400, 15 }, { -1, -1 } -}; -static u_long s2btab[] = { - 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, - 2400, 4800, 9600, 19200, 38400, -}; - -/* these two conversion functions have mostly been done - with some perl cut&paste, then handedited to comment - out what doesn't exist under NetBSD. - Note: (l & BITMASK1) / BITMASK1 * BITMASK2 - is translated optimally by gcc m68k, much better - than any ?: stuff. Code may vary with different - architectures of course. */ - -static void -stios2btios (st, bt) - struct sun_termios *st; - struct termios *bt; -{ - register u_long l; - - l = st->c_iflag; - bt->c_iflag = ( ((l & 0x00000001) / 0x00000001 * IGNBRK) - |((l & 0x00000002) / 0x00000002 * BRKINT) - |((l & 0x00000004) / 0x00000004 * IGNPAR) - |((l & 0x00000008) / 0x00000008 * PARMRK) - |((l & 0x00000010) / 0x00000010 * INPCK) - |((l & 0x00000020) / 0x00000020 * ISTRIP) - |((l & 0x00000040) / 0x00000040 * INLCR) - |((l & 0x00000080) / 0x00000080 * IGNCR) - |((l & 0x00000100) / 0x00000100 * ICRNL) - /*|((l & 0x00000200) / 0x00000200 * IUCLC)*/ - |((l & 0x00000400) / 0x00000400 * IXON) - |((l & 0x00000800) / 0x00000800 * IXANY) - |((l & 0x00001000) / 0x00001000 * IXOFF) - |((l & 0x00002000) / 0x00002000 * IMAXBEL)); - - l = st->c_oflag; - bt->c_oflag = ( ((l & 0x00000001) / 0x00000001 * OPOST) - /*|((l & 0x00000002) / 0x00000002 * OLCUC)*/ - |((l & 0x00000004) / 0x00000004 * ONLCR) - /*|((l & 0x00000008) / 0x00000008 * OCRNL)*/ - /*|((l & 0x00000010) / 0x00000010 * ONOCR)*/ - /*|((l & 0x00000020) / 0x00000020 * ONLRET)*/ - /*|((l & 0x00000040) / 0x00000040 * OFILL)*/ - /*|((l & 0x00000080) / 0x00000080 * OFDEL)*/ - /*|((l & 0x00000100) / 0x00000100 * NLDLY)*/ - /*|((l & 0x00000100) / 0x00000100 * NL1)*/ - /*|((l & 0x00000600) / 0x00000600 * CRDLY)*/ - /*|((l & 0x00000200) / 0x00000200 * CR1)*/ - /*|((l & 0x00000400) / 0x00000400 * CR2)*/ - /*|((l & 0x00000600) / 0x00000600 * CR3)*/ - /*|((l & 0x00001800) / 0x00001800 * TABDLY)*/ - /*|((l & 0x00000800) / 0x00000800 * TAB1)*/ - /*|((l & 0x00001000) / 0x00001000 * TAB2)*/ - |((l & 0x00001800) / 0x00001800 * OXTABS) - /*|((l & 0x00002000) / 0x00002000 * BSDLY)*/ - /*|((l & 0x00002000) / 0x00002000 * BS1)*/ - /*|((l & 0x00004000) / 0x00004000 * VTDLY)*/ - /*|((l & 0x00004000) / 0x00004000 * VT1)*/ - /*|((l & 0x00008000) / 0x00008000 * FFDLY)*/ - /*|((l & 0x00008000) / 0x00008000 * FF1)*/ - /*|((l & 0x00010000) / 0x00010000 * PAGEOUT)*/ - /*|((l & 0x00020000) / 0x00020000 * WRAP)*/); - - l = st->c_cflag; - bt->c_cflag = ( ((l & 0x00000010) / 0x00000010 * CS6) - |((l & 0x00000020) / 0x00000020 * CS7) - |((l & 0x00000030) / 0x00000030 * CS8) - |((l & 0x00000040) / 0x00000040 * CSTOPB) - |((l & 0x00000080) / 0x00000080 * CREAD) - |((l & 0x00000100) / 0x00000100 * PARENB) - |((l & 0x00000200) / 0x00000200 * PARODD) - |((l & 0x00000400) / 0x00000400 * HUPCL) - |((l & 0x00000800) / 0x00000800 * CLOCAL) - /*|((l & 0x00001000) / 0x00001000 * LOBLK)*/ - |((l & 0x80000000) / 0x80000000 * (CRTS_IFLOW|CCTS_OFLOW))); - - bt->c_ispeed = bt->c_ospeed = s2btab[l & 0x0000000f]; - - l = st->c_lflag; - bt->c_lflag = ( ((l & 0x00000001) / 0x00000001 * ISIG) - |((l & 0x00000002) / 0x00000002 * ICANON) - /*|((l & 0x00000004) / 0x00000004 * XCASE)*/ - |((l & 0x00000008) / 0x00000008 * ECHO) - |((l & 0x00000010) / 0x00000010 * ECHOE) - |((l & 0x00000020) / 0x00000020 * ECHOK) - |((l & 0x00000040) / 0x00000040 * ECHONL) - |((l & 0x00000080) / 0x00000080 * NOFLSH) - |((l & 0x00000100) / 0x00000100 * TOSTOP) - |((l & 0x00000200) / 0x00000200 * ECHOCTL) - |((l & 0x00000400) / 0x00000400 * ECHOPRT) - |((l & 0x00000800) / 0x00000800 * ECHOKE) - /*|((l & 0x00001000) / 0x00001000 * DEFECHO)*/ - |((l & 0x00002000) / 0x00002000 * FLUSHO) - |((l & 0x00004000) / 0x00004000 * PENDIN)); - - bt->c_cc[VINTR] = st->c_cc[0] ? st->c_cc[0] : _POSIX_VDISABLE; - bt->c_cc[VQUIT] = st->c_cc[1] ? st->c_cc[1] : _POSIX_VDISABLE; - bt->c_cc[VERASE] = st->c_cc[2] ? st->c_cc[2] : _POSIX_VDISABLE; - bt->c_cc[VKILL] = st->c_cc[3] ? st->c_cc[3] : _POSIX_VDISABLE; - bt->c_cc[VEOF] = st->c_cc[4] ? st->c_cc[4] : _POSIX_VDISABLE; - bt->c_cc[VEOL] = st->c_cc[5] ? st->c_cc[5] : _POSIX_VDISABLE; - bt->c_cc[VEOL2] = st->c_cc[6] ? st->c_cc[6] : _POSIX_VDISABLE; - /*bt->c_cc[VSWTCH] = st->c_cc[7] ? st->c_cc[7] : _POSIX_VDISABLE;*/ - bt->c_cc[VSTART] = st->c_cc[8] ? st->c_cc[8] : _POSIX_VDISABLE; - bt->c_cc[VSTOP] = st->c_cc[9] ? st->c_cc[9] : _POSIX_VDISABLE; - bt->c_cc[VSUSP] = st->c_cc[10] ? st->c_cc[10] : _POSIX_VDISABLE; - bt->c_cc[VDSUSP] = st->c_cc[11] ? st->c_cc[11] : _POSIX_VDISABLE; - bt->c_cc[VREPRINT] = st->c_cc[12] ? st->c_cc[12] : _POSIX_VDISABLE; - bt->c_cc[VDISCARD] = st->c_cc[13] ? st->c_cc[13] : _POSIX_VDISABLE; - bt->c_cc[VWERASE] = st->c_cc[14] ? st->c_cc[14] : _POSIX_VDISABLE; - bt->c_cc[VLNEXT] = st->c_cc[15] ? st->c_cc[15] : _POSIX_VDISABLE; - bt->c_cc[VSTATUS] = st->c_cc[16] ? st->c_cc[16] : _POSIX_VDISABLE; -} - - -static void -btios2stios (bt, st) - struct termios *bt; - struct sun_termios *st; -{ - register u_long l; - - l = bt->c_iflag; - st->c_iflag = ( ((l & IGNBRK) / IGNBRK * 0x00000001) - |((l & BRKINT) / BRKINT * 0x00000002) - |((l & IGNPAR) / IGNPAR * 0x00000004) - |((l & PARMRK) / PARMRK * 0x00000008) - |((l & INPCK) / INPCK * 0x00000010) - |((l & ISTRIP) / ISTRIP * 0x00000020) - |((l & INLCR) / INLCR * 0x00000040) - |((l & IGNCR) / IGNCR * 0x00000080) - |((l & ICRNL) / ICRNL * 0x00000100) - /*|((l & IUCLC) / IUCLC * 0x00000200)*/ - |((l & IXON) / IXON * 0x00000400) - |((l & IXANY) / IXANY * 0x00000800) - |((l & IXOFF) / IXOFF * 0x00001000) - |((l & IMAXBEL) / IMAXBEL * 0x00002000)); - - l = bt->c_oflag; - st->c_oflag = ( ((l & OPOST) / OPOST * 0x00000001) - /*|((l & OLCUC) / OLCUC * 0x00000002)*/ - |((l & ONLCR) / ONLCR * 0x00000004) - /*|((l & OCRNL) / OCRNL * 0x00000008)*/ - /*|((l & ONOCR) / ONOCR * 0x00000010)*/ - /*|((l & ONLRET) / ONLRET * 0x00000020)*/ - /*|((l & OFILL) / OFILL * 0x00000040)*/ - /*|((l & OFDEL) / OFDEL * 0x00000080)*/ - /*|((l & NLDLY) / NLDLY * 0x00000100)*/ - /*|((l & NL1) / NL1 * 0x00000100)*/ - /*|((l & CRDLY) / CRDLY * 0x00000600)*/ - /*|((l & CR1) / CR1 * 0x00000200)*/ - /*|((l & CR2) / CR2 * 0x00000400)*/ - /*|((l & CR3) / CR3 * 0x00000600)*/ - /*|((l & TABDLY) / TABDLY * 0x00001800)*/ - /*|((l & TAB1) / TAB1 * 0x00000800)*/ - /*|((l & TAB2) / TAB2 * 0x00001000)*/ - |((l & OXTABS) / OXTABS * 0x00001800) - /*|((l & BSDLY) / BSDLY * 0x00002000)*/ - /*|((l & BS1) / BS1 * 0x00002000)*/ - /*|((l & VTDLY) / VTDLY * 0x00004000)*/ - /*|((l & VT1) / VT1 * 0x00004000)*/ - /*|((l & FFDLY) / FFDLY * 0x00008000)*/ - /*|((l & FF1) / FF1 * 0x00008000)*/ - /*|((l & PAGEOUT) / PAGEOUT * 0x00010000)*/ - /*|((l & WRAP) / WRAP * 0x00020000)*/); - - l = bt->c_cflag; - st->c_cflag = ( ((l & CS6) / CS6 * 0x00000010) - |((l & CS7) / CS7 * 0x00000020) - |((l & CS8) / CS8 * 0x00000030) - |((l & CSTOPB) / CSTOPB * 0x00000040) - |((l & CREAD) / CREAD * 0x00000080) - |((l & PARENB) / PARENB * 0x00000100) - |((l & PARODD) / PARODD * 0x00000200) - |((l & HUPCL) / HUPCL * 0x00000400) - |((l & CLOCAL) / CLOCAL * 0x00000800) - /*|((l & LOBLK) / LOBLK * 0x00001000)*/ - |((l & (CRTS_IFLOW|CCTS_OFLOW)) / (CRTS_IFLOW|CCTS_OFLOW) * 0x80000000)); - - l = bt->c_lflag; - st->c_lflag = ( ((l & ISIG) / ISIG * 0x00000001) - |((l & ICANON) / ICANON * 0x00000002) - /*|((l & XCASE) / XCASE * 0x00000004)*/ - |((l & ECHO) / ECHO * 0x00000008) - |((l & ECHOE) / ECHOE * 0x00000010) - |((l & ECHOK) / ECHOK * 0x00000020) - |((l & ECHONL) / ECHONL * 0x00000040) - |((l & NOFLSH) / NOFLSH * 0x00000080) - |((l & TOSTOP) / TOSTOP * 0x00000100) - |((l & ECHOCTL) / ECHOCTL * 0x00000200) - |((l & ECHOPRT) / ECHOPRT * 0x00000400) - |((l & ECHOKE) / ECHOKE * 0x00000800) - /*|((l & DEFECHO) / DEFECHO * 0x00001000)*/ - |((l & FLUSHO) / FLUSHO * 0x00002000) - |((l & PENDIN) / PENDIN * 0x00004000)); - - l = ttspeedtab (bt->c_ospeed, sptab); - if (l >= 0) - st->c_cflag |= l; - - st->c_cc[0] = bt->c_cc[VINTR] != _POSIX_VDISABLE ? bt->c_cc[VINTR] : 0; - st->c_cc[1] = bt->c_cc[VQUIT] != _POSIX_VDISABLE ? bt->c_cc[VQUIT] : 0; - st->c_cc[2] = bt->c_cc[VERASE] != _POSIX_VDISABLE ? bt->c_cc[VERASE] : 0; - st->c_cc[3] = bt->c_cc[VKILL] != _POSIX_VDISABLE ? bt->c_cc[VKILL] : 0; - st->c_cc[4] = bt->c_cc[VEOF] != _POSIX_VDISABLE ? bt->c_cc[VEOF] : 0; - st->c_cc[5] = bt->c_cc[VEOL] != _POSIX_VDISABLE ? bt->c_cc[VEOL] : 0; - st->c_cc[6] = bt->c_cc[VEOL2] != _POSIX_VDISABLE ? bt->c_cc[VEOL2] : 0; - st->c_cc[7] = /*bt->c_cc[VSWTCH] != _POSIX_VDISABLE ? bt->c_cc[VSWTCH] :*/ 0; - st->c_cc[8] = bt->c_cc[VSTART] != _POSIX_VDISABLE ? bt->c_cc[VSTART] : 0; - st->c_cc[9] = bt->c_cc[VSTOP] != _POSIX_VDISABLE ? bt->c_cc[VSTOP] : 0; - st->c_cc[10] = bt->c_cc[VSUSP] != _POSIX_VDISABLE ? bt->c_cc[VSUSP] : 0; - st->c_cc[11] = bt->c_cc[VDSUSP] != _POSIX_VDISABLE ? bt->c_cc[VDSUSP] : 0; - st->c_cc[12] = bt->c_cc[VREPRINT] != _POSIX_VDISABLE ? bt->c_cc[VREPRINT] : 0; - st->c_cc[13] = bt->c_cc[VDISCARD] != _POSIX_VDISABLE ? bt->c_cc[VDISCARD] : 0; - st->c_cc[14] = bt->c_cc[VWERASE] != _POSIX_VDISABLE ? bt->c_cc[VWERASE] : 0; - st->c_cc[15] = bt->c_cc[VLNEXT] != _POSIX_VDISABLE ? bt->c_cc[VLNEXT] : 0; - st->c_cc[16] = bt->c_cc[VSTATUS] != _POSIX_VDISABLE ? bt->c_cc[VSTATUS] : 0; - - st->c_line = 0; -} - -static void -stios2stio (ts, t) - struct sun_termios *ts; - struct sun_termio *t; -{ - t->c_iflag = ts->c_iflag; - t->c_oflag = ts->c_oflag; - t->c_cflag = ts->c_cflag; - t->c_lflag = ts->c_lflag; - t->c_line = ts->c_line; - bcopy (ts->c_cc, t->c_cc, 8); -} - -static void -stio2stios (t, ts) - struct sun_termio *t; - struct sun_termios *ts; -{ - ts->c_iflag = t->c_iflag; - ts->c_oflag = t->c_oflag; - ts->c_cflag = t->c_cflag; - ts->c_lflag = t->c_lflag; - ts->c_line = t->c_line; - bcopy (t->c_cc, ts->c_cc, 8); /* don't touch the upper fields! */ -} - - - -struct sun_ioctl_args { - int fd; - int cmd; - caddr_t data; -}; - -int -sun_ioctl(p, uap, retval) - register struct proc *p; - register struct sun_ioctl_args *uap; - int *retval; -{ - register struct filedesc *fdp = p->p_fd; - register struct file *fp; - register int (*ctl)(); - int error; - - if ((unsigned)uap->fd >= fdp->fd_nfiles - || (fp = fdp->fd_ofiles[uap->fd]) == NULL) - return (EBADF); - - if ((fp->f_flag & (FREAD|FWRITE)) == 0) - return (EBADF); - - ctl = fp->f_ops->fo_ioctl; - - switch (uap->cmd) - { - case _IOR('t', 0, int): - uap->cmd = TIOCGETD; - break; - - case _IOW('t', 1, int): - { - int disc; - - if ((error = copyin (uap->data, (caddr_t) &disc, sizeof (disc))) != 0) - return error; - - /* map SunOS NTTYDISC into our termios discipline */ - if (disc == 2) - disc = 0; - /* all other disciplines are not supported by NetBSD */ - if (disc) - return ENXIO; - - return (*ctl)(fp, TIOCSETD, (caddr_t) &disc, p); - } - - case _IO('t', 36): /* sun TIOCCONS, no parameters */ - { - int on = 1; - return (*ctl)(fp, TIOCCONS, (caddr_t)&on, p); - } - - case _IOW('t', 37, struct sun_ttysize): - { - struct winsize ws; - struct sun_ttysize ss; - - if ((error = (*ctl)(fp, TIOCGWINSZ, (caddr_t)&ws, p)) != 0) - return (error); - - if ((error = copyin (uap->data, &ss, sizeof (ss))) != 0) - return error; - - ws.ws_row = ss.ts_row; - ws.ws_col = ss.ts_col; - - return ((*ctl)(fp, TIOCSWINSZ, (caddr_t)&ws, p)); - } - - case _IOW('t', 38, struct sun_ttysize): - { - struct winsize ws; - struct sun_ttysize ss; - - if ((error = (*ctl)(fp, TIOCGWINSZ, (caddr_t) &ws, p)) != 0) - return (error); - - ss.ts_row = ws.ws_row; - ss.ts_col = ws.ws_col; - - return copyout ((caddr_t) &ss, uap->data, sizeof (ss)); - } - - case _IOR('t', 130, int): - uap->cmd = TIOCSPGRP; - break; - - case _IOR('t', 131, int): - uap->cmd = TIOCGPGRP; - break; - - case _IO('t', 132): - uap->cmd = TIOCSCTTY; - break; - - case SUN_TCGETA: - case SUN_TCGETS: - { - struct termios bts; - struct sun_termios sts; - struct sun_termio st; - - if ((error = (*ctl)(fp, TIOCGETA, (caddr_t) &bts, p)) != 0) - return error; - - btios2stios (&bts, &sts); - if (uap->cmd == SUN_TCGETA) - { - stios2stio (&sts, &st); - return copyout ((caddr_t) &st, uap->data, sizeof (st)); - } - else - return copyout ((caddr_t) &sts, uap->data, sizeof (sts)); - /* not reached */ - - } - - case SUN_TCSETA: - case SUN_TCSETAW: - case SUN_TCSETAF: - { - struct termios bts; - struct sun_termios sts; - struct sun_termio st; - - if ((error = copyin (uap->data, (caddr_t) &st, sizeof (st))) != 0) - return error; - - /* get full BSD termios so we don't lose information */ - if ((error = (*ctl)(fp, TIOCGETA, (caddr_t) &bts, p)) != 0) - return error; - - /* convert to sun termios, copy in information from termio, and - convert back, then set new values. */ - btios2stios (&bts, &sts); - stio2stios (&st, &sts); - stios2btios (&sts, &bts); - - return (*ctl)(fp, uap->cmd - SUN_TCSETA + TIOCSETA, (caddr_t) &bts, p); - } - - case SUN_TCSETS: - case SUN_TCSETSW: - case SUN_TCSETSF: - { - struct termios bts; - struct sun_termios sts; - - if ((error = copyin (uap->data, (caddr_t) &sts, sizeof (sts))) != 0) - return error; - - stios2btios (&sts, &bts); - - return (*ctl)(fp, uap->cmd - SUN_TCSETS + TIOCSETA, (caddr_t) &bts, p); - } - - } - - return (ioctl(p, uap, retval)); -} diff --git a/sys/arch/amiga/sunos/sun_misc.c b/sys/arch/amiga/sunos/sun_misc.c deleted file mode 100644 index df66cc11b690..000000000000 --- a/sys/arch/amiga/sunos/sun_misc.c +++ /dev/null @@ -1,566 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)sun_misc.c 8.1 (Berkeley) 6/18/93 - * - * from: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp - * $Id: sun_misc.c,v 1.1 1993/10/30 23:42:25 mw Exp $ - */ - -/* - * SunOS compatibility module. - * - * SunOS system calls that are implemented differently in BSD are - * handled here. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -struct sun_wait4_args { - int pid; - int *status; - int options; - struct rusage *rusage; -}; -sun_wait4(p, uap, retval) - struct proc *p; - struct sun_wait4_args *uap; - int *retval; -{ - - if (uap->pid == 0) - uap->pid = WAIT_ANY; - return (wait4(p, uap, retval)); -} - -struct sun_creat_args { - char *fname; - int fmode; -}; -sun_creat(p, uap, retval) - struct proc *p; - struct sun_creat_args *uap; - int *retval; -{ - struct args { - char *fname; - int mode; - int crtmode; - } openuap; - - openuap.fname = uap->fname; - openuap.crtmode = uap->fmode; - openuap.mode = O_WRONLY | O_CREAT | O_TRUNC; - return (open(p, &openuap, retval)); -} - -struct sun_execv_args { - char *fname; - char **argp; - char **envp; /* pseudo */ -}; -sun_execv(p, uap, retval) - struct proc *p; - struct sun_execv_args *uap; - int *retval; -{ - - uap->envp = NULL; - return (sun_execve(p, uap, retval)); -} - -struct sun_omsync_args { - caddr_t addr; - int len; - int flags; -}; -sun_omsync(p, uap, retval) - struct proc *p; - struct sun_omsync_args *uap; - int *retval; -{ - - if (uap->flags) - return (EINVAL); - return (msync(p, uap, retval)); -} - -struct sun_unmount_args { - char *name; - int flags; /* pseudo */ -}; -sun_unmount(p, uap, retval) - struct proc *p; - struct sun_unmount_args *uap; - int *retval; -{ - - uap->flags = 0; - return (unmount(p, uap, retval)); -} - -static int -gettype(tptr) - int *tptr; -{ - int type, error; - char in[20]; - - if (error = copyinstr((caddr_t)*tptr, in, sizeof in, (u_int *)0)) - return (error); - if (strcmp(in, "4.2") == 0 || strcmp(in, "ufs") == 0) - type = MOUNT_UFS; - else if (strcmp(in, "nfs") == 0) - type = MOUNT_NFS; - else - return (EINVAL); - *tptr = type; - return (0); -} - -#define SUNM_RDONLY 0x01 /* mount fs read-only */ -#define SUNM_NOSUID 0x02 /* mount fs with setuid disallowed */ -#define SUNM_NEWTYPE 0x04 /* type is string (char *), not int */ -#define SUNM_GRPID 0x08 /* (bsd semantics; ignored) */ -#define SUNM_REMOUNT 0x10 /* update existing mount */ -#define SUNM_NOSUB 0x20 /* prevent submounts (rejected) */ -#define SUNM_MULTI 0x40 /* (ignored) */ -#define SUNM_SYS5 0x80 /* Sys 5-specific semantics (rejected) */ - -struct sun_mount_args { - int type; - char *dir; - int flags; - caddr_t data; -}; -sun_mount(p, uap, retval) - struct proc *p; - struct sun_mount_args *uap; - int *retval; -{ - int oflags = uap->flags, nflags, error; - - if (oflags & (SUNM_NOSUB | SUNM_SYS5)) - return (EINVAL); - if (oflags & SUNM_NEWTYPE && (error = gettype(&uap->type))) - return (error); - nflags = 0; - if (oflags & SUNM_RDONLY) - nflags |= MNT_RDONLY; - if (oflags & SUNM_NOSUID) - nflags |= MNT_NOSUID; - if (oflags & SUNM_REMOUNT) - nflags |= MNT_UPDATE; - uap->flags = nflags; - return (mount(p, uap, retval)); -} - -struct sun_sigpending_args { - int *mask; -}; -sun_sigpending(p, uap, retval) - struct proc *p; - struct sun_sigpending_args *uap; - int *retval; -{ - int mask = p->p_sig & p->p_sigmask; - - return (copyout((caddr_t)&mask, (caddr_t)uap->mask, sizeof(int))); -} - -/* TDR: Temporary until sys/dir.h, include/dirent.h and sys/dirent.h are fixed */ -struct dirent { - u_long d_fileno; /* file number of entry */ - u_short d_reclen; /* length of this record */ - u_short d_namlen; /* length of string in d_name */ - char d_name[255 + 1]; /* name must be no longer than this */ -}; - -/* - * Here is the sun layout. (Compare the BSD layout in .) - * We can assume big-endian, so the BSD d_type field is just the high - * byte of the SunOS d_namlen field, after adjusting for the extra "long". - */ -struct sun_dirent { - long d_off; - u_long d_fileno; - u_short d_reclen; - u_short d_namlen; - char d_name[256]; -}; - -/* - * Read Sun-style directory entries. We suck them into kernel space so - * that they can be massaged before being copied out to user code. Like - * SunOS, we squish out `empty' entries. - * - * This is quite ugly, but what do you expect from compatibility code? - */ -struct sun_getdents_args { - int fd; - char *buf; - int nbytes; -}; -sun_getdents(p, uap, retval) - struct proc *p; - register struct sun_getdents_args *uap; - int *retval; -{ - register struct vnode *vp; - register caddr_t inp, buf; /* BSD-format */ - register int len, reclen; /* BSD-format */ - register caddr_t outp; /* Sun-format */ - register int resid; /* Sun-format */ - struct file *fp; - struct uio auio; - struct iovec aiov; - off_t off; /* true file offset */ - long soff; /* Sun file offset */ - int buflen, error, eofflag; -#define BSD_DIRENT(cp) ((struct dirent *)(cp)) -#define SUN_RECLEN(reclen) (reclen + sizeof(long)) - - if ((error = getvnode(p->p_fd, uap->fd, &fp)) != 0) - return (error); - if ((fp->f_flag & FREAD) == 0) - return (EBADF); - vp = (struct vnode *)fp->f_data; - if (vp->v_type != VDIR) /* XXX vnode readdir op should do this */ - return (EINVAL); - buflen = min(MAXBSIZE, uap->nbytes); - buf = malloc(buflen, M_TEMP, M_WAITOK); - VOP_LOCK(vp); - off = fp->f_offset; -again: - aiov.iov_base = buf; - aiov.iov_len = buflen; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_rw = UIO_READ; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = p; - auio.uio_resid = buflen; - auio.uio_offset = off; - /* - * First we read into the malloc'ed buffer, then - * we massage it into user space, one record at a time. - */ - if (error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, NULL, 0)) - goto out; - inp = buf; - outp = uap->buf; - resid = uap->nbytes; - if ((len = buflen - auio.uio_resid) == 0) - goto eof; - for (; len > 0; len -= reclen) { - reclen = ((struct dirent *)inp)->d_reclen; - if (reclen & 3) - panic("sun_getdents"); - off += reclen; /* each entry points to next */ - if (BSD_DIRENT(inp)->d_fileno == 0) { - inp += reclen; /* it is a hole; squish it out */ - continue; - } - if (reclen > len || resid < SUN_RECLEN(reclen)) { - /* entry too big for buffer, so just stop */ - outp++; - break; - } - /* - * Massage in place to make a Sun-shaped dirent (otherwise - * we have to worry about touching user memory outside of - * the copyout() call). - */ - BSD_DIRENT(inp)->d_reclen = SUN_RECLEN(reclen); -#if notdef - BSD_DIRENT(inp)->d_type = 0; /* 4.4 specific */ -#endif - soff = off; - if ((error = copyout((caddr_t)&soff, outp, sizeof soff)) != 0 || - (error = copyout(inp, outp + sizeof soff, reclen)) != 0) - goto out; - /* advance past this real entry */ - inp += reclen; - /* advance output past Sun-shaped entry */ - outp += SUN_RECLEN(reclen); - resid -= SUN_RECLEN(reclen); - } - /* if we squished out the whole block, try again */ - if (outp == uap->buf) - goto again; - fp->f_offset = off; /* update the vnode offset */ -eof: - *retval = uap->nbytes - resid; -out: - VOP_UNLOCK(vp); - free(buf, M_TEMP); - return (error); -} - -/* - * The Sun bit-style arguments are not in the same order as the - * NetBSD ones. We must remap them the bits. - */ - -#define DEVZERO makedev(2, 12) /* major,minor of /dev/zero */ - -#define SUN_PROT_READ 1 -#define SUN_PROT_WRITE 2 -#define SUN_PROT_EXEC 4 -#define SUN_PROT_UALL (SUN_PROT_READ | SUN_PROT_WRITE | SUN_PROT_EXEC) - -#define SUN__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */ - -#define SUN_MAP_SHARED 1 -#define SUN_MAP_PRIVATE 2 -#define SUN_MAP_TYPE 0xf -#define SUN_MAP_FIXED 0x10 - -struct sun_mmap_args { - caddr_t addr; - size_t len; - int prot; - int flags; - int fd; - off_t off; -}; -sun_mmap(p, uap, retval) - register struct proc *p; - register struct sun_mmap_args *uap; - int *retval; -{ - register int flags, prot, newflags, newprot; - register struct filedesc *fdp; - register struct file *fp; - register struct vnode *vp; - - /* - * Verify and re-map the arguments. - */ - prot = uap->prot; - newprot = 0; - if (uap->prot & ~SUN_PROT_UALL) - return (EINVAL); - if (uap->prot & SUN_PROT_READ) - newprot |= PROT_READ; - if (uap->prot & SUN_PROT_WRITE) - newprot |= PROT_WRITE; - if (uap->prot & SUN_PROT_EXEC) - newprot |= PROT_EXEC; - - flags = uap->flags; - newflags = 0; - if ((flags & SUN__MAP_NEW) == 0) - return (EINVAL); - - switch (flags & SUN_MAP_TYPE) { - case SUN_MAP_SHARED: - newflags |= MAP_SHARED; - break; - case SUN_MAP_PRIVATE: - newflags |= MAP_PRIVATE; - break; - default: - return (EINVAL); - } - - if (flags & SUN_MAP_FIXED) - newflags |= MAP_FIXED; - - /* - * Special case: if fd refers to /dev/zero, map as MAP_ANON. (XXX) - */ - fdp = p->p_fd; - if ((unsigned)uap->fd < fdp->fd_nfiles && /*XXX*/ - (fp = fdp->fd_ofiles[uap->fd]) != NULL && /*XXX*/ - fp->f_type == DTYPE_VNODE && /*XXX*/ - (vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/ - vp->v_rdev == DEVZERO) { /*XXX*/ - newflags |= MAP_ANON; - uap->fd = -1; - } else - newflags |= MAP_FILE; - - /* All done, fix up fields and go. */ - uap->flags = newflags; - uap->prot = newprot; - return (smmap(p, uap, retval)); -} - -#define MC_SYNC 1 -#define MC_LOCK 2 -#define MC_UNLOCK 3 -#define MC_ADVISE 4 -#define MC_LOCKAS 5 -#define MC_UNLOCKAS 6 - -struct sun_mctl_args { - caddr_t addr; - size_t len; - int func; - void *arg; -}; -sun_mctl(p, uap, retval) - register struct proc *p; - register struct sun_mctl_args *uap; - int *retval; -{ - - switch (uap->func) { - - case MC_ADVISE: /* ignore for now */ - return (0); - - case MC_SYNC: /* translate to msync */ - return (msync(p, uap, retval)); - - default: - return (EINVAL); - } -} - -struct sun_setsockopt_args { - int s; - int level; - int name; - caddr_t val; - int valsize; -}; -sun_setsockopt(p, uap, retval) - struct proc *p; - register struct sun_setsockopt_args *uap; - int *retval; -{ - struct file *fp; - struct mbuf *m = NULL; - int error; - - if (error = getsock(p->p_fd, uap->s, &fp)) - return (error); -#define SO_DONTLINGER (~SO_LINGER) - if (uap->name == SO_DONTLINGER) { - m = m_get(M_WAIT, MT_SOOPTS); - if (m == NULL) - return (ENOBUFS); - mtod(m, struct linger *)->l_onoff = 0; - m->m_len = sizeof(struct linger); - return (sosetopt((struct socket *)fp->f_data, uap->level, - SO_LINGER, m)); - } - if (uap->valsize > MLEN) - return (EINVAL); - if (uap->val) { - m = m_get(M_WAIT, MT_SOOPTS); - if (m == NULL) - return (ENOBUFS); - if (error = copyin(uap->val, mtod(m, caddr_t), - (u_int)uap->valsize)) { - (void) m_free(m); - return (error); - } - m->m_len = uap->valsize; - } - return (sosetopt((struct socket *)fp->f_data, uap->level, - uap->name, m)); -} - -struct sun_fchroot_args { - int fdes; -}; -sun_fchroot(p, uap, retval) - register struct proc *p; - register struct sun_fchroot_args *uap; - int *retval; -{ - register struct filedesc *fdp = p->p_fd; - register struct vnode *vp; - struct file *fp; - int error; - - if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) - return (error); - if ((error = getvnode(fdp, uap->fdes, &fp)) != 0) - return (error); - vp = (struct vnode *)fp->f_data; - VOP_LOCK(vp); - if (vp->v_type != VDIR) - error = ENOTDIR; - else - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); - VOP_UNLOCK(vp); - if (error) - return (error); - VREF(vp); - if (fdp->fd_rdir != NULL) - vrele(fdp->fd_rdir); - fdp->fd_rdir = vp; - return (0); -} - -/* - * XXX: This needs cleaning up. - */ -auditsys(...) -{ - return 0; -} diff --git a/sys/arch/amiga/sunos/sun_syscall.h b/sys/arch/amiga/sunos/sun_syscall.h deleted file mode 100644 index 45f0da53e630..000000000000 --- a/sys/arch/amiga/sunos/sun_syscall.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * System call numbers. - * - * DO NOT EDIT-- this file is automatically generated. - * created from $Id: sun_syscall.h,v 1.1 1993/10/30 23:42:26 mw Exp $ - */ - -#define SYS_exit 1 -#define SYS_fork 2 -#define SYS_read 3 -#define SYS_write 4 -#define SYS_open 5 -#define SYS_close 6 -#define SYS_sun_wait4 7 -#define SYS_sun_creat 8 -#define SYS_link 9 -#define SYS_unlink 10 -#define SYS_sun_execv 11 -#define SYS_chdir 12 - /* 13 is old sun_time */ -#define SYS_mknod 14 -#define SYS_chmod 15 -#define SYS_chown 16 -#define SYS_break 17 - /* 18 is old sun_stat */ -#define SYS_lseek 19 -#define SYS_getpid 20 - /* 21 is obsolete sun_old_mount */ - /* 23 is old setuid */ -#define SYS_getuid 24 - /* 25 is old sun_stime */ - /* 27 is old sun_alarm */ - /* 28 is old sun_fstat */ - /* 29 is old sun_pause */ - /* 30 is old sun_utime */ -#define SYS_access 33 - /* 34 is old sun_nice */ - /* 35 is old sun_ftime */ -#define SYS_sync 36 -#define SYS_kill 37 -#define SYS_stat 38 - /* 39 is old sun_setpgrp */ -#define SYS_lstat 40 -#define SYS_dup 41 -#define SYS_pipe 42 - /* 43 is old sun_times */ -#define SYS_profil 44 - /* 46 is old sun_setgid */ -#define SYS_getgid 47 - /* 48 is old sun_ssig */ -#define SYS_acct 51 -#define SYS_sun_mctl 53 -#define SYS_sun_ioctl 54 -#define SYS_reboot 55 - /* 56 is obsolete sun_owait3 */ -#define SYS_symlink 57 -#define SYS_readlink 58 -#define SYS_sun_execve 59 -#define SYS_umask 60 -#define SYS_chroot 61 -#define SYS_fstat 62 -#define SYS_getpagesize 64 -#define SYS_sun_omsync 65 -#define SYS_vfork 66 - /* 67 is obsolete vread */ - /* 68 is obsolete vwrite */ -#define SYS_sbrk 69 -#define SYS_sstk 70 -#define SYS_mmap 71 -#define SYS_vadvise 72 -#define SYS_munmap 73 -#define SYS_mprotect 74 -#define SYS_madvise 75 - /* 76 is old vhangup */ - /* 77 is old vlimit */ -#define SYS_mincore 78 -#define SYS_getgroups 79 -#define SYS_setgroups 80 -#define SYS_getpgrp 81 -#define SYS_setpgid 82 -#define SYS_setitimer 83 - /* 84 is old wait */ -#define SYS_swapon 85 -#define SYS_getitimer 86 -#define SYS_gethostname 87 -#define SYS_sethostname 88 -#define SYS_getdtablesize 89 -#define SYS_dup2 90 -#define SYS_fcntl 92 -#define SYS_select 93 -#define SYS_fsync 95 -#define SYS_setpriority 96 -#define SYS_socket 97 -#define SYS_connect 98 -#define SYS_oaccept 99 -#define SYS_getpriority 100 -#define SYS_osend 101 -#define SYS_orecv 102 -#define SYS_bind 104 -#define SYS_sun_setsockopt 105 -#define SYS_listen 106 - /* 107 is old vtimes */ -#define SYS_osigvec 108 -#define SYS_osigblock 109 -#define SYS_osigsetmask 110 -#define SYS_sigsuspend 111 -#define SYS_sigstack 112 -#define SYS_orecvmsg 113 -#define SYS_osendmsg 114 - /* 115 is obsolete vtrace */ -#define SYS_gettimeofday 116 -#define SYS_getrusage 117 -#define SYS_getsockopt 118 -#define SYS_readv 120 -#define SYS_writev 121 -#define SYS_settimeofday 122 -#define SYS_fchown 123 -#define SYS_fchmod 124 -#define SYS_orecvfrom 125 -#define SYS_osetreuid 126 -#define SYS_osetregid 127 -#define SYS_rename 128 -#define SYS_truncate 129 -#define SYS_ftruncate 130 -#define SYS_flock 131 -#define SYS_sendto 133 -#define SYS_shutdown 134 -#define SYS_socketpair 135 -#define SYS_mkdir 136 -#define SYS_rmdir 137 -#define SYS_utimes 138 -#define SYS_sun_sigreturn 139 -#define SYS_adjtime 140 -#define SYS_ogetpeername 141 -#define SYS_gethostid 142 -#define SYS_getrlimit 144 -#define SYS_setrlimit 145 -#define SYS_okillpg 146 -#define SYS_ogetsockname 150 -#define SYS_getdirentries 156 -#define SYS_statfs 157 -#define SYS_fstatfs 158 -#define SYS_sun_unmount 159 -#define SYS_getdomainname 162 -#define SYS_setdomainname 163 -#define SYS_sun_mount 167 -#define SYS_shmsys 171 -#define SYS_auditsys 172 -#define SYS_sun_getdents 174 -#define SYS_setsid 175 -#define SYS_fchdir 176 -#define SYS_sun_fchroot 177 -#define SYS_sun_sigpending 183 -#define SYS_setpgid 185 diff --git a/sys/arch/amiga/sunos/sun_syscalls.c b/sys/arch/amiga/sunos/sun_syscalls.c deleted file mode 100644 index 916355a898fe..000000000000 --- a/sys/arch/amiga/sunos/sun_syscalls.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * System call names. - * - * DO NOT EDIT-- this file is automatically generated. - * created from $Id: sun_syscalls.c,v 1.1 1993/10/30 23:42:26 mw Exp $ - */ - -char *sun_syscallnames[] = { - "#0", /* 0 = nosys syscall */ - "exit", /* 1 = exit */ - "fork", /* 2 = fork */ - "read", /* 3 = read */ - "write", /* 4 = write */ - "open", /* 5 = open */ - "close", /* 6 = close */ - "sun_wait4", /* 7 = sun_wait4 */ - "sun_creat", /* 8 = sun_creat */ - "link", /* 9 = link */ - "unlink", /* 10 = unlink */ - "sun_execv", /* 11 = sun_execv */ - "chdir", /* 12 = chdir */ - "old.sun_time", /* 13 = old sun_time */ - "mknod", /* 14 = mknod */ - "chmod", /* 15 = chmod */ - "chown", /* 16 = chown */ - "break", /* 17 = break */ - "old.sun_stat", /* 18 = old sun_stat */ - "lseek", /* 19 = lseek */ - "getpid", /* 20 = getpid */ - "obs_sun_old_mount", /* 21 = obsolete sun_old_mount */ - "#22", /* 22 = System V umount */ - "old.setuid", /* 23 = old setuid */ - "getuid", /* 24 = getuid */ - "old.sun_stime", /* 25 = old sun_stime */ - "#26", /* 26 = sun_ptrace */ - "old.sun_alarm", /* 27 = old sun_alarm */ - "old.sun_fstat", /* 28 = old sun_fstat */ - "old.sun_pause", /* 29 = old sun_pause */ - "old.sun_utime", /* 30 = old sun_utime */ - "#31", /* 31 = was stty */ - "#32", /* 32 = was gtty */ - "access", /* 33 = access */ - "old.sun_nice", /* 34 = old sun_nice */ - "old.sun_ftime", /* 35 = old sun_ftime */ - "sync", /* 36 = sync */ - "kill", /* 37 = kill */ - "stat", /* 38 = stat */ - "old.sun_setpgrp", /* 39 = old sun_setpgrp */ - "lstat", /* 40 = lstat */ - "dup", /* 41 = dup */ - "pipe", /* 42 = pipe */ - "old.sun_times", /* 43 = old sun_times */ - "profil", /* 44 = profil */ - "#45", /* 45 = nosys */ - "old.sun_setgid", /* 46 = old sun_setgid */ - "getgid", /* 47 = getgid */ - "old.sun_ssig", /* 48 = old sun_ssig */ - "#49", /* 49 = reserved for USG */ - "#50", /* 50 = reserved for USG */ - "acct", /* 51 = acct */ - "#52", /* 52 = nosys */ - "sun_mctl", /* 53 = sun_mctl */ - "sun_ioctl", /* 54 = sun_ioctl */ - "reboot", /* 55 = reboot */ - "obs_sun_owait3", /* 56 = obsolete sun_owait3 */ - "symlink", /* 57 = symlink */ - "readlink", /* 58 = readlink */ - "sun_execve", /* 59 = sun_execve */ - "umask", /* 60 = umask */ - "chroot", /* 61 = chroot */ - "fstat", /* 62 = fstat */ - "#63", /* 63 = nosys */ - "getpagesize", /* 64 = getpagesize */ - "sun_omsync", /* 65 = sun_omsync */ - "vfork", /* 66 = vfork */ - "obs_vread", /* 67 = obsolete vread */ - "obs_vwrite", /* 68 = obsolete vwrite */ - "sbrk", /* 69 = sbrk */ - "sstk", /* 70 = sstk */ - "mmap", /* 71 = mmap */ - "vadvise", /* 72 = vadvise */ - "munmap", /* 73 = munmap */ - "mprotect", /* 74 = mprotect */ - "madvise", /* 75 = madvise */ - "old.vhangup", /* 76 = old vhangup */ - "old.vlimit", /* 77 = old vlimit */ - "mincore", /* 78 = mincore */ - "getgroups", /* 79 = getgroups */ - "setgroups", /* 80 = setgroups */ - "getpgrp", /* 81 = getpgrp */ - "setpgid", /* 82 = setpgid */ - "setitimer", /* 83 = setitimer */ - "old.wait", /* 84 = old wait */ - "swapon", /* 85 = swapon */ - "getitimer", /* 86 = getitimer */ - "gethostname", /* 87 = gethostname */ - "sethostname", /* 88 = sethostname */ - "getdtablesize", /* 89 = getdtablesize */ - "dup2", /* 90 = dup2 */ - "#91", /* 91 = getdopt */ - "fcntl", /* 92 = fcntl */ - "select", /* 93 = select */ - "#94", /* 94 = setdopt */ - "fsync", /* 95 = fsync */ - "setpriority", /* 96 = setpriority */ - "socket", /* 97 = socket */ - "connect", /* 98 = connect */ - "oaccept", /* 99 = oaccept */ - "getpriority", /* 100 = getpriority */ - "osend", /* 101 = osend */ - "orecv", /* 102 = orecv */ - "#103", /* 103 = old socketaddr */ - "bind", /* 104 = bind */ - "sun_setsockopt", /* 105 = sun_setsockopt */ - "listen", /* 106 = listen */ - "old.vtimes", /* 107 = old vtimes */ - "osigvec", /* 108 = osigvec */ - "osigblock", /* 109 = osigblock */ - "osigsetmask", /* 110 = osigsetmask */ - "sigsuspend", /* 111 = sigsuspend */ - "sigstack", /* 112 = sigstack */ - "orecvmsg", /* 113 = orecvmsg */ - "osendmsg", /* 114 = osendmsg */ - "obs_vtrace", /* 115 = obsolete vtrace */ - "gettimeofday", /* 116 = gettimeofday */ - "getrusage", /* 117 = getrusage */ - "getsockopt", /* 118 = getsockopt */ - "#119", /* 119 = nosys */ - "readv", /* 120 = readv */ - "writev", /* 121 = writev */ - "settimeofday", /* 122 = settimeofday */ - "fchown", /* 123 = fchown */ - "fchmod", /* 124 = fchmod */ - "orecvfrom", /* 125 = orecvfrom */ - "osetreuid", /* 126 = osetreuid */ - "osetregid", /* 127 = osetregid */ - "rename", /* 128 = rename */ - "truncate", /* 129 = truncate */ - "ftruncate", /* 130 = ftruncate */ - "flock", /* 131 = flock */ - "#132", /* 132 = nosys */ - "sendto", /* 133 = sendto */ - "shutdown", /* 134 = shutdown */ - "socketpair", /* 135 = socketpair */ - "mkdir", /* 136 = mkdir */ - "rmdir", /* 137 = rmdir */ - "utimes", /* 138 = utimes */ - "sun_sigreturn", /* 139 = sun_sigreturn */ - "adjtime", /* 140 = adjtime */ - "ogetpeername", /* 141 = ogetpeername */ - "gethostid", /* 142 = gethostid */ - "#143", /* 143 = old sethostid */ - "getrlimit", /* 144 = getrlimit */ - "setrlimit", /* 145 = setrlimit */ - "okillpg", /* 146 = okillpg */ - "#147", /* 147 = nosys */ - "#148", /* 148 = nosys */ - "#149", /* 149 = nosys */ - "ogetsockname", /* 150 = ogetsockname */ - "#151", /* 151 = getmsg */ - "#152", /* 152 = putmsg */ - "#153", /* 153 = poll */ - "#154", /* 154 = nosys */ - "#155", /* 155 = nosys */ - "getdirentries", /* 156 = getdirentries */ - "statfs", /* 157 = statfs */ - "fstatfs", /* 158 = fstatfs */ - "sun_unmount", /* 159 = sun_unmount */ - "#160", /* 160 = nosys */ - "#161", /* 161 = nosys */ - "getdomainname", /* 162 = getdomainname */ - "setdomainname", /* 163 = setdomainname */ - "#164", /* 164 = rtschedule */ - "#165", /* 165 = quotactl */ - "#166", /* 166 = exportfs */ - "sun_mount", /* 167 = sun_mount */ - "#168", /* 168 = ustat */ - "#169", /* 169 = semsys */ - "#170", /* 170 = msgsys */ -#ifdef SYSVSHM - "shmsys", /* 171 = shmsys */ -#else - "#171", /* 171 = nosys */ -#endif - "auditsys", /* 172 = auditsys */ - "#173", /* 173 = rfssys */ - "sun_getdents", /* 174 = sun_getdents */ - "setsid", /* 175 = setsid */ - "fchdir", /* 176 = fchdir */ - "sun_fchroot", /* 177 = sun_fchroot */ - "#178", /* 178 = nosys */ - "#179", /* 179 = nosys */ - "#180", /* 180 = nosys */ - "#181", /* 181 = nosys */ - "#182", /* 182 = nosys */ - "sun_sigpending", /* 183 = sun_sigpending */ - "#184", /* 184 = nosys */ - "setpgid", /* 185 = setpgid */ - "#186", /* 186 = pathconf */ - "#187", /* 187 = fpathconf */ - "#188", /* 188 = sysconf */ - "#189", /* 189 = uname */ -}; diff --git a/sys/arch/amiga/sunos/sun_sysent.c b/sys/arch/amiga/sunos/sun_sysent.c deleted file mode 100644 index 625371ba41c2..000000000000 --- a/sys/arch/amiga/sunos/sun_sysent.c +++ /dev/null @@ -1,367 +0,0 @@ -/* - * System call switch table. - * - * DO NOT EDIT-- this file is automatically generated. - * created from $Id: sun_sysent.c,v 1.1 1993/10/30 23:42:28 mw Exp $ - */ - -#include -#include - -int nosys(); - -int rexit(); -int fork(); -int read(); -int write(); -int open(); -int close(); -int sun_wait4(); -int sun_creat(); -int link(); -int unlink(); -int sun_execv(); -int chdir(); -int mknod(); -int chmod(); -int chown(); -int obreak(); -int lseek(); -int getpid(); -int getuid(); -int saccess(); -int sync(); -int kill(); -int stat(); -int lstat(); -int dup(); -int pipe(); -int profil(); -int getgid(); -int sysacct(); -int sun_mctl(); -int sun_ioctl(); -int reboot(); -int symlink(); -int readlink(); -int sun_execve(); -int umask(); -int chroot(); -int fstat(); -int getpagesize(); -int sun_omsync(); -int vfork(); -int sbrk(); -int sstk(); -int sun_mmap(); -int ovadvise(); -int munmap(); -int mprotect(); -int madvise(); -int mincore(); -int getgroups(); -int setgroups(); -int getpgrp(); -int setpgid(); -int setitimer(); -int swapon(); -int getitimer(); -int gethostname(); -int sethostname(); -int getdtablesize(); -int dup2(); -int fcntl(); -int select(); -int fsync(); -int setpriority(); -int socket(); -int connect(); -int oaccept(); -int getpriority(); -int osend(); -int orecv(); -int bind(); -int sun_setsockopt(); -int listen(); -int osigvec(); -int osigblock(); -int osigsetmask(); -int sigsuspend(); -int sigstack(); -int orecvmsg(); -int osendmsg(); -int gettimeofday(); -int getrusage(); -int getsockopt(); -int readv(); -int writev(); -int settimeofday(); -int fchown(); -int fchmod(); -int orecvfrom(); -int osetreuid(); -int osetregid(); -int rename(); -int truncate(); -int ftruncate(); -int flock(); -int sendto(); -int shutdown(); -int socketpair(); -int mkdir(); -int rmdir(); -int utimes(); -int sun_sigreturn(); -int adjtime(); -int ogetpeername(); -int gethostid(); -int getrlimit(); -int setrlimit(); -int okillpg(); -int ogetsockname(); -int getdirentries(); -int statfs(); -int fstatfs(); -int sun_unmount(); -int getdomainname(); -int setdomainname(); -int sun_mount(); -#ifdef SYSVSHM -int shmsys(); -#else -#endif -int auditsys(); -int sun_getdents(); -int setsid(); -int fchdir(); -int sun_fchroot(); -int sun_sigpending(); -int setpgid(); - -#ifdef XXX_UNUSED -#define compat(n, name) n, __CONCAT(o,name) - -int osun_time(); -int osun_stat(); -int osetuid(); -int osun_stime(); -int osun_alarm(); -int osun_fstat(); -int osun_pause(); -int osun_utime(); -int osun_nice(); -int osun_ftime(); -int osun_setpgrp(); -int osun_times(); -int osun_setgid(); -int osun_ssig(); -int ovhangup(); -int ovlimit(); -int owait(); -int ovtimes(); -#ifdef SYSVSHM -#else -#endif - -#else /* XXX_UNUSED */ -#define compat(n, name) 0, nosys -#endif /* XXX_UNUSED */ - -struct sysent sun_sysent[] = { - { 0, nosys }, /* 0 = nosys syscall */ - { 1, rexit }, /* 1 = exit */ - { 0, fork }, /* 2 = fork */ - { 3, read }, /* 3 = read */ - { 3, write }, /* 4 = write */ - { 3, open }, /* 5 = open */ - { 1, close }, /* 6 = close */ - { 4, sun_wait4 }, /* 7 = sun_wait4 */ - { 2, sun_creat }, /* 8 = sun_creat */ - { 2, link }, /* 9 = link */ - { 1, unlink }, /* 10 = unlink */ - { 2, sun_execv }, /* 11 = sun_execv */ - { 1, chdir }, /* 12 = chdir */ - { compat(0,sun_time) }, /* 13 = old sun_time */ - { 3, mknod }, /* 14 = mknod */ - { 2, chmod }, /* 15 = chmod */ - { 3, chown }, /* 16 = chown */ - { 1, obreak }, /* 17 = break */ - { compat(2,sun_stat) }, /* 18 = old sun_stat */ - { 3, lseek }, /* 19 = lseek */ - { 0, getpid }, /* 20 = getpid */ - { 0, nosys }, /* 21 = obsolete sun_old_mount */ - { 0, nosys }, /* 22 = System V umount */ - { compat(1,setuid) }, /* 23 = old setuid */ - { 0, getuid }, /* 24 = getuid */ - { compat(1,sun_stime) }, /* 25 = old sun_stime */ - { 0, nosys }, /* 26 = sun_ptrace */ - { compat(1,sun_alarm) }, /* 27 = old sun_alarm */ - { compat(1,sun_fstat) }, /* 28 = old sun_fstat */ - { compat(0,sun_pause) }, /* 29 = old sun_pause */ - { compat(2,sun_utime) }, /* 30 = old sun_utime */ - { 0, nosys }, /* 31 = was stty */ - { 0, nosys }, /* 32 = was gtty */ - { 2, saccess }, /* 33 = access */ - { compat(1,sun_nice) }, /* 34 = old sun_nice */ - { compat(1,sun_ftime) }, /* 35 = old sun_ftime */ - { 0, sync }, /* 36 = sync */ - { 2, kill }, /* 37 = kill */ - { 2, stat }, /* 38 = stat */ - { compat(2,sun_setpgrp) }, /* 39 = old sun_setpgrp */ - { 2, lstat }, /* 40 = lstat */ - { 2, dup }, /* 41 = dup */ - { 0, pipe }, /* 42 = pipe */ - { compat(1,sun_times) }, /* 43 = old sun_times */ - { 4, profil }, /* 44 = profil */ - { 0, nosys }, /* 45 = nosys */ - { compat(1,sun_setgid) }, /* 46 = old sun_setgid */ - { 0, getgid }, /* 47 = getgid */ - { compat(2,sun_ssig) }, /* 48 = old sun_ssig */ - { 0, nosys }, /* 49 = reserved for USG */ - { 0, nosys }, /* 50 = reserved for USG */ - { 1, sysacct }, /* 51 = acct */ - { 0, nosys }, /* 52 = nosys */ - { 4, sun_mctl }, /* 53 = sun_mctl */ - { 3, sun_ioctl }, /* 54 = sun_ioctl */ - { 2, reboot }, /* 55 = reboot */ - { 0, nosys }, /* 56 = obsolete sun_owait3 */ - { 2, symlink }, /* 57 = symlink */ - { 3, readlink }, /* 58 = readlink */ - { 3, sun_execve }, /* 59 = sun_execve */ - { 1, umask }, /* 60 = umask */ - { 1, chroot }, /* 61 = chroot */ - { 2, fstat }, /* 62 = fstat */ - { 0, nosys }, /* 63 = nosys */ - { 0, getpagesize }, /* 64 = getpagesize */ - { 3, sun_omsync }, /* 65 = sun_omsync */ - { 0, vfork }, /* 66 = vfork */ - { 0, nosys }, /* 67 = obsolete vread */ - { 0, nosys }, /* 68 = obsolete vwrite */ - { 1, sbrk }, /* 69 = sbrk */ - { 1, sstk }, /* 70 = sstk */ - { 6, sun_mmap }, /* 71 = mmap */ - { 1, ovadvise }, /* 72 = vadvise */ - { 2, munmap }, /* 73 = munmap */ - { 3, mprotect }, /* 74 = mprotect */ - { 3, madvise }, /* 75 = madvise */ - { compat(0,vhangup) }, /* 76 = old vhangup */ - { compat(0,vlimit) }, /* 77 = old vlimit */ - { 3, mincore }, /* 78 = mincore */ - { 2, getgroups }, /* 79 = getgroups */ - { 2, setgroups }, /* 80 = setgroups */ - { 1, getpgrp }, /* 81 = getpgrp */ - { 2, setpgid }, /* 82 = setpgid */ - { 3, setitimer }, /* 83 = setitimer */ - { compat(0,wait) }, /* 84 = old wait */ - { 1, swapon }, /* 85 = swapon */ - { 2, getitimer }, /* 86 = getitimer */ - { 2, gethostname }, /* 87 = gethostname */ - { 2, sethostname }, /* 88 = sethostname */ - { 0, getdtablesize }, /* 89 = getdtablesize */ - { 2, dup2 }, /* 90 = dup2 */ - { 0, nosys }, /* 91 = getdopt */ - { 3, fcntl }, /* 92 = fcntl */ - { 5, select }, /* 93 = select */ - { 0, nosys }, /* 94 = setdopt */ - { 1, fsync }, /* 95 = fsync */ - { 3, setpriority }, /* 96 = setpriority */ - { 3, socket }, /* 97 = socket */ - { 3, connect }, /* 98 = connect */ - { 3, oaccept }, /* 99 = oaccept */ - { 2, getpriority }, /* 100 = getpriority */ - { 4, osend }, /* 101 = osend */ - { 4, orecv }, /* 102 = orecv */ - { 0, nosys }, /* 103 = old socketaddr */ - { 3, bind }, /* 104 = bind */ - { 5, sun_setsockopt }, /* 105 = sun_setsockopt */ - { 2, listen }, /* 106 = listen */ - { compat(0,vtimes) }, /* 107 = old vtimes */ - { 3, osigvec }, /* 108 = osigvec */ - { 1, osigblock }, /* 109 = osigblock */ - { 1, osigsetmask }, /* 110 = osigsetmask */ - { 1, sigsuspend }, /* 111 = sigsuspend */ - { 2, sigstack }, /* 112 = sigstack */ - { 3, orecvmsg }, /* 113 = orecvmsg */ - { 3, osendmsg }, /* 114 = osendmsg */ - { 0, nosys }, /* 115 = obsolete vtrace */ - { 2, gettimeofday }, /* 116 = gettimeofday */ - { 2, getrusage }, /* 117 = getrusage */ - { 5, getsockopt }, /* 118 = getsockopt */ - { 0, nosys }, /* 119 = nosys */ - { 3, readv }, /* 120 = readv */ - { 3, writev }, /* 121 = writev */ - { 2, settimeofday }, /* 122 = settimeofday */ - { 3, fchown }, /* 123 = fchown */ - { 2, fchmod }, /* 124 = fchmod */ - { 6, orecvfrom }, /* 125 = orecvfrom */ - { 2, osetreuid }, /* 126 = osetreuid */ - { 2, osetregid }, /* 127 = osetregid */ - { 2, rename }, /* 128 = rename */ - { 2, truncate }, /* 129 = truncate */ - { 2, ftruncate }, /* 130 = ftruncate */ - { 2, flock }, /* 131 = flock */ - { 0, nosys }, /* 132 = nosys */ - { 6, sendto }, /* 133 = sendto */ - { 2, shutdown }, /* 134 = shutdown */ - { 5, socketpair }, /* 135 = socketpair */ - { 2, mkdir }, /* 136 = mkdir */ - { 1, rmdir }, /* 137 = rmdir */ - { 2, utimes }, /* 138 = utimes */ - { 1, sun_sigreturn }, /* 139 = sun_sigreturn */ - { 2, adjtime }, /* 140 = adjtime */ - { 3, ogetpeername }, /* 141 = ogetpeername */ - { 0, gethostid }, /* 142 = gethostid */ - { 0, nosys }, /* 143 = old sethostid */ - { 2, getrlimit }, /* 144 = getrlimit */ - { 2, setrlimit }, /* 145 = setrlimit */ - { 2, okillpg }, /* 146 = okillpg */ - { 0, nosys }, /* 147 = nosys */ - { 0, nosys }, /* 148 = nosys */ - { 0, nosys }, /* 149 = nosys */ - { 3, ogetsockname }, /* 150 = ogetsockname */ - { 0, nosys }, /* 151 = getmsg */ - { 0, nosys }, /* 152 = putmsg */ - { 0, nosys }, /* 153 = poll */ - { 0, nosys }, /* 154 = nosys */ - { 0, nosys }, /* 155 = nosys */ - { 4, getdirentries }, /* 156 = getdirentries */ - { 2, statfs }, /* 157 = statfs */ - { 2, fstatfs }, /* 158 = fstatfs */ - { 1, sun_unmount }, /* 159 = sun_unmount */ - { 0, nosys }, /* 160 = nosys */ - { 0, nosys }, /* 161 = nosys */ - { 2, getdomainname }, /* 162 = getdomainname */ - { 2, setdomainname }, /* 163 = setdomainname */ - { 0, nosys }, /* 164 = rtschedule */ - { 0, nosys }, /* 165 = quotactl */ - { 0, nosys }, /* 166 = exportfs */ - { 4, sun_mount }, /* 167 = sun_mount */ - { 0, nosys }, /* 168 = ustat */ - { 0, nosys }, /* 169 = semsys */ - { 0, nosys }, /* 170 = msgsys */ -#ifdef SYSVSHM - { 4, shmsys }, /* 171 = shmsys */ -#else - { 0, nosys }, /* 171 = nosys */ -#endif - { 4, auditsys }, /* 172 = auditsys */ - { 0, nosys }, /* 173 = rfssys */ - { 3, sun_getdents }, /* 174 = sun_getdents */ - { 1, setsid }, /* 175 = setsid */ - { 1, fchdir }, /* 176 = fchdir */ - { 1, sun_fchroot }, /* 177 = sun_fchroot */ - { 0, nosys }, /* 178 = nosys */ - { 0, nosys }, /* 179 = nosys */ - { 0, nosys }, /* 180 = nosys */ - { 0, nosys }, /* 181 = nosys */ - { 0, nosys }, /* 182 = nosys */ - { 1, sun_sigpending }, /* 183 = sun_sigpending */ - { 0, nosys }, /* 184 = nosys */ - { 2, setpgid }, /* 185 = setpgid */ - { 0, nosys }, /* 186 = pathconf */ - { 0, nosys }, /* 187 = fpathconf */ - { 0, nosys }, /* 188 = sysconf */ - { 0, nosys }, /* 189 = uname */ -}; - -int nsun_sysent = sizeof(sun_sysent) / sizeof(sun_sysent[0]); diff --git a/sys/arch/amiga/sunos/syscalls.master b/sys/arch/amiga/sunos/syscalls.master deleted file mode 100644 index 9091d7a846bc..000000000000 --- a/sys/arch/amiga/sunos/syscalls.master +++ /dev/null @@ -1,216 +0,0 @@ - $Id: syscalls.master,v 1.1 1993/10/30 23:42:29 mw Exp $ -; from: @(#)syscalls.master 8.1 (Berkeley) 7/19/93 -; System call name/number master file (or rather, slave, from SunOS). -; Processed to created sun_sysent.c, sun_syscalls.c and sun_syscall.h. - -; Columns: number type nargs name altname/comments -; number system call number, must be in order -; type one of STD, OBSOL, UNIMPL, COMPAT -; nargs number of arguments -; name name of syscall routine -; altname name of system call if different -; for UNIMPL/OBSOL, name continues with comments - -; types: -; STD always included -; COMPAT included on COMPAT #ifdef -; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h -; OBSOL obsolete, not included in system, only specifies name -; UNIMPL not implemented, placeholder only - -; #ifdef's, etc. may be included, and are copied to the output files. - -0 UNIMPL 0 nosys syscall -1 STD 1 rexit exit -2 STD 0 fork -3 STD 3 read -4 STD 3 write -5 STD 3 open -6 STD 1 close -7 STD 4 sun_wait4 -8 STD 2 sun_creat -9 STD 2 link -10 STD 1 unlink -11 STD 2 sun_execv -12 STD 1 chdir -13 COMPAT 0 sun_time -14 STD 3 mknod -15 STD 2 chmod -16 STD 3 chown -17 STD 1 obreak break -18 COMPAT 2 sun_stat -19 STD 3 lseek -20 STD 0 getpid -21 OBSOL 1 sun_old_mount -22 UNIMPL 1 System V umount -23 COMPAT 1 setuid -24 STD 0 getuid -25 COMPAT 1 sun_stime -26 UNIMPL 5 sun_ptrace -27 COMPAT 1 sun_alarm -28 COMPAT 1 sun_fstat -29 COMPAT 0 sun_pause -30 COMPAT 2 sun_utime -31 UNIMPL 0 was stty -32 UNIMPL 0 was gtty -33 STD 2 saccess access -34 COMPAT 1 sun_nice -35 COMPAT 1 sun_ftime -36 STD 0 sync -37 STD 2 kill -38 STD 2 stat -39 COMPAT 2 sun_setpgrp -40 STD 2 lstat -41 STD 2 dup -42 STD 0 pipe -43 COMPAT 1 sun_times -44 STD 4 profil -45 UNIMPL 0 nosys -46 COMPAT 1 sun_setgid -47 STD 0 getgid -48 COMPAT 2 sun_ssig -49 UNIMPL 0 reserved for USG -50 UNIMPL 0 reserved for USG -51 STD 1 sysacct acct -52 UNIMPL 0 nosys -53 STD 4 sun_mctl -54 STD 3 sun_ioctl -55 STD 2 reboot -56 OBSOL 3 sun_owait3 -57 STD 2 symlink -58 STD 3 readlink -59 STD 3 sun_execve -60 STD 1 umask -61 STD 1 chroot -62 STD 2 fstat -63 UNIMPL 0 nosys -64 STD 0 getpagesize -65 STD 3 sun_omsync -66 STD 0 vfork -67 OBSOL 0 vread -68 OBSOL 0 vwrite -69 STD 1 sbrk -70 STD 1 sstk -71 STD 6 sun_mmap mmap -72 STD 1 ovadvise vadvise -73 STD 2 munmap -74 STD 3 mprotect -75 STD 3 madvise -76 COMPAT 0 vhangup -77 COMPAT 0 vlimit -78 STD 3 mincore -79 STD 2 getgroups -80 STD 2 setgroups -81 STD 1 getpgrp -82 STD 2 setpgid -83 STD 3 setitimer -84 COMPAT 0 wait -85 STD 1 swapon -86 STD 2 getitimer -87 STD 2 gethostname -88 STD 2 sethostname -89 STD 0 getdtablesize -90 STD 2 dup2 -91 UNIMPL 2 getdopt -92 STD 3 fcntl -93 STD 5 select -94 UNIMPL 2 setdopt -95 STD 1 fsync -96 STD 3 setpriority -97 STD 3 socket -98 STD 3 connect -99 STD 3 oaccept -100 STD 2 getpriority -101 STD 4 osend -102 STD 4 orecv -103 UNIMPL 0 old socketaddr -104 STD 3 bind -105 STD 5 sun_setsockopt -106 STD 2 listen -107 COMPAT 0 vtimes -108 STD 3 osigvec -109 STD 1 osigblock -110 STD 1 osigsetmask -111 STD 1 sigsuspend -112 STD 2 sigstack -113 STD 3 orecvmsg -114 STD 3 osendmsg -115 OBSOL 3 vtrace -116 STD 2 gettimeofday -117 STD 2 getrusage -118 STD 5 getsockopt -119 UNIMPL 0 nosys -120 STD 3 readv -121 STD 3 writev -122 STD 2 settimeofday -123 STD 3 fchown -124 STD 2 fchmod -125 STD 6 orecvfrom -126 STD 2 osetreuid -127 STD 2 osetregid -128 STD 2 rename -129 STD 2 truncate -130 STD 2 ftruncate -131 STD 2 flock -132 UNIMPL 0 nosys -133 STD 6 sendto -134 STD 2 shutdown -135 STD 5 socketpair -136 STD 2 mkdir -137 STD 1 rmdir -138 STD 2 utimes -139 STD 1 sun_sigreturn -140 STD 2 adjtime -141 STD 3 ogetpeername -142 STD 0 gethostid -143 UNIMPL 1 old sethostid -144 STD 2 getrlimit -145 STD 2 setrlimit -146 STD 2 okillpg -147 UNIMPL 0 nosys -148 UNIMPL 0 nosys -149 UNIMPL 0 nosys -150 STD 3 ogetsockname -151 UNIMPL 4 getmsg -152 UNIMPL 4 putmsg -153 UNIMPL 3 poll -154 UNIMPL 0 nosys -155 UNIMPL 0 nosys -156 STD 4 getdirentries -157 STD 2 statfs -158 STD 2 fstatfs -159 STD 1 sun_unmount -160 UNIMPL 0 nosys -161 UNIMPL 0 nosys -162 STD 2 getdomainname -163 STD 2 setdomainname -164 UNIMPL 5 rtschedule -165 UNIMPL 4 quotactl -166 UNIMPL 2 exportfs -167 STD 4 sun_mount -168 UNIMPL 2 ustat -169 UNIMPL 5 semsys -170 UNIMPL 6 msgsys -#ifdef SYSVSHM -171 STD 4 shmsys -#else -171 UNIMPL 0 nosys -#endif -172 STD 4 auditsys -173 UNIMPL 5 rfssys -174 STD 3 sun_getdents -175 STD 1 setsid -176 STD 1 fchdir -177 STD 1 sun_fchroot -178 UNIMPL 0 nosys -179 UNIMPL 0 nosys -180 UNIMPL 0 nosys -181 UNIMPL 0 nosys -182 UNIMPL 0 nosys -183 STD 1 sun_sigpending -184 UNIMPL 0 nosys -185 STD 2 setpgid -186 UNIMPL 2 pathconf -187 UNIMPL 2 fpathconf -188 UNIMPL 1 sysconf -189 UNIMPL 1 uname diff --git a/sys/arch/hp300/hpux/hpux_sig.c b/sys/arch/hp300/hpux/hpux_sig.c deleted file mode 100644 index 1fb46a4c3b21..000000000000 --- a/sys/arch/hp300/hpux/hpux_sig.c +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: hpux_sig.c 1.4 92/01/20$ - * - * from: @(#)hpux_sig.c 8.2 (Berkeley) 9/23/93 - * $Id: hpux_sig.c,v 1.9 1994/05/23 08:04:19 mycroft Exp $ - */ - -/* - * Signal related HPUX compatibility routines - */ - -#include -#include -#include -#include -#include - -#include - -/* indexed by HPUX signal number - 1 */ -char hpuxtobsdsigmap[NSIG] = { -/*01*/ SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGIOT, SIGEMT, SIGFPE, -/*09*/ SIGKILL, SIGBUS, SIGSEGV, SIGSYS, SIGPIPE, SIGALRM, SIGTERM, SIGUSR1, -/*17*/ SIGUSR2, SIGCHLD, 0, SIGVTALRM,SIGPROF, SIGIO, SIGWINCH, SIGSTOP, -/*25*/ SIGTSTP, SIGCONT,SIGTTIN, SIGTTOU, SIGURG, 0, 0, 0 -}; - -/* indexed by BSD signal number - 1 */ -char bsdtohpuxsigmap[NSIG] = { -/*01*/ 1, 2, 3, 4, 5, 6, 7, 8, -/*09*/ 9, 10, 11, 12, 13, 14, 15, 29, -/*17*/ 24, 25, 26, 18, 27, 28, 22, 0, -/*25*/ 0, 20, 21, 23, 0, 16, 17, 0 -}; - -/* - * XXX: In addition to mapping the signal number we also have - * to see if the "old" style signal mechinism is needed. - * If so, we set the OUSIG flag. This is not really correct - * as under HP-UX "old" style handling can be set on a per - * signal basis and we are setting it for all signals in one - * swell foop. I suspect we can get away with this since I - * doubt any program of interest mixes the two semantics. - */ -struct hpux_sigvec_args { - int signo; - struct sigvec *nsv; - struct sigvec *osv; -}; -hpux_sigvec(p, uap, retval) - struct proc *p; - register struct hpux_sigvec_args *uap; - int *retval; -{ - struct sigvec vec; - register struct sigacts *ps = p->p_sigacts; - register struct sigvec *sv; - register int sig; - int bit, error; - - sig = hpuxtobsdsig(uap->signo); - if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) - return (EINVAL); - sv = &vec; - if (uap->osv) { - sv->sv_handler = ps->ps_sigact[sig]; - sv->sv_mask = ps->ps_catchmask[sig]; - bit = sigmask(sig); - sv->sv_flags = 0; - if ((ps->ps_sigonstack & bit) != 0) - sv->sv_flags |= SV_ONSTACK; - if ((ps->ps_sigintr & bit) != 0) - sv->sv_flags |= SV_INTERRUPT; -#if 0 -/* XXX -- SOUSIG no longer exists, do something here */ - if (p->p_flag & SOUSIG) - sv->sv_flags |= HPUXSV_RESET; /* XXX */ -#endif - error = copyout((caddr_t)sv, (caddr_t)uap->osv, sizeof (vec)); - if (error) - return (error); - } - if (uap->nsv) { - error = copyin((caddr_t)uap->nsv, (caddr_t)sv, sizeof (vec)); - if (error) - return (error); - if (sig == SIGCONT && sv->sv_handler == SIG_IGN) - return (EINVAL); - sv->sv_flags ^= SA_RESTART; - setsigvec(p, sig, (struct sigaction *)sv); -#if 0 -/* XXX -- SOUSIG no longer exists, do something here */ - if (sv->sv_flags & HPUXSV_RESET) - p->p_flag |= SOUSIG; /* XXX */ -#endif - } - return (0); -} - -struct hpux_sigblock_args { - int mask; -}; -hpux_sigblock(p, uap, retval) - register struct proc *p; - struct hpux_sigblock_args *uap; - int *retval; -{ - - (void) splhigh(); - *retval = bsdtohpuxmask(p->p_sigmask); - p->p_sigmask |= hpuxtobsdmask(uap->mask) &~ sigcantmask; - (void) spl0(); - return (0); -} - -struct hpux_sigsetmask_args { - int mask; -}; -hpux_sigsetmask(p, uap, retval) - struct proc *p; - struct hpux_sigsetmask_args *uap; - int *retval; -{ - - (void) splhigh(); - *retval = bsdtohpuxmask(p->p_sigmask); - p->p_sigmask = hpuxtobsdmask(uap->mask) &~ sigcantmask; - (void) spl0(); - return (0); -} - -struct hpux_sigpause_args { - int mask; -}; -hpux_sigpause(p, uap, retval) - struct proc *p; - struct hpux_sigpause_args *uap; - int *retval; -{ - - uap->mask = hpuxtobsdmask(uap->mask); - return (sigsuspend(p, uap, retval)); -} - -/* not totally correct, but close enuf' */ -struct hpux_kill_args { - int pid; - int signo; -}; -hpux_kill(p, uap, retval) - struct proc *p; - struct hpux_kill_args *uap; - int *retval; -{ - - if (uap->signo) { - uap->signo = hpuxtobsdsig(uap->signo); - if (uap->signo == 0) - uap->signo = NSIG; - } - return (kill(p, uap, retval)); -} - -/* - * The following (sigprocmask, sigpending, sigsuspend, sigaction are - * POSIX calls. Under BSD, the library routine dereferences the sigset_t - * pointers before traping. Not so under HP-UX. - */ - -/* - * Manipulate signal mask. - * Note that we receive new mask, not pointer, - * and return old mask as return value; - * the library stub does the rest. - */ -struct hpux_sigprocmask_args { - int how; - hpux_sigset_t *set; - hpux_sigset_t *oset; -}; -hpux_sigprocmask(p, uap, retval) - register struct proc *p; - struct hpux_sigprocmask_args *uap; - int *retval; -{ - int mask, error = 0; - hpux_sigset_t sigset; - - /* - * Copy out old mask first to ensure no errors. - * (proc sigmask should not be changed if call fails for any reason) - */ - if (uap->oset) { - bzero((caddr_t)&sigset, sizeof(sigset)); - sigset.sigset[0] = bsdtohpuxmask(p->p_sigmask); - if (copyout((caddr_t)&sigset, (caddr_t)uap->oset, sizeof(sigset))) - return (EFAULT); - } - if (uap->set) { - if (copyin((caddr_t)uap->set, (caddr_t)&sigset, sizeof(sigset))) - return (EFAULT); - mask = hpuxtobsdmask(sigset.sigset[0]); - (void) splhigh(); - switch (uap->how) { - case HPUXSIG_BLOCK: - p->p_sigmask |= mask &~ sigcantmask; - break; - case HPUXSIG_UNBLOCK: - p->p_sigmask &= ~mask; - break; - case HPUXSIG_SETMASK: - p->p_sigmask = mask &~ sigcantmask; - break; - default: - error = EINVAL; - break; - } - (void) spl0(); - } - return (error); -} - -struct hpux_sigpending_args { - hpux_sigset_t *set; -}; -hpux_sigpending(p, uap, retval) - register struct proc *p; - struct hpux_sigpending_args *uap; - int *retval; -{ - hpux_sigset_t sigset; - - sigset.sigset[0] = bsdtohpuxmask(p->p_siglist); - return (copyout((caddr_t)&sigset, (caddr_t)uap->set, sizeof(sigset))); -} - -struct hpux_sigsuspend_args { - hpux_sigset_t *set; -}; -hpux_sigsuspend(p, uap, retval) - register struct proc *p; - struct hpux_sigsuspend_args *uap; - int *retval; -{ - register struct sigacts *ps = p->p_sigacts; - hpux_sigset_t sigset; - int mask; - - if (copyin((caddr_t)uap->set, (caddr_t)&sigset, sizeof(sigset))) - return (EFAULT); - mask = hpuxtobsdmask(sigset.sigset[0]); - ps->ps_oldmask = p->p_sigmask; - ps->ps_flags |= SAS_OLDMASK; - p->p_sigmask = mask &~ sigcantmask; - (void) tsleep((caddr_t)ps, PPAUSE | PCATCH, "pause", 0); - /* always return EINTR rather than ERESTART... */ - return (EINTR); -} - -struct hpux_sigaction_args { - int signo; - struct hpux_sigaction *nsa; - struct hpux_sigaction *osa; -}; -hpux_sigaction(p, uap, retval) - struct proc *p; - register struct hpux_sigaction_args *uap; - int *retval; -{ - struct hpux_sigaction action; - register struct sigacts *ps = p->p_sigacts; - register struct hpux_sigaction *sa; - register int sig; - int bit; - - sig = hpuxtobsdsig(uap->signo); - if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) - return (EINVAL); - - sa = &action; - if (uap->osa) { - sa->sa_handler = ps->ps_sigact[sig]; - bzero((caddr_t)&sa->sa_mask, sizeof(sa->sa_mask)); - sa->sa_mask.sigset[0] = bsdtohpuxmask(ps->ps_catchmask[sig]); - bit = sigmask(sig); - sa->sa_flags = 0; - if ((ps->ps_sigonstack & bit) != 0) - sa->sa_flags |= HPUXSA_ONSTACK; -#if 0 -/* XXX -- SOUSIG no longer exists, do something here */ - if (p->p_flag & SOUSIG) - sa->sa_flags |= HPUXSA_RESETHAND; /* XXX */ -#endif - if (p->p_flag & P_NOCLDSTOP) - sa->sa_flags |= HPUXSA_NOCLDSTOP; - if (copyout((caddr_t)sa, (caddr_t)uap->osa, sizeof (action))) - return (EFAULT); - } - if (uap->nsa) { - struct sigaction act; - - if (copyin((caddr_t)uap->nsa, (caddr_t)sa, sizeof (action))) - return (EFAULT); - if (sig == SIGCONT && sa->sa_handler == SIG_IGN) - return (EINVAL); - /* - * Create a sigaction struct for setsigvec - */ - act.sa_handler = sa->sa_handler; - act.sa_mask = hpuxtobsdmask(sa->sa_mask.sigset[0]); - act.sa_flags == SA_RESTART; - if (sa->sa_flags & HPUXSA_ONSTACK) - act.sa_flags |= SA_ONSTACK; - if (sa->sa_flags & HPUXSA_NOCLDSTOP) - act.sa_flags |= SA_NOCLDSTOP; - setsigvec(p, sig, &act); -#if 0 -/* XXX -- SOUSIG no longer exists, do something here */ - if (sa->sa_flags & HPUXSA_RESETHAND) - p->p_flag |= SOUSIG; /* XXX */ -#endif - } - return (0); -} - -#ifdef COMPAT_OHPUX -struct ohpux_ssig_args { - int signo; - sig_t fun; -}; -ohpux_ssig(p, uap, retval) - struct proc *p; - struct ohpux_ssig_args *uap; - int *retval; -{ - register int a; - struct sigaction vec; - register struct sigaction *sa = &vec; - - a = hpuxtobsdsig(uap->signo); - sa->sa_handler = uap->fun; - /* - * Kill processes trying to use job control facilities - * (this'll help us find any vestiges of the old stuff). - */ - if ((a &~ 0377) || - (sa->sa_handler != SIG_DFL && sa->sa_handler != SIG_IGN && - ((int)sa->sa_handler) & 1)) { - psignal(p, SIGSYS); - return (0); - } - if (a <= 0 || a >= NSIG || a == SIGKILL || a == SIGSTOP || - a == SIGCONT && sa->sa_handler == SIG_IGN) - return (EINVAL); - sa->sa_mask = 0; - sa->sa_flags = 0; - *retval = (int)p->p_sigacts->ps_sigact[a]; - setsigvec(p, a, sa); -#if 0 - p->p_flag |= SOUSIG; /* mark as simulating old stuff */ -#endif - return (0); -} -#endif - -/* signal numbers: convert from HPUX to BSD */ -hpuxtobsdsig(sig) - register int sig; -{ - if (--sig < 0 || sig >= NSIG) - return(0); - return((int)hpuxtobsdsigmap[sig]); -} - -/* signal numbers: convert from BSD to HPUX */ -bsdtohpuxsig(sig) - register int sig; -{ - if (--sig < 0 || sig >= NSIG) - return(0); - return((int)bsdtohpuxsigmap[sig]); -} - -/* signal masks: convert from HPUX to BSD (not pretty or fast) */ -hpuxtobsdmask(mask) - register int mask; -{ - register int nmask, sig, nsig; - - if (mask == 0 || mask == -1) - return(mask); - nmask = 0; - for (sig = 1; sig < NSIG; sig++) - if ((mask & sigmask(sig)) && (nsig = hpuxtobsdsig(sig))) - nmask |= sigmask(nsig); - return(nmask); -} - -bsdtohpuxmask(mask) - register int mask; -{ - register int nmask, sig, nsig; - - if (mask == 0 || mask == -1) - return(mask); - nmask = 0; - for (sig = 1; sig < NSIG; sig++) - if ((mask & sigmask(sig)) && (nsig = bsdtohpuxsig(sig))) - nmask |= sigmask(nsig); - return(nmask); -} diff --git a/sys/arch/hp300/hpux/hpux_syscall.h b/sys/arch/hp300/hpux/hpux_syscall.h deleted file mode 100644 index 15d47fe635c5..000000000000 --- a/sys/arch/hp300/hpux/hpux_syscall.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * System call numbers. - * - * DO NOT EDIT-- this file is automatically generated. - * created from: NetBSD syscalls.master,v 1.5 1994/06/30 16:42:48 - */ - -#define SYS_exit 1 -#define SYS_fork 2 -#define SYS_read 3 -#define SYS_write 4 -#define SYS_open 5 -#define SYS_close 6 -#define SYS_owait 7 -#define SYS_ocreat 8 -#define SYS_link 9 -#define SYS_unlink 10 -#define SYS_execv 11 -#define SYS_chdir 12 - /* 13 is old hpux_time time */ -#define SYS_mknod 14 -#define SYS_chmod 15 -#define SYS_chown 16 -#define SYS_break 17 - /* 18 is old hpux_stat stat */ -#define SYS_olseek 19 -#define SYS_getpid 20 -#define SYS_setuid 23 -#define SYS_getuid 24 - /* 25 is old hpux_stime stime */ -#define SYS_ptrace 26 - /* 27 is old hpux_alarm alarm */ - /* 28 is old hpux_fstat fstat */ - /* 29 is old hpux_pause pause */ - /* 30 is old hpux_utime utime */ - /* 31 is old hpux_stty stty */ - /* 32 is old hpux_gtty gtty */ -#define SYS_access 33 - /* 34 is old hpux_nice nice */ - /* 35 is old hpux_ftime ftime */ -#define SYS_sync 36 -#define SYS_kill 37 -#define SYS_stat 38 - /* 39 is old hpux_setpgrp setpgrp */ -#define SYS_lstat 40 -#define SYS_dup 41 -#define SYS_pipe 42 - /* 43 is old hpux_times times */ -#define SYS_profil 44 -#define SYS_setgid 46 -#define SYS_getgid 47 - /* 48 is old hpux_ssig ssig */ -#define SYS_ioctl 54 -#define SYS_symlink 56 -#define SYS_utssys 57 -#define SYS_readlink 58 -#define SYS_execve 59 -#define SYS_umask 60 -#define SYS_chroot 61 -#define SYS_fcntl 62 -#define SYS_ulimit 63 -#define SYS_vfork 66 -#define SYS_vread 67 -#define SYS_vwrite 68 -#define SYS_mmap 71 -#define SYS_munmap 73 -#define SYS_getgroups 79 -#define SYS_setgroups 80 -#define SYS_getpgrp2 81 -#define SYS_setpgrp2 82 -#define SYS_setitimer 83 -#define SYS_wait3 84 -#define SYS_getitimer 86 -#define SYS_dup2 90 -#define SYS_fstat 92 -#define SYS_select 93 -#define SYS_fsync 95 -#define SYS_sigreturn 103 -#define SYS_sigvec 108 -#define SYS_sigblock 109 -#define SYS_sigsetmask 110 -#define SYS_sigpause 111 -#define SYS_osigstack 112 -#define SYS_gettimeofday 116 -#define SYS_readv 120 -#define SYS_writev 121 -#define SYS_settimeofday 122 -#define SYS_fchown 123 -#define SYS_fchmod 124 -#define SYS_setresuid 126 -#define SYS_setresgid 127 -#define SYS_rename 128 - /* 129 is old truncate */ - /* 130 is old ftruncate */ -#define SYS_sysconf 132 -#define SYS_mkdir 136 -#define SYS_rmdir 137 - /* 144 is old getrlimit */ - /* 145 is old setrlimit */ -#define SYS_rtprio 152 -#define SYS_netioctl 154 -#define SYS_lockf 155 -#define SYS_semget 156 -#define SYS_semctl 157 -#define SYS_semop 158 -#define SYS_msgget 159 -#define SYS_msgctl 160 -#define SYS_msgsnd 161 -#define SYS_msgrcv 162 -#define SYS_shmget 163 -#define SYS_shmctl 164 -#define SYS_shmat 165 -#define SYS_shmdt 166 -#define SYS_m68020_advise 167 -#define SYS_getcontext 174 -#define SYS_getaccess 190 -#define SYS_waitpid 200 - /* 231 is old getdirentries */ - /* 232 is old getdomainname */ - /* 236 is old setdomainname */ -#define SYS_sigaction 239 -#define SYS_sigprocmask 240 -#define SYS_sigpending 241 -#define SYS_sigsuspend 242 - /* 268 is old getdtablesize getnumfds */ -#define SYS_fchdir 272 - /* 275 is old accept */ -#define SYS_bind 276 -#define SYS_connect 277 - /* 278 is old getpeername */ - /* 279 is old getsockname */ -#define SYS_getsockopt 280 -#define SYS_listen 281 - /* 282 is old recv */ - /* 283 is old recvfrom */ - /* 284 is old recvmsg */ - /* 285 is old send */ - /* 286 is old sendmsg */ -#define SYS_sendto 287 -#define SYS_setsockopt2 288 -#define SYS_shutdown 289 -#define SYS_socket 290 -#define SYS_socketpair 291 -#define SYS_nsemctl 312 -#define SYS_nmsgctl 313 -#define SYS_nshmctl 314 diff --git a/sys/arch/hp300/hpux/hpux_syscalls.c b/sys/arch/hp300/hpux/hpux_syscalls.c deleted file mode 100644 index b5f2a7009515..000000000000 --- a/sys/arch/hp300/hpux/hpux_syscalls.c +++ /dev/null @@ -1,356 +0,0 @@ -/* - * System call names. - * - * DO NOT EDIT-- this file is automatically generated. - * created from: NetBSD syscalls.master,v 1.5 1994/06/30 16:42:48 - */ - -char *hpux_syscallnames[] = { - "#0", /* 0 = indir or out-of-range */ - "exit", /* 1 = exit */ - "fork", /* 2 = fork */ - "read", /* 3 = read */ - "write", /* 4 = write */ - "open", /* 5 = open */ - "close", /* 6 = close */ - "owait", /* 7 = owait */ - "ocreat", /* 8 = ocreat */ - "link", /* 9 = link */ - "unlink", /* 10 = unlink */ - "execv", /* 11 = execv */ - "chdir", /* 12 = chdir */ - "old.time", /* 13 = old time */ - "mknod", /* 14 = mknod */ - "chmod", /* 15 = chmod */ - "chown", /* 16 = chown */ - "break", /* 17 = break */ - "old.stat", /* 18 = old stat */ - "olseek", /* 19 = olseek */ - "getpid", /* 20 = getpid */ - "mount", /* 21 = mount (unimplemented) */ - "umount", /* 22 = umount (unimplemented) */ - "setuid", /* 23 = setuid */ - "getuid", /* 24 = getuid */ - "old.stime", /* 25 = old stime */ - "ptrace", /* 26 = ptrace */ - "old.alarm", /* 27 = old alarm */ - "old.fstat", /* 28 = old fstat */ - "old.pause", /* 29 = old pause */ - "old.utime", /* 30 = old utime */ - "old.stty", /* 31 = old stty */ - "old.gtty", /* 32 = old gtty */ - "access", /* 33 = access */ - "old.nice", /* 34 = old nice */ - "old.ftime", /* 35 = old ftime */ - "sync", /* 36 = sync */ - "kill", /* 37 = kill */ - "stat", /* 38 = stat */ - "old.setpgrp", /* 39 = old setpgrp */ - "lstat", /* 40 = lstat */ - "dup", /* 41 = dup */ - "pipe", /* 42 = pipe */ - "old.times", /* 43 = old times */ - "profil", /* 44 = profil */ - "ki_syscall", /* 45 = ki_syscall (unimplemented) */ - "setgid", /* 46 = setgid */ - "getgid", /* 47 = getgid */ - "old.ssig", /* 48 = old ssig */ - "#49", /* 49 = reserved for USG */ - "#50", /* 50 = reserved for USG */ - "acct", /* 51 = acct (unimplemented) */ - "#52", /* 52 = nosys */ - "#53", /* 53 = nosys */ - "ioctl", /* 54 = ioctl */ - "reboot", /* 55 = reboot (unimplemented) */ - "symlink", /* 56 = symlink */ - "utssys", /* 57 = utssys */ - "readlink", /* 58 = readlink */ - "execve", /* 59 = execve */ - "umask", /* 60 = umask */ - "chroot", /* 61 = chroot */ - "fcntl", /* 62 = fcntl */ - "ulimit", /* 63 = ulimit */ - "#64", /* 64 = nosys */ - "#65", /* 65 = nosys */ - "vfork", /* 66 = vfork */ - "vread", /* 67 = vread */ - "vwrite", /* 68 = vwrite */ - "#69", /* 69 = nosys */ - "#70", /* 70 = nosys */ - "mmap", /* 71 = mmap */ - "#72", /* 72 = nosys */ - "munmap", /* 73 = munmap */ - "mprotect", /* 74 = mprotect (unimplemented) */ - "#75", /* 75 = nosys */ - "#76", /* 76 = nosys */ - "#77", /* 77 = nosys */ - "#78", /* 78 = nosys */ - "getgroups", /* 79 = getgroups */ - "setgroups", /* 80 = setgroups */ - "getpgrp2", /* 81 = getpgrp2 */ - "setpgrp2", /* 82 = setpgrp2 */ - "setitimer", /* 83 = setitimer */ - "wait3", /* 84 = wait3 */ - "swapon", /* 85 = swapon (unimplemented) */ - "getitimer", /* 86 = getitimer */ - "#87", /* 87 = nosys */ - "#88", /* 88 = nosys */ - "#89", /* 89 = nosys */ - "dup2", /* 90 = dup2 */ - "#91", /* 91 = nosys */ - "fstat", /* 92 = fstat */ - "select", /* 93 = select */ - "#94", /* 94 = nosys */ - "fsync", /* 95 = fsync */ - "#96", /* 96 = nosys */ - "#97", /* 97 = nosys */ - "#98", /* 98 = nosys */ - "#99", /* 99 = nosys */ - "#100", /* 100 = nosys */ - "#101", /* 101 = nosys */ - "#102", /* 102 = nosys */ - "sigreturn", /* 103 = sigreturn */ - "#104", /* 104 = nosys */ - "#105", /* 105 = nosys */ - "#106", /* 106 = nosys */ - "#107", /* 107 = nosys */ - "sigvec", /* 108 = sigvec */ - "sigblock", /* 109 = sigblock */ - "sigsetmask", /* 110 = sigsetmask */ - "sigpause", /* 111 = sigpause */ - "osigstack", /* 112 = osigstack */ - "#113", /* 113 = nosys */ - "#114", /* 114 = nosys */ - "#115", /* 115 = nosys */ - "gettimeofday", /* 116 = gettimeofday */ - "#117", /* 117 = nosys */ - "#118", /* 118 = nosys */ - "hpib_io_stub", /* 119 = hpib_io_stub (unimplemented) */ - "readv", /* 120 = readv */ - "writev", /* 121 = writev */ - "settimeofday", /* 122 = settimeofday */ - "fchown", /* 123 = fchown */ - "fchmod", /* 124 = fchmod */ - "#125", /* 125 = nosys */ - "setresuid", /* 126 = setresuid */ - "setresgid", /* 127 = setresgid */ - "rename", /* 128 = rename */ - "old.truncate", /* 129 = old truncate */ - "old.ftruncate", /* 130 = old ftruncate */ - "#131", /* 131 = nosys */ - "sysconf", /* 132 = sysconf */ - "#133", /* 133 = nosys */ - "#134", /* 134 = nosys */ - "#135", /* 135 = nosys */ - "mkdir", /* 136 = mkdir */ - "rmdir", /* 137 = rmdir */ - "#138", /* 138 = nosys */ - "#139", /* 139 = nosys */ - "#140", /* 140 = nosys */ - "#141", /* 141 = nosys */ - "#142", /* 142 = nosys */ - "#143", /* 143 = nosys */ - "old.getrlimit", /* 144 = old getrlimit */ - "old.setrlimit", /* 145 = old setrlimit */ - "#146", /* 146 = nosys */ - "#147", /* 147 = nosys */ - "#148", /* 148 = nosys */ - "#149", /* 149 = nosys */ - "#150", /* 150 = nosys */ - "privgrp", /* 151 = privgrp (unimplemented) */ - "rtprio", /* 152 = rtprio */ - "plock", /* 153 = plock (unimplemented) */ - "netioctl", /* 154 = netioctl */ - "lockf", /* 155 = lockf */ -#ifdef SYSVSEM - "semget", /* 156 = semget */ - "semctl", /* 157 = semctl */ - "semop", /* 158 = semop */ -#else - "semget", /* 156 = semget (unimplemented) */ - "semctl", /* 157 = semctl (unimplemented) */ - "semop", /* 158 = semop (unimplemented) */ -#endif -#ifdef SYSVMSG - "msgget", /* 159 = msgget */ - "msgctl", /* 160 = msgctl */ - "msgsnd", /* 161 = msgsnd */ - "msgrcv", /* 162 = msgrcv */ -#else - "msgget", /* 159 = msgget (unimplemented) */ - "msgctl", /* 160 = msgctl (unimplemented) */ - "msgsnd", /* 161 = msgsnd (unimplemented) */ - "msgrcv", /* 162 = msgrcv (unimplemented) */ -#endif -#ifdef SYSVSHM - "shmget", /* 163 = shmget */ - "shmctl", /* 164 = shmctl */ - "shmat", /* 165 = shmat */ - "shmdt", /* 166 = shmdt */ -#else - "shmget", /* 163 = shmget (unimplemented) */ - "shmctl", /* 164 = shmctl (unimplemented) */ - "shmat", /* 165 = shmat (unimplemented) */ - "shmdt", /* 166 = shmdt (unimplemented) */ -#endif - "m68020_advise", /* 167 = m68020_advise */ - "nsp_init", /* 168 = nsp_init (unimplemented) */ - "cluster", /* 169 = cluster (unimplemented) */ - "mkrnod", /* 170 = mkrnod (unimplemented) */ - "#171", /* 171 = nosys */ - "unsp_open", /* 172 = unsp_open (unimplemented) */ - "#173", /* 173 = nosys */ - "getcontext", /* 174 = getcontext */ - "#175", /* 175 = nosys */ - "#176", /* 176 = nosys */ - "#177", /* 177 = nosys */ - "lsync", /* 178 = lsync (unimplemented) */ - "#179", /* 179 = nosys */ - "mysite", /* 180 = mysite (unimplemented) */ - "sitels", /* 181 = sitels (unimplemented) */ - "#182", /* 182 = nosys */ - "#183", /* 183 = nosys */ - "dskless_stats", /* 184 = dskless_stats (unimplemented) */ - "#185", /* 185 = nosys */ - "setacl", /* 186 = setacl (unimplemented) */ - "fsetacl", /* 187 = fsetacl (unimplemented) */ - "getacl", /* 188 = getacl (unimplemented) */ - "fgetacl", /* 189 = fgetacl (unimplemented) */ - "getaccess", /* 190 = getaccess */ - "getaudid", /* 191 = getaudid (unimplemented) */ - "setaudid", /* 192 = setaudid (unimplemented) */ - "getaudproc", /* 193 = getaudproc (unimplemented) */ - "setaudproc", /* 194 = setaudproc (unimplemented) */ - "getevent", /* 195 = getevent (unimplemented) */ - "setevent", /* 196 = setevent (unimplemented) */ - "audwrite", /* 197 = audwrite (unimplemented) */ - "audswitch", /* 198 = audswitch (unimplemented) */ - "audctl", /* 199 = audctl (unimplemented) */ - "waitpid", /* 200 = waitpid */ - "#201", /* 201 = nosys */ - "#202", /* 202 = nosys */ - "#203", /* 203 = nosys */ - "#204", /* 204 = nosys */ - "#205", /* 205 = nosys */ - "#206", /* 206 = nosys */ - "#207", /* 207 = nosys */ - "#208", /* 208 = nosys */ - "#209", /* 209 = nosys */ - "#210", /* 210 = nosys */ - "#211", /* 211 = nosys */ - "#212", /* 212 = nosys */ - "#213", /* 213 = nosys */ - "#214", /* 214 = nosys */ - "#215", /* 215 = nosys */ - "#216", /* 216 = nosys */ - "#217", /* 217 = nosys */ - "#218", /* 218 = nosys */ - "#219", /* 219 = nosys */ - "#220", /* 220 = nosys */ - "#221", /* 221 = nosys */ - "#222", /* 222 = nosys */ - "#223", /* 223 = nosys */ - "#224", /* 224 = nosys */ - "pathconf", /* 225 = pathconf (unimplemented) */ - "fpathconf", /* 226 = fpathconf (unimplemented) */ - "#227", /* 227 = nosys */ - "#228", /* 228 = nosys */ - "async_daemon", /* 229 = async_daemon (unimplemented) */ - "nfs_fcntl", /* 230 = nfs_fcntl (unimplemented) */ - "old.getdirentries", /* 231 = old getdirentries */ - "old.getdomainname", /* 232 = old getdomainname */ - "nfs_getfh", /* 233 = nfs_getfh (unimplemented) */ - "vfsmount", /* 234 = vfsmount (unimplemented) */ - "nfs_svc", /* 235 = nfs_svc (unimplemented) */ - "old.setdomainname", /* 236 = old setdomainname */ - "statfs", /* 237 = statfs (unimplemented) */ - "fstatfs", /* 238 = fstatfs (unimplemented) */ - "sigaction", /* 239 = sigaction */ - "sigprocmask", /* 240 = sigprocmask */ - "sigpending", /* 241 = sigpending */ - "sigsuspend", /* 242 = sigsuspend */ - "fsctl", /* 243 = fsctl (unimplemented) */ - "#244", /* 244 = nosys */ - "pstat", /* 245 = pstat (unimplemented) */ - "#246", /* 246 = nosys */ - "#247", /* 247 = nosys */ - "#248", /* 248 = nosys */ - "#249", /* 249 = nosys */ - "#250", /* 250 = nosys */ - "#251", /* 251 = nosys */ - "#252", /* 252 = nosys */ - "#253", /* 253 = nosys */ - "#254", /* 254 = nosys */ - "#255", /* 255 = nosys */ - "#256", /* 256 = nosys */ - "#257", /* 257 = nosys */ - "#258", /* 258 = nosys */ - "#259", /* 259 = nosys */ - "#260", /* 260 = nosys */ - "#261", /* 261 = nosys */ - "#262", /* 262 = nosys */ - "#263", /* 263 = nosys */ - "#264", /* 264 = nosys */ - "#265", /* 265 = nosys */ - "#266", /* 266 = nosys */ - "#267", /* 267 = nosys */ - "old.getnumfds", /* 268 = old getnumfds */ - "#269", /* 269 = nosys */ - "#270", /* 270 = nosys */ - "#271", /* 271 = nosys */ - "fchdir", /* 272 = fchdir */ - "#273", /* 273 = nosys */ - "#274", /* 274 = nosys */ - "old.accept", /* 275 = old accept */ - "bind", /* 276 = bind */ - "connect", /* 277 = connect */ - "old.getpeername", /* 278 = old getpeername */ - "old.getsockname", /* 279 = old getsockname */ - "getsockopt", /* 280 = getsockopt */ - "listen", /* 281 = listen */ - "old.recv", /* 282 = old recv */ - "old.recvfrom", /* 283 = old recvfrom */ - "old.recvmsg", /* 284 = old recvmsg */ - "old.send", /* 285 = old send */ - "old.sendmsg", /* 286 = old sendmsg */ - "sendto", /* 287 = sendto */ - "setsockopt2", /* 288 = setsockopt2 */ - "shutdown", /* 289 = shutdown */ - "socket", /* 290 = socket */ - "socketpair", /* 291 = socketpair */ - "#292", /* 292 = nosys */ - "#293", /* 293 = nosys */ - "#294", /* 294 = nosys */ - "#295", /* 295 = nosys */ - "#296", /* 296 = nosys */ - "#297", /* 297 = nosys */ - "#298", /* 298 = nosys */ - "#299", /* 299 = nosys */ - "#300", /* 300 = nosys */ - "#301", /* 301 = nosys */ - "#302", /* 302 = nosys */ - "#303", /* 303 = nosys */ - "#304", /* 304 = nosys */ - "#305", /* 305 = nosys */ - "#306", /* 306 = nosys */ - "#307", /* 307 = nosys */ - "#308", /* 308 = nosys */ - "#309", /* 309 = nosys */ - "#310", /* 310 = nosys */ - "#311", /* 311 = nosys */ -#ifdef SYSVSHM - "nsemctl", /* 312 = nsemctl */ -#else - "nsemctl", /* 312 = nsemctl (unimplemented) */ -#endif -#ifdef SYSVMSG - "nmsgctl", /* 313 = nmsgctl */ -#else - "nmsgctl", /* 313 = nmsgctl (unimplemented) */ -#endif -#ifdef SYSVSHM - "nshmctl", /* 314 = nshmctl */ -#else - "nshmctl", /* 314 = nshmctl (unimplemented) */ -#endif -}; diff --git a/sys/arch/hp300/hpux/hpux_sysent.c b/sys/arch/hp300/hpux/hpux_sysent.c deleted file mode 100644 index 0589e65d3346..000000000000 --- a/sys/arch/hp300/hpux/hpux_sysent.c +++ /dev/null @@ -1,547 +0,0 @@ -/* - * System call switch table. - * - * DO NOT EDIT-- this file is automatically generated. - * created from: NetBSD syscalls.master,v 1.5 1994/06/30 16:42:48 - */ - -#include -#include - -int nosys(),notimp(); - -int exit(); -int hpux_fork(); -int hpux_read(); -int hpux_write(); -int hpux_open(); -int close(); -int hpux_wait(); -int hpux_creat(); -int link(); -int unlink(); -int hpux_execv(); -int chdir(); -int mknod(); -int chmod(); -int chown(); -int obreak(); -int olseek(); -int getpid(); -int setuid(); -int getuid(); -int hpux_ptrace(); -int access(); -int sync(); -int hpux_kill(); -int hpux_stat(); -int hpux_lstat(); -int hpux_dup(); -int pipe(); -int profil(); -int setgid(); -int getgid(); -int hpux_ioctl(); -int symlink(); -int hpux_utssys(); -int readlink(); -int execve(); -int umask(); -int chroot(); -int hpux_fcntl(); -int hpux_ulimit(); -int hpux_vfork(); -int hpux_read(); -int hpux_write(); -int hpux_mmap(); -int munmap(); -int getgroups(); -int setgroups(); -int hpux_getpgrp2(); -int hpux_setpgrp2(); -int setitimer(); -int hpux_wait3(); -int getitimer(); -int dup2(); -int hpux_fstat(); -int select(); -int fsync(); -int sigreturn(); -int hpux_sigvec(); -int hpux_sigblock(); -int hpux_sigsetmask(); -int hpux_sigpause(); -int osigstack(); -int gettimeofday(); -int hpux_readv(); -int hpux_writev(); -int settimeofday(); -int fchown(); -int fchmod(); -int hpux_setresuid(); -int hpux_setresgid(); -int rename(); -int hpux_sysconf(); -int mkdir(); -int rmdir(); -int hpux_rtprio(); -int hpux_netioctl(); -int hpux_lockf(); -#ifdef SYSVSEM -int semget(); -int semctl(); -int semop(); -#else -#endif -#ifdef SYSVMSG -int msgget(); -int msgctl(); -int msgsnd(); -int msgrcv(); -#else -#endif -#ifdef SYSVSHM -int shmget(); -int hpux_shmctl(); -int shmat(); -int shmdt(); -#else -#endif -int hpux_advise(); -int hpux_getcontext(); -int hpux_getaccess(); -int hpux_waitpid(); -int hpux_sigaction(); -int hpux_sigprocmask(); -int hpux_sigpending(); -int hpux_sigsuspend(); -int fchdir(); -int bind(); -int connect(); -int getsockopt(); -int listen(); -int sendto(); -int hpux_setsockopt2(); -int shutdown(); -int socket(); -int socketpair(); -#ifdef SYSVSHM -int semctl(); -#else -#endif -#ifdef SYSVMSG -int msgctl(); -#else -#endif -#ifdef SYSVSHM -int hpux_nshmctl(); -#else -#endif - -#ifdef COMPAT_OHPUX -#define compat(n, name) n, __CONCAT(o,name) - -int ohpux_time(); -int ohpux_stat(); -int ohpux_stime(); -int ohpux_alarm(); -int ohpux_fstat(); -int ohpux_pause(); -int ohpux_utime(); -int ohpux_stty(); -int ohpux_gtty(); -int ohpux_nice(); -int ohpux_ftime(); -int ohpux_setpgrp(); -int ohpux_times(); -int ohpux_ssig(); -int otruncate(); -int oftruncate(); -int ogetrlimit(); -int osetrlimit(); -#ifdef SYSVSEM -#else -#endif -#ifdef SYSVMSG -#else -#endif -#ifdef SYSVSHM -#else -#endif -int ogetdirentries(); -int ogetdomainname(); -int osetdomainname(); -int ogetdtablesize(); -int oaccept(); -int ogetpeername(); -int ogetsockname(); -int orecv(); -int orecvfrom(); -int orecvmsg(); -int osend(); -int osendmsg(); -#ifdef SYSVSHM -#else -#endif -#ifdef SYSVMSG -#else -#endif -#ifdef SYSVSHM -#else -#endif - -#else /* COMPAT_OHPUX */ -#define compat(n, name) 0, nosys -#endif /* COMPAT_OHPUX */ - -struct sysent hpux_sysent[] = { - { 0, nosys }, /* 0 = indir or out-of-range */ - { 1, exit }, /* 1 = exit */ - { 0, hpux_fork }, /* 2 = fork */ - { 3, hpux_read }, /* 3 = read */ - { 3, hpux_write }, /* 4 = write */ - { 3, hpux_open }, /* 5 = open */ - { 1, close }, /* 6 = close */ - { 1, hpux_wait }, /* 7 = owait */ - { 2, hpux_creat }, /* 8 = ocreat */ - { 2, link }, /* 9 = link */ - { 1, unlink }, /* 10 = unlink */ - { 2, hpux_execv }, /* 11 = execv */ - { 1, chdir }, /* 12 = chdir */ - { compat(1,hpux_time) }, /* 13 = old time */ - { 3, mknod }, /* 14 = mknod */ - { 2, chmod }, /* 15 = chmod */ - { 3, chown }, /* 16 = chown */ - { 1, obreak }, /* 17 = break */ - { compat(2,hpux_stat) }, /* 18 = old stat */ - { 3, olseek }, /* 19 = olseek */ - { 0, getpid }, /* 20 = getpid */ - { 3, notimp }, /* 21 = mount (unimplemented) */ - { 1, notimp }, /* 22 = umount (unimplemented) */ - { 1, setuid }, /* 23 = setuid */ - { 0, getuid }, /* 24 = getuid */ - { compat(1,hpux_stime) }, /* 25 = old stime */ - { 4, hpux_ptrace }, /* 26 = ptrace */ - { compat(1,hpux_alarm) }, /* 27 = old alarm */ - { compat(2,hpux_fstat) }, /* 28 = old fstat */ - { compat(0,hpux_pause) }, /* 29 = old pause */ - { compat(2,hpux_utime) }, /* 30 = old utime */ - { compat(2,hpux_stty) }, /* 31 = old stty */ - { compat(2,hpux_gtty) }, /* 32 = old gtty */ - { 2, access }, /* 33 = access */ - { compat(1,hpux_nice) }, /* 34 = old nice */ - { compat(1,hpux_ftime) }, /* 35 = old ftime */ - { 0, sync }, /* 36 = sync */ - { 2, hpux_kill }, /* 37 = kill */ - { 2, hpux_stat }, /* 38 = stat */ - { compat(1,hpux_setpgrp) }, /* 39 = old setpgrp */ - { 2, hpux_lstat }, /* 40 = lstat */ - { 1, hpux_dup }, /* 41 = dup */ - { 0, pipe }, /* 42 = pipe */ - { compat(1,hpux_times) }, /* 43 = old times */ - { 4, profil }, /* 44 = profil */ - { 4, notimp }, /* 45 = ki_syscall (unimplemented) */ - { 1, setgid }, /* 46 = setgid */ - { 0, getgid }, /* 47 = getgid */ - { compat(2,hpux_ssig) }, /* 48 = old ssig */ - { 0, nosys }, /* 49 = reserved for USG */ - { 0, nosys }, /* 50 = reserved for USG */ - { 1, notimp }, /* 51 = acct (unimplemented) */ - { 0, nosys }, /* 52 = nosys */ - { 0, nosys }, /* 53 = nosys */ - { 3, hpux_ioctl }, /* 54 = ioctl */ - { 4, notimp }, /* 55 = reboot (unimplemented) */ - { 2, symlink }, /* 56 = symlink */ - { 3, hpux_utssys }, /* 57 = utssys */ - { 3, readlink }, /* 58 = readlink */ - { 3, execve }, /* 59 = execve */ - { 1, umask }, /* 60 = umask */ - { 1, chroot }, /* 61 = chroot */ - { 3, hpux_fcntl }, /* 62 = fcntl */ - { 2, hpux_ulimit }, /* 63 = ulimit */ - { 0, nosys }, /* 64 = nosys */ - { 0, nosys }, /* 65 = nosys */ - { 0, hpux_vfork }, /* 66 = vfork */ - { 0, hpux_read }, /* 67 = vread */ - { 0, hpux_write }, /* 68 = vwrite */ - { 0, nosys }, /* 69 = nosys */ - { 0, nosys }, /* 70 = nosys */ - { 6, hpux_mmap }, /* 71 = mmap */ - { 0, nosys }, /* 72 = nosys */ - { 2, munmap }, /* 73 = munmap */ - { 3, notimp }, /* 74 = mprotect (unimplemented) */ - { 0, nosys }, /* 75 = nosys */ - { 0, nosys }, /* 76 = nosys */ - { 0, nosys }, /* 77 = nosys */ - { 0, nosys }, /* 78 = nosys */ - { 2, getgroups }, /* 79 = getgroups */ - { 2, setgroups }, /* 80 = setgroups */ - { 1, hpux_getpgrp2 }, /* 81 = getpgrp2 */ - { 2, hpux_setpgrp2 }, /* 82 = setpgrp2 */ - { 3, setitimer }, /* 83 = setitimer */ - { 3, hpux_wait3 }, /* 84 = wait3 */ - { 5, notimp }, /* 85 = swapon (unimplemented) */ - { 2, getitimer }, /* 86 = getitimer */ - { 0, nosys }, /* 87 = nosys */ - { 0, nosys }, /* 88 = nosys */ - { 0, nosys }, /* 89 = nosys */ - { 2, dup2 }, /* 90 = dup2 */ - { 0, nosys }, /* 91 = nosys */ - { 2, hpux_fstat }, /* 92 = fstat */ - { 5, select }, /* 93 = select */ - { 0, nosys }, /* 94 = nosys */ - { 1, fsync }, /* 95 = fsync */ - { 0, nosys }, /* 96 = nosys */ - { 0, nosys }, /* 97 = nosys */ - { 0, nosys }, /* 98 = nosys */ - { 0, nosys }, /* 99 = nosys */ - { 0, nosys }, /* 100 = nosys */ - { 0, nosys }, /* 101 = nosys */ - { 0, nosys }, /* 102 = nosys */ - { 1, sigreturn }, /* 103 = sigreturn */ - { 0, nosys }, /* 104 = nosys */ - { 0, nosys }, /* 105 = nosys */ - { 0, nosys }, /* 106 = nosys */ - { 0, nosys }, /* 107 = nosys */ - { 3, hpux_sigvec }, /* 108 = sigvec */ - { 1, hpux_sigblock }, /* 109 = sigblock */ - { 1, hpux_sigsetmask }, /* 110 = sigsetmask */ - { 1, hpux_sigpause }, /* 111 = sigpause */ - { 2, osigstack }, /* 112 = osigstack */ - { 0, nosys }, /* 113 = nosys */ - { 0, nosys }, /* 114 = nosys */ - { 0, nosys }, /* 115 = nosys */ - { 2, gettimeofday }, /* 116 = gettimeofday */ - { 0, nosys }, /* 117 = nosys */ - { 0, nosys }, /* 118 = nosys */ - { 3, notimp }, /* 119 = hpib_io_stub (unimplemented) */ - { 3, hpux_readv }, /* 120 = readv */ - { 3, hpux_writev }, /* 121 = writev */ - { 2, settimeofday }, /* 122 = settimeofday */ - { 3, fchown }, /* 123 = fchown */ - { 2, fchmod }, /* 124 = fchmod */ - { 0, nosys }, /* 125 = nosys */ - { 3, hpux_setresuid }, /* 126 = setresuid */ - { 3, hpux_setresgid }, /* 127 = setresgid */ - { 2, rename }, /* 128 = rename */ - { compat(2,truncate) }, /* 129 = old truncate */ - { compat(2,ftruncate) }, /* 130 = old ftruncate */ - { 0, nosys }, /* 131 = nosys */ - { 1, hpux_sysconf }, /* 132 = sysconf */ - { 0, nosys }, /* 133 = nosys */ - { 0, nosys }, /* 134 = nosys */ - { 0, nosys }, /* 135 = nosys */ - { 2, mkdir }, /* 136 = mkdir */ - { 1, rmdir }, /* 137 = rmdir */ - { 0, nosys }, /* 138 = nosys */ - { 0, nosys }, /* 139 = nosys */ - { 0, nosys }, /* 140 = nosys */ - { 0, nosys }, /* 141 = nosys */ - { 0, nosys }, /* 142 = nosys */ - { 0, nosys }, /* 143 = nosys */ - { compat(2,getrlimit) }, /* 144 = old getrlimit */ - { compat(2,setrlimit) }, /* 145 = old setrlimit */ - { 0, nosys }, /* 146 = nosys */ - { 0, nosys }, /* 147 = nosys */ - { 0, nosys }, /* 148 = nosys */ - { 0, nosys }, /* 149 = nosys */ - { 0, nosys }, /* 150 = nosys */ - { 3, notimp }, /* 151 = privgrp (unimplemented) */ - { 2, hpux_rtprio }, /* 152 = rtprio */ - { 1, notimp }, /* 153 = plock (unimplemented) */ - { 2, hpux_netioctl }, /* 154 = netioctl */ - { 4, hpux_lockf }, /* 155 = lockf */ -#ifdef SYSVSEM - { 3, semget }, /* 156 = semget */ - { 4, semctl }, /* 157 = semctl */ - { 3, semop }, /* 158 = semop */ -#else - { 3, notimp }, /* 156 = semget (unimplemented) */ - { 4, notimp }, /* 157 = semctl (unimplemented) */ - { 3, notimp }, /* 158 = semop (unimplemented) */ -#endif -#ifdef SYSVMSG - { 2, msgget }, /* 159 = msgget */ - { 3, msgctl }, /* 160 = msgctl */ - { 4, msgsnd }, /* 161 = msgsnd */ - { 5, msgrcv }, /* 162 = msgrcv */ -#else - { 2, notimp }, /* 159 = msgget (unimplemented) */ - { 3, notimp }, /* 160 = msgctl (unimplemented) */ - { 4, notimp }, /* 161 = msgsnd (unimplemented) */ - { 5, notimp }, /* 162 = msgrcv (unimplemented) */ -#endif -#ifdef SYSVSHM - { 3, shmget }, /* 163 = shmget */ - { 3, hpux_shmctl }, /* 164 = shmctl */ - { 3, shmat }, /* 165 = shmat */ - { 1, shmdt }, /* 166 = shmdt */ -#else - { 3, notimp }, /* 163 = shmget (unimplemented) */ - { 3, notimp }, /* 164 = shmctl (unimplemented) */ - { 3, notimp }, /* 165 = shmat (unimplemented) */ - { 1, notimp }, /* 166 = shmdt (unimplemented) */ -#endif - { 1, hpux_advise }, /* 167 = m68020_advise */ - { 2, notimp }, /* 168 = nsp_init (unimplemented) */ - { 3, notimp }, /* 169 = cluster (unimplemented) */ - { 4, notimp }, /* 170 = mkrnod (unimplemented) */ - { 0, nosys }, /* 171 = nosys */ - { 0, notimp }, /* 172 = unsp_open (unimplemented) */ - { 0, nosys }, /* 173 = nosys */ - { 3, hpux_getcontext }, /* 174 = getcontext */ - { 0, nosys }, /* 175 = nosys */ - { 0, nosys }, /* 176 = nosys */ - { 0, nosys }, /* 177 = nosys */ - { 0, notimp }, /* 178 = lsync (unimplemented) */ - { 0, nosys }, /* 179 = nosys */ - { 0, notimp }, /* 180 = mysite (unimplemented) */ - { 1, notimp }, /* 181 = sitels (unimplemented) */ - { 0, nosys }, /* 182 = nosys */ - { 0, nosys }, /* 183 = nosys */ - { 4, notimp }, /* 184 = dskless_stats (unimplemented) */ - { 0, nosys }, /* 185 = nosys */ - { 3, notimp }, /* 186 = setacl (unimplemented) */ - { 3, notimp }, /* 187 = fsetacl (unimplemented) */ - { 3, notimp }, /* 188 = getacl (unimplemented) */ - { 3, notimp }, /* 189 = fgetacl (unimplemented) */ - { 6, hpux_getaccess }, /* 190 = getaccess */ - { 0, notimp }, /* 191 = getaudid (unimplemented) */ - { 1, notimp }, /* 192 = setaudid (unimplemented) */ - { 0, notimp }, /* 193 = getaudproc (unimplemented) */ - { 1, notimp }, /* 194 = setaudproc (unimplemented) */ - { 2, notimp }, /* 195 = getevent (unimplemented) */ - { 2, notimp }, /* 196 = setevent (unimplemented) */ - { 1, notimp }, /* 197 = audwrite (unimplemented) */ - { 1, notimp }, /* 198 = audswitch (unimplemented) */ - { 4, notimp }, /* 199 = audctl (unimplemented) */ - { 3, hpux_waitpid }, /* 200 = waitpid */ - { 0, nosys }, /* 201 = nosys */ - { 0, nosys }, /* 202 = nosys */ - { 0, nosys }, /* 203 = nosys */ - { 0, nosys }, /* 204 = nosys */ - { 0, nosys }, /* 205 = nosys */ - { 0, nosys }, /* 206 = nosys */ - { 0, nosys }, /* 207 = nosys */ - { 0, nosys }, /* 208 = nosys */ - { 0, nosys }, /* 209 = nosys */ - { 0, nosys }, /* 210 = nosys */ - { 0, nosys }, /* 211 = nosys */ - { 0, nosys }, /* 212 = nosys */ - { 0, nosys }, /* 213 = nosys */ - { 0, nosys }, /* 214 = nosys */ - { 0, nosys }, /* 215 = nosys */ - { 0, nosys }, /* 216 = nosys */ - { 0, nosys }, /* 217 = nosys */ - { 0, nosys }, /* 218 = nosys */ - { 0, nosys }, /* 219 = nosys */ - { 0, nosys }, /* 220 = nosys */ - { 0, nosys }, /* 221 = nosys */ - { 0, nosys }, /* 222 = nosys */ - { 0, nosys }, /* 223 = nosys */ - { 0, nosys }, /* 224 = nosys */ - { 2, notimp }, /* 225 = pathconf (unimplemented) */ - { 2, notimp }, /* 226 = fpathconf (unimplemented) */ - { 0, nosys }, /* 227 = nosys */ - { 0, nosys }, /* 228 = nosys */ - { 0, notimp }, /* 229 = async_daemon (unimplemented) */ - { 3, notimp }, /* 230 = nfs_fcntl (unimplemented) */ - { compat(4,getdirentries) }, /* 231 = old getdirentries */ - { compat(2,getdomainname) }, /* 232 = old getdomainname */ - { 2, notimp }, /* 233 = nfs_getfh (unimplemented) */ - { 4, notimp }, /* 234 = vfsmount (unimplemented) */ - { 1, notimp }, /* 235 = nfs_svc (unimplemented) */ - { compat(2,setdomainname) }, /* 236 = old setdomainname */ - { 2, notimp }, /* 237 = statfs (unimplemented) */ - { 2, notimp }, /* 238 = fstatfs (unimplemented) */ - { 3, hpux_sigaction }, /* 239 = sigaction */ - { 3, hpux_sigprocmask }, /* 240 = sigprocmask */ - { 1, hpux_sigpending }, /* 241 = sigpending */ - { 1, hpux_sigsuspend }, /* 242 = sigsuspend */ - { 4, notimp }, /* 243 = fsctl (unimplemented) */ - { 0, nosys }, /* 244 = nosys */ - { 3, notimp }, /* 245 = pstat (unimplemented) */ - { 0, nosys }, /* 246 = nosys */ - { 0, nosys }, /* 247 = nosys */ - { 0, nosys }, /* 248 = nosys */ - { 0, nosys }, /* 249 = nosys */ - { 0, nosys }, /* 250 = nosys */ - { 0, nosys }, /* 251 = nosys */ - { 0, nosys }, /* 252 = nosys */ - { 0, nosys }, /* 253 = nosys */ - { 0, nosys }, /* 254 = nosys */ - { 0, nosys }, /* 255 = nosys */ - { 0, nosys }, /* 256 = nosys */ - { 0, nosys }, /* 257 = nosys */ - { 0, nosys }, /* 258 = nosys */ - { 0, nosys }, /* 259 = nosys */ - { 0, nosys }, /* 260 = nosys */ - { 0, nosys }, /* 261 = nosys */ - { 0, nosys }, /* 262 = nosys */ - { 0, nosys }, /* 263 = nosys */ - { 0, nosys }, /* 264 = nosys */ - { 0, nosys }, /* 265 = nosys */ - { 0, nosys }, /* 266 = nosys */ - { 0, nosys }, /* 267 = nosys */ - { compat(0,getdtablesize) }, /* 268 = old getnumfds */ - { 0, nosys }, /* 269 = nosys */ - { 0, nosys }, /* 270 = nosys */ - { 0, nosys }, /* 271 = nosys */ - { 1, fchdir }, /* 272 = fchdir */ - { 0, nosys }, /* 273 = nosys */ - { 0, nosys }, /* 274 = nosys */ - { compat(3,accept) }, /* 275 = old accept */ - { 3, bind }, /* 276 = bind */ - { 3, connect }, /* 277 = connect */ - { compat(3,getpeername) }, /* 278 = old getpeername */ - { compat(3,getsockname) }, /* 279 = old getsockname */ - { 5, getsockopt }, /* 280 = getsockopt */ - { 2, listen }, /* 281 = listen */ - { compat(4,recv) }, /* 282 = old recv */ - { compat(6,recvfrom) }, /* 283 = old recvfrom */ - { compat(3,recvmsg) }, /* 284 = old recvmsg */ - { compat(4,send) }, /* 285 = old send */ - { compat(3,sendmsg) }, /* 286 = old sendmsg */ - { 6, sendto }, /* 287 = sendto */ - { 5, hpux_setsockopt2 }, /* 288 = setsockopt2 */ - { 2, shutdown }, /* 289 = shutdown */ - { 3, socket }, /* 290 = socket */ - { 4, socketpair }, /* 291 = socketpair */ - { 0, nosys }, /* 292 = nosys */ - { 0, nosys }, /* 293 = nosys */ - { 0, nosys }, /* 294 = nosys */ - { 0, nosys }, /* 295 = nosys */ - { 0, nosys }, /* 296 = nosys */ - { 0, nosys }, /* 297 = nosys */ - { 0, nosys }, /* 298 = nosys */ - { 0, nosys }, /* 299 = nosys */ - { 0, nosys }, /* 300 = nosys */ - { 0, nosys }, /* 301 = nosys */ - { 0, nosys }, /* 302 = nosys */ - { 0, nosys }, /* 303 = nosys */ - { 0, nosys }, /* 304 = nosys */ - { 0, nosys }, /* 305 = nosys */ - { 0, nosys }, /* 306 = nosys */ - { 0, nosys }, /* 307 = nosys */ - { 0, nosys }, /* 308 = nosys */ - { 0, nosys }, /* 309 = nosys */ - { 0, nosys }, /* 310 = nosys */ - { 0, nosys }, /* 311 = nosys */ -#ifdef SYSVSHM - { 4, semctl }, /* 312 = nsemctl */ -#else - { 4, notimp }, /* 312 = nsemctl (unimplemented) */ -#endif -#ifdef SYSVMSG - { 3, msgctl }, /* 313 = nmsgctl */ -#else - { 3, notimp }, /* 313 = nmsgctl (unimplemented) */ -#endif -#ifdef SYSVSHM - { 3, hpux_nshmctl }, /* 314 = nshmctl */ -#else - { 3, notimp }, /* 314 = nshmctl (unimplemented) */ -#endif -}; - -int hpux_nsysent = sizeof(hpux_sysent) / sizeof(hpux_sysent[0]); diff --git a/sys/arch/hp300/hpux/hpux_termio.h b/sys/arch/hp300/hpux/hpux_termio.h deleted file mode 100644 index a9bf08df4936..000000000000 --- a/sys/arch/hp300/hpux/hpux_termio.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: hpux_termio.h 1.1 90/07/09$ - * - * from: @(#)hpux_termio.h 8.1 (Berkeley) 6/10/93 - * $Id: hpux_termio.h,v 1.5 1994/05/23 08:04:24 mycroft Exp $ - */ - -/* HP-UX termio stuff */ - -#define HPUXNCC 8 - -/* control characters */ -#define HPUXVINTR 0 -#define HPUXVQUIT 1 -#define HPUXVERASE 2 -#define HPUXVKILL 3 -#define HPUXVEOF 4 -#define HPUXVEOL 5 -#define HPUXVMIN 4 -#define HPUXVTIME 5 -#define HPUXVEOL2 6 -#define HPUXVSWTCH 7 - -/* input modes */ -#define TIO_IGNBRK 0x00000001 /* 0000001 */ -#define TIO_BRKINT 0x00000002 /* 0000002 */ -#define TIO_IGNPAR 0x00000004 /* 0000004 */ -#define TIO_PARMRK 0x00000008 /* 0000010 */ -#define TIO_INPCK 0x00000010 /* 0000020 */ -#define TIO_ISTRIP 0x00000020 /* 0000040 */ -#define TIO_INLCR 0x00000040 /* 0000100 */ -#define TIO_IGNCR 0x00000080 /* 0000200 */ -#define TIO_ICRNL 0x00000100 /* 0000400 */ -#define TIO_IUCLC 0x00000200 /* 0001000 */ -#define TIO_IXON 0x00000400 /* 0002000 */ -#define TIO_IXANY 0x00000800 /* 0004000 */ -#define TIO_IXOFF 0x00001000 /* 0010000 */ -#define TIO_IENQAK 0x00002000 /* 0020000 */ - -/* output modes */ -#define TIO_OPOST 0x00000001 /* 0000001 */ -#define TIO_OLCUC 0x00000002 /* 0000002 */ -#define TIO_ONLCR 0x00000004 /* 0000004 */ -#define TIO_OCRNL 0x00000008 /* 0000010 */ -#define TIO_ONOCR 0x00000010 /* 0000020 */ -#define TIO_ONLRET 0x00000020 /* 0000040 */ -#define TIO_OFILL 0x00000040 /* 0000100 */ -#define TIO_OFDEL 0x00000080 /* 0000200 */ -#define TIO_NLDLY 0x00000100 /* 0000400 */ -#define TIO_NL0 0 -#define TIO_NL1 0x00000100 /* 0000400 */ -#define TIO_CRDLY 0x00000600 /* 0003000 */ -#define TIO_CR0 0 -#define TIO_CR1 0x00000200 /* 0001000 */ -#define TIO_CR2 0x00000400 /* 0002000 */ -#define TIO_CR3 0x00000600 /* 0003000 */ -#define TIO_TABDLY 0x00001800 /* 0014000 */ -#define TIO_TAB0 0 -#define TIO_TAB1 0x00000800 /* 0004000 */ -#define TIO_TAB2 0x00001000 /* 0010000 */ -#define TIO_TAB3 0x00001800 /* 0014000 */ -#define TIO_BSDLY 0x00002000 /* 0020000 */ -#define TIO_BS0 0 -#define TIO_BS1 0x00002000 /* 0020000 */ -#define TIO_VTDLY 0x00004000 /* 0040000 */ -#define TIO_VT0 0 -#define TIO_VT1 0x00004000 /* 0040000 */ -#define TIO_FFDLY 0x00008000 /* 0100000 */ -#define TIO_FF0 0 -#define TIO_FF1 0x00008000 /* 0100000 */ - -/* control modes */ -#define TIO_CBAUD 0x0000001f /* 0000037 */ -#define TIO_B0 0 -#define TIO_B50 0x00000001 /* 0000001 */ -#define TIO_B75 0x00000002 /* 0000002 */ -#define TIO_B110 0x00000003 /* 0000003 */ -#define TIO_B134 0x00000004 /* 0000004 */ -#define TIO_B150 0x00000005 /* 0000005 */ -#define TIO_B200 0x00000006 /* 0000006 */ -#define TIO_B300 0x00000007 /* 0000007 */ -#define TIO_B600 0x00000008 /* 0000010 */ -#define TIO_B900 0x00000009 /* 0000011 */ -#define TIO_B1200 0x0000000a /* 0000012 */ -#define TIO_B1800 0x0000000b /* 0000013 */ -#define TIO_B2400 0x0000000c /* 0000014 */ -#define TIO_B3600 0x0000000d /* 0000015 */ -#define TIO_B4800 0x0000000e /* 0000016 */ -#define TIO_B7200 0x0000000f /* 0000017 */ -#define TIO_B9600 0x00000010 /* 0000020 */ -#define TIO_B19200 0x00000011 /* 0000021 */ -#define TIO_B38400 0x00000012 /* 0000022 */ -#define TIO_EXTA 0x0000001e /* 0000036 */ -#define TIO_EXTB 0x0000001f /* 0000037 */ -#define TIO_CSIZE 0x00000060 /* 0000140 */ -#define TIO_CS5 0 -#define TIO_CS6 0x00000020 /* 0000040 */ -#define TIO_CS7 0x00000040 /* 0000100 */ -#define TIO_CS8 0x00000060 /* 0000140 */ -#define TIO_CSTOPB 0x00000080 /* 0000200 */ -#define TIO_CREAD 0x00000100 /* 0000400 */ -#define TIO_PARENB 0x00000200 /* 0001000 */ -#define TIO_PARODD 0x00000400 /* 0002000 */ -#define TIO_HUPCL 0x00000800 /* 0004000 */ -#define TIO_CLOCAL 0x00001000 /* 0010000 */ -#define TIO_CRTS 0x00002000 /* 0020000 */ /* Obsolete */ - -/* line discipline 0 modes */ -#define TIO_ISIG 0x00000001 /* 0000001 */ -#define TIO_ICANON 0x00000002 /* 0000002 */ -#define TIO_XCASE 0x00000004 /* 0000004 */ -#define TIO_ECHO 0x00000008 /* 0000010 */ -#define TIO_ECHOE 0x00000010 /* 0000020 */ -#define TIO_ECHOK 0x00000020 /* 0000040 */ -#define TIO_ECHONL 0x00000040 /* 0000100 */ -#define TIO_NOFLSH 0x00000080 /* 0000200 */ - -struct hpux_termio { - u_short c_iflag; /* input modes */ - u_short c_oflag; /* output modes */ - u_short c_cflag; /* control modes */ - u_short c_lflag; /* line discipline modes */ - char c_line; /* line discipline */ - u_char c_cc[HPUXNCC]; /* control chars */ -}; - -#define HPUXTCGETA _IOR('T', 1, struct hpux_termio) -#define HPUXTCSETA _IOW('T', 2, struct hpux_termio) -#define HPUXTCSETAW _IOW('T', 3, struct hpux_termio) -#define HPUXTCSETAF _IOW('T', 4, struct hpux_termio) - -/* HP-UX termios stuff */ - -#define HPUXNCCS 16 - -/* control characters */ -#define HPUXVMINS 11 /* different than termio */ -#define HPUXVTIMES 12 /* different than termio */ -#define HPUXVSUSP 13 -#define HPUXVSTART 14 -#define HPUXVSTOP 15 - -struct hpux_termios { - u_int c_iflag; /* input modes */ - u_int c_oflag; /* output modes */ - u_int c_cflag; /* control modes */ - u_int c_lflag; /* line discipline modes */ - u_int c_reserved; /* future use */ - u_char c_cc[HPUXNCCS]; /* control chars */ -}; - -#define HPUXTCGETATTR _IOR('T', 16, struct hpux_termios) -#define HPUXTCSETATTR _IOW('T', 17, struct hpux_termios) -#define HPUXTCSETATTRD _IOW('T', 18, struct hpux_termios) -#define HPUXTCSETATTRF _IOW('T', 19, struct hpux_termios) diff --git a/sys/arch/hp300/hpux/hpux_tty.c b/sys/arch/hp300/hpux/hpux_tty.c deleted file mode 100644 index bf392336377f..000000000000 --- a/sys/arch/hp300/hpux/hpux_tty.c +++ /dev/null @@ -1,539 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah $Hdr: hpux_tty.c 1.14 93/08/05$ - * - * from: @(#)hpux_tty.c 8.3 (Berkeley) 1/12/94 - * $Id: hpux_tty.c,v 1.6 1994/05/23 08:04:26 mycroft Exp $ - */ - -/* - * stty/gtty/termio emulation stuff - */ - -#ifndef COMPAT_43 -#define COMPAT_43 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* - * Map BSD/POSIX style termios info to and from SYS5 style termio stuff. - */ -hpux_termio(fd, com, data, p) - int fd, com; - caddr_t data; - struct proc *p; -{ - struct file *fp; - struct termios tios; - struct hpux_termios htios; - int line, error, (*ioctlrout)(); - int newi = 0; - - fp = p->p_fd->fd_ofiles[fd]; - ioctlrout = fp->f_ops->fo_ioctl; - switch (com) { - case HPUXTCGETATTR: - newi = 1; - /* fall into ... */ - case HPUXTCGETA: - /* - * Get BSD terminal state - */ - if (error = (*ioctlrout)(fp, TIOCGETA, (caddr_t)&tios, p)) - break; - bzero((char *)&htios, sizeof htios); - /* - * Set iflag. - * Same through ICRNL, no BSD equivs for IUCLC, IENQAK - */ - htios.c_iflag = tios.c_iflag & 0x1ff; - if (tios.c_iflag & IXON) - htios.c_iflag |= TIO_IXON; - if (tios.c_iflag & IXOFF) - htios.c_iflag |= TIO_IXOFF; - if (tios.c_iflag & IXANY) - htios.c_iflag |= TIO_IXANY; - /* - * Set oflag. - * No BSD equivs for OLCUC/OCRNL/ONOCR/ONLRET/OFILL/OFDEL - * or any of the delays. - */ - if (tios.c_oflag & OPOST) - htios.c_oflag |= TIO_OPOST; - if (tios.c_oflag & ONLCR) - htios.c_oflag |= TIO_ONLCR; - if (tios.c_oflag & OXTABS) - htios.c_oflag |= TIO_TAB3; - /* - * Set cflag. - * Baud from ospeed, rest from cflag. - */ - htios.c_cflag = bsdtohpuxbaud(tios.c_ospeed); - switch (tios.c_cflag & CSIZE) { - case CS5: - htios.c_cflag |= TIO_CS5; break; - case CS6: - htios.c_cflag |= TIO_CS6; break; - case CS7: - htios.c_cflag |= TIO_CS7; break; - case CS8: - htios.c_cflag |= TIO_CS8; break; - } - if (tios.c_cflag & CSTOPB) - htios.c_cflag |= TIO_CSTOPB; - if (tios.c_cflag & CREAD) - htios.c_cflag |= TIO_CREAD; - if (tios.c_cflag & PARENB) - htios.c_cflag |= TIO_PARENB; - if (tios.c_cflag & PARODD) - htios.c_cflag |= TIO_PARODD; - if (tios.c_cflag & HUPCL) - htios.c_cflag |= TIO_HUPCL; - if (tios.c_cflag & CLOCAL) - htios.c_cflag |= TIO_CLOCAL; - /* - * Set lflag. - * No BSD equiv for XCASE. - */ - if (tios.c_lflag & ECHOE) - htios.c_lflag |= TIO_ECHOE; - if (tios.c_lflag & ECHOK) - htios.c_lflag |= TIO_ECHOK; - if (tios.c_lflag & ECHO) - htios.c_lflag |= TIO_ECHO; - if (tios.c_lflag & ECHONL) - htios.c_lflag |= TIO_ECHONL; - if (tios.c_lflag & ISIG) - htios.c_lflag |= TIO_ISIG; - if (tios.c_lflag & ICANON) - htios.c_lflag |= TIO_ICANON; - if (tios.c_lflag & NOFLSH) - htios.c_lflag |= TIO_NOFLSH; - /* - * Line discipline - */ - if (!newi) { - line = 0; - (void) (*ioctlrout)(fp, TIOCGETD, (caddr_t)&line, p); - htios.c_reserved = line; - } - /* - * Set editing chars. - * No BSD equiv for VSWTCH. - */ - htios.c_cc[HPUXVINTR] = tios.c_cc[VINTR]; - htios.c_cc[HPUXVQUIT] = tios.c_cc[VQUIT]; - htios.c_cc[HPUXVERASE] = tios.c_cc[VERASE]; - htios.c_cc[HPUXVKILL] = tios.c_cc[VKILL]; - htios.c_cc[HPUXVEOF] = tios.c_cc[VEOF]; - htios.c_cc[HPUXVEOL] = tios.c_cc[VEOL]; - htios.c_cc[HPUXVEOL2] = tios.c_cc[VEOL2]; - htios.c_cc[HPUXVSWTCH] = 0; -#if 1 - /* - * XXX since VMIN and VTIME are not implemented, - * we need to return something reasonable. - * Otherwise a GETA/SETA combo would always put - * the tty in non-blocking mode (since VMIN == VTIME == 0). - */ - if (fp->f_flag & FNONBLOCK) { - htios.c_cc[HPUXVMINS] = 0; - htios.c_cc[HPUXVTIMES] = 0; - } else { - htios.c_cc[HPUXVMINS] = 6; - htios.c_cc[HPUXVTIMES] = 1; - } -#else - htios.c_cc[HPUXVMINS] = tios.c_cc[VMIN]; - htios.c_cc[HPUXVTIMES] = tios.c_cc[VTIME]; -#endif - htios.c_cc[HPUXVSUSP] = tios.c_cc[VSUSP]; - htios.c_cc[HPUXVSTART] = tios.c_cc[VSTART]; - htios.c_cc[HPUXVSTOP] = tios.c_cc[VSTOP]; - if (newi) - bcopy((char *)&htios, data, sizeof htios); - else - termiostotermio(&htios, (struct hpux_termio *)data); - break; - - case HPUXTCSETATTR: - case HPUXTCSETATTRD: - case HPUXTCSETATTRF: - newi = 1; - /* fall into ... */ - case HPUXTCSETA: - case HPUXTCSETAW: - case HPUXTCSETAF: - /* - * Get old characteristics and determine if we are a tty. - */ - if (error = (*ioctlrout)(fp, TIOCGETA, (caddr_t)&tios, p)) - break; - if (newi) - bcopy(data, (char *)&htios, sizeof htios); - else - termiototermios((struct termio *)data, &htios, &tios); - /* - * Set iflag. - * Same through ICRNL, no HP-UX equiv for IMAXBEL - */ - tios.c_iflag &= ~(IXON|IXOFF|IXANY|0x1ff); - tios.c_iflag |= htios.c_iflag & 0x1ff; - if (htios.c_iflag & TIO_IXON) - tios.c_iflag |= IXON; - if (htios.c_iflag & TIO_IXOFF) - tios.c_iflag |= IXOFF; - if (htios.c_iflag & TIO_IXANY) - tios.c_iflag |= IXANY; - /* - * Set oflag. - * No HP-UX equiv for ONOEOT - */ - tios.c_oflag &= ~(OPOST|ONLCR|OXTABS); - if (htios.c_oflag & TIO_OPOST) - tios.c_oflag |= OPOST; - if (htios.c_oflag & TIO_ONLCR) - tios.c_oflag |= ONLCR; - if (htios.c_oflag & TIO_TAB3) - tios.c_oflag |= OXTABS; - /* - * Set cflag. - * No HP-UX equiv for CCTS_OFLOW/CCTS_IFLOW/MDMBUF - */ - tios.c_cflag &= - ~(CSIZE|CSTOPB|CREAD|PARENB|PARODD|HUPCL|CLOCAL); - switch (htios.c_cflag & TIO_CSIZE) { - case TIO_CS5: - tios.c_cflag |= CS5; break; - case TIO_CS6: - tios.c_cflag |= CS6; break; - case TIO_CS7: - tios.c_cflag |= CS7; break; - case TIO_CS8: - tios.c_cflag |= CS8; break; - } - if (htios.c_cflag & TIO_CSTOPB) - tios.c_cflag |= CSTOPB; - if (htios.c_cflag & TIO_CREAD) - tios.c_cflag |= CREAD; - if (htios.c_cflag & TIO_PARENB) - tios.c_cflag |= PARENB; - if (htios.c_cflag & TIO_PARODD) - tios.c_cflag |= PARODD; - if (htios.c_cflag & TIO_HUPCL) - tios.c_cflag |= HUPCL; - if (htios.c_cflag & TIO_CLOCAL) - tios.c_cflag |= CLOCAL; - /* - * Set lflag. - * No HP-UX equiv for ECHOKE/ECHOPRT/ECHOCTL - * IEXTEN treated as part of ICANON - */ - tios.c_lflag &= ~(ECHOE|ECHOK|ECHO|ISIG|ICANON|IEXTEN|NOFLSH); - if (htios.c_lflag & TIO_ECHOE) - tios.c_lflag |= ECHOE; - if (htios.c_lflag & TIO_ECHOK) - tios.c_lflag |= ECHOK; - if (htios.c_lflag & TIO_ECHO) - tios.c_lflag |= ECHO; - if (htios.c_lflag & TIO_ECHONL) - tios.c_lflag |= ECHONL; - if (htios.c_lflag & TIO_ISIG) - tios.c_lflag |= ISIG; - if (htios.c_lflag & TIO_ICANON) - tios.c_lflag |= (ICANON|IEXTEN); - if (htios.c_lflag & TIO_NOFLSH) - tios.c_lflag |= NOFLSH; - /* - * Set editing chars. - * No HP-UX equivs of VWERASE/VREPRINT/VDSUSP/VLNEXT - * /VDISCARD/VSTATUS/VERASE2 - */ - tios.c_cc[VINTR] = htios.c_cc[HPUXVINTR]; - tios.c_cc[VQUIT] = htios.c_cc[HPUXVQUIT]; - tios.c_cc[VERASE] = htios.c_cc[HPUXVERASE]; - tios.c_cc[VKILL] = htios.c_cc[HPUXVKILL]; - tios.c_cc[VEOF] = htios.c_cc[HPUXVEOF]; - tios.c_cc[VEOL] = htios.c_cc[HPUXVEOL]; - tios.c_cc[VEOL2] = htios.c_cc[HPUXVEOL2]; - tios.c_cc[VMIN] = htios.c_cc[HPUXVMINS]; - tios.c_cc[VTIME] = htios.c_cc[HPUXVTIMES]; - tios.c_cc[VSUSP] = htios.c_cc[HPUXVSUSP]; - tios.c_cc[VSTART] = htios.c_cc[HPUXVSTART]; - tios.c_cc[VSTOP] = htios.c_cc[HPUXVSTOP]; - - /* - * Set the new stuff - */ - if (com == HPUXTCSETA || com == HPUXTCSETATTR) - com = TIOCSETA; - else if (com == HPUXTCSETAW || com == HPUXTCSETATTRD) - com = TIOCSETAW; - else - com = TIOCSETAF; - error = (*ioctlrout)(fp, com, (caddr_t)&tios, p); - if (error == 0) { - /* - * Set line discipline - */ - if (!newi) { - line = htios.c_reserved; - (void) (*ioctlrout)(fp, TIOCSETD, - (caddr_t)&line, p); - } - /* - * Set non-blocking IO if VMIN == VTIME == 0, clear - * if not. Should handle the other cases as well. - * Note it isn't correct to just turn NBIO off like - * we do as it could be on as the result of a fcntl - * operation. - * - * XXX - wouldn't need to do this at all if VMIN/VTIME - * were implemented. - */ - { - struct hpux_fcntl_args { - int fdes, cmd, arg; - } args; - int flags, nbio; - - nbio = (htios.c_cc[HPUXVMINS] == 0 && - htios.c_cc[HPUXVTIMES] == 0); - if (nbio && (fp->f_flag & FNONBLOCK) == 0 || - !nbio && (fp->f_flag & FNONBLOCK)) { - args.fdes = fd; - args.cmd = F_GETFL; - args.arg = 0; - (void) hpux_fcntl(p, &args, &flags); - if (nbio) - flags |= HPUXNDELAY; - else - flags &= ~HPUXNDELAY; - args.cmd = F_SETFL; - args.arg = flags; - (void) hpux_fcntl(p, &args, &flags); - } - } - } - break; - - default: - error = EINVAL; - break; - } - return(error); -} - -termiototermios(tio, tios, bsdtios) - struct hpux_termio *tio; - struct hpux_termios *tios; - struct termios *bsdtios; -{ - int i; - - bzero((char *)tios, sizeof *tios); - tios->c_iflag = tio->c_iflag; - tios->c_oflag = tio->c_oflag; - tios->c_cflag = tio->c_cflag; - tios->c_lflag = tio->c_lflag; - tios->c_reserved = tio->c_line; - for (i = 0; i <= HPUXVSWTCH; i++) - tios->c_cc[i] = tio->c_cc[i]; - if (tios->c_lflag & TIO_ICANON) { - tios->c_cc[HPUXVEOF] = tio->c_cc[HPUXVEOF]; - tios->c_cc[HPUXVEOL] = tio->c_cc[HPUXVEOL]; - tios->c_cc[HPUXVMINS] = 0; - tios->c_cc[HPUXVTIMES] = 0; - } else { - tios->c_cc[HPUXVEOF] = 0; - tios->c_cc[HPUXVEOL] = 0; - tios->c_cc[HPUXVMINS] = tio->c_cc[HPUXVMIN]; - tios->c_cc[HPUXVTIMES] = tio->c_cc[HPUXVTIME]; - } - tios->c_cc[HPUXVSUSP] = bsdtios->c_cc[VSUSP]; - tios->c_cc[HPUXVSTART] = bsdtios->c_cc[VSTART]; - tios->c_cc[HPUXVSTOP] = bsdtios->c_cc[VSTOP]; -} - -termiostotermio(tios, tio) - struct hpux_termios *tios; - struct hpux_termio *tio; -{ - int i; - - tio->c_iflag = tios->c_iflag; - tio->c_oflag = tios->c_oflag; - tio->c_cflag = tios->c_cflag; - tio->c_lflag = tios->c_lflag; - tio->c_line = tios->c_reserved; - for (i = 0; i <= HPUXVSWTCH; i++) - tio->c_cc[i] = tios->c_cc[i]; - if (tios->c_lflag & TIO_ICANON) { - tio->c_cc[HPUXVEOF] = tios->c_cc[HPUXVEOF]; - tio->c_cc[HPUXVEOL] = tios->c_cc[HPUXVEOL]; - } else { - tio->c_cc[HPUXVMIN] = tios->c_cc[HPUXVMINS]; - tio->c_cc[HPUXVTIME] = tios->c_cc[HPUXVTIMES]; - } -} - -bsdtohpuxbaud(bsdspeed) - long bsdspeed; -{ - switch (bsdspeed) { - case B0: return(TIO_B0); - case B50: return(TIO_B50); - case B75: return(TIO_B75); - case B110: return(TIO_B110); - case B134: return(TIO_B134); - case B150: return(TIO_B150); - case B200: return(TIO_B200); - case B300: return(TIO_B300); - case B600: return(TIO_B600); - case B1200: return(TIO_B1200); - case B1800: return(TIO_B1800); - case B2400: return(TIO_B2400); - case B4800: return(TIO_B4800); - case B9600: return(TIO_B9600); - case B19200: return(TIO_B19200); - case B38400: return(TIO_B38400); - default: return(TIO_B0); - } -} - -hpuxtobsdbaud(hpux_speed) - int hpux_speed; -{ - static char hpuxtobsdbaudtab[32] = { - B0, B50, B75, B110, B134, B150, B200, B300, - B600, B0, B1200, B1800, B2400, B0, B4800, B0, - B9600, B19200, B38400, B0, B0, B0, B0, B0, - B0, B0, B0, B0, B0, B0, EXTA, EXTB - }; - - return(hpuxtobsdbaudtab[hpux_speed & TIO_CBAUD]); -} - -#ifdef COMPAT_OHPUX -struct ohpux_sgtty_args { - int fdes; - caddr_t cmarg; -}; -ohpux_gtty(p, uap, retval) - struct proc *p; - struct ohpux_sgtty_args *uap; - int *retval; -{ - - return (getsettty(p, uap->fdes, HPUXTIOCGETP, uap->cmarg)); -} - -ohpux_stty(p, uap, retval) - struct proc *p; - struct ohpux_sgtty_args *uap; - int *retval; -{ - - return (getsettty(p, uap->fdes, HPUXTIOCSETP, uap->cmarg)); -} - -/* - * Simplified version of ioctl() for use by - * gtty/stty and TIOCGETP/TIOCSETP. - */ -getsettty(p, fdes, com, cmarg) - struct proc *p; - int fdes, com; - caddr_t cmarg; -{ - register struct filedesc *fdp = p->p_fd; - register struct file *fp; - struct hpux_sgttyb hsb; - struct sgttyb sb; - int error; - - if (((unsigned)fdes) >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[fdes]) == NULL) - return (EBADF); - if ((fp->f_flag & (FREAD|FWRITE)) == 0) - return (EBADF); - if (com == HPUXTIOCSETP) { - if (error = copyin(cmarg, (caddr_t)&hsb, sizeof hsb)) - return (error); - sb.sg_ispeed = hsb.sg_ispeed; - sb.sg_ospeed = hsb.sg_ospeed; - sb.sg_erase = hsb.sg_erase; - sb.sg_kill = hsb.sg_kill; - sb.sg_flags = hsb.sg_flags & ~(V7_HUPCL|V7_XTABS|V7_NOAL); - if (hsb.sg_flags & V7_XTABS) - sb.sg_flags |= XTABS; - if (hsb.sg_flags & V7_HUPCL) - (void)(*fp->f_ops->fo_ioctl) - (fp, TIOCHPCL, (caddr_t)0, p); - com = TIOCSETP; - } else { - bzero((caddr_t)&hsb, sizeof hsb); - com = TIOCGETP; - } - error = (*fp->f_ops->fo_ioctl)(fp, com, (caddr_t)&sb, p); - if (error == 0 && com == TIOCGETP) { - hsb.sg_ispeed = sb.sg_ispeed; - hsb.sg_ospeed = sb.sg_ospeed; - hsb.sg_erase = sb.sg_erase; - hsb.sg_kill = sb.sg_kill; - hsb.sg_flags = sb.sg_flags & ~(V7_HUPCL|V7_XTABS|V7_NOAL); - if (sb.sg_flags & XTABS) - hsb.sg_flags |= V7_XTABS; - error = copyout((caddr_t)&hsb, cmarg, sizeof hsb); - } - return (error); -} -#endif diff --git a/sys/arch/hp300/hpux/makesyscalls.sh b/sys/arch/hp300/hpux/makesyscalls.sh deleted file mode 100644 index b85030a300fa..000000000000 --- a/sys/arch/hp300/hpux/makesyscalls.sh +++ /dev/null @@ -1,181 +0,0 @@ -#! /bin/sh - -# $NetBSD: makesyscalls.sh,v 1.3 1994/06/30 16:42:47 cgd Exp $ -# -# @(#)makesyscalls.sh 8.2 (Berkeley) 9/9/93 - -set -e - -# name of compat option: -compat=COMPAT_OHPUX - -# output files: -sysnames="hpux_syscalls.c" -syshdr="hpux_syscall.h" -syssw="hpux_sysent.c" - -# tmp files: -sysdcl="sysent.dcl" -syscompat="sysent.compat" -sysent="sysent.switch" - -trap "rm $sysdcl $syscompat $sysent" 0 - -case $# in - 0) echo "Usage: $0 input-file" 1>&2 - exit 1 - ;; -esac - -awk < $1 " - BEGIN { - sysdcl = \"$sysdcl\" - syscompat = \"$syscompat\" - sysent = \"$sysent\" - sysnames = \"$sysnames\" - syshdr = \"$syshdr\" - compat = \"$compat\" - infile = \"$1\" - "' - - printf "/*\n * System call switch table.\n *\n" > sysdcl - printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl - - printf "\n#ifdef %s\n", compat > syscompat - printf "#define compat(n, name) n, __CONCAT(o,name)\n\n" > syscompat - - printf "/*\n * System call names.\n *\n" > sysnames - printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames - - printf "/*\n * System call numbers.\n *\n" > syshdr - printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr - } - NR == 1 { - printf " * created from: NetBSD %s %s %s %s\n */\n\n",$2,$3,$4,$5 > sysdcl - printf "#include \n" > sysdcl - printf "#include \n\n" > sysdcl - printf "int\tnosys(),notimp();\n\n" > sysdcl - - printf "struct sysent hpux_sysent[] = {\n" > sysent - - printf " * created from: NetBSD %s %s %s %s\n */\n\n",$2,$3,$4,$5 > sysnames - printf "char *hpux_syscallnames[] = {\n" > sysnames - - printf " * created from: NetBSD %s %s %s %s\n */\n\n",$2,$3,$4,$5 > syshdr - next - } - NF == 0 || $1 ~ /^;/ { - next - } - $1 ~ /^#[ ]*if/ { - print > sysent - print > sysdcl - print > syscompat - print > sysnames - savesyscall = syscall - next - } - $1 ~ /^#[ ]*else/ { - print > sysent - print > sysdcl - print > syscompat - print > sysnames - syscall = savesyscall - next - } - $1 ~ /^#/ { - print > sysent - print > sysdcl - print > syscompat - print > sysnames - next - } - syscall != $1 { - printf "%s: line %d: syscall number out of sync at %d\n", \ - infile, NR, syscall - printf "line is:\n" - print - exit 1 - } - { comment = $4 - for (i = 5; i <= NF; i++) - comment = comment " " $i - if (NF < 5) - $5 = $4 - } - $2 == "STD" { - printf("int\t%s();\n", $4) > sysdcl - printf("\t{ %d, %s },\t\t\t/* %d = %s */\n", \ - $3, $4, syscall, $5) > sysent - printf("\t\"%s\",\t\t\t/* %d = %s */\n", \ - $5, syscall, $5) > sysnames - printf("#define\tSYS_%s\t%d\n", \ - $5, syscall) > syshdr - syscall++ - next - } - $2 == "COMPAT" { - printf("int\to%s();\n", $4) > syscompat - printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \ - $3, $4, syscall, $5) > sysent - printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \ - $5, syscall, $5) > sysnames - printf("\t\t\t\t/* %d is old %s */\n", \ - syscall, comment) > syshdr - syscall++ - next - } - $2 == "LIBCOMPAT" { - printf("int\to%s();\n", $4) > syscompat - printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \ - $3, $4, syscall, $5) > sysent - printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \ - $5, syscall, $5) > sysnames - printf("#define\tSYS_%s\t%d\t/* compatibility; still used by libc */\n", \ - $5, syscall) > syshdr - syscall++ - next - } - $2 == "OBSOL" { - printf("\t{ 0, nosys },\t\t\t/* %d = obsolete %s */\n", \ - syscall, comment) > sysent - printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \ - $4, syscall, comment) > sysnames - printf("\t\t\t\t/* %d is obsolete %s */\n", \ - syscall, comment) > syshdr - syscall++ - next - } - $2 == "UNIMPL" { - printf("\t{ 0, nosys },\t\t\t/* %d = %s */\n", \ - syscall, comment) > sysent - printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \ - syscall, syscall, comment) > sysnames - syscall++ - next - } - $2 == "NOTIMPL" { - printf("\t{ %d, notimp },\t\t\t/* %d = %s (unimplemented) */\n", \ - $3, syscall, comment) > sysent - printf("\t\"%s\",\t\t\t/* %d = %s (unimplemented) */\n", \ - $4, syscall, comment) > sysnames - syscall++ - next - } - { - printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2 - exit 1 - } - END { - printf("\n#else /* %s */\n", compat) > syscompat - printf("#define compat(n, name) 0, nosys\n") > syscompat - printf("#endif /* %s */\n\n", compat) > syscompat - - printf("};\n\n") > sysent - printf("int\thpux_nsysent = sizeof(hpux_sysent) / sizeof(hpux_sysent[0]);\n") > sysent - - printf("};\n") > sysnames - } ' - -cat $sysdcl $syscompat $sysent >$syssw - -#chmod 444 $sysnames $syshdr $syssw diff --git a/sys/arch/hp300/hpux/syscalls.master b/sys/arch/hp300/hpux/syscalls.master deleted file mode 100644 index f969316d8e3a..000000000000 --- a/sys/arch/hp300/hpux/syscalls.master +++ /dev/null @@ -1,373 +0,0 @@ - $NetBSD: syscalls.master,v 1.5 1994/06/30 16:42:48 cgd Exp $ -; @(#)syscalls.master 8.3 (Berkeley) 2/7/94 -; System call name/number master file (or rather, slave, from HP-UX). -; Processed to created hpux_sysent.c, hpux_syscalls.c and hpux_syscall.h. -; -; from: Utah $Hdr: hpux_sysent.c 1.33 93/08/13$ -; - -; Columns: number type nargs name altname/comments -; number system call number, must be in order -; type one of STD, OBSOL, UNIMPL, COMPAT -; nargs number of arguments -; name name of syscall routine -; altname name of system call if different -; for UNIMPL/OBSOL, name continues with comments - -; types: -; STD always included -; COMPAT included on COMPAT #ifdef -; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h -; OBSOL obsolete, not included in system, only specifies name -; UNIMPL not implemented, placeholder only, call nosys -; NOTIMPL not implemented, placeholder only, call notimp - -; #ifdef's, etc. may be included, and are copied to the output files. - -0 UNIMPL 0 indir or out-of-range -1 STD 1 exit -2 STD 0 hpux_fork fork -3 STD 3 hpux_read read -4 STD 3 hpux_write write -5 STD 3 hpux_open open -6 STD 1 close -7 STD 1 hpux_wait owait -8 STD 2 hpux_creat ocreat -9 STD 2 link -10 STD 1 unlink -11 STD 2 hpux_execv execv -12 STD 1 chdir -13 COMPAT 1 hpux_time time -14 STD 3 mknod -15 STD 2 chmod -16 STD 3 chown -17 STD 1 obreak break -18 COMPAT 2 hpux_stat stat -19 STD 3 olseek -20 STD 0 getpid -21 NOTIMPL 3 mount -22 NOTIMPL 1 umount -23 STD 1 setuid -24 STD 0 getuid -25 COMPAT 1 hpux_stime stime -26 STD 4 hpux_ptrace ptrace -27 COMPAT 1 hpux_alarm alarm -28 COMPAT 2 hpux_fstat fstat -29 COMPAT 0 hpux_pause pause -30 COMPAT 2 hpux_utime utime -31 COMPAT 2 hpux_stty stty -32 COMPAT 2 hpux_gtty gtty -33 STD 2 access -34 COMPAT 1 hpux_nice nice -35 COMPAT 1 hpux_ftime ftime -36 STD 0 sync -37 STD 2 hpux_kill kill -38 STD 2 hpux_stat stat -39 COMPAT 1 hpux_setpgrp setpgrp -40 STD 2 hpux_lstat lstat -41 STD 1 hpux_dup dup -42 STD 0 pipe -43 COMPAT 1 hpux_times times -44 STD 4 profil -45 NOTIMPL 4 ki_syscall -46 STD 1 setgid -47 STD 0 getgid -48 COMPAT 2 hpux_ssig ssig -49 UNIMPL 0 reserved for USG -50 UNIMPL 0 reserved for USG -51 NOTIMPL 1 acct -52 UNIMPL 0 nosys -53 UNIMPL 0 nosys -54 STD 3 hpux_ioctl ioctl -55 NOTIMPL 4 reboot -56 STD 2 symlink -57 STD 3 hpux_utssys utssys -58 STD 3 readlink -59 STD 3 execve -60 STD 1 umask -61 STD 1 chroot -62 STD 3 hpux_fcntl fcntl -63 STD 2 hpux_ulimit ulimit -64 UNIMPL 0 nosys -65 UNIMPL 0 nosys -66 STD 0 hpux_vfork vfork -67 STD 0 hpux_read vread -68 STD 0 hpux_write vwrite -69 UNIMPL 0 nosys -70 UNIMPL 0 nosys -71 STD 6 hpux_mmap mmap -72 UNIMPL 0 nosys -73 STD 2 munmap -74 NOTIMPL 3 mprotect -75 UNIMPL 0 nosys -76 UNIMPL 0 nosys -77 UNIMPL 0 nosys -78 UNIMPL 0 nosys -79 STD 2 getgroups -80 STD 2 setgroups -81 STD 1 hpux_getpgrp2 getpgrp2 -82 STD 2 hpux_setpgrp2 setpgrp2 -83 STD 3 setitimer -84 STD 3 hpux_wait3 wait3 -85 NOTIMPL 5 swapon -86 STD 2 getitimer -87 UNIMPL 0 nosys -88 UNIMPL 0 nosys -89 UNIMPL 0 nosys -90 STD 2 dup2 -91 UNIMPL 0 nosys -92 STD 2 hpux_fstat fstat -93 STD 5 select -94 UNIMPL 0 nosys -95 STD 1 fsync -96 UNIMPL 0 nosys -97 UNIMPL 3 nosys -98 UNIMPL 2 nosys -99 UNIMPL 2 nosys -100 UNIMPL 0 nosys -101 UNIMPL 0 nosys -102 UNIMPL 0 nosys -103 STD 1 sigreturn -104 UNIMPL 2 nosys -105 UNIMPL 0 nosys -106 UNIMPL 0 nosys -107 UNIMPL 0 nosys -108 STD 3 hpux_sigvec sigvec -109 STD 1 hpux_sigblock sigblock -110 STD 1 hpux_sigsetmask sigsetmask -111 STD 1 hpux_sigpause sigpause -112 STD 2 osigstack -113 UNIMPL 0 nosys -114 UNIMPL 0 nosys -115 UNIMPL 0 nosys -116 STD 2 gettimeofday -117 UNIMPL 0 nosys -118 UNIMPL 0 nosys -119 NOTIMPL 3 hpib_io_stub -120 STD 3 hpux_readv readv -121 STD 3 hpux_writev writev -122 STD 2 settimeofday -123 STD 3 fchown -124 STD 2 fchmod -125 UNIMPL 0 nosys -126 STD 3 hpux_setresuid setresuid -127 STD 3 hpux_setresgid setresgid -128 STD 2 rename -129 COMPAT 2 truncate -130 COMPAT 2 ftruncate -131 UNIMPL 0 nosys -132 STD 1 hpux_sysconf sysconf -133 UNIMPL 0 nosys -134 UNIMPL 0 nosys -135 UNIMPL 0 nosys -136 STD 2 mkdir -137 STD 1 rmdir -138 UNIMPL 0 nosys -139 UNIMPL 0 nosys -140 UNIMPL 0 nosys -141 UNIMPL 0 nosys -142 UNIMPL 0 nosys -143 UNIMPL 0 nosys -144 COMPAT 2 getrlimit -145 COMPAT 2 setrlimit -146 UNIMPL 0 nosys -147 UNIMPL 0 nosys -148 UNIMPL 0 nosys -149 UNIMPL 0 nosys -150 UNIMPL 0 nosys -151 NOTIMPL 3 privgrp -152 STD 2 hpux_rtprio rtprio -153 NOTIMPL 1 plock -154 STD 2 hpux_netioctl netioctl -155 STD 4 hpux_lockf lockf -#ifdef SYSVSEM -156 STD 3 semget -157 STD 4 semctl -158 STD 3 semop -#else -156 NOTIMPL 3 semget -157 NOTIMPL 4 semctl -158 NOTIMPL 3 semop -#endif -#ifdef SYSVMSG -159 STD 2 msgget -160 STD 3 msgctl -161 STD 4 msgsnd -162 STD 5 msgrcv -#else -159 NOTIMPL 2 msgget -160 NOTIMPL 3 msgctl -161 NOTIMPL 4 msgsnd -162 NOTIMPL 5 msgrcv -#endif -#ifdef SYSVSHM -163 STD 3 shmget -164 STD 3 hpux_shmctl shmctl -165 STD 3 shmat -166 STD 1 shmdt -#else -163 NOTIMPL 3 shmget -164 NOTIMPL 3 shmctl -165 NOTIMPL 3 shmat -166 NOTIMPL 1 shmdt -#endif -167 STD 1 hpux_advise m68020_advise -168 NOTIMPL 2 nsp_init -169 NOTIMPL 3 cluster -170 NOTIMPL 4 mkrnod -171 UNIMPL 0 nosys -172 NOTIMPL 0 unsp_open -173 UNIMPL 0 nosys -174 STD 3 hpux_getcontext getcontext -175 UNIMPL 0 nosys -176 UNIMPL 0 nosys -177 UNIMPL 0 nosys -178 NOTIMPL 0 lsync -179 UNIMPL 0 nosys -180 NOTIMPL 0 mysite -181 NOTIMPL 1 sitels -182 UNIMPL 0 nosys -183 UNIMPL 0 nosys -184 NOTIMPL 4 dskless_stats -185 UNIMPL 0 nosys -186 NOTIMPL 3 setacl -187 NOTIMPL 3 fsetacl -188 NOTIMPL 3 getacl -189 NOTIMPL 3 fgetacl -190 STD 6 hpux_getaccess getaccess -191 NOTIMPL 0 getaudid -192 NOTIMPL 1 setaudid -193 NOTIMPL 0 getaudproc -194 NOTIMPL 1 setaudproc -195 NOTIMPL 2 getevent -196 NOTIMPL 2 setevent -197 NOTIMPL 1 audwrite -198 NOTIMPL 1 audswitch -199 NOTIMPL 4 audctl -200 STD 3 hpux_waitpid waitpid -201 UNIMPL 0 nosys -202 UNIMPL 0 nosys -203 UNIMPL 6 nosys -204 UNIMPL 0 nosys -205 UNIMPL 0 nosys -206 UNIMPL 9 nosys -207 UNIMPL 0 nosys -208 UNIMPL 0 nosys -209 UNIMPL 6 nosys -210 UNIMPL 5 nosys -211 UNIMPL 0 nosys -212 UNIMPL 0 nosys -213 UNIMPL 0 nosys -214 UNIMPL 0 nosys -215 UNIMPL 0 nosys -216 UNIMPL 0 nosys -217 UNIMPL 0 nosys -218 UNIMPL 0 nosys -219 UNIMPL 0 nosys -220 UNIMPL 4 nosys -221 UNIMPL 10 nosys -222 UNIMPL 0 nosys -223 UNIMPL 0 nosys -224 UNIMPL 0 nosys -225 NOTIMPL 2 pathconf -226 NOTIMPL 2 fpathconf -227 UNIMPL 0 nosys -228 UNIMPL 0 nosys -229 NOTIMPL 0 async_daemon -230 NOTIMPL 3 nfs_fcntl -231 COMPAT 4 getdirentries -232 COMPAT 2 getdomainname -233 NOTIMPL 2 nfs_getfh -234 NOTIMPL 4 vfsmount -235 NOTIMPL 1 nfs_svc -236 COMPAT 2 setdomainname -237 NOTIMPL 2 statfs -238 NOTIMPL 2 fstatfs -239 STD 3 hpux_sigaction sigaction -240 STD 3 hpux_sigprocmask sigprocmask -241 STD 1 hpux_sigpending sigpending -242 STD 1 hpux_sigsuspend sigsuspend -243 NOTIMPL 4 fsctl -244 UNIMPL 0 nosys -245 NOTIMPL 3 pstat -246 UNIMPL 0 nosys -247 UNIMPL 0 nosys -248 UNIMPL 0 nosys -249 UNIMPL 0 nosys -250 UNIMPL 0 nosys -251 UNIMPL 0 nosys -252 UNIMPL 0 nosys -253 UNIMPL 0 nosys -254 UNIMPL 0 nosys -255 UNIMPL 0 nosys -256 UNIMPL 0 nosys -257 UNIMPL 0 nosys -258 UNIMPL 0 nosys -259 UNIMPL 0 nosys -260 UNIMPL 0 nosys -261 UNIMPL 0 nosys -262 UNIMPL 0 nosys -263 UNIMPL 0 nosys -264 UNIMPL 0 nosys -265 UNIMPL 0 nosys -266 UNIMPL 0 nosys -267 UNIMPL 0 nosys -268 COMPAT 0 getdtablesize getnumfds -269 UNIMPL 0 nosys -270 UNIMPL 0 nosys -271 UNIMPL 0 nosys -272 STD 1 fchdir -273 UNIMPL 0 nosys -274 UNIMPL 0 nosys -275 COMPAT 3 accept -276 STD 3 bind -277 STD 3 connect -278 COMPAT 3 getpeername -279 COMPAT 3 getsockname -280 STD 5 getsockopt -281 STD 2 listen -282 COMPAT 4 recv -283 COMPAT 6 recvfrom -284 COMPAT 3 recvmsg -285 COMPAT 4 send -286 COMPAT 3 sendmsg -287 STD 6 sendto -288 STD 5 hpux_setsockopt2 setsockopt2 -289 STD 2 shutdown -290 STD 3 socket -291 STD 4 socketpair -292 UNIMPL 0 nosys -293 UNIMPL 0 nosys -294 UNIMPL 0 nosys -295 UNIMPL 0 nosys -296 UNIMPL 0 nosys -297 UNIMPL 0 nosys -298 UNIMPL 0 nosys -299 UNIMPL 0 nosys -300 UNIMPL 0 nosys -301 UNIMPL 0 nosys -302 UNIMPL 0 nosys -303 UNIMPL 0 nosys -304 UNIMPL 0 nosys -305 UNIMPL 0 nosys -306 UNIMPL 0 nosys -307 UNIMPL 0 nosys -308 UNIMPL 0 nosys -309 UNIMPL 0 nosys -310 UNIMPL 0 nosys -311 UNIMPL 0 nosys -#ifdef SYSVSHM -312 STD 4 semctl nsemctl -#else -312 NOTIMPL 4 nsemctl -#endif -#ifdef SYSVMSG -313 STD 3 msgctl nmsgctl -#else -313 NOTIMPL 3 nmsgctl -#endif -#ifdef SYSVSHM -314 STD 3 hpux_nshmctl nshmctl -#else -314 NOTIMPL 3 nshmctl -#endif diff --git a/sys/arch/i386/conf/GENERICAHB b/sys/arch/i386/conf/GENERICAHB deleted file mode 100644 index fd7b0f28d056..000000000000 --- a/sys/arch/i386/conf/GENERICAHB +++ /dev/null @@ -1,90 +0,0 @@ -# -# GENERICISA -- Generic ISA machine with aha1742 -- distribution floppy -# -# $Id: GENERICAHB,v 1.16 1993/07/11 09:03:13 cgd Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -ident GENERICAHBBT -timezone 8 dst -maxusers 10 -options INET,ISOFS,NFSCLIENT -options "COMPAT_43" -options "TCP_COMPAT_42" -options XSERVER,UCONSOLE -options PCFS,KERNFS -options SCSI -options "MATH_EMULATE" -options "COMPAT_NOMID" - -config netbsd root on wd0 swap on wd0 and sd0 - -controller isa0 -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 - -controller ahb0 at isa? bio irq 11 vector ahbintr -disk sd0 at ahb0 flags 0 drive ? -disk sd1 at ahb0 flags 0 drive ? -disk sd2 at ahb0 flags 0 drive ? -disk sd3 at ahb0 flags 0 drive ? -tape st0 at ahb0 flags 1 drive ? -tape st1 at ahb0 flags 1 drive ? -disk cd0 at ahb0 flags 2 drive ? -disk cd1 at ahb0 flags 2 drive ? - -controller bt0 at isa? port "IO_BT0" bio irq 11 vector btintr -disk sd0 at bt0 flags 0 drive ? -disk sd1 at bt0 flags 0 drive ? -disk sd2 at bt0 flags 0 drive ? -disk sd3 at bt0 flags 0 drive ? -tape st0 at bt0 flags 1 drive ? -tape st1 at bt0 flags 1 drive ? -disk cd0 at bt0 flags 2 drive ? -disk cd1 at bt0 flags 2 drive ? - -controller uha0 at isa? port "IO_UHA0" bio irq 11 drq 5 vector uhaintr -disk sd0 at uha0 flags 0 drive ? -disk sd1 at uha0 flags 0 drive ? -disk sd2 at uha0 flags 0 drive ? -disk sd3 at uha0 flags 0 drive ? -tape st0 at uha0 flags 1 drive ? -tape st1 at uha0 flags 1 drive ? -disk cd0 at uha0 flags 2 drive ? -disk cd1 at uha0 flags 2 drive ? - -device pc0 at isa? port "IO_KBD" tty irq 1 vector pcrint -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr -device com0 at isa? port "IO_COM1" tty irq 4 vector comintr -device com1 at isa? port "IO_COM2" tty irq 3 vector comintr -device com2 at isa? port "IO_COM3" tty irq 5 vector comintr -device com3 at isa? port "IO_COM4" tty irq 9 vector comintr - -device lpt0 at isa? port "IO_LPT3" tty irq 7 vector lptintr -device lpa0 at isa? port "IO_LPT1" tty -device lpa1 at isa? port "IO_LPT2" tty - -device we0 at isa? port 0x280 net irq 9 iomem 0xd0000 iosiz 8192 vector weintr -device ne0 at isa? port 0x300 net irq 9 vector neintr -device ec0 at isa? port 0x250 net irq 9 iomem 0xd8000 iosiz 8192 vector ecintr -device is0 at isa? port 0x320 net irq 10 drq 7 vector isintr - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr - -pseudo-device ether -pseudo-device log -pseudo-device loop -pseudo-device pty 4 -pseudo-device sl 1 -pseudo-device speaker - -pseudo-device swappager -pseudo-device vnodepager -pseudo-device devpager diff --git a/sys/arch/i386/conf/GENERICISA b/sys/arch/i386/conf/GENERICISA deleted file mode 100644 index c9f16e7810d8..000000000000 --- a/sys/arch/i386/conf/GENERICISA +++ /dev/null @@ -1,81 +0,0 @@ -# -# GENERICISA -- Generic ISA machine -- distribution floppy -# -# $Id: GENERICISA,v 1.20 1993/07/11 09:03:23 cgd Exp $ -# - -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -ident GENERICISA -timezone 8 dst -maxusers 10 -options INET,ISOFS,NFSCLIENT -options "COMPAT_43" -options "TCP_COMPAT_42" -options XSERVER,UCONSOLE -options PCFS,KERNFS -options SCSI -options "MATH_EMULATE" -options "COMPAT_NOMID" - -config netbsd root on wd0 swap on wd0 and sd0 - -controller isa0 -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -disk wd1 at wdc0 drive 1 - -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 - -controller aha0 at isa? port "IO_AHA0" bio irq 11 drq 5 vector ahaintr -disk sd0 at aha0 flags 0 drive ? -disk sd1 at aha0 flags 0 drive ? -disk sd2 at aha0 flags 0 drive ? -disk sd3 at aha0 flags 0 drive ? -tape st0 at aha0 flags 1 drive ? -tape st1 at aha0 flags 1 drive ? -disk cd0 at aha0 flags 2 drive ? -disk cd1 at aha0 flags 2 drive ? - -controller uha0 at isa? port "IO_UHA0" bio irq 11 drq 5 vector uhaintr -disk sd0 at uha0 flags 0 drive ? -disk sd1 at uha0 flags 0 drive ? -disk sd2 at uha0 flags 0 drive ? -disk sd3 at uha0 flags 0 drive ? -tape st0 at uha0 flags 1 drive ? -tape st1 at uha0 flags 1 drive ? -disk cd0 at uha0 flags 2 drive ? -disk cd1 at uha0 flags 2 drive ? - - -device pc0 at isa? port "IO_KBD" tty irq 1 vector pcrint -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr -device com0 at isa? port "IO_COM1" tty irq 4 vector comintr -device com1 at isa? port "IO_COM2" tty irq 3 vector comintr -device com2 at isa? port "IO_COM3" tty irq 5 vector comintr -device com3 at isa? port "IO_COM4" tty irq 9 vector comintr - -device lpt0 at isa? port "IO_LPT3" tty irq 7 vector lptintr -device lpa0 at isa? port "IO_LPT1" tty -device lpa1 at isa? port "IO_LPT2" tty - -device we0 at isa? port 0x280 net irq 9 iomem 0xd0000 iosiz 8192 vector weintr -device ne0 at isa? port 0x300 net irq 9 vector neintr -device ec0 at isa? port 0x250 net irq 9 iomem 0xd8000 iosiz 8192 vector ecintr -device is0 at isa? port 0x320 net irq 10 drq 7 vector isintr - -device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr - -pseudo-device ether -pseudo-device log -pseudo-device loop -pseudo-device pty 4 -pseudo-device sl 1 -pseudo-device speaker - -pseudo-device swappager -pseudo-device vnodepager -pseudo-device devpager diff --git a/sys/arch/i386/conf/SMALL b/sys/arch/i386/conf/SMALL deleted file mode 100644 index aed906e984d0..000000000000 --- a/sys/arch/i386/conf/SMALL +++ /dev/null @@ -1,40 +0,0 @@ -# -# Distribution Floppy -# -# $Id: SMALL,v 1.8 1993/06/03 01:30:35 cgd Exp $ -# -machine "i386" -cpu "I386_CPU" -cpu "I486_CPU" -ident SMALL -timezone 8 dst -maxusers 2 -options INET -options "COMPAT_43" -options "TCP_COMPAT_42" -options "MATH_EMULATE" -options "COMPAT_NOMID" - -config netbsd root on dk0 swap on dk0 - -controller isa0 -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk dk0 at wdc0 drive 0 -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk dk4 at fdc0 drive 0 -disk dk5 at fdc0 drive 1 - -device pc0 at isa? port "IO_KBD" tty irq 1 vector pcrint -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr -device com0 at isa? port "IO_COM1" tty irq 4 vector comintr -# device com1 at isa? port "IO_COM2" tty irq 3 vector comintr -device we0 at isa? port 0x280 net irq 3 iomem 0xd0000 iosiz 8192 vector weintr - -pseudo-device loop -pseudo-device ether -pseudo-device sl 1 -pseudo-device pty 2 - -pseudo-device swappager -pseudo-device vnodepager -pseudo-device devpager diff --git a/sys/arch/i386/conf/SUMNER b/sys/arch/i386/conf/SUMNER deleted file mode 100644 index c186f70fcee3..000000000000 --- a/sys/arch/i386/conf/SUMNER +++ /dev/null @@ -1,42 +0,0 @@ -# -# Thos Sumner's 50Mhz 486 -# -# $Id: SUMNER,v 1.11 1993/06/03 01:30:36 cgd Exp $ -# -machine "i386" -cpu "I486_CPU" -ident SUMNER -timezone 8 dst -maxusers 4 -options INET, NFSSERVER,NFSCLIENT, MFS, ISOFS -options "COMPAT_43" -options "TCP_COMPAT_42" -options DDB -options "COMPAT_NOMID" - -config netbsd root on wd0 swap on wd0 and as0 - -controller isa0 -controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr -disk wd0 at wdc0 drive 0 -controller fdc0 at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr -disk fd0 at fdc0 drive 0 -disk fd1 at fdc0 drive 1 -controller as0 at isa? port 0x330 bio irq 11 drq 5 vector asintr -disk as0 at as0 drive 0 - -device pc0 at isa? port "IO_KBD" tty irq 1 vector pcrint -device npx0 at isa? port "IO_NPX" irq 13 vector npxintr -device com0 at isa? port "IO_COM1" tty irq 4 vector comintr -device com1 at isa? port "IO_COM2" tty irq 3 vector comintr -device we0 at isa? port 0x280 net irq 9 iomem 0xd0000 iosiz 8192 vector weintr - -pseudo-device loop -pseudo-device pty 3 -pseudo-device ether -pseudo-device sl 1 -pseudo-device log - -pseudo-device swappager -pseudo-device vnodepager -pseudo-device devpager diff --git a/sys/arch/i386/isa/comreg.h b/sys/arch/i386/isa/comreg.h deleted file mode 100644 index 16971888bffe..000000000000 --- a/sys/arch/i386/isa/comreg.h +++ /dev/null @@ -1,118 +0,0 @@ -/* $NetBSD: comreg.h,v 1.5 1995/01/29 02:58:22 cgd Exp $ */ - -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)comreg.h 7.2 (Berkeley) 5/9/91 - */ - -#include - -#define COM_FREQ 1843200 /* 16-bit baud rate divisor */ -#define COM_TOLERANCE 30 /* baud rate tolerance, in 0.1% units */ - -/* interrupt enable register */ -#define IER_ERXRDY 0x1 -#define IER_ETXRDY 0x2 -#define IER_ERLS 0x4 -#define IER_EMSC 0x8 - -/* interrupt identification register */ -#define IIR_IMASK 0xf -#define IIR_RXTOUT 0xc -#define IIR_RLS 0x6 -#define IIR_RXRDY 0x4 -#define IIR_TXRDY 0x2 -#define IIR_NOPEND 0x1 -#define IIR_MLSC 0x0 -#define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */ - -/* fifo control register */ -#define FIFO_ENABLE 0x01 -#define FIFO_RCV_RST 0x02 -#define FIFO_XMT_RST 0x04 -#define FIFO_DMA_MODE 0x08 -#define FIFO_TRIGGER_1 0x00 -#define FIFO_TRIGGER_4 0x40 -#define FIFO_TRIGGER_8 0x80 -#define FIFO_TRIGGER_14 0xc0 - -/* character format control register */ -#define CFCR_DLAB 0x80 -#define CFCR_SBREAK 0x40 -#define CFCR_PZERO 0x30 -#define CFCR_PONE 0x20 -#define CFCR_PEVEN 0x10 -#define CFCR_PODD 0x00 -#define CFCR_PENAB 0x08 -#define CFCR_STOPB 0x04 -#define CFCR_8BITS 0x03 -#define CFCR_7BITS 0x02 -#define CFCR_6BITS 0x01 -#define CFCR_5BITS 0x00 - -/* modem control register */ -#define MCR_LOOPBACK 0x10 -#define MCR_IENABLE 0x08 -#define MCR_DRS 0x04 -#define MCR_RTS 0x02 -#define MCR_DTR 0x01 - -/* line status register */ -#define LSR_RCV_FIFO 0x80 -#define LSR_TSRE 0x40 -#define LSR_TXRDY 0x20 -#define LSR_BI 0x10 -#define LSR_FE 0x08 -#define LSR_PE 0x04 -#define LSR_OE 0x02 -#define LSR_RXRDY 0x01 -#define LSR_RCV_MASK 0x1f - -/* modem status register */ -#define MSR_DCD 0x80 -#define MSR_RI 0x40 -#define MSR_DSR 0x20 -#define MSR_CTS 0x10 -#define MSR_DDCD 0x08 -#define MSR_TERI 0x04 -#define MSR_DDSR 0x02 -#define MSR_DCTS 0x01 - -#define COM_NPORTS 8 - -/* - * WARNING: Serial console is assumed to be at COM1 address - * and CONUNIT must be 0. - */ -#define CONADDR (0x3f8) -#define CONUNIT (0) diff --git a/sys/arch/i386/isa/cy.c b/sys/arch/i386/isa/cy.c deleted file mode 100644 index 1056b0386631..000000000000 --- a/sys/arch/i386/isa/cy.c +++ /dev/null @@ -1,1646 +0,0 @@ -/* $NetBSD: cy.c,v 1.10 1995/01/29 02:58:24 cgd Exp $ */ - -/* - * cyclades cyclom-y serial driver - * Andrew Herbert , 17 August 1993 - * - * Copyright (c) 1993 Andrew Herbert. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name Andrew Herbert may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Device minor number encoding: - * - * c c x x u u u u - bits in the minor device number - * - * bits meaning - * ---- ------- - * uuuu physical serial line (i.e. unit) to use - * 0-7 on a cyclom-8Y, 0-15 on a cyclom-16Y - * xx unused - * cc carrier control mode - * 00 complete hardware carrier control of the tty. - * DCD must be high for the open(2) to complete. - * 01 dialin pseudo-device (not yet implemented) - * 10 carrier ignored until a high->low transition - * 11 carrier completed ignored - */ - -/* - * Known deficiencies: - * - * * no BREAK handling - breaks are ignored, and can't be sent either - * * no support for bad-char reporting, except via PARMRK - * * no support for dialin + dialout devices - */ - -#include "cy.h" -#if NCY > 0 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#define RxFifoThreshold 3 /* 3 characters (out of 12) in the receive - * FIFO before an interrupt is generated - */ -#define FastRawInput /* bypass the regular char-by-char canonical input - * processing whenever possible - */ -#define PollMode /* use polling-based irq service routine, not the - * hardware svcack lines. Must be defined for - * cyclom-16y boards. - * - * XXX cyclom-8y doesn't work without this defined - * either (!) - */ -#undef LogOverruns /* log receive fifo overruns */ -#undef TxBuffer /* buffer driver output, to be slightly more - * efficient - * - * XXX presently buggy - */ -#undef Smarts /* enable slightly more CD1400 intelligence. Mainly - * the output CR/LF processing, plus we can avoid a - * few checks usually done in ttyinput(). - * - * XXX not yet implemented, and not particularly - * worthwhile either. - */ -#define CyDebug /* include debugging code (minimal effect on - * performance) - */ - -#define CY_RX_BUFS 2 /* two receive buffers per port */ -#define CY_RX_BUF_SIZE 256 /* bytes per receive buffer */ -#define CY_TX_BUF_SIZE 512 /* bytes per transmit buffer */ - -/* #define CD1400s_PER_CYCLOM 1 */ /* cyclom-4y */ -#define CD1400s_PER_CYCLOM 2 /* cyclom-8y */ -/* #define CD1400s_PER_CYCLOM 4 */ /* cyclom-16y */ - -#if CD1400s_PER_CYCLOM < 4 -#define CD1400_MEMSIZE 0x400 /* 4*256 bytes per chip: cyclom-[48]y */ -#else -#define CD1400_MEMSIZE 0x100 /* 256 bytes per chip: cyclom-16y */ - /* XXX or is it 0x400 like the rest? */ -#endif - -#define PORTS_PER_CYCLOM (CD1400_NO_OF_CHANNELS * CD1400s_PER_CYCLOM) -#define CYCLOM_RESET_16 0x1400 /* cyclom-16y reset */ -#define CYCLOM_CLEAR_INTR 0x1800 /* intr ack address */ -#define CYCLOM_CLOCK 25000000 /* baud rate clock */ - -#define CY_UNITMASK 0x0f -#define CY_CARRIERMASK 0xC0 -#define CY_CARRIERSHIFT 6 - -#define UNIT(x) (minor(x) & CY_UNITMASK) -#define CARRIER_MODE(x) ((minor(x) & CY_CARRIERMASK) >> CY_CARRIERSHIFT) - -typedef u_char * volatile cy_addr; - -int cyprobe(struct isa_device *dev); -int cyattach(struct isa_device *isdp); -void cystart(struct tty *tp); -int cyparam(struct tty *tp, struct termios *t); -int cyspeed(int speed, int *prescaler_io); -static void cy_channel_init(dev_t dev, int reset); -static void cd1400_channel_cmd(cy_addr base, u_char cmd); - -void delay(int delay); - -extern unsigned int delaycount; /* calibrated 1 ms cpu-spin delay */ - -struct isa_driver cydriver = { - cyprobe, cyattach, "cy" -}; - -/* low-level ping-pong buffer structure */ - -struct cy_buf { - u_char *next_char; /* location of next char to write */ - u_int free; /* free chars remaining in buffer */ - struct cy_buf *next_buf; /* circular, you know */ - u_char buf[CY_RX_BUF_SIZE]; /* start of the buffer */ -}; - -/* low-level ring buffer */ - -#ifdef TxBuffer -struct cy_ring { - u_char buf[CY_TX_BUF_SIZE]; - u_char *head; - u_char *tail; /* next pos. to insert char */ - u_char *endish; /* physical end of buf */ - u_int used; /* no. of chars in queue */ -}; -#endif - - -/* - * define a structure to keep track of each serial line - */ - -struct cy { - cy_addr base_addr; /* base address of this port's cd1400 */ - struct tty *tty; - u_int dtrwait; /* time (in ticks) to hold dtr low after close */ - u_int recv_exception; /* exception chars received */ - u_int recv_normal; /* normal chars received */ - u_int xmit; /* chars transmitted */ - u_int mdm; /* modem signal changes */ -#ifdef CyDebug - u_int start_count; /* no. of calls to cystart() */ - u_int start_real; /* no. of calls that did something */ -#endif - u_char carrier_mode; /* hardware carrier handling mode */ - /* - * 0 = always use - * 1 = always use (dialin port) - * 2 = ignore during open, then use it - * 3 = ignore completely - */ - u_char carrier_delta; /* true if carrier has changed state */ - u_char fifo_overrun; /* true if cd1400 receive fifo has... */ - u_char rx_buf_overrun; /* true if low-level buf overflow */ - u_char intr_enable; /* CD1400 SRER shadow */ - u_char modem_sig; /* CD1400 modem signal shadow */ - u_char channel_control;/* CD1400 CCR control command shadow */ - u_char cor[3]; /* CD1400 COR1-3 shadows */ -#ifdef Smarts - u_char spec_char[4]; /* CD1400 SCHR1-4 shadows */ -#endif - struct cy_buf *rx_buf; /* current receive buffer */ - struct cy_buf rx_buf_pool[CY_RX_BUFS];/* receive ping-pong buffers */ -#ifdef TxBuffer - struct cy_ring tx_buf; /* transmit buffer */ -#endif -}; - -int cydefaultrate = TTYDEF_SPEED; -cy_addr cyclom_base; /* base address of the card */ -static struct cy *info[NCY*PORTS_PER_CYCLOM]; -struct tty *cy_tty[NCY*PORTS_PER_CYCLOM]; -static volatile u_char timeout_scheduled = 0; /* true if a timeout has been scheduled */ - -#ifdef CyDebug -u_int cy_svrr_probes = 0; /* debugging */ -u_int cy_timeouts = 0; -u_int cy_timeout_req = 0; -#endif - -/**********************************************************************/ - -int -cyprobe(struct isa_device *dev) -{ - int i, j; - u_char version = 0; /* firmware version */ - - /* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */ - i = *(cy_addr)(dev->id_maddr + CYCLOM_RESET_16); - - delay(500); /* wait for the board to get its act together (500 us) */ - - for (i = 0; i < CD1400s_PER_CYCLOM; i++) { - cy_addr base = dev->id_maddr + i * CD1400_MEMSIZE; - - /* wait for chip to become ready for new command */ - for (j = 0; j < 100; j += 50) { - delay(50); /* wait 50 us */ - - if (!*(base + CD1400_CCR)) - break; - } - - /* clear the GFRCR register */ - *(base + CD1400_GFRCR) = 0; - - /* issue a reset command */ - *(base + CD1400_CCR) = CD1400_CMD_RESET; - - /* wait for the CD1400 to initialise itself */ - for (j = 0; j < 1000; j += 50) { - delay(50); /* wait 50 us */ - - /* retrieve firmware version */ - version = *(base + CD1400_GFRCR); - if (version) - break; - } - - /* anything in the 40-4f range is fine */ - if ((version & 0xf0) != 0x40) { - return 0; - } - } - - return 1; /* found */ -} - - -int -cyattach(struct isa_device *isdp) -{ -/* u_char unit = UNIT(isdp->id_unit); */ - int i, j, k; - - /* global variable used various routines */ - cyclom_base = (cy_addr)isdp->id_maddr; - - for (i = 0, k = 0; i < CD1400s_PER_CYCLOM; i++) { - cy_addr base = cyclom_base + i * CD1400_MEMSIZE; - - /* setup a 1ms clock tick */ - *(base + CD1400_PPR) = CD1400_CLOCK_25_1MS; - - for (j = 0; j < CD1400_NO_OF_CHANNELS; j++, k++) { - struct cy *ip; - - /* - * grab some space. it'd be more polite to do this in cyopen(), - * but hey. - */ - info[k] = ip = malloc(sizeof(struct cy), M_DEVBUF, M_WAITOK); - - /* clear all sorts of junk */ - bzero(ip, sizeof(struct cy)); - - ip->base_addr = base; - - /* initialise the channel, without resetting it first */ - cy_channel_init(k, 0); - } - } - - /* clear interrupts */ - *(cyclom_base + CYCLOM_CLEAR_INTR) = (u_char)0; - - return 1; -} - - -int -cyopen(dev_t dev, int flag, int mode, struct proc *p) -{ - u_int unit = UNIT(dev); - struct cy *infop; - cy_addr base; - struct tty *tp; - int error = 0; - u_char carrier; - - if (unit >= PORTS_PER_CYCLOM) - return (ENXIO); - - infop = info[unit]; - base = infop->base_addr; - if (!cy_tty[unit]) - infop->tty = cy_tty[unit] = ttymalloc(); - tp = infop->tty; - - tp->t_oproc = cystart; - tp->t_param = cyparam; - tp->t_dev = dev; - if (!(tp->t_state & TS_ISOPEN)) { - tp->t_state |= TS_WOPEN; - ttychars(tp); - if (tp->t_ispeed == 0) { - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = cydefaultrate; - } - - (void) spltty(); - cy_channel_init(unit, 1); /* reset the hardware */ - - /* - * raise dtr and generally set things up correctly. this - * has the side-effect of selecting the appropriate cd1400 - * channel, to help us with subsequent channel control stuff - */ - cyparam(tp, &tp->t_termios); - - /* check carrier, and set t_state's TS_CARR_ON flag accordingly */ - infop->modem_sig = *(base + CD1400_MSVR); - carrier = infop->modem_sig & CD1400_MSVR_CD; - - if (carrier || (infop->carrier_mode >= 2)) - tp->t_state |= TS_CARR_ON; - else - tp->t_state &=~ TS_CARR_ON; - - /* - * enable modem & rx interrupts - relies on cyparam() - * having selected the appropriate cd1400 channel - */ - infop->intr_enable = (1 << 7) | (1 << 4); - *(base + CD1400_SRER) = infop->intr_enable; - - ttsetwater(tp); - } else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) - return (EBUSY); - - if (!(flag & O_NONBLOCK)) - while (!(tp->t_cflag & CLOCAL) && - !(tp->t_state & TS_CARR_ON) && !error) - error = ttysleep(tp, (caddr_t)&tp->t_rawq, - TTIPRI|PCATCH, ttopen, 0); - (void) spl0(); - - if (!error) - error = (*linesw[(u_char)tp->t_line].l_open)(dev, tp); - return (error); -} /* end of cyopen() */ - - -void -cyclose_wakeup(caddr_t arg) -{ - wakeup(arg); -} /* end of cyclose_wakeup() */ - - -int -cyclose(dev_t dev, int flag, int mode, struct proc *p) -{ - u_int unit = UNIT(dev); - struct cy *infop = info[unit]; - struct tty *tp = infop->tty; - cy_addr base = infop->base_addr; - int s; - - (*linesw[(u_char)tp->t_line].l_close)(tp, flag); - - s = spltty(); - /* select the appropriate channel on the CD1400 */ - *(base + CD1400_CAR) = (u_char)(unit & 0x03); - - /* disable this channel and lower DTR */ - infop->intr_enable = 0; - *(base + CD1400_SRER) = (u_char)0; /* no intrs */ - *(base + CD1400_DTR) = (u_char)CD1400_DTR_CLEAR; /* no DTR */ - infop->modem_sig &= ~CD1400_MSVR_DTR; - - /* disable receiver (leave transmitter enabled) */ - infop->channel_control = (1 << 4) | (1 << 3) | 1; - cd1400_channel_cmd(base, infop->channel_control); - splx(s); - - ttyclose(tp); -#ifdef broken /* session holds a ref to the tty; can't deallocate */ - ttyfree(tp); - infop->tty = cy_tty[unit] = (struct tty *)NULL; -#endif - - if (infop->dtrwait) { - int error; - - timeout(cyclose_wakeup, (caddr_t)&infop->dtrwait, infop->dtrwait); - do { - error = tsleep((caddr_t)&infop->dtrwait, - TTIPRI|PCATCH, "cyclose", 0); - } while (error == ERESTART); - } - - return 0; -} /* end of cyclose() */ - - -int -cyread(dev_t dev, struct uio *uio, int flag) -{ - u_int unit = UNIT(dev); - struct tty *tp = info[unit]->tty; - - return (*linesw[(u_char)tp->t_line].l_read)(tp, uio, flag); -} /* end of cyread() */ - - -int -cywrite(dev_t dev, struct uio *uio, int flag) -{ - u_int unit = UNIT(dev); - struct tty *tp = info[unit]->tty; - -#ifdef Smarts - /* XXX duplicate ttwrite(), but without so much output processing on - * CR & LF chars. Hardly worth the effort, given that high-throughput - * sessions are raw anyhow. - */ -#else - return (*linesw[(u_char)tp->t_line].l_write)(tp, uio, flag); -#endif -} /* end of cywrite() */ - - -#ifdef Smarts -/* standard line discipline input routine */ -int -cyinput(int c, struct tty *tp) -{ - /* XXX duplicate ttyinput(), but without the IXOFF/IXON/ISTRIP/IPARMRK - * bits, as they are done by the CD1400. Hardly worth the effort, - * given that high-throughput sessions are raw anyhow. - */ -} /* end of cyinput() */ -#endif /* Smarts */ - - -inline static void -service_upper_rx(int unit) -{ - struct cy *ip = info[unit]; - struct tty *tp = ip->tty; - struct cy_buf *buf; - int i; - u_char *ch; - - buf = ip->rx_buf; - - /* give service_rx() a new one */ - disable_intr(); /* faster than spltty() */ - ip->rx_buf = buf->next_buf; - enable_intr(); - - if (tp->t_state & TS_ISOPEN) { - ch = buf->buf; - i = buf->next_char - buf->buf; - -#ifdef FastRawInput - /* try to avoid calling the line discipline stuff if we can */ - if ((tp->t_line == 0) && - !(tp->t_iflag & (ICRNL | IMAXBEL | INLCR)) && - !(tp->t_lflag & (ECHO | ECHONL | ICANON | IEXTEN | - ISIG | PENDIN)) && - !(tp->t_state & (TS_CNTTB | TS_LNCH))) { - - i = b_to_q(ch, i, &tp->t_rawq); - if (i) { - /* - * we have no RTS flow control support on cy-8 - * boards, so this is really just tough luck - */ - - log(LOG_WARNING, "cy%d: tty input queue overflow\n", - unit); - } - - ttwakeup(tp); /* notify any readers */ - } - else -#endif /* FastRawInput */ - { - while (i--) - (*linesw[(u_char)tp->t_line].l_rint)((int)*ch++, tp); - } - } - - /* clear the buffer we've just processed */ - buf->next_char = buf->buf; - buf->free = CY_RX_BUF_SIZE; -} /* end of service_upper_rx() */ - - -#ifdef TxBuffer -static void -service_upper_tx(int unit) -{ - struct cy *ip = info[unit]; - struct tty *tp = ip->tty; - - tp->t_state &=~ (TS_BUSY|TS_FLUSH); - - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state&TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } - - if (tp->t_outq.c_cc > 0) { - struct cy_ring *txq = &ip->tx_buf; - int free_count = CY_TX_BUF_SIZE - ip->tx_buf.used; - u_char *cp = txq->tail; - int count; - int chars_done; - - tp->t_state |= TS_BUSY; - - /* find the largest contig. copy we can do */ - count = ((txq->endish - cp) > free_count) ? - free_count : txq->endish - cp; - - count = ((cp + free_count) > txq->endish) ? - txq->endish - cp : free_count; - - /* copy the first slab */ - chars_done = q_to_b(&tp->t_outq, cp, count); - - /* check for wrap-around time */ - cp += chars_done; - if (cp == txq->endish) - cp = txq->buf; /* back to the start */ - - /* copy anything else, after we've wrapped around */ - if ((chars_done == count) && (count != free_count)) { - /* copy the second slab */ - count = q_to_b(&tp->t_outq, cp, free_count - count); - cp += count; - chars_done += count; - } - - /* - * update queue, protecting ourselves from any rampant - * lower-layers - */ - disable_intr(); - txq->tail = cp; - txq->used += chars_done; - enable_intr(); - } - - if (!tp->t_outq.c_cc) - tp->t_state &=~ TS_BUSY; -} /* end of service_upper_tx() */ -#endif /* TxBuffer */ - - -inline static void -service_upper_mdm(int unit) -{ - struct cy *ip = info[unit]; - - if (ip->carrier_delta) { - int carrier = ip->modem_sig & CD1400_MSVR_CD; - struct tty *tp = ip->tty; - - if (!(*linesw[(u_char)tp->t_line].l_modem)(tp, carrier)) { - cy_addr base = ip->base_addr; - - /* clear DTR */ - disable_intr(); - *(base + CD1400_CAR) = (u_char)(unit & 0x03); - *(base + CD1400_DTR) = (u_char)CD1400_DTR_CLEAR; - ip->modem_sig &= ~CD1400_MSVR_DTR; - ip->carrier_delta = 0; - enable_intr(); - } - else { - disable_intr(); - ip->carrier_delta = 0; - enable_intr(); - } - } -} /* end of service_upper_mdm() */ - - -/* upper level character processing routine */ -static void -cytimeout(caddr_t ptr) -{ - int unit; - - timeout_scheduled = 0; - -#ifdef CyDebug - cy_timeouts++; -#endif - - /* check each port in turn */ - for (unit = 0; unit < NCY*PORTS_PER_CYCLOM; unit++) { - struct cy *ip = info[unit]; -#ifndef TxBuffer - struct tty *tp = ip->tty; -#endif - - /* ignore anything that is not open */ - if (!ip->tty) - continue; - - /* - * any received chars to handle? (doesn't matter if intr routine - * kicks in while we're testing this) - */ - if (ip->rx_buf->free != CY_RX_BUF_SIZE) - service_upper_rx(unit); - -#ifdef TxBuffer - /* anything to add to the transmit buffer (low-water mark)? */ - if (ip->tx_buf.used < CY_TX_BUF_SIZE/2) - service_upper_tx(unit); -#else - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state&TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } -#endif - - /* anything modem signals altered? */ - service_upper_mdm(unit); - - /* any overruns to log? */ -#ifdef LogOverruns - if (ip->fifo_overrun) { - /* - * turn off the alarm - not important enough to bother - * with interrupt protection. - */ - ip->fifo_overrun = 0; - - log(LOG_WARNING, "cy%d: receive fifo overrun\n", unit); - } -#endif - if (ip->rx_buf_overrun) { - /* - * turn off the alarm - not important enough to bother - * with interrupt protection. - */ - ip->rx_buf_overrun = 0; - - log(LOG_WARNING, "cy%d: receive buffer full\n", unit); - } - } -} /* cytimeout() */ - - -inline static void -schedule_upper_service(void) -{ -#ifdef CyDebug - cy_timeout_req++; -#endif - - if (!timeout_scheduled) { - timeout(cytimeout, (caddr_t)0, 1); /* call next tick */ - timeout_scheduled = 1; - } -} /* end of schedule_upper_service() */ - - -/* initialise a channel on the cyclom board */ - -static void -cy_channel_init(dev_t dev, int reset) -{ - u_int unit = UNIT(dev); - int carrier_mode = CARRIER_MODE(dev); - struct cy *ip = info[unit]; - cy_addr base = ip->base_addr; - struct tty *tp = ip->tty; - struct cy_buf *buf, *next_buf; - int i; -#ifndef PollMode - u_char cd1400_unit; -#endif - - /* clear the structure and refill it */ - bzero(ip, sizeof(struct cy)); - ip->base_addr = base; - ip->tty = tp; - ip->carrier_mode = carrier_mode; - - /* select channel of the CD1400 */ - *(base + CD1400_CAR) = (u_char)(unit & 0x03); - - if (reset) - cd1400_channel_cmd(base, 0x80); /* reset the channel */ - - /* set LIVR to 0 - intr routines depend on this */ - *(base + CD1400_LIVR) = 0; - -#ifndef PollMode - /* set top four bits of {R,T,M}ICR to the cd1400 - * number, cd1400_unit - */ - cd1400_unit = unit / CD1400_NO_OF_CHANNELS; - *(base + CD1400_RICR) = (u_char)(cd1400_unit << 4); - *(base + CD1400_TICR) = (u_char)(cd1400_unit << 4); - *(base + CD1400_MICR) = (u_char)(cd1400_unit << 4); -#endif - - ip->dtrwait = hz/4; /* quarter of a second */ - - /* setup low-level buffers */ - i = CY_RX_BUFS; - ip->rx_buf = next_buf = &ip->rx_buf_pool[0]; - while (i--) { - buf = &ip->rx_buf_pool[i]; - - buf->next_char = buf->buf; /* first char to use */ - buf->free = CY_RX_BUF_SIZE; /* i.e. empty */ - buf->next_buf = next_buf; /* where to go next */ - next_buf = buf; - } - -#ifdef TxBuffer - ip->tx_buf.endish = ip->tx_buf.buf + CY_TX_BUF_SIZE; - - /* clear the low-level tx buffer */ - ip->tx_buf.head = ip->tx_buf.tail = ip->tx_buf.buf; - ip->tx_buf.used = 0; -#endif - - /* clear the low-level rx buffer */ - ip->rx_buf->next_char = ip->rx_buf->buf; /* first char to use */ - ip->rx_buf->free = CY_RX_BUF_SIZE; /* completely empty */ -} /* end of cy_channel_init() */ - - -/* service a receive interrupt */ -inline static void -service_rx(int cd, caddr_t base) -{ - struct cy *infop; - unsigned count; - int ch; - u_char serv_type, channel; -#ifdef PollMode - u_char save_rir, save_car; -#endif - - /* setup */ -#ifdef PollMode - save_rir = *(base + CD1400_RIR); - channel = cd * CD1400_NO_OF_CHANNELS + (save_rir & 0x3); - save_car = *(base + CD1400_CAR); - *(base + CD1400_CAR) = save_rir; /* enter modem service */ - serv_type = *(base + CD1400_RIVR); -#else - serv_type = *(base + CD1400_SVCACKR); /* ack receive service */ - channel = ((u_char)*(base + CD1400_RICR)) >> 2; /* get cyclom channel # */ - -#ifdef CyDebug - if (channel >= PORTS_PER_CYCLOM) { - printf("cy: service_rx - channel %02x\n", channel); - panic("cy: service_rx - bad channel"); - } -#endif -#endif - - infop = info[channel]; - - /* read those chars */ - if (serv_type & CD1400_RIVR_EXCEPTION) { - /* read the exception status */ - u_char status = *(base + CD1400_RDSR); - - /* XXX is it a break? Do something if it is! */ - - /* XXX is IGNPAR not set? Store a null in the buffer. */ - -#ifdef LogOverruns - if (status & CD1400_RDSR_OVERRUN) { -#if 0 - ch |= TTY_PE; /* for SLIP */ -#endif - infop->fifo_overrun++; - } -#endif - infop->recv_exception++; - } - else { - struct cy_buf *buf = infop->rx_buf; - - count = (u_char)*(base + CD1400_RDCR); /* how many to read? */ - infop->recv_normal += count; - if (buf->free < count) { - infop->rx_buf_overrun += count; - - /* read & discard everything */ - while (count--) - ch = (u_char)*(base + CD1400_RDSR); - } - else { - /* slurp it into our low-level buffer */ - buf->free -= count; - while (count--) { - ch = (u_char)*(base + CD1400_RDSR); /* read the char */ - *(buf->next_char++) = ch; - } - } - } - -#ifdef PollMode - *(base + CD1400_RIR) = (u_char)(save_rir & 0x3f); /* terminate service context */ -#else - *(base + CD1400_EOSRR) = (u_char)0; /* terminate service context */ -#endif -} /* end of service_rx */ - - -/* service a transmit interrupt */ -inline static void -service_tx(int cd, caddr_t base) -{ - struct cy *ip; -#ifdef TxBuffer - struct cy_ring *txq; -#else - struct tty *tp; -#endif - u_char channel; -#ifdef PollMode - u_char save_tir, save_car; -#else - u_char vector; -#endif - - /* setup */ -#ifdef PollMode - save_tir = *(base + CD1400_TIR); - channel = cd * CD1400_NO_OF_CHANNELS + (save_tir & 0x3); - save_car = *(base + CD1400_CAR); - *(base + CD1400_CAR) = save_tir; /* enter tx service */ -#else - vector = *(base + CD1400_SVCACKT); /* ack transmit service */ - channel = ((u_char)*(base + CD1400_TICR)) >> 2; /* get cyclom channel # */ - -#ifdef CyDebug - if (channel >= PORTS_PER_CYCLOM) { - printf("cy: service_tx - channel %02x\n", channel); - panic("cy: service_tx - bad channel"); - } -#endif -#endif - - ip = info[channel]; -#ifdef TxBuffer - txq = &ip->tx_buf; - - if (txq->used > 0) { - cy_addr base = ip->base_addr; - int count = min(CD1400_FIFOSIZE, txq->used); - int chars_done = count; - u_char *cp = txq->head; - u_char *buf_end = txq->endish; - - /* ip->state |= CY_BUSY; */ - while (count--) { - *(base + CD1400_TDR) = *cp++; - if (cp >= buf_end) - cp = txq->buf; - }; - txq->head = cp; - txq->used -= chars_done; /* important that this is atomic */ - ip->xmit += chars_done; - } - - /* - * disable tx intrs if no more chars to send. we re-enable - * them in cystart() - */ - if (!txq->used) { - ip->intr_enable &=~ (1 << 2); - *(base + CD1400_SRER) = ip->intr_enable; - /* ip->state &= ~CY_BUSY; */ - } -#else - tp = ip->tty; - - if (!(tp->t_state & TS_TTSTOP) && (tp->t_outq.c_cc > 0)) { - cy_addr base = ip->base_addr; - int count = min(CD1400_FIFOSIZE, tp->t_outq.c_cc); - - ip->xmit += count; - tp->t_state |= TS_BUSY; - while (count--) - *(base + CD1400_TDR) = getc(&tp->t_outq); - } - - /* - * disable tx intrs if no more chars to send. we re-enable them - * in cystart() - */ - if (!tp->t_outq.c_cc) { - ip->intr_enable &=~ (1 << 2); - *(base + CD1400_SRER) = ip->intr_enable; - tp->t_state &= ~TS_BUSY; - } -#endif - -#ifdef PollMode - *(base + CD1400_TIR) = (u_char)(save_tir & 0x3f); /* terminate service context */ -#else - *(base + CD1400_EOSRR) = (u_char)0; /* terminate service context */ -#endif -} /* end of service_tx */ - - -/* service a modem status interrupt */ -inline static void -service_mdm(int cd, caddr_t base) -{ - struct cy *infop; - u_char channel, deltas; -#ifdef PollMode - u_char save_mir, save_car; -#else - u_char vector; -#endif - - /* setup */ -#ifdef PollMode - save_mir = *(base + CD1400_MIR); - channel = cd * CD1400_NO_OF_CHANNELS + (save_mir & 0x3); - save_car = *(base + CD1400_CAR); - *(base + CD1400_CAR) = save_mir; /* enter modem service */ -#else - vector = *(base + CD1400_SVCACKM); /* ack modem service */ - channel = ((u_char)*(base + CD1400_MICR)) >> 2; /* get cyclom channel # */ - -#ifdef CyDebug - if (channel >= PORTS_PER_CYCLOM) { - printf("cy: service_mdm - channel %02x\n", channel); - panic("cy: service_mdm - bad channel"); - } -#endif -#endif - - infop = info[channel]; - - /* read the siggies and see what's changed */ - infop->modem_sig = (u_char)*(base + CD1400_MSVR); - deltas = (u_char)*(base + CD1400_MISR); - - if ((infop->carrier_mode <= 2) && (deltas & CD1400_MISR_CDd)) - /* something for the upper layer to deal with */ - infop->carrier_delta = 1; - - infop->mdm++; - - /* terminate service context */ -#ifdef PollMode - *(base + CD1400_MIR) = (u_char)(save_mir & 0x3f); -#else - *(base + CD1400_EOSRR) = (u_char)0; -#endif -} /* end of service_mdm */ - - -int -cyintr(int unit) -{ - int cd; - u_char status; - - /* check each CD1400 in turn */ - for (cd = 0; cd < CD1400s_PER_CYCLOM; cd++) { - cy_addr base = cyclom_base + cd*CD1400_MEMSIZE; - - /* poll to see if it has any work */ - while (status = (u_char)*(base + CD1400_SVRR)) { -#ifdef CyDebug - cy_svrr_probes++; -#endif - /* service requests as appropriate, giving priority to RX */ - if (status & CD1400_SVRR_RX) - service_rx(cd, base); - if (status & CD1400_SVRR_TX) - service_tx(cd, base); - if (status & CD1400_SVRR_MDM) - service_mdm(cd, base); - } - } - - /* request upper level service to deal with whatever happened */ - schedule_upper_service(); - - /* re-enable interrupts on the cyclom */ - *(cyclom_base + CYCLOM_CLEAR_INTR) = (u_char)0; - - return 1; -} - - -int -cyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) -{ - int unit = UNIT(dev); - struct cy *infop = info[unit]; - struct tty *tp = infop->tty; - int error; - - error = (*linesw[(u_char)tp->t_line].l_ioctl)(tp, cmd, data, flag, p); - if (error >= 0) - return (error); - error = ttioctl(tp, cmd, data, flag, p); - if (error >= 0) - return (error); - - switch (cmd) { -#ifdef notyet /* sigh - more junk to do XXX */ - case TIOCSBRK: - break; - case TIOCCBRK: - break; - case TIOCSDTR: - break; - case TIOCCDTR: - break; - - case TIOCMSET: - break; - case TIOCMBIS: - break; - case TIOCMBIC: - break; -#endif /* notyet */ - - case TIOCMGET: { - int bits = 0; - u_char status = infop->modem_sig; - - if (status & CD1400_MSVR_DTR) bits |= TIOCM_DTR | TIOCM_RTS; - if (status & CD1400_MSVR_CD) bits |= TIOCM_CD; - if (status & CD1400_MSVR_CTS) bits |= TIOCM_CTS; - if (status & CD1400_MSVR_DSR) bits |= TIOCM_DSR; -#ifdef CYCLOM_16 - if (status & CD1400_MSVR_RI) bits |= TIOCM_RI; -#endif - if (infop->channel_control & 0x02) bits |= TIOCM_LE; - *(int *)data = bits; - break; - } - -#ifdef TIOCMSBIDIR - case TIOCMSBIDIR: - return (ENOTTY); -#endif /* TIOCMSBIDIR */ - -#ifdef TIOCMGBIDIR - case TIOCMGBIDIR: - return (ENOTTY); -#endif /* TIOCMGBIDIR */ - -#ifdef TIOCMSDTRWAIT - case TIOCMSDTRWAIT: - /* must be root to set dtr delay */ - if (p->p_ucred->cr_uid != 0) - return(EPERM); - - infop->dtrwait = *(u_int *)data; - break; -#endif /* TIOCMSDTRWAIT */ - -#ifdef TIOCMGDTRWAIT - case TIOCMGDTRWAIT: - *(u_int *)data = infop->dtrwait; - break; -#endif /* TIOCMGDTRWAIT */ - - default: - return (ENOTTY); - } - - return 0; -} /* end of cyioctl() */ - - -int -cyparam(struct tty *tp, struct termios *t) -{ - u_char unit = UNIT(tp->t_dev); - struct cy *infop = info[unit]; - cy_addr base = infop->base_addr; - int cflag = t->c_cflag; - int iflag = t->c_iflag; - int ispeed, ospeed; - int itimeout; - int iprescaler, oprescaler; - int s; - u_char cor_change = 0; - u_char opt; - - if (!t->c_ispeed) - t->c_ispeed = t->c_ospeed; - - s = spltty(); - - /* select the appropriate channel on the CD1400 */ - *(base + CD1400_CAR) = unit & 0x03; - - /* handle DTR drop on speed == 0 trick */ - if (t->c_ospeed == 0) { - *(base + CD1400_DTR) = CD1400_DTR_CLEAR; - infop->modem_sig &= ~CD1400_MSVR_DTR; - } - else { - *(base + CD1400_DTR) = CD1400_DTR_SET; - infop->modem_sig |= CD1400_MSVR_DTR; - } - - /* set baud rates if they've changed from last time */ - - if ((ospeed = cyspeed(t->c_ospeed, &oprescaler)) < 0) - return EINVAL; - *(base + CD1400_TBPR) = (u_char)ospeed; - *(base + CD1400_TCOR) = (u_char)oprescaler; - - if ((ispeed = cyspeed(t->c_ispeed, &iprescaler)) < 0) - return EINVAL; - *(base + CD1400_RBPR) = (u_char)ispeed; - *(base + CD1400_RCOR) = (u_char)iprescaler; - - /* - * set receive time-out period - * generate a rx interrupt if no new chars are received in - * this many ticks - * don't bother comparing old & new VMIN, VTIME and ispeed - it - * can't be much worse just to calculate and set it each time! - * certainly less hassle. :-) - */ - - /* - * calculate minimum timeout period: - * 5 ms or the time it takes to receive 1 char, rounded up to the - * next ms, whichever is greater - */ - if (t->c_ispeed > 0) { - itimeout = (t->c_ispeed > 2200) ? 5 : (10000/t->c_ispeed + 1); - - /* if we're using VTIME as an inter-char timeout, and it is set to - * be longer than the minimum calculated above, go for it - */ - if (t->c_cc[VMIN] && t->c_cc[VTIME] && t->c_cc[VTIME]*10 > itimeout) - itimeout = t->c_cc[VTIME]*10; - - /* store it, taking care not to overflow the byte-sized register */ - *(base + CD1400_RTPR) = (u_char)((itimeout <= 255) ? itimeout : 255); - } - - - /* - * channel control - * receiver enable - * transmitter enable (always set) - */ - opt = (1 << 4) | (1 << 3) | ((cflag & CREAD) ? (1 << 1) : 1); - if (opt != infop->channel_control) { - infop->channel_control = opt; - cd1400_channel_cmd(base, opt); - } - -#ifdef Smarts - /* set special chars */ - if (t->c_cc[VSTOP] != _POSIX_VDISABLE && - (t->c_cc[VSTOP] != infop->spec_char[0])) { - *(base + CD1400_SCHR1) = infop->spec_char[0] = t->c_cc[VSTOP]; - } - if (t->c_cc[VSTART] != _POSIX_VDISABLE && - (t->c_cc[VSTART] != infop->spec_char[1])) { - *(base + CD1400_SCHR2) = infop->spec_char[0] = t->c_cc[VSTART]; - } - if (t->c_cc[VINTR] != _POSIX_VDISABLE && - (t->c_cc[VINTR] != infop->spec_char[2])) { - *(base + CD1400_SCHR3) = infop->spec_char[0] = t->c_cc[VINTR]; - } - if (t->c_cc[VSUSP] != _POSIX_VDISABLE && - (t->c_cc[VSUSP] != infop->spec_char[3])) { - *(base + CD1400_SCHR4) = infop->spec_char[0] = t->c_cc[VSUSP]; - } -#endif - - /* - * set channel option register 1 - - * parity mode - * stop bits - * char length - */ - opt = 0; - /* parity */ - if (cflag & PARENB) { - if (cflag & PARODD) - opt |= 1 << 7; - opt |= 2 << 5; /* normal parity mode */ - } - if (!(iflag & INPCK)) - opt |= 1 << 4; /* ignore parity */ - /* stop bits */ - if (cflag & CSTOPB) - opt |= 2 << 2; - /* char length */ - opt |= (cflag & CSIZE) >> 8; /* nasty, but fast */ - if (opt != infop->cor[0]) { - cor_change |= 1 << 1; - *(base + CD1400_COR1) = opt; - } - - /* - * set channel option register 2 - - * flow control - */ - opt = 0; -#ifdef Smarts - if (iflag & IXANY) - opt |= 1 << 7; /* auto output restart on any char after XOFF */ - if (iflag & IXOFF) - opt |= 1 << 6; /* auto XOFF output flow-control */ -#endif - if (cflag & CCTS_OFLOW) - opt |= 1 << 1; /* auto CTS flow-control */ - if (opt != infop->cor[1]) { - cor_change |= 1 << 2; - *(base + CD1400_COR2) = opt; - } - - /* - * set channel option register 3 - - * receiver FIFO interrupt threshold - * flow control - */ - opt = RxFifoThreshold; /* rx fifo threshold */ -#ifdef Smarts - if (t->c_lflag & ICANON) - opt |= 1 << 6; /* detect INTR & SUSP chars */ - if (iflag & IXOFF) - opt |= (1 << 5) | (1 << 4); /* transparent in-band flow control */ -#endif - if (opt != infop->cor[2]) { - cor_change |= 1 << 3; - *(base + CD1400_COR3) = opt; - } - - - /* notify the CD1400 if COR1-3 have changed */ - if (cor_change) { - cor_change |= 1 << 6; /* COR change flag */ - cd1400_channel_cmd(base, cor_change); - } - - /* - * set channel option register 4 - - * CR/NL processing - * break processing - * received exception processing - */ - opt = 0; - if (iflag & IGNCR) - opt |= 1 << 7; -#ifdef Smarts - /* - * we need a new ttyinput() for this, as we don't want to - * have ICRNL && INLCR being done in both layers, or to have - * synchronisation problems - */ - if (iflag & ICRNL) - opt |= 1 << 6; - if (iflag & INLCR) - opt |= 1 << 5; -#endif - if (iflag & IGNBRK) - opt |= 1 << 4; - if (!(iflag & BRKINT)) - opt |= 1 << 3; - if (iflag & IGNPAR) -#ifdef LogOverruns - opt |= 0; /* broken chars cause receive exceptions */ -#else - opt |= 2; /* discard broken chars */ -#endif - else { - if (iflag & PARMRK) - opt |= 4; /* precede broken chars with 0xff 0x0 */ - else -#ifdef LogOverruns - opt |= 0; /* broken chars cause receive exceptions */ -#else - opt |= 3; /* convert framing/parity errs to nulls */ -#endif - } - *(base + CD1400_COR4) = opt; - - /* - * set channel option register 5 - - */ - opt = 0; - if (iflag & ISTRIP) - opt |= 1 << 7; - if (t->c_iflag & IEXTEN) { - opt |= 1 << 6; /* enable LNEXT (e.g. ctrl-v quoting) handling */ - } -#ifdef Smarts - if (t->c_oflag & ONLCR) - opt |= 1 << 1; - if (t->c_oflag & OCRNL) - opt |= 1; -#endif - *(base + CD1400_COR5) = opt; - - /* - * set modem change option register 1 - * generate modem interrupts on which 1 -> 0 input transitions - * also controls auto-DTR output flow-control, which we don't use - */ - opt = (cflag & CLOCAL) ? 0 : 1 << 4; /* CD */ - *(base + CD1400_MCOR1) = opt; - - /* - * set modem change option register 2 - * generate modem interrupts on specific 0 -> 1 input transitions - */ - opt = (cflag & CLOCAL) ? 0 : 1 << 4; /* CD */ - *(base + CD1400_MCOR2) = opt; - - splx(s); - - return 0; -} /* end of cyparam */ - - -void -cystart(struct tty *tp) -{ - u_char unit = UNIT(tp->t_dev); - struct cy *infop = info[unit]; - cy_addr base = infop->base_addr; - int s; - -#ifdef CyDebug - infop->start_count++; -#endif - - /* check the flow-control situation */ - if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) - return; - - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state&TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } - -#ifdef TxBuffer - service_upper_tx(unit); /* feed the monster */ -#endif - - s = spltty(); - - if (!(infop->intr_enable & (1 << 2))) { - /* select the channel */ - *(base + CD1400_CAR) = unit & (u_char)3; - - /* (re)enable interrupts to set things in motion */ - infop->intr_enable |= (1 << 2); - *(base + CD1400_SRER) = infop->intr_enable; - - infop->start_real++; - } - - splx(s); -} /* end of cystart() */ - - -int -cystop(struct tty *tp, int flag) -{ - u_char unit = UNIT(tp->t_dev); - struct cy *ip = info[unit]; - cy_addr base = ip->base_addr; - int s; - - s = spltty(); - - /* select the channel */ - *(base + CD1400_CAR) = unit & 3; - - /* halt output by disabling transmit interrupts */ - ip->intr_enable &=~ (1 << 2); - *(base + CD1400_SRER) = ip->intr_enable; - - splx(s); - - return 0; -} - - -int -cyselect(dev_t dev, int rw, struct proc *p) -{ - struct tty *tp = info[UNIT(dev)]->tty; - int s = spltty(); - int nread; - - switch (rw) { - - case FREAD: - nread = ttnread(tp); - if (nread > 0 || - ((tp->t_cflag&CLOCAL) == 0 && (tp->t_state&TS_CARR_ON) == 0)) - goto win; - selrecord(p, &tp->t_rsel); - break; - - case FWRITE: - if (tp->t_outq.c_cc <= tp->t_lowat) - goto win; - selrecord(p, &tp->t_wsel); - break; - } - splx(s); - return (0); - win: - splx(s); - return (1); -} /* end of cyselect() */ - - -int -cyspeed(int speed, int *prescaler_io) -{ - int actual; - int error; - int divider; - int prescaler; - int prescaler_unit; - - if (speed == 0) - return 0; - - if (speed < 0 || speed > 150000) - return -1; - - /* determine which prescaler to use */ - for (prescaler_unit = 4, prescaler = 2048; prescaler_unit; - prescaler_unit--, prescaler >>= 2) { - if (CYCLOM_CLOCK/prescaler/speed > 63) - break; - } - - divider = (CYCLOM_CLOCK/prescaler*2/speed + 1)/2; /* round off */ - if (divider > 255) - divider = 255; - actual = CYCLOM_CLOCK/prescaler/divider; - error = ((actual-speed)*2000/speed +1)/2; /* percentage */ - - /* 3.0% max error tolerance */ - if (error < -30 || error > 30) - return -1; - -#if 0 - printf("prescaler = %d (%d)\n", prescaler, prescaler_unit); - printf("divider = %d (%x)\n", divider, divider); - printf("actual = %d\n", actual); - printf("error = %d\n", error); -#endif - - *prescaler_io = prescaler_unit; - return divider; -} /* end of cyspeed() */ - - -static void -cd1400_channel_cmd(cy_addr base, u_char cmd) -{ - unsigned maxwait = delaycount * 5; /* approx. 5 ms */ - - /* wait for processing of previous command to complete */ - while (*(base + CD1400_CCR) && maxwait--) - ; - - if (!maxwait) - log(LOG_ERR, "cy: channel command timeout (%d loops) - arrgh\n", - delaycount * 5); - - *(base + CD1400_CCR) = cmd; -} /* end of cd1400_channel_cmd() */ - - -#ifdef CyDebug -/* useful in ddb */ -void -cyclear(void) -{ - /* clear the timeout request */ - disable_intr(); - timeout_scheduled = 0; - enable_intr(); -} - -void -cyclearintr(void) -{ - /* clear interrupts */ - *(cyclom_base + CYCLOM_CLEAR_INTR) = (u_char)0; -} - -int -cyparam_dummy(struct tty *tp, struct termios *t) -{ - return 0; -} - -void -cyset(int unit, int active) -{ - if (unit < 0 || unit > PORTS_PER_CYCLOM) { - printf("bad unit number %d\n", unit); - return; - } - cy_tty[unit]->t_param = active ? cyparam : cyparam_dummy; -} - - -/* useful in ddb */ -void -cystatus(int unit) -{ - struct cy *infop = info[unit]; - struct tty *tp = infop->tty; - cy_addr base = infop->base_addr; - - printf("info for channel %d\n", unit); - printf("------------------\n"); - - printf("cd1400 base address:\t0x%x\n", (int)infop->base_addr); - - /* select the port */ - *(base + CD1400_CAR) = (u_char)unit; - - printf("saved channel_control:\t%02x\n", infop->channel_control); - printf("saved cor1:\t\t%02x\n", infop->cor[0]); - printf("service request enable reg:\t%02x (%02x cached)\n", - (u_char)*(base + CD1400_SRER), infop->intr_enable); - printf("service request register:\t%02x\n", - (u_char)*(base + CD1400_SVRR)); - printf("\n"); - printf("modem status:\t\t\t%02x (%02x cached)\n", - (u_char)*(base + CD1400_MSVR), infop->modem_sig); - printf("rx/tx/mdm interrupt registers:\t%02x %02x %02x\n", - (u_char)*(base + CD1400_RIR), (u_char)*(base + CD1400_TIR), - (u_char)*(base + CD1400_MIR)); - printf("\n"); - if (tp) { - printf("tty state:\t\t\t%04x\n", tp->t_state); - printf("upper layer queue lengths:\t%d raw, %d canon, %d output\n", - tp->t_rawq.c_cc, tp->t_canq.c_cc, tp->t_outq.c_cc); - } - else - printf("tty state:\t\t\tclosed\n"); - printf("\n"); - - printf("calls to cystart():\t\t%d (%d useful)\n", - infop->start_count, infop->start_real); - printf("\n"); - printf("total cyclom service probes:\t%d\n", cy_svrr_probes); - printf("calls to upper layer:\t\t%d\n", cy_timeouts); - printf("rx buffer chars free:\t\t%d\n", infop->rx_buf->free); -#ifdef TxBuffer - printf("tx buffer chars used:\t\t%d\n", infop->tx_buf.used); -#endif - printf("received chars:\t\t\t%d good, %d exception\n", - infop->recv_normal, infop->recv_exception); - printf("transmitted chars:\t\t%d\n", infop->xmit); - printf("modem signal deltas:\t\t%d\n", infop->mdm); - printf("\n"); -} /* end of cystatus() */ -#endif -#endif /* NCY > 0 */ diff --git a/sys/arch/i386/isa/elink.c b/sys/arch/i386/isa/elink.c deleted file mode 100644 index f52ee91ecdf3..000000000000 --- a/sys/arch/i386/isa/elink.c +++ /dev/null @@ -1,78 +0,0 @@ -/* $NetBSD: elink.c,v 1.6 1995/01/07 21:37:54 mycroft Exp $ */ - -/* - * Copyright (c) 1994, 1995 Charles Hannum. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Common code for dealing with 3COM ethernet cards. - */ - -#include -#include -#include - -/* - * Issue a `global reset' to all cards, and reset the ID state machines. We - * have to be careful to do the global reset only once during autoconfig, to - * prevent resetting boards that have already been configured. - */ -void -elink_reset() -{ - static int x = 0; - - if (x == 0) { - x = 1; - outb(ELINK_ID_PORT, ELINK_RESET); - } - outb(ELINK_ID_PORT, 0x00); - outb(ELINK_ID_PORT, 0x00); -} - -/* - * The `ID sequence' is really just snapshots of an 8-bit CRC register as 0 - * bits are shifted in. Different board types use different polynomials. - */ -void -elink_idseq(p) - register u_char p; -{ - register int i; - register u_char c; - - c = 0xff; - for (i = 255; i; i--) { - outb(ELINK_ID_PORT, c); - if (c & 0x80) { - c <<= 1; - c ^= p; - } else - c <<= 1; - } -} diff --git a/sys/arch/i386/isa/elink.h b/sys/arch/i386/isa/elink.h deleted file mode 100644 index c2af300887e9..000000000000 --- a/sys/arch/i386/isa/elink.h +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: elink.h,v 1.3 1994/10/27 04:17:11 cgd Exp $ */ - -/* - * Copyright (c) 1994 Charles Hannum. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define ELINK_ID_PORT 0x100 -#define ELINK_RESET 0xc0 - -#define ELINK_507_POLY 0xe7 -#define ELINK_509_POLY 0xcf - -void elink_reset __P((void)); -void elink_idseq __P((u_char p)); diff --git a/sys/arch/i386/isa/ic/ns16550.h b/sys/arch/i386/isa/ic/ns16550.h deleted file mode 100644 index 840f78f7d87d..000000000000 --- a/sys/arch/i386/isa/ic/ns16550.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: ns16550.h,v 1.4 1994/10/27 04:18:43 cgd Exp $ */ - -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ns16550.h 7.1 (Berkeley) 5/9/91 - */ - -/* - * NS16550 UART registers - */ - -#define com_data 0 /* data register (R/W) */ -#define com_dlbl 0 /* divisor latch low (W) */ -#define com_dlbh 1 /* divisor latch high (W) */ -#define com_ier 1 /* interrupt enable (W) */ -#define com_iir 2 /* interrupt identification (R) */ -#define com_fifo 2 /* FIFO control (W) */ -#define com_lctl 3 /* line control register (R/W) */ -#define com_cfcr 3 /* line control register (R/W) */ -#define com_mcr 4 /* modem control register (R/W) */ -#define com_lsr 5 /* line status register (R/W) */ -#define com_msr 6 /* modem status register (R/W) */ -#define com_scratch 7 /* scratch register (R/W) */ diff --git a/sys/arch/i386/isa/if_ed.c b/sys/arch/i386/isa/if_ed.c deleted file mode 100644 index 90c9afa43b8d..000000000000 --- a/sys/arch/i386/isa/if_ed.c +++ /dev/null @@ -1,2321 +0,0 @@ -/* $NetBSD: if_ed.c,v 1.66 1995/01/03 01:30:32 mycroft Exp $ */ - -/* - * Device driver for National Semiconductor DS8390/WD83C690 based ethernet - * adapters. - * - * Copyright (c) 1994 Charles Hannum. - * - * Copyright (C) 1993, David Greenman. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided that - * the above copyright and these terms are retained. Under no circumstances is - * the author responsible for the proper functioning of this software, nor does - * the author assume any responsibility for damages incurred with its use. - * - * Currently supports the Western Digital/SMC 8003 and 8013 series, the SMC - * Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000, and a variety of - * similar clones. - */ - -#include "bpfilter.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef INET -#include -#include -#include -#include -#include -#endif - -#ifdef NS -#include -#include -#endif - -#if NBPFILTER > 0 -#include -#include -#endif - -#include -#include - -#include -#include -#include - -/* - * ed_softc: per line info and status - */ -struct ed_softc { - struct device sc_dev; - struct intrhand sc_ih; - - struct arpcom sc_arpcom; /* ethernet common */ - - char *type_str; /* pointer to type string */ - u_char vendor; /* interface vendor */ - u_char type; /* interface type code */ - - int asic_addr; /* ASIC I/O bus address */ - int nic_addr; /* NIC (DS8390) I/O bus address */ - -/* - * The following 'proto' variable is part of a work-around for 8013EBT asics - * being write-only. It's sort of a prototype/shadow of the real thing. - */ - u_char wd_laar_proto; -/* - * This `proto' variable is so we can turn MENB on and off without reading - * the value back from the card all the time. - */ - u_char wd_msr_proto; - u_char cr_proto; /* ED_CR_RD2 if not 790; 0 if 790 */ - u_char isa16bit; /* width of access to card 0=8 or 1=16 */ - u_char is790; /* set by probe if NIC is a 790 */ - - caddr_t mem_start; /* NIC memory start address */ - caddr_t mem_end; /* NIC memory end address */ - u_long mem_size; /* total NIC memory size */ - caddr_t mem_ring; /* start of RX ring-buffer (in NIC mem) */ - - u_char mem_shared; /* NIC memory is shared with host */ - u_char xmit_busy; /* transmitter is busy */ - u_char txb_cnt; /* number of transmit buffers */ - u_char txb_inuse; /* number of TX buffers currently in-use*/ - - u_char txb_new; /* pointer to where new buffer will be added */ - u_char txb_next_tx; /* pointer to next buffer ready to xmit */ - u_short txb_len[8]; /* buffered xmit buffer lengths */ - u_char tx_page_start; /* first page of TX buffer area */ - u_char rec_page_start; /* first page of RX ring-buffer */ - u_char rec_page_stop; /* last page of RX ring-buffer */ - u_char next_packet; /* pointer to next unread RX packet */ -}; - -int edprobe __P((struct device *, void *, void *)); -void edattach __P((struct device *, struct device *, void *)); -int edintr __P((struct ed_softc *)); -int ed_ioctl __P((struct ifnet *, u_long, caddr_t)); -int ed_start __P((struct ifnet *)); -int ed_watchdog __P((/* short */)); -void ed_reset __P((struct ed_softc *)); -void ed_init __P((struct ed_softc *)); -void ed_stop __P((struct ed_softc *)); -void ed_getmcaf __P((struct arpcom *, u_long *)); - -#define inline /* XXX for debugging porpoises */ - -void ed_get_packet __P((/* struct ed_softc *, caddr_t, u_short */)); -static inline void ed_rint __P((struct ed_softc *)); -static inline void ed_xmit __P((struct ed_softc *)); -static inline caddr_t ed_ring_copy __P((/* struct ed_Softc *, caddr_t, caddr_t, - u_short */)); - -void ed_pio_readmem __P((/* struct ed_softc *, u_short, caddr_t, u_short */)); -void ed_pio_writemem __P((/* struct ed_softc *, caddr_t, u_short, u_short */)); -u_short ed_pio_write_mbufs __P((/* struct ed_softc *, struct mbuf *, u_short */)); - -struct cfdriver edcd = { - NULL, "ed", edprobe, edattach, DV_IFNET, sizeof(struct ed_softc) -}; - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 - -/* - * Determine if the device is present. - */ -int -edprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct ed_softc *sc = match; - struct cfdata *cf = sc->sc_dev.dv_cfdata; - struct isa_attach_args *ia = aux; - - if (ed_probe_WD80x3(sc, cf, ia)) - return (1); - if (ed_probe_3Com(sc, cf, ia)) - return (1); - if (ed_probe_Novell(sc, cf, ia)) - return (1); - return (0); -} - -/* - * Generic probe routine for testing for the existance of a DS8390. Must be - * called after the NIC has just been reset. This routine works by looking at - * certain register values that are gauranteed to be initialized a certain way - * after power-up or reset. Seems not to currently work on the 83C690. - * - * Specifically: - * - * Register reset bits set bits - * Command Register (CR) TXP, STA RD2, STP - * Interrupt Status (ISR) RST - * Interrupt Mask (IMR) All bits - * Data Control (DCR) LAS - * Transmit Config. (TCR) LB1, LB0 - * - * We only look at the CR and ISR registers, however, because looking at the - * others would require changing register pages (which would be intrusive if - * this isn't an 8390). - * - * Return 1 if 8390 was found, 0 if not. - */ -int -ed_probe_generic8390(sc) - struct ed_softc *sc; -{ - - if ((inb(sc->nic_addr + ED_P0_CR) & - (ED_CR_RD2 | ED_CR_TXP | ED_CR_STA | ED_CR_STP)) != - (ED_CR_RD2 | ED_CR_STP)) - return (0); - if ((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST) - return (0); - - return (1); -} - -int ed_wd584_irq[] = { 9, 3, 5, 7, 10, 11, 15, 4 }; -int ed_wd790_irq[] = { IRQUNK, 9, 3, 5, 7, 10, 11, 15 }; - -/* - * Probe and vendor-specific initialization routine for SMC/WD80x3 boards. - */ -int -ed_probe_WD80x3(sc, cf, ia) - struct ed_softc *sc; - struct cfdata *cf; - struct isa_attach_args *ia; -{ - int i; - u_int memsize; - u_char iptr, isa16bit, sum; - - sc->asic_addr = ia->ia_iobase; - sc->nic_addr = sc->asic_addr + ED_WD_NIC_OFFSET; - sc->is790 = 0; - -#ifdef TOSH_ETHER - outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_POW); - delay(10000); -#endif - - /* - * Attempt to do a checksum over the station address PROM. If it - * fails, it's probably not a SMC/WD board. There is a problem with - * this, though: some clone WD boards don't pass the checksum test. - * Danpex boards for one. - */ - for (sum = 0, i = 0; i < 8; ++i) - sum += inb(sc->asic_addr + ED_WD_PROM + i); - - if (sum != ED_WD_ROM_CHECKSUM_TOTAL) { - /* - * Checksum is invalid. This often happens with cheap WD8003E - * clones. In this case, the checksum byte (the eighth byte) - * seems to always be zero. - */ - if (inb(sc->asic_addr + ED_WD_CARD_ID) != ED_TYPE_WD8003E || - inb(sc->asic_addr + ED_WD_PROM + 7) != 0) - return (0); - } - - /* Reset card to force it into a known state. */ -#ifdef TOSH_ETHER - outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST | ED_WD_MSR_POW); -#else - outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST); -#endif - delay(100); - outb(sc->asic_addr + ED_WD_MSR, - inb(sc->asic_addr + ED_WD_MSR) & ~ED_WD_MSR_RST); - /* Wait in the case this card is reading it's EEROM. */ - delay(5000); - - sc->vendor = ED_VENDOR_WD_SMC; - sc->type = inb(sc->asic_addr + ED_WD_CARD_ID); - - /* Set initial values for width/size. */ - memsize = 8192; - isa16bit = 0; - switch (sc->type) { - case ED_TYPE_WD8003S: - sc->type_str = "WD8003S"; - break; - case ED_TYPE_WD8003E: - sc->type_str = "WD8003E"; - break; - case ED_TYPE_WD8003EB: - sc->type_str = "WD8003EB"; - break; - case ED_TYPE_WD8003W: - sc->type_str = "WD8003W"; - break; - case ED_TYPE_WD8013EBT: - sc->type_str = "WD8013EBT"; - memsize = 16384; - isa16bit = 1; - break; - case ED_TYPE_WD8013W: - sc->type_str = "WD8013W"; - memsize = 16384; - isa16bit = 1; - break; - case ED_TYPE_WD8013EP: /* also WD8003EP */ - if (inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_16BIT) { - isa16bit = 1; - memsize = 16384; - sc->type_str = "WD8013EP"; - } else - sc->type_str = "WD8003EP"; - break; - case ED_TYPE_WD8013WC: - sc->type_str = "WD8013WC"; - memsize = 16384; - isa16bit = 1; - break; - case ED_TYPE_WD8013EBP: - sc->type_str = "WD8013EBP"; - memsize = 16384; - isa16bit = 1; - break; - case ED_TYPE_WD8013EPC: - sc->type_str = "WD8013EPC"; - memsize = 16384; - isa16bit = 1; - break; - case ED_TYPE_SMC8216C: - sc->type_str = "SMC8216/SMC8216C"; - memsize = 16384; - isa16bit = 1; - sc->is790 = 1; - break; - case ED_TYPE_SMC8216T: - sc->type_str = "SMC8216T"; - memsize = 16384; - isa16bit = 1; - sc->is790 = 1; - break; -#ifdef TOSH_ETHER - case ED_TYPE_TOSHIBA1: - sc->type_str = "Toshiba1"; - memsize = 32768; - isa16bit = 1; - break; - case ED_TYPE_TOSHIBA4: - sc->type_str = "Toshiba4"; - memsize = 32768; - isa16bit = 1; - break; -#endif - default: - sc->type_str = NULL; - break; - } - /* - * Make some adjustments to initial values depending on what is found - * in the ICR. - */ - if (isa16bit && (sc->type != ED_TYPE_WD8013EBT) && -#ifdef TOSH_ETHER - (sc->type != ED_TYPE_TOSHIBA1) && (sc->type != ED_TYPE_TOSHIBA4) && -#endif - ((inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_16BIT) == 0)) { - isa16bit = 0; - memsize = 8192; - } - -#ifdef ED_DEBUG - printf("type=%x type_str=%s isa16bit=%d memsize=%d id_msize=%d\n", - sc->type, sc->type_str ?: "unknown", isa16bit, memsize, - ia->ia_msize); - for (i = 0; i < 8; i++) - printf("%x -> %x\n", i, inb(sc->asic_addr + i)); -#endif - /* Allow the user to override the autoconfiguration. */ - if (ia->ia_msize) - memsize = ia->ia_msize; - /* - * (Note that if the user specifies both of the following flags that - * '8-bit' mode intentionally has precedence.) - */ - if (cf->cf_flags & ED_FLAGS_FORCE_16BIT_MODE) - isa16bit = 1; - if (cf->cf_flags & ED_FLAGS_FORCE_8BIT_MODE) - isa16bit = 0; - - /* - * If possible, get the assigned interrupt number from the card and - * use it. - */ - if (sc->is790) { - u_char x; - /* Assemble together the encoded interrupt number. */ - outb(ia->ia_iobase + ED_WD790_HWR, - inb(ia->ia_iobase + ED_WD790_HWR) | ED_WD790_HWR_SWH); - x = inb(ia->ia_iobase + ED_WD790_GCR); - iptr = ((x & ED_WD790_GCR_IR2) >> 4) | - ((x & (ED_WD790_GCR_IR1|ED_WD790_GCR_IR0)) >> 2); - outb(ia->ia_iobase + ED_WD790_HWR, - inb(ia->ia_iobase + ED_WD790_HWR) & ~ED_WD790_HWR_SWH); - /* - * Translate it using translation table, and check for - * correctness. - */ - if (ia->ia_irq != IRQUNK) { - if (ia->ia_irq != ed_wd790_irq[iptr]) { - printf("%s: irq mismatch; kernel configured %d != board configured %d\n", - sc->sc_dev.dv_xname, ia->ia_irq, - ed_wd790_irq[iptr]); - return (0); - } - } else - ia->ia_irq = ed_wd790_irq[iptr]; - /* Enable the interrupt. */ - outb(ia->ia_iobase + ED_WD790_ICR, - inb(ia->ia_iobase + ED_WD790_ICR) | ED_WD790_ICR_EIL); - } else if (sc->type & ED_WD_SOFTCONFIG) { - /* Assemble together the encoded interrupt number. */ - iptr = (inb(ia->ia_iobase + ED_WD_ICR) & ED_WD_ICR_IR2) | - ((inb(ia->ia_iobase + ED_WD_IRR) & - (ED_WD_IRR_IR0 | ED_WD_IRR_IR1)) >> 5); - /* - * Translate it using translation table, and check for - * correctness. - */ - if (ia->ia_irq != IRQUNK) { - if (ia->ia_irq != ed_wd584_irq[iptr]) { - printf("%s: irq mismatch; kernel configured %d != board configured %d\n", - sc->sc_dev.dv_xname, ia->ia_irq, - ed_wd584_irq[iptr]); - return (0); - } - } else - ia->ia_irq = ed_wd584_irq[iptr]; - /* Enable the interrupt. */ - outb(ia->ia_iobase + ED_WD_IRR, - inb(ia->ia_iobase + ED_WD_IRR) | ED_WD_IRR_IEN); - } else { - if (ia->ia_irq == IRQUNK) { - printf("%s: %s does not have soft configuration\n", - sc->sc_dev.dv_xname, sc->type_str); - return (0); - } - } - - /* XXX Figure out the shared memory address. */ - - sc->isa16bit = isa16bit; - sc->mem_shared = 1; - ia->ia_msize = memsize; - sc->mem_start = ISA_HOLE_VADDR(ia->ia_maddr); - - /* Allocate one xmit buffer if < 16k, two buffers otherwise. */ - if ((memsize < 16384) || (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING)) - sc->txb_cnt = 1; - else - sc->txb_cnt = 2; - - sc->tx_page_start = ED_WD_PAGE_OFFSET; - sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE; - sc->rec_page_stop = sc->tx_page_start + (memsize >> ED_PAGE_SHIFT); - sc->mem_ring = sc->mem_start + (sc->rec_page_start << ED_PAGE_SHIFT); - sc->mem_size = memsize; - sc->mem_end = sc->mem_start + memsize; - - /* Get station address from on-board ROM. */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) - sc->sc_arpcom.ac_enaddr[i] = - inb(sc->asic_addr + ED_WD_PROM + i); - - /* - * Set upper address bits and 8/16 bit access to shared memory. - */ - if (isa16bit) { - if (sc->is790) { - sc->wd_laar_proto = - inb(sc->asic_addr + ED_WD_LAAR) & - ~ED_WD_LAAR_M16EN; - } else { - sc->wd_laar_proto = - ED_WD_LAAR_L16EN | - ((kvtop(sc->mem_start) >> 19) & - ED_WD_LAAR_ADDRHI); - } - outb(sc->asic_addr + ED_WD_LAAR, - sc->wd_laar_proto | ED_WD_LAAR_M16EN); - } else { - if ((sc->type & ED_WD_SOFTCONFIG) || -#ifdef TOSH_ETHER - (sc->type == ED_TYPE_TOSHIBA1) || - (sc->type == ED_TYPE_TOSHIBA4) || -#endif - (sc->type == ED_TYPE_WD8013EBT) && !sc->is790) { - sc->wd_laar_proto = - ((kvtop(sc->mem_start) >> 19) & - ED_WD_LAAR_ADDRHI); - outb(sc->asic_addr + ED_WD_LAAR, - sc->wd_laar_proto); - } - } - - /* - * Set address and enable interface shared memory. - */ - if (!sc->is790) { -#ifdef TOSH_ETHER - outb(sc->asic_addr + ED_WD_MSR + 1, - ((kvtop(sc->mem_start) >> 8) & 0xe0) | 4); - outb(sc->asic_addr + ED_WD_MSR + 2, - ((kvtop(sc->mem_start) >> 16) & 0x0f)); - sc->wd_msr_proto = ED_WD_MSR_POW; -#else - sc->wd_msr_proto = - (kvtop(sc->mem_start) >> 13) & ED_WD_MSR_ADDR; -#endif - sc->cr_proto = ED_CR_RD2; - } else { - outb(sc->asic_addr + 0x04, - inb(sc->asic_addr + 0x04) | 0x80); - outb(sc->asic_addr + 0x0b, - ((kvtop(sc->mem_start) >> 13) & 0x0f) | - ((kvtop(sc->mem_start) >> 11) & 0x40) | - (inb(sc->asic_addr + 0x0b) & 0xb0)); - outb(sc->asic_addr + 0x04, - inb(sc->asic_addr + 0x04) & ~0x80); - sc->wd_msr_proto = 0x00; - sc->cr_proto = 0; - } - outb(sc->asic_addr + ED_WD_MSR, - sc->wd_msr_proto | ED_WD_MSR_MENB); - - (void) inb(0x84); - (void) inb(0x84); - - /* Now zero memory and verify that it is clear. */ - bzero(sc->mem_start, memsize); - - for (i = 0; i < memsize; ++i) - if (sc->mem_start[i]) { - printf("%s: failed to clear shared memory at %x - check configuration\n", - sc->sc_dev.dv_xname, - kvtop(sc->mem_start + i)); - - /* Disable 16 bit access to shared memory. */ - outb(sc->asic_addr + ED_WD_MSR, - sc->wd_msr_proto); - if (isa16bit) - outb(sc->asic_addr + ED_WD_LAAR, - sc->wd_laar_proto); - (void) inb(0x84); - (void) inb(0x84); - return (0); - } - - /* - * Disable 16bit access to shared memory - we leave it disabled - * so that 1) machines reboot properly when the board is set 16 - * 16 bit mode and there are conflicting 8bit devices/ROMS in - * the same 128k address space as this boards shared memory, - * and 2) so that other 8 bit devices with shared memory can be - * used in this 128k region, too. - */ - outb(sc->asic_addr + ED_WD_MSR, sc->wd_msr_proto); - if (isa16bit) - outb(sc->asic_addr + ED_WD_LAAR, sc->wd_laar_proto); - (void) inb(0x84); - (void) inb(0x84); - - ia->ia_iosize = ED_WD_IO_PORTS; - return (1); -} - -int ed_3com_iobase[] = {0x2e0, 0x2a0, 0x280, 0x250, 0x350, 0x330, 0x310, 0x300}; -int ed_3com_maddr[] = {MADDRUNK, MADDRUNK, MADDRUNK, MADDRUNK, 0xc8000, 0xcc000, 0xd8000, 0xdc000}; -#if 0 -int ed_3com_irq[] = {IRQUNK, IRQUNK, IRQUNK, IRQUNK, 9, 3, 4, 5}; -#endif - -/* - * Probe and vendor-specific initialization routine for 3Com 3c503 boards. - */ -int -ed_probe_3Com(sc, cf, ia) - struct ed_softc *sc; - struct cfdata *cf; - struct isa_attach_args *ia; -{ - int i; - u_int memsize; - u_char isa16bit, sum, x; - int ptr; - - sc->asic_addr = ia->ia_iobase + ED_3COM_ASIC_OFFSET; - sc->nic_addr = ia->ia_iobase + ED_3COM_NIC_OFFSET; - - /* - * Verify that the kernel configured I/O address matches the board - * configured address. - * - * This is really only useful to see if something that looks like the - * board is there; after all, we are already talking it at that - * address. - */ - x = inb(sc->asic_addr + ED_3COM_BCFR); - if (x == 0 || (x & (x - 1)) != 0) - return (0); - ptr = ffs(x) - 1; - if (ia->ia_iobase != IOBASEUNK) { - if (ia->ia_iobase != ed_3com_iobase[ptr]) { - printf("%s: %s mismatch; kernel configured %x != board configured %x\n", - "iobase", sc->sc_dev.dv_xname, ia->ia_iobase, - ed_3com_iobase[ptr]); - return (0); - } - } else - ia->ia_iobase = ed_3com_iobase[ptr]; - - x = inb(sc->asic_addr + ED_3COM_PCFR); - if (x == 0 || (x & (x - 1)) != 0) - return (0); - ptr = ffs(x) - 1; - if (ia->ia_maddr != MADDRUNK) { - if (ia->ia_maddr != ed_3com_maddr[ptr]) { - printf("%s: %s mismatch; kernel configured %x != board configured %x\n", - "maddr", sc->sc_dev.dv_xname, ia->ia_maddr, - ed_3com_maddr[ptr]); - return (0); - } - } else - ia->ia_maddr = ed_3com_maddr[ptr]; - -#if 0 - x = inb(sc->asic_addr + ED_3COM_IDCFR) & ED_3COM_IDCFR_IRQ; - if (x == 0 || (x & (x - 1)) != 0) - return (0); - ptr = ffs(x) - 1; - if (ia->ia_irq != IRQUNK) { - if (ia->ia_irq != ed_3com_irq[ptr]) { - printf("%s: irq mismatch; kernel configured %d != board configured %d\n", - sc->sc_dev.dv_xname, ia->ia_irq, - ed_3com_irq[ptr]); - return (0); - } - } else - ia->ia_irq = ed_3com_irq[ptr]; -#endif - - /* - * Reset NIC and ASIC. Enable on-board transceiver throughout reset - * sequence because it'll lock up if the cable isn't connected if we - * don't. - */ - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_RST | ED_3COM_CR_XSEL); - - /* Wait for a while, then un-reset it. */ - delay(50); - - /* - * The 3Com ASIC defaults to rather strange settings for the CR after a - * reset - it's important to set it again after the following outb - * (this is done when we map the PROM below). - */ - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL); - - /* Wait a bit for the NIC to recover from the reset. */ - delay(5000); - - sc->vendor = ED_VENDOR_3COM; - sc->type_str = "3c503"; - sc->mem_shared = 1; - sc->cr_proto = ED_CR_RD2; - - /* - * Hmmm...a 16bit 3Com board has 16k of memory, but only an 8k window - * to it. - */ - memsize = 8192; - - /* - * Get station address from on-board ROM. - * - * First, map ethernet address PROM over the top of where the NIC - * registers normally appear. - */ - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_EALO | ED_3COM_CR_XSEL); - - for (i = 0; i < ETHER_ADDR_LEN; ++i) - sc->sc_arpcom.ac_enaddr[i] = inb(sc->nic_addr + i); - - /* - * Unmap PROM - select NIC registers. The proper setting of the - * tranceiver is set in ed_init so that the attach code is given a - * chance to set the default based on a compile-time config option. - */ - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL); - - /* Determine if this is an 8bit or 16bit board. */ - - /* Select page 0 registers. */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP); - - /* - * Attempt to clear WTS bit. If it doesn't clear, then this is a - * 16-bit board. - */ - outb(sc->nic_addr + ED_P0_DCR, 0); - - /* Select page 2 registers. */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_2 | ED_CR_STP); - - /* The 3c503 forces the WTS bit to a one if this is a 16bit board. */ - if (inb(sc->nic_addr + ED_P2_DCR) & ED_DCR_WTS) - isa16bit = 1; - else - isa16bit = 0; - - /* Select page 0 registers. */ - outb(sc->nic_addr + ED_P2_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP); - - sc->mem_start = ISA_HOLE_VADDR(ia->ia_maddr); - sc->mem_size = memsize; - sc->mem_end = sc->mem_start + memsize; - - /* - * We have an entire 8k window to put the transmit buffers on the - * 16-bit boards. But since the 16bit 3c503's shared memory is only - * fast enough to overlap the loading of one full-size packet, trying - * to load more than 2 buffers can actually leave the transmitter idle - * during the load. So 2 seems the best value. (Although a mix of - * variable-sized packets might change this assumption. Nonetheless, - * we optimize for linear transfers of same-size packets.) - */ - if (isa16bit) { - if (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING) - sc->txb_cnt = 1; - else - sc->txb_cnt = 2; - - sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_16BIT; - sc->rec_page_start = ED_3COM_RX_PAGE_OFFSET_16BIT; - sc->rec_page_stop = - (memsize >> ED_PAGE_SHIFT) + ED_3COM_RX_PAGE_OFFSET_16BIT; - sc->mem_ring = sc->mem_start; - } else { - sc->txb_cnt = 1; - sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_8BIT; - sc->rec_page_start = - ED_TXBUF_SIZE + ED_3COM_TX_PAGE_OFFSET_8BIT; - sc->rec_page_stop = - (memsize >> ED_PAGE_SHIFT) + ED_3COM_TX_PAGE_OFFSET_8BIT; - sc->mem_ring = - sc->mem_start + (ED_TXBUF_SIZE << ED_PAGE_SHIFT); - } - - sc->isa16bit = isa16bit; - - /* - * Initialize GA page start/stop registers. Probably only needed if - * doing DMA, but what the Hell. - */ - outb(sc->asic_addr + ED_3COM_PSTR, sc->rec_page_start); - outb(sc->asic_addr + ED_3COM_PSPR, sc->rec_page_stop); - - /* Set IRQ. 3c503 only allows a choice of irq 3-5 or 9. */ - switch (ia->ia_irq) { - case 9: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ2); - break; - case 3: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ3); - break; - case 4: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ4); - break; - case 5: - outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ5); - break; - default: - printf("%s: invalid irq configuration (%d) must be 3-5 or 9 for 3c503\n", - sc->sc_dev.dv_xname, ia->ia_irq); - return (0); - } - - /* - * Initialize GA configuration register. Set bank and enable shared - * mem. - */ - outb(sc->asic_addr + ED_3COM_GACFR, - ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0); - - /* - * Initialize "Vector Pointer" registers. These gawd-awful things are - * compared to 20 bits of the address on ISA, and if they match, the - * shared memory is disabled. We set them to 0xffff0...allegedly the - * reset vector. - */ - outb(sc->asic_addr + ED_3COM_VPTR2, 0xff); - outb(sc->asic_addr + ED_3COM_VPTR1, 0xff); - outb(sc->asic_addr + ED_3COM_VPTR0, 0x00); - - /* Zero memory and verify that it is clear. */ - bzero(sc->mem_start, memsize); - - for (i = 0; i < memsize; ++i) - if (sc->mem_start[i]) { - printf("%s: failed to clear shared memory at %x - check configuration\n", - sc->sc_dev.dv_xname, kvtop(sc->mem_start + i)); - return (0); - } - - ia->ia_msize = memsize; - ia->ia_iosize = ED_3COM_IO_PORTS; - return (1); -} - -/* - * Probe and vendor-specific initialization routine for NE1000/2000 boards. - */ -int -ed_probe_Novell(sc, cf, ia) - struct ed_softc *sc; - struct cfdata *cf; - struct isa_attach_args *ia; -{ - u_int memsize, n; - u_char romdata[16], isa16bit = 0, tmp; - static u_char test_pattern[32] = "THIS is A memory TEST pattern"; - u_char test_buffer[32]; - - sc->asic_addr = ia->ia_iobase + ED_NOVELL_ASIC_OFFSET; - sc->nic_addr = ia->ia_iobase + ED_NOVELL_NIC_OFFSET; - - /* XXX - do Novell-specific probe here */ - - /* Reset the board. */ -#ifdef GWETHER - outb(sc->asic_addr + ED_NOVELL_RESET, 0); - delay(200); -#endif /* GWETHER */ - tmp = inb(sc->asic_addr + ED_NOVELL_RESET); - - /* - * I don't know if this is necessary; probably cruft leftover from - * Clarkson packet driver code. Doesn't do a thing on the boards I've - * tested. -DG [note that a outb(0x84, 0) seems to work here, and is - * non-invasive...but some boards don't seem to reset and I don't have - * complete documentation on what the 'right' thing to do is...so we do - * the invasive thing for now. Yuck.] - */ - outb(sc->asic_addr + ED_NOVELL_RESET, tmp); - delay(5000); - - /* - * This is needed because some NE clones apparently don't reset the NIC - * properly (or the NIC chip doesn't reset fully on power-up) - * XXX - this makes the probe invasive! ...Done against my better - * judgement. -DLG - */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP); - - delay(5000); - - /* Make sure that we really have an 8390 based board. */ - if (!ed_probe_generic8390(sc)) - return (0); - - sc->vendor = ED_VENDOR_NOVELL; - sc->mem_shared = 0; - sc->cr_proto = ED_CR_RD2; - ia->ia_msize = 0; - - /* - * Test the ability to read and write to the NIC memory. This has the - * side affect of determining if this is an NE1000 or an NE2000. - */ - - /* - * This prevents packets from being stored in the NIC memory when the - * readmem routine turns on the start bit in the CR. - */ - outb(sc->nic_addr + ED_P0_RCR, ED_RCR_MON); - - /* Temporarily initialize DCR for byte operations. */ - outb(sc->nic_addr + ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS); - - outb(sc->nic_addr + ED_P0_PSTART, 8192 >> ED_PAGE_SHIFT); - outb(sc->nic_addr + ED_P0_PSTOP, 16384 >> ED_PAGE_SHIFT); - - sc->isa16bit = 0; - - /* - * Write a test pattern in byte mode. If this fails, then there - * probably isn't any memory at 8k - which likely means that the board - * is an NE2000. - */ - ed_pio_writemem(sc, test_pattern, 8192, sizeof(test_pattern)); - ed_pio_readmem(sc, 8192, test_buffer, sizeof(test_pattern)); - - if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) { - /* not an NE1000 - try NE2000 */ - - outb(sc->nic_addr + ED_P0_DCR, - ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS); - outb(sc->nic_addr + ED_P0_PSTART, 16384 >> ED_PAGE_SHIFT); - outb(sc->nic_addr + ED_P0_PSTOP, 32768 >> ED_PAGE_SHIFT); - - sc->isa16bit = 1; - - /* - * Write a test pattern in word mode. If this also fails, then - * we don't know what this board is. - */ - ed_pio_writemem(sc, test_pattern, 16384, sizeof(test_pattern)); - ed_pio_readmem(sc, 16384, test_buffer, sizeof(test_pattern)); - - if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) - return (0); /* not an NE2000 either */ - - sc->type = ED_TYPE_NE2000; - sc->type_str = "NE2000"; - } else { - sc->type = ED_TYPE_NE1000; - sc->type_str = "NE1000"; - } - - if (ia->ia_irq == IRQUNK) { - printf("%s: %s does not have soft configuration\n", - sc->sc_dev.dv_xname, sc->type_str); - return (0); - } - - /* 8k of memory plus an additional 8k if 16-bit. */ - memsize = 8192 + sc->isa16bit * 8192; - -#if 0 /* probably not useful - NE boards only come two ways */ - /* Allow kernel config file overrides. */ - if (ia->ia_msize) - memsize = ia->ia_msize; -#endif - - /* NIC memory doesn't start at zero on an NE board. */ - /* The start address is tied to the bus width. */ - sc->mem_start = (caddr_t)(8192 + sc->isa16bit * 8192); - sc->tx_page_start = memsize >> ED_PAGE_SHIFT; - -#ifdef GWETHER - { - int x, i, mstart = 0; - char pbuf0[ED_PAGE_SIZE], pbuf[ED_PAGE_SIZE], tbuf[ED_PAGE_SIZE]; - - for (i = 0; i < ED_PAGE_SIZE; i++) - pbuf0[i] = 0; - - /* Search for the start of RAM. */ - for (x = 1; x < 256; x++) { - ed_pio_writemem(sc, pbuf0, x << ED_PAGE_SHIFT, ED_PAGE_SIZE); - ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE); - if (!bcmp(pbuf0, tbuf, ED_PAGE_SIZE)) { - for (i = 0; i < ED_PAGE_SIZE; i++) - pbuf[i] = 255 - x; - ed_pio_writemem(sc, pbuf, x << ED_PAGE_SHIFT, ED_PAGE_SIZE); - ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE); - if (!bcmp(pbuf, tbuf, ED_PAGE_SIZE)) { - mstart = x << ED_PAGE_SHIFT; - memsize = ED_PAGE_SIZE; - break; - } - } - } - - if (mstart == 0) { - printf("%s: cannot find start of RAM\n", - sc->sc_dev.dv_xname); - return (0); - } - - /* Search for the end of RAM. */ - for (++x; x < 256; x++) { - ed_pio_writemem(sc, pbuf0, x << ED_PAGE_SHIFT, ED_PAGE_SIZE); - ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE); - if (!bcmp(pbuf0, tbuf, ED_PAGE_SIZE)) { - for (i = 0; i < ED_PAGE_SIZE; i++) - pbuf[i] = 255 - x; - ed_pio_writemem(sc, pbuf, x << ED_PAGE_SHIFT, ED_PAGE_SIZE); - ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE); - if (!bcmp(pbuf, tbuf, ED_PAGE_SIZE)) - memsize += ED_PAGE_SIZE; - else - break; - } else - break; - } - - printf("%s: RAM start %x, size %d\n", - sc->sc_dev.dv_xname, mstart, memsize); - - sc->mem_start = (caddr_t)mstart; - sc->tx_page_start = mstart >> ED_PAGE_SHIFT; - } -#endif /* GWETHER */ - - sc->mem_size = memsize; - sc->mem_end = sc->mem_start + memsize; - - /* - * Use one xmit buffer if < 16k, two buffers otherwise (if not told - * otherwise). - */ - if ((memsize < 16384) || (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING)) - sc->txb_cnt = 1; - else - sc->txb_cnt = 2; - - sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE; - sc->rec_page_stop = sc->tx_page_start + (memsize >> ED_PAGE_SHIFT); - - sc->mem_ring = - sc->mem_start + ((sc->txb_cnt * ED_TXBUF_SIZE) << ED_PAGE_SHIFT); - - ed_pio_readmem(sc, 0, romdata, 16); - for (n = 0; n < ETHER_ADDR_LEN; n++) - sc->sc_arpcom.ac_enaddr[n] = romdata[n*(sc->isa16bit+1)]; - -#ifdef GWETHER - if (sc->arpcom.ac_enaddr[2] == 0x86) - sc->type_str = "Gateway AT"; -#endif /* GWETHER */ - - /* Clear any pending interrupts that might have occurred above. */ - outb(sc->nic_addr + ED_P0_ISR, 0xff); - - ia->ia_iosize = ED_NOVELL_IO_PORTS; - return (1); -} - -/* - * Install interface into kernel networking data structures. - */ -void -edattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct ed_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - struct cfdata *cf = sc->sc_dev.dv_cfdata; - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - - /* Set interface to stopped condition (reset). */ - ed_stop(sc); - - /* Initialize ifnet structure. */ - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = edcd.cd_name; - ifp->if_output = ether_output; - ifp->if_start = ed_start; - ifp->if_ioctl = ed_ioctl; - ifp->if_watchdog = ed_watchdog; - ifp->if_flags = - IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - - /* - * Set default state for LINK0 flag (used to disable the tranceiver - * for AUI operation), based on compile-time config option. - */ - switch (sc->vendor) { - case ED_VENDOR_3COM: - if (cf->cf_flags & ED_FLAGS_DISABLE_TRANCEIVER) - ifp->if_flags |= IFF_LINK0; - break; - case ED_VENDOR_WD_SMC: - if ((sc->type & ED_WD_SOFTCONFIG) == 0) - break; - if ((inb(sc->asic_addr + ED_WD_IRR) & ED_WD_IRR_OUT2) == 0) - ifp->if_flags |= IFF_LINK0; - break; - } - - /* Attach the interface. */ - if_attach(ifp); - ether_ifattach(ifp); - - /* Print additional info when attached. */ - printf(": address %s, ", ether_sprintf(sc->sc_arpcom.ac_enaddr)); - - if (sc->type_str) - printf("type %s ", sc->type_str); - else - printf("type unknown (0x%x) ", sc->type); - - printf("%s", sc->isa16bit ? "(16-bit)" : "(8-bit)"); - - switch (sc->vendor) { - case ED_VENDOR_WD_SMC: - if ((sc->type & ED_WD_SOFTCONFIG) == 0) - break; - case ED_VENDOR_3COM: - if (ifp->if_flags & IFF_LINK0) - printf(" aui"); - else - printf(" bnc"); - break; - } - - printf("\n"); - -#if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif - - sc->sc_ih.ih_fun = edintr; - sc->sc_ih.ih_arg = sc; - sc->sc_ih.ih_level = IPL_NET; - intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih); -} - -/* - * Reset interface. - */ -void -ed_reset(sc) - struct ed_softc *sc; -{ - int s; - - s = splimp(); - ed_stop(sc); - ed_init(sc); - splx(s); -} - -/* - * Take interface offline. - */ -void -ed_stop(sc) - struct ed_softc *sc; -{ - int n = 5000; - - /* Stop everything on the interface, and select page 0 registers. */ - outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP); - - /* - * Wait for interface to enter stopped state, but limit # of checks to - * 'n' (about 5ms). It shouldn't even take 5us on modern DS8390's, but - * just in case it's an old one. - */ - while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RST) == 0) && --n); -} - -/* - * Device timeout/watchdog routine. Entered if the device neglects to generate - * an interrupt after a transmit has been started on it. - */ -int -ed_watchdog(unit) - short unit; -{ - struct ed_softc *sc = edcd.cd_devs[unit]; - - log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); - ++sc->sc_arpcom.ac_if.if_oerrors; - - ed_reset(sc); -} - -/* - * Initialize device. - */ -void -ed_init(sc) - struct ed_softc *sc; -{ - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int i, s; - u_char command; - u_long mcaf[2]; - - /* Address not known. */ - if (ifp->if_addrlist == 0) - return; - - /* - * Initialize the NIC in the exact order outlined in the NS manual. - * This init procedure is "mandatory"...don't change what or when - * things happen. - */ - s = splimp(); - - /* Reset transmitter flags. */ - sc->xmit_busy = 0; - sc->sc_arpcom.ac_if.if_timer = 0; - - sc->txb_inuse = 0; - sc->txb_new = 0; - sc->txb_next_tx = 0; - - /* Set interface for page 0, remote DMA complete, stopped. */ - outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP); - - if (sc->isa16bit) { - /* - * Set FIFO threshold to 8, No auto-init Remote DMA, byte - * order=80x86, word-wide DMA xfers, - */ - outb(sc->nic_addr + ED_P0_DCR, - ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS); - } else { - /* Same as above, but byte-wide DMA xfers. */ - outb(sc->nic_addr + ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS); - } - - /* Clear remote byte count registers. */ - outb(sc->nic_addr + ED_P0_RBCR0, 0); - outb(sc->nic_addr + ED_P0_RBCR1, 0); - - /* Tell RCR to do nothing for now. */ - outb(sc->nic_addr + ED_P0_RCR, ED_RCR_MON); - - /* Place NIC in internal loopback mode. */ - outb(sc->nic_addr + ED_P0_TCR, ED_TCR_LB0); - - /* Set lower bits of byte addressable framing to 0. */ - if (sc->is790) - outb(sc->nic_addr + 0x09, 0); - - /* Initialize receive buffer ring. */ - outb(sc->nic_addr + ED_P0_BNRY, sc->rec_page_start); - outb(sc->nic_addr + ED_P0_PSTART, sc->rec_page_start); - outb(sc->nic_addr + ED_P0_PSTOP, sc->rec_page_stop); - - /* - * Clear all interrupts. A '1' in each bit position clears the - * corresponding flag. - */ - outb(sc->nic_addr + ED_P0_ISR, 0xff); - - /* - * Enable the following interrupts: receive/transmit complete, - * receive/transmit error, and Receiver OverWrite. - * - * Counter overflow and Remote DMA complete are *not* enabled. - */ - outb(sc->nic_addr + ED_P0_IMR, - ED_IMR_PRXE | ED_IMR_PTXE | ED_IMR_RXEE | ED_IMR_TXEE | - ED_IMR_OVWE); - - /* Program command register for page 1. */ - outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STP); - - /* Copy out our station address. */ - for (i = 0; i < ETHER_ADDR_LEN; ++i) - outb(sc->nic_addr + ED_P1_PAR0 + i, sc->sc_arpcom.ac_enaddr[i]); - - /* Set multicast filter on chip. */ - ed_getmcaf(&sc->sc_arpcom, mcaf); - for (i = 0; i < 8; i++) - outb(sc->nic_addr + ED_P1_MAR0 + i, ((u_char *)mcaf)[i]); - - /* - * Set current page pointer to one page after the boundary pointer, as - * recommended in the National manual. - */ - sc->next_packet = sc->rec_page_start + 1; - outb(sc->nic_addr + ED_P1_CURR, sc->next_packet); - - /* Program command register for page 0. */ - outb(sc->nic_addr + ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP); - - i = ED_RCR_AB | ED_RCR_AM; - if (ifp->if_flags & IFF_PROMISC) { - /* - * Set promiscuous mode. Multicast filter was set earlier so - * that we should receive all multicast packets. - */ - i |= ED_RCR_PRO | ED_RCR_AR | ED_RCR_SEP; - } - outb(sc->nic_addr + ED_P0_RCR, i); - - /* Take interface out of loopback. */ - outb(sc->nic_addr + ED_P0_TCR, 0); - - /* - * If this is a 3Com board, the tranceiver must be software enabled - * (there is no settable hardware default). - */ - switch (sc->vendor) { - u_char x; - case ED_VENDOR_3COM: - if (ifp->if_flags & IFF_LINK0) - outb(sc->asic_addr + ED_3COM_CR, 0); - else - outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL); - break; - case ED_VENDOR_WD_SMC: - if ((sc->type & ED_WD_SOFTCONFIG) == 0) - break; - x = inb(sc->asic_addr + ED_WD_IRR); - if (ifp->if_flags & IFF_LINK0) - x &= ~ED_WD_IRR_OUT2; - else - x |= ED_WD_IRR_OUT2; - outb(sc->asic_addr + ED_WD_IRR, x); - break; - } - - /* Fire up the interface. */ - outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA); - - /* Set 'running' flag, and clear output active flag. */ - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - - /* ...and attempt to start output. */ - ed_start(ifp); - - (void) splx(s); -} - -/* - * This routine actually starts the transmission on the interface. - */ -static inline void -ed_xmit(sc) - struct ed_softc *sc; -{ - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - u_short len; - - len = sc->txb_len[sc->txb_next_tx]; - - /* Set NIC for page 0 register access. */ - outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA); - - /* Set TX buffer start page. */ - outb(sc->nic_addr + ED_P0_TPSR, sc->tx_page_start + - sc->txb_next_tx * ED_TXBUF_SIZE); - - /* Set TX length. */ - outb(sc->nic_addr + ED_P0_TBCR0, len); - outb(sc->nic_addr + ED_P0_TBCR1, len >> 8); - - /* Set page 0, remote DMA complete, transmit packet, and *start*. */ - outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_TXP | ED_CR_STA); - sc->xmit_busy = 1; - - /* Point to next transmit buffer slot and wrap if necessary. */ - sc->txb_next_tx++; - if (sc->txb_next_tx == sc->txb_cnt) - sc->txb_next_tx = 0; - - /* Set a timer just in case we never hear from the board again. */ - ifp->if_timer = 2; -} - -/* - * Start output on interface. - * We make two assumptions here: - * 1) that the current priority is set to splimp _before_ this code - * is called *and* is returned to the appropriate priority after - * return - * 2) that the IFF_OACTIVE flag is checked before this code is called - * (i.e. that the output part of the interface is idle) - */ -int -ed_start(ifp) - struct ifnet *ifp; -{ - struct ed_softc *sc = edcd.cd_devs[ifp->if_unit]; - struct mbuf *m0, *m; - caddr_t buffer; - int len; - -outloop: - /* - * First, see if there are buffered packets and an idle transmitter - - * should never happen at this point. - */ - if (sc->txb_inuse && (sc->xmit_busy == 0)) { - printf("%s: packets buffered, but transmitter idle\n", - sc->sc_dev.dv_xname); - ed_xmit(sc); - } - - /* See if there is room to put another packet in the buffer. */ - if (sc->txb_inuse == sc->txb_cnt) { - /* No room. Indicate this to the outside world and exit. */ - ifp->if_flags |= IFF_OACTIVE; - return; - } - - IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m); - if (m == 0) { - /* - * We are using the !OACTIVE flag to indicate to the outside - * world that we can accept an additional packet rather than - * that the transmitter is _actually_ active. Indeed, the - * transmitter may be active, but if we haven't filled all the - * buffers with data then we still want to accept more. - */ - ifp->if_flags &= ~IFF_OACTIVE; - return; - } - - /* Copy the mbuf chain into the transmit buffer. */ - m0 = m; - - /* txb_new points to next open buffer slot. */ - buffer = sc->mem_start + ((sc->txb_new * ED_TXBUF_SIZE) << ED_PAGE_SHIFT); - - if (sc->mem_shared) { - /* Special case setup for 16 bit boards... */ - switch (sc->vendor) { - /* - * For 16bit 3Com boards (which have 16k of memory), we - * have the xmit buffers in a different page of memory - * ('page 0') - so change pages. - */ - case ED_VENDOR_3COM: - if (sc->isa16bit) - outb(sc->asic_addr + ED_3COM_GACFR, - ED_3COM_GACFR_RSEL); - break; - /* - * Enable 16bit access to shared memory on WD/SMC - * boards. - */ - case ED_VENDOR_WD_SMC: - if (sc->isa16bit) - outb(sc->asic_addr + ED_WD_LAAR, - sc->wd_laar_proto | ED_WD_LAAR_M16EN); - outb(sc->asic_addr + ED_WD_MSR, - sc->wd_msr_proto | ED_WD_MSR_MENB); - (void) inb(0x84); - (void) inb(0x84); - break; - } - - for (len = 0; m; m = m->m_next) { - bcopy(mtod(m, caddr_t), buffer, m->m_len); - buffer += m->m_len; - len += m->m_len; - } - - /* Restore previous shared memory access. */ - switch (sc->vendor) { - case ED_VENDOR_3COM: - if (sc->isa16bit) - outb(sc->asic_addr + ED_3COM_GACFR, - ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0); - break; - case ED_VENDOR_WD_SMC: - outb(sc->asic_addr + ED_WD_MSR, - sc->wd_msr_proto); - if (sc->isa16bit) - outb(sc->asic_addr + ED_WD_LAAR, - sc->wd_laar_proto); - (void) inb(0x84); - (void) inb(0x84); - break; - } - } else - len = ed_pio_write_mbufs(sc, m, (u_short)buffer); - - sc->txb_len[sc->txb_new] = max(len, ETHER_MIN_LEN); - sc->txb_inuse++; - - /* Point to next buffer slot and wrap if necessary. */ - if (++sc->txb_new == sc->txb_cnt) - sc->txb_new = 0; - - if (sc->xmit_busy == 0) - ed_xmit(sc); - -#if NBPFILTER > 0 - /* Tap off here if there is a BPF listener. */ - if (sc->sc_arpcom.ac_if.if_bpf) - bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0); -#endif - - m_freem(m0); - - /* Loop back to the top to possibly buffer more packets. */ - goto outloop; -} - -/* - * Ethernet interface receiver interrupt. - */ -static inline void -ed_rint(sc) - struct ed_softc *sc; -{ - u_char boundary, current; - u_short len; - u_char nlen; - struct ed_ring packet_hdr; - caddr_t packet_ptr; - -loop: - /* Set NIC to page 1 registers to get 'current' pointer. */ - outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA); - - /* - * 'sc->next_packet' is the logical beginning of the ring-buffer - i.e. - * it points to where new data has been buffered. The 'CURR' (current) - * register points to the logical end of the ring-buffer - i.e. it - * points to where additional new data will be added. We loop here - * until the logical beginning equals the logical end (or in other - * words, until the ring-buffer is empty). - */ - current = inb(sc->nic_addr + ED_P1_CURR); - if (sc->next_packet == current) - return; - - do { - /* Get pointer to this buffer's header structure. */ - packet_ptr = sc->mem_ring + - ((sc->next_packet - sc->rec_page_start) << ED_PAGE_SHIFT); - - /* - * The byte count includes a 4 byte header that was added by - * the NIC. - */ - if (sc->mem_shared) - packet_hdr = *(struct ed_ring *)packet_ptr; - else - ed_pio_readmem(sc, (u_short)packet_ptr, - (caddr_t) &packet_hdr, sizeof(packet_hdr)); - len = packet_hdr.count; - - /* - * Try do deal with old, buggy chips that sometimes duplicate - * the low byte of the length into the high byte. We do this - * by simply ignoring the high byte of the length and always - * recalculating it. - * - * NOTE: sc->next_packet is pointing at the current packet. - */ - if (packet_hdr.next_packet >= sc->next_packet) - nlen = (packet_hdr.next_packet - sc->next_packet); - else - nlen = ((packet_hdr.next_packet - sc->rec_page_start) + - (sc->rec_page_stop - sc->next_packet)); - --nlen; - if ((len & ED_PAGE_MASK) + sizeof(packet_hdr) > ED_PAGE_SIZE) - --nlen; - len = (len & ED_PAGE_MASK) | (nlen << ED_PAGE_SHIFT); -#ifdef DIAGNOSTIC - if (len != packet_hdr.count) { - printf("%s: length does not match next packet pointer\n", - sc->sc_dev.dv_xname); - printf("%s: len %04x nlen %04x start %02x curr %02x next %02x stop %02x\n", - sc->sc_dev.dv_xname, packet_hdr.count, len, - sc->rec_page_start, sc->next_packet, - packet_hdr.next_packet, sc->rec_page_stop); - } -#endif - - /* - * Be fairly liberal about what we allow as a "reasonable" - * length so that a [crufty] packet will make it to BPF (and - * can thus be analyzed). Note that all that is really - * important is that we have a length that will fit into one - * mbuf cluster or less; the upper layer protocols can then - * figure out the length from their own length field(s). - */ - if (len <= MCLBYTES && - packet_hdr.next_packet >= sc->rec_page_start && - packet_hdr.next_packet < sc->rec_page_stop) { - /* Go get packet. */ - ed_get_packet(sc, packet_ptr + sizeof(struct ed_ring), - len - sizeof(struct ed_ring)); - ++sc->sc_arpcom.ac_if.if_ipackets; - } else { - /* Really BAD. The ring pointers are corrupted. */ - log(LOG_ERR, - "%s: NIC memory corrupt - invalid packet length %d\n", - sc->sc_dev.dv_xname, len); - ++sc->sc_arpcom.ac_if.if_ierrors; - ed_reset(sc); - return; - } - - /* Update next packet pointer. */ - sc->next_packet = packet_hdr.next_packet; - - /* - * Update NIC boundary pointer - being careful to keep it one - * buffer behind (as recommended by NS databook). - */ - boundary = sc->next_packet - 1; - if (boundary < sc->rec_page_start) - boundary = sc->rec_page_stop - 1; - - /* Set NIC to page 0 registers to update boundary register. */ - outb(sc->nic_addr + ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA); - outb(sc->nic_addr + ED_P0_BNRY, boundary); - } while (sc->next_packet != current); - - goto loop; -} - -/* Ethernet interface interrupt processor. */ -int -edintr(sc) - struct ed_softc *sc; -{ - u_char isr; - - /* Set NIC to page 0 registers. */ - outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA); - - isr = inb(sc->nic_addr + ED_P0_ISR); - if (!isr) - return (0); - - /* Loop until there are no more new interrupts. */ - for (;;) { - /* - * Reset all the bits that we are 'acknowledging' by writing a - * '1' to each bit position that was set. - * (Writing a '1' *clears* the bit.) - */ - outb(sc->nic_addr + ED_P0_ISR, isr); - - /* - * Handle transmitter interrupts. Handle these first because - * the receiver will reset the board under some conditions. - */ - if (isr & (ED_ISR_PTX | ED_ISR_TXE)) { - u_char collisions = - inb(sc->nic_addr + ED_P0_NCR) & 0x0f; - - /* - * Check for transmit error. If a TX completed with an - * error, we end up throwing the packet away. Really - * the only error that is possible is excessive - * collisions, and in this case it is best to allow the - * automatic mechanisms of TCP to backoff the flow. Of - * course, with UDP we're screwed, but this is expected - * when a network is heavily loaded. - */ - (void) inb(sc->nic_addr + ED_P0_TSR); - if (isr & ED_ISR_TXE) { - /* - * Excessive collisions (16). - */ - if ((inb(sc->nic_addr + ED_P0_TSR) & ED_TSR_ABT) - && (collisions == 0)) { - /* - * When collisions total 16, the P0_NCR - * will indicate 0, and the TSR_ABT is - * set. - */ - collisions = 16; - } - - /* Update output errors counter. */ - ++sc->sc_arpcom.ac_if.if_oerrors; - } else { - /* - * Update total number of successfully - * transmitted packets. - */ - ++sc->sc_arpcom.ac_if.if_opackets; - } - - /* Reset TX busy and output active flags. */ - sc->xmit_busy = 0; - sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - - /* Clear watchdog timer. */ - sc->sc_arpcom.ac_if.if_timer = 0; - - /* - * Add in total number of collisions on last - * transmission. - */ - sc->sc_arpcom.ac_if.if_collisions += collisions; - - /* - * Decrement buffer in-use count if not zero (can only - * be zero if a transmitter interrupt occured while not - * actually transmitting). - * If data is ready to transmit, start it transmitting, - * otherwise defer until after handling receiver. - */ - if (sc->txb_inuse && --sc->txb_inuse) - ed_xmit(sc); - } - - /* Handle receiver interrupts. */ - if (isr & (ED_ISR_PRX | ED_ISR_RXE | ED_ISR_OVW)) { - /* - * Overwrite warning. In order to make sure that a - * lockup of the local DMA hasn't occurred, we reset - * and re-init the NIC. The NSC manual suggests only a - * partial reset/re-init is necessary - but some chips - * seem to want more. The DMA lockup has been seen - * only with early rev chips - Methinks this bug was - * fixed in later revs. -DG - */ - if (isr & ED_ISR_OVW) { - ++sc->sc_arpcom.ac_if.if_ierrors; -#ifdef DIAGNOSTIC - log(LOG_WARNING, - "%s: warning - receiver ring buffer overrun\n", - sc->sc_dev.dv_xname); -#endif - /* Stop/reset/re-init NIC. */ - ed_reset(sc); - } else { - /* - * Receiver Error. One or more of: CRC error, - * frame alignment error FIFO overrun, or - * missed packet. - */ - if (isr & ED_ISR_RXE) { - ++sc->sc_arpcom.ac_if.if_ierrors; -#ifdef ED_DEBUG - printf("%s: receive error %x\n", - sc->sc_dev.dv_xname, - inb(sc->nic_addr + ED_P0_RSR)); -#endif - } - - /* - * Go get the packet(s). - * XXX - Doing this on an error is dubious - * because there shouldn't be any data to get - * (we've configured the interface to not - * accept packets with errors). - */ - - /* - * Enable 16bit access to shared memory first - * on WD/SMC boards. - */ - if (sc->vendor == ED_VENDOR_WD_SMC) { - if (sc->isa16bit) - outb(sc->asic_addr + ED_WD_LAAR, - sc->wd_laar_proto | ED_WD_LAAR_M16EN); - outb(sc->asic_addr + ED_WD_MSR, - sc->wd_msr_proto | ED_WD_MSR_MENB); - (void) inb(0x84); - (void) inb(0x84); - } - - ed_rint(sc); - - /* Disable 16-bit access. */ - if (sc->vendor == ED_VENDOR_WD_SMC) { - outb(sc->asic_addr + ED_WD_MSR, - sc->wd_msr_proto); - if (sc->isa16bit) - outb(sc->asic_addr + ED_WD_LAAR, - sc->wd_laar_proto); - (void) inb(0x84); - (void) inb(0x84); - } - } - } - - /* - * If it looks like the transmitter can take more data, attempt - * to start output on the interface. This is done after - * handling the receiver to give the receiver priority. - */ - if ((sc->sc_arpcom.ac_if.if_flags & IFF_OACTIVE) == 0) - ed_start(&sc->sc_arpcom.ac_if); - - /* - * Return NIC CR to standard state: page 0, remote DMA - * complete, start (toggling the TXP bit off, even if was just - * set in the transmit routine, is *okay* - it is 'edge' - * triggered from low to high). - */ - outb(sc->nic_addr + ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA); - - /* - * If the Network Talley Counters overflow, read them to reset - * them. It appears that old 8390's won't clear the ISR flag - * otherwise - resulting in an infinite loop. - */ - if (isr & ED_ISR_CNT) { - (void) inb(sc->nic_addr + ED_P0_CNTR0); - (void) inb(sc->nic_addr + ED_P0_CNTR1); - (void) inb(sc->nic_addr + ED_P0_CNTR2); - } - - isr = inb(sc->nic_addr + ED_P0_ISR); - if (!isr) - return (1); - } -} - -/* - * Process an ioctl request. This code needs some work - it looks pretty ugly. - */ -int -ed_ioctl(ifp, command, data) - register struct ifnet *ifp; - u_long command; - caddr_t data; -{ - struct ed_softc *sc = edcd.cd_devs[ifp->if_unit]; - register struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splimp(); - - switch (command) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - ed_init(sc); /* before arpwhohas */ - /* - * See if another station has *our* IP address. - * i.e.: There is an address conflict! If a - * conflict exists, a message is sent to the - * console. - */ - sc->sc_arpcom.ac_ipaddr = IA_SIN(ifa)->sin_addr; - arpwhohas(&sc->sc_arpcom, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - /* XXX - This code is probably wrong. */ - case AF_NS: - { - register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr; - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(sc->sc_arpcom.ac_enaddr); - else - bcopy(ina->x_host.c_host, - sc->sc_arpcom.ac_enaddr, - sizeof(sc->sc_arpcom.ac_enaddr)); - /* Set new address. */ - ed_init(sc); - break; - } -#endif - default: - ed_init(sc); - break; - } - break; - - case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, then - * stop it. - */ - ed_stop(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, then - * start it. - */ - ed_init(sc); - } else { - /* - * Reset the interface to pick up changes in any other - * flags that affect hardware registers. - */ - ed_stop(sc); - ed_init(sc); - } - break; - - case SIOCADDMULTI: - case SIOCDELMULTI: - /* Update our multicast list. */ - error = (command == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->sc_arpcom) : - ether_delmulti(ifr, &sc->sc_arpcom); - - if (error == ENETRESET) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - ed_stop(sc); /* XXX for ds_setmcaf? */ - ed_init(sc); - error = 0; - } - break; - default: - error = EINVAL; - } - (void) splx(s); - return (error); -} - -/* - * Retreive packet from shared memory and send to the next level up via - * ether_input(). If there is a BPF listener, give a copy to BPF, too. - */ -void -ed_get_packet(sc, buf, len) - struct ed_softc *sc; - caddr_t buf; - u_short len; -{ - struct ether_header *eh; - struct mbuf *m, *ed_ring_to_mbuf(); - - /* Allocate a header mbuf. */ - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return; - m->m_pkthdr.rcvif = &sc->sc_arpcom.ac_if; - m->m_pkthdr.len = len; - m->m_len = 0; - - /* The following silliness is to make NFS happy. */ -#define EROUND ((sizeof(struct ether_header) + 3) & ~3) -#define EOFF (EROUND - sizeof(struct ether_header)) - - /* - * The following assumes there is room for the ether header in the - * header mbuf. - */ - m->m_data += EOFF; - eh = mtod(m, struct ether_header *); - - if (sc->mem_shared) - bcopy(buf, mtod(m, caddr_t), sizeof(struct ether_header)); - else - ed_pio_readmem(sc, (u_short)buf, mtod(m, caddr_t), - sizeof(struct ether_header)); - buf += sizeof(struct ether_header); - m->m_len += sizeof(struct ether_header); - len -= sizeof(struct ether_header); - - /* Pull packet off interface. */ - if (ed_ring_to_mbuf(sc, buf, m, len) == 0) { - m_freem(m); - return; - } - -#if NBPFILTER > 0 - /* - * Check if there's a BPF listener on this interface. If so, hand off - * the raw packet to bpf. - */ - if (sc->sc_arpcom.ac_if.if_bpf) { - bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - */ - if ((sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */ - bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0) { - m_freem(m); - return; - } - } -#endif - - /* Fix up data start offset in mbuf to point past ether header. */ - m_adj(m, sizeof(struct ether_header)); - ether_input(&sc->sc_arpcom.ac_if, eh, m); -} - -/* - * Supporting routines. - */ - -/* - * Given a NIC memory source address and a host memory destination address, - * copy 'amount' from NIC to host using Programmed I/O. The 'amount' is - * rounded up to a word - okay as long as mbufs are word sized. - * This routine is currently Novell-specific. - */ -void -ed_pio_readmem(sc, src, dst, amount) - struct ed_softc *sc; - u_short src; - caddr_t dst; - u_short amount; -{ - /* Select page 0 registers. */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA); - - /* Round up to a word. */ - if (amount & 1) - ++amount; - - /* Set up DMA byte count. */ - outb(sc->nic_addr + ED_P0_RBCR0, amount); - outb(sc->nic_addr + ED_P0_RBCR1, amount >> 8); - - /* Set up source address in NIC mem. */ - outb(sc->nic_addr + ED_P0_RSAR0, src); - outb(sc->nic_addr + ED_P0_RSAR1, src >> 8); - - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD0 | ED_CR_PAGE_0 | ED_CR_STA); - - if (sc->isa16bit) - insw(sc->asic_addr + ED_NOVELL_DATA, dst, amount / 2); - else - insb(sc->asic_addr + ED_NOVELL_DATA, dst, amount); -} - -/* - * Stripped down routine for writing a linear buffer to NIC memory. Only used - * in the probe routine to test the memory. 'len' must be even. - */ -void -ed_pio_writemem(sc, src, dst, len) - struct ed_softc *sc; - caddr_t src; - u_short dst; - u_short len; -{ - int maxwait = 100; /* about 120us */ - - /* Select page 0 registers. */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA); - - /* Reset remote DMA complete flag. */ - outb(sc->nic_addr + ED_P0_ISR, ED_ISR_RDC); - - /* Set up DMA byte count. */ - outb(sc->nic_addr + ED_P0_RBCR0, len); - outb(sc->nic_addr + ED_P0_RBCR1, len >> 8); - - /* Set up destination address in NIC mem. */ - outb(sc->nic_addr + ED_P0_RSAR0, dst); - outb(sc->nic_addr + ED_P0_RSAR1, dst >> 8); - - /* Set remote DMA write. */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA); - - if (sc->isa16bit) - outsw(sc->asic_addr + ED_NOVELL_DATA, src, len / 2); - else - outsb(sc->asic_addr + ED_NOVELL_DATA, src, len); - - /* - * Wait for remote DMA complete. This is necessary because on the - * transmit side, data is handled internally by the NIC in bursts and - * we can't start another remote DMA until this one completes. Not - * waiting causes really bad things to happen - like the NIC - * irrecoverably jamming the ISA bus. - */ - while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait); -} - -/* - * Write an mbuf chain to the destination NIC memory address using programmed - * I/O. - */ -u_short -ed_pio_write_mbufs(sc, m, dst) - struct ed_softc *sc; - struct mbuf *m; - u_short dst; -{ - u_short len; - struct mbuf *mp; - int maxwait = 100; /* about 120us */ - - /* First, count up the total number of bytes to copy. */ - for (len = 0, mp = m; mp; mp = mp->m_next) - len += mp->m_len; - - /* Select page 0 registers. */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA); - - /* Reset remote DMA complete flag. */ - outb(sc->nic_addr + ED_P0_ISR, ED_ISR_RDC); - - /* Set up DMA byte count. */ - outb(sc->nic_addr + ED_P0_RBCR0, len); - outb(sc->nic_addr + ED_P0_RBCR1, len >> 8); - - /* Set up destination address in NIC mem. */ - outb(sc->nic_addr + ED_P0_RSAR0, dst); - outb(sc->nic_addr + ED_P0_RSAR1, dst >> 8); - - /* Set remote DMA write. */ - outb(sc->nic_addr + ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA); - - /* - * Transfer the mbuf chain to the NIC memory. - * 16-bit cards require that data be transferred as words, and only - * words, so that case requires some extra code to patch over - * odd-length mbufs. - */ - if (!sc->isa16bit) { - /* NE1000s are easy. */ - for (; m != 0; m = m->m_next) { - if (m->m_len) { - outsb(sc->asic_addr + ED_NOVELL_DATA, - mtod(m, u_char *), m->m_len); - } - } - } else { - /* NE2000s are a bit trickier. */ - u_char *data, savebyte[2]; - int len, wantbyte; - - wantbyte = 0; - - for (; m != 0; m = m->m_next) { - data = mtod(m, u_char *); - len = m->m_len; - if (len > 0) { - /* Finish the last word. */ - if (wantbyte) { - savebyte[1] = *data; - outw(sc->asic_addr + ED_NOVELL_DATA, - *(u_short *)savebyte); - data++; - len--; - wantbyte = 0; - } - /* Output contiguous words. */ - if (len > 1) { - outsw(sc->asic_addr + ED_NOVELL_DATA, - data, len >> 1); - data += len & ~1; - len &= 1; - } - /* Save last byte, if necessary. */ - if (len == 1) { - savebyte[0] = *data; - wantbyte = 1; - } - } - } - - if (wantbyte) { - savebyte[1] = 0; - outw(sc->asic_addr + ED_NOVELL_DATA, - *(u_short *)savebyte); - } - } - - /* - * Wait for remote DMA complete. This is necessary because on the - * transmit side, data is handled internally by the NIC in bursts and - * we can't start another remote DMA until this one completes. Not - * waiting causes really bad things to happen - like the NIC - * irrecoverably jamming the ISA bus. - */ - while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait); - - if (!maxwait) { - log(LOG_WARNING, - "%s: remote transmit DMA failed to complete\n", - sc->sc_dev.dv_xname); - ed_reset(sc); - } - - return (len); -} - -/* - * Given a source and destination address, copy 'amount' of a packet from the - * ring buffer into a linear destination buffer. Takes into account ring-wrap. - */ -static inline char * -ed_ring_copy(sc, src, dst, amount) - struct ed_softc *sc; - char *src; - char *dst; - u_short amount; -{ - u_short tmp_amount; - - /* Does copy wrap to lower addr in ring buffer? */ - if (src + amount > sc->mem_end) { - tmp_amount = sc->mem_end - src; - - /* Copy amount up to end of NIC memory. */ - if (sc->mem_shared) - bcopy(src, dst, tmp_amount); - else - ed_pio_readmem(sc, (u_short)src, dst, tmp_amount); - - amount -= tmp_amount; - src = sc->mem_ring; - dst += tmp_amount; - } - - if (sc->mem_shared) - bcopy(src, dst, amount); - else - ed_pio_readmem(sc, (u_short)src, dst, amount); - - return (src + amount); -} - -/* - * Copy data from receive buffer to end of mbuf chain allocate additional mbufs - * as needed. Return pointer to last mbuf in chain. - * sc = ed info (softc) - * src = pointer in ed ring buffer - * dst = pointer to last mbuf in mbuf chain to copy to - * amount = amount of data to copy - */ -struct mbuf * -ed_ring_to_mbuf(sc, src, dst, total_len) - struct ed_softc *sc; - caddr_t src; - struct mbuf *dst; - u_short total_len; -{ - register struct mbuf *m = dst; - - while (total_len) { - register u_short amount = min(total_len, M_TRAILINGSPACE(m)); - - if (amount == 0) { - /* - * No more data in this mbuf; alloc another. - * - * If there is enough data for an mbuf cluster, attempt - * to allocate one of those, otherwise, a regular mbuf - * will do. - * Note that a regular mbuf is always required, even if - * we get a cluster - getting a cluster does not - * allocate any mbufs, and one is needed to assign the - * cluster to. The mbuf that has a cluster extension - * can not be used to contain data - only the cluster - * can contain data. - */ - dst = m; - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return (0); - - if (total_len >= MINCLSIZE) - MCLGET(m, M_DONTWAIT); - - m->m_len = 0; - dst->m_next = m; - amount = min(total_len, M_TRAILINGSPACE(m)); - } - - src = ed_ring_copy(sc, src, mtod(m, caddr_t) + m->m_len, - amount); - - m->m_len += amount; - total_len -= amount; - - } - return (m); -} - -/* - * Compute the multicast address filter from the list of multicast addresses we - * need to listen to. - */ -void -ed_getmcaf(ac, af) - struct arpcom *ac; - u_long *af; -{ - struct ifnet *ifp = &ac->ac_if; - struct ether_multi *enm; - register u_char *cp, c; - register u_long crc; - register int i, len; - struct ether_multistep step; - - /* - * Set up multicast address filter by passing all multicast addresses - * through a crc generator, and then using the high order 6 bits as an - * index into the 64 bit logical address filter. The high order bit - * selects the word, while the rest of the bits select the bit within - * the word. - */ - - if (ifp->if_flags & IFF_PROMISC) { - ifp->if_flags |= IFF_ALLMULTI; - af[0] = af[1] = 0xffffffff; - return; - } - - af[0] = af[1] = 0; - ETHER_FIRST_MULTI(step, ac, enm); - while (enm != NULL) { - if (bcmp(enm->enm_addrlo, enm->enm_addrhi, - sizeof(enm->enm_addrlo)) != 0) { - /* - * We must listen to a range of multicast addresses. - * For now, just accept all multicasts, rather than - * trying to set only those filter bits needed to match - * the range. (At this time, the only use of address - * ranges is for IP multicast routing, for which the - * range is big enough to require all bits set.) - */ - ifp->if_flags |= IFF_ALLMULTI; - af[0] = af[1] = 0xffffffff; - return; - } - - cp = enm->enm_addrlo; - crc = 0xffffffff; - for (len = sizeof(enm->enm_addrlo); --len >= 0;) { - c = *cp++; - for (i = 8; --i >= 0;) { - if (((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01)) { - crc <<= 1; - crc ^= 0x04c11db6 | 1; - } else - crc <<= 1; - c >>= 1; - } - } - /* Just want the 6 most significant bits. */ - crc >>= 26; - - /* Turn on the corresponding bit in the filter. */ - af[crc >> 5] |= 1 << ((crc & 0x1f) ^ 24); - - ETHER_NEXT_MULTI(step, enm); - } - ifp->if_flags &= ~IFF_ALLMULTI; -} diff --git a/sys/arch/i386/isa/if_edreg.h b/sys/arch/i386/isa/if_edreg.h deleted file mode 100644 index 00a1bf66a84a..000000000000 --- a/sys/arch/i386/isa/if_edreg.h +++ /dev/null @@ -1,932 +0,0 @@ -/* $NetBSD: if_edreg.h,v 1.13 1995/01/02 20:32:59 mycroft Exp $ */ - -/* - * National Semiconductor DS8390 NIC register definitions. - * - * Copyright (C) 1993, David Greenman. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided that - * the above copyright and these terms are retained. Under no circumstances is - * the author responsible for the proper functioning of this software, nor does - * the author assume any responsibility for damages incurred with its use. - */ - -/* - * Page 0 register offsets - */ -#define ED_P0_CR 0x00 /* Command Register */ - -#define ED_P0_CLDA0 0x01 /* Current Local DMA Addr low (read) */ -#define ED_P0_PSTART 0x01 /* Page Start register (write) */ - -#define ED_P0_CLDA1 0x02 /* Current Local DMA Addr high (read) */ -#define ED_P0_PSTOP 0x02 /* Page Stop register (write) */ - -#define ED_P0_BNRY 0x03 /* Boundary Pointer */ - -#define ED_P0_TSR 0x04 /* Transmit Status Register (read) */ -#define ED_P0_TPSR 0x04 /* Transmit Page Start (write) */ - -#define ED_P0_NCR 0x05 /* Number of Collisions Reg (read) */ -#define ED_P0_TBCR0 0x05 /* Transmit Byte count, low (write) */ - -#define ED_P0_FIFO 0x06 /* FIFO register (read) */ -#define ED_P0_TBCR1 0x06 /* Transmit Byte count, high (write) */ - -#define ED_P0_ISR 0x07 /* Interrupt Status Register */ - -#define ED_P0_CRDA0 0x08 /* Current Remote DMA Addr low (read) */ -#define ED_P0_RSAR0 0x08 /* Remote Start Address low (write) */ - -#define ED_P0_CRDA1 0x09 /* Current Remote DMA Addr high (read) */ -#define ED_P0_RSAR1 0x09 /* Remote Start Address high (write) */ - -#define ED_P0_RBCR0 0x0a /* Remote Byte Count low (write) */ - -#define ED_P0_RBCR1 0x0b /* Remote Byte Count high (write) */ - -#define ED_P0_RSR 0x0c /* Receive Status (read) */ -#define ED_P0_RCR 0x0c /* Receive Configuration Reg (write) */ - -#define ED_P0_CNTR0 0x0d /* frame alignment error counter (read) */ -#define ED_P0_TCR 0x0d /* Transmit Configuration Reg (write) */ - -#define ED_P0_CNTR1 0x0e /* CRC error counter (read) */ -#define ED_P0_DCR 0x0e /* Data Configuration Reg (write) */ - -#define ED_P0_CNTR2 0x0f /* missed packet counter (read) */ -#define ED_P0_IMR 0x0f /* Interrupt Mask Register (write) */ - -/* - * Page 1 register offsets - */ -#define ED_P1_CR 0x00 /* Command Register */ -#define ED_P1_PAR0 0x01 /* Physical Address Register 0 */ -#define ED_P1_PAR1 0x02 /* Physical Address Register 1 */ -#define ED_P1_PAR2 0x03 /* Physical Address Register 2 */ -#define ED_P1_PAR3 0x04 /* Physical Address Register 3 */ -#define ED_P1_PAR4 0x05 /* Physical Address Register 4 */ -#define ED_P1_PAR5 0x06 /* Physical Address Register 5 */ -#define ED_P1_CURR 0x07 /* Current RX ring-buffer page */ -#define ED_P1_MAR0 0x08 /* Multicast Address Register 0 */ -#define ED_P1_MAR1 0x09 /* Multicast Address Register 1 */ -#define ED_P1_MAR2 0x0a /* Multicast Address Register 2 */ -#define ED_P1_MAR3 0x0b /* Multicast Address Register 3 */ -#define ED_P1_MAR4 0x0c /* Multicast Address Register 4 */ -#define ED_P1_MAR5 0x0d /* Multicast Address Register 5 */ -#define ED_P1_MAR6 0x0e /* Multicast Address Register 6 */ -#define ED_P1_MAR7 0x0f /* Multicast Address Register 7 */ - -/* - * Page 2 register offsets - */ -#define ED_P2_CR 0x00 /* Command Register */ -#define ED_P2_PSTART 0x01 /* Page Start (read) */ -#define ED_P2_CLDA0 0x01 /* Current Local DMA Addr 0 (write) */ -#define ED_P2_PSTOP 0x02 /* Page Stop (read) */ -#define ED_P2_CLDA1 0x02 /* Current Local DMA Addr 1 (write) */ -#define ED_P2_RNPP 0x03 /* Remote Next Packet Pointer */ -#define ED_P2_TPSR 0x04 /* Transmit Page Start (read) */ -#define ED_P2_LNPP 0x05 /* Local Next Packet Pointer */ -#define ED_P2_ACU 0x06 /* Address Counter Upper */ -#define ED_P2_ACL 0x07 /* Address Counter Lower */ -#define ED_P2_RCR 0x0c /* Receive Configuration Register (read) */ -#define ED_P2_TCR 0x0d /* Transmit Configuration Register (read) */ -#define ED_P2_DCR 0x0e /* Data Configuration Register (read) */ -#define ED_P2_IMR 0x0f /* Interrupt Mask Register (read) */ - -/* - * Command Register (CR) definitions - */ - -/* - * STP: SToP. Software reset command. Takes the controller offline. No - * packets will be received or transmitted. Any reception or transmission in - * progress will continue to completion before entering reset state. To exit - * this state, the STP bit must reset and the STA bit must be set. The - * software reset has executed only when indicated by the RST bit in the ISR - * being set. - */ -#define ED_CR_STP 0x01 - -/* - * STA: STArt. This bit is used to activate the NIC after either power-up, or - * when the NIC has been put in reset mode by software command or error. - */ -#define ED_CR_STA 0x02 - -/* - * TXP: Transmit Packet. This bit must be set to indicate transmission of a - * packet. TXP is internally reset either after the transmission is completed - * or aborted. This bit should be set only after the Transmit Byte Count and - * Transmit Page Start register have been programmed. - */ -#define ED_CR_TXP 0x04 - -/* - * RD0, RD1, RD2: Remote DMA Command. These three bits control the operation - * of the remote DMA channel. RD2 can be set to abort any remote DMA command - * in progress. The Remote Byte Count registers should be cleared when a - * remote DMA has been aborted. The Remote Start Addresses are not restored - * to the starting address if the remote DMA is aborted. - * - * RD2 RD1 RD0 function - * 0 0 0 not allowed - * 0 0 1 remote read - * 0 1 0 remote write - * 0 1 1 send packet - * 1 X X abort - */ -#define ED_CR_RD0 0x08 -#define ED_CR_RD1 0x10 -#define ED_CR_RD2 0x20 - -/* - * PS0, PS1: Page Select. The two bits select which register set or 'page' to - * access. - * - * PS1 PS0 page - * 0 0 0 - * 0 1 1 - * 1 0 2 - * 1 1 reserved - */ -#define ED_CR_PS0 0x40 -#define ED_CR_PS1 0x80 -/* bit encoded aliases */ -#define ED_CR_PAGE_0 0x00 /* (for consistency) */ -#define ED_CR_PAGE_1 0x40 -#define ED_CR_PAGE_2 0x80 - -/* - * Interrupt Status Register (ISR) definitions - */ - -/* - * PRX: Packet Received. Indicates packet received with no errors. - */ -#define ED_ISR_PRX 0x01 - -/* - * PTX: Packet Transmitted. Indicates packet transmitted with no errors. - */ -#define ED_ISR_PTX 0x02 - -/* - * RXE: Receive Error. Indicates that a packet was received with one or more - * the following errors: CRC error, frame alignment error, FIFO overrun, - * missed packet. - */ -#define ED_ISR_RXE 0x04 - -/* - * TXE: Transmission Error. Indicates that an attempt to transmit a packet - * resulted in one or more of the following errors: excessive collisions, FIFO - * underrun. - */ -#define ED_ISR_TXE 0x08 - -/* - * OVW: OverWrite. Indicates a receive ring-buffer overrun. Incoming network - * would exceed (has exceeded?) the boundary pointer, resulting in data that - * was previously received and not yet read from the buffer to be overwritten. - */ -#define ED_ISR_OVW 0x10 - -/* - * CNT: Counter Overflow. Set when the MSB of one or more of the Network Tally - * Counters has been set. - */ -#define ED_ISR_CNT 0x20 - -/* - * RDC: Remote Data Complete. Indicates that a Remote DMA operation has - * completed. - */ -#define ED_ISR_RDC 0x40 - -/* - * RST: Reset status. Set when the NIC enters the reset state and cleared when - * a Start Command is issued to the CR. This bit is also set when a receive - * ring-buffer overrun (OverWrite) occurs and is cleared when one or more - * packets have been removed from the ring. This is a read-only bit. - */ -#define ED_ISR_RST 0x80 - -/* - * Interrupt Mask Register (IMR) definitions - */ - -/* - * PRXE: Packet Received interrupt Enable. If set, a received packet will - * cause an interrupt. - */ -#define ED_IMR_PRXE 0x01 - -/* - * PTXE: Packet Transmit interrupt Enable. If set, an interrupt is generated - * when a packet transmission completes. - */ -#define ED_IMR_PTXE 0x02 - -/* - * RXEE: Receive Error interrupt Enable. If set, an interrupt will occur - * whenever a packet is received with an error. - */ -#define ED_IMR_RXEE 0x04 - -/* - * TXEE: Transmit Error interrupt Enable. If set, an interrupt will occur - * whenever a transmission results in an error. - */ -#define ED_IMR_TXEE 0x08 - -/* - * OVWE: OverWrite error interrupt Enable. If set, an interrupt is generated - * whenever the receive ring-buffer is overrun. i.e. when the boundary pointer - * is exceeded. - */ -#define ED_IMR_OVWE 0x10 - -/* - * CNTE: Counter overflow interrupt Enable. If set, an interrupt is generated - * whenever the MSB of one or more of the Network Statistics counters has been - * set. - */ -#define ED_IMR_CNTE 0x20 - -/* - * RDCE: Remote DMA Complete interrupt Enable. If set, an interrupt is - * generated when a remote DMA transfer has completed. - */ -#define ED_IMR_RDCE 0x40 - -/* - * Bit 7 is unused/reserved. - */ - -/* - * Data Configuration Register (DCR) definitions - */ - -/* - * WTS: Word Transfer Select. WTS establishes byte or word transfers for both - * remote and local DMA transfers - */ -#define ED_DCR_WTS 0x01 - -/* - * BOS: Byte Order Select. BOS sets the byte order for the host. Should be 0 - * for 80x86, and 1 for 68000 series processors - */ -#define ED_DCR_BOS 0x02 - -/* - * LAS: Long Address Select. When LAS is 1, the contents of the remote DMA - * registers RSAR0 and RSAR1 are used to provide A16-A31. - */ -#define ED_DCR_LAS 0x04 - -/* - * LS: Loopback Select. When 0, loopback mode is selected. Bits D1 and D2 of - * the TCR must also be programmed for loopback operation. When 1, normal - * operation is selected. - */ -#define ED_DCR_LS 0x08 - -/* - * AR: Auto-initialize Remote. When 0, data must be removed from ring-buffer - * under program control. When 1, remote DMA is automatically initiated and - * the boundary pointer is automatically updated. - */ -#define ED_DCR_AR 0x10 - -/* - * FT0, FT1: Fifo Threshold select. - * - * FT1 FT0 Word-width Byte-width - * 0 0 1 word 2 bytes - * 0 1 2 words 4 bytes - * 1 0 4 words 8 bytes - * 1 1 8 words 12 bytes - * - * During transmission, the FIFO threshold indicates the number of bytes or - * words that the FIFO has filled from the local DMA before BREQ is asserted. - * The transmission threshold is 16 bytes minus the receiver threshold. - */ -#define ED_DCR_FT0 0x20 -#define ED_DCR_FT1 0x40 - -/* - * bit 7 (0x80) is unused/reserved - */ - -/* - * Transmit Configuration Register (TCR) definitions - */ - -/* - * CRC: Inhibit CRC. If 0, CRC will be appended by the transmitter, if 0, CRC - * is not appended by the transmitter. - */ -#define ED_TCR_CRC 0x01 - -/* - * LB0, LB1: Loopback control. These two bits set the type of loopback that is - * to be performed. - * - * LB1 LB0 mode - * 0 0 0 - normal operation (DCR_LS = 0) - * 0 1 1 - internal loopback (DCR_LS = 0) - * 1 0 2 - external loopback (DCR_LS = 1) - * 1 1 3 - external loopback (DCR_LS = 0) - */ -#define ED_TCR_LB0 0x02 -#define ED_TCR_LB1 0x04 - -/* - * ATD: Auto Transmit Disable. Clear for normal operation. When set, allows - * another station to disable the NIC's transmitter by transmitting to a - * multicast address hashing to bit 62. Reception of a multicast address - * hashing to bit 63 enables the transmitter. - */ -#define ED_TCR_ATD 0x08 - -/* - * OFST: Collision Offset enable. This bit when set modifies the backoff - * algorithm to allow prioritization of nodes. - */ -#define ED_TCR_OFST 0x10 - -/* - * bits 5, 6, and 7 are unused/reserved - */ - -/* - * Transmit Status Register (TSR) definitions - */ - -/* - * PTX: Packet Transmitted. Indicates successful transmission of packet. - */ -#define ED_TSR_PTX 0x01 - -/* - * bit 1 (0x02) is unused/reserved - */ - -/* - * COL: Transmit Collided. Indicates that the transmission collided at least - * once with another station on the network. - */ -#define ED_TSR_COL 0x04 - -/* - * ABT: Transmit aborted. Indicates that the transmission was aborted due to - * excessive collisions. - */ -#define ED_TSR_ABT 0x08 - -/* - * CRS: Carrier Sense Lost. Indicates that carrier was lost during the - * transmission of the packet. (Transmission is not aborted because of a loss - * of carrier). - */ -#define ED_TSR_CRS 0x10 - -/* - * FU: FIFO Underrun. Indicates that the NIC wasn't able to access bus/ - * transmission memory before the FIFO emptied. Transmission of the packet was - * aborted. - */ -#define ED_TSR_FU 0x20 - -/* - * CDH: CD Heartbeat. Indicates that the collision detection circuitry isn't - * working correctly during a collision heartbeat test. - */ -#define ED_TSR_CDH 0x40 - -/* - * OWC: Out of Window Collision: Indicates that a collision occurred after a - * slot time (51.2us). The transmission is rescheduled just as in normal - * collisions. - */ -#define ED_TSR_OWC 0x80 - -/* - * Receiver Configuration Register (RCR) definitions - */ - -/* - * SEP: Save Errored Packets. If 0, error packets are discarded. If set to 1, - * packets with CRC and frame errors are not discarded. - */ -#define ED_RCR_SEP 0x01 - -/* - * AR: Accept Runt packet. If 0, packet with less than 64 byte are discarded. - * If set to 1, packets with less than 64 byte are not discarded. - */ -#define ED_RCR_AR 0x02 - -/* - * AB: Accept Broadcast. If set, packets sent to the broadcast address will be - * accepted. - */ -#define ED_RCR_AB 0x04 - -/* - * AM: Accept Multicast. If set, packets sent to a multicast address are - * checked for a match in the hashing array. If clear, multicast packets are - * ignored. - */ -#define ED_RCR_AM 0x08 - -/* - * PRO: Promiscuous Physical. If set, all packets with a physical addresses - * are accepted. If clear, a physical destination address must match this - * station's address. Note: for full promiscuous mode, RCR_AB and RCR_AM must - * also be set. In addition, the multicast hashing array must be set to all - * 1's so that all multicast addresses are accepted. - */ -#define ED_RCR_PRO 0x10 - -/* - * MON: Monitor Mode. If set, packets will be checked for good CRC and - * framing, but are not stored in the ring-buffer. If clear, packets are - * stored (normal operation). - */ -#define ED_RCR_MON 0x20 - -/* - * Bits 6 and 7 are unused/reserved. - */ - -/* - * Receiver Status Register (RSR) definitions - */ - -/* - * PRX: Packet Received without error. - */ -#define ED_RSR_PRX 0x01 - -/* - * CRC: CRC error. Indicates that a packet has a CRC error. Also set for - * frame alignment errors. - */ -#define ED_RSR_CRC 0x02 - -/* - * FAE: Frame Alignment Error. Indicates that the incoming packet did not end - * on a byte boundary and the CRC did not match at the last byte boundary. - */ -#define ED_RSR_FAE 0x04 - -/* - * FO: FIFO Overrun. Indicates that the FIFO was not serviced (during local - * DMA) causing it to overrun. Reception of the packet is aborted. - */ -#define ED_RSR_FO 0x08 - -/* - * MPA: Missed Packet. Indicates that the received packet couldn't be stored - * in the ring-buffer because of insufficient buffer space (exceeding the - * boundary pointer), or because the transfer to the ring-buffer was inhibited - * by RCR_MON - monitor mode. - */ -#define ED_RSR_MPA 0x10 - -/* - * PHY: Physical address. If 0, the packet received was sent to a physical - * address. If 1, the packet was accepted because of a multicast/broadcast - * address match. - */ -#define ED_RSR_PHY 0x20 - -/* - * DIS: Receiver Disabled. Set to indicate that the receiver has enetered - * monitor mode. Cleared when the receiver exits monitor mode. - */ -#define ED_RSR_DIS 0x40 - -/* - * DFR: Deferring. Set to indicate a 'jabber' condition. The CRS and COL - * inputs are active, and the transceiver has set the CD line as a result of - * the jabber. - */ -#define ED_RSR_DFR 0x80 - -/* - * receive ring discriptor - * - * The National Semiconductor DS8390 Network interface controller uses the - * following receive ring headers. The way this works is that the memory on - * the interface card is chopped up into 256 bytes blocks. A contiguous - * portion of those blocks are marked for receive packets by setting start and - * end block #'s in the NIC. For each packet that is put into the receive - * ring, one of these headers (4 bytes each) is tacked onto the front. The - * first byte is a copy of the receiver status register at the time the packet - * was received. - */ -struct ed_ring { - u_char rsr; /* receiver status */ - u_char next_packet; /* pointer to next packet */ - u_short count; /* bytes in packet (length + 4) */ -}; - -/* - * Common constants - */ -#define ED_PAGE_SIZE 256 /* Size of RAM pages in bytes */ -#define ED_PAGE_MASK 255 -#define ED_PAGE_SHIFT 8 - -#define ED_TXBUF_SIZE 6 /* Size of TX buffer in pages */ - -/* - * Vendor types - */ -#define ED_VENDOR_WD_SMC 0x00 /* Western Digital/SMC */ -#define ED_VENDOR_3COM 0x01 /* 3Com */ -#define ED_VENDOR_NOVELL 0x02 /* Novell */ - -/* - * Compile-time config flags - */ -/* - * This sets the default for enabling/disablng the tranceiver. - */ -#define ED_FLAGS_DISABLE_TRANCEIVER 0x0001 - -/* - * This forces the board to be used in 8/16-bit mode even if it autoconfigs - * differently. - */ -#define ED_FLAGS_FORCE_8BIT_MODE 0x0002 -#define ED_FLAGS_FORCE_16BIT_MODE 0x0004 - -/* - * This disables the use of double transmit buffers. - */ -#define ED_FLAGS_NO_MULTI_BUFFERING 0x0008 - -/* - * This forces all operations with the NIC memory to use Programmed I/O (i.e. - * not via shared memory). - */ -#define ED_FLAGS_FORCE_PIO 0x0010 - -/* - * Definitions for Western digital/SMC WD80x3 series ASIC - */ -/* - * Memory Select Register (MSR) - */ -#define ED_WD_MSR 0 - -/* next three definitions for Toshiba */ -#define ED_WD_MSR_POW 0x02 /* 0 = power save, 1 = normal (R/W) */ -#define ED_WD_MSR_BSY 0x04 /* gate array busy (R) */ -#define ED_WD_MSR_LEN 0x20 /* 0 = 16-bit, 1 = 8-bit (R/W) */ - -#define ED_WD_MSR_ADDR 0x3f /* Memory decode bits 18-13 */ -#define ED_WD_MSR_MENB 0x40 /* Memory enable */ -#define ED_WD_MSR_RST 0x80 /* Reset board */ - -/* - * Interface Configuration Register (ICR) - */ -#define ED_WD_ICR 1 - -#define ED_WD_ICR_16BIT 0x01 /* 16-bit interface */ -#define ED_WD_ICR_OAR 0x02 /* select register (0=BIO 1=EAR) */ -#define ED_WD_ICR_IR2 0x04 /* high order bit of encoded IRQ */ -#define ED_WD_ICR_MSZ 0x08 /* memory size (0=8k 1=32k) */ -#define ED_WD_ICR_RLA 0x10 /* recall LAN address */ -#define ED_WD_ICR_RX7 0x20 /* recall all but i/o and LAN address */ -#define ED_WD_ICR_RIO 0x40 /* recall i/o address */ -#define ED_WD_ICR_STO 0x80 /* store to non-volatile memory */ -#ifdef TOSH_ETHER -#define ED_WD_ICR_MEM 0xe0 /* shared mem address A15-A13 (R/W) */ -#define ED_WD_ICR_MSZ1 0x0f /* memory size, 0x08 = 64K, 0x04 = 32K, - 0x02 = 16K, 0x01 = 8K */ - /* 64K can only be used if mem address - above 1MB */ - /* IAR holds address A23-A16 (R/W) */ -#endif - -/* - * IO Address Register (IAR) - */ -#define ED_WD_IAR 2 - -/* - * EEROM Address Register - */ -#define ED_WD_EAR 3 - -/* - * Interrupt Request Register (IRR) - */ -#define ED_WD_IRR 4 - -#define ED_WD_IRR_0WS 0x01 /* use 0 wait-states on 8 bit bus */ -#define ED_WD_IRR_OUT1 0x02 /* WD83C584 pin 1 output */ -#define ED_WD_IRR_OUT2 0x04 /* WD83C584 pin 2 output */ -#define ED_WD_IRR_OUT3 0x08 /* WD83C584 pin 3 output */ -#define ED_WD_IRR_FLASH 0x10 /* Flash RAM is in the ROM socket */ - -/* - * The three bits of the encoded IRQ are decoded as follows: - * - * IR2 IR1 IR0 IRQ - * 0 0 0 2/9 - * 0 0 1 3 - * 0 1 0 5 - * 0 1 1 7 - * 1 0 0 10 - * 1 0 1 11 - * 1 1 0 15 - * 1 1 1 4 - */ -#define ED_WD_IRR_IR0 0x20 /* bit 0 of encoded IRQ */ -#define ED_WD_IRR_IR1 0x40 /* bit 1 of encoded IRQ */ -#define ED_WD_IRR_IEN 0x80 /* Interrupt enable */ - -/* - * LA Address Register (LAAR) - */ -#define ED_WD_LAAR 5 - -#define ED_WD_LAAR_ADDRHI 0x1f /* bits 23-19 of RAM address */ -#define ED_WD_LAAR_0WS16 0x20 /* enable 0 wait-states on 16 bit bus */ -#define ED_WD_LAAR_L16EN 0x40 /* enable 16-bit operation */ -#define ED_WD_LAAR_M16EN 0x80 /* enable 16-bit memory access */ - -/* i/o base offset to station address/card-ID PROM */ -#define ED_WD_PROM 8 - -/* - * 83C790 specific registers - */ -/* - * Hardware Support Register (HWR) ('790) - */ -#define ED_WD790_HWR 4 - -#define ED_WD790_HWR_RST 0x10 /* hardware reset */ -#define ED_WD790_HWR_LPRM 0x40 /* LAN PROM select */ -#define ED_WD790_HWR_SWH 0x80 /* switch register set */ - -/* - * ICR790 Interrupt Control Register for the 83C790 - */ -#define ED_WD790_ICR 6 - -#define ED_WD790_ICR_EIL 0x01 /* enable interrupts */ - -/* - * General Control Register (GCR) - * Eanbled with SWH bit == 1 in HWR register - */ -#define ED_WD790_GCR 0x0d - -#define ED_WD790_GCR_IR0 0x04 /* bit 0 of encoded IRQ */ -#define ED_WD790_GCR_IR1 0x08 /* bit 1 of encoded IRQ */ -#define ED_WD790_GCR_ZWSEN 0x20 /* zero wait state enable */ -#define ED_WD790_GCR_IR2 0x40 /* bit 2 of encoded IRQ */ -/* - * The three bits of the encoded IRQ are decoded as follows: - * - * IR2 IR1 IR0 IRQ - * 0 0 0 none - * 0 0 1 9 - * 0 1 0 3 - * 0 1 1 5 - * 1 0 0 7 - * 1 0 1 10 - * 1 1 0 11 - * 1 1 1 15 - */ - -/* i/o base offset to CARD ID */ -#define ED_WD_CARD_ID ED_WD_PROM+6 - -/* Board type codes in card ID */ -#define ED_TYPE_WD8003S 0x02 -#define ED_TYPE_WD8003E 0x03 -#define ED_TYPE_WD8013EBT 0x05 -#define ED_TYPE_TOSHIBA1 0x11 /* named PCETA1 */ -#define ED_TYPE_TOSHIBA2 0x12 /* named PCETA2 */ -#define ED_TYPE_TOSHIBA3 0x13 /* named PCETB */ -#define ED_TYPE_TOSHIBA4 0x14 /* named PCETC */ -#define ED_TYPE_WD8003W 0x24 -#define ED_TYPE_WD8003EB 0x25 -#define ED_TYPE_WD8013W 0x26 -#define ED_TYPE_WD8013EP 0x27 -#define ED_TYPE_WD8013WC 0x28 -#define ED_TYPE_WD8013EPC 0x29 -#define ED_TYPE_SMC8216T 0x2a -#define ED_TYPE_SMC8216C 0x2b -#define ED_TYPE_WD8013EBP 0x2c - -/* Bit definitions in card ID */ -#define ED_WD_REV_MASK 0x1f /* Revision mask */ -#define ED_WD_SOFTCONFIG 0x20 /* Soft config */ -#define ED_WD_LARGERAM 0x40 /* Large RAM */ -#define ED_MICROCHANEL 0x80 /* Microchannel bus (vs. isa) */ - -/* - * Checksum total. All 8 bytes in station address PROM will add up to this. - */ -#ifdef TOSH_ETHER -#define ED_WD_ROM_CHECKSUM_TOTAL 0xA5 -#else -#define ED_WD_ROM_CHECKSUM_TOTAL 0xFF -#endif - -#define ED_WD_NIC_OFFSET 0x10 /* I/O base offset to NIC */ -#define ED_WD_ASIC_OFFSET 0 /* I/O base offset to ASIC */ -#define ED_WD_IO_PORTS 32 /* # of i/o addresses used */ - -#define ED_WD_PAGE_OFFSET 0 /* page offset for NIC access to mem */ - -/* - * Definitions for 3Com 3c503 - */ -#define ED_3COM_NIC_OFFSET 0 -#define ED_3COM_ASIC_OFFSET 0x400 /* offset to nic i/o regs */ - -/* - * XXX - The I/O address range is fragmented in the 3c503; this is the - * number of regs at iobase. - */ -#define ED_3COM_IO_PORTS 16 /* # of i/o addresses used */ - -/* tx memory starts in second bank on 8bit cards */ -#define ED_3COM_TX_PAGE_OFFSET_8BIT 0x20 - -/* tx memory starts in first bank on 16bit cards */ -#define ED_3COM_TX_PAGE_OFFSET_16BIT 0x0 - -/* ...and rx memory starts in second bank */ -#define ED_3COM_RX_PAGE_OFFSET_16BIT 0x20 - - -/* - * Page Start Register. Must match PSTART in NIC. - */ -#define ED_3COM_PSTR 0 - -/* - * Page Stop Register. Must match PSTOP in NIC. - */ -#define ED_3COM_PSPR 1 - -/* - * DrQ Timer Register. Determines number of bytes to be transfered during a - * DMA burst. - */ -#define ED_3COM_DQTR 2 - -/* - * Base Configuration Register. Read-only register which contains the - * board-configured I/O base address of the adapter. Bit encoded. - */ -#define ED_3COM_BCFR 3 - -/* - * EPROM Configuration Register. Read-only register which contains the - * board-configured memory base address. Bit encoded. - */ -#define ED_3COM_PCFR 4 - -/* - * GA Configuration Register. Gate-Array Configuration Register. - * - * mbs2 mbs1 mbs0 start address - * 0 0 0 0x0000 - * 0 0 1 0x2000 - * 0 1 0 0x4000 - * 0 1 1 0x6000 - * - * Note that with adapters with only 8K, the setting for 0x2000 must always be - * used. - */ -#define ED_3COM_GACFR 5 - -#define ED_3COM_GACFR_MBS0 0x01 -#define ED_3COM_GACFR_MBS1 0x02 -#define ED_3COM_GACFR_MBS2 0x04 - -#define ED_3COM_GACFR_RSEL 0x08 /* enable shared memory */ -#define ED_3COM_GACFR_TEST 0x10 /* for GA testing */ -#define ED_3COM_GACFR_OWS 0x20 /* select 0WS access to GA */ -#define ED_3COM_GACFR_TCM 0x40 /* Mask DMA interrupts */ -#define ED_3COM_GACFR_NIM 0x80 /* Mask NIC interrupts */ - -/* - * Control Register. Miscellaneous control functions. - */ -#define ED_3COM_CR 6 - -#define ED_3COM_CR_RST 0x01 /* Reset GA and NIC */ -#define ED_3COM_CR_XSEL 0x02 /* Transceiver select. BNC=1(def) AUI=0 */ -#define ED_3COM_CR_EALO 0x04 /* window EA PROM 0-15 to I/O base */ -#define ED_3COM_CR_EAHI 0x08 /* window EA PROM 16-31 to I/O base */ -#define ED_3COM_CR_SHARE 0x10 /* select interrupt sharing option */ -#define ED_3COM_CR_DBSEL 0x20 /* Double buffer select */ -#define ED_3COM_CR_DDIR 0x40 /* DMA direction select */ -#define ED_3COM_CR_START 0x80 /* Start DMA controller */ - -/* - * Status Register. Miscellaneous status information. - */ -#define ED_3COM_STREG 7 - -#define ED_3COM_STREG_REV 0x07 /* GA revision */ -#define ED_3COM_STREG_DIP 0x08 /* DMA in progress */ -#define ED_3COM_STREG_DTC 0x10 /* DMA terminal count */ -#define ED_3COM_STREG_OFLW 0x20 /* Overflow */ -#define ED_3COM_STREG_UFLW 0x40 /* Underflow */ -#define ED_3COM_STREG_DPRDY 0x80 /* Data port ready */ - -/* - * Interrupt/DMA Configuration Register - */ -#define ED_3COM_IDCFR 8 - -#define ED_3COM_IDCFR_DRQ 0x07 /* DMA request */ -#define ED_3COM_IDCFR_UNUSED 0x08 /* not used */ -#if 0 -#define ED_3COM_IDCFR_IRQ 0xF0 /* Interrupt request */ -#else -#define ED_3COM_IDCFR_IRQ2 0x10 /* Interrupt request 2 select */ -#define ED_3COM_IDCFR_IRQ3 0x20 /* Interrupt request 3 select */ -#define ED_3COM_IDCFR_IRQ4 0x40 /* Interrupt request 4 select */ -#define ED_3COM_IDCFR_IRQ5 0x80 /* Interrupt request 5 select */ -#endif - -/* - * DMA Address Register MSB - */ -#define ED_3COM_DAMSB 9 - -/* - * DMA Address Register LSB - */ -#define ED_3COM_DALSB 0x0a - -/* - * Vector Pointer Register 2 - */ -#define ED_3COM_VPTR2 0x0b - -/* - * Vector Pointer Register 1 - */ -#define ED_3COM_VPTR1 0x0c - -/* - * Vector Pointer Register 0 - */ -#define ED_3COM_VPTR0 0x0d - -/* - * Register File Access MSB - */ -#define ED_3COM_RFMSB 0x0e - -/* - * Register File Access LSB - */ -#define ED_3COM_RFLSB 0x0f - -/* - * Definitions for Novell NE1000/2000 boards - */ - -/* - * Board type codes - */ -#define ED_TYPE_NE1000 0x01 -#define ED_TYPE_NE2000 0x02 - -/* - * Register offsets/total - */ -#define ED_NOVELL_NIC_OFFSET 0x00 -#define ED_NOVELL_ASIC_OFFSET 0x10 -#define ED_NOVELL_IO_PORTS 32 - -/* - * Remote DMA data register; for reading or writing to the NIC mem via - * programmed I/O (offset from ASIC base). - */ -#define ED_NOVELL_DATA 0x00 - -/* - * Reset register; reading from this register causes a board reset. - */ -#define ED_NOVELL_RESET 0x0f diff --git a/sys/arch/i386/isa/if_eg.c b/sys/arch/i386/isa/if_eg.c deleted file mode 100644 index 39d1dbdacb74..000000000000 --- a/sys/arch/i386/isa/if_eg.c +++ /dev/null @@ -1,847 +0,0 @@ -/* $NetBSD: if_eg.c,v 1.9 1995/01/03 01:30:35 mycroft Exp $ */ - -/* - * Copyright (c) 1993 Dean Huxley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Dean Huxley. - * 4. The name of Dean Huxley may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* To do: - * - multicast - * - promiscuous - */ -#include "bpfilter.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#ifdef INET -#include -#include -#include -#include -#include -#endif - -#ifdef NS -#include -#include -#endif - -#if NBPFILTER > 0 -#include -#include -#endif - -#include -#include - -#include -#include -#include - -/* for debugging convenience */ -#ifdef EGDEBUG -#define dprintf(x) printf x -#else -#define dprintf(x) -#endif - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 - -#define EG_INLEN 10 -#define EG_BUFLEN 0x0670 - -/* - * Ethernet software status per interface. - */ -struct eg_softc { - struct device sc_dev; - struct intrhand sc_ih; - struct arpcom sc_arpcom; /* Ethernet common part */ - int eg_cmd; /* Command register R/W */ - int eg_ctl; /* Control register R/W (EG_CTL_*) */ - int eg_stat; /* Status register R/O (EG_STAT_*) */ - int eg_data; /* Data register R/W (16 bits) */ - u_char eg_rom_major; /* Cards ROM version (major number) */ - u_char eg_rom_minor; /* Cards ROM version (minor number) */ - short eg_ram; /* Amount of RAM on the card */ - u_char eg_pcb[64]; /* Primary Command Block buffer */ - u_char eg_incount; /* Number of buffers currently used */ - u_char *eg_inbuf; /* Incoming packet buffer */ - u_char *eg_outbuf; /* Outgoing packet buffer */ -}; - -int egprobe __P((struct device *, void *, void *)); -void egattach __P((struct device *, struct device *, void *)); - -struct cfdriver egcd = { - NULL, "eg", egprobe, egattach, DV_IFNET, sizeof(struct eg_softc) -}; - -int egintr __P((struct eg_softc *)); -static void eginit __P((struct eg_softc *)); -static int egioctl __P((struct ifnet *, u_long, caddr_t)); -static int egrecv __P((struct eg_softc *)); -static int egstart __P((struct ifnet *)); -static int egwatchdog __P((int)); -static void egreset __P((struct eg_softc *)); -static inline void egread __P((struct eg_softc *, caddr_t, int)); -static struct mbuf *egget __P((caddr_t, int, struct ifnet *)); -static void egstop __P((struct eg_softc *)); - -/* - * Support stuff - */ - -static inline void -egprintpcb(sc) - struct eg_softc *sc; -{ - int i; - - for (i = 0; i < sc->eg_pcb[1] + 2; i++) - dprintf(("pcb[%2d] = %x\n", i, sc->eg_pcb[i])); -} - - -static inline void -egprintstat(b) - u_char b; -{ - dprintf(("%s %s %s %s %s %s %s\n", - (b & EG_STAT_HCRE)?"HCRE":"", - (b & EG_STAT_ACRF)?"ACRF":"", - (b & EG_STAT_DIR )?"DIR ":"", - (b & EG_STAT_DONE)?"DONE":"", - (b & EG_STAT_ASF3)?"ASF3":"", - (b & EG_STAT_ASF2)?"ASF2":"", - (b & EG_STAT_ASF1)?"ASF1":"")); -} - -static int -egoutPCB(sc, b) - struct eg_softc *sc; - u_char b; -{ - int i; - - for (i=0; i < 4000; i++) { - if (inb(sc->eg_stat) & EG_STAT_HCRE) { - outb(sc->eg_cmd, b); - return 0; - } - delay(10); - } - dprintf(("egoutPCB failed\n")); - return 1; -} - -static int -egreadPCBstat(sc, statb) - struct eg_softc *sc; - u_char statb; -{ - int i; - - for (i=0; i < 5000; i++) { - if (EG_PCB_STAT(inb(sc->eg_stat))) - break; - delay(10); - } - if (EG_PCB_STAT(inb(sc->eg_stat)) == statb) - return 0; - return 1; -} - -static int -egreadPCBready(sc) - struct eg_softc *sc; -{ - int i; - - for (i=0; i < 10000; i++) { - if (inb(sc->eg_stat) & EG_STAT_ACRF) - return 0; - delay(5); - } - dprintf(("PCB read not ready\n")); - return 1; -} - -static int -egwritePCB(sc) - struct eg_softc *sc; -{ - int i; - u_char len; - - outb(sc->eg_ctl, EG_PCB_MASK(inb(sc->eg_ctl))); - - len = sc->eg_pcb[1] + 2; - for (i = 0; i < len; i++) - egoutPCB(sc, sc->eg_pcb[i]); - - for (i=0; i < 4000; i++) { - if (inb(sc->eg_stat) & EG_STAT_HCRE) - break; - delay(10); - } - outb(sc->eg_ctl, EG_PCB_MASK(inb(sc->eg_ctl)) | EG_PCB_DONE); - egoutPCB(sc, len); - - if (egreadPCBstat(sc, EG_PCB_ACCEPT)) - return 1; - return 0; -} - -static int -egreadPCB(sc) - struct eg_softc *sc; -{ - int i; - u_char b; - - outb(sc->eg_ctl, EG_PCB_MASK(inb(sc->eg_ctl))); - - bzero(sc->eg_pcb, sizeof(sc->eg_pcb)); - - if (egreadPCBready(sc)) - return 1; - - sc->eg_pcb[0] = inb(sc->eg_cmd); - - if (egreadPCBready(sc)) - return 1; - - sc->eg_pcb[1] = inb(sc->eg_cmd); - - if (sc->eg_pcb[1] > 62) { - dprintf(("len %d too large\n", sc->eg_pcb[1])); - return 1; - } - - for (i = 0; i < sc->eg_pcb[1]; i++) { - if (egreadPCBready(sc)) - return 1; - sc->eg_pcb[2+i] = inb(sc->eg_cmd); - } - if (egreadPCBready(sc)) - return 1; - if (egreadPCBstat(sc, EG_PCB_DONE)) - return 1; - if ((b = inb(sc->eg_cmd)) != sc->eg_pcb[1] + 2) { - dprintf(("%d != %d\n", b, sc->eg_pcb[1] + 2)); - return 1; - } - outb(sc->eg_ctl, EG_PCB_MASK(inb(sc->eg_ctl)) | EG_PCB_ACCEPT); - return 0; -} - -/* - * Real stuff - */ - -int -egprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct eg_softc *sc = match; - struct isa_attach_args *ia = aux; - int i; - - if (ia->ia_iobase & ~0x07f0 != 0) { - dprintf(("Weird iobase %x\n", ia->ia_iobase)); - return 0; - } - - sc->eg_cmd = ia->ia_iobase + EG_COMMAND; - sc->eg_ctl = ia->ia_iobase + EG_CONTROL; - sc->eg_stat = ia->ia_iobase + EG_STATUS; - sc->eg_data = ia->ia_iobase + EG_DATA; - - /* hard reset card */ - outb(sc->eg_ctl, EG_CTL_RESET); - outb(sc->eg_ctl, 0); - for (i = 0; i < 5000; i++) { - delay(1000); - if (EG_PCB_STAT(inb(sc->eg_stat)) == 0) - break; - } - if (EG_PCB_STAT(inb(sc->eg_stat)) != 0) { - dprintf(("eg: Reset failed\n")); - return 0; - } - sc->eg_pcb[0] = EG_CMD_GETINFO; /* Get Adapter Info */ - sc->eg_pcb[1] = 0; - if (egwritePCB(sc) != 0) - return 0; - - if (egreadPCB(sc) != 0) { - egprintpcb(sc); - return 0; - } - - if (sc->eg_pcb[0] != EG_RSP_GETINFO || /* Get Adapter Info Response */ - sc->eg_pcb[1] != 0x0a) { - egprintpcb(sc); - return 0; - } - sc->eg_rom_major = sc->eg_pcb[3]; - sc->eg_rom_minor = sc->eg_pcb[2]; - sc->eg_ram = sc->eg_pcb[6] | (sc->eg_pcb[7] << 8); - - ia->ia_iosize = 0x08; - ia->ia_msize = 0; - return 1; -} - -static void -egattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct eg_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int i; - - egstop(sc); - - sc->eg_pcb[0] = EG_CMD_GETEADDR; /* Get Station address */ - sc->eg_pcb[1] = 0; - if (egwritePCB(sc) != 0) { - dprintf(("write error\n")); - return; - } - if (egreadPCB(sc) != 0) { - dprintf(("read error\n")); - egprintpcb(sc); - return; - } - - /* check Get station address response */ - if (sc->eg_pcb[0] != EG_RSP_GETEADDR || sc->eg_pcb[1] != 0x06) { - dprintf(("parse error\n")); - egprintpcb(sc); - return; - } - bcopy(&sc->eg_pcb[2], sc->sc_arpcom.ac_enaddr, ETHER_ADDR_LEN); - - printf(": ROM v%d.%02d %dk address %s\n", - sc->eg_rom_major, sc->eg_rom_minor, sc->eg_ram, - ether_sprintf(sc->sc_arpcom.ac_enaddr)); - - sc->eg_pcb[0] = EG_CMD_SETEADDR; /* Set station address */ - if (egwritePCB(sc) != 0) { - dprintf(("write error2\n")); - return; - } - if (egreadPCB(sc) != 0) { - dprintf(("read error2\n")); - egprintpcb(sc); - return; - } - if (sc->eg_pcb[0] != EG_RSP_SETEADDR || sc->eg_pcb[1] != 0x02 || - sc->eg_pcb[2] != 0 || sc->eg_pcb[3] != 0) { - dprintf(("parse error2\n")); - egprintpcb(sc); - return; - } - - /* Initialize ifnet structure. */ - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = egcd.cd_name; - ifp->if_output = ether_output; - ifp->if_start = egstart; - ifp->if_ioctl = egioctl; - ifp->if_watchdog = egwatchdog; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; - - /* Now we can attach the interface. */ - if_attach(ifp); - ether_ifattach(ifp); - -#if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif - - sc->sc_ih.ih_fun = egintr; - sc->sc_ih.ih_arg = sc; - sc->sc_ih.ih_level = IPL_NET; - intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih); -} - -static void -eginit(sc) - register struct eg_softc *sc; -{ - register struct ifnet *ifp = &sc->sc_arpcom.ac_if; - - /* Address not known. */ - if (ifp->if_addrlist == 0) - return; - - /* soft reset the board */ - outb(sc->eg_ctl, EG_CTL_FLSH); - delay(100); - outb(sc->eg_ctl, EG_CTL_ATTN); - delay(100); - outb(sc->eg_ctl, 0); - delay(200); - - sc->eg_pcb[0] = EG_CMD_CONFIG82586; /* Configure 82586 */ - sc->eg_pcb[1] = 2; - sc->eg_pcb[2] = 3; /* receive broadcast & multicast */ - sc->eg_pcb[3] = 0; - if (egwritePCB(sc) != 0) - dprintf(("write error3\n")); - - if (egreadPCB(sc) != 0) { - dprintf(("read error\n")); - egprintpcb(sc); - } else if (sc->eg_pcb[2] != 0 || sc->eg_pcb[3] != 0) - printf("%s: configure card command failed\n", - sc->sc_dev.dv_xname); - - if (sc->eg_inbuf == NULL) - sc->eg_inbuf = malloc(EG_BUFLEN, M_TEMP, M_NOWAIT); - sc->eg_incount = 0; - - if (sc->eg_outbuf == NULL) - sc->eg_outbuf = malloc(EG_BUFLEN, M_TEMP, M_NOWAIT); - - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - - outb(sc->eg_ctl, EG_CTL_CMDE); - - egstart(ifp); - egrecv(sc); -} - -static int -egrecv(sc) - struct eg_softc *sc; -{ - - while (sc->eg_incount < EG_INLEN) { - sc->eg_pcb[0] = EG_CMD_RECVPACKET; - sc->eg_pcb[1] = 0x08; - sc->eg_pcb[2] = 0; /* address not used.. we send zero */ - sc->eg_pcb[3] = 0; - sc->eg_pcb[4] = 0; - sc->eg_pcb[5] = 0; - sc->eg_pcb[6] = EG_BUFLEN & 0xff; /* our buffer size */ - sc->eg_pcb[7] = (EG_BUFLEN >> 8) & 0xff; - sc->eg_pcb[8] = 0; /* timeout, 0 == none */ - sc->eg_pcb[9] = 0; - if (egwritePCB(sc) == 0) - sc->eg_incount++; - else - break; - } -} - -static int -egstart(ifp) - struct ifnet *ifp; -{ - register struct eg_softc *sc = egcd.cd_devs[ifp->if_unit]; - struct mbuf *m0, *m; - int len; - short *ptr; - - /* Don't transmit if interface is busy or not running */ - if ((sc->sc_arpcom.ac_if.if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING) - return 0; - - /* Dequeue the next datagram. */ - IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m0); - if (m0 == NULL) - return 0; - - sc->sc_arpcom.ac_if.if_flags |= IFF_OACTIVE; - - /* Copy the datagram to the buffer. */ - len = 0; - for (m = m0; m; m = m->m_next) { - if (m->m_len == 0) - continue; - if (len + m->m_len > EG_BUFLEN) { - dprintf(("Packet too large to send\n")); - m_freem(m0); - sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - sc->sc_arpcom.ac_if.if_oerrors++; - return 0; - } - bcopy(mtod(m, caddr_t), sc->eg_outbuf + len, m->m_len); - len += m->m_len; - } -#if NBPFILTER > 0 - if (sc->sc_arpcom.ac_if.if_bpf) - bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0); -#endif - m_freem(m0); - - /* length must be a minimum of ETHER_MIN_LEN bytes */ - len = max(len, ETHER_MIN_LEN); - - /* set direction bit: host -> adapter */ - outb(sc->eg_ctl, inb(sc->eg_ctl) & ~EG_CTL_DIR); - - sc->eg_pcb[0] = EG_CMD_SENDPACKET; - sc->eg_pcb[1] = 0x06; - sc->eg_pcb[2] = 0; /* address not used, we send zero */ - sc->eg_pcb[3] = 0; - sc->eg_pcb[4] = 0; - sc->eg_pcb[5] = 0; - sc->eg_pcb[6] = len & 0xff; /* length of packet */ - sc->eg_pcb[7] = (len >> 8) & 0xff; - if (egwritePCB(sc) == 0) { - for (ptr = (short *) sc->eg_outbuf; len > 0; len -= 2) { - outw(sc->eg_data, *ptr++); - while (!(inb(sc->eg_stat) & EG_STAT_HRDY)) - ; /* XXX need timeout here */ - } - } else { - dprintf(("egwritePCB in egstart failed\n")); - sc->sc_arpcom.ac_if.if_oerrors++; - sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - } - - /* Set direction bit : Adapter -> host */ - outb(sc->eg_ctl, inb(sc->eg_ctl) | EG_CTL_DIR); - - return 0; -} - -int -egintr(sc) - register struct eg_softc *sc; -{ - int i, len; - short *ptr; - - while (inb(sc->eg_stat) & EG_STAT_ACRF) { - egreadPCB(sc); - switch (sc->eg_pcb[0]) { - case EG_RSP_RECVPACKET: - len = sc->eg_pcb[6] | (sc->eg_pcb[7] << 8); - for (ptr = (short *) sc->eg_inbuf; len > 0; len -= 2) { - while (!(inb(sc->eg_stat) & EG_STAT_HRDY)) - ; - *ptr++ = inw(sc->eg_data); - } - len = sc->eg_pcb[8] | (sc->eg_pcb[9] << 8); - egrecv(sc); - sc->sc_arpcom.ac_if.if_ipackets++; - egread(sc, sc->eg_inbuf, len); - sc->eg_incount--; - break; - - case EG_RSP_SENDPACKET: - if (sc->eg_pcb[6] || sc->eg_pcb[7]) { - dprintf(("packet dropped\n")); - sc->sc_arpcom.ac_if.if_oerrors++; - } else - sc->sc_arpcom.ac_if.if_opackets++; - sc->sc_arpcom.ac_if.if_collisions += sc->eg_pcb[8] & 0xf; - sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - egstart(&sc->sc_arpcom.ac_if); - break; - - case EG_RSP_GETSTATS: - dprintf(("Card Statistics\n")); - bcopy(&sc->eg_pcb[2], &i, sizeof(i)); - dprintf(("Receive Packets %d\n", i)); - bcopy(&sc->eg_pcb[6], &i, sizeof(i)); - dprintf(("Transmit Packets %d\n", i)); - dprintf(("CRC errors %d\n", *(short*) &sc->eg_pcb[10])); - dprintf(("alignment errors %d\n", *(short*) &sc->eg_pcb[12])); - dprintf(("no resources errors %d\n", *(short*) &sc->eg_pcb[14])); - dprintf(("overrun errors %d\n", *(short*) &sc->eg_pcb[16])); - break; - - default: - dprintf(("egintr: Unknown response %x??\n", - sc->eg_pcb[0])); - egprintpcb(sc); - break; - } - } - - return 0; -} - -/* - * Pass a packet up to the higher levels. - */ -static inline void -egread(sc, buf, len) - struct eg_softc *sc; - caddr_t buf; - int len; -{ - struct ifnet *ifp; - struct mbuf *m; - struct ether_header *eh; - - if (len <= sizeof(struct ether_header) || - len > ETHER_MAX_LEN) { - dprintf(("Unacceptable packet size %d\n", len)); - sc->sc_arpcom.ac_if.if_ierrors++; - return; - } - - /* Pull packet off interface. */ - ifp = &sc->sc_arpcom.ac_if; - m = egget(buf, len, ifp); - if (m == 0) { - dprintf(("egget returned 0\n")); - sc->sc_arpcom.ac_if.if_ierrors++; - return; - } - - /* We assume the header fit entirely in one mbuf. */ - eh = mtod(m, struct ether_header *); - -#if NBPFILTER > 0 - /* - * Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to BPF. - */ - if (ifp->if_bpf) { - bpf_mtap(ifp->if_bpf, m); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - */ - if ((ifp->if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */ - bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0) { - m_freem(m); - return; - } - } -#endif - - /* We assume the header fit entirely in one mbuf. */ - m->m_pkthdr.len -= sizeof(*eh); - m->m_len -= sizeof(*eh); - m->m_data += sizeof(*eh); - - ether_input(ifp, eh, m); -} - -/* - * convert buf into mbufs - */ -static struct mbuf * -egget(buf, totlen, ifp) - caddr_t buf; - int totlen; - struct ifnet *ifp; -{ - struct mbuf *top, **mp, *m; - int len; - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - dprintf(("MGETHDR returns 0\n")); - return 0; - } - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = totlen; - len = MHLEN; - top = 0; - mp = ⊤ - - while (totlen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - m_freem(top); - dprintf(("MGET returns 0\n")); - return 0; - } - len = MLEN; - } - if (totlen >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - len = MCLBYTES; - } - m->m_len = len = min(totlen, len); - bcopy((caddr_t)buf, mtod(m, caddr_t), len); - buf += len; - totlen -= len; - *mp = m; - mp = &m->m_next; - } - - return top; -} - -static int -egioctl(ifp, command, data) - register struct ifnet *ifp; - u_long command; - caddr_t data; -{ - struct eg_softc *sc = egcd.cd_devs[ifp->if_unit]; - register struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splimp(); - - switch (command) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - eginit(sc); /* before arpwhohas */ - sc->sc_arpcom.ac_ipaddr = IA_SIN(ifa)->sin_addr; - arpwhohas(&sc->sc_arpcom, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - case AF_NS: - { - register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr; - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(sc->sc_arpcom.ac_enaddr); - else - bcopy(ina->x_host.c_host, - sc->sc_arpcom.ac_enaddr, - sizeof(sc->sc_arpcom.ac_enaddr)); - /* Set new address. */ - eginit(sc); - break; - } -#endif - default: - eginit(sc); - break; - } - break; - - case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, then - * stop it. - */ - egstop(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, then - * start it. - */ - eginit(sc); - } else { - sc->eg_pcb[0] = EG_CMD_GETSTATS; - sc->eg_pcb[1] = 0; - if (egwritePCB(sc) != 0) - dprintf(("write error\n")); - /* - * XXX deal with flags changes: - * IFF_MULTICAST, IFF_PROMISC, - * IFF_LINK0, IFF_LINK1, - */ - } - break; - - default: - error = EINVAL; - } - - splx(s); - return error; -} - -static void -egreset(sc) - struct eg_softc *sc; -{ - int s; - - dprintf(("egreset()\n")); - s = splimp(); - egstop(sc); - eginit(sc); - splx(s); -} - -static int -egwatchdog(unit) - int unit; -{ - struct eg_softc *sc = egcd.cd_devs[unit]; - - log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_oerrors++; - - egreset(sc); - return 0; -} - -static void -egstop(sc) - register struct eg_softc *sc; -{ - - outb(sc->eg_ctl, 0); -} diff --git a/sys/arch/i386/isa/if_egreg.h b/sys/arch/i386/isa/if_egreg.h deleted file mode 100644 index 168f4f928c47..000000000000 --- a/sys/arch/i386/isa/if_egreg.h +++ /dev/null @@ -1,105 +0,0 @@ -/* $NetBSD: if_egreg.h,v 1.2 1994/10/27 04:17:26 cgd Exp $ */ - -/* - * Copyright (c) 1993 Dean Huxley (dean@fsa.ca) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Dean Huxley. - * 4. The name of Dean Huxley may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Register offsets from base. - */ -#define EG_COMMAND 0x00 -#define EG_STATUS 0x02 -#define EG_DATA 0x04 -#define EG_CONTROL 0x06 - -/* - * Host Control Register bits - * EG_CTL_ATTN - does a soft reset - * EG_CTL_FLSH - flushes the data register - * EG_CTL_RESET - does a hard reset - * EG_CTL_DMAE - Used with DIR bit, enables DMA transfers to/from data reg. - * EG_CTL_DIR - if clear then host -> adapter, if set then adapter -> host - * EG_CTL_TCEN - terminal count enable. enables host interrupt after DMA. - * EG_CTL_CMDE - command reg interrupt enable. (when it is written) - * EG_CTL_HSF1 - Host status flag 1 - * EG_CTL_HSF2 - Host status flag 2 - */ - -#define EG_CTL_ATTN 0x80 -#define EG_CTL_FLSH 0x40 -#define EG_CTL_RESET (EG_CTL_ATTN|EG_CTL_FLSH) -#define EG_CTL_DMAE 0x20 -#define EG_CTL_DIR 0x10 -#define EG_CTL_TCEN 0x08 -#define EG_CTL_CMDE 0x04 -#define EG_CTL_HSF2 0x02 -#define EG_CTL_HSF1 0x01 - -/* - * Host Status Register bits - * EG_STAT_HRDY - Data Register ready - * EG_STAT_HCRE - Host Command Register empty - * EG_STAT_ACRF - Adapter Command register full - * EG_STAT_DIR - Direction flag, 0 = host -> adapter, 1 = adapter -> host - * EG_STAT_DONE - DMA done - * EG_STAT_ASF1 - Adapter status flag 1 - * EG_STAT_ASF2 - Adapter status flag 2 - * EG_STAT_ASF3 - Adapter status flag 3 - */ - -#define EG_STAT_HRDY 0x80 -#define EG_STAT_HCRE 0x40 -#define EG_STAT_ACRF 0x20 -#define EG_STAT_DIR 0x10 -#define EG_STAT_DONE 0x08 -#define EG_STAT_ASF3 0x04 -#define EG_STAT_ASF2 0x02 -#define EG_STAT_ASF1 0x01 - -#define EG_PCB_ACCEPT 1 -#define EG_PCB_REJECT 2 -#define EG_PCB_DONE 3 -#define EG_PCB_STAT(x) ((x)&3) -#define EG_PCB_MASK(x) ((x)&~3) - -#define EG_CMD_CONFIG82586 0x02 -#define EG_CMD_GETEADDR 0x03 -#define EG_CMD_RECVPACKET 0x08 -#define EG_CMD_SENDPACKET 0x09 -#define EG_CMD_GETSTATS 0x0a -#define EG_CMD_SETEADDR 0x10 -#define EG_CMD_GETINFO 0x11 - -#define EG_RSP_CONFIG82586 0x32 -#define EG_RSP_GETEADDR 0x33 -#define EG_RSP_RECVPACKET 0x38 -#define EG_RSP_SENDPACKET 0x39 -#define EG_RSP_GETSTATS 0x3a -#define EG_RSP_SETEADDR 0x40 -#define EG_RSP_GETINFO 0x41 diff --git a/sys/arch/i386/isa/if_el.c b/sys/arch/i386/isa/if_el.c deleted file mode 100644 index 745c09a4ae5f..000000000000 --- a/sys/arch/i386/isa/if_el.c +++ /dev/null @@ -1,772 +0,0 @@ -/* $NetBSD: if_el.c,v 1.20 1995/01/03 01:30:37 mycroft Exp $ */ - -/* - * Copyright (c) 1994, Matthew E. Kimmel. Permission is hereby granted - * to use, copy, modify and distribute this software provided that both - * the copyright notice and this permission notice appear in all copies - * of the software, derivative works or modified versions, and any - * portions thereof. - */ - -/* - * 3COM Etherlink 3C501 device driver - */ - -/* - * Bugs/possible improvements: - * - Does not currently support DMA - * - Does not currently support multicasts - */ - -#include "bpfilter.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef INET -#include -#include -#include -#include -#include -#endif - -#ifdef NS -#include -#include -#endif - -#if NBPFILTER > 0 -#include -#include -#endif - -#include -#include - -#include -#include - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 - -/* for debugging convenience */ -#ifdef EL_DEBUG -#define dprintf(x) printf x -#else -#define dprintf(x) -#endif - -/* - * per-line info and status - */ -struct el_softc { - struct device sc_dev; - struct intrhand sc_ih; - - struct arpcom sc_arpcom; /* ethernet common */ - int sc_iobase; /* base I/O addr */ - char sc_pktbuf[EL_BUFSIZ]; /* frame buffer */ -}; - -/* - * prototypes - */ -int elintr __P((struct el_softc *)); -static int el_init __P((struct el_softc *)); -static int el_ioctl __P((struct ifnet *, u_long, caddr_t)); -static int el_start __P((struct ifnet *)); -static int el_watchdog __P((int)); -static void el_reset __P((struct el_softc *)); -static void el_stop __P((struct el_softc *)); -static int el_xmit __P((struct el_softc *, int)); -static inline void elread __P((struct el_softc *, caddr_t, int)); -static struct mbuf *elget __P((caddr_t, int, struct ifnet *)); -static inline void el_hardreset __P((struct el_softc *)); - -int elprobe __P((struct device *, void *, void *)); -void elattach __P((struct device *, struct device *, void *)); - -/* isa_driver structure for autoconf */ -struct cfdriver elcd = { - NULL, "el", elprobe, elattach, DV_IFNET, sizeof(struct el_softc) -}; - -/* - * Probe routine. - * - * See if the card is there and at the right place. - * (XXX - cgd -- needs help) - */ -int -elprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct el_softc *sc = match; - struct isa_attach_args *ia = aux; - int iobase = ia->ia_iobase; - u_char station_addr[ETHER_ADDR_LEN]; - int i; - - /* First check the base. */ - if (iobase < 0x280 || iobase > 0x3f0) - return 0; - - /* Grab some info for our structure. */ - sc->sc_iobase = iobase; - - /* - * Now attempt to grab the station address from the PROM and see if it - * contains the 3com vendor code. - */ - dprintf(("Probing 3c501 at 0x%x...\n", iobase)); - - /* Reset the board. */ - dprintf(("Resetting board...\n")); - outb(iobase+EL_AC, EL_AC_RESET); - delay(5); - outb(iobase+EL_AC, 0); - - /* Now read the address. */ - dprintf(("Reading station address...\n")); - for (i = 0; i < ETHER_ADDR_LEN; i++) { - outb(iobase+EL_GPBL, i); - station_addr[i] = inb(iobase+EL_EAW); - } - dprintf(("Address is %s\n", ether_sprintf(station_addr))); - - /* - * If the vendor code is ok, return a 1. We'll assume that whoever - * configured this system is right about the IRQ. - */ - if (station_addr[0] != 0x02 || station_addr[1] != 0x60 || - station_addr[2] != 0x8c) { - dprintf(("Bad vendor code.\n")); - return 0; - } - - dprintf(("Vendor code ok.\n")); - /* Copy the station address into the arpcom structure. */ - bcopy(station_addr, sc->sc_arpcom.ac_enaddr, ETHER_ADDR_LEN); - - ia->ia_iosize = 4; /* XXX */ - ia->ia_msize = 0; - return 1; -} - -/* - * Attach the interface to the kernel data structures. By the time this is - * called, we know that the card exists at the given I/O address. We still - * assume that the IRQ given is correct. - */ -void -elattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct el_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - - dprintf(("Attaching %s...\n", sc->sc_dev.dv_xname)); - - /* Stop the board. */ - el_stop(sc); - - /* Initialize ifnet structure. */ - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = elcd.cd_name; - ifp->if_output = ether_output; - ifp->if_start = el_start; - ifp->if_ioctl = el_ioctl; - ifp->if_watchdog = el_watchdog; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; - - /* Now we can attach the interface. */ - dprintf(("Attaching interface...\n")); - if_attach(ifp); - ether_ifattach(ifp); - - /* Print out some information for the user. */ - printf(": address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr)); - - /* Finally, attach to bpf filter if it is present. */ -#if NBPFILTER > 0 - dprintf(("Attaching to BPF...\n")); - bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif - - sc->sc_ih.ih_fun = elintr; - sc->sc_ih.ih_arg = sc; - sc->sc_ih.ih_level = IPL_NET; - intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih); - - dprintf(("elattach() finished.\n")); -} - -/* - * Reset interface. - */ -static void -el_reset(sc) - struct el_softc *sc; -{ - int s; - - dprintf(("elreset()\n")); - s = splimp(); - el_stop(sc); - el_init(sc); - splx(s); -} - -/* - * Stop interface. - */ -static void -el_stop(sc) - struct el_softc *sc; -{ - - outb(sc->sc_iobase+EL_AC, 0); -} - -/* - * Do a hardware reset of the board, and upload the ethernet address again in - * case the board forgets. - */ -static inline void -el_hardreset(sc) - struct el_softc *sc; -{ - int iobase = sc->sc_iobase; - int i; - - outb(iobase+EL_AC, EL_AC_RESET); - delay(5); - outb(iobase+EL_AC, 0); - - for (i = 0; i < ETHER_ADDR_LEN; i++) - outb(iobase+i, sc->sc_arpcom.ac_enaddr[i]); -} - -/* - * Initialize interface. - */ -static int -el_init(sc) - struct el_softc *sc; -{ - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int iobase = sc->sc_iobase; - int s; - - /* If address not known, do nothing. */ - if (ifp->if_addrlist == 0) - return; - - s = splimp(); - - /* First, reset the board. */ - el_hardreset(sc); - - /* Configure rx. */ - dprintf(("Configuring rx...\n")); - if (ifp->if_flags & IFF_PROMISC) - outb(iobase+EL_RXC, EL_RXC_AGF | EL_RXC_DSHORT | EL_RXC_DDRIB | EL_RXC_DOFLOW | EL_RXC_PROMISC); - else - outb(iobase+EL_RXC, EL_RXC_AGF | EL_RXC_DSHORT | EL_RXC_DDRIB | EL_RXC_DOFLOW | EL_RXC_ABROAD); - outb(iobase+EL_RBC, 0); - - /* Configure TX. */ - dprintf(("Configuring tx...\n")); - outb(iobase+EL_TXC, 0); - - /* Start reception. */ - dprintf(("Starting reception...\n")); - outb(iobase+EL_AC, EL_AC_IRQE | EL_AC_RX); - - /* Set flags appropriately. */ - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - - /* And start output. */ - el_start(ifp); - - splx(s); -} - -/* - * Start output on interface. Get datagrams from the queue and output them, - * giving the receiver a chance between datagrams. Call only from splimp or - * interrupt level! - */ -static int -el_start(ifp) - struct ifnet *ifp; -{ - struct el_softc *sc = elcd.cd_devs[ifp->if_unit]; - int iobase = sc->sc_iobase; - struct mbuf *m, *m0; - int s, i, len, retries, done; - - dprintf(("el_start()...\n")); - s = splimp(); - - /* Don't do anything if output is active. */ - if (sc->sc_arpcom.ac_if.if_flags & IFF_OACTIVE) - return; - sc->sc_arpcom.ac_if.if_flags |= IFF_OACTIVE; - - /* - * The main loop. They warned me against endless loops, but would I - * listen? NOOO.... - */ - for (;;) { - /* Dequeue the next datagram. */ - IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m0); - - /* If there's nothing to send, return. */ - if (!m0) { - sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - splx(s); - return; - } - - /* Disable the receiver. */ - outb(iobase+EL_AC, EL_AC_HOST); - outb(iobase+EL_RBC, 0); - - /* Copy the datagram to the buffer. */ - len = 0; - for (m = m0; m; m = m->m_next) { - if (m->m_len == 0) - continue; - bcopy(mtod(m, caddr_t), sc->sc_pktbuf + len, m->m_len); - len += m->m_len; - } - m_freem(m0); - - len = max(len, ETHER_MIN_LEN); - - /* Give the packet to the bpf, if any. */ -#if NBPFILTER > 0 - if (sc->sc_arpcom.ac_if.if_bpf) - bpf_tap(sc->sc_arpcom.ac_if.if_bpf, sc->sc_pktbuf, len); -#endif - - /* Transfer datagram to board. */ - dprintf(("el: xfr pkt length=%d...\n", len)); - i = EL_BUFSIZ - len; - outb(iobase+EL_GPBL, i); - outb(iobase+EL_GPBH, i >> 8); - outsb(iobase+EL_BUF, sc->sc_pktbuf, len); - - /* Now transmit the datagram. */ - retries = 0; - done = 0; - while (!done) { - if (el_xmit(sc, len)) { - /* Something went wrong. */ - done = -1; - break; - } - /* Check out status. */ - i = inb(iobase+EL_TXS); - dprintf(("tx status=0x%x\n", i)); - if ((i & EL_TXS_READY) == 0) { - dprintf(("el: err txs=%x\n", i)); - sc->sc_arpcom.ac_if.if_oerrors++; - if (i & (EL_TXS_COLL | EL_TXS_COLL16)) { - if ((i & EL_TXC_DCOLL16) == 0 && - retries < 15) { - retries++; - outb(iobase+EL_AC, EL_AC_HOST); - } - } else - done = 1; - } else { - sc->sc_arpcom.ac_if.if_opackets++; - done = 1; - } - } - if (done == -1) - /* Packet not transmitted. */ - continue; - - /* - * Now give the card a chance to receive. - * Gotta love 3c501s... - */ - (void)inb(iobase+EL_AS); - outb(iobase+EL_AC, EL_AC_IRQE | EL_AC_RX); - splx(s); - /* Interrupt here. */ - s = splimp(); - } -} - -/* - * This function actually attempts to transmit a datagram downloaded to the - * board. Call at splimp or interrupt, after downloading data! Returns 0 on - * success, non-0 on failure. - */ -static int -el_xmit(sc, len) - struct el_softc *sc; - int len; -{ - int iobase = sc->sc_iobase; - int gpl; - int i; - - gpl = EL_BUFSIZ - len; - dprintf(("el: xmit...")); - outb(iobase+EL_GPBL, gpl); - outb(iobase+EL_GPBH, gpl >> 8); - outb(iobase+EL_AC, EL_AC_TXFRX); - i = 20000; - while ((inb(iobase+EL_AS) & EL_AS_TXBUSY) && (i > 0)) - i--; - if (i == 0) { - dprintf(("tx not ready\n")); - sc->sc_arpcom.ac_if.if_oerrors++; - return -1; - } - dprintf(("%d cycles.\n", 20000 - i)); - return 0; -} - -/* - * Controller interrupt. - */ -int -elintr(sc) - register struct el_softc *sc; -{ - int iobase = sc->sc_iobase; - int stat, rxstat, len, done; - - dprintf(("elintr: ")); - - /* Check board status. */ - stat = inb(iobase+EL_AS); - if (stat & EL_AS_RXBUSY) { - (void)inb(iobase+EL_RXC); - outb(iobase+EL_AC, EL_AC_IRQE | EL_AC_RX); - return 0; - } - - done = 0; - while (!done) { - rxstat = inb(iobase+EL_RXS); - if (rxstat & EL_RXS_STALE) { - (void)inb(iobase+EL_RXC); - outb(iobase+EL_AC, EL_AC_IRQE | EL_AC_RX); - return 1; - } - - /* If there's an overflow, reinit the board. */ - if ((rxstat & EL_RXS_NOFLOW) == 0) { - dprintf(("overflow.\n")); - el_hardreset(sc); - /* Put board back into receive mode. */ - if (sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) - outb(iobase+EL_RXC, EL_RXC_AGF | EL_RXC_DSHORT | EL_RXC_DDRIB | EL_RXC_DOFLOW | EL_RXC_PROMISC); - else - outb(iobase+EL_RXC, EL_RXC_AGF | EL_RXC_DSHORT | EL_RXC_DDRIB | EL_RXC_DOFLOW | EL_RXC_ABROAD); - (void)inb(iobase+EL_AS); - outb(iobase+EL_RBC, 0); - (void)inb(iobase+EL_RXC); - outb(iobase+EL_AC, EL_AC_IRQE | EL_AC_RX); - return 1; - } - - /* Incoming packet. */ - len = inb(iobase+EL_RBL); - len |= inb(iobase+EL_RBH) << 8; - dprintf(("receive len=%d rxstat=%x ", len, rxstat)); - outb(iobase+EL_AC, EL_AC_HOST); - - /* - * If packet too short or too long, restore rx mode and return. - */ - if (len <= sizeof(struct ether_header) || - len > ETHER_MAX_LEN) { - if (sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) - outb(iobase+EL_RXC, EL_RXC_AGF | EL_RXC_DSHORT | EL_RXC_DDRIB | EL_RXC_DOFLOW | EL_RXC_PROMISC); - else - outb(iobase+EL_RXC, EL_RXC_AGF | EL_RXC_DSHORT | EL_RXC_DDRIB | EL_RXC_DOFLOW | EL_RXC_ABROAD); - (void)inb(iobase+EL_AS); - outb(iobase+EL_RBC, 0); - (void)inb(iobase+EL_RXC); - outb(iobase+EL_AC, EL_AC_IRQE | EL_AC_RX); - return 1; - } - - sc->sc_arpcom.ac_if.if_ipackets++; - - /* Copy the data into our buffer. */ - outb(iobase+EL_GPBL, 0); - outb(iobase+EL_GPBH, 0); - insb(iobase+EL_BUF, sc->sc_pktbuf, len); - outb(iobase+EL_RBC, 0); - outb(iobase+EL_AC, EL_AC_RX); - dprintf(("%s-->", ether_sprintf(sc->sc_pktbuf+6))); - dprintf(("%s\n", ether_sprintf(sc->sc_pktbuf))); - - /* Pass data up to upper levels. */ - elread(sc, (caddr_t)sc->sc_pktbuf, len); - - /* Is there another packet? */ - stat = inb(iobase+EL_AS); - - /* If so, do it all again (i.e. don't set done to 1). */ - if ((stat & EL_AS_RXBUSY) == 0) - dprintf((" ")); - else - done = 1; - } - - (void)inb(iobase+EL_RXC); - outb(iobase+EL_AC, EL_AC_IRQE | EL_AC_RX); - return 1; -} - -/* - * Pass a packet up to the higher levels. - */ -static inline void -elread(sc, buf, len) - struct el_softc *sc; - caddr_t buf; - int len; -{ - register struct ether_header *eh; - struct mbuf *m; - - eh = (struct ether_header *)buf; - len -= sizeof(struct ether_header); - if (len <= 0) - return; - - /* Pull packet off interface. */ - m = elget(buf, len, &sc->sc_arpcom.ac_if); - if (m == 0) - return; - -#if NBPFILTER > 0 - /* - * Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to bpf. - */ - if (sc->sc_arpcom.ac_if.if_bpf) { - bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - */ - if ((sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */ - bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0) { - m_freem(m); - return; - } - } -#endif - - ether_input(&sc->sc_arpcom.ac_if, eh, m); -} - -/* - * Pull read data off a interface. Len is length of data, with local net - * header stripped. We copy the data into mbufs. When full cluster sized - * units are present we copy into clusters. - */ -struct mbuf * -elget(buf, totlen, ifp) - caddr_t buf; - int totlen; - struct ifnet *ifp; -{ - struct mbuf *top, **mp, *m, *p; - int len; - register caddr_t cp = buf; - char *epkt; - - buf += sizeof(struct ether_header); - cp = buf; - epkt = cp + totlen; - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return 0; - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = totlen; - m->m_len = MHLEN; - top = 0; - mp = ⊤ - - while (totlen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - m_freem(top); - return 0; - } - m->m_len = MLEN; - } - len = min(totlen, epkt - cp); - if (len >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - m->m_len = len = min(len, MCLBYTES); - else - len = m->m_len; - } else { - /* - * Place initial small packet/header at end of mbuf. - */ - if (len < m->m_len) { - if (top == 0 && len + max_linkhdr <= m->m_len) - m->m_data += max_linkhdr; - m->m_len = len; - } else - len = m->m_len; - } - bcopy(cp, mtod(m, caddr_t), (unsigned)len); - cp += len; - *mp = m; - mp = &m->m_next; - totlen -= len; - if (cp == epkt) - cp = buf; - } - - return top; -} - -/* - * Process an ioctl request. This code needs some work - it looks pretty ugly. - */ -static int -el_ioctl(ifp, cmd, data) - register struct ifnet *ifp; - u_long cmd; - caddr_t data; -{ - struct el_softc *sc = elcd.cd_devs[ifp->if_unit]; - struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splimp(); - - switch (cmd) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - el_init(sc); /* before arpwhohas */ - /* - * See if another station has *our* IP address. - * i.e.: There is an address conflict! If a - * conflict exists, a message is sent to the - * console. - */ - sc->sc_arpcom.ac_ipaddr = IA_SIN(ifa)->sin_addr; - arpwhohas(&sc->sc_arpcom, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - /* - * XXX - This code is probably wrong. - */ - case AF_NS: - { - register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr; - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(sc->sc_arpcom.ac_enaddr); - else { - /* - * - */ - bcopy((caddr_t)ina->x_host.c_host, - (caddr_t)sc->sc_arpcom.ac_enaddr, - sizeof(sc->sc_arpcom.ac_enaddr)); - } - /* Set new address. */ - el_init(sc); - break; - } -#endif - default: - el_init(sc); - break; - } - break; - - case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, then - * stop it. - */ - el_stop(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, then - * start it. - */ - el_init(sc); - } else { - /* - * Some other important flag might have changed, so - * reset. - */ - el_reset(sc); - } - - default: - error = EINVAL; - } - (void) splx(s); - return error; -} - -/* - * Device timeout routine. - */ -static int -el_watchdog(unit) - int unit; -{ - struct el_softc *sc = elcd.cd_devs[unit]; - - log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_oerrors++; - - el_reset(sc); -} diff --git a/sys/arch/i386/isa/if_elreg.h b/sys/arch/i386/isa/if_elreg.h deleted file mode 100644 index 51f85999ace8..000000000000 --- a/sys/arch/i386/isa/if_elreg.h +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: if_elreg.h,v 1.4 1994/10/27 04:17:29 cgd Exp $ */ - -/* - * Copyright (c) 1994, Matthew E. Kimmel. Permission is hereby granted - * to use, copy, modify and distribute this software provided that both - * the copyright notice and this permission notice appear in all copies - * of the software, derivative works or modified versions, and any - * portions thereof. - */ - -/* - * 3COM Etherlink 3C501 Register Definitions - */ - -/* - * I/O Ports - */ -#define EL_RXS 0x6 /* Receive status register */ -#define EL_RXC 0x6 /* Receive command register */ -#define EL_TXS 0x7 /* Transmit status register */ -#define EL_TXC 0x7 /* Transmit command register */ -#define EL_GPBL 0x8 /* GP buffer ptr low byte */ -#define EL_GPBH 0x9 /* GP buffer ptr high byte */ -#define EL_RBL 0xa /* Receive buffer ptr low byte */ -#define EL_RBC 0xa /* Receive buffer clear */ -#define EL_RBH 0xb /* Receive buffer ptr high byte */ -#define EL_EAW 0xc /* Ethernet address window */ -#define EL_AS 0xe /* Auxillary status register */ -#define EL_AC 0xe /* Auxillary command register */ -#define EL_BUF 0xf /* Data buffer */ - -/* Receive status register bits */ -#define EL_RXS_OFLOW 0x01 /* Overflow error */ -#define EL_RXS_FCS 0x02 /* FCS error */ -#define EL_RXS_DRIB 0x04 /* Dribble error */ -#define EL_RXS_SHORT 0x08 /* Short frame */ -#define EL_RXS_NOFLOW 0x10 /* No overflow */ -#define EL_RXS_GOOD 0x20 /* Received good frame */ -#define EL_RXS_STALE 0x80 /* Stale receive status */ - -/* Receive command register bits */ -#define EL_RXC_DISABLE 0x00 /* Receiver disabled */ -#define EL_RXC_DOFLOW 0x01 /* Detect overflow */ -#define EL_RXC_DFCS 0x02 /* Detect FCS errs */ -#define EL_RXC_DDRIB 0x04 /* Detect dribble errors */ -#define EL_RXC_DSHORT 0x08 /* Detect short frames */ -#define EL_RXC_DNOFLOW 0x10 /* Detect frames w/o overflow ??? */ -#define EL_RXC_AGF 0x20 /* Accept Good Frames */ -#define EL_RXC_PROMISC 0x40 /* Promiscuous mode */ -#define EL_RXC_ABROAD 0x80 /* Accept address, broadcast */ -#define EL_RXC_AMULTI 0xc0 /* Accept address, multicast */ - -/* Transmit status register bits */ -#define EL_TXS_UFLOW 0x01 /* Underflow */ -#define EL_TXS_COLL 0x02 /* Collision */ -#define EL_TXS_COLL16 0x04 /* Collision 16 */ -#define EL_TXS_READY 0x08 /* Ready for new frame */ - -/* Transmit command register bits */ -#define EL_TXC_DUFLOW 0x01 /* Detect underflow */ -#define EL_TXC_DCOLL 0x02 /* Detect collisions */ -#define EL_TXC_DCOLL16 0x04 /* Detect collision 16 */ -#define EL_TXC_DSUCCESS 0x08 /* Detect success */ - -/* Auxillary status register bits */ -#define EL_AS_RXBUSY 0x01 /* Receive busy */ -#define EL_AS_DMADONE 0x10 /* DMA finished */ -#define EL_AS_TXBUSY 0x80 /* Transmit busy */ - -/* Auxillary command register bits */ -#define EL_AC_HOST 0x00 /* System bus can access buffer */ -#define EL_AC_IRQE 0x01 /* IRQ enable */ -#define EL_AC_TXBAD 0x02 /* Transmit frames with bad FCS */ -#define EL_AC_TXFRX 0x04 /* Transmit followed by receive */ -#define EL_AC_RX 0x08 /* Receive */ -#define EL_AC_LB 0x0c /* Loopback */ -#define EL_AC_DRQ 0x20 /* DMA request */ -#define EL_AC_RIDE 0x40 /* DRQ and IRQ enabled */ -#define EL_AC_RESET 0x80 /* Reset */ - -/* Packet buffer size */ -#define EL_BUFSIZ 2048 diff --git a/sys/arch/i386/isa/if_ep.c b/sys/arch/i386/isa/if_ep.c deleted file mode 100644 index 581b3c81f72e..000000000000 --- a/sys/arch/i386/isa/if_ep.c +++ /dev/null @@ -1,1167 +0,0 @@ -/* $NetBSD: if_ep.c,v 1.68 1995/01/22 07:37:28 mycroft Exp $ */ - -/* - * Copyright (c) 1994 Herb Peyerl - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Herb Peyerl. - * 4. The name of Herb Peyerl may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "bpfilter.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#ifdef INET -#include -#include -#include -#include -#include -#endif - -#ifdef NS -#include -#include -#endif - -#if NBPFILTER > 0 -#include -#include -#endif - -#include -#include - -#include -#include -#include - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 -/* - * Ethernet software status per interface. - */ -struct ep_softc { - struct device sc_dev; - struct intrhand sc_ih; - - struct arpcom sc_arpcom; /* Ethernet common part */ - int ep_iobase; /* i/o bus address */ - char ep_connectors; /* Connectors on this card. */ -#define MAX_MBS 8 /* # of mbufs we keep around */ - struct mbuf *mb[MAX_MBS]; /* spare mbuf storage. */ - int next_mb; /* Which mbuf to use next. */ - int last_mb; /* Last mbuf. */ - int tx_start_thresh; /* Current TX_start_thresh. */ - int tx_succ_ok; /* # packets sent in sequence */ - /* w/o underrun */ - char bus32bit; /* 32bit access possible */ -}; - -static int epprobe __P((struct device *, void *, void *)); -static void epattach __P((struct device *, struct device *, void *)); - -struct cfdriver epcd = { - NULL, "ep", epprobe, epattach, DV_IFNET, sizeof(struct ep_softc) -}; - -int epintr __P((struct ep_softc *)); -static void epxstat __P((struct ep_softc *)); -static int epstatus __P((struct ep_softc *)); -static void epinit __P((struct ep_softc *)); -static int epioctl __P((struct ifnet *, u_long, caddr_t)); -static int epstart __P((struct ifnet *)); -static int epwatchdog __P((int)); -static void epreset __P((struct ep_softc *)); -static void epread __P((struct ep_softc *)); -static void epmbuffill __P((struct ep_softc *)); -static void epmbufempty __P((struct ep_softc *)); -static void epstop __P((struct ep_softc *)); -static void epsetfilter __P((struct ep_softc *sc)); -static void epsetlink __P((struct ep_softc *sc)); - -static u_short epreadeeprom __P((int id_port, int offset)); -static int epbusyeeprom __P((struct ep_softc *)); - -#define MAXEPCARDS 20 /* if you have 21 cards in your machine... you lose */ - -static struct epcard { - int iobase; - int irq; - char available; - char bus32bit; -} epcards[MAXEPCARDS]; -static int nepcards; - -static void -epaddcard(iobase, irq, bus32bit) - int iobase; - int irq; - char bus32bit; -{ - - if (nepcards >= MAXEPCARDS) - return; - epcards[nepcards].iobase = iobase; - epcards[nepcards].irq = (irq == 2) ? 9 : irq; - epcards[nepcards].available = 1; - epcards[nepcards].bus32bit = bus32bit; - nepcards++; -} - -/* - * 3c579 cards on the EISA bus are probed by their slot number. 3c509 - * cards on the ISA bus are probed in ethernet address order. The probe - * sequence requires careful orchestration, and we'd like like to allow - * the irq and base address to be wildcarded. So, we probe all the cards - * the first time epprobe() is called. On subsequent calls we look for - * matching cards. - */ -int -epprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct ep_softc *sc = match; - struct isa_attach_args *ia = aux; - static int probed; - int slot, iobase, i; - u_short vendor, model; - int k, k2; - - if (!probed) { - probed = 1; - - /* find all EISA cards */ - for (slot = 1; slot < 16; slot++) { - iobase = 0x1000 * slot; - - vendor = htons(inw(iobase + EISA_VENDOR)); - if (vendor != MFG_ID) - continue; - - model = htons(inw(iobase + EISA_MODEL)); - if ((model & 0xfff0) != PROD_ID) { -#ifndef trusted - printf("epprobe: ignoring model %04x\n", model); -#endif - continue; - } - - outb(iobase + EISA_CONTROL, EISA_ENABLE | EISA_RESET); - delay(10); - outb(iobase + EISA_CONTROL, EISA_ENABLE); - /* Wait for reset? */ - delay(1000); - - k = inw(iobase + EP_W0_ADDRESS_CFG); - k = (k & 0x1f) * 0x10 + 0x200; - - k2 = inw(iobase + EP_W0_RESOURCE_CFG); - k2 >>= 12; - epaddcard(iobase, k2, 1); - } - - for (slot = 0; slot < 10; slot++) { - elink_reset(); - elink_idseq(ELINK_509_POLY); - - /* Untag all the adapters so they will talk to us. */ - if (slot == 0) - outb(ELINK_ID_PORT, TAG_ADAPTER + 0); - - vendor = - htons(epreadeeprom(ELINK_ID_PORT, EEPROM_MFG_ID)); - if (vendor != MFG_ID) - continue; - - model = - htons(epreadeeprom(ELINK_ID_PORT, EEPROM_PROD_ID)); - if ((model & 0xfff0) != PROD_ID) { -#ifndef trusted - printf("epprobe: ignoring model %04x\n", model); -#endif - continue; - } - - k = epreadeeprom(ELINK_ID_PORT, EEPROM_ADDR_CFG); - k = (k & 0x1f) * 0x10 + 0x200; - - k2 = epreadeeprom(ELINK_ID_PORT, EEPROM_RESOURCE_CFG); - k2 >>= 12; - epaddcard(k, k2, 0); - - /* so card will not respond to contention again */ - outb(ELINK_ID_PORT, TAG_ADAPTER + 1); - - /* - * XXX: this should probably not be done here - * because it enables the drq/irq lines from - * the board. Perhaps it should be done after - * we have checked for irq/drq collisions? - */ - outb(ELINK_ID_PORT, ACTIVATE_ADAPTER_TO_CONFIG); - } - /* XXX should we sort by ethernet address? */ - } - - for (i = 0; i < nepcards; i++) { - if (epcards[i].available == 0) - continue; - if (ia->ia_iobase != IOBASEUNK && - ia->ia_iobase != epcards[i].iobase) - continue; - if (ia->ia_irq != IRQUNK && - ia->ia_irq != epcards[i].irq) - continue; - goto good; - } - return 0; - -good: - epcards[i].available = 0; - sc->bus32bit = epcards[i].bus32bit; - ia->ia_iobase = epcards[i].iobase; - ia->ia_irq = epcards[i].irq; - ia->ia_iosize = 0x10; - ia->ia_msize = 0; - return 1; -} - -static void -epattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct ep_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - u_short i; - - printf(": "); - - sc->ep_iobase = ia->ia_iobase; - - GO_WINDOW(0); - - sc->ep_connectors = 0; - i = inw(ia->ia_iobase + EP_W0_CONFIG_CTRL); - if (i & IS_AUI) { - printf("aui"); - sc->ep_connectors |= AUI; - } - if (i & IS_BNC) { - if (sc->ep_connectors) - printf("/"); - printf("bnc"); - sc->ep_connectors |= BNC; - } - if (i & IS_UTP) { - if (sc->ep_connectors) - printf("/"); - printf("utp"); - sc->ep_connectors |= UTP; - } - if (!sc->ep_connectors) - printf("no connectors!"); - - /* - * Read the station address from the eeprom - */ - for (i = 0; i < 3; i++) { - u_short x; - if (epbusyeeprom(sc)) - return; - outw(BASE + EP_W0_EEPROM_COMMAND, READ_EEPROM | i); - if (epbusyeeprom(sc)) - return; - x = inw(BASE + EP_W0_EEPROM_DATA); - sc->sc_arpcom.ac_enaddr[(i << 1)] = x >> 8; - sc->sc_arpcom.ac_enaddr[(i << 1) + 1] = x; - } - - printf(" address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr)); - - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = epcd.cd_name; - ifp->if_flags = - IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - ifp->if_output = ether_output; - ifp->if_start = epstart; - ifp->if_ioctl = epioctl; - ifp->if_watchdog = epwatchdog; - - if_attach(ifp); - ether_ifattach(ifp); - -#if NBPFILTER > 0 - bpfattach(&sc->sc_arpcom.ac_if.if_bpf, ifp, DLT_EN10MB, - sizeof(struct ether_header)); -#endif - - sc->tx_start_thresh = 20; /* probably a good starting point. */ - - sc->sc_ih.ih_fun = epintr; - sc->sc_ih.ih_arg = sc; - sc->sc_ih.ih_level = IPL_NET; - intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih); -} - -/* - * The order in here seems important. Otherwise we may not receive - * interrupts. ?! - */ -static void -epinit(sc) - register struct ep_softc *sc; -{ - register struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int s, i; - - /* Address not known. */ - if (ifp->if_addrlist == 0) - return; - - s = splimp(); - - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS) - ; - - GO_WINDOW(0); - outw(BASE + EP_W0_CONFIG_CTRL, 0); /* Disable the card */ - outw(BASE + EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ); /* Enable the card */ - - GO_WINDOW(2); - for (i = 0; i < 6; i++) /* Reload the ether_addr. */ - outb(BASE + EP_W2_ADDR_0 + i, sc->sc_arpcom.ac_enaddr[i]); - - outw(BASE + EP_COMMAND, RX_RESET); - outw(BASE + EP_COMMAND, TX_RESET); - - GO_WINDOW(1); /* Window 1 is operating window */ - for (i = 0; i < 31; i++) - inb(BASE + EP_W1_TX_STATUS); - - outw(BASE + EP_COMMAND, SET_RD_0_MASK | S_CARD_FAILURE | - S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL); - outw(BASE + EP_COMMAND, SET_INTR_MASK | S_CARD_FAILURE | - S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL); - - /* - * Attempt to get rid of any stray interrupts that occured during - * configuration. On the i386 this isn't possible because one may - * already be queued. However, a single stray interrupt is - * unimportant. - */ - outw(BASE + EP_COMMAND, ACK_INTR | 0xff); - - epsetfilter(sc); - epsetlink(sc); - - outw(BASE + EP_COMMAND, RX_ENABLE); - outw(BASE + EP_COMMAND, TX_ENABLE); - - epmbuffill(sc); - - /* Interface is now `running', with no output active. */ - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - - /* Attempt to start output, if any. */ - epstart(ifp); - - splx(s); -} - -static void -epsetfilter(sc) - register struct ep_softc *sc; -{ - register struct ifnet *ifp = &sc->sc_arpcom.ac_if; - - GO_WINDOW(1); /* Window 1 is operating window */ - outw(BASE + EP_COMMAND, SET_RX_FILTER | - FIL_INDIVIDUAL | FIL_BRDCST | - ((ifp->if_flags & IFF_MULTICAST) ? FIL_MULTICAST : 0 ) | - ((ifp->if_flags & IFF_PROMISC) ? FIL_PROMISC : 0 )); -} - -static void -epsetlink(sc) - register struct ep_softc *sc; -{ - register struct ifnet *ifp = &sc->sc_arpcom.ac_if; - - /* - * you can `ifconfig (link0|-link0) ep0' to get the following - * behaviour: - * -link0 disable AUI/UTP. enable BNC. - * link0 disable BNC. enable AUI. - * link1 if the card has a UTP connector, and link0 is - * set too, then you get the UTP port. - */ - GO_WINDOW(4); - outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP); - if (!(ifp->if_flags & IFF_LINK0) && (sc->ep_connectors & BNC)) { - outw(BASE + EP_COMMAND, START_TRANSCEIVER); - delay(1000); - } - if (ifp->if_flags & IFF_LINK0) { - outw(BASE + EP_COMMAND, STOP_TRANSCEIVER); - delay(1000); - if ((ifp->if_flags & IFF_LINK1) && (sc->ep_connectors & UTP)) - outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP); - } - GO_WINDOW(1); -} - -/* - * Start outputting on the interface. - * Always called as splimp(). - */ -static int -epstart(ifp) - struct ifnet *ifp; -{ - register struct ep_softc *sc = epcd.cd_devs[ifp->if_unit]; - struct mbuf *m, *m0; - int sh, len, pad; - - if (sc->sc_arpcom.ac_if.if_flags & IFF_OACTIVE) - return; - -startagain: - /* Sneak a peek at the next packet */ - m0 = sc->sc_arpcom.ac_if.if_snd.ifq_head; - if (m0 == 0) - return; -#if 0 - len = m0->m_pkthdr.len; -#else - for (len = 0, m = m0; m; m = m->m_next) - len += m->m_len; -#endif - - pad = (4 - len) & 3; - - /* - * The 3c509 automatically pads short packets to minimum ethernet - * length, but we drop packets that are too large. Perhaps we should - * truncate them instead? - */ - if (len + pad > ETHER_MAX_LEN) { - /* packet is obviously too large: toss it */ - ++sc->sc_arpcom.ac_if.if_oerrors; - IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m0); - m_freem(m0); - goto readcheck; - } - - if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) { - outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | (len + pad + 4)); - /* not enough room in FIFO */ - sc->sc_arpcom.ac_if.if_flags |= IFF_OACTIVE; - return; - } else { - outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 2044); - } - - IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m0); - if (m0 == 0) /* not really needed */ - return; - - outw(BASE + EP_COMMAND, SET_TX_START_THRESH | - (len / 4 + sc->tx_start_thresh)); - -#if NBPFILTER > 0 - if (sc->sc_arpcom.ac_if.if_bpf) - bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0); -#endif - - /* - * Do the output at splhigh() so that an interrupt from another device - * won't cause a FIFO underrun. - */ - sh = splhigh(); - - outw(BASE + EP_W1_TX_PIO_WR_1, len); - outw(BASE + EP_W1_TX_PIO_WR_1, 0xffff); /* Second dword meaningless */ - if (sc->bus32bit) { - for (m = m0; m; ) { - if (m->m_len > 3) - outsl(BASE + EP_W1_TX_PIO_WR_1, - mtod(m, caddr_t), m->m_len / 4); - if (m->m_len & 3) - outsb(BASE + EP_W1_TX_PIO_WR_1, - mtod(m, caddr_t) + (m->m_len & ~3), - m->m_len & 3); - MFREE(m, m0); - m = m0; - } - } else { - for (m = m0; m; ) { - if (m->m_len > 1) - outsw(BASE + EP_W1_TX_PIO_WR_1, - mtod(m, caddr_t), m->m_len / 2); - if (m->m_len & 1) - outb(BASE + EP_W1_TX_PIO_WR_1, - *(mtod(m, caddr_t) + m->m_len - 1)); - MFREE(m, m0); - m = m0; - } - } - while (pad--) - outb(BASE + EP_W1_TX_PIO_WR_1, 0); - - splx(sh); - - ++sc->sc_arpcom.ac_if.if_opackets; - -readcheck: - if ((inw(BASE + EP_W1_RX_STATUS) & ERR_INCOMPLETE) == 0) { - /* We received a complete packet. */ - u_short status = inw(BASE + EP_STATUS); - - if ((status & S_INTR_LATCH) == 0) { - /* - * No interrupt, read the packet and continue - * Is this supposed to happen? Is my motherboard - * completely busted? - */ - epread(sc); - } - else - /* Got an interrupt, return so that it gets serviced. */ - return; - } - else { - /* Check if we are stuck and reset [see XXX comment] */ - if (epstatus(sc)) { - if (sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG) - printf("%s: adapter reset\n", - sc->sc_dev.dv_xname); - epreset(sc); - } - } - - goto startagain; -} - - -/* - * XXX: The 3c509 card can get in a mode where both the fifo status bit - * FIFOS_RX_OVERRUN and the status bit ERR_INCOMPLETE are set - * We detect this situation and we reset the adapter. - * It happens at times when there is a lot of broadcast traffic - * on the cable (once in a blue moon). - */ -static int -epstatus(sc) - register struct ep_softc *sc; -{ - u_short fifost; - - /* - * Check the FIFO status and act accordingly - */ - GO_WINDOW(4); - fifost = inw(BASE + EP_W4_FIFO_DIAG); - GO_WINDOW(1); - - if (fifost & FIFOS_RX_UNDERRUN) { - if (sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG) - printf("%s: RX underrun\n", sc->sc_dev.dv_xname); - epreset(sc); - return 0; - } - - if (fifost & FIFOS_RX_STATUS_OVERRUN) { - if (sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG) - printf("%s: RX Status overrun\n", sc->sc_dev.dv_xname); - return 1; - } - - if (fifost & FIFOS_RX_OVERRUN) { - if (sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG) - printf("%s: RX overrun\n", sc->sc_dev.dv_xname); - return 1; - } - - if (fifost & FIFOS_TX_OVERRUN) { - if (sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG) - printf("%s: TX overrun\n", sc->sc_dev.dv_xname); - epreset(sc); - return 0; - } - - return 0; -} - - -static void -eptxstat(sc) - register struct ep_softc *sc; -{ - int i; - - /* - * We need to read+write TX_STATUS until we get a 0 status - * in order to turn off the interrupt flag. - */ - while ((i = inb(BASE + EP_W1_TX_STATUS)) & TXS_COMPLETE) { - outb(BASE + EP_W1_TX_STATUS, 0x0); - - if (i & TXS_JABBER) { - ++sc->sc_arpcom.ac_if.if_oerrors; - if (sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG) - printf("%s: jabber (%x)\n", - sc->sc_dev.dv_xname, i); - epreset(sc); - } else if (i & TXS_UNDERRUN) { - ++sc->sc_arpcom.ac_if.if_oerrors; - if (sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG) - printf("%s: fifo underrun (%x) @%d\n", - sc->sc_dev.dv_xname, i, - sc->tx_start_thresh); - if (sc->tx_succ_ok < 100) - sc->tx_start_thresh = min(ETHER_MAX_LEN, - sc->tx_start_thresh + 20); - sc->tx_succ_ok = 0; - epreset(sc); - } else if (i & TXS_MAX_COLLISION) { - ++sc->sc_arpcom.ac_if.if_collisions; - outw(BASE + EP_COMMAND, TX_ENABLE); - sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - } else - sc->tx_succ_ok = (sc->tx_succ_ok+1) & 127; - - } -} - -int -epintr(sc) - register struct ep_softc *sc; -{ - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - u_short status; - int ret = 0; - - for (;;) { - status = inw(BASE + EP_STATUS); - - if ((status & S_INTR_LATCH) == 0) - /* Not from this card; maybe a chained interrupt? */ - return; - - if ((status & (S_TX_COMPLETE | S_TX_AVAIL | - S_RX_COMPLETE | S_CARD_FAILURE)) == 0) - break; - - ret = 1; - - /* - * Acknowledge any interrupts. It's important that we do this - * first, since there would otherwise be a race condition. - * Due to the i386 interrupt queueing, we may get spurious - * interrupts occasionally. - */ - outw(BASE + EP_COMMAND, ACK_INTR | status); - - if (status & S_RX_COMPLETE) - epread(sc); - if (status & S_TX_AVAIL) { - sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - epstart(&sc->sc_arpcom.ac_if); - } - if (status & S_CARD_FAILURE) { - printf("%s: adapter failure (%x)\n", - sc->sc_dev.dv_xname, status); - outw(BASE + EP_COMMAND, C_INTR_LATCH); - epreset(sc); - return (1); - } - if (status & S_TX_COMPLETE) { - eptxstat(sc); - epstart(ifp); - } - } - - /* no more interrupts */ - outw(BASE + EP_COMMAND, C_INTR_LATCH); - return (ret); -} - -static void -epread(sc) - register struct ep_softc *sc; -{ - struct ether_header *eh; - struct mbuf *mcur, *m, *m0; - u_short totlen, mlen, save_totlen; - int sh; - - totlen = inw(BASE + EP_W1_RX_STATUS); -again: - m0 = 0; - - if (sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG) { - int err = totlen & ERR_MASK; - char *s = NULL; - - if (totlen & ERR_INCOMPLETE) - s = "incomplete packet"; - else if (err == ERR_OVERRUN) - s = "packet overrun"; - else if (err == ERR_RUNT) - s = "runt packet"; - else if (err == ERR_ALIGNMENT) - s = "bad alignment"; - else if (err == ERR_CRC) - s = "bad crc"; - else if (err == ERR_OVERSIZE) - s = "oversized packet"; - else if (err == ERR_DRIBBLE) - s = "dribble bits"; - - if (s) - printf("%s: %s\n", sc->sc_dev.dv_xname, s); - } - - if (totlen & ERR_INCOMPLETE) - return; - - if (totlen & ERR_RX) { - ++sc->sc_arpcom.ac_if.if_ierrors; - goto abort; - } - - save_totlen = totlen &= RX_BYTES_MASK; /* Lower 11 bits = RX bytes. */ - - m = sc->mb[sc->next_mb]; - sc->mb[sc->next_mb] = NULL; - - if (m == 0) { - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - goto abort; - } else { - /* Convert one of our saved mbuf's. */ - sc->next_mb = (sc->next_mb + 1) % MAX_MBS; - m->m_data = m->m_pktdat; - m->m_flags = M_PKTHDR; - } - - m0 = m; -#define EROUND ((sizeof(struct ether_header) + 3) & ~3) -#define EOFF (EROUND - sizeof(struct ether_header)) - m0->m_data += EOFF; - - /* - * We read the packet at splhigh() so that an interrupt from another - * device doesn't cause the card's buffer to overflow while we're - * reading it. We may still lose packets at other times. - */ - sh = splhigh(); - - /* Read what should be the header. */ - insw(BASE + EP_W1_RX_PIO_RD_1, - mtod(m0, caddr_t), sizeof(struct ether_header) / 2); - m0->m_len = sizeof(struct ether_header); - totlen -= sizeof(struct ether_header); - eh = mtod(m0, struct ether_header *); - - /* Read packet data. */ - while (totlen > 0) { - mlen = min(totlen, M_TRAILINGSPACE(m)); - if (mlen < 4) { - /* not enough room in this mbuf */ - mcur = m; - m = sc->mb[sc->next_mb]; - sc->mb[sc->next_mb] = 0; - if (m == 0) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - splx(sh); - goto abort; - } - } else { - timeout(epmbuffill, sc, 1); - sc->next_mb = (sc->next_mb + 1) % MAX_MBS; - } - if (totlen >= MINCLSIZE) - MCLGET(m, M_DONTWAIT); - m->m_len = 0; - mcur->m_next = m; - mlen = min(totlen, M_TRAILINGSPACE(m)); - } - if (sc->bus32bit) { - if (mlen > 3) { - mlen &= ~3; - insl(BASE + EP_W1_RX_PIO_RD_1, - mtod(m, caddr_t) + m->m_len, mlen / 4); - } else - insb(BASE + EP_W1_RX_PIO_RD_1, - mtod(m, caddr_t) + m->m_len, mlen); - } else { - if (mlen > 1) { - mlen &= ~1; - insw(BASE + EP_W1_RX_PIO_RD_1, - mtod(m, caddr_t) + m->m_len, mlen / 2); - } else - *(mtod(m, caddr_t) + m->m_len) = - inb(BASE + EP_W1_RX_PIO_RD_1); - } - m->m_len += mlen; - totlen -= mlen; - } - - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS) - ; - - splx(sh); - - m0->m_pkthdr.len = save_totlen; - m0->m_pkthdr.rcvif = &sc->sc_arpcom.ac_if; - - ++sc->sc_arpcom.ac_if.if_ipackets; - -#if NBPFILTER > 0 - if (sc->sc_arpcom.ac_if.if_bpf) { - bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - */ - if ((sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && - bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0) { - m_freem(m0); - return; - } - } -#endif - - m_adj(m0, sizeof(struct ether_header)); - ether_input(&sc->sc_arpcom.ac_if, eh, m0); - - /* - * In periods of high traffic we can actually receive enough - * packets so that the fifo overrun bit will be set at this point, - * even though we just read a packet. In this case we - * are not going to receive any more interrupts. We check for - * this condition and read again until the fifo is not full. - * We could simplify this test by not using epstatus(), but - * rechecking the RX_STATUS register directly. This test could - * result in unnecessary looping in cases where there is a new - * packet but the fifo is not full, but it will not fix the - * stuck behavior. - * - * Even with this improvement, we still get packet overrun errors - * which are hurting performance. Maybe when I get some more time - * I'll modify epread() so that it can handle RX_EARLY interrupts. - */ - if (epstatus(sc)) { - totlen = inw(BASE + EP_W1_RX_STATUS); - /* Check if we are stuck and reset [see XXX comment] */ - if (totlen & ERR_INCOMPLETE) { - if (sc->sc_arpcom.ac_if.if_flags & IFF_DEBUG) - printf("%s: adapter reset\n", - sc->sc_dev.dv_xname); - epreset(sc); - return; - } - goto again; - } - - return; - -abort: - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS) - ; - if (m0) - m_freem(m0); -} - -static int -epioctl(ifp, command, data) - register struct ifnet *ifp; - u_long command; - caddr_t data; -{ - struct ep_softc *sc = epcd.cd_devs[ifp->if_unit]; - register struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splimp(); - - switch (command) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - epinit(sc); /* before arpwhohas */ - /* - * See if another station has *our* IP address. - * i.e.: There is an address conflict! If a - * conflict exists, a message is sent to the - * console. - */ - sc->sc_arpcom.ac_ipaddr = IA_SIN(ifa)->sin_addr; - arpwhohas(&sc->sc_arpcom, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - case AF_NS: - { - register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr; - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(sc->sc_arpcom.ac_enaddr); - else - bcopy(ina->x_host.c_host, - sc->sc_arpcom.ac_enaddr, - sizeof(sc->sc_arpcom.ac_enaddr)); - /* Set new address. */ - epinit(sc); - break; - } -#endif - default: - epinit(sc); - break; - } - break; - - case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, then - * stop it. - */ - epstop(sc); - epmbufempty(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, then - * start it. - */ - epinit(sc); - } else { - /* - * deal with flags changes: - * IFF_MULTICAST, IFF_PROMISC, - * IFF_LINK0, IFF_LINK1, - */ - epsetfilter(sc); - epsetlink(sc); - } - break; - - case SIOCADDMULTI: - case SIOCDELMULTI: - /* Update our multicast list. */ - error = (command == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->sc_arpcom) : - ether_delmulti(ifr, &sc->sc_arpcom); - - if (error == ENETRESET) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - epreset(sc); - error = 0; - } - break; - - default: - error = EINVAL; - } - - splx(s); - return (error); -} - -static void -epreset(sc) - struct ep_softc *sc; -{ - int s; - - s = splimp(); - untimeout(epmbuffill, sc); - epstop(sc); - epinit(sc); - splx(s); -} - -static int -epwatchdog(unit) - int unit; -{ - register struct ep_softc *sc = epcd.cd_devs[unit]; - - log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); - epreset(sc); - return 0; -} - -static void -epstop(sc) - register struct ep_softc *sc; -{ - - outw(BASE + EP_COMMAND, RX_DISABLE); - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS) - ; - outw(BASE + EP_COMMAND, TX_DISABLE); - outw(BASE + EP_COMMAND, STOP_TRANSCEIVER); - outw(BASE + EP_COMMAND, RX_RESET); - outw(BASE + EP_COMMAND, TX_RESET); - outw(BASE + EP_COMMAND, C_INTR_LATCH); - outw(BASE + EP_COMMAND, SET_RD_0_MASK); - outw(BASE + EP_COMMAND, SET_INTR_MASK); - outw(BASE + EP_COMMAND, SET_RX_FILTER); -} - -/* - * We get eeprom data from the id_port given an offset into the - * eeprom. Basically; after the ID_sequence is sent to all of - * the cards; they enter the ID_CMD state where they will accept - * command requests. 0x80-0xbf loads the eeprom data. We then - * read the port 16 times and with every read; the cards check - * for contention (ie: if one card writes a 0 bit and another - * writes a 1 bit then the host sees a 0. At the end of the cycle; - * each card compares the data on the bus; if there is a difference - * then that card goes into ID_WAIT state again). In the meantime; - * one bit of data is returned in the AX register which is conveniently - * returned to us by inb(). Hence; we read 16 times getting one - * bit of data with each read. - */ -static u_short -epreadeeprom(id_port, offset) - int id_port; - int offset; -{ - int i, data = 0; - - outb(id_port, 0x80 + offset); - delay(1000); - for (i = 0; i < 16; i++) - data = (data << 1) | (inw(id_port) & 1); - return (data); -} - -static int -epbusyeeprom(sc) - struct ep_softc *sc; -{ - int i = 100, j; - - while (i--) { - j = inw(BASE + EP_W0_EEPROM_COMMAND); - if (j & EEPROM_BUSY) - delay(100); - else - break; - } - if (!i) { - printf("\n%s: eeprom failed to come ready\n", - sc->sc_dev.dv_xname); - return (1); - } - if (j & EEPROM_TST_MODE) { - printf("\n%s: erase pencil mark, or disable plug-n-play mode!\n", - sc->sc_dev.dv_xname); - return (1); - } - return (0); -} - -static void -epmbuffill(sc) - struct ep_softc *sc; -{ - int s, i; - - s = splimp(); - i = sc->last_mb; - do { - if (sc->mb[i] == NULL) - MGET(sc->mb[i], M_DONTWAIT, MT_DATA); - if (sc->mb[i] == NULL) - break; - i = (i + 1) % MAX_MBS; - } while (i != sc->next_mb); - sc->last_mb = i; - splx(s); -} - -static void -epmbufempty(sc) - struct ep_softc *sc; -{ - int s, i; - - s = splimp(); - for (i = 0; imb[i]) { - m_freem(sc->mb[i]); - sc->mb[i] = NULL; - } - } - sc->last_mb = sc->next_mb = 0; - untimeout(epmbuffill, sc); - splx(s); -} diff --git a/sys/arch/i386/isa/if_epreg.h b/sys/arch/i386/isa/if_epreg.h deleted file mode 100644 index da6d0c84ec7a..000000000000 --- a/sys/arch/i386/isa/if_epreg.h +++ /dev/null @@ -1,337 +0,0 @@ -/* $NetBSD: if_epreg.h,v 1.12 1995/01/22 07:37:30 mycroft Exp $ */ - -/* - * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * These define the EEPROM data structure. They are used in the probe - * function to verify the existance of the adapter after having sent - * the ID_Sequence. - * - * There are others but only the ones we use are defined here. - */ -#define EEPROM_NODE_ADDR_0 0x0 /* Word */ -#define EEPROM_NODE_ADDR_1 0x1 /* Word */ -#define EEPROM_NODE_ADDR_2 0x2 /* Word */ -#define EEPROM_PROD_ID 0x3 /* 0x9[0-f]50 */ -#define EEPROM_MFG_ID 0x7 /* 0x6d50 */ -#define EEPROM_ADDR_CFG 0x8 /* Base addr */ -#define EEPROM_RESOURCE_CFG 0x9 /* IRQ. Bits 12-15 */ - -/* - * These are the registers for the 3Com 3c509 and their bit patterns when - * applicable. They have been taken out the the "EtherLink III Parallel - * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual - * from 3com. - */ -#define EP_COMMAND 0x0e /* Write. BASE+0x0e is always a command reg. */ -#define EP_STATUS 0x0e /* Read. BASE+0x0e is always status reg. */ -#define EP_WINDOW 0x0f /* Read. BASE+0x0f is always window reg. */ - -/* - * Window 0 registers. Setup. - */ - /* Write */ -#define EP_W0_EEPROM_DATA 0x0c -#define EP_W0_EEPROM_COMMAND 0x0a -#define EP_W0_RESOURCE_CFG 0x08 -#define EP_W0_ADDRESS_CFG 0x06 -#define EP_W0_CONFIG_CTRL 0x04 - /* Read */ -#define EP_W0_PRODUCT_ID 0x02 -#define EP_W0_MFG_ID 0x00 - -/* - * Window 1 registers. Operating Set. - */ - /* Write */ -#define EP_W1_TX_PIO_WR_2 0x02 -#define EP_W1_TX_PIO_WR_1 0x00 - /* Read */ -#define EP_W1_FREE_TX 0x0c -#define EP_W1_TX_STATUS 0x0b /* byte */ -#define EP_W1_TIMER 0x0a /* byte */ -#define EP_W1_RX_STATUS 0x08 -#define EP_W1_RX_PIO_RD_2 0x02 -#define EP_W1_RX_PIO_RD_1 0x00 - -/* - * Window 2 registers. Station Address Setup/Read - */ - /* Read/Write */ -#define EP_W2_ADDR_5 0x05 -#define EP_W2_ADDR_4 0x04 -#define EP_W2_ADDR_3 0x03 -#define EP_W2_ADDR_2 0x02 -#define EP_W2_ADDR_1 0x01 -#define EP_W2_ADDR_0 0x00 - -/* - * Window 3 registers. FIFO Management. - */ - /* Read */ -#define EP_W3_FREE_TX 0x0c -#define EP_W3_FREE_RX 0x0a - -/* - * Window 4 registers. Diagnostics. - */ - /* Read/Write */ -#define EP_W4_MEDIA_TYPE 0x0a -#define EP_W4_CTRLR_STATUS 0x08 -#define EP_W4_NET_DIAG 0x06 -#define EP_W4_FIFO_DIAG 0x04 -#define EP_W4_HOST_DIAG 0x02 -#define EP_W4_TX_DIAG 0x00 - -/* - * Window 5 Registers. Results and Internal status. - */ - /* Read */ -#define EP_W5_READ_0_MASK 0x0c -#define EP_W5_INTR_MASK 0x0a -#define EP_W5_RX_FILTER 0x08 -#define EP_W5_RX_EARLY_THRESH 0x06 -#define EP_W5_TX_AVAIL_THRESH 0x02 -#define EP_W5_TX_START_THRESH 0x00 - -/* - * Window 6 registers. Statistics. - */ - /* Read/Write */ -#define TX_TOTAL_OK 0x0c -#define RX_TOTAL_OK 0x0a -#define TX_DEFERRALS 0x08 -#define RX_FRAMES_OK 0x07 -#define TX_FRAMES_OK 0x06 -#define RX_OVERRUNS 0x05 -#define TX_COLLISIONS 0x04 -#define TX_AFTER_1_COLLISION 0x03 -#define TX_AFTER_X_COLLISIONS 0x02 -#define TX_NO_SQE 0x01 -#define TX_CD_LOST 0x00 - -/* - * Register definitions. - */ - -/* - * Command register. All windows. - * - * 16 bit register. - * 15-11: 5-bit code for command to be executed. - * 10-0: 11-bit arg if any. For commands with no args; - * this can be set to anything. - */ -#define GLOBAL_RESET (u_short) 0x0000 /* Wait at least 1ms after issuing */ -#define WINDOW_SELECT (u_short) (0x1<<11) -#define START_TRANSCEIVER (u_short) (0x2<<11) /* Read ADDR_CFG reg to determine - whether this is needed. If so; - wait 800 uSec before using trans- - ceiver. */ -#define RX_DISABLE (u_short) (0x3<<11) /* state disabled on power-up */ -#define RX_ENABLE (u_short) (0x4<<11) -#define RX_RESET (u_short) (0x5<<11) -#define RX_DISCARD_TOP_PACK (u_short) (0x8<<11) -#define TX_ENABLE (u_short) (0x9<<11) -#define TX_DISABLE (u_short) (0xa<<11) -#define TX_RESET (u_short) (0xb<<11) -#define REQ_INTR (u_short) (0xc<<11) - -/* - * The following C_* acknowledge the various interrupts. - * Some of them don't do anything. See the manual. - */ -#define ACK_INTR (u_short) (0x6800) -# define C_INTR_LATCH (u_short) (ACK_INTR|0x01) -# define C_CARD_FAILURE (u_short) (ACK_INTR|0x02) -# define C_TX_COMPLETE (u_short) (ACK_INTR|0x04) -# define C_TX_AVAIL (u_short) (ACK_INTR|0x08) -# define C_RX_COMPLETE (u_short) (ACK_INTR|0x10) -# define C_RX_EARLY (u_short) (ACK_INTR|0x20) -# define C_INT_RQD (u_short) (ACK_INTR|0x40) -# define C_UPD_STATS (u_short) (ACK_INTR|0x80) -#define SET_INTR_MASK (u_short) (0x0e<<11) -#define SET_RD_0_MASK (u_short) (0x0f<<11) -#define SET_RX_FILTER (u_short) (0x10<<11) -# define FIL_INDIVIDUAL (u_short) (0x01) -# define FIL_MULTICAST (u_short) (0x02) -# define FIL_BRDCST (u_short) (0x04) -# define FIL_PROMISC (u_short) (0x08) -#define SET_RX_EARLY_THRESH (u_short) (0x11<<11) -#define SET_TX_AVAIL_THRESH (u_short) (0x12<<11) -#define SET_TX_START_THRESH (u_short) (0x13<<11) -#define STATS_ENABLE (u_short) (0x15<<11) -#define STATS_DISABLE (u_short) (0x16<<11) -#define STOP_TRANSCEIVER (u_short) (0x17<<11) - -/* - * Status register. All windows. - * - * 15-13: Window number(0-7). - * 12: Command_in_progress. - * 11: reserved. - * 10: reserved. - * 9: reserved. - * 8: reserved. - * 7: Update Statistics. - * 6: Interrupt Requested. - * 5: RX Early. - * 4: RX Complete. - * 3: TX Available. - * 2: TX Complete. - * 1: Adapter Failure. - * 0: Interrupt Latch. - */ -#define S_INTR_LATCH (u_short) (0x0001) -#define S_CARD_FAILURE (u_short) (0x0002) -#define S_TX_COMPLETE (u_short) (0x0004) -#define S_TX_AVAIL (u_short) (0x0008) -#define S_RX_COMPLETE (u_short) (0x0010) -#define S_RX_EARLY (u_short) (0x0020) -#define S_INT_RQD (u_short) (0x0040) -#define S_UPD_STATS (u_short) (0x0080) -#define S_COMMAND_IN_PROGRESS (u_short) (0x1000) - -/* - * FIFO Registers. RX Status. - * - * 15: Incomplete or FIFO empty. - * 14: 1: Error in RX Packet 0: Incomplete or no error. - * 14-11: Type of error. [14-11] - * 1000 = Overrun. - * 1011 = Run Packet Error. - * 1100 = Alignment Error. - * 1101 = CRC Error. - * 1001 = Oversize Packet Error (>1514 bytes) - * 0010 = Dribble Bits. - * (all other error codes, no errors.) - * - * 10-0: RX Bytes (0-1514) - */ -#define ERR_INCOMPLETE (u_short) (0x8000) -#define ERR_RX (u_short) (0x4000) -#define ERR_MASK (u_short) (0x7800) -#define ERR_OVERRUN (u_short) (0x4000) -#define ERR_RUNT (u_short) (0x5800) -#define ERR_ALIGNMENT (u_short) (0x6000) -#define ERR_CRC (u_short) (0x6800) -#define ERR_OVERSIZE (u_short) (0x4800) -#define ERR_DRIBBLE (u_short) (0x1000) - -/* - * TX Status - * - * Reports the transmit status of a completed transmission. Writing this - * register pops the transmit completion stack. - * - * Window 1/Port 0x0b. - * - * 7: Complete - * 6: Interrupt on successful transmission requested. - * 5: Jabber Error (TP Only, TX Reset required. ) - * 4: Underrun (TX Reset required. ) - * 3: Maximum Collisions. - * 2: TX Status Overflow. - * 1-0: Undefined. - * - */ -#define TXS_COMPLETE 0x80 -#define TXS_INTR_REQ 0x40 -#define TXS_JABBER 0x20 -#define TXS_UNDERRUN 0x10 -#define TXS_MAX_COLLISION 0x08 -#define TXS_STATUS_OVERFLOW 0x04 - -/* - * FIFO Status (Window 4) - * - * Supports FIFO diagnostics - * - * Window 4/Port 0x04.1 - * - * 15: 1=RX receiving (RO). Set when a packet is being received - * into the RX FIFO. - * 14: Reserved - * 13: 1=RX underrun (RO). Generates Adapter Failure interrupt. - * Requires RX Reset or Global Reset command to recover. - * It is generated when you read past the end of a packet - - * reading past what has been received so far will give bad - * data. - * 12: 1=RX status overrun (RO). Set when there are already 8 - * packets in the RX FIFO. While this bit is set, no additional - * packets are received. Requires no action on the part of - * the host. The condition is cleared once a packet has been - * read out of the RX FIFO. - * 11: 1=RX overrun (RO). Set when the RX FIFO is full (there - * may not be an overrun packet yet). While this bit is set, - * no additional packets will be received (some additional - * bytes can still be pending between the wire and the RX - * FIFO). Requires no action on the part of the host. The - * condition is cleared once a few bytes have been read out - * from the RX FIFO. - * 10: 1=TX overrun (RO). Generates adapter failure interrupt. - * Requires TX Reset or Global Reset command to recover. - * Disables Transmitter. - * 9-8: Unassigned. - * 7-0: Built in self test bits for the RX and TX FIFO's. - */ -#define FIFOS_RX_RECEIVING (u_short) 0x8000 -#define FIFOS_RX_UNDERRUN (u_short) 0x2000 -#define FIFOS_RX_STATUS_OVERRUN (u_short) 0x1000 -#define FIFOS_RX_OVERRUN (u_short) 0x0800 -#define FIFOS_TX_OVERRUN (u_short) 0x0400 - -/* - * Misc defines for various things. - */ -#define TAG_ADAPTER 0xd0 -#define ACTIVATE_ADAPTER_TO_CONFIG 0xff -#define ENABLE_DRQ_IRQ 0x0001 -#define MFG_ID 0x506d /* `TCM' */ -#define PROD_ID 0x5090 -#define BASE sc->ep_iobase -#define GO_WINDOW(x) outw(BASE+EP_COMMAND, WINDOW_SELECT|x) -#define AUI 0x1 -#define BNC 0x2 -#define UTP 0x4 -#define IS_AUI (1<<13) -#define IS_BNC (1<<12) -#define IS_UTP (1<<9) -#define EEPROM_BUSY (1<<15) -#define EEPROM_TST_MODE (1<<14) -#define READ_EEPROM (1<<7) -#define ENABLE_UTP 0xc0 -#define DISABLE_UTP 0x0 -#define RX_BYTES_MASK (u_short) (0x07ff) - -/* - * EISA registers (offset from slot base) - */ -#define EISA_VENDOR 0x0c80 /* vendor ID (2 ports) */ -#define EISA_MODEL 0x0c82 /* model number (2 ports) */ -#define EISA_CONTROL 0x0c84 -#define EISA_RESET 0x04 -#define EISA_ERROR 0x02 -#define EISA_ENABLE 0x01 diff --git a/sys/arch/i386/isa/if_hp.c b/sys/arch/i386/isa/if_hp.c deleted file mode 100644 index fb43dfa608a8..000000000000 --- a/sys/arch/i386/isa/if_hp.c +++ /dev/null @@ -1,1000 +0,0 @@ -/* $NetBSD: if_hp.c,v 1.18 1994/10/30 21:43:55 cgd Exp $ */ - -/*- - * Copyright (c) 1990, 1991 William F. Jolitz. - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * HP LAN Ethernet driver - * - * Parts inspired from Tim Tucker's if_wd driver for the wd8003, - * insight on the ne2000 gained from Robert Clements PC/FTP driver. - * - * receive bottom end totally rewritten by Curt Mayer, Dec 1992. - * no longer loses back to back packets. - * note to driver writers: RTFM! - * - * hooks for packet filter added by Charles Hannum, 29DEC1992. - * - * Mostly rewritten for HP-labelled EISA controllers by Charles Hannum, - * 18JAN1993. - */ - -#include "hp.h" -#if NHP > 0 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef INET -#include -#include -#include -#include -#include -#endif - -#ifdef NS -#include -#include -#endif - -#include "bpfilter.h" -#if NBPFILTER > 0 -#include -#include -#include -#endif - -#include -#include - -#include -#include -#include - -int hpprobe(), hpattach(), hpintr(); -int hpstart(), hpinit(), ether_output(), hpioctl(); - -struct isa_driver hpdriver = -{ - hpprobe, hpattach, "hp", -}; - -struct mbuf *hpget(); - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1536 - -/* - * Ethernet software status per interface. - * - * Each interface is referenced by a network interface structure, - * ns_if, which the routing code uses to locate the interface. - * This structure contains the output queue for the interface, its address, ... - */ -struct hp_softc { - struct arpcom ns_ac; /* Ethernet common part */ -#define ns_if ns_ac.ac_if /* network-visible interface */ -#define ns_addrp ns_ac.ac_enaddr /* hardware Ethernet address */ - int ns_flags; -#define DSF_LOCK 1 /* block re-entering enstart */ - int ns_oactive; - int ns_mask; - struct prhdr ns_ph; /* hardware header of incoming packet */ - u_char ns_pb[2048]; - u_char ns_txstart; /* transmitter buffer start */ - u_char ns_rxstart; /* receiver buffer start */ - u_char ns_rxend; /* receiver buffer end */ - u_char hp_type; /* HP board type */ - u_char hp_irq; /* interrupt vector */ - short ns_port; /* i/o port base */ - short ns_mode; /* word/byte mode */ - short ns_rcr; -#if NBPFILTER > 0 - caddr_t ns_bpf; -#endif -} - hp_softc[NHP]; -#define ENBUFSIZE (sizeof(struct ether_header) + ETHERMTU + 2 + ETHER_MIN_LEN) - -#define PAT(n) (0xa55a + 37*(n)) - -u_short boarddata[16]; - -#define hp_option (-8) -#define hp_data (-4) -#define HP_RUN (0x01) -#define HP_DATA (0x10) - -hpprobe(dvp) - struct isa_device *dvp; -{ - int val, i, s, sum, pat; - register struct hp_softc *ns = &hp_softc[0]; - register hpc; - -#ifdef lint - hpintr(0); -#endif - - hpc = (ns->ns_port = dvp->id_iobase + 0x10); - s = splimp(); - - ns->hp_irq = ffs(dvp->id_irq) - 1; - - /* Extract board address */ - for (i = 0; i < 6; i++) - ns->ns_addrp[i] = inb(hpc - 0x10 + i); - ns->hp_type = inb(hpc - 0x10 + 7); - - if (ns->ns_addrp[0] != 0x08 || - ns->ns_addrp[1] != 0x00 || - ns->ns_addrp[2] != 0x09) { - splx(s); - return 0; - } - /* Word Transfers, Burst Mode Select, Fifo at 8 bytes */ - /* On this board, WTS means 32-bit transfers, which is still - * experimental. - mycroft, 18JAN93 */ -#ifdef HP_32BIT - ns->ns_mode = DSDC_WTS | DSDC_BMS | DSDC_FT1; -#else - ns->ns_mode = DSDC_BMS | DSDC_FT1; -#endif - ns->ns_txstart = 0 * 1024 / DS_PGSIZE; - ns->ns_rxend = 32 * 1024 / DS_PGSIZE; - - ns->ns_rxstart = ns->ns_txstart + (PKTSZ / DS_PGSIZE); - - outb(hpc + hp_option, HP_RUN); - -#if 0 - outb(hpc + ds0_isr, 0xff); - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_STOP); - delay(1000); - - /* Check cmd reg and fail if not right */ - if ((i = inb(hpc + ds_cmd)) != (DSCM_NODMA | DSCM_PG0 | DSCM_STOP)) { - splx(s); - return (0); - } -#endif - - outb(hpc + hp_option, 0); - - splx(s); - return (32); -} -/* - * Fetch from onboard ROM/RAM - */ -hpfetch(ns, up, ad, len) - struct hp_softc *ns; - caddr_t up; -{ - u_char cmd; - register hpc = ns->ns_port; - int counter = 100000; - - outb(hpc + hp_option, inb(hpc + hp_option) | HP_DATA); - - cmd = inb(hpc + ds_cmd); - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START); - - /* Setup remote dma */ - outb(hpc + ds0_isr, DSIS_RDC); - - if (ns->ns_mode & DSDC_WTS) - len = (len + 3) & ~3; - else - len = (len + 1) & ~1; - - outb(hpc + ds0_rbcr0, len); - outb(hpc + ds0_rbcr1, len >> 8); - outb(hpc + ds0_rsar0, ad); - outb(hpc + ds0_rsar1, ad >> 8); - -#ifdef HP_DEBUG - printf("hpfetch: len=%d ioaddr=0x%03x addr=0x%04x option=0x%02x %d-bit\n", - len, hpc + hp_data, ad, inb(hpc + hp_option), - ns->ns_mode & DSDC_WTS ? 32 : 16); - printf("hpfetch: cmd=0x%02x isr=0x%02x ", - inb(hpc + ds_cmd), inb(hpc + ds0_isr)); - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG2 | DSCM_START); - printf("imr=0x%02x rcr=0x%02x tcr=0x%02x dcr=0x%02x\n", - inb(hpc + ds0_imr), inb(hpc + ds0_rcr), inb(hpc + ds0_tcr), - inb(hpc + ds0_dcr)); -#endif - - /* Execute & extract from card */ - outb(hpc + ds_cmd, DSCM_RREAD | DSCM_PG0 | DSCM_START); - -#ifdef HP_32BIT - if (ns->ns_mode & DSDC_WTS) - len = (caddr_t) insd(hpc + hp_data, up, len >> 2) - up; - else -#endif - len = (caddr_t) insw(hpc + hp_data, up, len >> 1) - up; - -#ifdef HP_DEBUG - printf("hpfetch: done len=%d\n", len); -#endif - - /* Wait till done, then shutdown feature */ - while ((inb(hpc + ds0_isr) & DSIS_RDC) == 0 && counter-- > 0); - outb(hpc + ds0_isr, DSIS_RDC); - outb(hpc + ds_cmd, cmd); - - outb(hpc + hp_option, inb(hpc + hp_option) & ~HP_DATA); -} -/* - * Put to onboard RAM - */ -hpput(ns, up, ad, len) - struct hp_softc *ns; - caddr_t up; -{ - u_char cmd; - register hpc = ns->ns_port; - int counter = 100000; - - outb(hpc + hp_option, inb(hpc + hp_option) | HP_DATA); - - cmd = inb(hpc + ds_cmd); - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START); - - /* Setup for remote dma */ - outb(hpc + ds0_isr, DSIS_RDC); - - if (ns->ns_mode & DSDC_WTS) - len = (len + 3) & ~3; - else - len = (len + 1) & ~1; - -#ifdef HP_DEBUG - printf("hpput: len=%d ioaddr=0x%03x addr=0x%04x option=0x%02x %d-bit\n", - len, hpc + hp_data, ad, inb(hpc + hp_option), - ns->ns_mode & DSDC_WTS ? 32 : 16); - printf("hpput: cmd=0x%02x isr=0x%02x ", - inb(hpc + ds_cmd), inb(hpc + ds0_isr)); - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG2 | DSCM_START); - printf("imr=0x%02x rcr=0x%02x tcr=0x%02x dcr=0x%02x\n", - inb(hpc + ds0_imr), inb(hpc + ds0_rcr), inb(hpc + ds0_tcr), - inb(hpc + ds0_dcr)); - { - unsigned char *p = (unsigned char *) up; - int n = len; - printf("hpput:"); - while (n--) - printf(" %02x", *(p++)); - printf("\n"); - } -#endif - - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START); - outb(hpc + ds0_rbcr0, 0xff); - outb(hpc + ds_cmd, DSCM_RREAD | DSCM_PG0 | DSCM_START); - - outb(hpc + ds0_rbcr0, len); - outb(hpc + ds0_rbcr1, len >> 8); - outb(hpc + ds0_rsar0, ad); - outb(hpc + ds0_rsar1, ad >> 8); - - /* Execute & stuff to card */ - outb(hpc + ds_cmd, DSCM_RWRITE | DSCM_PG0 | DSCM_START); - -#ifdef HP_32BIT - if (ns->ns_mode & DSDC_WTS) - len = (caddr_t) outsd(hpc + hp_data, up, len >> 2) - up; - else -#endif - len = (caddr_t) outsw(hpc + hp_data, up, len >> 1) - up; - -#ifdef HP_DEBUG - printf("hpput: done len=%d\n", len); -#endif - - /* Wait till done, then shutdown feature */ - while ((inb(hpc + ds0_isr) & DSIS_RDC) == 0 && counter-- > 0); - outb(hpc + ds0_isr, DSIS_RDC); - outb(hpc + ds_cmd, cmd); - - outb(hpc + hp_option, inb(hpc + hp_option) & ~HP_DATA); -} -/* - * Reset of interface. - */ -hpreset(unit, uban) - int unit, uban; -{ - register struct hp_softc *ns = &hp_softc[unit]; - register hpc = ns->ns_port; - if (unit >= NHP) - return; - printf("hp%d: reset\n", unit); - outb(hpc + hp_option, 0); - ns->ns_flags &= ~DSF_LOCK; - hpinit(unit); -} - -static char * -hp_id(type) - u_char type; -{ - static struct { - u_char type; - char *name; - } boards[] = { - { - 0x00, "hp27240" - }, { - 0x10, "hp24240" - }, { - 0x01, "hp27245" - }, { - 0x02, "hp27250" - }, { - 0x81, "hp27247" - }, { - 0x91, "hp27247r1" - } - }; - int n = sizeof(boards) / sizeof(boards[0]); - - while (n) - if (boards[--n].type == type) - return boards[n].name; - - return "UNKNOWN"; -} -/* - * Interface exists: make available by filling in network interface - * record. System will initialize the interface when it is ready - * to accept packets. We get the ethernet address here. - */ -hpattach(dvp) - struct isa_device *dvp; -{ - int unit = dvp->id_unit; - register struct hp_softc *ns = &hp_softc[unit]; - register struct ifnet *ifp = &ns->ns_if; - - ifp->if_unit = unit; - ifp->if_name = hpdriver.name; - ifp->if_mtu = ETHERMTU; - printf("hp%d: %s %d-bit ethernet address %s\n", unit, - hp_id(ns->hp_type), ns->ns_mode & DSDC_WTS ? 32 : 16, - ether_sprintf(ns->ns_addrp)); - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; - ifp->if_output = ether_output; - ifp->if_start = hpstart; - ifp->if_ioctl = hpioctl; - ifp->if_reset = hpreset; - ifp->if_watchdog = 0; - if_attach(ifp); - -#if NBPFILTER > 0 - bpfattach(&ns->ns_bpf, ifp, DLT_EN10MB, - sizeof(struct ether_header)); -#endif -} -/* - * Initialization of interface; set up initialization block - * and transmit/receive descriptor rings. - */ -hpinit(unit) - int unit; -{ - register struct hp_softc *ns = &hp_softc[unit]; - struct ifnet *ifp = &ns->ns_if; - int s; - int i; - char *cp; - register hpc = ns->ns_port; - - if (ifp->if_addrlist == (struct ifaddr *) 0) - return; - if (ifp->if_flags & IFF_RUNNING) - return; - - s = splimp(); - -#ifdef HP_DEBUG - printf("hpinit: hp%d at 0x%x irq %d\n", unit, hpc, (int) ns->hp_irq); - printf("hpinit: promiscuous mode %s\n", - ns->ns_if.if_flags & IFF_PROMISC ? "on" : "off"); -#endif - - ns->ns_rcr = (ns->ns_if.if_flags & IFF_BROADCAST ? DSRC_AB : 0) | - (ns->ns_if.if_flags & IFF_PROMISC ? DSRC_PRO : 0); -#ifdef HP_LOG_ERRORS - ns->ns_rcr |= DSRC_SEP; -#endif - - /* set irq and turn on board */ - outb(hpc + hp_option, HP_RUN | (ns->hp_irq << 1)); - - /* init regs */ - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_STOP); - outb(hpc + ds0_dcr, 0); - outb(hpc + ds0_rbcr0, 0); - outb(hpc + ds0_rbcr1, 0); - outb(hpc + ds0_rcr, DSRC_MON); - outb(hpc + ds0_tpsr, ns->ns_txstart); - outb(hpc + ds0_imr, 0); - outb(hpc + ds0_tcr, DSTC_LB0); - outb(hpc + ds0_pstart, ns->ns_rxstart); - outb(hpc + ds0_bnry, ns->ns_rxend - 1); - outb(hpc + ds0_pstop, ns->ns_rxend); - outb(hpc + ds0_isr, 0xff); - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG1 | DSCM_STOP); - outb(hpc + ds1_curr, ns->ns_rxstart); - - /* set physical address on ethernet */ - for (i = 0; i < 6; i++) - outb(hpc + ds1_par0 + i, ns->ns_addrp[i]); - - /* clr logical address hash filter for now */ - for (i = 0; i < 8; i++) - outb(hpc + ds1_mar0 + i, 0xff); - - /* fire it up */ - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START); - outb(hpc + ds0_dcr, ns->ns_mode); - outb(hpc + ds0_rcr, ns->ns_rcr); - outb(hpc + ds0_tcr, 0); - outb(hpc + ds0_imr, 0xff); - - ns->ns_if.if_flags |= IFF_RUNNING; - ns->ns_flags &= ~DSF_LOCK; - ns->ns_oactive = 0; - ns->ns_mask = ~0; - hpstart(ifp); - -#ifdef HP_DEBUG - printf("hpinit: done\n", unit, hpc); -#endif - - splx(s); -} -/* - * Setup output on interface. - * Get another datagram to send off of the interface queue, - * and map it to the interface before starting the output. - * called only at splimp or interrupt level. - */ -hpstart(ifp) - struct ifnet *ifp; -{ - register struct hp_softc *ns = &hp_softc[ifp->if_unit]; - struct mbuf *m0, *m; - int buffer; - int len, i, total; - register hpc = ns->ns_port; - - /* - * The DS8390 has only one transmit buffer, if it is busy we - * must wait until the transmit interrupt completes. - */ - if (ns->ns_flags & DSF_LOCK) - return; - - if (inb(hpc + ds_cmd) & DSCM_TRANS) - return; - - if ((ns->ns_if.if_flags & IFF_RUNNING) == 0) - return; - - IF_DEQUEUE(&ns->ns_if.if_snd, m); - - if (m == 0) - return; - - /* - * Copy the mbuf chain into the transmit buffer - */ - - ns->ns_flags |= DSF_LOCK; /* prevent entering hpstart */ - buffer = ns->ns_txstart * DS_PGSIZE; - i = 0; - total = len = m->m_pkthdr.len; - -#ifdef HP_DEBUG - printf("hpstart: len=%d\n", len); -#endif - -#if NBPFILTER > 0 - if (ns->ns_bpf) - bpf_mtap(ns->ns_bpf, m); -#endif - - for (m0 = m; m != 0;) { - if (m->m_len & 1 && t > m->m_len) { - m->m_len -= 1; - hpput(ns, mtod(m, caddr_t), buffer, m->m_len); - t -= m->m_len; - buffer += m->m_len; - m->m_data += m->m_len; - m->m_len = 1; - m = m_pullup(m, 2); - } else { - hpput(ns, mtod(m, caddr_t), buffer, m->m_len); - t -= m->m_len; - buffer += m->m_len; - MFREE(m, m0); - m = m0; - } - } - - /* - * Init transmit length registers, and set transmit start flag. - */ - len = total; - if (len < ETHER_MIN_LEN) - len = ETHER_MIN_LEN; - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START); - outb(hpc + ds0_tbcr0, len & 0xff); - outb(hpc + ds0_tbcr1, (len >> 8) & 0xff); - outb(hpc + ds0_tpsr, ns->ns_txstart); - outb(hpc + ds_cmd, DSCM_TRANS | DSCM_NODMA | DSCM_PG0 | DSCM_START); - -#ifdef HP_DEBUG - printf("hpstart: done\n", hpc); -#endif -} -/* - * Controller interrupt. - */ -hpintr(unit) -{ - register struct hp_softc *ns = &hp_softc[unit]; - u_char cmd, isr; - register hpc = ns->ns_port; - u_char err; - - /* Save cmd, clear interrupt */ - cmd = inb(hpc + ds_cmd); -loop: - isr = inb(hpc + ds0_isr); - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START); - outb(hpc + ds0_isr, isr); - - /* Receiver error */ - if (isr & DSIS_RXE) { - /* need to read these registers to clear status */ - err = inb(hpc + ds0_rsr); - (void) inb(hpc + 0xD); - (void) inb(hpc + 0xE); - (void) inb(hpc + 0xF); - ns->ns_if.if_ierrors++; -#ifdef HP_LOG_ERRORS - isr |= DSIS_RX; -#endif - } - /* We received something */ - if (isr & DSIS_RX) { - u_char bnry; - u_char curr; - u_short addr; - int len; - int i; - unsigned char c; - - while (1) { - outb(hpc + ds_cmd, DSCM_START | DSCM_NODMA | DSCM_PG0); - bnry = inb(hpc + ds0_bnry); - outb(hpc + ds_cmd, DSCM_START | DSCM_NODMA | DSCM_PG1); - curr = inb(hpc + ds1_curr); - -#ifdef HP_DEBUG - printf("hpintr: receive isr=0x%02x bnry=0x%02x curr=0x%02x\n", - isr, bnry, curr); -#endif - - if (++bnry >= ns->ns_rxend) - bnry = ns->ns_rxstart; - - /* if ring empty, done! */ - if (bnry == curr) - break; - - addr = bnry * DS_PGSIZE; - - outb(hpc + hp_option, inb(hpc + hp_option) | HP_DATA); - -#if 0 - /* send packet with auto packet release */ - outb(hpc + ds_cmd, DSCM_START | DSCM_NODMA | DSCM_PG0); - outb(hpc + ds0_rbcr1, 0x0f); - outb(hpc + ds0_dcr, ns->ns_mode | DSDC_AR); - outb(hpc + ds_cmd, DSCM_SENDP | DSCM_PG0 | DSCM_START); -#endif - - /* get length */ - hpfetch(ns, (caddr_t) & ns->ns_ph, addr, sizeof ns->ns_ph); - addr += sizeof ns->ns_ph; - -#ifdef HP_DEBUG - printf("hpintr: sendp packet hdr: %x %x %x %x\n", - ns->ns_ph.pr_status, - ns->ns_ph.pr_nxtpg, - ns->ns_ph.pr_sz0, - ns->ns_ph.pr_sz1); -#endif - -#ifdef HP_LOG_ERRORS - if (ns->ns_ph.pr_status & (DSRS_CRC | DSRS_FO | DSRS_DFR)) { - /* Get packet header */ - if (len > 14) - len = 14; - hpfetch(ns, (caddr_t) (ns->ns_pb), addr, len); - - /* move boundary up */ - bnry = ns->ns_ph.pr_nxtpg; - if (--bnry < ns->ns_rxstart) - bnry = ns->ns_rxend - 1; - outb(hpc + ds_cmd, DSCM_START | DSCM_NODMA | DSCM_PG0); - outb(hpc + ds0_bnry, bnry); - - printf("hp%d: receive error status=0x%02x\n", unit, - ns->ns_ph.pr_status); - printf("hp%d: packet header:", unit); - { - int n; - for (n = 0; n < len; n++) - printf(" %02x", ns->ns_pb[n]); - } - printf("\n"); - - continue; - } -#endif - - ns->ns_if.if_ipackets++; - len = ns->ns_ph.pr_sz0 + (ns->ns_ph.pr_sz1 << 8); - if (len < ETHER_MIN_LEN || len > ETHER_MAX_LEN) { - printf("hpintr: bnry %x curr %x\n", bnry, curr); - printf("hpintr: packet hdr: %x %x %x %x\n", - ns->ns_ph.pr_status, - ns->ns_ph.pr_nxtpg, - ns->ns_ph.pr_sz0, - ns->ns_ph.pr_sz1); - printf("isr = 0x%x reg_isr=0x%x\n", - isr, inb(hpc + ds0_isr)); - outb(hpc + ds_cmd, DSCM_START | DSCM_NODMA | DSCM_PG0); - bnry = inb(hpc + ds0_bnry); - outb(hpc + ds_cmd, DSCM_START | DSCM_NODMA | DSCM_PG1); - curr = inb(hpc + ds1_curr); - printf("hpintr: new bnry %x curr %x\n", bnry, curr); - printf("hpintr: bad len %d\n-hanging-\n", - len); - while (1); - } - /* read packet */ - hpfetch(ns, (caddr_t) (ns->ns_pb), addr, len); - - /* move boundary up */ - bnry = ns->ns_ph.pr_nxtpg; - if (--bnry < ns->ns_rxstart) - bnry = ns->ns_rxend - 1; - outb(hpc + ds_cmd, DSCM_START | DSCM_NODMA | DSCM_PG0); - outb(hpc + ds0_bnry, bnry); - -#ifdef HP_DEBUG - printf("hpintr: receive done bnry=0x%02x\n", bnry); -#endif - - outb(hpc + hp_option, inb(hpc + hp_option) & ~HP_DATA); - - /* adjust for ether header and checksum */ - len -= sizeof(struct ether_header) + sizeof(long); - - /* process packet */ - hpread(ns, (caddr_t) (ns->ns_pb), len); - } - } - /* Transmit error */ - if (isr & DSIS_TXE) { - ns->ns_flags &= ~DSF_LOCK; - /* Need to read these registers to clear status */ - ns->ns_if.if_collisions += inb(hpc + ds0_tbcr0); - ns->ns_if.if_oerrors++; - } - /* Packet Transmitted */ - if (isr & DSIS_TX) { - ns->ns_flags &= ~DSF_LOCK; - ++ns->ns_if.if_opackets; - ns->ns_if.if_collisions += inb(hpc + ds0_tbcr0); - } - /* Receiver ovverun? */ - if (isr & DSIS_ROVRN) { - log(LOG_ERR, "hp%d: error: isr %x\n", ns - hp_softc, isr - /* , DSIS_BITS */ ); - outb(hpc + ds0_rbcr0, 0); - outb(hpc + ds0_rbcr1, 0); - outb(hpc + ds0_tcr, DSTC_LB0); - outb(hpc + ds0_rcr, DSRC_MON); - outb(hpc + ds_cmd, DSCM_START | DSCM_NODMA); - outb(hpc + ds0_rcr, ns->ns_rcr); - outb(hpc + ds0_tcr, 0); - } - /* Any more to send? */ - outb(hpc + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START); - hpstart(&ns->ns_if); - outb(hpc + ds_cmd, cmd); - outb(hpc + ds0_imr, 0xff); - - /* Still more to do? */ - isr = inb(hpc + ds0_isr); - if (isr) - goto loop; -} -/* - * Pass a packet to the higher levels. - * We deal with the trailer protocol here. - */ -hpread(ns, buf, len) - register struct hp_softc *ns; - char *buf; - int len; -{ - register struct ether_header *eh; - struct mbuf *m; - int off, resid; - register struct ifqueue *inq; - u_short etype; - - /* - * Deal with trailer protocol: if type is trailer type - * get true type from first 16-bit word past data. - * Remember that type was trailer by setting off. - */ - eh = (struct ether_header *) buf; - etype = ntohs((u_short) eh->ether_type); -#define hpdataaddr(eh, off, type) ((type)(((caddr_t)((eh)+1)+(off)))) - if (etype >= ETHERTYPE_TRAIL && - etype < ETHERTYPE_TRAIL + ETHERTYPE_NTRAILER) { - off = (etype - ETHERTYPE_TRAIL) * 512; - if (off >= ETHERMTU) - return; /* sanity */ - eh->ether_type = *hpdataaddr(eh, off, u_short *); - resid = ntohs(*(hpdataaddr(eh, off + 2, u_short *))); - if (off + resid > len) - return; /* sanity */ - len = off + resid; - } else - off = 0; - - if (len == 0) - return; - -#if NBPFILTER > 0 - if (ns->ns_bpf) - bpf_tap(ns->ns_bpf, buf, len + sizeof(struct ether_header)); -#endif - - if ((ns->ns_if.if_flags & IFF_PROMISC) - && bcmp(eh->ether_dhost, ns->ns_addrp, - sizeof(eh->ether_dhost)) != 0 - && bcmp(eh->ether_dhost, etherbroadcastaddr, - sizeof(eh->ether_dhost)) != 0) - return; - - /* - * Pull packet off interface. Off is nonzero if packet - * has trailing header; hpget will then force this header - * information to be at the front, but we still have to drop - * the type and length which are at the front of any trailer data. - */ - m = hpget(buf, len, off, &ns->ns_if); - if (m == 0) - return; - - ether_input(&ns->ns_if, eh, m); -} -/* - * Supporting routines - */ - -/* - * Pull read data off a interface. - * Len is length of data, with local net header stripped. - * Off is non-zero if a trailer protocol was used, and - * gives the offset of the trailer information. - * We copy the trailer information and then all the normal - * data into mbufs. When full cluster sized units are present - * we copy into clusters. - */ -struct mbuf * -hpget(buf, totlen, off0, ifp) - caddr_t buf; - int totlen, off0; - struct ifnet *ifp; -{ - struct mbuf *top, **mp, *m, *p; - int off = off0, len; - register caddr_t cp = buf; - char *epkt; - - buf += sizeof(struct ether_header); - cp = buf; - epkt = cp + totlen; - - - if (off) { - cp += off + 2 * sizeof(u_short); - totlen -= 2 * sizeof(u_short); - } - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return (0); - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = totlen; - m->m_len = MHLEN; - - top = 0; - mp = ⊤ - while (totlen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - m_freem(top); - return (0); - } - m->m_len = MLEN; - } - len = min(totlen, epkt - cp); - if (len >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - m->m_len = len = min(len, MCLBYTES); - else - len = m->m_len; - } else { - /* - * Place initial small packet/header at end of mbuf. - */ - if (len < m->m_len) { - if (top == 0 && len + max_linkhdr <= m->m_len) - m->m_data += max_linkhdr; - m->m_len = len; - } else - len = m->m_len; - } - bcopy(cp, mtod(m, caddr_t), (unsigned) len); - cp += len; - *mp = m; - mp = &m->m_next; - totlen -= len; - if (cp == epkt) - cp = buf; - } - return (top); -} -/* - * Process an ioctl request. - */ -hpioctl(ifp, cmd, data) - register struct ifnet *ifp; - u_long cmd; - caddr_t data; -{ - register struct ifaddr *ifa = (struct ifaddr *) data; - struct hp_softc *ns = &hp_softc[ifp->if_unit]; - struct ifreq *ifr = (struct ifreq *) data; - int s = splimp(), error = 0; - - - switch (cmd) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - hpinit(ifp->if_unit); /* before arpwhohas */ - ((struct arpcom *) ifp)->ac_ipaddr = - IA_SIN(ifa)->sin_addr; - arpwhohas((struct arpcom *) ifp, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - case AF_NS: - { - register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); - - if (ns_nullhost(*ina)) - ina->x_host = *(union ns_host *) (ns->ns_addrp); - else { - /* - * The manual says we can't change the address - * while the receiver is armed, - * so reset everything - */ - ifp->if_flags &= ~IFF_RUNNING; - bcopy((caddr_t) ina->x_host.c_host, - (caddr_t) ns->ns_addrp, sizeof(ns->ns_addrp)); - } - hpinit(ifp->if_unit); /* does hp_setaddr() */ - break; - } -#endif - default: - hpinit(ifp->if_unit); - break; - } - break; - - case SIOCSIFFLAGS: -#ifdef HP_DEBUG - printf("hp: setting flags, up: %s, running: %s\n", - ifp->if_flags & IFF_UP ? "yes" : "no", - ifp->if_flags & IFF_RUNNING ? "yes" : "no"); -#endif - if ((ifp->if_flags & IFF_UP) == 0 && - ifp->if_flags & IFF_RUNNING) { - ifp->if_flags &= ~IFF_RUNNING; - outb(ns->ns_port + ds_cmd, DSCM_STOP | DSCM_NODMA); - } else - if (ifp->if_flags & IFF_UP && - (ifp->if_flags & IFF_RUNNING) == 0) - hpinit(ifp->if_unit); - break; - -#ifdef notdef - case SIOCGHWADDR: - bcopy((caddr_t) ns->ns_addrp, (caddr_t) & ifr->ifr_data, - sizeof(ns->ns_addrp)); - break; -#endif - - default: - error = EINVAL; - } - splx(s); - return (error); -} -#endif diff --git a/sys/arch/i386/isa/if_ie.c b/sys/arch/i386/isa/if_ie.c deleted file mode 100644 index dc8dcb8341d3..000000000000 --- a/sys/arch/i386/isa/if_ie.c +++ /dev/null @@ -1,1958 +0,0 @@ -/* $NetBSD: if_ie.c,v 1.31 1995/01/29 02:58:28 cgd Exp $ */ - -/*- - * Copyright (c) 1993, 1994, 1995 Charles Hannum. - * Copyright (c) 1992, 1993, University of Vermont and State - * Agricultural College. - * Copyright (c) 1992, 1993, Garrett A. Wollman. - * - * Portions: - * Copyright (c) 1994, 1995, Rafal K. Boni - * Copyright (c) 1990, 1991, William F. Jolitz - * Copyright (c) 1990, The Regents of the University of California - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Charles Hannum, by the - * University of Vermont and State Agricultural College and Garrett A. - * Wollman, by William F. Jolitz, and by the University of California, - * Berkeley, Lawrence Berkeley Laboratory, and its contributors. - * 4. Neither the names of the Universities nor the names of the authors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR AUTHORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Intel 82586 Ethernet chip - * Register, bit, and structure definitions. - * - * Original StarLAN driver written by Garrett Wollman with reference to the - * Clarkson Packet Driver code for this chip written by Russ Nelson and others. - * - * BPF support code taken from hpdev/if_le.c, supplied with tcpdump. - * - * 3C507 support is loosely based on code donated to NetBSD by Rafal Boni. - * - * Majorly cleaned up and 3C507 code merged by Charles Hannum. - */ - -/* - * The i82586 is a very versatile chip, found in many implementations. - * Programming this chip is mostly the same, but certain details differ - * from card to card. This driver is written so that different cards - * can be automatically detected at run-time. - */ - -/* -Mode of operation: - -We run the 82586 in a standard Ethernet mode. We keep NFRAMES received frame -descriptors around for the receiver to use, and NRXBUF associated receive -buffer descriptors, both in a circular list. Whenever a frame is received, we -rotate both lists as necessary. (The 586 treats both lists as a simple -queue.) We also keep a transmit command around so that packets can be sent -off quickly. - -We configure the adapter in AL-LOC = 1 mode, which means that the -Ethernet/802.3 MAC header is placed at the beginning of the receive buffer -rather than being split off into various fields in the RFD. This also means -that we must include this header in the transmit buffer as well. - -By convention, all transmit commands, and only transmit commands, shall have -the I (IE_CMD_INTR) bit set in the command. This way, when an interrupt -arrives at ieintr(), it is immediately possible to tell what precisely caused -it. ANY OTHER command-sending routines should run at splimp(), and should -post an acknowledgement to every interrupt they generate. - -The 82586 has a 24-bit address space internally, and the adaptor's memory is -located at the top of this region. However, the value we are given in -configuration is the CPU's idea of where the adaptor RAM is. So, we must go -through a few gyrations to come up with a kernel virtual address which -represents the actual beginning of the 586 address space. First, we autosize -the RAM by running through several possible sizes and trying to initialize the -adapter under the assumption that the selected size is correct. Then, knowing -the correct RAM size, we set up our pointers in the softc. `sc_maddr' -represents the computed base of the 586 address space. `iomembot' represents -the actual configured base of adapter RAM. Finally, `sc_msize' represents the -calculated size of 586 RAM. Then, when laying out commands, we use the -interval [sc_maddr, sc_maddr + sc_msize); to make 24-pointers, we subtract -iomem, and to make 16-pointers, we subtract sc_maddr and and with 0xffff. -*/ - -#include "bpfilter.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#if NBPFILTER > 0 -#include -#include -#endif - -#ifdef INET -#include -#include -#include -#include -#include -#endif - -#ifdef NS -#include -#include -#endif - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -static struct mbuf *last_not_for_us; - -#define IED_RINT 0x01 -#define IED_TINT 0x02 -#define IED_RNR 0x04 -#define IED_CNA 0x08 -#define IED_READFRAME 0x10 -#define IED_ALL 0x1f - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 - -/* -sizeof(iscp) == 1+1+2+4 == 8 -sizeof(scb) == 2+2+2+2+2+2+2+2 == 16 -NFRAMES * sizeof(rfd) == NFRAMES*(2+2+2+2+6+6+2+2) == NFRAMES*24 == 384 -sizeof(xmit_cmd) == 2+2+2+2+6+2 == 18 -sizeof(transmit buffer) == ETHER_MAX_LEN == 1518 -sizeof(transmit buffer desc) == 8 ------ -1952 - -NRXBUF * sizeof(rbd) == NRXBUF*(2+2+4+2+2) == NRXBUF*12 -NRXBUF * IE_RBUF_SIZE == NRXBUF*256 - -NRXBUF should be (16384 - 1952) / (256 + 12) == 14432 / 268 == 53 - -With NRXBUF == 48, this leaves us 1568 bytes for another command or -more buffers. Another transmit command would be 18+8+1518 == 1544 ----just barely fits! - -Obviously all these would have to be reduced for smaller memory sizes. -With a larger memory, it would be possible to roughly double the number of -both transmit and receive buffers. -*/ - -#define NFRAMES 16 /* number of receive frames */ -#define NRXBUF 48 /* number of buffers to allocate */ -#define IE_RBUF_SIZE 256 /* size of each receive buffer; - MUST BE POWER OF TWO */ -#define NTXBUF 2 /* number of transmit commands */ -#define IE_TBUF_SIZE ETHER_MAX_LEN /* length of transmit buffer */ - - -enum ie_hardware { - IE_STARLAN10, - IE_EN100, - IE_SLFIBER, - IE_3C507, - IE_UNKNOWN -}; - -const char *ie_hardware_names[] = { - "StarLAN 10", - "EN100", - "StarLAN Fiber", - "3C507", - "Unknown" -}; - -/* - * Ethernet status, per interface. - */ -struct ie_softc { - struct device sc_dev; - struct intrhand sc_ih; - - int sc_iobase; - caddr_t sc_maddr; - u_int sc_msize; - - struct arpcom sc_arpcom; - - void (*reset_586)(); - void (*chan_attn)(); - - enum ie_hardware hard_type; - int hard_vers; - - int want_mcsetup; - int promisc; - volatile struct ie_int_sys_conf_ptr *iscp; - volatile struct ie_sys_ctl_block *scb; - - int rfhead, rftail, rbhead, rbtail; - volatile struct ie_recv_frame_desc *rframes[NFRAMES]; - volatile struct ie_recv_buf_desc *rbuffs[NRXBUF]; - volatile char *cbuffs[NRXBUF]; - - int xmit_busy; - int xmit_free; - int xchead, xctail; - volatile struct ie_xmit_cmd *xmit_cmds[NTXBUF]; - volatile struct ie_xmit_buf *xmit_buffs[NTXBUF]; - u_char *xmit_cbuffs[NTXBUF]; - - struct ie_en_addr mcast_addrs[MAXMCAST + 1]; - int mcast_count; - -#ifdef IEDEBUG - int sc_debug; -#endif -}; - -int iewatchdog __P((/* short */)); -int ieintr __P((struct ie_softc *)); -int ieinit __P((struct ie_softc *)); -int ieioctl __P((struct ifnet *, u_long, caddr_t)); -int iestart __P((struct ifnet *)); -static void el_reset_586 __P((struct ie_softc *)); -static void sl_reset_586 __P((struct ie_softc *)); -static void el_chan_attn __P((struct ie_softc *)); -static void sl_chan_attn __P((struct ie_softc *)); -void iereset __P((struct ie_softc *)); -static void ie_readframe __P((struct ie_softc *, int)); -static void ie_drop_packet_buffer __P((struct ie_softc *)); -static void slel_get_address __P((struct ie_softc *)); -static void find_ie_mem_size __P((struct ie_softc *)); -static int command_and_wait __P((struct ie_softc *, int, - void volatile *, int)); -/*static*/ void ierint __P((struct ie_softc *)); -/*static*/ void ietint __P((struct ie_softc *)); -static int ieget __P((struct ie_softc *, struct mbuf **, - struct ether_header *, int *)); -void iememinit __P((void *, struct ie_softc *)); -static int mc_setup __P((struct ie_softc *, void *)); -static void mc_reset __P((struct ie_softc *)); - -#ifdef IEDEBUG -void print_rbd __P((volatile struct ie_recv_buf_desc *)); - -int in_ierint = 0; -int in_ietint = 0; -#endif - -int ieprobe __P((struct device *, void *, void *)); -void ieattach __P((struct device *, struct device *, void *)); - -struct cfdriver iecd = { - NULL, "ie", ieprobe, ieattach, DV_IFNET, sizeof(struct ie_softc) -}; - -#define MK_24(base, ptr) ((caddr_t)((u_long)ptr - (u_long)base)) -#define MK_16(base, ptr) ((u_short)(u_long)MK_24(base, ptr)) - -#define PORT sc->sc_iobase -#define MEM sc->sc_maddr - -/* - * Here are a few useful functions. We could have done these as macros, but - * since we have the inline facility, it makes sense to use that instead. - */ -static inline void -ie_setup_config(cmd, promiscuous, manchester) - volatile struct ie_config_cmd *cmd; - int promiscuous, manchester; -{ - - cmd->ie_config_count = 0x0c; - cmd->ie_fifo = 8; - cmd->ie_save_bad = 0x40; - cmd->ie_addr_len = 0x2e; - cmd->ie_priority = 0; - cmd->ie_ifs = 0x60; - cmd->ie_slot_low = 0; - cmd->ie_slot_high = 0xf2; - cmd->ie_promisc = !!promiscuous | manchester << 2; - cmd->ie_crs_cdt = 0; - cmd->ie_min_len = 64; - cmd->ie_junk = 0xff; -} - -static inline void -ie_ack(sc, mask) - struct ie_softc *sc; - u_int mask; -{ - volatile struct ie_sys_ctl_block *scb = sc->scb; - - scb->ie_command = scb->ie_status & mask; - (sc->chan_attn)(sc); - - while (scb->ie_command) - ; /* Spin Lock */ -} - -int -ieprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct ie_softc *sc = match; - struct isa_attach_args *ia = aux; - - if (sl_probe(sc, ia)) - return 1; - if (el_probe(sc, ia)) - return 1; - return 0; -} - -int -sl_probe(sc, ia) - struct ie_softc *sc; - struct isa_attach_args *ia; -{ - u_char c; - - sc->sc_iobase = ia->ia_iobase; - - /* Need this for part of the probe. */ - sc->reset_586 = sl_reset_586; - sc->chan_attn = sl_chan_attn; - - c = inb(PORT + IEATT_REVISION); - switch (SL_BOARD(c)) { - case SL10_BOARD: - sc->hard_type = IE_STARLAN10; - break; - case EN100_BOARD: - sc->hard_type = IE_EN100; - break; - case SLFIBER_BOARD: - sc->hard_type = IE_SLFIBER; - break; - - default: - /* Anything else is not recognized or cannot be used. */ - printf("%s: unknown AT&T board type code %d\n", - sc->sc_dev.dv_xname, SL_BOARD(c)); - return 0; - } - - sc->hard_vers = SL_REV(c); - - if (ia->ia_irq == IRQUNK || ia->ia_maddr == MADDRUNK) { - printf("%s: %s does not have soft configuration\n", - sc->sc_dev.dv_xname, ie_hardware_names[sc->hard_type]); - return 0; - } - - /* - * Divine memory size on-board the card. Ususally 16k. - */ - sc->sc_maddr = ISA_HOLE_VADDR(ia->ia_maddr); - find_ie_mem_size(sc); - - if (!sc->sc_msize) { - printf("%s: can't find shared memory\n", sc->sc_dev.dv_xname); - return 0; - } - - if (!ia->ia_msize) - ia->ia_msize = sc->sc_msize; - else if (ia->ia_msize != sc->sc_msize) { - printf("%s: msize mismatch; kernel configured %d != board configured %d\n", - sc->sc_dev.dv_xname, ia->ia_msize, sc->sc_msize); - return 0; - } - - slel_get_address(sc); - - ia->ia_iosize = 16; - return 1; -} - -int -el_probe(sc, ia) - struct ie_softc *sc; - struct isa_attach_args *ia; -{ - u_char c; - int i; - u_char signature[] = "*3COM*"; - - sc->sc_iobase = ia->ia_iobase; - - /* Need this for part of the probe. */ - sc->reset_586 = el_reset_586; - sc->chan_attn = el_chan_attn; - - /* Reset and put card in CONFIG state without changing address. */ - elink_reset(); - elink_idseq(ELINK_507_POLY); - elink_idseq(ELINK_507_POLY); - outb(ELINK_ID_PORT, 0xff); - - /* Check for 3COM signature before proceeding. */ - outb(PORT + IE507_CTRL, inb(PORT + IE507_CTRL) & 0xfc); /* XXX */ - for (i = 0; i < 6; i++) - if (inb(PORT + i) != signature[i]) - return 0; - - c = inb(PORT + IE507_MADDR); - if (c & 0x20) { - printf("%s: can't map 3C507 RAM in high memory\n", - sc->sc_dev.dv_xname); - return 0; - } - - /* Go to RUN state. */ - outb(ELINK_ID_PORT, 0x00); - elink_idseq(ELINK_507_POLY); - outb(ELINK_ID_PORT, 0x00); - - /* Set bank 2 for version info and read BCD version byte. */ - outb(PORT + IE507_CTRL, EL_CTRL_NRST | EL_CTRL_BNK2); - i = inb(PORT + 3); - - sc->hard_type = IE_3C507; - sc->hard_vers = 10*(i / 16) + (i % 16) - 1; - - i = inb(PORT + IE507_IRQ) & 0x0f; - - if (ia->ia_irq != IRQUNK) { - if (ia->ia_irq != i) { - printf("%s: irq mismatch; kernel configured %d != board configured %d\n", - sc->sc_dev.dv_xname, ia->ia_irq, i); - return 0; - } - } else - ia->ia_irq = i; - - i = ((inb(PORT + IE507_MADDR) & 0x1c) << 12) + 0xc0000; - - if (ia->ia_maddr != MADDRUNK) { - if (ia->ia_maddr != i) { - printf("%s: maddr mismatch; kernel configured %x != board configured %x\n", - sc->sc_dev.dv_xname, ia->ia_maddr, i); - return 0; - } - } else - ia->ia_maddr = i; - - outb(PORT + IE507_CTRL, EL_CTRL_NORMAL); - - /* - * Divine memory size on-board the card. - */ - sc->sc_maddr = ISA_HOLE_VADDR(ia->ia_maddr); - find_ie_mem_size(sc); - - if (!sc->sc_msize) { - printf("%s: can't find shared memory\n", sc->sc_dev.dv_xname); - outb(PORT + IE507_CTRL, EL_CTRL_NRST); - return 0; - } - - if (!ia->ia_msize) - ia->ia_msize = sc->sc_msize; - else if (ia->ia_msize != sc->sc_msize) { - printf("%s: msize mismatch; kernel configured %d != board configured %d\n", - sc->sc_dev.dv_xname, ia->ia_msize, sc->sc_msize); - outb(PORT + IE507_CTRL, EL_CTRL_NRST); - return 0; - } - - slel_get_address(sc); - - /* Clear the interrupt latch just in case. */ - outb(PORT + IE507_ICTRL, 1); - - ia->ia_iosize = 16; - return 1; -} - -/* - * Taken almost exactly from Bill's if_is.c, then modified beyond recognition. - */ -void -ieattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct ie_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = iecd.cd_name; - ifp->if_output = ether_output; - ifp->if_start = iestart; - ifp->if_ioctl = ieioctl; - ifp->if_watchdog = iewatchdog; - ifp->if_flags = - IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - - /* Attach the interface. */ - if_attach(ifp); - ether_ifattach(ifp); - - printf(": address %s, type %s R%d\n", - ether_sprintf(sc->sc_arpcom.ac_enaddr), - ie_hardware_names[sc->hard_type], sc->hard_vers + 1); - -#if NBPFILTER > 0 - bpfattach(&sc->sc_arpcom.ac_if.if_bpf, ifp, DLT_EN10MB, - sizeof(struct ether_header)); -#endif - - sc->sc_ih.ih_fun = ieintr; - sc->sc_ih.ih_arg = sc; - sc->sc_ih.ih_level = IPL_NET; - intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih); -} - -/* - * Device timeout/watchdog routine. Entered if the device neglects to generate - * an interrupt after a transmit has been started on it. - */ -int -iewatchdog(unit) - short unit; -{ - struct ie_softc *sc = iecd.cd_devs[unit]; - - log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); - ++sc->sc_arpcom.ac_if.if_oerrors; - - iereset(sc); -} - -/* - * What to do upon receipt of an interrupt. - */ -int -ieintr(sc) - struct ie_softc *sc; -{ - register u_short status; - - status = sc->scb->ie_status; - - if ((status & IE_ST_WHENCE) == 0) { - /* Clear the interrupt latch on the 3C507. */ - if (sc->hard_type == IE_3C507 && - (inb(PORT + IE507_CTRL) & EL_CTRL_INTL)) - outb(PORT + IE507_ICTRL, 1); - return 0; - } - -loop: - /* Ack interrupts FIRST in case we receive more during the ISR. */ - ie_ack(sc, IE_ST_WHENCE & status); - - if (status & (IE_ST_RECV | IE_ST_RNR)) { -#ifdef IEDEBUG - in_ierint++; - if (sc->sc_debug & IED_RINT) - printf("%s: rint\n", sc->sc_dev.dv_xname); -#endif - ierint(sc); -#ifdef IEDEBUG - in_ierint--; -#endif - } - - if (status & IE_ST_DONE) { -#ifdef IEDEBUG - in_ietint++; - if (sc->sc_debug & IED_TINT) - printf("%s: tint\n", sc->sc_dev.dv_xname); -#endif - ietint(sc); -#ifdef IEDEBUG - in_ietint--; -#endif - } - - if (status & IE_ST_RNR) { - printf("%s: receiver not ready\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_ierrors++; - iereset(sc); - } - -#ifdef IEDEBUG - if ((status & IE_ST_ALLDONE) && (sc->sc_debug & IED_CNA)) - printf("%s: cna\n", sc->sc_dev.dv_xname); -#endif - - if ((status = sc->scb->ie_status) & IE_ST_WHENCE) - goto loop; - - /* Clear the interrupt latch on the 3C507. */ - if (sc->hard_type == IE_3C507) - outb(PORT + IE507_ICTRL, 1); - - return 1; -} - -/* - * Process a received-frame interrupt. - */ -void -ierint(sc) - struct ie_softc *sc; -{ - volatile struct ie_sys_ctl_block *scb = sc->scb; - int i, status; - static int timesthru = 1024; - - i = sc->rfhead; - for (;;) { - status = sc->rframes[i]->ie_fd_status; - - if ((status & IE_FD_COMPLETE) && (status & IE_FD_OK)) { - sc->sc_arpcom.ac_if.if_ipackets++; - if (!--timesthru) { - sc->sc_arpcom.ac_if.if_ierrors += - scb->ie_err_crc + scb->ie_err_align + - scb->ie_err_resource + scb->ie_err_overrun; - scb->ie_err_crc = scb->ie_err_align = - scb->ie_err_resource = scb->ie_err_overrun = - 0; - timesthru = 1024; - } - ie_readframe(sc, i); - } else { - if ((status & IE_FD_RNR) != 0 && - (scb->ie_status & IE_RU_READY) == 0) { - sc->rframes[0]->ie_fd_buf_desc = - MK_16(MEM, sc->rbuffs[0]); - scb->ie_recv_list = MK_16(MEM, sc->rframes[0]); - command_and_wait(sc, IE_RU_START, 0, 0); - } - break; - } - i = (i + 1) % NFRAMES; - } -} - -/* - * Process a command-complete interrupt. These are only generated by the - * transmission of frames. This routine is deceptively simple, since most of - * the real work is done by iestart(). - */ -void -ietint(sc) - struct ie_softc *sc; -{ - int status; - - sc->sc_arpcom.ac_if.if_timer = 0; - sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - - status = sc->xmit_cmds[sc->xctail]->ie_xmit_status; - - if (!(status & IE_STAT_COMPL) || (status & IE_STAT_BUSY)) - printf("ietint: command still busy!\n"); - - if (status & IE_STAT_OK) { - sc->sc_arpcom.ac_if.if_opackets++; - sc->sc_arpcom.ac_if.if_collisions += status & IE_XS_MAXCOLL; - } else if (status & IE_STAT_ABORT) { - printf("%s: send aborted\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_oerrors++; - } else if (status & IE_XS_NOCARRIER) { - printf("%s: no carrier\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_oerrors++; - } else if (status & IE_XS_LOSTCTS) { - printf("%s: lost CTS\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_oerrors++; - } else if (status & IE_XS_UNDERRUN) { - printf("%s: DMA underrun\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_oerrors++; - } else if (status & IE_XS_EXCMAX) { - printf("%s: too many collisions\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_collisions += 16; - sc->sc_arpcom.ac_if.if_oerrors++; - } - - /* - * If multicast addresses were added or deleted while transmitting, - * mc_reset() set the want_mcsetup flag indicating that we should do - * it. - */ - if (sc->want_mcsetup) { - mc_setup(sc, (caddr_t)sc->xmit_cbuffs[sc->xctail]); - sc->want_mcsetup = 0; - } - - /* Done with the buffer. */ - sc->xmit_free++; - sc->xmit_busy = 0; - sc->xctail = (sc->xctail + 1) % NTXBUF; - - iestart(&sc->sc_arpcom.ac_if); -} - -/* - * Compare two Ether/802 addresses for equality, inlined and unrolled for - * speed. I'd love to have an inline assembler version of this... - */ -static inline int -ether_equal(one, two) - u_char *one, *two; -{ - - if (one[0] != two[0] || one[1] != two[1] || one[2] != two[2] || - one[3] != two[3] || one[4] != two[4] || one[5] != two[5]) - return 0; - return 1; -} - -/* - * Check for a valid address. to_bpf is filled in with one of the following: - * 0 -> BPF doesn't get this packet - * 1 -> BPF does get this packet - * 2 -> BPF does get this packet, but we don't - * Return value is true if the packet is for us, and false otherwise. - * - * This routine is a mess, but it's also critical that it be as fast - * as possible. It could be made cleaner if we can assume that the - * only client which will fiddle with IFF_PROMISC is BPF. This is - * probably a good assumption, but we do not make it here. (Yet.) - */ -static inline int -check_eh(sc, eh, to_bpf) - struct ie_softc *sc; - struct ether_header *eh; - int *to_bpf; -{ - int i; - - switch(sc->promisc) { - case IFF_ALLMULTI: - /* - * Receiving all multicasts, but no unicasts except those - * destined for us. - */ -#if NBPFILTER > 0 - *to_bpf = (sc->sc_arpcom.ac_if.if_bpf != 0); /* BPF gets this packet if anybody cares */ -#endif - if (eh->ether_dhost[0] & 1) - return 1; - if (ether_equal(eh->ether_dhost, sc->sc_arpcom.ac_enaddr)) return 1; - return 0; - - case IFF_PROMISC: - /* - * Receiving all packets. These need to be passed on to BPF. - */ -#if NBPFILTER > 0 - *to_bpf = (sc->sc_arpcom.ac_if.if_bpf != 0); -#endif - /* If for us, accept and hand up to BPF */ - if (ether_equal(eh->ether_dhost, sc->sc_arpcom.ac_enaddr)) return 1; - -#if NBPFILTER > 0 - if (*to_bpf) - *to_bpf = 2; /* we don't need to see it */ -#endif - - /* - * Not a multicast, so BPF wants to see it but we don't. - */ - if (!(eh->ether_dhost[0] & 1)) - return 1; - - /* - * If it's one of our multicast groups, accept it and pass it - * up. - */ - for (i = 0; i < sc->mcast_count; i++) { - if (ether_equal(eh->ether_dhost, (u_char *)&sc->mcast_addrs[i])) { -#if NBPFILTER > 0 - if (*to_bpf) - *to_bpf = 1; -#endif - return 1; - } - } - return 1; - - case IFF_ALLMULTI | IFF_PROMISC: - /* - * Acting as a multicast router, and BPF running at the same - * time. Whew! (Hope this is a fast machine...) - */ -#if NBPFILTER > 0 - *to_bpf = (sc->sc_arpcom.ac_if.if_bpf != 0); -#endif - /* We want to see multicasts. */ - if (eh->ether_dhost[0] & 1) - return 1; - - /* We want to see our own packets */ - if (ether_equal(eh->ether_dhost, sc->sc_arpcom.ac_enaddr)) - return 1; - - /* Anything else goes to BPF but nothing else. */ -#if NBPFILTER > 0 - if (*to_bpf) - *to_bpf = 2; -#endif - return 1; - - default: - /* - * Only accept unicast packets destined for us, or multicasts - * for groups that we belong to. For now, we assume that the - * '586 will only return packets that we asked it for. This - * isn't strictly true (it uses hashing for the multicast - * filter), but it will do in this case, and we want to get out - * of here as quickly as possible. - */ -#if NBPFILTER > 0 - *to_bpf = (sc->sc_arpcom.ac_if.if_bpf != 0); -#endif - return 1; - } - return 0; -} - -/* - * We want to isolate the bits that have meaning... This assumes that - * IE_RBUF_SIZE is an even power of two. If somehow the act_len exceeds - * the size of the buffer, then we are screwed anyway. - */ -static inline int -ie_buflen(sc, head) - struct ie_softc *sc; - int head; -{ - - return (sc->rbuffs[head]->ie_rbd_actual - & (IE_RBUF_SIZE | (IE_RBUF_SIZE - 1))); -} - -static inline int -ie_packet_len(sc) - struct ie_softc *sc; -{ - int i; - int head = sc->rbhead; - int acc = 0; - - do { - if (!(sc->rbuffs[sc->rbhead]->ie_rbd_actual & IE_RBD_USED)) { -#ifdef IEDEBUG - print_rbd(sc->rbuffs[sc->rbhead]); -#endif - log(LOG_ERR, "%s: receive descriptors out of sync at %d\n", - sc->sc_dev.dv_xname, sc->rbhead); - iereset(sc); - return -1; - } - - i = sc->rbuffs[head]->ie_rbd_actual & IE_RBD_LAST; - - acc += ie_buflen(sc, head); - head = (head + 1) % NRXBUF; - } while (!i); - - return acc; -} - -/* - * Setup all necessary artifacts for an XMIT command, and then pass the XMIT - * command to the chip to be executed. On the way, if we have a BPF listener - * also give him a copy. - */ -inline static void -iexmit(sc) - struct ie_softc *sc; -{ - -#if NBPFILTER > 0 - /* - * If BPF is listening on this interface, let it see the packet before - * we push it on the wire. - */ - if (sc->sc_arpcom.ac_if.if_bpf) - bpf_tap(sc->sc_arpcom.ac_if.if_bpf, - sc->xmit_cbuffs[sc->xctail], - sc->xmit_buffs[sc->xctail]->ie_xmit_flags); -#endif - - sc->xmit_buffs[sc->xctail]->ie_xmit_flags |= IE_XMIT_LAST; - sc->xmit_buffs[sc->xctail]->ie_xmit_next = 0xffff; - sc->xmit_buffs[sc->xctail]->ie_xmit_buf = - MK_24(MEM, sc->xmit_cbuffs[sc->xctail]); - - sc->xmit_cmds[sc->xctail]->com.ie_cmd_link = 0xffff; - sc->xmit_cmds[sc->xctail]->com.ie_cmd_cmd = - IE_CMD_XMIT | IE_CMD_INTR | IE_CMD_LAST; - - sc->xmit_cmds[sc->xctail]->ie_xmit_status = 0; - sc->xmit_cmds[sc->xctail]->ie_xmit_desc = - MK_16(MEM, sc->xmit_buffs[sc->xctail]); - - sc->scb->ie_command_list = MK_16(MEM, sc->xmit_cmds[sc->xctail]); - command_and_wait(sc, IE_CU_START, 0, 0); - - sc->xmit_busy = 1; - sc->sc_arpcom.ac_if.if_timer = 5; -} - -/* - * Read data off the interface, and turn it into an mbuf chain. - * - * This code is DRAMATICALLY different from the previous version; this version - * tries to allocate the entire mbuf chain up front, given the length of the - * data available. This enables us to allocate mbuf clusters in many - * situations where before we would have had a long chain of partially-full - * mbufs. This should help to speed up the operation considerably. (Provided - * that it works, of course.) - */ -static inline int -ieget(sc, mp, ehp, to_bpf) - struct ie_softc *sc; - struct mbuf **mp; - struct ether_header *ehp; - int *to_bpf; -{ - struct mbuf *m, *top, **mymp; - int i; - int offset; - int totlen, resid; - int thismboff; - int head; - - totlen = ie_packet_len(sc); - if (totlen <= 0) - return -1; - - i = sc->rbhead; - - /* - * Snarf the Ethernet header. - */ - bcopy((caddr_t)sc->cbuffs[i], (caddr_t)ehp, sizeof *ehp); - - /* - * As quickly as possible, check if this packet is for us. - * If not, don't waste a single cycle copying the rest of the - * packet in. - * This is only a consideration when FILTER is defined; i.e., when - * we are either running BPF or doing multicasting. - */ - if (!check_eh(sc, ehp, to_bpf)) { - ie_drop_packet_buffer(sc); - sc->sc_arpcom.ac_if.if_ierrors--; /* just this case, it's not an error */ - return -1; - } - totlen -= (offset = sizeof *ehp); - - MGETHDR(*mp, M_DONTWAIT, MT_DATA); - if (!*mp) { - ie_drop_packet_buffer(sc); - return -1; - } - - m = *mp; - m->m_pkthdr.rcvif = &sc->sc_arpcom.ac_if; - m->m_len = MHLEN; - resid = m->m_pkthdr.len = totlen; - top = 0; - mymp = ⊤ - - /* - * This loop goes through and allocates mbufs for all the data we will - * be copying in. It does not actually do the copying yet. - */ - do { /* while (resid > 0) */ - /* - * Try to allocate an mbuf to hold the data that we have. If - * we already allocated one, just get another one and stick it - * on the end (eventually). If we don't already have one, try - * to allocate an mbuf cluster big enough to hold the whole - * packet, if we think it's reasonable, or a single mbuf which - * may or may not be big enough. - * Got that? - */ - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (!m) { - m_freem(top); - ie_drop_packet_buffer(sc); - return -1; - } - m->m_len = MLEN; - } - - if (resid >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - m->m_len = min(resid, MCLBYTES); - } else { - if (resid < m->m_len) { - if (!top && resid + max_linkhdr <= m->m_len) - m->m_data += max_linkhdr; - m->m_len = resid; - } - } - resid -= m->m_len; - *mymp = m; - mymp = &m->m_next; - } while (resid > 0); - - resid = totlen; - m = top; - thismboff = 0; - head = sc->rbhead; - - /* - * Now we take the mbuf chain (hopefully only one mbuf most of the - * time) and stuff the data into it. There are no possible failures at - * or after this point. - */ - while (resid > 0) { /* while there's stuff left */ - int thislen = ie_buflen(sc, head) - offset; - - /* - * If too much data for the current mbuf, then fill the current - * one up, go to the next one, and try again. - */ - if (thislen > m->m_len - thismboff) { - int newlen = m->m_len - thismboff; - bcopy((caddr_t)(sc->cbuffs[head] + offset), - mtod(m, caddr_t) + thismboff, (u_int)newlen); - m = m->m_next; - thismboff = 0; /* new mbuf, so no offset */ - offset += newlen; /* we are now this far - into the packet */ - resid -= newlen; /* so there is this much - left to get */ - continue; - } - - /* - * If there is more than enough space in the mbuf to hold the - * contents of this buffer, copy everything in, advance - * pointers and so on. - */ - if (thislen < m->m_len - thismboff) { - bcopy((caddr_t)(sc->cbuffs[head] + offset), - mtod(m, caddr_t) + thismboff, (u_int)thislen); - thismboff += thislen; /* we are this far into the mbuf */ - resid -= thislen; /* and this much is left */ - goto nextbuf; - } - - /* - * Otherwise, there is exactly enough space to put this - * buffer's contents into the current mbuf. Do the combination - * of the above actions. - */ - bcopy((caddr_t)(sc->cbuffs[head] + offset), - mtod(m, caddr_t) + thismboff, (u_int)thislen); - m = m->m_next; - thismboff = 0; /* new mbuf, start at the beginning */ - resid -= thislen; /* and we are this far through */ - - /* - * Advance all the pointers. We can get here from either of - * the last two cases, but never the first. - */ - nextbuf: - offset = 0; - sc->rbuffs[head]->ie_rbd_actual = 0; - sc->rbuffs[head]->ie_rbd_length |= IE_RBD_LAST; - sc->rbhead = head = (head + 1) % NRXBUF; - sc->rbuffs[sc->rbtail]->ie_rbd_length &= ~IE_RBD_LAST; - sc->rbtail = (sc->rbtail + 1) % NRXBUF; - } - - /* - * Unless something changed strangely while we were doing the copy, we - * have now copied everything in from the shared memory. - * This means that we are done. - */ - return 0; -} - -/* - * Read frame NUM from unit UNIT (pre-cached as IE). - * - * This routine reads the RFD at NUM, and copies in the buffers from the list - * of RBD, then rotates the RBD and RFD lists so that the receiver doesn't - * start complaining. Trailers are DROPPED---there's no point in wasting time - * on confusing code to deal with them. Hopefully, this machine will never ARP - * for trailers anyway. - */ -static void -ie_readframe(sc, num) - struct ie_softc *sc; - int num; /* frame number to read */ -{ - int status; - struct mbuf *m = 0; - struct ether_header eh; -#if NBPFILTER > 0 - int bpf_gets_it = 0; -#endif - - status = sc->rframes[num]->ie_fd_status; - - /* Immediately advance the RFD list, since we have copied ours now. */ - sc->rframes[num]->ie_fd_status = 0; - sc->rframes[num]->ie_fd_last |= IE_FD_LAST; - sc->rframes[sc->rftail]->ie_fd_last &= ~IE_FD_LAST; - sc->rftail = (sc->rftail + 1) % NFRAMES; - sc->rfhead = (sc->rfhead + 1) % NFRAMES; - - if (status & IE_FD_OK) { -#if NBPFILTER > 0 - if (ieget(sc, &m, &eh, &bpf_gets_it)) { -#else - if (ieget(sc, &m, &eh, 0)) { -#endif - sc->sc_arpcom.ac_if.if_ierrors++; - return; - } - } - -#ifdef IEDEBUG - if (sc->sc_debug & IED_READFRAME) - printf("%s: frame from ether %s type %x\n", sc->sc_dev.dv_xname, - ether_sprintf(eh.ether_shost), (u_int)eh.ether_type); -#endif - - if (!m) - return; - - if (last_not_for_us) { - m_freem(last_not_for_us); - last_not_for_us = 0; - } - -#if NBPFILTER > 0 - /* - * Check for a BPF filter; if so, hand it up. - * Note that we have to stick an extra mbuf up front, because bpf_mtap - * expects to have the ether header at the front. - * It doesn't matter that this results in an ill-formatted mbuf chain, - * since BPF just looks at the data. (It doesn't try to free the mbuf, - * tho' it will make a copy for tcpdump.) - */ - if (bpf_gets_it) { - struct mbuf m0; - m0.m_len = sizeof eh; - m0.m_data = (caddr_t)&eh; - m0.m_next = m; - - /* Pass it up. */ - bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, &m0); - } - /* - * A signal passed up from the filtering code indicating that the - * packet is intended for BPF but not for the protocol machinery. - * We can save a few cycles by not handing it off to them. - */ - if (bpf_gets_it == 2) { - last_not_for_us = m; - return; - } -#endif /* NBPFILTER > 0 */ - - /* - * In here there used to be code to check destination addresses upon - * receipt of a packet. We have deleted that code, and replaced it - * with code to check the address much earlier in the cycle, before - * copying the data in; this saves us valuable cycles when operating - * as a multicast router or when using BPF. - */ - - /* - * Finally pass this packet up to higher layers. - */ - ether_input(&sc->sc_arpcom.ac_if, &eh, m); -} - -static void -ie_drop_packet_buffer(sc) - struct ie_softc *sc; -{ - int i; - - do { - /* - * This means we are somehow out of sync. So, we reset the - * adapter. - */ - if (!(sc->rbuffs[sc->rbhead]->ie_rbd_actual & IE_RBD_USED)) { -#ifdef IEDEBUG - print_rbd(sc->rbuffs[sc->rbhead]); -#endif - log(LOG_ERR, "%s: receive descriptors out of sync at %d\n", - sc->sc_dev.dv_xname, sc->rbhead); - iereset(sc); - return; - } - - i = sc->rbuffs[sc->rbhead]->ie_rbd_actual & IE_RBD_LAST; - - sc->rbuffs[sc->rbhead]->ie_rbd_length |= IE_RBD_LAST; - sc->rbuffs[sc->rbhead]->ie_rbd_actual = 0; - sc->rbhead = (sc->rbhead + 1) % NRXBUF; - sc->rbuffs[sc->rbtail]->ie_rbd_length &= ~IE_RBD_LAST; - sc->rbtail = (sc->rbtail + 1) % NRXBUF; - } while (!i); -} - - -/* - * Start transmission on an interface. - */ -int -iestart(ifp) - struct ifnet *ifp; -{ - struct ie_softc *sc = iecd.cd_devs[ifp->if_unit]; - struct mbuf *m0, *m; - u_char *buffer; - u_short len; - - if ((ifp->if_flags & IFF_RUNNING) == 0) - return 0; - - if (sc->xmit_free == 0) { - ifp->if_flags |= IFF_OACTIVE; - if (!sc->xmit_busy) - iexmit(sc); - return 0; - } - - do { - IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m); - if (!m) - break; - - len = 0; - buffer = sc->xmit_cbuffs[sc->xchead]; - - for (m0 = m; m && len < IE_TBUF_SIZE; m = m->m_next) { - bcopy(mtod(m, caddr_t), buffer, m->m_len); - buffer += m->m_len; - len += m->m_len; - } - - m_freem(m0); - len = max(len, ETHER_MIN_LEN); - sc->xmit_buffs[sc->xchead]->ie_xmit_flags = len; - - sc->xmit_free--; - sc->xchead = (sc->xchead + 1) % NTXBUF; - } while (sc->xmit_free > 0); - - /* If we stuffed any packets into the card's memory, send now. */ - if ((sc->xmit_free < NTXBUF) && (!sc->xmit_busy)) - iexmit(sc); - - return 1; -} - -/* - * Check to see if there's an 82586 out there. - */ -int -check_ie_present(sc, where, size) - struct ie_softc *sc; - caddr_t where; - u_int size; -{ - volatile struct ie_sys_conf_ptr *scp; - volatile struct ie_int_sys_conf_ptr *iscp; - volatile struct ie_sys_ctl_block *scb; - u_long realbase; - int s; - - s = splimp(); - - realbase = (u_long)where + size - (1 << 24); - - scp = (volatile struct ie_sys_conf_ptr *)(realbase + IE_SCP_ADDR); - bzero((char *)scp, sizeof *scp); - - /* - * First we put the ISCP at the bottom of memory; this tests to make - * sure that our idea of the size of memory is the same as the - * controller's. This is NOT where the ISCP will be in normal - * operation. - */ - iscp = (volatile struct ie_int_sys_conf_ptr *)where; - bzero((char *)iscp, sizeof *iscp); - - scb = (volatile struct ie_sys_ctl_block *)where; - bzero((char *)scb, sizeof *scb); - - scp->ie_bus_use = 0; /* 16-bit */ - scp->ie_iscp_ptr = (caddr_t)((volatile caddr_t)iscp - - (volatile caddr_t)realbase); - - iscp->ie_busy = 1; - iscp->ie_scb_offset = MK_16(realbase, scb) + 256; - - (sc->reset_586)(sc); - (sc->chan_attn)(sc); - - delay(100); /* wait a while... */ - - if (iscp->ie_busy) { - splx(s); - return 0; - } - - /* - * Now relocate the ISCP to its real home, and reset the controller - * again. - */ - iscp = (void *)ALIGN(realbase + IE_SCP_ADDR - sizeof(*iscp)); - bzero((char *)iscp, sizeof *iscp); - - scp->ie_iscp_ptr = (caddr_t)((caddr_t)iscp - (caddr_t)realbase); - - iscp->ie_busy = 1; - iscp->ie_scb_offset = MK_16(realbase, scb); - - (sc->reset_586)(sc); - (sc->chan_attn)(sc); - - delay(100); - - if (iscp->ie_busy) { - splx(s); - return 0; - } - - sc->sc_msize = size; - sc->sc_maddr = (caddr_t)realbase; - - sc->iscp = iscp; - sc->scb = scb; - - /* - * Acknowledge any interrupts we may have caused... - */ - ie_ack(sc, IE_ST_WHENCE); - splx(s); - - return 1; -} - -/* - * Divine the memory size of ie board UNIT. - * Better hope there's nothing important hiding just below the ie card... - */ -static void -find_ie_mem_size(sc) - struct ie_softc *sc; -{ - u_int size; - - sc->sc_msize = 0; - - for (size = 65536; size >= 16384; size -= 16384) - if (check_ie_present(sc, sc->sc_maddr, size)) - return; - - return; -} - -void -el_reset_586(sc) - struct ie_softc *sc; -{ - - outb(PORT + IE507_CTRL, EL_CTRL_RESET); - delay(100); - outb(PORT + IE507_CTRL, EL_CTRL_NORMAL); - delay(100); -} - -void -sl_reset_586(sc) - struct ie_softc *sc; -{ - - outb(PORT + IEATT_RESET, 0); -} - -void -el_chan_attn(sc) - struct ie_softc *sc; -{ - - outb(PORT + IE507_ATTN, 1); -} - -void -sl_chan_attn(sc) - struct ie_softc *sc; -{ - - outb(PORT + IEATT_ATTN, 0); -} - -void -slel_get_address(sc) - struct ie_softc *sc; -{ - u_char *addr = sc->sc_arpcom.ac_enaddr; - int i; - - for (i = 0; i < ETHER_ADDR_LEN; i++) - addr[i] = inb(PORT + i); -} - -void -iereset(sc) - struct ie_softc *sc; -{ - int s = splimp(); - - printf("%s: reset\n", sc->sc_dev.dv_xname); - - /* Clear OACTIVE in case we're called from watchdog (frozen xmit). */ - sc->sc_arpcom.ac_if.if_flags &= ~(IFF_UP | IFF_OACTIVE); - ieioctl(&sc->sc_arpcom.ac_if, SIOCSIFFLAGS, 0); - - /* - * Stop i82586 dead in its tracks. - */ - if (command_and_wait(sc, IE_RU_ABORT | IE_CU_ABORT, 0, 0)) - printf("%s: abort commands timed out\n", sc->sc_dev.dv_xname); - - if (command_and_wait(sc, IE_RU_DISABLE | IE_CU_STOP, 0, 0)) - printf("%s: disable commands timed out\n", sc->sc_dev.dv_xname); - -#ifdef notdef - if (!check_ie_present(sc, sc->sc_maddr, sc->sc_msize)) - panic("ie disappeared!\n"); -#endif - - sc->sc_arpcom.ac_if.if_flags |= IFF_UP; - ieioctl(&sc->sc_arpcom.ac_if, SIOCSIFFLAGS, 0); - - splx(s); -} - -/* - * This is called if we time out. - */ -static void -chan_attn_timeout(rock) - caddr_t rock; -{ - - *(int *)rock = 1; -} - -/* - * Send a command to the controller and wait for it to either complete or be - * accepted, depending on the command. If the command pointer is null, then - * pretend that the command is not an action command. If the command pointer - * is not null, and the command is an action command, wait for - * ((volatile struct ie_cmd_common *)pcmd)->ie_cmd_status & MASK - * to become true. - */ -static int -command_and_wait(sc, cmd, pcmd, mask) - struct ie_softc *sc; - int cmd; - volatile void *pcmd; - int mask; -{ - volatile struct ie_cmd_common *cc = pcmd; - volatile struct ie_sys_ctl_block *scb = sc->scb; - volatile int timedout = 0; - extern int hz; - - scb->ie_command = (u_short)cmd; - - if (IE_ACTION_COMMAND(cmd) && pcmd) { - (sc->chan_attn)(sc); - - /* - * According to the packet driver, the minimum timeout should - * be .369 seconds, which we round up to .4. - */ - timeout(chan_attn_timeout, (caddr_t)&timedout, 2 * hz / 5); - - /* - * Now spin-lock waiting for status. This is not a very nice - * thing to do, but I haven't figured out how, or indeed if, we - * can put the process waiting for action to sleep. (We may - * be getting called through some other timeout running in the - * kernel.) - */ - for (;;) - if ((cc->ie_cmd_status & mask) || timedout) - break; - - untimeout(chan_attn_timeout, (caddr_t)&timedout); - - return timedout; - } else { - /* - * Otherwise, just wait for the command to be accepted. - */ - (sc->chan_attn)(sc); - - while (scb->ie_command) - ; /* spin lock */ - - return 0; - } -} - -/* - * Run the time-domain reflectometer. - */ -static void -run_tdr(sc, cmd) - struct ie_softc *sc; - struct ie_tdr_cmd *cmd; -{ - int result; - - cmd->com.ie_cmd_status = 0; - cmd->com.ie_cmd_cmd = IE_CMD_TDR | IE_CMD_LAST; - cmd->com.ie_cmd_link = 0xffff; - - sc->scb->ie_command_list = MK_16(MEM, cmd); - cmd->ie_tdr_time = 0; - - if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || - !(cmd->com.ie_cmd_status & IE_STAT_OK)) - result = 0x10000; - else - result = cmd->ie_tdr_time; - - ie_ack(sc, IE_ST_WHENCE); - - if (result & IE_TDR_SUCCESS) - return; - - if (result & 0x10000) - printf("%s: TDR command failed\n", sc->sc_dev.dv_xname); - else if (result & IE_TDR_XCVR) - printf("%s: transceiver problem\n", sc->sc_dev.dv_xname); - else if (result & IE_TDR_OPEN) - printf("%s: TDR detected an open %d clocks away\n", - sc->sc_dev.dv_xname, result & IE_TDR_TIME); - else if (result & IE_TDR_SHORT) - printf("%s: TDR detected a short %d clocks away\n", - sc->sc_dev.dv_xname, result & IE_TDR_TIME); - else - printf("%s: TDR returned unknown status %x\n", - sc->sc_dev.dv_xname, result); -} - -#define _ALLOC(p, n) (bzero(p, n), p += n, p - n) -#define ALLOC(p, n) _ALLOC(p, ALIGN(n)) - -/* - * Here is a helper routine for ieinit(). This sets up the buffers. - */ -void -iememinit(ptr, sc) - void *ptr; - struct ie_softc *sc; -{ - int i; - - /* First lay them out. */ - for (i = 0; i < NFRAMES; i++) - sc->rframes[i] = ALLOC(ptr, sizeof(*sc->rframes[i])); - - /* Now link them together. */ - for (i = 0; i < NFRAMES; i++) - sc->rframes[i]->ie_fd_next = - MK_16(MEM, sc->rframes[(i + 1) % NFRAMES]); - - /* Finally, set the EOL bit on the last one. */ - sc->rframes[NFRAMES - 1]->ie_fd_last |= IE_FD_LAST; - - /* - * Now lay out some buffers for the incoming frames. Note that we set - * aside a bit of slop in each buffer, to make sure that we have enough - * space to hold a single frame in every buffer. - */ - for (i = 0; i < NRXBUF; i++) { - sc->rbuffs[i] = ALLOC(ptr, sizeof(*sc->rbuffs[i])); - sc->rbuffs[i]->ie_rbd_length = IE_RBUF_SIZE; - sc->rbuffs[i]->ie_rbd_buffer = MK_24(MEM, ptr); - sc->cbuffs[i] = ALLOC(ptr, IE_RBUF_SIZE); - } - - /* Now link them together. */ - for (i = 0; i < NRXBUF; i++) - sc->rbuffs[i]->ie_rbd_next = - MK_16(MEM, sc->rbuffs[(i + 1) % NRXBUF]); - - /* Tag EOF on the last one. */ - sc->rbuffs[NRXBUF - 1]->ie_rbd_length |= IE_RBD_LAST; - - /* - * We use the head and tail pointers on receive to keep track of the - * order in which RFDs and RBDs are used. - */ - sc->rfhead = 0; - sc->rftail = NFRAMES - 1; - sc->rbhead = 0; - sc->rbtail = NRXBUF - 1; - - sc->scb->ie_recv_list = MK_16(MEM, sc->rframes[0]); - sc->rframes[0]->ie_fd_buf_desc = MK_16(MEM, sc->rbuffs[0]); - - /* - * Finally, the transmit command and buffer are the last little bit of - * work. - */ - for (i = 0; i < NTXBUF; i++) { - sc->xmit_cmds[i] = ALLOC(ptr, sizeof(*sc->xmit_cmds[i])); - sc->xmit_buffs[i] = ALLOC(ptr, sizeof(*sc->xmit_buffs[i])); - } - - for (i = 0; i < NTXBUF; i++) - sc->xmit_cbuffs[i] = ALLOC(ptr, IE_TBUF_SIZE); - - /* Pointers to last packet sent and next available transmit buffer. */ - sc->xchead = sc->xctail = 0; - - /* Clear transmit-busy flag and set number of free transmit buffers. */ - sc->xmit_busy = 0; - sc->xmit_free = NTXBUF; -} - -/* - * Run the multicast setup command. - * Called at splimp(). - */ -static int -mc_setup(sc, ptr) - struct ie_softc *sc; - void *ptr; -{ - volatile struct ie_mcast_cmd *cmd = ptr; - - cmd->com.ie_cmd_status = 0; - cmd->com.ie_cmd_cmd = IE_CMD_MCAST | IE_CMD_LAST; - cmd->com.ie_cmd_link = 0xffff; - - bcopy((caddr_t)sc->mcast_addrs, (caddr_t)cmd->ie_mcast_addrs, - sc->mcast_count * sizeof *sc->mcast_addrs); - - cmd->ie_mcast_bytes = sc->mcast_count * ETHER_ADDR_LEN; /* grrr... */ - - sc->scb->ie_command_list = MK_16(MEM, cmd); - if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || - !(cmd->com.ie_cmd_status & IE_STAT_OK)) { - printf("%s: multicast address setup command failed\n", - sc->sc_dev.dv_xname); - return 0; - } - return 1; -} - -/* - * This routine takes the environment generated by check_ie_present() and adds - * to it all the other structures we need to operate the adapter. This - * includes executing the CONFIGURE, IA-SETUP, and MC-SETUP commands, starting - * the receiver unit, and clearing interrupts. - * - * THIS ROUTINE MUST BE CALLED AT splimp() OR HIGHER. - */ -int -ieinit(sc) - struct ie_softc *sc; -{ - volatile struct ie_sys_ctl_block *scb = sc->scb; - void *ptr; - int n; - - ptr = (void *)ALIGN(scb + 1); - - /* - * Send the configure command first. - */ - { - volatile struct ie_config_cmd *cmd = ptr; - - scb->ie_command_list = MK_16(MEM, cmd); - cmd->com.ie_cmd_status = 0; - cmd->com.ie_cmd_cmd = IE_CMD_CONFIG | IE_CMD_LAST; - cmd->com.ie_cmd_link = 0xffff; - - ie_setup_config(cmd, sc->promisc, sc->hard_type == IE_STARLAN10); - - if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || - !(cmd->com.ie_cmd_status & IE_STAT_OK)) { - printf("%s: configure command failed\n", - sc->sc_dev.dv_xname); - return 0; - } - } - - /* - * Now send the Individual Address Setup command. - */ - { - volatile struct ie_iasetup_cmd *cmd = ptr; - - scb->ie_command_list = MK_16(MEM, cmd); - cmd->com.ie_cmd_status = 0; - cmd->com.ie_cmd_cmd = IE_CMD_IASETUP | IE_CMD_LAST; - cmd->com.ie_cmd_link = 0xffff; - - bcopy(sc->sc_arpcom.ac_enaddr, (caddr_t)&cmd->ie_address, - sizeof cmd->ie_address); - - if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || - !(cmd->com.ie_cmd_status & IE_STAT_OK)) { - printf("%s: individual address setup command failed\n", - sc->sc_dev.dv_xname); - return 0; - } - } - - /* - * Now run the time-domain reflectometer. - */ - run_tdr(sc, ptr); - - /* - * Acknowledge any interrupts we have generated thus far. - */ - ie_ack(sc, IE_ST_WHENCE); - - /* - * Set up the RFA. - */ - iememinit(ptr, sc); - - sc->sc_arpcom.ac_if.if_flags |= IFF_RUNNING; /* tell higher levels that we are here */ - - sc->scb->ie_recv_list = MK_16(MEM, sc->rframes[0]); - command_and_wait(sc, IE_RU_START, 0, 0); - - ie_ack(sc, IE_ST_WHENCE); - - return 0; -} - -static void -iestop(sc) - struct ie_softc *sc; -{ - - command_and_wait(sc, IE_RU_DISABLE, 0, 0); -} - -int -ieioctl(ifp, cmd, data) - register struct ifnet *ifp; - u_long cmd; - caddr_t data; -{ - struct ie_softc *sc = iecd.cd_devs[ifp->if_unit]; - struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splimp(); - - switch(cmd) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch(ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - ieinit(sc); - /* - * See if another station has *our* IP address. - * i.e.: There is an address conflict! If a conflict - * exists, a message is sent to the console. - */ - sc->sc_arpcom.ac_ipaddr = IA_SIN(ifa)->sin_addr; - arpwhohas(&sc->sc_arpcom, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - /* XXX - This code is probably wrong. */ - case AF_NS: - { - struct ns_addr *ina = &IA_SNS(ifa)->sns_addr; - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(sc->sc_arpcom.ac_enaddr); - else - bcopy(ina->x_host.c_host, - sc->sc_arpcom.ac_enaddr, - sizeof(sc->sc_arpcom.ac_enaddr)); - /* Set new address. */ - ieinit(sc); - break; - } -#endif /* NS */ - default: - ieinit(sc); - break; - } - break; - - case SIOCSIFFLAGS: - sc->promisc = ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI); - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, then - * stop it. - */ - iestop(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, then - * start it. - */ - ieinit(sc); - } else { - /* - * Reset the interface to pick up changes in any other - * flags that affect hardware registers. - */ - iestop(sc); - ieinit(sc); - } -#ifdef IEDEBUG - if (ifp->if_flags & IFF_DEBUG) - sc->sc_debug = IED_ALL; - else - sc->sc_debug = 0; -#endif - break; - - case SIOCADDMULTI: - case SIOCDELMULTI: - error = (cmd == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->sc_arpcom): - ether_delmulti(ifr, &sc->sc_arpcom); - - if (error == ENETRESET) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - mc_reset(sc); - error = 0; - } - break; - - default: - error = EINVAL; - } - splx(s); - return error; -} - -static void -mc_reset(sc) - struct ie_softc *sc; -{ - struct ether_multi *enm; - struct ether_multistep step; - - /* - * Step through the list of addresses. - */ - sc->mcast_count = 0; - ETHER_FIRST_MULTI(step, &sc->sc_arpcom, enm); - while (enm) { - if (sc->mcast_count >= MAXMCAST || - bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) { - sc->sc_arpcom.ac_if.if_flags |= IFF_ALLMULTI; - ieioctl(&sc->sc_arpcom.ac_if, SIOCSIFFLAGS, (void *)0); - goto setflag; - } - - bcopy(enm->enm_addrlo, &sc->mcast_addrs[sc->mcast_count], 6); - sc->mcast_count++; - ETHER_NEXT_MULTI(step, enm); - } -setflag: - sc->want_mcsetup = 1; -} - -#ifdef IEDEBUG -void -print_rbd(rbd) - volatile struct ie_recv_buf_desc *rbd; -{ - - printf("RBD at %08lx:\nactual %04x, next %04x, buffer %08x\n" - "length %04x, mbz %04x\n", (u_long)rbd, rbd->ie_rbd_actual, - rbd->ie_rbd_next, rbd->ie_rbd_buffer, rbd->ie_rbd_length, - rbd->mbz); -} -#endif diff --git a/sys/arch/i386/isa/if_ie507.h b/sys/arch/i386/isa/if_ie507.h deleted file mode 100644 index 769911fc2da5..000000000000 --- a/sys/arch/i386/isa/if_ie507.h +++ /dev/null @@ -1,22 +0,0 @@ -/* $NetBSD: if_ie507.h,v 1.5 1995/01/23 04:50:10 mycroft Exp $ */ - -/* - * Definitions for 3C507 - */ - -#define IE507_CTRL 6 /* control port */ -#define IE507_ICTRL 10 /* interrupt control */ -#define IE507_ATTN 11 /* any write here sends a chan attn */ -#define IE507_MADDR 14 /* shared memory configuration */ -#define IE507_IRQ 15 /* IRQ configuration */ - -#define EL_CTRL_BNK0 0x00 /* register bank 0 */ -#define EL_CTRL_BNK1 0x01 /* register bank 1 */ -#define EL_CTRL_BNK2 0x02 /* register bank 2 */ -#define EL_CTRL_IEN 0x04 /* interrupt enable */ -#define EL_CTRL_INTL 0x08 /* interrupt active latch */ -#define EL_CTRL_16BIT 0x10 /* bus width; clear = 8-bit, set = 16-bit */ -#define EL_CTRL_LOOP 0x20 /* loopback mode */ -#define EL_CTRL_NRST 0x80 /* turn off to reset */ -#define EL_CTRL_RESET (EL_CTRL_LOOP) -#define EL_CTRL_NORMAL (EL_CTRL_NRST | EL_CTRL_IEN | EL_CTRL_BNK1) diff --git a/sys/arch/i386/isa/if_ieatt.h b/sys/arch/i386/isa/if_ieatt.h deleted file mode 100644 index f39114b6daa8..000000000000 --- a/sys/arch/i386/isa/if_ieatt.h +++ /dev/null @@ -1,25 +0,0 @@ -/* $NetBSD: if_ieatt.h,v 1.2 1994/10/27 04:17:40 cgd Exp $ */ - -/* - * definitions for AT&T StarLAN 10 etc... - */ - -#define IEATT_RESET 0 /* any write here resets the 586 */ -#define IEATT_ATTN 1 /* any write here sends a Chan attn */ -#define IEATT_REVISION 6 /* read here to figure out this board */ -#define IEATT_ATTRIB 7 /* more information about this board */ - -#define SL_BOARD(x) ((x) & 0x0f) -#define SL_REV(x) ((x) >> 4) - -#define SL1_BOARD 0 -#define SL10_BOARD 1 -#define EN100_BOARD 2 -#define SLFIBER_BOARD 3 - -#define SL_ATTR_WIDTH 0x04 /* bus width: clear -> 8-bit */ -#define SL_ATTR_SPEED 0x08 /* medium speed: clear -> 10 Mbps */ -#define SL_ATTR_CODING 0x10 /* encoding: clear -> Manchester */ -#define SL_ATTR_HBW 0x20 /* host bus width: clear -> 16-bit */ -#define SL_ATTR_TYPE 0x40 /* medium type: clear -> Ethernet */ -#define SL_ATTR_BOOTROM 0x80 /* set -> boot ROM present */ diff --git a/sys/arch/i386/isa/if_le.c b/sys/arch/i386/isa/if_le.c deleted file mode 100644 index 9ec80e9b2b62..000000000000 --- a/sys/arch/i386/isa/if_le.c +++ /dev/null @@ -1,1241 +0,0 @@ -/* $NetBSD: if_le.c,v 1.22 1995/01/03 01:30:46 mycroft Exp $ */ - -/* - * LANCE Ethernet driver - * - * Copyright (c) 1994 Charles Hannum. - * - * Copyright (C) 1993, Paul Richards. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided - * that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning - * of this software, nor does the author assume any responsibility - * for damages incurred with its use. - */ - -#include "bpfilter.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef INET -#include -#include -#include -#include -#include -#endif - -#ifdef NS -#include -#include -#endif - -#if NBPFILTER > 0 -#include -#include -#endif - -#include - -#include -#include - -#include -#include -#include -#include - - -#define ETHER_MIN_LEN 64 -#define ETHER_MAX_LEN 1518 -#define ETHER_ADDR_LEN 6 - -char *card_type[] = {"unknown", "BICC Isolan", "NE2100", "DEPCA"}; -char *chip_type[] = {"unknown", "Am7990 LANCE", "Am79960 PCnet-ISA"}; - - -/* - * Ethernet software status per interface. - * - * Each interface is referenced by a network interface structure, - * arpcom.ac_if, which the routing code uses to locate the interface. - * This structure contains the output queue for the interface, its address, ... - */ -struct le_softc { - struct device sc_dev; - struct intrhand sc_ih; - - struct arpcom sc_arpcom; /* Ethernet common part */ - int sc_iobase; /* IO base address of card */ - int sc_rap, sc_rdp; - int sc_chip, sc_card; - void *sc_mem; - struct init_block *sc_init; /* Lance initialisation block */ - struct mds *sc_rd, *sc_td; - u_char *sc_rbuf, *sc_tbuf; - int sc_last_rd, sc_last_td; - int sc_no_td; -#ifdef LEDEBUG - int sc_debug; -#endif -}; - -int leintr __P((struct le_softc *)); -int leioctl __P((struct ifnet *, u_long, caddr_t)); -int lestart __P((struct ifnet *)); -int lewatchdog __P((/* short */)); -static inline void lewrcsr __P((/* struct le_softc *, u_short, u_short */)); -static inline u_short lerdcsr __P((/* struct le_softc *, u_short */)); -void leinit __P((struct le_softc *)); -void lememinit __P((struct le_softc *)); -void lereset __P((struct le_softc *)); -void lestop __P((struct le_softc *)); -void letint __P((struct le_softc *)); -void lerint __P((struct le_softc *)); -void leread __P((struct le_softc *, u_char *, int)); -struct mbuf *leget __P((u_char *, int, struct ifnet *)); -#ifdef LEDEBUG -void recv_print __P((struct le_softc *, int)); -void xmit_print __P((struct le_softc *, int)); -#endif -void lesetladrf __P((struct arpcom *, u_long *)); - -int leprobe __P((struct device *, void *, void *)); -int depca_probe __P((struct le_softc *, struct isa_attach_args *)); -int ne2100_probe __P((struct le_softc *, struct isa_attach_args *)); -int bicc_probe __P((struct le_softc *, struct isa_attach_args *)); -int lance_probe __P((struct le_softc *)); -void leattach __P((struct device *, struct device *, void *)); - -struct cfdriver lecd = { - NULL, "le", leprobe, leattach, DV_IFNET, sizeof(struct le_softc) -}; - -static inline void -lewrcsr(sc, port, val) - struct le_softc *sc; - u_short port; - u_short val; -{ - - outw(sc->sc_rap, port); - outw(sc->sc_rdp, val); -} - -static inline u_short -lerdcsr(sc, port) - struct le_softc *sc; - u_short port; -{ - - outw(sc->sc_rap, port); - return inw(sc->sc_rdp); -} - -int -leprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct le_softc *sc = match; - struct isa_attach_args *ia = aux; - - if (bicc_probe(sc, ia)) - goto found; - if (ne2100_probe(sc, ia)) - goto found; - if (depca_probe(sc, ia)) - goto found; - return 0; - -found: - /* - * XXX - hopefully have better way to get dma'able memory later, - * this code assumes that the physical memory address returned - * from malloc will be below 16Mb. The Lance's address registers - * are only 24 bits wide! - */ -#define MAXMEM ((NRBUF + NTBUF) * (BUFSIZE + sizeof(struct mds)) + \ - sizeof(struct init_block)) - if (sc->sc_card == DEPCA) { - u_char *mem, val; - int i; - - mem = sc->sc_mem = ISA_HOLE_VADDR(ia->ia_maddr); - /* XXX This is somewhat bogus. */ - if (ia->ia_msize < MAXMEM) { - printf("%s: not enough memory configured\n", - sc->sc_dev.dv_xname); - return 0; - } - - val = 0xff; - for (;;) { - for (i = 0; i < ia->ia_msize; i++) - mem[i] = val; - for (i = 0; i < ia->ia_msize; i++) - if (mem[i] != val) { - printf("%s: failed to clear memory\n", - sc->sc_dev.dv_xname); - return 0; - } - if (val == 0x00) - break; - val -= 0x55; - } - } else { - sc->sc_mem = malloc(MAXMEM, M_TEMP, M_NOWAIT); - if (!sc->sc_mem) { - printf("%s: couldn't allocate memory for card\n", - sc->sc_dev.dv_xname); - return 0; - } - } - - return 1; -} - -int -depca_probe(sc, ia) - struct le_softc *sc; - struct isa_attach_args *ia; -{ - int iobase = ia->ia_iobase, port; - u_long sum, rom_sum; - u_char x; - int i; - - sc->sc_iobase = iobase; - sc->sc_rap = iobase + DEPCA_RAP; - sc->sc_rdp = iobase + DEPCA_RDP; - sc->sc_card = DEPCA; - - if (!(sc->sc_chip = lance_probe(sc))) - return 0; - - outb(iobase + DEPCA_CSR, DEPCA_CSR_DUM); - - /* - * Extract the physical MAC address from the ROM. - * - * The address PROM is 32 bytes wide, and we access it through - * a single I/O port. On each read, it rotates to the next - * position. We find the ethernet address by looking for a - * particular sequence of bytes (0xff, 0x00, 0x55, 0xaa, 0xff, - * 0x00, 0x55, 0xaa), and then reading the next 8 bytes (the - * ethernet address and a checksum). - * - * It appears that the PROM can be at one of two locations, so - * we just try both. - */ - port = iobase + DEPCA_ADP; - for (i = 0; i < 32; i++) - if (inb(port) == 0xff && inb(port) == 0x00 && - inb(port) == 0x55 && inb(port) == 0xaa && - inb(port) == 0xff && inb(port) == 0x00 && - inb(port) == 0x55 && inb(port) == 0xaa) - goto found; - port = iobase + DEPCA_ADP + 1; - for (i = 0; i < 32; i++) - if (inb(port) == 0xff && inb(port) == 0x00 && - inb(port) == 0x55 && inb(port) == 0xaa && - inb(port) == 0xff && inb(port) == 0x00 && - inb(port) == 0x55 && inb(port) == 0xaa) - goto found; - printf("%s: address not found\n", sc->sc_dev.dv_xname); - return 0; - -found: - for (i = 0; i < ETHER_ADDR_LEN; i++) - sc->sc_arpcom.ac_enaddr[i] = inb(port); - -#if 0 - sum = - (sc->sc_arpcom.ac_enaddr[0] << 2) + - (sc->sc_arpcom.ac_enaddr[1] << 10) + - (sc->sc_arpcom.ac_enaddr[2] << 1) + - (sc->sc_arpcom.ac_enaddr[3] << 9) + - (sc->sc_arpcom.ac_enaddr[4] << 0) + - (sc->sc_arpcom.ac_enaddr[5] << 8); - sum = (sum & 0xffff) + (sum >> 16); - sum = (sum & 0xffff) + (sum >> 16); - - rom_sum = inb(port); - rom_sum |= inb(port) << 8; - - if (sum != rom_sum) { - printf("%s: checksum mismatch; calculated %04x != read %04x", - sc->sc_dev.dv_xname, sum, rom_sum); - return 0; - } -#endif - - outb(iobase + DEPCA_CSR, DEPCA_CSR_NORMAL); - - ia->ia_iosize = 16; - ia->ia_drq = DRQUNK; - return 1; -} - -int -ne2100_probe(sc, ia) - struct le_softc *sc; - struct isa_attach_args *ia; -{ - int iobase = ia->ia_iobase; - int i; - - sc->sc_iobase = iobase; - sc->sc_rap = iobase + NE2100_RAP; - sc->sc_rdp = iobase + NE2100_RDP; - sc->sc_card = NE2100; - - if (!(sc->sc_chip = lance_probe(sc))) - return 0; - - /* - * Extract the physical MAC address from the ROM. - */ - for (i = 0; i < ETHER_ADDR_LEN; i++) - sc->sc_arpcom.ac_enaddr[i] = inb(iobase + i); - - ia->ia_iosize = 24; - return 1; -} - -int -bicc_probe(sc, ia) - struct le_softc *sc; - struct isa_attach_args *ia; -{ - int iobase = ia->ia_iobase; - int i; - - sc->sc_iobase = iobase; - sc->sc_rap = iobase + BICC_RAP; - sc->sc_rdp = iobase + BICC_RDP; - sc->sc_card = BICC; - - if (!(sc->sc_chip = lance_probe(sc))) - return 0; - - /* - * Extract the physical MAC address from the ROM. - */ - for (i = 0; i < ETHER_ADDR_LEN; i++) - sc->sc_arpcom.ac_enaddr[i] = inb(iobase + (i * 2)); - - ia->ia_iosize = 16; - return 1; -} - -/* - * Determine which chip is present on the card. - */ -int -lance_probe(sc) - struct le_softc *sc; -{ - int type; - - /* Stop the LANCE chip and put it in a known state. */ - lewrcsr(sc, 0, LE_STOP); - delay(100); - - if (lerdcsr(sc, 0) != LE_STOP) - return 0; - - /* - * The PCnet-ISA chip doesn't allow some bits to be set. - */ - lewrcsr(sc, 3, PROBE_MASK); - - switch (lerdcsr(sc, 3) & PROBE_MASK) { - case LANCE_MASK: - type = LANCE; - break; - case PCnet_ISA_MASK: - type = PCnet_ISA; - break; - default: - type = 0; - break; - } - - lewrcsr(sc, 3, sc->sc_card == DEPCA ? LE_ACON : 0); - return type; -} - -/* - * Interface exists: make available by filling in network interface - * record. System will initialize the interface when it is ready - * to accept packets. We get the ethernet address here. - */ -void -leattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct le_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = lecd.cd_name; - ifp->if_output = ether_output; - ifp->if_start = lestart; - ifp->if_ioctl = leioctl; - ifp->if_watchdog = lewatchdog; - ifp->if_flags = - IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - - if (ia->ia_drq != DRQUNK) - isa_dmacascade(ia->ia_drq); - - /* Attach the interface. */ - if_attach(ifp); - ether_ifattach(ifp); - - printf(": address %s, type %s %s\n", - ether_sprintf(sc->sc_arpcom.ac_enaddr), - card_type[sc->sc_card], chip_type[sc->sc_chip]); - -#if NBPFILTER > 0 - bpfattach(&sc->sc_arpcom.ac_if.if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif - - sc->sc_ih.ih_fun = leintr; - sc->sc_ih.ih_arg = sc; - sc->sc_ih.ih_level = IPL_NET; - intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih); -} - -void -lereset(sc) - struct le_softc *sc; -{ - - leinit(sc); -} - -int -lewatchdog(unit) - short unit; -{ - struct le_softc *sc = lecd.cd_devs[unit]; - - log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname); - ++sc->sc_arpcom.ac_if.if_oerrors; - lereset(sc); -} - -#define LANCE_ADDR(sc, a) \ - (sc->sc_card == DEPCA ? ((u_long)(a) - (u_long)sc->sc_mem) : kvtop(a)) - -/* LANCE initialization block set up. */ -void -lememinit(sc) - register struct le_softc *sc; -{ - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int i; - void *mem; - u_long a; - - /* - * At this point we assume that the memory allocated to the Lance is - * quadword aligned. If it isn't then the initialisation is going - * fail later on. - */ - mem = sc->sc_mem; - - sc->sc_init = mem; -#if NBPFILTER > 0 - if (ifp->if_flags & IFF_PROMISC) - sc->sc_init->mode = LE_NORMAL | LE_PROM; - else -#endif - sc->sc_init->mode = LE_NORMAL; - for (i = 0; i < ETHER_ADDR_LEN; i++) - sc->sc_init->padr[i] = sc->sc_arpcom.ac_enaddr[i]; - lesetladrf(&sc->sc_arpcom, sc->sc_init->ladrf); - mem += sizeof(struct init_block); - - sc->sc_rd = mem; - a = LANCE_ADDR(sc, mem); - sc->sc_init->rdra = a; - sc->sc_init->rlen = ((a >> 16) & 0xff) | (RLEN << 13); - mem += NRBUF * sizeof(struct mds); - - sc->sc_td = mem; - a = LANCE_ADDR(sc, mem); - sc->sc_init->tdra = a; - sc->sc_init->tlen = ((a >> 16) & 0xff) | (TLEN << 13); - mem += NTBUF * sizeof(struct mds); - - /* - * Set up receive ring descriptors. - */ - sc->sc_rbuf = mem; - for (i = 0; i < NRBUF; i++) { - a = LANCE_ADDR(sc, mem); - sc->sc_rd[i].addr = a; - sc->sc_rd[i].flags = ((a >> 16) & 0xff) | LE_OWN; - sc->sc_rd[i].bcnt = -BUFSIZE; - sc->sc_rd[i].mcnt = 0; - mem += BUFSIZE; - } - - /* - * Set up transmit ring descriptors. - */ - sc->sc_tbuf = mem; - for (i = 0; i < NTBUF; i++) { - a = LANCE_ADDR(sc, mem); - sc->sc_td[i].addr = a; - sc->sc_td[i].flags= ((a >> 16) & 0xff); - sc->sc_td[i].bcnt = 0xf000; - sc->sc_td[i].mcnt = 0; - mem += BUFSIZE; - } -} - -void -lestop(sc) - struct le_softc *sc; -{ - - lewrcsr(sc, 0, LE_STOP); -} - -/* - * Initialization of interface; set up initialization block - * and transmit/receive descriptor rings. - */ -void -leinit(sc) - register struct le_softc *sc; -{ - struct ifnet *ifp = &sc->sc_arpcom.ac_if; - int s; - register int timo; - u_long a; - - /* Address not known. */ - if (!ifp->if_addrlist) - return; - - s = splimp(); - - /* Don't want to get in a weird state. */ - lewrcsr(sc, 0, LE_STOP); - delay(100); - - sc->sc_last_rd = sc->sc_last_td = sc->sc_no_td = 0; - - /* Set up LANCE init block. */ - lememinit(sc); - - /* No byte swapping etc. */ - lewrcsr(sc, 3, sc->sc_card == DEPCA ? LE_ACON : 0); - - /* Give LANCE the physical address of its init block. */ - a = LANCE_ADDR(sc, sc->sc_init); - lewrcsr(sc, 1, a); - lewrcsr(sc, 2, (a >> 16) & 0xff); - - /* Try to initialize the LANCE. */ - delay(100); - lewrcsr(sc, 0, LE_INIT); - - /* Wait for initialization to finish. */ - for (timo = 1000; timo; timo--) - if (lerdcsr(sc, 0) & LE_IDON) - break; - - if (lerdcsr(sc, 0) & LE_IDON) { - /* Start the LANCE. */ - lewrcsr(sc, 0, LE_INEA | LE_STRT | LE_IDON); - ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; - lestart(ifp); - } else - printf("%s: card failed to initialize\n", sc->sc_dev.dv_xname); - - (void) splx(s); -} - -/* - * Controller interrupt. - */ -int -leintr(sc) - register struct le_softc *sc; -{ - register u_short isr; - - isr = lerdcsr(sc, 0); -#ifdef LEDEBUG - if (sc->sc_debug) - printf("%s: leintr entering with isr=%04x\n", - sc->sc_dev.dv_xname, isr); -#endif - if ((isr & LE_INTR) == 0) - return 0; - - if (sc->sc_card == DEPCA) - outb(sc->sc_iobase + DEPCA_CSR, DEPCA_CSR_NORMAL|DEPCA_CSR_IM); - - do { - lewrcsr(sc, 0, - isr & (LE_INEA | LE_BABL | LE_MISS | LE_MERR | - LE_RINT | LE_TINT | LE_IDON)); - if (isr & (LE_BABL | LE_CERR | LE_MISS | LE_MERR)) { - if (isr & LE_BABL) { - printf("%s: babble\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_oerrors++; - } -#if 0 - if (isr & LE_CERR) { - printf("%s: collision error\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_collisions++; - } -#endif - if (isr & LE_MISS) { -#if 0 - printf("%s: missed packet\n", sc->sc_dev.dv_xname); -#endif - sc->sc_arpcom.ac_if.if_ierrors++; - } - if (isr & LE_MERR) { - printf("%s: memory error\n", sc->sc_dev.dv_xname); - lereset(sc); - goto out; - } - } - - if ((isr & LE_RXON) == 0) { - printf("%s: receiver disabled\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_ierrors++; - lereset(sc); - goto out; - } - if ((isr & LE_TXON) == 0) { - printf("%s: transmitter disabled\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_oerrors++; - lereset(sc); - goto out; - } - - if (isr & LE_RINT) { - /* Reset watchdog timer. */ - sc->sc_arpcom.ac_if.if_timer = 0; - lerint(sc); - } - if (isr & LE_TINT) { - /* Reset watchdog timer. */ - sc->sc_arpcom.ac_if.if_timer = 0; - letint(sc); - } - - isr = lerdcsr(sc, 0); - } while ((isr & LE_INTR) != 0); - -#ifdef LEDEBUG - if (sc->sc_debug) - printf("%s: leintr returning with isr=%04x\n", - sc->sc_dev.dv_xname, isr); -#endif - -out: - if (sc->sc_card == DEPCA) - outb(sc->sc_iobase + DEPCA_CSR, DEPCA_CSR_NORMAL); - return 1; -} - -#define NEXTTDS \ - if (++tmd == NTBUF) tmd=0, cdm=sc->sc_td; else ++cdm - -/* - * Setup output on interface. - * Get another datagram to send off of the interface queue, and map it to the - * interface before starting the output. - * Called only at splimp or interrupt level. - */ -int -lestart(ifp) - struct ifnet *ifp; -{ - register struct le_softc *sc = lecd.cd_devs[ifp->if_unit]; - register int tmd; - struct mds *cdm; - struct mbuf *m0, *m; - u_char *buffer; - int len; - - if ((sc->sc_arpcom.ac_if.if_flags & (IFF_RUNNING | IFF_OACTIVE)) != - IFF_RUNNING) - return; - - tmd = sc->sc_last_td; - cdm = &sc->sc_td[tmd]; - - for (;;) { - if (sc->sc_no_td >= NTBUF) { - sc->sc_arpcom.ac_if.if_flags |= IFF_OACTIVE; -#ifdef LEDEBUG - if (sc->sc_debug) - printf("no_td = %d, last_td = %d\n", sc->sc_no_td, - sc->sc_last_td); -#endif - break; - } - -#ifdef LEDEBUG - if (cdm->flags & LE_OWN) { - sc->sc_arpcom.ac_if.if_flags |= IFF_OACTIVE; - printf("missing buffer, no_td = %d, last_td = %d\n", - sc->sc_no_td, sc->sc_last_td); - } -#endif - - IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m); - if (!m) - break; - - ++sc->sc_no_td; - - /* - * Copy the mbuf chain into the transmit buffer. - */ - buffer = sc->sc_tbuf + (BUFSIZE * sc->sc_last_td); - len = 0; - for (m0 = m; m; m = m->m_next) { - bcopy(mtod(m, caddr_t), buffer, m->m_len); - buffer += m->m_len; - len += m->m_len; - } - -#ifdef LEDEBUG - if (len > ETHER_MAX_LEN) - printf("packet length %d\n", len); -#endif - -#if NBPFILTER > 0 - if (sc->sc_arpcom.ac_if.if_bpf) - bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0); -#endif - - m_freem(m0); - len = max(len, ETHER_MIN_LEN); - - /* - * Init transmit registers, and set transmit start flag. - */ - cdm->bcnt = -len; - cdm->mcnt = 0; - cdm->flags |= LE_OWN | LE_STP | LE_ENP; - -#ifdef LEDEBUG - if (sc->sc_debug) - xmit_print(sc, sc->sc_last_td); -#endif - - lewrcsr(sc, 0, LE_INEA | LE_TDMD); - - NEXTTDS; - } - - sc->sc_last_td = tmd; -} - -void -letint(sc) - struct le_softc *sc; -{ - register int tmd = (sc->sc_last_td - sc->sc_no_td + NTBUF) % NTBUF; - struct mds *cdm = &sc->sc_td[tmd]; - - if (cdm->flags & LE_OWN) { - /* Race condition with loop below. */ -#ifdef LEDEBUG - if (sc->sc_debug) - printf("%s: extra tint\n", sc->sc_dev.dv_xname); -#endif - return; - } - - sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; - - do { - if (sc->sc_no_td <= 0) - break; -#ifdef LEDEBUG - if (sc->sc_debug) - printf("trans cdm = %x\n", cdm); -#endif - sc->sc_arpcom.ac_if.if_opackets++; - --sc->sc_no_td; - if (cdm->mcnt & (LE_TBUFF | LE_UFLO | LE_LCOL | LE_LCAR | LE_RTRY)) { - if (cdm->mcnt & LE_TBUFF) - printf("%s: transmit buffer error\n", sc->sc_dev.dv_xname); - if ((cdm->mcnt & (LE_TBUFF | LE_UFLO)) == LE_UFLO) - printf("%s: underflow\n", sc->sc_dev.dv_xname); - if (cdm->mcnt & LE_UFLO) { - lereset(sc); - return; - } -#if 0 - if (cdm->mcnt & LE_LCOL) { - printf("%s: late collision\n", sc->sc_dev.dv_xname); - sc->sc_arpcom.ac_if.if_collisions++; - } - if (cdm->mcnt & LE_LCAR) - printf("%s: lost carrier\n", sc->sc_dev.dv_xname); - if (cdm->mcnt & LE_RTRY) { - printf("%s: excessive collisions, tdr %d\n", - sc->sc_dev.dv_xname, cdm->flags & 0x1ff); - sc->sc_arpcom.ac_if.if_collisions += 16; - } -#endif - } else if (cdm->flags & LE_ONE) - sc->sc_arpcom.ac_if.if_collisions++; - else if (cdm->flags & LE_MORE) - /* Real number is unknown. */ - sc->sc_arpcom.ac_if.if_collisions += 2; - NEXTTDS; - } while ((cdm->flags & LE_OWN) == 0); - - lestart(&sc->sc_arpcom.ac_if); -} - -#define NEXTRDS \ - if (++rmd == NRBUF) rmd=0, cdm=sc->sc_rd; else ++cdm - -/* only called from one place, so may as well integrate */ -void -lerint(sc) - struct le_softc *sc; -{ - register int rmd = sc->sc_last_rd; - struct mds *cdm = &sc->sc_rd[rmd]; - - if (cdm->flags & LE_OWN) { - /* Race condition with loop below. */ -#ifdef LEDEBUG - if (sc->sc_debug) - printf("%s: extra rint\n", sc->sc_dev.dv_xname); -#endif - return; - } - - /* Process all buffers with valid data. */ - do { - if (cdm->flags & (LE_FRAM | LE_OFLO | LE_CRC | LE_RBUFF)) { - if ((cdm->flags & (LE_FRAM | LE_OFLO | LE_ENP)) == (LE_FRAM | LE_ENP)) - printf("%s: framing error\n", sc->sc_dev.dv_xname); - if ((cdm->flags & (LE_OFLO | LE_ENP)) == LE_OFLO) - printf("%s: overflow\n", sc->sc_dev.dv_xname); - if ((cdm->flags & (LE_CRC | LE_OFLO | LE_ENP)) == (LE_CRC | LE_ENP)) - printf("%s: crc mismatch\n", sc->sc_dev.dv_xname); - if (cdm->flags & LE_RBUFF) - printf("%s: receive buffer error\n", sc->sc_dev.dv_xname); - } else if (cdm->flags & (LE_STP | LE_ENP) != (LE_STP | LE_ENP)) { - do { - cdm->mcnt = 0; - cdm->flags |= LE_OWN; - NEXTRDS; - } while ((cdm->flags & (LE_OWN | LE_ERR | LE_STP | LE_ENP)) == 0); - sc->sc_last_rd = rmd; - printf("%s: chained buffer\n", sc->sc_dev.dv_xname); - if ((cdm->flags & (LE_OWN | LE_ERR | LE_STP | LE_ENP)) != LE_ENP) { - lereset(sc); - return; - } - } else { -#ifdef LEDEBUG - if (sc->sc_debug) - recv_print(sc, sc->sc_last_rd); -#endif - leread(sc, sc->sc_rbuf + (BUFSIZE * rmd), - (int)cdm->mcnt); - sc->sc_arpcom.ac_if.if_ipackets++; - } - - cdm->bcnt = -BUFSIZE; - cdm->mcnt = 0; - cdm->flags |= LE_OWN; - NEXTRDS; -#ifdef LEDEBUG - if (sc->sc_debug) - printf("sc->sc_last_rd = %x, cdm = %x\n", - sc->sc_last_rd, cdm); -#endif - } while ((cdm->flags & LE_OWN) == 0); - - sc->sc_last_rd = rmd; -} - -/* - * Pass a packet to the higher levels. - */ -void -leread(sc, buf, len) - register struct le_softc *sc; - u_char *buf; - int len; -{ - struct ifnet *ifp; - struct mbuf *m; - struct ether_header *eh; - - len -= 4; - if (len <= 0) - return; - - /* Pull packet off interface. */ - ifp = &sc->sc_arpcom.ac_if; - m = leget(buf, len, ifp); - if (m == 0) - return; - - /* We assume that the header fit entirely in one mbuf. */ - eh = mtod(m, struct ether_header *); - -#if NBPFILTER > 0 - /* - * Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to BPF. - */ - if (ifp->if_bpf) { - bpf_mtap(ifp->if_bpf, m); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - */ - if ((ifp->if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */ - bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0) { - m_freem(m); - return; - } - } -#endif - - /* We assume that the header fit entirely in one mbuf. */ - m->m_pkthdr.len -= sizeof(*eh); - m->m_len -= sizeof(*eh); - m->m_data += sizeof(*eh); - - ether_input(ifp, eh, m); -} - -/* - * Supporting routines - */ - -/* - * Pull data off an interface. - * Len is length of data, with local net header stripped. - * We copy the data into mbufs. When full cluster sized units are present - * we copy into clusters. - */ -struct mbuf * -leget(buf, totlen, ifp) - u_char *buf; - int totlen; - struct ifnet *ifp; -{ - struct mbuf *top, **mp, *m; - int len; - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return 0; - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = totlen; - len = MHLEN; - top = 0; - mp = ⊤ - - while (totlen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - m_freem(top); - return 0; - } - len = MLEN; - } - if (totlen >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - len = MCLBYTES; - } - m->m_len = len = min(totlen, len); - bcopy((caddr_t)buf, mtod(m, caddr_t), len); - buf += len; - totlen -= len; - *mp = m; - mp = &m->m_next; - } - - return top; -} - -/* - * Process an ioctl request. - */ -int -leioctl(ifp, cmd, data) - register struct ifnet *ifp; - u_long cmd; - caddr_t data; -{ - struct le_softc *sc = lecd.cd_devs[ifp->if_unit]; - struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; - int s, error = 0; - - s = splimp(); - - switch (cmd) { - - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - leinit(sc); /* before arpwhohas */ - /* - * See if another station has *our* IP address. - * i.e.: There is an address conflict! If a - * conflict exists, a message is sent to the - * console. - */ - sc->sc_arpcom.ac_ipaddr = IA_SIN(ifa)->sin_addr; - arpwhohas(&sc->sc_arpcom, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - /* XXX - This code is probably wrong. */ - case AF_NS: - { - register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr; - - if (ns_nullhost(*ina)) - ina->x_host = - *(union ns_host *)(sc->sc_arpcom.ac_enaddr); - else - bcopy(ina->x_host.c_host, - sc->sc_arpcom.ac_enaddr, - sizeof(sc->sc_arpcom.ac_enaddr)); - /* Set new address. */ - leinit(sc); - break; - } -#endif - default: - leinit(sc); - break; - } - break; - - case SIOCSIFFLAGS: - /* - * If interface is marked down and it is running, then stop it - */ - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, then - * stop it. - */ - lestop(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, then - * start it. - */ - leinit(sc); - } else { - /* - * Reset the interface to pick up changes in any other - * flags that affect hardware registers. - */ - /*lestop(sc);*/ - leinit(sc); - } -#ifdef LEDEBUG - if (ifp->if_flags & IFF_DEBUG) - sc->sc_debug = 1; - else - sc->sc_debug = 0; -#endif - break; - - case SIOCADDMULTI: - case SIOCDELMULTI: - error = (cmd == SIOCADDMULTI) ? - ether_addmulti(ifr, &sc->sc_arpcom): - ether_delmulti(ifr, &sc->sc_arpcom); - - if (error == ENETRESET) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - leinit(sc); - error = 0; - } - break; - - default: - error = EINVAL; - } - (void) splx(s); - return error; -} - -#ifdef LEDEBUG -void -recv_print(sc, no) - struct le_softc *sc; - int no; -{ - struct mds *rmd; - int i, printed = 0; - u_short len; - - rmd = &sc->sc_rd[no]; - len = rmd->mcnt; - printf("%s: receive buffer %d, len = %d\n", sc->sc_dev.dv_xname, no, - len); - printf("%s: status %x\n", sc->sc_dev.dv_xname, lerdcsr(sc, 0)); - for (i = 0; i < len; i++) { - if (!printed) { - printed = 1; - printf("%s: data: ", sc->sc_dev.dv_xname); - } - printf("%x ", *(sc->sc_rbuf + (BUFSIZE*no) + i)); - } - if (printed) - printf("\n"); -} - -void -xmit_print(sc, no) - struct le_softc *sc; - int no; -{ - struct mds *rmd; - int i, printed=0; - u_short len; - - rmd = &sc->sc_td[no]; - len = -rmd->bcnt; - printf("%s: transmit buffer %d, len = %d\n", sc->sc_dev.dv_xname, no, - len); - printf("%s: status %x\n", sc->sc_dev.dv_xname, lerdcsr(sc, 0)); - printf("%s: addr %x, flags %x, bcnt %x, mcnt %x\n", - sc->sc_dev.dv_xname, rmd->addr, rmd->flags, rmd->bcnt, rmd->mcnt); - for (i = 0; i < len; i++) { - if (!printed) { - printed = 1; - printf("%s: data: ", sc->sc_dev.dv_xname); - } - printf("%x ", *(sc->sc_tbuf + (BUFSIZE*no) + i)); - } - if (printed) - printf("\n"); -} -#endif /* LEDEBUG */ - -/* - * Set up the logical address filter. - */ -void -lesetladrf(ac, af) - struct arpcom *ac; - u_long *af; -{ - struct ifnet *ifp = &ac->ac_if; - struct ether_multi *enm; - register u_char *cp, c; - register u_long crc; - register int i, len; - struct ether_multistep step; - - /* - * Set up multicast address filter by passing all multicast addresses - * through a crc generator, and then using the high order 6 bits as an - * index into the 64 bit logical address filter. The high order bit - * selects the word, while the rest of the bits select the bit within - * the word. - */ - - if (ifp->if_flags & IFF_PROMISC) { - ifp->if_flags |= IFF_ALLMULTI; - af[0] = af[1] = 0xffffffff; - return; - } - - af[0] = af[1] = 0; - ETHER_FIRST_MULTI(step, ac, enm); - while (enm != NULL) { - if (bcmp(enm->enm_addrlo, enm->enm_addrhi, - sizeof(enm->enm_addrlo)) != 0) { - /* - * We must listen to a range of multicast addresses. - * For now, just accept all multicasts, rather than - * trying to set only those filter bits needed to match - * the range. (At this time, the only use of address - * ranges is for IP multicast routing, for which the - * range is big enough to require all bits set.) - */ - ifp->if_flags |= IFF_ALLMULTI; - af[0] = af[1] = 0xffffffff; - return; - } - - cp = enm->enm_addrlo; - crc = 0xffffffff; - for (len = sizeof(enm->enm_addrlo); --len >= 0;) { - c = *cp++; - for (i = 8; --i >= 0;) { - if ((crc & 0x01) ^ (c & 0x01)) { - crc >>= 1; - crc ^= 0x6db88320 | 0x80000000; - } else - crc >>= 1; - c >>= 1; - } - } - /* Just want the 6 most significant bits. */ - crc >>= 26; - - /* Turn on the corresponding bit in the filter. */ - af[crc >> 5] |= 1 << ((crc & 0x1f) ^ 0); - - ETHER_NEXT_MULTI(step, enm); - } - ifp->if_flags &= ~IFF_ALLMULTI; -} diff --git a/sys/arch/i386/isa/if_lereg.h b/sys/arch/i386/isa/if_lereg.h deleted file mode 100644 index ef665be13277..000000000000 --- a/sys/arch/i386/isa/if_lereg.h +++ /dev/null @@ -1,136 +0,0 @@ -/* $NetBSD: if_lereg.h,v 1.3 1994/10/27 04:17:42 cgd Exp $ */ - -/* - * LANCE Ethernet driver header file - * - * Copyright (c) 1994 Charles Hannum. - * - * Copyright (C) 1993, Paul Richards. This software may be used, modified, - * copied, distributed, and sold, in both source and binary form provided - * that the above copyright and these terms are retained. Under no - * circumstances is the author responsible for the proper functioning - * of this software, nor does the author assume any responsibility - * for damages incurred with its use. - */ - -/* Declarations specific to this driver */ -#define NTBUF 2 -#define TLEN 1 -#define NRBUF 8 -#define RLEN 3 -#define BUFSIZE 1518 - -/* Board types */ -#define BICC 1 -#define BICC_RDP 0xc -#define BICC_RAP 0xe -#define NE2100 2 -#define NE2100_RDP 0x10 -#define NE2100_RAP 0x12 -#define DEPCA 3 -#define DEPCA_RDP 0x4 -#define DEPCA_RAP 0x6 - -/* Chip types */ -#define PROBE_MASK 0x0007 -#define LANCE 1 -#define LANCE_MASK 0x0007 -#define PCnet_ISA 2 -#define PCnet_ISA_MASK 0x0000 - -/* - * Control and status bits - */ -#define LE_SERR 0x8000 -#define LE_BABL 0x4000 -#define LE_CERR 0x2000 -#define LE_MISS 0x1000 -#define LE_MERR 0x0800 -#define LE_RINT 0x0400 -#define LE_TINT 0x0200 -#define LE_IDON 0x0100 -#define LE_INTR 0x0080 -#define LE_INEA 0x0040 -#define LE_RXON 0x0020 -#define LE_TXON 0x0010 -#define LE_TDMD 0x0008 -#define LE_STOP 0x0004 -#define LE_STRT 0x0002 -#define LE_INIT 0x0001 - -#define LE_BSWP 0x0004 -#define LE_ACON 0x0002 -#define LE_BCON 0x0001 - -/* - * LANCE initialization block - */ -struct init_block { - u_short mode; /* mode register */ - u_char padr[6]; /* ethernet address */ - u_long ladrf[2]; /* logical address filter (multicast) */ - u_short rdra; /* low order pointer to receive ring */ - u_short rlen; /* high order pointer and no. rings */ - u_short tdra; /* low order pointer to transmit ring */ - u_short tlen; /* high order pointer and no rings */ -}; - -/* - * Mode bits -- init_block - */ -#define LE_PROM 0x8000 /* promiscuous */ -#define LE_INTL 0x0040 /* internal loopback */ -#define LE_DRTY 0x0020 /* disable retry */ -#define LE_COLL 0x0010 /* force collision */ -#define LE_DTCR 0x0008 /* disable transmit crc */ -#define LE_LOOP 0x0004 /* loopback */ -#define LE_DTX 0x0002 /* disable transmitter */ -#define LE_DRX 0x0001 /* disable receiver */ -#define LE_NORMAL 0x0000 - -/* - * Message descriptor - */ -struct mds { - u_short addr; - u_short flags; - u_short bcnt; - u_short mcnt; -}; - -/* Message descriptor flags */ -#define LE_OWN 0x8000 /* owner bit, 0=host, 1=LANCE */ -#define LE_ERR 0x4000 /* error */ -#define LE_STP 0x0200 /* start of packet */ -#define LE_ENP 0x0100 /* end of packet */ - -/* Receive ring status flags */ -#define LE_FRAM 0x2000 /* framing error error */ -#define LE_OFLO 0x1000 /* silo overflow */ -#define LE_CRC 0x0800 /* CRC error */ -#define LE_RBUFF 0x0400 /* buffer error */ - -/* Transmit ring status flags */ -#define LE_MORE 0x1000 /* more than 1 retry */ -#define LE_ONE 0x0800 /* one retry */ -#define LE_DEF 0x0400 /* deferred transmit */ - -/* Transmit errors */ -#define LE_TBUFF 0x8000 /* buffer error */ -#define LE_UFLO 0x4000 /* silo underflow */ -#define LE_LCOL 0x1000 /* late collision */ -#define LE_LCAR 0x0800 /* loss of carrier */ -#define LE_RTRY 0x0400 /* tried 16 times */ - - -/* DEPCA-specific definitions */ -#define DEPCA_CSR 0x0 -#define DEPCA_CSR_SHE 0x80 /* Shared memory enabled */ -#define DEPCA_CSR_SWAP32 0x40 /* Byte swapped */ -#define DEPCA_CSR_DUM 0x08 /* rev E compatibility */ -#define DEPCA_CSR_IM 0x04 /* Interrupt masked */ -#define DEPCA_CSR_IEN 0x02 /* Interrupt enabled */ -#define DEPCA_CSR_NORMAL \ - (DEPCA_CSR_SHE | DEPCA_CSR_DUM | DEPCA_CSR_IEN) - -#define DEPCA_ADP 0xc diff --git a/sys/arch/i386/isa/lpt.c b/sys/arch/i386/isa/lpt.c deleted file mode 100644 index ef83f8477b64..000000000000 --- a/sys/arch/i386/isa/lpt.c +++ /dev/null @@ -1,533 +0,0 @@ -/* $NetBSD: lpt.c,v 1.28 1995/01/26 07:35:49 mycroft Exp $ */ - -/* - * Copyright (c) 1993, 1994 Charles Hannum. - * Copyright (c) 1990 William F. Jolitz, TeleMuse - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This software is a component of "386BSD" developed by - * William F. Jolitz, TeleMuse. - * 4. Neither the name of the developer nor the name "386BSD" - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS A COMPONENT OF 386BSD DEVELOPED BY WILLIAM F. JOLITZ - * AND IS INTENDED FOR RESEARCH AND EDUCATIONAL PURPOSES ONLY. THIS - * SOFTWARE SHOULD NOT BE CONSIDERED TO BE A COMMERCIAL PRODUCT. - * THE DEVELOPER URGES THAT USERS WHO REQUIRE A COMMERCIAL PRODUCT - * NOT MAKE USE OF THIS WORK. - * - * FOR USERS WHO WISH TO UNDERSTAND THE 386BSD SYSTEM DEVELOPED - * BY WILLIAM F. JOLITZ, WE RECOMMEND THE USER STUDY WRITTEN - * REFERENCES SUCH AS THE "PORTING UNIX TO THE 386" SERIES - * (BEGINNING JANUARY 1991 "DR. DOBBS JOURNAL", USA AND BEGINNING - * JUNE 1991 "UNIX MAGAZIN", GERMANY) BY WILLIAM F. JOLITZ AND - * LYNNE GREER JOLITZ, AS WELL AS OTHER BOOKS ON UNIX AND THE - * ON-LINE 386BSD USER MANUAL BEFORE USE. A BOOK DISCUSSING THE INTERNALS - * OF 386BSD ENTITLED "386BSD FROM THE INSIDE OUT" WILL BE AVAILABLE LATE 1992. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Device Driver for AT parallel printer port - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#define TIMEOUT hz*16 /* wait up to 16 seconds for a ready */ -#define STEP hz/4 - -#define LPTPRI (PZERO+8) -#define LPT_BSIZE 1024 - -#if !defined(DEBUG) || !defined(notdef) -#define lprintf -#else -#define lprintf if (lptdebug) printf -int lptdebug = 1; -#endif - -struct lpt_softc { - struct device sc_dev; - struct intrhand sc_ih; - - size_t sc_count; - struct buf *sc_inbuf; - u_char *sc_cp; - int sc_spinmax; - int sc_iobase; - int sc_irq; - u_char sc_state; -#define LPT_OPEN 0x01 /* device is open */ -#define LPT_OBUSY 0x02 /* printer is busy doing output */ -#define LPT_INIT 0x04 /* waiting to initialize for open */ - u_char sc_flags; -#define LPT_AUTOLF 0x20 /* automatic LF on CR */ -#define LPT_NOPRIME 0x40 /* don't prime on open */ -#define LPT_NOINTR 0x80 /* do not use interrupt */ - u_char sc_control; - u_char sc_laststatus; -}; - -int lptprobe __P((struct device *, void *, void *)); -void lptattach __P((struct device *, struct device *, void *)); -int lptintr __P((struct lpt_softc *)); - -struct cfdriver lptcd = { - NULL, "lpt", lptprobe, lptattach, DV_TTY, sizeof(struct lpt_softc) -}; - -#define LPTUNIT(s) (minor(s) & 0x1f) -#define LPTFLAGS(s) (minor(s) & 0xe0) - -#define LPS_INVERT (LPS_SELECT|LPS_NERR|LPS_NBSY|LPS_NACK) -#define LPS_MASK (LPS_SELECT|LPS_NERR|LPS_NBSY|LPS_NACK|LPS_NOPAPER) -#define NOT_READY() ((inb(iobase + lpt_status) ^ LPS_INVERT) & LPS_MASK) -#define NOT_READY_ERR() not_ready(inb(iobase + lpt_status), sc) -static int not_ready __P((u_char, struct lpt_softc *)); - -static void lptwakeup __P((void *arg)); -static int pushbytes __P((struct lpt_softc *)); - -/* - * Internal routine to lptprobe to do port tests of one byte value. - */ -int -lpt_port_test(port, data, mask) - int port; - u_char data, mask; -{ - int timeout; - u_char temp; - - data &= mask; - outb(port, data); - timeout = 1000; - do { - delay(10); - temp = inb(port) & mask; - } while (temp != data && --timeout); - lprintf("lpt: port=0x%x out=0x%x in=0x%x timeout=%d\n", port, data, - temp, timeout); - return (temp == data); -} - -/* - * Logic: - * 1) You should be able to write to and read back the same value - * to the data port. Do an alternating zeros, alternating ones, - * walking zero, and walking one test to check for stuck bits. - * - * 2) You should be able to write to and read back the same value - * to the control port lower 5 bits, the upper 3 bits are reserved - * per the IBM PC technical reference manauls and different boards - * do different things with them. Do an alternating zeros, alternating - * ones, walking zero, and walking one test to check for stuck bits. - * - * Some printers drag the strobe line down when the are powered off - * so this bit has been masked out of the control port test. - * - * XXX Some printers may not like a fast pulse on init or strobe, I - * don't know at this point, if that becomes a problem these bits - * should be turned off in the mask byte for the control port test. - * - * 3) Set the data and control ports to a value of 0 - */ -int -lptprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct isa_attach_args *ia = aux; - int iobase = ia->ia_iobase; - int port; - u_char mask, data; - int i; - -#ifdef DEBUG -#define ABORT do {printf("lptprobe: mask %x data %x failed\n", mask, data); \ - return 0;} while (0) -#else -#define ABORT return 0 -#endif - - port = iobase + lpt_data; - mask = 0xff; - - data = 0x55; /* Alternating zeros */ - if (!lpt_port_test(port, data, mask)) - ABORT; - - data = 0xaa; /* Alternating ones */ - if (!lpt_port_test(port, data, mask)) - ABORT; - - for (i = 0; i < CHAR_BIT; i++) { /* Walking zero */ - data = ~(1 << i); - if (!lpt_port_test(port, data, mask)) - ABORT; - } - - for (i = 0; i < CHAR_BIT; i++) { /* Walking one */ - data = (1 << i); - if (!lpt_port_test(port, data, mask)) - ABORT; - } - - outb(iobase + lpt_data, 0); - outb(iobase + lpt_control, 0); - - ia->ia_iosize = LPT_NPORTS; - ia->ia_msize = 0; - return 1; -} - -void -lptattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct lpt_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - int iobase = ia->ia_iobase; - - if (ia->ia_irq != IRQUNK) - printf("\n"); - else - printf(": polled\n"); - - sc->sc_iobase = iobase; - sc->sc_irq = ia->ia_irq; - sc->sc_state = 0; - outb(iobase + lpt_control, LPC_NINIT); - - if (ia->ia_irq != IRQUNK) { - sc->sc_ih.ih_fun = lptintr; - sc->sc_ih.ih_arg = sc; - sc->sc_ih.ih_level = IPL_NONE; - intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih); - } -} - -/* - * Reset the printer, then wait until it's selected and not busy. - */ -int -lptopen(dev, flag) - dev_t dev; - int flag; -{ - int unit = LPTUNIT(dev); - u_char flags = LPTFLAGS(dev); - struct lpt_softc *sc; - int iobase; - u_char control; - int error; - int spin; - - if (unit >= lptcd.cd_ndevs) - return ENXIO; - sc = lptcd.cd_devs[unit]; - if (!sc) - return ENXIO; - - if (sc->sc_irq == IRQUNK && (flags & LPT_NOINTR) == 0) - return ENXIO; - -#ifdef DIAGNOSTIC - if (sc->sc_state) - printf("%s: stat=0x%x not zero\n", sc->sc_dev.dv_xname, - sc->sc_state); -#endif - - if (sc->sc_state) - return EBUSY; - - sc->sc_state = LPT_INIT; - sc->sc_flags = flags; - lprintf("%s: open: flags=0x%x\n", sc->sc_dev.dv_xname, flags); - iobase = sc->sc_iobase; - - if ((flags & LPT_NOPRIME) == 0) { - /* assert INIT for 100 usec to start up printer */ - outb(iobase + lpt_control, LPC_SELECT); - delay(100); - } - - control = LPC_SELECT | LPC_NINIT; - outb(iobase + lpt_control, control); - - /* wait till ready (printer running diagnostics) */ - for (spin = 0; NOT_READY_ERR(); spin += STEP) { - if (spin >= TIMEOUT) { - sc->sc_state = 0; - return EBUSY; - } - - /* wait 1/4 second, give up if we get a signal */ - if (error = tsleep((caddr_t)sc, LPTPRI | PCATCH, "lptopen", - STEP) != EWOULDBLOCK) { - sc->sc_state = 0; - return error; - } - } - - if ((flags & LPT_NOINTR) == 0) - control |= LPC_IENABLE; - if (flags & LPT_AUTOLF) - control |= LPC_AUTOLF; - sc->sc_control = control; - outb(iobase + lpt_control, control); - - sc->sc_inbuf = geteblk(LPT_BSIZE); - sc->sc_count = 0; - sc->sc_state = LPT_OPEN; - - if ((sc->sc_flags & LPT_NOINTR) == 0) - lptwakeup(sc); - - lprintf("%s: opened\n", sc->sc_dev.dv_xname); - return 0; -} - -int -not_ready(status, sc) - u_char status; - struct lpt_softc *sc; -{ - u_char new; - - status = (status ^ LPS_INVERT) & LPS_MASK; - new = status & ~sc->sc_laststatus; - sc->sc_laststatus = status; - - if (new & LPS_SELECT) - log(LOG_NOTICE, "%s: offline\n", sc->sc_dev.dv_xname); - else if (new & LPS_NOPAPER) - log(LOG_NOTICE, "%s: out of paper\n", sc->sc_dev.dv_xname); - else if (new & LPS_NERR) - log(LOG_NOTICE, "%s: output error\n", sc->sc_dev.dv_xname); - - return status; -} - -void -lptwakeup(arg) - void *arg; -{ - struct lpt_softc *sc = arg; - int s; - - s = spltty(); - lptintr(sc); - splx(s); - - timeout(lptwakeup, sc, STEP); -} - -/* - * Close the device, and free the local line buffer. - */ -lptclose(dev, flag) - dev_t dev; - int flag; -{ - int unit = LPTUNIT(dev); - struct lpt_softc *sc = lptcd.cd_devs[unit]; - int iobase = sc->sc_iobase; - - if (sc->sc_count) - (void) pushbytes(sc); - - if ((sc->sc_flags & LPT_NOINTR) == 0) - untimeout(lptwakeup, sc); - - outb(iobase + lpt_control, LPC_NINIT); - sc->sc_state = 0; - outb(iobase + lpt_control, LPC_NINIT); - brelse(sc->sc_inbuf); - - lprintf("%s: closed\n", sc->sc_dev.dv_xname); - return 0; -} - -int -pushbytes(sc) - struct lpt_softc *sc; -{ - int iobase = sc->sc_iobase; - int error; - - if (sc->sc_flags & LPT_NOINTR) { - int spin, tic; - u_char control = sc->sc_control; - - while (sc->sc_count > 0) { - spin = 0; - while (NOT_READY()) { - if (++spin < sc->sc_spinmax) - continue; - tic = 0; - /* adapt busy-wait algorithm */ - sc->sc_spinmax++; - while (NOT_READY_ERR()) { - /* exponential backoff */ - tic = tic + tic + 1; - if (tic > TIMEOUT) - tic = TIMEOUT; - error = tsleep((caddr_t)sc, - LPTPRI | PCATCH, "lptpsh", tic); - if (error != EWOULDBLOCK) - return error; - } - break; - } - - outb(iobase + lpt_data, *sc->sc_cp++); - outb(iobase + lpt_control, control | LPC_STROBE); - sc->sc_count--; - outb(iobase + lpt_control, control); - - /* adapt busy-wait algorithm */ - if (spin*2 + 16 < sc->sc_spinmax) - sc->sc_spinmax--; - } - } else { - int s; - - while (sc->sc_count > 0) { - /* if the printer is ready for a char, give it one */ - if ((sc->sc_state & LPT_OBUSY) == 0) { - lprintf("%s: write %d\n", sc->sc_dev.dv_xname, - sc->sc_count); - s = spltty(); - (void) lptintr(sc); - splx(s); - } - if (error = tsleep((caddr_t)sc, LPTPRI | PCATCH, - "lptwrite2", 0)) - return error; - } - } - return 0; -} - -/* - * Copy a line from user space to a local buffer, then call putc to get the - * chars moved to the output queue. - */ -lptwrite(dev, uio) - dev_t dev; - struct uio *uio; -{ - struct lpt_softc *sc = lptcd.cd_devs[LPTUNIT(dev)]; - size_t n; - int error = 0; - - while (n = min(LPT_BSIZE, uio->uio_resid)) { - uiomove(sc->sc_cp = sc->sc_inbuf->b_data, n, uio); - sc->sc_count = n; - error = pushbytes(sc); - if (error) { - /* - * Return accurate residual if interrupted or timed - * out. - */ - uio->uio_resid += sc->sc_count; - sc->sc_count = 0; - return error; - } - } - return 0; -} - -/* - * Handle printer interrupts which occur when the printer is ready to accept - * another char. - */ -int -lptintr(sc) - struct lpt_softc *sc; -{ - int iobase = sc->sc_iobase; - -#if 0 - if ((sc->sc_state & LPT_OPEN) == 0) - return 0; -#endif - - /* is printer online and ready for output */ - if (NOT_READY() && NOT_READY_ERR()) - return 0; - - if (sc->sc_count) { - u_char control = sc->sc_control; - /* send char */ - outb(iobase + lpt_data, *sc->sc_cp++); - outb(iobase + lpt_control, control | LPC_STROBE); - sc->sc_count--; - outb(iobase + lpt_control, control); - sc->sc_state |= LPT_OBUSY; - } else - sc->sc_state &= ~LPT_OBUSY; - - if (sc->sc_count == 0) { - /* none, wake up the top half to get more */ - wakeup((caddr_t)sc); - } - - return 1; -} - -int -lptioctl(dev, cmd, data, flag) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; -{ - int error = 0; - - switch (cmd) { - default: - error = ENODEV; - } - - return error; -} diff --git a/sys/arch/i386/isa/lptreg.h b/sys/arch/i386/isa/lptreg.h deleted file mode 100644 index b308fe24625f..000000000000 --- a/sys/arch/i386/isa/lptreg.h +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: lptreg.h,v 1.4 1994/10/27 04:17:56 cgd Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)lptreg.h 1.1 (Berkeley) 12/19/90 - */ - -/* - * AT Parallel Port (for lineprinter) - * Interface port and bit definitions - * Written by William Jolitz 12/18/90 - * Copyright (C) William Jolitz 1990 - */ - -#define lpt_data 0 /* Data to/from printer (R/W) */ - -#define lpt_status 1 /* Status of printer (R) */ -#define LPS_NERR 0x08 /* printer no error */ -#define LPS_SELECT 0x10 /* printer selected */ -#define LPS_NOPAPER 0x20 /* printer out of paper */ -#define LPS_NACK 0x40 /* printer no ack of data */ -#define LPS_NBSY 0x80 /* printer no ack of data */ - -#define lpt_control 2 /* Control printer (R/W) */ -#define LPC_STROBE 0x01 /* strobe data to printer */ -#define LPC_AUTOLF 0x02 /* automatic linefeed */ -#define LPC_NINIT 0x04 /* initialize printer */ -#define LPC_SELECT 0x08 /* printer selected */ -#define LPC_IENABLE 0x10 /* printer out of paper */ - -#define LPT_NPORTS 8 diff --git a/sys/arch/i386/isa/mcd.c b/sys/arch/i386/isa/mcd.c deleted file mode 100644 index a96683facfed..000000000000 --- a/sys/arch/i386/isa/mcd.c +++ /dev/null @@ -1,1338 +0,0 @@ -/* $NetBSD: mcd.c,v 1.26 1995/01/03 01:31:45 mycroft Exp $ */ - -/* - * Copyright (c) 1993, 1994 Charles Hannum. - * Copyright 1993 by Holger Veit (data part) - * Copyright 1993 by Brian Moore (audio part) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This software was developed by Holger Veit and Brian Moore - * for use with "386BSD" and similar operating systems. - * "Similar operating systems" includes mainly non-profit oriented - * systems for research and education, including but not restricted to - * "NetBSD", "FreeBSD", "Mach" (by CMU). - * 4. Neither the name of the developer(s) nor the name "386BSD" - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/*static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#ifndef MCDDEBUG -#define MCD_TRACE(fmt,a,b,c,d) -#else -#define MCD_TRACE(fmt,a,b,c,d) {if (sc->debug) {printf("%s: st=%02x: ", sc->sc_dev.dv_xname, sc->status); printf(fmt,a,b,c,d);}} -#endif - -#define MCDPART(dev) DISKPART(dev) -#define MCDUNIT(dev) DISKUNIT(dev) - -/* status */ -#define MCDAUDIOBSY MCD_ST_AUDIOBSY /* playing audio */ -#define MCDDSKCHNG MCD_ST_DSKCHNG /* sensed change of disk */ -#define MCDDSKIN MCD_ST_DSKIN /* sensed disk in drive */ -#define MCDDOOROPEN MCD_ST_DOOROPEN /* sensed door open */ - -/* toc */ -#define MCD_MAXTOCS 104 /* from the Linux driver */ -#define MCD_LASTPLUS1 170 /* special toc entry */ - -struct mcd_mbx { - struct mcd_softc *softc; - short retry; - short nblk; - int sz; - u_long skip; - struct buf *bp; - int p_offset; - short count; - short state; -#define MCD_S_BEGIN 0 -#define MCD_S_WAITSTAT 1 -#define MCD_S_WAITMODE 2 -#define MCD_S_WAITREAD 3 -}; - -struct mcd_softc { - struct device sc_dev; - struct dkdevice sc_dk; - struct intrhand sc_ih; - - int iobase; - short config; - short flags; -#define MCDOPEN 0x0001 /* device opened */ -#define MCDVALID 0x0002 /* parameters loaded */ -#define MCDLABEL 0x0004 /* label is read */ -#define MCDVOLINFO 0x0008 /* already read volinfo */ -#define MCDTOC 0x0010 /* already read toc */ -#define MCDMBXBSY 0x0020 /* local mbx is busy */ - short status; - int blksize; - u_long disksize; - struct mcd_volinfo volinfo; - struct mcd_qchninfo toc[MCD_MAXTOCS]; - short audio_status; - struct mcd_read2 lastpb; - short debug; - struct buf buf_queue; - struct mcd_mbx mbx; -}; - -/* prototypes */ -int mcdopen __P((dev_t, int, int, struct proc *)); -int mcdclose __P((dev_t, int, int)); -int mcd_start __P((struct mcd_softc *)); -int mcdioctl __P((dev_t, u_long, caddr_t, int, struct proc *)); -int mcd_getdisklabel __P((struct mcd_softc *)); -int mcdsize __P((dev_t)); -void mcd_configure __P((struct mcd_softc *)); -int mcd_waitrdy __P((int, int)); -int mcd_getreply __P((struct mcd_softc *, int)); -int mcd_getstat __P((struct mcd_softc *, int)); -void mcd_setflags __P((struct mcd_softc *)); -int mcd_get __P((struct mcd_softc *, char *, int)); -int mcd_send __P((struct mcd_softc *, int, int)); -int bcd2bin __P((bcd_t)); -bcd_t bin2bcd __P((int)); -void hsg2msf __P((int, bcd_t *)); -int msf2hsg __P((bcd_t *)); -int mcd_volinfo __P((struct mcd_softc *)); -int mcdintr __P((struct mcd_softc *)); -int mcd_setmode __P((struct mcd_softc *, int)); -void mcd_doread __P((void *)); -int mcd_toc_header __P((struct mcd_softc *, struct ioc_toc_header *)); -int mcd_read_toc __P((struct mcd_softc *)); -int mcd_toc_entry __P((struct mcd_softc *, struct ioc_read_toc_entry *)); -int mcd_stop __P((struct mcd_softc *)); -int mcd_getqchan __P((struct mcd_softc *, struct mcd_qchninfo *)); -int mcd_subchan __P((struct mcd_softc *, struct ioc_read_subchannel *)); -int mcd_playtracks __P((struct mcd_softc *, struct ioc_play_track *)); -int mcd_play __P((struct mcd_softc *, struct mcd_read2 *)); -int mcd_pause __P((struct mcd_softc *)); -int mcd_resume __P((struct mcd_softc *)); - -int mcdprobe __P((struct device *, void *, void *)); -void mcdattach __P((struct device *, struct device *, void *)); -void mcdstrategy __P((struct buf *)); - -struct cfdriver mcdcd = { - NULL, "mcd", mcdprobe, mcdattach, DV_DISK, sizeof(struct mcd_softc) -}; -struct dkdriver mcddkdriver = { mcdstrategy }; - -#define mcd_put(port,byte) outb(port,byte) - -#define MCD_RETRIES 5 -#define MCD_RDRETRIES 8 - -#define MCDBLK 2048 /* for cooked mode */ -#define MCDRBLK 2352 /* for raw mode */ - -/* several delays */ -#define RDELAY_WAITSTAT 300 -#define RDELAY_WAITMODE 300 -#define RDELAY_WAITREAD 800 - -#define DELAY_STATUS 10000l /* 10000 * 1us */ -#define DELAY_GETREPLY 200000l /* 200000 * 2us */ -#define DELAY_SEEKREAD 20000l /* 20000 * 1us */ - -void -mcdattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct mcd_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - -#ifdef notyet - /* Wire controller for interrupts and DMA. */ - mcd_configure(sc); -#endif - - printf("\n"); - - sc->flags = 0; - sc->sc_dk.dk_driver = &mcddkdriver; - - sc->sc_ih.ih_fun = mcdintr; - sc->sc_ih.ih_arg = sc; - sc->sc_ih.ih_level = IPL_BIO; - intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih); -} - -int -mcdopen(dev, flag, fmt, p) - dev_t dev; - int flag, fmt; - struct proc *p; -{ - int unit, part; - struct mcd_softc *sc; - - unit = MCDUNIT(dev); - if (unit >= mcdcd.cd_ndevs) - return ENXIO; - sc = mcdcd.cd_devs[unit]; - if (!sc) - return ENXIO; - - part = MCDPART(dev); - - /* If it's been invalidated forget the label. */ - if ((sc->flags & MCDVALID) == 0) { - sc->flags &= ~(MCDLABEL | MCDVOLINFO | MCDTOC); - - /* If any partition still open, then don't allow fresh open. */ - if (sc->sc_dk.dk_openmask != 0) - return ENXIO; - } - - if (mcd_getstat(sc, 1) < 0) - return ENXIO; - - if (mcdsize(dev) < 0) { - printf("%s: failed to get disk size\n", sc->sc_dev.dv_xname); - return ENXIO; - } - - sc->flags |= MCDVALID; - - /* XXX Get a default disklabel. */ - mcd_getdisklabel(sc); - - MCD_TRACE("open: partition=%d disksize=%d blksize=%d\n", part, - sc->disksize, sc->blksize, 0); - - if (part != RAW_PART && - (part >= sc->sc_dk.dk_label.d_npartitions || - sc->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED)) - return ENXIO; - - /* Insure only one open at a time. */ - switch (fmt) { - case S_IFCHR: - sc->sc_dk.dk_copenmask |= (1 << part); - break; - case S_IFBLK: - sc->sc_dk.dk_bopenmask |= (1 << part); - break; - } - sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask; - - return 0; -} - -int -mcdclose(dev, flag, fmt) - dev_t dev; - int flag, fmt; -{ - struct mcd_softc *sc = mcdcd.cd_devs[MCDUNIT(dev)]; - int part = MCDPART(dev); - - MCD_TRACE("close: partition=%d\n", part, 0, 0, 0); - - /* Get status. */ - mcd_getstat(sc, 1); - - switch (fmt) { - case S_IFCHR: - sc->sc_dk.dk_copenmask &= ~(1 << part); - break; - case S_IFBLK: - sc->sc_dk.dk_bopenmask &= ~(1 << part); - break; - } - sc->sc_dk.dk_openmask = sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask; - - return 0; -} - -void -mcdstrategy(bp) - struct buf *bp; -{ - struct mcd_softc *sc = mcdcd.cd_devs[MCDUNIT(bp->b_dev)]; - struct buf *qp; - int s; - - /* Test validity. */ - MCD_TRACE("strategy: buf=0x%lx blkno=%ld bcount=%ld\n", bp, - bp->b_blkno, bp->b_bcount, 0); - if (bp->b_blkno < 0) { - printf("%s: strategy: blkno=%d bcount=%d\n", - sc->sc_dev.dv_xname, bp->b_blkno, bp->b_bcount); - bp->b_error = EINVAL; - goto bad; - } - - /* If device invalidated (e.g. media change, door open), error. */ - if (!(sc->flags & MCDVALID)) { - MCD_TRACE("strategy: drive not valid\n", 0, 0, 0, 0); - bp->b_error = EIO; - goto bad; - } - - /* Check for read only. */ - if (!(bp->b_flags & B_READ)) { - bp->b_error = EROFS; - goto bad; - } - - /* No data to read. */ - if (bp->b_bcount == 0) - goto done; - - /* For non raw access, check partition limits. */ - if (MCDPART(bp->b_dev) != RAW_PART) { - if (!(sc->flags & MCDLABEL)) { - bp->b_error = EIO; - goto bad; - } - /* Adjust transfer if necessary. */ - if (bounds_check_with_label(bp, &sc->sc_dk.dk_label, 0) <= 0) - goto done; - } - - /* Queue it. */ - qp = &sc->buf_queue; - s = splbio(); - disksort(qp, bp); - splx(s); - - /* Now check whether we can perform processing. */ - mcd_start(sc); - return; - -bad: - bp->b_flags |= B_ERROR; -done: - bp->b_resid = bp->b_bcount; - biodone(bp); -} - -int -mcd_start(sc) - struct mcd_softc *sc; -{ - struct buf *bp, *qp = &sc->buf_queue; - int part; - int s; - -loop: - s = splbio(); - - if (sc->flags & MCDMBXBSY) { - splx(s); - return; - } - - if ((bp = qp->b_actf) == 0) { - /* Nothing to do; */ - splx(s); - return; - } - - /* Block found to process; dequeue. */ - MCD_TRACE("start: found block bp=0x%x\n", bp, 0, 0, 0); - qp->b_actf = bp->b_actf; - splx(s); - - /* Changed media? */ - if (!(sc->flags & MCDVALID)) { - MCD_TRACE("start: drive not valid\n", 0, 0, 0, 0); - sc->flags &= ~(MCDLABEL | MCDVOLINFO | MCDTOC); - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - biodone(bp); - goto loop; - } - - sc->flags |= MCDMBXBSY; - sc->mbx.softc = sc; - sc->mbx.retry = MCD_RETRIES; - sc->mbx.bp = bp; - part = MCDPART(bp->b_dev); - if (part == RAW_PART) - sc->mbx.p_offset = 0; - else - sc->mbx.p_offset = - sc->sc_dk.dk_label.d_partitions[part].p_offset; - - /* Calling the read routine. */ - sc->mbx.state = MCD_S_BEGIN; - mcd_doread(&sc->mbx); - /* triggers mcd_start, when successful finished. */ -} - -int -mcdioctl(dev, cmd, addr, flags, p) - dev_t dev; - u_long cmd; - caddr_t addr; - int flags; - struct proc *p; -{ - struct mcd_softc *sc = mcdcd.cd_devs[MCDUNIT(dev)]; - - if (!(sc->flags & MCDVALID)) - return EIO; - - MCD_TRACE("ioctl: cmd=0x%x\n", cmd, 0, 0, 0); - - switch (cmd) { - case DIOCSBAD: - return EINVAL; - case CDIOCPLAYTRACKS: - return mcd_playtracks(sc, (struct ioc_play_track *)addr); - case CDIOCPLAYBLOCKS: - return mcd_play(sc, (struct mcd_read2 *)addr); - case CDIOCREADSUBCHANNEL: - return mcd_subchan(sc, (struct ioc_read_subchannel *)addr); - case CDIOREADTOCHEADER: - return mcd_toc_header(sc, (struct ioc_toc_header *)addr); - case CDIOREADTOCENTRYS: - return mcd_toc_entry(sc, (struct ioc_read_toc_entry *)addr); - case CDIOCSETPATCH: - case CDIOCGETVOL: - case CDIOCSETVOL: - case CDIOCSETMONO: - case CDIOCSETSTEREO: - case CDIOCSETMUTE: - case CDIOCSETLEFT: - case CDIOCSETRIGHT: - return EINVAL; - case CDIOCRESUME: - return mcd_resume(sc); - case CDIOCPAUSE: - return mcd_pause(sc); - case CDIOCSTART: - return EINVAL; - case CDIOCSTOP: - return mcd_stop(sc); - case CDIOCEJECT: - return EINVAL; - case CDIOCSETDEBUG: - sc->debug = 1; - return 0; - case CDIOCCLRDEBUG: - sc->debug = 0; - return 0; - case CDIOCRESET: - return EINVAL; - default: -#if 0 - case DIOCGDINFO: - case DIOCGPART: - case DIOCWDINFO: - case DIOCSDINFO: - case DIOCWLABEL: -#endif - return ENOTTY; - } -#ifdef DIAGNOSTIC - panic("mcdioctl: impossible"); -#endif -} - -/* - * This could have been taken from scsi/cd.c, but it is not clear - * whether the scsi cd driver is linked in. - */ -int -mcd_getdisklabel(sc) - struct mcd_softc *sc; -{ - - if (sc->flags & MCDLABEL) - return 0; - - bzero(&sc->sc_dk.dk_label, sizeof(struct disklabel)); - bzero(&sc->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel)); - strncpy(sc->sc_dk.dk_label.d_typename, "Mitsumi CD ROM", 16); - strncpy(sc->sc_dk.dk_label.d_packname, "unknown", 16); - sc->sc_dk.dk_label.d_secsize = sc->blksize; - sc->sc_dk.dk_label.d_nsectors = 100; - sc->sc_dk.dk_label.d_ntracks = 1; - sc->sc_dk.dk_label.d_ncylinders = (sc->disksize /100) + 1; - sc->sc_dk.dk_label.d_secpercyl = 100; - sc->sc_dk.dk_label.d_secperunit = sc->disksize; - sc->sc_dk.dk_label.d_rpm = 300; - sc->sc_dk.dk_label.d_interleave = 1; - sc->sc_dk.dk_label.d_flags = D_REMOVABLE; - sc->sc_dk.dk_label.d_npartitions= RAW_PART + 1; - sc->sc_dk.dk_label.d_partitions[0].p_offset = 0; - sc->sc_dk.dk_label.d_partitions[0].p_size = sc->disksize; - sc->sc_dk.dk_label.d_partitions[0].p_fstype = 9; - sc->sc_dk.dk_label.d_partitions[RAW_PART].p_offset = 0; - sc->sc_dk.dk_label.d_partitions[RAW_PART].p_size = sc->disksize; - sc->sc_dk.dk_label.d_partitions[RAW_PART].p_fstype = 9; - - sc->flags |= MCDLABEL; - return 0; -} - -int -mcdsize(dev) - dev_t dev; -{ - int size; - struct mcd_softc *sc = mcdcd.cd_devs[MCDUNIT(dev)]; - - if (mcd_volinfo(sc) >= 0) { - sc->blksize = MCDBLK; - size = msf2hsg(sc->volinfo.vol_msf); - sc->disksize = size * (MCDBLK / DEV_BSIZE); - return 0; - } - return -1; -} - -int -mcddump() -{ - - /* Not implemented. */ - return EINVAL; -} - -/*************************************************************** - * lower level of driver starts here - **************************************************************/ - -#ifdef notyet -static char irqs[] = { - 0x00, 0x00, 0x10, 0x20, 0x00, 0x30, 0x00, 0x00, - 0x00, 0x10, 0x40, 0x50, 0x00, 0x00, 0x00, 0x00 -}; - -static char drqs[] = { - 0x00, 0x01, 0x00, 0x03, 0x00, 0x05, 0x06, 0x07 -}; -#endif - -void -mcd_configure(sc) - struct mcd_softc *sc; -{ - - outb(sc->iobase + mcd_config, sc->config); -} - -int -mcdprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct mcd_softc *sc = match; - struct isa_attach_args *ia = aux; - int iobase = ia->ia_iobase; - int i; - int st, check, version; - -#ifdef notyet - /* Get irq/drq configuration word. */ - sc->config = irqs[ia->ia_irq]; -#endif - sc->iobase = iobase; - - /* Send a reset. */ - outb(iobase + mcd_reset, 0); - delay(1000000); - /* Get any pending status and throw away. */ - for (i = 10; i; i--) - inb(iobase + mcd_status); - delay(1000); - - /* Send get status command. */ - outb(iobase + mcd_command, MCD_CMDGETSTAT); - st = mcd_getreply(sc, DELAY_GETREPLY); - - if (st < 0) { -#ifdef DEBUG - printf("Mitsumi drive NOT detected\n"); -#endif - return 0; - } - -/* - * The following code uses the 0xDC command, it returns a M from the - * second byte and a number in the third. - * (I hope you have the right drive for that, most drives don't do!) - * Whole code entirely rewriten by veit@gmd.de, the changes accessed - * the drive in an illegal way. Proper way is to use the timeout - * driven routines mcd_getreply etc. rather than arbitrary delays. - */ - - delay(2000); - outb(iobase + mcd_command, MCD_CMDCONTINFO); - st = mcd_getreply(sc, DELAY_GETREPLY); - - if (st < 0) { -#ifdef DEBUG - printf("Mitsumi drive error\n"); -#endif - return 0; - } - check = mcd_getreply(sc, DELAY_GETREPLY); - if (check < 0) - return 0; - version = mcd_getreply(sc, DELAY_GETREPLY); - if (version < 0) - return 0; - /* Flush junk. */ - (void) mcd_getreply(sc, DELAY_GETREPLY); - - /* - * The following is code which is not guaranteed to work for all - * drives, because the meaning of the expected 'M' is not clear - * (M_itsumi is an obvious assumption, but I don't trust that). - * Also, the original hack had a bogus condition that always - * returned true. - */ - if (check != 'D' && check != 'M') { - printf("%s: unrecognized drive version %c%02x; will try to use it anyway\n", - sc->sc_dev.dv_xname, check, version); - } - -#ifdef DEBUG - printf("Mitsumi drive detected\n"); -#endif - ia->ia_iosize = 4; - ia->ia_msize = 0; - return 1; -} - -int -mcd_waitrdy(iobase, dly) - int iobase; - int dly; -{ - int i; - - /* Wait until xfer port senses data ready. */ - for (i = dly; i; i--) { - if ((inb(iobase + mcd_xfer) & MCD_ST_BUSY) == 0) - return 0; - delay(1); - } - return -1; -} - -int -mcd_getreply(sc, dly) - struct mcd_softc *sc; - int dly; -{ - int iobase = sc->iobase; - - /* Wait data to become ready. */ - if (mcd_waitrdy(iobase, dly) < 0) { - printf("%s: timeout in getreply\n", sc->sc_dev.dv_xname); - return -1; - } - - /* Get the data. */ - return inb(iobase + mcd_status); -} - -int -mcd_getstat(sc, sflg) - struct mcd_softc *sc; - int sflg; -{ - int i; - int iobase = sc->iobase; - - /* Get the status. */ - if (sflg) - outb(iobase + mcd_command, MCD_CMDGETSTAT); - i = mcd_getreply(sc, DELAY_GETREPLY); - if (i < 0) { - printf("%s: timeout in getstat\n", sc->sc_dev.dv_xname); - return -1; - } - - sc->status = i; - - mcd_setflags(sc); - return sc->status; -} - -void -mcd_setflags(sc) - struct mcd_softc *sc; -{ - - /* Check flags. */ - if (sc->status & (MCDDSKCHNG | MCDDOOROPEN)) { - MCD_TRACE("getstat: sensed DSKCHNG or DOOROPEN\n", 0, 0, 0, 0); - sc->flags &= ~MCDVALID; - } - - if (sc->status & MCDAUDIOBSY) - sc->audio_status = CD_AS_PLAY_IN_PROGRESS; - else if (sc->audio_status == CD_AS_PLAY_IN_PROGRESS) - sc->audio_status = CD_AS_PLAY_COMPLETED; -} - -int -mcd_get(sc, buf, nmax) - struct mcd_softc *sc; - char *buf; - int nmax; -{ - int i, k; - - for (i = 0; i < nmax; i++) { - /* Wait for data. */ - if ((k = mcd_getreply(sc, DELAY_GETREPLY)) < 0) { - printf("%s: timeout in get\n", sc->sc_dev.dv_xname); - return -1; - } - buf[i] = k; - } - return i; -} - -int -mcd_send(sc, cmd, nretries) - struct mcd_softc *sc; - int cmd, nretries; -{ - int i, k; - int iobase = sc->iobase; - - MCD_TRACE("send: cmd=0x%x\n", cmd, 0, 0, 0); - - for (i = nretries; i; i--) { - outb(iobase + mcd_command, cmd); - if ((k = mcd_getstat(sc, 0)) != -1) - break; - } - if (!i) { - printf("%s: send: retry count exceeded\n", sc->sc_dev.dv_xname); - return -1; - } - - MCD_TRACE("send: status=0x%x\n", k, 0, 0, 0); - - return 0; -} - -int -bcd2bin(b) - bcd_t b; -{ - - return (b >> 4) * 10 + (b & 15); -} - -bcd_t -bin2bcd(b) - int b; -{ - - return ((b / 10) << 4) | (b % 10); -} - -void -hsg2msf(hsg, msf) - int hsg; - bcd_t *msf; -{ - - hsg += 150; - M_msf(msf) = bin2bcd(hsg / 4500); - hsg %= 4500; - S_msf(msf) = bin2bcd(hsg / 75); - F_msf(msf) = bin2bcd(hsg % 75); -} - -int -msf2hsg(msf) - bcd_t *msf; -{ - - return (bcd2bin(M_msf(msf)) * 60 + - bcd2bin(S_msf(msf))) * 75 + - bcd2bin(F_msf(msf)) - 150; -} - -int -mcd_volinfo(sc) - struct mcd_softc *sc; -{ - - MCD_TRACE("volinfo: enter\n", 0, 0, 0, 0); - - /* Get the status, in case the disc has been changed. */ - if (mcd_getstat(sc, 1) < 0) - return EIO; - - /* Just return if we already have it. */ - if (sc->flags & MCDVOLINFO) - return 0; - - /* Send volume info command. */ - if (mcd_send(sc, MCD_CMDGETVOLINFO, MCD_RETRIES) < 0) - return -1; - - /* Get the data. */ - if (mcd_get(sc, (char*) &sc->volinfo, sizeof(struct mcd_volinfo)) < 0) { - printf("%s: volinfo: error reading data\n", - sc->sc_dev.dv_xname); - return -1; - } - - if (sc->volinfo.trk_low != 0 || sc->volinfo.trk_high != 0) { - /* Volinfo is OK. */ - sc->flags |= MCDVOLINFO; - return 0; - } - - return -1; -} - -int -mcdintr(sc) - struct mcd_softc *sc; -{ - int iobase = sc->iobase; - - MCD_TRACE("stray interrupt xfer=0x%x\n", inb(iobase + mcd_xfer), - 0, 0, 0); - - /* Just read out status and ignore the rest. */ - if (inb(iobase + mcd_xfer) != 0xff) - (void) inb(iobase + mcd_status); - - return -1; -} - -/* - * State machine to process read requests. - * Initialize with MCD_S_BEGIN: calculate sizes, and read status - * MCD_S_WAITSTAT: wait for status reply, set mode - * MCD_S_WAITMODE: waits for status reply from set mode, set read command - * MCD_S_WAITREAD: wait for read ready, read data. - */ -void -mcd_doread(arg) - void *arg; -{ - struct mcd_mbx *mbx = arg; - struct mcd_softc *sc = mbx->softc; - int iobase = sc->iobase; - struct buf *bp = mbx->bp; - - int i, k; - struct mcd_read2 rbuf; - int blkno; - caddr_t addr; - -loop: - switch (mbx->state) { - case MCD_S_BEGIN: - /* Get status. */ - outb(iobase + mcd_command, MCD_CMDGETSTAT); - - mbx->count = RDELAY_WAITSTAT; - mbx->state = MCD_S_WAITSTAT; - timeout(mcd_doread, mbx, hz / 100); - return; - - case MCD_S_WAITSTAT: - untimeout(mcd_doread, mbx); - if (mbx->count-- < 0) { - printf("%s: timeout getting status\n", - sc->sc_dev.dv_xname); - goto readerr; - } - if (inb(iobase + mcd_xfer) & MCD_ST_BUSY) { - timeout(mcd_doread, mbx, hz / 100); - return; - } - mcd_setflags(sc); - MCD_TRACE("doread: got WAITSTAT delay=%d\n", - RDELAY_WAITSTAT - mbx->count, 0, 0, 0); - - /* Reject, if audio active. */ - if (sc->status & MCDAUDIOBSY) { - printf("%s: audio is active\n", - sc->sc_dev.dv_xname); - goto readerr; - } - - mcd_put(iobase + mcd_command, MCD_CMDSETMODE); - mcd_put(iobase + mcd_command, MCD_MD_COOKED); - - mbx->sz = sc->blksize; - mbx->count = RDELAY_WAITMODE; - mbx->state = MCD_S_WAITMODE; - timeout(mcd_doread, mbx, hz / 100); - return; - - case MCD_S_WAITMODE: - untimeout(mcd_doread, mbx); - if (mbx->count-- < 0) { - printf("%s: timeout setting mode\n", - sc->sc_dev.dv_xname); - goto readerr; - } - if (inb(iobase + mcd_xfer) & MCD_ST_BUSY) { - timeout(mcd_doread, mbx, hz / 100); - return; - } - mcd_setflags(sc); - MCD_TRACE("doread: got WAITMODE delay=%d\n", - RDELAY_WAITMODE - mbx->count, 0, 0, 0); - - /* For first block. */ - mbx->nblk = (bp->b_bcount + (mbx->sz - 1)) / mbx->sz; - mbx->skip = 0; - - nextblock: - blkno = (bp->b_blkno / (mbx->sz / DEV_BSIZE)) + mbx->p_offset + - (mbx->skip / mbx->sz); - - MCD_TRACE("doread: read blkno=%d for bp=0x%x\n", blkno, bp, 0, - 0); - - /* Build parameter block. */ - hsg2msf(blkno, rbuf.start_msf); - - /* Send the read command. */ - mcd_put(iobase + mcd_command, MCD_CMDREAD2); - mcd_put(iobase + mcd_command, rbuf.start_msf[0]); - mcd_put(iobase + mcd_command, rbuf.start_msf[1]); - mcd_put(iobase + mcd_command, rbuf.start_msf[2]); - mcd_put(iobase + mcd_command, 0); - mcd_put(iobase + mcd_command, 0); - mcd_put(iobase + mcd_command, 1); - - mbx->count = RDELAY_WAITREAD; - mbx->state = MCD_S_WAITREAD; - timeout(mcd_doread, mbx, hz / 100); - return; - - case MCD_S_WAITREAD: - untimeout(mcd_doread, mbx); - if (mbx->count-- < 0) { - printf("%s: timeout reading data\n", - sc->sc_dev.dv_xname); - goto readerr; - } - - k = inb(iobase + mcd_xfer); - if ((k & 2) == 0) { /* XXX MCD_ST_AUDIOBSY? */ - MCD_TRACE("doread: got data delay=%d\n", - RDELAY_WAITREAD - mbx->count, 0, 0, 0); - /* Data is ready. */ - addr = bp->b_data + mbx->skip; - outb(iobase + mcd_ctl2, 0x04); /* XXX */ - for (i = 0; i < mbx->sz; i++) - *addr++ = inb(iobase + mcd_rdata); - outb(iobase + mcd_ctl2, 0x0c); /* XXX */ - - if (--mbx->nblk > 0) { - mbx->skip += mbx->sz; - goto nextblock; - } - - /* Return buffer. */ - bp->b_resid = 0; - biodone(bp); - - sc->flags &= ~MCDMBXBSY; - mcd_start(sc); - return; - } - if ((k & MCD_ST_BUSY) == 0) - mcd_getstat(sc, 0); - timeout(mcd_doread, mbx, hz / 100); - return; - } - -readerr: - if (mbx->retry-- > 0) { - printf("%s: retrying\n", sc->sc_dev.dv_xname); - mbx->state = MCD_S_BEGIN; - goto loop; - } - - /* Invalidate the buffer. */ - bp->b_flags |= B_ERROR; - bp->b_resid = bp->b_bcount; - biodone(bp); - mcd_start(sc); - -#ifdef notyet - printf("%s: unit timeout; resetting\n", sc->sc_dev.dv_xname); - outb(mbx->iobase + mcd_reset, MCD_CMDRESET); - delay(300000); - (void)mcd_getstat(sc, 1); - (void)mcd_getstat(sc, 1); - /*sc->status &= ~MCDDSKCHNG; */ - sc->debug = 1; /* preventive set debug mode */ -#endif -} - -int -mcd_setmode(sc, mode) - struct mcd_softc *sc; - int mode; -{ - int iobase = sc->iobase; - int retry; - - printf("%s: setting mode to %d\n", sc->sc_dev.dv_xname, mode); - for (retry = MCD_RETRIES; retry; retry--) { - outb(iobase + mcd_command, MCD_CMDSETMODE); - outb(iobase + mcd_command, mode); - if (mcd_getstat(sc, 0) != -1) - return 0; - } - - return -1; -} - -int -mcd_toc_header(sc, th) - struct mcd_softc *sc; - struct ioc_toc_header *th; -{ - - if (mcd_volinfo(sc) < 0) - return ENXIO; - - th->len = msf2hsg(sc->volinfo.vol_msf); - th->starting_track = bcd2bin(sc->volinfo.trk_low); - th->ending_track = bcd2bin(sc->volinfo.trk_high); - - return 0; -} - -int -mcd_read_toc(sc) - struct mcd_softc *sc; -{ - struct ioc_toc_header th; - struct mcd_qchninfo q; - int rc, trk, idx, retry; - - /* Only read TOC if needed. */ - if (sc->flags & MCDTOC) - return 0; - - if (sc->debug) - printf("%s: read_toc: reading toc header\n", - sc->sc_dev.dv_xname); - if (mcd_toc_header(sc, &th) != 0) - return ENXIO; - - if (sc->debug) - printf("%s: read_toc: stopping play\n", sc->sc_dev.dv_xname); - if ((rc = mcd_stop(sc)) != 0) - return rc; - - /* Try setting the mode twice. */ - if (mcd_setmode(sc, MCD_MD_TOC) != 0) - return EIO; - if (mcd_setmode(sc, MCD_MD_TOC) != 0) - return EIO; - - if (sc->debug) - printf("%s: read_toc: reading qchannel info\n", - sc->sc_dev.dv_xname); - for (trk = th.starting_track; trk <= th.ending_track; trk++) - sc->toc[trk].idx_no = 0; - trk = th.ending_track - th.starting_track + 1; - for (retry = 300; retry && trk > 0; retry--) { - if (mcd_getqchan(sc, &q) < 0) - break; - idx = bcd2bin(q.idx_no); - if (idx > 0 && idx < MCD_MAXTOCS && q.trk_no == 0 && - sc->toc[idx].idx_no == 0) { - sc->toc[idx] = q; - trk--; - } - } - - if (mcd_setmode(sc, MCD_MD_COOKED) != 0) - return EIO; - - if (trk != 0) - return ENXIO; - - /* Add a fake last+1. */ - idx = th.ending_track + 1; - sc->toc[idx].ctrl_adr = sc->toc[idx-1].ctrl_adr; - sc->toc[idx].trk_no = 0; - sc->toc[idx].idx_no = 0xaa; - sc->toc[idx].hd_pos_msf[0] = sc->volinfo.vol_msf[0]; - sc->toc[idx].hd_pos_msf[1] = sc->volinfo.vol_msf[1]; - sc->toc[idx].hd_pos_msf[2] = sc->volinfo.vol_msf[2]; - - sc->flags |= MCDTOC; - return 0; -} - -int -mcd_toc_entry(sc, te) - struct mcd_softc *sc; - struct ioc_read_toc_entry *te; -{ - struct ret_toc { - struct ioc_toc_header th; - struct cd_toc_entry rt; - } ret_toc; - struct ioc_toc_header th; - int rc, i; - - /* Make sure we have a valid TOC. */ - if ((rc = mcd_read_toc(sc)) != 0) - return rc; - - /* Find the TOC to copy. */ - i = te->starting_track; - if (i == MCD_LASTPLUS1) - i = bcd2bin(sc->volinfo.trk_high) + 1; - - /* Verify starting track. */ - if (i < bcd2bin(sc->volinfo.trk_low) || - i > bcd2bin(sc->volinfo.trk_high) + 1) - return EINVAL; - - /* Do we have room? */ - if (te->data_len < sizeof(struct ioc_toc_header) + - sizeof(struct cd_toc_entry)) - return EINVAL; - - /* Copy the TOC header. */ - if (mcd_toc_header(sc, &th) < 0) - return EIO; - ret_toc.th = th; - - /* Copy the TOC data. */ - ret_toc.rt.control = sc->toc[i].ctrl_adr; - ret_toc.rt.addr_type = te->address_format; - ret_toc.rt.track = i; - if (te->address_format == CD_MSF_FORMAT) { - ret_toc.rt.addr[1] = sc->toc[i].hd_pos_msf[0]; - ret_toc.rt.addr[2] = sc->toc[i].hd_pos_msf[1]; - ret_toc.rt.addr[3] = sc->toc[i].hd_pos_msf[2]; - } - - /* Copy the data back. */ - copyout(&ret_toc, te->data, - sizeof(struct cd_toc_entry) + sizeof(struct ioc_toc_header)); - - return 0; -} - -int -mcd_stop(sc) - struct mcd_softc *sc; -{ - - if (mcd_send(sc, MCD_CMDSTOPAUDIO, MCD_RETRIES) < 0) - return ENXIO; - sc->audio_status = CD_AS_PLAY_COMPLETED; - return 0; -} - -int -mcd_getqchan(sc, q) - struct mcd_softc *sc; - struct mcd_qchninfo *q; -{ - - if (mcd_send(sc, MCD_CMDGETQCHN, MCD_RETRIES) < 0) - return -1; - if (mcd_get(sc, (char *) q, sizeof(struct mcd_qchninfo)) < 0) - return -1; - if (sc->debug) - printf("%s: getqchan: ctl=%d t=%d i=%d ttm=%d:%d.%d dtm=%d:%d.%d\n", - sc->sc_dev.dv_xname, q->ctrl_adr, q->trk_no, q->idx_no, - q->trk_size_msf[0], q->trk_size_msf[1], q->trk_size_msf[2], - q->trk_size_msf[0], q->trk_size_msf[1], q->trk_size_msf[2]); - return 0; -} - -int -mcd_subchan(sc, ch) - struct mcd_softc *sc; - struct ioc_read_subchannel *ch; -{ - struct mcd_qchninfo q; - struct cd_sub_channel_info data; - - if (sc->debug) - printf("%s: subchan: af=%d df=%d\n", sc->sc_dev.dv_xname, - ch->address_format, ch->data_format); - - if (ch->address_format != CD_MSF_FORMAT) - return EIO; - if (ch->data_format != CD_CURRENT_POSITION) - return EIO; - if (mcd_getqchan(sc, &q) < 0) - return EIO; - - data.header.audio_status = sc->audio_status; - data.what.position.data_format = CD_MSF_FORMAT; - data.what.position.track_number = bcd2bin(q.trk_no); - - if (copyout(&data, ch->data, sizeof(struct cd_sub_channel_info)) != 0) - return EFAULT; - return 0; -} - -int -mcd_playtracks(sc, pt) - struct mcd_softc *sc; - struct ioc_play_track *pt; -{ - struct mcd_read2 pb; - int a = pt->start_track; - int z = pt->end_track; - int rc; - - if ((rc = mcd_read_toc(sc)) != 0) - return rc; - - printf("%s: playtracks: from %d:%d to %d:%d\n", sc->sc_dev.dv_xname, - a, pt->start_index, z, pt->end_index); - - if (a < sc->volinfo.trk_low || a > sc->volinfo.trk_high || a > z || - z < sc->volinfo.trk_low || z > sc->volinfo.trk_high) - return EINVAL; - - pb.start_msf[0] = sc->toc[a].hd_pos_msf[0]; - pb.start_msf[1] = sc->toc[a].hd_pos_msf[1]; - pb.start_msf[2] = sc->toc[a].hd_pos_msf[2]; - pb.end_msf[0] = sc->toc[z+1].hd_pos_msf[0]; - pb.end_msf[1] = sc->toc[z+1].hd_pos_msf[1]; - pb.end_msf[2] = sc->toc[z+1].hd_pos_msf[2]; - - return mcd_play(sc, &pb); -} - -int -mcd_play(sc, pb) - struct mcd_softc *sc; - struct mcd_read2 *pb; -{ - int iobase = sc->iobase; - int retry, st; - - sc->lastpb = *pb; - for (retry = MCD_RETRIES; retry; retry--) { - outb(iobase + mcd_command, MCD_CMDREAD2); - outb(iobase + mcd_command, pb->start_msf[0]); - outb(iobase + mcd_command, pb->start_msf[1]); - outb(iobase + mcd_command, pb->start_msf[2]); - outb(iobase + mcd_command, pb->end_msf[0]); - outb(iobase + mcd_command, pb->end_msf[1]); - outb(iobase + mcd_command, pb->end_msf[2]); - if ((st = mcd_getstat(sc, 0)) != -1) - break; - } - if (sc->debug) - printf("%s: play: retry=%d status=%d\n", sc->sc_dev.dv_xname, - retry, st); - if (!retry) - return ENXIO; - - sc->audio_status = CD_AS_PLAY_IN_PROGRESS; - return 0; -} - -int -mcd_pause(sc) - struct mcd_softc *sc; -{ - struct mcd_qchninfo q; - int rc; - - /* Verify current status. */ - if (sc->audio_status != CD_AS_PLAY_IN_PROGRESS) { - printf("%s: pause: attempted when not playing\n", - sc->sc_dev.dv_xname); - return EINVAL; - } - - /* Get the current position. */ - if (mcd_getqchan(sc, &q) < 0) - return EIO; - - /* Copy it into lastpb. */ - sc->lastpb.start_msf[0] = q.hd_pos_msf[0]; - sc->lastpb.start_msf[1] = q.hd_pos_msf[1]; - sc->lastpb.start_msf[2] = q.hd_pos_msf[2]; - - /* Stop playing. */ - if ((rc = mcd_stop(sc)) != 0) - return rc; - - /* Set the proper status and exit. */ - sc->audio_status = CD_AS_PLAY_PAUSED; - return 0; -} - -int -mcd_resume(sc) - struct mcd_softc *sc; -{ - - if (sc->audio_status != CD_AS_PLAY_PAUSED) - return EINVAL; - return mcd_play(sc, &sc->lastpb); -} diff --git a/sys/arch/i386/isa/mcdreg.h b/sys/arch/i386/isa/mcdreg.h deleted file mode 100644 index 769bb73bf282..000000000000 --- a/sys/arch/i386/isa/mcdreg.h +++ /dev/null @@ -1,137 +0,0 @@ -/* $NetBSD: mcdreg.h,v 1.5 1994/10/27 04:17:59 cgd Exp $ */ - -/* - * Copyright 1993 by Holger Veit (data part) - * Copyright 1993 by Brian Moore (audio part) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This software was developed by Holger Veit and Brian Moore - * for use with "386BSD" and similar operating systems. - * "Similar operating systems" includes mainly non-profit oriented - * systems for research and education, including but not restricted to - * "NetBSD", "FreeBSD", "Mach" (by CMU). - * 4. Neither the name of the developer(s) nor the name "386BSD" - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPER(S) BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This file contains definitions for some cdrom control commands - * and status codes. This info was "inherited" from the DOS MTMCDE.SYS - * driver, and is thus not complete (and may even be wrong). Some day - * the manufacturer or anyone else might provide better documentation, - * so this file (and the driver) will then have a better quality. - */ - -#ifdef __GNUC__ -#if __GNUC__ >= 2 -#pragma pack(1) -#endif -#endif - -typedef unsigned char bcd_t; -#define M_msf(msf) msf[0] -#define S_msf(msf) msf[1] -#define F_msf(msf) msf[2] - -/* io lines used */ -#define MCD_IO_BASE 0x300 - -#define mcd_command 0 -#define mcd_status 0 -#define mcd_rdata 0 - -#define mcd_reset 1 -#define mcd_xfer 1 -#define mcd_ctl2 2 /* XXX Is this right? */ - -#define mcd_config 3 -#define MCD_MASK_DMA 0x07 /* bits 2-0 = DMA channel */ -#define MCD_MASK_IRQ 0x70 /* bits 6-4 = INT number */ - /* 001 = int 2,9 */ - /* 010 = int 3 */ - /* 011 = int 5 */ - /* 100 = int 10 */ - /* 101 = int 11 */ - -/* Status bits */ -#define MCD_ST_DOOROPEN 0x80 -#define MCD_ST_DSKIN 0x40 -#define MCD_ST_DSKCHNG 0x20 -#define MCD_ST_BUSY 0x04 -#define MCD_ST_AUDIOBSY 0x02 - -/* commands known by the controller */ -#define MCD_CMDRESET 0x00 -#define MCD_CMDGETVOLINFO 0x10 /* gets mcd_volinfo */ -#define MCD_CMDGETQCHN 0x20 /* gets mcd_qchninfo */ -#define MCD_CMDGETSTAT 0x40 /* gets a byte of status */ -#define MCD_CMDSETMODE 0x50 /* set transmission mode, needs byte */ -#define MCD_MD_RAW 0x60 -#define MCD_MD_COOKED 0x01 -#define MCD_MD_TOC 0x05 -#define MCD_CMDSTOPAUDIO 0x70 -#define MCD_CMDGETVOLUME 0x8E /* gets mcd_volume */ -#define MCD_CMDSETVOLUME 0xAE /* sets mcd_volume */ -#define MCD_CMDREAD1 0xB0 /* read n sectors */ -#define MCD_CMDREAD2 0xC0 /* read from-to */ -#define MCD_CMDCONTINFO 0xDC /* Get controller info */ -#define MCD_CMDEJECTDISK 0xF6 -#define MCD_CMDCLOSETRAY 0xF8 -#define MCD_CMDLOCKDRV 0xFE /* needs byte */ -#define MCD_LK_UNLOCK 0x00 -#define MCD_LK_LOCK 0x01 -#define MCD_LK_TEST 0x02 - -struct mcd_volinfo { - bcd_t trk_low; - bcd_t trk_high; - bcd_t vol_msf[3]; - bcd_t trk1_msf[3]; -}; - -struct mcd_qchninfo { - u_char ctrl_adr; - u_char trk_no; - u_char idx_no; - bcd_t trk_size_msf[3]; - u_char :8; - bcd_t hd_pos_msf[3]; -}; - -struct mcd_volume { - u_char v0l; - u_char v0rs; - u_char v0r; - u_char v0ls; -}; - -struct mcd_read1 { - bcd_t start_msf[3]; - u_char nsec[3]; -}; - -struct mcd_read2 { - bcd_t start_msf[3]; - bcd_t end_msf[3]; -}; diff --git a/sys/arch/i386/isa/rtfps.c b/sys/arch/i386/isa/rtfps.c deleted file mode 100644 index 2c6d98993434..000000000000 --- a/sys/arch/i386/isa/rtfps.c +++ /dev/null @@ -1,173 +0,0 @@ -/* $NetBSD: rtfps.c,v 1.11 1995/01/04 00:47:58 mycroft Exp $ */ - -/* - * Copyright (c) 1995 Charles Hannum. All rights reserved. - * - * This code is derived from public-domain software written by - * Roland McGrath. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include - -#include - -struct rtfps_softc { - struct device sc_dev; - struct intrhand sc_ih; - - int sc_iobase; - int sc_irqport; - int sc_alive; /* mask of slave units attached */ - void *sc_slaves[4]; /* com device unit numbers */ -}; - -int rtfpsprobe(); -void rtfpsattach(); -int rtfpsintr __P((struct rtfps_softc *)); - -struct cfdriver rtfpscd = { - NULL, "rtfps", rtfpsprobe, rtfpsattach, DV_TTY, sizeof(struct rtfps_softc) -}; - -int -rtfpsprobe(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct isa_attach_args *ia = aux; - - /* - * Do the normal com probe for the first UART and assume - * its presence means there is a multiport board there. - * XXX Needs more robustness. - */ - ia->ia_iosize = 4 * 8; - return comprobe1(ia->ia_iobase); -} - -struct rtfps_attach_args { - int ra_slave; -}; - -int -rtfpssubmatch(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct rtfps_softc *sc = (void *)parent; - struct cfdata *cf = match; - struct isa_attach_args *ia = aux; - struct rtfps_attach_args *ra = ia->ia_aux; - - if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ra->ra_slave) - return (0); - return ((*cf->cf_driver->cd_match)(parent, match, ia)); -} - -int -rtfpsprint(aux, rtfps) - void *aux; - char *rtfps; -{ - struct isa_attach_args *ia = aux; - struct rtfps_attach_args *ra = ia->ia_aux; - - printf(" slave %d", ra->ra_slave); -} - -void -rtfpsattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct rtfps_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - struct rtfps_attach_args ra; - struct isa_attach_args isa; - static int irqport[] = { - IOBASEUNK, IOBASEUNK, IOBASEUNK, IOBASEUNK, - IOBASEUNK, IOBASEUNK, IOBASEUNK, IOBASEUNK, - IOBASEUNK, 0x2f2, 0x6f2, 0x6f3, - IOBASEUNK, IOBASEUNK, IOBASEUNK, IOBASEUNK - }; - - sc->sc_iobase = ia->ia_iobase; - - if (ia->ia_irq >= 16 || irqport[ia->ia_irq] == IOBASEUNK) - panic("rtfpsattach: invalid irq"); - sc->sc_irqport = irqport[ia->ia_irq]; - - outb(sc->sc_irqport, 0); - - printf("\n"); - - isa.ia_aux = &ra; - for (ra.ra_slave = 0; ra.ra_slave < 4; ra.ra_slave++) { - struct cfdata *cf; - isa.ia_iobase = sc->sc_iobase + 8 * ra.ra_slave; - isa.ia_iosize = 0x666; - isa.ia_irq = IRQUNK; - isa.ia_drq = DRQUNK; - isa.ia_msize = 0; - if ((cf = config_search(rtfpssubmatch, self, &isa)) != 0) { - config_attach(self, cf, &isa, rtfpsprint); - sc->sc_slaves[ra.ra_slave] = - cf->cf_driver->cd_devs[cf->cf_unit]; - sc->sc_alive |= 1 << ra.ra_slave; - } - } - - sc->sc_ih.ih_fun = rtfpsintr; - sc->sc_ih.ih_arg = sc; - sc->sc_ih.ih_level = IPL_TTY; - intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih); -} - -int -rtfpsintr(sc) - struct rtfps_softc *sc; -{ - int iobase = sc->sc_iobase; - int alive = sc->sc_alive; - - outb(sc->sc_irqport, 0); - -#define TRY(n) \ - if (alive & (1 << (n))) \ - comintr(sc->sc_slaves[n]); - TRY(0); - TRY(1); - TRY(2); - TRY(3); -#undef TRY - - return (1); -} diff --git a/sys/arch/i386/isa/seagate.c b/sys/arch/i386/isa/seagate.c deleted file mode 100644 index 5455fef98b10..000000000000 --- a/sys/arch/i386/isa/seagate.c +++ /dev/null @@ -1,1434 +0,0 @@ -/* - * ST01/02, Future Domain TMC-885, TMC-950 SCSI driver - * - * Copyright 1994, Charles Hannum (mycroft@ai.mit.edu) - * Copyright 1994, Kent Palmkvist (kentp@isy.liu.se) - * Copyright 1994, Robert Knier (rknier@qgraph.com) - * Copyright 1992, 1994 Drew Eckhardt (drew@colorado.edu) - * Copyright 1994, Julian Elischer (julian@tfs.com) - * - * Others that has contributed by example code is - * Glen Overby (overby@cray.com) - * Tatu Yllnen - * Brian E Litzinger - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE DEVELOPERS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * kentp 940307 alpha version based on newscsi-03 version of Julians SCSI-code - * kentp 940314 Added possibility to not use messages - * rknier 940331 Added fast transfer code - * rknier 940407 Added assembler coded data transfers - */ - -/* - * What should really be done: - * - * Add missing tests for timeouts - * Restructure interrupt enable/disable code (runs to long with int disabled) - * Find bug? giving problem with tape status - * Add code to handle Future Domain 840, 841, 880 and 881 - * adjust timeouts (startup is very slow) - * add code to use tagged commands in SCSI2 - * Add code to handle slow devices better (sleep if device not disconnecting) - * Fix unnecessary interrupts - */ - -/* - * Note to users trying to share a disk between DOS and unix: - * The ST01/02 is a translating host-adapter. It is not giving DOS - * the same number of heads/tracks/sectors as specified by the disk. - * It is therefore important to look at what numbers DOS thinks the - * disk has. Use these to disklabel your disk in an appropriate manner - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#define SEA_SCB_MAX 32 /* allow maximally 8 scsi control blocks */ -#define SCB_TABLE_SIZE 8 /* start with 8 scb entries in table */ -#define BLOCK_SIZE 512 /* size of READ/WRITE areas on SCSI card */ - -/* - * defining SEA_BLINDTRANSFER will make DATA IN and DATA OUT to be done with - * blind transfers, i.e. no check is done for scsi phase changes. This will - * result in data loss if the scsi device does not send its data using - * BLOCK_SIZE bytes at a time. - * If SEA_BLINDTRANSFER defined and SEA_ASSEMBLER also defined will result in - * the use of blind transfers coded in assembler. SEA_ASSEMBLER is no good - * without SEA_BLINDTRANSFER defined. - */ -#define SEA_BLINDTRANSFER /* do blind transfers */ -#define SEA_ASSEMBLER /* Use assembly code for fast transfers */ - -/* - * defining SEA_NOMSGS causes messages not to be used (thereby disabling - * disconnects) - */ -#undef SEA_NOMSGS - -/* - * defining SEA_NODATAOUT makes dataout phase being aborted - */ -#undef SEA_NODATAOUT - -/* Debugging definitions. Should not be used unless you want a lot of - printouts even under normal conditions */ - -#undef SEA_DEBUGQUEUE /* Display info about queue-lengths */ - -/******************************* board definitions **************************/ -/* - * CONTROL defines - */ -#define CMD_RST 0x01 /* scsi reset */ -#define CMD_SEL 0x02 /* scsi select */ -#define CMD_BSY 0x04 /* scsi busy */ -#define CMD_ATTN 0x08 /* scsi attention */ -#define CMD_START_ARB 0x10 /* start arbitration bit */ -#define CMD_EN_PARITY 0x20 /* enable scsi parity generation */ -#define CMD_INTR 0x40 /* enable scsi interrupts */ -#define CMD_DRVR_ENABLE 0x80 /* scsi enable */ - -/* - * STATUS - */ -#define STAT_BSY 0x01 /* scsi busy */ -#define STAT_MSG 0x02 /* scsi msg */ -#define STAT_IO 0x04 /* scsi I/O */ -#define STAT_CD 0x08 /* scsi C/D */ -#define STAT_REQ 0x10 /* scsi req */ -#define STAT_SEL 0x20 /* scsi select */ -#define STAT_PARITY 0x40 /* parity error bit */ -#define STAT_ARB_CMPL 0x80 /* arbitration complete bit */ - -/* - * REQUESTS - */ -#define PH_DATAOUT (0) -#define PH_DATAIN (STAT_IO) -#define PH_CMD (STAT_CD) -#define PH_STAT (STAT_CD | STAT_IO) -#define PH_MSGOUT (STAT_MSG | STAT_CD) -#define PH_MSGIN (STAT_MSG | STAT_CD | STAT_IO) - -#define PH_MASK (STAT_MSG | STAT_CD | STAT_IO) - -#define PH_INVALID 0xff - -#define SEA_RAMOFFSET 0x00001800 - -#define BASE_CMD (CMD_INTR | CMD_EN_PARITY) - -#define SEAGATE 1 /* Seagate ST0[12] */ -#define FDOMAIN 2 /* Future Domain TMC-{885,950} */ -#define FDOMAIN840 3 /* Future Domain TMC-{84[01],88[01]} */ - -/******************************************************************************/ - -/* scsi control block used to keep info about a scsi command */ -struct sea_scb { - u_char *data; /* position in data buffer so far */ - int datalen; /* bytes remaining to transfer */ - TAILQ_ENTRY(sea_scb) chain; - struct scsi_xfer *xs; /* the scsi_xfer for this cmd */ - int flags; /* status of the instruction */ -#define SCB_FREE 0 -#define SCB_ACTIVE 1 -#define SCB_ABORTED 2 -#define SCB_TIMEOUT 4 -#define SCB_ERROR 8 -}; - -/* - * data structure describing current status of the scsi bus. One for each - * controller card. - */ -struct sea_softc { - struct device sc_dev; - struct isadev sc_id; - struct intrhand sc_ih; - - int type; /* board type */ - caddr_t maddr; /* Base address for card */ - caddr_t maddr_cr_sr; /* Address of control and status reg */ - caddr_t maddr_dr; /* Address of data register */ - - struct scsi_link sc_link; /* prototype for subdevs */ - TAILQ_HEAD(, sea_scb) free_list, ready_list, nexus_list; - struct sea_scb *nexus; /* currently connected command */ - int numscbs; /* number of scsi control blocks */ - struct sea_scb scb[SCB_TABLE_SIZE]; - - int our_id; /* our scsi id */ - u_char our_id_mask; - volatile u_char busy[8]; /* index=target, bit=lun, Keep track of - busy luns at device target */ -}; - -/* flag showing if main routine is running. */ -static volatile int main_running = 0; - -#define STATUS (*(volatile u_char *)sea->maddr_cr_sr) -#define CONTROL STATUS -#define DATA (*(volatile u_char *)sea->maddr_dr) - -/* - * These are "special" values for the tag parameter passed to sea_select - * Not implemented right now. - */ -#define TAG_NEXT -1 /* Use next free tag */ -#define TAG_NONE -2 /* - * Establish I_T_L nexus instead of I_T_L_Q - * even on SCSI-II devices. - */ - -typedef struct { - char *signature; - int offset, length; - int type; -} BiosSignature; - -/* - * Signatures for automatic recognition of board type - */ -static const BiosSignature signatures[] = { -{"ST01 v1.7 (C) Copyright 1987 Seagate", 15, 37, SEAGATE}, -{"SCSI BIOS 2.00 (C) Copyright 1987 Seagate", 15, 40, SEAGATE}, - -/* - * The following two lines are NOT mistakes. One detects ROM revision - * 3.0.0, the other 3.2. Since seagate has only one type of SCSI adapter, - * and this is not going to change, the "SEAGATE" and "SCSI" together - * are probably "good enough" - */ -{"SEAGATE SCSI BIOS ", 16, 17, SEAGATE}, -{"SEAGATE SCSI BIOS ", 17, 17, SEAGATE}, - -/* - * However, future domain makes several incompatible SCSI boards, so specific - * signatures must be used. - */ -{"FUTURE DOMAIN CORP. (C) 1986-1989 V5.0C2/14/89", 5, 45, FDOMAIN}, -{"FUTURE DOMAIN CORP. (C) 1986-1989 V6.0A7/28/89", 5, 46, FDOMAIN}, -{"FUTURE DOMAIN CORP. (C) 1986-1990 V6.0105/31/90",5, 47, FDOMAIN}, -{"FUTURE DOMAIN CORP. (C) 1986-1990 V6.0209/18/90",5, 47, FDOMAIN}, -{"FUTURE DOMAIN CORP. (C) 1986-1990 V7.009/18/90", 5, 46, FDOMAIN}, -{"FUTURE DOMAIN CORP. (C) 1992 V8.00.004/02/92", 5, 44, FDOMAIN}, -{"FUTURE DOMAIN TMC-950", 5, 21, FDOMAIN}, -}; - -#define nsignatures (sizeof(signatures) / sizeof(signatures[0])) - -static const char *bases[] = { - (char *) 0xc8000, (char *) 0xca000, (char *) 0xcc000, - (char *) 0xce000, (char *) 0xdc000, (char *) 0xde000 -}; - -#define nbases (sizeof(bases) / sizeof(bases[0])) - -int seaintr __P((struct sea_softc *)); -int sea_scsi_cmd __P((struct scsi_xfer *)); -void sea_timeout __P((void *)); -void seaminphys __P((struct buf *)); -void sea_done __P((struct sea_softc *, struct sea_scb *)); -struct sea_scb *sea_get_scb __P((struct sea_softc *, int)); -void sea_free_scb __P((struct sea_softc *, struct sea_scb *, int)); -static void sea_main __P((void)); -static void sea_information_transfer __P((struct sea_softc *)); -int sea_poll __P((struct sea_softc *, struct scsi_xfer *, int)); -void sea_init __P((struct sea_softc *)); -void sea_send_scb __P((struct sea_softc *sea, struct sea_scb *scb)); -void sea_reselect __P((struct sea_softc *sea)); -int sea_select __P((struct sea_softc *sea, struct sea_scb *scb)); -int sea_transfer_pio __P((struct sea_softc *sea, u_char *phase, - int *count, u_char **data)); -int sea_abort __P((struct sea_softc *, struct sea_scb *scb)); - -struct scsi_adapter sea_switch = { - sea_scsi_cmd, - seaminphys, - 0, - 0, -}; - -/* the below structure is so we have a default dev struct for our link struct */ -struct scsi_device sea_dev = { - NULL, /* use default error handler */ - NULL, /* have a queue, served by this */ - NULL, /* have no async handler */ - NULL, /* Use default 'done' routine */ -}; - -int seaprobe __P((struct device *, void *, void *)); -void seaattach __P((struct device *, struct device *, void *)); - -struct cfdriver seacd = { - NULL, "sea", seaprobe, seaattach, DV_DULL, sizeof(struct sea_softc) -}; - -#ifdef SEA_DEBUGQUEUE -void -sea_queue_length(sea) - struct sea_softc *sea; -{ - struct sea_scb *scb; - int connected, issued, disconnected; - - connected = sea->nexus ? 1 : 0; - for (scb = sea->ready_list.tqh_first, issued = 0; scb; - scb = scb->chain.tqe_next, issued++); - for (scb = sea->nexus_list.tqh_first, disconnected = 0; scb; - scb = scb->chain.tqe_next, disconnected++); - printf("%s: length: %d/%d/%d\n", sea->sc_dev.dv_xname, connected, - issued, disconnected); -} -#endif - -/* - * Check if the device can be found at the port given and if so, detect the - * type the type of board. Set it up ready for further work. Takes the isa_dev - * structure from autoconf as an argument. - * Returns 1 if card recognized, 0 if errors. - */ -int -seaprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct sea_softc *sea = match; - struct isa_attach_args *ia = aux; - int i; - - /* - * Could try to find a board by looking through all possible addresses. - * This is not done the right way now, because I have not found a way - * to get a boards virtual memory address given its physical. There is - * a function that returns the physical address for a given virtual - * address, but not the other way around. - */ - - if (ia->ia_maddr == MADDRUNK) { - /* XXX */ - return 0; - } else - sea->maddr = ISA_HOLE_VADDR(ia->ia_maddr); - - /* check board type */ /* No way to define this through config */ - for (i = 0; i < nsignatures; i++) - if (!memcmp(sea->maddr + signatures[i].offset, - signatures[i].signature, signatures[i].length)) { - sea->type = signatures[i].type; - break; - } - - /* Find controller and data memory addresses */ - switch (sea->type) { - case SEAGATE: - case FDOMAIN840: - sea->maddr_cr_sr = - (void *) (((u_char *)sea->maddr) + 0x1a00); - sea->maddr_dr = - (void *) (((u_char *)sea->maddr) + 0x1c00); - break; - case FDOMAIN: - sea->maddr_cr_sr = - (void *) (((u_char *)sea->maddr) + 0x1c00); - sea->maddr_dr = - (void *) (((u_char *)sea->maddr) + 0x1e00); - break; - default: - printf("%s: board type unknown at address 0x%lx\n", - sea->sc_dev.dv_xname, sea->maddr); - return 0; - } - - /* Test controller RAM (works the same way on future domain cards?) */ - *((u_char *)sea->maddr + SEA_RAMOFFSET) = 0xa5; - *((u_char *)sea->maddr + SEA_RAMOFFSET + 1) = 0x5a; - - if ((*((u_char *)sea->maddr + SEA_RAMOFFSET) != 0xa5) || - (*((u_char *)sea->maddr + SEA_RAMOFFSET + 1) != 0x5a)) { - printf("%s: board RAM failure\n", sea->sc_dev.dv_xname); - return 0; - } - - ia->ia_drq = DRQUNK; - ia->ia_msize = 0x2000; - ia->ia_iosize = 0; - return 1; -} - -seaprint() -{ - -} - -/* - * Attach all sub-devices we can find - */ -void -seaattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct isa_attach_args *ia = aux; - struct sea_softc *sea = (void *)self; - - sea_init(sea); - - /* - * fill in the prototype scsi_link. - */ - sea->sc_link.adapter_softc = sea; - sea->sc_link.adapter_target = sea->our_id; - sea->sc_link.adapter = &sea_switch; - sea->sc_link.device = &sea_dev; - sea->sc_link.openings = 1; - - printf("\n"); - -#ifdef NEWCONFIG - isa_establish(&sea->sc_id, &sea->sc_deV); -#endif - sea->sc_ih.ih_fun = seaintr; - sea->sc_ih.ih_arg = sea; - sea->sc_ih.ih_level = IPL_BIO; - intr_establish(ia->ia_irq, IST_EDGE, &sea->sc_ih); - - /* - * ask the adapter what subunits are present - */ - config_found(self, &sea->sc_link, seaprint); -} - -/* - * Catch an interrupt from the adaptor - */ -int -seaintr(sea) - struct sea_softc *sea; -{ - -#ifdef DEBUG /* extra overhead, and only needed for intr debugging */ - if ((STATUS & STAT_PARITY) == 0 && - (STATUS & (STAT_SEL | STAT_IO)) != (STAT_SEL | STAT_IO)) - return 0; -#endif - -loop: - /* dispatch to appropriate routine if found and done=0 */ - /* should check to see that this card really caused the interrupt */ - - if (STATUS & STAT_PARITY) { - /* Parity error interrupt */ - printf("%s: parity error\n", sea->sc_dev.dv_xname); - return 1; - } - - if ((STATUS & (STAT_SEL | STAT_IO)) == (STAT_SEL | STAT_IO)) { - /* Reselect interrupt */ - sea_reselect(sea); - if (!main_running) - sea_main(); - goto loop; - } - - return 1; -} - -/* - * Setup data structures, and reset the board and the SCSI bus. - */ -void -sea_init(sea) - struct sea_softc *sea; -{ - int i; - - /* Reset the scsi bus (I don't know if this is needed */ - CONTROL = BASE_CMD | CMD_DRVR_ENABLE | CMD_RST; - delay(25); /* hold reset for at least 25 microseconds */ - CONTROL = BASE_CMD; - delay(10); /* wait a Bus Clear Delay (800 ns + bus free delay (800 ns) */ - - /* Set our id (don't know anything about this) */ - switch (sea->type) { - case SEAGATE: - sea->our_id = 7; - break; - case FDOMAIN: - case FDOMAIN840: - sea->our_id = 6; - break; - } - sea->our_id_mask = 1 << sea->our_id; - - /* init fields used by our routines */ - sea->nexus = 0; - TAILQ_INIT(&sea->ready_list); - TAILQ_INIT(&sea->nexus_list); - TAILQ_INIT(&sea->free_list); - for (i = 0; i < 8; i++) - sea->busy[i] = 0x00; - - /* link up the free list of scbs */ - sea->numscbs = SCB_TABLE_SIZE; - for (i = 0; i < SCB_TABLE_SIZE; i++) { - TAILQ_INSERT_TAIL(&sea->free_list, &sea->scb[i], chain); - } -} - -void -seaminphys(bp) - struct buf *bp; -{ - - /* No need for a max since we're doing PIO. */ -} - -/* - * start a scsi operation given the command and the data address. Also needs - * the unit, target and lu. - */ -int -sea_scsi_cmd(xs) - struct scsi_xfer *xs; -{ - struct scsi_link *sc_link = xs->sc_link; - struct sea_softc *sea = sc_link->adapter_softc; - struct sea_scb *scb; - int flags; - int s; - - SC_DEBUG(sc_link, SDEV_DB2, ("sea_scsi_cmd\n")); - - flags = xs->flags; - if ((flags & (ITSDONE|INUSE)) != INUSE) { - printf("%s: done or not in use?\n", sea->sc_dev.dv_xname); - xs->flags &= ~ITSDONE; - xs->flags |= INUSE; - } - if ((scb = sea_get_scb(sea, flags)) == NULL) { - xs->error = XS_DRIVER_STUFFUP; - return TRY_AGAIN_LATER; - } - scb->flags = SCB_ACTIVE; - scb->xs = xs; - - if (flags & SCSI_RESET) { - /* - * Try to send a reset command to the card. - * XXX Not implemented. - */ - printf("%s: resetting\n", sea->sc_dev.dv_xname); - xs->error = XS_DRIVER_STUFFUP; - return COMPLETE; - } - - /* - * Put all the arguments for the xfer in the scb - */ - scb->datalen = xs->datalen; - scb->data = xs->data; - -#ifdef SEA_DEBUGQUEUE - sea_queue_length(sea); -#endif - - s = splbio(); - - sea_send_scb(sea, scb); - - /* - * Usually return SUCCESSFULLY QUEUED - */ - if ((flags & SCSI_POLL) == 0) { - timeout(sea_timeout, scb, (xs->timeout * hz) / 1000); - splx(s); - return SUCCESSFULLY_QUEUED; - } - - splx(s); - - /* - * If we can't use interrupts, poll on completion - */ - if (sea_poll(sea, xs, xs->timeout)) { - sea_timeout(scb); - if (sea_poll(sea, xs, 2000)) - sea_timeout(scb); - } - return COMPLETE; -} - -/* - * Get a free scb. If there are none, see if we can allocate a new one. If so, - * put it in the hash table too; otherwise return an error or sleep. - */ -struct sea_scb * -sea_get_scb(sea, flags) - struct sea_softc *sea; - int flags; -{ - int s; - struct sea_scb *scb; - - s = splbio(); - - /* - * If we can and have to, sleep waiting for one to come free - * but only if we can't allocate a new one. - */ - for (;;) { - scb = sea->free_list.tqh_first; - if (scb) { - TAILQ_REMOVE(&sea->free_list, scb, chain); - break; - } - if (sea->numscbs < SEA_SCB_MAX) { - if (scb = (struct sea_scb *) malloc(sizeof(struct sea_scb), - M_TEMP, M_NOWAIT)) { - bzero(scb, sizeof(struct sea_scb)); - sea->numscbs++; - } else - printf("%s: can't malloc scb\n", - sea->sc_dev.dv_xname); - break; - } else { - if ((flags & SCSI_NOSLEEP) == 0) - tsleep(&sea->free_list, PRIBIO, "seascb", 0); - } - } - - splx(s); - return scb; -} - -/* - * Try to send this command to the board. Because this board does not use any - * mailboxes, this routine simply adds the command to the queue held by the - * sea_softc structure. - * A check is done to see if the command contains a REQUEST_SENSE command, and - * if so the command is put first in the queue, otherwise the command is added - * to the end of the queue. ?? Not correct ?? - */ -void -sea_send_scb(sea, scb) - struct sea_softc *sea; - struct sea_scb *scb; -{ - - TAILQ_INSERT_TAIL(&sea->ready_list, scb, chain); - /* Try to do some work on the card. */ - if (!main_running) - sea_main(); -} - -/* - * Coroutine that runs as long as more work can be done on the seagate host - * adapter in a system. Both sea_scsi_cmd and sea_intr will try to start it in - * case it is not running. - */ -void -sea_main() -{ - struct sea_softc *sea; - struct sea_scb *scb; - int done; - int unit; - int s; - - main_running = 1; - - /* - * This should not be run with interrupts disabled, but use the splx - * code instead. - */ -loop: - done = 1; - for (unit = 0; unit < seacd.cd_ndevs; unit++) { - sea = seacd.cd_devs[unit]; - if (!sea) - continue; - s = splbio(); - if (!sea->nexus) { - /* - * Search through the ready_list for a command - * destined for a target that's not busy. - */ - for (scb = sea->ready_list.tqh_first; scb; - scb = scb->chain.tqe_next) { - if (!(sea->busy[scb->xs->sc_link->target] & - (1 << scb->xs->sc_link->lun))) { - TAILQ_REMOVE(&sea->ready_list, scb, - chain); - - /* Re-enable interrupts. */ - splx(s); - - /* - * Attempt to establish an I_T_L nexus. - * On success, sea->nexus is set. - * On failure, we must add the command - * back to the issue queue so we can - * keep trying. - */ - - /* - * REQUEST_SENSE commands are issued - * without tagged queueing, even on - * SCSI-II devices because the - * contingent alligence condition - * exists for the entire unit. - */ - - /* - * First check that if any device has - * tried a reconnect while we have done - * other things with interrupts - * disabled. - */ - - if ((STATUS & (STAT_SEL | STAT_IO)) == - (STAT_SEL | STAT_IO)) { - sea_reselect(sea); - break; - } - if (sea_select(sea, scb)) { - s = splbio(); - TAILQ_INSERT_HEAD(&sea->ready_list, - scb, chain); - splx(s); - } else - break; - } /* if target/lun is not busy */ - } /* for scb */ - if (!sea->nexus) { - /* check for reselection phase */ - if ((STATUS & (STAT_SEL | STAT_IO)) == - (STAT_SEL | STAT_IO)) { - sea_reselect(sea); - } - } - } /* if (!sea->nexus) */ - - splx(s); - if (sea->nexus) { /* we are connected. Do the task */ - sea_information_transfer(sea); - done = 0; - } else - break; - } /* for instance */ - - if (!done) - goto loop; - - main_running = 0; -} - -void -sea_free_scb(sea, scb, flags) - struct sea_softc *sea; - struct sea_scb *scb; - int flags; -{ - int s; - - s = splbio(); - - scb->flags = SCB_FREE; - TAILQ_INSERT_HEAD(&sea->free_list, scb, chain); - - /* - * If there were none, wake anybody waiting for one to come free, - * starting with queued entries. - */ - if (!scb->chain.tqe_next) - wakeup((caddr_t)&sea->free_list); - - splx(s); -} - -void -sea_timeout(arg) - void *arg; -{ - struct sea_scb *scb = arg; - struct scsi_xfer *xs = scb->xs; - struct scsi_link *sc_link = xs->sc_link; - struct sea_softc *sea = sc_link->adapter_softc; - int s; - - sc_print_addr(sc_link); - printf("timed out"); - - s = splbio(); - - /* - * If it has been through before, then - * a previous abort has failed, don't - * try abort again - */ - if (scb->flags & SCB_ABORTED) { - /* abort timed out */ - printf(" AGAIN\n"); - scb->xs->retries = 0; - scb->flags |= SCB_ABORTED; - sea_done(sea, scb); - } else { - /* abort the operation that has timed out */ - printf("\n"); - scb->flags |= SCB_ABORTED; - sea_abort(sea, scb); - /* 2 secs for the abort */ - if ((xs->flags & SCSI_POLL) == 0) - timeout(sea_timeout, scb, 2 * hz); - } - - splx(s); -} - -void -sea_reselect(sea) - struct sea_softc *sea; -{ - u_char target_mask; - int i; - u_char lun, phase; - u_char msg[3]; - int len; - u_char *data; - struct sea_scb *scb; - int abort = 0; - - if (!((target_mask = STATUS) & STAT_SEL)) { - printf("%s: wrong state 0x%x\n", sea->sc_dev.dv_xname, - target_mask); - return; - } - - /* wait for a device to win the reselection phase */ - /* signals this by asserting the I/O signal */ - for (i = 10; i && (STATUS & (STAT_SEL | STAT_IO | STAT_BSY)) != - (STAT_SEL | STAT_IO | 0); i--); - /* !! Check for timeout here */ - /* the data bus contains original initiator id ORed with target id */ - target_mask = DATA; - /* see that we really are the initiator */ - if (!(target_mask & sea->our_id_mask)) { - printf("%s: polled reselection was not for me: 0x%x\n", - sea->sc_dev.dv_xname, target_mask); - return; - } - /* find target who won */ - target_mask &= ~sea->our_id_mask; - /* host responds by asserting the BSY signal */ - CONTROL = BASE_CMD | CMD_DRVR_ENABLE | CMD_BSY; - /* target should respond by deasserting the SEL signal */ - for (i = 50000; i && (STATUS & STAT_SEL); i++); - /* remove the busy status */ - CONTROL = BASE_CMD | CMD_DRVR_ENABLE; - /* we are connected. Now we wait for the MSGIN condition */ - for (i = 50000; i && !(STATUS & STAT_REQ); i--); - /* !! Add timeout check here */ - /* hope we get an IDENTIFY message */ - len = 3; - data = msg; - phase = PH_MSGIN; - sea_transfer_pio(sea, &phase, &len, &data); - - if (MSG_ISIDENTIFY(msg[0])) { - printf("%s: expecting IDENTIFY message, got 0x%x\n", - sea->sc_dev.dv_xname, msg[0]); - abort = 1; - } else { - lun = msg[0] & 0x07; - - /* - * Find the command corresponding to the I_T_L or I_T_L_Q nexus - * we just reestablished, and remove it from the disconnected - * queue. - */ - for (scb = sea->nexus_list.tqh_first; scb; - scb = scb->chain.tqe_next) - if (target_mask == (1 << scb->xs->sc_link->target) && - lun == scb->xs->sc_link->lun) { - TAILQ_REMOVE(&sea->nexus_list, scb, - chain); - break; - } - if (!scb) { - printf("%s: target %02x lun %d not disconnected\n", - sea->sc_dev.dv_xname, target_mask, lun); - /* - * Since we have an established nexus that we can't do - * anything with, we must abort it. - */ - abort = 1; - } - } - - if (abort) { - msg[0] = MSG_ABORT; - len = 1; - data = msg; - phase = PH_MSGOUT; - CONTROL = BASE_CMD | CMD_ATTN; - sea_transfer_pio(sea, &phase, &len, &data); - } else - sea->nexus = scb; - - return; -} - -/* - * Transfer data in given phase using polled I/O. - */ -int -sea_transfer_pio(sea, phase, count, data) - struct sea_softc *sea; - u_char *phase; - int *count; - u_char **data; -{ - register u_char p = *phase, tmp; - register int c = *count; - register u_char *d = *data; - int timeout; - - do { - /* - * Wait for assertion of REQ, after which the phase bits will - * be valid. - */ - for (timeout = 0; timeout < 50000; timeout++) - if ((tmp = STATUS) & STAT_REQ) - break; - if (!(tmp & STAT_REQ)) { - printf("%s: timeout waiting for STAT_REQ\n", - sea->sc_dev.dv_xname); - break; - } - - /* - * Check for phase mismatch. Reached if the target decides - * that it has finished the transfer. - */ - if (sea->type == FDOMAIN840) - tmp = ((tmp & 0x08) >> 2) | - ((tmp & 0x02) << 2) | - (tmp & 0xf5); - if ((tmp & PH_MASK) != p) - break; - - /* Do actual transfer from SCSI bus to/from memory. */ - if (!(p & STAT_IO)) - DATA = *d; - else - *d = DATA; - ++d; - - /* - * The SCSI standard suggests that in MSGOUT phase, the - * initiator should drop ATN on the last byte of the message - * phase after REQ has been asserted for the handshake but - * before the initiator raises ACK. - * Don't know how to accomplish this on the ST01/02. - */ - -#if 0 - /* - * XXX - * The st01 code doesn't wait for STAT_REQ to be deasserted. - * Is this ok? - */ - for (timeout = 0; timeout < 200000L; timeout++) - if (!(STATUS & STAT_REQ)) - break; - if (STATUS & STAT_REQ) - printf("%s: timeout on wait for !STAT_REQ", - sea->sc_dev.dv_xname); -#endif - } while (--c); - - *count = c; - *data = d; - tmp = STATUS; - if (tmp & STAT_REQ) - *phase = tmp & PH_MASK; - else - *phase = PH_INVALID; - - if (c && (*phase != p)) - return -1; - return 0; -} - -/* - * Establish I_T_L or I_T_L_Q nexus for new or existing command including - * ARBITRATION, SELECTION, and initial message out for IDENTIFY and queue - * messages. Return -1 if selection could not execute for some reason, 0 if - * selection succeded or failed because the target did not respond. - */ -int -sea_select(sea, scb) - struct sea_softc *sea; - struct sea_scb *scb; -{ - u_char msg[3], phase; - u_char *data; - int len; - int timeout; - - CONTROL = BASE_CMD; - DATA = sea->our_id_mask; - CONTROL = (BASE_CMD & ~CMD_INTR) | CMD_START_ARB; - - /* wait for arbitration to complete */ - for (timeout = 0; timeout < 3000000L; timeout++) - if (STATUS & STAT_ARB_CMPL) - break; - if (!(STATUS & STAT_ARB_CMPL)) { - if (STATUS & STAT_SEL) { - printf("%s: arbitration lost\n", sea->sc_dev.dv_xname); - scb->flags |= SCB_ERROR; - } else { - printf("%s: arbitration timeout\n", - sea->sc_dev.dv_xname); - scb->flags |= SCB_TIMEOUT; - } - CONTROL = BASE_CMD; - return -1; - } - - delay(2); - DATA = (u_char)((1 << scb->xs->sc_link->target) | sea->our_id_mask); - CONTROL = -#ifdef SEA_NOMSGS - (BASE_CMD & ~CMD_INTR) | CMD_DRVR_ENABLE | CMD_SEL; -#else - (BASE_CMD & ~CMD_INTR) | CMD_DRVR_ENABLE | CMD_SEL | CMD_ATTN; -#endif - delay(1); - - /* wait for a bsy from target */ - for (timeout = 0; timeout < 2000000L; timeout++) - if (STATUS & STAT_BSY) - break; - if (!(STATUS & STAT_BSY)) { - /* should return some error to the higher level driver */ - CONTROL = BASE_CMD; - scb->flags |= SCB_TIMEOUT; - return 0; - } - - /* Try to make the target to take a message from us */ -#ifdef SEA_NOMSGS - CONTROL = (BASE_CMD & ~CMD_INTR) | CMD_DRVR_ENABLE; -#else - CONTROL = (BASE_CMD & ~CMD_INTR) | CMD_DRVR_ENABLE | CMD_ATTN; -#endif - delay(1); - - /* should start a msg_out phase */ - for (timeout = 0; timeout < 2000000L; timeout++) - if (STATUS & STAT_REQ) - break; - /* Remove ATN. */ - CONTROL = BASE_CMD | CMD_DRVR_ENABLE; - if (!(STATUS & STAT_REQ)) { - /* - * This should not be taken as an error, but more like an - * unsupported feature! Should set a flag indicating that the - * target don't support messages, and continue without failure. - * (THIS IS NOT AN ERROR!) - */ - } else { - msg[0] = MSG_IDENTIFY(scb->xs->sc_link->lun, 1); - len = 1; - data = msg; - phase = PH_MSGOUT; - /* Should do test on result of sea_transfer_pio(). */ - sea_transfer_pio(sea, &phase, &len, &data); - } - if (!(STATUS & STAT_BSY)) - printf("%s: after successful arbitrate: no STAT_BSY!\n", - sea->sc_dev.dv_xname); - - sea->nexus = scb; - sea->busy[scb->xs->sc_link->target] |= 1 << scb->xs->sc_link->lun; - /* This assignment should depend on possibility to send a message to target. */ - CONTROL = BASE_CMD | CMD_DRVR_ENABLE; - /* XXX Reset pointer in command? */ - return 0; -} - -/* - * Send an abort to the target. Return 1 success, 0 on failure. - */ -int -sea_abort(sea, scb) - struct sea_softc *sea; - struct sea_scb *scb; -{ - struct sea_scb *tmp; - u_char msg, phase, *msgptr; - int len; - - /* - * If the command hasn't been issued yet, we simply remove it from the - * issue queue - * XXX Could avoid this loop. - */ - for (tmp = sea->ready_list.tqh_first; tmp; tmp = tmp->chain.tqe_next) - if (scb == tmp) { - TAILQ_REMOVE(&sea->ready_list, scb, chain); - /* XXX Set some type of error result for operation. */ - return 1; - } - - /* - * If any commands are connected, we're going to fail the abort and let - * the high level SCSI driver retry at a later time or issue a reset. - */ - if (sea->nexus) - return 0; - - /* - * If the command is currently disconnected from the bus, and there are - * no connected commands, we reconnect the I_T_L or I_T_L_Q nexus - * associated with it, go into message out, and send an abort message. - */ - for (tmp = sea->nexus_list.tqh_first; tmp; - tmp = tmp->chain.tqe_next) - if (scb == tmp) { - if (sea_select(sea, scb)) - return 0; - - msg = MSG_ABORT; - msgptr = &msg; - len = 1; - phase = PH_MSGOUT; - CONTROL = BASE_CMD | CMD_ATTN; - sea_transfer_pio(sea, &phase, &len, &msgptr); - - for (tmp = sea->nexus_list.tqh_first; tmp; - tmp = tmp->chain.tqe_next) - if (scb == tmp) { - TAILQ_REMOVE(&sea->nexus_list, - scb, chain); - /* XXX Set some type of error result - for the operation. */ - return 1; - } - } - - /* Command not found in any queue; race condition? */ - return 1; -} - -void -sea_done(sea, scb) - struct sea_softc *sea; - struct sea_scb *scb; -{ - struct scsi_xfer *xs = scb->xs; - - untimeout(sea_timeout, scb); - - xs->resid = scb->datalen; - - /* XXXX need to get status */ - if (scb->flags == SCB_ACTIVE) { - xs->resid = 0; - } else { - if (scb->flags & (SCB_TIMEOUT | SCB_ABORTED)) - xs->error = XS_TIMEOUT; - if (scb->flags & SCB_ERROR) - xs->error = XS_DRIVER_STUFFUP; - } - xs->flags |= ITSDONE; - sea_free_scb(sea, scb, xs->flags); - scsi_done(xs); -} - -/* - * Wait for completion of command in polled mode. - */ -int -sea_poll(sea, xs, count) - struct sea_softc *sea; - struct scsi_xfer *xs; - int count; -{ - int s; - - while (count) { - /* try to do something */ - s = splbio(); - if (!main_running) - sea_main(); - splx(s); - if (xs->flags & ITSDONE) - return 0; - delay(1000); - count--; - } - return 1; -} - -/* - * Do the transfer. We know we are connected. Update the flags, and call - * sea_done() when task accomplished. Dialog controlled by the target. - */ -void -sea_information_transfer(sea) - struct sea_softc *sea; -{ - int timeout; - u_char msgout = MSG_NOOP; - int len; - int s; - u_char *data; - u_char phase, tmp, old_phase = PH_INVALID; - struct sea_scb *scb = sea->nexus; - int loop; - - for (timeout = 0; timeout < 10000000L; timeout++) { - tmp = STATUS; - if (tmp & STAT_PARITY) - printf("%s: parity error detected\n", - sea->sc_dev.dv_xname); - if (!(tmp & STAT_BSY)) { - for (loop = 0; loop < 20; loop++) - if ((tmp = STATUS) & STAT_BSY) - break; - if (!(tmp & STAT_BSY)) { - printf("%s: !STAT_BSY unit in data transfer!\n", - sea->sc_dev.dv_xname); - s = splbio(); - sea->nexus = NULL; - scb->flags = SCB_ERROR; - splx(s); - sea_done(sea, scb); - return; - } - } - - /* we only have a valid SCSI phase when REQ is asserted */ - if (!(tmp & STAT_REQ)) - continue; - - if (sea->type == FDOMAIN840) - tmp = ((tmp & 0x08) >> 2) | - ((tmp & 0x02) << 2) | - (tmp & 0xf5); - phase = tmp & PH_MASK; - if (phase != old_phase) - old_phase = phase; - - switch (phase) { - case PH_DATAOUT: -#ifdef SEA_NODATAOUT - printf("%s: SEA_NODATAOUT set, attempted DATAOUT aborted\n", - sea->sc_dev.dv_xname); - msgout = MSG_ABORT; - CONTROL = BASE_CMD | CMD_ATTN; - break; -#endif - case PH_DATAIN: - if (!scb->data) - printf("no data address!\n"); -#ifdef SEA_BLINDTRANSFER - if (scb->datalen && !(scb->datalen % BLOCK_SIZE)) { - while (scb->datalen) { - for (loop = 0; loop < 50000; loop++) - if ((tmp = STATUS) & STAT_REQ) - break; - if (!(tmp & STAT_REQ)) { - printf("%s: timeout waiting for STAT_REQ\n", - sea->sc_dev.dv_xname); - /* XXX Do something? */ - } - if (sea->type == FDOMAIN840) - tmp = ((tmp & 0x08) >> 2) | - ((tmp & 0x02) << 2) | - (tmp & 0xf5); - if ((tmp & PH_MASK) != phase) - break; - if (!(phase & STAT_IO)) { -#ifdef SEA_ASSEMBLER - asm("shr $2, %%ecx\n\t\ - cld\n\t\ - rep\n\t\ - movsl" : - "=S" (scb->data) : - "0" (scb->data), - "D" (sea->maddr_dr), - "c" (BLOCK_SIZE) : - "%ecx", "%edi"); -#else - for (count = 0; - count < BLOCK_SIZE; - count++) - DATA = *(scb->data++); -#endif - } else { -#ifdef SEA_ASSEMBLER - asm("shr $2, %%ecx\n\t\ - cld\n\t\ - rep\n\t\ - movsl" : - "=D" (scb->data) : - "S" (sea->maddr_dr), - "0" (scb->data), - "c" (BLOCK_SIZE) : - "%ecx", "%esi"); -#else - for (count = 0; - count < BLOCK_SIZE; - count++) - *(scb->data++) = DATA; -#endif - } - scb->datalen -= BLOCK_SIZE; - } - } -#endif - if (scb->datalen) - sea_transfer_pio(sea, &phase, &scb->datalen, - &scb->data); - break; - case PH_MSGIN: - /* Multibyte messages should not be present here. */ - len = 1; - data = &tmp; - sea_transfer_pio(sea, &phase, &len, &data); - /* scb->MessageIn = tmp; */ - - switch (tmp) { - case MSG_ABORT: - scb->flags = SCB_ABORTED; - printf("sea: command aborted by target\n"); - CONTROL = BASE_CMD; - sea_done(sea, scb); - return; - case MSG_CMDCOMPLETE: - s = splbio(); - sea->nexus = NULL; - splx(s); - sea->busy[scb->xs->sc_link->target] &= - ~(1 << scb->xs->sc_link->lun); - CONTROL = BASE_CMD; - sea_done(sea, scb); - return; - case MSG_MESSAGE_REJECT: - printf("%s: message_reject recieved\n", - sea->sc_dev.dv_xname); - break; - case MSG_DISCONNECT: - s = splbio(); - TAILQ_INSERT_TAIL(&sea->nexus_list, - scb, chain); - sea->nexus = NULL; - CONTROL = BASE_CMD; - splx(s); - return; - case MSG_SAVEDATAPOINTER: - case MSG_RESTOREPOINTERS: - /* save/restore of pointers are ignored */ - break; - default: - /* - * This should be handled in the pio data - * transfer phase, as the ATN should be raised - * before ACK goes false when rejecting a - * message. - */ - printf("%s: unknown message in: %x\n", - sea->sc_dev.dv_xname, tmp); - break; - } /* switch (tmp) */ - break; - case PH_MSGOUT: - len = 1; - data = &msgout; - /* sea->last_message = msgout; */ - sea_transfer_pio(sea, &phase, &len, &data); - if (msgout == MSG_ABORT) { - printf("%s: sent message abort to target\n", - sea->sc_dev.dv_xname); - s = splbio(); - sea->busy[scb->xs->sc_link->target] &= - ~(1 << scb->xs->sc_link->lun); - sea->nexus = NULL; - scb->flags = SCB_ABORTED; - splx(s); - /* enable interrupt from scsi */ - sea_done(sea, scb); - return; - } - msgout = MSG_NOOP; - break; - case PH_CMD: - len = scb->xs->cmdlen; - data = (char *) scb->xs->cmd; - sea_transfer_pio(sea, &phase, &len, &data); - break; - case PH_STAT: - len = 1; - data = &tmp; - sea_transfer_pio(sea, &phase, &len, &data); - scb->xs->status = tmp; - break; - default: - printf("sea: unknown phase\n"); - } /* switch (phase) */ - } /* for (...) */ - - /* If we get here we have got a timeout! */ - printf("%s: timeout in data transfer\n", sea->sc_dev.dv_xname); - scb->flags = SCB_TIMEOUT; - /* XXX Should I clear scsi-bus state? */ - sea_done(sea, scb); -} diff --git a/sys/arch/i386/isa/ultra14f.c b/sys/arch/i386/isa/ultra14f.c deleted file mode 100644 index bda7fadbf9be..000000000000 --- a/sys/arch/i386/isa/ultra14f.c +++ /dev/null @@ -1,1353 +0,0 @@ -/* $NetBSD: ultra14f.c,v 1.46 1995/01/13 14:46:56 mycroft Exp $ */ - -/* - * Copyright (c) 1994 Charles Hannum. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Ported for use with the UltraStor 14f by Gary Close (gclose@wvnvms.wvnet.edu) - * Slight fixes to timeouts to run with the 34F - * Thanks to Julian Elischer for advice and help with this port. - * - * Originally written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * commenced: Sun Sep 27 18:14:01 PDT 1992 - * slight mod to make work with 34F as well: Wed Jun 2 18:05:48 WST 1993 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#ifdef DDB -int Debugger(); -#else /* DDB */ -#define Debugger() panic("should call debugger here (ultra14f.c)") -#endif /* DDB */ - -typedef u_long physaddr; -typedef u_long physlen; - -#define KVTOPHYS(x) vtophys(x) - -#define UHA_MSCP_MAX 32 /* store up to 32 MSCPs at one time */ -#define MSCP_HASH_SIZE 32 /* hash table size for phystokv */ -#define MSCP_HASH_SHIFT 9 -#define MSCP_HASH(x) ((((long)(x))>>MSCP_HASH_SHIFT) & (MSCP_HASH_SIZE - 1)) - -#define UHA_NSEG 33 /* number of dma segments supported */ - -/************************** board definitions *******************************/ -/* - * I/O Port Interface - */ -#define U14_LMASK 0x0000 /* local doorbell mask reg */ -#define U14_LINT 0x0001 /* local doorbell int/stat reg */ -#define U14_SMASK 0x0002 /* system doorbell mask reg */ -#define U14_SINT 0x0003 /* system doorbell int/stat reg */ -#define U14_ID 0x0004 /* product id reg (2 ports) */ -#define U14_CONFIG 0x0006 /* config reg (2 ports) */ -#define U14_OGMPTR 0x0008 /* outgoing mail ptr (4 ports) */ -#define U14_ICMPTR 0x000c /* incoming mail ptr (4 ports) */ - -#define U24_CONFIG 0x0c85 /* config reg (3 ports) */ -#define U24_LMASK 0x0c8c /* local doorbell mask reg */ -#define U24_LINT 0x0c8d /* local doorbell int/stat reg */ -#define U24_SMASK 0x0c8e /* system doorbell mask reg */ -#define U24_SINT 0x0c8f /* system doorbell int/stat reg */ -#define U24_OGMCMD 0x0c96 /* outgoing commands */ -#define U24_OGMPTR 0x0c97 /* outgoing mail ptr (4 ports) */ -#define U24_ICMCMD 0x0c9b /* incoming commands */ -#define U24_ICMPTR 0x0c9c /* incoming mail ptr (4 ports) */ - -/* - * UHA_LMASK bits (read only) - */ -#define UHA_LDIE 0x80 /* local doorbell int enabled */ -#define UHA_SRSTE 0x40 /* soft reset enabled */ -#define UHA_ABORTEN 0x10 /* abort MSCP enabled */ -#define UHA_OGMINTEN 0x01 /* outgoing mail interrupt enabled */ - -/* - * UHA_LINT bits (read/write) - */ -#define U14_OGMFULL 0x01 /* outgoing mailbox is full */ -#define U14_ABORT 0x10 /* abort MSCP */ -#define U14_SBRST 0x20 /* scsi bus reset */ -#define U14_ADRST 0x40 /* adapter soft reset */ -#define U14_ASRST 0x60 /* adapter and scsi reset */ - -#define U24_OGMFULL 0x02 /* outgoing mailbox is full */ -#define U24_ABORT 0x10 /* abort MSCP */ -#define U24_SBRST 0x40 /* scsi bus reset */ -#define U24_ADRST 0x80 /* adapter soft reset */ -#define U24_ASRST 0xc0 /* adapter and scsi reset */ - -/* - * UHA_SMASK bits (read/write) - */ -#define UHA_ENSINT 0x80 /* enable system doorbell interrupt */ -#define UHA_EN_ABORT_COMPLETE 0x10 /* enable abort MSCP complete int */ -#define UHA_ENICM 0x01 /* enable ICM interrupt */ - -/* - * UHA_SINT bits (read) - */ -#define U14_ABORT_SUCC 0x10 /* abort MSCP successful */ -#define U14_ABORT_FAIL 0x18 /* abort MSCP failed */ -#define U14_SINTP 0x80 /* system doorbell int pending */ - -#define U24_SINTP 0x02 /* system doorbell int pending */ -#define U24_ABORT_SUCC 0x10 /* abort MSCP successful */ -#define U24_ABORT_FAIL 0x18 /* abort MSCP failed */ - -/* - * UHA_SINT bits (write) - */ -#define U14_ICM_ACK 0x01 /* acknowledge ICM and clear */ -#define U14_ABORT_ACK 0x18 /* acknowledge status and clear */ - -#define U24_ICM_ACK 0x02 /* acknowledge ICM and clear */ -#define U24_ABORT_ACK 0x18 /* acknowledge status and clear */ - -/* - * U14_CONFIG bits (read only) - */ -#define U14_DMA_CH5 0x0000 /* DMA channel 5 */ -#define U14_DMA_CH6 0x4000 /* 6 */ -#define U14_DMA_CH7 0x8000 /* 7 */ -#define U14_DMA_MASK 0xc000 -#define U14_IRQ15 0x0000 /* IRQ 15 */ -#define U14_IRQ14 0x1000 /* 14 */ -#define U14_IRQ11 0x2000 /* 11 */ -#define U14_IRQ10 0x3000 /* 10 */ -#define U14_IRQ_MASK 0x3000 -#define U14_HOSTID_MASK 0x0007 - -/* - * U24_CONFIG bits (read only) - */ -#define U24_MAGIC1 0x08 -#define U24_IRQ15 0x10 -#define U24_IRQ14 0x20 -#define U24_IRQ11 0x40 -#define U24_IRQ10 0x80 -#define U24_IRQ_MASK 0xf0 - -#define U24_MAGIC2 0x04 - -#define U24_HOSTID_MASK 0x07 - -/* - * EISA registers (offset from slot base) - */ -#define EISA_VENDOR 0x0c80 /* vendor ID (2 ports) */ -#define EISA_MODEL 0x0c82 /* model number (2 ports) */ -#define EISA_CONTROL 0x0c84 -#define EISA_RESET 0x04 -#define EISA_ERROR 0x02 -#define EISA_ENABLE 0x01 - -/* - * host_stat error codes - */ -#define UHA_NO_ERR 0x00 /* No error supposedly */ -#define UHA_SBUS_ABORT_ERR 0x84 /* scsi bus abort error */ -#define UHA_SBUS_TIMEOUT 0x91 /* scsi bus selection timeout */ -#define UHA_SBUS_OVER_UNDER 0x92 /* scsi bus over/underrun */ -#define UHA_BAD_SCSI_CMD 0x96 /* illegal scsi command */ -#define UHA_AUTO_SENSE_ERR 0x9b /* auto request sense err */ -#define UHA_SBUS_RES_ERR 0xa3 /* scsi bus reset error */ -#define UHA_BAD_SG_LIST 0xff /* invalid scatter gath list */ - -struct uha_dma_seg { - physaddr seg_addr; - physlen seg_len; -}; - -#pragma pack(1) -struct uha_mscp { - u_char opcode:3; -#define UHA_HAC 0x01 /* host adapter command */ -#define UHA_TSP 0x02 /* target scsi pass through command */ -#define UHA_SDR 0x04 /* scsi device reset */ - u_char xdir:2; /* xfer direction */ -#define UHA_SDET 0x00 /* determined by scsi command */ -#define UHA_SDIN 0x01 /* scsi data in */ -#define UHA_SDOUT 0x02 /* scsi data out */ -#define UHA_NODATA 0x03 /* no data xfer */ - u_char dcn:1; /* disable disconnect for this command */ - u_char ca:1; /* cache control */ - u_char sgth:1; /* scatter gather flag */ - u_char target:3; - u_char chan:2; /* scsi channel (always 0 for 14f) */ - u_char lun:3; - physaddr data_addr; - physlen data_length; - physaddr link_addr; - u_char link_id; - u_char sg_num; /* number of scat gath segs */ - /*in s-g list if sg flag is */ - /*set. starts at 1, 8bytes per */ - u_char req_sense_length; - u_char scsi_cmd_length; - struct scsi_generic scsi_cmd; - u_char host_stat; - u_char target_stat; - physaddr sense_ptr; /* if 0 no auto sense */ - /*-----------------end of hardware supported fields----------------*/ - TAILQ_ENTRY(uha_mscp) chain; - struct uha_mscp *nexthash; - long hashkey; - struct scsi_xfer *xs; /* the scsi_xfer for this cmd */ - int flags; -#define MSCP_FREE 0 -#define MSCP_ACTIVE 1 -#define MSCP_ABORTED 2 - struct uha_dma_seg uha_dma[UHA_NSEG]; - struct scsi_sense_data mscp_sense; -}; -#pragma pack(4) - -struct uha_softc { - struct device sc_dev; - struct isadev sc_id; - struct intrhand sc_ih; - - int sc_iobase; - int sc_irq, sc_drq; - - void (*send_mbox)(); - int (*abort)(); - int (*poll)(); - int (*intr)(); - void (*init)(); - - struct uha_mscp *mscphash[MSCP_HASH_SIZE]; - TAILQ_HEAD(, uha_mscp) free_mscp; - int nummscps; - int uha_scsi_dev; /* our scsi id */ - struct scsi_link sc_link; -}; - -void u14_start_mbox __P((struct uha_softc *, int, struct uha_mscp *)); -void u14_send_mbox __P((struct uha_softc *, struct uha_mscp *)); -void u24_start_mbox __P((struct uha_softc *, int, struct uha_mscp *)); -void u24_send_mbox __P((struct uha_softc *, struct uha_mscp *)); -int u14_abort __P((struct uha_softc *, struct uha_mscp *)); -int u24_abort __P((struct uha_softc *, struct uha_mscp *)); -int u14_poll __P((struct uha_softc *, struct scsi_xfer *, int)); -int u24_poll __P((struct uha_softc *, struct scsi_xfer *, int)); -int u14intr __P((struct uha_softc *)); -int u24intr __P((struct uha_softc *)); -void uha_done __P((struct uha_softc *, struct uha_mscp *)); -void uha_free_mscp __P((struct uha_softc *, struct uha_mscp *, int flags)); -struct uha_mscp *uha_get_mscp __P((struct uha_softc *, int)); -struct uha_mscp *uha_mscp_phys_kv __P((struct uha_softc *, u_long)); -int u14_find __P((struct uha_softc *, struct isa_attach_args *)); -int u24_find __P((struct uha_softc *, struct isa_attach_args *)); -void u14_init __P((struct uha_softc *)); -void u24_init __P((struct uha_softc *)); -void uhaminphys __P((struct buf *)); -int uha_scsi_cmd __P((struct scsi_xfer *)); -void uha_timeout __P((void *arg)); -#ifdef UHADEBUG -void uha_print_mscp __P((struct uha_mscp *)); -void uha_print_active_mscp __P((struct uha_softc *)); -#endif - -u_long scratch; -#define UHA_SHOWMSCPS 0x01 -#define UHA_SHOWINTS 0x02 -#define UHA_SHOWCMDS 0x04 -#define UHA_SHOWMISC 0x08 - -struct scsi_adapter uha_switch = { - uha_scsi_cmd, - uhaminphys, - 0, - 0, -}; - -/* the below structure is so we have a default dev struct for out link struct */ -struct scsi_device uha_dev = { - NULL, /* Use default error handler */ - NULL, /* have a queue, served by this */ - NULL, /* have no async handler */ - NULL, /* Use default 'done' routine */ -}; - -int uhaprobe __P((struct device *, void *, void *)); -void uhaattach __P((struct device *, struct device *, void *)); - -struct cfdriver uhacd = { - NULL, "uha", uhaprobe, uhaattach, DV_DULL, sizeof(struct uha_softc) -}; - -/* - * Function to send a command out through a mailbox - */ -void -u14_start_mbox(uha, opcode, mscp) - struct uha_softc *uha; - int opcode; - struct uha_mscp *mscp; -{ - int iobase = uha->sc_iobase; - int spincount = 100000; /* 1s should be enough */ - - while (--spincount) { - if ((inb(iobase + U14_LINT) & U14_OGMFULL) == 0) - break; - delay(100); - } - if (!spincount) { - printf("%s: uha_send_mbox, board not responding\n", - uha->sc_dev.dv_xname); - Debugger(); - } - - outl(iobase + U14_OGMPTR, KVTOPHYS(mscp)); - outb(iobase + U14_LINT, opcode); -} - -void -u14_send_mbox(uha, mscp) - struct uha_softc *uha; - struct uha_mscp *mscp; -{ - - u14_start_mbox(uha, U14_OGMFULL, mscp); -} - -void -u24_start_mbox(uha, opcode, mscp) - struct uha_softc *uha; - int opcode; - struct uha_mscp *mscp; -{ - int iobase = uha->sc_iobase; - int spincount = 100000; /* 1s should be enough */ - - while (--spincount) { - if ((inb(iobase + U24_LINT) & U24_OGMFULL) == 0) - break; - delay(100); - } - if (!spincount) { - printf("%s: uha_send_mbox, board not responding\n", - uha->sc_dev.dv_xname); - Debugger(); - } - - outl(iobase + U24_OGMPTR, KVTOPHYS(mscp)); - outb(iobase + U24_OGMCMD, 1); - outb(iobase + U24_LINT, opcode); -} - -void -u24_send_mbox(uha, mscp) - struct uha_softc *uha; - struct uha_mscp *mscp; -{ - - u24_start_mbox(uha, U24_OGMFULL, mscp); -} - -/* - * Function to send abort - */ -int -u14_abort(uha, mscp) - struct uha_softc *uha; - struct uha_mscp *mscp; -{ - int iobase = uha->sc_iobase; - int abortcount = 200000; /* 2 secs */ - int s = splbio(); - - u14_start_mbox(uha, U14_ABORT, mscp); - - while (--abortcount) { - if (inb(iobase + U14_SINT) & U14_ABORT_FAIL) - break; - delay(10); - } - if (!abortcount) { - printf("%s: u14_abort, board not responding\n", - uha->sc_dev.dv_xname); - Debugger(); - } - - if ((inb(iobase + U14_SINT) & (U14_ABORT_FAIL | U14_ABORT_SUCC)) == - U14_ABORT_SUCC) { - outb(iobase + U14_SINT, U14_ABORT_ACK); - splx(s); - return 1; - } else { - outb(iobase + U14_SINT, U14_ABORT_ACK); - splx(s); - return 0; - } -} - -int -u24_abort(uha, mscp) - struct uha_softc *uha; - struct uha_mscp *mscp; -{ - int iobase = uha->sc_iobase; - int abortcount = 200000; /* 2 secs */ - int s = splbio(); - - u24_start_mbox(uha, U24_ABORT, mscp); - - while (--abortcount) { - if (inb(iobase + U24_SINT) & U24_ABORT_FAIL) - break; - delay(10); - } - if (!abortcount) { - printf("%s: u24_abort, board not responding\n", - uha->sc_dev.dv_xname); - Debugger(); - } - - if ((inb(iobase + U24_SINT) & (U24_ABORT_FAIL | U24_ABORT_SUCC)) == - U24_ABORT_SUCC) { - outb(iobase + U24_SINT, U24_ABORT_ACK); - splx(s); - return 1; - } else { - outb(iobase + U24_SINT, U24_ABORT_ACK); - splx(s); - return 0; - } -} - -/* - * Function to poll for command completion when in poll mode. - * - * wait = timeout in msec - */ -int -u14_poll(uha, xs, count) - struct uha_softc *uha; - struct scsi_xfer *xs; - int count; -{ - int iobase = uha->sc_iobase; - - while (count) { - /* - * If we had interrupts enabled, would we - * have got an interrupt? - */ - if (inb(iobase + U14_SINT) & U14_SINTP) - u14intr(uha); - if (xs->flags & ITSDONE) - return 0; - delay(1000); - count--; - } - return 1; -} - -int -u24_poll(uha, xs, count) - struct uha_softc *uha; - struct scsi_xfer *xs; - int count; -{ - int iobase = uha->sc_iobase; - - while (count) { - /* - * If we had interrupts enabled, would we - * have got an interrupt? - */ - if (inb(iobase + U24_SINT) & U24_SINTP) - u24intr(uha); - if (xs->flags & ITSDONE) - return 0; - delay(1000); - count--; - } - return 1; -} - -/* - * Check if the device can be found at the port given and if so, set it up - * ready for further work as an argument, takes the isa_device structure - * from autoconf.c - */ -int -uhaprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct uha_softc *uha = match; - struct isa_attach_args *ia = aux; - - uha->sc_iobase = ia->ia_iobase; - - /* - * Try initialise a unit at this location - * sets up dma and bus speed, loads uha->sc_irq - */ - if (u24_find(uha, ia) != 0 && u14_find(uha, ia) != 0) - return 0; - - if (ia->ia_irq != IRQUNK) { - if (ia->ia_irq != uha->sc_irq) { - printf("%s: irq mismatch; kernel configured %d != board configured %d\n", - uha->sc_dev.dv_xname, ia->ia_irq, uha->sc_irq); - return 0; - } - } else - ia->ia_irq = uha->sc_irq; - - if (ia->ia_drq != DRQUNK) { - if (ia->ia_drq != uha->sc_drq) { - printf("%s: drq mismatch; kernel configured %d != board configured %d\n", - uha->sc_dev.dv_xname, ia->ia_drq, uha->sc_drq); - return 0; - } - } else - ia->ia_drq = uha->sc_drq; - - ia->ia_msize = 0; - ia->ia_iosize = 16; - return 1; -} - -uhaprint() -{ - -} - -/* - * Attach all the sub-devices we can find - */ -void -uhaattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct isa_attach_args *ia = aux; - struct uha_softc *uha = (void *)self; - - if (ia->ia_drq != DRQUNK) - isa_dmacascade(ia->ia_drq); - - (uha->init)(uha); - TAILQ_INIT(&uha->free_mscp); - - /* - * fill in the prototype scsi_link. - */ - uha->sc_link.adapter_softc = uha; - uha->sc_link.adapter_target = uha->uha_scsi_dev; - uha->sc_link.adapter = &uha_switch; - uha->sc_link.device = &uha_dev; - uha->sc_link.openings = 2; - - printf("\n"); - -#ifdef NEWCONFIG - isa_establish(&uha->sc_id, &uha->sc_dev); -#endif - uha->sc_ih.ih_fun = uha->intr; - uha->sc_ih.ih_arg = uha; - uha->sc_ih.ih_level = IPL_BIO; - intr_establish(ia->ia_irq, IST_EDGE, &uha->sc_ih); - - /* - * ask the adapter what subunits are present - */ - config_found(self, &uha->sc_link, uhaprint); -} - -/* - * Catch an interrupt from the adaptor - */ -int -u14intr(uha) - struct uha_softc *uha; -{ - struct uha_mscp *mscp; - u_char uhastat; - u_long mboxval; - int iobase = uha->sc_iobase; - -#ifdef UHADEBUG - printf("%s: uhaintr ", uha->sc_dev.dv_xname); -#endif /*UHADEBUG */ - - if ((inb(iobase + U14_SINT) & U14_SINTP) == 0) - return 0; - - for (;;) { - /* - * First get all the information and then - * acknowledge the interrupt - */ - uhastat = inb(iobase + U14_SINT); - mboxval = inl(iobase + U14_ICMPTR); - outb(iobase + U14_SINT, U14_ICM_ACK); - -#ifdef UHADEBUG - printf("status = 0x%x ", uhastat); -#endif /*UHADEBUG*/ - - /* - * Process the completed operation - */ - mscp = uha_mscp_phys_kv(uha, mboxval); - if (!mscp) { - printf("%s: BAD MSCP RETURNED!\n", - uha->sc_dev.dv_xname); - continue; /* whatever it was, it'll timeout */ - } - untimeout(uha_timeout, mscp); - uha_done(uha, mscp); - - if ((inb(iobase + U14_SINT) & U14_SINTP) == 0) - return 1; - } -} - -int -u24intr(uha) - struct uha_softc *uha; -{ - struct uha_mscp *mscp; - u_char uhastat; - u_long mboxval; - int iobase = uha->sc_iobase; - -#ifdef UHADEBUG - printf("%s: uhaintr ", uha->sc_dev.dv_xname); -#endif /*UHADEBUG */ - - if ((inb(iobase + U24_SINT) & U24_SINTP) == 0) - return 0; - - for (;;) { - /* - * First get all the information and then - * acknowledge the interrupt - */ - uhastat = inb(iobase + U24_SINT); - mboxval = inl(iobase + U24_ICMPTR); - outb(iobase + U24_SINT, U24_ICM_ACK); - outb(iobase + U24_ICMCMD, 0); - -#ifdef UHADEBUG - printf("status = 0x%x ", uhastat); -#endif /*UHADEBUG*/ - - /* - * Process the completed operation - */ - mscp = uha_mscp_phys_kv(uha, mboxval); - if (!mscp) { - printf("%s: BAD MSCP RETURNED!\n", - uha->sc_dev.dv_xname); - continue; /* whatever it was, it'll timeout */ - } - untimeout(uha_timeout, mscp); - uha_done(uha, mscp); - - if ((inb(iobase + U24_SINT) & U24_SINTP) == 0) - return 1; - } -} - -/* - * We have a mscp which has been processed by the adaptor, now we look to see - * how the operation went. - */ -void -uha_done(uha, mscp) - struct uha_softc *uha; - struct uha_mscp *mscp; -{ - struct scsi_sense_data *s1, *s2; - struct scsi_xfer *xs = mscp->xs; - - SC_DEBUG(xs->sc_link, SDEV_DB2, ("uha_done\n")); - /* - * Otherwise, put the results of the operation - * into the xfer and call whoever started it - */ - if ((xs->flags & INUSE) == 0) { - printf("%s: exiting but not in use!\n", uha->sc_dev.dv_xname); - Debugger(); - } - if (xs->error == XS_NOERROR) { - if (mscp->host_stat != UHA_NO_ERR) { - switch (mscp->host_stat) { - case UHA_SBUS_TIMEOUT: /* No response */ - xs->error = XS_SELTIMEOUT; - break; - case UHA_SBUS_OVER_UNDER: - SC_DEBUG(xs->sc_link, SDEV_DB3, - ("scsi bus xfer over/underrun\n")); - xs->error = XS_DRIVER_STUFFUP; - break; - case UHA_BAD_SG_LIST: - SC_DEBUG(xs->sc_link, SDEV_DB3, - ("bad sg list reported back\n")); - xs->error = XS_DRIVER_STUFFUP; - break; - default: /* Other scsi protocol messes */ - printf("%s: host_stat %x\n", - uha->sc_dev.dv_xname, mscp->host_stat); - xs->error = XS_DRIVER_STUFFUP; - } - } else if (mscp->target_stat != SCSI_OK) { - switch (mscp->target_stat) { - case SCSI_CHECK: - s1 = &mscp->mscp_sense; - s2 = &xs->sense; - *s2 = *s1; - xs->error = XS_SENSE; - break; - case SCSI_BUSY: - xs->error = XS_BUSY; - break; - default: - printf("%s: target_stat %x\n", - uha->sc_dev.dv_xname, mscp->target_stat); - xs->error = XS_DRIVER_STUFFUP; - } - } else - xs->resid = 0; - } - xs->flags |= ITSDONE; - uha_free_mscp(uha, mscp, xs->flags); - scsi_done(xs); -} - -/* - * A mscp (and hence a mbx-out) is put onto the free list. - */ -void -uha_free_mscp(uha, mscp, flags) - struct uha_softc *uha; - struct uha_mscp *mscp; - int flags; -{ - int opri; - - opri = splbio(); - - mscp->flags = MSCP_FREE; - TAILQ_INSERT_HEAD(&uha->free_mscp, mscp, chain); - - /* - * If there were none, wake abybody waiting for - * one to come free, starting with queued entries - */ - if (!mscp->chain.tqe_next) - wakeup(&uha->free_mscp); - - splx(opri); -} - -/* - * Get a free mscp - * - * If there are none, see if we can allocate a new one. If so, put it in the - * hash table too otherwise either return an error or sleep. - */ -struct uha_mscp * -uha_get_mscp(uha, flags) - struct uha_softc *uha; - int flags; -{ - int opri; - struct uha_mscp *mscp; - int hashnum; - - opri = splbio(); - - /* - * If we can and have to, sleep waiting for one to come free - * but only if we can't allocate a new one - */ - for (;;) { - mscp = uha->free_mscp.tqh_first; - if (mscp) { - TAILQ_REMOVE(&uha->free_mscp, mscp, chain); - break; - } - if (uha->nummscps < UHA_MSCP_MAX) { - if (mscp = (struct uha_mscp *) malloc(sizeof(struct uha_mscp), - M_TEMP, M_NOWAIT)) { - bzero(mscp, sizeof(struct uha_mscp)); - uha->nummscps++; - /* - * put in the phystokv hash table - * Never gets taken out. - */ - mscp->hashkey = KVTOPHYS(mscp); - hashnum = MSCP_HASH(mscp->hashkey); - mscp->nexthash = uha->mscphash[hashnum]; - uha->mscphash[hashnum] = mscp; - } else { - printf("%s: can't malloc mscp\n", - uha->sc_dev.dv_xname); - } - break; - } else { - if ((flags & SCSI_NOSLEEP) == 0) - tsleep(&uha->free_mscp, PRIBIO, "uhamsc", 0); - } - } - - splx(opri); - return mscp; -} - -/* - * given a physical address, find the mscp that it corresponds to. - */ -struct uha_mscp * -uha_mscp_phys_kv(uha, mscp_phys) - struct uha_softc *uha; - u_long mscp_phys; -{ - int hashnum = MSCP_HASH(mscp_phys); - struct uha_mscp *mscp = uha->mscphash[hashnum]; - - while (mscp) { - if (mscp->hashkey == mscp_phys) - break; - mscp = mscp->nexthash; - } - return mscp; -} - -/* - * Start the board, ready for normal operation - */ -int -u14_find(uha, ia) - struct uha_softc *uha; - struct isa_attach_args *ia; -{ - int iobase = uha->sc_iobase; - u_short model, config; - int resetcount = 4000; /* 4 secs? */ - - if (ia->ia_iobase == IOBASEUNK) - return ENXIO; - - model = htons(inw(iobase + U14_ID)); - if ((model & 0xfff0) != 0x5640) - return ENXIO; - - config = htons(inw(iobase + U14_CONFIG)); - - switch (model & 0x000f) { - case 0x0001: - /* This is a 34f, and doens't need an ISA DMA channel. */ - uha->sc_drq = DRQUNK; - break; - default: - switch (config & U14_DMA_MASK) { - case U14_DMA_CH5: - uha->sc_drq = 5; - break; - case U14_DMA_CH6: - uha->sc_drq = 6; - break; - case U14_DMA_CH7: - uha->sc_drq = 7; - break; - default: - printf("illegal dma setting %x\n", config & U14_DMA_MASK); - return EIO; - } - break; - } - - switch (config & U14_IRQ_MASK) { - case U14_IRQ10: - uha->sc_irq = 10; - break; - case U14_IRQ11: - uha->sc_irq = 11; - break; - case U14_IRQ14: - uha->sc_irq = 14; - break; - case U14_IRQ15: - uha->sc_irq = 15; - break; - default: - printf("illegal int setting %x\n", config & U14_IRQ_MASK); - return EIO; - } - - /* who are we on the scsi bus */ - uha->uha_scsi_dev = config & U14_HOSTID_MASK; - - outb(iobase + U14_LINT, U14_ASRST); - - while (--resetcount) { - if (inb(iobase + U14_LINT)) - break; - delay(1000); /* 1 mSec per loop */ - } - if (!resetcount) { - printf("%s: board timed out during reset\n", - uha->sc_dev.dv_xname); - return ENXIO; - } - - /* Save function pointers for later use. */ - uha->send_mbox = u14_send_mbox; - uha->abort = u14_abort; - uha->poll = u14_poll; - uha->intr = u14intr; - uha->init = u14_init; - - return 0; -} - -int -u24_find(uha, ia) - struct uha_softc *uha; - struct isa_attach_args *ia; -{ - static int uha_slot = 0; - int iobase; - u_short vendor, model; - u_char config0, config1, config2; - u_char irq_ch, uha_id; - int resetcount = 4000; /* 4 secs? */ - - if (ia->ia_iobase != IOBASEUNK) - return ENXIO; - - while (uha_slot < 15) { - uha_slot++; - iobase = 0x1000 * uha_slot; - - vendor = htons(inw(iobase + EISA_VENDOR)); - if (vendor != 0x5663) /* `USC' */ - continue; - - model = htons(inw(iobase + EISA_MODEL)); - if ((model & 0xfff0) != 0x0240) { -#ifndef trusted - printf("u24_find: ignoring model %04x\n", model); -#endif - continue; - } - -#if 0 - outb(iobase + EISA_CONTROL, EISA_ENABLE | EISA_RESET); - delay(10); - outb(iobase + EISA_CONTROL, EISA_ENABLE); - /* Wait for reset? */ - delay(1000); -#endif - - config0 = inb(iobase + U24_CONFIG); - config1 = inb(iobase + U24_CONFIG + 1); - config2 = inb(iobase + U24_CONFIG + 2); - if ((config0 & U24_MAGIC1) == 0 || - (config1 & U24_MAGIC2) == 0) - continue; - - irq_ch = config0 & U24_IRQ_MASK; - uha_id = config2 & U24_HOSTID_MASK; - - uha->sc_drq = DRQUNK; - - switch (irq_ch) { - case U24_IRQ10: - uha->sc_irq = 10; - break; - case U24_IRQ11: - uha->sc_irq = 11; - break; - case U24_IRQ14: - uha->sc_irq = 14; - break; - case U24_IRQ15: - uha->sc_irq = 15; - break; - default: - printf("illegal int setting %x\n", irq_ch); - continue; - } - - /* who are we on the scsi bus */ - uha->uha_scsi_dev = uha_id; - - outb(iobase + U24_LINT, U24_ASRST); - - while (--resetcount) { - if (inb(iobase + U24_LINT)) - break; - delay(1000); /* 1 mSec per loop */ - } - if (!resetcount) { - printf("%s: board timed out during reset\n", - uha->sc_dev.dv_xname); - continue; - } - - /* Save function pointers for later use. */ - uha->send_mbox = u24_send_mbox; - uha->abort = u24_abort; - uha->poll = u24_poll; - uha->intr = u24intr; - uha->init = u24_init; - - return 0; - } - - return ENXIO; -} - -void -u14_init(uha) - struct uha_softc *uha; -{ - int iobase = uha->sc_iobase; - - /* make sure interrupts are enabled */ - outb(iobase + U14_SMASK, - UHA_ENSINT | UHA_EN_ABORT_COMPLETE | UHA_ENICM); -} - -void -u24_init(uha) - struct uha_softc *uha; -{ - int iobase = uha->sc_iobase; - - /* free OGM and ICM */ - outb(iobase + U24_OGMCMD, 0); - outb(iobase + U24_ICMCMD, 0); - /* make sure interrupts are enabled */ - outb(iobase + U24_SMASK, 0xc2); /* XXXX */ -} - -void -uhaminphys(bp) - struct buf *bp; -{ - - if (bp->b_bcount > ((UHA_NSEG - 1) << PGSHIFT)) - bp->b_bcount = ((UHA_NSEG - 1) << PGSHIFT); -} - -/* - * start a scsi operation given the command and the data address. Also - * needs the unit, target and lu. - */ -int -uha_scsi_cmd(xs) - struct scsi_xfer *xs; -{ - struct scsi_link *sc_link = xs->sc_link; - struct uha_softc *uha = sc_link->adapter_softc; - struct uha_mscp *mscp; - struct uha_dma_seg *sg; - int seg; /* scatter gather seg being worked on */ - u_long thiskv, thisphys, nextphys; - int bytes_this_seg, bytes_this_page, datalen, flags; - struct iovec *iovp; - int s; - - SC_DEBUG(sc_link, SDEV_DB2, ("uha_scsi_cmd\n")); - /* - * get a mscp (mbox-out) to use. If the transfer - * is from a buf (possibly from interrupt time) - * then we can't allow it to sleep - */ - flags = xs->flags; - if ((flags & (ITSDONE|INUSE)) != INUSE) { - printf("%s: done or not in use?\n", uha->sc_dev.dv_xname); - xs->flags &= ~ITSDONE; - xs->flags |= INUSE; - } - if ((mscp = uha_get_mscp(uha, flags)) == NULL) { - xs->error = XS_DRIVER_STUFFUP; - return TRY_AGAIN_LATER; - } - mscp->flags = MSCP_ACTIVE; - mscp->xs = xs; - - /* - * Put all the arguments for the xfer in the mscp - */ - if (flags & SCSI_RESET) { - mscp->opcode = UHA_SDR; - mscp->ca = 0x01; - } else { - mscp->opcode = UHA_TSP; - /* XXX Not for tapes. */ - mscp->ca = 0x01; - } - mscp->xdir = UHA_SDET; - mscp->dcn = 0x00; - mscp->chan = 0x00; - mscp->target = sc_link->target; - mscp->lun = sc_link->lun; - mscp->scsi_cmd_length = xs->cmdlen; - mscp->sense_ptr = KVTOPHYS(&mscp->mscp_sense); - mscp->req_sense_length = sizeof(mscp->mscp_sense); - mscp->host_stat = 0x00; - mscp->target_stat = 0x00; - - if (xs->datalen && (flags & SCSI_RESET) == 0) { - mscp->data_addr = KVTOPHYS(mscp->uha_dma); - sg = mscp->uha_dma; - seg = 0; - mscp->sgth = 0x01; -#ifdef TFS - if (flags & SCSI_DATA_UIO) { - iovp = ((struct uio *) xs->data)->uio_iov; - datalen = ((struct uio *) xs->data)->uio_iovcnt; - xs->datalen = 0; - while (datalen && seg < UHA_NSEG) { - sg->seg_addr = (physaddr)iovp->iov_base; - sg->seg_len = iovp->iov_len; - xs->datalen += iovp->iov_len; - SC_DEBUGN(sc_link, SDEV_DB4, ("(0x%x@0x%x)", - iovp->iov_len, iovp->iov_base)); - sg++; - iovp++; - seg++; - datalen--; - } - } else -#endif /*TFS */ - { - /* - * Set up the scatter gather block - */ - SC_DEBUG(sc_link, SDEV_DB4, - ("%d @0x%x:- ", xs->datalen, xs->data)); - datalen = xs->datalen; - thiskv = (int) xs->data; - thisphys = KVTOPHYS(thiskv); - - while (datalen && seg < UHA_NSEG) { - bytes_this_seg = 0; - - /* put in the base address */ - sg->seg_addr = thisphys; - - SC_DEBUGN(sc_link, SDEV_DB4, ("0x%x", thisphys)); - - /* do it at least once */ - nextphys = thisphys; - while (datalen && thisphys == nextphys) { - /* - * This page is contiguous (physically) - * with the the last, just extend the - * length - */ - /* how far to the end of the page */ - nextphys = (thisphys & ~PGOFSET) + NBPG; - bytes_this_page = nextphys - thisphys; - /**** or the data ****/ - bytes_this_page = min(bytes_this_page, - datalen); - bytes_this_seg += bytes_this_page; - datalen -= bytes_this_page; - - /* get more ready for the next page */ - thiskv = (thiskv & ~PGOFSET) + NBPG; - if (datalen) - thisphys = KVTOPHYS(thiskv); - } - /* - * next page isn't contiguous, finish the seg - */ - SC_DEBUGN(sc_link, SDEV_DB4, - ("(0x%x)", bytes_this_seg)); - sg->seg_len = bytes_this_seg; - sg++; - seg++; - } - } - /* end of iov/kv decision */ - mscp->data_length = xs->datalen; - mscp->sg_num = seg; - SC_DEBUGN(sc_link, SDEV_DB4, ("\n")); - if (datalen) { - /* - * there's still data, must have run out of segs! - */ - printf("%s: uha_scsi_cmd, more than %d dma segs\n", - uha->sc_dev.dv_xname, UHA_NSEG); - xs->error = XS_DRIVER_STUFFUP; - uha_free_mscp(uha, mscp, flags); - return COMPLETE; - } - } else { /* No data xfer, use non S/G values */ - mscp->data_addr = (physaddr)0; - mscp->data_length = 0; - mscp->sgth = 0x00; - mscp->sg_num = 0; - } - mscp->link_id = 0; - mscp->link_addr = (physaddr)0; - - /* - * Put the scsi command in the mscp and start it - */ - if ((flags & SCSI_RESET) == 0) - bcopy(xs->cmd, &mscp->scsi_cmd, mscp->scsi_cmd_length); - - s = splbio(); - - (uha->send_mbox)(uha, mscp); - - /* - * Usually return SUCCESSFULLY QUEUED - */ - if ((flags & SCSI_POLL) == 0) { - timeout(uha_timeout, mscp, (xs->timeout * hz) / 1000); - splx(s); - return SUCCESSFULLY_QUEUED; - } - - splx(s); - - /* - * If we can't use interrupts, poll on completion - */ - if ((uha->poll)(uha, xs, xs->timeout)) { - uha_timeout(mscp); - if (!(uha->abort)(uha, mscp)) - uha_timeout(mscp); - } - return COMPLETE; -} - -void -uha_timeout(arg) - void *arg; -{ - struct uha_mscp *mscp = arg; - struct scsi_xfer *xs = mscp->xs; - struct scsi_link *sc_link = xs->sc_link; - struct uha_softc *uha = sc_link->adapter_softc; - int s; - - sc_print_addr(sc_link); - printf("timed out"); - - s = splbio(); - - if (!(uha->abort)(uha, mscp) || (mscp->flags == MSCP_ABORTED)) { - /* abort timed out */ - printf(" AGAIN\n"); - mscp->xs->retries = 0; /* I MEAN IT ! */ - mscp->host_stat = UHA_SBUS_TIMEOUT; - uha_done(uha, mscp); - } else { - /* abort the operation that has timed out */ - printf("\n"); - mscp->flags = MSCP_ABORTED; - /* 2 secs for the abort */ - if ((xs->flags & SCSI_POLL) == 0) - timeout(uha_timeout, mscp, 2 * hz); - } - - splx(s); -} - -#ifdef UHADEBUG -void -uha_print_mscp(mscp) - struct uha_mscp *mscp; -{ - - printf("mscp:%x op:%x cmdlen:%d senlen:%d\n", - mscp, mscp->opcode, mscp->cdblen, mscp->senselen); - printf(" sg:%d sgnum:%x datlen:%d hstat:%x tstat:%x flags:%x\n", - mscp->sgth, mscp->sg_num, mscp->datalen, mscp->host_stat, - mscp->target_stat, mscp->flags); - show_scsi_cmd(mscp->xs); -} - -void -uha_print_active_mscp(uha) - struct uha_softc *uha; -{ - struct uha_mscp *mscp; - int i = 0; - - while (i++ < MSCP_HASH_SIZE) { - mscp = uha->mscphash[i]; - while (mscp) { - if (mscp->flags != MSCP_FREE) - uha_print_mscp(mscp); - mscp = mscp->nexthash; - } - } -} -#endif /*UHADEBUG */ diff --git a/sys/arch/i386/isa/wd.c b/sys/arch/i386/isa/wd.c deleted file mode 100644 index 2c7092403a6c..000000000000 --- a/sys/arch/i386/isa/wd.c +++ /dev/null @@ -1,1734 +0,0 @@ -/* $NetBSD: wd.c,v 1.129 1995/01/13 12:30:59 mycroft Exp $ */ - -/* - * Copyright (c) 1994, 1995 Charles Hannum. All rights reserved. - * - * DMA and multi-sector PIO handling are derived from code contributed by - * Onno van der Linden. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)wd.c 7.2 (Berkeley) 5/9/91 - */ - -#define INSTRUMENT /* instrumentation stuff by Brad Parker */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef INSTRUMENT -#include -#endif - -#include - -#include -#include - -#include -#include - -#define WDCNDELAY 100000 /* delay = 100us; so 10s for a controller state change */ -#define WDCDELAY 100 - -#define WAITTIME (4 * hz) /* time to wait for a completion */ -#define RECOVERYTIME (hz / 2) /* time to recover from an error */ - -#if 0 -/* If you enable this, it will report any delays more than 100us * N long. */ -#define WDCNDELAY_DEBUG 10 -#endif - -#define WDIORETRIES 5 /* number of retries before giving up */ - -#define WDUNIT(dev) DISKUNIT(dev) -#define WDPART(dev) DISKPART(dev) -#define MAKEWDDEV(maj, unit, part) MAKEDISKDEV(maj, unit, part) - -#define WDLABELDEV(dev) (MAKEWDDEV(major(dev), WDUNIT(dev), RAW_PART)) - -#define b_cylin b_resid /* cylinder number for doing IO to */ - /* shares an entry in the buf struct */ - -/* - * Drive status. - */ -struct wd_softc { - struct device sc_dev; - struct dkdevice sc_dk; - - daddr_t sc_blkno; /* starting block number */ - int sc_bcount; /* byte count left */ - int sc_skip; /* bytes already transferred */ - int sc_nblks; /* number of blocks currently transferring */ - int sc_nbytes; /* number of bytes currently transferring */ - - int sc_drive; /* physical unit number */ - int sc_state; /* control state */ -#define RECAL 0 /* recalibrate */ -#define RECAL_WAIT 1 /* done recalibrating */ -#define GEOMETRY 2 /* upload geometry */ -#define GEOMETRY_WAIT 3 /* done uploading geometry */ -#define MULTIMODE 4 /* set multiple mode */ -#define MULTIMODE_WAIT 5 /* done setting multiple mode */ -#define OPEN 6 /* done with open */ - int sc_mode; /* transfer mode */ -#define WDM_PIOSINGLE 0 /* single-sector PIO */ -#define WDM_PIOMULTI 1 /* multi-sector PIO */ -#define WDM_DMA 2 /* DMA */ - int sc_multiple; /* multiple for WDM_PIOMULTI */ - int sc_flags; /* drive characteistics found */ -#define WDF_LOCKED 0x01 -#define WDF_WANTED 0x02 -#define WDF_LOADED 0x04 -#define WDF_WLABEL 0x08 /* label is writable */ -#define WDF_32BIT 0x10 /* can do 32-bit transfer */ - - struct wdparams sc_params; /* ESDI/IDE drive/controller parameters */ - daddr_t sc_badsect[127]; /* 126 plus trailing -1 marker */ - - TAILQ_ENTRY(wd_softc) sc_drivechain; - struct buf sc_q; -}; - -struct wdc_softc { - struct device sc_dev; - struct intrhand sc_ih; - - int sc_iobase; /* I/O port base */ - int sc_drq; /* DMA channel */ - - TAILQ_HEAD(drivehead, wd_softc) sc_drives; - int sc_flags; -#define WDCF_ACTIVE 0x01 /* controller is active */ -#define WDCF_SINGLE 0x02 /* sector at a time mode */ -#define WDCF_ERROR 0x04 /* processing a disk error */ -#define WDCF_WANTED 0x08 /* XXX locking for wd_get_parms() */ - int sc_errors; /* count of errors during current transfer */ - u_char sc_status; /* copy of status register */ - u_char sc_error; /* copy of error register */ -}; - -int wdcprobe __P((struct device *, void *, void *)); -void wdcattach __P((struct device *, struct device *, void *)); - -struct cfdriver wdccd = { - NULL, "wdc", wdcprobe, wdcattach, DV_DULL, sizeof(struct wd_softc) -}; - -int wdprobe __P((struct device *, void *, void *)); -void wdattach __P((struct device *, struct device *, void *)); - -struct cfdriver wdcd = { - NULL, "wd", wdprobe, wdattach, DV_DISK, sizeof(struct wd_softc) -}; - -void wdgetdisklabel __P((struct wd_softc *)); -int wd_get_parms __P((struct wd_softc *)); -void wdstrategy __P((struct buf *)); -void wdstart __P((struct wd_softc *)); - -struct dkdriver wddkdriver = { wdstrategy }; - -void wdfinish __P((struct wd_softc *, struct buf *)); -int wdcintr __P((struct wdc_softc *)); -static void wdcstart __P((struct wdc_softc *)); -static int wdcommand __P((struct wd_softc *, int, int, int, int, int)); -static int wdcommandshort __P((struct wdc_softc *, int, int)); -static int wdcontrol __P((struct wd_softc *)); -static int wdsetctlr __P((struct wd_softc *)); -static void bad144intern __P((struct wd_softc *)); -static int wdcreset __P((struct wdc_softc *)); -static void wdcrestart __P((void *arg)); -static void wdcunwedge __P((struct wdc_softc *)); -static void wdctimeout __P((void *arg)); -static void wderror __P((void *, struct buf *, char *)); -int wdcwait __P((struct wdc_softc *, int)); -/* ST506 spec says that if READY or SEEKCMPLT go off, then the read or write - command is aborted. */ -#define wait_for_drq(d) wdcwait(d, WDCS_DRDY | WDCS_DSC | WDCS_DRQ) -#define wait_for_ready(d) wdcwait(d, WDCS_DRDY | WDCS_DSC) -#define wait_for_unbusy(d) wdcwait(d, 0) - -/* - * Probe for controller. - */ -int -wdcprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct wdc_softc *wdc = match; - struct isa_attach_args *ia = aux; - int iobase; - - wdc->sc_iobase = iobase = ia->ia_iobase; - - /* Check if we have registers that work. */ - outb(iobase+wd_error, 0x5a); /* Error register not writable. */ - outb(iobase+wd_cyl_lo, 0xa5); /* But all of cyllo are implemented. */ - if (inb(iobase+wd_error) == 0x5a || inb(iobase+wd_cyl_lo) != 0xa5) - return 0; - - if (wdcreset(wdc) != 0) { - delay(500000); - if (wdcreset(wdc) != 0) - return 0; - } - - outb(iobase+wd_sdh, WDSD_IBM | 0); - - /* Wait for controller to become ready. */ - if (wait_for_unbusy(wdc) < 0) - return 0; - - /* Send command. */ - outb(iobase+wd_command, WDCC_DIAGNOSE); - - /* Wait for command to complete. */ - if (wait_for_unbusy(wdc) < 0) - return 0; - - ia->ia_iosize = 8; - ia->ia_msize = 0; - return 1; -} - -struct wdc_attach_args { - int wa_drive; -}; - -int -wdprint(aux, wdc) - void *aux; - char *wdc; -{ - struct wdc_attach_args *wa = aux; - - if (!wdc) - printf(" drive %d", wa->wa_drive); - return QUIET; -} - -void -wdcattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct wdc_softc *wdc = (void *)self; - struct isa_attach_args *ia = aux; - struct wdc_attach_args wa; - - TAILQ_INIT(&wdc->sc_drives); - wdc->sc_drq = ia->ia_drq; - - printf("\n"); - - wdc->sc_ih.ih_fun = wdcintr; - wdc->sc_ih.ih_arg = wdc; - wdc->sc_ih.ih_level = IPL_BIO; - intr_establish(ia->ia_irq, IST_EDGE, &wdc->sc_ih); - - for (wa.wa_drive = 0; wa.wa_drive < 2; wa.wa_drive++) - (void)config_found(self, (void *)&wa, wdprint); -} - -int -wdprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct wdc_softc *wdc = (void *)parent; - struct cfdata *cf = match; - struct wdc_attach_args *wa = aux; - int drive = wa->wa_drive; - - if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != drive) - return 0; - - if (wdcommandshort(wdc, drive, WDCC_RECAL) != 0 || - wait_for_ready(wdc) != 0) - return 0; - - return 1; -} - -void -wdattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct wd_softc *wd = (void *)self; - struct wdc_softc *wdc = (void *)parent; - struct wdc_attach_args *wa = aux; - int i, blank; - - wd->sc_drive = wa->wa_drive; - - wd_get_parms(wd); - printf(": %dMB, %d cyl, %d head, %d sec, %d bytes/sec <", - wd->sc_params.wdp_cylinders * - (wd->sc_params.wdp_heads * wd->sc_params.wdp_sectors) / - (1048576 / DEV_BSIZE), - wd->sc_params.wdp_cylinders, - wd->sc_params.wdp_heads, - wd->sc_params.wdp_sectors, - DEV_BSIZE); - for (i = blank = 0; i < sizeof(wd->sc_params.wdp_model); i++) { - char c = wd->sc_params.wdp_model[i]; - if (c == '\0') - break; - if (c != ' ') { - if (blank) - printf(" %c", c); - else - printf("%c", c); - blank = 0; - } else - blank = 1; - } - printf(">\n"); - - if ((wd->sc_params.wdp_capabilities & WD_CAP_DMA) != 0 && - wdc->sc_drq != DRQUNK) { - wd->sc_mode = WDM_DMA; - } else if (wd->sc_params.wdp_maxmulti > 1) { - wd->sc_mode = WDM_PIOMULTI; - wd->sc_multiple = min(wd->sc_params.wdp_maxmulti, 16); - } else { - wd->sc_mode = WDM_PIOSINGLE; - wd->sc_multiple = 1; - } - - printf("%s: using", wd->sc_dev.dv_xname); - if (wd->sc_mode == WDM_DMA) - printf(" dma transfers,"); - else - printf(" %d-sector %d-bit pio transfers,", - wd->sc_multiple, (wd->sc_flags & WDF_32BIT) == 0 ? 16 : 32); - if ((wd->sc_params.wdp_capabilities & WD_CAP_LBA) != 0) - printf(" lba addressing\n"); - else - printf(" chs addressing\n"); - - wd->sc_dk.dk_driver = &wddkdriver; -} - -/* - * Read/write routine for a buffer. Finds the proper unit, range checks - * arguments, and schedules the transfer. Does not wait for the transfer to - * complete. Multi-page transfers are supported. All I/O requests must be a - * multiple of a sector in length. - */ -void -wdstrategy(bp) - struct buf *bp; -{ - struct wd_softc *wd; /* disk unit to do the IO */ - int unit = WDUNIT(bp->b_dev); - int s; - - /* Valid unit, controller, and request? */ - if (unit >= wdcd.cd_ndevs || - (wd = wdcd.cd_devs[unit]) == 0 || - bp->b_blkno < 0 || - (bp->b_bcount % wd->sc_dk.dk_label.d_secsize) != 0 || - (bp->b_bcount / wd->sc_dk.dk_label.d_secsize) >= (1 << NBBY)) { - bp->b_error = EINVAL; - goto bad; - } - -#if 0 - /* "Soft" write protect check. */ - if ((wd->sc_flags & WDF_WRITEPROT) && (bp->b_flags & B_READ) == 0) { - bp->b_error = EROFS; - goto bad; - } -#endif - - /* If it's a null transfer, return immediately. */ - if (bp->b_bcount == 0) - goto done; - - /* - * Do bounds checking, adjust transfer. if error, process. - * If end of partition, just return. - */ - if (bounds_check_with_label(bp, &wd->sc_dk.dk_label, - (wd->sc_flags & WDF_WLABEL) != 0) <= 0) - goto done; - - /* Don't bother doing rotational optimization. */ - bp->b_cylin = 0; - - /* Queue transfer on drive, activate drive and controller if idle. */ - s = splbio(); - disksort(&wd->sc_q, bp); - if (!wd->sc_q.b_active) - wdstart(wd); /* Start drive. */ -#if 0 - else { - struct wdc_softc *wdc = (void *)wd->sc_dev.dv_parent; - if ((wdc->sc_flags & (WDCF_ACTIVE|WDCF_ERROR)) == 0) { - printf("wdstrategy: controller inactive\n"); - wdcstart(wdc); - } - } -#endif - splx(s); - return; - -bad: - bp->b_flags |= B_ERROR; -done: - /* Toss transfer; we're done early. */ - biodone(bp); -} - -/* - * Routine to queue a command to the controller. The unit's request is linked - * into the active list for the controller. If the controller is idle, the - * transfer is started. - */ -void -wdstart(wd) - struct wd_softc *wd; -{ - struct wdc_softc *wdc = (void *)wd->sc_dev.dv_parent; - int active = wdc->sc_drives.tqh_first != 0; - - /* Link onto controller queue. */ - wd->sc_q.b_active = 1; - TAILQ_INSERT_TAIL(&wdc->sc_drives, wd, sc_drivechain); - - /* If controller not already active, start it. */ - if (!active) - wdcstart(wdc); -} - -void -wdfinish(wd, bp) - struct wd_softc *wd; - struct buf *bp; -{ - struct wdc_softc *wdc = (void *)wd->sc_dev.dv_parent; - -#ifdef INSTRUMENT - dk_busy &= ~(1 << wd->sc_dev.dv_unit); -#endif - wdc->sc_flags &= ~(WDCF_SINGLE | WDCF_ERROR); - wdc->sc_errors = 0; - /* - * Move this drive to the end of the queue to give others a `fair' - * chance. - */ - if (wd->sc_drivechain.tqe_next) { - TAILQ_REMOVE(&wdc->sc_drives, wd, sc_drivechain); - if (bp->b_actf) { - TAILQ_INSERT_TAIL(&wdc->sc_drives, wd, sc_drivechain); - } else - wd->sc_q.b_active = 0; - } - bp->b_resid = wd->sc_bcount; - wd->sc_skip = 0; - wd->sc_q.b_actf = bp->b_actf; - biodone(bp); -} - -/* - * Controller startup routine. This does the calculation, and starts a - * single-sector read or write operation. Called to start a transfer, or from - * the interrupt routine to continue a multi-sector transfer. - * RESTRICTIONS: - * 1. The transfer length must be an exact multiple of the sector size. - */ -static void -wdcstart(wdc) - struct wdc_softc *wdc; -{ - struct wd_softc *wd; /* disk unit for IO */ - struct buf *bp; - struct disklabel *lp; - int nblks; - - /* - * XXX - * This is a kluge. See comments in wd_get_parms(). - */ - if ((wdc->sc_flags & WDCF_WANTED) != 0) { - wdc->sc_flags &= ~WDCF_WANTED; - wakeup(wdc); - return; - } - -loop: - /* Is there a drive for the controller to do a transfer with? */ - wd = wdc->sc_drives.tqh_first; - if (wd == NULL) - return; - - /* Is there a transfer to this drive? If not, deactivate drive. */ - bp = wd->sc_q.b_actf; - if (bp == NULL) { - TAILQ_REMOVE(&wdc->sc_drives, wd, sc_drivechain); - wd->sc_q.b_active = 0; - goto loop; - } - - if (wdc->sc_errors >= WDIORETRIES) { - wderror(wd, bp, "hard error"); - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - wdfinish(wd, bp); - goto loop; - } - - /* Do control operations specially. */ - if (wd->sc_state < OPEN) { - /* - * Actually, we want to be careful not to mess with the control - * state if the device is currently busy, but we can assume - * that we never get to this point if that's the case. - */ - if (wdcontrol(wd) == 0) { - /* The drive is busy. Wait. */ - return; - } - } - - /* - * WDCF_ERROR is set by wdcunwedge() and wdcintr() when an error is - * encountered. If we are in multi-sector mode, then we switch to - * single-sector mode and retry the operation from the start. - */ - if (wdc->sc_flags & WDCF_ERROR) { - wdc->sc_flags &= ~WDCF_ERROR; - if ((wdc->sc_flags & WDCF_SINGLE) == 0) { - wdc->sc_flags |= WDCF_SINGLE; - wd->sc_skip = 0; - } - } - - lp = &wd->sc_dk.dk_label; - - if (wd->sc_skip == 0) { - int part = WDPART(bp->b_dev); - daddr_t blkno; - -#ifdef WDDEBUG - printf("\n%s: wdcstart %s %d@%d; map ", wd->sc_dev.dv_xname, - (bp->b_flags & B_READ) ? "read" : "write", bp->b_bcount, - bp->b_blkno); -#endif - wd->sc_bcount = bp->b_bcount; - blkno = bp->b_blkno; - if (part != RAW_PART) - blkno += lp->d_partitions[part].p_offset; - wd->sc_blkno = blkno / (lp->d_secsize / DEV_BSIZE); -#ifdef INSTRUMENT - dk_busy |= (1 << wd->sc_dev.dv_unit); - dk_wds[wd->sc_dev.dv_unit] += bp->b_bcount >> 6; -#endif - } else { -#ifdef WDDEBUG - printf(" %d)%x", wd->sc_skip, inb(wd->sc_iobase+wd_altsts)); -#endif - } - - /* If starting a multisector transfer, or doing single transfers. */ - if (wd->sc_skip == 0 || (wdc->sc_flags & WDCF_SINGLE) != 0 || - wd->sc_mode == WDM_DMA) { - daddr_t blkno = wd->sc_blkno; - long cylin, head, sector; - int command; - - if ((wdc->sc_flags & WDCF_SINGLE) != 0) - nblks = 1; - else if (wd->sc_mode != WDM_DMA) - nblks = wd->sc_bcount / lp->d_secsize; - else - nblks = min(wd->sc_bcount / lp->d_secsize, 8); - - /* Check for bad sectors and adjust transfer, if necessary. */ - if ((lp->d_flags & D_BADSECT) != 0 -#ifdef B_FORMAT - && (bp->b_flags & B_FORMAT) == 0 -#endif - ) { - long blkdiff; - int i; - - for (i = 0; (blkdiff = wd->sc_badsect[i]) != -1; i++) { - blkdiff -= blkno; - if (blkdiff < 0) - continue; - if (blkdiff == 0) { - /* Replace current block of transfer. */ - blkno = - lp->d_secperunit - lp->d_nsectors - i - 1; - } - if (blkdiff < nblks) { - /* Bad block inside transfer. */ - wdc->sc_flags |= WDCF_SINGLE; - nblks = 1; - } - break; - } - /* Tranfer is okay now. */ - } - - if ((wd->sc_params.wdp_capabilities & WD_CAP_LBA) != 0) { - sector = (blkno >> 0) & 0xff; - cylin = (blkno >> 8) & 0xffff; - head = (blkno >> 24) & 0xf; - head |= WDSD_LBA; - } else { - sector = blkno % lp->d_nsectors; - sector++; /* Sectors begin with 1, not 0. */ - blkno /= lp->d_nsectors; - head = blkno % lp->d_ntracks; - blkno /= lp->d_ntracks; - cylin = blkno; - head |= WDSD_CHS; - } - -#ifdef INSTRUMENT - ++dk_seek[wd->sc_dev.dv_unit]; - ++dk_xfer[wd->sc_dev.dv_unit]; -#endif - - if (wd->sc_mode == WDM_PIOSINGLE || - (wdc->sc_flags & WDCF_SINGLE) != 0) - wd->sc_nblks = 1; - else if (wd->sc_mode == WDM_PIOMULTI) - wd->sc_nblks = min(nblks, wd->sc_multiple); - else - wd->sc_nblks = nblks; - wd->sc_nbytes = wd->sc_nblks * lp->d_secsize; - -#ifdef B_FORMAT - if (bp->b_flags & B_FORMAT) { - sector = lp->d_gap3; - nblks = lp->d_nsectors; - command = WDCC_FORMAT; - } else -#endif - switch (wd->sc_mode) { - case WDM_DMA: - command = (bp->b_flags & B_READ) ? - WDCC_READDMA : WDCC_WRITEDMA; - isa_dmastart(bp->b_flags & B_READ, - bp->b_data + wd->sc_skip, - wd->sc_nbytes, wdc->sc_drq); - break; - case WDM_PIOMULTI: - command = (bp->b_flags & B_READ) ? - WDCC_READMULTI : WDCC_WRITEMULTI; - break; - case WDM_PIOSINGLE: - command = (bp->b_flags & B_READ) ? - WDCC_READ : WDCC_WRITE; - break; - } - - /* Initiate command! */ - if (wdcommand(wd, command, cylin, head, sector, nblks) != 0) { - wderror(wd, NULL, - "wdcstart: timeout waiting for unbusy"); - wdcunwedge(wdc); - return; - } -#ifdef WDDEBUG - printf("sector %d cylin %d head %d addr %x sts %x\n", sector, - cylin, head, bp->b_data, inb(wd->sc_iobase+wd_altsts)); -#endif - } else if (wd->sc_nblks > 1) { - nblks = wd->sc_bcount / lp->d_secsize; - if (wd->sc_nblks > nblks) { - wd->sc_nblks = nblks; - wd->sc_nbytes = wd->sc_bcount; - } - } - - /* If this was a write and not using DMA, push the data. */ - if (wd->sc_mode != WDM_DMA && - (bp->b_flags & B_READ) == 0) { - if (wait_for_drq(wdc) < 0) { - wderror(wd, NULL, "wdcstart: timeout waiting for drq"); - wdcunwedge(wdc); - return; - } - - /* Then send it! */ - if ((wd->sc_flags & WDF_32BIT) == 0) - outsw(wdc->sc_iobase+wd_data, bp->b_data + wd->sc_skip, - wd->sc_nbytes >> 1); - else - outsl(wdc->sc_iobase+wd_data, bp->b_data + wd->sc_skip, - wd->sc_nbytes >> 2); - } - - wdc->sc_flags |= WDCF_ACTIVE; - timeout(wdctimeout, wdc, WAITTIME); -} - -/* - * Interrupt routine for the controller. Acknowledge the interrupt, check for - * errors on the current operation, mark it done if necessary, and start the - * next request. Also check for a partially done transfer, and continue with - * the next chunk if so. - */ -int -wdcintr(wdc) - struct wdc_softc *wdc; -{ - struct wd_softc *wd; - struct buf *bp; - - if ((wdc->sc_flags & WDCF_ACTIVE) == 0) { - /* Clear the pending interrupt. */ - (void) inb(wdc->sc_iobase+wd_status); - return 0; - } - - wdc->sc_flags &= ~WDCF_ACTIVE; - untimeout(wdctimeout, wdc); - - wd = wdc->sc_drives.tqh_first; - bp = wd->sc_q.b_actf; - -#ifdef WDDEBUG - printf("I%d ", ctrlr); -#endif - - if (wait_for_unbusy(wdc) < 0) { - wderror(wd, NULL, "wdcintr: timeout waiting for unbusy"); - wdc->sc_status |= WDCS_ERR; /* XXX */ - } - - /* Is it not a transfer, but a control operation? */ - if (wd->sc_state < OPEN) { - if (wdcontrol(wd) == 0) { - /* The drive is busy. Wait. */ - return 1; - } - wdcstart(wdc); - return 1; - } - - if (wd->sc_mode == WDM_DMA) - isa_dmadone(bp->b_flags & B_READ, bp->b_data + wd->sc_skip, - wd->sc_nbytes, wdc->sc_drq); - - /* Have we an error? */ - if (wdc->sc_status & WDCS_ERR) { - lose: -#ifdef WDDEBUG - wderror(wd, NULL, "wdcintr"); -#endif - if ((wdc->sc_flags & WDCF_SINGLE) == 0) { - wdc->sc_flags |= WDCF_ERROR; - goto restart; - } - -#ifdef B_FORMAT - if (bp->b_flags & B_FORMAT) - goto bad; -#endif - - if (++wdc->sc_errors < WDIORETRIES) - goto restart; - wderror(wd, bp, "hard error"); - - bad: - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - goto done; - } - - if (wdc->sc_status & WDCS_CORR) - wderror(wd, bp, "soft ecc"); - - /* If this was a read and not using DMA, fetch the data. */ - if (wd->sc_mode != WDM_DMA && - (bp->b_flags & B_READ) != 0) { - if ((wdc->sc_status & (WDCS_DRDY | WDCS_DSC | WDCS_DRQ)) - != (WDCS_DRDY | WDCS_DSC | WDCS_DRQ)) { - wderror(wd, NULL, "wdcintr: read intr before drq"); - wdcunwedge(wdc); - return 1; - } - - /* Suck in data. */ - if ((wd->sc_flags & WDF_32BIT) == 0) - insw(wdc->sc_iobase+wd_data, bp->b_data + wd->sc_skip, - wd->sc_nbytes >> 1); - else - insl(wdc->sc_iobase+wd_data, bp->b_data + wd->sc_skip, - wd->sc_nbytes >> 2); - } - - /* If we encountered any abnormalities, flag it as a soft error. */ - if (wdc->sc_errors) { - wderror(wd, bp, "soft error"); - wdc->sc_errors = 0; - } - - /* Ready for the next block, if any. */ - wd->sc_blkno += wd->sc_nblks; - wd->sc_skip += wd->sc_nbytes; - wd->sc_bcount -= wd->sc_nbytes; - - /* See if more to transfer. */ - if (wd->sc_bcount > 0) - goto restart; - -done: - /* Done with this transfer, with or without error. */ - wdfinish(wd, bp); - -restart: - /* Start the next transfer, if any. */ - wdcstart(wdc); - - return 1; -} - -/* - * Initialize a drive. - */ -int -wdopen(dev, flag, fmt) - dev_t dev; - int flag, fmt; -{ - int error; - int unit, part; - struct wd_softc *wd; - - unit = WDUNIT(dev); - if (unit >= wdcd.cd_ndevs) - return ENXIO; - wd = wdcd.cd_devs[unit]; - if (wd == 0) - return ENXIO; - - part = WDPART(dev); - - while ((wd->sc_flags & WDF_LOCKED) != 0) { - wd->sc_flags |= WDF_WANTED; - if ((error = tsleep(wd, PRIBIO | PCATCH, "wdopn", 0)) != 0) - return error; - } - - if (wd->sc_dk.dk_openmask != 0) { - /* - * If any partition is open, but the disk has been invalidated, - * disallow further opens. - */ - if ((wd->sc_flags & WDF_LOADED) == 0) - return ENXIO; - } else { - wd->sc_flags |= WDF_LOCKED; - - if ((wd->sc_flags & WDF_LOADED) == 0) { - wd->sc_flags |= WDF_LOADED; - - /* Load the physical device parameters. */ - if (wd_get_parms(wd) != 0) { - error = ENXIO; - goto bad2; - } - - /* Load the partition info if not already loaded. */ - wdgetdisklabel(wd); - } - - wd->sc_flags &= ~WDF_LOCKED; - if ((wd->sc_flags & WDF_WANTED) != 0) { - wd->sc_flags &= ~WDF_WANTED; - wakeup(wd); - } - } - - /* Check that the partition exists. */ - if (part != RAW_PART && - (part >= wd->sc_dk.dk_label.d_npartitions || - wd->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED)) { - error = ENXIO; - goto bad; - } - - /* Insure only one open at a time. */ - switch (fmt) { - case S_IFCHR: - wd->sc_dk.dk_copenmask |= (1 << part); - break; - case S_IFBLK: - wd->sc_dk.dk_bopenmask |= (1 << part); - break; - } - wd->sc_dk.dk_openmask = wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask; - - return 0; - -bad2: - wd->sc_flags &= ~WDF_LOADED; - -bad: - if (wd->sc_dk.dk_openmask == 0) { - wd->sc_flags &= ~WDF_LOCKED; - if ((wd->sc_flags & WDF_WANTED) != 0) { - wd->sc_flags &= ~WDF_WANTED; - wakeup(wd); - } - } - - return error; -} - -void -wdgetdisklabel(wd) - struct wd_softc *wd; -{ - char *errstring; - - bzero(&wd->sc_dk.dk_label, sizeof(struct disklabel)); - bzero(&wd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel)); - - wd->sc_dk.dk_label.d_secsize = DEV_BSIZE; - wd->sc_dk.dk_label.d_ntracks = wd->sc_params.wdp_heads; - wd->sc_dk.dk_label.d_nsectors = wd->sc_params.wdp_sectors; - wd->sc_dk.dk_label.d_ncylinders = wd->sc_params.wdp_cylinders; - wd->sc_dk.dk_label.d_secpercyl = - wd->sc_dk.dk_label.d_ntracks * wd->sc_dk.dk_label.d_nsectors; - -#if 0 - strncpy(wd->sc_dk.dk_label.d_typename, "ST506 disk", 16); - wd->sc_dk.dk_label.d_type = DTYPE_ST506; -#endif - strncpy(wd->sc_dk.dk_label.d_packname, wd->sc_params.wdp_model, 16); - wd->sc_dk.dk_label.d_secperunit = - wd->sc_dk.dk_label.d_secpercyl * wd->sc_dk.dk_label.d_ncylinders; - wd->sc_dk.dk_label.d_rpm = 3600; - wd->sc_dk.dk_label.d_interleave = 1; - wd->sc_dk.dk_label.d_flags = 0; - - wd->sc_dk.dk_label.d_partitions[RAW_PART].p_offset = 0; - wd->sc_dk.dk_label.d_partitions[RAW_PART].p_size = - wd->sc_dk.dk_label.d_secperunit * - (wd->sc_dk.dk_label.d_secsize / DEV_BSIZE); - wd->sc_dk.dk_label.d_partitions[RAW_PART].p_fstype = FS_UNUSED; - wd->sc_dk.dk_label.d_npartitions = RAW_PART + 1; - - wd->sc_dk.dk_label.d_magic = DISKMAGIC; - wd->sc_dk.dk_label.d_magic2 = DISKMAGIC; - wd->sc_dk.dk_label.d_checksum = dkcksum(&wd->sc_dk.dk_label); - - wd->sc_badsect[0] = -1; - - if (wd->sc_state > RECAL) - wd->sc_state = RECAL; - errstring = readdisklabel(MAKEWDDEV(0, wd->sc_dev.dv_unit, RAW_PART), - wdstrategy, &wd->sc_dk.dk_label, &wd->sc_dk.dk_cpulabel); - if (errstring) { - /* - * This probably happened because the drive's default - * geometry doesn't match the DOS geometry. We - * assume the DOS geometry is now in the label and try - * again. XXX This is a kluge. - */ - if (wd->sc_state > GEOMETRY) - wd->sc_state = GEOMETRY; - errstring = readdisklabel(MAKEWDDEV(0, wd->sc_dev.dv_unit, RAW_PART), - wdstrategy, &wd->sc_dk.dk_label, &wd->sc_dk.dk_cpulabel); - } - if (errstring) { - printf("%s: %s\n", wd->sc_dev.dv_xname, errstring); - return; - } - - if (wd->sc_state > GEOMETRY) - wd->sc_state = GEOMETRY; - if ((wd->sc_dk.dk_label.d_flags & D_BADSECT) != 0) - bad144intern(wd); -} - -/* - * Implement operations other than read/write. - * Called from wdcstart or wdcintr during opens and formats. - * Uses finite-state-machine to track progress of operation in progress. - * Returns 0 if operation still in progress, 1 if completed. - */ -static int -wdcontrol(wd) - struct wd_softc *wd; -{ - struct wdc_softc *wdc = (void *)wd->sc_dev.dv_parent; - - switch (wd->sc_state) { - case RECAL: /* Set SDH, step rate, do recal. */ - if (wdcommandshort(wdc, wd->sc_drive, WDCC_RECAL) != 0) { - wderror(wd, NULL, "wdcontrol: recal failed (1)"); - goto bad; - } - wd->sc_state = RECAL_WAIT; - break; - - case RECAL_WAIT: - if (wdc->sc_status & WDCS_ERR) { - wderror(wd, NULL, "wdcontrol: recal failed (2)"); - goto bad; - } - /* fall through */ - case GEOMETRY: - if ((wd->sc_params.wdp_capabilities & WD_CAP_LBA) != 0) - goto multimode; - if (wdsetctlr(wd) != 0) { - /* Already printed a message. */ - goto bad; - } - wd->sc_state = GEOMETRY_WAIT; - break; - - case GEOMETRY_WAIT: - if (wdc->sc_status & WDCS_ERR) { - wderror(wd, NULL, "wdcontrol: geometry failed"); - goto bad; - } - /* fall through */ - case MULTIMODE: - multimode: - if (wd->sc_mode != WDM_PIOMULTI) - goto open; - outb(wdc->sc_iobase+wd_seccnt, wd->sc_multiple); - if (wdcommandshort(wdc, wd->sc_drive, WDCC_SETMULTI) != 0) { - wderror(wd, NULL, "wdcontrol: setmulti failed (1)"); - goto bad; - } - wd->sc_state = MULTIMODE_WAIT; - break; - - case MULTIMODE_WAIT: - if (wdc->sc_status & WDCS_ERR) { - wderror(wd, NULL, "wdcontrol: setmulti failed (2)"); - goto bad; - } - /* fall through */ - case OPEN: - open: - wdc->sc_errors = 0; - wd->sc_state = OPEN; - /* - * The rest of the initialization can be done by normal means. - */ - return 1; - - bad: - wdcunwedge(wdc); - return 0; - } - - wdc->sc_flags |= WDCF_ACTIVE; - timeout(wdctimeout, wdc, WAITTIME); - return 0; -} - -/* - * Send a command and wait uninterruptibly until controller is finished. - * Return -1 if controller busy for too long, otherwise return non-zero if - * error. Intended for brief controller commands at critical points. - * Assumes interrupts are blocked. - */ -static int -wdcommand(wd, command, cylin, head, sector, count) - struct wd_softc *wd; - int command; - int cylin, head, sector, count; -{ - struct wdc_softc *wdc = (void *)wd->sc_dev.dv_parent; - int iobase = wdc->sc_iobase; - int stat; - - /* Select drive, head, and addressing mode. */ - outb(iobase+wd_sdh, WDSD_IBM | (wd->sc_drive << 4) | head); - - /* Wait for it to become ready to accept a command. */ - if (command == WDCC_IDP) - stat = wait_for_unbusy(wdc); - else - stat = wdcwait(wdc, WDCS_DRDY); - if (stat < 0) - return -1; - - /* Load parameters. */ - if (wd->sc_dk.dk_label.d_type == DTYPE_ST506) - outb(iobase+wd_precomp, wd->sc_dk.dk_label.d_precompcyl / 4); - else - outb(iobase+wd_features, 0); - outb(iobase+wd_cyl_lo, cylin); - outb(iobase+wd_cyl_hi, cylin >> 8); - outb(iobase+wd_sector, sector); - outb(iobase+wd_seccnt, count); - - /* Send command. */ - outb(iobase+wd_command, command); - - return 0; -} - -int -wdcommandshort(wdc, drive, command) - struct wdc_softc *wdc; - int drive; - int command; -{ - int iobase = wdc->sc_iobase; - - /* Select drive. */ - outb(iobase+wd_sdh, WDSD_IBM | (drive << 4)); - - if (wdcwait(wdc, WDCS_DRDY) < 0) - return -1; - - outb(iobase+wd_command, command); - - return 0; -} - -/* - * Issue IDP to drive to tell it just what geometry it is to be. - */ -static int -wdsetctlr(wd) - struct wd_softc *wd; -{ - struct wdc_softc *wdc = (void *)wd->sc_dev.dv_parent; - -#ifdef WDDEBUG - printf("wd(%d,%d) C%dH%dS%d\n", wd->sc_dev.dv_unit, wd->sc_drive, - wd->sc_dk.dk_label.d_ncylinders, wd->sc_dk.dk_label.d_ntracks, - wd->sc_dk.dk_label.d_nsectors); -#endif - - if (wdcommand(wd, WDCC_IDP, wd->sc_dk.dk_label.d_ncylinders, - wd->sc_dk.dk_label.d_ntracks - 1, 0, wd->sc_dk.dk_label.d_nsectors) - != 0) { - wderror(wd, NULL, "wdsetctlr: geometry upload failed"); - return -1; - } - - return 0; -} - -/* - * Issue IDENTIFY to drive to ask it what it is. - */ -int -wd_get_parms(wd) - struct wd_softc *wd; -{ - struct wdc_softc *wdc = (void *)wd->sc_dev.dv_parent; - int i; - char tb[DEV_BSIZE]; - int s, error; - - /* - * XXX - * The locking done here, not to mention the length of time it may - * keep the rest of the system suspended, is a kluge. This should be - * rewritten to set up a transfer and queue it through wdstart(). - */ - - s = splbio(); - - while ((wdc->sc_flags & WDCF_ACTIVE) != 0) { - wdc->sc_flags |= WDCF_WANTED; - if ((error = tsleep(wdc, PRIBIO | PCATCH, "wdprm", 0)) != 0) { - splx(s); - return error; - } - } - - if (wdcommandshort(wdc, wd->sc_drive, WDCC_IDENTIFY) != 0 || - wait_for_drq(wdc) != 0) { - /* - * We `know' there's a drive here; just assume it's old. - */ - strncpy(wd->sc_dk.dk_label.d_typename, "ST506", - sizeof wd->sc_dk.dk_label.d_typename); - wd->sc_dk.dk_label.d_type = DTYPE_ST506; - - strncpy(wd->sc_params.wdp_model, "unknown", - sizeof wd->sc_params.wdp_model); - wd->sc_params.wdp_config = WD_CFG_FIXED; - wd->sc_params.wdp_cylinders = 1024; - wd->sc_params.wdp_heads = 8; - wd->sc_params.wdp_sectors = 17; - wd->sc_params.wdp_maxmulti = 0; - wd->sc_params.wdp_usedmovsd = 0; - wd->sc_params.wdp_capabilities = 0; - } else { - strncpy(wd->sc_dk.dk_label.d_typename, "ESDI/IDE", - sizeof wd->sc_dk.dk_label.d_typename); - wd->sc_dk.dk_label.d_type = DTYPE_ESDI; - - /* Obtain parameters. */ - insw(wdc->sc_iobase+wd_data, tb, sizeof(tb) / sizeof(short)); - bcopy(tb, &wd->sc_params, sizeof(struct wdparams)); - - /* Shuffle string byte order. */ - for (i = 0; i < sizeof(wd->sc_params.wdp_model); i += 2) { - u_short *p; - p = (u_short *)(wd->sc_params.wdp_model + i); - *p = ntohs(*p); - } - } - -#if 0 - printf("gc %x cyl %d trk %d sec %d type %d sz %d model %s\n", - wp->wdp_config, wp->wdp_cylinders, wp->wdp_heads, wp->wdp_sectors, - wp->wdp_buftype, wp->wdp_bufsize, wp->wdp_model); -#endif - - /* Clear any leftover interrupt. */ - (void) inb(wdc->sc_iobase+wd_status); - - wdcstart(wdc); - - splx(s); - return 0; -} - -int -wdclose(dev, flag, fmt) - dev_t dev; - int flag, fmt; -{ - struct wd_softc *wd = wdcd.cd_devs[WDUNIT(dev)]; - int part = WDPART(dev); - int s; - - switch (fmt) { - case S_IFCHR: - wd->sc_dk.dk_copenmask &= ~(1 << part); - break; - case S_IFBLK: - wd->sc_dk.dk_bopenmask &= ~(1 << part); - break; - } - wd->sc_dk.dk_openmask = wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask; - - if (wd->sc_dk.dk_openmask == 0) { - wd->sc_flags |= WDF_LOCKED; - -#if 0 - s = splbio(); - while (...) { - wd->sc_flags |= WDF_WAITING; - if ((error = tsleep(wd, PRIBIO | PCATCH, "wdcls", 0)) != 0) - return error; - } - splx(s); -#endif - - wd->sc_flags &= ~WDF_LOCKED; - if ((wd->sc_flags & WDF_WANTED) != 0) { - wd->sc_flags &= WDF_WANTED; - wakeup(wd); - } - } - - return 0; -} - -int -wdioctl(dev, command, addr, flag, p) - dev_t dev; - u_long command; - caddr_t addr; - int flag; - struct proc *p; -{ - struct wd_softc *wd = wdcd.cd_devs[WDUNIT(dev)]; - int error; - - if ((wd->sc_flags & WDF_LOADED) == 0) - return EIO; - - switch (command) { - case DIOCSBAD: - if ((flag & FWRITE) == 0) - return EBADF; - wd->sc_dk.dk_cpulabel.bad = *(struct dkbad *)addr; - wd->sc_dk.dk_label.d_flags |= D_BADSECT; - bad144intern(wd); - return 0; - - case DIOCGDINFO: - *(struct disklabel *)addr = wd->sc_dk.dk_label; - return 0; - - case DIOCGPART: - ((struct partinfo *)addr)->disklab = &wd->sc_dk.dk_label; - ((struct partinfo *)addr)->part = - &wd->sc_dk.dk_label.d_partitions[WDPART(dev)]; - return 0; - - case DIOCSDINFO: - if ((flag & FWRITE) == 0) - return EBADF; - error = setdisklabel(&wd->sc_dk.dk_label, - (struct disklabel *)addr, /*wd->sc_dk.dk_openmask : */0, - &wd->sc_dk.dk_cpulabel); - if (error == 0) { - if (wd->sc_state > GEOMETRY) - wd->sc_state = GEOMETRY; - } - return error; - - case DIOCWLABEL: - if ((flag & FWRITE) == 0) - return EBADF; - if (*(int *)addr) - wd->sc_flags |= WDF_WLABEL; - else - wd->sc_flags &= ~WDF_WLABEL; - return 0; - - case DIOCWDINFO: - if ((flag & FWRITE) == 0) - return EBADF; - error = setdisklabel(&wd->sc_dk.dk_label, - (struct disklabel *)addr, /*wd->sc_dk.dk_openmask : */0, - &wd->sc_dk.dk_cpulabel); - if (error == 0) { - if (wd->sc_state > GEOMETRY) - wd->sc_state = GEOMETRY; - - /* Simulate opening partition 0 so write succeeds. */ - wd->sc_dk.dk_openmask |= (1 << 0); /* XXX */ - error = writedisklabel(WDLABELDEV(dev), wdstrategy, - &wd->sc_dk.dk_label, &wd->sc_dk.dk_cpulabel); - wd->sc_dk.dk_openmask = - wd->sc_dk.dk_copenmask | wd->sc_dk.dk_bopenmask; - } - return error; - -#ifdef notyet - case DIOCGDINFOP: - *(struct disklabel **)addr = &wd->sc_dk.dk_label; - return 0; - - case DIOCWFORMAT: - if ((flag & FWRITE) == 0) - return EBADF; - { - register struct format_op *fop; - struct iovec aiov; - struct uio auio; - - fop = (struct format_op *)addr; - aiov.iov_base = fop->df_buf; - aiov.iov_len = fop->df_count; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_resid = fop->df_count; - auio.uio_segflg = 0; - auio.uio_offset = - fop->df_startblk * wd->sc_dk.dk_label.d_secsize; - auio.uio_procp = p; - error = physio(wdformat, NULL, dev, B_WRITE, minphys, - &auio); - fop->df_count -= auio.uio_resid; - fop->df_reg[0] = wdc->sc_status; - fop->df_reg[1] = wdc->sc_error; - return error; - } -#endif - - default: - return ENOTTY; - } - -#ifdef DIAGNOSTIC - panic("wdioctl: impossible"); -#endif -} - -#ifdef B_FORMAT -int -wdformat(struct buf *bp) -{ - - bp->b_flags |= B_FORMAT; - return wdstrategy(bp); -} -#endif - -int -wdsize(dev) - dev_t dev; -{ - struct wd_softc *wd; - int part; - int size; - - if (wdopen(dev, 0, S_IFBLK) != 0) - return -1; - wd = wdcd.cd_devs[WDUNIT(dev)]; - part = WDPART(dev); - if (wd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_SWAP) - size = -1; - else - size = wd->sc_dk.dk_label.d_partitions[part].p_size; - if (wdclose(dev, 0, S_IFBLK) != 0) - return -1; - return size; -} - -/* - * Dump core after a system crash. - */ -int -wddump(dev) - dev_t dev; -{ - struct wd_softc *wd; /* disk unit to do the IO */ - struct wdc_softc *wdc; - struct disklabel *lp; - int unit, part; - long rblkno, nblks; - char *addr; - static wddoingadump = 0; - extern caddr_t CADDR1; - extern pt_entry_t *CMAP1; - - if (wddoingadump) - return EFAULT; - wddoingadump = 1; - - unit = WDUNIT(dev); - /* Check for acceptable drive number. */ - if (unit >= wdcd.cd_ndevs) - return ENXIO; - wd = wdcd.cd_devs[unit]; - /* Was it ever initialized? */ - if (wd == 0 || wd->sc_state < OPEN) - return ENXIO; - - wdc = (void *)wd->sc_dev.dv_parent; - addr = (char *)0; /* starting address */ - lp = &wd->sc_dk.dk_label; - part = WDPART(dev); - - /* Convert to disk sectors. */ - rblkno = lp->d_partitions[part].p_offset + dumplo; - nblks = min(ctob(physmem) / lp->d_secsize, - lp->d_partitions[part].p_size - dumplo); - - /* Check transfer bounds against partition size. */ - if (dumplo < 0 || nblks <= 0) - return EINVAL; - - /* Recalibrate. */ - if (wdcommandshort(wdc, wd->sc_drive, WDCC_RECAL) != 0 || - wait_for_ready(wdc) != 0 || wdsetctlr(wd) != 0 || - wait_for_ready(wdc) != 0) { - wderror(wd, NULL, "wddump: recal failed"); - return EIO; - } - - while (nblks > 0) { - long blkno; - long cylin, head, sector; - - blkno = rblkno; - - if ((lp->d_flags & D_BADSECT) != 0) { - long blkdiff; - int i; - - for (i = 0; (blkdiff = wd->sc_badsect[i]) != -1; i++) { - blkdiff -= blkno; - if (blkdiff < 0) - continue; - if (blkdiff == 0) { - /* Replace current block of transfer. */ - blkno = - lp->d_secperunit - lp->d_nsectors - i - 1; - } - break; - } - /* Tranfer is okay now. */ - } - - if ((wd->sc_params.wdp_capabilities & WD_CAP_LBA) != 0) { - sector = (blkno >> 0) & 0xff; - cylin = (blkno >> 8) & 0xffff; - head = (blkno >> 24) & 0xf; - head |= WDSD_LBA; - } else { - sector = blkno % lp->d_nsectors; - sector++; /* Sectors begin with 1, not 0. */ - blkno /= lp->d_nsectors; - head = blkno % lp->d_ntracks; - blkno /= lp->d_ntracks; - cylin = blkno; - head |= WDSD_CHS; - } - -#ifdef notdef - /* Let's just talk about this first. */ - printf("cylin %d, head %d, sector %d, addr 0x%x", cylin, head, - sector, addr); -#endif - if (wdcommand(wd, WDCC_WRITE, cylin, head, sector, 1) != 0 || - wait_for_drq(wdc) != 0) { - wderror(wd, NULL, "wddump: write failed"); - return EIO; - } - -#ifdef notdef /* Cannot use this since this address was mapped differently. */ - pmap_enter(kernel_pmap, CADDR1, trunc_page(addr), VM_PROT_READ, TRUE); -#else - *CMAP1 = PG_V | PG_KW | ctob((long)addr); - tlbflush(); -#endif - - outsw(wdc->sc_iobase+wd_data, CADDR1 + ((int)addr & PGOFSET), - DEV_BSIZE / sizeof(short)); - - /* Check data request (should be done). */ - if (wait_for_ready(wdc) != 0) { - wderror(wd, NULL, "wddump: timeout waiting for ready"); - return EIO; - } - if (wdc->sc_status & WDCS_DRQ) { - wderror(wd, NULL, "wddump: extra drq"); - return EIO; - } - - if ((unsigned)addr % 1048576 == 0) - printf("%d ", nblks / (1048576 / DEV_BSIZE)); - - /* Update block count. */ - nblks--; - rblkno++; - (int)addr += DEV_BSIZE; - } - - return 0; -} - -/* - * Internalize the bad sector table. - */ -void -bad144intern(wd) - struct wd_softc *wd; -{ - struct dkbad *bt = &wd->sc_dk.dk_cpulabel.bad; - struct disklabel *lp = &wd->sc_dk.dk_label; - int i = 0; - - for (; i < 126; i++) { - if (bt->bt_bad[i].bt_cyl == 0xffff) - break; - wd->sc_badsect[i] = - bt->bt_bad[i].bt_cyl * lp->d_secpercyl + - (bt->bt_bad[i].bt_trksec >> 8) * lp->d_nsectors + - (bt->bt_bad[i].bt_trksec & 0xff); - } - for (; i < 127; i++) - wd->sc_badsect[i] = -1; -} - -static int -wdcreset(wdc) - struct wdc_softc *wdc; -{ - int iobase = wdc->sc_iobase; - - /* Reset the device. */ - outb(iobase+wd_ctlr, WDCTL_RST | WDCTL_IDS); - delay(1000); - outb(iobase+wd_ctlr, WDCTL_IDS); - delay(1000); - (void) inb(iobase+wd_error); - outb(iobase+wd_ctlr, WDCTL_4BIT); - - if (wait_for_unbusy(wdc) < 0) { - printf("%s: reset failed\n", wdc->sc_dev.dv_xname); - return 1; - } - - return 0; -} - -static void -wdcrestart(arg) - void *arg; -{ - struct wdc_softc *wdc = (struct wdc_softc *)arg; - int s; - - s = splbio(); - wdcstart(wdc); - splx(s); -} - -/* - * Unwedge the controller after an unexpected error. We do this by resetting - * it, marking all drives for recalibration, and stalling the queue for a short - * period to give the reset time to finish. - * NOTE: We use a timeout here, so this routine must not be called during - * autoconfig or dump. - */ -static void -wdcunwedge(wdc) - struct wdc_softc *wdc; -{ - int unit; - - untimeout(wdctimeout, wdc); - (void) wdcreset(wdc); - - /* Schedule recalibrate for all drives on this controller. */ - for (unit = 0; unit < wdcd.cd_ndevs; unit++) { - struct wd_softc *wd = wdcd.cd_devs[unit]; - if (!wd || (void *)wd->sc_dev.dv_parent != wdc) - continue; - if (wd->sc_state > RECAL) - wd->sc_state = RECAL; - } - - wdc->sc_flags |= WDCF_ERROR; - ++wdc->sc_errors; - - /* Wake up in a little bit and restart the operation. */ - timeout(wdcrestart, wdc, RECOVERYTIME); -} - -int -wdcwait(wdc, mask) - struct wdc_softc *wdc; - int mask; -{ - int iobase = wdc->sc_iobase; - int timeout = 0; - u_char status; - extern int cold; - - for (;;) { - wdc->sc_status = status = inb(iobase+wd_status); - if ((status & WDCS_BSY) == 0 && (status & mask) == mask) - break; - if (++timeout > WDCNDELAY) - return -1; - delay(WDCDELAY); - } - if (status & WDCS_ERR) { - wdc->sc_error = inb(iobase+wd_error); - return WDCS_ERR; - } -#ifdef WDCNDELAY_DEBUG - /* After autoconfig, there should be no long delays. */ - if (!cold && timeout > WDCNDELAY_DEBUG) - printf("%s: warning: busy-wait took %dus\n", - wdc->sc_dev.dv_xname, WDCDELAY * timeout); -#endif - return 0; -} - -static void -wdctimeout(arg) - void *arg; -{ - struct wdc_softc *wdc = (struct wdc_softc *)arg; - int s; - - s = splbio(); - if ((wdc->sc_flags & WDCF_ACTIVE) != 0) { - wdc->sc_flags &= ~WDCF_ACTIVE; - wderror(wdc, NULL, "lost interrupt"); - wdcunwedge(wdc); - } else - wderror(wdc, NULL, "missing untimeout"); - splx(s); -} - -static void -wderror(dev, bp, msg) - void *dev; - struct buf *bp; - char *msg; -{ - struct wd_softc *wd = dev; - struct wdc_softc *wdc = dev; - - if (bp) { - diskerr(bp, "wd", msg, LOG_PRINTF, wd->sc_skip / DEV_BSIZE, - &wd->sc_dk.dk_label); - printf("\n"); - } else - printf("%s: %s: status %b error %b\n", wdc->sc_dev.dv_xname, - msg, wdc->sc_status, WDCS_BITS, wdc->sc_error, WDERR_BITS); -} diff --git a/sys/arch/i386/isa/wd7000.c b/sys/arch/i386/isa/wd7000.c deleted file mode 100644 index 3df977602ba0..000000000000 --- a/sys/arch/i386/isa/wd7000.c +++ /dev/null @@ -1,743 +0,0 @@ -/* $NetBSD: wd7000.c,v 1.19 1994/11/18 22:03:49 mycroft Exp $ */ - -/* - * UNFINISHED! UNFINISHED! UNFINISHED! UNFINISHED! UNFINISHED! UNFINISHED! - * - * deraadt@fsa.ca 93/04/02 - * - * I was writing this driver for a wd7000-ASC. Yeah, the "-ASC" not the - * "-FASST2". The difference is that the "-ASC" is missing scatter gather - * support. - * - * In any case, the real reason why I never finished it is because the - * motherboard I have has broken DMA. This card wants 8MHz 1 wait state - * operation, and my board munges about 30% of the words transferred. - * - * Hopefully someone can finish this for the wd7000-FASST2. It should be - * quite easy to do. Look at the Linux wd7000 device driver to see how - * scatter gather is done by the board, then look at one of the Adaptec - * drivers to finish off the job.. - */ -#include "wds.h" -#if NWDS > 0 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -extern int delaycount; /* from clock setup code */ - -#define PHYSTOKV(x) ((x) + KERNBASE) -#define KVTOPHYS(x) vtophys(x) -#define PAGESIZ 4096 - - -/* WD7000 registers */ -#define WDS_STAT 0 /* read */ -#define WDS_IRQSTAT 1 /* read */ - -#define WDS_CMD 0 /* write */ -#define WDS_IRQACK 1 /* write */ -#define WDS_HCR 2 /* write */ - -/* WDS_STAT (read) defs */ -#define WDS_IRQ 0x80 -#define WDS_RDY 0x40 -#define WDS_REJ 0x20 -#define WDS_INIT 0x10 - -/* WDS_IRQSTAT (read) defs */ -#define WDSI_MASK 0xc0 -#define WDSI_ERR 0x00 -#define WDSI_MFREE 0x80 -#define WDSI_MSVC 0xc0 - -/* WDS_CMD (write) defs */ -#define WDSC_NOOP 0x00 -#define WDSC_INIT 0x01 -#define WDSC_DISUNSOL 0x02 -#define WDSC_ENAUNSOL 0x03 -#define WDSC_IRQMFREE 0x04 -#define WDSC_SCSIRESETSOFT 0x05 -#define WDSC_SCSIRESETHARD 0x06 -#define WDSC_MSTART(m) (0x80 + (m)) -#define WDSC_MMSTART(m) (0xc0 + (m)) - -/* WDS_HCR (write) defs */ -#define WDSH_IRQEN 0x08 -#define WDSH_DRQEN 0x04 -#define WDSH_SCSIRESET 0x02 -#define WDSH_ASCRESET 0x01 - -struct wds_cmd { - u_char cmd; - u_char targ; - struct scsi_generic scb; /*u_char scb[12];*/ - u_char stat; - u_char venderr; - u_char len[3]; - u_char data[3]; - u_char next[3]; - u_char write; - u_char xx[6]; -}; - -struct wds_req { - struct wds_cmd cmd; - struct wds_cmd sense; - struct scsi_xfer *sxp; - int busy, polled; - int done, ret, ombn; -}; - -#define WDSX_SCSICMD 0x00 -#define WDSX_OPEN_RCVBUF 0x80 -#define WDSX_RCV_CMD 0x81 -#define WDSX_RCV_DATA 0x82 -#define WDSX_RCV_DATASTAT 0x83 -#define WDSX_SND_DATA 0x84 -#define WDSX_SND_DATASTAT 0x85 -#define WDSX_SND_CMDSTAT 0x86 -#define WDSX_READINIT 0x88 -#define WDSX_READSCSIID 0x89 -#define WDSX_SETUNSOLIRQMASK 0x8a -#define WDSX_GETUNSOLIRQMASK 0x8b -#define WDSX_GETFIRMREV 0x8c -#define WDSX_EXECDIAG 0x8d -#define WDSX_SETEXECPARM 0x8e -#define WDSX_GETEXECPARM 0x8f - -struct wds_mb { - u_char stat; - u_char addr[3]; -}; -/* ICMB status value */ -#define ICMB_OK 0x01 -#define ICMB_OKERR 0x02 -#define ICMB_ETIME 0x04 -#define ICMB_ERESET 0x05 -#define ICMB_ETARCMD 0x06 -#define ICMB_ERESEL 0x80 -#define ICMB_ESEL 0x81 -#define ICMB_EABORT 0x82 -#define ICMB_ESRESET 0x83 -#define ICMB_EHRESET 0x84 - -struct wds_setup { - u_char cmd; - u_char scsi_id; - u_char buson_t; - u_char busoff_t; - u_char xx; - u_char mbaddr[3]; - u_char nomb; - u_char nimb; -}; - -#define WDS_NOMB 16 -#define WDS_NIMB 8 -#define MAXSIMUL 8 -struct wds { - int addr; - struct wds_req wdsr[MAXSIMUL]; - struct wds_mb ombs[WDS_NOMB], imbs[WDS_NIMB]; -} wds[NWDS]; - -static int wdsunit = 0; -int wds_debug = 0; - -void p2x(u_char *, u_long); -u_char *x2p(u_char *); -int wdsprobe(struct isa_device *); -void wds_minphys(struct buf *); -struct wds_req *wdsr_alloc(int); -int wds_scsi_cmd(struct scsi_xfer *); -long wds_adapter_info(int); -int wdsintr(int); -int wds_done(int, struct wds_cmd *, u_char); -int wdsattach(struct isa_device *); -int wds_init(struct isa_device *); -int wds_cmd(int, u_char *, int); -void wds_wait(int, int, int); - - -struct scsi_switch wds_switch[NWDS]; - -struct isa_driver wdsdriver = { - wdsprobe, - wdsattach, - "wds", -}; - - -void -flushcache(void) -{ - extern main(); - volatile char *p, c; - int i; - - for(p=(char *)main, i=0; i<256*1024; i++) - c = *p++; -} - -void -p2x(u_char *p, u_long x) -{ - p[0] = (x & 0x00ff0000) >> 16; - p[1] = (x & 0x0000ff00) >> 8; - p[2] = (x & 0x000000ff); -} - -u_char * -x2p(u_char *x) -{ - u_long q; - - q = ((x[0]<<16) & 0x00ff0000) + ((x[1]<<8) & 0x0000ff00) + (x[2] & 0x000000ff); - return (u_char *)q; -} - -int -wdsprobe(struct isa_device *dev) -{ - /*scsi_debug = PRINTROUTINES | TRACEOPENS | TRACEINTERRUPTS | - SHOWREQUESTS | SHOWSCATGATH | SHOWINQUIRY | SHOWCOMMANDS;*/ - - if (dev->id_parent) - return 1; - - if(wdsunit > NWDS) - return 0; - - dev->id_unit = wdsunit; - wds[wdsunit].addr = dev->id_iobase; - - if(wds_init(dev) != 0) - return 0; - wdsunit++; - return 8; -} - -void -wds_minphys(struct buf *bp) -{ - int base = (int)bp->b_data & (PAGESIZ-1); - - if(base + bp->b_bcount > PAGESIZ) - bp->b_bcount = PAGESIZ - base; -} - -struct wds_req * -wdsr_alloc(int unit) -{ - struct wds_req *r; - int x; - int i; - - r = NULL; - x = splbio(); - for(i=0; ibusy = 1; - break; - } - if(r == NULL) { - splx(x); - return NULL; - } - - r->ombn = -1; - for(i=0; iombn = i; - break; - } - if(r->ombn == -1 ) { - r->busy = 0; - splx(x); - return NULL; - } - splx(x); - return r; -} - -int -wds_scsi_cmd(struct scsi_xfer *sxp) -{ - struct wds_req *r; - int unit = sxp->adapter; - int base; - u_char c, *p; - int i; - - base = wds[unit].addr; - - /*printf("scsi_cmd\n");*/ - - if( sxp->flags & SCSI_RESET) { - printf("reset!\n"); - return COMPLETE; - } - - r = wdsr_alloc(unit); - if(r==NULL) { - printf("no request slot available!\n"); - sxp->error = XS_DRIVER_STUFFUP; - return TRY_AGAIN_LATER; - } - r->done = 0; - r->sxp = sxp; - - printf("wds%d: target %d/%d req %8x flags %08x len %d: ", unit, - sxp->targ, sxp->lu, r, sxp->flags, sxp->cmdlen); - for(i=0, p=(u_char *)sxp->cmd; icmdlen; i++) - printf("%02x ", p[i]); - printf("\n"); - printf(" data %08x datalen %08x\n", sxp->data, sxp->datalen); - - if(sxp->flags & SCSI_DATA_UIO) { - printf("UIO!\n"); - sxp->error = XS_DRIVER_STUFFUP; - return TRY_AGAIN_LATER; - } - - p2x(&wds[unit].ombs[r->ombn].addr[0], KVTOPHYS(&r->cmd)); - printf("%08x/%08x mbox@%08x: %02x %02x %02x %02x\n", - &r->cmd, KVTOPHYS(&r->cmd), &wds[unit].ombs[0], - wds[unit].ombs[r->ombn].stat, wds[unit].ombs[r->ombn].addr[0], - wds[unit].ombs[r->ombn].addr[1], wds[unit].ombs[r->ombn].addr[2]); - - bzero(&r->cmd, sizeof r->cmd); - r->cmd.cmd = WDSX_SCSICMD; - r->cmd.targ = (sxp->targ << 5) | sxp->lu; - bcopy(sxp->cmd, &r->cmd.scb, sxp->cmdlen<12 ? sxp->cmdlen : 12); - p2x(&r->cmd.len[0], sxp->datalen); - p2x(&r->cmd.data[0], sxp->datalen ? KVTOPHYS(sxp->data) : 0); - r->cmd.write = (sxp->flags&SCSI_DATA_IN)? 0x80 : 0x00; - p2x(&r->cmd.next[0], KVTOPHYS(&r->sense)); - - bzero(&r->sense, sizeof r->sense); - r->sense.cmd = r->cmd.cmd; - r->sense.targ = r->cmd.targ; - r->sense.scb.opcode = REQUEST_SENSE; - p2x(&r->sense.data[0], KVTOPHYS(&sxp->sense)); - p2x(&r->sense.len[0], sizeof sxp->sense); - r->sense.write = 0x80; - - /*printf("wdscmd: "); - for(i=0, p=(u_char *)&r->cmd; icmd; i++) - printf("%02x ", p[i]); - printf("\n");*/ - - if(sxp->flags & SCSI_NOMASK) { - outb(base+WDS_HCR, WDSH_DRQEN); - r->polled = 1; - } else - r->polled = 0; - - c = WDSC_MSTART(r->ombn); - flushcache(); - if( wds_cmd(base, &c, sizeof c) != 0) { - printf("wds%d: unable to start outgoing mbox\n", unit); - r->busy = 0; - /* XXX need to free mailbox */ - return TRY_AGAIN_LATER; - } - - delay(10000); - /*printf("%08x/%08x mbox: %02x %02x %02x %02x\n", &r->cmd, KVTOPHYS(&r->cmd), - wds[unit].ombs[r->ombn].stat, wds[unit].ombs[r->ombn].addr[0], - wds[unit].ombs[r->ombn].addr[1], wds[unit].ombs[r->ombn].addr[2]);*/ - - if(sxp->flags & SCSI_NOMASK) { -repoll: printf("wds%d: polling.", unit); - i = 0; - while( (inb(base+WDS_STAT) & WDS_IRQ) == 0) { - printf("."); - delay(10000); - if(++i == 10) { - printf("failed %02x\n", inb(base+WDS_IRQSTAT)); - /*r->busy = 0;*/ - sxp->error = XS_TIMEOUT; - return HAD_ERROR; - } - } - flushcache(); - printf("got one!\n"); - wdsintr(unit); - if(r->done) { - r->sxp->flags |= ITSDONE; - if(r->sxp->when_done) - (*r->sxp->when_done)(r->sxp->done_arg, - r->sxp->done_arg2); - r->busy = 0; - return r->ret; - } - goto repoll; - } - - outb(base+WDS_HCR, WDSH_IRQEN|WDSH_DRQEN); - printf("wds%d: successfully queued\n", unit); - return SUCCESSFULLY_QUEUED; -} - -long -wds_adapter_info(int unit) -{ - return 1; -} - -int -wdsintr(int unit) -{ - struct wds_cmd *pc, *vc; - struct wds_mb *in; - u_char stat; - u_char c; - - /*printf("stat=%02x\n", inb(wds[unit].addr + WDS_STAT));*/ - delay(1000); - c = inb(wds[unit].addr + WDS_IRQSTAT); - printf("wdsintr: %02x\n", c); - if( (c&WDSI_MASK) == WDSI_MSVC) { - delay(1000); - c = c & ~WDSI_MASK; - flushcache(); - in = &wds[unit].imbs[c]; - - printf("incoming mailbox %02x@%08x: ", c, in); - printf("%02x %02x %02x %02x\n", - in->stat, in->addr[0], in->addr[1], in->addr[2]); - pc = (struct wds_cmd *)x2p(&in->addr[0]); - vc = (struct wds_cmd *)PHYSTOKV(pc); - stat = in->stat; - printf("p=%08x v=%08x stat %02x\n", pc, vc, stat); - wds_done(unit, vc, stat); - in->stat = 0; - - outb(wds[unit].addr + WDS_IRQACK, 0xff); - } - return 1; -} - -int -wds_done(int unit, struct wds_cmd *c, u_char stat) -{ - struct wds_req *r; - int i; - - r = (struct wds_req *)NULL; - for(i=0; icmd.stat, r->cmd.venderr, r->sense.stat, r->sense.venderr); - - r->done = 1; - /* XXX need to free mailbox */ - r->ret = HAD_ERROR; - switch(r->cmd.stat) { - case ICMB_OK: - /*XXX r->sxp->sense.valid = 0; - r->sxp->error = 0;*/ - r->ret = COMPLETE; - break; - case ICMB_OKERR: - printf("scsi err %02x\n", c->venderr); - /*XXX r->sxp->sense.error_code = c->venderr; - r->sxp->sense.valid = 1;*/ - r->ret = COMPLETE; - break; - case ICMB_ETIME: - r->sxp->error = XS_TIMEOUT; - r->ret = HAD_ERROR; - break; - case ICMB_ERESET: - case ICMB_ETARCMD: - case ICMB_ERESEL: - case ICMB_ESEL: - case ICMB_EABORT: - case ICMB_ESRESET: - case ICMB_EHRESET: - r->sxp->error = XS_DRIVER_STUFFUP; - r->ret = HAD_ERROR; - break; - } - if(r->polled==0) { - r->sxp->flags |= ITSDONE; - if(r->sxp->when_done) - (*r->sxp->when_done)(r->sxp->done_arg, r->sxp->done_arg2); - r->busy = 0; - } - return 0; -} - -int -wds_getvers(int unit) -{ - struct wds_req *r; - int base; - u_char c, *p; - int i; - - base = wds[unit].addr; - - /*printf("scsi_cmd\n");*/ - - r = wdsr_alloc(unit); - if(r==NULL) { - printf("wds%d: no request slot available!\n", unit); - return -1; - } - r->done = 0; - r->sxp = NULL; - - printf("wds%d: getvers req %8x\n", unit, r); - - p2x(&wds[unit].ombs[r->ombn].addr[0], KVTOPHYS(&r->cmd)); - printf("%08x/%08x mbox@%08x: %02x %02x %02x %02x\n", - &r->cmd, KVTOPHYS(&r->cmd), &wds[unit].ombs[0], - wds[unit].ombs[r->ombn].stat, wds[unit].ombs[r->ombn].addr[0], - wds[unit].ombs[r->ombn].addr[1], wds[unit].ombs[r->ombn].addr[2]); - - bzero(&r->cmd, sizeof r->cmd); - r->cmd.cmd = WDSX_GETFIRMREV; - r->cmd.write = 0x80; - - printf("wdscmd: "); - for(i=0, p=(u_char *)&r->cmd; icmd; i++) - printf("%02x ", p[i]); - printf("\n"); - - outb(base+WDS_HCR, WDSH_DRQEN); - r->polled = 1; - - c = WDSC_MSTART(r->ombn); - flushcache(); - if( wds_cmd(base, &c, sizeof c) != 0) { - printf("wds%d: unable to start outgoing mbox\n", unit); - r->busy = 0; - /* XXX need to free mailbox */ - return -1; - } - - delay(10000); - /*printf("%08x/%08x mbox: %02x %02x %02x %02x\n", &r->cmd, KVTOPHYS(&r->cmd), - wds[unit].ombs[r->ombn].stat, wds[unit].ombs[r->ombn].addr[0], - wds[unit].ombs[r->ombn].addr[1], wds[unit].ombs[r->ombn].addr[2]);*/ - - while(1) { - printf("wds%d: polling.", unit); - i = 0; - while( (inb(base+WDS_STAT) & WDS_IRQ) == 0) { - printf("."); - delay(10000); - if(++i == 10) { - printf("failed %02x\n", inb(base+WDS_IRQSTAT)); - /*r->busy = 0;*/ - return -1; - } - } - flushcache(); - printf("got one!\n"); - wdsintr(unit); - if(r->done) { - printf("wds%d: version %02x %02x\n", unit, - r->cmd.targ, r->cmd.scb.opcode); - r->busy = 0; - return 0; - } - } -} - -int -wdsattach(struct isa_device *dev) -{ - int masunit; - static int firstswitch[NWDS]; - static u_long versprobe /* max 32 controllers */ - int r; - - if (!dev->id_parent) - return 1; - masunit = dev->id_parent->id_unit; - - if( !(versprobe & (1<id_physid, - &dev->id_unit, dev->id_flags); - return r; -} - -int -wds_init(struct isa_device *dev) -{ - struct wds_setup init; - int base; - u_char *p, c; - int unit, i; - - unit = dev->id_unit; - base = wds[unit].addr; - - /* - * Sending a command causes the CMDRDY bit to clear. - */ - c = inb(base+WDS_STAT); - for(i=0; i<4; i++) - if( (inb(base+WDS_STAT) & WDS_RDY) != 0) { - goto ready; - delay(10); - } - return 1; - -ready: - outb(base+WDS_CMD, WDSC_NOOP); - if( inb(base+WDS_STAT) & WDS_RDY) - return 1; - - /* - * the controller exists. reset and init. - */ - outb(base+WDS_HCR, WDSH_SCSIRESET|WDSH_ASCRESET); - delay(3); - outb(base+WDS_HCR, WDSH_DRQEN); - delay(20000); - -#if 1 - outb(0xd6, 0xc3); - outb(0xd4, 0x03); -#else - isa_dmacascade(dev->id_drq); -#endif - - if( (inb(base+WDS_STAT) & (WDS_RDY)) != WDS_RDY) { - printf("wds%d: waiting for controller to become ready", unit); - for(i=0; i<6; i++) { - if( (inb(base+WDS_STAT) & (WDS_RDY)) == WDS_RDY) - break; - printf("."); - delay(10000); - } - if( (inb(base+WDS_STAT) & (WDS_RDY)) != WDS_RDY) { - printf("failed\n"); - return 1; - } - } - - bzero(&init, sizeof init); - init.cmd = WDSC_INIT; - init.scsi_id = 0; - init.buson_t = 24; - init.busoff_t = 48; - p2x(&init.mbaddr[0], KVTOPHYS(&wds[unit].ombs[0])); - init.xx = 0; - init.nomb = WDS_NOMB; - init.nimb = WDS_NIMB; - - /*p = (u_char *)&init; - printf("wds%d: %08x %08x init: ", unit, - &wds[unit].ombs[0], KVTOPHYS(&wds[unit].ombs[0])); - for(i=0; i - * Serge Vakulenko - * - * This software is distributed with NO WARRANTIES, not even the implied - * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Authors grant any other persons or organisations permission to use - * or modify this software as long as this message is kept with the software, - * all derivative works or modified versions. - * - * This driver is derived from the old 386bsd Wangtek streamer tape driver, - * made by Robert Baron at CMU, based on Intel sources. - */ - -/* - * Copyright (c) 1989 Carnegie-Mellon University. - * All rights reserved. - * - * Authors: Robert Baron - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -/* - * Copyright 1988, 1989 by Intel Corporation - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -/* - * Uncomment this to enable internal device tracing. - */ -#define DEBUG(x) /* printf x */ - -#define WTPRI (PZERO+10) /* sleep priority */ - -/* - * Wangtek controller ports - */ -#define WT_CTLPORT(base) ((base)+0) /* control, write only */ -#define WT_STATPORT(base) ((base)+0) /* status, read only */ -#define WT_CMDPORT(base) ((base)+1) /* command, write only */ -#define WT_DATAPORT(base) ((base)+1) /* data, read only */ -#define WT_NPORT 2 /* 2 i/o ports */ - -/* status port bits */ -#define WT_BUSY 0x01 /* not ready bit define */ -#define WT_NOEXCEP 0x02 /* no exception bit define */ -#define WT_RESETMASK 0x07 /* to check after reset */ -#define WT_RESETVAL 0x05 /* state after reset */ - -/* control port bits */ -#define WT_ONLINE 0x01 /* device selected */ -#define WT_RESET 0x02 /* reset command */ -#define WT_REQUEST 0x04 /* request command */ -#define WT_IEN 0x08 /* enable dma */ - -/* - * Archive controller ports - */ -#define AV_DATAPORT(base) ((base)+0) /* data, read only */ -#define AV_CMDPORT(base) ((base)+0) /* command, write only */ -#define AV_STATPORT(base) ((base)+1) /* status, read only */ -#define AV_CTLPORT(base) ((base)+1) /* control, write only */ -#define AV_SDMAPORT(base) ((base)+2) /* start dma */ -#define AV_RDMAPORT(base) ((base)+3) /* reset dma */ -#define AV_NPORT 4 /* 4 i/o ports */ - -/* status port bits */ -#define AV_BUSY 0x40 /* not ready bit define */ -#define AV_NOEXCEP 0x20 /* no exception bit define */ -#define AV_RESETMASK 0xf8 /* to check after reset */ -#define AV_RESETVAL 0x50 /* state after reset */ - -/* control port bits */ -#define AV_RESET 0x80 /* reset command */ -#define AV_REQUEST 0x40 /* request command */ -#define AV_IEN 0x20 /* enable interrupts */ - -enum wttype { - UNKNOWN = 0, /* unknown type, driver disabled */ - ARCHIVE, /* Archive Viper SC499, SC402 etc */ - WANGTEK, /* Wangtek */ -}; - -struct wt_softc { - struct device sc_dev; - struct intrhand sc_ih; - - enum wttype type; /* type of controller */ - int sc_iobase; /* base i/o port */ - int chan; /* dma channel number, 1..3 */ - int flags; /* state of tape drive */ - unsigned dens; /* tape density */ - int bsize; /* tape block size */ - void *buf; /* internal i/o buffer */ - - void *dmavaddr; /* virtual address of dma i/o buffer */ - size_t dmatotal; /* size of i/o buffer */ - int dmaflags; /* i/o direction, B_READ or B_WRITE */ - size_t dmacount; /* resulting length of dma i/o */ - - u_short error; /* code for error encountered */ - u_short ercnt; /* number of error blocks */ - u_short urcnt; /* number of underruns */ - - int DATAPORT, CMDPORT, STATPORT, CTLPORT, SDMAPORT, RDMAPORT; - u_char BUSY, NOEXCEP, RESETMASK, RESETVAL, ONLINE, RESET, REQUEST, IEN; -}; - -int wtwait __P((struct wt_softc *sc, int catch, char *msg)); -int wtcmd __P((struct wt_softc *sc, int cmd)); -int wtstart __P((struct wt_softc *sc, int flag, void *vaddr, size_t len)); -void wtdma __P((struct wt_softc *sc)); -void wttimer __P((void *arg)); -void wtclock __P((struct wt_softc *sc)); -int wtreset __P((struct wt_softc *sc)); -int wtsense __P((struct wt_softc *sc, int verbose, int ignore)); -int wtstatus __P((struct wt_softc *sc)); -void wtrewind __P((struct wt_softc *sc)); -int wtreadfm __P((struct wt_softc *sc)); -int wtwritefm __P((struct wt_softc *sc)); -u_char wtpoll __P((struct wt_softc *sc, int mask, int bits)); - -int wtprobe __P((struct device *, void *, void *)); -void wtattach __P((struct device *, struct device *, void *)); -int wtintr __P((struct wt_softc *sc)); - -struct cfdriver wtcd = { - NULL, "wt", wtprobe, wtattach, DV_TAPE, sizeof(struct wt_softc) -}; - -/* - * Probe for the presence of the device. - */ -int -wtprobe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct wt_softc *sc = match; - struct isa_attach_args *ia = aux; - int iobase; - - sc->chan = ia->ia_drq; - sc->sc_iobase = iobase = ia->ia_iobase; - if (sc->chan < 1 || sc->chan > 3) { - printf("%s: Bad drq=%d, should be 1..3\n", sc->sc_dev.dv_xname, - sc->chan); - return 0; - } - - /* Try Wangtek. */ - sc->type = WANGTEK; - sc->CTLPORT = WT_CTLPORT(iobase); - sc->STATPORT = WT_STATPORT(iobase); - sc->CMDPORT = WT_CMDPORT(iobase); - sc->DATAPORT = WT_DATAPORT(iobase); - sc->SDMAPORT = sc->RDMAPORT = 0; - sc->BUSY = WT_BUSY; sc->NOEXCEP = WT_NOEXCEP; - sc->RESETMASK = WT_RESETMASK; sc->RESETVAL = WT_RESETVAL; - sc->ONLINE = WT_ONLINE; sc->RESET = WT_RESET; - sc->REQUEST = WT_REQUEST; sc->IEN = WT_IEN; - if (wtreset(sc)) { - ia->ia_iosize = WT_NPORT; - return 1; - } - - /* Try Archive. */ - sc->type = ARCHIVE; - sc->CTLPORT = AV_CTLPORT(iobase); - sc->STATPORT = AV_STATPORT(iobase); - sc->CMDPORT = AV_CMDPORT(iobase); - sc->DATAPORT = AV_DATAPORT(iobase); - sc->SDMAPORT = AV_SDMAPORT(iobase); - sc->RDMAPORT = AV_RDMAPORT(iobase); - sc->BUSY = AV_BUSY; sc->NOEXCEP = AV_NOEXCEP; - sc->RESETMASK = AV_RESETMASK; sc->RESETVAL = AV_RESETVAL; - sc->ONLINE = 0; sc->RESET = AV_RESET; - sc->REQUEST = AV_REQUEST; sc->IEN = AV_IEN; - if (wtreset(sc)) { - ia->ia_iosize = AV_NPORT; - return 1; - } - - /* Tape controller not found. */ - sc->type = UNKNOWN; - return 0; -} - -/* - * Device is found, configure it. - */ -void -wtattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct wt_softc *sc = (void *)self; - struct isa_attach_args *ia = aux; - - if (sc->type == ARCHIVE) { - printf(": type \n"); - /* Reset DMA. */ - outb(sc->RDMAPORT, 0); - } else - printf(": type \n"); - sc->flags = TPSTART; /* tape is rewound */ - sc->dens = -1; /* unknown density */ - - sc->sc_ih.ih_fun = wtintr; - sc->sc_ih.ih_arg = sc; - sc->sc_ih.ih_level = IPL_BIO; - intr_establish(ia->ia_irq, IST_EDGE, &sc->sc_ih); -} - -int -wtdump(dev) - dev_t dev; -{ - - /* Not implemented. */ - return EINVAL; -} - -int -wtsize(dev) - dev_t dev; -{ - - /* Not implemented. */ - return -1; -} - -/* - * Open routine, called on every device open. - */ -int -wtopen(dev, flag) - dev_t dev; - int flag; -{ - int unit = minor(dev) & T_UNIT; - struct wt_softc *sc; - int error; - - if (unit >= wtcd.cd_ndevs) - return ENXIO; - sc = wtcd.cd_devs[unit]; - if (!sc) - return ENXIO; - - /* Check that device is not in use */ - if (sc->flags & TPINUSE) - return EBUSY; - - /* If the tape is in rewound state, check the status and set density. */ - if (sc->flags & TPSTART) { - /* If rewind is going on, wait */ - if (error = wtwait(sc, PCATCH, "wtrew")) - return error; - - /* Check the controller status */ - if (!wtsense(sc, 0, (flag & FWRITE) ? 0 : TP_WRP)) { - /* Bad status, reset the controller. */ - if (!wtreset(sc)) - return EIO; - if (!wtsense(sc, 1, (flag & FWRITE) ? 0 : TP_WRP)) - return EIO; - } - - /* Set up tape density. */ - if (sc->dens != (minor(dev) & WT_DENSEL)) { - int d = 0; - - switch (minor(dev) & WT_DENSEL) { - case WT_DENSDFLT: - default: - break; /* default density */ - case WT_QIC11: - d = QIC_FMT11; break; /* minor 010 */ - case WT_QIC24: - d = QIC_FMT24; break; /* minor 020 */ - case WT_QIC120: - d = QIC_FMT120; break; /* minor 030 */ - case WT_QIC150: - d = QIC_FMT150; break; /* minor 040 */ - case WT_QIC300: - d = QIC_FMT300; break; /* minor 050 */ - case WT_QIC600: - d = QIC_FMT600; break; /* minor 060 */ - } - if (d) { - /* Change tape density. */ - if (!wtcmd(sc, d)) - return EIO; - if (!wtsense(sc, 1, TP_WRP | TP_ILL)) - return EIO; - - /* Check the status of the controller. */ - if (sc->error & TP_ILL) { - printf("%s: invalid tape density\n", - sc->sc_dev.dv_xname); - return ENODEV; - } - } - sc->dens = minor(dev) & WT_DENSEL; - } - sc->flags &= ~TPSTART; - } else if (sc->dens != (minor(dev) & WT_DENSEL)) - return ENXIO; - - sc->bsize = (minor(dev) & WT_BSIZE) ? 1024 : 512; - sc->buf = malloc(sc->bsize, M_TEMP, M_WAITOK); - - sc->flags = TPINUSE; - if (flag & FREAD) - sc->flags |= TPREAD; - if (flag & FWRITE) - sc->flags |= TPWRITE; - return 0; -} - -/* - * Close routine, called on last device close. - */ -int -wtclose(dev) - dev_t dev; -{ - int unit = minor(dev) & T_UNIT; - struct wt_softc *sc = wtcd.cd_devs[unit]; - - /* If rewind is pending, do nothing */ - if (sc->flags & TPREW) - goto done; - - /* If seek forward is pending and no rewind on close, do nothing */ - if (sc->flags & TPRMARK) { - if (minor(dev) & T_NOREWIND) - goto done; - - /* If read file mark is going on, wait */ - wtwait(sc, 0, "wtrfm"); - } - - if (sc->flags & TPWANY) { - /* Tape was written. Write file mark. */ - wtwritefm(sc); - } - - if ((minor(dev) & T_NOREWIND) == 0) { - /* Rewind to beginning of tape. */ - /* Don't wait until rewind, though. */ - wtrewind(sc); - goto done; - } - if ((sc->flags & TPRANY) && (sc->flags & (TPVOL | TPWANY)) == 0) { - /* Space forward to after next file mark if no writing done. */ - /* Don't wait for completion. */ - wtreadfm(sc); - } - -done: - sc->flags &= TPREW | TPRMARK | TPSTART | TPTIMER; - free(sc->buf, M_TEMP); - return 0; -} - -/* - * Ioctl routine. Compatible with BSD ioctls. - * Direct QIC-02 commands ERASE and RETENSION added. - * There are three possible ioctls: - * ioctl(int fd, MTIOCGET, struct mtget *buf) -- get status - * ioctl(int fd, MTIOCTOP, struct mtop *buf) -- do BSD-like op - * ioctl(int fd, WTQICMD, int qicop) -- do QIC op - */ -int -wtioctl(dev, cmd, addr, flag) - dev_t dev; - u_long cmd; - void *addr; - int flag; -{ - int unit = minor(dev) & T_UNIT; - struct wt_softc *sc = wtcd.cd_devs[unit]; - int error, count, op; - - switch (cmd) { - default: - return EINVAL; - case WTQICMD: /* direct QIC command */ - op = *(int *)addr; - switch (op) { - default: - return EINVAL; - case QIC_ERASE: /* erase the whole tape */ - if ((sc->flags & TPWRITE) == 0 || (sc->flags & TPWP)) - return EACCES; - if (error = wtwait(sc, PCATCH, "wterase")) - return error; - break; - case QIC_RETENS: /* retension the tape */ - if (error = wtwait(sc, PCATCH, "wtretens")) - return error; - break; - } - /* Both ERASE and RETENS operations work like REWIND. */ - /* Simulate the rewind operation here. */ - sc->flags &= ~(TPRO | TPWO | TPVOL); - if (!wtcmd(sc, op)) - return EIO; - sc->flags |= TPSTART | TPREW; - if (op == QIC_ERASE) - sc->flags |= TPWANY; - wtclock(sc); - return 0; - case MTIOCIEOT: /* ignore EOT errors */ - case MTIOCEEOT: /* enable EOT errors */ - return 0; - case MTIOCGET: - ((struct mtget*)addr)->mt_type = - sc->type == ARCHIVE ? MT_ISVIPER1 : 0x11; - ((struct mtget*)addr)->mt_dsreg = sc->flags; /* status */ - ((struct mtget*)addr)->mt_erreg = sc->error; /* errors */ - ((struct mtget*)addr)->mt_resid = 0; - ((struct mtget*)addr)->mt_fileno = 0; /* file */ - ((struct mtget*)addr)->mt_blkno = 0; /* block */ - return 0; - case MTIOCTOP: - break; - } - - switch ((short)((struct mtop*)addr)->mt_op) { - default: -#if 0 - case MTFSR: /* forward space record */ - case MTBSR: /* backward space record */ - case MTBSF: /* backward space file */ -#endif - return EINVAL; - case MTNOP: /* no operation, sets status only */ - case MTCACHE: /* enable controller cache */ - case MTNOCACHE: /* disable controller cache */ - return 0; - case MTREW: /* rewind */ - case MTOFFL: /* rewind and put the drive offline */ - if (sc->flags & TPREW) /* rewind is running */ - return 0; - if (error = wtwait(sc, PCATCH, "wtorew")) - return error; - wtrewind(sc); - return 0; - case MTFSF: /* forward space file */ - for (count = ((struct mtop*)addr)->mt_count; count > 0; - --count) { - if (error = wtwait(sc, PCATCH, "wtorfm")) - return error; - if (error = wtreadfm(sc)) - return error; - } - return 0; - case MTWEOF: /* write an end-of-file record */ - if ((sc->flags & TPWRITE) == 0 || (sc->flags & TPWP)) - return EACCES; - if (error = wtwait(sc, PCATCH, "wtowfm")) - return error; - if (error = wtwritefm(sc)) - return error; - return 0; - } - -#ifdef DIAGNOSTIC - panic("wtioctl: impossible"); -#endif -} - -/* - * Strategy routine. - */ -void -wtstrategy(bp) - struct buf *bp; -{ - int unit = minor(bp->b_dev) & T_UNIT; - struct wt_softc *sc = wtcd.cd_devs[unit]; - int s; - - bp->b_resid = bp->b_bcount; - - /* at file marks and end of tape, we just return '0 bytes available' */ - if (sc->flags & TPVOL) - goto xit; - - if (bp->b_flags & B_READ) { - /* Check read access and no previous write to this tape. */ - if ((sc->flags & TPREAD) == 0 || (sc->flags & TPWANY)) - goto errxit; - - /* For now, we assume that all data will be copied out */ - /* If read command outstanding, just skip down */ - if ((sc->flags & TPRO) == 0) { - if (!wtsense(sc, 1, TP_WRP)) { - /* Clear status. */ - goto errxit; - } - if (!wtcmd(sc, QIC_RDDATA)) { - /* Set read mode. */ - wtsense(sc, 1, TP_WRP); - goto errxit; - } - sc->flags |= TPRO | TPRANY; - } - } else { - /* Check write access and write protection. */ - /* No previous read from this tape allowed. */ - if ((sc->flags & TPWRITE) == 0 || (sc->flags & (TPWP | TPRANY))) - goto errxit; - - /* If write command outstanding, just skip down */ - if ((sc->flags & TPWO) == 0) { - if (!wtsense(sc, 1, 0)) { - /* Clear status. */ - goto errxit; - } - if (!wtcmd(sc, QIC_WRTDATA)) { - /* Set write mode. */ - wtsense(sc, 1, 0); - goto errxit; - } - sc->flags |= TPWO | TPWANY; - } - } - - if (bp->b_bcount == 0) - goto xit; - - sc->flags &= ~TPEXCEP; - s = splbio(); - if (wtstart(sc, bp->b_flags, bp->b_data, bp->b_bcount)) { - wtwait(sc, 0, (bp->b_flags & B_READ) ? "wtread" : "wtwrite"); - bp->b_resid -= sc->dmacount; - } - splx(s); - - if (sc->flags & TPEXCEP) { -errxit: - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - } -xit: - biodone(bp); - return; -} - -/* - * Interrupt routine. - */ -int -wtintr(sc) - struct wt_softc *sc; -{ - u_char x; - - x = inb(sc->STATPORT); /* get status */ - DEBUG(("wtintr() status=0x%x -- ", x)); - if ((x & (sc->BUSY | sc->NOEXCEP)) == (sc->BUSY | sc->NOEXCEP)) { - DEBUG(("busy\n")); - return 0; /* device is busy */ - } - - /* - * Check if rewind finished. - */ - if (sc->flags & TPREW) { - DEBUG(((x & (sc->BUSY | sc->NOEXCEP)) == (sc->BUSY | sc->NOEXCEP) ? - "rewind busy?\n" : "rewind finished\n")); - sc->flags &= ~TPREW; /* rewind finished */ - wtsense(sc, 1, TP_WRP); - wakeup((caddr_t)sc); - return 1; - } - - /* - * Check if writing/reading of file mark finished. - */ - if (sc->flags & (TPRMARK | TPWMARK)) { - DEBUG(((x & (sc->BUSY | sc->NOEXCEP)) == (sc->BUSY | sc->NOEXCEP) ? - "marker r/w busy?\n" : "marker r/w finished\n")); - if ((x & sc->NOEXCEP) == 0) /* operation failed */ - wtsense(sc, 1, (sc->flags & TPRMARK) ? TP_WRP : 0); - sc->flags &= ~(TPRMARK | TPWMARK); /* operation finished */ - wakeup((caddr_t)sc); - return 1; - } - - /* - * Do we started any i/o? If no, just return. - */ - if ((sc->flags & TPACTIVE) == 0) { - DEBUG(("unexpected interrupt\n")); - return 0; - } - sc->flags &= ~TPACTIVE; - sc->dmacount += sc->bsize; /* increment counter */ - - /* - * Clean up dma. - */ - if ((sc->dmaflags & B_READ) && - (sc->dmatotal - sc->dmacount) < sc->bsize) { - /* If reading short block, copy the internal buffer - * to the user memory. */ - isa_dmadone(sc->dmaflags, sc->buf, sc->bsize, sc->chan); - bcopy(sc->buf, sc->dmavaddr, sc->dmatotal - sc->dmacount); - } else - isa_dmadone(sc->dmaflags, sc->dmavaddr, sc->bsize, sc->chan); - - /* - * On exception, check for end of file and end of volume. - */ - if ((x & sc->NOEXCEP) == 0) { - DEBUG(("i/o exception\n")); - wtsense(sc, 1, (sc->dmaflags & B_READ) ? TP_WRP : 0); - if (sc->error & (TP_EOM | TP_FIL)) - sc->flags |= TPVOL; /* end of file */ - else - sc->flags |= TPEXCEP; /* i/o error */ - wakeup((caddr_t)sc); - return 1; - } - - if (sc->dmacount < sc->dmatotal) { - /* Continue I/O. */ - sc->dmavaddr += sc->bsize; - wtdma(sc); - DEBUG(("continue i/o, %d\n", sc->dmacount)); - return 1; - } - if (sc->dmacount > sc->dmatotal) /* short last block */ - sc->dmacount = sc->dmatotal; - /* Wake up user level. */ - wakeup((caddr_t)sc); - DEBUG(("i/o finished, %d\n", sc->dmacount)); - return 1; -} - -/* start the rewind operation */ -void -wtrewind(sc) - struct wt_softc *sc; -{ - int rwmode = sc->flags & (TPRO | TPWO); - - sc->flags &= ~(TPRO | TPWO | TPVOL); - /* - * Wangtek strictly follows QIC-02 standard: - * clearing ONLINE in read/write modes causes rewind. - * REWIND command is not allowed in read/write mode - * and gives `illegal command' error. - */ - if (sc->type == WANGTEK && rwmode) { - outb(sc->CTLPORT, 0); - } else if (!wtcmd(sc, QIC_REWIND)) - return; - sc->flags |= TPSTART | TPREW; - wtclock(sc); -} - -/* - * Start the `read marker' operation. - */ -int -wtreadfm(sc) - struct wt_softc *sc; -{ - - sc->flags &= ~(TPRO | TPWO | TPVOL); - if (!wtcmd(sc, QIC_READFM)) { - wtsense(sc, 1, TP_WRP); - return EIO; - } - sc->flags |= TPRMARK | TPRANY; - wtclock(sc); - /* Don't wait for completion here. */ - return 0; -} - -/* - * Write marker to the tape. - */ -int -wtwritefm(sc) - struct wt_softc *sc; -{ - - tsleep((caddr_t)wtwritefm, WTPRI, "wtwfm", hz); - sc->flags &= ~(TPRO | TPWO); - if (!wtcmd(sc, QIC_WRITEFM)) { - wtsense(sc, 1, 0); - return EIO; - } - sc->flags |= TPWMARK | TPWANY; - wtclock(sc); - return wtwait(sc, 0, "wtwfm"); -} - -/* - * While controller status & mask == bits continue waiting. - */ -u_char -wtpoll(sc, mask, bits) - struct wt_softc *sc; - int mask, bits; -{ - u_char x; - int i; - - /* Poll status port, waiting for specified bits. */ - for (i = 0; i < 1000; ++i) { /* up to 1 msec */ - x = inb(sc->STATPORT); - if ((x & mask) != bits) - return x; - delay(1); - } - for (i = 0; i < 100; ++i) { /* up to 10 msec */ - x = inb(sc->STATPORT); - if ((x & mask) != bits) - return x; - delay(100); - } - for (;;) { /* forever */ - x = inb(sc->STATPORT); - if ((x & mask) != bits) - return x; - tsleep((caddr_t)wtpoll, WTPRI, "wtpoll", 1); - } -} - -/* - * Execute QIC command. - */ -int -wtcmd(sc, cmd) - struct wt_softc *sc; - int cmd; -{ - u_char x; - int s; - - DEBUG(("wtcmd() cmd=0x%x\n", cmd)); - s = splbio(); - x = wtpoll(sc, sc->BUSY | sc->NOEXCEP, sc->BUSY | sc->NOEXCEP); /* ready? */ - if ((x & sc->NOEXCEP) == 0) { /* error */ - splx(s); - return 0; - } - - outb(sc->CMDPORT, cmd); /* output the command */ - - outb(sc->CTLPORT, sc->REQUEST | sc->ONLINE); /* set request */ - wtpoll(sc, sc->BUSY, sc->BUSY); /* wait for ready */ - outb(sc->CTLPORT, sc->IEN | sc->ONLINE); /* reset request */ - wtpoll(sc, sc->BUSY, 0); /* wait for not ready */ - splx(s); - return 1; -} - -/* wait for the end of i/o, seeking marker or rewind operation */ -int -wtwait(sc, catch, msg) - struct wt_softc *sc; - int catch; - char *msg; -{ - int error; - - DEBUG(("wtwait() `%s'\n", msg)); - while (sc->flags & (TPACTIVE | TPREW | TPRMARK | TPWMARK)) - if (error = tsleep((caddr_t)sc, WTPRI | catch, msg, 0)) - return error; - return 0; -} - -/* initialize dma for the i/o operation */ -void -wtdma(sc) - struct wt_softc *sc; -{ - - sc->flags |= TPACTIVE; - wtclock(sc); - - if (sc->type == ARCHIVE) { - /* Set DMA. */ - outb(sc->SDMAPORT, 0); - } - - if ((sc->dmaflags & B_READ) && - (sc->dmatotal - sc->dmacount) < sc->bsize) { - /* Reading short block; do it through the internal buffer. */ - isa_dmastart(sc->dmaflags, sc->buf, sc->bsize, sc->chan); - } else - isa_dmastart(sc->dmaflags, sc->dmavaddr, sc->bsize, sc->chan); -} - -/* start i/o operation */ -int -wtstart(sc, flag, vaddr, len) - struct wt_softc *sc; - int flag; - void *vaddr; - size_t len; -{ - u_char x; - - DEBUG(("wtstart()\n")); - x = wtpoll(sc, sc->BUSY | sc->NOEXCEP, sc->BUSY | sc->NOEXCEP); /* ready? */ - if ((x & sc->NOEXCEP) == 0) { - sc->flags |= TPEXCEP; /* error */ - return 0; - } - sc->flags &= ~TPEXCEP; /* clear exception flag */ - sc->dmavaddr = vaddr; - sc->dmatotal = len; - sc->dmacount = 0; - sc->dmaflags = flag; - wtdma(sc); - return 1; -} - -/* - * Start timer. - */ -void -wtclock(sc) - struct wt_softc *sc; -{ - - if (sc->flags & TPTIMER) - return; - sc->flags |= TPTIMER; - /* - * Some controllers seem to lose dma interrupts too often. To make the - * tape stream we need 1 tick timeout. - */ - timeout(wttimer, sc, (sc->flags & TPACTIVE) ? 1 : hz); -} - -/* - * Simulate an interrupt periodically while i/o is going. - * This is necessary in case interrupts get eaten due to - * multiple devices on a single IRQ line. - */ -void -wttimer(arg) - void *arg; -{ - struct wt_softc *sc = (struct wt_softc *)arg; - int s; - - sc->flags &= ~TPTIMER; - if ((sc->flags & (TPACTIVE | TPREW | TPRMARK | TPWMARK)) == 0) - return; - - /* If i/o going, simulate interrupt. */ - s = splbio(); - if ((inb(sc->STATPORT) & (sc->BUSY | sc->NOEXCEP)) != (sc->BUSY | sc->NOEXCEP)) { - DEBUG(("wttimer() -- ")); - wtintr(sc); - } - splx(s); - - /* Restart timer if i/o pending. */ - if (sc->flags & (TPACTIVE | TPREW | TPRMARK | TPWMARK)) - wtclock(sc); -} - -/* - * Perform QIC-02 and QIC-36 compatible reset sequence. - */ -int -wtreset(sc) - struct wt_softc *sc; -{ - u_char x; - int i; - - outb(sc->CTLPORT, sc->RESET | sc->ONLINE); /* send reset */ - delay(30); - outb(sc->CTLPORT, sc->ONLINE); /* turn off reset */ - delay(30); - - /* Read the controller status. */ - x = inb(sc->STATPORT); - if (x == 0xff) /* no port at this address? */ - return 0; - - /* Wait 3 sec for reset to complete. Needed for QIC-36 boards? */ - for (i = 0; i < 3000; ++i) { - if ((x & sc->BUSY) == 0 || (x & sc->NOEXCEP) == 0) - break; - delay(1000); - x = inb(sc->STATPORT); - } - return (x & sc->RESETMASK) == sc->RESETVAL; -} - -/* - * Get controller status information. Return 0 if user i/o request should - * receive an i/o error code. - */ -int -wtsense(sc, verbose, ignore) - struct wt_softc *sc; - int verbose, ignore; -{ - char *msg = 0; - int error; - - DEBUG(("wtsense() ignore=0x%x\n", ignore)); - sc->flags &= ~(TPRO | TPWO); - if (!wtstatus(sc)) - return 0; - if ((sc->error & TP_ST0) == 0) - sc->error &= ~TP_ST0MASK; - if ((sc->error & TP_ST1) == 0) - sc->error &= ~TP_ST1MASK; - sc->error &= ~ignore; /* ignore certain errors */ - error = sc->error & (TP_FIL | TP_BNL | TP_UDA | TP_EOM | TP_WRP | - TP_USL | TP_CNI | TP_MBD | TP_NDT | TP_ILL); - if (!error) - return 1; - if (!verbose) - return 0; - - /* lifted from tdriver.c from Wangtek */ - if (error & TP_USL) - msg = "Drive not online"; - else if (error & TP_CNI) - msg = "No cartridge"; - else if ((error & TP_WRP) && (sc->flags & TPWP) == 0) { - msg = "Tape is write protected"; - sc->flags |= TPWP; - } else if (error & TP_FIL) - msg = 0 /*"Filemark detected"*/; - else if (error & TP_EOM) - msg = 0 /*"End of tape"*/; - else if (error & TP_BNL) - msg = "Block not located"; - else if (error & TP_UDA) - msg = "Unrecoverable data error"; - else if (error & TP_NDT) - msg = "No data detected"; - else if (error & TP_ILL) - msg = "Illegal command"; - if (msg) - printf("%s: %s\n", sc->sc_dev.dv_xname, msg); - return 0; -} - -/* - * Get controller status information. - */ -int -wtstatus(sc) - struct wt_softc *sc; -{ - char *p; - int s; - - s = splbio(); - wtpoll(sc, sc->BUSY | sc->NOEXCEP, sc->BUSY | sc->NOEXCEP); /* ready? */ - outb(sc->CMDPORT, QIC_RDSTAT); /* send `read status' command */ - - outb(sc->CTLPORT, sc->REQUEST | sc->ONLINE); /* set request */ - wtpoll(sc, sc->BUSY, sc->BUSY); /* wait for ready */ - outb(sc->CTLPORT, sc->ONLINE); /* reset request */ - wtpoll(sc, sc->BUSY, 0); /* wait for not ready */ - - p = (char *)&sc->error; - while (p < (char *)&sc->error + 6) { - u_char x = wtpoll(sc, sc->BUSY | sc->NOEXCEP, sc->BUSY | sc->NOEXCEP); - if ((x & sc->NOEXCEP) == 0) { /* error */ - splx(s); - return 0; - } - - *p++ = inb(sc->DATAPORT); /* read status byte */ - - outb(sc->CTLPORT, sc->REQUEST | sc->ONLINE); /* set request */ - wtpoll(sc, sc->BUSY, 0); /* wait for not ready */ - outb(sc->CTLPORT, sc->ONLINE); /* unset request */ - } - splx(s); - return 1; -} diff --git a/sys/arch/i386/isa/wtreg.h b/sys/arch/i386/isa/wtreg.h deleted file mode 100644 index 5cf2d773752e..000000000000 --- a/sys/arch/i386/isa/wtreg.h +++ /dev/null @@ -1,125 +0,0 @@ -/* $NetBSD: wtreg.h,v 1.5 1994/10/27 04:18:33 cgd Exp $ */ - -/* - * Streamer tape driver. - * Supports Archive and Wangtek compatible QIC-02/QIC-36 boards. - * - * Copyright (C) 1993 by: - * Sergey Ryzhkov - * Serge Vakulenko - * - * This software is distributed with NO WARRANTIES, not even the implied - * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Authors grant any other persons or organisations permission to use - * or modify this software as long as this message is kept with the software, - * all derivative works or modified versions. - * - * This driver is derived from the old 386bsd Wangtek streamer tape driver, - * made by Robert Baron at CMU, based on Intel sources. - */ - -/* - * Copyright (c) 1989 Carnegie-Mellon University. - * All rights reserved. - * - * Authors: Robert Baron - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -/* - * Copyright 1988, 1989 by Intel Corporation - */ - -/* ioctl for direct QIC commands */ -#define WTQICMD _IO('W', 0) - -/* QIC-02 commands allowed for WTQICMD */ -#define QIC_ERASE 0x22 /* erase the tape */ -#define QIC_RETENS 0x24 /* retension the tape */ - -/* internal QIC-02 commands */ -#define QIC_RDDATA 0x80 /* read data */ -#define QIC_READFM 0xa0 /* read file mark */ -#define QIC_WRTDATA 0x40 /* write data */ -#define QIC_WRITEFM 0x60 /* write file mark */ -#define QIC_RDSTAT 0xc0 /* read status command */ -#define QIC_REWIND 0x21 /* rewind command (position+bot) */ -#define QIC_FMT11 0x26 /* set format QIC-11 */ -#define QIC_FMT24 0x27 /* set format QIC-24 */ -#define QIC_FMT120 0x28 /* set format QIC-120 */ -#define QIC_FMT150 0x29 /* set format QIC-150 */ -#define QIC_FMT300 0x2a /* set format QIC-300/QIC-2100 */ -#define QIC_FMT600 0x2b /* set format QIC-600/QIC-2200 */ - -/* tape driver flags */ -#define TPINUSE 0x0001 /* tape is already open */ -#define TPREAD 0x0002 /* tape is only open for reading */ -#define TPWRITE 0x0004 /* tape is only open for writing */ -#define TPSTART 0x0008 /* tape must be rewound and reset */ -#define TPRMARK 0x0010 /* read file mark command outstanding */ -#define TPWMARK 0x0020 /* write file mark command outstanding */ -#define TPREW 0x0040 /* rewind command outstanding */ -#define TPEXCEP 0x0080 /* i/o exception flag */ -#define TPVOL 0x0100 /* read file mark or hit end of tape */ -#define TPWO 0x0200 /* write command outstanding */ -#define TPRO 0x0400 /* read command outstanding */ -#define TPWANY 0x0800 /* write command requested */ -#define TPRANY 0x1000 /* read command requested */ -#define TPWP 0x2000 /* write protect error seen */ -#define TPTIMER 0x4000 /* timer() is active */ -#define TPACTIVE 0x8000 /* dma i/o active */ - -/* controller error register bits */ -#define TP_FIL 0x0001 /* File mark detected */ -#define TP_BNL 0x0002 /* Block not located */ -#define TP_UDA 0x0004 /* Unrecoverable data error */ -#define TP_EOM 0x0008 /* End of media */ -#define TP_WRP 0x0010 /* Write protected cartridge */ -#define TP_USL 0x0020 /* Unselected drive */ -#define TP_CNI 0x0040 /* Cartridge not in place */ -#define TP_ST0 0x0080 /* Status byte 0 bits */ -#define TP_ST0MASK 0x00ff /* Status byte 0 mask */ -#define TP_POR 0x0100 /* Power on/reset occurred */ -#define TP_ERM 0x0200 /* Reserved for end of recorded media */ -#define TP_BPE 0x0400 /* Reserved for bus parity error */ -#define TP_BOM 0x0800 /* Beginning of media */ -#define TP_MBD 0x1000 /* Marginal block detected */ -#define TP_NDT 0x2000 /* No data detected */ -#define TP_ILL 0x4000 /* Illegal command - should not happen! */ -#define TP_ST1 0x8000 /* Status byte 1 bits */ -#define TP_ST1MASK 0xff00 /* Status byte 1 mask */ - -/* formats for printing flags and error values */ -#define WTDS_BITS "\20\1inuse\2read\3write\4start\5rmark\6wmark\7rew\10excep\11vol\12wo\13ro\14wany\15rany\16wp\17timer\20active" -#define WTER_BITS "\20\1eof\2bnl\3uda\4eom\5wrp\6usl\7cni\11por\12erm\13bpe\14bom\15mbd\16ndt\17ill" - -/* device minor number */ -#define WT_BSIZE 0100 /* long block flag */ -#define WT_DENSEL 0070 /* density select mask */ -#define WT_DENSDFLT 0000 /* default density */ -#define WT_QIC11 0010 /* 11 megabytes? */ -#define WT_QIC24 0020 /* 60 megabytes */ -#define WT_QIC120 0030 /* 120 megabytes */ -#define WT_QIC150 0040 /* 150 megabytes */ -#define WT_QIC300 0050 /* 300 megabytes? */ -#define WT_QIC600 0060 /* 600 megabytes? */ diff --git a/sys/arch/i386/stand/wdboot.x b/sys/arch/i386/stand/wdboot.x deleted file mode 100644 index 488054bd1bcc0b366c3d59eabe3b4b3f5702b7c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 512 zcmeyh!+@dh!X5@j!vlRc`VQFfGm3fD@H0N(VdQ80@S1Ug;eibTAc?*UX|Dom7#KJh zVBr6MAZz}41~5JOJcBrc5m0^~1CZFyz`)6{lYxnW;q#I`3=CWh896|K!@E8)GB9l5 zfA^$i*Jlum3B>viVkrPwf56NqEpJvdlzv&kQSxEe2cXnW1|X64DfdZBj%Lq*`g3zh)G0|7f2SU4H}Uw}Dtl*SVRp{oEMeOHscc_channel[(chan)].scc_command.datum,tmp); \ - scc_get_datum((scc)->scc_channel[(chan)].scc_command.datum,tmp); \ - } - -#define scc_read_reg(scc,chan,reg,val) { \ - scc_set_datum((scc)->scc_channel[(chan)].scc_command.datum,reg); \ - scc_get_datum((scc)->scc_channel[(chan)].scc_command.datum,val); \ - } - -#define scc_read_reg_zero(scc,chan,val) { \ - scc_get_datum((scc)->scc_channel[(chan)].scc_command.datum,val); \ - } - -#define scc_write_reg(scc,chan,reg,val) { \ - scc_set_datum((scc)->scc_channel[(chan)].scc_command.datum,reg); \ - scc_set_datum((scc)->scc_channel[(chan)].scc_command.datum,val); \ - } - -#define scc_write_reg_zero(scc,chan,val) { \ - scc_set_datum((scc)->scc_channel[(chan)].scc_command.datum,val); \ - } - -#define scc_read_data(scc,chan,val) { \ - scc_get_datum((scc)->scc_channel[(chan)].scc_data.datum,val); \ - } - -#define scc_write_data(scc,chan,val) { \ - scc_set_datum((scc)->scc_channel[(chan)].scc_data.datum,val); \ - } - -/* - * Addressable registers - */ - -#define SCC_RR0 0 /* status register */ -#define SCC_RR1 1 /* special receive conditions */ -#define SCC_RR2 2 /* (modified) interrupt vector */ -#define SCC_RR3 3 /* interrupts pending (cha A only) */ -#define SCC_RR8 8 /* recv buffer (alias for data) */ -#define SCC_RR10 10 /* sdlc status */ -#define SCC_RR12 12 /* BRG constant, low part */ -#define SCC_RR13 13 /* BRG constant, high part */ -#define SCC_RR15 15 /* interrupts currently enabled */ - -#define SCC_WR0 0 /* reg select, and commands */ -#define SCC_WR1 1 /* interrupt and DMA enables */ -#define SCC_WR2 2 /* interrupt vector */ -#define SCC_WR3 3 /* receiver params and enables */ -#define SCC_WR4 4 /* clock/char/parity params */ -#define SCC_WR5 5 /* xmit params and enables */ -#define SCC_WR6 6 /* synchr SYNCH/address */ -#define SCC_WR7 7 /* synchr SYNCH/flag */ -#define SCC_WR8 8 /* xmit buffer (alias for data) */ -#define SCC_WR9 9 /* vectoring and resets */ -#define SCC_WR10 10 /* synchr params */ -#define SCC_WR11 11 /* clocking definitions */ -#define SCC_WR12 12 /* BRG constant, low part */ -#define SCC_WR13 13 /* BRG constant, high part */ -#define SCC_WR14 14 /* BRG enables and commands */ -#define SCC_WR15 15 /* interrupt enables */ - -/* - * Read registers defines - */ - -#define SCC_RR0_BREAK 0x80 /* break detected (rings twice), or */ -#define SCC_RR0_ABORT 0x80 /* abort (synchr) */ -#define SCC_RR0_TX_UNDERRUN 0x40 /* xmit buffer empty/end of message */ -#define SCC_RR0_CTS 0x20 /* clear-to-send pin active (sampled - only on intr and after RESI cmd */ -#define SCC_RR0_SYNCH 0x10 /* SYNCH found/still hunting */ -#define SCC_RR0_DCD 0x08 /* carrier-detect (same as CTS) */ -#define SCC_RR0_TX_EMPTY 0x04 /* xmit buffer empty */ -#define SCC_RR0_ZERO_COUNT 0x02 /* ? */ -#define SCC_RR0_RX_AVAIL 0x01 /* recv fifo not empty */ - -#define SCC_RR1_EOF 0x80 /* end-of-frame, SDLC mode */ -#define SCC_RR1_CRC_ERR 0x40 /* incorrect CRC or.. */ -#define SCC_RR1_FRAME_ERR 0x40 /* ..bad frame */ -#define SCC_RR1_RX_OVERRUN 0x20 /* rcv fifo overflow */ -#define SCC_RR1_PARITY_ERR 0x10 /* incorrect parity in data */ -#define SCC_RR1_RESIDUE0 0x08 -#define SCC_RR1_RESIDUE1 0x04 -#define SCC_RR1_RESIDUE2 0x02 -#define SCC_RR1_ALL_SENT 0x01 - -/* RR2 contains the interrupt vector unmodified (channel A) or - modified as follows (channel B, if vector-include-status) */ - -#define SCC_RR2_STATUS(val) ((val)&0xf) - -#define SCC_RR2_B_XMIT_DONE 0x0 -#define SCC_RR2_B_EXT_STATUS 0x2 -#define SCC_RR2_B_RECV_DONE 0x4 -#define SCC_RR2_B_RECV_SPECIAL 0x6 -#define SCC_RR2_A_XMIT_DONE 0x8 -#define SCC_RR2_A_EXT_STATUS 0xa -#define SCC_RR2_A_RECV_DONE 0xc -#define SCC_RR2_A_RECV_SPECIAL 0xe - -/* Interrupts pending, to be read from channel A only (B raz) */ -#define SCC_RR3_zero 0xc0 -#define SCC_RR3_RX_IP_A 0x20 -#define SCC_RR3_TX_IP_A 0x10 -#define SCC_RR3_EXT_IP_A 0x08 -#define SCC_RR3_RX_IP_B 0x04 -#define SCC_RR3_TX_IP_B 0x02 -#define SCC_RR3_EXT_IP_B 0x01 - -/* RR8 is the receive data buffer, a 3 deep FIFO */ -#define SCC_RECV_BUFFER SCC_RR8 -#define SCC_RECV_FIFO_DEEP 3 - -#define SCC_RR10_1CLKS 0x80 -#define SCC_RR10_2CLKS 0x40 -#define SCC_RR10_zero 0x2d -#define SCC_RR10_LOOP_SND 0x10 -#define SCC_RR10_ON_LOOP 0x02 - -/* RR12/RR13 hold the timing base, upper byte in RR13 */ - -#define scc_get_timing_base(scc,chan,val) { \ - register char tmp; \ - scc_read_reg(scc,chan,SCC_RR12,val);\ - scc_read_reg(scc,chan,SCC_RR13,tmp);\ - (val) = ((val)<<8)|(tmp&0xff);\ - } - -#define SCC_RR15_BREAK_IE 0x80 -#define SCC_RR15_TX_UNDERRUN_IE 0x40 -#define SCC_RR15_CTS_IE 0x20 -#define SCC_RR15_SYNCH_IE 0x10 -#define SCC_RR15_DCD_IE 0x08 -#define SCC_RR15_zero 0x05 -#define SCC_RR15_ZERO_COUNT_IE 0x02 - - -/* - * Write registers defines - */ - -/* WR0 is used for commands too */ -#define SCC_RESET_TXURUN_LATCH 0xc0 -#define SCC_RESET_TX_CRC 0x80 -#define SCC_RESET_RX_CRC 0x40 -#define SCC_RESET_HIGHEST_IUS 0x38 /* channel A only */ -#define SCC_RESET_ERROR 0x30 -#define SCC_RESET_TX_IP 0x28 -#define SCC_IE_NEXT_CHAR 0x20 -#define SCC_SEND_SDLC_ABORT 0x18 -#define SCC_RESET_EXT_IP 0x10 - -#define SCC_WR1_DMA_ENABLE 0x80 /* dma control */ -#define SCC_WR1_DMA_MODE 0x40 /* drive ~req for DMA controller */ -#define SCC_WR1_DMA_RECV_DATA 0x20 /* from wire to host memory */ - /* interrupt enable/conditions */ -#define SCC_WR1_RXI_SPECIAL_O 0x18 /* on special only */ -#define SCC_WR1_RXI_ALL_CHAR 0x10 /* on each char, or special */ -#define SCC_WR1_RXI_FIRST_CHAR 0x08 /* on first char, or special */ -#define SCC_WR1_RXI_DISABLE 0x00 /* never on recv */ -#define SCC_WR1_PARITY_IE 0x04 /* on parity errors */ -#define SCC_WR1_TX_IE 0x02 -#define SCC_WR1_EXT_IE 0x01 - -/* WR2 is common and contains the interrupt vector (high nibble) */ - -#define SCC_WR3_RX_8_BITS 0xc0 -#define SCC_WR3_RX_6_BITS 0x80 -#define SCC_WR3_RX_7_BITS 0x40 -#define SCC_WR3_RX_5_BITS 0x00 -#define SCC_WR3_AUTO_ENABLE 0x20 -#define SCC_WR3_HUNT_MODE 0x10 -#define SCC_WR3_RX_CRC_ENABLE 0x08 -#define SCC_WR3_SDLC_SRCH 0x04 -#define SCC_WR3_INHIBIT_SYNCH 0x02 -#define SCC_WR3_RX_ENABLE 0x01 - -/* Should be re-written after reset */ -#define SCC_WR4_CLK_x64 0xc0 /* clock divide factor */ -#define SCC_WR4_CLK_x32 0x80 -#define SCC_WR4_CLK_x16 0x40 -#define SCC_WR4_CLK_x1 0x00 -#define SCC_WR4_EXT_SYNCH_MODE 0x30 /* synch modes */ -#define SCC_WR4_SDLC_MODE 0x20 -#define SCC_WR4_16BIT_SYNCH 0x10 -#define SCC_WR4_8BIT_SYNCH 0x00 -#define SCC_WR4_2_STOP 0x0c /* asynch modes */ -#define SCC_WR4_1_5_STOP 0x08 -#define SCC_WR4_1_STOP 0x04 -#define SCC_WR4_SYNCH_MODE 0x00 -#define SCC_WR4_EVEN_PARITY 0x02 -#define SCC_WR4_PARITY_ENABLE 0x01 - -#define SCC_WR5_DTR 0x80 /* drive DTR pin */ -#define SCC_WR5_TX_8_BITS 0x60 -#define SCC_WR5_TX_6_BITS 0x40 -#define SCC_WR5_TX_7_BITS 0x20 -#define SCC_WR5_TX_5_BITS 0x00 -#define SCC_WR5_SEND_BREAK 0x10 -#define SCC_WR5_TX_ENABLE 0x08 -#define SCC_WR5_CRC_16 0x04 /* CRC if non zero, .. */ -#define SCC_WR5_SDLC 0x00 /* ..SDLC otherwise */ -#define SCC_WR5_RTS 0x02 /* drive RTS pin */ -#define SCC_WR5_TX_CRC_ENABLE 0x01 - -/* Registers WR6 and WR7 are for synch modes data, with among other things: */ - -#define SCC_WR6_BISYNCH_12 0x0f -#define SCC_WR6_SDLC_RANGE_MASK 0x0f -#define SCC_WR7_SDLC_FLAG 0x7e - -/* WR8 is the transmit data buffer (no FIFO) */ -#define SCC_XMT_BUFFER SCC_WR8 - -#define SCC_WR9_HW_RESET 0xc0 /* force hardware reset */ -#define SCC_WR9_RESET_CHA_A 0x80 -#define SCC_WR9_RESET_CHA_B 0x40 -#define SCC_WR9_NON_VECTORED 0x20 /* mbz for Zilog chip */ -#define SCC_WR9_STATUS_HIGH 0x10 -#define SCC_WR9_MASTER_IE 0x08 -#define SCC_WR9_DLC 0x04 /* disable-lower-chain */ -#define SCC_WR9_NV 0x02 /* no vector */ -#define SCC_WR9_VIS 0x01 /* vector-includes-status */ - -#define SCC_WR10_CRC_PRESET 0x80 -#define SCC_WR10_FM0 0x60 -#define SCC_WR10_FM1 0x40 -#define SCC_WR10_NRZI 0x20 -#define SCC_WR10_NRZ 0x00 -#define SCC_WR10_ACTIVE_ON_POLL 0x10 -#define SCC_WR10_MARK_IDLE 0x08 /* flag if zero */ -#define SCC_WR10_ABORT_ON_URUN 0x04 /* flag if zero */ -#define SCC_WR10_LOOP_MODE 0x02 -#define SCC_WR10_6BIT_SYNCH 0x01 -#define SCC_WR10_8BIT_SYNCH 0x00 - -#define SCC_WR11_RTxC_XTAL 0x80 /* RTxC pin is input (ext oscill) */ -#define SCC_WR11_RCLK_DPLL 0x60 /* clock received data on dpll */ -#define SCC_WR11_RCLK_BAUDR 0x40 /* .. on BRG */ -#define SCC_WR11_RCLK_TRc_PIN 0x20 /* .. on TRxC pin */ -#define SCC_WR11_RCLK_RTc_PIN 0x00 /* .. on RTxC pin */ -#define SCC_WR11_XTLK_DPLL 0x18 -#define SCC_WR11_XTLK_BAUDR 0x10 -#define SCC_WR11_XTLK_TRc_PIN 0x08 -#define SCC_WR11_XTLK_RTc_PIN 0x00 -#define SCC_WR11_TRc_OUT 0x04 /* drive TRxC pin as output from..*/ -#define SCC_WR11_TRcOUT_DPLL 0x03 /* .. the dpll */ -#define SCC_WR11_TRcOUT_BAUDR 0x02 /* .. the BRG */ -#define SCC_WR11_TRcOUT_XMTCLK 0x01 /* .. the xmit clock */ -#define SCC_WR11_TRcOUT_XTAL 0x00 /* .. the external oscillator */ - -/* WR12/WR13 are for timing base preset */ -#define scc_set_timing_base(scc,chan,val) { \ - scc_write_reg(scc,chan,SCC_RR12,val);\ - scc_write_reg(scc,chan,SCC_RR13,(val)>>8);\ - } - -/* More commands in this register */ -#define SCC_WR14_NRZI_MODE 0xe0 /* synch modulations */ -#define SCC_WR14_FM_MODE 0xc0 -#define SCC_WR14_RTc_SOURCE 0xa0 /* clock is from pin .. */ -#define SCC_WR14_BAUDR_SOURCE 0x80 /* .. or internal BRG */ -#define SCC_WR14_DISABLE_DPLL 0x60 -#define SCC_WR14_RESET_CLKMISS 0x40 -#define SCC_WR14_SEARCH_MODE 0x20 -/* ..and more bitsy */ -#define SCC_WR14_LOCAL_LOOPB 0x10 -#define SCC_WR14_AUTO_ECHO 0x08 -#define SCC_WR14_DTR_REQUEST 0x04 -#define SCC_WR14_BAUDR_SRC 0x02 -#define SCC_WR14_BAUDR_ENABLE 0x01 - -#define SCC_WR15_BREAK_IE 0x80 -#define SCC_WR15_TX_UNDERRUN_IE 0x40 -#define SCC_WR15_CTS_IE 0x20 -#define SCC_WR15_SYNCHUNT_IE 0x10 -#define SCC_WR15_DCD_IE 0x08 -#define SCC_WR15_zero 0x05 -#define SCC_WR15_ZERO_COUNT_IE 0x02 - - -#endif /*_SCC_8530_H_*/ diff --git a/sys/arch/mac68k/dev/scc_8530_hdw.c b/sys/arch/mac68k/dev/scc_8530_hdw.c deleted file mode 100644 index 837cd3c3ea4b..000000000000 --- a/sys/arch/mac68k/dev/scc_8530_hdw.c +++ /dev/null @@ -1,1038 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1993-1989 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ -/* - * HISTORY - * $Log: scc_8530_hdw.c,v $ - * Revision 1.1.1.1 1993/09/29 06:09:28 briggs - * The current MacBSD architecture sub-directory for NetBSD-0.9--more or - * less. It needs some help to get to be -current. Support for minimal - * hardware on the SE/30, II, IIx, and IIcx exists. - * - * Revision 2.9 93/03/26 17:58:01 mrt - * No minor()s, no dev_t. - * [93/03/18 af] - * - * Revision 2.8 93/03/09 10:52:21 danner - * GCC quiet. - * [93/03/07 13:29:58 af] - * - * Post-debugging lint. - * [93/03/05 af] - * - * Revision 2.7 93/02/05 08:05:17 danner - * Flamingo, full_modem and isa_console per-line. - * [93/02/04 af] - * - * Revision 2.6 93/01/14 17:21:44 danner - * static/extern cleanups. - * [93/01/14 danner] - * - * Proper spl typing. - * [92/11/30 af] - * - * Revision 2.5 92/05/05 10:04:59 danner - * Fixed how the interrupt routine plays with priorities. - * Ask for buffering on all lines. - * [92/05/04 11:15:43 af] - * - * Fixed for more than just rconsole-ing. Two bugs: the chip - * needs one char out to generate the xmit-empty (so it really - * is a xmit-done) interrupt, and the t_addr game was not played - * properly. - * Tested both on maxine and the two serial lines kmin has. - * [92/04/14 11:47:26 af] - * - * Revision 2.4 92/02/19 16:46:10 elf - * Uhmm, lotsa changes. Basically, got channel B working - * and made it possible to use it as rconsole line. - * Missing modem bitsies only. - * A joint Terri&Sandro feature presentation. - * [92/02/10 17:03:08 af] - * - * Revision 2.3 91/08/28 11:09:53 jsb - * Fixed scc_scan to actually check the tp->state each time, - * we are not notified when the MI code brutally zeroes it - * on close and so we cannot update our software CARrier. - * [91/08/27 16:18:05 af] - * - * Revision 2.2 91/08/24 11:52:54 af - * Created, from the Zilog specs: - * "Z8530 SCC Serial Communications Controller, Product Specification" - * in the "1983/84 Components Data Book" pp 409-429, September 1983 - * Zilog, Campbell, CA 95008 - * [91/06/28 af] - * - */ -#ident "$Id: scc_8530_hdw.c,v 1.1.1.1 1993/09/29 06:09:28 briggs Exp $" -/* - * File: scc_8530_hdw.c - * Author: Alessandro Forin, Carnegie Mellon University - * Date: 6/91 - * - * Hardware-level operations for the SCC Serial Line Driver - */ - -#include -#if NSCC > 0 -#include -#include - -#include - -#include /* spl definitions */ -#include -#include -#include -#include - -#include -#include -#include - -/* Alignment and padding */ -#if defined(DECSTATION) -/* - * 3min's padding - */ -typedef struct { - char pad0; - volatile unsigned char datum; - char pad1[2]; -} scc_padded1_register_t; - -#define scc_register_t scc_padded1_register_t -#endif - -#if defined(FLAMINGO) -typedef struct { - volatile unsigned int datum; - unsigned int pad1; -} scc_padded1_register_t; - -#define scc_register_t scc_padded1_register_t - -#define scc_set_datum(d,v) (d) = (volatile unsigned int) (v) << 8, wbflush() -#define scc_get_datum(d,v) (v) = ((d) >> 8) & 0xff - -#endif - -#include /* needs the above defs */ - -/* - * On the 3min keyboard and mouse come in on channels A - * of the two units. The MI code expects them at 'lines' - * 0 and 1, respectively. So we map here back and forth. - * Note also the MI code believes unit 0 has four lines. - */ - -#define SCC_KBDUNIT 1 -#define SCC_PTRUNIT 0 - -mi_to_scc(unitp, linep) - int *unitp, *linep; -{ - /* only play games on MI 'unit' 0 */ - if (*unitp) { - /* e.g. by mapping the first four lines specially */ - *unitp++; - return; - } - - /* always get unit=0 (console) and line = 0|1 */ - if (*linep == SCREEN_LINE_KEYBOARD) { - *unitp = SCC_KBDUNIT; - *linep = SCC_CHANNEL_A; - } else if (*linep == SCREEN_LINE_POINTER) { - *unitp = SCC_PTRUNIT; - *linep = SCC_CHANNEL_A; - } else { - *unitp = (*linep & 1); - *linep = SCC_CHANNEL_B; - } -/* line 0 is channel B, line 1 is channel A */ -} - -#define NSCC_LINE 2 /* 2 ttys per chip */ - -/* only care for mapping to ttyno */ -scc_to_mi(sccunit, sccline) -{ - if (sccunit > 1) - return (sccunit * NSCC_LINE + sccline); - /* only for console (first pair of SCCs): */ - if (sccline == SCC_CHANNEL_A) - return ((!sccunit) & 1); - return 2+sccunit; -} - - -/* - * Driver status - */ -struct scc_softc { - scc_regmap_t *regs; - - /* software copy of some write regs, for reg |= */ - struct softreg { - unsigned char wr1; - unsigned char wr4; - unsigned char wr5; - unsigned char wr14; - } softr[2]; /* per channel */ - - unsigned short breaks; - unsigned short fake; /* missing rs232 bits, channel A */ - char polling_mode; - char softCAR, osoftCAR; - char probed_once; - - boolean_t full_modem; - boolean_t isa_console; - -} scc_softc_data[NSCC]; - -typedef struct scc_softc *scc_softc_t; - -scc_softc_t scc_softc[NSCC]; - -scc_softCAR(unit, line, on) -{ - mi_to_scc(&unit, &line); - if (on) - scc_softc[unit]->softCAR |= 1<softCAR &= ~(1 << line); -} - - -/* - * BRG formula is: - * ClockFrequency - * BRGconstant = --------------------------- - 2 - * 2 * BaudRate * ClockDivider - */ -/* Speed selections with Pclk=7.3728Mhz, clock x16 */ -static -short scc_speeds[] = - /* 0 50 75 110 134.5 150 200 300 600 1200 1800 2400 */ - { 0, 4606, 3070, 2093, 1711, 1534, 1150, 766, 382, 190, 126, 94, - - /* 4800 9600 19.2k 38.4k */ - 46, 22, 10, 4}; - -/* - * Definition of the driver for the auto-configuration program. - */ - -int scc_probe(), scc_attach(), scc_intr(); - -caddr_t scc_std[NSCC] = { 0 }; -struct bus_device *scc_info[NSCC]; -struct bus_driver scc_driver = - { scc_probe, 0, scc_attach, 0, scc_std, "scc", scc_info,}; - -/* - * Adapt/Probe/Attach functions - */ -boolean_t scc_uses_modem_control = FALSE;/* patch this with adb */ - -set_scc_address( sccunit, regs, has_modem, isa_console) - caddr_t regs; - boolean_t has_modem; - boolean_t isa_console; -{ - extern int scc_probe(), scc_param(), scc_start(), - scc_putc(), scc_getc(), - scc_pollc(), scc_mctl(), scc_softCAR(); - - scc_std[sccunit] = regs; - scc_softc_data[sccunit].full_modem = has_modem & scc_uses_modem_control; - scc_softc_data[sccunit].isa_console = isa_console; - - /* Do this here */ - console_probe = scc_probe; - console_param = scc_param; - console_start = scc_start; - console_putc = scc_putc; - console_getc = scc_getc; - console_pollc = scc_pollc; - console_mctl = scc_mctl; - console_softCAR = scc_softCAR; - -} - -scc_probe( xxx, ui) - struct bus_device *ui; -{ - int sccunit = ui->unit; - scc_softc_t scc; - register int val; - register scc_regmap_t *regs; - - regs = (scc_regmap_t *)scc_std[sccunit]; - if (regs == 0) - return 0; - - /* - * See if we are here - */ - if (check_memory(regs, 0)) { - /* no rides today */ - return 0; - } - - scc = &scc_softc_data[sccunit]; - - if (scc->probed_once++){ - return 1; - } - /* - * Chip once-only initialization - * - * NOTE: The wiring we assume is the one on the 3min: - * - * out A-TxD --> TxD keybd or mouse - * in A-RxD --> RxD keybd or mouse - * out A-DTR~ --> DTR comm - * out A-RTS~ --> RTS comm - * in A-CTS~ --> SI comm - * in A-DCD~ --> RI comm - * in A-SYNCH~--> DSR comm - * out B-TxD --> TxD comm - * in B-RxD --> RxD comm - * in B-RxC --> TRxCB comm - * in B-TxC --> RTxCB comm - * out B-RTS~ --> SS comm - * in B-CTS~ --> CTS comm - * in B-DCD~ --> CD comm - */ - - scc_softc[sccunit] = scc; - scc->regs = regs; - - scc->fake = 1<t_addr = (char*)(0x80000000L + (sccunit<<1) + (i&1)); - /* do min buffering */ - tp->t_state |= TS_MIN; - } - } - - /* make sure reg pointer is in known state */ - scc_init_reg(regs, SCC_CHANNEL_A); - scc_init_reg(regs, SCC_CHANNEL_B); - - /* reset chip, fully */ - scc_write_reg(regs, SCC_CHANNEL_A, SCC_WR9, SCC_WR9_HW_RESET); - delay(50000);/*enough ? */ - scc_write_reg(regs, SCC_CHANNEL_A, SCC_WR9, 0); - - /* program the interrupt vector */ - scc_write_reg(regs, SCC_CHANNEL_A, SCC_WR2, 0xf0); - scc_write_reg(regs, SCC_CHANNEL_B, SCC_WR2, 0xf0); - scc_write_reg(regs, SCC_CHANNEL_A, SCC_WR9, SCC_WR9_VIS); - - /* most of the init is in scc_param() */ - - /* timing base defaults */ - scc->softr[SCC_CHANNEL_A].wr4 = SCC_WR4_CLK_x16; - scc->softr[SCC_CHANNEL_B].wr4 = SCC_WR4_CLK_x16; - - /* enable DTR, RTS and SS */ - scc->softr[SCC_CHANNEL_B].wr5 = SCC_WR5_RTS; - scc->softr[SCC_CHANNEL_A].wr5 = SCC_WR5_RTS | SCC_WR5_DTR; - - /* baud rates */ - val = SCC_WR14_BAUDR_ENABLE|SCC_WR14_BAUDR_SRC; - scc->softr[SCC_CHANNEL_B].wr14 = val; - scc->softr[SCC_CHANNEL_A].wr14 = val; - - /* interrupt conditions */ - val = SCC_WR1_RXI_ALL_CHAR | SCC_WR1_PARITY_IE | - SCC_WR1_EXT_IE | SCC_WR1_TX_IE; - scc->softr[SCC_CHANNEL_A].wr1 = val; - scc->softr[SCC_CHANNEL_B].wr1 = val; - - /* - * After probing, any line that should be active - * (keybd,mouse,rcline) is activated via scc_param(). - */ - - scc_set_modem_control(scc, scc->full_modem); - -#if defined(KMIN) || defined (FLAMINGO) - /* - * Crock: MI code knows of unit 0 as console, we need - * unit 1 as well since the keyboard is there - * This is acceptable on maxine, which has to call its - * only one chip unit 1 so that rconsole is happy. - */ - if (sccunit == 0) { - struct bus_device d; - d = *ui; - d.unit = 1; - scc_probe( xxx, &d); - } -#endif - return 1; -} - -boolean_t scc_timer_started = FALSE; - -scc_attach(ui) - register struct bus_device *ui; -{ - int sccunit = ui->unit; - extern scc_scan(); - extern int tty_inq_size; - int i; - - /* We only have 4 ttys, but always at 9600 - * Give em a lot of room (plus dma..) - */ - tty_inq_size = 4096; - if (!scc_timer_started) { - /* do all of them, before we call scc_scan() */ - /* harmless if done already */ - for (i = 0; i < NSCC*NSCC_LINE; i++) - ttychars(console_tty[i]); - - scc_timer_started = TRUE; - scc_scan(); - } - -#if NBM > 0 - if (SCREEN_ISA_CONSOLE() && scc_softc[sccunit]->isa_console) { - printf("\n sl0: "); - if (sccunit && rcline == 3) printf("( rconsole )"); - - if (sccunit == SCC_KBDUNIT) { - printf("\n sl1: "); lk201_attach(0, sccunit >> 1); - } else if (sccunit == SCC_PTRUNIT) { - printf("\n sl1: "); mouse_attach(0, sccunit >> 1); - } - } else -#endif /*NBM > 0*/ - { - printf("%s", (sccunit == 1) ? - "\n sl0: ( alternate console )\n sl1:" : - "\n sl0:\n sl1:"); - } -} - -/* - * Would you like to make a phone call ? - */ -scc_set_modem_control(scc, on) - scc_softc_t scc; - boolean_t on; -{ - if (on) - /* your problem if the hardware then is broke */ - scc->fake = 0; - else - scc->fake = 3; - scc->full_modem = on; - /* user should do an scc_param() ifchanged */ -} - -/* - * Polled I/O (debugger) - */ -scc_pollc(unit, on) - boolean_t on; -{ - scc_softc_t scc; - int line = SCREEN_LINE_KEYBOARD, - sccunit = unit; - - mi_to_scc(&sccunit, &line); - - scc = scc_softc[sccunit]; - if (on) { - scc->polling_mode++; -#if NBM > 0 - screen_on_off(unit, TRUE); -#endif NBM > 0 - } else - scc->polling_mode--; -} - -/* - * Interrupt routine - */ -int scc_intr_count; - -scc_intr(unit,spllevel) - spl_t spllevel; -{ - scc_softc_t scc = scc_softc[unit]; - register scc_regmap_t *regs = scc->regs; - register int rr1, rr2; - register int c; - -scc_intr_count++; - -#if mips - splx(spllevel); /* lower priority */ -#endif - -next_intr: - - scc_read_reg(regs, SCC_CHANNEL_B, SCC_RR2, rr2); - - rr2 = SCC_RR2_STATUS(rr2); - - /* are we done yet ? */ - if (rr2 == 6) { /* strange, distinguished value */ - register int rr3; - scc_read_reg(regs, SCC_CHANNEL_A, SCC_RR3, rr3); - if (rr3 == 0) - return; - } - - if ((rr2 == SCC_RR2_A_XMIT_DONE) || (rr2 == SCC_RR2_B_XMIT_DONE)) { - - register chan = (rr2 == SCC_RR2_A_XMIT_DONE) ? - SCC_CHANNEL_A : SCC_CHANNEL_B; - - scc_write_reg(regs, SCC_CHANNEL_A, SCC_RR0, SCC_RESET_HIGHEST_IUS); - c = cons_simple_tint(scc_to_mi(unit,chan), FALSE); - - if (c == -1) { - /* no more data for this line */ - - scc_read_reg(regs, chan, SCC_RR15, c); - c &= ~SCC_WR15_TX_UNDERRUN_IE; - scc_write_reg(regs, chan, SCC_WR15, c); - - c = scc->softr[chan].wr1 & ~SCC_WR1_TX_IE; - scc_write_reg(regs, chan, SCC_WR1, c); - scc->softr[chan].wr1 = c; - - c = cons_simple_tint(scc_to_mi(unit,chan), TRUE); - if (c != -1) - /* funny race, scc_start has been called already */ - scc_write_data(regs, chan, c); - } else { - scc_write_data(regs, chan, c); - /* and leave it enabled */ - } - } - - else if (rr2 == SCC_RR2_A_RECV_DONE) { - int err = 0; - - scc_write_reg(regs, SCC_CHANNEL_A, SCC_RR0, SCC_RESET_HIGHEST_IUS); - if (scc->polling_mode) - goto next_intr; - - scc_read_data(regs, SCC_CHANNEL_A, c); - rr1 = scc_to_mi(unit,SCC_CHANNEL_A); - cons_simple_rint (rr1, rr1, c, 0); - } - - else if (rr2 == SCC_RR2_B_RECV_DONE) { - int err = 0; - - scc_write_reg(regs, SCC_CHANNEL_A, SCC_RR0, SCC_RESET_HIGHEST_IUS); - if (scc->polling_mode) - goto next_intr; - - scc_read_data(regs, SCC_CHANNEL_B, c); - rr1 = scc_to_mi(unit,SCC_CHANNEL_B); - cons_simple_rint (rr1, rr1, c, 0); - } - - else if ((rr2 == SCC_RR2_A_EXT_STATUS) || (rr2 == SCC_RR2_B_EXT_STATUS)) { - int chan = (rr2 == SCC_RR2_A_EXT_STATUS) ? - SCC_CHANNEL_A : SCC_CHANNEL_B; - scc_write_reg(regs, chan, SCC_RR0, SCC_RESET_EXT_IP); - scc_write_reg(regs, SCC_CHANNEL_A, SCC_RR0, SCC_RESET_HIGHEST_IUS); - scc_modem_intr(scc, chan); - } - - else if ((rr2 == SCC_RR2_A_RECV_SPECIAL) || (rr2 == SCC_RR2_B_RECV_SPECIAL)) { - register int chan = (rr2 == SCC_RR2_A_RECV_SPECIAL) ? - SCC_CHANNEL_A : SCC_CHANNEL_B; - - scc_read_reg(regs, chan, SCC_RR1, rr1); - if (rr1 & (SCC_RR1_PARITY_ERR | SCC_RR1_RX_OVERRUN | SCC_RR1_FRAME_ERR)) { - int err; - /* map to CONS_ERR_xxx MI error codes */ - err = ((rr1 & SCC_RR1_PARITY_ERR)<<8) | - ((rr1 & SCC_RR1_RX_OVERRUN)<<9) | - ((rr1 & SCC_RR1_FRAME_ERR)<<7); - scc_write_reg(regs, chan, SCC_RR0, SCC_RESET_ERROR); - rr1 = scc_to_mi(unit,chan); - cons_simple_rint(rr1, rr1, 0, err); - } - scc_write_reg(regs, SCC_CHANNEL_A, SCC_RR0, SCC_RESET_HIGHEST_IUS); - } - - goto next_intr; - -} - -boolean_t -scc_start(tp) - struct tty *tp; -{ - register scc_regmap_t *regs; - register int chan, temp; - register struct softreg *sr; - - temp = (natural_t)tp->t_addr; - chan = (temp & 1); /* channel */ - temp = (temp >> 1)&0xff;/* sccunit */ - regs = scc_softc[temp]->regs; - sr = &scc_softc[temp]->softr[chan]; - - scc_read_reg(regs, chan, SCC_RR15, temp); - temp |= SCC_WR15_TX_UNDERRUN_IE; - scc_write_reg(regs, chan, SCC_WR15, temp); - - temp = sr->wr1 | SCC_WR1_TX_IE; - scc_write_reg(regs, chan, SCC_WR1, temp); - sr->wr1 = temp; - - /* but we need a first char out or no cookie */ - scc_read_reg(regs, chan, SCC_RR0, temp); - if (temp & SCC_RR0_TX_EMPTY) - { - register char c; - - c = getc(&tp->t_outq); - scc_write_data(regs, chan, c); - } -} - -/* - * Get a char from a specific SCC line - * [this is only used for console&screen purposes] - */ -scc_getc( unit, line, wait, raw ) - boolean_t wait; - boolean_t raw; -{ - scc_softc_t scc; - register scc_regmap_t *regs; - unsigned char c; - int value, mi_line, rcvalue, from_line; - - mi_line = line; - mi_to_scc(&unit, &line); - - scc = scc_softc[unit]; - regs = scc->regs; - - /* - * wait till something available - * - * NOTE: we know! that rcline==3 - */ - if (rcline) rcline = 3; -again: - rcvalue = 0; - while (1) { - scc_read_reg_zero(regs, line, value); - if (rcline && (mi_line == SCREEN_LINE_KEYBOARD)) { - scc_read_reg_zero(regs, SCC_CHANNEL_B, rcvalue); - value |= rcvalue; - } - if (((value & SCC_RR0_RX_AVAIL) == 0) && wait) - delay(10); - else - break; - } - - /* - * if nothing found return -1 - */ - from_line = (rcvalue & SCC_RR0_RX_AVAIL) ? SCC_CHANNEL_B : line; - - if (value & SCC_RR0_RX_AVAIL) { - scc_read_reg(regs, from_line, SCC_RR1, value); - scc_read_data(regs, from_line, c); - } else { -/* splx(s);*/ - return -1; - } - - /* - * bad chars not ok - */ - if (value&(SCC_RR1_PARITY_ERR | SCC_RR1_RX_OVERRUN | SCC_RR1_FRAME_ERR)) { -/* scc_state(unit,from_line); */ - scc_write_reg(regs, from_line, SCC_RR0, SCC_RESET_ERROR); - if (wait) { - scc_write_reg(regs, SCC_CHANNEL_A, SCC_RR0, SCC_RESET_HIGHEST_IUS); - goto again; - } - } - scc_write_reg(regs, SCC_CHANNEL_A, SCC_RR0, SCC_RESET_HIGHEST_IUS); -/* splx(s);*/ - - -#if NBM > 0 - if ((mi_line == SCREEN_LINE_KEYBOARD) && (from_line == SCC_CHANNEL_A) && - !raw && SCREEN_ISA_CONSOLE() && scc->isa_console) - return lk201_rint(SCREEN_CONS_UNIT(), c, wait, scc->polling_mode); - else -#endif NBM > 0 - return c; -} - -/* - * Put a char on a specific SCC line - */ -scc_putc( unit, line, c ) -{ - scc_softc_t scc; - register scc_regmap_t *regs; - spl_t s = spltty(); - register int value; - - mi_to_scc(&unit, &line); - - scc = scc_softc[unit]; - regs = scc->regs; - - do { - scc_read_reg(regs, line, SCC_RR0, value); - if (value & SCC_RR0_TX_EMPTY) - break; - delay(100); - } while (1); - - scc_write_data(regs, line, c); -/* wait for it to swallow the char ? */ - - splx(s); -} - -scc_param(tp, line) - struct tty *tp; -{ - scc_regmap_t *regs; - int value, sccline, unit; - struct softreg *sr; - scc_softc_t scc; - - line = tp->t_dev; - /* MI code wants us to handle 4 lines on unit 0 */ - unit = (line < 4) ? 0 : (line / NSCC_LINE); - sccline = line; - mi_to_scc(&unit, &sccline); - - if ((scc = scc_softc[unit]) == 0) return; /* sanity */ - regs = scc->regs; - - sr = &scc->softr[sccline]; - - /* - * Do not let user fool around with kbd&mouse - */ -#if NBM > 0 - if (screen_captures(line)) { - tp->t_ispeed = tp->t_ospeed = B4800; - tp->t_flags |= TF_LITOUT; - } -#endif NBM > 0 - - if (tp->t_ispeed == 0) { - (void) scc_mctl(tp->t_dev, TM_HUP, DMSET); /* hang up line */ - return; - } - - /* reset line */ - value = (sccline == SCC_CHANNEL_A) ? SCC_WR9_RESET_CHA_A : SCC_WR9_RESET_CHA_B; - scc_write_reg(regs, sccline, SCC_WR9, value); - delay(25); - - /* stop bits, normally 1 */ - value = sr->wr4 & 0xf0; - value |= (tp->t_ispeed == B110) ? SCC_WR4_2_STOP : SCC_WR4_1_STOP; - /* .. and parity */ -#if 0 - if ((tp->t_flags & (TF_ODDP | TF_EVENP)) == TF_EVENP) - value |= SCC_WR4_EVEN_PARITY; - value |= SCC_WR4_PARITY_ENABLE; -#else - if ((tp->t_flags & (TF_ODDP | TF_EVENP)) == TF_ODDP) - value |= SCC_WR4_PARITY_ENABLE; -#endif - - /* set it now, remember it must be first after reset */ - sr->wr4 = value; - scc_write_reg(regs, sccline, SCC_WR4, value); - - /* vector again */ - scc_write_reg(regs, sccline, SCC_WR2, 0xf0); - - /* we only do 8 bits per char */ - value = SCC_WR3_RX_8_BITS; - scc_write_reg(regs, sccline, SCC_WR3, value); - - /* clear break, keep rts dtr */ - value = sr->wr5 & (SCC_WR5_DTR|SCC_WR5_RTS); - value |= SCC_WR5_TX_8_BITS; - sr->wr5 = value; - scc_write_reg(regs, sccline, SCC_WR5, value); - - scc_write_reg(regs, sccline, SCC_WR6, 0); - scc_write_reg(regs, sccline, SCC_WR7, 0); - - scc_write_reg(regs, sccline, SCC_WR9, SCC_WR9_VIS); - - scc_write_reg(regs, sccline, SCC_WR10, 0); - - /* clock config */ - value = SCC_WR11_RCLK_BAUDR | SCC_WR11_XTLK_BAUDR | - SCC_WR11_TRc_OUT | SCC_WR11_TRcOUT_BAUDR; - scc_write_reg(regs, sccline, SCC_WR11, value); - - value = scc_speeds[tp->t_ispeed]; - scc_set_timing_base(regs,sccline,value); - - value = sr->wr14; - scc_write_reg(regs, sccline, SCC_WR14, value); - - value = (scc->full_modem) ? - SCC_WR15_BREAK_IE | SCC_WR15_CTS_IE | SCC_WR15_DCD_IE : - SCC_WR15_BREAK_IE; - scc_write_reg(regs, sccline, SCC_WR15, value); - - /* and now the enables */ - value = SCC_WR3_RX_8_BITS | SCC_WR3_RX_ENABLE; - scc_write_reg(regs, sccline, SCC_WR3, value); - - value = sr->wr5 | SCC_WR5_TX_ENABLE; - sr->wr5 = value; - scc_write_reg(regs, sccline, SCC_WR5, value); - - /* master inter enable */ - scc_write_reg(regs,sccline,SCC_WR9,SCC_WR9_MASTER_IE|SCC_WR9_VIS); - - scc_write_reg(regs, sccline, SCC_WR1, sr->wr1); - -} - -/* - * Modem control functions - */ -scc_mctl(dev, bits, how) - int dev; - int bits, how; -{ - return 0; -#if 0 - register scc_regmap_t *regs; - int unit, sccline; - register int tcr, msr, brk, n_tcr, n_brk; - int b; - spl_t s; - scc_softc_t sc; - - unit = dev; - sccline = unit & 3; - unit >>= 2; - mi_to_scc(&unit, &sccline); - - /* no modem support on channel A */ -/* XXX break on 0&1 */ - if (sccline == SCC_CHANNEL_A) - return TM_LE | TM_DTR | TM_CTS | TM_CAR | TM_DSR; - - scc = scc_softc[unit]; - regs = scc->regs; - s = spltty(); - -....some other day.. - - tcr = ((regs->scc_tcr | (scc->fake>>4)) & 0xf00) >> (8 + b*2); - brk = (scc->breaks >> (8 + (unit&3))) & 1; /* THE break bit */ - - n_tcr = (bits & (TM_RTS | TM_DTR)) >> 1; - n_brk = (bits & TM_BRK) >> 9; - - /* break transitions, must 'send' a char out */ - bits = (brk ^ n_brk) & 1; - - switch (how) { - case DMSET: - tcr = n_tcr; - brk = n_brk; - break; - - case DMBIS: - tcr |= n_tcr; - brk |= n_brk; - break; - - case DMBIC: - tcr &= ~n_tcr; - brk = 0; - break; - - case DMGET: - msr = ((regs->scc_msr | scc->fake) & 0xf0f) >> (b*8); - (void) splx(s); - return (tcr<<1)|/* DTR, RTS */ - ((msr&1)<<5)|/* CTS */ - ((msr&2)<<7)|/* DSR */ - ((msr&0xc)<<4)|/* CD, RNG */ - (brk << 9)|/* BRK */ - TM_LE; - } - n_tcr = (regs->scc_tcr & ~(3 << (8 + b*2))) | - (tcr << (8 + b*2)); - - regs->scc_tcr = n_tcr; - scc->fake = (scc->fake & 0xf0f) | (n_tcr<<4&0xf000); - - scc->breaks = (scc->breaks & ~(1 << (8 + (unit&3)))) | - (brk << (8 + (unit&3))); - if(bits) scc_putc( unit>>2, unit&3, 0);/* force break, now */ - (void) splx(s); - return 0;/* useless to compute it */ -#endif -} - -scc_modem_intr(scc, chan) -{ - /* nothing yet */ -} - -static check_car( - register struct tty *tp, - boolean_t car) - -{ - if (car) { -#if notyet - /* cancel modem timeout if need to */ - if (car & (SCC_MSR_CD2 | SCC_MSR_CD3)) - untimeout(scc_hup, (caddr_t)tp); -#endif - - /* I think this belongs in the MI code */ - if (tp->t_state & TS_WOPEN) - tp->t_state |= TS_ISOPEN; - /* carrier present */ - if ((tp->t_state & TS_CARR_ON) == 0) - (void)ttymodem(tp, 1); - } else if ((tp->t_state&TS_CARR_ON) && ttymodem(tp, 0) == 0) - scc_mctl( tp->t_dev, TM_DTR, DMBIC); -} - -/* - * Periodically look at the CD signals: - * they do generate interrupts but we - * must fake them on channel A. We might - * also fake them on channel B. - */ -scc_scan() -{ - register i; - spl_t s = spltty(); - - for (i = 0; i < NSCC; i++) { - register scc_softc_t scc; - register int car; - register struct tty **tpp; - - scc = scc_softc[i]; - if (scc == 0) - continue; - car = scc->softCAR | scc->fake; - - tpp = &console_tty[i * NSCC_LINE]; - - while (car) { - if (car & 1) - check_car(*tpp, 1); - tpp++; - car = car>>1; - } - - } - splx(s); - timeout(scc_scan, (caddr_t)0, 5*hz); -} - - -#if 0 /* debug */ -scc_rreg(unit,chan,n) -{ - int val; - scc_read_reg(scc_softc[unit]->regs, chan, n, val); - return val; -} - -scc_wreg(unit,chan,n,val) -{ - scc_write_reg(scc_softc[unit]->regs, chan, n, val); -} - -scc_state(unit,soft) -{ - printf("{%d intr, A: R0 %x R1 %x R3 %x baudr %x R15 %x}\n", - scc_intr_count, - scc_rreg(unit, 1, SCC_RR0), - scc_rreg(unit, 1, SCC_RR1), - scc_rreg(unit, 1, SCC_RR3), - (scc_rreg(unit, 1, SCC_RR13) << 8) | scc_rreg(unit, 1, SCC_RR12), - scc_rreg(unit, 1, SCC_RR15)); - printf("{B: R0 %x R1 %x R2 %x baudr %x R15 %x}\n", - scc_rreg(unit, 1, SCC_RR0), - scc_rreg(unit, 1, SCC_RR1), - scc_rreg(unit, 1, SCC_RR2), - (scc_rreg(unit, 1, SCC_RR13) << 8) | scc_rreg(unit, 1, SCC_RR12), - scc_rreg(unit, 1, SCC_RR15)); - if (soft) { - struct softreg *sr; - sr = scc_softc[unit]->softr; - printf("{B: W1 %x W4 %x W5 %x W14 %x}", - sr->wr1, sr->wr4, sr->wr5, sr->wr14); - sr++; - printf("{A: W1 %x W4 %x W5 %x W14 %x}\n", - sr->wr1, sr->wr4, sr->wr5, sr->wr14); - } -} - -#endif - -#endif NSCC > 0 diff --git a/sys/arch/mac68k/include/nubus.h b/sys/arch/mac68k/include/nubus.h deleted file mode 100644 index a635972feb54..000000000000 --- a/sys/arch/mac68k/include/nubus.h +++ /dev/null @@ -1,45 +0,0 @@ -#error Helloo? Paying attention? This version shouldn't be used. -/*- - * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo, - * Michael L. Finch, Bradley A. Grantham, and - * Lawrence A. Kesteloot - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Alice Group. - * 4. The names of the Alice Group or any of its members may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -#ident "$Id: nubus.h,v 1.1.1.1 1993/09/29 06:09:23 briggs Exp $" - -/* LAK: NuBus info */ - -struct nubus { - int slotnum; /* Which slot */ - char str1[100]; /* First ID string */ - char str2[100]; /* Second ID string */ - char *addr; /* Address of board */ - char *rom; /* Address of ROM */ -}; diff --git a/sys/arch/mac68k/mac68k/symbols.raw b/sys/arch/mac68k/mac68k/symbols.raw deleted file mode 100644 index df9560e9e049..000000000000 --- a/sys/arch/mac68k/mac68k/symbols.raw +++ /dev/null @@ -1,89 +0,0 @@ -# @(#)symbols.raw 7.6 (Berkeley) 5/8/91 -# -# PATCHES MAGIC LEVEL PATCH THAT GOT US HERE -# -------------------- ----- ---------------------- -# CURRENT PATCH LEVEL: 1 00066 -# -------------------- ----- ---------------------- -# -# 28 Nov 1991 Warren Toomey Let symorder -t keep some needed -# symbols used by common programs -# - - -#gdb -# ??? _IdlePTD -# ??? _PTD - _curpcb - _kstack - _panicstr -# ??? _atdevbase -# _version -#dmesg - _msgbufp -# _msgbuf -#iostat - _dk_busy - _dk_time - _dk_xfer - _dk_wds - _tk_nin - _tk_nout - _dk_seek - _cp_time - _dk_wpms -# _io_info -#ps - _nswap - _maxslp - _ccpu - _fscale - _avail_start - _avail_end -#pstat -# _cons - _nswap - _swapmap -#vmstat - _cp_time - _rate - _total - _sum -# _rectime -# _pgintime - _dk_xfer - _boottime -#w - _swapdev - _nswap - _averunnable - _boottime -#netstat - _mbstat - _ipstat - _tcb - _tcpstat - _udb - _udpstat - _rawcb - _Sysmap - _ifnet - _rthost - _rtnet - _icmpstat - _filehead - _nfiles - _rthashsize -#routed - _ifnet -#rwho - _boottime -#savecore - _dumpdev - _dumplo - _version - _time - _dumpsize - _panicstr - _dumpmag -#deprecated -# _avenrun diff --git a/sys/arch/mac68k/scsi/README b/sys/arch/mac68k/scsi/README deleted file mode 100644 index 2758346ea66b..000000000000 --- a/sys/arch/mac68k/scsi/README +++ /dev/null @@ -1,215 +0,0 @@ - * - * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE - * -------------------- ----- ---------------------- - * CURRENT PATCH LEVEL: 1 00098 - * -------------------- ----- ---------------------- - * - * 16 Feb 93 Julian Elischer ADDED for SCSI system -This release consists of the following files -(relative to the base of the kernel tree) - - -MAKEDEV - -scsi -scsi/README -scsi/scsiconf.h -scsi/scsiconf.c -scsi/scsi_all.h - -scsi/scsi_disk.h -scsi/sd.c - -sys/mtio.h (modified) -scsi/scsi_tape.h -scsi/st.c - -sys/sgio.h -scsi/scsi_generic.h -scsi/sg.c /* port not complete */ - -sys/chio.h -scsi/scsi_changer.h -scsi/ch.c - -sys/cdio.h -scsi/scsi_cd.h -scsi/cd.c - -i386/conf/SCSITEST -i386/isa/aha1542.c - -README.AHA1742 -i386/conf/AHBTEST -i386/isa/aha1742.c - -i386/conf/UHATEST -i386/isa/ultra14f.c - -i386/conf/BTTEST -i386/isa/bt742a.c - - - ----------------------------------------------------------------- -This scsi system is designed to allow the re-use of top end drivers -such as disk and tape drivers, with different scsi adapters. - -As of writing this document, There are top end drivers working for: ----------------------------------------------------------------- -generic scsi disk -generic scsi tape -cd-rom (plays music under the xcplayer (?) program) -AEG Character recognition devices * -Calera Character recognition devices * -Kodak IL900 scanner * -Exabyte tape changer device. -GENERIC SCSI DEVICES (user generated scsi commands) (port not complete) ----------------------------------------------------------------- - - -There are also working bottom end drivers for: ----------------------------------------------------------------- -adaptec 1542 (and 1742 in 1542 mode) -bustec 742a (apparently works for VESA version) -adaptec 174x -Ultrastore 14f (works for 34f (VESA version)) ----------------------------------------------------------------- - - -Work is proceeding on the following bottom end drivers: ----------------------------------------------------------------- -Future Domain (1680)** hosler@tfs.com & me -Future Domain (8 bit)**** rpr@oce.nl -WD7000** terry@icarus.weber.edu -seagate st01/st02**** overby@aspen.cray.com ? ----------------------------------------------------------------- -* drivers not made public (proprietary.. proof that the concept works though) -** driver not yet released but working. -*** just a dream so far. -**** some amount more than just a dream so far. - - -################## Using the scsi system ################## -------------minor numbers--------------- -This scsi system does not allocate minor numbers to devices depending -on their SCSI IDs is any way. A devices minor number is dependant -on the order in which it was found. -e.g. the first tape found will become st0 (minor number 0) - the second found will become st1 (minor number 16) - the third will become st2 (minor 32) - etc. - -These devices could be on the same scsi bus or different scsi busses. -That would not change their minor numbers. - -THE EXCEPTION TO THIS IS IN THE GENERIC SCSI DRIVER. in which case -the following mapping applies: - -BB LLL TTT B= scsi bus number, T = target number, L = LUN. -(yes I know it's strange but it's SGI compatible) - -It is possible to run two different TYPES of scsi adapters at the -same time and have st0 on one and st1 on another. (for example) - -There is a scheme supported in which scsi devices can be 'wired in' even -if they are not present or powered on at probe time. (see scsiconf.c) - ---------------getting started------------ -It should be possible to use the /dev entries for as0 as if they were -/dev entries for sd0 and the old as bootblocks should -continue to work if you are using an adaptec 1542b. - ---------------making devices------------ -A changed version of /dev/MAKEDEV is supplied that -can be used to make devices sd[01234] and st[01234] - -e.g. -cd /dev -sh MAKEDEV sd0 sd1 sd2 st0 st1 cd0 - - -The tape devices are as follows: -rst0 basic raw device, will rewind on close -nrst0 will not rewind on close -erst0 will rewind and EJECTon close -nerst0 will not rewind and WILL eject (some devices may rewind anyhow) - -------------future enhancements-------------- -Some people have indicated that they would like to have the SCSI ID -encoded into the minor number in some way, and -this may be supported at some timein the future, using -minor numbers greater than 128. (or maybe a different major number) - - -I will also be writing (probably) a generic scsi-error -handling routine that will be table driven, so that the routine can -be removed from each individual driver. With enough care, -two similar devices with different error codes (quite common) could run -the same driver but use different error tables. - ---------------file layout------------------- -Originally I had all scsi definitions in one file: scsi.h -I have since moved definitions of commands so that all -definitions needed for a particular type of device are -found together in the include file of that name. -This approximatly follows the layout of their definition -in the SCSI-2 spec. -As such they are: - -scsi_all.h general commands for all devices --- CHAPTER 7 -scsi-disk.h commands relevant to disk --- CHAPTER 8 -scsi-tape.h commands for scsi tapes --- CHAPTER 9 -scsi-cd.h commands for cd-roms (and audio) --- CHAPTER 13 -scsi-changer.h commands medium changer devices --- CHAPTER 16 - ----------ioctl definitions------------- -User accessable structures (e.g. ioctl definitions) have been -placed in sys/cdio, sys/sgio and sys/chio (based after sys/mtio for -the ioctls for mag tapes (including st). - ------------cd-rom----------------- -The cd rom driver ha been tested by a number of people and -grefen@wilbur.zdv.uni-mainz.de has completed the audio play -functions. -(xcdplayer was available from the 'from_ref' directory on agate) - -At this time it is possible audio play is broken on cdroms and I will -be unable to fix it until I get one to test. - --------------media changer--------------- -Once again courtesy of grefen@wilbur.zdv.uni-mainz.de. -I have not tested this but he assures me it's ready for testing. -If anyone has an exabyte tape changer or similar, -contact the author for information regarding the control interface -and program. - -WARNING: This has not been tested for a LONG TIME! - ------------booting from an AHA-174x--------- -For some reason I have not yet worked out, -the BIOS-based bootblocks I have posted will not boot -from the aha1742 in extended mode. (it can't be serious -because the MACH version works) This is in fact not a -problem because the aha1742 driver will force the board into extended -mode during probe, so it can be left in standard mode during the boot. -During the next reboot, the bios will place it back in standard mode -ready for the NEXT boot. - -[Update: This has apparently been fixed in the newest NetBSD/FreeBSD -releases ] - - - ----------recent changes----------- -Removed all bitfields from machine independent sections to make -it possible for them to be used on big-endian architectures. - -Removed scsi specific timeouts in favour of system timeout handling. - -Many structures (getting more all the time) now dynamically allocated. - -Addition of code in the tape driver to recognise models of drive that -have particular problems so they can be handled specially. - -many bug-fixes and cleanups. diff --git a/sys/arch/mac68k/scsi/README.AHA1742 b/sys/arch/mac68k/scsi/README.AHA1742 deleted file mode 100644 index 3362f1f82bdb..000000000000 --- a/sys/arch/mac68k/scsi/README.AHA1742 +++ /dev/null @@ -1,24 +0,0 @@ - * - * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE - * -------------------- ----- ---------------------- - * CURRENT PATCH LEVEL: 1 00098 - * -------------------- ----- ---------------------- - * - * 16 Feb 93 Julian Elischer ADDED for SCSI system - -Just a note: -The new bootblocks do not work with the 1742 in extended mode: -They DO however love it in standard mode. - -The driver automatically switches the board to extended mode when -it finds it -so leave your 1742 board in standard mode and just boot with the new bootblocks. - -When unix starts the board will magically be in extended mode -and when it is rebooted the bios will take it back to standard mode again. - -Eventually I will fix the bootblocks, but this works just as well. - -julian - - diff --git a/sys/arch/mac68k/scsi/scsi_debug.h b/sys/arch/mac68k/scsi/scsi_debug.h deleted file mode 100644 index f4fcf8dbdfa7..000000000000 --- a/sys/arch/mac68k/scsi/scsi_debug.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: scsi_debug.h,v 1.3 1994/10/26 08:47:32 cgd Exp $ */ - -/*#define SCSIDEBUG 1*/ -/* - * Written by Julian Elischer (julian@tfs.com) - */ -#ifndef _SCSI_SCSI_DEBUG_H -#define _SCSI_SCSI_DEBUG_H 1 - -/* - * These are the new debug bits. (Sat Oct 2 12:46:46 WST 1993) - * the following DEBUG bits are defined to exist in the flags word of - * the scsi_link structure. - */ -#define SDEV_DB1 0x10 /* scsi commands, errors, data */ -#define SDEV_DB2 0x20 /* routine flow tracking */ -#define SDEV_DB3 0x40 /* internal to routine flows */ -#define SDEV_DB4 0x80 /* level 4 debugging for this dev */ - -/* target and LUN we want to debug */ -#define DEBUGTARG 9 /*9 = dissable*/ -#define DEBUGLUN 0 -#define DEBUGLEVEL (SDEV_DB1|SDEV_DB2) - -/* - * This is the usual debug macro for use with the above bits - */ -#ifdef SCSIDEBUG -#define SC_DEBUG(sc_link,Level,Printstuff) \ - if((sc_link)->flags & (Level)) \ - { \ - printf("%s%d(%s%d:%d:%d): ", \ - sc_link->device->name, \ - sc_link->dev_unit, \ - sc_link->adapter->name, \ - sc_link->scsibus, \ - sc_link->target, \ - sc_link->lun); \ - printf Printstuff; \ - } -#define SC_DEBUGN(sc_link,Level,Printstuff) \ - if((sc_link)->flags & (Level)) \ - { \ - printf Printstuff; \ - } -#else -#define SC_DEBUG(A,B,C) /* not included */ -#define SC_DEBUGN(A,B,C) /* not included */ -#endif - -#endif /*_SCSI_SCSI_DEBUG_H*/ -/* END OF FILE */ - diff --git a/sys/arch/mac68k/scsi/scsi_disk.h b/sys/arch/mac68k/scsi/scsi_disk.h deleted file mode 100644 index 33c8b7826a8f..000000000000 --- a/sys/arch/mac68k/scsi/scsi_disk.h +++ /dev/null @@ -1,216 +0,0 @@ -/* $NetBSD: scsi_disk.h,v 1.4 1994/10/26 08:47:33 cgd Exp $ */ - -/* - * SCSI interface description - */ - -/* - * Some lines of this file come from a file of the name "scsi.h" - * distributed by OSF as part of mach2.5, - * so the following disclaimer has been kept. - * - * Copyright 1990 by Open Software Foundation, - * Grenoble, FRANCE - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation, and that the name of OSF or Open Software - * Foundation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * Largely written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - */ - -/* - * SCSI command format - */ - -#ifndef _SCSI_SCSI_DISK_H -#define _SCSI_SCSI_DISK_H 1 - -struct scsi_reassign_blocks -{ - u_char op_code; - u_char byte2; - u_char unused[3]; - u_char control; -}; - -struct scsi_rw -{ - u_char op_code; - u_char addr_2; /* Most significant */ -#define SRW_TOPADDR 0x1F /* only 5 bits here */ - u_char addr_1; - u_char addr_0; /* least significant */ - u_char length; - u_char control; -}; - -struct scsi_rw_big -{ - u_char op_code; - u_char byte2; -#define SRWB_RELADDR 0x01 - u_char addr_3; /* Most significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* least significant */ - u_char reserved;; - u_char length2; - u_char length1; - u_char control; -}; - -struct scsi_read_capacity -{ - u_char op_code; - u_char byte2; - u_char addr_3; /* Most Significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least Significant */ - u_char unused[3]; - u_char control; -}; - -struct scsi_start_stop -{ - u_char op_code; - u_char byte2; - u_char unused[2]; - u_char how; -#define SSS_START 0x01 -#define SSS_LOEJ 0x02 - u_char control; -}; - - - -/* - * Opcodes - */ - -#define REASSIGN_BLOCKS 0x07 -#define READ_COMMAND 0x08 -#define WRITE_COMMAND 0x0a -#define MODE_SELECT 0x15 -#define MODE_SENSE 0x1a -#define START_STOP 0x1b -#define PREVENT_ALLOW 0x1e -#define READ_CAPACITY 0x25 -#define READ_BIG 0x28 -#define WRITE_BIG 0x2a - - - -struct scsi_read_cap_data -{ - u_char addr_3; /* Most significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least significant */ - u_char length_3; /* Most significant */ - u_char length_2; - u_char length_1; - u_char length_0; /* Least significant */ -}; - -struct scsi_reassign_blocks_data -{ - u_char reserved[2]; - u_char length_msb; - u_char length_lsb; - struct - { - u_char dlbaddr_3; /* defect logical block address (MSB) */ - u_char dlbaddr_2; - u_char dlbaddr_1; - u_char dlbaddr_0; /* defect logical block address (LSB) */ - } defect_descriptor[1]; -}; - -union disk_pages /* this is the structure copied from osf */ -{ - struct page_disk_format { - u_char pg_code; /* page code (should be 3) */ -#define DISK_PGCODE 0x3F /* only 6 bits valid */ - u_char pg_length; /* page length (should be 0x16) */ - u_char trk_z_1; /* tracks per zone (MSB) */ - u_char trk_z_0; /* tracks per zone (LSB) */ - u_char alt_sec_1; /* alternate sectors per zone (MSB) */ - u_char alt_sec_0; /* alternate sectors per zone (LSB) */ - u_char alt_trk_z_1; /* alternate tracks per zone (MSB) */ - u_char alt_trk_z_0; /* alternate tracks per zone (LSB) */ - u_char alt_trk_v_1; /* alternate tracks per volume (MSB) */ - u_char alt_trk_v_0; /* alternate tracks per volume (LSB) */ - u_char ph_sec_t_1; /* physical sectors per track (MSB) */ - u_char ph_sec_t_0; /* physical sectors per track (LSB) */ - u_char bytes_s_1; /* bytes per sector (MSB) */ - u_char bytes_s_0; /* bytes per sector (LSB) */ - u_char interleave_1;/* interleave (MSB) */ - u_char interleave_0;/* interleave (LSB) */ - u_char trk_skew_1; /* track skew factor (MSB) */ - u_char trk_skew_0; /* track skew factor (LSB) */ - u_char cyl_skew_1; /* cylinder skew (MSB) */ - u_char cyl_skew_0; /* cylinder skew (LSB) */ - u_char flags; /* various */ -#define DISK_FMT_SURF 0x10 -#define DISK_FMT_RMB 0x20 -#define DISK_FMT_HSEC 0x40 -#define DISK_FMT_SSEC 0x80 - u_char reserved2; - u_char reserved3; - } disk_format; - struct page_rigid_geometry { - u_char pg_code; /* page code (should be 4) */ - u_char pg_length; /* page length (should be 0x16) */ - u_char ncyl_2; /* number of cylinders (MSB) */ - u_char ncyl_1; /* number of cylinders */ - u_char ncyl_0; /* number of cylinders (LSB) */ - u_char nheads; /* number of heads */ - u_char st_cyl_wp_2; /* starting cyl., write precomp (MSB) */ - u_char st_cyl_wp_1; /* starting cyl., write precomp */ - u_char st_cyl_wp_0; /* starting cyl., write precomp (LSB) */ - u_char st_cyl_rwc_2;/* starting cyl., red. write cur (MSB)*/ - u_char st_cyl_rwc_1;/* starting cyl., red. write cur */ - u_char st_cyl_rwc_0;/* starting cyl., red. write cur (LSB)*/ - u_char driv_step_1; /* drive step rate (MSB) */ - u_char driv_step_0; /* drive step rate (LSB) */ - u_char land_zone_2; /* landing zone cylinder (MSB) */ - u_char land_zone_1; /* landing zone cylinder */ - u_char land_zone_0; /* landing zone cylinder (LSB) */ - u_char reserved1; - u_char reserved2; - u_char reserved3; - } rigid_geometry; -} ; -#endif /* _SCSI_SCSI_DISK_H*/ diff --git a/sys/arch/mac68k/scsi/scsi_generic.h b/sys/arch/mac68k/scsi/scsi_generic.h deleted file mode 100644 index 338aa516fa44..000000000000 --- a/sys/arch/mac68k/scsi/scsi_generic.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef _SCSI_GENERIC_H_ -#define _SCSI_GENERIC_H_ - -/* - * Contributed by HD Associates (hd@world.std.com). - * Copyright (c) 1992, 1993 HD Associates - * - * Berkeley style copyright. I've just snarfed it out of stdio.h: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/* generic SCSI header file. We use the same minor number format - * as on SGI except that the flag bits aren't available because they - * are used as the board index. - * - * The minor number format is: - * FF UUU III (FFUU UIII) - * - * Where: - * FF is the board index - * UUU are the LUN - * III is the SCSI ID (controller) - */ - -#define G_SCSI_FLAG(DEV) (((DEV) & 0xC0) >> 6) -#define G_SCSI_UNIT(DEV) G_SCSI_FLAG(DEV) -#define G_SCSI_LUN(DEV) (((DEV) & 0x38) >> 3) -#define G_SCSI_ID(DEV) ((DEV) & 0x7) - -#define G_SCSI_MINOR(FLAG, LUN, ID) \ - (((FLAG) << 6) | ((LUN) << 3) | (ID)) - -#endif /* _SCSI_GENERIC_H_ */ diff --git a/sys/arch/mac68k/scsi/scsi_ioctl.c b/sys/arch/mac68k/scsi/scsi_ioctl.c deleted file mode 100644 index 2107c9b5858e..000000000000 --- a/sys/arch/mac68k/scsi/scsi_ioctl.c +++ /dev/null @@ -1,335 +0,0 @@ -/* $NetBSD: scsi_ioctl.c,v 1.5 1994/10/26 08:47:34 cgd Exp $ */ - -/* - * Contributed by HD Associates (hd@world.std.com). - * Copyright (c) 1992, 1993 HD Associates - * - * Berkeley style copyright. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define b_screq b_driver1 /* XXX */ -#define b_sc_link b_driver2 /* XXX */ - -/* - * We let the user interpret his own sense in the generic scsi world. - * This routine is called at interrupt time if the SCSI_USER bit was set - * in the flags passed to scsi_scsi_cmd(). No other completion processing - * takes place, even if we are running over another device driver. - * The lower level routines that call us here, will free the xs and restart - * the device's queue if such exists. - */ -#ifndef min -#define min(A,B) ((Abp; - if (!bp) { /* ALL user requests must have a buf */ - sc_print_addr(xs->sc_link); - printf("User command with no buf\n"); - return; - } - screq = bp->b_screq; - if (!screq) { /* Is it one of ours? (the SCSI_USER bit says it is) */ - sc_print_addr(xs->sc_link); - printf("User command with no request\n"); - return; - } - - SC_DEBUG(xs->sc_link, SDEV_DB2, ("user-done\n")); - screq->retsts = 0; - screq->status = xs->status; - switch(xs->error) { - case XS_NOERROR: - SC_DEBUG(xs->sc_link, SDEV_DB3, ("no error\n")); - screq->datalen_used = xs->datalen - xs->resid; /* probably rubbish */ - screq->retsts = SCCMD_OK; - break; - - case XS_SENSE: - SC_DEBUG(xs->sc_link, SDEV_DB3, ("have sense\n")); - screq->senselen_used = min(sizeof(xs->sense), SENSEBUFLEN); - bcopy(&xs->sense, screq->sense, screq->senselen); - screq->retsts = SCCMD_SENSE; - break; - - case XS_DRIVER_STUFFUP: - sc_print_addr(xs->sc_link); - printf("host adapter code inconsistency\n"); - screq->retsts = SCCMD_UNKNOWN; - break; - - case XS_TIMEOUT: - SC_DEBUG(xs->sc_link, SDEV_DB3, ("timeout\n")); - screq->retsts = SCCMD_TIMEOUT; - break; - - case XS_BUSY: - SC_DEBUG(xs->sc_link, SDEV_DB3, ("busy\n")); - screq->retsts = SCCMD_BUSY; - break; - - default: - sc_print_addr(xs->sc_link); - printf("unknown error category from host adapter code\n"); - screq->retsts = SCCMD_UNKNOWN; - break; - } - biodone(bp); /* we're waiting on it in scsi_strategy() */ - return; /* it'll free the xs and restart any queue */ -#endif -} - - -/* Pseudo strategy function - * Called by scsi_do_ioctl() via physio/physstrat if there is to - * be data transfered, and directly if there is no data transfer. - * - * Should I reorganize this so it returns to physio instead - * of sleeping in scsiio_scsi_cmd? Is there any advantage, other - * than avoiding the probable duplicate wakeup in iodone? [PD] - * - * No, seems ok to me... [JRE] - * (I don't see any duplicate wakeups) - * - * Can't be used with block devices or raw_read/raw_write directly - * from the cdevsw/bdevsw tables because they couldn't have added - * the screq structure. [JRE] - */ -void scsistrategy(struct buf *bp) -{ -#ifdef notyet - int err; - struct scsi_link *sc_link = bp->b_sc_link; - scsireq_t *screq; - u_int32 flags = 0; - int s; - - if (!sc_link) { - printf("user_strat: No link pointer\n"); - scsierr(bp, EINVAL); - return; - } - SC_DEBUG(sc_link, SDEV_DB2, ("user_strategy\n")); - screq = bp->b_screq; - if (!screq) { - sc_print_addr(sc_link); - printf("No request block\n"); - scsierr(bp, EINVAL); - return; - } - - /* We're in trouble if physio tried to break up the - * transfer: - */ - if (bp->b_bcount != screq->datalen) { - sc_print_addr(sc_link); - printf("physio split the request.. cannot proceed\n"); - scsierr(bp, EIO); - return; - } - - if (screq->timeout == 0) { - scsierr(bp, EINVAL); - return; - } - - if (screq->cmdlen > sizeof(struct scsi_generic)) { - sc_print_addr(sc_link); - printf("cmdlen too big "); - scsierr(bp, EFAULT); - return; - } - - if (screq->flags & SCCMD_READ) - flags |= SCSI_DATA_IN; - - if (screq->flags & SCCMD_WRITE) - flags |= SCSI_DATA_OUT; - - if (screq->flags & SCCMD_TARGET) - flags |= SCSI_TARGET; - - if (screq->flags & SCCMD_ESCAPE) - flags |= SCSI_ESCAPE; - - err = scsi_scsi_cmd(sc_link, - (struct scsi_generic *)screq->cmd, - screq->cmdlen, - (u_char *)bp->b_un.b_addr, - screq->datalen, - 0, /* user must do the retries *//* ignored */ - screq->timeout, - bp, - flags | SCSI_USER); - - /* because there is a bp, scsi_scsi_cmd will return immediatly */ - if (err) { - scsierr(bp, err); - return; - } - SC_DEBUG(sc_link, SDEV_DB3, ("about to sleep\n")); - s = splbio(); - while (!(bp->b_flags & B_DONE)) - tsleep(bp, PRIBIO, "scistr", 0); - splx(s); - SC_DEBUG(sc_link, SDEV_DB3, ("back from sleep\n")); - return; -#endif -} - -void scsiminphys(struct buf *bp) -{ - /*XXX*//* call the adapter's minphys */ -} - - -/* - * Something (e.g. another driver) has called us - * with an sc_link for a target/lun/adapter, and a scsi - * specific ioctl to perform, better try. - * If user-level type command, we must still be running - * in the context of the calling process - */ -int -scsi_do_ioctl(struct scsi_link *sc_link, int cmd, caddr_t addr, int f) -{ - int error = 0; - int phys; - - SC_DEBUG(sc_link, SDEV_DB2, ("scsi_do_ioctl(0x%x)\n", cmd)); - switch(cmd) { -#ifndef __NetBSD__ - case SCIOCCOMMAND: - { - /* - * You won't believe this, but the arg copied in - * from the user space, is on the kernel stack - * for this process, so we can't write - * to it at interrupt time.. - * we need to copy it in and out! - * Make a static copy using malloc! - */ - scsireq_t *screq2 = (scsireq_t *)addr; - scsireq_t *screq = (scsireq_t *)addr; - int rwflag = (screq->flags & SCCMD_READ) ? B_READ : B_WRITE; - struct buf *bp; - caddr_t d_addr; - int len; - - if ((unsigned int)screq < KERNBASE) { - screq = malloc(sizeof(scsireq_t), - M_TEMP, M_WAITOK); - bcopy(screq2, screq, sizeof(scsireq_t)); - } - bp = malloc(sizeof (struct buf), M_TEMP, M_WAITOK); - bzero(bp, sizeof(struct buf)); - d_addr = screq->databuf; - bp->b_bcount = len = screq->datalen; - bp->b_screq = screq; - bp->b_sc_link = sc_link; - if (len) { - /* have data, translate it. (physio)*/ -#ifdef __NetBSD__ -#error "dev, mincntfn & uio need defining" - error = physio(scsistrategy, bp, dev, rwflag, - mincntfn, uio); -#else - error = physio(scsistrategy, 0, bp, 0, rwflag, - d_addr, &len, curproc); -#endif - } else { - /* if no data, no need to translate it.. */ - bp->b_un.b_addr = 0; - bp->b_dev = -1; /* irrelevant info */ - bp->b_flags = 0; - - scsistrategy(bp); - error = bp->b_error; - } - free(bp, M_TEMP); - if ((unsigned int)screq2 < KERNBASE) { - bcopy(screq, screq2, sizeof(scsireq_t)); - free(screq, M_TEMP); - } - break; - } -#endif /* !NetBSD */ - case SCIOCDEBUG: - { - int level = *((int *)addr); - SC_DEBUG(sc_link, SDEV_DB3, ("debug set to %d\n", level)); - sc_link->flags &= ~SDEV_DBX; /*clear debug bits */ - if (level & 1) - sc_link->flags |= SDEV_DB1; - if (level & 2) - sc_link->flags |= SDEV_DB2; - if (level & 4) - sc_link->flags |= SDEV_DB3; - if (level & 8) - sc_link->flags |= SDEV_DB4; - error = 0; - break; - } - case SCIOCREPROBE: - { - extern int scsibus; - struct scsi_addr *sca = (struct scsi_addr *) addr; - - error = scsi_probe_busses(sca->scbus, sca->target, sca->lun); - break; - } - case SCIOCRECONFIG: - case SCIOCDECONFIG: - error = EINVAL; - break; - case SCIOCIDENTIFY: - { - struct scsi_addr *sca = (struct scsi_addr *) addr; - sca->scbus = sc_link->scsibus; - sca->target = sc_link->target; - sca->lun = sc_link->lun; - break; - } - - default: - error = ENOTTY; - break; - } - - return error; -} - -void -scsierr(bp, error) - struct buf *bp; - int error; -{ - - bp->b_flags |= B_ERROR; - bp->b_error = error; - biodone(bp); - return; -} - diff --git a/sys/arch/mac68k/scsi/scsi_tape.h b/sys/arch/mac68k/scsi/scsi_tape.h deleted file mode 100644 index 6e8d3965b2a2..000000000000 --- a/sys/arch/mac68k/scsi/scsi_tape.h +++ /dev/null @@ -1,204 +0,0 @@ -/* $NetBSD: scsi_tape.h,v 1.4 1994/10/26 08:47:35 cgd Exp $ */ - -/* - * SCSI tape interface description - */ - -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - */ - -/* - * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - */ -#ifndef SCSI_SCSI_TAPE_H -#define SCSI_SCSI_TAPE_H 1 - - - -/* - * SCSI command formats - */ - - -struct scsi_rw_tape -{ - u_char op_code; - u_char byte2; -#define SRWT_FIXED 0x01 - u_char len[3]; - u_char control; -} rw_tape; - -struct scsi_space -{ - u_char op_code; - u_char byte2; -#define SS_CODE 0x03 - u_char number[3]; - u_char control; -} space; -#define SP_BLKS 0 -#define SP_FILEMARKS 1 -#define SP_SEQ_FILEMARKS 2 -#define SP_EOM 3 - -struct scsi_write_filemarks -{ - u_char op_code; - u_char byte2; - u_char number[3]; - u_char control; -} write_filemarks; - -struct scsi_rewind -{ - u_char op_code; - u_char byte2; -#define SR_IMMED 0x01 - u_char unused[3]; - u_char control; -} rewind; - -struct scsi_load -{ - u_char op_code; - u_char byte2; -#define SL_IMMED 0x01 - u_char unused[2]; - u_char how; - u_char control; -} load; -#define LD_UNLOAD 0 -#define LD_LOAD 1 -#define LD_RETEN 2 - - -struct scsi_blk_limits -{ - u_char op_code; - u_char byte2; - u_char unused[3]; - u_char control; -} blk_limits; - -/* - * Opcodes - */ - -#define REWIND 0x01 -#define READ_BLK_LIMITS 0x05 -#define READ_COMMAND_TAPE 0x08 -#define WRITE_COMMAND_TAPE 0x0a -#define WRITE_FILEMARKS 0x10 -#define SPACE 0x11 -#define LOAD_UNLOAD 0x1b /* same as above */ - - - -struct scsi_blk_limits_data -{ - u_char reserved; - u_char max_length_2; /* Most significant */ - u_char max_length_1; - u_char max_length_0; /* Least significant */ - u_char min_length_1; /* Most significant */ - u_char min_length_0; /* Least significant */ -}; - -/* defines for the device specific byte in the mode select/sense header */ -#define SMH_DSP_SPEED 0x0F -#define SMH_DSP_BUFF_MODE 0x70 -#define SMH_DSP_BUFF_MODE_OFF 0x00 -#define SMH_DSP_BUFF_MODE_ON 0x10 -#define SMH_DSP_BUFF_MODE_MLTI 0x20 -#define SMH_DSP_WRITE_PROT 0x80 - -/* A special for the CIPHER ST150S(old drive) */ -struct blk_desc_cipher -{ - u_char density; - u_char nblocks[3]; - u_char reserved; - u_char blklen[3]; - u_char other; -#define ST150_SEC 0x01 /* soft error count */ -#define SR150_AUI 0x02 /* autoload inhibit */ -}; - - - -/********************************************************************** - from the scsi2 spec - Value Tracks Density(bpi) Code Type Reference Note - 0x1 9 800 NRZI R X3.22-1983 2 - 0x2 9 1600 PE R X3.39-1986 2 - 0x3 9 6250 GCR R X3.54-1986 2 - 0x5 4/9 8000 GCR C X3.136-1986 1 - 0x6 9 3200 PE R X3.157-1987 2 - 0x7 4 6400 IMFM C X3.116-1986 1 - 0x8 4 8000 GCR CS X3.158-1986 1 - 0x9 18 37871 GCR C X3B5/87-099 2 - 0xA 22 6667 MFM C X3B5/86-199 1 - 0xB 4 1600 PE C X3.56-1986 1 - 0xC 24 12690 GCR C HI-TC1 1,5 - 0xD 24 25380 GCR C HI-TC2 1,5 - 0xF 15 10000 GCR C QIC-120 1,5 - 0x10 18 10000 GCR C QIC-150 1,5 - 0x11 26 16000 GCR C QIC-320(525?) 1,5 - 0x12 30 51667 RLL C QIC-1350 1,5 - 0x13 1 61000 DDS CS X3B5/88-185A 4 - 0x14 1 43245 RLL CS X3.202-1991 4 - 0x15 1 45434 RLL CS ECMA TC17 4 - 0x16 48 10000 MFM C X3.193-1990 1 - 0x17 48 42500 MFM C X3B5/91-174 1 - - where Code means: - NRZI Non Return to Zero, change on ones - GCR Group Code Recording - PE Phase Encoded - IMFM Inverted Modified Frequency Modulation - MFM Modified Frequency Modulation - DDS Dat Data Storage - RLL Run Length Encoding - - where Type means: - R Real-to-Real - C Cartridge - CS cassette - - where Notes means: - 1 Serial Recorded - 2 Parallel Recorded - 3 Old format know as QIC-11 - 4 Helical Scan - 5 Not ANSI standard, rather industry standard. - -********************************************************************/ - -#define HALFINCH_800 0x01 -#define HALFINCH_1600 0x02 -#define HALFINCH_6250 0x03 -#define QIC_11 0x04 /* from Archive 150S Theory of Op. XXX */ -#define QIC_24 0x05 /* may be bad, works for CIPHER ST150S XXX */ -#define QIC_120 0x0f -#define QIC_150 0x10 -#define QIC_320 0x11 -#define QIC_525 0x11 -#define QIC_1320 0x12 -#define DDS 0x13 -#define DAT_1 0x13 - -#endif /*SCSI_SCSI_TAPE_H*/ diff --git a/sys/arch/mac68k/scsi/scsiconf.c b/sys/arch/mac68k/scsi/scsiconf.c deleted file mode 100644 index 9b2d7d6a5df0..000000000000 --- a/sys/arch/mac68k/scsi/scsiconf.c +++ /dev/null @@ -1,581 +0,0 @@ -/* $NetBSD: scsiconf.c,v 1.5 1994/10/26 08:47:37 cgd Exp $ */ - -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - */ - -#include -#include -#include -#include -#include - -#include "st.h" -#include "sd.h" -#include "ch.h" -#include "cd.h" -#include "uk.h" -#include "su.h" - -#include -#include - -#ifdef TFS -#include "bll.h" -#include "cals.h" -#include "kil.h" -#include "scan.h" -#else /* TFS */ -#define NBLL 0 -#define NCALS 0 -#define NKIL 0 -#define NSCAN 0 -#endif /* TFS */ - -/* - * The structure of known drivers for autoconfiguration - */ -struct scsidevs { - char *devname; - u_int32 type; - boolean removable; - char flags; /* 1 show my comparisons during boot(debug) */ - char *manufacturer; - char *model; - char *version; -}; - -#define SC_SHOWME 0x01 -#define SC_ONE_LU 0x00 -#define SC_MORE_LUS 0x02 - -#if NUK > 0 -static struct scsidevs unknowndev = { - "uk", -1, 0, SC_MORE_LUS, - "standard", "any", "any" -}; -#endif /*NUK*/ - -static struct scsidevs knowndevs[] = { -#if NSD > 0 - { "sd", T_DIRECT, T_FIXED, SC_ONE_LU, - "standard", "any", "any" }, - { "sd", T_DIRECT, T_FIXED, SC_ONE_LU, - "MAXTOR ", "XT-4170S ", "B5A " }, -#endif /* NSD */ -#if NST > 0 - { "st", T_SEQUENTIAL, T_REMOV, SC_ONE_LU, - "standard", "any", "any" }, -#endif /* NST */ -#if NCALS > 0 - { "cals", T_PROCESSOR, T_FIXED, SC_MORE_LUS, - "standard", "any", "any" }, -#endif /* NCALS */ -#if NCH > 0 - { "ch", T_CHANGER, T_REMOV, SC_ONE_LU, - "standard", "any", "any" }, -#endif /* NCH */ -#if NCD > 0 -#ifndef UKTEST /* make cdroms unrecognised to test the uk driver */ - { "cd", T_READONLY, T_REMOV, SC_ONE_LU, - "SONY ", "CD-ROM CDU-8012 ", "3.1a" }, - { "cd", T_READONLY, T_REMOV, SC_MORE_LUS, - "PIONEER ", "CD-ROM DRM-600 ", "any" }, -#endif -#endif /* NCD */ -#if NBLL > 0 - { "bll", T_PROCESSOR, T_FIXED, SC_MORE_LUS, - "AEG ", "READER ", "V1.0" }, -#endif /* NBLL */ -#if NKIL > 0 - { "kil", T_SCANNER, T_FIXED, SC_ONE_LU, - "KODAK ", "IL Scanner 900 ", "any" }, -#endif /* NKIL */ - { 0 } -}; - -/* - * Declarations - */ -struct scsidevs *scsi_probedev(); -struct scsidevs *selectdev(); -int scsi_probe_bus __P((int bus, int targ, int lun)); - -struct scsi_device probe_switch = -{ - NULL, - NULL, - NULL, - NULL, - "probe", - 0, -}; - -int scsibusmatch __P((struct device *, struct cfdata *, void *)); -void scsibusattach __P((struct device *, struct device *, void *)); - -struct cfdriver scsibuscd = -{ - NULL, - "scsibus", - scsibusmatch, - scsibusattach, - DV_DULL, - sizeof(struct scsibus_data) -}; - -int -scsibusmatch(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; -{ - - return 1; -} - -/* - * The routine called by the adapter boards to get all their - * devices configured in. - */ -void -scsibusattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct scsibus_data *sb = (struct scsibus_data *)self; - struct scsi_link *sc_link_proto = aux; - - sc_link_proto->scsibus = sb->sc_dev.dv_unit; - sb->adapter_link = sc_link_proto; - printf("\n"); - -#if defined(SCSI_DELAY) && SCSI_DELAY > 2 - printf("%s: waiting for scsi devices to settle\n", - sb->sc_dev.dv_xname); -#else /* SCSI_DELAY > 2 */ -#undef SCSI_DELAY -#define SCSI_DELAY 2 -#endif /* SCSI_DELAY */ - DELAY(10 * SCSI_DELAY); - - scsi_probe_bus(sb->sc_dev.dv_unit, -1, -1); -} - -/* - * Probe the requested scsi bus. It must be already set up. - * -1 requests all set up scsi busses. - * targ and lun optionally narrow the search if not -1 - */ -int -scsi_probe_busses(bus, targ, lun) - int bus, targ, lun; -{ - - if (bus == -1) { - for (bus = 0; bus < scsibuscd.cd_ndevs; bus++) - if (scsibuscd.cd_devs[bus]) - scsi_probe_bus(bus, targ, lun); - return 0; - } else { - return scsi_probe_bus(bus, targ, lun); - } -} - -/* - * Probe the requested scsi bus. It must be already set up. - * targ and lun optionally narrow the search if not -1 - */ -int -scsi_probe_bus(bus, targ, lun) - int bus, targ, lun; -{ - struct scsibus_data *scsi; - int maxtarg, mintarg, maxlun, minlun; - struct scsi_link *sc_link_proto; - u_int8 scsi_addr ; - struct scsidevs *bestmatch = NULL; - struct scsi_link *sc_link = NULL; - boolean maybe_more; - - if (bus < 0 || bus >= scsibuscd.cd_ndevs) - return ENXIO; - scsi = scsibuscd.cd_devs[bus]; - if (!scsi) - return ENXIO; - -printf("scsibus: probing bus %d.\n", bus); - sc_link_proto = scsi->adapter_link; - scsi_addr = sc_link_proto->adapter_targ; - - if (targ == -1) { - maxtarg = 7; - mintarg = 0; - } else { - if (targ < 0 || targ > 7) - return EINVAL; - maxtarg = mintarg = targ; - } - - if (lun == -1) { - maxlun = 7; - minlun = 0; - } else { - if (lun < 0 || lun > 7) - return EINVAL; - maxlun = minlun = lun; - } - - for (targ = mintarg; targ <= maxtarg; targ++) { - maybe_more = 0; /* by default only check 1 lun */ -#if 0 /* XXXX */ - if (targ == scsi_addr) - continue; -#endif - for (lun = minlun; lun <= maxlun; lun++) { - /* - * The spot appears to already have something - * linked in, skip past it. Must be doing a 'reprobe' - */ - if (scsi->sc_link[targ][lun]) { - /* don't do this one, but check other luns */ - maybe_more = 1; - continue; - } - /* - * If we presently don't have a link block - * then allocate one to use while probing - */ - if (!sc_link) { - sc_link = malloc(sizeof(*sc_link), M_TEMP, M_NOWAIT); - *sc_link = *sc_link_proto; /* struct copy */ - sc_link->opennings = 1; - sc_link->device = &probe_switch; - } - sc_link->target = targ; - sc_link->lun = lun; - bestmatch = scsi_probedev(sc_link, &maybe_more); - /* - * We already know what the device is. We use a - * special matching routine which insists that the - * cfdata is of the right type rather than putting - * more intelligence in individual match routines for - * each high-level driver. We must have - * scsi_targmatch() do all of the comparisons, or we - * could get stuck in an infinite loop trying the same - * device repeatedly. We use the `fordriver' field of - * the scsi_link for now, rather than inventing a new - * structure just for the config_search(). - */ - if (bestmatch) { - sc_link->fordriver = bestmatch->devname; - if (config_found((struct device *)scsi, - sc_link, NULL)) { - scsi->sc_link[targ][lun] = sc_link; - sc_link = NULL; /* it's been used */ - } else - printf("No matching config entry.\n"); - } - if (!maybe_more)/* nothing suggests we'll find more */ - break; /* nothing here, skip to next targ */ - /* otherwise something says we should look further */ - } - } - if (sc_link) - free(sc_link, M_TEMP); - return 0; -} - -int -scsi_targmatch(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; -{ - struct scsi_link *sc_link = aux; - char *devname = sc_link->fordriver; - - if (strcmp(cf->cf_driver->cd_name, devname)) - return 0; - if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != sc_link->target) - return 0; - if (cf->cf_loc[1] != -1 && cf->cf_loc[1] != sc_link->lun) - return 0; - - return 1; -} - -/* - * given a target and lu, ask the device what - * it is, and find the correct driver table - * entry. - */ -struct scsidevs * -scsi_probedev(sc_link, maybe_more) - boolean *maybe_more; - struct scsi_link *sc_link; -{ - u_int8 target = sc_link->target; - u_int8 lun = sc_link->lun; - struct scsi_adapter *scsi_adapter = sc_link->adapter; - struct scsidevs *bestmatch = NULL; - char *dtype = NULL, *desc; - char *qtype; - static struct scsi_inquiry_data inqbuf; - u_int32 len, qualifier, type; - boolean remov; - char manu[32]; - char model[32]; - char version[32]; - - bzero(&inqbuf, sizeof(inqbuf)); - /* - * Ask the device what it is - */ -#ifdef SCSIDEBUG - if (target == DEBUGTARG && lun == DEBUGLUN) - sc_link->flags |= DEBUGLEVEL; - else - sc_link->flags &= ~(SDEV_DB1 | SDEV_DB2 | SDEV_DB3 | SDEV_DB4); -#endif /* SCSIDEBUG */ - /* catch unit attn */ - scsi_test_unit_ready(sc_link, SCSI_NOSLEEP | SCSI_NOMASK | SCSI_SILENT); -#ifdef DOUBTFULL - switch (scsi_test_unit_ready(sc_link, SCSI_NOSLEEP | SCSI_NOMASK | SCSI_SILENT)) { - case 0: /* said it WAS ready */ - case EBUSY: /* replied 'NOT READY' but WAS present, continue */ - case ENXIO: - break; - case EIO: /* device timed out */ - case EINVAL: /* Lun not supported */ - default: - return NULL; - - } -#endif /*DOUBTFULL*/ -#ifdef SCSI_2_DEF - /* some devices need to be told to go to SCSI2 */ - /* However some just explode if you tell them this.. leave it out */ - scsi_change_def(sc_link, SCSI_NOSLEEP | SCSI_NOMASK | SCSI_SILENT); -#endif /*SCSI_2_DEF */ - - /* Now go ask the device all about itself */ - if (scsi_inquire(sc_link, &inqbuf, SCSI_NOSLEEP | SCSI_NOMASK) != 0) - return NULL; - - /* - * note what BASIC type of device it is - */ - type = inqbuf.device & SID_TYPE; - qualifier = inqbuf.device & SID_QUAL; - remov = inqbuf.dev_qual2 & SID_REMOVABLE; - - /* - * Any device qualifier that has the top bit set (qualifier&4 != 0) - * is vendor specific and won't match in this switch. - */ - switch (qualifier) { - case SID_QUAL_LU_OK: - qtype = ""; - break; - - case SID_QUAL_LU_OFFLINE: - qtype = ", Unit not Connected!"; - break; - - case SID_QUAL_RSVD: - qtype = ", Reserved Peripheral Qualifier!"; - *maybe_more = 1; - return NULL; - break; - - case SID_QUAL_BAD_LU: - /* - * Check for a non-existent unit. If the device is returning - * this much, then we must set the flag that has - * the searchers keep looking on other luns. - */ - qtype = ", The Target can't support this Unit!"; - *maybe_more = 1; - return NULL; - - default: - dtype = "vendor specific"; - qtype = ""; - *maybe_more = 1; - break; - } - if (dtype == 0) { - switch (type) { - case T_DIRECT: - dtype = "direct"; - break; - case T_SEQUENTIAL: - dtype = "sequential"; - break; - case T_PRINTER: - dtype = "printer"; - break; - case T_PROCESSOR: - dtype = "processor"; - break; - case T_READONLY: - dtype = "readonly"; - break; - case T_WORM: - dtype = "worm"; - break; - case T_SCANNER: - dtype = "scanner"; - break; - case T_OPTICAL: - dtype = "optical"; - break; - case T_CHANGER: - dtype = "changer"; - break; - case T_COMM: - dtype = "communication"; - break; - case T_NODEVICE: - *maybe_more = 1; - return NULL; - default: - dtype = NULL; - break; - } - } - - /* - * Then if it's advanced enough, more detailed - * information - */ - if ((inqbuf.version & SID_ANSII) > 0) { - if ((len = inqbuf.additional_length - + ((char *) inqbuf.unused - - (char *) &inqbuf)) - > (sizeof(struct scsi_inquiry_data) - 1)) - len = sizeof(struct scsi_inquiry_data) - 1; - desc = inqbuf.vendor; - desc[len - (desc - (char *) &inqbuf)] = 0; - strncpy(manu, inqbuf.vendor, 8); - manu[8] = 0; - strncpy(model, inqbuf.product, 16); - model[16] = 0; - strncpy(version, inqbuf.revision, 4); - version[4] = 0; - } else - /* - * If not advanced enough, use default values - */ - { - desc = "early protocol device"; - strncpy(manu, "unknown", 8); - strncpy(model, "unknown", 16); - strncpy(version, "????", 4); - } - printf("%s targ %d lun %d: <%s%s%s> SCSI%d ", - ((struct device *)sc_link->adapter_softc)->dv_xname, - target, lun, manu, model, version, - inqbuf.version & SID_ANSII); - if (dtype) - printf("%s", dtype); - else - printf("type %d", type); - printf(" %s\n", remov ? "removable" : "fixed"); - if (qtype[0]) - printf("%s targ %d lun %d: qualifier %d(%s)\n", - ((struct device *)sc_link->adapter_softc)->dv_xname, - target, lun, qualifier, qtype); - - /* - * Try make as good a match as possible with - * available sub drivers - */ - bestmatch = selectdev(qualifier, type, remov ? T_REMOV : T_FIXED, - manu, model, version); - if (bestmatch && bestmatch->flags & SC_MORE_LUS) - *maybe_more = 1; - return bestmatch; -} - -/* - * Try make as good a match as possible with - * available sub drivers - */ -struct scsidevs * -selectdev(qualifier, type, remov, manu, model, rev) - u_int32 qualifier, type; - boolean remov; - char *manu, *model, *rev; -{ - u_int32 numents = (sizeof(knowndevs) / sizeof(struct scsidevs)) - 1; - u_int32 count = 0; - u_int32 bestmatches = 0; - struct scsidevs *bestmatch = (struct scsidevs *) 0; - struct scsidevs *thisentry = knowndevs; - - type |= qualifier; /* why? */ - - thisentry--; - while (count++ < numents) { - thisentry++; - if (type != thisentry->type) - continue; - if (bestmatches < 1) { - bestmatches = 1; - bestmatch = thisentry; - } - if (remov != thisentry->removable) - continue; - if (bestmatches < 2) { - bestmatches = 2; - bestmatch = thisentry; - } - if (thisentry->flags & SC_SHOWME) - printf("\n%s-\n%s-", thisentry->manufacturer, manu); - if (strcmp(thisentry->manufacturer, manu)) - continue; - if (bestmatches < 3) { - bestmatches = 3; - bestmatch = thisentry; - } - if (thisentry->flags & SC_SHOWME) - printf("\n%s-\n%s-", thisentry->model, model); - if (strcmp(thisentry->model, model)) - continue; - if (bestmatches < 4) { - bestmatches = 4; - bestmatch = thisentry; - } - if (thisentry->flags & SC_SHOWME) - printf("\n%s-\n%s-", thisentry->version, rev); - if (strcmp(thisentry->version, rev)) - continue; - if (bestmatches < 5) { - bestmatches = 5; - bestmatch = thisentry; - break; - } - } -#if NUK > 0 - if (!bestmatch) - bestmatch = &unknowndev; -#endif - if (!bestmatch) - printf("No matching driver.\n"); - return bestmatch; -} diff --git a/sys/arch/mac68k/scsi/scsiconf.h b/sys/arch/mac68k/scsi/scsiconf.h deleted file mode 100644 index ef517cd01d11..000000000000 --- a/sys/arch/mac68k/scsi/scsiconf.h +++ /dev/null @@ -1,251 +0,0 @@ -/* $NetBSD: scsiconf.h,v 1.5 1994/10/26 08:47:38 cgd Exp $ */ - -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - */ -#ifndef SCSI_SCSICONF_H -#define SCSI_SCSICONF_H 1 -typedef int boolean; -typedef long int int32; -typedef short int int16; -typedef char int8; -typedef unsigned long int u_int32; -typedef unsigned short int u_int16; -typedef unsigned char u_int8; - -#ifdef __NetBSD__ -#define DELAY delay -#endif - -#include -#include - -/* - * The following documentation tries to describe the relationship between the - * various structures defined in this file: - * - * each adapter type has a scsi_adapter struct. This describes the adapter and - * identifies routines that can be called to use the adapter. - * each device type has a scsi_device struct. This describes the device and - * identifies routines that can be called to use the device. - * each existing device position (scsibus + target + lun) - * can be described by a scsi_link struct. - * Only scsi positions that actually have devices, have a scsi_link - * structure assigned. so in effect each device has scsi_link struct. - * The scsi_link structure contains information identifying both the - * device driver and the adapter driver for that position on that scsi bus, - * and can be said to 'link' the two. - * each individual scsi bus has an array that points to all the scsi_link - * structs associated with that scsi bus. Slots with no device have - * a NULL pointer. - * each individual device also knows the address of it's own scsi_link - * structure. - * - * ------------- - * - * The key to all this is the scsi_link structure which associates all the - * other structures with each other in the correct configuration. The - * scsi_link is the connecting information that allows each part of the - * scsi system to find the associated other parts. - */ - - -/* - * These entrypoints are called by the high-end drivers to get services from - * whatever low-end drivers they are attached to each adapter type has one of - * these statically allocated. - */ -struct scsi_adapter -{ -/* 4*/ int (*scsi_cmd)(); -/* 8*/ void (*scsi_minphys)(); -/*12*/ int32 (*open_target_lu)(); -/*16*/ int32 (*close_target_lu)(); -/*20*/ u_int (*adapter_info)(); /* see definitions below */ -/*24*/ char *name; /* name of scsi bus controller */ -/*32*/ u_long spare[2]; -}; - -/* - * return values for scsi_cmd() - */ -#define SUCCESSFULLY_QUEUED 0 -#define TRY_AGAIN_LATER 1 -#define COMPLETE 2 -#define HAD_ERROR 3 /* do not use this, use COMPLETE */ -#define ESCAPE_NOT_SUPPORTED 4 - -/* - * Format of adapter_info() response data - * e.g. maximum number of entries queuable to a device by the adapter - */ -#define AD_INF_MAX_CMDS 0x000000FF -/* 24 bits of other adapter characteristics go here */ - -/* - * These entry points are called by the low-end drivers to get services from - * whatever high-end drivers they are attached to. Each device type has one - * of these statically allocated. - */ -struct scsi_device -{ -/* 4*/ int (*err_handler)(); /* returns -1 to say err processing complete */ -/* 8*/ void (*start)(); -/* 12*/ int32 (*async)(); -/* 16*/ int32 (*done)(); /* returns -1 to say done processing complete */ -/* 20*/ char *name; /* name of device type */ -/* 24*/ u_int32 flags; /* device type dependent flags */ -/* 32*/ int32 spare[2]; -}; - -/* - * This structure describes the connection between an adapter driver and - * a device driver, and is used by each to call services provided by - * the other, and to allow generic scsi glue code to call these services - * as well. - */ -struct scsi_link -{ -/* 1*/ u_int8 scsibus; /* the Nth scsibus */ -/* 2*/ u_int8 target; /* targ of this dev */ -/* 3*/ u_int8 lun; /* lun of this dev */ -/* 4*/ u_int8 adapter_targ; /* what are we on the scsi bus */ -/* 5*/ u_int8 dev_unit; /* e.g. the 0 in sd0 */ -/* 6*/ u_int8 opennings; /* available operations */ -/* 7*/ u_int8 active; /* operations in progress */ -/* 8*/ u_int8 sparea[1]; -/* 10*/ u_int16 flags; /* flags that all devices have */ -/* 12*/ u_int8 spareb[2]; -/* 16*/ struct scsi_adapter *adapter; /* adapter entry points etc. */ -/* 20*/ struct scsi_device *device; /* device entry points etc. */ -/* 24*/ struct scsi_xfer *active_xs; /* operations under way */ -/* 4*/ void *adapter_softc; /* e.g. the 0 in aha0 */ -/* 28*/ void *fordriver; /* for private use by the driver */ -}; -#define SDEV_MEDIA_LOADED 0x01 /* device figures are still valid */ -#define SDEV_WAITING 0x02 /* a process is waiting for this */ -#define SDEV_OPEN 0x04 /* at least 1 open session */ -#define SDEV_DBX 0xF0 /* debuging flags (scsi_debug.h) */ - -/* - * One of these is allocated and filled in for each scsi bus. - * it holds pointers to allow the scsi bus to get to the driver - * That is running each LUN on the bus - * it also has a template entry which is the prototype struct - * supplied by the adapter driver, this is used to initialise - * the others, before they have the rest of the fields filled in - */ -struct scsibus_data { - struct device sc_dev; - struct scsi_link *adapter_link; /* prototype supplied by adapter */ - struct scsi_link *sc_link[8][8]; -}; - -/* - * Each scsi transaction is fully described by one of these structures - * It includes information about the source of the command and also the - * device and adapter for which the command is destined. - * (via the scsi_link structure) - */ -struct scsi_xfer -{ -/* 4*/ struct scsi_xfer *next; /* when free */ -/* 8*/ u_int32 flags; -/*12*/ struct scsi_link *sc_link; /* all about our device and adapter */ -/*13*/ u_int8 retries; /* the number of times to retry */ -/*16*/ u_int8 spare[3]; -/*20*/ int32 timeout; /* in milliseconds */ -/*24*/ struct scsi_generic *cmd; /* The scsi command to execute */ -/*28*/ int32 cmdlen; /* how long it is */ -/*32*/ u_char *data; /* dma address OR a uio address */ -/*36*/ int32 datalen; /* data len (blank if uio) */ -/*40*/ int32 resid; /* how much buffer was not touched */ -/*44*/ int32 error; /* an error value */ -/*48*/ struct buf *bp; /* If we need to associate with a buf */ -/*80*/ struct scsi_sense_data sense; /* 32 bytes*/ - /* - * Believe it or not, Some targets fall on the ground with - * anything but a certain sense length. - */ -/*84*/ int32 req_sense_length; /* Explicit request sense length */ -/*88*/ int32 status; /* SCSI status */ -/*100*/ struct scsi_generic cmdstore; /* stash the command in here */ -}; - -/* - * Per-request Flag values - */ -#define SCSI_NOSLEEP 0x01 /* Not a user... don't sleep */ -#define SCSI_NOMASK 0x02 /* dont allow interrupts.. booting */ -#define SCSI_NOSTART 0x04 /* left over from ancient history */ -#define SCSI_USER 0x08 /* Is a user cmd, call scsi_user_done */ -#define ITSDONE 0x10 /* the transfer is as done as it gets */ -#define INUSE 0x20 /* The scsi_xfer block is in use */ -#define SCSI_SILENT 0x40 /* Don't report errors to console */ -#define SCSI_ERR_OK 0x80 /* An error on this operation is OK. */ -#define SCSI_RESET 0x100 /* Reset the device in question */ -#define SCSI_DATA_UIO 0x200 /* The data address refers to a UIO */ -#define SCSI_DATA_IN 0x400 /* expect data to come INTO memory */ -#define SCSI_DATA_OUT 0x800 /* expect data to flow OUT of memory */ -#define SCSI_TARGET 0x1000 /* This defines a TARGET mode op. */ -#define SCSI_ESCAPE 0x2000 /* Escape operation */ - -/* - * Escape op codes. This provides an extensible setup for operations - * that are not scsi commands. They are intended for modal operations. - */ - -#define SCSI_OP_TARGET 0x0001 -#define SCSI_OP_RESET 0x0002 -#define SCSI_OP_BDINFO 0x0003 - -/* - * Error values an adapter driver may return - */ -#define XS_NOERROR 0x0 /* there is no error, (sense is invalid) */ -#define XS_SENSE 0x1 /* Check the returned sense for the error */ -#define XS_DRIVER_STUFFUP 0x2 /* Driver failed to perform operation */ -#define XS_TIMEOUT 0x03 /* The device timed out.. turned off? */ -#define XS_SWTIMEOUT 0x04 /* The Timeout reported was caught by SW */ -#define XS_BUSY 0x08 /* The device busy, try again later? */ - -int scsi_targmatch __P((struct device *, struct cfdata *, void *)); - -struct scsi_xfer *get_xs __P((struct scsi_link *, u_int32)); -void free_xs __P((struct scsi_xfer *, struct scsi_link *, u_int32)); -u_int32 scsi_size __P((struct scsi_link *, u_int32)); -int scsi_test_unit_ready __P((struct scsi_link *, u_int32)); -int scsi_change_def __P((struct scsi_link *, u_int32)); -int scsi_inquire __P((struct scsi_link *, struct scsi_inquiry_data *, u_int32)); -int scsi_prevent __P((struct scsi_link *, u_int32, u_int32)); -int scsi_start_unit __P((struct scsi_link *, u_int32)); -void scsi_done __P((struct scsi_xfer *)); -int scsi_scsi_cmd __P((struct scsi_link *, struct scsi_generic *, - u_int32 cmdlen, u_char *data_addr, - u_int32 datalen, u_int32 retries, - u_int32 timeout, struct buf *bp, - u_int32 flags)); -int scsi_do_ioctl __P((struct scsi_link *, int, caddr_t, int)); - -void show_scsi_xs __P((struct scsi_xfer *)); -void show_scsi_cmd __P((struct scsi_xfer *)); -void show_mem __P((unsigned char *, u_int32)); - -void lto3b __P((int val, u_char *bytes)); -int _3btol __P((u_char *bytes)); - -#endif /*SCSI_SCSICONF_H*/ -/* END OF FILE */ diff --git a/sys/arch/mac68k/scsi/sd.c b/sys/arch/mac68k/scsi/sd.c deleted file mode 100644 index 1c1082a18e53..000000000000 --- a/sys/arch/mac68k/scsi/sd.c +++ /dev/null @@ -1,994 +0,0 @@ -/* $NetBSD: sd.c,v 1.9 1994/10/26 08:47:40 cgd Exp $ */ - -/* - * Written by Julian Elischer (julian@dialix.oz.au) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef DDB -int Debugger(); -#else /* DDB */ -#define Debugger() -#endif /* DDB */ - -#define SDOUTSTANDING 2 -#define SDRETRIES 4 - -#define SDUNIT(z) DISKUNIT(z) -#define SDPART(z) DISKPART(z) -#define MAKESDDEV(maj, unit, part) MAKEDISKDEV(maj, unit, part) - -struct sd_data { - struct dkdevice sc_dk; - - u_int32 flags; -#define SDINIT 0x04 /* device has been init'd */ -#define SDHAVELABEL 0x10 /* have read the label */ -#define SDDOSPART 0x20 /* Have read the DOS partition table */ -#define SDWRITEPROT 0x40 /* Device in readonly mode (S/W) */ - struct scsi_link *sc_link; /* contains our targ, lun etc. */ - u_int32 ad_info; /* info about the adapter */ - u_int32 cmdscount; /* cmds allowed outstanding by board */ - boolean wlabel; /* label is writable */ - struct disk_parms { - u_char heads; /* Number of heads */ - u_int16 cyls; /* Number of cylinders */ - u_char sectors; /* Number of sectors/track */ - u_int32 blksize; /* Number of bytes/sector */ - u_long disksize; /* total number sectors */ - } params; - u_int32 partflags[MAXPARTITIONS]; /* per partition flags */ -#define SDOPEN 0x01 - u_int32 openparts; /* one bit for each open partition */ - u_int32 xfer_block_wait; - struct buf buf_queue; -}; - -void sdattach __P((struct device *, struct device *, void *)); - -struct cfdriver sdcd = -{ NULL, "sd", scsi_targmatch, sdattach, DV_DISK, sizeof(struct sd_data) }; - -int sdgetdisklabel __P((struct sd_data *)); -int sd_get_parms __P((struct sd_data *, int)); -void sdstrategy __P((struct buf *)); -void sdstart __P((int)); - -struct dkdriver sddkdriver = { sdstrategy }; - -struct scsi_device sd_switch = -{ - NULL, /* Use default error handler */ - sdstart, /* have a queue, served by this */ - NULL, /* have no async handler */ - NULL, /* Use default 'done' routine */ - "sd", - 0 -}; - -/* - * The routine called by the low level scsi routine when it discovers - * a device suitable for this driver. - */ -void -sdattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct sd_data *sd = (struct sd_data *)self; - struct disk_parms *dp = &sd->params; - struct scsi_link *sc_link = aux; - - SC_DEBUG(sc_link, SDEV_DB2, ("sdattach: ")); - - /* - * Store information needed to contact our base driver - */ - sd->sc_link = sc_link; - sc_link->device = &sd_switch; - sc_link->dev_unit = self->dv_unit; - - sd->sc_dk.dk_driver = &sddkdriver; - - if (sd->sc_link->adapter->adapter_info) { - sd->ad_info = ((*(sd->sc_link->adapter->adapter_info)) (sc_link->adapter_softc)); - sd->cmdscount = sd->ad_info & AD_INF_MAX_CMDS; - if (sd->cmdscount > SDOUTSTANDING) - sd->cmdscount = SDOUTSTANDING; - } else { - sd->ad_info = 1; - sd->cmdscount = 1; - } - sc_link->opennings = sd->cmdscount; - - /* - * Use the subdriver to request information regarding - * the drive. We cannot use interrupts yet, so the - * request must specify this. - */ - sd_get_parms(sd, SCSI_NOSLEEP | SCSI_NOMASK); - printf(": %dMB, %d cyl, %d head, %d sec, %d bytes/sec\n", - dp->disksize / ((1024L * 1024L) / dp->blksize), - dp->cyls, dp->heads, dp->sectors, dp->blksize); - sd->flags |= SDINIT; -} - -/* - * open the device. Make sure the partition info is a up-to-date as can be. - */ -int -sdopen(dev) - dev_t dev; -{ - int error = 0; - int unit, part; - struct sd_data *sd; - struct scsi_link *sc_link; - - unit = SDUNIT(dev); - part = SDPART(dev); - - if (unit >= sdcd.cd_ndevs) - return ENXIO; - sd = sdcd.cd_devs[unit]; - /* - * Make sure the disk has been initialised - * At some point in the future, get the scsi driver - * to look for a new device if we are not initted - */ - if (!sd || !(sd->flags & SDINIT)) - return ENXIO; - - sc_link = sd->sc_link; - - SC_DEBUG(sc_link, SDEV_DB1, - ("sdopen: dev=0x%x (unit %d (of %d),partition %d)\n" - ,dev, unit, sdcd.cd_ndevs, part)); - - /* - * If it's been invalidated, then forget the label - */ - if (!(sc_link->flags & SDEV_MEDIA_LOADED)) { - sd->flags &= ~SDHAVELABEL; - - /* - * If somebody still has it open, then forbid re-entry. - */ - if (sd->openparts) - return ENXIO; - } - - /* - * "unit attention" errors should occur here if the - * drive has been restarted or the pack changed. - * just ingnore the result, it's a decoy instruction - * The error code will act on the error though - * and invalidate any media information we had. - */ - scsi_test_unit_ready(sc_link, SCSI_SILENT); - - /* - * In case it is a funny one, tell it to start - * not needed for most hard drives (ignore failure) - */ - scsi_start_unit(sc_link, SCSI_ERR_OK | SCSI_SILENT); - - /* - * Check that it is still responding and ok. - */ - sc_link->flags |= SDEV_OPEN; /* unit attn becomes an err now */ - if (scsi_test_unit_ready(sc_link, 0)) { - SC_DEBUG(sc_link, SDEV_DB3, ("device not reponding\n")); - error = ENXIO; - goto bad; - } - SC_DEBUG(sc_link, SDEV_DB3, ("device ok\n")); - - /* Lock the pack in. */ - scsi_prevent(sc_link, PR_PREVENT, SCSI_ERR_OK | SCSI_SILENT); - - /* - * Load the physical device parameters - */ - if (sd_get_parms(sd, 0)) { - error = ENXIO; - goto bad; - } - SC_DEBUG(sc_link, SDEV_DB3, ("Params loaded ")); - - /* - * Load the partition info if not already loaded. - */ - if ((error = sdgetdisklabel(sd)) && (part != RAW_PART)) - goto bad; - SC_DEBUG(sc_link, SDEV_DB3, ("Disklabel loaded ")); - - /* - * Check the partition is legal - */ - if (part >= sd->sc_dk.dk_label.d_npartitions && - part != RAW_PART) { - error = ENXIO; - goto bad; - } - SC_DEBUG(sc_link, SDEV_DB3, ("partition ok")); - - /* - * Check that the partition exists - */ - if (sd->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED && - part != RAW_PART) { - error = ENXIO; - goto bad; - } - sd->partflags[part] |= SDOPEN; - sd->openparts |= (1 << part); - SC_DEBUG(sc_link, SDEV_DB3, ("open complete\n")); - sc_link->flags |= SDEV_MEDIA_LOADED; - return 0; - -bad: - if (!sd->openparts) { - scsi_prevent(sc_link, PR_ALLOW, SCSI_ERR_OK | SCSI_SILENT); - sc_link->flags &= ~SDEV_OPEN; - } - return error; -} - -/* - * close the device.. only called if we are the LAST occurence of an open - * device. Convenient now but usually a pain. - */ -int -sdclose(dev) - dev_t dev; -{ - int unit, part; - struct sd_data *sd; - - unit = SDUNIT(dev); - part = SDPART(dev); - sd = sdcd.cd_devs[unit]; - sd->partflags[part] &= ~SDOPEN; - sd->openparts &= ~(1 << part); - if (!sd->openparts) { - scsi_prevent(sd->sc_link, PR_ALLOW, SCSI_ERR_OK | SCSI_SILENT); - sd->sc_link->flags &= ~SDEV_OPEN; - } - return 0; -} - -/* - * trim the size of the transfer if needed, called by physio - * basically the smaller of our max and the scsi driver's - * minphys (note we have no max) - * - * Trim buffer length if buffer-size is bigger than page size - */ -void -sdminphys(bp) - struct buf *bp; -{ - register struct sd_data *sd = sdcd.cd_devs[SDUNIT(bp->b_dev)]; - - (sd->sc_link->adapter->scsi_minphys) (bp); -} - -/* - * Actually translate the requested transfer into one the physical driver - * can understand. The transfer is described by a buf and will include - * only one physical transfer. - */ -void -sdstrategy(bp) - struct buf *bp; -{ - struct buf *dp; - int opri; - struct sd_data *sd; - int unit; - - unit = SDUNIT(bp->b_dev); - sd = sdcd.cd_devs[unit]; - SC_DEBUG(sd->sc_link, SDEV_DB2, ("sdstrategy ")); - SC_DEBUG(sd->sc_link, SDEV_DB1, - (" %d bytes @ blk%d\n", bp->b_bcount, bp->b_blkno)); - sdminphys(bp); - /* - * If the device has been made invalid, error out - */ - if (!(sd->sc_link->flags & SDEV_MEDIA_LOADED)) { - sd->flags &= ~SDHAVELABEL; - bp->b_error = EIO; - goto bad; - } - /* - * "soft" write protect check - */ - if ((sd->flags & SDWRITEPROT) && (bp->b_flags & B_READ) == 0) { - bp->b_error = EROFS; - goto bad; - } - /* - * If it's a null transfer, return immediatly - */ - if (bp->b_bcount == 0) - goto done; - /* - * Decide which unit and partition we are talking about - * only raw is ok if no label - */ - if (SDPART(bp->b_dev) != RAW_PART) { - if (!(sd->flags & SDHAVELABEL)) { - bp->b_error = EIO; - goto bad; - } - /* - * do bounds checking, adjust transfer. if error, process. - * if end of partition, just return - */ - if (bounds_check_with_label(bp, &sd->sc_dk.dk_label, sd->wlabel) <= 0) - goto done; - /* otherwise, process transfer request */ - } - opri = splbio(); - dp = &sd->buf_queue; - - /* - * Place it in the queue of disk activities for this disk - */ - disksort(dp, bp); - - /* - * Tell the device to get going on the transfer if it's - * not doing anything, otherwise just wait for completion - */ - sdstart(unit); - - splx(opri); - return; - -bad: - bp->b_flags |= B_ERROR; -done: - - /* - * Correctly set the buf to indicate a completed xfer - */ - bp->b_resid = bp->b_bcount; - biodone(bp); -} - -/* - * sdstart looks to see if there is a buf waiting for the device - * and that the device is not already busy. If both are true, - * It dequeues the buf and creates a scsi command to perform the - * transfer in the buf. The transfer request will call scsi_done - * on completion, which will in turn call this routine again - * so that the next queued transfer is performed. - * The bufs are queued by the strategy routine (sdstrategy) - * - * This routine is also called after other non-queued requests - * have been made of the scsi driver, to ensure that the queue - * continues to be drained. - * - * must be called at the correct (highish) spl level - * sdstart() is called at splbio from sdstrategy and scsi_done - */ -void -sdstart(unit) - int unit; -{ - register struct sd_data *sd = sdcd.cd_devs[unit]; - register struct scsi_link *sc_link = sd->sc_link; - struct buf *bp = 0; - struct buf *dp; - struct scsi_rw_big cmd; - int blkno, nblks; - struct partition *p; - - SC_DEBUG(sc_link, SDEV_DB2, ("sdstart%d ", unit)); - /* - * Check if the device has room for another command - */ - while (sc_link->opennings) { - /* - * there is excess capacity, but a special waits - * It'll need the adapter as soon as we clear out of the - * way and let it run (user level wait). - */ - if (sc_link->flags & SDEV_WAITING) - return; - - /* - * See if there is a buf with work for us to do.. - */ - dp = &sd->buf_queue; - if ((bp = dp->b_actf) == NULL) /* yes, an assign */ - return; - dp->b_actf = bp->b_actf; - - /* - * If the device has become invalid, abort all the - * reads and writes until all files have been closed and - * re-openned - */ - if (!(sc_link->flags & SDEV_MEDIA_LOADED)) { - sd->flags &= ~SDHAVELABEL; - goto bad; - } - - /* - * We have a buf, now we know we are going to go through - * With this thing.. - * - * First, translate the block to absolute - */ - blkno = bp->b_blkno / (sd->params.blksize / DEV_BSIZE); - if (SDPART(bp->b_dev) != RAW_PART) { - p = &sd->sc_dk.dk_label.d_partitions[SDPART(bp->b_dev)]; - blkno += p->p_offset; - } - nblks = (bp->b_bcount + (sd->params.blksize - 1)) / (sd->params.blksize); - - /* - * Fill out the scsi command - */ - bzero(&cmd, sizeof(cmd)); - cmd.op_code = (bp->b_flags & B_READ) ? READ_BIG : WRITE_BIG; - cmd.addr_3 = (blkno & 0xff000000) >> 24; - cmd.addr_2 = (blkno & 0xff0000) >> 16; - cmd.addr_1 = (blkno & 0xff00) >> 8; - cmd.addr_0 = blkno & 0xff; - cmd.length2 = (nblks & 0xff00) >> 8; - cmd.length1 = (nblks & 0xff); - - /* - * Call the routine that chats with the adapter. - * Note: we cannot sleep as we may be an interrupt - */ - if (scsi_scsi_cmd(sc_link, (struct scsi_generic *) &cmd, - sizeof(cmd), (u_char *) bp->b_un.b_addr, - bp->b_bcount, SDRETRIES, 10000, bp, - SCSI_NOSLEEP | ((bp->b_flags & B_READ) ? - SCSI_DATA_IN : SCSI_DATA_OUT)) - != SUCCESSFULLY_QUEUED) { -bad: - printf("%s: not queued", sd->sc_dk.dk_dev.dv_xname); - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - biodone(bp); - } - } -} - -/* - * Perform special action on behalf of the user - * Knows about the internals of this device - */ -int -sdioctl(dev, cmd, addr, flag) - dev_t dev; - int cmd; - caddr_t addr; - int flag; -{ - int error = 0; - int unit, part; - register struct sd_data *sd; - - /* - * Find the device that the user is talking about - */ - unit = SDUNIT(dev); - part = SDPART(dev); - sd = sdcd.cd_devs[unit]; - SC_DEBUG(sd->sc_link, SDEV_DB1, ("sdioctl (0x%x)", cmd)); - - /* - * If the device is not valid.. abandon ship - */ - if (!(sd->sc_link->flags & SDEV_MEDIA_LOADED)) - return EIO; - switch (cmd) { - - case DIOCSBAD: - return EINVAL; - - case DIOCGDINFO: - *(struct disklabel *) addr = sd->sc_dk.dk_label; - return 0; - - case DIOCGPART: - ((struct partinfo *) addr)->disklab = &sd->sc_dk.dk_label; - ((struct partinfo *) addr)->part = - &sd->sc_dk.dk_label.d_partitions[SDPART(dev)]; - return 0; - - case DIOCSDINFO: - if ((flag & FWRITE) == 0) - return EBADF; - error = setdisklabel(&sd->sc_dk.dk_label, - (struct disklabel *)addr, - /*(sd->flags & DKFL_BSDLABEL) ? sd->openparts : */ 0, - &sd->sc_dk.dk_cpulabel); - if (!error) - sd->flags |= SDHAVELABEL; - return error; - - case DIOCWLABEL: - sd->flags &= ~SDWRITEPROT; - if ((flag & FWRITE) == 0) - return EBADF; - sd->wlabel = *(boolean *) addr; - return 0; - - case DIOCWDINFO: - sd->flags &= ~SDWRITEPROT; - if ((flag & FWRITE) == 0) - return EBADF; - error = setdisklabel(&sd->sc_dk.dk_label, - (struct disklabel *)addr, - /*(sd->flags & SDHAVELABEL) ? sd->openparts : */ 0, - &sd->sc_dk.dk_cpulabel); - if (error) - return error; - - { - boolean wlab; - - /* ok - write will succeed */ - sd->flags |= SDHAVELABEL; - - /* simulate opening partition 0 so write succeeds */ - sd->openparts |= (1 << 0); /* XXX */ - wlab = sd->wlabel; - sd->wlabel = 1; - error = writedisklabel(dev, sdstrategy, - &sd->sc_dk.dk_label, - &sd->sc_dk.dk_cpulabel); - sd->wlabel = wlab; - return error; - } - - default: - if (part != RAW_PART) - return ENOTTY; - return scsi_do_ioctl(sd->sc_link, cmd, addr, flag); - } -#ifdef DIAGNOSTIC - panic("sdioctl: impossible"); -#endif -} - -/* - * Load the label information on the named device - */ -int -sdgetdisklabel(sd) - struct sd_data *sd; -{ - char *errstring; - - /* - * If the inflo is already loaded, use it - */ - if (sd->flags & SDHAVELABEL) - return 0; - - bzero(&sd->sc_dk.dk_label, sizeof(struct disklabel)); - bzero(&sd->sc_dk.dk_cpulabel, sizeof(struct cpu_disklabel)); - /* - * make partition RAW_PART the whole disk in case of failure then get - * pdinfo for historical reasons, make part a same as raw part, but - * set p_fstype to FS_UNUSED for part a so we can allocate it later - * (7 partitions just isn't enough to let root be singled out). - */ - sd->sc_dk.dk_label.d_partitions[0].p_offset = 0; - sd->sc_dk.dk_label.d_partitions[0].p_size - = sd->params.disksize * (sd->params.blksize / DEV_BSIZE); - sd->sc_dk.dk_label.d_partitions[0].p_fstype = FS_UNUSED; - sd->sc_dk.dk_label.d_partitions[RAW_PART].p_offset = 0; - sd->sc_dk.dk_label.d_partitions[RAW_PART].p_size - = sd->params.disksize * (sd->params.blksize / DEV_BSIZE); - sd->sc_dk.dk_label.d_partitions[RAW_PART].p_fstype = FS_OTHER; - sd->sc_dk.dk_label.d_npartitions = MAXPARTITIONS; - - sd->sc_dk.dk_label.d_secsize = sd->params.blksize; - sd->sc_dk.dk_label.d_ntracks = sd->params.heads; - sd->sc_dk.dk_label.d_nsectors = sd->params.sectors; - sd->sc_dk.dk_label.d_ncylinders = sd->params.cyls; - sd->sc_dk.dk_label.d_secpercyl = sd->params.heads * sd->params.sectors; - if (sd->sc_dk.dk_label.d_secpercyl == 0) { - sd->sc_dk.dk_label.d_secpercyl = 100; - /* as long as it's not 0 - readdisklabel divides by it (?) */ - } - - /* - * Call the generic disklabel extraction routine - */ -#if PRINT_DISKLABELS - printf("Disklabelling %s.\n", sd->sc_dk.dk_dev.dv_xname); -#endif - if (errstring = readdisklabel(MAKESDDEV(0, sd->sc_dk.dk_dev.dv_unit, - RAW_PART), sdstrategy, - &sd->sc_dk.dk_label, - &sd->sc_dk.dk_cpulabel)) { - printf("%s: %s\n", sd->sc_dk.dk_dev.dv_xname, errstring); - return ENXIO; - } - sd->flags |= SDHAVELABEL; /* WE HAVE IT ALL NOW */ - return 0; -} - -/* - * Find out from the device what it's capacity is - */ -u_int32 -sd_size(sd, flags) - struct sd_data *sd; - int flags; -{ - struct scsi_read_cap_data rdcap; - struct scsi_read_capacity scsi_cmd; - u_int32 size; - - /* - * make up a scsi command and ask the scsi driver to do - * it for you. - */ - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = READ_CAPACITY; - - /* - * If the command works, interpret the result as a 4 byte - * number of blocks - */ - if (scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), (u_char *) &rdcap, sizeof(rdcap), - SDRETRIES, 2000, NULL, flags | SCSI_DATA_IN) != 0) { - printf("%s: could not get size\n", sd->sc_dk.dk_dev.dv_xname); - return 0; - } else { - size = rdcap.addr_0 + 1; - size += rdcap.addr_1 << 8; - size += rdcap.addr_2 << 16; - size += rdcap.addr_3 << 24; - } - return size; -} - -/* - * Tell the device to map out a defective block - */ -int -sd_reassign_blocks(sd, block) - struct sd_data *sd; - int block; -{ - struct scsi_reassign_blocks scsi_cmd; - struct scsi_reassign_blocks_data rbdata; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - bzero(&rbdata, sizeof(rbdata)); - scsi_cmd.op_code = REASSIGN_BLOCKS; - - rbdata.length_msb = 0; - rbdata.length_lsb = sizeof(rbdata.defect_descriptor[0]); - rbdata.defect_descriptor[0].dlbaddr_3 = ((block >> 24) & 0xff); - rbdata.defect_descriptor[0].dlbaddr_2 = ((block >> 16) & 0xff); - rbdata.defect_descriptor[0].dlbaddr_1 = ((block >> 8) & 0xff); - rbdata.defect_descriptor[0].dlbaddr_0 = ((block) & 0xff); - - return scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), (u_char *) &rbdata, - sizeof(rbdata), SDRETRIES, 5000, NULL, - SCSI_DATA_OUT); -} - -#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0 ) - -/* - * Get the scsi driver to send a full inquiry to the * device and use the - * results to fill out the disk parameter structure. - */ -int -sd_get_parms(sd, flags) - struct sd_data *sd; - int flags; -{ - struct disk_parms *disk_parms = &sd->params; - struct scsi_mode_sense scsi_cmd; - struct scsi_mode_sense_data { - struct scsi_mode_header header; - struct blk_desc blk_desc; - union disk_pages pages; - } scsi_sense; - u_int32 sectors; - - /* - * First check if we have it all loaded - */ - if (sd->sc_link->flags & SDEV_MEDIA_LOADED) - return 0; - - /* - * do a "mode sense page 4" - */ - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = MODE_SENSE; - scsi_cmd.page = 4; - scsi_cmd.length = 0x20; - /* - * If the command worked, use the results to fill out - * the parameter structure - */ - if (scsi_scsi_cmd(sd->sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), (u_char *) &scsi_sense, - sizeof(scsi_sense), SDRETRIES, 2000, NULL, - flags | SCSI_DATA_IN) != 0) { - - printf("%s: could not mode sense", sd->sc_dk.dk_dev.dv_xname); - printf(" (4); using ficticious geometry\n"); - /* - * use adaptec standard ficticious geometry - * this depends on which controller (e.g. 1542C is - * different. but we have to put SOMETHING here..) - */ - sectors = sd_size(sd, flags); - disk_parms->heads = 64; - disk_parms->sectors = 32; - disk_parms->cyls = sectors / (64 * 32); - disk_parms->blksize = 512; - disk_parms->disksize = sectors; - } else { - - SC_DEBUG(sd->sc_link, SDEV_DB3, - ("%d cyls, %d heads, %d precomp, %d red_write, %d land_zone\n", - _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2), - scsi_sense.pages.rigid_geometry.nheads, - b2tol(scsi_sense.pages.rigid_geometry.st_cyl_wp), - b2tol(scsi_sense.pages.rigid_geometry.st_cyl_rwc), - b2tol(scsi_sense.pages.rigid_geometry.land_zone))); - - /* - * KLUDGE!!(for zone recorded disks) - * give a number of sectors so that sec * trks * cyls - * is <= disk_size - * can lead to wasted space! THINK ABOUT THIS ! - */ - disk_parms->heads = scsi_sense.pages.rigid_geometry.nheads; - disk_parms->cyls = _3btol(&scsi_sense.pages.rigid_geometry.ncyl_2); - disk_parms->blksize = _3btol(scsi_sense.blk_desc.blklen); - - sectors = sd_size(sd, flags); - disk_parms->disksize = sectors; - sectors /= (disk_parms->heads * disk_parms->cyls); - disk_parms->sectors = sectors; /* dubious on SCSI *//*XXX */ - } - sd->sc_link->flags |= SDEV_MEDIA_LOADED; - return 0; -} - -int -sdsize(dev_t dev) -{ - int unit = SDUNIT(dev), part = SDPART(dev), val; - struct sd_data *sd; - - if (unit >= sdcd.cd_ndevs) - return -1; - sd = sdcd.cd_devs[unit]; - if (!sd || !(sd->flags & SDINIT)) - return -1; - - if ((sd->flags & SDHAVELABEL) == 0) { - val = sdopen(MAKESDDEV(major(dev), unit, RAW_PART), FREAD, S_IFBLK, 0); - if (val != 0) - return -1; - } - if (sd->flags & SDWRITEPROT) - return -1; - return sd->sc_dk.dk_label.d_partitions[part].p_size; -} - - -#define SCSIDUMP 1 -#undef SCSIDUMP -#define NOT_TRUSTED 1 - -#ifdef SCSIDUMP -#include - -static struct scsi_xfer sx; -#define MAXTRANSFER 8 /* 1 page at a time */ - -/* - * dump all of physical memory into the partition specified, starting - * at offset 'dumplo' into the partition. - */ -int -sddump(dev_t dev) -{ /* dump core after a system crash */ - register struct sd_data *sd; /* disk unit to do the IO */ - int32 num; /* number of sectors to write */ - u_int32 unit, part; - int32 blkoff, blknum, blkcnt = MAXTRANSFER; - int32 nblocks; - char *addr; - struct scsi_rw_big cmd; - extern int Maxmem; - static int sddoingadump = 0; -#define MAPTO CADDR1 - extern caddr_t MAPTO; /* map the page we are about to write, here */ - struct scsi_xfer *xs = &sx; - int retval; - int c; - - addr = (char *) 0; /* starting address */ - - /* toss any characters present prior to dump */ - while ((c = sgetc(1)) && (c != 0x100)); /*syscons and pccons differ */ - - /* size of memory to dump */ - num = Maxmem; - unit = SDUNIT(dev); /* eventually support floppies? */ - part = SDPART(dev); /* file system */ - /* check for acceptable drive number */ - if (unit >= sdcd.cd_ndevs) - return ENXIO; - - sd = sd_data[unit]; - if (!sd) - return ENXIO; - /* was it ever initialized etc. ? */ - if (!(sd->flags & SDINIT)) - return ENXIO; - if (sd->sc_link->flags & SDEV_MEDIA_LOADED != SDEV_MEDIA_LOADED) - return ENXIO; - if (sd->flags & SDWRITEPROT) - return ENXIO; - - /* Convert to disk sectors */ - num = (u_int32) num * NBPG / sd->sc_dk.dk_label.d_secsize; - - /* check if controller active */ - if (sddoingadump) - return EFAULT; - - nblocks = sd->sc_dk.dk_label.d_partitions[part].p_size; - blkoff = sd->sc_dk.dk_label.d_partitions[part].p_offset; - - /* check transfer bounds against partition size */ - if ((dumplo < 0) || ((dumplo + num) > nblocks)) - return EINVAL; - - sddoingadump = 1; - - blknum = dumplo + blkoff; - /* blkcnt = initialise_me; */ - while (num > 0) { - pmap_enter(kernel_pmap, - MAPTO, - trunc_page(addr), - VM_PROT_READ, - TRUE); -#ifndef NOT_TRUSTED - /* - * Fill out the scsi command - */ - bzero(&cmd, sizeof(cmd)); - cmd.op_code = WRITE_BIG; - cmd.addr_3 = (blknum & 0xff000000) >> 24; - cmd.addr_2 = (blknum & 0xff0000) >> 16; - cmd.addr_1 = (blknum & 0xff00) >> 8; - cmd.addr_0 = blknum & 0xff; - cmd.length2 = (blkcnt & 0xff00) >> 8; - cmd.length1 = (blkcnt & 0xff); - /* - * Fill out the scsi_xfer structure - * Note: we cannot sleep as we may be an interrupt - * don't use scsi_scsi_cmd() as it may want - * to wait for an xs. - */ - bzero(xs, sizeof(sx)); - xs->flags |= SCSI_NOMASK | SCSI_NOSLEEP | INUSE; - xs->sc_link = sd->sc_link; - xs->retries = SDRETRIES; - xs->timeout = 10000; /* 10000 millisecs for a disk ! */ - xs->cmd = (struct scsi_generic *) &cmd; - xs->cmdlen = sizeof(cmd); - xs->resid = blkcnt * 512; - xs->error = XS_NOERROR; - xs->bp = 0; - xs->data = (u_char *) MAPTO; - xs->datalen = blkcnt * 512; - - /* - * Pass all this info to the scsi driver. - */ - retval = (*(sd->sc_link->adapter->scsi_cmd)) (xs); - switch (retval) { - case SUCCESSFULLY_QUEUED: - case HAD_ERROR: - return ENXIO; /* we said not to sleep! */ - case COMPLETE: - break; - default: - return ENXIO; /* we said not to sleep! */ - } -#else /* NOT_TRUSTED */ - /* lets just talk about this first... */ - printf("sd%d: dump addr 0x%x, blk %d\n", unit, addr, blknum); -#endif /* NOT_TRUSTED */ - - if ((unsigned) addr % (1024 * 1024) == 0) - printf("%d ", num / 2048); - /* update block count */ - num -= blkcnt; - blknum += blkcnt; - (int) addr += 512 * blkcnt; - - /* operator aborting dump? */ - if ((c = sgetc(1)) && (c != 0x100)) - return EINTR; - } - return 0; -} -#else /* SCSIDUMP */ -int -sddump() -{ - printf("\nsddump() -- not implemented\n"); - DELAY(60000000); /* 60 seconds */ - return -1; -} -#endif /* SCSIDUMP */ - -extern int -sd_target_to_unit(target) -int target; -{ - struct sd_data *sd; - int unit; - - for (unit = 0 ; unit < sdcd.cd_ndevs ; unit++) { - sd = sdcd.cd_devs[unit]; - if (sd->sc_link->target == target) - return sd->sc_link->dev_unit; - } - return -1; -} - diff --git a/sys/arch/mac68k/scsi/sg.c b/sys/arch/mac68k/scsi/sg.c deleted file mode 100644 index e78e60353802..000000000000 --- a/sys/arch/mac68k/scsi/sg.c +++ /dev/null @@ -1,758 +0,0 @@ -/* - * Contributed by HD Associates (hd@world.std.com). - * Copyright (c) 1992, 1993 HD Associates - * - * Berkeley style copyright. I've just snarfed it out of stdio.h: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "sg.h" -#include - -#define SGOUTSTANDING 2 -#define SG_RETRIES 2 -#define SPLSG splbio - -/* Use one of the implementation defined spare bits - * to indicate the escape op: - */ -#define DSRQ_ESCAPE DSRQ_CTRL1 - -struct sg -{ - int flags; - struct scsi_switch *sc_sw; - int ctlr; - - long int ad_info; /* info about the adapter */ - int cmdscount; /* cmds allowed outstanding by the board */ - - struct scsi_xfer *free_xfer; - int free_xfer_wait; -}; - -/* This is used to associate a struct dsreq and a struct buf. - */ -typedef struct dsbuf -{ - dsreq_t *dsreq; - struct buf buf; - - /* I think this is a portable way to get back to the base of - * the enclosing structure: - */ -# define DSBUF_P(BP) ((dsbuf_t *)((caddr_t)(BP) - (caddr_t)&((dsbuf_t *)0)->buf)) - - int magic; - -# define DSBUF_MAGIC 0xDBFACDBF -} dsbuf_t; - -#if NSG > 4 -/* The host adapter unit is encoded in the upper 2 bits of the minor number - * (the SGI flag bits). - */ -#error "NSG can't be > 4 unless the method of encoding the board unit changes" -#endif - -struct sg *sgs[NSG]; - -#define SG(DEV) sgs[G_SCSI_UNIT(DEV)] - -struct sg *sg_new(int lun) -{ - struct sg *sg = (struct sg *)malloc(sizeof(*sg),M_TEMP, M_NOWAIT); - - if (sg == 0) - return 0; - - bzero(sg, sizeof(struct sg)); - - return sg; -} - -int sg_attach(ctlr, scsi_addr, scsi_switch) -int ctlr,scsi_addr; -struct scsi_switch *scsi_switch; -{ - struct sg *sg; - int i; - struct scsi_xfer *scsi_xfer; - static int next_sg_unit = 0; - - int unit = next_sg_unit++; - - if (unit >= NSG) - { - printf("Too many generic SCSIs (%d > %d); reconfigure the kernel.\n", - unit+1, NSG); - - if (NSG == 4) - printf( - "You have hit the max of 4. You will have to change the driver.\n"); - - return 0; - } - - if ((sg = sg_new(0)) == 0) - return 0; - - sgs[unit] = sg; - - sg->sc_sw = scsi_switch; - sg->ctlr = ctlr; - - /* This is a bit confusing. It looks like Julian calls back into the - * adapter to find out how many outstanding transactions it can - * handle. How does he handle a tape/disk combo? - */ - - if (sg->sc_sw->adapter_info) - { - sg->ad_info = ( (*(sg->sc_sw->adapter_info))(unit)); - sg->cmdscount = sg->ad_info & AD_INF_MAX_CMDS; - if(sg->cmdscount > SGOUTSTANDING) - sg->cmdscount = SGOUTSTANDING; - } - else - { - sg->ad_info = 1; - sg->cmdscount = 1; - } - - i = sg->cmdscount; - - scsi_xfer = (struct scsi_xfer *)malloc(sizeof(struct scsi_xfer) * - i, M_TEMP, M_NOWAIT); - - if (scsi_xfer == 0) - { - printf("scsi_generic: Can't malloc.\n"); - return 0; - } - - while (i--) - { - scsi_xfer->next = sg->free_xfer; - sg->free_xfer = scsi_xfer; - scsi_xfer++; - } - -#ifndef EMBEDDED - if (unit == 0) - printf(" /dev/gs%d (instance 0) generic SCSI via controller %d\n", - scsi_addr, sg->ctlr); - else - printf(" /dev/gs%d-%d generic SCSI via controller %d\n", - unit, scsi_addr, sg->ctlr); -#endif - - return 1; -} - -/* It is trivial to add support for processor target devices - * here - enable target mode on open and disable on close - * if a flag bit is set in the minor number - */ -int sgopen(dev_t dev) -{ - if (SG(dev) == 0) - return ENXIO; - - return 0; -} - -int sgclose(dev_t dev) -{ - return 0; -} - - -/* Free a scsi_xfer, wake processes waiting for it - */ -void sg_free_xs(dev_t dev, struct scsi_xfer *xs, int flags) -{ - int s; - struct sg *sg = SG(dev); - - if(flags & SCSI_NOMASK) - { - if (sg->free_xfer_wait) - { - printf("sg_free_xs: doing a wakeup from NOMASK mode!\n"); - wakeup((caddr_t)&sg->free_xfer); - } - xs->next = sg->free_xfer; - sg->free_xfer = xs; - } - else - { - s = SPLSG(); - if (sg->free_xfer_wait) - wakeup((caddr_t)&sg->free_xfer); - xs->next = sg->free_xfer; - sg->free_xfer = xs; - splx(s); - } -} - -/* Get ownership of a scsi_xfer - * If need be, sleep on it, until it comes free - */ -struct scsi_xfer *sg_get_xs(dev_t dev, int flags) -{ - struct scsi_xfer *xs; - int s; - struct sg *sg = SG(dev); - - if(flags & (SCSI_NOSLEEP | SCSI_NOMASK)) - { - if (xs = sg->free_xfer) - { - sg->free_xfer = xs->next; - xs->flags = 0; - } - } - else - { - s = SPLSG(); - while (!(xs = sg->free_xfer)) - { - sg->free_xfer_wait++; /* someone waiting! */ - sleep((caddr_t)&sg->free_xfer, PRIBIO+1); - sg->free_xfer_wait--; - } - sg->free_xfer = xs->next; - splx(s); - xs->flags = 0; - } - - return xs; -} - -/* We let the user interpret his own sense in the - * generic scsi world - */ -int sg_interpret_sense(dev_t dev, struct scsi_xfer *xs, int *flag_p) -{ - return 0; -} - -/* ITSDONE is really used for things that are marked one - * in the interrupt. I'll leave the logic in in case I want - * to move done processing (and therefore have a start queue) - * back into the interrupt. - * BUG: No start queue. - */ - -int sg_done(dev_t dev, -struct scsi_xfer *xs) -{ - xs->flags |= ITSDONE; - wakeup(xs); - return 0; -} - -int sg_submit_cmd(dev_t dev, struct scsi_xfer *xs, dsreq_t *dsreq) -{ - int retval; - - struct sg *sg = SG(dev); - -retry: - xs->error = XS_NOERROR; - - xs->bp = 0; /* This bp doesn't seem to be used except to - * disable sleeping in the host adapter code. - * "st" does set it up, though. - */ - - retval = (*(sg->sc_sw->scsi_cmd))(xs); - - switch(retval) - { - case SUCCESSFULLY_QUEUED: - while(!(xs->flags & ITSDONE)) - sleep(xs,PRIBIO+1); - - /* Fall through... */ - - case HAD_ERROR: - - if (dsreq) - dsreq->ds_status = xs->status; - - switch(xs->error) - { - case XS_NOERROR: - if (dsreq) - dsreq->ds_datasent = dsreq->ds_datalen - xs->resid; - retval = 0; - break; - - case XS_SENSE: - retval = (sg_interpret_sense(dev ,xs, (int *)0)); - if (dsreq) - { - dsreq->ds_sensesent = sizeof(xs->sense); - dsreq->ds_ret = DSRT_SENSE; - } - retval = 0; - break; - - case XS_DRIVER_STUFFUP: - if (dsreq) - dsreq->ds_ret = DSRT_HOST; - printf("sg%d: host adapter code inconsistency\n" ,G_SCSI_UNIT(dev)); - retval = EIO; - break; - - case XS_TIMEOUT: - if (dsreq) - dsreq->ds_ret = DSRT_TIMEOUT; - retval = ETIMEDOUT; - break; - - case XS_BUSY: - if(xs->retries-- ) - { - xs->flags &= ~ITSDONE; - goto retry; - } - retval = EBUSY; - break; - - default: - printf("sg%d: unknown error category from host adapter code\n" - ,G_SCSI_UNIT(dev)); - retval = EIO; - break; - } - break; - - case COMPLETE: - if (dsreq) - dsreq->ds_datasent = dsreq->ds_datalen - xs->resid; - retval = 0; - break; - - case TRY_AGAIN_LATER: - if(xs->retries-- ) - { - xs->flags &= ~ITSDONE; - goto retry; - } - retval = EBUSY; - break; - - case ESCAPE_NOT_SUPPORTED: - retval = ENOSYS; /* "Function not implemented" */ - break; - - default: - printf("sg%d: illegal return from host adapter code\n", - G_SCSI_UNIT(dev)); - retval = EIO; - break; - } - - return retval; -} - -/* sg_escape: Do a generic SCSI escape - */ -int sg_escape(dev_t dev, int op_code, u_char *b, int nb) -{ - int retval; - - struct scsi_generic scsi_generic; - - int flags = SCSI_ESCAPE; - - struct scsi_xfer *xs; - struct sg *sg = SG(dev); - - xs = sg_get_xs(dev, flags); - - if (xs == 0) - { - printf("sg_target%d: controller busy" - " (this should never happen)\n",G_SCSI_UNIT(dev)); - return EBUSY; - } - - scsi_generic.opcode = op_code; - bcopy(b, scsi_generic.bytes, nb); - - /* Fill out the scsi_xfer structure - */ - xs->flags = (flags|INUSE); - xs->adapter = sg->ctlr; - xs->cmd = &scsi_generic; - xs->targ = G_SCSI_ID(dev); - xs->lu = G_SCSI_LUN(dev); - xs->retries = SG_RETRIES; - xs->timeout = 100; - xs->when_done = (flags & SCSI_NOMASK) - ?(int (*)())0 - :(int (*)())sg_done; - xs->done_arg = dev; - xs->done_arg2 = (int)xs; - - xs->status = 0; - - retval = sg_submit_cmd(dev, xs, 0); - - bcopy(scsi_generic.bytes, b, nb); - - sg_free_xs(dev,xs,flags); - - return retval; -} - -/* sg_target: Turn on / off target mode - */ -int sg_target(dev_t dev, int enable) -{ - u_char b0 = enable; - return sg_escape(dev, SCSI_OP_TARGET, &b0, 1); -} - -#ifdef EMBEDDED -/* This should REALLY be a select call! - * This is used in a stand alone system without an O/S. I didn't - * have the time to add select, which the system was missing, - * so I added this stuff to poll for the async arrival of - * connections for target mode. - */ -int sg_poll(dev_t dev, int *send, int *recv) -{ - scsi_op_poll_t s; - int ret; - - ret = sg_escape(dev, SCSI_OP_POLL, (u_char *)&s, sizeof(s)); - - if (ret == 0) - { - *send = s.send; - *recv = s.recv; - } - - return ret; -} -#endif /* EMBEDDED */ - -int sg_scsi_cmd(dev_t dev, -dsreq_t *dsreq, -struct scsi_generic *scsi_cmd, -u_char *d_addr, -long d_count, -struct scsi_sense_data *scsi_sense) -{ - int retval; - - int flags = 0; - struct scsi_xfer *xs; - struct sg *sg = SG(dev); - - if (sg->sc_sw == 0) - return ENODEV; - - dsreq->ds_status = 0; - dsreq->ds_sensesent = 0; - - if (dsreq->ds_flags & DSRQ_READ) - flags |= SCSI_DATA_IN; - - if (dsreq->ds_flags & DSRQ_WRITE) - flags |= SCSI_DATA_OUT; - - if (dsreq->ds_flags & DSRQ_TARGET) - flags |= SCSI_TARGET; - - if (dsreq->ds_flags & DSRQ_ESCAPE) - flags |= SCSI_ESCAPE; - -#ifdef SCSI_PHYSADDR - if (dsreq->ds_flags & DSRQ_PHYSADDR) - flags |= SCSI_PHYSADDR; -#endif - - xs = sg_get_xs(dev, flags); - - if (xs == 0) - { - printf("sg_scsi_cmd%d: controller busy" - " (this should never happen)\n",G_SCSI_UNIT(dev)); - - return EBUSY; - } - - /* Fill out the scsi_xfer structure - */ - xs->flags |= (flags|INUSE); - xs->adapter = sg->ctlr; - xs->targ = G_SCSI_ID(dev); - xs->lu = G_SCSI_LUN(dev); - xs->retries = SG_RETRIES; - xs->timeout = dsreq->ds_time; - xs->cmd = scsi_cmd; - xs->cmdlen = dsreq->ds_cmdlen; - xs->data = d_addr; - xs->datalen = d_count; - xs->resid = d_count; - xs->when_done = (flags & SCSI_NOMASK) - ?(int (*)())0 - :(int (*)())sg_done; - xs->done_arg = dev; - xs->done_arg2 = (int)xs; - - xs->req_sense_length = (dsreq->ds_senselen < sizeof(struct scsi_sense_data)) - ? dsreq->ds_senselen - : sizeof(struct scsi_sense_data); - xs->status = 0; - - retval = sg_submit_cmd(dev, xs, dsreq); - - if (dsreq->ds_ret == DSRT_SENSE) - bcopy(&(xs->sense), scsi_sense, sizeof(xs->sense)); - - sg_free_xs(dev,xs,flags); - - return retval; -} - -void sgerr(struct buf *bp, int err) -{ - bp->b_error = err; - bp->b_flags |= B_ERROR; - - iodone(bp); -} - -/* strategy function - * - * Should I reorganize this so it returns to physio instead - * of sleeping in sg_scsi_cmd? Is there any advantage, other - * than avoiding the probable duplicate wakeup in iodone? - * - * Don't create a block device entry point for this - * driver without making some fixes: - * you have to be able to go from the bp to the dsreq somehow. - */ -void sgstrategy(struct buf *bp) -{ - int err; - struct scsi_generic scsi_generic; - struct scsi_sense_data scsi_sense; - int lun = G_SCSI_LUN(bp->b_dev); - - dsbuf_t *dsbuf = DSBUF_P(bp); - dsreq_t *dsreq; - - if (dsbuf->magic != DSBUF_MAGIC) - { - printf("sgstrategy: struct buf not magic.\n"); - sgerr(bp, EFAULT); - return; - } - - dsreq = dsbuf->dsreq; - - /* We're in trouble if physio tried to break up the - * transfer: - */ - if (bp->b_bcount != dsreq->ds_datalen) - { - printf("sgstrategy unit%d: Transfer broken up.\n", - G_SCSI_UNIT(bp->b_dev)); - sgerr(bp, EIO); - return; - } - - dsreq->ds_ret = DSRT_OK; - - /* Reject 0 length timeouts. - */ - if (dsreq->ds_time == 0) - { - sgerr(bp, EINVAL); - return; - } - - if (dsreq->ds_cmdlen > sizeof(struct scsi_generic)) - { - sgerr(bp, EFAULT); - return; - } - - copyin(dsreq->ds_cmdbuf, (char *)&scsi_generic, dsreq->ds_cmdlen); - - /* Use device unit for the LUN. Using the one the user provided - * would be a huge security problem. - */ - if ((dsreq->ds_flags & DSRQ_ESCAPE) == 0) - scsi_generic.bytes[0] = (scsi_generic.bytes[0] & 0x1F) | (lun << 5); - - err = sg_scsi_cmd(bp->b_dev, dsreq, - &scsi_generic, - (u_char *)bp->b_un.b_addr, - bp->b_bcount, - &scsi_sense); - - if (dsreq->ds_sensesent) - { - if (dsreq->ds_sensesent > dsreq->ds_senselen) - dsreq->ds_sensesent = dsreq->ds_senselen; - - copyout(&scsi_sense, dsreq->ds_sensebuf, dsreq->ds_sensesent); - } - - if (err) - { - if (dsreq->ds_ret == DSRT_OK) - dsreq->ds_ret = DSRT_DEVSCSI; - - sgerr(bp, err); - return; - } - - /* This is a fake. It would be nice to know if the - * command was sent or not instead of pretending it was if - * we get this far. That would involve adding "sent" members - * to the xs so it could be set up down in the host adapter code. - */ - dsreq->ds_cmdsent = dsreq->ds_cmdlen; - - if (dsreq->ds_ret == 0) - dsreq->ds_ret = DSRT_OK; - - iodone(bp); /* Shouldn't this iodone be done in the interrupt? - */ - - return; -} - -void sgminphys(struct buf *bp) -{ -} - -int sgioctl(dev_t dev, int cmd, caddr_t addr, int f) -{ - int ret = 0; - int phys; - - switch(cmd) - { - case DS_ENTER: - { - dsreq_t *dsreq = (dsreq_t *)addr; - - int rwflag = (dsreq->ds_flags & DSRQ_READ) ? B_READ : B_WRITE; - - struct dsbuf dsbuf; - struct buf *bp = &dsbuf.buf; - - bzero(&dsbuf, sizeof(dsbuf)); - - dsbuf.dsreq = dsreq; - dsbuf.magic = DSBUF_MAGIC; - -#ifdef SCSI_PHYSADDR /* Physical memory addressing option */ - phys = (dsreq->ds_flags & DSRQ_PHYSADDR); -#else - phys = 0; -#endif - - if (phys) - { - bp->b_un.b_addr = dsreq->ds_databuf; - bp->b_bcount = dsreq->ds_datalen; - bp->b_dev = dev; - bp->b_flags = rwflag; - - sgstrategy(bp); - ret = bp->b_error; - } - else if (dsreq->ds_datalen) - { - struct uio uio; - struct iovec iovec; - - iovec.iov_base = dsreq->ds_databuf; - iovec.iov_len = dsreq->ds_datalen; - - uio.uio_offset = 0; - uio.uio_resid = dsreq->ds_datalen; - - uio.uio_segflg = UIO_USERSPACE; - uio.uio_procp = curproc; - uio.uio_rw = (rwflag == B_READ) ? UIO_READ : UIO_WRITE; - uio.uio_iov = &iovec; - uio.uio_iovcnt = 1; - -/* if ((ret = rawio(dev, &uio, bp)) == 0) - ret = bp->b_error; */ - } - else - { - bp->b_un.b_addr = 0; - bp->b_bcount = 0; - bp->b_dev = dev; - bp->b_flags = 0; - - sgstrategy(bp); - ret = bp->b_error; - } - - } - break; - - case DS_TARGET: - ret = sg_target(dev, *(int *)addr); - break; - - default: - ret = ENOTTY; - break; - } - - return ret; -} diff --git a/sys/arch/mac68k/scsi/st.c b/sys/arch/mac68k/scsi/st.c deleted file mode 100644 index 54e855f545de..000000000000 --- a/sys/arch/mac68k/scsi/st.c +++ /dev/null @@ -1,1810 +0,0 @@ -/* $NetBSD: st.c,v 1.6 1994/10/26 08:47:43 cgd Exp $ */ - -/* - * Written by Julian Elischer (julian@tfs.com)(now julian@DIALix.oz.au) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - * - * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * major changes by Julian Elischer (julian@jules.dialix.oz.au) May 1993 - */ - -/* - * To do: - * work out some better way of guessing what a good timeout is going - * to be depending on whether we expect to retension or not. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/* Defines for device specific stuff */ -#define PAGE_0_SENSE_DATA_SIZE 12 -#define DEF_FIXED_BSIZE 512 -#define ST_RETRIES 4 /* only on non IO commands */ - -#define STMODE(z) ( minor(z) & 0x03) -#define STDSTY(z) ((minor(z) >> 2) & 0x03) -#define STUNIT(z) ((minor(z) >> 4) ) -#define CTLMODE 3 - -#define SCSI_2_MAX_DENSITY_CODE 0x17 /* maximum density code specified - * in SCSI II spec. */ -/* - * Define various devices that we know mis-behave in some way, - * and note how they are bad, so we can correct for them - */ -struct modes { - u_int blksiz; - u_int quirks; /* same definitions as in rogues */ - char density; - char spare[3]; -}; - -struct rogues { - char *name; - char *manu; - char *model; - char *version; - u_int quirks; /* valid for all modes */ - struct modes modes[4]; -}; - -/* define behaviour codes (quirks) */ -#define ST_Q_NEEDS_PAGE_0 0x00001 -#define ST_Q_FORCE_FIXED_MODE 0x00002 -#define ST_Q_FORCE_VAR_MODE 0x00004 -#define ST_Q_SNS_HLP 0x00008 /* must do READ for good MODE SENSE */ -#define ST_Q_IGNORE_LOADS 0x00010 -#define ST_Q_BLKSIZ 0x00020 /* variable-block media_blksiz > 0 */ - -static struct rogues gallery[] = /* ends with an all-null entry */ -{ - {"Such an old device ", "pre-scsi", " unknown model ", "????", - 0, - { - {512, ST_Q_FORCE_FIXED_MODE, 0}, /* minor 0,1,2,3 */ - {512, ST_Q_FORCE_FIXED_MODE, QIC_24}, /* minor 4,5,6,7 */ - {0, ST_Q_FORCE_VAR_MODE, HALFINCH_1600}, /* minor 8,9,10,11 */ - {0, ST_Q_FORCE_VAR_MODE, HALFINCH_6250} /* minor 12,13,14,15 */ - } - }, - {"Tandberg tdc3600", "TANDBERG", " TDC 3600", "????", - ST_Q_NEEDS_PAGE_0, - { - {0, 0, 0}, /* minor 0,1,2,3 */ - {0, ST_Q_FORCE_VAR_MODE, QIC_525}, /* minor 4,5,6,7 */ - {0, 0, QIC_150}, /* minor 8,9,10,11 */ - {0, 0, QIC_120} /* minor 12,13,14,15 */ - } - }, - {"Rev 5 of the Archive 2525", "ARCHIVE ", "VIPER 2525 25462", "-005", - 0, - { - {0, ST_Q_SNS_HLP, 0}, /* minor 0,1,2,3 */ - {0, ST_Q_SNS_HLP, QIC_525}, /* minor 4,5,6,7 */ - {0, 0, QIC_150}, /* minor 8,9,10,11 */ - {0, 0, QIC_120} /* minor 12,13,14,15 */ - } - }, - {"Archive Viper 150", "ARCHIVE ", "VIPER 150", "????", - ST_Q_NEEDS_PAGE_0, - { - {0, 0, 0}, /* minor 0,1,2,3 */ - {0, 0, QIC_150}, /* minor 4,5,6,7 */ - {0, 0, QIC_120}, /* minor 8,9,10,11 */ - {0, 0, QIC_24} /* minor 12,13,14,15 */ - } - }, - {"Wangtek 5525ES", "WANGTEK ", "5525ES SCSI REV7", "????", - 0, - { - {0, 0, 0}, /* minor 0,1,2,3 */ - {0, ST_Q_BLKSIZ, QIC_525}, /* minor 4,5,6,7 */ - {0, 0, QIC_150}, /* minor 8,9,10,11 */ - {0, 0, QIC_120} /* minor 12,13,14,15 */ - } - }, - {"WangDAT model 1300", "WangDAT ", "Model 1300", "????", - 0, - { - {0, 0, 0}, /* minor 0,1,2,3 */ - {512, ST_Q_FORCE_FIXED_MODE, 0x13}, /* minor 4,5,6,7 */ - {1024, ST_Q_FORCE_FIXED_MODE, 0x13}, /* minor 8,9,10,11 */ - {0, ST_Q_FORCE_VAR_MODE, 0x13} /* minor 12,13,14,15 */ - } - }, - {(char *) 0} -}; - -#define NOEJECT 0 -#define EJECT 1 - -struct st_data { - struct device sc_dev; -/*--------------------present operating parameters, flags etc.----------------*/ - u_int flags; /* see below */ - u_int blksiz; /* blksiz we are using */ - u_int density; /* present density */ - u_int quirks; /* quirks for the open mode */ - u_int last_dsty; /* last density openned */ -/*--------------------device/scsi parameters----------------------------------*/ - struct scsi_link *sc_link; /* our link to the adpter etc. */ -/*--------------------parameters reported by the device ----------------------*/ - u_int blkmin; /* min blk size */ - u_int blkmax; /* max blk size */ - struct rogues *rogues; /* if we have a rogue entry */ -/*--------------------parameters reported by the device for this media--------*/ - u_int numblks; /* nominal blocks capacity */ - u_int media_blksiz; /* 0 if not ST_FIXEDBLOCKS */ - u_int media_density; /* this is what it said when asked */ -/*--------------------quirks for the whole drive------------------------------*/ - u_int drive_quirks; /* quirks of this drive */ -/*--------------------How we should set up when openning each minor device----*/ - struct modes modes[4]; /* plus more for each mode */ - u_int8 modeflags[4]; /* flags for the modes */ -#define DENSITY_SET_BY_USER 0x01 -#define DENSITY_SET_BY_QUIRK 0x02 -#define BLKSIZE_SET_BY_USER 0x04 -#define BLKSIZE_SET_BY_QUIRK 0x08 -/*--------------------storage for sense data returned by the drive------------*/ - unsigned char sense_data[12]; /* - * additional sense data needed - * for mode sense/select. - */ - struct buf *buf_queue; /* the queue of pending IO operations */ - struct scsi_xfer scsi_xfer; /* scsi xfer struct for this drive */ - u_int xfer_block_wait; /* is a process waiting? */ -}; - -void stattach __P((struct device *, struct device *, void *)); - -struct cfdriver stcd = -{ NULL, "st", scsi_targmatch, stattach, DV_TAPE, sizeof(struct st_data) }; - -int st_space __P((struct st_data *, int number, u_int what, u_int flags)); -int st_rewind __P((struct st_data *, boolean immed, u_int flags)); -int st_mode_sense __P((struct st_data *, u_int flags)); -int st_decide_mode __P((struct st_data *, boolean first_read)); -int st_rd_blk_lim __P((struct st_data *, u_int flags)); -int st_touch_tape __P((struct st_data *)); -int st_write_filemarks __P((struct st_data *, int number, u_int flags)); -int st_load __P((struct st_data *, u_int type, u_int flags)); -int st_mode_select __P((struct st_data *, u_int flags)); -void ststrategy(); -void stminphys(); -int st_chkeod(); -void ststart(); -void st_unmount(); -int st_mount_tape(); -void st_loadquirks(); -void st_identify_drive(); -int st_interpret_sense(); - -struct scsi_device st_switch = -{ - st_interpret_sense, - ststart, - NULL, - NULL, - "st", - 0 -}; - -#define ST_INITIALIZED 0x01 -#define ST_INFO_VALID 0x02 -#define ST_OPEN 0x04 -#define ST_BLOCK_SET 0x08 /* block size, mode set by ioctl */ -#define ST_WRITTEN 0x10 /* data have been written, EOD needed */ -#define ST_FIXEDBLOCKS 0x20 -#define ST_AT_FILEMARK 0x40 -#define ST_EIO_PENDING 0x80 /* we couldn't report it then (had data) */ -#define ST_NEW_MOUNT 0x100 /* still need to decide mode */ -#define ST_READONLY 0x200 /* st_mode_sense says write protected */ -#define ST_FM_WRITTEN 0x400 /* - * EOF file mark written -- used with - * ~ST_WRITTEN to indicate that multiple file - * marks have been written - */ -#define ST_BLANK_READ 0x800 /* BLANK CHECK encountered already */ -#define ST_2FM_AT_EOD 0x1000 /* write 2 file marks at EOD */ -#define ST_MOUNTED 0x2000 /* Device is presently mounted */ - -#define ST_PER_ACTION (ST_AT_FILEMARK | ST_EIO_PENDING | ST_BLANK_READ) -#define ST_PER_MOUNT (ST_INFO_VALID | ST_BLOCK_SET | ST_WRITTEN | \ - ST_FIXEDBLOCKS | ST_READONLY | \ - ST_FM_WRITTEN | ST_2FM_AT_EOD | ST_PER_ACTION) - -/* - * The routine called by the low level scsi routine when it discovers - * A device suitable for this driver - */ -void -stattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct st_data *st = (struct st_data *)self; - struct scsi_link *sc_link = aux; - - SC_DEBUG(sc_link, SDEV_DB2, ("stattach: ")); - - sc_link->device = &st_switch; - sc_link->dev_unit = st->sc_dev.dv_unit; - - /* - * Store information needed to contact our base driver - */ - st->sc_link = sc_link; - - /* - * Check if the drive is a known criminal and take - * Any steps needed to bring it into line - */ - st_identify_drive(st); - - /* - * Use the subdriver to request information regarding - * the drive. We cannot use interrupts yet, so the - * request must specify this. - */ - if (st_mode_sense(st, SCSI_NOSLEEP | SCSI_NOMASK | SCSI_SILENT)) { - printf(": drive offline\n"); - } else { - printf(": density code 0x%x, ", st->media_density); - if (!scsi_test_unit_ready(sc_link, SCSI_NOSLEEP | SCSI_NOMASK | SCSI_SILENT)) { - if (st->media_blksiz) - printf("%d-byte", st->media_blksiz); - else - printf("variable"); - printf(" blocks, write-%s\n", - (st->flags & ST_READONLY) ? "protected" : "enabled"); - } else { - printf("drive empty\n"); - } - } - - /* - * Set up the buf queue for this device - */ - st->buf_queue = 0; - st->flags |= ST_INITIALIZED; -} - -/* - * Use the inquiry routine in 'scsi_base' to get drive info so we can - * Further tailor our behaviour. - */ -void -st_identify_drive(st) - struct st_data *st; -{ - struct scsi_inquiry_data inqbuf; - struct rogues *finger; - char manu[32]; - char model[32]; - char model2[32]; - char version[32]; - u_int model_len; - - /* - * Get the device type information - */ - if (scsi_inquire(st->sc_link, &inqbuf, - SCSI_NOSLEEP | SCSI_NOMASK | SCSI_SILENT) != 0) { - printf("%s: couldn't get device type, using default\n", - st->sc_dev.dv_xname); - return; - } - if ((inqbuf.version & SID_ANSII) == 0) { - /* - * If not advanced enough, use default values - */ - strncpy(manu, "pre-scsi", 8); - manu[8] = 0; - strncpy(model, " unknown model ", 16); - model[16] = 0; - strncpy(version, "????", 4); - version[4] = 0; - } else { - strncpy(manu, inqbuf.vendor, 8); - manu[8] = 0; - strncpy(model, inqbuf.product, 16); - model[16] = 0; - strncpy(version, inqbuf.revision, 4); - version[4] = 0; - } - - /* - * Load the parameters for this kind of device, so we - * treat it as appropriate for each operating mode. - * Only check the number of characters in the array's - * model entry, not the entire model string returned. - */ - finger = gallery; - while (finger->name) { - model_len = 0; - while (finger->model[model_len] && (model_len < 32)) { - model2[model_len] = model[model_len]; - model_len++; - } - model2[model_len] = 0; - if ((strcmp(manu, finger->manu) == 0) - && (strcmp(model2, finger->model) == 0 || - strcmp("????????????????", finger->model) == 0) - && (strcmp(version, finger->version) == 0 || - strcmp("????", finger->version) == 0)) { - printf("%s: %s is a known rogue\n", - st->sc_dev.dv_xname, finger->name); - st->rogues = finger; - st->drive_quirks = finger->quirks; - st->quirks = finger->quirks; /*start value */ - st_loadquirks(st); - break; - } else { - finger++; /* go to next suspect */ - } - } -} - -/* - * initialise the subdevices to the default (QUIRK) state. - * this will remove any setting made by the system operator or previous - * operations. - */ -void -st_loadquirks(st) - struct st_data *st; -{ - int i; - struct modes *mode; - struct modes *mode2; - - if (!st->rogues) - return; - mode = st->rogues->modes; - mode2 = st->modes; - for (i = 0; i < 4; i++) { - bzero(mode2, sizeof(struct modes)); - st->modeflags[i] &= ~(BLKSIZE_SET_BY_QUIRK - | DENSITY_SET_BY_QUIRK - | BLKSIZE_SET_BY_USER - | DENSITY_SET_BY_USER); - if (mode->blksiz && ((mode->quirks | st->drive_quirks) - & (ST_Q_FORCE_FIXED_MODE))) { - mode2->blksiz = mode->blksiz; - st->modeflags[i] |= BLKSIZE_SET_BY_QUIRK; - } else { - if ((mode->quirks | st->drive_quirks) - & ST_Q_FORCE_VAR_MODE) { - mode2->blksiz = 0; - st->modeflags[i] |= BLKSIZE_SET_BY_QUIRK; - } - } - if (mode->density) { - mode2->density = mode->density; - st->modeflags[i] |= DENSITY_SET_BY_QUIRK; - } - mode++; - mode2++; - } -} - -/* - * open the device. - */ -int -stopen(dev, flags) - dev_t dev; - u_int flags; -{ - int unit; - u_int mode, dsty; - int error = 0; - struct st_data *st; - struct scsi_link *sc_link; - - unit = STUNIT(dev); - mode = STMODE(dev); - dsty = STDSTY(dev); - - if (unit >= stcd.cd_ndevs) - return ENXIO; - st = stcd.cd_devs[unit]; - if (!st || !(st->flags & ST_INITIALIZED)) - return ENXIO; - - sc_link = st->sc_link; - SC_DEBUG(sc_link, SDEV_DB1, ("open: dev=0x%x (unit %d (of %d))\n", - dev, unit, stcd.cd_ndevs)); - - if (st->flags & ST_OPEN) - return EBUSY; - - /* - * Throw out a dummy instruction to catch 'Unit attention - * errors (the error handling will invalidate all our - * device info if we get one, but otherwise, ignore it) - */ - scsi_test_unit_ready(sc_link, SCSI_SILENT); - - sc_link->flags |= SDEV_OPEN; /* unit attn are now errors */ - /* - * If the mode is 3 (e.g. minor = 3,7,11,15) - * then the device has been openned to set defaults - * This mode does NOT ALLOW I/O, only ioctls - */ - if (mode == CTLMODE) - return 0; - - /* - * Check that the device is ready to use (media loaded?) - * This time take notice of the return result - */ - if (error = (scsi_test_unit_ready(sc_link, 0))) { - printf("%s: not ready\n", st->sc_dev.dv_xname); - st_unmount(st, NOEJECT); - return error; - } - - /* - * if it's a different mode, or if the media has been - * invalidated, unmount the tape from the previous - * session but continue with open processing - */ - if ((st->last_dsty != dsty) - || (!(sc_link->flags & SDEV_MEDIA_LOADED))) { - st_unmount(st, NOEJECT); - } - - /* - * If we are not mounted, then we should start a new - * mount session. - */ - if (!(st->flags & ST_MOUNTED)) { - st_mount_tape(dev, flags); - st->last_dsty = dsty; - } - - /* - * Make sure that a tape opened in write-only mode will have - * file marks written on it when closed, even if not written to. - * This is for SUN compatibility - */ - if ((flags & O_ACCMODE) == FWRITE) - st->flags |= ST_WRITTEN; - - SC_DEBUG(sc_link, SDEV_DB2, ("Open complete\n")); - - st->flags |= ST_OPEN; - return 0; -} - -/* - * close the device.. only called if we are the LAST - * occurence of an open device - */ -int -stclose(dev) - dev_t dev; -{ - int unit, mode; - struct st_data *st; - struct scsi_link *sc_link; - - unit = STUNIT(dev); - mode = STMODE(dev); - st = stcd.cd_devs[unit]; - sc_link = st->sc_link; - - SC_DEBUG(sc_link, SDEV_DB1, ("closing\n")); - if ((st->flags & (ST_WRITTEN | ST_FM_WRITTEN)) == ST_WRITTEN) - st_write_filemarks(st, 1, 0); - switch (mode & 0x3) { - case 0: - case 3: /* for now */ - st_unmount(st, NOEJECT); - break; - case 1: /*leave mounted unless media seems to have been removed */ - if (!(sc_link->flags & SDEV_MEDIA_LOADED)) { - st_unmount(st, NOEJECT); - } - break; - case 2: - st_unmount(st, EJECT); - break; - } - sc_link->flags &= ~SDEV_OPEN; - st->flags &= ~ST_OPEN; - return 0; -} - -/* - * Start a new mount session. - * Copy in all the default parameters from the selected device mode. - * and try guess any that seem to be defaulted. - */ -int -st_mount_tape(dev, flags) - dev_t dev; - u_int flags; -{ - int unit; - u_int mode, dsty; - struct st_data *st; - struct scsi_link *sc_link; - int error = 0; - - unit = STUNIT(dev); - mode = STMODE(dev); - dsty = STDSTY(dev); - st = stcd.cd_devs[unit]; - sc_link = st->sc_link; - - if (st->flags & ST_MOUNTED) - return 0; - - SC_DEBUG(sc_link, SDEV_DB1, ("mounting\n ")); - st->flags |= ST_NEW_MOUNT; - st->quirks = st->drive_quirks | st->modes[dsty].quirks; - /* - * If the media is new, then make sure we give it a chance to - * to do a 'load' instruction. (We assume it is new.) - */ - if (error = st_load(st, LD_LOAD, 0)) - return error; - /* - * Throw another dummy instruction to catch - * 'Unit attention' errors. Some drives appear to give - * these after doing a Load instruction. - * (noteably some DAT drives) - */ - scsi_test_unit_ready(sc_link, SCSI_SILENT); - - /* - * Some devices can't tell you much until they have been - * asked to look at the media. This quirk does this. - */ - if (st->quirks & ST_Q_SNS_HLP) - if (error = st_touch_tape(st)) - return error; - /* - * Load the physical device parameters - * loads: blkmin, blkmax - */ - if (error = st_rd_blk_lim(st, 0)) - return error; - /* - * Load the media dependent parameters - * includes: media_blksiz,media_density,numblks - * As we have a tape in, it should be reflected here. - * If not you may need the "quirk" above. - */ - if (error = st_mode_sense(st, 0)) - return error; - /* - * If we have gained a permanent density from somewhere, - * then use it in preference to the one supplied by - * default by the driver. - */ - if (st->modeflags[dsty] & (DENSITY_SET_BY_QUIRK | DENSITY_SET_BY_USER)) - st->density = st->modes[dsty].density; - else - st->density = st->media_density; - /* - * If we have gained a permanent blocksize - * then use it in preference to the one supplied by - * default by the driver. - */ - st->flags &= ~ST_FIXEDBLOCKS; - if (st->modeflags[dsty] & (BLKSIZE_SET_BY_QUIRK | BLKSIZE_SET_BY_USER)) { - st->blksiz = st->modes[dsty].blksiz; - if (st->blksiz) - st->flags |= ST_FIXEDBLOCKS; - } else { - if (error = st_decide_mode(st, FALSE)) - return error; - } - if (error = st_mode_select(st, 0)) { - printf("%s: cannot set selected mode\n", st->sc_dev.dv_xname); - return error; - } - scsi_prevent(sc_link, PR_PREVENT, 0); /* who cares if it fails? */ - st->flags &= ~ST_NEW_MOUNT; - st->flags |= ST_MOUNTED; - sc_link->flags |= SDEV_MEDIA_LOADED; /* move earlier? */ - - return 0; -} - -/* - * End the present mount session. - * Rewind, and optionally eject the tape. - * Reset various flags to indicate that all new - * operations require another mount operation - */ -void -st_unmount(st, eject) - struct st_data *st; - boolean eject; -{ - struct scsi_link *sc_link = st->sc_link; - int nmarks; - - if (!(st->flags & ST_MOUNTED)) - return; - SC_DEBUG(sc_link, SDEV_DB1, ("unmounting\n")); - st_chkeod(st, FALSE, &nmarks, SCSI_SILENT); - st_rewind(st, FALSE, SCSI_SILENT); - scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT); - if (eject) - st_load(st, LD_UNLOAD, SCSI_SILENT); - st->flags &= ~(ST_MOUNTED | ST_NEW_MOUNT); - sc_link->flags &= ~SDEV_MEDIA_LOADED; -} - -/* - * Given all we know about the device, media, mode, 'quirks' and - * initial operation, make a decision as to how we should be set - * to run (regarding blocking and EOD marks) - */ -int -st_decide_mode(st, first_read) - struct st_data *st; - boolean first_read; -{ -#ifdef SCSIDEBUG - struct scsi_link *sc_link = st->sc_link; -#endif - - SC_DEBUG(sc_link, SDEV_DB2, ("starting block mode decision\n")); - - /* - * If the user hasn't already specified fixed or variable-length - * blocks and the block size (zero if variable-length), we'll - * have to try to figure them out ourselves. - * - * Our first shot at a method is, "The quirks made me do it!" - */ - switch (st->quirks & (ST_Q_FORCE_FIXED_MODE | ST_Q_FORCE_VAR_MODE)) { - case (ST_Q_FORCE_FIXED_MODE | ST_Q_FORCE_VAR_MODE): - printf("%s: bad quirks\n", st->sc_dev.dv_xname); - return EINVAL; - case ST_Q_FORCE_FIXED_MODE: /*specified fixed, but not what size */ - st->flags |= ST_FIXEDBLOCKS; - if (st->blkmin && (st->blkmin == st->blkmax)) - st->blksiz = st->blkmin; - else if (st->media_blksiz > 0) - st->blksiz = st->media_blksiz; - else - st->blksiz = DEF_FIXED_BSIZE; - SC_DEBUG(sc_link, SDEV_DB3, ("Quirks force fixed mode(%d)\n", - st->blksiz)); - goto done; - case ST_Q_FORCE_VAR_MODE: - st->flags &= ~ST_FIXEDBLOCKS; - st->blksiz = 0; - SC_DEBUG(sc_link, SDEV_DB3, ("Quirks force variable mode\n")); - goto done; - } - /* - * If the drive can only handle fixed-length blocks and only at - * one size, perhaps we should just do that. - */ - if (st->blkmin && (st->blkmin == st->blkmax)) { - st->flags |= ST_FIXEDBLOCKS; - st->blksiz = st->blkmin; - SC_DEBUG(sc_link, SDEV_DB3, - ("blkmin == blkmax of %d\n", st->blkmin)); - goto done; - } - /* - * If the tape density mandates (or even suggests) use of fixed - * or variable-length blocks, comply. - */ - switch (st->density) { - case HALFINCH_800: - case HALFINCH_1600: - case HALFINCH_6250: - case DDS: - st->flags &= ~ST_FIXEDBLOCKS; - st->blksiz = 0; - SC_DEBUG(sc_link, SDEV_DB3, ("density specified variable\n")); - goto done; - case QIC_11: - case QIC_24: - case QIC_120: - case QIC_150: - case QIC_525: - case QIC_1320: - st->flags |= ST_FIXEDBLOCKS; - if (st->media_blksiz > 0) - st->blksiz = st->media_blksiz; - else - st->blksiz = DEF_FIXED_BSIZE; - SC_DEBUG(sc_link, SDEV_DB3, ("density specified fixed\n")); - goto done; - } - /* - * If we're about to read the tape, perhaps we should choose - * fixed or variable-length blocks and block size according to - * what the drive found on the tape. - */ - if (first_read - && (!(st->quirks & ST_Q_BLKSIZ) - || (st->media_blksiz == 0) - || (st->media_blksiz == DEF_FIXED_BSIZE) - || (st->media_blksiz == 1024))) { - if (st->media_blksiz == 0) - st->flags &= ~ST_FIXEDBLOCKS; - else - st->flags |= ST_FIXEDBLOCKS; - st->blksiz = st->media_blksiz; - SC_DEBUG(sc_link, SDEV_DB3, - ("Used media_blksiz of %d\n", st->media_blksiz)); - goto done; - } - /* - * We're getting no hints from any direction. Choose variable- - * length blocks arbitrarily. - */ - st->flags &= ~ST_FIXEDBLOCKS; - st->blksiz = 0; - SC_DEBUG(sc_link, SDEV_DB3, ("Give up and default to variable mode\n")); -done: - - /* - * Decide whether or not to write two file marks to signify end- - * of-data. Make the decision as a function of density. If - * the decision is not to use a second file mark, the SCSI BLANK - * CHECK condition code will be recognized as end-of-data when - * first read. - * (I think this should be a by-product of fixed/variable..julian) - */ - switch (st->density) { -/* case 8 mm: What is the SCSI density code for 8 mm, anyway? */ - case QIC_11: - case QIC_24: - case QIC_120: - case QIC_150: - case QIC_525: - case QIC_1320: - st->flags &= ~ST_2FM_AT_EOD; - break; - default: - st->flags |= ST_2FM_AT_EOD; - } - return 0; -} - -/* - * trim the size of the transfer if needed, - * called by physio - * basically the smaller of our min and the scsi driver's - * minphys - */ -void -stminphys(bp) - struct buf *bp; -{ - register struct st_data *st = stcd.cd_devs[STUNIT(bp->b_dev)]; - - (st->sc_link->adapter->scsi_minphys) (bp); -} - -/* - * Actually translate the requested transfer into - * one the physical driver can understand - * The transfer is described by a buf and will include - * only one physical transfer. - */ -void -ststrategy(bp) - struct buf *bp; -{ - struct buf **dp; - int unit; - int opri; - struct st_data *st; - - unit = STUNIT(bp->b_dev); - st = stcd.cd_devs[unit]; - SC_DEBUG(st->sc_link, SDEV_DB1, - (" strategy: %d bytes @ blk%d\n", bp->b_bcount, bp->b_blkno)); - /* - * If it's a null transfer, return immediatly - */ - if (bp->b_bcount == 0) { - goto done; - } - /* - * Odd sized request on fixed drives are verboten - */ - if (st->flags & ST_FIXEDBLOCKS) { - if (bp->b_bcount % st->blksiz) { - printf("%s: bad request, must be multiple of %d\n", - st->sc_dev.dv_xname, st->blksiz); - bp->b_error = EIO; - goto bad; - } - } - /* - * as are out-of-range requests on variable drives. - */ - else if (bp->b_bcount < st->blkmin || bp->b_bcount > st->blkmax) { - printf("%s: bad request, must be between %d and %d\n", - st->sc_dev.dv_xname, st->blkmin, st->blkmax); - bp->b_error = EIO; - goto bad; - } - stminphys(bp); - opri = splbio(); - - /* - * Place it in the queue of activities for this tape - * at the end (a bit silly because we only have on user.. - * (but it could fork())) - */ - dp = &(st->buf_queue); - while (*dp) { - dp = &((*dp)->b_actf); - } - *dp = bp; - bp->b_actf = NULL; - - /* - * Tell the device to get going on the transfer if it's - * not doing anything, otherwise just wait for completion - * (All a bit silly if we're only allowing 1 open but..) - */ - ststart(unit); - - splx(opri); - return; -bad: - bp->b_flags |= B_ERROR; -done: - /* - * Correctly set the buf to indicate a completed xfer - */ - iodone(bp); - return; -} - -/* - * ststart looks to see if there is a buf waiting for the device - * and that the device is not already busy. If both are true, - * It dequeues the buf and creates a scsi command to perform the - * transfer required. The transfer request will call scsi_done - * on completion, which will in turn call this routine again - * so that the next queued transfer is performed. - * The bufs are queued by the strategy routine (ststrategy) - * - * This routine is also called after other non-queued requests - * have been made of the scsi driver, to ensure that the queue - * continues to be drained. - * ststart() is called at splbio - */ -void -ststart(unit) - int unit; -{ - struct st_data *st = stcd.cd_devs[unit]; - struct scsi_link *sc_link = st->sc_link; - register struct buf *bp = 0; - struct scsi_rw_tape cmd; - u_int flags; - - SC_DEBUG(sc_link, SDEV_DB2, ("ststart ")); - /* - * See if there is a buf to do and we are not already - * doing one - */ - while (sc_link->opennings != 0) { - - /* if a special awaits, let it proceed first */ - if (sc_link->flags & SDEV_WAITING) { - wakeup((caddr_t)sc_link); - return; - } - if ((bp = st->buf_queue) == NULL) - return; /* no work to bother with */ - st->buf_queue = bp->b_actf; - - /* - * if the device has been unmounted byt the user - * then throw away all requests until done - */ - if ((!(st->flags & ST_MOUNTED)) - || (!(sc_link->flags & SDEV_MEDIA_LOADED))) { - /* make sure that one implies the other.. */ - sc_link->flags &= ~SDEV_MEDIA_LOADED; - goto badnews; - } - /* - * only FIXEDBLOCK devices have pending operations - */ - if (st->flags & ST_FIXEDBLOCKS) { - /* - * If we are at a filemark but have not reported it yet - * then we should report it now - */ - if (st->flags & ST_AT_FILEMARK) { - if ((bp->b_flags & B_READ) == B_WRITE) { - /* - * Handling of ST_AT_FILEMARK in - * st_space will fill in the right file - * mark count. - * Back up over filemark - */ - if (st_space(st, 0, SP_FILEMARKS, 0)) - goto badnews; - } else { - bp->b_resid = bp->b_bcount; - bp->b_error = 0; - bp->b_flags &= ~B_ERROR; - st->flags &= ~ST_AT_FILEMARK; - biodone(bp); - continue; /* seek more work */ - } - } - /* - * If we are at EIO (e.g. EOM) but have not reported it - * yet then we should report it now - */ - if (st->flags & ST_EIO_PENDING) { - bp->b_resid = bp->b_bcount; - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - st->flags &= ~ST_EIO_PENDING; - biodone(bp); - continue; /* seek more work */ - } - } - /* - * Fill out the scsi command - */ - bzero(&cmd, sizeof(cmd)); - if ((bp->b_flags & B_READ) == B_WRITE) { - cmd.op_code = WRITE_COMMAND_TAPE; - st->flags &= ~ST_FM_WRITTEN; - st->flags |= ST_WRITTEN; - flags = SCSI_DATA_OUT; - } else { - cmd.op_code = READ_COMMAND_TAPE; - flags = SCSI_DATA_IN; - } - /* - * Handle "fixed-block-mode" tape drives by using the - * block count instead of the length. - */ - if (st->flags & ST_FIXEDBLOCKS) { - cmd.byte2 |= SRWT_FIXED; - lto3b(bp->b_bcount / st->blksiz, cmd.len); - } else { - lto3b(bp->b_bcount, cmd.len); - } - /* - * go ask the adapter to do all this for us - */ - if (scsi_scsi_cmd(sc_link, (struct scsi_generic *) &cmd, - sizeof(cmd), (u_char *) bp->b_un.b_addr, - bp->b_bcount, 0, 100000, bp, - flags | SCSI_NOSLEEP) - != SUCCESSFULLY_QUEUED) { -badnews: - printf("%s: not queued\n", st->sc_dev.dv_xname); - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - biodone(bp); - } - } /* go back and see if we can cram more work in.. */ -} - -/* - * Perform special action on behalf of the user; - * knows about the internals of this device - */ -int -stioctl(dev, cmd, arg, flag) - dev_t dev; - int cmd; - caddr_t arg; - int flag; -{ - int error = 0; - int unit; - int number, nmarks, dsty; - u_int flags; - struct st_data *st; - u_int hold_blksiz; - u_int hold_density; - struct mtop *mt = (struct mtop *) arg; - - /* - * Find the device that the user is talking about - */ - flags = 0; /* give error messages, act on errors etc. */ - unit = STUNIT(dev); - dsty = STDSTY(dev); - st = stcd.cd_devs[unit]; - hold_blksiz = st->blksiz; - hold_density = st->density; - - switch (cmd) { - - case MTIOCGET: { - struct mtget *g = (struct mtget *) arg; - - SC_DEBUG(st->sc_link, SDEV_DB1, ("[ioctl: get status]\n")); - bzero(g, sizeof(struct mtget)); - g->mt_type = 0x7; /* Ultrix compat *//*? */ - g->mt_density = st->density; - g->mt_blksiz = st->blksiz; - g->mt_mdensity[0] = st->modes[0].density; - g->mt_mdensity[1] = st->modes[1].density; - g->mt_mdensity[2] = st->modes[2].density; - g->mt_mdensity[3] = st->modes[3].density; - g->mt_mblksiz[0] = st->modes[0].blksiz; - g->mt_mblksiz[1] = st->modes[1].blksiz; - g->mt_mblksiz[2] = st->modes[2].blksiz; - g->mt_mblksiz[3] = st->modes[3].blksiz; - break; - } - case MTIOCTOP: { - - SC_DEBUG(st->sc_link, SDEV_DB1, ("[ioctl: op=0x%x count=0x%x]\n", - mt->mt_op, mt->mt_count)); - - /* compat: in U*x it is a short */ - number = mt->mt_count; - switch ((short) (mt->mt_op)) { - case MTWEOF: /* write an end-of-file record */ - error = st_write_filemarks(st, number, flags); - break; - case MTBSF: /* backward space file */ - number = -number; - case MTFSF: /* forward space file */ - error = st_chkeod(st, FALSE, &nmarks, flags); - if (!error) - error = st_space(st, number - nmarks, - SP_FILEMARKS, flags); - break; - case MTBSR: /* backward space record */ - number = -number; - case MTFSR: /* forward space record */ - error = st_chkeod(st, TRUE, &nmarks, flags); - if (!error) - error = st_space(st, number, SP_BLKS, flags); - break; - case MTREW: /* rewind */ - error = st_rewind(st, FALSE, flags); - break; - case MTOFFL: /* rewind and put the drive offline */ - st_unmount(st, EJECT); - break; - case MTNOP: /* no operation, sets status only */ - case MTCACHE: /* enable controller cache */ - case MTNOCACHE: /* disable controller cache */ - break; - case MTSETBSIZ: /* Set block size for device */ -#ifdef NOTYET - if (!(st->flags & ST_NEW_MOUNT)) { - uprintf("re-mount tape before changing blocksize"); - error = EINVAL; - break; - } -#endif - if (number == 0) { - st->flags &= ~ST_FIXEDBLOCKS; - } else { - if ((st->blkmin || st->blkmax) /* they exist */ - &&((number < st->blkmin - || number > st->blkmax))) { - error = EINVAL; - break; - } - st->flags |= ST_FIXEDBLOCKS; - } - st->blksiz = number; - st->flags |= ST_BLOCK_SET; /*XXX */ - goto try_new_value; - - case MTSETDNSTY: /* Set density for device and mode */ - if (number > SCSI_2_MAX_DENSITY_CODE) - error = EINVAL; - else - st->density = number; - goto try_new_value; - - default: - error = EINVAL; - } - break; - } - case MTIOCIEOT: - case MTIOCEEOT: - break; - default: - if (STMODE(dev) == CTLMODE) - error = scsi_do_ioctl(st->sc_link,cmd,arg,flag); - else - error = ENOTTY; - break; - } - return error; -/*-----------------------------*/ -try_new_value: - /* - * Check that the mode being asked for is aggreeable to the - * drive. If not, put it back the way it was. - */ - if (error = st_mode_select(st, 0)) { /* put it back as it was */ - printf("%s: cannot set selected mode\n", st->sc_dev.dv_xname); - st->density = hold_density; - st->blksiz = hold_blksiz; - if (st->blksiz) - st->flags |= ST_FIXEDBLOCKS; - else - st->flags &= ~ST_FIXEDBLOCKS; - return error; - } - /* - * As the drive liked it, if we are setting a new default, - * set it into the structures as such. - * - * The means for deciding this are not finalised yet - */ - if (STMODE(dev) == 0x03) { - /* special mode */ - /* XXX */ - switch ((short) (mt->mt_op)) { - case MTSETBSIZ: - st->modes[dsty].blksiz = st->blksiz; - st->modeflags[dsty] |= BLKSIZE_SET_BY_USER; - break; - case MTSETDNSTY: - st->modes[dsty].density = st->density; - st->modeflags[dsty] |= DENSITY_SET_BY_USER; - break; - } - } - return 0; -} - -/* - * Do a synchronous read. - */ -int -st_read(st, buf, size, flags) - struct st_data *st; - u_int size; - u_int flags; - char *buf; -{ - struct scsi_rw_tape scsi_cmd; - - /* - * If it's a null transfer, return immediatly - */ - if (size == 0) - return 0; - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = READ_COMMAND_TAPE; - if (st->flags & ST_FIXEDBLOCKS) { - scsi_cmd.byte2 |= SRWT_FIXED; - lto3b(size / (st->blksiz ? st->blksiz : DEF_FIXED_BSIZE), - scsi_cmd.len); - } else { - lto3b(size, scsi_cmd.len); - } - return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), (u_char *) buf, size, 0, 100000, - NULL, flags | SCSI_DATA_IN); -} - -#ifdef __STDC__ -#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0) -#else -#define b2tol(a) (((unsigned)(a/**/_1) << 8) + (unsigned)a/**/_0) -#endif - -/* - * Ask the drive what it's min and max blk sizes are. - */ -int -st_rd_blk_lim(st, flags) - struct st_data *st; - u_int flags; -{ - struct scsi_blk_limits scsi_cmd; - struct scsi_blk_limits_data scsi_blkl; - int error; - struct scsi_link *sc_link = st->sc_link; - - /* - * First check if we have it all loaded - */ - if ((sc_link->flags & SDEV_MEDIA_LOADED)) - return 0; - - /* - * do a 'Read Block Limits' - */ - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = READ_BLK_LIMITS; - - /* - * do the command, update the global values - */ - if (error = scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), (u_char *) & scsi_blkl, - sizeof(scsi_blkl), ST_RETRIES, 5000, NULL, - flags | SCSI_DATA_IN)) - return error; - - st->blkmin = b2tol(scsi_blkl.min_length); - st->blkmax = _3btol(&scsi_blkl.max_length_2); - - SC_DEBUG(sc_link, SDEV_DB3, - ("(%d <= blksiz <= %d)\n", st->blkmin, st->blkmax)); - return 0; -} - -/* - * Get the scsi driver to send a full inquiry to the - * device and use the results to fill out the global - * parameter structure. - * - * called from: - * attach - * open - * ioctl (to reset original blksize) - */ -int -st_mode_sense(st, flags) - struct st_data *st; - u_int flags; -{ - u_int scsi_sense_len; - int error; - char *scsi_sense_ptr; - struct scsi_mode_sense scsi_cmd; - struct scsi_sense { - struct scsi_mode_header header; - struct blk_desc blk_desc; - } scsi_sense; - - struct scsi_sense_page_0 { - struct scsi_mode_header header; - struct blk_desc blk_desc; - unsigned char sense_data[PAGE_0_SENSE_DATA_SIZE]; - /* Tandberg tape drives returns page 00 - * with the sense data, whether or not - * you want it (ie the don't like you - * saying you want anything less!!!!!) - * They also expect page 00 - * back when you issue a mode select - */ - } scsi_sense_page_0; - struct scsi_link *sc_link = st->sc_link; - - /* - * Define what sort of structure we're working with - */ - if (st->quirks & ST_Q_NEEDS_PAGE_0) { - scsi_sense_len = sizeof(scsi_sense_page_0); - scsi_sense_ptr = (char *) &scsi_sense_page_0; - } else { - scsi_sense_len = sizeof(scsi_sense); - scsi_sense_ptr = (char *) &scsi_sense; - } - /* - * Set up a mode sense - */ - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = MODE_SENSE; - scsi_cmd.length = scsi_sense_len; - - /* - * do the command, but we don't need the results - * just print them for our interest's sake, if asked, - * or if we need it as a template for the mode select - * store it away. - */ - if (error = scsi_scsi_cmd(sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), (u_char *) scsi_sense_ptr, - scsi_sense_len, ST_RETRIES, 5000, NULL, - flags | SCSI_DATA_IN)) - return error; - - st->numblks = _3btol(((struct scsi_sense *)scsi_sense_ptr)->blk_desc.nblocks); - st->media_blksiz = _3btol(((struct scsi_sense *)scsi_sense_ptr)->blk_desc.blklen); - st->media_density = ((struct scsi_sense *) scsi_sense_ptr)->blk_desc.density; - if (((struct scsi_sense *) scsi_sense_ptr)->header.dev_spec & - SMH_DSP_WRITE_PROT) { - st->flags |= ST_READONLY; - } - SC_DEBUG(sc_link, SDEV_DB3, - ("density code 0x%x, %d-byte blocks, write-%s, ", - st->media_density, st->media_blksiz, - st->flags & ST_READONLY ? "protected" : "enabled")); - SC_DEBUG(sc_link, SDEV_DB3, - ("%sbuffered\n", - ((struct scsi_sense *) scsi_sense_ptr)->header.dev_spec - & SMH_DSP_BUFF_MODE ? "" : "un")); - if (st->quirks & ST_Q_NEEDS_PAGE_0) { - bcopy(((struct scsi_sense_page_0 *) scsi_sense_ptr)->sense_data, - st->sense_data, - sizeof(((struct scsi_sense_page_0 *) scsi_sense_ptr)->sense_data)); - } - sc_link->flags |= SDEV_MEDIA_LOADED; - return 0; -} - -/* - * Send a filled out parameter structure to the drive to - * set it into the desire modes etc. - */ -int -st_mode_select(st, flags) - struct st_data *st; - u_int flags; -{ - u_int dat_len; - char *dat_ptr; - struct scsi_mode_select scsi_cmd; - struct dat { - struct scsi_mode_header header; - struct blk_desc blk_desc; - } dat; - struct dat_page_0 { - struct scsi_mode_header header; - struct blk_desc blk_desc; - unsigned char sense_data[PAGE_0_SENSE_DATA_SIZE]; - } dat_page_0; - - /* - * Define what sort of structure we're working with - */ - if (st->quirks & ST_Q_NEEDS_PAGE_0) { - dat_len = sizeof(dat_page_0); - dat_ptr = (char *) &dat_page_0; - } else { - dat_len = sizeof(dat); - dat_ptr = (char *) &dat; - } - /* - * Set up for a mode select - */ - bzero(dat_ptr, dat_len); - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = MODE_SELECT; - scsi_cmd.length = dat_len; - ((struct dat *) dat_ptr)->header.blk_desc_len = sizeof(struct blk_desc); - ((struct dat *) dat_ptr)->header.dev_spec |= SMH_DSP_BUFF_MODE_ON; - ((struct dat *) dat_ptr)->blk_desc.density = st->density; - if (st->flags & ST_FIXEDBLOCKS) - lto3b(st->blksiz, ((struct dat *) dat_ptr)->blk_desc.blklen); - if (st->quirks & ST_Q_NEEDS_PAGE_0) { - bcopy(st->sense_data, ((struct dat_page_0 *) dat_ptr)->sense_data, - sizeof(((struct dat_page_0 *) dat_ptr)->sense_data)); - /* the Tandberg tapes need the block size to */ - /* be set on each mode sense/select. */ - } - /* - * do the command - */ - return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), (u_char *) dat_ptr, dat_len, - ST_RETRIES, 5000, NULL, flags | SCSI_DATA_OUT); -} - -/* - * skip N blocks/filemarks/seq filemarks/eom - */ -int -st_space(st, number, what, flags) - struct st_data *st; - u_int what; - u_int flags; - int number; -{ - int error; - struct scsi_space scsi_cmd; - - switch (what) { - case SP_BLKS: - if (st->flags & ST_PER_ACTION) { - if (number > 0) { - st->flags &= ~ST_PER_ACTION; - return EIO; - } else if (number < 0) { - if (st->flags & ST_AT_FILEMARK) { - /* - * Handling of ST_AT_FILEMARK - * in st_space will fill in the - * right file mark count. - */ - error = st_space(st, 0, SP_FILEMARKS, - flags); - if (error) - return error; - } - if (st->flags & ST_BLANK_READ) { - st->flags &= ~ST_BLANK_READ; - return EIO; - } - st->flags &= ~ST_EIO_PENDING; - } - } - break; - case SP_FILEMARKS: - if (st->flags & ST_EIO_PENDING) { - if (number > 0) { /* pretend we just discover the error */ - st->flags &= ~ST_EIO_PENDING; - return EIO; - } else if (number < 0) { /* back away from the error */ - st->flags &= ~ST_EIO_PENDING; - } - } - if (st->flags & ST_AT_FILEMARK) { - st->flags &= ~ST_AT_FILEMARK; - number--; - } - if ((st->flags & ST_BLANK_READ) && (number < 0)) { /* back away from unwritten tape */ - st->flags &= ~ST_BLANK_READ; - number++; /* dubious */ - } - } - if (number == 0) - return 0; - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = SPACE; - scsi_cmd.byte2 = what & SS_CODE; - lto3b(number, scsi_cmd.number); - return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), 0, 0, 0, 600000, NULL, flags); -} - -/* - * write N filemarks - */ -int -st_write_filemarks(st, number, flags) - struct st_data *st; - u_int flags; - int number; -{ - struct scsi_write_filemarks scsi_cmd; - - /* - * It's hard to write a negative number of file marks. - * Don't try. - */ - if (number < 0) - return EINVAL; - switch (number) { - case 0: /* really a command to sync the drive's buffers */ - break; - case 1: - if (st->flags & ST_FM_WRITTEN) /* already have one down */ - st->flags &= ~ST_WRITTEN; - else - st->flags |= ST_FM_WRITTEN; - st->flags &= ~ST_PER_ACTION; - break; - default: - st->flags &= ~(ST_PER_ACTION | ST_WRITTEN); - } - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = WRITE_FILEMARKS; - lto3b(number, scsi_cmd.number); - return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), 0, 0, 0, 100000, NULL, flags); -} - -/* - * Make sure the right number of file marks is on tape if the - * tape has been written. If the position argument is true, - * leave the tape positioned where it was originally. - * - * nmarks returns the number of marks to skip (or, if position - * true, which were skipped) to get back original position. - */ -int -st_chkeod(st, position, nmarks, flags) - struct st_data *st; - boolean position; - int *nmarks; - u_int flags; -{ - int error; - - switch (st->flags & (ST_WRITTEN | ST_FM_WRITTEN | ST_2FM_AT_EOD)) { - default: - *nmarks = 0; - return 0; - case ST_WRITTEN: - case ST_WRITTEN | ST_FM_WRITTEN | ST_2FM_AT_EOD: - *nmarks = 1; - break; - case ST_WRITTEN | ST_2FM_AT_EOD: - *nmarks = 2; - } - error = st_write_filemarks(st, *nmarks, flags); - if (position && !error) - error = st_space(st, -*nmarks, SP_FILEMARKS, flags); - return error; -} - -/* - * load/unload (with retension if true) - */ -int -st_load(st, type, flags) - struct st_data *st; - u_int type; - u_int flags; -{ - struct scsi_load scsi_cmd; - struct scsi_link *sc_link = st->sc_link; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - if (type != LD_LOAD) { - int error; - int nmarks; - - error = st_chkeod(st, FALSE, &nmarks, flags); - if (error) - return error; - sc_link->flags &= ~SDEV_MEDIA_LOADED; - } - if (st->quirks & ST_Q_IGNORE_LOADS) - return 0; - scsi_cmd.op_code = LOAD_UNLOAD; - scsi_cmd.how |= type; - return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), 0, 0, ST_RETRIES, 300000, NULL, - flags); -} - -/* - * Rewind the device - */ -int -st_rewind(st, immed, flags) - struct st_data *st; - u_int flags; - boolean immed; -{ - struct scsi_rewind scsi_cmd; - int error; - int nmarks; - - error = st_chkeod(st, FALSE, &nmarks, flags); - if (error) - return error; - st->flags &= ~ST_PER_ACTION; - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = REWIND; - scsi_cmd.byte2 = immed ? SR_IMMED : 0; - return scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &scsi_cmd, - sizeof(scsi_cmd), 0, 0, ST_RETRIES, - immed ? 5000 : 300000, NULL, flags); -} - -#ifdef __NetBSD__ -#define SIGNAL_SHORT_READ -#else -#define SIGNAL_SHORT_READ bp->b_flags |= B_ERROR; -#endif - -/* - * Look at the returned sense and act on the error and detirmine - * The unix error number to pass back... (0 = report no error) - * (-1 = continue processing) - */ -int -st_interpret_sense(xs) - struct scsi_xfer *xs; -{ - struct scsi_link *sc_link = xs->sc_link; - struct scsi_sense_data *sense = &(xs->sense); - boolean silent = xs->flags & SCSI_SILENT; - struct buf *bp = xs->bp; - int unit = sc_link->dev_unit; - struct st_data *st = stcd.cd_devs[unit]; - u_int key; - int info; - - /* - * Get the sense fields and work out what code - */ - if (sense->error_code & SSD_ERRCODE_VALID) - info = ntohl(*((int *) sense->ext.extended.info)); - else - info = xs->datalen; /* bad choice if fixed blocks */ - if ((sense->error_code & SSD_ERRCODE) != 0x70) - return -1; /* let the generic code handle it */ - if (st->flags & ST_FIXEDBLOCKS) { - xs->resid = info * st->blksiz; - if (sense->ext.extended.flags & SSD_EOM) { - st->flags |= ST_EIO_PENDING; - if (bp) { - bp->b_resid = xs->resid; - SIGNAL_SHORT_READ - } - } - if (sense->ext.extended.flags & SSD_FILEMARK) { - st->flags |= ST_AT_FILEMARK; - if (bp) { - bp->b_resid = xs->resid; - SIGNAL_SHORT_READ - } - } - if (sense->ext.extended.flags & SSD_ILI) { - st->flags |= ST_EIO_PENDING; - if (bp) { - bp->b_resid = xs->resid; - SIGNAL_SHORT_READ - } - if (sense->error_code & SSD_ERRCODE_VALID && - !silent) - printf("%s: block wrong size" - ", %d blocks residual\n", - st->sc_dev.dv_xname, info); - - /* - * This quirk code helps the drive read - * the first tape block, regardless of - * format. That is required for these - * drives to return proper MODE SENSE - * information. - */ - if ((st->quirks & ST_Q_SNS_HLP) && - !(sc_link->flags & SDEV_MEDIA_LOADED)) - st->blksiz -= 512; - } - /* - * If no data was tranfered, do it immediatly - */ - if (xs->resid >= xs->datalen) { - if (st->flags & ST_EIO_PENDING) - return EIO; - if (st->flags & ST_AT_FILEMARK) { - if (bp) { - bp->b_resid = xs->resid; - SIGNAL_SHORT_READ - } - return 0; - } - } - } else { /* must be variable mode */ - xs->resid = xs->datalen; /* to be sure */ - if (sense->ext.extended.flags & SSD_EOM) - return EIO; - if (sense->ext.extended.flags & SSD_FILEMARK) { - if (bp) - bp->b_resid = bp->b_bcount; - return 0; - } - if (sense->ext.extended.flags & SSD_ILI) { - if (info < 0) { - /* - * the record was bigger than the read - */ - if (!silent) - printf("%s: %d-byte record too big\n", - st->sc_dev.dv_xname, - xs->datalen - info); - return EIO; - } - xs->resid = info; - if (bp) { - bp->b_resid = info; - SIGNAL_SHORT_READ - } - } - } - key = sense->ext.extended.flags & SSD_KEY; - - if (key == 0x8) { - /* - * This quirk code helps the drive read the - * first tape block, regardless of format. That - * is required for these drives to return proper - * MODE SENSE information. - */ - if ((st->quirks & ST_Q_SNS_HLP) && - !(sc_link->flags & SDEV_MEDIA_LOADED)) { /* still starting */ - st->blksiz -= 512; - } else if (!(st->flags & (ST_2FM_AT_EOD | ST_BLANK_READ))) { - st->flags |= ST_BLANK_READ; - xs->resid = xs->datalen; - if (bp) { - bp->b_resid = xs->resid; - /* return an EOF */ - } - return 0; - } - } - return -1; /* let the default/generic handler handle it */ -} - -/* - * The quirk here is that the drive returns some value to st_mode_sense - * incorrectly until the tape has actually passed by the head. - * - * The method is to set the drive to large fixed-block state (user-specified - * density and 1024-byte blocks), then read and rewind to get it to sense the - * tape. If that doesn't work, try 512-byte fixed blocks. If that doesn't - * work, as a last resort, try variable- length blocks. The result will be - * the ability to do an accurate st_mode_sense. - * - * We know we can do a rewind because we just did a load, which implies rewind. - * Rewind seems preferable to space backward if we have a virgin tape. - * - * The rest of the code for this quirk is in ILI processing and BLANK CHECK - * error processing, both part of st_interpret_sense. - */ -int -st_touch_tape(st) - struct st_data *st; -{ - char *buf; - u_int readsiz; - int error; - - buf = malloc(1024, M_TEMP, M_NOWAIT); - if (!buf) - return ENOMEM; - - if (error = st_mode_sense(st, 0)) - goto bad; - st->blksiz = 1024; - do { - switch (st->blksiz) { - case 512: - case 1024: - readsiz = st->blksiz; - st->flags |= ST_FIXEDBLOCKS; - break; - default: - readsiz = 1; - st->flags &= ~ST_FIXEDBLOCKS; - } - if (error = st_mode_select(st, 0)) - goto bad; - st_read(st, buf, readsiz, SCSI_SILENT); - if (error = st_rewind(st, FALSE, 0)) { -bad: free(buf, M_TEMP); - return error; - } - } while (readsiz != 1 && readsiz > st->blksiz); - free(buf, M_TEMP); - return 0; -} diff --git a/sys/arch/mac68k/scsi/su.c b/sys/arch/mac68k/scsi/su.c deleted file mode 100644 index c07d3b59d609..000000000000 --- a/sys/arch/mac68k/scsi/su.c +++ /dev/null @@ -1,6 +0,0 @@ -/* $NetBSD: su.c,v 1.2 1994/10/26 08:47:45 cgd Exp $ */ - - -/* this will be a special user scsi device */ -/* not written yet */ - diff --git a/sys/arch/mac68k/scsi/uk.c b/sys/arch/mac68k/scsi/uk.c deleted file mode 100644 index d55c47391d5e..000000000000 --- a/sys/arch/mac68k/scsi/uk.c +++ /dev/null @@ -1,159 +0,0 @@ -/* $NetBSD: uk.c,v 1.5 1994/10/26 08:47:46 cgd Exp $ */ - - -/* - * Dummy driver for a device we can't identify. - * by Julian Elischer (julian@tfs.com) - */ - - -#include -#include -#include -#include - -#include -#include - -#define NUK 16 - -/* - * This driver is so simple it uses all the default services - */ -struct scsi_device uk_switch = -{ - NULL, - NULL, - NULL, - NULL, - "uk", - 0, - 0, 0 -}; - -struct uk_data { - u_int32 flags; - struct scsi_link *sc_link; /* all the inter level info */ -} uk_data[NUK]; - -#define UK_KNOWN 0x02 - -static u_int32 next_uk_unit = 0; - -/* - * The routine called by the low level scsi routine when it discovers - * a device suitable for this driver. - */ -errval -ukattach(sc_link) - struct scsi_link *sc_link; -{ - u_int32 unit, i, stat; - unsigned char *tbl; - - SC_DEBUG(sc_link, SDEV_DB2, ("ukattach: ")); - /* - * Check we have the resources for another drive - */ - unit = next_uk_unit++; - if (unit >= NUK) { - printf("Too many unknown devices..(%d > %d) reconfigure kernel\n", - (unit + 1), NUK); - return (0); - } - /* - * Store information needed to contact our base driver - */ - uk_data[unit].sc_link = sc_link; - sc_link->device = &uk_switch; - sc_link->dev_unit = unit; - - printf("uk%d: unknown device\n", unit); - uk_data[unit].flags = UK_KNOWN; - - return; - -} - -/* - * open the device. - */ -errval -ukopen(dev) -{ - errval errcode = 0; - u_int32 unit, mode; - struct scsi_link *sc_link; - unit = minor(dev); - - /* - * Check the unit is legal - */ - if (unit >= NUK) { - printf("uk%d: uk %d > %d\n", unit, unit, NUK); - return ENXIO; - } - - /* - * Make sure the device has been initialised - */ - if((uk_data[unit].flags & UK_KNOWN) == 0) { - printf("uk%d: not set up\n", unit); - return ENXIO; - } - - /* - * Only allow one at a time - */ - sc_link = uk_data[unit].sc_link; - if (sc_link->flags & SDEV_OPEN) { - printf("uk%d: already open\n", unit); - return ENXIO; - } - sc_link->flags |= SDEV_OPEN; - SC_DEBUG(sc_link, SDEV_DB1, ("ukopen: dev=0x%x (unit %d (of %d))\n" - ,dev, unit, NUK)); - /* - * Catch any unit attention errors. - */ - return 0; -} - -/* - * close the device.. only called if we are the LAST - * occurence of an open device - */ -errval -ukclose(dev) -{ - unsigned char unit, mode; - struct scsi_link *sc_link; - - sc_link = uk_data[unit].sc_link; - - SC_DEBUG(sc_link, SDEV_DB1, ("Closing device")); - sc_link->flags &= ~SDEV_OPEN; - return (0); -} - -/* - * Perform special action on behalf of the user - * Only does generic scsi ioctls. - */ -errval -ukioctl(dev, cmd, arg, mode) - dev_t dev; - u_int32 cmd; - caddr_t arg; -{ - unsigned char unit; - struct scsi_link *sc_link; - - /* - * Find the device that the user is talking about - */ - unit = minor(dev); - sc_link = uk_data[unit].sc_link; - return(scsi_do_ioctl(sc_link,cmd,arg,mode)); -} - diff --git a/sys/arch/pc532/scsi/scsi_debug.h b/sys/arch/pc532/scsi/scsi_debug.h deleted file mode 100644 index 56b605b5d542..000000000000 --- a/sys/arch/pc532/scsi/scsi_debug.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: scsi_debug.h,v 1.2 1994/10/26 08:25:31 cgd Exp $ */ - -/*#define SCSIDEBUG 1*/ -/* - * Written by Julian Elischer (julian@tfs.com) - */ -#ifndef _SCSI_SCSI_DEBUG_H -#define _SCSI_SCSI_DEBUG_H 1 - -/* - * These are the new debug bits. (Sat Oct 2 12:46:46 WST 1993) - * the following DEBUG bits are defined to exist in the flags word of - * the scsi_link structure. - */ -#define SDEV_DB1 0x10 /* scsi commands, errors, data */ -#define SDEV_DB2 0x20 /* routine flow tracking */ -#define SDEV_DB3 0x40 /* internal to routine flows */ -#define SDEV_DB4 0x80 /* level 4 debugging for this dev */ - -/* target and LUN we want to debug */ -#define DEBUGTARG 9 /*9 = dissable*/ -#define DEBUGLUN 0 -#define DEBUGLEVEL (SDEV_DB1|SDEV_DB2) - -/* - * This is the usual debug macro for use with the above bits - */ -#ifdef SCSIDEBUG -#define SC_DEBUG(sc_link,Level,Printstuff) \ - if((sc_link)->flags & (Level)) \ - { \ - printf("%s%d(%s%d:%d:%d): ", \ - sc_link->device->name, \ - sc_link->dev_unit, \ - sc_link->adapter->name, \ - sc_link->scsibus, \ - sc_link->target, \ - sc_link->lun); \ - printf Printstuff; \ - } -#define SC_DEBUGN(sc_link,Level,Printstuff) \ - if((sc_link)->flags & (Level)) \ - { \ - printf Printstuff; \ - } -#else -#define SC_DEBUG(A,B,C) /* not included */ -#define SC_DEBUGN(A,B,C) /* not included */ -#endif - -#endif /*_SCSI_SCSI_DEBUG_H*/ -/* END OF FILE */ - diff --git a/sys/arch/pc532/scsi/scsi_disk.h b/sys/arch/pc532/scsi/scsi_disk.h deleted file mode 100644 index 4f886e881e14..000000000000 --- a/sys/arch/pc532/scsi/scsi_disk.h +++ /dev/null @@ -1,240 +0,0 @@ -/* $NetBSD: scsi_disk.h,v 1.2 1994/10/26 08:25:32 cgd Exp $ */ - -/* - * SCSI interface description - * - * Some lines of this file comes from a file of the name "scsi.h" - * distributed by OSF as part of mach2.5, - * so the following disclaimer has been kept. - * - * Copyright 1990 by Open Software Foundation, - * Grenoble, FRANCE - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation, and that the name of OSF or Open Software - * Foundation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * Largely written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - */ - -/* - * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - */ - -/* - * SCSI command format - */ - - -struct scsi_reassign_blocks -{ - u_char op_code; - u_char :5; - u_char lun:3; - u_char unused[3]; - u_char link:1; - u_char flag:1; - u_char :6; -}; - -struct scsi_rw -{ - u_char op_code; - u_char addr_2:5; /* Most significant */ - u_char lun:3; - u_char addr_1; - u_char addr_0; /* least significant */ - u_char length; - u_char link:1; - u_char flag:1; - u_char :6; -}; - -struct scsi_rw_big -{ - u_char op_code; - u_char rel_addr:1; - u_char :4; /* Most significant */ - u_char lun:3; - u_char addr_3; - u_char addr_2; - u_char addr_1; - u_char addr_0; /* least significant */ - u_char reserved;; - u_char length2; - u_char length1; - u_char link:1; - u_char flag:1; - u_char :4; - u_char vendor:2; -}; - -struct scsi_read_capacity -{ - u_char op_code; - u_char :5; - u_char lun:3; - u_char addr_3; /* Most Significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least Significant */ - u_char unused[3]; - u_char link:1; - u_char flag:1; - u_char :6; -}; - -struct scsi_start_stop -{ - u_char op_code; - u_char :5; - u_char lun:3; - u_char unused[2]; - u_char start:1; - u_char loej:1; - u_char :6; - u_char link:1; - u_char flag:1; - u_char :6; -}; - - - -/* - * Opcodes - */ - -#define FORMAT_DISK 0x04 -#define REASSIGN_BLOCKS 0x07 -#define READ_COMMAND 0x08 -#define WRITE_COMMAND 0x0a -#define MODE_SELECT 0x15 -#define MODE_SENSE 0x1a -#define START_STOP 0x1b -#define PREVENT_ALLOW 0x1e -#define READ_CAPACITY 0x25 -#define READ_BIG 0x28 -#define WRITE_BIG 0x2a - - -struct scsi_format_parms { /* physical BFI format */ - u_short reserved; - u_short list_len; - struct defect { - unsigned cyl : 24; - unsigned head : 8; - long bytes_from_index; - } defect[127]; -} format_parms; - - -struct scsi_read_cap_data -{ - u_char addr_3; /* Most significant */ - u_char addr_2; - u_char addr_1; - u_char addr_0; /* Least significant */ - u_char length_3; /* Most significant */ - u_char length_2; - u_char length_1; - u_char length_0; /* Least significant */ -}; - -struct scsi_reassign_blocks_data -{ - u_char reserved[2]; - u_char length_msb; - u_char length_lsb; - struct - { - u_char dlbaddr_3; /* defect logical block address (MSB) */ - u_char dlbaddr_2; - u_char dlbaddr_1; - u_char dlbaddr_0; /* defect logical block address (LSB) */ - } defect_descriptor[1]; -}; - -union disk_pages /* this is the structure copied from osf */ -{ - struct page_disk_format { - u_char pg_code:6; /* page code (should be 3) */ - u_char :2; - u_char pg_length; /* page length (should be 0x16) */ - u_char trk_z_1; /* tracks per zone (MSB) */ - u_char trk_z_0; /* tracks per zone (LSB) */ - u_char alt_sec_1; /* alternate sectors per zone (MSB) */ - u_char alt_sec_0; /* alternate sectors per zone (LSB) */ - u_char alt_trk_z_1; /* alternate tracks per zone (MSB) */ - u_char alt_trk_z_0; /* alternate tracks per zone (LSB) */ - u_char alt_trk_v_1; /* alternate tracks per volume (MSB) */ - u_char alt_trk_v_0; /* alternate tracks per volume (LSB) */ - u_char ph_sec_t_1; /* physical sectors per track (MSB) */ - u_char ph_sec_t_0; /* physical sectors per track (LSB) */ - u_char bytes_s_1; /* bytes per sector (MSB) */ - u_char bytes_s_0; /* bytes per sector (LSB) */ - u_char interleave_1;/* interleave (MSB) */ - u_char interleave_0;/* interleave (LSB) */ - u_char trk_skew_1; /* track skew factor (MSB) */ - u_char trk_skew_0; /* track skew factor (LSB) */ - u_char cyl_skew_1; /* cylinder skew (MSB) */ - u_char cyl_skew_0; /* cylinder skew (LSB) */ - u_char reserved1:4; - u_char surf:1; - u_char rmb:1; - u_char hsec:1; - u_char ssec:1; - u_char reserved2; - u_char reserved3; - } disk_format; - struct page_rigid_geometry { - u_char pg_code:7; /* page code (should be 4) */ - u_char mbone:1; /* must be one */ - u_char pg_length; /* page length (should be 0x16) */ - u_char ncyl_2; /* number of cylinders (MSB) */ - u_char ncyl_1; /* number of cylinders */ - u_char ncyl_0; /* number of cylinders (LSB) */ - u_char nheads; /* number of heads */ - u_char st_cyl_wp_2; /* starting cyl., write precomp (MSB) */ - u_char st_cyl_wp_1; /* starting cyl., write precomp */ - u_char st_cyl_wp_0; /* starting cyl., write precomp (LSB) */ - u_char st_cyl_rwc_2;/* starting cyl., red. write cur (MSB)*/ - u_char st_cyl_rwc_1;/* starting cyl., red. write cur */ - u_char st_cyl_rwc_0;/* starting cyl., red. write cur (LSB)*/ - u_char driv_step_1; /* drive step rate (MSB) */ - u_char driv_step_0; /* drive step rate (LSB) */ - u_char land_zone_2; /* landing zone cylinder (MSB) */ - u_char land_zone_1; /* landing zone cylinder */ - u_char land_zone_0; /* landing zone cylinder (LSB) */ - u_char reserved1; - u_char reserved2; - u_char reserved3; - } rigid_geometry; -} ; diff --git a/sys/arch/pc532/scsi/scsi_tape.h b/sys/arch/pc532/scsi/scsi_tape.h deleted file mode 100644 index 31ef4b9a7bfe..000000000000 --- a/sys/arch/pc532/scsi/scsi_tape.h +++ /dev/null @@ -1,149 +0,0 @@ -/* $NetBSD: scsi_tape.h,v 1.2 1994/10/26 08:25:33 cgd Exp $ */ - -/* - * SCSI tape interface description - * - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems. - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - */ - -/* - * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - */ - -/* - * SCSI command format - */ - - -struct scsi_rw_tape -{ - u_char op_code; - u_char fixed:1; - u_char :4; - u_char lun:3; - u_char len[3]; - u_char link:1; - u_char flag:1; - u_char :6; -} rw_tape; - -struct scsi_space -{ - u_char op_code; - u_char code:2; - u_char :3; - u_char lun:3; - u_char number[3]; - u_char link:1; - u_char flag:1; - u_char :6; -} space; -#define SP_BLKS 0 -#define SP_FILEMARKS 1 -#define SP_SEQ_FILEMARKS 2 -#define SP_EOM 3 - -struct scsi_write_filemarks -{ - u_char op_code; - u_char :5; - u_char lun:3; - u_char number[3]; - u_char link:1; - u_char flag:1; - u_char :6; -} write_filemarks; - -struct scsi_rewind -{ - u_char op_code; - u_char immed:1; - u_char :4; - u_char lun:3; - u_char unused[3]; - u_char link:1; - u_char flag:1; - u_char :6; -} rewind; - -struct scsi_load -{ - u_char op_code; - u_char immed:1; - u_char :4; - u_char lun:3; - u_char unused[2]; - u_char load:1; - u_char reten:1; - u_char :6; - u_char link:1; - u_char flag:1; - u_char :6; -} load; -#define LD_UNLOAD 0 -#define LD_LOAD 1 - -struct scsi_blk_limits -{ - u_char op_code; - u_char :5; - u_char lun:3; - u_char unused[3]; - u_char link:1; - u_char flag:1; - u_char :6; -} blk_limits; - -/* - * Opcodes - */ - -#define REWIND 0x01 -#define READ_BLK_LIMITS 0x05 -#define READ_COMMAND_TAPE 0x08 -#define WRITE_COMMAND_TAPE 0x0a -#define WRITE_FILEMARKS 0x10 -#define SPACE 0x11 -#define LOAD_UNLOAD 0x1b /* same as above */ - - - -struct scsi_blk_limits_data -{ - u_char reserved; - u_char max_length_2; /* Most significant */ - u_char max_length_1; - u_char max_length_0; /* Least significant */ - u_char min_length_1; /* Most significant */ - u_char min_length_0; /* Least significant */ -}; - -struct scsi_mode_header_tape -{ - u_char data_length; /* Sense data length */ - u_char medium_type; - u_char speed:4; - u_char buf_mode:3; - u_char write_protected:1; - u_char blk_desc_len; -}; - - -#define QIC_120 0x0f -#define QIC_150 0x10 -#define QIC_320 0x11 -#define QIC_525 0x11 -#define QIC_1320 0x12 - - diff --git a/sys/arch/pc532/scsi/scsiconf.c b/sys/arch/pc532/scsi/scsiconf.c deleted file mode 100644 index e6242e3e1819..000000000000 --- a/sys/arch/pc532/scsi/scsiconf.c +++ /dev/null @@ -1,600 +0,0 @@ -/* $NetBSD: scsiconf.c,v 1.3 1994/10/26 08:25:34 cgd Exp $ */ - -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * Hacked by Theo de Raadt - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../scsi/scsi_all.h" -#include "../../scsi/scsiconf.h" - -#include "st.h" -#include "sd.h" -#include "ch.h" -#include "cd.h" -#define NBLL 0 -#define NCALS 0 -#define NKIL 0 - -#if NSD > 0 -extern int sdattach(); -#endif NSD -#if NST > 0 -extern int stattach(); -#endif NST -#if NCH > 0 -extern int chattach(); -#endif NCH -#if NCD > 0 -extern int cdattach(); -#endif NCD -#if NBLL > 0 -extern int bllattach(); -#endif NBLL -#if NCALS > 0 -extern int calsattach(); -#endif NCALS -#if NKIL > 0 -extern int kil_attach(); -#endif NKIL - -struct scsidevs knowndevs[] = { -#if NSD > 0 - { - SC_TSD, T_DIRECT, T_FIXED, "standard", "any" ,"any", - sdattach, "sd" ,SC_ONE_LU - }, { - SC_TSD, T_DIRECT, T_FIXED, "MAXTOR ", "XT-4170S ", "B5A ", - sdattach, "mx1", SC_ONE_LU - }, -#endif NSD -#if NST > 0 - { - SC_TST, T_SEQUENTIAL, T_REMOV, "standard", "any", "any", - stattach, "st" ,SC_ONE_LU - }, -#endif NST -#if NCD > 0 - { - SC_TCD, T_READONLY, T_REMOV, "SONY ", "CD-ROM CDU-8012 ", "3.1a", - cdattach, "cd", SC_ONE_LU - }, { - SC_TCD, T_READONLY, T_REMOV, "PIONEER ", "CD-ROM DRM-600 ", "any", - cdattach, "cd", SC_MORE_LUS - }, -#endif NCD -#if NCALS > 0 - { - -1, T_PROCESSOR, T_FIXED, "standard" , "any" ,"any", - calsattach, "cals", SC_MORE_LUS - } -#endif NCALS -#if NCH > 0 - { - -1, T_CHANGER, T_REMOV, "standard", "any", "any", - chattach, "ch", SC_ONE_LU - }, -#endif NCH -#if NBLL > 0 - { - -1, T_PROCESSOR, T_FIXED, "AEG ", "READER ", "V1.0", - bllattach, "bll", SC_MORE_LUS - }, -#endif NBLL -#if NKIL > 0 - { - -1, T_SCANNER, T_FIXED, "KODAK ", "IL Scanner 900 ", "any", - kil_attach, "kil", SC_ONE_LU - }, -#endif NKIL -}; - -/* controls debug level within the scsi subsystem: see scsiconf.h */ -int scsi_debug = 0; - -struct scsidevs * -scsi_probe(int masunit, struct scsi_switch *sw, int physid, int type, int want) -{ - static struct scsi_inquiry_data inqbuf; - struct scsidevs *ret = (struct scsidevs *)0; - int targ = physid >> 3; - int lun = physid & 7; - char *qtype=NULL, *dtype=NULL, *desc; - char manu[9], model[17], revision[5]; - int len; - - bzero(&inqbuf, sizeof inqbuf); - - /*printf("probe: %s%d targ %d lun %d\n", - sw->name, masunit, targ, lun);*/ - - if( scsi_ready(masunit, targ, lun, sw, - SCSI_NOSLEEP | SCSI_NOMASK) != COMPLETE) - return (struct scsidevs *)-1; - - if( scsi_inquire(masunit, targ, lun, sw, (u_char *)&inqbuf, - SCSI_NOSLEEP | SCSI_NOMASK) != COMPLETE) - return (struct scsidevs *)0; - - if( inqbuf.device_qualifier==3 && inqbuf.device_type==T_NODEVICE) - return (struct scsidevs *)0; - - switch(inqbuf.device_qualifier) { - case 0: - qtype = ""; - break; - case 1: - qtype = "Unit not Connected!"; - break; - case 2: - qtype =", Reserved Peripheral Qualifier!"; - break; - case 3: - qtype = ", The Target can't support this Unit!"; - break; - default: - dtype = "vendor specific"; - qtype = ""; - break; - } - - if (dtype == NULL) { - switch(inqbuf.device_type) { - case T_DIRECT: - dtype = "direct"; - break; - case T_SEQUENTIAL: - dtype = "seq"; - break; - case T_PRINTER: - dtype = "pr"; - break; - case T_PROCESSOR: - dtype = "cpu"; - break; - case T_READONLY: - dtype = "ro"; - break; - case T_WORM: - dtype = "worm"; - break; - case T_SCANNER: - dtype = "scan"; - break; - case T_OPTICAL: - dtype = "optic"; - break; - case T_CHANGER: - dtype = "changer"; - break; - case T_COMM: - dtype = "comm"; - break; - default: - dtype = "???"; - break; - } - } - - if(inqbuf.ansii_version > 0) { - len = inqbuf.additional_length + - ((char *)inqbuf.unused - (char *)&inqbuf); - if( len > sizeof(struct scsi_inquiry_data) - 1) - len = sizeof(struct scsi_inquiry_data) - 1; - desc = inqbuf.vendor; - desc[len-(desc-(char *)&inqbuf)] = 0; - strncpy(manu, inqbuf.vendor, sizeof inqbuf.vendor); - manu[sizeof inqbuf.vendor] = '\0'; - strncpy(model, inqbuf.product, sizeof inqbuf.product); - model[sizeof inqbuf.product] = '\0'; - strncpy(revision, inqbuf.revision, sizeof inqbuf.revision); - revision[sizeof inqbuf.revision] = '\0'; - } else { - desc = "early protocol device"; - strcpy(manu, "????"); - strcpy(model, ""); - strcpy(revision, ""); - } - - if(want) - goto print; - - ret = selectdev(masunit, targ, lun, sw, inqbuf.device_qualifier, - inqbuf.device_type, inqbuf.removable, manu, model, revision, type); - if(sw->printed[targ] & (1< SCSI%d\n", - sw->name, masunit, targ, lun, - inqbuf.device_type, dtype, - inqbuf.removable ? "removable" : "fixed", - manu, model, revision, inqbuf.ansii_version); - if(qtype[0]) - printf("%s%d targ %d lun %d: qualifier %d(%s)\n", - sw->name, masunit, targ, lun, - inqbuf.device_qualifier, qtype); - sw->printed[targ] |= (1<empty[targ] & (1<used[targ] & (1<empty[targ] = 0xff; - else - sw->empty[targ] = 0xff; - continue; - } - if(match) { - targ = physid >> 3; - lun = physid & 7; - if(match->flags & SC_MORE_LUS) - sw->empty[targ] |= (1<empty[targ] = 0xff; - } - } - } -} - -/* - * not quite perfect. If we have two "drive ?" entries, this will - * probe through all the devices twice. It should have realized that - * any device that is not found the first time won't exist later on. - */ -int -scsi_attach(int masunit, int mytarg, struct scsi_switch *sw, - int *physid, int *unit, int type) -{ - struct scsidevs *match = (struct scsidevs *)0; - int targ, lun; - int ret=0; - - /*printf("%s%d probing at targ %d lun %d..\n", - sw->name, masunit, *physid >> 3, *physid & 7);*/ - - if( *physid!=-1 ) { - targ = *physid >> 3; - lun = *physid & 7; - - if( (sw->empty[targ] & (1<used[targ] & (1<empty[targ] = 0xff; - else - sw->empty[targ] |= (1<attach_rtn))(masunit, sw, *physid, unit); - goto success; - } - - for(targ=0; targ<8; targ++) { - if(targ==mytarg) - continue; - for(lun=0; lun<8; lun++) { - if( (sw->empty[targ] & (1<used[targ] & (1<empty[targ] = 0xff; - else - sw->empty[targ] |= (1<attach_rtn))(masunit, sw, *physid, unit); - if(ret) - goto success; - return 0; - } - } - *physid = -1; /* failed... */ - return 0; - -success: - targ = *physid >> 3; - lun = *physid & 7; - if(match->flags & SC_MORE_LUS) - sw->used[targ] |= (1<used[targ] = 0xff; - return ret; -} - -/* - * Try make as good a match as possible with - * available sub drivers - */ -struct scsidevs * -selectdev(int unit, int target, int lu, struct scsi_switch *sw, int qual, - int dtype, int remov, char *manu, char *model, char *rev, int type) -{ - struct scsidevs *sdbest = (struct scsidevs *)0; - struct scsidevs *sdent = knowndevs; - int numents = sizeof(knowndevs)/sizeof(struct scsidevs); - int count = 0, sdbestes = 0; - - dtype |= (qual << 5); - - sdent--; - while( count++ < numents) { - sdent++; - if(dtype != sdent->dtype) - continue; - if(type != sdent->type) - continue; - if(sdbestes < 1) { - sdbestes = 1; - sdbest = sdent; - } - if(remov != sdent->removable) - continue; - if(sdbestes < 2) { - sdbestes = 2; - sdbest = sdent; - } - if(sdent->flags & SC_SHOWME) - printf("\n%s-\n%s-", sdent->manufacturer, manu); - if(strcmp(sdent->manufacturer, manu)) - continue; - if(sdbestes < 3) { - sdbestes = 3; - sdbest = sdent; - } - if(sdent->flags & SC_SHOWME) - printf("\n%s-\n%s-",sdent->model, model); - if(strcmp(sdent->model, model)) - continue; - if(sdbestes < 4) { - sdbestes = 4; - sdbest = sdent; - } - if(sdent->flags & SC_SHOWME) - printf("\n%s-\n%s-",sdent->version, rev); - if(strcmp(sdent->version, rev)) - continue; - if(sdbestes < 5) { - sdbestes = 5; - sdbest = sdent; - break; - } - } - return sdbest; -} - -/* - * Do a scsi operation asking a device if it is - * ready. Use the scsi_cmd routine in the switch - * table. - */ -int -scsi_ready(int unit, int target, int lu, - struct scsi_switch *sw, int flags) -{ - struct scsi_test_unit_ready scsi_cmd; - struct scsi_xfer scsi_xfer; - volatile int rval; - int key; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - bzero(&scsi_xfer, sizeof(scsi_xfer)); - scsi_cmd.op_code = TEST_UNIT_READY; - - scsi_xfer.flags = flags | INUSE; - scsi_xfer.adapter = unit; - scsi_xfer.targ = target; - scsi_xfer.lu = lu; - scsi_xfer.cmd = (struct scsi_generic *)&scsi_cmd; - scsi_xfer.retries = 8; - scsi_xfer.timeout = 10000; - scsi_xfer.cmdlen = sizeof(scsi_cmd); - scsi_xfer.data = 0; - scsi_xfer.datalen = 0; - scsi_xfer.resid = 0; - scsi_xfer.when_done = 0; - scsi_xfer.done_arg = 0; -retry: scsi_xfer.error = 0; - - /* don't use interrupts! */ - - rval = (*(sw->scsi_cmd))(&scsi_xfer); - if (rval != COMPLETE) { - if(scsi_debug) { - printf("scsi error, rval = 0x%x\n", rval); - printf("code from driver: 0x%x\n", scsi_xfer.error); - } - switch(scsi_xfer.error) { - case XS_SENSE: - /* - * Any sense value is illegal except UNIT ATTENTION - * In which case we need to check again to get the - * correct response. (especially exabytes) - */ - if(scsi_xfer.sense.error_class == 7 ) { - key = scsi_xfer.sense.ext.extended.sense_key ; - switch(key) { - case 2: /* not ready BUT PRESENT! */ - return(COMPLETE); - case 6: - spinwait(1000); - if(scsi_xfer.retries--) { - scsi_xfer.flags &= ~ITSDONE; - goto retry; - } - return(COMPLETE); - default: - if(scsi_debug) - printf("%d:%d,key=%x.", target, - lu, key); - } - } - return(HAD_ERROR); - case XS_BUSY: - spinwait(1000); - if(scsi_xfer.retries--) { - scsi_xfer.flags &= ~ITSDONE; - goto retry; - } - return COMPLETE; /* it's busy so it's there */ - case XS_TIMEOUT: - default: - return HAD_ERROR; - } - } - return COMPLETE; -} - -/* - * Do a scsi operation asking a device what it is - * Use the scsi_cmd routine in the switch table. - */ -int -scsi_inquire(int unit, int target, int lu, struct scsi_switch *sw, - u_char *inqbuf, int flags) -{ - struct scsi_inquiry scsi_cmd; - struct scsi_xfer scsi_xfer; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - bzero(&scsi_xfer, sizeof(scsi_xfer)); - scsi_cmd.op_code = INQUIRY; - scsi_cmd.length = sizeof(struct scsi_inquiry_data); - - scsi_xfer.flags = flags | SCSI_DATA_IN | INUSE; - scsi_xfer.adapter = unit; - scsi_xfer.targ = target; - scsi_xfer.lu = lu; - scsi_xfer.retries = 8; - scsi_xfer.timeout = 10000; - scsi_xfer.cmd = (struct scsi_generic *)&scsi_cmd; - scsi_xfer.cmdlen = sizeof(struct scsi_inquiry); - scsi_xfer.data = inqbuf; - scsi_xfer.datalen = sizeof(struct scsi_inquiry_data); - scsi_xfer.resid = sizeof(struct scsi_inquiry_data); - scsi_xfer.when_done = 0; - scsi_xfer.done_arg = 0; - -retry: - scsi_xfer.error=0; - /* don't use interrupts! */ - - if ((*(sw->scsi_cmd))(&scsi_xfer) != COMPLETE) { - if(scsi_debug) - printf("inquiry had error(0x%x) ",scsi_xfer.error); - switch(scsi_xfer.error) { - case XS_NOERROR: - break; - case XS_SENSE: - /* - * Any sense value is illegal except UNIT ATTENTION - * In which case we need to check again to get the - * correct response. (especially exabytes) - */ - if( scsi_xfer.sense.error_class==7 && - scsi_xfer.sense.ext.extended.sense_key==6) { - /* it's changed so it's there */ - spinwait(1000); - if(scsi_xfer.retries--) { - scsi_xfer.flags &= ~ITSDONE; - goto retry; - } - return COMPLETE; - } - return HAD_ERROR; - case XS_BUSY: - spinwait(1000); - if(scsi_xfer.retries--) { - scsi_xfer.flags &= ~ITSDONE; - goto retry; - } - case XS_TIMEOUT: - default: - return(HAD_ERROR); - } - } - return COMPLETE; -} - -/* - * convert a physical address to 3 bytes, - * MSB at the lowest address, - * LSB at the highest. - */ -void -lto3b(u_long val, u_char *bytes) -{ - *bytes++ = (val&0xff0000)>>16; - *bytes++ = (val&0xff00)>>8; - *bytes = val&0xff; -} - -/* - * The reverse of lto3b - */ -u_long -_3btol(u_char *bytes) -{ - u_long rc; - - rc = (*bytes++ << 16); - rc += (*bytes++ << 8); - rc += *bytes; - return rc; -} - diff --git a/sys/arch/pc532/scsi/scsiconf.h b/sys/arch/pc532/scsi/scsiconf.h deleted file mode 100644 index 8e2022e2bca7..000000000000 --- a/sys/arch/pc532/scsi/scsiconf.h +++ /dev/null @@ -1,132 +0,0 @@ -/* $NetBSD: scsiconf.h,v 1.2 1994/10/26 08:25:35 cgd Exp $ */ - -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * Hacked by Theo de Raadt - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - */ - -/* - * these calls are called by the high-end - * drivers to get services from whatever low-end - * drivers they are attached to - */ -struct scsi_switch { - char *name; - int (*scsi_cmd)(); - void (*scsi_minphys)(); - int (*open_target_lu)(); - int (*close_target_lu)(); - long int (*adapter_info)(); /* see definitions below */ - u_long spare[3]; - u_char empty[8], used[8], printed[8]; -}; -#define AD_INF_MAX_CMDS 0x000000FF /* maximum number of entries - queuable to a device by - the adapter */ -/* 24 bits of other adapter charcteristics go here */ - -/***********************************************\ -* The scsi debug control bits * -\***********************************************/ -extern int scsi_debug; -#define PRINTROUTINES 0x01 -#define TRACEOPENS 0x02 -#define TRACEINTERRUPTS 0x04 -#define SHOWREQUESTS 0x08 -#define SHOWSCATGATH 0x10 -#define SHOWINQUIRY 0x20 -#define SHOWCOMMANDS 0x40 - - -/********************************/ -/* return values for scsi_cmd() */ -/********************************/ -#define SUCCESSFULLY_QUEUED 0 -#define TRY_AGAIN_LATER 1 -#define COMPLETE 2 -#define HAD_ERROR 3 - -struct scsi_xfer -{ - struct scsi_xfer *next; /* when free */ - int flags; - u_char adapter; - u_char targ; - u_char lu; - u_char retries; /* the number of times to retry */ - long int timeout; /* in miliseconds */ - struct scsi_generic *cmd; - int cmdlen; - u_char *data; /* either the dma address OR a uio address */ - int datalen; /* data len (blank if uio) */ - int resid; - int (*when_done)(); - int done_arg; - int done_arg2; - int error; - struct buf *bp; - struct scsi_sense_data sense; -}; -/********************************/ -/* Flag values */ -/********************************/ -#define SCSI_NOSLEEP 0x01 /* Not a user... don't sleep */ -#define SCSI_NOMASK 0x02 /* dont allow interrupts.. booting */ -#define SCSI_NOSTART 0x04 /* left over from ancient history */ -#define ITSDONE 0x10 /* the transfer is as done as it gets */ -#define INUSE 0x20 /* The scsi_xfer block is in use */ -#define SCSI_SILENT 0x40 /* Don't report errors to console */ -#define SCSI_ERR_OK 0x80 /* An error on this operation is OK. */ -#define SCSI_RESET 0x100 /* Reset the device in question */ -#define SCSI_DATA_UIO 0x200 /* The data address refers to a UIO */ -#define SCSI_DATA_IN 0x400 /* expect data to come INTO memory */ -#define SCSI_DATA_OUT 0x800 /* expect data to flow OUT of memory */ -#define SCSI_TARGET 0x1000 /* This defines a TARGET mode op. */ -/********************************/ -/* Error values */ -/********************************/ -#define XS_NOERROR 0x0 /* there is no error, (sense is invalid) */ -#define XS_SENSE 0x1 /* Check the returned sense for the error */ -#define XS_DRIVER_STUFFUP 0x2 /* Driver failed to perform operation */ -#define XS_TIMEOUT 0x03 /* The device timed out.. turned off? */ -#define XS_SWTIMEOUT 0x04 /* The Timeout reported was caught by SW */ -#define XS_BUSY 0x08 /* The device busy, try again later? */ - -/* - * The structure of known drivers for autoconfiguration - */ -#define SC_TSD 0 -#define SC_TST 1 -#define SC_TCD 2 - -#define SC_SHOWME 0x01 -#define SC_ONE_LU 0x00 -#define SC_MORE_LUS 0x02 -struct scsidevs { - int type, dtype, removable; - char *manufacturer, *model, *version; - int (*attach_rtn)(); - char *devname, flags; -}; - -int scsi_inquire(int, int, int, struct scsi_switch *, u_char *, int); -int scsi_ready(int, int, int, struct scsi_switch *, int); -int scsi_attach(int, int, struct scsi_switch *, int *, int *, int); -void scsi_warn(int, int, struct scsi_switch *); -struct scsidevs *scsi_probe(int, struct scsi_switch *, int, int, int); -struct scsidevs *selectdev(int, int, int, struct scsi_switch *, - int, int, int, char *, char *, char *, int); -u_long _3btol(u_char *); -void lto3b(u_long, u_char *); - diff --git a/sys/arch/pc532/scsi/sd.c b/sys/arch/pc532/scsi/sd.c deleted file mode 100644 index 2947205f9899..000000000000 --- a/sys/arch/pc532/scsi/sd.c +++ /dev/null @@ -1,1348 +0,0 @@ -/* $NetBSD: sd.c,v 1.5 1994/10/26 08:25:37 cgd Exp $ */ - -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * Hacked by Theo de Raadt - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - */ - -#include "sd.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../scsi/scsi_all.h" -#include "../../scsi/scsi_disk.h" -#include "../../scsi/scsiconf.h" -#include "../../scsi/sddefs.h" - -long int sdstrats, sdqueues; - -#define SPLSD splbio -#define ESUCCESS 0 - -#define SECSIZE 512 -#define PDLOCATION 29 -#define BOOTRECORDSIGNATURE (0x55aa & 0x00ff) -#define SDOUTSTANDING 2 -#define SDQSIZE 4 -#define SD_RETRIES 4 - -#define MAKESDDEV(maj, unit, part) (makedev(maj, ((unit<<3)+part))) -#define UNITSHIFT 3 -#define PARTITION(z) (minor(z) & 0x07) -#define UNIT(z) ( (minor(z) >> UNITSHIFT) ) - -#undef NSD -#define NSD ( makedev(1,0) >> UNITSHIFT) - -#define WHOLE_DISK(unit) ( (unit << UNITSHIFT) + RAW_PART ) - -struct sd_data *sd_data[NSD]; -int sd_debug = 0; - -/* - * The routine called by the low level scsi routine when it discovers - * A device suitable for this driver - */ -int -sdattach(int masunit, struct scsi_switch *sw, int physid, int *unit) -{ - struct scsi_xfer *sd_scsi_xfer; - struct disk_parms *dp; - struct sd_data *sd; - unsigned char *tbl; - long int ad_info; - int targ, lun, i; - u_long sod; - - targ = physid >> 3; - lun = physid & 7; - - /*printf("sdattach: sd%d at %s%d target %d lun %d\n", - *unit, sw->name, masunit, targ, lun);*/ - - if(*unit == -1) { - for(i=0; i NSD || *unit==-1) - return 0; - if(sd_data[*unit]) - return 0; - - sd = sd_data[*unit] = (struct sd_data *)malloc(sizeof *sd, - M_TEMP, M_NOWAIT); - if(!sd) - return 0; - bzero(sd, sizeof *sd); - - /* store information needed to contact our base driver */ - sd->sc_sw = sw; - sd->ctlr = masunit; - sd->targ = targ; - sd->lu = lun; - - dp = &(sd->params); - if(scsi_debug & PRINTROUTINES) - printf("sdattach: "); - - if(sd->sc_sw->adapter_info) { - sd->ad_info = ( (*(sd->sc_sw->adapter_info))(masunit)); - sd->cmdscount = sd->ad_info & AD_INF_MAX_CMDS; - if(sd->cmdscount > SDOUTSTANDING) - sd->cmdscount = SDOUTSTANDING; - } else { - sd->ad_info = 1; - sd->cmdscount = 1; - } - - i = sd->cmdscount; - sd_scsi_xfer = (struct scsi_xfer *)malloc(sizeof(struct scsi_xfer) * i, - M_TEMP, M_NOWAIT); - while(i--) { - sd_scsi_xfer->next = sd->freexfer; - sd->freexfer = sd_scsi_xfer; - sd_scsi_xfer++; - } - - /* - * Use the subdriver to request information regarding - * the drive. We cannot use interrupts yet, so the - * request must specify this. - */ - sd_get_parms(*unit, SCSI_NOSLEEP | SCSI_NOMASK); - sod = ((u_long)dp->cyls * (u_long)dp->heads * - (u_long)dp->sectors * (u_long)dp->secsiz) / (1024 * 1024); - printf("sd%d at %s%d targ %d lun %d: ", - *unit, sw->name, masunit, targ, lun); - printf("%uMB %d cyl, %d head, %d sec, %d byte/sec\n", - sod, dp->cyls, dp->heads, dp->sectors, dp->secsiz); - sd->flags |= SDINIT; - return 1; -} - - -/* - * open the device. Make sure the partition info - * is a up-to-date as can be. - */ -int -sdopen(int dev) -{ - struct disk_parms disk_parms; - struct sd_data *sd; - int errcode = 0; - int unit, part; - - unit = UNIT(dev); - part = PARTITION(dev); - if(scsi_debug & (PRINTROUTINES | TRACEOPENS)) - printf("sdopen: dev=0x%x (unit %d (of %d),partition %d)\n", - dev, unit, NSD, part); - - if(unit > NSD) - return ENXIO; - if( !sd_data[unit]) { - if(scsi_debug & PRINTROUTINES) - printf("nonexistant!\n"); - return ENXIO; - } - - sd = sd_data[unit]; - if(!sd) - return ENXIO; - if( !(sd->flags & SDVALID) ) - return ENXIO; - - /* - * Make sure the disk has been initialised. - * XXX get the scsi driver to look for a new device if - * we are not initted, like SunOS - */ - if( !(sd->flags & SDINIT)) - return ENXIO; - - /* - * If it's been invalidated, and not everybody has - * closed it then forbid re-entry. - */ - if( !(sd->flags & SDVALID) && sd->openparts) - return ENXIO; - - /* - * Check that it is still responding and ok. - * "unit attention errors should occur here if the drive - * has been restarted or the pack changed - */ - if(scsi_debug & TRACEOPENS) - printf("device is "); - - /* - * In case it is a funny one, tell it to start - * not needed for most hard drives (ignore failure) - * - * This needs to be done BEFORE the test_unit_ready - davidb/simonb - */ - sd_start_unit(unit, SCSI_ERR_OK|SCSI_SILENT); - if(scsi_debug & TRACEOPENS) - printf("started "); - - if (sd_test_unit_ready(unit, 0)) { - if(scsi_debug & TRACEOPENS) - printf("not responding\n"); - return ENXIO; - } - if(scsi_debug & TRACEOPENS) - printf("ok\n"); - - /* - * Load the physical device parameters - */ - sd_get_parms(unit, 0); /* sets SDVALID */ - if( sd->params.secsiz != SECSIZE) { - printf("sd%d: Can't deal with %d bytes logical blocks\n", - unit, sd->params.secsiz); - return ENXIO; - } - if(scsi_debug & TRACEOPENS) - printf("Params loaded "); - - /* - * Load the partition info if not already loaded - */ - sd_prevent(unit, PR_PREVENT, SCSI_ERR_OK|SCSI_SILENT); - if( (errcode=sdgetdisklabel(unit)) && (part != RAW_PART)) { - sd_prevent(unit, PR_ALLOW, SCSI_ERR_OK|SCSI_SILENT); - return errcode; - } - if(scsi_debug & TRACEOPENS) - printf("Disklabel loaded "); - - /* - * Check the partition is legal - */ - if ( part >= MAXPARTITIONS ) { - sd_prevent(unit, PR_ALLOW, SCSI_ERR_OK|SCSI_SILENT); - return ENXIO; - } - if(scsi_debug & TRACEOPENS) - printf("ok"); - - /* - * Check that the partition exists - */ - if( sd->disklabel.d_partitions[part].p_size==0 && part!=RAW_PART) { - sd_prevent(unit, PR_ALLOW, SCSI_ERR_OK|SCSI_SILENT); - return ENXIO; - } - - sd->partflags[part] |= SDOPEN; - sd->openparts |= (1 << part); - if(scsi_debug & TRACEOPENS) - printf("open %d %d\n", sdstrats, sdqueues); - return 0; -} - -/* - * Get ownership of a scsi_xfer - * If need be, sleep on it, until it comes free - */ -struct scsi_xfer * -sd_get_xs(int unit, int flags) -{ - struct sd_data *sd = sd_data[unit]; - struct scsi_xfer *xs; - int s; - - if(flags & (SCSI_NOSLEEP | SCSI_NOMASK)) { - if (xs = sd->freexfer) { - sd->freexfer = xs->next; - xs->flags = 0; - } - } else { - s = SPLSD(); - while (!(xs = sd->freexfer)) { - sd->blockwait++; /* someone waiting! */ - tsleep((caddr_t)&sd->freexfer, PRIBIO+1, "sd_get_xs",0); - sd->blockwait--; - } - sd->freexfer = xs->next; - splx(s); - xs->flags = 0; - } - return xs; -} - -/* - * Free a scsi_xfer, wake processes waiting for it - */ -void -sd_free_xs(int unit, struct scsi_xfer *xs, int flags) -{ - struct sd_data *sd = sd_data[unit]; - int s; - - if(flags & SCSI_NOMASK) { - if (sd->blockwait) { - printf("doing a wakeup from NOMASK mode\n"); - wakeup((caddr_t)&sd->freexfer); - } - xs->next = sd->freexfer; - sd->freexfer = xs; - } else { - s = SPLSD(); - if (sd->blockwait) - wakeup((caddr_t)&sd->freexfer); - xs->next = sd->freexfer; - sd->freexfer = xs; - splx(s); - } -} - -/* - * trim the size of the transfer if needed, called by physio - * basically the smaller of our max and the scsi driver's - * minphys (note we have no max) - */ -void -sdminphys(struct buf *bp) -{ - (*(sd_data[UNIT(bp->b_dev)]->sc_sw->scsi_minphys))(bp); -} - -/* - * Actually translate the requested transfer into - * one the physical driver can understand - * The transfer is described by a buf and will include - * only one physical transfer. - */ -void -sdstrategy(struct buf *bp) -{ - struct sd_data *sd; - unsigned int opri; - struct buf *dp; - int unit; - - sdstrats++; - unit = UNIT((bp->b_dev)); - - if(unit > NSD) { - printf("sdstrategy bailout: %d %d\n", unit, NSD); - bp->b_error = EIO; - goto bad; - } - if( !sd_data[unit]) { - printf("sdstrategy bailout\n"); - bp->b_error = EIO; - goto bad; - } - - sd = sd_data[unit]; - if(scsi_debug & PRINTROUTINES) - printf("\nsdstrategy "); - if(scsi_debug & SHOWREQUESTS) - printf("sd%d: %d bytes @ blk%d\n", - unit, bp->b_bcount, bp->b_blkno); - - /* Reject non block-aligned transfers */ - if (bp->b_bcount % SECSIZE) { - bp->b_error = EINVAL; - goto bad; - } - - sdminphys(bp); - - /* If the device has been made invalid, error out */ - if(!(sd->flags & SDVALID)) { - bp->b_error = EIO; - goto bad; - } - - /* "soft" write protect check */ - if ((sd->flags & SDWRITEPROT) && (bp->b_flags & B_READ) == 0) { - bp->b_error = EROFS; - goto bad; - } - - /* If it's a null transfer, return immediately */ - if (bp->b_bcount == 0) - goto done; - - /* - * Decide which unit and partition we are talking about - * only raw is ok if no label - */ - if(PARTITION(bp->b_dev) != RAW_PART) { - if (!(sd->flags & SDHAVELABEL)) { - bp->b_error = EIO; - goto bad; - } - - /* - * do bounds checking, adjust transfer. if error, process. - * if end of partition, just return - */ - if (bounds_check_with_label(bp, &sd->disklabel, sd->wlabel) <= 0) - goto done; - /* otherwise, process transfer request */ - } - - opri = SPLSD(); - dp = &(sd_data[unit]->sdbuf); - - /* Place it in the queue of disk activities for this disk */ - disksort(dp, bp); - - /* - * Tell the device to get going on the transfer if it's - * not doing anything, otherwise just wait for completion - */ - sdstart(unit); - - splx(opri); - return; -bad: - bp->b_flags |= B_ERROR; -done: - /* Correctly set the buf to indicate a completed xfer */ - bp->b_resid = bp->b_bcount; - biodone(bp); - return; -} - -/* - * sdstart looks to see if there is a buf waiting for the device - * and that the device is not already busy. If both are true, - * It deques the buf and creates a scsi command to perform the - * transfer in the buf. The transfer request will call sd_done - * on completion, which will in turn call this routine again - * so that the next queued transfer is performed. - * The bufs are queued by the strategy routine (sdstrategy) - * This routine is also called after other non-queued requests - * have been made of the scsi driver, to ensure that the queue - * continues to be drained. - * must be called at the correct (highish) spl level - * sdstart() is called at SPLSD from sdstrategy and sd_done - */ -void -sdstart(int unit) -{ - register struct buf *bp = 0, *dp; - struct sd_data *sd = sd_data[unit]; - struct scsi_rw_big cmd; - struct scsi_xfer *xs; - struct partition *p; - int drivecount, blkno, nblk; - - if(scsi_debug & PRINTROUTINES) - printf("sdstart%d ", unit); - - sd = sd_data[unit]; - if(!sd) - return; - - /* - * See if there is a buf to do and we are not already - * doing one - */ - if(!sd->freexfer) - return; /* none for us, unit already underway */ - - if(sd->blockwait) /* there is one, but a special waits */ - return; /* give the special that's waiting a chance to run */ - - - dp = &(sd_data[unit]->sdbuf); - if ((bp = dp->b_actf) != NULL) /* yes, an assign */ - dp->b_actf = bp->b_actf; - else - return; - - xs=sd_get_xs(unit, 0); /* ok we can grab it */ - xs->flags = INUSE; /* Now ours */ - - /* - * If the device has become invalid, abort all the reads - * and writes until all files have been closed and re-openned - */ - if( !(sd->flags & SDVALID) ) { - xs->error = XS_DRIVER_STUFFUP; - sd_done(unit,xs); /* clean up (calls sdstart) */ - return ; - } - - /* - * We have a buf, now we should move the data into - * a scsi_xfer definition and try start it - * First, translate the block to absolute - */ - p = sd->disklabel.d_partitions + PARTITION(bp->b_dev); - blkno = bp->b_blkno + p->p_offset; - nblk = (bp->b_bcount + 511) >> 9; - - /* Fill out the scsi command */ - bzero(&cmd, sizeof(cmd)); - cmd.op_code = (bp->b_flags & B_READ) ? READ_BIG : WRITE_BIG; - cmd.addr_3 = (blkno & 0xff000000) >> 24; - cmd.addr_2 = (blkno & 0xff0000) >> 16; - cmd.addr_1 = (blkno & 0xff00) >> 8; - cmd.addr_0 = blkno & 0xff; - cmd.length2 = (nblk & 0xff00) >> 8; - cmd.length1 = (nblk & 0xff); - - /* - * Fill out the scsi_xfer structure - * Note: we cannot sleep as we may be an interrupt - */ - xs->flags |= SCSI_NOSLEEP; - xs->adapter = sd->ctlr; - xs->targ = sd->targ; - xs->lu = sd->lu; - xs->retries = SD_RETRIES; - xs->timeout = 10000; /* 10000 millisecs for a disk !*/ - xs->cmd = (struct scsi_generic *)&cmd; - xs->cmdlen = sizeof(cmd); - xs->resid = bp->b_bcount; - xs->when_done = sd_done; - xs->done_arg = unit; - xs->done_arg2 = (int)xs; - xs->error = XS_NOERROR; - xs->bp = bp; - xs->data = (u_char *)bp->b_un.b_addr; - xs->datalen = bp->b_bcount; - - /* Pass all this info to the scsi driver */ - if ( (*(sd->sc_sw->scsi_cmd))(xs) != SUCCESSFULLY_QUEUED) { - printf("sd%d: oops not queued",unit); - xs->error = XS_DRIVER_STUFFUP; - sd_done(unit, xs); /* clean up (calls sdstart) */ - } - sdqueues++; -} - -/* - * This routine is called by the scsi interrupt when - * the transfer is complete. - */ -int -sd_done(int unit, struct scsi_xfer *xs) -{ - struct buf *bp; - int retval, retries = 0; - - if(scsi_debug & PRINTROUTINES) - printf("sd_done%d ",unit); - if( !(xs->flags & INUSE)) - panic("scsi_xfer not in use!"); - if(bp = xs->bp) { - switch(xs->error) { - case XS_NOERROR: - bp->b_error = 0; - bp->b_resid = 0; - break; - case XS_SENSE: - retval = (sd_interpret_sense(unit,xs)); - if(retval) { - bp->b_flags |= B_ERROR; - bp->b_error = retval; - } - break; - case XS_TIMEOUT: - printf("sd%d timeout\n",unit); - case XS_BUSY: /* should retry -- how? */ - /* - * SHOULD put buf back at head of queue - * and decrement retry count in (*xs) - * HOWEVER, this should work as a kludge - */ - if(xs->retries--) { - xs->error = XS_NOERROR; - xs->flags &= ~ITSDONE; - if( (*(sd_data[unit]->sc_sw->scsi_cmd))(xs) - == SUCCESSFULLY_QUEUED) { - /* don't wake the job, ok? */ - return; - } - xs->flags |= ITSDONE; - } /* fall through */ - - case XS_DRIVER_STUFFUP: - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - break; - default: - printf("sd%d: unknown error category from scsi driver\n", unit); - } - biodone(bp); - sd_free_xs(unit, xs, 0); - sdstart(unit); /* If there's anything waiting.. do it */ - } else - wakeup((caddr_t)xs); -} - -/* - * Perform special action on behalf of the user - * Knows about the internals of this device - */ -int -sdioctl(dev_t dev, int cmd, caddr_t addr, int flag) -{ - /* struct sd_cmd_buf *args;*/ - struct scsi_format_parms *fparms; - struct cpu_disklabel osdep; - extern struct proc *curproc; - register struct sd_data *sd; - unsigned char unit, part; - unsigned int opri; - int error = 0, x; - - /* Find the device that the user is talking about */ - unit = UNIT(dev); - part = PARTITION(dev); - if(scsi_debug & PRINTROUTINES) - printf("sdioctl%d ",unit); - - /* If the device is not valid.. abandon ship */ - if(unit > NSD) - return EIO; - sd = sd_data[unit]; - if(sd==NULL) - return EIO; - - if(!(sd->flags & SDVALID)) - return EIO; - - switch(cmd) { - case DIOCWFORMAT: - if( suser(curproc->p_ucred, &curproc->p_acflag)) - return EPERM; - - x = splbio(); - if(sd->formatting) - return EBUSY; - sd->formatting = 1; - (void)splx(x); - - fparms = (struct scsi_format_parms *)malloc(sizeof *fparms, - M_TEMP, M_NOWAIT); - if(!fparms) { - error = EAGAIN; - goto unlock; - } - - if(copyin(&addr, fparms, sizeof fparms)!=0) { - free(fparms, M_TEMP); - error = EFAULT; - goto unlock; - } - error = sd_format(unit, fparms, 0, 0); - if(!error && copyout(&addr, fparms, sizeof fparms) ) - error = EFAULT; - free(fparms, M_TEMP); -unlock: - x = splbio(); - sd->formatting = 0; - (void)splx(x); - - break; - case DIOCRFORMAT: - error = EINVAL; - break; - case DIOCSBAD: - error = EINVAL; - break; - case DIOCGDINFO: - *(struct disklabel *)addr = sd->disklabel; - break; - case DIOCGPART: - ((struct partinfo *)addr)->disklab = &sd->disklabel; - ((struct partinfo *)addr)->part = - &sd->disklabel.d_partitions[PARTITION(dev)]; - break; - case DIOCSDINFO: - if ((flag & FWRITE) == 0) - error = EBADF; - else { - error = setdisklabel(&sd->disklabel, (struct disklabel *)addr, - /*(sd->flags & DKFL_BSDLABEL) ? sd->openparts : */0, - &sd->cpudisklabel); - } - if (error == 0) - sd->flags |= SDHAVELABEL; - break; - case DIOCWLABEL: - sd->flags &= ~SDWRITEPROT; - if ((flag & FWRITE) == 0) - error = EBADF; - else - sd->wlabel = *(int *)addr; - break; - case DIOCWDINFO: - sd->flags &= ~SDWRITEPROT; - if ((flag & FWRITE) == 0) - error = EBADF; - else { - if ((error = setdisklabel(&sd->disklabel, - (struct disklabel *)addr, - /*(sd->flags & SDHAVELABEL) ? sd->openparts :*/0, - &sd->cpudisklabel)) == 0) { - int wlab; - - sd->flags |= SDHAVELABEL; /* ok write will succeed */ - - /* simulate opening partition 0 so write succeeds */ - sd->openparts |= (1 << 0); /* XXX */ - wlab = sd->wlabel; - sd->wlabel = 1; - error = writedisklabel(dev, sdstrategy, - &sd->disklabel, &sd->cpudisklabel); - sd->wlabel = wlab; - } - } - break; - default: - error = ENOTTY; - break; - } - return error; -} - - -/* - * Load the label information on the named device - */ -int -sdgetdisklabel(u_char unit) -{ - struct sd_data *sd = sd_data[unit]; - /*unsigned int n, m;*/ - char *errstring; - struct cpu_disklabel osdep; - - /* If the inflo is already loaded, use it */ - if(sd->flags & SDHAVELABEL) - return ESUCCESS; - - bzero(&sd->disklabel, sizeof(struct disklabel)); - /* - * make RAW_PART the whole disk in case of failure - * then get pdinfo - */ - sd->disklabel.d_partitions[0].p_offset = 0; - sd->disklabel.d_partitions[0].p_size = sd->params.disksize; - sd->disklabel.d_partitions[RAW_PART].p_offset = 0; - sd->disklabel.d_partitions[RAW_PART].p_size = sd->params.disksize; - sd->disklabel.d_npartitions = MAXPARTITIONS; - sd->disklabel.d_secsize = SECSIZE; /* as long as it's not 0 */ - sd->disklabel.d_ntracks = sd->params.heads; - sd->disklabel.d_nsectors = sd->params.sectors; - sd->disklabel.d_ncylinders = sd->params.cyls; - sd->disklabel.d_secpercyl = sd->params.heads * sd->params.sectors; - if (sd->disklabel.d_secpercyl == 0) { - /* as long as it's not 0 because readdisklabel() divides by it */ - sd->disklabel.d_secpercyl = 100; - } - - /* all the generic disklabel extraction routine */ - if(errstring = readdisklabel(makedev(0 ,(unit<disklabel, &sd->cpudisklabel)) { - printf("sd%d: %s\n",unit, errstring); - return ENXIO; - } - - /* leave partition 2 "open" for raw I/O */ - - sd->flags |= SDHAVELABEL; /* WE HAVE IT ALL NOW */ - return ESUCCESS; -} - -/* - * Find out from the device what it's capacity is - */ -int -sd_size(int unit, int flags) -{ - struct scsi_read_cap_data rdcap; - struct scsi_read_capacity scsi_cmd; - int size; - - /* - * make up a scsi command and ask the scsi driver to do - * it for you. - */ - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = READ_CAPACITY; - - /* - * If the command works, interpret the result as a 4 byte - * number of blocks - */ - if (sd_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)&rdcap, sizeof(rdcap), 2000, flags) != 0) { - printf("could not get size of unit %d\n", unit); - return 0; - } else { - size = rdcap.addr_0 + 1 ; - size += rdcap.addr_1 << 8; - size += rdcap.addr_2 << 16; - size += rdcap.addr_3 << 24; - } - return size; -} - -/* - * Get scsi driver to send a "are you ready?" command - */ -int -sd_test_unit_ready(int unit, int flags) -{ - struct scsi_test_unit_ready scsi_cmd; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = TEST_UNIT_READY; - - return sd_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), 0, 0, 100000, flags); -} - -/* - * format disk - */ -int -sd_format(int unit, struct scsi_format_parms *f, int flags, int type) -{ - struct scsi_prevent scsi_cmd; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = FORMAT_DISK; - scsi_cmd.prevent= type; - return sd_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)f, sizeof *f, 500000000, flags); -} - -/* - * Prevent or allow the user to remove the tape - */ -int -sd_prevent(int unit, int type, int flags) -{ - struct scsi_prevent scsi_cmd; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = PREVENT_ALLOW; - scsi_cmd.prevent=type; - return sd_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), 0, 0, 5000, flags); -} - -/* - * Get scsi driver to send a "start up" command - */ -int -sd_start_unit(int unit, int flags) -{ - struct scsi_start_stop scsi_cmd; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = START_STOP; - scsi_cmd.start = 1; - - return sd_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), 0, 0, 2000, flags); -} - -/* - * Tell the device to map out a defective block - */ -int -sd_reassign_blocks(int unit, int block) -{ - struct scsi_reassign_blocks_data rbdata; - struct scsi_reassign_blocks scsi_cmd; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - bzero(&rbdata, sizeof(rbdata)); - scsi_cmd.op_code = REASSIGN_BLOCKS; - - rbdata.length_msb = 0; - rbdata.length_lsb = sizeof(rbdata.defect_descriptor[0]); - rbdata.defect_descriptor[0].dlbaddr_3 = ((block >> 24) & 0xff); - rbdata.defect_descriptor[0].dlbaddr_2 = ((block >> 16) & 0xff); - rbdata.defect_descriptor[0].dlbaddr_1 = ((block >> 8) & 0xff); - rbdata.defect_descriptor[0].dlbaddr_0 = ((block ) & 0xff); - - return sd_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)&rbdata, sizeof(rbdata), 5000, 0); -} - -#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0 ) - -/* - * Get the scsi driver to send a full inquiry to the - * device and use the results to fill out the disk - * parameter structure. - */ -int -sd_get_parms(int unit, int flags) -{ - struct sd_data *sd = sd_data[unit]; - struct disk_parms *disk_parms = &sd->params; - struct scsi_mode_sense scsi_cmd; - union scsi_mode_sense_data { - struct t1 { - struct scsi_mode_header header; - struct blk_desc blk_desc; - union disk_pages pages; - } t1; - struct t0 { - struct scsi_mode_header header; - union disk_pages pages; - } t0; - } scsi_sense; - struct page_disk_format *scsi_disk_format; - struct page_rigid_geometry *scsi_disk_geometry; - int sectors; - - /* First check if we have it all loaded */ - if(!sd) - return 0; - if(sd->flags & SDVALID) - return 0; - - /* First do a mode sense page 3 */ - if (sd_debug) { - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = MODE_SENSE; - scsi_cmd.page_code = 3; - scsi_cmd.length = 0x24; - - /* - * do the command, but we don't need the results - * just print them for our interest's sake - */ - if (sd_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)&scsi_sense, sizeof(scsi_sense), - 2000, flags) != 0) { - printf("could not mode sense (3) for unit %d\n", unit); - return ENXIO; - } - if (scsi_sense.t1.header.blk_desc_len == 0) - scsi_disk_format = &scsi_sense.t0.pages.disk_format; - else - scsi_disk_format = &scsi_sense.t1.pages.disk_format; - - printf("unit %d: %d trk/zn, %d altsec/zn, %d alttrk/zn, %d alttrk/lun\n", - unit, b2tol(scsi_disk_format->trk_z), - b2tol(scsi_disk_format->alt_sec), - b2tol(scsi_disk_format->alt_trk_z), - b2tol(scsi_disk_format->alt_trk_v)); - printf(" %d sec/trk, %d byte/sec, %d interleave, %d blks\n", - b2tol(scsi_disk_format->ph_sec_t), - b2tol(scsi_disk_format->bytes_s), - b2tol(scsi_disk_format->interleave), - sd_size(unit, flags)); - } - - - /* do a "mode sense page 4" */ - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = MODE_SENSE; - scsi_cmd.page_code = 4; - scsi_cmd.length = 0x20; - - /* - * If the command worked, use the results to fill out - * the parameter structure - */ - if (sd_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)&scsi_sense, sizeof(scsi_sense), - 2000, flags) != 0) { - printf("could not mode sense (4) for unit %d\n", unit); - printf(" using ficticious geometry\n"); - sectors = sd_size(unit, flags); - disk_parms->heads = 64; - disk_parms->sectors = 32; - disk_parms->cyls = sectors/(64 * 32); - disk_parms->secsiz = SECSIZE; - } else { - if (scsi_sense.t1.header.blk_desc_len == 0) - scsi_disk_geometry = &scsi_sense.t0.pages.rigid_geometry; - else - scsi_disk_geometry = &scsi_sense.t1.pages.rigid_geometry; - - if (sd_debug) { - printf(" %d cyl, %d head, %d precomp, %d redwrite, %d land\n", - _3btol((u_char *)&scsi_disk_geometry->ncyl_2), - scsi_disk_geometry->nheads, - b2tol(scsi_disk_geometry->st_cyl_wp), - b2tol(scsi_disk_geometry->st_cyl_rwc), - b2tol(scsi_disk_geometry->land_zone)); - } - - /* - * KLUDGE!!(for zone recorded disks) - * give a number of sectors so that sec * trks * cyls - * is <= disk_size - */ - disk_parms->heads = scsi_disk_geometry->nheads; - disk_parms->cyls = - _3btol((u_char *)&scsi_disk_geometry->ncyl_2); - if (scsi_sense.t1.header.blk_desc_len != 0) - disk_parms->secsiz = _3btol((u_char *)&scsi_sense.t1.blk_desc.blklen); - else - disk_parms->secsiz = SECSIZE; /* Should use read_cap instead */ - - sectors = sd_size(unit, flags); - sectors /= disk_parms->cyls; - sectors /= disk_parms->heads; - disk_parms->sectors = sectors; /* dubious on SCSI*/ - } - - disk_parms->disksize = disk_parms->sectors * disk_parms->heads * - disk_parms->cyls; - sd->flags |= SDVALID; - return 0; -} - -/* - * close the device.. only called if we are the LAST - * occurence of an open device - */ -int -sdclose(dev_t dev) -{ - struct sd_data *sd; - unsigned char unit, part; - unsigned int old_priority; - - unit = UNIT(dev); - part = PARTITION(dev); - sd = sd_data[unit]; - sd->partflags[part] &= ~SDOPEN; - sd->openparts &= ~(1 << part); - if(sd->openparts == 0) - sd_prevent(unit, PR_ALLOW, SCSI_SILENT|SCSI_ERR_OK); - return 0; -} - -/* - * ask the scsi driver to perform a command for us. - * Call it through the switch table, and tell it which - * sub-unit we want, and what target and lu we wish to - * talk to. Also tell it where to find the command - * how long int is. - * Also tell it where to read/write the data, and how - * long the data is supposed to be - */ -int -sd_scsi_cmd(int unit, struct scsi_generic *scsi_cmd, int cmdlen, - u_char *data_addr, int datalen, int timeout, int flags) -{ - struct sd_data *sd = sd_data[unit]; - struct scsi_xfer *xs; - int retval, s; - - if(scsi_debug & PRINTROUTINES) - printf("\nsd_scsi_cmd%d ",unit); - if(!sd->sc_sw) { - printf("sd%d: not set up\n",unit); - return EINVAL; - } - - xs = sd_get_xs(unit,flags); /* should wait unless booting */ - if(!xs) { - printf("sd_scsi_cmd%d: controller busy" - " (this should never happen)\n",unit); - return EBUSY; - } - - xs->flags |= INUSE; - xs->flags |= flags; - xs->adapter = sd->ctlr; - xs->targ = sd->targ; - xs->lu = sd->lu; - xs->retries = SD_RETRIES; - xs->timeout = timeout; - xs->cmd = scsi_cmd; - xs->cmdlen = cmdlen; - xs->data = data_addr; - xs->datalen = datalen; - xs->resid = datalen; - xs->when_done = (flags & SCSI_NOMASK) ?(int (*)())0 : sd_done; - xs->done_arg = unit; - xs->done_arg2 = (int)xs; - -retry: - xs->error = XS_NOERROR; - xs->bp = 0; - retval = (*(sd->sc_sw->scsi_cmd))(xs); - switch(retval) { - case SUCCESSFULLY_QUEUED: - s = splbio(); - while(!(xs->flags & ITSDONE)) - tsleep((caddr_t)xs, PRIBIO+1, "sd_cmd", 0); - splx(s); - case HAD_ERROR: - /*printf("err = %d ", xs->error);*/ - switch(xs->error) { - case XS_NOERROR: - retval = ESUCCESS; - break; - case XS_SENSE: - retval = sd_interpret_sense(unit, xs); - break; - case XS_DRIVER_STUFFUP: - retval = EIO; - break; - case XS_TIMEOUT: - case XS_BUSY: - if(xs->retries-- ) { - xs->flags &= ~ITSDONE; - goto retry; - } - retval = EIO; - break; - default: - retval = EIO; - printf("sd%d: unknown error category from scsi driver\n", unit); - } - break; - case COMPLETE: - retval = ESUCCESS; - break; - case TRY_AGAIN_LATER: - if(xs->retries-- ) { - xs->flags &= ~ITSDONE; - goto retry; - } - retval = EIO; - break; - default: - retval = EIO; - } - - sd_free_xs(unit, xs, flags); - sdstart(unit); /* check if anything is waiting fr the xs */ - return retval; -} - -/* - * Look at the returned sense and act on the error and detirmine - * The unix error number to pass back... (0 = report no error) - */ -int -sd_interpret_sense(int unit, struct scsi_xfer *xs) -{ - struct sd_data *sd = sd_data[unit]; - struct scsi_sense_data *sense; - int key, silent; - - /* If the flags say errs are ok, then always return ok. */ - if (xs->flags & SCSI_ERR_OK) - return ESUCCESS; - silent = (xs->flags & SCSI_SILENT); - - sense = &(xs->sense); - switch(sense->error_class) { - case 7: - key = sense->ext.extended.sense_key; - switch(key) { - case 0x0: - return ESUCCESS; - case 0x1: - if(!silent) { - printf("sd%d: soft error(corrected) ", unit); - if(sense->valid) { - printf("block no. %d (decimal)", - (sense->ext.extended.info[0] <<24) | - (sense->ext.extended.info[1] <<16) | - (sense->ext.extended.info[2] <<8) | - (sense->ext.extended.info[3] )); - } - printf("\n"); - } - return ESUCCESS; - case 0x2: - if(!silent) - printf("sd%d: not ready\n ", unit); - return ENODEV; - case 0x3: - if(!silent) { - printf("sd%d: medium error ", unit); - if(sense->valid) { - printf("block no. %d (decimal)", - (sense->ext.extended.info[0] <<24) | - (sense->ext.extended.info[1] <<16) | - (sense->ext.extended.info[2] <<8) | - (sense->ext.extended.info[3] )); - } - printf("\n"); - } - return EIO; - case 0x4: - if(!silent) - printf("sd%d: non-media hardware failure\n ", unit); - return EIO; - case 0x5: - if(!silent) - printf("sd%d: illegal request\n ", unit); - return EINVAL; - case 0x6: - /* - * If we are not open, then this is not an error - * as we don't have state yet. Either way, make - * sure that we don't have any residual state - */ - if(!silent) - printf("sd%d: reset\n", unit); - sd->flags &= ~(SDVALID | SDHAVELABEL); - if (sd->openparts) - return EIO; - return ESUCCESS; /* not an error if nothing's open */ - case 0x7: - if(!silent) { - printf("sd%d: attempted protection violation ", unit); - if(sense->valid) { - printf("block no. %d (decimal)\n", - (sense->ext.extended.info[0] <<24) | - (sense->ext.extended.info[1] <<16) | - (sense->ext.extended.info[2] <<8) | - (sense->ext.extended.info[3] )); - } - printf("\n"); - } - return EACCES; - case 0x8: - if(!silent) { - printf("sd%d: block wrong state (worm)\n ", unit); - if(sense->valid) { - printf("block no. %d (decimal)\n", - (sense->ext.extended.info[0] <<24) | - (sense->ext.extended.info[1] <<16) | - (sense->ext.extended.info[2] <<8) | - (sense->ext.extended.info[3] )); - } - printf("\n"); - } - return EIO; - case 0x9: - if(!silent) - printf("sd%d: vendor unique\n", unit); - return EIO; - case 0xa: - if(!silent) - printf("sd%d: copy aborted\n ", unit); - return EIO; - case 0xb: - if(!silent) - printf("sd%d: command aborted\n ", unit); - return EIO; - case 0xc: - if(!silent) { - printf("sd%d: search returned\n ", unit); - if(sense->valid) { - printf("block no. %d (decimal)\n", - (sense->ext.extended.info[0] <<24) | - (sense->ext.extended.info[1] <<16) | - (sense->ext.extended.info[2] <<8) | - (sense->ext.extended.info[3] )); - } - printf("\n"); - } - return ESUCCESS; - case 0xd: - if(!silent) - printf("sd%d: volume overflow\n ", unit); - return ENOSPC; - case 0xe: - if(!silent) { - printf("sd%d: verify miscompare\n ", unit); - if(sense->valid) { - printf("block no. %d (decimal)\n", - (sense->ext.extended.info[0] <<24) | - (sense->ext.extended.info[1] <<16) | - (sense->ext.extended.info[2] <<8) | - (sense->ext.extended.info[3] )); - } - printf("\n"); - } - return EIO; - case 0xf: - if(!silent) - printf("sd%d: unknown error key\n ", unit); - return EIO; - } - break; - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - if(!silent)printf("sd%d: error class %d code %d\n", unit, - sense->error_class, sense->error_code); - if(sense->valid) - if(!silent) - printf("block no. %d (decimal)\n", - (sense->ext.unextended.blockhi <<16) - + (sense->ext.unextended.blockmed <<8) - + (sense->ext.unextended.blocklow )); - return EIO; - } - return 0; /* XXX? */ -} - -int -sdsize(dev_t dev) -{ - int unit = UNIT(dev), part = PARTITION(dev), val; - struct sd_data *sd; - - if (unit >= NSD) - return -1; - if(!sd_data[unit]) - return -1; - - sd = sd_data[unit]; - if((sd->flags & SDINIT) == 0) - return -1; - - if( sd==0 || (sd->flags & SDHAVELABEL)==0 ) - val = sdopen(MAKESDDEV(major(dev), unit, RAW_PART)); - if ( val!=0 || sd->flags & SDWRITEPROT) - return -1; - - return (int)sd->disklabel.d_partitions[part].p_size; -} - -sddump() -{ - printf("sddump() -- not implemented\n"); - return -1; -} diff --git a/sys/arch/pc532/scsi/sddefs.h b/sys/arch/pc532/scsi/sddefs.h deleted file mode 100644 index 90d57378d1f1..000000000000 --- a/sys/arch/pc532/scsi/sddefs.h +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: sddefs.h,v 1.2 1994/10/26 08:25:38 cgd Exp $ */ - -struct sd_data { - int flags; -#define SDVALID 0x02 /* PARAMS LOADED */ -#define SDINIT 0x04 /* device has been init'd */ -#define SDWAIT 0x08 /* device has someone waiting */ -#define SDHAVELABEL 0x10 /* have read the label */ -#define SDDOSPART 0x20 /* Have read host-dependent partition table */ -#define SDWRITEPROT 0x40 /* Device in readonly mode (S/W)*/ - struct scsi_switch *sc_sw; /* address of scsi low level switch */ - struct scsi_xfer *freexfer; /* chain of free ones */ - struct buf sdbuf; - int formatting; /* format lock */ - int ctlr; /* so they know which one we want */ - int targ; /* our scsi target ID */ - int lu; /* out scsi lu */ - long int ad_info; /* info about the adapter */ - int cmdscount; /* cmds allowed outstanding by board*/ - int wlabel; /* label is writable */ - struct disk_parms { - u_char heads; /* Number of heads */ - u_short cyls; /* Number of cylinders */ - u_char sectors; /* Number of sectors/track */ - u_short secsiz; /* Number of bytes/sector */ - u_long disksize; /* total number sectors */ - } params; - unsigned int sd_start_of_unix; /* unix vs host-dependent partitions */ - struct disklabel disklabel; - struct cpu_disklabel cpudisklabel; - int partflags[MAXPARTITIONS]; /* per partition flags */ -#define SDOPEN 0x01 - int openparts; /* one bit for each open partition */ - int blockwait; -}; - -int sdattach(int, struct scsi_switch *, int, int *); -int sdopen(int); -struct scsi_xfer *sd_get_xs(int, int); -void sd_free_xs(int, struct scsi_xfer *, int); -void sdminphys(struct buf *); -void sdstrategy(struct buf *); -void sdstart(int); -int sd_done(int, struct scsi_xfer *); -int sdioctl(dev_t, int, caddr_t, int); -int sdgetdisklabel(u_char); -int sd_size(int, int); -int sd_test_unit_ready(int, int); -void sd_dump(); -int sdsize(dev_t); -int sd_interpret_sense(int, struct scsi_xfer *); -int sd_scsi_cmd(int, struct scsi_generic *, int, u_char *, int, int, int); -int sd_close(dev_t); -int sd_get_parms(int, int); -int sd_reassign_blocks(int, int); -int sd_start_unit(int, int); -int sd_prevent(int, int, int); diff --git a/sys/arch/pc532/scsi/st.c b/sys/arch/pc532/scsi/st.c deleted file mode 100644 index ffa1e640d510..000000000000 --- a/sys/arch/pc532/scsi/st.c +++ /dev/null @@ -1,1422 +0,0 @@ -/* $NetBSD: st.c,v 1.3 1994/10/26 08:25:39 cgd Exp $ */ - -/* - * Written by Julian Elischer (julian@tfs.com) - * for TRW Financial Systems for use under the MACH(2.5) operating system. - * Hacked by Theo de Raadt - * - * TRW Financial Systems, in accordance with their agreement with Carnegie - * Mellon University, makes this software available to CMU to distribute - * or use in any manner that they see fit as long as this message is kept with - * the software. For this reason TFS also grants any other persons or - * organisations permission to use or modify this software. - * - * TFS supplies this software to be publicly redistributed - * on the understanding that TFS is not responsible for the correct - * functioning of this software in any circumstances. - */ - -/* - * To do: - * work out some better way of guessing what a good timeout is going - * to be depending on whether we expect to retension or not. - * - */ - -#include "st.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../scsi/scsi_all.h" -#include "../../scsi/scsi_tape.h" -#include "../../scsi/scsiconf.h" -#include "../../scsi/stdefs.h" - -long int ststrats, stqueues; - -#define ST_RETRIES 4 - -#define UNITSHIFT 4 -#define MODE(z) ((minor(z) & 0x03)) -#define DSTY(z) (((minor(z) >> 2) & 0x03)) -#define UNIT(z) ((minor(z) >> UNITSHIFT)) - -#undef NST -#define NST ( makedev(1,0) >> UNITSHIFT) - -#define DSTY_QIC120 3 -#define DSTY_QIC150 2 -#define DSTY_QIC525 1 - -#define QIC120 0x0f -#define QIC150 0x10 -#define QIC525 0x11 - -#define ESUCCESS 0 - -int st_debug = 0; - -struct st_data *st_data[NST]; -static int next_st_unit = 0; - -/* - * The routine called by the low level scsi routine when it discovers - * A device suitable for this driver - */ -int -stattach(int masunit, struct scsi_switch *sw, int physid, int *unit) -{ - struct st_data *st; - unsigned char *tbl; - int targ, lun, i; - - targ = physid >> 3; - lun = physid & 7; - - /*printf("stattach: st%d at %s%d target %d lun %d\n", - *unit, sw->name, masunit, targ, lun);*/ - - if(*unit==-1) { - for(i=0; i= NST || *unit==-1) - return 0; - if(st_data[*unit]) - return 0; - - st = st_data[*unit] = (struct st_data *)malloc(sizeof *st, - M_TEMP, M_NOWAIT); - bzero(st, sizeof *st); - - st->sc_sw = sw; - st->ctlr = masunit; - st->targ = targ; - st->lu = lun; - - /* - * Use the subdriver to request information regarding - * the drive. We cannot use interrupts yet, so the - * request must specify this. - */ - if( st_mode_sense(*unit, SCSI_NOSLEEP | SCSI_NOMASK | SCSI_SILENT)) - printf("st%d at %s%d targ %d lun %d: %d blocks of %d bytes\n", - *unit, sw->name, masunit, targ, lun, - st->numblks, st->blksiz); - else - printf("st%d at %s%d targ %d lun %d: offline\n", - *unit, sw->name, masunit, targ, lun); - - /* - * Set up the bufs for this device - */ - st->buf_queue.b_active = 0; - st->buf_queue.b_actf = 0; - st->buf_queue.b_actb = &st->buf_queue.b_actf; - st->initialized = 1; - return 1; -} - -/* - * open the device. -*/ -int -stopen(dev_t dev) -{ - int errcode = 0; - int unit, mode, dsty; - int dsty_code; - struct st_data *st; - unit = UNIT(dev); - mode = MODE(dev); - dsty = DSTY(dev); - st = st_data[unit]; - - /* - * Check the unit is legal - */ - if( unit >= NST ) - return ENXIO; - if(!st) - return ENXIO; - - /* - * Only allow one at a time - */ - if(st->flags & ST_OPEN) { - errcode = EBUSY; - goto bad; - } - /* - * Set up the mode flags according to the minor number - * ensure all open flags are in a known state - */ - st->flags &= ~ST_PER_OPEN; - switch(mode) { - case 2: - case 0: - st->flags &= ~ST_NOREWIND; - break; - case 3: - case 1: - st->flags |= ST_NOREWIND; - break; - default: - printf("st%d: bad mode (minor number) %d\n", unit, mode); - return EINVAL; - } - /* - * Check density code: 0 is drive default - */ - switch(dsty) { - case 0: - dsty_code = 0; - break; - case DSTY_QIC120: - dsty_code = QIC120; - break; - case DSTY_QIC150: - dsty_code = QIC150; - break; - case DSTY_QIC525: - dsty_code = QIC525; - break; - default: - printf("st%d: bad density (minor number) %d\n", unit, dsty); - return EINVAL; - } - - if(scsi_debug & (PRINTROUTINES | TRACEOPENS)) - printf("st%d: open dev=0x%x (unit %d (of %d))\n", unit, dev, NST); - - /* - * Make sure the device has been initialised - */ - if (!st->initialized) { - /*printf("st%d: uninitialized\n", unit);*/ - return ENXIO; - } - - /* - * Check that it is still responding and ok. - */ - if (!(st_req_sense(unit, 0))) { - errcode = EIO; - if(scsi_debug & TRACEOPENS) - printf("st%d: not responding\n", unit); - goto bad; - } - if(scsi_debug & TRACEOPENS) - printf("st%d: is responding\n", unit); - - if(!(st_test_ready(unit, 0))) { - printf("st%d: not ready\n", unit); - return EIO; - } - - if(!st->info_valid) /* is media new? */ - if(!st_load(unit, LD_LOAD, 0)) - return EIO; - - if(!st_rd_blk_lim(unit, 0)) - return EIO; - - if(!st_mode_sense(unit, 0)) - return EIO; - - if(!st_mode_select(unit, 0, dsty_code)) - return EIO; - - st->info_valid = TRUE; - - st_prevent(unit, PR_PREVENT, 0); /* who cares if it fails? */ - - /* - * Load the physical device parameters - */ - if(scsi_debug & TRACEOPENS) - printf("st%d: params ", unit); - st->flags |= ST_OPEN; - -bad: - return errcode; -} - -/* - * close the device.. only called if we are the LAST - * occurence of an open device -*/ -int -stclose(dev_t dev) -{ - unsigned char unit, mode; - struct st_data *st; - - unit = UNIT(dev); - mode = MODE(dev); - st = st_data[unit]; - - if(scsi_debug & TRACEOPENS) - printf("st%d: close\n", unit); - if(st->flags & ST_WRITTEN) - st_write_filemarks(unit, 1, 0); - - st->flags &= ~ST_WRITTEN; - switch(mode) { - case 0: - st_rewind(unit, FALSE, SCSI_SILENT); - st_prevent(unit, PR_ALLOW, SCSI_SILENT); - break; - case 1: - st_prevent(unit, PR_ALLOW, SCSI_SILENT); - break; - case 2: - st_rewind(unit, FALSE, SCSI_SILENT); - st_prevent(unit, PR_ALLOW, SCSI_SILENT); - st_load(unit, LD_UNLOAD, SCSI_SILENT); - break; - case 3: - st_prevent(unit, PR_ALLOW, SCSI_SILENT); - st_load(unit, LD_UNLOAD, SCSI_SILENT); - break; - default: - printf("st%d: bad mode (minor number) %d (how's it open?)\n", - unit, mode); - return EINVAL; - } - st->flags &= ~ST_PER_OPEN; - return 0; -} - -/* - * trim the size of the transfer if needed, - * called by physio - * basically the smaller of our min and the scsi driver's* - * minphys - */ -void -stminphys(struct buf *bp) -{ - (*(st_data[UNIT(bp->b_dev)]->sc_sw->scsi_minphys))(bp); -} - -/* - * Actually translate the requested transfer into - * one the physical driver can understand - * The transfer is described by a buf and will include - * only one physical transfer. - */ -void -ststrategy(struct buf *bp) -{ - struct st_data *st; - struct buf *dp; - unsigned char unit; - unsigned int opri; - - if (bp->b_bcount == 0) - goto done; - - ststrats++; - unit = UNIT((bp->b_dev)); - st = st_data[unit]; - if(scsi_debug & PRINTROUTINES) - printf("\nststrategy "); - if(scsi_debug & SHOWREQUESTS) - printf("st%d: %d bytes @ blk%d\n", unit, bp->b_bcount, bp->b_blkno); - - /* - * Odd sized request on fixed drives are verboten - */ - if((st->flags & ST_FIXEDBLOCKS) && bp->b_bcount % st->blkmin) { - printf("st%d: bad request, must be multiple of %d\n", - unit, st->blkmin); - bp->b_error = EIO; - goto bad; - } - - stminphys(bp); - opri = splbio(); - dp = &st->buf_queue; - - /* - * Place it at the end of the queue of activities for this tape. - */ - bp->b_actf = NULL; - bp->b_actb = dp->b_actb; - *dp->b_actb = bp; - dp->b_actb = &bp->b_actf; - - /* - * Tell the device to get going on the transfer if it's - * not doing anything, otherwise just wait for completion. - */ - ststart(unit); - - splx(opri); - return; -bad: - bp->b_flags |= B_ERROR; -done: - /* - * Correctly set the buf to indicate a completed xfer - */ - iodone(bp); - return; -} - - -/* - * ststart looks to see if there is a buf waiting for the device - * and that the device is not already busy. If both are true, - * It deques the buf and creates a scsi command to perform the - * transfer in the buf. The transfer request will call st_done - * on completion, which will in turn call this routine again - * so that the next queued transfer is performed. - * The bufs are queued by the strategy routine (ststrategy) - * - * This routine is also called after other non-queued requests - * have been made of the scsi driver, to ensure that the queue - * continues to be drained. -*/ -/* ststart() is called at splbio */ -int -ststart(int unit) -{ - struct st_data *st = st_data[unit]; - register struct buf *bp = 0, *dp; - struct scsi_rw_tape cmd; - struct scsi_xfer *xs; - int drivecount, blkno, nblk; - - if(scsi_debug & PRINTROUTINES) - printf("st%d: start\n", unit); - - /* - * See if there is a buf to do and we are not already - * doing one - */ - xs = &st->scsi_xfer; - if(xs->flags & INUSE) - return; /* unit already underway */ - -trynext: - if(st->blockwait) { - wakeup((caddr_t)&st->blockwait); - return; - } - - bp = st->buf_queue.b_actf; - if (!bp) - return; - if (dp = bp->b_actf) - dp->b_actb = bp->b_actb; - else - st->buf_queue.b_actb = bp->b_actb; - *bp->b_actb = dp; - xs->flags = INUSE; /* Now ours */ - - /* - * We have a buf, now we should move the data into - * a scsi_xfer definition and try start it - */ - - /* - * If we are at a filemark but have not reported it yet - * then we should report it now - */ - if(st->flags & ST_AT_FILEMARK) { - bp->b_error = 0; - bp->b_flags |= B_ERROR; /* EOF*/ - st->flags &= ~ST_AT_FILEMARK; - biodone(bp); - xs->flags = 0; /* won't need it now */ - goto trynext; - } - - /* - * If we are at EOM but have not reported it yet - * then we should report it now - */ - if(st->flags & ST_AT_EOM) { - bp->b_error = EIO; - bp->b_flags |= B_ERROR; - st->flags &= ~ST_AT_EOM; - biodone(bp); - xs->flags = 0; /* won't need it now */ - goto trynext; - } - - /* - * Fill out the scsi command - */ - bzero(&cmd, sizeof(cmd)); - if((bp->b_flags & B_READ) == B_WRITE) { - st->flags |= ST_WRITTEN; - xs->flags |= SCSI_DATA_OUT; - } - else - xs->flags |= SCSI_DATA_IN; - cmd.op_code = (bp->b_flags & B_READ) ? READ_COMMAND_TAPE : WRITE_COMMAND_TAPE; - - /* - * Handle "fixed-block-mode" tape drives by using the * - * block count instead of the length. - */ - if(st->flags & ST_FIXEDBLOCKS) { - cmd.fixed = 1; - lto3b(bp->b_bcount/st->blkmin, cmd.len); - } - else - lto3b(bp->b_bcount, cmd.len); - - /* - * Fill out the scsi_xfer structure - * Note: we cannot sleep as we may be an interrupt - */ - xs->flags |= SCSI_NOSLEEP; - xs->adapter = st->ctlr; - xs->targ = st->targ; - xs->lu = st->lu; - xs->retries = 1; /* can't retry on tape*/ - xs->timeout = 200000; /* allow 200 secs for retension */ - xs->cmd = (struct scsi_generic *)&cmd; - xs->cmdlen = sizeof(cmd); - xs->data = (u_char *)bp->b_un.b_addr; - xs->datalen = bp->b_bcount; - xs->resid = bp->b_bcount; - xs->when_done = st_done; - xs->done_arg = unit; - xs->done_arg2 = (int)xs; - xs->error = XS_NOERROR; - xs->bp = bp; - -#if defined(OSF) || defined(FIX_ME) - if (bp->b_flags & B_PHYS) { - xs->data = (u_char*)map_pva_kva(bp->b_proc, bp->b_un.b_addr, - bp->b_bcount, st_window[unit], - (bp->b_flags&B_READ)?B_WRITE:B_READ); - } else - xs->data = (u_char*)bp->b_un.b_addr; -#endif /* defined(OSF) */ - - if ( (*(st->sc_sw->scsi_cmd))(xs) != SUCCESSFULLY_QUEUED) { - printf("st%d: oops not queued", unit); - xs->error = XS_DRIVER_STUFFUP; - st_done(unit, xs); - } - stqueues++; -} - -/* - * This routine is called by the scsi interrupt when - * the transfer is complete. -*/ -int -st_done(int unit, struct scsi_xfer *xs) -{ - struct st_data *st = st_data[unit]; - struct buf *bp; - int retval; - - if(scsi_debug & PRINTROUTINES) - printf("st%d: done\n", unit); - if (! (xs->flags & INUSE)) - panic("scsi_xfer not in use!"); - - if(bp = xs->bp) { - switch(xs->error) { - case XS_NOERROR: - bp->b_flags &= ~B_ERROR; - bp->b_error = 0; - bp->b_resid = 0; - break; - case XS_SENSE: - retval = st_interpret_sense(unit, xs); - if(retval) { - /* - * We have a real error, the bit should - * be set to indicate this. The return - * value will contain the unix error code* - * that the error interpretation routine - * thought was suitable, so pass this - * value back in the buf structure. - * Furthermore we return information - * saying that no data was transferred - */ - bp->b_flags |= B_ERROR; - bp->b_error = retval; - bp->b_resid = bp->b_bcount; - st->flags &= ~(ST_AT_FILEMARK|ST_AT_EOM); - } else if(xs->resid && ( xs->resid != xs->datalen )) { - /* - * Here we have the tricky part.. - * We successfully read less data than - * we requested. (but not 0) - *------for variable blocksize tapes:----* - * UNDER 386BSD: - * We should legitimatly have the error - * bit set, with the error value set to - * zero.. This is to indicate to the - * physio code that while we didn't get - * as much information as was requested, - * we did reach the end of the record - * and so physio should not call us - * again for more data... we have it all - * SO SET THE ERROR BIT! - * - * UNDER MACH (CMU) and NetBSD: - * To indicate the same as above, we - * need only have a non 0 resid that is - * less than the b_bcount, but the - * ERROR BIT MUST BE CLEAR! (sigh) - * - * UNDER OSF1: - * To indicate the same as above, we - * need to have a non 0 resid that is - * less than the b_bcount, but the - * ERROR BIT MUST BE SET! (gasp)(sigh) - * - *-------for fixed blocksize device------* - * We could have read some successful - * records before hitting - * the EOF or EOT. These must be passed - * to the user, before we report the - * EOx. Only if there is no data for the - * user do we report it now. (via an EIO - * for EOM and resid == count for EOF). - * We will report the EOx NEXT time.. - */ - bp->b_flags &= ~B_ERROR; - bp->b_error = 0; - bp->b_resid = xs->resid; - if((st->flags & ST_FIXEDBLOCKS)) { - bp->b_resid *= st->blkmin; - if( (st->flags & ST_AT_EOM) - && (bp->b_resid == bp->b_bcount)) { - bp->b_error = EIO; - st->flags &= ~ST_AT_EOM; - } - } - xs->error = XS_NOERROR; - break; - } else { - /* - * We have come out of the error handler - * with no error code.. we have also - * not had an ili (would have gone to - * the previous clause). Now we need to - * distiguish between succesful read of - * no data (EOF or EOM) and successfull - * read of all requested data. - * At least all o/s agree that: - * 0 bytes read with no error is EOF - * 0 bytes read with an EIO is EOM - */ - bp->b_resid = bp->b_bcount; - if(st->flags & ST_AT_FILEMARK) { - st->flags &= ~ST_AT_FILEMARK; - bp->b_flags &= ~B_ERROR; - bp->b_error = 0; - break; - } - if(st->flags & ST_AT_EOM) { - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - st->flags &= ~ST_AT_EOM; - break; - } - printf("st%d: error ignored\n", unit); - } - break; - case XS_TIMEOUT: - printf("st%d: timeout\n", unit); - break; - case XS_BUSY: /* should retry -- how? */ - /* - * SHOULD put buf back at head of queue - * and decrement retry count in (*xs) - * HOWEVER, this should work as a kludge - */ - if(xs->retries--) { - xs->flags &= ~ITSDONE; - xs->error = XS_NOERROR; - if ( (*(st->sc_sw->scsi_cmd))(xs) - == SUCCESSFULLY_QUEUED) { - /* don't wake the job, ok? */ - return; - } - printf("st%d: device busy\n"); - xs->flags |= ITSDONE; - } - case XS_DRIVER_STUFFUP: - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - break; - default: - printf("st%d: unknown error category %d from scsi driver\n", - unit, xs->error); - } - biodone(bp); - xs->flags = 0; /* no longer in use */ - ststart(unit); /* If there's another waiting.. do it */ - } else - wakeup((caddr_t)xs); -} - -/* - * Perform special action on behalf of the user - * Knows about the internals of this device -*/ -int -stioctl(dev_t dev, int cmd, caddr_t arg, int mode) -{ - struct st_data *st; - struct mtop *mt; - struct mtget *g; - unsigned int opri; - unsigned char unit; - register i, j; - int errcode=0, number, flags, ret; - - /* - * Find the device that the user is talking about - */ - flags = 0; /* give error messages, act on errors etc. */ - unit = UNIT(dev); - st = st_data[unit]; - - if(unit >= NST) - return ENXIO; - if(!st) - return ENXIO; - - switch(cmd) { - default: - return EINVAL; - case MTIOCGET: - g = (struct mtget *)arg; - bzero(g, sizeof *g); - g->mt_type = 0x7; /* Ultrix compat */ - ret=TRUE; - break; - case MTIOCTOP: - mt = (struct mtop *)arg; - - if (st_debug) - printf("[sctape_sstatus: %x %x]\n", mt->mt_op, mt->mt_count); - - /* compat: in U*x it is a short */ - number = mt->mt_count; - switch ((short)(mt->mt_op)) { - case MTWEOF: /* write an end-of-file record */ - ret = st_write_filemarks(unit, number, flags); - st->flags &= ~ST_WRITTEN; - break; - case MTFSF: /* forward space file */ - ret = st_space(unit, number, SP_FILEMARKS, flags); - break; - case MTBSF: /* backward space file */ - ret = st_space(unit, -number, SP_FILEMARKS, flags); - break; - case MTFSR: /* forward space record */ - ret = st_space(unit, number, SP_BLKS, flags); - break; - case MTBSR: /* backward space record */ - ret = st_space(unit, -number, SP_BLKS, flags); - break; - case MTREW: /* rewind */ - ret = st_rewind(unit, FALSE, flags); - break; - case MTOFFL: /* rewind and put the drive offline */ - if((ret = st_rewind(unit, FALSE, flags))) { - st_prevent(unit, PR_ALLOW, 0); - ret = st_load(unit, LD_UNLOAD, flags); - } else - printf("st%d: rewind failed; unit still loaded\n"); - break; - case MTNOP: /* no operation, sets status only */ - case MTCACHE: /* enable controller cache */ - case MTNOCACHE: /* disable controller cache */ - ret = TRUE; - break; - default: - return EINVAL; - } - break; - case MTIOCIEOT: - case MTIOCEEOT: - ret=TRUE; - break; - } - return ret ? ESUCCESS : EIO; -} - - -/* - * Check with the device that it is ok, (via scsi driver)* -*/ -int -st_req_sense(int unit, int flags) -{ - struct scsi_sense_data sense; - struct scsi_sense scsi_cmd; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = REQUEST_SENSE; - scsi_cmd.length = sizeof(sense); - - if (st_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)&sense, sizeof(sense), - 100000, flags | SCSI_DATA_IN) != 0) - return FALSE; - else - return TRUE; -} - -/* - * Get scsi driver to send a "are you ready" command -*/ -int -st_test_ready(int unit, int flags) -{ - struct scsi_test_unit_ready scsi_cmd; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = TEST_UNIT_READY; - - if (st_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)0, 0, 100000, flags) != 0) - return FALSE; - else - return TRUE; -} - - -#ifdef __STDC__ -#define b2tol(a) (((unsigned)(a##_1) << 8) + (unsigned)a##_0 ) -#else -#define b2tol(a) (((unsigned)(a/**/_1) << 8) + (unsigned)a/**/_0 ) -#endif - -/* - * Ask the drive what it's min and max blk sizes are. -*/ -int -st_rd_blk_lim(int unit, int flags) -{ - struct st_data *st = st_data[unit]; - struct scsi_blk_limits scsi_cmd; - struct scsi_blk_limits_data scsi_blkl; - - st = st_data[unit]; - - /* - * First check if we have it all loaded - */ - if (st->info_valid) - goto done; - - /* - * do a 'Read Block Limits' - */ - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = READ_BLK_LIMITS; - - /* - * do the command, update the global values - */ - if (st_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)&scsi_blkl, sizeof(scsi_blkl), - 5000, flags | SCSI_DATA_IN) != 0) { - if(!(flags & SCSI_SILENT)) - printf("st%d: read block limits failed\n", unit); - st->info_valid = FALSE; - return FALSE; - } - if (st_debug) - printf("st%d: block size min %d max %d\n", unit, - b2tol(scsi_blkl.min_length), - _3btol(&scsi_blkl.max_length_2)); - - st->blkmin = b2tol(scsi_blkl.min_length); - st->blkmax = _3btol(&scsi_blkl.max_length_2); - -done: - if(st->blkmin && (st->blkmin == st->blkmax)) - st->flags |= ST_FIXEDBLOCKS; - return TRUE; -} - -/* - * Get the scsi driver to send a full inquiry to the - * device and use the results to fill out the global - * parameter structure. -*/ -int -st_mode_sense(int unit, int flags) -{ - struct st_data *st = st_data[unit]; - struct scsi_mode_sense scsi_cmd; - struct { - struct scsi_mode_header_tape header; - struct blk_desc blk_desc; - } scsi_s; - - /* - * First check if we have it all loaded - */ - if(st->info_valid) - return TRUE; - /* - * First do a mode sense - */ - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = MODE_SENSE; - scsi_cmd.length = sizeof(scsi_s); - - /* - * do the command, but we don't need the results - * just print them for our interest's sake - */ - if (st_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)&scsi_s, sizeof(scsi_s), - 5000, flags | SCSI_DATA_IN) != 0) { - if(!(flags & SCSI_SILENT)) - printf("st%d: mode sense failed\n", unit); - st->info_valid = FALSE; - return FALSE; - } - if (st_debug) - printf("st%d: %d blocks of %d bytes, write %s, %sbuffered\n", - unit, - _3btol((u_char *)&scsi_s.blk_desc.nblocks), - _3btol((u_char *)&scsi_s.blk_desc.blklen), - scsi_s.header.write_protected ? "protected" : "enabled", - scsi_s.header.buf_mode ? "" : "un"); - - st->numblks = _3btol((u_char *)&scsi_s.blk_desc.nblocks); - st->blksiz = _3btol((u_char *)&scsi_s.blk_desc.blklen); - return TRUE; -} - -/* - * Get the scsi driver to send a full inquiry to the - * device and use the results to fill out the global - * parameter structure. -*/ -int -st_mode_select(int unit, int flags, int dsty_code) -{ - struct st_data *st = st_data[unit]; - struct scsi_mode_select scsi_cmd; - struct { - struct scsi_mode_header_tape header; - struct blk_desc blk_desc; - } dat; - - /* - * Set up for a mode select - */ - bzero(&dat, sizeof(dat)); - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = MODE_SELECT; - scsi_cmd.length = sizeof(dat); - dat.header.blk_desc_len = sizeof(struct blk_desc); - dat.header.buf_mode = 1; - dat.blk_desc.density = dsty_code; - if(st->flags & ST_FIXEDBLOCKS) - lto3b(st->blkmin, dat.blk_desc.blklen); - -/* lto3b( st->numblks, dat.blk_desc.nblocks); use defaults!!!! - lto3b( st->blksiz, dat.blk_desc.blklen); - */ - /* - * do the command - */ - if (st_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)&dat, sizeof(dat), - 5000, flags | SCSI_DATA_OUT) != 0) { - if(!(flags & SCSI_SILENT)) - printf("st%d: mode select failed\n", unit); -#if 0 - st->info_valid = FALSE; - return FALSE; -#endif - } - return TRUE; -} - -/* - * skip N blocks/filemarks/seq filemarks/eom -*/ -int -st_space(int unit, int number, int what, int flags) -{ - struct st_data *st = st_data[unit]; - struct scsi_space scsi_cmd; - - /* if we are at a filemark now, we soon won't be*/ - st->flags &= ~(ST_AT_FILEMARK | ST_AT_EOM); - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = SPACE; - scsi_cmd.code = what; - lto3b(number, scsi_cmd.number); - if (st_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)0, 0, 600000, flags) != 0) { - if(!(flags & SCSI_SILENT)) - printf("st%d: %s space failed\n", unit, - (number > 0) ? "forward" : "backward"); - st->info_valid = FALSE; - return FALSE; - } - return TRUE; -} - -/* - * write N filemarks -*/ -int -st_write_filemarks(int unit, int number, int flags) -{ - struct st_data *st = st_data[unit]; - struct scsi_write_filemarks scsi_cmd; - - st->flags &= ~(ST_AT_FILEMARK); - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = WRITE_FILEMARKS; - lto3b(number, scsi_cmd.number); - if (st_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)0, 0, 100000, flags) != 0) { - if(!(flags & SCSI_SILENT)) - printf("st%d: write file marks failed\n", unit); - st->info_valid = FALSE; - return FALSE; - } - return TRUE; -} - -/* - * load /unload (with retension if true) -*/ -int -st_load(int unit, int type, int flags) -{ - struct st_data *st = st_data[unit]; - struct scsi_load scsi_cmd; - - st->flags &= ~(ST_AT_FILEMARK | ST_AT_EOM); - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = LOAD_UNLOAD; - scsi_cmd.load=type; - if (type == LD_LOAD) - { - /*scsi_cmd.reten=TRUE;*/ - scsi_cmd.reten=FALSE; - } - else - { - scsi_cmd.reten=FALSE; - } - if (st_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)0, 0, 30000, flags) != 0) { - if(!(flags & SCSI_SILENT)) - printf("st%d: %s failed\n", unit, - type == LD_LOAD ? "load" : "unload"); - st->info_valid = FALSE; - return FALSE; - } - return TRUE; -} - -/* - * Prevent or allow the user to remove the tape -*/ -int -st_prevent(int unit, int type, int flags) -{ - struct st_data *st = st_data[unit]; - struct scsi_prevent scsi_cmd; - - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = PREVENT_ALLOW; - scsi_cmd.prevent=type; - if (st_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)0, 0, 5000, flags) != 0) { - if(!(flags & SCSI_SILENT)) - printf("st%d: %s failed\n", unit, - type == PR_PREVENT ? "prevent" : "allow"); - st->info_valid = FALSE; - return FALSE; - } - return TRUE; -} - -/* - * Rewind the device -*/ -int -st_rewind(int unit, int immed, int flags) -{ - struct st_data *st = st_data[unit]; - struct scsi_rewind scsi_cmd; - - st->flags &= ~(ST_AT_FILEMARK | ST_AT_EOM); - bzero(&scsi_cmd, sizeof(scsi_cmd)); - scsi_cmd.op_code = REWIND; - scsi_cmd.immed=immed; - if (st_scsi_cmd(unit, (struct scsi_generic *)&scsi_cmd, - sizeof(scsi_cmd), (u_char *)0, 0, immed?5000:300000, flags) != 0) { - if(!(flags & SCSI_SILENT)) - printf("st%d: rewind failed\n", unit); - st->info_valid = FALSE; - return FALSE; - } - return TRUE; -} - -/* - * ask the scsi driver to perform a command for us. - * Call it through the switch table, and tell it which - * sub-unit we want, and what target and lu we wish to - * talk to. Also tell it where to find the command - * how long int is. - * Also tell it where to read/write the data, and how - * long the data is supposed to be -*/ -int -st_scsi_cmd(int unit, struct scsi_generic *scsi_cmd, int cmdlen, - u_char *data_addr, int datalen, int timeout, int flags) -{ - struct st_data *st = st_data[unit]; - struct scsi_xfer *xs; - int retval, s; - - if(scsi_debug & PRINTROUTINES) - printf("\nst_scsi_cmd%d ", unit); - if(!st->sc_sw) { - printf("st%d: not set up\n", unit); - return EINVAL; - } - - xs = &st->scsi_xfer; - if(!(flags & SCSI_NOMASK)) - s = splbio(); - st->blockwait++; /* there is someone waiting */ - while (xs->flags & INUSE) - tsleep((caddr_t)&st->blockwait, PRIBIO+1, "st_cmd1", 0); - st->blockwait--; - xs->flags = INUSE; - if(!(flags & SCSI_NOMASK)) - splx(s); - - /* - * Fill out the scsi_xfer structure - */ - xs->flags |= flags; - xs->adapter = st->ctlr; - xs->targ = st->targ; - xs->lu = st->lu; - xs->retries = ST_RETRIES; - xs->timeout = timeout; - xs->cmd = scsi_cmd; - xs->cmdlen = cmdlen; - xs->data = data_addr; - xs->datalen = datalen; - xs->resid = datalen; - xs->when_done = (flags & SCSI_NOMASK) ? (int (*)())0 : st_done; - xs->done_arg = unit; - xs->done_arg2 = (int)xs; -retry: - xs->error = XS_NOERROR; - xs->bp = 0; - retval = (*(st->sc_sw->scsi_cmd))(xs); - switch(retval) { - case SUCCESSFULLY_QUEUED: - s = splbio(); - while(!(xs->flags & ITSDONE)) - tsleep((caddr_t)xs,PRIBIO+1, "st_cmd2", 0); - splx(s); - case HAD_ERROR: - case COMPLETE: - switch(xs->error) { - case XS_NOERROR: - retval = ESUCCESS; - break; - case XS_SENSE: - retval = st_interpret_sense(unit, xs); - /* only useful for reads */ - if (retval) - st->flags &= ~(ST_AT_FILEMARK | ST_AT_EOM); - else { - xs->error = XS_NOERROR; - retval = ESUCCESS; - } - break; - case XS_DRIVER_STUFFUP: - retval = EIO; - break; - case XS_TIMEOUT: - case XS_BUSY: - if(xs->retries-- ) { - xs->flags &= ~ITSDONE; - goto retry; - } - retval = EIO; - break; - default: - retval = EIO; - printf("st%d: unknown error category %d from scsi driver\n", - unit, xs->error); - break; - } - break; - case TRY_AGAIN_LATER: - if(xs->retries--) { - xs->flags &= ~ITSDONE; - goto retry; - } - retval = EIO; - break; - default: - retval = EIO; - } - xs->flags = 0; /* it's free! */ - ststart(unit); - - return retval; -} - -/* - * Look at the returned sense and act on the error and detirmine - * The unix error number to pass back... (0 = report no error) -*/ - -int -st_interpret_sense(int unit, struct scsi_xfer *xs) -{ - struct st_data *st = st_data[unit]; - struct scsi_sense_data *sense; - int silent = xs->flags & SCSI_SILENT, key; - - /* - * If errors are ok, report a success - */ - if(xs->flags & SCSI_ERR_OK) - return ESUCCESS; - - /* - * Get the sense fields and work out what CLASS - */ - sense = &(xs->sense); - if(st_debug) { - int count = 0; - printf("code%x class%x valid%x\n", sense->error_code, - sense->error_class, sense->valid); - printf("seg%x key%x ili%x eom%x fmark%x\n", - sense->ext.extended.segment, sense->ext.extended.sense_key, - sense->ext.extended.ili, sense->ext.extended.eom, - sense->ext.extended.filemark); - printf("info: %x %x %x %x followed by %d extra bytes\n", - sense->ext.extended.info[0], sense->ext.extended.info[1], - sense->ext.extended.info[2], sense->ext.extended.info[3], - sense->ext.extended.extra_len); - printf("extra: "); - while(count < sense->ext.extended.extra_len) - printf("%x ", sense->ext.extended.extra_bytes[count++]); - printf("\n"); - } - - switch(sense->error_class) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - if(!silent) { - printf("st%d: error class %d code %d\n", unit, - sense->error_class, sense->error_code); - if(sense->valid) - printf("block no. %d (decimal)\n", - (sense->ext.unextended.blockhi <<16), - + (sense->ext.unextended.blockmed <<8), - + (sense->ext.unextended.blocklow )); - } - return EIO; - case 7: - /* - * If it's class 7, use the extended stuff and interpret - * the key - */ - if(sense->ext.extended.eom) - st->flags |= ST_AT_EOM; - if(sense->ext.extended.filemark) - st->flags |= ST_AT_FILEMARK; - - if(sense->ext.extended.ili) { - if(sense->valid) { - /* - * In all ili cases, note that - * the resid is non-0 AND not - * unchanged. - */ - xs->resid = ntohl(*((long *)sense->ext.extended.info)); - if(xs->bp) { - if(xs->resid < 0) { - /* never on block devices */ - /* - * it's only really bad - * if we have lost data - * (the record was - * bigger than the read) - */ - return EIO; - } - } - } else - printf("st%d: bad length error?", unit); - } - - key = sense->ext.extended.sense_key; - switch(key) { - case 0x0: - return ESUCCESS; - case 0x1: - if(!silent) { - printf("st%d: soft error (corrected)", unit); - if(sense->valid) { - printf(" block %d\n", - (sense->ext.extended.info[0] <<24)| - (sense->ext.extended.info[1] <<16)| - (sense->ext.extended.info[2] <<8)| - (sense->ext.extended.info[3] )); - } else - printf("\n"); - } - return ESUCCESS; - case 0x2: - if(!silent) - printf("st%d: not ready\n", unit); - return ENODEV; - case 0x3: - if(!silent) { - printf("st%d: medium error", unit); - if(sense->valid) { - printf(" block %d\n", - (sense->ext.extended.info[0] <<24)| - (sense->ext.extended.info[1] <<16)| - (sense->ext.extended.info[2] <<8)| - (sense->ext.extended.info[3] )); - } else - printf("\n"); - } - return EIO; - case 0x4: - if(!silent) - printf("st%d: component failure\n", - unit); - return EIO; - case 0x5: - if(!silent) - printf("st%d: illegal request\n", unit); - return EINVAL; - case 0x6: - if(!silent) - printf("st%d: media change\n", unit); - st->flags &= ~(ST_AT_FILEMARK|ST_AT_EOM); - st->info_valid = FALSE; - if (st->flags & ST_OPEN) /* TEMP!!!! */ - return EIO; - return ESUCCESS; - case 0x7: - if(!silent) { - printf("st%d: attempted protection violation", - unit); - if(sense->valid) { - printf(" block %d\n", - (sense->ext.extended.info[0] <<24)| - (sense->ext.extended.info[1] <<16)| - (sense->ext.extended.info[2] <<8)| - (sense->ext.extended.info[3] )); - } else - printf("\n"); - } - return EACCES; - case 0x8: - if(!silent) { - printf("st%d: block wrong state (worm)", unit); - if(sense->valid) { - printf(" block %d\n", - (sense->ext.extended.info[0] <<24)| - (sense->ext.extended.info[1] <<16)| - (sense->ext.extended.info[2] <<8)| - (sense->ext.extended.info[3] )); - } else - printf("\n"); - } - return EIO; - case 0x9: - if(!silent) - printf("st%d: vendor unique\n", unit); - return EIO; - case 0xa: - if(!silent) - printf("st%d: copy aborted\n", unit); - return EIO; - case 0xb: - if(!silent) - printf("st%d: command aborted\n", unit); - return EIO; - case 0xc: - if(!silent) { - printf("st%d: search returned", unit); - if(sense->valid) { - printf(" block %d\n", - (sense->ext.extended.info[0] <<24)| - (sense->ext.extended.info[1] <<16)| - (sense->ext.extended.info[2] <<8)| - (sense->ext.extended.info[3] )); - } else - printf("\n"); - } - return ESUCCESS; - case 0xd: - if(!silent) - printf("st%d: volume overflow\n", unit); - return ENOSPC; - case 0xe: - if(!silent) { - printf("st%d: verify miscompare\n", unit); - if(sense->valid) { - printf("block no. %d (decimal)\n", - (sense->ext.extended.info[0] <<24)| - (sense->ext.extended.info[1] <<16)| - (sense->ext.extended.info[2] <<8)| - (sense->ext.extended.info[3] )); - } else - printf("\n"); - } - return EIO; - case 0xf: - if(!silent) - printf("st%d: unknown error key\n", unit); - return EIO; - } - break; - } - return 0; -} diff --git a/sys/arch/pc532/scsi/stdefs.h b/sys/arch/pc532/scsi/stdefs.h deleted file mode 100644 index 3c3e2412c8e9..000000000000 --- a/sys/arch/pc532/scsi/stdefs.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: stdefs.h,v 1.2 1994/10/26 08:25:40 cgd Exp $ */ - -#define STQSIZE 4 -struct st_data { - struct scsi_switch *sc_sw; /* address of scsi low level switch */ - int flags; - int ctlr; /* so they know which one we want */ - int targ; /* our scsi target ID */ - int lu; /* our scsi lu */ - int blkmin; /* min blk size */ - int blkmax; /* max blk size */ - int numblks; /* nominal blocks capacity */ - int blksiz; /* nominal block size */ - int info_valid; /* the info about the device is valid */ - int initialized; - struct buf buf[STQSIZE]; /* buffer for raw io (one per device) */ - struct buf buf_queue; - struct scsi_xfer scsi_xfer; - int blockwait; -}; -#define ST_OPEN 0x01 -#define ST_NOREWIND 0x02 -#define ST_WRITTEN 0x04 -#define ST_FIXEDBLOCKS 0x10 -#define ST_AT_FILEMARK 0x20 -#define ST_AT_EOM 0x40 - -#define ST_PER_ACTION (ST_AT_FILEMARK | ST_AT_EOM) -#define ST_PER_OPEN (ST_OPEN | ST_NOREWIND | ST_WRITTEN | ST_PER_ACTION) -#define ST_PER_MEDIA ST_FIXEDBLOCKS - -int stattach(int, struct scsi_switch *, int, int *); -int stopen(dev_t); -int stclose(dev_t); -void stminphys(struct buf *); -void ststrategy(struct buf *); -int ststart(int); -int st_done(int, struct scsi_xfer *); -int stioctl(dev_t, int, caddr_t, int); -int st_req_sense(int, int); -int st_test_ready(int, int); -int st_rd_blk_lim(int, int); -int st_mode_sense(int, int); -int st_mode_select(int, int, int); -int st_space(int, int, int, int); -int st_write_filemarks(int, int, int); -int st_load(int, int, int); -int st_prevent(int, int, int); -int st_rewind(int, int, int); -int st_scsi_cmd(int, struct scsi_generic *, int, u_char *, int, int, int); -int st_interpret_sense(int, struct scsi_xfer *); -int stsize(dev_t); -int stdump(void); - diff --git a/sys/arch/pmax/conf/AMSTEL b/sys/arch/pmax/conf/AMSTEL deleted file mode 100644 index 9b4fb0e877eb..000000000000 --- a/sys/arch/pmax/conf/AMSTEL +++ /dev/null @@ -1,56 +0,0 @@ -# -# GENERIC DEC Station -# $Id: AMSTEL,v 1.3 1994/01/14 19:50:45 deraadt Exp $ -machine pmax - -cpu "DS3100" -ident AMSTEL - -timezone 5 dst - -# Standard 4.3-Reno options -maxusers 48 -options INET -#options NS -#options KADB -options QUOTA -#options FIFO -options SWAPPAGER, VNODEPAGER, DEVPAGER -options NFSSERVER,NFSCLIENT -options MFS -options FFS -#options LFS -options DIAGNOSTIC -options "TCP_COMPAT_42" -options "COMPAT_43" -options KTRACE -#options GATEWAY # slip needs this for packet forwarding -options ULTRIXCOMPAT # must define COMPAT_43 too -options DEBUG -options "NKMEMCLUSTERS=512" - -# OSI stuff: -#options ISO -#options TPIP -#options EON - - -#config netbsd swap generic -config netbsd root on rz0e swap on rz0b dumps on rz0b - -controller pm0 at nexus0 csr 0x8fc00000 -controller dc0 at nexus0 csr 0xbc000000 priority 2 -controller le0 at nexus0 csr 0xb8000000 priority 1 -master sii0 at nexus0 csr 0xba000000 priority 0 -disk rz0 at sii0 drive 0 slave 0 -disk rz1 at sii0 drive 1 slave 0 -#disk rz2 at sii0 drive 2 slave 0 -#disk rz3 at sii0 drive 3 slave 0 -#disk rz4 at sii0 drive 4 slave 0 -tape tz0 at sii0 drive 5 slave 0 -#tape tz1 at sii0 drive 6 slave 0 - -pseudo-device ite -pseudo-device pty -pseudo-device loop -pseudo-device ether diff --git a/sys/arch/pmax/conf/ECSTASY b/sys/arch/pmax/conf/ECSTASY deleted file mode 100644 index 1667000861be..000000000000 --- a/sys/arch/pmax/conf/ECSTASY +++ /dev/null @@ -1,55 +0,0 @@ -# -# GENERIC DECstation 3100 -# $Id: ECSTASY,v 1.3 1994/01/14 19:50:46 deraadt Exp $ -machine pmax - -cpu "DS3100" -ident ECSTASY - -timezone 8 dst - -# Standard 4.3-Reno options -maxusers 48 -options INET -#options NS -#options KADB -options QUOTA -options FIFO -options SWAPPAGER, VNODEPAGER, DEVPAGER -options NFSSERVER,NFSCLIENT -options MFS -options FFS -options DIAGNOSTIC -options "TCP_COMPAT_42" -options "COMPAT_43" -options KTRACE -#options GATEWAY # slip needs this for packet forwarding -options ULTRIXCOMPAT # must define COMPAT_43 too -options DEBUG -options "NKMEMCLUSTERS=512" - -# OSI stuff: -#options ISO -#options TPIP -#options EON - - -#config netbsd swap generic -config netbsd root on rz3a swap on rz3b dumps on rz3b - -controller pm0 at nexus0 csr 0x8fc00000 -controller dc0 at nexus0 csr 0xbc000000 priority 2 -controller le0 at nexus0 csr 0xb8000000 priority 1 -master sii0 at nexus0 csr 0xba000000 priority 0 -disk rz0 at sii0 drive 0 slave 0 -disk rz1 at sii0 drive 1 slave 0 -disk rz2 at sii0 drive 2 slave 0 -disk rz3 at sii0 drive 3 slave 0 -#disk rz4 at sii0 drive 4 slave 0 -#tape tz0 at sii0 drive 5 slave 0 -#tape tz1 at sii0 drive 6 slave 0 - -pseudo-device ite -pseudo-device pty -pseudo-device loop -pseudo-device ether diff --git a/sys/arch/pmax/conf/GENERIC.3100 b/sys/arch/pmax/conf/GENERIC.3100 deleted file mode 100644 index ed6edab88808..000000000000 --- a/sys/arch/pmax/conf/GENERIC.3100 +++ /dev/null @@ -1,57 +0,0 @@ -# -# GENERIC DECstation 3100 -# -# from: @(#)GENERIC.3100 7.4 (Berkeley) 7/25/92 -# $Id: GENERIC.3100,v 1.3 1994/01/14 19:50:47 deraadt Exp $ -machine pmax - -cpu "DS3100" -ident GENERIC - -timezone 8 dst - -# Standard 4.3-Reno options -maxusers 48 -options INET -#options NS -#options KADB -options QUOTA -options FIFO -options SWAPPAGER, VNODEPAGER, DEVPAGER -options NFSSERVER,NFSCLIENT -options MFS -options FFS -options DIAGNOSTIC -options "TCP_COMPAT_42" -options "COMPAT_43" -options KTRACE -#options GATEWAY # slip needs this for packet forwarding -options ULTRIXCOMPAT # must define COMPAT_43 too -options DEBUG -options "NKMEMCLUSTERS=512" - -# OSI stuff: -#options ISO -#options TPIP -#options EON - - -config netbsd swap generic -#config netbsd root on rz0a swap on rz0b dumps on rz0b - -controller pm0 at nexus0 csr 0x8fc00000 -controller dc0 at nexus0 csr 0xbc000000 -controller le0 at nexus0 csr 0xb8000000 -master sii0 at nexus0 csr 0xba000000 -disk rz0 at sii0 drive 0 slave 0 -disk rz1 at sii0 drive 1 slave 0 -disk rz2 at sii0 drive 2 slave 0 -disk rz3 at sii0 drive 3 slave 0 -disk rz4 at sii0 drive 4 slave 0 -tape tz0 at sii0 drive 5 slave 0 -tape tz1 at sii0 drive 6 slave 0 - -pseudo-device ite -pseudo-device pty -pseudo-device loop -pseudo-device ether diff --git a/sys/arch/pmax/conf/GENERIC.5000 b/sys/arch/pmax/conf/GENERIC.5000 deleted file mode 100644 index 2e1225aff5be..000000000000 --- a/sys/arch/pmax/conf/GENERIC.5000 +++ /dev/null @@ -1,69 +0,0 @@ -# -# GENERIC DECstation 5000 -# -# from: @(#)GENERIC.5000 7.4 (Berkeley) 3/8/93 -# $Id: GENERIC.5000,v 1.2 1994/01/14 04:57:48 deraadt Exp $ -machine pmax - -cpu "DS5000" -ident GENERIC - -timezone 8 dst - -# Standard 4.3-Reno options -maxusers 48 -options INET,MROUTING -#options NS -options QUOTA -options FIFO -options SWAPPAGER, VNODEPAGER, DEVPAGER -options NFSSERVER,NFSCLIENT -options MFS -options FFS -options LFS -options DIAGNOSTIC -options "TCP_COMPAT_42" -options "COMPAT_43" -options KTRACE -#options GATEWAY # slip needs this for packet forwarding -#options ULTRIXCOMPAT # must define COMPAT_43 too -options DEBUG -options "NKMEMCLUSTERS=512" - -# OSI stuff: -#options ISO -#options TPIP -#options EON - - -config netbsd swap generic -#config netbsd root on rz0a swap on rz0b dumps on rz0b - -controller dtop0 at nexus0 csr ? -controller dc0 at nexus0 csr ? -controller xcfb0 at nexus0 csr ? -controller cfb0 at nexus0 csr ? -controller mfb0 at nexus0 csr ? -controller pm0 at nexus0 csr ? -controller scc0 at nexus0 csr ? -controller le0 at nexus0 csr ? -master sii0 at nexus0 csr ? -disk rz0 at sii0 drive 0 slave 0 -disk rz1 at sii0 drive 1 slave 0 -disk rz2 at sii0 drive 2 slave 0 -disk rz3 at sii0 drive 3 slave 0 -disk rz4 at sii0 drive 4 slave 0 -tape tz0 at sii0 drive 5 slave 0 -tape tz1 at sii0 drive 6 slave 0 -master asc0 at nexus0 csr ? -disk rz0 at asc0 drive 0 slave 0 -disk rz1 at asc0 drive 1 slave 0 -disk rz2 at asc0 drive 2 slave 0 -disk rz3 at asc0 drive 3 slave 0 -disk rz4 at asc0 drive 4 slave 0 -tape tz0 at asc0 drive 5 slave 0 -tape tz1 at asc0 drive 6 slave 0 - -pseudo-device pty -pseudo-device loop -pseudo-device ether diff --git a/sys/arch/pmax/conf/MAXINE b/sys/arch/pmax/conf/MAXINE deleted file mode 100644 index 8678e25115c1..000000000000 --- a/sys/arch/pmax/conf/MAXINE +++ /dev/null @@ -1,62 +0,0 @@ -# -# GENERIC DECstation 5000 -# $Id: MAXINE,v 1.3 1994/01/14 19:50:48 deraadt Exp $ -machine pmax - -cpu "DS5000" -ident MAXINE - -timezone 5 dst - -# Standard 4.3-Reno options -maxusers 48 -options INET -#options NS -#options KADB -options QUOTA -options FIFO -options SWAPPAGER, VNODEPAGER, DEVPAGER -options NFSSERVER,NFSCLIENT -options MFS -options FFS -options DIAGNOSTIC -options "TCP_COMPAT_42" -options "COMPAT_43" -options KTRACE -#options GATEWAY # slip needs this for packet forwarding -options ULTRIXCOMPAT # must define COMPAT_43 too -options DEBUG -options "NKMEMCLUSTERS=512" - -# OSI stuff: -#options ISO -#options TPIP -#options EON - - -#config netbsd swap generic -config netbsd root on rz0e swap on rz0b dumps on rz0b - -controller dtop0 at nexus0 csr ? -controller dc0 at nexus0 csr ? -controller xcfb0 at nexus0 csr ? -controller cfb0 at nexus0 csr ? -controller mfb0 at nexus0 csr ? -controller pm0 at nexus0 csr ? -controller scc0 at nexus0 csr ? -controller le0 at nexus0 csr ? -master sii0 at nexus0 csr ? -disk rz0 at sii0 drive 0 slave 0 -master asc0 at nexus0 csr ? -disk rz0 at asc0 drive 0 slave 0 -#disk rz1 at asc0 drive 1 slave 0 -#disk rz2 at asc0 drive 2 slave 0 -#disk rz3 at asc0 drive 3 slave 0 -#disk rz4 at asc0 drive 4 slave 0 -#tape tz0 at asc0 drive 5 slave 0 -#tape tz1 at asc0 drive 6 slave 0 - -pseudo-device ite -pseudo-device pty -pseudo-device loop -pseudo-device ether diff --git a/sys/arch/pmax/conf/MAXP b/sys/arch/pmax/conf/MAXP deleted file mode 100644 index 2864bf2f5a46..000000000000 --- a/sys/arch/pmax/conf/MAXP +++ /dev/null @@ -1,65 +0,0 @@ -# -# GENERIC DECstation 5000 -# $Id: MAXP,v 1.3 1994/01/14 19:50:49 deraadt Exp $ -machine pmax - -cpu "DS5000" -ident MAXP - -timezone 5 dst - -# Standard 4.3-Reno options -maxusers 48 -options INET -#options NS -options SWAPPAGER, VNODEPAGER, DEVPAGER -#options KADB -options QUOTA -options FIFO -options NFSSERVER,NFSCLIENT -options MFS -options FFS -options DIAGNOSTIC -options "TCP_COMPAT_42" -options "COMPAT_43" -options KTRACE -#options GATEWAY # slip needs this for packet forwarding -options ULTRIXCOMPAT # must define COMPAT_43 too -options DEBUG -options "NKMEMCLUSTERS=512" - -# OSI stuff: -#options ISO -#options TPIP -#options EON - - -#config netbsd swap generic -config netbsd root on rz0e swap on rz0b dumps on rz0b - -controller dtop0 at nexus0 csr ? -controller dc0 at nexus0 csr ? -controller xcfb0 at nexus0 csr ? -controller cfb0 at nexus0 csr ? -controller mfb0 at nexus0 csr ? -controller pm0 at nexus0 csr ? -controller scc0 at nexus0 csr ? -controller scc1 at nexus0 csr ? -controller le0 at nexus0 csr ? -master sii0 at nexus0 csr ? -disk rz0 at sii0 drive 0 slave 0 -tape tz0 at sii0 drive 5 slave 0 -master asc0 at nexus0 csr ? -disk rz0 at asc0 drive 0 slave 0 -disk rz1 at asc0 drive 1 slave 0 -disk rz2 at asc0 drive 2 slave 0 -#disk rz3 at asc0 drive 3 slave 0 -#disk rz4 at asc0 drive 4 slave 0 -tape tz0 at asc0 drive 5 slave 0 -#tape tz1 at asc0 drive 6 slave 0 - -pseudo-device ite -pseudo-device pty -pseudo-device loop -pseudo-device ether - diff --git a/sys/arch/pmax/dist/get1 b/sys/arch/pmax/dist/get1 deleted file mode 100644 index d39162ddb870..000000000000 --- a/sys/arch/pmax/dist/get1 +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 1992 The Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# from: @(#)get1 7.1 (Berkeley) 4/20/92 -# $Id: get1,v 1.1.1.1 1993/10/12 03:22:48 deraadt Exp $ -# - -# Shell script to build a mini-root file system in preparation for building -# a distribution tape. The file system created here is image copied onto -# tape, then image copied onto disk as the "first" step in a cold boot o -# 4.3 systems. - -DISTROOT=/usr/obj -DISTUSR=/usr/obj/usr.bin -DISTSRC=/bsd3/src - -if [ `pwd` = '/' ] -then - echo You just '(almost)' destroyed the root - exit -fi -#cp /tmp/stripped_vmunix vmunix - -# create necessary directories -DIRLIST="bin dev etc a tmp stand sbin usr sys" -rm -rf $DIRLIST -mkdir $DIRLIST - -ETC="disktab" -for i in $ETC; do - cp $DISTSRC/etc/etc.pmax/$i etc/$i -done - -# disklabel -SBIN="fsck ifconfig init mknod mount newfs restore \ - rrestore umount" -for i in $SBIN; do - cp $DISTROOT/sbin/$i/$i sbin/$i -done - -# ed -BIN="test cat cp dd echo expr ls mkdir mv rcp rm sh stty sync" -UBIN="awk make mt" -for i in $BIN; do - cp $DISTROOT/bin/$i/$i bin/$i -done -#for i in $UBIN; do -# cp $DISTUSR/$i/$i bin/$i -#done -ln bin/stty bin/STTY -ln bin/test bin/[ - -#cp /nbsd/sys/floppy/[Ma-z0-9]* sys/floppy -#cp /nbsd/sys/consolerl/[Ma-z0-9]* sys/consolerl -#cp -r /nbsd/sys/cassette/[Ma-z0-9]* sys/cassette -#cp /nbsd/sys/cassette/[Ma-z0-9]* sys/cassette -#cp $DISTROOT/boot boot -#cp $DISTROOT/pcs750.bin pcs750.bin -cp $DISTROOT/.profile .profile - -cat >etc/passwd <etc/group <etc/fstab <xtr <<'EOF' -#: ${disk?'Usage: disk=xx0 type=tt tape=yy xtr'} -#: ${type?'Usage: disk=xx0 type=tt tape=yy xtr'} -#: ${tape?'Usage: disk=xx0 type=tt tape=yy xtr'} -#echo 'Build root file system' -#newfs ${disk}a ${type} -#sync -#echo 'Check the file system' -#fsck /dev/r${disk}a -#mount /dev/${disk}a /a -#cd /a -#echo 'Rewind tape' -#mt -f /dev/${tape}0 rew -#echo 'Restore the dump image of the root' -#restore rsf 3 /dev/${tape}0 -#cd / -#sync -#umount /dev/${disk}a -#sync -#fsck /dev/r${disk}a -#echo 'Root filesystem extracted' -#echo -#echo 'If this is an 8650 or 8600, update the console rl02' -#echo 'If this is a 780 or 785, update the floppy' -#echo 'If this is a 730, update the cassette' -#EOF -#chmod +x xtr - -cp $DISTSRC/etc/etc.pmax/MAKEDEV dev -chmod +x dev/MAKEDEV -cp /dev/null dev/MAKEDEV.local -cd dev -./MAKEDEV std dc0 rz0 tz0 pm0 pty0 -cd .. -sync diff --git a/sys/arch/pmax/pmax/Locore.c b/sys/arch/pmax/pmax/Locore.c deleted file mode 100644 index 6021351175f3..000000000000 --- a/sys/arch/pmax/pmax/Locore.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)Locore.c 7.2 (Berkeley) 10/11/92 - * $Id: Locore.c,v 1.1.1.1 1993/10/12 03:22:28 deraadt Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* - * Pseudo file for lint to show what is used/defined in locore.s. - */ - -int dumpflag; -int intstack[3*NBPG]; -int icode[8]; -int szicode = sizeof (icode); -char MachUTLBMiss[10], MachUTLBMissEnd[1]; -char MachException[10], MachException[1]; - -/* - * Variables declared for savecore, or - * implicitly, such as by config or the loader. - */ -char version[] = "4.3 BSD UNIX ...."; -int etext; - -lowinit() -{ -#if !defined(GPROF) - caddr_t cp; -#endif - extern int dumpmag; - extern int rthashsize; - extern int arptab_size; - extern int dk_ndrive; - extern struct domain unixdomain; -#ifdef INET - extern struct domain inetdomain; -#endif -#include "imp.h" -#if NIMP > 0 - extern struct domain impdomain; -#endif -#ifdef NS - extern struct domain nsdomain; -#endif - - /* cpp messes these up for lint so put them here */ - unixdomain.dom_next = domains; - domains = &unixdomain; -#ifdef INET - inetdomain.dom_next = domains; - domains = &inetdomain; -#endif -#if NIMP > 0 - impdomain.dom_next = domains; - domains = &impdomain; -#endif -#ifdef NS - nsdomain.dom_next = domains; - domains = &nsdomain; -#endif - dumpmag = 0; /* used only by savecore */ - rthashsize = rthashsize; /* used by netstat, etc. */ - arptab_size = arptab_size; /* used by arp command */ - dk_ndrive = dk_ndrive; /* used by vmstat, iostat, etc. */ - - /* - * Pseudo-uses of globals. - */ - lowinit(); - intstack[0] = intstack[1]; - maxmem = physmem = freemem = 0; - u = u; - fixctlrmask(); - main(0); - Xustray(); - - /* - * Routines called from interrupt vectors. - */ - panic("Machine check"); - printf("Write timeout"); - consdin(); - consdout(); - hardclock((caddr_t)0, 0); - softclock((caddr_t)0, 0); - trap((unsigned)0, (unsigned)0, (unsigned)0, (unsigned)0); - memerr(); - - /* - * Miscellaneous routines called from configurable - * drivers. - */ - disksort((struct buf *)0, (struct buf *)0); - (void) uwritec((struct uio *)0); - (void) todr(); - if (vmemall((struct pte *)0, 0, (struct proc *)0, 0)) - return; /* use value */ - boothowto = 0; - dumpflag = 0; dumpflag = dumpflag; -#ifdef KADB - bootesym = 0; bootesym = bootesym; -#endif -#if !defined(GPROF) - cp = (caddr_t)&etext; - cp = cp; -#endif -} - -struct pte Sysmap[6*NPTEPG]; -#ifdef KADB -char Sysbase[6*NPTEPG*NBPG]; -#endif -struct pte Usrptmap[USRPTSIZE]; -struct pte usrpt[USRPTSIZE*NPTEPG]; -struct pte Usriomap[USRIOSIZE]; -struct pte usrio[USRIOSIZE*NPTEPG]; -struct pte Forkmap[UPAGES]; -struct user forkutl; -struct pte Xswapmap[UPAGES]; -struct user xswaputl; -struct pte Xswap2map[UPAGES]; -struct user xswap2utl; -struct pte Swapmap[UPAGES]; -struct user swaputl; -struct pte Pushmap[UPAGES]; -struct user pushutl; -struct pte Vfmap[UPAGES]; -struct user vfutl; -struct pte Mbmap[NMBCLUSTERS/CLSIZE]; -struct mbuf mbutl[NMBCLUSTERS*CLBYTES/sizeof (struct mbuf)]; -struct pte kmempt[200]; -char kmembase[100*NBPG]; - -/*ARGSUSED*/ -badaddr(addr, len) char *addr; int len; { return (0); } - -/*ARGSUSED*/ -copyinstr(udaddr, kaddr, maxlength, lencopied) - caddr_t udaddr, kaddr; u_int maxlength, *lencopied; -{ *kaddr = *udaddr; *lencopied = maxlength; return (0); } -copyoutstr(kaddr, udaddr, maxlength, lencopied) - caddr_t kaddr, udaddr; u_int maxlength, *lencopied; -{ *udaddr = *kaddr; *lencopied = maxlength; return (0); } -copystr(kfaddr, kdaddr, maxlength, lencopied) - caddr_t kfaddr, kdaddr; u_int maxlength, *lencopied; -{ *kdaddr = *kfaddr; *lencopied = maxlength; return (0); } - -/*ARGSUSED*/ -copyin(udaddr, kaddr, n) caddr_t udaddr, kaddr; u_int n; { return (0); } -/*ARGSUSED*/ -copyout(kaddr, udaddr, n) caddr_t kaddr, udaddr; u_int n; { return (0); } - -/*ARGSUSED*/ -bzero(to, n) caddr_t to; u_int n; { } -/*ARGSUSED*/ -bcmp(from, to, n) caddr_t from, to; u_int n; { } -/*ARGSUSED*/ -bcopy(from, to, n) caddr_t from, to; u_int n; { } - -/*ARGSUSED*/ -CopyToBuffer(src, dst, length) - u_short *src, *dst; int length; -{ *dst = *src; } -/*ARGSUSED*/ -CopyFromBuffer(src, dst, length) - u_short *src; char *dst; int length; -{ *dst = *src; } - -/*ARGSUSED*/ -savectx(lp) label_t *lp; { return (0); } - -/*ARGSUSED*/ -setrq(p) struct proc *p; { } - -/*ARGSUSED*/ -remrq(p) struct proc *p; { } - -swtch() { if (whichqs) whichqs = 0; } - -/*ARGSUSED*/ -fubyte(base) caddr_t base; { return (0); } -#ifdef notdef -/*ARGSUSED*/ -fuibyte(base) caddr_t base; { return (0); } -#endif -/*ARGSUSED*/ -subyte(base, i) caddr_t base; { return (0); } -/*ARGSUSED*/ -suibyte(base, i) caddr_t base; { return (0); } -/*ARGSUSED*/ -fuword(base) caddr_t base; { return (0); } -/*ARGSUSED*/ -fuiword(base) caddr_t base; { return (0); } -/*ARGSUSED*/ -suword(base, i) caddr_t base; { return (0); } -/*ARGSUSED*/ -suiword(base, i) caddr_t base; { return (0); } - -/*ARGSUSED*/ -copyseg(udaddr, pf) caddr_t udaddr; unsigned pf; { } - -/*ARGSUSED*/ -clearseg(pf) unsigned pf; { } - -/*ARGSUSED*/ -addupc(pc, prof, ticks) unsigned pc; struct uprof *prof; int ticks; { } - -void MachEnableIntr() { } -void setsoftnet() { } -void clearsoftnet() { } -void setsoftclock() { } -void clearsoftclock() { } -spl0() { return (0); } -splsoftclock() { return (0); } -splnet() { return (0); } -splimp() { return (0); } /* XXX */ -splbio() { return (0); } -spltty() { return (0); } -splclock() { return (0); } -splhigh() { return (0); } - -/*ARGSUSED*/ -splx(s) int s; { } - -#ifdef notdef -/*ARGSUSED*/ -scanc(size, cp, table, mask) - unsigned size; char *cp, table[]; int mask; -{ return (0); } - -/*ARGSUSED*/ -skpc(mask, size, cp) int mask; int size; char *cp; { return (0); } - -/*ARGSUSED*/ -locc(mask, size, cp) int mask; char *cp; unsigned size; { return (0); } -#endif - -/*ARGSUSED*/ -_insque(p, q) caddr_t p, q; { } -/*ARGSUSED*/ -_remque(p) caddr_t p; { } - -/*ARGSUSED*/ -ffs(v) long v; { return (0); } - -/*ARGSUSED*/ -strlen(str) char *str; { return (0); } - -#ifdef notdef -imin(a, b) int a, b; { return (a < b ? a : b); } -imax(a, b) int a, b; { return (a > b ? a : b); } -unsigned min(a, b) u_int a, b; { return (a < b ? a : b); } -unsigned max(a, b) u_int a, b; { return (a > b ? a : b); } -#endif - -u_short ntohs(s) u_short s; { return ((u_short)s); } -u_short htons(s) u_short s; { return ((u_short)s); } -u_long ntohl(l) u_long l; { return ((u_long)l); } -u_long htonl(l) u_long l; { return ((u_long)l); } - -void MachKernGenException() { } -void MachUserGenException() { } -void MachTLBModException() { } -void MachTLBMissException() { } -void MachEmptyWriteBuffer() { } -/*ARGSUSED*/ -void MachTLBWriteIndexed(index, highEntry, lowEntry) - int index, highEntry, lowEntry; { } -/*ARGSUSED*/ -void MachSetPID(pid) int pid; { } -/*ARGSUSED*/ -void newptes(pte, v, size) struct pte *pte; u_int v; int size; { } -void MachTLBFlush() { } -/*ARGSUSED*/ -void MachTLBFlushPID(pid) int pid; { } -/*ARGSUSED*/ -void MachTLBFlushAddr(virt) caddr_t virt; { } -/*ARGSUSED*/ -void MachSwitchFPState(from, to) struct proc *from; struct user *to; { } -/*ARGSUSED*/ -void MachGetCurFPState(p) struct proc *p; { } -/*ARGSUSED*/ -void MachFPInterrupt(p) struct proc *p; { } -/*ARGSUSED*/ -void MachFPInterrupt(statusReg, causeReg, pc) - unsigned statusReg, causeReg, pc; { } -void MachConfigCache() { } -void MachFlushCache() { } -/*ARGSUSED*/ -void MachFlushICache(vaddr, len) caddr_t vaddr, int len; { } diff --git a/sys/arch/pmax/pmax/locore.s.sav b/sys/arch/pmax/pmax/locore.s.sav deleted file mode 100644 index 93e91884b97e..000000000000 --- a/sys/arch/pmax/pmax/locore.s.sav +++ /dev/null @@ -1,3085 +0,0 @@ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Digital Equipment Corporation and Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * Copyright (C) 1989 Digital Equipment Corporation. - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies. - * Digital Equipment Corporation makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/loMem.s, - * v 1.1 89/07/11 17:55:04 nelson Exp SPRITE (DECWRL) - * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsm.s, - * v 9.2 90/01/29 18:00:39 shirriff Exp SPRITE (DECWRL) - * from: Header: /sprite/src/kernel/vm/ds3100.md/vmPmaxAsm.s, - * v 1.1 89/07/10 14:27:41 nelson Exp SPRITE (DECWRL) - * from: @(#)locore.s 7.13 (Berkeley) 2/26/93 - * $Id: locore.s.sav,v 1.1.1.1 1993/10/12 03:22:36 deraadt Exp $ - */ - -/* - * Contains code that is the first executed at boot time plus - * assembly language support routines. - */ - -#include -#include - -#include -#include -#include -#include -#include - -#include "assym.h" - - .set noreorder - -/* - * Amount to take off of the stack for the benefit of the debugger. - */ -#define START_FRAME ((4 * 4) + 4 + 4) - - .globl start -start: - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts - li t1, MACH_RESERVED_ADDR # invalid address - mtc0 t1, MACH_COP_0_TLB_HI # Mark entry high as invalid - mtc0 zero, MACH_COP_0_TLB_LOW # Zero out low entry. -/* - * Clear the TLB (just to be safe). - * Align the starting value (t1), the increment (t2) and the upper bound (t3). - */ - move t1, zero - li t2, 1 << VMMACH_TLB_INDEX_SHIFT - li t3, VMMACH_NUM_TLB_ENTRIES << VMMACH_TLB_INDEX_SHIFT -1: - mtc0 t1, MACH_COP_0_TLB_INDEX # Set the index register. - addu t1, t1, t2 # Increment index. - bne t1, t3, 1b # NB: always executes next - tlbwi # Write the TLB entry. - - la sp, start - START_FRAME - la gp, _gp - sw zero, START_FRAME - 4(sp) # Zero out old ra for debugger - jal mach_init # mach_init(argc, argv, envp) - sw zero, START_FRAME - 8(sp) # Zero out old fp for debugger - - li t0, MACH_SR_COP_1_BIT # Disable interrupts and - mtc0 t0, MACH_COP_0_STATUS_REG # enable the coprocessor - li sp, KERNELSTACK - START_FRAME # switch to standard stack - mfc0 t0, MACH_COP_0_PRID # read processor ID register - cfc1 t1, MACH_FPC_ID # read FPU ID register - sw t0, cpu # save PRID register - sw t1, fpu # save FPU ID register - jal main # main() - nop - -/* proc[1] == /etc/init now running here; run icode */ - li v0, PSL_USERSET - mtc0 v0, MACH_COP_0_STATUS_REG # switch to user mode - li v0, VM_MIN_ADDRESS - j v0 # jump to icode - rfe - -/* - * GCC2 seems to want to call __main in main() for some reason. - */ -LEAF(__main) - j ra - nop -END(__main) - -/* - * This code is copied to user data space as the first program to run. - * Basically, it just calls execve(); - */ - .globl icode -icode: - li a1, VM_MIN_ADDRESS + (9 * 4) # address of 'icode_argv' - addu a0, a1, (3 * 4) # address of 'icode_fname' - move a2, zero # no environment - li v0, 59 # code for execve system call - syscall - li v0, 1 # code for exit system call - syscall # execve failed: call exit() -1: b 1b # loop if exit returns - nop -icode_argv: - .word VM_MIN_ADDRESS + (12 * 4) # address of 'icode_fname' - .word VM_MIN_ADDRESS + (15 * 4) # address of 'icodeEnd' - .word 0 -icode_fname: - .asciiz "/sbin/init" # occupies 3 words - .align 2 - .globl icodeEnd -icodeEnd: - - .sdata - .align 2 - .globl szicode -szicode: - .word (9 + 3 + 3) * 4 # compute icodeEnd - icode - .text - -/* - * This code is copied the user's stack for returning from signal handlers - * (see sendsig() and sigreturn()). We have to compute the address - * of the sigcontext struct for the sigreturn call. - */ - .globl sigcode -sigcode: - addu a0, sp, 16 # address of sigcontext - li v0, SYS_sigreturn # sigreturn(scp) - syscall - break 0 # just in case sigreturn fails - .globl esigcode -esigcode: - -/* - * Primitives - */ - -/* - * This table is indexed by u.u_pcb.pcb_onfault in trap(). - * The reason for using this table rather than storing an address in - * u.u_pcb.pcb_onfault is simply to make the code faster. - */ - .globl onfault_table - .data - .align 2 -onfault_table: - .word 0 # invalid index number -#define BADERR 1 - .word baderr -#define COPYERR 2 - .word copyerr -#define FSWBERR 3 - .word fswberr -#define FSWINTRBERR 4 - .word fswintrberr -#ifdef KADB -#define KADBERR 5 - .word kadberr -#endif - .text - -/* - * See if access to addr with a len type instruction causes a machine check. - * len is length of access (1=byte, 2=short, 4=long) - * - * badaddr(addr, len) - * char *addr; - * int len; - */ -LEAF(badaddr) - li v0, BADERR - bne a1, 1, 2f - sw v0, UADDR+U_PCB_ONFAULT - b 5f - lbu v0, (a0) -2: - bne a1, 2, 4f - nop - b 5f - lhu v0, (a0) -4: - lw v0, (a0) -5: - sw zero, UADDR+U_PCB_ONFAULT - j ra - move v0, zero # made it w/o errors -baderr: - j ra - li v0, 1 # trap sends us here -END(badaddr) - -/* - * netorder = htonl(hostorder) - * hostorder = ntohl(netorder) - */ -LEAF(htonl) # a0 = 0x11223344, return 0x44332211 -ALEAF(ntohl) - srl v1, a0, 24 # v1 = 0x00000011 - sll v0, a0, 24 # v0 = 0x44000000 - or v0, v0, v1 - and v1, a0, 0xff00 - sll v1, v1, 8 # v1 = 0x00330000 - or v0, v0, v1 - srl v1, a0, 8 - and v1, v1, 0xff00 # v1 = 0x00002200 - j ra - or v0, v0, v1 -END(htonl) - -/* - * netorder = htons(hostorder) - * hostorder = ntohs(netorder) - */ -LEAF(htons) -ALEAF(ntohs) - srl v0, a0, 8 - and v0, v0, 0xff - sll v1, a0, 8 - and v1, v1, 0xff00 - j ra - or v0, v0, v1 -END(htons) - -/* - * bit = ffs(value) - */ -LEAF(ffs) - beq a0, zero, 2f - move v0, zero -1: - and v1, a0, 1 # bit set? - addu v0, v0, 1 - beq v1, zero, 1b # no, continue - srl a0, a0, 1 -2: - j ra - nop -END(ffs) - -/* - * strlen(str) - */ -LEAF(strlen) - addu v1, a0, 1 -1: - lb v0, 0(a0) # get byte from string - addu a0, a0, 1 # increment pointer - bne v0, zero, 1b # continue if not end - nop - j ra - subu v0, a0, v1 # compute length - 1 for '\0' char -END(strlen) - -/* - * NOTE: this version assumes unsigned chars in order to be "8 bit clean". - */ -LEAF(strcmp) -1: - lbu t0, 0(a0) # get two bytes and compare them - lbu t1, 0(a1) - beq t0, zero, LessOrEq # end of first string? - nop - bne t0, t1, NotEq - nop - lbu t0, 1(a0) # unroll loop - lbu t1, 1(a1) - beq t0, zero, LessOrEq # end of first string? - addu a0, a0, 2 - beq t0, t1, 1b - addu a1, a1, 2 -NotEq: - j ra - subu v0, t0, t1 -LessOrEq: - j ra - subu v0, zero, t1 -END(strcmp) - -/* - * bzero(s1, n) - */ -LEAF(bzero) -ALEAF(blkclr) - blt a1, 12, smallclr # small amount to clear? - subu a3, zero, a0 # compute # bytes to word align address - and a3, a3, 3 - beq a3, zero, 1f # skip if word aligned - subu a1, a1, a3 # subtract from remaining count - swr zero, 0(a0) # clear 1, 2, or 3 bytes to align - addu a0, a0, a3 -1: - and v0, a1, 3 # compute number of words left - subu a3, a1, v0 - move a1, v0 - addu a3, a3, a0 # compute ending address -2: - addu a0, a0, 4 # clear words - bne a0, a3, 2b # unrolling loop does not help - sw zero, -4(a0) # since we are limited by memory speed -smallclr: - ble a1, zero, 2f - addu a3, a1, a0 # compute ending address -1: - addu a0, a0, 1 # clear bytes - bne a0, a3, 1b - sb zero, -1(a0) -2: - j ra - nop -END(bzero) - -/* - * bcmp(s1, s2, n) - */ -LEAF(bcmp) - blt a2, 16, smallcmp # is it worth any trouble? - xor v0, a0, a1 # compare low two bits of addresses - and v0, v0, 3 - subu a3, zero, a1 # compute # bytes to word align address - bne v0, zero, unalignedcmp # not possible to align addresses - and a3, a3, 3 - - beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count - move v0, v1 # init v0,v1 so unmodified bytes match - lwr v0, 0(a0) # read 1, 2, or 3 bytes - lwr v1, 0(a1) - addu a1, a1, a3 - bne v0, v1, nomatch - addu a0, a0, a3 -1: - and a3, a2, ~3 # compute number of whole words left - subu a2, a2, a3 # which has to be >= (16-3) & ~3 - addu a3, a3, a0 # compute ending address -2: - lw v0, 0(a0) # compare words - lw v1, 0(a1) - addu a0, a0, 4 - bne v0, v1, nomatch - addu a1, a1, 4 - bne a0, a3, 2b - nop - b smallcmp # finish remainder - nop -unalignedcmp: - beq a3, zero, 2f - subu a2, a2, a3 # subtract from remaining count - addu a3, a3, a0 # compute ending address -1: - lbu v0, 0(a0) # compare bytes until a1 word aligned - lbu v1, 0(a1) - addu a0, a0, 1 - bne v0, v1, nomatch - addu a1, a1, 1 - bne a0, a3, 1b - nop -2: - and a3, a2, ~3 # compute number of whole words left - subu a2, a2, a3 # which has to be >= (16-3) & ~3 - addu a3, a3, a0 # compute ending address -3: - lwr v0, 0(a0) # compare words a0 unaligned, a1 aligned - lwl v0, 3(a0) - lw v1, 0(a1) - addu a0, a0, 4 - bne v0, v1, nomatch - addu a1, a1, 4 - bne a0, a3, 3b - nop -smallcmp: - ble a2, zero, match - addu a3, a2, a0 # compute ending address -1: - lbu v0, 0(a0) - lbu v1, 0(a1) - addu a0, a0, 1 - bne v0, v1, nomatch - addu a1, a1, 1 - bne a0, a3, 1b - nop -match: - j ra - move v0, zero -nomatch: - j ra - li v0, 1 -END(bcmp) - -/* - * {ov}bcopy(from, to, len) - */ -LEAF(bcopy) -ALEAF(ovbcopy) - addu t0, a0, a2 # t0 = end of s1 region - sltu t1, a1, t0 - sltu t2, a0, a1 - and t1, t1, t2 # t1 = true if from < to < (from+len) - beq t1, zero, forward # non overlapping, do forward copy - slt t2, a2, 12 # check for small copy - - ble a2, zero, 2f - addu t1, a1, a2 # t1 = end of to region -1: - lb v0, -1(t0) # copy bytes backwards, - subu t0, t0, 1 # doesnt happen often so do slow way - subu t1, t1, 1 - bne t0, a0, 1b - sb v0, 0(t1) -2: - j ra - nop -forward: - bne t2, zero, smallcpy # do a small bcopy - xor v0, a0, a1 # compare low two bits of addresses - and v0, v0, 3 - subu a3, zero, a1 # compute # bytes to word align address - beq v0, zero, aligned # addresses can be word aligned - and a3, a3, 3 - - beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count - lwr v0, 0(a0) # get next 4 bytes (unaligned) - lwl v0, 3(a0) - addu a0, a0, a3 - swr v0, 0(a1) # store 1, 2, or 3 bytes to align a1 - addu a1, a1, a3 -1: - and v0, a2, 3 # compute number of words left - subu a3, a2, v0 - move a2, v0 - addu a3, a3, a0 # compute ending address -2: - lwr v0, 0(a0) # copy words a0 unaligned, a1 aligned - lwl v0, 3(a0) - addu a0, a0, 4 - addu a1, a1, 4 - bne a0, a3, 2b - sw v0, -4(a1) - b smallcpy - nop -aligned: - beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count - lwr v0, 0(a0) # copy 1, 2, or 3 bytes to align - addu a0, a0, a3 - swr v0, 0(a1) - addu a1, a1, a3 -1: - and v0, a2, 3 # compute number of whole words left - subu a3, a2, v0 - move a2, v0 - addu a3, a3, a0 # compute ending address -2: - lw v0, 0(a0) # copy words - addu a0, a0, 4 - addu a1, a1, 4 - bne a0, a3, 2b - sw v0, -4(a1) -smallcpy: - ble a2, zero, 2f - addu a3, a2, a0 # compute ending address -1: - lbu v0, 0(a0) # copy bytes - addu a0, a0, 1 - addu a1, a1, 1 - bne a0, a3, 1b - sb v0, -1(a1) -2: - j ra - move v0, zero -END(bcopy) - -/* - * Copy a null terminated string within the kernel address space. - * Maxlength may be null if count not wanted. - * copystr(fromaddr, toaddr, maxlength, &lencopied) - * caddr_t fromaddr; - * caddr_t toaddr; - * u_int maxlength; - * u_int *lencopied; - */ -LEAF(copystr) - move t2, a2 # Save the number of bytes -1: - lbu t0, 0(a0) - subu a2, a2, 1 - beq t0, zero, 2f - sb t0, 0(a1) - addu a0, a0, 1 - bne a2, zero, 1b - addu a1, a1, 1 -2: - beq a3, zero, 3f - subu a2, t2, a2 # compute length copied - sw a2, 0(a3) -3: - j ra - move v0, zero -END(copystr) - -/* - * Copy a null terminated string from the user address space into - * the kernel address space. - * - * copyinstr(fromaddr, toaddr, maxlength, &lencopied) - * caddr_t fromaddr; - * caddr_t toaddr; - * u_int maxlength; - * u_int *lencopied; - */ -NON_LEAF(copyinstr, STAND_FRAME_SIZE, ra) - subu sp, sp, STAND_FRAME_SIZE - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - sw ra, STAND_RA_OFFSET(sp) - blt a0, zero, copyerr # make sure address is in user space - li v0, COPYERR - jal copystr - sw v0, UADDR+U_PCB_ONFAULT - lw ra, STAND_RA_OFFSET(sp) - sw zero, UADDR+U_PCB_ONFAULT - addu sp, sp, STAND_FRAME_SIZE - j ra - move v0, zero -END(copyinstr) - -/* - * Copy a null terminated string from the kernel address space into - * the user address space. - * - * copyoutstr(fromaddr, toaddr, maxlength, &lencopied) - * caddr_t fromaddr; - * caddr_t toaddr; - * u_int maxlength; - * u_int *lencopied; - */ -NON_LEAF(copyoutstr, STAND_FRAME_SIZE, ra) - subu sp, sp, STAND_FRAME_SIZE - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - sw ra, STAND_RA_OFFSET(sp) - blt a1, zero, copyerr # make sure address is in user space - li v0, COPYERR - jal copystr - sw v0, UADDR+U_PCB_ONFAULT - lw ra, STAND_RA_OFFSET(sp) - sw zero, UADDR+U_PCB_ONFAULT - addu sp, sp, STAND_FRAME_SIZE - j ra - move v0, zero -END(copyoutstr) - -/* - * Copy specified amount of data from user space into the kernel - * copyin(from, to, len) - * caddr_t *from; (user source address) - * caddr_t *to; (kernel destination address) - * unsigned len; - */ -NON_LEAF(copyin, STAND_FRAME_SIZE, ra) - subu sp, sp, STAND_FRAME_SIZE - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - sw ra, STAND_RA_OFFSET(sp) - blt a0, zero, copyerr # make sure address is in user space - li v0, COPYERR - jal bcopy - sw v0, UADDR+U_PCB_ONFAULT - lw ra, STAND_RA_OFFSET(sp) - sw zero, UADDR+U_PCB_ONFAULT - addu sp, sp, STAND_FRAME_SIZE - j ra - move v0, zero -END(copyin) - -/* - * Copy specified amount of data from kernel to the user space - * copyout(from, to, len) - * caddr_t *from; (kernel source address) - * caddr_t *to; (user destination address) - * unsigned len; - */ -NON_LEAF(copyout, STAND_FRAME_SIZE, ra) - subu sp, sp, STAND_FRAME_SIZE - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - sw ra, STAND_RA_OFFSET(sp) - blt a1, zero, copyerr # make sure address is in user space - li v0, COPYERR - jal bcopy - sw v0, UADDR+U_PCB_ONFAULT - lw ra, STAND_RA_OFFSET(sp) - sw zero, UADDR+U_PCB_ONFAULT - addu sp, sp, STAND_FRAME_SIZE - j ra - move v0, zero -END(copyout) - -LEAF(copyerr) - lw ra, STAND_RA_OFFSET(sp) - sw zero, UADDR+U_PCB_ONFAULT - addu sp, sp, STAND_FRAME_SIZE - j ra - li v0, EFAULT # return error -END(copyerr) - -/* - * Copy data to the DMA buffer. - * The DMA bufffer can only be written one short at a time - * (and takes ~14 cycles). - * - * CopyToBuffer(src, dst, length) - * u_short *src; NOTE: must be short aligned - * u_short *dst; - * int length; - */ -LEAF(CopyToBuffer) - blez a2, 2f - nop -1: - lhu t0, 0(a0) # read 2 bytes of data - subu a2, a2, 2 - addu a0, a0, 2 - addu a1, a1, 4 - bgtz a2, 1b - sh t0, -4(a1) # write 2 bytes of data to buffer -2: - j ra - nop -END(CopyToBuffer) - -/* - * Copy data from the DMA buffer. - * The DMA bufffer can only be read one short at a time - * (and takes ~12 cycles). - * - * CopyFromBuffer(src, dst, length) - * u_short *src; - * char *dst; - * int length; - */ -LEAF(CopyFromBuffer) - and t0, a1, 1 # test for aligned dst - beq t0, zero, 3f - nop - blt a2, 2, 7f # at least 2 bytes to copy? - nop -1: - lhu t0, 0(a0) # read 2 bytes of data from buffer - addu a0, a0, 4 # keep buffer pointer word aligned - addu a1, a1, 2 - subu a2, a2, 2 - sb t0, -2(a1) - srl t0, t0, 8 - bge a2, 2, 1b - sb t0, -1(a1) -3: - blt a2, 2, 7f # at least 2 bytes to copy? - nop -6: - lhu t0, 0(a0) # read 2 bytes of data from buffer - addu a0, a0, 4 # keep buffer pointer word aligned - addu a1, a1, 2 - subu a2, a2, 2 - bge a2, 2, 6b - sh t0, -2(a1) -7: - ble a2, zero, 9f # done? - nop - lhu t0, 0(a0) # copy one more byte - nop - sb t0, 0(a1) -9: - j ra - nop -END(CopyFromBuffer) - -/* - * Copy the kernel stack to the new process and save the current context so - * the new process will return nonzero when it is resumed by cpu_swtch(). - * - * copykstack(up) - * struct user *up; - */ -LEAF(copykstack) - subu v0, sp, UADDR # compute offset into stack - addu v0, v0, a0 # v0 = new stack address - move v1, sp # v1 = old stack address - li t1, KERNELSTACK -1: - lw t0, 0(v1) # copy stack data - addu v1, v1, 4 - sw t0, 0(v0) - bne v1, t1, 1b - addu v0, v0, 4 - /* FALLTHROUGH */ -/* - * Save registers and state so we can do a longjmp later. - * Note: this only works if p != curproc since - * cpu_swtch() will copy over pcb_context. - * - * savectx(up) - * struct user *up; - */ -ALEAF(savectx) - sw s0, U_PCB_CONTEXT+0(a0) - sw s1, U_PCB_CONTEXT+4(a0) - sw s2, U_PCB_CONTEXT+8(a0) - sw s3, U_PCB_CONTEXT+12(a0) - mfc0 v0, MACH_COP_0_STATUS_REG - sw s4, U_PCB_CONTEXT+16(a0) - sw s5, U_PCB_CONTEXT+20(a0) - sw s6, U_PCB_CONTEXT+24(a0) - sw s7, U_PCB_CONTEXT+28(a0) - sw sp, U_PCB_CONTEXT+32(a0) - sw s8, U_PCB_CONTEXT+36(a0) - sw ra, U_PCB_CONTEXT+40(a0) - sw v0, U_PCB_CONTEXT+44(a0) - j ra - move v0, zero -END(copykstack) - -/* - * _whichqs tells which of the 32 queues _qs - * have processes in them. Setrq puts processes into queues, Remrq - * removes them from queues. The running process is on no queue, - * other processes are on a queue related to p->p_pri, divided by 4 - * actually to shrink the 0-127 range of priorities into the 32 available - * queues. - */ - -/* - * setrq(p) - * proc *p; - * - * Call should be made at splclock(), and p->p_stat should be SRUN. - */ -NON_LEAF(setrq, STAND_FRAME_SIZE, ra) - subu sp, sp, STAND_FRAME_SIZE - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - lw t0, P_RLINK(a0) ## firewall: p->p_rlink must be 0 - sw ra, STAND_RA_OFFSET(sp) ## - beq t0, zero, 1f ## - lbu t0, P_PRI(a0) # put on queue which is p->p_pri / 4 - PANIC("setrq") ## -1: - li t1, 1 # compute corresponding bit - srl t0, t0, 2 # compute index into 'whichqs' - sll t1, t1, t0 - lw t2, whichqs # set corresponding bit - nop - or t2, t2, t1 - sw t2, whichqs - sll t0, t0, 3 # compute index into 'qs' - la t1, qs - addu t0, t0, t1 # t0 = qp = &qs[pri >> 2] - lw t1, P_RLINK(t0) # t1 = qp->ph_rlink - sw t0, P_LINK(a0) # p->p_link = qp - sw t1, P_RLINK(a0) # p->p_rlink = qp->ph_rlink - sw a0, P_LINK(t1) # p->p_rlink->p_link = p; - sw a0, P_RLINK(t0) # qp->ph_rlink = p - j ra - addu sp, sp, STAND_FRAME_SIZE -END(setrq) - -/* - * Remrq(p) - * - * Call should be made at splclock(). - */ -NON_LEAF(remrq, STAND_FRAME_SIZE, ra) - subu sp, sp, STAND_FRAME_SIZE - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - lbu t0, P_PRI(a0) # get from queue which is p->p_pri / 4 - li t1, 1 # compute corresponding bit - srl t0, t0, 2 # compute index into 'whichqs' - lw t2, whichqs # check corresponding bit - sll t1, t1, t0 - and v0, t2, t1 - sw ra, STAND_RA_OFFSET(sp) ## - bne v0, zero, 1f ## - lw v0, P_RLINK(a0) # v0 = p->p_rlink - PANIC("remrq") ## it wasnt recorded to be on its q -1: - lw v1, P_LINK(a0) # v1 = p->p_link - nop - sw v1, P_LINK(v0) # p->p_rlink->p_link = p->p_link; - sw v0, P_RLINK(v1) # p->p_link->p_rlink = p->r_rlink - sll t0, t0, 3 # compute index into 'qs' - la v0, qs - addu t0, t0, v0 # t0 = qp = &qs[pri >> 2] - lw v0, P_LINK(t0) # check if queue empty - nop - bne v0, t0, 2f # No. qp->ph_link != qp - nop - xor t2, t2, t1 # clear corresponding bit in 'whichqs' - sw t2, whichqs -2: - sw zero, P_RLINK(a0) ## for firewall checking - j ra - addu sp, sp, STAND_FRAME_SIZE -END(remrq) - -/* - * swtch_exit() - * - * At exit of a process, do a cpu_swtch for the last time. - * The mapping of the pcb at p->p_addr has already been deleted, - * and the memory for the pcb+stack has been freed. - * All interrupts should be blocked at this point. - */ -LEAF(swtch_exit) - la v0, nullproc # save state into garbage proc - lw t0, P_UPTE+0(v0) # t0 = first u. pte - lw t1, P_UPTE+4(v0) # t1 = 2nd u. pte - li v0, UADDR # v0 = first HI entry - mtc0 zero, MACH_COP_0_TLB_INDEX # set the index register - mtc0 v0, MACH_COP_0_TLB_HI # init high entry - mtc0 t0, MACH_COP_0_TLB_LOW # init low entry - li t0, 1 << VMMACH_TLB_INDEX_SHIFT - tlbwi # Write the TLB entry. - addu v0, v0, NBPG # 2nd HI entry - mtc0 t0, MACH_COP_0_TLB_INDEX # set the index register - mtc0 v0, MACH_COP_0_TLB_HI # init high entry - mtc0 t1, MACH_COP_0_TLB_LOW # init low entry - nop - tlbwi # Write the TLB entry. - li sp, KERNELSTACK - START_FRAME # switch to standard stack - b cpu_swtch - nop -END(swtch_exit) - -/* - * When no processes are on the runq, cpu_swtch branches to idle - * to wait for something to come ready. - * Note: this is really a part of cpu_swtch() but defined here for kernel - * profiling. - */ -LEAF(idle) - li t0, (MACH_INT_MASK | MACH_SR_INT_ENA_CUR) - mtc0 t0, MACH_COP_0_STATUS_REG # enable all interrupts - sw zero, curproc # set curproc NULL for stats -1: - lw t0, whichqs # look for non-empty queue - nop - beq t0, zero, 1b - nop - b sw1 - mtc0 zero, MACH_COP_0_STATUS_REG # Disable all interrupts -END(idle) - -/* - * cpu_swtch() - * Find the highest priority process and resume it. - */ -NON_LEAF(cpu_swtch, STAND_FRAME_SIZE, ra) - sw sp, UADDR+U_PCB_CONTEXT+32 # save old sp - subu sp, sp, STAND_FRAME_SIZE - sw ra, STAND_RA_OFFSET(sp) - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - lw t2, cnt+V_SWTCH # for statistics - lw t1, whichqs # look for non-empty queue - mfc0 t0, MACH_COP_0_STATUS_REG # t0 = saved status register - sw ra, UADDR+U_PCB_CONTEXT+40 # save return address - sw t0, UADDR+U_PCB_CONTEXT+44 # save status register - addu t2, t2, 1 - beq t1, zero, idle # if none, idle - sw t2, cnt+V_SWTCH - mtc0 zero, MACH_COP_0_STATUS_REG # Disable all interrupts -sw1: - nop # wait for intrs disabled - nop - lw t0, whichqs # look for non-empty queue - li t2, -1 # t2 = lowest bit set - beq t0, zero, idle # if none, idle - move t3, t0 # t3 = saved whichqs -1: - addu t2, t2, 1 - and t1, t0, 1 # bit set? - beq t1, zero, 1b - srl t0, t0, 1 # try next bit -/* - * Remove process from queue. - */ - sll t0, t2, 3 - la t1, qs - addu t0, t0, t1 # t0 = qp = &qs[highbit] - lw a0, P_LINK(t0) # a0 = p = highest pri process - nop - lw v0, P_LINK(a0) # v0 = p->p_link - bne t0, a0, 2f # make sure something in queue - sw v0, P_LINK(t0) # qp->ph_link = p->p_link; - PANIC("cpu_swtch") # nothing in queue -2: - sw t0, P_RLINK(v0) # p->p_link->p_rlink = qp - bne v0, t0, 3f # queue still not empty - sw zero, P_RLINK(a0) ## for firewall checking - li v1, 1 # compute bit in 'whichqs' - sll v1, v1, t2 - xor t3, t3, v1 # clear bit in 'whichqs' - sw t3, whichqs -3: -/* - * Save old context and switch to new one. - */ - sw a0, curproc # set curproc - sw zero, want_resched - jal pmap_alloc_tlbpid # v0 = TLB PID - sw a0, STAND_FRAME_SIZE(sp) # save p - lw a0, STAND_FRAME_SIZE(sp) # restore p - sll v0, v0, VMMACH_TLB_PID_SHIFT # v0 = aligned PID - lw t0, P_UPTE+0(a0) # t0 = first u. pte - lw t1, P_UPTE+4(a0) # t1 = 2nd u. pte - sw s0, UADDR+U_PCB_CONTEXT+0 # do a 'savectx()' - sw s1, UADDR+U_PCB_CONTEXT+4 # We save s0 to s8 here because - sw s2, UADDR+U_PCB_CONTEXT+8 # the TLB trap code uses - sw s3, UADDR+U_PCB_CONTEXT+12 # CONTEXT and there should be - sw s4, UADDR+U_PCB_CONTEXT+16 # no faults at this point. - sw s5, UADDR+U_PCB_CONTEXT+20 - sw s6, UADDR+U_PCB_CONTEXT+24 - sw s7, UADDR+U_PCB_CONTEXT+28 - sw s8, UADDR+U_PCB_CONTEXT+36 - or v0, v0, UADDR # v0 = first HI entry -/* - * Resume process indicated by the pte's for its u struct - * NOTE: This is hard coded to UPAGES == 2. - * Also, there should be no TLB faults at this point. - */ - mtc0 zero, MACH_COP_0_TLB_INDEX # set the index register - mtc0 v0, MACH_COP_0_TLB_HI # init high entry - mtc0 t0, MACH_COP_0_TLB_LOW # init low entry - li t0, 1 << VMMACH_TLB_INDEX_SHIFT - tlbwi # Write the TLB entry. - addu v0, v0, NBPG # 2nd HI entry - mtc0 t0, MACH_COP_0_TLB_INDEX # set the index register - mtc0 v0, MACH_COP_0_TLB_HI # init high entry - mtc0 t1, MACH_COP_0_TLB_LOW # init low entry - nop - tlbwi # Write the TLB entry. -/* - * Now running on new u struct. - * Restore registers and return. - */ - lw v0, UADDR+U_PCB_CONTEXT+44 # restore kernel context - lw ra, UADDR+U_PCB_CONTEXT+40 - lw s0, UADDR+U_PCB_CONTEXT+0 - lw s1, UADDR+U_PCB_CONTEXT+4 - lw s2, UADDR+U_PCB_CONTEXT+8 - lw s3, UADDR+U_PCB_CONTEXT+12 - lw s4, UADDR+U_PCB_CONTEXT+16 - lw s5, UADDR+U_PCB_CONTEXT+20 - lw s6, UADDR+U_PCB_CONTEXT+24 - lw s7, UADDR+U_PCB_CONTEXT+28 - lw sp, UADDR+U_PCB_CONTEXT+32 - lw s8, UADDR+U_PCB_CONTEXT+36 - mtc0 v0, MACH_COP_0_STATUS_REG - j ra - li v0, 1 # possible return to 'savectx()' -END(cpu_swtch) - -/* - * {fu,su},{ibyte,isword,iword}, fetch or store a byte, short or word to - * user text space. - * {fu,su},{byte,sword,word}, fetch or store a byte, short or word to - * user data space. - */ -LEAF(fuword) -ALEAF(fuiword) - blt a0, zero, fswberr # make sure address is in user space - li v0, FSWBERR - sw v0, UADDR+U_PCB_ONFAULT - lw v0, 0(a0) # fetch word - j ra - sw zero, UADDR+U_PCB_ONFAULT -END(fuword) - -LEAF(fusword) -ALEAF(fuisword) - blt a0, zero, fswberr # make sure address is in user space - li v0, FSWBERR - sw v0, UADDR+U_PCB_ONFAULT - lhu v0, 0(a0) # fetch short - j ra - sw zero, UADDR+U_PCB_ONFAULT -END(fusword) - -LEAF(fubyte) -ALEAF(fuibyte) - blt a0, zero, fswberr # make sure address is in user space - li v0, FSWBERR - sw v0, UADDR+U_PCB_ONFAULT - lbu v0, 0(a0) # fetch byte - j ra - sw zero, UADDR+U_PCB_ONFAULT -END(fubyte) - -LEAF(suword) - blt a0, zero, fswberr # make sure address is in user space - li v0, FSWBERR - sw v0, UADDR+U_PCB_ONFAULT - sw a1, 0(a0) # store word - sw zero, UADDR+U_PCB_ONFAULT - j ra - move v0, zero -END(suword) - -/* - * Have to flush instruction cache afterwards. - */ -LEAF(suiword) - blt a0, zero, fswberr # make sure address is in user space - li v0, FSWBERR - sw v0, UADDR+U_PCB_ONFAULT - sw a1, 0(a0) # store word - sw zero, UADDR+U_PCB_ONFAULT - move v0, zero - b MachFlushICache # NOTE: this should not clobber v0! - li a1, 4 # size of word -END(suiword) - -/* - * Will have to flush the instruction cache if byte merging is done in hardware. - */ -LEAF(susword) -ALEAF(suisword) - blt a0, zero, fswberr # make sure address is in user space - li v0, FSWBERR - sw v0, UADDR+U_PCB_ONFAULT - sh a1, 0(a0) # store short - sw zero, UADDR+U_PCB_ONFAULT - j ra - move v0, zero -END(susword) - -LEAF(subyte) -ALEAF(suibyte) - blt a0, zero, fswberr # make sure address is in user space - li v0, FSWBERR - sw v0, UADDR+U_PCB_ONFAULT - sb a1, 0(a0) # store byte - sw zero, UADDR+U_PCB_ONFAULT - j ra - move v0, zero -END(subyte) - -LEAF(fswberr) - j ra - li v0, -1 -END(fswberr) - -/* - * fuswintr and suswintr are just like fusword and susword except that if - * the page is not in memory or would cause a trap, then we return an error. - * The important thing is to prevent sleep() and swtch(). - */ -LEAF(fuswintr) - blt a0, zero, fswintrberr # make sure address is in user space - li v0, FSWINTRBERR - sw v0, UADDR+U_PCB_ONFAULT - lhu v0, 0(a0) # fetch short - j ra - sw zero, UADDR+U_PCB_ONFAULT -END(fuswintr) - -LEAF(suswintr) - blt a0, zero, fswintrberr # make sure address is in user space - li v0, FSWINTRBERR - sw v0, UADDR+U_PCB_ONFAULT - sh a1, 0(a0) # store short - sw zero, UADDR+U_PCB_ONFAULT - j ra - move v0, zero -END(suswintr) - -LEAF(fswintrberr) - j ra - li v0, -1 -END(fswintrberr) - -/* - * Insert 'p' after 'q'. - * _insque(p, q) - * caddr_t p, q; - */ -LEAF(_insque) - lw v0, 0(a1) # v0 = q->next - sw a1, 4(a0) # p->prev = q - sw v0, 0(a0) # p->next = q->next - sw a0, 4(v0) # q->next->prev = p - j ra - sw a0, 0(a1) # q->next = p -END(_insque) - -/* - * Remove item 'p' from queue. - * _remque(p) - * caddr_t p; - */ -LEAF(_remque) - lw v0, 0(a0) # v0 = p->next - lw v1, 4(a0) # v1 = p->prev - nop - sw v0, 0(v1) # p->prev->next = p->next - j ra - sw v1, 4(v0) # p->next->prev = p->prev -END(_remque) - -/* - * This code is copied to the UTLB exception vector address to - * handle user level TLB translation misses. - * NOTE: This code must be relocatable!!! - */ - .globl MachUTLBMiss -MachUTLBMiss: - .set noat - mfc0 k0, MACH_COP_0_BAD_VADDR # get the virtual address - nop - srl k0, k0, PMAP_HASH_SHIFT1 # get page in low bits - srl k1, k0, PMAP_HASH_SHIFT2 - PMAP_HASH_SHIFT1 - and k0, k0, PMAP_HASH_MASK1 - and k1, k1, PMAP_HASH_MASK2 - or k1, k1, k0 - sll k1, k1, PMAP_HASH_SIZE_SHIFT # compute index - lw k0, PMAP_HASH_LOW_OFFSET(k1) # get cached low PTE entry - lw k1, PMAP_HASH_HIGH_OFFSET(k1) # get cached high PTE entry - mtc0 k0, MACH_COP_0_TLB_LOW - mfc0 k0, MACH_COP_0_TLB_HI # get actual high PTE entry - nop - bne k0, k1, 1f # non-matching PTE - mfc0 k0, MACH_COP_0_EXC_PC # get return address - tlbwr # update TLB - j k0 - rfe -1: - j UtlbFault # handle the rest - nop - .set at - .globl MachUTLBMissEnd -MachUTLBMissEnd: - -/* - * This code is copied to the general exception vector address to - * handle all execptions except RESET and UTLBMiss. - * NOTE: This code must be relocatable!!! - */ - .globl MachException -MachException: -/* - * Find out what mode we came from and jump to the proper handler. - */ - .set noat - mfc0 k0, MACH_COP_0_STATUS_REG # Get the status register - mfc0 k1, MACH_COP_0_CAUSE_REG # Get the cause register value. - and k0, k0, MACH_SR_KU_PREV # test for user mode - sll k0, k0, 3 # shift user bit for cause index - and k1, k1, MACH_CR_EXC_CODE # Mask out the cause bits. - or k1, k1, k0 # change index to user table -1: - la k0, machExceptionTable # get base of the jump table - addu k0, k0, k1 # Get the address of the - # function entry. Note that - # the cause is already - # shifted left by 2 bits so - # we dont have to shift. - lw k0, 0(k0) # Get the function address - nop - j k0 # Jump to the function. - nop - .set at - .globl MachExceptionEnd -MachExceptionEnd: - -/* - * Handle the rest of the UTLB miss. - */ -UtlbFault: - .set noat - mfc0 k0, MACH_COP_0_BAD_VADDR # get the virtual address - nop - srl k0, k0, PMAP_HASH_SHIFT1 # get page in low bits - srl k1, k0, PMAP_HASH_SHIFT2 - PMAP_HASH_SHIFT1 - and k0, k0, PMAP_HASH_MASK1 - and k1, k1, PMAP_HASH_MASK2 - or k1, k1, k0 - sll k1, k1, PMAP_HASH_SIZE_SHIFT # compute index - lw k0, PMAP_HASH_LOW_OFFSET+8(k1) # get cached low PTE entry - lw k1, PMAP_HASH_HIGH_OFFSET+8(k1) # get cached high PTE entry - mtc0 k0, MACH_COP_0_TLB_LOW - mfc0 k0, MACH_COP_0_TLB_HI # get actual high PTE entry - nop - bne k0, k1, SlowFault # non-matching PTE - mfc0 k0, MACH_COP_0_EXC_PC # get return address - tlbwr # update TLB - j k0 - rfe -/* - * We couldn't find a TLB entry. - * Find out what mode we came from and call the appropriate handler. - */ -SlowFault: - mfc0 k0, MACH_COP_0_STATUS_REG - nop - and k0, k0, MACH_SR_KU_PREV - bne k0, zero, MachUserGenException - nop - .set at -/* - * Fall though ... - */ - -/*---------------------------------------------------------------------------- - * - * MachKernGenException -- - * - * Handle an exception from kernel mode. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ - -/* - * The kernel exception stack contains 18 saved general registers, - * the status register and the multiply lo and high registers. - * In addition, we set this up for linkage conventions. - */ -#define KERN_REG_SIZE (18 * 4) -#define KERN_REG_OFFSET (STAND_FRAME_SIZE) -#define KERN_SR_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE) -#define KERN_MULT_LO_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE + 4) -#define KERN_MULT_HI_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE + 8) -#define KERN_EXC_FRAME_SIZE (STAND_FRAME_SIZE + KERN_REG_SIZE + 12) - -NON_LEAF(MachKernGenException, KERN_EXC_FRAME_SIZE, ra) - .set noat -#ifdef KADB - la k0, kdbpcb # save registers for kadb - sw s0, (S0 * 4)(k0) - sw s1, (S1 * 4)(k0) - sw s2, (S2 * 4)(k0) - sw s3, (S3 * 4)(k0) - sw s4, (S4 * 4)(k0) - sw s5, (S5 * 4)(k0) - sw s6, (S6 * 4)(k0) - sw s7, (S7 * 4)(k0) - sw s8, (S8 * 4)(k0) - sw gp, (GP * 4)(k0) - sw sp, (SP * 4)(k0) -#endif - subu sp, sp, KERN_EXC_FRAME_SIZE - .mask 0x80000000, (STAND_RA_OFFSET - KERN_EXC_FRAME_SIZE) -/* - * Save the relevant kernel registers onto the stack. - * We don't need to save s0 - s8, sp and gp because - * the compiler does it for us. - */ - sw AT, KERN_REG_OFFSET + 0(sp) - sw v0, KERN_REG_OFFSET + 4(sp) - sw v1, KERN_REG_OFFSET + 8(sp) - sw a0, KERN_REG_OFFSET + 12(sp) - mflo v0 - mfhi v1 - sw a1, KERN_REG_OFFSET + 16(sp) - sw a2, KERN_REG_OFFSET + 20(sp) - sw a3, KERN_REG_OFFSET + 24(sp) - sw t0, KERN_REG_OFFSET + 28(sp) - mfc0 a0, MACH_COP_0_STATUS_REG # First arg is the status reg. - sw t1, KERN_REG_OFFSET + 32(sp) - sw t2, KERN_REG_OFFSET + 36(sp) - sw t3, KERN_REG_OFFSET + 40(sp) - sw t4, KERN_REG_OFFSET + 44(sp) - mfc0 a1, MACH_COP_0_CAUSE_REG # Second arg is the cause reg. - sw t5, KERN_REG_OFFSET + 48(sp) - sw t6, KERN_REG_OFFSET + 52(sp) - sw t7, KERN_REG_OFFSET + 56(sp) - sw t8, KERN_REG_OFFSET + 60(sp) - mfc0 a2, MACH_COP_0_BAD_VADDR # Third arg is the fault addr. - sw t9, KERN_REG_OFFSET + 64(sp) - sw ra, KERN_REG_OFFSET + 68(sp) - sw v0, KERN_MULT_LO_OFFSET(sp) - sw v1, KERN_MULT_HI_OFFSET(sp) - mfc0 a3, MACH_COP_0_EXC_PC # Fourth arg is the pc. - sw a0, KERN_SR_OFFSET(sp) -/* - * Call the exception handler. - */ - jal trap - sw a3, STAND_RA_OFFSET(sp) # for debugging -/* - * Restore registers and return from the exception. - * v0 contains the return address. - */ - lw a0, KERN_SR_OFFSET(sp) - lw t0, KERN_MULT_LO_OFFSET(sp) - lw t1, KERN_MULT_HI_OFFSET(sp) - mtc0 a0, MACH_COP_0_STATUS_REG # Restore the SR, disable intrs - mtlo t0 - mthi t1 - move k0, v0 - lw AT, KERN_REG_OFFSET + 0(sp) - lw v0, KERN_REG_OFFSET + 4(sp) - lw v1, KERN_REG_OFFSET + 8(sp) - lw a0, KERN_REG_OFFSET + 12(sp) - lw a1, KERN_REG_OFFSET + 16(sp) - lw a2, KERN_REG_OFFSET + 20(sp) - lw a3, KERN_REG_OFFSET + 24(sp) - lw t0, KERN_REG_OFFSET + 28(sp) - lw t1, KERN_REG_OFFSET + 32(sp) - lw t2, KERN_REG_OFFSET + 36(sp) - lw t3, KERN_REG_OFFSET + 40(sp) - lw t4, KERN_REG_OFFSET + 44(sp) - lw t5, KERN_REG_OFFSET + 48(sp) - lw t6, KERN_REG_OFFSET + 52(sp) - lw t7, KERN_REG_OFFSET + 56(sp) - lw t8, KERN_REG_OFFSET + 60(sp) - lw t9, KERN_REG_OFFSET + 64(sp) - lw ra, KERN_REG_OFFSET + 68(sp) - addu sp, sp, KERN_EXC_FRAME_SIZE - j k0 # Now return from the - rfe # exception. - .set at -END(MachKernGenException) - -/*---------------------------------------------------------------------------- - * - * MachUserGenException -- - * - * Handle an exception from user mode. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ -NON_LEAF(MachUserGenException, STAND_FRAME_SIZE, ra) - .set noat - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) -/* - * Save all of the registers except for the kernel temporaries in u.u_pcb. - */ - sw AT, UADDR+U_PCB_REGS+(AST * 4) - sw v0, UADDR+U_PCB_REGS+(V0 * 4) - sw v1, UADDR+U_PCB_REGS+(V1 * 4) - sw a0, UADDR+U_PCB_REGS+(A0 * 4) - mflo v0 - sw a1, UADDR+U_PCB_REGS+(A1 * 4) - sw a2, UADDR+U_PCB_REGS+(A2 * 4) - sw a3, UADDR+U_PCB_REGS+(A3 * 4) - sw t0, UADDR+U_PCB_REGS+(T0 * 4) - mfhi v1 - sw t1, UADDR+U_PCB_REGS+(T1 * 4) - sw t2, UADDR+U_PCB_REGS+(T2 * 4) - sw t3, UADDR+U_PCB_REGS+(T3 * 4) - sw t4, UADDR+U_PCB_REGS+(T4 * 4) - mfc0 a0, MACH_COP_0_STATUS_REG # First arg is the status reg. - sw t5, UADDR+U_PCB_REGS+(T5 * 4) - sw t6, UADDR+U_PCB_REGS+(T6 * 4) - sw t7, UADDR+U_PCB_REGS+(T7 * 4) - sw s0, UADDR+U_PCB_REGS+(S0 * 4) - mfc0 a1, MACH_COP_0_CAUSE_REG # Second arg is the cause reg. - sw s1, UADDR+U_PCB_REGS+(S1 * 4) - sw s2, UADDR+U_PCB_REGS+(S2 * 4) - sw s3, UADDR+U_PCB_REGS+(S3 * 4) - sw s4, UADDR+U_PCB_REGS+(S4 * 4) - mfc0 a2, MACH_COP_0_BAD_VADDR # Third arg is the fault addr - sw s5, UADDR+U_PCB_REGS+(S5 * 4) - sw s6, UADDR+U_PCB_REGS+(S6 * 4) - sw s7, UADDR+U_PCB_REGS+(S7 * 4) - sw t8, UADDR+U_PCB_REGS+(T8 * 4) - mfc0 a3, MACH_COP_0_EXC_PC # Fourth arg is the pc. - sw t9, UADDR+U_PCB_REGS+(T9 * 4) - sw gp, UADDR+U_PCB_REGS+(GP * 4) - sw sp, UADDR+U_PCB_REGS+(SP * 4) - sw s8, UADDR+U_PCB_REGS+(S8 * 4) - li sp, KERNELSTACK - STAND_FRAME_SIZE # switch to kernel SP - sw ra, UADDR+U_PCB_REGS+(RA * 4) - sw v0, UADDR+U_PCB_REGS+(MULLO * 4) - sw v1, UADDR+U_PCB_REGS+(MULHI * 4) - sw a0, UADDR+U_PCB_REGS+(SR * 4) - la gp, _gp # switch to kernel GP - sw a3, UADDR+U_PCB_REGS+(PC * 4) - sw a3, STAND_RA_OFFSET(sp) # for debugging - .set at - and t0, a0, ~MACH_SR_COP_1_BIT # Turn off the FPU. - .set noat -/* - * Call the exception handler. - */ - jal trap - mtc0 t0, MACH_COP_0_STATUS_REG -/* - * Restore user registers and return. NOTE: interrupts are enabled. - */ - lw a0, UADDR+U_PCB_REGS+(SR * 4) - lw t0, UADDR+U_PCB_REGS+(MULLO * 4) - lw t1, UADDR+U_PCB_REGS+(MULHI * 4) - mtc0 a0, MACH_COP_0_STATUS_REG # this should disable interrupts - mtlo t0 - mthi t1 - lw k0, UADDR+U_PCB_REGS+(PC * 4) - lw AT, UADDR+U_PCB_REGS+(AST * 4) - lw v0, UADDR+U_PCB_REGS+(V0 * 4) - lw v1, UADDR+U_PCB_REGS+(V1 * 4) - lw a0, UADDR+U_PCB_REGS+(A0 * 4) - lw a1, UADDR+U_PCB_REGS+(A1 * 4) - lw a2, UADDR+U_PCB_REGS+(A2 * 4) - lw a3, UADDR+U_PCB_REGS+(A3 * 4) - lw t0, UADDR+U_PCB_REGS+(T0 * 4) - lw t1, UADDR+U_PCB_REGS+(T1 * 4) - lw t2, UADDR+U_PCB_REGS+(T2 * 4) - lw t3, UADDR+U_PCB_REGS+(T3 * 4) - lw t4, UADDR+U_PCB_REGS+(T4 * 4) - lw t5, UADDR+U_PCB_REGS+(T5 * 4) - lw t6, UADDR+U_PCB_REGS+(T6 * 4) - lw t7, UADDR+U_PCB_REGS+(T7 * 4) - lw s0, UADDR+U_PCB_REGS+(S0 * 4) - lw s1, UADDR+U_PCB_REGS+(S1 * 4) - lw s2, UADDR+U_PCB_REGS+(S2 * 4) - lw s3, UADDR+U_PCB_REGS+(S3 * 4) - lw s4, UADDR+U_PCB_REGS+(S4 * 4) - lw s5, UADDR+U_PCB_REGS+(S5 * 4) - lw s6, UADDR+U_PCB_REGS+(S6 * 4) - lw s7, UADDR+U_PCB_REGS+(S7 * 4) - lw t8, UADDR+U_PCB_REGS+(T8 * 4) - lw t9, UADDR+U_PCB_REGS+(T9 * 4) - lw gp, UADDR+U_PCB_REGS+(GP * 4) - lw sp, UADDR+U_PCB_REGS+(SP * 4) - lw s8, UADDR+U_PCB_REGS+(S8 * 4) - lw ra, UADDR+U_PCB_REGS+(RA * 4) - j k0 - rfe - .set at -END(MachUserGenException) - -/*---------------------------------------------------------------------------- - * - * MachKernIntr -- - * - * Handle an interrupt from kernel mode. - * Interrupts must use a separate stack since during exit() - * there is a window of time when there is no kernel stack. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ -#define KINTR_REG_OFFSET (STAND_FRAME_SIZE) -#define KINTR_SR_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE) -#define KINTR_SP_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE + 4) -#define KINTR_MULT_LO_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE + 8) -#define KINTR_MULT_HI_OFFSET (STAND_FRAME_SIZE + KERN_REG_SIZE + 12) -#define KINTR_FRAME_SIZE (STAND_FRAME_SIZE + KERN_REG_SIZE + 16) - -NON_LEAF(MachKernIntr, KINTR_FRAME_SIZE, ra) - .set noat - .mask 0x80000000, (STAND_RA_OFFSET - KINTR_FRAME_SIZE) -/* - * Check to see if we are already on the interrupt stack. - */ - li k0, MACH_CODE_START # interrupt stack below code - sltu k1, sp, k0 - beq k1, zero, 1f # no, init sp - nop - sw sp, KINTR_SP_OFFSET - KINTR_FRAME_SIZE(sp) # save old sp - b 2f - subu sp, sp, KINTR_FRAME_SIZE # allocate stack frame -1: - sw sp, KINTR_SP_OFFSET - KINTR_FRAME_SIZE(k0) # save old sp - subu sp, k0, KINTR_FRAME_SIZE # switch to interrupt stack -2: -/* - * Save the relevant kernel registers onto the stack. - * We don't need to save s0 - s8, sp and gp because - * the compiler does it for us. - */ - sw AT, KINTR_REG_OFFSET + 0(sp) - sw v0, KINTR_REG_OFFSET + 4(sp) - sw v1, KINTR_REG_OFFSET + 8(sp) - sw a0, KINTR_REG_OFFSET + 12(sp) - mflo v0 - mfhi v1 - sw a1, KINTR_REG_OFFSET + 16(sp) - sw a2, KINTR_REG_OFFSET + 20(sp) - sw a3, KINTR_REG_OFFSET + 24(sp) - sw t0, KINTR_REG_OFFSET + 28(sp) - mfc0 a0, MACH_COP_0_STATUS_REG # First arg is the status reg. - sw t1, KINTR_REG_OFFSET + 32(sp) - sw t2, KINTR_REG_OFFSET + 36(sp) - sw t3, KINTR_REG_OFFSET + 40(sp) - sw t4, KINTR_REG_OFFSET + 44(sp) - mfc0 a1, MACH_COP_0_CAUSE_REG # Second arg is the cause reg. - sw t5, KINTR_REG_OFFSET + 48(sp) - sw t6, KINTR_REG_OFFSET + 52(sp) - sw t7, KINTR_REG_OFFSET + 56(sp) - sw t8, KINTR_REG_OFFSET + 60(sp) - mfc0 a2, MACH_COP_0_EXC_PC # Third arg is the pc. - sw t9, KINTR_REG_OFFSET + 64(sp) - sw ra, KINTR_REG_OFFSET + 68(sp) - sw v0, KINTR_MULT_LO_OFFSET(sp) - sw v1, KINTR_MULT_HI_OFFSET(sp) - sw a0, KINTR_SR_OFFSET(sp) -/* - * Call the interrupt handler. - */ - jal interrupt - sw a2, STAND_RA_OFFSET(sp) # for debugging -/* - * Restore registers and return from the interrupt. - */ - lw a0, KINTR_SR_OFFSET(sp) - lw t0, KINTR_MULT_LO_OFFSET(sp) - lw t1, KINTR_MULT_HI_OFFSET(sp) - mtc0 a0, MACH_COP_0_STATUS_REG # Restore the SR, disable intrs - mtlo t0 - mthi t1 - lw k0, STAND_RA_OFFSET(sp) - lw AT, KINTR_REG_OFFSET + 0(sp) - lw v0, KINTR_REG_OFFSET + 4(sp) - lw v1, KINTR_REG_OFFSET + 8(sp) - lw a0, KINTR_REG_OFFSET + 12(sp) - lw a1, KINTR_REG_OFFSET + 16(sp) - lw a2, KINTR_REG_OFFSET + 20(sp) - lw a3, KINTR_REG_OFFSET + 24(sp) - lw t0, KINTR_REG_OFFSET + 28(sp) - lw t1, KINTR_REG_OFFSET + 32(sp) - lw t2, KINTR_REG_OFFSET + 36(sp) - lw t3, KINTR_REG_OFFSET + 40(sp) - lw t4, KINTR_REG_OFFSET + 44(sp) - lw t5, KINTR_REG_OFFSET + 48(sp) - lw t6, KINTR_REG_OFFSET + 52(sp) - lw t7, KINTR_REG_OFFSET + 56(sp) - lw t8, KINTR_REG_OFFSET + 60(sp) - lw t9, KINTR_REG_OFFSET + 64(sp) - lw ra, KINTR_REG_OFFSET + 68(sp) - lw sp, KINTR_SP_OFFSET(sp) # restore orig sp - j k0 # Now return from the - rfe # interrupt. - .set at -END(MachKernIntr) - -/*---------------------------------------------------------------------------- - * - * MachUserIntr -- - * - * Handle an interrupt from user mode. - * Note: we save minimal state in the u.u_pcb struct and use the standard - * kernel stack since there has to be a u page if we came from user mode. - * If there is a pending software interrupt, then save the remaining state - * and call softintr(). This is all because if we call swtch() inside - * interrupt(), not all the user registers have been saved in u.u_pcb. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ -NON_LEAF(MachUserIntr, STAND_FRAME_SIZE, ra) - .set noat - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) -/* - * Save the relevant user registers into the u.u_pcb struct. - * We don't need to save s0 - s8 because - * the compiler does it for us. - */ - sw AT, UADDR+U_PCB_REGS+(AST * 4) - sw v0, UADDR+U_PCB_REGS+(V0 * 4) - sw v1, UADDR+U_PCB_REGS+(V1 * 4) - sw a0, UADDR+U_PCB_REGS+(A0 * 4) - mflo v0 - mfhi v1 - sw a1, UADDR+U_PCB_REGS+(A1 * 4) - sw a2, UADDR+U_PCB_REGS+(A2 * 4) - sw a3, UADDR+U_PCB_REGS+(A3 * 4) - sw t0, UADDR+U_PCB_REGS+(T0 * 4) - mfc0 a0, MACH_COP_0_STATUS_REG # First arg is the status reg. - sw t1, UADDR+U_PCB_REGS+(T1 * 4) - sw t2, UADDR+U_PCB_REGS+(T2 * 4) - sw t3, UADDR+U_PCB_REGS+(T3 * 4) - sw t4, UADDR+U_PCB_REGS+(T4 * 4) - mfc0 a1, MACH_COP_0_CAUSE_REG # Second arg is the cause reg. - sw t5, UADDR+U_PCB_REGS+(T5 * 4) - sw t6, UADDR+U_PCB_REGS+(T6 * 4) - sw t7, UADDR+U_PCB_REGS+(T7 * 4) - sw t8, UADDR+U_PCB_REGS+(T8 * 4) - mfc0 a2, MACH_COP_0_EXC_PC # Third arg is the pc. - sw t9, UADDR+U_PCB_REGS+(T9 * 4) - sw gp, UADDR+U_PCB_REGS+(GP * 4) - sw sp, UADDR+U_PCB_REGS+(SP * 4) - sw ra, UADDR+U_PCB_REGS+(RA * 4) - li sp, KERNELSTACK - STAND_FRAME_SIZE # switch to kernel SP - sw v0, UADDR+U_PCB_REGS+(MULLO * 4) - sw v1, UADDR+U_PCB_REGS+(MULHI * 4) - sw a0, UADDR+U_PCB_REGS+(SR * 4) - sw a2, UADDR+U_PCB_REGS+(PC * 4) - la gp, _gp # switch to kernel GP - .set at - and t0, a0, ~MACH_SR_COP_1_BIT # Turn off the FPU. - .set noat - mtc0 t0, MACH_COP_0_STATUS_REG -/* - * Call the interrupt handler. - */ - jal interrupt - sw a2, STAND_RA_OFFSET(sp) # for debugging -/* - * Restore registers and return from the interrupt. - */ - lw a0, UADDR+U_PCB_REGS+(SR * 4) - lw v0, astpending # any pending interrupts? - mtc0 a0, MACH_COP_0_STATUS_REG # Restore the SR, disable intrs - bne v0, zero, 1f # dont restore, call softintr - lw t0, UADDR+U_PCB_REGS+(MULLO * 4) - lw t1, UADDR+U_PCB_REGS+(MULHI * 4) - lw k0, UADDR+U_PCB_REGS+(PC * 4) - lw AT, UADDR+U_PCB_REGS+(AST * 4) - lw v0, UADDR+U_PCB_REGS+(V0 * 4) - lw v1, UADDR+U_PCB_REGS+(V1 * 4) - lw a0, UADDR+U_PCB_REGS+(A0 * 4) - lw a1, UADDR+U_PCB_REGS+(A1 * 4) - lw a2, UADDR+U_PCB_REGS+(A2 * 4) - lw a3, UADDR+U_PCB_REGS+(A3 * 4) - mtlo t0 - mthi t1 - lw t0, UADDR+U_PCB_REGS+(T0 * 4) - lw t1, UADDR+U_PCB_REGS+(T1 * 4) - lw t2, UADDR+U_PCB_REGS+(T2 * 4) - lw t3, UADDR+U_PCB_REGS+(T3 * 4) - lw t4, UADDR+U_PCB_REGS+(T4 * 4) - lw t5, UADDR+U_PCB_REGS+(T5 * 4) - lw t6, UADDR+U_PCB_REGS+(T6 * 4) - lw t7, UADDR+U_PCB_REGS+(T7 * 4) - lw t8, UADDR+U_PCB_REGS+(T8 * 4) - lw t9, UADDR+U_PCB_REGS+(T9 * 4) - lw gp, UADDR+U_PCB_REGS+(GP * 4) - lw sp, UADDR+U_PCB_REGS+(SP * 4) - lw ra, UADDR+U_PCB_REGS+(RA * 4) - j k0 # Now return from the - rfe # interrupt. - -1: -/* - * We have pending software interrupts; save remaining user state in u.u_pcb. - */ - sw s0, UADDR+U_PCB_REGS+(S0 * 4) - sw s1, UADDR+U_PCB_REGS+(S1 * 4) - sw s2, UADDR+U_PCB_REGS+(S2 * 4) - sw s3, UADDR+U_PCB_REGS+(S3 * 4) - sw s4, UADDR+U_PCB_REGS+(S4 * 4) - sw s5, UADDR+U_PCB_REGS+(S5 * 4) - sw s6, UADDR+U_PCB_REGS+(S6 * 4) - sw s7, UADDR+U_PCB_REGS+(S7 * 4) - sw s8, UADDR+U_PCB_REGS+(S8 * 4) - li t0, MACH_HARD_INT_MASK | MACH_SR_INT_ENA_CUR -/* - * Call the software interrupt handler. - */ - jal softintr - mtc0 t0, MACH_COP_0_STATUS_REG # enable interrupts (spl0) -/* - * Restore user registers and return. NOTE: interrupts are enabled. - */ - lw a0, UADDR+U_PCB_REGS+(SR * 4) - lw t0, UADDR+U_PCB_REGS+(MULLO * 4) - lw t1, UADDR+U_PCB_REGS+(MULHI * 4) - mtc0 a0, MACH_COP_0_STATUS_REG # this should disable interrupts - mtlo t0 - mthi t1 - lw k0, UADDR+U_PCB_REGS+(PC * 4) - lw AT, UADDR+U_PCB_REGS+(AST * 4) - lw v0, UADDR+U_PCB_REGS+(V0 * 4) - lw v1, UADDR+U_PCB_REGS+(V1 * 4) - lw a0, UADDR+U_PCB_REGS+(A0 * 4) - lw a1, UADDR+U_PCB_REGS+(A1 * 4) - lw a2, UADDR+U_PCB_REGS+(A2 * 4) - lw a3, UADDR+U_PCB_REGS+(A3 * 4) - lw t0, UADDR+U_PCB_REGS+(T0 * 4) - lw t1, UADDR+U_PCB_REGS+(T1 * 4) - lw t2, UADDR+U_PCB_REGS+(T2 * 4) - lw t3, UADDR+U_PCB_REGS+(T3 * 4) - lw t4, UADDR+U_PCB_REGS+(T4 * 4) - lw t5, UADDR+U_PCB_REGS+(T5 * 4) - lw t6, UADDR+U_PCB_REGS+(T6 * 4) - lw t7, UADDR+U_PCB_REGS+(T7 * 4) - lw s0, UADDR+U_PCB_REGS+(S0 * 4) - lw s1, UADDR+U_PCB_REGS+(S1 * 4) - lw s2, UADDR+U_PCB_REGS+(S2 * 4) - lw s3, UADDR+U_PCB_REGS+(S3 * 4) - lw s4, UADDR+U_PCB_REGS+(S4 * 4) - lw s5, UADDR+U_PCB_REGS+(S5 * 4) - lw s6, UADDR+U_PCB_REGS+(S6 * 4) - lw s7, UADDR+U_PCB_REGS+(S7 * 4) - lw t8, UADDR+U_PCB_REGS+(T8 * 4) - lw t9, UADDR+U_PCB_REGS+(T9 * 4) - lw gp, UADDR+U_PCB_REGS+(GP * 4) - lw sp, UADDR+U_PCB_REGS+(SP * 4) - lw s8, UADDR+U_PCB_REGS+(S8 * 4) - lw ra, UADDR+U_PCB_REGS+(RA * 4) - j k0 - rfe - .set at -END(MachUserIntr) - -#if 0 -/*---------------------------------------------------------------------------- - * - * MachTLBModException -- - * - * Handle a TLB modified exception. - * The BaddVAddr, Context, and EntryHi registers contain the failed - * virtual address. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ -LEAF(MachTLBModException) - .set noat - tlbp # find the TLB entry - mfc0 k0, MACH_COP_0_TLB_LOW # get the physical address - mfc0 k1, MACH_COP_0_TLB_INDEX # check to be sure its valid - or k0, k0, VMMACH_TLB_MOD_BIT # update TLB - blt k1, zero, 4f # not found!!! - mtc0 k0, MACH_COP_0_TLB_LOW - li k1, MACH_CACHED_MEMORY_ADDR - subu k0, k0, k1 - srl k0, k0, VMMACH_TLB_PHYS_PAGE_SHIFT - la k1, pmap_attributes - addu k0, k0, k1 - lbu k1, 0(k0) # fetch old value - nop - or k1, k1, 1 # set modified bit - sb k1, 0(k0) # save new value - mfc0 k0, MACH_COP_0_EXC_PC # get return address - nop - j k0 - rfe -4: - break 0 # panic - .set at -END(MachTLBModException) -#endif - -/*---------------------------------------------------------------------------- - * - * MachTLBMissException -- - * - * Handle a TLB miss exception from kernel mode. - * The BaddVAddr, Context, and EntryHi registers contain the failed - * virtual address. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ -LEAF(MachTLBMissException) - .set noat - mfc0 k0, MACH_COP_0_BAD_VADDR # get the fault address - li k1, MACH_KSEG2_ADDR # compute index - subu k0, k0, k1 - srl k0, k0, PGSHIFT - li k1, PMAP_HASH_KPAGES * NPTEPG # index within range? - sltu k1, k0, k1 - beq k1, zero, MachKernGenException # No. do it the long way - sll k0, k0, 2 # compute offset from index - li k1, PMAP_HASH_KADDR - addu k0, k0, k1 - lw k0, 0(k0) # get PTE entry - mfc0 k1, MACH_COP_0_EXC_PC # get return address - mtc0 k0, MACH_COP_0_TLB_LOW # save PTE entry - and k0, k0, PG_V # make sure its valid - beq k0, zero, MachKernGenException # No. do it the long way - nop - tlbwr # update TLB - j k1 - rfe - .set at -END(MachTLBMissException) - -/* - * Set/clear software interrupt routines. - */ - -LEAF(setsoftclock) - mfc0 v0, MACH_COP_0_CAUSE_REG # read cause register - nop - or v0, v0, MACH_SOFT_INT_MASK_0 # set soft clock interrupt - mtc0 v0, MACH_COP_0_CAUSE_REG # save it - j ra - nop -END(setsoftclock) - -LEAF(clearsoftclock) - mfc0 v0, MACH_COP_0_CAUSE_REG # read cause register - nop - and v0, v0, ~MACH_SOFT_INT_MASK_0 # clear soft clock interrupt - mtc0 v0, MACH_COP_0_CAUSE_REG # save it - j ra - nop -END(clearsoftclock) - -LEAF(setsoftnet) - mfc0 v0, MACH_COP_0_CAUSE_REG # read cause register - nop - or v0, v0, MACH_SOFT_INT_MASK_1 # set soft net interrupt - mtc0 v0, MACH_COP_0_CAUSE_REG # save it - j ra - nop -END(setsoftnet) - -LEAF(clearsoftnet) - mfc0 v0, MACH_COP_0_CAUSE_REG # read cause register - nop - and v0, v0, ~MACH_SOFT_INT_MASK_1 # clear soft net interrupt - mtc0 v0, MACH_COP_0_CAUSE_REG # save it - j ra - nop -END(clearsoftnet) - -/* - * Set/change interrupt priority routines. - */ - -LEAF(MachEnableIntr) - mfc0 v0, MACH_COP_0_STATUS_REG # read status register - nop - or v0, v0, MACH_SR_INT_ENA_CUR - mtc0 v0, MACH_COP_0_STATUS_REG # enable all interrupts - j ra - nop -END(MachEnableIntr) - -LEAF(spl0) - mfc0 v0, MACH_COP_0_STATUS_REG # read status register - nop - or t0, v0, (MACH_INT_MASK | MACH_SR_INT_ENA_CUR) - mtc0 t0, MACH_COP_0_STATUS_REG # enable all interrupts - j ra - and v0, v0, (MACH_INT_MASK | MACH_SR_INT_ENA_CUR) -END(spl0) - -LEAF(splsoftclock) - mfc0 v0, MACH_COP_0_STATUS_REG # read status register - li t0, ~MACH_SOFT_INT_MASK_0 # disable soft clock - and t0, t0, v0 - mtc0 t0, MACH_COP_0_STATUS_REG # save it - j ra - and v0, v0, (MACH_INT_MASK | MACH_SR_INT_ENA_CUR) -END(splsoftclock) - -LEAF(Mach_spl0) - mfc0 v0, MACH_COP_0_STATUS_REG # read status register - li t0, ~(MACH_INT_MASK_0|MACH_SOFT_INT_MASK_1|MACH_SOFT_INT_MASK_0) - and t0, t0, v0 - mtc0 t0, MACH_COP_0_STATUS_REG # save it - j ra - and v0, v0, (MACH_INT_MASK | MACH_SR_INT_ENA_CUR) -END(Mach_spl0) - -LEAF(Mach_spl1) - mfc0 v0, MACH_COP_0_STATUS_REG # read status register - li t0, ~(MACH_INT_MASK_1|MACH_SOFT_INT_MASK_0|MACH_SOFT_INT_MASK_1) - and t0, t0, v0 - mtc0 t0, MACH_COP_0_STATUS_REG # save it - j ra - and v0, v0, (MACH_INT_MASK | MACH_SR_INT_ENA_CUR) -END(Mach_spl1) - -LEAF(Mach_spl2) - mfc0 v0, MACH_COP_0_STATUS_REG # read status register - li t0, ~(MACH_INT_MASK_2|MACH_SOFT_INT_MASK_1|MACH_SOFT_INT_MASK_0) - and t0, t0, v0 - mtc0 t0, MACH_COP_0_STATUS_REG # save it - j ra - and v0, v0, (MACH_INT_MASK | MACH_SR_INT_ENA_CUR) -END(Mach_spl2) - -LEAF(Mach_spl3) - mfc0 v0, MACH_COP_0_STATUS_REG # read status register - li t0, ~(MACH_INT_MASK_3|MACH_SOFT_INT_MASK_1|MACH_SOFT_INT_MASK_0) - and t0, t0, v0 - mtc0 t0, MACH_COP_0_STATUS_REG # save it - j ra - and v0, v0, (MACH_INT_MASK | MACH_SR_INT_ENA_CUR) -END(Mach_spl3) - -LEAF(splhigh) - mfc0 v0, MACH_COP_0_STATUS_REG # read status register - li t0, ~MACH_SR_INT_ENA_CUR # disable all interrupts - and t0, t0, v0 - mtc0 t0, MACH_COP_0_STATUS_REG # save it - j ra - and v0, v0, (MACH_INT_MASK | MACH_SR_INT_ENA_CUR) -END(splhigh) - -/* - * Restore saved interrupt mask. - */ -LEAF(splx) - mfc0 v0, MACH_COP_0_STATUS_REG - li t0, ~(MACH_INT_MASK | MACH_SR_INT_ENA_CUR) - and t0, t0, v0 - or t0, t0, a0 - mtc0 t0, MACH_COP_0_STATUS_REG - j ra - nop -END(splx) - -/*---------------------------------------------------------------------------- - * - * MachEmptyWriteBuffer -- - * - * Return when the write buffer is empty. - * - * MachEmptyWriteBuffer() - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ -LEAF(MachEmptyWriteBuffer) - nop - nop - nop - nop -1: bc0f 1b - nop - j ra - nop -END(MachEmptyWriteBuffer) - -/*-------------------------------------------------------------------------- - * - * MachTLBWriteIndexed -- - * - * Write the given entry into the TLB at the given index. - * - * MachTLBWriteIndexed(index, highEntry, lowEntry) - * int index; - * int highEntry; - * int lowEntry; - * - * Results: - * None. - * - * Side effects: - * TLB entry set. - * - *-------------------------------------------------------------------------- - */ -LEAF(MachTLBWriteIndexed) - mfc0 t1, MACH_COP_0_STATUS_REG # Save the status register. - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts - mfc0 t0, MACH_COP_0_TLB_HI # Save the current PID. - - sll a0, a0, VMMACH_TLB_INDEX_SHIFT - mtc0 a0, MACH_COP_0_TLB_INDEX # Set the index. - mtc0 a1, MACH_COP_0_TLB_HI # Set up entry high. - mtc0 a2, MACH_COP_0_TLB_LOW # Set up entry low. - nop - tlbwi # Write the TLB - - mtc0 t0, MACH_COP_0_TLB_HI # Restore the PID. - j ra - mtc0 t1, MACH_COP_0_STATUS_REG # Restore the status register -END(MachTLBWriteIndexed) - -/*-------------------------------------------------------------------------- - * - * MachTLBWriteRandom -- - * - * Write the given entry into the TLB at a random location. - * - * MachTLBWriteRandom(highEntry, lowEntry) - * unsigned highEntry; - * unsigned lowEntry; - * - * Results: - * None. - * - * Side effects: - * TLB entry set. - * - *-------------------------------------------------------------------------- - */ -LEAF(MachTLBWriteRandom) - mfc0 v1, MACH_COP_0_STATUS_REG # Save the status register. - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts - mfc0 v0, MACH_COP_0_TLB_HI # Save the current PID. - - mtc0 a0, MACH_COP_0_TLB_HI # Set up entry high. - mtc0 a1, MACH_COP_0_TLB_LOW # Set up entry low. - nop - tlbwr # Write the TLB - - mtc0 v0, MACH_COP_0_TLB_HI # Restore the PID. - j ra - mtc0 v1, MACH_COP_0_STATUS_REG # Restore the status register -END(MachTLBWriteRandom) - -/*-------------------------------------------------------------------------- - * - * MachSetPID -- - * - * Write the given pid into the TLB pid reg. - * - * MachSetPID(pid) - * int pid; - * - * Results: - * None. - * - * Side effects: - * PID set in the entry hi register. - * - *-------------------------------------------------------------------------- - */ -LEAF(MachSetPID) - sll a0, a0, VMMACH_TLB_PID_SHIFT # put PID in right spot - mtc0 a0, MACH_COP_0_TLB_HI # Write the hi reg value - j ra - nop -END(MachSetPID) - -/*-------------------------------------------------------------------------- - * - * MachTLBFlush -- - * - * Flush the "random" entries from the TLB. - * - * MachTLBFlush() - * - * Results: - * None. - * - * Side effects: - * The TLB is flushed. - * - *-------------------------------------------------------------------------- - */ -LEAF(MachTLBFlush) - mfc0 v1, MACH_COP_0_STATUS_REG # Save the status register. - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts - mfc0 t0, MACH_COP_0_TLB_HI # Save the PID - li t1, MACH_RESERVED_ADDR # invalid address - mtc0 t1, MACH_COP_0_TLB_HI # Mark entry high as invalid - mtc0 zero, MACH_COP_0_TLB_LOW # Zero out low entry. -/* - * Align the starting value (t1) and the upper bound (t2). - */ - li t1, VMMACH_FIRST_RAND_ENTRY << VMMACH_TLB_INDEX_SHIFT - li t2, VMMACH_NUM_TLB_ENTRIES << VMMACH_TLB_INDEX_SHIFT -1: - mtc0 t1, MACH_COP_0_TLB_INDEX # Set the index register. - addu t1, t1, 1 << VMMACH_TLB_INDEX_SHIFT # Increment index. - bne t1, t2, 1b # NB: always executes next - tlbwi # Write the TLB entry. - - mtc0 t0, MACH_COP_0_TLB_HI # Restore the PID - j ra - mtc0 v1, MACH_COP_0_STATUS_REG # Restore the status register -END(MachTLBFlush) - -/*-------------------------------------------------------------------------- - * - * MachTLBFlushPID -- - * - * Flush all entries with the given PID from the TLB. - * - * MachTLBFlushPID(pid) - * int pid; - * - * Results: - * None. - * - * Side effects: - * All entries corresponding to this PID are flushed. - * - *-------------------------------------------------------------------------- - */ -LEAF(MachTLBFlushPID) - mfc0 v1, MACH_COP_0_STATUS_REG # Save the status register. - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts - mfc0 t0, MACH_COP_0_TLB_HI # Save the current PID - sll a0, a0, VMMACH_TLB_PID_SHIFT # Align the pid to flush. -/* - * Align the starting value (t1) and the upper bound (t2). - */ - li t1, VMMACH_FIRST_RAND_ENTRY << VMMACH_TLB_INDEX_SHIFT - li t2, VMMACH_NUM_TLB_ENTRIES << VMMACH_TLB_INDEX_SHIFT - mtc0 t1, MACH_COP_0_TLB_INDEX # Set the index register -1: - addu t1, t1, 1 << VMMACH_TLB_INDEX_SHIFT # Increment index. - tlbr # Read from the TLB - mfc0 t4, MACH_COP_0_TLB_HI # Fetch the hi register. - nop - and t4, t4, VMMACH_TLB_PID # compare PIDs - bne t4, a0, 2f - li v0, MACH_RESERVED_ADDR # invalid address - mtc0 v0, MACH_COP_0_TLB_HI # Mark entry high as invalid - mtc0 zero, MACH_COP_0_TLB_LOW # Zero out low entry. - nop - tlbwi # Write the entry. -2: - bne t1, t2, 1b - mtc0 t1, MACH_COP_0_TLB_INDEX # Set the index register - - mtc0 t0, MACH_COP_0_TLB_HI # restore PID - j ra - mtc0 v1, MACH_COP_0_STATUS_REG # Restore the status register -END(MachTLBFlushPID) - -/*-------------------------------------------------------------------------- - * - * MachTLBFlushAddr -- - * - * Flush any TLB entries for the given address and TLB PID. - * - * MachTLBFlushAddr(highreg) - * unsigned highreg; - * - * Results: - * None. - * - * Side effects: - * The process's page is flushed from the TLB. - * - *-------------------------------------------------------------------------- - */ -LEAF(MachTLBFlushAddr) - mfc0 v1, MACH_COP_0_STATUS_REG # Save the status register. - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts - mfc0 t0, MACH_COP_0_TLB_HI # Get current PID - - mtc0 a0, MACH_COP_0_TLB_HI # look for addr & PID - nop - tlbp # Probe for the entry. - mfc0 v0, MACH_COP_0_TLB_INDEX # See what we got - li t1, MACH_RESERVED_ADDR # Load invalid entry. - bltz v0, 1f # index < 0 => !found - mtc0 t1, MACH_COP_0_TLB_HI # Mark entry high as invalid - mtc0 zero, MACH_COP_0_TLB_LOW # Zero out low entry. - nop - tlbwi -1: - mtc0 t0, MACH_COP_0_TLB_HI # restore PID - j ra - mtc0 v1, MACH_COP_0_STATUS_REG # Restore the status register -END(MachTLBFlushAddr) - -/*-------------------------------------------------------------------------- - * - * MachTLBUpdate -- - * - * Update the TLB if highreg is found. - * - * MachTLBUpdate(highreg, lowreg) - * unsigned highreg, lowreg; - * - * Results: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -LEAF(MachTLBUpdate) - mfc0 v1, MACH_COP_0_STATUS_REG # Save the status register. - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts - mfc0 t0, MACH_COP_0_TLB_HI # Save current PID - - mtc0 a0, MACH_COP_0_TLB_HI # init high reg. - mtc0 a1, MACH_COP_0_TLB_LOW # init low reg. - nop - tlbp # Probe for the entry. - mfc0 v0, MACH_COP_0_TLB_INDEX # See what we got - nop - bltz v0, 1f # index < 0 => !found - nop - tlbwi -1: - mtc0 t0, MACH_COP_0_TLB_HI # restore PID - j ra - mtc0 v1, MACH_COP_0_STATUS_REG # Restore the status register -END(MachTLBUpdate) - -#if defined(DEBUG) || defined(KADB) -/*-------------------------------------------------------------------------- - * - * MachTLBFind -- - * - * Search the TLB for the given entry. - * - * MachTLBFind(hi) - * unsigned hi; - * - * Results: - * Returns a value >= 0 if the entry was found (the index). - * Returns a value < 0 if the entry was not found. - * - * Side effects: - * tlbhi and tlblo will contain the TLB entry found. - * - *-------------------------------------------------------------------------- - */ - .comm tlbhi, 4 - .comm tlblo, 4 -LEAF(MachTLBFind) - mfc0 v1, MACH_COP_0_STATUS_REG # Save the status register. - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts - mfc0 t0, MACH_COP_0_TLB_HI # Get current PID - nop - mtc0 a0, MACH_COP_0_TLB_HI # Set up entry high. - nop - tlbp # Probe for the entry. - mfc0 v0, MACH_COP_0_TLB_INDEX # See what we got - nop - bltz v0, 1f # not found - nop - tlbr # read TLB - mfc0 t1, MACH_COP_0_TLB_HI # See what we got - mfc0 t2, MACH_COP_0_TLB_LOW # See what we got - sw t1, tlbhi - sw t2, tlblo -1: - mtc0 t0, MACH_COP_0_TLB_HI # Restore current PID - j ra - mtc0 v1, MACH_COP_0_STATUS_REG # Restore the status register -END(MachTLBFind) - -/*-------------------------------------------------------------------------- - * - * MachTLBRead -- - * - * Read the TLB entry. - * - * MachTLBRead(entry) - * unsigned entry; - * - * Results: - * None. - * - * Side effects: - * tlbhi and tlblo will contain the TLB entry found. - * - *-------------------------------------------------------------------------- - */ -LEAF(MachTLBRead) - mfc0 v1, MACH_COP_0_STATUS_REG # Save the status register. - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts - mfc0 t0, MACH_COP_0_TLB_HI # Get current PID - - sll a0, a0, VMMACH_TLB_INDEX_SHIFT - mtc0 a0, MACH_COP_0_TLB_INDEX # Set the index register - nop - tlbr # Read from the TLB - mfc0 t3, MACH_COP_0_TLB_HI # fetch the hi entry - mfc0 t4, MACH_COP_0_TLB_LOW # fetch the low entry - sw t3, tlbhi - sw t4, tlblo - - mtc0 t0, MACH_COP_0_TLB_HI # restore PID - j ra - mtc0 v1, MACH_COP_0_STATUS_REG # Restore the status register -END(MachTLBRead) - -/*-------------------------------------------------------------------------- - * - * MachTLBGetPID -- - * - * MachTLBGetPID() - * - * Results: - * Returns the current TLB pid reg. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ -LEAF(MachTLBGetPID) - mfc0 v0, MACH_COP_0_TLB_HI # get PID - nop - and v0, v0, VMMACH_TLB_PID # mask off PID - j ra - srl v0, v0, VMMACH_TLB_PID_SHIFT # put PID in right spot -END(MachTLBGetPID) - -/* - * Return the current value of the cause register. - */ -LEAF(MachGetCauseReg) - mfc0 v0, MACH_COP_0_CAUSE_REG - j ra - nop -END(MachGetCauseReg) -#endif /* DEBUG */ - -/*---------------------------------------------------------------------------- - * - * MachSwitchFPState -- - * - * Save the current state into 'from' and restore it from 'to'. - * - * MachSwitchFPState(from, to) - * struct proc *from; - * struct user *to; - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ -LEAF(MachSwitchFPState) - mfc0 t1, MACH_COP_0_STATUS_REG # Save old SR - li t0, MACH_SR_COP_1_BIT # enable the coprocessor - mtc0 t0, MACH_COP_0_STATUS_REG - - beq a0, zero, 1f # skip save if NULL pointer - nop -/* - * First read out the status register to make sure that all FP operations - * have completed. - */ - lw a0, P_ADDR(a0) # get pointer to pcb for proc - cfc1 t0, MACH_FPC_CSR # stall til FP done - cfc1 t0, MACH_FPC_CSR # now get status - li t3, ~MACH_SR_COP_1_BIT - lw t2, U_PCB_REGS+(PS * 4)(a0) # get CPU status register - sw t0, U_PCB_FPREGS+(32 * 4)(a0) # save FP status - and t2, t2, t3 # clear COP_1 enable bit - sw t2, U_PCB_REGS+(PS * 4)(a0) # save new status register -/* - * Save the floating point registers. - */ - swc1 $f0, U_PCB_FPREGS+(0 * 4)(a0) - swc1 $f1, U_PCB_FPREGS+(1 * 4)(a0) - swc1 $f2, U_PCB_FPREGS+(2 * 4)(a0) - swc1 $f3, U_PCB_FPREGS+(3 * 4)(a0) - swc1 $f4, U_PCB_FPREGS+(4 * 4)(a0) - swc1 $f5, U_PCB_FPREGS+(5 * 4)(a0) - swc1 $f6, U_PCB_FPREGS+(6 * 4)(a0) - swc1 $f7, U_PCB_FPREGS+(7 * 4)(a0) - swc1 $f8, U_PCB_FPREGS+(8 * 4)(a0) - swc1 $f9, U_PCB_FPREGS+(9 * 4)(a0) - swc1 $f10, U_PCB_FPREGS+(10 * 4)(a0) - swc1 $f11, U_PCB_FPREGS+(11 * 4)(a0) - swc1 $f12, U_PCB_FPREGS+(12 * 4)(a0) - swc1 $f13, U_PCB_FPREGS+(13 * 4)(a0) - swc1 $f14, U_PCB_FPREGS+(14 * 4)(a0) - swc1 $f15, U_PCB_FPREGS+(15 * 4)(a0) - swc1 $f16, U_PCB_FPREGS+(16 * 4)(a0) - swc1 $f17, U_PCB_FPREGS+(17 * 4)(a0) - swc1 $f18, U_PCB_FPREGS+(18 * 4)(a0) - swc1 $f19, U_PCB_FPREGS+(19 * 4)(a0) - swc1 $f20, U_PCB_FPREGS+(20 * 4)(a0) - swc1 $f21, U_PCB_FPREGS+(21 * 4)(a0) - swc1 $f22, U_PCB_FPREGS+(22 * 4)(a0) - swc1 $f23, U_PCB_FPREGS+(23 * 4)(a0) - swc1 $f24, U_PCB_FPREGS+(24 * 4)(a0) - swc1 $f25, U_PCB_FPREGS+(25 * 4)(a0) - swc1 $f26, U_PCB_FPREGS+(26 * 4)(a0) - swc1 $f27, U_PCB_FPREGS+(27 * 4)(a0) - swc1 $f28, U_PCB_FPREGS+(28 * 4)(a0) - swc1 $f29, U_PCB_FPREGS+(29 * 4)(a0) - swc1 $f30, U_PCB_FPREGS+(30 * 4)(a0) - swc1 $f31, U_PCB_FPREGS+(31 * 4)(a0) - -1: -/* - * Restore the floating point registers. - */ - lw t0, U_PCB_FPREGS+(32 * 4)(a1) # get status register - lwc1 $f0, U_PCB_FPREGS+(0 * 4)(a1) - lwc1 $f1, U_PCB_FPREGS+(1 * 4)(a1) - lwc1 $f2, U_PCB_FPREGS+(2 * 4)(a1) - lwc1 $f3, U_PCB_FPREGS+(3 * 4)(a1) - lwc1 $f4, U_PCB_FPREGS+(4 * 4)(a1) - lwc1 $f5, U_PCB_FPREGS+(5 * 4)(a1) - lwc1 $f6, U_PCB_FPREGS+(6 * 4)(a1) - lwc1 $f7, U_PCB_FPREGS+(7 * 4)(a1) - lwc1 $f8, U_PCB_FPREGS+(8 * 4)(a1) - lwc1 $f9, U_PCB_FPREGS+(9 * 4)(a1) - lwc1 $f10, U_PCB_FPREGS+(10 * 4)(a1) - lwc1 $f11, U_PCB_FPREGS+(11 * 4)(a1) - lwc1 $f12, U_PCB_FPREGS+(12 * 4)(a1) - lwc1 $f13, U_PCB_FPREGS+(13 * 4)(a1) - lwc1 $f14, U_PCB_FPREGS+(14 * 4)(a1) - lwc1 $f15, U_PCB_FPREGS+(15 * 4)(a1) - lwc1 $f16, U_PCB_FPREGS+(16 * 4)(a1) - lwc1 $f17, U_PCB_FPREGS+(17 * 4)(a1) - lwc1 $f18, U_PCB_FPREGS+(18 * 4)(a1) - lwc1 $f19, U_PCB_FPREGS+(19 * 4)(a1) - lwc1 $f20, U_PCB_FPREGS+(20 * 4)(a1) - lwc1 $f21, U_PCB_FPREGS+(21 * 4)(a1) - lwc1 $f22, U_PCB_FPREGS+(22 * 4)(a1) - lwc1 $f23, U_PCB_FPREGS+(23 * 4)(a1) - lwc1 $f24, U_PCB_FPREGS+(24 * 4)(a1) - lwc1 $f25, U_PCB_FPREGS+(25 * 4)(a1) - lwc1 $f26, U_PCB_FPREGS+(26 * 4)(a1) - lwc1 $f27, U_PCB_FPREGS+(27 * 4)(a1) - lwc1 $f28, U_PCB_FPREGS+(28 * 4)(a1) - lwc1 $f29, U_PCB_FPREGS+(29 * 4)(a1) - lwc1 $f30, U_PCB_FPREGS+(30 * 4)(a1) - lwc1 $f31, U_PCB_FPREGS+(31 * 4)(a1) - - and t0, t0, ~MACH_FPC_EXCEPTION_BITS - ctc1 t0, MACH_FPC_CSR - nop - - mtc0 t1, MACH_COP_0_STATUS_REG # Restore the status register. - j ra - nop -END(MachSwitchFPState) - -/*---------------------------------------------------------------------------- - * - * MachSaveCurFPState -- - * - * Save the current floating point coprocessor state. - * - * MachSaveCurFPState(p) - * struct proc *p; - * - * Results: - * None. - * - * Side effects: - * machFPCurProcPtr is cleared. - * - *---------------------------------------------------------------------------- - */ -LEAF(MachSaveCurFPState) - lw a0, P_ADDR(a0) # get pointer to pcb for proc - mfc0 t1, MACH_COP_0_STATUS_REG # Disable interrupts and - li t0, MACH_SR_COP_1_BIT # enable the coprocessor - mtc0 t0, MACH_COP_0_STATUS_REG - sw zero, machFPCurProcPtr # indicate state has been saved -/* - * First read out the status register to make sure that all FP operations - * have completed. - */ - lw t2, U_PCB_REGS+(PS * 4)(a0) # get CPU status register - li t3, ~MACH_SR_COP_1_BIT - and t2, t2, t3 # clear COP_1 enable bit - cfc1 t0, MACH_FPC_CSR # stall til FP done - cfc1 t0, MACH_FPC_CSR # now get status - sw t2, U_PCB_REGS+(PS * 4)(a0) # save new status register - sw t0, U_PCB_FPREGS+(32 * 4)(a0) # save FP status -/* - * Save the floating point registers. - */ - swc1 $f0, U_PCB_FPREGS+(0 * 4)(a0) - swc1 $f1, U_PCB_FPREGS+(1 * 4)(a0) - swc1 $f2, U_PCB_FPREGS+(2 * 4)(a0) - swc1 $f3, U_PCB_FPREGS+(3 * 4)(a0) - swc1 $f4, U_PCB_FPREGS+(4 * 4)(a0) - swc1 $f5, U_PCB_FPREGS+(5 * 4)(a0) - swc1 $f6, U_PCB_FPREGS+(6 * 4)(a0) - swc1 $f7, U_PCB_FPREGS+(7 * 4)(a0) - swc1 $f8, U_PCB_FPREGS+(8 * 4)(a0) - swc1 $f9, U_PCB_FPREGS+(9 * 4)(a0) - swc1 $f10, U_PCB_FPREGS+(10 * 4)(a0) - swc1 $f11, U_PCB_FPREGS+(11 * 4)(a0) - swc1 $f12, U_PCB_FPREGS+(12 * 4)(a0) - swc1 $f13, U_PCB_FPREGS+(13 * 4)(a0) - swc1 $f14, U_PCB_FPREGS+(14 * 4)(a0) - swc1 $f15, U_PCB_FPREGS+(15 * 4)(a0) - swc1 $f16, U_PCB_FPREGS+(16 * 4)(a0) - swc1 $f17, U_PCB_FPREGS+(17 * 4)(a0) - swc1 $f18, U_PCB_FPREGS+(18 * 4)(a0) - swc1 $f19, U_PCB_FPREGS+(19 * 4)(a0) - swc1 $f20, U_PCB_FPREGS+(20 * 4)(a0) - swc1 $f21, U_PCB_FPREGS+(21 * 4)(a0) - swc1 $f22, U_PCB_FPREGS+(22 * 4)(a0) - swc1 $f23, U_PCB_FPREGS+(23 * 4)(a0) - swc1 $f24, U_PCB_FPREGS+(24 * 4)(a0) - swc1 $f25, U_PCB_FPREGS+(25 * 4)(a0) - swc1 $f26, U_PCB_FPREGS+(26 * 4)(a0) - swc1 $f27, U_PCB_FPREGS+(27 * 4)(a0) - swc1 $f28, U_PCB_FPREGS+(28 * 4)(a0) - swc1 $f29, U_PCB_FPREGS+(29 * 4)(a0) - swc1 $f30, U_PCB_FPREGS+(30 * 4)(a0) - swc1 $f31, U_PCB_FPREGS+(31 * 4)(a0) - - mtc0 t1, MACH_COP_0_STATUS_REG # Restore the status register. - j ra - nop -END(MachSaveCurFPState) - -/*---------------------------------------------------------------------------- - * - * MachFPInterrupt -- - * - * Handle a floating point interrupt. - * - * MachFPInterrupt(statusReg, causeReg, pc) - * unsigned statusReg; - * unsigned causeReg; - * unsigned pc; - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ -NON_LEAF(MachFPInterrupt, STAND_FRAME_SIZE, ra) - subu sp, sp, STAND_FRAME_SIZE - mfc0 t0, MACH_COP_0_STATUS_REG - sw ra, STAND_RA_OFFSET(sp) - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - - or t1, t0, MACH_SR_COP_1_BIT - mtc0 t1, MACH_COP_0_STATUS_REG - nop - nop - cfc1 t1, MACH_FPC_CSR # stall til FP done - cfc1 t1, MACH_FPC_CSR # now get status - nop - sll t2, t1, (31 - 17) # unimplemented operation? - bgez t2, 3f # no, normal trap - nop -/* - * We got an unimplemented operation trap so - * fetch the instruction, compute the next PC and emulate the instruction. - */ - bgez a1, 1f # Check the branch delay bit. - nop -/* - * The instruction is in the branch delay slot so the branch will have to - * be emulated to get the resulting PC. - */ - sw a2, STAND_FRAME_SIZE + 8(sp) - li a0, UADDR+U_PCB_REGS # first arg is ptr to CPU registers - move a1, a2 # second arg is instruction PC - move a2, t1 # third arg is floating point CSR - jal MachEmulateBranch # compute PC after branch - move a3, zero # fourth arg is FALSE -/* - * Now load the floating-point instruction in the branch delay slot - * to be emulated. - */ - lw a2, STAND_FRAME_SIZE + 8(sp) # restore EXC pc - b 2f - lw a0, 4(a2) # a0 = coproc instruction -/* - * This is not in the branch delay slot so calculate the resulting - * PC (epc + 4) into v0 and continue to MachEmulateFP(). - */ -1: - lw a0, 0(a2) # a0 = coproc instruction - addu v0, a2, 4 # v0 = next pc -2: - sw v0, UADDR+U_PCB_REGS+(PC * 4) # save new pc -/* - * Check to see if the instruction to be emulated is a floating-point - * instruction. - */ - srl a3, a0, MACH_OPCODE_SHIFT - beq a3, MACH_OPCODE_C1, 4f # this should never fail -/* - * Send a floating point exception signal to the current process. - */ -3: - lw a0, curproc # get current process - cfc1 a2, MACH_FPC_CSR # code = FP execptions - ctc1 zero, MACH_FPC_CSR # Clear exceptions - jal trapsignal - li a1, SIGFPE - b FPReturn - nop - -/* - * Finally, we can call MachEmulateFP() where a0 is the instruction to emulate. - */ -4: - jal MachEmulateFP - nop - -/* - * Turn off the floating point coprocessor and return. - */ -FPReturn: - mfc0 t0, MACH_COP_0_STATUS_REG - lw ra, STAND_RA_OFFSET(sp) - and t0, t0, ~MACH_SR_COP_1_BIT - mtc0 t0, MACH_COP_0_STATUS_REG - j ra - addu sp, sp, STAND_FRAME_SIZE -END(MachFPInterrupt) - -/*---------------------------------------------------------------------------- - * - * MachConfigCache -- - * - * Size the caches. - * NOTE: should only be called from mach_init(). - * - * Results: - * None. - * - * Side effects: - * The size of the data cache is stored into machDataCacheSize and the - * size of instruction cache is stored into machInstCacheSize. - * - *---------------------------------------------------------------------------- - */ -NON_LEAF(MachConfigCache, STAND_FRAME_SIZE, ra) - subu sp, sp, STAND_FRAME_SIZE - sw ra, STAND_RA_OFFSET(sp) # Save return address. - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts. - la v0, 1f - or v0, MACH_UNCACHED_MEMORY_ADDR # Run uncached. - j v0 - nop -1: -/* - * This works because jal doesn't change pc[31..28] and the - * linker still thinks SizeCache is in the cached region so it computes - * the correct address without complaining. - */ - jal SizeCache # Get the size of the d-cache. - nop - sw v0, machDataCacheSize - nop # Make sure sw out of pipe - nop - nop - nop - li v0, MACH_SR_SWAP_CACHES # Swap caches - mtc0 v0, MACH_COP_0_STATUS_REG - nop # Insure caches stable - nop - nop - nop - jal SizeCache # Get the size of the i-cache. - nop - mtc0 zero, MACH_COP_0_STATUS_REG # Swap back caches and enable. - nop - nop - nop - nop - sw v0, machInstCacheSize - la t0, 1f - j t0 # Back to cached mode - nop -1: - lw ra, STAND_RA_OFFSET(sp) # Restore return addr - addu sp, sp, STAND_FRAME_SIZE # Restore sp. - j ra - nop -END(MachConfigCache) - -/*---------------------------------------------------------------------------- - * - * SizeCache -- - * - * Get the size of the cache. - * - * Results: - * The size of the cache. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------------- - */ -LEAF(SizeCache) - mfc0 t0, MACH_COP_0_STATUS_REG # Save the current status reg. - nop - or v0, t0, MACH_SR_ISOL_CACHES # Isolate the caches. - nop # Make sure no stores in pipe - mtc0 v0, MACH_COP_0_STATUS_REG - nop # Make sure isolated - nop - nop -/* - * Clear cache size boundaries. - */ - li v0, MACH_MIN_CACHE_SIZE - li v1, MACH_CACHED_MEMORY_ADDR - li t2, MACH_MAX_CACHE_SIZE -1: - addu t1, v0, v1 # Compute address to clear - sw zero, 0(t1) # Clear cache memory - bne v0, t2, 1b - sll v0, v0, 1 - - li v0, -1 - sw v0, 0(v1) # Store marker in cache - li v0, MACH_MIN_CACHE_SIZE -2: - addu t1, v0, v1 # Compute address - lw t3, 0(t1) # Look for marker - nop - bne t3, zero, 3f # Found marker. - nop - bne v0, t2, 2b # keep looking - sll v0, v0, 1 # cache size * 2 - - move v0, zero # must be no cache -3: - mtc0 t0, MACH_COP_0_STATUS_REG - nop # Make sure unisolated - nop - nop - nop - j ra - nop -END(SizeCache) - -/*---------------------------------------------------------------------------- - * - * MachFlushCache -- - * - * Flush the caches. - * - * Results: - * None. - * - * Side effects: - * The contents of the caches is flushed. - * - *---------------------------------------------------------------------------- - */ -LEAF(MachFlushCache) - lw t1, machInstCacheSize # Must load before isolating - lw t2, machDataCacheSize # Must load before isolating - mfc0 t3, MACH_COP_0_STATUS_REG # Save the status register. - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts. - la v0, 1f - or v0, MACH_UNCACHED_MEMORY_ADDR # Run uncached. - j v0 - nop -/* - * Flush the instruction cache. - */ -1: - li v0, MACH_SR_ISOL_CACHES | MACH_SR_SWAP_CACHES - mtc0 v0, MACH_COP_0_STATUS_REG # Isolate and swap caches. - li t0, MACH_UNCACHED_MEMORY_ADDR - subu t0, t0, t1 - li t1, MACH_UNCACHED_MEMORY_ADDR - la v0, 1f # Run cached - j v0 - nop -1: - addu t0, t0, 4 - bne t0, t1, 1b - sb zero, -4(t0) - - la v0, 1f - or v0, MACH_UNCACHED_MEMORY_ADDR - j v0 # Run uncached - nop -/* - * Flush the data cache. - */ -1: - li v0, MACH_SR_ISOL_CACHES - mtc0 v0, MACH_COP_0_STATUS_REG # Isolate and swap back caches - li t0, MACH_UNCACHED_MEMORY_ADDR - subu t0, t0, t2 - la v0, 1f - j v0 # Back to cached mode - nop -1: - addu t0, t0, 4 - bne t0, t1, 1b - sb zero, -4(t0) - - nop # Insure isolated stores - nop # out of pipe. - nop - nop - mtc0 t3, MACH_COP_0_STATUS_REG # Restore status reg. - nop # Insure cache unisolated. - nop - nop - nop - j ra - nop -END(MachFlushCache) - -/*---------------------------------------------------------------------------- - * - * MachFlushICache -- - * - * void MachFlushICache(addr, len) - * vm_offset_t addr, len; - * - * Flush instruction cache for range of addr to addr + len - 1. - * The address can be any valid address so long as no TLB misses occur. - * - * Results: - * None. - * - * Side effects: - * The contents of the cache is flushed. - * - *---------------------------------------------------------------------------- - */ -LEAF(MachFlushICache) - mfc0 t0, MACH_COP_0_STATUS_REG # Save SR - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts. - - la v1, 1f - or v1, MACH_UNCACHED_MEMORY_ADDR # Run uncached. - j v1 - nop -1: - bc0f 1b # make sure stores are complete - li v1, MACH_SR_ISOL_CACHES | MACH_SR_SWAP_CACHES - mtc0 v1, MACH_COP_0_STATUS_REG - nop - addu a1, a1, a0 # compute ending address -1: - addu a0, a0, 4 - bne a0, a1, 1b - sb zero, -4(a0) - - mtc0 t0, MACH_COP_0_STATUS_REG # enable interrupts - j ra # return and run cached - nop -END(MachFlushICache) - -/*---------------------------------------------------------------------------- - * - * MachFlushDCache -- - * - * void MachFlushDCache(addr, len) - * vm_offset_t addr, len; - * - * Flush data cache for range of addr to addr + len - 1. - * The address can be any valid address so long as no TLB misses occur. - * (Be sure to use cached K0SEG kernel addresses) - * Results: - * None. - * - * Side effects: - * The contents of the cache is flushed. - * - *---------------------------------------------------------------------------- - */ -LEAF(MachFlushDCache) - mfc0 t0, MACH_COP_0_STATUS_REG # Save SR - mtc0 zero, MACH_COP_0_STATUS_REG # Disable interrupts. - - la v1, 1f - or v1, MACH_UNCACHED_MEMORY_ADDR # Run uncached. - j v1 - nop -1: - bc0f 1b # make sure stores are complete - li v1, MACH_SR_ISOL_CACHES - mtc0 v1, MACH_COP_0_STATUS_REG - nop - addu a1, a1, a0 # compute ending address -1: - addu a0, a0, 4 - bne a0, a1, 1b - sb zero, -4(a0) - - mtc0 t0, MACH_COP_0_STATUS_REG # enable interrupts - j ra # return and run cached - nop -END(MachFlushDCache) - -#ifdef KADB -/* - * Read a long and return it. - * Note: addresses can be unaligned! - * - * long -L* kdbpeek(addr) -L* caddt_t addr; -L* { -L* return (*(long *)addr); -L* } - */ -LEAF(kdbpeek) - li v0, KADBERR - sw v0, UADDR+U_PCB_ONFAULT - and v0, a0, 3 # unaligned address? - bne v0, zero, 1f - nop - b 2f - lw v0, (a0) # aligned access -1: - lwr v0, 0(a0) # get next 4 bytes (unaligned) - lwl v0, 3(a0) -2: - j ra # made it w/o errors - sw zero, UADDR+U_PCB_ONFAULT -kadberr: - li v0, 1 # trap sends us here - sw v0, kdbmkfault - j ra - nop -END(kdbpeek) - -/* - * Write a long to 'addr'. - * Note: addresses can be unaligned! - * -L* void -L* kdbpoke(addr, value) -L* caddt_t addr; -L* long value; -L* { -L* *(long *)addr = value; -L* } - */ -LEAF(kdbpoke) - li v0, KADBERR - sw v0, UADDR+U_PCB_ONFAULT - and v0, a0, 3 # unaligned address? - bne v0, zero, 1f - nop - b 2f - sw a1, (a0) # aligned access -1: - swr a1, 0(a0) # store next 4 bytes (unaligned) - swl a1, 3(a0) - and a0, a0, ~3 # align address for cache flush -2: - sw zero, UADDR+U_PCB_ONFAULT - b MachFlushICache # flush instruction cache - li a1, 8 -END(kdbpoke) - -/* - * Save registers and state so we can do a 'kdbreset' (like longjmp) later. - * Always returns zero. - * -L* int kdb_savearea[11]; -L* -L* int -L* kdbsetexit() -L* { -L* kdb_savearea[0] = 0; -L* return (0); -L* } - */ - .comm kdb_savearea, (11 * 4) - -LEAF(kdbsetexit) - la a0, kdb_savearea - sw s0, 0(a0) - sw s1, 4(a0) - sw s2, 8(a0) - sw s3, 12(a0) - sw s4, 16(a0) - sw s5, 20(a0) - sw s6, 24(a0) - sw s7, 28(a0) - sw sp, 32(a0) - sw s8, 36(a0) - sw ra, 40(a0) - j ra - move v0, zero -END(kdbsetexit) - -/* - * Restore registers and state (like longjmp) and return x. - * -L* int -L* kdbreset(x) -L* { -L* return (x); -L* } - */ -LEAF(kdbreset) - la v0, kdb_savearea - lw ra, 40(v0) - lw s0, 0(v0) - lw s1, 4(v0) - lw s2, 8(v0) - lw s3, 12(v0) - lw s4, 16(v0) - lw s5, 20(v0) - lw s6, 24(v0) - lw s7, 28(v0) - lw sp, 32(v0) - lw s8, 36(v0) - j ra - move v0, a0 -END(kdbreset) - -/* - * Trap into the debugger. - * -L* void -L* kdbpanic() -L* { -L* } - */ -LEAF(kdbpanic) - break MACH_BREAK_KDB_VAL - j ra - nop -END(kdbpanic) -#endif /* KADB */ - -#ifdef DEBUG -LEAF(cpu_getregs) /* XXX */ - sw sp, 0(a0) - la v0, cpu_getregs - sw v0, 4(a0) - sw ra, 8(a0) - sw a0, 12(a0) - sw a1, 16(a0) - sw a2, 20(a0) - sw a3, 24(a0) - j ra - sw s8, 28(a0) -END(cpu_getregs) -#endif /* DEBUG */ diff --git a/sys/arch/pmax/pmax/trap.c.sav b/sys/arch/pmax/pmax/trap.c.sav deleted file mode 100644 index 0cd4dc2266ef..000000000000 --- a/sys/arch/pmax/pmax/trap.c.sav +++ /dev/null @@ -1,1821 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department and Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah Hdr: trap.c 1.32 91/04/06 - * from: @(#)trap.c 7.14 (Berkeley) 3/8/93 - * $Id: trap.c.sav,v 1.1.1.1 1993/10/12 03:22:36 deraadt Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef KTRACE -#include -#endif -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -/* - * This is a kludge to allow X windows to work. - */ -#define X_KLUGE - -#ifdef X_KLUGE -#define USER_MAP_ADDR 0x4000 -#define NPTES 550 -static pt_entry_t UserMapPtes[NPTES]; -static unsigned nUserMapPtes; -static pid_t UserMapPid; -#endif - -struct proc *machFPCurProcPtr; /* pointer to last proc to use FP */ - -extern void MachKernGenException(); -extern void MachUserGenException(); -extern void MachKernIntr(); -extern void MachUserIntr(); -extern void MachTLBModException(); -extern void MachTLBMissException(); -extern unsigned MachEmulateBranch(); - -void (*machExceptionTable[])() = { -/* - * The kernel exception handlers. - */ - MachKernIntr, /* external interrupt */ - MachKernGenException, /* TLB modification */ - MachTLBMissException, /* TLB miss (load or instr. fetch) */ - MachTLBMissException, /* TLB miss (store) */ - MachKernGenException, /* address error (load or I-fetch) */ - MachKernGenException, /* address error (store) */ - MachKernGenException, /* bus error (I-fetch) */ - MachKernGenException, /* bus error (load or store) */ - MachKernGenException, /* system call */ - MachKernGenException, /* breakpoint */ - MachKernGenException, /* reserved instruction */ - MachKernGenException, /* coprocessor unusable */ - MachKernGenException, /* arithmetic overflow */ - MachKernGenException, /* reserved */ - MachKernGenException, /* reserved */ - MachKernGenException, /* reserved */ -/* - * The user exception handlers. - */ - MachUserIntr, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, -}; - -char *trap_type[] = { - "external interrupt", - "TLB modification", - "TLB miss (load or instr. fetch)", - "TLB miss (store)", - "address error (load or I-fetch)", - "address error (store)", - "bus error (I-fetch)", - "bus error (load or store)", - "system call", - "breakpoint", - "reserved instruction", - "coprocessor unusable", - "arithmetic overflow", - "reserved 13", - "reserved 14", - "reserved 15", -}; - -#ifdef DEBUG -#define TRAPSIZE 10 -struct trapdebug { /* trap history buffer for debugging */ - u_int status; - u_int cause; - u_int vadr; - u_int pc; - u_int ra; - u_int code; -} trapdebug[TRAPSIZE], *trp = trapdebug; -#endif - -static void pmax_errintr(); -static void kn02_errintr(), kn02ba_errintr(); -#ifdef DS5000_240 -static void kn03_errintr(); -#endif -static unsigned kn02ba_recover_erradr(); -extern tc_option_t tc_slot_info[TC_MAX_LOGICAL_SLOTS]; -extern u_long kmin_tc3_imask, xine_tc3_imask; -extern const struct callback *callv; -#ifdef DS5000_240 -extern u_long kn03_tc3_imask; -#endif -int (*pmax_hardware_intr)() = (int (*)())0; -extern volatile struct chiptime *Mach_clock_addr; - -/* - * Handle an exception. - * Called from MachKernGenException() or MachUserGenException() - * when a processor trap occurs. - * In the case of a kernel trap, we return the pc where to resume if - * ((struct pcb *)UADDR)->pcb_onfault is set, otherwise, return old pc. - */ -unsigned -trap(statusReg, causeReg, vadr, pc, args) - unsigned statusReg; /* status register at time of the exception */ - unsigned causeReg; /* cause register at time of exception */ - unsigned vadr; /* address (if any) the fault occured on */ - unsigned pc; /* program counter where to continue */ -{ - register int type, i; - unsigned ucode = 0; - register struct proc *p = curproc; - u_quad_t sticks; - vm_prot_t ftype; - extern unsigned onfault_table[]; - -#ifdef DEBUG - trp->status = statusReg; - trp->cause = causeReg; - trp->vadr = vadr; - trp->pc = pc; - trp->ra = !USERMODE(statusReg) ? ((int *)&args)[19] : - p->p_md.md_regs[RA]; - trp->code = 0; - if (++trp == &trapdebug[TRAPSIZE]) - trp = trapdebug; -#endif - - cnt.v_trap++; - type = (causeReg & MACH_CR_EXC_CODE) >> MACH_CR_EXC_CODE_SHIFT; - if (USERMODE(statusReg)) { - type |= T_USER; - sticks = p->p_sticks; - } - - /* - * Enable hardware interrupts if they were on before. - * We only respond to software interrupts when returning to user mode. - */ - if (statusReg & MACH_SR_INT_ENA_PREV) - splx((statusReg & MACH_HARD_INT_MASK) | MACH_SR_INT_ENA_CUR); - - switch (type) { - case T_TLB_MOD: - /* check for kernel address */ - if ((int)vadr < 0) { - register pt_entry_t *pte; - register unsigned entry; -#ifndef ATTR - register vm_offset_t pa; -#endif - - pte = kvtopte(vadr); - entry = pte->pt_entry; - if (entry & PG_RO) { - /* write to read only page in the kernel */ - ftype = VM_PROT_WRITE; - goto kernel_fault; - } - entry |= PG_M; - pte->pt_entry = entry; - vadr &= PG_FRAME; - printf("trap: TLBupdate hi %x lo %x i %x\n", vadr, - entry, MachTLBUpdate(vadr, entry)); /* XXX */ -#ifdef ATTR - pmap_attributes[atop(entry - KERNBASE)] |= PMAP_ATTR_MOD; -#else - pa = entry & PG_FRAME; - if (!IS_VM_PHYSADDR(pa)) - panic("trap: kmod"); - PHYS_TO_VM_PAGE(pa)->flags &= ~PG_CLEAN; -#endif - return (pc); - } - /* FALLTHROUGH */ - - case T_TLB_MOD+T_USER: - { - pmap_hash_t hp; -#ifndef ATTR - vm_offset_t pa; -#endif -#ifdef DIAGNOSTIC - extern pmap_hash_t zero_pmap_hash; - extern pmap_t cur_pmap; - - if (cur_pmap->pm_hash == zero_pmap_hash || - cur_pmap->pm_hash == (pmap_hash_t)0) - panic("tlbmod"); -#endif - hp = &((pmap_hash_t)PMAP_HASH_UADDR)[PMAP_HASH(vadr)]; - if (((hp->pmh_pte[0].high ^ vadr) & ~PGOFSET) == 0) - i = 0; - else if (((hp->pmh_pte[1].high ^ vadr) & ~PGOFSET) == 0) - i = 1; - else - panic("trap: tlb umod not found"); - if (hp->pmh_pte[i].low & PG_RO) { - ftype = VM_PROT_WRITE; - goto dofault; - } - hp->pmh_pte[i].low |= PG_M; - printf("trap: TLBupdate hi %x lo %x i %x\n", - hp->pmh_pte[i].high, hp->pmh_pte[i].low, - MachTLBUpdate(hp->pmh_pte[i].high, hp->pmh_pte[i].low)); /* XXX */ -#ifdef ATTR - pmap_attributes[atop(hp->pmh_pte[i].low - KERNBASE)] |= - PMAP_ATTR_MOD; -#else - pa = hp->pmh_pte[i].low & PG_FRAME; - if (!IS_VM_PHYSADDR(pa)) - panic("trap: umod"); - PHYS_TO_VM_PAGE(pa)->flags &= ~PG_CLEAN; -#endif - if (!USERMODE(statusReg)) - return (pc); - goto out; - } - - case T_TLB_LD_MISS: - case T_TLB_ST_MISS: - ftype = (type == T_TLB_ST_MISS) ? VM_PROT_WRITE : VM_PROT_READ; - /* check for kernel address */ - if ((int)vadr < 0) { - register vm_offset_t va; - int rv; - - kernel_fault: - va = trunc_page((vm_offset_t)vadr); - rv = vm_fault(kernel_map, va, ftype, FALSE); - if (rv == KERN_SUCCESS) - return (pc); - if (i = ((struct pcb *)UADDR)->pcb_onfault) { - ((struct pcb *)UADDR)->pcb_onfault = 0; - return (onfault_table[i]); - } - goto err; - } - /* - * It is an error for the kernel to access user space except - * through the copyin/copyout routines. - */ - if ((i = ((struct pcb *)UADDR)->pcb_onfault) == 0) - goto err; - /* check for fuswintr() or suswintr() getting a page fault */ - if (i == 4) - return (onfault_table[i]); - goto dofault; - - case T_TLB_LD_MISS+T_USER: - ftype = VM_PROT_READ; - goto dofault; - - case T_TLB_ST_MISS+T_USER: - ftype = VM_PROT_WRITE; - dofault: - { - register vm_offset_t va; - register struct vmspace *vm = p->p_vmspace; - register vm_map_t map = &vm->vm_map; - int rv; - -#ifdef X_KLUGE - if (p->p_pid == UserMapPid && - (va = pmax_btop(vadr - USER_MAP_ADDR)) < nUserMapPtes) { - register pt_entry_t *pte; - - pte = &UserMapPtes[va]; - MachTLBWriteRandom((vadr & PG_FRAME) | - (vm->vm_pmap.pm_tlbpid << VMMACH_TLB_PID_SHIFT), - pte->pt_entry); - return (pc); - } -#endif - va = trunc_page((vm_offset_t)vadr); - rv = vm_fault(map, va, ftype, FALSE); - if (rv != KERN_SUCCESS) { - printf("vm_fault(%x, %x, %x, 0) -> %x ADR %x PC %x RA %x\n", - map, va, ftype, rv, vadr, pc, - !USERMODE(statusReg) ? ((int *)&args)[19] : - p->p_md.md_regs[RA]); /* XXX */ - printf("\tpid %d %s PC %x RA %x SP %x\n", p->p_pid, - p->p_comm, p->p_md.md_regs[PC], - p->p_md.md_regs[RA], - p->p_md.md_regs[SP]); /* XXX */ - } - /* - * If this was a stack access we keep track of the maximum - * accessed stack size. Also, if vm_fault gets a protection - * failure it is due to accessing the stack region outside - * the current limit and we need to reflect that as an access - * error. - */ - if ((caddr_t)va >= vm->vm_maxsaddr) { - if (rv == KERN_SUCCESS) { - unsigned nss; - - nss = clrnd(btoc(USRSTACK-(unsigned)va)); - if (nss > vm->vm_ssize) - vm->vm_ssize = nss; - } else if (rv == KERN_PROTECTION_FAILURE) - rv = KERN_INVALID_ADDRESS; - } - if (rv == KERN_SUCCESS) { - if (!USERMODE(statusReg)) - return (pc); - goto out; - } - if (!USERMODE(statusReg)) { - if (i = ((struct pcb *)UADDR)->pcb_onfault) { - ((struct pcb *)UADDR)->pcb_onfault = 0; - return (onfault_table[i]); - } - goto err; - } - ucode = vadr; - i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; - break; - } - - case T_ADDR_ERR_LD+T_USER: /* misaligned or kseg access */ - case T_ADDR_ERR_ST+T_USER: /* misaligned or kseg access */ - case T_BUS_ERR_IFETCH+T_USER: /* BERR asserted to cpu */ - case T_BUS_ERR_LD_ST+T_USER: /* BERR asserted to cpu */ - i = SIGSEGV; - break; - - case T_SYSCALL+T_USER: - { - register int *locr0 = p->p_md.md_regs; - register struct sysent *callp; - unsigned int code; - int numsys; - struct args { - int i[8]; - } args; - int rval[2]; - struct sysent *systab; - extern int nsysent; -#ifdef ULTRIXCOMPAT - extern struct sysent ultrixsysent[]; - extern int ultrixnsysent; -#endif - - cnt.v_syscall++; - /* compute next PC after syscall instruction */ - if ((int)causeReg < 0) - locr0[PC] = MachEmulateBranch(locr0, pc, 0, 0); - else - locr0[PC] += 4; - systab = sysent; - numsys = nsysent; -#ifdef ULTRIXCOMPAT - if (p->p_md.md_flags & MDP_ULTRIX) { - systab = ultrixsysent; - numsys = ultrixnsysent; - } -#endif - code = locr0[V0]; - switch (code) { - case SYS_indir: - /* - * Code is first argument, followed by actual args. - */ - code = locr0[A0]; - if (code >= numsys) - callp = &systab[SYS_indir]; /* (illegal) */ - else - callp = &systab[code]; - i = callp->sy_narg; - args.i[0] = locr0[A1]; - args.i[1] = locr0[A2]; - args.i[2] = locr0[A3]; - if (i > 3) { - i = copyin((caddr_t)(locr0[SP] + - 4 * sizeof(int)), - (caddr_t)&args.i[3], - (u_int)(i - 3) * sizeof(int)); - if (i) { - locr0[V0] = i; - locr0[A3] = 1; -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p->p_tracep, code, - callp->sy_narg, args.i); -#endif - goto done; - } - } - break; - - case SYS___indir: - /* - * Like indir, but code is a quad, so as to maintain - * quad alignment for the rest of the arguments. - */ - code = locr0[A0 + _QUAD_LOWWORD]; - if (code >= numsys) - callp = &systab[SYS_indir]; /* (illegal) */ - else - callp = &systab[code]; - i = callp->sy_narg; - args.i[0] = locr0[A2]; - args.i[1] = locr0[A3]; - if (i > 2) { - i = copyin((caddr_t)(locr0[SP] + - 4 * sizeof(int)), - (caddr_t)&args.i[2], - (u_int)(i - 2) * sizeof(int)); - if (i) { - locr0[V0] = i; - locr0[A3] = 1; -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p->p_tracep, code, - callp->sy_narg, args.i); -#endif - goto done; - } - } - break; - - default: - if (code >= numsys) - callp = &systab[SYS_indir]; /* (illegal) */ - else - callp = &systab[code]; - i = callp->sy_narg; - args.i[0] = locr0[A0]; - args.i[1] = locr0[A1]; - args.i[2] = locr0[A2]; - args.i[3] = locr0[A3]; - if (i > 4) { - i = copyin((caddr_t)(locr0[SP] + - 4 * sizeof(int)), - (caddr_t)&args.i[4], - (u_int)(i - 4) * sizeof(int)); - if (i) { - locr0[V0] = i; - locr0[A3] = 1; -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p->p_tracep, code, - callp->sy_narg, args.i); -#endif - goto done; - } - } - } -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p->p_tracep, code, callp->sy_narg, args.i); -#endif - rval[0] = 0; - rval[1] = locr0[V1]; -#ifdef DEBUG - if (trp == trapdebug) - trapdebug[TRAPSIZE - 1].code = code; - else - trp[-1].code = code; -#endif - i = (*callp->sy_call)(p, &args, rval); - /* - * Reinitialize proc pointer `p' as it may be different - * if this is a child returning from fork syscall. - */ - p = curproc; - locr0 = p->p_md.md_regs; -#ifdef DEBUG - { int s; - s = splhigh(); - trp->status = statusReg; - trp->cause = causeReg; - trp->vadr = locr0[SP]; - trp->pc = locr0[PC]; - trp->ra = locr0[RA]; - trp->code = -code; - if (++trp == &trapdebug[TRAPSIZE]) - trp = trapdebug; - splx(s); - } -#endif - switch (i) { - case 0: - locr0[V0] = rval[0]; - locr0[V1] = rval[1]; - locr0[A3] = 0; - break; - - case ERESTART: - locr0[PC] = pc; - break; - - case EJUSTRETURN: - break; /* nothing to do */ - - default: - locr0[V0] = i; - locr0[A3] = 1; - } - done: -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) - ktrsysret(p->p_tracep, code, i, rval[0]); -#endif - goto out; - } - - case T_BREAK+T_USER: - { - register unsigned va, instr; - - /* compute address of break instruction */ - va = pc; - if ((int)causeReg < 0) - va += 4; - - /* read break instruction */ - instr = fuiword((caddr_t)va); -#ifdef KADB - if (instr == MACH_BREAK_BRKPT || instr == MACH_BREAK_SSTEP) - goto err; -#endif - if (p->p_md.md_ss_addr != va || instr != MACH_BREAK_SSTEP) { - i = SIGTRAP; - break; - } - - /* restore original instruction and clear BP */ - i = suiword((caddr_t)va, p->p_md.md_ss_instr); - if (i < 0) { - vm_offset_t sa, ea; - int rv; - - sa = trunc_page((vm_offset_t)va); - ea = round_page((vm_offset_t)va+sizeof(int)-1); - rv = vm_map_protect(&p->p_vmspace->vm_map, sa, ea, - VM_PROT_DEFAULT, FALSE); - if (rv == KERN_SUCCESS) { - i = suiword((caddr_t)va, p->p_md.md_ss_instr); - (void) vm_map_protect(&p->p_vmspace->vm_map, - sa, ea, VM_PROT_READ|VM_PROT_EXECUTE, - FALSE); - } - } - if (i < 0) { - i = SIGTRAP; - break; - } - p->p_md.md_ss_addr = 0; - goto out; - } - - case T_RES_INST+T_USER: - i = SIGILL; - break; - - case T_COP_UNUSABLE+T_USER: - if ((causeReg & MACH_CR_COP_ERR) != 0x10000000) { - i = SIGILL; /* only FPU instructions allowed */ - break; - } - MachSwitchFPState(machFPCurProcPtr, p->p_md.md_regs); - machFPCurProcPtr = p; - p->p_md.md_regs[PS] |= MACH_SR_COP_1_BIT; - p->p_md.md_flags |= MDP_FPUSED; - goto out; - - case T_OVFLOW+T_USER: - i = SIGFPE; - break; - - case T_ADDR_ERR_LD: /* misaligned access */ - case T_ADDR_ERR_ST: /* misaligned access */ - case T_BUS_ERR_LD_ST: /* BERR asserted to cpu */ - if (i = ((struct pcb *)UADDR)->pcb_onfault) { - ((struct pcb *)UADDR)->pcb_onfault = 0; - return (onfault_table[i]); - } - /* FALLTHROUGH */ - - default: - err: -#ifdef KADB - { - extern struct pcb kdbpcb; - - if (USERMODE(statusReg)) - kdbpcb = p->p_addr->u_pcb; - else { - kdbpcb.pcb_regs[ZERO] = 0; - kdbpcb.pcb_regs[AST] = ((int *)&args)[2]; - kdbpcb.pcb_regs[V0] = ((int *)&args)[3]; - kdbpcb.pcb_regs[V1] = ((int *)&args)[4]; - kdbpcb.pcb_regs[A0] = ((int *)&args)[5]; - kdbpcb.pcb_regs[A1] = ((int *)&args)[6]; - kdbpcb.pcb_regs[A2] = ((int *)&args)[7]; - kdbpcb.pcb_regs[A3] = ((int *)&args)[8]; - kdbpcb.pcb_regs[T0] = ((int *)&args)[9]; - kdbpcb.pcb_regs[T1] = ((int *)&args)[10]; - kdbpcb.pcb_regs[T2] = ((int *)&args)[11]; - kdbpcb.pcb_regs[T3] = ((int *)&args)[12]; - kdbpcb.pcb_regs[T4] = ((int *)&args)[13]; - kdbpcb.pcb_regs[T5] = ((int *)&args)[14]; - kdbpcb.pcb_regs[T6] = ((int *)&args)[15]; - kdbpcb.pcb_regs[T7] = ((int *)&args)[16]; - kdbpcb.pcb_regs[T8] = ((int *)&args)[17]; - kdbpcb.pcb_regs[T9] = ((int *)&args)[18]; - kdbpcb.pcb_regs[RA] = ((int *)&args)[19]; - kdbpcb.pcb_regs[MULLO] = ((int *)&args)[21]; - kdbpcb.pcb_regs[MULHI] = ((int *)&args)[22]; - kdbpcb.pcb_regs[PC] = pc; - kdbpcb.pcb_regs[SR] = statusReg; - bzero((caddr_t)&kdbpcb.pcb_regs[F0], 33 * sizeof(int)); - } - if (kdb(causeReg, vadr, p, !USERMODE(statusReg))) - return (kdbpcb.pcb_regs[PC]); - } -#else -#ifdef DEBUG - trapDump("trap"); -#endif -#endif - panic("trap"); - } - printf("trap: pid %d %s sig %d adr %x pc %x ra %x\n", p->p_pid, - p->p_comm, i, vadr, pc, p->p_md.md_regs[RA]); /* XXX */ - trapsignal(p, i, ucode); -out: - /* - * Note: we should only get here if returning to user mode. - */ - /* take pending signals */ - while ((i = CURSIG(p)) != 0) - psig(i); - p->p_pri = p->p_usrpri; - astpending = 0; - if (want_resched) { - int s; - - /* - * Since we are curproc, clock will normally just change - * our priority without moving us from one queue to another - * (since the running process is not on a queue.) - * If that happened after we setrq ourselves but before we - * swtch()'ed, we might not be on the queue indicated by - * our priority. - */ - s = splstatclock(); - setrq(p); - p->p_stats->p_ru.ru_nivcsw++; - swtch(); - splx(s); - while ((i = CURSIG(p)) != 0) - psig(i); - } - - /* - * If profiling, charge system time to the trapped pc. - */ - if (p->p_flag & SPROFIL) { - extern int psratio; - - addupc_task(p, pc, (int)(p->p_sticks - sticks) * psratio); - } - - curpri = p->p_pri; - return (pc); -} - -/* - * Handle an interrupt. - * Called from MachKernIntr() or MachUserIntr() - * Note: curproc might be NULL. - */ -interrupt(statusReg, causeReg, pc) - unsigned statusReg; /* status register at time of the exception */ - unsigned causeReg; /* cause register at time of exception */ - unsigned pc; /* program counter where to continue */ -{ - register unsigned mask; - struct clockframe cf; - -#ifdef DEBUG - trp->status = statusReg; - trp->cause = causeReg; - trp->vadr = 0; - trp->pc = pc; - trp->ra = 0; - trp->code = 0; - if (++trp == &trapdebug[TRAPSIZE]) - trp = trapdebug; -#endif - - cnt.v_intr++; - mask = causeReg & statusReg; /* pending interrupts & enable mask */ - if (pmax_hardware_intr) - splx((*pmax_hardware_intr)(mask, pc, statusReg, causeReg)); - if (mask & MACH_INT_MASK_5) { - if (!USERMODE(statusReg)) { -#ifdef DEBUG - trapDump("fpintr"); -#else - printf("FPU interrupt: PC %x CR %x SR %x\n", - pc, causeReg, statusReg); -#endif - } else - MachFPInterrupt(statusReg, causeReg, pc); - } - if (mask & MACH_SOFT_INT_MASK_0) { - clearsoftclock(); - cnt.v_soft++; - softclock(); - } - /* process network interrupt if we trapped or will very soon */ - if ((mask & MACH_SOFT_INT_MASK_1) || - netisr && (statusReg & MACH_SOFT_INT_MASK_1)) { - clearsoftnet(); - cnt.v_soft++; -#ifdef INET - if (netisr & (1 << NETISR_ARP)) { - netisr &= ~(1 << NETISR_ARP); - arpintr(); - } - if (netisr & (1 << NETISR_IP)) { - netisr &= ~(1 << NETISR_IP); - ipintr(); - } -#endif -#ifdef NS - if (netisr & (1 << NETISR_NS)) { - netisr &= ~(1 << NETISR_NS); - nsintr(); - } -#endif -#ifdef ISO - if (netisr & (1 << NETISR_ISO)) { - netisr &= ~(1 << NETISR_ISO); - clnlintr(); - } -#endif - } -} - -/* - * Handle pmax (DECstation 2100/3100) interrupts. - */ -pmax_intr(mask, pc, statusReg, causeReg) - unsigned mask; - unsigned pc; - unsigned statusReg; - unsigned causeReg; -{ - register volatile struct chiptime *c = Mach_clock_addr; - struct clockframe cf; - int temp; - - /* handle clock interrupts ASAP */ - if (mask & MACH_INT_MASK_3) { - temp = c->regc; /* XXX clear interrupt bits */ - cf.pc = pc; - cf.sr = statusReg; - hardclock(&cf); - /* keep clock interrupts enabled */ - causeReg &= ~MACH_INT_MASK_3; - } - /* Re-enable clock interrupts */ - splx(MACH_INT_MASK_3 | MACH_SR_INT_ENA_CUR); -#if NSII > 0 - if (mask & MACH_INT_MASK_0) - siiintr(0); -#endif -#if NLE > 0 - if (mask & MACH_INT_MASK_1) - leintr(0); -#endif -#if NDC > 0 - if (mask & MACH_INT_MASK_2) - dcintr(0); -#endif - if (mask & MACH_INT_MASK_4) - pmax_errintr(); - return ((statusReg & ~causeReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); -} - -/* - * Handle hardware interrupts for the KN02. (DECstation 5000/200) - * Returns spl value. - */ -kn02_intr(mask, pc, statusReg, causeReg) - unsigned mask; - unsigned pc; - unsigned statusReg; - unsigned causeReg; -{ - register unsigned i, m; - register volatile struct chiptime *c = Mach_clock_addr; - register unsigned csr; - int temp; - struct clockframe cf; - static int warned = 0; - - /* handle clock interrupts ASAP */ - if (mask & MACH_INT_MASK_1) { - csr = *(unsigned *)MACH_PHYS_TO_UNCACHED(KN02_SYS_CSR); - if ((csr & KN02_CSR_PSWARN) && !warned) { - warned = 1; - printf("WARNING: power supply is overheating!\n"); - } else if (warned && !(csr & KN02_CSR_PSWARN)) { - warned = 0; - printf("WARNING: power supply is OK again\n"); - } - - temp = c->regc; /* XXX clear interrupt bits */ - cf.pc = pc; - cf.sr = statusReg; - hardclock(&cf); - - /* keep clock interrupts enabled */ - causeReg &= ~MACH_INT_MASK_1; - } - /* Re-enable clock interrupts */ - splx(MACH_INT_MASK_1 | MACH_SR_INT_ENA_CUR); - if (mask & MACH_INT_MASK_0) { - - csr = *(unsigned *)MACH_PHYS_TO_UNCACHED(KN02_SYS_CSR); - m = csr & (csr >> KN02_CSR_IOINTEN_SHIFT) & KN02_CSR_IOINT; -#if 0 - *(unsigned *)MACHPHYS_TO_UNCACHED(KN02_SYS_CSR) = - (csr & ~(KN02_CSR_WRESERVED | 0xFF)) | - (m << KN02_CSR_IOINTEN_SHIFT); -#endif - for (i = 0; m; i++, m >>= 1) { - if (!(m & 1)) - continue; - if (tc_slot_info[i].intr) - (*tc_slot_info[i].intr)(tc_slot_info[i].unit); - else - printf("spurious interrupt %d\n", i); - } -#if 0 - *(unsigned *)MACH_PHYS_TO_UNCACHED(KN02_SYS_CSR) = - csr & ~(KN02_CSR_WRESERVED | 0xFF); -#endif - } - if (mask & MACH_INT_MASK_3) - kn02_errintr(); - return ((statusReg & ~causeReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); -} - -/* - * 3min hardware interrupts. (DECstation 5000/1xx) - */ -kmin_intr(mask, pc, statusReg, causeReg) - unsigned mask; - unsigned pc; - unsigned statusReg; - unsigned causeReg; -{ - register u_int intr; - register volatile struct chiptime *c = Mach_clock_addr; - volatile u_int *imaskp = - (volatile u_int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_IMSK); - volatile u_int *intrp = - (volatile u_int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_INTR); - unsigned int old_mask; - struct clockframe cf; - int temp; - static int user_warned = 0; - - old_mask = *imaskp & kmin_tc3_imask; - *imaskp = old_mask; - - if (mask & MACH_INT_MASK_4) - (*callv->halt)((int *)0, 0); - if (mask & MACH_INT_MASK_3) { - intr = *intrp; - /* masked interrupts are still observable */ - intr &= old_mask; - - if (intr & KMIN_INTR_SCSI_PTR_LOAD) { - *intrp &= ~KMIN_INTR_SCSI_PTR_LOAD; -#ifdef notdef - asc_dma_intr(); -#endif - } - - if (intr & (KMIN_INTR_SCSI_OVRUN | KMIN_INTR_SCSI_READ_E)) - *intrp &= ~(KMIN_INTR_SCSI_OVRUN | KMIN_INTR_SCSI_READ_E); - - if (intr & KMIN_INTR_LANCE_READ_E) - *intrp &= ~KMIN_INTR_LANCE_READ_E; - - if (intr & KMIN_INTR_TIMEOUT) - kn02ba_errintr(); - - if (intr & KMIN_INTR_CLOCK) { - temp = c->regc; /* XXX clear interrupt bits */ - cf.pc = pc; - cf.sr = statusReg; - hardclock(&cf); - } - - if ((intr & KMIN_INTR_SCC_0) && - tc_slot_info[KMIN_SCC0_SLOT].intr) - (*(tc_slot_info[KMIN_SCC0_SLOT].intr)) - (tc_slot_info[KMIN_SCC0_SLOT].unit); - - if ((intr & KMIN_INTR_SCC_1) && - tc_slot_info[KMIN_SCC1_SLOT].intr) - (*(tc_slot_info[KMIN_SCC1_SLOT].intr)) - (tc_slot_info[KMIN_SCC1_SLOT].unit); - - if ((intr & KMIN_INTR_SCSI) && - tc_slot_info[KMIN_SCSI_SLOT].intr) - (*(tc_slot_info[KMIN_SCSI_SLOT].intr)) - (tc_slot_info[KMIN_SCSI_SLOT].unit); - - if ((intr & KMIN_INTR_LANCE) && - tc_slot_info[KMIN_LANCE_SLOT].intr) - (*(tc_slot_info[KMIN_LANCE_SLOT].intr)) - (tc_slot_info[KMIN_LANCE_SLOT].unit); - - if (user_warned && ((intr & KMIN_INTR_PSWARN) == 0)) { - printf("%s\n", "Power supply ok now."); - user_warned = 0; - } - if ((intr & KMIN_INTR_PSWARN) && (user_warned < 3)) { - user_warned++; - printf("%s\n", "Power supply overheating"); - } - } - if ((mask & MACH_INT_MASK_0) && tc_slot_info[0].intr) - (*tc_slot_info[0].intr)(tc_slot_info[0].unit); - if ((mask & MACH_INT_MASK_1) && tc_slot_info[1].intr) - (*tc_slot_info[1].intr)(tc_slot_info[1].unit); - if ((mask & MACH_INT_MASK_2) && tc_slot_info[2].intr) - (*tc_slot_info[2].intr)(tc_slot_info[2].unit); - return ((statusReg & ~causeReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); -} - -/* - * Maxine hardware interrupts. (Personal DECstation 5000/xx) - */ -xine_intr(mask, pc, statusReg, causeReg) - unsigned mask; - unsigned pc; - unsigned statusReg; - unsigned causeReg; -{ - register u_int intr; - register volatile struct chiptime *c = Mach_clock_addr; - volatile u_int *imaskp = (volatile u_int *) - MACH_PHYS_TO_UNCACHED(XINE_REG_IMSK); - volatile u_int *intrp = (volatile u_int *) - MACH_PHYS_TO_UNCACHED(XINE_REG_INTR); - u_int old_mask; - struct clockframe cf; - int temp; - - old_mask = *imaskp & xine_tc3_imask; - *imaskp = old_mask; - - if (mask & MACH_INT_MASK_4) - (*callv->halt)((int *)0, 0); - - /* handle clock interrupts ASAP */ - if (mask & MACH_INT_MASK_1) { - temp = c->regc; /* XXX clear interrupt bits */ - cf.pc = pc; - cf.sr = statusReg; - hardclock(&cf); - causeReg &= ~MACH_INT_MASK_1; - /* reenable clock interrupts */ - splx(MACH_INT_MASK_1 | MACH_SR_INT_ENA_CUR); - } - if (mask & MACH_INT_MASK_3) { - intr = *intrp; - /* masked interrupts are still observable */ - intr &= old_mask; - - if (intr & XINE_INTR_SCSI_PTR_LOAD) { - *intrp &= ~XINE_INTR_SCSI_PTR_LOAD; -#ifdef notdef - asc_dma_intr(); -#endif - } - - if (intr & (XINE_INTR_SCSI_OVRUN | XINE_INTR_SCSI_READ_E)) - *intrp &= ~(XINE_INTR_SCSI_OVRUN | XINE_INTR_SCSI_READ_E); - - if (intr & XINE_INTR_LANCE_READ_E) - *intrp &= ~XINE_INTR_LANCE_READ_E; - - if ((intr & XINE_INTR_SCC_0) && - tc_slot_info[XINE_SCC0_SLOT].intr) - (*(tc_slot_info[XINE_SCC0_SLOT].intr)) - (tc_slot_info[XINE_SCC0_SLOT].unit); - - if ((intr & XINE_INTR_DTOP_RX) && - tc_slot_info[XINE_DTOP_SLOT].intr) - (*(tc_slot_info[XINE_DTOP_SLOT].intr)) - (tc_slot_info[XINE_DTOP_SLOT].unit); - - if ((intr & XINE_INTR_FLOPPY) && - tc_slot_info[XINE_FLOPPY_SLOT].intr) - (*(tc_slot_info[XINE_FLOPPY_SLOT].intr)) - (tc_slot_info[XINE_FLOPPY_SLOT].unit); - - if ((intr & XINE_INTR_TC_0) && - tc_slot_info[0].intr) - (*(tc_slot_info[0].intr)) - (tc_slot_info[0].unit); - - if ((intr & XINE_INTR_TC_1) && - tc_slot_info[1].intr) - (*(tc_slot_info[1].intr)) - (tc_slot_info[1].unit); - - if ((intr & XINE_INTR_ISDN) && - tc_slot_info[XINE_ISDN_SLOT].intr) - (*(tc_slot_info[XINE_ISDN_SLOT].intr)) - (tc_slot_info[XINE_ISDN_SLOT].unit); - - if ((intr & XINE_INTR_SCSI) && - tc_slot_info[XINE_SCSI_SLOT].intr) - (*(tc_slot_info[XINE_SCSI_SLOT].intr)) - (tc_slot_info[XINE_SCSI_SLOT].unit); - - if ((intr & XINE_INTR_LANCE) && - tc_slot_info[XINE_LANCE_SLOT].intr) - (*(tc_slot_info[XINE_LANCE_SLOT].intr)) - (tc_slot_info[XINE_LANCE_SLOT].unit); - - } - if (mask & MACH_INT_MASK_2) - kn02ba_errintr(); - return ((statusReg & ~causeReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); -} - -#ifdef DS5000_240 -/* - * 3Max+ hardware interrupts. (DECstation 5000/240) UNTESTED!! - */ -kn03_intr(mask, pc, statusReg, causeReg) - unsigned mask; - unsigned pc; - unsigned statusReg; - unsigned causeReg; -{ - register u_int intr; - register volatile struct chiptime *c = Mach_clock_addr; - volatile u_int *imaskp = (volatile u_int *) - MACH_PHYS_TO_UNCACHED(KN03_REG_IMSK); - volatile u_int *intrp = (volatile u_int *) - MACH_PHYS_TO_UNCACHED(KN03_REG_INTR); - u_int old_mask; - struct clockframe cf; - int temp; - static int user_warned = 0; - - old_mask = *imaskp & kn03_tc3_imask; - *imaskp = old_mask; - - if (mask & MACH_INT_MASK_4) - (*callv->halt)((int *)0, 0); - - /* handle clock interrupts ASAP */ - if (mask & MACH_INT_MASK_1) { - temp = c->regc; /* XXX clear interrupt bits */ - cf.pc = pc; - cf.sr = statusReg; - hardclock(&cf); - causeReg &= ~MACH_INT_MASK_1; - /* reenable clock interrupts */ - splx(MACH_INT_MASK_1 | MACH_SR_INT_ENA_CUR); - } - if (mask & MACH_INT_MASK_0) { - intr = *intrp; - /* masked interrupts are still observable */ - intr &= old_mask; - - if (intr & KN03_INTR_SCSI_PTR_LOAD) { - *intrp &= ~KN03_INTR_SCSI_PTR_LOAD; -#ifdef notdef - asc_dma_intr(); -#endif - } - - if (intr & (KN03_INTR_SCSI_OVRUN | KN03_INTR_SCSI_READ_E)) - *intrp &= ~(KN03_INTR_SCSI_OVRUN | KN03_INTR_SCSI_READ_E); - - if (intr & KN03_INTR_LANCE_READ_E) - *intrp &= ~KN03_INTR_LANCE_READ_E; - - if ((intr & KN03_INTR_SCC_0) && - tc_slot_info[KN03_SCC0_SLOT].intr) - (*(tc_slot_info[KN03_SCC0_SLOT].intr)) - (tc_slot_info[KN03_SCC0_SLOT].unit); - - if ((intr & KN03_INTR_SCC_1) && - tc_slot_info[KN03_SCC1_SLOT].intr) - (*(tc_slot_info[KN03_SCC1_SLOT].intr)) - (tc_slot_info[KN03_SCC1_SLOT].unit); - - if ((intr & KN03_INTR_TC_0) && - tc_slot_info[0].intr) - (*(tc_slot_info[0].intr)) - (tc_slot_info[0].unit); - - if ((intr & KN03_INTR_TC_1) && - tc_slot_info[1].intr) - (*(tc_slot_info[1].intr)) - (tc_slot_info[1].unit); - - if ((intr & KN03_INTR_TC_2) && - tc_slot_info[2].intr) - (*(tc_slot_info[2].intr)) - (tc_slot_info[2].unit); - - if ((intr & KN03_INTR_SCSI) && - tc_slot_info[KN03_SCSI_SLOT].intr) - (*(tc_slot_info[KN03_SCSI_SLOT].intr)) - (tc_slot_info[KN03_SCSI_SLOT].unit); - - if ((intr & KN03_INTR_LANCE) && - tc_slot_info[KN03_LANCE_SLOT].intr) - (*(tc_slot_info[KN03_LANCE_SLOT].intr)) - (tc_slot_info[KN03_LANCE_SLOT].unit); - - if (user_warned && ((intr & KN03_INTR_PSWARN) == 0)) { - printf("%s\n", "Power supply ok now."); - user_warned = 0; - } - if ((intr & KN03_INTR_PSWARN) && (user_warned < 3)) { - user_warned++; - printf("%s\n", "Power supply overheating"); - } - } - if (mask & MACH_INT_MASK_3) - kn03_errintr(); - return ((statusReg & ~causeReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); -} -#endif /* DS5000_240 */ - -/* - * This is called from MachUserIntr() if astpending is set. - * This is very similar to the tail of trap(). - */ -softintr(statusReg, pc) - unsigned statusReg; /* status register at time of the exception */ - unsigned pc; /* program counter where to continue */ -{ - register struct proc *p = curproc; - int sig; - - cnt.v_soft++; - /* take pending signals */ - while ((sig = CURSIG(p)) != 0) - psig(sig); - p->p_pri = p->p_usrpri; - astpending = 0; - if (p->p_flag & SOWEUPC) { - p->p_flag &= ~SOWEUPC; - ADDUPROF(p); - } - if (want_resched) { - int s; - - /* - * Since we are curproc, clock will normally just change - * our priority without moving us from one queue to another - * (since the running process is not on a queue.) - * If that happened after we setrq ourselves but before we - * swtch()'ed, we might not be on the queue indicated by - * our priority. - */ - s = splstatclock(); - setrq(p); - p->p_stats->p_ru.ru_nivcsw++; - swtch(); - splx(s); - while ((sig = CURSIG(p)) != 0) - psig(sig); - } - curpri = p->p_pri; -} - -#ifdef DEBUG -trapDump(msg) - char *msg; -{ - register int i; - int s; - - s = splhigh(); - printf("trapDump(%s)\n", msg); - for (i = 0; i < TRAPSIZE; i++) { - if (trp == trapdebug) - trp = &trapdebug[TRAPSIZE - 1]; - else - trp--; - if (trp->cause == 0) - break; - printf("%s: ADR %x PC %x CR %x SR %x\n", - trap_type[(trp->cause & MACH_CR_EXC_CODE) >> - MACH_CR_EXC_CODE_SHIFT], - trp->vadr, trp->pc, trp->cause, trp->status); - printf(" RA %x code %d\n", trp-> ra, trp->code); - } - bzero(trapdebug, sizeof(trapdebug)); - trp = trapdebug; - splx(s); -} -#endif - -#ifdef X_KLUGE -/* - * This is a kludge to allow X windows to work. - */ -caddr_t -vmUserMap(size, pa) - int size; - unsigned pa; -{ - register caddr_t v; - unsigned off, entry; - - if (nUserMapPtes == 0) - UserMapPid = curproc->p_pid; - else if (UserMapPid != curproc->p_pid) - return ((caddr_t)0); - off = pa & PGOFSET; - size = btoc(off + size); - if (nUserMapPtes + size > NPTES) - return ((caddr_t)0); - v = (caddr_t)(USER_MAP_ADDR + pmax_ptob(nUserMapPtes) + off); - entry = (pa & 0x9ffff000) | PG_V | PG_M; - if (pa >= MACH_UNCACHED_MEMORY_ADDR) - entry |= PG_N; - while (size > 0) { - UserMapPtes[nUserMapPtes].pt_entry = entry; - entry += NBPG; - nUserMapPtes++; - size--; - } - return (v); -} - -vmUserUnmap() -{ - int id; - - nUserMapPtes = 0; - if (UserMapPid == curproc->p_pid) { - id = curproc->p_vmspace->vm_pmap.pm_tlbpid; - if (id >= 0) - MachTLBFlushPID(id); - } - UserMapPid = 0; -} -#endif - -/* - *---------------------------------------------------------------------- - * - * MemErrorInterrupts -- - * pmax_errintr - for the DS2100/DS3100 - * kn02_errintr - for the DS5000/200 - * kn02ba_errintr - for the DS5000/1xx and DS5000/xx - * - * Handler an interrupt for the control register. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ -static void -pmax_errintr() -{ - volatile u_short *sysCSRPtr = - (u_short *)MACH_PHYS_TO_UNCACHED(KN01_SYS_CSR); - u_short csr; - - csr = *sysCSRPtr; - - if (csr & KN01_CSR_MERR) { - printf("Memory error at 0x%x\n", - *(unsigned *)MACH_PHYS_TO_UNCACHED(KN01_SYS_ERRADR)); - panic("Mem error interrupt"); - } - *sysCSRPtr = (csr & ~KN01_CSR_MBZ) | 0xff; -} - -static void -kn02_errintr() -{ - - printf("erradr %x\n", *(unsigned *)MACH_PHYS_TO_UNCACHED(KN02_SYS_ERRADR)); - *(unsigned *)MACH_PHYS_TO_UNCACHED(KN02_SYS_ERRADR) = 0; - MachEmptyWriteBuffer(); -} - -#ifdef DS5000_240 -static void -kn03_errintr() -{ - - printf("erradr %x\n", *(unsigned *)MACH_PHYS_TO_UNCACHED(KN03_SYS_ERRADR)); - *(unsigned *)MACH_PHYS_TO_UNCACHED(KN03_SYS_ERRADR) = 0; - MachEmptyWriteBuffer(); -} -#endif /* DS5000_240 */ - -static void -kn02ba_errintr() -{ - register int mer, adr, siz; - static int errintr_cnt = 0; - - siz = *(volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_MSR); - mer = *(volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_MER); - adr = *(volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_AER); - - /* clear interrupt bit */ - *(unsigned int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_TIMEOUT) = 0; - - errintr_cnt++; - printf("(%d)%s%x [%x %x %x]\n", errintr_cnt, - "Bad memory chip at phys ", - kn02ba_recover_erradr(adr, mer), - mer, siz, adr); -} - -static unsigned -kn02ba_recover_erradr(phys, mer) - register unsigned phys, mer; -{ - /* phys holds bits 28:2, mer knows which byte */ - switch (mer & KMIN_MER_LASTBYTE) { - case KMIN_LASTB31: - mer = 3; break; - case KMIN_LASTB23: - mer = 2; break; - case KMIN_LASTB15: - mer = 1; break; - case KMIN_LASTB07: - mer = 0; break; - } - return ((phys & KMIN_AER_ADDR_MASK) | mer); -} - -/* - * Return the resulting PC as if the branch was executed. - */ -unsigned -MachEmulateBranch(regsPtr, instPC, fpcCSR, allowNonBranch) - unsigned *regsPtr; - unsigned instPC; - unsigned fpcCSR; - int allowNonBranch; -{ - InstFmt inst; - unsigned retAddr; - int condition; - extern unsigned GetBranchDest(); - -#if 0 - printf("regsPtr=%x PC=%x Inst=%x fpcCsr=%x\n", regsPtr, instPC, - *instPC, fpcCSR); -#endif - - inst = *(InstFmt *)instPC; - switch ((int)inst.JType.op) { - case OP_SPECIAL: - switch ((int)inst.RType.func) { - case OP_JR: - case OP_JALR: - retAddr = regsPtr[inst.RType.rs]; - break; - - default: - if (!allowNonBranch) - panic("MachEmulateBranch: Non-branch"); - retAddr = instPC + 4; - break; - } - break; - - case OP_BCOND: - switch ((int)inst.IType.rt) { - case OP_BLTZ: - case OP_BLTZAL: - if ((int)(regsPtr[inst.RType.rs]) < 0) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - case OP_BGEZAL: - case OP_BGEZ: - if ((int)(regsPtr[inst.RType.rs]) >= 0) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - default: - panic("MachEmulateBranch: Bad branch cond"); - } - break; - - case OP_J: - case OP_JAL: - retAddr = (inst.JType.target << 2) | - ((unsigned)instPC & 0xF0000000); - break; - - case OP_BEQ: - if (regsPtr[inst.RType.rs] == regsPtr[inst.RType.rt]) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - case OP_BNE: - if (regsPtr[inst.RType.rs] != regsPtr[inst.RType.rt]) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - case OP_BLEZ: - if ((int)(regsPtr[inst.RType.rs]) <= 0) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - case OP_BGTZ: - if ((int)(regsPtr[inst.RType.rs]) > 0) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - case OP_COP1: - switch (inst.RType.rs) { - case OP_BCx: - case OP_BCy: - if ((inst.RType.rt & COPz_BC_TF_MASK) == COPz_BC_TRUE) - condition = fpcCSR & MACH_FPC_COND_BIT; - else - condition = !(fpcCSR & MACH_FPC_COND_BIT); - if (condition) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - default: - if (!allowNonBranch) - panic("MachEmulateBranch: Bad coproc branch instruction"); - retAddr = instPC + 4; - } - break; - - default: - if (!allowNonBranch) - panic("MachEmulateBranch: Non-branch instruction"); - retAddr = instPC + 4; - } -#if 0 - printf("Target addr=%x\n", retAddr); -#endif - return (retAddr); -} - -unsigned -GetBranchDest(InstPtr) - InstFmt *InstPtr; -{ - return ((unsigned)InstPtr + 4 + ((short)InstPtr->IType.imm << 2)); -} - -/* - * This routine is called by procxmt() to single step one instruction. - * We do this by storing a break instruction after the current instruction, - * resuming execution, and then restoring the old instruction. - */ -cpu_singlestep(p) - register struct proc *p; -{ - register unsigned va; - register int *locr0 = p->p_md.md_regs; - int i; - - /* compute next address after current location */ - va = MachEmulateBranch(locr0, locr0[PC], 0, 1); - if (p->p_md.md_ss_addr || p->p_md.md_ss_addr == va || - !useracc((caddr_t)va, 4, B_READ)) { - printf("SS %s (%d): breakpoint already set at %x (va %x)\n", - p->p_comm, p->p_pid, p->p_md.md_ss_addr, va); /* XXX */ - return (EFAULT); - } - p->p_md.md_ss_addr = va; - p->p_md.md_ss_instr = fuiword((caddr_t)va); - i = suiword((caddr_t)va, MACH_BREAK_SSTEP); - if (i < 0) { - vm_offset_t sa, ea; - int rv; - - sa = trunc_page((vm_offset_t)va); - ea = round_page((vm_offset_t)va+sizeof(int)-1); - rv = vm_map_protect(&p->p_vmspace->vm_map, sa, ea, - VM_PROT_DEFAULT, FALSE); - if (rv == KERN_SUCCESS) { - i = suiword((caddr_t)va, MACH_BREAK_SSTEP); - (void) vm_map_protect(&p->p_vmspace->vm_map, - sa, ea, VM_PROT_READ|VM_PROT_EXECUTE, FALSE); - } - } - if (i < 0) - return (EFAULT); - printf("SS %s (%d): breakpoint set at %x: %x (pc %x)\n", - p->p_comm, p->p_pid, p->p_md.md_ss_addr, - p->p_md.md_ss_instr, locr0[PC]); /* XXX */ - return (0); -} - -#ifdef DEBUG -kdbpeek(addr) -{ - if (addr & 3) { - printf("kdbpeek: unaligned address %x\n", addr); - return (-1); - } - return (*(int *)addr); -} - -#define MIPS_JR_RA 0x03e00008 /* instruction code for jr ra */ - -/* - * Print a stack backtrace. - */ -void -stacktrace() -{ - unsigned pc, sp, fp, ra, va, subr; - int a0, a1, a2, a3; - unsigned instr, mask; - InstFmt i; - int more, stksize; - int regs[8]; - extern setsoftclock(); - extern char start[], edata[]; - - cpu_getregs(regs); - - /* get initial values from the exception frame */ - sp = regs[0]; - pc = regs[2]; - ra = 0; - a0 = regs[3]; - a1 = regs[4]; - a2 = regs[5]; - a3 = regs[6]; - fp = regs[7]; - -loop: - /* check for current PC in the kernel interrupt handler code */ - if (pc >= (unsigned)MachKernIntr && pc < (unsigned)MachUserIntr) { - /* NOTE: the offsets depend on the code in locore.s */ - printf("interrupt\n"); - a0 = kdbpeek(sp + 36); - a1 = kdbpeek(sp + 40); - a2 = kdbpeek(sp + 44); - a3 = kdbpeek(sp + 48); - pc = kdbpeek(sp + 20); - ra = kdbpeek(sp + 92); - sp = kdbpeek(sp + 100); - fp = kdbpeek(sp + 104); - } - - /* check for current PC in the exception handler code */ - if (pc >= 0x80000000 && pc < (unsigned)setsoftclock) { - ra = 0; - subr = 0; - goto done; - } - - /* check for bad PC */ - if (pc & 3 || pc < 0x80000000 || pc >= (unsigned)edata) { - printf("PC 0x%x: not in kernel\n", pc); - ra = 0; - subr = 0; - goto done; - } - - /* - * Find the beginning of the current subroutine by scanning backwards - * from the current PC for the end of the previous subroutine. - */ - va = pc - sizeof(int); - while ((instr = kdbpeek(va)) != MIPS_JR_RA) - va -= sizeof(int); - va += 2 * sizeof(int); /* skip back over branch & delay slot */ - /* skip over nulls which might separate .o files */ - while ((instr = kdbpeek(va)) == 0) - va += sizeof(int); - subr = va; - - /* scan forwards to find stack size and any saved registers */ - stksize = 0; - more = 3; - mask = 0; - for (; more; va += sizeof(int), more = (more == 3) ? 3 : more - 1) { - /* stop if hit our current position */ - if (va >= pc) - break; - instr = kdbpeek(va); - i.word = instr; - switch (i.JType.op) { - case OP_SPECIAL: - switch (i.RType.func) { - case OP_JR: - case OP_JALR: - more = 2; /* stop after next instruction */ - break; - - case OP_SYSCALL: - case OP_BREAK: - more = 1; /* stop now */ - }; - break; - - case OP_BCOND: - case OP_J: - case OP_JAL: - case OP_BEQ: - case OP_BNE: - case OP_BLEZ: - case OP_BGTZ: - more = 2; /* stop after next instruction */ - break; - - case OP_COP0: - case OP_COP1: - case OP_COP2: - case OP_COP3: - switch (i.RType.rs) { - case OP_BCx: - case OP_BCy: - more = 2; /* stop after next instruction */ - }; - break; - - case OP_SW: - /* look for saved registers on the stack */ - if (i.IType.rs != 29) - break; - /* only restore the first one */ - if (mask & (1 << i.IType.rt)) - break; - mask |= 1 << i.IType.rt; - switch (i.IType.rt) { - case 4: /* a0 */ - a0 = kdbpeek(sp + (short)i.IType.imm); - break; - - case 5: /* a1 */ - a1 = kdbpeek(sp + (short)i.IType.imm); - break; - - case 6: /* a2 */ - a2 = kdbpeek(sp + (short)i.IType.imm); - break; - - case 7: /* a3 */ - a3 = kdbpeek(sp + (short)i.IType.imm); - break; - - case 30: /* fp */ - fp = kdbpeek(sp + (short)i.IType.imm); - break; - - case 31: /* ra */ - ra = kdbpeek(sp + (short)i.IType.imm); - } - break; - - case OP_ADDI: - case OP_ADDIU: - /* look for stack pointer adjustment */ - if (i.IType.rs != 29 || i.IType.rt != 29) - break; - stksize = (short)i.IType.imm; - } - } - -done: - printf("%x+%x (%x,%x,%x,%x) ra %x sz %d\n", - subr, pc - subr, a0, a1, a2, a3, ra, stksize); - - if (ra) { - if (pc == ra && stksize == 0) - printf("stacktrace: loop!\n"); - else { - pc = ra; - sp -= stksize; - goto loop; - } - } -} -#endif /* DEBUG */ diff --git a/sys/arch/pmax/pmax/trap.c.sav2 b/sys/arch/pmax/pmax/trap.c.sav2 deleted file mode 100644 index eaa681b14569..000000000000 --- a/sys/arch/pmax/pmax/trap.c.sav2 +++ /dev/null @@ -1,1846 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department and Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah Hdr: trap.c 1.32 91/04/06 - * from: @(#)trap.c 7.14 (Berkeley) 3/8/93 - * $Id: trap.c.sav2,v 1.1.1.1 1993/10/12 03:22:38 deraadt Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef KTRACE -#include -#endif -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -/* - * This is a kludge to allow X windows to work. - */ -#define X_KLUGE - -#ifdef X_KLUGE -#define USER_MAP_ADDR 0x4000 -#define NPTES 550 -static pt_entry_t UserMapPtes[NPTES]; -static unsigned nUserMapPtes; -static pid_t UserMapPid; -#endif - -struct proc *machFPCurProcPtr; /* pointer to last proc to use FP */ - -extern void MachKernGenException(); -extern void MachUserGenException(); -extern void MachKernIntr(); -extern void MachUserIntr(); -extern void MachTLBModException(); -extern void MachTLBMissException(); -extern unsigned MachEmulateBranch(); - -void (*machExceptionTable[])() = { -/* - * The kernel exception handlers. - */ - MachKernIntr, /* external interrupt */ - MachKernGenException, /* TLB modification */ - MachTLBMissException, /* TLB miss (load or instr. fetch) */ - MachTLBMissException, /* TLB miss (store) */ - MachKernGenException, /* address error (load or I-fetch) */ - MachKernGenException, /* address error (store) */ - MachKernGenException, /* bus error (I-fetch) */ - MachKernGenException, /* bus error (load or store) */ - MachKernGenException, /* system call */ - MachKernGenException, /* breakpoint */ - MachKernGenException, /* reserved instruction */ - MachKernGenException, /* coprocessor unusable */ - MachKernGenException, /* arithmetic overflow */ - MachKernGenException, /* reserved */ - MachKernGenException, /* reserved */ - MachKernGenException, /* reserved */ -/* - * The user exception handlers. - */ - MachUserIntr, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, - MachUserGenException, -}; - -char *trap_type[] = { - "external interrupt", - "TLB modification", - "TLB miss (load or instr. fetch)", - "TLB miss (store)", - "address error (load or I-fetch)", - "address error (store)", - "bus error (I-fetch)", - "bus error (load or store)", - "system call", - "breakpoint", - "reserved instruction", - "coprocessor unusable", - "arithmetic overflow", - "reserved 13", - "reserved 14", - "reserved 15", -}; - -#ifdef DEBUG -#define TRAPSIZE 10 -struct trapdebug { /* trap history buffer for debugging */ - u_int status; - u_int cause; - u_int vadr; - u_int pc; - u_int ra; - u_int code; -} trapdebug[TRAPSIZE], *trp = trapdebug; -#endif - -static void pmax_errintr(); -static void kn02_errintr(), kn02ba_errintr(); -#ifdef DS5000_240 -static void kn03_errintr(); -#endif -static unsigned kn02ba_recover_erradr(); -extern tc_option_t tc_slot_info[TC_MAX_LOGICAL_SLOTS]; -extern u_long kmin_tc3_imask, xine_tc3_imask; -extern const struct callback *callv; -#ifdef DS5000_240 -extern u_long kn03_tc3_imask; -#endif -int (*pmax_hardware_intr)() = (int (*)())0; -extern volatile struct chiptime *Mach_clock_addr; - -/* - * Handle an exception. - * Called from MachKernGenException() or MachUserGenException() - * when a processor trap occurs. - * In the case of a kernel trap, we return the pc where to resume if - * ((struct pcb *)UADDR)->pcb_onfault is set, otherwise, return old pc. - */ -unsigned -trap(statusReg, causeReg, vadr, pc, args) - unsigned statusReg; /* status register at time of the exception */ - unsigned causeReg; /* cause register at time of exception */ - unsigned vadr; /* address (if any) the fault occured on */ - unsigned pc; /* program counter where to continue */ -{ - register int type, i; - unsigned ucode = 0; - register struct proc *p = curproc; - u_quad_t sticks; - vm_prot_t ftype; - extern unsigned onfault_table[]; - -#ifdef DEBUG - trp->status = statusReg; - trp->cause = causeReg; - trp->vadr = vadr; - trp->pc = pc; - trp->ra = !USERMODE(statusReg) ? ((int *)&args)[19] : - p->p_md.md_regs[RA]; - trp->code = 0; - if (++trp == &trapdebug[TRAPSIZE]) - trp = trapdebug; -#endif - - cnt.v_trap++; - type = (causeReg & MACH_CR_EXC_CODE) >> MACH_CR_EXC_CODE_SHIFT; - if (USERMODE(statusReg)) { - type |= T_USER; - sticks = p->p_sticks; - } - - /* - * Enable hardware interrupts if they were on before. - * We only respond to software interrupts when returning to user mode. - */ - if (statusReg & MACH_SR_INT_ENA_PREV) - splx((statusReg & MACH_HARD_INT_MASK) | MACH_SR_INT_ENA_CUR); - - switch (type) { - case T_TLB_MOD: - /* check for kernel address */ - if ((int)vadr < 0) { - register pt_entry_t *pte; - register unsigned entry; -#ifndef ATTR - register vm_offset_t pa; -#endif - - pte = kvtopte(vadr); - entry = pte->pt_entry; - if (entry & PG_RO) { - /* write to read only page in the kernel */ - ftype = VM_PROT_WRITE; - goto kernel_fault; - } - entry |= PG_M; - pte->pt_entry = entry; - vadr &= PG_FRAME; - printf("trap: TLBupdate hi %x lo %x i %x\n", vadr, - entry, MachTLBUpdate(vadr, entry)); /* XXX */ -#ifdef ATTR - pmap_attributes[atop(entry - KERNBASE)] |= PMAP_ATTR_MOD; -#else - pa = entry & PG_FRAME; - if (!IS_VM_PHYSADDR(pa)) - panic("trap: kmod"); - PHYS_TO_VM_PAGE(pa)->flags &= ~PG_CLEAN; -#endif - return (pc); - } - /* FALLTHROUGH */ - - case T_TLB_MOD+T_USER: - { - pmap_hash_t hp; -#ifndef ATTR - vm_offset_t pa; -#endif -#ifdef DIAGNOSTIC - extern pmap_hash_t zero_pmap_hash; - extern pmap_t cur_pmap; - - if (cur_pmap->pm_hash == zero_pmap_hash || - cur_pmap->pm_hash == (pmap_hash_t)0) - panic("tlbmod"); -#endif - hp = &((pmap_hash_t)PMAP_HASH_UADDR)[PMAP_HASH(vadr)]; - if (((hp->pmh_pte[0].high ^ vadr) & ~PGOFSET) == 0) - i = 0; - else if (((hp->pmh_pte[1].high ^ vadr) & ~PGOFSET) == 0) - i = 1; - else - panic("trap: tlb umod not found"); - if (hp->pmh_pte[i].low & PG_RO) { - ftype = VM_PROT_WRITE; - goto dofault; - } - hp->pmh_pte[i].low |= PG_M; - printf("trap: TLBupdate hi %x lo %x i %x\n", - hp->pmh_pte[i].high, hp->pmh_pte[i].low, - MachTLBUpdate(hp->pmh_pte[i].high, hp->pmh_pte[i].low)); /* XXX */ -#ifdef ATTR - pmap_attributes[atop(hp->pmh_pte[i].low - KERNBASE)] |= - PMAP_ATTR_MOD; -#else - pa = hp->pmh_pte[i].low & PG_FRAME; - if (!IS_VM_PHYSADDR(pa)) - panic("trap: umod"); - PHYS_TO_VM_PAGE(pa)->flags &= ~PG_CLEAN; -#endif - if (!USERMODE(statusReg)) - return (pc); - goto out; - } - - case T_TLB_LD_MISS: - case T_TLB_ST_MISS: - ftype = (type == T_TLB_ST_MISS) ? VM_PROT_WRITE : VM_PROT_READ; - /* check for kernel address */ - if ((int)vadr < 0) { - register vm_offset_t va; - int rv; - - kernel_fault: - va = trunc_page((vm_offset_t)vadr); - rv = vm_fault(kernel_map, va, ftype, FALSE); - if (rv == KERN_SUCCESS) - return (pc); - if (i = ((struct pcb *)UADDR)->pcb_onfault) { - ((struct pcb *)UADDR)->pcb_onfault = 0; - return (onfault_table[i]); - } - goto err; - } - /* - * It is an error for the kernel to access user space except - * through the copyin/copyout routines. - */ - if ((i = ((struct pcb *)UADDR)->pcb_onfault) == 0) - goto err; - /* check for fuswintr() or suswintr() getting a page fault */ - if (i == 4) - return (onfault_table[i]); - goto dofault; - - case T_TLB_LD_MISS+T_USER: - ftype = VM_PROT_READ; - goto dofault; - - case T_TLB_ST_MISS+T_USER: - ftype = VM_PROT_WRITE; - dofault: - { - register vm_offset_t va; - register struct vmspace *vm = p->p_vmspace; - register vm_map_t map = &vm->vm_map; - int rv; - -#ifdef X_KLUGE - if (p->p_pid == UserMapPid && - (va = pmax_btop(vadr - USER_MAP_ADDR)) < nUserMapPtes) { - register pt_entry_t *pte; - - pte = &UserMapPtes[va]; - MachTLBWriteRandom((vadr & PG_FRAME) | - (vm->vm_pmap.pm_tlbpid << VMMACH_TLB_PID_SHIFT), - pte->pt_entry); - return (pc); - } -#endif - va = trunc_page((vm_offset_t)vadr); - rv = vm_fault(map, va, ftype, FALSE); - if (rv != KERN_SUCCESS) { - printf("vm_fault(%x, %x, %x, 0) -> %x ADR %x PC %x RA %x\n", - map, va, ftype, rv, vadr, pc, - !USERMODE(statusReg) ? ((int *)&args)[19] : - p->p_md.md_regs[RA]); /* XXX */ - printf("\tpid %d %s PC %x RA %x SP %x\n", p->p_pid, - p->p_comm, p->p_md.md_regs[PC], - p->p_md.md_regs[RA], - p->p_md.md_regs[SP]); /* XXX */ - } - /* - * If this was a stack access we keep track of the maximum - * accessed stack size. Also, if vm_fault gets a protection - * failure it is due to accessing the stack region outside - * the current limit and we need to reflect that as an access - * error. - */ - if ((caddr_t)va >= vm->vm_maxsaddr) { - if (rv == KERN_SUCCESS) { - unsigned nss; - - nss = clrnd(btoc(USRSTACK-(unsigned)va)); - if (nss > vm->vm_ssize) - vm->vm_ssize = nss; - } else if (rv == KERN_PROTECTION_FAILURE) - rv = KERN_INVALID_ADDRESS; - } - if (rv == KERN_SUCCESS) { - if (!USERMODE(statusReg)) - return (pc); - goto out; - } - if (!USERMODE(statusReg)) { - if (i = ((struct pcb *)UADDR)->pcb_onfault) { - ((struct pcb *)UADDR)->pcb_onfault = 0; - return (onfault_table[i]); - } - goto err; - } - ucode = vadr; - i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; - break; - } - - case T_ADDR_ERR_LD+T_USER: /* misaligned or kseg access */ - case T_ADDR_ERR_ST+T_USER: /* misaligned or kseg access */ - case T_BUS_ERR_IFETCH+T_USER: /* BERR asserted to cpu */ - case T_BUS_ERR_LD_ST+T_USER: /* BERR asserted to cpu */ - i = SIGSEGV; - break; - - case T_SYSCALL+T_USER: - { - register int *locr0 = p->p_md.md_regs; - register struct sysent *callp; - unsigned int code; - int numsys; - struct args { - int i[8]; - } args; - int rval[2]; - struct sysent *systab; - extern int nsysent; -#ifdef ULTRIXCOMPAT - extern struct sysent ultrixsysent[]; - extern int ultrixnsysent; -#endif - - cnt.v_syscall++; - /* compute next PC after syscall instruction */ - if ((int)causeReg < 0) - locr0[PC] = MachEmulateBranch(locr0, pc, 0, 0); - else - locr0[PC] += 4; - systab = sysent; - numsys = nsysent; -#ifdef ULTRIXCOMPAT - if (p->p_md.md_flags & MDP_ULTRIX) { - systab = ultrixsysent; - numsys = ultrixnsysent; - } -#endif - code = locr0[V0]; - switch (code) { - case SYS_indir: - /* - * Code is first argument, followed by actual args. - */ - code = locr0[A0]; - if (code >= numsys) - callp = &systab[SYS_indir]; /* (illegal) */ - else - callp = &systab[code]; - i = callp->sy_narg; - args.i[0] = locr0[A1]; - args.i[1] = locr0[A2]; - args.i[2] = locr0[A3]; - if (i > 3) { - i = copyin((caddr_t)(locr0[SP] + - 4 * sizeof(int)), - (caddr_t)&args.i[3], - (u_int)(i - 3) * sizeof(int)); - if (i) { - locr0[V0] = i; - locr0[A3] = 1; -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p->p_tracep, code, - callp->sy_narg, args.i); -#endif - goto done; - } - } - break; - - case SYS___indir: - /* - * Like indir, but code is a quad, so as to maintain - * quad alignment for the rest of the arguments. - */ - code = locr0[A0 + _QUAD_LOWWORD]; - if (code >= numsys) - callp = &systab[SYS_indir]; /* (illegal) */ - else - callp = &systab[code]; - i = callp->sy_narg; - args.i[0] = locr0[A2]; - args.i[1] = locr0[A3]; - if (i > 2) { - i = copyin((caddr_t)(locr0[SP] + - 4 * sizeof(int)), - (caddr_t)&args.i[2], - (u_int)(i - 2) * sizeof(int)); - if (i) { - locr0[V0] = i; - locr0[A3] = 1; -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p->p_tracep, code, - callp->sy_narg, args.i); -#endif - goto done; - } - } - break; - - default: - if (code >= numsys) - callp = &systab[SYS_indir]; /* (illegal) */ - else - callp = &systab[code]; - i = callp->sy_narg; - args.i[0] = locr0[A0]; - args.i[1] = locr0[A1]; - args.i[2] = locr0[A2]; - args.i[3] = locr0[A3]; - if (i > 4) { - i = copyin((caddr_t)(locr0[SP] + - 4 * sizeof(int)), - (caddr_t)&args.i[4], - (u_int)(i - 4) * sizeof(int)); - if (i) { - locr0[V0] = i; - locr0[A3] = 1; -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p->p_tracep, code, - callp->sy_narg, args.i); -#endif - goto done; - } - } - } -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p->p_tracep, code, callp->sy_narg, args.i); -#endif - rval[0] = 0; - rval[1] = locr0[V1]; -#ifdef DEBUG - if (trp == trapdebug) - trapdebug[TRAPSIZE - 1].code = code; - else - trp[-1].code = code; -#endif - i = (*callp->sy_call)(p, &args, rval); - /* - * Reinitialize proc pointer `p' as it may be different - * if this is a child returning from fork syscall. - */ - p = curproc; - locr0 = p->p_md.md_regs; -#ifdef DEBUG - { int s; - s = splhigh(); - trp->status = statusReg; - trp->cause = causeReg; - trp->vadr = locr0[SP]; - trp->pc = locr0[PC]; - trp->ra = locr0[RA]; - trp->code = -code; - if (++trp == &trapdebug[TRAPSIZE]) - trp = trapdebug; - splx(s); - } -#endif - switch (i) { - case 0: - locr0[V0] = rval[0]; - locr0[V1] = rval[1]; - locr0[A3] = 0; - break; - - case ERESTART: - locr0[PC] = pc; - break; - - case EJUSTRETURN: - break; /* nothing to do */ - - default: - locr0[V0] = i; - locr0[A3] = 1; - } - done: -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) - ktrsysret(p->p_tracep, code, i, rval[0]); -#endif - goto out; - } - - case T_BREAK+T_USER: - { - register unsigned va, instr; - - /* compute address of break instruction */ - va = pc; - if ((int)causeReg < 0) - va += 4; - - /* read break instruction */ - instr = fuiword((caddr_t)va); -#ifdef KADB - if (instr == MACH_BREAK_BRKPT || instr == MACH_BREAK_SSTEP) - goto err; -#endif - if (p->p_md.md_ss_addr != va || instr != MACH_BREAK_SSTEP) { - i = SIGTRAP; - break; - } - - /* restore original instruction and clear BP */ - i = suiword((caddr_t)va, p->p_md.md_ss_instr); - if (i < 0) { - vm_offset_t sa, ea; - int rv; - - sa = trunc_page((vm_offset_t)va); - ea = round_page((vm_offset_t)va+sizeof(int)-1); - rv = vm_map_protect(&p->p_vmspace->vm_map, sa, ea, - VM_PROT_DEFAULT, FALSE); - if (rv == KERN_SUCCESS) { - i = suiword((caddr_t)va, p->p_md.md_ss_instr); - (void) vm_map_protect(&p->p_vmspace->vm_map, - sa, ea, VM_PROT_READ|VM_PROT_EXECUTE, - FALSE); - } - } - if (i < 0) { - i = SIGTRAP; - break; - } - p->p_md.md_ss_addr = 0; - goto out; - } - - case T_RES_INST+T_USER: - i = SIGILL; - break; - - case T_COP_UNUSABLE+T_USER: - if ((causeReg & MACH_CR_COP_ERR) != 0x10000000) { - i = SIGILL; /* only FPU instructions allowed */ - break; - } - MachSwitchFPState(machFPCurProcPtr, p->p_md.md_regs); - machFPCurProcPtr = p; - p->p_md.md_regs[PS] |= MACH_SR_COP_1_BIT; - p->p_md.md_flags |= MDP_FPUSED; - goto out; - - case T_OVFLOW+T_USER: - i = SIGFPE; - break; - - case T_ADDR_ERR_LD: /* misaligned access */ - case T_ADDR_ERR_ST: /* misaligned access */ - case T_BUS_ERR_LD_ST: /* BERR asserted to cpu */ - if (i = ((struct pcb *)UADDR)->pcb_onfault) { - ((struct pcb *)UADDR)->pcb_onfault = 0; - return (onfault_table[i]); - } - /* FALLTHROUGH */ - - default: - err: -#ifdef KADB - { - extern struct pcb kdbpcb; - - if (USERMODE(statusReg)) - kdbpcb = p->p_addr->u_pcb; - else { - kdbpcb.pcb_regs[ZERO] = 0; - kdbpcb.pcb_regs[AST] = ((int *)&args)[2]; - kdbpcb.pcb_regs[V0] = ((int *)&args)[3]; - kdbpcb.pcb_regs[V1] = ((int *)&args)[4]; - kdbpcb.pcb_regs[A0] = ((int *)&args)[5]; - kdbpcb.pcb_regs[A1] = ((int *)&args)[6]; - kdbpcb.pcb_regs[A2] = ((int *)&args)[7]; - kdbpcb.pcb_regs[A3] = ((int *)&args)[8]; - kdbpcb.pcb_regs[T0] = ((int *)&args)[9]; - kdbpcb.pcb_regs[T1] = ((int *)&args)[10]; - kdbpcb.pcb_regs[T2] = ((int *)&args)[11]; - kdbpcb.pcb_regs[T3] = ((int *)&args)[12]; - kdbpcb.pcb_regs[T4] = ((int *)&args)[13]; - kdbpcb.pcb_regs[T5] = ((int *)&args)[14]; - kdbpcb.pcb_regs[T6] = ((int *)&args)[15]; - kdbpcb.pcb_regs[T7] = ((int *)&args)[16]; - kdbpcb.pcb_regs[T8] = ((int *)&args)[17]; - kdbpcb.pcb_regs[T9] = ((int *)&args)[18]; - kdbpcb.pcb_regs[RA] = ((int *)&args)[19]; - kdbpcb.pcb_regs[MULLO] = ((int *)&args)[21]; - kdbpcb.pcb_regs[MULHI] = ((int *)&args)[22]; - kdbpcb.pcb_regs[PC] = pc; - kdbpcb.pcb_regs[SR] = statusReg; - bzero((caddr_t)&kdbpcb.pcb_regs[F0], 33 * sizeof(int)); - } - if (kdb(causeReg, vadr, p, !USERMODE(statusReg))) - return (kdbpcb.pcb_regs[PC]); - } -#else -#ifdef DEBUG - trapDump("trap"); -#endif -#endif - panic("trap"); - } - printf("trap: pid %d %s sig %d adr %x pc %x ra %x\n", p->p_pid, - p->p_comm, i, vadr, pc, p->p_md.md_regs[RA]); /* XXX */ - trapsignal(p, i, ucode); -out: - /* - * Note: we should only get here if returning to user mode. - */ - /* take pending signals */ - while ((i = CURSIG(p)) != 0) - psig(i); - p->p_pri = p->p_usrpri; - astpending = 0; - if (want_resched) { - int s; - - /* - * Since we are curproc, clock will normally just change - * our priority without moving us from one queue to another - * (since the running process is not on a queue.) - * If that happened after we setrq ourselves but before we - * swtch()'ed, we might not be on the queue indicated by - * our priority. - */ - s = splstatclock(); - setrq(p); - p->p_stats->p_ru.ru_nivcsw++; - swtch(); - splx(s); - while ((i = CURSIG(p)) != 0) - psig(i); - } - - /* - * If profiling, charge system time to the trapped pc. - */ - if (p->p_flag & SPROFIL) { - extern int psratio; - - addupc_task(p, pc, (int)(p->p_sticks - sticks) * psratio); - } - - curpri = p->p_pri; - return (pc); -} - -/* - * Handle an interrupt. - * Called from MachKernIntr() or MachUserIntr() - * Note: curproc might be NULL. - */ -interrupt(statusReg, causeReg, pc) - unsigned statusReg; /* status register at time of the exception */ - unsigned causeReg; /* cause register at time of exception */ - unsigned pc; /* program counter where to continue */ -{ - register unsigned mask; - struct clockframe cf; - -#ifdef DEBUG - trp->status = statusReg; - trp->cause = causeReg; - trp->vadr = 0; - trp->pc = pc; - trp->ra = 0; - trp->code = 0; - if (++trp == &trapdebug[TRAPSIZE]) - trp = trapdebug; -#endif - - cnt.v_intr++; - mask = causeReg & statusReg; /* pending interrupts & enable mask */ - if (mask & MACH_INT_MASK_5) { - if (!USERMODE(statusReg)) { -#ifdef DEBUG - trapDump("fpintr"); -#else - printf("FPU interrupt: PC %x CR %x SR %x\n", - pc, causeReg, statusReg); -#endif - } else - MachFPInterrupt(statusReg, causeReg, pc); - } - if (pmax_hardware_intr) - (*pmax_hardware_intr)(mask, pc, statusReg, causeReg); - if (mask & MACH_SOFT_INT_MASK_0) { - clearsoftclock(); - cnt.v_soft++; - softclock(); - } - /* process network interrupt if we trapped or will very soon */ - if ((mask & MACH_SOFT_INT_MASK_1) || - netisr && (statusReg & MACH_SOFT_INT_MASK_1)) { - clearsoftnet(); - cnt.v_soft++; -#ifdef INET - if (netisr & (1 << NETISR_ARP)) { - netisr &= ~(1 << NETISR_ARP); - arpintr(); - } - if (netisr & (1 << NETISR_IP)) { - netisr &= ~(1 << NETISR_IP); - ipintr(); - } -#endif -#ifdef NS - if (netisr & (1 << NETISR_NS)) { - netisr &= ~(1 << NETISR_NS); - nsintr(); - } -#endif -#ifdef ISO - if (netisr & (1 << NETISR_ISO)) { - netisr &= ~(1 << NETISR_ISO); - clnlintr(); - } -#endif - } -} - -/* - * Handle pmax (DECstation 2100/3100) interrupts. - */ -pmax_intr(mask, pc, statusReg, causeReg) - unsigned mask; - unsigned pc; - unsigned statusReg; - unsigned causeReg; -{ - register volatile struct chiptime *c = Mach_clock_addr; - struct clockframe cf; - int temp; - - /* handle clock interrupts ASAP */ - if (mask & MACH_INT_MASK_3) { - temp = c->regc; /* XXX clear interrupt bits */ - cf.pc = pc; - cf.sr = statusReg; - hardclock(&cf); - /* keep clock interrupts enabled */ - causeReg &= ~MACH_INT_MASK_3; - } - /* Re-enable clock interrupts */ - splx(MACH_INT_MASK_3 | MACH_SR_INT_ENA_CUR); -#if NSII > 0 - if (mask & MACH_INT_MASK_0) - siiintr(0); -#endif -#if NLE > 0 - if (mask & MACH_INT_MASK_1) - leintr(0); -#endif -#if NDC > 0 - if (mask & MACH_INT_MASK_2) - dcintr(0); -#endif - if (mask & MACH_INT_MASK_4) - pmax_errintr(); - return ((statusReg & ~causeReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); -} - -/* - * Handle hardware interrupts for the KN02. (DECstation 5000/200) - * Returns spl value. - */ -kn02_intr(mask, pc, statusReg, causeReg) - unsigned mask; - unsigned pc; - unsigned statusReg; - unsigned causeReg; -{ - register unsigned i, m; - register volatile struct chiptime *c = Mach_clock_addr; - register unsigned csr; - int temp; - struct clockframe cf; - static int warned = 0; - - /* handle clock interrupts ASAP */ - if (mask & MACH_INT_MASK_1) { - csr = *(unsigned *)MACH_PHYS_TO_UNCACHED(KN02_SYS_CSR); - if ((csr & KN02_CSR_PSWARN) && !warned) { - warned = 1; - printf("WARNING: power supply is overheating!\n"); - } else if (warned && !(csr & KN02_CSR_PSWARN)) { - warned = 0; - printf("WARNING: power supply is OK again\n"); - } - - temp = c->regc; /* XXX clear interrupt bits */ - cf.pc = pc; - cf.sr = statusReg; - hardclock(&cf); - - /* keep clock interrupts enabled */ - causeReg &= ~MACH_INT_MASK_1; - } - /* Re-enable clock interrupts */ - splx(MACH_INT_MASK_1 | MACH_SR_INT_ENA_CUR); - if (mask & MACH_INT_MASK_0) { - - csr = *(unsigned *)MACH_PHYS_TO_UNCACHED(KN02_SYS_CSR); - m = csr & (csr >> KN02_CSR_IOINTEN_SHIFT) & KN02_CSR_IOINT; -#if 0 - *(unsigned *)MACHPHYS_TO_UNCACHED(KN02_SYS_CSR) = - (csr & ~(KN02_CSR_WRESERVED | 0xFF)) | - (m << KN02_CSR_IOINTEN_SHIFT); -#endif - for (i = 0; m; i++, m >>= 1) { - if (!(m & 1)) - continue; - if (tc_slot_info[i].intr) - (*tc_slot_info[i].intr)(tc_slot_info[i].unit); - else - printf("spurious interrupt %d\n", i); - } -#if 0 - *(unsigned *)MACH_PHYS_TO_UNCACHED(KN02_SYS_CSR) = - csr & ~(KN02_CSR_WRESERVED | 0xFF); -#endif - } - if (mask & MACH_INT_MASK_3) - kn02_errintr(); - return ((statusReg & ~causeReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); -} - -/* - * 3min hardware interrupts. (DECstation 5000/1xx) - */ -kmin_intr(mask, pc, statusReg, causeReg) - unsigned mask; - unsigned pc; - unsigned statusReg; - unsigned causeReg; -{ - register u_int intr; - register volatile struct chiptime *c = Mach_clock_addr; - register volatile u_int *imaskp = - (volatile u_int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_IMSK); - register volatile u_int *intrp = - (volatile u_int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_INTR); - unsigned int old_mask; - struct clockframe cf; - int temp; - static int user_warned = 0; - - old_mask = (*imaskp & kmin_tc3_imask); - - if (mask & MACH_INT_MASK_4) - (*callv->halt)((int *)0, 0); - if (mask & MACH_INT_MASK_3) { - /* masked interrupts are still observable */ - intr = (*intrp & old_mask); - *intrp = 0; - - /* - * Set things up so that the asic - * interrupts can be flipped on after being serviced. - */ - *imaskp = 0; - MachEmptyWriteBuffer(); - splx(MACH_INT_MASK_3 | MACH_SR_INT_ENA_CUR); - -#ifdef notdef - if (intr & (KMIN_INTR_SCSI_PTR_LOAD | - KMIN_INTR_SCSI_OVRUN | KMIN_INTR_SCSI_READ_E)) { - asc_dma_intr(intr); - } -#endif - - if (intr & KMIN_INTR_TIMEOUT) - kn02ba_errintr(); - - if (intr & KMIN_INTR_CLOCK) { - temp = c->regc; /* XXX clear interrupt bits */ - cf.pc = pc; - cf.sr = statusReg; - hardclock(&cf); - } - *imaskp = KMIN_INTR_CLOCK; /* Re-enable clock */ - - if ((intr & KMIN_INTR_SCC_0) && - tc_slot_info[KMIN_SCC0_SLOT].intr) - (*(tc_slot_info[KMIN_SCC0_SLOT].intr)) - (tc_slot_info[KMIN_SCC0_SLOT].unit); - - if ((intr & KMIN_INTR_SCC_1) && - tc_slot_info[KMIN_SCC1_SLOT].intr) - (*(tc_slot_info[KMIN_SCC1_SLOT].intr)) - (tc_slot_info[KMIN_SCC1_SLOT].unit); - - /* - * Re-enable serial ports, since they are sensitive to - * interrupt latency. - */ - *imaskp = (KMIN_INTR_CLOCK | KMIN_INTR_SCC_0 | KMIN_INTR_SCC_1); - - if ((intr & KMIN_INTR_SCSI) && - tc_slot_info[KMIN_SCSI_SLOT].intr) - (*(tc_slot_info[KMIN_SCSI_SLOT].intr)) - (tc_slot_info[KMIN_SCSI_SLOT].unit); - - if ((intr & KMIN_INTR_LANCE) && - tc_slot_info[KMIN_LANCE_SLOT].intr) - (*(tc_slot_info[KMIN_LANCE_SLOT].intr)) - (tc_slot_info[KMIN_LANCE_SLOT].unit); - - if (user_warned && ((intr & KMIN_INTR_PSWARN) == 0)) { - printf("%s\n", "Power supply ok now."); - user_warned = 0; - } - if ((intr & KMIN_INTR_PSWARN) && (user_warned < 3)) { - user_warned++; - printf("%s\n", "Power supply overheating"); - } - } - if ((mask & MACH_INT_MASK_0) && tc_slot_info[0].intr) - (*tc_slot_info[0].intr)(tc_slot_info[0].unit); - if ((mask & MACH_INT_MASK_1) && tc_slot_info[1].intr) - (*tc_slot_info[1].intr)(tc_slot_info[1].unit); - if ((mask & MACH_INT_MASK_2) && tc_slot_info[2].intr) - (*tc_slot_info[2].intr)(tc_slot_info[2].unit); - - /* - * Re-enable all asic interrupts. - */ - *imaskp = old_mask; - return ((statusReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); -} - -/* - * Maxine hardware interrupts. (Personal DECstation 5000/xx) - */ -xine_intr(mask, pc, statusReg, causeReg) - unsigned mask; - unsigned pc; - unsigned statusReg; - unsigned causeReg; -{ - register u_int intr; - register volatile struct chiptime *c = Mach_clock_addr; - register volatile u_int *imaskp = (volatile u_int *) - MACH_PHYS_TO_UNCACHED(XINE_REG_IMSK); - register volatile u_int *intrp = (volatile u_int *) - MACH_PHYS_TO_UNCACHED(XINE_REG_INTR); - u_int old_mask; - struct clockframe cf; - int temp; - - old_mask = *imaskp & xine_tc3_imask; - - if (mask & MACH_INT_MASK_4) - (*callv->halt)((int *)0, 0); - - /* handle clock interrupts ASAP */ - if (mask & MACH_INT_MASK_1) { - temp = c->regc; /* XXX clear interrupt bits */ - cf.pc = pc; - cf.sr = statusReg; - hardclock(&cf); - } - - if (mask & MACH_INT_MASK_2) - kn02ba_errintr(); - - /* - * Service all I/O ASIC interrupts. - */ - if (mask & MACH_INT_MASK_3) { - /* masked interrupts are still observable */ - intr = (*intrp & old_mask); - *intrp = 0; - - /* - * Re-enable clock interrupts. - */ - *imaskp = 0; - MachEmptyWriteBuffer(); - splx((statusReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); - -#ifdef notdef - if (intr & (XINE_INTR_SCSI_PTR_LOAD | - XINE_INTR_SCSI_OVRUN | XINE_INTR_SCSI_READ_E)) { - asc_dma_intr(intr); - } -#endif - - if ((intr & XINE_INTR_SCC_0) && - tc_slot_info[XINE_SCC0_SLOT].intr) - (*(tc_slot_info[XINE_SCC0_SLOT].intr)) - (tc_slot_info[XINE_SCC0_SLOT].unit); - - if ((intr & XINE_INTR_DTOP_RX) && - tc_slot_info[XINE_DTOP_SLOT].intr) - (*(tc_slot_info[XINE_DTOP_SLOT].intr)) - (tc_slot_info[XINE_DTOP_SLOT].unit); - - /* - * Re-enable the serial and desktop bus interrupts. - */ - *imaskp = (XINE_INTR_SCC_0 | XINE_INTR_DTOP_RX); - - if ((intr & XINE_INTR_FLOPPY) && - tc_slot_info[XINE_FLOPPY_SLOT].intr) - (*(tc_slot_info[XINE_FLOPPY_SLOT].intr)) - (tc_slot_info[XINE_FLOPPY_SLOT].unit); - - if ((intr & XINE_INTR_TC_0) && - tc_slot_info[0].intr) - (*(tc_slot_info[0].intr)) - (tc_slot_info[0].unit); - - if ((intr & XINE_INTR_TC_1) && - tc_slot_info[1].intr) - (*(tc_slot_info[1].intr)) - (tc_slot_info[1].unit); - - if ((intr & XINE_INTR_ISDN) && - tc_slot_info[XINE_ISDN_SLOT].intr) - (*(tc_slot_info[XINE_ISDN_SLOT].intr)) - (tc_slot_info[XINE_ISDN_SLOT].unit); - - if ((intr & XINE_INTR_LANCE) && - tc_slot_info[XINE_LANCE_SLOT].intr) - (*(tc_slot_info[XINE_LANCE_SLOT].intr)) - (tc_slot_info[XINE_LANCE_SLOT].unit); - - if ((intr & XINE_INTR_SCSI) && - tc_slot_info[XINE_SCSI_SLOT].intr) - (*(tc_slot_info[XINE_SCSI_SLOT].intr)) - (tc_slot_info[XINE_SCSI_SLOT].unit); - - /* - * Turn the interrupts all back on. - */ - *imaskp = old_mask; - } - return ((statusReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); -} - -#ifdef DS5000_240 -/* - * 3Max+ hardware interrupts. (DECstation 5000/240) UNTESTED!! - */ -kn03_intr(mask, pc, statusReg, causeReg) - unsigned mask; - unsigned pc; - unsigned statusReg; - unsigned causeReg; -{ - register u_int intr; - register volatile struct chiptime *c = Mach_clock_addr; - volatile u_int *imaskp = (volatile u_int *) - MACH_PHYS_TO_UNCACHED(KN03_REG_IMSK); - volatile u_int *intrp = (volatile u_int *) - MACH_PHYS_TO_UNCACHED(KN03_REG_INTR); - u_int old_mask; - struct clockframe cf; - int temp; - static int user_warned = 0; - - old_mask = *imaskp & kn03_tc3_imask; - *imaskp = old_mask; - - if (mask & MACH_INT_MASK_4) - (*callv->halt)((int *)0, 0); - - /* handle clock interrupts ASAP */ - if (mask & MACH_INT_MASK_1) { - temp = c->regc; /* XXX clear interrupt bits */ - cf.pc = pc; - cf.sr = statusReg; - hardclock(&cf); - causeReg &= ~MACH_INT_MASK_1; - /* reenable clock interrupts */ - splx(MACH_INT_MASK_1 | MACH_SR_INT_ENA_CUR); - } - if (mask & MACH_INT_MASK_0) { - intr = *intrp; - /* masked interrupts are still observable */ - intr &= old_mask; - - if (intr & KN03_INTR_SCSI_PTR_LOAD) { - *intrp &= ~KN03_INTR_SCSI_PTR_LOAD; -#ifdef notdef - asc_dma_intr(); -#endif - } - - if (intr & (KN03_INTR_SCSI_OVRUN | KN03_INTR_SCSI_READ_E)) - *intrp &= ~(KN03_INTR_SCSI_OVRUN | KN03_INTR_SCSI_READ_E); - - if (intr & KN03_INTR_LANCE_READ_E) - *intrp &= ~KN03_INTR_LANCE_READ_E; - - if ((intr & KN03_INTR_SCC_0) && - tc_slot_info[KN03_SCC0_SLOT].intr) - (*(tc_slot_info[KN03_SCC0_SLOT].intr)) - (tc_slot_info[KN03_SCC0_SLOT].unit); - - if ((intr & KN03_INTR_SCC_1) && - tc_slot_info[KN03_SCC1_SLOT].intr) - (*(tc_slot_info[KN03_SCC1_SLOT].intr)) - (tc_slot_info[KN03_SCC1_SLOT].unit); - - if ((intr & KN03_INTR_TC_0) && - tc_slot_info[0].intr) - (*(tc_slot_info[0].intr)) - (tc_slot_info[0].unit); - - if ((intr & KN03_INTR_TC_1) && - tc_slot_info[1].intr) - (*(tc_slot_info[1].intr)) - (tc_slot_info[1].unit); - - if ((intr & KN03_INTR_TC_2) && - tc_slot_info[2].intr) - (*(tc_slot_info[2].intr)) - (tc_slot_info[2].unit); - - if ((intr & KN03_INTR_SCSI) && - tc_slot_info[KN03_SCSI_SLOT].intr) - (*(tc_slot_info[KN03_SCSI_SLOT].intr)) - (tc_slot_info[KN03_SCSI_SLOT].unit); - - if ((intr & KN03_INTR_LANCE) && - tc_slot_info[KN03_LANCE_SLOT].intr) - (*(tc_slot_info[KN03_LANCE_SLOT].intr)) - (tc_slot_info[KN03_LANCE_SLOT].unit); - - if (user_warned && ((intr & KN03_INTR_PSWARN) == 0)) { - printf("%s\n", "Power supply ok now."); - user_warned = 0; - } - if ((intr & KN03_INTR_PSWARN) && (user_warned < 3)) { - user_warned++; - printf("%s\n", "Power supply overheating"); - } - } - if (mask & MACH_INT_MASK_3) - kn03_errintr(); - return ((statusReg & ~causeReg & MACH_HARD_INT_MASK) | - MACH_SR_INT_ENA_CUR); -} -#endif /* DS5000_240 */ - -/* - * This is called from MachUserIntr() if astpending is set. - * This is very similar to the tail of trap(). - */ -softintr(statusReg, pc) - unsigned statusReg; /* status register at time of the exception */ - unsigned pc; /* program counter where to continue */ -{ - register struct proc *p = curproc; - int sig; - - cnt.v_soft++; - /* take pending signals */ - while ((sig = CURSIG(p)) != 0) - psig(sig); - p->p_pri = p->p_usrpri; - astpending = 0; - if (p->p_flag & SOWEUPC) { - p->p_flag &= ~SOWEUPC; - ADDUPROF(p); - } - if (want_resched) { - int s; - - /* - * Since we are curproc, clock will normally just change - * our priority without moving us from one queue to another - * (since the running process is not on a queue.) - * If that happened after we setrq ourselves but before we - * swtch()'ed, we might not be on the queue indicated by - * our priority. - */ - s = splstatclock(); - setrq(p); - p->p_stats->p_ru.ru_nivcsw++; - swtch(); - splx(s); - while ((sig = CURSIG(p)) != 0) - psig(sig); - } - curpri = p->p_pri; -} - -#ifdef DEBUG -trapDump(msg) - char *msg; -{ - register int i; - int s; - - s = splhigh(); - printf("trapDump(%s)\n", msg); - for (i = 0; i < TRAPSIZE; i++) { - if (trp == trapdebug) - trp = &trapdebug[TRAPSIZE - 1]; - else - trp--; - if (trp->cause == 0) - break; - printf("%s: ADR %x PC %x CR %x SR %x\n", - trap_type[(trp->cause & MACH_CR_EXC_CODE) >> - MACH_CR_EXC_CODE_SHIFT], - trp->vadr, trp->pc, trp->cause, trp->status); - printf(" RA %x code %d\n", trp-> ra, trp->code); - } - bzero(trapdebug, sizeof(trapdebug)); - trp = trapdebug; - splx(s); -} -#endif - -#ifdef X_KLUGE -/* - * This is a kludge to allow X windows to work. - */ -caddr_t -vmUserMap(size, pa) - int size; - unsigned pa; -{ - register caddr_t v; - unsigned off, entry; - - if (nUserMapPtes == 0) - UserMapPid = curproc->p_pid; - else if (UserMapPid != curproc->p_pid) - return ((caddr_t)0); - off = pa & PGOFSET; - size = btoc(off + size); - if (nUserMapPtes + size > NPTES) - return ((caddr_t)0); - v = (caddr_t)(USER_MAP_ADDR + pmax_ptob(nUserMapPtes) + off); - entry = (pa & 0x9ffff000) | PG_V | PG_M; - if (pa >= MACH_UNCACHED_MEMORY_ADDR) - entry |= PG_N; - while (size > 0) { - UserMapPtes[nUserMapPtes].pt_entry = entry; - entry += NBPG; - nUserMapPtes++; - size--; - } - return (v); -} - -vmUserUnmap() -{ - int id; - - nUserMapPtes = 0; - if (UserMapPid == curproc->p_pid) { - id = curproc->p_vmspace->vm_pmap.pm_tlbpid; - if (id >= 0) - MachTLBFlushPID(id); - } - UserMapPid = 0; -} -#endif - -/* - *---------------------------------------------------------------------- - * - * MemErrorInterrupts -- - * pmax_errintr - for the DS2100/DS3100 - * kn02_errintr - for the DS5000/200 - * kn02ba_errintr - for the DS5000/1xx and DS5000/xx - * - * Handler an interrupt for the control register. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ -static void -pmax_errintr() -{ - volatile u_short *sysCSRPtr = - (u_short *)MACH_PHYS_TO_UNCACHED(KN01_SYS_CSR); - u_short csr; - - csr = *sysCSRPtr; - - if (csr & KN01_CSR_MERR) { - printf("Memory error at 0x%x\n", - *(unsigned *)MACH_PHYS_TO_UNCACHED(KN01_SYS_ERRADR)); - panic("Mem error interrupt"); - } - *sysCSRPtr = (csr & ~KN01_CSR_MBZ) | 0xff; -} - -static void -kn02_errintr() -{ - - printf("erradr %x\n", *(unsigned *)MACH_PHYS_TO_UNCACHED(KN02_SYS_ERRADR)); - *(unsigned *)MACH_PHYS_TO_UNCACHED(KN02_SYS_ERRADR) = 0; - MachEmptyWriteBuffer(); -} - -#ifdef DS5000_240 -static void -kn03_errintr() -{ - - printf("erradr %x\n", *(unsigned *)MACH_PHYS_TO_UNCACHED(KN03_SYS_ERRADR)); - *(unsigned *)MACH_PHYS_TO_UNCACHED(KN03_SYS_ERRADR) = 0; - MachEmptyWriteBuffer(); -} -#endif /* DS5000_240 */ - -static void -kn02ba_errintr() -{ - register int mer, adr, siz; - static int errintr_cnt = 0; - - siz = *(volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_MSR); - mer = *(volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_MER); - adr = *(volatile int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_AER); - - /* clear interrupt bit */ - *(unsigned int *)MACH_PHYS_TO_UNCACHED(KMIN_REG_TIMEOUT) = 0; - - errintr_cnt++; - printf("(%d)%s%x [%x %x %x]\n", errintr_cnt, - "Bad memory chip at phys ", - kn02ba_recover_erradr(adr, mer), - mer, siz, adr); -} - -static unsigned -kn02ba_recover_erradr(phys, mer) - register unsigned phys, mer; -{ - /* phys holds bits 28:2, mer knows which byte */ - switch (mer & KMIN_MER_LASTBYTE) { - case KMIN_LASTB31: - mer = 3; break; - case KMIN_LASTB23: - mer = 2; break; - case KMIN_LASTB15: - mer = 1; break; - case KMIN_LASTB07: - mer = 0; break; - } - return ((phys & KMIN_AER_ADDR_MASK) | mer); -} - -/* - * Return the resulting PC as if the branch was executed. - */ -unsigned -MachEmulateBranch(regsPtr, instPC, fpcCSR, allowNonBranch) - unsigned *regsPtr; - unsigned instPC; - unsigned fpcCSR; - int allowNonBranch; -{ - InstFmt inst; - unsigned retAddr; - int condition; - extern unsigned GetBranchDest(); - -#if 0 - printf("regsPtr=%x PC=%x Inst=%x fpcCsr=%x\n", regsPtr, instPC, - *instPC, fpcCSR); -#endif - - inst = *(InstFmt *)instPC; - switch ((int)inst.JType.op) { - case OP_SPECIAL: - switch ((int)inst.RType.func) { - case OP_JR: - case OP_JALR: - retAddr = regsPtr[inst.RType.rs]; - break; - - default: - if (!allowNonBranch) - panic("MachEmulateBranch: Non-branch"); - retAddr = instPC + 4; - break; - } - break; - - case OP_BCOND: - switch ((int)inst.IType.rt) { - case OP_BLTZ: - case OP_BLTZAL: - if ((int)(regsPtr[inst.RType.rs]) < 0) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - case OP_BGEZAL: - case OP_BGEZ: - if ((int)(regsPtr[inst.RType.rs]) >= 0) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - default: - panic("MachEmulateBranch: Bad branch cond"); - } - break; - - case OP_J: - case OP_JAL: - retAddr = (inst.JType.target << 2) | - ((unsigned)instPC & 0xF0000000); - break; - - case OP_BEQ: - if (regsPtr[inst.RType.rs] == regsPtr[inst.RType.rt]) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - case OP_BNE: - if (regsPtr[inst.RType.rs] != regsPtr[inst.RType.rt]) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - case OP_BLEZ: - if ((int)(regsPtr[inst.RType.rs]) <= 0) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - case OP_BGTZ: - if ((int)(regsPtr[inst.RType.rs]) > 0) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - case OP_COP1: - switch (inst.RType.rs) { - case OP_BCx: - case OP_BCy: - if ((inst.RType.rt & COPz_BC_TF_MASK) == COPz_BC_TRUE) - condition = fpcCSR & MACH_FPC_COND_BIT; - else - condition = !(fpcCSR & MACH_FPC_COND_BIT); - if (condition) - retAddr = GetBranchDest((InstFmt *)instPC); - else - retAddr = instPC + 8; - break; - - default: - if (!allowNonBranch) - panic("MachEmulateBranch: Bad coproc branch instruction"); - retAddr = instPC + 4; - } - break; - - default: - if (!allowNonBranch) - panic("MachEmulateBranch: Non-branch instruction"); - retAddr = instPC + 4; - } -#if 0 - printf("Target addr=%x\n", retAddr); -#endif - return (retAddr); -} - -unsigned -GetBranchDest(InstPtr) - InstFmt *InstPtr; -{ - return ((unsigned)InstPtr + 4 + ((short)InstPtr->IType.imm << 2)); -} - -/* - * This routine is called by procxmt() to single step one instruction. - * We do this by storing a break instruction after the current instruction, - * resuming execution, and then restoring the old instruction. - */ -cpu_singlestep(p) - register struct proc *p; -{ - register unsigned va; - register int *locr0 = p->p_md.md_regs; - int i; - - /* compute next address after current location */ - va = MachEmulateBranch(locr0, locr0[PC], 0, 1); - if (p->p_md.md_ss_addr || p->p_md.md_ss_addr == va || - !useracc((caddr_t)va, 4, B_READ)) { - printf("SS %s (%d): breakpoint already set at %x (va %x)\n", - p->p_comm, p->p_pid, p->p_md.md_ss_addr, va); /* XXX */ - return (EFAULT); - } - p->p_md.md_ss_addr = va; - p->p_md.md_ss_instr = fuiword((caddr_t)va); - i = suiword((caddr_t)va, MACH_BREAK_SSTEP); - if (i < 0) { - vm_offset_t sa, ea; - int rv; - - sa = trunc_page((vm_offset_t)va); - ea = round_page((vm_offset_t)va+sizeof(int)-1); - rv = vm_map_protect(&p->p_vmspace->vm_map, sa, ea, - VM_PROT_DEFAULT, FALSE); - if (rv == KERN_SUCCESS) { - i = suiword((caddr_t)va, MACH_BREAK_SSTEP); - (void) vm_map_protect(&p->p_vmspace->vm_map, - sa, ea, VM_PROT_READ|VM_PROT_EXECUTE, FALSE); - } - } - if (i < 0) - return (EFAULT); - printf("SS %s (%d): breakpoint set at %x: %x (pc %x)\n", - p->p_comm, p->p_pid, p->p_md.md_ss_addr, - p->p_md.md_ss_instr, locr0[PC]); /* XXX */ - return (0); -} - -#ifdef DEBUG -kdbpeek(addr) -{ - if (addr & 3) { - printf("kdbpeek: unaligned address %x\n", addr); - return (-1); - } - return (*(int *)addr); -} - -#define MIPS_JR_RA 0x03e00008 /* instruction code for jr ra */ - -/* - * Print a stack backtrace. - */ -void -stacktrace() -{ - unsigned pc, sp, fp, ra, va, subr; - int a0, a1, a2, a3; - unsigned instr, mask; - InstFmt i; - int more, stksize; - int regs[8]; - extern setsoftclock(); - extern char start[], edata[]; - - cpu_getregs(regs); - - /* get initial values from the exception frame */ - sp = regs[0]; - pc = regs[2]; - ra = 0; - a0 = regs[3]; - a1 = regs[4]; - a2 = regs[5]; - a3 = regs[6]; - fp = regs[7]; - -loop: - /* check for current PC in the kernel interrupt handler code */ - if (pc >= (unsigned)MachKernIntr && pc < (unsigned)MachUserIntr) { - /* NOTE: the offsets depend on the code in locore.s */ - printf("interrupt\n"); - a0 = kdbpeek(sp + 36); - a1 = kdbpeek(sp + 40); - a2 = kdbpeek(sp + 44); - a3 = kdbpeek(sp + 48); - pc = kdbpeek(sp + 20); - ra = kdbpeek(sp + 92); - sp = kdbpeek(sp + 100); - fp = kdbpeek(sp + 104); - } - - /* check for current PC in the exception handler code */ - if (pc >= 0x80000000 && pc < (unsigned)setsoftclock) { - ra = 0; - subr = 0; - goto done; - } - - /* check for bad PC */ - if (pc & 3 || pc < 0x80000000 || pc >= (unsigned)edata) { - printf("PC 0x%x: not in kernel\n", pc); - ra = 0; - subr = 0; - goto done; - } - - /* - * Find the beginning of the current subroutine by scanning backwards - * from the current PC for the end of the previous subroutine. - */ - va = pc - sizeof(int); - while ((instr = kdbpeek(va)) != MIPS_JR_RA) - va -= sizeof(int); - va += 2 * sizeof(int); /* skip back over branch & delay slot */ - /* skip over nulls which might separate .o files */ - while ((instr = kdbpeek(va)) == 0) - va += sizeof(int); - subr = va; - - /* scan forwards to find stack size and any saved registers */ - stksize = 0; - more = 3; - mask = 0; - for (; more; va += sizeof(int), more = (more == 3) ? 3 : more - 1) { - /* stop if hit our current position */ - if (va >= pc) - break; - instr = kdbpeek(va); - i.word = instr; - switch (i.JType.op) { - case OP_SPECIAL: - switch (i.RType.func) { - case OP_JR: - case OP_JALR: - more = 2; /* stop after next instruction */ - break; - - case OP_SYSCALL: - case OP_BREAK: - more = 1; /* stop now */ - }; - break; - - case OP_BCOND: - case OP_J: - case OP_JAL: - case OP_BEQ: - case OP_BNE: - case OP_BLEZ: - case OP_BGTZ: - more = 2; /* stop after next instruction */ - break; - - case OP_COP0: - case OP_COP1: - case OP_COP2: - case OP_COP3: - switch (i.RType.rs) { - case OP_BCx: - case OP_BCy: - more = 2; /* stop after next instruction */ - }; - break; - - case OP_SW: - /* look for saved registers on the stack */ - if (i.IType.rs != 29) - break; - /* only restore the first one */ - if (mask & (1 << i.IType.rt)) - break; - mask |= 1 << i.IType.rt; - switch (i.IType.rt) { - case 4: /* a0 */ - a0 = kdbpeek(sp + (short)i.IType.imm); - break; - - case 5: /* a1 */ - a1 = kdbpeek(sp + (short)i.IType.imm); - break; - - case 6: /* a2 */ - a2 = kdbpeek(sp + (short)i.IType.imm); - break; - - case 7: /* a3 */ - a3 = kdbpeek(sp + (short)i.IType.imm); - break; - - case 30: /* fp */ - fp = kdbpeek(sp + (short)i.IType.imm); - break; - - case 31: /* ra */ - ra = kdbpeek(sp + (short)i.IType.imm); - } - break; - - case OP_ADDI: - case OP_ADDIU: - /* look for stack pointer adjustment */ - if (i.IType.rs != 29 || i.IType.rt != 29) - break; - stksize = (short)i.IType.imm; - } - } - -done: - printf("%x+%x (%x,%x,%x,%x) ra %x sz %d\n", - subr, pc - subr, a0, a1, a2, a3, ra, stksize); - - if (ra) { - if (pc == ra && stksize == 0) - printf("stacktrace: loop!\n"); - else { - pc = ra; - sp -= stksize; - goto loop; - } - } -} -#endif /* DEBUG */ diff --git a/sys/arch/pmax/test/Makefile b/sys/arch/pmax/test/Makefile deleted file mode 100644 index 25bc4df48807..000000000000 --- a/sys/arch/pmax/test/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -CFLAGS = -g -AFLAGS = -g -I../../compile/PMAX - -fptest: fptest.o fptest1.o fp.o - $(CC) $(CFLAGS) -o fptest fptest.o fptest1.o fp.o - -fp.o: ../pmax/fp.s - $(CC) $(AFLAGS) -c ../pmax/fp.s - -fp1: fp1.o - $(CC) $(CFLAGS) -o fp1 fp1.o - -fp2: fp2.o - $(CC) $(CFLAGS) -o fp2 fp2.o -lm - -fp3: fp3.o - $(CC) $(CFLAGS) -o fp3 fp3.o -lm - -fp4: fp4.o - $(CC) $(CFLAGS) -o fp4 fp4.o -lm - -fp5: fp5.o - $(CC) $(CFLAGS) -o fp5 fp5.o -lm - -fp6: fp6.o - $(CC) $(CFLAGS) -o fp6 fp6.o -lm - -fp7: fp7.o - $(CC) $(CFLAGS) -o fp7 fp7.o - -fp8: fp8.o - $(CC) $(CFLAGS) -o fp8 fp8.o diff --git a/sys/arch/pmax/test/coff.c b/sys/arch/pmax/test/coff.c deleted file mode 100644 index 3a44ac8762fc..000000000000 --- a/sys/arch/pmax/test/coff.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)coff.c 7.1 (Berkeley) 1/7/92 - * $Id: coff.c,v 1.1.1.1 1993/10/12 03:22:51 deraadt Exp $ - */ - -#define COFF -#include - -/* - * Print header info for coff files. - */ -void -main(argc, argv) - int argc; - char **argv; -{ - register struct devices *dp; - register int fd, i, n; - char *fname; - struct exec aout; - - if (argc < 2) { - printf("usage: %s \n"); - goto err; - } - if ((fd = open(fname = argv[1], 0)) < 0) - goto err; - - /* read the COFF header */ - i = read(fd, (char *)&aout, sizeof(aout)); - if (i != sizeof(aout)) { - printf("No a.out header\n"); - goto cerr; - } - printf("HDR: magic 0x%x(0%o) nsec %d nsym %d optheader %d textoff %x\n", - aout.ex_fhdr.magic, - aout.ex_fhdr.magic, - aout.ex_fhdr.numSections, - aout.ex_fhdr.numSyms, - aout.ex_fhdr.optHeader, - N_TXTOFF(aout)); - printf("A.out: magic 0x%x(0%o) ver %d entry %x gprM %x gpV %x\n", - aout.ex_aout.magic, - aout.ex_aout.magic, - aout.ex_aout.verStamp, - aout.ex_aout.entry, - aout.ex_aout.gprMask, - aout.ex_aout.gpValue); - printf("\tstart %x,%x,%x size %d+%d+%d\n", - aout.ex_aout.codeStart, - aout.ex_aout.heapStart, - aout.ex_aout.bssStart, - aout.ex_aout.codeSize, - aout.ex_aout.heapSize, - aout.ex_aout.bssSize); - -cerr: - close(fd); -err: - exit(0); -} diff --git a/sys/arch/pmax/test/fp.c b/sys/arch/pmax/test/fp.c deleted file mode 100644 index 7a2ff0964f59..000000000000 --- a/sys/arch/pmax/test/fp.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -union { - unsigned w; - float f; -} uf; - -union { - unsigned w[2]; - double d; -} ud; - -/* - * Read test vectors from file and test the fp emulation by - * comparing it with the hardware. - */ -main(argc, argv) - int argc; - char **argv; -{ - - while (scanf("%lf", &ud.d) == 1) { - uf.f = ud.d; - printf("%g = (%x,%x) (%x)\n", ud.d, ud.w[1], ud.w[0], uf.w); - } - exit(0); -} diff --git a/sys/arch/pmax/test/fp1.c b/sys/arch/pmax/test/fp1.c deleted file mode 100644 index 87db1453ca70..000000000000 --- a/sys/arch/pmax/test/fp1.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -union { - unsigned w; - float f; -} uf; - -union { - unsigned w[2]; - double d; -} ud; - -/* - * Read test vectors from file and test the fp emulation by - * comparing it with the hardware. - */ -main(argc, argv) - int argc; - char **argv; -{ - char buf[1024]; - - while (fgets(buf, sizeof(buf), stdin) != NULL) { - ud.d = atof(buf); - uf.f = ud.d; - printf("'%s' (%x,%x) (%x)\n", buf, ud.w[1], ud.w[0], uf.w); - } - exit(0); -} diff --git a/sys/arch/pmax/test/fp2.c b/sys/arch/pmax/test/fp2.c deleted file mode 100644 index 7f2aa34e859d..000000000000 --- a/sys/arch/pmax/test/fp2.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#include - -int lineno; - -union { - unsigned w[2]; - double d; -} uda, udb, udc; - -/* - * Read test vectors from file and test the fp emulation by - * comparing it with the hardware. - */ -main(argc, argv) - int argc; - char **argv; -{ - register char *cp; - register int c; - char buf[10]; - unsigned arg[4]; - - for (lineno = 1; ; lineno++) { - c = scanf("%x %x %x %x", &arg[1], &arg[0], &arg[3], &arg[2]); - if (c < 0) - break; - if (c != 4) { - fprintf(stderr, "line %d: expected 4 args\n", - lineno); - goto skip; - } - - uda.w[0] = arg[0]; - uda.w[1] = arg[1]; - udb.w[0] = arg[2]; - udb.w[1] = arg[3]; - udc.d = copysign(uda.d, udb.d); - - printf("line %d: copysign(%x,%x %x,%x) = %x,%x\n", - lineno, - uda.w[1], uda.w[0], - udb.w[1], udb.w[0], - udc.w[1], udc.w[0]); - skip: - while ((c = getchar()) != EOF && c != '\n') - ; - } -} - -trapsignal(p, sig, code) - int p, sig, code; -{ - printf("line %d: signal(%d, %x)\n", lineno, sig, code); -} diff --git a/sys/arch/pmax/test/fp2_out b/sys/arch/pmax/test/fp2_out deleted file mode 100644 index 2a3bb33c61fb..000000000000 --- a/sys/arch/pmax/test/fp2_out +++ /dev/null @@ -1,27 +0,0 @@ -line 1: copysign(0,0 80000000,0) = 80000000,0 -line 2: copysign(0,0 0,0) = 0,0 -line 3: copysign(3ff00000,0 0,0) = 3ff00000,0 -line 4: copysign(0,0 3ff00000,0) = 0,0 -line 5: copysign(0,1 0,0) = 0,1 -line 6: copysign(0,0 0,1) = 0,0 -line 7: copysign(0,32 0,69) = 0,32 -line 8: copysign(0,32 80000000,69) = 80000000,32 -line 9: copysign(3ff00000,0 3ff00000,0) = 3ff00000,0 -line 10: copysign(3ff00000,0 41200000,0) = 3ff00000,0 -line 11: copysign(3ff00000,1 41200000,0) = 3ff00000,1 -line 12: copysign(3f000000,1 41200000,0) = 3f000000,1 -line 13: copysign(3f000000,1 41200000,1) = 3f000000,1 -line 14: copysign(bf800000,0 0,0) = 3f800000,0 -line 15: copysign(0,0 bf800000,0) = 80000000,0 -line 16: copysign(80000001,0 0,0) = 1,0 -line 17: copysign(0,0 80000001,0) = 80000000,0 -line 18: copysign(bf800000,0 3f800000,0) = 3f800000,0 -line 19: copysign(3f800000,0 c1200000,0) = bf800000,0 -line 20: copysign(bf800001,0 41200000,0) = 3f800001,0 -line 21: copysign(bf000001,0 41200000,0) = 3f000001,0 -line 22: copysign(bf000001,0 41200001,0) = 3f000001,0 -line 23: copysign(3f123456,76543210 bf123456,76543210) = bf123456,76543210 -line 24: copysign(3f123456,76543210 bf123456,76543211) = bf123456,76543210 -line 25: copysign(bf123456,76543210 3f123456,76543211) = 3f123456,76543210 -line 26: copysign(bf123456,76543211 3f123456,76543210) = 3f123456,76543211 -line 27: copysign(bf123456,76543210 3f123456,76543210) = 3f123456,76543210 diff --git a/sys/arch/pmax/test/fp2_t b/sys/arch/pmax/test/fp2_t deleted file mode 100644 index 9e0389a21dfb..000000000000 --- a/sys/arch/pmax/test/fp2_t +++ /dev/null @@ -1,27 +0,0 @@ -0 0 80000000 0 -0 0 0 0 -3ff00000 0 0 0 -0 0 3ff00000 0 -0 1 0 0 -0 0 0 1 -0 32 0 69 -0 32 80000000 69 -3ff00000 0 3ff00000 0 -3ff00000 0 41200000 0 -3ff00000 1 41200000 0 -3f000000 1 41200000 0 -3f000000 1 41200000 1 -bf800000 0 0 0 -0 0 bf800000 0 -80000001 0 0 0 -0 0 80000001 0 -bf800000 0 3f800000 0 -3f800000 0 c1200000 0 -bf800001 0 41200000 0 -bf000001 0 41200000 0 -bf000001 0 41200001 0 -3f123456 76543210 bf123456 76543210 -3f123456 76543210 bf123456 76543211 -bf123456 76543210 3f123456 76543211 -bf123456 76543211 3f123456 76543210 -bf123456 76543210 3f123456 76543210 diff --git a/sys/arch/pmax/test/fp3.c b/sys/arch/pmax/test/fp3.c deleted file mode 100644 index 936d38325ae8..000000000000 --- a/sys/arch/pmax/test/fp3.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include - -int lineno; - -union { - unsigned w[2]; - double d; -} uda, udb, udc; - -/* - * Read test vectors from file and test the fp emulation by - * comparing it with the hardware. - */ -main(argc, argv) - int argc; - char **argv; -{ - register char *cp; - register int c; - char buf[10]; - unsigned arg[4]; - - for (lineno = 1; ; lineno++) { - c = scanf("%x %x", &arg[1], &arg[0]); - if (c < 0) - break; - if (c != 2) { - fprintf(stderr, "line %d: expected 2 args\n", - lineno); - goto skip; - } - - uda.w[0] = arg[0]; - uda.w[1] = arg[1]; - c = finite(uda.d); - - printf("line %d: finite(%x,%x) = %d, isnan %d, isinf %d\n", - lineno, uda.w[1], uda.w[0], c, - isnan(uda.d), isinf(uda.d)); - skip: - while ((c = getchar()) != EOF && c != '\n') - ; - } -} - -trapsignal(p, sig, code) - int p, sig, code; -{ - printf("line %d: signal(%d, %x)\n", lineno, sig, code); -} diff --git a/sys/arch/pmax/test/fp3_out b/sys/arch/pmax/test/fp3_out deleted file mode 100644 index 04aee8dc7ebe..000000000000 --- a/sys/arch/pmax/test/fp3_out +++ /dev/null @@ -1,10 +0,0 @@ -line 1: finite(0,0) = 1, isnan 0, isinf 0 -line 2: finite(80000000,0) = 1, isnan 0, isinf 0 -line 3: finite(3ff00000,0) = 1, isnan 0, isinf 0 -line 4: finite(bff00000,0) = 1, isnan 0, isinf 0 -line 5: finite(0,1) = 1, isnan 0, isinf 0 -line 6: finite(80000000,1) = 1, isnan 0, isinf 0 -line 7: finite(7ff00000,0) = 0, isnan 0, isinf 1 -line 8: finite(fff00000,0) = 0, isnan 0, isinf 1 -line 9: finite(7ff00000,ffffffff) = 0, isnan 1, isinf 0 -line 10: finite(fff80000,ffffffff) = 0, isnan 1, isinf 0 diff --git a/sys/arch/pmax/test/fp3_t b/sys/arch/pmax/test/fp3_t deleted file mode 100644 index c095bfb213d8..000000000000 --- a/sys/arch/pmax/test/fp3_t +++ /dev/null @@ -1,10 +0,0 @@ -0 0 -80000000 0 -3ff00000 0 -bff00000 0 -0 1 -80000000 1 -7ff00000 0 -fff00000 0 -7ff00000 ffffffff -fff80000 ffffffff diff --git a/sys/arch/pmax/test/fp4.c b/sys/arch/pmax/test/fp4.c deleted file mode 100644 index 61d96bdf8d0c..000000000000 --- a/sys/arch/pmax/test/fp4.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include - -int lineno; - -union { - unsigned w[2]; - double d; -} uda, udb, udc; - -/* - * Read test vectors from file and test the fp emulation by - * comparing it with the hardware. - */ -main(argc, argv) - int argc; - char **argv; -{ - register char *cp; - register int c; - char buf[10]; - unsigned arg[4]; - - for (lineno = 1; ; lineno++) { - c = scanf("%x %x", &arg[1], &arg[0]); - if (c < 0) - break; - if (c != 2) { - fprintf(stderr, "line %d: expected 2 args\n", - lineno); - goto skip; - } - - uda.w[0] = arg[0]; - uda.w[1] = arg[1]; - udc.d = logb(uda.d); - - printf("line %d: logb(%x,%x) = %x,%x (%d)\n", - lineno, uda.w[1], uda.w[0], - udc.w[1], udc.w[0], (int)udc.d); - skip: - while ((c = getchar()) != EOF && c != '\n') - ; - } -} - -trapsignal(p, sig, code) - int p, sig, code; -{ - printf("line %d: signal(%d, %x)\n", lineno, sig, code); -} diff --git a/sys/arch/pmax/test/fp4_out b/sys/arch/pmax/test/fp4_out deleted file mode 100644 index 42a051548c6b..000000000000 --- a/sys/arch/pmax/test/fp4_out +++ /dev/null @@ -1,12 +0,0 @@ -line 1: logb(0,0) = fff00000,0 (-2147483648) -line 2: logb(80000000,0) = fff00000,0 (-2147483648) -line 3: logb(3ff00000,0) = 0,0 (0) -line 4: logb(bff00000,0) = 0,0 (0) -line 5: logb(80000,0) = c08ff800,0 (-1023) -line 6: logb(0,80000000) = c0904c00,0 (-1043) -line 7: logb(0,1) = c090c800,0 (-1074) -line 8: logb(80000000,1) = c090c800,0 (-1074) -line 9: logb(7ff00000,0) = 7ff00000,0 (2147483647) -line 10: logb(fff00000,0) = 7ff00000,0 (2147483647) -line 11: logb(7ff00000,ffffffff) = 7ff00000,ffffffff (2147483647) -line 12: logb(fff80000,ffffffff) = fff80000,ffffffff (-2147483648) diff --git a/sys/arch/pmax/test/fp4_t b/sys/arch/pmax/test/fp4_t deleted file mode 100644 index b79c374eafa6..000000000000 --- a/sys/arch/pmax/test/fp4_t +++ /dev/null @@ -1,12 +0,0 @@ -0 0 -80000000 0 -3ff00000 0 -bff00000 0 -00080000 0 -00000000 80000000 -0 1 -80000000 1 -7ff00000 0 -fff00000 0 -7ff00000 ffffffff -fff80000 ffffffff diff --git a/sys/arch/pmax/test/fp5.c b/sys/arch/pmax/test/fp5.c deleted file mode 100644 index bb3b37345e34..000000000000 --- a/sys/arch/pmax/test/fp5.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include - -int lineno; - -union { - unsigned w[2]; - double d; -} uda, udb, udc; - -/* - * Read test vectors from file and test the fp emulation by - * comparing it with the hardware. - */ -main(argc, argv) - int argc; - char **argv; -{ - register char *cp; - register int c; - char buf[10]; - unsigned arg[4]; - - for (lineno = 1; ; lineno++) { - c = scanf("%x %x", &arg[1], &arg[0]); - if (c < 0) - break; - if (c != 2) { - fprintf(stderr, "line %d: expected 2 args\n", - lineno); - goto skip; - } - - uda.w[0] = arg[0]; - uda.w[1] = arg[1]; - udc.d = sqrt(uda.d); - - printf("line %d: sqrt(%x,%x) = %x,%x\n", - lineno, uda.w[1], uda.w[0], - udc.w[1], udc.w[0]); - skip: - while ((c = getchar()) != EOF && c != '\n') - ; - } -} - -trapsignal(p, sig, code) - int p, sig, code; -{ - printf("line %d: signal(%d, %x)\n", lineno, sig, code); -} diff --git a/sys/arch/pmax/test/fp6.c b/sys/arch/pmax/test/fp6.c deleted file mode 100644 index 5f1e91a1557f..000000000000 --- a/sys/arch/pmax/test/fp6.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include - -int lineno; - -union { - unsigned w[2]; - double d; -} uda, udb, udc; - -/* - * Read test vectors from file and test the fp emulation by - * comparing it with the hardware. - */ -main(argc, argv) - int argc; - char **argv; -{ - register char *cp; - register int c; - char buf[10]; - unsigned arg[4]; - - for (lineno = 1; ; lineno++) { - c = scanf("%x %x %d", &arg[1], &arg[0], &arg[2]); - if (c < 0) - break; - if (c != 3) { - fprintf(stderr, "line %d: expected 3 args\n", - lineno); - goto skip; - } - - uda.w[0] = arg[0]; - uda.w[1] = arg[1]; - udc.d = scalb(uda.d, arg[2]); - - printf("line %d: scalb(%x,%x,%d) = %x,%x\n", - lineno, uda.w[1], uda.w[0], arg[2], - udc.w[1], udc.w[0]); - skip: - while ((c = getchar()) != EOF && c != '\n') - ; - } -} - -trapsignal(p, sig, code) - int p, sig, code; -{ - printf("line %d: signal(%d, %x)\n", lineno, sig, code); -} diff --git a/sys/arch/pmax/test/fp6_out b/sys/arch/pmax/test/fp6_out deleted file mode 100644 index 1d132d55d861..000000000000 --- a/sys/arch/pmax/test/fp6_out +++ /dev/null @@ -1,23 +0,0 @@ -line 1: scalb(0,0,1) = 0,0 -line 2: scalb(80000000,0,3) = 80000000,0 -line 3: scalb(3ff00000,0,3) = 40200000,0 -line 4: scalb(3ff00000,0,1024) = 7ff00000,0 -line 5: scalb(bff00000,0,1025) = fff00000,0 -line 6: scalb(bff00000,0,2) = c0100000,0 -line 7: scalb(40500000,0,-3) = 40200000,0 -line 8: scalb(c0300000,0,-2) = c0100000,0 -line 9: scalb(80000,0,2046) = 7fe00000,0 -line 10: scalb(80000,0,2047) = 7ff00000,0 -line 11: scalb(80000,0,2) = 200000,0 -line 12: scalb(80000,0,1) = 100000,0 -line 13: scalb(80000,0,0) = c0000,0 -line 14: scalb(0,80000000,22) = 200000,0 -line 15: scalb(0,1,54) = 300000,0 -line 16: scalb(80000000,1,54) = 80300000,0 -line 17: scalb(7ff00000,0,1) = 7ff00000,0 -line 18: scalb(fff00000,0,1) = fff00000,0 -line 19: scalb(7ff00000,0,-1) = 7ff00000,0 -line 20: scalb(fff00000,0,-1) = fff00000,0 -line 21: scalb(7ff00000,ffffffff,1) = 7ff00000,ffffffff -line 22: scalb(fff80000,ffffffff,1) = fff80000,ffffffff -line 23: scalb(bff00000,0,-1023) = 80000,0 diff --git a/sys/arch/pmax/test/fp6_t b/sys/arch/pmax/test/fp6_t deleted file mode 100644 index ab673274dfaa..000000000000 --- a/sys/arch/pmax/test/fp6_t +++ /dev/null @@ -1,26 +0,0 @@ -0 0 1 -80000000 0 3 -3ff00000 0 3 -3ff00000 0 1024 -bff00000 0 1025 -bff00000 0 2 -40500000 0 -3 -c0300000 0 -2 -00080000 0 2046 -00080000 0 2047 -00080000 0 2 -00080000 0 1 -00080000 0 0 -00000000 80000000 22 -0 1 54 -80000000 1 54 -7ff00000 0 1 -fff00000 0 1 -7ff00000 0 -1 -fff00000 0 -1 -7ff00000 ffffffff 1 -fff80000 ffffffff 1 -bff00000 2 -1023 -bff00000 2 -1024 -bff00000 3 -1024 -bff00000 2 -1075 diff --git a/sys/arch/pmax/test/fp7.c b/sys/arch/pmax/test/fp7.c deleted file mode 100644 index 48973d854039..000000000000 --- a/sys/arch/pmax/test/fp7.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include -#include - -int lineno; - -union { - unsigned w[2]; - double d; -} uda, udb, udc; - -/* - * Read test vectors from file and test the fp emulation by - * comparing it with the hardware. - */ -main(argc, argv) - int argc; - char **argv; -{ - register char *cp; - register int c; - char buf[10]; - unsigned arg[4]; - - for (lineno = 1; ; lineno++) { - c = scanf("%x %x", &arg[1], &arg[0]); - if (c < 0) - break; - if (c != 2) { - fprintf(stderr, "line %d: expected 2 args\n", - lineno); - goto skip; - } - - uda.w[0] = arg[0]; - uda.w[1] = arg[1]; - - printf("line %d: (%x,%x) = %f\n", - lineno, uda.w[1], uda.w[0], uda.d); - skip: - while ((c = getchar()) != EOF && c != '\n') - ; - } -} - -trapsignal(p, sig, code) - int p, sig, code; -{ - printf("line %d: signal(%d, %x)\n", lineno, sig, code); -} diff --git a/sys/arch/pmax/test/fp7_t b/sys/arch/pmax/test/fp7_t deleted file mode 100644 index b79c374eafa6..000000000000 --- a/sys/arch/pmax/test/fp7_t +++ /dev/null @@ -1,12 +0,0 @@ -0 0 -80000000 0 -3ff00000 0 -bff00000 0 -00080000 0 -00000000 80000000 -0 1 -80000000 1 -7ff00000 0 -fff00000 0 -7ff00000 ffffffff -fff80000 ffffffff diff --git a/sys/arch/pmax/test/fp8.c b/sys/arch/pmax/test/fp8.c deleted file mode 100644 index 6fa7cd3994a5..000000000000 --- a/sys/arch/pmax/test/fp8.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include - -int lineno; - -union { - unsigned w[2]; - double d; -} uda, udb, udc; - -/* - * Read test vectors from file and test the fp emulation by - * comparing it with the hardware. - */ -main(argc, argv) - int argc; - char **argv; -{ - register char *cp; - register int c; - char buf[10]; - unsigned arg[4]; - - for (lineno = 1; ; lineno++) { - c = scanf("%x %x", &arg[1], &arg[0]); - if (c < 0) - break; - if (c != 2) { - fprintf(stderr, "line %d: expected 2 args\n", - lineno); - goto skip; - } - - uda.w[0] = arg[0]; - uda.w[1] = arg[1]; - udc.d = modf(uda.d, &udb.d); - - printf("line %d: modf(%x,%x) = %x,%x int %x,%x\n", - lineno, uda.w[1], uda.w[0], - udc.w[1], udc.w[0], udb.w[1], udb.w[0]); - skip: - while ((c = getchar()) != EOF && c != '\n') - ; - } -} - -trapsignal(p, sig, code) - int p, sig, code; -{ - printf("line %d: signal(%d, %x)\n", lineno, sig, code); -} diff --git a/sys/arch/pmax/test/fp8_t b/sys/arch/pmax/test/fp8_t deleted file mode 100644 index ff8479295c32..000000000000 --- a/sys/arch/pmax/test/fp8_t +++ /dev/null @@ -1,15 +0,0 @@ -0 0 -80000000 0 -3ff00000 0 -bff00000 0 -3ff80000 0 -3ffc0000 1 -400c0000 1 -00080000 0 -00000000 80000000 -0 1 -80000000 1 -7ff00000 0 -fff00000 0 -7ff00000 ffffffff -fff80000 ffffffff diff --git a/sys/arch/pmax/test/fp_t b/sys/arch/pmax/test/fp_t deleted file mode 100644 index 7f823b0152ae..000000000000 --- a/sys/arch/pmax/test/fp_t +++ /dev/null @@ -1,844 +0,0 @@ -add.s 0 80000000 -add.s 0 0 -add.s 3f800000 0 -add.s 0 3f800000 -add.s 1 0 -add.s 0 1 -add.s 3f800000 3f800000 -add.s 3f800000 41200000 -add.s 3f800001 41200000 -add.s 3f000001 41200000 -add.s 3f000001 41200001 -add.s bf800000 0 -add.s 0 bf800000 -add.s 80000001 0 -add.s 0 80000001 -add.s bf800000 3f800000 -add.s 3f800000 c1200000 -add.s bf800001 41200000 -add.s bf000001 41200000 -add.s bf000001 41200001 -add.s 3f123456 bf123456 -add.s 0 ff800000 -add.s ff800000 0 -add.s ff800000 ff800000 -add.s 7f800000 ff800000 -add.d 0 0 80000000 0 -add.d 0 0 0 0 -add.d 3ff00000 0 0 0 -add.d 0 0 3ff00000 0 -add.d 0 1 0 0 -add.d 0 0 0 1 -add.d 0 32 0 69 -add.d 0 32 80000000 69 -add.d 3ff00000 0 3ff00000 0 -add.d 3ff00000 0 41200000 0 -add.d 3ff00000 1 41200000 0 -add.d 3f000000 1 41200000 0 -add.d 3f000000 1 41200000 1 -add.d bf800000 0 0 0 -add.d 0 0 bf800000 0 -add.d 80000001 0 0 0 -add.d 0 0 80000001 0 -add.d bf800000 0 3f800000 0 -add.d 3f800000 0 c1200000 0 -add.d bf800001 0 41200000 0 -add.d bf000001 0 41200000 0 -add.d bf000001 0 41200001 0 -add.d 3f123456 76543210 bf123456 76543210 -add.d 3f123456 76543210 bf123456 76543211 -add.d bf123456 76543210 3f123456 76543211 -add.d bf123456 76543211 3f123456 76543210 -add.d bf123456 76543210 3f123456 76543210 -sub.s 0 80000000 -sub.s 0 0 -sub.s 3f800000 0 -sub.s 0 3f800000 -sub.s 1 0 -sub.s 0 1 -sub.s 3f800000 3f800000 -sub.s 3f800000 41200000 -sub.s 3f800001 41200000 -sub.s 3f000001 41200000 -sub.s 3f000001 41200001 -sub.s bf800000 0 -sub.s 0 bf800000 -sub.s 80000001 0 -sub.s 0 80000001 -sub.s bf800000 3f800000 -sub.s 3f800000 c1200000 -sub.s bf800001 41200000 -sub.s bf000001 41200000 -sub.s bf000001 41200001 -sub.s 3f123456 bf123456 -sub.s 0 ff800000 -sub.s ff800000 0 -sub.s ff800000 ff800000 -sub.s 7f800000 ff800000 -sub.d 0 0 80000000 0 -sub.d 0 0 0 0 -sub.d 3ff00000 0 0 0 -sub.d 0 0 3ff00000 0 -sub.d 0 1 0 0 -sub.d 0 0 0 1 -sub.d 3ff00000 0 3ff00000 0 -sub.d 3ff00000 0 41200000 0 -sub.d 3ff00000 1 41200000 0 -sub.d 3f000000 1 41200000 0 -sub.d 3f000000 1 41200000 1 -sub.d bf800000 0 0 0 -sub.d 0 0 bf800000 0 -sub.d 80000001 0 0 0 -sub.d 0 0 80000001 0 -sub.d bf800000 0 3f800000 0 -sub.d 3f800000 0 c1200000 0 -sub.d bf800001 0 41200000 0 -sub.d bf000001 0 41200000 0 -sub.d bf000001 0 41200001 0 -sub.d 3f123456 76543210 bf123456 76543210 -sub.d 3f123456 76543210 bf123456 76543211 -sub.d bf123456 76543210 3f123456 76543211 -sub.d bf123456 76543211 3f123456 76543210 -sub.d bf123456 76543210 3f123456 76543210 -mul.s 0 80000000 -mul.s 0 0 -mul.s 3f800000 0 -mul.s 0 3f800000 -mul.s 1 0 -mul.s 0 1 -mul.s 3f800000 3f800000 -mul.s 3f800000 41200000 -mul.s 3f800001 41200000 -mul.s 3f000001 41200000 -mul.s 3f000001 41200001 -mul.s bf800000 0 -mul.s 0 bf800000 -mul.s 80000001 0 -mul.s 0 80000001 -mul.s bf800000 3f800000 -mul.s 3f800000 c1200000 -mul.s bf800001 41200000 -mul.s bf000001 41200000 -mul.s bf000001 41200001 -mul.s 3f123456 bf123456 -mul.s 0 ff800000 -mul.s ff800000 0 -mul.s ff800000 ff800000 -mul.s 7f800000 ff800000 -mul.d 0 0 80000000 0 -mul.d 0 0 0 0 -mul.d 3ff00000 0 0 0 -mul.d 0 0 3ff00000 0 -mul.d 0 1 0 0 -mul.d 0 0 0 1 -mul.d 3ff00000 0 3ff00000 0 -mul.d 3ff00000 0 41200000 0 -mul.d 3ff00000 1 41200000 0 -mul.d 3f000000 1 41200000 0 -mul.d 3f000000 1 41200000 1 -mul.d bf800000 0 0 0 -mul.d 0 0 bf800000 0 -mul.d 80000001 0 0 0 -mul.d 0 0 80000001 0 -mul.d bf800000 0 3f800000 0 -mul.d 3f800000 0 c1200000 0 -mul.d bf800001 0 41200000 0 -mul.d bf000001 0 41200000 0 -mul.d bf000001 0 41200001 0 -mul.d 3f123456 76543210 bf123456 76543210 -mul.d 3f123456 76543210 bf123456 76543211 -mul.d bf123456 76543210 3f123456 76543211 -mul.d bf123456 76543211 3f123456 76543210 -mul.d bf123456 76543210 3f123456 76543210 -mul.d 0 0 fff00000 0 -mul.d fff00000 0 fff00000 0 -mul.d 7ff00000 0 fff00000 0 -div.s 0 ff800000 -div.s ff800000 0 -div.s ff800000 ff800000 -div.s 1 ff800000 -div.s ff800000 1 -div.s ff800000 ff800000 -div.s 1 1 -div.s 3ff12348 3f800000 -div.s 0 80000000 -div.s 0 0 -div.s 3f800000 0 -div.s 0 3f800000 -div.s 1 0 -div.s 0 1 -div.s 3f800000 3f800000 -div.s 3f800000 41200000 -div.s 3f800001 41200000 -div.s 3f000001 41200000 -div.s 3f000001 41200001 -div.s bf800000 0 -div.s 0 bf800000 -div.s 80000001 0 -div.s 0 80000001 -div.s bf800000 3f800000 -div.s 3f800000 c1200000 -div.s bf800001 41200000 -div.s bf000001 41200000 -div.s bf000001 41200001 -div.s 3f123456 bf123456 -div.s 0 ff800000 -div.s ff800000 0 -div.s ff800000 ff800000 -div.s 7f800000 ff800000 -div.d 0 0 80000000 0 -div.d 0 0 0 0 -div.d 3ff00000 0 0 0 -div.d 0 0 3ff00000 0 -div.d 0 1 0 0 -div.d 0 0 0 1 -div.d 3ff00000 0 3ff00000 0 -div.d 3ff00000 0 41200000 0 -div.d 3ff00000 1 41200000 0 -div.d 3f000000 1 41200000 0 -div.d 3f000000 1 41200000 1 -div.d bf800000 0 0 0 -div.d 0 0 bf800000 0 -div.d 80000001 0 0 0 -div.d 0 0 80000001 0 -div.d bf800000 0 3f800000 0 -div.d 3f800000 0 c1200000 0 -div.d bf800001 0 41200000 0 -div.d bf000001 0 41200000 0 -div.d bf000001 0 41200001 0 -div.d 3f123456 76543210 bf123456 76543210 -div.d 3f123456 76543210 bf123456 76543211 -div.d bf123456 76543210 3f123456 76543211 -div.d bf123456 76543211 3f123456 76543210 -div.d bf123456 76543210 3f123456 76543210 -div.d 0 0 fff00000 0 -div.d fff00000 0 fff00000 0 -div.d 7ff00000 0 fff00000 0 -abs.s 0 -abs.s 80000000 -abs.s 3f812345 -abs.s bf812345 -abs.s 7f800000 -abs.s ff800000 -abs.d 0 0 -abs.d 80000000 0 -abs.d 3ff12345 87654321 -abs.d bff12345 87654321 -abs.d 7ff00000 0 -abs.d fff00000 0 -mov.s 0 -mov.s 80000000 -mov.s 3f812345 -mov.s bf812345 -mov.s 7f800000 -mov.s ff800000 -mov.d 0 0 -mov.d 80000000 0 -mov.d 3ff12345 87654321 -mov.d bff12345 87654321 -mov.d 7ff00000 0 -mov.d fff00000 0 -neg.s 0 -neg.s 80000000 -neg.s 3f812345 -neg.s bf812345 -neg.s 7f800000 -neg.s ff800000 -neg.d 0 0 -neg.d 80000000 0 -neg.d 3ff12345 87654321 -neg.d bff12345 87654321 -neg.d 7ff00000 0 -neg.d fff00000 0 -cvt.w.s 0 -cvt.w.s 32 -cvt.w.s 80000000 -cvt.w.s 3f812345 -cvt.w.s bf812345 -cvt.w.s 7f800000 -cvt.w.s ff800000 -cvt.w.d 0 0 -cvt.w.d 0 32 -cvt.w.d 80000000 0 -cvt.w.d 3ff12345 87654321 -cvt.w.d bff12345 87654321 -cvt.w.d 7ff00000 0 -cvt.w.d fff00000 0 -cvt.w.d 41e00000 0 -cvt.w.d c1f00000 0 -cvt.w.d 41bfffff ffe00000 -cvt.w.d 41bfffff fff00000 -cvt.w.d c1e00000 0 -cvt.s.d 0 0 -cvt.s.d 0 32 -cvt.s.d 80000000 0 -cvt.s.d 3ff12345 87654321 -cvt.s.d bff12345 87654321 -cvt.s.d 7ff00000 0 -cvt.s.d fff00000 0 -cvt.s.d 41e00000 0 -cvt.s.d c1f00000 0 -cvt.s.d 41bfffff ffe00000 -cvt.s.d 41bfffff fff00000 -cvt.s.d c1e00000 0 -cvt.s.w 0 -cvt.s.w 32 -cvt.s.w ffff0000 -cvt.s.w 80000000 -cvt.s.w 7fffffff -cvt.d.s 0 -cvt.d.s 32 -cvt.d.s 80000000 -cvt.d.s 3f812345 -cvt.d.s bf812345 -cvt.d.s 7f800000 -cvt.d.s ff800000 -cvt.d.w 0 -cvt.d.w 32 -cvt.d.w ffff0000 -cvt.d.w 80000000 -cvt.d.w 7fffffff -c.f.s 0 80000000 -c.f.s 0 0 -c.f.s 80000000 0 -c.f.s 0 3f800000 -c.f.s bf800000 3f800000 -c.f.s bf800000 bf800001 -c.f.s 80000001 80000002 -c.f.s 00000001 00000002 -c.f.s ff800000 7f800000 -c.f.s 3f800000 0 -c.f.s 3f800000 bf800000 -c.f.s bf800001 bf800000 -c.f.s 80000002 80000001 -c.f.s 00000002 00000001 -c.f.s 7f800000 ff800000 -c.f.s 7f800001 0 -c.f.s 0 7f800001 -c.un.s 0 80000000 -c.un.s 0 0 -c.un.s 80000000 0 -c.un.s 0 3f800000 -c.un.s bf800000 3f800000 -c.un.s bf800000 bf800001 -c.un.s 80000001 80000002 -c.un.s 00000001 00000002 -c.un.s ff800000 7f800000 -c.un.s 3f800000 0 -c.un.s 3f800000 bf800000 -c.un.s bf800001 bf800000 -c.un.s 80000002 80000001 -c.un.s 00000002 00000001 -c.un.s 7f800000 ff800000 -c.un.s 7f800001 0 -c.un.s 0 7f800001 -c.eq.s 0 80000000 -c.eq.s 0 0 -c.eq.s 80000000 0 -c.eq.s 0 3f800000 -c.eq.s bf800000 3f800000 -c.eq.s bf800000 bf800001 -c.eq.s 80000001 80000002 -c.eq.s 00000001 00000002 -c.eq.s ff800000 7f800000 -c.eq.s 3f800000 0 -c.eq.s 3f800000 bf800000 -c.eq.s bf800001 bf800000 -c.eq.s 80000002 80000001 -c.eq.s 00000002 00000001 -c.eq.s 7f800000 ff800000 -c.eq.s 7f800001 0 -c.eq.s 0 7f800001 -c.ueq.s 0 80000000 -c.ueq.s 0 0 -c.ueq.s 80000000 0 -c.ueq.s 0 3f800000 -c.ueq.s bf800000 3f800000 -c.ueq.s bf800000 bf800001 -c.ueq.s 80000001 80000002 -c.ueq.s 00000001 00000002 -c.ueq.s ff800000 7f800000 -c.ueq.s 3f800000 0 -c.ueq.s 3f800000 bf800000 -c.ueq.s bf800001 bf800000 -c.ueq.s 80000002 80000001 -c.ueq.s 00000002 00000001 -c.ueq.s 7f800000 ff800000 -c.ueq.s 7f800001 0 -c.ueq.s 0 7f800001 -c.olt.s 0 80000000 -c.olt.s 0 0 -c.olt.s 80000000 0 -c.olt.s 0 3f800000 -c.olt.s bf800000 3f800000 -c.olt.s bf800000 bf800001 -c.olt.s 80000001 80000002 -c.olt.s 00000001 00000002 -c.olt.s ff800000 7f800000 -c.olt.s 3f800000 0 -c.olt.s 3f800000 bf800000 -c.olt.s bf800001 bf800000 -c.olt.s 80000002 80000001 -c.olt.s 00000002 00000001 -c.olt.s 7f800000 ff800000 -c.olt.s 7f800001 0 -c.olt.s 0 7f800001 -c.ult.s 0 80000000 -c.ult.s 0 0 -c.ult.s 80000000 0 -c.ult.s 0 3f800000 -c.ult.s bf800000 3f800000 -c.ult.s bf800000 bf800001 -c.ult.s 80000001 80000002 -c.ult.s 00000001 00000002 -c.ult.s ff800000 7f800000 -c.ult.s 3f800000 0 -c.ult.s 3f800000 bf800000 -c.ult.s bf800001 bf800000 -c.ult.s 80000002 80000001 -c.ult.s 00000002 00000001 -c.ult.s 7f800000 ff800000 -c.ult.s 7f800001 0 -c.ult.s 0 7f800001 -c.ole.s 0 80000000 -c.ole.s 0 0 -c.ole.s 80000000 0 -c.ole.s 0 3f800000 -c.ole.s bf800000 3f800000 -c.ole.s bf800000 bf800001 -c.ole.s 80000001 80000002 -c.ole.s 00000001 00000002 -c.ole.s ff800000 7f800000 -c.ole.s 3f800000 0 -c.ole.s 3f800000 bf800000 -c.ole.s bf800001 bf800000 -c.ole.s 80000002 80000001 -c.ole.s 00000002 00000001 -c.ole.s 7f800000 ff800000 -c.ole.s 7f800001 0 -c.ole.s 0 7f800001 -c.ule.s 0 80000000 -c.ule.s 0 0 -c.ule.s 80000000 0 -c.ule.s 0 3f800000 -c.ule.s bf800000 3f800000 -c.ule.s bf800000 bf800001 -c.ule.s 80000001 80000002 -c.ule.s 00000001 00000002 -c.ule.s ff800000 7f800000 -c.ule.s 3f800000 0 -c.ule.s 3f800000 bf800000 -c.ule.s bf800001 bf800000 -c.ule.s 80000002 80000001 -c.ule.s 00000002 00000001 -c.ule.s 7f800000 ff800000 -c.ule.s 7f800001 0 -c.ule.s 0 7f800001 -c.sf.s 0 80000000 -c.sf.s 0 0 -c.sf.s 80000000 0 -c.sf.s 0 3f800000 -c.sf.s bf800000 3f800000 -c.sf.s bf800000 bf800001 -c.sf.s 80000001 80000002 -c.sf.s 00000001 00000002 -c.sf.s ff800000 7f800000 -c.sf.s 3f800000 0 -c.sf.s 3f800000 bf800000 -c.sf.s bf800001 bf800000 -c.sf.s 80000002 80000001 -c.sf.s 00000002 00000001 -c.sf.s 7f800000 ff800000 -c.sf.s 7f800001 0 -c.sf.s 0 7f800001 -c.ngle.s 0 80000000 -c.ngle.s 0 0 -c.ngle.s 80000000 0 -c.ngle.s 0 3f800000 -c.ngle.s bf800000 3f800000 -c.ngle.s bf800000 bf800001 -c.ngle.s 80000001 80000002 -c.ngle.s 00000001 00000002 -c.ngle.s ff800000 7f800000 -c.ngle.s 3f800000 0 -c.ngle.s 3f800000 bf800000 -c.ngle.s bf800001 bf800000 -c.ngle.s 80000002 80000001 -c.ngle.s 00000002 00000001 -c.ngle.s 7f800000 ff800000 -c.ngle.s 7f800001 0 -c.ngle.s 0 7f800001 -c.seq.s 0 80000000 -c.seq.s 0 0 -c.seq.s 80000000 0 -c.seq.s 0 3f800000 -c.seq.s bf800000 3f800000 -c.seq.s bf800000 bf800001 -c.seq.s 80000001 80000002 -c.seq.s 00000001 00000002 -c.seq.s ff800000 7f800000 -c.seq.s 3f800000 0 -c.seq.s 3f800000 bf800000 -c.seq.s bf800001 bf800000 -c.seq.s 80000002 80000001 -c.seq.s 00000002 00000001 -c.seq.s 7f800000 ff800000 -c.seq.s 7f800001 0 -c.seq.s 0 7f800001 -c.ngl.s 0 80000000 -c.ngl.s 0 0 -c.ngl.s 80000000 0 -c.ngl.s 0 3f800000 -c.ngl.s bf800000 3f800000 -c.ngl.s bf800000 bf800001 -c.ngl.s 80000001 80000002 -c.ngl.s 00000001 00000002 -c.ngl.s ff800000 7f800000 -c.ngl.s 3f800000 0 -c.ngl.s 3f800000 bf800000 -c.ngl.s bf800001 bf800000 -c.ngl.s 80000002 80000001 -c.ngl.s 00000002 00000001 -c.ngl.s 7f800000 ff800000 -c.ngl.s 7f800001 0 -c.ngl.s 0 7f800001 -c.lt.s 0 80000000 -c.lt.s 0 0 -c.lt.s 80000000 0 -c.lt.s 0 3f800000 -c.lt.s bf800000 3f800000 -c.lt.s bf800000 bf800001 -c.lt.s 80000001 80000002 -c.lt.s 00000001 00000002 -c.lt.s ff800000 7f800000 -c.lt.s 3f800000 0 -c.lt.s 3f800000 bf800000 -c.lt.s bf800001 bf800000 -c.lt.s 80000002 80000001 -c.lt.s 00000002 00000001 -c.lt.s 7f800000 ff800000 -c.lt.s 7f800001 0 -c.lt.s 0 7f800001 -c.nge.s 0 80000000 -c.nge.s 0 0 -c.nge.s 80000000 0 -c.nge.s 0 3f800000 -c.nge.s bf800000 3f800000 -c.nge.s bf800000 bf800001 -c.nge.s 80000001 80000002 -c.nge.s 00000001 00000002 -c.nge.s ff800000 7f800000 -c.nge.s 3f800000 0 -c.nge.s 3f800000 bf800000 -c.nge.s bf800001 bf800000 -c.nge.s 80000002 80000001 -c.nge.s 00000002 00000001 -c.nge.s 7f800000 ff800000 -c.nge.s 7f800001 0 -c.nge.s 0 7f800001 -c.le.s 0 80000000 -c.le.s 0 0 -c.le.s 80000000 0 -c.le.s 0 3f800000 -c.le.s bf800000 3f800000 -c.le.s bf800000 bf800001 -c.le.s 80000001 80000002 -c.le.s 00000001 00000002 -c.le.s ff800000 7f800000 -c.le.s 3f800000 0 -c.le.s 3f800000 bf800000 -c.le.s bf800001 bf800000 -c.le.s 80000002 80000001 -c.le.s 00000002 00000001 -c.le.s 7f800000 ff800000 -c.le.s 7f800001 0 -c.le.s 0 7f800001 -c.ngt.s 0 80000000 -c.ngt.s 0 0 -c.ngt.s 80000000 0 -c.ngt.s 0 3f800000 -c.ngt.s bf800000 3f800000 -c.ngt.s bf800000 bf800001 -c.ngt.s 80000001 80000002 -c.ngt.s 00000001 00000002 -c.ngt.s ff800000 7f800000 -c.ngt.s 3f800000 0 -c.ngt.s 3f800000 bf800000 -c.ngt.s bf800001 bf800000 -c.ngt.s 80000002 80000001 -c.ngt.s 00000002 00000001 -c.ngt.s 7f800000 ff800000 -c.ngt.s 7f800001 0 -c.ngt.s 0 7f800001 -c.f.d 0 0 80000000 0 -c.f.d 0 0 0 0 -c.f.d 80000000 0 0 0 -c.f.d 0 0 3ff00000 0 -c.f.d bff00000 0 3ff00000 0 -c.f.d bff00000 0 bff00000 1 -c.f.d 80000000 1 80000000 2 -c.f.d 00000000 1 00000000 2 -c.f.d fff00000 0 7ff00000 0 -c.f.d 3ff00000 0 0 0 -c.f.d 3ff00000 0 bff00000 0 -c.f.d bff00001 1 bff00000 0 -c.f.d 80000000 2 80000000 1 -c.f.d 00000000 2 00000000 1 -c.f.d 7ff00000 0 fff00000 0 -c.f.d 7ff00000 1 0 0 -c.f.d 0 0 7ff00000 1 -c.un.d 0 0 80000000 0 -c.un.d 0 0 0 0 -c.un.d 80000000 0 0 0 -c.un.d 0 0 3ff00000 0 -c.un.d bff00000 0 3ff00000 0 -c.un.d bff00000 0 bff00000 1 -c.un.d 80000000 1 80000000 2 -c.un.d 00000000 1 00000000 2 -c.un.d fff00000 0 7ff00000 0 -c.un.d 3ff00000 0 0 0 -c.un.d 3ff00000 0 bff00000 0 -c.un.d bff00001 1 bff00000 0 -c.un.d 80000000 2 80000000 1 -c.un.d 00000000 2 00000000 1 -c.un.d 7ff00000 0 fff00000 0 -c.un.d 7ff00000 1 0 0 -c.un.d 0 0 7ff00000 1 -c.eq.d 0 0 80000000 0 -c.eq.d 0 0 0 0 -c.eq.d 80000000 0 0 0 -c.eq.d 0 0 3ff00000 0 -c.eq.d bff00000 0 3ff00000 0 -c.eq.d bff00000 0 bff00000 1 -c.eq.d 80000000 1 80000000 2 -c.eq.d 00000000 1 00000000 2 -c.eq.d fff00000 0 7ff00000 0 -c.eq.d 3ff00000 0 0 0 -c.eq.d 3ff00000 0 bff00000 0 -c.eq.d bff00001 1 bff00000 0 -c.eq.d 80000000 2 80000000 1 -c.eq.d 00000000 2 00000000 1 -c.eq.d 7ff00000 0 fff00000 0 -c.eq.d 7ff00000 1 0 0 -c.eq.d 0 0 7ff00000 1 -c.ueq.d 0 0 80000000 0 -c.ueq.d 0 0 0 0 -c.ueq.d 80000000 0 0 0 -c.ueq.d 0 0 3ff00000 0 -c.ueq.d bff00000 0 3ff00000 0 -c.ueq.d bff00000 0 bff00000 1 -c.ueq.d 80000000 1 80000000 2 -c.ueq.d 00000000 1 00000000 2 -c.ueq.d fff00000 0 7ff00000 0 -c.ueq.d 3ff00000 0 0 0 -c.ueq.d 3ff00000 0 bff00000 0 -c.ueq.d bff00001 1 bff00000 0 -c.ueq.d 80000000 2 80000000 1 -c.ueq.d 00000000 2 00000000 1 -c.ueq.d 7ff00000 0 fff00000 0 -c.ueq.d 7ff00000 1 0 0 -c.ueq.d 0 0 7ff00000 1 -c.olt.d 0 0 80000000 0 -c.olt.d 0 0 0 0 -c.olt.d 80000000 0 0 0 -c.olt.d 0 0 3ff00000 0 -c.olt.d bff00000 0 3ff00000 0 -c.olt.d bff00000 0 bff00000 1 -c.olt.d 80000000 1 80000000 2 -c.olt.d 00000000 1 00000000 2 -c.olt.d fff00000 0 7ff00000 0 -c.olt.d 3ff00000 0 0 0 -c.olt.d 3ff00000 0 bff00000 0 -c.olt.d bff00001 1 bff00000 0 -c.olt.d 80000000 2 80000000 1 -c.olt.d 00000000 2 00000000 1 -c.olt.d 7ff00000 0 fff00000 0 -c.olt.d 7ff00000 1 0 0 -c.olt.d 0 0 7ff00000 1 -c.ult.d 0 0 80000000 0 -c.ult.d 0 0 0 0 -c.ult.d 80000000 0 0 0 -c.ult.d 0 0 3ff00000 0 -c.ult.d bff00000 0 3ff00000 0 -c.ult.d bff00000 0 bff00000 1 -c.ult.d 80000000 1 80000000 2 -c.ult.d 00000000 1 00000000 2 -c.ult.d fff00000 0 7ff00000 0 -c.ult.d 3ff00000 0 0 0 -c.ult.d 3ff00000 0 bff00000 0 -c.ult.d bff00001 1 bff00000 0 -c.ult.d 80000000 2 80000000 1 -c.ult.d 00000000 2 00000000 1 -c.ult.d 7ff00000 0 fff00000 0 -c.ult.d 7ff00000 1 0 0 -c.ult.d 0 0 7ff00000 1 -c.ole.d 0 0 80000000 0 -c.ole.d 0 0 0 0 -c.ole.d 80000000 0 0 0 -c.ole.d 0 0 3ff00000 0 -c.ole.d bff00000 0 3ff00000 0 -c.ole.d bff00000 0 bff00000 1 -c.ole.d 80000000 1 80000000 2 -c.ole.d 00000000 1 00000000 2 -c.ole.d fff00000 0 7ff00000 0 -c.ole.d 3ff00000 0 0 0 -c.ole.d 3ff00000 0 bff00000 0 -c.ole.d bff00001 1 bff00000 0 -c.ole.d 80000000 2 80000000 1 -c.ole.d 00000000 2 00000000 1 -c.ole.d 7ff00000 0 fff00000 0 -c.ole.d 7ff00000 1 0 0 -c.ole.d 0 0 7ff00000 1 -c.ule.d 0 0 80000000 0 -c.ule.d 0 0 0 0 -c.ule.d 80000000 0 0 0 -c.ule.d 0 0 3ff00000 0 -c.ule.d bff00000 0 3ff00000 0 -c.ule.d bff00000 0 bff00000 1 -c.ule.d 80000000 1 80000000 2 -c.ule.d 00000000 1 00000000 2 -c.ule.d fff00000 0 7ff00000 0 -c.ule.d 3ff00000 0 0 0 -c.ule.d 3ff00000 0 bff00000 0 -c.ule.d bff00001 1 bff00000 0 -c.ule.d 80000000 2 80000000 1 -c.ule.d 00000000 2 00000000 1 -c.ule.d 7ff00000 0 fff00000 0 -c.ule.d 7ff00000 1 0 0 -c.ule.d 0 0 7ff00000 1 -c.sf.d 0 0 80000000 0 -c.sf.d 0 0 0 0 -c.sf.d 80000000 0 0 0 -c.sf.d 0 0 3ff00000 0 -c.sf.d bff00000 0 3ff00000 0 -c.sf.d bff00000 0 bff00000 1 -c.sf.d 80000000 1 80000000 2 -c.sf.d 00000000 1 00000000 2 -c.sf.d fff00000 0 7ff00000 0 -c.sf.d 3ff00000 0 0 0 -c.sf.d 3ff00000 0 bff00000 0 -c.sf.d bff00001 1 bff00000 0 -c.sf.d 80000000 2 80000000 1 -c.sf.d 00000000 2 00000000 1 -c.sf.d 7ff00000 0 fff00000 0 -c.sf.d 7ff00000 1 0 0 -c.sf.d 0 0 7ff00000 1 -c.ngle.d 0 0 80000000 0 -c.ngle.d 0 0 0 0 -c.ngle.d 80000000 0 0 0 -c.ngle.d 0 0 3ff00000 0 -c.ngle.d bff00000 0 3ff00000 0 -c.ngle.d bff00000 0 bff00000 1 -c.ngle.d 80000000 1 80000000 2 -c.ngle.d 00000000 1 00000000 2 -c.ngle.d fff00000 0 7ff00000 0 -c.ngle.d 3ff00000 0 0 0 -c.ngle.d 3ff00000 0 bff00000 0 -c.ngle.d bff00001 1 bff00000 0 -c.ngle.d 80000000 2 80000000 1 -c.ngle.d 00000000 2 00000000 1 -c.ngle.d 7ff00000 0 fff00000 0 -c.ngle.d 7ff00000 1 0 0 -c.ngle.d 0 0 7ff00000 1 -c.seq.d 0 0 80000000 0 -c.seq.d 0 0 0 0 -c.seq.d 80000000 0 0 0 -c.seq.d 0 0 3ff00000 0 -c.seq.d bff00000 0 3ff00000 0 -c.seq.d bff00000 0 bff00000 1 -c.seq.d 80000000 1 80000000 2 -c.seq.d 00000000 1 00000000 2 -c.seq.d fff00000 0 7ff00000 0 -c.seq.d 3ff00000 0 0 0 -c.seq.d 3ff00000 0 bff00000 0 -c.seq.d bff00001 1 bff00000 0 -c.seq.d 80000000 2 80000000 1 -c.seq.d 00000000 2 00000000 1 -c.seq.d 7ff00000 0 fff00000 0 -c.seq.d 7ff00000 1 0 0 -c.seq.d 0 0 7ff00000 1 -c.ngl.d 0 0 80000000 0 -c.ngl.d 0 0 0 0 -c.ngl.d 80000000 0 0 0 -c.ngl.d 0 0 3ff00000 0 -c.ngl.d bff00000 0 3ff00000 0 -c.ngl.d bff00000 0 bff00000 1 -c.ngl.d 80000000 1 80000000 2 -c.ngl.d 00000000 1 00000000 2 -c.ngl.d fff00000 0 7ff00000 0 -c.ngl.d 3ff00000 0 0 0 -c.ngl.d 3ff00000 0 bff00000 0 -c.ngl.d bff00001 1 bff00000 0 -c.ngl.d 80000000 2 80000000 1 -c.ngl.d 00000000 2 00000000 1 -c.ngl.d 7ff00000 0 fff00000 0 -c.ngl.d 7ff00000 1 0 0 -c.ngl.d 0 0 7ff00000 1 -c.lt.d 0 0 80000000 0 -c.lt.d 0 0 0 0 -c.lt.d 80000000 0 0 0 -c.lt.d 0 0 3ff00000 0 -c.lt.d bff00000 0 3ff00000 0 -c.lt.d bff00000 0 bff00000 1 -c.lt.d 80000000 1 80000000 2 -c.lt.d 00000000 1 00000000 2 -c.lt.d fff00000 0 7ff00000 0 -c.lt.d 3ff00000 0 0 0 -c.lt.d 3ff00000 0 bff00000 0 -c.lt.d bff00001 1 bff00000 0 -c.lt.d 80000000 2 80000000 1 -c.lt.d 00000000 2 00000000 1 -c.lt.d 7ff00000 0 fff00000 0 -c.lt.d 7ff00000 1 0 0 -c.lt.d 0 0 7ff00000 1 -c.nge.d 0 0 80000000 0 -c.nge.d 0 0 0 0 -c.nge.d 80000000 0 0 0 -c.nge.d 0 0 3ff00000 0 -c.nge.d bff00000 0 3ff00000 0 -c.nge.d bff00000 0 bff00000 1 -c.nge.d 80000000 1 80000000 2 -c.nge.d 00000000 1 00000000 2 -c.nge.d fff00000 0 7ff00000 0 -c.nge.d 3ff00000 0 0 0 -c.nge.d 3ff00000 0 bff00000 0 -c.nge.d bff00001 1 bff00000 0 -c.nge.d 80000000 2 80000000 1 -c.nge.d 00000000 2 00000000 1 -c.nge.d 7ff00000 0 fff00000 0 -c.nge.d 7ff00000 1 0 0 -c.nge.d 0 0 7ff00000 1 -c.le.d 0 0 80000000 0 -c.le.d 0 0 0 0 -c.le.d 80000000 0 0 0 -c.le.d 0 0 3ff00000 0 -c.le.d bff00000 0 3ff00000 0 -c.le.d bff00000 0 bff00000 1 -c.le.d 80000000 1 80000000 2 -c.le.d 00000000 1 00000000 2 -c.le.d fff00000 0 7ff00000 0 -c.le.d 3ff00000 0 0 0 -c.le.d 3ff00000 0 bff00000 0 -c.le.d bff00001 1 bff00000 0 -c.le.d 80000000 2 80000000 1 -c.le.d 00000000 2 00000000 1 -c.le.d 7ff00000 0 fff00000 0 -c.le.d 7ff00000 1 0 0 -c.le.d 0 0 7ff00000 1 -c.ngt.d 0 0 80000000 0 -c.ngt.d 0 0 0 0 -c.ngt.d 80000000 0 0 0 -c.ngt.d 0 0 3ff00000 0 -c.ngt.d bff00000 0 3ff00000 0 -c.ngt.d bff00000 0 bff00000 1 -c.ngt.d 80000000 1 80000000 2 -c.ngt.d 00000000 1 00000000 2 -c.ngt.d fff00000 0 7ff00000 0 -c.ngt.d 3ff00000 0 0 0 -c.ngt.d 3ff00000 0 bff00000 0 -c.ngt.d bff00001 1 bff00000 0 -c.ngt.d 80000000 2 80000000 1 -c.ngt.d 00000000 2 00000000 1 -c.ngt.d 7ff00000 0 fff00000 0 -c.ngt.d 7ff00000 1 0 0 -c.ngt.d 0 0 7ff00000 1 diff --git a/sys/arch/pmax/test/fptest.c b/sys/arch/pmax/test/fptest.c deleted file mode 100644 index 3e73817943e3..000000000000 --- a/sys/arch/pmax/test/fptest.c +++ /dev/null @@ -1,202 +0,0 @@ -#include "/usr/include.orig/signal.h" -#include -#include - -unsigned fp_res[3], em_res[3]; /* place for the result */ -unsigned curproc; /* not used */ -int lineno; - -union { - unsigned w; - float f; -} uf; - -union { - unsigned w[2]; - double d; -} ud; - -struct optab { - char *name; /* MIPS opcode name */ - int nargs; /* number of integer arguments needed */ - int nresult; /* number of integer words for the result */ -} optab[] = { - "add.s", 2, 1, - "add.d", 4, 2, - "sub.s", 2, 1, - "sub.d", 4, 2, - "mul.s", 2, 1, - "mul.d", 4, 2, - "div.s", 2, 1, - "div.d", 4, 2, - "abs.s", 1, 1, - "abs.d", 2, 2, - "mov.s", 1, 1, - "mov.d", 2, 2, - "neg.s", 1, 1, - "neg.d", 2, 2, - "cvt.s.d", 2, 1, - "cvt.s.w", 1, 1, - "cvt.d.s", 1, 2, - "cvt.d.w", 1, 2, - "cvt.w.s", 1, 1, - "cvt.w.d", 2, 1, - "c.f.s", 2, 0, - "c.un.s", 2, 0, - "c.eq.s", 2, 0, - "c.ueq.s", 2, 0, - "c.olt.s", 2, 0, - "c.ult.s", 2, 0, - "c.ole.s", 2, 0, - "c.ule.s", 2, 0, - "c.sf.s", 2, 0, - "c.ngle.s", 2, 0, - "c.seq.s", 2, 0, - "c.ngl.s", 2, 0, - "c.lt.s", 2, 0, - "c.nge.s", 2, 0, - "c.le.s", 2, 0, - "c.ngt.s", 2, 0, - "c.f.d", 4, 0, - "c.un.d", 4, 0, - "c.eq.d", 4, 0, - "c.ueq.d", 4, 0, - "c.olt.d", 4, 0, - "c.ult.d", 4, 0, - "c.ole.d", 4, 0, - "c.ule.d", 4, 0, - "c.sf.d", 4, 0, - "c.ngle.d", 4, 0, - "c.seq.d", 4, 0, - "c.ngl.d", 4, 0, - "c.lt.d", 4, 0, - "c.nge.d", 4, 0, - "c.le.d", 4, 0, - "c.ngt.d", 4, 0, -}; - -/* - * Read test vectors from file and test the fp emulation by - * comparing it with the hardware. - */ -main(argc, argv) - int argc; - char **argv; -{ - register char *cp; - register int c; - register struct optab *op; - char buf[10]; - unsigned arg[4]; - - signal(SIGFPE, SIG_IGN); - for (lineno = 1; ; lineno++) { - /* read opcode */ - for (cp = buf; ; ) { - c = getchar(); - if (c == EOF) - return (0); - if (isspace(c)) - break; - *cp++ = c; - } - *cp = '\0'; - if (buf[0] == '\0') { - if (c == '\n') - continue; - goto skip; - } - for (op = optab; op->name; op++) { - if (strcmp(op->name, buf) == 0) - goto fnd; - } - fprintf(stderr, "line %d: unknown operation '%s'\n", - lineno, buf); - goto skip; - fnd: - switch (op->nargs) { - case 1: - if (scanf("%x", &arg[0]) != 1) { - fprintf(stderr, "line %d: expected 1 arg\n", - lineno); - goto skip; - } - arg[1] = arg[2] = arg[3] = 0; - break; - case 2: - if (scanf("%x %x", &arg[0], &arg[2]) != 2) { - fprintf(stderr, "line %d: expected 2 args\n", - lineno); - goto skip; - } - if (op->nresult == 1) { - arg[1] = arg[0]; - arg[0] = arg[2]; - arg[2] = arg[3] = 0; - } else if (op->nresult == 2) { - arg[1] = arg[2]; - arg[2] = arg[3] = 0; - } else { - arg[1] = arg[3] = 0; - } - break; - case 4: - if (scanf("%x %x %x %x", &arg[1], &arg[0], - &arg[3], &arg[2]) != 4) { - fprintf(stderr, "line %d: expected 4 args\n", - lineno); - goto skip; - } - break; - } - - c = op - optab; - dofp(c, arg[0], arg[1], arg[2], arg[3]); - emfp(c, arg[0], arg[1], arg[2], arg[3]); - - switch (op->nresult) { - case 0: - if (fp_res[2] != em_res[2]) { - printf("line %d: (%d) %s %x,%x %x,%x\n", - lineno, c, buf, - arg[0], arg[1], arg[2], arg[3]); - printf("\tcsr %x != %x\n", - fp_res[2], em_res[2]); - } - break; - case 1: - if (fp_res[0] != em_res[0] || - fp_res[2] != em_res[2]) { - printf("line %d: (%d) %s %x,%x %x,%x\n", - lineno, c, buf, - arg[0], arg[1], arg[2], arg[3]); - printf("\t%x != %x (csr %x %x)\n", - fp_res[0], em_res[0], - fp_res[2], em_res[2]); - } - break; - case 2: - if (fp_res[0] != em_res[0] || - fp_res[1] != em_res[1] || - fp_res[2] != em_res[2]) { - printf("line %d: (%d) %s %x,%x %x,%x\n", - lineno, c, buf, - arg[0], arg[1], arg[2], arg[3]); - printf("\t%x,%x != %x,%x (csr %x %x)\n", - fp_res[0], fp_res[1], - em_res[0], em_res[1], - fp_res[2], em_res[2]); - } - break; - } - skip: - while ((c = getchar()) != EOF && c != '\n') - ; - } -} - -trapsignal(p, sig, code) - int p, sig, code; -{ - printf("line %d: signal(%d, %x)\n", lineno, sig, code); -} diff --git a/sys/arch/pmax/test/fptest1.s b/sys/arch/pmax/test/fptest1.s deleted file mode 100644 index 47526779da9b..000000000000 --- a/sys/arch/pmax/test/fptest1.s +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Routines for floating point emulation testing. - */ - -#include -#include -#include - - .rdata -jtab: - .word add_s - .word add_d - .word sub_s - .word sub_d - .word mul_s - .word mul_d - .word div_s - .word div_d - .word abs_s - .word abs_d - .word mov_s - .word mov_d - .word neg_s - .word neg_d - .word cvt_s_d - .word cvt_s_w - .word cvt_d_s - .word cvt_d_w - .word cvt_w_s - .word cvt_w_d - .word c_f_s - .word c_un_s - .word c_eq_s - .word c_ueq_s - .word c_olt_s - .word c_ult_s - .word c_ole_s - .word c_ule_s - .word c_sf_s - .word c_ngle_s - .word c_seq_s - .word c_ngl_s - .word c_lt_s - .word c_nge_s - .word c_le_s - .word c_ngt_s - .word c_f_d - .word c_un_d - .word c_eq_d - .word c_ueq_d - .word c_olt_d - .word c_ult_d - .word c_ole_d - .word c_ule_d - .word c_sf_d - .word c_ngle_d - .word c_seq_d - .word c_ngl_d - .word c_lt_d - .word c_nge_d - .word c_le_d - .word c_ngt_d - .text - -LEAF(dofp) - cfc1 v0, MACH_FPC_CSR - lw t1, 16(sp) # get 4th arg - mtc1 a1, $f4 - mtc1 a2, $f5 - mtc1 a3, $f6 - mtc1 t1, $f7 - ctc1 zero, MACH_FPC_CSR - sll a0, a0, 2 # index into jump table - lw t0, jtab(a0) - j t0 - -add_s: - add.s $f0, $f4, $f6 - b done -add_d: - add.d $f0, $f4, $f6 - b done -sub_s: - sub.s $f0, $f4, $f6 - b done -sub_d: - sub.d $f0, $f4, $f6 - b done -mul_s: - mul.s $f0, $f4, $f6 - b done -mul_d: - mul.d $f0, $f4, $f6 - b done -div_s: - div.s $f0, $f4, $f6 - b done -div_d: - div.d $f0, $f4, $f6 - b done -abs_s: - abs.s $f0, $f4 - b done -abs_d: - abs.d $f0, $f4 - b done -mov_s: - mov.s $f0, $f4 - b done -mov_d: - mov.d $f0, $f4 - b done -neg_s: - neg.s $f0, $f4 - b done -neg_d: - neg.d $f0, $f4 - b done -cvt_s_d: - cvt.s.d $f0, $f4 - b done -cvt_s_w: - cvt.s.w $f0, $f4 - b done -cvt_d_s: - cvt.d.s $f0, $f4 - b done -cvt_d_w: - cvt.d.w $f0, $f4 - b done -cvt_w_s: - cvt.w.s $f0, $f4 - b done -cvt_w_d: - cvt.w.d $f0, $f4 - b done -c_f_s: - c.f.s $f4, $f6 - b done -c_un_s: - c.un.s $f4, $f6 - b done -c_eq_s: - c.eq.s $f4, $f6 - b done -c_ueq_s: - c.ueq.s $f4, $f6 - b done -c_olt_s: - c.olt.s $f4, $f6 - b done -c_ult_s: - c.ult.s $f4, $f6 - b done -c_ole_s: - c.ole.s $f4, $f6 - b done -c_ule_s: - c.ule.s $f4, $f6 - b done -c_sf_s: - c.sf.s $f4, $f6 - b done -c_ngle_s: - c.ngle.s $f4, $f6 - b done -c_seq_s: - c.seq.s $f4, $f6 - b done -c_ngl_s: - c.ngl.s $f4, $f6 - b done -c_lt_s: - c.lt.s $f4, $f6 - b done -c_nge_s: - c.nge.s $f4, $f6 - b done -c_le_s: - c.le.s $f4, $f6 - b done -c_ngt_s: - c.ngt.s $f4, $f6 - b done -c_f_d: - c.f.d $f4, $f6 - b done -c_un_d: - c.un.d $f4, $f6 - b done -c_eq_d: - c.eq.d $f4, $f6 - b done -c_ueq_d: - c.ueq.d $f4, $f6 - b done -c_olt_d: - c.olt.d $f4, $f6 - b done -c_ult_d: - c.ult.d $f4, $f6 - b done -c_ole_d: - c.ole.d $f4, $f6 - b done -c_ule_d: - c.ule.d $f4, $f6 - b done -c_sf_d: - c.sf.d $f4, $f6 - b done -c_ngle_d: - c.ngle.d $f4, $f6 - b done -c_seq_d: - c.seq.d $f4, $f6 - b done -c_ngl_d: - c.ngl.d $f4, $f6 - b done -c_lt_d: - c.lt.d $f4, $f6 - b done -c_nge_d: - c.nge.d $f4, $f6 - b done -c_le_d: - c.le.d $f4, $f6 - b done -c_ngt_d: - c.ngt.d $f4, $f6 -done: - cfc1 t0, MACH_FPC_CSR - mfc1 v0, $f0 - mfc1 v1, $f1 - sw t0, fp_res+8 - sw v0, fp_res - sw v1, fp_res+4 - j ra -END(dofp) - - .rdata -itab: - .word 0x46062000 # add.s f0,f4,f6 - .word 0x46262000 # add.d f0,f4,f6 - .word 0x46062001 # sub.s f0,f4,f6 - .word 0x46262001 # sub.d f0,f4,f6 - .word 0x46062002 # mul.s f0,f4,f6 - .word 0x46262002 # mul.d f0,f4,f6 - .word 0x46062003 # div.s f0,f4,f6 - .word 0x46262003 # div.d f0,f4,f6 - .word 0x46002005 # abs.s f0,f4 - .word 0x46202005 # abs.d f0,f4 - .word 0x46002006 # mov.s f0,f4 - .word 0x46202006 # mov.d f0,f4 - .word 0x46002007 # neg.s f0,f4,f0 - .word 0x46202007 # neg.d f0,f4,f0 - .word 0x46202020 # cvt.s.d f0,f4 - .word 0x46802020 # cvt.s.w f0,f4 - .word 0x46002021 # cvt.d.s f0,f4 - .word 0x46802021 # cvt.d.w f0,f4 - .word 0x46002024 # cvt.w.s f0,f4 - .word 0x46202024 # cvt.w.d f0,f4 - .word 0x46062030 # c.f.s f4,f6 - .word 0x46062031 # c.un.s f4,f6 - .word 0x46062032 # c.eq.s f4,f6 - .word 0x46062033 # c.ueq.s f4,f6 - .word 0x46062034 # c.olt.s f4,f6 - .word 0x46062035 # c.ult.s f4,f6 - .word 0x46062036 # c.ole.s f4,f6 - .word 0x46062037 # c.ule.s f4,f6 - .word 0x46062038 # c.sf.s f4,f6 - .word 0x46062039 # c.ngle.s f4,f6 - .word 0x4606203a # c.seq.s f4,f6 - .word 0x4606203b # c.ngl.s f4,f6 - .word 0x4606203c # c.lt.s f4,f6 - .word 0x4606203d # c.nge.s f4,f6 - .word 0x4606203e # c.le.s f4,f6 - .word 0x4606203f # c.ngt.s f4,f6 - .word 0x46262030 # c.f.d f4,f6 - .word 0x46262031 # c.un.d f4,f6 - .word 0x46262032 # c.eq.d f4,f6 - .word 0x46262033 # c.ueq.d f4,f6 - .word 0x46262034 # c.olt.d f4,f6 - .word 0x46262035 # c.ult.d f4,f6 - .word 0x46262036 # c.ole.d f4,f6 - .word 0x46262037 # c.ule.d f4,f6 - .word 0x46262038 # c.sf.d f4,f6 - .word 0x46262039 # c.ngle.d f4,f6 - .word 0x4626203a # c.seq.d f4,f6 - .word 0x4626203b # c.ngl.d f4,f6 - .word 0x4626203c # c.lt.d f4,f6 - .word 0x4626203d # c.nge.d f4,f6 - .word 0x4626203e # c.le.d f4,f6 - .word 0x4626203f # c.ngt.d f4,f6 - .text - -NON_LEAF(emfp, STAND_FRAME_SIZE, ra) - subu sp, sp, STAND_FRAME_SIZE - sw ra, STAND_RA_OFFSET(sp) - .mask 0x80000000, (STAND_RA_OFFSET - STAND_FRAME_SIZE) - - cfc1 v0, MACH_FPC_CSR - lw t1, STAND_FRAME_SIZE+16(sp) # get 4th arg - mtc1 a1, $f4 - mtc1 a2, $f5 - mtc1 a3, $f6 - mtc1 t1, $f7 - ctc1 zero, MACH_FPC_CSR - sll a0, a0, 2 # index into instruction table - lw a0, itab(a0) - - jal MachEmulateFP - - cfc1 t0, MACH_FPC_CSR - mfc1 v0, $f0 - mfc1 v1, $f1 - sw t0, em_res+8 - sw v0, em_res - sw v1, em_res+4 - lw ra, STAND_RA_OFFSET(sp) - addu sp, sp, STAND_FRAME_SIZE - j ra -END(emfp) diff --git a/sys/arch/pmax/test/sum.c b/sys/arch/pmax/test/sum.c deleted file mode 100644 index b6b4f87f3af5..000000000000 --- a/sys/arch/pmax/test/sum.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include - -/* - * Print simple check sum for text and data section. - */ -void -main(argc, argv) - int argc; - char **argv; -{ - register int fd, i, n; - char *fname; - struct coff_exec ex; - int tsum, dsum, word; - - if (argc < 2) { - printf("usage: sum \n"); - goto err; - } - if ((fd = open(fname = argv[1], 0)) < 0) - goto err; - - /* read the COFF header */ - i = read(fd, (char *)&ex, sizeof(ex)); - if (i != sizeof(ex) || COFF_BADMAG(ex)) { - printf("No COFF header\n"); - goto cerr; - } - if (lseek(fd, COFF_TEXTOFF(ex), 0)) { - perror("lseek"); - goto cerr; - } - tsum = 0; - for (n = ex.aouthdr.tsize; n > 0; n -= sizeof(int)) { - if (read(fd, &word, sizeof(word)) != sizeof(word)) { - perror("read text"); - goto cerr; - } - tsum += word; - } - dsum = 0; - for (n = ex.aouthdr.dsize; n > 0; n -= sizeof(int)) { - if (read(fd, &word, sizeof(word)) != sizeof(word)) { - perror("read data"); - goto cerr; - } - dsum += word; - } - printf("tsum %d dsum %d\n", tsum, dsum); - -cerr: - close(fd); -err: - exit(0); -} diff --git a/sys/arch/pmax/test/t01.c b/sys/arch/pmax/test/t01.c deleted file mode 100644 index ebeafbe3b44c..000000000000 --- a/sys/arch/pmax/test/t01.c +++ /dev/null @@ -1,9 +0,0 @@ -main(argc, argv) - char **argv; -{ - int fd = open("/dev/console", 1); - - if (fd >= 0) - write(fd, "Hello\n", 6); - return(0); -} diff --git a/sys/arch/pmax/test/t02.c b/sys/arch/pmax/test/t02.c deleted file mode 100644 index 8f66f5706b7e..000000000000 --- a/sys/arch/pmax/test/t02.c +++ /dev/null @@ -1,13 +0,0 @@ -main(argc, argv) - int argc; - char **argv; -{ - register int i; - int fd = open("/dev/console", 1); - - for (i = 0; i= 0) - write(fd, hello, 6); - return(0); -} diff --git a/sys/arch/pmax/test/t04.c b/sys/arch/pmax/test/t04.c deleted file mode 100644 index 38f74c78818e..000000000000 --- a/sys/arch/pmax/test/t04.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -main(argc, argv) - char **argv; -{ - int fin = open("/dev/console", 0); - int fout = open("/dev/console", 1); - int ferr = open("/dev/console", 1); - int pid; - - switch(pid = fork()) { - case 0: /* child */ - printf("child\n"); - return(1); - case -1: - perror("fork"); - return(2); - - default: - printf("parent %d\n", pid); - } - return(0); -} diff --git a/sys/arch/pmax/test/t05.c b/sys/arch/pmax/test/t05.c deleted file mode 100644 index 0bd68530f3fd..000000000000 --- a/sys/arch/pmax/test/t05.c +++ /dev/null @@ -1,19 +0,0 @@ -main(argc, argv) - char **argv; -{ - int fout = open("/dev/console", 1); - - switch(fork()) { - case 0: /* child */ - write(fout, "child\n", 6); - return(1); - - case -1: - write(fout, "error\n", 6); - return(2); - - default: - write(fout, "parent\n", 7); - return(0); - } -} diff --git a/sys/arch/pmax/test/t05.s b/sys/arch/pmax/test/t05.s deleted file mode 100644 index a58acc462ffb..000000000000 --- a/sys/arch/pmax/test/t05.s +++ /dev/null @@ -1,720 +0,0 @@ - __start: - 0x4000f0: 2402002d li v0,45 - 0x4000f4: 0000000c syscall - 0x4000f8: 8fa40000 lw a0,0(sp) - 0x4000fc: 27a50004 addiu a1,sp,4 - 0x400100: 3c1c1001 lui gp,0x1001 - 0x400104: 24a60004 addiu a2,a1,4 - 0x400108: 00041080 sll v0,a0,2 - 0x40010c: 279c8030 addiu gp,gp,-32720 - 0x400110: 00c23021 addu a2,a2,v0 - 0x400114: 27bdffe8 addiu sp,sp,-24 - 0x400118: af868040 sw a2,-32704(gp) - 0x40011c: 0c100050 jal main - 0x400120: afa00014 sw zero,20(sp) - 0x400124: 0c100078 jal 0x4001e0 - 0x400128: 00402021 move a0,v0 - 0x40012c: 0000000d break 0 - moncontrol: - 0x400130: 03e00008 jr ra - 0x400134: 00000000 nop - _mcount: - 0x400138: 03e00008 jr ra - 0x40013c: 00000000 nop - main: - 0x400140: 27bdffd8 addiu sp,sp,-40 - 0x400144: afa40028 sw a0,40(sp) - 0x400148: afbf001c sw ra,28(sp) - 0x40014c: afa5002c sw a1,44(sp) - 0x400150: 3c041000 lui a0,0x1000 - 0x400154: afb00018 sw s0,24(sp) - 0x400158: 24840000 addiu a0,a0,0 - 0x40015c: 0c1000a4 jal 0x400290 # open - 0x400160: 24050001 li a1,1 - 0x400164: 0c1000b5 jal 0x4002d4 # fork - 0x400168: afa20024 sw v0,36(sp) - 0x40016c: 00408021 move s0,v0 - 0x400170: 2401ffff li at,-1 - 0x400174: 1201000a beq s0,at,0x4001a0 - 0x400178: 8fa40024 lw a0,36(sp) - 0x40017c: 1600000e bne s0,zero,0x4001b8 - 0x400180: 8fa40024 lw a0,36(sp) - 0x400184: 8fa40024 lw a0,36(sp) # child - 0x400188: 27858010 addiu a1,gp,-32752 - 0x40018c: 0c1000c0 jal 0x400300 - 0x400190: 24060006 li a2,6 - 0x400194: 1000000c b 0x4001c8 - 0x400198: 24020001 li v0,1 - 0x40019c: 8fa40024 lw a0,36(sp) - 0x4001a0: 27858017 addiu a1,gp,-32745 # error - 0x4001a4: 0c1000c0 jal 0x400300 - 0x4001a8: 24060006 li a2,6 - 0x4001ac: 10000006 b 0x4001c8 - 0x4001b0: 24020002 li v0,2 - 0x4001b4: 8fa40024 lw a0,36(sp) - 0x4001b8: 2785801e addiu a1,gp,-32738 # parent - 0x4001bc: 0c1000c0 jal 0x400300 - 0x4001c0: 24060007 li a2,7 - 0x4001c4: 00001021 move v0,zero - 0x4001c8: 8fbf001c lw ra,28(sp) - 0x4001cc: 8fb00018 lw s0,24(sp) - 0x4001d0: 03e00008 jr ra - 0x4001d4: 27bd0028 addiu sp,sp,40 - 0x4001d8: 00000000 nop - 0x4001dc: 00000000 nop - 0x4001e0: 8f828044 lw v0,-32700(gp) - 0x4001e4: 27bdffc8 addiu sp,sp,-56 - 0x4001e8: afb20018 sw s2,24(sp) - 0x4001ec: afbf001c sw ra,28(sp) - 0x4001f0: afa40038 sw a0,56(sp) - 0x4001f4: 10400018 beq v0,zero,0x400258 - 0x4001f8: 00409021 move s2,v0 - 0x4001fc: afb00024 sw s0,36(sp) - 0x400200: afb10020 sw s1,32(sp) - 0x400204: 8e420004 lw v0,4(s2) - 0x400208: 00000000 nop - 0x40020c: 2442ffff addiu v0,v0,-1 - 0x400210: 0440000a bltz v0,0x40023c - 0x400214: 00000000 nop - 0x400218: 00028080 sll s0,v0,2 - 0x40021c: 02508821 addu s1,s2,s0 - 0x400220: 8e2e0008 lw t6,8(s1) - 0x400224: 00000000 nop - 0x400228: 01c0f809 jalr ra,t6 - 0x40022c: 00000000 nop - 0x400230: 2610fffc addiu s0,s0,-4 - 0x400234: 0601fffa bgez s0,0x400220 - 0x400238: 2631fffc addiu s1,s1,-4 - 0x40023c: 8e520000 lw s2,0(s2) - 0x400240: 00000000 nop - 0x400244: 1640ffef bne s2,zero,0x400204 - 0x400248: 00000000 nop - 0x40024c: 8fb00024 lw s0,36(sp) - 0x400250: 8fb10020 lw s1,32(sp) - 0x400254: 00000000 nop - 0x400258: 8f828048 lw v0,-32696(gp) - 0x40025c: 00000000 nop - 0x400260: 10400003 beq v0,zero,0x400270 - 0x400264: 00000000 nop - 0x400268: 0040f809 jalr ra,v0 - 0x40026c: 00000000 nop - 0x400270: 8fa40038 lw a0,56(sp) - 0x400274: 0c1000c8 jal 0x400320 - 0x400278: 00000000 nop - 0x40027c: 8fbf001c lw ra,28(sp) - 0x400280: 8fb20018 lw s2,24(sp) - 0x400284: 03e00008 jr ra - 0x400288: 27bd0038 addiu sp,sp,56 - 0x40028c: 00000000 nop - 0x400290: 24020005 li v0,5 - 0x400294: 0000000c syscall - 0x400298: 14e00003 bne a3,zero,0x4002a8 - 0x40029c: 00000000 nop - 0x4002a0: 03e00008 jr ra - 0x4002a4: 00000000 nop - 0x4002a8: 081000d9 j 0x400364 - 0x4002ac: 00000000 nop - 0x4002b0: 29232840 slti v1,t1,10304 - 0x4002b4: 6b726f66 op68 s2,k1,28518 - 0x4002b8: 3520732e ori zero,t1,0x732e - 0x4002bc: 2820312e slti zero,at,12590 - 0x4002c0: 6b726542 op68 s2,k1,25922 - 0x4002c4: 79656c65 op78 a1,t3,27749 - 0x4002c8: 2f352029 sltiu s5,t9,8233 - 0x4002cc: 392f3231 xori t7,t1,0x3231 - 0x4002d0: 00000030 spec60 zero,zero,zero - 0x4002d4: 24020002 li v0,2 - 0x4002d8: 0000000c syscall - 0x4002dc: 14e00006 bne a3,zero,0x4002f8 - 0x4002e0: 00000000 nop - 0x4002e4: 10600002 beq v1,zero,0x4002f0 - 0x4002e8: 00000000 nop - 0x4002ec: 00001021 move v0,zero - 0x4002f0: 03e00008 jr ra - 0x4002f4: 00000000 nop - 0x4002f8: 081000d9 j 0x400364 - 0x4002fc: 00000000 nop - 0x400300: 24020004 li v0,4 - 0x400304: 0000000c syscall - 0x400308: 14e00003 bne a3,zero,0x400318 - 0x40030c: 00000000 nop - 0x400310: 03e00008 jr ra - 0x400314: 00000000 nop - 0x400318: 081000d9 j 0x400364 - 0x40031c: 00000000 nop - 0x400320: 24020001 li v0,1 - 0x400324: 0000000c syscall - 0x400328: 14e00003 bne a3,zero,0x400338 - 0x40032c: 00000000 nop - 0x400330: 03e00008 jr ra - 0x400334: 00000000 nop - 0x400338: 081000d9 j 0x400364 - 0x40033c: 00000000 nop - 0x400340: 29232840 slti v1,t1,10304 - 0x400344: 72726563 op70 s2,s3,25955 - 0x400348: 732e726f op70 t6,t9,29295 - 0x40034c: 312e3520 andi t6,t1,0x3520 - 0x400350: 65422820 op64 v0,t2,10272 - 0x400354: 6c656b72 op6c a1,v1,27506 - 0x400358: 20297965 addi t1,at,31077 - 0x40035c: 32312f35 andi s1,s1,0x2f35 - 0x400360: 0030392f spec57 a3,at,s0 - 0x400364: 3c011000 lui at,0x1000 - 0x400368: ac22007c sw v0,124(at) - 0x40036c: 03e00008 jr ra - 0x400370: 2402ffff li v0,-1 - 0x400374: 00000000 nop - 0x400378: 00000000 nop - 0x40037c: 00000000 nop - 0x400380: 29232840 slti v1,t1,10304 - 0x400384: 6c727265 op6c s2,v1,29285 - 0x400388: 632e7473 op60 t6,t9,29811 - 0x40038c: 312e3509 andi t6,t1,0x3509 - 0x400390: 42282030 c0 c0op48 - 0x400394: 656b7265 op64 t3,t3,29285 - 0x400398: 2979656c slti t9,t3,25964 - 0x40039c: 312f3220 andi t7,t1,0x3220 - 0x4003a0: 31392f39 andi t9,t1,0x2f39 - 0x4003a4: 00000000 nop - 0x4003a8: 004004e8 spec50 zero,v0,zero - 0x4003ac: 004004fb spec73 zero,v0,zero - 0x4003b0: 00400513 mtlo v0 - 0x4003b4: 0040052d spec55 zero,v0,zero - 0x4003b8: 0040053d spec75 zero,v0,zero - 0x4003bc: 00400555 spec25 zero,v0,zero - 0x4003c0: 00400568 spec50 zero,v0,zero - 0x4003c4: 0040057e spec76 zero,v0,zero - 0x4003c8: 00400595 spec25 zero,v0,zero - 0x4003cc: 004005a7 nor zero,v0,zero - 0x4003d0: 004005bb spec73 zero,v0,zero - 0x4003d4: 004005ce vcall 64,23 - 0x4003d8: 004005e8 spec50 zero,v0,zero - 0x4003dc: 004005ff spec77 zero,v0,zero - 0x4003e0: 00400611 mthi v0 - 0x4003e4: 0040061d spec35 zero,v0,zero - 0x4003e8: 00400633 spec63 zero,v0,zero - 0x4003ec: 0040063f spec77 zero,v0,zero - 0x4003f0: 0040064b spec13 zero,v0,zero - 0x4003f4: 0040065d spec35 zero,v0,zero - 0x4003f8: 0040067f spec77 zero,v0,zero - 0x4003fc: 0040068f spec17 zero,v0,zero - 0x400400: 0040069e spec36 zero,v0,zero - 0x400404: 004006af spec57 zero,v0,zero - 0x400408: 004006cd break 64,27 - 0x40040c: 004006e1 move zero,v0 - 0x400410: 00400700 sll zero,zero,28 - 0x400414: 0040070f spec17 zero,v0,zero - 0x400418: 0040071e spec36 zero,v0,zero - 0x40041c: 00400736 spec66 zero,v0,zero - 0x400420: 00400743 sra zero,zero,29 - 0x400424: 00400759 multu v0,zero - 0x400428: 00400768 spec50 zero,v0,zero - 0x40042c: 00400774 spec64 zero,v0,zero - 0x400430: 00400795 spec25 zero,v0,zero - 0x400434: 004007a6 xor zero,v0,zero - 0x400438: 004007c7 srav zero,zero,v0 - 0x40043c: 004007e1 move zero,v0 - 0x400440: 004007ff spec77 zero,v0,zero - 0x400444: 0040081e spec36 at,v0,zero - 0x400448: 0040083b spec73 at,v0,zero - 0x40044c: 0040084c syscall - 0x400450: 0040086b sltu at,v0,zero - 0x400454: 00400882 srl at,zero,2 - 0x400458: 00400899 multu v0,zero - 0x40045c: 004008b3 spec63 at,v0,zero - 0x400460: 004008cb spec13 at,v0,zero - 0x400464: 004008e9 spec51 at,v0,zero - 0x400468: 00400919 multu v0,zero - 0x40046c: 00400930 spec60 at,v0,zero - 0x400470: 0040094f spec17 at,v0,zero - 0x400474: 0040095f spec37 at,v0,zero - 0x400478: 00400976 spec66 at,v0,zero - 0x40047c: 0040099a div v0,zero - 0x400480: 004009bb spec73 at,v0,zero - 0x400484: 004009d4 spec24 at,v0,zero - 0x400488: 004009ee spec56 at,v0,zero - 0x40048c: 00400a0a spec12 at,v0,zero - 0x400490: 00400a22 sub at,v0,zero - 0x400494: 00400a43 sra at,zero,9 - 0x400498: 00400a65 or at,v0,zero - 0x40049c: 00400a7a spec72 at,v0,zero - 0x4004a0: 00400a8d break 64,42 - 0x4004a4: 00400aaf spec57 at,v0,zero - 0x4004a8: 00400ac2 srl at,zero,11 - 0x4004ac: 00400acf spec17 at,v0,zero - 0x4004b0: 00400ae0 add at,v0,zero - 0x4004b4: 00400af4 spec64 at,v0,zero - 0x4004b8: 00400b07 srav at,zero,v0 - 0x4004bc: 00400b16 spec26 at,v0,zero - 0x4004c0: 00400b2a slt at,v0,zero - 0x4004c4: 00400b40 sll at,zero,13 - 0x4004c8: 00400b62 sub at,v0,zero - 0x4004cc: 00400b74 spec64 at,v0,zero - 0x4004d0: 00400b86 srlv at,zero,v0 - 0x4004d4: 00400b9a div v0,zero - 0x4004d8: 00400bb0 spec60 at,v0,zero - 0x4004dc: 00400bca spec12 at,v0,zero - 0x4004e0: 00400bdd spec35 at,v0,zero - 0x4004e4: 00400bf6 spec66 at,v0,zero - 0x4004e8: 65646e55 op64 a0,t3,28245 - 0x4004ec: 656e6966 op64 t6,t3,26982 - 0x4004f0: 72652064 op70 a1,s3,8292 - 0x4004f4: 3a726f72 xori s2,s3,0x6f72 - 0x4004f8: 4f003020 c0 c0op32 - 0x4004fc: 61726570 op60 s2,t3,25968 - 0x400500: 6e6f6974 op6c t7,s3,26996 - 0x400504: 746f6e20 op74 t7,v1,28192 - 0x400508: 72657020 op70 a1,s3,28704 - 0x40050c: 7474696d op74 s4,v1,26989 - 0x400510: 4e006465 c0 c0op37 - 0x400514: 7573206f op74 s3,t3,8303 - 0x400518: 66206863 op64 zero,s1,26723 - 0x40051c: 20656c69 addi a1,v1,27753 - 0x400520: 6420726f op64 zero,at,29295 - 0x400524: 63657269 op60 a1,k1,29289 - 0x400528: 79726f74 op78 s2,t3,28532 - 0x40052c: 206f4e00 addi t7,v1,19968 - 0x400530: 68637573 op68 v1,v1,30067 - 0x400534: 6f727020 op6c s2,k1,28704 - 0x400538: 73736563 op70 s3,k1,25955 - 0x40053c: 746e4900 op74 t6,v1,18688 - 0x400540: 75727265 op74 s2,t3,29285 - 0x400544: 64657470 op64 a1,v1,29808 - 0x400548: 73797320 op70 t9,k1,29472 - 0x40054c: 206d6574 addi t5,v1,25972 - 0x400550: 6c6c6163 op6c t4,v1,24931 - 0x400554: 706e4900 op70 t6,v1,18688 - 0x400558: 6f2f7475 op6c t7,t9,29813 - 0x40055c: 75707475 op74 s0,t3,29813 - 0x400560: 72652074 op70 a1,s3,8308 - 0x400564: 00726f72 spec62 t5,v1,s2 - 0x400568: 69766544 op68 s6,t3,25924 - 0x40056c: 6e206563 op6c zero,s1,25955 - 0x400570: 6320746f op60 zero,t9,29807 - 0x400574: 69666e6f op68 a2,t3,28271 - 0x400578: 65727567 op64 s2,t3,30055 - 0x40057c: 72410064 op70 at,s2,100 - 0x400580: 656d7567 op64 t5,t3,30055 - 0x400584: 6c20746e op6c zero,at,29806 - 0x400588: 20747369 addi s4,v1,29545 - 0x40058c: 206f6f74 addi t7,v1,28532 - 0x400590: 676e6f6c op64 t6,k1,28524 - 0x400594: 65784500 op64 t8,t3,17664 - 0x400598: 6f662063 op6c a2,k1,8291 - 0x40059c: 74616d72 op74 at,v1,28018 - 0x4005a0: 72726520 op70 s2,s3,25888 - 0x4005a4: 4200726f c0 c0op47 - 0x4005a8: 66206461 op64 zero,s1,25697 - 0x4005ac: 20656c69 addi a1,v1,27753 - 0x4005b0: 63736564 op60 s3,k1,25956 - 0x4005b4: 74706972 op74 s0,v1,26994 - 0x4005b8: 4e00726f c0 c0op47 - 0x4005bc: 6863206f op68 v1,v1,8303 - 0x4005c0: 20646c69 addi a0,v1,27753 - 0x4005c4: 636f7270 op60 t7,k1,29296 - 0x4005c8: 65737365 op64 s3,t3,29541 - 0x4005cc: 65520073 op64 s2,t2,115 - 0x4005d0: 72756f73 op70 s5,s3,28531 - 0x4005d4: 64206563 op64 zero,at,25955 - 0x4005d8: 6c646165 op6c a0,v1,24933 - 0x4005dc: 206b636f addi t3,v1,25455 - 0x4005e0: 696f7661 op68 t7,t3,30305 - 0x4005e4: 00646564 and t4,v1,a0 - 0x4005e8: 6e6e6143 op6c t6,s3,24899 - 0x4005ec: 6120746f op60 zero,t1,29807 - 0x4005f0: 636f6c6c op60 t7,k1,27756 - 0x4005f4: 20657461 addi a1,v1,29793 - 0x4005f8: 6f6d656d op6c t5,k1,25965 - 0x4005fc: 50007972 op50 zero,zero,31090 - 0x400600: 696d7265 op68 t5,t3,29285 - 0x400604: 6f697373 op6c t1,k1,29555 - 0x400608: 6564206e op64 a0,t3,8302 - 0x40060c: 6465696e op64 a1,v1,26990 - 0x400610: 64614200 op64 at,v1,16896 - 0x400614: 64646120 op64 a0,v1,24864 - 0x400618: 73736572 op70 s3,k1,25970 - 0x40061c: 6f6c4200 op6c t4,k1,16896 - 0x400620: 64206b63 op64 zero,at,27491 - 0x400624: 63697665 op60 t1,k1,30309 - 0x400628: 65722065 op64 s2,t3,8293 - 0x40062c: 72697571 op70 t1,s3,30065 - 0x400630: 44006465 mfc1 zero,f12 - 0x400634: 63697665 op60 t1,k1,30309 - 0x400638: 75622065 op74 v0,t3,8293 - 0x40063c: 46007973 c.ueq.s f15,f0 - 0x400640: 20656c69 addi a1,v1,27753 - 0x400644: 73697865 op70 t1,k1,30821 - 0x400648: 43007374 c0 c0op52 - 0x40064c: 73736f72 op70 s3,k1,28530 - 0x400650: 7665642d op74 a1,s3,25645 - 0x400654: 20656369 addi a1,v1,25449 - 0x400658: 6b6e696c op68 t6,k1,26988 - 0x40065c: 65704f00 op64 s0,t3,20224 - 0x400660: 69746172 op68 s4,t3,24946 - 0x400664: 6e206e6f op6c zero,s1,28271 - 0x400668: 7320746f op70 zero,t9,29807 - 0x40066c: 6f707075 op6c s0,k1,28789 - 0x400670: 64657472 op64 a1,v1,29810 - 0x400674: 20796220 addi t9,v1,25120 - 0x400678: 69766564 op68 s6,t3,25956 - 0x40067c: 4e006563 c0 c0op35 - 0x400680: 6120746f op60 zero,t1,29807 - 0x400684: 72696420 op70 t1,s3,25632 - 0x400688: 6f746365 op6c s4,k1,25445 - 0x40068c: 49007972 bc2f 0x41ec58 - 0x400690: 20612073 addi at,v1,8307 - 0x400694: 65726964 op64 s2,t3,26980 - 0x400698: 726f7463 op70 t7,s3,29795 - 0x40069c: 6e490079 op6c t1,s2,121 - 0x4006a0: 696c6176 op68 t4,t3,24950 - 0x4006a4: 72612064 op70 at,s3,8292 - 0x4006a8: 656d7567 op64 t5,t3,30055 - 0x4006ac: 5400746e op54 zero,zero,29806 - 0x4006b0: 6d206f6f op6c zero,t1,28527 - 0x4006b4: 20796e61 addi t9,v1,28257 - 0x4006b8: 6e65706f op6c a1,s3,28783 - 0x4006bc: 6c696620 op6c t1,v1,26144 - 0x4006c0: 69207365 op68 zero,t1,29541 - 0x4006c4: 7973206e op78 s3,t3,8302 - 0x4006c8: 6d657473 op6c a1,t3,29811 - 0x4006cc: 6f6f5400 op6c t7,k1,21504 - 0x4006d0: 6e616d20 op6c at,s3,27936 - 0x4006d4: 706f2079 op70 t7,v1,8313 - 0x4006d8: 66206e65 op64 zero,s1,28261 - 0x4006dc: 73656c69 op70 a1,k1,27753 - 0x4006e0: 616e4900 op60 t6,t3,18688 - 0x4006e4: 6f727070 op6c s2,k1,28784 - 0x4006e8: 61697270 op60 t1,t3,29296 - 0x4006ec: 69206574 op68 zero,t1,25972 - 0x4006f0: 6c74636f op6c s4,v1,25455 - 0x4006f4: 726f6620 op70 t7,s3,26144 - 0x4006f8: 76656420 op74 a1,s3,25632 - 0x4006fc: 00656369 spec51 t4,v1,a1 - 0x400700: 74786554 op74 t8,v1,25940 - 0x400704: 6c696620 op6c t1,v1,26144 - 0x400708: 75622065 op74 v0,t3,8293 - 0x40070c: 46007973 c.ueq.s f15,f0 - 0x400710: 20656c69 addi a1,v1,27753 - 0x400714: 206f6f74 addi t7,v1,28532 - 0x400718: 6772616c op64 s2,k1,24940 - 0x40071c: 6f4e0065 op6c t6,k0,101 - 0x400720: 61707320 op60 s0,t3,29472 - 0x400724: 6c206563 op6c zero,at,25955 - 0x400728: 20746665 addi s4,v1,26213 - 0x40072c: 64206e6f op64 zero,at,28271 - 0x400730: 63697665 op60 t1,k1,30309 - 0x400734: 6c490065 op6c t1,v0,101 - 0x400738: 6167656c op60 a3,t3,25964 - 0x40073c: 6573206c op64 s3,t3,8300 - 0x400740: 52006b65 op50 zero,s0,27493 - 0x400744: 2d646165 sltiu a0,t3,24933 - 0x400748: 796c6e6f op78 t4,t3,28271 - 0x40074c: 6c696620 op6c t1,v1,26144 - 0x400750: 79732065 op78 s3,t3,8293 - 0x400754: 6d657473 op6c a1,t3,29811 - 0x400758: 6f6f5400 op6c t7,k1,21504 - 0x40075c: 6e616d20 op6c at,s3,27936 - 0x400760: 696c2079 op68 t4,t3,8313 - 0x400764: 00736b6e spec56 t5,v1,s3 - 0x400768: 6b6f7242 op68 t7,k1,29250 - 0x40076c: 70206e65 op70 zero,at,28261 - 0x400770: 00657069 spec51 t6,v1,a1 - 0x400774: 656d754e op64 t5,t3,30030 - 0x400778: 61636972 op60 v1,t3,26994 - 0x40077c: 7261206c op70 at,s3,8300 - 0x400780: 656d7567 op64 t5,t3,30055 - 0x400784: 6f20746e op6c zero,t9,29806 - 0x400788: 6f207475 op6c zero,t9,29813 - 0x40078c: 6f642066 op6c a0,k1,8294 - 0x400790: 6e69616d op6c t1,s3,24941 - 0x400794: 73655200 op70 a1,k1,20992 - 0x400798: 20746c75 addi s4,v1,27765 - 0x40079c: 206f6f74 addi t7,v1,28532 - 0x4007a0: 6772616c op64 s2,k1,24940 - 0x4007a4: 65520065 op64 s2,t2,101 - 0x4007a8: 72756f73 op70 s5,s3,28531 - 0x4007ac: 74206563 op74 zero,at,25955 - 0x4007b0: 6f706d65 op6c s0,k1,28005 - 0x4007b4: 69726172 op68 s2,t3,24946 - 0x4007b8: 7520796c op74 zero,t1,31084 - 0x4007bc: 6176616e op60 s6,t3,24942 - 0x4007c0: 62616c69 op60 at,s3,27753 - 0x4007c4: 4f00656c c0 c0op44 - 0x4007c8: 61726570 op60 s2,t3,25968 - 0x4007cc: 6e6f6974 op6c t7,s3,26996 - 0x4007d0: 776f6e20 op74 t7,k1,28192 - 0x4007d4: 206e6920 addi t6,v1,26912 - 0x4007d8: 676f7270 op64 t7,k1,29296 - 0x4007dc: 73736572 op70 s3,k1,25970 - 0x4007e0: 65704f00 op64 s0,t3,20224 - 0x4007e4: 69746172 op68 s4,t3,24946 - 0x4007e8: 61206e6f op60 zero,t1,28271 - 0x4007ec: 6165726c op60 a1,t3,29292 - 0x4007f0: 69207964 op68 zero,t1,31076 - 0x4007f4: 7270206e op70 s0,s3,8302 - 0x4007f8: 6572676f op64 s2,t3,26479 - 0x4007fc: 53007373 op50 zero,t8,29555 - 0x400800: 656b636f op64 t3,t3,25455 - 0x400804: 706f2074 op70 t7,v1,8308 - 0x400808: 74617265 op74 at,v1,29285 - 0x40080c: 206e6f69 addi t6,v1,28521 - 0x400810: 6e206e6f op6c zero,s1,28271 - 0x400814: 732d6e6f op70 t5,t9,28271 - 0x400818: 656b636f op64 t3,t3,25455 - 0x40081c: 65440074 op64 a0,t2,116 - 0x400820: 6e697473 op6c t1,s3,29811 - 0x400824: 6f697461 op6c t1,k1,29793 - 0x400828: 6461206e op64 at,v1,8302 - 0x40082c: 73657264 op70 a1,k1,29284 - 0x400830: 65722073 op64 s2,t3,8307 - 0x400834: 72697571 op70 t1,s3,30065 - 0x400838: 4d006465 bc3f 0x4199d0 - 0x40083c: 61737365 op60 s3,t3,29541 - 0x400840: 74206567 op74 zero,at,25959 - 0x400844: 6c206f6f op6c zero,at,28527 - 0x400848: 00676e6f spec57 t5,v1,a3 - 0x40084c: 746f7250 op74 t7,v1,29264 - 0x400850: 6c6f636f op6c t7,v1,25455 - 0x400854: 6f727720 op6c s2,k1,30496 - 0x400858: 7420676e op74 zero,at,26478 - 0x40085c: 20657079 addi a1,v1,28793 - 0x400860: 20726f66 addi s2,v1,28518 - 0x400864: 6b636f73 op68 v1,k1,28531 - 0x400868: 50007465 op50 zero,zero,29797 - 0x40086c: 6f746f72 op6c s4,k1,28530 - 0x400870: 206c6f63 addi t4,v1,28515 - 0x400874: 20746f6e addi s4,v1,28526 - 0x400878: 69617661 op68 at,t3,30305 - 0x40087c: 6c62616c op6c v0,v1,24940 - 0x400880: 72500065 op70 s0,s2,101 - 0x400884: 636f746f op60 t7,k1,29807 - 0x400888: 6e206c6f op6c zero,s1,27759 - 0x40088c: 7320746f op70 zero,t9,29807 - 0x400890: 6f707075 op6c s0,k1,28789 - 0x400894: 64657472 op64 a1,v1,29810 - 0x400898: 636f5300 op60 t7,k1,21248 - 0x40089c: 2074656b addi s4,v1,25963 - 0x4008a0: 65707974 op64 s0,t3,31092 - 0x4008a4: 746f6e20 op74 t7,v1,28192 - 0x4008a8: 70757320 op70 s5,v1,29472 - 0x4008ac: 74726f70 op74 s2,v1,28528 - 0x4008b0: 4f006465 c0 c0op37 - 0x4008b4: 61726570 op60 s2,t3,25968 - 0x4008b8: 6e6f6974 op6c t7,s3,26996 - 0x4008bc: 746f6e20 op74 t7,v1,28192 - 0x4008c0: 70757320 op70 s5,v1,29472 - 0x4008c4: 74726f70 op74 s2,v1,28528 - 0x4008c8: 50006465 op50 zero,zero,25701 - 0x4008cc: 6f746f72 op6c s4,k1,28530 - 0x4008d0: 206c6f63 addi t4,v1,28515 - 0x4008d4: 696d6166 op68 t5,t3,24934 - 0x4008d8: 6e20796c op6c zero,s1,31084 - 0x4008dc: 7320746f op70 zero,t9,29807 - 0x4008e0: 6f707075 op6c s0,k1,28789 - 0x4008e4: 64657472 op64 a1,v1,29810 - 0x4008e8: 64644100 op64 a0,v1,16640 - 0x4008ec: 73736572 op70 s3,k1,25970 - 0x4008f0: 6d616620 op6c at,t3,26144 - 0x4008f4: 20796c69 addi t9,v1,27753 - 0x4008f8: 20746f6e addi s4,v1,28526 - 0x4008fc: 70707573 op70 s0,v1,30067 - 0x400900: 6574726f op64 s4,t3,29295 - 0x400904: 79622064 op78 v0,t3,8292 - 0x400908: 6f727020 op6c s2,k1,28704 - 0x40090c: 6f636f74 op6c v1,k1,28532 - 0x400910: 6166206c op60 a2,t3,8300 - 0x400914: 796c696d op78 t4,t3,26989 - 0x400918: 64644100 op64 a0,v1,16640 - 0x40091c: 73736572 op70 s3,k1,25970 - 0x400920: 726c6120 op70 t4,s3,24864 - 0x400924: 79646165 op78 a0,t3,24933 - 0x400928: 206e6920 addi t6,v1,26912 - 0x40092c: 00657375 spec65 t6,v1,a1 - 0x400930: 276e6143 addiu t6,k1,24899 - 0x400934: 73612074 op70 at,k1,8308 - 0x400938: 6e676973 op6c a3,s3,26995 - 0x40093c: 71657220 op70 a1,t3,29216 - 0x400940: 74736575 op74 s3,v1,25973 - 0x400944: 61206465 op60 zero,t1,25701 - 0x400948: 65726464 op64 s2,t3,25700 - 0x40094c: 4e007373 c0 c0op51 - 0x400950: 6f777465 op6c s7,k1,29797 - 0x400954: 69206b72 op68 zero,t1,27506 - 0x400958: 6f642073 op6c a0,k1,8307 - 0x40095c: 4e006e77 c0 c0op55 - 0x400960: 6f777465 op6c s7,k1,29797 - 0x400964: 69206b72 op68 zero,t1,27506 - 0x400968: 6e752073 op6c s5,s3,8307 - 0x40096c: 63616572 op60 at,k1,25970 - 0x400970: 6c626168 op6c v0,v1,24936 - 0x400974: 654e0065 op64 t6,t2,101 - 0x400978: 726f7774 op70 t7,s3,30580 - 0x40097c: 7264206b op70 a0,s3,8299 - 0x400980: 6570706f op64 s0,t3,28783 - 0x400984: 6f632064 op6c v1,k1,8292 - 0x400988: 63656e6e op60 a1,k1,28270 - 0x40098c: 6e6f6974 op6c t7,s3,26996 - 0x400990: 206e6f20 addi t6,v1,28448 - 0x400994: 65736572 op64 s3,t3,25970 - 0x400998: 6f530074 op6c s3,k0,116 - 0x40099c: 61777466 op60 s7,t3,29798 - 0x4009a0: 63206572 op60 zero,t9,25970 - 0x4009a4: 65737561 op64 s3,t3,30049 - 0x4009a8: 6f632064 op6c v1,k1,8292 - 0x4009ac: 63656e6e op60 a1,k1,28270 - 0x4009b0: 6e6f6974 op6c t7,s3,26996 - 0x4009b4: 6f626120 op6c v0,k1,24864 - 0x4009b8: 43007472 c0 c0op50 - 0x4009bc: 656e6e6f op64 t6,t3,28271 - 0x4009c0: 6f697463 op6c t1,k1,29795 - 0x4009c4: 6572206e op64 s2,t3,8302 - 0x4009c8: 20746573 addi s4,v1,25971 - 0x4009cc: 70207962 op70 zero,at,31074 - 0x4009d0: 00726565 or t4,v1,s2 - 0x4009d4: 62206f4e op60 zero,s1,28494 - 0x4009d8: 65666675 op64 a2,t3,26229 - 0x4009dc: 70732072 op70 s3,v1,8306 - 0x4009e0: 20656361 addi a1,v1,25441 - 0x4009e4: 69617661 op68 at,t3,30305 - 0x4009e8: 6c62616c op6c v0,v1,24940 - 0x4009ec: 6f530065 op6c s3,k0,101 - 0x4009f0: 74656b63 op74 a1,v1,27491 - 0x4009f4: 20736920 addi s3,v1,26912 - 0x4009f8: 65726c61 op64 s2,t3,27745 - 0x4009fc: 20796461 addi t9,v1,25697 - 0x400a00: 6e6e6f63 op6c t6,s3,28515 - 0x400a04: 65746365 op64 s4,t3,25445 - 0x400a08: 6f530064 op6c s3,k0,100 - 0x400a0c: 74656b63 op74 a1,v1,27491 - 0x400a10: 20736920 addi s3,v1,26912 - 0x400a14: 20746f6e addi s4,v1,28526 - 0x400a18: 6e6e6f63 op6c t6,s3,28515 - 0x400a1c: 65746365 op64 s4,t3,25445 - 0x400a20: 61430064 op60 v1,t2,100 - 0x400a24: 2074276e addi s4,v1,10094 - 0x400a28: 646e6573 op64 t6,v1,25971 - 0x400a2c: 74666120 op74 a2,v1,24864 - 0x400a30: 73207265 op70 zero,t9,29285 - 0x400a34: 656b636f op64 t3,t3,25455 - 0x400a38: 68732074 op68 s3,v1,8308 - 0x400a3c: 6f647475 op6c a0,k1,29813 - 0x400a40: 54006e77 op54 zero,zero,28279 - 0x400a44: 6d206f6f op6c zero,t1,28527 - 0x400a48: 20796e61 addi t9,v1,28257 - 0x400a4c: 65666572 op64 a2,t3,25970 - 0x400a50: 636e6572 op60 t6,k1,25970 - 0x400a54: 203a7365 addi k0,at,29541 - 0x400a58: 276e6163 addiu t6,k1,24931 - 0x400a5c: 70732074 op70 s3,v1,8308 - 0x400a60: 6563696c op64 v1,t3,26988 - 0x400a64: 6e6f4300 op6c t7,s3,17152 - 0x400a68: 7463656e op74 v1,v1,25966 - 0x400a6c: 206e6f69 addi t6,v1,28521 - 0x400a70: 656d6974 op64 t5,t3,26996 - 0x400a74: 756f2064 op74 t7,t3,8292 - 0x400a78: 6f430074 op6c v1,k0,116 - 0x400a7c: 63656e6e op60 a1,k1,28270 - 0x400a80: 6e6f6974 op6c t7,s3,26996 - 0x400a84: 66657220 op64 a1,s3,29216 - 0x400a88: 64657375 op64 a1,v1,29557 - 0x400a8c: 6f6f5400 op6c t7,k1,21504 - 0x400a90: 6e616d20 op6c at,s3,27936 - 0x400a94: 656c2079 op64 t4,t3,8313 - 0x400a98: 736c6576 op70 t4,k1,25974 - 0x400a9c: 20666f20 addi a2,v1,28448 - 0x400aa0: 626d7973 op60 t5,s3,31091 - 0x400aa4: 63696c6f op60 t1,k1,27759 - 0x400aa8: 6e696c20 op6c t1,s3,27680 - 0x400aac: 4600736b fop2b.s f13,f14,f0 - 0x400ab0: 20656c69 addi a1,v1,27753 - 0x400ab4: 656d616e op64 t5,t3,24942 - 0x400ab8: 6f6f7420 op6c t7,k1,29728 - 0x400abc: 6e6f6c20 op6c t7,s3,27680 - 0x400ac0: 6f480067 op6c t0,k0,103 - 0x400ac4: 69207473 op68 zero,t1,29811 - 0x400ac8: 6f642073 op6c a0,k1,8307 - 0x400acc: 4e006e77 c0 c0op55 - 0x400ad0: 6f72206f op6c s2,k1,8303 - 0x400ad4: 20657475 addi a1,v1,29813 - 0x400ad8: 68206f74 op68 zero,at,28532 - 0x400adc: 0074736f spec57 t6,v1,s4 - 0x400ae0: 65726944 op64 s2,t3,26948 - 0x400ae4: 726f7463 op70 t7,s3,29795 - 0x400ae8: 6f6e2079 op6c t6,k1,8313 - 0x400aec: 6d652074 op6c a1,t3,8308 - 0x400af0: 00797470 spec60 t6,v1,t9 - 0x400af4: 206f6f54 addi t7,v1,28500 - 0x400af8: 796e616d op78 t6,t3,24941 - 0x400afc: 6f727020 op6c s2,k1,28704 - 0x400b00: 73736563 op70 s3,k1,25955 - 0x400b04: 54007365 op54 zero,zero,29541 - 0x400b08: 6d206f6f op6c zero,t1,28527 - 0x400b0c: 20796e61 addi t9,v1,28257 - 0x400b10: 72657375 op70 a1,s3,29557 - 0x400b14: 69440073 op68 a0,t2,115 - 0x400b18: 71206373 op70 zero,t1,25459 - 0x400b1c: 61746f75 op60 s4,t3,28533 - 0x400b20: 63786520 op60 t8,k1,25888 - 0x400b24: 65646565 op64 a0,t3,25957 - 0x400b28: 74530064 op74 s3,v0,100 - 0x400b2c: 20656c61 addi a1,v1,27745 - 0x400b30: 2053464e addi s3,v0,17998 - 0x400b34: 656c6966 op64 t4,t3,26982 - 0x400b38: 6e616820 op6c at,s3,26656 - 0x400b3c: 00656c64 and t5,v1,a1 - 0x400b40: 206f6f54 addi t7,v1,28500 - 0x400b44: 796e616d op78 t6,t3,24941 - 0x400b48: 76656c20 op74 a1,s3,27680 - 0x400b4c: 20736c65 addi s3,v1,27749 - 0x400b50: 7220666f op70 zero,s1,26223 - 0x400b54: 746f6d65 op74 t7,v1,28005 - 0x400b58: 6e692065 op6c t1,s3,8293 - 0x400b5c: 74617020 op74 at,v1,28704 - 0x400b60: 50520068 op50 s2,v0,104 - 0x400b64: 74732043 op74 s3,v1,8259 - 0x400b68: 74637572 op74 v1,v1,30066 - 0x400b6c: 20736920 addi s3,v1,26912 - 0x400b70: 00646162 sub t4,v1,a0 - 0x400b74: 20435052 addi v1,v0,20562 - 0x400b78: 73726576 op70 s2,k1,25974 - 0x400b7c: 206e6f69 addi t6,v1,28521 - 0x400b80: 6e6f7277 op6c t7,s3,29303 - 0x400b84: 50520067 op50 s2,v0,103 - 0x400b88: 72702043 op70 s0,s3,8259 - 0x400b8c: 202e676f addi t6,at,26479 - 0x400b90: 20746f6e addi s4,v1,28526 - 0x400b94: 69617661 op68 at,t3,30305 - 0x400b98: 7250006c op70 s0,s2,108 - 0x400b9c: 6172676f op60 s2,t3,26479 - 0x400ba0: 6576206d op64 s6,t3,8301 - 0x400ba4: 6f697372 op6c t1,k1,29554 - 0x400ba8: 7277206e op70 s7,s3,8302 - 0x400bac: 00676e6f spec57 t5,v1,a3 - 0x400bb0: 20646142 addi a0,v1,24898 - 0x400bb4: 636f7270 op60 t7,k1,29296 - 0x400bb8: 72756465 op70 s5,s3,25701 - 0x400bbc: 6f662065 op6c a2,k1,8293 - 0x400bc0: 72702072 op70 s0,s3,8306 - 0x400bc4: 6172676f op60 s2,t3,26479 - 0x400bc8: 6f4e006d op6c t6,k0,109 - 0x400bcc: 636f6c20 op60 t7,k1,27680 - 0x400bd0: 6120736b op60 zero,t1,29547 - 0x400bd4: 6c696176 op6c t1,v1,24950 - 0x400bd8: 656c6261 op64 t4,t3,25185 - 0x400bdc: 6e754600 op6c s5,s3,17920 - 0x400be0: 6f697463 op6c t1,k1,29795 - 0x400be4: 6f6e206e op6c t6,k1,8302 - 0x400be8: 6d692074 op6c t1,t3,8308 - 0x400bec: 6d656c70 op6c a1,t3,27760 - 0x400bf0: 65746e65 op64 s4,t3,28261 - 0x400bf4: 6e490064 op6c t1,s2,100 - 0x400bf8: 72707061 op70 s0,s3,28769 - 0x400bfc: 6972706f op68 s2,t3,28783 - 0x400c00: 20657461 addi a1,v1,29793 - 0x400c04: 656c6966 op64 t4,t3,26982 - 0x400c08: 70797420 op70 t9,v1,29728 - 0x400c0c: 726f2065 op70 t7,s3,8293 - 0x400c10: 726f6620 op70 t7,s3,26144 - 0x400c14: 0074616d spec55 t4,v1,s4 - 0x400c18: 00000000 nop - 0x400c1c: 00000000 nop diff --git a/sys/arch/pmax/test/t06.c b/sys/arch/pmax/test/t06.c deleted file mode 100644 index f016352cddd3..000000000000 --- a/sys/arch/pmax/test/t06.c +++ /dev/null @@ -1,30 +0,0 @@ -int foo; - -main(argc, argv) - char **argv; -{ - int fout = open("/dev/console", 1); - int i; - - foo = 0; - switch(fork()) { - case 0: /* child */ - foo = 30; - for (i = 0; i < 10; i++) { - printf("child %d, foo %d\n", i, foo); - foo++; - } - return(1); - - case -1: - perror("fork"); - return(2); - - default: - for (i = 0; i < 10; i++) { - printf("parent %d foo %d\n", i, foo); - foo++; - } - return(0); - } -} diff --git a/sys/arch/pmax/test/t07.c b/sys/arch/pmax/test/t07.c deleted file mode 100644 index 09075aa5334a..000000000000 --- a/sys/arch/pmax/test/t07.c +++ /dev/null @@ -1,48 +0,0 @@ -int foo; -int foo1; - -main(argc, argv) - char **argv; -{ - int i, j; - - for (i = 0; i < 10; i++) { - printf("main: bla %d pid %d\n", j = bla(), getpid()); - if (j == 1) - exit(0); - } -} - -bla() -{ - int i; - - foo = 0; - switch(fork()) { - case 0: /* child */ - foo = 30; - for (i = 0; i < 10; i++) { - printf("child %d, foo %d\n", i, foo); - bar(foo); - foo++; - } - return(1); - - case -1: - perror("fork"); - return(2); - - default: - for (i = 0; i < 10; i++) { - printf("parent %d foo %d\n", i, foo); - bar(foo); - foo++; - } - return(0); - } -} - -bar(a) -{ - printf("bar(%d) pid %d\n", a, getpid()); -} diff --git a/sys/arch/pmax/test/tdisk.sh b/sys/arch/pmax/test/tdisk.sh deleted file mode 100644 index 019f38626bab..000000000000 --- a/sys/arch/pmax/test/tdisk.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh - -cp /vmunix /tmp/vmunix -while cmp /vmunix /tmp/vmunix -do - echo -done diff --git a/sys/arch/pmax/ultrix/ultrix_sysent.c b/sys/arch/pmax/ultrix/ultrix_sysent.c deleted file mode 100644 index c67d825b20e2..000000000000 --- a/sys/arch/pmax/ultrix/ultrix_sysent.c +++ /dev/null @@ -1,429 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department and Ralph Campbell. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah Hdr: hpux_sysent.c 1.1 90/07/09 - * - * from: @(#)ultrix_sysent.c 8.1 (Berkeley) 6/10/93 - * $Id: ultrix_sysent.c,v 1.4 1994/05/27 09:07:02 glass Exp $ - */ - -/* - * System call switch table. - */ - -#include -#include - -int nosys(),notimp(); - -int rexit(); -int fork(); -int read(); -int write(); -int open(); -int close(); -int ocreat(); -int link(); -int unlink(); -int chdir(); -int mknod(); -int chmod(); -int chown(); -int obreak(); -int lseek(); -int getpid(); -int getuid(); -int ptrace(); -int saccess(); -int sync(); -int kill(); -int ostat(); -int olstat(); -int dup(); -int pipe(); -int profil(); -int ultrixtobsd(); -int getgid(); -int ioctl(); -int reboot(); -int symlink(); -int readlink(); -int execve(); -int umask(); -int chroot(); -int ofstat(); -int ogetpagesize(); -int vfork(); -int sbrk(); -int sstk(); -int getgroups(); -int setgroups(); -int ultrixgetpgrp(); -int ultrixsetpgrp(); -int setitimer(); -int ultrixwait3(); -int getitimer(); -int ogethostname(); -int osethostname(); -int getdtablesize(); -int dup2(); -int fcntl(); -int select(); -int fsync(); -int setpriority(); -int socket(); -int connect(); -int oaccept(); -int getpriority(); -int osend(); -int orecv(); -int sigreturn(); -int bind(); -int setsockopt(); -int listen(); -int ultrixsigvec(); -int osigblock(); -int osigsetmask(); -int sigsuspend(); -int osigstack(); -int orecvmsg(); -int osendmsg(); -int gettimeofday(); -int getrusage(); -int getsockopt(); -int readv(); -int writev(); -int settimeofday(); -int fchown(); -int fchmod(); -int orecvfrom(); -int osetreuid(); -int osetregid(); -int rename(); -int truncate(); -int ftruncate(); -int flock(); -int sendto(); -int shutdown(); -int socketpair(); -int mkdir(); -int rmdir(); -int utimes(); -int adjtime(); -int ogetpeername(); -int ogethostid(); -int osethostid(); -int getrlimit(); -int setrlimit(); -int okillpg(); -int ogetsockname(); -int ogetdirentries(); -int ultrixgetdomainname(); -int ultrixsetdomainname(); -int ultrixgetsysinfo(); - -/* - * Reserved/unimplemented system calls in the range 0-150 inclusive - * are reserved for use in future Berkeley releases. - * Additional system calls implemented in vendor and other - * redistributions should be placed in the reserved range at the end - * of the current calls. - */ -struct sysent ultrixsysent[] = { - 0, nosys, /* 0 = out of range */ - 1, rexit, /* 1 = exit */ - 0, fork, /* 2 = fork */ - 3, read, /* 3 = read */ - 3, write, /* 4 = write */ - 3, open, /* 5 = open */ - 1, close, /* 6 = close */ - 0, nosys, /* 7 = old wait */ - 2, ocreat, /* 8 = creat */ - 2, link, /* 9 = link */ - 1, unlink, /* 10 = unlink */ - 0, nosys, /* 11 = old execv */ - 1, chdir, /* 12 = chdir */ - 0, nosys, /* 13 = old time */ - 3, mknod, /* 14 = mknod */ - 2, chmod, /* 15 = chmod */ - 3, chown, /* 16 = chown */ - 1, obreak, /* 17 = old break */ - 0, nosys, /* 18 = old stat */ - 3, lseek, /* 19 = lseek */ - 0, getpid, /* 20 = getpid */ - 3, notimp, /* 21 = mount */ - 1, notimp, /* 22 = umount */ - 0, nosys, /* 23 = old setuid */ - 0, getuid, /* 24 = getuid */ - 0, nosys, /* 25 = old stime */ - 4, ptrace, /* 26 = ptrace */ - 0, nosys, /* 27 = old alarm */ - 0, nosys, /* 28 = old fstat */ - 0, nosys, /* 29 = old pause */ - 0, nosys, /* 30 = old utime */ - 0, nosys, /* 31 = old stty */ - 0, nosys, /* 32 = old gtty */ - 2, saccess, /* 33 = access */ - 0, nosys, /* 34 = old nice */ - 0, nosys, /* 35 = old ftime */ - 0, sync, /* 36 = sync */ - 2, kill, /* 37 = kill */ - 2, ostat, /* 38 = stat */ - 0, nosys, /* 39 = old setpgrp */ - 2, olstat, /* 40 = lstat */ - 1, dup, /* 41 = dup */ - 1, pipe, /* 42 = pipe */ - 0, nosys, /* 43 = old times */ - 4, profil, /* 44 = profil */ - 0, ultrixtobsd, /* 45 = unused */ - 0, nosys, /* 46 = old setgid */ - 0, getgid, /* 47 = getgid */ - 0, nosys, /* 48 = old sigsys */ - 0, nosys, /* 49 = reserved for USG */ - 0, nosys, /* 50 = reserved for USG */ - 1, notimp, /* 51 = acct */ - 0, nosys, /* 52 = old set phys addr */ - 0, nosys, /* 53 = old lock in core */ - 3, ioctl, /* 54 = ioctl */ - 1, reboot, /* 55 = reboot */ - 0, nosys, /* 56 = old mpxchan */ - 2, symlink, /* 57 = symlink */ - 3, readlink, /* 58 = readlink */ - 3, execve, /* 59 = execve */ - 1, umask, /* 60 = umask */ - 1, chroot, /* 61 = chroot */ - 2, ofstat, /* 62 = fstat */ - 0, nosys, /* 63 = unused */ - 0, ogetpagesize, /* 64 = getpagesize */ - 0, notimp, /* 65 = mremap */ - 0, vfork, /* 66 = vfork */ - 0, nosys, /* 67 = old vread */ - 0, nosys, /* 68 = old vwrite */ - 1, sbrk, /* 69 = sbrk */ - 1, sstk, /* 70 = sstk */ - 0, nosys, /* 71 = mmap */ - 0, nosys, /* 72 = old vadvise */ - 0, notimp, /* 73 = munmap */ - 0, notimp, /* 74 = mprotect */ - 0, notimp, /* 75 = madvise */ - 0, notimp, /* 76 = vhangup */ - 0, nosys, /* 77 = old vlimit */ - 0, nosys, /* 78 = mincore */ - 2, getgroups, /* 79 = getgroups */ - 2, setgroups, /* 80 = setgroups */ - 1, ultrixgetpgrp, /* 81 = getpgrp */ - 2, ultrixsetpgrp, /* 82 = setpgrp */ - 3, setitimer, /* 83 = setitimer */ - 3, ultrixwait3, /* 84 = wait3 */ - 1, notimp, /* 85 = swapon */ - 2, getitimer, /* 86 = getitimer */ - 2, ogethostname, /* 87 = gethostname */ - 2, osethostname, /* 88 = sethostname */ - 0, getdtablesize, /* 89 = getdtablesize */ - 2, dup2, /* 90 = dup2 */ - 0, notimp, /* 91 = getdopt */ - 3, fcntl, /* 92 = fcntl */ - 5, select, /* 93 = select */ - 0, notimp, /* 94 = setdopt */ - 1, fsync, /* 95 = fsync */ - 3, setpriority, /* 96 = setpriority */ - 3, socket, /* 97 = socket */ - 3, connect, /* 98 = connect */ - 3, oaccept, /* 99 = accept */ - 2, getpriority, /* 100 = getpriority */ - 4, osend, /* 101 = send */ - 4, orecv, /* 102 = recv */ - 1, sigreturn, /* 103 = sigreturn */ - 3, bind, /* 104 = bind */ - 5, setsockopt, /* 105 = setsockopt */ - 2, listen, /* 106 = listen */ - 0, nosys, /* 107 = old vtimes */ - 4, ultrixsigvec, /* 108 = sigvec */ - 1, osigblock, /* 109 = sigblock */ - 1, osigsetmask, /* 110 = sigsetmask */ - 1, sigsuspend, /* 111 = sigpause */ - 2, osigstack, /* 112 = sigstack */ - 3, orecvmsg, /* 113 = recvmsg */ - 3, osendmsg, /* 114 = sendmsg */ - 0, nosys, /* 115 = old vtrace */ - 2, gettimeofday, /* 116 = gettimeofday */ - 2, getrusage, /* 117 = getrusage */ - 5, getsockopt, /* 118 = getsockopt */ - 0, nosys, /* 119 = old resuba */ - 3, readv, /* 120 = readv */ - 3, writev, /* 121 = writev */ - 2, settimeofday, /* 122 = settimeofday */ - 3, fchown, /* 123 = fchown */ - 2, fchmod, /* 124 = fchmod */ - 6, orecvfrom, /* 125 = recvfrom */ - 2, osetreuid, /* 126 = setreuid */ - 2, osetregid, /* 127 = setregid */ - 2, rename, /* 128 = rename */ - 2, truncate, /* 129 = truncate */ - 2, ftruncate, /* 130 = ftruncate */ - 2, flock, /* 131 = flock */ - 0, nosys, /* 132 = nosys */ - 6, sendto, /* 133 = sendto */ - 2, shutdown, /* 134 = shutdown */ - 5, socketpair, /* 135 = socketpair */ - 2, mkdir, /* 136 = mkdir */ - 1, rmdir, /* 137 = rmdir */ - 2, utimes, /* 138 = utimes */ - 1, sigreturn, /* 139 = internal (4.2 sigreturn) */ - 2, adjtime, /* 140 = adjtime */ - 3, ogetpeername, /* 141 = getpeername */ - 2, ogethostid, /* 142 = gethostid */ - 2, osethostid, /* 143 = sethostid */ - 2, getrlimit, /* 144 = getrlimit */ - 2, setrlimit, /* 145 = setrlimit */ - 2, okillpg, /* 146 = killpg */ - 0, nosys, /* 147 = nosys */ - 0, notimp, /* 148 = setquota */ - 0, notimp, /* 149 = quota */ - 3, ogetsockname, /* 150 = getsockname */ - /* - * ULTRIX specific syscalls - */ - 0, notimp, /* 151 = sysmips */ - 0, notimp, /* 152 = cacheflush */ - 0, notimp, /* 153 = cachectl */ - 0, notimp, /* 154 = debug */ - 0, nosys, /* 155 = nosys */ - 0, nosys, /* 156 = nosys */ - 0, nosys, /* 157 = nosys */ - 0, notimp, /* 158 = nfs_svc */ - 4, ogetdirentries, /* 159 = getdirentries */ - 0, nosys, /* 160 = nosys */ - 0, nosys, /* 161 = nosys */ - 0, nosys, /* 162 = nosys */ - 0, notimp, /* 163 = nfs_biod */ - 0, notimp, /* 164 = nfs_getfh */ - 0, ultrixgetdomainname, /* 165 = getdomainname */ - 0, ultrixsetdomainname, /* 166 = setdomainname */ - 0, nosys, /* 167 = nosys */ - 0, nosys, /* 168 = nosys */ - 0, notimp, /* 169 = exportfs */ - 0, nosys, /* 170 = nosys */ - 0, nosys, /* 171 = nosys */ - 0, notimp, /* 172 = msgctl */ - 0, notimp, /* 173 = msgget */ - 0, notimp, /* 174 = msgrcv */ - 0, notimp, /* 175 = msgsnd */ - 0, notimp, /* 176 = semctl */ - 0, notimp, /* 177 = semget */ - 0, notimp, /* 178 = semop */ - 0, notimp, /* 179 = uname */ - 0, notimp, /* 180 = shmsys */ - 0, notimp, /* 181 = plock */ - 0, notimp, /* 182 = lockf */ - 0, notimp, /* 183 = ustat */ - 0, notimp, /* 184 = getmnt */ - 0, notimp, /* 185 = mount */ - 0, notimp, /* 186 = umount */ - 0, notimp, /* 187 = sigpending */ - 0, nosys, /* 188 = nosys */ - 0, nosys, /* 189 = nosys */ - 0, nosys, /* 190 = nosys */ - 0, nosys, /* 191 = nosys */ - 0, nosys, /* 192 = nosys */ - 0, nosys, /* 193 = nosys */ - 0, nosys, /* 194 = nosys */ - 0, nosys, /* 195 = nosys */ - 0, nosys, /* 196 = nosys */ - 0, nosys, /* 197 = nosys */ - 0, nosys, /* 198 = nosys */ - 0, nosys, /* 199 = nosys */ - 0, nosys, /* 200 = nosys */ - 0, nosys, /* 201 = nosys */ - 0, nosys, /* 202 = nosys */ - 0, nosys, /* 203 = nosys */ - 0, nosys, /* 204 = nosys */ - 0, nosys, /* 205 = nosys */ - 0, nosys, /* 206 = nosys */ - 0, nosys, /* 207 = nosys */ - 0, nosys, /* 208 = nosys */ - 0, nosys, /* 209 = nosys */ - 0, nosys, /* 210 = nosys */ - 0, nosys, /* 211 = nosys */ - 0, nosys, /* 212 = nosys */ - 0, nosys, /* 213 = nosys */ - 0, nosys, /* 214 = nosys */ - 0, nosys, /* 215 = nosys */ - 0, nosys, /* 216 = nosys */ - 0, nosys, /* 217 = nosys */ - 0, nosys, /* 218 = nosys */ - 0, nosys, /* 219 = nosys */ - 0, nosys, /* 220 = nosys */ - 0, nosys, /* 221 = nosys */ - 0, nosys, /* 222 = nosys */ - 0, nosys, /* 223 = nosys */ - 0, nosys, /* 224 = nosys */ - 0, nosys, /* 225 = nosys */ - 0, nosys, /* 226 = nosys */ - 0, nosys, /* 227 = nosys */ - 0, nosys, /* 228 = nosys */ - 0, nosys, /* 229 = nosys */ - 0, nosys, /* 230 = nosys */ - 0, nosys, /* 231 = nosys */ - 0, nosys, /* 232 = nosys */ - 0, notimp, /* 233 = nosys */ - 0, notimp, /* 234 = nosys */ - 0, notimp, /* 235 = nosys */ - 0, nosys, /* 236 = nosys */ - 0, notimp, /* 237 = nosys */ - 0, notimp, /* 238 = nosys */ - 0, nosys, /* 239 = nosys */ - 0, nosys, /* 240 = nosys */ - 0, nosys, /* 241 = nosys */ - 0, nosys, /* 242 = nosys */ - 0, nosys, /* 243 = nosys */ - 0, nosys, /* 244 = nosys */ - 0, nosys, /* 245 = nosys */ - 0, nosys, /* 246 = nosys */ - 0, nosys, /* 247 = nosys */ - 0, nosys, /* 248 = nosys */ - 0, nosys, /* 249 = nosys */ - 0, nosys, /* 250 = nosys */ - 0, nosys, /* 251 = nosys */ - 0, nosys, /* 252 = nosys */ - 0, nosys, /* 253 = nosys */ - 0, nosys, /* 254 = nosys */ - 0, nosys, /* 255 = nosys */ - 0, ultrixgetsysinfo, /* 256 = getsysinfo */ - 0, notimp, /* 257 = setsysinfo */ -}; -int ultrixnsysent = sizeof(ultrixsysent) / sizeof (ultrixsysent[0]); diff --git a/sys/arch/sparc/conf/std.sparc b/sys/arch/sparc/conf/std.sparc deleted file mode 100644 index 6087201b2b0a..000000000000 --- a/sys/arch/sparc/conf/std.sparc +++ /dev/null @@ -1,10 +0,0 @@ -# $NetBSD: std.sparc,v 1.5 1994/11/20 20:51:47 deraadt Exp $ - -# @(#)std.sparc 8.1 (Berkeley) 6/11/93 -# standard SPARCstation information. - -machine sparc - -mainbus0 at root - -cpu0 at mainbus0 diff --git a/sys/arch/sparc/conf/std.sun4 b/sys/arch/sparc/conf/std.sun4 deleted file mode 100644 index 8f3d3db878df..000000000000 --- a/sys/arch/sparc/conf/std.sun4 +++ /dev/null @@ -1,20 +0,0 @@ -# $NetBSD: std.sun4,v 1.3 1994/11/20 20:51:48 deraadt Exp $ - -obio0 at mainbus0 - -vmes0 at mainbus0 -vmel0 at mainbus0 - -clock0 at obio0 addr 0xf2000000 -memreg0 at obio0 addr 0xf4000000 -timer0 at obio0 addr 0xef000000 - -zs0 at obio0 addr 0xf1000000 level 12 flags 0x103 -zs1 at obio0 addr 0xf0000000 level 12 flags 0x103 -zs2 at obio0 addr 0xe0000000 level 12 flags 0x103 - -esp0 at obio0 addr 0xfa000000 level 4 -dma0 at obio0 addr 0xfa001000 level 4 - -le0 at obio0 addr 0xf9000000 level 6 - diff --git a/sys/arch/sparc/conf/std.sun4c b/sys/arch/sparc/conf/std.sun4c deleted file mode 100644 index 3d0b94cc3cf0..000000000000 --- a/sys/arch/sparc/conf/std.sun4c +++ /dev/null @@ -1,35 +0,0 @@ -# $NetBSD: std.sun4c,v 1.3 1994/11/20 20:51:49 deraadt Exp $ - -sbus0 at mainbus0 - -audio0 at mainbus0 -auxreg0 at mainbus0 -clock0 at mainbus0 -memreg0 at mainbus0 -timer0 at mainbus0 - -zs0 at mainbus0 -zs1 at mainbus0 - -# FSBE/S or sun4m -espdma0 at sbus0 slot ? offset ? -espdma* at sbus0 slot ? offset ? -esp0 at espdma? slot ? offset ? -esp* at espdma? slot ? offset ? - -# old sun4c SCSI -dma0 at sbus0 slot ? offset ? -dma* at sbus0 slot ? offset ? -esp0 at sbus0 slot ? offset ? -esp* at sbus0 slot ? offset ? - -# old sun4c -le0 at sbus? slot ? offset ? -le* at sbus? slot ? offset ? - -bwtwo0 at sbus? slot ? offset ? -bwtwo* at sbus? slot ? offset ? -cgthree0 at sbus? slot ? offset ? -cgthree* at sbus? slot ? offset ? -cgsix0 at sbus? slot ? offset ? -cgsix* at sbus? slot ? offset ? diff --git a/sys/arch/sparc/sbus/cgsixreg.h b/sys/arch/sparc/sbus/cgsixreg.h deleted file mode 100644 index a4a856966362..000000000000 --- a/sys/arch/sparc/sbus/cgsixreg.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 1993 The Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * %W% (Berkeley) %G% - * - * from: Header: cgsixreg.h,v 1.1 93/10/12 15:29:24 torek Exp - * $Id: cgsixreg.h,v 1.2 1994/05/07 01:14:45 deraadt Exp $ - */ - -/* - * CG6 display registers. (Note, I got tired of writing `cgsix' about - * halfway through and changed everything to cg6, but I probably missed - * some. Unfortunately, the way config works, we need to spell out `six' - * in some places anyway.) - * - * The cg6 is a complicated beastie. We have been unable to extract any - * documentation and most of the following are guesses based on a limited - * amount of reverse engineering. - * - * A cg6 is composed of numerous groups of control registers, all with TLAs: - * FBC - frame buffer control? - * FHC - fbc hardware configuration / control? register (32 bits) - * DHC - ??? - * TEC - transform engine control? - * THC - TEC Hardware Configuration - * ROM - a 64Kbyte ROM with who knows what in it. - * colormap - see below - * frame buffer memory (video RAM) - * possible other stuff - * - * Like the cg3, the cg6 uses a Brooktree Video DAC (see btreg.h). - * - * Various revisions of the cgsix have various hardware bugs. So far, - * we have only seen rev 1 & 2. - */ - -/* bits in FHC register */ -#define FHC_FBID_MASK 0xff000000 /* bits 24..31 are frame buffer ID */ -#define FHC_FBID_SHIFT 24 -#define FHC_REV_MASK 0x00f00000 /* bits 20..23 are revision */ -#define FHC_REV_SHIFT 20 -#define FHC_FROP_DISABLE 0x00080000 /* disable fast/font? rasterops */ -#define FHC_ROW_DISABLE 0x00040000 /* ??? */ -#define FHC_SRC_DISABLE 0x00020000 /* ??? */ -#define FHC_DST_DISABLE 0x00010000 /* disable destination cache */ -#define FHC_RESET 0x00008000 /* ??? */ -#define FHC_XXX0 0x00004000 /* ??? */ -#define FHC_LEBO 0x00002000 /* set little endian byte order? */ -#define FHC_RES_MASK 0x00001800 /* bits 11&12 are resolution */ -#define FHC_RES_1024 0x00000000 /* res = 1024x768 */ -#define FHC_RES_1152 0x00000800 /* res = 1152x900 */ -#define FHC_RES_1280 0x00001000 /* res = 1280x1024 */ -#define FHC_RES_1600 0x00001800 /* res = 1600x1200 */ -#define FHC_CPU_MASK 0x00000600 /* bits 9&10 are cpu type */ -#define FHC_CPU_SPARC 0x00000000 /* cpu = sparc */ -#define FHC_CPU_68020 0x00000200 /* cpu = 68020 */ -#define FHC_CPU_386 0x00000400 /* cpu = 80386 */ -#define FHC_CPU_XXX 0x00000600 /* ??? */ -#define FHC_TEST 0x00000100 /* ??? test window ??? */ -#define FHC_TESTX_MASK 0x000000f0 /* bits 4..7 are test window X */ -#define FHC_TESTX_SHIFT 4 -#define FHC_TESTY_MASK 0x0000000f /* bits 0..3 are test window Y */ -#define FHC_TESTY_SHIFT 0 - -/* - * The layout of the THC. - */ -struct cg6_thc { - u_int thc_xxx0[512]; /* ??? */ - u_int thc_hsync1; /* horizontal sync timing */ - u_int thc_hsync2; /* more hsync timing */ - u_int thc_hsync3; /* yet more hsync timing */ - u_int thc_vsync1; /* vertical sync timing */ - u_int thc_vsync2; /* only two of these */ - u_int thc_refresh; /* refresh counter */ - u_int thc_misc; /* miscellaneous control & status */ - u_int thc_xxx1[56]; /* ??? */ - u_int thc_cursxy; /* cursor x,y position (16 bits each) */ - u_int thc_cursmask[32]; /* cursor mask bits */ - u_int thc_cursbits[32]; /* what to show where mask enabled */ -}; - -/* bits in thc_misc */ -#define THC_MISC_XXX0 0xfff00000 /* unused */ -#define THC_MISC_REVMASK 0x000f0000 /* cg6 revision? */ -#define THC_MISC_REVSHIFT 16 -#define THC_MISC_XXX1 0x0000e000 /* unused */ -#define THC_MISC_RESET 0x00001000 /* ??? */ -#define THC_MISC_XXX2 0x00000800 /* unused */ -#define THC_MISC_VIDEN 0x00000400 /* video enable */ -#define THC_MISC_SYNC 0x00000200 /* not sure what ... */ -#define THC_MISC_VSYNC 0x00000100 /* ... these really are */ -#define THC_MISC_SYNCEN 0x00000080 /* sync enable */ -#define THC_MISC_CURSRES 0x00000040 /* cursor resolution */ -#define THC_MISC_INTEN 0x00000020 /* v.retrace intr enable */ -#define THC_MISC_INTR 0x00000010 /* intr pending / ack bit */ -#define THC_MISC_XXX 0x0000000f /* ??? */ - -/* cursor x / y position value for `off' */ -#define THC_CURSOFF (65536-32) /* i.e., USHRT_MAX+1-32 */ - -/* - * Partial description of TEC (needed to get around FHC rev 1 bugs). - */ -struct cg6_tec_xxx { - u_int tec_mv; /* matrix stuff */ - u_int tec_clip; /* clipping stuff */ - u_int tec_vdc; /* ??? */ -}; - -/* - * This structure exists only to compute the layout of the CG6 - * hardware. Each of the individual substructures lives on a - * separate `page' (where a `page' is at least 4K), and many are - * very far apart. We avoid large offsets (which make for lousy - * code) by using pointers to the individual interesting pieces, - * and map them in independently (to avoid using up PTEs unnecessarily). - */ -struct cg6_layout { - /* ROM at 0 */ - union { - long un_id; /* ID = ?? */ - char un_rom[65536]; /* 64K rom */ - char un_pad[0x200000]; - } cg6_rom_un; - - /* Brooktree DAC at 0x200000 */ - union { - struct bt_regs un_btregs; - char un_pad[0x040000]; - } cg6_bt_un; - - /* DHC, whatever that is, at 0x240000 */ - union { - char un_pad[0x40000]; - } cg6_dhc_un; - - /* ALT, whatever that is, at 0x280000 */ - union { - char un_pad[0x80000]; - } cg6_alt_un; - - /* FHC register at 0x300000 */ - union { - int un_fhc; - char un_pad[0x1000]; - } cg6_fhc_un; - - /* THC at 0x301000 */ - union { - struct cg6_thc un_thc; - char un_pad[0x400000 - 0x1000]; - } cg6_thc_un; - - /* FBC at 0x700000 */ - union { - char un_pad[0x1000]; - } cg6_fbc_un; - - /* TEC at 0x701000 */ - union { - char un_pad[0x100000 - 0x1000]; - struct cg6_tec_xxx un_tec; - } cg6_tec_un; - - /* Video RAM at 0x800000 */ - char cg6_ram[1024 * 1024]; /* approx.? */ -}; diff --git a/sys/arch/sparc/sbus/cgthree.c b/sys/arch/sparc/sbus/cgthree.c deleted file mode 100644 index 469a314fb504..000000000000 --- a/sys/arch/sparc/sbus/cgthree.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * %W% (Berkeley) %G% - * - * from: Header: cgthree.c,v 1.8 93/10/31 05:09:24 torek Exp - * $Id: cgthree.c,v 1.6 1994/07/04 21:37:25 deraadt Exp $ - */ - -/* - * color display (cgthree) driver. - * - * Does not handle interrupts, even though they can occur. - * - * XXX should defer colormap updates to vertical retrace interrupts - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -/* per-display variables */ -struct cgthree_softc { - struct device sc_dev; /* base device */ - struct sbusdev sc_sd; /* sbus device */ - struct fbdevice sc_fb; /* frame buffer device */ - volatile struct bt_regs *sc_bt; /* Brooktree registers */ - caddr_t sc_phys; /* display RAM (phys addr) */ - int sc_blanked; /* true if blanked */ - union bt_cmap sc_cmap; /* Brooktree color map */ -}; - -/* autoconfiguration driver */ -static void cgthreeattach(struct device *, struct device *, void *); -struct cfdriver cgthreecd = - { NULL, "cgthree", matchbyname, cgthreeattach, - DV_DULL, sizeof(struct cgthree_softc) }; - -/* frame buffer generic driver */ -static void cgthreeunblank(struct device *); -static struct fbdriver cgthreefbdriver = { cgthreeunblank }; - -extern int fbnode; -extern struct tty *fbconstty; -extern int (*v_putc)(); -extern int nullop(); -static int cgthree_cnputc(); - -static void cgthreeloadcmap __P((struct cgthree_softc *, int, int)); - -#define CGTHREE_MAJOR 55 /* XXX */ - -/* - * Attach a display. We need to notice if it is the console, too. - */ -void -cgthreeattach(parent, self, args) - struct device *parent, *self; - void *args; -{ - register struct cgthree_softc *sc = (struct cgthree_softc *)self; - register struct sbus_attach_args *sa = args; - register int node = sa->sa_ra.ra_node, ramsize, i; - register volatile struct bt_regs *bt; - register struct cgthree_all *p; - int isconsole; - - sc->sc_fb.fb_major = CGTHREE_MAJOR; /* XXX to be removed */ - - sc->sc_fb.fb_driver = &cgthreefbdriver; - sc->sc_fb.fb_device = &sc->sc_dev; - /* - * The defaults below match my screen, but are not guaranteed - * to be correct as defaults go... - */ - sc->sc_fb.fb_type.fb_type = FBTYPE_SUN3COLOR; - sc->sc_fb.fb_type.fb_width = getpropint(node, "width", 1152); - sc->sc_fb.fb_type.fb_height = getpropint(node, "height", 900); - sc->sc_fb.fb_linebytes = getpropint(node, "linebytes", 1152); - ramsize = roundup(sc->sc_fb.fb_type.fb_height * sc->sc_fb.fb_linebytes, - NBPG); - sc->sc_fb.fb_type.fb_depth = 8; - sc->sc_fb.fb_type.fb_cmsize = 256; - sc->sc_fb.fb_type.fb_size = ramsize; - printf(": %s, %d x %d", getpropstring(node, "model"), - sc->sc_fb.fb_type.fb_width, sc->sc_fb.fb_type.fb_height); - - /* - * When the ROM has mapped in a cgthree display, the address - * maps only the video RAM, so in any case we have to map the - * registers ourselves. We only need the video RAM if we are - * going to print characters via rconsole. - */ - isconsole = node == fbnode && fbconstty != NULL; - p = (struct cgthree_all *)sa->sa_ra.ra_paddr; - if ((sc->sc_fb.fb_pixels = sa->sa_ra.ra_vaddr) == NULL && isconsole) { - /* this probably cannot happen, but what the heck */ - sc->sc_fb.fb_pixels = mapiodev(p->ba_ram, ramsize); - } - sc->sc_bt = bt = (volatile struct bt_regs *) - mapiodev((caddr_t)&p->ba_btreg, sizeof(p->ba_btreg)); - sc->sc_phys = p->ba_ram; - - /* grab initial (current) color map */ - bt->bt_addr = 0; - for (i = 0; i < 256 * 3 / 4; i++) - sc->sc_cmap.cm_chip[i] = bt->bt_cmap; - /* make sure we are not blanked (see cgthreeunblank) */ - bt->bt_addr = 0x06; /* command reg */ - bt->bt_ctrl = 0x73; /* overlay plane */ - bt->bt_addr = 0x04; /* read mask */ - bt->bt_ctrl = 0xff; /* color planes */ - - if (isconsole) { - printf(" (console)\n"); -#ifdef RCONSOLE - rcons_init(&sc->sc_fb); -#endif - } else - printf("\n"); - sbus_establish(&sc->sc_sd, &sc->sc_dev); - if (node == fbnode) - fb_attach(&sc->sc_fb); -} - -int -cgthreeopen(dev, flags, mode, p) - dev_t dev; - int flags, mode; - struct proc *p; -{ - int unit = minor(dev); - - if (unit >= cgthreecd.cd_ndevs || cgthreecd.cd_devs[unit] == NULL) - return (ENXIO); - return (0); -} - -int -cgthreeclose(dev, flags, mode, p) - dev_t dev; - int flags, mode; - struct proc *p; -{ - - return (0); -} - -int -cgthreeioctl(dev, cmd, data, flags, p) - dev_t dev; - int cmd; - register caddr_t data; - int flags; - struct proc *p; -{ - register struct cgthree_softc *sc = cgthreecd.cd_devs[minor(dev)]; - register struct fbgattr *fba; - int error; - - switch (cmd) { - - case FBIOGTYPE: - *(struct fbtype *)data = sc->sc_fb.fb_type; - break; - - case FBIOGATTR: - fba = (struct fbgattr *)data; - fba->real_type = sc->sc_fb.fb_type.fb_type; - fba->owner = 0; /* XXX ??? */ - fba->fbtype = sc->sc_fb.fb_type; - fba->sattr.flags = 0; - fba->sattr.emu_type = sc->sc_fb.fb_type.fb_type; - fba->sattr.dev_specific[0] = -1; - fba->emu_types[0] = sc->sc_fb.fb_type.fb_type; - fba->emu_types[1] = -1; - break; - - case FBIOGETCMAP: - return (bt_getcmap((struct fbcmap *)data, &sc->sc_cmap, 256)); - - case FBIOPUTCMAP: - /* copy to software map */ -#define p ((struct fbcmap *)data) - error = bt_putcmap(p, &sc->sc_cmap, 256); - if (error) - return (error); - /* now blast them into the chip */ - /* XXX should use retrace interrupt */ - cgthreeloadcmap(sc, p->index, p->count); -#undef p - break; - - case FBIOGVIDEO: - *(int *)data = sc->sc_blanked; - break; - - case FBIOSVIDEO: - if (*(int *)data) - cgthreeunblank(&sc->sc_dev); - else if (!sc->sc_blanked) { - register volatile struct bt_regs *bt; - - bt = sc->sc_bt; - bt->bt_addr = 0x06; /* command reg */ - bt->bt_ctrl = 0x70; /* overlay plane */ - bt->bt_addr = 0x04; /* read mask */ - bt->bt_ctrl = 0x00; /* color planes */ - /* - * Set color 0 to black -- note that this overwrites - * R of color 1. - */ - bt->bt_addr = 0; - bt->bt_cmap = 0; - - sc->sc_blanked = 1; - } - break; - - default: - return (ENOTTY); - } - return (0); -} - -/* - * Undo the effect of an FBIOSVIDEO that turns the video off. - */ -static void -cgthreeunblank(dev) - struct device *dev; -{ - struct cgthree_softc *sc = (struct cgthree_softc *)dev; - register volatile struct bt_regs *bt; - - if (sc->sc_blanked) { - sc->sc_blanked = 0; - bt = sc->sc_bt; - /* restore color 0 (and R of color 1) */ - bt->bt_addr = 0; - bt->bt_cmap = sc->sc_cmap.cm_chip[0]; - - /* restore read mask */ - bt->bt_addr = 0x06; /* command reg */ - bt->bt_ctrl = 0x73; /* overlay plane */ - bt->bt_addr = 0x04; /* read mask */ - bt->bt_ctrl = 0xff; /* color planes */ - } -} - -/* - * Load a subset of the current (new) colormap into the Brooktree DAC. - */ -static void -cgthreeloadcmap(sc, start, ncolors) - register struct cgthree_softc *sc; - register int start, ncolors; -{ - register volatile struct bt_regs *bt; - register u_int *ip; - register int count; - - ip = &sc->sc_cmap.cm_chip[BT_D4M3(start)]; /* start/4 * 3 */ - count = BT_D4M3(start + ncolors - 1) - BT_D4M3(start) + 3; - bt = sc->sc_bt; - bt->bt_addr = BT_D4M4(start); - while (--count >= 0) - bt->bt_cmap = *ip++; -} - -/* - * Return the address that would map the given device at the given - * offset, allowing for the given protection, or return -1 for error. - * - * The cg3 is mapped starting at 256KB, for pseudo-compatibility with - * the cg4 (which had an overlay plane in the first 128K and an enable - * plane in the next 128K). X11 uses only 256k+ region but tries to - * map the whole thing, so we repeatedly map the first 256K to the - * first page of the color screen. If someone tries to use the overlay - * and enable regions, they will get a surprise.... - * - * As well, mapping at an offset of 0x04000000 causes the cg3 to be - * mapped in flat mode without the cg4 emulation. - */ -int -cgthreemap(dev, off, prot) - dev_t dev; - int off, prot; -{ - register struct cgthree_softc *sc = cgthreecd.cd_devs[minor(dev)]; -#define START (128*1024 + 128*1024) -#define NOOVERLAY (0x04000000) - - if (off & PGOFSET) - panic("cgthreemap"); - if ((u_int)off >= NOOVERLAY) - off -= NOOVERLAY; - else if ((u_int)off >= START) - off -= START; - else - off = 0; - if ((unsigned)off >= sc->sc_fb.fb_type.fb_size) - return (-1); - /* - * I turned on PMAP_NC here to disable the cache as I was - * getting horribly broken behaviour with it on. - */ - return ((int)sc->sc_phys + off + PMAP_OBIO + PMAP_NC); -} diff --git a/sys/arch/sparc/sbus/cgthreereg.h b/sys/arch/sparc/sbus/cgthreereg.h deleted file mode 100644 index 36cde92cd169..000000000000 --- a/sys/arch/sparc/sbus/cgthreereg.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)cgthreereg.h 8.1 (Berkeley) 6/11/93 - * - * from: Header: cgthreereg.h,v 1.7 93/10/31 05:09:28 torek Exp - * $Id: cgthreereg.h,v 1.3 1994/03/03 12:22:04 deraadt Exp $ - */ - -/* - * cgthree display registers. Much like bwtwo registers, except that - * there is a Brooktree Video DAC in there (so we also use btreg.h). - */ - -/* offsets */ -#define CG3REG_ID 0 -#define CG3REG_REG 0x400000 -#define CG3REG_MEM 0x800000 - -/* same, but for gdb */ -struct cgthree_all { - long ba_id; /* ID = 0xfe010104 on my IPC */ - char ba_xxx0[0x400000-4]; - struct bt_regs ba_btreg; /* Brooktree registers */ - char ba_xxx1[0x400000-sizeof(struct bt_regs)]; - char ba_ram[4096]; /* actually larger */ -}; diff --git a/sys/arch/sparc/sbus/dmareg.h b/sys/arch/sparc/sbus/dmareg.h deleted file mode 100644 index 236fc957957c..000000000000 --- a/sys/arch/sparc/sbus/dmareg.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)dmareg.h 8.1 (Berkeley) 6/11/93 - * - * from: Header: dmareg.h,v 1.6 93/04/27 14:39:17 torek Exp (LBL) - * $Id: dmareg.h,v 1.1 1993/10/02 10:23:49 deraadt Exp $ - */ - -/* - * Sun-4c Sbus slot 0 DMA registers. - * - * Note that the dma_addr on the rev 1 gate array cannot increment - * across a 16 MB boundary (the counter is only 24 bits wide; the - * top 8 bits are simply latched). - */ -struct dmareg { - u_long dma_csr; /* control/status register */ - u_long dma_addr; /* address (virtual: is fed to MMU) */ - u_long dma_bc; /* byte count (not used) */ - u_long dma_diag; /* diagnostic register (not used) */ -}; - -/* - * Bits in dma_csr. - * DMA chip revision numbers are confusing (rev 3 = `DMA2'?!). - * Not my fault; we just live with what they give us.... - * - * Notes in [brackets]: - * 1: used this way in rev 1 (`DMA') chips. - * 2: used this way in rev 2 (`DMA+') chips. - * 3: used this way in rev 3 (`DMA2') chips. - * R: not self-clearing, must be reset after being set. - * D: `drain' is like Unibus `bdp purge', i.e., it tells - * the chip to finish up, because there is no more data - * going into the buffer register. Supposed to be needed - * only in rev 1, but apparently needed or harmless in all - * revs. Self-clearing (hence write-only). - * I: also enables scsi interrupts. - */ -#define DMA_REV(csr) (((csr) >> 28) & 0xf) /* device id field */ -#define DMAREV_1 0x8 /* rev 1 DMA gate array */ -#define DMAREV_2 0x9 /* rev 2 DMA gate array (`DMA+') */ -#define DMAREV_3 0xa /* rev 3 DMA gate array (`DMA2') */ - -#define DMA_1ZERO 0x0fff0000 /* unused; reads as zero [1] */ -#define DMA_NAL 0x08000000 /* next address loaded [2] (ro) */ -#define DMA_AL 0x04000000 /* address loaded [2] (ro) */ -#define DMA_ON 0x02000000 /* working [2] (ro) */ -#define DMA_NAE 0x01000000 /* next-address enable [2] (rw) */ -#define DMA_DTCI 0x00800000 /* disable DMA_TC intr [2] (rw) */ -#define DMA_TURBO 0x00400000 /* faster 53C90A mode [2] (rw) */ -#define DMA_LERR 0x00200000 /* LANCE error [2] (ro) */ -#define DMA_TWOCYCLE 0x00200000 /* two cycle mode [3] (rw?) */ -#define DMA_ALE 0x00100000 /* LANCE addr latch ena [2] (rw) */ -#define DMA_2ZERO 0x000f0000 /* unused; reads as zero [2] */ -#define DMA_BURSTMASK 0x000c0000 /* burst mode mask [3] */ -#define DMA_BURST16 0x00000000 /* 16-byte bursts (default) */ -#define DMA_BURST32 0x00040000 /* 32-byte bursts */ -#define DMA_BURST0 0x00080000 /* no bursts */ -#define DMA_ILACC 0x00008000 /* for new AMD ethernet chip [1,2] */ -#define DMA_TC 0x00004000 /* terminal cnt: dma_bc ran out [1,2] */ -#define DMA_BCE 0x00002000 /* byte count enable (leave 0) */ -#define DMA_BO 0x00001800 /* byte offset [1] (ro) */ -#define DMA_RP 0x00000400 /* busy, plz don't flush [1] (ro) */ -#define DMA_ENA 0x00000200 /* enable the dma chip */ -#define DMA_READ 0x00000100 /* set for dev=>mem, i.e., read() */ -#define DMA_RESET 0x00000080 /* reset dma chip [R] */ -#define DMA_DRAIN 0x00000040 /* drain buffered data [D,1] (wo) */ -#define DMA_SLAVEERR 0x00000040 /* slave error [2,3] (ro) */ -#define DMA_FLUSH 0x00000020 /* clear PC, EP, and TC [2,3] (wo) */ -#define DMA_IE 0x00000010 /* interrupt enable [2,3,I] */ -#define DMA_PC 0x0000000c /* bytes in pack reg [1] (ro) */ -#define DMA_DRAINING 0x0000000c /* nonzero => draining [2,3] (ro) */ -#define DMA_EP 0x00000002 /* error pending (ro) */ -#define DMA_IP 0x00000001 /* interrupt pending (ro) */ - -#define DMA_REV1_BITS \ -"\20\20ILACC\17TC\16BCE\13RP\12ENA\11READ\10RESET\7DRAIN\2EP\1IP" - -/* Look ma, second system syndrome! */ -#define DMA_REV2_BITS \ -"\20\34NAL\33AL\32ON\31NAE\30DTCI\27TURBO\26LERR\25ALE\ -\20ILACC\17TC\16BCE\12ENA\11READ\10RESET\7SLAVEERR\6FLUSH\5IE\2EP\1IP" - -/* (Note how most of the crap has been discarded now.) */ -#define DMA_REV3_BITS \ -"\20\26TWOCYCLE\16BCE\12ENA\11READ\10RESET\7SLAVEERR\6FLUSH\5IE\2EP\1IP" - -/* DMA_BYTE turns the DMA_BO field into a byte index */ -#define DMA_BYTE(csr) (((csr) >> 11) & 3) - -/* DMA_NPACK turns the DMA_PC field into a byte count */ -#define DMA_NPACK(csr) (((csr) >> 2) & 3) - -/* DMA_INTR is true if the DMA chip says an ESP or DMA interrupt is pending */ -#define DMA_INTR(csr) ((csr) & (DMA_IP | DMA_EP)) diff --git a/sys/arch/sparc/sbus/esp.c b/sys/arch/sparc/sbus/esp.c deleted file mode 100644 index b744d7fdaee2..000000000000 --- a/sys/arch/sparc/sbus/esp.c +++ /dev/null @@ -1,1327 +0,0 @@ -/* - * Copyright (c) 1988, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)esp.c 8.4 (Berkeley) 5/6/94 - * - * from: Header: esp.c,v 1.28 93/04/27 14:40:44 torek Exp (LBL) - * $Id: esp.c,v 1.6 1994/08/13 08:53:38 deraadt Exp $ - * - * Loosely derived from Mary Baker's devSCSIC90.c from the Berkeley - * Sprite project, which is: - * - * Copyright 1988 Regents of the University of California - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The University of California - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - * - * from /sprite/src/kernel/dev/sun4c.md/RCS/devSCSIC90.c,v 1.4 - * 90/12/19 12:37:58 mgbaker Exp $ SPRITE (Berkeley) - */ - -/* - * Sbus ESP/DMA driver. A single driver must be used for both devices - * as they are physically tied to each other: The DMA chip can only - * be used to assist ESP SCSI transactions; the ESP interrupt enable is - * in the DMA chip csr. - * - * Since DMA and SCSI interrupts are handled in the same routine, the - * DMA device does not declare itself as an sbus device. This saves - * some space. - */ - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#define ESP_PHASE_NAMES -#include -#include - -/* - * This driver is largely a giant state machine: - * - * Given some previous SCSI state (as set up or tracked by us - * earlier) and the interrupt registers provided on the chips - * (dmacsr, espstat, espstep, and espintr), derive an action. - * In many cases this is just a matter of reading the target's - * phase and following its orders, which sets a new state. - * - * This sequencing is done in espact(); the state is primed in espselect(). - * - * Data transfer is always done via DMA. Unfortunately, there are - * limits in the DMA and ESP chips on how much data can be moved - * in a single operation. The ESP chip has a 16-bit counter, so - * it is limited to 65536 bytes. More insidiously, while the DMA - * chip has a 32-bit address, this is composed of a 24-bit counter - * with an 8-bit latch, so it cannot cross a 16 MB boundary. To - * handle these, we program a smaller count than our caller requests; - * when this shorter transfer is done, if the target is still up - * for data transfer, we simply keep going (updating the DMA address) - * as needed. - */ - -/* per-DMA variables */ -struct dma_softc { - struct device dc_dev; /* base device */ - volatile struct dmareg *dc_dma; /* register virtual address */ - int dc_dmarev; /* revision */ - char *dc_dmafmt; /* format for error messages */ -}; -void dmaattach(struct device *, struct device *, void *); -struct cfdriver dmacd = - { NULL, "dma", matchbyname, dmaattach, DV_DULL, sizeof(struct dma_softc) }; - -/* per-ESP variables */ -struct esp_softc { - /* - * External interfaces. - */ - struct hba_softc sc_hba; /* base device + hba, must be first */ -#define sc_dev sc_hba.hba_dev - struct sbusdev sc_sd; /* sbus device */ - struct intrhand sc_ih; /* interrupt entry */ - struct evcnt sc_intrcnt; /* interrupt counter */ - struct dma_softc *sc_dc; /* pointer to corresponding dma sc */ - - /* - * Addresses mapped to hardware registers. - */ - volatile struct espreg *sc_esp; - volatile struct dmareg *sc_dma; - - /* - * Copies of registers cleared/unlatched by reading. - * (FIFO flags is not cleared, but we want it for debugging.) - */ - u_long sc_dmacsr; - u_char sc_espstat; - u_char sc_espstep; - u_char sc_espintr; - u_char sc_espfflags; - - /* miscellaneous */ - int sc_clockfreq; /* clock frequency */ - u_char sc_sel_timeout; /* select timeout */ - u_char sc_id; /* initiator ID (default = 7) */ - u_char sc_esptype; /* 100, 100A, 2xx (see below) */ - u_char sc_ccf; /* clock conversion factor */ - u_char sc_conf1; /* value for config reg 1 */ - u_char sc_conf2; /* value for config reg 2 */ - u_char sc_conf3; /* value for config reg 3 */ - struct bootpath *sc_bp; /* esp bootpath so far */ - - /* - * Information pertaining to the current transfer, - * including sequencing. - * - * The size of sc_msg is the size of the ESP fifo, - * since we do message-in simply by allowing the fifo to fill. - */ - char sc_probing; /* used during autoconf; see below */ - char sc_iwant; /* true => icmd needs wakeup on idle */ - char sc_state; /* SCSI protocol state; see below */ - char sc_sentcmd; /* set once we get cmd out */ - char sc_dmaactive; /* true => doing dma */ -#ifdef notyet - u_char sc_sync; /* synchronous transfer stuff (?) */ -#endif - u_char sc_stat[2]; /* status from last `status' phase */ - u_char sc_msg[16]; /* message from device */ - u_short sc_dmactl; /* control to load into dma csr */ - u_long sc_dmaaddr; /* address for next xfer */ - int sc_dmasize; /* size of current xfer */ - int sc_resid; /* count of bytes not yet xferred */ - int sc_targ; /* the target involved */ - struct scsi_cdb *sc_curcdb; /* ptr to current command */ - /* might cdbspace eventually be per-target? */ - struct scsi_cdb sc_cdbspace; /* space for one command */ -}; - -/* - * Values for sc_esptype (used to control configuration reset, and for - * workarounds for chip bugs). The order is important; see espreset(). - */ -#define ESP100 0 -#define ESP100A 1 -#define ESP2XX 2 - -/* - * Probe state. 0 means not probing. While looking for each target - * we set this to PROBE_TESTING and do a TEST UNIT READY on unit 0. - * If selection fails, this is changed to PROBE_NO_TARGET; otherwise - * we assume the target exists, regardless of the result of the test. - */ -#define PROBE_TESTING 1 -#define PROBE_NO_TARGET 2 - -/* - * States in sc_state. - * - * Note that S_SVC is rare: normally we load the SCSI command into the - * ESP fifo and get interrupted only when the device has gone to data - * or status phase. If the device wants to play games, though, we end - * up doing things differently. - */ -char *espstates[] = { -#define S_IDLE 0 /* not doing anything */ - "idle", -#define S_SEL 1 /* expecting select done interrupt */ - "selecting", -#define S_SVC 2 /* expecting service req interrupt */ - "waiting for svc req", -#define S_DI 3 /* expecting data-in done interrupt */ - "receiving data", -#define S_DO 4 /* expecting data-out done interrupt */ - "sending data", -#define S_STAT 5 /* expecting status done interrupt */ - "receiving status", -#define S_MI 6 /* expecting message-in done interrupt */ - "receiving message", -#define S_FI 7 /* expecting final disconnect interrupt */ - "waiting for disconnect" -}; - -/* - * Hardware limits on transfer sizes (see comments at top). - */ -#define ESPMAX (64 * 1024) -#define DMAMAX(a) (0x01000000 - ((a) & 0x00ffffff)) - -/* - * Return values from espact(). - */ -#define ACT_CONT 0 /* espact() handled everything */ -#define ACT_IO 1 /* espact() is xferring data */ -#define ACT_DONE 2 /* handled everything, and op is now done */ -#define ACT_ERROR 3 /* an error occurred, op has been trashed */ -#define ACT_RESET 4 /* please reset ESP, then do ACT_ERROR */ -#define ACT_QUICKINTR 5 /* another interrupt is expected immediately */ - -/* autoconfiguration driver */ -void espattach(struct device *, struct device *, void *); -struct cfdriver espcd = - { NULL, "esp", matchbyname, espattach, DV_DULL, sizeof(struct esp_softc) }; - -/* Sbus driver */ -void espsbreset(struct device *); - -/* interrupt interface */ -int espintr(void *); - -/* SCSI HBA driver */ -int espicmd(struct hba_softc *, int, struct scsi_cdb *, caddr_t, int, int); -int espdump(struct hba_softc *, int, struct scsi_cdb *, caddr_t, int); -void espstart(struct device *, struct sq *, struct buf *, - scdgo_fn, struct device *); -int espgo(struct device *, int, scintr_fn, struct device *, - struct buf *, int); -void esprel(struct device *); -void esphbareset(struct hba_softc *, int); -static struct hbadriver esphbadriver = - { espicmd, espdump, espstart, espgo, esprel, esphbareset }; - -/* other prototypes */ -static void espdoattach(int); -static void dmareset(struct esp_softc *); -static void espreset(struct esp_softc *, int); -static void esperror(struct esp_softc *, const char *); -static int espact(struct esp_softc *); -void espselect(struct esp_softc *, int, struct scsi_cdb *); - -/* second arg to espreset() */ -#define RESET_ESPCHIP 0x1 -#define RESET_SCSIBUS 0x2 -#define RESET_BOTH (RESET_ESPCHIP | RESET_SCSIBUS) - -/* - * Attach a found DMA chip. - * The second argument is really a pointer to an sbus_attach_args. - */ -void -dmaattach(parent, dev, args) - struct device *parent; - struct device *dev; - void *args; -{ - register struct dma_softc *dc = (struct dma_softc *)dev; - register struct sbus_attach_args *sa = args; - register volatile struct dmareg *dma; - register int rev; - struct esp_softc *esc; - - if (sa->sa_ra.ra_vaddr) - dma = (volatile struct dmareg *)sa->sa_ra.ra_vaddr; - else - dma = (volatile struct dmareg *) - mapiodev(sa->sa_ra.ra_paddr, sizeof(struct dmareg)); - dc->dc_dma = dma; - - switch (rev = DMA_REV(dma->dma_csr)) { - case DMAREV_1: - printf(": rev 1\n"); - dc->dc_dmafmt = DMA_REV1_BITS; - break; - case DMAREV_2: - printf(": rev 2\n"); - dc->dc_dmafmt = DMA_REV2_BITS; - break; - case DMAREV_3: - printf(": rev 3\n"); - printf("WARNING: esp.c not yet updated for rev 3\n"); - dc->dc_dmafmt = DMA_REV3_BITS; - break; - default: - printf(": unknown revision code 0x%x\n", rev); - dc->dc_dmafmt = DMA_REV3_BITS; /* cross fingers */ - break; - } - dc->dc_dmarev = rev; - espdoattach(dc->dc_dev.dv_unit); -} - -/* - * Attach a found ESP chip. Search for targets; attach each one found. - * The latter must be deferred if the corresponding dma chip has not yet - * been configured. - */ -void -espattach(parent, self, args) - struct device *parent; - struct device *self; - void *args; -{ - register struct esp_softc *sc = (struct esp_softc *)self; - register struct sbus_attach_args *sa = args; - register volatile struct espreg *esp; - register struct bootpath *bp; - int node, pri, freq, t; - - if (sa->sa_ra.ra_nintr != 1) { - printf(": expected 1 interrupt, got %d\n", sa->sa_ra.ra_nintr); - return; - } - pri = sa->sa_ra.ra_intr[0].int_pri; - printf(" pri %d", pri); - if (sa->sa_ra.ra_vaddr) - esp = (volatile struct espreg *)sa->sa_ra.ra_vaddr; - else - esp = (volatile struct espreg *) - mapiodev(sa->sa_ra.ra_paddr, sizeof(struct espreg)); - sc->sc_esp = esp; - node = sa->sa_ra.ra_node; - sc->sc_id = getpropint(node, "initiator-id", 7); - freq = getpropint(node, "clock-frequency", -1); - if (freq < 0) - freq = - ((struct sbus_softc *)sc->sc_dev.dv_parent)->sc_clockfreq; - - /* MIGHT NEED TO RESET ESP CHIP HERE ...? */ - - /* - * Find out whether we have a -100, -100A, or -2xx, - * and what speed it runs at. - */ - sc->sc_conf1 = sc->sc_id | ESPCONF1_PARENB; - /* sc->sc_conf2 = 0; */ - /* sc->sc_conf3 = 0; */ - esp->esp_conf1 = sc->sc_conf1; - esp->esp_conf2 = 0; - esp->esp_conf2 = ESPCONF2_SCSI2 | ESPCONF2_RPE; - if ((esp->esp_conf2 & ~ESPCONF2_RSVD) != - (ESPCONF2_SCSI2 | ESPCONF2_RPE)) { - printf(": ESP100"); - sc->sc_esptype = ESP100; - } else { - esp->esp_conf2 = 0; - esp->esp_conf3 = 0; - esp->esp_conf3 = 5; - if (esp->esp_conf3 != 5) { /* XXX def bits */ - printf(": ESP100A"); - sc->sc_esptype = ESP100A; - } else { - esp->esp_conf3 = 0; - printf(": ESP2XX"); - sc->sc_esptype = ESP2XX; - } - } - printf(", clock = %s MHz, ID = %d\n", clockfreq(freq), sc->sc_id); - - /* - * Set clock conversion factor and select timeout. - * N.B.: clock frequency is not actually used in the rest - * of the driver; I calculate it here for completeness only - * (so I can see it when debugging). - */ - sc->sc_clockfreq = freq; - freq = howmany(freq, 1000 * 1000); /* convert to MHz */ - t = ESPCCF_FROMMHZ(freq); - if (t < ESPCCF_MIN) - t = ESPCCF_MIN; - sc->sc_ccf = t; - t = ESPTIMO_REGVAL(250, t, freq); /* timeout = 250 ms. */ - if (t >= 256) - t = 0; - sc->sc_sel_timeout = t; - - /* - * Link into sbus; set interrupt handler. - */ - sc->sc_sd.sd_reset = espsbreset; - sbus_establish(&sc->sc_sd, &sc->sc_dev); - sc->sc_ih.ih_fun = espintr; - sc->sc_ih.ih_arg = sc; - intr_establish(pri, &sc->sc_ih); - evcnt_attach(&sc->sc_dev, "intr", &sc->sc_intrcnt); - -#define SAME_ESP(bp, sa) \ - ((bp->val[0] == sa->sa_slot && bp->val[1] == sa->sa_offset) || \ - (bp->val[0] == -1 && bp->val[1] == sc->sc_dev.dv_unit)) - - bp = sa->sa_ra.ra_bp; - if (bp != NULL && strcmp(bp->name, "esp") == 0 && SAME_ESP(bp, sa)) - sc->sc_bp = bp + 1; - espdoattach(sc->sc_dev.dv_unit); -} - -/* - * `Final' attach of esp occurs once esp and dma chips have been found - * and assigned virtual addresses. Set up the ESP SCSI data structures - * and probe the SCSI bus. - */ -static void -espdoattach(unit) - int unit; -{ - register struct esp_softc *sc; - register struct dma_softc *dc; - register struct bootpath *bp; - register struct targ *t; - register int targ, u; - - /* make sure we have both */ - if (espcd.cd_ndevs <= unit || - dmacd.cd_ndevs <= unit || - (sc = espcd.cd_devs[unit]) == NULL || - (dc = dmacd.cd_devs[unit]) == NULL) - return; - sc->sc_dc = dc; - sc->sc_dma = dc->dc_dma; - sc->sc_hba.hba_driver = &esphbadriver; - - sc->sc_dma->dma_csr = 0; /* ??? */ - espreset(sc, RESET_ESPCHIP); - - /* MAYBE THIS SHOULD BE MOVED TO scsi_subr.c? */ - for (targ = 0; targ < 8; targ++) { - if (targ == sc->sc_id) - continue; - sc->sc_probing = PROBE_TESTING; - (void)scsi_test_unit_ready(&sc->sc_hba, targ, 0); - if (sc->sc_probing != PROBE_NO_TARGET) { - sc->sc_probing = 0; - SCSI_FOUNDTARGET(&sc->sc_hba, targ); - } - } - sc->sc_probing = 0; - - /* - * See if we booted from a unit on this target. We could - * compare bp->name against the unit's name but there's no - * real need since a target and unit uniquely specify a - * scsi device. - */ - if ((bp = sc->sc_bp) != NULL && (u_int)(targ = bp->val[0]) < 8 && - (u_int)(u = bp->val[1]) < 8 && - (t = sc->sc_hba.hba_targets[targ]) != NULL && t->t_units[u] != NULL) - bootdv = t->t_units[u]->u_dev; -} - -/* - * We are not allowed to touch the DMA "flush" and "drain" bits - * while it is still thinking about a request (DMA_RP). - */ -#define DMAWAIT(dma) while ((dma)->dma_csr & DMA_RP) DELAY(1) -#define DMAWAIT1(dma) while ((dma)->dma_csr & DMA_PC) DELAY(1) - -/* - * Reset the DMA chip. - */ -static void -dmareset(sc) - struct esp_softc *sc; -{ - register volatile struct dmareg *dma = sc->sc_dma; - - DMAWAIT(dma); - dma->dma_csr |= DMA_RESET; - DELAY(200); - dma->dma_csr &= ~DMA_RESET; /* ??? */ - sc->sc_dmaactive = 0; - if (sc->sc_dc->dc_dmarev == DMAREV_2 && sc->sc_esptype != ESP100) - dma->dma_csr |= DMA_TURBO; - dma->dma_csr |= DMA_IE; /* enable interrupts */ - DELAY(200); -} - -/* - * Reset the chip and/or SCSI bus (always resets DMA). - */ -static void -espreset(sc, how) - register struct esp_softc *sc; - int how; -{ - register volatile struct espreg *esp = sc->sc_esp; - - dmareset(sc); - if (how & RESET_ESPCHIP) { - esp->esp_cmd = ESPCMD_RESET_CHIP; - esp->esp_cmd = ESPCMD_NOP; - /* - * Reload configuration registers (cleared by - * RESET_CHIP command). Reloading conf2 on an - * ESP100 goofs it up, so out of paranoia we load - * only the registers that exist. - */ - esp->esp_conf1 = sc->sc_conf1; - if (sc->sc_esptype > ESP100) { /* 100A, 2XX */ - esp->esp_conf2 = sc->sc_conf2; - if (sc->sc_esptype > ESP100A) /* 2XX only */ - esp->esp_conf3 = sc->sc_conf3; - } - esp->esp_ccf = sc->sc_ccf; - esp->esp_timeout = sc->sc_sel_timeout; - /* We set synch offset later. */ - } - if (how & RESET_SCSIBUS) { - /* - * The chip should retain most of its parameters - * (including esp_ccf) across this kind of reset - * (see section 3.5 of Emulex documentation). - */ - /* turn off scsi bus reset interrupts and reset scsi bus */ - esp->esp_conf1 = sc->sc_conf1 | ESPCONF1_REPORT; - esp->esp_cmd = ESPCMD_RESET_BUS; - esp->esp_cmd = ESPCMD_NOP; - DELAY(100000); /* ??? */ - (void)esp->esp_intr; - esp->esp_conf1 = sc->sc_conf1; - } - sc->sc_state = S_IDLE; -} - -/* - * Reset the SCSI bus and, optionally, all attached targets. - */ -void -esphbareset(hba, resetunits) - struct hba_softc *hba; - int resetunits; -{ - register struct esp_softc *sc = (struct esp_softc *)hba; - - espreset(sc, RESET_SCSIBUS); - if (resetunits) - scsi_reset_units(&sc->sc_hba); -} - -/* - * Reset the esp, after an Sbus reset. - * Also resets corresponding dma chip. - * - * THIS ROUTINE MIGHT GO AWAY - */ -void -espsbreset(dev) - struct device *dev; -{ - struct esp_softc *sc = (struct esp_softc *)dev; - - if (sc->sc_dc) { - printf(" %s %s", sc->sc_dc->dc_dev.dv_xname, - sc->sc_dev.dv_xname); - esphbareset(&sc->sc_hba, 1); - } -} - -/* - * Log an error. - */ -static void -esperror(sc, err) - register struct esp_softc *sc; - const char *err; -{ - int stat; - - stat = sc->sc_espstat; - printf( -"%s target %d cmd 0x%x (%s): %s:\n\ -\tstat=%b (%s) step=%x dmacsr=%b fflags=%x intr=%b\n", - sc->sc_dev.dv_xname, sc->sc_targ, sc->sc_curcdb->cdb_bytes[0], - espstates[sc->sc_state], err, - stat, ESPSTAT_BITS, espphases[stat & ESPSTAT_PHASE], - sc->sc_espstep, sc->sc_dmacsr, sc->sc_dc->dc_dmafmt, - sc->sc_espfflags, sc->sc_espintr, ESPINTR_BITS); -} - -/* - * Issue a select, loading command into the FIFO. - * Return nonzero on error, 0 if OK. - * Sets state to `selecting'; espact() will sequence state FSM. - */ -void -espselect(sc, targ, cdb) - register struct esp_softc *sc; - register int targ; - register struct scsi_cdb *cdb; -{ - register volatile struct espreg *esp; - register int i, cmdlen; - - sc->sc_targ = targ; - sc->sc_state = S_SEL; - sc->sc_curcdb = cdb; - sc->sc_sentcmd = 0; - sc->sc_stat[0] = 0xff; /* ??? */ - sc->sc_msg[0] = 0xff; /* ??? */ - - /* - * Try to talk to target. - * Synch offset 0 => asynchronous transfer. - */ - esp = sc->sc_esp; - esp->esp_id = targ; - esp->esp_syncoff = 0; - - /* - * Stuff the command bytes into the fifo. - * Select without attention since we do not do disconnect yet. - */ - cmdlen = SCSICMDLEN(cdb->cdb_bytes[0]); - for (i = 0; i < cmdlen; i++) - esp->esp_fifo = cdb->cdb_bytes[i]; - esp->esp_cmd = ESPCMD_SEL_NATN; - /* the rest is done elsewhere */ -} - -/* - * Sequence through the SCSI state machine. Return the action to take. - * - * Most of the work happens here. - * - * There are three interrupt sources: - * -- ESP interrupt request (typically, some device wants something). - * -- DMA memory error. - * -- DMA byte count has reached 0 (we do not often want this one but - * can only turn it off in rev 2 DMA chips, it seems). - * DOES THIS OCCUR AT ALL HERE? THERE IS NOTHING TO HANDLE IT! - */ -static int -espact(sc) - register struct esp_softc *sc; -{ - register volatile struct espreg *esp; - register volatile struct dmareg *dma; - register int reg, i, resid, newstate; - register struct scsi_cdb *cdb; - - dma = sc->sc_dma; - /* check various error conditions, using as little code as possible */ - if (sc->sc_dmacsr & DMA_EP) { - esperror(sc, "DMA error"); - DMAWAIT(dma); - dma->dma_csr |= DMA_FLUSH; - DMAWAIT1(dma); - return (ACT_ERROR); - } - reg = sc->sc_espstat; - if (reg & ESPSTAT_GE) { - /* - * This often occurs when there is no target. - * (See DSC code below.) - */ - if (sc->sc_espintr & ESPINTR_DSC && - sc->sc_state == S_SEL && sc->sc_probing) { - sc->sc_probing = PROBE_NO_TARGET; - return (ACT_RESET); - } -esperror(sc, "DIAG: gross error (ignored)"); - } - if (reg & ESPSTAT_PE) { - esperror(sc, "parity error"); - return (ACT_RESET); - } - reg = sc->sc_espintr; -#define ERR (ESPINTR_SBR|ESPINTR_ILC|ESPINTR_RSL|ESPINTR_SAT|ESPINTR_SEL) - if (reg & ERR) { - if (reg & ESPINTR_SBR) - esperror(sc, "scsi bus reset"); - else if (reg & ESPINTR_ILC) - esperror(sc, "illegal command (driver bug)"); - else { - printf("%s: target %d", sc->sc_dev.dv_xname, - sc->sc_targ); - if (reg & ESPINTR_RSL) - printf(" tried to reselect;"); - if (reg & ESPINTR_SAT) - printf(" selected with ATN;"); - if (reg & ESPINTR_SEL) - printf(" selected us as target;"); - printf("we do not allow this yet\n"); - } - return (ACT_ERROR); - } -#undef ERR - - esp = sc->sc_esp; - - /* - * Disconnect currently only allowed in `final interrupt' states. - */ - if (reg & ESPINTR_DSC) { - if (sc->sc_state == S_FI) - return (ACT_DONE); - /* - * If we were doing a select just to test the existence - * of the target, note that it did not respond; otherwise - * gripe. - */ - if (sc->sc_state == S_SEL) { - if (sc->sc_probing) { - sc->sc_probing = PROBE_NO_TARGET; - return (ACT_RESET); - } - } - /* flush fifo, in case we were selecting or sending data */ - esp->esp_cmd = ESPCMD_FLUSH_FIFO; - DELAY(1); - printf("%s: target %d not responding\n", - sc->sc_dev.dv_xname, sc->sc_targ); - return (ACT_ERROR); - } - - /* - * Okay, things are moving along. - * What were we doing the last time we did something, - * and did it complete normally? - */ - switch (sc->sc_state) { - - case S_SEL: - /* - * We were selecting. Arbitration and select are - * complete (because ESPINTR_DSC was not set), but - * there is no guarantee the command went out. - */ - if ((reg & (ESPINTR_SVC|ESPINTR_CMP)) != - (ESPINTR_SVC|ESPINTR_CMP)) { - esperror(sc, "selection failed"); - return (ACT_RESET); - } - if (sc->sc_espstep == ESPSTEP_DONE) { - sc->sc_sentcmd = 1; - break; - } - if (sc->sc_espstep == 2) { - /* - * We got something other than command phase. - * Just pretend things are normal; the - * device will ask for the command later. - */ -esperror(sc, "DIAG: esp step 2"); - } else if (sc->sc_espstep == 3) { - /* - * Device entered command phase and then exited it - * before we finished handing out the command. - * Do not know how to handle this. - */ -esperror(sc, "DIAG: esp step 3"); - } else { - printf("%s: mysterious esp step %d\n", - sc->sc_dev.dv_xname, sc->sc_espstep); - return (ACT_RESET); - } - - /* - * Part of the command may still be lodged in the FIFO. - */ - if (ESP_NFIFO(sc->sc_espfflags)) { - esp->esp_cmd = ESPCMD_FLUSH_FIFO; - DELAY(1); - } - break; - - case S_SVC: - /* - * We were waiting for phase change after stuffing the command - * into the FIFO. Make sure it got out. - */ - if (ESP_NFIFO(sc->sc_espfflags)) { -esperror(sc, "DIAG: CMDSVC, fifo not empty"); - esp->esp_cmd = ESPCMD_FLUSH_FIFO; - DELAY(1); - } else - sc->sc_sentcmd = 1; - break; - - case S_DI: - /* - * We were doing DMA data in, and expecting a - * transfer-count-zero interrupt or a phase change. - * We got that; drain the pack register and handle - * as for data out -- but ignore FIFO (it should be - * empty, except for sync mode which we are not - * using anyway). - */ - DMAWAIT(dma); - dma->dma_csr |= DMA_DRAIN; - DMAWAIT1(dma); - resid = 0; - goto dma_data_done; - - case S_DO: - /* - * We were doing DMA data out. If there is data in the - * FIFO, it is stuff that got DMAed out but never made - * it to the device, so it counts as residual. - */ - if ((resid = ESP_NFIFO(sc->sc_espfflags)) != 0) { - esp->esp_cmd = ESPCMD_FLUSH_FIFO; - DELAY(1); - } -dma_data_done: - if (sc->sc_dmaactive == 0) { - esperror(sc, "dma done w/o dmaactive"); - panic("espact"); - } - sc->sc_dmaactive = 0; - - /* Finish computing residual count. */ - reg = esp->esp_tcl | (esp->esp_tch << 8); - if (reg == 0 && (sc->sc_espstat & ESPSTAT_TC) == 0) - reg = 65536; - resid += reg; - - /* Compute xfer count (requested - resid). */ - i = sc->sc_dmasize - resid; - if (i < 0) { - printf("%s: xfer resid (%d) > xfer req (%d)\n", - sc->sc_dev.dv_xname, resid, sc->sc_dmasize); - i = sc->sc_dmasize; /* forgiving... */ - } - - /* If data came in we must flush cache. */ - if (sc->sc_state == S_DI) - cache_flush(sc->sc_dmaaddr, i); - sc->sc_dmaaddr += i; - sc->sc_resid -= i; - if ((sc->sc_espintr & ESPINTR_SVC) == 0) { - esperror(sc, "no bus service req"); - return (ACT_RESET); - } - break; - - case S_STAT: - /* - * The last thing we did was tell it `initiator complete' - * and so we expect to have gotten both the status byte - * and the final message byte. It is possible that we - * got something else.... - * - * Apparently, BUS SERVICE is set if we got just status, - * while FUNCTION COMPLETE is set if we got both. - */ - if ((reg & (ESPINTR_SVC|ESPINTR_CMP)) != ESPINTR_CMP) { - esperror(sc, "bad status interrupt state"); - return (ACT_RESET); - } - reg = ESP_NFIFO(sc->sc_espfflags); - if (reg < 2) { - printf( - "%s: command done but fifo count = %d; must be >= 2\n", - sc->sc_dev.dv_xname, reg); - return (ACT_RESET); - } - /* - * Read the status and the first msg byte. - * It should be CMD_COMPLETE. Eventually we - * may handle IDENTIFY, DISCONNECT, etc., as well. - */ - sc->sc_stat[0] = esp->esp_fifo; - sc->sc_msg[0] = reg = esp->esp_fifo; - esp->esp_cmd = ESPCMD_MSG_ACCEPT; - if (reg == MSG_CMD_COMPLETE) { - sc->sc_state = S_FI; - return (ACT_CONT); - } - if (SCSIMSGLEN(reg) != 1) { - printf("%s: target %d is naughty\n", - sc->sc_dev.dv_xname, sc->sc_targ); - return (ACT_RESET); - } - printf("%s: warning: target %d returned msg 0x%x\n", - sc->sc_dev.dv_xname, sc->sc_targ, reg); - sc->sc_state = S_FI; - return (ACT_CONT); - - case S_MI: - if ((reg & ESPINTR_SVC) == 0) { - esperror(sc, "missing phase after msg in"); - return (ACT_RESET); - } - reg = ESP_NFIFO(sc->sc_espfflags); - for (i = 0; i < reg; i++) - sc->sc_msg[i] = esp->esp_fifo; - break; - - case S_FI: - esperror(sc, "target did not disconnect"); - return (ACT_RESET); - } - - /* - * Things are still moving along. The phase tells us - * what the device wants next. Do it. - */ - switch (sc->sc_espstat & ESPSTAT_PHASE) { - - case ESPPHASE_DATA_OUT: -if (!sc->sc_sentcmd) esperror(sc, "DIAG: data out without command"); - if (sc->sc_dmactl & DMA_READ) { - esperror(sc, "wrong phase (want to read)"); - return (ACT_RESET); - } - newstate = S_DO; - goto do_data_xfer; - - case ESPPHASE_DATA_IN: -if (!sc->sc_sentcmd) esperror(sc, "DIAG: data in without command"); - if (!(sc->sc_dmactl & DMA_READ)) { - esperror(sc, "wrong phase (want to write)"); - return (ACT_RESET); - } - newstate = S_DI; -do_data_xfer: - if (sc->sc_resid == 0) { - esperror(sc, "data count error"); - return (ACT_RESET); - } - - /* - * Compute DMA count based on chip limits. - * Set DMA address and load transfer count into - * ESP via DMA NOP, then set DMA control, and - * then we can start the DMA. - */ - sc->sc_state = newstate; - i = min(sc->sc_resid, ESPMAX); - i = min(i, DMAMAX(sc->sc_dmaaddr)); - sc->sc_dmasize = i; - dma->dma_addr = sc->sc_dmaaddr; - esp->esp_tch = i >> 8; - esp->esp_tcl = i; - esp->esp_cmd = ESPCMD_DMA | ESPCMD_NOP; - dma->dma_csr = sc->sc_dmactl; - sc->sc_dmaactive = 1; - esp->esp_cmd = ESPCMD_DMA | ESPCMD_XFER_INFO; - return (ACT_IO); - - case ESPPHASE_CMD: - /* - * Silly thing wants the command again. - * Load it into the FIFO and go to SVC state. - */ -printf("%s: redoing command\n", sc->sc_dev.dv_xname); - cdb = sc->sc_curcdb; - reg = SCSICMDLEN(cdb->cdb_bytes[0]); - for (i = 0; i < reg; i++) - esp->esp_fifo = cdb->cdb_bytes[i]; - sc->sc_state = S_SVC; - esp->esp_cmd = ESPCMD_XFER_INFO; - return (ACT_CONT); - - case ESPPHASE_STATUS: - sc->sc_state = S_STAT; - esp->esp_cmd = ESPCMD_INIT_COMP; - return (ACT_CONT); - - case ESPPHASE_MSG_IN: -printf("%s: accepting (& ignoring) msg from target %d\n", - sc->sc_dev.dv_xname, sc->sc_targ); - sc->sc_state = S_MI; - esp->esp_cmd = ESPCMD_MSG_ACCEPT; - return (ACT_CONT); - - default: - esperror(sc, "bad phase"); - return (ACT_RESET); - } - /* NOTREACHED */ -} - -/* - * THIS SHOULD BE ADJUSTABLE - */ - /* name howlong purpose */ -#define SELECT_WAIT 300000 /* wait for select to complete */ -#define CMD_WAIT 100000 /* wait for next phase, generic */ -#define DATA_WAIT 100000 /* time to xfer data in/out */ - -/* - * Send an `immediate' command, i.e., poll until the whole thing is done. - * Return the status byte from the device, or -1 if we timed out. We use - * DMA to transfer the data as the fifo only moves one byte at a time. - */ -int -espicmd(hba, targ, cdb, buf, len, rw) - struct hba_softc *hba; - int targ; - struct scsi_cdb *cdb; - caddr_t buf; - int len, rw; -{ - register struct esp_softc *sc = (struct esp_softc *)hba; - register volatile struct espreg *esp = sc->sc_esp; - register volatile struct dmareg *dma = sc->sc_dma; - register int r, s, wait; - register struct sq *sq; - register char old_busy; - - /* - * Wait for any ongoing operation to complete. - */ - s = splbio(); - while (sc->sc_state != S_IDLE) { - sc->sc_iwant = 1; - tsleep((caddr_t)&sc->sc_iwant, PRIBIO, "espicmd", 0); - } - old_busy = sc->sc_hba.hba_busy; - sc->sc_hba.hba_busy = 1; - splx(s); - - /* - * Set up DMA transfer control (leaving interrupts disabled). - */ - sc->sc_dmactl = rw & B_READ ? DMA_ENA | DMA_READ : DMA_ENA; - sc->sc_dmaaddr = (u_long)buf; - sc->sc_resid = len; - - /* - * Disable hardware interrupts and start select sequence, - * then loop, calling espact() after each ``interrupt''. - */ - DMAWAIT(dma); /* ??? */ - dma->dma_csr = 0; - espselect(sc, targ, cdb); - wait = SELECT_WAIT; - for (;;) { - r = dma->dma_csr; - if (!DMA_INTR(r)) { - if (--wait < 0) { - esperror(sc, "timeout"); - goto reset; - } - DELAY(1); - continue; - } - sc->sc_espstat = esp->esp_stat; - sc->sc_espstep = esp->esp_step & ESPSTEP_MASK; - sc->sc_espintr = esp->esp_intr; - sc->sc_espfflags = esp->esp_fflags; - sc->sc_dmacsr = r; - switch (r = espact(sc)) { - - case ACT_CONT: - case ACT_QUICKINTR: - wait = CMD_WAIT; - break; - - case ACT_IO: - wait = DATA_WAIT; - break; - - case ACT_RESET: - goto reset; - - case ACT_DONE: - r = sc->sc_stat[0]; - goto done; - - case ACT_ERROR: - r = -1; - goto done; - - default: - panic("espicmd action"); - } - } -reset: - espreset(sc, RESET_ESPCHIP); /* ??? */ - r = -1; -done: - sc->sc_state = S_IDLE; - s = splbio(); - if (!old_busy) { - if (sc->sc_iwant) { - sc->sc_iwant = 0; - wakeup((caddr_t)&sc->sc_iwant); - } else if ((sq = sc->sc_hba.hba_head) != NULL) { - sc->sc_hba.hba_head = sq->sq_forw; - (*sq->sq_dgo)(sq->sq_dev, &sc->sc_cdbspace); - } else - sc->sc_hba.hba_busy = 0; - } - splx(s); - return (r); -} - -/* - * Dump (write memory, possibly physmem). - * SPARC higher-level dump code always provides virtual addresses, - * so we need not do any I/O mapping here. - */ -int -espdump(hba, targ, cdb, buf, len) - register struct hba_softc *hba; - int targ; - struct scsi_cdb *cdb; - caddr_t buf; - register int len; -{ - register struct esp_softc *sc = (struct esp_softc *)hba; - - /* - * If we crashed in the middle of a bus transaction... - */ - if (sc->sc_state != S_IDLE) - espreset(sc, RESET_BOTH); /* ??? */ - return (espicmd(hba, targ, cdb, buf, len, B_WRITE)); -} - -/* - * Allocate resources (SCSI bus and DVMA space) for the given transfer. - * Must be called at splbio(). - * - * THIS SHOULD RETURN SUCCESS/FAIL INDICATION - */ -void -espstart(self, sq, bp, dgo, dev) - struct device *self; - register struct sq *sq; - struct buf *bp; - scdgo_fn dgo; - struct device *dev; -{ - register struct esp_softc *sc = (struct esp_softc *)self; - - if (sc->sc_hba.hba_busy == 0) { - /* - * Bus not busy, nothing to do here, just tell - * this target or unit that it has the SCSI bus. - */ - sc->sc_hba.hba_busy = 1; - (*dgo)(dev, &sc->sc_cdbspace); - } else { - /* - * Bus is busy; just enqueue. - */ - sq->sq_dgo = dgo; - sq->sq_dev = dev; - sq->sq_forw = NULL; - if (sc->sc_hba.hba_head == NULL) - sc->sc_hba.hba_head = sq; - else - sc->sc_hba.hba_tail->sq_forw = sq; - sc->sc_hba.hba_tail = sq; - } -} - -/* - * Start buffered I/O. - * Return 0 on success, 1 on failure. - */ -int -espgo(self, targ, intr, dev, bp, pad) - struct device *self; - int targ; - scintr_fn intr; - struct device *dev; - register struct buf *bp; - int pad; -{ - register struct esp_softc *sc = (struct esp_softc *)self; - - /* Set up dma control for espact(). */ - sc->sc_dmactl = bp->b_flags & B_READ ? - DMA_ENA | DMA_READ | DMA_IE : DMA_ENA | DMA_IE; - sc->sc_dmaaddr = (u_long)bp->b_un.b_addr; - sc->sc_resid = bp->b_bcount; - - /* - * Enable interrupts and start selection. - * The rest is done in espintr() and espact(). - */ - sc->sc_hba.hba_intr = intr; /* remember dev done function */ - sc->sc_hba.hba_intrdev = dev; /* and its first arg */ - sc->sc_dma->dma_csr = DMA_IE; - espselect(sc, targ, &sc->sc_cdbspace); - return (0); -} - -/* - * Handle interrupt. Return 1 if taken. - */ -int -espintr(sc0) - void *sc0; -{ - register struct esp_softc *sc = (struct esp_softc *)sc0; - register volatile struct espreg *esp = sc->sc_esp; - register volatile struct dmareg *dma = sc->sc_dma; - register int r, wait; - register struct sq *sq; - - r = dma->dma_csr; - if (!DMA_INTR(r)) - return (0); /* not ours */ - sc->sc_intrcnt.ev_count++; - -again: - sc->sc_espstat = esp->esp_stat; - sc->sc_espstep = esp->esp_step & ESPSTEP_MASK; - sc->sc_espintr = esp->esp_intr; - sc->sc_espfflags = esp->esp_fflags; - sc->sc_dmacsr = r; - - if (sc->sc_state == S_IDLE) { - printf("%s: stray interrupt\n", sc->sc_dev.dv_xname); - dma->dma_csr &= ~DMA_IE; /* ??? */ - return (1); - } - switch (r = espact(sc)) { - - case ACT_CONT: /* just return */ - case ACT_IO: - break; - - case ACT_RESET: /* please reset esp */ -reset: - espreset(sc, RESET_ESPCHIP); /* ??? */ - /* FALLTHROUGH */ - - case ACT_DONE: /* this one is done, successfully */ - case ACT_ERROR: /* this one is done due to `severe' error */ - if (!sc->sc_hba.hba_busy) - panic("espintr sq"); - /* - * This transaction is done. Call the driver's intr routine. - * If an immediate command is pending, let it run in front - * of us, otherwise start the next transation. Note that - * the interrupt routine may run its own immediate commands - * (`request sense' for errors, eg) before we get around to - * the process waiting to do immediate command, but that - * is OK; if we did not set S_IDLE here we could deadlock. - */ - sc->sc_state = S_IDLE; - (*sc->sc_hba.hba_intr)(sc->sc_hba.hba_intrdev, - r == ACT_DONE ? sc->sc_stat[0] : -1, sc->sc_resid); - if (sc->sc_iwant) { - wakeup((caddr_t)&sc->sc_iwant); - sc->sc_iwant = 0; - } else if ((sq = sc->sc_hba.hba_head) != NULL) { - sc->sc_hba.hba_head = sq->sq_forw; - (*sq->sq_dgo)(sq->sq_dev, &sc->sc_cdbspace); - } else - sc->sc_hba.hba_busy = 0; - break; - - case ACT_QUICKINTR: /* wait a short while for another interrupt */ -printf("%s: quickintr: ", sc->sc_dev.dv_xname); - wait = 100; - do { - r = dma->dma_csr; - if (DMA_INTR(r)) { -printf("got one, wait=%d\n", wait); - goto again; - } - } while (--wait > 0); -printf("did not get one\n"); - break; - - default: - panic("espintr action"); - } - return (1); -} - -/* - * Target or unit decided to let go of the bus early. - */ -void -esprel(self) - struct device *self; -{ - register struct esp_softc *sc = (struct esp_softc *)self; - register struct sq *sq; - - /* if there is someone else waiting, give them a crack at it */ - if (sc->sc_iwant) { - wakeup((caddr_t)&sc->sc_iwant); - sc->sc_iwant = 0; - } else if ((sq = sc->sc_hba.hba_head) != NULL) { - sc->sc_hba.hba_head = sq->sq_forw; - (*sq->sq_dgo)(sq->sq_dev, &sc->sc_cdbspace); - } else - sc->sc_hba.hba_busy = 0; -} diff --git a/sys/arch/sparc/sbus/espreg.h b/sys/arch/sparc/sbus/espreg.h deleted file mode 100644 index 4096cbe8f5ad..000000000000 --- a/sys/arch/sparc/sbus/espreg.h +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright (c) 1988, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)espreg.h 8.2 (Berkeley) 12/14/93 - * from: Header: espreg.h,v 1.7 92/11/26 02:28:10 torek Exp (LBL) - * $Id: espreg.h,v 1.2 1994/05/27 02:38:19 deraadt Exp $ - * - * Derived from Mary Baker's devSCSIC90.c from the Berkeley - * Sprite project, which is: - * - * Copyright 1988 Regents of the University of California - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The University of California - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - */ - -/* - * Emulex ESP100, ESP100A, and ESP200 registers, as found on the - * Sun-4c Sbus. - * - * The registers are all bytes, and all on longword boundaries. - * Grody to the max! - */ -struct espreg { - u_char esp_tcl; /* transfer count low (byte 0) (rw) */ - u_char esp_xxx0[3]; - u_char esp_tch; /* transfer count high (byte 1) (rw) */ - u_char esp_xxx1[3]; - u_char esp_fifo; /* fifo data register (rw) */ - u_char esp_xxx2[3]; - u_char esp_cmd; /* command (rw) */ - u_char esp_xxx3[3]; - u_char esp_stat; /* status (ro); scsi id (wo) */ -#define esp_id esp_stat - u_char esp_xxx4[3]; - u_char esp_intr; /* interrupt (ro); timeout (wo) */ -#define esp_timeout esp_intr - u_char esp_xxx5[3]; - u_char esp_step; /* sequence step (ro); sync period (wo) */ -#define esp_syncperiod esp_step - u_char esp_xxx6[3]; - u_char esp_fflags; /* fifo flags (ro); sync offset (wo) */ -#define esp_syncoff esp_fflags - u_char esp_xxx7[3]; - u_char esp_conf1; /* configuration #1 (rw) */ - u_char esp_xxx8[3]; - u_char esp_ccf; /* clock conversion factor (wo) */ - u_char esp_xxx9[3]; - u_char esp_test; /* test (do not use) */ - u_char esp_xxxA[3]; - u_char esp_conf2; /* configuration #2 (rw, ESP100A/2xx) */ - u_char esp_xxxB[3]; - u_char esp_conf3; /* configuration #3 (rw, ESP-236) */ - u_char esp_xxxC[3]; -}; - -/* THE REST OF THESE NAMES COULD STAND TO BE SHORTENED */ - -/* - * Bits in esp_cmd. Note that the cmd register is two levels deep (see - * Emulex documentation, p. 4-3); our typical usage is to set the command, - * then set it again with DMA. - * - * Targets will use disconnected and target mode commands; initiators will use - * disconnected and initiator mode commands. Bit 0x40 indicates disconnected - * mode, 0x20 target mode, and 0x10 initiator mode. (However, everyone can - * use the miscellaneous commands, which have none of those bits set.) - */ -#define ESPCMD_DMA 0x80 /* flag => do DMA */ - -/* miscellaneous */ -#define ESPCMD_NOP 0x00 /* do nothing */ -#define ESPCMD_FLUSH_FIFO 0x01 /* flush FIFO */ -#define ESPCMD_RESET_CHIP 0x02 /* reset ESP chip */ -#define ESPCMD_RESET_BUS 0x03 /* reset SCSI bus */ -/* NB: fifo flush takes time, may need delay or NOP to allow completion */ - -/* disconnected */ -#define ESPCMD_RESEL_SEQ 0x40 /* reselect sequence */ -#define ESPCMD_SEL_NATN 0x41 /* select without ATN sequence */ -#define ESPCMD_SEL_ATN 0x42 /* select with ATN sequence */ -#define ESPCMD_SEL_ATNS 0x43 /* select with ATN & stop seq */ -#define ESPCMD_SEL_ENA 0x44 /* enable selection/reselection */ -#define ESPCMD_SEL_DIS 0x45 /* disable selection/reselection */ -#define ESPCMD_SEL_ATN3 0x46 /* select with ATN3 sequence */ - -/* target state */ -#define ESPCMD_SEND_MSG 0x20 /* send message */ -#define ESPCMD_SEND_STATUS 0x21 /* send status */ -#define ESPCMD_SEND_DATA 0x22 /* send data */ -#define ESPCMD_DIS_SEQ 0x23 /* disconnect sequence */ -#define ESPCMD_TERM_SEQ 0x24 /* terminate sequence */ -#define ESPCMD_TARG_COMP 0x25 /* target command complete sequence */ -#define ESPCMD_DISCONNECT 0x27 /* disconnect */ -#define ESPCMD_RCV_MSG 0x28 /* receive message sequence */ -#define ESPCMD_RCV_CMD 0x29 /* receive command */ -#define ESPCMD_RCV_DATA 0x2a /* receive data */ -#define ESPCMD_REC_CMD_SEQ 0x2b /* receive command sequence */ -#define ESPCMD_STOP_DMA 0x04 /* stop DMA (see p. 4-6) */ -/* ESPCMD_TARG_ABORT 0x06 target abort sequence */ - -/* initiator state */ -#define ESPCMD_XFER_INFO 0x10 /* transfer information */ -#define ESPCMD_INIT_COMP 0x11 /* initiator command complete seq */ -#define ESPCMD_MSG_ACCEPT 0x12 /* message accepted */ -#define ESPCMD_XFER_PAD 0x18 /* transfer pad (use only w/ DMA) */ -#define ESPCMD_SET_ATN 0x1a /* set ATN */ -#define ESPCMD_RESET_ATN 0x1b /* reset ATN */ - -/* - * Bits in esp_stat. - * Bits 3 through 7 are latched until esp_intr is read; - * bits 0 through 2 (the phase) are not normally latched. - * The interrupt bit is set even if interrupts are disabled. - * Hardware or software reset, or reading esp_intr, will - * clear the interrupt and turn off ESPSTAT_INT. - */ -#ifdef notdef -#define ESPSTAT_INT 0x80 /* ASC interrupting processor */ -#else -#define ESPSTAT_XXX 0x80 /* rumored unreliable: use dma IP */ -#endif -#define ESPSTAT_GE 0x40 /* gross error */ -#define ESPSTAT_PE 0x20 /* parity error */ -#define ESPSTAT_ERR 0x60 /* pseudo composite */ -#define ESPSTAT_TC 0x10 /* terminal count */ -#define ESPSTAT_VGC 0x08 /* valid group code */ -#define ESPSTAT_MSG 0x04 /* MSG line from SCSI bus */ -#define ESPSTAT_CD 0x02 /* CD line from SCSI bus */ -#define ESPSTAT_IO 0x01 /* IO line from SCSI bus */ -#define ESPSTAT_PHASE 7 /* phase mask */ -#define ESPPHASE_DATA_OUT 0 /* data out */ -#define ESPPHASE_DATA_IN 1 /* data in */ -#define ESPPHASE_CMD 2 /* command */ -#define ESPPHASE_STATUS 3 /* status */ -#define ESPPHASE_MSG_OUT 6 /* message out (w.r.t. initiator) */ -#define ESPPHASE_MSG_IN 7 /* message in */ - -#ifdef ESP_PHASE_NAMES -/* printed as `... during %s phase' */ -char *espphases[] = - { "data out", "data in", "command", "status", - "impossible(4)", "impossible(5)", "message out", "message in" }; -#endif - -#define ESPSTAT_BITS "\20\10INT\7GE\6PE\5TC\4VGC\3MSG\2CD\1IO" - -/* - * Bits in esp_intr. - */ -#define ESPINTR_SBR 0x80 /* SCSI bus reset detected */ -#define ESPINTR_ILC 0x40 /* illegal command */ -#define ESPINTR_DSC 0x20 /* target disconnected, or timeout */ -#define ESPINTR_SVC 0x10 /* a device wants bus service */ -#define ESPINTR_CMP 0x08 /* function complete */ -#define ESPINTR_RSL 0x04 /* reselected */ -#define ESPINTR_SAT 0x02 /* selected with ATN */ -#define ESPINTR_SEL 0x01 /* selected (no ATN) */ - -#define ESPINTR_BITS "\20\10SBR\7ILC\6DSC\5SVC\4CMP\3RSL\2SAT\1SEL" - -/* - * Formula for select/reselect timeout (esp_timeout). - * TU = 7682 * CCF * TCP - * T / TU = register value - * CCF = clock conversion factor - * TCP = input clock period (in same units as T) - * TU = time unit (i.e., the esp_timeout register counts in TUs) - * T = desired timeout - * (i.e., we want ceil(timeout / (7682*ccf*tcp))). If timeout is in ms., - * and tcp is in MHz, then (ccf * 7682)/tcp gives us 1000*TU, and - * 1000*timeout/(1000*TU) gives us our result (but remember to round up). - * - * N.B.: The register value 0 gives a TU of 256. - */ -#define ESPTIMO_REGVAL(timo_ms, ccf, mhz) \ - howmany(1000 * (timo_ms), ((ccf) * 7682) / (mhz)) - -/* - * Value in esp_step. These tell us how much of a `sequence' completed, - * and apply to the following sequenced operations: - * [initiator] - * select without ATN - * select with ATN - * select with ATN3 - * select with ATN and stop - * [target] - * bus-initiated select with ATN - * bus-initiated select - * receive command sequence - * command complete sequence - * disconnect sequence - * terminate sequence - * The actual values are too complicated to define here, except that - * code 4 always means `everything worked and the command went out' - * (and is thus typical for everything except ATN-and-stop). - */ -#define ESPSTEP_MASK 0x07 /* only these bits are valid */ -#define ESPSTEP_DONE 4 /* command went out */ - -/* - * Synchronous transfer period (esp_syncperiod, 5 bits). - * The minimum clocks-per-period is 5 and the max is 35; - * the default on reset is 5. Note that a period value of 4 - * actually gives 5 clocks. - */ -#define ESP_CLOCKS_TO_PERIOD(nclocks) ((nclocks) & 31) - -/* - * Bits in fifo flags (esp_fflags) register. The FIFO itself - * is only 16 bytes, so the byte count fits in 5 bits. Normally - * a copy of the sequence step register appears in the top 3 bits, - * but in test mode the chip re-uses one of those for a synchronous - * offset bit; in any case, they are pretty much worthless. - * - * Note that the fifo flags register must not be read while the - * fifo is changing. - */ -#define ESP_NFIFO(fflags) ((fflags) & 0x1f) - -#define ESPFFLAGS_TM_SOFFNZ 0x20 /* nonzero sync offset (test mode) */ - -/* - * Bits in esp_conf1. - */ -#define ESPCONF1_SLOW_CABLE 0x80 /* ``slow cable'' mode */ -#define ESPCONF1_REPORT 0x40 /* disable reporting of interrupts - from scsi bus reset command */ -#define ESPCONF1_PARTST 0x20 /* parity test mode */ -#define ESPCONF1_PARENB 0x10 /* enable parity */ -#define ESPCONF1_TEST 0x08 /* chip test mode */ -#define ESPCONF1_ID_MASK 0x07 /* SCSI bus ID field */ - -#define ESPCONF1_BITS "\20\10SLOW_CABLE\7REPORT\6PARTST\5PARENB\4TEST" - -/* - * Values for clock conversion factor (esp_ccf). - */ -#define ESPCCF_FROMMHZ(mhz) (((mhz) + 4) / 5) -#define ESPCCF_MIN 2 /* minimum CCF value */ - -/* - * Bits in esp_test (for board testing only; can only be used in test mode). - */ -#define ESPTEST_MBZ 0xf8 /* reserved; must be 0 */ -#define ESPTEST_TRISTATE 0x04 /* all output pins tristated */ -#define ESPTEST_INITIATOR 0x02 /* operate as initiator */ -#define ESPTEST_TARGET 0x01 /* operate as target */ - -/* - * Bits in esp_conf2. - */ -#define ESPCONF2_RSVD 0xe0 /* reserved */ -#define ESPCONF2_TRISTATE_DMA 0x10 /* tristate the DMA REQ pin */ -#define ESPCONF2_SCSI2 0x08 /* enable SCSI 2 (see p. 4-18) */ -#define ESPCONF2_TBPA 0x04 /* enable target bad parity abort */ -#define ESPCONF2_RPE 0x02 /* register parity ena (ESP2xx only) */ -#define ESPCONF2_DPE 0x01 /* DMA parity enable (ESP2xx only) */ diff --git a/sys/arch/sparc/sbus/if_le.c b/sys/arch/sparc/sbus/if_le.c deleted file mode 100644 index 632f8f8057f4..000000000000 --- a/sys/arch/sparc/sbus/if_le.c +++ /dev/null @@ -1,976 +0,0 @@ -/*- - * Copyright (c) 1982, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: if_le.c,v 1.25 93/10/31 04:47:50 leres Locked - * from: @(#)if_le.c 8.2 (Berkeley) 10/30/93 - * $Id: if_le.c,v 1.10 1994/07/04 21:37:27 deraadt Exp $ - */ - -#include "bpfilter.h" - -/* - * AMD 7990 LANCE - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#if NBPFILTER > 0 -#include -#include -#include -#endif - -#ifdef INET -#include -#include -#include -#include -#include -#endif - -#ifdef NS -#include -#include -#endif - -#ifdef APPLETALK -#include -#endif - -#include -#include -#include - -#include -#include - -/* DVMA address to LANCE address -- the Sbus/MMU will resupply the 0xff */ -#define LANCE_ADDR(x) ((int)(x) & ~0xff000000) - -int ledebug = 0; /* console error messages */ - -#ifdef PACKETSTATS -long lexpacketsizes[LEMTU+1]; -long lerpacketsizes[LEMTU+1]; -#endif - -/* Per interface statistics */ -/* XXX this should go in something like if_levar.h */ -struct lestats { - long lexints; /* transmitter interrupts */ - long lerints; /* receiver interrupts */ - long lerbufs; /* total buffers received during interrupts */ - long lerhits; /* times current rbuf was full */ - long lerscans; /* rbufs scanned before finding first full */ -}; - -/* - * Ethernet software status per interface. - * - * Each interface is referenced by a network interface structure, - * le_if, which the routing code uses to locate the interface. - * This structure contains the output queue for the interface, its address, ... - */ -struct le_softc { - struct device sc_dev; /* base device */ - struct sbusdev sc_sd; /* sbus device */ - struct intrhand sc_ih; /* interrupt vectoring */ - struct evcnt sc_intrcnt; /* # of interrupts, per le */ - struct evcnt sc_errcnt; /* # of errors, per le */ - - struct arpcom sc_ac; /* common Ethernet structures */ -#define sc_if sc_ac.ac_if /* network-visible interface */ -#define sc_addr sc_ac.ac_enaddr /* hardware Ethernet address */ - volatile struct lereg1 *sc_r1; /* LANCE registers */ - volatile struct lereg2 *sc_r2; /* dual-port RAM */ - int sc_rmd; /* predicted next rmd to process */ - int sc_runt; - int sc_jab; - int sc_merr; - int sc_babl; - int sc_cerr; - int sc_miss; - int sc_xint; - int sc_xown; - int sc_uflo; - int sc_rxlen; - int sc_rxoff; - int sc_txoff; - int sc_busy; - short sc_iflags; - struct lestats sc_lestats; /* per interface statistics */ -}; - - -/* autoconfiguration driver */ -void leattach(struct device *, struct device *, void *); -struct cfdriver lecd = - { NULL, "le", matchbyname, leattach, DV_IFNET, sizeof(struct le_softc) }; - -/* Forwards */ -void leattach(struct device *, struct device *, void *); -void lesetladrf(struct le_softc *); -void lereset(struct device *); -int leinit(int); -int lestart(struct ifnet *); -int leintr(void *); -void lexint(struct le_softc *); -void lerint(struct le_softc *); -void leread(struct le_softc *, char *, int); -int leput(char *, struct mbuf *); -struct mbuf *leget(char *, int, int, struct ifnet *); -int leioctl(struct ifnet *, int, caddr_t); -void leerror(struct le_softc *, int); -void lererror(struct le_softc *, char *); -void lexerror(struct le_softc *); - -/* - * Interface exists: make available by filling in network interface - * record. System will initialize the interface when it is ready - * to accept packets. - */ -void -leattach(parent, self, args) - struct device *parent; - struct device *self; - void *args; -{ - register struct le_softc *sc = (struct le_softc *)self; - register struct sbus_attach_args *sa = args; - register volatile struct lereg2 *ler2; - struct ifnet *ifp = &sc->sc_if; - register struct bootpath *bp; - register int a, pri; - - /* XXX the following declarations should be elsewhere */ - extern void myetheraddr(u_char *); - extern caddr_t dvma_malloc(size_t); - - if (sa->sa_ra.ra_nintr != 1) { - printf(": expected 1 interrupt, got %d\n", sa->sa_ra.ra_nintr); - return; - } - pri = sa->sa_ra.ra_intr[0].int_pri; - printf(" pri %d", pri); - sc->sc_r1 = (volatile struct lereg1 *) - mapiodev(sa->sa_ra.ra_paddr, sizeof(struct lereg1)); - ler2 = sc->sc_r2 = (volatile struct lereg2 *) - dvma_malloc(sizeof(struct lereg2)); - - myetheraddr(sc->sc_addr); - printf(": hardware address %s\n", ether_sprintf(sc->sc_addr)); - - /* - * Setup for transmit/receive - * - * According to Van, some versions of the Lance only use this - * address to receive packets; it doesn't put them in - * output packets. We'll want to make sure that lestart() - * installs the address. - */ - ler2->ler2_padr[0] = sc->sc_addr[1]; - ler2->ler2_padr[1] = sc->sc_addr[0]; - ler2->ler2_padr[2] = sc->sc_addr[3]; - ler2->ler2_padr[3] = sc->sc_addr[2]; - ler2->ler2_padr[4] = sc->sc_addr[5]; - ler2->ler2_padr[5] = sc->sc_addr[4]; - a = LANCE_ADDR(&ler2->ler2_rmd); - ler2->ler2_rlen = LE_RLEN | (a >> 16); - ler2->ler2_rdra = a; - a = LANCE_ADDR(&ler2->ler2_tmd); - ler2->ler2_tlen = LE_TLEN | (a >> 16); - ler2->ler2_tdra = a; - - /* - * Link into sbus, and establish interrupt handler. - */ - sc->sc_sd.sd_reset = lereset; - sbus_establish(&sc->sc_sd, &sc->sc_dev); - sc->sc_ih.ih_fun = leintr; - sc->sc_ih.ih_arg = sc; - intr_establish(pri, &sc->sc_ih); - - /* - * Set up event counters. - */ - evcnt_attach(&sc->sc_dev, "intr", &sc->sc_intrcnt); - evcnt_attach(&sc->sc_dev, "errs", &sc->sc_errcnt); - - ifp->if_unit = sc->sc_dev.dv_unit; - ifp->if_name = "le"; - ifp->if_ioctl = leioctl; - ifp->if_output = ether_output; - ifp->if_start = lestart; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; -#ifdef IFF_NOTRAILERS - /* XXX still compile when the blasted things are gone... */ - ifp->if_flags |= IFF_NOTRAILERS; -#endif -#if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); -#endif - if_attach(ifp); - ether_ifattach(ifp); - -#define SAME_LANCE(bp, sa) \ - ((bp->val[0] == sa->sa_slot && bp->val[1] == sa->sa_offset) || \ - (bp->val[0] == -1 && bp->val[1] == sc->sc_dev.dv_unit)) - - bp = sa->sa_ra.ra_bp; - if (bp != NULL && strcmp(bp->name, "le") == 0 && SAME_LANCE(bp, sa)) - bootdv = &sc->sc_dev; -} - -/* - * Setup the logical address filter - */ -void -lesetladrf(sc) - register struct le_softc *sc; -{ - register volatile struct lereg2 *ler2 = sc->sc_r2; - register struct ifnet *ifp = &sc->sc_if; - register struct ether_multi *enm; - register u_char *cp, c; - register u_long crc; - register int i, len; - struct ether_multistep step; - - /* - * Set up multicast address filter by passing all multicast - * addresses through a crc generator, and then using the high - * order 6 bits as a index into the 64 bit logical address - * filter. The high order two bits select the word, while the - * rest of the bits select the bit within the word. - */ - - ler2->ler2_ladrf[0] = 0; - ler2->ler2_ladrf[1] = 0; - ler2->ler2_ladrf[2] = 0; - ler2->ler2_ladrf[3] = 0; - ifp->if_flags &= ~IFF_ALLMULTI; - ETHER_FIRST_MULTI(step, &sc->sc_ac, enm); - while (enm != NULL) { - if (bcmp((caddr_t)&enm->enm_addrlo, - (caddr_t)&enm->enm_addrhi, sizeof(enm->enm_addrlo)) != 0) { - /* - * We must listen to a range of multicast - * addresses. For now, just accept all - * multicasts, rather than trying to set only - * those filter bits needed to match the range. - * (At this time, the only use of address - * ranges is for IP multicast routing, for - * which the range is big enough to require all - * bits set.) - */ - ler2->ler2_ladrf[0] = 0xffff; - ler2->ler2_ladrf[1] = 0xffff; - ler2->ler2_ladrf[2] = 0xffff; - ler2->ler2_ladrf[3] = 0xffff; - ifp->if_flags |= IFF_ALLMULTI; - return; - } - - /* - * One would think, given the AM7990 document's polynomial - * of 0x04c11db6, that this should be 0x6db88320 (the bit - * reversal of the AMD value), but that is not right. See - * the BASIC listing: bit 0 (our bit 31) must then be set. - */ - cp = (unsigned char *)&enm->enm_addrlo; - crc = 0xffffffff; - for (len = 6; --len >= 0;) { - c = *cp++; - for (i = 0; i < 8; i++) { - if ((c & 0x01) ^ (crc & 0x01)) { - crc >>= 1; - crc = crc ^ 0xedb88320; - } else - crc >>= 1; - c >>= 1; - } - } - /* Just want the 6 most significant bits. */ - crc = crc >> 26; - - /* Turn on the corresponding bit in the filter. */ - ler2->ler2_ladrf[crc >> 4] |= 1 << (crc & 0xf); - - ETHER_NEXT_MULTI(step, enm); - } -} - -void -lereset(dev) - struct device *dev; -{ - register struct le_softc *sc = (struct le_softc *)dev; - register volatile struct lereg1 *ler1 = sc->sc_r1; - register volatile struct lereg2 *ler2 = sc->sc_r2; - register int i, a, timo, stat; - -#if NBPFILTER > 0 - if (sc->sc_if.if_flags & IFF_PROMISC) - ler2->ler2_mode = LE_MODE_NORMAL | LE_MODE_PROM; - else -#endif - ler2->ler2_mode = LE_MODE_NORMAL; - ler1->ler1_rap = LE_CSR0; - ler1->ler1_rdp = LE_C0_STOP; - - /* Setup the logical address filter */ - lesetladrf(sc); - - /* init receive and transmit rings */ - for (i = 0; i < LERBUF; i++) { - a = LANCE_ADDR(&ler2->ler2_rbuf[i][0]); - ler2->ler2_rmd[i].rmd0 = a; - ler2->ler2_rmd[i].rmd1_hadr = a >> 16; - ler2->ler2_rmd[i].rmd1_bits = LE_R1_OWN; - ler2->ler2_rmd[i].rmd2 = -LEMTU | LE_XMD2_ONES; - ler2->ler2_rmd[i].rmd3 = 0; - } - for (i = 0; i < LETBUF; i++) { - a = LANCE_ADDR(&ler2->ler2_tbuf[i][0]); - ler2->ler2_tmd[i].tmd0 = a; - ler2->ler2_tmd[i].tmd1_hadr = a >> 16; - ler2->ler2_tmd[i].tmd1_bits = 0; - ler2->ler2_tmd[i].tmd2 = LE_XMD2_ONES; - ler2->ler2_tmd[i].tmd3 = 0; - } - -bzero(&ler2->ler2_rbuf[0][0], (LERBUF + LETBUF) * LEMTU); - /* lance will stuff packet into receive buffer 0 next */ - sc->sc_rmd = 0; - - /* tell the chip where to find the initialization block */ - a = LANCE_ADDR(&ler2->ler2_mode); - ler1->ler1_rap = LE_CSR1; - ler1->ler1_rdp = a; - ler1->ler1_rap = LE_CSR2; - ler1->ler1_rdp = a >> 16; - ler1->ler1_rap = LE_CSR3; - ler1->ler1_rdp = LE_C3_BSWP | LE_C3_ACON | LE_C3_BCON; - ler1->ler1_rap = LE_CSR0; - ler1->ler1_rdp = LE_C0_INIT; - timo = 100000; - while (((stat = ler1->ler1_rdp) & (LE_C0_ERR | LE_C0_IDON)) == 0) { - if (--timo == 0) { - printf("%s: init timeout, stat=%b\n", - sc->sc_dev.dv_xname, stat, LE_C0_BITS); - break; - } - } - if (stat & LE_C0_ERR) - printf("%s: init failed, stat=%b\n", - sc->sc_dev.dv_xname, stat, LE_C0_BITS); - else - ler1->ler1_rdp = LE_C0_IDON; /* clear IDON */ - ler1->ler1_rdp = LE_C0_STRT | LE_C0_INEA; - sc->sc_if.if_flags &= ~IFF_OACTIVE; -} - -/* - * Initialization of interface - */ -int -leinit(unit) - int unit; -{ - register struct le_softc *sc = lecd.cd_devs[unit]; - register struct ifnet *ifp = &sc->sc_if; - register int s; - - /* not yet, if address still unknown */ - if (ifp->if_addrlist == (struct ifaddr *)0) - return (0); - if ((ifp->if_flags & IFF_RUNNING) == 0) { - s = splimp(); - ifp->if_flags |= IFF_RUNNING; - lereset(&sc->sc_dev); - lestart(ifp); - splx(s); - } - return (0); -} - -/* - * Start output on interface. Get another datagram to send - * off of the interface queue, and copy it to the interface - * before starting the output. - */ -int -lestart(ifp) - register struct ifnet *ifp; -{ - register struct le_softc *sc = lecd.cd_devs[ifp->if_unit]; - register volatile struct letmd *tmd; - register struct mbuf *m; - register int len; - - if ((sc->sc_if.if_flags & IFF_RUNNING) == 0) - return (0); - IF_DEQUEUE(&sc->sc_if.if_snd, m); - if (m == 0) - return (0); - len = leput(sc->sc_r2->ler2_tbuf[0], m); -#if NBPFILTER > 0 - /* - * If bpf is listening on this interface, let it - * see the packet before we commit it to the wire. - */ - if (sc->sc_if.if_bpf) - bpf_tap(sc->sc_if.if_bpf, sc->sc_r2->ler2_tbuf[0], len); -#endif - -#ifdef PACKETSTATS - if (len <= LEMTU) - lexpacketsizes[len]++; -#endif - tmd = sc->sc_r2->ler2_tmd; - tmd->tmd3 = 0; - tmd->tmd2 = -len | LE_XMD2_ONES; - tmd->tmd1_bits = LE_T1_OWN | LE_T1_STP | LE_T1_ENP; - sc->sc_if.if_flags |= IFF_OACTIVE; - return (0); -} - -int -leintr(dev) - register void *dev; -{ - register struct le_softc *sc = dev; - register volatile struct lereg1 *ler1 = sc->sc_r1; - register int csr0; - - csr0 = ler1->ler1_rdp; - if ((csr0 & LE_C0_INTR) == 0) - return (0); - sc->sc_intrcnt.ev_count++; - - if (csr0 & LE_C0_ERR) { - sc->sc_errcnt.ev_count++; - leerror(sc, csr0); - if (csr0 & LE_C0_MERR) { - sc->sc_merr++; - lereset(&sc->sc_dev); - return (1); - } - if (csr0 & LE_C0_BABL) - sc->sc_babl++; - if (csr0 & LE_C0_CERR) - sc->sc_cerr++; - if (csr0 & LE_C0_MISS) - sc->sc_miss++; - ler1->ler1_rdp = LE_C0_BABL|LE_C0_CERR|LE_C0_MISS|LE_C0_INEA; - } - if ((csr0 & LE_C0_RXON) == 0) { - sc->sc_rxoff++; - lereset(&sc->sc_dev); - return (1); - } - if ((csr0 & LE_C0_TXON) == 0) { - sc->sc_txoff++; - lereset(&sc->sc_dev); - return (1); - } - if (csr0 & LE_C0_RINT) { - /* interrupt is cleared in lerint */ - lerint(sc); - } - if (csr0 & LE_C0_TINT) { - ler1->ler1_rdp = LE_C0_TINT|LE_C0_INEA; - lexint(sc); - } - return (1); -} - -/* - * Ethernet interface transmitter interrupt. - * Start another output if more data to send. - */ -void -lexint(sc) - register struct le_softc *sc; -{ - register volatile struct letmd *tmd = sc->sc_r2->ler2_tmd; - - sc->sc_lestats.lexints++; - if ((sc->sc_if.if_flags & IFF_OACTIVE) == 0) { - sc->sc_xint++; - return; - } - if (tmd->tmd1_bits & LE_T1_OWN) { - sc->sc_xown++; - return; - } - if (tmd->tmd1_bits & LE_T1_ERR) { -err: - lexerror(sc); - sc->sc_if.if_oerrors++; - if (tmd->tmd3 & (LE_T3_BUFF|LE_T3_UFLO)) { - sc->sc_uflo++; - lereset(&sc->sc_dev); - } else if (tmd->tmd3 & LE_T3_LCOL) - sc->sc_if.if_collisions++; - else if (tmd->tmd3 & LE_T3_RTRY) - sc->sc_if.if_collisions += 16; - } - else if (tmd->tmd3 & LE_T3_BUFF) - /* XXX documentation says BUFF not included in ERR */ - goto err; - else if (tmd->tmd1_bits & LE_T1_ONE) - sc->sc_if.if_collisions++; - else if (tmd->tmd1_bits & LE_T1_MORE) - /* what is the real number? */ - sc->sc_if.if_collisions += 2; - else - sc->sc_if.if_opackets++; - sc->sc_if.if_flags &= ~IFF_OACTIVE; - lestart(&sc->sc_if); -} - -#define LENEXTRMP \ - if (++bix == LERBUF) bix = 0, rmd = sc->sc_r2->ler2_rmd; else ++rmd - -/* - * Ethernet interface receiver interrupt. - * If input error just drop packet. - * Decapsulate packet based on type and pass to type specific - * higher-level input routine. - */ -void -lerint(sc) - register struct le_softc *sc; -{ - register int bix = sc->sc_rmd; - register volatile struct lermd *rmd = &sc->sc_r2->ler2_rmd[bix]; - - sc->sc_lestats.lerints++; - /* - * Out of sync with hardware, should never happen? - */ - if (rmd->rmd1_bits & LE_R1_OWN) { - do { - sc->sc_lestats.lerscans++; - LENEXTRMP; - } while ((rmd->rmd1_bits & LE_R1_OWN) && bix != sc->sc_rmd); - if (bix == sc->sc_rmd) - printf("%s: RINT with no buffer\n", - sc->sc_dev.dv_xname); - } else - sc->sc_lestats.lerhits++; - - /* - * Process all buffers with valid data - */ - while ((rmd->rmd1_bits & LE_R1_OWN) == 0) { - int len = rmd->rmd3; - - /* Clear interrupt to avoid race condition */ - sc->sc_r1->ler1_rdp = LE_C0_RINT|LE_C0_INEA; - - if (rmd->rmd1_bits & LE_R1_ERR) { - sc->sc_rmd = bix; - lererror(sc, "bad packet"); - sc->sc_if.if_ierrors++; - } else if ((rmd->rmd1_bits & (LE_R1_STP|LE_R1_ENP)) != - (LE_R1_STP|LE_R1_ENP)) { - /* XXX make a define for LE_R1_STP|LE_R1_ENP? */ - /* - * Find the end of the packet so we can see how long - * it was. We still throw it away. - */ - do { - sc->sc_r1->ler1_rdp = LE_C0_RINT|LE_C0_INEA; - rmd->rmd3 = 0; - rmd->rmd1_bits = LE_R1_OWN; - LENEXTRMP; - } while (!(rmd->rmd1_bits & - (LE_R1_OWN|LE_R1_ERR|LE_R1_STP|LE_R1_ENP))); - sc->sc_rmd = bix; - lererror(sc, "chained buffer"); - sc->sc_rxlen++; - /* - * If search terminated without successful completion - * we reset the hardware (conservative). - */ - if ((rmd->rmd1_bits & - (LE_R1_OWN|LE_R1_ERR|LE_R1_STP|LE_R1_ENP)) != - LE_R1_ENP) { - lereset(&sc->sc_dev); - return; - } - } else { - leread(sc, sc->sc_r2->ler2_rbuf[bix], len); -#ifdef PACKETSTATS - lerpacketsizes[len]++; -#endif - sc->sc_lestats.lerbufs++; - } - rmd->rmd3 = 0; - rmd->rmd1_bits = LE_R1_OWN; - LENEXTRMP; - } - sc->sc_rmd = bix; -} - -void -leread(sc, pkt, len) - register struct le_softc *sc; - char *pkt; - int len; -{ - register struct ether_header *et; - register struct ifnet *ifp = &sc->sc_if; - struct mbuf *m; - struct ifqueue *inq; - int flags; - - ifp->if_ipackets++; - et = (struct ether_header *)pkt; - et->ether_type = ntohs((u_short)et->ether_type); - /* adjust input length to account for header and CRC */ - len -= sizeof(struct ether_header) + 4; - - if (len <= 0) { - if (ledebug) - log(LOG_WARNING, - "%s: ierror(runt packet): from %s: len=%d\n", - sc->sc_dev.dv_xname, - ether_sprintf(et->ether_shost), len); - sc->sc_runt++; - ifp->if_ierrors++; - return; - } - - /* Setup mbuf flags we'll need later */ - flags = 0; - if (bcmp((caddr_t)etherbroadcastaddr, - (caddr_t)et->ether_dhost, sizeof(etherbroadcastaddr)) == 0) - flags |= M_BCAST; - if (et->ether_dhost[0] & 1) - flags |= M_MCAST; - -#if NBPFILTER > 0 - /* - * Check if there's a bpf filter listening on this interface. - * If so, hand off the raw packet to enet, then discard things - * not destined for us (but be sure to keep broadcast/multicast). - */ - if (sc->sc_if.if_bpf) { - bpf_tap(sc->sc_if.if_bpf, pkt, - len + sizeof(struct ether_header)); - if ((flags & (M_BCAST | M_MCAST)) == 0 && - bcmp(et->ether_dhost, sc->sc_addr, - sizeof(et->ether_dhost)) != 0) - return; - } -#endif - m = leget(pkt, len, 0, ifp); - if (m == 0) - return; - ether_input(ifp, et, m); -} - -/* - * Routine to copy from mbuf chain to transmit - * buffer in board local memory. - * - * ### this can be done by remapping in some cases - */ -int -leput(lebuf, m) - register char *lebuf; - register struct mbuf *m; -{ - register struct mbuf *mp; - register int len, tlen = 0; - - for (mp = m; mp; mp = mp->m_next) { - len = mp->m_len; - if (len == 0) - continue; - tlen += len; - bcopy(mtod(mp, char *), lebuf, len); - lebuf += len; - } - m_freem(m); - if (tlen < LEMINSIZE) { - bzero(lebuf, LEMINSIZE - tlen); - tlen = LEMINSIZE; - } - return (tlen); -} - -/* - * Routine to copy from board local memory into mbufs. - */ -struct mbuf * -leget(lebuf, totlen, off0, ifp) - char *lebuf; - int totlen, off0; - struct ifnet *ifp; -{ - register struct mbuf *m; - struct mbuf *top = 0, **mp = ⊤ - register int off = off0, len; - register char *cp; - char *epkt; - - lebuf += sizeof(struct ether_header); - cp = lebuf; - epkt = cp + totlen; - if (off) { - cp += off + 2 * sizeof(u_short); - totlen -= 2 * sizeof(u_short); - } - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) - return (0); - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = totlen; - m->m_len = MHLEN; - - while (totlen > 0) { - if (top) { - MGET(m, M_DONTWAIT, MT_DATA); - if (m == 0) { - m_freem(top); - return (0); - } - m->m_len = MLEN; - } - len = min(totlen, epkt - cp); - if (len >= MINCLSIZE) { - MCLGET(m, M_DONTWAIT); - if (m->m_flags & M_EXT) - m->m_len = len = min(len, MCLBYTES); - else - len = m->m_len; - } else { - /* - * Place initial small packet/header at end of mbuf. - */ - if (len < m->m_len) { - if (top == 0 && len + max_linkhdr <= m->m_len) - m->m_data += max_linkhdr; - m->m_len = len; - } else - len = m->m_len; - } - bcopy(cp, mtod(m, caddr_t), (unsigned)len); - cp += len; - *mp = m; - mp = &m->m_next; - totlen -= len; - if (cp == epkt) - cp = lebuf; - } - return (top); -} - -/* - * Process an ioctl request. - */ -int -leioctl(ifp, cmd, data) - register struct ifnet *ifp; - int cmd; - caddr_t data; -{ - register struct ifaddr *ifa; - register struct le_softc *sc = lecd.cd_devs[ifp->if_unit]; - register volatile struct lereg1 *ler1; - int s = splimp(), error = 0; - - switch (cmd) { - - case SIOCSIFADDR: - ifa = (struct ifaddr *)data; - ifp->if_flags |= IFF_UP; - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - (void)leinit(ifp->if_unit); /* before arpwhohas */ - ((struct arpcom *)ifp)->ac_ipaddr = - IA_SIN(ifa)->sin_addr; - arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr); - break; -#endif -#ifdef NS - case AF_NS: - { - register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); - - if (ns_nullhost(*ina)) - ina->x_host = *(union ns_host *)(sc->sc_addr); - else { - /* - * The manual says we can't change the address - * while the receiver is armed, - * so reset everything - */ - ifp->if_flags &= ~IFF_RUNNING; - bcopy((caddr_t)ina->x_host.c_host, - (caddr_t)sc->sc_addr, sizeof(sc->sc_addr)); - } - (void)leinit(ifp->if_unit); /* does le_setaddr() */ - break; - } -#endif - default: - (void)leinit(ifp->if_unit); - break; - } - break; - - case SIOCSIFFLAGS: - ler1 = sc->sc_r1; - if ((ifp->if_flags & IFF_UP) == 0 && - ifp->if_flags & IFF_RUNNING) { - ler1->ler1_rdp = LE_C0_STOP; - ifp->if_flags &= ~IFF_RUNNING; - } else if (ifp->if_flags & IFF_UP && - (ifp->if_flags & IFF_RUNNING) == 0) - (void)leinit(ifp->if_unit); - /* - * If the state of the promiscuous bit changes, the interface - * must be reset to effect the change. - */ - if (((ifp->if_flags ^ sc->sc_iflags) & IFF_PROMISC) && - (ifp->if_flags & IFF_RUNNING)) { - sc->sc_iflags = ifp->if_flags; - lereset(&sc->sc_dev); - lestart(ifp); - } - break; - - case SIOCADDMULTI: - error = ether_addmulti((struct ifreq *)data, &sc->sc_ac); - goto update_multicast; - - case SIOCDELMULTI: - error = ether_delmulti((struct ifreq *)data, &sc->sc_ac); - update_multicast: - if (error == ENETRESET) { - /* - * Multicast list has changed; set the hardware - * filter accordingly. - */ - lereset(&sc->sc_dev); - error = 0; - } - break; - - default: - error = EINVAL; - } - splx(s); - return (error); -} - -void -leerror(sc, stat) - register struct le_softc *sc; - int stat; -{ - if (!ledebug) - return; - - /* - * Not all transceivers implement heartbeat - * so we only log CERR once. - */ - if ((stat & LE_C0_CERR) && sc->sc_cerr) - return; - log(LOG_WARNING, "%s: error: stat=%b\n", - sc->sc_dev.dv_xname, stat, LE_C0_BITS); -} - -void -lererror(sc, msg) - register struct le_softc *sc; - char *msg; -{ - register volatile struct lermd *rmd; - int len; - - if (!ledebug) - return; - - rmd = &sc->sc_r2->ler2_rmd[sc->sc_rmd]; - len = rmd->rmd3; - log(LOG_WARNING, "%s: ierror(%s): from %s: buf=%d, len=%d, rmd1=%b\n", - sc->sc_dev.dv_xname, msg, len > 11 ? - ether_sprintf((u_char *)&sc->sc_r2->ler2_rbuf[sc->sc_rmd][6]) : - "unknown", - sc->sc_rmd, len, rmd->rmd1_bits, LE_R1_BITS); -} - -void -lexerror(sc) - register struct le_softc *sc; -{ - register volatile struct letmd *tmd; - register int len, tmd3, tdr; - - if (!ledebug) - return; - - tmd = sc->sc_r2->ler2_tmd; - tmd3 = tmd->tmd3; - tdr = tmd3 & LE_T3_TDR_MASK; - len = -(tmd->tmd2 & ~LE_XMD2_ONES); - log(LOG_WARNING, - "%s: oerror: to %s: buf=%d, len=%d, tmd1=%b, tmd3=%b, tdr=%d (%d nsecs)\n", - sc->sc_dev.dv_xname, len > 5 ? - ether_sprintf((u_char *)&sc->sc_r2->ler2_tbuf[0][0]) : "unknown", - 0, len, - tmd->tmd1_bits, LE_T1_BITS, - tmd3, LE_T3_BITS, tdr, tdr * 100); -} diff --git a/sys/arch/sparc/sbus/if_lereg.h b/sys/arch/sparc/sbus/if_lereg.h deleted file mode 100644 index 207ee43f9c5f..000000000000 --- a/sys/arch/sparc/sbus/if_lereg.h +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * Copyright (c) 1982, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Header: if_lereg.h,v 1.7 93/10/31 04:41:00 leres Locked - * from: @(#)if_lereg.h 8.2 (Berkeley) 10/30/93 - * $Id: if_lereg.h,v 1.3 1994/07/02 01:10:07 deraadt Exp $ - */ - -#define LEMTU 1518 -#define LEMINSIZE 60 /* should be 64 if mode DTCR is set */ -#define LERBUF 8 -#define LERBUFLOG2 3 -#define LE_RLEN (LERBUFLOG2 << 13) -#define LETBUF 1 -#define LETBUFLOG2 0 -#define LE_TLEN (LETBUFLOG2 << 13) - -/* Local Area Network Controller for Ethernet (LANCE) registers */ -struct lereg1 { - u_short ler1_rdp; /* register data port */ - u_short ler1_rap; /* register address port */ -}; - -/* register addresses */ -#define LE_CSR0 0 /* Control and status register */ -#define LE_CSR1 1 /* low address of init block */ -#define LE_CSR2 2 /* high address of init block */ -#define LE_CSR3 3 /* Bus master and control */ - -/* Control and status register 0 (csr0) */ -#define LE_C0_ERR 0x8000 /* error summary */ -#define LE_C0_BABL 0x4000 /* transmitter timeout error */ -#define LE_C0_CERR 0x2000 /* collision */ -#define LE_C0_MISS 0x1000 /* missed a packet */ -#define LE_C0_MERR 0x0800 /* memory error */ -#define LE_C0_RINT 0x0400 /* receiver interrupt */ -#define LE_C0_TINT 0x0200 /* transmitter interrupt */ -#define LE_C0_IDON 0x0100 /* initalization done */ -#define LE_C0_INTR 0x0080 /* interrupt condition */ -#define LE_C0_INEA 0x0040 /* interrupt enable */ -#define LE_C0_RXON 0x0020 /* receiver on */ -#define LE_C0_TXON 0x0010 /* transmitter on */ -#define LE_C0_TDMD 0x0008 /* transmit demand */ -#define LE_C0_STOP 0x0004 /* disable all external activity */ -#define LE_C0_STRT 0x0002 /* enable external activity */ -#define LE_C0_INIT 0x0001 /* begin initalization */ - -#define LE_C0_BITS \ - "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\ -\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT" - -/* Control and status register 3 (csr3) */ -#define LE_C3_BSWP 0x4 /* byte swap */ -#define LE_C3_ACON 0x2 /* ALE control, eh? */ -#define LE_C3_BCON 0x1 /* byte control */ -/* - * Current size is 13,758 bytes with 8 x 1518 receive buffers and - * 1 x 1518 transmit buffer. - */ -struct lereg2 { - /* initialization block */ - u_short ler2_mode; /* mode */ - u_char ler2_padr[6]; /* physical address */ - u_short ler2_ladrf[4]; /* logical address filter */ - u_short ler2_rdra; /* receive descriptor addr */ - u_short ler2_rlen; /* rda high and ring size */ - u_short ler2_tdra; /* transmit descriptor addr */ - u_short ler2_tlen; /* tda high and ring size */ - /* receive message descriptors. bits/hadr are byte order dependent. */ - struct lermd { - u_short rmd0; /* low address of packet */ - u_char rmd1_bits; /* descriptor bits */ - u_char rmd1_hadr; /* high address of packet */ - short rmd2; /* buffer byte count */ - u_short rmd3; /* message byte count */ - } ler2_rmd[LERBUF]; - /* transmit message descriptors */ - struct letmd { - u_short tmd0; /* low address of packet */ - u_char tmd1_bits; /* descriptor bits */ - u_char tmd1_hadr; /* high address of packet */ - short tmd2; /* buffer byte count */ - u_short tmd3; /* transmit error bits */ - } ler2_tmd[LETBUF]; - char ler2_rbuf[LERBUF][LEMTU]; - char ler2_tbuf[LETBUF][LEMTU]; -}; - -/* Initialzation block (mode) */ -#define LE_MODE_PROM 0x8000 /* promiscuous mode */ -/* 0x7f80 reserved, must be zero */ -#define LE_MODE_INTL 0x0040 /* internal loopback */ -#define LE_MODE_DRTY 0x0020 /* disable retry */ -#define LE_MODE_COLL 0x0010 /* force a collision */ -#define LE_MODE_DTCR 0x0008 /* disable transmit CRC */ -#define LE_MODE_LOOP 0x0004 /* loopback mode */ -#define LE_MODE_DTX 0x0002 /* disable transmitter */ -#define LE_MODE_DRX 0x0001 /* disable receiver */ -#define LE_MODE_NORMAL 0 /* none of the above */ - - -/* Receive message descriptor 1 (rmd1_bits) */ -#define LE_R1_OWN 0x80 /* LANCE owns the packet */ -#define LE_R1_ERR 0x40 /* error summary */ -#define LE_R1_FRAM 0x20 /* framing error */ -#define LE_R1_OFLO 0x10 /* overflow error */ -#define LE_R1_CRC 0x08 /* CRC error */ -#define LE_R1_BUFF 0x04 /* buffer error */ -#define LE_R1_STP 0x02 /* start of packet */ -#define LE_R1_ENP 0x01 /* end of packet */ - -#define LE_R1_BITS \ - "\20\10OWN\7ERR\6FRAM\5OFLO\4CRC\3BUFF\2STP\1ENP" - -/* Transmit message descriptor 1 (tmd1_bits) */ -#define LE_T1_OWN 0x80 /* LANCE owns the packet */ -#define LE_T1_ERR 0x40 /* error summary */ -#define LE_T1_MORE 0x10 /* multiple collisions */ -#define LE_T1_ONE 0x08 /* single collision */ -#define LE_T1_DEF 0x04 /* defferred transmit */ -#define LE_T1_STP 0x02 /* start of packet */ -#define LE_T1_ENP 0x01 /* end of packet */ - -#define LE_T1_BITS \ - "\20\10OWN\7ERR\6RES\5MORE\4ONE\3DEF\2STP\1ENP" - -/* Transmit message descriptor 3 (tmd3) */ -#define LE_T3_BUFF 0x8000 /* buffer error */ -#define LE_T3_UFLO 0x4000 /* underflow error */ -#define LE_T3_LCOL 0x1000 /* late collision */ -#define LE_T3_LCAR 0x0800 /* loss of carrier */ -#define LE_T3_RTRY 0x0400 /* retry error */ -#define LE_T3_TDR_MASK 0x03ff /* time domain reflectometry counter */ - -#define LE_XMD2_ONES 0xf000 - -#define LE_T3_BITS \ - "\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY" diff --git a/sys/arch/sparc/sbus/sbus.c b/sys/arch/sparc/sbus/sbus.c deleted file mode 100644 index 678e387735d5..000000000000 --- a/sys/arch/sparc/sbus/sbus.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)sbus.c 8.1 (Berkeley) 6/11/93 - * - * from: Header: sbus.c,v 1.10 92/11/26 02:28:13 torek Exp (LBL) - * $Id: sbus.c,v 1.1 1993/10/02 10:23:55 deraadt Exp $ - */ - -/* - * Sbus stuff. - */ - -#include -#include - -#include - -#include -#include - -/* autoconfiguration driver */ -void sbus_attach __P((struct device *, struct device *, void *)); -struct cfdriver sbuscd = - { NULL, "sbus", matchbyname, sbus_attach, - DV_DULL, sizeof(struct sbus_softc) }; - -/* - * Print the location of some sbus-attached device (called just - * before attaching that device). If `sbus' is not NULL, the - * device was found but not configured; print the sbus as well. - * Return UNCONF (config_find ignores this if the device was configured). - */ -int -sbus_print(args, sbus) - void *args; - char *sbus; -{ - register struct sbus_attach_args *sa = args; - - if (sbus) - printf("%s at %s", sa->sa_ra.ra_name, sbus); - printf(" slot %d offset 0x%x", sa->sa_slot, sa->sa_offset); - return (UNCONF); -} - -/* - * Attach an Sbus. - */ -void -sbus_attach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - register struct sbus_softc *sc = (struct sbus_softc *)self; - register int base, node, slot; - register char *name; - struct sbus_attach_args sa; - register struct romaux *ra; - - /* - * XXX there is only one Sbus, for now -- do not know how to - * address children on others - */ - if (sc->sc_dev.dv_unit > 0) { - printf(" unsupported\n"); - return; - } - - /* - * Record clock frequency for synchronous SCSI. - * IS THIS THE CORRECT DEFAULT?? - */ - ra = aux; - node = ra->ra_node; - sc->sc_clockfreq = getpropint(node, "clock-frequency", 25*1000*1000); - printf(": clock = %s MHz\n", clockfreq(sc->sc_clockfreq)); - - if (ra->ra_bp != NULL && strcmp(ra->ra_bp->name, "sbus") == 0) - sa.sa_ra.ra_bp = ra->ra_bp + 1; - else - sa.sa_ra.ra_bp = NULL; - - /* - * Loop through ROM children, fixing any relative addresses - * and then configuring each device. - */ - for (node = firstchild(node); node; node = nextsibling(node)) { - name = getpropstring(node, "name"); - if (!romprop(&sa.sa_ra, name, node)) - continue; - base = (int)sa.sa_ra.ra_paddr; - if (SBUS_ABS(base)) { - sa.sa_slot = SBUS_ABS_TO_SLOT(base); - sa.sa_offset = SBUS_ABS_TO_OFFSET(base); - } else { - sa.sa_slot = slot = sa.sa_ra.ra_iospace; - sa.sa_offset = base; - sa.sa_ra.ra_paddr = (void *)SBUS_ADDR(slot, base); - } - (void) config_found(&sc->sc_dev, (void *)&sa, sbus_print); - } -} - -/* - * Each attached device calls sbus_establish after it initializes - * its sbusdev portion. - */ -void -sbus_establish(sd, dev) - register struct sbusdev *sd; - register struct device *dev; -{ - register struct sbus_softc *sc = (struct sbus_softc *)dev->dv_parent; - - sd->sd_dev = dev; - sd->sd_bchain = sc->sc_sbdev; - sc->sc_sbdev = sd; -} - -/* - * Reset the given sbus. (???) - */ -void -sbusreset(sbus) - int sbus; -{ - register struct sbusdev *sd; - struct sbus_softc *sc = sbuscd.cd_devs[sbus]; - struct device *dev; - - printf("reset %s:", sc->sc_dev.dv_xname); - for (sd = sc->sc_sbdev; sd != NULL; sd = sd->sd_bchain) { - if (sd->sd_reset) { - dev = sd->sd_dev; - (*sd->sd_reset)(dev); - printf(" %s", dev->dv_xname); - } - } -} diff --git a/sys/arch/sparc/sbus/sbusreg.h b/sys/arch/sparc/sbus/sbusreg.h deleted file mode 100644 index 1ffdc82c0c8b..000000000000 --- a/sys/arch/sparc/sbus/sbusreg.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)sbusreg.h 8.1 (Berkeley) 6/11/93 - * - * from: Header: sbusreg.h,v 1.6 92/11/26 02:28:14 torek Exp (LBL) - * $Id: sbusreg.h,v 1.1 1993/10/02 10:23:56 deraadt Exp $ - */ - -/* - * Sun-4c S-bus definitions. (Should be made generic!) - * - * Sbus slot 0 is not a separate slot; it talks to the onboard I/O devices. - * It is, however, addressed just like any `real' Sbus. - * - * Sbus device addresses are obtained from the FORTH PROMs. They come - * in `absolute' and `relative' address flavors, so we have to handle both. - * Relative addresses do *not* include the slot number. - */ -#define SBUS_BASE 0xf8000000 -#define SBUS_ADDR(slot, off) (SBUS_BASE + ((slot) << 25) + (off)) -#define SBUS_ABS(a) ((unsigned)(a) >= SBUS_BASE) -#define SBUS_ABS_TO_SLOT(a) (((a) - SBUS_BASE) >> 25) -#define SBUS_ABS_TO_OFFSET(a) (((a) - SBUS_BASE) & 0x1ffffff) diff --git a/sys/arch/sparc/sbus/sbusvar.h b/sys/arch/sparc/sbus/sbusvar.h deleted file mode 100644 index 5527897e827f..000000000000 --- a/sys/arch/sparc/sbus/sbusvar.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)sbusvar.h 8.1 (Berkeley) 6/11/93 - * - * from: Header: sbusvar.h,v 1.6 92/11/26 02:28:14 torek Exp (LBL) - * $Id: sbusvar.h,v 1.1 1993/10/02 10:23:57 deraadt Exp $ - */ - -/* - * S-bus variables. - */ -struct sbusdev { - struct device *sd_dev; /* backpointer to generic */ - struct sbusdev *sd_bchain; /* forward link in bus chain */ - void (*sd_reset) __P((struct device *)); -}; - -/* - * Sbus driver attach arguments. - */ -struct sbus_attach_args { - struct romaux sa_ra; /* name, node, addr, etc */ - int sa_slot; /* Sbus slot number */ - int sa_offset; /* offset within slot */ -}; - -/* variables per Sbus */ -struct sbus_softc { - struct device sc_dev; /* base device */ - int sc_clockfreq; /* clock frequency (in Hz) */ - struct sbusdev *sc_sbdev; /* list of all children */ -}; - -int sbusdev_match __P((struct cfdata *, void *)); -void sbus_establish __P((struct sbusdev *, struct device *)); diff --git a/sys/arch/sparc/scsi/scsi_subr.c b/sys/arch/sparc/scsi/scsi_subr.c deleted file mode 100644 index 3d4b89630e99..000000000000 --- a/sys/arch/sparc/scsi/scsi_subr.c +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratories. - * - * %sccs.include.redist.c% - * - * %W% (Berkeley) %G% - * - * from: Header: scsi_subr.c,v 1.10 93/02/01 19:21:58 torek Locked (LBL) - * $Id: scsi_subr.c,v 1.2 1993/10/27 18:15:06 deraadt Exp $ - */ - -/* - * Generic SCSI host adapter driver. - * Does almost nothing (most work is relegated to per-hba drivers). - */ - -#include -#include -#include - -#include -#include - -/* - * General subroutines, and scsi data. - */ - -/* table of lengths of scsi commands */ -const char scsicmdlen[8] = { 6, 10, 0, 0, 0, 12, 0, 0 }; - -/* table of lengths of scsi messages */ -const signed char scsimsglen[0x24] = { - SMLEN_DONE, /* MSG_CMD_COMPLETE */ - SMLEN_EXTENDED, /* MSG_EXT_MESSAGE */ - 1, /* MSG_SAVE_DATA_PTR */ - 1, /* MSG_RESTORE_PTR */ - 1, /* MSG_DISCONNECT */ - 1, /* MSG_INIT_DETECT_ERROR */ - 1, /* MSG_ABORT */ - 1, /* MSG_REJECT */ - 1, /* MSG_NOOP */ - 1, /* MSG_PARITY_ERROR */ - 1, /* MSG_LCC */ - 1, /* MSG_LCCF */ - 1, /* MSG_BUS_DEVICE_RESET */ - 1, /* MSG_ABORT_TAG */ - 1, /* MSG_CLEAR_QUEUE */ - 1, /* MSG_INITIATE_RECOVERY */ - 1, /* MSG_RELEASE_RECOVERY */ - 1, /* MSG_TERMINATE_PROCESS */ - SMLEN_UNDEF, /* 0x12 */ - SMLEN_UNDEF, /* 0x13 */ - SMLEN_UNDEF, /* 0x14 */ - SMLEN_UNDEF, /* 0x15 */ - SMLEN_UNDEF, /* 0x16 */ - SMLEN_UNDEF, /* 0x17 */ - SMLEN_UNDEF, /* 0x18 */ - SMLEN_UNDEF, /* 0x19 */ - SMLEN_UNDEF, /* 0x1a */ - SMLEN_UNDEF, /* 0x1b */ - SMLEN_UNDEF, /* 0x1c */ - SMLEN_UNDEF, /* 0x1d */ - SMLEN_UNDEF, /* 0x1e */ - SMLEN_UNDEF, /* 0x1f */ - 2, /* MSG_SIMPLE_QTAG */ - 2, /* MSG_HEAD_QTAG */ - 2, /* MSG_ORDERED_QTAG */ - 2, /* MSG_IGNORE_WIDE_RESID */ -}; - -/* definition of `tg' target driver for autoconfig */ -static int scsi_targmatch __P((struct device *, struct cfdata *, void *)); -static void scsi_targattach __P((struct device *, struct device *, void *)); -struct cfdriver tgcd = - { NULL, "tg", scsi_targmatch, scsi_targattach, - DV_DULL, sizeof(struct targ) }; - -void scsi_targstart __P((struct device *, struct sq *, struct buf *, - scdgo_fn, struct device *)); -int scsi_targgo __P((struct device *, int targ, - scintr_fn, struct device *, struct buf *, int)); -void scsi_targintr __P((struct device *, int, int)); -void scsi_targrel __P((struct device *)); - -#define NOBUF ((caddr_t)0) - -/* - * Perform a TEST UNIT READY immediate (polled) command - * on the given pair. Return the status byte - * returned, or -1 for none. - */ -int -scsi_test_unit_ready(hba, targ, unit) - struct hba_softc *hba; - int targ, unit; -{ - struct scsi_cdb cdb; - - CDB6(&cdb)->cdb_cmd = CMD_TEST_UNIT_READY; - CDB6(&cdb)->cdb_lun_lbah = unit << 5; - *(short *)&CDB6(&cdb)->cdb_lbam = 0; - *(short *)&CDB6(&cdb)->cdb_len = 0; - return (hba->hba_driver->hd_icmd(hba, targ, &cdb, NOBUF, 0, 0)); -} - -/* - * Request sense. The sense is to be written into the given buffer. - * The given length must be < 256. - */ -int -scsi_request_sense(hba, targ, unit, buf, len) - struct hba_softc *hba; - int targ, unit; - caddr_t buf; - int len; -{ - struct scsi_cdb cdb; - - CDB6(&cdb)->cdb_cmd = CMD_REQUEST_SENSE; - CDB6(&cdb)->cdb_lun_lbah = unit << 5; - *(short *)&CDB6(&cdb)->cdb_lbam = 0; - CDB6(&cdb)->cdb_len = len; - CDB6(&cdb)->cdb_ctrl = 0; - return (hba->hba_driver->hd_icmd(hba, targ, &cdb, buf, len, B_READ)); -} - -/* - * Called (indirectly, via config_found) from scsi_hbaattach. - * Print target number, and if no device was configured there, - * the hba as well. - */ -int -scsi_targprint(aux, hba) - void *aux; - char *hba; -{ - - if (hba) { - printf("target %d on %s", *(int *)aux, hba); - return (UNCONF); - } - printf(" target %d", *(int *)aux); - return (QUIET); -} - -/* - * Print information about a unit found on some target. - * If the unit was not configured, `targ' is the name of the target - * on which the unit was found. If it was, targ is NULL and we - * let the unit's attach routine print the INQUIRE result if - * appropriate. - */ -static int -scsi_unitprint(aux, targ) - void *aux; - char *targ; -{ - register struct scsi_attach_args *sa = aux; - - if (targ) { - printf("unit %d at %s", sa->sa_unit, targ); - if ((sa->sa_inq_status & STS_MASK) == STS_GOOD) { - printf(" ("); - scsi_printinq(&sa->sa_si); - printf(")"); - } - return (UNCONF); - } - printf(" unit %d", sa->sa_unit); - return (QUIET); -} - -/* - * Generic target-match. - */ -static int -scsi_targmatch(parent, cf, aux) - struct device *parent; - register struct cfdata *cf; - void *aux; -{ - int targ = *(int *)aux; - - return (cf->cf_loc[0] == targ || cf->cf_loc[0] == -1); -} - -/* - * And now, a generic `target attach' routine. - * We assume that INQUIRY works. - */ -static void -scsi_targattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - register struct targ *t = (struct targ *)self; - register struct hba_softc *hba; - register struct hbadriver *hd; - register int targ, unit; - struct scsi_attach_args sa; - struct scsi_cdb si; - - printf("\n"); - t->t_targ = targ = *(int *)aux; - hba = (struct hba_softc *)parent; - hba->hba_targets[targ] = t; - - /* - * Probe each of the 8 units using the sequence - * TEST UNIT READY - * REQUEST SENSE - * INQUIRY - * The first should not be necessary, but some SCSI devices - * refuse to speak until it is done. The second is only necessary - * if the first returns a CHECK CONDITION status, but we do it - * anyway. - */ - hd = hba->hba_driver; - sa.sa_targ = targ; - CDB6(&si)->cdb_cmd = CMD_INQUIRY; - *(short *)&CDB6(&si)->cdb_lbam = 0; - CDB6(&si)->cdb_len = sizeof sa.sa_si; - CDB6(&si)->cdb_ctrl = 0; - for (unit = 0; unit < 8; unit++) { - if (scsi_test_unit_ready(hba, targ, unit) == -1) - continue; - sa.sa_unit = unit; - sa.sa_req_status = scsi_request_sense(hba, targ, unit, - (caddr_t)&sa.sa_sn, sizeof sa.sa_sn); - CDB6(&si)->cdb_lun_lbah = unit << 5; - sa.sa_inq_status = (*hd->hd_icmd)(hba, targ, &si, - (caddr_t)&sa.sa_si, sizeof sa.sa_si, B_READ); - if ((sa.sa_inq_status & STS_MASK) == STS_GOOD && -#ifdef notdef /* XXX don't know if this is a reasonable test */ - (sa.sa_si.si_type & TYPE_QUAL_MASK) == TYPE_QUAL_NOTCONN && -#endif - (sa.sa_si.si_type & TYPE_TYPE_MASK) == TYPE_NP) { - continue; - } - config_found(&t->t_dev, (void *)&sa, scsi_unitprint); - } -} - -/* - * Each unit calls scsi_establish to tell the hba and target of - * its existence. - */ -void -scsi_establish(u, dev, unit) - register struct unit *u; - struct device *dev; - register int unit; -{ - register struct targ *t; - register struct hba_softc *hba; - register struct hbadriver *hbd; - - u->u_dev = dev; - t = (struct targ *)dev->dv_parent; - hba = (struct hba_softc *)t->t_dev.dv_parent; - hbd = hba->hba_driver; - t->t_units[unit] = u; - if (t->t_nunits == 0) { - /* - * This is the first unit on the target. We can - * probably just call the hba start code, avoiding - * one level of calls and queueing. If we attach - * another target we will fix this in the code below. - */ - u->u_start = hbd->hd_start; - u->u_go = hbd->hd_go; - u->u_rel = hbd->hd_rel; - u->u_updev = &hba->hba_dev; - t->t_firstunit = unit; - } else { - /* - * This is not the only unit on the target, so we - * must call the target start code rather than the - * hba start code. Fix the linkage on the first - * target too (possibly for the 2nd, 3rd, ..., time). - */ - t->t_units[t->t_firstunit]->u_start = scsi_targstart; - t->t_units[t->t_firstunit]->u_go = scsi_targgo; - t->t_units[t->t_firstunit]->u_rel = scsi_targrel; - t->t_units[t->t_firstunit]->u_updev = &t->t_dev; - u->u_start = scsi_targstart; - u->u_go = scsi_targgo; - u->u_rel = scsi_targrel; - u->u_updev = &t->t_dev; - } - t->t_nunits++; /* another unit is alive */ - u->u_unit = unit; - u->u_targ = t->t_targ; /* record target number, */ - u->u_hba = hba; /* hba ... */ - u->u_hbd = hbd; /* and driver */ -} - -/* NO DOUBT SOME OF THE STUFF PRINTED HERE IS USELESS */ -void -scsi_printinq(inq) - register struct scsi_inquiry *inq; -{ - register int iso, ecma, ansi, t; - static char *types[] = { "disk", "tape", "printer", "processor", - "WORM", "ROM disk", "scanner", "magneto-optical", - "jukebox", "lan" }; - - if ((t = (inq->si_type & TYPE_QUAL_MASK)) != 0) - printf("type-qual=0x%x ", t); - t = inq->si_type & TYPE_TYPE_MASK; - if (t < sizeof types / sizeof *types) - printf("%s", types[t]); - else - printf("", t); - if (inq->si_qual & QUAL_RMB) - printf(" (removable)"); - printf(" qual=0x%x", inq->si_qual & QUAL_MASK); - iso = (inq->si_qual >> VER_ISO_SHIFT) & VER_ISO_MASK; - ecma = (inq->si_qual >> VER_ECMA_SHIFT) & VER_ECMA_MASK; - ansi = (inq->si_qual >> VER_ANSI_SHIFT) & VER_ANSI_MASK; - printf(" version=", iso, ecma, ansi); - if (ansi == 1 || ansi == 2) { - char v[9], p[17], r[5]; - - scsi_inq_ansi((struct scsi_inq_ansi *)inq, v, p, r); - printf(" vendor %s, product %s, rev %s", v, p, r); - } -} - -/* copy a counted string but trim trailing blanks; make the dest a C string */ -static void -scsi_str(src, dst, len) - register char *src, *dst; - register int len; -{ - - while (src[len - 1] == ' ') { - if (--len == 0) { - *dst = 0; - return; - } - } - bcopy(src, dst, len); - dst[len] = 0; -} - -void -scsi_inq_ansi(si, vendor, product, rev) - register struct scsi_inq_ansi *si; - char *vendor, *product, *rev; -{ - register int i, len; - - /* if too short, extend with blanks */ - len = si->si_len + 5; /* 5 fixed; len is `additional' */ - if (len < sizeof(*si)) - for (i = len; i < sizeof *si; i++) - ((char *)si)[i] = ' '; - scsi_str(si->si_vendor, vendor, sizeof si->si_vendor); - scsi_str(si->si_product, product, sizeof si->si_product); - scsi_str(si->si_rev, rev, sizeof si->si_rev); -} - -/* - * Tell all the devices on the given hba that it has been reset. - * SHOULD PROBABLY DO MORE HERE - */ -void -scsi_reset_units(hba) - register struct hba_softc *hba; -{ - register int targ, unit; - register struct targ *t; - register struct unit *u; - - for (targ = 0; targ < 8; targ++) { - if ((t = hba->hba_targets[targ]) == NULL) - continue; - for (unit = 0; unit < 8; unit++) - if ((u = t->t_units[unit]) != NULL) - (*u->u_driver->ud_reset)(u); - } -} - -/* - * Start a unit on a target. - * If the target is busy, just enqueue the unit; - * once the target becomes free, we will call the hba start routine. - * Otherwise, call the hba start routine now, and then when the hba - * becomes free it will call the unit's dgo routine. - */ -void -scsi_targstart(self, sq, bp, dgo, dev) - struct device *self; - register struct sq *sq; - struct buf *bp; - scdgo_fn dgo; - struct device *dev; -{ - register struct targ *t = (struct targ *)self; - register struct hba_softc *hba; - - sq->sq_forw = NULL; - if (t->t_head == NULL) - t->t_head = sq; - else - t->t_tail->sq_forw = sq; - t->t_tail = sq; - if (t->t_busy == 0) { - t->t_busy = 1; - hba = (struct hba_softc *)t->t_dev.dv_parent; - (*hba->hba_driver->hd_start)(&hba->hba_dev, &t->t_forw, bp, - dgo, dev); - } else { - sq->sq_bp = bp; - sq->sq_dgo = dgo; - sq->sq_dev = dev; - } -} - -/* - * The unit got the bus, and wants the hba to go. - * Remember its interrupt handler; substitute ours instead. - */ -int -scsi_targgo(self, targ, intr, dev, bp, pad) - struct device *self; - int targ; - scintr_fn intr; - struct device *dev; - struct buf *bp; - int pad; -{ - register struct targ *t = (struct targ *)self; - register struct hba_softc *hba; - - t->t_intr = intr; - t->t_intrdev = dev; - hba = (struct hba_softc *)t->t_dev.dv_parent; - return ((*hba->hba_driver->hd_go)(&hba->hba_dev, targ, - scsi_targintr, &t->t_dev, bp, pad)); -} - -/* - * The hba got an interrupt. Dequeue the unit from the target - * (the target is already off the hba queue) and then call the - * underlying interrupt handler. - */ -void -scsi_targintr(self, stat, resid) - struct device *self; - int stat, resid; -{ - register struct targ *t = (struct targ *)self; - register struct hba_softc *hba; - register struct sq *sq; - - sq = t->t_head; -if (sq == NULL) panic("scsi_targintr"); - t->t_head = sq = sq->sq_forw; - (*t->t_intr)(t->t_intrdev, stat, resid); - if (sq != NULL) { - hba = (struct hba_softc *)t->t_dev.dv_parent; - (*hba->hba_driver->hd_start)(&hba->hba_dev, &t->t_forw, - sq->sq_bp, sq->sq_dgo, sq->sq_dev); - } else - t->t_busy = 0; -} - -/* - * The unit decided that it needed to `give up' its hold on the bus early. - */ -void -scsi_targrel(self) - struct device *self; -{ - register struct targ *t = (struct targ *)self; - register struct hba_softc *hba; - register struct sq *sq; - - hba = (struct hba_softc *)t->t_dev.dv_parent; - sq = t->t_head; -if (sq == NULL) panic("scsi_targrel"); - /* - * This target is at the head of the hba queue. - * Remove it by calling hba bus release. Then, if the - * target queue is not empty, put it back on the hba queue. - * (This produces round robin service.) - */ - (*hba->hba_driver->hd_rel)(&hba->hba_dev); - sq = sq->sq_forw; - if ((t->t_head = sq) != NULL) - (*hba->hba_driver->hd_start)(&hba->hba_dev, &t->t_forw, - sq->sq_bp, sq->sq_dgo, sq->sq_dev); - else - t->t_busy = 0; -} diff --git a/sys/arch/sparc/scsi/scsivar.h b/sys/arch/sparc/scsi/scsivar.h deleted file mode 100644 index c3e2ca061b4a..000000000000 --- a/sys/arch/sparc/scsi/scsivar.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratories. - * - * %sccs.include.redist.c% - * - * %W% (Berkeley) %G% - * - * from: Header: scsivar.h,v 1.7 92/12/02 03:54:05 torek Exp (LBL) - * $Id: scsivar.h,v 1.1 1993/10/27 17:48:42 deraadt Exp $ - */ - -/* - * SCSI variables. - * - * Each SCSI Host Bus Adapter (hba) has: - * a target queue head and tail - * eight targets (for units to enqueue on) - * a list of all units on all targets - * its target number (the number cpu uses in initiating requests) - * a driver - * Each SCSI target has: - * a forward link so that it can sit on a SCSI host bus adapter queue - * a unit queue head and tail - * Each SCSI unit has: - * a forward link so that it can sit on a SCSI target queue - * a driver - * an hba & driver (so that we need not chase parent pointers) - */ - -/* - * Downcalls. These are usually made from hba to unit, but can be - * hba->target->unit (when there are multiple units on a target). - */ -/* device go function (`you got bus') */ -typedef void (*scdgo_fn) __P((struct device *, struct scsi_cdb *)); - -/* intr function (`you no got bus no more') */ -typedef void (*scintr_fn) __P((struct device *, int stat, int resid)); - -/* - * Upcalls. These are usually made from unit to hba, but can be - * unit->target->hba. - */ -/* bus alloc function (`please get me bus') */ -struct sq; struct buf; -typedef void (*scstart_fn) __P((struct device *, struct sq *, struct buf *, - scdgo_fn, struct device *)); - -/* bus go function (`I have bus and I set up cmd, so start it up') */ -typedef int (*scbusgo_fn) __P((struct device *, int targ, - scintr_fn, struct device *, - struct buf *, int pad)); - -/* bus release function (`I have bus but do not need it after all') */ -typedef void (*scbusrel_fn) __P((struct device *)); - -/* - * SCSI Queue. This is an element in a queue of devices (targets - * and/or units) waiting for the bus. - */ -struct sq { - struct sq *sq_forw; /* forward link */ - struct buf *sq_bp; /* buffer for transfer */ - scdgo_fn sq_dgo; /* device-go to call when got bus */ - struct device *sq_dev; /* device argument to sq_dgo */ -}; - -struct hba_softc { - struct device hba_dev; /* generic part */ - struct sq *hba_head, *hba_tail;/* io queue (u's/t's wanting bus) */ - char hba_busy; /* true => will inspect qhead later */ - struct targ *hba_targets[8]; /* the 8 possible targets */ - struct hbadriver *hba_driver; /* hba driver */ - scintr_fn hba_intr; /* current interrupt function */ - struct device *hba_intrdev; /* arg 0 for hba_intr */ -}; - -struct targ { - struct device t_dev; /* generic part */ - struct sq t_forw; /* forward link, etc, on hba queue */ - struct sq *t_head, *t_tail; /* io queue */ - char t_busy; /* true => will inspect qhead later */ - char t_targ; /* target number */ - char t_nunits; /* count of live units */ - char t_firstunit; /* the first live unit */ - struct unit *t_units[8]; /* the 8 possible units */ - scintr_fn t_intr; /* current interrupt function */ - struct device *t_intrdev; /* arg 0 for t_intr */ -}; - -/* since a unit may be a disk, tape, etc., it has only pointer to dev */ -struct unit { - struct device *u_dev; /* backpointer to generic */ - int u_unit; /* unit number on target */ - scstart_fn u_start; /* upcall to get bus */ - scbusgo_fn u_go; /* upcall to use bus */ - scbusrel_fn u_rel; /* upcall to release bus early */ - struct device *u_updev; /* device for upcalls */ - struct sq u_forw; /* forward link on target or hba q */ - struct unitdriver *u_driver; /* unit driver */ -/* the following three fields are copied from target & hba, for quick lookup */ - int u_targ; /* target number */ - struct hba_softc *u_hba; /* hba, from parent */ - struct hbadriver *u_hbd; /* hba driver, from parent */ -}; - -/* - * SCSI hba driver. - */ -struct hbadriver { - /* immediate command; should not depend on receiving interrupts */ - int (*hd_icmd) __P((struct hba_softc *, int targ, - struct scsi_cdb *cmd, - caddr_t addr, int len, int rw)); - /* crash dump: like icmd(B_WRITE), but possibly from physmem */ - int (*hd_dump) __P((struct hba_softc *, int targ, - struct scsi_cdb *cmd, caddr_t addr, int len)); - scstart_fn hd_start; /* allocate DMA & bus */ - scbusgo_fn hd_go; /* start DMA xfer on bus */ - scbusrel_fn hd_rel; /* release bus early */ - void (*hd_reset) __P((struct hba_softc *, int)); -}; - -/* - * SCSI unit driver (`downcalls' from hba to unit). - */ -struct unitdriver { - void (*ud_reset) __P((struct unit *)); /* SCSI bus reset */ -}; - -/* - * The generic SCSI target probe code passes the following to - * unit configuration `match' routines. - */ -struct scsi_attach_args { - int sa_targ; /* target number */ - int sa_unit; /* unit number */ - int sa_req_status; /* status from REQUEST SENSE */ - struct scsi_sense sa_sn; /* contents from same */ - int sa_inq_status; /* status from INQUIRY command */ - struct scsi_inquiry sa_si; /* contents from same */ -}; - -/* - * The SCSICMDLEN macro gives the SCSI-standard-defined length of - * a given SCSI command. This is 0 if the command is in an undefined - * group (see scsi.h). - */ -extern const char scsicmdlen[8]; -#define SCSICMDLEN(cmd) scsicmdlen[(cmd) >> 5] - -/* - * The SCSIMSGLEN macro gives the SCSI-standard-defined length of - * a given SCSI message byte. This is -1 if the message byte is - * undefined, -3 if it is an identify, -2 for an extended message, - * 0 if it is normal completion, otherwise positive. - */ -#define SMLEN_IDENTIFY -3 -#define SMLEN_EXTENDED -2 -#define SMLEN_UNDEF -1 -#define SMLEN_DONE 0 -extern const signed char scsimsglen[0x24]; -#define SCSIMSGLEN(msg) ((msg) & MSG_IDENTIFY ? SMLEN_IDENTIFY : \ - (msg) > 0x24 ? SMLEN_UNDEF : scsimsglen[msg]) - -/* - * Declarations for exported functions in scsi_subr.c - */ -int scsi_test_unit_ready __P((struct hba_softc *, int targ, int unit)); -int scsi_request_sense __P((struct hba_softc *, int, int, caddr_t, int)); -void scsi_hbaattach __P((struct hba_softc *)); -void scsi_establish __P((struct unit *, struct device *, int)); -void scsi_printinq __P((struct scsi_inquiry *)); -void scsi_inq_ansi __P((struct scsi_inq_ansi *, char *, char *, char *)); -void scsi_reset_units __P((struct hba_softc *)); - -#define SCSI_FOUNDTARGET(hba, targ) { \ - extern int scsi_targprint(void *, char *); \ - int _t = targ; \ - config_found(&(hba)->hba_dev, (void *)&_t, scsi_targprint); \ -} diff --git a/sys/arch/sparc/scsi/sd.c b/sys/arch/sparc/scsi/sd.c deleted file mode 100644 index 2dd265b9fcec..000000000000 --- a/sys/arch/sparc/scsi/sd.c +++ /dev/null @@ -1,884 +0,0 @@ -/* - * Copyright (c) 1990, 1992 The Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * %sccs.include.redist.c% - * - * %W% (Berkeley) %G% - * - * from: Header: sd.c,v 1.27 93/04/29 01:22:19 torek Exp - * $Id: sd.c,v 1.5 1994/02/01 06:01:30 deraadt Exp $ - */ - -/* - * SCSI CCS (Command Command Set) disk driver. - * - * MACHINE INDEPENDENT (do not put machine dependent goo in here!) - * - * (from sd.c,v 1.7 90/12/15 14:11:26 van Exp) - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#ifdef sparc /* XXX */ -#define SUN_LABEL_HACK /* XXX */ -#endif /* XXX */ - -#ifdef SUN_LABEL_HACK -#include -#endif - -/* - * Per-disk variables. - * - * sd_dk contains all the `disk' specific stuff (label/partitions, - * transfer rate, etc). We need only things that are special to - * scsi disks. Note that our blocks are in terms of DEV_BSIZE blocks. - */ -struct sd_softc { - struct dkdevice sc_dk; /* base disk device, must be first */ - struct unit sc_unit; /* scsi unit */ - pid_t sc_format_pid; /* process using "format" mode */ - u_char sc_type; /* drive type */ - u_char sc_bshift; /* convert device blocks to DEV_BSIZE blks */ - short sc_flags; /* see below */ - u_int sc_blks; /* number of blocks on device */ - int sc_blksize; /* device block size in bytes */ - - /* should be in dkdevice?? */ - struct buf sc_tab; /* transfer queue */ - - /* statistics */ - long sc_resets; /* number of times reset */ - long sc_transfers; /* count of total transfers */ - long sc_partials; /* count of `partial' transfers */ - - /* for user formatting */ - struct scsi_cdb sc_cmd; - struct scsi_fmt_sense sc_sense; -}; - -#define SDF_ALIVE 1 /* drive OK for regular kernel use */ - -/* definition of the autoconfig driver */ -int sdmatch __P((struct device *, struct cfdata *, void *)); -void sdattach __P((struct device *, struct device *, void *)); - -struct cfdriver sdcd = - { NULL, "sd", sdmatch, sdattach, DV_DISK, sizeof(struct sd_softc) }; - -/* definition of the unit driver, for hba */ -void sdigo __P((struct device *, struct scsi_cdb *)); -void sdgo __P((struct device *, struct scsi_cdb *)); -void sdintr __P((struct device *, int, int)); -void sdreset __P((struct unit *)); - -static struct unitdriver sdunitdriver = { /*sdgo, sdintr*/ sdreset }; - -/* definition of the disk driver, for kernel */ -void sdstrategy __P((struct buf *)); - -static struct dkdriver sddkdriver = { sdstrategy }; - -#ifdef DEBUG -int sddebug = 1; -#define SDB_ERROR 0x01 -#define SDB_PARTIAL 0x02 -#endif - -#define sdunit(x) (minor(x) >> 3) -#define sdpart(x) (minor(x) & 0x7) - -#define b_cylin b_resid - -#define SDRETRY 2 - -/* - * Table of scsi commands users are allowed to access via `format' - * mode. 0 means not legal. 1 means `immediate' (doesn't need dma). - * -1 means needs dma and/or wait for intr (i.e., `slow'). - */ -static char legal_cmds[256] = { -/***** 0 1 2 3 4 5 6 7 8 9 A B C D E F */ -/*00*/ 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*10*/ 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -/*20*/ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*30*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*40*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*50*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*60*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*70*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*80*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*90*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*a0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*b0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*c0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*d0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*e0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*f0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -int -sdmatch(parent, cf, aux) - struct device *parent; - register struct cfdata *cf; - void *aux; -{ - register struct scsi_attach_args *sa = aux; -#ifdef DEBUG - char *whynot; -#endif - - /* - * unit number must match, or be given as `any' - */ - if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != sa->sa_unit) - return (0); - /* - * drive must be a disk, and of a kind we recognize - */ - if ((sa->sa_inq_status & STS_MASK) != STS_GOOD) { -#ifdef DEBUG - whynot = "INQUIRY failed"; -#endif - goto notdisk; - } - - switch (sa->sa_si.si_type & TYPE_TYPE_MASK) { - - case TYPE_DAD: /* disk */ - case TYPE_WORM: /* WORM */ - case TYPE_ROM: /* CD-ROM */ - case TYPE_MO: /* Magneto-optical */ - case TYPE_JUKEBOX: /* medium changer */ - break; - - default: - notdisk: -#ifdef DEBUG - whynot = "not a disk"; - printf("[not matching `sd' at unit %d: %s]\n", - sa->sa_unit, whynot); -#endif - return (0); - } - - /* - * It is a disk of some kind; take it. We will figure out - * the rest in the attach routine. - */ - return (1); -} - -/* - * Attach a disk (called after sdmatch returns true). - * Note that this routine is never reentered (so we can use statics). - */ -void -sdattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - register struct sd_softc *sc = (struct sd_softc *)self; - register struct scsi_attach_args *sa = aux; - register int i; - char vendor[10], drive[17], rev[5]; - static u_char capbuf[8]; - static struct scsi_cdb cap = { CMD_READ_CAPACITY }; -#ifdef SUN_LABEL_HACK - static struct scsi_cdb rd0 = { CMD_READ10, 0, 0, 0, 0, 0, 0, 0, 1, 0 }; - caddr_t sector; -#endif - - /* - * Declare our existence. - */ - sc->sc_unit.u_driver = &sdunitdriver; - scsi_establish(&sc->sc_unit, &sc->sc_dk.dk_dev, sa->sa_unit); - - /* - * Figure out what kind of disk this is. - * We only accepted it if the inquiry succeeded, so - * we can inspect those fields. - */ - i = (sa->sa_si.si_version >> VER_ANSI_SHIFT) & VER_ANSI_MASK; - if (i == 1 || i == 2) { - scsi_inq_ansi((struct scsi_inq_ansi *)&sa->sa_si, - vendor, drive, rev); - printf(": %s %s", vendor, drive); - /* XXX should we even ever bother printing this? */ - if (rev[0]) - printf(" %s", rev); - } else { - /* bleah */ - bcopy("", vendor, 10); - bcopy("", drive, 10); - printf(": type 0x%x, qual 0x%x, ver %d", - sa->sa_si.si_type, sa->sa_si.si_qual, - sa->sa_si.si_version); - } - - CDB10(&cap)->cdb_lun_rel = sc->sc_unit.u_unit << 5; - i = (*sc->sc_unit.u_hbd->hd_icmd)(sc->sc_unit.u_hba, - sc->sc_unit.u_targ, &cap, (char *)capbuf, sizeof capbuf, B_READ); - i &= STS_MASK; - if (i == STS_GOOD) { -#define NUMBER(p) (((p)[0] << 24) | ((p)[1] << 16) | ((p)[2] << 8) | (p)[3]) - sc->sc_blks = NUMBER(&capbuf[0]); - sc->sc_blksize = NUMBER(&capbuf[4]); - } else if (i == STS_CHECKCOND && - (strcmp(vendor, "HP") == 0 && strcmp(drive, "S6300.650A") == 0)) { - /* XXX unformatted or nonexistent MO medium: fake it */ - sc->sc_blks = 318664; - sc->sc_blksize = 1024; - } else { - /* XXX shouldn't bail for removable media */ - printf(": unable to determine drive capacity [sts=%x]\n", i); - return; - } - /* return value from read capacity is last valid block, not nblocks */ - sc->sc_blks++; - printf(", %u %d byte blocks\n", sc->sc_blks, sc->sc_blksize); - if (sc->sc_blksize != DEV_BSIZE) { - for (i = sc->sc_blksize; i > DEV_BSIZE; i >>= 1) - ++sc->sc_bshift; - if (i != DEV_BSIZE) { - printf("%s: blksize not multiple of %d: cannot use\n", - sc->sc_dk.dk_dev.dv_xname, DEV_BSIZE); - return; - } - sc->sc_blks <<= sc->sc_bshift; - } - sc->sc_type = sa->sa_si.si_type; /* sufficient? */ - - sc->sc_dk.dk_driver = &sddkdriver; -#ifdef notyet - dk_establish(&sc->sc_dk); - /* READ DISK LABEL HERE, UNLESS REMOVABLE MEDIUM... NEEDS THOUGHT */ -#else - sc->sc_dk.dk_label.d_secsize = 512; /* XXX */ - sc->sc_dk.dk_bps = (3600/60) * 32 * 512;/* XXX */ - -#ifdef SUN_LABEL_HACK - sector = (caddr_t)malloc(sc->sc_blksize, M_DEVBUF, M_NOWAIT); - CDB10(&rd0)->cdb_lun_rel = sc->sc_unit.u_unit << 5; - i = (*sc->sc_unit.u_hbd->hd_icmd)(sc->sc_unit.u_hba, - sc->sc_unit.u_targ, &rd0, sector, sc->sc_blksize, B_READ); - if (i == STS_GOOD) { - printf("%s: <%s>\n", sc->sc_dk.dk_dev.dv_xname, - ((struct sun_disklabel *)sector)->sl_text); - if (sun_disklabel(sector, &sc->sc_dk.dk_label)) - sc->sc_flags |= SDF_ALIVE; - else - printf("%s: sun_disklabel fails\n", - sc->sc_dk.dk_dev.dv_xname); - } else - printf("%s: could not read sector 0 for disk label\n", - sc->sc_dk.dk_dev.dv_xname); - free(sector, M_DEVBUF); -#endif -#endif /* notyet */ -} - -/* - * Reset a disk, after a SCSI bus reset. - * - * XXX untested and probably incomplete/incorrect - */ -void -sdreset(u) - register struct unit *u; -{ - register struct sd_softc *sc = (struct sd_softc *)u->u_dev; - - printf(" %s", sc->sc_dk.dk_dev.dv_xname); - sc->sc_resets++; -} - -/* dev_t is short, must use prototype syntax */ -int -sdopen(dev_t dev, int flags, int ifmt, struct proc *p) -{ - register int unit = sdunit(dev); - register struct sd_softc *sc; - - if (unit >= sdcd.cd_ndevs || (sc = sdcd.cd_devs[unit]) == NULL) - return (ENXIO); - if ((sc->sc_flags & SDF_ALIVE) == 0 && suser(p->p_ucred, &p->p_acflag)) - return (ENXIO); - return (0); -} - -int -sdclose(dev_t dev, int flags, int ifmt, struct proc *p) -{ - register struct sd_softc *sc = sdcd.cd_devs[sdunit(dev)]; - - sc->sc_format_pid = 0; - return (0); -} - -/* - * This routine is called for partial block transfers and non-aligned - * transfers (the latter only being possible on devices with a block size - * larger than DEV_BSIZE). The operation is performed in three steps - * using a locally allocated buffer: - * 1. transfer any initial partial block - * 2. transfer full blocks - * 3. transfer any final partial block - */ -static void -sdlblkstrat(bp, bsize) - register struct buf *bp; - register int bsize; -{ - register int bn, resid, boff, count; - register caddr_t addr, cbuf; - struct buf *tbp; - - /* should probably use geteblk() here, but I fear consequences */ - cbuf = (caddr_t)malloc(bsize, M_DEVBUF, M_WAITOK); - tbp = (struct buf *)malloc(sizeof *tbp, M_DEVBUF, M_WAITOK); - bzero((caddr_t)tbp, sizeof *tbp); - tbp->b_proc = curproc; - tbp->b_dev = bp->b_dev; - bn = bp->b_blkno; - resid = bp->b_bcount; - addr = bp->b_un.b_addr; -#ifdef DEBUG - if (sddebug & SDB_PARTIAL) - printf("sdlblkstrat: bp %x flags %x bn %x resid %x addr %x\n", - bp, bp->b_flags, bn, resid, addr); -#endif - - while (resid > 0) { - boff = dbtob(bn) & (bsize - 1); - if (boff || resid < bsize) { - struct sd_softc *sc = sdcd.cd_devs[sdunit(bp->b_dev)]; - sc->sc_partials++; - count = min(resid, bsize - boff); - tbp->b_flags = B_BUSY | B_READ; - tbp->b_blkno = bn - btodb(boff); - tbp->b_un.b_addr = cbuf; - tbp->b_bcount = bsize; -#ifdef DEBUG - if (sddebug & SDB_PARTIAL) - printf(" readahead: bn %x cnt %x off %x addr %x\n", - tbp->b_blkno, count, boff, addr); -#endif - sdstrategy(tbp); - biowait(tbp); - if (tbp->b_flags & B_ERROR) { - bp->b_flags |= B_ERROR; - bp->b_error = tbp->b_error; - break; - } - if (bp->b_flags & B_READ) { - bcopy(&cbuf[boff], addr, count); - goto done; - } - bcopy(addr, &cbuf[boff], count); -#ifdef DEBUG - if (sddebug & SDB_PARTIAL) - printf(" writeback: bn %x cnt %x off %x addr %x\n", - tbp->b_blkno, count, boff, addr); -#endif - } else { - count = resid & ~(bsize - 1); - tbp->b_blkno = bn; - tbp->b_un.b_addr = addr; - tbp->b_bcount = count; -#ifdef DEBUG - if (sddebug & SDB_PARTIAL) - printf(" fulltrans: bn %x cnt %x addr %x\n", - tbp->b_blkno, count, addr); -#endif - } - tbp->b_flags = B_BUSY | (bp->b_flags & B_READ); - sdstrategy(tbp); - biowait(tbp); - if (tbp->b_flags & B_ERROR) { - bp->b_flags |= B_ERROR; - bp->b_error = tbp->b_error; - break; - } -done: - bn += btodb(count); - resid -= count; - addr += count; -#ifdef DEBUG - if (sddebug & SDB_PARTIAL) - printf(" done: bn %x resid %x addr %x\n", - bn, resid, addr); -#endif - } - free(cbuf, M_DEVBUF); - free((caddr_t)tbp, M_DEVBUF); - biodone(bp); -} - -/* - * Start a transfer on sc as described by bp - * (i.e., call hba or target start). - * If in format mode, we may not need dma. - */ -#define sdstart(sc, bp) { \ - SD_TRACE(T_START, sc, bp); \ - if ((sc)->sc_format_pid && legal_cmds[(sc)->sc_cmd.cdb_bytes[0]] > 0) \ - (*(sc)->sc_unit.u_start)((sc)->sc_unit.u_updev, \ - &(sc)->sc_unit.u_forw, (struct buf *)NULL, \ - sdigo, &(sc)->sc_dk.dk_dev); \ - else \ - (*(sc)->sc_unit.u_start)((sc)->sc_unit.u_updev, \ - &(sc)->sc_unit.u_forw, bp, sdgo, &(sc)->sc_dk.dk_dev); \ -} - -void -sdstrategy(bp) - register struct buf *bp; -{ - register struct sd_softc *sc = sdcd.cd_devs[sdunit(bp->b_dev)]; - register int s; - - if (sc->sc_format_pid) { - /* XXXXXXXXX SHOULD NOT COMPARE curproc IN HERE!?! */ - /* - * In format mode, only allow the owner to mess - * with the drive. Skip all the partition checks. - */ - if (sc->sc_format_pid != curproc->p_pid) { - bp->b_error = EPERM; - bp->b_flags |= B_ERROR; - biodone(bp); - return; - } - bp->b_cylin = 0; - } else { - register daddr_t bn = bp->b_blkno; - register int sz = howmany(bp->b_bcount, DEV_BSIZE); - register struct partition *p; - - /* - * Make sure transfer is within partition. - * If it starts at the end, return EOF; if - * it extends past the end, truncate it. - */ - p = &sc->sc_dk.dk_label.d_partitions[sdpart(bp->b_dev)]; - if ((unsigned)bn >= p->p_size) { - if ((unsigned)bn > p->p_size) { - bp->b_error = EINVAL; - bp->b_flags |= B_ERROR; - } else - bp->b_resid = bp->b_bcount; - biodone(bp); - return; - } - if (bn + sz > p->p_size) { - sz = p->p_size - bn; - bp->b_bcount = dbtob(sz); - } - /* - * Non-aligned or partial-block transfers handled specially. - * SHOULD THIS BE AT A HIGHER LEVEL? - */ - s = sc->sc_blksize - 1; - if ((dbtob(bn) & s) || (bp->b_bcount & s)) { - sdlblkstrat(bp, sc->sc_blksize); - return; - } - bp->b_cylin = (bn + p->p_offset) >> sc->sc_bshift; - } - - /* - * Transfer valid, or format mode. Queue the request - * on the drive, and maybe try to start it. - */ - s = splbio(); - disksort(&sc->sc_tab, bp); - if (sc->sc_tab.b_active == 0) { - sc->sc_tab.b_active = 1; - sdstart(sc, bp); - } - splx(s); -} - -int -sderror(sc, stat) - register struct sd_softc *sc; - register int stat; -{ - register struct scsi_sense *sn; - int retry = 0; - - sc->sc_sense.status = stat; - if ((stat & STS_MASK) == STS_CHECKCOND) { - sn = (struct scsi_sense *)sc->sc_sense.sense; - stat = scsi_request_sense(sc->sc_unit.u_hba, - sc->sc_unit.u_targ, sc->sc_unit.u_unit, - (caddr_t)sn, sizeof sc->sc_sense.sense); - sc->sc_sense.status = stat; /* ??? */ - if ((stat & STS_MASK) != STS_GOOD) { - printf("%s: sense failed, status %x\n", - sc->sc_dk.dk_dev.dv_xname, stat); - return (0); - } - printf("%s: scsi sense class %d, code %d", - sc->sc_dk.dk_dev.dv_xname, - SENSE_ECLASS(sn), SENSE_ECODE(sn)); - if (SENSE_ISXSENSE(sn) && XSENSE_ISSTD(sn)) { - int key; - - /* - * Standard extended sense: can examine sense key - * and (if valid) info. - */ - key = XSENSE_KEY(sn); - printf(", key %d", key); - if (XSENSE_IVALID(sn)) - printf(", blk %d", XSENSE_INFO(sn)); - /* no sense or recovered error, try again */ - if (key == 0 || key == 1) - retry = 1; - } - printf("\n"); - } - return (retry); -} - -/* - * sdigo is called from the hba driver when it has got the scsi bus - * for us, and we were doing a format op that did not need dma. - */ -void -sdigo(sc0, cdb) - struct device *sc0; - struct scsi_cdb *cdb; -{ - register struct sd_softc *sc = (struct sd_softc *)sc0; - register struct buf *bp = sc->sc_tab.b_actf; - register int stat; - - stat = (*sc->sc_unit.u_hbd->hd_icmd)(sc->sc_unit.u_hba, - sc->sc_unit.u_targ, &sc->sc_cmd, bp->b_un.b_addr, bp->b_bcount, - bp->b_flags & B_READ); - sc->sc_sense.status = stat; - if (stat & 0xfe) { /* XXX */ - (void) sderror(sc, stat); - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - } - /* - * Done with SCSI bus, before we `ought' to be. Release it. - */ - (*sc->sc_unit.u_rel)(sc->sc_unit.u_updev); - bp->b_resid = 0; - sc->sc_tab.b_errcnt = 0; - sc->sc_tab.b_actf = bp->b_actf; - biodone(bp); - if ((bp = sc->sc_tab.b_actf) == NULL) - sc->sc_tab.b_active = 0; - else - sdstart(sc, bp); -} - -/* - * sdgo is called from the hba driver or target code when it has - * allocated the scsi bus and DMA resources and target datapath for us. - */ -void -sdgo(sc0, cdb) - struct device *sc0; - register struct scsi_cdb *cdb; -{ - register struct sd_softc *sc = (struct sd_softc *)sc0; - register struct buf *bp = sc->sc_tab.b_actf; - register int n; - register unsigned int u; - - SD_TRACE(T_MKCDB, sc, bp); - if (sc->sc_format_pid) { - *cdb = sc->sc_cmd; - n = 0; - } else { - CDB10(cdb)->cdb_cmd = bp->b_flags & B_READ ? CMD_READ10 : - CMD_WRITE10; - CDB10(cdb)->cdb_lun_rel = sc->sc_unit.u_unit << 5; - u = bp->b_cylin; - CDB10(cdb)->cdb_lbah = u >> 24; - CDB10(cdb)->cdb_lbahm = u >> 16; - CDB10(cdb)->cdb_lbalm = u >> 8; - CDB10(cdb)->cdb_lbal = u; - CDB10(cdb)->cdb_xxx = 0; - n = sc->sc_blksize - 1; - u = (bp->b_bcount + n) >> (DEV_BSHIFT + sc->sc_bshift); - CDB10(cdb)->cdb_lenh = u >> 8; - CDB10(cdb)->cdb_lenl = u; - CDB10(cdb)->cdb_ctrl = 0; - n = (bp->b_bcount & n) != 0; -#ifdef DEBUG - if (n) - printf("%s: partial block xfer -- %x bytes\n", - sc->sc_dk.dk_dev.dv_xname, bp->b_bcount); -#endif - sc->sc_transfers++; - } - if ((*sc->sc_unit.u_go)(sc->sc_unit.u_updev, sc->sc_unit.u_targ, - sdintr, (void *)sc, bp, n) == 0) { -#ifdef notyet - sc->sc_dk.dk_busy = 1; - sc->sc_dk.dk_seek++; /* XXX */ - sc->sc_dk.dk_xfer++; - sc->sc_dk.dk_wds += bp->b_bcount >> 6; -#endif - return; - } - /* - * Some sort of nasty unrecoverable error: clobber the - * transfer. Call the bus release function first, though. - */ - (*sc->sc_unit.u_rel)(sc->sc_unit.u_updev); -#ifdef DEBUG - if (sddebug & SDB_ERROR) - printf("%s: sdgo: %s adr %d blk %d len %d ecnt %d\n", - sc->sc_dk.dk_dev.dv_xname, - bp->b_flags & B_READ? "read" : "write", - bp->b_un.b_addr, bp->b_cylin, bp->b_bcount, - sc->sc_tab.b_errcnt); -#endif - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - bp->b_resid = 0; - sc->sc_tab.b_errcnt = 0; - sc->sc_tab.b_actf = bp->b_actf; - biodone(bp); - if ((bp = sc->sc_tab.b_actf) == NULL) - sc->sc_tab.b_active = 0; - else - sdstart(sc, bp); -} - -/* - * A transfer finished (or, someday, disconnected). - * We are already off the target/hba queues. - * Restart this one for error recovery, or start the next, as appropriate. - */ -void -sdintr(sc0, stat, resid) - struct device *sc0; - int stat, resid; -{ - register struct sd_softc *sc = (struct sd_softc *)sc0; - register struct buf *bp = sc->sc_tab.b_actf; - int retry; - - if (bp == NULL) - panic("sdintr"); - SD_TRACE(T_INTR, sc, bp); -#ifdef notyet - sc->sc_dk.dk_busy = 0; -#endif - if ((stat & STS_MASK) != STS_GOOD) { -#ifdef DEBUG - if (sddebug & SDB_ERROR) - printf("%s: sdintr scsi status 0x%x resid %d\n", - sc->sc_dk.dk_dev.dv_xname, stat, resid); -#endif - retry = sderror(sc, stat); - if (retry && ++sc->sc_tab.b_errcnt <= SDRETRY) { - printf("%s: retry %d\n", - sc->sc_dk.dk_dev.dv_xname, sc->sc_tab.b_errcnt); - goto restart; - } - bp->b_flags |= B_ERROR; - bp->b_error = EIO; - } - bp->b_resid = resid; - sc->sc_tab.b_errcnt = 0; - sc->sc_tab.b_actf = bp->b_actf; - biodone(bp); - if ((bp = sc->sc_tab.b_actf) == NULL) - sc->sc_tab.b_active = 0; - else { -restart: - sdstart(sc, bp); - } -} - -int -sdioctl(dev_t dev, int cmd, register caddr_t data, int flag, struct proc *p) -{ - register struct sd_softc *sc = sdcd.cd_devs[sdunit(dev)]; -#ifdef COMPAT_SUNOS - int error; - - error = sun_dkioctl(&sc->sc_dk, cmd, data, sdpart(dev)); - if (error >= 0) - return (error); -#endif - switch (cmd) { - - case SDIOCSFORMAT: - /* take this device into or out of "format" mode */ - if (suser(p->p_ucred, &p->p_acflag)) - return (EPERM); - if (*(int *)data) { - if (sc->sc_format_pid) - return (EPERM); - sc->sc_format_pid = p->p_pid; - } else - sc->sc_format_pid = 0; - break; - - case SDIOCGFORMAT: - /* find out who has the device in format mode */ - *(int *)data = sc->sc_format_pid; - break; - - case SDIOCSCSICOMMAND: -#define cdb ((struct scsi_cdb *)data) - /* - * Save what user gave us as SCSI cdb to use with next - * read or write to the char device. Be sure to replace - * the lun field with the actual unit number. - */ - if (sc->sc_format_pid != p->p_pid) - return (EPERM); - if (legal_cmds[cdb->cdb_bytes[0]] == 0) - return (EINVAL); - sc->sc_cmd = *cdb; - sc->sc_cmd.cdb_bytes[1] = - (sc->sc_cmd.cdb_bytes[1] & ~(7 << 5)) | - (sc->sc_unit.u_unit << 5); -#undef cdb - break; - - case SDIOCSENSE: - /* - * return the SCSI sense data saved after the last - * operation that completed with "check condition" status. - */ - sc->sc_sense = *(struct scsi_fmt_sense *)data; - break; - - case DIOCGDINFO: - *(struct disklabel *)data = sc->sc_dk.dk_label; - break; - - case DIOCGPART: - ((struct partinfo *)data)->disklab = &sc->sc_dk.dk_label; - ((struct partinfo *)data)->part = - &sc->sc_dk.dk_label.d_partitions[sdpart(dev)]; - break; - - default: - return (ENOTTY); - } - return (0); -} - -int -sdsize(dev_t dev) -{ - register int unit = sdunit(dev); - register struct sd_softc *sc; - - if (unit >= sdcd.cd_ndevs || (sc = sdcd.cd_devs[unit]) == NULL || - (sc->sc_flags & SDF_ALIVE) == 0) - return (-1); - return (sc->sc_dk.dk_label.d_partitions[sdpart(dev)].p_size); -} - -/* - * Write `len' bytes from address `addr' to drive and partition in `dev', - * at block blkoff from the beginning of the partition. The address is - * either kernel virtual or physical (some machines may never use one or - * the other, but we need it in the protocol to stay machine-independent). - */ -int -sddump(dev_t dev, daddr_t blkoff, caddr_t addr, int len) -{ - register struct sd_softc *sc; - register struct partition *p; - register daddr_t bn, n, nblks; - register struct hba_softc *hba; - register int stat, unit; - struct scsi_cdb cdb; - - /* drive ok? */ - unit = sdunit(dev); - if (unit >= sdcd.cd_ndevs || (sc = sdcd.cd_devs[unit]) == NULL || - (sc->sc_flags & SDF_ALIVE) == 0) - return (ENXIO); - - /* blocks in range? */ - p = &sc->sc_dk.dk_label.d_partitions[sdpart(dev)]; - n = (len + sc->sc_blksize - 1) >> DEV_BSHIFT; - if (blkoff < 0 || blkoff >= p->p_size || blkoff + n > p->p_size) - return (EINVAL); - bn = blkoff + p->p_offset; - bn >>= sc->sc_bshift; - - /* scsi bus idle? */ - hba = sc->sc_unit.u_hba; - if (hba->hba_head) { - (*hba->hba_driver->hd_reset)(hba, 0); - printf("[reset %s] ", sc->sc_dk.dk_dev.dv_xname); - } - - CDB10(&cdb)->cdb_cmd = CMD_WRITE10; - CDB10(&cdb)->cdb_lun_rel = sc->sc_unit.u_unit << 5; - CDB10(&cdb)->cdb_xxx = 0; - CDB10(&cdb)->cdb_ctrl = 0; - -#define DUMP_MAX (32 * 1024) /* no more than 32k per write */ - for (;;) { - if ((n = len) > DUMP_MAX) - n = DUMP_MAX; - CDB10(&cdb)->cdb_lbah = bn >> 24; - CDB10(&cdb)->cdb_lbahm = bn >> 16; - CDB10(&cdb)->cdb_lbalm = bn >> 8; - CDB10(&cdb)->cdb_lbal = bn; - nblks = n >> (DEV_BSHIFT + sc->sc_bshift); - CDB10(&cdb)->cdb_lenh = nblks >> 8; - CDB10(&cdb)->cdb_lenl = nblks; - stat = hba->hba_driver->hd_dump(hba, sc->sc_unit.u_targ, - &cdb, addr, n); - if ((stat & STS_MASK) != STS_GOOD) { - printf("%s: scsi write error 0x%x\ndump ", - sc->sc_dk.dk_dev.dv_xname, stat); - return (EIO); - } - if ((len -= n) == 0) - return (0); - addr += n; - bn += nblks; - } -} diff --git a/sys/arch/sparc/scsi/sdtrace.h b/sys/arch/sparc/scsi/sdtrace.h deleted file mode 100644 index 1455af1cb1a2..000000000000 --- a/sys/arch/sparc/scsi/sdtrace.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratories. - * - * %sccs.include.redist.c% - * - * %W% (Berkeley) %G% - * - * from: Header: sdtrace.h,v 1.6 92/12/02 03:53:47 torek Exp (LBL) - * $Id: sdtrace.h,v 1.1 1993/10/27 17:48:44 deraadt Exp $ - */ - -/* - * SCSI disk command tracing - */ - -#if defined(SDTRACE) || !defined(KERNEL) -struct sdtrace { - struct timeval time; /* timestamp */ - u_int block; /* disk block */ - u_int bcount; /* # bytes transferred */ - u_char tcode; /* trace code */ - u_char target; /* target number */ - u_char unit; /* unit number on target */ - u_char read; /* read operation */ -}; - -#define T_START 0x01 -#define T_MKCDB 0x02 -#define T_INTR 0x03 -#endif - -#ifdef SDTRACE -/* Allow kernel config to override number of entries */ -#ifndef NSDOPBUF -#define NSDOPBUF 1024 -#endif - -struct sdtrace sdopbuf[NSDOPBUF]; -struct sdtrace *sdopptr = sdopbuf; -int nsdopbuf = NSDOPBUF; /* for sdtrace */ -u_long sdopcnt; - -#define SD_TRACE(code, sc, bp) { \ - if (++sdopptr >= &sdopbuf[NSDOPBUF]) \ - sdopptr = sdopbuf; \ - microtime(&sdopptr->time); \ - sdopptr->tcode = code; \ - sdopptr->read = bp->b_flags & B_READ; \ - sdopptr->block = bp->b_blkno; \ - sdopptr->bcount = bp->b_bcount; \ - sdopptr->target = sc->sc_unit.u_targ; \ - sdopptr->unit = sc->sc_unit.u_unit; \ - ++sdopcnt; \ -} -#else -#define SD_TRACE(code, sc, bp) { } -#endif diff --git a/sys/arch/sparc/scsi/sun_disklabel.c b/sys/arch/sparc/scsi/sun_disklabel.c deleted file mode 100644 index 9abae99d2feb..000000000000 --- a/sys/arch/sparc/scsi/sun_disklabel.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)sun_disklabel.c 8.1 (Berkeley) 6/11/93 - * - * from: Header: sun_disklabel.c,v 1.5 92/06/17 07:04:12 torek Exp - * $Id: sun_disklabel.c,v 1.2 1993/11/14 10:47:54 deraadt Exp $ - */ - -/* - * SunOS disk label code. - */ - -#include -#include -#include -#include -#include - -#include - -/* - * Take a sector (cp) containing a SunOS disk label and set lp to a BSD - * disk label. - */ -int -sun_disklabel(cp, lp) - register caddr_t cp; - register struct disklabel *lp; -{ - register u_short *sp; - register struct sun_disklabel *sl; - register int i, v; - - sp = (u_short *)(cp + sizeof(struct sun_disklabel)); - --sp; - v = 0; - while (sp >= (u_short *)cp) - v ^= *sp--; - if (v) - return (0); - sl = (struct sun_disklabel *)cp; - lp->d_magic = 0; /* denote as pseudo */ - lp->d_ncylinders = sl->sl_ncylinders; - lp->d_acylinders = sl->sl_acylinders; - v = (lp->d_ntracks = sl->sl_ntracks) * - (lp->d_nsectors = sl->sl_nsectors); - lp->d_secpercyl = v; - lp->d_npartitions = 8; - for (i = 0; i < 8; i++) { - lp->d_partitions[i].p_offset = - sl->sl_part[i].sdkp_cyloffset * v; - lp->d_partitions[i].p_size = sl->sl_part[i].sdkp_nsectors; - } - return (1); -} - -int -sun_dkioctl(dk, cmd, data, partition) - struct dkdevice *dk; - int cmd; - caddr_t data; - int partition; -{ - register struct partition *p; - - switch (cmd) { - - case DKIOCGGEOM: -#define geom ((struct sun_dkgeom *)data) - bzero(data, sizeof(*geom)); - geom->sdkc_ncylinders = dk->dk_label.d_ncylinders; - geom->sdkc_acylinders = dk->dk_label.d_acylinders; - geom->sdkc_ntracks = dk->dk_label.d_ntracks; - geom->sdkc_nsectors = dk->dk_label.d_nsectors; - geom->sdkc_interleave = dk->dk_label.d_interleave; - geom->sdkc_sparespercyl = dk->dk_label.d_sparespercyl; - geom->sdkc_rpm = dk->dk_label.d_rpm; - geom->sdkc_pcylinders = - dk->dk_label.d_ncylinders + dk->dk_label.d_acylinders; -#undef geom - break; - - case DKIOCINFO: - /* Homey don't do DKIOCINFO */ - bzero(data, sizeof(struct sun_dkctlr)); - break; - - case DKIOCGPART: - if (dk->dk_label.d_secpercyl == 0) - return (ERANGE); /* XXX */ - p = &dk->dk_label.d_partitions[partition]; - if (p->p_offset % dk->dk_label.d_secpercyl != 0) - return (ERANGE); /* XXX */ -#define part ((struct sun_dkpart *)data) - part->sdkp_cyloffset = p->p_offset / dk->dk_label.d_secpercyl; - part->sdkp_nsectors = p->p_size; -#undef part - break; - - default: - return (-1); - } - return (0); -} diff --git a/sys/arch/sparc/scsi/sun_disklabel.h b/sys/arch/sparc/scsi/sun_disklabel.h deleted file mode 100644 index ffa0b1b2c93a..000000000000 --- a/sys/arch/sparc/scsi/sun_disklabel.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)sun_disklabel.h 8.1 (Berkeley) 6/11/93 - * - * from: Header: sun_disklabel.h,v 1.4 92/06/17 07:04:13 torek Exp - * $Id: sun_disklabel.h,v 1.1 1993/11/14 10:47:13 deraadt Exp $ - */ - -/* - * SunOS disk label layout (only relevant portions discovered here). - */ - -#define SUN_DKMAGIC 55998 - -/* These are the guys that Sun's dkinfo needs... */ -#define DKIOCGGEOM _IOR('d', 2, struct sun_dkgeom) /* geometry info */ -#define DKIOCINFO _IOR('d', 8, struct sun_dkctlr) /* controller info */ -#define DKIOCGPART _IOR('d', 4, struct sun_dkpart) /* partition info */ - -/* geometry info */ -struct sun_dkgeom { - u_short sdkc_ncylinders; /* data cylinders */ - u_short sdkc_acylinders; /* alternate cylinders */ - u_short sdkc_xxx1; - u_short sdkc_ntracks; /* tracks per cylinder */ - u_short sdkc_xxx2; - u_short sdkc_nsectors; /* sectors per track */ - u_short sdkc_interleave; /* interleave factor */ - u_short sdkc_xxx3; - u_short sdkc_xxx4; - u_short sdkc_sparespercyl; /* spare sectors per cylinder */ - u_short sdkc_rpm; /* rotational speed */ - u_short sdkc_pcylinders; /* physical cylinders */ - u_short sdkc_xxx5[7]; -}; - -/* controller info */ -struct sun_dkctlr { - int sdkc_addr; /* controller address */ - short sdkc_unit; /* unit (slave) address */ - short sdkc_type; /* controller type */ - short sdkc_flags; /* flags */ -}; - -/* partition info */ -struct sun_dkpart { - long sdkp_cyloffset; /* starting cylinder */ - long sdkp_nsectors; /* number of sectors */ -}; - -struct sun_disklabel { /* total size = 512 bytes */ - char sl_text[128]; - char sl_xxx1[292]; - u_short sl_rpm; /* rotational speed */ - char sl_xxx2[2]; - u_short sl_sparespercyl; /* spare sectors per cylinder */ - char sl_xxx3[4]; - u_short sl_interleave; /* interleave factor */ - u_short sl_ncylinders; /* data cylinders */ - u_short sl_acylinders; /* alternate cylinders */ - u_short sl_ntracks; /* tracks per cylinder */ - u_short sl_nsectors; /* sectors per track */ - char sl_xxx4[4]; - struct sun_dkpart sl_part[8]; /* partition layout */ - u_short sl_magic; /* == SUN_DKMAGIC */ - u_short sl_cksum; /* xor checksum of all shorts */ -}; - -#ifdef KERNEL -/* reads sun label in sector at [cp..cp+511] and sets *lp to BSD label */ -int sun_disklabel __P((caddr_t, struct disklabel *)); /* true on success */ - -/* compatability dk ioctl's */ -int sun_dkioctl __P((struct dkdevice *, int, caddr_t, int)); -#endif diff --git a/sys/arch/sparc/scsi/tape.h b/sys/arch/sparc/scsi/tape.h deleted file mode 100644 index bf55a1ea05a9..000000000000 --- a/sys/arch/sparc/scsi/tape.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1992 The Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratories. - * - * %sccs.include.redist.c% - * - * %W% (Berkeley) %G% - * - * from: Header: tape.h,v 1.3 92/12/02 03:53:14 torek Exp (LBL) - * $Id: tape.h,v 1.1 1993/10/27 17:48:47 deraadt Exp $ - */ - -/* - * SCSI definitions for Sequential Access Devices (tapes). - * - * Commands defined in common headers (scsi.h or disktape.h) are omitted. - */ -#define CMD_REWIND 0x01 /* rewind */ -#define CMD_READ_BLOCK_LIMITS 0x05 /* read block limits */ -#define CMD_READ 0x08 /* read */ -#define CMD_WRITE 0x0a /* write */ -#define CMD_TRACK_SELECT 0x0b /* track select */ -#define CMD_READ_REVERSE 0x0f /* read reverse */ -#define CMD_WRITE_FILEMARK 0x10 /* write file marks */ -#define CMD_SPACE 0x11 /* space */ -#define CMD_VERIFY 0x13 /* verify */ -#define CMD_RBD 0x14 /* recover buffered data */ -#define CMD_RESERVE_UNIT 0x16 /* reserve unit */ -#define CMD_RELEASE_UNIT 0x17 /* release unit */ -/* CMD_COPY 0x18 copy (common to all scsi devs) */ -#define CMD_ERASE 0x19 /* erase */ -#define CMD_LOAD_UNLOAD 0x1b /* load/unload */ -#define CMD_PAMR 0x1e /* prevent/allow medium removal */ - -/* - * Structure of READ, WRITE, READ REVERSE, RECOVER BUFFERED DATA - * commands (i.e., the cdb). - * Also used for VERIFY commands. - */ -struct scsi_cdb_rw { - u_char cdb_cmd, /* 0x08 or 0x0a or 0x0f or 0x13 or 0x14 */ - cdb_lun_bf, /* LUN + reserved + bytecmp + fixed */ - cdb_lenh, /* transfer length (MSB) */ - cdb_lenm, /* transfer length */ - cdb_lenl, /* transfer length (LSB) */ - cdb_ctrl; /* control byte */ -}; -#define SCSI_RW_BYTECMP 0x02 /* byte compare flag if verify */ -#define SCSI_RW_FIXEDBLK 0x01 /* fixed block size for read/write */ - -/* - * Structure of a TRACK SELECT command. - */ -struct scsi_cdb_ts { - u_char cdb_cmd, /* 0x0b */ - cdb_lun_xxx, /* logical unit number + reserved */ - cdb_xxx1, /* reserved */ - cdb_xxx2, /* reserved */ - cdb_track, /* track value */ - cdb_ctrl; /* control byte */ -}; - -/* - * Structure of a WRITE FILEMARKS command. - */ -struct scsi_cdb_wfm { - u_char cdb_cmd, /* 0x0b */ - cdb_lun_xxx, /* logical unit number + reserved */ - cdb_nfh, /* number of filemarks (MSB) */ - cdb_nfm, /* number of filemarks */ - cdb_nfl, /* number of filemarks (LSB) */ - cdb_ctrl; /* control byte */ -}; - -/* - * Structure of a SPACE command. - */ -struct scsi_cdb_space { - u_char cdb_cmd, /* 0x0b */ - cdb_lun_code, /* LUN + reserved + 2-bit code */ - cdb_counth, /* count (MSB) */ - cdb_countm, /* count */ - cdb_countl, /* count (LSB) */ - cdb_ctrl; /* control byte */ -}; -#define SCSI_CMD_SPACE_BLOCKS 0 /* skip blocks */ -#define SCSI_CMD_SPACE_FMS 1 /* skip file marks */ -#define SCSI_CMD_SPACE_SFMS 2 /* skip sequential file marks */ -#define SCSI_CMD_SPACE_PEOD 3 /* skip to physical end of data */ - -/* - * Structure of an ERASE command. - */ -struct scsi_cdb_erase { - u_char cdb_cmd, /* 0x0b */ - cdb_lun_long, /* LUN + reserved + long-erase flag */ - cdb_xxx1, /* reserved */ - cdb_xxx2, /* reserved */ - cdb_xxx3, /* reserved */ - cdb_ctrl; /* control byte */ -}; - -/* - * Structure of a LOAD/UNLOAD command. - */ -struct scsi_cdb_lu { - u_char cdb_cmd, /* 0x1b */ - cdb_lun_immed, /* LUN + reserved + immediate flag */ - cdb_xxx1, /* reserved */ - cdb_xxx2, /* reserved */ - cdb_rl, /* reserved + retension flag + load flag */ - cdb_ctrl; /* control byte */ -}; -#define SCSI_LU_RL_RETEN 0x02 /* retension */ -#define SCSI_LU_RL_LOAD 0x01 /* load */ -#define SCSI_LU_RL_UNLOAD 0x00 /* unload (pseudo flag) */ diff --git a/sys/arch/sparc/sunos/sun_syscall.h b/sys/arch/sparc/sunos/sun_syscall.h deleted file mode 100644 index 1c2a65a6dfe7..000000000000 --- a/sys/arch/sparc/sunos/sun_syscall.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * System call numbers. - * - * DO NOT EDIT-- this file is automatically generated. - * created from $Id: sun_syscall.h,v 1.7 1993/11/20 03:09:03 deraadt Exp $ - */ - -#define SYS_syscall 0 -#define SYS_exit 1 -#define SYS_fork 2 -#define SYS_read 3 -#define SYS_write 4 -#define SYS_sun_open 5 -#define SYS_close 6 -#define SYS_sun_wait4 7 -#define SYS_sun_creat 8 -#define SYS_link 9 -#define SYS_unlink 10 -#define SYS_sun_execv 11 -#define SYS_chdir 12 - /* 13 is old sun_time */ -#define SYS_mknod 14 -#define SYS_chmod 15 -#define SYS_chown 16 -#define SYS_break 17 - /* 18 is old sun_stat */ -#define SYS_lseek 19 -#define SYS_getpid 20 - /* 21 is obsolete sun_old_mount */ - /* 23 is old setuid */ -#define SYS_getuid 24 - /* 25 is old sun_stime */ - /* 27 is old sun_alarm */ - /* 28 is old sun_fstat */ - /* 29 is old sun_pause */ - /* 30 is old sun_utime */ -#define SYS_access 33 - /* 34 is old sun_nice */ - /* 35 is old sun_ftime */ -#define SYS_sync 36 -#define SYS_kill 37 -#define SYS_stat 38 - /* 39 is old sun_setpgrp */ -#define SYS_lstat 40 -#define SYS_dup 41 -#define SYS_pipe 42 - /* 43 is old sun_times */ -#define SYS_profil 44 - /* 46 is old sun_setgid */ -#define SYS_getgid 47 - /* 48 is old sun_ssig */ -#define SYS_acct 51 -#define SYS_sun_mctl 53 -#define SYS_sun_ioctl 54 -#define SYS_reboot 55 - /* 56 is obsolete sun_owait3 */ -#define SYS_symlink 57 -#define SYS_readlink 58 -#define SYS_execve 59 -#define SYS_umask 60 -#define SYS_chroot 61 -#define SYS_fstat 62 -#define SYS_getpagesize 64 -#define SYS_sun_omsync 65 -#define SYS_vfork 66 - /* 67 is obsolete vread */ - /* 68 is obsolete vwrite */ -#define SYS_sbrk 69 -#define SYS_sstk 70 -#define SYS_mmap 71 -#define SYS_vadvise 72 -#define SYS_munmap 73 -#define SYS_mprotect 74 -#define SYS_madvise 75 - /* 76 is old vhangup */ - /* 77 is old vlimit */ -#define SYS_mincore 78 -#define SYS_getgroups 79 -#define SYS_setgroups 80 -#define SYS_getpgrp 81 -#define SYS_sun_setpgid 82 -#define SYS_setitimer 83 - /* 84 is old wait */ -#define SYS_swapon 85 -#define SYS_getitimer 86 -#define SYS_gethostname 87 -#define SYS_sethostname 88 -#define SYS_getdtablesize 89 -#define SYS_dup2 90 -#define SYS_fcntl 92 -#define SYS_select 93 -#define SYS_fsync 95 -#define SYS_setpriority 96 -#define SYS_socket 97 -#define SYS_connect 98 -#define SYS_oaccept 99 -#define SYS_getpriority 100 -#define SYS_osend 101 -#define SYS_orecv 102 -#define SYS_bind 104 -#define SYS_sun_setsockopt 105 -#define SYS_listen 106 - /* 107 is old vtimes */ -#define SYS_osigvec 108 -#define SYS_osigblock 109 -#define SYS_osigsetmask 110 -#define SYS_sigsuspend 111 -#define SYS_sigstack 112 -#define SYS_orecvmsg 113 -#define SYS_osendmsg 114 - /* 115 is obsolete vtrace */ -#define SYS_gettimeofday 116 -#define SYS_getrusage 117 -#define SYS_getsockopt 118 -#define SYS_readv 120 -#define SYS_writev 121 -#define SYS_settimeofday 122 -#define SYS_fchown 123 -#define SYS_fchmod 124 -#define SYS_orecvfrom 125 -#define SYS_osetreuid 126 -#define SYS_osetregid 127 -#define SYS_rename 128 -#define SYS_truncate 129 -#define SYS_ftruncate 130 -#define SYS_flock 131 -#define SYS_sendto 133 -#define SYS_shutdown 134 -#define SYS_socketpair 135 -#define SYS_mkdir 136 -#define SYS_rmdir 137 -#define SYS_utimes 138 -#define SYS_sigreturn 139 -#define SYS_adjtime 140 -#define SYS_ogetpeername 141 -#define SYS_gethostid 142 -#define SYS_getrlimit 144 -#define SYS_setrlimit 145 -#define SYS_okillpg 146 -#define SYS_ogetsockname 150 -#define SYS_getdirentries 156 -#define SYS_statfs 157 -#define SYS_fstatfs 158 -#define SYS_sun_unmount 159 -#define SYS_getdomainname 162 -#define SYS_setdomainname 163 -#define SYS_sun_mount 167 -#define SYS_semsys 169 -#define SYS_msgsys 170 -#define SYS_shmsys 171 -#define SYS_sun_auditsys 172 -#define SYS_sun_getdents 174 -#define SYS_setsid 175 -#define SYS_fchdir 176 -#define SYS_sun_fchroot 177 -#define SYS_sun_sigpending 183 -#define SYS_setpgid 185 -#define SYS_sun_uname 189 diff --git a/sys/arch/sparc/sunos/sun_syscalls.c b/sys/arch/sparc/sunos/sun_syscalls.c deleted file mode 100644 index 9db77f9d4e59..000000000000 --- a/sys/arch/sparc/sunos/sun_syscalls.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * System call names. - * - * DO NOT EDIT-- this file is automatically generated. - * created from $Id: sun_syscalls.c,v 1.7 1993/11/20 03:09:04 deraadt Exp $ - */ - -char *sun_syscallnames[] = { - "syscall", /* 0 = syscall */ - "exit", /* 1 = exit */ - "fork", /* 2 = fork */ - "read", /* 3 = read */ - "write", /* 4 = write */ - "sun_open", /* 5 = sun_open */ - "close", /* 6 = close */ - "sun_wait4", /* 7 = sun_wait4 */ - "sun_creat", /* 8 = sun_creat */ - "link", /* 9 = link */ - "unlink", /* 10 = unlink */ - "sun_execv", /* 11 = sun_execv */ - "chdir", /* 12 = chdir */ - "old.sun_time", /* 13 = old sun_time */ - "mknod", /* 14 = mknod */ - "chmod", /* 15 = chmod */ - "chown", /* 16 = chown */ - "break", /* 17 = break */ - "old.sun_stat", /* 18 = old sun_stat */ - "lseek", /* 19 = lseek */ - "getpid", /* 20 = getpid */ - "obs_sun_old_mount", /* 21 = obsolete sun_old_mount */ - "#22", /* 22 = System V umount */ - "old.setuid", /* 23 = old setuid */ - "getuid", /* 24 = getuid */ - "old.sun_stime", /* 25 = old sun_stime */ - "#26", /* 26 = sun_ptrace */ - "old.sun_alarm", /* 27 = old sun_alarm */ - "old.sun_fstat", /* 28 = old sun_fstat */ - "old.sun_pause", /* 29 = old sun_pause */ - "old.sun_utime", /* 30 = old sun_utime */ - "#31", /* 31 = was stty */ - "#32", /* 32 = was gtty */ - "access", /* 33 = access */ - "old.sun_nice", /* 34 = old sun_nice */ - "old.sun_ftime", /* 35 = old sun_ftime */ - "sync", /* 36 = sync */ - "kill", /* 37 = kill */ - "stat", /* 38 = stat */ - "old.sun_setpgrp", /* 39 = old sun_setpgrp */ - "lstat", /* 40 = lstat */ - "dup", /* 41 = dup */ - "pipe", /* 42 = pipe */ - "old.sun_times", /* 43 = old sun_times */ - "profil", /* 44 = profil */ - "#45", /* 45 = nosys */ - "old.sun_setgid", /* 46 = old sun_setgid */ - "getgid", /* 47 = getgid */ - "old.sun_ssig", /* 48 = old sun_ssig */ - "#49", /* 49 = reserved for USG */ - "#50", /* 50 = reserved for USG */ - "acct", /* 51 = acct */ - "#52", /* 52 = nosys */ - "sun_mctl", /* 53 = sun_mctl */ - "sun_ioctl", /* 54 = sun_ioctl */ - "reboot", /* 55 = reboot */ - "obs_sun_owait3", /* 56 = obsolete sun_owait3 */ - "symlink", /* 57 = symlink */ - "readlink", /* 58 = readlink */ - "execve", /* 59 = execve */ - "umask", /* 60 = umask */ - "chroot", /* 61 = chroot */ - "fstat", /* 62 = fstat */ - "#63", /* 63 = nosys */ - "getpagesize", /* 64 = getpagesize */ - "sun_omsync", /* 65 = sun_omsync */ - "vfork", /* 66 = vfork */ - "obs_vread", /* 67 = obsolete vread */ - "obs_vwrite", /* 68 = obsolete vwrite */ - "sbrk", /* 69 = sbrk */ - "sstk", /* 70 = sstk */ - "mmap", /* 71 = mmap */ - "vadvise", /* 72 = vadvise */ - "munmap", /* 73 = munmap */ - "mprotect", /* 74 = mprotect */ - "madvise", /* 75 = madvise */ - "old.vhangup", /* 76 = old vhangup */ - "old.vlimit", /* 77 = old vlimit */ - "mincore", /* 78 = mincore */ - "getgroups", /* 79 = getgroups */ - "setgroups", /* 80 = setgroups */ - "getpgrp", /* 81 = getpgrp */ - "sun_setpgid", /* 82 = sun_setpgid */ - "setitimer", /* 83 = setitimer */ - "old.wait", /* 84 = old wait */ - "swapon", /* 85 = swapon */ - "getitimer", /* 86 = getitimer */ - "gethostname", /* 87 = gethostname */ - "sethostname", /* 88 = sethostname */ - "getdtablesize", /* 89 = getdtablesize */ - "dup2", /* 90 = dup2 */ - "#91", /* 91 = getdopt */ - "fcntl", /* 92 = fcntl */ - "select", /* 93 = select */ - "#94", /* 94 = setdopt */ - "fsync", /* 95 = fsync */ - "setpriority", /* 96 = setpriority */ - "socket", /* 97 = socket */ - "connect", /* 98 = connect */ - "oaccept", /* 99 = oaccept */ - "getpriority", /* 100 = getpriority */ - "osend", /* 101 = osend */ - "orecv", /* 102 = orecv */ - "#103", /* 103 = old socketaddr */ - "bind", /* 104 = bind */ - "sun_setsockopt", /* 105 = sun_setsockopt */ - "listen", /* 106 = listen */ - "old.vtimes", /* 107 = old vtimes */ - "osigvec", /* 108 = osigvec */ - "osigblock", /* 109 = osigblock */ - "osigsetmask", /* 110 = osigsetmask */ - "sigsuspend", /* 111 = sigsuspend */ - "sigstack", /* 112 = sigstack */ - "orecvmsg", /* 113 = orecvmsg */ - "osendmsg", /* 114 = osendmsg */ - "obs_vtrace", /* 115 = obsolete vtrace */ - "gettimeofday", /* 116 = gettimeofday */ - "getrusage", /* 117 = getrusage */ - "getsockopt", /* 118 = getsockopt */ - "#119", /* 119 = nosys */ - "readv", /* 120 = readv */ - "writev", /* 121 = writev */ - "settimeofday", /* 122 = settimeofday */ - "fchown", /* 123 = fchown */ - "fchmod", /* 124 = fchmod */ - "orecvfrom", /* 125 = orecvfrom */ - "osetreuid", /* 126 = osetreuid */ - "osetregid", /* 127 = osetregid */ - "rename", /* 128 = rename */ - "truncate", /* 129 = truncate */ - "ftruncate", /* 130 = ftruncate */ - "flock", /* 131 = flock */ - "#132", /* 132 = nosys */ - "sendto", /* 133 = sendto */ - "shutdown", /* 134 = shutdown */ - "socketpair", /* 135 = socketpair */ - "mkdir", /* 136 = mkdir */ - "rmdir", /* 137 = rmdir */ - "utimes", /* 138 = utimes */ - "sigreturn", /* 139 = sigreturn */ - "adjtime", /* 140 = adjtime */ - "ogetpeername", /* 141 = ogetpeername */ - "gethostid", /* 142 = gethostid */ - "#143", /* 143 = old sethostid */ - "getrlimit", /* 144 = getrlimit */ - "setrlimit", /* 145 = setrlimit */ - "okillpg", /* 146 = okillpg */ - "#147", /* 147 = nosys */ - "#148", /* 148 = nosys */ - "#149", /* 149 = nosys */ - "ogetsockname", /* 150 = ogetsockname */ - "#151", /* 151 = getmsg */ - "#152", /* 152 = putmsg */ - "#153", /* 153 = poll */ - "#154", /* 154 = nosys */ - "#155", /* 155 = nosys */ - "getdirentries", /* 156 = getdirentries */ - "statfs", /* 157 = statfs */ - "fstatfs", /* 158 = fstatfs */ - "sun_unmount", /* 159 = sun_unmount */ - "#160", /* 160 = nosys */ - "#161", /* 161 = nosys */ - "getdomainname", /* 162 = getdomainname */ - "setdomainname", /* 163 = setdomainname */ - "#164", /* 164 = rtschedule */ - "#165", /* 165 = quotactl */ - "#166", /* 166 = exportfs */ - "sun_mount", /* 167 = sun_mount */ - "#168", /* 168 = ustat */ -#ifdef SYSVSEM - "semsys", /* 169 = semsys */ -#else - "#169", /* 169 = nosys */ -#endif -#ifdef SYSVMSG - "msgsys", /* 170 = msgsys */ -#else - "#170", /* 170 = nosys */ -#endif -#ifdef SYSVSHM - "shmsys", /* 171 = shmsys */ -#else - "#171", /* 171 = nosys */ -#endif - "sun_auditsys", /* 172 = sun_auditsys */ - "#173", /* 173 = rfssys */ - "sun_getdents", /* 174 = sun_getdents */ - "setsid", /* 175 = setsid */ - "fchdir", /* 176 = fchdir */ - "sun_fchroot", /* 177 = sun_fchroot */ - "#178", /* 178 = nosys */ - "#179", /* 179 = nosys */ - "#180", /* 180 = nosys */ - "#181", /* 181 = nosys */ - "#182", /* 182 = nosys */ - "sun_sigpending", /* 183 = sun_sigpending */ - "#184", /* 184 = nosys */ - "setpgid", /* 185 = setpgid */ - "#186", /* 186 = pathconf */ - "#187", /* 187 = fpathconf */ - "#188", /* 188 = sysconf */ - "sun_uname", /* 189 = sun_uname */ -}; diff --git a/sys/arch/sparc/sunos/sun_sysent.c b/sys/arch/sparc/sunos/sun_sysent.c deleted file mode 100644 index f56186cb52cc..000000000000 --- a/sys/arch/sparc/sunos/sun_sysent.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * System call switch table. - * - * DO NOT EDIT-- this file is automatically generated. - * created from $Id: sun_sysent.c,v 1.7 1993/11/20 03:09:05 deraadt Exp $ - */ - -#include -#include - -int nosys(); - -int nosys(); -int rexit(); -int fork(); -int read(); -int write(); -int sun_open(); -int close(); -int sun_wait4(); -int sun_creat(); -int link(); -int unlink(); -int sun_execv(); -int chdir(); -int mknod(); -int chmod(); -int chown(); -int obreak(); -int lseek(); -int getpid(); -int getuid(); -int saccess(); -int sync(); -int kill(); -int stat(); -int lstat(); -int dup(); -int pipe(); -int profil(); -int getgid(); -int sysacct(); -int sun_mctl(); -int sun_ioctl(); -int reboot(); -int symlink(); -int readlink(); -int execve(); -int umask(); -int chroot(); -int fstat(); -int getpagesize(); -int sun_omsync(); -int vfork(); -int sbrk(); -int sstk(); -int sun_mmap(); -int ovadvise(); -int munmap(); -int mprotect(); -int madvise(); -int mincore(); -int getgroups(); -int setgroups(); -int getpgrp(); -int sun_setpgid(); -int setitimer(); -int swapon(); -int getitimer(); -int gethostname(); -int sethostname(); -int getdtablesize(); -int dup2(); -int fcntl(); -int select(); -int fsync(); -int setpriority(); -int socket(); -int connect(); -int oaccept(); -int getpriority(); -int osend(); -int orecv(); -int bind(); -int sun_setsockopt(); -int listen(); -int osigvec(); -int osigblock(); -int osigsetmask(); -int sigsuspend(); -int sigstack(); -int orecvmsg(); -int osendmsg(); -int gettimeofday(); -int getrusage(); -int getsockopt(); -int readv(); -int writev(); -int settimeofday(); -int fchown(); -int fchmod(); -int orecvfrom(); -int osetreuid(); -int osetregid(); -int rename(); -int truncate(); -int ftruncate(); -int flock(); -int sendto(); -int shutdown(); -int socketpair(); -int mkdir(); -int rmdir(); -int utimes(); -int sigreturn(); -int adjtime(); -int ogetpeername(); -int gethostid(); -int getrlimit(); -int setrlimit(); -int okillpg(); -int ogetsockname(); -int getdirentries(); -int statfs(); -int fstatfs(); -int sun_unmount(); -int getdomainname(); -int setdomainname(); -int sun_mount(); -#ifdef SYSVSEM -int semsys(); -#else -#endif -#ifdef SYSVMSG -int msgsys(); -#else -#endif -#ifdef SYSVSHM -int shmsys(); -#else -#endif -int sun_auditsys(); -int sun_getdents(); -int setsid(); -int fchdir(); -int sun_fchroot(); -int sun_sigpending(); -int setpgid(); -int sun_uname(); - -#ifdef XXX_UNUSED -#define compat(n, name) n, __CONCAT(o,name) - -int osun_time(); -int osun_stat(); -int osetuid(); -int osun_stime(); -int osun_alarm(); -int osun_fstat(); -int osun_pause(); -int osun_utime(); -int osun_nice(); -int osun_ftime(); -int osun_setpgrp(); -int osun_times(); -int osun_setgid(); -int osun_ssig(); -int ovhangup(); -int ovlimit(); -int owait(); -int ovtimes(); -#ifdef SYSVSEM -#else -#endif -#ifdef SYSVMSG -#else -#endif -#ifdef SYSVSHM -#else -#endif - -#else /* XXX_UNUSED */ -#define compat(n, name) 0, nosys -#endif /* XXX_UNUSED */ - -struct sysent sun_sysent[] = { - { 0, nosys }, /* 0 = syscall */ - { 1, rexit }, /* 1 = exit */ - { 0, fork }, /* 2 = fork */ - { 3, read }, /* 3 = read */ - { 3, write }, /* 4 = write */ - { 3, sun_open }, /* 5 = sun_open */ - { 1, close }, /* 6 = close */ - { 4, sun_wait4 }, /* 7 = sun_wait4 */ - { 2, sun_creat }, /* 8 = sun_creat */ - { 2, link }, /* 9 = link */ - { 1, unlink }, /* 10 = unlink */ - { 2, sun_execv }, /* 11 = sun_execv */ - { 1, chdir }, /* 12 = chdir */ - { compat(0,sun_time) }, /* 13 = old sun_time */ - { 3, mknod }, /* 14 = mknod */ - { 2, chmod }, /* 15 = chmod */ - { 3, chown }, /* 16 = chown */ - { 1, obreak }, /* 17 = break */ - { compat(2,sun_stat) }, /* 18 = old sun_stat */ - { 3, lseek }, /* 19 = lseek */ - { 0, getpid }, /* 20 = getpid */ - { 0, nosys }, /* 21 = obsolete sun_old_mount */ - { 0, nosys }, /* 22 = System V umount */ - { compat(1,setuid) }, /* 23 = old setuid */ - { 0, getuid }, /* 24 = getuid */ - { compat(1,sun_stime) }, /* 25 = old sun_stime */ - { 0, nosys }, /* 26 = sun_ptrace */ - { compat(1,sun_alarm) }, /* 27 = old sun_alarm */ - { compat(1,sun_fstat) }, /* 28 = old sun_fstat */ - { compat(0,sun_pause) }, /* 29 = old sun_pause */ - { compat(2,sun_utime) }, /* 30 = old sun_utime */ - { 0, nosys }, /* 31 = was stty */ - { 0, nosys }, /* 32 = was gtty */ - { 2, saccess }, /* 33 = access */ - { compat(1,sun_nice) }, /* 34 = old sun_nice */ - { compat(1,sun_ftime) }, /* 35 = old sun_ftime */ - { 0, sync }, /* 36 = sync */ - { 2, kill }, /* 37 = kill */ - { 2, stat }, /* 38 = stat */ - { compat(2,sun_setpgrp) }, /* 39 = old sun_setpgrp */ - { 2, lstat }, /* 40 = lstat */ - { 2, dup }, /* 41 = dup */ - { 0, pipe }, /* 42 = pipe */ - { compat(1,sun_times) }, /* 43 = old sun_times */ - { 4, profil }, /* 44 = profil */ - { 0, nosys }, /* 45 = nosys */ - { compat(1,sun_setgid) }, /* 46 = old sun_setgid */ - { 0, getgid }, /* 47 = getgid */ - { compat(2,sun_ssig) }, /* 48 = old sun_ssig */ - { 0, nosys }, /* 49 = reserved for USG */ - { 0, nosys }, /* 50 = reserved for USG */ - { 1, sysacct }, /* 51 = acct */ - { 0, nosys }, /* 52 = nosys */ - { 4, sun_mctl }, /* 53 = sun_mctl */ - { 3, sun_ioctl }, /* 54 = sun_ioctl */ - { 2, reboot }, /* 55 = reboot */ - { 0, nosys }, /* 56 = obsolete sun_owait3 */ - { 2, symlink }, /* 57 = symlink */ - { 3, readlink }, /* 58 = readlink */ - { 3, execve }, /* 59 = execve */ - { 1, umask }, /* 60 = umask */ - { 1, chroot }, /* 61 = chroot */ - { 2, fstat }, /* 62 = fstat */ - { 0, nosys }, /* 63 = nosys */ - { 0, getpagesize }, /* 64 = getpagesize */ - { 3, sun_omsync }, /* 65 = sun_omsync */ - { 0, vfork }, /* 66 = vfork */ - { 0, nosys }, /* 67 = obsolete vread */ - { 0, nosys }, /* 68 = obsolete vwrite */ - { 1, sbrk }, /* 69 = sbrk */ - { 1, sstk }, /* 70 = sstk */ - { 6, sun_mmap }, /* 71 = mmap */ - { 1, ovadvise }, /* 72 = vadvise */ - { 2, munmap }, /* 73 = munmap */ - { 3, mprotect }, /* 74 = mprotect */ - { 3, madvise }, /* 75 = madvise */ - { compat(0,vhangup) }, /* 76 = old vhangup */ - { compat(0,vlimit) }, /* 77 = old vlimit */ - { 3, mincore }, /* 78 = mincore */ - { 2, getgroups }, /* 79 = getgroups */ - { 2, setgroups }, /* 80 = setgroups */ - { 1, getpgrp }, /* 81 = getpgrp */ - { 2, sun_setpgid }, /* 82 = sun_setpgid */ - { 3, setitimer }, /* 83 = setitimer */ - { compat(0,wait) }, /* 84 = old wait */ - { 1, swapon }, /* 85 = swapon */ - { 2, getitimer }, /* 86 = getitimer */ - { 2, gethostname }, /* 87 = gethostname */ - { 2, sethostname }, /* 88 = sethostname */ - { 0, getdtablesize }, /* 89 = getdtablesize */ - { 2, dup2 }, /* 90 = dup2 */ - { 0, nosys }, /* 91 = getdopt */ - { 3, fcntl }, /* 92 = fcntl */ - { 5, select }, /* 93 = select */ - { 0, nosys }, /* 94 = setdopt */ - { 1, fsync }, /* 95 = fsync */ - { 3, setpriority }, /* 96 = setpriority */ - { 3, socket }, /* 97 = socket */ - { 3, connect }, /* 98 = connect */ - { 3, oaccept }, /* 99 = oaccept */ - { 2, getpriority }, /* 100 = getpriority */ - { 4, osend }, /* 101 = osend */ - { 4, orecv }, /* 102 = orecv */ - { 0, nosys }, /* 103 = old socketaddr */ - { 3, bind }, /* 104 = bind */ - { 5, sun_setsockopt }, /* 105 = sun_setsockopt */ - { 2, listen }, /* 106 = listen */ - { compat(0,vtimes) }, /* 107 = old vtimes */ - { 3, osigvec }, /* 108 = osigvec */ - { 1, osigblock }, /* 109 = osigblock */ - { 1, osigsetmask }, /* 110 = osigsetmask */ - { 1, sigsuspend }, /* 111 = sigsuspend */ - { 2, sigstack }, /* 112 = sigstack */ - { 3, orecvmsg }, /* 113 = orecvmsg */ - { 3, osendmsg }, /* 114 = osendmsg */ - { 0, nosys }, /* 115 = obsolete vtrace */ - { 2, gettimeofday }, /* 116 = gettimeofday */ - { 2, getrusage }, /* 117 = getrusage */ - { 5, getsockopt }, /* 118 = getsockopt */ - { 0, nosys }, /* 119 = nosys */ - { 3, readv }, /* 120 = readv */ - { 3, writev }, /* 121 = writev */ - { 2, settimeofday }, /* 122 = settimeofday */ - { 3, fchown }, /* 123 = fchown */ - { 2, fchmod }, /* 124 = fchmod */ - { 6, orecvfrom }, /* 125 = orecvfrom */ - { 2, osetreuid }, /* 126 = osetreuid */ - { 2, osetregid }, /* 127 = osetregid */ - { 2, rename }, /* 128 = rename */ - { 2, truncate }, /* 129 = truncate */ - { 2, ftruncate }, /* 130 = ftruncate */ - { 2, flock }, /* 131 = flock */ - { 0, nosys }, /* 132 = nosys */ - { 6, sendto }, /* 133 = sendto */ - { 2, shutdown }, /* 134 = shutdown */ - { 5, socketpair }, /* 135 = socketpair */ - { 2, mkdir }, /* 136 = mkdir */ - { 1, rmdir }, /* 137 = rmdir */ - { 2, utimes }, /* 138 = utimes */ - { 1, sigreturn }, /* 139 = sigreturn */ - { 2, adjtime }, /* 140 = adjtime */ - { 3, ogetpeername }, /* 141 = ogetpeername */ - { 0, gethostid }, /* 142 = gethostid */ - { 0, nosys }, /* 143 = old sethostid */ - { 2, getrlimit }, /* 144 = getrlimit */ - { 2, setrlimit }, /* 145 = setrlimit */ - { 2, okillpg }, /* 146 = okillpg */ - { 0, nosys }, /* 147 = nosys */ - { 0, nosys }, /* 148 = nosys */ - { 0, nosys }, /* 149 = nosys */ - { 3, ogetsockname }, /* 150 = ogetsockname */ - { 0, nosys }, /* 151 = getmsg */ - { 0, nosys }, /* 152 = putmsg */ - { 0, nosys }, /* 153 = poll */ - { 0, nosys }, /* 154 = nosys */ - { 0, nosys }, /* 155 = nosys */ - { 4, getdirentries }, /* 156 = getdirentries */ - { 2, statfs }, /* 157 = statfs */ - { 2, fstatfs }, /* 158 = fstatfs */ - { 1, sun_unmount }, /* 159 = sun_unmount */ - { 0, nosys }, /* 160 = nosys */ - { 0, nosys }, /* 161 = nosys */ - { 2, getdomainname }, /* 162 = getdomainname */ - { 2, setdomainname }, /* 163 = setdomainname */ - { 0, nosys }, /* 164 = rtschedule */ - { 0, nosys }, /* 165 = quotactl */ - { 0, nosys }, /* 166 = exportfs */ - { 4, sun_mount }, /* 167 = sun_mount */ - { 0, nosys }, /* 168 = ustat */ -#ifdef SYSVSEM - { 5, semsys }, /* 169 = semsys */ -#else - { 0, nosys }, /* 169 = nosys */ -#endif -#ifdef SYSVMSG - { 6, msgsys }, /* 170 = msgsys */ -#else - { 0, nosys }, /* 170 = nosys */ -#endif -#ifdef SYSVSHM - { 4, shmsys }, /* 171 = shmsys */ -#else - { 0, nosys }, /* 171 = nosys */ -#endif - { 4, sun_auditsys }, /* 172 = sun_auditsys */ - { 0, nosys }, /* 173 = rfssys */ - { 3, sun_getdents }, /* 174 = sun_getdents */ - { 1, setsid }, /* 175 = setsid */ - { 1, fchdir }, /* 176 = fchdir */ - { 1, sun_fchroot }, /* 177 = sun_fchroot */ - { 0, nosys }, /* 178 = nosys */ - { 0, nosys }, /* 179 = nosys */ - { 0, nosys }, /* 180 = nosys */ - { 0, nosys }, /* 181 = nosys */ - { 0, nosys }, /* 182 = nosys */ - { 1, sun_sigpending }, /* 183 = sun_sigpending */ - { 0, nosys }, /* 184 = nosys */ - { 2, setpgid }, /* 185 = setpgid */ - { 0, nosys }, /* 186 = pathconf */ - { 0, nosys }, /* 187 = fpathconf */ - { 0, nosys }, /* 188 = sysconf */ - { 1, sun_uname }, /* 189 = sun_uname */ -}; - -int nsun_sysent = sizeof(sun_sysent) / sizeof(sun_sysent[0]); diff --git a/sys/arch/sparc/sunos/syscalls.master b/sys/arch/sparc/sunos/syscalls.master deleted file mode 100644 index 67049c0eb1be..000000000000 --- a/sys/arch/sparc/sunos/syscalls.master +++ /dev/null @@ -1,224 +0,0 @@ - $Id: syscalls.master,v 1.7 1993/11/20 03:01:58 deraadt Exp $ -; from: @(#)syscalls.master 8.1 (Berkeley) 7/19/93 -; System call name/number master file (or rather, slave, from SunOS). -; Processed to created sun_sysent.c, sun_syscalls.c and sun_syscall.h. - -; Columns: number type nargs name altname/comments -; number system call number, must be in order -; type one of STD, OBSOL, UNIMPL, COMPAT -; nargs number of arguments -; name name of syscall routine -; altname name of system call if different -; for UNIMPL/OBSOL, name continues with comments - -; types: -; STD always included -; COMPAT included on COMPAT #ifdef -; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h -; OBSOL obsolete, not included in system, only specifies name -; UNIMPL not implemented, placeholder only - -; #ifdef's, etc. may be included, and are copied to the output files. - -0 STD 0 nosys syscall -1 STD 1 rexit exit -2 STD 0 fork -3 STD 3 read -4 STD 3 write -5 STD 3 sun_open -6 STD 1 close -7 STD 4 sun_wait4 -8 STD 2 sun_creat -9 STD 2 link -10 STD 1 unlink -11 STD 2 sun_execv -12 STD 1 chdir -13 COMPAT 0 sun_time -14 STD 3 mknod -15 STD 2 chmod -16 STD 3 chown -17 STD 1 obreak break -18 COMPAT 2 sun_stat -19 STD 3 lseek -20 STD 0 getpid -21 OBSOL 1 sun_old_mount -22 UNIMPL 1 System V umount -23 COMPAT 1 setuid -24 STD 0 getuid -25 COMPAT 1 sun_stime -26 UNIMPL 5 sun_ptrace -27 COMPAT 1 sun_alarm -28 COMPAT 1 sun_fstat -29 COMPAT 0 sun_pause -30 COMPAT 2 sun_utime -31 UNIMPL 0 was stty -32 UNIMPL 0 was gtty -33 STD 2 saccess access -34 COMPAT 1 sun_nice -35 COMPAT 1 sun_ftime -36 STD 0 sync -37 STD 2 kill -38 STD 2 stat -39 COMPAT 2 sun_setpgrp -40 STD 2 lstat -41 STD 2 dup -42 STD 0 pipe -43 COMPAT 1 sun_times -44 STD 4 profil -45 UNIMPL 0 nosys -46 COMPAT 1 sun_setgid -47 STD 0 getgid -48 COMPAT 2 sun_ssig -49 UNIMPL 0 reserved for USG -50 UNIMPL 0 reserved for USG -51 STD 1 sysacct acct -52 UNIMPL 0 nosys -53 STD 4 sun_mctl -54 STD 3 sun_ioctl -55 STD 2 reboot -56 OBSOL 3 sun_owait3 -57 STD 2 symlink -58 STD 3 readlink -59 STD 3 execve -60 STD 1 umask -61 STD 1 chroot -62 STD 2 fstat -63 UNIMPL 0 nosys -64 STD 0 getpagesize -65 STD 3 sun_omsync -66 STD 0 vfork -67 OBSOL 0 vread -68 OBSOL 0 vwrite -69 STD 1 sbrk -70 STD 1 sstk -71 STD 6 sun_mmap mmap -72 STD 1 ovadvise vadvise -73 STD 2 munmap -74 STD 3 mprotect -75 STD 3 madvise -76 COMPAT 0 vhangup -77 COMPAT 0 vlimit -78 STD 3 mincore -79 STD 2 getgroups -80 STD 2 setgroups -81 STD 1 getpgrp -82 STD 2 sun_setpgid -83 STD 3 setitimer -84 COMPAT 0 wait -85 STD 1 swapon -86 STD 2 getitimer -87 STD 2 gethostname -88 STD 2 sethostname -89 STD 0 getdtablesize -90 STD 2 dup2 -91 UNIMPL 2 getdopt -92 STD 3 fcntl -93 STD 5 select -94 UNIMPL 2 setdopt -95 STD 1 fsync -96 STD 3 setpriority -97 STD 3 socket -98 STD 3 connect -99 STD 3 oaccept -100 STD 2 getpriority -101 STD 4 osend -102 STD 4 orecv -103 UNIMPL 0 old socketaddr -104 STD 3 bind -105 STD 5 sun_setsockopt -106 STD 2 listen -107 COMPAT 0 vtimes -108 STD 3 osigvec -109 STD 1 osigblock -110 STD 1 osigsetmask -111 STD 1 sigsuspend -112 STD 2 sigstack -113 STD 3 orecvmsg -114 STD 3 osendmsg -115 OBSOL 3 vtrace -116 STD 2 gettimeofday -117 STD 2 getrusage -118 STD 5 getsockopt -119 UNIMPL 0 nosys -120 STD 3 readv -121 STD 3 writev -122 STD 2 settimeofday -123 STD 3 fchown -124 STD 2 fchmod -125 STD 6 orecvfrom -126 STD 2 osetreuid -127 STD 2 osetregid -128 STD 2 rename -129 STD 2 truncate -130 STD 2 ftruncate -131 STD 2 flock -132 UNIMPL 0 nosys -133 STD 6 sendto -134 STD 2 shutdown -135 STD 5 socketpair -136 STD 2 mkdir -137 STD 1 rmdir -138 STD 2 utimes -139 STD 1 sigreturn -140 STD 2 adjtime -141 STD 3 ogetpeername -142 STD 0 gethostid -143 UNIMPL 1 old sethostid -144 STD 2 getrlimit -145 STD 2 setrlimit -146 STD 2 okillpg -147 UNIMPL 0 nosys -148 UNIMPL 0 nosys -149 UNIMPL 0 nosys -150 STD 3 ogetsockname -151 UNIMPL 4 getmsg -152 UNIMPL 4 putmsg -153 UNIMPL 3 poll -154 UNIMPL 0 nosys -155 UNIMPL 0 nosys -156 STD 4 getdirentries -157 STD 2 statfs -158 STD 2 fstatfs -159 STD 1 sun_unmount -160 UNIMPL 0 nosys -161 UNIMPL 0 nosys -162 STD 2 getdomainname -163 STD 2 setdomainname -164 UNIMPL 5 rtschedule -165 UNIMPL 4 quotactl -166 UNIMPL 2 exportfs -167 STD 4 sun_mount -168 UNIMPL 2 ustat -#ifdef SYSVSEM -169 STD 5 semsys -#else -169 UNIMPL 0 nosys -#endif -#ifdef SYSVMSG -170 STD 6 msgsys -#else -170 UNIMPL 0 nosys -#endif -#ifdef SYSVSHM -171 STD 4 shmsys -#else -171 UNIMPL 0 nosys -#endif -172 STD 4 sun_auditsys -173 UNIMPL 5 rfssys -174 STD 3 sun_getdents -175 STD 1 setsid -176 STD 1 fchdir -177 STD 1 sun_fchroot -178 UNIMPL 0 nosys -179 UNIMPL 0 nosys -180 UNIMPL 0 nosys -181 UNIMPL 0 nosys -182 UNIMPL 0 nosys -183 STD 1 sun_sigpending -184 UNIMPL 0 nosys -185 STD 2 setpgid -186 UNIMPL 2 pathconf -187 UNIMPL 2 fpathconf -188 UNIMPL 1 sysconf -189 STD 1 sun_uname diff --git a/sys/boot/bootparam.c b/sys/boot/bootparam.c deleted file mode 100644 index 3b320f0139c6..000000000000 --- a/sys/boot/bootparam.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1993 Adam Glass - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Adam Glass. - * 4. The name of the Author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Header: /cvsroot/src/sys/boot/Attic/bootparam.c,v 1.1 1993/10/12 06:02:23 glass Exp $ - */ - -#include "netboot.h" -#include "config.h" diff --git a/sys/boot/exec.c b/sys/boot/exec.c deleted file mode 100644 index a68d25b22669..000000000000 --- a/sys/boot/exec.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 1993 Adam Glass - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Adam Glass. - * 4. The name of the Author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Header: /cvsroot/src/sys/boot/Attic/exec.c,v 1.1 1993/10/12 06:02:25 glass Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include "netboot.h" -#include "config.h" -#include "netif.h" -#include "exec_var.h" - -char *kern_names[] = { - "netbsd", "onetbsd", "netbsd.old", - MACHINE "bsd", "o" MACHINE "bsd", MACHINE "bsd.old" - "vmunix", "ovmunix", "vmunix.old", NULL -}; - -void nfs_load_image(desc, image, ev) - struct iodesc *desc; - char *image; - struct exec_var *ev; -{ - u_long t; - - t = gettenths(); - printf("%s: ", image); - readseg(desc, ev->text_info.file_offset, - ev->text_info.segment_size, ev->text_info.segment_va); - printf("%d", ev->text_info.segment_size); - readseg(desc, ev->data_info.file_offset, - ev->data_info.segment_size, ev->data_info.segment_va); - printf("+%d", ev->data_info.segment_size); - printf("+%d", ev->bss_info.segment_size); - t = gettenths() - t; - printf(" [%d.%d seconds]\n", t/10, t%10); -} - -unsigned int nfs_load(desc, nfsdp, image) - struct iodesc *desc; - struct nfs_diskless **nfsdp; - char *image; -{ - struct exec_var ev; - - /* get fundamental parameters */ - if (machdep_exec_override(desc, &ev)) - if (netbsd_exec(desc, &ev)) - if (machdep_exec(desc, &ev)) - panic("nfs_load: unable to understand image"); - - machdep_exec_setup(&ev); - - nfs_load_image(desc, image, &ev); - - if (ev.nfs_disklessp) - *nfsdp = (struct nfs_diskless *) ev.nfs_disklessp; - return ev.real_entry_point; -} - -int netbsd_exec_compute(exec, ev) - struct exec exec; - struct exec_var *ev; -{ - bzero(ev, sizeof(*ev)); - - ev->text_info.file_offset = N_TXTOFF(exec); - ev->text_info.segment_size = exec.a_text; - ev->text_info.segment_addr = N_TXTADDR(exec) + exec.a_entry; - - ev->data_info.file_offset = N_DATOFF(exec); - ev->data_info.segment_size = exec.a_data; - ev->data_info.segment_addr = N_DATADDR(exec) + exec.a_entry; - - ev->bss_info.file_offset = 0; - ev->bss_info.segment_size = exec.a_bss; - ev->bss_info.segment_addr = N_DATADDR(exec)+exec.a_data + exec.a_entry; - - ev->entry_point = exec.a_entry; - - return 0; -} -int netbsd_exec(desc, ev) - struct iodesc *desc; - struct exec_var *ev; -{ - int cc, error; - u_long midmag, magic; - u_short mid; - struct exec exec; - - cc = readdata(desc, 0, &exec, sizeof(exec)); - - if (cc != sizeof(exec)) - panic("netbsd_exec: image appears truncated\n"); - if (cc < 0) - panic("netbsd_exec: bad exec read\n"); - if (N_GETMID(exec) != MID_MACHINE) { - error = 1; - goto failed; - } - if (N_BADMAG(exec)) { - error = 1; - goto failed; - } - error = netbsd_exec_compute(exec, ev); - failed: - if (error) - printf("netbsd_exec: bad exec? code %d\n", error); - return error; -} - -void nfs_exec(desc, kernel_override) - struct iodesc *desc; - char *kernel_override; -{ - time_t tenths; - char *image; - u_long ftype, bytes; - u_char image_fh[NFS_FHSIZE]; - struct nfs_diskless *nfsd; - unsigned int call_addr; - - nfsd = NULL; - image = NULL; - - if (kernel_override) { - image = kernel_override; - /* Get image file handle and size */ - if (lookupfh(desc, image, image_fh, NULL, &bytes, &ftype) < 0) - panic("nfs_exec: lookup failed %s: %s", image, strerror(errno)); - if (ftype != NFREG) - panic("nfs_exec: bad image ftype %d", ftype); - } - else { - int i; - - for (i = 0; kern_names[i]; i++) { - if (lookupfh(desc, kern_names[i], image_fh, NULL, - &bytes, &ftype) < 0) - continue; - if (ftype != NFREG) - panic("nfs_exec: %s, bad image ftype %d", - kern_names[i], ftype); - image = kern_names[i]; - break; - } - if (!image) - panic("nfs_exec: couldn't find kernel"); - } - printf("nfs_exec: %s\n", image); - desc->fh = image_fh; - call_addr = nfs_load(desc, &nfsd, image); - -#if 0 - if (nfsd) - nfs_diskless_munge(nfsd); -#endif - /* Now we're ready to fill in the nfs_diskless struct */ -#if 0 - if (nfsd) - diskless_setup(desc, (struct nfs_diskless_v1 *)sym); -#endif -} diff --git a/sys/boot/exec_var.h b/sys/boot/exec_var.h deleted file mode 100644 index 6e66e370d684..000000000000 --- a/sys/boot/exec_var.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1993 Adam Glass - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Adam Glass. - * 4. The name of the Author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Header: /cvsroot/src/sys/boot/Attic/exec_var.h,v 1.1 1993/10/12 06:02:26 glass Exp $ - */ - -struct exec_var_addr { - unsigned int file_offset; - unsigned int segment_size; - unsigned int segment_addr; - unsigned int segment_va; -}; - -typedef struct exec_var_addr exec_var_addr; - -struct exec_var { - unsigned int entry_point; - unsigned int real_entry_point; - caddr_t nfs_disklessp; - exec_var_addr text_info; - exec_var_addr data_info; - exec_var_addr bss_info; -}; diff --git a/sys/boot/in_cksum.c b/sys/boot/in_cksum.c deleted file mode 100644 index 1c3a6335fe13..000000000000 --- a/sys/boot/in_cksum.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#) $Header: /cvsroot/src/sys/boot/Attic/in_cksum.c,v 1.1 1993/10/12 06:02:28 glass Exp $ (LBL) - */ - -#include - -/* - * Checksum routine for Internet Protocol family headers. - * This routine is very heavily used in the network - * code and should be modified for each CPU to be as fast as possible. - * In particular, it should not be this one. - */ -int -in_cksum(p, len) - register void *p; - register int len; -{ - register int sum = 0, oddbyte = 0, v = 0; - register u_char *cp = p; - - /* we assume < 2^16 bytes being summed */ - while (len > 0) { - if (oddbyte) { - sum += v + *cp++; - len--; - } - if (((int)cp & 1) == 0) { - while ((len -= 2) >= 0) { - sum += *(u_short *)cp; - cp += 2; - } - } else { - while ((len -= 2) >= 0) { - sum += *cp++ << 8; - sum += *cp++; - } - } - if ((oddbyte = len & 1) != 0) - v = *cp << 8; - } - if (oddbyte) - sum += v; - sum = (sum >> 16) + (sum & 0xffff); /* add in accumulated carries */ - sum += sum >> 16; /* add potential last carry */ - return (0xffff & ~sum); -} diff --git a/sys/boot/net.c b/sys/boot/net.c deleted file mode 100644 index 09c90ab56be4..000000000000 --- a/sys/boot/net.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#) $Header: /cvsroot/src/sys/boot/Attic/net.c,v 1.1 1993/10/12 06:02:29 glass Exp $ (LBL) - */ - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include "netboot.h" -#include "config.h" -#include "netif.h" - -/* Caller must leave room for ethernet, ip and udp headers in front!! */ -int -sendudp(d, buf, len) - register struct iodesc *d; - register void *buf; - register int len; -{ - register int cc; - register struct ip *ip; - register struct udphdr *up; - register u_char *ea; - - if (debug) - printf("sendudp: called\n"); - up = ((struct udphdr *)buf) - 1; - ip = ((struct ip *)up) - 1; - len += sizeof(*ip) + sizeof(*up); - - bzero(ip, sizeof(*ip) + sizeof(*up)); - - ip->ip_v = IPVERSION; - ip->ip_hl = sizeof(*ip) >> 2; - ip->ip_len = htons(len); - ip->ip_p = IPPROTO_UDP; - ip->ip_ttl = IP_TTL; - ip->ip_src.s_addr = d->myip; - ip->ip_dst.s_addr = d->destip; - ip->ip_sum = in_cksum(ip, sizeof(*ip)); - - up->uh_sport = htons(d->myport); - up->uh_dport = htons(d->destport); - up->uh_ulen = htons(len - sizeof(*ip)); - up->uh_sum = in_cksum(up, len - sizeof(*ip)); - - if (ip->ip_dst.s_addr == INADDR_BROADCAST || ip->ip_src.s_addr == 0 || - mask == 0 || SAMENET(ip->ip_src.s_addr, ip->ip_dst.s_addr, mask)) - ea = arpwhohas(d, ip->ip_dst.s_addr); - else - ea = arpwhohas(d, gateip); - - cc = sendether(d, ip, len, ea, ETHERTYPE_IP); - - if (cc < 0) - return (cc); - if (cc != len) - panic("sendudp: bad write (%d != %d)", cc, len); - - return (cc - (sizeof(*ip) + sizeof(*up))); -} - -/* Caller must leave room for ethernet header in front!! */ -int -sendether(d, buf, len, dea, etype) - register struct iodesc *d; - register void *buf; - register int len; - register u_char *dea; - register int etype; -{ - register struct ether_header *eh; - - if (debug) - printf("sendether: called\n"); - eh = ((struct ether_header *)buf) - 1; - len += ETHER_SIZE; - - MACPY(d->myea, eh->ether_shost); - MACPY(dea, eh->ether_dhost); - - eh->ether_type = etype; - return (ethernet_put(d, eh, len) - ETHER_SIZE); -} - -/* Check that packet is a valid udp packet for us */ -void * -checkudp(d, pkt, lenp) - register struct iodesc *d; - register void *pkt; - register int *lenp; -{ - register int hlen, len; - register struct ether_header *eh; - register struct ip *ip; - register struct udphdr *up; - - if (debug) - printf("checkudp: called\n"); - eh = pkt; - ip = (struct ip *)(eh + 1); - up = (struct udphdr *)(ip + 1); - - /* Must be to us */ - if (bcmp(d->myea, eh->ether_dhost, 6) != 0 && - bcmp(bcea, eh->ether_dhost, 6) != 0) - return (NULL); - - /* And ip */ - if (eh->ether_type != ETHERTYPE_IP) - return (NULL); - - /* Check ip header */ - if (ip->ip_v != IPVERSION || ip->ip_p != IPPROTO_UDP) - return (NULL); - - hlen = ip->ip_hl << 2; - if (hlen < sizeof(*ip) || in_cksum(ip, hlen) != 0) - return (NULL); - NTOHS(ip->ip_len); - if (*lenp - sizeof(*eh) < ip->ip_len) - return (NULL); - if (d->myip && ip->ip_dst.s_addr != d->myip) - return (NULL); - - /* If there were ip options, make them go away */ - if (hlen != sizeof(*ip)) { - bcopy(((u_char *)ip) + hlen, up, - *lenp - (sizeof(*eh) + hlen)); - ip->ip_len = sizeof(*ip); - *lenp -= hlen - sizeof(*ip); - } - if (ntohs(up->uh_dport) != d->myport) - return (NULL); - - if (up->uh_sum) { - len = ntohs(up->uh_ulen); - if (len > RECV_SIZE - (sizeof(*eh) + sizeof(*ip))) { - printf("checkudp: huge packet, udp len %lu\n", len); - return (NULL); - } - if (in_cksum(up, len) != 0) - return (NULL); - } - NTOHS(up->uh_dport); - NTOHS(up->uh_sport); - NTOHS(up->uh_ulen); - if (up->uh_ulen < sizeof(*up)) - return (NULL); - *lenp -= sizeof(*eh) + sizeof(*ip) + sizeof(*up); - return (up + 1); -} - -/* - * Send a packet and wait for a reply, with exponential backoff. - * - * The send routine must return the actual number of bytes written. - * - * The receive routine can indicate success by returning the number of - * bytes read; it can return 0 to indicate EOF; it can return -1 with a - * non-zero errno to indicate failure; finally, it can return -1 with a - * zero errno to indicate it isn't done yet. - */ -int -sendrecv(d, sproc, sbuf, ssize, rproc, rbuf, rsize) - register struct iodesc *d; - register int (*sproc)(struct iodesc *, void *, int); - register void *sbuf; - register int ssize; - register int (*rproc)(struct iodesc *, void *, int); - register void *rbuf; - register int rsize; -{ - register int cc; - register time_t t, tmo, tlast, tleft; - - if (debug) - printf("sendrecv: called\n"); - tmo = MINTMO; - tlast = tleft = 0; - t = getsecs(); - for (;;) { - if (tleft <= 0) { - cc = (*sproc)(d, sbuf, ssize); - if (cc < ssize) - panic("sendrecv: short write! (%d < %d)", - cc, ssize); - - tleft = tmo; - tmo <<= 1; - if (tmo > MAXTMO) - tmo = MAXTMO; - tlast = t; - } - - cc = ethernet_get(d, rbuf, rsize, tleft); - if (cc >= 0) { - /* Got a packet, process it */ - cc = (*rproc)(d, rbuf, cc); - /* Return on data, EOF or real error */ - if (cc >= 0 || errno != 0) - return (cc); - } - /* Timed out or didn't get the packet we're waiting for */ - t = getsecs(); - tleft -= t - tlast; - tlast = t; - } -} - -int ethernet_get(desc, pkt, len, timeout) - struct iodesc *desc; - void *pkt; - int len; - time_t timeout; -{ - int val; - val = desc->io_netif->netif_get(desc, pkt, len, timeout); - if (debug) - printf("ethernet_get: received %d\n", val); - return val; -} -int ethernet_put(desc, pkt, len) - struct iodesc *desc; - void *pkt; - int len; -{ - int count, val; - - if (debug) { - struct ether_header *eh; - - printf("ethernet_put: called\n"); - eh = pkt; - printf("ethernet_put: ether_dhost %s\n", - ether_sprintf(eh->ether_dhost)); - printf("ethernet_put: ether_shost %s\n", - ether_sprintf(eh->ether_shost)); - printf("ethernet_put: ether_type %x\n", eh->ether_type); - } - if (!desc->io_netif) - panic("ethernet_put: no netif_put support"); - val = desc->io_netif->netif_put(desc, pkt, len); - return val; -} diff --git a/sys/boot/netboot.h b/sys/boot/netboot.h deleted file mode 100644 index bc4862bdbf54..000000000000 --- a/sys/boot/netboot.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 1993 Adam Glass - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#) $Header: /cvsroot/src/sys/boot/Attic/netboot.h,v 1.1 1993/10/12 06:02:31 glass Exp $ (LBL) - */ - -#define BA { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } - -/* Returns true if n_long's on the same net */ -#define SAMENET(a1, a2, m) ((a1 & m) == (a2 & m)) - -#define MACPY(s, d) bcopy((char *)s, (char *)d, 6) - -#define MAXTMO 20 /* seconds */ -#define MINTMO 2 /* seconds */ - -#define FNAME_SIZE 128 -#define IFNAME_SIZE 16 -#define RECV_SIZE 1536 /* XXX delete this */ - -/* Size of struct ether_header + struct ip + struct udphdr */ -#define ETHER_SIZE 14 -#define HEADER_SIZE (ETHER_SIZE + 20 + 8) - -struct iodesc { - n_long destip; /* destination ip address */ - n_long myip; /* my ip address */ - u_short destport; /* destination port */ - u_short myport; /* destination port */ - u_long xid; /* transaction identification */ - u_char myea[6]; /* my ethernet address */ - u_char *fh; /* pointer to file handle */ - struct netif *io_netif; -}; - -extern u_char bcea[6]; -extern char rootpath[FNAME_SIZE]; -extern char swappath[FNAME_SIZE]; -extern char ifname[IFNAME_SIZE]; -extern n_long rootip; -extern n_long swapip; -extern n_long gateip; -extern n_long smask; -extern n_long nmask; -extern n_long mask; -extern time_t bot; -extern int debug; - -u_char *arpwhohas __P((struct iodesc *, n_long)); - -void getnfsfh __P((struct iodesc *, char *, u_char *)); -void getnfsinfo __P((struct iodesc *, time_t *, u_long *, u_long *)); -int lookupfh __P((struct iodesc *, char *, u_char *, time_t *, - u_long *, u_long *)); -int readdata __P((struct iodesc *, u_long, void *, u_long)); -void readseg __P((struct iodesc *, u_long, u_long, u_long)); - - -void ethernet_init __P((struct iodesc *)); -int ethernet_put __P((struct iodesc *, void *, int)); -int ethernet_poll __P((struct iodesc *, void *, int)); -int ethernet_get __P((struct iodesc *, void *, int, time_t)); -void ethernet_macaddr __P((struct iodesc *, int, u_char *)); -time_t getsecs __P((void)); -u_long gettenths __P((void)); - -int sendether __P((struct iodesc *, void *, int, u_char *, int)); -int sendudp __P((struct iodesc *, void *, int)); -int recvudp __P((struct iodesc *, void *, int, time_t)); -int sendrecv __P((struct iodesc *, int (*)(struct iodesc *, void *, int), - void *, int, int (*)(struct iodesc *, void *, int), void *, int)); -void *checkudp __P((struct iodesc *, void *, int *)); - -void panic __P((const char *, ...)); -char *ether_sprintf __P((u_char *)); -int in_cksum __P((void *, int)); -void call __P((u_long)); diff --git a/sys/boot/netif.c b/sys/boot/netif.c deleted file mode 100644 index 866df05ad93c..000000000000 --- a/sys/boot/netif.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 1993 Adam Glass - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Adam Glass. - * 4. The name of the Author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Header: /cvsroot/src/sys/boot/Attic/netif.c,v 1.1 1993/10/12 06:02:33 glass Exp $ - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include "netboot.h" -#include "config.h" -#include "netif.h" - -static int netif_newp = 0; /* an optimization to skip over exhausted netifs */ - -void netif_init() -{ - int i; - - if (debug) - printf("netif_init: called\n"); - for (i =0; i < n_netif; i++) { - netiftab[i]->netif_unit; - netiftab[i]->netif_exhausted = 0; - } -} -int netif_match(nif, machdep_hint, unitp) - struct netif *nif; - void *machdep_hint; - int *unitp; -{ - if (debug) - printf("netif_match: called\n"); - return nif->netif_match(machdep_hint, unitp); -} - -struct netif *netif_select(machdep_hint) - void *machdep_hint; -{ - int i; - struct netif *best_if = NULL; - int best_unit; - int best_val; - int val, unit; - - best_val = 0; - if (debug) - printf("network interfaces: %d\n", n_netif); - for (i = netif_newp; i < n_netif; i++) { - val = netif_match(netiftab[i], machdep_hint, &unit); - if (val == 0) { - netiftab[i]->netif_exhausted = 1; - continue; - } - if (debug) - printf("netif_select: %s%d = %d\n", netiftab[i]->netif_bname, - netiftab[i]->netif_unit, val); - if (val > best_val) { - best_if = netiftab[i]; - best_unit = unit; - } - } - if (!best_if) return NULL; - best_if->netif_unit = best_unit; - return best_if; -} - -int netif_probe(nif, machdep_hint) - struct netif *nif; - void *machdep_hint; -{ - if (debug) - printf("netif_probe: called\n"); - return nif->netif_probe(machdep_hint); -} - -void netif_attach(nif, desc, machdep_hint) - struct netif *nif; - struct iodesc *desc; - void *machdep_hint; -{ - if (debug) - printf("netif_attach: called\n"); - nif->netif_init(desc, machdep_hint); - desc->io_netif = nif; - bzero(desc->io_netif->netif_stats, *desc->io_netif->netif_stats); -} -void netif_detach(nif) - struct netif *nif; -{ - if (debug) - printf("netif_detach: called\n"); - nif->netif_end(); -} diff --git a/sys/boot/netif.h b/sys/boot/netif.h deleted file mode 100644 index c5d4b1b864b2..000000000000 --- a/sys/boot/netif.h +++ /dev/null @@ -1,32 +0,0 @@ - -struct netif { - char *netif_bname; - int netif_unit; - int netif_exhausted; - int (*netif_match) __P((void *, int *)); - int (*netif_probe) __P((void *)); - void (*netif_init) __P((struct iodesc *, void *)); - int (*netif_get) __P((struct iodesc *, void *, int, time_t)); - int (*netif_put) __P((struct iodesc *, void *, int)); - void (*netif_end) __P((void)); - struct netif_stats *netif_stats; -}; - -struct netif_stats { - int collisions; - int collision_error; - int missed; - int sent; - int received; - int deferred; - int overflow; -}; -extern struct netif *netiftab[]; - -extern int n_netif; - -void netif_init __P((void)); -struct netif *netif_select __P((void *)); -int netif_probe __P((struct netif *, void *)); -void netif_attach __P((struct netif *, struct iodesc *, void *)); -void netif_detach __P((struct netif *)); diff --git a/sys/boot/nfsboot.c b/sys/boot/nfsboot.c deleted file mode 100644 index 387261d12cec..000000000000 --- a/sys/boot/nfsboot.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 1993 Adam Glass - * All rights reserved. - * - * A lot of this code is derived material from the LBL bootbootp release, - * thus their copyright below. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Adam Glass. - * 4. The name of the Author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Header: /cvsroot/src/sys/boot/Attic/nfsboot.c,v 1.1 1993/10/12 06:02:38 glass Exp $ - */ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#) $Header: /cvsroot/src/sys/boot/Attic/nfsboot.c,v 1.1 1993/10/12 06:02:38 glass Exp $ (LBL) - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "netboot.h" -#include "config.h" -#include "bootbootp.h" -#include "bootp.h" -#include "netif.h" - -/* Globals */ -u_char bcea[6] = BA; /* broadcast ethernet address */ -char rootpath[FNAME_SIZE]; /* root mount path */ -char swappath[FNAME_SIZE]; /* swap mount path */ -char ifname[IFNAME_SIZE]; /* name of interface (e.g. "le0") */ -n_long rootip; /* root ip address */ -n_long swapip; /* swap ip address */ -n_long gateip; /* swap ip address */ -n_long smask; /* subnet mask */ -n_long nmask; /* net mask */ -n_long mask; /* subnet or net mask */ -time_t bot; /* beginning of time in seconds */ - -#ifdef DEBUG -int debug = 1; -#else -int debug = 0; -#endif - -static u_char rootfh[NFS_FHSIZE]; -static u_char swapfh[NFS_FHSIZE]; -static u_long swapblks; -static time_t roottime; - -void nfs_setup(desc) - struct iodesc *desc; -{ - u_long ftype, bytes; - - bcopy(&desc->myea[4], &desc->myport, 2); - - printf("myip: %s", intoa(desc->myip)); - if (gateip) - printf(", gateip: %s", intoa(gateip)); - if (mask) - printf(", mask: %s", intoa(mask)); - printf("\n"); - printf("root: %s:%s\n", intoa(rootip), rootpath); - printf("swap: %s:%s\n", intoa(swapip), swappath); - - /* Get root file handle and timestamp */ - desc->destip = rootip; - getnfsfh(desc, rootpath, rootfh); - desc->fh = rootfh; - getnfsinfo(desc, &roottime, NULL, &ftype); - if (ftype != NFDIR) - panic("bad root ftype %d", ftype); - if (debug) - printf("nfs_setup: got root fh\n"); - - desc->destip = swapip; - getnfsfh(desc, swappath, swapfh); - desc->fh = swapfh; - getnfsinfo(desc, NULL, &bytes, &ftype); - if (bytes % 512) - printf("warning: swap is odd sized\n"); - if (ftype != NFREG) - panic("bad swap ftype %d\n", ftype); - swapblks = bytes / 512; - if (debug) - printf("nfs_setup: got swap fh\n"); - printf("swap: %d (%d blocks)\n", bytes, swapblks); - desc->destip = rootip; - desc->fh = rootfh; -} - - -unsigned int nfs_boot(kernel_override, machdep_hint) - char *kernel_override; - void *machdep_hint; -{ - /* - * 0. get common ether addr if exists - * 1. choose interface - * 2. set up interface - * 3. bootp or bootparam - * 4. get filesystem fh information - * 5. get swap information - * 6. load kernel - * 7. if nfs_diskless crud, do the right thign - * 8. run kernel - */ - struct iodesc *desc; - struct iodesc desc_store; - struct netif *nif; - - desc = &desc_store; - netif_init(); - while (1) { - bzero(desc, sizeof(*desc)); -#ifdef COMMON_ETHERADDR - machdep_common_ether(desc->myea); -#endif - nif = netif_select(machdep_hint); - if (!nif) - panic("netboot: no interfaces left untried"); - if (netif_probe(nif, machdep_hint)) { - printf("netboot: couldn't probe %s%d\n", - nif->netif_bname, nif->netif_unit); - continue; - } - netif_attach(nif, desc, machdep_hint); - - get_bootinfo(desc); - nfs_setup(desc); - nfs_exec(desc, kernel_override); - failed: netif_detach(nif); - } -} diff --git a/sys/boot/rpc.c b/sys/boot/rpc.c deleted file mode 100644 index b3bcea91d3c3..000000000000 --- a/sys/boot/rpc.c +++ /dev/null @@ -1,617 +0,0 @@ -/* - * Copyright (c) 1992 Regents of the University of California. - * All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#) $Header: /cvsroot/src/sys/boot/Attic/rpc.c,v 1.1 1993/10/12 06:02:40 glass Exp $ (LBL) - */ - -#include -#include - -#include -#include - -#include -#include - -#include - -#include "netboot.h" -#include "netif.h" -#include "config.h" -#include "bootbootp.h" - -/* XXX defines we can't easily get from system includes */ -#define PMAPPORT 111 -#define PMAPPROG 100000 -#define PMAPVERS 2 -#define PMAPPROC_GETPORT 3 - -#define RPC_MSG_VERSION 2 -#define MSG_ACCEPTED 0 -#define CALL 0 -#define REPLY 1 - -/* Null rpc auth info */ -struct auth_info { - int rp_atype; /* zero (really AUTH_NULL) */ - u_long rp_alen; /* zero (size of auth struct) */ -}; - -/* Generic rpc call header */ -struct rpc_call { - u_long rp_xid; /* request transaction id */ - int rp_direction; /* call direction */ - u_long rp_rpcvers; /* rpc version (2) */ - u_long rp_prog; /* program */ - u_long rp_vers; /* version */ - u_long rp_proc; /* procedure */ - struct auth_info rp_auth; /* AUTH_NULL */ - struct auth_info rp_verf; /* AUTH_NULL */ -}; - -/* Generic rpc reply header */ -struct rpc_reply { - u_long rp_xid; /* request transaction id */ - int rp_direction; /* call direction */ - int rp_stat; /* accept status */ - u_long rp_prog; /* program (unused) */ - u_long rp_vers; /* version (unused) */ - u_long rp_proc; /* procedure (unused) */ -}; - -struct nfs_call_data { - u_char fh[NFS_FHSIZE]; - u_long off; - u_long len; - u_long xxx; /* XXX what's this for? */ -}; - -/* Data part of nfs rpc reply (also the largest thing we receive) */ -struct nfs_reply_data { - u_long errno; - struct nfsv2_fattr fa; - u_long count; - u_char data[1200]; -}; -#define NFSREAD_SIZE sizeof(((struct nfs_reply_data *)0)->data) - -/* Cache stuff */ -#define PMAP_NUM 8 /* need at most 5 pmap entries */ - -static struct pmap_list { - u_long addr; /* address of server */ - u_long prog; - u_long vers; - u_short port; /* cached port for service */ -} pmap_list[PMAP_NUM] = { - { 0, PMAPPROG, PMAPVERS, PMAPPORT } -}; -static int pmap_num = 1; - -/* Local forwards */ -static int callrpc __P((struct iodesc *, u_long, u_long, u_long, - void *, int, void *, int)); -static int recvrpc __P((struct iodesc *, void *, int)); -static u_short getport __P((struct iodesc *, u_long, u_long)); - -/* Make a rpc call; return length of answer */ -static int -callrpc(d, prog, vers, proc, sdata, slen, rdata, rlen) - register struct iodesc *d; - register u_long prog, vers, proc; - register void *sdata; - register int slen; - register void *rdata; - register int rlen; -{ - register int cc; - register struct rpc_call *rpc; - struct { - u_char header[HEADER_SIZE]; - struct rpc_call wrpc; - u_char data[sizeof(struct nfs_reply_data)]; /* XXX */ - } wbuf; - struct { - u_char header[HEADER_SIZE]; - struct rpc_reply rrpc; - union { - u_long errno; - u_char data[sizeof(struct nfs_reply_data)]; - } ru; - } rbuf; - - if (debug) - printf("callrpc: called\n"); - if (rlen > sizeof(rbuf.ru.data)) - panic("callrpc: huge read (%d > %d)", - rlen, sizeof(rbuf.ru.data)); - - d->destport = getport(d, prog, vers); - - rpc = &wbuf.wrpc; - - bzero(rpc, sizeof(*rpc)); - - rpc->rp_xid = d->xid; - rpc->rp_rpcvers = htonl(RPC_MSG_VERSION); - rpc->rp_prog = htonl(prog); - rpc->rp_vers = htonl(vers); - rpc->rp_proc = htonl(proc); - bcopy(sdata, wbuf.data, slen); - - cc = sendrecv(d, sendudp, rpc, sizeof(*rpc) + slen, recvrpc, - ((u_char *)&rbuf.rrpc) - HEADER_SIZE, sizeof(rbuf) - HEADER_SIZE); - - if (cc < rlen) { - /* Check for an error return */ - if (cc >= sizeof(rbuf.ru.errno) && rbuf.ru.errno != 0) { - errno = ntohl(rbuf.ru.errno); - return (-1); - } - panic("callrpc: missing data (%d < %d)", cc, rlen); - } - if (cc > sizeof(rbuf.ru.data)) - panic("callrpc: huge return (%d > %d)", - cc, sizeof(rbuf.ru.data)); - bcopy(rbuf.ru.data, rdata, cc); - return (cc); -} - -/* Returns true if packet is the one we're waiting for */ -static int -recvrpc(d, pkt, len) - register struct iodesc *d; - register void *pkt; - int len; -{ - register struct rpc_reply *rpc; - - if (debug) - printf("recvrpc: called\n"); - rpc = (struct rpc_reply *)checkudp(d, pkt, &len); - if (rpc == NULL || len < sizeof(*rpc)) { - errno = 0; - return (-1); - } - - NTOHL(rpc->rp_direction); - NTOHL(rpc->rp_stat); - - if (rpc->rp_xid != d->xid || rpc->rp_direction != REPLY || - rpc->rp_stat != MSG_ACCEPTED) { - errno = 0; - return (-1); - } - - /* Bump xid so next request will be unique */ - ++d->xid; - - /* Return data count (thus indicating success) */ - return (len - sizeof(*rpc)); -} - -/* Request a port number from the port mapper */ -static u_short -getport(d, prog, vers) - register struct iodesc *d; - u_long prog; - u_long vers; -{ - register int i; - register struct pmap_list *pl; - u_long port; - struct { - u_long prog; /* call program */ - u_long vers; /* call version */ - u_long proto; /* call protocol */ - u_long port; /* call port (unused) */ - } sdata; - - if (debug) - printf("getport: called\n"); - /* Try for cached answer first */ - for (i = 0, pl = pmap_list; i < pmap_num; ++i, ++pl) - if ((pl->addr == d->destip || pl->addr == 0) && - pl->prog == prog && pl->vers == vers) - return (pl->port); - - /* Don't overflow cache */ - if (pmap_num > PMAP_NUM - 1) - panic("getport: overflowed pmap_list!"); - - sdata.prog = htonl(prog); - sdata.vers = htonl(vers); - sdata.proto = htonl(IPPROTO_UDP); - sdata.port = 0; - - if (callrpc(d, PMAPPROG, PMAPVERS, PMAPPROC_GETPORT, - &sdata, sizeof(sdata), &port, sizeof(port)) < 0) - panic("getport: %s", strerror(errno)); - - /* Cache answer */ - pl->addr = d->destip; - pl->prog = prog; - pl->vers = vers; - pl->port = port; - ++pmap_num; - - return ((u_short)port); -} - -/* Fetch file handle */ -void -getnfsfh(d, path, fhp) - register struct iodesc *d; - char *path; - u_char *fhp; -{ - register int len; - struct { - u_long len; - char path[FNAME_SIZE]; - } sdata; - struct { - u_long errno; - u_char fh[NFS_FHSIZE]; - } rdata; - - if (debug) - printf("getnfsfh: called\n"); - bzero(&sdata, sizeof(sdata)); - len = strlen(path); - if (len > sizeof(sdata.path)) - len = sizeof(sdata.path); - bcopy(path, sdata.path, len); - sdata.len = htonl(len); - len = sizeof(sdata) - sizeof(sdata.path) + roundup(len, sizeof(long)); - - if (callrpc(d, RPCPROG_MNT, RPCMNT_VER1, RPCMNT_MOUNT, - &sdata, len, &rdata, sizeof(rdata)) < 0) - panic("getnfsfh: %s", strerror(errno)); - - bcopy(rdata.fh, fhp, sizeof(rdata.fh)); -} - -/* Fetch file timestamp and size */ -void -getnfsinfo(d, tp, sp, fp) - register struct iodesc *d; - register time_t *tp; - register u_long *sp, *fp; -{ - struct { - u_long errno; - struct nfsv2_fattr fa; - } rdata; - - if (debug) - printf("getnfsinfo: called\n"); - if (callrpc(d, NFS_PROG, NFS_VER2, NFSPROC_GETATTR, - d->fh, NFS_FHSIZE, &rdata, sizeof(rdata)) < 0) - panic("getnfsfh: %s", strerror(errno)); - - if (tp) - *tp = ntohl(rdata.fa.fa_ctime.tv_sec); - if (sp) - *sp = ntohl(rdata.fa.fa_size); - if (fp) - *fp = ntohl(rdata.fa.fa_type); -} - -/* Lookup a file. Optionally return timestamp and size */ -int -lookupfh(d, name, fhp, tp, sp, fp) - register struct iodesc *d; - register char *name; - register u_char *fhp; - register time_t *tp; - register u_long *sp, *fp; -{ - register int len; - struct { - u_char fh[NFS_FHSIZE]; - u_long len; - char name[FNAME_SIZE]; - } sdata; - struct { - u_long errno; - u_char fh[NFS_FHSIZE]; - struct nfsv2_fattr fa; - } rdata; - - if (debug) - printf("lookupfh: called\n"); - - bzero(&sdata, sizeof(sdata)); - bcopy(d->fh, sdata.fh, sizeof(sdata.fh)); - len = strlen(name); - if (len > sizeof(sdata.name)) - len = sizeof(sdata.name); - bcopy(name, sdata.name, len); - sdata.len = htonl(len); - len = sizeof(sdata) - sizeof(sdata.name) + roundup(len, sizeof(long)); - - if (callrpc(d, NFS_PROG, NFS_VER2, NFSPROC_LOOKUP, - &sdata, len, &rdata, sizeof(rdata)) < 0) - return (-1); - - bcopy(rdata.fh, fhp, sizeof(rdata.fh)); - if (tp) - *tp = ntohl(rdata.fa.fa_ctime.tv_sec); - if (sp) - *sp = ntohl(rdata.fa.fa_size); - if (fp) - *fp = ntohl(rdata.fa.fa_type); - return (0); -} - -static int sendreaddata __P((struct iodesc *, void *, int)); -static int recvreaddata __P((struct iodesc *, void *, int)); - -/* max number of nfs reads pending */ -#define NFS_COUNT 10 - -static struct nfsstate { - u_long off; - u_long len; - int done; - void *addr; - u_long xid; -} nfsstate[NFS_COUNT]; - -static u_long nfscc; - -static int -sendreaddata(d, pkt, len) - register struct iodesc *d; - register void *pkt; - register int len; -{ - register int i; - register u_long cc; - register struct rpc_call *rpc; - register struct nfs_call_data *nfs; - register struct nfsstate *ns; - - if (debug) - printf("sendreaddata: called\n"); - - if (len != sizeof(*rpc) + sizeof(*nfs)) - panic("sendreaddata: bad buffer (%d != %d)", - len, sizeof(*rpc) + sizeof(*nfs)); - rpc = pkt; - nfs = (struct nfs_call_data *)(rpc + 1); - for (i = 0, ns = nfsstate; i < NFS_COUNT; ++i, ++ns) { - if (ns->done) - continue; - - rpc->rp_xid = ns->xid; - nfs->off = htonl(ns->off); - nfs->len = htonl(ns->len); - cc = sendudp(d, rpc, len); - - if (cc != len) - panic("sendreaddata: short write (%d != %d)", cc, len); - } - /* XXX we may have actually sent a lot more bytes... */ - - return (len); -} - -/* Returns char count if done else -1 (and errno == 0) */ -static int -recvreaddata(d, pkt, len) - register struct iodesc *d; - register void *pkt; - int len; -{ - register int i; - register struct rpc_reply *rpc; - register struct nfs_reply_data *nfs; - register struct nfsstate *ns; - - if (debug) - printf("recvreaddata: called\n"); - rpc = (struct rpc_reply *)checkudp(d, pkt, &len); - if (rpc == NULL || len < sizeof(*rpc)) { - errno = 0; - return (-1); - } - len -= sizeof(*rpc); - - NTOHL(rpc->rp_direction); - NTOHL(rpc->rp_stat); - - if (rpc->rp_direction != REPLY || rpc->rp_stat != MSG_ACCEPTED) { - errno = 0; - return (-1); - } - - for (i = 0, ns = nfsstate; i < NFS_COUNT; ++i, ++ns) - if (rpc->rp_xid == ns->xid) - break; - if (i >= NFS_COUNT) { - errno = 0; - return (-1); - } - - if (ns->done) { - errno = 0; - return (-1); - } - nfs = (struct nfs_reply_data *)(rpc + 1); - if (len < sizeof(nfs->errno)) - panic("recvreaddata: bad read %d", len); - if (nfs->errno) { - errno = ntohl(nfs->errno); - return (-1); - } - if (len < sizeof(*nfs) - sizeof(nfs->data)) - panic("recvreaddata: less than nfs sized %d", len); - len -= sizeof(*nfs) - sizeof(nfs->data); - - if (len < nfs->count) - panic("recvreaddata: short read (%d < %d)", len, nfs->count); - len = nfs->count; - if (len > ns->len) - panic("recvreaddata: huge read (%d > %d)", len, ns->len); - - bcopy(nfs->data, ns->addr, len); - ns->done = 1; - nfscc += len; - - if (len < ns->len) { - /* If first packet assume no more data to read */ - if (i == 0) - return (0); - - /* Short read, assume we are at EOF */ - ++i; - ++ns; - while (i < NFS_COUNT) { - ns->done = 1; - ++i; - ++ns; - } - } - - for (i = 0, ns = nfsstate; i < NFS_COUNT; ++i, ++ns) - if (!ns->done) { - errno = 0; - return (-1); - } - - /* Return data count (thus indicating success) */ - return (nfscc); -} - -/* Read data from a file */ -int -readdata(d, off, addr, len) - register struct iodesc *d; - register u_long off; - register void *addr; - register u_long len; -{ - register int i, cc; - register struct rpc_call *rpc; - register struct nfsstate *ns; - struct { - u_char header[HEADER_SIZE]; - struct rpc_call rpc; - struct nfs_call_data nfs; - } sdata; - struct { - u_char header[HEADER_SIZE]; - struct rpc_call rpc; - struct nfs_reply_data nfs; - } rdata; - - if (debug) - printf("readdata: called\n"); - if (len == 0) - return (0); - d->destport = getport(d, NFS_PROG, NFS_VER2); - - - bzero(&sdata, sizeof(sdata)); - - for (i = 0, ns = nfsstate; i < NFS_COUNT; ++i, ++ns) { - if (len <= 0) { - ns->done = 1; - continue; - } - ns->done = 0; - - ns->xid = d->xid; - ++d->xid; - - ns->off = off; - ns->len = len; - if (ns->len > NFSREAD_SIZE) - ns->len = NFSREAD_SIZE; -#ifdef notdef -/* XXX to align or not align? It doesn't seem to speed things up... */ - if ((ns->off % NFSREAD_SIZE) != 0) - ns->len -= off % NFSREAD_SIZE; -#endif - - off += ns->len; - len -= ns->len; - - ns->addr = addr; - addr += NFSREAD_SIZE; - } - - rpc = &sdata.rpc; - rpc->rp_rpcvers = htonl(RPC_MSG_VERSION); - rpc->rp_prog = htonl(NFS_PROG); - rpc->rp_vers = htonl(NFS_VER2); - rpc->rp_proc = htonl(NFSPROC_READ); - bcopy(d->fh, sdata.nfs.fh, sizeof(sdata.nfs.fh)); - - nfscc = 0; - cc = sendrecv(d, sendreaddata, - &sdata.rpc, - sizeof(struct rpc_call) + sizeof(struct nfs_call_data), - recvreaddata, - ((u_char *)&rdata.rpc) - HEADER_SIZE, HEADER_SIZE + - sizeof(struct rpc_call) + sizeof(struct nfs_reply_data)); - return (cc); -} - -void readseg(d, off, size, addr) - register struct iodesc * d; - register u_long off, size, addr; -{ - register int i, cc; - i = 0; - while (size > 0) { - cc = readdata(d, off, (void *)addr, size); - if (cc <= 0) { - /* XXX maybe should retry on certain errors */ - if (cc < 0) - panic("\nreadseg: read: %s", - strerror(errno)); - panic("\nreadseg: hit EOF unexpectantly"); - } - off += cc; - addr += cc; - size -= cc; - i = ~i; - printf("%c\010", i ? '-' : '='); - } -} diff --git a/sys/boot/util.c b/sys/boot/util.c deleted file mode 100644 index cdfa8befa57b..000000000000 --- a/sys/boot/util.c +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -#include - -#include -#include - -#include "config.h" - -#include "../include/stdarg.h" - -void -#ifdef __STDC__ -panic(const char *fmt, ...) -#else -panic(fmt /*, va_alist */) - char *fmt; -#endif -{ - va_list ap; - - va_start(ap, fmt); - printf(fmt, ap); - printf("\n"); - va_end(ap); - machdep_stop(); -} - - -/* Similar to inet_ntoa() */ -char * -intoa(addr) - n_long addr; -{ - register char *cp; - register u_int byte; - register int n; - static char buf[sizeof(".xxx.xxx.xxx.xxx")]; - - cp = &buf[sizeof buf]; - *--cp = '\0'; - - n = 4; - do { - byte = addr & 0xff; - *--cp = byte % 10 + '0'; - byte /= 10; - if (byte > 0) { - *--cp = byte % 10 + '0'; - byte /= 10; - if (byte > 0) - *--cp = byte + '0'; - } - *--cp = '.'; - addr >>= 8; - } while (--n > 0); - - return (cp + 1); -} - -char *strerror(errnum) - int errnum; -{ - char ebuf[1024] = "Unknown error: code "; - char *p; - int length; - - - - switch (errnum) { - case EPERM: - return "Permission Denied"; - case ENOENT: - return "No such file or directory"; - case ESTALE: - return "Stale NFS file handle"; - default: - length = strlen(ebuf); - p = ebuf+length; - do { - *p++ = "0123456789"[errnum %10]; - } while (errnum /= 10); - *p = '\0'; - return ebuf; - } -} - - -/* - * Convert Ethernet address to printable (loggable) representation. - */ -static char digits[] = "0123456789abcdef"; -char * -ether_sprintf(ap) - register u_char *ap; -{ - register i; - static char etherbuf[18]; - register char *cp = etherbuf; - - for (i = 0; i < 6; i++) { - *cp++ = digits[*ap >> 4]; - *cp++ = digits[*ap++ & 0xf]; - *cp++ = ':'; - } - *--cp = 0; - return (etherbuf); -} - -void bzero(addr, len) - char *addr; - int len; -{ - while (len--) - *addr++ = '\0'; -} diff --git a/sys/compat/sunos/sun_syscall.h b/sys/compat/sunos/sun_syscall.h deleted file mode 100644 index 45fd60839d6f..000000000000 --- a/sys/compat/sunos/sun_syscall.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * System call numbers. - * - * DO NOT EDIT-- this file is automatically generated. - * created from: NetBSD syscalls.master,v 1.17 1994/06/29 06:30:25 - */ - -#define SUN_SYS_syscall 0 -#define SUN_SYS_exit 1 -#define SUN_SYS_fork 2 -#define SUN_SYS_read 3 -#define SUN_SYS_write 4 -#define SUN_SYS_sun_open 5 -#define SUN_SYS_close 6 -#define SUN_SYS_sun_wait4 7 -#define SUN_SYS_sun_creat 8 -#define SUN_SYS_link 9 -#define SUN_SYS_unlink 10 -#define SUN_SYS_sun_execv 11 -#define SUN_SYS_chdir 12 - /* 13 is old sun_time */ -#define SUN_SYS_sun_mknod 14 -#define SUN_SYS_chmod 15 -#define SUN_SYS_chown 16 -#define SUN_SYS_break 17 - /* 18 is old sun_stat */ -#define SUN_SYS_lseek 19 -#define SUN_SYS_getpid 20 - /* 21 is obsolete sun_old_mount */ - /* 23 is old setuid */ -#define SUN_SYS_getuid 24 - /* 25 is old sun_stime */ - /* 27 is old sun_alarm */ - /* 28 is old sun_fstat */ - /* 29 is old sun_pause */ - /* 30 is old sun_utime */ -#define SUN_SYS_access 33 - /* 34 is old sun_nice */ - /* 35 is old sun_ftime */ -#define SUN_SYS_sync 36 -#define SUN_SYS_kill 37 -#define SUN_SYS_stat 38 - /* 39 is old sun_setpgrp */ -#define SUN_SYS_lstat 40 -#define SUN_SYS_dup 41 -#define SUN_SYS_pipe 42 - /* 43 is old sun_times */ -#define SUN_SYS_profil 44 - /* 46 is old sun_setgid */ -#define SUN_SYS_getgid 47 - /* 48 is old sun_ssig */ -#define SUN_SYS_acct 51 -#define SUN_SYS_sun_mctl 53 -#define SUN_SYS_sun_ioctl 54 -#define SUN_SYS_reboot 55 - /* 56 is obsolete sun_owait3 */ -#define SUN_SYS_symlink 57 -#define SUN_SYS_readlink 58 -#define SUN_SYS_execve 59 -#define SUN_SYS_umask 60 -#define SUN_SYS_chroot 61 -#define SUN_SYS_ofstat 62 -#define SUN_SYS_ogetpagesize 64 -#define SUN_SYS_sun_omsync 65 -#define SUN_SYS_vfork 66 - /* 67 is obsolete vread */ - /* 68 is obsolete vwrite */ -#define SUN_SYS_sbrk 69 -#define SUN_SYS_sstk 70 -#define SUN_SYS_mmap 71 -#define SUN_SYS_vadvise 72 -#define SUN_SYS_munmap 73 -#define SUN_SYS_mprotect 74 -#define SUN_SYS_madvise 75 -#define SUN_SYS_sun_vhangup 76 - /* 77 is old vlimit */ -#define SUN_SYS_mincore 78 -#define SUN_SYS_getgroups 79 -#define SUN_SYS_setgroups 80 -#define SUN_SYS_getpgrp 81 -#define SUN_SYS_sun_setpgid 82 -#define SUN_SYS_setitimer 83 - /* 84 is old wait */ -#define SUN_SYS_swapon 85 -#define SUN_SYS_getitimer 86 -#define SUN_SYS_ogethostname 87 -#define SUN_SYS_osethostname 88 -#define SUN_SYS_ogetdtablesize 89 -#define SUN_SYS_dup2 90 -#define SUN_SYS_fcntl 92 -#define SUN_SYS_select 93 -#define SUN_SYS_fsync 95 -#define SUN_SYS_setpriority 96 -#define SUN_SYS_socket 97 -#define SUN_SYS_connect 98 -#define SUN_SYS_oaccept 99 -#define SUN_SYS_getpriority 100 -#define SUN_SYS_osend 101 -#define SUN_SYS_orecv 102 -#define SUN_SYS_bind 104 -#define SUN_SYS_sun_setsockopt 105 -#define SUN_SYS_listen 106 - /* 107 is old vtimes */ -#define SUN_SYS_osigvec 108 -#define SUN_SYS_osigblock 109 -#define SUN_SYS_osigsetmask 110 -#define SUN_SYS_sigsuspend 111 -#define SUN_SYS_osigstack 112 -#define SUN_SYS_orecvmsg 113 -#define SUN_SYS_osendmsg 114 - /* 115 is obsolete vtrace */ -#define SUN_SYS_gettimeofday 116 -#define SUN_SYS_getrusage 117 -#define SUN_SYS_getsockopt 118 -#define SUN_SYS_readv 120 -#define SUN_SYS_writev 121 -#define SUN_SYS_settimeofday 122 -#define SUN_SYS_fchown 123 -#define SUN_SYS_fchmod 124 -#define SUN_SYS_orecvfrom 125 -#define SUN_SYS_osetreuid 126 -#define SUN_SYS_osetregid 127 -#define SUN_SYS_rename 128 -#define SUN_SYS_truncate 129 -#define SUN_SYS_ftruncate 130 -#define SUN_SYS_flock 131 -#define SUN_SYS_sendto 133 -#define SUN_SYS_shutdown 134 -#define SUN_SYS_socketpair 135 -#define SUN_SYS_mkdir 136 -#define SUN_SYS_rmdir 137 -#define SUN_SYS_utimes 138 -#define SUN_SYS_sigreturn 139 -#define SUN_SYS_adjtime 140 -#define SUN_SYS_ogetpeername 141 -#define SUN_SYS_ogethostid 142 -#define SUN_SYS_sun_getrlimit 144 -#define SUN_SYS_sun_setrlimit 145 -#define SUN_SYS_okillpg 146 -#define SUN_SYS_ogetsockname 150 -#define SUN_SYS_sun_nfssvc 155 -#define SUN_SYS_getdirentries 156 -#define SUN_SYS_sun_statfs 157 -#define SUN_SYS_sun_fstatfs 158 -#define SUN_SYS_sun_unmount 159 -#define SUN_SYS_async_daemon 160 -#define SUN_SYS_getfh 161 -#define SUN_SYS_ogetdomainname 162 -#define SUN_SYS_osetdomainname 163 -#define SUN_SYS_sun_quotactl 165 -#define SUN_SYS_sun_exportfs 166 -#define SUN_SYS_sun_mount 167 -#define SUN_SYS_sun_ustat 168 -#define SUN_SYS_semsys 169 -#define SUN_SYS_msgsys 170 -#define SUN_SYS_shmsys 171 -#define SUN_SYS_sun_auditsys 172 -#define SUN_SYS_sun_getdents 174 -#define SUN_SYS_setsid 175 -#define SUN_SYS_fchdir 176 -#define SUN_SYS_sun_fchroot 177 -#define SUN_SYS_sun_sigpending 183 -#define SUN_SYS_setpgid 185 -#define SUN_SYS_sun_sysconf 188 -#define SUN_SYS_sun_uname 189 diff --git a/sys/compat/sunos/sun_syscalls.c b/sys/compat/sunos/sun_syscalls.c deleted file mode 100644 index 319c7b55e12d..000000000000 --- a/sys/compat/sunos/sun_syscalls.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - * System call names. - * - * DO NOT EDIT-- this file is automatically generated. - * created from: NetBSD syscalls.master,v 1.17 1994/06/29 06:30:25 - */ - -char *sun_syscallnames[] = { - "syscall", /* 0 = syscall */ - "exit", /* 1 = exit */ - "fork", /* 2 = fork */ - "read", /* 3 = read */ - "write", /* 4 = write */ - "sun_open", /* 5 = sun_open */ - "close", /* 6 = close */ - "sun_wait4", /* 7 = sun_wait4 */ - "sun_creat", /* 8 = sun_creat */ - "link", /* 9 = link */ - "unlink", /* 10 = unlink */ - "sun_execv", /* 11 = sun_execv */ - "chdir", /* 12 = chdir */ - "old.sun_time", /* 13 = old sun_time */ - "sun_mknod", /* 14 = sun_mknod */ - "chmod", /* 15 = chmod */ - "chown", /* 16 = chown */ - "break", /* 17 = break */ - "old.sun_stat", /* 18 = old sun_stat */ - "lseek", /* 19 = lseek */ - "getpid", /* 20 = getpid */ - "obs_sun_old_mount", /* 21 = obsolete sun_old_mount */ - "#22", /* 22 = System V umount */ - "old.setuid", /* 23 = old setuid */ - "getuid", /* 24 = getuid */ - "old.sun_stime", /* 25 = old sun_stime */ - "#26", /* 26 = sun_ptrace */ - "old.sun_alarm", /* 27 = old sun_alarm */ - "old.sun_fstat", /* 28 = old sun_fstat */ - "old.sun_pause", /* 29 = old sun_pause */ - "old.sun_utime", /* 30 = old sun_utime */ - "#31", /* 31 = was stty */ - "#32", /* 32 = was gtty */ - "access", /* 33 = access */ - "old.sun_nice", /* 34 = old sun_nice */ - "old.sun_ftime", /* 35 = old sun_ftime */ - "sync", /* 36 = sync */ - "kill", /* 37 = kill */ - "stat", /* 38 = stat */ - "old.sun_setpgrp", /* 39 = old sun_setpgrp */ - "lstat", /* 40 = lstat */ - "dup", /* 41 = dup */ - "pipe", /* 42 = pipe */ - "old.sun_times", /* 43 = old sun_times */ - "profil", /* 44 = profil */ - "#45", /* 45 = nosys */ - "old.sun_setgid", /* 46 = old sun_setgid */ - "getgid", /* 47 = getgid */ - "old.sun_ssig", /* 48 = old sun_ssig */ - "#49", /* 49 = reserved for USG */ - "#50", /* 50 = reserved for USG */ - "acct", /* 51 = acct */ - "#52", /* 52 = nosys */ - "sun_mctl", /* 53 = sun_mctl */ - "sun_ioctl", /* 54 = sun_ioctl */ - "reboot", /* 55 = reboot */ - "obs_sun_owait3", /* 56 = obsolete sun_owait3 */ - "symlink", /* 57 = symlink */ - "readlink", /* 58 = readlink */ - "execve", /* 59 = execve */ - "umask", /* 60 = umask */ - "chroot", /* 61 = chroot */ - "ofstat", /* 62 = ofstat */ - "#63", /* 63 = nosys */ - "ogetpagesize", /* 64 = ogetpagesize */ - "sun_omsync", /* 65 = sun_omsync */ - "vfork", /* 66 = vfork */ - "obs_vread", /* 67 = obsolete vread */ - "obs_vwrite", /* 68 = obsolete vwrite */ - "sbrk", /* 69 = sbrk */ - "sstk", /* 70 = sstk */ - "mmap", /* 71 = mmap */ - "vadvise", /* 72 = vadvise */ - "munmap", /* 73 = munmap */ - "mprotect", /* 74 = mprotect */ - "madvise", /* 75 = madvise */ - "sun_vhangup", /* 76 = sun_vhangup */ - "old.vlimit", /* 77 = old vlimit */ - "mincore", /* 78 = mincore */ - "getgroups", /* 79 = getgroups */ - "setgroups", /* 80 = setgroups */ - "getpgrp", /* 81 = getpgrp */ - "sun_setpgid", /* 82 = sun_setpgid */ - "setitimer", /* 83 = setitimer */ - "old.wait", /* 84 = old wait */ - "swapon", /* 85 = swapon */ - "getitimer", /* 86 = getitimer */ - "ogethostname", /* 87 = ogethostname */ - "osethostname", /* 88 = osethostname */ - "ogetdtablesize", /* 89 = ogetdtablesize */ - "dup2", /* 90 = dup2 */ - "#91", /* 91 = getdopt */ - "fcntl", /* 92 = fcntl */ - "select", /* 93 = select */ - "#94", /* 94 = setdopt */ - "fsync", /* 95 = fsync */ - "setpriority", /* 96 = setpriority */ - "socket", /* 97 = socket */ - "connect", /* 98 = connect */ - "oaccept", /* 99 = oaccept */ - "getpriority", /* 100 = getpriority */ - "osend", /* 101 = osend */ - "orecv", /* 102 = orecv */ - "#103", /* 103 = old socketaddr */ - "bind", /* 104 = bind */ - "sun_setsockopt", /* 105 = sun_setsockopt */ - "listen", /* 106 = listen */ - "old.vtimes", /* 107 = old vtimes */ - "osigvec", /* 108 = osigvec */ - "osigblock", /* 109 = osigblock */ - "osigsetmask", /* 110 = osigsetmask */ - "sigsuspend", /* 111 = sigsuspend */ - "osigstack", /* 112 = osigstack */ - "orecvmsg", /* 113 = orecvmsg */ - "osendmsg", /* 114 = osendmsg */ - "obs_vtrace", /* 115 = obsolete vtrace */ - "gettimeofday", /* 116 = gettimeofday */ - "getrusage", /* 117 = getrusage */ - "getsockopt", /* 118 = getsockopt */ - "#119", /* 119 = nosys */ - "readv", /* 120 = readv */ - "writev", /* 121 = writev */ - "settimeofday", /* 122 = settimeofday */ - "fchown", /* 123 = fchown */ - "fchmod", /* 124 = fchmod */ - "orecvfrom", /* 125 = orecvfrom */ - "osetreuid", /* 126 = osetreuid */ - "osetregid", /* 127 = osetregid */ - "rename", /* 128 = rename */ - "truncate", /* 129 = truncate */ - "ftruncate", /* 130 = ftruncate */ - "flock", /* 131 = flock */ - "#132", /* 132 = nosys */ - "sendto", /* 133 = sendto */ - "shutdown", /* 134 = shutdown */ - "socketpair", /* 135 = socketpair */ - "mkdir", /* 136 = mkdir */ - "rmdir", /* 137 = rmdir */ - "utimes", /* 138 = utimes */ - "sigreturn", /* 139 = sigreturn */ - "adjtime", /* 140 = adjtime */ - "ogetpeername", /* 141 = ogetpeername */ - "ogethostid", /* 142 = ogethostid */ - "#143", /* 143 = old sethostid */ - "sun_getrlimit", /* 144 = sun_getrlimit */ - "sun_setrlimit", /* 145 = sun_setrlimit */ - "okillpg", /* 146 = okillpg */ - "#147", /* 147 = nosys */ - "#148", /* 148 = nosys */ - "#149", /* 149 = nosys */ - "ogetsockname", /* 150 = ogetsockname */ - "#151", /* 151 = getmsg */ - "#152", /* 152 = putmsg */ - "#153", /* 153 = poll */ - "#154", /* 154 = nosys */ -#ifdef NFSSERVER - "sun_nfssvc", /* 155 = sun_nfssvc */ -#else - "#155", /* 155 = nosys */ -#endif - "getdirentries", /* 156 = getdirentries */ - "sun_statfs", /* 157 = sun_statfs */ - "sun_fstatfs", /* 158 = sun_fstatfs */ - "sun_unmount", /* 159 = sun_unmount */ -#ifdef NFSCLIENT - "async_daemon", /* 160 = async_daemon */ - "getfh", /* 161 = getfh */ -#else - "#160", /* 160 = nosys */ - "#161", /* 161 = nosys */ -#endif - "ogetdomainname", /* 162 = ogetdomainname */ - "osetdomainname", /* 163 = osetdomainname */ - "#164", /* 164 = rtschedule */ - "sun_quotactl", /* 165 = sun_quotactl */ - "sun_exportfs", /* 166 = sun_exportfs */ - "sun_mount", /* 167 = sun_mount */ - "sun_ustat", /* 168 = sun_ustat */ -#ifdef SYSVSEM - "semsys", /* 169 = semsys */ -#else - "#169", /* 169 = nosys */ -#endif -#ifdef SYSVMSG - "msgsys", /* 170 = msgsys */ -#else - "#170", /* 170 = nosys */ -#endif -#ifdef SYSVSHM - "shmsys", /* 171 = shmsys */ -#else - "#171", /* 171 = nosys */ -#endif - "sun_auditsys", /* 172 = sun_auditsys */ - "#173", /* 173 = rfssys */ - "sun_getdents", /* 174 = sun_getdents */ - "setsid", /* 175 = setsid */ - "fchdir", /* 176 = fchdir */ - "sun_fchroot", /* 177 = sun_fchroot */ - "#178", /* 178 = vpixsys */ - "#179", /* 179 = aioread */ - "#180", /* 180 = aiowrite */ - "#181", /* 181 = aiowait */ - "#182", /* 182 = aiocancel */ - "sun_sigpending", /* 183 = sun_sigpending */ - "#184", /* 184 = nosys */ - "setpgid", /* 185 = setpgid */ - "#186", /* 186 = pathconf */ - "#187", /* 187 = fpathconf */ - "sun_sysconf", /* 188 = sun_sysconf */ - "sun_uname", /* 189 = sun_uname */ -}; diff --git a/sys/compat/sunos/sun_sysent.c b/sys/compat/sunos/sun_sysent.c deleted file mode 100644 index 1fb1d1b51ce6..000000000000 --- a/sys/compat/sunos/sun_sysent.c +++ /dev/null @@ -1,419 +0,0 @@ -/* - * System call switch table. - * - * DO NOT EDIT-- this file is automatically generated. - * created from: NetBSD syscalls.master,v 1.17 1994/06/29 06:30:25 - */ - -#include -#include - -int nosys(); - -int nosys(); -int exit(); -int fork(); -int read(); -int write(); -int sun_open(); -int close(); -int sun_wait4(); -int sun_creat(); -int link(); -int unlink(); -int sun_execv(); -int chdir(); -int sun_mknod(); -int chmod(); -int chown(); -int obreak(); -int olseek(); -int getpid(); -int getuid(); -int access(); -int sync(); -int kill(); -int ostat(); -int olstat(); -int dup(); -int pipe(); -int profil(); -int getgid(); -int acct(); -int sun_mctl(); -int sun_ioctl(); -int reboot(); -int symlink(); -int readlink(); -int execve(); -int umask(); -int chroot(); -int ofstat(); -int ogetpagesize(); -int sun_omsync(); -int vfork(); -int sbrk(); -int sstk(); -int sun_mmap(); -int ovadvise(); -int munmap(); -int mprotect(); -int madvise(); -int sun_vhangup(); -int mincore(); -int getgroups(); -int setgroups(); -int getpgrp(); -int sun_setpgid(); -int setitimer(); -int swapon(); -int getitimer(); -int ogethostname(); -int osethostname(); -int ogetdtablesize(); -int dup2(); -int fcntl(); -int select(); -int fsync(); -int setpriority(); -int socket(); -int connect(); -int oaccept(); -int getpriority(); -int osend(); -int orecv(); -int bind(); -int sun_setsockopt(); -int listen(); -int osigvec(); -int osigblock(); -int osigsetmask(); -int sigsuspend(); -int osigstack(); -int orecvmsg(); -int osendmsg(); -int gettimeofday(); -int getrusage(); -int getsockopt(); -int readv(); -int writev(); -int settimeofday(); -int fchown(); -int fchmod(); -int orecvfrom(); -int osetreuid(); -int osetregid(); -int rename(); -int otruncate(); -int oftruncate(); -int flock(); -int sendto(); -int shutdown(); -int socketpair(); -int mkdir(); -int rmdir(); -int utimes(); -int sigreturn(); -int adjtime(); -int ogetpeername(); -int ogethostid(); -int sun_getrlimit(); -int sun_setrlimit(); -int okillpg(); -int ogetsockname(); -#ifdef NFSSERVER -int sun_nfssvc(); -#else -#endif -int getdirentries(); -int sun_statfs(); -int sun_fstatfs(); -int sun_unmount(); -#ifdef NFSCLIENT -int async_daemon(); -int getfh(); -#else -#endif -int ogetdomainname(); -int osetdomainname(); -int sun_quotactl(); -int sun_exportfs(); -int sun_mount(); -int sun_ustat(); -#ifdef SYSVSEM -int semsys(); -#else -#endif -#ifdef SYSVMSG -int msgsys(); -#else -#endif -#ifdef SYSVSHM -int shmsys(); -#else -#endif -int sun_auditsys(); -int sun_getdents(); -int setsid(); -int fchdir(); -int sun_fchroot(); -int sun_sigpending(); -int setpgid(); -int sun_sysconf(); -int sun_uname(); - -#ifdef XXX_UNUSED -#define compat(n, name) n, __CONCAT(o,name) - -int osun_time(); -int osun_stat(); -int osetuid(); -int osun_stime(); -int osun_alarm(); -int osun_fstat(); -int osun_pause(); -int osun_utime(); -int osun_nice(); -int osun_ftime(); -int osun_setpgrp(); -int osun_times(); -int osun_setgid(); -int osun_ssig(); -int ovlimit(); -int owait(); -int ovtimes(); -#ifdef NFSSERVER -#else -#endif -#ifdef NFSCLIENT -#else -#endif -#ifdef SYSVSEM -#else -#endif -#ifdef SYSVMSG -#else -#endif -#ifdef SYSVSHM -#else -#endif - -#else /* XXX_UNUSED */ -#define compat(n, name) 0, nosys -#endif /* XXX_UNUSED */ - -struct sysent sun_sysent[] = { - { 0, nosys }, /* 0 = syscall */ - { 1, exit }, /* 1 = exit */ - { 0, fork }, /* 2 = fork */ - { 3, read }, /* 3 = read */ - { 3, write }, /* 4 = write */ - { 3, sun_open }, /* 5 = sun_open */ - { 1, close }, /* 6 = close */ - { 4, sun_wait4 }, /* 7 = sun_wait4 */ - { 2, sun_creat }, /* 8 = sun_creat */ - { 2, link }, /* 9 = link */ - { 1, unlink }, /* 10 = unlink */ - { 2, sun_execv }, /* 11 = sun_execv */ - { 1, chdir }, /* 12 = chdir */ - { compat(0,sun_time) }, /* 13 = old sun_time */ - { 3, sun_mknod }, /* 14 = sun_mknod */ - { 2, chmod }, /* 15 = chmod */ - { 3, chown }, /* 16 = chown */ - { 1, obreak }, /* 17 = break */ - { compat(2,sun_stat) }, /* 18 = old sun_stat */ - { 3, olseek }, /* 19 = lseek */ - { 0, getpid }, /* 20 = getpid */ - { 0, nosys }, /* 21 = obsolete sun_old_mount */ - { 0, nosys }, /* 22 = System V umount */ - { compat(1,setuid) }, /* 23 = old setuid */ - { 0, getuid }, /* 24 = getuid */ - { compat(1,sun_stime) }, /* 25 = old sun_stime */ - { 0, nosys }, /* 26 = sun_ptrace */ - { compat(1,sun_alarm) }, /* 27 = old sun_alarm */ - { compat(1,sun_fstat) }, /* 28 = old sun_fstat */ - { compat(0,sun_pause) }, /* 29 = old sun_pause */ - { compat(2,sun_utime) }, /* 30 = old sun_utime */ - { 0, nosys }, /* 31 = was stty */ - { 0, nosys }, /* 32 = was gtty */ - { 2, access }, /* 33 = access */ - { compat(1,sun_nice) }, /* 34 = old sun_nice */ - { compat(1,sun_ftime) }, /* 35 = old sun_ftime */ - { 0, sync }, /* 36 = sync */ - { 2, kill }, /* 37 = kill */ - { 2, ostat }, /* 38 = stat */ - { compat(2,sun_setpgrp) }, /* 39 = old sun_setpgrp */ - { 2, olstat }, /* 40 = lstat */ - { 2, dup }, /* 41 = dup */ - { 0, pipe }, /* 42 = pipe */ - { compat(1,sun_times) }, /* 43 = old sun_times */ - { 4, profil }, /* 44 = profil */ - { 0, nosys }, /* 45 = nosys */ - { compat(1,sun_setgid) }, /* 46 = old sun_setgid */ - { 0, getgid }, /* 47 = getgid */ - { compat(2,sun_ssig) }, /* 48 = old sun_ssig */ - { 0, nosys }, /* 49 = reserved for USG */ - { 0, nosys }, /* 50 = reserved for USG */ - { 1, acct }, /* 51 = acct */ - { 0, nosys }, /* 52 = nosys */ - { 4, sun_mctl }, /* 53 = sun_mctl */ - { 3, sun_ioctl }, /* 54 = sun_ioctl */ - { 2, reboot }, /* 55 = reboot */ - { 0, nosys }, /* 56 = obsolete sun_owait3 */ - { 2, symlink }, /* 57 = symlink */ - { 3, readlink }, /* 58 = readlink */ - { 3, execve }, /* 59 = execve */ - { 1, umask }, /* 60 = umask */ - { 1, chroot }, /* 61 = chroot */ - { 2, ofstat }, /* 62 = ofstat */ - { 0, nosys }, /* 63 = nosys */ - { 0, ogetpagesize }, /* 64 = ogetpagesize */ - { 3, sun_omsync }, /* 65 = sun_omsync */ - { 0, vfork }, /* 66 = vfork */ - { 0, nosys }, /* 67 = obsolete vread */ - { 0, nosys }, /* 68 = obsolete vwrite */ - { 1, sbrk }, /* 69 = sbrk */ - { 1, sstk }, /* 70 = sstk */ - { 6, sun_mmap }, /* 71 = mmap */ - { 1, ovadvise }, /* 72 = vadvise */ - { 2, munmap }, /* 73 = munmap */ - { 3, mprotect }, /* 74 = mprotect */ - { 3, madvise }, /* 75 = madvise */ - { 0, sun_vhangup }, /* 76 = sun_vhangup */ - { compat(0,vlimit) }, /* 77 = old vlimit */ - { 3, mincore }, /* 78 = mincore */ - { 2, getgroups }, /* 79 = getgroups */ - { 2, setgroups }, /* 80 = setgroups */ - { 1, getpgrp }, /* 81 = getpgrp */ - { 2, sun_setpgid }, /* 82 = sun_setpgid */ - { 3, setitimer }, /* 83 = setitimer */ - { compat(0,wait) }, /* 84 = old wait */ - { 1, swapon }, /* 85 = swapon */ - { 2, getitimer }, /* 86 = getitimer */ - { 2, ogethostname }, /* 87 = ogethostname */ - { 2, osethostname }, /* 88 = osethostname */ - { 0, ogetdtablesize }, /* 89 = ogetdtablesize */ - { 2, dup2 }, /* 90 = dup2 */ - { 0, nosys }, /* 91 = getdopt */ - { 3, fcntl }, /* 92 = fcntl */ - { 5, select }, /* 93 = select */ - { 0, nosys }, /* 94 = setdopt */ - { 1, fsync }, /* 95 = fsync */ - { 3, setpriority }, /* 96 = setpriority */ - { 3, socket }, /* 97 = socket */ - { 3, connect }, /* 98 = connect */ - { 3, oaccept }, /* 99 = oaccept */ - { 2, getpriority }, /* 100 = getpriority */ - { 4, osend }, /* 101 = osend */ - { 4, orecv }, /* 102 = orecv */ - { 0, nosys }, /* 103 = old socketaddr */ - { 3, bind }, /* 104 = bind */ - { 5, sun_setsockopt }, /* 105 = sun_setsockopt */ - { 2, listen }, /* 106 = listen */ - { compat(0,vtimes) }, /* 107 = old vtimes */ - { 3, osigvec }, /* 108 = osigvec */ - { 1, osigblock }, /* 109 = osigblock */ - { 1, osigsetmask }, /* 110 = osigsetmask */ - { 1, sigsuspend }, /* 111 = sigsuspend */ - { 2, osigstack }, /* 112 = osigstack */ - { 3, orecvmsg }, /* 113 = orecvmsg */ - { 3, osendmsg }, /* 114 = osendmsg */ - { 0, nosys }, /* 115 = obsolete vtrace */ - { 2, gettimeofday }, /* 116 = gettimeofday */ - { 2, getrusage }, /* 117 = getrusage */ - { 5, getsockopt }, /* 118 = getsockopt */ - { 0, nosys }, /* 119 = nosys */ - { 3, readv }, /* 120 = readv */ - { 3, writev }, /* 121 = writev */ - { 2, settimeofday }, /* 122 = settimeofday */ - { 3, fchown }, /* 123 = fchown */ - { 2, fchmod }, /* 124 = fchmod */ - { 6, orecvfrom }, /* 125 = orecvfrom */ - { 2, osetreuid }, /* 126 = osetreuid */ - { 2, osetregid }, /* 127 = osetregid */ - { 2, rename }, /* 128 = rename */ - { 2, otruncate }, /* 129 = truncate */ - { 2, oftruncate }, /* 130 = ftruncate */ - { 2, flock }, /* 131 = flock */ - { 0, nosys }, /* 132 = nosys */ - { 6, sendto }, /* 133 = sendto */ - { 2, shutdown }, /* 134 = shutdown */ - { 5, socketpair }, /* 135 = socketpair */ - { 2, mkdir }, /* 136 = mkdir */ - { 1, rmdir }, /* 137 = rmdir */ - { 2, utimes }, /* 138 = utimes */ - { 1, sigreturn }, /* 139 = sigreturn */ - { 2, adjtime }, /* 140 = adjtime */ - { 3, ogetpeername }, /* 141 = ogetpeername */ - { 0, ogethostid }, /* 142 = ogethostid */ - { 0, nosys }, /* 143 = old sethostid */ - { 2, sun_getrlimit }, /* 144 = sun_getrlimit */ - { 2, sun_setrlimit }, /* 145 = sun_setrlimit */ - { 2, okillpg }, /* 146 = okillpg */ - { 0, nosys }, /* 147 = nosys */ - { 0, nosys }, /* 148 = nosys */ - { 0, nosys }, /* 149 = nosys */ - { 3, ogetsockname }, /* 150 = ogetsockname */ - { 0, nosys }, /* 151 = getmsg */ - { 0, nosys }, /* 152 = putmsg */ - { 0, nosys }, /* 153 = poll */ - { 0, nosys }, /* 154 = nosys */ -#ifdef NFSSERVER - { 0, sun_nfssvc }, /* 155 = sun_nfssvc */ -#else - { 0, nosys }, /* 155 = nosys */ -#endif - { 4, getdirentries }, /* 156 = getdirentries */ - { 2, sun_statfs }, /* 157 = sun_statfs */ - { 2, sun_fstatfs }, /* 158 = sun_fstatfs */ - { 1, sun_unmount }, /* 159 = sun_unmount */ -#ifdef NFSCLIENT - { 0, async_daemon }, /* 160 = async_daemon */ - { 2, getfh }, /* 161 = getfh */ -#else - { 0, nosys }, /* 160 = nosys */ - { 0, nosys }, /* 161 = nosys */ -#endif - { 2, ogetdomainname }, /* 162 = ogetdomainname */ - { 2, osetdomainname }, /* 163 = osetdomainname */ - { 0, nosys }, /* 164 = rtschedule */ - { 4, sun_quotactl }, /* 165 = sun_quotactl */ - { 2, sun_exportfs }, /* 166 = sun_exportfs */ - { 4, sun_mount }, /* 167 = sun_mount */ - { 2, sun_ustat }, /* 168 = sun_ustat */ -#ifdef SYSVSEM - { 5, semsys }, /* 169 = semsys */ -#else - { 0, nosys }, /* 169 = nosys */ -#endif -#ifdef SYSVMSG - { 6, msgsys }, /* 170 = msgsys */ -#else - { 0, nosys }, /* 170 = nosys */ -#endif -#ifdef SYSVSHM - { 4, shmsys }, /* 171 = shmsys */ -#else - { 0, nosys }, /* 171 = nosys */ -#endif - { 4, sun_auditsys }, /* 172 = sun_auditsys */ - { 0, nosys }, /* 173 = rfssys */ - { 3, sun_getdents }, /* 174 = sun_getdents */ - { 1, setsid }, /* 175 = setsid */ - { 1, fchdir }, /* 176 = fchdir */ - { 1, sun_fchroot }, /* 177 = sun_fchroot */ - { 0, nosys }, /* 178 = vpixsys */ - { 0, nosys }, /* 179 = aioread */ - { 0, nosys }, /* 180 = aiowrite */ - { 0, nosys }, /* 181 = aiowait */ - { 0, nosys }, /* 182 = aiocancel */ - { 1, sun_sigpending }, /* 183 = sun_sigpending */ - { 0, nosys }, /* 184 = nosys */ - { 2, setpgid }, /* 185 = setpgid */ - { 0, nosys }, /* 186 = pathconf */ - { 0, nosys }, /* 187 = fpathconf */ - { 1, sun_sysconf }, /* 188 = sun_sysconf */ - { 1, sun_uname }, /* 189 = sun_uname */ -}; - -int nsun_sysent = sizeof(sun_sysent) / sizeof(sun_sysent[0]); diff --git a/sys/isofs/isofs_node.h b/sys/isofs/isofs_node.h deleted file mode 100644 index 810c85119cb5..000000000000 --- a/sys/isofs/isofs_node.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * $Id: isofs_node.h,v 1.9 1993/12/23 07:37:42 cgd Exp $ - */ - - -typedef struct { - struct timeval iso_atime; /* time of last access */ - struct timeval iso_mtime; /* time of last modification */ - struct timeval iso_ctime; /* time file changed */ - u_short iso_mode; /* files access mode and type */ - uid_t iso_uid; /* owner user id */ - gid_t iso_gid; /* owner group id */ - short iso_links; /* links of file */ - dev_t iso_rdev; /* Major/Minor number for special */ -} ISO_RRIP_INODE; - -#ifdef ISODEVMAP -/* - * FOr device# (major,minor) translation table - */ -struct iso_dnode { - struct iso_dnode *d_chain[2]; /* hash chain, MUST be first */ - dev_t i_dev; /* device where dnode resides */ - ino_t i_number; /* the identity of the inode */ - dev_t d_dev; /* device # for translation */ -}; -#define d_forw d_chain[0] -#define d_back d_chain[1] -#endif - -struct iso_node { - struct iso_node *i_chain[2]; /* hash chain, MUST be first */ - struct vnode *i_vnode; /* vnode associated with this inode */ - struct vnode *i_devvp; /* vnode for block I/O */ - u_long i_flag; /* see below */ - dev_t i_dev; /* device where inode resides */ - ino_t i_number; /* the identity of the inode */ - /* we use the actual starting block of the file */ - struct iso_mnt *i_mnt; /* filesystem associated with this inode */ - struct lockf *i_lockf; /* head of byte-level lock list */ - long i_diroff; /* offset in dir, where we found last entry */ - off_t i_endoff; /* end of useful stuff in directory */ - long i_spare0; - long i_spare1; - - long iso_extent; /* extent of file */ - long i_size; - long iso_start; /* actual start of data of file (may be different */ - /* from iso_extent, if file has extended attributes) */ - ISO_RRIP_INODE inode; -}; - -#define i_forw i_chain[0] -#define i_back i_chain[1] - -/* flags */ -#define ILOCKED 0x0001 /* inode is locked */ -#define IWANT 0x0002 /* some process waiting on lock */ -#define IACC 0x0020 /* inode access time to be updated */ - -#define VTOI(vp) ((struct iso_node *)(vp)->v_data) -#define ITOV(ip) ((ip)->i_vnode) - -#define ISO_ILOCK(ip) iso_ilock(ip) -#define ISO_IUNLOCK(ip) iso_iunlock(ip) - -/* - * Prototypes for ISOFS vnode operations - */ -int isofs_lookup __P((struct vnode *vp, struct nameidata *ndp, struct proc *p)); -int isofs_open __P((struct vnode *vp, int mode, struct ucred *cred, - struct proc *p)); -int isofs_close __P((struct vnode *vp, int fflag, struct ucred *cred, - struct proc *p)); -int isofs_access __P((struct vnode *vp, int mode, struct ucred *cred, - struct proc *p)); -int isofs_getattr __P((struct vnode *vp, struct vattr *vap, struct ucred *cred, - struct proc *p)); -int isofs_read __P((struct vnode *vp, struct uio *uio, int ioflag, - struct ucred *cred)); -int isofs_ioctl __P((struct vnode *vp, int command, caddr_t data, int fflag, - struct ucred *cred, struct proc *p)); -int isofs_select __P((struct vnode *vp, int which, int fflags, struct ucred *cred, - struct proc *p)); -int isofs_mmap __P((struct vnode *vp, int fflags, struct ucred *cred, - struct proc *p)); -int isofs_seek __P((struct vnode *vp, off_t oldoff, off_t newoff, - struct ucred *cred)); -int isofs_readdir __P((struct vnode *vp, struct uio *uio, struct ucred *cred, - int *eofflagp, u_int *cookies, int ncookies)); -int isofs_abortop __P((struct nameidata *ndp)); -int isofs_inactive __P((struct vnode *vp, struct proc *p)); -int isofs_reclaim __P((struct vnode *vp)); -int isofs_lock __P((struct vnode *vp)); -int isofs_unlock __P((struct vnode *vp)); -int isofs_strategy __P((struct buf *bp)); -int isofs_print __P((struct vnode *vp)); -int isofs_islocked __P((struct vnode *vp)); -void isofs_defattr __P((struct iso_directory_record *isodir, - struct iso_node *inop, struct buf *bp)); -void isofs_deftstamp __P((struct iso_directory_record *isodir, - struct iso_node *inop, struct buf *bp)); -#ifdef ISODEVMAP -struct iso_dnode *iso_dmap __P((dev_t dev, ino_t ino, int create)); -void iso_dunmap __P((dev_t dev)); -#endif diff --git a/sys/isofs/isofs_rrip.c b/sys/isofs/isofs_rrip.c deleted file mode 100644 index be5b52b6a35b..000000000000 --- a/sys/isofs/isofs_rrip.c +++ /dev/null @@ -1,680 +0,0 @@ -/* - * Copyright (c) 1993 Atsushi Murai (amurai@spec.co.jp) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Atsushi Murai(amurai@spec.co.jp)``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id: isofs_rrip.c,v 1.8 1994/03/13 17:24:23 ws Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -/* - * POSIX file attribute - */ -static int -isofs_rrip_attr(p,ana) - ISO_RRIP_ATTR *p; - ISO_RRIP_ANALYZE *ana; -{ - ana->inop->inode.iso_mode = isonum_731(p->mode_l); - ana->inop->inode.iso_uid = (uid_t)isonum_731(p->uid_l); - ana->inop->inode.iso_gid = (gid_t)isonum_731(p->gid_l); - ana->inop->inode.iso_links = isonum_731(p->links_l); - ana->fields &= ~ISO_SUSP_ATTR; - return ISO_SUSP_ATTR; -} - -static void -isofs_rrip_defattr(isodir,ana) - struct iso_directory_record *isodir; - ISO_RRIP_ANALYZE *ana; -{ - /* But this is a required field! */ - printf("RRIP without PX field?\n"); - isofs_defattr(isodir,ana->inop,NULL); -} - -/* - * Symbolic Links - */ -static int -isofs_rrip_slink(p,ana) - ISO_RRIP_SLINK *p; - ISO_RRIP_ANALYZE *ana; -{ - register ISO_RRIP_SLINK_COMPONENT *pcomp; - register ISO_RRIP_SLINK_COMPONENT *pcompe; - int len, wlen, cont; - char *outbuf, *inbuf; - - pcomp = (ISO_RRIP_SLINK_COMPONENT *)p->component; - pcompe = (ISO_RRIP_SLINK_COMPONENT *)((char *)p + isonum_711(p->h.length)); - len = *ana->outlen; - outbuf = ana->outbuf; - cont = ana->cont; - - /* - * Gathering a Symbolic name from each component with path - */ - for (; - pcomp < pcompe; - pcomp = (ISO_RRIP_SLINK_COMPONENT *)((char *)pcomp + ISO_RRIP_SLSIZ - + isonum_711(pcomp->clen))) { - - if (!cont) { - if (len < ana->maxlen) { - len++; - *outbuf++ = '/'; - } - } - cont = 0; - - inbuf = ".."; - wlen = 0; - - switch (*pcomp->cflag) { - - case ISO_SUSP_CFLAG_CURRENT: - /* Inserting Current */ - wlen = 1; - break; - - case ISO_SUSP_CFLAG_PARENT: - /* Inserting Parent */ - wlen = 2; - break; - - case ISO_SUSP_CFLAG_ROOT: - /* Inserting slash for ROOT */ - /* start over from beginning(?) */ - outbuf -= len; - len = 0; - break; - - case ISO_SUSP_CFLAG_VOLROOT: - /* Inserting a mount point i.e. "/cdrom" */ - /* same as above */ - outbuf -= len; - len = 0; - inbuf = ana->imp->im_mountp->mnt_stat.f_mntonname; - wlen = strlen(inbuf); - break; - - case ISO_SUSP_CFLAG_HOST: - /* Inserting hostname i.e. "kurt.tools.de" */ - inbuf = hostname; - wlen = hostnamelen; - break; - - case ISO_SUSP_CFLAG_CONTINUE: - cont = 1; - /* fall thru */ - case 0: - /* Inserting component */ - wlen = isonum_711(pcomp->clen); - inbuf = pcomp->name; - break; - default: - printf("RRIP with incorrect flags?"); - wlen = ana->maxlen + 1; - break; - } - - if (len + wlen > ana->maxlen) { - /* indicate error to caller */ - ana->cont = 1; - ana->fields = 0; - ana->outbuf -= *ana->outlen; - *ana->outlen = 0; - return 0; - } - - bcopy(inbuf,outbuf,wlen); - outbuf += wlen; - len += wlen; - - } - ana->outbuf = outbuf; - *ana->outlen = len; - ana->cont = cont; - - if (!isonum_711(p->flags)) { - ana->fields &= ~ISO_SUSP_SLINK; - return ISO_SUSP_SLINK; - } - return 0; -} - -/* - * Alternate name - */ -static int -isofs_rrip_altname(p,ana) - ISO_RRIP_ALTNAME *p; - ISO_RRIP_ANALYZE *ana; -{ - char *inbuf; - int wlen; - int cont; - - inbuf = ".."; - wlen = 0; - cont = 0; - - switch (*p->flags) { - case ISO_SUSP_CFLAG_CURRENT: - /* Inserting Current */ - wlen = 1; - break; - - case ISO_SUSP_CFLAG_PARENT: - /* Inserting Parent */ - wlen = 2; - break; - - case ISO_SUSP_CFLAG_HOST: - /* Inserting hostname i.e. "kurt.tools.de" */ - inbuf = hostname; - wlen = hostnamelen; - break; - - case ISO_SUSP_CFLAG_CONTINUE: - cont = 1; - /* fall thru */ - case 0: - /* Inserting component */ - wlen = isonum_711(p->h.length) - 5; - inbuf = (char *)p + 5; - break; - - default: - printf("RRIP with incorrect NM flags?\n"); - wlen = ana->maxlen + 1; - break; - } - - if ((*ana->outlen += wlen) > ana->maxlen) { - /* treat as no name field */ - ana->fields &= ~ISO_SUSP_ALTNAME; - ana->outbuf -= *ana->outlen - wlen; - *ana->outlen = 0; - return 0; - } - - bcopy(inbuf,ana->outbuf,wlen); - ana->outbuf += wlen; - - if (!cont) { - ana->fields &= ~ISO_SUSP_ALTNAME; - return ISO_SUSP_ALTNAME; - } - return 0; -} - -static void -isofs_rrip_defname(isodir,ana) - struct iso_directory_record *isodir; - ISO_RRIP_ANALYZE *ana; -{ - strcpy(ana->outbuf,".."); - switch (*isodir->name) { - default: - isofntrans(isodir->name,isonum_711(isodir->name_len), - ana->outbuf,ana->outlen, - 1,isonum_711(isodir->flags)&4); - break; - case 0: - *ana->outlen = 1; - break; - case 1: - *ana->outlen = 2; - break; - } -} - -/* - * Parent or Child Link - */ -static int -isofs_rrip_pclink(p,ana) - ISO_RRIP_CLINK *p; - ISO_RRIP_ANALYZE *ana; -{ - *ana->inump = isonum_733(p->dir_loc) << ana->imp->im_bshift; - ana->fields &= ~(ISO_SUSP_CLINK|ISO_SUSP_PLINK); - return *p->h.type == 'C' ? ISO_SUSP_CLINK : ISO_SUSP_PLINK; -} - -/* - * Relocated directory - */ -static int -isofs_rrip_reldir(p,ana) - ISO_RRIP_RELDIR *p; - ISO_RRIP_ANALYZE *ana; -{ - /* special hack to make caller aware of RE field */ - *ana->outlen = 0; - ana->fields = 0; - return ISO_SUSP_RELDIR|ISO_SUSP_ALTNAME|ISO_SUSP_CLINK|ISO_SUSP_PLINK; -} - -static int -isofs_rrip_tstamp(p,ana) - ISO_RRIP_TSTAMP *p; - ISO_RRIP_ANALYZE *ana; -{ - unsigned char *ptime; - - ptime = p->time; - - /* Check a format of time stamp (7bytes/17bytes) */ - if (!(*p->flags&ISO_SUSP_TSTAMP_FORM17)) { - if (*p->flags&ISO_SUSP_TSTAMP_CREAT) - ptime += 7; - - if (*p->flags&ISO_SUSP_TSTAMP_MODIFY) { - isofs_tstamp_conv7(ptime,&ana->inop->inode.iso_mtime); - ptime += 7; - } else - bzero(&ana->inop->inode.iso_mtime,sizeof(struct timeval)); - - if (*p->flags&ISO_SUSP_TSTAMP_ACCESS) { - isofs_tstamp_conv7(ptime,&ana->inop->inode.iso_atime); - ptime += 7; - } else - ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime; - - if (*p->flags&ISO_SUSP_TSTAMP_ATTR) - isofs_tstamp_conv7(ptime,&ana->inop->inode.iso_ctime); - else - ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime; - - } else { - if (*p->flags&ISO_SUSP_TSTAMP_CREAT) - ptime += 17; - - if (*p->flags&ISO_SUSP_TSTAMP_MODIFY) { - isofs_tstamp_conv17(ptime,&ana->inop->inode.iso_mtime); - ptime += 17; - } else - bzero(&ana->inop->inode.iso_mtime,sizeof(struct timeval)); - - if (*p->flags&ISO_SUSP_TSTAMP_ACCESS) { - isofs_tstamp_conv17(ptime,&ana->inop->inode.iso_atime); - ptime += 17; - } else - ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime; - - if (*p->flags&ISO_SUSP_TSTAMP_ATTR) - isofs_tstamp_conv17(ptime,&ana->inop->inode.iso_ctime); - else - ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime; - - } - ana->fields &= ~ISO_SUSP_TSTAMP; - return ISO_SUSP_TSTAMP; -} - -static void -isofs_rrip_deftstamp(isodir,ana) - struct iso_directory_record *isodir; - ISO_RRIP_ANALYZE *ana; -{ - isofs_deftstamp(isodir,ana->inop,NULL); -} - -/* - * POSIX device modes - */ -static int -isofs_rrip_device(p,ana) - ISO_RRIP_DEVICE *p; - ISO_RRIP_ANALYZE *ana; -{ - unsigned high, low; - - high = isonum_733(p->dev_t_high_l); - low = isonum_733(p->dev_t_low_l); - - if (high == 0) - ana->inop->inode.iso_rdev = makedev(major(low),minor(low)); - else - ana->inop->inode.iso_rdev = makedev(high,minor(low)); - ana->fields &= ~ISO_SUSP_DEVICE; - return ISO_SUSP_DEVICE; -} - -/* - * Flag indicating - */ -static int -isofs_rrip_idflag(p,ana) - ISO_RRIP_IDFLAG *p; - ISO_RRIP_ANALYZE *ana; -{ - ana->fields &= isonum_711(p->flags)|~0xff; /* don't touch high bits */ - /* special handling of RE field */ - if (ana->fields&ISO_SUSP_RELDIR) - return isofs_rrip_reldir(p,ana); - - return ISO_SUSP_IDFLAG; -} - -/* - * Continuation pointer - */ -static int -isofs_rrip_cont(p,ana) - ISO_RRIP_CONT *p; - ISO_RRIP_ANALYZE *ana; -{ - ana->iso_ce_blk = isonum_733(p->location); - ana->iso_ce_off = isonum_733(p->offset); - ana->iso_ce_len = isonum_733(p->length); - return ISO_SUSP_CONT; -} - -/* - * System Use end - */ -static int -isofs_rrip_stop(p,ana) - ISO_SUSP_HEADER *p; - ISO_RRIP_ANALYZE *ana; -{ - return ISO_SUSP_STOP; -} - -/* - * Extension reference - */ -static int -isofs_rrip_extref(p,ana) - ISO_RRIP_EXTREF *p; - ISO_RRIP_ANALYZE *ana; -{ - if (isonum_711(p->len_id) != 10 - || bcmp((char *)p + 8,"RRIP_1991A",10) - || isonum_711(p->version) != 1) - return 0; - ana->fields &= ~ISO_SUSP_EXTREF; - return ISO_SUSP_EXTREF; -} - -typedef struct { - char type[2]; - int (*func)(); - void (*func2)(); - int result; -} RRIP_TABLE; - -static int -isofs_rrip_loop(isodir,ana,table) - struct iso_directory_record *isodir; - ISO_RRIP_ANALYZE *ana; - RRIP_TABLE *table; -{ - register RRIP_TABLE *ptable; - register ISO_SUSP_HEADER *phead; - register ISO_SUSP_HEADER *pend; - struct buf *bp = NULL; - int i; - char *pwhead; - int result; - - /* - * Note: If name length is odd, - * it will be padding 1 byte after the name - */ - pwhead = isodir->name + isonum_711(isodir->name_len); - if (!(isonum_711(isodir->name_len)&1)) - pwhead++; - - /* If it's not the '.' entry of the root dir obey SP field */ - if (*isodir->name != 0 - || isonum_733(isodir->extent) != ana->imp->root_extent) - pwhead += ana->imp->rr_skip; - else - pwhead += ana->imp->rr_skip0; - - phead = (ISO_SUSP_HEADER *)pwhead; - pend = (ISO_SUSP_HEADER *)((char *)isodir + isonum_711(isodir->length)); - - result = 0; - while (1) { - ana->iso_ce_len = 0; - /* - * Note: "pend" should be more than one SUSP header - */ - while (pend >= phead + 1) { - if (isonum_711(phead->version) == 1) { - for (ptable = table; ptable->func; ptable++) { - if (*phead->type == *ptable->type - && phead->type[1] == ptable->type[1]) { - result |= ptable->func(phead,ana); - break; - } - } - if (!ana->fields) - break; - } - if (result&ISO_SUSP_STOP) { - result &= ~ISO_SUSP_STOP; - break; - } - /* plausibility check */ - if (isonum_711(phead->length) < sizeof(*phead)) - break; - /* - * move to next SUSP - * Hopefully this works with newer versions, too - */ - phead = (ISO_SUSP_HEADER *)((char *)phead + isonum_711(phead->length)); - } - - if (ana->fields && ana->iso_ce_len) { - if (ana->iso_ce_blk >= ana->imp->volume_space_size - || ana->iso_ce_off + ana->iso_ce_len > ana->imp->logical_block_size - || bread(ana->imp->im_devvp, - ana->iso_ce_blk * ana->imp->logical_block_size / DEV_BSIZE, - ana->imp->logical_block_size,NOCRED,&bp)) - /* what to do now? */ - break; - phead = (ISO_SUSP_HEADER *)(bp->b_un.b_addr + ana->iso_ce_off); - pend = (ISO_SUSP_HEADER *) ((char *)phead + ana->iso_ce_len); - } else - break; - } - if (bp) - brelse(bp); - /* - * If we don't find the Basic SUSP stuffs, just set default value - * (attribute/time stamp) - */ - for (ptable = table; ptable->func2; ptable++) - if (!(ptable->result&result)) - ptable->func2(isodir,ana); - - return result; -} - -/* - * Get Attributes. - */ -static RRIP_TABLE rrip_table_analyze[] = { - { "PX", isofs_rrip_attr, isofs_rrip_defattr, ISO_SUSP_ATTR }, - { "TF", isofs_rrip_tstamp, isofs_rrip_deftstamp, ISO_SUSP_TSTAMP }, - { "PN", isofs_rrip_device, 0, ISO_SUSP_DEVICE }, - { "RR", isofs_rrip_idflag, 0, ISO_SUSP_IDFLAG }, - { "CE", isofs_rrip_cont, 0, ISO_SUSP_CONT }, - { "ST", isofs_rrip_stop, 0, ISO_SUSP_STOP }, - { "", 0, 0, 0 } -}; - -int -isofs_rrip_analyze(isodir,inop,imp) - struct iso_directory_record *isodir; - struct iso_node *inop; - struct iso_mnt *imp; -{ - ISO_RRIP_ANALYZE analyze; - - analyze.inop = inop; - analyze.imp = imp; - analyze.fields = ISO_SUSP_ATTR|ISO_SUSP_TSTAMP|ISO_SUSP_DEVICE; - - return isofs_rrip_loop(isodir,&analyze,rrip_table_analyze); -} - -/* - * Get Alternate Name. - */ -static RRIP_TABLE rrip_table_getname[] = { - { "NM", isofs_rrip_altname, isofs_rrip_defname, ISO_SUSP_ALTNAME }, - { "CL", isofs_rrip_pclink, 0, ISO_SUSP_CLINK|ISO_SUSP_PLINK }, - { "PL", isofs_rrip_pclink, 0, ISO_SUSP_CLINK|ISO_SUSP_PLINK }, - { "RE", isofs_rrip_reldir, 0, ISO_SUSP_RELDIR }, - { "RR", isofs_rrip_idflag, 0, ISO_SUSP_IDFLAG }, - { "CE", isofs_rrip_cont, 0, ISO_SUSP_CONT }, - { "ST", isofs_rrip_stop, 0, ISO_SUSP_STOP }, - { "", 0, 0, 0 } -}; - -int -isofs_rrip_getname(isodir,outbuf,outlen,inump,imp) - struct iso_directory_record *isodir; - char *outbuf; - u_short *outlen; - ino_t *inump; - struct iso_mnt *imp; -{ - ISO_RRIP_ANALYZE analyze; - RRIP_TABLE *tab; - - analyze.outbuf = outbuf; - analyze.outlen = outlen; - analyze.maxlen = NAME_MAX; - analyze.inump = inump; - analyze.imp = imp; - analyze.fields = ISO_SUSP_ALTNAME|ISO_SUSP_RELDIR|ISO_SUSP_CLINK|ISO_SUSP_PLINK; - *outlen = 0; - - tab = rrip_table_getname; - if (*isodir->name == 0 - || *isodir->name == 1) { - isofs_rrip_defname(isodir,&analyze); - - analyze.fields &= ~ISO_SUSP_ALTNAME; - tab++; - } - - return isofs_rrip_loop(isodir,&analyze,tab); -} - -/* - * Get Symbolic Link. - */ -static RRIP_TABLE rrip_table_getsymname[] = { - { "SL", isofs_rrip_slink, 0, ISO_SUSP_SLINK }, - { "RR", isofs_rrip_idflag, 0, ISO_SUSP_IDFLAG }, - { "CE", isofs_rrip_cont, 0, ISO_SUSP_CONT }, - { "ST", isofs_rrip_stop, 0, ISO_SUSP_STOP }, - { "", 0, 0, 0 } -}; - -int -isofs_rrip_getsymname(isodir,outbuf,outlen,imp) - struct iso_directory_record *isodir; - char *outbuf; - u_short *outlen; - struct iso_mnt *imp; -{ - ISO_RRIP_ANALYZE analyze; - - analyze.outbuf = outbuf; - analyze.outlen = outlen; - *outlen = 0; - analyze.maxlen = MAXPATHLEN; - analyze.cont = 1; /* don't start with a slash */ - analyze.imp = imp; - analyze.fields = ISO_SUSP_SLINK; - - return (isofs_rrip_loop(isodir,&analyze,rrip_table_getsymname)&ISO_SUSP_SLINK); -} - -static RRIP_TABLE rrip_table_extref[] = { - { "ER", isofs_rrip_extref, 0, ISO_SUSP_EXTREF }, - { "CE", isofs_rrip_cont, 0, ISO_SUSP_CONT }, - { "ST", isofs_rrip_stop, 0, ISO_SUSP_STOP }, - { "", 0, 0, 0 } -}; - -/* - * Check for Rock Ridge Extension and Return Offset of its Fields. - * Note: We insist on the ER field. - */ -int -isofs_rrip_offset(isodir,imp) - struct iso_directory_record *isodir; - struct iso_mnt *imp; -{ - ISO_RRIP_OFFSET *p; - ISO_RRIP_ANALYZE analyze; - - imp->rr_skip0 = 0; - p = (ISO_RRIP_OFFSET *)(isodir->name + 1); - if (bcmp(p,"SP\7\1\276\357",6)) { - /* Maybe, it's a CDROM XA disc? */ - imp->rr_skip0 = 15; - p = (ISO_RRIP_OFFSET *)((char *)p + 15); - if (bcmp(p,"SP\7\1\276\357",6)) - return -1; - } - - analyze.imp = imp; - analyze.fields = ISO_SUSP_EXTREF; - if (!(isofs_rrip_loop(isodir,&analyze,rrip_table_extref)&ISO_SUSP_EXTREF)) - return -1; - - return isonum_711(p->skip); -} diff --git a/sys/isofs/isofs_rrip.h b/sys/isofs/isofs_rrip.h deleted file mode 100644 index 5ca34ba38d40..000000000000 --- a/sys/isofs/isofs_rrip.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 1993 Atsushi Murai (amurai@spec.co.jp) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Atsushi Murai(amurai@spec.co.jp)``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)isofs_rrip.h - * $Id: isofs_rrip.h,v 1.3 1993/09/07 15:40:58 ws Exp $ - */ - -typedef struct { - char type [ISODCL ( 0, 1)]; - unsigned char length [ISODCL ( 2, 2)]; /* 711 */ - unsigned char version [ISODCL ( 3, 3)]; -} ISO_SUSP_HEADER; - -typedef struct { - ISO_SUSP_HEADER h; - char mode_l [ISODCL ( 4, 7)]; /* 731 */ - char mode_m [ISODCL ( 8, 11)]; /* 732 */ - char links_l [ISODCL ( 12, 15)]; /* 731 */ - char links_m [ISODCL ( 16, 19)]; /* 732 */ - char uid_l [ISODCL ( 20, 23)]; /* 731 */ - char uid_m [ISODCL ( 24, 27)]; /* 732 */ - char gid_l [ISODCL ( 28, 31)]; /* 731 */ - char gid_m [ISODCL ( 32, 35)]; /* 732 */ -} ISO_RRIP_ATTR; - -typedef struct { - ISO_SUSP_HEADER h; - char dev_t_high_l [ISODCL ( 4, 7)]; /* 731 */ - char dev_t_high_m [ISODCL ( 8, 11)]; /* 732 */ - char dev_t_low_l [ISODCL ( 12, 15)]; /* 731 */ - char dev_t_low_m [ISODCL ( 16, 19)]; /* 732 */ -} ISO_RRIP_DEVICE; - -#define ISO_SUSP_CFLAG_CONTINUE 0x01 -#define ISO_SUSP_CFLAG_CURRENT 0x02 -#define ISO_SUSP_CFLAG_PARENT 0x04 -#define ISO_SUSP_CFLAG_ROOT 0x08 -#define ISO_SUSP_CFLAG_VOLROOT 0x10 -#define ISO_SUSP_CFLAG_HOST 0x20 - -typedef struct { - u_char cflag [ISODCL ( 1, 1)]; - u_char clen [ISODCL ( 2, 2)]; - u_char name [0]; -} ISO_RRIP_SLINK_COMPONENT; -#define ISO_RRIP_SLSIZ 2 - -typedef struct { - ISO_SUSP_HEADER h; - u_char flags [ISODCL ( 4, 4)]; - u_char component [ISODCL ( 5, 5)]; -} ISO_RRIP_SLINK; - -typedef struct { - ISO_SUSP_HEADER h; - char flags [ISODCL ( 4, 4)]; -} ISO_RRIP_ALTNAME; - -typedef struct { - ISO_SUSP_HEADER h; - char dir_loc [ISODCL ( 4, 11)]; /* 733 */ -} ISO_RRIP_CLINK; - -typedef struct { - ISO_SUSP_HEADER h; - char dir_loc [ISODCL ( 4, 11)]; /* 733 */ -} ISO_RRIP_PLINK; - -typedef struct { - ISO_SUSP_HEADER h; -} ISO_RRIP_RELDIR; - -#define ISO_SUSP_TSTAMP_FORM17 0x80 -#define ISO_SUSP_TSTAMP_FORM7 0x00 -#define ISO_SUSP_TSTAMP_CREAT 0x01 -#define ISO_SUSP_TSTAMP_MODIFY 0x02 -#define ISO_SUSP_TSTAMP_ACCESS 0x04 -#define ISO_SUSP_TSTAMP_ATTR 0x08 -#define ISO_SUSP_TSTAMP_BACKUP 0x10 -#define ISO_SUSP_TSTAMP_EXPIRE 0x20 -#define ISO_SUSP_TSTAMP_EFFECT 0x40 - -typedef struct { - ISO_SUSP_HEADER h; - unsigned char flags [ISODCL ( 4, 4)]; - unsigned char time [ISODCL ( 5, 5)]; -} ISO_RRIP_TSTAMP; - -typedef struct { - ISO_SUSP_HEADER h; - unsigned char flags [ISODCL ( 4, 4)]; -} ISO_RRIP_IDFLAG; - -typedef struct { - ISO_SUSP_HEADER h; - char len_id [ISODCL ( 4, 4)]; - char len_des [ISODCL ( 5, 5)]; - char len_src [ISODCL ( 6, 6)]; - char version [ISODCL ( 7, 7)]; -} ISO_RRIP_EXTREF; - -typedef struct { - ISO_SUSP_HEADER h; - char check [ISODCL ( 4, 5)]; - char skip [ISODCL ( 6, 6)]; -} ISO_RRIP_OFFSET; - -typedef struct { - ISO_SUSP_HEADER h; - char location [ISODCL ( 4, 11)]; - char offset [ISODCL ( 12, 19)]; - char length [ISODCL ( 20, 27)]; -} ISO_RRIP_CONT; diff --git a/sys/isofs/isofs_util.c b/sys/isofs/isofs_util.c deleted file mode 100644 index 1c7d7a4624fd..000000000000 --- a/sys/isofs/isofs_util.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * $Id: isofs_util.c,v 1.10 1994/05/07 01:22:26 cgd Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include /* XXX */ -#include /* XXX */ - -#include - -#include - -#ifdef __notanymore__ -int -isonum_711 (p) -unsigned char *p; -{ - return (*p); -} - -int -isonum_712 (p) -signed char *p; -{ - return (*p); -} - -int -isonum_721 (p) -unsigned char *p; -{ - /* little endian short */ -#if BYTE_ORDER != LITTLE_ENDIAN - printf ("isonum_721 called on non little-endian machine!\n"); -#endif - - return *(short *)p; -} - -int -isonum_722 (p) -unsigned char *p; -{ - /* big endian short */ -#if BYTE_ORDER != BIG_ENDIAN - printf ("isonum_722 called on non big-endian machine!\n"); -#endif - - return *(short *)p; -} - -int -isonum_723 (p) -unsigned char *p; -{ -#if BYTE_ORDER == BIG_ENDIAN - return isonum_722 (p + 2); -#elif BYTE_ORDER == LITTLE_ENDIAN - return isonum_721 (p); -#else - printf ("isonum_723 unsupported byte order!\n"); - return 0; -#endif -} - -int -isonum_731 (p) -unsigned char *p; -{ - /* little endian long */ -#if BYTE_ORDER != LITTLE_ENDIAN - printf ("isonum_731 called on non little-endian machine!\n"); -#endif - - return *(long *)p; -} - -int -isonum_732 (p) -unsigned char *p; -{ - /* big endian long */ -#if BYTE_ORDER != BIG_ENDIAN - printf ("isonum_732 called on non big-endian machine!\n"); -#endif - - return *(long *)p; -} - -int -isonum_733 (p) -unsigned char *p; -{ -#if BYTE_ORDER == BIG_ENDIAN - return isonum_732 (p + 4); -#elif BYTE_ORDER == LITTLE_ENDIAN - return isonum_731 (p); -#else - printf ("isonum_733 unsupported byte order!\n"); - return 0; -#endif -} -#endif /* __notanymore__ */ - -/* - * translate and compare a filename - * Note: Version number plus ';' may be omitted. - */ -int -isofncmp(unsigned char *fn,int fnlen,unsigned char *isofn,int isolen) -{ - int i, j; - char c; - - while (--fnlen >= 0) { - if (--isolen < 0) - return *fn; - if ((c = *isofn++) == ';') { - switch (*fn++) { - default: - return *--fn; - case 0: - return 0; - case ';': - break; - } - for (i = 0; --fnlen >= 0; i = i * 10 + *fn++ - '0') { - if (*fn < '0' || *fn > '9') { - return -1; - } - } - for (j = 0; --isolen >= 0; j = j * 10 + *isofn++ - '0'); - return i - j; - } - if (c != *fn) { - if (c >= 'A' && c <= 'Z') { - if (c + ('a' - 'A') != *fn) { - if (*fn >= 'a' && *fn <= 'z') - return *fn - ('a' - 'A') - c; - else - return *fn - c; - } - } else - return *fn - c; - } - fn++; - } - if (isolen > 0) { - switch (*isofn) { - default: - return -1; - case '.': - if (isofn[1] != ';') - return -1; - case ';': - return 0; - } - } - return 0; -} - -/* - * translate a filename - */ -void -isofntrans(unsigned char *infn,int infnlen, - unsigned char *outfn,unsigned short *outfnlen, - int original,int assoc) -{ - int fnidx = 0; - - if (assoc) { - *outfn++ = ASSOCCHAR; - fnidx++; - } - for (; fnidx < infnlen; fnidx++) { - char c = *infn++; - - if (!original && c >= 'A' && c <= 'Z') - *outfn++ = c + ('a' - 'A'); - else if (!original && c == '.' && *infn == ';') - break; - else if (!original && c == ';') - break; - else - *outfn++ = c; - } - *outfnlen = fnidx; -} diff --git a/sys/isofs/isofs_vfsops.c b/sys/isofs/isofs_vfsops.c deleted file mode 100644 index e54cfe158948..000000000000 --- a/sys/isofs/isofs_vfsops.c +++ /dev/null @@ -1,590 +0,0 @@ -/* - * $Id: isofs_vfsops.c,v 1.13 1994/04/23 07:54:38 cgd Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include /* XXX */ - -#include -#include - -extern int enodev (); - -struct vfsops isofs_vfsops = { - MOUNT_ISOFS, - isofs_mount, - isofs_start, - isofs_unmount, - isofs_root, - (void *)enodev, /* quotactl */ - isofs_statfs, - isofs_sync, - isofs_fhtovp, - isofs_vptofh, - isofs_init -}; - -/* - * Called by vfs_mountroot when iso is going to be mounted as root. - * - * Name is updated by mount(8) after booting. - */ -#define ROOTNAME "root_device" - -static iso_mountfs(); - -isofs_mountroot() -{ - register struct mount *mp; - extern struct vnode *rootvp; - struct proc *p = curproc; /* XXX */ - struct iso_mnt *imp; - register struct fs *fs; - u_int size; - int error; - struct iso_args args; - - mp = (struct mount *)malloc((u_long)sizeof(struct mount), - M_MOUNT, M_WAITOK); - mp->mnt_op = (struct vfsops *)&isofs_vfsops; - mp->mnt_flag = MNT_RDONLY; - mp->mnt_exroot = 0; - LIST_INIT(&mp->mnt_vnodelist); - args.flags = ISOFSMNT_ROOT; - error = iso_mountfs(rootvp, mp, p, &args); - if (error) { - free((caddr_t)mp, M_MOUNT); - return error; - } - if (error = vfs_lock(mp)) { - (void)isofs_unmount(mp, 0, p); - free((caddr_t)mp, M_MOUNT); - return error; - } - rootfs = mp; - TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); - mp->mnt_vnodecovered = NULLVP; - imp = VFSTOISOFS(mp); - bzero(imp->im_fsmnt, sizeof(imp->im_fsmnt)); - imp->im_fsmnt[0] = '/'; - bcopy((caddr_t)imp->im_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname, - MNAMELEN); - (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, - &size); - bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void) isofs_statfs(mp, &mp->mnt_stat, p); - vfs_unlock(mp); - return 0; -} - -/* - * Flag to allow forcible unmounting. - */ -int iso_doforce = 1; - -/* - * VFS Operations. - * - * mount system call - */ -isofs_mount(mp, path, data, ndp, p) - register struct mount *mp; - char *path; - caddr_t data; - struct nameidata *ndp; - struct proc *p; -{ - struct vnode *devvp; - struct iso_args args; - u_int size; - int error; - struct iso_mnt *imp; - - if (error = copyin(data, (caddr_t)&args, sizeof (struct iso_args))) - return error; - - if ((mp->mnt_flag & MNT_RDONLY) == 0) - return EROFS; - - /* - * If updating, check whether changing from read-only to - * read/write; if there is no device name, that's all we do. - */ - if (mp->mnt_flag & MNT_UPDATE) { - imp = VFSTOISOFS(mp); - if (args.fspec == 0) - return 0; - } - /* - * Not an update, or updating the name: look up the name - * and verify that it refers to a sensible block device. - */ - ndp->ni_nameiop = LOOKUP | FOLLOW; - ndp->ni_segflg = UIO_USERSPACE; - ndp->ni_dirp = args.fspec; - if (error = namei(ndp, p)) - return error; - devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { - vrele(devvp); - return ENOTBLK; - } - if (major(devvp->v_rdev) >= nblkdev) { - vrele(devvp); - return ENXIO; - } - - if ((mp->mnt_flag & MNT_UPDATE) == 0) - error = iso_mountfs(devvp, mp, p, &args); - else { - if (devvp != imp->im_devvp) - error = EINVAL; /* needs translation */ - else - vrele(devvp); - } - if (error) { - vrele(devvp); - return error; - } - imp = VFSTOISOFS(mp); - - (void) copyinstr(path, imp->im_fsmnt, sizeof(imp->im_fsmnt)-1, &size); - bzero(imp->im_fsmnt + size, sizeof(imp->im_fsmnt) - size); - bcopy((caddr_t)imp->im_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname, - MNAMELEN); - (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, - &size); - bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void) isofs_statfs(mp, &mp->mnt_stat, p); - return 0; -} - -/* - * Common code for mount and mountroot - */ -static iso_mountfs(devvp, mp, p, argp) - register struct vnode *devvp; - struct mount *mp; - struct proc *p; - struct iso_args *argp; -{ - register struct iso_mnt *isomp = (struct iso_mnt *)0; - struct buf *bp = NULL; - dev_t dev = devvp->v_rdev; - caddr_t base, space; - int havepart = 0, blks; - int error = EINVAL, i, size; - int needclose = 0; - int ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - extern struct vnode *rootvp; - int j; - int iso_bsize; - int iso_blknum; - struct iso_volume_descriptor *vdp; - struct iso_primary_descriptor *pri; - struct iso_directory_record *rootp; - int logical_block_size; - - if (!ronly) - return EROFS; - - /* - * Disallow multiple mounts of the same device. - * Disallow mounting of a device that is currently in use - * (except for root, which might share swap device for miniroot). - * Flush out any old buffers remaining from a previous use. - */ - if (error = mountedon(devvp)) - return error; - if (vcount(devvp) > 1 && devvp != rootvp) - return EBUSY; - vinvalbuf(devvp, 1); - if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p)) - return error; - needclose = 1; - - /* This is the "logical sector size". The standard says this - * should be 2048 or the physical sector size on the device, - * whichever is greater. For now, we'll just use a constant. - */ - iso_bsize = 2048; - - for (iso_blknum = 16; iso_blknum < 100; iso_blknum++) { - if (error = bread (devvp, iso_blknum * iso_bsize / DEV_BSIZE, - iso_bsize, NOCRED, &bp)) - goto out; - - vdp = (struct iso_volume_descriptor *)bp->b_un.b_addr; - if (bcmp (vdp->id, ISO_STANDARD_ID, sizeof vdp->id) != 0) { - error = EINVAL; - goto out; - } - - if (isonum_711 (vdp->type) == ISO_VD_END) { - error = EINVAL; - goto out; - } - - if (isonum_711 (vdp->type) == ISO_VD_PRIMARY) - break; - brelse(bp); - } - - if (isonum_711 (vdp->type) != ISO_VD_PRIMARY) { - error = EINVAL; - goto out; - } - - pri = (struct iso_primary_descriptor *)vdp; - - logical_block_size = isonum_723 (pri->logical_block_size); - - if (logical_block_size < DEV_BSIZE - || logical_block_size >= MAXBSIZE - || (logical_block_size & (logical_block_size - 1)) != 0) { - error = EINVAL; - goto out; - } - - rootp = (struct iso_directory_record *)pri->root_directory_record; - - isomp = (struct iso_mnt *)malloc(sizeof *isomp,M_ISOFSMNT,M_WAITOK); - isomp->logical_block_size = logical_block_size; - isomp->volume_space_size = isonum_733 (pri->volume_space_size); - bcopy (rootp, isomp->root, sizeof isomp->root); - isomp->root_extent = isonum_733 (rootp->extent); - isomp->root_size = isonum_733 (rootp->size); - - isomp->im_bmask = logical_block_size - 1; - isomp->im_bshift = 0; - while ((1 << isomp->im_bshift) < isomp->logical_block_size) - isomp->im_bshift++; - - bp->b_flags |= B_AGE; - brelse(bp); - bp = NULL; - - mp->mnt_data = (qaddr_t)isomp; - mp->mnt_stat.f_fsid.val[0] = (long)dev; - mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_ISOFS); - mp->mnt_flag |= MNT_LOCAL; - isomp->im_mountp = mp; - isomp->im_dev = dev; - isomp->im_devvp = devvp; - - devvp->v_specflags |= SI_MOUNTEDON; - - /* Check the Rock Ridge Extention support */ - if (!(argp->flags & ISOFSMNT_NORRIP)) { - if (error = bread (isomp->im_devvp, - (isomp->root_extent + isonum_711(rootp->ext_attr_length)) - * isomp->logical_block_size / DEV_BSIZE, - isomp->logical_block_size,NOCRED,&bp)) - goto out; - - rootp = (struct iso_directory_record *)bp->b_un.b_addr; - - if ((isomp->rr_skip = isofs_rrip_offset(rootp,isomp)) < 0) { - argp->flags |= ISOFSMNT_NORRIP; - } else { - argp->flags &= ~ISOFSMNT_GENS; - } - - /* - * The contents are valid, - * but they will get reread as part of another vnode, so... - */ - bp->b_flags |= B_AGE; - brelse(bp); - bp = NULL; - } - isomp->im_flags = argp->flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS|ISOFSMNT_EXTATT); - switch (isomp->im_flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS)) { - default: - isomp->iso_ftype = ISO_FTYPE_DEFAULT; - break; - case ISOFSMNT_GENS|ISOFSMNT_NORRIP: - isomp->iso_ftype = ISO_FTYPE_9660; - break; - case 0: - isomp->iso_ftype = ISO_FTYPE_RRIP; - break; - } - - return 0; -out: - if (bp) - brelse(bp); - if (needclose) - (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p); - if (isomp) { - free((caddr_t)isomp, M_ISOFSMNT); - mp->mnt_data = (qaddr_t)0; - } - return error; -} - -/* - * Make a filesystem operational. - * Nothing to do at the moment. - */ -/* ARGSUSED */ -isofs_start(mp, flags, p) - struct mount *mp; - int flags; - struct proc *p; -{ - return 0; -} - -/* - * unmount system call - */ -isofs_unmount(mp, mntflags, p) - struct mount *mp; - int mntflags; - struct proc *p; -{ - register struct iso_mnt *isomp; - int i, error, ronly, flags = 0; - - if (mntflags & MNT_FORCE) { - if (!iso_doforce || mp == rootfs) - return EINVAL; - flags |= FORCECLOSE; - } - mntflushbuf(mp, 0); - if (mntinvalbuf(mp)) - return EBUSY; - isomp = VFSTOISOFS(mp); - - if (error = vflush(mp, NULLVP, flags)) - return error; -#ifdef ISODEVMAP - if (isomp->iso_ftype == ISO_FTYPE_RRIP) - iso_dunmap(isomp->im_dev); -#endif - - isomp->im_devvp->v_specflags &= ~SI_MOUNTEDON; - error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED, p); - vrele(isomp->im_devvp); - free((caddr_t)isomp, M_ISOFSMNT); - mp->mnt_data = (qaddr_t)0; - mp->mnt_flag &= ~MNT_LOCAL; - return error; -} - -/* - * Return root of a filesystem - */ -isofs_root(mp, vpp) - struct mount *mp; - struct vnode **vpp; -{ - register struct iso_node *ip; - struct iso_node *nip; - struct vnode tvp; - int error; - struct iso_mnt *imp = VFSTOISOFS (mp); - struct iso_directory_record *dp; - - tvp.v_mount = mp; - ip = VTOI(&tvp); - ip->i_vnode = &tvp; - ip->i_dev = imp->im_dev; - ip->i_diroff = 0; - dp = (struct iso_directory_record *)imp->root; - isodirino(&ip->i_number,dp,imp); - - /* - * With RRIP we must use the `.' entry of the root directory. - * Simply tell iget, that it's a relocated directory. - */ - error = iso_iget(ip,ip->i_number, - imp->iso_ftype == ISO_FTYPE_RRIP, - &nip,dp); - if (error) - return error; - *vpp = ITOV(nip); - return 0; -} - -/* - * Get file system statistics. - */ -isofs_statfs(mp, sbp, p) - struct mount *mp; - register struct statfs *sbp; - struct proc *p; -{ - register struct iso_mnt *isomp; - register struct fs *fs; - - isomp = VFSTOISOFS(mp); - -#ifdef COMPAT_09 - sbp->f_type = 5; /* XXX */ -#else - sbp->f_type = 0; -#endif - sbp->f_bsize = isomp->logical_block_size; - sbp->f_iosize = sbp->f_bsize; - sbp->f_blocks = isomp->volume_space_size; - sbp->f_bfree = 0; /* total free blocks */ - sbp->f_bavail = 0; /* blocks free for non superuser */ - sbp->f_files = 0; /* total files */ - sbp->f_ffree = 0; /* free file nodes */ - if (sbp != &mp->mnt_stat) { - bcopy((caddr_t)mp->mnt_stat.f_mntonname, - (caddr_t)&sbp->f_mntonname[0], MNAMELEN); - bcopy((caddr_t)mp->mnt_stat.f_mntfromname, - (caddr_t)&sbp->f_mntfromname[0], MNAMELEN); - } - /* Use the first spare for flags: */ - sbp->f_spare[0] = isomp->im_flags; - strncpy(&sbp->f_fstypename[0], mp->mnt_op->vfs_name, MFSNAMELEN); - sbp->f_fstypename[MFSNAMELEN] = '\0'; - return 0; -} - -isofs_sync(mp, waitfor) - struct mount *mp; - int waitfor; -{ - return 0; -} - -/* - * File handle to vnode - * - * Have to be really careful about stale file handles: - * - check that the inode number is in range - * - call iget() to get the locked inode - * - check for an unallocated inode (i_mode == 0) - * - check that the generation number matches - */ - -struct ifid { - ushort ifid_len; - ushort ifid_pad; - int ifid_ino; - off_t ifid_start; -}; - -isofs_fhtovp(mp, fhp, vpp) - register struct mount *mp; - struct fid *fhp; - struct vnode **vpp; -{ - /* here's a guess at what we need here */ - struct vnode tvp; - int error; - int lbn, off; - struct ifid *ifhp; - struct iso_mnt *imp; - struct buf *bp; - struct iso_directory_record *dirp; - struct iso_node *ip, *nip; - - ifhp = (struct ifid *)fhp; - imp = VFSTOISOFS (mp); - -#ifdef ISOFS_DBG - printf("fhtovp: ino %d, start %ld\n",ifhp->ifid_ino,ifhp->ifid_start); -#endif - - lbn = ifhp->ifid_ino >> imp->im_bshift; - off = ifhp->ifid_ino & imp->im_bmask; - - if (lbn >= imp->volume_space_size) { - printf("fhtovp: lbn exceed volume space %d\n",lbn); - return EINVAL; - } - - if (off + ISO_DIRECTORY_RECORD_SIZE > imp->logical_block_size) { - printf("fhtovp: across the block boundary %d\n", - off + ISO_DIRECTORY_RECORD_SIZE); - return EINVAL; - } - - if (error = bread(imp->im_devvp, - lbn * imp->logical_block_size / DEV_BSIZE, - imp->logical_block_size, - NOCRED,&bp)) { - printf("fhtovp: bread error %d\n",error); - brelse(bp); - return EINVAL; - } - - dirp = (struct iso_directory_record *)(bp->b_un.b_addr + off); - - if (off + isonum_711(dirp->length) > imp->logical_block_size) { - brelse(bp); - printf("fhtovp: directory across the block boundary %d[off=%d/len=%d]\n", - off + isonum_711(dirp->length),off,isonum_711(dirp->length)); - return EINVAL; - } - - if (isonum_733(dirp->extent) + isonum_711(dirp->ext_attr_length) - != ifhp->ifid_start) { - brelse(bp); - printf("fhtovp: file start miss %d vs %d\n", - isonum_733(dirp->extent) + isonum_711(dirp->ext_attr_length), - ifhp->ifid_start); - return EINVAL; - } - - tvp.v_mount = mp; - ip = VTOI(&tvp); - ip->i_vnode = &tvp; - ip->i_dev = imp->im_dev; - if (error = iso_iget(ip,ifhp->ifid_ino,0,&nip,dirp)) { - *vpp = NULLVP; - brelse(bp); - printf("fhtovp: failed to get ino\n"); - return error; - } - ip = nip; - *vpp = ITOV(ip); - brelse(bp); - return 0; -} - -/* - * Vnode pointer to File handle - */ -/* ARGSUSED */ -isofs_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - register struct iso_node *ip = VTOI(vp); - register struct ifid *ifhp; - register struct iso_mnt *mp = ip->i_mnt; - - ifhp = (struct ifid *)fhp; - ifhp->ifid_len = sizeof(struct ifid); - - ifhp->ifid_ino = ip->i_number; - ifhp->ifid_start = ip->iso_start; - -#ifdef ISOFS_DBG - printf("vptofh: ino %d, start %ld\n", - ifhp->ifid_ino,ifhp->ifid_start); -#endif - return 0; -} diff --git a/sys/isofs/isofs_vnops.c b/sys/isofs/isofs_vnops.c deleted file mode 100644 index a4e462251bac..000000000000 --- a/sys/isofs/isofs_vnops.c +++ /dev/null @@ -1,842 +0,0 @@ -/* - * $Id: isofs_vnops.c,v 1.18 1994/05/24 02:38:39 cgd Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include /* XXX */ -#include /* XXX */ - -#include -#include -#include - -/* - * Mknod vnode call - * Actually remap the device number - */ -/* ARGSUSED */ -isofs_mknod(ndp, vap, cred, p) - struct nameidata *ndp; - struct ucred *cred; - struct vattr *vap; - struct proc *p; -{ -#ifndef ISODEVMAP - free(ndp->ni_pnbuf, M_NAMEI); - vput(ndp->ni_dvp); - vput(ndp->ni_vp); - return EINVAL; -#else - register struct vnode *vp; - struct iso_node *ip; - struct iso_dnode *dp; - int error; - - vp = ndp->ni_vp; - ip = VTOI(vp); - - if (ip->i_mnt->iso_ftype != ISO_FTYPE_RRIP - || vap->va_type != vp->v_type - || (vap->va_type != VCHR && vap->va_type != VBLK)) { - free(ndp->ni_pnbuf, M_NAMEI); - vput(ndp->ni_dvp); - vput(ndp->ni_vp); - return EINVAL; - } - - dp = iso_dmap(ip->i_dev,ip->i_number,1); - if (ip->inode.iso_rdev == vap->va_rdev || vap->va_rdev == VNOVAL) { - /* same as the unmapped one, delete the mapping */ - remque(dp); - FREE(dp,M_CACHE); - } else - /* enter new mapping */ - dp->d_dev = vap->va_rdev; - - /* - * Remove inode so that it will be reloaded by iget and - * checked to see if it is an alias of an existing entry - * in the inode cache. - */ - vput(vp); - vp->v_type = VNON; - vgone(vp); - return (0); -#endif -} - -/* - * Open called. - * - * Nothing to do. - */ -/* ARGSUSED */ -isofs_open(vp, mode, cred, p) - struct vnode *vp; - int mode; - struct ucred *cred; - struct proc *p; -{ - return (0); -} - -/* - * Close called - * - * Update the times on the inode on writeable file systems. - */ -/* ARGSUSED */ -isofs_close(vp, fflag, cred, p) - struct vnode *vp; - int fflag; - struct ucred *cred; - struct proc *p; -{ - return (0); -} - -/* - * Check mode permission on inode pointer. Mode is READ, WRITE or EXEC. - * The mode is shifted to select the owner/group/other fields. The - * super user is granted all permissions. - */ -isofs_access(vp, mode, cred, p) - struct vnode *vp; - register int mode; - struct ucred *cred; - struct proc *p; -{ - register struct iso_node *ip = VTOI(vp); - register gid_t *gp; - int i; - - if (cred->cr_uid == 0) - return 0; - if (cred->cr_uid != ip->inode.iso_uid) { - mode >>= 3; - gp = cred->cr_groups; - for (i = 0; i < cred->cr_ngroups; i++, gp++) - if (ip->inode.iso_gid == *gp) - goto found; - mode >>= 3; -found: - ; - } - return (ip->inode.iso_mode & mode) == mode ? 0 : EACCES; -} - -/* ARGSUSED */ -isofs_getattr(vp, vap, cred, p) - struct vnode *vp; - register struct vattr *vap; - struct ucred *cred; - struct proc *p; -{ - register struct iso_node *ip = VTOI(vp); - int i; - - vap->va_fsid = ip->i_dev; - vap->va_fileid = ip->i_number; - - vap->va_mode = ip->inode.iso_mode; - vap->va_nlink = ip->inode.iso_links; - vap->va_uid = ip->inode.iso_uid; - vap->va_gid = ip->inode.iso_gid; - TIMEVAL_TO_TIMESPEC(&ip->inode.iso_atime, &vap->va_atime); - TIMEVAL_TO_TIMESPEC(&ip->inode.iso_mtime, &vap->va_mtime); - TIMEVAL_TO_TIMESPEC(&ip->inode.iso_ctime, &vap->va_ctime); - vap->va_rdev = ip->inode.iso_rdev; - - vap->va_size = ip->i_size; - vap->va_flags = 0; - vap->va_gen = 1; - vap->va_blocksize = ip->i_mnt->logical_block_size; - vap->va_bytes = ip->i_size; - vap->va_type = vp->v_type; - return (0); -} - -/* - * Vnode op for reading. - */ -/* ARGSUSED */ -isofs_read(vp, uio, ioflag, cred) - struct vnode *vp; - register struct uio *uio; - int ioflag; - struct ucred *cred; -{ - register struct iso_node *ip = VTOI(vp); - register struct iso_mnt *imp; - struct buf *bp; - daddr_t lbn, bn, rablock; - int size, diff, error = 0; - long n, on, type; - - if (uio->uio_resid == 0) - return (0); - if (uio->uio_offset < 0) - return (EINVAL); - ip->i_flag |= IACC; - imp = ip->i_mnt; - do { - lbn = iso_lblkno(imp, uio->uio_offset); - on = iso_blkoff(imp, uio->uio_offset); - n = min((unsigned)(imp->logical_block_size - on), uio->uio_resid); - diff = ip->i_size - uio->uio_offset; - if (diff <= 0) - return (0); - if (diff < n) - n = diff; - size = iso_blksize(imp, ip, lbn); - rablock = lbn + 1; - if (vp->v_lastr + 1 == lbn && - iso_lblktosize(imp, rablock) < ip->i_size) - error = breada(ITOV(ip), lbn, size, rablock, - iso_blksize(imp, ip, rablock), NOCRED, &bp); - else - error = bread(ITOV(ip), lbn, size, NOCRED, &bp); - vp->v_lastr = lbn; - n = min(n, size - bp->b_resid); - if (error) { - brelse(bp); - return (error); - } - - error = uiomove(bp->b_un.b_addr + on, (int)n, uio); - if (n + on == imp->logical_block_size || uio->uio_offset == ip->i_size) - bp->b_flags |= B_AGE; - brelse(bp); - } while (error == 0 && uio->uio_resid > 0 && n != 0); - return (error); -} - -/* ARGSUSED */ -isofs_ioctl(vp, com, data, fflag, cred, p) - struct vnode *vp; - int com; - caddr_t data; - int fflag; - struct ucred *cred; - struct proc *p; -{ - printf("You did ioctl for isofs !!\n"); - return (ENOTTY); -} - -/* ARGSUSED */ -isofs_select(vp, which, fflags, cred, p) - struct vnode *vp; - int which, fflags; - struct ucred *cred; - struct proc *p; -{ - - /* - * We should really check to see if I/O is possible. - */ - return (1); -} - -/* - * Mmap a file - * - * NB Currently unsupported. - */ -/* ARGSUSED */ -isofs_mmap(vp, fflags, cred, p) - struct vnode *vp; - int fflags; - struct ucred *cred; - struct proc *p; -{ - - return (EINVAL); -} - -/* - * Seek on a file - * - * Nothing to do, so just return. - */ -/* ARGSUSED */ -isofs_seek(vp, oldoff, newoff, cred) - struct vnode *vp; - off_t oldoff, newoff; - struct ucred *cred; -{ - - return (0); -} - -/* - * Structure for reading directories - */ -struct isoreaddir { - struct dirent saveent; - struct dirent assocent; - struct dirent current; - off_t saveoff; - off_t assocoff; - off_t curroff; - struct uio *uio; - off_t uio_off; - u_int *cookiep; - int ncookies; - int eof; -}; - -static int -iso_uiodir(idp,dp,off) - struct isoreaddir *idp; - struct dirent *dp; - off_t off; -{ - int error; - - dp->d_name[dp->d_namlen] = 0; - dp->d_reclen = DIRSIZ(dp); - - if (idp->uio->uio_resid < dp->d_reclen) { - idp->eof = 0; - return -1; - } - - if (idp->cookiep) { - if (idp->ncookies <= 0) { - idp->eof = 0; - return -1; - } - - *idp->cookiep++ = off; - --idp->ncookies; - } - - if (error = uiomove(dp,dp->d_reclen,idp->uio)) - return error; - idp->uio_off = off; - return 0; -} - -static int -iso_shipdir(idp) - struct isoreaddir *idp; -{ - struct dirent *dp; - int cl, sl, assoc; - int error; - char *cname, *sname; - - cl = idp->current.d_namlen; - cname = idp->current.d_name; - if (assoc = cl > 1 && *cname == ASSOCCHAR) { - cl--; - cname++; - } - - dp = &idp->saveent; - sname = dp->d_name; - if (!(sl = dp->d_namlen)) { - dp = &idp->assocent; - sname = dp->d_name + 1; - sl = dp->d_namlen - 1; - } - if (sl > 0) { - if (sl != cl - || bcmp(sname,cname,sl)) { - if (idp->assocent.d_namlen) { - if (error = iso_uiodir(idp,&idp->assocent,idp->assocoff)) - return error; - idp->assocent.d_namlen = 0; - } - if (idp->saveent.d_namlen) { - if (error = iso_uiodir(idp,&idp->saveent,idp->saveoff)) - return error; - idp->saveent.d_namlen = 0; - } - } - } - idp->current.d_reclen = DIRSIZ(&idp->current); - if (assoc) { - idp->assocoff = idp->curroff; - bcopy(&idp->current,&idp->assocent,idp->current.d_reclen); - } else { - idp->saveoff = idp->curroff; - bcopy(&idp->current,&idp->saveent,idp->current.d_reclen); - } - return 0; -} - -/* - * Vnode op for readdir - */ -isofs_readdir(vp, uio, cred, eofflagp, cookies, ncookies) - struct vnode *vp; - register struct uio *uio; - struct ucred *cred; - int *eofflagp; - u_int *cookies; - int ncookies; -{ - struct isoreaddir *idp; - int entryoffsetinblock; - int error = 0; - int endsearch; - struct iso_directory_record *ep; - int reclen; - struct iso_mnt *imp; - struct iso_node *ip; - struct buf *bp = NULL; - - ip = VTOI (vp); - imp = ip->i_mnt; - - MALLOC(idp,struct isoreaddir *,sizeof(*idp),M_TEMP,M_WAITOK); - idp->saveent.d_namlen = 0; - idp->assocent.d_namlen = 0; - idp->uio = uio; - idp->cookiep = cookies; - idp->ncookies = ncookies; - idp->curroff = uio->uio_offset; - idp->eof = 1; - - entryoffsetinblock = iso_blkoff(imp, idp->curroff); - if (entryoffsetinblock != 0) { - if (error = iso_blkatoff(ip, idp->curroff, &bp)) { - FREE(idp,M_TEMP); - return (error); - } - } - - endsearch = ip->i_size; - - while (idp->curroff < endsearch) { - /* - * If offset is on a block boundary, - * read the next directory block. - * Release previous if it exists. - */ - - if (iso_blkoff(imp, idp->curroff) == 0) { - if (bp != NULL) - brelse(bp); - if (error = iso_blkatoff(ip, idp->curroff, &bp)) - break; - entryoffsetinblock = 0; - } - /* - * Get pointer to next entry. - */ - - ep = (struct iso_directory_record *) - (bp->b_un.b_addr + entryoffsetinblock); - - reclen = isonum_711 (ep->length); - if (reclen == 0) { - /* skip to next block, if any */ - idp->curroff = roundup (idp->curroff, - imp->logical_block_size); - continue; - } - - if (reclen < ISO_DIRECTORY_RECORD_SIZE) { - error = EINVAL; - /* illegal entry, stop */ - break; - } - - if (entryoffsetinblock + reclen > imp->logical_block_size) { - error = EINVAL; - /* illegal directory, so stop looking */ - break; - } - - idp->current.d_namlen = isonum_711 (ep->name_len); - if (isonum_711(ep->flags)&2) - isodirino(&idp->current.d_fileno,ep,imp); - else - idp->current.d_fileno = (bp->b_blkno << DEV_BSHIFT) + idp->curroff; - - if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) { - error = EINVAL; - /* illegal entry, stop */ - break; - } - - idp->curroff += reclen; - /* - * - */ - switch (imp->iso_ftype) { - case ISO_FTYPE_RRIP: - isofs_rrip_getname(ep,idp->current.d_name, - &idp->current.d_namlen, - &idp->current.d_fileno,imp); - if (idp->current.d_namlen) - error = iso_uiodir(idp,&idp->current,idp->curroff); - break; - default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 */ - strcpy(idp->current.d_name,".."); - switch (ep->name[0]) { - case 0: - idp->current.d_namlen = 1; - error = iso_uiodir(idp,&idp->current,idp->curroff); - break; - case 1: - idp->current.d_namlen = 2; - error = iso_uiodir(idp,&idp->current,idp->curroff); - break; - default: - isofntrans(ep->name,idp->current.d_namlen, - idp->current.d_name,&idp->current.d_namlen, - imp->iso_ftype == ISO_FTYPE_9660, - isonum_711(ep->flags)&4); - if (imp->iso_ftype == ISO_FTYPE_DEFAULT) - error = iso_shipdir(idp); - else - error = iso_uiodir(idp,&idp->current,idp->curroff); - break; - } - } - if (error) - break; - - entryoffsetinblock += reclen; - } - - if (!error && imp->iso_ftype == ISO_FTYPE_DEFAULT) { - idp->current.d_namlen = 0; - error = iso_shipdir(idp); - } - if (error < 0) - error = 0; - - if (bp) - brelse (bp); - - uio->uio_offset = idp->uio_off; - *eofflagp = idp->eof; - - FREE(idp,M_TEMP); - - return (error); -} - -/* - * Return target name of a symbolic link - * Shouldn't we get the parent vnode and read the data from there? - * This could eventually result in deadlocks in isofs_lookup. - * But otherwise the block read here is in the block buffer two times. - */ -typedef struct iso_directory_record ISODIR; -typedef struct iso_node ISONODE; -typedef struct iso_mnt ISOMNT; -int isofs_readlink(vp, uio, cred) - struct vnode *vp; - struct uio *uio; - struct ucred *cred; -{ - ISONODE *ip; - ISODIR *dirp; - ISOMNT *imp; - struct buf *bp; - u_short symlen; - int error; - char *symname; - ino_t ino; - - ip = VTOI(vp); - imp = ip->i_mnt; - - if (imp->iso_ftype != ISO_FTYPE_RRIP) - return EINVAL; - - /* - * Get parents directory record block that this inode included. - */ - error = bread(imp->im_devvp, - (daddr_t)((ip->i_number&~imp->im_bmask) / DEV_BSIZE), - imp->logical_block_size, - NOCRED, - &bp); - if (error) { - brelse(bp); - return EINVAL; - } - - /* - * Setup the directory pointer for this inode - */ - dirp = (ISODIR *)(bp->b_un.b_addr + (ip->i_number & imp->im_bmask)); -#ifdef DEBUG - printf("lbn=%d,off=%d,bsize=%d,DEV_BSIZE=%d, dirp= %08x, b_addr=%08x, offset=%08x(%08x)\n", - (daddr_t)(ip->i_number >> imp->im_bshift), - ip->i_number & imp->im_bmask, - imp->logical_block_size, - DEV_BSIZE, - dirp, - bp->b_un.b_addr, - ip->i_number, - ip->i_number & imp->im_bmask ); -#endif - - /* - * Just make sure, we have a right one.... - * 1: Check not cross boundary on block - */ - if ((ip->i_number & imp->im_bmask) + isonum_711(dirp->length) - > imp->logical_block_size) { - brelse(bp); - return EINVAL; - } - - /* - * Now get a buffer - * Abuse a namei buffer for now. - */ - MALLOC(symname,char *,MAXPATHLEN,M_NAMEI,M_WAITOK); - - /* - * Ok, we just gathering a symbolic name in SL record. - */ - if (isofs_rrip_getsymname(dirp,symname,&symlen,imp) == 0) { - FREE(symname,M_NAMEI); - brelse(bp); - return EINVAL; - } - /* - * Don't forget before you leave from home ;-) - */ - brelse(bp); - - /* - * return with the symbolic name to caller's. - */ - error = uiomove(symname,symlen,uio); - - FREE(symname,M_NAMEI); - - return error; -} - -/* - * Ufs abort op, called after namei() when a CREATE/DELETE isn't actually - * done. If a buffer has been saved in anticipation of a CREATE, delete it. - */ -/* ARGSUSED */ -isofs_abortop(ndp) - struct nameidata *ndp; -{ - - if ((ndp->ni_nameiop & (HASBUF | SAVESTART)) == HASBUF) - FREE(ndp->ni_pnbuf, M_NAMEI); - return 0; -} - -/* - * Lock an inode. - */ -isofs_lock(vp) - struct vnode *vp; -{ - register struct iso_node *ip = VTOI(vp); - - ISO_ILOCK(ip); - return 0; -} - -/* - * Unlock an inode. - */ -isofs_unlock(vp) - struct vnode *vp; -{ - register struct iso_node *ip = VTOI(vp); - - if (!(ip->i_flag & ILOCKED)) - panic("isofs_unlock NOT LOCKED"); - ISO_IUNLOCK(ip); - return 0; -} - -/* - * Check for a locked inode. - */ -isofs_islocked(vp) - struct vnode *vp; -{ - - if (VTOI(vp)->i_flag & ILOCKED) - return 1; - return 0; -} - -/* - * Calculate the logical to physical mapping if not done already, - * then call the device strategy routine. - */ - -isofs_strategy(bp) - register struct buf *bp; -{ - register struct iso_node *ip = VTOI(bp->b_vp); - struct vnode *vp; - int error; - - if (bp->b_vp->v_type == VBLK || bp->b_vp->v_type == VCHR) - panic("isofs_strategy: spec"); - if (bp->b_blkno == bp->b_lblkno) { - if (error = iso_bmap(ip, bp->b_lblkno, &bp->b_blkno)) - return error; - if ((long)bp->b_blkno == -1) - clrbuf(bp); - } - if ((long)bp->b_blkno == -1) { - biodone(bp); - return 0; - } - vp = ip->i_devvp; - bp->b_dev = vp->v_rdev; - (*(vp->v_op->vop_strategy))(bp); - return 0; -} - -/* - * Print out the contents of an inode. - */ -int -isofs_print(vp) - struct vnode *vp; -{ - printf("tag VT_ISOFS, isofs vnode\n"); - return (0); -} - -extern int enodev (); - -/* - * Global vfs data structures for isofs - */ -struct vnodeops isofs_vnodeops = { - isofs_lookup, /* lookup */ - (void *)enodev, /* create */ - (void *)enodev, /* mknod */ - isofs_open, /* open */ - isofs_close, /* close */ - isofs_access, /* access */ - isofs_getattr, /* getattr */ - (void *)enodev, /* setattr */ - isofs_read, /* read */ - (void *)enodev, /* write */ - isofs_ioctl, /* ioctl */ - isofs_select, /* select */ - isofs_mmap, /* mmap */ - (void *)nullop, /* fsync */ - isofs_seek, /* seek */ - (void *)enodev, /* remove */ - (void *)enodev, /* link */ - (void *)enodev, /* rename */ - (void *)enodev, /* mkdir */ - (void *)enodev, /* rmdir */ - (void *)enodev, /* symlink */ - isofs_readdir, /* readdir */ - isofs_readlink, /* readlink */ - isofs_abortop, /* abortop */ - isofs_inactive, /* inactive */ - isofs_reclaim, /* reclaim */ - isofs_lock, /* lock */ - isofs_unlock, /* unlock */ - (void *)enodev, /* bmap */ - isofs_strategy, /* strategy */ - isofs_print, /* print */ - isofs_islocked, /* islocked */ - (void *)enodev, /* advlock */ -}; - -struct vnodeops isofs_spec_inodeops = { - spec_lookup, /* lookup */ - (void *)enodev, /* create */ - (void *)enodev, /* mknod */ - spec_open, /* open */ - spec_close, /* close */ - isofs_access, /* access */ - isofs_getattr, /* getattr */ - (void *)enodev, /* setattr */ - spec_read, /* read */ - spec_write, /* write */ - spec_ioctl, /* ioctl */ - spec_select, /* select */ - spec_mmap, /* mmap */ - spec_fsync, /* fsync */ - spec_seek, /* seek */ - (void *)enodev, /* remove */ - (void *)enodev, /* link */ - (void *)enodev, /* rename */ - (void *)enodev, /* mkdir */ - (void *)enodev, /* rmdir */ - (void *)enodev, /* symlink */ - spec_readdir, /* readdir */ - spec_readlink, /* readlink */ - spec_abortop, /* abortop */ - isofs_inactive, /* inactive */ - isofs_reclaim, /* reclaim */ - isofs_lock, /* lock */ - isofs_unlock, /* unlock */ - (void *)enodev, /* bmap */ - spec_strategy, /* strategy */ - isofs_print, /* print */ - isofs_islocked, /* islocked */ - spec_advlock, /* advlock */ -}; - -#ifdef FIFO -struct vnodeops isofs_fifo_inodeops = { - fifo_lookup, /* lookup */ - (void *)enodev, /* create */ - (void *)enodev, /* mknod */ - fifo_open, /* open */ - fifo_close, /* close */ - isofs_access, /* access */ - isofs_getattr, /* getattr */ - (void *)enodev, /* setattr */ - fifo_read, /* read */ - fifo_write, /* write */ - fifo_ioctl, /* ioctl */ - fifo_select, /* select */ - fifo_mmap, /* mmap */ - fifo_fsync, /* fsync */ - fifo_seek, /* seek */ - (void *)enodev, /* remove */ - (void *)enodev, /* link */ - (void *)enodev, /* rename */ - (void *)enodev, /* mkdir */ - (void *)enodev, /* rmdir */ - (void *)enodev, /* symlink */ - fifo_readdir, /* readdir */ - fifo_readlink, /* readlink */ - fifo_abortop, /* abortop */ - isofs_inactive, /* inactive */ - isofs_reclaim, /* reclaim */ - isofs_lock, /* lock */ - isofs_unlock, /* unlock */ - (void *)enodev, /* bmap */ - fifo_strategy, /* strategy */ - isofs_print, /* print */ - isofs_islocked, /* islocked */ - fifo_advlock, /* advlock */ -}; -#endif /* FIFO */ diff --git a/sys/lib/libkern/arch/i386/bcmp.s b/sys/lib/libkern/arch/i386/bcmp.s deleted file mode 100644 index 521c0952c6e4..000000000000 --- a/sys/lib/libkern/arch/i386/bcmp.s +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: bcmp.s,v 1.1 1993/10/27 22:01:02 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: bcmp.s,v 1.1 1993/10/27 22:01:02 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * bcmp (void *b1, void *b2, size_t len) - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(bcmp) - pushl %edi - pushl %esi - movl 12(%esp),%edi - movl 16(%esp),%esi - movl 20(%esp),%edx - xorl %eax,%eax /* clear return value */ - cld /* set compare direction forward */ - - movl %edx,%ecx /* compare by words */ - shrl $2,%ecx - repe - cmpsl - jne L1 - - movl %edx,%ecx /* compare remainder by bytes */ - andl $3,%ecx - repe - cmpsb - je L2 - -L1: incl %eax -L2: popl %esi - popl %edi - ret diff --git a/sys/lib/libkern/arch/i386/bzero.s b/sys/lib/libkern/arch/i386/bzero.s deleted file mode 100644 index 84e8de45f9eb..000000000000 --- a/sys/lib/libkern/arch/i386/bzero.s +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: bzero.s,v 1.1 1993/10/27 22:01:03 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: bzero.s,v 1.1 1993/10/27 22:01:03 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * bzero (void *b, size_t len) - * write len zero bytes to the string b. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(bzero) - pushl %edi - pushl %ebx - movl 12(%esp),%edi - movl 16(%esp),%ecx - - cld /* set fill direction forward */ - xorl %eax,%eax /* set fill data to 0 */ - - /* - * if the string is too short, it's really not worth the overhead - * of aligning to word boundries, etc. So we jump to a plain - * unaligned set. - */ - cmpl $0x0f,%ecx - jle L1 - - movl %edi,%edx /* compute misalignment */ - negl %edx - andl $3,%edx - movl %ecx,%ebx - subl %edx,%ebx - - movl %edx,%ecx /* zero until word aligned */ - rep - stosb - - movl %ebx,%ecx /* zero by words */ - shrl $2,%ecx - rep - stosl - - movl %ebx,%ecx - andl $3,%ecx /* zero remainder by bytes */ -L1: rep - stosb - - popl %ebx - popl %edi - ret diff --git a/sys/lib/libkern/arch/i386/ffs.s b/sys/lib/libkern/arch/i386/ffs.s deleted file mode 100644 index c15cd03fc920..000000000000 --- a/sys/lib/libkern/arch/i386/ffs.s +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: ffs.s,v 1.1 1993/10/27 22:01:04 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: ffs.s,v 1.1 1993/10/27 22:01:04 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * ffs(value) - * finds the first bit set in value and returns the index of - * that bit. Bits are numbered starting from 1, starting at the - * rightmost bit. A return value of 0 means that the argument - * was zero. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(ffs) - bsfl 4(%esp),%eax - jz L1 /* ZF is set if all bits are 0 */ - incl %eax /* bits numbered from 1, not 0 */ - ret - - .align 2 -L1: xorl %eax,%eax /* clear result */ - ret diff --git a/sys/lib/libkern/arch/i386/htonl.s b/sys/lib/libkern/arch/i386/htonl.s deleted file mode 100644 index 85d7d69f67f5..000000000000 --- a/sys/lib/libkern/arch/i386/htonl.s +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)htonl.s 5.3 (Berkeley) 12/17/90 - * $Id: htonl.s,v 1.1 1993/10/27 22:01:05 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: htonl.s,v 1.1 1993/10/27 22:01:05 jtc Exp $" -#endif - -/* netorder = htonl(hostorder) */ - -#include "DEFS.h" - -ENTRY(htonl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/sys/lib/libkern/arch/i386/htons.s b/sys/lib/libkern/arch/i386/htons.s deleted file mode 100644 index 7fb69ef3deb6..000000000000 --- a/sys/lib/libkern/arch/i386/htons.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)htons.s 5.2 (Berkeley) 12/17/90 - * $Id: htons.s,v 1.1 1993/10/27 22:01:06 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: htons.s,v 1.1 1993/10/27 22:01:06 jtc Exp $" -#endif - -/* netorder = htons(hostorder) */ - -#include "DEFS.h" - -ENTRY(htons) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/sys/lib/libkern/arch/i386/ntohl.s b/sys/lib/libkern/arch/i386/ntohl.s deleted file mode 100644 index 991d0ee70777..000000000000 --- a/sys/lib/libkern/arch/i386/ntohl.s +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ntohl.s 5.2 (Berkeley) 12/17/90 - * $Id: ntohl.s,v 1.1 1993/10/27 22:01:07 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: ntohl.s,v 1.1 1993/10/27 22:01:07 jtc Exp $" -#endif - -/* hostorder = ntohl(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/sys/lib/libkern/arch/i386/ntohs.s b/sys/lib/libkern/arch/i386/ntohs.s deleted file mode 100644 index 42a85e82cb72..000000000000 --- a/sys/lib/libkern/arch/i386/ntohs.s +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ntohs.s 5.2 (Berkeley) 12/17/90 - * $Id: ntohs.s,v 1.1 1993/10/27 22:01:09 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: ntohs.s,v 1.1 1993/10/27 22:01:09 jtc Exp $" -#endif - -/* hostorder = ntohs(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohs) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/sys/lib/libkern/arch/i386/setjmp.s b/sys/lib/libkern/arch/i386/setjmp.s deleted file mode 100644 index 6fe95dacd68e..000000000000 --- a/sys/lib/libkern/arch/i386/setjmp.s +++ /dev/null @@ -1,26 +0,0 @@ -#include "DEFS.h" - -ENTRY(setjmp) - movl 4(%esp),%eax - movl %ebx,(%eax) # save ebx - movl %esp,4(%eax) # save esp - movl %ebp,8(%eax) # save ebp - movl %esi,12(%eax) # save esi - movl %edi,16(%eax) # save edi - movl (%esp),%edx # get rta - movl %edx,20(%eax) # save eip - xorl %eax,%eax # return (0); - ret - -ENTRY(longjmp) - movl 4(%esp),%eax - movl (%eax),%ebx # restore ebx - movl 4(%eax),%esp # restore esp - movl 8(%eax),%ebp # restore ebp - movl 12(%eax),%esi # restore esi - movl 16(%eax),%edi # restore edi - movl 20(%eax),%edx # get rta - movl %edx,(%esp) # put in return frame - xorl %eax,%eax # return (1); - incl %eax - ret diff --git a/sys/lib/libkern/arch/i386/strcat.s b/sys/lib/libkern/arch/i386/strcat.s deleted file mode 100644 index 1e25e9cdf237..000000000000 --- a/sys/lib/libkern/arch/i386/strcat.s +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcat.s,v 1.1 1993/10/27 22:01:10 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcat.s,v 1.1 1993/10/27 22:01:10 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strcat(s, append) - * append a copy of the null-terminated string "append" to the end - * of the null-terminated string s, then add a terminating `\0'. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcat) - pushl %edi /* save edi */ - movl 8(%esp),%edi /* dst address */ - movl 12(%esp),%edx /* src address */ - pushl %edi /* push destination address */ - - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - - leal -1(%edi),%ecx /* correct dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - je L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - je L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - je L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - je L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - je L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - je L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - je L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jne L1 -L2: popl %eax /* pop destination address */ - popl %edi /* restore edi */ - ret diff --git a/sys/lib/libkern/arch/i386/strcmp.s b/sys/lib/libkern/arch/i386/strcmp.s deleted file mode 100644 index 70728480fdd9..000000000000 --- a/sys/lib/libkern/arch/i386/strcmp.s +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcmp.s,v 1.1 1993/10/27 22:01:11 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcmp.s,v 1.1 1993/10/27 22:01:11 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strcmp(s1, s2) - * return an integer greater than, equal to, or less than 0, - * according as string s1 is greater than, equal to, or less - * than the string s2. - * - * %eax - pointer to s1 - * %edx - pointer to s2 - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcmp) - movl 0x04(%esp),%eax - movl 0x08(%esp),%edx - jmp L2 /* Jump into the loop! */ - - .align 2,0x90 -L1: incl %eax - incl %edx -L2: movb (%eax),%cl - testb %cl,%cl /* null terminator??? */ - je L3 - cmpb %cl,(%edx) /* chars match??? */ - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - je L1 - .align 2, 0x90 -L3: movsbl (%eax),%eax /* unsigned comparison */ - movsbl (%edx),%edx - subl %edx,%eax - ret diff --git a/sys/lib/libkern/arch/i386/strcpy.s b/sys/lib/libkern/arch/i386/strcpy.s deleted file mode 100644 index 2b38f631bb3d..000000000000 --- a/sys/lib/libkern/arch/i386/strcpy.s +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcpy.s,v 1.1 1993/10/27 22:01:12 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcpy.s,v 1.1 1993/10/27 22:01:12 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strcpy (dst, src) - * copy the string src to dst. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcpy) - movl 4(%esp),%ecx /* dst address */ - movl 8(%esp),%edx /* src address */ - pushl %ecx /* push dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - je L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - je L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - je L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - je L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - je L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - je L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - je L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jne L1 -L2: popl %eax /* pop dst address */ - ret diff --git a/sys/lib/libkern/arch/i386/strlen.s b/sys/lib/libkern/arch/i386/strlen.s deleted file mode 100644 index fc9005131225..000000000000 --- a/sys/lib/libkern/arch/i386/strlen.s +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strlen.s,v 1.1 1993/10/27 22:01:13 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strlen.s,v 1.1 1993/10/27 22:01:13 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strlen (s) - * compute the length of the string s. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strlen) - pushl %edi - movl 8(%esp),%edi /* string address */ - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - notl %ecx /* get length by taking complement */ - leal -1(%ecx),%eax /* and subtracting one */ - popl %edi - ret diff --git a/sys/lib/libkern/arch/m68k/locc.s b/sys/lib/libkern/arch/m68k/locc.s deleted file mode 100644 index f080ce0408b0..000000000000 --- a/sys/lib/libkern/arch/m68k/locc.s +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1980, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah Hdr: locore.s 1.58 91/04/22 - * from: @(#)locore.s 7.11 (Berkeley) 5/9/91 - * $Id: locc.s,v 1.1 1993/10/13 05:41:02 cgd Exp $ - */ - -#include "DEFS.h" - -/* - * Emulate fancy VAX string operations: - * locc(mask, count, startc) - */ -ENTRY(locc) - movl sp@(8),d0 | get length - jeq Llcdone | nothing to do, return - movb sp@(7),d1 | mask to use - movl sp@(12),a0 | where to start - subqw #1,d0 | adjust for dbcc -Llcloop: - cmpb a0@+,d1 | compate with mask - dbeq d0,Llcloop | keep going til no more or non-zero - addqw #1,d0 | overshot by one -Llcdone: - rts diff --git a/sys/lib/libkern/arch/m68k/scanc.s b/sys/lib/libkern/arch/m68k/scanc.s deleted file mode 100644 index f7be24b40cc6..000000000000 --- a/sys/lib/libkern/arch/m68k/scanc.s +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1980, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah Hdr: locore.s 1.58 91/04/22 - * from: @(#)locore.s 7.11 (Berkeley) 5/9/91 - * $Id: scanc.s,v 1.1 1993/10/13 05:41:03 cgd Exp $ - */ - -#include "DEFS.h" - -/* - * Emulate fancy VAX string operations: - * scanc(count, startc, table, mask) - */ -ENTRY(scanc) - movl sp@(4),d0 | get length - jeq Lscdone | nothing to do, return - movl sp@(8),a0 | start of scan - movl sp@(12),a1 | table to compare with - movb sp@(19),d1 | and mask to use - movw d2,sp@- | need a scratch register - clrw d2 | clear it out - subqw #1,d0 | adjust for dbra -Lscloop: - movb a0@+,d2 | get character - movb a1@(0,d2:w),d2 | get table entry - andb d1,d2 | mask it - dbne d0,Lscloop | keep going til no more or non-zero - addqw #1,d0 | overshot by one - movw sp@+,d2 | restore scratch -Lscdone: - rts diff --git a/sys/lib/libkern/arch/m68k/skpc.s b/sys/lib/libkern/arch/m68k/skpc.s deleted file mode 100644 index 24b59c24d0a3..000000000000 --- a/sys/lib/libkern/arch/m68k/skpc.s +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1980, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah Hdr: locore.s 1.58 91/04/22 - * from: @(#)locore.s 7.11 (Berkeley) 5/9/91 - * $Id: skpc.s,v 1.1 1993/10/13 05:41:05 cgd Exp $ - */ - -#include "DEFS.h" - -/* - * Emulate fancy VAX string operations: - * skpc(mask, count, startc) - */ -ENTRY(skpc) - movl sp@(8),d0 | get length - jeq Lskdone | nothing to do, return - movb sp@(7),d1 | mask to use - movl sp@(12),a0 | where to start - subqw #1,d0 | adjust for dbcc -Lskloop: - cmpb a0@+,d1 | compate with mask - dbne d0,Lskloop | keep going til no more or zero - addqw #1,d0 | overshot by one -Lskdone: - rts diff --git a/sys/lib/libkern/i386/locc.S b/sys/lib/libkern/i386/locc.S deleted file mode 100644 index fc8323cb93c4..000000000000 --- a/sys/lib/libkern/i386/locc.S +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 1994 Charles Hannum. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: locc.S,v 1.1 1994/02/24 00:41:03 mycroft Exp $ - */ - -#include "DEFS.h" - -ENTRY(locc) - pushl %edi - movl 16(%esp),%edi - movl 12(%esp),%ecx - movl 8(%esp),%eax - cld - repne - scasb - jne 1f - incl %ecx -1: - movl %ecx,%eax - popl %edi - ret diff --git a/sys/lib/libkern/i386/ntohl.S b/sys/lib/libkern/i386/ntohl.S deleted file mode 100644 index b94a8f0bfc2c..000000000000 --- a/sys/lib/libkern/i386/ntohl.S +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ntohl.s 5.2 (Berkeley) 12/17/90 - * $Id: ntohl.S,v 1.1 1993/12/04 03:06:32 cgd Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: ntohl.S,v 1.1 1993/12/04 03:06:32 cgd Exp $" -#endif - -/* hostorder = ntohl(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/sys/lib/libkern/i386/ntohs.S b/sys/lib/libkern/i386/ntohs.S deleted file mode 100644 index 682218f0021d..000000000000 --- a/sys/lib/libkern/i386/ntohs.S +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ntohs.s 5.2 (Berkeley) 12/17/90 - * $Id: ntohs.S,v 1.1 1993/12/04 03:06:42 cgd Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: ntohs.S,v 1.1 1993/12/04 03:06:42 cgd Exp $" -#endif - -/* hostorder = ntohs(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohs) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/sys/lib/libkern/i386/scanc.S b/sys/lib/libkern/i386/scanc.S deleted file mode 100644 index fa2c4e769cf4..000000000000 --- a/sys/lib/libkern/i386/scanc.S +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1994 Charles Hannum. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: scanc.S,v 1.4 1994/03/23 08:49:46 mycroft Exp $ - */ - -#include "DEFS.h" - -ENTRY(scanc) - movl 4(%esp),%ecx - testl %ecx,%ecx - jz 3f - pushl %esi - pushl %edi - movl 16(%esp),%esi - movl 20(%esp),%edi - movb 24(%esp),%dl - xorl %eax,%eax - cld -1: - lodsb - testb %dl,(%eax,%edi) - jnz 2f - decl %ecx - jnz 1b -2: - popl %edi - popl %esi -3: - movl %ecx,%eax - ret diff --git a/sys/lib/libkern/i386/setjmp.S b/sys/lib/libkern/i386/setjmp.S deleted file mode 100644 index b1745b7e019e..000000000000 --- a/sys/lib/libkern/i386/setjmp.S +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 - * $Id: setjmp.S,v 1.4 1993/10/21 01:48:16 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: setjmp.S,v 1.4 1993/10/21 01:48:16 jtc Exp $" -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -#include "DEFS.h" -#include "SYS.h" - -ENTRY(setjmp) - pushl $0 - call PIC_PLT(_sigblock) - popl %edx - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - movl %eax,24(%ecx) - xorl %eax,%eax - ret - -ENTRY(longjmp) - movl 4(%esp),%edx - pushl 24(%edx) - call PIC_PLT(_sigsetmask) - popl %eax - movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/sys/lib/libkern/i386/skpc.S b/sys/lib/libkern/i386/skpc.S deleted file mode 100644 index 0db9c51206be..000000000000 --- a/sys/lib/libkern/i386/skpc.S +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 1994 Charles Hannum. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: skpc.S,v 1.1 1994/02/24 00:41:06 mycroft Exp $ - */ - -#include "DEFS.h" - -ENTRY(skpc) - pushl %edi - movl 16(%esp),%edi - movl 12(%esp),%ecx - movl 8(%esp),%eax - cld - repe - scasb - je 1f - incl %ecx -1: - movl %ecx,%eax - popl %edi - ret diff --git a/sys/lib/libkern/i386/strcat.S b/sys/lib/libkern/i386/strcat.S deleted file mode 100644 index 5732a7ce4da9..000000000000 --- a/sys/lib/libkern/i386/strcat.S +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 1993,94 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcat.S,v 1.3 1994/02/15 13:42:31 mycroft Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcat.S,v 1.3 1994/02/15 13:42:31 mycroft Exp $" -#endif - -#include "DEFS.h" - -/* - * strcat(s, append) - * append a copy of the null-terminated string "append" to the end - * of the null-terminated string s, then add a terminating `\0'. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cache. - */ - -ENTRY(strcat) - pushl %edi /* save edi */ - movl 8(%esp),%edi /* dst address */ - movl 12(%esp),%edx /* src address */ - pushl %edi /* push destination address */ - - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - - leal -1(%edi),%ecx /* correct dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - jz L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - jz L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - jz L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - jz L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - jz L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - jz L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - jz L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jnz L1 -L2: popl %eax /* pop destination address */ - popl %edi /* restore edi */ - ret diff --git a/sys/lib/libkern/i386/strcat.s b/sys/lib/libkern/i386/strcat.s deleted file mode 100644 index 1e25e9cdf237..000000000000 --- a/sys/lib/libkern/i386/strcat.s +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcat.s,v 1.1 1993/10/27 22:01:10 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcat.s,v 1.1 1993/10/27 22:01:10 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strcat(s, append) - * append a copy of the null-terminated string "append" to the end - * of the null-terminated string s, then add a terminating `\0'. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcat) - pushl %edi /* save edi */ - movl 8(%esp),%edi /* dst address */ - movl 12(%esp),%edx /* src address */ - pushl %edi /* push destination address */ - - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - - leal -1(%edi),%ecx /* correct dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - je L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - je L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - je L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - je L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - je L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - je L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - je L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jne L1 -L2: popl %eax /* pop destination address */ - popl %edi /* restore edi */ - ret diff --git a/sys/lib/libkern/i386/strcmp.S b/sys/lib/libkern/i386/strcmp.S deleted file mode 100644 index bfeaa717a970..000000000000 --- a/sys/lib/libkern/i386/strcmp.S +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcmp.S,v 1.3 1994/02/15 13:42:32 mycroft Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcmp.S,v 1.3 1994/02/15 13:42:32 mycroft Exp $" -#endif - -#include "DEFS.h" - -/* - * strcmp(s1, s2) - * return an integer greater than, equal to, or less than 0, - * according as string s1 is greater than, equal to, or less - * than the string s2. - * - * %eax - pointer to s1 - * %edx - pointer to s2 - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cache. - */ - -ENTRY(strcmp) - movl 0x04(%esp),%eax - movl 0x08(%esp),%edx - jmp L2 /* Jump into the loop! */ - - .align 2,0x90 -L1: incl %eax - incl %edx -L2: movb (%eax),%cl - testb %cl,%cl /* null terminator??? */ - jz L3 - cmpb %cl,(%edx) /* chars match??? */ - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - jz L3 - cmpb %cl,(%edx) - je L1 - .align 2, 0x90 -L3: movzbl (%eax),%eax /* unsigned comparison */ - movzbl (%edx),%edx - subl %edx,%eax - ret diff --git a/sys/lib/libkern/i386/strcmp.s b/sys/lib/libkern/i386/strcmp.s deleted file mode 100644 index 70728480fdd9..000000000000 --- a/sys/lib/libkern/i386/strcmp.s +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcmp.s,v 1.1 1993/10/27 22:01:11 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcmp.s,v 1.1 1993/10/27 22:01:11 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strcmp(s1, s2) - * return an integer greater than, equal to, or less than 0, - * according as string s1 is greater than, equal to, or less - * than the string s2. - * - * %eax - pointer to s1 - * %edx - pointer to s2 - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcmp) - movl 0x04(%esp),%eax - movl 0x08(%esp),%edx - jmp L2 /* Jump into the loop! */ - - .align 2,0x90 -L1: incl %eax - incl %edx -L2: movb (%eax),%cl - testb %cl,%cl /* null terminator??? */ - je L3 - cmpb %cl,(%edx) /* chars match??? */ - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - jne L3 - incl %eax - incl %edx - movb (%eax),%cl - testb %cl,%cl - je L3 - cmpb %cl,(%edx) - je L1 - .align 2, 0x90 -L3: movsbl (%eax),%eax /* unsigned comparison */ - movsbl (%edx),%edx - subl %edx,%eax - ret diff --git a/sys/lib/libkern/i386/strcpy.S b/sys/lib/libkern/i386/strcpy.S deleted file mode 100644 index 1ec79df74035..000000000000 --- a/sys/lib/libkern/i386/strcpy.S +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1993,94 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcpy.S,v 1.3 1994/02/15 13:42:33 mycroft Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcpy.S,v 1.3 1994/02/15 13:42:33 mycroft Exp $" -#endif - -#include "DEFS.h" - -/* - * strcpy (dst, src) - * copy the string src to dst. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cache. - */ - -ENTRY(strcpy) - movl 4(%esp),%ecx /* dst address */ - movl 8(%esp),%edx /* src address */ - pushl %ecx /* push dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - jz L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - jz L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - jz L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - jz L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - jz L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - jz L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - jz L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jnz L1 -L2: popl %eax /* pop dst address */ - ret diff --git a/sys/lib/libkern/i386/strcpy.s b/sys/lib/libkern/i386/strcpy.s deleted file mode 100644 index 2b38f631bb3d..000000000000 --- a/sys/lib/libkern/i386/strcpy.s +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strcpy.s,v 1.1 1993/10/27 22:01:12 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strcpy.s,v 1.1 1993/10/27 22:01:12 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strcpy (dst, src) - * copy the string src to dst. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -/* - * I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cashe. - */ - -ENTRY(strcpy) - movl 4(%esp),%ecx /* dst address */ - movl 8(%esp),%edx /* src address */ - pushl %ecx /* push dst address */ - - .align 2,0x90 -L1: movb (%edx),%al /* unroll loop, but not too much */ - movb %al,(%ecx) - testb %al,%al - je L2 - movb 1(%edx),%al - movb %al,1(%ecx) - testb %al,%al - je L2 - movb 2(%edx),%al - movb %al,2(%ecx) - testb %al,%al - je L2 - movb 3(%edx),%al - movb %al,3(%ecx) - testb %al,%al - je L2 - movb 4(%edx),%al - movb %al,4(%ecx) - testb %al,%al - je L2 - movb 5(%edx),%al - movb %al,5(%ecx) - testb %al,%al - je L2 - movb 6(%edx),%al - movb %al,6(%ecx) - testb %al,%al - je L2 - movb 7(%edx),%al - movb %al,7(%ecx) - addl $8,%edx - addl $8,%ecx - testb %al,%al - jne L1 -L2: popl %eax /* pop dst address */ - ret diff --git a/sys/lib/libkern/i386/strlen.S b/sys/lib/libkern/i386/strlen.S deleted file mode 100644 index 2c65127f5613..000000000000 --- a/sys/lib/libkern/i386/strlen.S +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strlen.S,v 1.2 1994/01/28 23:48:05 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strlen.S,v 1.2 1994/01/28 23:48:05 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strlen (s) - * compute the length of the string s. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strlen) - pushl %edi - movl 8(%esp),%edi /* string address */ - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - notl %ecx /* get length by taking complement */ - leal -1(%ecx),%eax /* and subtracting one */ - popl %edi - ret diff --git a/sys/lib/libkern/i386/strlen.s b/sys/lib/libkern/i386/strlen.s deleted file mode 100644 index fc9005131225..000000000000 --- a/sys/lib/libkern/i386/strlen.s +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: strlen.s,v 1.1 1993/10/27 22:01:13 jtc Exp $ - */ - -#if defined(LIBC_SCCS) - .text - .asciz "$Id: strlen.s,v 1.1 1993/10/27 22:01:13 jtc Exp $" -#endif - -#include "DEFS.h" - -/* - * strlen (s) - * compute the length of the string s. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strlen) - pushl %edi - movl 8(%esp),%edi /* string address */ - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - notl %ecx /* get length by taking complement */ - leal -1(%ecx),%eax /* and subtracting one */ - popl %edi - ret diff --git a/sys/lib/libkern/m68k/locc.S b/sys/lib/libkern/m68k/locc.S deleted file mode 100644 index cb974e2ca527..000000000000 --- a/sys/lib/libkern/m68k/locc.S +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1980, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah Hdr: locore.s 1.58 91/04/22 - * from: @(#)locore.s 7.11 (Berkeley) 5/9/91 - * $Id: locc.S,v 1.1 1993/10/13 05:41:02 cgd Exp $ - */ - -#include "DEFS.h" - -/* - * Emulate fancy VAX string operations: - * locc(mask, count, startc) - */ -ENTRY(locc) - movl sp@(8),d0 | get length - jeq Llcdone | nothing to do, return - movb sp@(7),d1 | mask to use - movl sp@(12),a0 | where to start - subqw #1,d0 | adjust for dbcc -Llcloop: - cmpb a0@+,d1 | compate with mask - dbeq d0,Llcloop | keep going til no more or non-zero - addqw #1,d0 | overshot by one -Llcdone: - rts diff --git a/sys/lib/libkern/m68k/ntohl.S b/sys/lib/libkern/m68k/ntohl.S deleted file mode 100644 index 31f992c9de27..000000000000 --- a/sys/lib/libkern/m68k/ntohl.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)ntohl.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: ntohl.S,v 1.1 1994/03/29 07:14:51 chopps Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* hostorder = ntohl(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohl) - movl sp@(4),d0 - rts diff --git a/sys/lib/libkern/m68k/ntohs.S b/sys/lib/libkern/m68k/ntohs.S deleted file mode 100644 index 7af457a4f811..000000000000 --- a/sys/lib/libkern/m68k/ntohs.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)ntohs.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: ntohs.S,v 1.1 1994/03/29 07:14:52 chopps Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* hostorder = ntohs(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohs) - clrl d0 - movw sp@(6),d0 - rts diff --git a/sys/lib/libkern/m68k/scanc.S b/sys/lib/libkern/m68k/scanc.S deleted file mode 100644 index 5e4d227de084..000000000000 --- a/sys/lib/libkern/m68k/scanc.S +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1980, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah Hdr: locore.s 1.58 91/04/22 - * from: @(#)locore.s 7.11 (Berkeley) 5/9/91 - * $Id: scanc.S,v 1.1 1993/10/13 05:41:03 cgd Exp $ - */ - -#include "DEFS.h" - -/* - * Emulate fancy VAX string operations: - * scanc(count, startc, table, mask) - */ -ENTRY(scanc) - movl sp@(4),d0 | get length - jeq Lscdone | nothing to do, return - movl sp@(8),a0 | start of scan - movl sp@(12),a1 | table to compare with - movb sp@(19),d1 | and mask to use - movw d2,sp@- | need a scratch register - clrw d2 | clear it out - subqw #1,d0 | adjust for dbra -Lscloop: - movb a0@+,d2 | get character - movb a1@(0,d2:w),d2 | get table entry - andb d1,d2 | mask it - dbne d0,Lscloop | keep going til no more or non-zero - addqw #1,d0 | overshot by one - movw sp@+,d2 | restore scratch -Lscdone: - rts diff --git a/sys/lib/libkern/m68k/skpc.S b/sys/lib/libkern/m68k/skpc.S deleted file mode 100644 index 8887ce94e741..000000000000 --- a/sys/lib/libkern/m68k/skpc.S +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1980, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: Utah Hdr: locore.s 1.58 91/04/22 - * from: @(#)locore.s 7.11 (Berkeley) 5/9/91 - * $Id: skpc.S,v 1.1 1993/10/13 05:41:05 cgd Exp $ - */ - -#include "DEFS.h" - -/* - * Emulate fancy VAX string operations: - * skpc(mask, count, startc) - */ -ENTRY(skpc) - movl sp@(8),d0 | get length - jeq Lskdone | nothing to do, return - movb sp@(7),d1 | mask to use - movl sp@(12),a0 | where to start - subqw #1,d0 | adjust for dbcc -Lskloop: - cmpb a0@+,d1 | compate with mask - dbne d0,Lskloop | keep going til no more or zero - addqw #1,d0 | overshot by one -Lskdone: - rts diff --git a/sys/lib/libkern/m68k/strcmp.S b/sys/lib/libkern/m68k/strcmp.S deleted file mode 100644 index 19d8fb03b153..000000000000 --- a/sys/lib/libkern/m68k/strcmp.S +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strcmp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strcmp.S,v 1.1 1994/03/29 07:14:54 chopps Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * NOTE: this guy returns result compatible with the VAX assembly version. - * The C version on the portable gen directory returns different results - * (different signs!) when comparing chars with the high bit on. Who is - * right?? - */ -ENTRY(strcmp) - movl sp@(4),a0 /* a0 = string1 */ - movl sp@(8),a1 /* a1 = string2 */ -scloop: - movb a0@+,d0 /* get *string1 */ - cmpb a1@+,d0 /* compare a byte */ - jne scexit /* not equal, break out */ - tstb d0 /* at end of string1? */ - jne scloop /* no, keep going */ - moveq #0,d0 /* strings are equal */ - rts -scexit: - subb a1@-,d0 /* *string1 - *string2 */ - extbl d0 - rts diff --git a/sys/lib/libkern/m68k/strcpy.S b/sys/lib/libkern/m68k/strcpy.S deleted file mode 100644 index 708b391860dd..000000000000 --- a/sys/lib/libkern/m68k/strcpy.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strcpy.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strcpy.S,v 1.1 1994/03/29 07:14:56 chopps Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strcpy) - movl sp@(8),a0 /* a0 = fromaddr */ - movl sp@(4),d0 /* return value is toaddr */ - movl d0,a1 /* a1 = toaddr */ -scloop: - movb a0@+,a1@+ /* copy a byte */ - jne scloop /* copied non-null, keep going */ - rts diff --git a/sys/lib/libkern/m68k/strlen.S b/sys/lib/libkern/m68k/strlen.S deleted file mode 100644 index 8218768de79a..000000000000 --- a/sys/lib/libkern/m68k/strlen.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strlen.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strlen.S,v 1.1 1994/03/29 07:14:57 chopps Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strlen) - moveq #-1,d0 - movl sp@(4),a0 /* string */ -slloop: - addql #1,d0 /* increment count */ - tstb a0@+ /* null? */ - jne slloop /* no, keep going */ - rts diff --git a/sys/lib/libkern/m68k/strncmp.S b/sys/lib/libkern/m68k/strncmp.S deleted file mode 100644 index f6be80c7333e..000000000000 --- a/sys/lib/libkern/m68k/strncmp.S +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strncmp.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strncmp.S,v 1.1 1994/03/29 07:14:58 chopps Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * NOTE: this guy returns result compatible with the VAX assembly version. - * The C version on the portable gen directory returns different results - * (different signs!) when comparing chars with the high bit on. Who is - * right?? - */ -ENTRY(strncmp) - movl sp@(12),d1 /* count */ - jeq scdone /* nothing to do */ - movl sp@(4),a0 /* a0 = string1 */ - movl sp@(8),a1 /* a1 = string2 */ -scloop: - movb a0@+,d0 /* get *string1 */ - cmpb a1@+,d0 /* compare a byte */ - jne scexit /* not equal, break out */ - tstb d0 /* at end of string1? */ - jeq scdone /* yes, all done */ - subql #1,d1 /* no, adjust count */ - jne scloop /* more to do, keep going */ -scdone: - moveq #0,d0 /* strings are equal */ - rts -scexit: - subb a1@-,d0 /* *string1 - *string2 */ - extbl d0 - rts diff --git a/sys/lib/libkern/m68k/strncpy.S b/sys/lib/libkern/m68k/strncpy.S deleted file mode 100644 index f498bd6eb183..000000000000 --- a/sys/lib/libkern/m68k/strncpy.S +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text - /*.asciz "from: @(#)strncpy.s 5.1 (Berkeley) 5/12/90"*/ - .asciz "$Id: strncpy.S,v 1.1 1994/03/29 07:14:59 chopps Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -ENTRY(strncpy) - movl sp@(4),d0 /* return value is toaddr */ - movl sp@(12),d1 /* count */ - jeq scdone /* nothing to do */ - movl sp@(8),a0 /* a0 = fromaddr */ - movl d0,a1 /* a1 = toaddr */ -scloop: - movb a0@+,a1@+ /* copy a byte */ - jeq scploop /* copied null, go pad if necessary */ - subql #1,d1 /* adjust count */ - jne scloop /* more room, keep going */ -scdone: - rts -scploop: - subql #1,d1 /* adjust count */ - jeq scdone /* no more room, all done */ - clrb a1@+ /* clear a byte */ - jra scploop /* keep going */ diff --git a/sys/lib/libkern/ns32k/setjmp.S b/sys/lib/libkern/ns32k/setjmp.S deleted file mode 100644 index 401e6cd7d525..000000000000 --- a/sys/lib/libkern/ns32k/setjmp.S +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 1992 Helsinki University of Technology - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN - * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY - * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE - * USE OF THIS SOFTWARE. - */ -/* - * HISTORY - * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology - * Created. - * - * $Id: setjmp.S,v 1.1 1993/10/07 00:20:24 cgd Exp $ - */ - -#include -#include - -ENTRY(setjmp) - movqd 0, tos - bsr EX(sigblock) - adjspb -4 - movd 4(sp), r2 /* jmp_buf */ - movd 0(sp), JMP_BUF_PC(r2) /* pc of caller */ - movd r0, JMP_BUF_SIGMASK(r2) /* save mask */ - - sprd sp, JMP_BUF_SP(r2) - sprd fp, JMP_BUF_FP(r2) - sprd sb, JMP_BUF_SB(r2) - movd r3, JMP_BUF_R3(r2) /* save registers r3-r7 */ - movd r4, JMP_BUF_R4(r2) - movd r5, JMP_BUF_R5(r2) - movd r6, JMP_BUF_R6(r2) - movd r7, JMP_BUF_R7(r2) - - movqd 0, r0 - ret 0 - -ENTRY(longjmp) - movd 4(sp),r2 /* jmp_buf */ - movd JMP_BUF_SIGMASK(r2), tos /* restore mask */ - bsr EX(sigsetmask) - adjspb -4 - movd 4(sp), r2 /* jmp_buf */ - movd 8(sp), r0 /* value */ - - lprd sp, JMP_BUF_SP(r2) - lprd fp, JMP_BUF_FP(r2) - lprd sb, JMP_BUF_SB(r2) - movd JMP_BUF_R3(r2), r3 /* load registers r3-r7 */ - movd JMP_BUF_R4(r2), r4 - movd JMP_BUF_R5(r2), r5 - movd JMP_BUF_R6(r2), r6 - movd JMP_BUF_R7(r2), r7 - movd JMP_BUF_PC(r2), 0(sp) /* patch return pc */ - - cmpqd 0, r0 - bne nonzero - movqd 1, r0 -nonzero: - ret 0 - diff --git a/sys/libkern/scanc.c b/sys/libkern/scanc.c deleted file mode 100644 index 472305e07d6c..000000000000 --- a/sys/libkern/scanc.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ufs_subr.c 7.13 (Berkeley) 6/28/90 - * $Id: scanc.c,v 1.1 1993/09/01 21:14:22 jtc Exp $ - */ - -#include - -int -scanc(size, cp, table, mask) - u_int size; - register u_char *cp, table[]; - register u_char mask; -{ - register u_char *end = &cp[size]; - - while (cp < end && (table[*cp] & mask) == 0) - cp++; - return (end - cp); -} diff --git a/sys/libkern/skpc.c b/sys/libkern/skpc.c deleted file mode 100644 index 064e264494de..000000000000 --- a/sys/libkern/skpc.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ufs_subr.c 7.13 (Berkeley) 6/28/90 - * $Id: skpc.c,v 1.1 1993/09/01 21:14:23 jtc Exp $ - */ - -#include - -int -skpc(mask, size, cp) - register int mask; - u_int size; - register u_char *cp; -{ - register u_char *end = &cp[size]; - - while (cp < end && *cp == mask) - cp++; - return (end - cp); -} diff --git a/sys/libkern/ulmax.c b/sys/libkern/ulmax.c deleted file mode 100644 index d04b1a6c458e..000000000000 --- a/sys/libkern/ulmax.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1991 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91 - * $Id: ulmax.c,v 1.1 1993/09/01 21:14:24 jtc Exp $ - */ - -unsigned long -ulmax(a, b) - unsigned long a, b; -{ - return (a > b ? a : b); -} diff --git a/sys/libkern/ulmin.c b/sys/libkern/ulmin.c deleted file mode 100644 index 2c84562e28af..000000000000 --- a/sys/libkern/ulmin.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1991 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)subr_xxx.c 7.10 (Berkeley) 4/20/91 - * $Id: ulmin.c,v 1.1 1993/09/01 21:14:25 jtc Exp $ - */ - -unsigned long -ulmin(a, b) - unsigned long a, b; -{ - return (a < b ? a : b); -} diff --git a/sys/pcfs/pcfs_denode.c b/sys/pcfs/pcfs_denode.c deleted file mode 100644 index ca656923e542..000000000000 --- a/sys/pcfs/pcfs_denode.c +++ /dev/null @@ -1,619 +0,0 @@ -/* - * Written by Paul Popelka (paulp@uts.amdahl.com) - * - * You can do anything you want with this software, - * just don't say you wrote it, - * and don't remove this notice. - * - * This software is provided "as is". - * - * The author supplies this software to be publicly - * redistributed on the understanding that the author - * is not responsible for the correct functioning of - * this software in any circumstances and is not liable - * for any damages caused by this software. - * - * October 1992 - * - * $Id: pcfs_denode.c,v 1.5 1993/08/07 08:11:58 cgd Exp $ - */ - -#include "param.h" -#include "systm.h" -#include "mount.h" -#include "proc.h" -#include "buf.h" -#include "vnode.h" -#include "kernel.h" /* defines "time" */ - -#include "bpb.h" -#include "pcfsmount.h" -#include "direntry.h" -#include "denode.h" -#include "fat.h" - -#define DEHSZ 512 -#if ((DEHSZ & (DEHSZ-1)) == 0) -#define DEHASH(dev, deno) (((dev)+(deno)+((deno)>>16))&(DEHSZ-1)) -#else -#define DEHASH(dev, deno) (((dev)+(deno)+((deno)>>16))%DEHSZ) -#endif /* ((DEHSZ & (DEHSZ-1)) == 0) */ - -union dehead { - union dehead *deh_head[2]; - struct denode *deh_chain[2]; -} dehead[DEHSZ]; - -pcfs_init() -{ - int i; - union dehead *deh; - - if (VN_MAXPRIVATE < sizeof(struct denode)) - panic("pcfs_init: vnode too small"); - - for (i = DEHSZ, deh = dehead; --i >= 0; deh++) { - deh->deh_head[0] = deh; - deh->deh_head[1] = deh; - } -} - -/* - * If deget() succeeds it returns with the gotten denode - * locked(). - * pmp - address of pcfsmount structure of the filesystem - * containing the denode of interest. The pm_dev field - * and the address of the pcfsmount structure are used. - * dirclust - which cluster bp contains, if dirclust is 0 - * (root directory) diroffset is relative to the beginning - * of the root directory, otherwise it is cluster relative. - * diroffset - offset past begin of cluster of denode we - * want - * direntptr - address of the direntry structure of interest. - * direntptr is NULL, the block is read if necessary. - * depp - returns the address of the gotten denode. - */ -int -deget (pmp, dirclust, diroffset, direntptr, depp) - struct pcfsmount *pmp; /* so we know the maj/min number */ - u_long dirclust; /* cluster this dir entry came from */ - u_long diroffset; /* index of entry within the cluster */ - struct direntry *direntptr; - struct denode **depp; /* returns the addr of the gotten denode*/ -{ - int error; - dev_t dev = pmp->pm_dev; - union dehead *deh; - struct mount *mntp = pmp->pm_mountp; - extern struct vnodeops pcfs_vnodeops; - struct denode *ldep; - struct vnode *nvp; - struct buf *bp; -#if defined(PCFSDEBUG) -printf("deget(pmp %08x, dirclust %d, diroffset %x, direntptr %x, depp %08x)\n", - pmp, dirclust, diroffset, direntptr, depp); -#endif /* defined(PCFSDEBUG) */ - - /* If dir entry is given and refers to a directory, convert to - * canonical form - */ - if (direntptr && (direntptr->deAttributes & ATTR_DIRECTORY)) { - dirclust = direntptr->deStartCluster; - if (dirclust == PCFSROOT) - diroffset = PCFSROOT_OFS; - else - diroffset = 0; - } - -/* - * See if the denode is in the denode cache. Use the location of - * the directory entry to compute the hash value. - * For subdir use address of "." entry. - * for root dir use cluster PCFSROOT, offset PCFSROOT_OFS - * - * NOTE: The check for de_refcnt > 0 below insures the denode - * being examined does not represent an unlinked but - * still open file. These files are not to be accessible - * even when the directory entry that represented the - * file happens to be reused while the deleted file is still - * open. - */ - deh = &dehead[DEHASH(dev, dirclust + diroffset)]; -loop: - for (ldep = deh->deh_chain[0]; ldep != (struct denode *)deh; - ldep = ldep->de_forw) { - if (dev != ldep->de_dev || ldep->de_refcnt == 0) - continue; - if (dirclust != ldep->de_dirclust - || diroffset != ldep->de_diroffset) - continue; - if (ldep->de_flag & DELOCKED) { - /* should we brelse() the passed buf hdr to - * avoid some potential deadlock? */ - ldep->de_flag |= DEWANT; - sleep((caddr_t)ldep, PINOD); - goto loop; - } - if (vget(DETOV(ldep))) - goto loop; - *depp = ldep; - return 0; - } - - -/* - * Directory entry was not in cache, have to create - * a vnode and copy it from the passed disk buffer. - */ - /* getnewvnode() does a VREF() on the vnode */ - if (error = getnewvnode(VT_MSDOSFS, mntp, &pcfs_vnodeops, &nvp)) { - *depp = 0; - return error; - } - ldep = VTODE(nvp); - ldep->de_vnode = nvp; - ldep->de_flag = 0; - ldep->de_devvp = 0; - ldep->de_lockf = 0; - ldep->de_dev = dev; - fc_purge(ldep, 0); /* init the fat cache for this denode */ - -/* - * Insert the denode into the hash queue and lock the - * denode so it can't be accessed until we've read it - * in and have done what we need to it. - */ - insque(ldep, deh); - DELOCK(ldep); - - /* - * Copy the directory entry into the denode area of the - * vnode. - */ - if (dirclust == PCFSROOT && diroffset == PCFSROOT_OFS) { - /* Directory entry for the root directory. - * There isn't one, so we manufacture one. - * We should probably rummage through the root directory and - * find a label entry (if it exists), and then use the time - * and date from that entry as the time and date for the - * root denode. - */ - ldep->de_Attributes = ATTR_DIRECTORY; - ldep->de_StartCluster = PCFSROOT; - ldep->de_FileSize = pmp->pm_rootdirsize * pmp->pm_BytesPerSec; - /* fill in time and date so that dos2unixtime() doesn't - * spit up when called from pcfs_getattr() with root denode */ - ldep->de_Time = 0x0000; /* 00:00:00 */ - ldep->de_Date = (0 << 9) | (1 << 5) | (1 << 0); - /* Jan 1, 1980 */ - /* leave the other fields as garbage */ - } - else { - bp = NULL; - if (!direntptr) { - error = readep(pmp, dirclust, diroffset, &bp, - &direntptr); - if (error) - return error; - } - ldep->de_de = *direntptr; - if (bp) - brelse (bp); - } - -/* - * Fill in a few fields of the vnode and finish filling - * in the denode. Then return the address of the found - * denode. - */ - ldep->de_pmp = pmp; - ldep->de_devvp = pmp->pm_devvp; - ldep->de_refcnt = 1; - ldep->de_dirclust = dirclust; - ldep->de_diroffset = diroffset; - if (ldep->de_Attributes & ATTR_DIRECTORY) { - /* - * Since DOS directory entries that describe directories - * have 0 in the filesize field, we take this opportunity - * to find out the length of the directory and plug it - * into the denode structure. - */ - u_long size; - - nvp->v_type = VDIR; - if (ldep->de_StartCluster == PCFSROOT) - nvp->v_flag |= VROOT; - else { - error = pcbmap(ldep, 0xffff, 0, &size); - if (error == E2BIG) { - ldep->de_FileSize = size << pmp->pm_cnshift; - error = 0; - } - else - printf("deget(): pcbmap returned %d\n", error); - } - } - else - nvp->v_type = VREG; - VREF(ldep->de_devvp); - *depp = ldep; - return 0; -} - -void -deput(dep) - struct denode *dep; -{ - if ((dep->de_flag & DELOCKED) == 0) - panic("deput: denode not locked"); - DEUNLOCK(dep); - vrele(DETOV(dep)); -} - -int -deupdat(dep, tp, waitfor) - struct denode *dep; - struct timeval *tp; - int waitfor; -{ - int error; - daddr_t bn; - int diro; - struct buf *bp; - struct direntry *dirp; - struct pcfsmount *pmp = dep->de_pmp; - struct vnode *vp = DETOV(dep); -#if defined(PCFSDEBUG) -printf("deupdat(): dep %08x\n", dep); -#endif /* defined(PCFSDEBUG) */ - -/* - * If the update bit is off, or this denode is from - * a readonly filesystem, or this denode is for a - * directory, or the denode represents an open but - * unlinked file then don't do anything. DOS directory - * entries that describe a directory do not ever - * get updated. This is the way dos treats them. - */ - if ((dep->de_flag & DEUPD) == 0 || - vp->v_mount->mnt_flag & MNT_RDONLY || - dep->de_Attributes & ATTR_DIRECTORY || - dep->de_refcnt <= 0) - return 0; - -/* - * Read in the cluster containing the directory entry - * we want to update. - */ - if (error = readde(dep, &bp, &dirp)) - return error; - -/* - * Put the passed in time into the directory entry. - */ - unix2dostime(&time, (union dosdate *)&dep->de_Date, - (union dostime *)&dep->de_Time); - dep->de_flag &= ~DEUPD; - -/* - * Copy the directory entry out of the denode into - * the cluster it came from. - */ - *dirp = dep->de_de; /* structure copy */ - -/* - * Write the cluster back to disk. If they asked - * for us to wait for the write to complete, then - * use bwrite() otherwise use bdwrite(). - */ - error = 0; /* note that error is 0 from above, but ... */ - if (waitfor) - error = bwrite(bp); - else - bdwrite(bp); - return error; -} - -/* - * Truncate the file described by dep to the length - * specified by length. - */ -int -detrunc(dep, length, flags) - struct denode *dep; - u_long length; - int flags; -{ - int error; - int allerror; - u_long eofentry; - u_long chaintofree; - daddr_t bn; - int boff; - int isadir = dep->de_Attributes & ATTR_DIRECTORY; - struct buf *bp; - struct pcfsmount *pmp = dep->de_pmp; -#if defined(PCFSDEBUG) -printf("detrunc(): file %s, length %d, flags %d\n", dep->de_Name, length, flags); -#endif /* defined(PCFSDEBUG) */ - -/* - * Disallow attempts to truncate the root directory - * since it is of fixed size. That's just the way - * dos filesystems are. We use the VROOT bit in the - * vnode because checking for the directory bit and - * a startcluster of 0 in the denode is not adequate - * to recognize the root directory at this point in - * a file or directory's life. - */ - if (DETOV(dep)->v_flag & VROOT) { - printf("detrunc(): can't truncate root directory, clust %d, offset %d\n", - dep->de_dirclust, dep->de_diroffset); - return EINVAL; - } - - vnode_pager_setsize(DETOV(dep), length); - - if (dep->de_FileSize <= length) { - dep->de_flag |= DEUPD; - error = deupdat(dep, &time, 1); -#if defined(PCFSDEBUG) -printf("detrunc(): file is shorter return point, errno %d\n", error); -#endif /* defined(PCFSDEBUG) */ - return error; - } - -/* - * If the desired length is 0 then remember the starting - * cluster of the file and set the StartCluster field in - * the directory entry to 0. If the desired length is - * not zero, then get the number of the last cluster in - * the shortened file. Then get the number of the first - * cluster in the part of the file that is to be freed. - * Then set the next cluster pointer in the last cluster - * of the file to CLUST_EOFE. - */ - if (length == 0) { - chaintofree = dep->de_StartCluster; - dep->de_StartCluster = 0; - eofentry = ~0; - } else { - error = pcbmap(dep, (length-1) >> pmp->pm_cnshift, - 0, &eofentry); - if (error) { -#if defined(PCFSDEBUG) -printf("detrunc(): pcbmap fails %d\n", error); -#endif /* defined(PCFSDEBUG) */ - return error; - } - } - - fc_purge(dep, (length + pmp->pm_crbomask) >> pmp->pm_cnshift); - -/* - * If the new length is not a multiple of the cluster size - * then we must zero the tail end of the new last cluster in case - * it becomes part of the file again because of a seek. - */ - if ((boff = length & pmp->pm_crbomask) != 0) { - /* should read from file vnode or - * filesystem vnode depending on if file or dir */ - if (isadir) { - bn = cntobn(pmp, eofentry); - error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, - NOCRED, &bp); - } else { - bn = (length-1) >> pmp->pm_cnshift; - error = bread(DETOV(dep), bn, pmp->pm_bpcluster, - NOCRED, &bp); - } - if (error) { - brelse(bp); - return error; - } - vnode_pager_uncache(DETOV(dep)); /* what's this for? */ - /* is this the right - * place for it? */ - bzero(bp->b_un.b_addr + boff, pmp->pm_bpcluster - boff); - if (flags & IO_SYNC) - bwrite(bp); - else - bdwrite(bp); - } - -/* - * Write out the updated directory entry. Even - * if the update fails we free the trailing clusters. - */ - dep->de_FileSize = length; - dep->de_flag |= DEUPD; - vinvalbuf(DETOV(dep), length > 0); - allerror = deupdat(dep, &time, MNT_WAIT); -#if defined(PCFSDEBUG) -printf("detrunc(): allerror %d, eofentry %d\n", - allerror, eofentry); -#endif /* defined(PCFSDEBUG) */ - -/* - * If we need to break the cluster chain for the file - * then do it now. - */ - if (eofentry != ~0) { - error = fatentry(FAT_GET_AND_SET, pmp, eofentry, - &chaintofree, CLUST_EOFE); - if (error) { -#if defined(PCFSDEBUG) -printf("detrunc(): fatentry errors %d\n", error); -#endif /* defined(PCFSDEBUG) */ - return error; - } - fc_setcache(dep, FC_LASTFC, (length - 1) >> pmp->pm_cnshift, - eofentry); - } - -/* - * Now free the clusters removed from the file because - * of the truncation. - */ - if (chaintofree != 0 && !PCFSEOF(chaintofree)) - freeclusterchain(pmp, chaintofree); - - return allerror; -} - -/* - * Move a denode to its correct hash queue after - * the file it represents has been moved to a new - * directory. - */ -reinsert(dep) - struct denode *dep; -{ - struct pcfsmount *pmp = dep->de_pmp; - union dehead *deh; - -/* - * Fix up the denode cache. If the denode is - * for a directory, there is nothing to do since the - * hash is based on the starting cluster of the directory - * file and that hasn't changed. If for a file the hash - * is based on the location - * of the directory entry, so we must remove it from the - * cache and re-enter it with the hash based on the new - * location of the directory entry. - */ - if ((dep->de_Attributes & ATTR_DIRECTORY) == 0) { - remque(dep); - deh = &dehead[DEHASH(pmp->pm_dev, - dep->de_dirclust + dep->de_diroffset)]; - insque(dep, deh); - } -} - -int pcfs_prtactive; /* print reclaims of active vnodes */ - -int -pcfs_reclaim(vp) - struct vnode *vp; -{ - struct denode *dep = VTODE(vp); - int i; -#if defined(PCFSDEBUG) -printf("pcfs_reclaim(): dep %08x, file %s, refcnt %d\n", - dep, dep->de_Name, dep->de_refcnt); -#endif /* defined(PCFSDEBUG) */ - - if (pcfs_prtactive && vp->v_usecount != 0) - vprint("pcfs_reclaim(): pushing active", vp); - -/* - * Remove the denode from the denode hash chain we - * are in. - */ - remque(dep); - dep->de_forw = dep; - dep->de_back = dep; - - cache_purge(vp); -/* - * Indicate that one less file on the filesystem is open. - */ - if (dep->de_devvp) { - vrele(dep->de_devvp); - dep->de_devvp = 0; - } - - dep->de_flag = 0; - return 0; -} - -int -pcfs_inactive(vp, p) - struct vnode *vp; - struct proc *p; -{ - struct denode *dep = VTODE(vp); - int error = 0; -#if defined(PCFSDEBUG) -printf("pcfs_inactive(): dep %08x, de_Name[0] %x\n", dep, dep->de_Name[0]); -#endif /* defined(PCFSDEBUG) */ - - if (pcfs_prtactive && vp->v_usecount != 0) - vprint("pcfs_inactive(): pushing active", vp); - -/* - * Get rid of denodes related to stale file handles. - * Hmmm, what does this really do? - */ - if (dep->de_Name[0] == SLOT_DELETED) { - if ((vp->v_flag & VXLOCK) == 0) - vgone(vp); - return 0; - } - -/* - * If the file has been deleted and it is on a read/write - * filesystem, then truncate the file, and mark the directory - * slot as empty. (This may not be necessary for the dos - * filesystem. - */ -#if defined(PCFSDEBUG) -printf("pcfs_inactive(): dep %08x, refcnt %d, mntflag %x, MNT_RDONLY %x\n", - dep, dep->de_refcnt, vp->v_mount->mnt_flag, MNT_RDONLY); -#endif /* defined(PCFSDEBUG) */ - DELOCK(dep); - if (dep->de_refcnt <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { - error = detrunc(dep, (u_long)0, 0); - dep->de_flag |= DEUPD; - dep->de_Name[0] = SLOT_DELETED; - } - DEUPDAT(dep, &time, 0); - DEUNLOCK(dep); - dep->de_flag = 0; - -/* - * If we are done with the denode, then reclaim - * it so that it can be reused now. - */ -#if defined(PCFSDEBUG) -printf("pcfs_inactive(): v_usecount %d, de_Name[0] %x\n", vp->v_usecount, - dep->de_Name[0]); -#endif /* defined(PCFSDEBUG) */ - if (vp->v_usecount == 0 && dep->de_Name[0] == SLOT_DELETED) - vgone(vp); - return error; -} - -int -delock(dep) - struct denode *dep; -{ - while (dep->de_flag & DELOCKED) { - dep->de_flag |= DEWANT; - if (dep->de_spare0 == curproc->p_pid) - panic("delock: locking against myself"); - dep->de_spare1 = curproc->p_pid; - (void) sleep((caddr_t)dep, PINOD); - } - dep->de_spare1 = 0; - dep->de_spare0 = curproc->p_pid; - dep->de_flag |= DELOCKED; - - return 0; -} - -int -deunlock(dep) - struct denode *dep; -{ - if ((dep->de_flag & DELOCKED) == 0) - vprint("deunlock: found unlocked denode", DETOV(dep)); - dep->de_spare0 = 0; - dep->de_flag &= ~DELOCKED; - if (dep->de_flag & DEWANT) { - dep->de_flag &= ~DEWANT; - wakeup((caddr_t)dep); - } - - return 0; -} diff --git a/sys/pcfs/pcfs_fat.c b/sys/pcfs/pcfs_fat.c deleted file mode 100644 index 7f55552c2118..000000000000 --- a/sys/pcfs/pcfs_fat.c +++ /dev/null @@ -1,727 +0,0 @@ -/* - * Written by Paul Popelka (paulp@uts.amdahl.com) - * - * You can do anything you want with this software, - * just don't say you wrote it, - * and don't remove this notice. - * - * This software is provided "as is". - * - * The author supplies this software to be publicly - * redistributed on the understanding that the author - * is not responsible for the correct functioning of - * this software in any circumstances and is not liable - * for any damages caused by this software. - * - * October 1992 - * - * $Id: pcfs_fat.c,v 1.3 1993/05/20 03:34:12 cgd Exp $ - */ - -/* - * kernel include files. - */ -#include "param.h" -#include "systm.h" -#include "buf.h" -#include "file.h" -#include "namei.h" -#include "mount.h" /* to define statfs structure */ -#include "vnode.h" /* to define vattr structure */ -#include "errno.h" - -/* - * pcfs include files. - */ -#include "bpb.h" -#include "pcfsmount.h" -#include "direntry.h" -#include "denode.h" -#include "fat.h" - -/* - * Fat cache stats. - */ -int fc_fileextends; /* # of file extends */ -int fc_lfcempty; /* # of time last file cluster cache entry - * was empty */ -int fc_bmapcalls; /* # of times pcbmap was called */ -#define LMMAX 20 -int fc_lmdistance[LMMAX]; /* counters for how far off the last cluster - * mapped entry was. */ -int fc_largedistance; /* off by more than LMMAX */ - -/* Byte offset in FAT on filesystem pmp, cluster cn */ -#define FATOFS(pmp, cn) (FAT12(pmp) ? (cn) * 3 / 2 : (cn) * 2) - - -static void fatblock (pmp, ofs, bnp, sizep, bop) - struct pcfsmount *pmp; - u_long ofs; - u_long *bnp; - u_long *sizep; - u_long *bop; -{ - u_long bn, size; - - bn = ofs / pmp->pm_fatblocksize * pmp->pm_fatblocksec; - size = min (pmp->pm_fatblocksec, pmp->pm_FATsecs - bn) - * pmp->pm_BytesPerSec; - bn += pmp->pm_fatblk; - if (bnp) - *bnp = bn; - if (sizep) - *sizep = size; - if (bop) - *bop = ofs % pmp->pm_fatblocksize; -} - -/* - * Map the logical cluster number of a file into - * a physical disk sector that is filesystem relative. - * dep - address of denode representing the file of interest - * findcn - file relative cluster whose filesystem relative - * cluster number and/or block number are/is to be found - * bnp - address of where to place the file system relative - * block number. If this pointer is null then don't return - * this quantity. - * cnp - address of where to place the file system relative - * cluster number. If this pointer is null then don't return - * this quantity. - * NOTE: - * Either bnp or cnp must be non-null. - * This function has one side effect. If the requested - * file relative cluster is beyond the end of file, then - * the actual number of clusters in the file is returned - * in *cnp. This is useful for determining how long a - * directory is. If cnp is null, nothing is returned. - */ -int -pcbmap(dep, findcn, bnp, cnp) - struct denode *dep; - u_long findcn; /* file relative cluster to get */ - daddr_t *bnp; /* returned filesys relative blk number */ - u_long *cnp; /* returned cluster number */ -{ - int error; - u_long i; - u_long cn; - u_long prevcn; - u_long byteoffset; - u_long bn; - u_long bo; - struct buf *bp = NULL; - u_long bp_bn = -1; - struct pcfsmount *pmp = dep->de_pmp; - u_long bsize; - int fat12 = FAT12(pmp); /* 12 bit fat */ - - fc_bmapcalls++; - -/* - * If they don't give us someplace to return a value - * then don't bother doing anything. - */ - if (bnp == NULL && cnp == NULL) - return 0; - - cn = dep->de_StartCluster; -/* - * The "file" that makes up the root directory is contiguous, - * permanently allocated, of fixed size, and is not made up - * of clusters. If the cluster number is beyond the end of - * the root directory, then return the number of clusters in - * the file. - */ - if (cn == PCFSROOT) { - if (dep->de_Attributes & ATTR_DIRECTORY) { - if (findcn * pmp->pm_SectPerClust > pmp->pm_rootdirsize) { - if (cnp) - *cnp = pmp->pm_rootdirsize / pmp->pm_SectPerClust; - return E2BIG; - } - if (bnp) - *bnp = pmp->pm_rootdirblk + (findcn * pmp->pm_SectPerClust); - if (cnp) - *cnp = PCFSROOT; - return 0; - } - else { /* just an empty file */ - if (cnp) - *cnp = 0; - return E2BIG; - } - } - -/* - * Rummage around in the fat cache, maybe we can avoid - * tromping thru every fat entry for the file. - * And, keep track of how far off the cache was from - * where we wanted to be. - */ - i = 0; - fc_lookup(dep, findcn, &i, &cn); - if ((bn = findcn - i) >= LMMAX) - fc_largedistance++; - else - fc_lmdistance[bn]++; - -/* - * Handle all other files or directories the normal way. - */ - for (; i < findcn; i++) { - if (PCFSEOF(cn)) - goto hiteof; - byteoffset = FATOFS(pmp, cn); - fatblock(pmp, byteoffset, &bn, &bsize, &bo); - if (bn != bp_bn) { - if (bp) - brelse(bp); - error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); - if (error) { - brelse(bp); - return error; - } - bp_bn = bn; - } - prevcn = cn; - cn = getushort(&bp->b_un.b_addr[bo]); - if (fat12) { - if (prevcn & 1) - cn >>= 4; - cn &= 0x0fff; -/* - * Force the special cluster numbers in the range - * 0x0ff0-0x0fff to be the same as for 16 bit cluster - * numbers to let the rest of pcfs think it is always - * dealing with 16 bit fats. - */ - if ((cn & 0x0ff0) == 0x0ff0) - cn |= 0xf000; - } - } - - if (!PCFSEOF(cn)) { - if (bp) - brelse(bp); - if (bnp) - *bnp = cntobn(pmp, cn); - if (cnp) - *cnp = cn; - fc_setcache(dep, FC_LASTMAP, i, cn); - return 0; - } - -hiteof:; - if (cnp) - *cnp = i; - if (bp) - brelse(bp); - /* update last file cluster entry in the fat cache */ - fc_setcache(dep, FC_LASTFC, i-1, prevcn); - return E2BIG; -} - -/* - * Find the closest entry in the fat cache to the - * cluster we are looking for. - */ -fc_lookup(dep, findcn, frcnp, fsrcnp) - struct denode *dep; - u_long findcn; - u_long *frcnp; - u_long *fsrcnp; -{ - int i; - u_long cn; - struct fatcache *closest = 0; - - for (i = 0; i < FC_SIZE; i++) { - cn = dep->de_fc[i].fc_frcn; - if (cn != FCE_EMPTY && cn <= findcn) { - if (closest == 0 || cn > closest->fc_frcn) - closest = &dep->de_fc[i]; - } - } - if (closest) { - *frcnp = closest->fc_frcn; - *fsrcnp = closest->fc_fsrcn; - } -} - -/* - * Purge the fat cache in denode dep of all entries - * relating to file relative cluster frcn and beyond. - */ -fc_purge(dep, frcn) - struct denode *dep; - u_int frcn; -{ - int i; - struct fatcache *fcp; - - fcp = dep->de_fc; - for (i = 0; i < FC_SIZE; i++, fcp++) { - if (fcp->fc_frcn != FCE_EMPTY && fcp->fc_frcn >= frcn) - fcp->fc_frcn = FCE_EMPTY; - } -} - -/* - * Once the first fat is updated the other copies of - * the fat must also be updated. This function does - * this. - * pmp - pcfsmount structure for filesystem to update - * bp - addr of modified fat block - * fatbn - block number relative to begin of filesystem - * of the modified fat block. - */ -void -updateotherfats(pmp, bp, fatbn) - struct pcfsmount *pmp; - struct buf *bp; - u_long fatbn; -{ - int i; - struct buf *bpn; - -#if defined(PCFSDEBUG) -printf("updateotherfats(pmp %08x, bp %08x, fatbn %d)\n", - pmp, bp, fatbn); -#endif /* defined(PCFSDEBUG) */ - -/* - * Now copy the block(s) of the modified fat to the other - * copies of the fat and write them out. This is faster - * than reading in the other fats and then writing them - * back out. This could tie up the fat for quite a while. - * Preventing others from accessing it. To prevent us - * from going after the fat quite so much we use delayed - * writes, unless they specfied "synchronous" when the - * filesystem was mounted. If synch is asked for then - * use bwrite()'s and really slow things down. - */ - for (i = 1; i < pmp->pm_FATs; i++) { - fatbn += pmp->pm_FATsecs; - /* getblk() never fails */ - bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount); - bcopy(bp->b_un.b_addr, bpn->b_un.b_addr, - bp->b_bcount); - if (pmp->pm_waitonfat) - bwrite(bpn); - else - bdwrite(bpn); - } -} - -/* - * Updating entries in 12 bit fats is a pain in the butt. - * - * The following picture shows where nibbles go when - * moving from a 12 bit cluster number into the appropriate - * bytes in the FAT. - * - * byte m byte m+1 byte m+2 - * +----+----+ +----+----+ +----+----+ - * | 0 1 | | 2 3 | | 4 5 | FAT bytes - * +----+----+ +----+----+ +----+----+ - * - * +----+----+----+ +----+----+----+ - * | 3 0 1 | | 4 5 2 | - * +----+----+----+ +----+----+----+ - * cluster n cluster n+1 - * - * Where n is even. - * m = n + (n >> 2) - * - * (Function no longer used) - */ - - -extern inline void -usemap_alloc (struct pcfsmount *pmp, u_long cn) -{ - pmp->pm_inusemap[cn / 8] |= 1 << (cn % 8); - pmp->pm_freeclustercount--; - /* This assumes that the lowest available cluster was allocated */ - pmp->pm_lookhere = cn + 1; -} - -extern inline void -usemap_free (struct pcfsmount *pmp, u_long cn) -{ - pmp->pm_freeclustercount++; - pmp->pm_inusemap[cn / 8] &= ~(1 << (cn % 8)); - if (pmp->pm_lookhere > cn) - pmp->pm_lookhere = cn; -} - -int -clusterfree(pmp, cluster, oldcnp) - struct pcfsmount *pmp; - u_long cluster; - u_long *oldcnp; -{ - int error; - u_long oldcn; - - error = fatentry(FAT_GET_AND_SET, pmp, cluster, &oldcn, PCFSFREE); - if (error == 0) { -/* - * If the cluster was successfully marked free, then update the count of - * free clusters, and turn off the "allocated" bit in the - * "in use" cluster bit map. - */ - usemap_free(pmp, cluster); - if (oldcnp) - *oldcnp = oldcn; - } - return error; -} - -/* - * Get or Set or 'Get and Set' the cluster'th entry in the - * fat. - * function - whether to get or set a fat entry - * pmp - address of the pcfsmount structure for the - * filesystem whose fat is to be manipulated. - * cluster - which cluster is of interest - * oldcontents - address of a word that is to receive - * the contents of the cluster'th entry if this is - * a get function - * newcontents - the new value to be written into the - * cluster'th element of the fat if this is a set - * function. - * - * This function can also be used to free a cluster - * by setting the fat entry for a cluster to 0. - * - * All copies of the fat are updated if this is a set - * function. - * NOTE: - * If fatentry() marks a cluster as free it does not - * update the inusemap in the pcfsmount structure. - * This is left to the caller. - */ -int -fatentry(function, pmp, cn, oldcontents, newcontents) - int function; - struct pcfsmount *pmp; - u_long cn; - u_long *oldcontents; - u_long newcontents; -{ - int error; - u_long readcn; - u_long bn, bo, bsize, byteoffset; - struct buf *bp; -/*printf("fatentry(func %d, pmp %08x, clust %d, oldcon %08x, newcon %d)\n", - function, pmp, cluster, oldcontents, newcontents);*/ - -#ifdef DIAGNOSTIC -/* - * Be sure they asked us to do something. - */ - if ((function & (FAT_SET | FAT_GET)) == 0) { - printf("fatentry(): function code doesn't specify get or set\n"); - return EINVAL; - } - -/* - * If they asked us to return a cluster number - * but didn't tell us where to put it, give them - * an error. - */ - if ((function & FAT_GET) && oldcontents == NULL) { - printf("fatentry(): get function with no place to put result\n"); - return EINVAL; - } -#endif - -/* - * Be sure the requested cluster is in the filesystem. - */ - if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster) - return EINVAL; - - byteoffset = FATOFS(pmp, cn); - fatblock(pmp, byteoffset, &bn, &bsize, &bo); - error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); - if (error) { - brelse(bp); - return error; - } - if (function & FAT_GET) { - readcn = getushort(&bp->b_un.b_addr[bo]); - if (FAT12(pmp)) { - if (cn & 1) - readcn >>= 4; - readcn &= 0x0fff; - /* map certain 12 bit fat entries to 16 bit */ - if ((readcn & 0x0ff0) == 0x0ff0) - readcn |= 0xf000; - } - *oldcontents = readcn; - } - if (function & FAT_SET) { - if (FAT12(pmp)) { - readcn = getushort(&bp->b_un.b_addr[bo]); - if (cn & 1) { - readcn &= 0x000f; - readcn |= (newcontents << 4); - } - else { - readcn &= 0xf000; - readcn |= (newcontents << 0); - } - putushort(&bp->b_un.b_addr[bo], readcn); - } - else - putushort(&bp->b_un.b_addr[bo], newcontents); - updateotherfats(pmp, bp, bn); -/* - * Write out the first fat last. - */ - if (pmp->pm_waitonfat) - bwrite(bp); - else - bdwrite(bp); - bp = NULL; - pmp->pm_fmod++; - } - if (bp) - brelse(bp); - return 0; -} - -/* - * Allocate a free cluster. - * pmp - - * retcluster - put the allocated cluster's number here. - * fillwith - put this value into the fat entry for the - * allocated cluster. - */ -int -clusteralloc(pmp, retcluster, fillwith) - struct pcfsmount *pmp; - u_long *retcluster; - u_long fillwith; -{ - int error; - u_long cn; - u_long idx, max_idx, bit, map; - - max_idx = pmp->pm_maxcluster / 8; - for (idx = pmp->pm_lookhere / 8; idx <= max_idx; idx++) { - map = pmp->pm_inusemap[idx]; - if (map != 0xff) { - for (bit = 0; bit < 8; bit++) { - if ((map & (1 << bit)) == 0) { - cn = idx * 8 + bit; - goto found_one; - } - } - } - } - return ENOSPC; - -found_one:; - error = fatentry(FAT_SET, pmp, cn, 0, fillwith); - if (error == 0) { - usemap_alloc(pmp, cn); - *retcluster = cn; - } -#if defined(PCFSDEBUG) -printf("clusteralloc(): allocated cluster %d\n", cn); -#endif /* defined(PCFSDEBUG) */ - return error; -} - -/* - * Free a chain of clusters. - * pmp - address of the pcfs mount structure for the - * filesystem containing the cluster chain to be freed. - * startcluster - number of the 1st cluster in the chain - * of clusters to be freed. - */ -int -freeclusterchain(pmp, startcluster) - struct pcfsmount *pmp; - u_long startcluster; -{ - u_long nextcluster; - int error = 0; - - while (startcluster >= CLUST_FIRST && startcluster <= pmp->pm_maxcluster) { - error = clusterfree(pmp, startcluster, &nextcluster); - if (error) { - printf("freeclusterchain(): free failed, cluster %d\n", - startcluster); - break; - } - startcluster = nextcluster; - } - return error; -} - -/* - * Read in fat blocks looking for free clusters. - * For every free cluster found turn off its - * corresponding bit in the pm_inusemap. - */ -int -fillinusemap(pmp) - struct pcfsmount *pmp; -{ - struct buf *bp = NULL; - u_long cn, readcn; - int error; - int fat12 = FAT12(pmp); - u_long bn, bo, bsize, byteoffset; - -/* - * Mark all clusters in use, we mark the free ones in the - * fat scan loop further down. - */ - for (cn = 0; cn < (pmp->pm_maxcluster >> 3) + 1; cn++) - pmp->pm_inusemap[cn] = 0xff; - -/* - * Figure how many free clusters are in the filesystem - * by ripping thougth the fat counting the number of - * entries whose content is zero. These represent free - * clusters. - */ - pmp->pm_freeclustercount = 0; - pmp->pm_lookhere = pmp->pm_maxcluster + 1; - for (cn = CLUST_FIRST; cn <= pmp->pm_maxcluster; cn++) { - byteoffset = FATOFS(pmp, cn); - bo = byteoffset % pmp->pm_fatblocksize; - if (!bo || !bp) { - /* Read new FAT block */ - if (bp) - brelse(bp); - fatblock(pmp, byteoffset, &bn, &bsize, NULL); - error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); - if (error) { - brelse(bp); - return error; - } - } - readcn = getushort(&bp->b_un.b_addr[bo]); - if (fat12) { - if (cn & 1) - readcn >>= 4; - readcn &= 0x0fff; - } - - if (readcn == 0) - usemap_free(pmp, cn); - } - brelse(bp); - return 0; -} - -/* - * Allocate a new cluster and chain it onto the end of the - * file. - * dep - the file to extend - * bpp - where to return the address of the buf header for the - * new file block - * ncp - where to put cluster number of the newly allocated file block - * If this pointer is 0, do not return the cluster number. - * - * NOTE: - * This function is not responsible for turning on the DEUPD - * bit if the de_flag field of the denode and it does not - * change the de_FileSize field. This is left for the caller - * to do. - */ -int -extendfile(dep, bpp, ncp) - struct denode *dep; - struct buf **bpp; - u_int *ncp; -{ - int error = 0; - u_long frcn; - u_long cn; - struct pcfsmount *pmp = dep->de_pmp; - -/* - * Don't try to extend the root directory - */ - if (DETOV(dep)->v_flag & VROOT) { - printf("extendfile(): attempt to extend root directory\n"); - return ENOSPC; - } - -/* - * If the "file's last cluster" cache entry is empty, - * and the file is not empty, - * then fill the cache entry by calling pcbmap(). - */ - fc_fileextends++; - if (dep->de_fc[FC_LASTFC].fc_frcn == FCE_EMPTY && - dep->de_StartCluster != 0) { - fc_lfcempty++; - error = pcbmap(dep, 0xffff, 0, &cn); - /* we expect it to return E2BIG */ - if (error != E2BIG) - return error; - error = 0; - } - -/* - * Allocate another cluster and chain onto the end of the file. - * If the file is empty we make de_StartCluster point to the - * new block. Note that de_StartCluster being 0 is sufficient - * to be sure the file is empty since we exclude attempts to - * extend the root directory above, and the root dir is the - * only file with a startcluster of 0 that has blocks allocated - * (sort of). - */ - if (error = clusteralloc(pmp, &cn, CLUST_EOFE)) - return error; - if (dep->de_StartCluster == 0) { - dep->de_StartCluster = cn; - frcn = 0; - } else { - error = fatentry(FAT_SET, pmp, dep->de_fc[FC_LASTFC].fc_fsrcn, - 0, cn); - if (error) { - clusterfree(pmp, cn, NULL); - return error; - } - - frcn = dep->de_fc[FC_LASTFC].fc_frcn + 1; - } - -/* - * Update the "last cluster of the file" entry in the denode's - * fat cache. - */ - fc_setcache(dep, FC_LASTFC, frcn, cn); - -/* - * Get the buf header for the new block of the file. - */ - if (dep->de_Attributes & ATTR_DIRECTORY) - *bpp = getblk(pmp->pm_devvp, cntobn(pmp, cn), - pmp->pm_bpcluster); - else - *bpp = getblk(DETOV(dep), frcn, pmp->pm_bpcluster); - clrbuf(*bpp); - - if (dep->de_Attributes & ATTR_DIRECTORY) - /* If we extend a directory, me must record the new size */ - dep->de_FileSize = (frcn + 1) * pmp->pm_bpcluster; - -/* - * Give them the filesystem relative cluster number - * if they want it. - */ - if (ncp) - *ncp = cn; - return 0; -} diff --git a/sys/pcfs/pcfs_lookup.c b/sys/pcfs/pcfs_lookup.c deleted file mode 100644 index faf98638546e..000000000000 --- a/sys/pcfs/pcfs_lookup.c +++ /dev/null @@ -1,731 +0,0 @@ -/* - * Written by Paul Popelka (paulp@uts.amdahl.com) - * - * You can do anything you want with this software, - * just don't say you wrote it, - * and don't remove this notice. - * - * This software is provided "as is". - * - * The author supplies this software to be publicly - * redistributed on the understanding that the author - * is not responsible for the correct functioning of - * this software in any circumstances and is not liable - * for any damages caused by this software. - * - * October 1992 - * - * $Id: pcfs_lookup.c,v 1.3 1993/05/20 03:34:16 cgd Exp $ - */ - -#include "param.h" -#include "namei.h" -#include "buf.h" -#include "vnode.h" -#include "mount.h" - -#include "bpb.h" -#include "direntry.h" -#include "denode.h" -#include "pcfsmount.h" -#include "fat.h" - -/* - * When we search a directory the blocks containing directory - * entries are read and examined. The directory entries - * contain information that would normally be in the inode - * of a unix filesystem. This means that some of a directory's - * contents may also be in memory resident denodes (sort of - * an inode). This can cause problems if we are searching - * while some other process is modifying a directory. To - * prevent one process from accessing incompletely modified - * directory information we depend upon being the soul owner - * of a directory block. bread/brelse provide this service. - * This being the case, when a process modifies a directory - * it must first acquire the disk block that contains the - * directory entry to be modified. Then update the disk - * block and the denode, and then write the disk block out - * to disk. This way disk blocks containing directory - * entries and in memory denode's will be in synch. - */ -int -pcfs_lookup(vdp, ndp, p) - struct vnode *vdp; /* vnode of directory to search */ - struct nameidata *ndp; - struct proc *p; -{ - daddr_t bn; - int flag; - int error; - int lockparent; - int wantparent; - int slotstatus; -#define NONE 0 -#define FOUND 1 - int slotoffset; - int slotcluster; - int frcn; - u_long cluster; - int rootreloff; - int diroff; - int isadir; /* ~0 if found direntry is a directory */ - u_long scn; /* starting cluster number */ - struct denode *dp; - struct denode *pdp; - struct denode *tdp; - struct pcfsmount *pmp; - struct buf *bp = 0; - struct direntry *dep; - u_char dosfilename[12]; - -#if defined(PCFSDEBUG) -printf("pcfs_lookup(): looking for %s\n", ndp->ni_ptr); -#endif /* defined(PCFSDEBUG) */ - ndp->ni_dvp = vdp; - ndp->ni_vp = NULL; - dp = VTODE(vdp); - pmp = dp->de_pmp; - lockparent = ndp->ni_nameiop & LOCKPARENT; - flag = ndp->ni_nameiop & OPMASK; - wantparent = ndp->ni_nameiop & (LOCKPARENT | WANTPARENT); -#if defined(PCFSDEBUG) -printf("pcfs_lookup(): vdp %08x, dp %08x, Attr %02x\n", - vdp, dp, dp->de_Attributes); -#endif /* defined(PCFSDEBUG) */ - -/* - * Be sure vdp is a directory. Since dos filesystems - * don't have the concept of execute permission anybody - * can search a directory. - */ - if ((dp->de_Attributes & ATTR_DIRECTORY) == 0) - return ENOTDIR; - -/* - * See if the component of the pathname we are looking for - * is in the directory cache. If so then do a few things - * and return. - */ - if (error = cache_lookup(ndp)) { - int vpid; - - if (error == ENOENT) - return error; -#ifdef PARANOID - if (vdp == ndp->ni_rdir && ndp->ni_isdotdot) - panic("pcfs_lookup: .. thru root"); -#endif /* PARANOID */ - pdp = dp; - vdp = ndp->ni_vp; - dp = VTODE(vdp); - vpid = vdp->v_id; - if (pdp == dp) { - VREF(vdp); - error = 0; - } else if (ndp->ni_isdotdot) { - DEUNLOCK(pdp); - error = vget(vdp); - if (!error && lockparent && *ndp->ni_next == '\0') - DELOCK(pdp); - } else { - error = vget(vdp); - if (!lockparent || error || *ndp->ni_next != '\0') - DEUNLOCK(pdp); - } - - if (!error) { - if (vpid == vdp->v_id) { -#if defined(PCFSDEBUG) -printf("pcfs_lookup(): cache hit, vnode %08x, file %s\n", vdp, dp->de_Name); -#endif /* defined(PCFSDEBUG) */ - return 0; - } - deput(dp); - if (lockparent && pdp != dp && *ndp->ni_next == '\0') - DEUNLOCK(pdp); - } - DELOCK(pdp); - dp = pdp; - vdp = DETOV(dp); - ndp->ni_vp = NULL; - } - -/* - * If they are going after the . or .. entry in the - * root directory, they won't find it. DOS filesystems - * don't have them in the root directory. So, we fake it. - * deget() is in on this scam too. - */ - if ((vdp->v_flag & VROOT) && ndp->ni_ptr[0] == '.' && - (ndp->ni_namelen == 1 || - (ndp->ni_namelen == 2 && ndp->ni_ptr[1] == '.'))) { - isadir = ATTR_DIRECTORY; - scn = PCFSROOT; -#if defined(PCFSDEBUG) -printf("pcfs_lookup(): looking for . or .. in root directory\n"); -#endif /* defined(PCFSDEBUG) */ - cluster == PCFSROOT; - diroff = PCFSROOT_OFS; - goto foundroot; - } - -/* - * Don't search for free slots unless we are creating - * a filename and we are at the end of the pathname. - */ - slotstatus = FOUND; - if ((flag == CREATE || flag == RENAME) && *ndp->ni_next == '\0') { - slotstatus = NONE; - slotoffset = -1; - } - - unix2dosfn((u_char *)ndp->ni_ptr, dosfilename, ndp->ni_namelen); - dosfilename[11] = 0; -#if defined(PCFSDEBUG) -printf("pcfs_lookup(): dos version of filename %s, length %d\n", - dosfilename, ndp->ni_namelen); -#endif /* defined(PCFSDEBUG) */ -/* - * Search the directory pointed at by vdp for the - * name pointed at by ndp->ni_ptr. - */ - tdp = NULL; -/* - * The outer loop ranges over the clusters that make - * up the directory. Note that the root directory is - * different from all other directories. It has a - * fixed number of blocks that are not part of the - * pool of allocatable clusters. So, we treat it a - * little differently. - * The root directory starts at "cluster" 0. - */ - rootreloff = 0; - for (frcn = 0; ; frcn++) { - if (error = pcbmap(dp, frcn, &bn, &cluster)) { - if (error == E2BIG) - break; - return error; - } - error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, &bp); - if (error) { - brelse(bp); - return error; - } - dep = (struct direntry *)bp->b_un.b_addr; - for (diroff = 0; diroff < pmp->pm_depclust; diroff++, dep++) { -/* - * If the slot is empty and we are still looking for - * an empty then remember this one. If the slot is - * not empty then check to see if it matches what we - * are looking for. If the slot has never been filled - * with anything, then the remainder of the directory - * has never been used, so there is no point in searching - * it. - */ - if (dep->deName[0] == SLOT_EMPTY || - dep->deName[0] == SLOT_DELETED) { - if (slotstatus != FOUND) { - slotstatus = FOUND; - if (cluster == PCFSROOT) - slotoffset = rootreloff; - else - slotoffset = diroff; - slotcluster = cluster; - } - if (dep->deName[0] == SLOT_EMPTY) { - brelse(bp); - goto notfound; - } - } else { - /* Ignore volume labels (anywhere, not just - * the root directory). */ - if ((dep->deAttributes & ATTR_VOLUME) == 0 && - bcmp(dosfilename, dep->deName, 11) == 0) { -#if defined(PCFSDEBUG) -printf("pcfs_lookup(): match diroff %d, rootreloff %d\n", diroff, rootreloff); -#endif /* defined(PCFSDEBUG) */ -/* - * Remember where this directory entry came from - * for whoever did this lookup. - * If this is the root directory we are interested - * in the offset relative to the beginning of the - * directory (not the beginning of the cluster). - */ - if (cluster == PCFSROOT) - diroff = rootreloff; - ndp->ni_pcfs.pcfs_offset = diroff; - ndp->ni_pcfs.pcfs_cluster = cluster; - goto found; - } - } - rootreloff++; - } /* for (diroff = 0; .... */ -/* - * Release the buffer holding the directory cluster - * just searched. - */ - brelse(bp); - } /* for (frcn = 0; ; frcn++) */ -notfound:; -/* - * We hold no disk buffers at this point. - */ - -/* - * If we get here we didn't find the entry we were looking - * for. But that's ok if we are creating or renaming and - * are at the end of the pathname and the directory hasn't - * been removed. - */ -#if defined(PCFSDEBUG) -printf("pcfs_lookup(): flag %d, refcnt %d, slotstatus %d\n", - flag, dp->de_refcnt, slotstatus); -printf(" slotoffset %d, slotcluster %d\n", - slotoffset, slotcluster); -#endif /* defined(PCFSDEBUG) */ - if ((flag == CREATE || flag == RENAME) && - *ndp->ni_next == '\0' && dp->de_refcnt != 0) { - if (slotstatus == NONE) { - ndp->ni_pcfs.pcfs_offset = 0; - ndp->ni_pcfs.pcfs_cluster = 0; - ndp->ni_pcfs.pcfs_count = 0; - } else { -#if defined(PCFSDEBUG) -printf("pcfs_lookup(): saving empty slot location\n"); -#endif /* defined(PCFSDEBUG) */ - ndp->ni_pcfs.pcfs_offset = slotoffset; - ndp->ni_pcfs.pcfs_cluster = slotcluster; - ndp->ni_pcfs.pcfs_count = 1; - } -/* dp->de_flag |= DEUPD; /* never update dos directories */ - ndp->ni_nameiop |= SAVENAME; - if (!lockparent) /* leave searched dir locked? */ - DEUNLOCK(dp); - } -/* - * Insert name in cache as non-existant if not - * trying to create it. - */ - if (ndp->ni_makeentry && flag != CREATE) - cache_enter(ndp); - return ENOENT; - -found:; -/* - * NOTE: We still have the buffer with matched - * directory entry at this point. - */ - isadir = dep->deAttributes & ATTR_DIRECTORY; - scn = dep->deStartCluster; - -foundroot:; -/* - * If we entered at foundroot, then we are looking - * for the . or .. entry of the filesystems root - * directory. isadir and scn were setup before - * jumping here. And, bp is null. There is no buf header. - */ - -/* - * If deleting and at the end of the path, then - * if we matched on "." then don't deget() we would - * probably panic(). Otherwise deget() the directory - * entry. - */ - if (flag == DELETE && ndp->ni_next == '\0') { - if (dp->de_StartCluster == scn && - isadir) { /* "." */ - VREF(vdp); - ndp->ni_vp = vdp; - if (bp) brelse(bp); - return 0; - } - error = deget(pmp, cluster, diroff, dep, &tdp); - if (error) { - if (bp) brelse(bp); - return error; - } - ndp->ni_vp = DETOV(tdp); - if (!lockparent) - DEUNLOCK(dp); - if (bp) brelse(bp); - return 0; - } - -/* - * If renaming. - */ - if (flag == RENAME && wantparent && *ndp->ni_next == '\0') { - if (dp->de_StartCluster == scn && - isadir) { - if (bp) brelse(bp); - return EISDIR; - } - error = deget(pmp, cluster, diroff, dep, &tdp); - if (error) { - if (bp) brelse(bp); - return error; - } - ndp->ni_vp = DETOV(tdp); - ndp->ni_nameiop |= SAVENAME; - if (!lockparent) - DEUNLOCK(dp); - if (bp) brelse(bp); - return 0; - } - -/* - * ? - */ - pdp = dp; - if (ndp->ni_isdotdot) { - DEUNLOCK(pdp); - error = deget(pmp, cluster, diroff, dep, &tdp); - if (error) { - DELOCK(pdp); - if (bp) brelse(bp); - return error; - } - if (lockparent && *ndp->ni_next == '\0') - DELOCK(pdp); - ndp->ni_vp = DETOV(tdp); - } else if (dp->de_StartCluster == scn && - isadir) { /* "." */ - VREF(vdp); - ndp->ni_vp = vdp; - } else { - error = deget(pmp, cluster, diroff, dep, &tdp); - if (error) { - if (bp) brelse(bp); - return error; - } - if (!lockparent || *ndp->ni_next != '\0') - DEUNLOCK(pdp); - ndp->ni_vp = DETOV(tdp); - } - if (bp) brelse(bp); - -/* - * Insert name in cache if wanted. - */ - if (ndp->ni_makeentry) - cache_enter(ndp); - return 0; -} - -/* - * dep - directory to copy into the directory - * ndp - nameidata structure containing info on - * where to put the directory entry in the directory. - * depp - return the address of the denode for the - * created directory entry if depp != 0 - */ -int -createde(dep, ndp, depp) - struct denode *dep; - struct nameidata *ndp; - struct denode **depp; -{ - int bn; - int error; - u_long dirclust, diroffset; - struct direntry *ndep; - struct denode *ddep = VTODE(ndp->ni_dvp); /* directory to add to */ - struct pcfsmount *pmp = dep->de_pmp; - struct buf *bp; -#if defined(PCFSDEBUG) -printf("createde(dep %08x, ndp %08x, depp %08x)\n", dep, ndp, depp); -#endif /* defined(PCFSDEBUG) */ - -/* - * If no space left in the directory then allocate - * another cluster and chain it onto the end of the - * file. There is one exception to this. That is, - * if the root directory has no more space it can NOT - * be expanded. extendfile() checks for and fails attempts to - * extend the root directory. We just return an error - * in that case. - */ - if (ndp->ni_pcfs.pcfs_count == 0) { - if (error = extendfile(ddep, &bp, &dirclust)) - return error; - ndep = (struct direntry *)bp->b_un.b_addr; -/* - * Let caller know where we put the directory entry. - */ - ndp->ni_pcfs.pcfs_cluster = dirclust; - ndp->ni_pcfs.pcfs_offset = diroffset = 0; - } - - else { -/* - * There is space in the existing directory. So, - * we just read in the cluster with space. Copy - * the new directory entry in. Then write it to - * disk. - * NOTE: DOS directories do not get smaller as - * clusters are emptied. - */ - dirclust = ndp->ni_pcfs.pcfs_cluster; - diroffset = ndp->ni_pcfs.pcfs_offset; - - error = readep(pmp, dirclust, diroffset, &bp, &ndep); - if (error) - return error; - } - *ndep = dep->de_de; -/* - * If they want us to return with the denode gotten. - */ - if (depp) { - error = deget(pmp, dirclust, diroffset, ndep, depp); - if (error) - return error; - } - if (error = bwrite(bp)) -/*deput()?*/ - return error; - return 0; -} - -/* - * Read in a directory entry and mark it as being deleted. - */ -int -markdeleted(pmp, dirclust, diroffset) - struct pcfsmount *pmp; - u_long dirclust; - u_long diroffset; -{ - int error; - struct direntry *ep; - struct buf *bp; - - error = readep(pmp, dirclust, diroffset, &bp, &ep); - if (error) - return error; - ep->deName[0] = SLOT_DELETED; - return bwrite(bp); -} - -/* - * Remove a directory entry. - * At this point the file represented by the directory - * entry to be removed is still full length until no - * one has it open. When the file no longer being - * used pcfs_inactive() is called and will truncate - * the file to 0 length. When the vnode containing - * the denode is needed for some other purpose by - * VFS it will call pcfs_reclaim() which will remove - * the denode from the denode cache. - */ -int -removede(ndp) - struct nameidata *ndp; -{ - struct denode *dep = VTODE(ndp->ni_vp); /* the file being removed */ - struct pcfsmount *pmp = dep->de_pmp; - int error; - -#if defined(PCFSDEBUG) -/*printf("removede(): filename %s\n", dep->de_Name); -printf("rmde(): dep %08x, ndpcluster %d, ndpoffset %d\n", - dep, ndp->ni_pcfs.pcfs_cluster, ndp->ni_pcfs.pcfs_offset);*/ -#endif /* defined(PCFSDEBUG) */ - -/* - * Read the directory block containing the directory - * entry we are to make free. The nameidata structure - * holds the cluster number and directory entry index - * number of the entry to free. - */ - error = markdeleted(pmp, ndp->ni_pcfs.pcfs_cluster, - ndp->ni_pcfs.pcfs_offset); - - dep->de_refcnt--; - return error; -} - -/* - * Be sure a directory is empty except for "." and "..". - * Return 1 if empty, return 0 if not empty or error. - */ -int -dosdirempty(dep) - struct denode *dep; -{ - int dei; - int error; - u_long cn; - daddr_t bn; - struct buf *bp; - struct pcfsmount *pmp = dep->de_pmp; - struct direntry *dentp; - -/* - * Since the filesize field in directory entries for a directory - * is zero, we just have to feel our way through the directory - * until we hit end of file. - */ - for (cn = 0;; cn++) { - error = pcbmap(dep, cn, &bn, 0); - if (error == E2BIG) - return 1; /* it's empty */ - error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, - &bp); - if (error) { - brelse(bp); - return error; - } - dentp = (struct direntry *)bp->b_un.b_addr; - for (dei = 0; dei < pmp->pm_depclust; dei++) { - if (dentp->deName[0] != SLOT_DELETED) { -/* - * In dos directories an entry whose name starts with SLOT_EMPTY (0) - * starts the beginning of the unused part of the directory, so we - * can just return that it is empty. - */ - if (dentp->deName[0] == SLOT_EMPTY) { - brelse(bp); - return 1; - } -/* - * Any names other than "." and ".." in a directory mean - * it is not empty. - */ - if (bcmp(dentp->deName, ". ", 11) && - bcmp(dentp->deName, ".. ", 11)) { - brelse(bp); -#if defined(PCFSDEBUG) -printf("dosdirempty(): entry %d found %02x, %02x\n", dei, dentp->deName[0], - dentp->deName[1]); -#endif /* defined(PCFSDEBUG) */ - return 0; /* not empty */ - } - } - dentp++; - } - brelse(bp); - } - /*NOTREACHED*/ -} - -/* - * Check to see if the directory described by target is - * in some subdirectory of source. This prevents something - * like the following from succeeding and leaving a bunch - * or files and directories orphaned. - * mv /a/b/c /a/b/c/d/e/f - * Where c and f are directories. - * source - the inode for /a/b/c - * target - the inode for /a/b/c/d/e/f - * Returns 0 if target is NOT a subdirectory of source. - * Otherwise returns a non-zero error number. - * The target inode is always unlocked on return. - */ -int -doscheckpath(source, target) - struct denode *source; - struct denode *target; -{ - daddr_t scn; - struct denode dummy; - struct pcfsmount *pmp; - struct direntry *ep; - struct denode *dep; - struct buf *bp = NULL; - int error = 0; - - dep = target; - if ((target->de_Attributes & ATTR_DIRECTORY) == 0 || - (source->de_Attributes & ATTR_DIRECTORY) == 0) { - error = ENOTDIR; - goto out; - } - if (dep->de_StartCluster == source->de_StartCluster) { - error = EEXIST; - goto out; - } - if (dep->de_StartCluster == PCFSROOT) - goto out; - for (;;) { - if ((dep->de_Attributes & ATTR_DIRECTORY) == 0) { - error = ENOTDIR; - break; - } - pmp = dep->de_pmp; - scn = dep->de_StartCluster; - error = readep(pmp, scn, 1, &bp, &ep); - if (error) - break; - if ((ep->deAttributes & ATTR_DIRECTORY) == 0 || - bcmp(ep->deName, ".. ", 11) != 0) { - /* Bad Directory */ - error = ENOTDIR; - break; - } - if (ep->deStartCluster == source->de_StartCluster) { - error = EINVAL; - break; - } - if (ep->deStartCluster == PCFSROOT) - break; - deput(dep); - /* NOTE: deget() clears dep on error */ - error = deget(pmp, ep->deStartCluster, 0, ep, &dep); - brelse(bp); - bp = NULL; - if (error) - break; - } -out:; - if (bp) - brelse(bp); - if (error == ENOTDIR) - printf("doscheckpath(): .. not a directory?\n"); - if (dep != NULL) - deput(dep); - return error; -} - -/* - * Read in the disk block containing the directory entry - * (dirclu, dirofs) and return the address of the buf header, - * and the address of the directory entry within the block. - */ -int -readep(pmp, dirclu, dirofs, bpp, epp) - struct pcfsmount *pmp; - u_long dirclu, dirofs; - struct buf **bpp; - struct direntry **epp; -{ - int error; - daddr_t bn; - - bn = detobn(pmp, dirclu, dirofs); - if (error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, bpp)) { - brelse(*bpp); - *bpp = NULL; - return error; - } - if (epp) - *epp = bptoep(pmp, *bpp, dirofs); - return 0; -} - - -/* - * Read in the disk block containing the directory entry - * dep came from and return the address of the buf header, - * and the address of the directory entry within the block. - */ -int -readde(dep, bpp, epp) - struct denode *dep; - struct buf **bpp; - struct direntry **epp; -{ - return readep(dep->de_pmp, dep->de_dirclust, dep->de_diroffset, - bpp, epp); -} diff --git a/sys/pcfs/pcfs_vfsops.c b/sys/pcfs/pcfs_vfsops.c deleted file mode 100644 index 4e6e02f48338..000000000000 --- a/sys/pcfs/pcfs_vfsops.c +++ /dev/null @@ -1,620 +0,0 @@ -/* - * Written by Paul Popelka (paulp@uts.amdahl.com) - * - * You can do anything you want with this software, - * just don't say you wrote it, - * and don't remove this notice. - * - * This software is provided "as is". - * - * The author supplies this software to be publicly - * redistributed on the understanding that the author - * is not responsible for the correct functioning of - * this software in any circumstances and is not liable - * for any damages caused by this software. - * - * October 1992 - * - * April 6, 1993: - * Changed MOUNT_PCFS to MOUNT_MSDOS, this whole package should be renamed - * to msdosfs, but I did not have the time to do it. Some one please do - * this and resubmit it to the patchkit! - * Rodney W. Grimes - * - * $Id: pcfs_vfsops.c,v 1.5 1993/08/07 08:12:02 cgd Exp $ - */ - -#include "param.h" -#include "systm.h" -#include "namei.h" -#include "proc.h" -#include "kernel.h" -#include "vnode.h" -#include "specdev.h" /* defines v_rdev */ -#include "mount.h" -#include "buf.h" -#include "file.h" -#include "malloc.h" - -#include "bpb.h" -#include "bootsect.h" -#include "direntry.h" -#include "denode.h" -#include "pcfsmount.h" -#include "fat.h" - -int pcfsdoforce = 0; /* 1 = force unmount */ - -/* - * mp - - * path - addr in user space of mount point (ie /usr or whatever) - * data - addr in user space of mount params including the - * name of the block special file to treat as a filesystem. - * ndp - - * p - - */ -int -pcfs_mount(mp, path, data, ndp, p) - struct mount *mp; - char *path; - caddr_t data; - struct nameidata *ndp; - struct proc *p; -{ - struct vnode *devvp; /* vnode for blk device to mount */ - struct pcfs_args args; /* will hold data from mount request */ - struct pcfsmount *pmp; /* pcfs specific mount control block */ - int error; - u_int size; - -/* - * Copy in the args for the mount request. - */ - if (error = copyin(data, (caddr_t)&args, sizeof(struct pcfs_args))) - return error; - -/* - * Check to see if they want it to be an exportable - * filesystem via nfs. And, if they do, should it - * be read only, and what uid is root to be mapped - * to. - */ - if ((args.exflags & MNT_EXPORTED) || (mp->mnt_flag & MNT_EXPORTED)) { - if (args.exflags & MNT_EXPORTED) - mp->mnt_flag |= MNT_EXPORTED; - else - mp->mnt_flag &= ~MNT_EXPORTED; - if (args.exflags & MNT_EXRDONLY) - mp->mnt_flag |= MNT_EXRDONLY; - else - mp->mnt_flag &= ~MNT_EXRDONLY; - mp->mnt_exroot = args.exroot; - } - -/* - * If they just want to update then be sure we can - * do what is asked. Can't change a filesystem from - * read/write to read only. Why? - * And if they've supplied a new device file name then we - * continue, otherwise return. - */ - if (mp->mnt_flag & MNT_UPDATE) { - pmp = (struct pcfsmount *)mp->mnt_data; - if (pmp->pm_ronly && (mp->mnt_flag & MNT_RDONLY) == 0) - pmp->pm_ronly = 0; - if (args.fspec == 0) - return 0; - } - -/* - * Now, lookup the name of the block device this - * mount or name update request is to apply to. - */ - ndp->ni_nameiop = LOOKUP | FOLLOW; - ndp->ni_segflg = UIO_USERSPACE; - ndp->ni_dirp = args.fspec; - if (error = namei(ndp, p)) - return error; - -/* - * Be sure they've given us a block device to treat - * as a filesystem. And, that its major number is - * within the bdevsw table. - */ - devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { - vrele(devvp); /* namei() acquires this? */ - return ENOTBLK; - } - if (major(devvp->v_rdev) >= nblkdev) { - vrele(devvp); - return ENXIO; - } - -/* - * If this is an update, then make sure the vnode - * for the block special device is the same as the - * one our filesystem is in. - */ - if (mp->mnt_flag & MNT_UPDATE) { - if (devvp != pmp->pm_devvp) - error = EINVAL; - else - vrele(devvp); - } else { - -/* - * Well, it's not an update, it's a real mount request. - * Time to get dirty. - */ - error = mountpcfs(devvp, mp, p); - } - if (error) { - vrele(devvp); - return error; - } - -/* - * Copy in the name of the directory the filesystem - * is to be mounted on. - * Then copy in the name of the block special file - * representing the filesystem being mounted. - * And we clear the remainder of the character strings - * to be tidy. - * Then, we try to fill in the filesystem stats structure - * as best we can with whatever applies from a dos file - * system. - */ - pmp = (struct pcfsmount *)mp->mnt_data; - copyinstr(path, (caddr_t)mp->mnt_stat.f_mntonname, - sizeof(mp->mnt_stat.f_mntonname)-1, &size); - bzero(mp->mnt_stat.f_mntonname + size, - sizeof(mp->mnt_stat.f_mntonname) - size); - copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN-1, &size); - bzero(mp->mnt_stat.f_mntfromname + size, - MNAMELEN - size); - (void)pcfs_statfs(mp, &mp->mnt_stat, p); -#if defined(PCFSDEBUG) -printf("pcfs_mount(): mp %x, pmp %x, inusemap %x\n", mp, pmp, pmp->pm_inusemap); -#endif /* defined(PCFSDEBUG) */ - return 0; -} - -int -mountpcfs(devvp, mp, p) - struct vnode *devvp; - struct mount *mp; - struct proc *p; -{ - int i; - u_long bpc; - int bit; - int error = 0; - int needclose; - int ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - dev_t dev = devvp->v_rdev; - union bootsector *bsp; - struct pcfsmount *pmp = NULL; - struct buf *bp0 = NULL; - struct byte_bpb33 *b33; - struct byte_bpb50 *b50; - -/* - * Multiple mounts of the same block special file - * aren't allowed. Make sure no one else has the - * special file open. And flush any old buffers - * from this filesystem. Presumably this prevents - * us from running into buffers that are the wrong - * blocksize. - * NOTE: mountedon() is a part of the ufs filesystem. - * If the ufs filesystem is not gen'ed into the system - * we will get an unresolved reference. - */ - if (error = mountedon(devvp)) - return error; - if (vcount(devvp) > 1) - return EBUSY; - vinvalbuf(devvp, 1); - -/* - * Now open the block special file. - */ - if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p)) - return error; - needclose = 1; - -/* - * Read the boot sector of the filesystem, and then - * check the boot signature. If not a dos boot sector - * then error out. We could also add some checking on - * the bsOemName field. So far I've seen the following - * values: - * "IBM 3.3" - * "MSDOS3.3" - * "MSDOS5.0" - */ - if (error = bread(devvp, 0, 512, NOCRED, &bp0)) - goto error_exit; - bp0->b_flags |= B_AGE; - bsp = (union bootsector *)bp0->b_un.b_addr; - b33 = (struct byte_bpb33 *)bsp->bs33.bsBPB; - b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB; - if (bsp->bs50.bsBootSectSig != BOOTSIG) { - error = EINVAL; - goto error_exit; - } - - pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK); - pmp->pm_inusemap = NULL; - pmp->pm_mountp = mp; - -/* - * Compute several useful quantities from the bpb in - * the bootsector. Copy in the dos 5 variant of the - * bpb then fix up the fields that are different between - * dos 5 and dos 3.3. - */ - pmp->pm_BytesPerSec = getushort(b50->bpbBytesPerSec); - pmp->pm_SectPerClust = b50->bpbSecPerClust; - pmp->pm_ResSectors = getushort(b50->bpbResSectors); - pmp->pm_FATs = b50->bpbFATs; - pmp->pm_RootDirEnts = getushort(b50->bpbRootDirEnts); - pmp->pm_Sectors = getushort(b50->bpbSectors); - pmp->pm_Media = b50->bpbMedia; - pmp->pm_FATsecs = getushort(b50->bpbFATsecs); - pmp->pm_SecPerTrack = getushort(b50->bpbSecPerTrack); - pmp->pm_Heads = getushort(b50->bpbHeads); - if (pmp->pm_Sectors == 0) { - pmp->pm_HiddenSects = getulong(b50->bpbHiddenSecs); - pmp->pm_HugeSectors = getulong(b50->bpbHugeSectors); - } else { - pmp->pm_HiddenSects = getushort(b33->bpbHiddenSecs); - pmp->pm_HugeSectors = pmp->pm_Sectors; - } - pmp->pm_fatblk = pmp->pm_ResSectors; - pmp->pm_rootdirblk = pmp->pm_fatblk + - (pmp->pm_FATs * pmp->pm_FATsecs); - pmp->pm_rootdirsize = (pmp->pm_RootDirEnts * sizeof(struct direntry)) - / - pmp->pm_BytesPerSec; /* in sectors */ - pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize; - pmp->pm_nmbrofclusters = (pmp->pm_HugeSectors - pmp->pm_firstcluster) / - pmp->pm_SectPerClust; - pmp->pm_maxcluster = pmp->pm_nmbrofclusters + 1; - pmp->pm_fatsize = pmp->pm_FATsecs * pmp->pm_BytesPerSec; - if (FAT12(pmp)) - /* This will usually be a floppy disk. - * This size makes sure that one fat entry will not be split - * across multiple blocks. */ - pmp->pm_fatblocksize = 3 * pmp->pm_BytesPerSec; - else - /* This will usually be a hard disk. - * Reading or writing one block should be quite fast. */ - pmp->pm_fatblocksize = MAXBSIZE; - pmp->pm_fatblocksec = pmp->pm_fatblocksize / pmp->pm_BytesPerSec; - - if ((pmp->pm_rootdirsize % pmp->pm_SectPerClust) != 0) - printf("mountpcfs(): root directory is not a multiple of the clustersize in length\n"); - -/* - * Compute mask and shift value for isolating cluster relative - * byte offsets and cluster numbers from a file offset. - */ - bpc = pmp->pm_SectPerClust * pmp->pm_BytesPerSec; - if (!bpc || (bpc & (bpc - 1))) { - error = EINVAL; - goto error_exit; - } - pmp->pm_bpcluster = bpc; - pmp->pm_depclust = bpc/sizeof(struct direntry); - pmp->pm_crbomask = bpc - 1; - pmp->pm_cnshift = ffs(bpc) - 1; - - pmp->pm_brbomask = 0x01ff; /* 512 byte blocks only (so far) */ - pmp->pm_bnshift = 9; /* shift right 9 bits to get bn */ - -/* - * Release the bootsector buffer. - */ - brelse(bp0); - bp0 = NULL; - -/* - * Allocate memory for the bitmap of allocated clusters, - * and then fill it in. - */ - pmp->pm_inusemap = malloc((pmp->pm_maxcluster / 8) + 1, - M_MSDOSFSFAT, M_WAITOK); - -/* - * fillinusemap() needs pm_devvp. - */ - pmp->pm_dev = dev; - pmp->pm_devvp = devvp; - -/* - * Have the inuse map filled in. - */ - error = fillinusemap(pmp); - if (error) - goto error_exit; - -/* - * If they want fat updates to be synchronous then let - * them suffer the performance degradation in exchange - * for the on disk copy of the fat being correct just - * about all the time. I suppose this would be a good - * thing to turn on if the kernel is still flakey. - */ - pmp->pm_waitonfat = mp->mnt_flag & MNT_SYNCHRONOUS; - -/* - * Finish up. - */ - pmp->pm_ronly = ronly; - if (ronly == 0) - pmp->pm_fmod = 1; - mp->mnt_data = (qaddr_t)pmp; - mp->mnt_stat.f_fsid.val[0] = (long)dev; - mp->mnt_stat.f_fsid.val[1] = MOUNT_MSDOS; - mp->mnt_flag |= MNT_LOCAL; -#if defined(QUOTA) -/* - * If we ever do quotas for DOS filesystems this would - * be a place to fill in the info in the pcfsmount - * structure. - * You dolt, quotas on dos filesystems make no sense - * because files have no owners on dos filesystems. - * of course there is some empty space in the directory - * entry where we could put uid's and gid's. - */ -#endif /* defined(QUOTA) */ - devvp->v_specflags |= SI_MOUNTEDON; - - return 0; - -error_exit:; - if (bp0) - brelse(bp0); - if (needclose) - (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, - NOCRED, p); - if (pmp) { - if (pmp->pm_inusemap) - free((caddr_t)pmp->pm_inusemap, M_MSDOSFSFAT); - free((caddr_t)pmp, M_MSDOSFSMNT); - mp->mnt_data = (qaddr_t)0; - } - return error; -} - -int -pcfs_start(mp, flags, p) - struct mount *mp; - int flags; - struct proc *p; -{ - return 0; -} - -/* - * Unmount the filesystem described by mp. - */ -int -pcfs_unmount(mp, mntflags, p) - struct mount *mp; - int mntflags; - struct proc *p; -{ - int flags = 0; - int error; - struct pcfsmount *pmp = (struct pcfsmount *)mp->mnt_data; - struct vnode *vp = pmp->pm_devvp; - - if (mntflags & MNT_FORCE) { - if (!pcfsdoforce) - return EINVAL; - flags |= FORCECLOSE; - } - mntflushbuf(mp, 0); - if (mntinvalbuf(mp)) - return EBUSY; -#if defined(QUOTA) -#endif /* defined(QUOTA) */ - if (error = vflush(mp, NULLVP, flags)) - return error; - pmp->pm_devvp->v_specflags &= ~SI_MOUNTEDON; -#if defined(PCFSDEBUG) -printf("pcfs_umount(): just before calling VOP_CLOSE()\n"); -printf("flag %08x, usecount %d, writecount %d, holdcnt %d\n", - vp->v_flag, vp->v_usecount, vp->v_writecount, vp->v_holdcnt); -printf("lastr %d, id %d, mount %08x, op %08x\n", - vp->v_lastr, vp->v_id, vp->v_mount, vp->v_op); -printf("freef %08x, freeb %08x, mountf %08x, mountb %08x\n", - vp->v_freef, vp->v_freeb, vp->v_mountf, vp->v_mountb); -printf("cleanblkhd %08x, dirtyblkhd %08x, numoutput %d, type %d\n", - vp->v_cleanblkhd, vp->v_dirtyblkhd, vp->v_numoutput, vp->v_type); -printf("union %08x, tag %d, data[0] %08x, data[1] %08x\n", - vp->v_socket, vp->v_tag, vp->v_data[0], vp->v_data[1]); -#endif /* defined(PCFSDEBUG) */ - error = VOP_CLOSE(pmp->pm_devvp, pmp->pm_ronly ? FREAD : FREAD|FWRITE, - NOCRED, p); - vrele(pmp->pm_devvp); - free((caddr_t)pmp->pm_inusemap, M_MSDOSFSFAT); - free((caddr_t)pmp, M_MSDOSFSMNT); - mp->mnt_data = (qaddr_t)0; - mp->mnt_flag &= ~MNT_LOCAL; - return error; -} - -int -pcfs_root(mp, vpp) - struct mount *mp; - struct vnode **vpp; -{ - struct denode *ndep; - struct pcfsmount *pmp = (struct pcfsmount *)(mp->mnt_data); - int error; - - error = deget(pmp, PCFSROOT, PCFSROOT_OFS, NULL, &ndep); -#if defined(PCFSDEBUG) -printf("pcfs_root(); mp %08x, pmp %08x, ndep %08x, vp %08x\n", - mp, pmp, ndep, DETOV(ndep)); -#endif /* defined(PCFSDEBUG) */ - if (error == 0) - *vpp = DETOV(ndep); - return error; -} - -int -pcfs_quotactl(mp, cmds, uid, arg, p) - struct mount *mp; - int cmds; - uid_t uid; - caddr_t arg; - struct proc *p; -{ -#if defined(QUOTA) -#else - return EOPNOTSUPP; -#endif /* defined(QUOTA) */ -} - -int -pcfs_statfs(mp, sbp, p) - struct mount *mp; - struct statfs *sbp; - struct proc *p; -{ - struct pcfsmount *pmp = (struct pcfsmount *)mp->mnt_data; - -/* - * Fill in the stat block. - */ - sbp->f_type = MOUNT_MSDOS; - sbp->f_fsize = pmp->pm_bpcluster; - sbp->f_bsize = pmp->pm_bpcluster; - sbp->f_blocks = pmp->pm_nmbrofclusters; - sbp->f_bfree = pmp->pm_freeclustercount; - sbp->f_bavail = pmp->pm_freeclustercount; - sbp->f_files = pmp->pm_RootDirEnts; - sbp->f_ffree = 0; /* what to put in here? */ - -/* - * Copy the mounted on and mounted from names into - * the passed in stat block, if it is not the one - * in the mount structure. - */ - if (sbp != &mp->mnt_stat) { - bcopy((caddr_t)mp->mnt_stat.f_mntonname, - (caddr_t)&sbp->f_mntonname[0], MNAMELEN); - bcopy((caddr_t)mp->mnt_stat.f_mntfromname, - (caddr_t)&sbp->f_mntfromname[0], MNAMELEN); - } - return 0; -} - -int -pcfs_sync(mp, waitfor) - struct mount *mp; - int waitfor; -{ - struct vnode *vp; - struct denode *dep; - struct pcfsmount *pmp; - int error; - int allerror = 0; - - pmp = (struct pcfsmount *)mp->mnt_data; - -/* - * If we ever switch to not updating all of the fats - * all the time, this would be the place to update them - * from the first one. - */ - if (pmp->pm_fmod) { - if (pmp->pm_ronly) { - printf("pcfs_sync(): writing to readonly filesystem\n"); - return EINVAL; - } else { - /* update fats here */ - } - } - -/* - * Go thru in memory denodes and write them out along - * with unwritten file blocks. - */ -loop: - for (vp = mp->mnt_mounth; vp; vp = vp->v_mountf) { - if (vp->v_mount != mp) /* not ours anymore */ - goto loop; - if (VOP_ISLOCKED(vp)) /* file is busy */ - continue; - dep = VTODE(vp); - if ((dep->de_flag & DEUPD) == 0 && vp->v_dirtyblkhd == NULL) - continue; - if (vget(vp)) /* not there anymore? */ - goto loop; - if (vp->v_dirtyblkhd) /* flush dirty file blocks */ - vflushbuf(vp, 0); - if ((dep->de_flag & DEUPD) && - (error = deupdat(dep, &time, 0))) - allerror = error; - vput(vp); /* done with this one */ - } - -/* - * Flush filesystem control info. - */ - vflushbuf(pmp->pm_devvp, waitfor == MNT_WAIT ? B_SYNC : 0); - return allerror; -} - -int -pcfs_fhtovp (mp, fhp, vpp) - struct mount *mp; - struct fid *fhp; - struct vnode **vpp; -{ - struct pcfsmount *pmp = (struct pcfsmount *)mp->mnt_data; - struct defid *defhp = (struct defid *)fhp; - struct denode *dep; - int error; - - error = deget (pmp, defhp->defid_dirclust, defhp->defid_dirofs, - NULL, &dep); - if (error) - return (error); - *vpp = DETOV (dep); - return (0); -} - - -int -pcfs_vptofh (vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - struct denode *dep = VTODE(vp); - struct defid *defhp = (struct defid *)fhp; - - defhp->defid_len = sizeof(struct defid); - defhp->defid_dirclust = dep->de_dirclust; - defhp->defid_dirofs = dep->de_diroffset; -/* defhp->defid_gen = ip->i_gen; */ - return (0); -} - -struct vfsops pcfs_vfsops = { - pcfs_mount, - pcfs_start, - pcfs_unmount, - pcfs_root, - pcfs_quotactl, - pcfs_statfs, - pcfs_sync, - pcfs_fhtovp, - pcfs_vptofh, - pcfs_init -}; diff --git a/sys/pcfs/pcfs_vnops.c b/sys/pcfs/pcfs_vnops.c deleted file mode 100644 index 6d1c08f21484..000000000000 --- a/sys/pcfs/pcfs_vnops.c +++ /dev/null @@ -1,1607 +0,0 @@ -/* - * Written by Paul Popelka (paulp@uts.amdahl.com) - * - * You can do anything you want with this software, - * just don't say you wrote it, - * and don't remove this notice. - * - * This software is provided "as is". - * - * The author supplies this software to be publicly - * redistributed on the understanding that the author - * is not responsible for the correct functioning of - * this software in any circumstances and is not liable - * for any damages caused by this software. - * - * October 1992 - * - * $Id: pcfs_vnops.c,v 1.5 1993/08/07 08:12:06 cgd Exp $ - */ - -#include "param.h" -#include "systm.h" -#include "namei.h" -#include "resourcevar.h" /* defines plimit structure in proc struct */ -#include "kernel.h" -#include "file.h" /* define FWRITE ... */ -#include "stat.h" -#include "buf.h" -#include "proc.h" -#include "mount.h" -#include "vnode.h" -#include "specdev.h" /* defines plimit structure in the proc struct */ -#include "malloc.h" - -#include "dir.h" /* defines dirent structure */ - -#include "bpb.h" -#include "direntry.h" -#include "denode.h" -#include "pcfsmount.h" -#include "fat.h" -/* - * Some general notes: - * - * In the ufs filesystem the inodes, superblocks, and indirect - * blocks are read/written using the vnode for the filesystem. - * Blocks that represent the contents of a file are read/written - * using the vnode for the file (including directories when - * they are read/written as files). - * This presents problems for the dos filesystem because data - * that should be in an inode (if dos had them) resides in the - * directory itself. Since we must update directory entries - * without the benefit of having the vnode for the directory - * we must use the vnode for the filesystem. This means that - * when a directory is actually read/written (via read, write, - * or readdir, or seek) we must use the vnode for the filesystem - * instead of the vnode for the directory as would happen in ufs. - * This is to insure we retreive the correct block from the - * buffer cache since the hash value is based upon the vnode - * address and the desired block number. - */ - -/* - * Create a regular file. - * On entry the directory to contain the file being - * created is locked. We must release before we - * return. - * We must also free the pathname buffer pointed at - * by ndp->ni_pnbuf, always on error, or only if the - * SAVESTART bit in ni_nameiop is clear on success. - */ -int -pcfs_create(ndp, vap, p) - struct nameidata *ndp; - struct vattr *vap; - struct proc *p; -{ - struct denode ndirent; - struct direntry *ndirp = &ndirent.de_de; - struct denode *dep; - struct denode *pdep = VTODE(ndp->ni_dvp); - int error; -#if defined(PCFSDEBUG) -printf("pcfs_create(ndp %08x, vap %08x, p %08x\n", ndp, vap, p); -#endif /* defined(PCFSDEBUG) */ - -/* - * Create a directory entry for the file, then call - * createde() to have it installed. - * NOTE: DOS files are always executable. We use the - * absence of the owner write bit to make the file readonly. - */ - bzero(&ndirent, sizeof(ndirent)); - unix2dostime(&time, (union dosdate *)&ndirp->deDate, - (union dostime *)&ndirp->deTime); - unix2dosfn((u_char *)ndp->ni_ptr, ndirp->deName, ndp->ni_namelen); - ndirp->deAttributes = (vap->va_mode & VWRITE) ? 0 : ATTR_READONLY; - ndirp->deStartCluster = 0; - ndirp->deFileSize = 0; - ndirent.de_pmp = pdep->de_pmp; - ndirent.de_dev = pdep->de_dev; - ndirent.de_devvp = pdep->de_devvp; - if ((error = createde(&ndirent, ndp, &dep)) == 0) { - ndp->ni_vp = DETOV(dep); - if ((ndp->ni_nameiop & SAVESTART) == 0) - free(ndp->ni_pnbuf, M_NAMEI); - } else { - free(ndp->ni_pnbuf, M_NAMEI); - } - deput(pdep); /* release parent dir */ - return error; -} - -int -pcfs_mknod(ndp, vap, cred, p) - struct nameidata *ndp; - struct vattr *vap; - struct ucred *cred; - struct proc *p; -{ - int error; - - switch (vap->va_type) { - case VDIR: - error = pcfs_mkdir(ndp, vap, p); - break; - -/* - * pcfs_create() sets ndp->ni_vp. - */ - case VREG: - error = pcfs_create(ndp, vap, p); - break; - - default: - error = EINVAL; - break; - } - return error; -} - -int -pcfs_open(vp, mode, cred, p) - struct vnode *vp; - int mode; - struct ucred *cred; - struct proc *p; -{ - return 0; -} - -int -pcfs_close(vp, fflag, cred, p) - struct vnode *vp; - int fflag; - struct ucred *cred; - struct proc *p; -{ - struct denode *dep = VTODE(vp); - - if (vp->v_usecount > 1 && !(dep->de_flag & DELOCKED)) - DETIMES(dep, &time); - return 0; -} - -int -pcfs_access(vp, mode, cred, p) - struct vnode *vp; - int mode; - struct ucred *cred; - struct proc *p; -{ - int dosmode; - struct denode *dep = VTODE(vp); - -/* - * Root gets to do anything. Even execute a file - * without the x-bit on? But, for dos filesystems - * every file is executable. I may regret this. - */ - if (cred->cr_uid == 0) - return 0; - -/* - * mode is filled with a combination of VREAD, VWRITE, - * and/or VEXEC bits turned on. In an octal number these - * are the Y in 0Y00. - * - * Since the dos filesystem doesn't have the concept of - * file ownership we just give everybody read and execute - * access and write access if the readonly bit is off. - */ - dosmode = VEXEC | VREAD | - ((dep->de_Attributes & ATTR_READONLY) ? 0 : VWRITE); - return ((dosmode & mode) != 0) ? 0 : EACCES; -} - -int -pcfs_getattr(vp, vap, cred, p) - struct vnode *vp; - struct vattr *vap; - struct ucred *cred; - struct proc *p; -{ - u_int cn; - struct denode *dep = VTODE(vp); - - DETIMES(dep, &time); - vap->va_fsid = dep->de_dev; - /* The following computation of the fileid must be the - * same as that used in pcfs_readdir() to compute d_fileno. - * If not, pwd doesn't work. */ - if (dep->de_Attributes & ATTR_DIRECTORY) { - if ((cn = dep->de_StartCluster) == PCFSROOT) - cn = 1; - } else { - if ((cn = dep->de_dirclust) == PCFSROOT) - cn = 1; - cn = (cn << 16) | (dep->de_diroffset & 0xffff); - } - vap->va_fileid = cn; - vap->va_mode = (dep->de_Attributes & ATTR_READONLY) ? 0555 : 0777; - if (dep->de_Attributes & ATTR_DIRECTORY) - vap->va_mode |= S_IFDIR; - vap->va_nlink = 1; - vap->va_gid = 0; - vap->va_uid = 0; - vap->va_rdev = 0; - vap->va_size = dep->de_FileSize; - vap->va_size_rsv = 0; - dos2unixtime((union dosdate *)&dep->de_Date, - (union dostime *)&dep->de_Time, &vap->va_atime); - vap->va_atime.tv_usec = 0; - vap->va_mtime.tv_sec = vap->va_atime.tv_sec; - vap->va_mtime.tv_usec = 0; - vap->va_ctime.tv_sec = vap->va_atime.tv_sec; - vap->va_ctime.tv_usec = 0; - vap->va_flags = dep->de_flag; - vap->va_gen = 0; - vap->va_blocksize = dep->de_pmp->pm_bpcluster; - vap->va_bytes = (dep->de_FileSize + dep->de_pmp->pm_crbomask) & - ~(dep->de_pmp->pm_crbomask); - vap->va_bytes_rsv = 0; - vap->va_type = vp->v_type; - return 0; -} - -int -pcfs_setattr(vp, vap, cred, p) - struct vnode *vp; - struct vattr *vap; - struct ucred *cred; - struct proc *p; -{ - int error = 0; - struct denode *dep = VTODE(vp); - -#if defined(PCFSDEBUG) -printf("pcfs_setattr(): vp %08x, vap %08x, cred %08x, p %08x\n", - vp, vap, cred, p); -#endif /* defined(PCFSDEBUG) */ - if ((vap->va_type != VNON) || - (vap->va_nlink != VNOVAL) || - (vap->va_fsid != VNOVAL) || - (vap->va_fileid != VNOVAL) || - (vap->va_blocksize != VNOVAL) || - (vap->va_rdev != VNOVAL) || - (vap->va_bytes != VNOVAL) || - (vap->va_gen != VNOVAL) || -#if 0 - (vap->va_uid != (u_short)VNOVAL) || - (vap->va_gid != (u_short)VNOVAL) || - (vap->va_atime.tv_sec != VNOVAL) || -#endif - 0) { -#if defined(PCFSDEBUG) -printf("pcfs_setattr(): returning EINVAL\n"); -printf(" va_type %d, va_nlink %x, va_fsid %x, va_fileid %x\n", - vap->va_type, vap->va_nlink, vap->va_fsid, vap->va_fileid); -printf(" va_blocksize %x, va_rdev %x, va_bytes %x, va_gen %x\n", - vap->va_blocksize, vap->va_rdev, vap->va_bytes, vap->va_gen); -printf(" va_uid %x, va_gid %x, va_atime.tv_sec %x\n", - vap->va_uid, vap->va_gid, vap->va_atime.tv_sec); -#endif /* defined(PCFSDEBUG) */ - return EINVAL; - } - - if (vap->va_size != VNOVAL) { - if (vp->v_type == VDIR) - return EISDIR; - if (error = detrunc(dep, vap->va_size, 0)) - return error; - } - if (vap->va_mtime.tv_sec != VNOVAL) { - dep->de_flag |= DEUPD; - if (error = deupdat(dep, &vap->va_mtime, 1)) - return error; - } - -/* - * DOS files only have the ability to have thier - * writability attribute set, so we use the owner - * write bit to set the readonly attribute. - */ - if (vap->va_mode != (u_short)VNOVAL) { - /* We ignore the read and execute bits */ - if (vap->va_mode & VWRITE) - dep->de_Attributes &= ~ATTR_READONLY; - else - dep->de_Attributes |= ATTR_READONLY; - dep->de_flag |= DEUPD; - } - - if (vap->va_flags != VNOVAL) { - if (error = suser(cred, &p->p_acflag)) - return error; - if (cred->cr_uid == 0) - dep->de_flag = vap->va_flags; - else { - dep->de_flag &= 0xffff0000; - dep->de_flag |= (vap->va_flags & 0xffff); - } - dep->de_flag |= DEUPD; - } - return error; -} - - -int -pcfs_read(vp, uio, ioflag, cred) - struct vnode *vp; - struct uio *uio; - int ioflag; - struct ucred *cred; -{ - int error = 0; - int diff; - int isadir; - long n; - long on; - daddr_t bn; - daddr_t lbn; - daddr_t rablock; - struct buf *bp; - struct denode *dep = VTODE(vp); - struct pcfsmount *pmp = dep->de_pmp; - -/* - * If they didn't ask for any data, then we - * are done. - */ - if (uio->uio_resid == 0) - return 0; - if (uio->uio_offset < 0) - return EINVAL; - - isadir = dep->de_Attributes & ATTR_DIRECTORY; - do { - lbn = uio->uio_offset >> pmp->pm_cnshift; - on = uio->uio_offset & pmp->pm_crbomask; - n = MIN((u_long)(pmp->pm_bpcluster - on), uio->uio_resid); - diff = dep->de_FileSize - uio->uio_offset; - if (diff <= 0) - return 0; - /* convert cluster # to block # if a directory */ - if (isadir) { - error = pcbmap(dep, lbn, &lbn, 0); - if (error) - return error; - } - if (diff < n) - n = diff; -/* - * If we are operating on a directory file then be - * sure to do i/o with the vnode for the filesystem - * instead of the vnode for the directory. - */ - if (isadir) { - error = bread(pmp->pm_devvp, lbn, pmp->pm_bpcluster, - NOCRED, &bp); - } else { - rablock = lbn + 1; - if (vp->v_lastr + 1 == lbn && - rablock * pmp->pm_bpcluster < dep->de_FileSize) { - error = breada(vp, lbn, pmp->pm_bpcluster, - rablock, pmp->pm_bpcluster, NOCRED, &bp); - } else { - error = bread(vp, lbn, pmp->pm_bpcluster, NOCRED, - &bp); - } - vp->v_lastr = lbn; - } - if (error) { - brelse(bp); - return error; - } - n = MIN(n, pmp->pm_bpcluster - bp->b_resid); - error = uiomove(bp->b_un.b_addr + on, (int)n, uio); -/* - * If we have read everything from this block or - * have read to end of file then we are done with - * this block. Mark it to say the buffer can be reused if - * need be. - */ -#if 0 - if (n + on == pmp->pm_bpcluster || - uio->uio_offset == dep->de_FileSize) - bp->b_flags |= B_AGE; -#endif - brelse(bp); - } while (error == 0 && uio->uio_resid > 0 && n != 0); - return error; -} - -/* - * Write data to a file or directory. - */ -int -pcfs_write(vp, uio, ioflag, cred) - struct vnode *vp; - struct uio *uio; - int ioflag; - struct ucred *cred; -{ - int n; - int croffset; - int resid; - int osize; - int error; - u_long cluster; - u_long nextcluster; - u_long lastcluster; - daddr_t bn; - struct buf *bp; - struct proc *p = uio->uio_procp; - struct denode *dep = VTODE(vp); - struct pcfsmount *pmp = dep->de_pmp; - -#if defined(PCFSDEBUG) -printf("pcfs_write(vp %08x, uio %08x, ioflag %08x, cred %08x\n", - vp, uio, ioflag, cred); -printf("pcfs_write(): diroff %d, dirclust %d, startcluster %d\n", - dep->de_diroffset, dep->de_dirclust, dep->de_StartCluster); -#endif /* defined(PCFSDEBUG) */ - - switch (vp->v_type) { - case VREG: - if (ioflag & IO_APPEND) - uio->uio_offset = dep->de_FileSize; - break; - - case VDIR: - /* In pcfs, directory updates don't use pcfs_write */ - panic("pcfs_write(): directory update"); - break; - - default: - panic("pcfs_write(): bad file type"); - break; - } - - if (uio->uio_offset < 0) - return EINVAL; - if (uio->uio_resid == 0) - return 0; - -/* - * If they've exceeded their filesize limit, tell them about it. - */ - if (vp->v_type == VREG && p && - ((uio->uio_offset + uio->uio_resid) > - p->p_rlimit[RLIMIT_FSIZE].rlim_cur)) { - psignal(p, SIGXFSZ); - return EFBIG; - } - -/* - * If the offset we are starting the write at is beyond the - * end of the file, then they've done a seek. Unix filesystems - * allow files with holes in them, DOS doesn't so we must - * fill the hole with zeroed blocks. - */ - if (uio->uio_offset > dep->de_FileSize) { - error = pcfsextend(vp, uio->uio_offset); - if (error) - return error; - } - -/* - * Remember some values in case the write fails. - */ - resid = uio->uio_resid; - osize = dep->de_FileSize; - - do { - bn = uio->uio_offset >> pmp->pm_cnshift; - croffset = uio->uio_offset & pmp->pm_crbomask; - n = MIN(uio->uio_resid, pmp->pm_bpcluster-croffset); -/* - * If we are appending to the file and we are on a - * cluster boundary, then allocate a new cluster - * and chain it onto the file. - */ - if (uio->uio_offset == dep->de_FileSize && - (uio->uio_offset & pmp->pm_crbomask) == 0) { - if (error = extendfile(dep, &bp, 0)) - break; - } else { -/* - * The block we need to write into exists, - * so just read it in. - */ - if (n == pmp->pm_bpcluster) - /* We will overwrite the whole block, so - * dont read it*/ - bp = getblk(vp, bn, pmp->pm_bpcluster); - else { - error = bread(vp, bn, pmp->pm_bpcluster, cred, &bp); - if (error) { - brelse(bp); - return error; - } - } - } - if (uio->uio_offset+n > dep->de_FileSize) { - dep->de_FileSize = uio->uio_offset + n; - vnode_pager_setsize(vp, dep->de_FileSize); - } - (void) vnode_pager_uncache(vp); - -/* - * Copy the data from user space into the buf header. - */ - error = uiomove(bp->b_un.b_addr+croffset, n, uio); - -/* - * If they want this synchronous then write it and wait - * for it. Otherwise, if on a cluster boundary write it - * asynchronously so we can move on to the next block - * without delay. Otherwise do a delayed write because - * we may want to write somemore into the block later. - */ - if (ioflag & IO_SYNC) - (void) bwrite(bp); - else - if (n + croffset == pmp->pm_bpcluster) { - bp->b_flags |= B_AGE; - bawrite(bp); - } else - bdwrite(bp); - dep->de_flag |= DEUPD; - } while (error == 0 && uio->uio_resid > 0); - -/* - * If the write failed and they want us to, truncate - * the file back to the size it was before the write - * was attempted. - */ - if (error && (ioflag & IO_UNIT)) { - detrunc(dep, osize, ioflag & IO_SYNC); - uio->uio_offset -= resid - uio->uio_resid; - uio->uio_resid = resid; - } - if (!error && (ioflag & IO_UNIT)) - error = deupdat(dep, &time, 1); - return error; -} - -int -pcfs_ioctl(vp, com, data, fflag, cred, p) - struct vnode *vp; - int com; - caddr_t data; - struct ucred *cred; - struct proc *p; -{ - return ENOTTY; -} - -int -pcfs_select(vp, which, fflags, cred, p) - struct vnode *vp; - int which; - int fflags; - struct ucred *cred; - struct proc *p; -{ - return 1; /* DOS filesystems never block? */ -} - -int -pcfs_mmap(vp, fflags, cred, p) - struct vnode *vp; - int fflags; - struct ucred *cred; - struct proc *p; -{ - return EINVAL; -} - -/* - * Flush the blocks of a file to disk. - * - * This function is worthless for vnodes that represent - * directories. - * Maybe we could just do a sync if they try an fsync - * on a directory file. - */ -int -pcfs_fsync(vp, fflags, cred, waitfor, p) - struct vnode *vp; - int fflags; - struct ucred *cred; - int waitfor; - struct proc *p; -{ - struct denode *dep = VTODE(vp); - - if (fflags & FWRITE) - dep->de_flag |= DEUPD; - - vflushbuf(vp, waitfor == MNT_WAIT ? B_SYNC : 0); - return deupdat(dep, &time, waitfor == MNT_WAIT); -} - -/* - * Since the dos filesystem does not allow files with - * holes in them we must fill the file with zeroed - * blocks when a write past the end of file happens. - */ -int -pcfsextend(vp, newoff) - struct vnode *vp; - off_t newoff; -{ - int error = 0; - off_t foff; - struct buf *bp; - struct denode *dep = VTODE(vp); - struct pcfsmount *pmp = dep->de_pmp; - -#ifdef DIAGNOSTIC - if (dep->de_Attributes & ATTR_DIRECTORY) - /* should not happen */ - return EISDIR; -#endif - -/* - * Compute the offset of the first byte after the - * last block in the file. - * If writing beyond the end of file then fill the - * file with zeroed blocks up to the seek address. - */ - foff = (dep->de_FileSize + (pmp->pm_bpcluster-1)) & ~pmp->pm_crbomask; - if (newoff <= foff) - return 0; - -/* - * Allocate and chain together as many clusters as - * are needed to get to newoff. - */ - while (foff < newoff) { - if (error = extendfile(dep, &bp, 0)) - return error; - bdwrite(bp); - foff += pmp->pm_bpcluster; - dep->de_FileSize += pmp->pm_bpcluster; - } - dep->de_FileSize = newoff; - dep->de_flag |= DEUPD; - return deupdat(dep, &time); -} - -/* - * Seek on a file - * - * Nothing to do, so just return. - */ -int -pcfs_seek(vp, oldoff, newoff, cred) - struct vnode *vp; - off_t oldoff; - off_t newoff; - struct ucred *cred; -{ - return 0; -} - -int -pcfs_remove(ndp, p) - struct nameidata *ndp; - struct proc *p; -{ - int error; - struct denode *dep = VTODE(ndp->ni_vp); - struct denode *ddep = VTODE(ndp->ni_dvp); - - error = removede(ndp); -#if defined(PCFSDEBUG) -printf("pcfs_remove(), dep %08x, v_usecount %d\n", dep, ndp->ni_vp->v_usecount); -#endif /* defined(PCFSDEBUG) */ - if (ddep == dep) - vrele(DETOV(dep)); - else - deput(dep); /* causes pcfs_inactive() to be called via vrele() */ - deput(ddep); - return error; -} - -/* - * DOS filesystems don't know what links are. - */ -int -pcfs_link(vp, ndp, p) - struct vnode *vp; - struct nameidata *ndp; - struct proc *p; -{ - return EINVAL; -} - -/* - * Renames on files require moving the denode to - * a new hash queue since the denode's location is - * used to compute which hash queue to put the file in. - * Unless it is a rename in place. For example "mv a b". - * - * What follows is the basic algorithm: - * - * if (file move) { - * if (dest file exists) { - * remove dest file - * } - * if (dest and src in same directory) { - * rewrite name in existing directory slot - * } else { - * write new entry in dest directory - * update offset and dirclust in denode - * move denode to new hash chain - * clear old directory entry - * } - * } else { directory move - * if (dest directory exists) { - * if (dest is not empty) { - * return ENOTEMPTY - * } - * remove dest directory - * } - * if (dest and src in same directory) { - * rewrite name in existing entry - * } else { - * be sure dest is not a child of src directory - * write entry in dest directory - * update "." and ".." in moved directory - * update offset and dirclust in denode - * move denode to new hash chain - * clear old directory entry for moved directory - * } - * } - * - * On entry: - * source's parent directory is unlocked - * source file or directory is unlocked - * destination's parent directory is locked - * destination file or directory is locked if it exists - * - * On exit: - * all denodes should be released - * Notes: - * I'm not sure how the memory containing the pathnames - * pointed at by the nameidata structures is freed, there - * may be some memory bleeding for each rename done. - */ -int -pcfs_rename(fndp, tndp, p) - struct nameidata *fndp; - struct nameidata *tndp; - struct proc *p; -{ - u_char toname[11]; - int error; - int newparent = 0; - int sourceisadirectory = 0; - u_long to_dirclust; - u_long to_diroffset; - u_long cn; - daddr_t bn; - struct denode *fddep; /* from file's parent directory */ - struct denode *fdep; /* from file or directory */ - struct denode *tddep; /* to file's parent directory */ - struct denode *tdep; /* to file or directory */ - struct pcfsmount *pmp; - struct direntry *dotdotp; - struct direntry *ep; - struct buf *bp; - -#if defined(PCFSDEBUG) -printf("pcfs_rename(fndp %08x, tndp %08x, p %08x\n", fndp, tndp, p); -#endif /* defined(PCFSDEBUG) */ - fddep = VTODE(fndp->ni_dvp); - fdep = VTODE(fndp->ni_vp); - tddep = VTODE(tndp->ni_dvp); - tdep = tndp->ni_vp ? VTODE(tndp->ni_vp) : NULL; - pmp = fddep->de_pmp; - -/* - * Convert the filename in tdnp into a dos filename. - * We copy this into the denode and directory entry - * for the destination file/directory. - */ - unix2dosfn((u_char *)tndp->ni_ptr, toname, tndp->ni_namelen); - -/* - * At this point this is the lock state of the denodes: - * fddep referenced - * fdep referenced - * tddep locked - * tdep locked if it exists - */ - -/* - * Be sure we are not renaming ".", "..", or an alias of ".". - * This leads to a crippled directory tree. It's pretty tough - * to do a "ls" or "pwd" with the "." directory entry missing, - * and "cd .." doesn't work if the ".." entry is missing. - */ - if (fdep->de_Attributes & ATTR_DIRECTORY) { - if ((fndp->ni_namelen == 1 && fndp->ni_ptr[0] == '.') || - fddep == fdep || /* won't happen ? */ - fndp->ni_isdotdot) { - VOP_ABORTOP(tndp); - vput(tndp->ni_dvp); - if (tndp->ni_vp) - vput(tndp->ni_vp); - VOP_ABORTOP(fndp); - vrele(fndp->ni_dvp); - vrele(fndp->ni_vp); - return EINVAL; - } - sourceisadirectory = 1; - } - -/* - * If we are renaming a directory, and the directory - * is being moved to another directory, then we must - * be sure the destination directory is not in the - * subtree of the source directory. This could orphan - * everything under the source directory. - * doscheckpath() unlocks the destination's parent - * directory so we must look it up again to relock it. - */ - if (fddep->de_StartCluster != tddep->de_StartCluster) - newparent = 1; - if (sourceisadirectory && newparent) { - if (tdep) { - deput(tdep); - tdep = NULL; - } - /* doscheckpath() deput()'s tddep */ - error = doscheckpath(fdep, tddep, tndp->ni_cred); - tddep = NULL; - if (error) - goto bad; - if ((tndp->ni_nameiop & SAVESTART) == 0) - panic("pcfs_rename(): lost to startdir"); - if (error = lookup(tndp, p)) - goto bad; - tddep = VTODE(tndp->ni_dvp); - tdep = tndp->ni_vp ? VTODE(tndp->ni_vp) : NULL; - } - -/* - * If the destination exists, then be sure its type (file or dir) - * matches that of the source. And, if it is a directory make - * sure it is empty. Then delete the destination. - */ - if (tdep) { - if (tdep->de_Attributes & ATTR_DIRECTORY) { - if (!sourceisadirectory) { - error = ENOTDIR; - goto bad; - } - if (!dosdirempty(tdep)) { - error = ENOTEMPTY; - goto bad; - } - } else { /* destination is file */ - if (sourceisadirectory) { - error = EISDIR; - goto bad; - } - } - to_dirclust = tdep->de_dirclust; - to_diroffset = tdep->de_diroffset; - if (error = removede(tndp)) - goto bad; - deput(tdep); - tdep = NULL; - -/* - * Remember where the slot was for createde(). - */ - tndp->ni_pcfs.pcfs_count = 1; - tndp->ni_pcfs.pcfs_cluster = to_dirclust; - tndp->ni_pcfs.pcfs_offset = to_diroffset; - } - -/* - * If the source and destination are in the same - * directory then just read in the directory entry, - * change the name in the directory entry and - * write it back to disk. - */ - if (newparent == 0) { - /* tddep and fddep point to the same denode here */ - DELOCK(fdep); /* tddep is already locked */ - if (error = readde(fdep, &bp, &ep)) { - DEUNLOCK(fdep); - goto bad; - } - bcopy(toname, ep->deName, 11); - if (error = bwrite(bp)) { - DEUNLOCK(fdep); - goto bad; - } - bcopy(toname, fdep->de_Name, 11); /* update denode */ -/* - * fdep locked - * fddep and tddep point to the same denode which is locked - * tdep is unlocked and unreferenced - */ - } else { - u_long dirsize; -/* - * If the source and destination are in different - * directories, then mark the entry in the source - * directory as deleted and write a new entry in the - * destination directory. Then move the denode to - * the correct hash chain for its new location in - * the filesystem. And, if we moved a directory, - * then update its .. entry to point to the new - * parent directory. - * If we moved a directory will also insure that - * the directory entry on disk has a filesize of - * zero. - */ - DELOCK(fdep); - bcopy(toname, fdep->de_Name, 11); /* update denode */ - if (fdep->de_Attributes & ATTR_DIRECTORY) { - dirsize = fdep->de_FileSize; - fdep->de_FileSize = 0; - } - error = createde(fdep, tndp, (struct denode **)0); - if (fdep->de_Attributes & ATTR_DIRECTORY) { - fdep->de_FileSize = dirsize; - } - if (error) { - /* should put back filename */ - DEUNLOCK(fdep); - goto bad; - } - DELOCK(fddep); - error = markdeleted (pmp, - fndp->ni_pcfs.pcfs_cluster, - fndp->ni_pcfs.pcfs_offset); - if (error) { - DEUNLOCK(fdep); - DEUNLOCK(fddep); - goto bad; - } - if (!(fdep->de_Attributes & ATTR_DIRECTORY)) { - fdep->de_dirclust = tndp->ni_pcfs.pcfs_cluster; - fdep->de_diroffset = tndp->ni_pcfs.pcfs_offset; - reinsert(fdep); - } - DEUNLOCK(fddep); - } - /* fdep is still locked here */ - -/* - * If we moved a directory to a new parent directory, - * then we must fixup the ".." entry in the moved - * directory. - */ - if (sourceisadirectory && newparent) { - cn = fdep->de_StartCluster; - if (cn == PCFSROOT) - /* this should never happen */ - panic("pcfs_rename(): updating .. in root directory?\n"); - error = readep(pmp, cn, 1, &bp, &dotdotp); - if (error) { - /* should really panic here, fs is corrupt */ - DEUNLOCK(fdep); - goto bad; - } - dotdotp->deStartCluster = tddep->de_StartCluster; - error = bwrite(bp); - DEUNLOCK(fdep); - if (error) - /* should really panic here, fs is corrupt */ - goto bad; - } - else - DEUNLOCK(fdep); -bad:; - vrele(DETOV(fdep)); - vrele(DETOV(fddep)); - if (tdep) - vput(DETOV(tdep)); - if (tddep) - vput(DETOV(tddep)); - return error; -} - -struct { - struct direntry dot; - struct direntry dotdot; -} dosdirtemplate = { - ". ", " ", /* the . entry */ - ATTR_DIRECTORY, /* file attribute */ - 0,0,0,0,0,0,0,0,0,0, /* resevered */ - 1234, 1234, /* time and date */ - 0, /* startcluster */ - 0, /* filesize */ - ".. ", " ", /* the .. entry */ - ATTR_DIRECTORY, /* file attribute */ - 0,0,0,0,0,0,0,0,0,0, /* resevered */ - 1234, 1234, /* time and date */ - 0, /* startcluster */ - 0, /* filesize */ -}; - -int -pcfs_mkdir(ndp, vap, p) - struct nameidata *ndp; - struct vattr *vap; - struct proc *p; -{ - int bn; - int error; - u_long newcluster; - struct denode *pdep; - struct denode *ndep; - struct vnode *pvp; - struct direntry *denp; - struct denode ndirent; - struct pcfsmount *pmp; - struct buf *bp; - - pvp = ndp->ni_dvp; - pdep = VTODE(pvp); - -/* - * If this is the root directory and there is no space left - * we can't do anything. This is because the root directory - * can not change size. - */ - if (pdep->de_StartCluster == PCFSROOT && ndp->ni_pcfs.pcfs_count == 0) { - free(ndp->ni_pnbuf, M_NAMEI); - deput(pdep); - return ENOSPC; - } - - pmp = pdep->de_pmp; - -/* - * Allocate a cluster to hold the about to be created directory. - */ - if (error = clusteralloc(pmp, &newcluster, CLUST_EOFE)) { - free(ndp->ni_pnbuf, M_NAMEI); - deput(pdep); - return error; - } - -/* - * Now fill the cluster with the "." and ".." entries. - * And write the cluster to disk. This way it is there - * for the parent directory to be pointing at if there - * were a crash. - */ - bn = cntobn(pmp, newcluster); - bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster); /* always succeeds */ - clrbuf(bp); - bcopy(&dosdirtemplate, bp->b_un.b_addr, sizeof dosdirtemplate); - denp = (struct direntry *)bp->b_un.b_addr; - denp->deStartCluster = newcluster; - unix2dostime(&time, (union dosdate *)&denp->deDate, - (union dostime *)&denp->deTime); - denp++; - denp->deStartCluster = pdep->de_StartCluster; - unix2dostime(&time, (union dosdate *)&denp->deDate, - (union dostime *)&denp->deTime); - if (error = bwrite(bp)) { - clusterfree(pmp, newcluster, NULL); - free(ndp->ni_pnbuf, M_NAMEI); - deput(pdep); - return error; - } - -/* - * Now build up a directory entry pointing to the newly - * allocated cluster. This will be written to an empty - * slot in the parent directory. - */ - ndep = &ndirent; - bzero(ndep, sizeof(*ndep)); - unix2dosfn((u_char *)ndp->ni_ptr, ndep->de_Name, ndp->ni_namelen); - unix2dostime(&time, (union dosdate *)&ndep->de_Date, - (union dostime *)&ndep->de_Time); - ndep->de_StartCluster = newcluster; - ndep->de_Attributes = ATTR_DIRECTORY; - ndep->de_pmp = pmp; /* createde() needs this */ - - error = createde(ndep, ndp, &ndep); - if (error) { - clusterfree(pmp, newcluster, NULL); - } else { - ndp->ni_vp = DETOV(ndep); - } - free(ndp->ni_pnbuf, M_NAMEI); -#if defined(PCFSDEBUG) -printf("pcfs_mkdir(): deput(%08x), vnode %08x\n", pdep, DETOV(pdep)); -#endif /* defined(PCFSDEBUG) */ - deput(pdep); - return error; -} - -int -pcfs_rmdir(ndp, p) - struct nameidata *ndp; - struct proc *p; -{ - struct denode *ddep; - struct denode *dep; - int error = 0; - - ddep = VTODE(ndp->ni_dvp); /* parent dir of dir to delete */ - dep = VTODE(ndp->ni_vp); /* directory to delete */ - -/* - * Don't let "rmdir ." go thru. - */ - if (ddep == dep) { - vrele(DETOV(dep)); - deput(dep); - return EINVAL; - } - -/* - * Be sure the directory being deleted is empty. - */ - if (dosdirempty(dep) == 0) { - error = ENOTEMPTY; - goto out; - } - -/* - * Delete the entry from the directory. For dos filesystems - * this gets rid of the directory entry on disk, the in memory - * copy still exists but the de_refcnt is <= 0. This prevents - * it from being found by deget(). When the deput() on dep is - * done we give up access and eventually pcfs_reclaim() will - * be called which will remove it from the denode cache. - */ - if (error = removede(ndp)) - goto out; - -/* - * This is where we decrement the link count in the parent - * directory. Since dos filesystems don't do this we just - * purge the name cache and let go of the parent directory - * denode. - */ - cache_purge(DETOV(ddep)); - deput(ddep); - ndp->ni_dvp = NULL; /* getting rid of parent dir pointer? */ - -/* - * Truncate the directory that is being deleted. - */ - error = detrunc(dep, (u_long)0, IO_SYNC); - cache_purge(DETOV(dep)); - -out:; - if (ndp->ni_dvp) - deput(ddep); - deput(dep); - return error; -} - -/* - * DOS filesystems don't know what symlinks are. - */ -int -pcfs_symlink(ndp, vap, target, p) - struct nameidata *ndp; - struct vattr *vap; - char *target; - struct proc *p; -{ - return EINVAL; -} - -/* - * Dummy dirents to simulate the "." and ".." entries - * of the root directory in a dos filesystem. Dos doesn't - * provide these. - * Note that each entry must be the same size as a dos - * directory entry (32 bytes). - */ -struct dos_dirent { - u_long d_fileno; - u_short d_reclen; - u_short d_namlen; - u_char d_name[24]; -} rootdots[2] = { - { - 1, /* d_fileno */ - sizeof(struct direntry), /* d_reclen */ - 1, /* d_namlen */ - "." /* d_name */ - }, - { - 1, /* d_fileno */ - sizeof(struct direntry), /* d_reclen */ - 2, /* d_namlen */ - ".." /* d_name */ - } -}; - -int -pcfs_readdir(vp, uio, cred, eofflagp) - struct vnode *vp; - struct uio *uio; - struct ucred *cred; - int *eofflagp; -{ - int error = 0; - int diff; - char pushout; - long n; - long on; - long lost; - long count; - u_long cn; - u_long fileno; - long bias = 0; - daddr_t bn; - daddr_t lbn; - struct buf *bp; - struct denode *dep = VTODE(vp); - struct pcfsmount *pmp = dep->de_pmp; - struct direntry *dentp; - struct dirent *prev; - struct dirent *crnt; - u_char dirbuf[512]; /* holds converted dos directories */ -int i=0; - -#if defined(PCFSDEBUG) -printf("pcfs_readdir(): vp %08x, uio %08x, cred %08x, eofflagp %08x\n", - vp, uio, cred, eofflagp); -#endif /* defined(PCFSDEBUG) */ - -/* - * pcfs_readdir() won't operate properly on regular files - * since it does i/o only with the the filesystem vnode, - * and hence can retrieve the wrong block from the buffer - * cache for a plain file. So, fail attempts to readdir() - * on a plain file. - */ - if ((dep->de_Attributes & ATTR_DIRECTORY) == 0) - return ENOTDIR; - -/* - * If the user buffer is smaller than the size of one dos - * directory entry or the file offset is not a multiple of - * the size of a directory entry, then we fail the read. - */ - count = uio->uio_resid & ~(sizeof(struct direntry)-1); - lost = uio->uio_resid - count; - if (count < sizeof(struct direntry) || - (uio->uio_offset & (sizeof(struct direntry)-1))) - return EINVAL; - uio->uio_resid = count; - uio->uio_iov->iov_len = count; - -/* - * If they are reading from the root directory then, - * we simulate the . and .. entries since these don't - * exist in the root directory. We also set the offset - * bias to make up for having to simulate these entries. - * By this I mean that at file offset 64 we read the first entry - * in the root directory that lives on disk. - */ - if (dep->de_StartCluster == PCFSROOT) { -/*printf("pcfs_readdir(): going after . or .. in root dir, offset %d\n", - uio->uio_offset);*/ - bias = 2*sizeof(struct direntry); - if (uio->uio_offset < 2*sizeof(struct direntry)) { - error = uiomove((char *)rootdots + uio->uio_offset, - sizeof rootdots - uio->uio_offset, uio); - if (error) - goto out; - } - } - do { - lbn = (uio->uio_offset-bias) >> pmp->pm_cnshift; - on = (uio->uio_offset-bias) & pmp->pm_crbomask; - n = MIN((u_long)(pmp->pm_bpcluster - on), uio->uio_resid); - diff = dep->de_FileSize - (uio->uio_offset - bias); - if (diff <= 0) - return 0; - if (diff < n) - n = diff; - error = pcbmap(dep, lbn, &bn, &cn); - if (error) - break; - error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, &bp); - if (error) { - brelse(bp); - return error; - } - n = MIN(n, pmp->pm_bpcluster - bp->b_resid); - -/* - * code to convert from dos directory entries to ufs directory entries - */ - pushout = 0; - dentp = (struct direntry *)(bp->b_un.b_addr + on); - prev = 0; - crnt = (struct dirent *)dirbuf; - while ((char *)dentp < bp->b_un.b_addr + on + n) { -/*printf("rd: dentp %08x prev %08x crnt %08x deName %02x attr %02x\n", - dentp, prev, crnt, dentp->deName[0], dentp->deAttributes);*/ -/* - * If we have an empty entry or a slot from a deleted - * file, or a volume label entry just concatenate its - * space onto the end of the previous entry or, - * manufacture an empty entry if there is no previous - * entry. - */ - if (dentp->deName[0] == SLOT_EMPTY || - dentp->deName[0] == SLOT_DELETED || - (dentp->deAttributes & ATTR_VOLUME)) { - if (prev) { - prev->d_reclen += sizeof(struct direntry); - } else { - prev = crnt; - prev->d_fileno = 0; - prev->d_reclen = sizeof(struct direntry); - prev->d_namlen = 0; - prev->d_name[0] = 0; - } - } else { - /* this computation of d_fileno must match - * the computation of va_fileid in pcfs_getattr */ - if (dentp->deAttributes & ATTR_DIRECTORY) { - /* if this is the root directory */ - if ((fileno = dentp->deStartCluster) == PCFSROOT) - fileno = 1; - } else { - /* if the file's dirent lives in root dir */ - if ((fileno = cn) == PCFSROOT) - fileno = 1; - fileno = (fileno << 16) | - ((dentp - (struct direntry *)bp->b_un.b_addr) & 0xffff); - } - crnt->d_fileno = fileno; - crnt->d_reclen = sizeof(struct direntry); - crnt->d_namlen = dos2unixfn(dentp->deName, - (u_char *)crnt->d_name); -/*printf("readdir: file %s, fileno %08x, attr %02x, start %08x\n", - crnt->d_name, crnt->d_fileno, dentp->deAttributes, dentp->deStartCluster);*/ - prev = crnt; - } - crnt = (struct dirent *)((char *)crnt + sizeof(struct direntry)); - pushout = 1; - -/* - * If our intermediate buffer is full then copy - * its contents to user space. - */ - if ((u_char *)crnt >= &dirbuf[sizeof dirbuf]) { - pushout = 0; - error = uiomove(dirbuf, sizeof(dirbuf), uio); - if (error) - break; - prev = 0; - crnt = (struct dirent *)dirbuf; - } - dentp++; - } - if (pushout) { - pushout = 0; - error = uiomove(dirbuf, (char *)crnt - (char *)dirbuf, - uio); - } - -/* - * If we have read everything from this block or - * have read to end of file then we are done with - * this block. Mark it to say the buffer can be reused if - * need be. - */ -#if 0 - if (n + on == pmp->pm_bpcluster || - (uio->uio_offset-bias) == dep->de_FileSize) - bp->b_flags |= B_AGE; -#endif - brelse(bp); - } while (error == 0 && uio->uio_resid > 0 && n != 0); -out:; - uio->uio_resid += lost; - -/* - * I don't know why we bother setting this eofflag, getdirentries() - * in vfs_syscalls.c doesn't bother to look at it when we return. - * But nfsrv_readdir does. - */ - if (dep->de_FileSize - uio->uio_offset - bias <= 0) - *eofflagp = 1; - else - *eofflagp = 0; - return error; -} - -/* - * DOS filesystems don't know what symlinks are. - */ -int -pcfs_readlink(vp, uio, cred) - struct vnode *vp; - struct uio *uio; - struct ucred *cred; -{ - return EINVAL; -} - -int -pcfs_abortop(ndp) - struct nameidata *ndp; -{ - if ((ndp->ni_nameiop & (HASBUF | SAVESTART)) == HASBUF) - FREE(ndp->ni_pnbuf, M_NAMEI); - return 0; -} - -int -pcfs_lock(vp) - struct vnode *vp; -{ - struct denode *dep = VTODE(vp); - - DELOCK(dep); - return 0; -} - -int -pcfs_unlock(vp) - struct vnode *vp; -{ - struct denode *dep = VTODE(vp); - - if (!(dep->de_flag & DELOCKED)) - panic("pcfs_unlock: denode not locked"); - DEUNLOCK(dep); - return 0; -} - -int -pcfs_islocked(vp) - struct vnode *vp; -{ - return VTODE(vp)->de_flag & DELOCKED ? 1 : 0; -} - -/* - * vp - address of vnode file the file - * bn - which cluster we are interested in mapping to - * a filesystem block number. - * vpp - returns the vnode for the block special file - * holding the filesystem containing the file of interest - * bnp - address of where to return the filesystem - * relative block number - */ -int -pcfs_bmap(vp, bn, vpp, bnp) - struct vnode *vp; - daddr_t bn; - struct vnode **vpp; - daddr_t *bnp; -{ - struct denode *dep = VTODE(vp); - struct pcfsmount *pmp = dep->de_pmp; - - if (vpp != NULL) - *vpp = dep->de_devvp; - if (bnp == NULL) - return 0; - return pcbmap(dep, bn << (pmp->pm_cnshift - pmp->pm_bnshift), bnp, 0); -} - -int -pcfs_strategy(bp) - struct buf *bp; -{ - struct denode *dep = VTODE(bp->b_vp); - struct pcfsmount *pmp = dep->de_pmp; - struct vnode *vp; - int error; - - if (bp->b_vp->v_type == VBLK || bp->b_vp->v_type == VCHR) - panic("pcfs_strategy: spec"); -/* - * If we don't already know the filesystem relative - * block number then get it using pcbmap(). If pcbmap() - * returns the block number as -1 then we've got a hole - * in the file. DOS filesystems don't allow files with - * holes, so we shouldn't ever see this. - */ - if (bp->b_blkno == bp->b_lblkno) { - if (error = pcbmap(dep, bp->b_lblkno, &bp->b_blkno, 0)) - return error; - if ((long)bp->b_blkno == -1) - clrbuf(bp); - } - if ((long)bp->b_blkno == -1) { - biodone(bp); - return 0; - } -#ifdef DIAGNOSTIC -#endif /* defined(DIAGNOSTIC) */ -/* - * Read/write the block from/to the disk that contains the desired - * file block. - */ - vp = dep->de_devvp; - bp->b_dev = vp->v_rdev; - (*(vp->v_op->vop_strategy))(bp); - return 0; -} - -void -pcfs_print(vp) - struct vnode *vp; -{ - struct denode *dep = VTODE(vp); - - printf("tag VT_MSDOSFS, startcluster %d, dircluster %d, diroffset %d ", - dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset); - printf(" dev %d, %d, %s\n", - major(dep->de_dev), minor(dep->de_dev), - dep->de_flag & DELOCKED ? "(LOCKED)" : ""); - if (dep->de_spare0) { - printf(" owner pid %d", dep->de_spare0); - if (dep->de_spare1) - printf(" waiting pid %d", dep->de_spare1); - printf("\n"); - } -} - -int -pcfs_advlock(vp, id, op, fl, flags) - struct vnode *vp; - caddr_t id; - int op; - struct flock *fl; - int flags; -{ - return EINVAL; /* we don't do locking yet */ -} - -struct vnodeops pcfs_vnodeops = { - pcfs_lookup, - pcfs_create, - pcfs_mknod, - pcfs_open, - pcfs_close, - pcfs_access, - pcfs_getattr, - pcfs_setattr, - pcfs_read, - pcfs_write, - pcfs_ioctl, - pcfs_select, - pcfs_mmap, - pcfs_fsync, - pcfs_seek, - pcfs_remove, - pcfs_link, - pcfs_rename, - pcfs_mkdir, - pcfs_rmdir, - pcfs_symlink, - pcfs_readdir, - pcfs_readlink, - pcfs_abortop, - pcfs_inactive, - pcfs_reclaim, - pcfs_lock, - pcfs_unlock, - pcfs_bmap, - pcfs_strategy, - pcfs_print, - pcfs_islocked, - pcfs_advlock, -}; diff --git a/sys/pcfs/pcfsmount.h b/sys/pcfs/pcfsmount.h deleted file mode 100644 index a88aefe41211..000000000000 --- a/sys/pcfs/pcfsmount.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Written by Paul Popelka (paulp@uts.amdahl.com) - * - * You can do anything you want with this software, - * just don't say you wrote it, - * and don't remove this notice. - * - * This software is provided "as is". - * - * The author supplies this software to be publicly - * redistributed on the understanding that the author - * is not responsible for the correct functioning of - * this software in any circumstances and is not liable - * for any damages caused by this software. - * - * October 1992 - * - * $Id: pcfsmount.h,v 1.2 1993/05/20 03:34:27 cgd Exp $ - */ - -/* - * Layout of the mount control block for a msdos - * file system. - */ -struct pcfsmount { - struct mount *pm_mountp; /* vfs mount struct for this fs */ - dev_t pm_dev; /* block special device mounted */ - struct vnode *pm_devvp; /* vnode for block device mntd */ - struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */ - u_long pm_fatblk; /* block # of first FAT */ - u_long pm_rootdirblk; /* block # of root directory */ - u_long pm_rootdirsize; /* size in blocks (not clusters) */ - u_long pm_firstcluster; /* block number of first cluster */ - u_long pm_nmbrofclusters; /* # of clusters in filesystem */ - u_long pm_maxcluster; /* maximum cluster number */ - u_long pm_freeclustercount; /* number of free clusters */ - u_long pm_lookhere; /* start free cluster search here */ - u_long pm_bnshift; /* shift file offset right this - * amount to get a block number */ - u_long pm_brbomask; /* and a file offset with this - * mask to get block rel offset */ - u_long pm_cnshift; /* shift file offset right this - * amount to get a cluster number */ - u_long pm_crbomask; /* and a file offset with this - * mask to get cluster rel offset */ - u_long pm_bpcluster; /* bytes per cluster */ - u_long pm_depclust; /* directory entries per cluster */ - u_long pm_fmod; /* ~0 if fs is modified, this can - * rollover to 0 */ - u_long pm_fatblocksize; /* size of fat blocks in bytes */ - u_long pm_fatblocksec; /* size of fat blocks in sectors */ - u_long pm_fatsize; /* size of fat in bytes */ - u_char *pm_inusemap; /* ptr to bitmap of in-use clusters */ - char pm_ronly; /* read only if non-zero */ - char pm_waitonfat; /* wait for writes of the fat to complt, - * when 0 use bdwrite, else use bwrite */ -}; -/* - * How to compute pm_cnshift and pm_crbomask. - * - * pm_crbomask = (pm_SectPerClust * pm_BytesPerSect) - 1 - * if (bytesperclust == 0) return EBADBLKSZ; - * bit = 1; - * for (i = 0; i < 32; i++) { - * if (bit & bytesperclust) { - * if (bit ^ bytesperclust) return EBADBLKSZ; - * pm_cnshift = i; - * break; - * } - * bit <<= 1; - * } - */ - -/* - * Shorthand for fields in the bpb contained in - * the pcfsmount structure. - */ -#define pm_BytesPerSec pm_bpb.bpbBytesPerSec -#define pm_SectPerClust pm_bpb.bpbSecPerClust -#define pm_ResSectors pm_bpb.bpbResSectors -#define pm_FATs pm_bpb.bpbFATs -#define pm_RootDirEnts pm_bpb.bpbRootDirEnts -#define pm_Sectors pm_bpb.bpbSectors -#define pm_Media pm_bpb.bpbMedia -#define pm_FATsecs pm_bpb.bpbFATsecs -#define pm_SecPerTrack pm_bpb.bpbSecPerTrack -#define pm_Heads pm_bpb.bpbHeads -#define pm_HiddenSects pm_bpb.bpbHiddenSecs -#define pm_HugeSectors pm_bpb.bpbHugeSectors - -/* - * Map a cluster number into a filesystem relative - * block number. - */ -#define cntobn(pmp, cn) \ - ((((cn)-CLUST_FIRST) * (pmp)->pm_SectPerClust) + (pmp)->pm_firstcluster) - -/* - * Map a filesystem relative block number back into - * a cluster number. - */ -#define bntocn(pmp, bn) \ - ((((bn) - pmp->pm_firstcluster)/ (pmp)->pm_SectPerClust) + CLUST_FIRST) - -/* - * Calculate block number for directory entry in root dir, offset dirofs - */ -#define roottobn(pmp, dirofs) \ - (((dirofs) / (pmp)->pm_depclust) * (pmp)->pm_SectPerClust \ - + (pmp)->pm_rootdirblk) - -/* - * Calculate block number for directory entry at cluster dirclu, offset dirofs - */ -#define detobn(pmp, dirclu, dirofs) \ - ((dirclu) == PCFSROOT \ - ? roottobn((pmp), (dirofs)) \ - : cntobn((pmp), (dirclu))) - -/* - * Convert pointer to buffer -> pointer to direntry - */ -#define bptoep(pmp, bp, dirofs) \ - ((struct direntry *)((bp)->b_un.b_addr) \ - + (dirofs) % (pmp)->pm_depclust) - - -/* - * Prototypes for PCFS virtual filesystem operations - */ -int pcfs_mount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); -int pcfs_start __P((struct mount *mp, int flags, struct proc *p)); -int pcfs_unmount __P((struct mount *mp, int mntflags, struct proc *p)); -int pcfs_root __P((struct mount *mp, struct vnode **vpp)); -int pcfs_quotactl __P((struct mount *mp, int cmds, int uid, /* should be uid_t */ - caddr_t arg, struct proc *p)); -int pcfs_statfs __P((struct mount *mp, struct statfs *sbp, struct proc *p)); -int pcfs_sync __P((struct mount *mp, int waitfor)); -int pcfs_fhtovp __P((struct mount *mp, struct fid *fhp, struct vnode **vpp)); -int pcfs_vptofh __P((struct vnode *vp, struct fid *fhp)); -int pcfs_init __P(()); diff --git a/sys/ufs/mfsnode.h b/sys/ufs/mfsnode.h deleted file mode 100644 index 7c88d16970da..000000000000 --- a/sys/ufs/mfsnode.h +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)mfsnode.h 7.3 (Berkeley) 4/16/91 - * $Id: mfsnode.h,v 1.7 1993/12/23 07:03:20 cgd Exp $ - */ - -#ifndef _UFS_MFSNODE_H_ -#define _UFS_MFSNODE_H_ - -/* - * This structure defines the control data for the memory - * based file system. - */ - -struct mfsnode { - struct vnode *mfs_vnode; /* vnode associated with this mfsnode */ - caddr_t mfs_baseoff; /* base of file system in memory */ - long mfs_size; /* size of memory file system */ - pid_t mfs_pid; /* supporting process pid */ - struct buf *mfs_buflist; /* list of I/O requests */ - long mfs_spare[4]; -}; - -/* - * Convert between mfsnode pointers and vnode pointers - */ -#define VTOMFS(vp) ((struct mfsnode *)(vp)->v_data) -#define MFSTOV(mfsp) ((mfsp)->mfs_vnode) - -/* - * Prototypes for MFS operations on vnodes. - */ -int mfs_badop(); -#define mfs_lookup ((int (*) __P(( \ - struct vnode *vp, \ - struct nameidata *ndp, \ - struct proc *p))) mfs_badop) -#define mfs_create ((int (*) __P(( \ - struct nameidata *ndp, \ - struct vattr *vap, \ - struct proc *p))) mfs_badop) -#define mfs_mknod ((int (*) __P(( \ - struct nameidata *ndp, \ - struct vattr *vap, \ - struct ucred *cred, \ - struct proc *p))) mfs_badop) -int mfs_open __P(( - struct vnode *vp, - int mode, - struct ucred *cred, - struct proc *p)); -int mfs_close __P(( - struct vnode *vp, - int fflag, - struct ucred *cred, - struct proc *p)); -#define mfs_access ((int (*) __P(( \ - struct vnode *vp, \ - int mode, \ - struct ucred *cred, \ - struct proc *p))) mfs_badop) -#define mfs_getattr ((int (*) __P(( \ - struct vnode *vp, \ - struct vattr *vap, \ - struct ucred *cred, \ - struct proc *p))) mfs_badop) -#define mfs_setattr ((int (*) __P(( \ - struct vnode *vp, \ - struct vattr *vap, \ - struct ucred *cred, \ - struct proc *p))) mfs_badop) -#define mfs_read ((int (*) __P(( \ - struct vnode *vp, \ - struct uio *uio, \ - int ioflag, \ - struct ucred *cred))) mfs_badop) -#define mfs_write ((int (*) __P(( \ - struct vnode *vp, \ - struct uio *uio, \ - int ioflag, \ - struct ucred *cred))) mfs_badop) -int mfs_ioctl __P(( - struct vnode *vp, - int command, - caddr_t data, - int fflag, - struct ucred *cred, - struct proc *p)); -#define mfs_select ((int (*) __P(( \ - struct vnode *vp, \ - int which, \ - int fflags, \ - struct ucred *cred, \ - struct proc *p))) mfs_badop) -#define mfs_mmap ((int (*) __P(( \ - struct vnode *vp, \ - int fflags, \ - struct ucred *cred, \ - struct proc *p))) mfs_badop) -#define mfs_fsync ((int (*) __P(( \ - struct vnode *vp, \ - int fflags, \ - struct ucred *cred, \ - int waitfor, \ - struct proc *p))) mfs_badop) -#define mfs_seek ((int (*) __P(( \ - struct vnode *vp, \ - off_t oldoff, \ - off_t newoff, \ - struct ucred *cred))) mfs_badop) -#define mfs_remove ((int (*) __P(( \ - struct nameidata *ndp, \ - struct proc *p))) mfs_badop) -#define mfs_link ((int (*) __P(( \ - struct vnode *vp, \ - struct nameidata *ndp, \ - struct proc *p))) mfs_badop) -#define mfs_rename ((int (*) __P(( \ - struct nameidata *fndp, \ - struct nameidata *tdnp, \ - struct proc *p))) mfs_badop) -#define mfs_mkdir ((int (*) __P(( \ - struct nameidata *ndp, \ - struct vattr *vap, \ - struct proc *p))) mfs_badop) -#define mfs_rmdir ((int (*) __P(( \ - struct nameidata *ndp, \ - struct proc *p))) mfs_badop) -#define mfs_symlink ((int (*) __P(( \ - struct nameidata *ndp, \ - struct vattr *vap, \ - char *target, \ - struct proc *p))) mfs_badop) -#define mfs_readdir ((int (*) __P(( \ - struct vnode *vp, \ - struct uio *uio, \ - struct ucred *cred, \ - int *eofflagp, \ - u_int *cookies, \ - int ncookies))) mfs_badop) -#define mfs_readlink ((int (*) __P(( \ - struct vnode *vp, \ - struct uio *uio, \ - struct ucred *cred))) mfs_badop) -#define mfs_abortop ((int (*) __P(( \ - struct nameidata *ndp))) mfs_badop) -int mfs_inactive __P(( - struct vnode *vp, - struct proc *p)); -#define mfs_reclaim ((int (*) __P(( \ - struct vnode *vp))) nullop) -#define mfs_lock ((int (*) __P(( \ - struct vnode *vp))) nullop) -#define mfs_unlock ((int (*) __P(( \ - struct vnode *vp))) nullop) -int mfs_bmap __P(( - struct vnode *vp, - daddr_t bn, - struct vnode **vpp, - daddr_t *bnp)); -int mfs_strategy __P(( - struct buf *bp)); -int mfs_print __P(( - struct vnode *vp)); -#define mfs_islocked ((int (*) __P(( \ - struct vnode *vp))) nullop) -#define mfs_advlock ((int (*) __P(( \ - struct vnode *vp, \ - caddr_t id, \ - int op, \ - struct flock *fl, \ - int flags))) mfs_badop) - -#endif /* !_UFS_MFSNODE_H_ */ diff --git a/sys/ufs/quota.h b/sys/ufs/quota.h deleted file mode 100644 index 81e7d204e2d9..000000000000 --- a/sys/ufs/quota.h +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 1982, 1986 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Robert Elz at The University of Melbourne. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)quota.h 7.9 (Berkeley) 2/22/91 - * $Id: quota.h,v 1.5 1994/04/27 21:43:47 cgd Exp $ - */ - -#ifndef _UFS_QUOTA_H_ -#define _UFS_QUOTA_H_ - -/* - * Definitions for disk quotas imposed on the average user - * (big brother finally hits UNIX). - * - * The following constants define the amount of time given a user - * before the soft limits are treated as hard limits (usually resulting - * in an allocation failure). The timer is started when the user crosses - * their soft limit, it is reset when they go below their soft limit. - */ -#define MAX_IQ_TIME (7*24*60*60) /* 1 week */ -#define MAX_DQ_TIME (7*24*60*60) /* 1 week */ - -/* - * The following constants define the usage of the quota file array - * in the ufsmount structure and dquot array in the inode structure. - * The semantics of the elements of these arrays are defined in the - * routine getinoquota; the remainder of the quota code treats them - * generically and need not be inspected when changing the size of - * the array. - */ -#define MAXQUOTAS 2 -#define USRQUOTA 0 /* element used for user quotas */ -#define GRPQUOTA 1 /* element used for group quotas */ - -/* - * Definitions for the default names of the quotas files. - */ -#define INITQFNAMES { \ - "user", /* USRQUOTA */ \ - "group", /* GRPQUOTA */ \ - "undefined", \ -}; -#define QUOTAFILENAME "quota" -#define QUOTAGROUP "operator" - -/* - * Command definitions for the 'quotactl' system call. - * The commands are broken into a main command defined below - * and a subcommand that is used to convey the type of - * quota that is being manipulated (see above). - */ -#define SUBCMDMASK 0x00ff -#define SUBCMDSHIFT 8 -#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK)) - -#define Q_QUOTAON 0x0100 /* enable quotas */ -#define Q_QUOTAOFF 0x0200 /* disable quotas */ -#define Q_GETQUOTA 0x0300 /* get limits and usage */ -#define Q_SETQUOTA 0x0400 /* set limits and usage */ -#define Q_SETUSE 0x0500 /* set usage */ -#define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */ - -/* - * The following structure defines the format of the disk quota file - * (as it appears on disk) - the file is an array of these structures - * indexed by user or group number. The setquota system call establishes - * the vnode for each quota file (a pointer is retained in the ufsmount - * structure). - */ -struct dqblk { - u_long dqb_bhardlimit; /* absolute limit on disk blks alloc */ - u_long dqb_bsoftlimit; /* preferred limit on disk blks */ - u_long dqb_curblocks; /* current block count */ - u_long dqb_ihardlimit; /* maximum # allocated inodes + 1 */ - u_long dqb_isoftlimit; /* preferred inode limit */ - u_long dqb_curinodes; /* current # allocated inodes */ - time_t dqb_btime; /* time limit for excessive disk use */ - time_t dqb_itime; /* time limit for excessive files */ -}; - -#ifdef KERNEL -/* - * The following structure records disk usage for a user or group on a - * filesystem. There is one allocated for each quota that exists on any - * filesystem for the current user or group. A cache is kept of recently - * used entries. - */ -struct dquot { - struct dquot *dq_forw, *dq_back;/* MUST be first entry */ - struct dquot *dq_freef, **dq_freeb; /* free list */ - short dq_flags; /* flags, see below */ - short dq_cnt; /* count of active references */ - short dq_spare; /* unused spare padding */ - short dq_type; /* quota type of this dquot */ - u_long dq_id; /* identifier this applies to */ - struct ufsmount *dq_ump; /* filesystem that this is taken from */ - struct dqblk dq_dqb; /* actual usage & quotas */ -}; -/* - * Flag values. - */ -#define DQ_LOCK 0x01 /* this quota locked (no MODS) */ -#define DQ_WANT 0x02 /* wakeup on unlock */ -#define DQ_MOD 0x04 /* this quota modified since read */ -#define DQ_FAKE 0x08 /* no limits here, just usage */ -#define DQ_BLKS 0x10 /* has been warned about blk limit */ -#define DQ_INODS 0x20 /* has been warned about inode limit */ -/* - * Shorthand notation. - */ -#define dq_bhardlimit dq_dqb.dqb_bhardlimit -#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit -#define dq_curblocks dq_dqb.dqb_curblocks -#define dq_ihardlimit dq_dqb.dqb_ihardlimit -#define dq_isoftlimit dq_dqb.dqb_isoftlimit -#define dq_curinodes dq_dqb.dqb_curinodes -#define dq_btime dq_dqb.dqb_btime -#define dq_itime dq_dqb.dqb_itime - -/* - * If the system has never checked for a quota for this file, - * then it is set to NODQUOT. Once a write attempt is made - * the inode pointer is set to reference a dquot structure. - */ -#define NODQUOT ((struct dquot *) 0) - -/* - * Flags to chkdq() and chkiq() - */ -#define FORCE 0x01 /* force usage changes independent of limits */ -#define CHOWN 0x02 /* (advisory) change initiated by chown */ - -/* - * Macros to avoid subroutine calls to trivial functions. - */ -#ifndef DIAGNOSTIC -#define DQREF(dq) (dq)->dq_cnt++ -#else -#define DQREF(dq) dqref(dq) -#endif /* DIAGNOSTIC */ - -#else - -#include - -struct dquot; -struct inode; -struct mount; -struct proc; -struct ucred; -struct ufsmount; -struct vnode; -__BEGIN_DECLS -int quotactl __P((const char *, int, int, void *)); -int getinoquota __P((struct inode *)); -int chkdq __P((struct inode *, long, struct ucred *, int)); -int chkiq __P((struct inode *, long, struct ucred *, int)); -int quotaon __P((struct proc *, struct mount *, int, caddr_t)); -int quotaoff __P((struct proc *, struct mount *, int)); -int getquota __P((struct mount *, u_long, int, caddr_t)); -int setquota __P((struct mount *, u_long, int, caddr_t)); -int setuse __P((struct mount *, u_long, int, caddr_t)); -int qsync __P((struct mount *)); -__END_DECLS - -#endif /* KERNEL */ - -#endif /* !_UFS_QUOTA_H_ */ diff --git a/sys/ufs/ufs_alloc.c b/sys/ufs/ufs_alloc.c deleted file mode 100644 index 3add120726fb..000000000000 --- a/sys/ufs/ufs_alloc.c +++ /dev/null @@ -1,1101 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ufs_alloc.c 7.26 (Berkeley) 5/2/91 - * $Id: ufs_alloc.c,v 1.6 1994/05/18 10:21:42 cgd Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -extern u_long hashalloc(); -extern ino_t ialloccg(); -extern daddr_t alloccg(); -extern daddr_t alloccgblk(); -extern daddr_t fragextend(); -extern daddr_t blkpref(); -extern daddr_t mapsearch(); -extern int inside[], around[]; -extern unsigned char *fragtbl[]; - -/* - * Allocate a block in the file system. - * - * The size of the requested block is given, which must be some - * multiple of fs_fsize and <= fs_bsize. - * A preference may be optionally specified. If a preference is given - * the following hierarchy is used to allocate a block: - * 1) allocate the requested block. - * 2) allocate a rotationally optimal block in the same cylinder. - * 3) allocate a block in the same cylinder group. - * 4) quadradically rehash into other cylinder groups, until an - * available block is located. - * If no block preference is given the following heirarchy is used - * to allocate a block: - * 1) allocate a block in the cylinder group that contains the - * inode for the file. - * 2) quadradically rehash into other cylinder groups, until an - * available block is located. - */ -alloc(ip, lbn, bpref, size, bnp) - register struct inode *ip; - daddr_t lbn, bpref; - int size; - daddr_t *bnp; -{ - daddr_t bno; - register struct fs *fs; - register struct buf *bp; - int cg, error; - struct ucred *cred = curproc->p_ucred; /* XXX */ - - *bnp = 0; - fs = ip->i_fs; - if ((unsigned)size > fs->fs_bsize || fragoff(fs, size) != 0) { - printf("dev = 0x%x, bsize = %d, size = %d, fs = %s\n", - ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt); - panic("alloc: bad size"); - } - if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0) - goto nospace; - if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0) - goto nospace; -#ifdef QUOTA - if (error = chkdq(ip, (long)btodb(size), cred, 0)) - return (error); -#endif - if (bpref >= fs->fs_size) - bpref = 0; - if (bpref == 0) - cg = itog(fs, ip->i_number); - else - cg = dtog(fs, bpref); - bno = (daddr_t)hashalloc(ip, cg, (long)bpref, size, - (u_long (*)())alloccg); - if (bno > 0) { - ip->i_blocks += btodb(size); - ip->i_flag |= IUPD|ICHG; - *bnp = bno; - return (0); - } -#ifdef QUOTA - /* - * Restore user's disk quota because allocation failed. - */ - (void) chkdq(ip, (long)-btodb(size), cred, FORCE); -#endif -nospace: - fserr(fs, cred->cr_uid, "file system full"); - uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt); - return (ENOSPC); -} - -/* - * Reallocate a fragment to a bigger size - * - * The number and size of the old block is given, and a preference - * and new size is also specified. The allocator attempts to extend - * the original block. Failing that, the regular block allocator is - * invoked to get an appropriate block. - */ -realloccg(ip, lbprev, bpref, osize, nsize, bpp) - register struct inode *ip; - daddr_t lbprev; - daddr_t bpref; - int osize, nsize; - struct buf **bpp; -{ - register struct fs *fs; - struct buf *bp, *obp; - int cg, request, error; - daddr_t bprev, bno; - struct ucred *cred = curproc->p_ucred; /* XXX */ - - *bpp = 0; - fs = ip->i_fs; - if ((unsigned)osize > fs->fs_bsize || fragoff(fs, osize) != 0 || - (unsigned)nsize > fs->fs_bsize || fragoff(fs, nsize) != 0) { - printf("dev = 0x%x, bsize = %d, osize = %d, nsize = %d, fs = %s\n", - ip->i_dev, fs->fs_bsize, osize, nsize, fs->fs_fsmnt); - panic("realloccg: bad size"); - } - if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0) - goto nospace; - if ((bprev = ip->i_db[lbprev]) == 0) { - printf("dev = 0x%x, bsize = %d, bprev = %d, fs = %s\n", - ip->i_dev, fs->fs_bsize, bprev, fs->fs_fsmnt); - panic("realloccg: bad bprev"); - } - /* - * Allocate the extra space in the buffer. - */ - if (error = bread(ITOV(ip), lbprev, osize, NOCRED, &bp)) { - brelse(bp); - return (error); - } -#ifdef QUOTA - if (error = chkdq(ip, (long)btodb(nsize - osize), cred, 0)) { - brelse(bp); - return (error); - } -#endif - /* - * Check for extension in the existing location. - */ - cg = dtog(fs, bprev); - if (bno = fragextend(ip, cg, (long)bprev, osize, nsize)) { - if (bp->b_blkno != fsbtodb(fs, bno)) - panic("bad blockno"); - ip->i_blocks += btodb(nsize - osize); - ip->i_flag |= IUPD|ICHG; - allocbuf(bp, nsize); - bp->b_flags |= B_DONE; - bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize); - *bpp = bp; - return (0); - } - /* - * Allocate a new disk location. - */ - if (bpref >= fs->fs_size) - bpref = 0; - switch ((int)fs->fs_optim) { - case FS_OPTSPACE: - /* - * Allocate an exact sized fragment. Although this makes - * best use of space, we will waste time relocating it if - * the file continues to grow. If the fragmentation is - * less than half of the minimum free reserve, we choose - * to begin optimizing for time. - */ - request = nsize; - if (fs->fs_minfree < 5 || - fs->fs_cstotal.cs_nffree > - fs->fs_dsize * fs->fs_minfree / (2 * 100)) - break; - log(LOG_NOTICE, "%s: optimization changed from SPACE to TIME\n", - fs->fs_fsmnt); - fs->fs_optim = FS_OPTTIME; - break; - case FS_OPTTIME: - /* - * At this point we have discovered a file that is trying - * to grow a small fragment to a larger fragment. To save - * time, we allocate a full sized block, then free the - * unused portion. If the file continues to grow, the - * `fragextend' call above will be able to grow it in place - * without further copying. If aberrant programs cause - * disk fragmentation to grow within 2% of the free reserve, - * we choose to begin optimizing for space. - */ - request = fs->fs_bsize; - if (fs->fs_cstotal.cs_nffree < - fs->fs_dsize * (fs->fs_minfree - 2) / 100) - break; - log(LOG_NOTICE, "%s: optimization changed from TIME to SPACE\n", - fs->fs_fsmnt); - fs->fs_optim = FS_OPTSPACE; - break; - default: - printf("dev = 0x%x, optim = %d, fs = %s\n", - ip->i_dev, fs->fs_optim, fs->fs_fsmnt); - panic("realloccg: bad optim"); - /* NOTREACHED */ - } - bno = (daddr_t)hashalloc(ip, cg, (long)bpref, request, - (u_long (*)())alloccg); - if (bno > 0) { - bp->b_blkno = fsbtodb(fs, bno); - (void) vnode_pager_uncache(ITOV(ip)); - blkfree(ip, bprev, osize); - if (nsize < request) - blkfree(ip, bno + numfrags(fs, nsize), - (request - nsize)); - ip->i_blocks += btodb(nsize - osize); - ip->i_flag |= IUPD|ICHG; - allocbuf(bp, nsize); - bp->b_flags |= B_DONE; - bzero(bp->b_un.b_addr + osize, (unsigned)nsize - osize); - *bpp = bp; - return (0); - } -#ifdef QUOTA - /* - * Restore user's disk quota because allocation failed. - */ - (void) chkdq(ip, (long)-btodb(nsize - osize), cred, FORCE); -#endif - brelse(bp); -nospace: - /* - * no space available - */ - fserr(fs, cred->cr_uid, "file system full"); - uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt); - return (ENOSPC); -} - -/* - * Allocate an inode in the file system. - * - * A preference may be optionally specified. If a preference is given - * the following hierarchy is used to allocate an inode: - * 1) allocate the requested inode. - * 2) allocate an inode in the same cylinder group. - * 3) quadradically rehash into other cylinder groups, until an - * available inode is located. - * If no inode preference is given the following heirarchy is used - * to allocate an inode: - * 1) allocate an inode in cylinder group 0. - * 2) quadradically rehash into other cylinder groups, until an - * available inode is located. - */ -ialloc(pip, ipref, mode, cred, ipp) - register struct inode *pip; - ino_t ipref; - int mode; - struct ucred *cred; - struct inode **ipp; -{ - ino_t ino; - register struct fs *fs; - register struct inode *ip; - int cg, error; - - *ipp = 0; - fs = pip->i_fs; - if (fs->fs_cstotal.cs_nifree == 0) - goto noinodes; - if (ipref >= fs->fs_ncg * fs->fs_ipg) - ipref = 0; - cg = itog(fs, ipref); - ino = (ino_t)hashalloc(pip, cg, (long)ipref, mode, ialloccg); - if (ino == 0) - goto noinodes; - error = iget(pip, ino, ipp); - if (error) { - ifree(pip, ino, mode); - return (error); - } - ip = *ipp; - if (ip->i_mode) { - printf("mode = 0%o, inum = %d, fs = %s\n", - ip->i_mode, ip->i_number, fs->fs_fsmnt); - panic("ialloc: dup alloc"); - } - if (ip->i_blocks) { /* XXX */ - printf("free inode %s/%d had %d blocks\n", - fs->fs_fsmnt, ino, ip->i_blocks); - ip->i_blocks = 0; - } - ip->i_flags = 0; - /* - * Set up a new generation number for this inode. - */ - if (++nextgennumber < (u_long)time.tv_sec) - nextgennumber = time.tv_sec; - ip->i_gen = nextgennumber; - return (0); -noinodes: - fserr(fs, cred->cr_uid, "out of inodes"); - uprintf("\n%s: create/symlink failed, no inodes free\n", fs->fs_fsmnt); - return (ENOSPC); -} - -/* - * Find a cylinder to place a directory. - * - * The policy implemented by this algorithm is to select from - * among those cylinder groups with above the average number of - * free inodes, the one with the smallest number of directories. - */ -ino_t -dirpref(fs) - register struct fs *fs; -{ - int cg, minndir, mincg, avgifree; - - avgifree = fs->fs_cstotal.cs_nifree / fs->fs_ncg; - minndir = fs->fs_ipg; - mincg = 0; - for (cg = 0; cg < fs->fs_ncg; cg++) - if (fs->fs_cs(fs, cg).cs_ndir < minndir && - fs->fs_cs(fs, cg).cs_nifree >= avgifree) { - mincg = cg; - minndir = fs->fs_cs(fs, cg).cs_ndir; - } - return ((ino_t)(fs->fs_ipg * mincg)); -} - -/* - * Select the desired position for the next block in a file. The file is - * logically divided into sections. The first section is composed of the - * direct blocks. Each additional section contains fs_maxbpg blocks. - * - * If no blocks have been allocated in the first section, the policy is to - * request a block in the same cylinder group as the inode that describes - * the file. If no blocks have been allocated in any other section, the - * policy is to place the section in a cylinder group with a greater than - * average number of free blocks. An appropriate cylinder group is found - * by using a rotor that sweeps the cylinder groups. When a new group of - * blocks is needed, the sweep begins in the cylinder group following the - * cylinder group from which the previous allocation was made. The sweep - * continues until a cylinder group with greater than the average number - * of free blocks is found. If the allocation is for the first block in an - * indirect block, the information on the previous allocation is unavailable; - * here a best guess is made based upon the logical block number being - * allocated. - * - * If a section is already partially allocated, the policy is to - * contiguously allocate fs_maxcontig blocks. The end of one of these - * contiguous blocks and the beginning of the next is physically separated - * so that the disk head will be in transit between them for at least - * fs_rotdelay milliseconds. This is to allow time for the processor to - * schedule another I/O transfer. - */ -daddr_t -blkpref(ip, lbn, indx, bap) - struct inode *ip; - daddr_t lbn; - int indx; - daddr_t *bap; -{ - register struct fs *fs; - register int cg; - int avgbfree, startcg; - daddr_t nextblk; - - fs = ip->i_fs; - if (indx % fs->fs_maxbpg == 0 || bap[indx - 1] == 0) { - if (lbn < NDADDR) { - cg = itog(fs, ip->i_number); - return (fs->fs_fpg * cg + fs->fs_frag); - } - /* - * Find a cylinder with greater than average number of - * unused data blocks. - */ - if (indx == 0 || bap[indx - 1] == 0) - startcg = itog(fs, ip->i_number) + lbn / fs->fs_maxbpg; - else - startcg = dtog(fs, bap[indx - 1]) + 1; - startcg %= fs->fs_ncg; - avgbfree = fs->fs_cstotal.cs_nbfree / fs->fs_ncg; - for (cg = startcg; cg < fs->fs_ncg; cg++) - if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) { - fs->fs_cgrotor = cg; - return (fs->fs_fpg * cg + fs->fs_frag); - } - for (cg = 0; cg <= startcg; cg++) - if (fs->fs_cs(fs, cg).cs_nbfree >= avgbfree) { - fs->fs_cgrotor = cg; - return (fs->fs_fpg * cg + fs->fs_frag); - } - return (NULL); - } - /* - * One or more previous blocks have been laid out. If less - * than fs_maxcontig previous blocks are contiguous, the - * next block is requested contiguously, otherwise it is - * requested rotationally delayed by fs_rotdelay milliseconds. - */ - nextblk = bap[indx - 1] + fs->fs_frag; - if (indx < fs->fs_maxcontig || bap[indx - fs->fs_maxcontig] + - blkstofrags(fs, fs->fs_maxcontig) != nextblk) - return (nextblk); - if (fs->fs_rotdelay != 0) - /* - * Here we convert ms of delay to frags as: - * (frags) = (ms) * (rev/sec) * (sect/rev) / - * ((sect/frag) * (ms/sec)) - * then round up to the next block. - */ - nextblk += roundup(fs->fs_rotdelay * fs->fs_rps * fs->fs_nsect / - (NSPF(fs) * 1000), fs->fs_frag); - return (nextblk); -} - -/* - * Implement the cylinder overflow algorithm. - * - * The policy implemented by this algorithm is: - * 1) allocate the block in its requested cylinder group. - * 2) quadradically rehash on the cylinder group number. - * 3) brute force search for a free block. - */ -/*VARARGS5*/ -u_long -hashalloc(ip, cg, pref, size, allocator) - struct inode *ip; - int cg; - long pref; - int size; /* size for data blocks, mode for inodes */ - u_long (*allocator)(); -{ - register struct fs *fs; - long result; - int i, icg = cg; - - fs = ip->i_fs; - /* - * 1: preferred cylinder group - */ - result = (*allocator)(ip, cg, pref, size); - if (result) - return (result); - /* - * 2: quadratic rehash - */ - for (i = 1; i < fs->fs_ncg; i *= 2) { - cg += i; - if (cg >= fs->fs_ncg) - cg -= fs->fs_ncg; - result = (*allocator)(ip, cg, 0, size); - if (result) - return (result); - } - /* - * 3: brute force search - * Note that we start at i == 2, since 0 was checked initially, - * and 1 is always checked in the quadratic rehash. - */ - cg = (icg + 2) % fs->fs_ncg; - for (i = 2; i < fs->fs_ncg; i++) { - result = (*allocator)(ip, cg, 0, size); - if (result) - return (result); - cg++; - if (cg == fs->fs_ncg) - cg = 0; - } - return (NULL); -} - -/* - * Determine whether a fragment can be extended. - * - * Check to see if the necessary fragments are available, and - * if they are, allocate them. - */ -daddr_t -fragextend(ip, cg, bprev, osize, nsize) - struct inode *ip; - int cg; - long bprev; - int osize, nsize; -{ - register struct fs *fs; - register struct cg *cgp; - struct buf *bp; - long bno; - int frags, bbase; - int i, error; - - fs = ip->i_fs; - if (fs->fs_cs(fs, cg).cs_nffree < numfrags(fs, nsize - osize)) - return (NULL); - frags = numfrags(fs, nsize); - bbase = fragnum(fs, bprev); - if (bbase > fragnum(fs, (bprev + frags - 1))) { - /* cannot extend across a block boundary */ - return (NULL); - } - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), - (int)fs->fs_cgsize, NOCRED, &bp); - if (error) { - brelse(bp); - return (NULL); - } - cgp = (struct cg *)bp->b_data; - if (!cg_chkmagic(cgp)) { - brelse(bp); - return (NULL); - } - cgp->cg_time = time.tv_sec; - bno = dtogd(fs, bprev); - for (i = numfrags(fs, osize); i < frags; i++) - if (isclr(cg_blksfree(cgp), bno + i)) { - brelse(bp); - return (NULL); - } - /* - * the current fragment can be extended - * deduct the count on fragment being extended into - * increase the count on the remaining fragment (if any) - * allocate the extended piece - */ - for (i = frags; i < fs->fs_frag - bbase; i++) - if (isclr(cg_blksfree(cgp), bno + i)) - break; - cgp->cg_frsum[i - numfrags(fs, osize)]--; - if (i != frags) - cgp->cg_frsum[i - frags]++; - for (i = numfrags(fs, osize); i < frags; i++) { - clrbit(cg_blksfree(cgp), bno + i); - cgp->cg_cs.cs_nffree--; - fs->fs_cstotal.cs_nffree--; - fs->fs_cs(fs, cg).cs_nffree--; - } - fs->fs_fmod++; - bdwrite(bp); - return (bprev); -} - -/* - * Determine whether a block can be allocated. - * - * Check to see if a block of the apprpriate size is available, - * and if it is, allocate it. - */ -daddr_t -alloccg(ip, cg, bpref, size) - struct inode *ip; - int cg; - daddr_t bpref; - int size; -{ - register struct fs *fs; - register struct cg *cgp; - struct buf *bp; - register int i; - int error, bno, frags, allocsiz; - - fs = ip->i_fs; - if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize) - return (NULL); - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), - (int)fs->fs_cgsize, NOCRED, &bp); - if (error) { - brelse(bp); - return (NULL); - } - cgp = (struct cg *)bp->b_data; - if (!cg_chkmagic(cgp) || - (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) { - brelse(bp); - return (NULL); - } - cgp->cg_time = time.tv_sec; - if (size == fs->fs_bsize) { - bno = alloccgblk(fs, cgp, bpref); - bdwrite(bp); - return (bno); - } - /* - * check to see if any fragments are already available - * allocsiz is the size which will be allocated, hacking - * it down to a smaller size if necessary - */ - frags = numfrags(fs, size); - for (allocsiz = frags; allocsiz < fs->fs_frag; allocsiz++) - if (cgp->cg_frsum[allocsiz] != 0) - break; - if (allocsiz == fs->fs_frag) { - /* - * no fragments were available, so a block will be - * allocated, and hacked up - */ - if (cgp->cg_cs.cs_nbfree == 0) { - brelse(bp); - return (NULL); - } - bno = alloccgblk(fs, cgp, bpref); - bpref = dtogd(fs, bno); - for (i = frags; i < fs->fs_frag; i++) - setbit(cg_blksfree(cgp), bpref + i); - i = fs->fs_frag - frags; - cgp->cg_cs.cs_nffree += i; - fs->fs_cstotal.cs_nffree += i; - fs->fs_cs(fs, cg).cs_nffree += i; - fs->fs_fmod++; - cgp->cg_frsum[i]++; - bdwrite(bp); - return (bno); - } - bno = mapsearch(fs, cgp, bpref, allocsiz); - if (bno < 0) { - brelse(bp); - return (NULL); - } - for (i = 0; i < frags; i++) - clrbit(cg_blksfree(cgp), bno + i); - cgp->cg_cs.cs_nffree -= frags; - fs->fs_cstotal.cs_nffree -= frags; - fs->fs_cs(fs, cg).cs_nffree -= frags; - fs->fs_fmod++; - cgp->cg_frsum[allocsiz]--; - if (frags != allocsiz) - cgp->cg_frsum[allocsiz - frags]++; - bdwrite(bp); - return (cg * fs->fs_fpg + bno); -} - -/* - * Allocate a block in a cylinder group. - * - * This algorithm implements the following policy: - * 1) allocate the requested block. - * 2) allocate a rotationally optimal block in the same cylinder. - * 3) allocate the next available block on the block rotor for the - * specified cylinder group. - * Note that this routine only allocates fs_bsize blocks; these - * blocks may be fragmented by the routine that allocates them. - */ -daddr_t -alloccgblk(fs, cgp, bpref) - register struct fs *fs; - register struct cg *cgp; - daddr_t bpref; -{ - daddr_t bno; - int cylno, pos, delta; - short *cylbp; - register int i; - - if (bpref == 0) { - bpref = cgp->cg_rotor; - goto norot; - } - bpref = blknum(fs, bpref); - bpref = dtogd(fs, bpref); - /* - * if the requested block is available, use it - */ - if (isblock(fs, cg_blksfree(cgp), fragstoblks(fs, bpref))) { - bno = bpref; - goto gotit; - } - /* - * check for a block available on the same cylinder - */ - cylno = cbtocylno(fs, bpref); - if (cg_blktot(cgp)[cylno] == 0) - goto norot; - if (fs->fs_cpc == 0) { - /* - * block layout info is not available, so just have - * to take any block in this cylinder. - */ - bpref = howmany(fs->fs_spc * cylno, NSPF(fs)); - goto norot; - } - /* - * check the summary information to see if a block is - * available in the requested cylinder starting at the - * requested rotational position and proceeding around. - */ - cylbp = cg_blks(fs, cgp, cylno); - pos = cbtorpos(fs, bpref); - for (i = pos; i < fs->fs_nrpos; i++) - if (cylbp[i] > 0) - break; - if (i == fs->fs_nrpos) - for (i = 0; i < pos; i++) - if (cylbp[i] > 0) - break; - if (cylbp[i] > 0) { - /* - * found a rotational position, now find the actual - * block. A panic if none is actually there. - */ - pos = cylno % fs->fs_cpc; - bno = (cylno - pos) * fs->fs_spc / NSPB(fs); - if (fs_postbl(fs, pos)[i] == -1) { - printf("pos = %d, i = %d, fs = %s\n", - pos, i, fs->fs_fsmnt); - panic("alloccgblk: cyl groups corrupted"); - } - for (i = fs_postbl(fs, pos)[i];; ) { - if (isblock(fs, cg_blksfree(cgp), bno + i)) { - bno = blkstofrags(fs, (bno + i)); - goto gotit; - } - delta = fs_rotbl(fs)[i]; - if (delta <= 0 || - delta + i > fragstoblks(fs, fs->fs_fpg)) - break; - i += delta; - } - printf("pos = %d, i = %d, fs = %s\n", pos, i, fs->fs_fsmnt); - panic("alloccgblk: can't find blk in cyl"); - } -norot: - /* - * no blocks in the requested cylinder, so take next - * available one in this cylinder group. - */ - bno = mapsearch(fs, cgp, bpref, (int)fs->fs_frag); - if (bno < 0) - return (NULL); - cgp->cg_rotor = bno; -gotit: - clrblock(fs, cg_blksfree(cgp), (long)fragstoblks(fs, bno)); - cgp->cg_cs.cs_nbfree--; - fs->fs_cstotal.cs_nbfree--; - fs->fs_cs(fs, cgp->cg_cgx).cs_nbfree--; - cylno = cbtocylno(fs, bno); - cg_blks(fs, cgp, cylno)[cbtorpos(fs, bno)]--; - cg_blktot(cgp)[cylno]--; - fs->fs_fmod++; - return (cgp->cg_cgx * fs->fs_fpg + bno); -} - -/* - * Determine whether an inode can be allocated. - * - * Check to see if an inode is available, and if it is, - * allocate it using the following policy: - * 1) allocate the requested inode. - * 2) allocate the next available inode after the requested - * inode in the specified cylinder group. - */ -ino_t -ialloccg(ip, cg, ipref, mode) - struct inode *ip; - int cg; - daddr_t ipref; - int mode; -{ - register struct fs *fs; - register struct cg *cgp; - struct buf *bp; - int error, start, len, loc, map, i; - - fs = ip->i_fs; - if (fs->fs_cs(fs, cg).cs_nifree == 0) - return (NULL); - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), - (int)fs->fs_cgsize, NOCRED, &bp); - if (error) { - brelse(bp); - return (NULL); - } - cgp = (struct cg *)bp->b_data; - if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) { - brelse(bp); - return (NULL); - } - cgp->cg_time = time.tv_sec; - if (ipref) { - ipref %= fs->fs_ipg; - if (isclr(cg_inosused(cgp), ipref)) - goto gotit; - } - start = cgp->cg_irotor / NBBY; - len = howmany(fs->fs_ipg - cgp->cg_irotor, NBBY); - loc = skpc(0xff, len, &cg_inosused(cgp)[start]); - if (loc == 0) { - len = start + 1; - start = 0; - loc = skpc(0xff, len, &cg_inosused(cgp)[0]); - if (loc == 0) { - printf("cg = %s, irotor = %d, fs = %s\n", - cg, cgp->cg_irotor, fs->fs_fsmnt); - panic("ialloccg: map corrupted"); - /* NOTREACHED */ - } - } - i = start + len - loc; - map = cg_inosused(cgp)[i]; - ipref = i * NBBY; - for (i = 1; i < (1 << NBBY); i <<= 1, ipref++) { - if ((map & i) == 0) { - cgp->cg_irotor = ipref; - goto gotit; - } - } - printf("fs = %s\n", fs->fs_fsmnt); - panic("ialloccg: block not in map"); - /* NOTREACHED */ -gotit: - setbit(cg_inosused(cgp), ipref); - cgp->cg_cs.cs_nifree--; - fs->fs_cstotal.cs_nifree--; - fs->fs_cs(fs, cg).cs_nifree--; - fs->fs_fmod++; - if ((mode & IFMT) == IFDIR) { - cgp->cg_cs.cs_ndir++; - fs->fs_cstotal.cs_ndir++; - fs->fs_cs(fs, cg).cs_ndir++; - } - bdwrite(bp); - return (cg * fs->fs_ipg + ipref); -} - -/* - * Free a block or fragment. - * - * The specified block or fragment is placed back in the - * free map. If a fragment is deallocated, a possible - * block reassembly is checked. - */ -blkfree(ip, bno, size) - register struct inode *ip; - daddr_t bno; - daddr_t size; -{ - register struct fs *fs; - register struct cg *cgp; - struct buf *bp; - int error, cg, blk, frags, bbase; - register int i; - struct ucred *cred = curproc->p_ucred; /* XXX */ - - fs = ip->i_fs; - if ((unsigned)size > fs->fs_bsize || fragoff(fs, size) != 0) { - printf("dev = 0x%x, bsize = %d, size = %d, fs = %s\n", - ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt); - panic("blkfree: bad size"); - } - cg = dtog(fs, bno); - if ((unsigned)bno >= fs->fs_size) { - printf("bad block %d, ino %d\n", bno, ip->i_number); - fserr(fs, cred->cr_uid, "bad block"); - return; - } - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), - (int)fs->fs_cgsize, NOCRED, &bp); - if (error) { - brelse(bp); - return; - } - cgp = (struct cg *)bp->b_data; - if (!cg_chkmagic(cgp)) { - brelse(bp); - return; - } - cgp->cg_time = time.tv_sec; - bno = dtogd(fs, bno); - if (size == fs->fs_bsize) { - if (isblock(fs, cg_blksfree(cgp), fragstoblks(fs, bno))) { - printf("dev = 0x%x, block = %d, fs = %s\n", - ip->i_dev, bno, fs->fs_fsmnt); - panic("blkfree: freeing free block"); - } - setblock(fs, cg_blksfree(cgp), fragstoblks(fs, bno)); - cgp->cg_cs.cs_nbfree++; - fs->fs_cstotal.cs_nbfree++; - fs->fs_cs(fs, cg).cs_nbfree++; - i = cbtocylno(fs, bno); - cg_blks(fs, cgp, i)[cbtorpos(fs, bno)]++; - cg_blktot(cgp)[i]++; - } else { - bbase = bno - fragnum(fs, bno); - /* - * decrement the counts associated with the old frags - */ - blk = blkmap(fs, cg_blksfree(cgp), bbase); - fragacct(fs, blk, cgp->cg_frsum, -1); - /* - * deallocate the fragment - */ - frags = numfrags(fs, size); - for (i = 0; i < frags; i++) { - if (isset(cg_blksfree(cgp), bno + i)) { - printf("dev = 0x%x, block = %d, fs = %s\n", - ip->i_dev, bno + i, fs->fs_fsmnt); - panic("blkfree: freeing free frag"); - } - setbit(cg_blksfree(cgp), bno + i); - } - cgp->cg_cs.cs_nffree += i; - fs->fs_cstotal.cs_nffree += i; - fs->fs_cs(fs, cg).cs_nffree += i; - /* - * add back in counts associated with the new frags - */ - blk = blkmap(fs, cg_blksfree(cgp), bbase); - fragacct(fs, blk, cgp->cg_frsum, 1); - /* - * if a complete block has been reassembled, account for it - */ - if (isblock(fs, cg_blksfree(cgp), - (daddr_t)fragstoblks(fs, bbase))) { - cgp->cg_cs.cs_nffree -= fs->fs_frag; - fs->fs_cstotal.cs_nffree -= fs->fs_frag; - fs->fs_cs(fs, cg).cs_nffree -= fs->fs_frag; - cgp->cg_cs.cs_nbfree++; - fs->fs_cstotal.cs_nbfree++; - fs->fs_cs(fs, cg).cs_nbfree++; - i = cbtocylno(fs, bbase); - cg_blks(fs, cgp, i)[cbtorpos(fs, bbase)]++; - cg_blktot(cgp)[i]++; - } - } - fs->fs_fmod++; - bdwrite(bp); -} - -/* - * Free an inode. - * - * The specified inode is placed back in the free map. - */ -ifree(ip, ino, mode) - struct inode *ip; - ino_t ino; - int mode; -{ - register struct fs *fs; - register struct cg *cgp; - struct buf *bp; - int error, cg; - - fs = ip->i_fs; - if ((unsigned)ino >= fs->fs_ipg*fs->fs_ncg) { - printf("dev = 0x%x, ino = %d, fs = %s\n", - ip->i_dev, ino, fs->fs_fsmnt); - panic("ifree: range"); - } - cg = itog(fs, ino); - error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), - (int)fs->fs_cgsize, NOCRED, &bp); - if (error) { - brelse(bp); - return; - } - cgp = (struct cg *)bp->b_data; - if (!cg_chkmagic(cgp)) { - brelse(bp); - return; - } - cgp->cg_time = time.tv_sec; - ino %= fs->fs_ipg; - if (isclr(cg_inosused(cgp), ino)) { - printf("dev = 0x%x, ino = %d, fs = %s\n", - ip->i_dev, ino, fs->fs_fsmnt); - if (fs->fs_ronly == 0) - panic("ifree: freeing free inode"); - } - clrbit(cg_inosused(cgp), ino); - if (ino < cgp->cg_irotor) - cgp->cg_irotor = ino; - cgp->cg_cs.cs_nifree++; - fs->fs_cstotal.cs_nifree++; - fs->fs_cs(fs, cg).cs_nifree++; - if ((mode & IFMT) == IFDIR) { - cgp->cg_cs.cs_ndir--; - fs->fs_cstotal.cs_ndir--; - fs->fs_cs(fs, cg).cs_ndir--; - } - fs->fs_fmod++; - bdwrite(bp); -} - -/* - * Find a block of the specified size in the specified cylinder group. - * - * It is a panic if a request is made to find a block if none are - * available. - */ -daddr_t -mapsearch(fs, cgp, bpref, allocsiz) - register struct fs *fs; - register struct cg *cgp; - daddr_t bpref; - int allocsiz; -{ - daddr_t bno; - int start, len, loc, i; - int blk, field, subfield, pos; - - /* - * find the fragment by searching through the free block - * map for an appropriate bit pattern - */ - if (bpref) - start = dtogd(fs, bpref) / NBBY; - else - start = cgp->cg_frotor / NBBY; - len = howmany(fs->fs_fpg, NBBY) - start; - loc = scanc((unsigned)len, (u_char *)&cg_blksfree(cgp)[start], - (u_char *)fragtbl[fs->fs_frag], - (u_char)(1 << (allocsiz - 1 + (fs->fs_frag % NBBY)))); - if (loc == 0) { - len = start + 1; - start = 0; - loc = scanc((unsigned)len, (u_char *)&cg_blksfree(cgp)[0], - (u_char *)fragtbl[fs->fs_frag], - (u_char)(1 << (allocsiz - 1 + (fs->fs_frag % NBBY)))); - if (loc == 0) { - printf("start = %d, len = %d, fs = %s\n", - start, len, fs->fs_fsmnt); - panic("alloccg: map corrupted"); - /* NOTREACHED */ - } - } - bno = (start + len - loc) * NBBY; - cgp->cg_frotor = bno; - /* - * found the byte in the map - * sift through the bits to find the selected frag - */ - for (i = bno + NBBY; bno < i; bno += fs->fs_frag) { - blk = blkmap(fs, cg_blksfree(cgp), bno); - blk <<= 1; - field = around[allocsiz]; - subfield = inside[allocsiz]; - for (pos = 0; pos <= fs->fs_frag - allocsiz; pos++) { - if ((blk & field) == subfield) - return (bno + pos); - field <<= 1; - subfield <<= 1; - } - } - printf("bno = %d, fs = %s\n", bno, fs->fs_fsmnt); - panic("alloccg: block not in map"); - return (-1); -} - -/* - * Fserr prints the name of a file system with an error diagnostic. - * - * The form of the error message is: - * fs: error message - */ -fserr(fs, uid, cp) - struct fs *fs; - uid_t uid; - char *cp; -{ - - log(LOG_ERR, "uid %d on %s: %s\n", uid, fs->fs_fsmnt, cp); -} diff --git a/sys/ufs/ufs_lookup.c b/sys/ufs/ufs_lookup.c deleted file mode 100644 index 27e831ee87af..000000000000 --- a/sys/ufs/ufs_lookup.c +++ /dev/null @@ -1,927 +0,0 @@ -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ufs_lookup.c 7.33 (Berkeley) 5/19/91 - * $Id: ufs_lookup.c,v 1.9 1994/05/17 04:26:17 cgd Exp $ - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -struct nchstats nchstats; -#ifdef DIAGNOSTIC -int dirchk = 1; -#else -int dirchk = 0; -#endif - -/* - * Convert a component of a pathname into a pointer to a locked inode. - * This is a very central and rather complicated routine. - * If the file system is not maintained in a strict tree hierarchy, - * this can result in a deadlock situation (see comments in code below). - * - * The flag argument is LOOKUP, CREATE, RENAME, or DELETE depending on - * whether the name is to be looked up, created, renamed, or deleted. - * When CREATE, RENAME, or DELETE is specified, information usable in - * creating, renaming, or deleting a directory entry may be calculated. - * If flag has LOCKPARENT or'ed into it and the target of the pathname - * exists, lookup returns both the target and its parent directory locked. - * When creating or renaming and LOCKPARENT is specified, the target may - * not be ".". When deleting and LOCKPARENT is specified, the target may - * be "."., but the caller must check to ensure it does an vrele and iput - * instead of two iputs. - * - * Overall outline of ufs_lookup: - * - * check accessibility of directory - * look for name in cache, if found, then if at end of path - * and deleting or creating, drop it, else return name - * search for name in directory, to found or notfound - * notfound: - * if creating, return locked directory, leaving info on available slots - * else return error - * found: - * if at end of path and deleting, return information to allow delete - * if at end of path and rewriting (RENAME and LOCKPARENT), lock target - * inode and return info to allow rewrite - * if not at end, add name to cache; if at end and neither creating - * nor deleting, add name to cache - * - * NOTE: (LOOKUP | LOCKPARENT) currently returns the parent inode unlocked. - */ -ufs_lookup(vdp, ndp, p) - register struct vnode *vdp; - register struct nameidata *ndp; - struct proc *p; -{ - register struct inode *dp; /* the directory we are searching */ - register struct fs *fs; /* file system that directory is in */ - struct buf *bp = 0; /* a buffer of directory entries */ - register struct direct *ep; /* the current directory entry */ - int entryoffsetinblock; /* offset of ep in bp's buffer */ - enum {NONE, COMPACT, FOUND} slotstatus; - int slotoffset = -1; /* offset of area with free space */ - int slotsize; /* size of area at slotoffset */ - int slotfreespace; /* amount of space free in slot */ - int slotneeded; /* size of the entry we're seeking */ - int numdirpasses; /* strategy for directory search */ - int endsearch; /* offset to end directory search */ - int prevoff; /* ndp->ni_ufs.ufs_offset of previous entry */ - struct inode *pdp; /* saved dp during symlink work */ - struct inode *tdp; /* returned by iget */ - long enduseful; /* pointer past last used dir slot XXX - doff_t */ - int flag; /* LOOKUP, CREATE, RENAME, or DELETE */ - int lockparent; /* 1 => lockparent flag is set */ - int wantparent; /* 1 => wantparent or lockparent flag */ - int error; - - ndp->ni_dvp = vdp; - ndp->ni_vp = NULL; - dp = VTOI(vdp); - fs = dp->i_fs; - lockparent = ndp->ni_nameiop & LOCKPARENT; - flag = ndp->ni_nameiop & OPMASK; - wantparent = ndp->ni_nameiop & (LOCKPARENT|WANTPARENT); - - /* - * Check accessiblity of directory. - */ - if ((dp->i_mode&IFMT) != IFDIR) - return (ENOTDIR); - if (error = ufs_access(vdp, VEXEC, ndp->ni_cred, p)) - return (error); - - /* - * We now have a segment name to search for, and a directory to search. - * - * Before tediously performing a linear scan of the directory, - * check the name cache to see if the directory/name pair - * we are looking for is known already. - */ - if (error = cache_lookup(ndp)) { - int vpid; /* capability number of vnode */ - - if (error == ENOENT) - return (error); -#ifdef DIAGNOSTIC - if (vdp == ndp->ni_rootdir && ndp->ni_isdotdot) - panic("ufs_lookup: .. through root"); -#endif - /* - * Get the next vnode in the path. - * See comment below starting `Step through' for - * an explaination of the locking protocol. - */ - pdp = dp; - dp = VTOI(ndp->ni_vp); - vdp = ndp->ni_vp; - vpid = vdp->v_id; - if (pdp == dp) { - VREF(vdp); - error = 0; - } else if (ndp->ni_isdotdot) { - IUNLOCK(pdp); - error = vget(vdp, 1); - if (!error && lockparent && *ndp->ni_next == '\0') - ILOCK(pdp); - } else { - error = vget(vdp, 1); - if (!lockparent || error || *ndp->ni_next != '\0') - IUNLOCK(pdp); - } - /* - * Check that the capability number did not change - * while we were waiting for the lock. - */ - if (!error) { - if (vpid == vdp->v_id) - return (0); - iput(dp); - if (lockparent && pdp != dp && *ndp->ni_next == '\0') - IUNLOCK(pdp); - } - ILOCK(pdp); - dp = pdp; - vdp = ITOV(dp); - ndp->ni_vp = NULL; - } - - /* - * Suppress search for slots unless creating - * file and at end of pathname, in which case - * we watch for a place to put the new file in - * case it doesn't already exist. - */ - slotstatus = FOUND; - if ((flag == CREATE || flag == RENAME) && *ndp->ni_next == 0) { - slotstatus = NONE; - slotfreespace = 0; - slotneeded = ((sizeof (struct direct) - (MAXNAMLEN + 1)) + - ((ndp->ni_namelen + 1 + 3) &~ 3)); - } - - /* - * If there is cached information on a previous search of - * this directory, pick up where we last left off. - * We cache only lookups as these are the most common - * and have the greatest payoff. Caching CREATE has little - * benefit as it usually must search the entire directory - * to determine that the entry does not exist. Caching the - * location of the last DELETE or RENAME has not reduced - * profiling time and hence has been removed in the interest - * of simplicity. - */ - if (flag != LOOKUP || dp->i_diroff == 0 || dp->i_diroff > dp->i_size) { - ndp->ni_ufs.ufs_offset = 0; - numdirpasses = 1; - } else { - ndp->ni_ufs.ufs_offset = dp->i_diroff; - entryoffsetinblock = blkoff(fs, ndp->ni_ufs.ufs_offset); - if (entryoffsetinblock != 0) { - if (error = blkatoff(dp, (off_t)ndp->ni_ufs.ufs_offset, - (char **)0, &bp)) - return (error); - } - numdirpasses = 2; - nchstats.ncs_2passes++; - } - endsearch = roundup(dp->i_size, DIRBLKSIZ); - enduseful = 0; - -searchloop: - while (ndp->ni_ufs.ufs_offset < endsearch) { - /* - * If offset is on a block boundary, - * read the next directory block. - * Release previous if it exists. - */ - if (blkoff(fs, ndp->ni_ufs.ufs_offset) == 0) { - if (bp != NULL) - brelse(bp); - if (error = blkatoff(dp, (off_t)ndp->ni_ufs.ufs_offset, - (char **)0, &bp)) - return (error); - entryoffsetinblock = 0; - } - /* - * If still looking for a slot, and at a DIRBLKSIZE - * boundary, have to start looking for free space again. - */ - if (slotstatus == NONE && - (entryoffsetinblock & (DIRBLKSIZ - 1)) == 0) { - slotoffset = -1; - slotfreespace = 0; - } - /* - * Get pointer to next entry. - * Full validation checks are slow, so we only check - * enough to insure forward progress through the - * directory. Complete checks can be run by patching - * "dirchk" to be true. - */ - ep = (struct direct *)(bp->b_un.b_addr + entryoffsetinblock); - if (ep->d_reclen == 0 || - dirchk && dirbadentry(ep, entryoffsetinblock)) { - int i; - -printf("ep = 0x%x\n", ep); -printf("addr = 0x%x\n", bp->b_un.b_addr); -printf("eoib = 0x%x\n", entryoffsetinblock); -printf("d_fileno = %d\n", ep->d_ino); -printf("d_reclen = %d\n", ep->d_reclen); -printf("d_namelen = %d\n", ep->d_namlen); - - dirbad(dp, ndp->ni_ufs.ufs_offset, "mangled entry"); - i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)); - ndp->ni_ufs.ufs_offset += i; - entryoffsetinblock += i; - continue; - } - - /* - * If an appropriate sized slot has not yet been found, - * check to see if one is available. Also accumulate space - * in the current block so that we can determine if - * compaction is viable. - */ - if (slotstatus != FOUND) { - int size = ep->d_reclen; - - if (ep->d_ino != 0) - size -= DIRSIZ(ep); - if (size > 0) { - if (size >= slotneeded) { - slotstatus = FOUND; - slotoffset = ndp->ni_ufs.ufs_offset; - slotsize = ep->d_reclen; - } else if (slotstatus == NONE) { - slotfreespace += size; - if (slotoffset == -1) - slotoffset = - ndp->ni_ufs.ufs_offset; - if (slotfreespace >= slotneeded) { - slotstatus = COMPACT; - slotsize = - ndp->ni_ufs.ufs_offset + - ep->d_reclen - slotoffset; - } - } - } - } - - /* - * Check for a name match. - */ - if (ep->d_ino) { - if (ep->d_namlen == ndp->ni_namelen && - !bcmp(ndp->ni_ptr, ep->d_name, - (unsigned)ep->d_namlen)) { - /* - * Save directory entry's inode number and - * reclen in ndp->ni_ufs area, and release - * directory buffer. - */ - ndp->ni_ufs.ufs_ino = ep->d_ino; - ndp->ni_ufs.ufs_reclen = ep->d_reclen; - goto found; - } - } - prevoff = ndp->ni_ufs.ufs_offset; - ndp->ni_ufs.ufs_offset += ep->d_reclen; - entryoffsetinblock += ep->d_reclen; - if (ep->d_ino) - enduseful = ndp->ni_ufs.ufs_offset; - } -/* notfound: */ - /* - * If we started in the middle of the directory and failed - * to find our target, we must check the beginning as well. - */ - if (numdirpasses == 2) { - numdirpasses--; - ndp->ni_ufs.ufs_offset = 0; - endsearch = dp->i_diroff; - goto searchloop; - } - if (bp != NULL) - brelse(bp); - /* - * If creating, and at end of pathname and current - * directory has not been removed, then can consider - * allowing file to be created. - */ - if ((flag == CREATE || flag == RENAME) && - *ndp->ni_next == 0 && dp->i_nlink != 0) { - /* - * Access for write is interpreted as allowing - * creation of files in the directory. - */ - if (error = ufs_access(vdp, VWRITE, ndp->ni_cred, p)) - return (error); - /* - * Return an indication of where the new directory - * entry should be put. If we didn't find a slot, - * then set ndp->ni_ufs.ufs_count to 0 indicating - * that the new slot belongs at the end of the - * directory. If we found a slot, then the new entry - * can be put in the range from ndp->ni_ufs.ufs_offset - * to ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count. - */ - if (slotstatus == NONE) { - ndp->ni_ufs.ufs_offset = roundup(dp->i_size, DIRBLKSIZ); - ndp->ni_ufs.ufs_count = 0; - enduseful = ndp->ni_ufs.ufs_offset; - } else { - ndp->ni_ufs.ufs_offset = slotoffset; - ndp->ni_ufs.ufs_count = slotsize; - if (enduseful < slotoffset + slotsize) - enduseful = slotoffset + slotsize; - } - ndp->ni_ufs.ufs_endoff = roundup(enduseful, DIRBLKSIZ); - dp->i_flag |= IUPD|ICHG; - /* - * We return with the directory locked, so that - * the parameters we set up above will still be - * valid if we actually decide to do a direnter(). - * We return ni_vp == NULL to indicate that the entry - * does not currently exist; we leave a pointer to - * the (locked) directory inode in ndp->ni_dvp. - * The pathname buffer is saved so that the name - * can be obtained later. - * - * NB - if the directory is unlocked, then this - * information cannot be used. - */ - ndp->ni_nameiop |= SAVENAME; - if (!lockparent) - IUNLOCK(dp); - return (EJUSTRETURN); - } - /* - * Insert name into cache (as non-existent) if appropriate. - */ - if (ndp->ni_makeentry && flag != CREATE) - cache_enter(ndp); - return (ENOENT); - -found: - if (numdirpasses == 2) - nchstats.ncs_pass2++; - /* - * Check that directory length properly reflects presence - * of this entry. - */ - if (entryoffsetinblock + DIRSIZ(ep) > dp->i_size) { - dirbad(dp, ndp->ni_ufs.ufs_offset, "i_size too small"); - dp->i_size = entryoffsetinblock + DIRSIZ(ep); - dp->i_flag |= IUPD|ICHG; - } - - brelse(bp); - - /* - * Found component in pathname. - * If the final component of path name, save information - * in the cache as to where the entry was found. - */ - if (*ndp->ni_next == '\0' && flag == LOOKUP) - dp->i_diroff = ndp->ni_ufs.ufs_offset &~ (DIRBLKSIZ - 1); - - /* - * If deleting, and at end of pathname, return - * parameters which can be used to remove file. - * If the wantparent flag isn't set, we return only - * the directory (in ndp->ni_dvp), otherwise we go - * on and lock the inode, being careful with ".". - */ - if (flag == DELETE && *ndp->ni_next == 0) { - /* - * Write access to directory required to delete files. - */ - if (error = ufs_access(vdp, VWRITE, ndp->ni_cred, p)) - return (error); - /* - * Return pointer to current entry in ndp->ni_ufs.ufs_offset, - * and distance past previous entry (if there - * is a previous entry in this block) in ndp->ni_ufs.ufs_count. - * Save directory inode pointer in ndp->ni_dvp for dirremove(). - */ - if ((ndp->ni_ufs.ufs_offset&(DIRBLKSIZ-1)) == 0) - ndp->ni_ufs.ufs_count = 0; - else - ndp->ni_ufs.ufs_count = ndp->ni_ufs.ufs_offset - prevoff; - if (dp->i_number == ndp->ni_ufs.ufs_ino) { - VREF(vdp); - ndp->ni_vp = vdp; - return (0); - } - if (error = iget(dp, ndp->ni_ufs.ufs_ino, &tdp)) - return (error); - /* - * If directory is "sticky", then user must own - * the directory, or the file in it, else she - * may not delete it (unless she's root). This - * implements append-only directories. - */ - if ((dp->i_mode & ISVTX) && - ndp->ni_cred->cr_uid != 0 && - ndp->ni_cred->cr_uid != dp->i_uid && - tdp->i_uid != ndp->ni_cred->cr_uid) { - iput(tdp); - return (EPERM); - } - ndp->ni_vp = ITOV(tdp); - if (!lockparent) - IUNLOCK(dp); - return (0); - } - - /* - * If rewriting (RENAME), return the inode and the - * information required to rewrite the present directory - * Must get inode of directory entry to verify it's a - * regular file, or empty directory. - */ - if (flag == RENAME && wantparent && *ndp->ni_next == 0) { - if (error = ufs_access(vdp, VWRITE, ndp->ni_cred, p)) - return (error); - /* - * Careful about locking second inode. - * This can only occur if the target is ".". - */ - if (dp->i_number == ndp->ni_ufs.ufs_ino) - return (EISDIR); - if (error = iget(dp, ndp->ni_ufs.ufs_ino, &tdp)) - return (error); - ndp->ni_vp = ITOV(tdp); - ndp->ni_nameiop |= SAVENAME; - if (!lockparent) - IUNLOCK(dp); - return (0); - } - - /* - * Step through the translation in the name. We do not `iput' the - * directory because we may need it again if a symbolic link - * is relative to the current directory. Instead we save it - * unlocked as "pdp". We must get the target inode before unlocking - * the directory to insure that the inode will not be removed - * before we get it. We prevent deadlock by always fetching - * inodes from the root, moving down the directory tree. Thus - * when following backward pointers ".." we must unlock the - * parent directory before getting the requested directory. - * There is a potential race condition here if both the current - * and parent directories are removed before the `iget' for the - * inode associated with ".." returns. We hope that this occurs - * infrequently since we cannot avoid this race condition without - * implementing a sophisticated deadlock detection algorithm. - * Note also that this simple deadlock detection scheme will not - * work if the file system has any hard links other than ".." - * that point backwards in the directory structure. - */ - pdp = dp; - if (ndp->ni_isdotdot) { - IUNLOCK(pdp); /* race to get the inode */ - if (error = iget(dp, ndp->ni_ufs.ufs_ino, &tdp)) { - ILOCK(pdp); - return (error); - } - if (lockparent && *ndp->ni_next == '\0') - ILOCK(pdp); - ndp->ni_vp = ITOV(tdp); - } else if (dp->i_number == ndp->ni_ufs.ufs_ino) { - VREF(vdp); /* we want ourself, ie "." */ - ndp->ni_vp = vdp; - } else { - if (error = iget(dp, ndp->ni_ufs.ufs_ino, &tdp)) - return (error); - if (!lockparent || *ndp->ni_next != '\0') - IUNLOCK(pdp); - ndp->ni_vp = ITOV(tdp); - } - - /* - * Insert name into cache if appropriate. - */ - if (ndp->ni_makeentry) - cache_enter(ndp); - return (0); -} - - -dirbad(ip, offset, how) - struct inode *ip; - long offset; /* doff_t */ - char *how; -{ - - printf("%s: bad dir ino %d at offset %d: %s\n", - ip->i_fs->fs_fsmnt, ip->i_number, offset, how); - if (ip->i_fs->fs_ronly == 0) - panic("bad dir"); -} - -/* - * Do consistency checking on a directory entry: - * record length must be multiple of 4 - * entry must fit in rest of its DIRBLKSIZ block - * record must be large enough to contain entry - * name is not longer than MAXNAMLEN - * name must be as long as advertised, and null terminated - */ -dirbadentry(ep, entryoffsetinblock) - register struct direct *ep; - int entryoffsetinblock; -{ - register int i; - - if ((ep->d_reclen & 0x3) != 0 || - ep->d_reclen > DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)) || - ep->d_reclen < DIRSIZ(ep) || ep->d_namlen > MAXNAMLEN) - return (1); - for (i = 0; i < ep->d_namlen; i++) - if (ep->d_name[i] == '\0') - return (1); - return (ep->d_name[i]); -} - -/* - * Write a directory entry after a call to namei, using the parameters - * that it left in nameidata. The argument ip is the inode which the new - * directory entry will refer to. The nameidata field ndp->ni_dvp is a - * pointer to the directory to be written, which was left locked by namei. - * Remaining parameters (ndp->ni_ufs.ufs_offset, ndp->ni_ufs.ufs_count) - * indicate how the space for the new entry is to be obtained. - */ -direnter(ip, ndp) - struct inode *ip; - register struct nameidata *ndp; -{ - register struct direct *ep, *nep; - register struct inode *dp = VTOI(ndp->ni_dvp); - struct buf *bp; - int loc, spacefree, error = 0; - u_int dsize; - int newentrysize; - char *dirbuf; - struct uio auio; - struct iovec aiov; - struct direct newdir; - -#ifdef DIAGNOSTIC - if ((ndp->ni_nameiop & SAVENAME) == 0) - panic("direnter: missing name"); -#endif - newdir.d_ino = ip->i_number; - newdir.d_namlen = ndp->ni_namelen; - bcopy(ndp->ni_ptr, newdir.d_name, (unsigned)ndp->ni_namelen + 1); - newentrysize = DIRSIZ(&newdir); - if (ndp->ni_ufs.ufs_count == 0) { - /* - * If ndp->ni_ufs.ufs_count is 0, then namei could find no - * space in the directory. Here, ndp->ni_ufs.ufs_offset will - * be on a directory block boundary and we will write the - * new entry into a fresh block. - */ - if (ndp->ni_ufs.ufs_offset & (DIRBLKSIZ - 1)) - panic("wdir: newblk"); - auio.uio_offset = ndp->ni_ufs.ufs_offset; - newdir.d_reclen = DIRBLKSIZ; - auio.uio_resid = newentrysize; - aiov.iov_len = newentrysize; - aiov.iov_base = (caddr_t)&newdir; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_rw = UIO_WRITE; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_procp = (struct proc *)0; - error = ufs_write(ndp->ni_dvp, &auio, IO_SYNC, ndp->ni_cred); - if (DIRBLKSIZ > dp->i_fs->fs_fsize) { - panic("wdir: blksize"); /* XXX - should grow w/balloc */ - } else if (!error) { - dp->i_size = roundup(dp->i_size, DIRBLKSIZ); - dp->i_flag |= ICHG; - } - return (error); - } - - /* - * If ndp->ni_ufs.ufs_count is non-zero, then namei found space - * for the new entry in the range ndp->ni_ufs.ufs_offset to - * ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count in the directory. - * To use this space, we may have to compact the entries located - * there, by copying them together towards the beginning of the - * block, leaving the free space in one usable chunk at the end. - */ - - /* - * Increase size of directory if entry eats into new space. - * This should never push the size past a new multiple of - * DIRBLKSIZE. - * - * N.B. - THIS IS AN ARTIFACT OF 4.2 AND SHOULD NEVER HAPPEN. - */ - if (ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count > dp->i_size) - dp->i_size = ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count; - /* - * Get the block containing the space for the new directory entry. - */ - if (error = blkatoff(dp, (off_t)ndp->ni_ufs.ufs_offset, (char **)&dirbuf, &bp)) - return (error); - /* - * Find space for the new entry. In the simple case, the entry at - * offset base will have the space. If it does not, then namei - * arranged that compacting the region ndp->ni_ufs.ufs_offset to - * ndp->ni_ufs.ufs_offset + ndp->ni_ufs.ufs_count would yield the - * space. - */ - ep = (struct direct *)dirbuf; - dsize = DIRSIZ(ep); - spacefree = ep->d_reclen - dsize; - for (loc = ep->d_reclen; loc < ndp->ni_ufs.ufs_count; ) { - nep = (struct direct *)(dirbuf + loc); - if (ep->d_ino) { - /* trim the existing slot */ - ep->d_reclen = dsize; - ep = (struct direct *)((char *)ep + dsize); - } else { - /* overwrite; nothing there; header is ours */ - spacefree += dsize; - } - dsize = DIRSIZ(nep); - spacefree += nep->d_reclen - dsize; - loc += nep->d_reclen; - bcopy((caddr_t)nep, (caddr_t)ep, dsize); - } - /* - * Update the pointer fields in the previous entry (if any), - * copy in the new entry, and write out the block. - */ - if (ep->d_ino == 0) { - if (spacefree + dsize < newentrysize) - panic("wdir: compact1"); - newdir.d_reclen = spacefree + dsize; - } else { - if (spacefree < newentrysize) - panic("wdir: compact2"); - newdir.d_reclen = spacefree; - ep->d_reclen = dsize; - ep = (struct direct *)((char *)ep + dsize); - } - bcopy((caddr_t)&newdir, (caddr_t)ep, (u_int)newentrysize); - error = bwrite(bp); - dp->i_flag |= IUPD|ICHG; - if (!error && ndp->ni_ufs.ufs_endoff && - ndp->ni_ufs.ufs_endoff < dp->i_size) - error = itrunc(dp, (u_long)ndp->ni_ufs.ufs_endoff, IO_SYNC); - return (error); -} - -/* - * Remove a directory entry after a call to namei, using - * the parameters which it left in nameidata. The entry - * ni_ufs.ufs_offset contains the offset into the directory of the - * entry to be eliminated. The ni_ufs.ufs_count field contains the - * size of the previous record in the directory. If this - * is 0, the first entry is being deleted, so we need only - * zero the inode number to mark the entry as free. If the - * entry is not the first in the directory, we must reclaim - * the space of the now empty record by adding the record size - * to the size of the previous entry. - */ -dirremove(ndp) - register struct nameidata *ndp; -{ - register struct inode *dp = VTOI(ndp->ni_dvp); - struct direct *ep; - struct buf *bp; - int error; - - if (ndp->ni_ufs.ufs_count == 0) { - /* - * First entry in block: set d_ino to zero. - */ - error = blkatoff(dp, (off_t)ndp->ni_ufs.ufs_offset, (char **)&ep, &bp); - if (error) - return (error); - ep->d_ino = 0; - error = bwrite(bp); - dp->i_flag |= IUPD|ICHG; - return (error); - } - /* - * Collapse new free space into previous entry. - */ - if (error = blkatoff(dp, (off_t)ndp->ni_ufs.ufs_offset - ndp->ni_ufs.ufs_count, - (char **)&ep, &bp)) { - return (error); - } - ep->d_reclen += ndp->ni_ufs.ufs_reclen; - error = bwrite(bp); - dp->i_flag |= IUPD|ICHG; - return (error); -} - -/* - * Rewrite an existing directory entry to point at the inode - * supplied. The parameters describing the directory entry are - * set up by a call to namei. - */ -dirrewrite(dp, ip, ndp) - struct inode *dp, *ip; - struct nameidata *ndp; -{ - struct direct *ep; - struct buf *bp; - int error; - - if (error = blkatoff(dp, (off_t)ndp->ni_ufs.ufs_offset, (char **)&ep, &bp)) - return (error); - ep->d_ino = ip->i_number; - error = bwrite(bp); - dp->i_flag |= IUPD|ICHG; - return (error); -} - -/* - * Return buffer with contents of block "offset" - * from the beginning of directory "ip". If "res" - * is non-zero, fill it in with a pointer to the - * remaining space in the directory. - */ -blkatoff(ip, offset, res, bpp) - struct inode *ip; - off_t offset; - char **res; - struct buf **bpp; -{ - register struct fs *fs = ip->i_fs; - daddr_t lbn = lblkno(fs, offset); - int bsize = blksize(fs, ip, lbn); - struct buf *bp; - daddr_t bn; - int error; - - *bpp = 0; - if (error = bread(ITOV(ip), lbn, bsize, NOCRED, &bp)) { - brelse(bp); - return (error); - } - if (res) - *res = bp->b_un.b_addr + blkoff(fs, offset); - *bpp = bp; - return (0); -} - -/* - * Check if a directory is empty or not. - * Inode supplied must be locked. - * - * Using a struct dirtemplate here is not precisely - * what we want, but better than using a struct direct. - * - * NB: does not handle corrupted directories. - */ -dirempty(ip, parentino, cred) - register struct inode *ip; - ino_t parentino; - struct ucred *cred; -{ - register off_t off; - struct dirtemplate dbuf; - register struct direct *dp = (struct direct *)&dbuf; - int error, count; -#define MINDIRSIZ (sizeof (struct dirtemplate) / 2) - - for (off = 0; off < ip->i_size; off += dp->d_reclen) { - error = vn_rdwr(UIO_READ, ITOV(ip), (caddr_t)dp, MINDIRSIZ, off, - UIO_SYSSPACE, IO_NODELOCKED, cred, &count, (struct proc *)0); - /* - * Since we read MINDIRSIZ, residual must - * be 0 unless we're at end of file. - */ - if (error || count != 0) - return (0); - /* avoid infinite loops */ - if (dp->d_reclen == 0) - return (0); - /* skip empty entries */ - if (dp->d_ino == 0) - continue; - /* accept only "." and ".." */ - if (dp->d_namlen > 2) - return (0); - if (dp->d_name[0] != '.') - return (0); - /* - * At this point d_namlen must be 1 or 2. - * 1 implies ".", 2 implies ".." if second - * char is also "." - */ - if (dp->d_namlen == 1) - continue; - if (dp->d_name[1] == '.' && dp->d_ino == parentino) - continue; - return (0); - } - return (1); -} - -/* - * Check if source directory is in the path of the target directory. - * Target is supplied locked, source is unlocked. - * The target is always iput() before returning. - */ -checkpath(source, target, cred) - struct inode *source, *target; - struct ucred *cred; -{ - struct dirtemplate dirbuf; - struct inode *ip; - int error = 0; - - ip = target; - if (ip->i_number == source->i_number) { - error = EEXIST; - goto out; - } - if (ip->i_number == ROOTINO) - goto out; - - for (;;) { - if ((ip->i_mode&IFMT) != IFDIR) { - error = ENOTDIR; - break; - } - error = vn_rdwr(UIO_READ, ITOV(ip), (caddr_t)&dirbuf, - sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE, - IO_NODELOCKED, cred, (int *)0, (struct proc *)0); - if (error != 0) - break; - if (dirbuf.dotdot_namlen != 2 || - dirbuf.dotdot_name[0] != '.' || - dirbuf.dotdot_name[1] != '.') { - error = ENOTDIR; - break; - } - if (dirbuf.dotdot_ino == source->i_number) { - error = EINVAL; - break; - } - if (dirbuf.dotdot_ino == ROOTINO) - break; - iput(ip); - if (error = iget(ip, dirbuf.dotdot_ino, &ip)) - break; - } - -out: - if (error == ENOTDIR) - printf("checkpath: .. not a directory\n"); - if (ip != NULL) - iput(ip); - return (error); -} diff --git a/sys/ufs/ufs_quota.c b/sys/ufs/ufs_quota.c deleted file mode 100644 index a99b303145a0..000000000000 --- a/sys/ufs/ufs_quota.c +++ /dev/null @@ -1,935 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1990 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Robert Elz at The University of Melbourne. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ufs_quota.c 7.11 (Berkeley) 6/21/91 - * $Id: ufs_quota.c,v 1.6 1994/04/25 03:50:50 cgd Exp $ - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -/* - * Quota name to error message mapping. - */ -static char *quotatypes[] = INITQFNAMES; - -/* - * Set up the quotas for an inode. - * - * This routine completely defines the semantics of quotas. - * If other criterion want to be used to establish quotas, the - * MAXQUOTAS value in quotas.h should be increased, and the - * additional dquots set up here. - */ -getinoquota(ip) - register struct inode *ip; -{ - struct ufsmount *ump; - struct vnode *vp = ITOV(ip); - int error; - - ump = VFSTOUFS(vp->v_mount); - /* - * Set up the user quota based on file uid. - * EINVAL means that quotas are not enabled. - */ - if (ip->i_dquot[USRQUOTA] == NODQUOT && - (error = - dqget(vp, ip->i_uid, ump, USRQUOTA, &ip->i_dquot[USRQUOTA])) && - error != EINVAL) - return (error); - /* - * Set up the group quota based on file gid. - * EINVAL means that quotas are not enabled. - */ - if (ip->i_dquot[GRPQUOTA] == NODQUOT && - (error = - dqget(vp, ip->i_gid, ump, GRPQUOTA, &ip->i_dquot[GRPQUOTA])) && - error != EINVAL) - return (error); - return (0); -} - -/* - * Update disk usage, and take corrective action. - */ -chkdq(ip, change, cred, flags) - register struct inode *ip; - long change; - struct ucred *cred; - int flags; -{ - register struct dquot *dq; - register int i; - int ncurblocks, error; - -#ifdef DIAGNOSTIC - if ((flags & CHOWN) == 0) - chkdquot(ip); -#endif - if (change == 0) - return (0); - if (change < 0) { - for (i = 0; i < MAXQUOTAS; i++) { - if ((dq = ip->i_dquot[i]) == NODQUOT) - continue; - while (dq->dq_flags & DQ_LOCK) { - dq->dq_flags |= DQ_WANT; - tsleep((caddr_t)dq, PINOD+1, "chkdq1", 0); - } - ncurblocks = dq->dq_curblocks + change; - if (ncurblocks >= 0) - dq->dq_curblocks = ncurblocks; - else - dq->dq_curblocks = 0; - dq->dq_flags &= ~DQ_BLKS; - dq->dq_flags |= DQ_MOD; - } - return (0); - } - if ((flags & FORCE) == 0 && cred->cr_uid != 0) { - for (i = 0; i < MAXQUOTAS; i++) { - if ((dq = ip->i_dquot[i]) == NODQUOT) - continue; - if (error = chkdqchg(ip, change, cred, i)) - return (error); - } - } - for (i = 0; i < MAXQUOTAS; i++) { - if ((dq = ip->i_dquot[i]) == NODQUOT) - continue; - while (dq->dq_flags & DQ_LOCK) { - dq->dq_flags |= DQ_WANT; - tsleep((caddr_t)dq, PINOD+1, "chkdq2", 0); - } - dq->dq_curblocks += change; - dq->dq_flags |= DQ_MOD; - } - return (0); -} - -/* - * Check for a valid change to a users allocation. - * Issue an error message if appropriate. - */ -chkdqchg(ip, change, cred, type) - struct inode *ip; - long change; - struct ucred *cred; - int type; -{ - register struct dquot *dq = ip->i_dquot[type]; - long ncurblocks = dq->dq_curblocks + change; - - /* - * If user would exceed their hard limit, disallow space allocation. - */ - if (ncurblocks >= dq->dq_bhardlimit && dq->dq_bhardlimit) { - if ((dq->dq_flags & DQ_BLKS) == 0 && - ip->i_uid == cred->cr_uid) { - uprintf("\n%s: write failed, %s disk limit reached\n", - ip->i_fs->fs_fsmnt, quotatypes[type]); - dq->dq_flags |= DQ_BLKS; - } - return (EDQUOT); - } - /* - * If user is over their soft limit for too long, disallow space - * allocation. Reset time limit as they cross their soft limit. - */ - if (ncurblocks >= dq->dq_bsoftlimit && dq->dq_bsoftlimit) { - if (dq->dq_curblocks < dq->dq_bsoftlimit) { - dq->dq_btime = time.tv_sec + - VFSTOUFS(ITOV(ip)->v_mount)->um_btime[type]; - if (ip->i_uid == cred->cr_uid) - uprintf("\n%s: warning, %s %s\n", - ip->i_fs->fs_fsmnt, quotatypes[type], - "disk quota exceeded"); - return (0); - } - if (time.tv_sec > dq->dq_btime) { - if ((dq->dq_flags & DQ_BLKS) == 0 && - ip->i_uid == cred->cr_uid) { - uprintf("\n%s: write failed, %s %s\n", - ip->i_fs->fs_fsmnt, quotatypes[type], - "disk quota exceeded too long"); - dq->dq_flags |= DQ_BLKS; - } - return (EDQUOT); - } - } - return (0); -} - -/* - * Check the inode limit, applying corrective action. - */ -chkiq(ip, change, cred, flags) - register struct inode *ip; - long change; - struct ucred *cred; - int flags; -{ - register struct dquot *dq; - register int i; - int ncurinodes, error; - -#ifdef DIAGNOSTIC - if ((flags & CHOWN) == 0) - chkdquot(ip); -#endif - if (change == 0) - return (0); - if (change < 0) { - for (i = 0; i < MAXQUOTAS; i++) { - if ((dq = ip->i_dquot[i]) == NODQUOT) - continue; - while (dq->dq_flags & DQ_LOCK) { - dq->dq_flags |= DQ_WANT; - tsleep((caddr_t)dq, PINOD+1, "chkiq1", 0); - } - ncurinodes = dq->dq_curinodes + change; - if (ncurinodes >= 0) - dq->dq_curinodes = ncurinodes; - else - dq->dq_curinodes = 0; - dq->dq_flags &= ~DQ_INODS; - dq->dq_flags |= DQ_MOD; - } - return (0); - } - if ((flags & FORCE) == 0 && cred->cr_uid != 0) { - for (i = 0; i < MAXQUOTAS; i++) { - if ((dq = ip->i_dquot[i]) == NODQUOT) - continue; - if (error = chkiqchg(ip, change, cred, i)) - return (error); - } - } - for (i = 0; i < MAXQUOTAS; i++) { - if ((dq = ip->i_dquot[i]) == NODQUOT) - continue; - while (dq->dq_flags & DQ_LOCK) { - dq->dq_flags |= DQ_WANT; - tsleep((caddr_t)dq, PINOD+1, "chkiq2", 0); - } - dq->dq_curinodes += change; - dq->dq_flags |= DQ_MOD; - } - return (0); -} - -/* - * Check for a valid change to a users allocation. - * Issue an error message if appropriate. - */ -chkiqchg(ip, change, cred, type) - struct inode *ip; - long change; - struct ucred *cred; - int type; -{ - register struct dquot *dq = ip->i_dquot[type]; - long ncurinodes = dq->dq_curinodes + change; - - /* - * If user would exceed their hard limit, disallow inode allocation. - */ - if (ncurinodes >= dq->dq_ihardlimit && dq->dq_ihardlimit) { - if ((dq->dq_flags & DQ_INODS) == 0 && - ip->i_uid == cred->cr_uid) { - uprintf("\n%s: write failed, %s inode limit reached\n", - ip->i_fs->fs_fsmnt, quotatypes[type]); - dq->dq_flags |= DQ_INODS; - } - return (EDQUOT); - } - /* - * If user is over their soft limit for too long, disallow inode - * allocation. Reset time limit as they cross their soft limit. - */ - if (ncurinodes >= dq->dq_isoftlimit && dq->dq_isoftlimit) { - if (dq->dq_curinodes < dq->dq_isoftlimit) { - dq->dq_itime = time.tv_sec + - VFSTOUFS(ITOV(ip)->v_mount)->um_itime[type]; - if (ip->i_uid == cred->cr_uid) - uprintf("\n%s: warning, %s %s\n", - ip->i_fs->fs_fsmnt, quotatypes[type], - "inode quota exceeded"); - return (0); - } - if (time.tv_sec > dq->dq_itime) { - if ((dq->dq_flags & DQ_INODS) == 0 && - ip->i_uid == cred->cr_uid) { - uprintf("\n%s: write failed, %s %s\n", - ip->i_fs->fs_fsmnt, quotatypes[type], - "inode quota exceeded too long"); - dq->dq_flags |= DQ_INODS; - } - return (EDQUOT); - } - } - return (0); -} - -#ifdef DIAGNOSTIC -/* - * On filesystems with quotas enabled, - * it is an error for a file to change size and not - * to have a dquot structure associated with it. - */ -chkdquot(ip) - register struct inode *ip; -{ - struct ufsmount *ump = VFSTOUFS(ITOV(ip)->v_mount); - register int i; - - for (i = 0; i < MAXQUOTAS; i++) { - if (ump->um_quotas[i] == NULLVP || - (ump->um_qflags[i] & (QTF_OPENING|QTF_CLOSING))) - continue; - if (ip->i_dquot[i] == NODQUOT) { - vprint("chkdquot: missing dquot", ITOV(ip)); - panic("missing dquot"); - } - } -} -#endif /* DIAGNOSTIC */ - -/* - * Code to process quotactl commands. - */ - -/* - * Q_QUOTAON - set up a quota file for a particular file system. - */ -quotaon(p, mp, type, fname) - struct proc *p; - struct mount *mp; - register int type; - caddr_t fname; -{ - register struct ufsmount *ump = VFSTOUFS(mp); - register struct vnode *vp, **vpp; - struct vnode *nextvp; - struct dquot *dq; - int error; - struct nameidata nd; - - vpp = &ump->um_quotas[type]; - nd.ni_segflg = UIO_USERSPACE; - nd.ni_dirp = fname; - if (error = vn_open(&nd, p, FREAD|FWRITE, 0)) - return (error); - vp = nd.ni_vp; - VOP_UNLOCK(vp); - if (vp->v_type != VREG) { - (void) vn_close(vp, FREAD|FWRITE, p->p_ucred, p); - return (EACCES); - } - if (vfs_busy(mp)) { - (void) vn_close(vp, FREAD|FWRITE, p->p_ucred, p); - return (EBUSY); - } - if (*vpp != vp) - quotaoff(p, mp, type); - ump->um_qflags[type] |= QTF_OPENING; - mp->mnt_flag |= MNT_QUOTA; - vp->v_flag |= VSYSTEM; - *vpp = vp; - /* - * Save the credential of the process that turned on quotas. - * Set up the time limits for this quota. - */ - crhold(p->p_ucred); - ump->um_cred[type] = p->p_ucred; - ump->um_btime[type] = MAX_DQ_TIME; - ump->um_itime[type] = MAX_IQ_TIME; - if (dqget(NULLVP, 0, ump, type, &dq) == 0) { - if (dq->dq_btime > 0) - ump->um_btime[type] = dq->dq_btime; - if (dq->dq_itime > 0) - ump->um_itime[type] = dq->dq_itime; - dqrele(NULLVP, dq); - } - /* - * Search vnodes associated with this mount point, - * adding references to quota file being opened. - * NB: only need to add dquot's for inodes being modified. - */ -again: - for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nextvp) { - nextvp = vp->v_mntvnodes.le_next; - if (vp->v_writecount == 0) - continue; - if (vget(vp, 1)) - goto again; - if (error = getinoquota(VTOI(vp))) { - vput(vp); - break; - } - vput(vp); - if (vp->v_mntvnodes.le_next != nextvp || vp->v_mount != mp) - goto again; - } - ump->um_qflags[type] &= ~QTF_OPENING; - if (error) - quotaoff(p, mp, type); - vfs_unbusy(mp); - return (error); -} - -/* - * Q_QUOTAOFF - turn off disk quotas for a filesystem. - */ -quotaoff(p, mp, type) - struct proc *p; - struct mount *mp; - register int type; -{ - register struct vnode *vp; - struct vnode *qvp, *nextvp; - struct ufsmount *ump = VFSTOUFS(mp); - register struct dquot *dq; - register struct inode *ip; - int error; - - if ((mp->mnt_flag & MNT_MPBUSY) == 0) - panic("quotaoff: not busy"); - if ((qvp = ump->um_quotas[type]) == NULLVP) - return (0); - ump->um_qflags[type] |= QTF_CLOSING; - /* - * Search vnodes associated with this mount point, - * deleting any references to quota file being closed. - */ -again: - for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nextvp) { - nextvp = vp->v_mntvnodes.le_next; - if (vget(vp, 1)) - goto again; - ip = VTOI(vp); - dq = ip->i_dquot[type]; - ip->i_dquot[type] = NODQUOT; - dqrele(vp, dq); - vput(vp); - if (vp->v_mntvnodes.le_next != nextvp || vp->v_mount != mp) - goto again; - } - dqflush(qvp); - qvp->v_flag &= ~VSYSTEM; - error = vn_close(qvp, FREAD|FWRITE, p->p_ucred, p); - ump->um_quotas[type] = NULLVP; - crfree(ump->um_cred[type]); - ump->um_cred[type] = NOCRED; - ump->um_qflags[type] &= ~QTF_CLOSING; - for (type = 0; type < MAXQUOTAS; type++) - if (ump->um_quotas[type] != NULLVP) - break; - if (type == MAXQUOTAS) - mp->mnt_flag &= ~MNT_QUOTA; - return (error); -} - -/* - * Q_GETQUOTA - return current values in a dqblk structure. - */ -getquota(mp, id, type, addr) - struct mount *mp; - u_long id; - int type; - caddr_t addr; -{ - struct dquot *dq; - int error; - - if (error = dqget(NULLVP, id, VFSTOUFS(mp), type, &dq)) - return (error); - error = copyout((caddr_t)&dq->dq_dqb, addr, sizeof (struct dqblk)); - dqrele(NULLVP, dq); - return (error); -} - -/* - * Q_SETQUOTA - assign an entire dqblk structure. - */ -setquota(mp, id, type, addr) - struct mount *mp; - u_long id; - int type; - caddr_t addr; -{ - register struct dquot *dq; - struct dquot *ndq; - struct ufsmount *ump = VFSTOUFS(mp); - struct dqblk newlim; - int error; - - if (error = copyin(addr, (caddr_t)&newlim, sizeof (struct dqblk))) - return (error); - if (error = dqget(NULLVP, id, ump, type, &ndq)) - return (error); - dq = ndq; - while (dq->dq_flags & DQ_LOCK) { - dq->dq_flags |= DQ_WANT; - tsleep((caddr_t)dq, PINOD+1, "setquot", 0); - } - /* - * Copy all but the current values. - * Reset time limit if previously had no soft limit or were - * under it, but now have a soft limit and are over it. - */ - newlim.dqb_curblocks = dq->dq_curblocks; - newlim.dqb_curinodes = dq->dq_curinodes; - if (dq->dq_id != 0) { - newlim.dqb_btime = dq->dq_btime; - newlim.dqb_itime = dq->dq_itime; - } - if (newlim.dqb_bsoftlimit && - dq->dq_curblocks >= newlim.dqb_bsoftlimit && - (dq->dq_bsoftlimit == 0 || dq->dq_curblocks < dq->dq_bsoftlimit)) - newlim.dqb_btime = time.tv_sec + ump->um_btime[type]; - if (newlim.dqb_isoftlimit && - dq->dq_curinodes >= newlim.dqb_isoftlimit && - (dq->dq_isoftlimit == 0 || dq->dq_curinodes < dq->dq_isoftlimit)) - newlim.dqb_itime = time.tv_sec + ump->um_itime[type]; - dq->dq_dqb = newlim; - if (dq->dq_curblocks < dq->dq_bsoftlimit) - dq->dq_flags &= ~DQ_BLKS; - if (dq->dq_curinodes < dq->dq_isoftlimit) - dq->dq_flags &= ~DQ_INODS; - if (dq->dq_isoftlimit == 0 && dq->dq_bsoftlimit == 0 && - dq->dq_ihardlimit == 0 && dq->dq_bhardlimit == 0) - dq->dq_flags |= DQ_FAKE; - else - dq->dq_flags &= ~DQ_FAKE; - dq->dq_flags |= DQ_MOD; - dqrele(NULLVP, dq); - return (0); -} - -/* - * Q_SETUSE - set current inode and block usage. - */ -setuse(mp, id, type, addr) - struct mount *mp; - u_long id; - int type; - caddr_t addr; -{ - register struct dquot *dq; - struct ufsmount *ump = VFSTOUFS(mp); - struct dquot *ndq; - struct dqblk usage; - int error; - - if (error = copyin(addr, (caddr_t)&usage, sizeof (struct dqblk))) - return (error); - if (error = dqget(NULLVP, id, ump, type, &ndq)) - return (error); - dq = ndq; - while (dq->dq_flags & DQ_LOCK) { - dq->dq_flags |= DQ_WANT; - tsleep((caddr_t)dq, PINOD+1, "setuse", 0); - } - /* - * Reset time limit if have a soft limit and were - * previously under it, but are now over it. - */ - if (dq->dq_bsoftlimit && dq->dq_curblocks < dq->dq_bsoftlimit && - usage.dqb_curblocks >= dq->dq_bsoftlimit) - dq->dq_btime = time.tv_sec + ump->um_btime[type]; - if (dq->dq_isoftlimit && dq->dq_curinodes < dq->dq_isoftlimit && - usage.dqb_curinodes >= dq->dq_isoftlimit) - dq->dq_itime = time.tv_sec + ump->um_itime[type]; - dq->dq_curblocks = usage.dqb_curblocks; - dq->dq_curinodes = usage.dqb_curinodes; - if (dq->dq_curblocks < dq->dq_bsoftlimit) - dq->dq_flags &= ~DQ_BLKS; - if (dq->dq_curinodes < dq->dq_isoftlimit) - dq->dq_flags &= ~DQ_INODS; - dq->dq_flags |= DQ_MOD; - dqrele(NULLVP, dq); - return (0); -} - -/* - * Q_SYNC - sync quota files to disk. - */ -qsync(mp) - struct mount *mp; -{ - struct ufsmount *ump = VFSTOUFS(mp); - register struct vnode *vp, *nextvp; - register struct dquot *dq; - register int i; - - /* - * Check if the mount point has any quotas. - * If not, simply return. - */ - if ((mp->mnt_flag & MNT_MPBUSY) == 0) - panic("qsync: not busy"); - for (i = 0; i < MAXQUOTAS; i++) - if (ump->um_quotas[i] != NULLVP) - break; - if (i == MAXQUOTAS) - return (0); - /* - * Search vnodes associated with this mount point, - * synchronizing any modified dquot structures. - */ -again: - for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nextvp) { - nextvp = vp->v_mntvnodes.le_next; - if (VOP_ISLOCKED(vp)) - continue; - if (vget(vp, 1)) - goto again; - for (i = 0; i < MAXQUOTAS; i++) { - dq = VTOI(vp)->i_dquot[i]; - if (dq != NODQUOT && (dq->dq_flags & DQ_MOD)) - dqsync(vp, dq); - } - vput(vp); - if (vp->v_mntvnodes.le_next != nextvp || vp->v_mount != mp) - goto again; - } - return (0); -} - -/* - * Code pertaining to management of the in-core dquot data structures. - */ - -/* - * Dquot cache - hash chain headers. - */ -union dqhead { - union dqhead *dqh_head[2]; - struct dquot *dqh_chain[2]; -}; -#define dqh_forw dqh_chain[0] -#define dqh_back dqh_chain[1] - -union dqhead *dqhashtbl; -long dqhash; - -/* - * Dquot free list. - */ -#define DQUOTINC 5 /* minimum free dquots desired */ -struct dquot *dqfreel, **dqback = &dqfreel; -long numdquot, desireddquot = DQUOTINC; - -/* - * Initialize the quota system. - */ -dqinit() -{ - register union dqhead *dhp; - register long dqhashsize; - - dqhashsize = roundup((desiredvnodes + 1) * sizeof *dhp / 2, - NBPG * CLSIZE); - dqhashtbl = (union dqhead *)malloc(dqhashsize, M_DQUOT, M_WAITOK); - for (dqhash = 1; dqhash <= dqhashsize / sizeof *dhp; dqhash <<= 1) - /* void */; - dqhash = (dqhash >> 1) - 1; - for (dhp = &dqhashtbl[dqhash]; dhp >= dqhashtbl; dhp--) { - dhp->dqh_head[0] = dhp; - dhp->dqh_head[1] = dhp; - } -} - -/* - * Obtain a dquot structure for the specified identifier and quota file - * reading the information from the file if necessary. - */ -dqget(vp, id, ump, type, dqp) - struct vnode *vp; - u_long id; - register struct ufsmount *ump; - register int type; - struct dquot **dqp; -{ - register struct dquot *dq; - register union dqhead *dh; - register struct dquot *dp; - register struct vnode *dqvp; - struct iovec aiov; - struct uio auio; - int error; - - dqvp = ump->um_quotas[type]; - if (dqvp == NULLVP || (ump->um_qflags[type] & QTF_CLOSING)) { - *dqp = NODQUOT; - return (EINVAL); - } - /* - * Check the cache first. - */ - dh = &dqhashtbl[((((int)(dqvp)) >> 8) + id) & dqhash]; - for (dq = dh->dqh_forw; dq != (struct dquot *)dh; dq = dq->dq_forw) { - if (dq->dq_id != id || - dq->dq_ump->um_quotas[dq->dq_type] != dqvp) - continue; - /* - * Cache hit with no references. Take - * the structure off the free list. - */ - if (dq->dq_cnt == 0) { - dp = dq->dq_freef; - if (dp != NODQUOT) - dp->dq_freeb = dq->dq_freeb; - else - dqback = dq->dq_freeb; - *dq->dq_freeb = dp; - } - DQREF(dq); - *dqp = dq; - return (0); - } - /* - * Not in cache, allocate a new one. - */ - if (dqfreel == NODQUOT && numdquot < MAXQUOTAS * desiredvnodes) - desireddquot += DQUOTINC; - if (numdquot < desireddquot) { - dq = (struct dquot *)malloc(sizeof *dq, M_DQUOT, M_WAITOK); - bzero((char *)dq, sizeof *dq); - numdquot++; - } else { - if ((dq = dqfreel) == NULL) { - tablefull("dquot"); - *dqp = NODQUOT; - return (EUSERS); - } - if (dq->dq_cnt || (dq->dq_flags & DQ_MOD)) - panic("free dquot isn't"); - if ((dp = dq->dq_freef) != NODQUOT) - dp->dq_freeb = &dqfreel; - else - dqback = &dqfreel; - dqfreel = dp; - dq->dq_freef = NULL; - dq->dq_freeb = NULL; - remque(dq); - } - /* - * Initialize the contents of the dquot structure. - */ - if (vp != dqvp) - VOP_LOCK(dqvp); - insque(dq, dh); - DQREF(dq); - dq->dq_flags = DQ_LOCK; - dq->dq_id = id; - dq->dq_ump = ump; - dq->dq_type = type; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - aiov.iov_base = (caddr_t)&dq->dq_dqb; - aiov.iov_len = sizeof (struct dqblk); - auio.uio_resid = sizeof (struct dqblk); - auio.uio_offset = (off_t)(id * sizeof (struct dqblk)); - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_rw = UIO_READ; - auio.uio_procp = (struct proc *)0; - error = VOP_READ(dqvp, &auio, 0, ump->um_cred[type]); - if (auio.uio_resid == sizeof(struct dqblk) && error == 0) - bzero((caddr_t)&dq->dq_dqb, sizeof(struct dqblk)); - if (vp != dqvp) - VOP_UNLOCK(dqvp); - if (dq->dq_flags & DQ_WANT) - wakeup((caddr_t)dq); - dq->dq_flags = 0; - /* - * I/O error in reading quota file, release - * quota structure and reflect problem to caller. - */ - if (error) { - remque(dq); - dq->dq_forw = dq; /* on a private, unfindable hash list */ - dq->dq_back = dq; - dqrele(vp, dq); - *dqp = NODQUOT; - return (error); - } - /* - * Check for no limit to enforce. - * Initialize time values if necessary. - */ - if (dq->dq_isoftlimit == 0 && dq->dq_bsoftlimit == 0 && - dq->dq_ihardlimit == 0 && dq->dq_bhardlimit == 0) - dq->dq_flags |= DQ_FAKE; - if (dq->dq_id != 0) { - if (dq->dq_btime == 0) - dq->dq_btime = time.tv_sec + ump->um_btime[type]; - if (dq->dq_itime == 0) - dq->dq_itime = time.tv_sec + ump->um_itime[type]; - } - *dqp = dq; - return (0); -} - -/* - * Obtain a reference to a dquot. - */ -dqref(dq) - struct dquot *dq; -{ - - dq->dq_cnt++; -} - -/* - * Release a reference to a dquot. - */ -dqrele(vp, dq) - struct vnode *vp; - register struct dquot *dq; -{ - - if (dq == NODQUOT) - return; - if (dq->dq_cnt > 1) { - dq->dq_cnt--; - return; - } - if (dq->dq_flags & DQ_MOD) - (void) dqsync(vp, dq); - if (--dq->dq_cnt > 0) - return; - if (dqfreel != NODQUOT) { - *dqback = dq; - dq->dq_freeb = dqback; - } else { - dqfreel = dq; - dq->dq_freeb = &dqfreel; - } - dq->dq_freef = NODQUOT; - dqback = &dq->dq_freef; -} - -/* - * Update the disk quota in the quota file. - */ -dqsync(vp, dq) - struct vnode *vp; - register struct dquot *dq; -{ - struct vnode *dqvp; - struct iovec aiov; - struct uio auio; - int error; - - if (dq == NODQUOT) - panic("dqsync: dquot"); - if ((dq->dq_flags & DQ_MOD) == 0) - return (0); - if ((dqvp = dq->dq_ump->um_quotas[dq->dq_type]) == NULLVP) - panic("dqsync: file"); - if (vp != dqvp) - VOP_LOCK(dqvp); - while (dq->dq_flags & DQ_LOCK) { - dq->dq_flags |= DQ_WANT; - tsleep((caddr_t)dq, PINOD+2, "dqsync", 0); - if ((dq->dq_flags & DQ_MOD) == 0) { - if (vp != dqvp) - VOP_UNLOCK(dqvp); - return (0); - } - } - dq->dq_flags |= DQ_LOCK; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - aiov.iov_base = (caddr_t)&dq->dq_dqb; - aiov.iov_len = sizeof (struct dqblk); - auio.uio_resid = sizeof (struct dqblk); - auio.uio_offset = (off_t)(dq->dq_id * sizeof (struct dqblk)); - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_rw = UIO_WRITE; - auio.uio_procp = (struct proc *)0; - error = VOP_WRITE(dqvp, &auio, 0, dq->dq_ump->um_cred[dq->dq_type]); - if (auio.uio_resid && error == 0) - error = EIO; - if (dq->dq_flags & DQ_WANT) - wakeup((caddr_t)dq); - dq->dq_flags &= ~(DQ_MOD|DQ_LOCK|DQ_WANT); - if (vp != dqvp) - VOP_UNLOCK(dqvp); - return (error); -} - -/* - * Flush all entries from the cache for a particular vnode. - */ -dqflush(vp) - register struct vnode *vp; -{ - register union dqhead *dh; - register struct dquot *dq, *nextdq; - - /* - * Move all dquot's that used to refer to this quota - * file off their hash chains (they will eventually - * fall off the head of the free list and be re-used). - */ - for (dh = &dqhashtbl[dqhash]; dh >= dqhashtbl; dh--) { - for (dq = dh->dqh_forw; dq != (struct dquot *)dh; dq = nextdq) { - nextdq = dq->dq_forw; - if (dq->dq_ump->um_quotas[dq->dq_type] != vp) - continue; - if (dq->dq_cnt) - panic("dqflush: stray dquot"); - remque(dq); - dq->dq_forw = dq; - dq->dq_back = dq; - dq->dq_ump = (struct ufsmount *)0; - } - } -} diff --git a/sys/ufs/ufs_subr.c b/sys/ufs/ufs_subr.c deleted file mode 100644 index 2236df83dfc2..000000000000 --- a/sys/ufs/ufs_subr.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ufs_subr.c 7.13 (Berkeley) 6/28/90 - * $Id: ufs_subr.c,v 1.6 1993/12/17 08:12:23 mycroft Exp $ - */ - -#include - -#include - -extern int around[9]; -extern int inside[9]; -extern u_char *fragtbl[]; - -/* - * Update the frsum fields to reflect addition or deletion - * of some frags. - */ -fragacct(fs, fragmap, fraglist, cnt) - struct fs *fs; - int fragmap; - long fraglist[]; - int cnt; -{ - int inblk; - register int field, subfield; - register int siz, pos; - - inblk = (int)(fragtbl[fs->fs_frag][fragmap]) << 1; - fragmap <<= 1; - for (siz = 1; siz < fs->fs_frag; siz++) { - if ((inblk & (1 << (siz + (fs->fs_frag % NBBY)))) == 0) - continue; - field = around[siz]; - subfield = inside[siz]; - for (pos = siz; pos <= fs->fs_frag; pos++) { - if ((fragmap & field) == subfield) { - fraglist[siz] += cnt; - pos += siz; - field <<= siz; - subfield <<= siz; - } - field <<= 1; - subfield <<= 1; - } - } -} - -/* - * block operations - * - * check if a block is available - */ -isblock(fs, cp, h) - struct fs *fs; - unsigned char *cp; - daddr_t h; -{ - unsigned char mask; - - switch ((int)fs->fs_frag) { - case 8: - return (cp[h] == 0xff); - case 4: - mask = 0x0f << ((h & 0x1) << 2); - return ((cp[h >> 1] & mask) == mask); - case 2: - mask = 0x03 << ((h & 0x3) << 1); - return ((cp[h >> 2] & mask) == mask); - case 1: - mask = 0x01 << (h & 0x7); - return ((cp[h >> 3] & mask) == mask); - default: - panic("isblock"); - return (NULL); - } -} - -/* - * take a block out of the map - */ -clrblock(fs, cp, h) - struct fs *fs; - u_char *cp; - daddr_t h; -{ - - switch ((int)fs->fs_frag) { - case 8: - cp[h] = 0; - return; - case 4: - cp[h >> 1] &= ~(0x0f << ((h & 0x1) << 2)); - return; - case 2: - cp[h >> 2] &= ~(0x03 << ((h & 0x3) << 1)); - return; - case 1: - cp[h >> 3] &= ~(0x01 << (h & 0x7)); - return; - default: - panic("clrblock"); - } -} - -/* - * put a block into the map - */ -setblock(fs, cp, h) - struct fs *fs; - unsigned char *cp; - daddr_t h; -{ - - switch ((int)fs->fs_frag) { - - case 8: - cp[h] = 0xff; - return; - case 4: - cp[h >> 1] |= (0x0f << ((h & 0x1) << 2)); - return; - case 2: - cp[h >> 2] |= (0x03 << ((h & 0x3) << 1)); - return; - case 1: - cp[h >> 3] |= (0x01 << (h & 0x7)); - return; - default: - panic("setblock"); - } -} diff --git a/sys/ufs/ufs_tables.c b/sys/ufs/ufs_tables.c deleted file mode 100644 index bb66df12f157..000000000000 --- a/sys/ufs/ufs_tables.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 1982, 1986 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ufs_tables.c 7.4 (Berkeley) 6/28/90 - * $Id: ufs_tables.c,v 1.3 1993/12/17 08:12:26 mycroft Exp $ - */ - -#include - -/* - * Bit patterns for identifying fragments in the block map - * used as ((map & around) == inside) - */ -int around[9] = { - 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff -}; -int inside[9] = { - 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe -}; - -/* - * Given a block map bit pattern, the frag tables tell whether a - * particular size fragment is available. - * - * used as: - * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] { - * at least one fragment of the indicated size is available - * } - * - * These tables are used by the scanc instruction on the VAX to - * quickly find an appropriate fragment. - */ -u_char fragtbl124[256] = { - 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e, - 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x26, 0x36, 0x36, 0x2e, 0x36, 0x36, 0x26, 0x6e, - 0x36, 0x36, 0x36, 0x3e, 0x2e, 0x3e, 0x6e, 0xae, - 0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e, - 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe, - 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe, - 0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e, - 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce, - 0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce, - 0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a, -}; - -u_char fragtbl8[256] = { - 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04, - 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, - 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, - 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11, - 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, - 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a, - 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04, - 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, - 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21, - 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, - 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, - 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12, - 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04, - 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c, - 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c, - 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80, -}; - -/* - * The actual fragtbl array. - */ -u_char *fragtbl[MAXFRAG + 1] = { - 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8, -}; diff --git a/sys/ufs/ufs_vfsops.c b/sys/ufs/ufs_vfsops.c deleted file mode 100644 index 5630edbc3b80..000000000000 --- a/sys/ufs/ufs_vfsops.c +++ /dev/null @@ -1,698 +0,0 @@ -/* - * Copyright (c) 1989, 1991 The Regents of the University of California. - * All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ufs_vfsops.c 7.56 (Berkeley) 6/28/91 - * $Id: ufs_vfsops.c,v 1.18 1994/05/24 02:33:03 cgd Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include /* XXX */ -#include -#include -#include -#include /* XXX */ -#include -#include -#include -#include - -#include -#include -#include -#include - -struct vfsops ufs_vfsops = { - MOUNT_UFS, - ufs_mount, - ufs_start, - ufs_unmount, - ufs_root, - ufs_quotactl, - ufs_statfs, - ufs_sync, - ufs_fhtovp, - ufs_vptofh, - ufs_init -}; - -/* - * Called by vfs_mountroot when ufs is going to be mounted as root. - * - * Name is updated by mount(8) after booting. - */ -#define ROOTNAME "root_device" - -ufs_mountroot() -{ - register struct mount *mp; - extern struct vnode *rootvp; - struct proc *p = curproc; /* XXX */ - struct ufsmount *ump; - register struct fs *fs; - u_int size; - int error; - - mp = (struct mount *)malloc((u_long)sizeof(struct mount), - M_MOUNT, M_WAITOK); - mp->mnt_op = &ufs_vfsops; - mp->mnt_flag = MNT_RDONLY; - mp->mnt_exroot = 0; - LIST_INIT(&mp->mnt_vnodelist); - error = mountfs(rootvp, mp, p); - if (error) { - free((caddr_t)mp, M_MOUNT); - return (error); - } - if (error = vfs_lock(mp)) { - (void)ufs_unmount(mp, 0, p); - free((caddr_t)mp, M_MOUNT); - return (error); - } - rootfs = mp; - TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); - mp->mnt_vnodecovered = NULLVP; - ump = VFSTOUFS(mp); - fs = ump->um_fs; - bzero(fs->fs_fsmnt, sizeof(fs->fs_fsmnt)); - fs->fs_fsmnt[0] = '/'; - bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname, - MNAMELEN); - (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, - &size); - bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void) ufs_statfs(mp, &mp->mnt_stat, p); - vfs_unlock(mp); - inittodr(fs->fs_time); - return (0); -} - -/* - * VFS Operations. - * - * mount system call - */ -ufs_mount(mp, path, data, ndp, p) - register struct mount *mp; - char *path; - caddr_t data; - struct nameidata *ndp; - struct proc *p; -{ - struct vnode *devvp; - struct ufs_args args; - struct ufsmount *ump; - register struct fs *fs; - u_int size; - int error; - - if (error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args))) - return (error); - /* - * If updating, check whether changing from read-only to - * read/write; if there is no device name, that's all we do. - */ - if (mp->mnt_flag & MNT_UPDATE) { - ump = VFSTOUFS(mp); - fs = ump->um_fs; - if (fs->fs_ronly && (mp->mnt_flag & MNT_RDONLY) == 0) - fs->fs_ronly = 0; - if (args.fspec == 0) - return (0); - } - /* - * Not an update, or updating the name: look up the name - * and verify that it refers to a sensible block device. - */ - ndp->ni_nameiop = LOOKUP | FOLLOW; - ndp->ni_segflg = UIO_USERSPACE; - ndp->ni_dirp = args.fspec; - if (error = namei(ndp, p)) - return (error); - devvp = ndp->ni_vp; - if (devvp->v_type != VBLK) { - vrele(devvp); - return (ENOTBLK); - } - if (major(devvp->v_rdev) >= nblkdev) { - vrele(devvp); - return (ENXIO); - } - if ((mp->mnt_flag & MNT_UPDATE) == 0) - error = mountfs(devvp, mp, p); - else { - if (devvp != ump->um_devvp) - error = EINVAL; /* needs translation */ - else - vrele(devvp); - } - if (error) { - vrele(devvp); - return (error); - } - ump = VFSTOUFS(mp); - fs = ump->um_fs; - (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size); - bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size); - bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname, - MNAMELEN); - (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, - &size); - bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); - (void) ufs_statfs(mp, &mp->mnt_stat, p); - return (0); -} - -/* - * Common code for mount and mountroot - */ -mountfs(devvp, mp, p) - register struct vnode *devvp; - struct mount *mp; - struct proc *p; -{ - register struct ufsmount *ump = (struct ufsmount *)0; - struct buf *bp = NULL; - register struct fs *fs; - dev_t dev = devvp->v_rdev; - struct partinfo dpart; - caddr_t base, space; - int havepart = 0, blks; - int error, i, size; - int needclose = 0; - int ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - extern struct vnode *rootvp; - - /* - * Disallow multiple mounts of the same device. - * Disallow mounting of a device that is currently in use - * (except for root, which might share swap device for miniroot). - * Flush out any old buffers remaining from a previous use. - */ - if (error = mountedon(devvp)) - return (error); - if (vcount(devvp) > 1 && devvp != rootvp) - return (EBUSY); - vinvalbuf(devvp, 1); - if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p)) - return (error); - needclose = 1; - if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0) - size = DEV_BSIZE; - else { - havepart = 1; - size = dpart.disklab->d_secsize; - } - if (error = bread(devvp, SBOFF / size, SBSIZE, NOCRED, &bp)) - goto out; - fs = (struct fs *)bp->b_data; - if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE || - fs->fs_bsize < sizeof(struct fs)) { - error = EINVAL; /* XXX needs translation */ - goto out; - } - ump = (struct ufsmount *)malloc(sizeof *ump, M_UFSMNT, M_WAITOK); - ump->um_fs = (struct fs *)malloc((u_long)fs->fs_sbsize, M_UFSMNT, - M_WAITOK); - bcopy((caddr_t)bp->b_un.b_addr, (caddr_t)ump->um_fs, - (u_int)fs->fs_sbsize); - if (fs->fs_sbsize < SBSIZE) - bp->b_flags |= B_INVAL; - brelse(bp); - bp = NULL; - fs = ump->um_fs; - fs->fs_ronly = ronly; - if (ronly == 0) - fs->fs_fmod = 1; - if (havepart) { - dpart.part->p_fstype = FS_BSDFFS; - dpart.part->p_fsize = fs->fs_fsize; - dpart.part->p_frag = fs->fs_frag; - dpart.part->p_cpg = fs->fs_cpg; - } - blks = howmany(fs->fs_cssize, fs->fs_fsize); - base = space = (caddr_t)malloc((u_long)fs->fs_cssize, M_UFSMNT, - M_WAITOK); - for (i = 0; i < blks; i += fs->fs_frag) { - size = fs->fs_bsize; - if (i + fs->fs_frag > blks) - size = (blks - i) * fs->fs_fsize; - error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + i), size, - NOCRED, &bp); - if (error) { - free((caddr_t)base, M_UFSMNT); - goto out; - } - bcopy((caddr_t)bp->b_un.b_addr, space, (u_int)size); - fs->fs_csp[fragstoblks(fs, i)] = (struct csum *)space; - space += size; - brelse(bp); - bp = NULL; - } - mp->mnt_data = (qaddr_t)ump; - mp->mnt_stat.f_fsid.val[0] = (long)dev; - mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_UFS); - mp->mnt_flag |= MNT_LOCAL; - ump->um_mountp = mp; - ump->um_dev = dev; - ump->um_devvp = devvp; - for (i = 0; i < MAXQUOTAS; i++) - ump->um_quotas[i] = NULLVP; - devvp->v_specflags |= SI_MOUNTEDON; - - /* Sanity checks for old file systems. XXX */ - fs->fs_npsect = max(fs->fs_npsect, fs->fs_nsect); /* XXX */ - fs->fs_interleave = max(fs->fs_interleave, 1); /* XXX */ - if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */ - fs->fs_nrpos = 8; /* XXX */ - return (0); -out: - if (bp) - brelse(bp); - if (needclose) - (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p); - if (ump) { - free((caddr_t)ump->um_fs, M_UFSMNT); - free((caddr_t)ump, M_UFSMNT); - mp->mnt_data = (qaddr_t)0; - } - return (error); -} - -/* - * Make a filesystem operational. - * Nothing to do at the moment. - */ -/* ARGSUSED */ -ufs_start(mp, flags, p) - struct mount *mp; - int flags; - struct proc *p; -{ - - return (0); -} - -/* - * unmount system call - */ -ufs_unmount(mp, mntflags, p) - struct mount *mp; - int mntflags; - struct proc *p; -{ - register struct ufsmount *ump; - register struct fs *fs; - int i, error, ronly, flags = 0; - extern int doforce; - - if (mntflags & MNT_FORCE) { - if (!doforce || mp == rootfs) - return (EINVAL); - flags |= FORCECLOSE; - } - mntflushbuf(mp, 0); - if (mntinvalbuf(mp)) - return (EBUSY); - ump = VFSTOUFS(mp); -#ifdef QUOTA - if (mp->mnt_flag & MNT_QUOTA) { - if (error = vflush(mp, NULLVP, SKIPSYSTEM|flags)) - return (error); - for (i = 0; i < MAXQUOTAS; i++) { - if (ump->um_quotas[i] == NULLVP) - continue; - quotaoff(p, mp, i); - } - /* - * Here we fall through to vflush again to ensure - * that we have gotten rid of all the system vnodes. - */ - } -#endif - if (error = vflush(mp, NULLVP, flags)) - return (error); - fs = ump->um_fs; - ronly = !fs->fs_ronly; - ump->um_devvp->v_specflags &= ~SI_MOUNTEDON; - error = VOP_CLOSE(ump->um_devvp, ronly ? FREAD : FREAD|FWRITE, - NOCRED, p); - vrele(ump->um_devvp); - free((caddr_t)fs->fs_csp[0], M_UFSMNT); - free((caddr_t)fs, M_UFSMNT); - free((caddr_t)ump, M_UFSMNT); - mp->mnt_data = (qaddr_t)0; - mp->mnt_flag &= ~MNT_LOCAL; - return (error); -} - -/* - * Return root of a filesystem - */ -ufs_root(mp, vpp) - struct mount *mp; - struct vnode **vpp; -{ - register struct inode *ip; - struct inode *nip; - struct vnode tvp; - int error; - - tvp.v_mount = mp; - ip = VTOI(&tvp); - ip->i_vnode = &tvp; - ip->i_dev = VFSTOUFS(mp)->um_dev; - error = iget(ip, (ino_t)ROOTINO, &nip); - if (error) - return (error); - *vpp = ITOV(nip); - return (0); -} - -/* - * Do operations associated with quotas - */ -ufs_quotactl(mp, cmds, uid, arg, p) - struct mount *mp; - int cmds; - uid_t uid; - caddr_t arg; - struct proc *p; -{ - struct ufsmount *ump = VFSTOUFS(mp); - int cmd, type, error; - -#ifndef QUOTA - return (EOPNOTSUPP); -#else - if (uid == (uid_t) -1) - uid = p->p_cred->p_ruid; - cmd = cmds >> SUBCMDSHIFT; - - switch (cmd) { - case Q_GETQUOTA: - case Q_SYNC: - if (uid == p->p_cred->p_ruid) - break; - /* fall through */ - default: - if (error = suser(p->p_ucred, &p->p_acflag)) - return (error); - } - - type = cmd & SUBCMDMASK; - if ((u_int)type >= MAXQUOTAS) - return (EINVAL); - - switch (cmd) { - - case Q_QUOTAON: - return (quotaon(p, mp, type, arg)); - - case Q_QUOTAOFF: - if (vfs_busy(mp)) - return (0); - error = quotaoff(p, mp, type); - vfs_unbusy(mp); - return (error); - - case Q_SETQUOTA: - return (setquota(mp, uid, type, arg)); - - case Q_SETUSE: - return (setuse(mp, uid, type, arg)); - - case Q_GETQUOTA: - return (getquota(mp, uid, type, arg)); - - case Q_SYNC: - if (vfs_busy(mp)) - return (0); - error = qsync(mp); - vfs_unbusy(mp); - return (error); - - default: - return (EINVAL); - } - /* NOTREACHED */ -#endif -} - -/* - * Get file system statistics. - */ -ufs_statfs(mp, sbp, p) - struct mount *mp; - register struct statfs *sbp; - struct proc *p; -{ - register struct ufsmount *ump; - register struct fs *fs; - - ump = VFSTOUFS(mp); - fs = ump->um_fs; - if (fs->fs_magic != FS_MAGIC) - panic("ufs_statfs"); -#ifdef COMPAT_09 - sbp->f_type = 1; -#else - sbp->f_type = 0; -#endif - sbp->f_bsize = fs->fs_fsize; - sbp->f_iosize = fs->fs_bsize; - sbp->f_blocks = fs->fs_dsize; - sbp->f_bfree = fs->fs_cstotal.cs_nbfree * fs->fs_frag + - fs->fs_cstotal.cs_nffree; - sbp->f_bavail = (fs->fs_dsize * (100 - fs->fs_minfree) / 100) - - (fs->fs_dsize - sbp->f_bfree); - sbp->f_files = fs->fs_ncg * fs->fs_ipg - ROOTINO; - sbp->f_ffree = fs->fs_cstotal.cs_nifree; - if (sbp != &mp->mnt_stat) { - bcopy((caddr_t)mp->mnt_stat.f_mntonname, - (caddr_t)&sbp->f_mntonname[0], MNAMELEN); - bcopy((caddr_t)mp->mnt_stat.f_mntfromname, - (caddr_t)&sbp->f_mntfromname[0], MNAMELEN); - } - strncpy(&sbp->f_fstypename[0], mp->mnt_op->vfs_name, MFSNAMELEN); - sbp->f_fstypename[MFSNAMELEN] = '\0'; - return (0); -} - -/* - * Go through the disk queues to initiate sandbagged IO; - * go through the inodes to write those that have been modified; - * initiate the writing of the super block if it has been modified. - * - * Note: we are always called with the filesystem marked `MPBUSY'. - */ -ufs_sync(mp, waitfor) - struct mount *mp; - int waitfor; -{ - register struct vnode *vp; - register struct inode *ip; - register struct ufsmount *ump = VFSTOUFS(mp); - register struct fs *fs; - int error, allerror = 0; - - fs = ump->um_fs; - /* - * Write back modified superblock. - * Consistency check that the superblock - * is still in the buffer cache. - */ - if (fs->fs_fmod != 0) { - if (fs->fs_ronly != 0) { /* XXX */ - printf("fs = %s\n", fs->fs_fsmnt); - panic("update: rofs mod"); - } - fs->fs_fmod = 0; - fs->fs_time = time.tv_sec; - allerror = sbupdate(ump, waitfor); - } - /* - * Write back each (modified) inode. - */ -loop: - for (vp = mp->mnt_vnodelist.lh_first; vp; - vp = vp->v_mntvnodes.le_next) { - /* - * If the vnode that we are about to sync is no longer - * associated with this mount point, start over. - */ - if (vp->v_mount != mp) - goto loop; - if (VOP_ISLOCKED(vp)) - continue; - ip = VTOI(vp); - if ((ip->i_flag & (IMOD|IACC|IUPD|ICHG)) == 0 && - vp->v_dirtyblkhd.lh_first == NULL) - continue; - if (vget(vp, 1)) - goto loop; - if (vp->v_dirtyblkhd.lh_first != NULL) - vflushbuf(vp, 0); - if ((ip->i_flag & (IMOD|IACC|IUPD|ICHG)) && - (error = iupdat(ip, (struct timeval *)&time, - (struct timeval *)&time, 0))) - allerror = error; - vput(vp); - } - /* - * Force stale file system control information to be flushed. - */ - vflushbuf(ump->um_devvp, waitfor == MNT_WAIT ? B_SYNC : 0); -#ifdef QUOTA - qsync(mp); -#endif - return (allerror); -} - -/* - * Write a superblock and associated information back to disk. - */ -sbupdate(mp, waitfor) - struct ufsmount *mp; - int waitfor; -{ - register struct fs *fs = mp->um_fs; - register struct buf *bp; - int blks; - caddr_t space; - int i, size, error = 0; - - i = SBOFF >> (fs->fs_fshift - fs->fs_fsbtodb); - bp = getblk(mp->um_devvp, i, (int)fs->fs_sbsize, 0, 0); - bcopy((caddr_t)fs, bp->b_un.b_addr, (u_int)fs->fs_sbsize); - /* Restore compatibility to old file systems. XXX */ - if (fs->fs_postblformat == FS_42POSTBLFMT) /* XXX */ - ((struct fs *)bp->b_data)->fs_nrpos = -1; /* XXX */ - if (waitfor == MNT_WAIT) - error = bwrite(bp); - else - bawrite(bp); - blks = howmany(fs->fs_cssize, fs->fs_fsize); - space = (caddr_t)fs->fs_csp[0]; - for (i = 0; i < blks; i += fs->fs_frag) { - size = fs->fs_bsize; - if (i + fs->fs_frag > blks) - size = (blks - i) * fs->fs_fsize; - bp = getblk(mp->um_devvp, fsbtodb(fs, fs->fs_csaddr + i), size, - 0, 0); - bcopy(space, bp->b_un.b_addr, (u_int)size); - space += size; - if (waitfor == MNT_WAIT) - error = bwrite(bp); - else - bawrite(bp); - } - return (error); -} - -/* - * File handle to vnode - * - * Have to be really careful about stale file handles: - * - check that the inode number is in range - * - call iget() to get the locked inode - * - check for an unallocated inode (i_mode == 0) - * - check that the generation number matches - */ -ufs_fhtovp(mp, fhp, vpp) - register struct mount *mp; - struct fid *fhp; - struct vnode **vpp; -{ - register struct ufid *ufhp; - register struct fs *fs; - register struct inode *ip; - struct inode *nip; - struct vnode tvp; - int error; - - ufhp = (struct ufid *)fhp; - fs = VFSTOUFS(mp)->um_fs; - if (ufhp->ufid_ino < ROOTINO || - ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg) { - *vpp = NULLVP; - return (EINVAL); - } - tvp.v_mount = mp; - ip = VTOI(&tvp); - ip->i_vnode = &tvp; - ip->i_dev = VFSTOUFS(mp)->um_dev; - if (error = iget(ip, ufhp->ufid_ino, &nip)) { - *vpp = NULLVP; - return (error); - } - ip = nip; - if (ip->i_mode == 0) { - iput(ip); - *vpp = NULLVP; - return (EINVAL); - } - if (ip->i_gen != ufhp->ufid_gen) { - iput(ip); - *vpp = NULLVP; - return (EINVAL); - } - *vpp = ITOV(ip); - return (0); -} - -/* - * Vnode pointer to File handle - */ -/* ARGSUSED */ -ufs_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - register struct inode *ip = VTOI(vp); - register struct ufid *ufhp; - - ufhp = (struct ufid *)fhp; - ufhp->ufid_len = sizeof(struct ufid); - ufhp->ufid_ino = ip->i_number; - ufhp->ufid_gen = ip->i_gen; - return (0); -} diff --git a/sys/ufs/ufs_vtab.c b/sys/ufs/ufs_vtab.c deleted file mode 100644 index cadcaffdcade..000000000000 --- a/sys/ufs/ufs_vtab.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ufs_vnops.c 7.64 (Berkeley) 5/16/91 - * $Id: ufs_vtab.c,v 1.1 1994/03/09 21:25:26 ws Exp $ - */ -#include -#include - -#include - -enum vtype iftovt_tab[16] = { - VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON, - VREG, VNON, VLNK, VNON, VSOCK, VNON, VNON, VBAD, -}; -int vttoif_tab[9] = { - 0, IFREG, IFDIR, IFBLK, IFCHR, IFLNK, IFSOCK, IFIFO, IFMT, -}; diff --git a/sys/ufs/ufsmount.h b/sys/ufs/ufsmount.h deleted file mode 100644 index cfe16ac401ac..000000000000 --- a/sys/ufs/ufsmount.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1982, 1986, 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ufsmount.h 7.9 (Berkeley) 5/8/91 - * $Id: ufsmount.h,v 1.4 1994/03/27 09:10:36 cgd Exp $ - */ - -#ifndef _UFS_UFSMOUNT_H_ -#define _UFS_UFSMOUNT_H_ - -/* - * This structure describes the UFS specific mount structure data. - */ -struct ufsmount { - struct mount *um_mountp; /* vfs structure for this filesystem */ - dev_t um_dev; /* device mounted */ - struct vnode *um_devvp; /* vnode for block device mounted */ - struct fs *um_fs; /* pointer to superblock */ - struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */ - struct ucred *um_cred[MAXQUOTAS]; /* cred for access to quota file */ - time_t um_btime[MAXQUOTAS]; /* block quota time limit */ - time_t um_itime[MAXQUOTAS]; /* inode quota time limit */ - char um_qflags[MAXQUOTAS]; /* quota specific flags, see below */ -}; -/* - * Flags describing the state of quotas. - */ -#define QTF_OPENING 0x01 /* Q_QUOTAON in progress */ -#define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */ - -#ifdef KERNEL -/* - * Convert mount ptr to ufsmount ptr. - */ -#define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data)) -#endif /* KERNEL */ - -/* - * Prototypes for UFS mount operations - */ -int ufs_mount __P((struct mount *mp, char *path, caddr_t data, - struct nameidata *ndp, struct proc *p)); -int ufs_start __P((struct mount *mp, int flags, struct proc *p)); -int ufs_unmount __P((struct mount *mp, int mntflags, struct proc *p)); -int ufs_root __P((struct mount *mp, struct vnode **vpp)); -int ufs_quotactl __P((struct mount *mp, int cmds, uid_t uid, caddr_t arg, - struct proc *p)); -int ufs_statfs __P((struct mount *mp, struct statfs *sbp, struct proc *p)); -int ufs_sync __P((struct mount *mp, int waitfor)); -int ufs_fhtovp __P((struct mount *mp, struct fid *fhp, struct vnode **vpp)); -int ufs_vptofh __P((struct vnode *vp, struct fid *fhp)); -int ufs_init __P(()); - -#endif /* !_UFS_UFSMOUNT_H_ */ diff --git a/usr.bin/elvis/ctype.h b/usr.bin/elvis/ctype.h deleted file mode 100644 index df0512b0c361..000000000000 --- a/usr.bin/elvis/ctype.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ctype.h */ - -/* This file contains macros definitions and extern declarations for a - * version of which is aware of the o_flipcase letters used in - * elvis. - * - * This file uses the "uchar" data type and "UCHAR" conversion macro which - * are defined in "config.h". Consequently, any file that includes this - * header must include config.h first. - * - * $Id: ctype.h,v 1.2 1993/08/02 17:53:48 mycroft Exp $ - */ - -#ifndef _CT_UPPER - -#define _CT_UPPER 0x01 -#define _CT_LOWER 0x02 -#define _CT_SPACE 0x04 -#define _CT_DIGIT 0x08 -#define _CT_ALNUM 0x10 -#define _CT_CNTRL 0x20 - -#define isalnum(c) (_ct_ctypes[UCHAR(c)] & _CT_ALNUM) -#define isalpha(c) (_ct_ctypes[UCHAR(c)] & (_CT_LOWER|_CT_UPPER)) -#define isdigit(c) (_ct_ctypes[UCHAR(c)] & _CT_DIGIT) -#define islower(c) (_ct_ctypes[UCHAR(c)] & _CT_LOWER) -#define isspace(c) (_ct_ctypes[UCHAR(c)] & _CT_SPACE) -#define isupper(c) (_ct_ctypes[UCHAR(c)] & _CT_UPPER) -#define iscntrl(c) (_ct_ctypes[UCHAR(c)] & _CT_CNTRL) -#define ispunct(c) (!_ct_ctypes[UCHAR(c)]) /* punct = "none of the above" */ - -#define isascii(c) (!((c) & 0x80)) - -#define toupper(c) _ct_toupper[UCHAR(c)] -#define tolower(c) _ct_tolower[UCHAR(c)] - -extern uchar _ct_toupper[]; -extern uchar _ct_tolower[]; -extern uchar _ct_ctypes[]; -extern void _ct_init(/* char *flipcase */); - -#endif /* ndef _CT_UPPER */ diff --git a/usr.bin/elvis/curses.c b/usr.bin/elvis/curses.c deleted file mode 100644 index 037f1f583200..000000000000 --- a/usr.bin/elvis/curses.c +++ /dev/null @@ -1,1051 +0,0 @@ -/* curses.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains the functions & variables needed for a tiny subset of - * curses. The principle advantage of this version of curses is its - * extreme speed. Disadvantages are potentially larger code, few supported - * functions, limited compatibility with full curses, and only stdscr. - */ - -#ifndef lint -static char rcsid[] = "$Id: curses.c,v 1.4 1993/11/08 05:06:13 alm Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" - -#if ANY_UNIX -# if UNIXV || COH_386 -# ifdef TERMIOS -# include -# else -# include -# endif -# ifndef NO_S5WINSIZE -# ifndef _SEQUENT_ -# include /* winsize struct defined in one of these? */ -# include -# endif -# else -# undef TIOCGWINSZ /* we can't handle it correctly yet */ -# endif -# else -# include -# endif -#endif - -#if TOS -# include -#endif - -#if OSK -# include -#endif - -#if VMS -extern int VMS_read_raw; /* Set in initscr() */ -#endif - - -static void starttcap(); - -/* variables, publicly available & used in the macros */ -char *termtype; /* name of terminal entry */ -short ospeed; /* speed of the tty, eg B2400 */ -#if OSK -char PC_; /* Pad char */ -char *BC; /* backspace character string */ -#else -char PC; /* Pad char */ -#endif -WINDOW *stdscr; /* pointer into kbuf[] */ -WINDOW kbuf[KBSIZ]; /* a very large output buffer */ -int LINES; /* :li#: number of rows */ -int COLS; /* :co#: number of columns */ -int AM; /* :am: boolean: auto margins? */ -int PT; /* :pt: boolean: physical tabs? */ -char *VB; /* :vb=: visible bell */ -char *UP; /* :up=: move cursor up */ -char *SO = ""; /* :so=: standout start */ -char *SE = ""; /* :se=: standout end */ -char *US = ""; /* :us=: underline start */ -char *UE = ""; /* :ue=: underline end */ -char *MD = ""; /* :md=: bold start */ -char *ME = ""; /* :me=: bold end */ -char *AS = ""; /* :as=: alternate (italic) start */ -char *AE = ""; /* :ae=: alternate (italic) end */ -#ifndef NO_VISIBLE -char *MV; /* :mv=: "visible" selection start */ -#endif -char *CM; /* :cm=: cursor movement */ -char *CE; /* :ce=: clear to end of line */ -char *CD; /* :cd=: clear to end of screen */ -char *AL; /* :al=: add a line */ -char *DL; /* :dl=: delete a line */ -#if OSK -char *SR_; /* :sr=: scroll reverse */ -#else -char *SR; /* :sr=: scroll reverse */ -#endif -char *KS = ""; /* :ks=: switch keypad to application mode */ -char *KE = ""; /* :ke=: switch keypad to system mode */ -char *KU; /* :ku=: key sequence sent by up arrow */ -char *KD; /* :kd=: key sequence sent by down arrow */ -char *KL; /* :kl=: key sequence sent by left arrow */ -char *KR; /* :kr=: key sequence sent by right arrow */ -char *HM; /* :HM=: key sequence sent by the key */ -char *EN; /* :EN=: key sequence sent by the key */ -char *PU; /* :PU=: key sequence sent by the key */ -char *PD; /* :PD=: key sequence sent by the key */ -char *KI; /* :kI=: key sequence sent by the key */ -#ifndef NO_FKEY -char *FKEY[NFKEYS]; /* :k0=: ... :k9=: sequences sent by function keys */ -#endif -char *IM = ""; /* :im=: insert mode start */ -char *IC = ""; /* :ic=: insert the following character */ -char *EI = ""; /* :ei=: insert mode end */ -char *DC; /* :dc=: delete a character */ -char *TI = ""; /* :ti=: terminal init */ /* GB */ -char *TE = ""; /* :te=: terminal exit */ /* GB */ -#ifndef NO_CURSORSHAPE -#if 1 -char *CQ = (char *)0;/* :cQ=: normal cursor */ -char *CX = (char *)1;/* :cX=: cursor used for EX command/entry */ -char *CV = (char *)2;/* :cV=: cursor used for VI command mode */ -char *CI = (char *)3;/* :cI=: cursor used for VI input mode */ -char *CR = (char *)4;/* :cR=: cursor used for VI replace mode */ -#else -char *CQ = ""; /* :cQ=: normal cursor */ -char *CX = ""; /* :cX=: cursor used for EX command/entry */ -char *CV = ""; /* :cV=: cursor used for VI command mode */ -char *CI = ""; /* :cI=: cursor used for VI input mode */ -char *CR = ""; /* :cR=: cursor used for VI replace mode */ -#endif -#endif -char *aend = ""; /* end an attribute -- either UE or ME */ -char ERASEKEY; /* backspace key taken from ioctl structure */ -#ifndef NO_COLOR -char normalcolor[24]; -char SOcolor[24]; -char SEcolor[24]; -char UScolor[24]; -char UEcolor[24]; -char MDcolor[24]; -char MEcolor[24]; -char AScolor[24]; -char AEcolor[24]; -# ifndef NO_POPUP -char POPUPcolor[24]; -# endif -# ifndef NO_VISIBLE -char VISIBLEcolor[24]; -# endif -#endif - -#if ANY_UNIX -# if UNIXV || COH_386 -# ifdef TERMIOS -static struct termios oldtermio; /* original tty mode */ -static struct termios newtermio; /* cbreak/noecho tty mode */ -# else -static struct termio oldtermio; /* original tty mode */ -static struct termio newtermio; /* cbreak/noecho tty mode */ -# endif -# else -static struct sgttyb oldsgttyb; /* original tty mode */ -static struct sgttyb newsgttyb; /* cbreak/nl/noecho tty mode */ -static int oldint; /* ^C or DEL, the "intr" character */ -# ifdef TIOCSLTC -static int oldswitch; /* ^Z, the "suspend" character */ -static int olddswitch; /* ^Y, the "delayed suspend" char */ -static int oldquote; /* ^V, the "quote next char" char */ -# endif -# endif -#endif - -#if OSK -static struct sgbuf oldsgttyb; /* orginal tty mode */ -static struct sgbuf newsgttyb; /* noecho tty mode */ -#endif - -static char *capbuf; /* capability string buffer */ - - -/* Initialize the Curses package. */ -void initscr() -{ - /* make sure TERM variable is set */ - termtype = getenv("TERM"); - -#if VMS - /* VMS getenv() handles TERM as a environment setting. Foreign - * terminal support can be implemented by setting the ELVIS_TERM - * logical or symbol to match a tinytcap entry. - */ - if (!strcmp(termtype,"unknown")) - termtype = getenv("ELVIS_TERM"); -#endif -#if MSDOS - /* For MS-DOS, if TERM is unset we can default to "pcbios", or - * maybe "rainbow". - */ - if (!termtype) - { -#ifdef RAINBOW - if (*(unsigned char far*)(0xffff000eL) == 6 /* Rainbow 100a */ - || *(unsigned char far*)(0xffff000eL) == 148)/* Rainbow 100b */ - { - termtype = "rainbow"; - } - else -#endif - termtype = "pcbios"; - } - if (!strcmp(termtype, "pcbios")) -#else - if (!termtype) -#endif - { -#if ANY_UNIX - write(2, "Environment variable TERM must be set\n", (unsigned)38); - exit(2); -#endif -#if OSK - writeln(2, "Environment variable TERM must be set\n", (unsigned)38); - exit(2); -#endif -#if AMIGA - termtype = TERMTYPE; - starttcap(termtype); -#endif -#if MSDOS - starttcap("pcbios"); -#endif -#if TOS - termtype = "vt52"; - starttcap(termtype); -#endif -#if VMS - write(2, "UNKNOWN terminal: define ELVIS_TERM\n", (unsigned)36); - exit(2); -#endif - } - else - { -#if MSDOS - *o_pcbios = 0; -#endif - /* start termcap stuff */ - starttcap(termtype); - } - - /* create stdscr and curscr */ - stdscr = kbuf; - - /* change the terminal mode to cbreak/noecho */ -#if ANY_UNIX -# if UNIXV || COH_386 -# ifdef TERMIOS - tcgetattr(2, &oldtermio); -# else - ioctl(2, TCGETA, &oldtermio); -# endif -# else - ioctl(2, TIOCGETP, &oldsgttyb); -# endif -#endif - -#if OSK - _gs_opt(0, &oldsgttyb); -#endif - -#if VMS - VMS_read_raw = 1; /* cbreak/noecho */ - vms_open_tty(); -#endif - resume_curses(TRUE); -} - -/* Shut down the Curses package. */ -void endwin() -{ - /* change the terminal mode back the way it was */ - suspend_curses(); -#if AMIGA - amiclosewin(); -#endif -} - - -static int curses_active = FALSE; - -extern int oldcurs; - -/* Send any required termination strings. Turn off "raw" mode. */ -void suspend_curses() -{ -#if ANY_UNIX && !(UNIXV || COH_386) - struct tchars tbuf; -# ifdef TIOCSLTC - struct ltchars ltbuf; -# endif -#endif -#ifndef NO_CURSORSHAPE - if (has_CQ) - { - do_CQ(); - oldcurs = 0; - } -#endif - if (has_TE) /* GB */ - { - do_TE(); - } - if (has_KE) - { - do_KE(); - } -#ifndef NO_COLOR - quitcolor(); -#endif - refresh(); - - /* change the terminal mode back the way it was */ -#if ANY_UNIX -# if (UNIXV || COH_386) -# ifdef TERMIOS - tcsetattr(2, TCSADRAIN, &oldtermio); -# else - ioctl(2, TCSETAW, &oldtermio); -# endif -# else - ioctl(2, TIOCSETP, &oldsgttyb); - - ioctl(2, TIOCGETC, (struct sgttyb *) &tbuf); - tbuf.t_intrc = oldint; - ioctl(2, TIOCSETC, (struct sgttyb *) &tbuf); - -# ifdef TIOCSLTC - ioctl(2, TIOCGLTC, <buf); - ltbuf.t_suspc = oldswitch; - ltbuf.t_dsuspc = olddswitch; - ltbuf.t_lnextc = oldquote; - ioctl(2, TIOCSLTC, <buf); -# endif -# endif -#endif -#if OSK - _ss_opt(0, &oldsgttyb); -#endif -#if AMIGA - ttyshutdown(); -#endif -#if MSDOS - raw_set_stdio(FALSE); -#endif - -#if VMS - VMS_read_raw = 0; -#endif - curses_active = FALSE; -} - - -/* put the terminal in RAW mode. If "quietly" is FALSE, then ask the user - * to hit a key, and wait for keystroke before returning. - */ -void resume_curses(quietly) - int quietly; -{ - if (!curses_active) - { - /* change the terminal mode to cbreak/noecho */ -#if ANY_UNIX -# if UNIXV || COH_386 - ospeed = (oldtermio.c_cflag & CBAUD); - ERASEKEY = oldtermio.c_cc[VERASE]; - newtermio = oldtermio; - newtermio.c_iflag &= (IXON|IXOFF|IXANY|ISTRIP|IGNBRK); - newtermio.c_oflag &= ~OPOST; - newtermio.c_lflag &= ISIG; - newtermio.c_cc[VINTR] = ctrl('C'); /* always use ^C for interrupts */ - newtermio.c_cc[VMIN] = 1; - newtermio.c_cc[VTIME] = 0; -# ifdef VSWTCH - newtermio.c_cc[VSWTCH] = 0; -# endif -# ifdef VSUSP - newtermio.c_cc[VSUSP] = 0; -# endif -# ifdef TERMIOS - tcsetattr(2, TCSADRAIN, &newtermio); -# else - ioctl(2, TCSETAW, &newtermio); -# endif -# else /* BSD, V7, Coherent-286, or Minix */ - struct tchars tbuf; -# ifdef TIOCSLTC - struct ltchars ltbuf; -# endif - - ospeed = oldsgttyb.sg_ospeed; - ERASEKEY = oldsgttyb.sg_erase; - newsgttyb = oldsgttyb; - newsgttyb.sg_flags |= CBREAK; - newsgttyb.sg_flags &= ~(CRMOD|ECHO|XTABS); - ioctl(2, TIOCSETP, &newsgttyb); - - ioctl(2, TIOCGETC, (struct sgttyb *) &tbuf); - oldint = tbuf.t_intrc; - tbuf.t_intrc = ctrl('C'); /* always use ^C for interrupts */ - ioctl(2, TIOCSETC, (struct sgttyb *) &tbuf); - -# ifdef TIOCSLTC - ioctl(2, TIOCGLTC, <buf); - oldswitch = ltbuf.t_suspc; - ltbuf.t_suspc = 0; /* disable ^Z for elvis */ - olddswitch = ltbuf.t_dsuspc; - ltbuf.t_dsuspc = 0; /* disable ^Y for elvis */ - oldquote = ltbuf.t_lnextc; - ltbuf.t_lnextc = 0; /* disable ^V for elvis */ - ioctl(2, TIOCSLTC, <buf); -# endif - -# endif -#endif -#if OSK - newsgttyb = oldsgttyb; - newsgttyb.sg_echo = 0; - newsgttyb.sg_eofch = 0; - newsgttyb.sg_kbach = 0; - newsgttyb.sg_kbich = ctrl('C'); - _ss_opt(0, &newsgttyb); - ospeed = oldsgttyb.sg_baud; - ERASEKEY = oldsgttyb.sg_bspch; -#endif -#if AMIGA - /* turn on window resize and RAW */ - ttysetup(); -#endif -#if MSDOS - raw_set_stdio(TRUE); -#endif - -#if VMS - VMS_read_raw = 1; - { int c; - read(0,&c,0); /* Flush the tty buffer. */ - } - ERASEKEY = '\177'; /* Accept as <^H> for VMS */ -#endif - - curses_active = TRUE; - } - - /* If we're supposed to quit quietly, then we're done */ - if (quietly) - { - if (has_TI) /* GB */ - { - do_TI(); - } - if (has_KS) - { - do_KS(); - } - - return; - } - - signal(SIGINT, SIG_IGN); - - move(LINES - 1, 0); - do_SO(); -#if VMS - qaddstr("\n[Press to continue]"); -#else - qaddstr("[Press to continue]"); -#endif - do_SE(); - refresh(); - ttyread(kbuf, 20, 0); /* in RAW mode, so <20 is very likely */ - if (has_TI) - { - do_TI(); - } - if (kbuf[0] == ':') - { - mode = MODE_COLON; - addch('\n'); - refresh(); - } - else - { - mode = MODE_VI; - redraw(MARK_UNSET, FALSE); - } - exwrote = FALSE; - - signal(SIGINT, trapint); -} - -/* This function fetches an optional string from termcap */ -static void mayhave(T, s) - char **T; /* where to store the returned pointer */ - char *s; /* name of the capability */ -{ - char *val; - - val = tgetstr(s, &capbuf); - if (val) - { - *T = val; - } -} - - -/* This function fetches a required string from termcap */ -static void musthave(T, s) - char **T; /* where to store the returned pointer */ - char *s; /* name of the capability */ -{ - mayhave(T, s); - if (!*T) - { - write(2, "This termcap entry lacks the :", (unsigned)30); - write(2, s, (unsigned)2); - write(2, "=: capability\n", (unsigned)14); -#if OSK - write(2, "\l", 1); -#endif - exit(2); - } -} - - -/* This function fetches a pair of strings from termcap. If one of them is - * missing, then the other one is ignored. - */ -static void pair(T, U, sT, sU) - char **T; /* where to store the first pointer */ - char **U; /* where to store the second pointer */ - char *sT; /* name of the first capability */ - char *sU; /* name of the second capability */ -{ - mayhave(T, sT); - mayhave(U, sU); - if (!**T || !**U) - { - *T = *U = ""; - } -} - - - -/* Read everything from termcap */ -static void starttcap(term) - char *term; -{ - static char cbmem[800]; - - /* allocate memory for capbuf */ - capbuf = cbmem; - - /* get the termcap entry */ - switch (tgetent(kbuf, term)) - { - case -1: - write(2, "Can't read /etc/termcap\n", (unsigned)24); -#if OSK - write(2, "\l", 1); -#endif - exit(2); - - case 0: - write(2, "Unrecognized TERM type\n", (unsigned)23); -#if OSK - write(2, "\l", 1); -#endif - exit(3); - } - - /* get strings */ - musthave(&UP, "up"); - mayhave(&VB, "vb"); - musthave(&CM, "cm"); - pair(&SO, &SE, "so", "se"); - mayhave(&TI, "ti"); - mayhave(&TE, "te"); - if (tgetnum("ug") <= 0) - { - pair(&US, &UE, "us", "ue"); - pair(&MD, &ME, "md", "me"); - - /* get italics, or have it default to underline */ - pair(&AS, &AE, "as", "ae"); - if (!*AS) - { - AS = US; - AE = UE; - } - } -#ifndef NO_VISIBLE - MV = SO; /* by default */ - mayhave(&MV, "mv"); -#endif - mayhave(&AL, "al"); - mayhave(&DL, "dl"); - musthave(&CE, "ce"); - mayhave(&CD, "cd"); -#if OSK - mayhave(&SR_, "sr"); -#else - mayhave(&SR, "sr"); -#endif - pair(&IM, &EI, "im", "ei"); - mayhave(&IC, "ic"); - mayhave(&DC, "dc"); - - /* other termcap stuff */ - AM = (tgetflag("am") && !tgetflag("xn")); - PT = tgetflag("pt"); -#if AMIGA - amiopenwin(termtype); /* Must run this before ttysetup(); */ - ttysetup(); /* Must run this before getsize(0); */ -#endif - getsize(0); - - /* Key sequences */ - pair(&KS, &KE, "ks", "ke"); /* keypad enable/disable */ - mayhave(&KU, "ku"); /* up */ - mayhave(&KD, "kd"); /* down */ - mayhave(&KR, "kr"); /* right */ - mayhave(&KL, "kl"); /* left */ - if (KL && KL[0]=='\b' && !KL[1]) - { - /* never use '\b' as a left arrow! */ - KL = (char *)0; - } - mayhave(&PU, "kP"); /* PgUp */ - mayhave(&PD, "kN"); /* PgDn */ - mayhave(&HM, "kh"); /* Home */ - mayhave(&EN, "kH"); /* End */ - mayhave(&KI, "kI"); /* Insert */ -#ifndef CRUNCH - if (!PU) mayhave(&PU, "K2"); /* "3x3 pad" names for PgUp, etc. */ - if (!PD) mayhave(&PD, "K5"); - if (!HM) mayhave(&HM, "K1"); - if (!EN) mayhave(&EN, "K4"); - - mayhave(&PU, "PU"); /* old XENIX names for PgUp, etc. */ - mayhave(&PD, "PD"); /* (overrides others, if used.) */ - mayhave(&HM, "HM"); - mayhave(&EN, "EN"); -#endif -#ifndef NO_FKEY - mayhave(&FKEY[0], "k0"); /* function key codes */ - mayhave(&FKEY[1], "k1"); - mayhave(&FKEY[2], "k2"); - mayhave(&FKEY[3], "k3"); - mayhave(&FKEY[4], "k4"); - mayhave(&FKEY[5], "k5"); - mayhave(&FKEY[6], "k6"); - mayhave(&FKEY[7], "k7"); - mayhave(&FKEY[8], "k8"); - mayhave(&FKEY[9], "k9"); -# ifndef NO_SHIFT_FKEY - mayhave(&FKEY[10], "s0"); /* shift function key codes */ - mayhave(&FKEY[11], "s1"); - mayhave(&FKEY[12], "s2"); - mayhave(&FKEY[13], "s3"); - mayhave(&FKEY[14], "s4"); - mayhave(&FKEY[15], "s5"); - mayhave(&FKEY[16], "s6"); - mayhave(&FKEY[17], "s7"); - mayhave(&FKEY[18], "s8"); - mayhave(&FKEY[19], "s9"); -# ifndef NO_CTRL_FKEY - mayhave(&FKEY[20], "c0"); /* control function key codes */ - mayhave(&FKEY[21], "c1"); - mayhave(&FKEY[22], "c2"); - mayhave(&FKEY[23], "c3"); - mayhave(&FKEY[24], "c4"); - mayhave(&FKEY[25], "c5"); - mayhave(&FKEY[26], "c6"); - mayhave(&FKEY[27], "c7"); - mayhave(&FKEY[28], "c8"); - mayhave(&FKEY[29], "c9"); -# ifndef NO_ALT_FKEY - mayhave(&FKEY[30], "a0"); /* alt function key codes */ - mayhave(&FKEY[31], "a1"); - mayhave(&FKEY[32], "a2"); - mayhave(&FKEY[33], "a3"); - mayhave(&FKEY[34], "a4"); - mayhave(&FKEY[35], "a5"); - mayhave(&FKEY[36], "a6"); - mayhave(&FKEY[37], "a7"); - mayhave(&FKEY[38], "a8"); - mayhave(&FKEY[39], "a9"); -# endif -# endif -# endif -#endif - -#ifndef NO_CURSORSHAPE - /* cursor shapes */ - CQ = tgetstr("cQ", &capbuf); - if (has_CQ) - { - CX = tgetstr("cX", &capbuf); - if (!CX) CX = CQ; - CV = tgetstr("cV", &capbuf); - if (!CV) CV = CQ; - CI = tgetstr("cI", &capbuf); - if (!CI) CI = CQ; - CR = tgetstr("cR", &capbuf); - if (!CR) CR = CQ; - } -# ifndef CRUNCH - else - { - CQ = CV = ""; - pair(&CQ, &CV, "ve", "vs"); - CX = CI = CR = CQ; - } -# endif /* !CRUNCH */ -#endif /* !NO_CURSORSHAPE */ - -#ifndef NO_COLOR - strcpy(SOcolor, SO); - strcpy(SEcolor, SE); - strcpy(AScolor, AS); - strcpy(AEcolor, AE); - strcpy(MDcolor, MD); - strcpy(MEcolor, ME); - strcpy(UScolor, US); - strcpy(UEcolor, UE); -# ifndef NO_POPUP - strcpy(POPUPcolor, SO); -# endif -# ifndef NO_VISIBLE - strcpy(VISIBLEcolor, MV); -# endif -#endif - -} - - -/* This function gets the window size. It uses the TIOCGWINSZ ioctl call if - * your system has it, or tgetnum("li") and tgetnum("co") if it doesn't. - * This function is called once during initialization, and thereafter it is - * called whenever the SIGWINCH signal is sent to this process. - */ -int getsize(signo) - int signo; -{ - int lines; - int cols; -#ifdef TIOCGWINSZ - struct winsize size; -#endif - -#ifdef SIGWINCH - /* reset the signal vector */ - signal(SIGWINCH, (void *)getsize); -#endif - - /* get the window size, one way or another. */ - lines = cols = 0; -#ifdef TIOCGWINSZ - if (ioctl(2, TIOCGWINSZ, &size) >= 0) - { - lines = size.ws_row; - cols = size.ws_col; - } -#endif -#if AMIGA - /* Amiga gets window size by asking the console.device */ - if (!strcmp(TERMTYPE, termtype)) - { - auto long len; - auto char buf[30]; - - Write(Output(), "\2330 q", 4); /* Ask the console.device */ - len = Read(Input(), buf, 29); - buf[len] = '\000'; - sscanf(&buf[5], "%d;%d", &lines, &cols); - } -#endif - if ((lines == 0 || cols == 0) && signo == 0) - { - LINES = tgetnum("li"); - COLS = tgetnum("co"); - } -#if MSDOS -# ifdef RAINBOW - if (!strcmp(termtype, "rainbow")) - { - /* Determine whether Rainbow is in 80-column or 132-column mode */ - cols = *(unsigned char far *)0xee000f57L; - } - else -# endif - { - lines = v_rows(); - cols = v_cols(); - } -#endif - if (lines >= 2 && cols >= 30) - { - LINES = lines; - COLS = cols; - } - - /* Make sure we got values that we can live with */ - if (LINES < 2 || COLS < 30) - { - write(2, "Screen too small\n", (unsigned)17); -#if OSK - write(2, "\l", 1); -#endif - endwin(); - exit(2); - } - -#if AMIGA - if (*o_lines != LINES || *o_columns != COLS) - { - *o_lines = LINES; - *o_columns = COLS; - } -#endif - - return 0; -} - - -/* This is a function version of addch() -- it is used by tputs() */ -int faddch(ch) - int ch; -{ - addch(ch); - - return 0; -} - -/* This function quickly adds a string to the output queue. It does *NOT* - * convert \n into . - */ -void qaddstr(str) - char *str; -{ - REG char *s_, *d_; - -#if MSDOS - if (o_pcbios[0]) - { - while (*str) - qaddch(*str++); - return; - } -#endif - for (s_=(str), d_=stdscr; *d_++ = *s_++; ) - { - } - stdscr = d_ - 1; -} - -/* Output the ESC sequence needed to go into any video mode, if supported */ -void attrset(a) - int a; -{ - do_aend(); - if (a == A_BOLD) - { - do_MD(); - aend = ME; - } - else if (a == A_UNDERLINE) - { - do_US(); - aend = UE; - } - else if (a == A_ALTCHARSET) - { - do_AS(); - aend = AE; - } - else - { - aend = ""; - } -} - - -/* Insert a single character into the display */ -void insch(ch) - int ch; -{ - if (has_IM) - do_IM(); - do_IC(); - qaddch(ch); - if (has_EI) - do_EI(); -} - -void wrefresh() -{ - if (stdscr != kbuf) - { - VOIDBIOS(;,ttywrite(kbuf, (unsigned)(stdscr - kbuf))); - stdscr = kbuf; - } -} - -void wqrefresh() -{ - if (stdscr - kbuf > 2000) - { - VOIDBIOS(stdscr = kbuf, - { - ttywrite(kbuf, (unsigned)(stdscr - kbuf)); - stdscr = kbuf; - }); - } -} - -#ifndef NO_COLOR -/* This function is called during termination. It resets color modes */ -int ansiquit() -{ - /* if ANSI terminal & colors were set, then reset the colors */ - if (!strcmp(UP, "\033[A") && strcmp(SOcolor, SO)) - { - tputs("\033[37;40m\033[m", 1, faddch); - clrtoeol(); - return 1; - } - return 0; -} - -/* This sets the color strings that work for ANSI terminals. If the TERMCAP - * doesn't look like an ANSI terminal, then it returns FALSE. If the colors - * aren't understood, it also returns FALSE. If all goes well, it returns TRUE - */ -int ansicolor(cmode, attrbyte) - int cmode; /* mode to set, e.g. A_NORMAL */ - int attrbyte; /* IBM PC attribute byte */ -{ - char temp[24]; /* hold the new mode string */ - - /* if not ANSI-ish, then fail */ - if (strcmp(UP, "\033[A") && strcmp(UP, "\033OA")) - { - /* Only give an error message if we're editing a file. - * (I.e., if we're *NOT* currently doing a ".exrc") - */ - if (tmpfd >= 0) - msg("Don't know how to set colors for this terminal"); - return FALSE; - } - - /* construct the color string */ -#ifdef MWC /* either Coherent-286 ("COHERENT"), or Coherent-386 ("M_SYSV") */ - sprintf(temp, "\033[m\033[3%cm\033[4%cm%s%s", - "04261537"[attrbyte & 0x07], - "04261537"[(attrbyte >> 4) & 0x07], - (attrbyte & 0x08) ? "\033[1m" : "", - (attrbyte & 0x80) ? "\033[5m" : ""); -#else - sprintf(temp, "\033[m\033[3%c;4%c%s%sm", - "04261537"[attrbyte & 0x07], - "04261537"[(attrbyte >> 4) & 0x07], - (attrbyte & 0x08) ? ";1" : "", - (attrbyte & 0x80) ? ";5" : ""); -#endif - - /* stick it in the right place */ - switch (cmode) - { - case A_NORMAL: - if (!strcmp(MEcolor, normalcolor)) - strcpy(MEcolor, temp); - if (!strcmp(UEcolor, normalcolor)) - strcpy(UEcolor, temp); - if (!strcmp(AEcolor, normalcolor)) - strcpy(AEcolor, temp); - if (!strcmp(SEcolor, normalcolor)) - strcpy(SEcolor, temp); - - strcpy(normalcolor, temp); - tputs(normalcolor, 1, faddch); - break; - - case A_BOLD: - strcpy(MDcolor, temp); - strcpy(MEcolor, normalcolor); - break; - - case A_UNDERLINE: - strcpy(UScolor, temp); - strcpy(UEcolor, normalcolor); - break; - - case A_ALTCHARSET: - strcpy(AScolor, temp); - strcpy(AEcolor, normalcolor); - break; - - case A_STANDOUT: - strcpy(SOcolor, temp); - strcpy(SEcolor, normalcolor); - break; - -#ifndef NO_POPUP - case A_POPUP: - strcpy(POPUPcolor, temp); - break; -#endif - -#ifndef NO_VISIBLE - case A_VISIBLE: - strcpy(VISIBLEcolor, temp); - break; -#endif - } - - return TRUE; -} - - -/* This function outputs the ESC sequence needed to switch the screen back - * to "normal" mode. On color terminals which haven't had their color set - * yet, this is one of the termcap strings; for color terminals that really - * have had colors defined, we just the "normal color" escape sequence. - */ -int -endcolor() -{ - if (aend == ME) - tputs(MEcolor, 1, faddch); - else if (aend == UE) - tputs(UEcolor, 1, faddch); - else if (aend == AE) - tputs(AEcolor, 1, faddch); - else if (aend == SE) - tputs(SEcolor, 1, faddch); - aend = ""; - return 0; -} - - -#endif /* !NO_COLOR */ diff --git a/usr.bin/elvis/curses.h b/usr.bin/elvis/curses.h deleted file mode 100644 index ec8e158c58c1..000000000000 --- a/usr.bin/elvis/curses.h +++ /dev/null @@ -1,321 +0,0 @@ -/* curses.h */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - * - * $Id: curses.h,v 1.2 1993/08/02 17:53:50 mycroft Exp $ - */ - - -/* This is the header file for a small, fast, fake curses package */ - -/* termcap stuff */ -extern char *tgoto(); -extern char *tgetstr(); -extern void tputs(); - -#if MSDOS -/* BIOS interface used instead of termcap for MS-DOS */ -extern int vmode; -extern void v_up(); -extern void v_cb(); -extern void v_cs(); -extern void v_ce(); -extern void v_cl(); -extern void v_cd(); -extern void v_al(); -extern void v_dl(); -extern void v_sr(); -extern void v_move(); -#endif - -/* faddch() is a function. a pointer to it is passed to tputs() */ -extern int faddch(); - -/* data types */ -#define WINDOW char - -/* CONSTANTS & SYMBOLS */ -#define TRUE 1 -#define FALSE 0 -#define A_NORMAL 0 -#define A_STANDOUT 1 -#define A_BOLD 2 -#define A_UNDERLINE 3 -#define A_ALTCHARSET 4 -#define A_POPUP 5 -#define A_VISIBLE 6 -#define KBSIZ 4096 - -/* figure out how many function keys we need to allow. */ -#ifndef NO_FKEY -# ifdef NO_SHIFT_FKEY -# define NFKEYS 10 -# else -# ifdef NO_CTRL_FKEY -# define NFKEYS 20 -# else -# ifdef NO_ALT_FKEY -# define NFKEYS 30 -# else -# define NFKEYS 40 -# endif -# endif -# endif -extern char *FKEY[NFKEYS]; /* :k0=:...:k9=: codes sent by function keys */ -#endif - -/* extern variables, defined in curses.c */ -extern char *termtype; /* name of terminal entry */ -extern short ospeed; /* tty speed, eg B2400 */ -#if OSK -extern char PC_; /* Pad char */ -extern char *BC; /* Backspace char string */ -#else -extern char PC; /* Pad char */ -#endif -extern WINDOW *stdscr; /* pointer into kbuf[] */ -extern WINDOW kbuf[KBSIZ]; /* a very large output buffer */ -extern int LINES; /* :li#: number of rows */ -extern int COLS; /* :co#: number of columns */ -extern int AM; /* :am: boolean: auto margins? */ -extern int PT; /* :pt: boolean: physical tabs? */ -extern char *VB; /* :vb=: visible bell */ -extern char *UP; /* :up=: move cursor up */ -extern char *SO; /* :so=: standout start */ -extern char *SE; /* :se=: standout end */ -extern char *US; /* :us=: underline start */ -extern char *UE; /* :ue=: underline end */ -extern char *MD; /* :md=: bold start */ -extern char *ME; /* :me=: bold end */ -extern char *AS; /* :as=: alternate (italic) start */ -extern char *AE; /* :ae=: alternate (italic) end */ -#ifndef NO_VISIBLE -extern char *MV; /* :mv=: "visible" selection start */ -#endif -extern char *CM; /* :cm=: cursor movement */ -extern char *CE; /* :ce=: clear to end of line */ -extern char *CD; /* :cd=: clear to end of screen */ -extern char *AL; /* :al=: add a line */ -extern char *DL; /* :dl=: delete a line */ -#if OSK -extern char *SR_; /* :sr=: scroll reverse */ -#else -extern char *SR; /* :sr=: scroll reverse */ -#endif -extern char *KS; /* :ks=: init string for cursor */ -extern char *KE; /* :ke=: restore string for cursor */ -extern char *KU; /* :ku=: sequence sent by up key */ -extern char *KD; /* :kd=: sequence sent by down key */ -extern char *KL; /* :kl=: sequence sent by left key */ -extern char *KR; /* :kr=: sequence sent by right key */ -extern char *PU; /* :PU=: key sequence sent by PgUp key */ -extern char *PD; /* :PD=: key sequence sent by PgDn key */ -extern char *HM; /* :HM=: key sequence sent by Home key */ -extern char *EN; /* :EN=: key sequence sent by End key */ -extern char *KI; /* :kI=: key sequence sent by Insert key */ -extern char *IM; /* :im=: insert mode start */ -extern char *IC; /* :ic=: insert following char */ -extern char *EI; /* :ei=: insert mode end */ -extern char *DC; /* :dc=: delete a character */ -extern char *TI; /* :ti=: terminal init */ /* GB */ -extern char *TE; /* :te=: terminal exit */ /* GB */ -#ifndef NO_CURSORSHAPE -extern char *CQ; /* :cQ=: normal cursor */ -extern char *CX; /* :cX=: cursor used for EX command/entry */ -extern char *CV; /* :cV=: cursor used for VI command mode */ -extern char *CI; /* :cI=: cursor used for VI input mode */ -extern char *CR; /* :cR=: cursor used for VI replace mode */ -#endif -extern char *aend; /* end an attribute -- either UE or ME */ -extern char ERASEKEY; /* taken from the ioctl structure */ -#ifndef NO_COLOR -extern char SOcolor[]; -extern char SEcolor[]; -extern char UScolor[]; -extern char UEcolor[]; -extern char MDcolor[]; -extern char MEcolor[]; -extern char AScolor[]; -extern char AEcolor[]; -# ifndef NO_POPUP -extern char POPUPcolor[]; -# endif -# ifndef NO_VISIBLE -extern char VISIBLEcolor[]; -# endif -extern char normalcolor[]; -#endif /* undef NO_COLOR */ - -/* Msdos-versions may use bios; others always termcap. - * Will emit some 'code has no effect' warnings in unix. - */ - -#if MSDOS -extern char o_pcbios[1]; /* BAH! */ -#define CHECKBIOS(x,y) (*o_pcbios ? (x) : (y)) -#define VOIDBIOS(x,y) {if (*o_pcbios) {x;} else {y;}} -#else -#define CHECKBIOS(x,y) (y) -#define VOIDBIOS(x,y) {y;} -#endif - -#ifndef NO_COLOR -# define setcolor(m,a) CHECKBIOS(bioscolor(m,a), ansicolor(m,a)) -# define fixcolor() VOIDBIOS(;, tputs(normalcolor, 1, faddch)) -# define quitcolor() CHECKBIOS(biosquit(), ansiquit()) -# define do_SO() VOIDBIOS((vmode=A_STANDOUT), tputs(SOcolor, 1, faddch)) -# define do_SE() VOIDBIOS((vmode=A_NORMAL), tputs(SEcolor, 1, faddch)) -# define do_US() VOIDBIOS((vmode=A_UNDERLINE), tputs(UScolor, 1, faddch)) -# define do_UE() VOIDBIOS((vmode=A_NORMAL), tputs(UEcolor, 1, faddch)) -# define do_MD() VOIDBIOS((vmode=A_BOLD), tputs(MDcolor, 1, faddch)) -# define do_ME() VOIDBIOS((vmode=A_NORMAL), tputs(MEcolor, 1, faddch)) -# define do_AS() VOIDBIOS((vmode=A_ALTCHARSET), tputs(AScolor, 1, faddch)) -# define do_AE() VOIDBIOS((vmode=A_NORMAL), tputs(AEcolor, 1, faddch)) -# define do_POPUP() VOIDBIOS((vmode=A_POPUP), tputs(POPUPcolor, 1, faddch)) -# define do_VISIBLE() VOIDBIOS((vmode=A_VISIBLE), tputs(VISIBLEcolor, 1, faddch)) -#else -# define do_SO() VOIDBIOS((vmode=A_STANDOUT), tputs(SO, 1, faddch)) -# define do_SE() VOIDBIOS((vmode=A_NORMAL), tputs(SE, 1, faddch)) -# define do_US() VOIDBIOS((vmode=A_UNDERLINE), tputs(US, 1, faddch)) -# define do_UE() VOIDBIOS((vmode=A_NORMAL), tputs(UE, 1, faddch)) -# define do_MD() VOIDBIOS((vmode=A_BOLD), tputs(MD, 1, faddch)) -# define do_ME() VOIDBIOS((vmode=A_NORMAL), tputs(ME, 1, faddch)) -# define do_AS() VOIDBIOS((vmode=A_ALTCHARSET), tputs(AS, 1, faddch)) -# define do_AE() VOIDBIOS((vmode=A_NORMAL), tputs(AE, 1, faddch)) -# define do_POPUP() VOIDBIOS((vmode=A_POPUP), tputs(SO, 1, faddch)) -# define do_VISIBLE() VOIDBIOS((vmode=A_VISIBLE), tputs(MV, 1, faddch)) -#endif - -#define do_VB() VOIDBIOS(;, tputs(VB, 1, faddch)) -#define do_UP() VOIDBIOS(v_up(), tputs(UP, 1, faddch)) -#undef do_CM /* move */ -#define do_CE() VOIDBIOS(v_ce(), tputs(CE, 1, faddch)) -#define do_CD() VOIDBIOS(v_cd(), tputs(CD, 1, faddch)) -#define do_AL() VOIDBIOS(v_al(), tputs(AL, LINES, faddch)) -#define do_DL() VOIDBIOS(v_dl(), tputs(DL, LINES, faddch)) -#if OSK -#define do_SR() VOIDBIOS(v_sr(), tputs(SR_, 1, faddch)) -#else -#define do_SR() VOIDBIOS(v_sr(), tputs(SR, 1, faddch)) -#endif -#define do_KS() VOIDBIOS(1, tputs(KS, 1, faddch)) -#define do_KE() VOIDBIOS(1, tputs(KE, 1, faddch)) -#define do_IM() VOIDBIOS(;, tputs(IM, 1, faddch)) -#define do_IC() VOIDBIOS(;, tputs(IC, 1, faddch)) -#define do_EI() VOIDBIOS(;, tputs(EI, 1, faddch)) -#define do_DC() VOIDBIOS(;, tputs(DC, COLS, faddch)) -#define do_TI() VOIDBIOS(;, (void)ttywrite(TI, (unsigned)strlen(TI))) -#define do_TE() VOIDBIOS(;, (void)ttywrite(TE, (unsigned)strlen(TE))) -#ifndef NO_CURSORSHAPE -# define do_CQ() VOIDBIOS(v_cs(), tputs(CQ, 1, faddch)) -# define do_CX() VOIDBIOS(v_cs(), tputs(CX, 1, faddch)) -# define do_CV() VOIDBIOS(v_cs(), tputs(CV, 1, faddch)) -# define do_CI() VOIDBIOS(v_cb(), tputs(CI, 1, faddch)) -# define do_CR() VOIDBIOS(v_cb(), tputs(CR, 1, faddch)) -#endif -#ifndef NO_COLOR -# define do_aend() VOIDBIOS((vmode=A_NORMAL), endcolor()) -#else -# define do_aend() VOIDBIOS((vmode=A_NORMAL), tputs(aend, 1, faddch)) -#endif - -#define has_AM CHECKBIOS(1, AM) -#define has_PT CHECKBIOS(0, PT) -#define has_VB CHECKBIOS((char *)0, VB) -#define has_UP CHECKBIOS((char *)1, UP) -#define has_SO CHECKBIOS((char)1, (*SO)) -#define has_SE CHECKBIOS((char)1, (*SE)) -#define has_US CHECKBIOS((char)1, (*US)) -#define has_UE CHECKBIOS((char)1, (*UE)) -#define has_MD CHECKBIOS((char)1, (*MD)) -#define has_ME CHECKBIOS((char)1, (*ME)) -#define has_AS CHECKBIOS((char)1, (*AS)) -#define has_AE CHECKBIOS((char)1, (*AE)) -#undef has_CM /* cursor move: don't need */ -#define has_CB CHECKBIOS(1, 0) -#define has_CS CHECKBIOS(1, 0) -#define has_CE CHECKBIOS((char *)1, CE) -#define has_CD CHECKBIOS((char *)1, CD) -#define has_AL CHECKBIOS((char *)1, AL) -#define has_DL CHECKBIOS((char *)1, DL) -#if OSK -#define has_SR CHECKBIOS((char *)1, SR_) -#else -#define has_SR CHECKBIOS((char *)1, SR) -#endif -#define has_KS CHECKBIOS((char)1, (*KS)) -#define has_KE CHECKBIOS((char)1, (*KE)) -#define has_KU KU -#define has_KD KD -#define has_KL KL -#define has_KR KR -#define has_HM HM -#define has_EN EN -#define has_PU PU -#define has_PD PD -#define has_KI KI -#define has_IM CHECKBIOS((char)0, (*IM)) -#define has_IC CHECKBIOS((char)0, (*IC)) -#define has_EI CHECKBIOS((char)0, (*EI)) -#define has_DC CHECKBIOS((char *)0, DC) -#define has_TI CHECKBIOS((char)0, (*TI)) -#define has_TE CHECKBIOS((char)0, (*TE)) -#ifndef NO_CURSORSHAPE -#define has_CQ CHECKBIOS((char *)1, CQ) -#endif - -/* (pseudo)-Curses-functions */ - -#ifdef lint -# define _addCR VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : (stdscr[-1] = '\n'))) -#else -# if OSK -# define _addCR VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\l') : (stdscr[-1] = stdscr[-1]))) -# else -# define _addCR VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : 0)) -# endif -#endif - -#ifdef AZTEC_C -# define qaddch(ch) CHECKBIOS(v_put(ch), (*stdscr = (ch), *stdscr++)) -#else -#define qaddch(ch) CHECKBIOS(v_put(ch), (*stdscr++ = (ch))) -#endif - -#if OSK -#define addch(ch) if (qaddch(ch) == '\n') qaddch('\l'); else -#else -#define addch(ch) if (qaddch(ch) == '\n') qaddch('\r'); else -#endif - -extern void initscr(); -extern void endwin(); -extern void suspend_curses(); -extern void resume_curses(); -extern void attrset(); -extern void insch(); -extern void qaddstr(); -extern void wrefresh(); -extern void wqrefresh(); -#define addstr(str) {qaddstr(str); _addCR;} -#define move(y,x) VOIDBIOS(v_move(x,y), tputs(tgoto(CM, x, y), 1, faddch)) -#define mvaddch(y,x,ch) {move(y,x); addch(ch);} -#define refresh() VOIDBIOS(;, wrefresh()) -#define standout() do_SO() -#define standend() do_SE() -#define clrtoeol() do_CE() -#define clrtobot() do_CD() -#define insertln() do_AL() -#define deleteln() do_DL() -#define delch() do_DC() -#define scrollok(w,b) -#define raw() -#define echo() -#define cbreak() -#define noraw() -#define noecho() -#define nocbreak() diff --git a/usr.bin/elvis/cut.c b/usr.bin/elvis/cut.c deleted file mode 100644 index e0fa6add664d..000000000000 --- a/usr.bin/elvis/cut.c +++ /dev/null @@ -1,705 +0,0 @@ -/* cut.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains function which manipulate the cut buffers. */ - -#ifndef lint -static char rcsid[] = "$Id: cut.c,v 1.3 1993/08/02 17:53:51 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" -#if TURBOC -#include /* needed for getpid */ -#endif -#if TOS -#include -#define rename(a,b) Frename(0,a,b) -#endif - -# define NANONS 9 /* number of anonymous buffers */ - -static struct cutbuf -{ - short *phys; /* pointer to an array of #s of BLKs containing text */ - int nblks; /* number of blocks in phys[] array */ - int start; /* offset into first block of start of cut */ - int end; /* offset into last block of end of cut */ - int tmpnum; /* ID number of the temp file */ - char lnmode; /* boolean: line-mode cut? (as opposed to char-mode) */ -} - named[27], /* cut buffers "a through "z and ". */ - anon[NANONS]; /* anonymous cut buffers */ - -static char cbname; /* name chosen for next cut/paste operation */ -static char dotcb; /* cut buffer to use if "doingdot" is set */ - - -#ifndef NO_RECYCLE -/* This function builds a list of all blocks needed in the current tmp file - * for the contents of cut buffers. - * !!! WARNING: if you have more than ~450000 bytes of text in all of the - * cut buffers, then this will fail disastrously, because buffer overflow - * is *not* allowed for. - */ -int cutneeds(need) - BLK *need; /* this is where we deposit the list */ -{ - struct cutbuf *cb; /* used to count through cut buffers */ - int i; /* used to count through blocks of a cut buffer */ - int n; /* total number of blocks in list */ - - n = 0; - - /* first the named buffers... */ - for (cb = named; cb < &named[27]; cb++) - { - if (cb->tmpnum != tmpnum) - continue; - - for (i = cb->nblks; i-- > 0; ) - { - need->n[n++] = cb->phys[i]; - } - } - - /* then the anonymous buffers */ - for (cb = anon; cb < &anon[NANONS]; cb++) - { - if (cb->tmpnum != tmpnum) - continue; - - for (i = cb->nblks; i-- > 0; ) - { - need->n[n++] = cb->phys[i]; - } - } - - /* return the length of the list */ - return n; -} -#endif - -static void maybezap(num) - int num; /* the tmpnum of the temporary file to [maybe] delete */ -{ - char cutfname[80]; - int i; - - /* if this is the current tmp file, then we'd better keep it! */ - if (tmpfd >= 0 && num == tmpnum) - { - return; - } - - /* see if anybody else needs this tmp file */ - for (i = 27; --i >= 0; ) - { - if (named[i].nblks > 0 && named[i].tmpnum == num) - { - break; - } - } - if (i < 0) - { - for (i = NANONS; --i >= 0 ; ) - { - if (anon[i].nblks > 0 && anon[i].tmpnum == num) - { - break; - } - } - } - - /* if nobody else needs it, then discard the tmp file */ - if (i < 0) - { -#if MSDOS || TOS - strcpy(cutfname, o_directory); - if ((i = strlen(cutfname)) && !strchr(":/\\", cutfname[i - 1])) - cutfname[i++] = SLASH; - sprintf(cutfname + i, TMPNAME + 3, getpid(), num); -#else - sprintf(cutfname, TMPNAME, o_directory, getpid(), num); -#endif - unlink(cutfname); - } -} - -/* This function frees a cut buffer. If it was the last cut buffer that - * refered to an old temp file, then it will delete the temp file. */ -static void cutfree(buf) - struct cutbuf *buf; -{ - int num; - - /* return immediately if the buffer is already empty */ - if (buf->nblks <= 0) - { - return; - } - - /* else free up stuff */ - num = buf->tmpnum; - buf->nblks = 0; -#ifdef DEBUG - if (!buf->phys) - msg("cutfree() tried to free a NULL buf->phys pointer."); - else -#endif - _free_((char *)buf->phys); - - /* maybe delete the temp file */ - maybezap(num); -} - -/* This function is called when we are about to abort a tmp file. - * - * To minimize the number of extra files lying around, only named cut buffers - * are preserved in a file switch; the anonymous buffers just go away. - */ -void cutswitch() -{ - int i; - - /* mark the current temp file as being "obsolete", and close it. */ - storename((char *)0); - close(tmpfd); - tmpfd = -1; - - /* discard all anonymous cut buffers */ - for (i = 0; i < NANONS; i++) - { - cutfree(&anon[i]); - } - - /* delete the temp file, if we don't really need it */ - maybezap(tmpnum); -} - -/* This function should be called just before termination of vi */ -void cutend() -{ - int i; - - /* free the anonymous buffers, if they aren't already free */ - cutswitch(); - - /* free all named cut buffers, since they might be forcing an older - * tmp file to be retained. - */ - for (i = 0; i < 27; i++) - { - cutfree(&named[i]); - } - - /* delete the temp file */ - maybezap(tmpnum); -} - - -/* This function is used to select the cut buffer to be used next */ -void cutname(name) - int name; /* a single character */ -{ - cbname = name; -} - - - - -/* This function copies a selected segment of text to a cut buffer */ -void cut(from, to) - MARK from; /* start of text to cut */ - MARK to; /* end of text to cut */ -{ - int first; /* logical number of first block in cut */ - int last; /* logical number of last block used in cut */ - long line; /* a line number */ - int lnmode; /* boolean: will this be a line-mode cut? */ - MARK delthru;/* end of text temporarily inserted for apnd */ - REG struct cutbuf *cb; - REG long l; - REG int i; - REG char *scan; - char *blkc; - - /* detect whether this must be a line-mode cut or char-mode cut */ - if (markidx(from) == 0 && markidx(to) == 0) - lnmode = TRUE; - else - lnmode = FALSE; - - /* by default, we don't "delthru" anything */ - delthru = MARK_UNSET; - - /* handle the "doingdot" quirks */ - if (doingdot) - { - if (!cbname) - { - cbname = dotcb; - } - } - else if (cbname != '.') - { - dotcb = cbname; - } - - /* decide which cut buffer to use */ - if (!cbname) - { - /* free up the last anonymous cut buffer */ - cutfree(&anon[NANONS - 1]); - - /* shift the anonymous cut buffers */ - for (i = NANONS - 1; i > 0; i--) - { - anon[i] = anon[i - 1]; - } - - /* use the first anonymous cut buffer */ - cb = anon; - cb->nblks = 0; - } - else if (cbname >= 'a' && cbname <= 'z') - { - cb = &named[cbname - 'a']; - cutfree(cb); - } -#ifndef CRUNCH - else if (cbname >= 'A' && cbname <= 'Z') - { - cb = &named[cbname - 'A']; - if (cb->nblks > 0) - { - /* resolve linemode/charmode differences */ - if (!lnmode && cb->lnmode) - { - from &= ~(BLKSIZE - 1); - if (markidx(to) != 0 || to == from) - { - to = to + BLKSIZE - markidx(to); - } - lnmode = TRUE; - } - - /* insert the old cut-buffer before the new text */ - mark[28] = to; - delthru = paste(from, FALSE, TRUE); - if (delthru == MARK_UNSET) - { - return; - } - delthru++; - to = mark[28]; - } - cutfree(cb); - } -#endif /* not CRUNCH */ - else if (cbname == '.') - { - cb = &named[26]; - cutfree(cb); - } - else - { - msg("Invalid cut buffer name: \"%c", cbname); - dotcb = cbname = '\0'; - return; - } - cbname = '\0'; - cb->tmpnum = tmpnum; - - /* detect whether we're doing a line mode cut */ - cb->lnmode = lnmode; - - /* ---------- */ - - /* Reporting... */ - if (markidx(from) == 0 && markidx(to) == 0) - { - rptlines = markline(to) - markline(from); - rptlabel = "yanked"; - } - - /* ---------- */ - - /* make sure each block has a physical disk address */ - blksync(); - - /* find the first block in the cut */ - line = markline(from); - for (first = 1; line > lnum[first]; first++) - { - } - - /* fetch text of the block containing that line */ - blkc = scan = blkget(first)->c; - - /* find the mark in the block */ - for (l = lnum[first - 1]; ++l < line; ) - { - while (*scan++ != '\n') - { - } - } - scan += markidx(from); - - /* remember the offset of the start */ - cb->start = scan - blkc; - - /* ---------- */ - - /* find the last block in the cut */ - line = markline(to); - for (last = first; line > lnum[last]; last++) - { - } - - /* fetch text of the block containing that line */ - if (last != first) - { - blkc = scan = blkget(last)->c; - } - else - { - scan = blkc; - } - - /* find the mark in the block */ - for (l = lnum[last - 1]; ++l < line; ) - { - while (*scan++ != '\n') - { - } - } - if (markline(to) <= nlines) - { - scan += markidx(to); - } - - /* remember the offset of the end */ - cb->end = scan - blkc; - - /* ------- */ - - /* remember the physical block numbers of all included blocks */ - cb->nblks = last - first; - if (cb->end > 0) - { - cb->nblks++; - } -#ifdef lint - cb->phys = (short *)0; -#else - cb->phys = (short *)malloc((unsigned)(cb->nblks * sizeof(short))); -#endif - for (i = 0; i < cb->nblks; i++) - { - cb->phys[i] = hdr.n[first++]; - } - -#ifndef CRUNCH - /* if we temporarily inserted text for appending, then delete that - * text now -- before the user sees it. - */ - if (delthru) - { - line = rptlines; - delete(from, delthru); - rptlines = line; - rptlabel = "yanked"; - } -#endif /* not CRUNCH */ -} - - -static void readcutblk(cb, blkno) - struct cutbuf *cb; - int blkno; -{ - char cutfname[50];/* name of an old temp file */ - int fd; /* either tmpfd or the result of open() */ -#if MSDOS || TOS - int i; -#endif - - /* decide which fd to use */ - if (cb->tmpnum == tmpnum) - { - fd = tmpfd; - } - else - { -#if MSDOS || TOS - strcpy(cutfname, o_directory); - if ((i = strlen(cutfname)) && !strchr(":/\\", cutfname[i-1])) - cutfname[i++]=SLASH; - sprintf(cutfname+i, TMPNAME+3, getpid(), cb->tmpnum); -#else - sprintf(cutfname, TMPNAME, o_directory, getpid(), cb->tmpnum); -#endif - fd = open(cutfname, O_RDONLY); - } - - /* get the block */ - lseek(fd, (long)cb->phys[blkno] * (long)BLKSIZE, 0); - if (read(fd, tmpblk.c, (unsigned)BLKSIZE) != BLKSIZE) - { - msg("Error reading back from tmp file for pasting!"); - } - - /* close the fd, if it isn't tmpfd */ - if (fd != tmpfd) - { - close(fd); - } -} - - -/* This function inserts text from a cut buffer, and returns the MARK where - * insertion ended. Return MARK_UNSET on errors. - */ -MARK paste(at, after, retend) - MARK at; /* where to insert the text */ - int after; /* boolean: insert after mark? (rather than before) */ - int retend; /* boolean: return end of text? (rather than start) */ -{ - REG struct cutbuf *cb; - REG int i; - - /* handle the "doingdot" quirks */ - if (doingdot) - { - if (!cbname) - { - if (dotcb >= '1' && dotcb < '1' + NANONS - 1) - { - dotcb++; - } - cbname = dotcb; - } - } - else if (cbname != '.') - { - dotcb = cbname; - } - - /* decide which cut buffer to use */ - if (cbname >= 'A' && cbname <= 'Z') - { - cb = &named[cbname - 'A']; - } - else if (cbname >= 'a' && cbname <= 'z') - { - cb = &named[cbname - 'a']; - } - else if (cbname >= '1' && cbname <= '9') - { - cb = &anon[cbname - '1']; - } - else if (cbname == '.') - { - cb = &named[26]; - } - else if (!cbname) - { - cb = anon; - } - else - { - msg("Invalid cut buffer name: \"%c", cbname); - cbname = '\0'; - return MARK_UNSET; - } - - /* make sure it isn't empty */ - if (cb->nblks == 0) - { - if (cbname) - msg("Cut buffer \"%c is empty", cbname); - else - msg("Cut buffer is empty"); - cbname = '\0'; - return MARK_UNSET; - } - cbname = '\0'; - - /* adjust the insertion MARK for "after" and line-mode cuts */ - if (cb->lnmode) - { - at &= ~(BLKSIZE - 1); - if (after) - { - at += BLKSIZE; - } - } - else if (after) - { - /* careful! if markidx(at) == 0 we might be pasting into an - * empty line -- so we can't blindly increment "at". - */ - if (markidx(at) == 0) - { - pfetch(markline(at)); - if (plen != 0) - { - at++; - } - } - else - { - at++; - } - } - - /* put a copy of the "at" mark in the mark[] array, so it stays in - * sync with changes made via add(). - */ - mark[27] = at; - - /* simple one-block paste? */ - if (cb->nblks == 1) - { - /* get the block */ - readcutblk(cb, 0); - - /* isolate the text we need within it */ - if (cb->end) - { - tmpblk.c[cb->end] = '\0'; - } - - /* insert it */ - ChangeText - { - add(at, &tmpblk.c[cb->start]); - } - } - else - { - /* multi-block paste */ - - ChangeText - { - i = cb->nblks - 1; - - /* add text from the last block first */ - if (cb->end > 0) - { - readcutblk(cb, i); - tmpblk.c[cb->end] = '\0'; - add(at, tmpblk.c); - i--; - } - - /* add intervening blocks */ - while (i > 0) - { - readcutblk(cb, i); - add(at, tmpblk.c); - i--; - } - - /* add text from the first cut block */ - readcutblk(cb, 0); - add(at, &tmpblk.c[cb->start]); - } - } - - /* Reporting... */ - rptlines = markline(mark[27]) - markline(at); - rptlabel = "pasted"; - - /* return the mark at the beginning/end of inserted text */ - if (retend) - { - return mark[27] - 1L; - } - return at; -} - - - - -#ifndef NO_AT - -/* This function copies characters from a cut buffer into a string. - * It returns the number of characters in the cut buffer. If the cut - * buffer is too large to fit in the string (i.e. if cb2str() returns - * a number >= size) then the characters will not have been copied. - * It returns 0 if the cut buffer is empty, and -1 for invalid cut buffers. - */ -int cb2str(name, buf, size) - int name; /* the name of a cut-buffer to get: a-z only! */ - char *buf; /* where to put the string */ - unsigned size; /* size of buf */ -{ - REG struct cutbuf *cb; - REG char *src; - REG char *dest; - - /* decide which cut buffer to use */ - if (name >= 'a' && name <= 'z') - { - cb = &named[name - 'a']; - } - else - { - return -1; - } - - /* if the buffer is empty, return 0 */ - if (cb->nblks == 0) - { - return 0; - } - - /* !!! if not a single-block cut, then fail */ - if (cb->nblks != 1) - { - return size; - } - - /* if too big, return the size now, without doing anything */ - if ((unsigned)(cb->end - cb->start) >= size) - { - return cb->end - cb->start; - } - - /* get the block */ - readcutblk(cb, 0); - - /* isolate the string within that blk */ - if (cb->start == 0) - { - tmpblk.c[cb->end] = '\0'; - } - else - { - for (dest = tmpblk.c, src = dest + cb->start; src < tmpblk.c + cb->end; ) - { - *dest++ = *src++; - } - *dest = '\0'; - } - - /* copy the string into the buffer */ - if (buf != tmpblk.c) - { - strcpy(buf, tmpblk.c); - } - - /* return the length */ - return cb->end - cb->start; -} -#endif diff --git a/usr.bin/elvis/doc/elvis.man b/usr.bin/elvis/doc/elvis.man deleted file mode 100644 index 8d10b78a44db..000000000000 --- a/usr.bin/elvis/doc/elvis.man +++ /dev/null @@ -1,149 +0,0 @@ -.TH ELVIS 1 -.SH NAME -elvis, ex, vi, view, input - The editor -.SH SYNOPSIS -\fBelvis\fP [\fIflags\fP] [\fB+\fP\fIcmd\fP] [\fIfiles\fP...] -.SH DESCRIPTION -\fIElvis\fP is a text editor which emulates \fIvi\fP/\fIex\fP. -.PP -On systems which pass the program name as an argument, such as Unix and Minix, -you may also install \fIelvis\fP under the names "ex", "vi", "view", and "input". -These extra names would normally be links to elvis; -see the "ln" shell command. -.PP -When \fIelvis\fP is invoked as "vi", -it behaves exactly as though it was invoked as "elvis". -However, if you invoke \fIelvis\fP as "view", -then the readonly option is set as though you had given it the "-R" flag. -If you invoke \fIelvis\fP as "ex", -then \fIelvis\fP will start up in the colon command mode -instead of the visual command mode, -as though you had given it the "-e" flag. -If you invoke \fIelvis\fP as "input" or "edit", -then \fIelvis\fP will start up in input mode, -as though the "-i" flag was given. -.SH OPTIONS -.IP \fB-r\fP -To the real vi, this flag means that a previous edit should be recovered. -\fIElvis\fP, though, has a separate program, called \fIelvrec(1)\fP, for recovering -files. -When you invoke \fIelvis\fP with -r, \fIelvis\fP will tell you to run \fIelvrec\fP. -.IP \fB-R\fP -This sets the "readonly" option, -so you won't accidentally overwrite a file. -.IP "\fB-t\fP \fItag\fP" -This causes \fIelvis\fP to start editing at the given tag. -.IP "\fB-m\fP [\fIfile\fP]" -\fIElvis\fP will search through \fIfile\fP for something that looks like -an error message from a compiler. -It will then begin editing the source file that caused the error, -with the cursor sitting on the line where the error was detected. -If you don't explicitly name a \fIfile\fP, then "errlist" is assumed. -.IP \fB-e\fP -\fIElvis\fP will start up in colon command mode. -.IP \fB-v\fP -\fIElvis\fP will start up in visual command mode. -.IP \fB-i\fP -\fIElvis\fP will start up in input mode. -.IP "\fB-w\fR \fIwinsize\fR" -Sets the "window" option's value to \fIwinsize\fR. -.IP "\fB+\fP\fIcommand\fP or \fB-c\fP \fIcommand\fP" -If you use the +\fIcommand\fP parameter, -then after the first file is loaded -\fIcommand\fP is executed as an EX command. -A typical example would be "elvis +237 foo", -which would cause \fIelvis\fP to start editing foo and -then move directly to line 237. -The "-c \fIcommand\fP" variant was added for UNIX SysV compatibility. -.SH FILES -.IP /tmp/elv* -During editing, -\fIelvis\fP stores text in a temporary file. -For UNIX, this file will usually be stored in the /tmp directory, -and the first three characters will be "elv". -For other systems, the temporary files may be stored someplace else; -see the version-specific section of the documentation. -.IP tags -This is the database used by the \fI:tags\fP command and the \fB-t\fP option. -It is usually created by the \fIctags(1)\fP program. -.IP ".exrc or elvis.rc" -On UNIX-like systems, a file called ".exrc" in your home directory -is executed as a series of \fIex\fR commands. -A file by the same name may be executed in the current directory, too. -On non-UNIX systems, ".exrc" is usually an invalid file name; -there, the initialization file is called "elvis.rc" instead. -.SH ENVIRONMENT -.IP TERM -This is the name of your terminal's entry in the termcap or terminfo -database. -The list of legal values varies from one system to another. -.IP TERMCAP -Optional. -If your system uses termcap, and the TERMCAP variable is unset, then -\*E will read your terminal's definition from \fB/etc/termcap\fR. -If TERMCAP is set to the full pathname of a file (starting with a '/') -then \*E will look in the named file instead of \fB/etc/termcap\fR. -If TERMCAP is set to a value which doesn't start with a '/', -then its value is assumed to be the full termcap entry for your terminal. -.IP TERMINFO -Optional. -If your system uses terminfo, and the TERMINFO variable is unset, then -\*E will read your terminal's definition from the database in the -\fB/usr/lib/terminfo\fR database. -If TERMINFO is set, then its value is used as the database name to use -instead of \fB/usr/lib/terminfo\fR. -.IP "LINES, COLUMNS" -Optional. -These variables, if set, will override the screen size values given in -the termcap/terminfo for your terminal. -On windowing systems such as X, \*E has other ways of determining the -screen size, so you should probably leave these variables unset. -.IP EXINIT -Optional. -This variable can hold EX commands which will be executed before any .exrc -files. -.IP SHELL -Optional. -The SHELL variable sets the default value for the "shell" option, -which determines which shell program is used to perform wildcard -expansion in file names, and also which is used to execute filters -or external programs. -The default value on UNIX systems is "/bin/sh". -.IP -Note: Under MS-DOS, this variable is called COMSPEC instead of SHELL. -.IP HOME -This variable should be set to the name of your home directory. -\*E looks for its initialization file there; -if HOME is unset then the initialization file will not be executed. -.IP TAGPATH -Optional. -This variable is used by the "ref" program, which is invoked by the shift-K, -control-], and :tag commands. -See "ref" for more information. -.IP "TMP, TEMP" -These optional environment variables are only used in non-UNIX versions -of \*E. -They allow you to supply a directory name to be used for storing temporary files. -.SH "SEE ALSO" -ctags(1), ref(1), virec(1) -.PP -\fIElvis - A Clone of Vi/Ex\fP, the complete \fIelvis\fP documentation. -.SH BUGS -There is no LISP support. -Certain other features are missing, too. -.PP -Auto-indent mode is not quite compatible with the real vi. -Among other things, 0^D and ^^D don't do what you might expect. -.PP -Long lines are displayed differently. -The real vi wraps long lines onto multiple rows of the screen, -but \fIelvis\fP scrolls sideways. -.SH AUTHOR -.nf -Steve Kirkendall -kirkenda@cs.pdx.edu -.fi -.PP -Many other people have worked to port \fIelvis\fP to various operating systems. -To see who deserves credit, run the \fI:version\fP command from within \fIelvis\fP, -or look in the system-specific section of the complete documentation. diff --git a/usr.bin/elvis/doc/elvprsv.man b/usr.bin/elvis/doc/elvprsv.man deleted file mode 100644 index 065fb2b12093..000000000000 --- a/usr.bin/elvis/doc/elvprsv.man +++ /dev/null @@ -1,54 +0,0 @@ -.TH ELVPRSV 1 -.SH NAME -elvprsv - Preserve the the modified version of a file after a crash. -.SH SYNOPSIS -.nf -\fB\fBelvprsv\fP ["-\fIwhy elvis died\fP"] /tmp/\fIfilename\fP... -\fB\fBelvprsv\fP -R /tmp/\fIfilename\fP... -.fi -.SH DESCRIPTION -.PP -\fIelvprsv\fP preserves your edited text after \fIelvis\fP dies. -The text can be recovered later, via the \fIelvprsv\fP program. -.PP -For UNIX-like systems, -you should never need to run this program from the command line. -It is run automatically when \fIelvis\fP is about to die, -and it should be run (via /etc/rc) when the computer is booted. -THAT'S ALL! -.PP -For non-UNIX systems such as MS-DOS, you can either use \fIelvprsv\fP -the same way as under UNIX systems (by running it from your AUTOEXEC.BAT file), -or you can run it separately with the "-R" flag to recover the files -in one step. -.PP -If you're editing a file when \fIelvis\fP dies -(due to a bug, system crash, power failure, etc.) -then \fIelvprsv\fP will preserve the most recent version of your text. -The preserved text is stored in a special directory; it does NOT overwrite -your text file automatically. -.PP -\fIelvprsv\fP will send mail to any user whose work it preserves, -if your operating system normally supports mail. -.SH FILES -.IP /tmp/elv* -The temporary file that \fIelvis\fP was using when it died. -.IP /usr/preserve/p* -The text that is preserved by \fIelvprsv\fP. -.IP /usr/preserve/Index -A text file which lists the names of all preserved files, and the names -of the /usr/preserve/p* files which contain their preserved text. -.SH BUGS -.PP -Due to the permissions on the /usr/preserve directory, on UNIX systems -\fIelvprsv\fP must be run as superuser. -This is accomplished by making the \fIelvprsv\fP executable be owned by "root" -and turning on its "set user id" bit. -.PP -If you're editing a nameless buffer when \fIelvis\fP dies, then \fIelvprsv\fP will pretend -that the file was named "foo". -.SH AUTHOR -.nf -Steve Kirkendall -kirkenda@cs.pdx.edu -.fi diff --git a/usr.bin/elvis/doc/elvrec.man b/usr.bin/elvis/doc/elvrec.man deleted file mode 100644 index b541c2ed14d1..000000000000 --- a/usr.bin/elvis/doc/elvrec.man +++ /dev/null @@ -1,47 +0,0 @@ -.TH ELVREC 1 -.SH NAME -elvrec - Recover the modified version of a file after a crash -.SH SYNOPSIS -.nf -\fBelvrec\fP [\fIpreservedfile\fP [\fInewfile\fR]] -.fi -.SH DESCRIPTION -.PP -If you're editing a file when \fIelvis\fP dies, the system crashes, or power fails, -the most recent version of your text will be preserved. -The preserved text is stored in a special directory; it does NOT overwrite -your text file automatically. -.PP -The \fIelvrec\fP program locates the preserved version of a given file, -and writes it over the top of your text file -- or to a new file, if you prefer. -The recovered file will have nearly all of your changes. -.PP -To see a list of all recoverable files, run \fIelvrec\fP with no arguments. -.SH FILES -.IP /usr/preserve/p* -The text that was preserved when \fIelvis\fP died. -.IP /usr/preserve/Index -A text file which lists the names of all preserved files, and the names -of the /usr/preserve/p* files which contain their preserved text. -.SH BUGS -.PP -\fIelvrec\fP is very picky about filenames. -You must tell it to recover the file using exactly the same pathname as -when you were editing it. -The simplest way to do this is to go into the same directory that you were -editing, and invoke \fIelvrec\fP with the same filename as \fIelvis\fP. -If that doesn't work, then try running \fIelvrec\fP with no arguments, -to see exactly which pathname it is using for the desired file. -.PP -Due to the permissions on the /usr/preserve directory, on UNIX systems -\fIelvrec\fP must be run as superuser. -This is accomplished by making the \fIelvrec\fP executable be owned by "root" -and setting its "set user id" bit. -.PP -If you're editing a nameless buffer when \fIelvis\fP dies, then \fIelvrec\fP -will pretend that the file was named "foo". -.SH AUTHOR -.nf -Steve Kirkendall -kirkenda@cs.pdx.edu -.fi diff --git a/usr.bin/elvis/doc/environ.ms b/usr.bin/elvis/doc/environ.ms deleted file mode 100644 index 6c97f51ea17f..000000000000 --- a/usr.bin/elvis/doc/environ.ms +++ /dev/null @@ -1,60 +0,0 @@ -.Go 12 "ENVIRONMENT VARIABLES" -.PP -\*E examines several environment variables when it starts up. -The values of these variables are used internally for a variety -of purposes. -You don't need to define all of these; -on most systems, \*E only requires TERM to be defined. -On AmigaDOS, MS-DOS or TOS systems, even that is optional. -.IP "TERM, TERMCAP" -TERM tells \*E the name of the termcap entry to use. -TERMCAP may contain either the entire termcap entry, -or the full pathname of the termcap file to search through. -.IP -If your version of \*E is using tinytcap instead of the full termcap library, -then the value of TERMCAP can't be the name of a file; it can only be undefined, -or contain the entire termcap entry. -In the termcap entry, tinytcap will convert \\E to an character, -but other backslash escapes (\\b, \\r, etc.) or carat escapes (^[, ^M, etc.) -will not be converted to control characters. -Instead, you should embed the actual control character into the string. -.IP "TMP, TEMP" -These only work for AmigaDOS, MS-DOS and Atari TOS. -Either of these variables may be used to set the "directory" option, -which controls where temporary files are stored. -If you define them both, then TMP is used, and TEMP is ignored. -.IP "LINES, COLUMNS" -The termcap entry for your terminal should specify the size of your screen. -If you're using a windowing interface, then there is an ioctl() call which -will provide the size of the window; the ioctl() values will override the -values in the termcap entry. -The LINES and COLUMNS environment variables (if defined) -will override either of these sources. -They, in turn, can be overridden by a ":set" command. -.IP -Normally, the LINES and COLUMNS variables shouldn't need to be defined. -.IP EXINIT -This variable's value may contain one or more colon-mode commands, -which will be executed after all of the ".exrc" files -but before interactive editing begins. -.IP -To put more than one command in EXINIT, you can separate the commands -with either a newline or a '|' character. -.IP "SHELL, COMSPEC" -You can use COMSPEC in MS-DOS, or SHELL in any other system, -to specify which shell should be used for executing commands and -expanding wildcards. -.IP HOME -This variable should give the full pathname of your home directory. -\*E needs to know the name of your home directory so it can locate -the ".exrc" file there. -.IP TAGPATH -This variable is used by the "ref" program. -It contains a list of directories that might contain a relevent "tags" file. -Under AmigaDOS, MS-DOS or Atari TOS, the names of the directories should be separated by -semicolons (";"). -Under other operating systems, the names should be separated by colons (":"). -.IP -If you don't define TAGPATH, then "ref" will use a default list which includes -the current directory and a few other likely places. -See the definition of DEFTAGPATH at the start of ref.c for an accurate list. diff --git a/usr.bin/elvis/doc/ex.ms b/usr.bin/elvis/doc/ex.ms deleted file mode 100644 index 1d97697e08ed..000000000000 --- a/usr.bin/elvis/doc/ex.ms +++ /dev/null @@ -1,524 +0,0 @@ -.Go 3 "COLON MODE COMMANDS" -.ID -.ps -.in 0.8i -.ta 2i 3.i -.\" NOTE: The following macro is used to output a single line of the -.\" command chart. Its usage is: -.\" -.\" .Cm ... -.\" -.de Cm -.if "\\$1"0" \t\\$2\t\\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.if "\\$1"1" \s'-2'[line]\s'+2'\t\\$2\t\\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.if "\\$1"2" \s'-2'[line][,line]\s'+2'\t\\$2\t\\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 -.. -.if t .ds Q `` -.if t .ds U '' -.if n .ds Q " -.if n .ds U " -\s'+2'LINES COMMAND ARGUMENTS\s'-2' -.Cm 0 ab[br] [short] [expanded form] -.Cm 1 a[ppend][!] -.Cm 0 ar[gs] [files] -.Cm 0 cc [files] -.Cm 0 cd[!] [directory] -.Cm 2 c[hange] -.Cm 0 chd[ir][!] [directory] -.Cm 2 co[py] line -.Cm 0 col[or] [when] [[\*Qlight\*U] color] [\*Qon\*U color] -.Cm 2 d[elete] [\*Ux] -.Cm 0 dig[raph][!] [XX [Y]] -.Cm 0 e[dit][!] [file] -.Cm 0 er[rlist][!] [errlist] -.Cm 0 f[ile] [file] -.Cm 2 g[lobal] /regexp/ command -.Cm 1 i[nsert] -.Cm 2 j[oin][!] -.Cm 2 l[ist] -.Cm 0 mak[e] [target] -.Cm 0 map[!] key mapped_to -.Cm 1 ma[rk] \*Ux -.Cm 0 mk[exrc] -.Cm 2 m[ove] line -.Cm 0 n[ext][!] [files] -.Cm 0 N[ext][!] -.Cm 2 nu[mber] -.Cm 2 p[rint] -.Cm 1 pu[t] [\*Ux] -.Cm 0 q[uit][!] -.Cm 1 r[ead] file -.Cm 0 rew[ind][!] -.Cm 0 se[t] [options] -.Cm 0 so[urce] file -.Cm 2 s[ubstitute] /regexp/replacement/[p][g][c] -.Cm 0 ta[g][!] tagname -.Cm 0 una[bbr] [short] -.Cm 0 u[ndo] -.Cm 0 unm[ap][!] key -.Cm 0 ve[rsion] -.Cm 2 v[global] /regexp/ command -.Cm 0 vi[sual] [filename] -.Cm 0 wq -.Cm 2 w[rite][!] [[>>]file] -.Cm 0 x[it][!] -.Cm 2 y[ank] [\*Ux] -.Cm 2 ! command -.Cm 2 < -.Cm 2 = -.Cm 2 > -.Cm 2 & -.Cm 0 @ "" \*Ux -.DE -.TA -.PP -To use colon mode commands, you must switch from visual command -mode to colon command mode. -The visual mode commands to do this are ":" for a single colon command, -or "Q" for many colon mode commands. -.NH 2 -Line Specifiers -.PP -Line specifiers are always optional. -The first line specifier of most commands usually defaults to the current line. -The second line specifier usually defaults to be the same -as the first line specifier. -Exceptions are :write, :global, and :vglobal, which act on all lines of the -file by default, and :!, which acts on no lines by default. -.PP -Line specifiers consist of an absolute part and a relative part. -The absolute part of a line specifier may be either an explicit line number, -a mark, a dot to denote the current line, a dollar sign to denote the last -line of the file, or a forward or backward search. -.PP -An explicit line number is simply a decimal number, expressed as a -string of digits. -.PP -A mark is typed in as an apostrophe followed by a letter. -Marks must be set before they can be used. -You can set a mark in visual command mode by typing "m" and a letter, -or you can set it in colon command mode via the "mark" command. -.PP -A forward search is typed in as a regular expression surrounded by -slash characters; searching begins at the default line. -A backward search is typed in as a regular expression surrounded by -question marks; searching begins at the line before the default line. -.PP -If you omit the absolute part, then the default line is used. -.PP -The relative part of a line specifier is typed as a "+" or "-" character -followed by a decimal number. -The number is added to or subtracted from the absolute part -of the line specifier to produce the final line number. -.PP -As a special case, the % character may be used to specify all lines of the file. -It is roughly equivelent to saying 1,$. -This can be a handy shortcut. -.PP -Some examples: -.LD -.ps -.ta 0.5i 1.8i - :p print the current line - :37p print line 37 - :'gp print the line which contains mark g - :/foo/p print the next line that contains "foo" - :$p print the last line of the file - :20,30p print lines 20 through 30 - :1,$p print all lines of the file - :%p print all lines of the file - :/foo/-2,+4p print 5 lines around the next "foo" -.TA -.DE -.NH 2 -Text Entry Commands -.if n .ul 0 -.ID -.ps -[line] append -[line][,line] change ["x] -[line] insert -.DE -.PP -The \fBa\fRppend command inserts text after the specified line. -.PP -The \fBi\fRnsert command inserts text before the specified line. -.PP -The \fBc\fRhange command copies the range of lines into a cut buffer, -deletes them, and inserts new text where the old text used to be. -.PP -For all of these commands, you indicate the end of the text you're -inserting by hitting ^D or by entering a line which contains only a -period. -.NH 2 -Cut & Paste Commands -.if n .ul 0 -.ID -.ps -[line][,line] delete ["x] -[line][,line] yank ["x] -[line] put ["x] -[line][,line] copy line -[line][,line] to line -[line][,line] move line -.DE -.PP -The \fBd\fRelete command copies the specified range of lines into a -cut buffer, and then deletes them. -.PP -The \fBy\fRank command copies the specified range of lines into a cut -buffer, but does *not* delete them. -.PP -The \fBpu\fRt command inserts text from a cut buffer after the -specified line. -.PP -The \fBco\fRpy and \fBt\fRo commands yank the specified range of lines and -then immediately paste them after some other line. -.PP -The \fBm\fRove command deletes the specified range of lines and then -immediately pastes them after some other line. -If the destination line comes after the deleted text, -then it will be adjusted automatically to account for the deleted lines. -.NH 2 -Display Text Commands -.if n .ul 0 -.ID -.ps -[line][,line] print -[line][,line] list -[line][,line] number -.DE -.PP -The \fBp\fRrint command displays the specified range of lines. -.PP -The \fBnu\fRmber command displays the lines, with line numbers. -.PP -The \fBl\fRist command also displays them, but it is careful to make -control characters visible. -.NH 2 -Global Operations Commands -.if n .ul 0 -.ID -.ps -[line][,line] global /regexp/ command -[line][,line] vglobal /regexp/ command -.DE -.PP -The \fBg\fRlobal command searches through the lines of the specified range -(or through the whole file if no range is specified) -for lines that contain a given regular expression. -It then moves the cursor to each of these lines and -runs some other command on them. -.PP -The \fBv\fRglobal command is similar, but it searches for lines that \fIdon't\fR -contain the regular expression. -.NH 2 -Line Editing Commands -.if n .ul 0 -.ID -.ps -[line][,line] join[!] -[line][,line] ! program -[line][,line] < -[line][,line] > -[line][,line] substitute /regexp/replacement/[p][g][c] -[line][,line] & -.DE -.PP -The \fBj\fRoin command catenates all lines in the specified range together -to form one big line. -If only a single line is specified, then the following line is catenated -onto it. -The normal ":join" inserts one or two spaces between the lines; -the ":join!" variation (with a '!') doesn't insert spaces. -.PP -The \fB!\fR command runs an external filter program, -and feeds the specified range of lines to it's stdin. -The lines are then replaced by the output of the filter. -A typical example would be ":'a,'z!sort" to sort the lines 'a,'z. -.PP -The \fB<\fR and \fB>\fR commands shift the specified range of lines left or right, -normally by the width of 1 tab character. -The "shiftwidth" option determines the shifting amount. -.PP -The \fBs\fRubstitute command finds the regular expression in each line, -and replaces it with the replacement text. -The "p" option causes the altered lines to be printed. -The "g" option permits all instances of the regular expression -to be found & replaced. -(Without "g", only the first occurrence in each line is replaced.) -The "c" option asks for confirmation before each substitution. -.PP -The \fB&\fR command repeats the previous substitution command. -Actually, "&" is equivelent to "s//~/" with the same options as last time. -It searches for the last regular expression that you specified for any purpose, -and replaces it with the the same text -that was used in the previous substitution. -.NH 2 -Undo Command -.if n .ul 0 -.ID -.ps -undo -.DE -.PP -The \fBu\fRndo command restores the file to the state it was in before -your most recent command which changed text. -.NH 2 -Configuration & Status Commands -.if n .ul 0 -.ID -.ps -map[!] [key mapped_to] -unmap[!] key -abbr [word expanded_form_of_word] -unabbr word -digraph[!] [XX [Y]] -set [options] -mkexrc -[line] mark "x -visual -version -[line][,line] = -file [file] -source file -@ "x -color [when] [["light"] color] ["on" color] -.DE -.PP -The \fBma\fRp command allows you to configure \*E to recognize your function keys, -and treat them as though they transmitted some other sequence of characters. -Normally this mapping is done only when in the visual command mode, -but with the [!] present it will map keys under input and replace modes as well. -When this command is given with no arguments, -it prints a table showing all mappings currently in effect. -When called with two arguments, the first is the sequence that your -function key really sends, and the second is the sequence that you want -\*E to treat it as having sent. -As a special case, if the first argument is a number then \*E will map the -corresponding function key; -for example, ":map 7 dd" will cause the key to delete a line. -.PP -The \fBunm\fRap command removes key definitions that were made via the map command. -.PP -The \fBab\fRbr command is used to define/list a table of abbreviations. -The table contains both the abbreviated form and the fully spelled-out form. -When you're in visual input mode, and you type in the abbreviated form, -\*E will replace the abbreviated form with the fully spelled-out form. -When this command is called without arguments, it lists the table; -with two or more arguments, the first argument is taken as the abbreviated -form, and the rest of the command line is the fully-spelled out form. -.PP -The \fBuna\fRbbr command deletes entries from the abbr table. -.PP -The \fBdi\fRgraph command allows you to display the set of digraphs that \*E is -using, or add/remove a digraph. -To list the set of digraphs, use the digraph command with no arguments. -To add a digraph, you should give the digraph command two arguments. -The first argument is the two ASCII characters that are to be combined; -the second is the non-ASCII character that they represent. -The non-ASCII character's most significant bit is automatically set by the -digraph command, unless to append a ! to the command name. -Removal of a digraph is similar to adding a digraph, except that you should -leave off the second argument. -.PP -The \fBse\fRt command allows you examine or set various options. -With no arguments, it displays the values of options that have been changed. -With the single argument "all" it displays the values of all options, -regardless of whether they've been explicitly set or not. -Otherwise, the arguments are treated as options to be set. -.PP -The \fBmk\fRexrc command saves the current configuration to a file -called ".exrc" in the current directory. -.PP -The mar\fBk\fR command defines a named mark to refer to a specific place -in the file. -This mark may be used later to specify lines for other commands. -.PP -The \fBvi\fRsual command puts the editor into visual mode. -Instead of emulating ex, \*E will start emulating vi. -.PP -The \fBve\fRrsion command tells you that what version of \*E this is. -.PP -The \fB=\fR command tells you what line you specified, or, -if you specified a range of lines, it will tell you both endpoints and -the number of lines included in the range. -.PP -The \fBf\fRile command tells you the name of the file, -whether it has been modified, -the number of lines in the file, -and the current line number. -You can also use it to change the name of the current file. -.PP -The \fBso\fRurce command reads a sequence of colon mode commands from a file, -and interprets them. -.PP -The \fB@\fR command executes the contents of a cut-buffer as EX commands. -.PP -The \fBcol\fRor command only works under MS-DOS, or if you have an ANSI-compatible -color terminal. -It allows you to set the foreground and background colors -for different types of text: -normal, bold, italic, underlined, standout, pop-up menu, and visible selection. -By default, it changes the "normal" colors; -to change other colors, the first argument to the :color command should be -the first letter of the type of text you want. -The syntax for the colors themselves is fairly intuitive. -For example, ":color light cyan on blue" causes normal text to be displayed -in light cyan on a blue background, and -":color b bright white" causes bold text to be displayed in bright white on -a blue background. -The background color always defaults to the current background color of -normal text. -Your first :color command \fImust\fP specify both the foreground and background -for normal text. -.NH 2 -Multiple File Commands -.if n .ul 0 -.ID -.ps -args [files] -next[!] [files] -Next[!] -previous[!] -rewind[!] -.DE -.PP -When you invoke \*E from your shell's command line, -any filenames that you give to \*E as arguments are stored in the args list. -The \fBar\fRgs command will display this list, or define a new one. -.PP -The \fBn\fRext command switches from the current file to the next one -in the args list. -You may specify a new args list here, too. -.PP -The \fBN\fRext and \fBpre\fRvious commands -(they're really aliases for the same command) -switch from the current file to the preceding file in the args list. -.PP -The \fBrew\fRind command switches from the current file to the first file -in the args list. -.NH 2 -Switching Files -.if n .ul 0 -.ID -.ps -edit[!] [file] -tag[!] tagname -.DE -.PP -The \fBe\fRdit command allows to switch from the current file to some other file. -This has nothing to do with the args list, by the way. -.PP -The \fBta\fRg command looks up a given tagname in a file called "tags". -This tells it which file the tag is in, and how to find it in that file. -\*E then switches to the tag's file and finds the tag. -.NH 2 -Working with a Compiler -.if n .ul 0 -.ID -.ps -cc [files] -make [target] -errlist[!] [errlist] -.DE -.PP -The \fBcc\fR and \fBmak\fRe commands execute your compiler or "make" utility -and redirect any error messages into a file called "errlist". -By default, cc is run on the current file. -(You should write it before running cc.) -The contents of the "errlist" file are then scanned for error messages. -If an error message is found, then the cursor is moved to the line where -the error was detected, -and the description of the error is displayed on the status line. -.PP -After you've fixed one error, the \fBer\fRrlist command will move -the cursor to the next error. -In visual command mode, -hitting `*' will do this, too. -.PP -You can also create an "errlist" file from outside of \*E, -and use "elvis -m" to start \*E and have the cursor moved to the -first error. -Note that you don't need to supply a filename with "elvis -m" because -the error messages always say which source file an error is in. -.PP -Note: -When you use errlist repeatedly to fix several errors in a single file, -it will attempt to adjust the reported line numbers to allow for lines -that you have inserted or deleted. -These adjustments are made with the assumption that you will work though -the file from the beginning to the end. -.NH 2 -Exit Commands -.if n .ul 0 -.ID -.ps -quit[!] -wq -xit -.DE -.PP -The \fBq\fRuit command exits from the editor without saving your file. -.PP -The \fBwq\fR command writes your file out, then then exits. -.PP -The \fBx\fRit command is similar to the \fBwq\fR command, except that -\fBx\fRit won't bother to write your file if you haven't modified it. -.NH 2 -File I/O Commands -.if n .ul 0 -.ID -.ps -[line] read file -[line][,line] write[!] [[>>]file] -.DE -.PP -The \fBr\fRead command gets text from another file and inserts it -after the specified line. -It can also read the output of a program; -simply precede the program name by a '!' and use it in place of the file name. -.PP -The \fBw\fRrite command writes the whole file, or just part of it, -to some other file. -The !, if present, will permit the lines to be written even if you've set -the readonly option. -If you precede the filename by >> then the lines will be appended to the file. -You can send the lines to the standard input of a program by replacing the -filename with a '!' followed by the command and its arguments. -.PP -Note: Be careful not to confuse ":w!filename" and ":w !command". -To write to a program, you must have at least one blank before the '!'. -.NH 2 -Directory Commands -.if n .ul 0 -.ID -.ps -cd [directory] -chdir [directory] -shell -.DE -.PP -The \fBcd\fR and \fBchd\fRir commands -(really two names for one command) -switch the current working directory. -.PP -The \fBsh\fRell command starts an interactive shell. -.NH 2 -Debugging Commands -.if n .ul 0 -.ID -.ps -[line][,line] debug[!] -validate[!] -.DE -.PP -These commands are only available if you compile \*E with the -DDEBUG flag. -.PP -The de\fBb\fRug command lists statistics for the blocks which contain -the specified range of lines. -If the ! is present, then the contents of those blocks is displayed, too. -.PP -The \fBva\fRlidate command checks certain variables for internal consistency. -Normally it doesn't output anything unless it detects a problem. -With the !, though, it will always produce *some* output. diff --git a/usr.bin/elvis/doc/fmt.man b/usr.bin/elvis/doc/fmt.man deleted file mode 100644 index 3c731faf5d3e..000000000000 --- a/usr.bin/elvis/doc/fmt.man +++ /dev/null @@ -1,26 +0,0 @@ -.TH FMT 1 -.SH NAME -fmt - adjust line-length for paragraphs of text -.SH SYNOPSIS -\fBfmt\fP [\-\fIwidth\fP] [\fIfiles\fP]... -.SH DESCRIPTION -\fIfmt\fR is a simple text formatter. -It inserts or deletes newlines, as necessary, to make all lines in a -paragraph be approximately the same width. -It preserves indentation and word spacing. -.PP -The default line width is 72 characters. -You can override this with the \-\fIwidth\fR flag. -If you don't name any files on the command line, -then \fIfmt\fR will read from stdin. -.PP -It is typically used from within \fIvi\fR to adjust the line breaks -in a single paragraph. -To do this, move the cursor to the top of the paragraph, -type "!}fmt", and -hit . -.SH AUTHOR -.nf -Steve Kirkendall -kirkenda@cs.pdx.edu -.fi diff --git a/usr.bin/elvis/doc/index.ms b/usr.bin/elvis/doc/index.ms deleted file mode 100644 index 0e4a9e23e6c4..000000000000 --- a/usr.bin/elvis/doc/index.ms +++ /dev/null @@ -1,78 +0,0 @@ -.XS 1 -INTRODUCTION -What \*E does, -Copyright, -How to compile \*E, -Overview -.XA 2 -VISUAL MODE COMMANDS -Normal interactive editing, -Input mode, -Arrow keys, -Digraphs, -Abbreviations, -Auto-indentation -.XA 3 -COLON MODE COMMANDS -Line specifiers, -Text entry, -Cut & paste, -Display text, -Global operations, -Line editing, -Undo, -Configuration & status, -Multiple files, -Switching files, -Working with a compiler, -Exiting, -File I/O, -Directory & shell, -Debugging -.XA 4 -REGULAR EXPRESSIONS -Syntax, -Options, -Substitutions, -Examples -.XA 5 -OPTIONS -Autoindent, -Autoprint, -etc. -.XA 6 -CUT BUFFERS -Putting text into a cut buffer, -Pasting from a cut buffer, -Macros, -The effect of switching files -.XA 7 -DIFFERENCES BETWEEN \*E AND THE REAL VI/EX -Extensions, -Omissions -.XA 8 -INTERNAL -For programmers only, -The temporary file, -Implementation of editing, -Marks and the cursor, -Colon command interpretation, -Screen control, -Portability -.XA 9 -MAKEFILE -.XA 10 -CFLAGS -.XA 11 -TERMCAP -.XA 12 -ENVIRONMENT VARIABLES -.XA 13 -VERSIONS -.XA 14 -QUESTIONS & ANSWERS -.XE -.PX -.sp 0.3i -.ce 1 -UNIX-style "man" pages appear at the end of this manual. diff --git a/usr.bin/elvis/doc/internal.ms b/usr.bin/elvis/doc/internal.ms deleted file mode 100644 index e18960c62aac..000000000000 --- a/usr.bin/elvis/doc/internal.ms +++ /dev/null @@ -1,232 +0,0 @@ -.Go 8 "INTERNAL" -.PP -You don't need to know the material in this section to use \*E. -You only need it if you intend to modify \*E. -.PP -You should also check out the CFLAGS, TERMCAP, ENVIRONMENT VARIABLES, -VERSIONS, and QUIESTIONS & ANSWERS sections of this manual. -.NH 2 -The temporary file -.PP -The temporary file is divided into blocks of 1024 bytes each. -The functions in "blk.c" maintain a cache of the five most recently used blocks, -to minimize file I/O. -.PP -When \*E starts up, the file is copied into the temporary file -by the function \fBtmpstart()\fR in "tmp.c". -Small amounts of extra space are inserted into the temporary file to -insure that no text lines cross block boundaries. -This speeds up processing and simplifies storage management. -The extra space is filled with NUL characters. -the input file must not contain any NULs, to avoid confusion. -This also limits lines to a length of 1023 characters or less. -.PP -The data blocks aren't necessarily stored in sequence. -For example, it is entirely possible that the data block containing -the first lines of text will be stored after the block containing the -last lines of text. -.PP -In RAM, \*E maintains two lists: one that describes the "proper" -order of the disk blocks, and another that records the line number of -the last line in each block. -When \*E needs to fetch a given line of text, it uses these tables -to locate the data block which contains that line. -.PP -Before each change is made to the file, these lists are copied. -The copies can be used to "undo" the change. -Also, the first list --- the one that lists the data blocks in their proper order -- -is written to the first data block of the temp file. -This list can be used during file recovery. -.PP -When blocks are altered, they are rewritten to a \fIdifferent\fR block in the file, -and the order list is updated accordingly. -The original block is left intact, so that "undo" can be performed easily. -\*E will eventually reclaim the original block, when it is no longer needed. -.NH 2 -Implementation of Editing -.PP -There are three basic operations which affect text: -.ID -\(bu delete text - delete(from, to) -\(bu add text - add(at, text) -\(bu yank text - cut(from, to) -.DE -.PP -To yank text, all text between two text positions is copied into a cut buffer. -The original text is not changed. -To copy the text into a cut buffer, -you need only remember which physical blocks that contain the cut text, -the offset into the first block of the start of the cut, -the offset into the last block of the end of the cut, -and what kind of cut it was. -(Cuts may be either character cuts or line cuts; -the kind of a cut affects the way it is later "put".) -Yanking is implemented in the function \fBcut()\fR, -and pasting is implemented in the function \fBpaste()\fR. -These functions are defined in "cut.c". -.PP -To delete text, you must modify the first and last blocks, and -remove any reference to the intervening blocks in the header's list. -The text to be deleted is specified by two marks. -This is implemented in the function \fBdelete()\fR. -.PP -To add text, you must specify -the text to insert (as a NUL-terminated string) -and the place to insert it (as a mark). -The block into which the text is to be inserted may need to be split into -as many as four blocks, with new intervening blocks needed as well... -or it could be as simple as modifying a single block. -This is implemented in the function \fBadd()\fR. -.PP -There is also a \fBchange()\fR function, -which generally just calls delete() and add(). -For the special case where a single character is being replaced by another -single character, though, change() will optimize things somewhat. -The add(), delete(), and change() functions are all defined in "modify.c". -.PP -The \fBinput()\fR function reads text from a user and inserts it into the file. -It makes heavy use of the add(), delete(), and change() functions. -It inserts characters one at a time, as they are typed. -.PP -When text is modified, an internal file-revision counter, called \fBchanges\fR, -is incremented. -This counter is used to detect when certain caches are out of date. -(The "changes" counter is also incremented when we switch to a different file, -and also in one or two similar situations -- all related to invalidating caches.) -.NH 2 -Marks and the Cursor -.PP -Marks are places within the text. -They are represented internally as 32-bit values which are split -into two bitfields: -a line number and a character index. -Line numbers start with 1, and character indexes start with 0. -Lines can be up to 1023 characters long, so the character index is 10 bits -wide and the line number fills the remaining 22 bits in the long int. -.PP -Since line numbers start with 1, -it is impossible for a valid mark to have a value of 0L. -0L is therefore used to represent unset marks. -.PP -When you do the "delete text" change, any marks that were part of -the deleted text are unset, and any marks that were set to points -after it are adjusted. -Marks are adjusted similarly after new text is inserted. -.PP -The cursor is represented as a mark. -.NH 2 -Colon Command Interpretation -.PP -Colon commands are parsed, and the command name is looked up in an array -of structures which also contain a pointer to the function that implements -the command, and a description of the arguments that the command can take. -If the command is recognized and its arguments are legal, -then the function is called. -.PP -Each function performs its task; this may cause the cursor to be -moved to a different line, or whatever. -.NH 2 -Screen Control -.PP -In input mode or visual command mode, -the screen is redrawn by a function called \fBredraw()\fR. -This function is called in the getkey() function before each keystroke is -read in, if necessary. -.PP -Redraw() writes to the screen via a package which looks like the "curses" -library, but isn't. -It is actually much simpler. -Most curses operations are implemented as macros which copy characters -into a large I/O buffer, which is then written with a single large -write() call as part of the refresh() operation. -.PP -(Note: Under MS-DOS, the pseudo-curses macros check to see whether you're -using the pcbios interface. If you are, then the macros call functions -in "pc.c" to implement screen updates.) -.PP -The low-level functions which modify text (namely add(), delete(), and change()) -supply redraw() with clues to help redraw() decide which parts of the -screen must be redrawn. -The clues are given via a function called \fBredrawrange()\fR. -.PP -Most EX commands use the pseudo-curses package to perform their output, -like redraw(). -.PP -There is also a function called \fBmsg()\fR which uses the same syntax as printf(). -In EX mode, msg() writes message to the screen and automatically adds a -newline. -In VI mode, msg() writes the message on the bottom line of the screen -with the "standout" character attribute turned on. -.NH 2 -Options -.PP -For each option available through the ":set" command, -\*E contains a character array variable, named "o_\fIoption\fR". -For example, the "lines" option uses a variable called "o_lines". -.PP -For boolean options, the array has a dimension of 1. -The first (and only) character of the array will be NUL if the -variable's value is FALSE, and some other value if it is TRUE. -To check the value, just by dereference the array name, -as in "if (*o_autoindent)". -.PP -For number options, the array has a dimension of 3. -The array is treated as three unsigned one-byte integers. -The first byte is the current value of the option. -The second and third bytes are the lower and upper bounds of that -option. -.PP -For string options, the array usually has a dimension of about 60 -but this may vary. -The option's value is stored as a normal NUL-terminated string. -.PP -All of the options are declared in "opts.c". -Most are initialized to their default values; -the \fBinitopts()\fR function is used to perform any environment-specific -initialization. -.NH 2 -Portability -.PP -To improve portability, \*E collects as many of the system-dependent -definitions as possible into the "config.h" file. -This file begins with some preprocessor instructions which attempt to -determine which compiler and operating system you have. -After that, it conditionally defines some macros and constants for your system. -.PP -One of the more significant macros is \fBttyread()\fR. -This macro is used to read raw characters from the keyboard, possibly -with timeout. -For UNIX systems, this basically reads bytes from stdin. -For MSDOS, TOS, and OS9, ttyread() is a function defined in curses.c. -There is also a \fBttywrite()\fR macro. -.PP -The \fBtread()\fR and \fBtwrite()\fR macros are versions of read() and write() that are -used for text files. -On UNIX systems, these are equivelent to read() and write(). -On MS-DOS, these are also equivelent to read() and write(), -since DOS libraries are generally clever enough to convert newline characters -automatically. -For Atari TOS, though, the MWC library is too stupid to do this, -so we had to do the conversion explicitly. -.PP -Other macros may substitute index() for strchr(), or bcopy() for memcpy(), -or map the "void" data type to "int", or whatever. -.PP -The file "tinytcap.c" contains a set of functions that emulate the termcap -library for a small set of terminal types. -The terminal-specific info is hard-coded into this file. -It is only used for systems that don't support real termcap. -Another alternative for screen control can be seen in -the "curses.h" and "pc.c" files. -Here, macros named VOIDBIOS and CHECKBIOS are used to indirectly call -functions which perform low-level screen manipulation via BIOS calls. -.PP -The stat() function must be able to come up with UNIX-style major/minor/inode -numbers that uniquely identify a file or directory. -.PP -Please try to keep you changes localized, -and wrap them in #if/#endif pairs, -so that \*E can still be compiled on other systems. -And PLEASE let me know about it, so I can incorporate your changes into -my latest-and-greatest version of \*E. diff --git a/usr.bin/elvis/doc/intro.ms b/usr.bin/elvis/doc/intro.ms deleted file mode 100644 index f27822bbadd8..000000000000 --- a/usr.bin/elvis/doc/intro.ms +++ /dev/null @@ -1,53 +0,0 @@ -.Go 1 "INTRODUCTION" -.PP -\*E is a clone of vi/ex, the standard UNIX editor. -\*E supports nearly all of the vi/ex commands, -in both visual mode and colon mode. -.PP -Like vi/ex, \*E stores most of the text in a temporary file, instead of RAM. -This allows it to edit files that are too large to fit -in a single process' data space. -Also, the edit buffer can survive a power failure or crash. -.PP -\*E runs under BSD UNIX, AT&T SysV UNIX, Minix, MS-DOS, Atari TOS, -Coherent, OS9/68000, VMS and AmigaDos. -The next version is also expected to add MS-Windows, OS/2 and MacOS. -Contact me before you start porting it to some other OS, -because somebody else may have already done it for you. -.PP -\*E is freely redistributable, in either source form or executable form. -There are no restrictions on how you may use it. -.NH 2 -Compiling -.PP -See the "Versions" section of this manual for instructions on how to compile -\*E. -.PP -If you want to port \*E to another O.S. or compiler, then -you should start be reading the "Portability" part of the "Internal" section. -.NH 2 -Overview of \*E -.PP -The user interface of \*E/vi/ex is weird. -There are two major command modes in \*E, and a few text input modes as well. -Each command mode has a command which allows you to switch to the other mode. -.PP -You will probably use the \fIvisual command mode\fR -most of the time. -This is the mode that \*E normally starts up in. -.PP -In visual command mode, the entire screen is filled with lines of text -from your file. -Each keystroke is interpretted as part of a visual command. -If you start typing text, it will \fInot\fR be inserted, -it will be treated as part of a command. -To insert text, you must first give an "insert text" command. -This will take some getting used to. -(An alternative exists. -Lookup the "inputmode" option.) -.PP -The \fIcolon mode\fR is quite different. -\*E displays a ":" character on the bottom line of the screen, as a prompt. -You are then expected to type in a command line and hit the key. -The set of commands recognized in the colon mode is different -from visual mode's. diff --git a/usr.bin/elvis/doc/makefile.ms b/usr.bin/elvis/doc/makefile.ms deleted file mode 100644 index ae00f9476a7d..000000000000 --- a/usr.bin/elvis/doc/makefile.ms +++ /dev/null @@ -1,255 +0,0 @@ -.Go 9 "MAKEFILE" -.PP -On most Operating Systems, and with most compilers, the "Makefile.mix" -file is used to control compilation and installation of \*E. -This section of the manual describes the overall structure of "Makefile.mix", -and the various configuration options in it. -.NH 2 -Configuring the Makefile -.PP -Begin by copying "Makefile.mix" to "Makefile". -Never alter the original "Makefile.mix". -.PP -Most of the configuration options are controlled via a group of macros. -Makefile.mix begins with several pre-configured sets of macro definitions \- -one group for each of the most common supported systems. -As shipped, all of these macro definitions are commented out; -you must either uncomment out one of the groups, or -(for less common systems) construct an entirely new group. -.NH 2 -Using the Makefile -.PP -After configuring the Makefile, you can run "make" to compile the programs. -There are also some other useful things that the Makefile can do... -.LD -.ta 1i 2.2i - COMMAND RESULT - make compile all programs - make install copy the programs to the BIN directory - make clean remove all object files - make clobber remove everything except source & documentation - make uue produce uuencoded compressed tar archives of the source - make sh produce shar archives of the source -.DE -.PP -Note that the last two will probably work only under UNIX. -.NH 2 -What "make install" does -.PP -To install elvis, we should copy all of the executables into a directory -where users can find them; -copy the documentation into a directory where the on-line manual program -can find them; -and arrange for edit buffers to be preserved after a system crash. -The "make install" command tries to do this automatically, -but there are problems. -.PP -Practically all operating systems allow programs to be installed different -directories. -As shipped, Makefile.mix contains somebody's best guess as to where you'd -like them to go. -You should double check it, though. -The BIN macro controls where the programs will be installed. -.PP -On UNIX systems the "elvprsv" and "elvrec" programs need to be -installed as SUID-root programs. -Consequently, you must run "make install" as root; -then they will automatically be installed as SUID-root. -.PP -For text to be recovered after a crash, you need to arrange for the -"elvprsv" program to be run before the /tmp file is cleaned. -This means that the /etc/rc file (or whatever) needs to be edited. -If you have a SysV UNIX system which uses a /etc/rc2.d directory for storing -start-up commands, then you're lucky. -"make install" will detect that /etc/rc2.d exists and attempt to -automatically create a file called "/etc/rc2.d/S03elvis" which runs elvprsv. -However, for non-UNIX systems, or UNIX systems which don't have a /etc/rc2.d -directory, you'll need to do this by hand. -See the "Versions" section of the manual for hints about doing this on -your particular system. -.PP -Non-UNIX systems don't have a standard place where UNIX-style man-pages -go, so "make install" doesn't attempt to install documentation on those -systems. -.PP -On UNIX systems, there is no standard place either, but you can be -pretty sure that your system has a non-standard one. -There is a shell script called "instman.sh" which attempts to figure -out where the man-pages belong on your system, and then copies them there. -You might need to edit "instman.sh" to make it work, but try it as-is first. -"instman.sh" is automatically run by "make install". -.PP -Note: It is safe to run "make install" more than once. -.NH 2 -Summary of Macros -.PP -The following describes the configuration macros. -With most versions of make, a blank macro can simply be left undefined. -.IP OBJ -This is the filename extension for unlinked object files -\- usually .o, but MS-DOS uses .obj. -.IP EXE -This is the filename extension for elvis executable file -\- usually nothing, but MS-DOS uses .exe, -and other operating systems may use something else. -.IP COM -This is the filename extension for the executables of elvis' support programs -\- usually the same as the EXE macro, but since the support programs are all -much smaller that elvis, MS-DOS can use the .com format. -.IP EXTRA -This is a space-delimited list of version-specific object files to be linked -into elvis. -Typically, this list will contain at least one object file which was written -specifically for a given operating system. -It may also contain "tinytcap$(OBJ)" or "tinyprnt$(OBJ)". -.IP EXTRA2 -This is a space-delimited list of version-specific object files used in elvis -and a few of the support programs. -For UNIX-like systems, this is typically an empty list. -For non-UNIX systems, it will usually either be empty, or it will contain -the name of an object file which contains functions which emulate certain -UNIX system calls. -(Not all non-UNIX systems need any special emulation functions, because -all C libraries try to emulate UNIX. You only need an EXTRA2 list if -the library doesn't emulate UNIX well enough.) -.IP LIBS -This is a list of library flags used while linking elvis. -UNIX systems need "-ltermcap" or something similar, unless the EXTRA -macro includes "tinytcap$(OBJ)". -Most other operating systems use "tinytcap$(OBJ)" and don't need anything else, -so they leave the LIBS list empty. -.IP BIN -This is the directory where executables should be installed by "make install". -.IP CC -This is the C compiler command, possibly with "memory model" flags. -.IP CFLAGS -This lists the compiler flags used to select compile-time options. -The "CFLAGS" section of this manual describes this in detail. -.IP LNK -This is the name of the linker. -If you want to use $(CC) as your linker, then you can leave LNK undefined. -.IP LFLAGS -This is a list of linker flags used to select link-time options. -It is almost always blank. -.IP SMALL -The flag for special small memory model compilation \- usually blank. -.IP OF -The link flag to control the output file's name \- usually -o. -The Sun version of "make" strips off trailing whitespace, so a pair -of empty quotes has been added after the space, to protect it. -On non-Suns, this isn't necessary. -.IP RF -The flag used to denote "compile but don't link" \- usually -c -.IP PROGS -This is a space-delimited list of all programs. -This list always includes elvis, ctags, ref, elvrec, and elvprsv. -Also, everybody gets fmt except for BSD UNIX; it already has its own -version of fmt as standard equipment. -.IP -Most non-UNIX systems also include the vi, ex, and view aliases. -(UNIX doesn't need those aliases in the PROGS list because it creates -them via file links during installation.) -OS-9 doesn't include the ex alias, because there is already a command -by that name built into its standard shell. -.IP -Note: some MS-DOS configurations break this list into two smaller lists, -to compensate for MS-DOS's limitations on command line length. -.IP CHMEM -This is either blank, or a command to be run immediately after linking elvis. -Under Minix and Coherent, elvis needs to have extra space assigned for the -stack & heap after it has been linked, -so their commands to do that are placed here. -Most other operating systems generally either don't need to have their stacks -enlarged, or they enlarge it during linking. -.IP SORT -This should be defined to be -DSORT if you want your tags list to be sorted, -or blank if you want it unsorted. -The real vi requires a sorted tags file, so for the sake of compatibility -all of the UNIX configurations use -DSORT. -Elvis doesn't need a sorted tags file, though, so on non-UNIX systems you -can leave this macro blank. -.IP RM -This is the name of a program that deletes files unconditionally. -It is used during "make clean". -RM is defined as "rm -f" for UNIX systems, or "del" for most others. -.IP CP -This is the name of a program that copies files. -\- usually "cp" or "copy". -It is used during "make install". -.IP SYS -This is the type of system. -It is used to select an appropriate style of linking and installation -that are used by "make" and "make install", respectively. -The available types are: -.LD -.ta 2i 3i - unx UNIX and UNIX-like systems - dos MS-DOS - ami AmigaDos - tos Atari TOS - os9 OS-9/68k - vms VAX/VMS - xdos cross-compiled on SCO for MS-DOS -.DE -.IP DUMMY -This is used as the "source" filename in the dependency list of -targets which are supposed to be unconditionally compiled. -It is usually nothing since most versions of "make" treat an -empty source file list as a special case, -but OS-9 needs it defined as "dummy" and further requires that -there be no actual file named dummy. -.IP CFG -The is the name of the compiler configuration file \- usually blank, -since most compilers don't need a configuration file. -Some MS-DOS compilers need it, though. -.NH 2 -Structure of Makefile.mix -.PP -Makefile.mix begins with several sets of commented out configuration -macro definitions, as described above. -A comment saying "The rest of this Makefile contains no user-serviceable parts" -marks the end of this section. -Most people won't need to edit anything after that. -.PP -This is followed by macro definitions which are identical, -regardless of your operating system. -The OBJS macros list the object files that form the portable parts of -elvis, and are used together with the EXTRA and EXTRA2 configuration macros -during linking. -.PP -The SRC macros list all of the files mentioned in the "MANIFEST" file. -These are used to bundle the source code via "make uue" or "make sh". -.PP -This is followed by a target named "all" which depends on all of the -programs listed in the PROGS configuration macro. -This is followed by detailed instructions describing how each file is -compiled and linked. -The only exceptions are the "elvis" program, and the various forms of the -"alias" program. -.PP -Linking a big program like elvis is non-standard on some systems. -To support this, we just say that elvis depends on "linkelv.$(SYS)", -where "$(SYS)" is replaced by whatever you defined the SYS configuration -macro to be. -The various link styles are listed after that. -The only really tricky one is for DOS. -Since the list of files to be linked is too long to fit on a DOS command line, -a customized response file is created, and the name of the response file -is passed instead. -The exact format of the response file depends on the compiler you're using. -.PP -This is followed by system-dependent ways of linking the "alias" object -file to create multiple executables. -For most systems, we only really link it once to form the "ex" executable, -and then copy that executable to form the "vi", "view", and "input" executables. -OS-9, though, doesn't need an "ex" executable and it requires actual -linking for each alias. -.PP -Next comes installation, in all its system dependent forms. -This uses the now-familiar trick of saying that the "install" target -depends on a bogus file named "inst.$(SYS)" and then listing each -installation technique after that. -There should be no surprises here. -.PP -The rest of Makefile.mix contains a few handy pseudo-targets, -such as "make clean". diff --git a/usr.bin/elvis/doc/options.ms b/usr.bin/elvis/doc/options.ms deleted file mode 100644 index 79f5ea2a8846..000000000000 --- a/usr.bin/elvis/doc/options.ms +++ /dev/null @@ -1,561 +0,0 @@ -.Go 5 "OPTIONS" -.PP -Options may be set or examined via the colon command "set". -The values of options will affect the operation of later commands. -.PP -For convenience, options have both a long descriptive name and a short name -which is easy to type. -You may use either name interchangably. -I like the short names, myself. -.PP -There are three types of options: Boolean, string, and numeric. -Boolean options are made TRUE by giving the name of the option as an -argument to the "set" command; -they are made FALSE by prefixing the name with "no". -For example, "set autoindent" makes the autoindent option TRUE, -and "set noautoindent" makes it FALSE. -\*E also allows boolean options to be toggled by prefixing the name with "neg". -So, ":map g :set neglist^M" will cause the key to alternately toggle the -"list" option on and off. -(The "neg" prefix is an extension; the real vi doesn't support it.) -.PP -To change the value of a string or numeric option, pass the "set" command -the name of the option, followed by an "=" sign and the option's new value. -For example, "set tabstop=8" will give the tabstop option a value of 8. -For string options, you may enclose the new value in quotes. -.LD -.ta 1.9i 2.4i 3.8i -.ps +2 -\fBNAMES TYPE DEFAULT MEANING\fP -.ps -2 -autoindent, ai Bool noai auto-indent during input -autoprint, ap Bool ap in EX, print the current line -autotab, at Bool at auto-indent allowed to use tabs? -autowrite, aw Bool noaw auto-write when switching files -beautify, bf Bool nobf strip control chars from file? -charattr, ca Bool noca interpret \\fX sequences? -cc, cc Str cc="cc -c" name of the C compiler -columns, co Num co=80 width of the screen -digraph, dig Bool nodig recognize digraphs? -directory, dir Str dir="/usr/tmp" where tmp files are kept -edcompatible, ed Bool noed remember ":s//" options -equalprg, ep Bool ep="fmt" program to run for = operator -errorbells, eb Bool eb ring bell on error -exrc, exrc Bool noexrc read "./.exrc" file? -exrefresh, er Bool er write lines indiviually in EX -flash, vbell Bool flash use visible alternative to bell -flipcase, fc Str fc="" non-ASCII chars flipped by ~ -hideformat, hf Bool hf hide text formatter commands -ignorecase, ic Bool noic upper/lowercase match in search -inputmode, im Bool noim start vi in insert mode? -keytime, kt Num kt=2 timeout for mapped key entry -keywordprg, kp Str kp="ref" full pathname of shift-K prog -lines, ln Num ln=25 number of lines on the screen -list, li Bool noli display lines in "list" mode -magic, ma Bool ma use regular expression in search -make, mk Str mk="make" name of the "make" program -mesg, ms Bool ms allow messages from other users? -modelines, ml Bool noml are modelines processed? -more, more Bool more pause between messages? -nearscroll, ns Num ns=15 when to scroll vs. redraw -novice, nov Bool nonovice set options for ease of use -number, nu Bool nonumber show line numbers -paragraphs, para Str para="PPppIPLPQP" names of "paragraph" nroff cmd -prompt, pr Bool pr show ':' prompt in \fIex\fR mode -readonly, ro Bool noro prevent overwriting of orig file -remap, rem Bool remap allow key maps to call key maps -report, re Num re=5 report when 5 or more changes -ruler, ru Bool noru display line/column numbers -scroll, sc Num sc=12 scroll amount for ^U and ^D -sections, sect Str sect="NHSHSSSEse" names of "section" nroff cmd -shell, sh Str sh="/bin/sh" full pathname of the shell -showmatch, sm Bool nosm show matching ()[]{} -showmode, smd Bool nosmd say when we're in input mode -shiftwidth, sw Num sw=8 shift amount for < and > -sidescroll, ss Num ss=8 amount of sideways scrolling -sync, sy Bool nosy call sync() often -tabstop, ts Num ts=8 width of tab characters -taglength, tl Num tl=0 significant chars in tag name -tags, tag Str tags="tags" list of tags files -tagstack, tgs Bool tgs enable tagstack? -term, te Str te="$TERM" name of the termcap entry -terse, tr Bool notr give shorter error messages -timeout, to Bool to distinguish from ? -warn, wa Bool wa warn for ! if file modified -window, wi Num wi=24 lines to redraw after long move -wrapmargin, wm Num wm=0 wrap long lines in input mode -wrapscan, ws Bool ws at EOF, searches wrap to line 1 -writeany, wr Bool nowr allow :w to clobber files -.DE -.TA -.ne 6 -.IP "autoindent, ai" -During input mode, the autoindent option will cause each added line -to begin with the same amount of leading whitespace as the line above it. -Without autoindent, added lines are initially empty. -.IP "autoprint, ap" -This option only affects EX mode. -If the autoprint option on, -and either the cursor has moved to a different line -or the previous command modified the file, -then \*E will print the current line. -.IP "autotab, at" -This option affects the behaviour of the autoindent mode. -If autoindent is turned off, then autotab has no effect. -.IP -When autotab is turned on, elvis will use a mixture of spaces and tabs -to create the proper amount of indentation. -This is the default. -.IP -When autotab is turned off, elvis will only use spaces for auto-indent. -\*E will still insert a real tab character when you hit the key, though; -the autotab option only affects \fIautomatic\fR indentation. -.IP "autowrite, aw" -When you're editing one file and decide to switch to another -\- via the :tag command, or :next command, perhaps \- -if your current file has been modified, -then \*E will normally print an error message and refuse to switch. -.IP -However, if the autowrite option is on, -then \*E will write the modified version of the current file -and successfully switch to the new file. -.IP "beautify, bf" -This option causes all control characters to be deleted from the text file, -at the time when you start editing it. -If you're already editing a file when you turn on the beautify option, -then that file won't be affected. -.IP cc -The :cc command runs the C compiler. -This option should be set to the name of your compiler. -.IP "charattr, ca" -Many text formatting programs allow you to designate portions of -your text to be underlined, italicized, or boldface by embedding -the special strings \\fU, \\fI, and \\fB in your text. -The special string \\fP marks the end of underlined or boldface text. -.IP -\*E normally treats those special strings just like any other text. -.IP -However, if the charattr option is on, then \*E will interpret -those special strings correctly, -to display underlined or boldface text on the screen. -(This only works, of course, if your terminal can display -underlined and boldface, and if the TERMCAP entry says how to do it.) -.IP "columns, co" -This option shows how wide your screen is. -.IP "digraph, dig" -This option is used to enable/disable recognition of digraphs. -The default value is nodigraph, which means that digraphs will not be -recognized. -.IP "directory, dir" -\*E stores text in temporary files. -This option allows you to control which directory those temporary files will -appear in. -The default is /usr/tmp. -.IP -This option can only be set in a .exrc file; -after that, \*E will have already started making temporary files -in some other directory, so it would be too late. -.IP "edcompatible, ed" -This option affects the behaviour of the ":s/regexp/text/options" command. -It is normally off (:se noed) which causes all of the substitution options -to be off unless explicitly given. -.IP -However, with edcompatible on (:se ed), the substitution command remembers -which options you used last time. -Those same options will continue to be used until you change them. -In edcompatible mode, when you explicitly give the name of a -substitution option, you will toggle the state of that option. -.IP -This all seems very strange to me, but its implementation was almost free -when I added the ":&" command to repeat the previous substitution, -so there it is. -.IP "equalprg, ep" -This holds the name & arguments of the external filter program -used the the visual = operator. -The defualt value is "fmt", -so the = operator will adjust line breaks in text. -.IP "errorbells, eb" -\*E normally rings a bell when you do something wrong. -This option lets you disable the bell. -.IP exrc -This option specifies whether a .exrc file in the current directory -should be executed. -By default, this option is off (":set noexrc") which prevents elvis from -executing .exrc in the current directory. -If the .exrc file in your home directory turns this option on (":set exrc") -then the \*E will attempt to execute the .exrc file in the current directory. -.IP -This option exist mainly for security reasons. -A mean-spirited person could do something like -.br - echo >/tmp/.exrc '!rm -rf $HOME' -.br -and then anybody who attempted to edit or view a file in the /tmp directory -would lose most of their files. -With the exrc option turned off, this couldn't happen to you. -.IP "exrefresh, er" -The EX mode of \*E writes many lines to the screen. -You can make \*E either write each line to the screen separately, -or save up many lines and write them all at once. -.IP -The exrefresh option is normally on, so each line is written to the -screen separately. -.IP -You may wish to turn the exrefresh option off (:se noer) if the -"write" system call is costly on your machine, or if you're using a -windowing environment. -(Windowing environments scroll text a lot faster when you write -many lines at once.) -.IP -This option has no effect in visual command mode or input mode. -.IP "flash, vbell" -If your termcap entry describes a visible alternative to ringing -your terminal's bell, then this option will say whether the visible -version gets used or not. -Normally it will be. -.IP -If your termcap does NOT include a visible bell capability, -then the flash option will be off, and you can't turn it on. -.IP "flipcase, fc" -The flipcase option allows you to control how the non-ASCII characters are -altered by the "~" command. -.IP -The string is divided into pairs of characters. -When "~" is applied to a non-ASCII character, -\*E looks up the character in the flipcase string to see which pair it's in, -and replaces it by the other character of the pair. -.IP "hideformat, hf" -Many text formatters require you to embed format commands in your text, -on lines that start with a "." character. -\*E normally displays these lines like any other text, -but if the hideformat option is on, -then format lines are displayed as blank lines. -.IP "ignorecase, ic" -Normally, when \*E searches for text, it treats uppercase letters -as being different for lowercase letters. -.IP -When the ignorecase option is on, uppercase and lowercase are treated as equal. -.IP "inputmode, im" -This option allows you to have \*E start up in insert mode. -You can still exit insert mode at any time by hitting the ESC key, as usual. -Usually, this option would be set in your ".exrc" file. -.IP "keytime, kt" -The arrow keys of most terminals send a multi-character sequence. -It takes a measurable amount of time for these sequences to be transmitted. -The keytime option allows you to control the maximum amount of time -to allow for an arrow key (or other mapped key) to be received in full. -.IP -On most systems, the setting is the number of tenths of a second to allow -between characters. -On some other systems, the setting is in whole seconds. -.IP -Try to avoid setting keytime=1. -Most systems just count clock beats, so if you tried to read a character -shortly before a clock beat, you could allow almost no time at all for -reading the characters. -For higher keytime settings, the difference is less critical. -.IP -If your system's response time is poor, you might want to increase the keytime. -In particular, I've found that when keystrokes must be sent through a network -(via X windows, rlogin, or telnet, for example) the keytime should be set to -at least 1 second. -.IP -As a special case, -you can set keytime to 0 to disable this time limit stuff altogether. -The big problem here is: -If your arrow keys' sequences start with an ESC, -then every time you hit your ESC key \*E will wait... and wait... -to see if maybe that ESC was part of an arrow key's sequence. -.IP -NOTE: this option is a generalization of the timeout option of the real vi. -.IP "keywordprg, kp" -\*E has a special keyword lookup feature. -You move the cursor onto a word, and hit shift-K, -and \*E uses another program to look up the word -and display information about it. -.IP -This option says which program gets run. -.IP -The default value of this option is "ref", -which is a program that looks up the definition of a function in C. -It looks up the function name in a file called "refs" which is created by ctags. -.IP -You can subtitute other programs, such as an English dictionary program -or the online manual. -\*E runs the program, using the keyword as its only argument. -The program should write information to stdout. -The program's exit status should be 0, unless you want \*E to print -"<<< failed >>>". -.IP "lines, ln" -This option says how many lines you screen has. -.IP "list, li" -In nolist mode (the default), \*E displays text in a "normal" manner --- with tabs expanded to an appropriate number of spaces, etc. -.IP -However, sometimes it is useful to have tab characters displayed differently. -In list mode, tabs are displayed as "^I", -and a "$" is displayed at the end of each line. -.IP "magic, ma" -The search mechanism in \*E can accept "regular expressions" --- strings in which certain characters have special meaning. -.IP -The magic option is normally on, which causes these characters to be treated -specially. -.IP -If you turn the magic option off (:se noma), -then all characters except ^ and $ are treated literally. -^ and $ retain their special meanings regardless of the setting of magic. -.IP "make, mk" -The :make command runs your "make" program. -This option defines the name of your "make" program. -.IP mesg -With the real vi, running under real UNIX, -":set nomesg" would prevent other users from sending you messages. -\*E ignores it, though. -.IP "modelines, ml" -\*E supports modelines. -Modelines are lines near the beginning or end of your text file which -contain "ex:yowza:", -where "yowza" is any EX command. -A typical "yowza" would be something like "set ts=5 ca kp=spell wm=15". -Other text may also appear on a modeline, -so you can place the "ex:yowza:" in a comment: -.br -.ID -/* ex:set sw=4 ai: */ -.DE -.IP -Normally these lines are ignored, for security reasons, -but if you have "set modelines" in your .exrc file -then "yowza" is executed. -.IP "nearscroll, ns" -The line that contains the cursor will always be on the screen. -If you move the cursor to a line that isn't on the screen, -then elvis will either scroll -(if the cursor's line is nearly on the screen already) -or redraw the screen completely with the cursor's line centered -(if the cursor line is \fInot\fR near the screen already). -.IP -This option allows you to control elvis' idea of "near". -A value of 15 is typical. -A value of 1 would cause elvis to scroll no more that one line. -A value of 0 disables scrolling. -.IP "novice, nov" -The command ":set novice" is equivelent to ":set nomagic report=1 showmode". -.IP "number, nu" -The "number" option causes \*E to display line numbers at the start of -each line. -The numbers are not actually part of the text; when the file is written out, -it will be written without line numbers. -.IP "paragraphs, pa" -The { and } commands move the cursor forward or backward in increments -of one paragraph. -Paragraphs may be separated by blank lines, or by a "dot" command of -a text formatter. -Different text formatters use different "dot" commands. -This option allows you to configure \*E to work with your text formatter. -.IP -It is assumed that your formatter uses commands that start with a -"." character at the front of a line, -and then have a one- or two-character command name. -.IP -The value of the paragraphs option is a string in which each pair -of characters is one possible form of your text formatter's paragraph -command. -.IP "more" -When \*E must display a sequence of messages at the bottom line of the screen -in visual mode, it normally pauses after all but the last one, so you have -time to read them all. -.IP -If you turn off the "more" option, then \*E will not pause. -This means you can only read the last message, but it is usually the most -important one anyway. -.IP "prompt, pr" -If you ":set noprompt", then \*E will no longer emit a ':' when it -expects you to type in an \fIex\fR command. -This is slightly useful if you're using an astonishingly slow UNIX machine, -but the rest of us can just ignore this one. -.IP "readonly, ro" -Normally, \*E will let you write back any file to which you have -write permission. -If you don't have write permission, then you can only write the changed -version of the file to a \fIdifferent\fP file. -.IP -If you set the readonly option, -then \*E will pretend you don't have write permission to \fIany\fP file you edit. -It is useful when you really only mean to use \*E to look at a file, -not to change it. -This way you can't change it accidentally. -.IP -This option is normally off, unless you use the "view" alias of \*E. -"View" is like "vi" except that the readonly option is on. -.IP "remap" -The ":map" command allows you to convert one key sequence into another. -The remap option allows you to specify what should happen if portions of -that other sequence are also in the map table. -If remap is on, then those portions will also be mapped, just as if they -had been typed on the keyboard. -If remap is off, then the matching portions will not be mapped. -.IP -For example, if you enter the commands ":map A B" and ":map B C", -then when remap is on, A will be converted to C. -But when remap is off, A will be converted only to B. -.IP "report, re" -Commands in \*E may affect many lines. -For commands that affect a lot of lines, \*E will output a message saying -what was done and how many lines were affected. -This option allows you to define what "a lot of lines" means. -The default is 5, so any command which affects 5 or more lines will cause -a message to be shown. -.IP "ruler, ru" -This option is normally off. -If you turn it on, then \*E will constantly display the line/column numbers -of the cursor, at the bottom of the screen. -.IP "scroll, sc" -The ^U and ^D keys normally scroll backward or forward by half a screenful, -but this is adjustable. -The value of this option says how many lines those keys should scroll by. -If you invoke ^U or ^D with a count argument (for example, "33^D") then -this option's value is set to the count. -.IP "sections, se" -The [[ and ]] commands move the cursor backward or forward in increments of -1 section. -Sections may be delimited by a { character in column 1 -(which is useful for C source code) -or by means of a text formatter's "dot" commands. -.IP -This option allows you to configure \*E to work with your text formatter's -"section" command, in exectly the same way that the paragraphs option makes -it work with the formatter's "paragraphs" command. -.IP "shell, sh" -When \*E forks a shell -(perhaps for the :! or :shell commands) -this is the program that is uses as a shell. -This is "/bin/sh" by default, -unless you have set the SHELL (or COMSPEC, for MS-DOS) environment variable, -it which case the default value is copied from the environment. -.IP "shiftwidth, sw" -The < and > commands shift text left or right by some uniform number of columns. -The shiftwidth option defines that "uniform number". -The default is 8. -.IP "showmatch, sm" -With showmatch set, -in input mode every time you hit one of )}], -\*E will momentarily move the cursor to the matching ({[. -.IP "showmode, smd" -In visual mode, it is easy to forget whether you're in the visual command mode -or input/replace mode. -Normally, the showmode option is off, and you haven't a clue as to which mode -you're in. -If you turn the showmode option on, though, a little message will appear in the -lower right-hand corner of your screen, telling you which mode you're in. -.IP "sidescroll, ss" -For long lines, \*E scrolls sideways. -(This is different from the real vi, -which wraps a single long line onto several rows of the screen.) -.IP -To minimize the number of scrolls needed, -\*E moves the screen sideways by several characters at a time. -The value of this option says how many characters' widths to scroll at a time. -.IP -Generally, the faster your screen can be redrawn, -the lower the value you will want in this option. -.IP "sync, sy" -If the system crashes during an edit session, then most of your work -can be recovered from the temporary file that \*E uses to store -changes. -However, sometimes the OS will not copy changes to the -hard disk immediately, so recovery might not be possible. -The [no]sync option lets you control this. -.IP -In nosync mode (which is the default, for UNIX), \*E lets the operating system -control when data is written to the disk. -This is generally faster. -.IP -In sync mode (which is the default for MS-DOS, AmigaDos, and Atari TOS), -\*E forces all changes out -to disk every time you make a change. -This is generally safer, but slower. -It can also be a rather rude thing to do on a multi-user system. -.IP "tabstop, ts" -Tab characters are normally 8 characters wide, -but you can change their widths by means of this option. -.IP "taglength, tl" -This option allows you to specify how many characters of a tag's name -must match when performing tag lookup. -As a special case, ":set taglength=0" means that all characters of a tag's -name must match. -.IP -Note: some configurations of \*E don't support this option. -.IP "tags, tag" -If your version of elvis is compiled with -DINTERNAL_TAGS, -then this is a space-delimited list of tags files. -When you tell elvis to look up a tag, -it searches though each file in turn until it finds the tag. -.IP -If your version of elvis is compiled without -DINTERNAL_TAGS, -then you can achieve the same effect via an environment variable called -TAGPATH. -TAGPATH's value is a colon-delimited list of file or directory names. -(For some operating systems, including MS-DOS, the list is delimited by -semicolons instead of colons.) -.IP "tagstack" -This option allows you to disable the tagstack. -I can't think of any reason why you would want to do that. -.IP "term, te" -This read-only option shows the name of the termcap entry that -\*E is using for your terminal. -.IP "terse, tr" -The real vi uses this option to select longer vs. shorter error messages. -\*E has only one set of error messages, though, so this option has no effect. -.IP "timeout, to" -The command ":set notimeout" is equivelent to ":set keytime=0", -and ":set timeout" is equivelent to ":set keytime=1". -This affects the behaviour of the key. -See the discussion of the "keytime" option for more information. -.IP "warn, wa" -If you have modified a file but not yet written it back to disk, then -\*E will normally print a warning before executing a ":!cmd" command. -However, in nowarn mode, this warning is not given. -.IP -\*E also normally prints a message after a successful search that -wrapped at EOF. -The [no]warn option can also disable this warning. -.IP "window, wi" -This option controls how many lines are redrawn after a long move. -.IP -On fast terminals, this is usually set to the number of rows that the -terminal can display, minus one. -This causes the entire screen to be filled with text around the cursor. -.IP -On slow terminals, you may wish to reduce this value to about 7 or so. -That way, if you're doing something like repeatedly hitting 'n' to search -for each occurrence of some string and trying to find a particular occurrence, -then you don't need to wait as long for \*E to redraw the screen after each -search. -.IP "wrapmargin, wm" -Normally (with wrapmargin=0) \*E will let you type in extremely long -lines, if you wish. -.IP -However, with warpmargin set to something other that 0 (wrapmargin=10 -is nice), \*E will automatically cause long lines to be "wrapped" -on a word break for lines come too close to the right-hand margin. -For example: On an 80-column screen, ":set wm=10" will cause lines to -wrap when their length exceeds 70 columns. -.IP "wrapscan, ws" -Normally, when you search for something, \*E will find it no matter -where it is in the file. -\*E starts at the cursor position, and searches forward. -If \*E hits EOF without finding what you're looking for, -then it wraps around to continue searching from line 1. -If you turn off the wrapscan option (:se nows), -then when \*E hits EOF during a search, it will stop and say so. -.IP "writeany, wr" -With "writeany" turned off, elvis will prevent you from accidentally -overwriting a file. -For example, if "foo" exists then ":w foo" will fail. -If you turn on the "writeany" option, then ":w foo" will work. -.IP -Regardless of the setting of "writeany", though, ":w! foo" will work. -The '!' forces the ":w" command to write the file unless the operating system -won't allow it. diff --git a/usr.bin/elvis/doc/question.ms b/usr.bin/elvis/doc/question.ms deleted file mode 100644 index db8f8d2819ce..000000000000 --- a/usr.bin/elvis/doc/question.ms +++ /dev/null @@ -1,172 +0,0 @@ -.Go 14 "QUESTIONS & ANSWERS" -.nr qN 0 1 -.de Q -.sp -.IP \fB\\n+(qN) 0.4i -.. -.de A -.IP \fR 0.75i -.. -.Q -How can I make \*E run faster under DOS? -.A -There are several things you can do. -The first thing to do is get a good screen driver such as NANSI.SYS. -This can speed up screen redrawing by as much as a factor of eight! -The DOS-specific part of section 12 tells you how to do this. -.A -You might also consider reducing the size of the blocks that \*E uses. -You'll need to recompile \*E to do this. -The default BLKSIZE is 1024 byte for the DOS version of \*E, which means -that for each keystroke that you insert, \*E must shift an average of -about 500 bytes. -That's a lot to ask from a little old 5MHz 8088. -A BLKSIZE of 512 bytes might be more appropriate. -.A -If you're \fIreally\fR desperate for more speed, you might want to make -\*E store its temporary files on a RAM disk. -However, this limits the size of the file you can edit, and it eliminates any -chance you may have had to recover your work after a power failure -or system crash, but it might be worth it; you decide. -To do this, add ":set dir=R:\\" (or whatever your RAM disk's name is) -to the \fIelvis.rc\fP file. -.A -Next, consider turning off the "sync" option. -When the sync option is turned on, \*E will close the temporary file -and reopen it after every change, in order to force DOS to update -the file's directory entry. -If you put ":set nosync" into the \fIelvis.rc\fP file, then \*E will -only close the file when you start editing a different text file, or -when you're exiting \*E. -Consequently, there is no chance that you'll be able to recover your -changes after a power failure... so if you're going to this, then you -might as well store the temp files on the RAM disk, too. -.Q -Where's the key on a DEC keyboard? -.A -I don't know. Maybe the key? -You could always use ":map!" to make some other key act like the key. -If all else fails, use <[>. -.Q -Is there a way to show which keys do what? -.A -Yes. The command ":map" will show what each key does in command mode, -and ":map!" (with an exclamation mark) shows what each key does in -input mode. -.A -The table is divided into three columns: the key's label, the characters -that it sends, and the characters that \*E pretends you typed. -.Q -How can I make \*E display long lines like the real vi? -.A -You can't yet. -The next version of \*E should support this, though. -.Q -I can't recover my text [under MS-DOS or Atari TOS]. -According to the directory listing, the temporary file is 0 bytes long. -What went wrong? -.A -MS-DOS and TOS only update a file's directory entry when the file is closed. -If the system crashes while the file is still open, then the file's length -is stored as 0 bytes. -The ":set sync" option is supposed to prevent this; -you probably turned it off in the interest of speed, right? -.A -Under MS-DOS [I don't know about TOS], you should delete the empty -temporary file, and then run CHKDSK/F. -This \fImight\fP find the data that belonged in the empty file, -and place it in a new file with a name like "000001.CHK" -- something like that. -You can then try to extract the text from that temporary file by giving the -command "elvprsv -R 000001.chk". -If you're lucky, then this might recover your text. -.Q -What is the most current version of \*E? -.A -Each version of \*E that is released to the public has a version number -of the form "number point number". -As I write this, the most current version of \*E is \*V. -.A -The intermediate steps between one release and the next are labeled with -the \fInext\fP version number, with a letter appended. -For example, after 1.4 was released, I started working on 1.5a. -I am currently working on 2.0a. -When \*E reaches a stable state, I'll call it 2.0 and release it. -.A -Sometimes a beta-test version of \*E will be available via anonymous FTP -from m2xenix.psg.com, in the directory "pub/elvis/beta". -.Q -I only got executables, but now I want the source code. -Where can I get it? -.A -If you have access to the Internet, then you should be able to fetch it -from one of the public archives such as \fBplains.nodak.edu\fP. -It is accessible via anonymous FTP, or via an email server named -"archive-server@plains.nodak.edu". -Elvis is located in the directory "/pub/Minix/all.contrib". -.A -It is also available from the C Users' Group, in volume #365. -As I write this, they are asking $4 per disk plus $3.50 per order in the US, -and elvis requires three disks; this is subject to change. -Their phone number is (913) 841-1631, and their address is: -.LD -.ta 2.5i -.sp - The C Users' Group - 1601 W. 23rd Street, #200 - Lawrence KS 66046-2743 -.DE -.Q -Is this shareware, or public domain, or what? -.A -It is not public domain; it is copyrighted by me, Steve Kirkendall. -However, this particular version is freely redistributable, in either -source form or executable form. -(I would prefer that you give copies away for free, complete with the -full source code... but I'm not going to force you.) -.A -It is not shareware; you aren't expected to send me anything. -You can use it without guilt. -.A -It is not "copylefted." -I hold a copyright, but currently I have not added any of the usual restrictions -that you would find on copylefted software. -If people start doing really obnoxious things to \*E, then I will start -adding restrictions to subsequent versions, but earlier versions won't -be affected. -(So far, everybody has been pretty good about this so no restrictions -have been necessary.) -.Q -Can I reuse parts of your source code? -.A -Yes. Please be careful, though, to make sure that the code really is mine. -Some of the code was contributed by other people, and I don't have the -authority to give you permission to use it. -The author's name can be found near the top of each source file. -If it says "Steve Kirkendall" then you may use it; -otherwise, you'd better contact the author first. -.A -Please don't remove my name from the source code. -If you modify the source, please make a note of that fact in a comment -near the top of the source code. -And, finally, please mention my name in your documentation. -.Q -Can \*E work with non-ASCII files? -.A -\*E is 8-bit clean. -This means that \*E will allow you to edit files that use a European -extended ASCII character set. -However, some terminals are not 8-bit clean; -they treat characters in the range 0x80-0x9f as control characters. -\*E expects all characters above 0x7f to be treated as normal displayable -characters, so on these terminals \*E may produce a scrambled display. -.A -\*E can't edit binary files because it can't handle the NUL character, -and because of line-length limitations. -.A -\*E has also modified to work with 16-bit character sets, but that modification -is not part of the standard \*E distribution. -Yongguang Zhang (ygz@cs.purdue.edu) has created a Chinese version of \*E -that uses 16-bit characters and runs under cxterm (Chinese X-term) -on X-windows systems. -Junichiro Itoh (itojun@foretune.co.jp) has modified \*E to edit Japanese -text under MS-DOS. diff --git a/usr.bin/elvis/doc/ref.man b/usr.bin/elvis/doc/ref.man deleted file mode 100644 index e7d2e178f144..000000000000 --- a/usr.bin/elvis/doc/ref.man +++ /dev/null @@ -1,88 +0,0 @@ -.TH REF 1 -.SH NAME -ref - Display a C function header -.SH SYNOPSIS -\fBref\fR [-t] [-c \fIclass\fR]... [-f \fIfile\fR]... \fItag\fR -.SH DESCRIPTION -\fIref\fP quickly locates and displays the header of a function. -To do this, \fIref\fR -looks in the "tags" file for the line that describes the function, and then -scans the source file for the function. -When it locates the function, it displays an introductory comment -(if there is one), the function's declaration, and the declarations of all -arguments. -.SH "SEARCH METHOD" -.PP -\fIref\fR uses a fairly sophisticated tag look-up algorithm. -If you supply a filename via \fB-f\fR \fIfile\fR, then elvis first scans -the tags file for a static tag from that file. -This search is limited to the tags file in the current directory. -.PP -If you supply a classname via \fB-c\fR \fIclass\fR, then elvis searches -for a tag from that class. -This search is not limited to the current directory; -You can supply a list of directories in the environment variable \fITAGPATH\fR, -and \fIref\fR will search through the "tags" file in each directory until it finds -a tag in the desired class. -.PP -If that fails, \fIref\fR will then try to look up an ordinary global tag. -This search checks all of the directories listed in \fITAGPATH\fR, too. -.PP -If you've given the \fB-t\fR flag, then \fIref\fR will simply output the tag line that -it found, and then exit. -Without \fB-t\fR, though, \fIref\fR will search for the tag line. -It will try to open the source file, which should be in the same directory -as the tags file where the tag was discovered. -If the source file doesn't exist, or is unreadable, then \fIref\fR will try to open -a file called "\fIrefs\fR" in that directory. -Either way, \fIref\fR will try to locate the tag, and display whatever it finds. -.SH "INTERACTION WITH ELVIS" -.PP -\fIref\fP is used by \fIelvis\fR' shift-K command. -If the cursor is located on a word such as "splat", in the file "foo.c", -then \fIelvis\fR will invoke \fIref\fR with the command "ref -f foo.c splat". -.PP -If \fIelvis\fR has been compiled with the -DEXTERNAL_TAGS flag, then \fIelvis\fR will -use \fIref\fR \fB\fRto scan the tags files. -This is slower than the built-in tag searching, but it allows \fIelvis\fR to access -the more sophisticated tag lookup provided by \fIref\fR. -Other than that, external tags should act exactly like internal tags. -.SH OPTIONS -.IP \fB-t\fR -Output tag info, instead of the function header. -.IP "\fB-f\fR \fIfile\fR" -The tag might be a static function in \fIfile\fR. -You can use several -f flags to have \fIref\fR consider static tags from more than one file. -.IP "\fB-c\fR \fIclass\fR" -The tag might be a member of class \fIclass\fR. -You can use several -c flags to have \fIref\fR consider tags from more than one class. -.SH FILES -.IP \fBtags\fR -List of function names and their locations, generated by \fIctags\fR. -.IP \fBrefs\fR -Function headers extracted from source files (optional). -.SH ENVIRONMENT -.IP \fBTAGPATH\fR -List of directories to be searched. -The elements in the list are separated by either -semicolons (for MS-DOS, Atari TOS, and AmigaDos), or -by colons (every other operating system). -For each operating system, \fIref\fR has a built-in default which is probably -adequate. -.SH NOTES -.PP -You might want to generate a "tags" file the directory that contains the -source code for standard C library on your system. -If licensing restrictions prevent you from making the library source readable -by everybody, then you can have \fIctags\fR generate a "refs" file, -and make "refs" readable by everybody. -.PP -If your system doesn't come with the library source code, then perhaps you -can produce something workable from the \fIlint\fR libraries. -.SH "SEE ALSO" -elvis(1), ctags(1) -.SH AUTHOR -.nf -Steve Kirkendall -kirkenda@cs.pdx.edu -.fi diff --git a/usr.bin/elvis/doc/regexp.ms b/usr.bin/elvis/doc/regexp.ms deleted file mode 100644 index 3bf77a14dd25..000000000000 --- a/usr.bin/elvis/doc/regexp.ms +++ /dev/null @@ -1,181 +0,0 @@ -.Go 4 "REGULAR EXPRESSIONS" - -.PP -\*E uses regular expressions for searching and substututions. -A regular expression is a text string in which some characters have -special meanings. -This is much more powerful than simple text matching. -.SH -Syntax -.PP -\*E' regexp package treats the following one- or two-character -strings (called meta-characters) in special ways: -.IP "\e(\fIsubexpression\fP\e)" 0.8i -The \e( and \e) metacharacters are used to delimit subexpressions. -When the regular expression matches a particular chunk of text, -\*E will remember which portion of that chunk matched the \fIsubexpression\fP. -The :s/regexp/newtext/ command makes use of this feature. -.IP "^" 0.8i -The ^ metacharacter matches the beginning of a line. -If, for example, you wanted to find "foo" at the beginning of a line, -you would use a regular expression such as /^foo/. -Note that ^ is only a metacharacter if it occurs -at the beginning of a regular expression; -anyplace else, it is treated as a normal character. -.IP "$" 0.8i -The $ metacharacter matches the end of a line. -It is only a metacharacter when it occurs at the end of a regular expression; -elsewhere, it is treated as a normal character. -For example, the regular expression /$$/ will search for a dollar sign at -the end of a line. -.IP "\e<" 0.8i -The \e< metacharacter matches a zero-length string at the beginning of -a word. -A word is considered to be a string of 1 or more letters and digits. -A word can begin at the beginning of a line -or after 1 or more non-alphanumeric characters. -.IP "\e>" 0.8i -The \e> metacharacter matches a zero-length string at the end of a word. -A word can end at the end of the line -or before 1 or more non-alphanumeric characters. -For example, /\e/ would find any instance of the word "end", -but would ignore any instances of e-n-d inside another word -such as "calendar". -.IP "\&." 0.8i -The . metacharacter matches any single character. -.IP "[\fIcharacter-list\fP]" 0.8i -This matches any single character from the \fIcharacter-list\fP. -Inside the \fIcharacter-list\fP, you can denote a span of characters -by writing only the first and last characters, with a hyphen between -them. -If the \fIcharacter-list\fP is preceded by a ^ character, then the -list is inverted -- it will match character that \fIisn't\fP mentioned -in the list. -For example, /[a-zA-Z]/ matches any letter, and /[^ ]/ matches anything -other than a blank. -.IP "\e{\fIn\fP\e}" 0.8i -This is a closure operator, -which means that it can only be placed after something that matches a -single character. -It controls the number of times that the single-character expression -should be repeated. -.IP "" 0.8i -The \e{\fIn\fP\e} operator, in particular, means that the preceding -expression should be repeated exactly \fIn\fP times. -For example, /^-\e{80\e}$/ matches a line of eighty hyphens, and -/\e<[a-zA-Z]\e{4\e}\e>/ matches any four-letter word. -.IP "\e{\fIn\fP,\fIm\fP\e}" 0.8i -This is a closure operator which means that the preceding single-character -expression should be repeated between \fIn\fP and \fIm\fP times, inclusive. -If the \fIm\fP is omitted (but the comma is present) then \fIm\fP is -taken to be inifinity. -For example, /"[^"]\e{3,5\e}"/ matches any pair of quotes which contains -three, four, or five non-quote characters. -.IP "*" 0.8i -The * metacharacter is a closure operator which means that the preceding -single-character expression can be repeated zero or more times. -It is equivelent to \e{0,\e}. -For example, /.*/ matches a whole line. -.IP "\e+" 0.8i -The \e+ metacharacter is a closure operator which means that the preceding -single-character expression can be repeated one or more times. -It is equivelent to \e{1,\e}. -For example, /.\e+/ matches a whole line, but only if the line contains -at least one character. -It doesn't match empty lines. -.IP "\e?" 0.8i -The \e? metacharacter is a closure operator which indicates that the -preceding single-character expression is optional -- that is, that it -can occur 0 or 1 times. -It is equivelent to \e{0,1\e}. -For example, /no[ -]\e?one/ matches "no one", "no-one", or "noone". -.PP -Anything else is treated as a normal character which must exactly match -a character from the scanned text. -The special strings may all be preceded by a backslash to -force them to be treated normally. -.SH -Substitutions -.PP -The :s command has at least two arguments: a regular expression, -and a substitution string. -The text that matched the regular expression is replaced by text -which is derived from the substitution string. -.br -.ne 15 \" so we don't mess up the table -.PP -Most characters in the substitution string are copied into the -text literally but a few have special meaning: -.LD -.ta 0.75i 1.3i - & Insert a copy of the original text - ~ Insert a copy of the previous replacement text - \e1 Insert a copy of that portion of the original text which - matched the first set of \e( \e) parentheses - \e2-\e9 Do the same for the second (etc.) pair of \e( \e) - \eU Convert all chars of any later & or \e# to uppercase - \eL Convert all chars of any later & or \e# to lowercase - \eE End the effect of \eU or \eL - \eu Convert the first char of the next & or \e# to uppercase - \el Convert the first char of the next & or \e# to lowercase -.TA -.DE -.PP -These may be preceded by a backslash to force them to be treated normally. -If "nomagic" mode is in effect, -then & and ~ will be treated normally, -and you must write them as \e& and \e~ for them to have special meaning. -.SH -Options -.PP -\*E has two options which affect the way regular expressions are used. -These options may be examined or set via the :set command. -.PP -The first option is called "[no]magic". -This is a boolean option, and it is "magic" (TRUE) by default. -While in magic mode, all of the meta-characters behave as described above. -In nomagic mode, only ^ and $ retain their special meaning. -.PP -The second option is called "[no]ignorecase". -This is a boolean option, and it is "noignorecase" (FALSE) by default. -While in ignorecase mode, the searching mechanism will not distinguish between -an uppercase letter and its lowercase form. -In noignorecase mode, uppercase and lowercase are treated as being different. -.PP -Also, the "[no]wrapscan" option affects searches. -.SH -Examples -.PP -This example changes every occurence of "utilize" to "use": -.sp -.ti +1i -:%s/utilize/use/g -.PP -This example deletes all whitespace that occurs at the end of a line anywhere -in the file. -(The brackets contain a single space and a single tab.): -.sp -.ti +1i -:%s/[ ]\e+$// -.PP -This example converts the current line to uppercase: -.sp -.ti +1i -:s/.*/\eU&/ -.PP -This example underlines each letter in the current line, -by changing it into an "underscore backspace letter" sequence. -(The ^H is entered as "control-V backspace".): -.sp -.ti +1i -:s/[a-zA-Z]/_^H&/g -.PP -This example locates the last colon in a line, -and swaps the text before the colon with the text after the colon. -The first \e( \e) pair is used to delimit the stuff before the colon, -and the second pair delimit the stuff after. -In the substitution text, \e1 and \e2 are given in reverse order -to perform the swap: -.sp -.ti +1i -:s/\e(.*\e):\e(.*\e)/\e2:\e1/ diff --git a/usr.bin/elvis/doc/termcap.ms b/usr.bin/elvis/doc/termcap.ms deleted file mode 100644 index cd38f1c3c88a..000000000000 --- a/usr.bin/elvis/doc/termcap.ms +++ /dev/null @@ -1,146 +0,0 @@ -.Go 11 "TERMCAP" -.PP -\*E uses fairly standard termcap fields for most things. -I invented the cursor shape names and some of the function key names, -but other than that there should be few surprises. -.SH -Required numeric fields -.if n .ul 0 -.ID -.ta 12n -:co#: number of columns on the screen (chars per line) -:li#: number of lines on the screen -.DE -.SH -Required string fields -.if n .ul 0 -.ID -.ta 12n -:ce=: clear to end-of-line -:cl=: home the cursor & clear the screen -:cm=: move the cursor to a given row/column -:up=: move the cursor up one line -.DE -.SH -Boolean fields -.if n .ul 0 -.ID -.ta 12n -:am: auto margins - wrap when char is written in last column? -:xn: brain-damaged auto margins - newline ignored after wrap -:pt: physical tabs? -.DE -.SH -Optional string fields -.if n .ul 0 -.ID -.ta 12n -:al=: insert a blank row on the screen -:dl=: delete a row from the screen -:cd=: clear to end of display -:ei=: end insert mode -:ic=: insert a blank character -:im=: start insert mode -:dc=: delete a character -:sr=: scroll reverse (insert row at top of screen) -:vb=: visible bell -:ks=: keypad enable -:ke=: keypad disable -:ti=: terminal initialization string, to start full-screen mode -:te=: terminal termination, to end full-screen mode -.DE -.SH -Optional strings received from the keyboard -.if n .ul 0 -.ID -.ta 12n -:kd=: sequence sent by the key -:kl=: sequence sent by the key -:kr=: sequence sent by the key -:ku=: sequence sent by the key -:kP=: sequence sent by the key -:kN=: sequence sent by the key -:kh=: sequence sent by the key -:kH=: sequence sent by the key -:kI=: sequence sent by the key -.DE -.PP -Originally, termcap didn't have any names for the , , , -and keys. -Although the capability names shown in the table above are the most common, -they are \fInot\fR universal. -SCO Xenix uses :PU=:PD=:HM=:EN=: for those keys. -Also, if the four arrow keys happen to be part of a 3x3 keypad, -then the five non-arrow keys may be named :K1=: through :K5=:, -so an IBM PC keyboard may be described using those names instead. -\*E can find any of these names. -.SH -Optional strings sent by function keys -.if n .ul 0 -.ID -.ta 20n -:k1=:...:k9=:k0=: codes sent by through keys -:s1=:...:s9=:s0=: codes sent by ... -:c1=:...:c9=:c0=: codes sent by ... -:a1=:...:a9=:a0=: codes sent by ... -.DE -.PP -Note that :k0=: is used to describe the key. -Some termcap documents recommend :ka=: or even :k;=: for describing -the key, but \*E doesn't support that. -.PP -Also, the :s1=:..., :c1=:..., and :a1=:... codes are very non-standard. -The terminfo library doesn't support them. -Consequently, if you're using the terminfo library then you might as well -add -DNO_SHIFT_FKEY to your CFLAGS setting. -.SH -Optional fields that describe character attributes -.if n .ul 0 -.ID -.ta 12n -:so=:se=: start/end standout mode (We don't care about :sg#:) -:us=:ue=: start/end underlined mode -:md=:me=: start/end boldface mode -:as=:ae=: start/end alternate character set (italics) -:ug#: visible gap left by :us=:ue=:md=:me=:as=:ae=: -.DE -.SH -Optional fields that affect the cursor's shape -.PP -The :cQ=: string is used by \*E immediately before exiting to undo -the effects of the other cursor shape strings. -If :cQ=: is not given, then all other cursor shape strings are ignored. -.ID -.ta 12n -:cQ=: normal cursor -:cX=: cursor used for reading EX command -:cV=: cursor used for reading VI commands -:cI=: cursor used during VI input mode -:cR=: cursor used during VI replace mode -.DE -.PP -If the capabilities above aren't given, then \*E will try to use the -following values instead. -.ID -.ta 12n -:ve=: normal cursor, used as :cQ=:cX=:cI=:cR=: -:vs=: gaudy cursor, used as :cV=: -.DE -.SH -An example -.PP -Here's the termcap entry I use on my Minix-ST system. -.sp -.LD -.ne 10 -mx|minix|minixst|ansi:\e - :is=\eE[0~:co#80:li#25:bs:pt:\e - :cm=\eE[%i%d;%dH:up=\eE[A:do=^J:nd=\eE[C:sr=\eEM:\e - :cd=\eE[J:ce=\eE[K:cl=\eE[H\eE[J:\e - :al=\eE[L:dl=\eE[M:ic=\eE[@:dc=\eE[P:im=:ei=:\e - :so=\eE[7m:se=\eE[m:us=\eE[4m:ue=\eE[m:\e - :md=\eE[1m:me=\eE[m:as=\eE[1;3m:ae=\eE[m:\e - :ku=\eE[A:kd=\eE[B:kr=\eE[C:kl=\eE[D:\e - :k1=\eE[1~:k2=\eE[2~:k3=\eE[3~:k4=\eE[4~:k5=\eE[5~:\e - :k6=\eE[6~:k7=\eE[17~:k8=\eE[18~:k9=\eE[19~:k0=\eE[20~: -.DE diff --git a/usr.bin/elvis/doc/title.ms b/usr.bin/elvis/doc/title.ms deleted file mode 100644 index 7d879d6f110c..000000000000 --- a/usr.bin/elvis/doc/title.ms +++ /dev/null @@ -1,35 +0,0 @@ -.de tE -.ps 80 -.ce 1 -\*E -.. -.de nE -.ce 7 -:: ####### :: -::: # # # # # #### ::: -:::: # # # # # # :::: -::::: ##### # # # # #### ::::: -:::: # # # # # # :::: -::: # # # # # # # ::: -:: ####### ###### ## # #### :: -.. - -.sp |2.5i -.if t .tE -.if n .nE -.ps 10 -.sp 1 -.ce 2 -- a clone of vi/ex - -version \*V -.sp |7.5i -.IP Author: 0.9i -Steve Kirkendall -.br -14407 SW Teal Blvd., Apt C -.br -Beaverton, OR 97005 -.IP E-Mail: 0.9i -kirkenda@cs.pdx.edu -.IP Phone: 0.9i -(503) 643-6980 diff --git a/usr.bin/elvis/doc/ver.ms b/usr.bin/elvis/doc/ver.ms deleted file mode 100644 index 2ce756cbb2da..000000000000 --- a/usr.bin/elvis/doc/ver.ms +++ /dev/null @@ -1,14 +0,0 @@ -.ds V 1.7 -.if t .ds E E\s'-2'LVIS\s'0' -.if n .ds E Elvis -.\" -.\" usage: .Go -.de Go -.ds LH "\\$1-\\\\n% -.ds RH "\\$1-\\\\n% -.ds CH "\\$2 -.NH S \\$1 -\\$2 -.\"if !\\n%=1 .bp 1 -.if n .ul 0 -.. diff --git a/usr.bin/elvis/doc/versions.ms b/usr.bin/elvis/doc/versions.ms deleted file mode 100644 index 7137d9da36ef..000000000000 --- a/usr.bin/elvis/doc/versions.ms +++ /dev/null @@ -1,405 +0,0 @@ -.Go 13 "VERSIONS" -.PP -\*E currently works under BSD UNIX, AT&T System-V UNIX, SCO XENIX, -Minix, Coherent, MS-DOS, Atari TOS, OS9/68k, VAX/VMS, and AmigaDos. -This section of the manual provides special information that applies to each -particular version of \*E. -.PP -For all versions except MS-DOS and VMS, -the file "Makefile.mix" should be copied to "Makefile", -and then edited to select the correct set of options for your system. -There is more information about this embedded in the file itself. -.NH 2 -BSD UNIX -.PP -Temporary files are stored in /tmp. -.PP -You should modify /etc/rc so that -the temp files are preserved when the system is rebooted. -Find a line in /etc/rc which reads -.sp -.ti +0.5i -ex4.3preserve /tmp -.LP -or something like that, and append the following line: -.sp -.ti +0.5i -elvprsv /tmp/elv* -.PP -If you do not have permission to modify /etc/rc, don't fret. -The above modification is only needed to allow you to recover your changes -after a system crash. -You can still run \*E without that modification, -and you can still recover your changes when \*E crashes -or when your dialup modem looses the carrier signal, or something like that. -Only a system crash or power failure could hurt you. -.PP -Both \*E and the real Vi -read initialization commands from a file called ".exrc", -but the commands in that file might work on one editor but not the other. -For example, "set keywordprg=man" will work for \*E, -but Vi will complain because it doesn't have a "keywordprg" option. -If the warning messages annoy you, then you can edit the CFLAGS setting -in the Makefile and add -DEXRC=\\".elvisrc\\". -.PP -If you use X windows, you may wish to add "-DCS_LATIN1" to CFLAGS. -This will cause the digraph table and the flipcase option to have default -values that are appropriate for the LATIN-1 character set. -That's the standard character set for X. -.PP -The default mailer used notify users when text is preserver is "mail". -You may wish to change this to "Mail" (with an uppercase 'M'). -See the description of "MAILER" in the CFLAGS section of this manual. -.PP -The default keyboard macro time-out value is larger for BSD than it is for -some other systems, because I've had trouble running \*E via rlogin or Xterm. -I guess it takes a while for those keystokes to squirt through the net. -.NH 2 -System-V UNIX -.PP -Most SysV UNIX systems use terminfo instead of termcap, -but the terminfo library doesn't seem to have a standard name. -As shipped, \*E' Makefile.mix is configured with "LIBS=-ltermcap". -You may need to change it to "LIBS=-lterm" or "LIBS=-lterminfo" -or even "LIBS=-lcurses". -.PP -The /etc/rc file (or its equivelent) should be modified as described -for BSD systems, above. -There's a pretty good chance that "make install" will do this for you; -it knows how to create an editor recovery file in the /etc/rc2.d directory, -which is where most modern SysV systems store initialization commands. -You only need to do it manually for older SysV systems. -.PP -The potential trouble with ".exrc" described above for BSD UNIX applies -to System-V UNIX as well. -.PP -The default mailer used notify users when text is preserver is "mail". -You may wish to change this to "mailx". -See the description of "MAILER" in the CFLAGS section of this manual. -.PP -\*E uses control-C as the interrupt key, not Delete. -This was done so that the <Del> key could be used for character deletion. -.NH 2 -SCO Xenix -.PP -For Xenix-386, you can use the generic System-V settings. -You may wish to add "-DCS_IBMPC" to CFLAGS, to have the digraph table and -flipcase option start up in a mode that is appropriate for the console. -Also, note that there is a separate group of settings for use with Xenix-286. -It already has "-DCS_IBMPC" in CFLAGS. -.PP -Because Xenix is so similar to System-V, everything I said earlier about -System-V applies to the Xenix version too, except that editor recovery -might belong in a directory called /etc/rc.d/8 instead. -.NH 2 -Minix -.PP -There are separate settings in Makefile.mix for Minix-PC and Minix-68k. -The differences between these two are that -the 68k version uses ".o" for the object file extension where -the PC version uses ".s", and -the PC version has some extra flags in CFLAGS to reduce the size of \*E. -The PC version also uses tinytcap (instead of the full termcap) -to make it smaller. -.PP -Minix-PC users should read the CFLAGS section of this manual very carefully. -You have some choices to make... -.PP -The temporary files are stored in /usr/tmp. -The /usr/tmp directory must exist before you run \*E, -and it must be readable & writable by everybody. -We use /usr/tmp instead of /tmp because -after a system crash or power failure, -you can recover the altered version of a file from the temporary file -in /usr/tmp. -If it was stored in /tmp, though, then it would be lost because /tmp is -normally located on the RAM disk. -Also, you'll need a /usr/preserve directory which is readable & writable -by root; -this directory is used to store text files that have been preserved after a -crash. -The "make install" script will create it if necessary. -.PP -\*E uses control-C as the interrupt key, not Delete. -.NH 2 -Coherent -.PP -\*E was ported to Coherent by Esa Ahola. -.PP -\*E is too large to run under Coherent unless you eliminate some -features via the CFLAGS setting. -The recommended settings, in Makefile.mix, produce a working version -of \*E which emulates Vi faithfully, but lacks most of the extensions. -You should read the CFLAGS section of this manual carefully. -.PP -You can probably reduce the size of \*E by using tinytcap.c instead of -lterm. -This would allow you to keep most features of \*E, -at the expense of terminal independence. -(Tinytcap.c has ANSI escape sequences hard-coded into it.) -To use tinytcap, just add "tinytcap.o" to the "EXTRA=" line in the Makefile, -and remove "-lterm" from the "LIBS=" line. -.PP -The temporary files are stored in /tmp. -Preserved files are stored in /usr/preserve. -You should modify your /etc/rc file to support file file preservation; -add the line... -.sp - /usr/bin/elvprsv /tmp/* -.sp -... just before the first "/bin/rm" line. -.NH 2 -MS-DOS -.PP -\*E was ported to MS-DOS by Guntram Blohm and Martin Patzel. -Willett Kempton added support for the DEC Rainbow. -.PP -Ideally, \*E should be compiled with Microsoft C 5.10 and the standard -Microsoft Make utility, -via the command "make elvis.mak". -This will compile \*E and all related utilities. -.PP -With Microsoft C 6.00, you may have trouble compiling regexp.c. -If so, try compiling it without optimization. -.PP -The "Makefile.mix" file contains a set of suggested settings for compiling -\*E with Turbo-C or Borland C. -(If you have Turbo-C, but not the Make utility, -then you can \fIalmost\fR use the "\*E.prj" file to compile \*E, -but you must explicitly force Turbo-C to compile it with the "medium" memory model. -Most of the related programs [ctags, ref, virec, refont, and wildcard] are -only one file long, so you should have no trouble compiling them.) -The "alias.c" file is meant to be compiled once into an executable named -"ex.exe". -You should then copy "ex.exe" to "vi.exe" and "view.exe". -.PP -\*E stores its temporary files in C:\\tmp. -If this is not satisfactory, then you should edit the CFLAGS line of -your Makefile to change TMPDIR to something else before compiling. -You can also control the name of the temp directory via an environment -variable named TMP or TEMP. -The directory must exist before you can run \*E. -.PP -The TERM environment variable determines how \*E will write to the screen. -It can be set to any one of the following values: -.LD -.ta 1.5i 2.5i - pcbios Use BIOS calls on an IBM-PC clone. - rainbow Use DEC Rainbow interface. - ansi Use ANSI.SYS driver. - nansi User faster NANSI.SYS driver. -.DE -.PP -If the TERM variable isn't set, then \*E will automatically select either -the "rainbow" interface (when run on a Rainbow) or "pcbios" (on an IBM clone). -.PP -You may prefer to use NANSI.SYS for speed; -or you may NEED to use ANSI.SYS for a non-clone, such as a lap-top. -If so, you should -install one of these drivers by adding "driver = nansi.sys" (or whatever) -to your CONFIG.SYS file, -and then you should define TERM to be "nansi" (or whatever) by adding -"set TERM=nansi" to your AUTOEXEC.BAT file. -You must then reboot for these changes to take effect. -After that, \*E will notice the "TERM" setting and use the driver. -.PP -Since ".exrc" is not a valid DOS filename, -the name of the initialization file has been changed to "elvis.rc". -\*E will look for an "elvis.rc" file first in your home directory. -If it exists, and contains ":set exrc", then \*E will check for -another "elvis.rc" in the current directory. -By default, the directory where ELVIS.EXE resides is taken to be your -home directory. -You can override this default by setting an environment variable named -"HOME" to the full pathname of your home directory. -To set "HOME", you would typically add the following line to your -AUTOEXEC.BAT file: -.br -.ti +0.5i -set HOME c:\\ -.PP -An extra program, called "wildcard", is needed for MS-DOS. -It expands wildcard characters in file names. -If \*E flashes a "Bad command or filename" message when it starts, -then you've probably lost the WILDCARD.EXE program somehow. -.PP -\*E can run under Windows, but you may have trouble with TEMP. -Windows uses an environment variable called TEMP which interferes with -\*E' usage of TEMP; -to work around this, you can simply set an environment variable named -TMP (with no 'E') to the name of \*E' temporary directory. -When TEMP and TMP are both set, \*E uses TMP and ignored TEMP. -.NH 2 -Atari TOS -.PP -\*E was ported to Atari TOS by Guntram Blohm and Martin Patzel. -It is very similar to the MS-DOS version. -It has been tested with the Mark Williams C compiler and also GNU-C. -.PP -The TERM environment variable is ignored; -the ST port always assumes that TERM=vt52. -The SHELL (not COMSPEC!) variable should be set to -the name of a line-oriented shell. -.PP -A simple shell in included with \*E. -Its source is in "shell.c", and the name of the executable is "shell.ttp". -The file "profile.sh" should contain a set of instructions to be executed -when the shell first starts up. -An example of this file is included, but you will almost certainly want to -edit it right away to match your configuration. -(If you already have a command-line shell, -then you'll probably want to continue using it. -The shell that comes with \*E is very limited.) -.PP -Currently, character attributes cannot be displayed on the screen. -.PP -\*E runs under MiNT (a free multi-tasking extension to TOS) -but it can be a CPU hog because of the way that \*E reads from the -keyboard with timeout. -Also, \*E doesn't use any of the special features of MiNT. -I have received a set of patches that optimize \*E for MiNT, -but they arrived too late to integrate into this release. -.NH 2 -OS9/68k -.PP -\*E was ported to OS9/68k by Peter Reinig. -.PP -The Makefile is currently configured to install \*E and the related -programs in /dd/usr/cmds -If this this is unacceptable, then you should change the BIN setting -to some other directory. -Similarly, it expects the source code to reside in /dd/usr/src/elvis; -the ODIR setting is used to control this. -.PP -Temporary files are stored in the /dd/tmp directory. -Your /dd/startup file may need to be modified -to prevent it from deleting \*E' temporary files; -make /dd/startup run the \fIelvprsv\fR program before it wipes out /dd/tmp. -.PP -The program in alias.c is linked repeatedly to produce the -"vi", "view", and "input" aliases for \*E. -Sadly, the "ex" alias is impossible to implement under OS9 -because the shell has a built-in command by that name. -.PP -For some purposes, -you must give `make' the "-b" option. -Specifically, you need this for "make -b clean" and "make -b install". -.NH 2 -VAX/VMS -.PP -John Campbell ported \*E to VAX/VMS. -.PP -A heavily laden VAX can take half an hour to compile \*E. -This is normal. -Don't panic. -.PP -While running, \*E will create temporary files in SYS$SCRATCH. -Enter SHOW LOGICAL SYS$SCRATCH to see what actual directory you are using. -Many sites have SYS$SCRATCH equivalenced to SYS$LOGIN. -The \*E temporary files look like the following on VMS while \*E is running: -.br -.ti 0.75i -ELV_1123A.1;1 ELV_1123A.2;1 SO070202.;1 -.PP -Also, filtering commands (like !!dir and !}fmt) should work on VMS. -This assumes, however, that you can create temporary mailboxes and that -your mailbox quota (a sysgen parameter) is at least 256 bytes for a -single write to the mailbox. -This is the default sysgen parameter, -so there should be few people who experience filter problems. -.PP -Additionally, an attempt was made to support the standard terminals on VMS: -"vt52", "vt100", "vt200", "vt300", "vt101", "vt102". -Non-standard terminals could be supported by setting your terminal type to -UNKNOWN (by entering SET TERM/UNKNOWN) -and defining the logical name ELVIS_TERM. -Whatever ELVIS_TERM translates to, however, will have to be included in -tinytcap.c. -Note that the upper/lowercase distinctions are significant, -and that DCL will upshift characters that are not quoted strings, so -enter DEFINE ELVIS_TERM "hp2621a". -As distributed, it would probably not be a good idea to have more than the -standard terminals in tinytcap.c (else it wouldn't be tiny, would it?). -Changes here, of course, would require a recompilation to take effect. -.PP -If you have a version of the "termcap" library and database on your system, -then you may wish to replace tinytcap with the real termcap. -.NH 2 -AmigaDOS -.PP -Mike Rieser and Dale Rahn ported \*E to AmigaDOS. -.PP -The port was done using Manx Aztec C version 5.2b. -\*E uses about as much space as it can and still be small code and data. -\*E should also compile under DICE, though there may be a little trouble with -signed versus unsigned chars. -.PP -The port has been done so the same binary will run under both versions of AmigaDOS. -Under AmigaDOS 2.04, \*E supports all the documented features. -It also uses an external program ref to do tag lookup. -So, the accompanying programs: ref and ctags are recommended. -Under AmigaDOS 1.2/1.3 \*E works, buts lacks the more advanced features. -.PP -For the port to AmigaDOS 2.04, we tried to use as many Native AmigaDOS -calls as we could. -This should increase \*E's chances at being compiled with other compilers. -DICE seems to have a different default char type. -You may need to use the UCHAR() macro in tio.c. -To test it, try the :map command; if it looks right, things are cool. -.PP -For the port to AmigaDOS 1.3, we tried to make sure the program was at -least usable. -Many features are missing, most notably running commands in subshells. -Also, what we could get working, we used Aztec functions to support them, -so this part is little more compiler dependent. -.PP -Aztec is compatible with the SAS libcall #pragma. -I personally prefer using the includes that come from Commodore over the ones -supplied with Aztec, but for people with a straight Aztec installation, -I went with the default names for the Aztec pragmas. -.PP -One include you'll need is <sys/types.h>. -It's a common include when porting software just make yourself one. -It's a two line file that saves a lot of hassle especially in the \*E source. -So, make a directory where your includes are located called `sys' -and in a file below that type: -.br -.ti +0.8i -/* sys/types.h */ -.br -.ti +0.8i -#include <exec/types.h> -.PP -When setting environment variables (either local or global) for -variables that specify a directory, make sure the variable ends in `:' -or `/'. -This saved from having to change much of the way \*E works. -The default temporary directory (if TEMP and TMP aren't specified) is "T:". -The default if HOME directory (if no HOME environment variable is set) is "S:". -.PP -To avoid conlict with other uses, \*E uses elvis.rc instead of .exrc or -where it looks for macros. -.NH 2 -Other Systems -.PP -For SunOS and Solaris 1.x, use the BSD settings; -for Solaris 2.x, use the SysV settings. -Earlier versions of \*E didn't link correctly due to a quirk in Sun's -version of the "make" utility, but this version of \*E has a work-around -for that quirk so you should have no trouble at all. -.PP -For Linux, use the SysV settings. -You can probably just remove the "-lterm" from the "LIBS= -lterm" line, -since linux keeps the termcap functions in the standard C library. -.PP -For other UNIXoid systems, I suggest you start with the Minix-68k settings -and then grow from that. -Minix is a nice starting point because it is a clone of Version 7 UNIX, -which was the last common ancestor of BSD UNIX and SysV UNIX. -Any Operating System which claims any UNIX compatibility what so ever -will therefore support V7/Minix code. -You may need to fiddle with #include directives or something, though. -Minix-68k is a better starting point than Minix-PC because the PC compiler -has some severe quirks. -.PP -If you're thinking of porting \*E to some non-UNIX system, -I suggest you begin by studying the "INTERNALS" section of this manual. diff --git a/usr.bin/elvis/doc/visual.ms b/usr.bin/elvis/doc/visual.ms deleted file mode 100644 index 18f216e9e73c..000000000000 --- a/usr.bin/elvis/doc/visual.ms +++ /dev/null @@ -1,297 +0,0 @@ -.Go 2 "VISUAL MODE COMMANDS" -.PP -Most visual mode commands are one keystroke long. -The following table lists the operation performed by each keystroke, -and also denotes any options or arguments that it accepts. -Notes at the end of the table describe the notation used in this table. -.PP -In addition to the keys listed here, your keyboard's "arrow" keys -will be interpretted as the appropriate cursor movement commands. -The same goes for <PgUp> and <PgDn>, if your keyboard has them. -The <Insert> key will toggle between insert mode and replace mode. -There is a colon mode command (":map", to be described later) -which will allow you to define other keys, such as function keys. -.PP -A tip: visual command mode looks a lot like text input mode. -If you forget which mode you're in, just hit the <Esc> key. -If \*E beeps, then you're in visual command mode. -If \*E does not beep, then you were in input mode, -but by hitting <Esc> you will have switched to visual command mode. -So, one way or another, after <Esc> \*E will be ready for a command. -.LD -.ta 0.7i 1.3i -\s'+2'COMMAND DESCRIPTION\s'-2' - ^A Search for next occurence of word at cursor (MOVE)(EXT) - ^B Move toward the top of the file by 1 screenful - ^C --- (usually sends SIGINT, to interupt a command) -count ^D Scroll down <count> lines (default 1/2 screen) -count ^E Scroll up <count> lines - ^F Move toward the bottom of the file by 1 screenful - ^G Show file status, and the current line # -count ^H Move left, like h (MOVE) - ^I --- -count ^J Move down (MOVE) - ^K --- - ^L Redraw the screen -count ^M Move to the front of the next line (MOVE) -count ^N Move down (MOVE) - ^O --- -count ^P Move up (MOVE) - ^Q --- (typically XON, which restarts screen updates) - ^R Redraw the screen - ^S --- (typically XOFF, which stops screen updates) - ^T --- -count ^U Scroll up <count> lines (default 1/2 screen) - ^V --- - ^W --- -count ^X Move to a physical column number on the screen (MOVE) (EXT) -count ^Y Scroll down <count> lines - ^Z --- (sometimes sends SIGSUSP, to suspend execution) - ESC --- - ^\\ --- (usually sends SIGQUIT, which is ignored) - ^] If the cursor is on a tag name, go to that tag - ^^ Switch to the previous file, like ":e #" - ^_ --- -count SPC Move right,like l (MOVE) - ! \s'-2'mv\s'+2' Run the selected lines thru an external filter program - " \s'-2'key\s'+2' Select which cut buffer to use next -count # \s'-2'+\s'+2' Increment a number (EDIT) (EXT) - $ Move to the rear of the current line (MOVE) -count % Move to matching (){}[] or to a given % of file (MOVE) (EXT) -count & Repeat the previous ":s//" command here (EDIT) - ' \s'-2'key\s'+2' Move to a marked line (MOVE) -count ( Move backward <count> sentences (MOVE) -count ) Move forward <count> sentences (MOVE) - * Go to the next error in the errlist (EXT) -count + Move to the front of the next line (MOVE) -count , Repeat the previous [fFtT] but in the other direction (MOVE) -count - Move to the front of the preceding line (MOVE) -count . Repeat the previous "edit" command - / \s'-2'text\s'+2' Search forward for a given regular expression (MOVE) - 0 If not part of count, move to 1st char of this line (MOVE) - 1 Part of count - 2 Part of count - 3 Part of count - 4 Part of count - 5 Part of count - 6 Part of count - 7 Part of count - 8 Part of count - 9 Part of count - : \s'-2'text\s'+2' Run single EX cmd -count ; Repeat the previous [fFtT] cmd (MOVE) - < \s'-2'mv\s'+2' Shift text left (EDIT) - = \s'-2'mv\s'+2' Reformat - > \s'-2'mv\s'+2' Shift text right (EDIT) - ? \s'-2'text\s'+2' Search backward for a given regular expression (MOVE) - @ \s'-2'key\s'+2' Execute the contents of a cut-buffer as VI commands -count A \s'-2'inp\s'+2' Append at end of the line (EDIT) -count B Move back Word (MOVE) - C \s'-2'inp\s'+2' Change text from the cursor through the end of the line (EDIT) - D Delete text from the cursor through the end of the line (EDIT) -count E Move end of Word (MOVE) -count F \s'-2'key\s'+2' Move leftward to a given character (MOVE) -count G Move to line #<count> (default is the bottom line) (MOVE) -count H Move to home row (the line at the top of the screen) -count I \s'-2'inp\s'+2' Insert at the front of the line (after indents) (EDIT) -count J Join lines, to form one big line (EDIT) - K Look up keyword (EXT) -count L Move to last row (the line at the bottom of the screen) - M Move to middle row - N Repeat previous search, but in the opposite direction (MOVE) -count O \s'-2'inp\s'+2' Open up a new line above the current line (EDIT) - P Paste text before the cursor (EDIT) - Q Quit to EX mode - R \s'-2'inp\s'+2' Overtype (EDIT) -count S \s'-2'inp\s'+2' Change lines, like <count>cc -count T \s'-2'key\s'+2' Move leftward *almost* to a given character (MOVE) - U Undo all recent changes to the current line - V Start marking lines for c/d/y/</>/!/\\ (EXT) -count W Move forward <count> Words (MOVE) -count X Delete the character(s) to the left of the cursor (EDIT) -count Y Yank text line(s) (copy them into a cut buffer) - Z Z Save the file & exit - [ [ Move back 1 section (MOVE) - \\ \s'-2'mv\s'+2' Pop-up menu for modifying text (EXT) - ] ] Move forward 1 section (MOVE) - ^ Move to the front of the current line (after indent) (MOVE) -count _ Move to the current line - ` \s'-2'key\s'+2' Move to a marked character (MOVE) -count a \s'-2'inp\s'+2' Insert text after the cursor (EDIT) -count b Move back <count> words (MOVE) - c \s'-2'mv\s'+2' Change text (EDIT) - d \s'-2'mv\s'+2' Delete text (EDIT) -count e Move forward to the end of the current word (MOVE) -count f \s'-2'key\s'+2' Move rightward to a given character (MOVE) - g --- -count h Move left (MOVE) -count i \s'-2'inp\s'+2' Insert text at the cursor (EDIT) -count j Move down (MOVE) -count k Move up (MOVE) -count l Move right (MOVE) - m \s'-2'key\s'+2' Mark a line or character - n Repeat the previous search (MOVE) -count o \s'-2'inp\s'+2' Open a new line below the current line (EDIT) - p Paste text after the cursor (EDIT) - q --- -count r \s'-2'key\s'+2' Replace <count> chars by a given character (EDIT) -count s \s'-2'inp\s'+2' Replace <count> chars with text from the user (EDIT) -count t \s'-2'key\s'+2' Move rightward *almost* to a given character (MOVE) - u Undo the previous edit command - v Start marking characters for c/d/y/</>/!/\\ (EXT) -count w Move forward <count> words (MOVE) -count x Delete the character that the cursor's on (EDIT) - y \s'-2'mv\s'+2' Yank text (copy it into a cut buffer) - z \s'-2'key\s'+2' Scroll current line to the screen's +=top -=bottom .=middle -count { Move back <count> paragraphs (MOVE) -count | Move to column <count> (the leftmost column is 1) -count } Move forward <count> paragraphs (MOVE) -count ~ Switch a character between uppercase & lowercase (EDIT) - DEL --- (usually mapped to shift-X, so it deletes one character) -.DE -.IP count 0.7i -Many commands may be preceded by a count. This is a sequence of digits -representing a decimal number. For most commands that use a count, -the command is repeated <count> times. The count is always optional, -and usually defaults to 1. -.IP key 0.7i -Some commands require two keystrokes. The first key always determines -which command is to be executed. The second key is used as a parameter -to the command. -.IP mv 0.7i -Some commands (! < > c d y \\ =) operate on text between the cursor and some -other position. -There are three ways that you can specifify that other position. -.IP "" 0.7i -The first way is to follow the command keystroke with a movement command. -For example, "dw" deletes a single word. -"d3w" and "3dw" both delete three words. -.IP "" 0.7i -The second way is to type the command keystroke twice. -This causes whole lines to be acted upon. -For example, ">>" indents the current line. -"3>>" indents the current line and the following two lines. -.IP "" 0.7i -The last way is to move the cursor to one end of the text, -type 'v' or 'V' to start marking, -move the cursor to the other end, -and then type the desired command key. -.IP inp 0.7i -Many commands allow the user to interactively enter text. -See the discussion of "input mode" in the following section. -.IP (EXT) 0.7i -These commands are extensions -- the real vi doesn't have them. -.IP (EDIT) 0.7i -These commands affect text, and may be repeated by the "." command. -.IP (MOVE) 0.7i -These commands move the cursor, and may be used to specify the extent -of a member of the "mv" class of commands. -.NH 2 -Input Mode -.PP -You can't type text into your file directly from visual command mode. -Instead, you must first give a command which will put you into input mode. -The commands to do this are A/C/I/O/R/S/a/i/o/s. -.PP -The S/s/C/c commands temporarily place a $ at the end of the text that -they are going to change. -.PP -In input mode, all keystrokes are inserted into the text at the -cursor's position, except for the following: -.ID -^A insert a copy of the last input text -^D delete one indent character -^H (backspace) erase the character before the cursor -^L redraw the screen -^M (carriage return) insert a newline (^J, linefeed) -^O execute next key as a visual command (limited!) -^P insert the contents of the cut buffer -^R redraw the screen, like ^L -^T insert an indent character -^U backspace to the beginning of the line -^V insert the following keystroke, even if special -^W backspace to the beginning of the current word -^Z^Z write the file & exit \*E -^[ (ESCape) exit from input mode, back to command mode -.DE -.PP -Also, on some systems, ^S may stop output, ^Q may restart output, -and ^C may interupt execution. -^@ (the NUL character) cannot be inserted. -.PP -The R visual command puts you in overtype mode, -which is a slightly different form of input mode. -In overtype mode, each time you insert a character, -one of the old characters is deleted from the file. -.NH 2 -Arrow keys in Input Mode -.PP -The arrow keys can be used to move the cursor in input mode. -(This is an extension; the real Vi doesn't support arrow keys in input mode.) -The <PgUp>, <PgDn>, <Home>, and <End> keys work in input mode, too. -The <Delete> key deletes a single character in input mode. -The <Insert> key toggles between input mode and replace mode. -.PP -The best thing about allowing arrow keys to work in input mode is that -as long as you're in input mode, -\*E seems to have a fairly ordinary user interface. -With most other text editors, you are always in either insert mode or -replace mode, and you can use the arrow keys at any time to move the cursor. -Now, \*E can act like that, too. -In fact, with the new "inputmode" option and the "control-Z control-Z" input -command, you may never have to go into visual command mode for simple edit -sessions. -.NH 2 -Digraphs -.PP -\*E supports digraphs as a way to enter non-ASCII characters. -A digraph is a character which is composed of two other characters. -For example, an apostrophe and the letter i could be defined as a digraph -which is to be stored & displayed as an accented i. -.PP -There is no single standard for extended ASCII character sets. -\*E can be compiled to fill the digraph with values appropriate for -either the IBM PC character set, or the LATIN-1 character set used by -X windows, or neither. -(See the discussions of -DCS_IBMPC and -DCS_LATIN1 in the CFLAGS section -of this manual.) -You can view or edit the digraph table via the ":digraph" colon command. -.PP -Digraphs will not be recognized until you've entered ":set digraph". -.PP -To actually use a digraph -type the first character, then hit <Backspace>, and then type the -second character. -\*E will then substitute the non-ASCII character in their place. -.NH 2 -Abbreviations -.PP -\*E can expand abbreviations for you. -You define an abbreviation with the :abbr command, -and then whenever you type in the abbreviated form while in input mode, -\*E will immediately replace it with the long form. -COBOL programmers should find this useful. :-) -.PP -\*E doesn't perform the substitution until you type a non-alphanumeric -character to mark the end of the word. -If you type a control-V before that non-alphanumeric character, then -\*E will not perform the substitution. -.NH 2 -Auto-Indent -.PP -With the ":set autoindent" option turned on, -\*E will automatically insert leading whitespace at the beginning of each -new line that you type in. -The leading whitespace is copied from the preceding line. -.PP -To add more leading whitespace, type control-T. -To remove some whitespace, type control-D. -.PP -If you ":set noautotab", then the whitespace generated by control-T will -always consist of spaces -- never tabs. -Some people seem to prefer this. -.PP -\*E' autoindent mode isn't 100% compatible with vi's. -In \*E, 0^D and ^^D don't work, -^U can wipeout all indentation, -and sometimes \*E will use a different amount of indentation than vi would. diff --git a/usr.bin/elvis/elvis.1 b/usr.bin/elvis/elvis.1 deleted file mode 100644 index be5c821e5595..000000000000 --- a/usr.bin/elvis/elvis.1 +++ /dev/null @@ -1,150 +0,0 @@ -.\" $Id: elvis.1,v 1.3 1993/08/02 17:53:52 mycroft Exp $ -*- nroff -*- -.TH ELVIS 1 -.SH NAME -elvis, ex, vi, view, input - The editor -.SH SYNOPSIS -\fBelvis\fP [\fIflags\fP] [\fB+\fP\fIcmd\fP] [\fIfiles\fP...] -.SH DESCRIPTION -\fIElvis\fP is a text editor which emulates \fIvi\fP/\fIex\fP. -.PP -On systems which pass the program name as an argument, such as Unix and Minix, -you may also install \fIelvis\fP under the names "ex", "vi", "view", and "input". -These extra names would normally be links to elvis; -see the "ln" shell command. -.PP -When \fIelvis\fP is invoked as "vi", -it behaves exactly as though it was invoked as "elvis". -However, if you invoke \fIelvis\fP as "view", -then the readonly option is set as though you had given it the "-R" flag. -If you invoke \fIelvis\fP as "ex", -then \fIelvis\fP will start up in the colon command mode -instead of the visual command mode, -as though you had given it the "-e" flag. -If you invoke \fIelvis\fP as "input" or "edit", -then \fIelvis\fP will start up in input mode, -as though the "-i" flag was given. -.SH OPTIONS -.IP \fB-r\fP -To the real vi, this flag means that a previous edit should be recovered. -\fIElvis\fP, though, has a separate program, called \fIelvrec(1)\fP, for recovering -files. -When you invoke \fIelvis\fP with -r, \fIelvis\fP will tell you to run \fIelvrec\fP. -.IP \fB-R\fP -This sets the "readonly" option, -so you won't accidentally overwrite a file. -.IP "\fB-t\fP \fItag\fP" -This causes \fIelvis\fP to start editing at the given tag. -.IP "\fB-m\fP [\fIfile\fP]" -\fIElvis\fP will search through \fIfile\fP for something that looks like -an error message from a compiler. -It will then begin editing the source file that caused the error, -with the cursor sitting on the line where the error was detected. -If you don't explicitly name a \fIfile\fP, then "errlist" is assumed. -.IP \fB-e\fP -\fIElvis\fP will start up in colon command mode. -.IP \fB-v\fP -\fIElvis\fP will start up in visual command mode. -.IP \fB-i\fP -\fIElvis\fP will start up in input mode. -.IP "\fB-w\fR \fIwinsize\fR" -Sets the "window" option's value to \fIwinsize\fR. -.IP "\fB+\fP\fIcommand\fP or \fB-c\fP \fIcommand\fP" -If you use the +\fIcommand\fP parameter, -then after the first file is loaded -\fIcommand\fP is executed as an EX command. -A typical example would be "elvis +237 foo", -which would cause \fIelvis\fP to start editing foo and -then move directly to line 237. -The "-c \fIcommand\fP" variant was added for UNIX SysV compatibility. -.SH FILES -.IP /tmp/elv* -During editing, -\fIelvis\fP stores text in a temporary file. -For UNIX, this file will usually be stored in the /tmp directory, -and the first three characters will be "elv". -For other systems, the temporary files may be stored someplace else; -see the version-specific section of the documentation. -.IP tags -This is the database used by the \fI:tags\fP command and the \fB-t\fP option. -It is usually created by the \fIctags(1)\fP program. -.IP ".exrc or elvis.rc" -On UNIX-like systems, a file called ".exrc" in your home directory -is executed as a series of \fIex\fR commands. -A file by the same name may be executed in the current directory, too. -On non-UNIX systems, ".exrc" is usually an invalid file name; -there, the initialization file is called "elvis.rc" instead. -.SH ENVIRONMENT -.IP TERM -This is the name of your terminal's entry in the termcap or terminfo -database. -The list of legal values varies from one system to another. -.IP TERMCAP -Optional. -If your system uses termcap, and the TERMCAP variable is unset, then -\*E will read your terminal's definition from \fB/etc/termcap\fR. -If TERMCAP is set to the full pathname of a file (starting with a '/') -then \*E will look in the named file instead of \fB/etc/termcap\fR. -If TERMCAP is set to a value which doesn't start with a '/', -then its value is assumed to be the full termcap entry for your terminal. -.IP TERMINFO -Optional. -If your system uses terminfo, and the TERMINFO variable is unset, then -\*E will read your terminal's definition from the database in the -\fB/usr/lib/terminfo\fR database. -If TERMINFO is set, then its value is used as the database name to use -instead of \fB/usr/lib/terminfo\fR. -.IP "LINES, COLUMNS" -Optional. -These variables, if set, will override the screen size values given in -the termcap/terminfo for your terminal. -On windowing systems such as X, \*E has other ways of determining the -screen size, so you should probably leave these variables unset. -.IP EXINIT -Optional. -This variable can hold EX commands which will be executed before any .exrc -files. -.IP SHELL -Optional. -The SHELL variable sets the default value for the "shell" option, -which determines which shell program is used to perform wildcard -expansion in file names, and also which is used to execute filters -or external programs. -The default value on UNIX systems is "/bin/sh". -.IP -Note: Under MS-DOS, this variable is called COMSPEC instead of SHELL. -.IP HOME -This variable should be set to the name of your home directory. -\*E looks for its initialization file there; -if HOME is unset then the initialization file will not be executed. -.IP TAGPATH -Optional. -This variable is used by the "ref" program, which is invoked by the shift-K, -control-], and :tag commands. -See "ref" for more information. -.IP "TMP, TEMP" -These optional environment variables are only used in non-UNIX versions -of \*E. -They allow you to supply a directory name to be used for storing temporary files. -.SH "SEE ALSO" -ctags(1), ref(1), virec(1) -.PP -\fIElvis - A Clone of Vi/Ex\fP, the complete \fIelvis\fP documentation. -.SH BUGS -There is no LISP support. -Certain other features are missing, too. -.PP -Auto-indent mode is not quite compatible with the real vi. -Among other things, 0^D and ^^D don't do what you might expect. -.PP -Long lines are displayed differently. -The real vi wraps long lines onto multiple rows of the screen, -but \fIelvis\fP scrolls sideways. -.SH AUTHOR -.nf -Steve Kirkendall -kirkenda@cs.pdx.edu -.fi -.PP -Many other people have worked to port \fIelvis\fP to various operating systems. -To see who deserves credit, run the \fI:version\fP command from within \fIelvis\fP, -or look in the system-specific section of the complete documentation. diff --git a/usr.bin/elvis/ex.c b/usr.bin/elvis/ex.c deleted file mode 100644 index 87e714c1f8ec..000000000000 --- a/usr.bin/elvis/ex.c +++ /dev/null @@ -1,775 +0,0 @@ -/* ex.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains the code for reading ex commands. */ - -#ifndef lint -static char rcsid[] = "$Id: ex.c,v 1.4 1993/08/02 17:53:53 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "ctype.h" -#include "vi.h" - -/* This data type is used to describe the possible argument combinations */ -typedef short ARGT; -#define FROM 1 /* allow a linespec */ -#define TO 2 /* allow a second linespec */ -#define BANG 4 /* allow a ! after the command name */ -#define EXTRA 8 /* allow extra args after command name */ -#define XFILE 16 /* expand wildcards in extra part */ -#define NOSPC 32 /* no spaces allowed in the extra part */ -#define DFLALL 64 /* default file range is 1,$ */ -#define DFLNONE 128 /* no default file range */ -#define NODFL 256 /* do not default to the current file name */ -#define EXRCOK 512 /* can be in a .exrc file */ -#define NL 1024 /* if mode!=MODE_EX, then write a newline first */ -#define PLUS 2048 /* allow a line number, as in ":e +32 foo" */ -#define ZERO 4096 /* allow 0 to be given as a line number */ -#define NOBAR 8192 /* treat following '|' chars as normal */ -#define FILES (XFILE + EXTRA) /* multiple extra files allowed */ -#define WORD1 (EXTRA + NOSPC) /* one extra word allowed */ -#define FILE1 (FILES + NOSPC) /* 1 file allowed, defaults to current file */ -#define NAMEDF (FILE1 + NODFL) /* 1 file allowed, defaults to "" */ -#define NAMEDFS (FILES + NODFL) /* multiple files allowed, default is "" */ -#define RANGE (FROM + TO) /* range of linespecs allowed */ -#define NONE 0 /* no args allowed at all */ - -/* This array maps ex command names to command codes. The order in which - * command names are listed below is significant -- ambiguous abbreviations - * are always resolved to be the first possible match. (e.g. "r" is taken - * to mean "read", not "rewind", because "read" comes before "rewind") - */ -static struct -{ - char *name; /* name of the command */ - CMD code; /* enum code of the command */ - void (*fn)();/* function which executes the command */ - ARGT argt; /* command line arguments permitted/needed/used */ -} - cmdnames[] = -{ /* cmd name cmd code function arguments */ - {"print", CMD_PRINT, cmd_print, RANGE+NL }, - - {"append", CMD_APPEND, cmd_append, FROM+ZERO+BANG }, -#ifdef DEBUG - {"bug", CMD_DEBUG, cmd_debug, RANGE+BANG+EXTRA+NL}, -#endif - {"change", CMD_CHANGE, cmd_append, RANGE+BANG }, - {"delete", CMD_DELETE, cmd_delete, RANGE+WORD1 }, - {"edit", CMD_EDIT, cmd_edit, BANG+FILE1+PLUS }, - {"file", CMD_FILE, cmd_file, NAMEDF }, - {"global", CMD_GLOBAL, cmd_global, RANGE+BANG+EXTRA+DFLALL+NOBAR}, - {"insert", CMD_INSERT, cmd_append, FROM+BANG }, - {"join", CMD_INSERT, cmd_join, RANGE+BANG }, - {"k", CMD_MARK, cmd_mark, FROM+WORD1 }, - {"list", CMD_LIST, cmd_print, RANGE+NL }, - {"move", CMD_MOVE, cmd_move, RANGE+EXTRA }, - {"next", CMD_NEXT, cmd_next, BANG+NAMEDFS }, - {"Next", CMD_PREVIOUS, cmd_next, BANG }, - {"quit", CMD_QUIT, cmd_xit, BANG }, - {"read", CMD_READ, cmd_read, FROM+ZERO+NAMEDF}, - {"substitute", CMD_SUBSTITUTE, cmd_substitute, RANGE+EXTRA }, - {"to", CMD_COPY, cmd_move, RANGE+EXTRA }, - {"undo", CMD_UNDO, cmd_undo, NONE }, - {"vglobal", CMD_VGLOBAL, cmd_global, RANGE+EXTRA+DFLALL+NOBAR}, - {"write", CMD_WRITE, cmd_write, RANGE+BANG+FILE1+DFLALL}, - {"xit", CMD_XIT, cmd_xit, BANG+NL }, - {"yank", CMD_YANK, cmd_delete, RANGE+WORD1 }, - - {"!", CMD_BANG, cmd_shell, EXRCOK+RANGE+NAMEDFS+DFLNONE+NL+NOBAR}, - {"#", CMD_NUMBER, cmd_print, RANGE+NL }, - {"<", CMD_SHIFTL, cmd_shift, RANGE }, - {">", CMD_SHIFTR, cmd_shift, RANGE }, - {"=", CMD_EQUAL, cmd_file, RANGE }, - {"&", CMD_SUBAGAIN, cmd_substitute, RANGE }, -#ifndef NO_AT - {"@", CMD_AT, cmd_at, EXTRA }, -#endif - -#ifndef NO_ABBR - {"abbreviate", CMD_ABBR, cmd_map, EXRCOK+BANG+EXTRA}, -#endif - {"args", CMD_ARGS, cmd_args, EXRCOK+NAMEDFS }, -#ifndef NO_ERRLIST - {"cc", CMD_CC, cmd_make, BANG+FILES }, -#endif - {"cd", CMD_CD, cmd_cd, EXRCOK+BANG+NAMEDF}, - {"copy", CMD_COPY, cmd_move, RANGE+EXTRA }, -#ifndef NO_DIGRAPH - {"digraph", CMD_DIGRAPH, cmd_digraph, EXRCOK+BANG+EXTRA}, -#endif -#ifndef NO_ERRLIST - {"errlist", CMD_ERRLIST, cmd_errlist, BANG+NAMEDF }, -#endif - {"ex", CMD_EDIT, cmd_edit, BANG+FILE1 }, - {"mark", CMD_MARK, cmd_mark, FROM+WORD1 }, -#ifndef NO_MKEXRC - {"mkexrc", CMD_MKEXRC, cmd_mkexrc, NAMEDF }, -#endif - {"number", CMD_NUMBER, cmd_print, RANGE+NL }, -#ifndef NO_TAGSTACK - {"pop", CMD_POP, cmd_pop, BANG+WORD1 }, -#endif - {"put", CMD_PUT, cmd_put, FROM+ZERO+WORD1 }, - {"set", CMD_SET, cmd_set, EXRCOK+EXTRA }, - {"shell", CMD_SHELL, cmd_shell, NL }, - {"source", CMD_SOURCE, cmd_source, EXRCOK+NAMEDF }, -#ifdef SIGTSTP - {"stop", CMD_STOP, cmd_suspend, NONE }, -#endif - {"tag", CMD_TAG, cmd_tag, BANG+WORD1 }, - {"version", CMD_VERSION, cmd_version, EXRCOK+NONE }, - {"visual", CMD_VISUAL, cmd_edit, BANG+NAMEDF }, - {"wq", CMD_WQUIT, cmd_xit, NL }, - -#ifdef DEBUG - {"debug", CMD_DEBUG, cmd_debug, RANGE+BANG+EXTRA+NL}, - {"validate", CMD_VALIDATE, cmd_validate, BANG+NL }, -#endif - {"chdir", CMD_CD, cmd_cd, EXRCOK+BANG+NAMEDF}, -#ifndef NO_COLOR - {"color", CMD_COLOR, cmd_color, EXRCOK+EXTRA }, -#endif -#ifndef NO_ERRLIST - {"make", CMD_MAKE, cmd_make, BANG+NAMEDFS }, -#endif - {"map", CMD_MAP, cmd_map, EXRCOK+BANG+EXTRA}, - {"previous", CMD_PREVIOUS, cmd_next, BANG }, - {"rewind", CMD_REWIND, cmd_next, BANG }, -#ifdef SIGTSTP - {"suspend", CMD_SUSPEND, cmd_suspend, NONE }, -#endif - {"unmap", CMD_UNMAP, cmd_map, EXRCOK+BANG+EXTRA}, -#ifndef NO_ABBR - {"unabbreviate",CMD_UNABBR, cmd_map, EXRCOK+WORD1 }, -#endif - - {(char *)0} -}; - - -/* This function parses a search pattern - given a pointer to a / or ?, - * it replaces the ending / or ? with a \0, and returns a pointer to the - * stuff that came after the pattern. - */ -char *parseptrn(ptrn) - REG char *ptrn; -{ - REG char *scan; - - for (scan = ptrn + 1; - *scan && *scan != *ptrn; - scan++) - { - /* allow backslashed versions of / and ? in the pattern */ - if (*scan == '\\' && scan[1] != '\0') - { - scan++; - } - } - if (*scan) - { - *scan++ = '\0'; - } - - return scan; -} - - -/* This function parses a line specifier for ex commands */ -char *linespec(s, markptr) - REG char *s; /* start of the line specifier */ - MARK *markptr; /* where to store the mark's value */ -{ - long num; - REG char *t; - - /* parse each ;-delimited clause of this linespec */ - do - { - /* skip an initial ';', if any */ - if (*s == ';') - { - s++; - } - - /* skip leading spaces */ - while (isspace(*s)) - { - s++; - } - - /* dot means current position */ - if (*s == '.') - { - s++; - *markptr = cursor; - } - /* '$' means the last line */ - else if (*s == '$') - { - s++; - *markptr = MARK_LAST; - } - /* digit means an absolute line number */ - else if (isdigit(*s)) - { - for (num = 0; isdigit(*s); s++) - { - num = num * 10 + *s - '0'; - } - *markptr = MARK_AT_LINE(num); - } - /* appostrophe means go to a set mark */ - else if (*s == '\'') - { - s++; - *markptr = m_tomark(cursor, 1L, (int)*s); - s++; - } - /* slash means do a search */ - else if (*s == '/' || *s == '?') - { - /* put a '\0' at the end of the search pattern */ - t = parseptrn(s); - - /* search for the pattern */ - *markptr &= ~(BLKSIZE - 1); - if (*s == '/') - { - pfetch(markline(*markptr)); - if (plen > 0) - *markptr += plen - 1; - *markptr = m_fsrch(*markptr, s); - } - else - { - *markptr = m_bsrch(*markptr, s); - } - - /* adjust command string pointer */ - s = t; - } - - /* if linespec was faulty, quit now */ - if (!*markptr) - { - return s; - } - - /* maybe add an offset */ - t = s; - if (*t == '-' || *t == '+') - { - s++; - for (num = 0; isdigit(*s); s++) - { - num = num * 10 + *s - '0'; - } - if (num == 0) - { - num = 1; - } - *markptr = m_updnto(*markptr, num, *t); - } - } while (*s == ';' || *s == '+' || *s == '-'); - - /* protect against invalid line numbers */ - num = markline(*markptr); - if (num < 1L || num > nlines) - { - msg("Invalid line number -- must be from 1 to %ld", nlines); - *markptr = MARK_UNSET; - } - - return s; -} - - - -/* This function reads an ex command and executes it. */ -void ex() -{ - char cmdbuf[150]; - REG int cmdlen; - static long oldline; - - significant = FALSE; - oldline = markline(cursor); - - while (mode == MODE_EX) - { - /* read a line */ -#ifdef CRUNCH - cmdlen = vgets(':', cmdbuf, sizeof(cmdbuf)); -#else - cmdlen = vgets(*o_prompt ? ':' : '\0', cmdbuf, sizeof(cmdbuf)); -#endif - if (cmdlen < 0) - { - return; - } - - /* if empty line, assume ".+1" */ - if (cmdlen == 0) - { - strcpy(cmdbuf, ".+1"); - qaddch('\r'); - clrtoeol(); - } - else - { - addch('\n'); - } - refresh(); - - /* parse & execute the command */ - doexcmd(cmdbuf); - - /* handle autoprint */ - if (significant || markline(cursor) != oldline) - { - significant = FALSE; - oldline = markline(cursor); - if (*o_autoprint && mode == MODE_EX) - { - cmd_print(cursor, cursor, CMD_PRINT, FALSE, ""); - } - } - } -} - -void doexcmd(cmdbuf) - char *cmdbuf; /* string containing an ex command */ -{ - REG char *scan; /* used to scan thru cmdbuf */ - MARK frommark; /* first linespec */ - MARK tomark; /* second linespec */ - REG int cmdlen; /* length of the command name given */ - CMD cmd; /* what command is this? */ - ARGT argt; /* argument types for this command */ - short forceit; /* bang version of a command? */ - REG int cmdidx; /* index of command */ - REG char *build; /* used while copying filenames */ - int iswild; /* boolean: filenames use wildcards? */ - int isdfl; /* using default line ranges? */ - int didsub; /* did we substitute file names for % or # */ - - /* ex commands can't be undone via the shift-U command */ - U_line = 0L; - - /* permit extra colons at the start of the line */ - for (; *cmdbuf == ':'; cmdbuf++) - { - } - - /* ignore command lines that start with a double-quote */ - if (*cmdbuf == '"') - { - return; - } - scan = cmdbuf; - - /* parse the line specifier */ - if (nlines < 1) - { - /* no file, so don't allow addresses */ - } - else if (*scan == '%') - { - /* '%' means all lines */ - frommark = MARK_FIRST; - tomark = MARK_LAST; - scan++; - } - else if (*scan == '0') - { - scan++; - frommark = tomark = (*scan ? MARK_UNSET : MARK_FIRST); - } - else - { - frommark = cursor; - scan = linespec(scan, &frommark); - tomark = frommark; - if (frommark && *scan == ',') - { - scan++; - scan = linespec(scan, &tomark); - } - if (!tomark) - { - /* faulty line spec -- fault already described */ - return; - } - if (frommark > tomark) - { - msg("first address exceeds the second"); - return; - } - } - isdfl = (scan == cmdbuf); - - /* skip whitespace */ - while (isspace(*scan)) - { - scan++; - } - - /* Figure out how long the command name is. If no command, then the - * length is 0, which will match the "print" command. - */ - if (!*scan) - { - /* if not in ex mode, and both endpoints are at the line, - * then just move to the start of that line without printing - */ - if (mode != MODE_EX && frommark == tomark) - { - if (tomark != MARK_UNSET) - cursor = tomark; - return; - } - cmdlen = 0; - } - else if (!isalpha(*scan)) - { - cmdlen = 1; - } - else - { - for (cmdlen = 1; - isalpha(scan[cmdlen]); - cmdlen++) - { - } - } - - /* lookup the command code */ - for (cmdidx = 0; - cmdnames[cmdidx].name && strncmp(scan, cmdnames[cmdidx].name, cmdlen); - cmdidx++) - { - } - argt = cmdnames[cmdidx].argt; - cmd = cmdnames[cmdidx].code; - if (cmd == CMD_NULL) - { - msg("Unknown command \"%.*s\"", cmdlen, scan); - return; - } - - /* !!! if the command doesn't have NOBAR set, then replace | with \0 */ - - /* if the command ended with a bang, set the forceit flag */ - scan += cmdlen; - if ((argt & BANG) && *scan == '!') - { - scan++; - forceit = 1; - } - else - { - forceit = 0; - } - - /* skip any more whitespace, to leave scan pointing to arguments */ - while (isspace(*scan)) - { - scan++; - } - - /* a couple of special cases for filenames */ - if (argt & XFILE) - { - /* if names were given, process them */ - if (*scan) - { - for (build = tmpblk.c, iswild = didsub = FALSE; *scan; scan++) - { - switch (*scan) - { - case '\\': - if (scan[1] == '\\' || scan[1] == '%' || scan[1] == '#') - { - *build++ = *++scan; - } - else - { - *build++ = '\\'; - } - break; - - case '%': - if (!*origname) - { - msg("No filename to substitute for %%"); - return; - } - strcpy(build, origname); - while (*build) - { - build++; - } - didsub = TRUE; - break; - - case '#': - if (!*prevorig) - { - msg("No filename to substitute for #"); - return; - } - strcpy(build, prevorig); - while (*build) - { - build++; - } - didsub = TRUE; - break; - - case '*': - case '?': -#if !(MSDOS || TOS) - case '[': - case '`': - case '{': /* } */ - case '$': - case '~': -#endif - *build++ = *scan; - iswild = TRUE; - break; - - default: - *build++ = *scan; - } - } - *build = '\0'; - - if (cmd == CMD_BANG - || cmd == CMD_READ && tmpblk.c[0] == '!' - || cmd == CMD_WRITE && tmpblk.c[0] == '!') - { - if (didsub) - { - if (mode != MODE_EX) - { - addch('\n'); - } - addstr(tmpblk.c); - addch('\n'); - exrefresh(); - } - } - else - { - if (iswild && tmpblk.c[0] != '>') - { - scan = wildcard(tmpblk.c); - } - } - } - else /* no names given, maybe assume origname */ - { - if (!(argt & NODFL)) - { - strcpy(tmpblk.c, origname); - } - else - { - *tmpblk.c = '\0'; - } - } - - scan = tmpblk.c; - } - - /* bad arguments? */ - if (!(argt & EXRCOK) && nlines < 1L) - { - msg("Can't use the \"%s\" command in a %s file", cmdnames[cmdidx].name, EXRC); - return; - } - if (!(argt & (ZERO | EXRCOK)) && frommark == MARK_UNSET) - { - msg("Can't use address 0 with \"%s\" command.", cmdnames[cmdidx].name); - return; - } - if (!(argt & FROM) && frommark != cursor && nlines >= 1L) - { - msg("Can't use address with \"%s\" command.", cmdnames[cmdidx].name); - return; - } - if (!(argt & TO) && tomark != frommark && nlines >= 1L) - { - msg("Can't use a range with \"%s\" command.", cmdnames[cmdidx].name); - return; - } - if (!(argt & EXTRA) && *scan) - { - msg("Extra characters after \"%s\" command.", cmdnames[cmdidx].name); - return; - } - if ((argt & NOSPC) && !(cmd == CMD_READ && (forceit || *scan == '!'))) - { - build = scan; -#ifndef CRUNCH - if ((argt & PLUS) && *build == '+') - { - while (*build && !isspace(*build)) - { - build++; - } - while (*build && isspace(*build)) - { - build++; - } - } -#endif /* not CRUNCH */ - for (; *build; build++) - { - if (isspace(*build)) - { - msg("Too many %s to \"%s\" command.", - (argt & XFILE) ? "filenames" : "arguments", - cmdnames[cmdidx].name); - return; - } - } - } - - /* some commands have special default ranges */ - if (isdfl && (argt & DFLALL)) - { - frommark = MARK_FIRST; - tomark = MARK_LAST; - } - else if (isdfl && (argt & DFLNONE)) - { - frommark = tomark = 0L; - } - - /* write a newline if called from visual mode */ - if ((argt & NL) && mode != MODE_EX && !exwrote) - { - addch('\n'); - exrefresh(); - } - - /* act on the command */ - (*cmdnames[cmdidx].fn)(frommark, tomark, cmd, forceit, scan); -} - - -/* This function executes EX commands from a file. It returns 1 normally, or - * 0 if the file could not be opened for reading. - */ -int doexrc(filename) - char *filename; /* name of a ".exrc" file */ -{ - int fd; /* file descriptor */ - int len; /* length of the ".exrc" file */ - -#ifdef CRUNCH - /* small address space - we need to conserve space */ - - /* !!! kludge: we use U_text as the buffer. This has the side-effect - * of interfering with the shift-U visual command. Disable shift-U. - */ - U_line = 0L; -#else -# if TINYSTACK -# if TOS || MINT - /* small stack, but big heap. Allocate buffer from heap */ - char *U_text = (char *)malloc(4096); - if (!U_text) - { - return 0; - } -# else - /* small stack - we need to conserve space */ - - /* !!! kludge: we use U_text as the buffer. This has the side-effect - * of interfering with the shift-U visual command. Disable shift-U. - */ - U_line = 0L; -# endif -# else - /* This is how we would *like* to do it -- with a large buffer on the - * stack, so we can handle large .exrc files and also recursion. - */ - char U_text[4096]; -# endif -#endif - - /* open the file, read it, and close */ - fd = open(filename, O_RDONLY); - if (fd < 0) - { -#if TINYSTACK && (TOS || MINT) - free(U_text); -#endif - return 0; - } -#if TINYSTACK && (TOS || MINT) - len = tread(fd, U_text, 4096); -#else - len = tread(fd, U_text, sizeof U_text); -#endif - close(fd); - - /* execute the string */ - exstring(U_text, len, ctrl('V')); - -#if TINYSTACK && (TOS || MINT) - free(U_text); -#endif - return 1; -} - -/* This function executes EX commands from a string. The commands may be - * separated by newlines or by | characters. It also handles quoting. - * Each individual command is limited to 132 bytes, but the total string - * may be longer. - */ -void exstring(buf, len, qchar) - char *buf; /* the commands to execute */ - int len; /* the length of the string */ - int qchar; /* the quote character -- ^V for file, or \ for kbd */ -{ - char single[133]; /* a single command */ - char *src, *dest; - int i; - - /* find & do each command */ - for (src = buf; src < &buf[len]; src++) - { - /* Copy a single command into single[]. Convert any quoted | - * into a normal |, and stop at a newline or unquoted |. - */ - for (dest = single, i = 0; - i < 132 && src < &buf[len] && *src != '\n' && *src != '|'; - src++, i++) - { - if (src[0] == qchar && src[1] == '|') - { - src++; - } - *dest++ = *src; - } - *dest = '\0'; - - /* do it */ - doexcmd(single); - } -} diff --git a/usr.bin/elvis/input.c b/usr.bin/elvis/input.c deleted file mode 100644 index 3a4461acb22a..000000000000 --- a/usr.bin/elvis/input.c +++ /dev/null @@ -1,876 +0,0 @@ -/* input.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains the input() function, which implements vi's INPUT mode. - * It also contains the code that supports digraphs. - */ - -#ifndef lint -static char rcsid[] = "$Id: input.c,v 1.3 1993/08/02 17:53:54 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "ctype.h" -#include "vi.h" - - -#ifndef NO_DIGRAPH -static struct _DIG -{ - struct _DIG *next; - char key1; - char key2; - char dig; - char save; -} *digs; - -char digraph(key1, key2) - int key1; /* the underlying character */ - int key2; /* the second character */ -{ - int newkey; - REG struct _DIG *dp; - - /* if digraphs are disabled, then just return the new char */ - if (!*o_digraph) - { - return key2; - } - - /* remember the new key, so we can return it if this isn't a digraph */ - newkey = key2; - - /* sort key1 and key2, so that their original order won't matter */ - if (key1 > key2) - { - key2 = key1; - key1 = newkey; - } - - /* scan through the digraph chart */ - for (dp = digs; - dp && (dp->key1 != key1 || dp->key2 != key2); - dp = dp->next) - { - } - - /* if this combination isn't in there, just use the new key */ - if (!dp) - { - return newkey; - } - - /* else use the digraph key */ - return dp->dig; -} - -/* this function lists or defines digraphs */ -void do_digraph(bang, extra) - int bang; - char extra[]; -{ - int dig; - REG struct _DIG *dp; - struct _DIG *prev; - static int user_defined = FALSE; /* boolean: are all later digraphs user-defined? */ - char listbuf[8]; - - /* if "extra" is NULL, then we've reached the end of the built-ins */ - if (!extra) - { - user_defined = TRUE; - return; - } - - /* if no args, then display the existing digraphs */ - if (*extra < ' ') - { - listbuf[0] = listbuf[1] = listbuf[2] = listbuf[5] = ' '; - listbuf[7] = '\0'; - for (dig = 0, dp = digs; dp; dp = dp->next) - { - if (dp->save || bang) - { - dig += 7; - if (dig >= COLS) - { - addch('\n'); - exrefresh(); - dig = 7; - } - listbuf[3] = dp->key1; - listbuf[4] = dp->key2; - listbuf[6] = dp->dig; - qaddstr(listbuf); - } - } - addch('\n'); - exrefresh(); - return; - } - - /* make sure we have at least two characters */ - if (!extra[1]) - { - msg("Digraphs must be composed of two characters"); - return; - } - - /* sort key1 and key2, so that their original order won't matter */ - if (extra[0] > extra[1]) - { - dig = extra[0]; - extra[0] = extra[1]; - extra[1] = dig; - } - - /* locate the new digraph character */ - for (dig = 2; extra[dig] == ' ' || extra[dig] == '\t'; dig++) - { - } - dig = extra[dig]; - if (!bang && dig) - { - dig |= 0x80; - } - - /* search for the digraph */ - for (prev = (struct _DIG *)0, dp = digs; - dp && (dp->key1 != extra[0] || dp->key2 != extra[1]); - prev = dp, dp = dp->next) - { - } - - /* deleting the digraph? */ - if (!dig) - { - if (!dp) - { -#ifndef CRUNCH - msg("%c%c not a digraph", extra[0], extra[1]); -#endif - return; - } - if (prev) - prev->next = dp->next; - else - digs = dp->next; - _free_(dp); - return; - } - - /* if necessary, create a new digraph struct for the new digraph */ - if (dig && !dp) - { - dp = (struct _DIG *)malloc(sizeof *dp); - if (!dp) - { - msg("Out of space in the digraph table"); - return; - } - if (prev) - prev->next = dp; - else - digs = dp; - dp->next = (struct _DIG *)0; - } - - /* assign it the new digraph value */ - dp->key1 = extra[0]; - dp->key2 = extra[1]; - dp->dig = dig; - dp->save = user_defined; -} - -# ifndef NO_MKEXRC -void savedigs(fd) - int fd; -{ - static char buf[] = "digraph! XX Y\n"; - REG struct _DIG *dp; - - for (dp = digs; dp; dp = dp->next) - { - if (dp->save) - { - buf[9] = dp->key1; - buf[10] = dp->key2; - buf[12] = dp->dig; - write(fd, buf, (unsigned)14); - } - } -} -# endif -#endif - - -/* This function allows the user to replace an existing (possibly zero-length) - * chunk of text with typed-in text. It returns the MARK of the last character - * that the user typed in. - */ -MARK input(from, to, when, delta) - MARK from; /* where to start inserting text */ - MARK to; /* extent of text to delete */ - int when; /* either WHEN_VIINP or WHEN_VIREP */ - int delta; /* 1 to take indent from lower line, -1 for upper, 0 for none */ -{ - char key[2]; /* key char followed by '\0' char */ - char *build; /* used in building a newline+indent string */ - char *scan; /* used while looking at the indent chars of a line */ - MARK m; /* some place in the text */ -#ifndef NO_EXTENSIONS - int quit = FALSE; /* boolean: are we exiting after this? */ - int inchg; /* boolean: have we done a "beforedo()" yet? */ -#endif - -#ifdef DEBUG - /* if "from" and "to" are reversed, complain */ - if (from > to) - { - msg("ERROR: input(%ld:%d, %ld:%d)", - markline(from), markidx(from), - markline(to), markidx(to)); - return MARK_UNSET; - } -#endif - - key[1] = 0; - - /* if we're replacing text with new text, save the old stuff */ - /* (Alas, there is no easy way to save text for replace mode) */ - if (from != to) - { - cut(from, to); - } - - /* if doing a dot command, then reuse the previous text */ - if (doingdot) - { - ChangeText - { - /* delete the text that's there now */ - if (from != to) - { - delete(from, to); - } - - /* insert the previous text */ - cutname('.'); - cursor = paste(from, FALSE, TRUE) + 1L; - } - } - else /* interactive version */ - { - /* assume that whoever called this already did a beforedo() */ -#ifndef NO_EXTENSIONS - inchg = TRUE; -#endif - - /* if doing a change within the line... */ - if (from != to && markline(from) == markline(to)) - { - /* mark the end of the text with a "$" */ - change(to - 1, to, "$"); - } - else - { - /* delete the old text right off */ - if (from != to) - { - delete(from, to); - } - to = from; - } - - /* handle autoindent of the first line, maybe */ - cursor = from; - m = cursor + MARK_AT_LINE(delta); - if (delta != 0 && *o_autoindent && markidx(m) == 0 - && markline(m) >= 1L && markline(m) <= nlines) - { - /* Only autoindent blank lines. */ - pfetch(markline(cursor)); - if (plen == 0) - { - /* Okay, we really want to autoindent */ - pfetch(markline(m)); - for (scan = ptext, build = tmpblk.c; - *scan == ' ' || *scan == '\t'; - ) - { - *build++ = *scan++; - } - if (build > tmpblk.c) - { - *build = '\0'; - add(cursor, tmpblk.c); - cursor += (int)(build - tmpblk.c); - if (cursor > to) - to = cursor; - } - } - } - - /* repeatedly add characters from the user */ - for (;;) - { - /* Get a character */ - redraw(cursor, TRUE); -#ifdef DEBUG2 - msg("cursor=%ld.%d, to=%ld.%d", - markline(cursor), markidx(cursor), - markline(to), markidx(to)); -#endif -#ifndef NO_ABBR - pfetch(markline(cursor)); - build = ptext; - if (pline == markline(from)) - build += markidx(from); - for (scan = ptext + markidx(cursor); --scan >= build && !isspace(*scan); ) - { - } - scan++; - key[0] = getabkey(when, scan, (int)(ptext + markidx(cursor) - scan)); -#else - key[0] = getkey(when); -#endif -#ifndef NO_VISIBLE - if (key[0] != ctrl('O') && V_from != MARK_UNSET) - { - msg("Can't modify text during a selection"); - beep(); - continue; - } -#endif - -#ifndef NO_EXTENSIONS - if (key[0] == ctrl('O')) - { - if (inchg) - { - if (cursor < to) - { - delete(cursor, to); - redraw(cursor, TRUE); - } - afterdo(); - inchg = FALSE; - } - } - else if (key[0] != ctrl('[')) - { - if (!inchg) - { - beforedo(FALSE); - inchg = TRUE; - } - } -#endif - -#ifndef CRUNCH - /* if wrapmargin is set & we're past the - * warpmargin, then change the last whitespace - * characters on line into a newline - */ - if (*o_wrapmargin) - { - pfetch(markline(cursor)); - if (plen == idx2col(cursor, ptext, TRUE) - && plen > COLS - (*o_wrapmargin & 0xff)) - { - build = tmpblk.c; - *build++ = '\n'; - if (*o_autoindent) - { - /* figure out indent for next line */ - for (scan = ptext; *scan == ' ' || *scan == '\t'; ) - { - *build++ = *scan++; - } - } - *build = '\0'; - - scan = ptext + plen; - m = cursor & ~(BLKSIZE - 1); - while (ptext < scan) - { - scan--; - if (*scan != ' ' && *scan != '\t') - continue; - - /*break up line, and we do autoindent if needed*/ - change(m + (int)(scan - ptext), m + (int)(scan - ptext) + 1, tmpblk.c); - - /* NOTE: for some reason, MSC 5.10 doesn't - * like for these lines to be combined!!! - */ - cursor = (cursor & ~(BLKSIZE - 1)); - cursor += BLKSIZE; - cursor += strlen(tmpblk.c) - 1; - cursor += plen - (int)(scan - ptext) - 1; - - /*remove trailing spaces on previous line*/ - pfetch(markline(m)); - scan = ptext + plen; - while (ptext < scan) - { - scan--; - if (*scan != ' ' && *scan != '\t') - break; - } - delete(m + (int)(scan - ptext) + 1, m + plen); - - break; - } - } - } -#endif /* !CRUNCH */ - - /* process it */ - switch (*key) - { -#ifndef NO_EXTENSIONS - case ctrl('O'): /* special movement mapped keys */ - *key = getkey(0); - switch (*key) - { - case 'h': m = m_left(cursor, 0L); break; - case 'j': - case 'k': m = m_updnto(cursor, 0L, *key); break; - case 'l': m = cursor + 1; break; - case 'B': - case 'b': m = m_bword(cursor, 0L, *key); break; - case 'W': - case 'w': m = m_fword(cursor, 0L, *key, '\0'); break; - case '^': m = m_front(cursor, 0L); break; - case '$': m = m_rear(cursor, 0L); break; - case ctrl('B'): - case ctrl('F'): - m = m_scroll(cursor, 0L, *key); break; - case 'x': -#ifndef NO_VISIBLE - if (V_from) - beep(); - else -#endif - ChangeText - { - m = v_xchar(cursor, 0L, 'x'); - } - break; - case 'i': m = to = from = cursor; - when = WHEN_VIINP + WHEN_VIREP - when; - break; - case 'K': - pfetch(markline(cursor)); - changes++; /* <- after this, we can alter ptext */ - ptext[markidx(cursor)] = 0; - for (scan = ptext + markidx(cursor) - 1; - scan >= ptext && isalnum(*scan); - scan--) - { - } - scan++; - m = (*scan ? v_keyword(scan, cursor, 0L) : cursor); - break; - -# ifndef NO_VISIBLE - case 'v': - case 'V': - if (V_from) - V_from = MARK_UNSET; - else - V_from = cursor; - m = from = to = cursor; - V_linemd = (*key == 'V'); - break; - - case 'd': - case 'y': - case '\\': - /* do nothing if unmarked */ - if (!V_from) - { - msg("You must mark the text first"); - beep(); - break; - } - - /* "from" must come before "to" */ - if (V_from < cursor) - { - from = V_from; - to = cursor; - } - else - { - from = cursor; - to = V_from; - } - - /* we don't need V_from anymore */ - V_from = MARK_UNSET; - - if (V_linemd) - { - /* adjust for line mode */ - from &= ~(BLKSIZE - 1); - to |= (BLKSIZE - 1); - } - else - { - /* in character mode, we must - * worry about deleting the newline - * at the end of the last line - */ - pfetch(markline(to)); - if (markidx(to) == plen) - to |= (BLKSIZE - 1); - } - to++; - - switch (*key) - { - case 'y': - cut(from, to); - break; - - case 'd': - ChangeText - { - cut(from, to); - delete(from, to); - } - cursor = from; - break; - -#ifndef NO_POPUP - case '\\': - ChangeText - { - cursor = v_popup(from, to); - } - break; -#endif - } - m = from = to = cursor; - break; - - case 'p': - case 'P': - V_from = MARK_UNSET; - ChangeText - { - m = paste(cursor, (*key == 'p'), FALSE); - } - break; -# endif /* !NO_VISIBLE */ - default: m = MARK_UNSET; - } - - /* adjust the moved cursor */ - if (m != cursor) - { - m = adjmove(cursor, m, (*key == 'j' || *key == 'k' ? NCOL|FINL : FINL)); - if (plen && (*key == '$' || (*key == 'l' && m <= cursor))) - { - m++; - } - } - - /* if the cursor is reasonable, use it */ - if (m == MARK_UNSET) - { - beep(); - } - else - { - from = to = cursor = m; - } - break; - - case ctrl('Z'): - if (getkey(0) == ctrl('Z')) - { - quit = TRUE; - goto BreakBreak; - } - break; -#endif - - case ctrl('['): - /* if last line contains only whitespace, then remove whitespace */ - if (*o_autoindent) - { - pfetch(markline(cursor)); - for (scan = ptext; isspace(*scan); scan++) - { - } - if (scan > ptext && !*scan) - { - cursor &= ~(BLKSIZE - 1L); - if (to < cursor + plen) - { - to = cursor + plen; - } - } - } - goto BreakBreak; - - case ctrl('U'): - if (markline(cursor) == markline(from)) - { - cursor = from; - } - else - { - cursor &= ~(BLKSIZE - 1); - } - break; - - case ctrl('D'): - case ctrl('T'): - if (to > cursor) - { - delete(cursor, to); - } - mark[27] = cursor; - cmd_shift(cursor, cursor, *key == ctrl('D') ? CMD_SHIFTL : CMD_SHIFTR, TRUE, ""); - if (mark[27]) - { - cursor = mark[27]; - } - else - { - cursor = m_front(cursor, 0L); - } - to = cursor; - break; - - case '\b': - if (cursor <= from) - { - beep(); - } - else if (markidx(cursor) == 0) - { - cursor -= BLKSIZE; - pfetch(markline(cursor)); - cursor += plen; - } - else - { - cursor--; - } - break; - - case ctrl('W'): - m = m_bword(cursor, 1L, 'b'); - if (markline(m) == markline(cursor) && m >= from) - { - cursor = m; - if (from > cursor) - { - from = cursor; - } - } - else - { - beep(); - } - break; - - case '\n': -#if OSK - case '\l': -#else - case '\r': -#endif - build = tmpblk.c; - *build++ = '\n'; - if (*o_autoindent) - { - /* figure out indent for next line */ - pfetch(markline(cursor)); - for (scan = ptext; *scan == ' ' || *scan == '\t'; ) - { - *build++ = *scan++; - } - - /* remove indent from this line, if blank */ - if ((int)(scan - ptext) >= markidx(cursor) && plen > 0) - { - to = cursor &= ~(BLKSIZE - 1); - delete(cursor, cursor + (int)(scan - ptext)); - } - -#if 0 - /* advance "to" past whitespace at the cursor */ - if (to >= cursor) - { - for (scan = ptext + markidx(cursor), to = cursor; *scan == ' ' || *scan == '\t'; scan++, to++) - { - } - } -#endif - } - *build = 0; - if (cursor >= to && when != WHEN_VIREP) - { - add(cursor, tmpblk.c); - } - else - { - change(cursor, to, tmpblk.c); - } - redraw(cursor, TRUE); - to = cursor = (cursor & ~(BLKSIZE - 1)) - + BLKSIZE - + (int)(build - tmpblk.c) - 1; - break; - - case ctrl('A'): - case ctrl('P'): - if (cursor < to) - { - delete(cursor, to); - } - if (*key == ctrl('A')) - { - cutname('.'); - } - m = paste(cursor, FALSE, TRUE); - if (m != MARK_UNSET) - { - to = cursor = m + 1L; - } - break; - - case ctrl('V'): - if (cursor >= to && when != WHEN_VIREP) - { - add(cursor, "^"); - } - else - { - change(cursor, to, "^"); - to = cursor + 1; - } - redraw(cursor, TRUE); - *key = getkey(0); - if (*key == '\n') - { - /* '\n' too hard to handle */ -#if OSK - *key = '\l'; -#else - *key = '\r'; -#endif - } - change(cursor, cursor + 1, key); - cursor++; - if (cursor > to) - { - to = cursor; - } - break; - - case ctrl('L'): - case ctrl('R'): - redraw(MARK_UNSET, FALSE); - break; - - default: - if (cursor >= to && when != WHEN_VIREP) - { - add(cursor, key); - cursor++; - to = cursor; - } - else - { - pfetch(markline(cursor)); - if (markidx(cursor) == plen) - { - add(cursor, key); - } - else - { -#ifndef NO_DIGRAPH - *key = digraph(ptext[markidx(cursor)], *key); -#endif - change(cursor, cursor + 1, key); - } - cursor++; - } -#ifndef NO_SHOWMATCH - /* show matching "({[" if necessary */ - if (*o_showmatch && strchr(")}]", *key)) - { - redraw(cursor, TRUE); - m = m_match(cursor - 1, 0L); - if (markline(m) >= topline - && markline(m) <= botline) - { - redraw(m, TRUE); - refresh(); - sleep(1); - } - } -#endif - } /* end switch(*key) */ - } /* end for(;;) */ -BreakBreak:; - /* delete any excess characters */ - if (cursor < to) - { -#ifndef NO_EXTENSIONS - /* if we aren't in the middle of a change, start one! */ - if (!inchg) - { - beforedo(FALSE); - inchg = TRUE; - } -#endif - delete(cursor, to); - } - - } /* end if doingdot else */ - - /* put the new text into a cut buffer for possible reuse */ - if (!doingdot) - { - blksync(); - cutname('.'); - cut(from, cursor); - } - - /* move to last char that we inputted, unless it was newline */ - if (markidx(cursor) != 0) - { - cursor--; - } - redraw(cursor, FALSE); - -#ifndef NO_EXTENSIONS - if (quit) - { - /* if this is a nested "do", then cut it short */ - abortdo(); - - /* exit, unless we can't write out the file */ - cursor = v_xit(cursor, 0L, 'Z'); - } -#endif - - rptlines = 0L; - return cursor; -} diff --git a/usr.bin/elvis/main.c b/usr.bin/elvis/main.c deleted file mode 100644 index c90f12917975..000000000000 --- a/usr.bin/elvis/main.c +++ /dev/null @@ -1,515 +0,0 @@ -/* main.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains the main() function of vi */ - -#ifndef lint -static char rcsid[] = "$Id: main.c,v 1.3 1993/08/02 17:53:55 mycroft Exp $"; -#endif /* not lint */ - - -/* HACK! bcc needs to disable use of precompiled headers for this file, - or else command line args will not be passed to elvis */ -#if __BORLANDC__ -#include "borland.h" -#endif - -#include "config.h" -#include <setjmp.h> -#include "vi.h" - -extern SIGTYPE trapint(); /* defined below */ -jmp_buf jmpenv; - -#ifndef NO_DIGRAPH -static init_digraphs(); -#endif - -/*---------------------------------------------------------------------*/ - -#if AMIGA -# include "amiwild.c" -main (argc, argv) -#else -# if VMS -# include "vmswild.c" -main (argc, argv) -# else -void main(argc, argv) -# endif -#endif - int argc; - char *argv[]; -{ - int i; - char *cmd = (char *)0; - char *err = (char *)0; - char *str; - char *tag = (char *)0; - - /* set mode to MODE_VI or MODE_EX depending on program name */ - switch (argv[0][strlen(argv[0]) - 1]) - { - case 'x': /* "ex" */ - mode = MODE_EX; - break; - - case 'w': /* "view" */ - mode = MODE_VI; - *o_readonly = TRUE; - break; -#ifndef NO_EXTENSIONS - case 't': /* "edit" or "input" */ - mode = MODE_VI; - *o_inputmode = TRUE; - break; -#endif - default: /* "vi" or "elvis" */ - mode = MODE_VI; - } - -#ifndef DEBUG -# ifdef SIGQUIT - /* normally, we ignore SIGQUIT. SIGINT is trapped later */ - signal(SIGQUIT, SIG_IGN); -# endif -#endif - - /* temporarily ignore SIGINT */ - signal(SIGINT, SIG_IGN); - - /* start curses */ - initscr(); - cbreak(); - noecho(); - scrollok(stdscr, TRUE); - - /* arrange for deadly signals to be caught */ -# ifdef SIGHUP - signal(SIGHUP, deathtrap); -# endif -# ifndef DEBUG -# ifdef SIGILL - signal(SIGILL, deathtrap); -# endif -# ifdef SIGBUS - signal(SIGBUS, deathtrap); -# endif -# ifdef SIGSEGV - signal(SIGSEGV, deathtrap); -# endif -# ifdef SIGSYS - signal(SIGSYS, deathtrap); -# endif -# endif /* !DEBUG */ -# ifdef SIGPIPE - signal(SIGPIPE, deathtrap); -# endif -# ifdef SIGTERM - signal(SIGTERM, deathtrap); -# endif -# ifdef SIGUSR1 - signal(SIGUSR1, deathtrap); -# endif -# ifdef SIGUSR2 - signal(SIGUSR2, deathtrap); -# endif - - /* initialize the options - must be done after initscr(), so that - * we can alter LINES and COLS if necessary. - */ - initopts(); - - /* map the arrow keys. The KU,KD,KL,and KR variables correspond to - * the :ku=: (etc.) termcap capabilities. The variables are defined - * as part of the curses package. - */ - if (has_KU) mapkey(has_KU, "k", WHEN_VICMD|WHEN_INMV, "<Up>"); - if (has_KD) mapkey(has_KD, "j", WHEN_VICMD|WHEN_INMV, "<Down>"); - if (has_KL) mapkey(has_KL, "h", WHEN_VICMD|WHEN_INMV, "<Left>"); - if (has_KR) mapkey(has_KR, "l", WHEN_VICMD|WHEN_INMV, "<Right>"); - if (has_HM) mapkey(has_HM, "^", WHEN_VICMD|WHEN_INMV, "<Home>"); - if (has_EN) mapkey(has_EN, "$", WHEN_VICMD|WHEN_INMV, "<End>"); - if (has_PU) mapkey(has_PU, "\002", WHEN_VICMD|WHEN_INMV, "<PageUp>"); - if (has_PD) mapkey(has_PD, "\006", WHEN_VICMD|WHEN_INMV, "<PageDn>"); - if (has_KI) mapkey(has_KI, "i", WHEN_VICMD|WHEN_INMV, "<Insert>"); -#if MSDOS -# if RAINBOW - if (!strcmp("rainbow", o_term)) - { - mapkey("\033[1~", "/", WHEN_VICMD, "<Find>"); - mapkey("\033[3~", "x", WHEN_VICMD|WHEN_INMV, "<Remove>"); - mapkey("\033[4~", "v", WHEN_VICMD|WHEN_INMV, "<Select>"); - mapkey("\033[17~", ":sh\n", WHEN_VICMD, "<Intrpt>"); - mapkey("\033[19~", ":q\n", WHEN_VICMD, "<Cancel>"); - mapkey("\033[21~", "ZZ", WHEN_VICMD, "<Exit>"); - mapkey("\033[26~", "V", WHEN_VICMD|WHEN_INMV, "<AddlOp>"); - mapkey("\033[28~", "\\", WHEN_VICMD|WHEN_INMV, "<Help>"); - mapkey("\033[29~", "K", WHEN_VICMD|WHEN_INMV, "<Do>"); - } - else -# endif /* RAINBOW */ - { - mapkey("#S", "x", WHEN_VICMD|WHEN_INMV, "<Delete>"); - mapkey("#s", "B", WHEN_VICMD|WHEN_INMV, "^<Left>"); - mapkey("#t", "W", WHEN_VICMD|WHEN_INMV, "^<Right>"); - } -#else /* not MSDOS */ -# if COHERENT - mapkey("\033[P", "x", WHEN_VICMD|WHEN_INMV, "<Del>"); -# else -#if AMIGA - mapkey("\233?~", "\\", WHEN_VICMD|WHEN_INMV, "<Help>"); -#endif - - if (ERASEKEY != '\177') - { - mapkey("\177", "x", WHEN_VICMD|WHEN_INMV, "<Del>"); - } -# endif -#endif - -#ifndef NO_DIGRAPH - init_digraphs(); -#endif /* NO_DIGRAPH */ - - /* process any flags */ - for (i = 1; i < argc && *argv[i] == '-'; i++) - { - switch (argv[i][1]) - { - case 'R': /* readonly */ - *o_readonly = TRUE; - break; - - case 'L': - case 'r': /* recover */ - msg("Use the `elvrec` program to recover lost files"); - endmsgs(); - refresh(); - endwin(); - exit(1); - break; - - case 't': /* tag */ - if (argv[i][2]) - { - tag = argv[i] + 2; - } - else - { - tag = argv[++i]; - } - break; - - case 'v': /* vi mode */ - mode = MODE_VI; - break; - - case 'e': /* ex mode */ - mode = MODE_EX; - break; -#ifndef NO_EXTENSIONS - case 'i': /* input mode */ - *o_inputmode = TRUE; - break; -#endif -#ifndef NO_ERRLIST - case 'm': /* use "errlist" as the errlist */ - if (argv[i][2]) - { - err = argv[i] + 2; - } - else if (i + 1 < argc) - { - err = argv[++i]; - } - else - { - err = ""; - } - break; -#endif -#ifndef CRUNCH - case 'c': /* run the following command, later */ - if (argv[i][2]) - { - cmd = argv[i] + 2; - } - else - { - cmd = argv[++i]; - } - break; - - case 'w': /* set the window size */ - if (argv[i][2]) - { - *o_window = atoi(argv[i] + 2); - wset = TRUE; - } - else - { - *o_window = atoi(argv[++i]); - wset = TRUE; - } - break; -#endif - default: - msg("Ignoring unknown flag \"%s\"", argv[i]); - } - } - - /* if we were given an initial ex command, save it... */ - if (i < argc && *argv[i] == '+') - { - if (argv[i][1]) - { - cmd = argv[i++] + 1; - } - else - { - cmd = "$"; /* "vi + file" means start at EOF */ - i++; - } - } - - /* the remaining args are file names. */ - if (i < argc) - { - strcpy(args, argv[i]); - while (++i < argc && strlen(args) + 1 + strlen(argv[i]) < sizeof args) - { - strcat(args, " "); - strcat(args, argv[i]); - } -#if MSDOS || TOS - /* expand wildcard characters, if necessary */ - if (strchr(args, '*') || strchr(args, '?')) - { - strcpy(args, wildcard(args)); - } -#endif - strcpy(tmpblk.c, args); - cmd_args(MARK_UNSET, MARK_UNSET, CMD_ARGS, TRUE, tmpblk.c); - } - else - { - /* empty args list */ - args[0] = '\0'; - nargs = 1; - argno = -1; - } - - /* perform the .exrc files and EXINIT environment variable */ -#ifdef SYSEXRC - doexrc(SYSEXRC); -#endif -#ifdef HMEXRC - str = gethome(argv[0]); - if (str && *str) - { - strcpy(tmpblk.c, str); - str = tmpblk.c + strlen(tmpblk.c); -#if !VMS -# if AMIGA /* Don't SLASH a device. "Elvis:.exrc" */ - if (str[-1] != COLON && str[-1] != SLASH) -# else - if (str[-1] != SLASH) -# endif - { - *str++ = SLASH; - } -#endif - strcpy(str, HMEXRC); - doexrc(tmpblk.c); - } -#endif -#ifndef CRUNCH - if (*o_exrc) -#endif - { - doexrc(EXRC); - } -#ifdef EXINIT - str = getenv(EXINIT); - if (str) - { - exstring(str, strlen(str), ctrl('V')); - } -#endif - - /* search for a tag (or an error) now, if desired */ - blkinit(); - if (tag) - { - cmd_tag(MARK_UNSET, MARK_FIRST, CMD_TAG, 0, tag); - } -#ifndef NO_ERRLIST - else if (err) - { - cmd_errlist(MARK_FIRST, MARK_FIRST, CMD_ERRLIST, 0, err); - } -#endif - - /* if no tag/err, or tag failed, then start with first arg */ - if (tmpfd < 0) - { - /* start with first arg */ - cmd_next(MARK_UNSET, MARK_UNSET, CMD_NEXT, FALSE, ""); - - /* pretend to do something, just to force a recoverable - * version of the file out to disk - */ - ChangeText - { - } - clrflag(file, MODIFIED); - } - - /* now we do the immediate ex command that we noticed before */ - if (cmd) - { - doexcmd(cmd); - } - - /* repeatedly call ex() or vi() (depending on the mode) until the - * mode is set to MODE_QUIT - */ - while (mode != MODE_QUIT) - { - if (setjmp(jmpenv)) - { - /* Maybe we just aborted a change? */ - abortdo(); - } - signal(SIGINT, trapint); - - switch (mode) - { - case MODE_VI: - vi(); - break; - - case MODE_EX: - ex(); - break; -#ifdef DEBUG - default: - msg("mode = %d?", mode); - mode = MODE_QUIT; -#endif - } - } - - /* free up the cut buffers */ - cutend(); - - /* end curses */ -#ifndef NO_CURSORSHAPE - if (has_CQ) - do_CQ(); -#endif - endmsgs(); - move(LINES - 1, 0); - clrtoeol(); - refresh(); - endwin(); - - exit(exitcode); - /*NOTREACHED*/ -} - - -/*ARGSUSED*/ -SIGTYPE trapint(signo) - int signo; -{ - beep(); - resume_curses(FALSE); - abortdo(); -#if OSK - sigmask(-1); -#endif - signal(signo, trapint); - doingglobal = FALSE; - - longjmp(jmpenv, 1); - /*NOTREACHED*/ -} - - - -#ifndef NO_DIGRAPH - -/* This stuff us used to build the default digraphs table. */ -static char digtable[][4] = -{ -# ifdef CS_IBMPC - "C,\200", "u\"\1", "e'\2", "a^\3", - "a\"\4", "a`\5", "a@\6", "c,\7", - "e^\10", "e\"\211", "e`\12", "i\"\13", - "i^\14", "i`\15", "A\"\16", "A@\17", - "E'\20", "ae\21", "AE\22", "o^\23", - "o\"\24", "o`\25", "u^\26", "u`\27", - "y\"\30", "O\"\31", "U\"\32", "a'\240", - "i'!", "o'\"", "u'#", "n~$", - "N~%", "a-&", "o-'", "~?(", - "~!-", "\"<.", "\">/", -# ifdef CS_SPECIAL - "2/+", "4/,", "^+;", "^q<", - "^c=", "^r>", "^t?", "pp]", - "^^^", "oo_", "*a`", "*ba", - "*pc", "*Sd", "*se", "*uf", - "*tg", "*Ph", "*Ti", "*Oj", - "*dk", "*Hl", "*hm", "*En", - "*No", "eqp", "pmq", "ger", - "les", "*It", "*iu", "*/v", - "*=w", "sq{", "^n|", "^2}", - "^3~", "^_\377", -# endif /* CS_SPECIAL */ -# endif /* CS_IBMPC */ -# ifdef CS_LATIN1 - "~!!", "a-*", "\">+", "o-:", - "\"<>", "~??", - - "A`@", "A'A", "A^B", "A~C", - "A\"D", "A@E", "AEF", "C,G", - "E`H", "E'I", "E^J", "E\"K", - "I`L", "I'M", "I^N", "I\"O", - "-DP", "N~Q", "O`R", "O'S", - "O^T", "O~U", "O\"V", "O/X", - "U`Y", "U'Z", "U^[", "U\"\\", - "Y'_", - - "a``", "a'a", "a^b", "a~c", - "a\"d", "a@e", "aef", "c,g", - "e`h", "e'i", "e^j", "e\"k", - "i`l", "i'm", "i^n", "i\"o", - "-dp", "n~q", "o`r", "o's", - "o^t", "o~u", "o\"v", "o/x", - "u`y", "u'z", "u^{", "u\"|", - "y'~", -# endif /* CS_LATIN1 */ - "" -}; - -static int init_digraphs() -{ - int i; - - for (i = 0; *digtable[i]; i++) - { - do_digraph(FALSE, digtable[i]); - } - do_digraph(FALSE, (char *)0); - return 0; -} -#endif /* NO_DIGRAPH */ diff --git a/usr.bin/elvis/misc.c b/usr.bin/elvis/misc.c deleted file mode 100644 index b0d826ff0e96..000000000000 --- a/usr.bin/elvis/misc.c +++ /dev/null @@ -1,108 +0,0 @@ -/* misc.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains functions which didn't seem happy anywhere else */ - -#ifndef lint -static char rcsid[] = "$Id: misc.c,v 1.3 1993/11/08 05:06:17 alm Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" - - -/* find a particular line & return a pointer to a copy of its text */ -char *fetchline(line) - long line; /* line number of the line to fetch */ -{ - int i; - REG char *scan; /* used to search for the line in a BLK */ - long l; /* line number counter */ - static BLK buf; /* holds ONLY the selected line (as string) */ - REG char *cpy; /* used while copying the line */ - static long nextline; /* } These four variables are used */ - static long chglevel; /* } to implement a shortcut when */ - static char *nextscan; /* } consecutive lines are fetched */ - static long nextlnum; /* } */ - - /* can we do a shortcut? */ - if (changes == chglevel && line == nextline) - { - scan = nextscan; - } - else - { - /* scan lnum[] to determine which block its in */ - for (i = 1; line > lnum[i]; i++) - { - } - nextlnum = lnum[i]; - - /* fetch text of the block containing that line */ - scan = blkget(i)->c; - - /* find the line in the block */ - for (l = lnum[i - 1]; ++l < line; ) - { - while (*scan++ != '\n') - { - } - } - } - - /* copy it into a block by itself, with no newline */ - for (cpy = buf.c; *scan != '\n'; ) - { - *cpy++ = *scan++; - } - *cpy = '\0'; - - /* maybe speed up the next call to fetchline() ? */ - if (line < nextlnum) - { - nextline = line + 1; - chglevel = changes; - nextscan = scan + 1; - } - else - { - nextline = 0; - } - - /* Calls to fetchline() interfere with calls to pfetch(). Make sure - * that pfetch() resets itself on its next invocation. - */ - pchgs = 0L; - - /* Return a pointer to the line's text */ - return buf.c; -} - - -/* error message from the regexp code */ -void regerr(txt) - char *txt; /* an error message */ -{ - msg("RE error: %s", txt); -} - -/* This function is equivelent to the pfetch() macro */ -void pfetch(l) - long l; /* line number of line to fetch */ -{ - if(l != pline || changes != pchgs) - { - pline = (l); - ptext = fetchline(pline); - plen = strlen(ptext); - pchgs = changes; - } -} diff --git a/usr.bin/elvis/modify.c b/usr.bin/elvis/modify.c deleted file mode 100644 index 78c3d34adc17..000000000000 --- a/usr.bin/elvis/modify.c +++ /dev/null @@ -1,479 +0,0 @@ -/* modify.c */ - -/* This file contains the low-level file modification functions: - * delete(frommark, tomark) - removes line or portions of lines - * add(frommark, text) - inserts new text - * change(frommark, tomark, text) - delete, then add - */ - -#ifndef lint -static char rcsid[] = "$Id: modify.c,v 1.3 1993/08/02 17:53:57 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" - -#ifdef DEBUG2 -# include <stdio.h> -static FILE *dbg; - -/*VARARGS1*/ -debout(msg, arg1, arg2, arg3, arg4, arg5) - char *msg, *arg1, *arg2, *arg3, *arg4, *arg5; -{ - if (!dbg) - { - dbg = fopen("debug.out", "w"); - if (!dbg) - return; - setbuf(dbg, (FILE *)0); - } - fprintf(dbg, msg, arg1, arg2, arg3, arg4, arg5); -} -#endif /* DEBUG2 */ - -/* delete a range of text from the file */ -void delete(frommark, tomark) - MARK frommark; /* first char to be deleted */ - MARK tomark; /* AFTER last char to be deleted */ -{ - int i; /* used to move thru logical blocks */ - REG char *scan; /* used to scan thru text of the blk */ - REG char *cpy; /* used when copying chars */ - BLK *blk; /* a text block */ - long l; /* a line number */ - MARK m; /* a traveling version of frommark */ - -#ifdef DEBUG2 - debout("delete(%ld.%d, %ld.%d)\n", markline(frommark), markidx(frommark), markline(tomark), markidx(tomark)); -#endif - - /* if not deleting anything, quit now */ - if (frommark == tomark) - { - return; - } - - /* This is a change */ - changes++; - significant = TRUE; - - /* supply clues to the redraw module */ - redrawrange(markline(frommark), markline(tomark), markline(frommark)); - - /* adjust marks 'a through 'z and '' as needed */ - l = markline(tomark); - for (i = 0; i < NMARKS; i++) - { - if (mark[i] < frommark) - { - continue; - } - else if (mark[i] < tomark) - { - mark[i] = MARK_UNSET; - } - else if (markline(mark[i]) == l) - { - if (markline(frommark) == l) - { - mark[i] -= markidx(tomark) - markidx(frommark); - } - else - { - mark[i] -= markidx(tomark); - } - } - else - { - mark[i] -= MARK_AT_LINE(l - markline(frommark)); - } - } - - /* Reporting... */ - if (markidx(frommark) == 0 && markidx(tomark) == 0) - { - rptlines = markline(tomark) - markline(frommark); - rptlabel = "deleted"; - } - - /* find the block containing frommark */ - l = markline(frommark); - for (i = 1; lnum[i] < l; i++) - { - } - - /* process each affected block... */ - for (m = frommark; - m < tomark && lnum[i] < INFINITY; - m = MARK_AT_LINE(lnum[i - 1] + 1)) - { - /* fetch the block */ - blk = blkget(i); - - /* find the mark in the block */ - scan = blk->c; - for (l = markline(m) - lnum[i - 1] - 1; l > 0; l--) - { - while (*scan++ != '\n') - { - } - } - scan += markidx(m); - - /* figure out where the changes to this block end */ - if (markline(tomark) > lnum[i]) - { - cpy = blk->c + BLKSIZE; - } - else if (markline(tomark) == markline(m)) - { - cpy = scan - markidx(m) + markidx(tomark); - } - else - { - cpy = scan; - for (l = markline(tomark) - markline(m); - l > 0; - l--) - { - while (*cpy++ != '\n') - { - } - } - cpy += markidx(tomark); - } - - /* delete the stuff by moving chars within this block */ - while (cpy < blk->c + BLKSIZE) - { - *scan++ = *cpy++; - } - while (scan < blk->c + BLKSIZE) - { - *scan++ = '\0'; - } - - /* adjust tomark to allow for lines deleted from this block */ - tomark -= MARK_AT_LINE(lnum[i] + 1 - markline(m)); - - /* if this block isn't empty now, then advance i */ - if (*blk->c) - { - i++; - } - - /* the buffer has changed. Update hdr and lnum. */ - blkdirty(blk); - } - - /* must have at least 1 line */ - if (nlines == 0) - { - blk = blkadd(1); - blk->c[0] = '\n'; - blkdirty(blk); - cursor = MARK_FIRST; - } -} - - -/* add some text at a specific place in the file */ -void add(atmark, newtext) - MARK atmark; /* where to insert the new text */ - char *newtext; /* NUL-terminated string to insert */ -{ - REG char *scan; /* used to move through string */ - REG char *build; /* used while copying chars */ - int addlines; /* number of lines we're adding */ - int lastpart; /* size of last partial line */ - BLK *blk; /* the block to be modified */ - int blkno; /* the logical block# of (*blk) */ - REG char *newptr; /* where new text starts in blk */ - BLK buf; /* holds chars from orig blk */ - BLK linebuf; /* holds part of line that didn't fit */ - BLK *following; /* the BLK following the last BLK */ - int i; - long l; - -#ifdef DEBUG2 - debout("add(%ld.%d, \"%s\")\n", markline(atmark), markidx(atmark), newtext); -#endif -#ifdef lint - buf.c[0] = 0; -#endif - /* if not adding anything, return now */ - if (!*newtext) - { - return; - } - - /* This is a change */ - changes++; - significant = TRUE; - - /* count the number of lines in the new text */ - for (scan = newtext, lastpart = addlines = 0; *scan; ) - { - if (*scan++ == '\n') - { - addlines++; - lastpart = 0; - } - else - { - lastpart++; - } - } - - /* Reporting... */ - if (lastpart == 0 && markidx(atmark) == 0) - { - rptlines = addlines; - rptlabel = "added"; - } - - /* extract the line# from atmark */ - l = markline(atmark); - - /* supply clues to the redraw module */ - if ((markidx(atmark) == 0 && lastpart == 0) || addlines == 0) - { - redrawrange(l, l, l + addlines); - } - else - { - /* make sure the last line gets redrawn -- it was - * split, so its appearance has changed - */ - redrawrange(l, l + 1L, l + addlines + 1L); - } - - /* adjust marks 'a through 'z and '' as needed */ - for (i = 0; i < NMARKS; i++) - { - if (mark[i] < atmark) - { - /* earlier line, or earlier in same line: no change */ - continue; - } - else if (markline(mark[i]) > l) - { - /* later line: move down a whole number of lines */ - mark[i] += MARK_AT_LINE(addlines); - } - else - { - /* later in same line */ - if (addlines > 0) - { - /* multi-line add, which split this line: - * move down, and possibly left or right, - * depending on where the split was and how - * much text was inserted after the last \n - */ - mark[i] += MARK_AT_LINE(addlines) + lastpart - markidx(atmark); - } - else - { - /* totally within this line: move right */ - mark[i] += lastpart; - } - } - } - - /* get the block to be modified */ - for (blkno = 1; lnum[blkno] < l && lnum[blkno + 1] < INFINITY; blkno++) - { - } - blk = blkget(blkno); - buf = *blk; - - /* figure out where the new text starts */ - for (newptr = buf.c, l = markline(atmark) - lnum[blkno - 1] - 1; - l > 0; - l--) - { - while (*newptr++ != '\n') - { - } - } - newptr += markidx(atmark); - - /* keep start of old block */ - build = blk->c + (int)(newptr - buf.c); - - /* fill this block (or blocks) from the newtext string */ - while (*newtext) - { - while (*newtext && build < blk->c + BLKSIZE - 1) - { - *build++ = *newtext++; - } - if (*newtext) - { - /* save the excess */ - for (scan = linebuf.c + BLKSIZE; - build > blk->c && build[-1] != '\n'; - ) - { - *--scan = *--build; - } - - /* write the block */ - while (build < blk->c + BLKSIZE) - { - *build++ = '\0'; - } - blkdirty(blk); - - /* add another block */ - blkno++; - blk = blkadd(blkno); - - /* copy in the excess from last time */ - for (build = blk->c; scan < linebuf.c + BLKSIZE; ) - { - *build++ = *scan++; - } - } - } - - /* fill this block(s) from remainder of orig block */ - while (newptr < buf.c + BLKSIZE && *newptr) - { - while (newptr < buf.c + BLKSIZE - && *newptr - && build < blk->c + BLKSIZE - 1) - { - *build++ = *newptr++; - } - if (newptr < buf.c + BLKSIZE && *newptr) - { - /* save the excess */ - for (scan = linebuf.c + BLKSIZE; - build > blk->c && build[-1] != '\n'; - ) - { - *--scan = *--build; - } - - /* write the block */ - while (build < blk->c + BLKSIZE) - { - *build++ = '\0'; - } - blkdirty(blk); - - /* add another block */ - blkno++; - blk = blkadd(blkno); - - /* copy in the excess from last time */ - for (build = blk->c; scan < linebuf.c + BLKSIZE; ) - { - *build++ = *scan++; - } - } - } - - /* see if we can combine our last block with the following block */ - if (lnum[blkno] < nlines && lnum[blkno + 1] - lnum[blkno] < (BLKSIZE >> 6)) - { - /* hey, we probably can! Get the following block & see... */ - following = blkget(blkno + 1); - if (strlen(following->c) + (build - blk->c) < (unsigned)(BLKSIZE - 1)) - { - /* we can! Copy text from following to blk */ - for (scan = following->c; *scan; ) - { - *build++ = *scan++; - } - while (build < blk->c + BLKSIZE) - { - *build++ = '\0'; - } - blkdirty(blk); - - /* pretend the following was the last blk */ - blk = following; - build = blk->c; - } - } - - /* that last block is dirty by now */ - while (build < blk->c + BLKSIZE) - { - *build++ = '\0'; - } - blkdirty(blk); -} - - -/* change the text of a file */ -void change(frommark, tomark, newtext) - MARK frommark, tomark; - char *newtext; -{ - int i; - long l; - char *text; - BLK *blk; - -#ifdef DEBUG2 - debout("change(%ld.%d, %ld.%d, \"%s\")\n", markline(frommark), markidx(frommark), markline(tomark), markidx(tomark), newtext); -#endif - - /* optimize for single-character replacement */ - if (frommark + 1 == tomark && newtext[0] && !newtext[1] && newtext[0] != '\n') - { - /* find the block containing frommark */ - l = markline(frommark); - for (i = 1; lnum[i] < l; i++) - { - } - - /* get the block */ - blk = blkget(i); - - /* find the line within the block */ - for (text = blk->c, i = l - lnum[i - 1] - 1; i > 0; text++) - { - if (*text == '\n') - { - i--; - } - } - - /* replace the char */ - text += markidx(frommark); - if (*text == newtext[0]) - { - /* no change was needed - same char */ - return; - } - else if (*text != '\n') - { - /* This is a change */ - changes++; - significant = TRUE; - ChangeText - { - *text = newtext[0]; - blkdirty(blk); - } - redrawrange(markline(frommark), markline(tomark), markline(frommark)); - return; - } - /* else it is a complex change involving newline... */ - } - - /* couldn't optimize, so do delete & add */ - ChangeText - { - delete(frommark, tomark); - add(frommark, newtext); - rptlabel = "changed"; - } -} diff --git a/usr.bin/elvis/move1.c b/usr.bin/elvis/move1.c deleted file mode 100644 index 79213dfe3bef..000000000000 --- a/usr.bin/elvis/move1.c +++ /dev/null @@ -1,623 +0,0 @@ -/* move1.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains most movement functions */ - -#ifndef lint -static char rcsid[] = "$Id: move1.c,v 1.3 1993/08/02 17:53:58 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" -#include "ctype.h" - -MARK m_updnto(m, cnt, cmd) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument */ - int cmd; /* the command character */ -{ - DEFAULT(cmd == 'G' ? nlines : 1L); - - /* move up or down 'cnt' lines */ - switch (cmd) - { - case ctrl('P'): - case '-': - case 'k': - m -= MARK_AT_LINE(cnt); - break; - - case 'G': - if (cnt < 1L || cnt > nlines) - { - msg("Only %ld lines", nlines); - return MARK_UNSET; - } - m = MARK_AT_LINE(cnt); - break; - - case '_': - cnt--; - /* fall through... */ - - default: - m += MARK_AT_LINE(cnt); - } - - /* if that left us screwed up, then fail */ - if (m < MARK_FIRST || markline(m) > nlines) - { - return MARK_UNSET; - } - - return m; -} - -/*ARGSUSED*/ -MARK m_right(m, cnt, key, prevkey) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument */ - int key; /* movement keystroke */ - int prevkey;/* operator keystroke, or 0 if none */ -{ - int idx; /* index of the new cursor position */ - - DEFAULT(1); - - /* If used with an operator, then move 1 less character, since the 'l' - * command includes the character that it moves onto. - */ - if (prevkey != '\0') - { - cnt--; - } - - /* move to right, if that's OK */ - pfetch(markline(m)); - idx = markidx(m) + cnt; - if (idx < plen) - { - m += cnt; - } - else - { - return MARK_UNSET; - } - - return m; -} - -/*ARGSUSED*/ -MARK m_left(m, cnt) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument */ -{ - DEFAULT(1); - - /* move to the left, if that's OK */ - if (markidx(m) >= cnt) - { - m -= cnt; - } - else - { - return MARK_UNSET; - } - - return m; -} - -/*ARGSUSED*/ -MARK m_tocol(m, cnt, cmd) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument */ - int cmd; /* either ctrl('X') or '|' */ -{ - char *text; /* text of the line */ - int col; /* column number */ - int idx; /* index into the line */ - - - /* if doing ^X, then adjust for sideways scrolling */ - if (cmd == ctrl('X')) - { - DEFAULT(*o_columns & 0xff); - cnt += leftcol; - } - else - { - DEFAULT(1); - } - - /* internally, columns are numbered 0..COLS-1, not 1..COLS */ - cnt--; - - /* if 0, that's easy */ - if (cnt == 0) - { - m &= ~(BLKSIZE - 1); - return m; - } - - /* find that column within the line */ - pfetch(markline(m)); - text = ptext; - for (col = idx = 0; col < cnt && *text; text++, idx++) - { - if (*text == '\t' && !*o_list) - { - col += *o_tabstop; - col -= col % *o_tabstop; - } - else if (UCHAR(*text) < ' ' || *text == '\177') - { - col += 2; - } -#ifndef NO_CHARATTR - else if (text[0] == '\\' && text[1] == 'f' && text[2] && *o_charattr) - { - text += 2; /* plus one more as part of for loop */ - } -#endif - else - { - col++; - } - } - if (!*text) - { - /* the desired column was past the end of the line, so - * act like the user pressed "$" instead. - */ - return m | (BLKSIZE - 1); - } - else - { - m = (m & ~(BLKSIZE - 1)) + idx; - } - return m; -} - -/*ARGSUSED*/ -MARK m_front(m, cnt) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument (ignored) */ -{ - char *scan; - - /* move to the first non-whitespace character */ - pfetch(markline(m)); - scan = ptext; - m &= ~(BLKSIZE - 1); - while (*scan == ' ' || *scan == '\t') - { - scan++; - m++; - } - - return m; -} - -/*ARGSUSED*/ -MARK m_rear(m, cnt) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument (ignored) */ -{ - /* Try to move *EXTREMELY* far to the right. It is fervently hoped - * that other code will convert this to a more reasonable MARK before - * anything tries to actually use it. (See adjmove() in vi.c) - */ - return m | (BLKSIZE - 1); -} - -#ifndef NO_SENTENCE -static int isperiod(ptr) - char *ptr; /* pointer to possible sentence-ender */ -{ - /* if not '.', '?', or '!', then it isn't a sentence ender */ - if (*ptr != '.' && *ptr != '?' && *ptr != '!') - { - return FALSE; - } - - /* skip any intervening ')', ']', or '"' characters */ - do - { - ptr++; - } while (*ptr == ')' || *ptr == ']' || *ptr == '"'); - - /* do we have two spaces or EOL? */ - if (!*ptr || ptr[0] == ' ' && ptr[1] == ' ') - { - return TRUE; - } - return FALSE; -} - -/*ARGSUSED*/ -MARK m_sentence(m, cnt, cmd) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument */ - int cmd; /* either '(' or ')' */ -{ - REG char *text; - REG long l; -#ifndef CRUNCH - /* figure out where the paragraph boundary is */ - MARK pp = m_paragraph(m, 1L, cmd=='(' ? '{' : '}'); -#endif - - DEFAULT(1); - - /* If '(' command, then move back one word, so that if we hit '(' at - * the start of a sentence we don't simply stop at the end of the - * previous sentence and bounce back to the start of this one again. - */ - if (cmd == '(') - { - m = m_bword(m, 1L, 'b'); - if (!m) - { - return m; - } - } - - /* get the current line */ - l = markline(m); - pfetch(l); - text = ptext + markidx(m); - - /* for each requested sentence... */ - while (cnt-- > 0) - { - /* search forward for one of [.?!] followed by spaces or EOL */ - do - { - if (cmd == ')') - { - /* move forward, wrap at end of line */ - if (!text[0]) - { - if (l == nlines) - { - goto BreakBreak; - } - l++; - pfetch(l); - text = ptext; - } - else - { - text++; - } - } - else - { - /* move backward, wrap at beginning of line */ - if (text == ptext) - { - do - { - if (l == 1L) - { - goto BreakBreak; - } - l--; - pfetch(l); - } while (!*ptext); - text = ptext + plen - 1; - } - else - { - text--; - } - } - } while (!isperiod(text)); - } -BreakBreak: - - /* construct a mark for this location */ - m = buildmark(text); - - /* move forward to the first word of the next sentence */ - m = m_fword(m, 1L, 'w', '\0'); - if (m == MARK_UNSET) - { - m = MARK_EOF; - } - -#ifndef CRUNCH - /* don't cross the paragraph boundary */ - if (pp && ((cmd=='(') ? (m<pp) : (m>pp))) - { - m = pp; - } -#endif - - return m; -} -#endif - -MARK m_paragraph(m, cnt, cmd) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument */ - int cmd; /* either '{' or '}' */ -{ - char *text; /* text of the current line */ - char *pscn; /* used to scan thru value of "paragraphs" option */ - long l, ol; /* current line number, original line number */ - int dir; /* -1 if we're moving up, or 1 if down */ - char col0; /* character to expect in column 0 */ - long limit; /* line where searching must stop */ -#ifndef NO_SENTENCE -# define SENTENCE(x) (x) - char *list; /* either o_sections or o_paragraph */ -#else -# define SENTENCE(x) -#endif -#ifndef CRUNCH - MARK ss; -#endif - - DEFAULT(1); - - /* set the direction, based on the command */ - switch (cmd) - { - case '{': - dir = -1; - col0 = '\0'; - SENTENCE(list = o_paragraphs); -#ifndef CRUNCH - ss = m_paragraph(m, 1L, '<'); - if (ss) - limit = markline(ss); - else -#endif - limit = 1L; - break; - - case '}': - dir = 1; - col0 = '\0'; - SENTENCE(list = o_paragraphs); -#ifndef CRUNCH - ss = m_paragraph(m, 1L, '>'); - if (ss) - limit = markline(ss); - else -#endif - limit = nlines; - break; - - case '[': - if (getkey(0) != '[') - { - return MARK_UNSET; - } - /* fall through... */ - case '<': - dir = -1; - col0 = '{'; - SENTENCE(list = o_sections); - limit = 1L; - break; - - case ']': - if (getkey(0) != ']') - { - return MARK_UNSET; - } - /* fall through... */ - case '>': - dir = 1; - col0 = '{'; - SENTENCE(list = o_sections); - limit = nlines; - break; - } - ol = l = markline(m); - - /* for each paragraph that we want to travel through... */ - while (l != limit && cnt-- > 0) - { - /* skip blank lines between paragraphs */ - while (l != limit && col0 == *(text = fetchline(l))) - { - l += dir; - } - - /* skip non-blank lines that aren't paragraph separators - */ - do - { -#ifndef NO_SENTENCE - if (*text == '.' && l != ol) - { - for (pscn = list; pscn[0] && pscn[1]; pscn += 2) - { - if (pscn[0] == text[1] && pscn[1] == text[2]) - { - pscn = (char *)0; - goto BreakBreak; - } - } - } -#endif - l += dir; - } while (l != limit && col0 != *(text = fetchline(l))); -BreakBreak: ; - } - - m = MARK_AT_LINE(l); -#ifdef DEBUG2 - debout("m_paragraph() returning %ld.%d\n", markline(m), markidx(m)); -#endif - return m; -} - - -/*ARGSUSED*/ -MARK m_match(m, cnt) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument (normally 0) */ -{ - long l; - REG char *text; - REG char match; - REG char nest; - REG int count; - -#ifndef NO_EXTENSIONS - /* if we're given a number, then treat it as a percentage of the file */ - if (cnt > 0) - { - /* make sure it is a reasonable number */ - if (cnt > 100) - { - msg("can only be from 1%% to 100%%"); - return MARK_UNSET; - } - - /* return the appropriate line number */ - l = (nlines - 1L) * cnt / 100L + 1L; - return MARK_AT_LINE(l); - } -#endif /* undef NO_EXTENSIONS */ - - /* get the current line */ - l = markline(m); - pfetch(l); - text = ptext + markidx(m); - - /* search forward within line for one of "[](){}" */ - for (match = '\0'; !match && *text; text++) - { - /* tricky way to recognize 'em in ASCII */ - nest = *text; - if ((nest & 0xdf) == ']' || (nest & 0xdf) == '[') - { - match = nest ^ ('[' ^ ']'); - } - else if ((nest & 0xfe) == '(') - { - match = nest ^ ('(' ^ ')'); - } - else - { - match = 0; - } - } - if (!match) - { - return MARK_UNSET; - } - text--; - - /* search forward or backward for match */ - if (match == '(' || match == '[' || match == '{') - { - /* search backward */ - for (count = 1; count > 0; ) - { - /* wrap at beginning of line */ - if (text == ptext) - { - do - { - if (l <= 1L) - { - return MARK_UNSET; - } - l--; - pfetch(l); - } while (!*ptext); - text = ptext + plen - 1; - } - else - { - text--; - } - - /* check the char */ - if (*text == match) - count--; - else if (*text == nest) - count++; - } - } - else - { - /* search forward */ - for (count = 1; count > 0; ) - { - /* wrap at end of line */ - if (!*text) - { - if (l >= nlines) - { - return MARK_UNSET; - } - l++; - pfetch(l); - text = ptext; - } - else - { - text++; - } - - /* check the char */ - if (*text == match) - count--; - else if (*text == nest) - count++; - } - } - - /* construct a mark for this place */ - m = buildmark(text); - return m; -} - -/*ARGSUSED*/ -MARK m_tomark(m, cnt, key) - MARK m; /* movement is relative to this mark */ - long cnt; /* (ignored) */ - int key; /* keystroke - the mark to move to */ -{ - /* mark '' is a special case */ - if (key == '\'' || key == '`') - { - if (mark[26] == MARK_UNSET) - { - return MARK_FIRST; - } - else - { - return mark[26]; - } - } - - /* if not a valid mark number, don't move */ - if (key < 'a' || key > 'z') - { - return MARK_UNSET; - } - - /* return the selected mark -- may be MARK_UNSET */ - if (!mark[key - 'a']) - { - msg("mark '%c is unset", key); - } - return mark[key - 'a']; -} - diff --git a/usr.bin/elvis/move2.c b/usr.bin/elvis/move2.c deleted file mode 100644 index 1bead6254ca5..000000000000 --- a/usr.bin/elvis/move2.c +++ /dev/null @@ -1,361 +0,0 @@ -/* move2.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This function contains the movement functions that perform RE searching */ - -#ifndef lint -static char rcsid[] = "$Id: move2.c,v 1.4 1993/11/08 05:06:20 alm Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" -#ifdef REGEX -# include <regex.h> -#else -# include "regexp.h" -#endif - -extern long atol(); - -#ifdef REGEX -static regex_t *re = NULL; /* compiled version of the pattern to search for */ -#else -static regexp *re; /* compiled version of the pattern to search for */ -#endif -static prevsf; /* boolean: previous search direction was forward? */ - -#ifndef NO_EXTENSIONS -/*ARGSUSED*/ -MARK m_wsrch(word, m, cnt) - char *word; /* the word to search for */ - MARK m; /* the starting point */ - int cnt; /* ignored */ -{ - char buffer[30]; - - /* wrap \< and \> around the word */ - strcpy(buffer, "/\\<"); - strcat(buffer, word); - strcat(buffer, "\\>"); - - /* show the searched-for word on the bottom line */ - move(LINES - 1, 0); - qaddstr(buffer); - clrtoeol(); - refresh(); - - /* search for the word */ - return m_fsrch(m, buffer); -} -#endif - -MARK m_nsrch(m, cnt, cmd) - MARK m; /* where to start searching */ - long cnt; /* number of searches to do */ - int cmd; /* command character -- 'n' or 'N' */ -{ - int oldprevsf; /* original value of prevsf, so we can fix any changes */ - - DEFAULT(1L); - - /* clear the bottom line. In particular, we want to loose any - * "(wrapped)" notice. - */ - move(LINES - 1, 0); - clrtoeol(); - - /* if 'N' command, then invert the "prevsf" variable */ - oldprevsf = prevsf; - if (cmd == 'N') - { - prevsf = !prevsf; - } - - /* search forward if prevsf -- i.e., if previous search was forward */ - while (--cnt >= 0L && m != MARK_UNSET) - { - if (prevsf) - { - m = m_fsrch(m, (char *)0); - } - else - { - m = m_bsrch(m, (char *)0); - } - } - - /* restore the old value of prevsf -- if cmd=='N' then it was inverted, - * and the m_fsrch() and m_bsrch() functions force it to a (possibly - * incorrect) value. The value of prevsf isn't supposed to be changed - * at all here! - */ - prevsf = oldprevsf; - return m; -} - - -MARK m_fsrch(m, ptrn) - MARK m; /* where to start searching */ - char *ptrn; /* pattern to search for */ -{ - long l; /* line# of line to be searched */ - char *line; /* text of line to be searched */ - int wrapped;/* boolean: has our search wrapped yet? */ - int pos; /* where we are in the line */ -#ifdef REGEX - regex_t *optpat(); - regmatch_t rm[SE_MAX]; - int n; -#endif -#ifndef CRUNCH - long delta = INFINITY;/* line offset, for things like "/foo/+1" */ -#endif - - /* remember: "previous search was forward" */ - prevsf = TRUE; - - if (ptrn && *ptrn) - { - /* locate the closing '/', if any */ - line = parseptrn(ptrn); -#ifndef CRUNCH - if (*line) - { - delta = atol(line); - } -#endif - ptrn++; - - -#ifdef REGEX - /* XXX where to free re? */ - re = optpat(ptrn); -#else - /* free the previous pattern */ - if (re) _free_(re); - - /* compile the pattern */ - re = regcomp(ptrn); -#endif - if (!re) - { - return MARK_UNSET; - } - } - else if (!re) - { - msg("No previous expression"); - return MARK_UNSET; - } - - /* search forward for the pattern */ - pos = markidx(m) + 1; - pfetch(markline(m)); - if (pos >= plen) - { - pos = 0; - m = (m | (BLKSIZE - 1)) + 1; - } - wrapped = FALSE; - for (l = markline(m); l != markline(m) + 1 || !wrapped; l++) - { - /* wrap search */ - if (l > nlines) - { - /* if we wrapped once already, then the search failed */ - if (wrapped) - { - break; - } - - /* else maybe we should wrap now? */ - if (*o_wrapscan) - { - l = 0; - wrapped = TRUE; - continue; - } - else - { - break; - } - } - - /* get this line */ - line = fetchline(l); - - /* check this line */ -#ifdef REGEX - if (!regexec(re, &line[pos], SE_MAX, rm, (pos == 0) ? 0 : REG_NOTBOL)) -#else - if (regexec(re, &line[pos], (pos == 0))) -#endif - { - /* match! */ - if (wrapped && *o_warn) - msg("(wrapped)"); -#ifndef CRUNCH - if (delta != INFINITY) - { - l += delta; - if (l < 1 || l > nlines) - { - msg("search offset too big"); - return MARK_UNSET; - } - force_flags = LNMD|INCL; - return MARK_AT_LINE(l); - } -#endif -#ifdef REGEX - return MARK_AT_LINE(l) + pos + rm[0].rm_so; -#else - return MARK_AT_LINE(l) + (int)(re->startp[0] - line); -#endif - } - pos = 0; - } - - /* not found */ - msg(*o_wrapscan ? "Not found" : "Hit bottom without finding RE"); - return MARK_UNSET; -} - -MARK m_bsrch(m, ptrn) - MARK m; /* where to start searching */ - char *ptrn; /* pattern to search for */ -{ - long l; /* line# of line to be searched */ - char *line; /* text of line to be searched */ - int wrapped;/* boolean: has our search wrapped yet? */ - int pos; /* last acceptable idx for a match on this line */ - int last; /* remembered idx of the last acceptable match on this line */ - int try; /* an idx at which we strat searching for another match */ -#ifdef REGEX - regex_t *optpat(); - regmatch_t rm[SE_MAX]; - int n; -#endif -#ifndef CRUNCH - long delta = INFINITY;/* line offset, for things like "/foo/+1" */ -#endif - - /* remember: "previous search was not forward" */ - prevsf = FALSE; - - if (ptrn && *ptrn) - { - /* locate the closing '?', if any */ - line = parseptrn(ptrn); -#ifndef CRUNCH - if (*line) - { - delta = atol(line); - } -#endif - ptrn++; - -#ifdef REGEX - /* XXX where to free re? */ - re = optpat(ptrn); -#else - /* free the previous pattern, if any */ - if (re) _free_(re); - - /* compile the pattern */ - re = regcomp(ptrn); -#endif - if (!re) - { - return MARK_UNSET; - } - } - else if (!re) - { - msg("No previous expression"); - return MARK_UNSET; - } - - /* search backward for the pattern */ - pos = markidx(m); - wrapped = FALSE; - for (l = markline(m); l != markline(m) - 1 || !wrapped; l--) - { - /* wrap search */ - if (l < 1) - { - if (*o_wrapscan) - { - l = nlines + 1; - wrapped = TRUE; - continue; - } - else - { - break; - } - } - - /* get this line */ - line = fetchline(l); - - /* check this line */ -#ifdef REGEX - if (!regexec(re, line, SE_MAX, rm, 0) && rm[0].rm_so < pos) -#else - if (regexec(re, line, 1) && (int)(re->startp[0] - line) < pos) -#endif - { - try = 0; - /* match! now find the last acceptable one in this line */ - do - { -#ifdef REGEX - last = try + rm[0].rm_so; - try += rm[0].rm_eo; -#else - last = (int)(re->startp[0] - line); - try = (int)(re->endp[0] - line); -#endif - } while (try > 0 -#ifdef REGEX - && !regexec(re, &line[try], SE_MAX, rm, REG_NOTBOL) - && try + rm[0].rm_so < pos); -#else - && regexec(re, &line[try], FALSE) - && (int)(re->startp[0] - line) < pos); -#endif - - if (wrapped && *o_warn) - msg("(wrapped)"); -#ifndef CRUNCH - if (delta != INFINITY) - { - l += delta; - if (l < 1 || l > nlines) - { - msg("search offset too big"); - return MARK_UNSET; - } - force_flags = LNMD|INCL; - return MARK_AT_LINE(l); - } -#endif - return MARK_AT_LINE(l) + last; - } - pos = BLKSIZE; - } - - /* not found */ - msg(*o_wrapscan ? "Not found" : "Hit top without finding RE"); - return MARK_UNSET; -} - diff --git a/usr.bin/elvis/move3.c b/usr.bin/elvis/move3.c deleted file mode 100644 index b5b9f7bad25a..000000000000 --- a/usr.bin/elvis/move3.c +++ /dev/null @@ -1,150 +0,0 @@ -/* move3.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains movement functions that perform character searches */ - -#ifndef lint -static char rcsid[] = "$Id: move3.c,v 1.3 1993/08/02 17:53:59 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" - -#ifndef NO_CHARSEARCH -static MARK (*prevfwdfn)(); /* function to search in same direction */ -static MARK (*prevrevfn)(); /* function to search in opposite direction */ -static char prev_key; /* sought cvhar from previous [fFtT] */ - -MARK m__ch(m, cnt, cmd) - MARK m; /* current position */ - long cnt; - int cmd; /* command: either ',' or ';' */ -{ - MARK (*tmp)(); - - if (!prevfwdfn) - { - msg("No previous f, F, t, or T command"); - return MARK_UNSET; - } - - if (cmd == ',') - { - m = (*prevrevfn)(m, cnt, prev_key); - - /* Oops! we didn't want to change the prev*fn vars! */ - tmp = prevfwdfn; - prevfwdfn = prevrevfn; - prevrevfn = tmp; - - return m; - } - else - { - return (*prevfwdfn)(m, cnt, prev_key); - } -} - -/* move forward within this line to next occurrence of key */ -MARK m_fch(m, cnt, key) - MARK m; /* where to search from */ - long cnt; - int key; /* what to search for */ -{ - REG char *text; - - DEFAULT(1); - - prevfwdfn = m_fch; - prevrevfn = m_Fch; - prev_key = key; - - pfetch(markline(m)); - text = ptext + markidx(m); - while (cnt-- > 0) - { - do - { - m++; - text++; - } while (*text && *text != key); - } - if (!*text) - { - return MARK_UNSET; - } - return m; -} - -/* move backward within this line to previous occurrence of key */ -MARK m_Fch(m, cnt, key) - MARK m; /* where to search from */ - long cnt; - int key; /* what to search for */ -{ - REG char *text; - - DEFAULT(1); - - prevfwdfn = m_Fch; - prevrevfn = m_fch; - prev_key = key; - - pfetch(markline(m)); - text = ptext + markidx(m); - while (cnt-- > 0) - { - do - { - m--; - text--; - } while (text >= ptext && *text != key); - } - if (text < ptext) - { - return MARK_UNSET; - } - return m; -} - -/* move forward within this line almost to next occurrence of key */ -MARK m_tch(m, cnt, key) - MARK m; /* where to search from */ - long cnt; - int key; /* what to search for */ -{ - m = m_fch(m, cnt, key); - if (m != MARK_UNSET) - { - prevfwdfn = m_tch; - prevrevfn = m_Tch; - m--; - } - return m; -} - -/* move backward within this line almost to previous occurrence of key */ -MARK m_Tch(m, cnt, key) - MARK m; /* where to search from */ - long cnt; - int key; /* what to search for */ -{ - m = m_Fch(m, cnt, key); - if (m == MARK_UNSET) - { - prevfwdfn = m_Tch; - prevrevfn = m_tch; - m++; - } - - return m; -} -#endif diff --git a/usr.bin/elvis/move4.c b/usr.bin/elvis/move4.c deleted file mode 100644 index eb86d2f67aba..000000000000 --- a/usr.bin/elvis/move4.c +++ /dev/null @@ -1,225 +0,0 @@ -/* move4.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains movement functions which are screen-relative */ - -#ifndef lint -static char rcsid[] = "$Id: move4.c,v 1.3 1993/08/02 17:54:00 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" - -/* This moves the cursor to a particular row on the screen */ -/*ARGSUSED*/ -MARK m_row(m, cnt, key) - MARK m; /* the cursor position */ - long cnt; /* the row we'll move to */ - int key; /* the keystroke of this move - H/L/M */ -{ - DEFAULT(1); - - /* calculate destination line based on key */ - cnt--; - switch (key) - { - case 'H': - cnt = topline + cnt; - break; - - case 'M': - cnt = topline + (LINES - 1) / 2; - break; - - case 'L': - cnt = botline - cnt; - break; - } - - /* return the mark of the destination line */ - return MARK_AT_LINE(cnt); -} - - -/* This function repositions the current line to show on a given row */ -MARK m_z(m, cnt, key) - MARK m; /* the cursor */ - long cnt; /* the line number we're repositioning */ - int key; /* key struck after the z */ -{ - long newtop; - int i; - - /* Which line are we talking about? */ - if (cnt < 0 || cnt > nlines) - { - return MARK_UNSET; - } - if (cnt) - { - m = MARK_AT_LINE(cnt); - newtop = cnt; - } - else - { - newtop = markline(m); - } - - /* allow a "window size" number to be entered */ - for (i = 0; key >= '0' && key <= '9'; key = getkey(0)) - { - i = i * 10 + key - '0'; - } -#ifndef CRUNCH - if (i > 0 && i <= LINES - 1) - { - *o_window = i; - wset = TRUE; - } -#else - /* the number is ignored if -DCRUNCH */ -#endif - - /* figure out which line will have to be at the top of the screen */ - switch (key) - { - case '\n': -#if OSK - case '\l': -#else - case '\r': -#endif - case '+': - break; - - case '.': - case 'z': - newtop -= LINES / 2; - break; - - case '-': - newtop -= LINES - 1; - break; - - default: - return MARK_UNSET; - } - - /* make the new topline take effect */ - redraw(MARK_UNSET, FALSE); - if (newtop >= 1) - { - topline = newtop; - } - else - { - topline = 1L; - } - redrawrange(0L, INFINITY, INFINITY); - - /* The cursor doesn't move */ - return m; -} - - -/* This function scrolls the screen. It does this by calling redraw() with - * an off-screen line as the argument. It will move the cursor if necessary - * so that the cursor is on the new screen. - */ -/*ARGSUSED*/ -MARK m_scroll(m, cnt, key) - MARK m; /* the cursor position */ - long cnt; /* for some keys: the number of lines to scroll */ - int key; /* keystroke that causes this movement */ -{ - MARK tmp; /* a temporary mark, used as arg to redraw() */ -#ifndef CRUNCH - int savenearscroll; - - savenearscroll = *o_nearscroll; - *o_nearscroll = LINES; -#endif - - /* adjust cnt, and maybe *o_scroll, depending of key */ - switch (key) - { - case ctrl('F'): - case ctrl('B'): - DEFAULT(1); - redrawrange(0L, INFINITY, INFINITY); /* force complete redraw */ - cnt = cnt * (LINES - 1) - 2; /* keeps two old lines on screen */ - break; - - case ctrl('E'): - case ctrl('Y'): - DEFAULT(1); - break; - - case ctrl('U'): - case ctrl('D'): - if (cnt == 0) /* default */ - { - cnt = *o_scroll; - } - else - { - if (cnt > LINES - 1) - { - cnt = LINES - 1; - } - *o_scroll = cnt; - } - break; - } - - /* scroll up or down, depending on key */ - switch (key) - { - case ctrl('B'): - case ctrl('Y'): - case ctrl('U'): - cnt = topline - cnt; - if (cnt < 1L) - { - cnt = 1L; - m = MARK_FIRST; - } - tmp = MARK_AT_LINE(cnt) + markidx(m); - redraw(tmp, FALSE); - if (markline(m) > botline) - { - m = MARK_AT_LINE(botline); - } - break; - - case ctrl('F'): - case ctrl('E'): - case ctrl('D'): - cnt = botline + cnt; - if (cnt > nlines) - { - cnt = nlines; - m = MARK_LAST; - } - tmp = MARK_AT_LINE(cnt) + markidx(m); - redraw(tmp, FALSE); - if (markline(m) < topline) - { - m = MARK_AT_LINE(topline); - } - break; - } - -#ifndef CRUNCH - *o_nearscroll = savenearscroll; -#endif - return m; -} diff --git a/usr.bin/elvis/move5.c b/usr.bin/elvis/move5.c deleted file mode 100644 index e32b9da99aa3..000000000000 --- a/usr.bin/elvis/move5.c +++ /dev/null @@ -1,261 +0,0 @@ -/* move5.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains the word-oriented movement functions */ - -#ifndef lint -static char rcsid[] = "$Id: move5.c,v 1.3 1993/08/02 17:54:01 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "ctype.h" -#include "vi.h" - -MARK m_fword(m, cnt, cmd, prevkey) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument */ - int cmd; /* either 'w' or 'W' */ - int prevkey;/* previous command... if 'c' then exclude whitespace */ -{ - REG long l; - REG char *text; - REG int i; - - DEFAULT(1); - - l = markline(m); - pfetch(l); - text = ptext + markidx(m); - -#ifndef CRUNCH - /* As a special case, "cw" or "cW" on whitespace without a count - * treats the single whitespace character under the cursor as a word. - */ - if (cnt == 1L && prevkey == 'c' && isspace(*text)) - { - return m; - } -#endif - - while (cnt-- > 0) /* yes, ASSIGNMENT! */ - { - i = *text++; - - if (cmd == 'W') - { - /* include any non-whitespace */ - while (i && !isspace(i)) - { - i = *text++; - } - } - else if (isalnum(i) || i == '_') - { - /* include an alphanumeric word */ - while (i && isalnum(i)) - { - i = *text++; - } - } - else - { - /* include contiguous punctuation */ - while (i && !isalnum(i) && !isspace(i)) - { - i = *text++; - } - } - - /* if not part of "cw" or "cW" command... */ - if (prevkey != 'c' || cnt > 0) - { - /* include trailing whitespace */ - while (!i || isspace(i)) - { - /* did we hit the end of this line? */ - if (!i) - { - /* "dw" shouldn't delete newline after word */ - if (prevkey && cnt == 0) - { - break; - } - - /* move to next line, if there is one */ - l++; - if (l > nlines) - { - return MARK_UNSET; - } - pfetch(l); - text = ptext; - } - - i = *text++; - } - } - text--; - } - - /* if argument to operator, then back off 1 char since "w" and "W" - * include the last char in the affected text. - */ - if (prevkey) - { - text--; - } - - /* construct a MARK for this place */ - m = buildmark(text); - return m; -} - - -MARK m_bword(m, cnt, cmd) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument */ - int cmd; /* either 'b' or 'B' */ -{ - REG long l; - REG char *text; - - DEFAULT(1); - - l = markline(m); - pfetch(l); - text = ptext + markidx(m); - while (cnt-- > 0) /* yes, ASSIGNMENT! */ - { - text--; - - /* include preceding whitespace */ - while (text < ptext || isspace(*text)) - { - /* did we hit the end of this line? */ - if (text < ptext) - { - /* move to preceding line, if there is one */ - l--; - if (l <= 0) - { - return MARK_UNSET; - } - pfetch(l); - text = ptext + plen - 1; - } - else - { - text--; - } - } - - if (cmd == 'B') - { - /* include any non-whitespace */ - while (text >= ptext && !isspace(*text)) - { - text--; - } - } - else if (isalnum(*text) || *text == '_') - { - /* include an alphanumeric word */ - while (text >= ptext && isalnum(*text)) - { - text--; - } - } - else - { - /* include contiguous punctuation */ - while (text >= ptext && !isalnum(*text) && !isspace(*text)) - { - text--; - } - } - text++; - } - - /* construct a MARK for this place */ - m = buildmark(text); - return m; -} - -MARK m_eword(m, cnt, cmd) - MARK m; /* movement is relative to this mark */ - long cnt; /* a numeric argument */ - int cmd; /* either 'e' or 'E' */ -{ - REG long l; - REG char *text; - REG int i; - - DEFAULT(1); - - l = markline(m); - pfetch(l); - text = ptext + markidx(m); - while (cnt-- > 0) /* yes, ASSIGNMENT! */ - { - if (*text) - text++; - i = *text++; - - /* include preceding whitespace */ - while (!i || isspace(i)) - { - /* did we hit the end of this line? */ - if (!i) - { - /* move to next line, if there is one */ - l++; - if (l > nlines) - { - return MARK_UNSET; - } - pfetch(l); - text = ptext; - } - - i = *text++; - } - - if (cmd == 'E') - { - /* include any non-whitespace */ - while (i && !isspace(i)) - { - i = *text++; - } - } - else if (isalnum(i) || i == '_') - { - /* include an alphanumeric word */ - while (i && isalnum(i)) - { - i = *text++; - } - } - else - { - /* include contiguous punctuation */ - while (i && !isalnum(i) && !isspace(i)) - { - i = *text++; - } - } - text -= 2; - } - - /* construct a MARK for this place */ - m = buildmark(text); - return m; -} diff --git a/usr.bin/elvis/opts.c b/usr.bin/elvis/opts.c deleted file mode 100644 index f14c931455f2..000000000000 --- a/usr.bin/elvis/opts.c +++ /dev/null @@ -1,818 +0,0 @@ -/* opts.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains the code that manages the run-time options -- The - * values that can be modified via the "set" command. - */ - -#ifndef lint -static char rcsid[] = "$Id: opts.c,v 1.3 1993/08/02 17:54:02 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" -#include "ctype.h" -#ifndef NULL -#define NULL (char *)0 -#endif - -/* maximum width to permit for strings, including ="" */ -#define MAXWIDTH 20 - -/* These are the default values of all options */ -char o_autoindent[1] = {FALSE}; -char o_autoprint[1] = {TRUE}; -char o_autotab[1] = {TRUE}; -char o_autowrite[1] = {FALSE}; -char o_columns[3] = {80, 32, ~0}; -char o_directory[30] = TMPDIR; -char o_edcompatible[1] = {FALSE}; -char o_equalprg[80] = {"fmt"}; -char o_errorbells[1] = {TRUE}; -char o_exrefresh[1] = {TRUE}; -char o_ignorecase[1] = {FALSE}; -char o_keytime[3] = {2, 0, 50}; -char o_keywordprg[80] = {KEYWORDPRG}; -char o_lines[3] = {25, 2, 96}; -char o_list[1] = {FALSE}; -char o_number[1] = {FALSE}; -char o_readonly[1] = {FALSE}; -char o_remap[1] = {TRUE}; -char o_report[3] = {5, 1, 127}; -char o_scroll[3] = {12, 1, 127}; -char o_shell[60] = SHELL; -char o_shiftwidth[3] = {8, 1, ~0}; -char o_sidescroll[3] = {8, 1, 40}; -char o_sync[1] = {NEEDSYNC}; -char o_tabstop[3] = {8, 1, 40}; -char o_term[30] = "?"; -char o_flash[1] = {TRUE}; -char o_warn[1] = {TRUE}; -char o_wrapscan[1] = {TRUE}; - -#ifndef CRUNCH -char o_beautify[1] = {FALSE}; -char o_exrc[1] = {FALSE}; -char o_mesg[1] = {TRUE}; -char o_more[1] = {TRUE}; -char o_nearscroll[3] = {15, 0, ~0}; -char o_novice[1] = {FALSE}; -char o_prompt[1] = {TRUE}; -char o_taglength[3] = {0, 0, 30}; -char o_tags[256] = {"tags"}; -char o_terse[1] = {FALSE}; -char o_window[3] = {0, 1, 24}; -char o_wrapmargin[3] = {0, 0, ~0}; -char o_writeany[1] = {FALSE}; -#endif - -#ifndef NO_ERRLIST -char o_cc[30] = {CC_COMMAND}; -char o_make[30] = {MAKE_COMMAND}; -#endif - -#ifndef NO_CHARATTR -char o_charattr[1] = {FALSE}; -#endif - -#ifndef NO_DIGRAPH -char o_digraph[1] = {FALSE}; -char o_flipcase[80] -# ifdef CS_IBMPC - = {"\207\200\201\232\202\220\204\216\206\217\221\222\224\231\244\245"} -# endif -# ifdef CS_LATIN1 - /* initialized by initopts() */ -# endif - ; -#endif - -#ifndef NO_SENTENCE -char o_hideformat[1] = {FALSE}; -#endif - -#ifndef NO_EXTENSIONS -char o_inputmode[1] = {FALSE}; -char o_ruler[1] = {FALSE}; -#endif - -#ifndef NO_MAGIC -char o_magic[1] = {TRUE}; -#endif - -#ifndef NO_MODELINES -char o_modelines[1] = {FALSE}; -#endif - -#ifndef NO_SENTENCE -char o_paragraphs[30] = "PPppIPLPQP"; -char o_sections[30] = "NHSHSSSEse"; -#endif - -#if MSDOS -char o_pcbios[1] = {TRUE}; -#endif - -#ifndef NO_SHOWMATCH -char o_showmatch[1] = {FALSE}; -#endif - -#ifndef NO_SHOWMODE -char o_smd[1] = {FALSE}; -#endif - -#ifndef NO_TAGSTACK -char o_tagstack[1] = {TRUE}; -#endif - - - -/* The following describes the names & types of all options */ -#define BOOL 0 -#define NUM 1 -#define STR 2 -#define SET 0x01 /* this option has had its value altered */ -#define CANSET 0x02 /* this option can be set at any time */ -#define RCSET 0x06 /* this option can be set in a .exrc file only */ -#define NOSAVE 0x0a /* this option should never be saved by mkexrc */ -#define WSET 0x20 /* is this the "window" size option? */ -#define MR 0x40 /* does this option affect the way text is displayed? */ -struct -{ - char *name; /* name of an option */ - char *nm; /* short name of an option */ - char type; /* type of an option */ - char flags; /* boolean: has this option been set? */ - char *value; /* value */ -} - opts[] = -{ - /* name type flags value */ - { "autoindent", "ai", BOOL, CANSET, o_autoindent }, - { "autoprint", "ap", BOOL, CANSET, o_autoprint }, - { "autotab", "at", BOOL, CANSET, o_autotab }, - { "autowrite", "aw", BOOL, CANSET, o_autowrite }, -#ifndef CRUNCH - { "beautify", "bf", BOOL, CANSET, o_beautify }, -#endif -#ifndef NO_ERRLIST - { "cc", "cc", STR, CANSET, o_cc }, -#endif -#ifndef NO_CHARATTR - { "charattr", "ca", BOOL, CANSET|MR, o_charattr }, -#endif - { "columns", "co", NUM, SET|NOSAVE|MR, o_columns }, -#ifndef NO_DIGRAPH - { "digraph", "dig", BOOL, CANSET, o_digraph }, -#endif - { "directory", "dir", STR, RCSET, o_directory }, - { "edcompatible","ed", BOOL, CANSET, o_edcompatible }, - { "equalprg", "ep", STR, CANSET, o_equalprg }, - { "errorbells", "eb", BOOL, CANSET, o_errorbells }, -#ifndef CRUNCH - { "exrc", "exrc", BOOL, CANSET, o_exrc }, -#endif - { "exrefresh", "er", BOOL, CANSET, o_exrefresh }, - { "flash", "vbell",BOOL, CANSET, o_flash }, -#ifndef NO_DIGRAPH - { "flipcase", "fc", STR, CANSET, o_flipcase }, -#endif -#ifndef NO_SENTENCE - { "hideformat", "hf", BOOL, CANSET|MR, o_hideformat }, -#endif - { "ignorecase", "ic", BOOL, CANSET, o_ignorecase }, -#ifndef NO_EXTENSIONS - { "inputmode", "im", BOOL, CANSET, o_inputmode }, -#endif - { "keytime", "kt", NUM, CANSET, o_keytime }, - { "keywordprg", "kp", STR, CANSET, o_keywordprg }, - { "lines", "ls", NUM, SET|NOSAVE|MR, o_lines }, - { "list", "li", BOOL, CANSET|MR, o_list }, -#ifndef NO_MAGIC - { "magic", "ma", BOOL, CANSET, o_magic }, -#endif -#ifndef NO_ERRLIST - { "make", "mk", STR, CANSET, o_make }, -#endif -#ifndef CRUNCH - { "mesg", "me", BOOL, CANSET, o_mesg }, -#endif -#ifndef NO_MODELINES - { "modelines", "ml", BOOL, CANSET, o_modelines }, -#endif -#ifndef CRUNCH - { "more", "mo", BOOL, CANSET, o_more }, - { "nearscroll", "ns", NUM, CANSET, o_nearscroll }, - { "novice", "nov", BOOL, CANSET, o_novice }, -#endif - { "number", "nu", BOOL, CANSET|MR, o_number }, -#ifndef NO_SENTENCE - { "paragraphs", "para", STR, CANSET, o_paragraphs }, -#endif -#if MSDOS - { "pcbios", "pc", BOOL, SET|NOSAVE, o_pcbios }, -#endif -#ifndef CRUNCH - { "prompt", "pr", BOOL, CANSET, o_prompt }, -#endif - { "readonly", "ro", BOOL, CANSET, o_readonly }, - { "remap", "remap",BOOL, CANSET, o_remap }, - { "report", "re", NUM, CANSET, o_report }, -#ifndef NO_EXTENSIONS - { "ruler", "ru", BOOL, CANSET, o_ruler }, -#endif - { "scroll", "sc", NUM, CANSET, o_scroll }, -#ifndef NO_SENTENCE - { "sections", "sect", STR, CANSET, o_sections }, -#endif - { "shell", "sh", STR, CANSET, o_shell }, -#ifndef NO_SHOWMATCH - { "showmatch", "sm", BOOL, CANSET, o_showmatch }, -#endif -#ifndef NO_SHOWMODE - { "showmode", "smd", BOOL, CANSET, o_smd }, -#endif - { "shiftwidth", "sw", NUM, CANSET, o_shiftwidth }, - { "sidescroll", "ss", NUM, CANSET, o_sidescroll }, - { "sync", "sy", BOOL, CANSET, o_sync }, - { "tabstop", "ts", NUM, CANSET|MR, o_tabstop }, -#ifndef CRUNCH - { "taglength", "tl", NUM, CANSET, o_taglength }, - { "tags", "tag", STR, CANSET, o_tags }, -#endif -#ifndef NO_TAGSTACK - { "tagstack", "tgs", BOOL, CANSET, o_tagstack }, -#endif - { "term", "te", STR, SET, o_term }, -#ifndef CRUNCH - { "terse", "tr", BOOL, CANSET, o_terse }, - { "timeout", "to", BOOL, CANSET, o_keytime }, -#endif -#ifndef CRUNCH - { "window", "wi", NUM, CANSET|MR|WSET, o_window }, - { "wrapmargin", "wm", NUM, CANSET, o_wrapmargin }, -#endif - { "wrapscan", "ws", BOOL, CANSET, o_wrapscan }, -#ifndef CRUNCH - { "writeany", "wr", BOOL, CANSET, o_writeany }, -#endif - { NULL, NULL, 0, CANSET, NULL } -}; - - -/* This function initializes certain options from environment variables, etc. */ -void initopts() -{ - char *val; - int i; - - /* set some stuff from environment variables */ -#if MSDOS - if (val = getenv("COMSPEC")) /* yes, ASSIGNMENT! */ -#else - if (val = getenv("SHELL")) /* yes, ASSIGNMENT! */ -#endif - { - strcpy(o_shell, val); - } - - strcpy(o_term, termtype); -#if MSDOS - if (strcmp(termtype, "pcbios")) - { - o_pcbios[0] = FALSE; - } - else - { - o_pcbios[0] = TRUE; - } -#endif - -#if AMIGA || MSDOS || TOS - if ((val = getenv("TMP")) /* yes, ASSIGNMENT! */ - || (val = getenv("TEMP"))) - strcpy(o_directory, val); -#endif - -#ifndef CRUNCH - if ((val = getenv("LINES")) && atoi(val) > 4) /* yes, ASSIGNMENT! */ - { - LINES = atoi(val); - } - if ((val = getenv("COLUMNS")) && atoi(val) > 30) /* yes, ASSIGNMENT! */ - { - COLS = atoi(val); - } -#endif - *o_lines = LINES; - *o_columns = COLS; - *o_scroll = LINES / 2 - 1; -#ifndef CRUNCH - if (o_window[0] == 0) - { - o_window[0] = o_window[2] = *o_lines; - } - *o_nearscroll = *o_lines; -#endif - - /* disable the flash option if we don't know how to do a flash */ - if (!has_VB) - { - for (i = 0; opts[i].value != o_flash; i++) - { - } - opts[i].flags &= ~CANSET; - *o_flash = FALSE; - } - -#ifndef NO_DIGRAPH -# ifdef CS_LATIN1 - for (i = 0, val = o_flipcase; i < 32; i++) - { - /* leave out the multiply/divide symbols */ - if (i == 23) - continue; - - /* add lower/uppercase pair */ - *val++ = i + 0xe0; - *val++ = i + 0xc0; - } - *val = '\0'; -# endif /* CS_LATIN1 */ - - /* initialize the ctype package */ - _ct_init(o_flipcase); -#else - _ct_init(""); -#endif /* not NO_DIGRAPH */ -} - -/* This function lists the current values of all options */ -void dumpopts(all) - int all; /* boolean: dump all options, or just set ones? */ -{ -#ifndef NO_OPTCOLS - int i, j, k; - char nbuf[4]; /* used for converting numbers to ASCII */ - int widths[5]; /* width of each column, including gap */ - int ncols; /* number of columns */ - int nrows; /* number of options per column */ - int nset; /* number of options to be output */ - int width; /* width of a particular option */ - int todump[60]; /* indicies of options to be dumped */ - - /* step 1: count the number of set options */ - for (nset = i = 0; opts[i].name; i++) - { - if (all || (opts[i].flags & SET)) - { - todump[nset++] = i; - } - } - - /* step two: try to use as many columns as possible */ - for (ncols = (nset > 5 ? 5 : nset); ncols > 1; ncols--) - { - /* how many would go in this column? */ - nrows = (nset + ncols - 1) / ncols; - - /* figure out the width of each column */ - for (i = 0; i < ncols; i++) - { - widths[i] = 0; - for (j = 0, k = nrows * i; j < nrows && k < nset; j++, k++) - { - /* figure out the width of a particular option */ - switch (opts[todump[k]].type) - { - case BOOL: - if (!*opts[todump[k]].value) - width = 2; - else - width = 0; - break; - - case STR: - width = 3 + strlen(opts[todump[k]].value); - if (width > MAXWIDTH) - width = MAXWIDTH; - break; - - case NUM: - width = 4; - break; - } - width += strlen(opts[todump[k]].name); - - /* if this is the widest so far, widen col */ - if (width > widths[i]) - { - widths[i] = width; - } - } - - } - - /* if the total width is narrow enough, then use it */ - for (width = -2, i = 0; i < ncols; i++) - { - width += widths[i] + 2; - } - if (width < COLS - 1) - { - break; - } - } - - /* step 3: output the columns */ - nrows = (nset + ncols - 1) / ncols; - for (i = 0; i < nrows; i++) - { - for (j = 0; j < ncols; j++) - { - /* if we hit the end of the options, quit */ - k = i + j * nrows; - if (k >= nset) - { - break; - } - - /* output this option's value */ - width = 0; - switch (opts[todump[k]].type) - { - case BOOL: - if (!*opts[todump[k]].value) - { - qaddch('n'); - qaddch('o'); - width = 2; - } - qaddstr(opts[todump[k]].name); - width += strlen(opts[todump[k]].name); - break; - - case NUM: - sprintf(nbuf, "%-3d", UCHAR(*opts[todump[k]].value)); - qaddstr(opts[todump[k]].name); - qaddch('='); - qaddstr(nbuf); - width = 4 + strlen(opts[todump[k]].name); - break; - - case STR: - qaddstr(opts[todump[k]].name); - qaddch('='); - qaddch('"'); - strcpy(tmpblk.c, opts[todump[k]].value); - width = 3 + strlen(tmpblk.c); - if (width > MAXWIDTH) - { - width = MAXWIDTH; - strcpy(tmpblk.c + MAXWIDTH - 6, "..."); - } - qaddstr(tmpblk.c); - qaddch('"'); - width += strlen(opts[todump[k]].name); - break; - } - - /* pad the field to the correct size */ - if (k + nrows <= nset) - { - while (width < widths[j] + 2) - { - qaddch(' '); - width++; - } - } - } - addch('\n'); - exrefresh(); - } -#else - int i; - int col; - char nbuf[4]; - - for (i = col = 0; opts[i].name; i++) - { - /* if not set and not all, ignore this option */ - if (!all && !(opts[i].flags & SET)) - { - continue; - } - - /* align this option in one of the columns */ - if (col > 52) - { - addch('\n'); - col = 0; - } - else if (col > 26) - { - while (col < 52) - { - qaddch(' '); - col++; - } - } - else if (col > 0) - { - while (col < 26) - { - qaddch(' '); - col++; - } - } - - switch (opts[i].type) - { - case BOOL: - if (!*opts[i].value) - { - qaddch('n'); - qaddch('o'); - col += 2; - } - qaddstr(opts[i].name); - col += strlen(opts[i].name); - break; - - case NUM: - sprintf(nbuf, "%-3d", UCHAR(*opts[i].value)); - qaddstr(opts[i].name); - qaddch('='); - qaddstr(nbuf); - col += 4 + strlen(opts[i].name); - break; - - case STR: - qaddstr(opts[i].name); - qaddch('='); - qaddch('"'); - qaddstr(opts[i].value); - qaddch('"'); - col += 3 + strlen(opts[i].name) + strlen(opts[i].value); - break; - } - exrefresh(); - } - if (col > 0) - { - addch('\n'); - exrefresh(); - } -#endif -} - -#ifndef NO_MKEXRC -/* This function saves the current configuration of options to a file */ -void saveopts(fd) - int fd; /* file descriptor to write to */ -{ - int i; - char buf[256], *pos; - - /* write each set options */ - for (i = 0; opts[i].name; i++) - { - /* if unset or unsettable, ignore this option */ - if ((opts[i].flags & (SET|CANSET|NOSAVE)) != (SET|CANSET)) - { - continue; - } - - strcpy(buf, "set "); - pos = &buf[4]; - switch (opts[i].type) - { - case BOOL: - if (!*opts[i].value) - { - *pos++='n'; - *pos++='o'; - } - strcpy(pos, opts[i].name); - strcat(pos, "\n"); - break; - - case NUM: - sprintf(pos, "%s=%-3d\n", opts[i].name, *opts[i].value & 0xff); - break; - - case STR: - sprintf(pos, "%s=\"%s\"\n", opts[i].name, opts[i].value); - break; - } - twrite(fd, buf, (unsigned)strlen(buf)); - } -} -#endif - - -/* This function changes the values of one or more options. */ -void setopts(assignments) - char *assignments; /* a string containing option assignments */ -{ - char *name; /* name of variable in assignments */ - char *value; /* value of the variable */ - char *scan; /* used for moving through strings */ - char *build; /* used for copying chars from "scan" */ - char *prefix; /* pointer to "neg" or "no" at front of a boolean */ - int quote; /* boolean: inside '"' quotes? */ - int i, j; - -#ifndef CRUNCH - /* reset the upper limit of "window" option to lines-1 */ - *o_window = *o_lines - 1; -#endif - - /* for each assignment... */ - for (name = assignments; *name; ) - { - /* skip whitespace */ - if (*name == ' ' || *name == '\t') - { - name++; - continue; - } - - /* after the name, find the value (if any) */ - for (scan = name; isalnum(*scan); scan++) - { - } - if (*scan == '=') - { - *scan++ = '\0'; - value = build = scan; - for (quote = FALSE; *scan && (quote || !isspace(*scan)); scan++) - { - if (*scan == '"') - { - quote = !quote; - } - else if (*scan == '\\' && scan[1]) - { - *build++ = *++scan; - } - else - { - *build++ = *scan; - } - } - if (*scan) - scan++; - *build = '\0'; - } - else /* no "=" so it is probably boolean... */ - { - if (*scan) - { - *scan++ = '\0'; - } - value = NULL; - prefix = name; -#ifndef CRUNCH - if (!strcmp(name, "novice")) - /* don't check for a "no" prefix */; - else -#endif - if (prefix[0] == 'n' && prefix[1] == 'o') - name += 2; - else if (prefix[0] == 'n' && prefix[1] == 'e' && prefix[2] == 'g') - name += 3; - } - - /* find the variable */ - for (i = 0; - opts[i].name && strcmp(opts[i].name, name) && strcmp(opts[i].nm, name); - i++) - { - } - - /* change the variable */ - if (!opts[i].name) - { - /* only complain about unknown options if we're editing - * a file; i.e., if we're not executing the .exrc now. - */ - if (tmpfd >= 0) - msg("invalid option name \"%s\"", name); - } - else if ((opts[i].flags & CANSET) != CANSET) - { - msg("option \"%s\" can't be altered", name); - } - else if ((opts[i].flags & RCSET) != CANSET && nlines >= 1L) - { - msg("option \"%s\" can only be set in a %s file", name, EXRC); - } - else if (value) - { - switch (opts[i].type) - { - case BOOL: - msg("option \"[no]%s\" is boolean", name); - break; - - case NUM: - j = atoi(value); - if (j == 0 && *value != '0') - { - msg("option \"%s\" must have a numeric value", name); - } - else if (j < opts[i].value[1] || j > (opts[i].value[2] & 0xff)) - { - msg("option \"%s\" must have a value between %d and %d", - name, opts[i].value[1], opts[i].value[2] & 0xff); - } - else - { - *opts[i].value = atoi(value); - opts[i].flags |= SET; - } - break; - - case STR: - strcpy(opts[i].value, value); - opts[i].flags |= SET; - break; - } - if (opts[i].flags & MR) - { - redraw(MARK_UNSET, FALSE); - } -#ifndef CRUNCH - if (opts[i].flags & WSET) - { - wset = TRUE; - } -#endif - } - else /* valid option, no value */ - { - if (opts[i].type == BOOL) - { - if (prefix == name) - *opts[i].value = TRUE; - else if (prefix[1] == 'o') - *opts[i].value = FALSE; - else - *opts[i].value = !*opts[i].value; - - opts[i].flags |= SET; - if (opts[i].flags & MR) - { - redraw(MARK_UNSET, FALSE); - } - } - else - { - msg("option \"%s\" must be given a value", name); - } - } - - /* move on to the next option */ - name = scan; - } - - /* special processing ... */ - -#ifndef CRUNCH - /* if "novice" is set, then ":set report=1 showmode nomagic" */ - if (*o_novice) - { - *o_report = 1; -# ifndef NO_SHOWMODE - *o_smd = TRUE; -# endif -# ifndef NO_MAGIC - *o_magic = FALSE; -# endif - } -#endif - - /* if "readonly" then set the READONLY flag for this file */ - if (*o_readonly) - { - setflag(file, READONLY); - } - -#ifndef NO_DIGRAPH - /* re-initialize the ctype package */ - _ct_init(o_flipcase); -#endif /* not NO_DIGRAPH */ - - /* copy o_lines and o_columns into LINES and COLS */ - LINES = (*o_lines & 255); - COLS = (*o_columns & 255); -} diff --git a/usr.bin/elvis/prsvunix.c b/usr.bin/elvis/prsvunix.c deleted file mode 100644 index 02200088d3a1..000000000000 --- a/usr.bin/elvis/prsvunix.c +++ /dev/null @@ -1,110 +0,0 @@ -/* prsvunix.c */ - -/* This file contains the UNIX-specific parts of the "elvprsv" program. */ - -#ifndef lint -static char prsvunix_rcsid[] = "$Id: prsvunix.c,v 1.4 1993/12/06 09:29:36 cgd Exp $"; -#endif /* not lint */ - - -#if OSK -#define ELVPRSV -#include "osk.c" -#else -#include <sys/stat.h> -#include <pwd.h> -#endif - -/* This variable is used to add extra error messages for mail sent to root */ -char *ps; - -/* This function returns the login name of the owner of a file */ -char *ownername(filename) - char *filename; /* name of a file */ -{ - struct stat st; - struct passwd *pw; - - /* stat the file, to get its uid */ - if (stat(filename, &st) < 0) - { - ps = "stat() failed"; - return "root"; - } - - /* get the /etc/passwd entry for that user */ - pw = getpwuid(st.st_uid); - if (!pw) - { - ps = "uid not found in password file"; - return "root"; - } - - /* return the user's name */ - return pw->pw_name; -} - - -/* This function sends a mail message to a given user, saying that a file - * has been preserved. - */ -void mail(user, file, when) - char *user; /* name of user who should receive the mail */ - char *file; /* name of original text file that was preserved */ - char *when; /* description of why the file was preserved */ -{ - char cmd[80];/* buffer used for constructing a "mail" command */ - FILE *m, *popen(); /* stream used for giving text to the "mail" program */ - char *base; /* basename of the file */ - - /* separate the directory name from the basename. */ - for (base = file + strlen(file); --base > file && *base != SLASH; ) - { - } - if (*base == SLASH) - { - *base++ = '\0'; - } - - /* for anonymous buffers, pretend the name was "foo" */ - if (!strcmp(base, "*")) - { - base = "foo"; - } - - /* open a pipe to the "mail" program */ -#if OSK - sprintf(cmd, "mail \"-s=%s preserved!\" %s", base, user); -#else /* ANY_UNIX */ - sprintf(cmd, "mail %s >/dev/null 2>/dev/null", user); -#endif - m = popen(cmd, "w"); - if (!m) - { - /* Can't send mail! Hope the user figures it out. */ - return; - } - - /* Tell the user that the file was preserved */ - fprintf(m, "A version of your file \"%s%c%s\"\n", file, SLASH, base); - fprintf(m, "was preserved when %s.\n", when); - fprintf(m, "To recover this file, do the following:\n"); - fprintf(m, "\n"); -#if OSK - fprintf(m, " chd %s\n", file); -#else /* ANY_UNIX */ - fprintf(m, " cd %s\n", file); -#endif - fprintf(m, " elvisrecover %s\n", base); - fprintf(m, "\n"); - fprintf(m, "With fond wishes for a speedy recovery,\n"); - fprintf(m, " Elvis\n"); - if (ps) - { - fprintf(m, "\nP.S. %s\n", ps); - ps = (char *)0; - } - - /* close the stream */ - pclose(m); -} diff --git a/usr.bin/elvis/recycle.c b/usr.bin/elvis/recycle.c deleted file mode 100644 index eea599d24c10..000000000000 --- a/usr.bin/elvis/recycle.c +++ /dev/null @@ -1,215 +0,0 @@ -/* recycle.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains the functions perform garbage collection and allocate - * reusable blocks. - */ - -#ifndef lint -static char rcsid[] = "$Id: recycle.c,v 1.3 1993/08/02 17:54:04 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" - -#ifndef NO_RECYCLE -/* this whole file would have be skipped if NO_RECYCLE is defined */ - - -#define BTST(bitno, byte) ((byte) & (1 << (bitno))) -#define BSET(bitno, byte) ((byte) |= (1 << (bitno))) -#define BCLR(bitno, byte) ((byte) &= ~(1 << (bitno))) - -#define TST(blkno) ((blkno) < MAXBIT ? BTST((blkno) & 7, bitmap[(blkno) >> 3]) : 1) -#define SET(blkno) if ((blkno) < MAXBIT) BSET((blkno) & 7, bitmap[(blkno) >> 3]) -#define CLR(blkno) if ((blkno) < MAXBIT) BCLR((blkno) & 7, bitmap[(blkno) >> 3]) - -/* bitmap of free blocks in first 4096k of tmp file */ -static unsigned char bitmap[512]; -#define MAXBIT (sizeof bitmap << 3) - -/* this function locates all free blocks in the current tmp file */ -void garbage() -{ - int i; - BLK oldhdr; - - /* start by assuming every block is free */ - for (i = 0; i < sizeof bitmap; i++) - { - bitmap[i] = 255; - } - - /* header blocks aren't free */ -#ifndef lint - CLR(0); - CLR(1); -#endif - - /* blocks needed for current hdr aren't free */ - for (i = 1; i < MAXBLKS; i++) - { - CLR(hdr.n[i]); - } - - /* blocks needed for undo version aren't free */ - lseek(tmpfd, 0L, 0); - if (read(tmpfd, &oldhdr, (unsigned)sizeof oldhdr) != sizeof oldhdr) - { - msg("garbage() failed to read oldhdr??"); - for (i = 0; i < sizeof bitmap; i++) - { - bitmap[i] = 0; - } - return; - } - for (i = 1; i < MAXBLKS; i++) - { - CLR(oldhdr.n[i]); - } - - /* blocks needed for cut buffers aren't free */ - for (i = cutneeds(&oldhdr) - 1; i >= 0; i--) - { - CLR(oldhdr.n[i]); - } -} - -/* This function allocates the first available block in the tmp file */ -long allocate() -{ - int i; - long offset; - - /* search for the first byte with a free bit set */ - for (i = 0; i < sizeof bitmap && bitmap[i] == 0; i++) - { - } - - /* if we hit the end of the bitmap, return the end of the file */ - if (i == sizeof bitmap) - { - offset = lseek(tmpfd, 0L, 2); - } - else /* compute the offset for the free block */ - { - for (i <<= 3; TST(i) == 0; i++) - { - } - offset = (long)i * (long)BLKSIZE; - - /* mark the block as "allocated" */ - CLR(i); - } - - return offset; -} - -#endif - -#ifdef DEBUG -# include <stdio.h> -# undef malloc -# undef free -# define MEMMAGIC 0x19f72cc0L -# define MAXALLOC 800 -static char *allocated[MAXALLOC]; -static char *fromfile[MAXALLOC]; -static int fromline[MAXALLOC]; -static int sizes[MAXALLOC]; - -char *dbmalloc(size, file, line) - int size; - char *file; - int line; -{ - char *ret; - int i; - - size = size + sizeof(long) - (size % sizeof(long)); - ret = (char *)malloc(size + 2 * sizeof(long)) + sizeof(long); - for (i = 0; i < MAXALLOC && allocated[i]; i++) - { - } - if (i == MAXALLOC) - { - endwin(); - fprintf(stderr, "\r\n%s(%d): Too many malloc calls!\n", file, line); - abort(); - } - sizes[i] = size/sizeof(long); - allocated[i] = ret; - fromfile[i] = file; - fromline[i] = line; - ((long *)ret)[-1] = MEMMAGIC; - ((long *)ret)[sizes[i]] = MEMMAGIC; - return ret; -} - -dbfree(ptr, file, line) - char *ptr; - char *file; - int line; -{ - int i; - - for (i = 0; i < MAXALLOC && allocated[i] != ptr; i++) - { - } - if (i == MAXALLOC) - { - endwin(); - fprintf(stderr, "\r\n%s(%d): attempt to free mem that wasn't allocated\n", file, line); - abort(); - } - allocated[i] = (char *)0; - if (((long *)ptr)[-1] != MEMMAGIC) - { - endwin(); - fprintf(stderr, "\r\n%s(%d): underflowed malloc space, allocated at %s(%d)\n", file, line, fromfile[i], fromline[i]); - abort(); - } - if (((long *)ptr)[sizes[i]] != MEMMAGIC) - { - endwin(); - fprintf(stderr, "\r\n%s(%d): overflowed malloc space, allocated at %s(%d)\n", file, line, fromfile[i], fromline[i]); - abort(); - } - free(ptr - sizeof(long)); -} - -dbcheckmem(file, line) - char *file; - int line; -{ - int i, j; - - for (i = j = 0; i < MAXALLOC && allocated[i]; i++) - { - if (((long *)allocated[i])[-1] != MEMMAGIC) - { - if (!j) endwin(); - fprintf(stderr, "\r\n%s(%d): underflowed malloc space, allocated at %s(%d)\n", file, line, fromfile[i], fromline[i]); - j++; - } - if (((long *)allocated[i])[sizes[i]] != MEMMAGIC) - { - if (!j) endwin(); - fprintf(stderr, "\r\n%s(%d): overflowed malloc space, allocated at %s(%d)\n", file, line, fromfile[i], fromline[i]); - j++; - } - } - if (j) - { - abort(); - } -} -#endif diff --git a/usr.bin/elvis/redraw.c b/usr.bin/elvis/redraw.c deleted file mode 100644 index 3521a2f620bd..000000000000 --- a/usr.bin/elvis/redraw.c +++ /dev/null @@ -1,1311 +0,0 @@ -/* redraw.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains functions that draw text on the screen. The major entry - * points are: - * redrawrange() - called from modify.c to give hints about what parts - * of the screen need to be redrawn. - * redraw() - redraws the screen (or part of it) and positions - * the cursor where it belongs. - * idx2col() - converts a markidx() value to a logical column number. - */ - -#ifndef lint -static char rcsid[] = "$Id: redraw.c,v 1.3 1993/08/02 17:54:04 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" -#ifdef CRUNCH -# define NEAR LINES -#else -# define NEAR (*o_nearscroll&0xff) -#endif - -/* This variable contains the line number that smartdrawtext() knows best */ -static long smartlno; - -/* This function remembers where changes were made, so that the screen can be - * redraw in a more efficient manner. - */ -static long redrawafter; /* line# of first line that must be redrawn */ -static long preredraw; /* line# of last line changed, before change */ -static long postredraw; /* line# of last line changed, after change */ -static int mustredraw; /* boolean: anything forcing a screen update? */ -void redrawrange(after, pre, post) - long after; /* lower bound of redrawafter */ - long pre; /* upper bound of preredraw */ - long post; /* upper bound of postredraw */ -{ - if (after == redrawafter) - { - /* multiple insertions/deletions at the same place -- combine - * them - */ - preredraw -= (post - pre); - if (postredraw < post) - { - preredraw += (post - postredraw); - postredraw = post; - } - if (redrawafter > preredraw) - { - redrawafter = preredraw; - } - if (redrawafter < 1L) - { - redrawafter = 0L; - preredraw = postredraw = INFINITY; - } - } - else if (postredraw > 0L) - { - /* multiple changes in different places -- redraw everything - * after "after". - */ - postredraw = preredraw = INFINITY; - if (after < redrawafter) - redrawafter = after; - } - else - { - /* first change */ - redrawafter = after; - preredraw = pre; - postredraw = post; - } - mustredraw = TRUE; -} - - -#ifndef NO_CHARATTR -/* see if a given line uses character attribute strings */ -static int hasattr(lno, text) - long lno; /* the line# of the cursor */ - REG char *text; /* the text of the line, from fetchline */ -{ - static long plno; /* previous line number */ - static long chgs; /* previous value of changes counter */ - static int panswer;/* previous answer */ - char *scan; - - /* if charattr is off, then the answer is "no, it doesn't" */ - if (!*o_charattr) - { - chgs = 0; /* <- forces us to check if charattr is later set */ - return FALSE; - } - - /* if we already know the answer, return it... */ - if (lno == plno && chgs == changes) - { - return panswer; - } - - /* get the line & look for "\fX" */ - if (!text[0] || !text[1] || !text[2]) - { - panswer = FALSE; - } - else - { - for (scan = text; scan[2] && !(scan[0] == '\\' && scan[1] == 'f'); scan++) - { - } - panswer = (scan[2] != '\0'); - } - - /* save the results */ - plno = lno; - chgs = changes; - - /* return the results */ - return panswer; -} -#endif - - -#ifndef NO_VISIBLE -/* This function checks to make sure that the correct lines are shown in - * reverse-video. This is used to handle the "v" and "V" commands. - */ -static long vizlow, vizhigh; /* the starting and ending lines */ -static int vizleft, vizright; /* starting & ending indicies */ -static int vizchange; /* boolean: must use stupid drawtext? */ -static void setviz(curs) - MARK curs; -{ - long newlow, newhigh; - long extra = 0L; - - /* for now, assume the worst... */ - vizchange = TRUE; - - /* set newlow & newhigh according to V_from and cursor */ - if (!V_from) - { - /* no lines should have reverse-video */ - if (vizlow) - { - redrawrange(vizlow, vizhigh + 1L, vizhigh + 1L); - vizlow = vizhigh = 0L; - } - else - { - vizchange = FALSE; - } - return; - } - - /* figure out which lines *SHOULD* have hilites */ - if (V_from < curs) - { - newlow = markline(V_from); - newhigh = markline(curs); - vizleft = markidx(V_from); - vizright = markidx(curs) + 1; - } - else - { - newlow = markline(curs); - newhigh = markline(V_from); - vizleft = markidx(curs); - vizright = markidx(V_from) + 1; - } - - /* adjust for line-mode hiliting */ - if (V_linemd) - { - vizleft = 0; - vizright = BLKSIZE - 1; - } - else - { - extra = 1L; - } - - /* arrange for the necessary lines to be redrawn */ - if (vizlow == 0L) - { - /* just starting to redraw */ - redrawrange(newlow, newhigh, newhigh); - } - else - { - /* Were new lines added/removed at the front? */ - if (newlow != vizlow) - { - if (newlow < vizlow) - redrawrange(newlow, vizlow + extra, vizlow + extra); - else - redrawrange(vizlow, newlow + extra, newlow + extra); - } - - /* Were new lines added/removed at the back? */ - if (newhigh != vizhigh) - { - if (newhigh < vizhigh) - redrawrange(newhigh + 1L - extra, vizhigh + 1L, vizhigh + 1L); - else - redrawrange(vizhigh + 1L - extra, newhigh, newhigh); - } - } - - /* remember which lines will contain hilighted text now */ - vizlow = newlow; - vizhigh = newhigh; -} -#endif /* !NO_VISIBLE */ - - -/* This function converts a MARK to a column number. It doesn't automatically - * adjust for leftcol; that must be done by the calling function - */ -int idx2col(curs, text, inputting) - MARK curs; /* the line# & index# of the cursor */ - REG char *text; /* the text of the line, from fetchline */ - int inputting; /* boolean: called from input() ? */ -{ - static MARK pcursor;/* previous cursor, for possible shortcut */ - static MARK pcol; /* column number for pcol */ - static long chgs; /* previous value of changes counter */ - REG int col; /* used to count column numbers */ - REG int idx; /* used to count down the index */ - REG int i; - - /* for now, assume we have to start counting at the left edge */ - col = 0; - idx = markidx(curs); - - /* if the file hasn't changed & line number is the same & it has no - * embedded character attribute strings, can we do shortcuts? - */ - if (chgs == changes - && !((curs ^ pcursor) & ~(BLKSIZE - 1)) -#ifndef NO_CHARATTR - && !hasattr(markline(curs), text) -#endif - ) - { - /* no movement? */ - if (curs == pcursor) - { - /* return the column of the char; for tabs, return its last column */ - if (text[idx] == '\t' && !inputting && !*o_list) - { - return pcol + *o_tabstop - (pcol % *o_tabstop) - 1; - } - else - { - return pcol; - } - } - - /* movement to right? */ - if (curs > pcursor) - { - /* start counting from previous place */ - col = pcol; - idx = markidx(curs) - markidx(pcursor); - text += markidx(pcursor); - } - } - - /* count over to the char after the idx position */ - while (idx > 0 && (i = *text)) /* yes, ASSIGNMENT! */ - { - if (i == '\t' && !*o_list) - { - col += *o_tabstop; - col -= col % *o_tabstop; - } - else if (i >= '\0' && i < ' ' || i == '\177') - { - col += 2; - } -#ifndef NO_CHARATTR - else if (i == '\\' && text[1] == 'f' && text[2] && *o_charattr) - { - text += 2; /* plus one more at bottom of loop */ - idx -= 2; - } -#endif - else - { - col++; - } - text++; - idx--; - } - - /* save stuff to speed next call */ - pcursor = curs; - pcol = col; - chgs = changes; - - /* return the column of the char; for tabs, return its last column */ - if (*text == '\t' && !inputting && !*o_list) - { - return col + *o_tabstop - (col % *o_tabstop) - 1; - } - else - { - return col; - } -} - - -/* This function is similar to idx2col except that it takes care of sideways - * scrolling - for the given line, at least. - */ -int mark2phys(m, text, inputting) - MARK m; /* a mark to convert */ - char *text; /* the line that m refers to */ - int inputting; /* boolean: caled from input() ? */ -{ - int i; - - i = idx2col(m, text, inputting); - while (i < leftcol) - { - leftcol -= *o_sidescroll; - mustredraw = TRUE; - redrawrange(1L, INFINITY, INFINITY); - } - while (i > rightcol) - { - leftcol += *o_sidescroll; - mustredraw = TRUE; - redrawrange(1L, INFINITY, INFINITY); - } - physrow = markline(m) - topline; - physcol = i - leftcol; - if (*o_number) - physcol += 8; - - return physcol; -} - -/* This function draws a single line of text on the screen. The screen's - * cursor is assumed to be located at the leftmost column of the appropriate - * row. - */ -static void drawtext(text, lno, clr) - REG char *text; /* the text to draw */ - long lno; /* the number of the line to draw */ - int clr; /* boolean: do a clrtoeol? */ -{ - REG int col; /* column number */ - REG int i; - REG int tabstop; /* *o_tabstop */ - REG int limitcol; /* leftcol or leftcol + COLS */ - int abnormal; /* boolean: charattr != A_NORMAL? */ -#ifndef NO_VISIBLE - int rev; /* boolean: standout mode, too? */ - int idx = 0; -#endif - char numstr[9]; - - /* show the line number, if necessary */ - if (*o_number) - { - sprintf(numstr, "%6ld ", lno); - qaddstr(numstr); - } - -#ifndef NO_SENTENCE - /* if we're hiding format lines, and this is one of them, then hide it */ - if (*o_hideformat && *text == '.') - { - clrtoeol(); -#if OSK - qaddch('\l'); -#else - qaddch('\n'); -#endif - return; - } -#endif - - /* move some things into registers... */ - limitcol = leftcol; - tabstop = *o_tabstop; - abnormal = FALSE; - -#ifndef CRUNCH - if (clr) - clrtoeol(); -#endif - - /* skip stuff that was scrolled off left edge */ - for (col = 0; - (i = *text) && col < limitcol; /* yes, ASSIGNMENT! */ - text++) - { -#ifndef NO_VISIBLE - idx++; -#endif - if (i == '\t' && !*o_list) - { - col = col + tabstop - (col % tabstop); - } - else if (i >= 0 && i < ' ' || i == '\177') - { - col += 2; - } -#ifndef NO_CHARATTR - else if (i == '\\' && text[1] == 'f' && text[2] && *o_charattr) - { - text += 2; /* plus one more as part of "for" loop */ - - /* since this attribute might carry over, we need it */ - switch (*text) - { - case 'R': - case 'P': - attrset(A_NORMAL); - abnormal = FALSE; - break; - - case 'B': - attrset(A_BOLD); - abnormal = TRUE; - break; - - case 'U': - attrset(A_UNDERLINE); - abnormal = TRUE; - break; - - case 'I': - attrset(A_ALTCHARSET); - abnormal = TRUE; - break; - } - } -#endif - else - { - col++; - } - } - -#ifndef NO_VISIBLE - /* Should we start hiliting at the first char of this line? */ - if ((lno > vizlow && lno <= vizhigh - || lno == vizlow && vizleft < idx) - && !(lno == vizhigh && vizright < idx)) - { - do_VISIBLE(); - rev = TRUE; - } -#endif - - /* adjust for control char that was partially visible */ - while (col > limitcol) - { - qaddch(' '); - limitcol++; - } - - /* now for the visible characters */ - limitcol = leftcol + COLS; - if (*o_number) - limitcol -= 8; - for (; (i = *text) && col < limitcol; text++) - { -#ifndef NO_VISIBLE - /* maybe turn hilite on/off in the middle of the line */ - if (lno == vizlow && vizleft == idx) - { - do_VISIBLE(); - rev = TRUE; - } - if (lno == vizhigh && vizright == idx) - { - do_SE(); - rev = FALSE; - } - idx++; - - /* if hiliting, never emit physical tabs */ - if (rev && i == '\t' && !*o_list) - { - i = col + tabstop - (col % tabstop); - do - { - qaddch(' '); - col++; - } while (col < i && col < limitcol); - } - else -#endif /* !NO_VISIBLE */ - if (i == '\t' && !*o_list) - { - i = col + tabstop - (col % tabstop); - if (i < limitcol) - { -#ifdef CRUNCH - if (!clr && has_PT && !((i - leftcol) & 7)) -#else - if (has_PT && !((i - leftcol) & 7)) -#endif - { - do - { - qaddch('\t'); - col += 8; /* not exact! */ - } while (col < i); - col = i; /* NOW it is exact */ - } - else - { - do - { - qaddch(' '); - col++; - } while (col < i && col < limitcol); - } - } - else /* tab ending after screen? next line! */ - { -#ifdef CRUNCH - /* needed at least when scrolling the screen right -nox */ - if (clr && col < limitcol) - clrtoeol(); -#endif - col = limitcol; - if (has_AM) - { - addch('\n'); /* GB */ - } - } - } - else if (i >= 0 && i < ' ' || i == '\177') - { - col += 2; - qaddch('^'); - if (col <= limitcol) - { - qaddch(i ^ '@'); - } - } -#ifndef NO_CHARATTR - else if (i == '\\' && text[1] == 'f' && text[2] && *o_charattr) - { - text += 2; /* plus one more as part of "for" loop */ - switch (*text) - { - case 'R': - case 'P': - attrset(A_NORMAL); - abnormal = FALSE; - break; - - case 'B': - attrset(A_BOLD); - abnormal = TRUE; - break; - - case 'U': - attrset(A_UNDERLINE); - abnormal = TRUE; - break; - - case 'I': - attrset(A_ALTCHARSET); - abnormal = TRUE; - break; - } - } -#endif - else - { - col++; - qaddch(i); - } - } - - /* get ready for the next line */ -#ifndef NO_CHARATTR - if (abnormal) - { - attrset(A_NORMAL); - } -#endif - if (*o_list && col < limitcol) - { - qaddch('$'); - col++; - } - -#ifndef NO_VISIBLE - /* did we hilite this whole line? If so, STOP! */ - if (rev) - { - do_SE(); - } -#endif - -#ifdef CRUNCH - if (clr && col < limitcol) - { - clrtoeol(); - } -#endif - if (!has_AM || col < limitcol) - { - addch('\n'); - } - - wqrefresh(); -} - - -#ifndef CRUNCH -static void nudgecursor(same, scan, new, lno) - int same; /* number of chars to be skipped over */ - char *scan; /* where the same chars end */ - char *new; /* where the visible part of the line starts */ - long lno; /* line number of this line */ -{ - int col; - - if (same > 0) - { - if (same < 5) - { - /* move the cursor by overwriting */ - while (same > 0) - { - qaddch(scan[-same]); - same--; - } - } - else - { - /* move the cursor by calling move() */ - col = (int)(scan - new); - if (*o_number) - col += 8; - move((int)(lno - topline), col); - } - } -} -#endif /* not CRUNCH */ - -/* This function draws a single line of text on the screen, possibly with - * some cursor optimization. The cursor is repositioned before drawing - * begins, so its position before doesn't really matter. - */ -static void smartdrawtext(text, lno, showit) - REG char *text; /* the text to draw */ - long lno; /* line number of the text */ - int showit; /* boolean: output line? (else just remember it) */ -{ -#ifdef CRUNCH - move((int)(lno - topline), 0); - if (showit) - { - drawtext(text, lno, TRUE); - } -#else /* not CRUNCH */ - static char old[256]; /* how the line looked last time */ - char new[256]; /* how it looks now */ - char *build; /* used to put chars into new[] */ - char *scan; /* used for moving thru new[] or old[] */ - char *end; /* last non-blank changed char */ - char *shift; /* used to insert/delete chars */ - int same; /* length of a run of unchanged chars */ - int limitcol; - int col; - int i; - char numstr[9]; - -# ifndef NO_CHARATTR - /* if this line has attributes, do it the dumb way instead */ - if (hasattr(lno, text)) - { - move((int)(lno - topline), 0); - drawtext(text, lno, TRUE); - return; - } -# endif -# ifndef NO_SENTENCE - /* if this line is a format line, & we're hiding format lines, then - * let the dumb drawtext() function handle it - */ - if (*o_hideformat && *text == '.') - { - move((int)(lno - topline), 0); - drawtext(text, lno, TRUE); - return; - } -# endif -# ifndef NO_VISIBLE - if (vizchange) - { - move((int)(lno - topline), 0); - drawtext(text, lno, TRUE); - smartlno = 0L; - return; - } -# endif - - /* skip stuff that was scrolled off left edge */ - limitcol = leftcol; - for (col = 0; - (i = *text) && col < limitcol; /* yes, ASSIGNMENT! */ - text++) - { - if (i == '\t' && !*o_list) - { - col = col + *o_tabstop - (col % *o_tabstop); - } - else if (i >= 0 && i < ' ' || i == '\177') - { - col += 2; - } - else - { - col++; - } - } - - /* adjust for control char that was partially visible */ - build = new; - while (col > limitcol) - { - *build++ = ' '; - limitcol++; - } - - /* now for the visible characters */ - limitcol = leftcol + COLS; - if (*o_number) - limitcol -= 8; - for (; (i = *text) && col < limitcol; text++) - { - if (i == '\t' && !*o_list) - { - i = col + *o_tabstop - (col % *o_tabstop); - while (col < i && col < limitcol) - { - *build++ = ' '; - col++; - } - } - else if (i >= 0 && i < ' ' || i == '\177') - { - col += 2; - *build++ = '^'; - if (col <= limitcol) - { - *build++ = (i ^ '@'); - } - } - else - { - col++; - *build++ = i; - } - } - if (col < limitcol && *o_list) - { - *build++ = '$'; - col++; - } - end = build; - while (col < limitcol) - { - *build++ = ' '; - col++; - } - - /* if we're just supposed to remember this line, then remember it */ - if (!showit) - { - smartlno = lno; - strncpy(old, new, COLS); - return; - } - - /* locate the last non-blank character */ - while (end > new && end[-1] == ' ') - { - end--; - } - - /* can we optimize the displaying of this line? */ - if (lno != smartlno) - { - /* nope, can't optimize - different line */ - move((int)(lno - topline), 0); - - /* show the line number, if necessary */ - if (*o_number) - { - sprintf(numstr, "%6ld ", lno); - qaddstr(numstr); - } - - /* show the new line */ - for (scan = new, build = old; scan < end; ) - { - qaddch(*scan); - *build++ = *scan++; - } - if (end < new + COLS - (*o_number ? 8 : 0)) - { - clrtoeol(); - while (build < old + COLS) - { - *build++ = ' '; - } - } - smartlno = lno; - return; - } - - /* skip any initial unchanged characters */ - for (scan = new, build = old; scan < end && *scan == *build; scan++, build++) - { - } - i = (scan - new); - if (*o_number) - i += 8; - move((int)(lno - topline), i); - - /* The in-between characters must be changed */ - same = 0; - while (scan < end) - { - /* is this character a match? */ - if (scan[0] == build[0]) - { - same++; - } - else /* do we want to insert? */ - if (scan < end - 1 && scan[1] == build[0] && (has_IC || has_IM)) - { - nudgecursor(same, scan, new, lno); - same = 0; - - insch(*scan); - for (shift = old + COLS; --shift > build; ) - { - shift[0] = shift[-1]; - } - *build = *scan; - } - else /* do we want to delete? */ - if (build < old + COLS - 1 && scan[0] == build[1] && has_DC) - { - nudgecursor(same, scan, new, lno); - same = 0; - - delch(); - same++; - for (shift = build; shift < old + COLS - 1; shift++) - { - shift[0] = shift[1]; - } - if (*o_number) - shift -= 8; - *shift = ' '; - } - else /* we must overwrite */ - { - nudgecursor(same, scan, new, lno); - same = 0; - - addch(*scan); - *build = *scan; - } - - build++; - scan++; - } - - /* maybe clear to EOL */ - end = old + COLS - (*o_number ? 8 : 0); - while (build < end && *build == ' ') - { - build++; - } - if (build < end) - { - nudgecursor(same, scan, new, lno); - same = 0; - - clrtoeol(); - while (build < old + COLS) - { - *build++ = ' '; - } - } -#endif /* not CRUNCH */ -} - - -/* This function is used in visual mode for drawing the screen (or just parts - * of the screen, if that's all thats needed). It also takes care of - * scrolling. - */ -void redraw(curs, inputting) - MARK curs; /* where to leave the screen's cursor */ - int inputting; /* boolean: being called from input() ? */ -{ - char *text; /* a line of text to display */ - static long chgs; /* previous changes level */ - long l; - int i; -#ifndef CRUNCH - static long showtop; /* top line in window */ - static long showbottom; /* bottom line in window */ -#endif - - /* if curs == MARK_UNSET, then we should reset internal vars */ - if (curs == MARK_UNSET) - { - if (topline < 1 || topline > nlines) - { - topline = 1L; - } - else - { - move(LINES - 1, 0); - clrtoeol(); - } - leftcol = 0; - mustredraw = TRUE; - redrawafter = INFINITY; - preredraw = 0L; - postredraw = 0L; - chgs = 0; - smartlno = 0L; -#ifndef NO_VISIBLE - vizlow = vizhigh = 0L; - vizchange = FALSE; -#endif -#ifndef CRUNCH - showtop = 0; - showbottom = INFINITY; -#endif - return; - } - -#ifndef NO_VISIBLE - /* adjustments to hilited area may force extra lines to be redrawn. */ - setviz(curs); -#endif - - /* figure out which column the cursor will be in */ - l = markline(curs); - text = fetchline(l); - mark2phys(curs, text, inputting); - -#ifndef NO_COLOR - fixcolor(); -#endif - - /* adjust topline, if necessary, to get the cursor on the screen */ - if (l >= topline && l <= botline) - { - /* it is on the screen already */ - - /* if the file was changed but !mustredraw, then redraw line */ - if (!mustredraw && (chgs != changes -#ifndef NO_VISIBLE - || V_from -#endif -#ifndef CRUNCH - || l < showtop || l > showbottom -#endif - )) - { - smartdrawtext(text, l, (chgs != changes)); - } - } - else if (l < topline && l >= topline - NEAR && (has_SR || has_AL)) - { - /* near top - scroll down */ - if (!mustredraw) - { - move(0,0); - while (l < topline) - { - topline--; - if (has_SR) - { - do_SR(); - } - else - { - insertln(); - } - text = fetchline(topline); - drawtext(text, topline, FALSE); - do_UP(); - } - - /* blank out the last line */ - move(LINES - 1, 0); - clrtoeol(); - } - else - { - topline = l; - redrawrange(0L, INFINITY, INFINITY); - } - } - else if (l > topline && l <= botline + NEAR) - { - /* near bottom -- scroll up */ - if (!mustredraw) - { - move(LINES - 1,0); - clrtoeol(); - while (l > botline) - { - topline++; /* <-- also adjusts botline */ - text = fetchline(botline); - drawtext(text, botline, FALSE); - } -#ifndef CRUNCH - showbottom = l; -#endif - } - else - { - topline = l - (LINES - 2); - redrawrange(0L, INFINITY, INFINITY); - } - } - else - { - /* distant line - center it & force a redraw */ - topline = l - (LINES - 1) / 2; - if (topline < 1) - { - topline = 1; - } - redrawrange(0L, INFINITY, INFINITY); - smartlno = 0L; - changes++; - } - -#ifndef CRUNCH - /* make sure the current line is included in the "window" */ - if (l < showtop) - { - redrawrange(l, showtop, showtop); - showtop = l; - } - if (l > showbottom) - { - redrawrange(showbottom, l, l); - showbottom = l; - } -#endif - - - /* Now... do we really have to redraw? */ - if (mustredraw) - { - /* If redrawfter (and friends) aren't set, assume we should - * redraw everything. - */ - if (redrawafter == INFINITY) - { - redrawafter = 0L; - preredraw = postredraw = INFINITY; - } - -#ifndef CRUNCH - /* shrink the window, if possible */ - if (showtop < topline) - { - showtop = topline; - } - if (showbottom > botline) - { - showbottom = botline; - } - if (postredraw == INFINITY) - { - /* these will be set to more reasonable values later */ - showtop = INFINITY; - showbottom = 0L; - } -#endif - - /* adjust smartlno to correspond with inserted/deleted lines */ - if (smartlno >= redrawafter) - { - if (smartlno < preredraw && postredraw != preredraw) /*!!!*/ - { - smartlno = 0L; - } - else - { - smartlno += (postredraw - preredraw); - } - } - - /* should we insert some lines into the screen? */ - if (preredraw < postredraw && preredraw <= botline) - { - /* lines were inserted into the file */ - - /* decide where insertion should start */ - if (preredraw < topline) - { - l = topline; - } - else - { - l = preredraw; - } - - /* insert the lines... maybe */ - if (l + postredraw - preredraw > botline || !has_AL || *o_number) - { - /* Whoa! a whole screen full - just redraw */ - preredraw = postredraw = INFINITY; - } - else - { - /* really insert 'em */ - move((int)(l - topline), 0); - for (i = postredraw - preredraw; i > 0; i--) - { - insertln(); - } - - /* NOTE: the contents of those lines will be - * drawn as part of the regular redraw loop. - */ - - /* clear the last line */ - move(LINES - 1, 0); - clrtoeol(); - } - } - - /* do we want to delete some lines from the screen? */ - if (preredraw > postredraw && postredraw <= botline) - { - if (preredraw > botline || !has_DL || *o_number) - { - postredraw = preredraw = INFINITY; - } - else /* we'd best delete some lines from the screen */ - { - /* clear the last line, so it doesn't look - * ugly as it gets pulled up into the screen - */ - move(LINES - 1, 0); - clrtoeol(); - - /* delete the lines */ - move((int)(postredraw - topline), 0); - for (l = postredraw; - l < preredraw && l <= botline; - l++) - { - deleteln(); - } - - /* draw the lines that are now newly visible - * at the bottom of the screen - */ - i = LINES - 1 + (postredraw - preredraw); - move(i, 0); - for (l = topline + i; l <= botline; l++) - { - /* clear this line */ - clrtoeol(); - - /* draw the line, or ~ for non-lines */ - if (l <= nlines) - { - text = fetchline(l); - drawtext(text, l, FALSE); - } - else - { - addstr("~\n"); - } - } - } - } - - /* redraw the current line */ - l = markline(curs); - pfetch(l); - smartdrawtext(ptext, l, TRUE); - -#ifndef CRUNCH - /* decide which lines must be in the "window" around the cursor */ - l = markline(curs); - if ((*o_window & 0xff) + 1 == LINES) - { - showtop = 1; - showbottom = INFINITY; - } - else if (l < showtop || l > showbottom) - { - l -= (*o_window & 0xff) / 2; - if (l < topline) - { - l = topline; - } - if (l < showtop) - { - showtop = l; - } - l += (*o_window & 0xff) - 1; - if (l > botline) - { - showtop = showtop - l + botline; - l = botline; - } - if (l > showbottom) - { - showbottom = l; - } - } -#endif - - /* decide where we should start redrawing from */ - if (redrawafter < topline) - { - l = topline; - } - else - { - l = redrawafter; - } - if (l <= botline && l < postredraw && (l != smartlno || botline != smartlno)) - { - /* draw the other lines */ - move((int)(l - topline), 0); - for (; l <= botline && l < postredraw; l++) - { - /* we already drew the current line, so skip it now */ - if (l == smartlno) - { -#if OSK - qaddch('\l'); -#else - qaddch('\n'); -#endif - continue; - } - - /* draw the line, or ~ for non-lines */ - if (l > nlines) - { - qaddch('~'); - clrtoeol(); - addch('\n'); - } -#ifndef CRUNCH - else if (l < showtop || l > showbottom) - { - qaddch('@'); - clrtoeol(); - addch('\n'); - } -#endif - else - { - text = fetchline(l); - drawtext(text, l, TRUE); - } - } - } - - mustredraw = FALSE; - } - - /* force total (non-partial) redraw next time if not set */ - redrawafter = INFINITY; - preredraw = 0L; - postredraw = 0L; - - /* move the cursor to where it belongs */ - move((int)(markline(curs) - topline), physcol); - wqrefresh(); - - chgs = changes; -} diff --git a/usr.bin/elvis/regexp.c b/usr.bin/elvis/regexp.c deleted file mode 100644 index 603e6d0dddbc..000000000000 --- a/usr.bin/elvis/regexp.c +++ /dev/null @@ -1,1036 +0,0 @@ -/* regexp.c */ - -/* This file contains the code that compiles regular expressions and executes - * them. It supports the same syntax and features as vi's regular expression - * code. Specifically, the meta characters are: - * ^ matches the beginning of a line - * $ matches the end of a line - * \< matches the beginning of a word - * \> matches the end of a word - * . matches any single character - * [] matches any character in a character class - * \( delimits the start of a subexpression - * \) delimits the end of a subexpression - * * repeats the preceding 0 or more times - * NOTE: You cannot follow a \) with a *. - * - * The physical structure of a compiled RE is as follows: - * - First, there is a one-byte value that says how many character classes - * are used in this regular expression - * - Next, each character class is stored as a bitmap that is 256 bits - * (32 bytes) long. - * - A mixture of literal characters and compiled meta characters follows. - * This begins with M_BEGIN(0) and ends with M_END(0). All meta chars - * are stored as a \n followed by a one-byte code, so they take up two - * bytes apiece. Literal characters take up one byte apiece. \n can't - * be used as a literal character. - * - * If NO_MAGIC is defined, then a different set of functions is used instead. - * That right, this file contains TWO versions of the code. - */ - -#ifndef lint -static char rcsid[] = "$Id: regexp.c,v 1.4 1993/11/08 05:06:24 alm Exp $"; -#endif /* not lint */ - - -#include <setjmp.h> -#include "config.h" -#include "ctype.h" -#include "vi.h" -#ifdef REGEX -# include <regex.h> -#else -# include "regexp.h" -#endif - - -#ifdef REGEX -extern int patlock; /* from cmd_substitute() module */ - -static regex_t *previous = NULL; /* the previous regexp, used when null regexp is given */ - -regex_t * -optpat(s) - char *s; -{ - static char *neuter(); - - int n; - if (*s == '\0') { - if (!previous) regerr("RE error: no previous pattern"); - return previous; - } else if (previous && !patlock) - regfree(previous); - else if ((previous = (regex_t *) malloc(sizeof(regex_t))) == NULL) { - regerr("RE error: out of memory"); - return previous; - } - patlock = 0; - if (n = regcomp(previous, *o_magic ? s : neuter(s), - *o_ignorecase ? REG_ICASE : 0)) { - regerr("RE error: %d", n); - free(previous); - return previous = NULL; - } - return previous; -} - -/* escape BRE meta-characters in a string */ -static char * -neuter(s) - char *s; -{ - static char *hd = NULL; - - char *t; - int n = strlen(s); - - free(hd); - if ((hd = t = (char *) malloc(n + n + 1)) == NULL) - return NULL; - if (*s == '^') - *t++ = *s++; - while (*s) { - if (*s == '.' || *s == '\\' || *s == '[' || *s == '*') - *t++ = '\\'; - *t++ = *s++; - } - *t = '\0'; - return hd; -} - -#else -static char *previous; /* the previous regexp, used when null regexp is given */ - - -#ifndef NO_MAGIC -/* THE REAL REGEXP PACKAGE IS USED UNLESS "NO_MAGIC" IS DEFINED */ - -/* These are used to classify or recognize meta-characters */ -#define META '\0' -#define BASE_META(m) ((m) - 256) -#define INT_META(c) ((c) + 256) -#define IS_META(m) ((m) >= 256) -#define IS_CLASS(m) ((m) >= M_CLASS(0) && (m) <= M_CLASS(9)) -#define IS_START(m) ((m) >= M_START(0) && (m) <= M_START(9)) -#define IS_END(m) ((m) >= M_END(0) && (m) <= M_END(9)) -#define IS_CLOSURE(m) ((m) >= M_SPLAT && (m) <= M_RANGE) -#define ADD_META(s,m) (*(s)++ = META, *(s)++ = BASE_META(m)) -#define GET_META(s) (*(s) == META ? INT_META(*++(s)) : *s) - -/* These are the internal codes used for each type of meta-character */ -#define M_BEGLINE 256 /* internal code for ^ */ -#define M_ENDLINE 257 /* internal code for $ */ -#define M_BEGWORD 258 /* internal code for \< */ -#define M_ENDWORD 259 /* internal code for \> */ -#define M_ANY 260 /* internal code for . */ -#define M_SPLAT 261 /* internal code for * */ -#define M_PLUS 262 /* internal code for \+ */ -#define M_QMARK 263 /* internal code for \? */ -#define M_RANGE 264 /* internal code for \{ */ -#define M_CLASS(n) (265+(n)) /* internal code for [] */ -#define M_START(n) (275+(n)) /* internal code for \( */ -#define M_END(n) (285+(n)) /* internal code for \) */ - -/* These are used during compilation */ -static int class_cnt; /* used to assign class IDs */ -static int start_cnt; /* used to assign start IDs */ -static int end_stk[NSUBEXP];/* used to assign end IDs */ -static int end_sp; -static char *retext; /* points to the text being compiled */ - -/* error-handling stuff */ -jmp_buf errorhandler; -#define FAIL(why) regerr(why); longjmp(errorhandler, 1) - - - - - -/* This function builds a bitmap for a particular class */ -static char *makeclass(text, bmap) - REG char *text; /* start of the class */ - REG char *bmap; /* the bitmap */ -{ - REG int i; - int complement = 0; - - - checkmem(); - - /* zero the bitmap */ - for (i = 0; bmap && i < 32; i++) - { - bmap[i] = 0; - } - - /* see if we're going to complement this class */ - if (*text == '^') - { - text++; - complement = 1; - } - - /* add in the characters */ - while (*text && *text != ']') - { - /* is this a span of characters? */ - if (text[1] == '-' && text[2]) - { - /* spans can't be backwards */ - if (text[0] > text[2]) - { - FAIL("Backwards span in []"); - } - - /* add each character in the span to the bitmap */ - for (i = UCHAR(text[0]); bmap && (unsigned)i <= UCHAR(text[2]); i++) - { - bmap[i >> 3] |= (1 << (i & 7)); - } - - /* move past this span */ - text += 3; - } - else - { - /* add this single character to the span */ - i = *text++; - if (bmap) - { - bmap[UCHAR(i) >> 3] |= (1 << (UCHAR(i) & 7)); - } - } - } - - /* make sure the closing ] is missing */ - if (*text++ != ']') - { - FAIL("] missing"); - } - - /* if we're supposed to complement this class, then do so */ - if (complement && bmap) - { - for (i = 0; i < 32; i++) - { - bmap[i] = ~bmap[i]; - } - } - - checkmem(); - - return text; -} - - - - -/* This function gets the next character or meta character from a string. - * The pointer is incremented by 1, or by 2 for \-quoted characters. For [], - * a bitmap is generated via makeclass() (if re is given), and the - * character-class text is skipped. - */ -static int gettoken(sptr, re) - char **sptr; - regexp *re; -{ - int c; - - c = **sptr; - if (!c) - { - return c; - } - ++*sptr; - if (c == '\\') - { - c = **sptr; - ++*sptr; - switch (c) - { - case '<': - return M_BEGWORD; - - case '>': - return M_ENDWORD; - - case '(': - if (start_cnt >= NSUBEXP) - { - FAIL("Too many \\(s"); - } - end_stk[end_sp++] = start_cnt; - return M_START(start_cnt++); - - case ')': - if (end_sp <= 0) - { - FAIL("Mismatched \\)"); - } - return M_END(end_stk[--end_sp]); - - case '*': - return (*o_magic ? c : M_SPLAT); - - case '.': - return (*o_magic ? c : M_ANY); - - case '+': - return M_PLUS; - - case '?': - return M_QMARK; -#ifndef CRUNCH - case '{': - return M_RANGE; -#endif - default: - return c; - } - } - else if (*o_magic) - { - switch (c) - { - case '^': - if (*sptr == retext + 1) - { - return M_BEGLINE; - } - return c; - - case '$': - if (!**sptr) - { - return M_ENDLINE; - } - return c; - - case '.': - return M_ANY; - - case '*': - return M_SPLAT; - - case '[': - /* make sure we don't have too many classes */ - if (class_cnt >= 10) - { - FAIL("Too many []s"); - } - - /* process the character list for this class */ - if (re) - { - /* generate the bitmap for this class */ - *sptr = makeclass(*sptr, re->program + 1 + 32 * class_cnt); - } - else - { - /* skip to end of the class */ - *sptr = makeclass(*sptr, (char *)0); - } - return M_CLASS(class_cnt++); - - default: - return c; - } - } - else /* unquoted nomagic */ - { - switch (c) - { - case '^': - if (*sptr == retext + 1) - { - return M_BEGLINE; - } - return c; - - case '$': - if (!**sptr) - { - return M_ENDLINE; - } - return c; - - default: - return c; - } - } - /*NOTREACHED*/ -} - - - - -/* This function calculates the number of bytes that will be needed for a - * compiled RE. Its argument is the uncompiled version. It is not clever - * about catching syntax errors; that is done in a later pass. - */ -static unsigned calcsize(text) - char *text; -{ - unsigned size; - int token; - - retext = text; - class_cnt = 0; - start_cnt = 1; - end_sp = 0; - size = 5; - while ((token = gettoken(&text, (regexp *)0)) != 0) - { - if (IS_CLASS(token)) - { - size += 34; - } -#ifndef CRUNCH - else if (token == M_RANGE) - { - size += 4; - while ((token = gettoken(&text, (regexp *)0)) != 0 - && token != '}') - { - } - if (!token) - { - return size; - } - } -#endif - else if (IS_META(token)) - { - size += 2; - } - else - { - size++; - } - } - - return size; -} - - - -/* This function compiles a regexp. */ -regexp *regcomp(exp) - char *exp; -{ - int needfirst; - unsigned size; - int token; - int peek; - char *build; -#if __STDC__ - volatile -#endif - regexp *re; -#ifndef CRUNCH - int from; - int to; - int digit; -#endif -#ifdef DEBUG - int calced; -#endif - - - checkmem(); - - /* prepare for error handling */ - re = (regexp *)0; - if (setjmp(errorhandler)) - { - checkmem(); - if (re) - { - _free_(re); - } - return (regexp *)0; - } - - /* if an empty regexp string was given, use the previous one */ - if (*exp == 0) - { - if (!previous) - { - FAIL("No previous RE"); - } - exp = previous; - } - else /* non-empty regexp given, so remember it */ - { - if (previous) - _free_(previous); - previous = (char *)malloc((unsigned)(strlen(exp) + 1)); - if (previous) - strcpy(previous, exp); - } - - /* allocate memory */ - checkmem(); - class_cnt = 0; - start_cnt = 1; - end_sp = 0; - retext = exp; -#ifdef DEBUG - calced = calcsize(exp); - size = calced + sizeof(regexp); -#else - size = calcsize(exp) + sizeof(regexp) + 10; /* !!! 10 bytes for slop */ -#endif -#ifdef lint - re = (regexp *)0; -#else - re = (regexp *)malloc((unsigned)size); -#endif - if (!re) - { - FAIL("Not enough memory for this RE"); - } - checkmem(); - - /* compile it */ - build = &re->program[1 + 32 * class_cnt]; - re->program[0] = class_cnt; - for (token = 0; token < NSUBEXP; token++) - { - re->startp[token] = re->endp[token] = (char *)0; - } - re->first = 0; - re->bol = 0; - re->minlen = 0; - needfirst = 1; - class_cnt = 0; - start_cnt = 1; - end_sp = 0; - retext = exp; - for (token = M_START(0), peek = gettoken(&exp, re); - token; - token = peek, peek = gettoken(&exp, re)) - { - /* special processing for the closure operator */ - if (IS_CLOSURE(peek)) - { - /* detect misuse of closure operator */ - if (IS_START(token)) - { - FAIL("Closure operator follows nothing"); - } - else if (IS_META(token) && token != M_ANY && !IS_CLASS(token)) - { - FAIL("Closure operators can only follow a normal character or . or []"); - } - -#ifndef CRUNCH - /* if \{ \} then read the range */ - if (peek == M_RANGE) - { - from = 0; - for (digit = gettoken(&exp, re); - !IS_META(digit) && isdigit(digit); - digit = gettoken(&exp, re)) - { - from = from * 10 + digit - '0'; - } - if (digit == '}') - { - to = from; - } - else if (digit == ',') - { - to = 0; - for (digit = gettoken(&exp, re); - !IS_META(digit) && isdigit(digit); - digit = gettoken(&exp, re)) - { - to = to * 10 + digit - '0'; - } - if (to == 0) - { - to = 255; - } - } - if (digit != '}') - { - FAIL("Bad characters after \\{"); - } - else if (to < from || to == 0 || from >= 255) - { - FAIL("Invalid range for \\{ \\}"); - } - re->minlen += from; - } - else -#endif - if (peek != M_SPLAT) - { - re->minlen++; - } - - /* it is okay -- make it prefix instead of postfix */ - ADD_META(build, peek); -#ifndef CRUNCH - if (peek == M_RANGE) - { - *build++ = from; - *build++ = (to < 255 ? to : 255); - } -#endif - - - /* take care of "needfirst" - is this the first char? */ - if (needfirst && peek == M_PLUS && !IS_META(token)) - { - re->first = token; - } - needfirst = 0; - - /* we used "peek" -- need to refill it */ - peek = gettoken(&exp, re); - if (IS_CLOSURE(peek)) - { - FAIL("* or \\+ or \\? doubled up"); - } - } - else if (!IS_META(token)) - { - /* normal char is NOT argument of closure */ - if (needfirst) - { - re->first = token; - needfirst = 0; - } - re->minlen++; - } - else if (token == M_ANY || IS_CLASS(token)) - { - /* . or [] is NOT argument of closure */ - needfirst = 0; - re->minlen++; - } - - /* the "token" character is not closure -- process it normally */ - if (token == M_BEGLINE) - { - /* set the BOL flag instead of storing M_BEGLINE */ - re->bol = 1; - } - else if (IS_META(token)) - { - ADD_META(build, token); - } - else - { - *build++ = token; - } - } - checkmem(); - - /* end it with a \) which MUST MATCH the opening \( */ - ADD_META(build, M_END(0)); - if (end_sp > 0) - { - FAIL("Not enough \\)s"); - } - -#ifdef DEBUG - if ((int)(build - re->program) != calced) - { - msg("regcomp error: calced=%d, actual=%d", calced, (int)(build - re->program)); - getkey(0); - } -#endif - - checkmem(); - return re; -} - - - -/*---------------------------------------------------------------------------*/ - - -/* This function checks for a match between a character and a token which is - * known to represent a single character. It returns 0 if they match, or - * 1 if they don't. - */ -int match1(re, ch, token) - regexp *re; - REG char ch; - REG int token; -{ - if (!ch) - { - /* the end of a line can't match any RE of width 1 */ - return 1; - } - if (token == M_ANY) - { - return 0; - } - else if (IS_CLASS(token)) - { - if (re->program[1 + 32 * (token - M_CLASS(0)) + (UCHAR(ch) >> 3)] & (1 << (UCHAR(ch) & 7))) - return 0; - } - else if (ch == token || *o_ignorecase && tolower(ch) == tolower(token)) - { - return 0; - } - return 1; -} - - - -/* This function checks characters up to and including the next closure, at - * which point it does a recursive call to check the rest of it. This function - * returns 0 if everything matches, or 1 if something doesn't match. - */ -int match(re, str, prog, here) - regexp *re; /* the regular expression */ - char *str; /* the string */ - REG char *prog; /* a portion of re->program, an compiled RE */ - REG char *here; /* a portion of str, the string to compare it to */ -{ - REG int token; /* the roken pointed to by prog */ - REG int nmatched;/* counter, used during closure matching */ - REG int closure;/* the token denoting the type of closure */ - int from; /* minimum number of matches in closure */ - int to; /* maximum number of matches in closure */ - - for (token = GET_META(prog); !IS_CLOSURE(token); prog++, token = GET_META(prog)) - { - switch (token) - { - /*case M_BEGLINE: can't happen; re->bol is used instead */ - case M_ENDLINE: - if (*here) - return 1; - break; - - case M_BEGWORD: - if (here != str && - (here[-1] == '_' || isalnum(here[-1]))) - return 1; - break; - - case M_ENDWORD: - if (here[0] == '_' || isalnum(here[0])) - return 1; - break; - - case M_START(0): - case M_START(1): - case M_START(2): - case M_START(3): - case M_START(4): - case M_START(5): - case M_START(6): - case M_START(7): - case M_START(8): - case M_START(9): - re->startp[token - M_START(0)] = (char *)here; - break; - - case M_END(0): - case M_END(1): - case M_END(2): - case M_END(3): - case M_END(4): - case M_END(5): - case M_END(6): - case M_END(7): - case M_END(8): - case M_END(9): - re->endp[token - M_END(0)] = (char *)here; - if (token == M_END(0)) - { - return 0; - } - break; - - default: /* literal, M_CLASS(n), or M_ANY */ - if (match1(re, *here, token) != 0) - return 1; - here++; - } - } - - /* C L O S U R E */ - - /* step 1: see what we have to match against, and move "prog" to point - * to the remainder of the compiled RE. - */ - closure = token; - prog++; - switch (closure) - { - case M_SPLAT: - from = 0; - to = strlen(str); /* infinity */ - break; - - case M_PLUS: - from = 1; - to = strlen(str); /* infinity */ - break; - - case M_QMARK: - from = 0; - to = 1; - break; - -#ifndef CRUNCH - case M_RANGE: - from = UCHAR(*prog++); - to = UCHAR(*prog++); - if (to == 255) - { - to = strlen(str); /* infinity */ - } - break; -#endif - } - token = GET_META(prog); - prog++; - - /* step 2: see how many times we can match that token against the string */ - for (nmatched = 0; - nmatched < to && *here && match1(re, *here, token) == 0; - nmatched++, here++) - { - } - - /* step 3: try to match the remainder, and back off if it doesn't */ - while (nmatched >= from && match(re, str, prog, here) != 0) - { - nmatched--; - here--; - } - - /* so how did it work out? */ - if (nmatched >= from) - return 0; - return 1; -} - - - -/* This function searches through a string for text that matches an RE. */ -int regexec(re, str, bol) - regexp *re; /* the compiled regexp to search for */ - char *str; /* the string to search through */ - int bol; /* boolean: does str start at the beginning of a line? */ -{ - char *prog; /* the entry point of re->program */ - int len; /* length of the string */ - REG char *here; - - checkmem(); - - /* if must start at the beginning of a line, and this isn't, then fail */ - if (re->bol && !bol) - { - return 0; - } - - len = strlen(str); - prog = re->program + 1 + 32 * re->program[0]; - - /* search for the RE in the string */ - if (re->bol) - { - /* must occur at BOL */ - if ((re->first - && match1(re, *(char *)str, re->first))/* wrong first letter? */ - || len < re->minlen /* not long enough? */ - || match(re, (char *)str, prog, str)) /* doesn't match? */ - return 0; /* THEN FAIL! */ - } -#ifndef CRUNCH - else if (!*o_ignorecase) - { - /* can occur anywhere in the line, noignorecase */ - for (here = (char *)str; - (re->first && re->first != *here) - || match(re, (char *)str, prog, here); - here++, len--) - { - if (len < re->minlen) - return 0; - } - } -#endif - else - { - /* can occur anywhere in the line, ignorecase */ - for (here = (char *)str; - (re->first && match1(re, *here, (int)re->first)) - || match(re, (char *)str, prog, here); - here++, len--) - { - if (len < re->minlen) - return 0; - } - } - - /* if we didn't fail, then we must have succeeded */ - checkmem(); - return 1; -} - -/*============================================================================*/ -#else /* NO_MAGIC */ - -regexp *regcomp(exp) - char *exp; -{ - char *src; - char *dest; - regexp *re; - int i; - - /* allocate a big enough regexp structure */ -#ifdef lint - re = (regexp *)0; -#else - re = (regexp *)malloc((unsigned)(strlen(exp) + 1 + sizeof(struct regexp))); -#endif - if (!re) - { - regerr("Could not malloc a regexp structure"); - return (regexp *)0; - } - - /* initialize all fields of the structure */ - for (i = 0; i < NSUBEXP; i++) - { - re->startp[i] = re->endp[i] = (char *)0; - } - re->minlen = 0; - re->first = 0; - re->bol = 0; - - /* copy the string into it, translating ^ and $ as needed */ - for (src = exp, dest = re->program + 1; *src; src++) - { - switch (*src) - { - case '^': - if (src == exp) - { - re->bol += 1; - } - else - { - *dest++ = '^'; - re->minlen++; - } - break; - - case '$': - if (!src[1]) - { - re->bol += 2; - } - else - { - *dest++ = '$'; - re->minlen++; - } - break; - - case '\\': - if (src[1]) - { - *dest++ = *++src; - re->minlen++; - } - else - { - regerr("extra \\ at end of regular expression"); - } - break; - - default: - *dest++ = *src; - re->minlen++; - } - } - *dest = '\0'; - - return re; -} - - -/* This "helper" function checks for a match at a given location. It returns - * 1 if it matches, 0 if it doesn't match here but might match later on in the - * string, or -1 if it could not possibly match - */ -static int reghelp(prog, string, bolflag) - struct regexp *prog; - char *string; - int bolflag; -{ - char *scan; - char *str; - - /* if ^, then require bolflag */ - if ((prog->bol & 1) && !bolflag) - { - return -1; - } - - /* if it matches, then it will start here */ - prog->startp[0] = string; - - /* compare, possibly ignoring case */ - if (*o_ignorecase) - { - for (scan = &prog->program[1]; *scan; scan++, string++) - if (tolower(*scan) != tolower(*string)) - return *string ? 0 : -1; - } - else - { - for (scan = &prog->program[1]; *scan; scan++, string++) - if (*scan != *string) - return *string ? 0 : -1; - } - - /* if $, then require string to end here, too */ - if ((prog->bol & 2) && *string) - { - return 0; - } - - /* if we get to here, it matches */ - prog->endp[0] = string; - return 1; -} - - - -int regexec(prog, string, bolflag) - struct regexp *prog; - char *string; - int bolflag; -{ - int rc; - - /* keep trying to match it */ - for (rc = reghelp(prog, string, bolflag); rc == 0; rc = reghelp(prog, string, 0)) - { - string++; - } - - /* did we match? */ - return rc == 1; -} -#endif -#endif /* !REGEX */ diff --git a/usr.bin/elvis/regexp.h b/usr.bin/elvis/regexp.h deleted file mode 100644 index 0c202154f3f2..000000000000 --- a/usr.bin/elvis/regexp.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Definitions etc. for regexp(3) routines. - * - * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], - * not the System V one. - * - * $Id: regexp.h,v 1.3 1993/11/08 05:06:29 alm Exp $ - */ -#define NSUBEXP 10 - -typedef struct regexp { - char *startp[NSUBEXP]; - char *endp[NSUBEXP]; - int minlen; /* length of shortest possible match */ - char first; /* first character, if known; else \0 */ - char bol; /* boolean: must start at beginning of line? */ - char program[1]; /* Unwarranted chumminess with compiler. */ -} regexp; - -extern regexp *regcomp(); -extern int regexec(); -extern void regsub(); -extern void regerr(); diff --git a/usr.bin/elvis/regsub.c b/usr.bin/elvis/regsub.c deleted file mode 100644 index c3668cfdf257..000000000000 --- a/usr.bin/elvis/regsub.c +++ /dev/null @@ -1,283 +0,0 @@ -/* regsub.c */ - -/* This file contains the regsub() function, which performs substitutions - * after a regexp match has been found. - */ - -#ifndef lint -static char rcsid[] = "$Id: regsub.c,v 1.4 1993/11/08 05:06:32 alm Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "ctype.h" -#include "vi.h" -#ifdef REGEX -# include <regex.h> -#else -# include "regexp.h" -#endif - - -/* perform substitutions after a regexp match */ -#ifdef REGEX -void regsub(rm, startp, endp, src, dst) - regmatch_t *rm; /* the regexp with pointers into matched text */ - char *startp, *endp; - REG char *src; /* the replacement string */ - REG char *dst; /* where to put the result of the subst */ -#else -void regsub(re, src, dst) - regexp *re; /* the regexp with pointers into matched text */ - REG char *src; /* the replacement string */ - REG char *dst; /* where to put the result of the subst */ -#endif -{ - REG char *cpy; /* pointer to start of text to copy */ - REG char *end; /* pointer to end of text to copy */ - REG char c; - char *start; -#ifndef CRUNCH - int mod = 0;/* used to track \U, \L, \u, \l, and \E */ - int len; /* used to calculate length of subst string */ - static char *prev; /* a copy of the text from the previous subst */ - - /* replace \~ (or maybe ~) by previous substitution text */ - - /* step 1: calculate the length of the new substitution text */ - for (len = strlen(src), c = '\0', cpy = src; *cpy; cpy++) - { -# ifdef NO_MAGIC - if (c == '\\' && *cpy == '~') -# else - if (c == (*o_magic ? '\0' : '\\') && *cpy == '~') -# endif - { - if (!prev) - { - regerr("No prev text to substitute for ~"); - - return; - } - len += strlen(prev) - 1; -# ifndef NO_MAGIC - if (!*o_magic) -# endif - len -= 1; /* because we lose the \ too */ - } - - /* watch backslash quoting */ - if (c != '\\' && *cpy == '\\') - c = '\\'; - else - c = '\0'; - } - - /* allocate memory for the ~ed version of src */ - checkmem(); - start = cpy = (char *)malloc((unsigned)(len + 1)); - if (!cpy) - { - regerr("Not enough memory for ~ expansion"); - return; - } - - /* copy src into start, replacing the ~s by the previous text */ - while (*src) - { -# ifndef NO_MAGIC - if (*o_magic && *src == '~') - { - strcpy(cpy, prev); - cpy += strlen(prev); - src++; - } - else if (!*o_magic && *src == '\\' && *(src + 1) == '~') -# else /* NO_MAGIC */ - if (*src == '\\' && *(src + 1) == '~') -# endif /* NO_MAGIC */ - { - strcpy(cpy, prev); - cpy += strlen(prev); - src += 2; - } - else - { - *cpy++ = *src++; - } - } - *cpy = '\0'; -#ifdef DEBUG - if ((int)(cpy - start) != len) - { - msg("Bug in regsub.c! Predicted length = %d, Actual length = %d", len, (int)(cpy - start)); - } -#endif - checkmem(); - - /* remember this as the "previous" for next time */ - if (prev) - _free_(prev); - prev = src = start; - -#endif /* undef CRUNCH */ - - start = src; - while ((c = *src++) != '\0') - { -#ifndef NO_MAGIC - /* recognize any meta characters */ - if (c == '&' && *o_magic) - { -#ifdef REGEX - cpy = startp; - end = endp; -#else - cpy = re->startp[0]; - end = re->endp[0]; -#endif - } - else -#endif /* not NO_MAGIC */ - if (c == '\\') - { - c = *src++; - switch (c) - { -#ifndef NO_MAGIC - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - /* \0 thru \9 mean "copy subexpression" */ - c -= '0'; -#ifdef REGEX - cpy = startp + (rm[c].rm_so - rm[0].rm_so); - end = endp + (rm[c].rm_eo - rm[0].rm_eo); -#else - cpy = re->startp[c]; - end = re->endp[c]; -#endif - break; -# ifndef CRUNCH - case 'U': - case 'u': - case 'L': - case 'l': - /* \U and \L mean "convert to upper/lowercase" */ - mod = c; - continue; - - case 'E': - case 'e': - /* \E ends the \U or \L */ - mod = 0; - continue; -# endif /* not CRUNCH */ - case '&': - /* "\&" means "original text" */ - if (*o_magic) - { - *dst++ = c; - continue; - } -#ifdef REGEX - cpy = startp; - end = endp; -#else - cpy = re->startp[0]; - end = re->endp[0]; -#endif - break; - -#else /* NO_MAGIC */ - case '&': - /* "\&" means "original text" */ -#ifdef REGEX - cpy = startp; - end = endp; -#else - cpy = re->startp[0]; - end = re->endp[0]; -#endif - break; -#endif /* NO_MAGIC */ - default: - /* ordinary char preceded by backslash */ - *dst++ = c; - continue; - } - } -#ifndef CRUNCH -# if OSK - else if (c == '\l') -# else - else if (c == '\r') -# endif - { - /* transliterate ^M into newline */ - *dst++ = '\n'; - continue; - } -#endif /* !CRUNCH */ - else - { - /* ordinary character, so just copy it */ - *dst++ = c; - continue; - } - - /* Note: to reach this point in the code, we must have evaded - * all "continue" statements. To do that, we must have hit - * a metacharacter that involves copying. - */ - - /* if there is nothing to copy, loop */ - if (!cpy) - continue; - - /* copy over a portion of the original */ - while (cpy < end) - { -#ifndef NO_MAGIC -# ifndef CRUNCH - switch (mod) - { - case 'U': - case 'u': - /* convert to uppercase */ - *dst++ = toupper(*cpy++); - break; - - case 'L': - case 'l': - /* convert to lowercase */ - *dst++ = tolower(*cpy++); - break; - - default: - /* copy without any conversion */ - *dst++ = *cpy++; - } - - /* \u and \l end automatically after the first char */ - if (mod && (mod == 'u' || mod == 'l')) - { - mod = 0; - } -# else /* CRUNCH */ - *dst++ = *cpy++; -# endif /* CRUNCH */ -#else /* NO_MAGIC */ - *dst++ = *cpy++; -#endif /* NO_MAGIC */ - } - } - *dst = '\0'; -} diff --git a/usr.bin/elvis/system.c b/usr.bin/elvis/system.c deleted file mode 100644 index 43ed29c386c9..000000000000 --- a/usr.bin/elvis/system.c +++ /dev/null @@ -1,425 +0,0 @@ -/* system.c -- UNIX version */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains a new version of the system() function and related stuff. - * - * Entry points are: - * system(cmd) - run a single shell command - * wildcard(names) - expand wildcard characters in filanames - * filter(m,n,cmd,back) - run text lines through a filter program - * - * This is probably the single least portable file in the program. The code - * shown here should work correctly if it links at all; it will work on UNIX - * and any O.S./Compiler combination which adheres to UNIX forking conventions. - */ - -#ifndef lint -static char rcsid[] = "$Id: system.c,v 1.3 1993/08/02 17:54:08 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" -#ifndef XDOS -extern char **environ; -#endif - -#if ANY_UNIX - -/* This is a new version of the system() function. The only difference - * between this one and the library one is: this one uses the o_shell option. - */ -int system(cmd) -#ifdef __STDC__ - const -#endif - char *cmd; /* a command to run */ -{ - int pid; /* process ID of child */ - int died; - int status; /* exit status of the command */ - - - signal(SIGINT, SIG_IGN); - pid = fork(); - switch (pid) - { - case -1: /* error */ - msg("fork() failed"); - status = -1; - break; - - case 0: /* child */ - /* for the child, close all files except stdin/out/err */ - for (status = 3; status < 60 && (close(status), errno != EINVAL); status++) - { - } - - signal(SIGINT, SIG_DFL); - if (cmd == o_shell) - { - execle(o_shell, o_shell, (char *)0, environ); - } - else - { - execle(o_shell, o_shell, "-c", cmd, (char *)0, environ); - } - msg("execle(\"%s\", ...) failed", o_shell); - exit(1); /* if we get here, the exec failed */ - - default: /* parent */ - do - { - died = wait(&status); - } while (died >= 0 && died != pid); - if (died < 0) - { - status = -1; - } - signal(SIGINT, trapint); - } - - return status; -} - -/* This private function opens a pipe from a filter. It is similar to the - * system() function above, and to popen(cmd, "r"). - */ -int rpipe(cmd, in) - char *cmd; /* the filter command to use */ - int in; /* the fd to use for stdin */ -{ - int r0w1[2];/* the pipe fd's */ - - /* make the pipe */ - if (pipe(r0w1) < 0) - { - return -1; /* pipe failed */ - } - - /* The parent process (elvis) ignores signals while the filter runs. - * The child (the filter program) will reset this, so that it can - * catch the signal. - */ - signal(SIGINT, SIG_IGN); - - switch (fork()) - { - case -1: /* error */ - return -1; - - case 0: /* child */ - /* close the "read" end of the pipe */ - close(r0w1[0]); - - /* redirect stdout to go to the "write" end of the pipe */ - close(1); - dup(r0w1[1]); - close(2); - dup(r0w1[1]); - close(r0w1[1]); - - /* redirect stdin */ - if (in != 0) - { - close(0); - dup(in); - close(in); - } - - /* the filter should accept SIGINT signals */ - signal(SIGINT, SIG_DFL); - - /* exec the shell to run the command */ - execle(o_shell, o_shell, "-c", cmd, (char *)0, environ); - exit(1); /* if we get here, exec failed */ - - default: /* parent */ - /* close the "write" end of the pipe */ - close(r0w1[1]); - - return r0w1[0]; - } -} - -#endif /* non-DOS */ - -#if OSK - -/* This private function opens a pipe from a filter. It is similar to the - * system() function above, and to popen(cmd, "r"). - */ -int rpipe(cmd, in) - char *cmd; /* the filter command to use */ - int in; /* the fd to use for stdin */ -{ - return osk_popen(cmd, "r", in, 0); -} -#endif - -#if ANY_UNIX || OSK - -/* This function closes the pipe opened by rpipe(), and returns 0 for success */ -int rpclose(fd) - int fd; -{ - int status; - - close(fd); - wait(&status); - signal(SIGINT, trapint); - return status; -} - -#endif /* non-DOS */ - -/* This function expands wildcards in a filename or filenames. It does this - * by running the "echo" command on the filenames via the shell; it is assumed - * that the shell will expand the names for you. If for any reason it can't - * run echo, then it returns the names unmodified. - */ - -#if MSDOS || TOS -#define PROG "wildcard " -#define PROGLEN 9 -#include <string.h> -#else -#define PROG "echo " -#define PROGLEN 5 -#endif - -#if !AMIGA -char *wildcard(names) - char *names; -{ - -# if VMS -/* - We could use expand() [vmswild.c], but what's the point on VMS? - Anyway, echo is the wrong thing to do, it takes too long to build - a subprocess on VMS and any "echo" program would have to be supplied - by elvis. More importantly, many VMS utilities expand names - themselves (the shell doesn't do any expansion) so the concept is - non-native. jdc -*/ - return names; -# else - - int i, j, fd; - REG char *s, *d; - - - /* build the echo command */ - if (names != tmpblk.c) - { - /* the names aren't in tmpblk.c, so we can do it the easy way */ - strcpy(tmpblk.c, PROG); - strcat(tmpblk.c, names); - } - else - { - /* the names are already in tmpblk.c, so shift them to make - * room for the word "echo " - */ - for (s = names + strlen(names) + 1, d = s + PROGLEN; s > names; ) - { - *--d = *--s; - } - strncpy(names, PROG, PROGLEN); - } - - /* run the command & read the resulting names */ - fd = rpipe(tmpblk.c, 0); - if (fd < 0) return names; - i = 0; - do - { - j = tread(fd, tmpblk.c + i, BLKSIZE - i); - i += j; - } while (j > 0); - - /* successful? */ - if (rpclose(fd) == 0 && j == 0 && i < BLKSIZE && i > 0) - { - tmpblk.c[i-1] = '\0'; /* "i-1" so we clip off the newline */ - return tmpblk.c; - } - else - { - return names; - } -# endif -} -#endif - -/* This function runs a range of lines through a filter program, and replaces - * the original text with the filtered version. As a special case, if "to" - * is MARK_UNSET, then it runs the filter program with stdin coming from - * /dev/null, and inserts any output lines. - */ -int filter(from, to, cmd, back) - MARK from, to; /* the range of lines to filter */ - char *cmd; /* the filter command */ - int back; /* boolean: will we read lines back? */ -{ - int scratch; /* fd of the scratch file */ - int fd; /* fd of the pipe from the filter */ - char scrout[50]; /* name of the scratch out file */ - MARK new; /* place where new text should go */ - long sent, rcvd; /* number of lines sent/received */ - int i, j; - - /* write the lines (if specified) to a temp file */ - if (to) - { - /* we have lines */ -#if MSDOS || TOS - strcpy(scrout, o_directory); - if ((i=strlen(scrout)) && !strchr("\\/:", scrout[i-1])) - scrout[i++]=SLASH; - strcpy(scrout+i, SCRATCHOUT+3); -#else - sprintf(scrout, SCRATCHOUT, o_directory); -#endif - mktemp(scrout); - cmd_write(from, to, CMD_BANG, FALSE, scrout); - sent = markline(to) - markline(from) + 1L; - - /* use those lines as stdin */ - scratch = open(scrout, O_RDONLY); - if (scratch < 0) - { - unlink(scrout); - return -1; - } - } - else - { - scratch = 0; - sent = 0L; - } - - /* start the filter program */ -#if VMS - /* - VMS doesn't know a thing about file descriptor 0. The rpipe - concept is non-portable. Hence we need a file name argument. - */ - fd = rpipe(cmd, scratch, scrout); -#else - fd = rpipe(cmd, scratch); -#endif - if (fd < 0) - { - if (to) - { - close(scratch); - unlink(scrout); - } - return -1; - } - - if (back) - { - ChangeText - { - /* adjust MARKs for whole lines, and set "new" */ - from &= ~(BLKSIZE - 1); - if (to) - { - to &= ~(BLKSIZE - 1); - to += BLKSIZE; - new = to; - } - else - { - new = from + BLKSIZE; - } - -#if VMS -/* Reading from a VMS mailbox (pipe) is record oriented... */ -# define tread vms_pread -#endif - - /* repeatedly read in new text and add it */ - rcvd = 0L; - while ((i = tread(fd, tmpblk.c, BLKSIZE - 1)) > 0) - { - tmpblk.c[i] = '\0'; - add(new, tmpblk.c); -#if VMS - /* What! An advantage to record oriented reads? */ - new += (i - 1); - new = (new & ~(BLKSIZE - 1)) + BLKSIZE; - rcvd++; -#else - for (i = 0; tmpblk.c[i]; i++) - { - if (tmpblk.c[i] == '\n') - { - new = (new & ~(BLKSIZE - 1)) + BLKSIZE; - rcvd++; - } - else - { - new++; - } - } -#endif - } - - /* delete old text, if any */ - if (to) - { - cut(from, to); - delete(from, to); - } - } - } - else - { - /* read the command's output, and copy it to the screen */ - while ((i = tread(fd, tmpblk.c, BLKSIZE - 1)) > 0) - { - for (j = 0; j < i; j++) - { - addch(tmpblk.c[j]); - } - } - rcvd = 0; - } - - /* Reporting... */ - if (sent >= *o_report || rcvd >= *o_report) - { - if (sent > 0L && rcvd > 0L) - { - msg("%ld lines out, %ld lines back", sent, rcvd); - } - else if (sent > 0) - { - msg("%ld lines written to filter", sent); - } - else - { - msg("%ld lines read from filter", rcvd); - } - } - rptlines = 0L; - - /* cleanup */ - rpclose(fd); - if (to) - { - close(scratch); - unlink(scrout); - } - return 0; -} diff --git a/usr.bin/elvis/tio.c b/usr.bin/elvis/tio.c deleted file mode 100644 index 503b3b975bf6..000000000000 --- a/usr.bin/elvis/tio.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* tio.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains terminal I/O functions */ - -#ifndef lint -static char rcsid[] = "$Id: tio.c,v 1.3 1993/08/02 17:54:10 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" -#include "ctype.h" - -static int showmsg P_((void)); - -/* This function reads in a line from the terminal. */ -int vgets(prompt, buf, bsize) - int prompt; /* the prompt character, or '\0' for none */ - char *buf; /* buffer into which the string is read */ - int bsize; /* size of the buffer */ -{ - int len; /* how much we've read so far */ - int ch; /* a character from the user */ - int quoted; /* is the next char quoted? */ - int tab; /* column position of cursor */ - char widths[132]; /* widths of characters */ - int word; /* index of first letter of word */ -#ifndef NO_DIGRAPH - int erased; /* 0, or first char of a digraph */ -#endif - - /* show the prompt */ - move(LINES - 1, 0); - tab = 0; - if (prompt) - { - addch(prompt); - tab = 1; - } - clrtoeol(); - refresh(); - - /* read in the line */ -#ifndef NO_DIGRAPH - erased = -#endif - quoted = len = 0; - for (;;) - { -#ifndef NO_ABBR - if (quoted || mode == MODE_EX) - { - ch = getkey(0); - } - else - { - /* maybe expand an abbreviation while getting key */ - for (word = len; --word >= 0 && !isspace(buf[word]); ) - { - } - word++; - ch = getabkey(WHEN_EX, &buf[word], len - word); - } -#else - ch = getkey(0); -#endif -#ifndef NO_EXTENSIONS - if (ch == ctrl('O')) - { - ch = getkey(quoted ? 0 : WHEN_EX); - } -#endif - - /* some special conversions */ -#if 0 - if (ch == ctrl('D') && len == 0) - ch = ctrl('['); -#endif -#ifndef NO_DIGRAPH - if (*o_digraph && erased != 0 && ch != '\b') - { - ch = digraph(erased, ch); - erased = 0; - } -#endif - - /* inhibit detection of special chars (except ^J) after a ^V */ - if (quoted && ch != '\n') - { - ch |= 256; - } - - /* process the character */ - switch(ch) - { - case ctrl('V'): - qaddch('^'); - qaddch('\b'); - quoted = TRUE; - break; - - case ctrl('D'): - return -1; - - case ctrl('['): - case '\n': -#if OSK - case '\l': -#else - case '\r': -#endif - clrtoeol(); - goto BreakBreak; - -#ifndef CRUNCH - case ctrl('U'): - while (len > 0) - { - len--; - while (widths[len]-- > 0) - { - qaddch('\b'); - qaddch(' '); - qaddch('\b'); - } - } - break; -#endif - - case '\b': - if (len > 0) - { - len--; -#ifndef NO_DIGRAPH - erased = buf[len]; -#endif - for (ch = widths[len]; ch > 0; ch--) - addch('\b'); - if (mode == MODE_EX) - { - clrtoeol(); - } - tab -= widths[len]; - } - else - { - return -1; - } - break; - - default: - /* strip off quotation bit */ - if (ch & 256) - { - ch &= ~256; - qaddch(' '); - qaddch('\b'); - } - - /* add & echo the char */ - if (len < bsize - 1) - { - if (ch == '\t' && !quoted) - { - widths[len] = *o_tabstop - (tab % *o_tabstop); - addstr(" " + 8 - widths[len]); - tab += widths[len]; - } - else if (ch > 0 && ch < ' ') /* > 0 by GB */ - { - addch('^'); - addch(ch + '@'); - widths[len] = 2; - tab += 2; - } - else if (ch == '\177') - { - addch('^'); - addch('?'); - widths[len] = 2; - tab += 2; - } - else - { - addch(ch); - widths[len] = 1; - tab++; - } - buf[len++] = ch; - } - else - { - beep(); - } - quoted = FALSE; - } - } -BreakBreak: - refresh(); - buf[len] = '\0'; - return len; -} - - -static int manymsgs; /* This variable keeps msgs from overwriting each other */ -static char pmsg[80]; /* previous message (waiting to be displayed) */ - - -static int showmsg() -{ - /* if there is no message to show, then don't */ - if (!manymsgs) - return FALSE; - - /* display the message */ - move(LINES - 1, 0); - if (*pmsg) - { - standout(); - qaddch(' '); - qaddstr(pmsg); - qaddch(' '); - standend(); - } - clrtoeol(); - - manymsgs = FALSE; - return TRUE; -} - - -void endmsgs() -{ - if (manymsgs) - { - showmsg(); - addch('\n'); - } -} - -/* Write a message in an appropriate way. This should really be a varargs - * function, but there is no such thing as vwprintw. Hack!!! - * - * In MODE_EX or MODE_COLON, the message is written immediately, with a - * newline at the end. - * - * In MODE_VI, the message is stored in a character buffer. It is not - * displayed until getkey() is called. msg() will call getkey() itself, - * if necessary, to prevent messages from being lost. - * - * msg("") - clears the message line - * msg("%s %d", ...) - does a printf onto the message line - */ -#ifdef __STDC__ -void msg (char *fmt, ...) -{ - va_list ap; - va_start (ap, fmt); -#else -void msg(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) - char *fmt; - long arg1, arg2, arg3, arg4, arg5, arg6, arg7; -{ -#endif - if (mode != MODE_VI) - { -#ifdef __STDC__ - vsprintf (pmsg, fmt, ap); -#else - sprintf(pmsg, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7); -#endif - qaddstr(pmsg); - addch('\n'); - exrefresh(); - } - else - { - /* wait for keypress between consecutive msgs */ - if (manymsgs) - { - getkey(WHEN_MSG); - } - - /* real message */ -#ifdef __STDC__ - vsprintf (pmsg, fmt, ap); -#else - sprintf(pmsg, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7); -#endif - if (*fmt) - { - manymsgs = TRUE; - } - } -#ifdef __STDC__ - va_end (ap); -#endif -} - - -/* This function calls refresh() if the option exrefresh is set */ -void exrefresh() -{ - char *scan; - - /* If this ex command wrote ANYTHING set exwrote so vi's : command - * can tell that it must wait for a user keystroke before redrawing. - */ - for (scan=kbuf; scan<stdscr; scan++) - if (*scan == '\n') - exwrote = TRUE; - - /* now we do the refresh thing */ - if (*o_exrefresh) - { - refresh(); - } - else - { - wqrefresh(); - } - if (mode != MODE_VI) - { - manymsgs = FALSE; - } -} - - -/* This structure is used to store maps and abbreviations. The distinction - * between them is that maps are stored in the list referenced by the "maps" - * pointer, while abbreviations are referenced by the "abbrs" pointer. - */ -typedef struct _map -{ - struct _map *next; /* another abbreviation */ - short len; /* length of the "rawin" characters */ - short flags; /* various flags */ - char *label; /* label of the map/abbr, or NULL */ - char *rawin; /* the "rawin" characters */ - char *cooked;/* the "cooked" characters */ -} MAP; - -static char keybuf[KEYBUFSIZE]; -static int cend; /* end of input characters */ -static int user; /* from user through end are chars typed by user */ -static int next; /* index of the next character to be returned */ -static MAP *match; /* the matching map, found by countmatch() */ -static MAP *maps; /* the map table */ -#ifndef NO_ABBR -static MAP *abbrs; /* the abbreviation table */ -#endif - - - -/* ring the terminal's bell */ -void beep() -{ - /* do a visible/audible bell */ - if (*o_flash) - { - do_VB(); - refresh(); - } - else if (*o_errorbells) - { - tputs("\007", 1, faddch); - } - - /* discard any buffered input, and abort macros */ - next = user = cend; -} - - - -/* This function replaces a "rawin" character sequence with the "cooked" version, - * by modifying the internal type-ahead buffer. - */ -void execmap(rawlen, cookedstr, visual) - int rawlen; /* length of rawin text -- string to delete */ - char *cookedstr; /* the cooked text -- string to insert */ - int visual; /* boolean -- chars to be executed in visual mode? */ -{ - int cookedlen; - char *src, *dst; - int i; - - /* find the length of the cooked string */ - cookedlen = strlen(cookedstr); -#ifndef NO_EXTENSIONS - if (visual) - { - cookedlen *= 2; - } -#endif - - /* if too big to fit in type-ahead buffer, then don't do it */ - if (cookedlen + (cend - next) - rawlen > KEYBUFSIZE) - { - return; - } - - /* shift to make room for cookedstr at the front of keybuf */ - src = &keybuf[next + rawlen]; - dst = &keybuf[cookedlen]; - i = cend - (next + rawlen); - if (src >= dst) - { - while (i-- > 0) - { - *dst++ = *src++; - } - } - else - { - src += i; - dst += i; - while (i-- > 0) - { - *--dst = *--src; - } - } - - /* insert cookedstr, and adjust offsets */ - cend += cookedlen - rawlen - next; - user += cookedlen - rawlen - next; - next = 0; - for (dst = keybuf, src = cookedstr; *src; ) - { -#ifndef NO_EXTENSIONS - if (visual) - { - *dst++ = ctrl('O'); - cookedlen--; - } -#endif - *dst++ = *src++; - } - -#ifdef DEBUG2 - { -#include <stdio.h> - FILE *debout; - int i; - - debout = fopen("debug.out", "a"); - fprintf(debout, "After execmap(%d, \"%s\", %d)...\n", rawlen, cookedstr, visual); - for (i = 0; i < cend; i++) - { - if (i == next) fprintf(debout, "(next)"); - if (i == user) fprintf(debout, "(user)"); - if (UCHAR(keybuf[i]) < ' ') - fprintf(debout, "^%c", keybuf[i] ^ '@'); - else - fprintf(debout, "%c", keybuf[i]); - } - fprintf(debout, "(end)\n"); - fclose(debout); - } -#endif -} - -#ifndef NO_CURSORSHAPE -/* made global so that suspend_curses() can reset it. -nox */ -int oldcurs; -#endif -/* This function calls ttyread(). If necessary, it will also redraw the screen, - * change the cursor shape, display the mode, and update the ruler. If the - * number of characters read is 0, and we didn't time-out, then it exits because - * we've apparently reached the end of an EX script. - */ -static int fillkeybuf(when, timeout) - int when; /* mixture of WHEN_XXX flags */ - int timeout;/* timeout in 1/10 second increments, or 0 */ -{ - int nkeys; -#ifndef NO_SHOWMODE - static int oldwhen; /* "when" from last time */ - static int oldleft; - static long oldtop; - static long oldnlines; - char *str; -#endif - -#ifdef DEBUG - watch(); -#endif - - -#ifndef NO_CURSORSHAPE - /* make sure the cursor is the right shape */ - if (has_CQ) - { - if (when != oldcurs) - { - switch (when) - { - case WHEN_EX: do_CX(); break; - case WHEN_VICMD: do_CV(); break; - case WHEN_VIINP: do_CI(); break; - case WHEN_VIREP: do_CR(); break; - } - oldcurs = when; - } - } -#endif - -#ifndef NO_SHOWMODE - /* if "showmode" then say which mode we're in */ - if (*o_smd && (when & WHENMASK)) - { - /* redraw the screen before we check to see whether the - * "showmode" message needs to be redrawn. - */ - redraw(cursor, !(when & WHEN_VICMD)); - - /* now the "topline" test should be valid */ - if (when != oldwhen - || topline != oldtop - || leftcol != oldleft - || nlines != oldnlines) - { - oldwhen = when; - oldtop = topline; - oldleft = leftcol; - oldnlines = nlines; - - if (when & WHEN_VICMD) str = "Command"; - else if (when & WHEN_VIINP) str = " Input "; - else if (when & WHEN_VIREP) str = "Replace"; - else if (when & WHEN_REP1) str = "Replc 1"; - else if (when & WHEN_CUT) str = "Buffer "; - else if (when & WHEN_MARK) str = " Mark "; - else if (when & WHEN_CHAR) str = "Dest Ch"; - else str = (char *)0; - - if (str) - { - move(LINES - 1, COLS - 10); - standout(); - qaddstr(str); - standend(); - } - } - } -#endif - -#ifndef NO_EXTENSIONS - /* maybe display the ruler */ - if (*o_ruler && (when & (WHEN_VICMD|WHEN_VIINP|WHEN_VIREP))) - { - char buf[20]; - - redraw(cursor, !(when & WHEN_VICMD)); - pfetch(markline(cursor)); - sprintf(buf, "%7ld,%-4d", markline(cursor), 1 + idx2col(cursor, ptext, when & (WHEN_VIINP|WHEN_VIREP))); - move(LINES - 1, COLS - 22); - addstr(buf); - } -#endif - - /* redraw, so the cursor is in the right place */ - if (when & WHENMASK) - { - redraw(cursor, !(when & (WHENMASK & ~(WHEN_VIREP|WHEN_VIINP)))); - } - - /* Okay, now we can finally read the rawin keystrokes */ - refresh(); - nkeys = ttyread(keybuf + cend, sizeof keybuf - cend, timeout); - - /* if nkeys == 0 then we've reached EOF of an ex script. */ - if (nkeys == 0 && timeout == 0) - { - tmpabort(TRUE); - move(LINES - 1, 0); - clrtoeol(); - refresh(); - endwin(); - exit(exitcode); - } - - cend += nkeys; - user += nkeys; - return nkeys; -} - - -/* This function counts the number of maps that could match the characters - * between &keybuf[next] and &keybuf[cend], including incomplete matches. - * The longest comlete match is remembered via the "match" variable. - */ -static int countmatch(when) - int when; /* mixture of WHEN_XXX flags */ -{ - MAP *map; - int count; - - /* clear the "match" variable */ - match = (MAP *)0; - - /* check every map */ - for (count = 0, map = maps; map; map = map->next) - { - /* can't match if wrong mode */ - if ((map->flags & when) == 0) - { - continue; - } - - /* would this be a complete match? */ - if (map->len <= cend - next) - { - /* Yes, it would be. Now does it really match? */ - if (!strncmp(map->rawin, &keybuf[next], map->len)) - { - count++; - - /* if this is the longest complete match, - * then remember it. - */ - if (!match || match->len < map->len) - { - match = map; - } - } - } - else - { - /* No, it wouldn't. But check for partial match */ - if (!strncmp(map->rawin, &keybuf[next], cend - next)) - { - /* increment by 2 instead of 1 so that, in the - * event that we have a partial match with a - * single map, we don't mistakenly assume we - * have resolved the map yet. - */ - count += 2; - } - } - } - return count; -} - - -#ifndef NO_ABBR -/* This function checks to see whether a word is an abbreviation. If it is, - * then an appropriate number of backspoace characters is inserted into the - * type-ahead buffer, followed by the expanded form of the abbreviation. - */ -static void expandabbr(word, wlen) - char *word; - int wlen; -{ - MAP *abbr; - - /* if the next character wouldn't end the word, then don't expand */ - if (isalnum(keybuf[next]) || keybuf[next] == ctrl('V') || keybuf[next] == '\b') - { - return; - } - - /* find the abbreviation, if any */ - for (abbr = abbrs; - abbr && (abbr->len != wlen || strncmp(abbr->rawin, word, wlen)); - abbr = abbr->next) - { - } - - /* If an abbreviation was found, then expand it by inserting the long - * version into the type-ahead buffer, and then inserting (in front of - * the long version) enough backspaces to erase to the short version. - */ - if (abbr) - { - execmap(0, abbr->cooked, FALSE); - while (wlen > 15) - { - execmap(0, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", FALSE); - wlen -= 15; - } - if (wlen > 0) - { - execmap(0, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" + 15 - wlen, FALSE); - } - } -} -#endif - - -/* This function calls getabkey() without attempting to expand abbreviations */ -int getkey(when) - int when; /* mixture of WHEN_XXX flags */ -{ - return getabkey(when, "", 0); -} - - -/* This is it. This function returns keystrokes one-at-a-time, after mapping - * and abbreviations have been taken into account. - */ -int getabkey(when, word, wlen) - int when; /* mixture of WHEN_XXX flags */ - char *word; /* a word that may need to be expanded as an abbr */ - int wlen; /* length of "word" -- since "word" might not have \0 */ -{ - int matches; - - /* if this key is needed for delay between multiple error messages, - * then reset the manymsgs flag and abort any mapped key sequence. - */ - if (showmsg()) - { - if (when == WHEN_MSG) - { -#ifndef CRUNCH - if (!*o_more) - { - refresh(); - return ' '; - } -#endif - qaddstr("[More...]"); - refresh(); - execmap(user, "", FALSE); - } - } - -#ifdef DEBUG - /* periodically check for screwed up internal tables */ - watch(); -#endif - - /* if buffer empty, read some characters without timeout */ - if (next >= cend) - { - next = user = cend = 0; - fillkeybuf(when, 0); - } - - /* try to map the key, unless already mapped and not ":set noremap" */ - if (next <= user || *o_remap) - { - do - { - do - { - matches = countmatch(when); - } while (matches > 1 && fillkeybuf(when, *o_keytime) > 0); - if (matches == 1) - { - execmap(match->len, match->cooked, - (match->flags & WHEN_INMV) != 0 - && (when & (WHEN_VIINP|WHEN_VIREP)) != 0); - } - } while (*o_remap && matches == 1); - } - - /* ERASEKEY should always be mapped to '\b'. */ - if (keybuf[next] == ERASEKEY) - { - keybuf[next] = '\b'; - } - -#ifndef NO_ABBR - /* try to expand an abbreviation, except in visual command mode */ - if (wlen > 0 && (mode & (WHEN_EX|WHEN_VIINP|WHEN_VIREP)) != 0) - { - expandabbr(word, wlen); - } -#endif - - /* return the next key */ - return keybuf[next++]; -} - -/* This function maps or unmaps a key */ -void mapkey(rawin, cooked, when, name) - char *rawin; /* the input key sequence, before mapping */ - char *cooked;/* after mapping -- or NULL to remove map */ - int when; /* bitmap of when mapping should happen */ - char *name; /* name of the key, NULL for no name, "abbr" for abbr */ -{ - MAP **head; /* head of list of maps or abbreviations */ - MAP *scan; /* used for scanning through the list */ - MAP *prev; /* used during deletions */ - - /* Is this a map or an abbreviation? Choose the right list. */ -#ifndef NO_ABBR - head = ((!name || strcmp(name, "abbr")) ? &maps : &abbrs); -#else - head = &maps; -#endif - - /* try to find the map in the list */ - for (scan = *head, prev = (MAP *)0; - scan && (strcmp(rawin, scan->rawin) && strcmp(rawin, scan->cooked) || - !(scan->flags & when & (WHEN_EX|WHEN_VICMD|WHEN_VIINP|WHEN_VIREP))); - prev = scan, scan = scan->next) - { - } - - /* trying to map? (not unmap) */ - if (cooked && *cooked) - { - /* if map starts with "visual ", then mark it as a visual map */ - if (head == &maps && !strncmp(cooked, "visual ", 7)) - { - cooked += 7; - when |= WHEN_INMV; - } - - /* "visual" maps always work in input mode */ - if (when & WHEN_INMV) - { - when |= WHEN_VIINP|WHEN_VIREP|WHEN_POPUP; - } - - /* if not already in the list, then allocate a new structure */ - if (!scan) - { - scan = (MAP *)malloc(sizeof(MAP)); - scan->len = strlen(rawin); - scan->rawin = malloc((unsigned)(scan->len + 1)); - strcpy(scan->rawin, rawin); - scan->flags = when; - scan->label = name; - if (*head) - { - prev->next = scan; - } - else - { - *head = scan; - } - scan->next = (MAP *)0; - } - else /* recycle old structure */ - { - _free_(scan->cooked); - } - scan->cooked = malloc((unsigned)(strlen(cooked) + 1)); - strcpy(scan->cooked, cooked); - } - else /* unmapping */ - { - /* if nothing to unmap, then exit silently */ - if (!scan) - { - return; - } - - /* unlink the structure from the list */ - if (prev) - { - prev->next = scan->next; - } - else - { - *head = scan->next; - } - - /* free it, and the strings that it refers to */ - _free_(scan->rawin); - _free_(scan->cooked); - _free_(scan); - } -} - - -/* This function returns a printable version of a string. It uses tmpblk.c */ -char *printable(str) - char *str; /* the string to convert */ -{ - char *build; /* used for building the string */ - - for (build = tmpblk.c; *str; str++) - { -#if AMIGA - if (*str == '\233') - { - *build++ = '<'; - *build++ = 'C'; - *build++ = 'S'; - *build++ = 'I'; - *build++ = '>'; - } else -#endif - if (UCHAR(*str) < ' ' || *str == '\177') - { - *build++ = '^'; - *build++ = *str ^ '@'; - } - else - { - *build++ = *str; - } - } - *build = '\0'; - return tmpblk.c; -} - -/* This function displays the contents of either the map table or the - * abbreviation table. User commands call this function as follows: - * :map dumpkey(WHEN_VICMD, FALSE); - * :map! dumpkey(WHEN_VIREP|WHEN_VIINP, FALSE); - * :abbr dumpkey(WHEN_VIINP|WHEN_VIREP, TRUE); - * :abbr! dumpkey(WHEN_EX|WHEN_VIINP|WHEN_VIREP, TRUE); - */ -void dumpkey(when, abbr) - int when; /* WHEN_XXXX of mappings to be dumped */ - int abbr; /* boolean: dump abbreviations instead of maps? */ -{ - MAP *scan; - char *str; - int len; - -#ifndef NO_ABBR - for (scan = (abbr ? abbrs : maps); scan; scan = scan->next) -#else - for (scan = maps; scan; scan = scan->next) -#endif - { - /* skip entries that don't match "when" */ - if ((scan->flags & when) == 0) - { - continue; - } - - /* dump the key label, if any */ - if (!abbr) - { - len = 8; - if (scan->label) - { - qaddstr(scan->label); - len -= strlen(scan->label); - } - do - { - qaddch(' '); - } while (len-- > 0); - } - - /* dump the rawin version */ - str = printable(scan->rawin); - qaddstr(str); - len = strlen(str); - do - { - qaddch(' '); - } while (len++ < 8); - - /* dump the mapped version */ -#ifndef NO_EXTENSIONS - if ((scan->flags & WHEN_INMV) && (when & (WHEN_VIINP|WHEN_VIREP))) - { - qaddstr("visual "); - } -#endif - str = printable(scan->cooked); - qaddstr(str); - addch('\n'); - exrefresh(); - } -} - -#ifndef NO_MKEXRC - -static void safequote(str) - char *str; -{ - char *build; - - build = tmpblk.c + strlen(tmpblk.c); - while (*str) - { - if (*str <= ' ' && *str >= 1 || *str == '|') - { - *build++ = ctrl('V'); - } - *build++ = *str++; - } - *build = '\0'; -} - -/* This function saves the contents of either the map table or the - * abbreviation table into a file. Both the "bang" and "no bang" versions - * are saved. - * :map dumpkey(WHEN_VICMD, FALSE); - * :map! dumpkey(WHEN_VIREP|WHEN_VIINP, FALSE); - * :abbr dumpkey(WHEN_VIINP|WHEN_VIREP, TRUE); - * :abbr! dumpkey(WHEN_EX|WHEN_VIINP|WHEN_VIREP, TRUE); - */ -void -savemaps(fd, abbr) - int fd; /* file descriptor of an open file to write to */ - int abbr; /* boolean: do abbr table? (else do map table) */ -{ - MAP *scan; - int bang; - int when; - -# ifndef NO_ABBR - for (scan = (abbr ? abbrs : maps); scan; scan = scan->next) -# else - for (scan = maps; scan; scan = scan->next) -# endif - { - /* skip maps that have labels, except for function keys */ - if (scan->label && *scan->label != '#') - { - continue; - } - - for (bang = 0; bang < 2; bang++) - { - /* decide which "when" flags we want */ -# ifndef NO_ABBR - if (abbr) - when = (bang ? WHEN_EX|WHEN_VIINP|WHEN_VIREP : WHEN_VIINP|WHEN_VIREP); - else -# endif - when = (bang ? WHEN_VIREP|WHEN_VIINP : WHEN_VICMD); - - /* skip entries that don't match "when" */ - if ((scan->flags & when) == 0) - { - continue; - } - - /* write a "map" or "abbr" command name */ -# ifndef NO_ABBR - if (abbr) - strcpy(tmpblk.c, "abbr"); - else -# endif - strcpy(tmpblk.c, "map"); - - /* maybe write a bang. Definitely write a space */ - if (bang) - strcat(tmpblk.c, "! "); - else - strcat(tmpblk.c, " "); - - /* write the rawin version */ -# ifndef NO_FKEY - if (scan->label) - strcat(tmpblk.c, scan->label); - else -# endif - safequote(scan->rawin); - strcat(tmpblk.c, " "); - - /* dump the mapped version */ -# ifndef NO_EXTENSIONS - if ((scan->flags & WHEN_INMV) && (when & (WHEN_VIINP|WHEN_VIREP))) - { - strcat(tmpblk.c, "visual "); - } -# endif - safequote(scan->cooked); - strcat(tmpblk.c, "\n"); - twrite(fd, tmpblk.c, strlen(tmpblk.c)); - } - } -} -#endif diff --git a/usr.bin/elvis/tmp.c b/usr.bin/elvis/tmp.c deleted file mode 100644 index 5c3ce09f2422..000000000000 --- a/usr.bin/elvis/tmp.c +++ /dev/null @@ -1,795 +0,0 @@ -/* tmp.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains functions which create & readback a TMPFILE */ - -#ifndef lint -static char rcsid[] = "$Id: tmp.c,v 1.4 1993/08/02 17:54:11 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" -#if TOS -# include <stat.h> -#else -# if OSK -# include "osk.h" -# else -# if AMIGA -# include "amistat.h" -# else -# include <sys/stat.h> -# endif -# endif -#endif -#if TURBOC -# include <process.h> -#endif - -#ifndef NO_MODELINES -static void do_modelines(l, stop) - long l; /* line number to start at */ - long stop; /* line number to stop at */ -{ - char *str; /* used to scan through the line */ - char *start; /* points to the start of the line */ - char buf[80]; - - /* if modelines are disabled, then do nothing */ - if (!*o_modelines) - { - return; - } - - /* for each line... */ - for (; l <= stop; l++) - { - /* for each position in the line.. */ - for (str = fetchline(l); *str; str++) - { - /* if it is the start of a modeline command... */ - if ((str[0] == 'e' && str[1] == 'x' - || str[0] == 'v' && str[1] == 'i') - && str[2] == ':') - { - start = str += 3; - - /* find the end */ - for (str = start + strlen(start); *--str != ':'; ) - { - } - - /* if it is a well-formed modeline, execute it */ - if (str > start && str - start < sizeof buf) - { - strncpy(buf, start, (int)(str - start)); - exstring(buf, str - start, '\\'); - break; - } - } - } - } -} -#endif - - -/* The FAIL() macro prints an error message and then exits. */ -#define FAIL(why,arg) mode = MODE_EX; msg(why, arg); endwin(); exit(9) - -/* This is the name of the temp file */ -static char tmpname[80]; - -/* This function creates the temp file and copies the original file into it. - * Returns if successful, or stops execution if it fails. - */ -int tmpstart(filename) - char *filename; /* name of the original file */ -{ - int origfd; /* fd used for reading the original file */ - struct stat statb; /* stat buffer, used to examine inode */ - REG BLK *this; /* pointer to the current block buffer */ - REG BLK *next; /* pointer to the next block buffer */ - int inbuf; /* number of characters in a buffer */ - int nread; /* number of bytes read */ - REG int j, k; - int i; - long nbytes; - - /* switching to a different file certainly counts as a change */ - changes++; - redraw(MARK_UNSET, FALSE); - - /* open the original file for reading */ - *origname = '\0'; - if (filename && *filename) - { - strcpy(origname, filename); - origfd = open(origname, O_RDONLY); - if (origfd < 0 && errno != ENOENT) - { - msg("Can't open \"%s\"", origname); - return tmpstart(""); - } - if (origfd >= 0) - { - if (stat(origname, &statb) < 0) - { - FAIL("Can't stat \"%s\"", origname); - } -#if TOS - if (origfd >= 0 && (statb.st_mode & S_IJDIR)) -#else -# if OSK - if (origfd >= 0 && (statb.st_mode & S_IFDIR)) -# else - if (origfd >= 0 && (statb.st_mode & S_IFMT) != S_IFREG) -# endif -#endif - { - msg("\"%s\" is not a regular file", origname); - return tmpstart(""); - } - } - else - { - stat(".", &statb); - } - if (origfd >= 0) - { - origtime = statb.st_mtime; -#if OSK - if (*o_readonly || !(statb.st_mode & - ((getuid() >> 16) == 0 ? S_IOWRITE | S_IWRITE : - ((statb.st_gid != (getuid() >> 16) ? S_IOWRITE : S_IWRITE))))) -#endif -#if AMIGA || MSDOS - if (*o_readonly || !(statb.st_mode & S_IWRITE)) -#endif -#if TOS -# ifdef __GNUC__ - if (*o_readonly || !(statb.st_mode & S_IWRITE)) -# else - if (*o_readonly || (statb.st_mode & S_IJRON)) -# endif -#endif -#if ANY_UNIX - if (*o_readonly || !(statb.st_mode & - ((geteuid() == 0) ? 0222 : - ((statb.st_uid != geteuid() ? 0022 : 0200))))) -#endif -#if VMS - if (*o_readonly) -#endif - { - setflag(file, READONLY); - } - } - else - { - origtime = 0L; - } - } - else - { - setflag(file, NOFILE); - origfd = -1; - origtime = 0L; - stat(".", &statb); - } - - /* make a name for the tmp file */ - do - { - tmpnum++; -#if MSDOS || TOS - /* MS-Dos doesn't allow multiple slashes, but supports drives - * with current directories. - * This relies on TMPNAME beginning with "%s\\"!!!! - */ - strcpy(tmpname, o_directory); - if ((i = strlen(tmpname)) && !strchr(":/\\", tmpname[i-1])) - tmpname[i++]=SLASH; - sprintf(tmpname+i, TMPNAME+3, getpid(), tmpnum); -#else - sprintf(tmpname, TMPNAME, o_directory, getpid(), tmpnum); -#endif - } while (access(tmpname, 0) == 0); - - /* !!! RACE CONDITION HERE - some other process with the same PID could - * create the temp file between the access() call and the creat() call. - * This could happen in a couple of ways: - * - different workstation may share the same temp dir via NFS. Each - * workstation could have a process with the same number. - * - The DOS version may be running multiple times on the same physical - * machine in different virtual machines. The DOS pid number will - * be the same on all virtual machines. - * - * This race condition could be fixed by replacing access(tmpname, 0) - * with open(tmpname, O_CREAT|O_EXCL, 0600), if we could only be sure - * that open() *always* used modern UNIX semantics. - */ - - /* create the temp file */ -#if ANY_UNIX - close(creat(tmpname, 0600)); /* only we can read it */ -#else - close(creat(tmpname, FILEPERMS)); /* anybody body can read it, alas */ -#endif - tmpfd = open(tmpname, O_RDWR | O_BINARY); - if (tmpfd < 0) - { - FAIL("Can't create temp file... Does directory \"%s\" exist?", o_directory); - return 1; - } - - /* allocate space for the header in the file */ - if (write(tmpfd, hdr.c, (unsigned)BLKSIZE) < BLKSIZE - || write(tmpfd, tmpblk.c, (unsigned)BLKSIZE) < BLKSIZE) - { - FAIL("Error writing headers to \"%s\"", tmpname); - } - -#ifndef NO_RECYCLE - /* initialize the block allocator */ - /* This must already be done here, before the first attempt - * to write to the new file! GB */ - garbage(); -#endif - - /* initialize lnum[] */ - for (i = 1; i < MAXBLKS; i++) - { - lnum[i] = INFINITY; - } - lnum[0] = 0; - - /* if there is no original file, then create a 1-line file */ - if (origfd < 0) - { - hdr.n[0] = 0; /* invalid inode# denotes new file */ - - this = blkget(1); /* get the new text block */ - strcpy(this->c, "\n"); /* put a line in it */ - - lnum[1] = 1L; /* block 1 ends with line 1 */ - nlines = 1L; /* there is 1 line in the file */ - nbytes = 1L; - - if (*origname) - { - msg("\"%s\" [NEW FILE] 1 line, 1 char", origname); - } - else - { - msg("\"[NO FILE]\" 1 line, 1 char"); - } - } - else /* there is an original file -- read it in */ - { - nbytes = nlines = 0; - - /* preallocate 1 "next" buffer */ - i = 1; - next = blkget(i); - inbuf = 0; - - /* loop, moving blocks from orig to tmp */ - for (;;) - { - /* "next" buffer becomes "this" buffer */ - this = next; - - /* read [more] text into this block */ - nread = tread(origfd, &this->c[inbuf], BLKSIZE - 1 - inbuf); - if (nread < 0) - { - close(origfd); - close(tmpfd); - tmpfd = -1; - unlink(tmpname); - FAIL("Error reading \"%s\"", origname); - } - - /* convert NUL characters to something else */ - for (j = k = inbuf; k < inbuf + nread; k++) - { - if (!this->c[k]) - { - setflag(file, HADNUL); - this->c[j++] = 0x80; - } -#ifndef CRUNCH - else if (*o_beautify && this->c[k] < ' ' && this->c[k] >= 1) - { - if (this->c[k] == '\t' - || this->c[k] == '\n' - || this->c[k] == '\f') - { - this->c[j++] = this->c[k]; - } - else if (this->c[k] == '\b') - { - /* delete '\b', but complain */ - setflag(file, HADBS); - } - /* else silently delete control char */ - } -#endif - else - { - this->c[j++] = this->c[k]; - } - } - inbuf = j; - - /* if the buffer is empty, quit */ - if (inbuf == 0) - { - goto FoundEOF; - } - -#if MSDOS || TOS -/* BAH! MS text mode read fills inbuf, then compresses eliminating \r - but leaving garbage at end of buf. The same is true for TURBOC. GB. */ - - memset(this->c + inbuf, '\0', BLKSIZE - inbuf); -#endif - - /* search backward for last newline */ - for (k = inbuf; --k >= 0 && this->c[k] != '\n';) - { - } - if (k++ < 0) - { - if (inbuf >= BLKSIZE - 1) - { - k = 80; - } - else - { - k = inbuf; - } - } - - /* allocate next buffer */ - if (i >= MAXBLKS - 2) - { - FAIL("File too big. Limit is approx %ld kbytes.", MAXBLKS * BLKSIZE / 1024L); - } - next = blkget(++i); - - /* move fragmentary last line to next buffer */ - inbuf -= k; - for (j = 0; k < BLKSIZE; j++, k++) - { - next->c[j] = this->c[k]; - this->c[k] = 0; - } - - /* if necessary, add a newline to this buf */ - for (k = BLKSIZE - inbuf; --k >= 0 && !this->c[k]; ) - { - } - if (this->c[k] != '\n') - { - setflag(file, ADDEDNL); - this->c[k + 1] = '\n'; - } - - /* count the lines in this block */ - for (k = 0; k < BLKSIZE && this->c[k]; k++) - { - if (this->c[k] == '\n') - { - nlines++; - } - nbytes++; - } - lnum[i - 1] = nlines; - } -FoundEOF: - - /* if this is a zero-length file, add 1 line */ - if (nlines == 0) - { - this = blkget(1); /* get the new text block */ - strcpy(this->c, "\n"); /* put a line in it */ - - lnum[1] = 1; /* block 1 ends with line 1 */ - nlines = 1; /* there is 1 line in the file */ - nbytes = 1; - } - -#if MSDOS || TOS - /* each line has an extra CR that we didn't count yet */ - nbytes += nlines; -#endif - - /* report the number of lines in the file */ - msg("\"%s\" %s %ld line%s, %ld char%s", - origname, - (tstflag(file, READONLY) ? "[READONLY]" : ""), - nlines, - nlines == 1 ? "" : "s", - nbytes, - nbytes == 1 ? "" : "s"); - } - - /* initialize the cursor to start of line 1 */ - cursor = MARK_FIRST; - - /* close the original file */ - close(origfd); - - /* any other messages? */ - if (tstflag(file, HADNUL)) - { - msg("This file contained NULs. They've been changed to \\x80 chars"); - } - if (tstflag(file, ADDEDNL)) - { - msg("Newline characters have been inserted to break up long lines"); - } -#ifndef CRUNCH - if (tstflag(file, HADBS)) - { - msg("Backspace characters deleted due to ':set beautify'"); - } -#endif - - storename(origname); - -#ifndef NO_MODELINES - if (nlines > 10) - { - do_modelines(1L, 5L); - do_modelines(nlines - 4L, nlines); - } - else - { - do_modelines(1L, nlines); - } -#endif - - /* force all blocks out onto the disk, to support file recovery */ - blksync(); - - return 0; -} - - - -/* This function copies the temp file back onto an original file. - * Returns TRUE if successful, or FALSE if the file could NOT be saved. - */ -int tmpsave(filename, bang) - char *filename; /* the name to save it to */ - int bang; /* forced write? */ -{ - int fd; /* fd of the file we're writing to */ - REG int len; /* length of a text block */ - REG BLK *this; /* a text block */ - long bytes; /* byte counter */ - REG int i; - - /* if no filename is given, assume the original file name */ - if (!filename || !*filename) - { - filename = origname; - } - - /* if still no file name, then fail */ - if (!*filename) - { - msg("Don't know a name for this file -- NOT WRITTEN"); - return FALSE; - } - - /* can't rewrite a READONLY file */ - if (!strcmp(filename, origname) && tstflag(file, READONLY) && !bang) - { - msg("\"%s\" [READONLY] -- NOT WRITTEN", filename); - return FALSE; - } - - /* open the file */ - if (*filename == '>' && filename[1] == '>') - { - filename += 2; - while (*filename == ' ' || *filename == '\t') - { - filename++; - } -#ifdef O_APPEND - fd = open(filename, O_WRONLY|O_APPEND); -#else - fd = open(filename, O_WRONLY); - lseek(fd, 0L, 2); -#endif - } - else - { - /* either the file must not exist, or it must be the original - * file, or we must have a bang, or "writeany" must be set. - */ - if (strcmp(filename, origname) && access(filename, 0) == 0 && !bang -#ifndef CRUNCH - && !*o_writeany -#endif - ) - { - msg("File already exists - Use :w! to overwrite"); - return FALSE; - } -#if VMS - /* Create a new VMS version of this file. */ - { - char *strrchr(), *ptr = strrchr(filename,';'); - if (ptr) *ptr = '\0'; /* Snip off any ;number in the name */ - } -#endif - fd = creat(filename, FILEPERMS); - } - if (fd < 0) - { - msg("Can't write to \"%s\" -- NOT WRITTEN", filename); - return FALSE; - } - - /* write each text block to the file */ - bytes = 0L; - for (i = 1; i < MAXBLKS && (this = blkget(i)) && this->c[0]; i++) - { - for (len = 0; len < BLKSIZE && this->c[len]; len++) - { - } - if (twrite(fd, this->c, len) < len) - { - msg("Trouble writing to \"%s\"", filename); - if (!strcmp(filename, origname)) - { - setflag(file, MODIFIED); - } - close(fd); - return FALSE; - } - bytes += len; - } - - /* reset the "modified" flag, but not the "undoable" flag */ - clrflag(file, MODIFIED); - significant = FALSE; - if (!strcmp(origname, filename)) - { - exitcode &= ~1; - } - - /* report lines & characters */ -#if MSDOS || TOS - bytes += nlines; /* for the inserted carriage returns */ -#endif - msg("Wrote \"%s\" %ld lines, %ld characters", filename, nlines, bytes); - - /* close the file */ - close(fd); - - return TRUE; -} - - -/* This function deletes the temporary file. If the file has been modified - * and "bang" is FALSE, then it returns FALSE without doing anything; else - * it returns TRUE. - * - * If the "autowrite" option is set, then instead of returning FALSE when - * the file has been modified and "bang" is false, it will call tmpend(). - */ -int tmpabort(bang) - int bang; -{ - /* if there is no file, return successfully */ - if (tmpfd < 0) - { - return TRUE; - } - - /* see if we must return FALSE -- can't quit */ - if (!bang && tstflag(file, MODIFIED)) - { - /* if "autowrite" is set, then act like tmpend() */ - if (*o_autowrite) - return tmpend(bang); - else - return FALSE; - } - - /* delete the tmp file */ - cutswitch(); - strcpy(prevorig, origname); - prevline = markline(cursor); - *origname = '\0'; - origtime = 0L; - blkinit(); - nlines = 0; - initflags(); - return TRUE; -} - -/* This function saves the file if it has been modified, and then deletes - * the temporary file. Returns TRUE if successful, or FALSE if the file - * needs to be saved but can't be. When it returns FALSE, it will not have - * deleted the tmp file, either. - */ -int tmpend(bang) - int bang; -{ - /* save the file if it has been modified */ - if (tstflag(file, MODIFIED) && !tmpsave((char *)0, FALSE) && !bang) - { - return FALSE; - } - - /* delete the tmp file */ - tmpabort(TRUE); - - return TRUE; -} - - -/* If the tmp file has been changed, then this function will force those - * changes to be written to the disk, so that the tmp file will survive a - * system crash or power failure. - */ -#if AMIGA || MSDOS || TOS -sync() -{ - /* MS-DOS and TOS don't flush their buffers until the file is closed, - * so here we close the tmp file and then immediately reopen it. - */ - close(tmpfd); - tmpfd = open(tmpname, O_RDWR | O_BINARY); - return 0; -} -#endif - - -/* This function stores the file's name in the second block of the temp file. - * SLEAZE ALERT! SLEAZE ALERT! The "tmpblk" buffer is probably being used - * to store the arguments to a command, so we can't use it here. Instead, - * we'll borrow the buffer that is used for "shift-U". - */ -int -storename(name) - char *name; /* the name of the file - normally origname */ -{ -#ifndef CRUNCH - int len; - char *ptr; -#endif - - /* we're going to clobber the U_text buffer, so reset U_line */ - U_line = 0L; - - if (!name) - { - strncpy(U_text, "", BLKSIZE); - U_text[1] = 127; - } -#ifndef CRUNCH -# if TOS || MINT || MSDOS || AMIGA - else if (*name != '/' && *name != '\\' && !(*name && name[1] == ':')) -# else - else if (*name != SLASH) -# endif - { - /* get the directory name */ - ptr = getcwd(U_text, BLKSIZE); - if (ptr != U_text) - { - strcpy(U_text, ptr); - } - - /* append a slash to the directory name */ - len = strlen(U_text); - U_text[len++] = SLASH; - - /* append the filename, padded with heaps o' NULs */ - strncpy(U_text + len, *name ? name : "foo", BLKSIZE - len); - } -#endif - else - { - /* copy the filename into U_text */ - strncpy(U_text, *name ? name : "foo", BLKSIZE); - } - - if (tmpfd >= 0) - { - /* write the name out to second block of the temp file */ - lseek(tmpfd, (long)BLKSIZE, 0); - if (write(tmpfd, U_text, (unsigned)BLKSIZE) < BLKSIZE) - { - FAIL("Error stuffing name \"%s\" into temp file", U_text); - } - } - return 0; -} - - - -/* This function handles deadly signals. It restores sanity to the terminal - * preserves the current temp file, and deletes any old temp files. - */ -SIGTYPE deathtrap(sig) - int sig; /* the deadly signal that we caught */ -{ - char *why; - - /* restore the terminal's sanity */ - endwin(); - -#ifdef CRUNCH - why = "-Elvis died"; -#else - /* give a more specific description of how Elvis died */ - switch (sig) - { -# ifdef SIGHUP - case SIGHUP: why = "-the modem lost its carrier"; break; -# endif -# ifndef DEBUG -# ifdef SIGILL - case SIGILL: why = "-Elvis hit an illegal instruction"; break; -# endif -# ifdef SIGBUS - case SIGBUS: why = "-Elvis had a bus error"; break; -# endif -# ifdef SIGSEGV -# if !TOS - case SIGSEGV: why = "-Elvis had a segmentation violation"; break; -# endif -# endif -# ifdef SIGSYS - case SIGSYS: why = "-Elvis munged a system call"; break; -# endif -# endif /* !DEBUG */ -# ifdef SIGPIPE - case SIGPIPE: why = "-the pipe reader died"; break; -# endif -# ifdef SIGTERM - case SIGTERM: why = "-Elvis was terminated"; break; -# endif -# if !MINIX -# ifdef SIGUSR1 - case SIGUSR1: why = "-Elvis was killed via SIGUSR1"; break; -# endif -# ifdef SIGUSR2 - case SIGUSR2: why = "-Elvis was killed via SIGUSR2"; break; -# endif -# endif - default: why = "-Elvis died"; break; - } -#endif - - /* if we had a temp file going, then preserve it */ - if (tmpnum > 0 && tmpfd >= 0) - { - close(tmpfd); - sprintf(tmpblk.c, "%s \"%s\" %s", PRESERVE, why, tmpname); - system(tmpblk.c); - } - - /* delete any old temp files */ - cutend(); - - /* exit with the proper exit status */ - exit(sig); -} diff --git a/usr.bin/elvis/unix.c b/usr.bin/elvis/unix.c deleted file mode 100644 index 7e403d37b090..000000000000 --- a/usr.bin/elvis/unix.c +++ /dev/null @@ -1,227 +0,0 @@ -/* unix.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains the unix-specific versions the ttyread() functions. - * There are actually three versions of ttyread() defined here, because - * BSD, SysV, and V7 all need quite different implementations. - */ - -#ifndef lint -static char rcsid[] = "$Id: unix.c,v 1.3 1993/08/02 17:54:12 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#if ANY_UNIX -# include "vi.h" - -# if BSD -/* For BSD, we use select() to wait for characters to become available, - * and then do a read() to actually get the characters. We also try to - * handle SIGWINCH -- if the signal arrives during the select() call, then - * we adjust the o_columns and o_lines variables, and fake a control-L. - */ -# include <sys/types.h> -# include <sys/time.h> -int ttyread(buf, len, time) - char *buf; /* where to store the gotten characters */ - int len; /* maximum number of characters to read */ - int time; /* maximum time to allow for reading */ -{ - fd_set rd; /* the file descriptors that we want to read from */ - static tty; /* 'y' if reading from tty, or 'n' if not a tty */ - int i; - struct timeval t; - struct timeval *tp; - - - /* do we know whether this is a tty or not? */ - if (!tty) - { - tty = (isatty(0) ? 'y' : 'n'); - } - - /* compute the timeout value */ - if (time) - { - t.tv_sec = time / 10; - t.tv_usec = (time % 10) * 100000L; - tp = &t; - } - else - { - tp = (struct timeval *)0; - } - - /* loop until we get characters or a definite EOF */ - for (;;) - { - if (tty == 'y') - { - /* wait until timeout or characters are available */ - FD_ZERO(&rd); - FD_SET(0, &rd); - i = select(1, &rd, (fd_set *)0, (fd_set *)0, tp); - } - else - { - /* if reading from a file or pipe, never timeout! - * (This also affects the way that EOF is detected) - */ - i = 1; - } - - /* react accordingly... */ - switch (i) - { - case -1: /* assume we got an EINTR because of SIGWINCH */ - if (*o_lines != LINES || *o_columns != COLS) - { -#ifndef CRUNCH - *o_nearscroll = -#endif - *o_lines = LINES; - *o_columns = COLS; -#ifndef CRUNCH - if (!wset) - { - *o_window = LINES - 1; - } -#endif - if (mode != MODE_EX) - { - /* pretend the user hit ^L */ - *buf = ctrl('L'); - return 1; - } - } - break; - - case 0: /* timeout */ - return 0; - - default: /* characters available */ - return read(0, buf, len); - } - } -} -# else - -# if UNIXV || COH_386 -/* For System-V, we use VMIN/VTIME to implement the timeout. For no timeout, - * VMIN should be 1 and VTIME should be 0; for timeout, VMIN should be 0 and - * VTIME should be the timeout value. - */ -# include <termio.h> -int ttyread(buf, len, time) - char *buf; /* where to store the gotten characters */ - int len; /* maximum number of characters to read */ - int time; /* maximum time to allow for reading */ -{ - struct termio tio; - int bytes; /* number of bytes actually read */ - - /* arrange for timeout */ - ioctl(0, TCGETA, &tio); - if (time) - { - tio.c_cc[VMIN] = 0; - tio.c_cc[VTIME] = time; - } - else - { - tio.c_cc[VMIN] = 1; - tio.c_cc[VTIME] = 0; - } - ioctl(0, TCSETA, &tio); - - /* Perform the read. Loop if EINTR error happens */ - while ((bytes = read(0, buf, (unsigned)len)) < 0) - { - /* probably EINTR error because a SIGWINCH was received */ - if (*o_lines != LINES || *o_columns != COLS) - { - *o_lines = LINES; - *o_columns = COLS; -#ifndef CRUNCH - if (!wset) - { - *o_nearscroll = LINES; - *o_window = LINES - 1; - } -#endif - if (mode != MODE_EX) - { - /* pretend the user hit ^L */ - *buf = ctrl('L'); - return 1; - } - } - } - - /* return the number of bytes read */ - return bytes; - - /* NOTE: The terminal may be left in a timeout-mode after this function - * returns. This shouldn't be a problem since Elvis *NEVER* tries to - * read from the keyboard except through this function. - */ -} - -# else /* any other version of UNIX, assume it is V7 compatible */ - -/* For V7 UNIX (including Minix) we set an alarm() before doing a blocking - * read(), and assume that the SIGALRM signal will cause the read() function - * to give up. - */ - -#include <setjmp.h> - -static jmp_buf env; - -/*ARGSUSED*/ -SIGTYPE dummy(signo) - int signo; -{ - longjmp(env, 1); -} -int ttyread(buf, len, time) - char *buf; /* where to store the gotten characters */ - int len; /* maximum number of characters to read */ - int time; /* maximum time to allow for reading */ -{ - /* arrange for timeout */ - signal(SIGALRM, dummy); - alarm(time); - - /* perform the blocking read */ - if (setjmp(env) == 0) - { - len = read(0, buf, (unsigned)len); - } - else /* I guess we timed out */ - { - len = 0; - } - - /* cancel the alarm */ - signal(SIGALRM, dummy); /* <-- to work around a bug in Minix */ - alarm(0); - - /* return the number of bytes read */ - if (len < 0) - len = 0; - return len; -} - -# endif /* M_SYSV */ -# endif /* !BSD */ - -#endif /* ANY_UNIX */ diff --git a/usr.bin/elvis/vars.c b/usr.bin/elvis/vars.c deleted file mode 100644 index 428a9dad36d7..000000000000 --- a/usr.bin/elvis/vars.c +++ /dev/null @@ -1,121 +0,0 @@ -/* vars.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains variables which weren't happy anyplace else */ - -#ifndef lint -static char rcsid[] = "$Id: vars.c,v 1.4 1993/11/03 08:27:14 cgd Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "vi.h" - -/*------------------------------------------------------------------------*/ - -/* used to remember whether the file has been modified */ -struct _viflags viflags; - -/* used to access the tmp file */ -long lnum[MAXBLKS]; -long nlines; -int tmpfd = -1; -int tmpnum; -#ifndef CRUNCH -int wset = FALSE; -#endif - -/* used to keep track of the current file & alternate file */ -long origtime; -char origname[256]; -char prevorig[256]; -long prevline = 1; - -/* used to track various places in the text */ -MARK mark[NMARKS]; /* marks 'a through 'z, plus mark '' */ -MARK cursor; /* the cursor position within the file */ - -/* which mode of the editor we're in */ -int mode; /* vi mode? ex mode? quitting? */ - -/* used to manage the args list */ -char args[BLKSIZE]; /* list of filenames to edit */ -int argno; /* index of current file in args list */ -int nargs; /* number of filenames in args[] */ - -/* dummy var, never explicitly referenced */ -int bavar; /* used only in BeforeAfter macros */ - -/* used to detect changes that invalidate cached text/blocks */ -long changes; /* incremented when file is changed */ -int significant; /* boolean: was a *REAL* change made? */ -int exitcode; /* 0=overwritten, 1=error */ - -/* used to support the pfetch() macro */ -int plen; /* length of the line */ -long pline; /* line number that len refers to */ -long pchgs; /* "changes" level that len refers to */ -char *ptext; /* text of previous line, if valid */ - -/* misc temporary storage - mostly for strings */ -BLK tmpblk; /* a block used to accumulate changes */ - -/* screen oriented stuff */ -long topline; /* file line number of top line */ -int leftcol; /* column number of left col */ -int physcol; /* physical column number that cursor is on */ -int physrow; /* physical row number that cursor is on */ - -/* used to help minimize that "[Hit a key to continue]" message */ -int exwrote; /* Boolean: was the last ex command wordy? */ - -/* This variable affects the behaviour of certain functions -- most importantly - * the input function. - */ -int doingdot; /* boolean: are we doing the "." command? */ - -/* This variable affects the behaviour of the ":s" command, and it is also - * used to detect & prohibit nesting of ":g" commands - */ -int doingglobal; /* boolean: are doing a ":g" command? */ - -/* This variable is zeroed before a command executes, and later ORed with the - * command's flags after the command has been executed. It is used to force - * certain flags to be TRUE for *some* invocations of a particular command. - * For example, "/regexp/+offset" forces the LNMD flag, and sometimes a "p" - * or "P" command will force FRNT. - */ -int force_flags; - -/* These are used for reporting multi-line changes to the user */ -long rptlines; /* number of lines affected by a command */ -char *rptlabel; /* description of how lines were affected */ - -/* These store info that pertains to the shift-U command */ -long U_line; /* line# of the undoable line, or 0l for none */ -char U_text[BLKSIZE]; /* contents of the undoable line */ - - -#ifndef NO_VISIBLE -/* These are used to implement the 'v' and 'V' commands */ -MARK V_from; /* starting point for v or V */ -int V_linemd; /* boolean: doing line-mode version? (V, not v) */ -#endif - -/* Bigger stack req'ed for TOS and TURBOC */ - -#if TOS -long _stksize = 16384; -#endif - -#if TURBOC -#include <dos.h> -extern unsigned _stklen = 16384U; -#endif diff --git a/usr.bin/elvis/vcmd.c b/usr.bin/elvis/vcmd.c deleted file mode 100644 index 7732adc38638..000000000000 --- a/usr.bin/elvis/vcmd.c +++ /dev/null @@ -1,991 +0,0 @@ -/* vcmd.c */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - - -/* This file contains the functions that handle VI commands */ - -#ifndef lint -static char rcsid[] = "$Id: vcmd.c,v 1.3 1993/08/02 17:54:13 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "ctype.h" -#include "vi.h" -#if MSDOS -# include <process.h> -# include <string.h> -#endif -#if TOS -# include <osbind.h> -# include <string.h> -#endif -#if OSK -# include <stdio.h> -#endif - - -/* This function puts the editor in EX mode */ -MARK v_quit() -{ - move(LINES - 1, 0); - mode = MODE_EX; - return cursor; -} - -/* This function causes the screen to be redrawn */ -MARK v_redraw() -{ - redraw(MARK_UNSET, FALSE); - return cursor; -} - -/* This function executes a string of EX commands, and waits for a user keystroke - * before returning to the VI screen. If that keystroke is another ':', then - * another EX command is read and executed. - */ -/*ARGSUSED*/ -MARK v_1ex(m, text) - MARK m; /* the current line */ - char *text; /* the first command to execute */ -{ - /* run the command. be careful about modes & output */ - exwrote = (mode == MODE_COLON); - doexcmd(text); - exrefresh(); - - /* if mode is no longer MODE_VI, then we should quit right away! */ - if (mode != MODE_VI && mode != MODE_COLON) - return cursor; - - /* The command did some output. Wait for a keystoke. */ - if (exwrote) - { - mode = MODE_VI; - msg("[Hit <RETURN> to continue]"); - if (getkey(0) == ':') - { mode = MODE_COLON; - addch('\n'); - } - else - redraw(MARK_UNSET, FALSE); - } - - return cursor; -} - -/* This function undoes the last change */ -/*ARGSUSED*/ -MARK v_undo(m) - MARK m; /* (ignored) */ -{ - if (undo()) - { - redraw(MARK_UNSET, FALSE); - } - return cursor; -} - -/* This function deletes the character(s) that the cursor is on */ -MARK v_xchar(m, cnt, cmd) - MARK m; /* where to start deletions */ - long cnt; /* number of chars to delete */ - int cmd; /* either 'x' or 'X' */ -{ - DEFAULT(1); - - /* for 'X', adjust so chars are deleted *BEFORE* cursor */ - if (cmd == 'X') - { - if (markidx(m) < cnt) - return MARK_UNSET; - m -= cnt; - } - - /* make sure we don't try to delete more thars than there are */ - pfetch(markline(m)); - if (markidx(m + cnt) > plen) - { - cnt = plen - markidx(m); - } - if (cnt == 0L) - { - return MARK_UNSET; - } - - /* do it */ - ChangeText - { - cut(m, m + cnt); - delete(m, m + cnt); - } - return m; -} - -/* This function defines a mark */ -/*ARGSUSED*/ -MARK v_mark(m, count, key) - MARK m; /* where the mark will be */ - long count; /* (ignored) */ - int key; /* the ASCII label of the mark */ -{ - if (key < 'a' || key > 'z') - { - msg("Marks must be from a to z"); - } - else - { - mark[key - 'a'] = m; - } - return m; -} - -/* This function toggles upper & lower case letters */ -MARK v_ulcase(m, cnt) - MARK m; /* where to make the change */ - long cnt; /* number of chars to flip */ -{ - REG char *pos; - REG int j; - - DEFAULT(1); - - /* fetch the current version of the line */ - pfetch(markline(m)); - - /* for each position in the line */ - for (j = 0, pos = &ptext[markidx(m)]; j < cnt && *pos; j++, pos++) - { - if (isupper(*pos)) - { - tmpblk.c[j] = tolower(*pos); - } - else - { - tmpblk.c[j] = toupper(*pos); - } - } - - /* if the new text is different from the old, then change it */ - if (strncmp(tmpblk.c, &ptext[markidx(m)], j)) - { - ChangeText - { - tmpblk.c[j] = '\0'; - change(m, m + j, tmpblk.c); - } - } - - return m + j; -} - - -MARK v_replace(m, cnt, key) - MARK m; /* first char to be replaced */ - long cnt; /* number of chars to replace */ - int key; /* what to replace them with */ -{ - REG char *text; - REG int i; - - DEFAULT(1); - - /* map ^M to '\n' */ - if (key == '\r') - { - key = '\n'; - } - - /* make sure the resulting line isn't too long */ - if (cnt > BLKSIZE - 2 - markidx(m)) - { - cnt = BLKSIZE - 2 - markidx(m); - } - - /* build a string of the desired character with the desired length */ - for (text = tmpblk.c, i = cnt; i > 0; i--) - { - *text++ = key; - } - *text = '\0'; - - /* make sure cnt doesn't extend past EOL */ - pfetch(markline(m)); - key = markidx(m); - if (key + cnt > plen) - { - cnt = plen - key; - } - - /* do the replacement */ - ChangeText - { - change(m, m + cnt, tmpblk.c); - } - - if (*tmpblk.c == '\n') - { - return (m & ~(BLKSIZE - 1)) + cnt * BLKSIZE; - } - else - { - return m + cnt - 1; - } -} - -MARK v_overtype(m) - MARK m; /* where to start overtyping */ -{ - MARK end; /* end of a substitution */ - static long width; /* width of a single-line replace */ - - /* the "doingdot" version of replace is really a substitution */ - if (doingdot) - { - /* was the last one really repeatable? */ - if (width < 0) - { - msg("Can't repeat a multi-line overtype command"); - return MARK_UNSET; - } - - /* replacing nothing by nothing? Don't bother */ - if (width == 0) - { - return m; - } - - /* replace some chars by repeated text */ - return v_subst(m, width); - } - - /* Normally, we input starting here, in replace mode */ - ChangeText - { - end = input(m, m, WHEN_VIREP, 0); - } - - /* if we ended on the same line we started on, then this - * overtype is repeatable via the dot key. - */ - if (markline(end) == markline(m) && end >= m - 1L) - { - width = end - m + 1L; - } - else /* it isn't repeatable */ - { - width = -1L; - } - - return end; -} - - -/* This function selects which cut buffer to use */ -/*ARGSUSED*/ -MARK v_selcut(m, cnt, key) - MARK m; - long cnt; - int key; -{ - cutname(key); - return m; -} - -/* This function pastes text from a cut buffer */ -/*ARGSUSED*/ -MARK v_paste(m, cnt, cmd) - MARK m; /* where to paste the text */ - long cnt; /* (ignored) */ - int cmd; /* either 'p' or 'P' */ -{ - MARK dest; - - ChangeText - { - /* paste the text, and find out where it ends */ - dest = paste(m, cmd == 'p', TRUE); - - /* was that a line-mode paste? */ - if (dest && markline(dest) != markline(m)) - { - /* line-mode pastes leave the cursor at the front - * of the first pasted line. - */ - dest = m; - if (cmd == 'p') - { - dest += BLKSIZE; - } - force_flags |= FRNT; - } - } - return dest; -} - -/* This function yanks text into a cut buffer */ -MARK v_yank(m, n) - MARK m, n; /* range of text to yank */ -{ - cut(m, n); - return m; -} - -/* This function deletes a range of text */ -MARK v_delete(m, n) - MARK m, n; /* range of text to delete */ -{ - /* illegal to try and delete nothing */ - if (n <= m) - { - return MARK_UNSET; - } - - /* Do it */ - ChangeText - { - cut(m, n); - delete(m, n); - } - return m; -} - - -/* This starts input mode without deleting anything */ -MARK v_insert(m, cnt, key) - MARK m; /* where to start (sort of) */ - long cnt; /* repeat how many times? */ - int key; /* what command is this for? {a,A,i,I,o,O} */ -{ - int wasdot; - long reps; - int delta = 0;/* 1 to take autoindent from line below, -1 for above */ - - DEFAULT(1); - - ChangeText - { - /* tweak the insertion point, based on command key */ - switch (key) - { - case 'i': - break; - - case 'a': - pfetch(markline(m)); - if (plen > 0) - { - m++; - } - break; - - case 'I': - m = m_front(m, 1L); - break; - - case 'A': - pfetch(markline(m)); - m = (m & ~(BLKSIZE - 1)) + plen; - break; - - case 'O': - m &= ~(BLKSIZE - 1); - add(m, "\n"); - delta = 1; - break; - - case 'o': - m = (m & ~(BLKSIZE - 1)) + BLKSIZE; - add(m, "\n"); - delta = -1; - break; - } - - /* insert the same text once or more */ - for (reps = cnt, wasdot = doingdot; reps > 0; reps--, doingdot = TRUE) - { - m = input(m, m, WHEN_VIINP, delta) + 1; - } - if (markidx(m) > 0) - { - m--; - } - - doingdot = wasdot; - } - -#ifndef CRUNCH -# ifndef NO_EXTENSIONS - if (key == 'i' && *o_inputmode && mode == MODE_VI) - { - msg("Now in command mode! To return to input mode, hit <i>"); - } -# endif -#endif - - return m; -} - -/* This starts input mode with some text deleted */ -MARK v_change(m, n) - MARK m, n; /* the range of text to change */ -{ - int lnmode; /* is this a line-mode change? */ - - /* swap them if they're in reverse order */ - if (m > n) - { - MARK tmp; - tmp = m; - m = n; - n = tmp; - } - - /* for line mode, retain the last newline char */ - lnmode = (markidx(m) == 0 && markidx(n) == 0 && m != n); - if (lnmode) - { - n -= BLKSIZE; - pfetch(markline(n)); - n = (n & ~(BLKSIZE - 1)) + plen; - } - - ChangeText - { - cut(m, n); - m = input(m, n, WHEN_VIINP, 0); - } - - return m; -} - -/* This function replaces a given number of characters with input */ -MARK v_subst(m, cnt) - MARK m; /* where substitutions start */ - long cnt; /* number of chars to replace */ -{ - DEFAULT(1); - - /* make sure we don't try replacing past EOL */ - pfetch(markline(m)); - if (markidx(m) + cnt > plen) - { - cnt = plen - markidx(m); - } - - /* Go for it! */ - ChangeText - { - cut(m, m + cnt); - m = input(m, m + cnt, WHEN_VIINP, 0); - } - return m; -} - -/* This calls the ex "join" command to join some lines together */ -MARK v_join(m, cnt) - MARK m; /* the first line to be joined */ - long cnt; /* number of other lines to join */ -{ - MARK joint; /* where the lines were joined */ - - DEFAULT(1); - - /* figure out where the joint will be */ - pfetch(markline(m)); - joint = (m & ~(BLKSIZE - 1)) + plen; - - /* join the lines */ - cmd_join(m, m + MARK_AT_LINE(cnt), CMD_JOIN, 0, ""); - - /* the cursor should be left at the joint */ - return joint; -} - - -/* This calls the ex "<" command to shift some lines left */ -MARK v_lshift(m, n) - MARK m, n; /* range of lines to shift */ -{ - /* adjust for inclusive endmarks in ex */ - n -= BLKSIZE; - - cmd_shift(m, n, CMD_SHIFTL, FALSE, (char *)0); - - return m; -} - -/* This calls the ex ">" command to shift some lines right */ -MARK v_rshift(m, n) - MARK m, n; /* range of lines to shift */ -{ - /* adjust for inclusive endmarks in ex */ - n -= BLKSIZE; - - cmd_shift(m, n, CMD_SHIFTR, FALSE, (char *)0); - - return m; -} - -/* This filters some lines through a preset program, to reformat them */ -MARK v_reformat(m, n) - MARK m, n; /* range of lines to shift */ -{ - /* adjust for inclusive endmarks in ex */ - n -= BLKSIZE; - - /* run the filter command */ - filter(m, n, o_equalprg, TRUE); - - redraw(MARK_UNSET, FALSE); - return m; -} - - -/* This runs some lines through a filter program */ -MARK v_filter(m, n) - MARK m, n; /* range of lines to shift */ -{ - char cmdln[150]; /* a shell command line */ - - /* adjust for inclusive endmarks in ex */ - n -= BLKSIZE; - - if (vgets('!', cmdln, sizeof(cmdln)) > 0) - { - filter(m, n, cmdln, TRUE); - } - - redraw(MARK_UNSET, FALSE); - return m; -} - - -/* This function runs the ex "file" command to show the file's status */ -MARK v_status() -{ - cmd_file(cursor, cursor, CMD_FILE, 0, ""); - return cursor; -} - - -/* This function runs the ":&" command to repeat the previous :s// */ -MARK v_again(m, n) - MARK m, n; -{ - cmd_substitute(m, n - BLKSIZE, CMD_SUBAGAIN, TRUE, ""); - return cursor; -} - - - -/* This function switches to the previous file, if possible */ -MARK v_switch() -{ - if (!*prevorig) - msg("No previous file"); - else - { strcpy(tmpblk.c, prevorig); - cmd_edit(cursor, cursor, CMD_EDIT, 0, tmpblk.c); - } - return cursor; -} - -/* This function does a tag search on a keyword */ -/*ARGSUSED*/ -MARK v_tag(keyword, m, cnt) - char *keyword; - MARK m; - long cnt; -{ - /* move the cursor to the start of the tag name, where m is */ - cursor = m; - - /* perform the tag search */ - cmd_tag(cursor, cursor, CMD_TAG, 0, keyword); - - return cursor; -} - -#ifndef NO_EXTENSIONS -/* This function looks up a keyword by calling the helpprog program */ -/*ARGSUSED*/ -MARK v_keyword(keyword, m, cnt) - char *keyword; - MARK m; - long cnt; -{ - int waswarn; - char cmdline[130]; - - move(LINES - 1, 0); - addstr("---------------------------------------------------------\n"); - clrtoeol(); - refresh(); - sprintf(cmdline, "%s %s", o_keywordprg, keyword); - waswarn = *o_warn; - *o_warn = FALSE; - suspend_curses(); - if (system(cmdline)) - { - addstr("<<< failed >>>\n"); - } - resume_curses(FALSE); - mode = MODE_VI; - redraw(MARK_UNSET, FALSE); - *o_warn = waswarn; - - return m; -} - - - -MARK v_increment(keyword, m, cnt) - char *keyword; - MARK m; - long cnt; -{ - static sign; - char newval[12]; - long atol(); - - DEFAULT(1); - - /* get one more keystroke, unless doingdot */ - if (!doingdot) - { - sign = getkey(0); - } - - /* adjust the number, based on that second keystroke */ - switch (sign) - { - case '+': - case '#': - cnt = atol(keyword) + cnt; - break; - - case '-': - cnt = atol(keyword) - cnt; - break; - - case '=': - break; - - default: - return MARK_UNSET; - } - sprintf(newval, "%ld", cnt); - - ChangeText - { - change(m, m + strlen(keyword), newval); - } - - return m; -} -#endif - - -/* This function acts like the EX command "xit" */ -/*ARGSUSED*/ -MARK v_xit(m, cnt, key) - MARK m; /* ignored */ - long cnt; /* ignored */ - int key; /* must be a second 'Z' */ -{ - /* if second char wasn't 'Z', fail */ - if (key != 'Z') - { - return MARK_UNSET; - } - - /* move the cursor to the bottom of the screen */ - move(LINES - 1, 0); - clrtoeol(); - - /* do the xit command */ - cmd_xit(m, m, CMD_XIT, FALSE, ""); - - /* return the cursor */ - return m; -} - - -/* This function undoes changes to a single line, if possible */ -MARK v_undoline(m) - MARK m; /* where we hope to undo the change */ -{ - /* make sure we have the right line in the buffer */ - if (markline(m) != U_line) - { - return MARK_UNSET; - } - - /* fix it */ - ChangeText - { - strcat(U_text, "\n"); - change(MARK_AT_LINE(U_line), MARK_AT_LINE(U_line + 1), U_text); - } - - /* nothing in the buffer anymore */ - U_line = -1L; - - /* return, with the cursor at the front of the line */ - return m & ~(BLKSIZE - 1); -} - - -#ifndef NO_ERRLIST -MARK v_errlist(m) - MARK m; -{ - cmd_errlist(m, m, CMD_ERRLIST, FALSE, ""); - return cursor; -} -#endif - - -#ifndef NO_AT -/*ARGSUSED*/ -MARK v_at(m, cnt, key) - MARK m; - long cnt; - int key; -{ - int size; - - size = cb2str(key, tmpblk.c, BLKSIZE); - if (size <= 0 || size == BLKSIZE) - { - return MARK_UNSET; - } - - execmap(0, tmpblk.c, FALSE); - return cursor; -} -#endif - - -#ifdef SIGTSTP -MARK v_suspend() -{ - cmd_suspend(MARK_UNSET, MARK_UNSET, CMD_SUSPEND, FALSE, ""); - return MARK_UNSET; -} -#endif - - -#ifndef NO_VISIBLE -/*ARGSUSED*/ -MARK v_start(m, cnt, cmd) - MARK m; /* starting point for a v or V command */ - long cnt; /* ignored */ - int cmd; /* either 'v' or 'V' */ -{ - if (V_from) - { - V_from = MARK_UNSET; - } - else - { - V_from = m; - V_linemd = isupper(cmd); - } - return m; -} -#endif - -#ifndef NO_POPUP -# define MENU_HEIGHT 11 -# define MENU_WIDTH 23 -MARK v_popup(m, n) - MARK m, n; /* the range of text to change */ -{ - int i; - int y, x; /* position where the window will pop up at */ - int key; /* keystroke from the user */ - int sel; /* index of the selected operation */ - static int dfltsel;/* default value of sel */ - static char *labels[11] = - { - "ESC cancel! ", - " d delete (cut) ", - " y yank (copy) ", - " p paste after ", - " P paste before ", - " > more indented ", - " < less indented ", - " = reformat ", - " ! external filter ", - " ZZ save & exit ", - " u undo previous " - }; - - /* try to position the menu near the cursor */ - x = physcol - (MENU_WIDTH / 2); - if (x < 0) - x = 0; - else if (x + MENU_WIDTH + 2 > COLS) - x = COLS - MENU_WIDTH - 2; - if (markline(cursor) < topline || markline(cursor) > botline) - y = 0; - else if (markline(cursor) + 1L + MENU_HEIGHT > botline) - y = (int)(markline(cursor) - topline) - MENU_HEIGHT; - else - y = (int)(markline(cursor) - topline) + 1L; - - /* draw the menu */ - for (sel = 0; sel < MENU_HEIGHT; sel++) - { - move(y + sel, x); - do_POPUP(); - if (sel == dfltsel) - qaddstr("-->"); - else - qaddstr(" "); - qaddstr(labels[sel]); - do_SE(); - } - - /* get a selection */ - move(y + dfltsel, x + 4); - for (sel = dfltsel; (key = getkey(WHEN_POPUP)) != '\\' && key != '\r'; ) - { - /* erase the selection arrow */ - move(y + sel, x); - do_POPUP(); - qaddstr(" "); - qaddstr(labels[sel]); - do_SE(); - - /* process the user's keystroke */ - if (key == 'j' && sel < MENU_HEIGHT - 1) - { - sel++; - } - else if (key == 'k' && sel > 0) - { - sel--; - } - else if (key == '\033') - { - sel = 0; - break; - } - else - { - for (i = 1; i < MENU_HEIGHT && labels[i][1] != key; i++) - { - } - if (i < MENU_HEIGHT) - { - sel = i; - break; - } - } - - /* redraw the arrow, possibly in a new place */ - move(y + sel, x); - do_POPUP(); - qaddstr("-->"); - qaddstr(labels[sel]); - do_SE(); - move(y + sel, x + 4); - } - - /* in most cases, the default selection is "paste after" */ - dfltsel = 3; - - /* perform the appropriate action */ - switch (sel) - { - case 0: - m = cursor; - dfltsel = 0; - break; - - case 1: /* delete (cut) */ - m = v_delete(m, n); - break; - - case 2: /* yank (copy) */ - m = v_yank(m, n); - break; - - case 3: /* paste after */ - m = v_paste(n, 1L, 'P'); - break; - - case 4: /* paste before */ - m = v_paste(m, 1L, 'P'); - dfltsel = 4; - break; - - case 5: /* more indented */ - m = v_rshift(m, n); - dfltsel = 5; - break; - - case 6: /* less indented */ - m = v_lshift(m, n); - dfltsel = 6; - break; - - case 7: /* reformat */ - m = v_reformat(m, n); - dfltsel = 7; - break; - - case 8: /* external filter */ - m = v_filter(m, n); - dfltsel = 0; - break; - - case 9: /* save & exit */ - /* get confirmation first */ - do - { - key = getkey(0); - } while (key != '\\' && key != 'Z' && key != '\r' /* good */ - && key != '\033'); /* bad */ - if (key != '\033') - { - m = v_xit(m, 0L, 'Z'); - } - break; - - case 10: /* undo previous */ - m = v_undo(m); - dfltsel = 9; - break; - } - - /* arrange for the menu to be erased (except "save & exit" doesn't care) - */ - if (mode == MODE_VI) - redraw(MARK_UNSET, FALSE); - - return m; -} -#endif /* undef NO_POPUP */ - -#ifndef NO_TAGSTACK -MARK v_pop(m, cnt, cmd) - MARK m; /* original cursor position (ignored) */ - long cnt; /* number of levels to pop */ - int cmd; /* command key -- ^T (ignored) */ -{ - DEFAULT(1L); - sprintf(tmpblk.c, "%ld", cnt); - cmd_pop(m, m, CMD_POP, FALSE, tmpblk.c); - return cursor; -} -#endif diff --git a/usr.bin/elvis/vi.c b/usr.bin/elvis/vi.c deleted file mode 100644 index f7fcb061f7ec..000000000000 --- a/usr.bin/elvis/vi.c +++ /dev/null @@ -1,847 +0,0 @@ -/* vi.c */ - -/* Author: - * Steve Kirkendall - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - */ - -#ifndef lint -static char rcsid[] = "$Id: vi.c,v 1.3 1993/08/02 17:54:14 mycroft Exp $"; -#endif /* not lint */ - - -#include "config.h" -#include "ctype.h" -#include "vi.h" - - - -/* This array describes what each key does */ -#define NO_FUNC (MARK (*)())0 - -#define NO_ARGS 0 -#define CURSOR 1 -#define CURSOR_CNT_KEY 2 -#define CURSOR_MOVED 3 -#define CURSOR_EOL 4 -#define ZERO 5 -#define DIGIT 6 -#define CURSOR_TEXT 7 -#define KEYWORD 8 -#define ARGSMASK 0x0f -#define C_C_K_REP1 (CURSOR_CNT_KEY | 0x10) -#define C_C_K_CUT (CURSOR_CNT_KEY | 0x20) -#define C_C_K_MARK (CURSOR_CNT_KEY | 0x30) -#define C_C_K_CHAR (CURSOR_CNT_KEY | 0x40) -#ifndef NO_SHOWMODE -static int keymodes[] = {0, WHEN_REP1, WHEN_CUT, WHEN_MARK, WHEN_CHAR}; -# define KEYMODE(args) (keymodes[(args) >> 4]) -#else -# define KEYMODE(args) 0 -#endif - -static struct keystru -{ - MARK (*func)(); /* the function to run */ - uchar args; /* description of the args needed */ -#ifndef NO_VISIBLE - short flags; -#else - uchar flags; /* other stuff */ -#endif -} - vikeys[] = -{ -/* NUL not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#ifndef NO_EXTENSIONS -/* ^A find cursor word */ {m_wsrch, KEYWORD, MVMT|NREL|VIZ}, -#else -/* ^A not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* ^B page backward */ {m_scroll, CURSOR, FRNT|VIZ}, -/* ^C not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* ^D scroll dn 1/2page*/ {m_scroll, CURSOR, NCOL|VIZ}, -/* ^E scroll up */ {m_scroll, CURSOR, NCOL|VIZ}, -/* ^F page forward */ {m_scroll, CURSOR, FRNT|VIZ}, -/* ^G show file status */ {v_status, NO_ARGS, NO_FLAGS}, -/* ^H move left, like h*/ {m_left, CURSOR, MVMT|VIZ}, -/* ^I not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* ^J move down */ {m_updnto, CURSOR, MVMT|LNMD|VIZ|INCL}, -/* ^K not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* ^L redraw screen */ {v_redraw, NO_ARGS, NO_FLAGS|VIZ}, -/* ^M mv front next ln */ {m_updnto, CURSOR, MVMT|FRNT|LNMD|VIZ|INCL}, -/* ^N move down */ {m_updnto, CURSOR, MVMT|LNMD|VIZ|INCL|NCOL}, -/* ^O not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* ^P move up */ {m_updnto, CURSOR, MVMT|LNMD|VIZ|INCL|NCOL}, -/* ^Q not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* ^R redraw screen */ {v_redraw, NO_ARGS, NO_FLAGS|VIZ}, -/* ^S not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#ifndef NO_TAGSTACK -/* ^T pop tagstack */ {v_pop, CURSOR, NO_FLAGS}, -#else -/* ^T not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* ^U scroll up 1/2page*/ {m_scroll, CURSOR, NCOL|VIZ}, -/* ^V not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* ^W not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* ^X move to phys col */ {m_tocol, CURSOR, MVMT|NREL|VIZ}, -/* ^Y scroll down */ {m_scroll, CURSOR, NCOL|VIZ}, -#ifdef SIGTSTP -/* ^Z suspend elvis */ {v_suspend, NO_ARGS, NO_FLAGS}, -#else -/* ^Z not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* ESC not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* ^\ not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* ^] keyword is tag */ {v_tag, KEYWORD, NO_FLAGS}, -/* ^^ previous file */ {v_switch, CURSOR, FRNT}, -/* ^_ not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* SPC move right,like l*/ {m_right, CURSOR, MVMT|INCL|VIZ}, -/* ! run thru filter */ {v_filter, CURSOR_MOVED, FRNT|LNMD|INCL|VIZ}, -/* " select cut buffer*/ {v_selcut, C_C_K_CUT, PTMV|VIZ}, -#ifndef NO_EXTENSIONS -/* # increment number */ {v_increment, KEYWORD, SDOT}, -#else -/* # not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* $ move to rear */ {m_rear, CURSOR, MVMT|INCL|VIZ}, -/* % move to match */ {m_match, CURSOR, MVMT|INCL|VIZ}, -/* & repeat subst */ {v_again, CURSOR_MOVED, SDOT|NCOL|LNMD|INCL}, -/* ' move to a mark */ {m_tomark, C_C_K_MARK, MVMT|FRNT|NREL|LNMD|INCL|VIZ}, -#ifndef NO_SENTENCE -/* ( mv back sentence */ {m_sentence, CURSOR, MVMT|VIZ}, -/* ) mv fwd sentence */ {m_sentence, CURSOR, MVMT|VIZ}, -#else -/* ( not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* ) not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -#ifndef NO_ERRLIST -/* * errlist */ {v_errlist, CURSOR, FRNT|NREL}, -#else -/* * not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* + mv front next ln */ {m_updnto, CURSOR, MVMT|FRNT|LNMD|VIZ|INCL}, -#ifndef NO_CHARSEARCH -/* , reverse [fFtT] cmd*/ {m__ch, CURSOR, MVMT|INCL|VIZ}, -#else -/* , not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* - mv front prev ln */ {m_updnto, CURSOR, MVMT|FRNT|LNMD|VIZ|INCL}, -/* . special... */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* / forward search */ {m_fsrch, CURSOR_TEXT, MVMT|NREL|VIZ}, -/* 0 part of count? */ {NO_FUNC, ZERO, MVMT|PTMV|VIZ}, -/* 1 part of count */ {NO_FUNC, DIGIT, PTMV|VIZ}, -/* 2 part of count */ {NO_FUNC, DIGIT, PTMV|VIZ}, -/* 3 part of count */ {NO_FUNC, DIGIT, PTMV|VIZ}, -/* 4 part of count */ {NO_FUNC, DIGIT, PTMV|VIZ}, -/* 5 part of count */ {NO_FUNC, DIGIT, PTMV|VIZ}, -/* 6 part of count */ {NO_FUNC, DIGIT, PTMV|VIZ}, -/* 7 part of count */ {NO_FUNC, DIGIT, PTMV|VIZ}, -/* 8 part of count */ {NO_FUNC, DIGIT, PTMV|VIZ}, -/* 9 part of count */ {NO_FUNC, DIGIT, PTMV|VIZ}, -/* : run single EX cmd*/ {v_1ex, CURSOR_TEXT, NO_FLAGS}, -#ifndef NO_CHARSEARCH -/* ; repeat [fFtT] cmd*/ {m__ch, CURSOR, MVMT|INCL|VIZ}, -#else -/* ; not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS|VIZ}, -#endif -/* < shift text left */ {v_lshift, CURSOR_MOVED, SDOT|FRNT|LNMD|INCL|VIZ}, -/* = preset filter */ {v_reformat, CURSOR_MOVED, SDOT|FRNT|LNMD|INCL|VIZ}, -/* > shift text right */ {v_rshift, CURSOR_MOVED, SDOT|FRNT|LNMD|INCL|VIZ}, -/* ? backward search */ {m_bsrch, CURSOR_TEXT, MVMT|NREL|VIZ}, -#ifndef NO_AT -/* @ execute a cutbuf */ {v_at, C_C_K_CUT, NO_FLAGS}, -#else -/* @ not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* A append at EOL */ {v_insert, CURSOR, SDOT}, -/* B move back Word */ {m_bword, CURSOR, MVMT|VIZ}, -/* C change to EOL */ {v_change, CURSOR_EOL, SDOT}, -/* D delete to EOL */ {v_delete, CURSOR_EOL, SDOT}, -/* E move end of Word */ {m_eword, CURSOR, MVMT|INCL|VIZ}, -#ifndef NO_CHARSEARCH -/* F move bk to char */ {m_Fch, C_C_K_CHAR, MVMT|INCL|VIZ}, -#else -/* F not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* G move to line # */ {m_updnto, CURSOR, MVMT|NREL|LNMD|FRNT|INCL|VIZ}, -/* H move to row */ {m_row, CURSOR, MVMT|LNMD|FRNT|VIZ|INCL}, -/* I insert at front */ {v_insert, CURSOR, SDOT}, -/* J join lines */ {v_join, CURSOR, SDOT}, -#ifndef NO_EXTENSIONS -/* K look up keyword */ {v_keyword, KEYWORD, NO_FLAGS}, -#else -/* K not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* L move to last row */ {m_row, CURSOR, MVMT|LNMD|FRNT|VIZ|INCL}, -/* M move to mid row */ {m_row, CURSOR, MVMT|LNMD|FRNT|VIZ|INCL}, -/* N reverse prev srch*/ {m_nsrch, CURSOR, MVMT|NREL|VIZ}, -/* O insert above line*/ {v_insert, CURSOR, SDOT}, -/* P paste before */ {v_paste, CURSOR, SDOT}, -/* Q quit to EX mode */ {v_quit, NO_ARGS, NO_FLAGS}, -/* R overtype */ {v_overtype, CURSOR, SDOT}, -/* S change line */ {v_change, CURSOR_MOVED, SDOT}, -#ifndef NO_CHARSEARCH -/* T move bk to char */ {m_Tch, C_C_K_CHAR, MVMT|INCL|VIZ}, -#else -/* T not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* U undo whole line */ {v_undoline, CURSOR, FRNT}, -#ifndef NO_VISIBLE -/* V start visible */ {v_start, CURSOR, INCL|LNMD|VIZ}, -#else -/* V not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* W move forward Word*/ {m_fword, CURSOR, MVMT|INCL|NWRP|VIZ}, -/* X delete to left */ {v_xchar, CURSOR, SDOT}, -/* Y yank text */ {v_yank, CURSOR_MOVED, NCOL}, -/* Z save file & exit */ {v_xit, CURSOR_CNT_KEY, NO_FLAGS}, -/* [ move back section*/ {m_paragraph, CURSOR, MVMT|LNMD|NREL|VIZ}, -#ifndef NO_POPUP -/* \ pop-up menu */ {v_popup, CURSOR_MOVED, VIZ}, -#else -/* \ not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* ] move fwd section */ {m_paragraph, CURSOR, MVMT|LNMD|NREL|VIZ}, -/* ^ move to front */ {m_front, CURSOR, MVMT|VIZ}, -/* _ current line */ {m_updnto, CURSOR, MVMT|LNMD|FRNT|INCL}, -/* ` move to mark */ {m_tomark, C_C_K_MARK, MVMT|NREL|VIZ}, -/* a append at cursor */ {v_insert, CURSOR, SDOT}, -/* b move back word */ {m_bword, CURSOR, MVMT|VIZ}, -/* c change text */ {v_change, CURSOR_MOVED, SDOT|VIZ}, -/* d delete op */ {v_delete, CURSOR_MOVED, SDOT|VIZ}, -/* e move end word */ {m_eword, CURSOR, MVMT|INCL|VIZ}, -#ifndef NO_CHARSEARCH -/* f move fwd for char*/ {m_fch, C_C_K_CHAR, MVMT|INCL|VIZ}, -#else -/* f not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* g not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* h move left */ {m_left, CURSOR, MVMT|VIZ}, -/* i insert at cursor */ {v_insert, CURSOR, SDOT}, -/* j move down */ {m_updnto, CURSOR, MVMT|NCOL|LNMD|VIZ|INCL}, -/* k move up */ {m_updnto, CURSOR, MVMT|NCOL|LNMD|VIZ|INCL}, -/* l move right */ {m_right, CURSOR, MVMT|INCL|VIZ}, -/* m define a mark */ {v_mark, C_C_K_MARK, NO_FLAGS}, -/* n repeat prev srch */ {m_nsrch, CURSOR, MVMT|NREL|VIZ}, -/* o insert below line*/ {v_insert, CURSOR, SDOT}, -/* p paste after */ {v_paste, CURSOR, SDOT}, -/* q not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -/* r replace chars */ {v_replace, C_C_K_REP1, SDOT}, -/* s subst N chars */ {v_subst, CURSOR, SDOT}, -#ifndef NO_CHARSEARCH -/* t move fwd to char */ {m_tch, C_C_K_CHAR, MVMT|INCL|VIZ}, -#else -/* t not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* u undo */ {v_undo, CURSOR, NO_FLAGS}, -#ifndef NO_VISIBLE -/* v start visible */ {v_start, CURSOR, INCL|VIZ}, -#else -/* v not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS}, -#endif -/* w move fwd word */ {m_fword, CURSOR, MVMT|INCL|NWRP|VIZ}, -/* x delete character */ {v_xchar, CURSOR, SDOT}, -/* y yank text */ {v_yank, CURSOR_MOVED, NCOL|VIZ}, -/* z adjust scrn row */ {m_z, CURSOR_CNT_KEY, NCOL|VIZ}, -/* { back paragraph */ {m_paragraph, CURSOR, MVMT|VIZ}, -/* | move to column */ {m_tocol, CURSOR, MVMT|NREL|VIZ}, -/* } fwd paragraph */ {m_paragraph, CURSOR, MVMT|VIZ}, -/* ~ upper/lowercase */ {v_ulcase, CURSOR, SDOT}, -/* DEL not defined */ {NO_FUNC, NO_ARGS, NO_FLAGS} -}; - - - -void vi() -{ - REG int key; /* keystroke from user */ - long count; /* numeric argument to some functions */ - REG struct keystru *keyptr;/* pointer to vikeys[] element */ - MARK tcurs; /* temporary cursor */ - int prevkey;/* previous key, if d/c/y/</>/! */ - MARK range; /* start of range for d/c/y/</>/! */ - char text[132]; - int dotkey; /* last "key" of a change */ - int dotpkey;/* last "prevkey" of a change */ - int dotkey2;/* last extra "getkey()" of a change */ - int dotcnt; /* last "count" of a change */ - int firstkey; - REG int i; - - /* tell the redraw() function to start from scratch */ - redraw(MARK_UNSET, FALSE); - -#ifdef lint - /* lint says that "range" might be used before it is set. This - * can't really happen due to the way "range" and "prevkey" are used, - * but lint doesn't know that. This line is here ONLY to keep lint - * happy. - */ - range = 0L; -#endif - - /* safeguard against '.' with no previous command */ - dotkey = dotpkey = dotkey2 = dotcnt = 0; - - /* go immediately into insert mode, if ":set inputmode" */ - firstkey = 0; -#ifndef NO_EXTENSIONS - if (*o_inputmode) - { - firstkey = 'i'; - } -#endif - - /* Repeatedly handle VI commands */ - for (count = 0, prevkey = '\0'; mode == MODE_VI; ) - { - /* if we've moved off the undoable line, then we can't undo it at all */ - if (markline(cursor) != U_line) - { - U_line = 0L; - } - - /* report any changes from the previous command */ - if (rptlines >= *o_report) - { - redraw(cursor, FALSE); - msg("%ld line%s %s", rptlines, (rptlines==1?"":"s"), rptlabel); - } - rptlines = 0L; - - /* get the next command key. It must be ASCII */ - if (firstkey) - { - key = firstkey; - firstkey = 0; - } - else - { - do - { - key = getkey(WHEN_VICMD); - } while (key < 0 || key > 127); - } -#ifdef DEBUG2 - debout("\nkey='%c'\n", key); -#endif - - /* Convert a doubled-up operator such as "dd" into "d_" */ - if (prevkey && key == prevkey) - { - key = '_'; - } - - /* look up the structure describing this command */ - keyptr = &vikeys[key]; - - /* '&' and uppercase operators always act like doubled */ - if (!prevkey && keyptr->args == CURSOR_MOVED - && (key == '&' || isupper(key))) - { - range = cursor; - prevkey = key; - key = '_'; - keyptr = &vikeys[key]; - } - -#ifndef NO_VISIBLE - /* if we're in the middle of a v/V command, reject commands - * that aren't operators or movement commands - */ - if (V_from && !(keyptr->flags & VIZ)) - { - beep(); - prevkey = 0; - count = 0; - continue; - } -#endif - - /* if we're in the middle of a d/c/y/</>/! command, reject - * anything but movement. - */ - if (prevkey && !(keyptr->flags & (MVMT|PTMV))) - { - beep(); - prevkey = 0; - count = 0; - continue; - } - - /* set the "dot" variables, if we're supposed to */ - if (((keyptr->flags & SDOT) - || (prevkey && vikeys[prevkey].flags & SDOT)) -#ifndef NO_VISIBLE - && !V_from -#endif - ) - { - dotkey = key; - dotpkey = prevkey; - dotkey2 = '\0'; - dotcnt = count; - - /* remember the line before any changes are made */ - if (U_line != markline(cursor)) - { - U_line = markline(cursor); - strcpy(U_text, fetchline(U_line)); - } - } - - /* if this is "." then set other vars from the "dot" vars */ - if (key == '.') - { - key = dotkey; - keyptr = &vikeys[key]; - prevkey = dotpkey; - if (prevkey) - { - range = cursor; - } - if (count == 0) - { - count = dotcnt; - } - doingdot = TRUE; - - /* remember the line before any changes are made */ - if (U_line != markline(cursor)) - { - U_line = markline(cursor); - strcpy(U_text, fetchline(U_line)); - } - } - else - { - doingdot = FALSE; - } - - /* process the key as a command */ - tcurs = cursor; - force_flags = NO_FLAGS; - switch (keyptr->args & ARGSMASK) - { - case ZERO: - if (count == 0) - { - tcurs = cursor & ~(BLKSIZE - 1); - break; - } - /* else fall through & treat like other digits... */ - - case DIGIT: - count = count * 10 + key - '0'; - break; - - case KEYWORD: - /* if not on a keyword, fail */ - pfetch(markline(cursor)); - key = markidx(cursor); - if (!isalnum(ptext[key])) - { - tcurs = MARK_UNSET; - break; - } - - /* find the start of the keyword */ - while (key > 0 && isalnum(ptext[key - 1])) - { - key--; - } - tcurs = (cursor & ~(BLKSIZE - 1)) + key; - - /* copy it into a buffer, and NUL-terminate it */ - i = 0; - do - { - text[i++] = ptext[key++]; - } while (isalnum(ptext[key])); - text[i] = '\0'; - - /* call the function */ - tcurs = (*keyptr->func)(text, tcurs, count); - count = 0L; - break; - - case NO_ARGS: - if (keyptr->func) - { - (*keyptr->func)(); - } - else - { - beep(); - } - count = 0L; - break; - - case CURSOR: - tcurs = (*keyptr->func)(cursor, count, key, prevkey); - count = 0L; - break; - - case CURSOR_CNT_KEY: - if (doingdot) - { - tcurs = (*keyptr->func)(cursor, count, dotkey2); - } - else - { - /* get a key */ - i = getkey(KEYMODE(keyptr->args)); - if (i == '\033') /* ESC */ - { - count = 0; - tcurs = MARK_UNSET; - break; /* exit from "case CURSOR_CNT_KEY" */ - } - else if (i == ctrl('V')) - { - i = getkey(0); - } - - /* if part of an SDOT command, remember it */ - if (keyptr->flags & SDOT - || (prevkey && vikeys[prevkey].flags & SDOT)) - { - dotkey2 = i; - } - - /* do it */ - tcurs = (*keyptr->func)(cursor, count, i); - } - count = 0L; - break; - - case CURSOR_MOVED: -#ifndef NO_VISIBLE - if (V_from) - { - range = cursor; - tcurs = V_from; - count = 0L; - prevkey = key; - key = (V_linemd ? 'V' : 'v'); - keyptr = &vikeys[key]; - } - else -#endif - { - prevkey = key; - range = cursor; - force_flags = LNMD|INCL; - } - break; - - case CURSOR_EOL: - prevkey = key; - /* a zero-length line needs special treatment */ - pfetch(markline(cursor)); - if (plen == 0) - { - /* act on a zero-length section of text */ - range = tcurs = cursor; - key = '0'; - } - else - { - /* act like CURSOR_MOVED with '$' movement */ - range = cursor; - tcurs = m_rear(cursor, 1L); - key = '$'; - } - count = 0L; - keyptr = &vikeys[key]; - break; - - case CURSOR_TEXT: - do - { - text[0] = key; - text[1] = '\0'; - if (doingdot || vgets(key, text + 1, sizeof text - 1) >= 0) - { - /* reassure user that <CR> was hit */ - qaddch('\r'); - refresh(); - - /* call the function with the text */ - tcurs = (*keyptr->func)(cursor, text); - } - else - { - if (exwrote || mode == MODE_COLON) - { - redraw(MARK_UNSET, FALSE); - } - mode = MODE_VI; - } - } while (mode == MODE_COLON); - count = 0L; - break; - } - - /* if that command took us out of vi mode, then exit the loop - * NOW, without tweaking the cursor or anything. This is very - * important when mode == MODE_QUIT. - */ - if (mode != MODE_VI) - { - break; - } - - /* now move the cursor, as appropriate */ - if (prevkey && ((keyptr->flags & MVMT) -#ifndef NO_VISIBLE - || V_from -#endif - ) && count == 0L) - { - /* movements used as targets are less strict */ - tcurs = adjmove(cursor, tcurs, (int)(keyptr->flags | force_flags)); - } - else if (keyptr->args == CURSOR_MOVED) - { - /* the < and > keys have FRNT, - * but it shouldn't be applied yet - */ - tcurs = adjmove(cursor, tcurs, FINL); - } - else - { - tcurs = adjmove(cursor, tcurs, (int)(keyptr->flags | force_flags | FINL)); - } - - /* was that the end of a d/c/y/</>/! command? */ - if (prevkey && ((keyptr->flags & MVMT) -#ifndef NO_VISIBLE - || V_from -#endif - ) && count == 0L) - { -#ifndef NO_VISIBLE - /* turn off the hilight */ - V_from = 0L; -#endif - - /* if the movement command failed, cancel operation */ - if (tcurs == MARK_UNSET) - { - prevkey = 0; - count = 0; - continue; - } - - /* make sure range=front and tcurs=rear. Either way, - * leave cursor=range since that's where we started. - */ - cursor = range; - if (tcurs < range) - { - range = tcurs; - tcurs = cursor; - } - - /* The 'w' and 'W' destinations should never take us - * to the front of a line. Instead, they should take - * us only to the end of the preceding line. - */ - if ((keyptr->flags & NWRP) == NWRP - && markline(range) < markline(tcurs) - && (markline(tcurs) > nlines || tcurs == m_front(tcurs, 0L))) - { - tcurs = (tcurs & ~(BLKSIZE - 1)) - BLKSIZE; - pfetch(markline(tcurs)); - tcurs += plen; - } - - /* adjust for line mode & inclusion of last char/line */ - i = (keyptr->flags | vikeys[prevkey].flags); - switch ((i | force_flags) & (INCL|LNMD)) - { - case INCL: - tcurs++; - break; - - case INCL|LNMD: - tcurs += BLKSIZE; - /* fall through... */ - - case LNMD: - range &= ~(BLKSIZE - 1); - tcurs &= ~(BLKSIZE - 1); - break; - } - - /* run the function */ - tcurs = (*vikeys[prevkey].func)(range, tcurs); - if (mode == MODE_VI) - { - (void)adjmove(cursor, cursor, FINL); - cursor = adjmove(cursor, tcurs, (int)(vikeys[prevkey].flags | FINL)); - } - - /* cleanup */ - prevkey = 0; - } - else if (!prevkey) - { - if (tcurs != MARK_UNSET) - cursor = tcurs; - } - } -} - -/* This function adjusts the MARK value that they return; here we make sure - * it isn't past the end of the line, and that the column hasn't been - * *accidentally* changed. - */ -MARK adjmove(old, new, flags) - MARK old; /* the cursor position before the command */ - REG MARK new; /* the cursor position after the command */ - int flags; /* various flags regarding cursor mvmt */ -{ - static int colno; /* the column number that we want */ - REG char *text; /* used to scan through the line's text */ - REG int i; - -#ifdef DEBUG2 - debout("adjmove(%ld.%d, %ld.%d, 0x%x)\n", markline(old), markidx(old), markline(new), markidx(new), flags); -#endif -#ifdef DEBUG - watch(); -#endif - - /* if the command failed, bag it! */ - if (new == MARK_UNSET) - { - if (flags & FINL) - { - beep(); - return old; - } - return new; - } - - /* if this is a non-relative movement, set the '' mark */ - if (flags & NREL) - { - mark[26] = old; - } - - /* make sure it isn't past the end of the file */ - if (markline(new) < 1) - { - new = MARK_FIRST; - } - else if (markline(new) > nlines) - { - if (!(flags & FINL)) - { - return MARK_EOF; - } - new = MARK_LAST; - } - - /* fetch the new line */ - pfetch(markline(new)); - - /* move to the front, if we're supposed to */ - if (flags & FRNT) - { - new = m_front(new, 1L); - } - - /* change the column#, or change the mark to suit the column# */ - if (!(flags & NCOL)) - { - /* change the column# */ - i = markidx(new); - if (i == BLKSIZE - 1) - { - new &= ~(BLKSIZE - 1); - if (plen > 0) - { - new += plen - 1; - } - colno = BLKSIZE * 8; /* one heck of a big colno */ - } - else if (plen > 0) - { - if (i >= plen) - { - new = (new & ~(BLKSIZE - 1)) + plen - 1; - } - colno = idx2col(new, ptext, FALSE); - } - else - { - new &= ~(BLKSIZE - 1); - colno = 0; - } - } - else - { - /* adjust the mark to get as close as possible to column# */ - for (i = 0, text = ptext; i <= colno && *text; text++) - { - if (*text == '\t' && !*o_list) - { - i += *o_tabstop - (i % *o_tabstop); - } - else if (UCHAR(*text) < ' ' || *text == 127) - { - i += 2; - } -#ifndef NO_CHARATTR - else if (*o_charattr && text[0] == '\\' && text[1] == 'f' && text[2]) - { - text += 2; /* plus one more in "for()" stmt */ - } -#endif - else - { - i++; - } - } - if (text > ptext) - { - text--; - } - new = (new & ~(BLKSIZE - 1)) + (int)(text - ptext); - } - - return new; -} - - -#ifdef DEBUG -watch() -{ - static wasset; - - if (*origname) - { - wasset = TRUE; - } - else if (wasset) - { - mode = MODE_EX; - msg("origname was clobbered"); - endwin(); - abort(); - } - - if (wasset && nlines == 0) - { - mode = MODE_EX; - msg("nlines=0"); - endwin(); - abort(); - } -} -#endif diff --git a/usr.bin/elvis/vi.h b/usr.bin/elvis/vi.h deleted file mode 100644 index 5f62f8779327..000000000000 --- a/usr.bin/elvis/vi.h +++ /dev/null @@ -1,653 +0,0 @@ -/* vi.h */ - -/* Author: - * Steve Kirkendall - * 14407 SW Teal Blvd. #C - * Beaverton, OR 97005 - * kirkenda@cs.pdx.edu - * - * $Id: vi.h,v 1.5 1993/11/08 05:06:35 alm Exp $ - */ - -#define VERSION "ELVIS 1.7, by Steve Kirkendall (30 December 1992)" -#define COPYING "This version of ELVIS is freely redistributable." - -#include <errno.h> -#if TOS -# ifndef __GNUC__ -# define ENOENT (-AEFILNF) -# endif -#endif - -#if TOS || VMS -# include <types.h> -# define O_RDONLY 0 -# define O_WRONLY 1 -# define O_RDWR 2 -# ifdef __GNUC__ -# define S_IJDIR S_IFDIR -# endif -#else -# if OSK -# include <modes.h> -# define O_RDONLY S_IREAD -# define O_WRONLY S_IWRITE -# define O_RDWR (S_IREAD | S_IWRITE) -# define ENOENT E_PNNF -# define sprintf Sprintf -# else -# if !AMIGA -# include <sys/types.h> -# endif -# if COH_286 -# include <sys/fcntl.h> -# else -# include <fcntl.h> -# endif -# endif -#endif - -#ifndef O_BINARY -# define O_BINARY 0 -#endif - -#include "curses.h" - -#include <signal.h> -#ifdef __STDC__ -# include <stdio.h> /* for [v]sprintf prototype */ -# include <string.h> /* for str* prototypes */ -# include <stdlib.h> /* for atoi, system, malloc, free */ -# include <stdarg.h> /* for vararg definitions */ -# if ANY_UNIX -# include <unistd.h> /* for read, write, ... prototypes */ -# include <sys/wait.h> /* for wait prototype */ -# endif -#endif - -/*------------------------------------------------------------------------*/ -/* Miscellaneous constants. */ - -#ifdef REGEX -# define SE_MAX 30 /* max number of subexpressions */ -#endif -#define INFINITY 2000000001L /* a very large integer */ -#define LONGKEY 10 /* longest possible raw :map key */ -#ifndef MAXRCLEN -# define MAXRCLEN 1000 /* longest possible :@ command */ -#endif - -/*------------------------------------------------------------------------*/ -/* These describe how temporary files are divided into blocks */ - -#define MAXBLKS (BLKSIZE / sizeof(unsigned short)) -typedef union -{ - char c[BLKSIZE]; /* for text blocks */ - unsigned short n[MAXBLKS]; /* for the header block */ -} - BLK; - -/*------------------------------------------------------------------------*/ -/* These are used manipulate BLK buffers. */ - -extern BLK hdr; /* buffer for the header block */ -extern BLK *blkget P_((int)); /* given index into hdr.c[], reads block */ -extern BLK *blkadd P_((int)); /* inserts a new block into hdr.c[] */ - -/*------------------------------------------------------------------------*/ -/* These are used to keep track of various flags */ -extern struct _viflags -{ - short file; /* file flags */ -} - viflags; - -/* file flags */ -#define NEWFILE 0x0001 /* the file was just created */ -#define READONLY 0x0002 /* the file is read-only */ -#define HADNUL 0x0004 /* the file contained NUL characters */ -#define MODIFIED 0x0008 /* the file has been modified, but not saved */ -#define NOFILE 0x0010 /* no name is known for the current text */ -#define ADDEDNL 0x0020 /* newlines were added to the file */ -#define HADBS 0x0040 /* backspace chars were lost from the file */ -#define UNDOABLE 0x0080 /* file has been modified */ -#define NOTEDITED 0x0100 /* the :file command has been used */ - -/* macros used to set/clear/test flags */ -#define setflag(x,y) viflags.x |= y -#define clrflag(x,y) viflags.x &= ~y -#define tstflag(x,y) (viflags.x & y) -#define initflags() viflags.file = 0; - -/* The options */ -extern char o_autoindent[1]; -extern char o_autoprint[1]; -extern char o_autotab[1]; -extern char o_autowrite[1]; -extern char o_columns[3]; -extern char o_directory[30]; -extern char o_edcompatible[1]; -extern char o_equalprg[80]; -extern char o_errorbells[1]; -extern char o_exrefresh[1]; -extern char o_ignorecase[1]; -extern char o_keytime[3]; -extern char o_keywordprg[80]; -extern char o_lines[3]; -extern char o_list[1]; -extern char o_number[1]; -extern char o_readonly[1]; -extern char o_remap[1]; -extern char o_report[3]; -extern char o_scroll[3]; -extern char o_shell[60]; -extern char o_shiftwidth[3]; -extern char o_sidescroll[3]; -extern char o_sync[1]; -extern char o_tabstop[3]; -extern char o_term[30]; -extern char o_flash[1]; -extern char o_warn[1]; -extern char o_wrapscan[1]; - -#ifndef CRUNCH -extern char o_beautify[1]; -extern char o_exrc[1]; -extern char o_mesg[1]; -extern char o_more[1]; -extern char o_nearscroll[3]; -extern char o_novice[1]; -extern char o_prompt[1]; -extern char o_taglength[3]; -extern char o_tags[256]; -extern char o_terse[1]; -extern char o_window[3]; -extern char o_wrapmargin[3]; -extern char o_writeany[1]; -#endif - -#ifndef NO_ERRLIST -extern char o_cc[30]; -extern char o_make[30]; -#endif - -#ifndef NO_CHARATTR -extern char o_charattr[1]; -#endif - -#ifndef NO_DIGRAPH -extern char o_digraph[1]; -extern char o_flipcase[80]; -#endif - -#ifndef NO_SENTENCE -extern char o_hideformat[1]; -#endif - -#ifndef NO_EXTENSIONS -extern char o_inputmode[1]; -extern char o_ruler[1]; -#endif - -#ifndef NO_MAGIC -extern char o_magic[1]; -#endif - -#ifndef NO_MODELINES -extern char o_modelines[1]; -#endif - -#ifndef NO_SENTENCE -extern char o_paragraphs[30]; -extern char o_sections[30]; -#endif - -#if MSDOS -extern char o_pcbios[1]; -#endif - -#ifndef NO_SHOWMATCH -extern char o_showmatch[1]; -#endif - -#ifndef NO_SHOWMODE -extern char o_smd[1]; -#endif - -#ifndef NO_TAGSTACK -extern char o_tagstack[1]; -#endif - -/*------------------------------------------------------------------------*/ -/* These help support the single-line multi-change "undo" -- shift-U */ - -extern char U_text[BLKSIZE]; -extern long U_line; - -/*------------------------------------------------------------------------*/ -/* These are used to refer to places in the text */ - -typedef long MARK; -#define markline(x) (long)((x) / BLKSIZE) -#define markidx(x) (int)((x) & (BLKSIZE - 1)) -#define MARK_UNSET ((MARK)0) -#define MARK_FIRST ((MARK)BLKSIZE) -#define MARK_LAST ((MARK)(nlines * BLKSIZE)) -#define MARK_EOF ((MARK)((nlines + 1) * BLKSIZE)) -#define MARK_AT_LINE(x) ((MARK)(x) * BLKSIZE) - -#define NMARKS 29 -extern MARK mark[NMARKS]; /* marks a-z, plus mark ' and two temps */ -extern MARK cursor; /* mark where line is */ - -/*------------------------------------------------------------------------*/ -/* These are used to keep track of the current & previous files. */ - -extern long origtime; /* modification date&time of the current file */ -extern char origname[256]; /* name of the current file */ -extern char prevorig[256]; /* name of the preceding file */ -extern long prevline; /* line number from preceding file */ - -/*------------------------------------------------------------------------*/ -/* misc housekeeping variables & functions */ - -extern int tmpfd; /* fd used to access the tmp file */ -extern int tmpnum; /* counter used to generate unique filenames */ -extern long lnum[MAXBLKS]; /* last line# of each block */ -extern long nlines; /* number of lines in the file */ -extern char args[BLKSIZE]; /* file names given on the command line */ -extern int argno; /* the current element of args[] */ -extern int nargs; /* number of filenames in args */ -extern long changes; /* counts changes, to prohibit short-cuts */ -extern int significant; /* boolean: was a *REAL* change made? */ -extern int exitcode; /* 0=overwritten, 1=error */ -extern BLK tmpblk; /* a block used to accumulate changes */ -extern long topline; /* file line number of top line */ -extern int leftcol; /* column number of left col */ -#define botline (topline + LINES - 2) -#define rightcol (leftcol + COLS - (*o_number ? 9 : 1)) -extern int physcol; /* physical column number that cursor is on */ -extern int physrow; /* physical row number that cursor is on */ -extern int exwrote; /* used to detect verbose ex commands */ -extern int doingdot; /* boolean: are we doing the "." command? */ -extern int doingglobal; /* boolean: are doing a ":g" command? */ -extern long rptlines; /* number of lines affected by a command */ -extern char *rptlabel; /* description of how lines were affected */ -extern char *fetchline P_((long)); /* read a given line from tmp file */ -extern char *parseptrn P_((REG char *)); /* isolate a regexp in a line */ -extern MARK paste P_((MARK, int, int)); /* paste from cut buffer to a given point */ -extern char *wildcard P_((char *)); /* expand wildcards in filenames */ -extern MARK input P_((MARK, MARK, int, int)); /* inserts characters from keyboard */ -extern char *linespec P_((REG char *, MARK *)); /* finds the end of a /regexp/ string */ -#define ctrl(ch) ((ch)&037) -#ifndef NO_RECYCLE -extern long allocate P_((void)); /* allocate a free block of the tmp file */ -#endif -extern SIGTYPE trapint P_((int)); /* trap handler for SIGINT */ -extern SIGTYPE deathtrap P_((int)); /* trap handler for deadly signals */ -extern void blkdirty P_((BLK *)); /* marks a block as being "dirty" */ -extern void blksync P_((void)); /* forces all "dirty" blocks to disk */ -extern void blkinit P_((void)); /* resets the block cache to "empty" state */ -extern void beep P_((void)); /* rings the terminal's bell */ -extern void exrefresh P_((void)); /* writes text to the screen */ -#ifdef __STDC__ -extern void msg (char *, ...); /* writes a printf-style message to the screen */ -#else -extern void msg (); /* writes a printf-style message to the screen */ -#endif -extern void endmsgs P_((void)); /* if "manymsgs" is set, then scroll up 1 line */ -extern void garbage P_((void)); /* reclaims any garbage blocks */ -extern void redraw P_((MARK, int)); /* updates the screen after a change */ -extern void resume_curses P_((int)); /* puts the terminal in "cbreak" mode */ -extern void beforedo P_((int)); /* saves current revision before a new change */ -extern void afterdo P_((void)); /* marks end of a beforedo() change */ -extern void abortdo P_((void)); /* like "afterdo()" followed by "undo()" */ -extern int undo P_((void)); /* restores file to previous undo() */ -extern void dumpkey P_((int, int)); /* lists key mappings to the screen */ -extern void mapkey P_((char *, char *, int, char *)); /* defines a new key mapping */ -extern void redrawrange P_((long, long, long)); /* records clues from modify.c */ -extern void cut P_((MARK, MARK)); /* saves text in a cut buffer */ -extern void delete P_((MARK, MARK)); /* deletes text */ -extern void add P_((MARK, char *)); /* adds text */ -extern void change P_((MARK, MARK, char *));/* deletes text, and then adds other text */ -extern void cutswitch P_((void)); /* updates cut buffers when we switch files */ -extern void do_digraph P_((int, char [])); /* defines or lists digraphs */ -extern void exstring P_((char *, int, int));/* execute a string as EX commands */ -extern void dumpopts P_((int)); /* display current option settings on the screen */ -extern void setopts P_((char *)); /* assign new values to options */ -extern void saveopts P_((int)); /* save current option values to a given fd */ -extern void savedigs P_((int)); /* save current non-standard digraphs to fd */ -extern void savecolor P_((int)); /* save current color settings (if any) to fd */ -extern void cutname P_((int)); /* select cut buffer for next cut/paste */ -extern void initopts P_((void)); /* initialize options */ -extern void cutend P_((void)); /* free all cut buffers & delete temp files */ -extern int storename P_((char *)); /* stamp temp file with pathname of text file */ -extern int tmpstart P_((char *)); /* load a text file into edit buffer */ -extern int tmpsave P_((char *, int)); /* write edit buffer out to text file */ -extern int tmpend P_((int)); /* call tmpsave(), and then tmpabort */ -extern int tmpabort P_((int)); /* abandon the current edit buffer */ -extern void savemaps P_((int, int)); /* write current :map or :ab commands to fd */ -extern int ansicolor P_((int, int)); /* emit ANSI color command to terminal */ -extern int filter P_((MARK, MARK, char *, int)); /* I/O though another program */ -extern int getkey P_((int)); /* return a keystroke, interpretting maps */ -extern int vgets P_((int, char *, int)); /* read a single line from keyboard */ -extern int doexrc P_((char *)); /* execute a string as a sequence of EX commands */ -extern int cb2str P_((int, char *, unsigned));/* return a string containing cut buffer's contents */ -extern int ansiquit P_((void)); /* neutralize previous ansicolor() call */ -extern int ttyread P_((char *, int, int)); /* read from keyboard with optional timeout */ -extern int tgetent P_((char *, char *)); /* start termcap */ -extern int tgetnum P_((char *)); /* get a termcap number */ -extern int tgetflag P_((char *)); /* get a termcap boolean */ -extern int getsize P_((int)); /* determine how big the screen is */ -extern int endcolor P_((void)); /* used during color output */ -extern int getabkey P_((int, char *, int));/* like getkey(), but also does abbreviations */ -extern int idx2col P_((MARK, REG char *, int)); /* returns column# of a given MARK */ -extern int cutneeds P_((BLK *)); /* returns bitmap of blocks needed to hold cutbuffer text */ -extern void execmap P_((int, char *, int)); /* replaces "raw" keys with "mapped" keys */ -#ifndef CRUNCH -extern int wset; /* boolean: has the "window" size been set? */ -#endif - -/*------------------------------------------------------------------------*/ -/* macros that are used as control structures */ - -#define BeforeAfter(before, after) for((before),bavar=1;bavar;(after),bavar=0) -#define ChangeText BeforeAfter(beforedo(FALSE),afterdo()) - -extern int bavar; /* used only in BeforeAfter macros */ - -/*------------------------------------------------------------------------*/ -/* These are the movement commands. Each accepts a mark for the starting */ -/* location & number and returns a mark for the destination. */ - -extern MARK m_updnto P_((MARK, long, int)); /* k j G */ -extern MARK m_right P_((MARK, long, int, int)); /* h */ -extern MARK m_left P_((MARK, long)); /* l */ -extern MARK m_tocol P_((MARK, long, int)); /* | */ -extern MARK m_front P_((MARK, long)); /* ^ */ -extern MARK m_rear P_((MARK, long)); /* $ */ -extern MARK m_fword P_((MARK, long, int, int)); /* w */ -extern MARK m_bword P_((MARK, long, int)); /* b */ -extern MARK m_eword P_((MARK, long, int)); /* e */ -extern MARK m_paragraph P_((MARK, long, int)); /* { } [[ ]] */ -extern MARK m_match P_((MARK, long)); /* % */ -#ifndef NO_SENTENCE -extern MARK m_sentence P_((MARK, long, int)); /* ( ) */ -#endif -extern MARK m_tomark P_((MARK, long, int)); /* 'm */ -#ifndef NO_EXTENSIONS -extern MARK m_wsrch P_((char *, MARK, int)); /* ^A */ -#endif -extern MARK m_nsrch P_((MARK, long, int)); /* n */ -extern MARK m_fsrch P_((MARK, char *)); /* /regexp */ -extern MARK m_bsrch P_((MARK, char *)); /* ?regexp */ -#ifndef NO_CHARSEARCH -extern MARK m__ch P_((MARK, long, int)); /* ; , */ -extern MARK m_fch P_((MARK, long, int)); /* f */ -extern MARK m_tch P_((MARK, long, int)); /* t */ -extern MARK m_Fch P_((MARK, long, int)); /* F */ -extern MARK m_Tch P_((MARK, long, int)); /* T */ -#endif -extern MARK m_row P_((MARK, long, int)); /* H L M */ -extern MARK m_z P_((MARK, long, int)); /* z */ -extern MARK m_scroll P_((MARK, long, int)); /* ^B ^F ^E ^Y ^U ^D */ - -/* Some stuff that is used by movement functions... */ - -extern MARK adjmove P_((MARK, REG MARK, int)); /* a helper fn, used by move fns */ - -/* This macro is used to set the default value of cnt */ -#define DEFAULT(val) if (cnt < 1) cnt = (val) - -/* These are used to minimize calls to fetchline() */ -extern int plen; /* length of the line */ -extern long pline; /* line number that len refers to */ -extern long pchgs; /* "changes" level that len refers to */ -extern char *ptext; /* text of previous line, if valid */ -extern void pfetch P_((long)); -extern char digraph P_((int, int)); - -/* This is used to build a MARK that corresponds to a specific point in the - * line that was most recently pfetch'ed. - */ -#define buildmark(text) (MARK)(BLKSIZE * pline + (int)((text) - ptext)) - - -/*------------------------------------------------------------------------*/ -/* These are used to handle EX commands. */ - -#define CMD_NULL 0 /* NOT A VALID COMMAND */ -#define CMD_ABBR 1 /* "define an abbreviation" */ -#define CMD_ARGS 2 /* "show me the args" */ -#define CMD_APPEND 3 /* "insert lines after this line" */ -#define CMD_AT 4 /* "execute a cut buffer's contents via EX" */ -#define CMD_BANG 5 /* "run a single shell command" */ -#define CMD_CC 6 /* "run `cc` and then do CMD_ERRLIST" */ -#define CMD_CD 7 /* "change directories" */ -#define CMD_CHANGE 8 /* "change some lines" */ -#define CMD_COLOR 9 /* "change the default colors" */ -#define CMD_COPY 10 /* "copy the selected text to a given place" */ -#define CMD_DELETE 11 /* "delete the selected text" */ -#define CMD_DIGRAPH 12 /* "add a digraph, or display them all" */ -#define CMD_EDIT 13 /* "switch to a different file" */ -#define CMD_EQUAL 14 /* "display a line number" */ -#define CMD_ERRLIST 15 /* "locate the next error in a list" */ -#define CMD_FILE 16 /* "show the file's status" */ -#define CMD_GLOBAL 17 /* "globally search & do a command" */ -#define CMD_INSERT 18 /* "insert lines before the current line" */ -#define CMD_JOIN 19 /* "join the selected line & the one after" */ -#define CMD_LIST 20 /* "print lines, making control chars visible" */ -#define CMD_MAKE 21 /* "run `make` and then do CMD_ERRLIST" */ -#define CMD_MAP 22 /* "adjust the keyboard map" */ -#define CMD_MARK 23 /* "mark this line" */ -#define CMD_MKEXRC 24 /* "make a .exrc file" */ -#define CMD_MOVE 25 /* "move the selected text to a given place" */ -#define CMD_NEXT 26 /* "switch to next file in args" */ -#define CMD_NUMBER 27 /* "print lines from the file w/ line numbers" */ -#define CMD_POP 28 /* "pop a position off the tagstack" */ -#define CMD_PRESERVE 29 /* "act as though vi crashed" */ -#define CMD_PREVIOUS 30 /* "switch to the previous file in args" */ -#define CMD_PRINT 31 /* "print the selected text" */ -#define CMD_PUT 32 /* "insert any cut lines before this line" */ -#define CMD_QUIT 33 /* "quit without writing the file" */ -#define CMD_READ 34 /* "append the given file after this line */ -#define CMD_RECOVER 35 /* "recover file after vi crashes" - USE -r FLAG */ -#define CMD_REWIND 36 /* "rewind to first file" */ -#define CMD_SET 37 /* "set a variable's value" */ -#define CMD_SHELL 38 /* "run some lines through a command" */ -#define CMD_SHIFTL 39 /* "shift lines left" */ -#define CMD_SHIFTR 40 /* "shift lines right" */ -#define CMD_SOURCE 41 /* "interpret a file's contents as ex commands" */ -#define CMD_STOP 42 /* same as CMD_SUSPEND */ -#define CMD_SUBAGAIN 43 /* "repeat the previous substitution" */ -#define CMD_SUBSTITUTE 44 /* "substitute text in this line" */ -#define CMD_SUSPEND 45 /* "suspend the vi session" */ -#define CMD_TR 46 /* "transliterate chars in the selected lines" */ -#define CMD_TAG 47 /* "go to a particular tag" */ -#define CMD_UNABBR 48 /* "remove an abbreviation definition" */ -#define CMD_UNDO 49 /* "undo the previous command" */ -#define CMD_UNMAP 50 /* "remove a key sequence map */ -#define CMD_VERSION 51 /* "describe which version this is" */ -#define CMD_VGLOBAL 52 /* "apply a cmd to lines NOT containing an RE" */ -#define CMD_VISUAL 53 /* "go into visual mode" */ -#define CMD_WQUIT 54 /* "write this file out (any case) & quit" */ -#define CMD_WRITE 55 /* "write the selected(?) text to a given file" */ -#define CMD_XIT 56 /* "write this file out (if modified) & quit" */ -#define CMD_YANK 57 /* "copy the selected text into the cut buffer" */ -#define CMD_DEBUG 58 /* access to internal data structures */ -#define CMD_VALIDATE 59 /* check for internal consistency */ -typedef int CMD; - -extern void ex P_((void)); -extern void vi P_((void)); -extern void doexcmd P_((char *)); - -extern void cmd_append P_((MARK, MARK, CMD, int, char *)); -extern void cmd_args P_((MARK, MARK, CMD, int, char *)); -#ifndef NO_AT - extern void cmd_at P_((MARK, MARK, CMD, int, char *)); -#endif -extern void cmd_cd P_((MARK, MARK, CMD, int, char *)); -#ifndef NO_COLOR - extern void cmd_color P_((MARK, MARK, CMD, int, char *)); -#endif -extern void cmd_delete P_((MARK, MARK, CMD, int, char *)); -#ifndef NO_DIGRAPH - extern void cmd_digraph P_((MARK, MARK, CMD, int, char *)); -#endif -extern void cmd_edit P_((MARK, MARK, CMD, int, char *)); -#ifndef NO_ERRLIST - extern void cmd_errlist P_((MARK, MARK, CMD, int, char *)); -#endif -extern void cmd_file P_((MARK, MARK, CMD, int, char *)); -extern void cmd_global P_((MARK, MARK, CMD, int, char *)); -extern void cmd_join P_((MARK, MARK, CMD, int, char *)); -extern void cmd_mark P_((MARK, MARK, CMD, int, char *)); -#ifndef NO_ERRLIST - extern void cmd_make P_((MARK, MARK, CMD, int, char *)); -#endif -extern void cmd_map P_((MARK, MARK, CMD, int, char *)); -#ifndef NO_MKEXRC - extern void cmd_mkexrc P_((MARK, MARK, CMD, int, char *)); -#endif -extern void cmd_next P_((MARK, MARK, CMD, int, char *)); -#ifndef NO_TAGSTACK -extern void cmd_pop P_((MARK, MARK, CMD, int, char *)); -#endif -extern void cmd_print P_((MARK, MARK, CMD, int, char *)); -extern void cmd_put P_((MARK, MARK, CMD, int, char *)); -extern void cmd_read P_((MARK, MARK, CMD, int, char *)); -extern void cmd_set P_((MARK, MARK, CMD, int, char *)); -extern void cmd_shell P_((MARK, MARK, CMD, int, char *)); -extern void cmd_shift P_((MARK, MARK, CMD, int, char *)); -extern void cmd_source P_((MARK, MARK, CMD, int, char *)); -extern void cmd_substitute P_((MARK, MARK, CMD, int, char *)); -extern void cmd_tag P_((MARK, MARK, CMD, int, char *)); -extern void cmd_undo P_((MARK, MARK, CMD, int, char *)); -extern void cmd_version P_((MARK, MARK, CMD, int, char *)); -extern void cmd_write P_((MARK, MARK, CMD, int, char *)); -extern void cmd_xit P_((MARK, MARK, CMD, int, char *)); -extern void cmd_move P_((MARK, MARK, CMD, int, char *)); -#ifdef DEBUG - extern void cmd_debug P_((MARK, MARK, CMD, int, char *)); - extern void cmd_validate P_((MARK, MARK, CMD, int, char *)); -#endif -#ifdef SIGTSTP - extern void cmd_suspend P_((MARK, MARK, CMD, int, char *)); -#endif - -/*----------------------------------------------------------------------*/ -/* These are used to handle VI commands */ - -extern MARK v_1ex P_((MARK, char *)); /* : */ -extern MARK v_mark P_((MARK, long, int)); /* m */ -extern MARK v_quit P_((void)); /* Q */ -extern MARK v_redraw P_((void)); /* ^L ^R */ -extern MARK v_ulcase P_((MARK, long)); /* ~ */ -extern MARK v_undo P_((MARK)); /* u */ -extern MARK v_xchar P_((MARK, long, int)); /* x X */ -extern MARK v_replace P_((MARK, long, int));/* r */ -extern MARK v_overtype P_((MARK)); /* R */ -extern MARK v_selcut P_((MARK, long, int)); /* " */ -extern MARK v_paste P_((MARK, long, int)); /* p P */ -extern MARK v_yank P_((MARK, MARK)); /* y Y */ -extern MARK v_delete P_((MARK, MARK)); /* d D */ -extern MARK v_join P_((MARK, long)); /* J */ -extern MARK v_insert P_((MARK, long, int)); /* a A i I o O */ -extern MARK v_change P_((MARK, MARK)); /* c C */ -extern MARK v_subst P_((MARK, long)); /* s */ -extern MARK v_lshift P_((MARK, MARK)); /* < */ -extern MARK v_rshift P_((MARK, MARK)); /* > */ -extern MARK v_reformat P_((MARK, MARK)); /* = */ -extern MARK v_filter P_((MARK, MARK)); /* ! */ -extern MARK v_status P_((void)); /* ^G */ -extern MARK v_switch P_((void)); /* ^^ */ -extern MARK v_tag P_((char *, MARK, long)); /* ^] */ -extern MARK v_xit P_((MARK, long, int)); /* ZZ */ -extern MARK v_undoline P_((MARK)); /* U */ -extern MARK v_again P_((MARK, MARK)); /* & */ -#ifndef NO_EXTENSIONS -extern MARK v_keyword P_((char *, MARK, long)); /* K */ -extern MARK v_increment P_((char *, MARK, long)); /* * */ -#endif -#ifndef NO_ERRLIST -extern MARK v_errlist P_((MARK)); /* * */ -#endif -#ifndef NO_AT -extern MARK v_at P_((MARK, long, int)); /* @ */ -#endif -#ifdef SIGTSTP -extern MARK v_suspend P_((void)); /* ^Z */ -#endif -#ifndef NO_POPUP -extern MARK v_popup P_((MARK, MARK)); /* \ */ -#endif -#ifndef NO_TAGSTACK -extern MARK v_pop P_((MARK, long, int)); /* ^T */ -#endif - -/*----------------------------------------------------------------------*/ -/* These flags describe the quirks of the individual visual commands */ -#define NO_FLAGS 0x00 -#define MVMT 0x01 /* this is a movement command */ -#define PTMV 0x02 /* this can be *part* of a movement command */ -#define FRNT 0x04 /* after move, go to front of line */ -#define INCL 0x08 /* include last char when used with c/d/y */ -#define LNMD 0x10 /* use line mode of c/d/y */ -#define NCOL 0x20 /* this command can't change the column# */ -#define NREL 0x40 /* this is "non-relative" -- set the '' mark */ -#define SDOT 0x80 /* set the "dot" variables, for the "." cmd */ -#define FINL 0x100 /* final testing, more strict! */ -#define NWRP 0x200 /* no line-wrap (used for 'w' and 'W') */ -#ifndef NO_VISIBLE -# define VIZ 0x400 /* commands which can be used with 'v' */ -#else -# define VIZ 0 -#endif - -/* This variable is zeroed before a command executes, and later ORed with the - * command's flags after the command has been executed. It is used to force - * certain flags to be TRUE for *some* invocations of a particular command. - * For example, "/regexp/+offset" forces the LNMD flag, and sometimes a "p" - * or "P" command will force FRNT. - */ -extern int force_flags; - -/*----------------------------------------------------------------------*/ -/* These describe what mode we're in */ - -#define MODE_EX 1 /* executing ex commands */ -#define MODE_VI 2 /* executing vi commands */ -#define MODE_COLON 3 /* executing an ex command from vi mode */ -#define MODE_QUIT 4 -extern int mode; - -#define WHEN_VICMD 1 /* getkey: we're reading a VI command */ -#define WHEN_VIINP 2 /* getkey: we're in VI's INPUT mode */ -#define WHEN_VIREP 4 /* getkey: we're in VI's REPLACE mode */ -#define WHEN_EX 8 /* getkey: we're in EX mode */ -#define WHEN_MSG 16 /* getkey: we're at a "more" prompt */ -#define WHEN_POPUP 32 /* getkey: we're in the pop-up menu */ -#define WHEN_REP1 64 /* getkey: we're getting a single char for 'r' */ -#define WHEN_CUT 128 /* getkey: we're getting a cut buffer name */ -#define WHEN_MARK 256 /* getkey: we're getting a mark name */ -#define WHEN_CHAR 512 /* getkey: we're getting a destination for f/F/t/T */ -#define WHEN_INMV 4096 /* in input mode, interpret the key in VICMD mode */ -#define WHEN_FREE 8192 /* free the keymap after doing it once */ -#define WHENMASK (WHEN_VICMD|WHEN_VIINP|WHEN_VIREP|WHEN_REP1|WHEN_CUT|WHEN_MARK|WHEN_CHAR) - -#ifndef NO_VISIBLE -extern MARK V_from; -extern int V_linemd; -extern MARK v_start P_((MARK m, long cnt, int cmd)); -#endif - -#ifdef DEBUG -# define malloc(size) dbmalloc(size, __FILE__, __LINE__) -# define free(ptr) dbfree(ptr, __FILE__, __LINE__) -# define checkmem() dbcheckmem(__FILE__, __LINE__) -extern char *dbmalloc P_((int, char *, int)); -#else -# define checkmem() -#endif diff --git a/usr.bin/file/magdir/vax.byteswap b/usr.bin/file/magdir/vax.byteswap deleted file mode 100644 index be51eceab769..000000000000 --- a/usr.bin/file/magdir/vax.byteswap +++ /dev/null @@ -1,17 +0,0 @@ -# Byte-swapped VAXen -# From: dupuy@amsterdam.columbia.edu (Alexander Dupuy) -# -# Here are a few lines you can add to /etc/magic on your sun workstations in -# order to recognize VAX executables and objects.... you could do something -# similar (in reverse) for your vaxen, but since 4.3+NFS' file(1) doesn't look -# for /etc/magic, I've never bothered. It really should be built in to file(1) -# so you would see the state of setuid/setgid/sticky bits. Or actually, there -# should be support for checking that sort of thing in /etc/magic. -# -0 long 00700200000 VAX executable ->16 long &0x7fffffff not stripped -0 long 01000200000 VAX pure executable ->16 long &0x7fffffff not stripped -0 long 01300200000 VAX demand-paged pure executable ->16 long &0x7fffffff not stripped -0 long 01100200000 PDP-11 executable diff --git a/usr.bin/lex/lex.1 b/usr.bin/lex/lex.1 deleted file mode 100644 index 5c3d0eeba6d3..000000000000 --- a/usr.bin/lex/lex.1 +++ /dev/null @@ -1,833 +0,0 @@ -.\" Copyright (c) 1990 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)lex.1 5.13 (Berkeley) 7/24/91 -.\" $Id: lex.1,v 1.4 1993/08/06 19:41:44 mycroft Exp $ -.\" -.Dd July 24, 1991 -.Dt LEX 1 -.Os -.Sh NAME -.Nm lex -.Nd fast lexical analyzer generator -.Sh SYNOPSIS -.Nm lex -.Oo -.Op Fl bcdfinpstvFILT8 -.Fl C Ns Ns Op Cm efmF -.Fl S Ns Ns Ar skeleton -.Oc -.Op Ar -.Sh DESCRIPTION -.Nm Lex -is a tool for generating -.Ar scanners : -programs which recognized lexical patterns in text. -.Nm Lex -reads -the given input files, or its standard input if no file names are given, -for a description of a scanner to generate. The description is in -the form of pairs -of regular expressions and C code, called -.Em rules . -.Nm Lex -generates as output a C source file, -.Pa lex.yy.c , -which defines a routine -.Fn yylex . -This file is compiled and linked with the -.Fl lfl -library to produce an executable. When the executable is run, -it analyzes its input for occurrences -of the regular expressions. Whenever it finds one, it executes -the corresponding C code. -.Pp -For full documentation, see -.Em Lexdoc . -This manual entry is intended for use as a quick reference. -.Sh OPTIONS -.Nm Lex -has the following options: -.Bl -tag -width Ds -.It Fl b -Generate backtracking information to -.Va lex.backtrack . -This is a list of scanner states which require backtracking -and the input characters on which they do so. By adding rules one -can remove backtracking states. If all backtracking states -are eliminated and -.Fl f -or -.Fl F -is used, the generated scanner will run faster. -.It Fl c -is a do-nothing, deprecated option included for -.Tn POSIX -compliance. -.Pp -.Ar NOTE : -in previous releases of -.Nm Lex -.Op Fl c -specified table-compression options. This functionality is -now given by the -.Fl C -flag. To ease the the impact of this change, when -.Nm lex -encounters -.Fl c, -it currently issues a warning message and assumes that -.Fl C -was desired instead. In the future this "promotion" of -.Fl c -to -.Fl C -will go away in the name of full -.Tn POSIX -compliance (unless -the -.Tn POSIX -meaning is removed first). -.It Fl d -Makes the generated scanner run in -.Ar debug -mode. Whenever a pattern is recognized and the global -.Va yy_Lex_debug -is non-zero (which is the default), the scanner will -write to -.Li stderr -a line of the form: -.Pp -.Dl --accepting rule at line 53 ("the matched text") -.Pp -The line number refers to the location of the rule in the file -defining the scanner (i.e., the file that was fed to lex). Messages -are also generated when the scanner backtracks, accepts the -default rule, reaches the end of its input buffer (or encounters -a -.Tn NUL ; -the two look the same as far as the scanner's concerned), -or reaches an end-of-file. -.It Fl f -Specifies (take your pick) -.Em full table -or -.Em fast scanner . -No table compression is done. The result is large but fast. -This option is equivalent to -.Fl Cf -(see below). -.It Fl i -Instructs -.Nm lex -to generate a -.Em case-insensitive -scanner. The case of letters given in the -.Nm lex -input patterns will -be ignored, and tokens in the input will be matched regardless of case. The -matched text given in -.Va yytext -will have the preserved case (i.e., it will not be folded). -.It Fl n -Is another do-nothing, deprecated option included only for -.Tn POSIX -compliance. -.It Fl p -Generates a performance report to stderr. The report -consists of comments regarding features of the -.Nm lex -input file which will cause a loss of performance in the resulting scanner. -.It Fl s -Causes the -.Ar default rule -(that unmatched scanner input is echoed to -.Ar stdout ) -to be suppressed. If the scanner encounters input that does not -match any of its rules, it aborts with an error. -.It Fl t -Instructs -.Nm lex -to write the scanner it generates to standard output instead -of -.Pa lex.yy.c . -.It Fl v -Specifies that -.Nm lex -should write to -.Li stderr -a summary of statistics regarding the scanner it generates. -.It Fl F -Specifies that the -.Em fast -scanner table representation should be used. This representation is -about as fast as the full table representation -.Pq Fl f , -and for some sets of patterns will be considerably smaller (and for -others, larger). See -.Em Lexdoc -for details. -.Pp -This option is equivalent to -.Fl CF -(see below). -.It Fl I -Instructs -.Nm lex -to generate an -.Em interactive -scanner, that is, a scanner which stops immediately rather than -looking ahead if it knows -that the currently scanned text cannot be part of a longer rule's match. -Again, see -.Em Lexdoc -for details. -.Pp -Note, -.Fl I -cannot be used in conjunction with -.Em full -or -.Em fast tables , -i.e., the -.Fl f , F , Cf , -or -.Fl CF -flags. -.It Fl L -Instructs -.Nm lex -not to generate -.Li #line -directives in -.Pa lex.yy.c . -The default is to generate such directives so error -messages in the actions will be correctly -located with respect to the original -.Nm lex -input file, and not to -the fairly meaningless line numbers of -.Pa lex.yy.c . -.It Fl T -Makes -.Nm lex -run in -.Em trace -mode. It will generate a lot of messages to -.Li stdout -concerning -the form of the input and the resultant non-deterministic and deterministic -finite automata. This option is mostly for use in maintaining -.Nm lex . -.It Fl 8 -Instructs -.Nm lex -to generate an 8-bit scanner. -On some sites, this is the default. On others, the default -is 7-bit characters. To see which is the case, check the verbose -.Pq Fl v -output for "equivalence classes created". If the denominator of -the number shown is 128, then by default -.Nm lex -is generating 7-bit characters. If it is 256, then the default is -8-bit characters. -.It Fl C Ns Op Cm efmF -Controls the degree of table compression. The default setting is -.Fl Cem . -.Pp -.Bl -tag -width Ds -.It Fl C -A lone -.Fl C -specifies that the scanner tables should be compressed but neither -equivalence classes nor meta-equivalence classes should be used. -.It Fl \&Ce -Directs -.Nm lex -to construct -.Em equivalence classes , -i.e., sets of characters -which have identical lexical properties. -Equivalence classes usually give -dramatic reductions in the final table/object file sizes (typically -a factor of 2-5) and are pretty cheap performance-wise (one array -look-up per character scanned). -.It Fl \&Cf -Specifies that the -.Em full -scanner tables should be generated - -.Nm lex -should not compress the -tables by taking advantages of similar transition functions for -different states. -.It Fl \&CF -Specifies that the alternate fast scanner representation (described in -.Em Lexdoc ) -should be used. -.It Fl \&Cm -Directs -.Nm lex -to construct -.Em meta-equivalence classes , -which are sets of equivalence classes (or characters, if equivalence -classes are not being used) that are commonly used together. Meta-equivalence -classes are often a big win when using compressed tables, but they -have a moderate performance impact (one or two "if" tests and one -array look-up per character scanned). -.It Fl Cem -(Default) -Generate both equivalence classes -and meta-equivalence classes. This setting provides the highest -degree of table compression. -.El -.Pp -Faster-executing scanners can be traded off at the -cost of larger tables with -the following generally being true: -.Bd -ragged -offset center -slowest & smallest - -Cem - -Cm - -Ce - -C - -C{f,F}e - -C{f,F} -fastest & largest -.Ed -.Pp -.Fl C -options are not cumulative; whenever the flag is encountered, the -previous -C settings are forgotten. -.Pp -The options -.Fl \&Cf -or -.Fl \&CF -and -.Fl \&Cm -do not make sense together - there is no opportunity for meta-equivalence -classes if the table is not being compressed. Otherwise the options -may be freely mixed. -.It Fl S Ns Ar skeleton_file -Overrides the default skeleton file from which -.Nm lex -constructs its scanners. Useful for -.Nm lex -maintenance or development. -.El -.Sh SUMMARY OF LEX REGULAR EXPRESSIONS -The patterns in the input are written using an extended set of regular -expressions. These are: -.Pp -.Bl -tag -width 10n -compact -.It Li x -Match the character 'x'. -.It Li \&. -Any character except newline. -.It Op Li xyz -A "character class"; in this case, the pattern -matches either an 'x', a 'y', or a 'z'. -.It Op Li abj-oZ -A "character class" with a range in it; matches -an 'a', a 'b', any letter from 'j' through 'o', -or a 'Z'. -.It Op Li ^A-Z -A "negated character class", i.e., any character -but those in the class. In this case, any -character -.Em except -an uppercase letter. -.It Op Li ^A-Z\en -Any character -.Em except -an uppercase letter or -a newline. -.It Li r* -Zero or more r's, where r is any regular expression. -.It Li r+ -One or more r's. -.It Li r? -Zero or one r's (that is, "an optional r"). -.It Li r{2,5} -Anywhere from two to five r's. -.It Li r{2,} -Two or more r's. -.It Li r{4} -Exactly 4 r's. -.It Li {name} -The expansion of the "name" definition -(see above). -.It Xo -.Oo Li xyz Oc Ns Li "\e\&\*qfoo" -.Xc -The literal string: -[xyz]\*qfoo. -.It Li \&\eX -If X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v', -then the -.Tn ANSI-C -interpretation of \ex. -Otherwise, a literal 'X' (used to escape -operators such as '*'). -.It Li \&\e123 -The character with octal value 123. -.It Li \&\ex2a -The character with hexadecimal value 2a. -.It Li (r) -Match an r; parentheses are used to override -precedence (see below). -.It Li rs -The regular expression r followed by the -regular expression s; called "concatenation". -.It Li rs -Either an r or an s. -.It Li r/s -An r but only if it is followed by an s. The -s is not part of the matched text. This type -of pattern is called as "trailing context". -.It Li \&^r -An r, but only at the beginning of a line. -.It Li r$ -An r, but only at the end of a line. Equivalent -to "r/\en". -.It Li <s>r -An r, but only in start condition s (see -below for discussion of start conditions). -.It Li <s1,s2,s3>r -Same, but in any of start conditions s1, -s2, or s3. -.It Li <<EOF>> -An end-of-file. -.It Li <s1,s2><<EOF>> -An end-of-file when in start condition s1 or s2. -.El -The regular expressions listed above are grouped according to -precedence, from highest precedence at the top to lowest at the bottom. -Those grouped together have equal precedence. -.Pp -Some notes on patterns: -.Pp -Negated character classes -.Ar match newlines -unless "\en" (or an equivalent escape sequence) is one of the -characters explicitly present in the negated character class -(e.g., " [^A-Z\en] "). -.Pp -A rule can have at most one instance of trailing context (the '/' operator -or the '$' operator). The start condition, '^', and "<<EOF>>" patterns -can only occur at the beginning of a pattern, and, as well as with '/' and '$', -cannot be grouped inside parentheses. The following are all illegal: -.Pp -.Bd -literal -offset indent -foo/bar$ -foo(bar$) -foo^bar -<sc1>foo<sc2>bar -.Ed -.Sh SUMMARY OF SPECIAL ACTIONS -In addition to arbitrary C code, the following can appear in actions: -.Bl -tag -width Fl -.It Ic ECHO -Copies -.Va yytext -to the scanner's output. -.It Ic BEGIN -Followed by the name of a start condition places the scanner in the -corresponding start condition. -.It Ic REJECT -Directs the scanner to proceed on to the "second best" rule which matched the -input (or a prefix of the input). -.Va yytext -and -.Va yyleng -are set up appropriately. Note that -.Ic REJECT -is a particularly expensive feature in terms scanner performance; -if it is used in -.Em any -of the scanner's actions it will slow down -.Em all -of the scanner's matching. Furthermore, -.Ic REJECT -cannot be used with the -.Fl f -or -.Fl F -options. -.Pp -Note also that unlike the other special actions, -.Ic REJECT -is a -.Em branch ; -code immediately following it in the action will -.Em not -be executed. -.It Fn yymore -tells the scanner that the next time it matches a rule, the corresponding -token should be -.Em appended -onto the current value of -.Va yytext -rather than replacing it. -.It Fn yyless \&n -returns all but the first -.Ar n -characters of the current token back to the input stream, where they -will be rescanned when the scanner looks for the next match. -.Va yytext -and -.Va yyleng -are adjusted appropriately (e.g., -.Va yyleng -will now be equal to -.Ar n ) . -.It Fn unput c -puts the character -.Ar c -back onto the input stream. It will be the next character scanned. -.It Fn input -reads the next character from the input stream (this routine is called -.Fn yyinput -if the scanner is compiled using -.Em C \&+\&+ ) . -.It Fn yyterminate -can be used in lieu of a return statement in an action. It terminates -the scanner and returns a 0 to the scanner's caller, indicating "all done". -.Pp -By default, -.Fn yyterminate -is also called when an end-of-file is encountered. It is a macro and -may be redefined. -.It Ic YY_NEW_FILE -is an action available only in <<EOF>> rules. It means "Okay, I've -set up a new input file, continue scanning". -.It Fn yy_create_buffer file size -takes a -.Ic FILE -pointer and an integer -.Ar size . -It returns a YY_BUFFER_STATE -handle to a new input buffer large enough to accomodate -.Ar size -characters and associated with the given file. When in doubt, use -.Ar YY_BUF_SIZE -for the size. -.It Fn yy_switch_to_buffer new_buffer -switches the scanner's processing to scan for tokens from -the given buffer, which must be a YY_BUFFER_STATE. -.It Fn yy_delete_buffer buffer -deletes the given buffer. -.El -.Sh VALUES AVAILABLE TO THE USER -.Bl -tag -width Fl -.It Va char \&*yytext -holds the text of the current token. It may not be modified. -.It Va int yyleng -holds the length of the current token. It may not be modified. -.It Va FILE \&*yyin -is the file which by default -.Nm lex -reads from. It may be redefined but doing so only makes sense before -scanning begins. Changing it in the middle of scanning will have -unexpected results since -.Nm lex -buffers its input. Once scanning terminates because an end-of-file -has been seen, -.Fn "void yyrestart" "FILE *new_file" -may be called to point -.Va yyin -at the new input file. -.It Va FILE \&*yyout -is the file to which -.Ar ECHO -actions are done. It can be reassigned by the user. -.It Va YY_CURRENT_BUFFER -returns a -YY_BUFFER_STATE -handle to the current buffer. -.El -.Sh MACROS THE USER CAN REDEFINE -.Bl -tag -width Fl -.It Va YY_DECL -controls how the scanning routine is declared. -By default, it is "int yylex()", or, if prototypes are being -used, "int yylex(void)". This definition may be changed by redefining -the "YY_DECL" macro. Note that -if you give arguments to the scanning routine using a -K&R-style/non-prototyped function declaration, you must terminate -the definition with a semi-colon (;). -.It Va YY_INPUT -The nature of how the scanner -gets its input can be controlled by redefining the -YY_INPUT -macro. -YY_INPUT's calling sequence is "YY_INPUT(buf,result,max_size)". Its -action is to place up to -.Ar max _size -characters in the character array -.Ar buf -and return in the integer variable -.Ar result -either the -number of characters read or the constant YY_NULL (0 on Unix systems) -to indicate EOF. The default YY_INPUT reads from the -global file-pointer "yyin". -A sample redefinition of YY_INPUT (in the definitions -section of the input file): -.Bd -literal -offset indent -%{ -#undef YY_INPUT -#define YY_INPUT(buf,result,max_size) \e - result = ((buf[0] = getchar()) == EOF) ? YY_NULL : 1; -%} -.Ed -.It Va YY_INPUT -When the scanner receives an end-of-file indication from YY_INPUT, -it then checks the -.Fn yywrap -function. If -.Fn yywrap -returns false (zero), then it is assumed that the -function has gone ahead and set up -.Va yyin -to point to another input file, and scanning continues. If it returns -true (non-zero), then the scanner terminates, returning 0 to its -caller. -.It Va yywrap -The default -.Fn yywrap -always returns 1. Presently, to redefine it you must first -"#undef yywrap", as it is currently implemented as a macro. It is -likely that -.Fn yywrap -will soon be defined to be a function rather than a macro. -.It Va YY_USER_ACTION -can be redefined to provide an action -which is always executed prior to the matched rule's action. -.It Va YY_USER_INIT -The macro -.Va YY _USER_INIT -may be redefined to provide an action which is always executed before -the first scan. -.It Va YY_BREAK -In the generated scanner, the actions are all gathered in one large -switch statement and separated using -.Va YY _BREAK , -which may be redefined. By default, it is simply a "break", to separate -each rule's action from the following rule's. -.El -.Sh FILES -.Bl -tag -width lex.backtrack -compact -.It Pa lex.skel -skeleton scanner. -.It Pa lex.yy.c -generated scanner -(called -.Pa lexyy.c -on some systems). -.It Pa lex.backtrack -backtracking information for -.Fl b -.It Pa flag -(called -.Pa lex.bck -on some systems). -.El -.Sh SEE ALSO -.Xr lex 1 , -.Xr yacc 1 , -.Xr sed 1 , -.Xr awk 1 . -.Rs -.%T "lexdoc" -.Re -.Rs -.%A M. E. Lesk -.%A E. Schmidt -.%T "LEX \- Lexical Analyzer Generator" -.Re -.Sh DIAGNOSTICS -.Bl -tag -width Fl -.It Li reject_used_but_not_detected undefined -or -.It Li yymore_used_but_not_detected undefined -These errors can occur at compile time. -They indicate that the -scanner uses -.Ic REJECT -or -.Fn yymore -but that -.Nm lex -failed to notice the fact, -meaning that -.Nm lex -scanned the first two sections looking for occurrences of these actions -and failed to find any, -but somehow you snuck some in via a #include -file, -for example . -Make an explicit reference to the action in your -.Nm lex -input file. -Note that previously -.Nm lex -supported a -.Li %used/%unused -mechanism for dealing with this problem; -this feature is still supported -but now deprecated, -and will go away soon unless the author hears from -people who can argue compellingly that they need it. -.It Li lex scanner jammed -a scanner compiled with -.Fl s -has encountered an input string which wasn't matched by -any of its rules. -.It Li lex input buffer overflowed -a scanner rule matched a string long enough to overflow the -scanner's internal input buffer 16K bytes - controlled by -.Va YY_BUF_MAX -in -.Pa lex.skel . -.It Li scanner requires \&\-8 flag -Your scanner specification includes recognizing 8-bit characters and -you did not specify the -8 flag and your site has not installed lex -with -8 as the default . -.It Li too many \&%t classes! -You managed to put every single character into its own %t class. -.Nm Lex -requires that at least one of the classes share characters. -.El -.Sh HISTORY -A -.Nm lex -appeared in -.At v6 . -The version this man page describes is -derived from code contributed by Vern Paxson. -.Sh AUTHOR -Vern Paxson, with the help of many ideas and much inspiration from -Van Jacobson. Original version by Jef Poskanzer. -.Pp -See -.%T "Lexdoc" -for additional credits and the address to send comments to. -.Sh BUGS -.Pp -Some trailing context -patterns cannot be properly matched and generate -warning messages ("Dangerous trailing context"). These are -patterns where the ending of the -first part of the rule matches the beginning of the second -part, such as "zx*/xy*", where the 'x*' matches the 'x' at -the beginning of the trailing context. (Note that the -.Tn POSIX -draft -states that the text matched by such patterns is undefined.) -.Pp -For some trailing context rules, parts which are actually fixed-length are -not recognized as such, leading to the abovementioned performance loss. -In particular, parts using '\&|' or {n} (such as "foo{3}") are always -considered variable-length. -.Pp -Combining trailing context with the special '\&|' action can result in -.Em fixed -trailing context being turned into the more expensive -.Em variable -trailing context. This happens in the following example: -.Bd -literal -offset indent -%% -abc \&| -xyz/def -.Ed -.Pp -Use of -.Fn unput -invalidates yytext and yyleng. -.Pp -Use of -.Fn unput -to push back more text than was matched can -result in the pushed-back text matching a beginning-of-line ('^') -rule even though it didn't come at the beginning of the line -(though this is rare!). -.Pp -Pattern-matching of -.Tn NUL Ns 's -is substantially slower than matching other -characters. -.Pp -.Nm Lex -does not generate correct #line directives for code internal -to the scanner; thus, bugs in -.Pa lex.skel -yield bogus line numbers. -.Pp -Due to both buffering of input and read-ahead, you cannot intermix -calls to -.Aq Pa stdio.h -routines, such as, for example, -.Fn getchar , -with -.Nm lex -rules and expect it to work. Call -.Fn input -instead. -.Pp -The total table entries listed by the -.Fl v -flag excludes the number of table entries needed to determine -what rule has been matched. The number of entries is equal -to the number of -.Tn DFA -states if the scanner does not use -.Ic REJECT , -and somewhat greater than the number of states if it does. -.Pp -.Ic REJECT -cannot be used with the -.Fl f -or -.Fl F -options. -.Pp -Some of the macros, such as -.Fn yywrap , -may in the future become functions which live in the -.Fl lfl -library. This will doubtless break a lot of code, but may be -required for -.Tn POSIX Ns \-compliance . -.Pp -The -.Nm lex -internal algorithms need documentation. diff --git a/usr.bin/lex/lex.skel b/usr.bin/lex/lex.skel deleted file mode 100644 index c6d64ed97a19..000000000000 --- a/usr.bin/lex/lex.skel +++ /dev/null @@ -1,836 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* scanner skeleton version: - * $Header: /cvsroot/src/usr.bin/lex/Attic/lex.skel,v 1.3 1993/11/19 05:11:46 cgd Exp $ - */ - -#define FLEX_SCANNER - -#include <stdio.h> - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include <stdlib.h> -#include <osfcn.h> - -/* use prototypes in function declarations */ -#define YY_USE_PROTOS - -/* the "const" storage-class-modifier is valid */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#ifdef __STDC__ - -#ifdef __GNUC__ -#include <stddef.h> -void *malloc( size_t ); -void free( void* ); -#else -#include <stdlib.h> -#endif /* __GNUC__ */ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - - -#ifdef __TURBOC__ -#define YY_USE_CONST -#endif - - -#ifndef YY_USE_CONST -#define const -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -/* we can't get here if it's an ANSI C compiler, or a C++ compiler, - * so it's got to be a K&R compiler, and therefore there's no standard - * place from which to include these definitions - */ -char *malloc(); -int free(); -#endif - - -/* amount of stuff to slurp up with each read */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* returned upon end-of-file */ -#define YY_END_TOK 0 - -/* copy whatever the last rule matched to the standard output */ - -/* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */ -/* this used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite() - */ -#define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout ) - -/* gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#define YY_INPUT(buf,result,max_size) \ - if ( ((result = fread( (char *) buf, 1, max_size, yyin )) == 0 ) && \ - ferror(yyin) ) \ - YY_FATAL_ERROR( "fread() in flex scanner failed" ); -#define YY_NULL 0 - -/* no semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#define yyterminate() return ( YY_NULL ) - -/* report a fatal error */ - -/* The funky do-while is used to turn this macro definition into - * a single C statement (which needs a semi-colon terminator). - * This avoids problems with code like: - * - * if ( something_happens ) - * YY_FATAL_ERROR( "oops, the something happened" ); - * else - * everything_okay(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the YY_FATAL_ERROR() call. - */ - -#define YY_FATAL_ERROR(msg) \ - do \ - { \ - (void) fputs( msg, stderr ); \ - (void) putc( '\n', stderr ); \ - exit( 1 ); \ - } \ - while ( 0 ) - -/* default yywrap function - always treat EOF as an EOF */ -#define yywrap() 1 - -/* enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN - */ -#define BEGIN yy_start = 1 + 2 * - -/* action number for EOF rule of a given start state */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* special action meaning "start processing a new file" */ -#define YY_NEW_FILE \ - do \ - { \ - yy_init_buffer( yy_current_buffer, yyin ); \ - yy_load_buffer_state(); \ - } \ - while ( 0 ) - -/* default declaration of generated scanner - a define so the user can - * easily add parameters - */ -#define YY_DECL int yylex YY_PROTO(( void )) - -/* code executed at the end of each rule */ -#define YY_BREAK break; - -#define YY_END_OF_BUFFER_CHAR 0 - -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */ -#endif - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -%% section 1 definitions go here - -/* done after the current pattern has been matched and before the - * corresponding action - sets up yytext - */ -#define YY_DO_BEFORE_ACTION \ - yytext = yy_bp; \ -%% code to fiddle yytext and yyleng for yymore() goes here - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* return all but the first 'n' matched characters back to the input stream */ -#define yyless(n) \ - do \ - { \ - /* undo effects of setting up yytext */ \ - *yy_cp = yy_hold_char; \ - yy_c_buf_p = yy_cp = yy_bp + n; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext ) - - -struct yy_buffer_state - { - FILE *yy_input_file; - - YY_CHAR *yy_ch_buf; /* input buffer */ - YY_CHAR *yy_buf_pos; /* current position in input buffer */ - - /* size of input buffer in bytes, not including room for EOB characters */ - int yy_buf_size; - - /* number of characters read into yy_ch_buf, not including EOB characters */ - int yy_n_chars; - - int yy_eof_status; /* whether we've seen an EOF on this buffer */ -#define EOF_NOT_SEEN 0 - /* "pending" happens when the EOF has been seen but there's still - * some text process - */ -#define EOF_PENDING 1 -#define EOF_DONE 2 - }; - -static YY_BUFFER_STATE yy_current_buffer; - -/* we provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state" - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - -/* yy_hold_char holds the character lost when yytext is formed */ -static YY_CHAR yy_hold_char; - -static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - - -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -#ifndef YY_USER_INIT -#define YY_USER_INIT -#endif - -extern YY_CHAR *yytext; -extern int yyleng; -extern FILE *yyin, *yyout; - -YY_CHAR *yytext; -int yyleng; - -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; - -%% data tables for the DFA go here - -/* these variables are all declared out here so that section 3 code can - * manipulate them - */ -/* points to current character in buffer */ -static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0; -static int yy_init = 1; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr )); -void yyrestart YY_PROTO(( FILE *input_file )); -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); - -#define yy_new_buffer yy_create_buffer - -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif - -YY_DECL - { - register yy_state_type yy_current_state; - register YY_CHAR *yy_cp, *yy_bp; - register int yy_act; - -%% user's declarations go here - - if ( yy_init ) - { - YY_USER_INIT; - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = stdin; - - if ( ! yyout ) - yyout = stdout; - - if ( yy_current_buffer ) - yy_init_buffer( yy_current_buffer, yyin ); - else - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - - yy_init = 0; - } - - while ( 1 ) /* loops until end-of-file is reached */ - { -%% yymore()-related code goes here - yy_cp = yy_c_buf_p; - - /* support of yytext */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of the - * current run. - */ - yy_bp = yy_cp; - -%% code to set up and find next match goes here - -yy_find_action: -%% code to find the action number goes here - - YY_DO_BEFORE_ACTION; - YY_USER_ACTION; - -do_action: /* this label is used only to access EOF actions */ - -%% debug code goes here - - switch ( yy_act ) - { -%% actions go here - - case YY_END_OF_BUFFER: - { - /* amount of text matched not including the EOB char */ - int yy_amount_of_matched_text = yy_cp - yytext - 1; - - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - - /* note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the end- - * of-buffer state). Contrast this with the test in yyinput(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* this was really a NUL */ - { - yy_state_type yy_next_state; - - yy_c_buf_p = yytext + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* okay, we're now positioned to make the - * NUL transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we - * don't want to build jamming into it because - * then it will run more slowly) - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* consume the NUL */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { -%% code to do backtracking for compressed tables and set up yy_cp goes here - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* note: because we've taken care in - * yy_get_next_buffer() to have set up yytext, - * we can now set up yy_c_buf_p so that if some - * total hoser (like flex itself) wants - * to call the scanner after we return the - * YY_NULL, it'll still work - another YY_NULL - * will get returned. - */ - yy_c_buf_p = yytext + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF((yy_start - 1) / 2); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - } - break; - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: -#ifdef FLEX_DEBUG - printf( "action # %d\n", yy_act ); -#endif - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } - } - } - - -/* yy_get_next_buffer - try to read in a new buffer - * - * synopsis - * int yy_get_next_buffer(); - * - * returns a code representing an action - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -static int yy_get_next_buffer() - - { - register YY_CHAR *dest = yy_current_buffer->yy_ch_buf; - register YY_CHAR *source = yytext - 1; /* copy prev. char, too */ - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - /* try to read more data */ - - /* first move last chars to start of buffer */ - number_to_move = yy_c_buf_p - yytext; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_n_chars = 0; - - else - { - int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - else if ( num_to_read <= 0 ) - YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - - /* read in more data */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move - YY_MORE_ADJ == 1 ) - { - ret_val = EOB_ACT_END_OF_FILE; - yy_current_buffer->yy_eof_status = EOF_DONE; - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_eof_status = EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - /* yytext begins at the second character in yy_ch_buf; the first - * character is the one which preceded it before reading in the latest - * buffer; it needs to be kept around in case it's a newline, so - * yy_get_previous_state() will have with '^' rules active - */ - - yytext = &yy_current_buffer->yy_ch_buf[1]; - - return ( ret_val ); - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached - * - * synopsis - * yy_state_type yy_get_previous_state(); - */ - -static yy_state_type yy_get_previous_state() - - { - register yy_state_type yy_current_state; - register YY_CHAR *yy_cp; - -%% code to get the start state into yy_current_state goes here - - for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { -%% code to find the next state goes here - } - - return ( yy_current_state ); - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -register yy_state_type yy_current_state; -#endif - - { - register int yy_is_jam; -%% code to find the next state, and perhaps do backtracking, goes here - - return ( yy_is_jam ? 0 : yy_current_state ); - } - - -#ifdef YY_USE_PROTOS -static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp ) -#else -static void yyunput( c, yy_bp ) -YY_CHAR c; -register YY_CHAR *yy_bp; -#endif - - { - register YY_CHAR *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */ - register YY_CHAR *dest = - &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2]; - register YY_CHAR *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += dest - source; - yy_bp += dest - source; - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - if ( yy_cp > yy_bp && yy_cp[-1] == '\n' ) - yy_cp[-2] = '\n'; - - *--yy_cp = c; - - /* note: the formal parameter *must* be called "yy_bp" for this - * macro to now work correctly - */ - YY_DO_BEFORE_ACTION; /* set up yytext again */ - } - - -#ifdef __cplusplus -static int yyinput() -#else -static int input() -#endif - - { - int c; - YY_CHAR *yy_cp = yy_c_buf_p; - - *yy_cp = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* this was really a NUL */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - yytext = yy_c_buf_p; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - { - yy_c_buf_p = yytext + YY_MORE_ADJ; - return ( EOF ); - } - - YY_NEW_FILE; - -#ifdef __cplusplus - return ( yyinput() ); -#else - return ( input() ); -#endif - } - break; - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext + YY_MORE_ADJ; - break; - - case EOB_ACT_LAST_MATCH: -#ifdef __cplusplus - YY_FATAL_ERROR( "unexpected last match in yyinput()" ); -#else - YY_FATAL_ERROR( "unexpected last match in input()" ); -#endif - } - } - } - - c = *yy_c_buf_p; - yy_hold_char = *++yy_c_buf_p; - - return ( c ); - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - - { - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* flush out information for old buffer */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* we don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) ); - - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) ); - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - yy_init_buffer( b, file ); - - return ( b ); - } - - -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - - { - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - free( (char *) b->yy_ch_buf ); - free( (char *) b ); - } - - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif - - { - b->yy_input_file = file; - - /* we put in the '\n' and start reading from [1] so that an - * initial match-at-newline will be true. - */ - - b->yy_ch_buf[0] = '\n'; - b->yy_n_chars = 1; - - /* we always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[1]; - - b->yy_eof_status = EOF_NOT_SEEN; - } diff --git a/usr.bin/lex/lib/ln.order b/usr.bin/lex/lib/ln.order deleted file mode 100644 index 484a5a989871..000000000000 --- a/usr.bin/lex/lib/ln.order +++ /dev/null @@ -1 +0,0 @@ -libmain.o diff --git a/usr.bin/lex/lib/shlib_version b/usr.bin/lex/lib/shlib_version deleted file mode 100644 index 97c9f92d6b8f..000000000000 --- a/usr.bin/lex/lib/shlib_version +++ /dev/null @@ -1,2 +0,0 @@ -major=0 -minor=0 diff --git a/usr.bin/rcs/man/Makefile b/usr.bin/rcs/man/Makefile deleted file mode 100644 index 59294b403e7c..000000000000 --- a/usr.bin/rcs/man/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (c) 1987 Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms are permitted -# provided that the above copyright notice and this paragraph are -# duplicated in all such forms and that any documentation, -# advertising materials, and other materials related to such -# distribution and use acknowledge that the software was developed -# by the University of California, Berkeley. The name of the -# University may not be used to endorse or promote products derived -# from this software without specific prior written permission. -# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -# -# @(#)Makefile 5.7 (Berkeley) 2/27/89 -# - -MAN1= ci.0 co.0 ident.0 merge.0 rcs.0 rcsclean.0 rcsdiff.0 \ - rcsfreeze.0 rcsintro.0 rcsmerge.0 rlog.0 sccstorcs.0 -MAN5= rcsfile.0 - -.if !defined(NOMAN) -install: ${MAN1} ${MAN5} - install -c -o bin -g bin -m 444 ${MAN1} ${DESTDIR}/usr/share/man/cat1 - install -c -o bin -g bin -m 444 ${MAN5} ${DESTDIR}/usr/share/man/cat5 -.else -install: -.endif - -.include <bsd.prog.mk> diff --git a/usr.bin/rcs/man/ci.1 b/usr.bin/rcs/man/ci.1 deleted file mode 100644 index 6d992f9a1121..000000000000 --- a/usr.bin/rcs/man/ci.1 +++ /dev/null @@ -1,231 +0,0 @@ -.TH CI 1L "" "Purdue University" -.SH NAME -ci \- check in RCS revisions -.SH SYNOPSIS -.B ci -[ options ] -file ... -.SH DESCRIPTION -.I Ci -stores new revisions into RCS files. -Each file name ending in `,v' is taken to be an RCS file, all others -are assumed to be working files containing new revisions. -\fICi\fR deposits the contents of each working file -into the corresponding RCS file. -If only a working file is given, \fIci\fR tries to find the corresponding -RCS file in the directory ./RCS and then in the current directory. -For more details, see the file naming section below. -.PP -For \fIci\fR to work, the caller's login must be on the access list, -except if the access list is empty or the caller is the superuser or the -owner of the file. -To append a new revision to an existing branch, the tip revision on -that branch must be locked by the caller. Otherwise, only a -new branch can be created. This restriction is not enforced -for the owner of the file, unless locking is set to \fIstrict\fR -(see -.IR rcs (1L)). -A lock held by someone else may be broken with the \fIrcs\fR command. -.PP -Normally, \fIci\fR checks whether the revision to be deposited is different -from the preceding one. If it is not different, \fIci\fR -either aborts the deposit (if -.B \-q -is given) or asks whether to abort -(if -.B \-q -is omitted). A deposit can be forced with the -.B \-f -option. -.PP -For each revision deposited, -.I ci -prompts for a log message. -The log message should summarize the change and must be terminated with -a line containing a single `.' or a control-D. -If several files are checked in, \fIci\fR asks whether to reuse the -previous log message. -If the standard input is not a terminal, \fIci\fR suppresses the prompt -and uses the same log message for all files. -See also \fB\-m\fR. -.PP -The number of the deposited revision can be given by any of the options -\fB\-r\fR, \fB\-f\fR, \fB\-k\fR, \fB\-l\fR, \fB\-u\fR, or \fB\-q\fR. -.PP -If the RCS file does not exist, \fIci\fR creates it and -deposits the contents of the working file as the initial revision -(default number: 1.1). -The access list is initialized to empty. -Instead of the log message, \fIci\fR requests descriptive text (see -\fB\-t\fR below). -.TP 10 -.BR \-r [\fIrev\fR] -assigns the revision number \fIrev\fR -to the checked-in revision, releases the corresponding lock, and -deletes the working file. This is the default. -\fIRev\fR may be symbolic, numeric, or mixed. - -If \fIrev\fR is a revision number, it must be higher than the latest -one on the branch to which \fIrev\fR belongs, or must start a new branch. - -If \fIrev\fR is a branch rather than a revision number, -the new revision is appended to that branch. The level number is obtained -by incrementing the tip revision number of that branch. -If \fIrev\fR indicates a non-existing branch, -that branch is created with the initial revision numbered -.IR rev .1. - -.ne 8 -If \fIrev\fR is omitted, \fIci\fR tries to derive the new revision number from -the caller's last lock. If the caller has locked the tip revision of a branch, -the new revision is appended to that branch. The new revision number is obtained -by incrementing the tip revision number. -If the caller locked a non-tip revision, a new branch is started at -that revision by incrementing the highest branch number at that revision. -The default initial branch and level numbers are 1. - -If \fIrev\fR is omitted and the caller has no lock, but he is the owner -of the file and locking -is not set to \fIstrict\fR, then the revision is appended to the -default branch (normally the trunk; see the -.B \-b -option of -.IR rcs (1L)). - -Exception: On the trunk, revisions can be appended to the end, but -not inserted. -.TP 10 -.BR \-f [\fIrev\fR] -forces a deposit; the new revision is deposited even it is not different -from the preceding one. -.TP 10 -.BR \-k [\fIrev\fR] -searches the working file for keyword values to determine its revision number, -creation date, state, and author (see \fIco\fR(1)), and assigns these -values to the deposited revision, rather than computing them locally. -It also generates a default login message noting the login of the caller -and the actual checkin date. -This option is useful for software distribution. A revision that is sent to -several sites should be checked in with the \fB\-k\fR option at these sites to -preserve the original number, date, author, and state. -The extracted keyword values and the default log message may be overridden -with the options \fB\-r\fR, \fB\-d\fR, \fB\-s\fR, \fB\-w\fR, and \fB\-m\fR. -.TP 10 -.BR \-l [\fIrev\fR] -works like \fB\-r\fR, except it performs an additional \fIco \fB\-l\fR for the -deposited revision. Thus, the deposited revision is immediately -checked out again and locked. -This is useful for saving a revision although one wants to continue -editing it after the checkin. -.TP 10 -.BR \-u [\fIrev\fR] -works like \fB\-l\fR, except that the deposited revision is not locked. -This is useful if one wants to process (e.g., compile) the revision -immediately after checkin. -.TP 10 -.BR \-q [\fIrev\fR] -quiet mode; diagnostic output is not printed. -A revision that is not different from the preceding one is not deposited, -unless \fB\-f\fR is given. -.TP 10 -.BI \-d "date" -uses \fIdate\fR for the checkin date and time. -\fIDate\fR may be specified in free format as explained in \fIco\fR(1). -Useful for lying about the checkin date, and for -.B \-k -if no date is available. -.TP 10 -.BI \-m "msg" -uses the string \fImsg\fR as the log message for all revisions checked in. -.TP 10 -.BI \-n "name" -assigns the symbolic name \fIname\fR to the number of the checked-in revision. -\fICi\fR prints an error message if \fIname\fR is already assigned to another -number. -.TP 10 -.BI \-N "name" -same as \fB\-n\fR, except that it overrides a previous assignment of \fIname\fR. -.TP -.BI \-s "state" -sets the state of the checked-in revision to the identifier \fIstate\fR. -The default is \fIExp\fR. -.TP -.BR \-t [\fItxtfile\fR] -writes descriptive text into the RCS file (deletes the existing text). -If \fItxtfile\fR is omitted, -\fIci\fR prompts the user for text supplied from the standard input, -terminated with a line containing a single `.' or control-D. -Otherwise, the descriptive text is copied from the file \fItxtfile\fR. -During initialization, descriptive text is requested -even if \fB\-t\fR is not given. -The prompt is suppressed if standard input is not a terminal. -.TP -.BI \-w "login" -uses \fIlogin\fR for the author field of the deposited revision. -Useful for lying about the author, and for -.B \-k -if no author is available. -.SH "FILE NAMING" -Pairs of RCS files and working files may be specified in 3 ways (see also the -example section of \fIco\fR(1)). -.PP -1) Both the RCS file and the working file are given. The RCS file name is of -the form \fIpath1/workfile,v\fR -and the working file name is of the form -\fIpath2/workfile\fR, where -\fIpath1/\fR and -\fIpath2/\fR are (possibly different or empty) paths and -\fIworkfile\fR is a file name. -.PP -2) Only the RCS file is given. -Then the working file is assumed to be in the current -directory and its name is derived from the name of the RCS file -by removing \fIpath1/\fR and the suffix \fI,v\fR. -.PP -3) Only the working file is given. -Then \fIci\fR looks for an RCS file of the form -\fIpath2/RCS/workfile,v\fR or \fIpath2/workfile,v\fR (in this order). -.PP -If the RCS file is specified without a path in 1) and 2), then \fIci\fR -looks for the RCS file first in the directory ./RCS and then in the current -directory. -.SH "FILE MODES" -An RCS file created by \fIci\fR inherits the read and execute permissions -from the working file. If the RCS file exists already, \fIci\fR -preserves its read and execute permissions. -\fICi\fR always turns off all write permissions of RCS files. -.SH FILES -The caller of the command -must have read/write permission for the directories containing -the RCS file and the working file, and read permission for the RCS file itself. -A number of temporary files are created. -A semaphore file is created in the directory containing the RCS file. -\fICi\fR always creates a new RCS file and unlinks the old one. -This strategy makes links to RCS files useless. -.SH DIAGNOSTICS -For each revision, -\fIci\fR prints the RCS file, the working file, and the number -of both the deposited and the preceding revision. -The exit status always refers to the last file checked in, -and is 0 if the operation was successful, 1 otherwise. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.sp 0 -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -co(1L), ident(1L), rcs(1L), rcsdiff(1L), rcsintro(1L), rcsmerge(1L), rlog(1L), -rcsfile(5L) -.sp 0 -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. diff --git a/usr.bin/rcs/man/co.1 b/usr.bin/rcs/man/co.1 deleted file mode 100644 index 00c66a5bcaef..000000000000 --- a/usr.bin/rcs/man/co.1 +++ /dev/null @@ -1,305 +0,0 @@ -.TH CO 1L "" "Purdue University" -.SH NAME -co \- check out RCS revisions -.SH SYNOPSIS -.B co -[ options ] -file ... -.SH DESCRIPTION -.I Co -retrieves a revision from each RCS file and stores it into -the corresponding working file. -Each file name ending in `,v' is taken to be an RCS file; -all other files are assumed to be working files. -If only a working file is given, \fIco\fR tries to find the corresponding -RCS file in the directory ./RCS and then in the current directory. -For more details, see the file naming section below. -.PP -Revisions of an RCS file may be checked out locked or unlocked. Locking a -revision prevents overlapping updates. A revision checked out for reading or -processing (e.g., compiling) need not be locked. A revision checked out -for editing and later checkin must normally be locked. \fICo\fR with locking -fails if the revision to be checked out is currently locked by another user. -(A lock may be broken with the -.IR rcs (1L) -command.) -\fICo\fR with locking also requires the caller to be on the access list of -the RCS file, unless he is the owner of the -file or the superuser, or the access list is empty. -\fICo\fR without locking is not subject to accesslist restrictions, and is -not affected by the presence of locks. -.PP -A revision is selected by options for revision or branch number, -checkin date/time, author, or state. -When the selection options -are applied in combination, \fIco\fR retrieves the latest revision -that satisfies all of them. -If none of the selection options -is specified, \fIco\fR retrieves the latest revision -on the default branch (normally the trunk, see the -.B \-b -option of -.IR rcs (1L)). -A revision or branch number may be attached -to any of the options -\fB\-f\fR, \fB\-l\fR, \fB\-p\fR, \fB\-q\fR, \fB\-r\fR, or \fB\-u\fR. -The options \fB\-d\fR (date), \fB\-s\fR (state), and \fB\-w\fR (author) -retrieve from a single branch, the \fIselected\fR branch, -which is either specified by one of -\fB\-f\fR,..., \fB\-u\fR, or the default branch. -.PP -A \fIco\fR command applied to an RCS -file with no revisions creates a zero-length working file. -\fICo\fR always performs keyword substitution (see below). -.PP -.TP 11 -.BR \-r [\fIrev\fR] -retrieves the latest revision whose number is less than or equal to \fIrev\fR. -If \fIrev\fR indicates a branch rather than a revision, -the latest revision on that branch is retrieved. -If \fIrev\fR is omitted, the latest revision on the default branch -(see the -.B \-b -option of -.IR rcs (1L)) -is retrieved. -\fIRev\fR is composed of one or more numeric or symbolic fields -separated by `.'. The numeric equivalent of a symbolic field -is specified with the \fB\-n\fR option of the commands -.IR ci (1L) -and -.IR rcs (1L). -.TP 11 -.BR \-l [\fIrev\fR] -same as \fB\-r\fR, except that it also locks the retrieved revision for -the caller. See option \fB\-r\fR for handling of the revision number -.I rev . -.TP 11 -.BR \-u [\fIrev\fR] -same as \fB\-r\fR, except that it unlocks the retrieved revision (if it was -locked by the caller). If \fIrev\fR is omitted, \fB\-u\fR -retrieves the latest revision locked by the caller; if no such lock exists, -it retrieves the latest revision on the default branch. -.TP 11 -.BR \-f [\fIrev\fR] -forces the overwriting of the working file; -useful in connection with \fB\-q\fR. -See also the section on file modes below. -.TP 11 -.BR \-p [\fIrev\fR] -prints the retrieved revision on the standard output rather than storing it -in the working file. -This option is useful when \fIco\fR -is part of a pipe. -.TP 11 -.BR \-q [\fIrev\fR] -quiet mode; diagnostics are not printed. -.TP 11 -.BI \-d "date" -retrieves the latest revision on the selected branch whose checkin date/time is less than or equal to \fIdate\fR. -The date and time may be given in free format and are converted to local time. -Examples of formats for \fIdate\fR: -.ne 5 -.nf - -\fI22-April-1982, 17:20-CDT, -2:25 AM, Dec. 29, 1983, -Tue-PDT, 1981, 4pm Jul 21\fR \fR(free format), -\fIFri, April 16 15:52:25 EST 1982 \fR(output of ctime). -.fi - -Most fields in the date and time may be defaulted. -\fICo\fR determines the defaults in the order year, month, day, -hour, minute, and second (most to least significant). At least one of these -fields must be provided. For omitted fields that are of higher significance -than the highest provided field, -the current values are assumed. For all other omitted fields, -the lowest possible values are assumed. -For example, the date "20, 10:30" defaults to -10:30:00 of the 20th of the current month and current year. -The date/time must be quoted if it contains spaces. -.TP 11 -.BI \-s "state" -retrieves the latest revision on the selected branch whose state is set to \fIstate\fR. -.TP 11 -.BR \-w [\fIlogin\fR] -retrieves the latest revision on the selected branch which was checked in -by the user with login name \fIlogin\fR. If the argument \fIlogin\fR is -omitted, the caller's login is assumed. -.TP 11 -.BI \-j joinlist -generates a new revision which is the join of the revisions on \fIjoinlist\fR. -\fIJoinlist\fR is a comma-separated list of pairs of the form -\fIrev2:rev3\fR, where \fIrev2\fR and \fIrev3\fR are (symbolic or numeric) -revision numbers. -For the initial such pair, \fIrev1\fR denotes the revision selected -by the above options \fB\-r\fR, ..., \fB\-w\fR. For all other pairs, \fIrev1\fR -denotes the revision generated by the previous pair. (Thus, the output -of one join becomes the input to the next.) - -For each pair, \fIco\fR joins revisions \fIrev1\fR and \fIrev3\fR -with respect to \fIrev2\fR. -This means that all changes that transform -\fIrev2\fR into \fIrev1\fR are applied to a copy of \fIrev3\fR. -This is particularly useful if \fIrev1\fR -and \fIrev3\fR are the ends of two branches that have \fIrev2\fR as a common -ancestor. If \fIrev1\fR < \fIrev2\fR < \fIrev3\fR on the same branch, -joining generates a new revision which is like \fIrev3\fR, but with all -changes that lead from \fIrev1\fR to \fIrev2\fR undone. -If changes from \fIrev2\fR to \fIrev1\fR overlap with changes from -\fIrev2\fR to \fIrev3\fR, \fIco\fR prints a warning and includes the -overlapping sections, delimited by the lines \fI<<<<<<<\ rev1, -=======\fR, and \fI>>>>>>>\ rev3\fR. - -For the initial pair, \fIrev2\fR may be omitted. The default is the common -ancestor. -If any of the arguments indicate branches, the latest revisions -on those branches are assumed. -The options \fB\-l\fR and \fB\-u\fR lock or unlock \fIrev1\fR. -.SH "KEYWORD SUBSTITUTION" -Strings of the form \fI$keyword$\fR and \fI$keyword:...$\fR embedded in -the text are replaced -with strings of the form \fI$keyword:\ value\ $\fR, -where \fIkeyword\fR and \fIvalue\fR are pairs listed below. -Keywords may be embedded in literal strings -or comments to identify a revision. -.PP -Initially, the user enters strings of the form \fI$keyword$\fR. -On checkout, \fIco\fR replaces these strings with strings of the form -\fI$keyword:\ value\ $\fR. If a revision containing strings of the latter form -is checked back in, the value fields will be replaced during the next -checkout. -Thus, the keyword values are automatically updated on checkout. -.PP -Keywords and their corresponding values: -.TP 13 -$\&Author$ -The login name of the user who checked in the revision. -.TP -$\&Date$ -The date and time the revision was checked in. -.TP -$\&Header$ -A standard header containing the full pathname of the RCS file, the -revision number, the date, the author, the state, and the locker (if locked). -.TP -$\&Id$ -Same as $\&Header$, except that the RCS file name is without a path. -.TP -$\&Locker$ -The login name of the user who locked the revision (empty if not locked). -.TP -$\&Log$ -The log message supplied during checkin, preceded by a header -containing the RCS file name, the revision number, the author, and the date. -Existing log messages are NOT replaced. -Instead, the new log message is inserted after \fI$\&Log:...$\fR. -This is useful for -accumulating a complete change log in a source file. -.TP -$\&RCSfile$ -The name of the RCS file without path. -.TP -$\&Revision$ -The revision number assigned to the revision. -.TP -$\&Source$ -The full pathname of the RCS file. -.TP -$\&State$ -The state assigned to the revision with the -.B \-s -option of -.IR rcs (1L) -or -.IR ci (1L). -.TP -.SH "FILE NAMING" -Pairs of RCS files and working files may be specified in 3 ways (see also the -example section). -.PP -1) Both the RCS file and the working file are given. The RCS file name is of -the form \fIpath1/workfile,v\fR -and the working file name is of the form -\fIpath2/workfile\fR, where -\fIpath1/\fR and -\fIpath2/\fR are (possibly different or empty) paths and -\fIworkfile\fR is a file name. -.PP -2) Only the RCS file is given. Then the working file is created in the current -directory and its name is derived from the name of the RCS file -by removing \fIpath1/\fR and the suffix \fI,v\fR. -.PP -3) Only the working file is given. -Then \fIco\fR looks for an RCS file of the form -\fIpath2/RCS/workfile,v\fR or \fIpath2/workfile,v\fR (in this order). -.PP -If the RCS file is specified without a path in 1) and 2), then \fIco\fR -looks for the RCS file first in the directory ./RCS and then in the current -directory. -.SH EXAMPLES -Suppose the current directory contains a subdirectory `RCS' with an RCS file -`io.c,v'. Then all of the following commands retrieve the latest -revision from `RCS/io.c,v' and store it into `io.c'. -.nf -.sp - co io.c; co RCS/io.c,v; co io.c,v; - co io.c RCS/io.c,v; co io.c io.c,v; - co RCS/io.c,v io.c; co io.c,v io.c; -.fi -.SH "FILE MODES" -The working file inherits the read and execute permissions from the RCS -file. In addition, the owner write permission is turned on, unless the file -is checked out unlocked and locking is set to \fIstrict\fR (see -.IR rcs (1L)). -.PP -If a file with the name of the working file exists already and has write -permission, \fIco\fR aborts the checkout if \fB\-q\fR is given, or asks -whether to abort if \fB\-q\fR is not given. If the existing working file is -not writable or \fB\-f\fR is given, the working file is deleted without asking. -.SH FILES -The caller of the command must have write permission in the working -directory, read permission for the RCS file, and either read permission -(for reading) or read/write permission (for locking) in the directory which -contains the RCS file. -.PP -A number of temporary files are created. -A semaphore file is created in the directory of the RCS file -to prevent simultaneous update. -.SH DIAGNOSTICS -The RCS file name, the working file name, -and the revision number retrieved are -written to the diagnostic output. -The exit status always refers to the last file checked out, -and is 0 if the operation was successful, 1 otherwise. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.sp 0 -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -ci(1L), ident(1L), rcs(1L), rcsdiff(1L), rcsintro(1L), rcsmerge(1L), rlog(1L), -rcsfile(5L) -.sp 0 -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. -.SH LIMITATIONS -The option \fB\-d\fR gets confused in some circumstances, -and accepts no date before 1970. -Links to the RCS and working files are not preserved. -There is no way to suppress the expansion of keywords, except -by writing them differently. In nroff and troff, this is done by embedding the -null-character `\\&' into the keyword. -.SH BUGS -The option \fB\-j\fR does not work for -files that contain lines with a single `.'. diff --git a/usr.bin/rcs/man/ident.1 b/usr.bin/rcs/man/ident.1 deleted file mode 100644 index 0754ef718344..000000000000 --- a/usr.bin/rcs/man/ident.1 +++ /dev/null @@ -1,68 +0,0 @@ -.TH IDENT 1L "" "Purdue University" -.SH NAME -ident \- identify files -.SH SYNOPSIS -\fBident\fR [ \fB\-q\fR ] [ file ... ] -.SH DESCRIPTION -.I Ident -searches the named files or, if no file name appears, the standard input -for all occurrences of the pattern -\fI$keyword:...$\fR, where \fIkeyword\fR is one of -.nf - - Author - Date - Header - Id - Locker - Log - Revision - RCSfile - Source - State - -.fi -These patterns are normally inserted automatically by the RCS command -.IR co (1L), -but can also be inserted manually. The option \fB\-q\fR suppresses -the warning given if there are no patterns in a file. -.PP -\fIIdent\fR works on text files as well as object files and dumps. -For example, if the C program in file f.c contains -.nf - - char rcsid[] = "$\&Header: Header information $"; - -.fi -and f.c is compiled into f.o, then the command -.nf - - ident f.c f.o - -will print - - f.c: - $\&Header: Header information $ - f.o: - $\&Header: Header information $ - -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.sp 0 -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -ci(1L), co(1L), rcs(1L), rcsdiff(1L), rcsintro(1L), rcsmerge(1L), rlog(1L), rcsfile(5L), -.sp 0 -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. diff --git a/usr.bin/rcs/man/merge.1 b/usr.bin/rcs/man/merge.1 deleted file mode 100644 index 1634e61529c6..000000000000 --- a/usr.bin/rcs/man/merge.1 +++ /dev/null @@ -1,45 +0,0 @@ -.TH MERGE 1L "" "Purdue University" -.SH NAME -merge \- three-way file merge -.SH SYNOPSIS -\fBmerge\fR [ \fB-p\fR ] file1 file2 file3 -.SH DESCRIPTION -.I Merge -incorporates all changes that lead form \fIfile2\fR to \fIfile3\fR into -\fIfile1\fR. The result goes to std. output if \fB-p\fR is present, into -\fIfile1\fR otherwise. \fIMerge\fR is useful for combining separate changes -to an original. Suppose \fIfile2\fR is the original, and both \fIfile1\fR -and \fIfile3\fR are modifications of \fIfile2\fR. Then \fImerge\fR -combines both changes. -.PP -An overlap occurs if both \fIfile1\fR and \fIfile3\fR -have changes in a common segment of lines. -\fIMerge\fR prints how many overlaps occurred, and includes both alternatives -in the result. The alternatives are delimited as follows: -.sp -.nf - <<<<<<< file1 - lines in file1 - ======= - lines in file3 - >>>>>>> file3 -.fi -.sp -If there are overlaps, the user should edit the result and delete one of the -alternatives. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.sp 0 -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -diff3 (1), diff (1), rcsmerge (1L), co (1L). diff --git a/usr.bin/rcs/man/rcs.1 b/usr.bin/rcs/man/rcs.1 deleted file mode 100644 index 7c4a5a16fe97..000000000000 --- a/usr.bin/rcs/man/rcs.1 +++ /dev/null @@ -1,170 +0,0 @@ -.TH RCS 1L "" "Purdue University" -.SH NAME -rcs \- change RCS file attributes -.SH SYNOPSIS -.B rcs -[ options ] -file ... -.SH DESCRIPTION -.I Rcs -creates new RCS files or changes attributes of existing ones. -An RCS file contains multiple revisions of text, -an access list, a change log, -descriptive text, -and some control attributes. -For \fIrcs\fR to work, the caller's login name must be on the access list, -except if the access list is empty, the caller is the owner of the file -or the superuser, or -the \fB\-i\fR option is present. -.PP -Files ending in `,v' are RCS files, all others are working files. If -a working file is given, \fIrcs\fR tries to find the corresponding -RCS file first in directory ./RCS and then in the current directory, -as explained in -.IR co (1L). -.TP 11 -.B \-i -creates and initializes a new RCS file, but does not deposit any revision. -If the RCS file has no path prefix, \fIrcs\fR tries to place it -first into the subdirectory ./RCS, and then into the current directory. -If the RCS file -already exists, an error message is printed. -.TP -.BI \-a "logins" -appends the login names appearing in the comma-separated list \fIlogins\fR -to the access list of the RCS file. -.TP -.BI \-A "oldfile" -appends the access list of \fIoldfile\fR to the access list of the RCS file. -.TP -.BR \-e [\fIlogins\fR] -erases the login names appearing in the comma-separated list \fIlogins\fR -from the access list of the RCS file. -If \fIlogins\fR is omitted, the entire access list is erased. -.TP -.BR \-b [\fIrev\fR] -sets the default branch to \fIrev\fR. If \fIrev\fR is omitted, the default -branch is reset to the (dynamically) highest branch on the trunk. -.TP -.BI \-c "string" -sets the comment leader to \fIstring\fR. The comment leader -is printed before every log message line generated by the keyword -$\&Log$ during checkout (see -.IR co (1L)). -This is useful for programming -languages without multi-line comments. During \fBrcs -i\fR or initial -\fBci\fR, the comment leader is guessed from the suffix of the working file. -.TP -.BR \-l [\fIrev\fR] -locks the revision with number \fIrev\fR. -If a branch is given, the latest revision on that branch is locked. -If \fIrev\fR is omitted, the latest revision on the default branch is locked. -Locking prevents overlapping changes. -A lock is removed with \fBci\fR or \fBrcs -u\fR (see below). -.TP -.BR \-u [\fIrev\fR] -unlocks the revision with number \fIrev\fR. -If a branch is given, the latest revision on that branch is unlocked. -If \fIrev\fR is omitted, the latest lock held by the caller is removed. -Normally, only the locker of a revision may unlock it. -Somebody else unlocking a revision breaks the lock. -This causes a mail message to be sent to the original locker. -The message contains a commentary solicited from the breaker. -The commentary is terminated with a line containing a single `.' or -control-D. -.TP -.B \-L -sets locking to \fIstrict\fR. Strict locking means that the owner -of an RCS file is not exempt from locking for checkin. -This option should be used for files that are shared. -.TP -.B \-U -sets locking to non-strict. Non-strict locking means that the owner of -a file need not lock a revision for checkin. -This option should NOT be used for files that are shared. -The default (\fB\-L\fR or \fB\-U\fR) is determined by your system administrator. -.TP -.B \-n\fIname\fR[:\fIrev\fR] -associates the symbolic name \fIname\fR with the branch or -revision \fIrev\fR. -\fIRcs\fR prints an error message if \fIname\fR is already associated with -another number. -If \fIrev\fR is omitted, the symbolic name is deleted. -.TP -.B \-N\fIname\fR[:\fIrev\fR] -same as \fB\-n\fR, except that it overrides a previous assignment of -\fIname\fR. -.TP -.BI \-o "range" -deletes ("outdates") the revisions given by \fIrange\fR. -A range consisting of a single revision number means that revision. -A range consisting of a branch number means the latest revision on that -branch. -A range of the form \fIrev1-rev2\fR means -revisions \fIrev1\fR to \fIrev2\fR on the same branch, -\fI-rev\fR means from the beginning of the branch containing -\fIrev\fR up to and including \fIrev\fR, and \fIrev-\fR means -from revision \fIrev\fR to the end of the branch containing \fIrev\fR. -None of the outdated revisions may have branches or locks. -.TP -.B \-q -quiet mode; diagnostics are not printed. -.TP -.B \-s\fIstate\fR[:\fIrev\fR] -sets the state attribute of the revision \fIrev\fR to \fIstate\fR. -If \fIrev\fR is a branch number, the latest revision on that branch is -assumed. -If \fIrev\fR is omitted, the latest revision on the default branch is assumed. -Any identifier is acceptable for \fIstate\fR. -A useful set of states -is \fIExp\fR (for experimental), \fIStab\fR (for stable), and \fIRel\fR (for -released). -By default, -.IR ci (1L) -sets the state of a revision to \fIExp\fR. -.TP -.BR \-t [\fItxtfile\fR] -writes descriptive text into the RCS file (deletes the existing text). -If \fItxtfile\fR is omitted, -\fIrcs\fR prompts the user for text supplied from the standard input, -terminated with a line containing a single `.' or control-D. -Otherwise, the descriptive text is copied from the file \fItxtfile\fR. -If the \fB\-i\fR option is present, descriptive text is requested -even if \fB\-t\fR is not given. -The prompt is suppressed if the standard input is not a terminal. -.SH DIAGNOSTICS -The RCS file name and the revisions outdated are written to -the diagnostic output. -The exit status always refers to the last RCS file operated upon, -and is 0 if the operation was successful, 1 otherwise. -.SH FILES -The caller of the command -must have read/write permission for the directory containing -the RCS file and read permission for the RCS file itself. -.I Rcs -creates a semaphore file in the same directory as the RCS -file to prevent simultaneous update. -For changes, \fIrcs\fR always creates a new file. On successful completion, -\fIrcs\fR deletes the old one and renames the new one. -This strategy makes links to RCS files useless. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.sp 0 -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -co(1L), ci(1L), ident(1L), rcsdiff(1L), rcsintro(1L), rcsmerge(1L), rlog(1L), -rcsfile(5L) -.sp 0 -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. diff --git a/usr.bin/rcs/man/rcsclean.1 b/usr.bin/rcs/man/rcsclean.1 deleted file mode 100644 index 95fa62394d69..000000000000 --- a/usr.bin/rcs/man/rcsclean.1 +++ /dev/null @@ -1,64 +0,0 @@ -.TH RCSCLEAN 1L "" "Purdue University" -.SH NAME -rcsclean \- clean up working files -.SH SYNOPSIS -\fBrcsclean\fR [ \fB-r\fIrev\fR ] [ \fB-q\fIrev\fR ] file... -.SH DESCRIPTION -.I Rcsclean -removes working files that were checked out and never modified. -For each file given, \fIrcsclean\fR -compares the working file and a revision in the corresponding -RCS file. If it finds no difference, it removes the working file, and, -if the revision was locked by the caller, unlocks the revision. -.PP -A file name ending in ',v' is an RCS file name, otherwise a -working file name. \fIRcsclean\fR derives the working file name from the RCS -file name and vice versa, as explained in -.IR co (1L). -Pairs consisting -of both an RCS and a working file name may also be specified. -.PP -\fIRev\fR specifies with which revision the working file is compared. -If \fIrev\fR is omitted, \fIrcsclean\fR compares the working file with -the latest revision -on the default branch (normally the highest branch on the trunk). -The option \fB-q\fR suppresses diagnostics. -.PP -\fIRcsclean\fR is useful for "clean" targets in Makefiles. -Note that -.IR rcsdiff (1L) -prints out the differences. -Also, -.IR ci (1L) -normally asks whether to check in a file -if it was not changed. -.SH EXAMPLES -.nf -The command - - rcsclean *.c *.h - -.fi -removes all working files ending in ".c" or ".h" that were not changed -since their checkout. -.SH DIAGNOSTICS -The exit status is 0 if there were no differences -during the last comparison or if the last working file did not exist, -1 if there were differences, and 2 if there were errors. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.sp 0 -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -co(1L), ci(1L), ident(1L), rcs(1L), rcsdiff(1L), rcsintro(1L), rcsmerge(1L), -rlog(1L), rcsfile(5L). diff --git a/usr.bin/rcs/man/rcsdiff.1 b/usr.bin/rcs/man/rcsdiff.1 deleted file mode 100644 index 3117e8a7ee42..000000000000 --- a/usr.bin/rcs/man/rcsdiff.1 +++ /dev/null @@ -1,72 +0,0 @@ -.TH RCSDIFF 1L "" "Purdue University" -.SH NAME -rcsdiff \- compare RCS revisions -.SH SYNOPSIS -\fBrcsdiff\fR [ \fB\-biwt\fR ] [ \fB\-cefhn\fR ] [ \fB\-q\fR ] [ \fB\-r\fIrev1\fR ] [ \fB\-r\fIrev2\fR ] file ... -.SH DESCRIPTION -.I Rcsdiff -runs -.IR diff (1) -to compare two revisions of each RCS file given. -A file name ending in ',v' is an RCS file name, otherwise a -working file name. \fIRcsdiff\fR derives the working file name from the RCS -file name and vice versa, as explained in -.IR co (1L). -Pairs consisting -of both an RCS and a working file name may also be specified. -.PP -The options \fB\-b\fR, \fB\-i\fR, \fB\-w\fR, \fB\-t\fR, -\fB\-c\fR, \fB\-e\fR, \fB\-f\fR, and \fB\-h\fR, -have the same effect as described in -.IR diff (1); -option -\fB\-n\fR generates an edit script of the format used by RCS. -The option \fB\-q\fR suppresses diagnostic output. -.PP -If both \fIrev1\fR and \fIrev2\fR -are omitted, \fIrcsdiff\fR compares the latest revision on the -default branch (normally the highest branch on the trunk) -with the contents of the corresponding working file. This is useful -for determining what you changed since the last checkin. -.PP -If \fIrev1\fR is given, but \fIrev2\fR is omitted, -\fIrcsdiff\fR compares revision \fIrev1\fR of the RCS file with -the contents of the corresponding working file. -.PP -If both \fIrev1\fR and \fIrev2\fR are given, -\fIrcsdiff\fR compares revisions \fIrev1\fR and \fIrev2\fR of the RCS file. -.PP -Both \fIrev1\fR and \fIrev2\fR may be given numerically or symbolically, -and may actually be attached to any of the options. -.SH EXAMPLES -.nf -The command - -.B " rcsdiff f.c - -.fi -runs \fIdiff\fR on the latest revision on the default branch of RCS file f.c,v -and the contents of working file f.c. -.SH DIAGNOSTICS -The exit status is 0 if there were no differences during the last comparison, -1 if there were differences, and 2 if there were errors. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.sp 0 -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -ci(1L), co(1L), diff(1), ident(1L), rcs(1L), rcsintro(1L), rcsmerge(1L), rlog(1L) -.br -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. diff --git a/usr.bin/rcs/man/rcsfile.5 b/usr.bin/rcs/man/rcsfile.5 deleted file mode 100644 index d487f33e201c..000000000000 --- a/usr.bin/rcs/man/rcsfile.5 +++ /dev/null @@ -1,156 +0,0 @@ -.TH RCSFILE 5L "" "Purdue University" -.SH NAME -rcsfile \- format of RCS file -.SH DESCRIPTION -An RCS file is an ASCII file. Its contents are described by the grammar -below. The text is free format, i.e., spaces, tabs and new lines have -no significance except in strings. Strings are enclosed by `@'. -If a string contains a `@', it must be doubled. -.PP -The meta syntax uses the following conventions: `|' (bar) separates -alternatives; `{' and `}' enclose optional phrases; `{' and `}*' enclose -phrases that may be repeated zero or more times; -`{' and '}+' enclose phrases that must appear at least once and may be -repeated; -`<' and `>' enclose nonterminals. -.PP -.ta 1.5i 2.0i 3i -.fc ~ -.nf - - -<rcstext> ~~::=~~<admin> {<delta>}* <desc> {<deltatext>}* - -<admin> ~~::=~~\fBhead\fR ~~{<num>}; - ~~ ~~\fBbranch\fR ~~{<num>}; - ~~ ~~\fBaccess\fR ~~{<id>}*; - ~~ ~~\fBsymbols\fR ~~{<id> : <num>}*; - ~~ ~~\fBlocks\fR ~~{<id> : <num>}*; - ~~ ~~\fBcomment\fR ~~{<string>}; - -<delta> ~~::=~~<num> - ~~ ~~\fBdate\fR ~~<num>; - ~~ ~~\fBauthor\fR ~~<id>; - ~~ ~~\fBstate\fR ~~{<id>}; - ~~ ~~\fBbranches\fR ~~{<num>}*; - ~~ ~~\fBnext\fR ~~{<num>}; - -<desc> ~~::=~~\fBdesc\fR ~~<string> - -<deltatext>~~::=~~<num> - ~~ ~~\fBlog\fR ~~<string> - ~~ ~~\fBtext\fR ~~<string> - - -<num> ~~::=~~{<digit>{.}}+ - -<digit> ~~::=~~0 | 1 | ... | 9 - -<id> ~~::=~~<letter>{<idchar>}* - -<letter> ~~::=~~A | B | ... | Z | a | b | ... | z - -<idchar> ~~::=~~Any printing ASCII character except space, - ~~ ~~tab, carriage return, new line, and <special>. - -<special> ~~::=~~; | : | , | @ - -<string> ~~::=~~@{any ASCII character, with `@' doubled}*@ - -.fi -.PP -Identifiers are case sensitive. Keywords are in lower case only. -The sets of keywords and identifiers may overlap. -.PP -The <delta> nodes form a tree. All nodes whose numbers -consist of a single pair -(e.g., 2.3, 2.1, 1.3, etc.) -are on the "trunk", and are linked through the \fBnext\fR -field in order of decreasing numbers. The \fBhead\fR field in the -<admin> node points to the head of that sequence (i.e., contains -the highest pair). -The \fBbranch\fR node in the admin node indicates the default -branch (or revision) for most RCS operations. If empty, the default -branch is the highest branch on the trunk. -.PP -All <delta> nodes whose numbers consist of 2n fields (n\(>=2) -(e.g., 3.1.1.1, 2.1.2.2, etc.) -are linked as follows. All nodes whose first (2n)-1 number fields are identical -are linked through the \fBnext\fR field in order of increasing numbers. -For each such sequence, -the <delta> node whose number is identical to the first -2(n-1) number fields of the deltas on that sequence is called the branchpoint. -The \fBbranches\fR field of a node contains a list of the -numbers of the first nodes of all sequences for which it is a branchpoint. -This list is ordered in increasing numbers. -.sp 1 -.ne 38 -Example: -.eo -.nf -.vs 12pts -.cs 1 20 -.if t .in +0.5i - Head - | - | - v - --------- - / \ / \ | | / \ / \ - / \ / \ | 2.1 | / \ / \ - / \ / \ | | / \ / \ -/1.2.1.3\ /1.3.1.1\ | | /1.2.2.2\ /1.2.2.1.1.1\ ---------- --------- --------- --------- ------------- - ^ ^ | ^ ^ - | | | | | - | | v | | - / \ | --------- / \ | - / \ | \ 1.3 / / \ | - / \ ---------\ / / \----------- -/1.2.1.1\ \ / /1.2.2.1\ ---------- \ / --------- - ^ | ^ - | | | - | v | - | --------- | - | \ 1.2 / | - ----------------------\ /--------- - \ / - \ / - | - | - v - --------- - \ 1.1 / - \ / - \ / - \ / - - -.if t .in -0.5i -.cs 1 -.ec -.ce -Fig. 1: A revision tree -.fi -.PP -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.sp 0 -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -ci(1L), co(1L), ident(1L), rcs(1L), rcsdiff(1L), rcsmerge(1L), rlog(1L), -.br -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. diff --git a/usr.bin/rcs/man/rcsfreeze.1 b/usr.bin/rcs/man/rcsfreeze.1 deleted file mode 100644 index 98a6ae2fa16f..000000000000 --- a/usr.bin/rcs/man/rcsfreeze.1 +++ /dev/null @@ -1,50 +0,0 @@ -.TH RCSFREEZE 1L "" "Purdue University" -.SH NAME -rcsfreeze \- freeze a configuration of sources checked in under RCS -.SH SYNOPSIS -.B rcsfreeze -[symbolic revision name] -.SH DESCRIPTION -The -.I rcsfreeze -command has the purpose of assigning a symbolic revision -number to a set of RCS files, which form a valid configuration. -.PP -The idea is to run -.I rcsfreeze -each time a new version is checked -in. A unique symbolic revision number (\c -.BI C_ number, -where -.I number -is increased each time rcsfreeze is run) is then assigned to the most -recent revision of each RCS file of the main trunk. -.PP -If the command is invoked with an argument, then this -argument is used as the symbolic name to freeze a configuration. -The unique identifier is still generated -and is listed in the log file but it will not appear as -part of the symbolic revision name in the actual RCS files. -.PP -A log message is requested from the user which is saved for future -references. -.PP -The shell script works only on all RCS files at one time. -It is important that all changed files are checked in (there are -no precautions against any error in this respect). Run -.IR rcsclean (1L) -first and see whether any sources remain in the current directory. -.SH FILES -.TP 2.5i -[RCS/]rcsfreeze.version -for the version number -.TP -[RCS/]rscfreeze.log -for the log messages, most recent log message first. -.SH AUTHOR -Stephan v. Bechtolsheim -.SH "SEE ALSO" -rcs(1L), rlog(1L), rcsclean(1L) -.SH BUGS -The program does not check whether there are any sources checked out -and modified. diff --git a/usr.bin/rcs/man/rcsintro.1 b/usr.bin/rcs/man/rcsintro.1 deleted file mode 100644 index 26b72ac4280a..000000000000 --- a/usr.bin/rcs/man/rcsintro.1 +++ /dev/null @@ -1,241 +0,0 @@ -.TH RCSINTRO 1L "May 11, 1983" "Purdue University" -.SH NAME -rcsintro - introduction to RCS commands -.SH DESCRIPTION -The Revision Control System (RCS) manages multiple revisions of text files. -RCS automates the storing, retrieval, logging, identification, and merging -of revisions. RCS is useful for text that is revised frequently, for example -programs, documentation, graphics, papers, form letters, etc. -.PP -The basic user interface is extremely simple. The novice only needs -to learn two commands: -.IR ci (1L) -and -.IR co (1L). -\fICi\fR, short for "check in", deposits the contents of a -text file into an archival file called an RCS file. An RCS file -contains all revisions of a particular text file. -\fICo\fR, short for "check out", retrieves revisions from an RCS file. -.PP -.B "Functions of RCS" -.PP -.IP \(bu -Storage and retrieval of multiple revisions of text. RCS saves all old -revisions in a space efficient way. -Changes no longer destroy the original, because the -previous revisions remain accessible. Revisions can be retrieved according to -ranges of revision numbers, symbolic names, dates, authors, and -states. -.IP \(bu -Maintenance of a complete history of changes. RCS logs all changes automatically. -Besides the text of each revision, RCS stores the author, the date and time of -check-in, and a log message summarizing the change. -The logging makes it easy to find out -what happened to a module, without having to compare -source listings or having to track down colleagues. -.IP \(bu -Resolution of access conflicts. When two or more programmers wish to -modify the same revision, RCS alerts the programmers and prevents one -modification from corrupting the other. -.IP \(bu -Maintenance of a tree of Revisions. RCS can maintain separate lines of development -for each module. It stores a tree structure that represents the -ancestral relationships among revisions. -.IP \(bu -Merging of revisions and resolution of conflicts. -Two separate lines of development of a module can be coalesced by merging. -If the revisions to be merged affect the same sections of code, RCS alerts the -user about the overlapping changes. -.IP \(bu -Release and configuration control. Revisions can be assigned symbolic names -and marked as released, stable, experimental, etc. -With these facilities, configurations of modules can be -described simply and directly. -.IP \(bu -Automatic identification of each revision with name, revision number, -creation time, author, etc. -The identification is like a stamp that can be embedded at an appropriate place -in the text of a revision. -The identification makes it simple to determine which -revisions of which modules make up a given configuration. -.IP \(bu -Minimization of secondary storage. RCS needs little extra space for -the revisions (only the differences). If intermediate revisions are -deleted, the corresponding deltas are compressed accordingly. -.sp -.PP -.B "Getting Started with RCS" -.PP -Suppose you have a file f.c that you wish to put under control of RCS. -Invoke the check-in command -.PP -.ti 1.5i -.B "ci f.c -.PP -This command creates the RCS file f.c,v, stores f.c into it as revision 1.1, and -deletes f.c. It also asks you for a description. The description -should be a synopsis of the contents of the file. All later check-in -commands will ask you for a log entry, which should summarize the -changes that you made. -.PP -Files ending in ,v are called RCS files (`v' stands for `versions'), -the others are called working files. -To get back the working file f.c in the previous example, use the check-out -command -.PP -.ti 1.5i -.B "co f.c -.PP -This command extracts the latest revision from f.c,v and writes -it into f.c. You can now edit f.c and check it back in by invoking -.PP -.ti 1.5i -.B "ci f.c -.PP -\fICi\fR increments the revision number properly. -If \fIci\fR complains with the message -.PP - ci error: no lock set by <your login> -.PP -then your system administrator has decided to create all RCS files -with the locking attribute set to `strict'. In this case, you should -have locked the revision during the previous check-out. Your last check-out -should have been -.PP -.ti 1.5i -.B "co \-l f.c -.PP -Of course, it is too late now to do the check-out with locking, because you -probably modified f.c already, and a second check-out would -overwrite your modifications. Instead, invoke -.PP -.ti 1.5i -.B "rcs \-l f.c -.PP -This command will lock the latest revision for you, unless somebody -else got ahead of you already. In this case, you'll have to negotiate with -that person. -.PP -Locking assures that you, and only you, can check in the next update, and -avoids nasty problems if several people work on the same file. -Even if a revision is locked, it can still be checked out for -reading, compiling, etc. All that locking -prevents is a CHECK-IN by anybody but the locker. -.PP -If your RCS file is private, i.e., if you are the only person who is going -to deposit revisions into it, strict locking is not needed and you -can turn it off. -If strict locking is turned off, -the owner of the RCS file need not have a lock for check-in; all others -still do. Turning strict locking off and on is done with the commands -.PP -.ti 1.5i -.BR "rcs \-U f.c" " and " "rcs \-L f.c" -.PP -If you don't want to clutter your working directory with RCS files, create -a subdirectory called RCS in your working directory, and move all your RCS -files there. RCS commands will look first into that directory to find -needed files. All the commands discussed above will still work, without any -modification. -(Actually, pairs of RCS and working files can be specified in 3 ways: -(a) both are given, (b) only the working file is given, (c) only the -RCS file is given. Both RCS and working files may have arbitrary path prefixes; -RCS commands pair them up intelligently). -.PP -To avoid the deletion of the working file during check-in (in case you want to -continue editing), invoke -.PP -.ti 1.5i -.BR "ci \-l f.c" " or " "ci \-u f.c" -.PP -These commands check in f.c as usual, but perform an implicit -check-out. The first form also locks the checked in revision, the second one -doesn't. Thus, these options save you one check-out operation. -The first form is useful if locking is strict, the second one if not strict. -Both update the identification markers in your working file (see below). -.PP -You can give \fIci\fR the number you want assigned to a checked in -revision. Assume all your revisions were numbered 1.1, 1.2, 1.3, etc., -and you would like to start release 2. -The command -.PP -.ti 1.5i -.BR "ci \-r2 f.c" " or " "ci \-r2.1 f.c" -.PP -assigns the number 2.1 to the new revision. -From then on, \fIci\fR will number the subsequent revisions -with 2.2, 2.3, etc. The corresponding \fIco\fR commands -.PP -.ti 1.5i -.BR "co \-r2 f.c" " and " "co \-r2.1 f.c" -.PP -retrieve the latest revision numbered 2.x and the revision 2.1, -respectively. \fICo\fR without a revision number selects -the latest revision on the "trunk", i.e., the highest -revision with a number consisting of 2 fields. Numbers with more than 2 -fields are needed for branches. -For example, to start a branch at revision 1.3, invoke -.PP -.ti 1.5i -.B "ci \-r1.3.1 f.c -.PP -This command starts a branch numbered 1 at revision 1.3, and assigns -the number 1.3.1.1 to the new revision. For more information about -branches, see \fIrcsfile\fR(5L). -.sp -.PP -.B "Automatic Identification" -.PP -RCS can put special strings for identification into your source and object -code. To obtain such identification, place the marker -.PP -.ti 1.5i -$\&Header$ -.PP -into your text, for instance inside a comment. -RCS will replace this marker with a string of the form -.PP -.ti 1.5i -$\&Header: filename revision_number date time author state $ -.PP -With such a marker on the first page of each module, you can -always see with which revision you are working. -RCS keeps the markers up to date automatically. -To propagate the markers into your object code, simply put -them into literal character strings. In C, this is done as follows: -.PP -.ti 1.5i -static char rcsid[] = "$\&Header$"; -.PP -The command \fIident\fR extracts such markers from any file, even object code -and dumps. -Thus, \fIident\fR lets you find out -which revisions of which modules were used in a given program. -.PP -You may also find it useful to put the marker $\&Log$ -into your text, inside a comment. This marker accumulates -the log messages that are requested during check-in. -Thus, you can maintain the complete history of your file directly inside it. -There are several additional identification markers; see \fIco\fR(1L) for -details. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.br -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.br -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -ci(1L), co(1L), ident(1L), merge(1L), rcs(1L), rcsdiff(1L), rcsmerge(1L), rlog(1L), -rcsfile(5L), -.br -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. diff --git a/usr.bin/rcs/man/rcsmerge.1 b/usr.bin/rcs/man/rcsmerge.1 deleted file mode 100644 index f438b569751a..000000000000 --- a/usr.bin/rcs/man/rcsmerge.1 +++ /dev/null @@ -1,75 +0,0 @@ -.TH RCSMERGE 1L "" "Purdue University" -.SH NAME -rcsmerge \- merge RCS revisions -.SH SYNOPSIS -\fBrcsmerge\fR \fB\-r\fIrev1\fR [ \fB\-r\fIrev2\fR ] [ \fB\-p\fR ] file -.SH DESCRIPTION -.I Rcsmerge -incorporates the changes between \fIrev1\fR and \fIrev2\fR of an -RCS file into the corresponding working file. If \fB\-p\fR is given, the result -is printed on the standard output, otherwise the result overwrites the -working file. -.PP -A file name ending in ',v' is an RCS file name, otherwise a -working file name. \fIMerge\fR derives the working file name from the RCS -file name and vice versa, as explained in -.IR co (1L). -A pair consisting -of both an RCS and a working file name may also be specified. -.PP -\fIRev1\fR may not be omitted. If \fIrev2\fR is omitted, the latest -revision on the default branch (normally the highest branch on the trunk) -is assumed. -Both \fIrev1\fR and \fIrev2\fR may be given numerically or symbolically. -.PP -\fIRcsmerge\fR prints a warning if there are overlaps, and delimits -the overlapping regions as explained in \fIco \-j\fR. -The command is useful for incorporating changes into a checked-out revision. -.SH EXAMPLES -Suppose you have released revision 2.8 of f.c. Assume -furthermore that you just completed revision 3.4, when you receive -updates to release 2.8 from someone else. -To combine the updates to 2.8 and your changes between 2.8 and 3.4, -put the updates to 2.8 into file f.c and execute -.sp -.B " rcsmerge \-p \-r2.8 \-r3.4 f.c >f.merged.c -.sp -Then examine f.merged.c. -Alternatively, if you want to save the updates to 2.8 in the RCS file, -check them in as revision 2.8.1.1 and execute \fIco \-j\fR: -.sp -.B " ci \-r2.8.1.1 f.c -.br -.B " co \-r3.4 \-j2.8:2.8.1.1 f.c -.sp -As another example, the following command undoes the changes -between revision 2.4 and 2.8 in your currently checked out revision -in f.c. -.sp -.B " rcsmerge \-r2.8 \-r2.4 f.c -.sp -Note the order of the arguments, and that f.c will be -overwritten. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.sp 0 -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -ci(1L), co(1L), merge(1L), ident(1L), rcs(1L), rcsdiff(1L), rlog(1L), rcsfile(5L), -.br -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. -.SH BUGS -\fIRcsmerge\fR does not work on -files that contain lines with a single `.'. diff --git a/usr.bin/rcs/man/rlog.1 b/usr.bin/rcs/man/rlog.1 deleted file mode 100644 index b251b969ea98..000000000000 --- a/usr.bin/rcs/man/rlog.1 +++ /dev/null @@ -1,133 +0,0 @@ -.TH RLOG 1L "" "Purdue University" -.SH NAME -rlog \- print log messages and other information about RCS files -.SH SYNOPSIS -.B rlog -[ options ] -file ... -.SH DESCRIPTION -.I Rlog -prints information about RCS files. -Files ending in `,v' are RCS files, all others are working files. If -a working file is given, \fIrlog\fR tries to find the corresponding -RCS file first in directory ./RCS and then in the current directory, -as explained in -.IR co (1L). -.PP -\fIRlog\fR prints the following information for each -RCS file: RCS file name, working file name, head (i.e., the number -of the latest revision on the trunk), default branch, access list, locks, -symbolic names, suffix, total number of revisions, -number of revisions selected for printing, and -descriptive text. This is followed by entries for the selected revisions in -reverse chronological order for each branch. For each revision, -\fIrlog\fR prints revision number, author, date/time, state, number of -lines added/deleted (with respect to the previous revision), -locker of the revision (if any), and log message. -Without options, \fIrlog\fR prints complete information. -The options below restrict this output. -.TP 10 -.B \-L -ignores RCS files that have no locks set; convenient in combination with -\fB\-R\fR, \fB\-h\fR, or \fB\-l\fR. -.TP 10 -.B \-R -only prints the name of the RCS file; convenient for translating a -working file name into an RCS file name. -.TP 10 -.B \-h -prints only RCS file name, working file name, head, -default branch, access list, locks, -symbolic names, and suffix. -.TP 10 -.B \-t -prints the same as \fB\-h\fR, plus the descriptive text. -.TP 10 -.B \-b -prints information about the revisions on the default branch (normally -the highest branch on the trunk). -.TP 10 -.BI \-d "dates" -prints information about revisions with a checkin date/time in the ranges given by -the semicolon-separated list of \fIdates\fR. -A range of the form \fId1<d2\fR or \fId2>d1\fR -selects the revisions that were deposited between -\fId1\fR and \fId2\fR, (inclusive). -A range of the form \fI<d\fR or \fId>\fR selects -all revisions dated -\fId\fR or earlier. -A range of the form \fId<\fR or \fI>d\fR selects -all revisions dated \fId\fR or later. -A range of the form \fId\fR selects the single, latest revision dated \fId\fR or -earlier. -The date/time strings \fId, d1, \fRand \fId2\fR -are in the free format explained in -.IR co (1L). -Quoting is normally necessary, especially for \fI<\fR and \fI>\fR. Note that the separator is -a semicolon. -.TP 10 -.B \-l\fR[\fIlockers\fR] -prints information about locked revisions. -If the comma-separated list \fIlockers\fR of login names is given, -only the revisions locked by the given login names are printed. -If the list is omitted, all locked revisions are printed. -.TP 10 -.BI \-r "revisions" -prints information about revisions given in the comma-separated list -\fIrevisions\fR of revisions and ranges. A range \fIrev1-rev2\fR means revisions -\fIrev1\fR to \fIrev2\fR on the same branch, \fI-rev\fR means revisions -from the beginning of the branch up to and including \fIrev\fR, -and \fIrev-\fR means revisions starting with \fIrev\fR to the end of the -branch containing \fIrev\fR. An argument that is a branch means all -revisions on that branch. A range of branches means all revisions -on the branches in that range. -.TP 10 -.BI \-s "states" -prints information about revisions whose state attributes match one of the -states given in the comma-separated list \fIstates\fR. -.TP 10 -.B \-w\fR[\fIlogins\fR] -prints information about revisions checked in by users with -login names appearing in the comma-separated list \fIlogins\fR. -If \fIlogins\fR is omitted, the user's login is assumed. -.PP -\fIRlog\fR prints the intersection of the revisions selected with -the options \fB\-d\fR, \fB\-l\fR, \fB\-s\fR, \fB\-w\fR, intersected -with the union of the revisions selected by \fB\-b\fR and \fB\-r\fR. -.SH EXAMPLES -.nf -.sp - rlog \-L \-R RCS/*,v - rlog \-L \-h RCS/*,v - rlog \-L \-l RCS/*,v - rlog RCS/*,v -.sp -.fi -The first command prints the names of all RCS files in the subdirectory `RCS' -which have locks. The second command prints the headers of those files, -and the third prints the headers plus the log messages of the locked revisions. -The last command prints complete information. -.SH DIAGNOSTICS -The exit status always refers to the last RCS file operated upon, -and is 0 if the operation was successful, 1 otherwise. -.SH IDENTIFICATION -.de VL -\\$2 -.. -Author: Walter F. Tichy, -Purdue University, West Lafayette, IN, 47907. -.sp 0 -Revision Number: -.VL $Revision: 1.1.1.1 $ -; Release Date: -.VL $Date: 1993/03/21 09:45:37 $ -\&. -.sp 0 -Copyright \(co 1982, 1988, 1989 by Walter F. Tichy. -.SH SEE ALSO -ci(1L), co(1L), ident(1L), rcs(1L), rcsdiff(1L), rcsintro(1L), rcsmerge(1L), -rcsfile(5L) -.br -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control -System," in \fIProceedings of the 6th International Conference on Software -Engineering\fR, IEEE, Tokyo, Sept. 1982. diff --git a/usr.bin/rcs/man/sccstorcs.1 b/usr.bin/rcs/man/sccstorcs.1 deleted file mode 100644 index a9754919e3c7..000000000000 --- a/usr.bin/rcs/man/sccstorcs.1 +++ /dev/null @@ -1,51 +0,0 @@ -.TH SCCSTORCS 8 "29 June 1983" -.UC 4 -.SH NAME -sccstorcs \- build RCS file from SCCS file -.SH SYNOPSIS -\fBsccstorcs\fR [\fB\-t\fR] [\fB\-v\fR] \fIs.file\fR ... -.SH DESCRIPTION -.I Sccstorcs -builds an RCS file from each SCCS file argument. -The deltas and comments for each delta are preserved and installed into -the new RCS file in order. -Also preserved are -the user access list and descriptive text, if any, -from the SCCS file. -.PP -The following flags are meaningful: -.TP -\fB\-t\fR -Trace only. -Prints detailed information about the SCCS file and lists the -commands that would be executed to produce the RCS file. -No commands are actually executed and no RCS file is made. -.TP -\fB\-v\fR -Verbose. -Prints each command that is run while it is building the RCS file. -.SH FILES -For each s.\fIsomefile\fR, -.I Sccstorcs -writes the files \fIsomefile\fR and \fIsomefile\fR,v -which should not already exist. -.I Sccstorcs -will abort, rather than overwrite those files if they do exist. -.SH SEE ALSO -ci (1), co (1), rcs (1). -.br -Walter F. Tichy, "Design, Implementation, and Evaluation of a Revision -Control System," in \fIProceedings of the 6th International Conference -on Software Engineering\fR, IEEE, Tokyo, Sept. 1982. -.SH DIAGNOSTICS -All diagnostics are written to stderr. -Non-zero exit status on error. -.SH BUGS -.I Sccstorcs -does not preserve all SCCS options specified in the SCCS file. -Most notably, it does not preserve removed deltas, MR numbers, -and cutoff points. -.SH AUTHOR -Ken Greer - -Copyright \(co 1983 by Kenneth L. Greer diff --git a/usr.bin/rcs/src/maketime.c b/usr.bin/rcs/src/maketime.c deleted file mode 100644 index deedbc84e7f8..000000000000 --- a/usr.bin/rcs/src/maketime.c +++ /dev/null @@ -1,212 +0,0 @@ -# -/* - * MAKETIME derive 32-bit time value from TM structure. - * - * Usage: - * long t,maketime(); - * struct tm *tp; Pointer to TM structure from <time.h> - * NOTE: this must be extended version!!! - * t = maketime(tp); - * - * Returns: - * 0 if failure; parameter out of range or nonsensical. - * else long time-value. - * Notes: - * This code is quasi-public; it may be used freely in like software. - * It is not to be sold, nor used in licensed software without - * permission of the author. - * For everyone's benefit, please report bugs and improvements! - * Copyright 1981 by Ken Harrenstien, SRI International. - * (ARPANET: KLH @ SRI) - */ -#ifndef lint -static char rcsid[]= "$Id: maketime.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif -/* $Log: maketime.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 1.8 88/11/08 13:54:53 narten - * allow negative timezones (-24h <= x <= 24h) - * - * Revision 1.7 88/11/08 12:02:24 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 1.7 88/08/28 14:47:52 eggert - * Allow cc -R. Remove unportable "#endif XXX"s. - * - * Revision 1.6 87/12/18 17:05:58 narten - * include rcsparam.h - * - * Revision 1.5 87/12/18 11:35:51 narten - * maketime.c: fixed USG code - you have tgo call "tzset" in order to have - * "timezone" set. ("localtime" calls it, but it's probably better not to - * count on "localtime" having been called.) - * - * Revision 1.4 87/10/18 10:26:57 narten - * Updating version numbers. Changes relative to 1.0 are actually - * relative to 1.2 - * - * Revision 1.3 87/09/24 13:58:45 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:21:48 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:04 kcs - * Initial revision - * - * Revision 1.2 83/12/05 10:12:56 wft - * added cond. compilation for USG Unix; long timezone; - * - * Revision 1.1 82/05/06 11:38:00 wft - * Initial revision - * - */ - - -#include "rcsbase.h" -#include "time.h" - -int daytb[] = { /* # days in year thus far, indexed by month (0-12!!) */ - 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 -}; - -struct tm *localtime(); -long time(); - -long maketime(atm) -struct tm *atm; -{ register struct tm *tp; - register int i; - int year, yday, mon, day, hour, min, sec, zone, dst, leap; - long tres, curtim; - - VOID time(&curtim); - tp = localtime(&curtim); /* Get breakdowns of current time */ - year = tp->tm_year; /* Use to set up defaults */ - mon = tp->tm_mon; - day = tp->tm_mday; - - -#ifdef DEBUG -printf("first YMD: %d %d %d, T=%ld\n",year,mon,day,tres); -#endif - tp = atm; - - /* First must find date, using specified year, month, day. - * If one of these is unspecified, it defaults either to the - * current date (if no more global spec was given) or to the - * zero-value for that spec (i.e. a more global spec was seen). - * Start with year... note 32 bits can only handle 135 years. - */ - if(tp->tm_year != TMNULL) - { if((year = tp->tm_year) >= 1900) /* Allow full yr # */ - year -= 1900; /* by making kosher */ - mon = 0; /* Since year was given, default */ - day = 1; /* for remaining specs is zero */ - } - if(year < 70 || 70+134 < year ) /* Check range */ - return(0); /* ERR: year out of range */ - leap = year&03 ? 0 : 1; /* See if leap year */ - year -= 70; /* UNIX time starts at 1970 */ - - /* - * Find day of year. - * YDAY is used only if it exists and either the month or day-of-month - * is missing. - */ - if (tp->tm_yday != TMNULL - && (tp->tm_mon == TMNULL || tp->tm_mday == TMNULL)) - yday = tp->tm_yday; - else - { if(tp->tm_mon != TMNULL) - { mon = tp->tm_mon; /* Month was specified */ - day = 1; /* so set remaining default */ - } - if(mon < 0 || 11 < mon) return(0); /* ERR: bad month */ - if(tp->tm_mday != TMNULL) day = tp->tm_mday; - if(day < 1 - || (((daytb[mon+1]-daytb[mon]) < day) - && (day!=29 || mon!=1 || !leap) )) - return(0); /* ERR: bad day */ - yday = daytb[mon] /* Add # of days in months so far */ - + ((leap /* Leap year, and past Feb? If */ - && mon>1)? 1:0) /* so, add leap day for this year */ - + day-1; /* And finally add # days this mon */ - - if (tp->tm_yday != TMNULL /* Confirm that YDAY correct */ - && tp->tm_yday != yday) return(0); /* ERR: conflict */ - } - if(yday < 0 || (leap?366:365) <= yday) - return(0); /* ERR: bad YDAY or maketime bug */ - - tres = year*365 /* Get # days of years so far */ - + ((year+1)>>2) /* plus # of leap days since 1970 */ - + yday; /* and finally add # days this year */ - - if((i = tp->tm_wday) != TMNULL) /* Check WDAY if present */ - if(i < 0 || 6 < i /* Ensure within range */ - || i != (tres+4)%7) /* Matches? Jan 1,1970 was Thu = 4 */ - return(0); /* ERR: bad WDAY */ - -#ifdef DEBUG -printf("YMD: %d %d %d, T=%ld\n",year,mon,day,tres); -#endif - /* - * Now determine time. If not given, default to zeros - * (since time is always the least global spec) - */ - tres *= 86400L; /* Get # seconds (24*60*60) */ - hour = min = sec = 0; - if(tp->tm_hour != TMNULL) hour = tp->tm_hour; - if(tp->tm_min != TMNULL) min = tp->tm_min; - if(tp->tm_sec != TMNULL) sec = tp->tm_sec; - if( min < 0 || 60 <= min - || sec < 0 || 60 <= sec) return(0); /* ERR: MS out of range */ - if(hour < 0 || 24 <= hour) - if(hour != 24 || (min+sec) !=0) /* Allow 24:00 */ - return(0); /* ERR: H out of range */ - - /* confirm AM/PM if there */ - switch(tp->tm_ampm) - { case 0: case TMNULL: /* Ignore these values */ - break; - case 1: /* AM */ - case 2: /* PM */ - if(hour > 12) return(0); /* ERR: hrs 13-23 bad */ - if(hour ==12) hour = 0; /* Modulo 12 */ - if(tp->tm_ampm == 2) /* If PM, then */ - hour += 12; /* get 24-hour time */ - break; - default: return(0); /* ERR: illegal TM_AMPM value */ - } - - tres += sec + 60L*(min + 60L*hour); /* Add in # secs of time */ - -#ifdef DEBUG -printf("HMS: %d %d %d T=%ld\n",hour,min,sec,tres); -#endif - /* - * We now have the GMT date/time and must make final - * adjustment for the specified time zone. If none is specified, - * the local time-zone is assumed. - */ - if((zone = tp->tm_zon) == TMNULL /* If unspecified */ - || (zone == 1)) /* or local-zone requested */ - zone = localzone(); /* then set to local zone */ - if(zone < -24*60 || 24*60 <= zone) - return(0); /* ERR: zone out of range */ - - /* See if must apply Daylight Saving Time shift. - * Note that if DST is specified, validity is not checked. - */ - if((dst = tp->tm_isdst) == TMNULL) /* Must we figure it out? */ - { curtim = tres +localzone()*60L; /* Yuck. Get equiv local */ - dst = localtime(&curtim)->tm_isdst; /* time, and ask. */ - } - tres += zone*60L -(dst?3600:0); /* Add in # seconds of zone adj */ - - return(tres); -} diff --git a/usr.bin/rcs/src/merge.sh b/usr.bin/rcs/src/merge.sh deleted file mode 100644 index 18df94698e69..000000000000 --- a/usr.bin/rcs/src/merge.sh +++ /dev/null @@ -1,53 +0,0 @@ - -# $Id: merge.sh,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ - -PATH=/bin:/usr/bin -DIFF=/bin/diff -DIFF3=/usr/local/lib/rdiff3 -p=w -case $1 in --p) - p='1,$p' - shift -esac - -case $# in -0|1|2) - echo >&2 "merge: usage: merge [-p] file1 file2 file3" - exit 1 -esac - -case $p in -w) - if test ! -w $1 - then - echo >&2 "$1 not writeable" - exit 1 - fi -esac - -trap 's=$?; rm -f /tmp/d3a$$ /tmp/d3b$$; exit $s' 0 -trap exit 1 2 3 13 15 -umask 077 - -$DIFF $1 $3 >/tmp/d3a$$ -case $? in -0|1) ;; -*) exit -esac - -$DIFF $2 $3 >/tmp/d3b$$ -case $? in -0|1) ;; -*) exit -esac - -{ - $DIFF3 -E /tmp/d3a$$ /tmp/d3b$$ $1 $2 $3 $4 $5 - case $? in - 0) ;; - 1) echo >&2 merge: warning: 1 overlap during merge.;; - *) echo >&2 merge: warning: $? overlaps during merge. - esac - echo $p -} | ed - $1 diff --git a/usr.bin/rcs/src/partime.c b/usr.bin/rcs/src/partime.c deleted file mode 100644 index e1435463561a..000000000000 --- a/usr.bin/rcs/src/partime.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - * PARTIME parse date/time string into a TM structure - * - * Usage: - * #include "time.h" -- expanded tm structure - * char *str; struct tm *tp; - * partime(str,tp); - * Returns: - * 0 if parsing failed - * else time values in specified TM structure (unspecified values - * set to TMNULL) - * Notes: - * This code is quasi-public; it may be used freely in like software. - * It is not to be sold, nor used in licensed software without - * permission of the author. - * For everyone's benefit, please report bugs and improvements! - * Copyright 1980 by Ken Harrenstien, SRI International. - * (ARPANET: KLH @ SRI) - */ - -/* Hacknotes: - * If parsing changed so that no backup needed, could perhaps modify - * to use a FILE input stream. Need terminator, though. - * Perhaps should return 0 on success, else a non-zero error val? - * Flush AMPM from TM structure and handle locally within PARTIME, - * like midnight/noon? - */ - -#ifndef lint -static char rcsid[]= -"$Header: /cvsroot/src/usr.bin/rcs/src/Attic/partime.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $"; -#endif - -/* $Log: partime.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 1.4 89/05/01 14:48:46 narten - * fixed #ifdef DEBUG construct - * - * Revision 1.3 88/11/08 12:02:15 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 1.3 88/08/28 14:53:40 eggert - * Remove unportable "#endif XXX"s. - * - * Revision 1.2 87/03/27 14:21:53 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:07 kcs - * Initial revision - * - * Revision 1.1 82/05/06 11:38:26 wft - * Initial revision - * - */ - -#include <stdio.h> -#include <ctype.h> -#include "time.h" - -#ifndef lint -static char timeid[] = TIMEID; -#endif - -struct tmwent { - char *went; - long wval; /* must be big enough to hold pointer or integer */ - char wflgs; - char wtype; -}; - /* wflgs */ -#define TWSPEC 01 /* Word wants special processing */ -#define TWTIME 02 /* Word is a time value (absence implies date) */ -#define TWDST 04 /* Word is a DST-type timezone */ -#define TW1200 010 /* Word is NOON or MIDNIGHT (sigh) */ - -int pt12hack(); -int ptnoise(); -struct tmwent tmwords [] = { - {"january", 0, 0, TM_MON}, - {"february", 1, 0, TM_MON}, - {"march", 2, 0, TM_MON}, - {"april", 3, 0, TM_MON}, - {"may", 4, 0, TM_MON}, - {"june", 5, 0, TM_MON}, - {"july", 6, 0, TM_MON}, - {"august", 7, 0, TM_MON}, - {"september", 8, 0, TM_MON}, - {"october", 9, 0, TM_MON}, - {"november", 10, 0, TM_MON}, - {"december", 11, 0, TM_MON}, - - {"sunday", 0, 0, TM_WDAY}, - {"monday", 1, 0, TM_WDAY}, - {"tuesday", 2, 0, TM_WDAY}, - {"wednesday", 3, 0, TM_WDAY}, - {"thursday", 4, 0, TM_WDAY}, - {"friday", 5, 0, TM_WDAY}, - {"saturday", 6, 0, TM_WDAY}, - - {"gmt", 0*60, TWTIME, TM_ZON}, /* Greenwich */ - {"gst", 0*60, TWTIME, TM_ZON}, - {"gdt", 0*60, TWTIME+TWDST, TM_ZON}, /* ?? */ - - {"ast", 4*60, TWTIME, TM_ZON}, /* Atlantic */ - {"est", 5*60, TWTIME, TM_ZON}, /* Eastern */ - {"cst", 6*60, TWTIME, TM_ZON}, /* Central */ - {"mst", 7*60, TWTIME, TM_ZON}, /* Mountain */ - {"pst", 8*60, TWTIME, TM_ZON}, /* Pacific */ - {"yst", 9*60, TWTIME, TM_ZON}, /* Yukon */ - {"hst", 10*60, TWTIME, TM_ZON}, /* Hawaii */ - {"bst", 11*60, TWTIME, TM_ZON}, /* Bering */ - - {"adt", 4*60, TWTIME+TWDST, TM_ZON}, /* Atlantic */ - {"edt", 5*60, TWTIME+TWDST, TM_ZON}, /* Eastern */ - {"cdt", 6*60, TWTIME+TWDST, TM_ZON}, /* Central */ - {"mdt", 7*60, TWTIME+TWDST, TM_ZON}, /* Mountain */ - {"pdt", 8*60, TWTIME+TWDST, TM_ZON}, /* Pacific */ - {"ydt", 9*60, TWTIME+TWDST, TM_ZON}, /* Yukon */ - {"hdt", 10*60, TWTIME+TWDST, TM_ZON}, /* Hawaii */ - {"bdt", 11*60, TWTIME+TWDST, TM_ZON}, /* Bering */ - - {"daylight", 1, TWTIME+TWDST, TM_ZON}, /* Local Daylight */ - {"standard", 1, TWTIME, TM_ZON}, /* Local Standard */ - {"std", 1, TWTIME, TM_ZON}, /* " " */ - - {"am", 1, TWTIME, TM_AMPM}, - {"pm", 2, TWTIME, TM_AMPM}, - {"noon", 12,TWTIME+TW1200, 0}, /* Special frobs */ - {"midnight", 0, TWTIME+TW1200, 0}, - {"at", (long)ptnoise, TWSPEC, 0}, /* Noise word */ - - {0, 0, 0, 0}, /* Zero entry to terminate searches */ -}; - -#define TMWILD (-2) /* Value meaning item specified as wild-card */ - /* (May use someday...) */ - -struct token { - char *tcp; /* pointer to string */ - int tcnt; /* # chars */ - char tbrk; /* "break" char */ - char tbrkl; /* last break char */ - char tflg; /* 0 = alpha, 1 = numeric */ - union { /* Resulting value; */ - int tnum;/* either a #, or */ - struct tmwent *ttmw;/* ptr to a tmwent. */ - } tval; -}; - -partime(astr, atm) -char *astr; -struct tm *atm; -{ register int *tp; - register struct tmwent *twp; - register int i; - struct token btoken, atoken; - char *cp, ch; - int ord, midnoon; - int (*aproc)(); - - tp = (int *)atm; - zaptime(tp); /* Initialize the TM structure */ - midnoon = TMNULL; /* and our own temp stuff */ - btoken.tcnt = btoken.tbrkl = 0; - btoken.tcp = astr; - -domore: - if(!ptitoken(btoken.tcp+btoken.tcnt,&btoken)) /* Get a token */ - { if(btoken.tval.tnum) return(0); /* Read error? */ - if(midnoon != TMNULL) /* EOF, wrap up */ - return(pt12hack(tp, midnoon)); - return(1); /* Win return! */ - } - if(btoken.tflg == 0) /* Alpha? */ - { twp = btoken.tval.ttmw; /* Yes, get ptr to entry */ - if(twp->wflgs&TWSPEC) /* Special alpha crock */ - { aproc = (int (*) ()) (twp->wval); - if(!(*aproc)(tp, twp, &btoken)) - return(0); /* ERR: special word err */ - goto domore; - } - if(twp->wflgs&TW1200) - if(ptstash(&midnoon,(int)twp->wval)) - return(0); /* ERR: noon/midnite clash */ - else goto domore; - if(ptstash(&tp[twp->wtype],(int)twp->wval)) - return(0); /* ERR: val already set */ - if(twp->wtype == TM_ZON) /* If was zone, hack DST */ - if(ptstash(&tp[TM_ISDST],(twp->wflgs&TWDST))) - return(0); /* ERR: DST conflict */ - goto domore; - } - - /* Token is number. Lots of hairy heuristics. */ - if(btoken.tcnt >= 7) /* More than 6 digits in string? */ - return(0); /* ERR: number too big */ - if(btoken.tcnt == 6) /* 6 digits = HHMMSS. Needs special crock */ - { /* since 6 digits are too big for integer! */ - i = (btoken.tcp[0]-'0')*10 /* Gobble 1st 2 digits */ - + btoken.tcp[1]-'0'; - btoken.tcnt = 2; /* re-read last 4 chars */ - goto coltime; - } - - i = btoken.tval.tnum; /* Value now known to be valid; get it. */ - if( btoken.tcnt == 5 /* 5 digits = HMMSS */ - || btoken.tcnt == 3) /* 3 digits = HMM */ - { if(btoken.tcnt != 3) - if(ptstash(&tp[TM_SEC], i%100)) - return(0); /* ERR: sec conflict */ - else i /= 100; -hhmm4: if(ptstash(&tp[TM_MIN], i%100)) - return(0); /* ERR: min conflict */ - i /= 100; -hh2: if(ptstash(&tp[TM_HOUR], i)) - return(0); /* ERR: hour conflict */ - goto domore; - } - - if(btoken.tcnt == 4) /* 4 digits = YEAR or HHMM */ - { if(tp[TM_YEAR] != TMNULL) goto hhmm4; /* Already got yr? */ - if(tp[TM_HOUR] != TMNULL) goto year4; /* Already got hr? */ - if((i%100) > 59) goto year4; /* MM >= 60? */ - if(btoken.tbrk == ':') /* HHMM:SS ? */ - if( ptstash(&tp[TM_HOUR],i/100) - || ptstash(&tp[TM_MIN], i%100)) - return(0); /* ERR: hr/min clash */ - else goto coltm2; /* Go handle SS */ - if(btoken.tbrk != ',' && btoken.tbrk != '/' - && ptitoken(btoken.tcp+btoken.tcnt,&atoken) /* Peek */ - && atoken.tflg == 0 /* alpha */ - && (atoken.tval.ttmw->wflgs&TWTIME)) /* HHMM-ZON */ - goto hhmm4; - if(btoken.tbrkl == '-' /* DD-Mon-YYYY */ - || btoken.tbrkl == ',' /* Mon DD, YYYY */ - || btoken.tbrkl == '/' /* MM/DD/YYYY */ - || btoken.tbrkl == '.' /* DD.MM.YYYY */ - || btoken.tbrk == '-' /* YYYY-MM-DD */ - ) goto year4; - goto hhmm4; /* Give up, assume HHMM. */ - } - - /* From this point on, assume tcnt == 1 or 2 */ - /* 2 digits = YY, MM, DD, or HH (MM and SS caught at coltime) */ - if(btoken.tbrk == ':') /* HH:MM[:SS] */ - goto coltime; /* must be part of time. */ - if(i > 31) goto yy2; /* If >= 32, only YY poss. */ - - /* Check for numerical-format date */ - for (cp = "/-."; ch = *cp++;) - { ord = (ch == '.' ? 0 : 1); /* n/m = D/M or M/D */ - if(btoken.tbrk == ch) /* "NN-" */ - { if(btoken.tbrkl != ch) - { if(ptitoken(btoken.tcp+btoken.tcnt,&atoken) - && atoken.tflg == 0 - && atoken.tval.ttmw->wtype == TM_MON) - goto dd2; - if(ord)goto mm2; else goto dd2; /* "NN-" */ - } /* "-NN-" */ - if(tp[TM_DAY] == TMNULL - && tp[TM_YEAR] != TMNULL) /* If "YY-NN-" */ - goto mm2; /* then always MM */ - if(ord)goto dd2; else goto mm2; - } - if(btoken.tbrkl == ch /* "-NN" */ - && tp[ord ? TM_MON : TM_DAY] != TMNULL) - if(tp[ord ? TM_DAY : TM_MON] == TMNULL) /* MM/DD */ - if(ord)goto dd2; else goto mm2; - else goto yy2; /* "-YY" */ - } - - /* At this point only YY, DD, and HH are left. - * YY is very unlikely since value is <= 32 and there was - * no numerical format date. Make one last try at YY - * before dropping through to DD vs HH code. - */ - if(btoken.tcnt == 2 /* If 2 digits */ - && tp[TM_HOUR] != TMNULL /* and already have hour */ - && tp[TM_DAY] != TMNULL /* and day, but */ - && tp[TM_YEAR] == TMNULL) /* no year, then assume */ - goto yy2; /* that's what we have. */ - - /* Now reduced to choice between HH and DD */ - if(tp[TM_HOUR] != TMNULL) goto dd2; /* Have hour? Assume day. */ - if(tp[TM_DAY] != TMNULL) goto hh2; /* Have day? Assume hour. */ - if(i > 24) goto dd2; /* Impossible HH means DD */ - if(!ptitoken(btoken.tcp+btoken.tcnt, &atoken)) /* Read ahead! */ - if(atoken.tval.tnum) return(0); /* ERR: bad token */ - else goto dd2; /* EOF, assume day. */ - if( atoken.tflg == 0 /* If next token is an alpha */ - && atoken.tval.ttmw->wflgs&TWTIME) /* time-spec, assume hour */ - goto hh2; /* e.g. "3 PM", "11-EDT" */ - -dd2: if(ptstash(&tp[TM_DAY],i)) /* Store day (1 based) */ - return(0); - goto domore; - -mm2: if(ptstash(&tp[TM_MON], i-1)) /* Store month (make zero based) */ - return(0); - goto domore; - -yy2: i += 1900; -year4: if(ptstash(&tp[TM_YEAR],i)) /* Store year (full number) */ - return(0); /* ERR: year conflict */ - goto domore; - - /* Hack HH:MM[[:]SS] */ -coltime: - if(ptstash(&tp[TM_HOUR],i)) return(0); - if(!ptitoken(btoken.tcp+btoken.tcnt,&btoken)) - return(!btoken.tval.tnum); - if(!btoken.tflg) return(0); /* ERR: HH:<alpha> */ - if(btoken.tcnt == 4) /* MMSS */ - if(ptstash(&tp[TM_MIN],btoken.tval.tnum/100) - || ptstash(&tp[TM_SEC],btoken.tval.tnum%100)) - return(0); - else goto domore; - if(btoken.tcnt != 2 - || ptstash(&tp[TM_MIN],btoken.tval.tnum)) - return(0); /* ERR: MM bad */ - if(btoken.tbrk != ':') goto domore; /* Seconds follow? */ -coltm2: if(!ptitoken(btoken.tcp+btoken.tcnt,&btoken)) - return(!btoken.tval.tnum); - if(!btoken.tflg || btoken.tcnt != 2 /* Verify SS */ - || ptstash(&tp[TM_SEC], btoken.tval.tnum)) - return(0); /* ERR: SS bad */ - goto domore; -} - -/* Store date/time value, return 0 if successful. - * Fails if entry already set to a different value. - */ -ptstash(adr,val) -int *adr; -{ register int *a; - if( *(a=adr) != TMNULL) - return(*a != val); - *a = val; - return(0); -} - -/* This subroutine is invoked for NOON or MIDNIGHT when wrapping up - * just prior to returning from partime. - */ -pt12hack(atp, aval) -int *atp, aval; -{ register int *tp, i, h; - tp = atp; - if (((i=tp[TM_MIN]) && i != TMNULL) /* Ensure mins, secs */ - || ((i=tp[TM_SEC]) && i != TMNULL)) /* are 0 or unspec'd */ - return(0); /* ERR: MM:SS not 00:00 */ - i = aval; /* Get 0 or 12 (midnite or noon) */ - if ((h = tp[TM_HOUR]) == TMNULL /* If hour unspec'd, win */ - || h == 12) /* or if 12:00 (matches either) */ - tp[TM_HOUR] = i; /* Then set time */ - else if(!(i == 0 /* Nope, but if midnight and */ - &&(h == 0 || h == 24))) /* time matches, can pass. */ - return(0); /* ERR: HH conflicts */ - tp[TM_AMPM] = TMNULL; /* Always reset this value if won */ - return(1); -} - -/* Null routine for no-op tokens */ - -ptnoise() { return(1); } - -/* Get a token and identify it to some degree. - * Returns 0 on failure; token.tval will be 0 for normal EOF, otherwise - * hit error of some sort - */ - -ptitoken(astr, tkp) -register struct token *tkp; -char *astr; -{ - register char *cp; - register int i; - - tkp->tval.tnum = 0; - if(pttoken(astr,tkp) == 0) -#ifdef DEBUG - { - VOID printf("EOF\n"); - return(0); - } -#else - return(0); -#endif - cp = tkp->tcp; - -#ifdef DEBUG - i = cp[tkp->tcnt]; - cp[tkp->tcnt] = 0; - VOID printf("Token: \"%s\" ",cp); - cp[tkp->tcnt] = i; -#endif - - if(tkp->tflg) - for(i = tkp->tcnt; i > 0; i--) - tkp->tval.tnum = (int)tkp->tval.tnum*10 + ((*cp++)-'0'); - else - { i = ptmatchstr(cp, tkp->tcnt, tmwords); - tkp->tval.tnum = i ? i : -1; /* Set -1 for error */ - -#ifdef DEBUG - if(!i) VOID printf("Not found!\n"); -#endif - - if(!i) return(0); - } - -#ifdef DEBUG - if(tkp->tflg) - VOID printf("Val: %d.\n",tkp->tval.tnum); - else VOID printf("Found: \"%s\", val: %d., type %d\n", - tkp->tval.ttmw->went,tkp->tval.ttmw->wval,tkp->tval.ttmw->wtype); -#endif - - return(1); -} - -/* Read token from input string into token structure */ -pttoken(astr,tkp) -register struct token *tkp; -char *astr; -{ - register char *cp; - register int c; - - tkp->tcp = cp = astr; - tkp->tbrkl = tkp->tbrk; /* Set "last break" */ - tkp->tcnt = tkp->tbrk = tkp->tflg = 0; - - while(c = *cp++) - { switch(c) - { case ' ': case '\t': /* Flush all whitespace */ - while((c = *cp++) && isspace(c)); - cp--; /* Drop thru to handle brk */ - case '(': case ')': /* Perhaps any non-alphanum */ - case '-': case ',': /* shd qualify as break? */ - case '/': case ':': case '.': /* Break chars */ - if(tkp->tcnt == 0) /* If no token yet */ - { tkp->tcp = cp; /* ignore the brk */ - tkp->tbrkl = c; - continue; /* and go on. */ - } - tkp->tbrk = c; - return(tkp->tcnt); - } - if(tkp->tcnt == 0) /* If first char of token, */ - tkp->tflg = isdigit(c); /* determine type */ - if(( isdigit(c) && tkp->tflg) /* If not first, make sure */ - ||(!isdigit(c) && !tkp->tflg)) /* char matches type */ - tkp->tcnt++; /* Win, add to token. */ - else { - cp--; /* Wrong type, back up */ - tkp->tbrk = c; - return(tkp->tcnt); - } - } - return(tkp->tcnt); /* When hit EOF */ -} - - -ptmatchstr(astr,cnt,astruc) -char *astr; -int cnt; -struct tmwent *astruc; -{ register char *cp, *mp; - register int c; - struct tmwent *lastptr; - struct integ { int word; }; /* For getting at array ptr */ - int i; - - lastptr = 0; - for(;mp = (char *)((struct integ *)astruc)->word; astruc += 1) - { cp = astr; - for(i = cnt; i > 0; i--) - { switch((c = *cp++) ^ *mp++) /* XOR the chars */ - { case 0: continue; /* Exact match */ - case 040: if(isalpha(c)) - continue; - } - break; - } - if(i==0) - if(*mp == 0) return((unsigned int)astruc); /* Exact match */ - else if(lastptr) return(0); /* Ambiguous */ - else lastptr = astruc; /* 1st ambig */ - } - return((unsigned int)lastptr); -} - - - -zaptime(tp) -register int *tp; -/* clears tm structure pointed to by tp */ -{ register int i; - i = (sizeof (struct tm))/(sizeof (int)); - do *tp++ = TMNULL; /* Set entry to "unspecified" */ - while(--i); /* Faster than FOR */ -} diff --git a/usr.bin/rcs/src/rcs.c b/usr.bin/rcs/src/rcs.c deleted file mode 100644 index a9ea6062e137..000000000000 --- a/usr.bin/rcs/src/rcs.c +++ /dev/null @@ -1,1562 +0,0 @@ -/* - * RCS create/change operation - */ -#ifndef lint -static char rcsid[]= -"$Header: /cvsroot/src/usr.bin/rcs/src/Attic/rcs.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - - -/* $Log: rcs.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.11 89/05/01 15:12:06 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.10 88/11/08 16:01:54 narten - * didn't install previous patch correctly - * - * Revision 4.9 88/11/08 13:56:01 narten - * removed include <sysexits.h> (not needed) - * minor fix for -A option - * - * Revision 4.8 88/11/08 12:01:58 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.8 88/08/09 19:12:27 eggert - * Don't access freed storage. - * Use execv(), not system(); yield proper exit status; remove lint. - * - * Revision 4.7 87/12/18 11:37:17 narten - * lint cleanups (Guy Harris) - * - * Revision 4.6 87/10/18 10:28:48 narten - * Updating verison numbers. Changes relative to 1.1 are actually - * relative to 4.3 - * - * Revision 1.4 87/09/24 13:58:52 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.3 87/03/27 14:21:55 jenkins - * Port to suns - * - * Revision 1.2 85/12/17 13:59:09 albitz - * Changed setstate to rcs_setstate because of conflict with random.o. - * - * Revision 1.1 84/01/23 14:50:09 kcs - * Initial revision - * - * Revision 4.3 83/12/15 12:27:33 wft - * rcs -u now breaks most recent lock if it can't find a lock by the caller. - * - * Revision 4.2 83/12/05 10:18:20 wft - * Added conditional compilation for sending mail. - * Alternatives: V4_2BSD, V6, USG, and other. - * - * Revision 4.1 83/05/10 16:43:02 wft - * Simplified breaklock(); added calls to findlock() and getcaller(). - * Added option -b (default branch). Updated -s and -w for -b. - * Removed calls to stat(); now done by pairfilenames(). - * Replaced most catchints() calls with restoreints(). - * Removed check for exit status of delivermail(). - * Directed all interactive output to stderr. - * - * Revision 3.9.1.1 83/12/02 22:08:51 wft - * Added conditional compilation for 4.2 sendmail and 4.1 delivermail. - * - * Revision 3.9 83/02/15 15:38:39 wft - * Added call to fastcopy() to copy remainder of RCS file. - * - * Revision 3.8 83/01/18 17:37:51 wft - * Changed sendmail(): now uses delivermail, and asks whether to break the lock. - * - * Revision 3.7 83/01/15 18:04:25 wft - * Removed putree(); replaced with puttree() in rcssyn.c. - * Combined putdellog() and scanlogtext(); deleted putdellog(). - * Cleaned up diagnostics and error messages. Fixed problem with - * mutilated files in case of deletions in 2 files in a single command. - * Changed marking of selector from 'D' to DELETE. - * - * Revision 3.6 83/01/14 15:37:31 wft - * Added ignoring of interrupts while new RCS file is renamed; - * Avoids deletion of RCS files by interrupts. - * - * Revision 3.5 82/12/10 21:11:39 wft - * Removed unused variables, fixed checking of return code from diff, - * introduced variant COMPAT2 for skipping Suffix on -A files. - * - * Revision 3.4 82/12/04 13:18:20 wft - * Replaced getdelta() with gettree(), changed breaklock to update - * field lockedby, added some diagnostics. - * - * Revision 3.3 82/12/03 17:08:04 wft - * Replaced getlogin() with getpwuid(), flcose() with ffclose(), - * /usr/ucb/Mail with macro MAIL. Removed handling of Suffix (-x). - * fixed -u for missing revno. Disambiguated structure members. - * - * Revision 3.2 82/10/18 21:05:07 wft - * rcs -i now generates a file mode given by the umask minus write permission; - * otherwise, rcs keeps the mode, but removes write permission. - * I added a check for write error, fixed call to getlogin(), replaced - * curdir() with getfullRCSname(), cleaned up handling -U/L, and changed - * conflicting, long identifiers. - * - * Revision 3.1 82/10/13 16:11:07 wft - * fixed type of variables receiving from getc() (char -> int). - */ - - -#include <sys/types.h> -#include <sys/stat.h> -#include "rcsbase.h" -#include <paths.h> -#ifndef lint -static char rcsbaseid[] = RCSBASE; -#endif - -extern FILE * fopen(); -extern char * bindex(); -extern int expandsym(); /* get numeric revision name */ -extern struct hshentry * getnum(); -extern struct lock * addlock(); /* add a lock */ -extern char * getid(); -extern char Klog[], Khead[], Kaccess[], Kbranch[], Ktext[]; -#ifdef COMPAT2 -extern char Ksuffix[]; -#endif -extern char * getcaller(); /* get login of caller */ -extern struct hshentry * findlock(); /* find and remove lock */ -extern struct hshentry * genrevs(); -extern char * checkid(); /* check an identifier */ -extern char * getfullRCSname(); /* get full path name of RCS file */ -extern char * mktempfile(); /* temporary file name generator */ -extern free(); -extern void catchints(); -extern void ignoreints(); -extern int nerror; /* counter for errors */ -extern int quietflag; /* diagnoses suppressed if true */ -extern char curlogmsg[]; /* current log message */ -extern char * resultfile; /* filename for fcopy */ -extern FILE *fcopy; /* result file during editing */ -extern FILE * finptr; /* RCS input file */ -extern FILE * frewrite; /* new RCS file */ -extern int rewriteflag; /* indicates whether input should be*/ - /* echoed to frewrite */ - -char * newRCSfilename, * diffilename, * cutfilename; -char * RCSfilename, * workfilename; -extern struct stat RCSstat, workstat; /* file status of RCS and work file */ -extern int haveRCSstat, haveworkstat;/* status indicators */ - -char accessorlst[strtsize]; -FILE * fcut; /* temporary file to rebuild delta tree */ -int oldumask; /* save umask */ - -int initflag, strictlock, strict_selected, textflag; -char * textfile, * accessfile; -char * caller, numrev[30]; /* caller's login; */ -struct access * newaccessor, * rmvaccessor, * rplaccessor; -struct access *curaccess, *rmaccess; -struct hshentry * gendeltas[hshsize]; - -struct Lockrev { - char * revno; - struct Lockrev * nextrev; -}; - -struct Symrev { - char * revno; - char * ssymbol; - int override; - struct Symrev * nextsym; -}; - -struct Status { - char * revno; - char * status; - struct Status * nextstatus; -}; - -struct delrevpair { - char * strt; - char * end; - int code; -}; - -struct Lockrev * newlocklst, * rmvlocklst; -struct Symrev * assoclst, * lastassoc; -struct Status * statelst, * laststate; -struct delrevpair * delrev; -struct hshentry * cuthead, *cuttail, * delstrt; -char branchnum[revlength], * branchsym; -struct hshentry branchdummy; -char * commsyml; -char * headstate; -int lockhead,unlockcaller,chgheadstate,branchflag,commentflag; -int delaccessflag; -enum stringwork {copy, edit, empty}; /* expand and edit_expand not needed */ - - -main (argc, argv) -int argc; -char * argv[]; -{ - char *comdusge; - int result; - struct access *removeaccess(), * getaccessor(); - struct Lockrev *rmnewlocklst(); - struct Lockrev *curlock, * rmvlock, *lockpt; - struct Status * curstate; - struct access *temp, *temptr; - int status; - - status = 0; - nerror = 0; - catchints(); - cmdid = "rcs"; - quietflag = false; - comdusge ="command format:\nrcs -i -alogins -Alogins -e[logins] -b[rev] -c[commentleader] -l[rev] -u[rev] -L -U -nname[:rev] -Nname[:rev] -orange -sstate[:rev] -t[textfile] file...."; - rplaccessor = nil; delstrt = nil; - accessfile = textfile = caller = nil; - branchflag = commentflag = chgheadstate = false; - lockhead = false; unlockcaller=false; - initflag= textflag = false; - strict_selected = 0; - - caller=getcaller(); - laststate = statelst = nil; - lastassoc = assoclst = nil; - curlock = rmvlock = newlocklst = rmvlocklst = nil; - curaccess = rmaccess = rmvaccessor = newaccessor = nil; - delaccessflag = false; - - /* preprocessing command options */ - while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) { - switch ((*argv)[1]) { - - case 'i': /* initail version */ - initflag = true; - break; - - case 'b': /* change default branch */ - if (branchflag)warn("Redfinition of option -b"); - branchflag= true; - branchsym = (*argv)+2; - break; - - case 'c': /* change comment symbol */ - if (commentflag)warn("Redefinition of option -c"); - commentflag = true; - commsyml = (*argv)+2; - break; - - case 'a': /* add new accessor */ - if ( (*argv)[2] == '\0') { - error("Login name missing after -a"); - } - if ( (temp = getaccessor((*argv)+1)) ) { - if ( newaccessor ) - curaccess->nextaccess = temp->nextaccess; - else - newaccessor = temp->nextaccess; - temp->nextaccess = nil; - curaccess = temp; - } - break; - - case 'A': /* append access list according to accessfile */ - if ( (*argv)[2] == '\0') { - error("Missing file name after -A"); - break; - } - if ( accessfile) warn("Redefinition of option -A"); - *argv = *argv+2; - if( pairfilenames(1, argv, true, false) > 0) { - releaselst(newaccessor); - newaccessor = curaccess = nil; - releaselst(rmvaccessor); - rmvaccessor = rmaccess = nil; - accessfile = RCSfilename; - } - else - accessfile = nil; - break; - - case 'e': /* remove accessors */ - if ( (*argv)[2] == '\0' ) { - delaccessflag = true; - break; - } - if ( (temp = getaccessor((*argv)+1)) ) { - if ( rmvaccessor ) - rmaccess->nextaccess = temp->nextaccess; - else - rmvaccessor = temp->nextaccess; - temptr = temp->nextaccess; - temp->nextaccess = nil; - rmaccess = temp; - while( temptr ) { - newaccessor = removeaccess(temptr,newaccessor,false); - temptr = temptr->nextaccess; - } - curaccess = temp = newaccessor; - while( temp){ - curaccess = temp; - temp = temp->nextaccess; - } - } - break; - - case 'l': /* lock a revision if it is unlocked */ - if ( (*argv)[2] == '\0'){ /* lock head or def. branch */ - lockhead = true; - break; - } - lockpt = (struct Lockrev *)talloc(sizeof(struct Lockrev)); - lockpt->revno = (*argv)+2; - lockpt->nextrev = nil; - if ( curlock ) - curlock->nextrev = lockpt; - else - newlocklst = lockpt; - curlock = lockpt; - break; - - case 'u': /* release lock of a locked revision */ - if ( (*argv)[2] == '\0'){ /* unlock head */ - unlockcaller=true; - break; - } - lockpt = (struct Lockrev *)talloc(sizeof(struct Lockrev)); - lockpt->revno = (*argv)+2; - lockpt->nextrev = nil; - if (rmvlock) - rmvlock->nextrev = lockpt; - else - rmvlocklst = lockpt; - rmvlock = lockpt; - - curlock = rmnewlocklst(lockpt); - break; - - case 'L': /* set strict locking */ - if (strict_selected++) { /* Already selected L or U? */ - if (!strictlock) /* Already selected -U? */ - warn("Option -L overrides -U"); - } - strictlock = true; - break; - - case 'U': /* release strict locking */ - if (strict_selected++) { /* Already selected L or U? */ - if (strictlock) /* Already selected -L? */ - warn("Option -L overrides -U"); - } - else - strictlock = false; - break; - - case 'n': /* add new association: error, if name exists */ - if ( (*argv)[2] == '\0') { - error("Missing symbolic name after -n"); - break; - } - getassoclst(false, (*argv)+1); - break; - - case 'N': /* add or change association */ - if ( (*argv)[2] == '\0') { - error("Missing symbolic name after -N"); - break; - } - getassoclst(true, (*argv)+1); - break; - - case 'o': /* delete revisins */ - if (delrev) warn("Redefinition of option -o"); - if ( (*argv)[2] == '\0' ) { - error("Missing revision range after -o"); - break; - } - getdelrev( (*argv)+1 ); - break; - - case 's': /* change state attribute of a revision */ - if ( (*argv)[2] == '\0') { - error("State missing after -s"); - break; - } - getstates( (*argv)+1); - break; - - case 't': /* change descriptive text */ - textflag=true; - if ((*argv)[2]!='\0'){ - if (textfile!=nil)warn("Redefinition of -t option"); - textfile = (*argv)+2; - } - break; - - case 'q': - quietflag = true; - break; - default: - faterror("Unknown option: %s\n%s", *argv, comdusge); - }; - } /* end processing of options */ - - if (argc<1) faterror("No input file\n%s", comdusge); - if (nerror) { /* exit, if any error in command options */ - diagnose("%s aborted",cmdid); - exit(1); - } - if (accessfile) /* get replacement for access list */ - getrplaccess(); - if (nerror) { - diagnose("%s aborted",cmdid); - exit(1); - } - - /* now handle all filenames */ - do { - rewriteflag = false; - finptr=frewrite=NULL; - - if ( initflag ) { - switch( pairfilenames(argc, argv, false, false) ) { - case -1: break; /* not exist; ok */ - case 0: continue; /* error */ - case 1: error("file %s exists already", RCSfilename); - VOID fclose(finptr); - continue; - } - } - else { - switch( pairfilenames(argc, argv, true, false) ) { - case -1: continue; /* not exist */ - case 0: continue; /* errors */ - case 1: break; /* file exists; ok*/ - } - } - - - /* now RCSfilename contains the name of the RCS file, and - * workfilename contains the name of the working file. - * if !initflag, finptr contains the file descriptor for the - * RCS file. The admin node is initialized. - */ - - diagnose("RCS file: %s", RCSfilename); - - if (!trydiraccess(RCSfilename)) continue; /* give up */ - if (!initflag && !checkaccesslist(caller)) continue; /* give up */ - if (!trysema(RCSfilename,true)) continue; /* give up */ - - gettree(); /* read in delta tree */ - - /* update admin. node */ - if (strict_selected) StrictLocks = strictlock; - if (commentflag) Comment = commsyml; - - /* update default branch */ - if (branchflag && expandsym(branchsym, branchnum)) { - if (countnumflds(branchnum)>0) { - branchdummy.num=branchnum; - Dbranch = &branchdummy; - } else - Dbranch = nil; - } - - /* update access list */ - if ( delaccessflag ) AccessList = nil; - if ( accessfile ) { - temp = rplaccessor; - while( temp ) { - temptr = temp->nextaccess; - if ( addnewaccess(temp) ) - temp->nextaccess = nil; - temp = temptr; - } - } - temp = rmvaccessor; - while(temp) { /* remove accessors from accesslist */ - AccessList = removeaccess(temp, AccessList,true); - temp = temp->nextaccess; - } - temp = newaccessor; - while( temp) { /* add new accessors */ - temptr = temp->nextaccess; - if ( addnewaccess( temp ) ) - temp->nextaccess = nil; - temp = temptr; - } - - updateassoc(); /* update association list */ - - updatelocks(); /* update locks */ - - /* update state attribution */ - if (chgheadstate) { - /* change state of default branch or head */ - if (Dbranch==nil) { - if (Head==nil) - warn("Can't change states in an empty tree"); - else Head->state = headstate; - } else { - rcs_setstate(Dbranch->num,headstate); /* Can't set directly */ - } - } - curstate = statelst; - while( curstate ) { - rcs_setstate(curstate->revno,curstate->status); - curstate = curstate->nextstatus; - } - - cuthead = cuttail = nil; - if ( delrev && removerevs()) { - /* rebuild delta tree if some deltas are deleted */ - if ( cuttail ) - VOID genrevs(cuttail->num, (char *)nil,(char *)nil, - (char *)nil, gendeltas); - buildtree(); - } - - - /* prepare for rewriting the RCS file */ - newRCSfilename=mktempfile(RCSfilename,NEWRCSFILE); - oldumask = umask(0222); /* turn off write bits */ - if ((frewrite=fopen(newRCSfilename, "w"))==NULL) { - VOID fclose(finptr); - error("Can't open file %s",newRCSfilename); - continue; - } - VOID umask(oldumask); - putadmin(frewrite); - if ( Head ) - puttree(Head, frewrite); - putdesc(initflag,textflag,textfile,quietflag); - rewriteflag = false; - - if ( Head) { - if (!delrev) { - /* no revision deleted */ - fastcopy(finptr,frewrite); - } else { - if ( cuttail ) - buildeltatext(gendeltas); - else - scanlogtext((struct hshentry *)nil,empty); - /* copy rest of delta text nodes that are not deleted */ - } - } - ffclose(frewrite); frewrite = NULL; - if ( ! nerror ) { /* move temporary file to RCS file if no error */ - ignoreints(); /* ignore interrupts */ - if(rename(newRCSfilename,RCSfilename)<0) { - error("Can't create RCS file %s; saved in %s", - RCSfilename, newRCSfilename); - newRCSfilename[0] = '\0'; /* avoid deletion by cleanup */ - restoreints(); - VOID cleanup(); - break; - } - newRCSfilename[0]='\0'; /* avoid re-unlinking by cleanup()*/ - /* update mode */ - result=0; - if (!initflag) /* preserve mode bits */ - result=chmod(RCSfilename,RCSstat.st_mode & ~0222); - elsif (haveworkstat==0) /* initialization, and work file exists */ - result=chmod(RCSfilename,workstat.st_mode & ~0222); - if (result<0) warn("Can't set mode of %s",RCSfilename); - - restoreints(); /* catch them all again */ - diagnose("done"); - } else { - diagnose("%s aborted; %s unchanged.",cmdid,RCSfilename); - status = 1; - nerror = 0; - } - } while (cleanup(), - ++argv, --argc >=1); - - exit(status); -} /* end of main (rcs) */ - - - -getassoclst(flag, sp) -int flag; -char * sp; -/* Function: associate a symbolic name to a revision or branch, */ -/* and store in assoclst */ - -{ - struct Symrev * pt; - char * temp, *temp2; - int c; - - while( (c=(*++sp)) == ' ' || c == '\t' || c =='\n') ; - temp = sp; - temp2=checkid(sp, ':'); /* check for invalid symbolic name */ - sp = temp2; c = *sp; *sp = '\0'; - while( c == ' ' || c == '\t' || c == '\n') c = *++sp; - - if ( c != ':' && c != '\0') { - error("Invalid string %s after option -n or -N",sp); - return; - } - - pt = (struct Symrev *)talloc(sizeof(struct Symrev)); - pt->ssymbol = temp; - pt->override = flag; - if (c == '\0') /* delete symbol */ - pt->revno = nil; - else { - while( (c = *++sp) == ' ' || c == '\n' || c == '\t') ; - if ( c == '\0' ) - pt->revno = nil; - else - pt->revno = sp; - } - pt->nextsym = nil; - if (lastassoc) - lastassoc->nextsym = pt; - else - assoclst = pt; - lastassoc = pt; - return; -} - - - -struct access * getaccessor( sp) -char *sp; -/* Function: get the accessor list of options -e and -a, */ -/* and store in curpt */ - - -{ - struct access * curpt, * pt, *pre; - char *temp; - register c; - - while( ( c = *++sp) == ' ' || c == '\n' || c == '\t' || c == ',') ; - if ( c == '\0') { - error("Missing login name after option -a or -e"); - return nil; - } - - curpt = pt = nil; - while( c != '\0') { - temp=checkid(sp,','); - pt = (struct access *)talloc(sizeof(struct access)); - pt->login = sp; - if ( curpt ) - pre->nextaccess = pt; - else - curpt = pt; - pt->nextaccess = curpt; - pre = pt; - sp = temp; c = *sp; *sp = '\0'; - while( c == ' ' || c == '\n' || c == '\t'|| c == ',')c =(*++sp); - } - return pt; -} - - - -getstates(sp) -char *sp; -/* Function: get one state attribute and the corresponding */ -/* revision and store in statelst */ - -{ - char *temp, *temp2; - struct Status *pt; - register c; - - while( (c=(*++sp)) ==' ' || c == '\t' || c == '\n') ; - temp = sp; - temp2=checkid(sp,':'); /* check for invalid state attribute */ - sp = temp2; c = *sp; *sp = '\0'; - while( c == ' ' || c == '\t' || c == '\n' ) c = *++sp; - - if ( c == '\0' ) { /* change state of def. branch or Head */ - chgheadstate = true; - headstate = temp; - return; - } - else if ( c != ':' ) { - error("Missing ':' after state in option -s"); - return; - } - - while( (c = *++sp) == ' ' || c == '\t' || c == '\n') ; - pt = (struct Status *)talloc(sizeof(struct Status)); - pt->status = temp; - pt->revno = sp; - pt->nextstatus = nil; - if (laststate) - laststate->nextstatus = pt; - else - statelst = pt; - laststate = pt; -} - - - -getrplaccess() -/* Function : get the accesslist of the 'accessfile' */ -/* and place in rplaccessor */ -{ - register char *id, *nextp; - struct access *newaccess, *oldaccess; - - if ( (finptr=fopen(accessfile, "r")) == NULL) { - faterror("Can't open file %s", accessfile); - } - Lexinit(); - nextp = &accessorlst[0]; - - if ( ! getkey(Khead)) faterror("Missing head in %s", accessfile); - VOID getnum(); - if ( ! getlex(SEMI) ) serror("Missing ';' after head in %s",accessfile); - - if (getkey(Kbranch)) { /* optional */ - Dbranch=getnum(); - if (!getlex(SEMI)) serror("Missing ';' after branch list"); - } - - -#ifdef COMPAT2 - /* read suffix. Only in release 2 format */ - if (getkey(Ksuffix)) { - if (nexttok==STRING) { - readstring(); nextlex(); /*through away the suffix*/ - } elsif(nexttok==ID) { - nextlex(); - } - if ( ! getlex(SEMI) ) serror("Missing ';' after suffix in %s",accessfile); - } -#endif - - if (! getkey(Kaccess))fatserror("Missing access list in %s",accessfile); - oldaccess = nil; - while( id =getid() ) { - newaccess = (struct access *)talloc(sizeof(struct access)); - newaccess->login = nextp; - newaccess->nextaccess = nil; - while( ( *nextp++ = *id++) != '\0') ; - if ( oldaccess ) - oldaccess->nextaccess = newaccess; - else - rplaccessor = newaccess; - oldaccess = newaccess; - } - if ( ! getlex(SEMI))serror("Missing ';' after access list in %s",accessfile); - return; -} - - - -getdelrev(sp) -char *sp; -/* Function: get revision range or branch to be deleted, */ -/* and place in delrev */ -{ - int c; - struct delrevpair *pt; - - if (delrev) free((char *)delrev); - - pt = (struct delrevpair *)talloc(sizeof(struct delrevpair)); - while((c = (*++sp)) == ' ' || c == '\n' || c == '\t') ; - - if ( c == '<' || c == '-' ) { /* -o -rev or <rev */ - while( (c = (*++sp)) == ' ' || c == '\n' || c == '\t') ; - pt->strt = sp; pt->code = 1; - while( c != ' ' && c != '\n' && c != '\t' && c != '\0') c =(*++sp); - *sp = '\0'; - pt->end = nil; delrev = pt; - return; - } - else { - pt->strt = sp; - while( c != ' ' && c != '\n' && c != '\t' && c != '\0' - && c != '-' && c != '<' ) c = *++sp; - *sp = '\0'; - while( c == ' ' || c == '\n' || c == '\t' ) c = *++sp; - if ( c == '\0' ) { /* -o rev or branch */ - pt->end = nil; pt->code = 0; - delrev = pt; - return; - } - if ( c != '-' && c != '<') { - faterror("Invalid range %s %s after -o", pt->strt, sp); - free((char *)pt); - return; - } - while( (c = *++sp) == ' ' || c == '\n' || c == '\t') ; - if ( c == '\0') { /* -o rev- or rev< */ - pt->end = nil; pt->code = 2; - delrev = pt; - return; - } - } - /* -o rev1-rev2 or rev1<rev2 */ - pt->end = sp; pt->code = 3; delrev = pt; - while( c!= ' ' && c != '\n' && c != '\t' && c != '\0') c = *++sp; - *sp = '\0'; -} - - - - -scanlogtext(delta,func) -struct hshentry * delta; enum stringwork func; -/* Function: Scans delta text nodes up to and including the one given - * by delta, or up to last one present, if delta==nil. - * For the one given by delta (if delta!=nil), the log message is saved into - * curlogmsg and the text is processed according to parameter func. - * Assumes the initial lexeme must be read in first. - * Does not advance nexttok after it is finished, except if delta==nil. - */ -{ struct hshentry * nextdelta; - - do { - rewriteflag = false; - nextlex(); - if (!(nextdelta=getnum())) { - if(delta) - faterror("Can't find delta for revision %s", delta->num); - else return; /* no more delta text nodes */ - } - if ( nextdelta->selector != DELETE) { - rewriteflag = true; - VOID fprintf(frewrite,DELNUMFORM,nextdelta->num,Klog); - } - if (!getkey(Klog) || nexttok!=STRING) - serror("Missing log entry"); - elsif (delta==nextdelta) { - VOID savestring(curlogmsg,logsize); - delta->log=curlogmsg; - } else {readstring(); - if (delta!=nil) delta->log=""; - } - nextlex(); - if (!getkey(Ktext) || nexttok!=STRING) - fatserror("Missing delta text"); - - if(delta==nextdelta) - /* got the one we're looking for */ - switch (func) { - case copy: copystring(); - break; - case edit: editstring((struct hshentry *)nil); - break; - default: faterror("Wrong scanlogtext"); - } - else readstring(); /* skip over it */ - - } while (delta!=nextdelta); -} - - - -releaselst(sourcelst) -struct access * sourcelst; -/* Function: release the storages whose address are in sourcelst */ - -{ - struct access * pt; - - pt = sourcelst; - while(pt) { - struct access *pn = pt->nextaccess; - free((char *)pt); - pt = pn; - } -} - - - -struct Lockrev * rmnewlocklst(which) -struct Lockrev * which; -/* Function: remove lock to revision which->revno from newlocklst */ - -{ - struct Lockrev * pt, *pre; - - while( newlocklst && (! strcmp(newlocklst->revno, which->revno))){ - struct Lockrev *pn = newlocklst->nextrev; - free((char *)newlocklst); - newlocklst = pn; - } - - pt = pre = newlocklst; - while( pt ) { - if ( ! strcmp(pt->revno, which->revno) ) { - pre->nextrev = pt->nextrev; - free((char *)pt); - pt = pre->nextrev; - } - else { - pre = pt; - pt = pt->nextrev; - } - } - return pre; -} - - - -struct access * removeaccess( who, sourcelst,flag) -struct access * who, * sourcelst; -int flag; -/* Function: remove the accessor-- who from sourcelst */ - -{ - struct access *pt, *pre; - - pt = sourcelst; - while( pt && (! strcmp(who->login, pt->login) )) { - pre = pt->nextaccess; - free((char *)pt); - pt = pre; - flag = false; - } - pre = sourcelst = pt; - while( pt ) { - if ( ! strcmp(who->login, pt->login) ) { - pre->nextaccess = pt->nextaccess; - free((char *)pt); - pt = pre->nextaccess; - flag = false; - } - else { - pre = pt; - pt = pt->nextaccess; - } - } - if ( flag ) warn("Can't remove a nonexisting accessor %s",who->login); - return sourcelst; -} - - - -int addnewaccess( who ) -struct access * who; -/* Function: add new accessor-- who into AccessList */ - -{ - struct access *pt, *pre; - - pre = pt = AccessList; - - while( pt ) { - if ( strcmp( who->login, pt->login) ) { - pre = pt; - pt = pt->nextaccess; - } - else - return 0; - } - if ( pre == pt ) - AccessList = who; - else - pre->nextaccess = who; - return 1; -} - - -sendmail(Delta, who) -char * Delta, *who; -/* Function: mail to who, informing him that his lock on delta was - * broken by caller. Ask first whether to go ahead. Return false on - * error or if user decides not to break the lock. - */ -{ - char * messagefile; - int old1, old2, c, response; - FILE * mailmess; - - - VOID fprintf(stderr, "Revision %s is already locked by %s.\n", Delta, who); - VOID fprintf(stderr, "Do you want to break the lock? [ny](n): "); - response=c=getchar(); - while (!(c==EOF || c=='\n')) c=getchar();/*skip to end of line*/ - if (response=='\n'||response=='n'||response=='N') return false; - - /* go ahead with breaking */ - messagefile=mktempfile("/tmp/", "RCSmailXXXXXX"); - if ( (mailmess = fopen(messagefile, "w")) == NULL) { - faterror("Can't open file %s", messagefile); - } - - VOID fprintf(mailmess, "Subject: Broken lock on %s\n\n",bindex(RCSfilename,'/')); - VOID fprintf(mailmess, "Your lock on revision %s of file %s\n",Delta, getfullRCSname()); - VOID fprintf(mailmess,"has been broken by %s for the following reason:\n",caller); - VOID fputs("State the reason for breaking the lock:\n", stderr); - VOID fputs("(terminate with ^D or single '.')\n>> ", stderr); - - old1 = '\n'; old2 = ' '; - for (; ;) { - c = getchar(); - if ( c == EOF ) { - VOID putc('\n',stderr); - VOID fprintf(mailmess, "%c\n", old1); - break; - } - else if ( c == '\n' && old1 == '.' && old2 == '\n') - break; - else { - VOID fputc( old1, mailmess); - old2 = old1; old1 = c; - if (c== '\n') VOID fputs(">> ", stderr); - } - } - ffclose(mailmess); - - /* ignore the exit status, even if delivermail unsuccessful */ - VOID run(messagefile,(char*)nil, - _PATH_SENDMAIL, - who,(char*)nil); - VOID unlink(messagefile); - return(true); -} - - - -static breaklock(who,delta) -char * who; struct hshentry * delta; -/* function: Finds the lock held by who on delta, - * and removes it. - * Sends mail if a lock different from the caller's is broken. - * Prints an error message if there is no such lock or error. - */ -{ - register struct lock * next, * trail; - char * num; - struct lock dummy; - int whor, numr; - - num=delta->num; - dummy.nextlock=next=Locks; - trail = &dummy; - while (next!=nil) { - if (num != nil) - numr = strcmp(num, next->delta->num); - - whor=strcmp(who,next->login); - if (whor==0 && numr==0) break; /* exact match */ - if (numr==0 && whor !=0) { - if (!sendmail( num, next->login)){ - diagnose("%s still locked by %s",num,next->login); - return; - } else break; /* continue after loop */ - } - trail=next; - next=next->nextlock; - } - if (next!=nil) { - /*found one */ - diagnose("%s unlocked",next->delta->num); - trail->nextlock=next->nextlock; - next->delta->lockedby=nil; - Locks=dummy.nextlock; - } else { - error("no lock set on revision %s", num); - } -} - - - -struct hshentry *searchcutpt(object, length, store) -char * object; -int length; -struct hshentry * * store; -/* Function: Search store and return entry with number being object. */ -/* cuttail = nil, if the entry is Head; otherwise, cuttail */ -/* is the entry point to the one with number being object */ - -{ - while( compartial( (*store++)->num, object, length) ) ; - store--; - - if ( *store == Head) - cuthead = nil; - else - cuthead = *(store -1); - return *store; -} - - - -int branchpoint(strt, tail) -struct hshentry *strt, *tail; -/* Function: check whether the deltas between strt and tail */ -/* are locked or branch point, return 1 if any is */ -/* locked or branch point; otherwise, return 0 and */ -/* mark DELETE on selector */ - -{ - struct hshentry *pt; - struct lock *lockpt; - int flag; - - - pt = strt; - flag = false; - while( pt != tail) { - if ( pt->branches ){ /* a branch point */ - flag = true; - error("Can't remove branch point %s", pt->num); - } - lockpt = Locks; - while(lockpt && lockpt->delta != pt) - lockpt = lockpt->nextlock; - if ( lockpt ) { - flag = true; - error("Can't remove locked revision %s",pt->num); - } - pt = pt->next; - } - - if ( ! flag ) { - pt = strt; - while( pt != tail ) { - pt->selector = DELETE; - diagnose("deleting revision %s ",pt->num); - pt = pt->next; - } - } - return flag; -} - - - -removerevs() -/* Function: get the revision range to be removed, and place the */ -/* first revision removed in delstrt, the revision before */ -/* delstrt in cuthead( nil, if delstrt is head), and the */ -/* revision after the last removed revision in cuttail(nil */ -/* if the last is a leaf */ - -{ - struct hshentry *target, *target2, * temp, *searchcutpt(); - int length, flag; - - flag = false; - if ( ! expandsym(delrev->strt, &numrev[0]) ) return 0; - target = genrevs(&numrev[0], (char *)nil, (char *)nil, (char *)nil, gendeltas); - if ( ! target ) return 0; - if ( cmpnum(target->num, &numrev[0]) ) flag = true; - length = countnumflds( &numrev[0] ); - - if ( delrev->code == 0 ) { /* -o rev or -o branch */ - if ( length % 2) - temp=searchcutpt(target->num,length+1,gendeltas); - else if (flag) { - error("Revision %s does not exist", &numrev[0]); - return 0; - } - else - temp = searchcutpt(&numrev[0],length,gendeltas); - cuttail = target->next; - if ( branchpoint(temp, cuttail) ) { - cuttail = nil; - return 0; - } - delstrt = temp; /* first revision to be removed */ - return 1; - } - - if ( length % 2 ) { /* invalid branch after -o */ - error("Invalid branch range %s after -o", &numrev[0]); - return 0; - } - - if ( delrev->code == 1 ) { /* -o -rev */ - if ( length > 2 ) { - temp = searchcutpt( target->num, length-1, gendeltas); - cuttail = target->next; - } - else { - temp = searchcutpt(target->num, length, gendeltas); - cuttail = target; - while( cuttail && ! cmpnumfld(target->num,cuttail->num,1) ) - cuttail = cuttail->next; - } - if ( branchpoint(temp, cuttail) ){ - cuttail = nil; - return 0; - } - delstrt = temp; - return 1; - } - - if ( delrev->code == 2 ) { /* -o rev- */ - if ( length == 2 ) { - temp = searchcutpt(target->num, 1,gendeltas); - if ( flag) - cuttail = target; - else - cuttail = target->next; - } - else { - if ( flag){ - cuthead = target; - if ( !(temp = target->next) ) return 0; - } - else - temp = searchcutpt(target->num, length, gendeltas); - getbranchno(temp->num, &numrev[0]); /* get branch number */ - target = genrevs(&numrev[0], (char *)nil, (char *)nil, (char *)nil, gendeltas); - } - if ( branchpoint( temp, cuttail ) ) { - cuttail = nil; - return 0; - } - delstrt = temp; - return 1; - } - - /* -o rev1-rev2 */ - if ( ! expandsym(delrev->end, &numrev[0]) ) return 0; - if ( length != countnumflds( &numrev[0] ) ) { - error("Invalid revision range %s-%s", target->num, &numrev[0]); - return 0; - } - if ( length > 2 && compartial( &numrev[0], target->num, length-1) ) { - error("Invalid revision range %s-%s", target->num, &numrev[0]); - return 0; - } - - target2 = genrevs( &numrev[0], (char *)nil, (char *)nil, (char *)nil,gendeltas); - if ( ! target2 ) return 0; - - if ( length > 2) { /* delete revisions on branches */ - if ( cmpnum(target->num, target2->num) > 0) { - if ( cmpnum(target2->num, &numrev[0]) ) - flag = true; - else - flag = false; - temp = target; - target = target2; - target2 = temp; - } - if ( flag ) { - if ( ! cmpnum(target->num, target2->num) ) { - error("Revisions %s-%s don't exist", delrev->strt,delrev->end); - return 0; - } - cuthead = target; - temp = target->next; - } - else - temp = searchcutpt(target->num, length, gendeltas); - cuttail = target2->next; - } - else { /* delete revisions on trunk */ - if ( cmpnum( target->num, target2->num) < 0 ) { - temp = target; - target = target2; - target2 = temp; - } - else - if ( cmpnum(target2->num, &numrev[0]) ) - flag = true; - else - flag = false; - if ( flag ) { - if ( ! cmpnum(target->num, target2->num) ) { - error("Revisions %s-%s don't exist", delrev->strt, delrev->end); - return 0; - } - cuttail = target2; - } - else - cuttail = target2->next; - temp = searchcutpt(target->num, length, gendeltas); - } - if ( branchpoint(temp, cuttail) ) { - cuttail = nil; - return 0; - } - delstrt = temp; - return 1; -} - - - -updateassoc() -/* Function: add or delete(if revno is nil) association */ -/* which is stored in assoclst */ - -{ - struct Symrev * curassoc; - struct assoc * pre, * pt; - struct hshentry * target; - - /* add new associations */ - curassoc = assoclst; - while( curassoc ) { - if ( curassoc->revno == nil ) { /* delete symbol */ - pre = pt = Symbols; - while( pt && strcmp(pt->symbol,curassoc->ssymbol) ) { - pre = pt; - pt = pt->nextassoc; - } - if ( pt ) - if ( pre == pt ) - Symbols = pt->nextassoc; - else - pre->nextassoc = pt->nextassoc; - else - warn("Can't delete nonexisting symbol %s",curassoc->ssymbol); - } - else if ( expandsym( curassoc->revno, &numrev[0] ) ) { - /* add symbol */ - target = (struct hshentry *) talloc(sizeof(struct hshentry)); - target->num = &numrev[0]; - VOID addsymbol(target, curassoc->ssymbol, curassoc->override); - } - curassoc = curassoc->nextsym; - } - -} - - - -updatelocks() -/* Function: remove lock for caller or first lock if unlockcaller==true; - * remove locks which are stored in rmvlocklst, - * add new locks which are stored in newlocklst, - * add lock for Dbranch or Head if lockhead==true. - */ -{ - struct hshentry *target; - struct Lockrev *lockpt; - - if(unlockcaller == true) { /* find lock for caller */ - if ( Head ) { - if (Locks) { - target=findlock(caller,true); - if (target==nil) { - breaklock(caller, Locks->delta); /* remove most recent lock */ - } else { - diagnose("%s unlocked",target->num); - } - } else { - warn("There are no locks set."); - } - } else { - warn("Can't unlock an empty tree"); - } - } - - /* remove locks which are stored in rmvlocklst */ - lockpt = rmvlocklst; - while( lockpt ) { - if (expandsym(lockpt->revno, numrev)) { - target = genrevs(numrev, (char *)nil, (char *)nil, (char *)nil, gendeltas); - if ( target ) - if ( !(countnumflds(numrev)%2) && cmpnum(target->num,numrev)) - error("Can't unlock nonexisting revision %s",lockpt->revno); - else - breaklock(caller, target); - /* breaklock does its own diagnose */ - } - lockpt = lockpt->nextrev; - } - - /* add new locks which stored in newlocklst */ - lockpt = newlocklst; - while( lockpt ) { - setlock(lockpt->revno,caller); - lockpt = lockpt->nextrev; - } - - if ( lockhead == true) { /* lock default branch or head */ - if (Dbranch) { - setlock(Dbranch->num,caller); - } elsif ( Head) { - if (addlock(Head, caller)) - diagnose("%s locked",Head->num); - } else { - warn("Can't lock an empty tree"); - } - } - -} - - - -setlock(rev,who) -char * rev, * who; -/* Function: Given a revision or branch number, finds the correponding - * delta and locks it for who. - */ -{ - struct lock *lpt; - struct hshentry *target; - - if (expandsym(rev, &numrev[0]) ){ - target = genrevs(&numrev[0],(char *) nil,(char *) nil, - (char *)nil, gendeltas); - if ( target ) - if ( !(countnumflds(&numrev[0])%2) && cmpnum(target->num,&numrev[0])) - error("Can't lock nonexisting revision %s",numrev); - else - if(lpt=addlock(target, who)) - diagnose("%s locked",lpt->delta->num); - } -} - - - -rcs_setstate(rev,status) -char * rev, * status; -/* Function: Given a revision or branch number, finds the corresponding delta - * and sets its state to status. - */ -{ - struct hshentry *target; - - if ( expandsym(rev, &numrev[0]) ) { - target = genrevs(&numrev[0],(char *) nil, (char *)nil, - (char *) nil, gendeltas); - if ( target ) - if ( !(countnumflds(&numrev[0])%2) && cmpnum(target->num, &numrev[0]) ) - error("Can't set state of nonexisting revision %s to %s", - numrev,status); - else - target->state = status; - } -} - - - - - -buildeltatext(deltas) -struct hshentry ** deltas; -/* Function: put the delta text on frewrite and make necessary */ -/* change to delta text */ -{ - int i, c, exit_stats; - - cuttail->selector = DELETE; - initeditfiles("/tmp/"); - scanlogtext(deltas[0], copy); - i = 1; - if ( cuthead ) { - cutfilename=mktempfile("/tmp/", "RCScutXXXXXX"); - if ( (fcut = fopen(cutfilename, "w")) == NULL) { - faterror("Can't open temporary file %s", cutfilename); - } - - while( deltas[i-1] != cuthead ) { - scanlogtext(deltas[i++], edit); - } - - finishedit((struct hshentry *)nil); rewind(fcopy); - while( (c = getc(fcopy)) != EOF) VOID putc(c, fcut); - swapeditfiles(false); - ffclose(fcut); - } - - while( deltas[i-1] != cuttail) - scanlogtext(deltas[i++], edit); - finishedit((struct hshentry *)nil); ffclose(fcopy); - - if ( cuthead ) { - diffilename=mktempfile("/tmp/", "RCSdifXXXXXX"); - exit_stats = run((char*)nil,diffilename, - DIFF,"-n",cutfilename,resultfile,(char*)nil); - if (exit_stats != 0 && exit_stats != (1 << BYTESIZ)) - faterror ("diff failed"); - if(!putdtext(cuttail->num,curlogmsg,diffilename,frewrite)) return; - } - else - if (!putdtext(cuttail->num,curlogmsg,resultfile,frewrite)) return; - - scanlogtext((struct hshentry *)nil,empty); /* read the rest of the deltas */ -} - - - -buildtree() -/* Function: actually removes revisions whose selector field */ -/* is DELETE, and rebuilds the linkage of deltas. */ -/* asks for reconfirmation if deleting last revision*/ -{ - int c, response; - - struct hshentry * Delta; - struct branchhead *pt, *pre; - - if ( cuthead ) - if ( cuthead->next == delstrt ) - cuthead->next = cuttail; - else { - pre = pt = cuthead->branches; - while( pt && pt->hsh != delstrt ) { - pre = pt; - pt = pt->nextbranch; - } - if ( cuttail ) - pt->hsh = cuttail; - else if ( pt == pre ) - cuthead->branches = pt->nextbranch; - else - pre->nextbranch = pt->nextbranch; - } - else { - if ( cuttail == nil && !quietflag) { - VOID fprintf(stderr,"Do you really want to delete all revisions ?[ny](n): "); - c = response = getchar(); - while( c != EOF && c != '\n') c = getchar(); - if ( response != 'y' && response != 'Y') { - diagnose("No revision deleted"); - Delta = delstrt; - while( Delta) { - Delta->selector = 'S'; - Delta = Delta->next; - } - return; - } - } - Head = cuttail; - } - return; -} - diff --git a/usr.bin/rcs/src/rcsbase.h b/usr.bin/rcs/src/rcsbase.h deleted file mode 100644 index a10c2142986d..000000000000 --- a/usr.bin/rcs/src/rcsbase.h +++ /dev/null @@ -1,393 +0,0 @@ - -/* - * RCS common definitions and data structures - */ -#define RCSBASE "$Id: rcsbase.h,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $" - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - -/***************************************************************************** - * INSTRUCTIONS: - * ============= - * The following should be handled in the Makefile: - * For USG Unix, define USG; for BSD Unix, don't (see ifdef USG). - * For 4.2 bsd, define V4_2BSD; this will replace the routines - * getwd() and rename() with the corresponding ones in the C-library. - * V4_2BSD also selects different definitions for the macros NCPFN and NCPPN - * (max. number of characters per filename, number of characters per path name). - * Define STRICT_LOCKING appropriately (see STRICT_LOCKING). - * The following need be changed for porting to a different machine: - * Define SMALLOG for a machine with small memory (like the PDP11). - * SMALLOG conserves space for log messages. - * Change BYTESIZ if necessary. - * If you need to change the comment leaders, update the table comtable[] - * in rcsfnms.c. (This can wait until you know what a comment leader is.) - ***************************************************************************** - */ - - -/* $Log: rcsbase.h,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.9 89/05/01 15:17:14 narten - * botched previous USG fix - * - * Revision 4.8 89/05/01 14:53:05 narten - * changed #include <strings.h> -> string.h for USG systems. - * - * Revision 4.7 88/11/08 15:58:45 narten - * removed defs for functions loaded from libraries - * - * Revision 4.6 88/11/08 12:04:06 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.6 88/08/09 19:12:36 eggert - * Shrink stdio code size; remove lint; permit -Dhshsize=nn. - * - * Revision 4.5 87/12/18 17:06:41 narten - * made removed BSD ifdef, now uses V4_2BSD - * - * Revision 4.4 87/10/18 10:29:49 narten - * Updating version numbers - * Changes relative to 1.1 are actually relative to 4.2 - * - * Revision 1.3 87/09/24 14:02:25 narten - * changes for lint - * - * Revision 1.2 87/03/27 14:22:02 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:14 kcs - * Initial revision - * - * Revision 4.2 83/12/20 16:04:20 wft - * merged 3.6.1.1 and 4.1 (SMALLOG, logsize). - * moved setting of STRICT_LOCKING to Makefile. - * changed DOLLAR to UNKN (conflict with KDELIM). - * - * Revision 4.1 83/05/04 09:12:41 wft - * Added markers Id and RCSfile. - * Added Dbranch for default branches. - * - * Revision 3.6.1.1 83/12/02 21:56:22 wft - * Increased logsize, added macro SMALLOG. - * - * Revision 3.6 83/01/15 16:43:28 wft - * 4.2 prerelease - * - * Revision 3.6 83/01/15 16:43:28 wft - * Replaced dbm.h with BYTESIZ, fixed definition of rindex(). - * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD. - * Added macro DELNUMFORM to have uniform format for printing delta text nodes. - * Added macro DELETE to mark deleted deltas. - * - * Revision 3.5 82/12/10 12:16:56 wft - * Added two forms of DATEFORM, one using %02d, the other %.2d. - * - * Revision 3.4 82/12/04 20:01:25 wft - * added LOCKER, Locker, and USG (redefinition of rindex). - * - * Revision 3.3 82/12/03 12:22:04 wft - * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3, - * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength - * using NCPPN. Changed putc() to abort on write error. - * - * Revision 3.2 82/10/18 15:03:52 wft - * added macro STRICT_LOCKING, removed RCSUMASK. - * renamed JOINFILE[1,2] to JOINFIL[1,2]. - * - * Revision 3.1 82/10/11 19:41:17 wft - * removed NBPW, NBPC, NCPW. - * added typdef int void to aid compiling - */ - - - -#include <stdio.h> -#ifdef USG -#include <string.h> -#else -#include <strings.h> -#endif -#undef putc /* will be redefined */ - - -#ifdef USG -# define rindex strrchr -# define DATEFORM "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d" -#else -# define DATEFORM "%02d.%02d.%02d.%02d.%02d.%02d" -#endif -/* Make sure one of %02d or %.2d prints a number with a field width 2, with - * leading zeroes. For example, 0, 1, and 22 must be printed as 00, 01, and - * 22. Otherwise, there will be problems with the dates. - */ - -#define PRINTDATE(file,date) fprintf(file,"%.2s/%.2s/%.2s",date,date+3,date+6) -#define PRINTTIME(file,date) fprintf(file,"%.2s:%.2s:%.2s",date+9,date+12,date+15) -/* print RCS format date and time in nice format from a string */ - -/* - * Parameters - */ -#define BYTESIZ 8 /* number of bits in a byte */ - -/*#define STRICT_LOCKING 0 /* 0 sets the default locking to non-strict; */ - /* used in experimental environments. */ - /* 1 sets the default locking to strict; */ - /* used in production environments. */ - /* STRICT_LOCKING is set in the Makefile! */ -#ifndef hshsize -#define hshsize 239 /* hashtable size; MUST be prime and -1 mod 4 */ - /* other choices: 547 or 719 */ -#endif - -#define strtsize (hshsize * 50) /* string table size */ -#ifdef SMALLOG -# define logsize 1024 /* max. size of log message for pdp11 */ -#else -# define logsize 4096 /* max. size of log message for others */ -#endif -#define revlength 30 /* max. length of revision numbers */ -#define datelength 20 /* length of a date in RCS format */ -#define joinlength 20 /* number of joined revisions permitted */ -#define RCSDIR "RCS/" /* subdirectory for RCS files */ -#define RCSSUF 'v' /* suffix for RCS files */ -#define RCSSEP ',' /* separator for RCSSUF */ -#define KDELIM '$' /* delimiter for keywords */ -#define VDELIM ':' /* separates keywords from values */ -#define DEFAULTSTATE "Exp" /* default state of revisions */ -#ifdef V4_2BSD -# define NCPFN 256 /* number of characters per filename */ -# define NCPPN 1024 /* number of characters per pathname */ -#else -# define NCPFN 14 /* number of characters per filename */ -# define NCPPN 6*NCPFN /* number of characters per pathname */ -#endif -#define keylength 20 /* buffer length for expansion keywords */ -#define keyvallength NCPPN+revlength+datelength+60 - /* buffer length for keyword expansion */ - - - -#define true 1 -#define false 0 -#define nil 0 -#define elsif else if -#define elif else if - - -/* temporary file names */ - -#define NEWRCSFILE ",RCSnewXXXXXX" -#define DIFFILE ",RCSciXXXXXX" -#define TMPFILE1 ",RCSt1XXXXXX" -#define TMPFILE2 ",RCSt2XXXXXX" -#define TMPFILE3 ",RCSt3XXXXXX" -#define JOINFIL2 ",RCSj2XXXXXX" -#define JOINFIL3 ",RCSj3XXXXXX" - - -#ifdef _FSTDIO -#define putc(x,p) (--(p)->_w < 0 ? wbuf((unsigned)(x), p) : \ - (*(p)->_p = (x), (int)*(p)->_p++)) -#else -#define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):fflsbuf((unsigned)(x),p)) -#endif -/* This version of putc prints a char, but aborts on write error */ - -#define GETC(in,out,echo) (c=getc(in), echo?putc(c,out):c) -/* GETC modifies a local variable c; a kludge, but smaller and faster. */ -/* GETC writes a del-character (octal 177) on end of file */ - -#define WORKMODE(RCSmode) (RCSmode&~0222)|((lockflag||!StrictLocks)?0600:0000) -/* computes mode of working file: same as RCSmode, but write permission */ -/* determined by lockflag and StrictLocks. */ - - -/* character classes and token codes */ -enum tokens { -/* char classes*/ DIGIT, IDCHAR, NEWLN, LETTER, PERIOD, SBEGIN, SPACE, UNKN, -/* tokens */ COLON, DATE, EOFILE, ID, KEYW, NUM, SEMI, STRING, -}; - -#define AT SBEGIN /* class SBEGIN (string begin) is returned by lex. anal. */ -#define SDELIM '@' /* the actual character is needed for string handling*/ -/* these must be changed consistently, for instance to: - * #define DQUOTE SBEGIN - * #define SDELIM '"' - * #define AT IDCHAR - * there should be no overlap among SDELIM, KDELIM, and VDELIM - */ - -/* other characters */ - -#define ACCENT IDCHAR -#define AMPER IDCHAR -#define BACKSL IDCHAR -#define BAR IDCHAR -#define COMMA UNKN -#define DIVIDE IDCHAR -#define DOLLAR UNKN /* overlap with KDELIM */ -#define DQUOTE IDCHAR -#define EQUAL IDCHAR -#define EXCLA IDCHAR -#define GREAT IDCHAR -#define HASH IDCHAR -#define INSERT UNKN -#define LBRACE IDCHAR -#define LBRACK IDCHAR -#define LESS IDCHAR -#define LPARN IDCHAR -#define MINUS IDCHAR -#define PERCNT IDCHAR -#define PLUS IDCHAR -#define QUEST IDCHAR -#define RBRACE IDCHAR -#define RBRACK IDCHAR -#define RPARN IDCHAR -#define SQUOTE IDCHAR -#define TILDE IDCHAR -#define TIMES IDCHAR -#define UNDER IDCHAR -#define UPARR IDCHAR - - - - -/*************************************** - * Data structures for the symbol table - ***************************************/ - - -/* Hash table entry */ -struct hshentry { - char * num; /* pointer to revision number (ASCIZ) */ - char * date; /* pointer to date of checking */ - char * author; /* login of person checking in */ - char * lockedby; /* who locks the revision */ - char * log; /* log message requested at checkin */ - char * state; /* state of revision (Exp by default) */ - struct branchhead * branches; /* list of first revisions on branches*/ - struct hshentry * next; /* next revision on same branch */ - int insertlns;/* lines inserted (computed by rlog) */ - int deletelns;/* lines deleted (computed by rlog) */ - char selector; /* marks entry for selection/deletion */ -}; - -/* list element for branch lists */ -struct branchhead { - struct hshentry * hsh; - struct branchhead * nextbranch; -}; - -/* accesslist element */ -struct access { - char * login; - struct access * nextaccess; -}; - -/* list element for locks */ -struct lock { - char * login; - struct hshentry * delta; - struct lock * nextlock; -}; - -/* list element for symbolic names */ -struct assoc { - char * symbol; - struct hshentry * delta; - struct assoc * nextassoc; -}; - - -/* common variables (getadmin and getdelta())*/ -extern char * Comment; -extern struct access * AccessList; -extern struct assoc * Symbols; -extern struct lock * Locks; -extern struct hshentry * Head; -extern struct hshentry * Dbranch; -extern int StrictLocks; -extern int TotalDeltas; -#ifndef lint -static char copyright[]="Copyright (C) 1982 by Walter F. Tichy"; -#endif - -/* common variables (lexical analyzer)*/ -extern enum tokens map[]; -#define ctab (&map[1]) -extern enum tokens nexttok; -extern int hshenter; -extern char * NextString; -extern char * cmdid; - -#if defined(USG) || defined(V4_2BSD) -#define VOID (void) -#else -typedef int void; -#define VOID -#endif - -/* common routines */ -extern char *talloc(); -extern int serror(); -extern int faterror(); -extern int fatserror(); -extern void ignoreints(); -extern void catchints(); -extern void restoreints(); - -#ifdef USG -extern int sprintf(); -#endif - -/* - * Markers for keyword expansion (used in co and ident) - */ -#define AUTHOR "Author" -#define DATE "Date" -#define HEADER "Header" -#define IDH "Id" -#define LOCKER "Locker" -#define LOG "Log" -#define RCSFILE "RCSfile" -#define REVISION "Revision" -#define SOURCE "Source" -#define STATE "State" - -enum markers { Nomatch, Author, Date, Header, Id, - Locker, Log, RCSfile, Revision, Source, State }; - -#define DELNUMFORM "\n\n%s\n%s\n" -/* used by putdtext and scanlogtext */ -#define DELETE 'D' -/* set by rcs -o and used by puttree() in rcssyn */ - diff --git a/usr.bin/rcs/src/rcsclean.c b/usr.bin/rcs/src/rcsclean.c deleted file mode 100644 index cb44dd41a3dd..000000000000 --- a/usr.bin/rcs/src/rcsclean.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * RCS rcsclean operation - */ - -static char rcsid[]= -"$Header $ Purdue CS"; -/***************************************************************************** - * remove unneded working files - ***************************************************************************** - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - - -/* $Log: rcsclean.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.4 89/05/01 15:12:21 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.3 88/11/08 15:59:54 narten - * removed reference to TARGETDIR - * - * Revision 4.2 87/10/18 10:30:43 narten - * Updating version numbers. Changes relative to 1.1 are actually - * relative to 4.1 - * - * Revision 1.2 87/09/24 13:59:13 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.1 84/01/23 14:50:16 kcs - * Initial revision - * - * Revision 4.1 83/12/15 12:26:18 wft - * Initial revision. - * - */ -#include "rcsbase.h" -#define ERRCODE 2 /*error code for exit status */ -static char rcsbaseid[] = RCSBASE; - -extern int cleanup(); /* cleanup after signals */ -extern char * mktempfile(); /*temporary file name generator */ -extern int fterror(); /*forward for special fatal error func. */ -extern struct hshentry * genrevs(); /*generate delta numbers */ -extern int nerror; /*counter for errors */ -extern int quietflag; /*suppresses diagnostics */ -extern FILE * finptr; /* RCS input file */ -extern FILE * fopen(); - -char *RCSfilename; -char *workfilename; -char * tempfile; -FILE * file1, * file2; /*file descriptors for comparison */ - -main (argc, argv) -int argc; char **argv; -{ - char * cmdusage; - char command[NCPPN+revlength+40]; - char * rev; /* revision number from command line */ - char numericrev[revlength]; /* holds expanded revision number */ - int revnums; /* number of -r options */ - struct hshentry * gendeltas[hshsize];/*stores deltas to be generated*/ - struct hshentry * target; - int filecounter; - register int c1; /* reading input */ - int result; /* result of comparison */ - int pairresult; /* reulst of pairfilenames */ - - catchints(); - cmdid = "rcsclean"; - cmdusage = "command format:\n rcsclean [-rrev] file"; - filecounter=revnums=0; - quietflag=true; /* default no diagnostics */ - while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) { - switch ((*argv)[1]) { - case 'r': - revno: if ((*argv)[2]!='\0') { - if (revnums==0) { - rev= *argv+2; revnums=1; - } else { - fterror("too many revision numbers"); - } - } /* do nothing for empty -r */ - break; - case 'D': /* debug option */ - quietflag = false; - break; - - default: - fterror("unknown option: %s\n%s", *argv,cmdusage); - }; - } /* end of option processing */ - - if (argc<1) fterror("No input file\n%s",cmdusage); - - /* now handle all filenames */ - do { - finptr=NULL; - pairresult=pairfilenames(argc,argv,false,false); - - if (pairresult==0) continue; /* error */ - if (!(access(workfilename,4)==0)) { - diagnose("Can't open %s",workfilename); - continue; - } elsif (pairresult == -1) { - warn("Can't find RCS file for %s",workfilename); - continue; - } - diagnose("RCS file: %s",RCSfilename); - if (!trysema(RCSfilename,false)) continue; /* give up */ - - - gettree(); /* reads in the delta tree */ - - if (Head==nil) { - error("no revisions present"); - continue; - } - if (revnums==0) - rev=(Dbranch!=nil?Dbranch->num:Head->num); /* default rev1 */ - - if (!expandsym(rev,numericrev)) continue; - if (!(target=genrevs(numericrev,nil,nil,nil,gendeltas))) continue; - - tempfile=mktempfile("/tmp/",TMPFILE1); - diagnose("retrieving revision %s",target->num); - VOID sprintf(command,"%s -q -p%s %s > %s\n", - CO ,target->num,RCSfilename,tempfile); - if (system(command)){ - error("co failed"); - continue; - } - /* now do comparison */ - if ((file1=fopen(tempfile,"r"))==NULL) { - error("Can't open checked out file %s",tempfile); - continue; - } - if ((file2=fopen(workfilename,"r"))==NULL) { - error("Can't open %s",workfilename); - continue; - } - result=1; - while ((c1=getc(file1))==getc(file2)) { - if (c1==EOF) { - /* identical files; can remove working file */ - result=0; - diagnose("files identical; %s removed",workfilename); - if (unlink(workfilename)!=0) { - error("Can't unlink %s",workfilename); - } - break; - } - } - fclose(file1); fclose(file2); - - if (result==1) diagnose ("files different"); - - - } while (cleanup(), - ++argv, --argc >=1); - - - if (nerror>0) { - exit(ERRCODE); - } else { - exit(result); - } - -} - - -fterror(e, e1, e2) -char * e, * e1, * e2; -/* prints error message and terminates program with ERRCODE */ -{ nerror++; - VOID fprintf(stderr,"%s error: ",cmdid); - VOID fprintf(stderr,e, e1, e2); - VOID fprintf(stderr,"\n%s aborted\n",cmdid); - VOID cleanup(); - exit(ERRCODE); -} - diff --git a/usr.bin/rcs/src/rcsclean.sh b/usr.bin/rcs/src/rcsclean.sh deleted file mode 100644 index 628a4491e6c9..000000000000 --- a/usr.bin/rcs/src/rcsclean.sh +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -# -# RCS cleanup operation. -# $Header: /cvsroot/src/usr.bin/rcs/src/Attic/rcsclean.sh,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ -# -# This program removes working files which are copies of the latest -# revision on the default branch of the corresponding RCS files. -# For each file given, rcsclean performs a co operation for the latest -# revision on the default branch, and compares -# the result with the working file. If the two are identical, -# the working file is deleted. -# -# A typical application in a Makefile would be: -# clean:; rm *.o; rcsclean *.c *.o -# -# Limitation: This program doesn't work if given the name of -# an RCS file rather than the name of the working file. - -PATH=/usr/new/bin:/usr/local/bin:/bin:/usr/bin:/usr/ucb -export PATH -progname=$0 -if [ $# = 0 ] ; then - echo "usage: $progname file ..." - echo "removes all working files that are checked in and are unchanged" - exit 0 -fi -TMPFILE=/tmp/rcscl$$.tmp -while test $# -gt 0 ; do - if test -f $1 ; then - co -p -q $1 > $TMPFILE - if [ $? = 0 ] ; then - cmp -s $1 $TMPFILE - if [ $? = 0 ] ; then - chmod +w $1; rm -f $1; rcs -u -q $1 - fi - fi - fi - shift -done -rm -f $TMPFILE diff --git a/usr.bin/rcs/src/rcsdiff.c b/usr.bin/rcs/src/rcsdiff.c deleted file mode 100644 index c913822caba9..000000000000 --- a/usr.bin/rcs/src/rcsdiff.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - * RCS rcsdiff operation - */ -#ifndef lint -static char rcsid[]= -"$Header: /cvsroot/src/usr.bin/rcs/src/Attic/rcsdiff.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/***************************************************************************** - * generate difference between RCS revisions - ***************************************************************************** - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - - -/* $Log: rcsdiff.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 3.12 91/02/22 00:11:20 elan - * *** empty log message *** - * - * Revision 3.11 89/08/15 21:37:01 bostic - * Version 4 from Tom Narten at Purdue - * - * Revision 4.6 89/05/01 15:12:27 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.5 88/11/08 12:01:51 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.5 88/08/09 19:12:41 eggert - * Use execv(), not system(); yield exit status like diff(1)s; allow cc -R. - * - * Revision 4.4 87/12/18 11:37:46 narten - * changes Jay Lepreau made in the 4.3 BSD version, to add support for - * "-i", "-w", and "-t" flags and to permit flags to be bundled together, - * merged in. - * - * Revision 4.3 87/10/18 10:31:42 narten - * Updating version numbers. Changes relative to 1.1 actually - * relative to 4.1 - * - * Revision 1.3 87/09/24 13:59:21 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:15 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:18 kcs - * Initial revision - * - * Revision 4.1 83/05/03 22:13:19 wft - * Added default branch, option -q, exit status like diff. - * Added fterror() to replace faterror(). - * - * Revision 3.6 83/01/15 17:52:40 wft - * Expanded mainprogram to handle multiple RCS files. - * - * Revision 3.5 83/01/06 09:33:45 wft - * Fixed passing of -c (context) option to diff. - * - * Revision 3.4 82/12/24 15:28:38 wft - * Added call to catchsig(). - * - * Revision 3.3 82/12/10 16:08:17 wft - * Corrected checking of return code from diff; improved error msgs. - * - * Revision 3.2 82/12/04 13:20:09 wft - * replaced getdelta() with gettree(). Changed diagnostics. - * - * Revision 3.1 82/11/28 19:25:04 wft - * Initial revision. - * - */ -#include <ctype.h> -#include "rcsbase.h" -#define ERRCODE 2 /*error code for exit status */ -extern char *rindex(); -#ifndef lint -static char rcsbaseid[] = RCSBASE; -#endif -static char co[] = CO; - -extern int cleanup(); /* cleanup after signals */ -extern char * mktempfile(); /*temporary file name generator */ -extern int fterror(); /*forward for special fatal error func. */ -extern struct hshentry * genrevs(); /*generate delta numbers */ -extern int nerror; /*counter for errors */ -extern int quietflag; /*suppresses diagnostics */ -extern FILE * finptr; /* RCS input file */ - -char *RCSfilename; -char *workfilename; -char * temp1file, * temp2file; - -char bops[10]; -char otherops[10]; - -main (argc, argv) -int argc; char **argv; -{ - char * cmdusage; - char commarg[revlength+3]; - int revnums; /* counter for revision numbers given */ - char * rev1, * rev2; /* revision numbers from command line */ - char numericrev[revlength]; /* holds expanded revision number */ - char * xrev1, * xrev2; /* expanded revision numbers */ - struct hshentry * gendeltas[hshsize];/*stores deltas to be generated*/ - struct hshentry * target; - char * boption, * otheroption; - int exit_stats; - int diffs_found; - char *argp; - register c; - - catchints(); - otheroption = otherops + 2; - boption = bops + 2; - cmdid = "rcsdiff"; - cmdusage = "command format:\n rcsdiff [-biwt] [-q] [-cefhn] [-rrev1] [-rrev2] file"; - diffs_found=revnums=0; - while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) { - argp = &((*argv)[1]); - while (c = *argp++) switch (c) { - case 'r': - if (*argp!='\0') { - if (revnums==0) { - rev1= argp; revnums=1; - } elif (revnums==1) { - rev2= argp; revnums=2; - } else { - fterror("too many revision numbers"); - } - } /* do nothing for empty -r */ - argp += strlen(argp); - break; - case 'b': - case 'i': - case 'w': - case 't': - if (!rindex(bops + 2, c)) - *boption++ = c; - break; - case 'q': - quietflag=true; - break; - case 'c': - case 'e': - case 'f': - case 'h': - case 'n': - if (otheroption == otherops + 2) { - *otheroption++ = c; - if (c == 'c' && isdigit(*argp)) { - while (isdigit(*argp) && otheroption < otherops+sizeof(otherops)-1) - *otheroption++ = *argp++; - if (*argp) - faterror("-c: bad count"); - argp = ""; - } - } else { - fterror("Options c,e,f,h,n are mutually exclusive"); - } - break; - default: - fterror("unknown option: %s\n%s", *argv,cmdusage); - }; - } /* end of option processing */ - - if (boption != bops + 2) { - bops[0] = ' '; - bops[1] = '-'; - boption = bops; - } - if (otheroption != otherops + 2) { - otherops[0] = ' '; - otherops[1] = '-'; - otheroption = otherops; - } - if (argc<1) fterror("No input file\n%s",cmdusage); - - /* now handle all filenames */ - do { - finptr=NULL; - - if (pairfilenames(argc,argv,true,false)!=1) continue; - diagnose("==================================================================="); - diagnose("RCS file: %s",RCSfilename); - if (revnums<2 && !(access(workfilename,4)==0)) { - error("Can't open %s",workfilename); - continue; - } - if (!trysema(RCSfilename,false)) continue; /* give up */ - - - gettree(); /* reads in the delta tree */ - - if (Head==nil) { - error("no revisions present"); - continue; - } - if (revnums==0) - rev1=Dbranch!=nil?Dbranch->num:Head->num; /* default rev1 */ - - if (!expandsym(rev1,numericrev)) continue; - if (!(target=genrevs(numericrev,(char *)nil,(char *)nil,(char *)nil,gendeltas))) continue; - xrev1=target->num; - - if (revnums==2) { - if (!expandsym(rev2,numericrev)) continue; - if (!(target=genrevs(numericrev,(char *)nil,(char *)nil,(char *)nil,gendeltas))) continue; - xrev2=target->num; - } - - - temp1file=mktempfile("/tmp/",TMPFILE1); - diagnose("retrieving revision %s",xrev1); - VOID sprintf(commarg,"-p%s",xrev1); - if (run((char*)nil,temp1file, co,"-q",commarg,RCSfilename,(char*)nil)){ - error("co failed"); - continue; - } - if (revnums<=1) { - temp2file=workfilename; - diagnose("diff%s%s -r%s %s",boption,otheroption,xrev1,workfilename); - } else { - temp2file=mktempfile("/tmp/",TMPFILE2); - diagnose("retrieving revision %s",xrev2); - VOID sprintf(commarg,"-p%s",xrev2); - if (run((char*)nil,temp2file, co,"-q",commarg,RCSfilename,(char *)nil)){ - error("co failed"); - continue; - } - diagnose("diff%s%s -r%s -r%s",boption,otheroption,xrev1,xrev2); - } - - exit_stats = - *boption - ? *otheroption - ? run((char*)nil,(char*)nil, DIFF, boption+1, otheroption+1, temp1file,temp2file,(char*)nil) - : run((char*)nil,(char*)nil, DIFF, boption+1, temp1file,temp2file,(char*)nil) - : *otheroption - ? run((char*)nil,(char*)nil, DIFF, otheroption+1, temp1file,temp2file,(char*)nil) - : run((char*)nil,(char*)nil, DIFF, temp1file,temp2file,(char*)nil); - - if (exit_stats == (1 << BYTESIZ)) - diffs_found = 1; - else if (exit_stats != 0) { - error ("diff failed"); - continue; - } - } while (cleanup(), - ++argv, --argc >=1); - - - exit(nerror ? ERRCODE : diffs_found); -} - - -/*VARARGS3*/ -fterror(e, e1, e2) -char * e, * e1, * e2; -/* prints error message and terminates program with ERRCODE */ -{ nerror++; - VOID fprintf(stderr,"%s error: ",cmdid); - VOID fprintf(stderr,e, e1, e2); - VOID fprintf(stderr,"\n%s aborted\n",cmdid); - VOID cleanup(); - exit(ERRCODE); -} - diff --git a/usr.bin/rcs/src/rcsedit.c b/usr.bin/rcs/src/rcsedit.c deleted file mode 100644 index 2856eca757f7..000000000000 --- a/usr.bin/rcs/src/rcsedit.c +++ /dev/null @@ -1,524 +0,0 @@ -/* - * RCS stream editor - */ -#ifndef lint -static char rcsid[]= "$Id: rcsedit.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/********************************************************************************** - * edits the input file according to a - * script from stdin, generated by diff -n - * performs keyword expansion - ********************************************************************************** - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - -/* $Log: rcsedit.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 3.11 89/08/15 21:37:31 bostic - * Version 4 from Tom Narten at Purdue - * - * Revision 4.8 89/05/01 15:12:35 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.7 88/11/08 13:54:14 narten - * misplaced semicolon caused infinite loop - * - * Revision 4.6 88/11/08 12:01:41 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.6 88/08/09 19:12:45 eggert - * Shrink stdio code size; allow cc -R. - * - * Revision 4.5 87/12/18 11:38:46 narten - * Changes from the 43. version. Don't know the significance of the - * first change involving "rewind". Also, additional "lint" cleanup. - * (Guy Harris) - * - * Revision 4.4 87/10/18 10:32:21 narten - * Updating version numbers. Changes relative to version 1.1 actually - * relative to 4.1 - * - * Revision 1.4 87/09/24 13:59:29 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.3 87/09/15 16:39:39 shepler - * added an initializatin of the variables editline and linecorr - * this will be done each time a file is processed. - * (there was an obscure bug where if co was used to retrieve multiple files - * it would dump) - * fix attributed to Roy Morris @FileNet Corp ...!felix!roy - * - * Revision 1.2 87/03/27 14:22:17 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:20 kcs - * Initial revision - * - * Revision 4.1 83/05/12 13:10:30 wft - * Added new markers Id and RCSfile; added locker to Header and Id. - * Overhauled expandline completely() (problem with $01234567890123456789@). - * Moved trymatch() and marker table to rcskeys.c. - * - * Revision 3.7 83/05/12 13:04:39 wft - * Added retry to expandline to resume after failed match which ended in $. - * Fixed truncation problem for $19chars followed by@@. - * Log no longer expands full path of RCS file. - * - * Revision 3.6 83/05/11 16:06:30 wft - * added retry to expandline to resume after failed match which ended in $. - * Fixed truncation problem for $19chars followed by@@. - * - * Revision 3.5 82/12/04 13:20:56 wft - * Added expansion of keyword Locker. - * - * Revision 3.4 82/12/03 12:26:54 wft - * Added line number correction in case editing does not start at the - * beginning of the file. - * Changed keyword expansion to always print a space before closing KDELIM; - * Expansion for Header shortened. - * - * Revision 3.3 82/11/14 14:49:30 wft - * removed Suffix from keyword expansion. Replaced fclose with ffclose. - * keyreplace() gets log message from delta, not from curlogmsg. - * fixed expression overflow in while(c=putc(GETC.... - * checked nil printing. - * - * Revision 3.2 82/10/18 21:13:39 wft - * I added checks for write errors during the co process, and renamed - * expandstring() to xpandstring(). - * - * Revision 3.1 82/10/13 15:52:55 wft - * changed type of result of getc() from char to int. - * made keyword expansion loop in expandline() portable to machines - * without sign-extension. - */ - - -#include "rcsbase.h" - - -extern FILE * fopen(); -extern char * mktempfile(); -extern char * bindex(); -extern FILE * finptr, * frewrite; -extern int rewriteflag; -extern int nextc; -extern char * RCSfilename, * workfilename; -extern char * bindex(); -extern char * getfullRCSname(); -extern enum markers trymatch(); - - -FILE * fcopy, * fedit; /* result and edit file descriptors */ -char *resultfile; /* result file name */ -char * editfile; /* edit file name */ -int editline; /*line counter in fedit; starts with 1, is always #lines+1 */ -int linecorr; /*contains #adds - #deletes in each edit run. */ - /*used to correct editline in case file is not rewound after */ - /* applying one delta */ - -initeditfiles(dir) -char * dir; -/* Function: Initializes resultfile and editfile with temporary filenames - * in directory dir. Opens resultfile for reading and writing, with fcopy - * as file descriptor. fedit is set to nil. - */ -{ - editline = linecorr = 0; /* make sure we start from the beginning*/ - resultfile=mktempfile(dir,TMPFILE1); - editfile =mktempfile(dir,TMPFILE2); - fedit=nil; - if ((fcopy=fopen(resultfile,"w+"))==NULL) { - faterror("Can't open working file %s",resultfile); - } -} - - -swapeditfiles(tostdout) -/* Function: swaps resultfile and editfile, assigns fedit=fcopy, - * rewinds fedit for reading, and opens resultfile for reading and - * writing, using fcopy. If tostdout, fcopy is set to stdout. - */ -{ char * tmpptr; - if(ferror(fcopy)) - faterror("write failed on %s -- file system full?",resultfile); - fedit=fcopy; - rewind(fedit); - editline = 1; linecorr=0; - tmpptr=editfile; editfile=resultfile; resultfile=tmpptr; - if (tostdout) - fcopy=stdout; - elsif ((fcopy=fopen(resultfile,"w+"))==NULL) { - faterror("Can't open working file %s",resultfile); - } -} - - -finishedit(delta) -struct hshentry * delta; -/* copy the rest of the edit file and close it (if it exists). - * if delta!=nil, perform keyword substitution at the same time. - */ -{ - register int c; - if (fedit!=nil) { - if (delta!=nil) { - while (expandline(fedit,fcopy,delta,false,false)) editline++; - } else { - while((c=getc(fedit))!=EOF) { - VOID putc(c,fcopy); - if (c=='\n') editline++; - } - } - ffclose(fedit); - } -} - - -copylines(line,delta) -register int line; struct hshentry * delta; -/* Function: copies input lines editline..line-1 from fedit to fcopy. - * If delta != nil, keyword expansion is done simultaneously. - * editline is updated. Rewinds a file only if necessary. - */ -{ - - if (editline>line) { - /* swap files */ - finishedit((struct hshentry *)nil); swapeditfiles(false); - /* assumes edit only during last pass, from the beginning*/ - } - while (editline<line) { - /*copy another line*/ - if (delta) - VOID expandline(fedit,fcopy,delta,false,false); - else - while (putc(getc(fedit),fcopy)!='\n'); - editline++; - } -} - - - -xpandstring(delta) -struct hshentry * delta; -/* Function: Reads a string terminated by SDELIM from finptr and writes it - * to fcopy. Double SDELIM is replaced with single SDELIM. - * Keyword expansion is performed with data from delta. - * If rewriteflag==true, the string is also copied unchanged to frewrite. - * editline is updated. - */ -{ - editline=1; - while (expandline(finptr,fcopy,delta,true,rewriteflag)) editline++; - nextc='\n'; -} - - -copystring() -/* Function: copies a string terminated with a single SDELIM from finptr to - * fcopy, replacing all double SDELIM with a single SDELIM. - * If rewriteflag==true, the string also copied unchanged to frewrite. - * editline is set to (number of lines copied)+1. - * Assumption: next character read is first string character. - */ -{ register c; - register FILE *fin, *frew, *fcop; - register write; - - fin=finptr; frew=frewrite; fcop=fcopy; - write=rewriteflag; - editline=1; - while ((c=GETC(fin,frew,write)) != EOF) { - if ((c==SDELIM)&&((c=GETC(fin,frew,write)) != SDELIM)){ - /* end of string */ - nextc = c; - return; - } - VOID putc(c,fcop); - if (c=='\n') editline++; - } - nextc = c; - serror("Unterminated string"); - return; -} - - - - -editstring(delta) -struct hshentry * delta; -/* Function: reads an edit script from finptr and applies it to - * file fedit; the result is written to fcopy. - * If delta!=nil, keyword expansion is performed simultaneously. - * If frewrite==true, the edit script is also copied verbatim to frewrite. - * Assumes that all these files are open. - * If running out of lines in fedit, fedit and fcopy are swapped. - * resultfile and editfile are the names of the files that go with fcopy - * and fedit, respectively. - * Assumes the next input character from finptr is the first character of - * the edit script. Resets nextc on exit. - */ -{ - int ed; /* editor command */ - register int c; - register FILE *fin, *frew; - register int write, i; - int line, length; - - fin=finptr; frew=frewrite; - editline += linecorr; linecorr=0; /*correct line number*/ - write=rewriteflag; - for (;;) { - /* read next command and decode */ - /* assume next non-white character is command name*/ - while((ed=GETC(fin,frew,write))=='\n'|| - ed==' ' || ed=='\t'); - if (ed==SDELIM) break; - /* now attempt to read numbers. */ - /* fscanf causes trouble because of the required echoing */ - while ((c=GETC(fin,frew,write))==' '); /*skip spaces*/ - if (!('0'<=c && c<='9')) { - faterror("missing line number in edit script"); - break; - } - line= c -'0'; - while ('0'<=(c=GETC(fin,frew,write)) && c<='9') { - line = line*10 + c-'0'; - } - while (c==' ') c=GETC(fin,frew,write); - if (!('0'<=c && c<='9')) { - faterror("incorrect range in edit script"); - break; - } - length= c -'0'; - while ('0'<=(c=GETC(fin,frew,write)) && c<='9') { - length = length*10 + c-'0'; - } - while(c!='\n'&&c!=EOF) c=GETC(fin,frew,write); /* skip to end of line */ - - switch (ed) { - case 'd': - copylines(line,delta); - /* skip over unwanted lines */ - for (i=length;i>0;i--) { - /*skip next line*/ - while ((c=getc(fedit))!='\n') - if (c==EOF) - faterror("EOF during edit"); - editline++; - } - linecorr -= length; - break; - case 'a': - copylines(line+1,delta); /*copy only; no delete*/ - for (i=length;i>0;i--) { - /*copy next line from script*/ - if (delta!=nil) - VOID expandline(fin,fcopy,delta,true,write); - else { - c = GETC(fin,frew,write); - while (putc(c,fcopy)!='\n'){ - if ((c==SDELIM)&&((c=GETC(fin,frew,write))!=SDELIM)){ - serror("Missing string delimiter in edit script"); - VOID putc(c,fcopy); - } - c = GETC(fin,frew,write); - } - } - } - linecorr += length; - break; - default: - faterror("unknown command in edit script: %c", ed); - break; - } - } - nextc=GETC(fin,frew,write); -} - - - -/* The rest is for keyword expansion */ - - - -expandline(in, out, delta,delimstuffed,write) -register FILE * in, * out; struct hshentry * delta; -int delimstuffed, write; -/* Function: Reads a line from in and writes it to out. - * If delimstuffed==true, double SDELIM is replaced with single SDELIM. - * Keyword expansion is performed with data from delta. - * If write==true, the string is also copied unchanged to frewrite. - * Returns false if end-of-string or end-of-line is detected, true otherwise. - */ -{ - register c; - register FILE * frew; - register w, ds; - register char * tp; - char keystring[keylength+2]; - char keyval[keyvallength+2]; - enum markers matchresult; - - frew = frewrite; - w = write; - ds = delimstuffed; - c=GETC(in,frew,w); - for (;;) { - if (c==EOF) { - if(ds) { - error("unterminated string"); - nextc=c; - } - return(false); - } - - if (c==SDELIM && ds) { - if ((c=GETC(in,frew,w))!=SDELIM) { - /* end of string */ - nextc=c; - return false; - } - } - VOID putc(c,out); - - if (c=='\n') return true; /* end of line */ - - if (c==KDELIM) { - /* check for keyword */ - /* first, copy a long enough string into keystring */ - tp=keystring; - while (((c=GETC(in,frew,w))!=EOF) && (tp<keystring+keylength) && (c!='\n') - && (c!=SDELIM) && (c!=KDELIM) && (c!=VDELIM)) { - VOID putc(c,out); - *tp++ = c; - } - *tp++ = c; *tp = '\0'; - matchresult=trymatch(keystring,false); - if (matchresult==Nomatch) continue; - /* last c will be dealt with properly by continue*/ - - /* Now we have a keyword terminated with a K/VDELIM */ - if (c==VDELIM) { - /* try to find closing KDELIM, and replace value */ - tp=keyval; - while (((c=GETC(in,frew,w)) != EOF) - && (c!='\n') && (c!=KDELIM) && (tp<keyval+keyvallength)) { - *tp++ =c; - if (c==SDELIM && ds) { /*skip next SDELIM */ - c=GETC(in,frew,w); - /* Can't be at end of string. - /* always a \n before closing SDELIM */ - } - } - if (c!=KDELIM) { - /* couldn't find closing KDELIM -- give up */ - VOID putc(VDELIM,out); *tp='\0'; - VOID fputs(keyval,out); - continue; /* last c handled properly */ - } - } - /* now put out the new keyword value */ - keyreplace(matchresult,delta,out); - } - c=GETC(in,frew,w); - } /* end for */ -} - - - -keyreplace(marker,delta,out) -enum markers marker; struct hshentry * delta; register FILE * out; -/* function: ouputs the keyword value(s) corresponding to marker. - * Attributes are derived from delta. - */ -{ - char * date; - register char * sp; - - date= delta->date; - - switch (marker) { - case Author: - VOID fprintf(out,"%c %s %c",VDELIM,delta->author,KDELIM); - break; - case Date: - VOID putc(VDELIM,out);VOID putc(' ',out); - VOID PRINTDATE(out,date);VOID putc(' ',out); - VOID PRINTTIME(out,date);VOID putc(' ',out);VOID putc(KDELIM,out); - break; - case Id: - case Header: - VOID putc(VDELIM,out); VOID putc(' ',out); - if (marker==Id) - VOID fputs(bindex(RCSfilename,'/'),out); - else VOID fputs(getfullRCSname(),out); - VOID fprintf(out," %s ", delta->num); - VOID PRINTDATE(out,date);VOID putc(' ',out);VOID PRINTTIME(out,date); - VOID fprintf(out, " %s %s ",delta->author,delta->state); - if (delta->lockedby!=nil) - VOID fprintf(out,"Locker: %s ",delta->lockedby); - VOID putc(KDELIM,out); - break; - case Locker: - VOID fprintf(out,"%c %s %c", VDELIM, - delta->lockedby==nil?"":delta->lockedby,KDELIM); - break; - case Log: - VOID fprintf(out, "%c\t%s %c\n%sRevision %s ", - VDELIM, bindex(RCSfilename,'/'), KDELIM, Comment, delta->num); - VOID PRINTDATE(out,date);VOID fputs(" ",out);VOID PRINTTIME(out,date); - VOID fprintf(out, " %s\n%s",delta->author,Comment); - /* do not include state here because it may change and is not updated*/ - sp = delta->log; - while (*sp) if (putc(*sp++,out)=='\n') VOID fputs(Comment,out); - /* Comment is the comment leader */ - break; - case RCSfile: - VOID fprintf(out,"%c %s %c",VDELIM,bindex(RCSfilename,'/'),KDELIM); - break; - case Revision: - VOID fprintf(out,"%c %s %c",VDELIM,delta->num,KDELIM); - break; - case Source: - VOID fprintf(out,"%c %s %c",VDELIM,getfullRCSname(),KDELIM); - break; - case State: - VOID fprintf(out,"%c %s %c",VDELIM,delta->state,KDELIM); - break; - case Nomatch: - VOID putc(KDELIM,out); - break; - } -} - - diff --git a/usr.bin/rcs/src/rcsfcmp.c b/usr.bin/rcs/src/rcsfcmp.c deleted file mode 100644 index 7f0f9fa9756c..000000000000 --- a/usr.bin/rcs/src/rcsfcmp.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * RCS file comparison - */ -#ifndef lint -static char rcsid[]= "$Id: rcsfcmp.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/***************************************************************************** - * rcsfcmp() - * Testprogram: define FCMPTEST - ***************************************************************************** - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - - - -/* $Log: rcsfcmp.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.5 89/05/01 15:12:42 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.4 88/11/08 12:01:33 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.4 88/08/09 19:12:50 eggert - * Shrink stdio code size. - * - * Revision 4.3 87/12/18 11:40:02 narten - * lint cleanups (Guy Harris) - * - * Revision 4.2 87/10/18 10:33:06 narten - * updting version number. Changes relative to 1.1 actually relative to - * 4.1 - * - * Revision 1.2 87/03/27 14:22:19 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:23 kcs - * Initial revision - * - * Revision 4.1 83/05/10 16:24:04 wft - * Marker matching now uses trymatch(). Marker pattern is now - * checked precisely. - * - * Revision 3.1 82/12/04 13:21:40 wft - * Initial revision. - * - */ - -/* -#define FCMPTEST -/* Testprogram; prints out whether two files are identical, - * except for keywords - */ - -#include "rcsbase.h" -extern FILE * fopen(); -extern enum markers trymatch(); /* check for keywords */ - - -rcsfcmp(xfname,uxfname,delta) -char * xfname, *uxfname; struct hshentry *delta; -/* Function: compares the files xfname and uxfname. Returns true - * if xfname has the same contents as uxfname, while disregarding - * keyword values. For the LOG-keyword, rcsfcmp skips the log message - * given by the parameter delta in xfname. Thus, rcsfcmp returns true - * if xfname contains the same as uxfname, with the keywords expanded. - * Implementation: character-by-character comparison until $ is found. - * If a $ is found, read in the marker keywords; if they are real keywords - * and identical, read in keyword value. If value is terminated properly, - * disregard it and optionally skip log message; otherwise, compare value. - */ -{ - register int xc,uxc; - char xkeyword[keylength+2], uxkeyword[keylength+2]; - char xkeyval[keyvallength+1], uxkeyval[keyvallength+1]; - register FILE * xfp, * uxfp; - register char * tp; - int result; - enum markers match1,match2; - - if ((xfp=fopen(tp=xfname,"r"))==NULL || (uxfp=fopen(tp=uxfname,"r"))==NULL) { - faterror("Can't open %s\n", tp); - return false; - } - result=false; - xc=getc(xfp); uxc=getc(uxfp); - while( xc == uxc) { /* comparison loop */ - if (xc==EOF) { /* finished; everything is the same*/ - result=true; - break; - } - if ( xc!=KDELIM) { - /* get the next characters */ - xc=getc(xfp); uxc=getc(uxfp); - } else { - /* try to get both keywords */ - tp = xkeyword; - while( (xc=getc(xfp))!=EOF && (tp< xkeyword+keylength) && (xc!='\n') - && (xc!=KDELIM) && (xc!=VDELIM)) - *tp++ = xc; - *tp++ = xc; /* add closing K/VDELIM */ - *tp='\0'; - tp = uxkeyword; - while( (uxc=getc(uxfp))!=EOF && (tp< uxkeyword+keylength) && (uxc!='\n') - && (uxc!=KDELIM) && (uxc!=VDELIM)) - *tp++ = uxc; - *tp++ = xc; /* add closing K/VDELIM */ - *tp='\0'; - /* now we have 2 keywords, or something thal looks like it.*/ - match1=trymatch(xkeyword,false); - match2=trymatch(uxkeyword,false); - if (match1 != match2) break; /* not identical */ -#ifdef FCMPTEST - VOID printf("found potential keywords %s and %s\n",xkeyword,uxkeyword); -#endif - - if (match1 == Nomatch) { - /* not a keyword pattern, but could still be identical */ - if (strcmp(xkeyword,uxkeyword)==0) - continue; - else break; - } -#ifdef FCMPTEST - VOID printf("found common keyword %s\n",xkeyword); -#endif - tp=xkeyval; - if (xc==VDELIM) {/* get value */ - while (((xc=getc(xfp))!=KDELIM) && (xc!='\n') && (xc!=EOF) && - (tp<xkeyval+keyvallength)) - *tp++ = xc; - } - *tp = '\0'; /*xkeyval now filled with value; possibly empty*/ - tp=uxkeyval; - if (uxc==VDELIM) {/* get value */ - while (((uxc=getc(uxfp))!=KDELIM) && (uxc!='\n') && (uxc!=EOF) && - (tp<uxkeyval+keyvallength)) - *tp++ = uxc; - } - *tp = '\0'; /*uxkeyval now filled with value; possibly empty*/ - if (xc!=uxc) break; /* not the same */ - if (xc==KDELIM) { - xc=getc(xfp); uxc=getc(uxfp); /* skip closing KDELIM */ - /* if the keyword is LOG, also skip the log message in xfp*/ - if (match1==Log) { - /* first, compute the number of line feeds in log msg */ - int lncnt, ccnt; - lncnt=2; tp=delta->log; - while(*tp) if(*tp++=='\n') lncnt++; - while(xc!=EOF) { - if (xc=='\n') - if(--lncnt==0) break; - xc=getc(xfp); - } - /* skip last comment leader */ - /* Can't just skip another line here, because there may be */ - /* additional characters on the line (after the Log....$) */ - for (ccnt=strlen(Comment); ccnt>=0; lncnt--) { - xc=getc(xfp); - if(xc=='\n') break; - /* reads to the end of the comment leader or '\n', */ - /* whatever comes first. This is because some editors */ - /* strip off trailing blanks from a leader like " * ". */ - } - } - } else { - /* both end in the same character, but not a KDELIM */ - /* must compare string values.*/ -#ifdef FCMPTEST - VOID printf("non-terminated keywords %s, potentially different values\n",xkeyword); -#endif - if (strcmp(xkeyval,uxkeyval)!=0) break; /*different */ - xc=getc(xfp); uxc=getc(uxfp); /* skip closing char */ - } - } - } - VOID fclose(xfp); VOID fclose(uxfp); - return result; -} - - - -#ifdef FCMPTEST -char * RCSfilename, * workfilename; - -char * Comment; - -main(argc, argv) -int argc; char *argv[]; -/* first argument: comment leader; 2nd: log message, 3rd: expanded file, - * 4th: unexpanded file - */ -{ struct hshentry delta; - - cmdid="rcsfcmp"; - Comment=argv[1]; - delta.log=argv[2]; - if (rcsfcmp(argv[3],argv[4],&delta)) - VOID printf("files are the same\n"); - else VOID printf("files are different\n"); -} -#endif diff --git a/usr.bin/rcs/src/rcsfnms.c b/usr.bin/rcs/src/rcsfnms.c deleted file mode 100644 index 300e9bfaec44..000000000000 --- a/usr.bin/rcs/src/rcsfnms.c +++ /dev/null @@ -1,790 +0,0 @@ -/* - * RCS file name handling - */ -#ifndef lint - static char - rcsid[]= "$Id: rcsfnms.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/**************************************************************************** - * creation and deletion of semaphorefile, - * creation of temporary filenames and cleanup() - * pairing of RCS file names and working file names. - * Testprogram: define PAIRTEST - **************************************************************************** - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - - -/* $Log: rcsfnms.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 3.12 89/08/15 21:38:10 bostic - * Version 4 from Tom Narten at Purdue - * - * Revision 4.8 89/05/01 15:09:41 narten - * changed getwd to not stat empty directories. - * - * Revision 4.7 88/11/08 12:01:22 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.7 88/08/09 19:12:53 eggert - * Fix troff macro comment leader bug; add Prolog; allow cc -R; remove lint. - * - * Revision 4.6 87/12/18 11:40:23 narten - * additional file types added from 4.3 BSD version, and SPARC assembler - * comment character added. Also, more lint cleanups. (Guy Harris) - * - * Revision 4.5 87/10/18 10:34:16 narten - * Updating version numbers. Changes relative to 1.1 actually relative - * to verion 4.3 - * - * Revision 1.3 87/03/27 14:22:21 jenkins - * Port to suns - * - * Revision 1.2 85/06/26 07:34:28 svb - * Comment leader '% ' for '*.tex' files added. - * - * Revision 1.1 84/01/23 14:50:24 kcs - * Initial revision - * - * Revision 4.3 83/12/15 12:26:48 wft - * Added check for KDELIM in file names to pairfilenames(). - * - * Revision 4.2 83/12/02 22:47:45 wft - * Added csh, red, and sl file name suffixes. - * - * Revision 4.1 83/05/11 16:23:39 wft - * Added initialization of Dbranch to InitAdmin(). Canged pairfilenames(): - * 1. added copying of path from workfile to RCS file, if RCS file is omitted; - * 2. added getting the file status of RCS and working files; - * 3. added ignoring of directories. - * - * Revision 3.7 83/05/11 15:01:58 wft - * Added comtable[] which pairs file name suffixes with comment leaders; - * updated InitAdmin() accordingly. - * - * Revision 3.6 83/04/05 14:47:36 wft - * fixed Suffix in InitAdmin(). - * - * Revision 3.5 83/01/17 18:01:04 wft - * Added getwd() and rename(); these can be removed by defining - * V4_2BSD, since they are not needed in 4.2 bsd. - * Changed sys/param.h to sys/types.h. - * - * Revision 3.4 82/12/08 21:55:20 wft - * removed unused variable. - * - * Revision 3.3 82/11/28 20:31:37 wft - * Changed mktempfile() to store the generated file names. - * Changed getfullRCSname() to store the file and pathname, and to - * delete leading "../" and "./". - * - * Revision 3.2 82/11/12 14:29:40 wft - * changed pairfilenames() to handle file.sfx,v; also deleted checkpathnosfx(), - * checksuffix(), checkfullpath(). Semaphore name generation updated. - * mktempfile() now checks for nil path; freefilename initialized properly. - * Added Suffix .h to InitAdmin. Added testprogram PAIRTEST. - * Moved rmsema, trysema, trydiraccess, getfullRCSname from rcsutil.c to here. - * - * Revision 3.1 82/10/18 14:51:28 wft - * InitAdmin() now initializes StrictLocks=STRICT_LOCKING (def. in rcsbase.h). - * renamed checkpath() to checkfullpath(). - */ - - -#include "rcsbase.h" -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/dir.h> - -extern char * rindex(); -extern char * mktemp(); -extern FILE * fopen(); -extern char * getwd(); /* get working directory; forward decl */ -extern int stat(), fstat(); - -extern FILE * finptr; /* RCS input file descriptor */ -extern FILE * frewrite; /* New RCS file descriptor */ -extern char * RCSfilename, * workfilename; /* filenames */ -struct stat RCSstat, workstat; /* file status for RCS file and working file */ -int haveRCSstat, haveworkstat; /* indicators if status availalble */ - - -char tempfilename [NCPFN+10]; /* used for derived file names */ -char sub1filename [NCPPN]; /* used for files path/file.sfx,v */ -char sub2filename [NCPPN]; /* used for files path/RCS/file.sfx,v */ -char semafilename [NCPPN]; /* name of semaphore file */ -int madesema; /* indicates whether a semaphore file has been set */ -char * tfnames[10]; /* temp. file names to be unlinked when finished */ -int freefilename; /* index of next free file name in tfnames[] */ - - -struct compair { - char * suffix, * comlead; -}; - -struct compair comtable[] = { -/* comtable pairs each filename suffix with a comment leader. The comment */ -/* leader is placed before each line generated by the $Log keyword. This */ -/* table is used to guess the proper comment leader from the working file's */ -/* suffix during initial ci (see InitAdmin()). Comment leaders are needed */ -/* for languages without multiline comments; for others they are optional. */ - "c", " * ", /* C */ - "csh", "# ", /* shell */ - "e", "# ", /* efl */ - "f", "c ", /* fortran */ - "h", " * ", /* C-header */ - "l", " * ", /* lex NOTE: conflict between lex and franzlisp*/ - "mac", "; ", /* macro vms or dec-20 or pdp-11 macro */ - "me", ".\\\" ",/* me-macros t/nroff*/ - "mm", ".\\\" ",/* mm-macros t/nroff*/ - "ms", ".\\\" ",/* ms-macros t/nroff*/ - "p", " * ", /* pascal */ - "pl", "% ", /* prolog */ - "r", "# ", /* ratfor */ - "red", "% ", /* psl/rlisp */ - -#ifdef sparc - "s", "! ", /* assembler */ -#endif -#ifdef mc68000 - "s", "| ", /* assembler */ -#endif -#ifdef pdp11 - "s", "/ ", /* assembler */ -#endif -#ifdef vax - "s", "# ", /* assembler */ -#endif - - "sh", "# ", /* shell */ - "sl", "% ", /* psl */ - "red", "% ", /* psl/rlisp */ - "cl", ";;; ", /* common lisp */ - "ml", "; ", /* mocklisp */ - "el", "; ", /* gnulisp */ - "tex", "% ", /* tex */ - "y", " * ", /* yacc */ - "ye", " * ", /* yacc-efl */ - "yr", " * ", /* yacc-ratfor */ - "", "# ", /* default for empty suffix */ - nil, "" /* default for unknown suffix; must always be last */ -}; - - -ffclose(fptr) -FILE * fptr; -/* Function: checks ferror(fptr) and aborts the program if there were - * errors; otherwise closes fptr. - */ -{ if (ferror(fptr) || fclose(fptr)==EOF) - faterror("File read or write error; file system full?"); -} - - - -int trysema(RCSname,makesema) -char * RCSname; int makesema; -/* Function: Checks whether a semaphore file exists for RCSname. If yes, - * returns false. If not, creates one if makesema==true and returns true - * if successful. If a semaphore file was created, madesema is set to true. - * The name of the semaphore file is put into variable semafilename. - */ -{ - register char * tp, *sp, *lp; - int fdesc; - - sp=RCSname; - lp = rindex(sp,'/'); - if (lp==0) { - semafilename[0]='.'; semafilename[1]='/'; - tp= &semafilename[2]; - } else { - /* copy path */ - tp=semafilename; - do *tp++ = *sp++; while (sp<=lp); - } - /*now insert `,' and append file name */ - *tp++ = ','; - lp = rindex(sp, RCSSEP); - while (sp<lp) *tp++ = *sp++; - *tp++ = ','; *tp++ = '\0'; /* will be the same length as RCSname*/ - - madesema = false; - if (access(semafilename, 0) == 0) { - error("RCS file %s is in use",RCSname); - return false; - } - if (makesema) { - if ((fdesc=creat(semafilename, 000)) == -1) { - error("Can't create semaphore file for RCS file %s",RCSname); - return false; - } else - VOID close(fdesc); - madesema=true; - } - return true; -} - - -rmsema() -/* Function: delete the semaphore file if madeseam==true; - * sets madesema to false. - */ -{ - if (madesema) { - madesema=false; - if (unlink(semafilename) == -1) { - error("Can't find semaphore file %s",semafilename); - } - } -} - - - -InitCleanup() -{ freefilename = 0; /* initialize pointer */ -} - - -cleanup() -/* Function: closes input file and rewrite file. - * Unlinks files in tfnames[], deletes semaphore file. - */ -{ - register int i; - - if (finptr!=NULL) VOID fclose(finptr); - if (frewrite!=NULL) VOID fclose(frewrite); - for (i=0; i<freefilename; i++) { - if (tfnames[i][0]!='\0') VOID unlink(tfnames[i]); - } - InitCleanup(); - rmsema(); -} - - -char * mktempfile(fullpath,filename) -register char * fullpath, * filename; -/* Function: Creates a unique filename using the process id and stores it - * into a free slot in tfnames. The filename consists of the path contained - * in fullpath concatenated with filename. filename should end in "XXXXXX". - * Because of storage in tfnames, cleanup() can unlink the file later. - * freefilename indicates the lowest unoccupied slot in tfnames. - * Returns a pointer to the filename created. - * Example use: mktempfile("/tmp/", somefilename) - */ -{ - register char * lastslash, *tp; - if ((tp=tfnames[freefilename])==nil) - tp=tfnames[freefilename] = talloc(NCPPN); - if (fullpath!=nil && (lastslash=rindex(fullpath,'/'))!=0) { - /* copy path */ - while (fullpath<=lastslash) *tp++ = *fullpath++; - } - while (*tp++ = *filename++); - return (mktemp(tfnames[freefilename++])); -} - - - - -char * bindex(sp,c) -register char * sp, c; -/* Function: Finds the last occurrence of character c in string sp - * and returns a pointer to the character just beyond it. If the - * character doesn't occur in the string, sp is returned. - */ -{ register char * r; - r = sp; - while (*sp) { - if (*sp++ == c) r=sp; - } - return r; -} - - - - - -InitAdmin() -/* function: initializes an admin node */ -{ register char * Suffix; - register int i; - - Head=Dbranch=nil; AccessList=nil; Symbols=nil; Locks=nil; - StrictLocks=STRICT_LOCKING; - - /* guess the comment leader from the suffix*/ - Suffix=bindex(workfilename, '.'); - if (Suffix==workfilename) Suffix= ""; /* empty suffix; will get default*/ - for (i=0;;i++) { - if (comtable[i].suffix==nil) { - Comment=comtable[i].comlead; /*default*/ - break; - } elsif (strcmp(Suffix,comtable[i].suffix)==0) { - Comment=comtable[i].comlead; /*default*/ - break; - } - } - Lexinit(); /* Note: if finptr==NULL, reads nothing; only initializes*/ -} - - - -char * findpairfile(argc, argv, fname) -int argc; char * argv[], *fname; -/* Function: Given a filename fname, findpairfile scans argv for a pathname - * ending in fname. If found, returns a pointer to the pathname, and sets - * the corresponding pointer in argv to nil. Otherwise returns fname. - * argc indicates the number of entries in argv. Some of them may be nil. - */ -{ - register char * * next, * match; - register int count; - - for (next = argv, count = argc; count>0; next++,count--) { - if ((*next != nil) && strcmp(bindex(*next,'/'),fname)==0) { - /* bindex finds the beginning of the file name stem */ - match= *next; - *next=nil; - return match; - } - } - return fname; -} - - -int pairfilenames(argc, argv, mustread, tostdout) -int argc; char ** argv; int mustread, tostdout; -/* Function: Pairs the filenames pointed to by argv; argc indicates - * how many there are. - * Places a pointer to the RCS filename into RCSfilename, - * and a pointer to the name of the working file into workfilename. - * If both the workfilename and the RCS filename are given, and tostdout - * is true, a warning is printed. - * - * If the working file exists, places its status into workstat and - * sets haveworkstat to 0; otherwise, haveworkstat is set to -1; - * Similarly for the RCS file and the variables RCSstat and haveRCSstat. - * - * If the RCS file exists, it is opened for reading, the file pointer - * is placed into finptr, and the admin-node is read in; returns 1. - * If the RCS file does not exist and mustread==true, an error is printed - * and 0 returned. - * If the RCS file does not exist and mustread==false, the admin node - * is initialized to empty (Head, AccessList, Locks, Symbols, StrictLocks, Dbranch) - * and -1 returned. - * - * 0 is returned on all errors. Files that are directories are errors. - * Also calls InitCleanup(); - */ -{ - register char * sp, * tp; - char * lastsep, * purefname, * pureRCSname; - int opened, returncode; - char * RCS1; - char prefdir[NCPPN]; - - if (*argv == nil) return 0; /* already paired filename */ - if (rindex(*argv,KDELIM)!=0) { - /* KDELIM causes havoc in keyword expansion */ - error("RCS file name may not contain %c",KDELIM); - return 0; - } - InitCleanup(); - - /* first check suffix to see whether it is an RCS file or not */ - purefname=bindex(*argv, '/'); /* skip path */ - lastsep=rindex(purefname, RCSSEP); - if (lastsep!= 0 && *(lastsep+1)==RCSSUF && *(lastsep+2)=='\0') { - /* RCS file name given*/ - RCS1=(*argv); pureRCSname=purefname; - /* derive workfilename*/ - sp = purefname; tp=tempfilename; - while (sp<lastsep) *tp++ = *sp++; *tp='\0'; - /* try to find workfile name among arguments */ - workfilename=findpairfile(argc-1,argv+1,tempfilename); - if (strlen(pureRCSname)>NCPFN) { - error("RCS file name %s too long",RCS1); - return 0; - } - } else { - /* working file given; now try to find RCS file */ - workfilename= *argv; - /* derive RCS file name*/ - sp=purefname; tp=tempfilename; - while (*tp++ = *sp++); - *(tp-1)=RCSSEP; *tp++=RCSSUF; *tp++='\0'; - /* Try to find RCS file name among arguments*/ - RCS1=findpairfile(argc-1,argv+1,tempfilename); - pureRCSname=bindex(RCS1, '/'); - if (strlen(pureRCSname)>NCPFN) { - error("working file name %s too long",workfilename); - return 0; - } - } - /* now we have a (tentative) RCS filename in RCS1 and workfilename */ - /* First, get status of workfilename */ - haveworkstat=stat(workfilename, &workstat); - if ((haveworkstat==0) && ((workstat.st_mode & S_IFDIR) == S_IFDIR)) { - diagnose("Directory %s ignored",workfilename); - return 0; - } - /* Second, try to find the right RCS file */ - if (pureRCSname!=RCS1) { - /* a path for RCSfile is given; single RCS file to look for */ - finptr=fopen(RCSfilename=RCS1, "r"); - if (finptr!=NULL) { - returncode=1; - } else { /* could not open */ - if (access(RCSfilename,0)==0) { - error("Can't open existing %s", RCSfilename); - return 0; - } - if (mustread) { - error("Can't find %s", RCSfilename); - return 0; - } else { - /* initialize if not mustread */ - returncode = -1; - } - } - } else { - /* no path for RCS file name. Prefix it with path of work */ - /* file if RCS file omitted. Make a second name including */ - /* RCSDIR and try to open that one first. */ - sub1filename[0]=sub2filename[0]= '\0'; - if (RCS1==tempfilename) { - /* RCS file name not given; prepend work path */ - sp= *argv; tp= sub1filename; - while (sp<purefname) *tp++ = *sp ++; - *tp='\0'; - VOID strcpy(sub2filename,sub1filename); /* second one */ - } - VOID strcat(sub1filename,RCSDIR); - VOID strcpy(prefdir,sub1filename); /* preferred directory for RCS file*/ - VOID strcat(sub1filename,RCS1); VOID strcat(sub2filename,RCS1); - - - opened=( - ((finptr=fopen(RCSfilename=sub1filename, "r"))!=NULL) || - ((finptr=fopen(RCSfilename=sub2filename,"r"))!=NULL) ); - - if (opened) { - /* open succeeded */ - returncode=1; - } else { - /* open failed; may be read protected */ - if ((access(RCSfilename=sub1filename,0)==0) || - (access(RCSfilename=sub2filename,0)==0)) { - error("Can't open existing %s",RCSfilename); - return 0; - } - if (mustread) { - error("Can't find %s nor %s",sub1filename,sub2filename); - return 0; - } else { - /* initialize new file. Put into ./RCS if possible, strip off suffix*/ - RCSfilename= (access(prefdir,0)==0)?sub1filename:sub2filename; - returncode= -1; - } - } - } - - if (returncode == 1) { /* RCS file open */ - haveRCSstat=fstat(fileno(finptr),&RCSstat); - if ((haveRCSstat== 0) && ((RCSstat.st_mode & S_IFDIR) == S_IFDIR)) { - diagnose("Directory %s ignored",RCSfilename); - return 0; - } - Lexinit(); getadmin(); - } else { /* returncode == -1; RCS file nonexisting */ - haveRCSstat = -1; - InitAdmin(); - }; - - if (tostdout&& - !(RCS1==tempfilename||workfilename==tempfilename)) - /*The last term determines whether a pair of */ - /* file names was given in the argument list */ - warn("Option -p is set; ignoring output file %s",workfilename); - - return returncode; -} - - -char * getfullRCSname() -/* Function: returns a pointer to the full path name of the RCS file. - * Calls getwd(), but only once. - * removes leading "../" and "./". - */ -{ static char pathbuf[NCPPN]; - static char namebuf[NCPPN]; - static int pathlength; - - register char * realname, * lastpathchar; - register int dotdotcounter, realpathlength; - - if (*RCSfilename=='/') { - return(RCSfilename); - } else { - if (pathlength==0) { /*call curdir for the first time*/ - if (getwd(pathbuf)==NULL) - faterror("Can't build current directory path"); - pathlength=strlen(pathbuf); - if (!((pathlength==1) && (pathbuf[0]=='/'))) { - pathbuf[pathlength++]='/'; - /* Check needed because some getwd implementations */ - /* generate "/" for the root. */ - } - } - /*the following must be redone since RCSfilename may change*/ - /* find how many ../ to remvove from RCSfilename */ - dotdotcounter =0; - realname = RCSfilename; - while( realname[0]=='.' && - (realname[1]=='/'||(realname[1]=='.'&&realname[2]=='/'))){ - if (realname[1]=='/') { - /* drop leading ./ */ - realname += 2; - } else { - /* drop leading ../ and remember */ - dotdotcounter++; - realname += 3; - } - } - /* now remove dotdotcounter trailing directories from pathbuf*/ - lastpathchar=pathbuf + pathlength-1; - while (dotdotcounter>0 && lastpathchar>pathbuf) { - /* move pointer backwards over trailing directory */ - lastpathchar--; - if (*lastpathchar=='/') { - dotdotcounter--; - } - } - if (dotdotcounter>0) { - error("Can't generate full path name for RCS file"); - return RCSfilename; - } else { - /* build full path name */ - realpathlength=lastpathchar-pathbuf+1; - VOID strncpy(namebuf,pathbuf,realpathlength); - VOID strcpy(&namebuf[realpathlength],realname); - return(namebuf); - } - } -} - - - -int trydiraccess(filename) -char * filename; -/* checks write permission in directory of filename and returns - * true if writable, false otherwise - */ -{ - char pathname[NCPPN]; - register char * tp, *sp, *lp; - lp = rindex(filename,'/'); - if (lp==0) { - /* check current directory */ - if (access(".",2)==0) - return true; - else { - error("Current directory not writable"); - return false; - } - } - /* copy path */ - sp=filename; - tp=pathname; - do *tp++ = *sp++; while (sp<=lp); - *tp='\0'; - if (access(pathname,2)==0) - return true; - else { - error("Directory %s not writable", pathname); - return false; - } -} - - - -#ifndef V4_2BSD -/* rename() and getwd() will be provided in bsd 4.2 */ - - -int rename(from, to) -char * from, *to; -/* Function: renames a file with the name given by from to the name given by to. - * unlinks the to-file if it already exists. returns -1 on error, 0 otherwise. - */ -{ VOID unlink(to); /* no need to check return code; will be caught by link*/ - /* no harm done if file "to" does not exist */ - if (link(from,to)<0) return -1; - return(unlink(from)); -} - - - -#define dot "." -#define dotdot ".." - - - -char * getwd(name) -char * name; -/* Function: places full pathname of current working directory into name and - * returns name on success, NULL on failure. - * getwd is an adaptation of pwd. May not return to the current directory on - * failure. - */ -{ - FILE *file; - struct stat d, dd; - char buf[2]; /* to NUL-terminate dir.d_name */ - struct direct dir; - - int rdev, rino; - int off; - register i,j; - - name[off= 0] = '/'; - name[1] = '\0'; - buf[0] = '\0'; - if (stat("/", &d)<0) return NULL; - rdev = d.st_dev; - rino = d.st_ino; - for (;;) { - if (stat(dot, &d)<0) return NULL; - if (d.st_ino==rino && d.st_dev==rdev) { - if (name[off] == '/') name[off] = '\0'; - chdir(name); /*change back to current directory*/ - return name; - } - if ((file = fopen(dotdot,"r")) == NULL) return NULL; - if (fstat(fileno(file), &dd)<0) goto fail; - chdir(dotdot); - if(d.st_dev == dd.st_dev) { - if(d.st_ino == dd.st_ino) { - if (name[off] == '/') name[off] = '\0'; - chdir(name); /*change back to current directory*/ - VOID fclose(file); - return name; - } - do { - if (fread((char *)&dir, sizeof(dir), 1, file) !=1) - goto fail; - } while (dir.d_ino != d.st_ino); - } - else do { - if(fread((char *)&dir, sizeof(dir), 1, file) != 1) { - goto fail; - } - if (dir.d_ino == 0) - dd.st_ino = d.st_ino + 1; - else if (stat(dir.d_name, &dd) < 0) - goto fail; - } while(dd.st_ino != d.st_ino || dd.st_dev != d.st_dev); - VOID fclose(file); - - /* concatenate file name */ - i = -1; - while (dir.d_name[++i] != 0); - for(j=off+1; j>0; --j) - name[j+i+1] = name[j]; - off=i+off+1; - name[i+1] = '/'; - for(--i; i>=0; --i) - name[i+1] = dir.d_name[i]; - } /* end for */ - -fail: VOID fclose(file); - return NULL; -} - - -#endif - - -#ifdef PAIRTEST -/* test program for pairfilenames() and getfullRCSname() */ -char * workfilename, *RCSfilename; -extern int quietflag; - -main(argc, argv) -int argc; char *argv[]; -{ - int result; - int initflag,tostdout; - quietflag=tostdout=initflag=false; - cmdid="pair"; - - while(--argc, ++argv, argc>=1 && ((*argv)[0] == '-')) { - switch ((*argv)[1]) { - - case 'p': tostdout=true; - break; - case 'i': initflag=true; - break; - case 'q': quietflag=true; - break; - default: error("unknown option: %s", *argv); - break; - } - } - - do { - RCSfilename=workfilename=nil; - result=pairfilenames(argc,argv,!initflag,tostdout); - if (result!=0) { - diagnose("RCSfile: %s; working file: %s",RCSfilename,workfilename); - diagnose("Full RCS file name: %s", getfullRCSname()); - } - switch (result) { - case 0: continue; /* already paired file */ - - case 1: if (initflag) { - error("RCS file %s exists already",RCSfilename); - } else { - diagnose("RCS file %s exists",RCSfilename); - } - VOID fclose(finptr); - break; - - case -1:diagnose("RCS file does not exist"); - break; - } - - } while (++argv, --argc>=1); - -} -#endif diff --git a/usr.bin/rcs/src/rcsfreeze.sh b/usr.bin/rcs/src/rcsfreeze.sh deleted file mode 100644 index b76180674614..000000000000 --- a/usr.bin/rcs/src/rcsfreeze.sh +++ /dev/null @@ -1,94 +0,0 @@ -#! /bin/sh -PATH=/usr/local/bin:/bin:/usr/bin:/usr/ucb -# 'rcsfreeze' has the purpose of assigning a symbolic revision -# number to a set of RCS files, which form a valid configuration. -# -# The idea is to run rcsfreeze each time a new version is checked -# in. A unique symbolic revision number (C_[number], where number -# is increased each time rcsfreeze is run) is then assigned to the most -# recent revision of each RCS file of the main trunk. -# -# If the command is invoked with an argument, then this -# argument is used as the symbolic name to freeze a configuration. -# The unique identifier is still generated -# and is listed in the log file but it will not appear as -# part of the symbolic revision name in the actual RCS file. -# -# A log message is requested from the user which is saved for future -# references. -# -# The shell script works only on all RCS files at one time. -# It is important that all changed files are checked in (there are -# no precautions against any error in this respect). -# file names: -# {RCS/}rcsfreeze.version for the version number -# {RCS/}rscfreeze.log for the log messages, most recent -# logmessage first. - -progname=`basename $0` -DATE=`date` -# Check whether we have an RCS subdirectory, so we can have the right -# prefix for our paths. -if [ -d RCS ] ; then - RCSDIR=RCS -else - RCSDIR=. -fi - -# Version number stuff, log message file -VERSIONFILE=$RCSDIR/.rcsfreeze.version -LOGFILE=$RCSDIR/.rcsfreeze.log -if [ ! -r $VERSIONFILE ] ; then -# Initialize, rcsfreeze never run before in the current directory - cat << EOF > $VERSIONFILE -0 -EOF - touch $LOGFILE -fi - -# Get Version number, increase it, write back to file. -VERSIONNUMBER=`cat $VERSIONFILE` -VERSIONNUMBER=`expr $VERSIONNUMBER + 1` - cat << EOF > $VERSIONFILE -$VERSIONNUMBER -EOF - -# Symbolic Revision Number -SYMREV=C_$VERSIONNUMBER -# Allow the user to give a meaningful symbolic name to the revision. -SYMREVNAME=${1-$SYMREV} -echo "$progname: symbolic revision number computed: \"$SYMREV\"" -echo "$progname: symbolic revision number used: \"$SYMREVNAME\"" -echo "$progname: the two differ only when $progname invoked with argument" - -# Stamp the logfile. Because we order the logfile the most recent -# first we will have to save everything right now in a temporary file. -TMPLOG=/tmp/rcsfreeze.$$.log.tmp -echo "Version: $SYMREVNAME($SYMREV), Date: $DATE" > $TMPLOG -echo "-----------" >> $TMPLOG -# Now ask for a log message, continously add to the log file -echo "$progname: give log message, summarizing changes" -echo " (terminate with ^D or single '.')" -while read MESS ; do - if [ "$MESS" = '.' ] ; then break ; fi - echo " $MESS" >> $TMPLOG -done -echo "-----------" >> $TMPLOG -echo >> $TMPLOG - -# combine old and new logfiles -TMPLOG2=$TMPLOG.2 -cat $TMPLOG $LOGFILE > $TMPLOG2 -cp $TMPLOG2 $LOGFILE -rm -f $TMPLOG $TMPLOG2 - -# Now the real work begins by assigning a symbolic revision number -# to each rcs file. Take the most recent version of the main trunk. - -for FILE in $RCSDIR/* ; do -# get the revision number of the most recent revision - REV=`rlog -h -d"$DATE" $FILE | fgrep 'head:' | awk ' { print $2 } ' ` - echo "$progname: file name: \"$FILE\", Revision Number: $REV" -# assign symbolic name to it. - rcs -q -n$SYMREVNAME:$REV $FILE -done diff --git a/usr.bin/rcs/src/rcsgen.c b/usr.bin/rcs/src/rcsgen.c deleted file mode 100644 index 9ad4d6d8422f..000000000000 --- a/usr.bin/rcs/src/rcsgen.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * RCS revision generation - */ -#ifndef lint -static char rcsid[]= "$Id: rcsgen.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - -/* $Log: rcsgen.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 3.8 89/08/15 21:38:51 bostic - * Version 4 from Tom Narten at Purdue - * - * Revision 4.7 89/05/01 15:12:49 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.6 88/11/08 12:01:13 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.6 88/08/28 14:59:10 eggert - * Shrink stdio code size; allow cc -R; remove lint; isatty() -> ttystdin() - * - * Revision 4.5 87/12/18 11:43:25 narten - * additional lint cleanups, and a bug fix from the 4.3BSD version that - * keeps "ci" from sticking a '\377' into the description if you run it - * with a zero-length file as the description. (Guy Harris) - * - * Revision 4.4 87/10/18 10:35:10 narten - * Updating version numbers. Changes relative to 1.1 actually relative to - * 4.2 - * - * Revision 1.3 87/09/24 13:59:51 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:27 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:28 kcs - * Initial revision - * - * Revision 4.2 83/12/02 23:01:39 wft - * merged 4.1 and 3.3.1.1 (clearerr(stdin)). - * - * Revision 4.1 83/05/10 16:03:33 wft - * Changed putamin() to abort if trying to reread redirected stdin. - * Fixed getdesc() to output a prompt on initial newline. - * - * Revision 3.3.1.1 83/10/19 04:21:51 lepreau - * Added clearerr(stdin) for re-reading description from stdin. - * - * Revision 3.3 82/11/28 21:36:49 wft - * 4.2 prerelease - * - * Revision 3.3 82/11/28 21:36:49 wft - * Replaced ferror() followed by fclose() with ffclose(). - * Putdesc() now suppresses the prompts if stdin - * is not a terminal. A pointer to the current log message is now - * inserted into the corresponding delta, rather than leaving it in a - * global variable. - * - * Revision 3.2 82/10/18 21:11:26 wft - * I added checks for write errors during editing, and improved - * the prompt on putdesc(). - * - * Revision 3.1 82/10/13 15:55:09 wft - * corrected type of variables assigned to by getc (char --> int) - */ - - - - -#include "rcsbase.h" - -extern struct hshentry * getnum(); -extern FILE * fopen(); -extern savestring(); -extern editstring(); - -extern int nextc; /* next character from lexical analyzer */ -extern char Ktext[]; /* keywords from syntax analyzer */ -extern char Klog[]; /* Keyword "log" */ -extern char Kdesc[]; /* Keyword for description */ -extern FILE * frewrite; /* new RCS file */ -extern FILE * fcopy; /* result file during editing */ -extern char * resultfile; /* file name for fcopy */ -extern int rewriteflag; /* indicates whether to rewrite the input file */ - - -char curlogmsg[logsize]; /* buffer for current log message */ - -enum stringwork {copy, edit, expand, edit_expand }; -/* parameter to scandeltatext() */ - - - - -char * buildrevision(deltas, target, dir, expandflag) -struct hshentry ** deltas, * target; -char * dir; int expandflag; -/* Function: Generates the revision given by target - * by retrieving all deltas given by parameter deltas and combining them. - * If dir==nil, the revision is printed on the standard output, - * otherwise written into a temporary file in directory dir. - * if expandflag==true, keyword expansion is performed. - * returns false on errors, the name of the file with the revision otherwise. - * - * Algorithm: Copy inital revision unchanged. Then edit all revisions but - * the last one into it, alternating input and output files (resultfile and - * editfile). The last revision is then edited in, performing simultaneous - * keyword substitution (this saves one extra pass). - * All this simplifies if only one revision needs to be generated, - * or no keyword expansion is necessary, or if output goes to stdout. - */ -{ - int i; - - if (deltas[0]==target) { - /* only latest revision to generate */ - if (dir==nil) {/* print directly to stdout */ - fcopy=stdout; - scandeltatext(target,expand); - return(char *) true; - } else { - initeditfiles(dir); - scandeltatext(target,expandflag?expand:copy); - ffclose(fcopy); - return(resultfile); - } - } else { - /* several revisions to generate */ - initeditfiles(dir?dir:"/tmp/"); - /* write initial revision into fcopy, no keyword expansion */ - scandeltatext(deltas[0],copy); - i = 1; - while (deltas[i+1] != nil) { - /* do all deltas except last one */ - scandeltatext(deltas[i++],edit); - } - if (!expandflag) { - /* no keyword expansion; only invoked from ci */ - scandeltatext(deltas[i],edit); - finishedit((struct hshentry *)nil); - ffclose(fcopy); - } else { - /* perform keyword expansion*/ - /* first, get to beginning of file*/ - finishedit((struct hshentry *)nil); swapeditfiles(dir==nil); - scandeltatext(deltas[i],edit_expand); - finishedit(deltas[i]); - if (dir!=nil) ffclose(fcopy); - } - return(resultfile); /*doesn't matter for dir==nil*/ - } -} - - - -scandeltatext(delta,func) -struct hshentry * delta; enum stringwork func; -/* Function: Scans delta text nodes up to and including the one given - * by delta. For the one given by delta, the log message is saved into - * curlogmsg and the text is processed according to parameter func. - * Assumes the initial lexeme must be read in first. - * Does not advance nexttok after it is finished. - */ -{ struct hshentry * nextdelta; - - do { - nextlex(); - if (!(nextdelta=getnum())) { - fatserror("Can't find delta for revision %s", delta->num); - } - if (!getkey(Klog) || nexttok!=STRING) - serror("Missing log entry"); - elsif (delta==nextdelta) { - VOID savestring(curlogmsg,logsize); - delta->log=curlogmsg; - } else {readstring(); - delta->log= ""; - } - nextlex(); - if (!getkey(Ktext) || nexttok!=STRING) - fatserror("Missing delta text"); - - if(delta==nextdelta) - /* got the one we're looking for */ - switch (func) { - case copy: copystring(); - break; - case expand: xpandstring(delta); - break; - case edit: editstring((struct hshentry *)nil); - break; - case edit_expand: editstring(delta); - break; - } - else readstring(); /* skip over it */ - - } while (delta!=nextdelta); -} - - -int stdinread; /* stdinread>0 if redirected stdin has been read once */ - -int ttystdin() -{ - static int initialized, istty; - if (!initialized) { - istty = isatty(fileno(stdin)); - initialized = 1; - } - return istty; -} - -putdesc(initflag,textflag,textfile,quietflag) -int initflag,textflag; char * textfile; int quietflag; -/* Function: puts the descriptive text into file frewrite. - * if !initflag && !textflag, the text is copied from the old description. - * Otherwise, if the textfile!=nil, the text is read from that - * file, or from stdin, if textfile==nil. - * Increments stdinread if text is read from redirected stdin. - * if initflag&&quietflag&&!textflag, an empty text is inserted. - * if !initflag, the old descriptive text is discarded. - */ -{ register FILE * txt; register int c, old1, old2; - register FILE * frew; -#ifdef lint - if (quietflag == 0) initflag = quietflag; /* silencelint */ -#endif - - frew = frewrite; - if (!initflag && !textflag) { - /* copy old description */ - VOID fprintf(frew,"\n\n%s%c",Kdesc,nextc); - rewriteflag=true; getdesc(false); - } else { - /* get new description */ - if (!initflag) { - /*skip old description*/ - rewriteflag=false; getdesc(false); - } - VOID fprintf(frew,"\n\n%s\n%c",Kdesc,SDELIM); - if (textfile) { - old1='\n'; - /* copy textfile */ - if ((txt=fopen(textfile,"r"))!=NULL) { - while ((c=getc(txt))!=EOF) { - if (c==SDELIM) VOID putc(c,frew); /*double up*/ - VOID putc(c,frew); - old1=c; - } - if (old1!='\n') VOID putc('\n',frew); - VOID fclose(txt); - VOID putc(SDELIM,frew); - VOID fputs("\n\n", frew); - return; - } else { - error("Can't open file %s with description",textfile); - if (!ttystdin()) return; - /* otherwise, get description from terminal */ - } - } - /* read text from stdin */ - if (ttystdin()) { - VOID fputs("enter description, terminated with ^D or '.':\n",stderr); - VOID fputs("NOTE: This is NOT the log message!\n>> ",stderr); - if (feof(stdin)) - clearerr(stdin); - } else { /* redirected stdin */ - if (stdinread>0) - faterror("Can't reread redirected stdin for description; use -t<file>"); - stdinread++; - } - c = '\0'; old2= '\n'; - if ((old1=getchar())==EOF) { - if (ttystdin()) { - VOID putc('\n',stderr); - clearerr(stdin); - } - } else { - if (old1=='\n' && ttystdin()) - VOID fputs(">> ",stderr); - for (;;) { - c=getchar(); - if (c==EOF) { - if (ttystdin()) { - VOID putc('\n',stderr); - clearerr(stdin); - } - VOID putc(old1,frew); - if (old1!='\n') VOID putc('\n',frew); - break; - } - if (c=='\n' && old1=='.' && old2=='\n') { - break; - } - if (c=='\n' && ttystdin()) VOID fputs(">> ",stderr); - if(old1==SDELIM) VOID putc(old1,frew); /* double up*/ - VOID putc(old1,frew); - old2=old1; - old1=c; - } /* end for */ - } - VOID putc(SDELIM,frew); VOID fputs("\n\n",frew); - } -} diff --git a/usr.bin/rcs/src/rcskeep.c b/usr.bin/rcs/src/rcskeep.c deleted file mode 100644 index c5eaca66b8fe..000000000000 --- a/usr.bin/rcs/src/rcskeep.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * RCS keyword extraction - */ -#ifndef lint -static char rcsid[]= "$Id: rcskeep.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/***************************************************************************** - * main routine: getoldkeys() - * Testprogram: define KEEPTEST - ***************************************************************************** - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - -/* $Log: rcskeep.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.6 89/05/01 15:12:56 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.5 88/11/08 12:01:05 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.5 88/08/09 19:13:03 eggert - * Remove lint and speed up by making FILE *fp local, not global. - * - * Revision 4.4 87/12/18 11:44:21 narten - * more lint cleanups (Guy Harris) - * - * Revision 4.3 87/10/18 10:35:50 narten - * Updating version numbers. Changes relative to 1.1 actually relative - * to 4.1 - * - * Revision 1.3 87/09/24 14:00:00 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:29 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:30 kcs - * Initial revision - * - * Revision 4.1 83/05/10 16:26:44 wft - * Added new markers Id and RCSfile; extraction added. - * Marker matching with trymatch(). - * - * Revision 3.2 82/12/24 12:08:26 wft - * added missing #endif. - * - * Revision 3.1 82/12/04 13:22:41 wft - * Initial revision. - * - */ - -/* -#define KEEPTEST -/* Testprogram; prints out the keyword values found. */ - -#include "rcsbase.h" -extern char * checkid(); -extern FILE * fopen(); -static int getval(); -extern enum markers trymatch(); - -#define IDLENGTH 30 -char prevauthor[IDLENGTH]; -char prevdate[datelength]; -char prevRCS[NCPFN]; -char prevrev[revlength]; -char prevsource[NCPPN]; -char prevstate [IDLENGTH]; -char prevlocker[IDLENGTH]; -char dummy[IDLENGTH]; - -getoldkeys(fname) -char * fname; -/* Function: Tries to read keyword values for author, date, - * revision number, RCS file, (both with and without path), - * state, and workfilename out of the file fname. - * The results are placed into - * prevauthor, prevdate, prevRCS, prevrev, prevsource, prevstate. - * Aborts immediately if it finds an error and returns false. - * If it returns true, it doesn't mean that any of the - * values were found; instead, check to see whether the corresponding arrays - * contain the empty string. - */ -{ - register FILE *fp; - register int c; - char keyword[keylength+2]; - register char * tp; - enum markers mresult; - - /* initialize to empty */ - prevauthor[0]=prevsource[0]=prevstate[0]=prevdate[0]=prevrev[0]= '\0'; - - if ( (fp = fopen(fname, "r") ) == NULL ) { - error("Can't open %s\n", fname); - return false; - } - while( (c=getc(fp)) != EOF) { - if ( c==KDELIM) { - /* try to get keyword */ - tp = keyword; - while( (c=getc(fp))!=EOF && (tp< keyword+keylength) && (c!='\n') - && (c!=KDELIM) && (c!=VDELIM)) - *tp++ = c; - - if (c==KDELIM) {VOID ungetc(c,fp);continue;} - if (c!=VDELIM) continue; - *tp++ = c; - *tp='\0'; - while ((c=getc(fp))==' '||c=='\t'); /* skip blanks */ - VOID ungetc(c,fp); /* needed for getval */ - - switch (mresult=trymatch(keyword,true)) { - case Author: - if (getval(fp,prevauthor,IDLENGTH,true)) - if (!checkid(prevauthor, '\0')) goto errexit; - break; - case Date: - if (!getprevdate(fp,true)) goto errexit; - break; - case Header: - case Id: - if (mresult==Header) { - if (!getval(fp,prevsource,NCPPN,true)) break; /*unexpanded*/ - } else { - if (!getval(fp,prevRCS,NCPFN,true)) break; /*unexpanded*/ - } - if (!getval(fp,prevrev,revlength,false)) goto errexit; - if (!checknum(prevrev,-1)) { - error("Bad revision number"); - goto errexit; - } - if (!getprevdate(fp,false)) goto errexit; - if (!getval(fp,prevauthor,IDLENGTH,false)) goto errexit; - if (!checkid(prevauthor, '\0')) goto errexit; - if (!getval(fp,prevstate,IDLENGTH,false)) goto errexit; - if (!checkid(prevstate, '\0')) goto errexit; - VOID getval(fp, dummy, IDLENGTH, true); /* optional locker*/ - VOID getval(fp, prevlocker,IDLENGTH,true); /* optional locker*/ - break; - case Locker: - VOID getval(fp,prevlocker,IDLENGTH,true); - if (!checkid(prevlocker, '\0')) goto errexit; - break; - case Log: - VOID getval(fp,prevRCS,NCPPN,true); - break; - case RCSfile: - VOID getval(fp,prevRCS,NCPFN,true); - break; - case Revision: - if (getval(fp,prevrev,revlength,true)) - if (!checknum(prevrev,-1)) { - error("Bad revision number"); - goto errexit; - } - break; - case Source: - VOID getval(fp,prevsource,NCPPN,true); - break; - case State: - if (getval(fp,prevstate,IDLENGTH,true)) - if (!checkid(prevstate, '\0')) goto errexit; - break; - default: - continue; - } - if (getc(fp)!=KDELIM) - warn("Closing %c missing on keyword",KDELIM); - if (prevauthor[0]!='\0'&&prevrev[0]!='\0'&&prevstate[0]!='\0'&& - prevdate[0]!='\0' && - ((prevsource[0]!='\0')||(prevRCS[0]!='\0'))){ - /* done; prevlocker is irrelevant */ - break; - } - } - } - VOID fclose(fp); - return true; - -errexit: - prevauthor[0]=prevsource[0]=prevstate[0]=prevdate[0]=prevrev[0]= '\0'; - VOID fclose(fp); return false; -} - - -static int getval(fp,target,maxchars,optional) -register FILE *fp; -char * target; int maxchars, optional; -/* Function: Places a keyword value into target, but not more - * than maxchars characters. Prints an error if optional==false - * and there is no keyword. Returns true if one is found, false otherwise. - */ -{ register char * tp; - register int c; - - tp=target; - c=getc(fp); - if (c==KDELIM) { - if (!optional) - error("Missing keyword value"); - VOID ungetc(c,fp); - return false; - } else { - while (!(c==' '||c=='\n'||c=='\t'||c==KDELIM||c==EOF)) { - if (tp-target>=maxchars-1) { - error("keyword value too long"); - return false; - } else { - *tp++ =c; - c=getc(fp); - } - } - *tp= '\0'; -# ifdef KEEPTEST - VOID printf("getval: %s\n",target); -# endif - while(c==' '||c=='\t') c=getc(fp); /* skip trailing blanks */ - } - VOID ungetc(c,fp); - return true; -} - - -int getprevdate(fp,optional) -FILE *fp; -int optional; -/* Function: reads a date prevdate; checks format - * If there is not date and optional==false, an error is printed. - * Returns false on error, true otherwise. - */ -{ char prevday[10]; - char prevtime[10]; - - prevday[0]=prevtime[0]='\0'; - if (!getval(fp,prevday,9,optional)) return optional; - if (!getval(fp,prevtime,9,false)) return false; - /*process date */ - prevday[2]=prevday[5]=prevday[8]=prevtime[2]=prevtime[5]='.'; - prevday[9]='\0'; - VOID strcpy(prevdate,prevday); - VOID strcat(prevdate,prevtime); - if (!checknum(prevdate,5)) { - error("Bad date: %s",prevdate); - prevdate[0]='\0'; - return false; - } - return true; -} - -int checknum(sp,fields) -register char * sp; int fields; -{ register int dotcount; - if (sp==nil||*sp=='\0') return true; - dotcount=0; - while(*sp) { - if (*sp=='.') dotcount++; - elsif (ctab[*sp]!=DIGIT) return false; - sp++; - } - if (fields >= 0 && dotcount!=fields) return false; - return true; -} - - - -#ifdef KEEPTEST -char * RCSfilename, * workfilename; - -main(argc, argv) -int argc; char *argv[]; -{ - cmdid="keeptest"; - while (*(++argv)) { - if (getoldkeys(*argv)) - VOID printf("%s: revision: %s, date: %s, author: %s, state: %s\n", - *argv, prevrev, prevdate, prevauthor,prevstate); - VOID printf("Source: %s, RCSfile: %s\n",prevsource,prevRCS); - } - exit(0); -} -#endif diff --git a/usr.bin/rcs/src/rcskeys.c b/usr.bin/rcs/src/rcskeys.c deleted file mode 100644 index 2298645aecb2..000000000000 --- a/usr.bin/rcs/src/rcskeys.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * RCS keyword table and match operation - */ -#ifndef lint -static char rcsid[]= "$Id: rcskeys.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - -/* $Log: rcskeys.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.3 89/05/01 15:13:02 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.2 87/10/18 10:36:33 narten - * Updating version numbers. Changes relative to 1.1 actuallyt - * relative to 4.1 - * - * Revision 1.2 87/09/24 14:00:10 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.1 84/01/23 14:50:32 kcs - * Initial revision - * - * Revision 4.1 83/05/04 10:06:53 wft - * Initial revision. - * - */ - - -#include "rcsbase.h" - - - -struct { char * keyword; enum markers marker;} markertable[] = - {{AUTHOR, Author }, - {DATE, Date }, - {HEADER, Header }, - {IDH, Id }, - {LOCKER, Locker }, - {LOG, Log }, - {RCSFILE, RCSfile }, - {REVISION, Revision}, - {SOURCE, Source }, - {STATE, State }, - {nil, Nomatch }}; - - - -enum markers trymatch(string,onlyvdelim) -char * string; -/* function: Checks whether string starts with a keyword followed - * by a KDELIM or a VDELIM. If onlyvdelim==true, only a VDELIM - * may follow the keyword. - * If successful, returns the appropriate marker, otherwise Nomatch. - */ -{ - register int j; - register char * p, * s; - for (j=0; markertable[j].keyword!=nil; j++ ) { - /* try next keyword */ - p = markertable[j].keyword; s = string; - while (*p!='\0' && *s!='\0' && *p == *s) { - p++; s++; - } - if (*p != '\0') continue; /* no match */ - if ((*s == VDELIM) || (!onlyvdelim && (*s == KDELIM))) - return(markertable[j].marker); - } - return(Nomatch); -} - diff --git a/usr.bin/rcs/src/rcslex.c b/usr.bin/rcs/src/rcslex.c deleted file mode 100644 index cb6ca4c6bc7c..000000000000 --- a/usr.bin/rcs/src/rcslex.c +++ /dev/null @@ -1,810 +0,0 @@ -/* - * RCS file input - */ -#ifndef lint -static char rcsid[]= "$Id: rcslex.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/********************************************************************************* - * Lexical Analysis. - * Character mapping table, - * hashtable, Lexinit, nextlex, getlex, getkey, - * getid, getnum, readstring, printstring, savestring, - * checkid, serror, fatserror, error, faterror, warn, diagnose - * fflsbuf, puts, fprintf - * Testprogram: define LEXDB - ********************************************************************************* - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - -/* $Log: rcslex.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.6 89/05/01 15:13:07 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.5 88/11/08 12:00:54 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.5 88/08/28 15:01:12 eggert - * Don't loop when writing error messages to a full filesystem. - * Flush stderr/stdout when mixing output. - * Yield exit status compatible with diff(1). - * Shrink stdio code size; allow cc -R; remove lint. - * - * Revision 4.4 87/12/18 11:44:47 narten - * fixed to use "varargs" in "fprintf"; this is required if it is to - * work on a SPARC machine such as a Sun-4 - * - * Revision 4.3 87/10/18 10:37:18 narten - * Updating version numbers. Changes relative to 1.1 actually relative - * to version 4.1 - * - * Revision 1.3 87/09/24 14:00:17 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:33 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:33 kcs - * Initial revision - * - * Revision 4.1 83/03/25 18:12:51 wft - * Only changed $Header to $Id. - * - * Revision 3.3 82/12/10 16:22:37 wft - * Improved error messages, changed exit status on error to 1. - * - * Revision 3.2 82/11/28 21:27:10 wft - * Renamed ctab to map and included EOFILE; ctab is now a macro in rcsbase.h. - * Added fflsbuf(), fputs(), and fprintf(), which abort the RCS operations - * properly in case there is an IO-error (e.g., file system full). - * - * Revision 3.1 82/10/11 19:43:56 wft - * removed unused label out:; - * made sure all calls to getc() return into an integer, not a char. - */ - - -/* -#define LEXDB -/* version LEXDB is for testing the lexical analyzer. The testprogram - * reads a stream of lexemes, enters the revision numbers into the - * hashtable, and prints the recognized tokens. Keywords are recognized - * as identifiers. - */ - - - -#include "rcsbase.h" -#if __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - - - -/* character mapping table */ -enum tokens map[] = { - EOFILE, /* this will end up at ctab[-1] */ - UNKN, INSERT, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, - UNKN, SPACE, NEWLN, UNKN, SPACE, UNKN, UNKN, UNKN, - UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, - UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, - SPACE, EXCLA, DQUOTE, HASH, DOLLAR, PERCNT, AMPER, SQUOTE, - LPARN, RPARN, TIMES, PLUS, COMMA, MINUS, PERIOD, DIVIDE, - DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, - DIGIT, DIGIT, COLON, SEMI, LESS, EQUAL, GREAT, QUEST, - AT, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LBRACK, BACKSL, RBRACK, UPARR, UNDER, - ACCENT, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, - LETTER, LETTER, LETTER, LBRACE, BAR, RBRACE, TILDE, UNKN -}; - - - - -struct hshentry * nexthsh; /*pointer to next hashtable-entry, set by lookup*/ - -enum tokens nexttok; /*next token, set by nextlex */ - -int hshenter; /*if true, next suitable lexeme will be entered */ - /*into the symbol table. Handle with care. */ -int nextc; /*next input character, initialized by Lexinit */ - -int eof; /*end-of-file indicator, set to >0 on end of file*/ -int line; /*current line-number of input */ -int nerror; /*counter for errors */ -int nwarn; /*counter for warnings */ -char * cmdid; /*command identification for error messages */ -int quietflag; /*indicates quiet mode */ -FILE * finptr; /*input file descriptor */ - -FILE * frewrite; /*file descriptor for echoing input */ - -int rewriteflag;/*indicates whether to echo to frewrite */ - -char StringTab[strtsize]; /* string table and heap */ - -char * NextString; /*pointer to next identifier in StringTab*/ -char * Topchar; /*pointer to next free byte in StringTab*/ - /*set by nextlex, lookup */ -struct hshentry hshtab[hshsize]; /*hashtable */ - - - - - -lookup() { - -/* Function: Looks up the character string pointed to by NextString in the - * hashtable. If the string is not present, a new entry for it is created. - * If the string is present, TopChar is moved back to save the space for - * the string, and NextString is set to point to the original string. - * In any case, the address of the corresponding hashtable entry is placed - * into nexthsh. - * Algorithm: Quadratic hash, covering all entries. - * Assumptions: NextString points at the first character of the string. - * Topchar points at the first empty byte after the string. - */ - - register int ihash; /* index into hashtable */ - register char * sp, * np; - int c, delta, final, FirstScan; /*loop control*/ - - /* calculate hash code */ - sp = NextString; - ihash = 0; - while (*sp) ihash += *sp++; - - /* set up first search loop (c=0,step=1,until (hshsiz-1)/2 */ - c=0;delta=1;final=(hshsize-1)/2; - FirstScan=true; /*first loop */ - - for (;;) { - ihash = (ihash+c)%hshsize; /*next index*/ - - if (hshtab[ihash].num == nil) { - /*empty slot found*/ - hshtab[ihash].num = NextString; - nexthsh= &hshtab[ihash];/*save hashtable address*/ -# ifdef LEXDB - VOID printf("\nEntered: %s at %d ",nexthsh->num, ihash); -# endif - return; - } - /* compare strings */ - sp=NextString;np=hshtab[ihash].num; - while (*sp == *np++) { - if (*sp == 0) { - /* match found */ - nexthsh= &hshtab[ihash]; - Topchar = NextString; - NextString = nexthsh->num; - return; - } else sp++; - } - - /* neither empty slot nor string found */ - /* calculate next index and repeat */ - if (c != final) - c += delta; - else { - if (FirstScan) { - /*set up second sweep*/ - delta = -1; final = 1; FirstScan= false; - } else { - fatserror("Hashtable overflow"); - } - } - } -}; - - - - - - -Lexinit() -/* Function: Initialization of lexical analyzer: - * initializes the hastable, - * initializes nextc, nexttok if finptr != NULL - */ -{ register int c; - - for (c=hshsize-1; c>=0; c--) { - hshtab[c].num = nil; - } - - hshenter=true; eof=0; line=1; nerror=0; nwarn=0; - NextString=nil; Topchar = &StringTab[0]; - if (finptr) { - nextc = GETC(finptr,frewrite,rewriteflag); /*initial character*/ - nextlex(); /*initial token*/ - } else { - nextc = '\0'; - nexttok=EOFILE; - } -} - - - - - - - -nextlex() - -/* Function: Reads the next token and sets nexttok to the next token code. - * Only if the hshenter==true, a revision number is entered into the - * hashtable and a pointer to it is placed into nexthsh. - * This is useful for avoiding that dates are placed into the hashtable. - * For ID's and NUM's, NextString is set to the character string in the - * string table. Assumption: nextc contains the next character. - */ -{ register c; - register FILE * fin, * frew; - register char * sp; - register enum tokens d; - - if (eof) { - nexttok=EOFILE; - return; - } - fin=finptr; frew=frewrite; -loop: - switch(nexttok=ctab[nextc]) { - - case UNKN: - case IDCHAR: - case PERIOD: - serror("unknown Character: %c",nextc); - nextc=GETC(fin,frew,rewriteflag); - goto loop; - - case NEWLN: - line++; -# ifdef LEXDB - VOID putchar('\n'); -# endif - /* Note: falls into next case */ - - case SPACE: - nextc=GETC(fin,frew,rewriteflag); - goto loop; - - case EOFILE: - eof++; - nexttok=EOFILE; - return; - - case DIGIT: - NextString = sp = Topchar; - *sp++ = nextc; - while ((d=ctab[c=GETC(fin,frew,rewriteflag)])==DIGIT || - d==PERIOD) { - *sp++ = c; /* 1.2. and 1.2 are different */ - } - *sp++ = '\0'; - if (sp >= StringTab+strtsize) { - /*may have written outside stringtable already*/ - fatserror("Stringtable overflow"); - } - Topchar = sp; - nextc = c; - if (hshenter == true) - lookup(); /* lookup updates NextString, Topchar*/ - nexttok = NUM; - return; - - - case LETTER: - NextString = sp = Topchar; - *sp++ = nextc; - while ((d=ctab[c=GETC(fin,frew,rewriteflag)])==LETTER || - d==DIGIT || d==IDCHAR) { - *sp++ = c; - } - *sp++ = '\0'; - if (sp >= StringTab+strtsize) { - /*may have written outside stringtable already*/ - fatserror("Stringtable overflow"); - } - Topchar = sp; - nextc = c; - nexttok = ID; /* may be ID or keyword */ - return; - - case SBEGIN: /* long string */ - nexttok = STRING; - /* note: only the initial SBEGIN has been read*/ - /* read the string, and reset nextc afterwards*/ - return; - - default: - nextc=GETC(fin,frew,rewriteflag); - return; - } -} - - -int getlex(token) -enum tokens token; -/* Function: Checks if nexttok is the same as token. If so, - * advances the input by calling nextlex and returns true. - * otherwise returns false. - * Doesn't work for strings and keywords; loses the character string for ids. - */ -{ - if (nexttok==token) { - nextlex(); - return(true); - } else return(false); -} - -int getkey (key) -char * key; -/* Function: If the current token is a keyword identical to key, - * getkey advances the input by calling nextlex and returns true; - * otherwise returns false. - */ -{ - register char *s1,*s2; - - if (nexttok==ID) { - s1=key; s2=NextString; - while(*s1 == *s2++) - if (*s1++ == '\0') { - /* match found */ - Topchar = NextString; /*reset Topchar */ - nextlex(); - return(true); - } - } - return(false); -} - - - -char * getid() -/* Function: Checks if nexttok is an identifier. If so, - * advances the input by calling nextlex and returns a pointer - * to the identifier; otherwise returns nil. - * Treats keywords as identifiers. - */ -{ - register char * name; - if (nexttok==ID) { - name = NextString; - nextlex(); - return name; - } else return nil; -} - - -struct hshentry * getnum() -/* Function: Checks if nexttok is a number. If so, - * advances the input by calling nextlex and returns a pointer - * to the hashtable entry. Otherwise returns nil. - * Doesn't work if hshenter is false. - */ -{ - register struct hshentry * num; - if (nexttok==NUM) { - num=nexthsh; - nextlex(); - return num; - } else return nil; -} - - -readstring() -/* skip over characters until terminating single SDELIM */ -/* if rewriteflag==true, copy every character read to frewrite.*/ -/* Does not advance nextlex at the end. */ -{ register c; - register FILE * fin, * frew; - fin=finptr; frew=frewrite; - if (rewriteflag) { - /* copy string verbatim to frewrite */ - while ((c=getc(fin)) != EOF) { - VOID putc(c,frew); - if (c==SDELIM) { - if ((c=getc(fin)) == EOF || putc(c,frew) != SDELIM) { - /* end of string */ - nextc=c; - return; - } - } - } - } else { - /* skip string */ - while ((c=getc(fin)) != EOF) { - if (c==SDELIM) { - if ((c=getc(fin)) != SDELIM) { - /* end of string */ - nextc=c; - return; - } - } - } - } - nextc = c; - error("Unterminated string"); -} - - -printstring() -/* Function: copy a string to stdout, until terminated with a single SDELIM. - * Does not advance nextlex at the end. - */ -{ - register c; - register FILE * fin; - fin=finptr; - while ((c=getc(fin)) != EOF) { - if (c==SDELIM) { - if ((c=getc(fin)) != SDELIM) { - /* end of string */ - nextc=c; - return; - } - } - VOID putchar(c); - } - nextc = c; - error("Unterminated string"); -} - - - -savestring(target,length) -char * target; int length; -/* copies a string terminated with SDELIM from file finptr to buffer target, - * but not more than length bytes. If the string is longer than length, - * the extra characters are skipped. The string may be empty, in which - * case a '\0' is placed into target. - * Double SDELIM is replaced with SDELIM. - * If rewriteflag==true, the string is also copied unchanged to frewrite. - * Returns the length of the saved string. - * Does not advance nextlex at the end. - */ -{ - register c; - register FILE * fin, * frew; - register char * tp, * max; - - fin=finptr; frew=frewrite; - tp=target; max= target+length; /*max is one too large*/ - while ((c=GETC(fin,frew,rewriteflag))!=EOF) { - *tp++ =c; - if (c== SDELIM) { - if ((c=GETC(fin,frew,rewriteflag))!=SDELIM) { - /* end of string */ - *(tp-1)='\0'; - nextc=c; - return; - } - } - if (tp >= max) { - /* overflow */ - error("string buffer overflow -- truncating string"); - target[length-1]='\0'; - /* skip rest of string */ - while ((c=GETC(fin,frew,rewriteflag))!=EOF) { - if ((c==SDELIM) && ((c=GETC(fin,frew,rewriteflag))!=SDELIM)) { - /* end of string */ - nextc=c; - return; - } - } - nextc = c; - error("Can't find %c to terminate string before end of file",SDELIM); - return; - } - } - nextc = c; - error("Can't find %c to terminate string before end of file",SDELIM); -} - - -char *checkid(id, delim) -char *id, delim; -/* Function: check whether the string starting at id is an */ -/* identifier and return a pointer to the last char*/ -/* of the identifer. White space, delim and '\0' */ -/* are legal delimeters. Aborts the program if not */ -/* a legal identifier. Useful for checking commands*/ -{ - register enum tokens d; - register char *temp; - register char c,tc; - - temp = id; - if ( ctab[*id] == LETTER ) { - while( (d=ctab[c=(*++id)]) == LETTER || d==DIGIT || d==IDCHAR) ; - if ( c!=' ' && c!='\t' && c!='\n' && c!='\0' && c!=delim) { - /* append \0 to end of id before error message */ - tc = c; - while( (c=(*++id))!=' ' && c!='\t' && c!='\n' && c!='\0' && c!=delim) ; - *id = '\0'; - faterror("Invalid character %c in identifier %s",tc,temp); - return nil ; - } else - return id; - } else { - /* append \0 to end of id before error message */ - while( (c=(*++id))!=' ' && c!='\t' && c!='\n' && c!='\0' && c!=delim) ; - *id = '\0'; - faterror("Identifier %s does not start with letter",temp); - return nil; - } -} - -writeerror() -{ - static looping; - if (looping) - exit(2); - looping = 1; - faterror("write error"); -} - -nlflush(iop) -register FILE * iop; -{ - if (putc('\n',iop)==EOF || fflush(iop)==EOF) - writeerror(); -} - - -/*VARARGS1*/ -serror(e,e1,e2,e3,e4,e5) -char * e, * e1, * e2, * e3, * e4, * e5; -/* non-fatal syntax error */ -{ nerror++; - VOID fprintf(stderr,"%s error, line %d: ", cmdid, line); - VOID fprintf(stderr,e, e1, e2, e3, e4, e5); - nlflush(stderr); -} - -/*VARARGS1*/ -error(e,e1,e2,e3,e4,e5) -char * e, * e1, * e2, * e3, * e4, * e5; -/* non-fatal error */ -{ nerror++; - VOID fprintf(stderr,"%s error: ",cmdid); - VOID fprintf(stderr,e, e1, e2, e3, e4, e5); - nlflush(stderr); -} - -/*VARARGS1*/ -fatserror(e,e1,e2,e3,e4,e5) -char * e, * e1, * e2, * e3, * e4, * e5; -/* fatal syntax error */ -{ nerror++; - VOID fprintf(stderr,"%s error, line %d: ", cmdid,line); - VOID fprintf(stderr,e, e1, e2, e3, e4, e5); - VOID fprintf(stderr,"\n%s aborted\n",cmdid); - VOID cleanup(); - exit(2); -} - -/*VARARGS1*/ -faterror(e,e1,e2,e3,e4,e5) -char * e, * e1, * e2, * e3, * e4, * e5; -/* fatal error, terminates program after cleanup */ -{ nerror++; - VOID fprintf(stderr,"%s error: ",cmdid); - VOID fprintf(stderr,e, e1, e2, e3, e4, e5); - VOID fprintf(stderr,"\n%s aborted\n",cmdid); - VOID cleanup(); - exit(2); -} - -/*VARARGS1*/ -warn(e,e1,e2,e3,e4,e5) -char * e, * e1, * e2, * e3, * e4, * e5; -/* prints a warning message */ -{ nwarn++; - VOID fprintf(stderr,"%s warning: ",cmdid); - VOID fprintf(stderr,e, e1, e2, e3, e4, e5); - nlflush(stderr); -} - - -/*VARARGS1*/ -diagnose(e,e1,e2,e3,e4,e5) -char * e, * e1, * e2, * e3, * e4, * e5; -/* prints a diagnostic message */ -{ - if (!quietflag) { - VOID fprintf(stderr,e, e1, e2, e3, e4, e5); - nlflush(stderr); - } -} - - - -#ifdef _FSTDIO -wbuf(c, fp) - unsigned c; - register FILE *fp; -{ - register int result; - - if ((result = __sputc(c, fp)) == EOF) - writeerror(); - return result; -} -#else -fflsbuf(c, iop) -unsigned c; register FILE * iop; -/* Function: Flush iop. - * Same routine as _flsbuf in stdio, but aborts program on error. - */ -{ register result; - if ((result=_flsbuf(c,iop))==EOF) - writeerror(); - return result; -} -#endif - - -#ifdef _FSTDIO -fputs(s, iop) - const char *s; - FILE *iop; -{ - - VOID fprintf(iop, "%s", s); - return 0; -} -#else -fputs(s, iop) -register char *s; -register FILE *iop; -/* Function: Put string s on file iop, abort on error. - * Same as puts in stdio, but with different putc macro. - */ -{ - register r; - register c; - - while (c = *s++) - r = putc(c, iop); - return(r); -} -#endif - - - -#if __STDC__ -fprintf(FILE *iop, const char *fmt, ...) -#else -fprintf(iop, fmt, va_alist) -FILE *iop; -const char *fmt; -va_dcl -#endif -/* Function: formatted output. Same as fprintf in stdio, - * but aborts program on error - */ -{ - register int value; - va_list ap; - -#ifdef __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif -#ifdef VFPRINTF - VOID vfprintf(iop, fmt, ap); -#else - _doprnt(fmt, ap, iop); -#endif - if (ferror(iop)) { - writeerror(); - value = EOF; - } else value = 0; - va_end(ap); - return value; -} - - - -#ifdef LEXDB -/* test program reading a stream of lexems and printing the tokens. - */ - - - -main(argc,argv) -int argc; char * argv[]; -{ - cmdid="lextest"; - if (argc<2) { - VOID fputs("No input file\n",stderr); - exit(1); - } - if ((finptr=fopen(argv[1], "r")) == NULL) { - faterror("Can't open input file %s\n",argv[1]); - } - Lexinit(); - rewriteflag=false; - while (nexttok != EOFILE) { - switch (nexttok) { - - case ID: - VOID printf("ID: %s",NextString); - break; - - case NUM: - if (hshenter==true) - VOID printf("NUM: %s, index: %d",nexthsh->num, nexthsh-hshtab); - else - VOID printf("NUM, unentered: %s",NextString); - hshenter = !hshenter; /*alternate between dates and numbers*/ - break; - - case COLON: - VOID printf("COLON"); break; - - case SEMI: - VOID printf("SEMI"); break; - - case STRING: - readstring(); - VOID printf("STRING"); break; - - case UNKN: - VOID printf("UNKN"); break; - - default: - VOID printf("DEFAULT"); break; - } - VOID printf(" | "); - nextlex(); - } - VOID printf("\nEnd of lexical analyzer test\n"); -} - -cleanup() -/* dummy */ -{} - - -#endif diff --git a/usr.bin/rcs/src/rcsmerge.c b/usr.bin/rcs/src/rcsmerge.c deleted file mode 100644 index 01ad1195484a..000000000000 --- a/usr.bin/rcs/src/rcsmerge.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * rcsmerge operation - */ -#ifndef lint -static char rcsid[]= -"$Header: /cvsroot/src/usr.bin/rcs/src/Attic/rcsmerge.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/***************************************************************************** - * join 2 revisions with respect to a third - ***************************************************************************** - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - -/* $Log: rcsmerge.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.5 89/05/01 15:13:16 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.4 88/11/08 12:00:47 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.4 88/08/09 19:13:13 eggert - * Beware merging into a readonly file. - * Beware merging a revision to itself (no change). - * Use execv(), not system(); yield exit status like diff(1)'s. - * - * Revision 4.3 87/10/18 10:38:02 narten - * Updating version numbers. Changes relative to version 1.1 - * actually relative to 4.1 - * - * Revision 1.3 87/09/24 14:00:31 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:36 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:36 kcs - * Initial revision - * - * Revision 4.1 83/03/28 11:14:57 wft - * Added handling of default branch. - * - * Revision 3.3 82/12/24 15:29:00 wft - * Added call to catchsig(). - * - * Revision 3.2 82/12/10 21:32:02 wft - * Replaced getdelta() with gettree(); improved error messages. - * - * Revision 3.1 82/11/28 19:27:44 wft - * Initial revision. - * - */ -#include "rcsbase.h" -#ifndef lint -static char rcsbaseid[] = RCSBASE; -#endif -static char co[] = CO; -static char merge[] = MERGE; - -extern int cleanup(); /* cleanup after signals */ -extern char * mktempfile(); /*temporary file name generator */ -extern struct hshentry * genrevs(); /*generate delta numbers */ -extern int nerror; /*counter for errors */ - -char *RCSfilename; -char *workfilename; -char * temp1file, * temp2file; - -main (argc, argv) -int argc; char **argv; -{ - char * cmdusage; - int revnums; /* counter for revision numbers given */ - int tostdout; - int nochange; - char * rev1, * rev2; /*revision numbers*/ - char commarg[revlength+3]; - char numericrev[revlength]; /* holds expanded revision number */ - struct hshentry * gendeltas[hshsize];/*stores deltas to be generated*/ - struct hshentry * target; - - catchints(); - cmdid = "rcsmerge"; - cmdusage = "command format:\n rcsmerge -p -rrev1 -rrev2 file\n rcsmerge -p -rrev1 file"; - revnums=0;tostdout=false;nochange=false; - - while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) { - switch ((*argv)[1]) { - case 'p': - tostdout=true; - /* falls into -r */ - case 'r': - if ((*argv)[2]!='\0') { - if (revnums==0) { - rev1= *argv+2; revnums=1; - } elif (revnums==1) { - rev2= *argv+2; revnums=2; - } else { - faterror("too many revision numbers"); - } - } /* do nothing for empty -r or -p */ - break; - - default: - faterror("unknown option: %s\n%s", *argv,cmdusage); - }; - } /* end of option processing */ - - if (argc<1) faterror("No input file\n%s",cmdusage); - if (revnums<1) faterror("no base revision number given"); - - /* now handle all filenames */ - - if (pairfilenames(argc,argv,true,false)==1) { - - if (argc>2 || (argc==2&&argv[1]!=nil)) - warn("too many arguments"); - diagnose("RCS file: %s",RCSfilename); - if (!(access(workfilename,tostdout?4:6)==0)) - nowork(); - - if (!trysema(RCSfilename,false)) goto end; /* give up */ - - gettree(); /* reads in the delta tree */ - - if (Head==nil) faterror("no revisions present"); - - - if (!expandsym(rev1,numericrev)) goto end; - if (!(target=genrevs(numericrev, (char *)nil, (char *)nil, (char *)nil,gendeltas))) goto end; - rev1=target->num; - if (revnums==1) /*get default for rev2 */ - rev2=Dbranch!=nil?Dbranch->num:Head->num; - if (!expandsym(rev2,numericrev)) goto end; - if (!(target=genrevs(numericrev, (char *)nil, (char *)nil, (char *)nil,gendeltas))) goto end; - rev2=target->num; - - if (strcmp(rev1,rev2) == 0) { - diagnose("Merging revision %s to itself (no change)", - rev1 - ); - nochange = true; - if (tostdout) { - FILE *w = fopen(workfilename,"r"); - if (w==NULL) - nowork(); - fastcopy(w,stdout); - } - goto end; - } - - temp1file=mktempfile("/tmp/",TMPFILE1); - temp2file=mktempfile("/tmp/",TMPFILE2); - - diagnose("retrieving revision %s",rev1); - VOID sprintf(commarg,"-p%s",rev1); - if (run((char*)nil,temp1file, co,"-q",commarg,RCSfilename,(char*)nil)){ - faterror("co failed"); - } - diagnose("retrieving revision %s",rev2); - VOID sprintf(commarg,"-p%s",rev2); - if (run((char*)nil,temp2file, co,"-q",commarg,RCSfilename,(char*)nil)){ - faterror("co failed"); - } - diagnose("Merging differences between %s and %s into %s%s", - rev1, rev2, workfilename, - tostdout?"; result to stdout":""); - - if ( - tostdout - ? run((char*)nil,(char*)nil,merge,"-p",workfilename,temp1file,temp2file,workfilename,rev2,(char*)nil) - : run((char*)nil,(char*)nil,merge, workfilename,temp1file,temp2file,workfilename,rev2,(char*)nil)) { - faterror("merge failed"); - } - } - -end: - VOID cleanup(); - exit(2*(nerror!=0) + nochange); - -} - - -nowork() -{ - faterror("Can't open %s",workfilename); -} diff --git a/usr.bin/rcs/src/rcsrev.c b/usr.bin/rcs/src/rcsrev.c deleted file mode 100644 index bd0b3f933b1d..000000000000 --- a/usr.bin/rcs/src/rcsrev.c +++ /dev/null @@ -1,719 +0,0 @@ -/* - * RCS revision number handling - */ -#ifndef lint -static char rcsid[]= "$Id: rcsrev.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - - -/* $Log: rcsrev.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.5 89/05/01 15:13:22 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.4 87/12/18 11:45:22 narten - * more lint cleanups. Also, the NOTREACHED comment is no longer necessary, - * since there's now a return value there with a value. (Guy Harris) - * - * Revision 4.3 87/10/18 10:38:42 narten - * Updating version numbers. Changes relative to version 1.1 actually - * relative to 4.1 - * - * Revision 1.3 87/09/24 14:00:37 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:37 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:37 kcs - * Initial revision - * - * Revision 4.1 83/03/25 21:10:45 wft - * Only changed $Header to $Id. - * - * Revision 3.4 82/12/04 13:24:08 wft - * Replaced getdelta() with gettree(). - * - * Revision 3.3 82/11/28 21:33:15 wft - * fixed compartial() and compnum() for nil-parameters; fixed nils - * in error messages. Testprogram output shortenend. - * - * Revision 3.2 82/10/18 21:19:47 wft - * renamed compnum->cmpnum, compnumfld->cmpnumfld, - * numericrevno->numricrevno. - * - * Revision 3.1 82/10/11 19:46:09 wft - * changed expandsym() to check for source==nil; returns zero length string - * in that case. - */ - - - -/* -#define REVTEST -/* version REVTEST is for testing the routines that generate a sequence - * of delta numbers needed to regenerate a given delta. - */ - -#include "rcsbase.h" - -extern FILE * finptr; /* RCS input file */ -extern char * getid(); -extern struct hshentry * getnum(); -extern int getkey(); -extern int getlex(); - -extern char * getkeyval(); -struct hshentry * genbranch(); /* forward */ - - - -int countnumflds(s) -char * s; -/* Given a pointer s to a dotted number (date or revision number), - * countnumflds returns the number of digitfields in s. - */ -{ register char * sp; - register int count; - if ((sp=s)==nil) return(0); - if (*sp == '\0') return(0); - count = 1; - while (*sp) { - if (*sp++ == '.') count++; - } - if (*(--sp) == '.') count--; /*trailing periods don't count*/ - return(count); -} - -getbranchno(revno,branchno) -char * revno, * branchno; -/* Given a non-nil revision number revno, getbranchno copies the number of the branch - * on which revno is into branchnumber. If revno itself is a branch number, - * it is copied unchanged. - */ -{ - register int i, numflds; - register char * tp, * sp; - - numflds=countnumflds(revno); - if (numflds%2 == 1) - VOID strcpy(branchno,revno); - else { - sp=revno; tp=branchno; - for (i=1;i<numflds;i++) { - while(*sp!='.') *tp++ = *sp++; - *tp++ = *sp++; - } - *(tp-1)='\0'; - } -} - - - -int cmpnum(num1, num2) -char * num1, * num2; -/* compares the two dotted numbers num1 and num2 lexicographically - * by field. Individual fields are compared numerically. - * returns <0, 0, >0 if num1<num2, num1==num2, and num1>num2, resp. - * omitted fields are assumed to be higher than the existing ones. -*/ -{ - register char * s1, *s2; - register int n1, n2; - - s1=num1==nil?"":num1; - s2=num2==nil?"":num2; - - do { - n1 = 0; - while (('0' <= *s1) && (*s1 <= '9')) { - n1 = n1*10 + (*s1 - '0'); - s1++; - } - /* skip '.' */ - if (*s1=='.') s1++; - - n2 = 0; - while (('0' <= *s2) && (*s2 <= '9')) { - n2 = n2*10 + (*s2 - '0'); - s2++; - } - /* skip '.' */ - if (*s2=='.') s2++; - - } while ((n1==n2) && (*s1!='\0') && (*s2!='\0')); - - if (((*s1=='\0') && (*s2=='\0')) || (n1!=n2)) - return (n1 - n2); - /*now n1==n2 and one of s1 or s2 is shorter*/ - /*give precedence to shorter one*/ - if (*s1=='\0') return 1; - else return -1; - -} - - - -int cmpnumfld(num1, num2, fld) -char * num1, * num2; int fld; -/* compares the two dotted numbers at field fld and returns - * num1[fld]-num2[fld]. Assumes that num1 and num2 have at least fld fields. -*/ -{ - register char * s1, *s2; - register int n1, n2; - - s1=num1; n1=fld-1; - /* skip fld-1 fields */ - while (n1) { - while(*s1 != '.') s1++; - n1--; s1++; - } - s2 = num2; n2=fld-1; - while (n2) { - while(*s2 != '.') s2++; - n2--; s2++; - } - /* Don't put the above into a single loop! */ - /* Now s1 and s2 point to the beginning of the respective fields */ - /* compute numerical value and compare */ - n1 = 0; - while (('0' <= *s1) && (*s1 <= '9')) { - n1 = n1*10 + (*s1 - '0'); - s1++; - } - n2 = 0; - while (('0' <= *s2) && (*s2 <= '9')) { - n2 = n2*10 + (*s2 - '0'); - s2++; - } - return (n1 - n2); -} - - -int compartial(num1, num2, length) -char * num1; -char * num2; -int length; - -/* compare the first "length" fields of two dot numbers; - the omitted field is considered to be larger than any number */ -/* restriction: at least one number has length or more fields */ - -{ - register char *s1, *s2; - register int n1, n2; - - - s1 = num1; s2 = num2; - if ( s1==nil || *s1 == '\0' ) return 1; - if ( s2==nil || *s2 == '\0' ) return -1; - - do { - n1 = 0; - while( ('0' <= *s1) && (*s1 <= '9') ) { - n1 = n1 * 10 + (*s1 - '0') ; - s1++; - } - if ( *s1 == '.' ) s1++; /* skip . */ - - n2 = 0; - while( ( '0' <= *s2) && ( *s2 <= '9' ) ) { - n2 = n2 * 10 + ( *s2 - '0' ) ; - s2++; - } - if (*s2 == '.') s2++; - } while( ( n1 == n2) && ((--length) != 0) && - ( *s1 != '\0') && (*s2 != '\0') ); - - if ( (n1 != n2) || (length == 0) ){ - return(n1-n2); } - - if ( *s1 == '\0' ) return 1; - if ( *s2 == '\0' ) return -1; - VOID fprintf(stderr, "RCS Internal error, routine: compartial\n"); - return(0); -} - - - -incnum(onum,nnum) -char * onum, *nnum; -/* increments the last field of revision number onum by one and - * places the result into nnum - */ -{ - register char * sp, *tp; - register int i; - - sp = onum; tp = nnum; - for (i=countnumflds(onum)-1; i>0; i--) { - while (*sp != '.') *tp++ = *sp++; - *tp++ = *sp++; /* copy dot also */ - } - VOID sprintf(tp,"%d",atoi(sp)+1); -} - - -char * partialno(rev1,rev2,length) -char * rev1, * rev2; register int length; -/* Function: Copies length fields of revision number rev2 into rev1. - * returns rev1. - */ -{ register char * r1,* r2; - - r1=rev1; r2=rev2; - while (length) { - while(*r2 != '.' && *r2!='\0') *r1++ = *r2++; - *r1++ = *r2++; - length--; - } - /* eliminate last '.'*/ - *(r1-1)='\0'; - return rev1; -} - - - -char * getancestor(r1, r2, r3) -char * r1, *r2, *r3; -/* function: finds the common ancestor of r1 and r2 and - * places it into r3. - * returns r3 if successful, false otherwise. - * works reliably only if r1 and r2 are not branch numbers. - */ -{ int l1, l2, l3; - char t1[revlength], t2[revlength]; - - l1=countnumflds(r1); l2=countnumflds(r2); - if ((l1<=2 && l2<=2)||(cmpnum(r1,r2)==0)) { - /* on main trunk or identical */ - error("Common ancestor of %s and %s undefined.", r1, r2); - return false; - } - - l3=0; - while ((cmpnumfld(r1, r2, l3+1)==0) && (cmpnumfld(r1, r2, l3+2)==0)){ - l3=l3+2; - } - /* This will terminate since r1 and r2 are not the same; see above*/ - if (l3==0) { - /* no common prefix. Common ancestor on main trunk. */ - VOID partialno(t1,r1,l1>2?2:l1); VOID partialno(t2,r2,l2>2?2:l2); - if (cmpnum(t1,t2)<0) - VOID strcpy(r3,t1); - else VOID strcpy(r3,t2); - if ((cmpnum(r3,r1)==0)||(cmpnum(r3,r2)==0)) { - error("Ancestor for %s and %s undefined.",r1,r2); - return false; - } - return r3; - } else { - if (cmpnumfld(r1,r2,l3+1)==0) { - error("Ancestor for %s and %s undefined.",r1,r2); - return false; - } - return(partialno(r3,r1,l3)); - } -} - - - - -struct hshentry * genrevs(revno,date,author,state,store) -char * revno, * date, * author, * state; -struct hshentry * * store; -/* Function: finds the deltas needed for reconstructing the - * revision given by revno, date, author, and state, and stores pointers - * to these deltas into an array whose starting address is given by store. - * The last pointer stored is nil. The last delta (target delta) is returned. - * If the proper delta could not be found, nil is returned. - */ -{ - int length; - register struct hshentry * next; - int result; - char * branchnum; - char t[revlength]; - - if (Head == nil) { - error("RCSfile empty."); - return nil; - } - - length = countnumflds(revno); - next=Head; - - if (length >= 1) { - /* at least one field; find branch exactly */ - while ((next!=nil) && - ((result=cmpnumfld(revno,next->num,1))<0)) { - /*puts(next->num);*/ - *store++ = next; - next = next->next; - } - - if (next==nil) {error("Branch number %s too low.",partialno(t,revno,1));return nil;} - if (result>0) {error("Branch number %s not present.",partialno(t,revno,1));return nil;} - } - if (length<=1){ - /* pick latest one on given branch */ - branchnum = next->num; /* works even for empty revno*/ - while ((next!=nil) && - (cmpnumfld(branchnum,next->num,1)==0) && - !( - (date==nil?1:(cmpnum(date,next->date)>=0)) && - (author==nil?1:(strcmp(author,next->author)==0)) && - (state ==nil?1:(strcmp(state, next->state) ==0)) - ) - ) - { /*puts(next->num);*/ - *store ++ = next; - next=next->next; - } - if ((next==nil) || - (cmpnumfld(branchnum,next->num,1)!=0))/*overshot*/ { - error("Cannot find revision on branch %s with a date before %s, author %s, and state %s.", - length==0?partialno(t,branchnum,1):revno,date==nil?"<now>":date, - author==nil?"<any>":author, state==nil?"<any>":state); - return nil; - } else { - /*puts(next->num);*/ - *store++ = next; - } - *store = nil; - return next; - } - - /* length >=2 */ - /* find revision; may go low if length==2*/ - while ((next!=nil) && - ((result =cmpnumfld(revno,next->num,2)) <0) && - (cmpnumfld(revno,next->num,1)==0) ) { - /*puts(next->num);*/ - *store++ = next; - next = next->next; - } - - if ((next==nil) || (cmpnumfld(revno,next->num,1)!=0)) { - error("Revision number %s too low.",partialno(t,revno,2)); - return nil; - } - if ((length>2) && (result!=0)) { - error("Revision %s not present.",partialno(t,revno,2)); - return nil; - } - - /* print last one */ - /*puts(next->num);*/ - *store++ = next; - - if (length>2) - return genbranch(next,revno,length,date,author,state,store); - else { /* length == 2*/ - if ((date!=nil) && (cmpnum(date,next->date)<0)){ - error("Revision %s has date %s.",next->num, next->date); - return nil; - } - if ((author!=nil)&&(strcmp(author,next->author)!=0)) { - error("Revision %s has author %s.",next->num,next->author); - return nil; - } - if ((state!=nil)&&(strcmp(state,next->state)!=0)) { - error("Revision %s has state %s.",next->num, - next->state==nil?"<empty>":next->state); - return nil; - } - *store=nil; - return next; - } -} - - - - -struct hshentry * genbranch(bpoint, revno, length,date,author,state,store) -struct hshentry * bpoint; -char * revno; int length; -char * date, * author, * state; -struct hshentry ** store; -/* Function: given a branchpoint, a revision number, date, author, and state, - * genbranch finds the deltas necessary to reconstruct the given revision - * from the branch point on. - * Pointers to the found deltas are stored in an array beginning with store. - * revno must be on a side branch. - * return nil on error - */ -{ - int field; - register struct hshentry * next, * trail; - register struct branchhead * bhead; - int result; - char t[revlength]; - - bhead = bpoint->branches; - - for (field=3; field<=length; field=field+2) { - - if (bhead==nil) {error("No side branches present for %s.",partialno(t,revno,field-1));return nil;} - - /*find branch head*/ - /*branches are arranged in increasing order*/ - while ((bhead!=nil) && - ((result=cmpnumfld(revno,bhead->hsh->num,field))>0)) { - bhead = bhead->nextbranch; - } - - if (bhead==nil) {error("Branch number %s too high.",partialno(t,revno,field));return nil;} - if (result<0) {error("Branch number %s not present.",partialno(t,revno,field));return nil;} - - next = bhead->hsh; - if (length==field) { - /* pick latest one on that branch */ - trail=nil; - do { if ((date==nil?1:(cmpnum(date,next->date)>=0)) && - (author==nil?1:(strcmp(author,next->author)==0)) && - (state ==nil?1:(strcmp(state, next->state) ==0)) - ) trail = next; - next=next->next; - } while (next!=nil); - - if (trail==nil) { - error("Cannot find revision on branch %s with a date before %s, author %s, and state %s.", - revno, date==nil?"<now>":date, - author==nil?"<any>":author, state==nil?"<any>":state); - return nil; - } else { /* print up to last one suitable */ - next = bhead->hsh; - while (next!=trail) { - /*puts(next->num);*/ - *store++ = next; - next=next->next; - } - /*puts(next->num);*/ - *store++ = next; - } - *store = nil; - return next; - } - - /* length > field */ - /* find revision */ - /* check low */ - if (cmpnumfld(revno,next->num,field+1)<0) { - error("Revision number %s too low.",partialno(t,revno,field+1)); - return(nil); - } - do { /*puts(next->num);*/ - *store++ = next; - trail = next; - next = next->next; - } while ((next!=nil) && - (cmpnumfld(revno,next->num,field+1) >=0)); - - if ((length>field+1) && /*need exact hit */ - (cmpnumfld(revno,trail->num,field+1) !=0)){ - error("Revision %s not present.",partialno(t,revno,field+1)); - return(nil); - } - if (length == field+1) { - if ((date!=nil) && (cmpnum(date,trail->date)<0)){ - error("Revision %s has date %s.",trail->num, trail->date); - return nil; - } - if ((author!=nil)&&(strcmp(author,trail->author)!=0)) { - error("Revision %s has author %s.",trail->num,trail->author); - return nil; - } - if ((state!=nil)&&(strcmp(state,trail->state)!=0)) { - error("Revision %s has state %s.",trail->num, - trail->state==nil?"<empty>":trail->state); - return nil; - } - } - bhead = trail->branches; - - } - * store = nil; - return trail; -} - - -char * lookupsym(id) -char * id; -/* Function: looks up id in the list of symbolic names starting - * with pointer SYMBOLS, and returns a pointer to the corresponding - * revision number. Returns nil if not present. - */ -{ - register struct assoc * next; - next = Symbols; - while (next!=nil) { - if (strcmp(id, next->symbol)==0) - return(next->delta->num); - else next=next->nextassoc; - } - return nil; -} - -int expandsym(source, target) -char * source, * target; -/* Function: Source points to a revision number. Expandsym copies - * the number to target, but replaces all symbolic fields in the - * source number with their numeric values. - * A trailing '.' is omitted; leading zeroes are compressed. - * returns false on error; - */ -{ register char * sp, * tp, *bp; - char symbuf[30]; - register enum tokens d; - - sp = source; tp=target; - if (sp == nil) { /*accept nil pointer as a legal value*/ - *tp='\0'; - return true; - } - - while (*sp != '\0') { - if (ctab[*sp] == DIGIT) { - if (*sp=='0') { - /* skip leading zeroes */ - sp++; - while(*sp == '0') sp++; - if (*sp=='\0' || *sp=='.') *tp++ = '0'; /*single zero*/ - } - while(ctab[*sp] == DIGIT) *tp++ = *sp++; - if ((*sp == '\0') || ((*sp=='.')&&(*(sp+1)=='\0'))) { - *tp='\0'; return true; - } - if (*sp == '.') *tp++ = *sp++; - else { - error("Improper revision number: %s",source); - *tp = '\0'; - return false; - } - } elsif (ctab[*sp] == LETTER) { - bp = symbuf; - do { *bp++ = *sp++; - } while(((d=ctab[*sp])==LETTER) || (d==DIGIT) || - (d==IDCHAR)); - *bp= '\0'; - bp=lookupsym(symbuf); - if (bp==nil) { - error("Symbolic number %s is undefined.",symbuf); - *tp='\0'; - return false; - } else { /* copy number */ - while (*tp++ = *bp++); /* copies the trailing \0*/ - } - if ((*sp == '\0') || ((*sp=='.')&&(*(sp+1)=='\0'))) - return true; - if (*sp == '.') { - *(tp-1) = *sp++; - } else { - error("Improper revision number: %s",source); - return false; - } - }else { - error("Improper revision number: %s", source); - *tp = '\0'; - return false; - } - } - *tp = '\0'; - return true; -} - - - -#ifdef REVTEST - -main(argc,argv) -int argc; char * argv[]; -{ - char symrevno[revlength]; /* used for input of revision numbers */ - char numricrevno[revlength]; - char author[20]; - char state[20]; - char date[20]; - struct hshentry * gendeltas[hshsize/2]; - struct hshentry * target; - int i; - - cmdid = "revtest"; - if (argc<2) { - VOID fputs("No input file\n",stderr); - exit(-1); - } - if ((finptr=fopen(argv[1], "r")) == NULL) { - faterror("Can't open input file %s\n",argv[1]); - } - Lexinit(); - getadmin(); - - gettree(); - - getdesc(false); - - do { - /* all output goes to stderr, to have diagnostics and */ - /* errors in sequence. */ - VOID fprintf(stderr,"\nEnter revision number or <return> or '.': "); - if(gets(symrevno)==NULL) break; - if (*symrevno == '.') break; - VOID fprintf(stderr,"%s;\n",symrevno); - expandsym(symrevno,numricrevno); - VOID fprintf(stderr,"expanded number: %s; ",numricrevno); - VOID fprintf(stderr,"Date: "); - gets(date); VOID fprintf(stderr,"%s; ",date); - VOID fprintf(stderr,"Author: "); - gets(author);VOID fprintf(stderr,"%s; ",author); - VOID fprintf(stderr,"State: "); - gets(state); VOID fprintf(stderr, "%s;\n", state); - target=genrevs(numricrevno,*date=='\0'?(char *)nil:date, *author=='\0'?(char *)nil:author, - *state=='\0'?(char *)nil:state,gendeltas); - if (target!=nil) { - i=0; - while (gendeltas[i]!=nil) { - VOID fprintf(stderr,"%s\n",gendeltas[i++]->num); - } - } - } while (true); - VOID fprintf(stderr,"done\n"); - -} - -cleanup(){} -/*dummy*/ - -#endif REVTEST diff --git a/usr.bin/rcs/src/rcssyn.c b/usr.bin/rcs/src/rcssyn.c deleted file mode 100644 index 8069a78cc315..000000000000 --- a/usr.bin/rcs/src/rcssyn.c +++ /dev/null @@ -1,572 +0,0 @@ -/* - * RCS file input - */ -#ifndef lint -static char rcsid[]= "$Id: rcssyn.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/********************************************************************************* - * Syntax Analysis. - * Keyword table - * Testprogram: define SYNDB - * Compatibility with Release 2: define COMPAT2 - ********************************************************************************* - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - -/* $Log: rcssyn.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.6 89/05/01 15:13:32 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.5 88/11/08 12:00:37 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.5 88/08/09 19:13:21 eggert - * Allow cc -R; remove lint. - * - * Revision 4.4 87/12/18 11:46:16 narten - * more lint cleanups (Guy Harris) - * - * Revision 4.3 87/10/18 10:39:36 narten - * Updating version numbers. Changes relative to 1.1 actually relative to - * 4.1 - * - * Revision 1.3 87/09/24 14:00:49 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:40 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:40 kcs - * Initial revision - * - * Revision 4.1 83/03/28 11:38:49 wft - * Added parsing and printing of default branch. - * - * Revision 3.6 83/01/15 17:46:50 wft - * Changed readdelta() to initialize selector and log-pointer. - * Changed puttree to check for selector==DELETE; putdtext() uses DELNUMFORM. - * - * Revision 3.5 82/12/08 21:58:58 wft - * renamed Commentleader to Commleader. - * - * Revision 3.4 82/12/04 13:24:40 wft - * Added routine gettree(), which updates keeplock after reading the - * delta tree. - * - * Revision 3.3 82/11/28 21:30:11 wft - * Reading and printing of Suffix removed; version COMPAT2 skips the - * Suffix for files of release 2 format. Fixed problems with printing nil. - * - * Revision 3.2 82/10/18 21:18:25 wft - * renamed putdeltatext to putdtext. - * - * Revision 3.1 82/10/11 19:45:11 wft - * made sure getc() returns into an integer. - */ - - - -/* -#define COMPAT2 -/* version COMPAT2 reads files of the format of release 2 and 3, but - * generates files of release 3 format. Need not be defined if no - * old RCS files generated with release 2 exist. - */ -/* -#define SYNDB -/* version SYNDB is for debugging the syntax analysis for RCS files. - * SYNDB performs additional error checks. - */ -/* -#define SYNTEST -/* version SYNTEST inputs a RCS file and then prints out its internal - * data structures. -*/ - -#include "rcsbase.h" -extern FILE * finptr; /*RCS input file*/ -extern char * getid(); -extern struct hshentry * getnum(); -extern int getkey(); -extern int getlex(); -extern readstring(); -extern savestring(); - -/* forward */ -char * getkeyval(); - -/* keyword table */ - -char Kaccess[] = "access"; -char Kauthor[] = "author"; -char Kbranch[] = "branch"; -char Kbranches[] = "branches"; -char Kcomment[] = "comment"; -char Kdate[] = "date"; -char Kdesc[] = "desc"; -char Khead[] = "head"; -char Klocks[] = "locks"; -char Klog[] = "log"; -char Knext[] = "next"; -char Kstate[] = "state"; -char Kstrict[] = "strict"; -#ifdef COMPAT2 -char Ksuffix[] = "suffix"; -#endif -char Ksymbols[] = "symbols"; -char Ktext[] = "text"; - -#define COMMLENGTH 20 -char Commleader[COMMLENGTH]; -char * Comment; -struct access * AccessList; -struct access * LastAccess; -struct assoc * Symbols; -struct assoc * LastSymbol; -struct lock * Locks; -struct lock * LastLock; -int StrictLocks; -struct hshentry * Head; -struct hshentry * Dbranch; -int TotalDeltas; - - - -getadmin() -/* Function: Reads an <admin> and initializes the globals - * AccessList, LastAccess, Symbols, LastSymbol, - * Locks, LastLock, StrictLocks, Head, Comment, TotalDeltas; - */ -{ - register char * id; - struct access * newaccess; - struct assoc * newassoc; - struct lock * newlock; - struct hshentry * delta; - - Comment=""; - AccessList=LastAccess=nil; - Symbols=LastSymbol=nil; - Locks=LastLock=nil; - Dbranch = Head = nil; - TotalDeltas=0; - - if (!getkey(Khead)) fatserror("Missing head"); - Head=getnum(); -# ifdef SYNDB - if (Head&&((countnumflds(Head->num)%2)!=0)) - serror("Delta number required for head"); -# endif - if (!getlex(SEMI)) serror("Missing ';' after head"); - - if (getkey(Kbranch)) { /* optional */ - Dbranch=getnum(); - if (!getlex(SEMI)) serror("Missing ';' after branch list"); - } - - -#ifdef COMPAT2 - /* read suffix. Only in release 2 format */ - if (getkey(Ksuffix)) { - if (nexttok==STRING) { - readstring(); nextlex(); /*through away the suffix*/ - } elsif(nexttok==ID) { - nextlex(); - } - if (!getlex(SEMI)) serror("Missing ';' after %s",Ksuffix); - } -#endif - - if (!getkey(Kaccess)) fatserror("Missing access list"); - while (id=getid()) { - newaccess = (struct access *)talloc(sizeof(struct access)); - newaccess->login = id; - newaccess->nextaccess = nil; - if (AccessList == nil) { - AccessList=LastAccess=newaccess; - } else { - LastAccess=LastAccess->nextaccess=newaccess; - } - } - if (!getlex(SEMI)) serror("Missing ';' after access list"); - - if (!getkey(Ksymbols)) fatserror("Missing symbols"); - while (id = getid()) { - if (!getlex(COLON)) - serror("Missing ':' in symbolic name definition"); - if (!(delta=getnum())) { - serror("Missing number in symbolic name definition"); - } else { /*add new pair to association list*/ - newassoc=(struct assoc *)talloc(sizeof(struct assoc)); - newassoc->symbol=id; - newassoc->delta=delta; - newassoc->nextassoc=nil; - if (Symbols == nil) { - Symbols=LastSymbol=newassoc; - } else { - LastSymbol=LastSymbol->nextassoc=newassoc; - } - } - } - if (!getlex(SEMI)) serror("Missing ';' after symbolic names"); - - if (!getkey(Klocks)) serror("Missing locks"); - while (id = getid()) { - if (!getlex(COLON)) - serror("Missing ':' in lock"); - if (!(delta=getnum())) { - serror("Missing number in lock"); - } else { /*add new pair to lock list*/ -# ifdef SYNDB - if ((countnumflds(delta->num)%2)!=0) - serror("Delta number required for lock"); -# endif - newlock=(struct lock *)talloc(sizeof(struct lock)); - newlock->login=id; - newlock->delta=delta; - newlock->nextlock=nil; - if (Locks == nil) { - Locks=LastLock=newlock; - } else { - LastLock=LastLock->nextlock=newlock; - } - } - } - if (!getlex(SEMI)) serror("Missing ';' after locks"); - if (!getkey(Kstrict)) { - StrictLocks = false; - } else { - StrictLocks = true; - if (!getlex(SEMI)) serror("Missing ';' after keyword %s",Kstrict); - } - if (getkey(Kcomment) && (nexttok==STRING)) { - VOID savestring(Commleader,COMMLENGTH);nextlex(); - Comment=Commleader; - if (!getlex(SEMI)) serror("Missing ';' after %s",Kcomment); - } -} - - - -getdelta() -/* Function: reads a delta block. - * returns false if the current block does not start with a number. - */ -{ - register struct hshentry * Delta, * num; - struct branchhead * LastBranch, * NewBranch; - - if (!(Delta=getnum())) return false; -# ifdef SYNDB - if ((countnumflds(Delta->num)%2)!=0) - serror("Delta number required"); -# endif - - hshenter = false; /*Don't enter dates into hashtable*/ - Delta->date = getkeyval(Kdate, NUM, false); - hshenter=true; /*reset hshenter for revision numbers.*/ - - Delta->author = getkeyval(Kauthor, ID, false); - - Delta->state = getkeyval(Kstate, ID, true); - - if (!getkey(Kbranches)) fatserror("Missing branches"); - Delta->branches = LastBranch=nil; - while (num=getnum()) { -# ifdef SYNDB - if ((countnumflds(num->num)%2)!=0) - serror("Delta number required"); -# endif - NewBranch = (struct branchhead *)talloc(sizeof(struct branchhead)); - NewBranch->hsh = num; - NewBranch->nextbranch = nil; - if (LastBranch == nil) { - Delta->branches=LastBranch=NewBranch; - } else { - LastBranch=LastBranch->nextbranch=NewBranch; - } - } - if (!getlex(SEMI)) serror("Missing ';' after branches"); - - if (!getkey(Knext)) fatserror("Missing next"); - Delta->next=num=getnum(); -# ifdef SYNDB - if (num&&((countnumflds(num->num)%2)!=0)) - serror("Delta number required"); -# endif - if (!getlex(SEMI)) serror("Missing ';' after next"); - Delta->log=Delta->lockedby = nil; - Delta->selector = '\0'; - TotalDeltas++; - return (true); -} - - -gettree() -/* Function: Reads in the delta tree with getdelta(), then - * updates the lockedby fields. - */ -{ struct lock * currlock; - while (getdelta()); - currlock=Locks; - while (currlock) { - currlock->delta->lockedby = currlock->login; - currlock = currlock->nextlock; - } -} - - -getdesc(prdesc) -int prdesc; -/* Function: read in descriptive text - * nexttok is not advanced afterwards. - * if prdesc==true, the text is printed to stdout. - */ -{ - - if (!getkey(Kdesc) || (nexttok!=STRING)) fatserror("Missing descriptive text"); - if (prdesc) - printstring(); /*echo string*/ - else readstring(); /*skip string*/ -} - - - - - - -char * getkeyval(keyword, token, optional) -enum tokens token; char * keyword; int optional; -/* reads a pair of the form - * <keyword> <token> ; - * where token is one of <id> or <num>. optional indicates whether - * <token> is optional. A pointer to - * the acutal character string of <id> or <num) is returned. - * Getkeyval terminates the program on missing keyword or token, continues - * on missing ;. - */ -{ - register char * val; - - if (!getkey(keyword)) { - fatserror("Missing %s", keyword); - } - if (nexttok==token) { - val = NextString; - nextlex(); - } else { - if (!optional) {fatserror("Missing %s", keyword); } - else val = nil; - } - if (!getlex(SEMI)) serror("Missing ';' after %s",keyword); - return(val); -} - - - - -putadmin(fout) -register FILE * fout; -/* Function: Print the <admin> node read with getadmin() to file fout. - * Assumption: Variables AccessList, Symbols, Locks, StrictLocks, - * and Head have been set. - */ -{ struct assoc * curassoc; - struct lock * curlock; - struct access * curaccess; - register char * sp; - - VOID fputs(Khead,fout); VOID fputs(" ",fout); - if (Head) VOID fputs(Head->num,fout); - - VOID fprintf(fout,";\n%s ",Kbranch); - if (Dbranch) VOID fputs(Dbranch->num,fout); - - VOID fprintf(fout,";\n%s ",Kaccess); - curaccess = AccessList; - if (curaccess==nil) VOID putc(' ',fout); - while (curaccess) { - VOID putc(' ',fout); - VOID fputs(curaccess->login,fout); - curaccess = curaccess->nextaccess; - } - VOID fprintf(fout,";\n%s ",Ksymbols); - curassoc = Symbols; - if (curassoc==nil) VOID putc(' ',fout); - while (curassoc) { - VOID fprintf(fout," %s:%s",curassoc->symbol, curassoc->delta->num); - curassoc = curassoc->nextassoc; - } - VOID fprintf(fout,";\n%s ",Klocks); - curlock = Locks; - if (curlock==nil) VOID putc(' ',fout); - while (curlock) { - VOID fprintf(fout," %s:%s",curlock->login, curlock->delta->num); - curlock = curlock->nextlock; - } - if (StrictLocks) VOID fprintf(fout,"; %s",Kstrict); - VOID fprintf(fout,";\n%s %c",Kcomment,SDELIM); - if((sp=Comment)!=nil) { - while (*sp) if (putc(*sp++,fout)==SDELIM) VOID putc(SDELIM,fout); - } - VOID fprintf(fout,"%c;\n\n",SDELIM); -} - - - - -putdelta(node,fout) -register struct hshentry * node; -register FILE * fout; -/* Function: prints a <delta> node to fout; - */ -{ struct branchhead * nextbranch; - - if (node == nil) return; - - VOID fprintf(fout,"\n%s\n",node->num); - VOID fprintf(fout,"%s %s; %s %s; %s ", - Kdate,node->date,Kauthor,node->author,Kstate); - if (node->state!=nil) VOID fputs(node->state,fout); - VOID fputs(";\nbranches",fout); - nextbranch = node->branches; - if (nextbranch==nil) VOID putc(' ',fout); - while (nextbranch) { - VOID putc(' ',fout); - VOID fputs(nextbranch->hsh->num,fout); - nextbranch = nextbranch->nextbranch; - } - - VOID fprintf(fout,";\n%s ",Knext); - if (node->next!=nil) VOID fputs(node->next->num,fout); - VOID fputs(";\n",fout); - -} - - - - -puttree(root,fout) -struct hshentry * root; -register FILE * fout; -/* Function: prints the delta tree in preorder to fout, starting with root. - */ -{ struct branchhead * nextbranch; - - if (root==nil) return; - - if (root->selector !=DELETE)putdelta(root,fout); - /* selector DELETE means deleted; set by rcs -o */ - - puttree(root->next,fout); - - nextbranch = root->branches; - while (nextbranch) { - puttree(nextbranch->hsh,fout); - nextbranch = nextbranch->nextbranch; - } -} - - - -int putdtext(num,log,srcfilename,fout) -char * num, * log, * srcfilename; FILE * fout; -/* Function: write a deltatext-node to fout. - * num points to the deltanumber, log to the logmessage, and - * sourcefile contains the text. Doubles up all SDELIMs in both the - * log and the text; Makes sure the log message ends in \n. - * returns false on error. - */ -{ - register char * sp; - register int c; - register FILE * fin; - - VOID fprintf(fout,DELNUMFORM,num,Klog); - /* put log */ - VOID putc(SDELIM,fout); - sp=log; - while (*sp) if (putc(*sp++,fout)==SDELIM) VOID putc(SDELIM,fout); - if (*(sp-1)!='\n') VOID putc('\n', fout); /*append \n if necessary*/ - /* put text */ - VOID fprintf(fout, "%c\n%s\n%c",SDELIM,Ktext,SDELIM); - if ((fin=fopen(srcfilename,"r"))==NULL) { - error("Can't open source file %s",srcfilename); - return false; - } - while ((c=fgetc(fin))!=EOF) { - if (c==SDELIM) VOID putc(SDELIM,fout); /*double up SDELIM*/ - VOID putc(c,fout); - } - VOID putc(SDELIM,fout); VOID putc('\n',fout); - VOID fclose(fin); - return true; -} - - - -#ifdef SYNTEST - -main(argc,argv) -int argc; char * argv[]; -{ - - cmdid = "syntest"; - if (argc<2) { - VOID fputs("No input file\n",stderr); - exit(-1); - } - if ((finptr=fopen(argv[1], "r")) == NULL) { - faterror("Can't open input file %s\n",argv[1]); - } - Lexinit(); - getadmin(); - putadmin(stdout); - - gettree(); - puttree(Head,stdout); - - getdesc(true); - - if (nextlex(),nexttok!=EOFILE) { - fatserror("Syntax error"); - } - exit(0); -} - - -cleanup(){} -/*dummy*/ - - -#endif - diff --git a/usr.bin/rcs/src/rcsutil.c b/usr.bin/rcs/src/rcsutil.c deleted file mode 100644 index 6f821944855e..000000000000 --- a/usr.bin/rcs/src/rcsutil.c +++ /dev/null @@ -1,516 +0,0 @@ -/* - * RCS utilities - */ -#ifndef lint -static char rcsid[]= "$Id: rcsutil.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - - -/* $Log: rcsutil.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.6 89/05/01 15:13:40 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.5 88/11/08 16:01:02 narten - * corrected use of varargs routines - * - * Revision 4.4 88/11/08 12:00:28 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.4 88/08/09 19:13:24 eggert - * Check for memory exhaustion. - * Permit signal handlers to yield either 'void' or 'int'; fix oldSIGINT botch. - * Use execv(), not system(); yield exit status like diff(1)'s. - * - * Revision 4.3 87/10/18 10:40:22 narten - * Updating version numbers. Changes relative to 1.1 actually - * relative to 4.1 - * - * Revision 1.3 87/09/24 14:01:01 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:43 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:43 kcs - * Initial revision - * - * Revision 4.1 83/05/10 15:53:13 wft - * Added getcaller() and findlock(). - * Changed catchints() to check SIGINT for SIG_IGN before setting up the signal - * (needed for background jobs in older shells). Added restoreints(). - * Removed printing of full RCS path from logcommand(). - * - * Revision 3.8 83/02/15 15:41:49 wft - * Added routine fastcopy() to copy remainder of a file in blocks. - * - * Revision 3.7 82/12/24 15:25:19 wft - * added catchints(), ignoreints() for catching and ingnoring interrupts; - * fixed catchsig(). - * - * Revision 3.6 82/12/08 21:52:05 wft - * Using DATEFORM to format dates. - * - * Revision 3.5 82/12/04 18:20:49 wft - * Replaced SNOOPDIR with SNOOPFILE; changed addlock() to update - * lockedby-field. - * - * Revision 3.4 82/12/03 17:17:43 wft - * Added check to addlock() ensuring only one lock per person. - * Addlock also returns a pointer to the lock created. Deleted fancydate(). - * - * Revision 3.3 82/11/27 12:24:37 wft - * moved rmsema(), trysema(), trydiraccess(), getfullRCSname() to rcsfnms.c. - * Introduced macro SNOOP so that snoop can be placed in directory other than - * TARGETDIR. Changed %02d to %.2d for compatibility reasons. - * - * Revision 3.2 82/10/18 21:15:11 wft - * added function getfullRCSname(). - * - * Revision 3.1 82/10/13 16:17:37 wft - * Cleanup message is now suppressed in quiet mode. - */ - - - - -#include <sys/types.h> -#include <sys/stat.h> -#include <signal.h> -#include "rcsbase.h" -#include <pwd.h> -#include <varargs.h> - -#if defined(USG) || defined(V4_2BSD) -#include <fcntl.h> -#endif - -#ifndef V4_2BSD -#define vfork fork -#endif - -extern char * bindex(); -extern FILE * finptr; -extern char * RCSfilename; -extern char * getlogin(); -extern char * malloc(); - - -char * talloc(size) -unsigned size; -{ - char * p; - if (!(p = malloc(size))) { - faterror("out of memory"); - } - return p; -} - - - -char * getcaller() -/* Function: gets the callers login from his uid. - * If the uid is root, tries to get the true login with getlogin(). - */ -{ - struct passwd *pw; - char *name; - static int special_user(); - - pw = getpwuid(getuid()); - if (pw == NULL || special_user(name = pw->pw_name)) - if ((name = getlogin()) == NULL || *name == 0) - name = pw == NULL ? "nobody" : pw->pw_name; - return (name); -} - -static -special_user(s) - register char *s; -{ - register char **p; - static char *u[] = { "root", "daemon", "bin", "news", 0 }; - - for (p = u; *p; p++) - if (**p == *s && strcmp(*p, s) == 0) - return (1); - return (0); -} - - -struct hshentry * findlock(who,delete) -char * who; int delete; -/* Finds the first lock held by who and returns a pointer - * to the locked delta; also removes the lock if delete==true. - * Returns nil if there is no lock held by who. - */ -{ - register struct lock * next, * trail; - struct lock dummy; - - dummy.nextlock=next=Locks; - trail = &dummy; - while (next!=nil) { - if(strcmp(who,next->login)==0) break; /*found a lock*/ - trail=next; - next=next->nextlock; - } - if (next!=nil) { - /* found one */ - if (delete) { - /* delete it */ - trail->nextlock=next->nextlock; - Locks=dummy.nextlock; - next->delta->lockedby=nil; /* reset locked-by */ - } - return next->delta; - } else return nil; -} - - - - - - - -struct lock * addlock(delta,who) -struct hshentry * delta; char * who; -/* Given a delta, addlock checks whether - * the delta is locked by somebody other than who. - * If so, an error message is printed, and false returned. - * If the delta is not reserved at all, a lock for it is added, - * and a pointer for the lock returned. - */ -{ - struct lock * next; - - next=Locks; - while (next!=nil) { - if (cmpnum(delta->num,next->delta->num)==0) { - if (strcmp(who,next->login)==0) - return next; - /* lock exists already */ - else { - error("revision %s already locked by %s", - delta->num, next->login); - return false; - } - } else { - if (strcmp(who,next->login)==0) { - error("you already locked %s; only one lock allowed per person.", - next->delta->num); - return false; - } else { - next=next->nextlock; - } - } - } - /* not found; set up new lockblock */ - next= (struct lock *) talloc(sizeof (struct lock)); - delta->lockedby=next->login=who; - next->delta= delta; - next->nextlock=Locks; - Locks=next; - return next; -} - - - -int addsymbol(delta,name,rebind) -struct hshentry * delta; char * name; int rebind; -/* Function: adds a new symbolic name and associates it with node delta. - * If name already exists and rebind is true, the name is associated - * with the new delta; otherwise, an error message is printed and - * false returned. Returns true it successful. - */ -{ register struct assoc * next; - next=Symbols; - while (next!=nil) { - if (strcmp(name,next->symbol)==0) { - if (rebind) { - next->delta=delta; - return true; - } else { - error("symbolic name %s already bound to %s", - name,next->delta->num); - return false; - } - } else next = next->nextassoc; - } - /* not found; insert new pair. */ - next = (struct assoc *) talloc(sizeof(struct assoc)); - next->symbol=name; - next->delta=delta; - next->nextassoc=Symbols; - Symbols = next; - return true; -} - - - - -int checkaccesslist(who) -char * who; -/* function: Returns true if who is the superuser, the owner of the - * file, the access list is empty, or who is on the access list. - * Prints an error message and returns false otherwise. - */ -{ - register struct access * next; - struct stat statbuf; - - if ((AccessList==nil) || (strcmp(who,"root")==0)) - return true; - - next=AccessList; - do { - if (strcmp(who,next->login)==0) - return true; - next=next->nextaccess; - } while (next!=nil); - - VOID fstat(fileno(finptr),&statbuf); /* get owner of file */ - if (getuid() == statbuf.st_uid) return true; - - error("User %s not on the access list",who); - return false; -} - - -static SIGNAL_TYPE catchsig(s) -{ - ignoreints(); - diagnose("\nRCS: cleaning up\n"); - VOID cleanup(); - exit(2); -#ifdef lint - catchsig(s); -#endif -} - -static sig[] = {SIGINT,SIGHUP,SIGQUIT,SIGPIPE,SIGTERM}; -#define SIGS (sizeof(sig)/sizeof(*sig)) -static SIGNAL_TYPE (*catcher[SIGS])(); - - void catchints() - { - register i; - for (i=SIGS; 0<=--i; ) - catcher[i] = - signal(sig[i],SIG_IGN) == SIG_IGN ? SIG_IGN : catchsig; - restoreints(); - } - - void ignoreints() - { - register i; - for (i=SIGS; 0<=--i; ) - VOID signal(sig[i], SIG_IGN); - } - -void restoreints() -{ - register i; - for (i=SIGS; 0<=--i; ) - if (catcher[i] != SIG_IGN) - VOID signal(sig[i], catcher[i]); -} - -fastcopy(inf,outf) -FILE * inf, * outf; -/* Function: copies the remainder of file inf to outf. First copies the - * rest that is in the IO-buffer of inf character by character, and then - * copies the remainder in blocks. - */ -{ char buf[BUFSIZ]; - register int rcount, wcount; - - /* write the rest of the buffer to outf */ -#ifdef _FSTDIO - while (--inf->_r >= 0) - VOID putc(*inf->_p++, outf); -#else - while ((--inf->_cnt)>=0) { - VOID putc(*inf->_ptr++&0377,outf); - } -#endif - if (fflush(outf) == EOF) { - writeerror(); - } - - /*now read the rest of the file in blocks*/ - while ((rcount=read(fileno(inf),buf,BUFSIZ))>0) { - wcount=write(fileno(outf),buf,rcount); - if (wcount!=rcount) { - writeerror(); - } - } -} - - - - - - -#ifdef SNOOPFILE - -#include "time.h" -extern struct tm* localtime(); -extern long time(); - -logcommand(commandname,delta, sequence,login) -char* commandname; struct hshentry * delta, * sequence[];char * login; -/* Function: start a process to write the file that - * logs the RCS command. - * Each line in the log file contains the following information: - * operation, revision(r), backward deltas applied(b), forward deltas applied(f), - * total deltas present(t), creation date of delta(d), date of operation(o), - * login of caller, RCS file name. - */ -{ - char logline[200]; - char curdate[datelength]; - char *inoutargs[5]; - register int i, backward, forward; - long clock; - struct tm * tm; - - clock=time((long *)0); - tm=localtime(&clock); - - VOID sprintf(curdate,DATEFORM, - tm->tm_year, tm->tm_mon+1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); - - i= backward=forward=0; - while(sequence[i]!=nil) { /* count deltas to be applied*/ - if (countnumflds(sequence[i]->num) == 2) - backward++; /* reverse delta */ - else forward++; /* branch delta */ - i++; - } - VOID sprintf(logline,"%s %10sr %3db %3df %3dt %sc %so %s %s", - commandname,delta->num,backward,forward,TotalDeltas,delta->date, - curdate,login,bindex(getfullRCSname(),'/')); - inoutargs[0] = nil; - inoutargs[1] = nil; - inoutargs[2] = SNOOP; - inoutargs[3] = logline; - inoutargs[4] = nil; - VOID run_back(inoutargs); -} -#endif - - -static int fdreopen(fd, file, flags, mode) - char *file; -{ - int newfd; - VOID close(fd); - newfd = flags==-1 ? creat(file,mode) : open(file,flags,mode); - if (newfd < 0 || newfd == fd) - return newfd; -#ifdef F_DUPFD - fd = fcntl(newfd, F_DUPFD, fd); -#else - fd = dup2(newfd, fd); -#endif - VOID close(newfd); - return fd; -} - -static void tryopen(fd,file,flags) - char *file; -{ - if (file && fdreopen(fd,file,flags,0600) != fd) { - VOID write(fileno(stderr), file, strlen(file)); - VOID write(fileno(stderr), ": cannot open\n", 14); - _exit(2); - } -} - -/* -/* Run in the background a command specified by the strings in 'inoutargs'. -/* inoutargs[0], if nonnil, is the name of the input file. -/* inoutargs[1], if nonnil, is the name of the output file. -/* inoutargs[2..] form the command to be run in the background. -/*/ -static int run_back(inoutargs) - register char **inoutargs; -{ - int pid; - if (fflush(stdout) == EOF || fflush(stderr) == EOF) - return -1; - if (!(pid = vfork())) { - tryopen(fileno(stdin), inoutargs[0], 0); - tryopen(fileno(stdout), inoutargs[1], -1); - VOID execv(inoutargs[2], &inoutargs[2]); - inoutargs[1] = "/bin/sh"; - VOID execv(inoutargs[1], &inoutargs[1]); - VOID write(fileno(stderr), "/bin/sh: not found\n", 19); - _exit(2); - } - return pid; -} - -#define CARGSMAX 20 -/* -/* Run a command. -/* The first two arguments are the input and output files (if nonnil); -/* the rest specify the command and its arguments. -/*/ -int run(va_alist) - va_dcl -{ - va_list ap; - int pid, wstatus, w; - char *rgargs[CARGSMAX]; - register i = 0; - va_start(ap); - rgargs[0] = va_arg(ap, char *); - rgargs[1] = va_arg(ap, char *); - for (i =2; i< CARGSMAX; i++) { - rgargs[i] = va_arg(ap, char *); - if (rgargs[i] == NULL) - break; - } - va_end(ap); - pid = run_back(rgargs); - if (pid < 0) - return pid; - for (;;) - if ((w = wait(&wstatus)) < 0) - return w; - else if (w == pid) - return wstatus; -} diff --git a/usr.bin/rcs/src/rlog.c b/usr.bin/rcs/src/rlog.c deleted file mode 100644 index e651217d5d66..000000000000 --- a/usr.bin/rcs/src/rlog.c +++ /dev/null @@ -1,1212 +0,0 @@ -/* - * RLOG operation - */ -#ifndef lint -static char rcsid[]= -"$Header: /cvsroot/src/usr.bin/rcs/src/Attic/rlog.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/***************************************************************************** - * print contents of RCS files - ***************************************************************************** - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - - - -/* $Log: rlog.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.7 89/05/01 15:13:48 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.6 88/11/08 11:59:40 narten - * changes from eggert@sm.unisys.com (Paul Eggert) - * - * Revision 4.6 88/08/09 19:13:28 eggert - * Check for memory exhaustion; don't access freed storage. - * Shrink stdio code size; remove lint. - * - * Revision 4.5 87/12/18 11:46:38 narten - * more lint cleanups (Guy Harris) - * - * Revision 4.4 87/10/18 10:41:12 narten - * Updating version numbers - * Changes relative to 1.1 actually relative to 4.2 - * - * Revision 1.3 87/09/24 14:01:10 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.2 87/03/27 14:22:45 jenkins - * Port to suns - * - * Revision 1.1 84/01/23 14:50:45 kcs - * Initial revision - * - * Revision 4.2 83/12/05 09:18:09 wft - * changed rewriteflag to external. - * - * Revision 4.1 83/05/11 16:16:55 wft - * Added -b, updated getnumericrev() accordingly. - * Replaced getpwuid() with getcaller(). - * - * Revision 3.7 83/05/11 14:24:13 wft - * Added options -L and -R; - * Fixed selection bug with -l on multiple files. - * Fixed error on dates of the form -d'>date' (rewrote getdatepair()). - * - * Revision 3.6 82/12/24 15:57:53 wft - * shortened output format. - * - * Revision 3.5 82/12/08 21:45:26 wft - * removed call to checkaccesslist(); used DATEFORM to format all dates; - * removed unused variables. - * - * Revision 3.4 82/12/04 13:26:25 wft - * Replaced getdelta() with gettree(); removed updating of field lockedby. - * - * Revision 3.3 82/12/03 14:08:20 wft - * Replaced getlogin with getpwuid(), %02d with %.2d, fancydate with PRINTDATE. - * Fixed printing of nil, removed printing of Suffix, - * added shortcut if no revisions are printed, disambiguated struct members. - * - * Revision 3.2 82/10/18 21:09:06 wft - * call to curdir replaced with getfullRCSname(), - * fixed call to getlogin(), cosmetic changes on output, - * changed conflicting long identifiers. - * - * Revision 3.1 82/10/13 16:07:56 wft - * fixed type of variables receiving from getc() (char -> int). - */ - - - -#include "time.h" -#include "rcsbase.h" -#ifndef lint -static char rcsbaseid[] = RCSBASE; -#endif - -extern char * partialno(); -extern char * getcaller(); /*get login of caller */ -extern free(); -extern int countnumflds(); -extern int compartial(); -extern int expandsym(); /*get numeric name of a revision */ -extern int nextc; /*next input character */ -extern char Klog[]; -extern char Ktext[]; -extern int partime(); -extern long maketime(); /*convert parsed time to unix time. */ -extern struct tm * localtime(); /*convert unixtime into a tm-structure */ -extern int pairfilenames(); -extern struct hshentry * getnum(); -extern FILE * finptr; /* RCS input file */ -extern FILE * frewrite; /* new RCS file */ -extern int rewriteflag; /* indicates whether input should be */ - /* echoed to frewrite */ -extern int nerror; /* error counter */ - -char * RCSfilename, * workfilename; - -char * caller; /* caller's login; */ -int descflag, selectflag, selectop; /* option to print access list, symbolic */ - /* names, descriptive text, locks and */ - /* Head */ -int onlylockflag; /* option to print only files */ - /* with locks */ -int onlyRCSflag; /* option to print only RCS file name */ -int lockflag; /* whether locker option is set */ -int revno; /* number of revision chosen */ - -struct lockers { /* lockers in locker option; stored */ - char * login; /* lockerlist */ - struct lockers * lockerlink; - } ; - -struct stateattri { /* states in state option; stored in */ - char * status; /* statelist */ - struct stateattri * nextstate; - } ; - -struct authors { /* login names in author option; */ - char * login; /* stored in authorlist */ - struct authors * nextauthor; - } ; - -struct Revpairs{ /* revision or branch range in -r */ - int numfld; /* option; stored in revlist */ - char * strtrev; - char * endrev; - struct Revpairs * rnext; - } ; - -struct Datepairs{ /* date range in -d option; stored in */ - char strtdate[datelength]; /* duelst and datelist */ - char enddate[datelength]; - struct Datepairs * dnext; - }; - -char Dotstring[200]; /* string of numeric revision name */ -char * Nextdotstring; /* next available place of Dotstring */ -struct Datepairs * datelist, * duelst; -struct Revpairs * revlist, * Revlst; -int branchflag; /* set on -b */ -struct lockers * lockerlist; -struct stateattri * statelist; -struct authors * authorlist; - - - -main (argc, argv) -int argc; -char * argv[]; -{ - struct Datepairs * currdate; - struct assoc * curassoc; - struct access * curaccess; - struct lock * currlock; - char * cmdusage; - - cmdusage = "command format:\nrlog -L -R -h -t -b -ddates -l[lockers] -rrevisions -sstates -w[logins] file ..."; - cmdid = "rlog"; - descflag = selectflag = true; - lockflag = onlylockflag = selectop = false; - onlyRCSflag = false; - lockerlist = nil; - authorlist = nil; - statelist = nil; - Revlst = revlist = nil; - branchflag= false; - duelst = datelist = nil; - caller=getcaller(); - - while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) { - switch ((*argv)[1]) { - - case 'L': - onlylockflag = true; - break; - - case 'R': - onlyRCSflag =true; - break; - - case 'l': - selectop = true; - lockflag = true; - getlocker( (*argv)+2 ); - break; - - case 'b': - selectop = true; - branchflag = true; - break; - - case 'r': - selectop = true; - getrevpairs( (*argv)+2 ); - break; - - case 'd': - selectop = true; - getdatepair( (*argv)+2 ); - break; - - case 's': - selectop = true; - getstate( (*argv)+2); - break; - - case 'w': - selectop = true; - getauthor( (*argv)+2); - break; - - case 'h': - if ( ! selectflag ) warn("option -t overrides -h"); - else descflag = false; - break; - - case 't': - selectflag = false; - if ( ! descflag ) warn("option -t overrides -h"); - descflag = true; - break; - - default: - faterror("unknown option: %s\n%s", *argv,cmdusage); - - }; - } /* end of option processing */ - - if (argc<1) faterror("No input file\n%s",cmdusage); - - - /* now handle all filenames */ - do { - rewriteflag=false; - finptr=frewrite=nil; - - - if (!pairfilenames(argc, argv, true,false)) continue; - - /* now RCSfilename contains the name of the RCS file, and finptr - * the file descriptor. Workfilename contains the name of the - * working file. - */ - - if ( !trysema(RCSfilename, false)) goto loopend; /* give up */ - - /* do nothing if -L is given and there are no locks*/ - if ( onlylockflag && Locks == nil ) goto loopend; - - if ( onlyRCSflag ) { - VOID fprintf(stdout, "%s\n", RCSfilename); - goto loopend; - } - /* print RCS filename , working filename and optional - administrative information */ - VOID fprintf(stdout, "\nRCS file: %s; ",RCSfilename); - /* could use getfullRCSname() here, but that is very slow */ - VOID fprintf(stdout, "Working file: %s\n", workfilename); - VOID fprintf(stdout, "head: %s\n", Head==nil?"":Head->num); - VOID fprintf(stdout, "branch: %s\n", Dbranch==nil?"":Dbranch->num); - - VOID fputs("locks: ", stdout); /* print locker list */ - currlock = Locks; - while( currlock ) { - VOID fprintf(stdout," %s: %s;", currlock->login, - currlock->delta->num); - currlock = currlock->nextlock; - } - if ( StrictLocks ) - VOID fputs(Locks==nil?" ; strict":" strict",stdout); - - VOID fputs("\naccess list: ", stdout); /* print access list */ - curaccess = AccessList; - while(curaccess) { - VOID fputs(" ",stdout); - VOID fputs(curaccess->login, stdout); - curaccess = curaccess->nextaccess; - } - - VOID fputs("\nsymbolic names:", stdout); /* print symbolic names */ - curassoc = Symbols; - while( curassoc ) { - VOID fprintf(stdout, " %s: %s;",curassoc->symbol, - curassoc->delta->num); - curassoc = curassoc->nextassoc; - } - - VOID fprintf(stdout,"\ncomment leader: \"%s\"\n",Comment); - - gettree(); - VOID fprintf(stdout, "total revisions: %d; ", TotalDeltas); - if ( Head == nil || !selectflag || !descflag) { - VOID putc('\n',stdout); - if (descflag) VOID fputs("description:\n", stdout); - getdesc(descflag); - VOID fputs("=============================================================================\n",stdout); - goto loopend; - } - - - /* keep only those locks given by -l */ - if (lockflag) - trunclocks(); - getnumericrev(); /* get numeric revision or branch names */ - revno = 0; - - exttree(Head); - - /* get most recently date of the dates pointed by duelst */ - currdate = duelst; - while( currdate) { - recentdate(Head, currdate); - currdate = currdate->dnext; - } - - extdate(Head); - - /* reinitialize the date specification list */ - currdate = duelst; - while(currdate) { - VOID sprintf(currdate->strtdate,DATEFORM,0,0,0,0,0,0); - currdate = currdate->dnext; - } - - if ( selectop || ( selectflag && descflag) ) - VOID fprintf(stdout, "selected revisions: %d", revno); - VOID putc('\n', stdout); - if (descflag) VOID fputs("description:\n", stdout); - getdesc(descflag); - while( (nexttok != EOFILE) && readdeltalog()); - if (selectflag && descflag && revno) { - putrunk(); - putree(Head); - if (nextlex(), nexttok != EOFILE) - fatserror("syntax error; expecting EOF"); - } - VOID fputs("=============================================================================\n",stdout); - loopend: - VOID fclose(finptr); - } while( ++argv, --argc >= 1); - exit(nerror!=0); -} - - - -putrunk() -/* function: print revisions chosen, which are in trunk */ - -{ - struct hshentry * ptr, * pre; - - if (Head == nil) return; /* empty tree */ - - pre = Head; - ptr = Head->next; - while( ptr ) { - putadelta(pre,ptr,true); - pre = ptr; - ptr = ptr->next; - } - putadelta(pre,ptr,true); -} - - - -putree(root) -struct hshentry *root; -/* function: print delta tree( not include trunck) in reversed calender - order on each branch */ - -{ - if ( root == nil ) return; - - putree(root->next); - - putforest(root->branches); -} - - - - -putforest(branchroot) -struct branchhead * branchroot; -/* function: print branches that has the same direct ancestor */ -{ - - if ( branchroot == nil ) return; - - putforest(branchroot->nextbranch); - - putabranch(branchroot->hsh); - putree(branchroot->hsh); -} - - - - -putabranch(root) -struct hshentry *root; -/* function : print one branch */ - -{ - - if ( root == nil) return; - - putabranch(root->next); - - putadelta(root, root, false); -} - - - - - -putadelta(node,editscript,trunk) -register struct hshentry * node; -register struct hshentry * editscript; -int trunk; -/* function: print delta node if node->selector is 's'. */ -/* editscript indicates where the editscript is stored */ -/* trunk indicated whether this node is in trunk */ -{ - struct branchhead * newbranch; - char * branchnum, branch[40]; - - if ( ( node == nil) || ( node->selector == 'u')) - return; - - VOID fprintf(stdout,"----------------------------\n"); - VOID fprintf(stdout, "revision %s ",node->num); - if ( node->lockedby ) - VOID fprintf(stdout, "locked by: %s; ", node->lockedby); - VOID putc('\n', stdout); - - VOID fputs("date: ",stdout); - VOID PRINTDATE(stdout,node->date); VOID putc(' ',stdout); - VOID PRINTTIME(stdout,node->date); - VOID fprintf(stdout, "; author: %s; ", node->author); - VOID fprintf(stdout, "state: %s; ", node->state); - - if ( editscript ) - if(trunk) - VOID fprintf(stdout,"lines added/del: %d/%d", - editscript->deletelns, editscript->insertlns); - else - VOID fprintf(stdout,"lines added/del: %d/%d", - editscript->insertlns, editscript->deletelns); - - VOID putc('\n', stdout); - - branchnum = & (branch[0]); - newbranch = node->branches; - if ( newbranch ) { - VOID fputs("branches: ", stdout); - while( newbranch ) { - getbranchno(newbranch->hsh->num, branchnum); - VOID fprintf(stdout, "%s; ", branchnum); - newbranch = newbranch->nextbranch; - } - VOID putc('\n', stdout); - } - - VOID fputs(node->log,stdout); -} - - - - - -readdeltalog() -/* Function : get the log message and skip the text of a deltatext node. - * Return false if current block does not start with a number. - * Assumes the current lexeme is not yet in nexttok; does not - * advance nexttok. - */ -{ - register struct hshentry * Delta; - - nextlex(); - if ( !(Delta = getnum() )) return(false); - if ( ! getkey(Klog) || ( nexttok != STRING ) ) - fatserror("Missing log entry"); - Delta->log = talloc(logsize); - VOID savestring(Delta->log, logsize); - nextlex(); - if ( ! getkey(Ktext) || (nexttok != STRING) ) - fatserror("Missing delta text"); - Delta->insertlns = Delta->deletelns = 0; - if ( Delta != Head) - getscript(Delta); - else - readstring(); - return true; -} - - - -getscript(Delta) -struct hshentry * Delta; -/* function: read edit script of Delta and count how many lines added */ -/* and deleted in the script */ - -{ - int ed; /* editor command */ - register FILE * fin; - register int c; - register int i; - int length; - - fin = finptr; - while( (ed = getc(fin)) != EOF) { - /* assume first none white character is command name */ - while( ed == '\n' || ed == ' ' || ed == '\t') - ed = getc(fin); - if (ed == SDELIM) break; /* script text is ended */ - while( ( c = getc(fin)) == ' ' ); /* skip blank */ - if ( ! ('0' <= c && c <= '9')) { - faterror("Missing line number in edit script"); - break; - } - while( '0' <= (c = getc(fin)) && c <= '9' ) ; - - while( c == ' ')c = getc(fin); /* skip blanks */ - if ( !('0' <= c && c <= '9' ) ) { - faterror("Incorrect range in edit script"); - break; - } - length = c - '0'; - while( '0' <= (c = getc(fin)) && c <= '9' ) - length = length * 10 + c - '0'; - while( c != '\n' && c != EOF) c = getc(fin); - switch (ed) { - case 'd' : - Delta->deletelns += length; - break; - - case 'a' : - /* skip scripted lines */ - for ( i=length; i > 0 && c != EOF; i--){ - while( (c=getc(fin)) != '\n' && c != EOF); - Delta->insertlns++; - } - break; - - default: - faterror("Unknown command in edit script: %c", ed); - break; - } - } - nextc = getc(fin); -} - - - - - - - -exttree(root) -struct hshentry *root; -/* function: select revisions , starting with root */ - -{ - struct branchhead * newbranch; - - if (root == nil) return; - - extractdelta(root); - exttree(root->next); - - newbranch = root->branches; - while( newbranch ) { - exttree(newbranch->hsh); - newbranch = newbranch->nextbranch; - } -} - - - - -getlocker(argv) -char * argv; -/* function : get the login names of lockers from command line */ -/* and store in lockerlist. */ - -{ - register char c; - struct lockers * newlocker; - argv--; - while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' || - c == '\n' || c == ';') ; - if ( c == '\0') { - lockerlist=nil; - return; - } - - while( c != '\0' ) { - newlocker = ( struct lockers *)talloc( sizeof(struct lockers) ); - newlocker->lockerlink = lockerlist; - newlocker->login = argv; - lockerlist = newlocker; - while ( ( c = (*++argv)) != ',' && c != '\0' && c != ' ' - && c != '\t' && c != '\n' && c != ';') ; - *argv = '\0'; - if ( c == '\0' ) return; - while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' || - c == '\n' || c == ';') ; - } -} - - - -getauthor(argv) -char *argv; -/* function: get the author's name form command line */ -/* and store in aauthorlist */ - -{ - register c; - struct authors * newauthor; - - argv--; - while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' || - c == '\n' || c == ';') ; - if ( c == '\0' ) { - authorlist = (struct authors *)talloc(sizeof(struct authors)); - authorlist->login = caller; - authorlist->nextauthor = nil; - return; - } - - while( c != '\0' ) { - newauthor = (struct authors *)talloc(sizeof(struct authors)); - newauthor->nextauthor = authorlist; - newauthor->login = argv; - authorlist = newauthor; - while( ( c = *++argv) != ',' && c != '\0' && c != ' ' - && c != '\t' && c != '\n' && c != ';') ; - * argv = '\0'; - if ( c == '\0') return; - while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' || - c == '\n' || c == ';') ; - } -} - - - - -getstate(argv) -char * argv; -/* function : get the states of revisions from command line */ -/* and store in statelist */ - -{ - register char c; - struct stateattri *newstate; - - argv--; - while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' || - c == '\n' || c == ';') ; - if ( c == '\0'){ - warn(" Missing state attributes after -s options"); - return; - } - - while( c != '\0' ) { - newstate = (struct stateattri *)talloc(sizeof(struct stateattri)); - newstate->nextstate = statelist; - newstate->status = argv; - statelist = newstate; - while( (c = (*++argv)) != ',' && c != '\0' && c != ' ' - && c != '\t' && c != '\n' && c != ';') ; - *argv = '\0'; - if ( c == '\0' ) return; - while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' || - c == '\n' || c == ';') ; - } -} - - - -trunclocks() -/* Function: Truncate the list of locks to those that are held by the */ -/* id's on lockerlist. Do not truncate if lockerlist empty. */ - -{ - struct lockers * plocker; - struct lock * plocked, * nextlocked; - - if ( (lockerlist == nil) || (Locks == nil)) return; - - /* shorten Locks to those contained in lockerlist */ - plocked = Locks; - Locks = nil; - while( plocked != nil) { - plocker = lockerlist; - while((plocker != nil) && ( strcmp(plocker->login, plocked->login)!=0)) - plocker = plocker->lockerlink; - nextlocked = plocked->nextlock; - if ( plocker != nil) { - plocked->nextlock = Locks; - Locks = plocked; - } - plocked = nextlocked; - } -} - - - -recentdate(root, pd) -struct hshentry * root; -struct Datepairs * pd; -/* function: Finds the delta that is closest to the cutoff date given by */ -/* pd among the revisions selected by exttree. */ -/* Successively narrows down the interfal given by pd, */ -/* and sets the strtdate of pd to the date of the selected delta */ -{ - struct branchhead * newbranch; - - if ( root == nil) return; - if ( root->selector == 's') { - if ( cmpnum(root->date, pd->strtdate) >= 0 && - cmpnum(root->date, pd->enddate) <= 0) - VOID strcpy(pd->strtdate, root->date); - } - - recentdate(root->next, pd); - newbranch = root->branches; - while( newbranch) { - recentdate(newbranch->hsh, pd); - newbranch = newbranch->nextbranch; - } -} - - - - - - -extdate(root) -struct hshentry * root; -/* function: select revisions which are in the date range specified */ -/* in duelst and datelist, start at root */ - -{ - struct branchhead * newbranch; - struct Datepairs * pdate; - - if ( root == nil) return; - - if ( datelist || duelst) { - pdate = datelist; - while( pdate ) { - if ( (pdate->strtdate)[0] == '\0' || cmpnum(root->date,pdate->strtdate) >= 0){ - if ((pdate->enddate)[0] == '\0' || cmpnum(pdate->enddate,root->date) >= 0) - break; - } - pdate = pdate->dnext; - } - if ( pdate == nil) { - pdate = duelst; - while(pdate) { - if ( cmpnum(root->date, pdate->strtdate) == 0) - break; - pdate = pdate->dnext; - } - } - if ( pdate == nil) - root->selector = 'u'; - } - if (root->selector == 's') revno++; - - extdate(root->next); - - newbranch = root->branches; - while( newbranch ) { - extdate(newbranch->hsh); - newbranch = newbranch->nextbranch; - } -} - - - -extractdelta(pdelta) -struct hshentry * pdelta; -/* function: compare information of pdelta to the authorlst, lockerlist, */ -/* statelist, revlist and mark 's' on selector if pdelta is */ -/* selected; otherwise, mark 'u' */ - -{ - struct lock * plock; - struct stateattri * pstate; - struct authors * pauthor; - struct Revpairs * prevision; - int length; - - pdelta->selector = 's'; - if ( authorlist ) { /* certain author's revisions wanted only */ - pauthor = authorlist; - while((pauthor != nil) && ( strcmp(pauthor->login, pdelta->author)!=0)) - pauthor = pauthor->nextauthor; - if ( pauthor == nil ) { - pdelta->selector = 'u'; - return; - } - } - if ( statelist ) { /* revisions with certain state wanted */ - pstate = statelist; - while((pstate != nil) && (strcmp(pstate->status, pdelta->state)!=0)) - pstate = pstate->nextstate; - if ( pstate == nil ) { - pdelta->selector = 'u'; - return; - } - } - if ( lockflag ) { /* locked revisions */ - plock = Locks; - while( plock && (plock->delta != pdelta)) - plock = plock->nextlock; - if (plock == nil ) { - pdelta->selector = 'u'; - return; - } - } - if ( Revlst ) { /* revisions or branches selected */ - - prevision = Revlst; - while( prevision != nil ) { - length = prevision->numfld; - if ( length % 2 == 1) { /* a branch number */ - if ( countnumflds(pdelta->num) ==(length+1)) - if ( (compartial(pdelta->num, prevision->strtrev,length) >= 0)&& - (compartial(prevision->endrev, pdelta->num, length) >= 0) ) - break; - } - else if ( countnumflds(pdelta->num ) == length) /* a revision */ - if ( (compartial(pdelta->num, prevision->strtrev, length) >= 0) && - (compartial(prevision->endrev, pdelta->num, length) >= 0) ) - break; - prevision = prevision->rnext; - } - if (prevision == nil) { - pdelta->selector = 'u'; - return; - } - } -} - - - -char * procdate(target, source) -char * target, * source; -/* Function: Parses a free-format date in target, converts it - * into RCS internal format, and stores the result into source. - * Returns target on success, nil otherwise. - */ -{ - long unixtime; - struct tm parseddate, *ftm; - - if ( partime(source, &parseddate) == 0) { - error("Can't parse date/time: %s", source); - *target= '\0'; - return nil; - } - if ( (unixtime = maketime(&parseddate)) == 0L) { - error("Inconsistent date/time: %s", source); - *target='\0'; - return nil; - } - ftm = localtime(&unixtime); - VOID sprintf(target,DATEFORM, - ftm->tm_year,ftm->tm_mon+1,ftm->tm_mday,ftm->tm_hour,ftm->tm_min,ftm->tm_sec); - return target; -} - - - -getdatepair(argv) - char * argv; -/* function: get time range from command line and store in datelist if */ -/* a time range specified or in duelst if a time spot specified */ - -{ - register char c; - struct Datepairs * nextdate; - char * rawdate; - int switchflag; - - argv--; - while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' || - c == '\n' || c == ';') ; - if ( c == '\0' ) { - warn("Missing date/time after -d"); - return; - } - - while( c != '\0' ) { - switchflag = false; - nextdate = (struct Datepairs *) talloc(sizeof(struct Datepairs)); - if ( c == '<' ) { /* case: -d <date */ - c = *++argv; - (nextdate->strtdate)[0] = '\0'; - } elsif (c == '>') { /* case: -d >date */ - c = *++argv; - (nextdate->enddate)[0] = '\0'; - switchflag = true; - } else { - rawdate = argv; - while( c != '<' && c != '>' && c != ';' && c != '\0') - c = *++argv; - *argv = '\0'; - if ( c == '>' ) switchflag=true; - if (procdate(switchflag?nextdate->enddate:nextdate->strtdate, - rawdate)==nil) continue; - if ( c == ';' || c == '\0') { /* case: -d date */ - VOID strcpy(nextdate->enddate,nextdate->strtdate); - VOID sprintf(nextdate->strtdate,DATEFORM,0,0,0,0,0,0); - nextdate->dnext = duelst; - duelst = nextdate; - goto end; - } else { - /* case: -d date< or -d date>; see switchflag */ - while ( (c= *++argv) == ' ' || c=='\t' || c=='\n'); - if ( c == ';' || c == '\0') { - /* second date missing */ - if (switchflag) - *nextdate->strtdate= '\0'; - else - *nextdate->enddate= '\0'; - nextdate->dnext = datelist; - datelist = nextdate; - goto end; - } - } - } - rawdate = argv; - while( c != '>' && c != '<' && c != ';' && c != '\0') - c = *++argv; - *argv = '\0'; - if (procdate(switchflag?nextdate->strtdate:nextdate->enddate, - rawdate)==nil) continue; - nextdate->dnext = datelist; - datelist = nextdate; - end: -/* - VOID printf("startdate: %s; enddate: %s;\n", nextdate->strtdate,nextdate->enddate); -*/ - if ( c == '\0') return; - while( (c = *++argv) == ';' || c == ' ' || c == '\t' || c =='\n'); - } -} - - - - - -getnumericrev() -/* function: get the numeric name of revisions which stored in revlist */ -/* and then stored the numeric names in Revlst */ -/* if branchflag, also add default branch */ - -{ - struct Revpairs * ptr, *pt; - int flag; - char *temprev; - - /* free the previous numeric revision list */ - pt = Revlst; - while( pt) { - ptr = pt->rnext; - free((char *)pt); - pt = ptr; - } - Nextdotstring = &Dotstring[0]; /* reset buffer */ - - - Revlst = nil; - ptr = revlist; - while( ptr ) { - pt = (struct Revpairs *) talloc(sizeof(struct Revpairs)); - if ( ptr->numfld == 1 ){ /* case: -r rev */ - if ( (flag = expandsym(ptr->strtrev, Nextdotstring)) == true ) { - pt->numfld = countnumflds(Nextdotstring); - pt->strtrev = pt->endrev = Nextdotstring; - while( *Nextdotstring++ != '\0' ) ; - } - } - else if( ptr->numfld == 2){ /* case: -r rev- */ - if ( (flag = expandsym(ptr->strtrev, Nextdotstring)) == true) { - pt->numfld = countnumflds(Nextdotstring); - pt->strtrev = Nextdotstring; - while( *Nextdotstring++ != '\0' ) ; - pt->endrev = Nextdotstring; - if ( pt->numfld > 2) choptail(pt->strtrev); - * Nextdotstring++ = '\0'; - } - } - else if(ptr->numfld == 3) { /* case: -r -rev */ - if ( (flag = expandsym(ptr->endrev, Nextdotstring)) == true) { - pt->endrev = Nextdotstring; - while( *Nextdotstring++ != '\0' ) ; - pt->numfld = countnumflds(pt->endrev); - pt->strtrev = Nextdotstring; - if ( pt->numfld == 2) - *Nextdotstring++ = '1'; - else - choptail(pt->endrev); - *Nextdotstring++ = '.'; - *Nextdotstring++ = '1'; - *Nextdotstring++ = '\0'; - } - } - else { /* case: -r rev1-rev2 */ - if ( (flag = expandsym(ptr->strtrev, Nextdotstring)) == true ) { - pt->strtrev = Nextdotstring; - while( *Nextdotstring++ != '\0' ) ; - if ( ( flag = expandsym(ptr->endrev, Nextdotstring)) == true) { - pt->numfld = countnumflds(pt->strtrev); - pt->endrev = Nextdotstring; - while( *Nextdotstring++ != '\0' ) ; - if((flag = checkrevpair(pt->strtrev, pt->endrev)) == true) - /* switch pt->strtrev with pt->endrev, if pt->strtrev > pt->endre */ - if (compartial(pt->strtrev, pt->endrev, pt->numfld) > 0 ) { - temprev = pt->strtrev; - pt->strtrev = pt->endrev; - pt->endrev = temprev; - } - } - } - } - - if ( flag ){ - pt->rnext = Revlst; - Revlst = pt; - } - else - free((char *)pt); - ptr = ptr->rnext; - } - /* Now take care of branchflag */ - if (branchflag) { - flag =true; - pt = (struct Revpairs *) talloc(sizeof(struct Revpairs)); - if (Dbranch) { - pt->strtrev = pt->endrev = Dbranch->num; - } elsif (Head!=nil) { - pt->strtrev = pt->endrev = /* branch number of head */ - partialno(Nextdotstring,Head->num,1); - while( *Nextdotstring++ != '\0' ) ; - } else flag = false; - if (flag) { /* prepend new node */ - pt->rnext=Revlst; Revlst=pt; - pt->numfld = countnumflds(pt->strtrev); - } - } - -} - - - -checkrevpair(num1,num2) -char *num1, *num2; -/* function: check whether num1, num2 are legal pair,i.e. - only the last field are different and have same number of - feilds( if length <= 2, may be different if first field) */ - -{ - int length; - - if ( (length = countnumflds(num1)) != countnumflds(num2) ) { - error(" Invalid branch or revision pair %s : %s", num1, num2); - return false; - } - if ( length > 2 ) - if (compartial(num1, num2, length-1) != 0) { - error("Invalid branch or revision pair %s : %s", num1, num2); - return false; - } - - return true; -} - - - -getrevpairs(argv) -register char * argv; -/* function: get revision or branch range from command line, and */ -/* store in revlist */ - -{ - register char c; - struct Revpairs * nextrevpair; - int flag; - - argv--; - while( ( c = (*++argv)) == ',' || c == ' ' || c == '\t' || - c == '\n' || c == ';') ; - if ( c == '\0' ) { - warn(" Missing revision or branch number after -r"); - return; - } - - while( c != '\0') { - while( c == ',' || c == ' ' || c == '\t' || - c == '\n' || c == ';') c = *++argv; - if (c == '\0') return; - nextrevpair = (struct Revpairs *) talloc(sizeof(struct Revpairs)); - nextrevpair->rnext = revlist; - revlist = nextrevpair; - nextrevpair->numfld = nil; - nextrevpair->strtrev = nil; - nextrevpair->endrev = nil; - flag = false; - if ( c == '<' || c == '-' ) { /* case: -r -rev or -r <rev */ - flag = true; - while( (c =(*++argv)) == ' ' || c == '\t' || c =='\n') ; - } - else { - nextrevpair->strtrev = argv; - /* get a revision or branch name */ - while( c != ',' && c != ';' && c != ' ' && c != '\0' && c != '-' - && c != '\t' && c != '\n' && c != '<') c = *++argv; - - *argv = '\0'; - - if ( c != '<' && c != '-') { /* case: rev */ - nextrevpair->numfld = 1; - continue; - } - - if ( (c =(*++argv)) == ',' || c == '\0' || c == ' ' - || c == '\t' || c == '\n' || c == ';') {/* case: rev_ */ - nextrevpair->numfld = 2; - continue; - } - } - nextrevpair->endrev = argv; - while( c != ',' && c != ' ' && c != '\0' && c != '\t' && c != '<' - && c != '\n' && c != '-' && c != ';') c = *++argv; - - * argv = '\0'; - if ( c == '<'){ - error("separator expected near %s", nextrevpair->endrev); - while( (c = *++argv) != ',' && c != ' ' && c != '\0' && - c != '\t' && c != '\n' && c != ';' ) ; - revlist = nextrevpair->rnext; - continue; - } - else { - if (flag) /* case: -rev */ - nextrevpair->numfld = 3; - - else /* rev1-rev2 appears */ - nextrevpair->numfld = 4; - } - } -} - - - -choptail(strhead) -char * strhead; -/* function : chop off the last field of a branch or a revision number */ - -{ - char *pt, *sp; - - for(pt = Nextdotstring-1; pt != strhead && *pt != '.'; pt--) ; - for(sp = strhead; sp < pt; sp++) *Nextdotstring++ = *sp; -} - diff --git a/usr.bin/rcs/src/sccstorcs.c b/usr.bin/rcs/src/sccstorcs.c deleted file mode 100644 index 24498ab71cd5..000000000000 --- a/usr.bin/rcs/src/sccstorcs.c +++ /dev/null @@ -1,450 +0,0 @@ -static char *RCSid = -"$Header: /cvsroot/src/usr.bin/rcs/src/Attic/sccstorcs.c,v 1.2 1993/04/21 08:48:48 mycroft Exp $"; - -/* - * SCCSTORCS - build RCS file from SCCS file preserving deltas. - * Author: Ken Greer - * - * Copyright (c) 1983 by Kenneth L. Greer - * - * All rights reserved. No part of this software may be sold or distributed - * in any form or by any means without the prior written permission of the - * author. - * - * $Log: sccstorcs.c,v $ - * Revision 1.2 1993/04/21 08:48:48 mycroft - * Use ANSI vfprintf() rather than outdated _doprnt(). - * - * Revision 1.1.1.1 1993/03/21 09:58:11 cgd - * initial import of 386bsd-0.1 sources - * - * Revision 1.4 84/10/17 21:12:11 root - * Added check for having multiple deltas in a row for the same revision. - * --ks - * - * Revision 1.3 84/10/17 20:53:18 root - * Put in SCCS string in comment for telling who checked it in.. - * --ks - * - * Revision 1.2 84/10/17 12:22:14 root - * Fixed the case when a delta was removed. - * Also, use -f on checkin so comments are kept even if the file - * didn't change between deltas. - * --ks - * - * Revision 1.1 84/10/07 14:59:47 root - * Initial revision - * - * Revision 1.2 83/03/27 11:21:17 root - * Returns non-zero exit codes on soft errors also. - * - * Revision 1.1 83/03/24 14:33:24 root - * Initial revision - * - */ - -#include <stdio.h> - -#define TRUE 1 -#define FALSE 0 -#define SOH 001 /* SCCS lines start with SOH (Control-A) */ -#define RCS "rcs -q" -#define GET "get -s" -#define CI "ci -q -f" - -#define prefix(a, b) (strncmp(a, b, strlen(a)) == 0) -#define null(str) ((str) == NULL ? "<null>\n" : (str)) - -int - trace = FALSE, /* just show what would be done, don't run commands */ - verbose = FALSE; /* Print commands before executing */ - -typedef struct delta -{ - char *revision; - char *commentary; - struct delta *next; -} DELTA; - -typedef struct userlist -{ - char *user; - struct userlist *next; -} USERLIST; - -typedef struct header -{ - DELTA *deltas; - USERLIST *userlist; - char *description; -} HEADER; - - -quit (fmt, args) -char *fmt; -{ - fprintf (stderr, "sccstorcs: "); - vfprintf(stderr, fmt, &args); - exit (1); -} - -char * -xalloc (size) -unsigned size; -{ - extern char *malloc (); - char *p; - if ((p = malloc (size)) == NULL) - quit ("Out of Memory.\n"); - return (p); -} - -/* - * Allocate space for string and copy str to it. - */ -char * -string (str) -char *str; -{ - register char *p = xalloc ((unsigned) (strlen (str) + 1)); - strcpy (p, str); - return (p); -} - -/* - * Return pointer to the final file name in a path. - * I.e. sname ("/foo/baz/mumble") returns a pointer to "mumble". - */ -char * -sname (s) -register char *s; -{ - register char *p; - - for (p = s; *p;) - if (*p++ == '/') - s = p; - return (s); -} - -DELTA * -new_delta (line) -char *line; -{ - register DELTA *delta; - char rev[32]; - - sscanf (line, "%*s %*s %s", rev); - delta = (DELTA *) xalloc (sizeof (DELTA)); - delta -> revision = string (rev); - delta -> commentary = NULL; - return (delta); -} - -char * -concat (old_str, str) -char *old_str, *str; -{ - register int len; - register char *newstring; - - if (old_str == NULL) - return (string (str)); - - len = strlen (old_str) + strlen (str); - newstring = (char *) xalloc ((unsigned) (len + 1)); - strcpy (newstring, old_str); - strcat (newstring, str); - free (old_str); - return (newstring); -} - -trimtail (line) -char *line; -{ - register char *p = line; - while (*p) p++; - while (p > line && p[-1] <= ' ') - p--; - *p = '\0'; -} - -USERLIST * -collect_userlist (fd) -FILE *fd; -{ - char line[128]; - USERLIST *userlist = NULL, *newuser; - while (fgets (line, sizeof line, fd)) - { - if (line[0] == SOH && line[1] == 'U') /* End of userlist */ - break; - trimtail (line); - newuser = (USERLIST *) xalloc (sizeof (USERLIST)); - newuser -> user = string (line); - newuser -> next = userlist; - userlist = newuser; - } - return (userlist); -} - -HEADER * -collect_header (fd) -FILE *fd; -{ - DELTA *head = NULL, *delta; - USERLIST *userlist = NULL; - static HEADER header; - char line[512], *description = NULL; - while (fgets (line, sizeof line, fd)) - { - if (line[0] != SOH) - continue; - if (line[1] == 'I') /* The first INCLUDE */ - break; - switch (line[1]) - { - case 'd': /* New delta */ -#ifdef PURDUE_EE - if (line[3] == 'R') - while (fgets (line, sizeof line, fd)) - if (line[0] == SOH && line[1] == 'd' && line[3] != 'R') - break; -#endif - delta = new_delta (line); -#ifdef PURDUE_EE - if (!head || strcmp(delta -> revision, head -> revision)) { -#endif - delta -> next = head; - head = delta; -#ifdef PURDUE_EE - } -#endif -#ifndef PURDUE_EE - break; -#endif - case 'c': /* Commentary */ - delta -> commentary = concat (delta -> commentary, &line[3]); - break; - case 'u': - userlist = collect_userlist (fd); - break; - case 't': - while (fgets (line, sizeof line, fd) && !prefix("\1T", line)) - description = concat (description, line); - } - } - header.userlist = userlist; - header.deltas = head; - header.description = description; - return (&header); -} - -/* - * Convert SCCS file to RCS file - */ -HEADER * -read_sccs (sccsfile) -char *sccsfile; -{ - HEADER *header; - FILE *fd; - if (strncmp (sname (sccsfile), "s.", 2) != 0) /* An SCCS file? */ - { - fprintf (stderr, "%s: not an SCCS file.\n", sccsfile); - return (NULL); - } - if ((fd = fopen (sccsfile, "r")) == NULL) - { - fprintf (stderr, "%s: cannot open.\n", sccsfile); - return (NULL); - } - header = collect_header (fd); - fclose (fd); - return (header); -} - -install_userlist (userlist, rcsfile) -register USERLIST *userlist; -char *rcsfile; -{ - char command[512]; - int count; - if (userlist == NULL) - return (0); - sprintf (command, "%s -a", RCS); - for (count = 0; userlist; userlist = userlist -> next, count++) - { - if (count > 0) - strcat (command, ","); - strcat (command, userlist -> user); - } - strcat (command, " "); - strcat (command, rcsfile); - if (trace || verbose) - printf ("%% %s\n", command); - if (trace) - return (0); - return (system (command)); -} - -initialize_rcsfile (description, rcsfile) -char *description, *rcsfile; -{ - char command[512]; - extern FILE *popen(); - FILE *pd; - - sprintf (command, "%s -i -U %s", RCS, rcsfile); - if (trace || verbose) - printf ("%% %s\n", command); - if (trace) - { - printf ("Description:\n%s\n", null(description)); - return (0); - } - if ((pd = popen (command, "w")) == NULL) - return (-1); - fprintf (pd, "%s", description ? description : "\n"); - return (pclose (pd)); -} - -install_deltas (delta, sccsfile, rcsfile) -register DELTA *delta; -char *sccsfile, *rcsfile; -{ - char command[512]; - for (; delta; delta = delta -> next) - { - /* - * Get the SCCS file. - */ - sprintf (command, "%s -p -r%s %s > %s", - GET, delta -> revision, sccsfile, rcsfile); - if (trace || verbose) - printf("%% %s\n", command); - if (!trace) - { - if (system (command)) - return (-1); - } - - sprintf (command, "%s -r%s %s", CI, delta -> revision, rcsfile); - if (trace || verbose) - printf("%% %s\n", command); - if (trace) - printf("Commentary:\n%s\n", null(delta -> commentary)); - else - { - extern FILE *popen (); - FILE *pd; - int x; - if ((pd = popen (command, "w")) == NULL) - return (-1); - if (delta -> commentary) - fprintf (pd, delta -> commentary); - if ((x = pclose (pd)) != 0) - return (x); - } - } - return (0); -} - -finalize_rcsfile (rcsfile) -char *rcsfile; -{ - char command[512]; - sprintf (command, "%s -L %s", RCS, rcsfile); - if (trace || verbose) - printf ("%% %s\n", command); - if (trace) - return (0); - return (system (command)); -} - -build_new_rcs_file (header, sccsfile) -HEADER *header; -char *sccsfile; -{ - char *rcsfile = &(sname (sccsfile))[2]; - - if (initialize_rcsfile (header -> description, rcsfile)) - quit ("Error initializing new rcs file %s\n", rcsfile); - - if (install_userlist (header -> userlist, rcsfile)) - quit ("Error installing user access list to rcs file %s\n", rcsfile); - - if (install_deltas (header -> deltas, sccsfile, rcsfile)) - quit ("Error installing delta to rcs file %s\n", rcsfile); - - if (finalize_rcsfile (rcsfile)) - quit ("Error setting defaults to rcs file %s\n", rcsfile); -} - -print_header (sccsfile, header) -char *sccsfile; -register HEADER *header; -{ - register DELTA *d; - register USERLIST *u; - - printf ("\n%s:\n", sccsfile); - printf ("------------------------------------------------------------\n"); - if (header -> description) - printf ("Descriptive text:\n%s", header -> description); - - if (header -> userlist) - { - printf ("\nUser access list:\n"); - for (u = header -> userlist; u; u = u -> next) - printf ("%s\n", u -> user); - } - - for (d = header -> deltas; d; d = d -> next) - { - printf ("\nRelease: %s\n", d -> revision); - printf ("Commentary:\n%s", d -> commentary); - } - printf ("------------------------------------------------------------\n"); -} - -main (argc, argv) -char **argv; -{ - int errors = 0; - - for (; argc > 1 && argv[1][0] == '-'; argc--, argv++) - { - switch (argv[1][1]) - { - case 'v': - verbose = TRUE; - break; - case 't': - trace = TRUE; - break; - default: - fprintf (stderr, "Unknown switch \"%s\".\n", argv[1]); - exit (1); - } - } - - if (argc <= 1) - quit ("Usage: sccstorcs [-t -v] s.file ...\n"); - - for (; argc > 1; argc--, argv++) - { - HEADER *header; - char *sccsfile; - sccsfile = argv[1]; - if ((header = read_sccs (sccsfile)) != NULL) - { - if (trace) - print_header (sccsfile, header); - build_new_rcs_file (header, sccsfile); - } - else - errors++; - } - exit (errors); -} diff --git a/usr.bin/rcs/src/snoop.c b/usr.bin/rcs/src/snoop.c deleted file mode 100644 index 8105eae5ac43..000000000000 --- a/usr.bin/rcs/src/snoop.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Logging of RCS commands co and ci - */ -#ifndef lint - static char rcsid[]= - "$Header: /cvsroot/src/usr.bin/rcs/src/Attic/snoop.c,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $ Purdue CS"; -#endif -/******************************************************************* - * This program appends argv[1] to the file SNOOPFILE. - * To avoid overlaps, it creates a lockfile with name lock in the same - * directory as SNOOPFILE. SNOOPFILE must be defined in the cc command. - * Prints an error message if lockfile doesn't get deleted after - * MAXTRIES tries. - ******************************************************************* - */ - -/* Copyright (C) 1982, 1988, 1989 Walter Tichy - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by Walter Tichy. - * 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. - * - * Report all problems and direct all questions to: - * rcs-bugs@cs.purdue.edu - * - - - - - - - -*/ - - -/* $Log: snoop.c,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 4.4 89/05/01 15:14:00 narten - * changed copyright header to reflect current distribution rules - * - * Revision 4.3 87/12/18 11:46:52 narten - * more lint cleanups (Guy Harris) - * - * Revision 4.2 87/10/18 10:41:47 narten - * Changing version numbers. Changes relative to 1.1 actually relative to - * 4.1 - * - * Revision 1.2 87/09/24 14:01:41 narten - * Sources now pass through lint (if you ignore printf/sprintf/fprintf - * warnings) - * - * Revision 1.1 84/01/23 14:50:49 kcs - * Initial revision - * - * Revision 4.1 83/03/28 13:23:42 wft - * No change; just new revision number. - * - * Revision 3.2 82/12/04 17:14:31 wft - * Added rcsbase.h, changed SNOOPDIR to SNOOPFILE, reintroduced - * error message in case of permanent locking. - * - * Revision 3.1 82/10/18 21:22:03 wft - * Number of polls now 20, no error message if critical section can't - * be entered. - * - * Revision 2.3 82/07/01 23:49:28 wft - * changed copyright notice only. - * - * Revision 2.2 82/06/03 20:00:10 wft - * changed name from rcslog to snoop, replaced LOGDIR with SNOOPDIR. - * - * Revision 2.1 82/05/06 17:55:54 wft - * Initial revision - * - */ - - -#include "rcsbase.h" -#ifdef _FSTDIO -#undef putc -#define putc __sputc -#define fflsbuf _flsbuf -#endif -/* undo redefinition of putc in rcsbase.h */ - -char lockfname[NCPPN]; -FILE * logfile; -int lockfile; - -#define MAXTRIES 20 - -main(argc,argv) -int argc; char * argv[]; -/* writes argv[1] to SNOOPFILE and appends a newline. Invoked as follows: - * rcslog logmessage - */ -{ int tries; - register char * lastslash, *sp; - - VOID strcpy(lockfname,(char *) SNOOPFILE); - lastslash = sp = lockfname; - while (*sp) if (*sp++ =='/') lastslash=sp; /* points beyond / */ - VOID strcpy(lastslash,",lockfile"); - tries=0; - while (((lockfile=creat(lockfname, 000)) == -1) && (tries<=MAXTRIES)) { - tries++; - sleep(5); - } - if (tries<=MAXTRIES) { - VOID close(lockfile); - if ((logfile=fopen(SNOOPFILE,"a")) ==NULL) { - VOID fprintf(stderr,"Can't open logfile %s\n",SNOOPFILE); - } else { - VOID fputs(argv[1],logfile); - VOID putc('\n',logfile); - VOID fclose(logfile); - } - VOID unlink(lockfname); - } else { - VOID fprintf(stderr,"RCS logfile %s seems permanently locked.\n",SNOOPFILE); - VOID fprintf(stderr,"Please alert system administrator\n"); - } -} diff --git a/usr.bin/rcs/src/time.h b/usr.bin/rcs/src/time.h deleted file mode 100644 index 41641e5e4efb..000000000000 --- a/usr.bin/rcs/src/time.h +++ /dev/null @@ -1,55 +0,0 @@ - -/* Structure for use by time manipulating subroutines. - * The following library routines use it: - * libc: ctime, localtime, gmtime, asctime - * libcx: partime, maketime (may not be installed yet) - */ - -#define TIMEID "$Id: time.h,v 1.1.1.1 1993/03/21 09:45:37 cgd Exp $" - -/* $Log: time.h,v $ -/* Revision 1.1.1.1 1993/03/21 09:45:37 cgd -/* initial import of 386bsd-0.1 sources -/* - * Revision 1.1 84/01/23 14:50:50 kcs - * Initial revision - * - * Revision 1.1 82/05/06 11:34:29 wft - * Initial revision - * - */ - -struct tm { /* See defines below for allowable ranges */ - 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; - int tm_zon; /* NEW: mins westward of Greenwich */ - int tm_ampm; /* NEW: 1 if AM, 2 if PM */ -}; - -#define LCLZONE (5*60) /* Until V7 ftime(2) works, this defines local zone*/ -#define TMNULL (-1) /* Items not specified are given this value - * in order to distinguish null specs from zero - * specs. This is only used by partime and - * maketime. */ - - /* Indices into TM structure */ -#define TM_SEC 0 /* 0-59 */ -#define TM_MIN 1 /* 0-59 */ -#define TM_HOUR 2 /* 0-23 */ -#define TM_MDAY 3 /* 1-31 day of month */ -#define TM_DAY TM_MDAY /* " synonym */ -#define TM_MON 4 /* 0-11 */ -#define TM_YEAR 5 /* (year-1900) (year) */ -#define TM_WDAY 6 /* 0-6 day of week (0 = Sunday) */ -#define TM_YDAY 7 /* 0-365 day of year */ -#define TM_ISDST 8 /* 0 Std, 1 DST */ - /* New stuff */ -#define TM_ZON 9 /* 0-(24*60) minutes west of Greenwich */ -#define TM_AMPM 10 /* 1 AM, 2 PM */ diff --git a/usr.bin/sed/Makefile.bsd b/usr.bin/sed/Makefile.bsd deleted file mode 100644 index 5b116636bd91..000000000000 --- a/usr.bin/sed/Makefile.bsd +++ /dev/null @@ -1,10 +0,0 @@ - -PROG= sed -SRCS= sed.c utils.c regex.c getopt.c getopt1.c -CFLAGS+=-I${.CURDIR} # -DSTDC_HEADERS -NOMAN=noman - -sed.o regex.o: regex.h -sed.o getopt1.o: getopt.h - -.include <bsd.prog.mk> diff --git a/usr.bin/sed/getopt.h b/usr.bin/sed/getopt.h deleted file mode 100644 index 151379fc69d2..000000000000 --- a/usr.bin/sed/getopt.h +++ /dev/null @@ -1,102 +0,0 @@ -/* 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/usr.bin/sed/getopt1.c b/usr.bin/sed/getopt1.c deleted file mode 100644 index 781673c6f210..000000000000 --- a/usr.bin/sed/getopt1.c +++ /dev/null @@ -1,158 +0,0 @@ -/* 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" - -#ifndef __STDC__ -#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 <stdio.h> - -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/usr.bin/sed/regex.c b/usr.bin/sed/regex.c deleted file mode 100644 index a24d05cec870..000000000000 --- a/usr.bin/sed/regex.c +++ /dev/null @@ -1,2781 +0,0 @@ -/* Extended regular expression matching and search 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. */ - - -/* To test, compile with -Dtest. This Dtestable feature turns this into - a self-contained program which reads a pattern, describes how it - compiles, then reads a string and searches for it. - - On the other hand, if you compile with both -Dtest and -Dcanned you - can run some tests we've already thought of. */ - -/* AIX requires the alloca decl to be the first thing in the file. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#ifdef sparc -#include <alloca.h> -#else -#ifdef _AIX -#pragma alloca -#else -char *alloca (); -#endif -#endif -#endif - -#ifdef emacs - -/* The `emacs' switch turns on certain special matching commands - that make sense only in emacs. */ - -#include "config.h" -#include "lisp.h" -#include "buffer.h" -#include "syntax.h" - -#else /* not emacs */ - -#if defined (USG) || defined (STDC_HEADERS) -#ifndef BSTRING -#include <string.h> -#define bcopy(s,d,n) memcpy((d),(s),(n)) -#define bcmp(s1,s2,n) memcmp((s1),(s2),(n)) -#define bzero(s,n) memset((s),0,(n)) -#endif -#endif - -#ifdef STDC_HEADERS -#include <stdlib.h> -#else -char *malloc (); -char *realloc (); -#endif - -/* Define the syntax stuff, so we can do the \<, \>, etc. */ - -/* This must be nonzero for the wordchar and notwordchar pattern - commands in re_match_2. */ -#ifndef Sword -#define Sword 1 -#endif - -#define SYNTAX(c) re_syntax_table[c] - - -#ifdef SYNTAX_TABLE - -char *re_syntax_table; - -#else /* not SYNTAX_TABLE */ - -static char re_syntax_table[256]; - - -static void -init_syntax_once () -{ - register int c; - static int done = 0; - - if (done) - return; - - bzero (re_syntax_table, sizeof re_syntax_table); - - for (c = 'a'; c <= 'z'; c++) - re_syntax_table[c] = Sword; - - for (c = 'A'; c <= 'Z'; c++) - re_syntax_table[c] = Sword; - - for (c = '0'; c <= '9'; c++) - re_syntax_table[c] = Sword; - - done = 1; -} - -#endif /* SYNTAX_TABLE */ -#endif /* emacs */ - -/* We write fatal error messages on standard error. */ -#include <stdio.h> - -/* isalpha(3) etc. are used for the character classes. */ -#include <ctype.h> -/* Sequents are missing isgraph. */ -#ifndef isgraph -#define isgraph(c) (isprint((c)) && !isspace((c))) -#endif - -/* Get the interface, including the syntax bits. */ -#include "regex.h" - - -/* These are the command codes that appear in compiled regular - expressions, one per byte. Some command codes are followed by - argument bytes. A command code can specify any interpretation - whatsoever for its arguments. Zero-bytes may appear in the compiled - regular expression. - - The value of `exactn' is needed in search.c (search_buffer) in emacs. - So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of - `exactn' we use here must also be 1. */ - -enum regexpcode - { - unused=0, - exactn=1, /* Followed by one byte giving n, then by n literal bytes. */ - begline, /* Fail unless at beginning of line. */ - endline, /* Fail unless at end of line. */ - jump, /* Followed by two bytes giving relative address to jump to. */ - on_failure_jump, /* Followed by two bytes giving relative address of - place to resume at in case of failure. */ - finalize_jump, /* Throw away latest failure point and then jump to - address. */ - maybe_finalize_jump, /* Like jump but finalize if safe to do so. - This is used to jump back to the beginning - of a repeat. If the command that follows - this jump is clearly incompatible with the - one at the beginning of the repeat, such that - we can be sure that there is no use backtracking - out of repetitions already completed, - then we finalize. */ - dummy_failure_jump, /* Jump, and push a dummy failure point. This - failure point will be thrown away if an attempt - is made to use it for a failure. A + construct - makes this before the first repeat. Also - use it as an intermediary kind of jump when - compiling an or construct. */ - succeed_n, /* Used like on_failure_jump except has to succeed n times; - then gets turned into an on_failure_jump. The relative - address following it is useless until then. The - address is followed by two bytes containing n. */ - jump_n, /* Similar to jump, but jump n times only; also the relative - address following is in turn followed by yet two more bytes - containing n. */ - set_number_at, /* Set the following relative location to the - subsequent number. */ - anychar, /* Matches any (more or less) one character. */ - charset, /* Matches any one char belonging to specified set. - First following byte is number of bitmap bytes. - Then come bytes for a bitmap saying which chars are in. - Bits in each byte are ordered low-bit-first. - A character is in the set if its bit is 1. - A character too large to have a bit in the map - is automatically not in the set. */ - charset_not, /* Same parameters as charset, but match any character - that is not one of those specified. */ - start_memory, /* Start remembering the text that is matched, for - storing in a memory register. Followed by one - byte containing the register number. Register numbers - must be in the range 0 through RE_NREGS. */ - stop_memory, /* Stop remembering the text that is matched - and store it in a memory register. Followed by - one byte containing the register number. Register - numbers must be in the range 0 through RE_NREGS. */ - duplicate, /* Match a duplicate of something remembered. - Followed by one byte containing the index of the memory - register. */ - before_dot, /* Succeeds if before point. */ - at_dot, /* Succeeds if at point. */ - after_dot, /* Succeeds if after point. */ - begbuf, /* Succeeds if at beginning of buffer. */ - endbuf, /* Succeeds if at end of buffer. */ - wordchar, /* Matches any word-constituent character. */ - notwordchar, /* Matches any char that is not a word-constituent. */ - wordbeg, /* Succeeds if at word beginning. */ - wordend, /* Succeeds if at word end. */ - wordbound, /* Succeeds if at a word boundary. */ - notwordbound,/* Succeeds if not at a word boundary. */ - syntaxspec, /* Matches any character whose syntax is specified. - followed by a byte which contains a syntax code, - e.g., Sword. */ - notsyntaxspec /* Matches any character whose syntax differs from - that specified. */ - }; - - -/* Number of failure points to allocate space for initially, - when matching. If this number is exceeded, more space is allocated, - so it is not a hard limit. */ - -#ifndef NFAILURES -#define NFAILURES 80 -#endif - -#ifdef CHAR_UNSIGNED -#define SIGN_EXTEND_CHAR(c) ((c)>(char)127?(c)-256:(c)) /* for IBM RT */ -#endif -#ifndef SIGN_EXTEND_CHAR -#define SIGN_EXTEND_CHAR(x) (x) -#endif - - -/* Store NUMBER in two contiguous bytes starting at DESTINATION. */ -#define STORE_NUMBER(destination, number) \ - { (destination)[0] = (number) & 0377; \ - (destination)[1] = (number) >> 8; } - -/* Same as STORE_NUMBER, except increment the destination pointer to - the byte after where the number is stored. Watch out that values for - DESTINATION such as p + 1 won't work, whereas p will. */ -#define STORE_NUMBER_AND_INCR(destination, number) \ - { STORE_NUMBER(destination, number); \ - (destination) += 2; } - - -/* Put into DESTINATION a number stored in two contingous bytes starting - at SOURCE. */ -#define EXTRACT_NUMBER(destination, source) \ - { (destination) = *(source) & 0377; \ - (destination) += SIGN_EXTEND_CHAR (*(char *)((source) + 1)) << 8; } - -/* Same as EXTRACT_NUMBER, except increment the pointer for source to - point to second byte of SOURCE. Note that SOURCE has to be a value - such as p, not, e.g., p + 1. */ -#define EXTRACT_NUMBER_AND_INCR(destination, source) \ - { EXTRACT_NUMBER (destination, source); \ - (source) += 2; } - - -/* Specify the precise syntax of regexps for compilation. This provides - for compatibility for various utilities which historically have - different, incompatible syntaxes. - - The argument SYNTAX is a bit-mask comprised of the various bits - defined in regex.h. */ - -int -re_set_syntax (syntax) - int syntax; -{ - int ret; - - ret = obscure_syntax; - obscure_syntax = syntax; - return ret; -} - -/* Set by re_set_syntax to the current regexp syntax to recognize. */ -int obscure_syntax = 0; - - - -/* Macros for re_compile_pattern, which is found below these definitions. */ - -#define CHAR_CLASS_MAX_LENGTH 6 - -/* Fetch the next character in the uncompiled pattern, translating it if - necessary. */ -#define PATFETCH(c) \ - {if (p == pend) goto end_of_pattern; \ - c = * (unsigned char *) p++; \ - if (translate) c = translate[c]; } - -/* Fetch the next character in the uncompiled pattern, with no - translation. */ -#define PATFETCH_RAW(c) \ - {if (p == pend) goto end_of_pattern; \ - c = * (unsigned char *) p++; } - -#define PATUNFETCH p-- - - -/* If the buffer isn't allocated when it comes in, use this. */ -#define INIT_BUF_SIZE 28 - -/* Make sure we have at least N more bytes of space in buffer. */ -#define GET_BUFFER_SPACE(n) \ - { \ - while (b - bufp->buffer + (n) >= bufp->allocated) \ - EXTEND_BUFFER; \ - } - -/* Make sure we have one more byte of buffer space and then add CH to it. */ -#define BUFPUSH(ch) \ - { \ - GET_BUFFER_SPACE (1); \ - *b++ = (char) (ch); \ - } - -/* Extend the buffer by twice its current size via reallociation and - reset the pointers that pointed into the old allocation to point to - the correct places in the new allocation. If extending the buffer - results in it being larger than 1 << 16, then flag memory exhausted. */ -#define EXTEND_BUFFER \ - { char *old_buffer = bufp->buffer; \ - if (bufp->allocated == (1L<<16)) goto too_big; \ - bufp->allocated *= 2; \ - if (bufp->allocated > (1L<<16)) bufp->allocated = (1L<<16); \ - bufp->buffer = (char *) realloc (bufp->buffer, bufp->allocated); \ - if (bufp->buffer == 0) \ - goto memory_exhausted; \ - b = (b - old_buffer) + bufp->buffer; \ - if (fixup_jump) \ - fixup_jump = (fixup_jump - old_buffer) + bufp->buffer; \ - if (laststart) \ - laststart = (laststart - old_buffer) + bufp->buffer; \ - begalt = (begalt - old_buffer) + bufp->buffer; \ - if (pending_exact) \ - pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ - } - -/* Set the bit for character C in a character set list. */ -#define SET_LIST_BIT(c) (b[(c) / BYTEWIDTH] |= 1 << ((c) % BYTEWIDTH)) - -/* Get the next unsigned number in the uncompiled pattern. */ -#define GET_UNSIGNED_NUMBER(num) \ - { if (p != pend) \ - { \ - PATFETCH (c); \ - while (isdigit (c)) \ - { \ - if (num < 0) \ - num = 0; \ - num = num * 10 + c - '0'; \ - if (p == pend) \ - break; \ - PATFETCH (c); \ - } \ - } \ - } - -/* Subroutines for re_compile_pattern. */ -static void store_jump (), insert_jump (), store_jump_n (), - insert_jump_n (), insert_op_2 (); - - -/* re_compile_pattern takes a regular-expression string - and converts it into a buffer full of byte commands for matching. - - PATTERN is the address of the pattern string - SIZE is the length of it. - BUFP is a struct re_pattern_buffer * which points to the info - on where to store the byte commands. - This structure contains a char * which points to the - actual space, which should have been obtained with malloc. - re_compile_pattern may use realloc to grow the buffer space. - - The number of bytes of commands can be found out by looking in - the `struct re_pattern_buffer' that bufp pointed to, after - re_compile_pattern returns. */ - -char * -re_compile_pattern (pattern, size, bufp) - char *pattern; - int size; - struct re_pattern_buffer *bufp; -{ - register char *b = bufp->buffer; - register char *p = pattern; - char *pend = pattern + size; - register unsigned c, c1; - char *p1; - unsigned char *translate = (unsigned char *) bufp->translate; - - /* Address of the count-byte of the most recently inserted `exactn' - command. This makes it possible to tell whether a new exact-match - character can be added to that command or requires a new `exactn' - command. */ - - char *pending_exact = 0; - - /* Address of the place where a forward-jump should go to the end of - the containing expression. Each alternative of an `or', except the - last, ends with a forward-jump of this sort. */ - - char *fixup_jump = 0; - - /* Address of start of the most recently finished expression. - This tells postfix * where to find the start of its operand. */ - - char *laststart = 0; - - /* In processing a repeat, 1 means zero matches is allowed. */ - - char zero_times_ok; - - /* In processing a repeat, 1 means many matches is allowed. */ - - char many_times_ok; - - /* Address of beginning of regexp, or inside of last \(. */ - - char *begalt = b; - - /* In processing an interval, at least this many matches must be made. */ - int lower_bound; - - /* In processing an interval, at most this many matches can be made. */ - int upper_bound; - - /* Place in pattern (i.e., the {) to which to go back if the interval - is invalid. */ - char *beg_interval = 0; - - /* Stack of information saved by \( and restored by \). - Four stack elements are pushed by each \(: - First, the value of b. - Second, the value of fixup_jump. - Third, the value of regnum. - Fourth, the value of begalt. */ - - int stackb[40]; - int *stackp = stackb; - int *stacke = stackb + 40; - int *stackt; - - /* Counts \('s as they are encountered. Remembered for the matching \), - where it becomes the register number to put in the stop_memory - command. */ - - int regnum = 1; - - bufp->fastmap_accurate = 0; - -#ifndef emacs -#ifndef SYNTAX_TABLE - /* Initialize the syntax table. */ - init_syntax_once(); -#endif -#endif - - if (bufp->allocated == 0) - { - bufp->allocated = INIT_BUF_SIZE; - if (bufp->buffer) - /* EXTEND_BUFFER loses when bufp->allocated is 0. */ - bufp->buffer = (char *) realloc (bufp->buffer, INIT_BUF_SIZE); - else - /* Caller did not allocate a buffer. Do it for them. */ - bufp->buffer = (char *) malloc (INIT_BUF_SIZE); - if (!bufp->buffer) goto memory_exhausted; - begalt = b = bufp->buffer; - } - - while (p != pend) - { - PATFETCH (c); - - switch (c) - { - case '$': - { - char *p1 = p; - /* When testing what follows the $, - look past the \-constructs that don't consume anything. */ - if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - while (p1 != pend) - { - if (*p1 == '\\' && p1 + 1 != pend - && (p1[1] == '<' || p1[1] == '>' - || p1[1] == '`' || p1[1] == '\'' -#ifdef emacs - || p1[1] == '=' -#endif - || p1[1] == 'b' || p1[1] == 'B')) - p1 += 2; - else - break; - } - if (obscure_syntax & RE_TIGHT_VBAR) - { - if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS) && p1 != pend) - goto normal_char; - /* Make operand of last vbar end before this `$'. */ - if (fixup_jump) - store_jump (fixup_jump, jump, b); - fixup_jump = 0; - BUFPUSH (endline); - break; - } - /* $ means succeed if at end of line, but only in special contexts. - If validly in the middle of a pattern, it is a normal character. */ - - if ((obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) && p1 != pend) - goto invalid_pattern; - if (p1 == pend || *p1 == '\n' - || (obscure_syntax & RE_CONTEXT_INDEP_OPS) - || (obscure_syntax & RE_NO_BK_PARENS - ? *p1 == ')' - : *p1 == '\\' && p1[1] == ')') - || (obscure_syntax & RE_NO_BK_VBAR - ? *p1 == '|' - : *p1 == '\\' && p1[1] == '|')) - { - BUFPUSH (endline); - break; - } - goto normal_char; - } - case '^': - /* ^ means succeed if at beg of line, but only if no preceding - pattern. */ - - if ((obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) && laststart) - goto invalid_pattern; - if (laststart && p - 2 >= pattern && p[-2] != '\n' - && !(obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - if (obscure_syntax & RE_TIGHT_VBAR) - { - if (p != pattern + 1 - && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - BUFPUSH (begline); - begalt = b; - } - else - BUFPUSH (begline); - break; - - case '+': - case '?': - if ((obscure_syntax & RE_BK_PLUS_QM) - || (obscure_syntax & RE_LIMITED_OPS)) - goto normal_char; - handle_plus: - case '*': - /* If there is no previous pattern, char not special. */ - if (!laststart) - { - if (obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) - goto invalid_pattern; - else if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - } - /* If there is a sequence of repetition chars, - collapse it down to just one. */ - zero_times_ok = 0; - many_times_ok = 0; - while (1) - { - zero_times_ok |= c != '+'; - many_times_ok |= c != '?'; - if (p == pend) - break; - PATFETCH (c); - if (c == '*') - ; - else if (!(obscure_syntax & RE_BK_PLUS_QM) - && (c == '+' || c == '?')) - ; - else if ((obscure_syntax & RE_BK_PLUS_QM) - && c == '\\') - { - int c1; - PATFETCH (c1); - if (!(c1 == '+' || c1 == '?')) - { - PATUNFETCH; - PATUNFETCH; - break; - } - c = c1; - } - else - { - PATUNFETCH; - break; - } - } - - /* Star, etc. applied to an empty pattern is equivalent - to an empty pattern. */ - if (!laststart) - break; - - /* Now we know whether or not zero matches is allowed - and also whether or not two or more matches is allowed. */ - if (many_times_ok) - { - /* If more than one repetition is allowed, put in at the - end a backward relative jump from b to before the next - jump we're going to put in below (which jumps from - laststart to after this jump). */ - GET_BUFFER_SPACE (3); - store_jump (b, maybe_finalize_jump, laststart - 3); - b += 3; /* Because store_jump put stuff here. */ - } - /* On failure, jump from laststart to b + 3, which will be the - end of the buffer after this jump is inserted. */ - GET_BUFFER_SPACE (3); - insert_jump (on_failure_jump, laststart, b + 3, b); - pending_exact = 0; - b += 3; - if (!zero_times_ok) - { - /* At least one repetition is required, so insert a - dummy-failure before the initial on-failure-jump - instruction of the loop. This effects a skip over that - instruction the first time we hit that loop. */ - GET_BUFFER_SPACE (6); - insert_jump (dummy_failure_jump, laststart, laststart + 6, b); - b += 3; - } - break; - - case '.': - laststart = b; - BUFPUSH (anychar); - break; - - case '[': - if (p == pend) - goto invalid_pattern; - while (b - bufp->buffer - > bufp->allocated - 3 - (1 << BYTEWIDTH) / BYTEWIDTH) - EXTEND_BUFFER; - - laststart = b; - if (*p == '^') - { - BUFPUSH (charset_not); - p++; - } - else - BUFPUSH (charset); - p1 = p; - - BUFPUSH ((1 << BYTEWIDTH) / BYTEWIDTH); - /* Clear the whole map */ - bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); - - if ((obscure_syntax & RE_HAT_NOT_NEWLINE) && b[-2] == charset_not) - SET_LIST_BIT ('\n'); - - - /* Read in characters and ranges, setting map bits. */ - while (1) - { - /* Don't translate while fetching, in case it's a range bound. - When we set the bit for the character, we translate it. */ - PATFETCH_RAW (c); - - /* If set, \ escapes characters when inside [...]. */ - if ((obscure_syntax & RE_AWK_CLASS_HACK) && c == '\\') - { - PATFETCH(c1); - SET_LIST_BIT (c1); - continue; - } - if (c == ']') - { - if (p == p1 + 1) - { - /* If this is an empty bracket expression. */ - if ((obscure_syntax & RE_NO_EMPTY_BRACKETS) - && p == pend) - goto invalid_pattern; - } - else - /* Stop if this isn't merely a ] inside a bracket - expression, but rather the end of a bracket - expression. */ - break; - } - /* Get a range. */ - if (p[0] == '-' && p[1] != ']') - { - PATFETCH (c1); - /* Don't translate the range bounds while fetching them. */ - PATFETCH_RAW (c1); - - if ((obscure_syntax & RE_NO_EMPTY_RANGES) && c > c1) - goto invalid_pattern; - - if ((obscure_syntax & RE_NO_HYPHEN_RANGE_END) - && c1 == '-' && *p != ']') - goto invalid_pattern; - - while (c <= c1) - { - /* Translate each char that's in the range. */ - if (translate) - SET_LIST_BIT (translate[c]); - else - SET_LIST_BIT (c); - c++; - } - } - else if ((obscure_syntax & RE_CHAR_CLASSES) - && c == '[' && p[0] == ':') - { - /* Longest valid character class word has six characters. */ - char str[CHAR_CLASS_MAX_LENGTH]; - PATFETCH (c); - c1 = 0; - /* If no ] at end. */ - if (p == pend) - goto invalid_pattern; - while (1) - { - /* Don't translate the ``character class'' characters. */ - PATFETCH_RAW (c); - if (c == ':' || c == ']' || p == pend - || c1 == CHAR_CLASS_MAX_LENGTH) - break; - str[c1++] = c; - } - str[c1] = '\0'; - if (p == pend - || c == ']' /* End of the bracket expression. */ - || p[0] != ']' - || p + 1 == pend - || (strcmp (str, "alpha") != 0 - && strcmp (str, "upper") != 0 - && strcmp (str, "lower") != 0 - && strcmp (str, "digit") != 0 - && strcmp (str, "alnum") != 0 - && strcmp (str, "xdigit") != 0 - && strcmp (str, "space") != 0 - && strcmp (str, "print") != 0 - && strcmp (str, "punct") != 0 - && strcmp (str, "graph") != 0 - && strcmp (str, "cntrl") != 0)) - { - /* Undo the ending character, the letters, and leave - the leading : and [ (but set bits for them). */ - c1++; - while (c1--) - PATUNFETCH; - SET_LIST_BIT ('['); - SET_LIST_BIT (':'); - } - else - { - /* The ] at the end of the character class. */ - PATFETCH (c); - if (c != ']') - goto invalid_pattern; - for (c = 0; c < (1 << BYTEWIDTH); c++) - { - if ((strcmp (str, "alpha") == 0 && isalpha (c)) - || (strcmp (str, "upper") == 0 && isupper (c)) - || (strcmp (str, "lower") == 0 && islower (c)) - || (strcmp (str, "digit") == 0 && isdigit (c)) - || (strcmp (str, "alnum") == 0 && isalnum (c)) - || (strcmp (str, "xdigit") == 0 && isxdigit (c)) - || (strcmp (str, "space") == 0 && isspace (c)) - || (strcmp (str, "print") == 0 && isprint (c)) - || (strcmp (str, "punct") == 0 && ispunct (c)) - || (strcmp (str, "graph") == 0 && isgraph (c)) - || (strcmp (str, "cntrl") == 0 && iscntrl (c))) - SET_LIST_BIT (c); - } - } - } - else if (translate) - SET_LIST_BIT (translate[c]); - else - SET_LIST_BIT (c); - } - - /* Discard any character set/class bitmap bytes that are all - 0 at the end of the map. Decrement the map-length byte too. */ - while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) - b[-1]--; - b += b[-1]; - break; - - case '(': - if (! (obscure_syntax & RE_NO_BK_PARENS)) - goto normal_char; - else - goto handle_open; - - case ')': - if (! (obscure_syntax & RE_NO_BK_PARENS)) - goto normal_char; - else - goto handle_close; - - case '\n': - if (! (obscure_syntax & RE_NEWLINE_OR)) - goto normal_char; - else - goto handle_bar; - - case '|': - if ((obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) - && (! laststart || p == pend)) - goto invalid_pattern; - else if (! (obscure_syntax & RE_NO_BK_VBAR)) - goto normal_char; - else - goto handle_bar; - - case '{': - if (! ((obscure_syntax & RE_NO_BK_CURLY_BRACES) - && (obscure_syntax & RE_INTERVALS))) - goto normal_char; - else - goto handle_interval; - - case '\\': - if (p == pend) goto invalid_pattern; - PATFETCH_RAW (c); - switch (c) - { - case '(': - if (obscure_syntax & RE_NO_BK_PARENS) - goto normal_backsl; - handle_open: - if (stackp == stacke) goto nesting_too_deep; - - /* Laststart should point to the start_memory that we are about - to push (unless the pattern has RE_NREGS or more ('s). */ - *stackp++ = b - bufp->buffer; - if (regnum < RE_NREGS) - { - BUFPUSH (start_memory); - BUFPUSH (regnum); - } - *stackp++ = fixup_jump ? fixup_jump - bufp->buffer + 1 : 0; - *stackp++ = regnum++; - *stackp++ = begalt - bufp->buffer; - fixup_jump = 0; - laststart = 0; - begalt = b; - break; - - case ')': - if (obscure_syntax & RE_NO_BK_PARENS) - goto normal_backsl; - handle_close: - if (stackp == stackb) goto unmatched_close; - begalt = *--stackp + bufp->buffer; - if (fixup_jump) - store_jump (fixup_jump, jump, b); - if (stackp[-1] < RE_NREGS) - { - BUFPUSH (stop_memory); - BUFPUSH (stackp[-1]); - } - stackp -= 2; - fixup_jump = *stackp ? *stackp + bufp->buffer - 1 : 0; - laststart = *--stackp + bufp->buffer; - break; - - case '|': - if ((obscure_syntax & RE_LIMITED_OPS) - || (obscure_syntax & RE_NO_BK_VBAR)) - goto normal_backsl; - handle_bar: - if (obscure_syntax & RE_LIMITED_OPS) - goto normal_char; - /* Insert before the previous alternative a jump which - jumps to this alternative if the former fails. */ - GET_BUFFER_SPACE (6); - insert_jump (on_failure_jump, begalt, b + 6, b); - pending_exact = 0; - b += 3; - /* The alternative before the previous alternative has a - jump after it which gets executed if it gets matched. - Adjust that jump so it will jump to the previous - alternative's analogous jump (put in below, which in - turn will jump to the next (if any) alternative's such - jump, etc.). The last such jump jumps to the correct - final destination. */ - if (fixup_jump) - store_jump (fixup_jump, jump, b); - - /* Leave space for a jump after previous alternative---to be - filled in later. */ - fixup_jump = b; - b += 3; - - laststart = 0; - begalt = b; - break; - - case '{': - if (! (obscure_syntax & RE_INTERVALS) - /* Let \{ be a literal. */ - || ((obscure_syntax & RE_INTERVALS) - && (obscure_syntax & RE_NO_BK_CURLY_BRACES)) - /* If it's the string "\{". */ - || (p - 2 == pattern && p == pend)) - goto normal_backsl; - handle_interval: - beg_interval = p - 1; /* The {. */ - /* If there is no previous pattern, this isn't an interval. */ - if (!laststart) - { - if (obscure_syntax & RE_CONTEXTUAL_INVALID_OPS) - goto invalid_pattern; - else - goto normal_backsl; - } - /* It also isn't an interval if not preceded by an re - matching a single character or subexpression, or if - the current type of intervals can't handle back - references and the previous thing is a back reference. */ - if (! (*laststart == anychar - || *laststart == charset - || *laststart == charset_not - || *laststart == start_memory - || (*laststart == exactn && laststart[1] == 1) - || (! (obscure_syntax & RE_NO_BK_REFS) - && *laststart == duplicate))) - { - if (obscure_syntax & RE_NO_BK_CURLY_BRACES) - goto normal_char; - - /* Posix extended syntax is handled in previous - statement; this is for Posix basic syntax. */ - if (obscure_syntax & RE_INTERVALS) - goto invalid_pattern; - - goto normal_backsl; - } - lower_bound = -1; /* So can see if are set. */ - upper_bound = -1; - GET_UNSIGNED_NUMBER (lower_bound); - if (c == ',') - { - GET_UNSIGNED_NUMBER (upper_bound); - if (upper_bound < 0) - upper_bound = RE_DUP_MAX; - } - if (upper_bound < 0) - upper_bound = lower_bound; - if (! (obscure_syntax & RE_NO_BK_CURLY_BRACES)) - { - if (c != '\\') - goto invalid_pattern; - PATFETCH (c); - } - if (c != '}' || lower_bound < 0 || upper_bound > RE_DUP_MAX - || lower_bound > upper_bound - || ((obscure_syntax & RE_NO_BK_CURLY_BRACES) - && p != pend && *p == '{')) - { - if (obscure_syntax & RE_NO_BK_CURLY_BRACES) - goto unfetch_interval; - else - goto invalid_pattern; - } - - /* If upper_bound is zero, don't want to succeed at all; - jump from laststart to b + 3, which will be the end of - the buffer after this jump is inserted. */ - - if (upper_bound == 0) - { - GET_BUFFER_SPACE (3); - insert_jump (jump, laststart, b + 3, b); - b += 3; - } - - /* Otherwise, after lower_bound number of succeeds, jump - to after the jump_n which will be inserted at the end - of the buffer, and insert that jump_n. */ - else - { /* Set to 5 if only one repetition is allowed and - hence no jump_n is inserted at the current end of - the buffer; then only space for the succeed_n is - needed. Otherwise, need space for both the - succeed_n and the jump_n. */ - - unsigned slots_needed = upper_bound == 1 ? 5 : 10; - - GET_BUFFER_SPACE (slots_needed); - /* Initialize the succeed_n to n, even though it will - be set by its attendant set_number_at, because - re_compile_fastmap will need to know it. Jump to - what the end of buffer will be after inserting - this succeed_n and possibly appending a jump_n. */ - insert_jump_n (succeed_n, laststart, b + slots_needed, - b, lower_bound); - b += 5; /* Just increment for the succeed_n here. */ - - /* More than one repetition is allowed, so put in at - the end of the buffer a backward jump from b to the - succeed_n we put in above. By the time we've gotten - to this jump when matching, we'll have matched once - already, so jump back only upper_bound - 1 times. */ - - if (upper_bound > 1) - { - store_jump_n (b, jump_n, laststart, upper_bound - 1); - b += 5; - /* When hit this when matching, reset the - preceding jump_n's n to upper_bound - 1. */ - BUFPUSH (set_number_at); - GET_BUFFER_SPACE (2); - STORE_NUMBER_AND_INCR (b, -5); - STORE_NUMBER_AND_INCR (b, upper_bound - 1); - } - /* When hit this when matching, set the succeed_n's n. */ - GET_BUFFER_SPACE (5); - insert_op_2 (set_number_at, laststart, b, 5, lower_bound); - b += 5; - } - pending_exact = 0; - beg_interval = 0; - break; - - - unfetch_interval: - /* If an invalid interval, match the characters as literals. */ - if (beg_interval) - p = beg_interval; - else - { - fprintf (stderr, - "regex: no interval beginning to which to backtrack.\n"); - exit (1); - } - - beg_interval = 0; - PATFETCH (c); /* normal_char expects char in `c'. */ - goto normal_char; - break; - -#ifdef emacs - case '=': - BUFPUSH (at_dot); - break; - - case 's': - laststart = b; - BUFPUSH (syntaxspec); - PATFETCH (c); - BUFPUSH (syntax_spec_code[c]); - break; - - case 'S': - laststart = b; - BUFPUSH (notsyntaxspec); - PATFETCH (c); - BUFPUSH (syntax_spec_code[c]); - break; -#endif /* emacs */ - - case 'w': - laststart = b; - BUFPUSH (wordchar); - break; - - case 'W': - laststart = b; - BUFPUSH (notwordchar); - break; - - case '<': - BUFPUSH (wordbeg); - break; - - case '>': - BUFPUSH (wordend); - break; - - case 'b': - BUFPUSH (wordbound); - break; - - case 'B': - BUFPUSH (notwordbound); - break; - - case '`': - BUFPUSH (begbuf); - break; - - case '\'': - BUFPUSH (endbuf); - break; - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (obscure_syntax & RE_NO_BK_REFS) - goto normal_char; - c1 = c - '0'; - if (c1 >= regnum) - { - if (obscure_syntax & RE_NO_EMPTY_BK_REF) - goto invalid_pattern; - else - goto normal_char; - } - /* Can't back reference to a subexpression if inside of it. */ - for (stackt = stackp - 2; stackt > stackb; stackt -= 4) - if (*stackt == c1) - goto normal_char; - laststart = b; - BUFPUSH (duplicate); - BUFPUSH (c1); - break; - - case '+': - case '?': - if (obscure_syntax & RE_BK_PLUS_QM) - goto handle_plus; - else - goto normal_backsl; - break; - - default: - normal_backsl: - /* You might think it would be useful for \ to mean - not to translate; but if we don't translate it - it will never match anything. */ - if (translate) c = translate[c]; - goto normal_char; - } - break; - - default: - normal_char: /* Expects the character in `c'. */ - if (!pending_exact || pending_exact + *pending_exact + 1 != b - || *pending_exact == 0177 || *p == '*' || *p == '^' - || ((obscure_syntax & RE_BK_PLUS_QM) - ? *p == '\\' && (p[1] == '+' || p[1] == '?') - : (*p == '+' || *p == '?')) - || ((obscure_syntax & RE_INTERVALS) - && ((obscure_syntax & RE_NO_BK_CURLY_BRACES) - ? *p == '{' - : (p[0] == '\\' && p[1] == '{')))) - { - laststart = b; - BUFPUSH (exactn); - pending_exact = b; - BUFPUSH (0); - } - BUFPUSH (c); - (*pending_exact)++; - } - } - - if (fixup_jump) - store_jump (fixup_jump, jump, b); - - if (stackp != stackb) goto unmatched_open; - - bufp->used = b - bufp->buffer; - return 0; - - invalid_pattern: - return "Invalid regular expression"; - - unmatched_open: - return "Unmatched \\("; - - unmatched_close: - return "Unmatched \\)"; - - end_of_pattern: - return "Premature end of regular expression"; - - nesting_too_deep: - return "Nesting too deep"; - - too_big: - return "Regular expression too big"; - - memory_exhausted: - return "Memory exhausted"; -} - - -/* Store a jump of the form <OPCODE> <relative address>. - Store in the location FROM a jump operation to jump to relative - address FROM - TO. OPCODE is the opcode to store. */ - -static void -store_jump (from, opcode, to) - char *from, *to; - char opcode; -{ - from[0] = opcode; - STORE_NUMBER(from + 1, to - (from + 3)); -} - - -/* Open up space before char FROM, and insert there a jump to TO. - CURRENT_END gives the end of the storage not in use, so we know - how much data to copy up. OP is the opcode of the jump to insert. - - If you call this function, you must zero out pending_exact. */ - -static void -insert_jump (op, from, to, current_end) - char op; - char *from, *to, *current_end; -{ - register char *pfrom = current_end; /* Copy from here... */ - register char *pto = current_end + 3; /* ...to here. */ - - while (pfrom != from) - *--pto = *--pfrom; - store_jump (from, op, to); -} - - -/* Store a jump of the form <opcode> <relative address> <n> . - - Store in the location FROM a jump operation to jump to relative - address FROM - TO. OPCODE is the opcode to store, N is a number the - jump uses, say, to decide how many times to jump. - - If you call this function, you must zero out pending_exact. */ - -static void -store_jump_n (from, opcode, to, n) - char *from, *to; - char opcode; - unsigned n; -{ - from[0] = opcode; - STORE_NUMBER (from + 1, to - (from + 3)); - STORE_NUMBER (from + 3, n); -} - - -/* Similar to insert_jump, but handles a jump which needs an extra - number to handle minimum and maximum cases. Open up space at - location FROM, and insert there a jump to TO. CURRENT_END gives the - end of the storage in use, so we know how much data to copy up. OP is - the opcode of the jump to insert. - - If you call this function, you must zero out pending_exact. */ - -static void -insert_jump_n (op, from, to, current_end, n) - char op; - char *from, *to, *current_end; - unsigned n; -{ - register char *pfrom = current_end; /* Copy from here... */ - register char *pto = current_end + 5; /* ...to here. */ - - while (pfrom != from) - *--pto = *--pfrom; - store_jump_n (from, op, to, n); -} - - -/* Open up space at location THERE, and insert operation OP followed by - NUM_1 and NUM_2. CURRENT_END gives the end of the storage in use, so - we know how much data to copy up. - - If you call this function, you must zero out pending_exact. */ - -static void -insert_op_2 (op, there, current_end, num_1, num_2) - char op; - char *there, *current_end; - int num_1, num_2; -{ - register char *pfrom = current_end; /* Copy from here... */ - register char *pto = current_end + 5; /* ...to here. */ - - while (pfrom != there) - *--pto = *--pfrom; - - there[0] = op; - STORE_NUMBER (there + 1, num_1); - STORE_NUMBER (there + 3, num_2); -} - - - -/* Given a pattern, compute a fastmap from it. The fastmap records - which of the (1 << BYTEWIDTH) possible characters can start a string - that matches the pattern. This fastmap is used by re_search to skip - quickly over totally implausible text. - - The caller must supply the address of a (1 << BYTEWIDTH)-byte data - area as bufp->fastmap. - The other components of bufp describe the pattern to be used. */ - -void -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; -{ - unsigned char *pattern = (unsigned char *) bufp->buffer; - int size = bufp->used; - register char *fastmap = bufp->fastmap; - register unsigned char *p = pattern; - register unsigned char *pend = pattern + size; - register int j, k; - unsigned char *translate = (unsigned char *) bufp->translate; - - unsigned char *stackb[NFAILURES]; - unsigned char **stackp = stackb; - - unsigned is_a_succeed_n; - - bzero (fastmap, (1 << BYTEWIDTH)); - bufp->fastmap_accurate = 1; - bufp->can_be_null = 0; - - while (p) - { - is_a_succeed_n = 0; - if (p == pend) - { - bufp->can_be_null = 1; - break; - } -#ifdef SWITCH_ENUM_BUG - switch ((int) ((enum regexpcode) *p++)) -#else - switch ((enum regexpcode) *p++) -#endif - { - case exactn: - if (translate) - fastmap[translate[p[1]]] = 1; - else - fastmap[p[1]] = 1; - break; - - case begline: - case before_dot: - case at_dot: - case after_dot: - case begbuf: - case endbuf: - case wordbound: - case notwordbound: - case wordbeg: - case wordend: - continue; - - case endline: - if (translate) - fastmap[translate['\n']] = 1; - else - fastmap['\n'] = 1; - - if (bufp->can_be_null != 1) - bufp->can_be_null = 2; - break; - - case jump_n: - case finalize_jump: - case maybe_finalize_jump: - case jump: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - if (j > 0) - continue; - /* Jump backward reached implies we just went through - the body of a loop and matched nothing. - Opcode jumped to should be an on_failure_jump. - Just treat it like an ordinary jump. - For a * loop, it has pushed its failure point already; - If so, discard that as redundant. */ - - if ((enum regexpcode) *p != on_failure_jump - && (enum regexpcode) *p != succeed_n) - continue; - p++; - EXTRACT_NUMBER_AND_INCR (j, p); - p += j; - if (stackp != stackb && *stackp == p) - stackp--; - continue; - - case on_failure_jump: - handle_on_failure_jump: - EXTRACT_NUMBER_AND_INCR (j, p); - *++stackp = p + j; - if (is_a_succeed_n) - EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ - continue; - - case succeed_n: - is_a_succeed_n = 1; - /* Get to the number of times to succeed. */ - p += 2; - /* Increment p past the n for when k != 0. */ - EXTRACT_NUMBER_AND_INCR (k, p); - if (k == 0) - { - p -= 4; - goto handle_on_failure_jump; - } - continue; - - case set_number_at: - p += 4; - continue; - - case start_memory: - case stop_memory: - p++; - continue; - - case duplicate: - bufp->can_be_null = 1; - fastmap['\n'] = 1; - case anychar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (j != '\n') - fastmap[j] = 1; - if (bufp->can_be_null) - return; - /* Don't return; check the alternative paths - so we can set can_be_null if appropriate. */ - break; - - case wordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == Sword) - fastmap[j] = 1; - break; - - case notwordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != Sword) - fastmap[j] = 1; - break; - -#ifdef emacs - case syntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == (enum syntaxcode) k) - fastmap[j] = 1; - break; - - case notsyntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != (enum syntaxcode) k) - fastmap[j] = 1; - break; -#endif /* not emacs */ - - case charset: - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) - { - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - } - break; - - case charset_not: - /* Chars beyond end of map must be allowed */ - for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) - { - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - } - break; - } - - /* Get here means we have successfully found the possible starting - characters of one path of the pattern. We need not follow this - path any farther. Instead, look at the next alternative - remembered in the stack. */ - if (stackp != stackb) - p = *stackp--; - else - break; - } -} - - - -/* Like re_search_2, below, but only one string is specified, and - doesn't let you say where to stop matching. */ - -int -re_search (pbufp, string, size, startpos, range, regs) - struct re_pattern_buffer *pbufp; - char *string; - int size, startpos, range; - struct re_registers *regs; -{ - return re_search_2 (pbufp, (char *) 0, 0, string, size, startpos, range, - regs, size); -} - - -/* Using the compiled pattern in PBUFP->buffer, first tries to match the - virtual concatenation of STRING1 and STRING2, starting first at index - STARTPOS, then at STARTPOS + 1, and so on. RANGE is the number of - places to try before giving up. If RANGE is negative, it searches - backwards, i.e., the starting positions tried are STARTPOS, STARTPOS - - 1, etc. STRING1 and STRING2 are of SIZE1 and SIZE2, respectively. - In REGS, return the indices of the virtual concatenation of STRING1 - and STRING2 that matched the entire PBUFP->buffer and its contained - subexpressions. Do not consider matching one past the index MSTOP in - the virtual concatenation of STRING1 and STRING2. - - The value returned is the position in the strings at which the match - was found, or -1 if no match was found, or -2 if error (such as - failure stack overflow). */ - -int -re_search_2 (pbufp, string1, size1, string2, size2, startpos, range, - regs, mstop) - struct re_pattern_buffer *pbufp; - char *string1, *string2; - int size1, size2; - int startpos; - register int range; - struct re_registers *regs; - int mstop; -{ - register char *fastmap = pbufp->fastmap; - register unsigned char *translate = (unsigned char *) pbufp->translate; - int total_size = size1 + size2; - int endpos = startpos + range; - int val; - - /* Check for out-of-range starting position. */ - if (startpos < 0 || startpos > total_size) - return -1; - - /* Fix up range if it would eventually take startpos outside of the - virtual concatenation of string1 and string2. */ - if (endpos < -1) - range = -1 - startpos; - else if (endpos > total_size) - range = total_size - startpos; - - /* Update the fastmap now if not correct already. */ - if (fastmap && !pbufp->fastmap_accurate) - re_compile_fastmap (pbufp); - - /* If the search isn't to be a backwards one, don't waste time in a - long search for a pattern that says it is anchored. */ - if (pbufp->used > 0 && (enum regexpcode) pbufp->buffer[0] == begbuf - && range > 0) - { - if (startpos > 0) - return -1; - else - range = 1; - } - - while (1) - { - /* If a fastmap is supplied, skip quickly over characters that - cannot possibly be the start of a match. Note, however, that - if the pattern can possibly match the null string, we must - test it at each starting point so that we take the first null - string we get. */ - - if (fastmap && startpos < total_size && pbufp->can_be_null != 1) - { - if (range > 0) /* Searching forwards. */ - { - register int lim = 0; - register unsigned char *p; - int irange = range; - if (startpos < size1 && startpos + range >= size1) - lim = range - (size1 - startpos); - - p = ((unsigned char *) - &(startpos >= size1 ? string2 - size1 : string1)[startpos]); - - while (range > lim && !fastmap[translate - ? translate[*p++] - : *p++]) - range--; - startpos += irange - range; - } - else /* Searching backwards. */ - { - register unsigned char c; - - if (string1 == 0 || startpos >= size1) - c = string2[startpos - size1]; - else - c = string1[startpos]; - - c &= 0xff; - if (translate ? !fastmap[translate[c]] : !fastmap[c]) - goto advance; - } - } - - if (range >= 0 && startpos == total_size - && fastmap && pbufp->can_be_null == 0) - return -1; - - val = re_match_2 (pbufp, string1, size1, string2, size2, startpos, - regs, mstop); - if (val >= 0) - return startpos; - if (val == -2) - return -2; - -#ifdef C_ALLOCA - alloca (0); -#endif /* C_ALLOCA */ - - advance: - if (!range) - break; - else if (range > 0) - { - range--; - startpos++; - } - else - { - range++; - startpos--; - } - } - return -1; -} - - - -#ifndef emacs /* emacs never uses this. */ -int -re_match (pbufp, string, size, pos, regs) - struct re_pattern_buffer *pbufp; - char *string; - int size, pos; - struct re_registers *regs; -{ - return re_match_2 (pbufp, (char *) 0, 0, string, size, pos, regs, size); -} -#endif /* not emacs */ - - -/* The following are used for re_match_2, defined below: */ - -/* Roughly the maximum number of failure points on the stack. Would be - exactly that if always pushed MAX_NUM_FAILURE_ITEMS each time we failed. */ - -int re_max_failures = 2000; - -/* Routine used by re_match_2. */ -static int bcmp_translate (); - - -/* Structure and accessing macros used in re_match_2: */ - -struct register_info -{ - unsigned is_active : 1; - unsigned matched_something : 1; -}; - -#define IS_ACTIVE(R) ((R).is_active) -#define MATCHED_SOMETHING(R) ((R).matched_something) - - -/* Macros used by re_match_2: */ - - -/* I.e., regstart, regend, and reg_info. */ - -#define NUM_REG_ITEMS 3 - -/* We push at most this many things on the stack whenever we - fail. The `+ 2' refers to PATTERN_PLACE and STRING_PLACE, which are - arguments to the PUSH_FAILURE_POINT macro. */ - -#define MAX_NUM_FAILURE_ITEMS (RE_NREGS * NUM_REG_ITEMS + 2) - - -/* We push this many things on the stack whenever we fail. */ - -#define NUM_FAILURE_ITEMS (last_used_reg * NUM_REG_ITEMS + 2) - - -/* This pushes most of the information about the current state we will want - if we ever fail back to it. */ - -#define PUSH_FAILURE_POINT(pattern_place, string_place) \ - { \ - short last_used_reg, this_reg; \ - \ - /* Find out how many registers are active or have been matched. \ - (Aside from register zero, which is only set at the end.) */ \ - for (last_used_reg = RE_NREGS - 1; last_used_reg > 0; last_used_reg--)\ - if (regstart[last_used_reg] != (unsigned char *) -1) \ - break; \ - \ - if (stacke - stackp < NUM_FAILURE_ITEMS) \ - { \ - unsigned char **stackx; \ - unsigned int len = stacke - stackb; \ - if (len > re_max_failures * MAX_NUM_FAILURE_ITEMS) \ - return -2; \ - \ - /* Roughly double the size of the stack. */ \ - stackx = (unsigned char **) alloca (2 * len \ - * sizeof (unsigned char *));\ - /* Only copy what is in use. */ \ - bcopy (stackb, stackx, len * sizeof (char *)); \ - stackp = stackx + (stackp - stackb); \ - stackb = stackx; \ - stacke = stackb + 2 * len; \ - } \ - \ - /* Now push the info for each of those registers. */ \ - for (this_reg = 1; this_reg <= last_used_reg; this_reg++) \ - { \ - *stackp++ = regstart[this_reg]; \ - *stackp++ = regend[this_reg]; \ - *stackp++ = (unsigned char *) ®_info[this_reg]; \ - } \ - \ - /* Push how many registers we saved. */ \ - *stackp++ = (unsigned char *) last_used_reg; \ - \ - *stackp++ = pattern_place; \ - *stackp++ = string_place; \ - } - - -/* This pops what PUSH_FAILURE_POINT pushes. */ - -#define POP_FAILURE_POINT() \ - { \ - int temp; \ - stackp -= 2; /* Remove failure points. */ \ - temp = (int) *--stackp; /* How many regs pushed. */ \ - temp *= NUM_REG_ITEMS; /* How much to take off the stack. */ \ - stackp -= temp; /* Remove the register info. */ \ - } - - -#define MATCHING_IN_FIRST_STRING (dend == end_match_1) - -/* Is true if there is a first string and if PTR is pointing anywhere - inside it or just past the end. */ - -#define IS_IN_FIRST_STRING(ptr) \ - (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) - -/* Call before fetching a character with *d. This switches over to - string2 if necessary. */ - -#define PREFETCH \ - while (d == dend) \ - { \ - /* end of string2 => fail. */ \ - if (dend == end_match_2) \ - goto fail; \ - /* end of string1 => advance to string2. */ \ - d = string2; \ - dend = end_match_2; \ - } - - -/* Call this when have matched something; it sets `matched' flags for the - registers corresponding to the subexpressions of which we currently - are inside. */ -#define SET_REGS_MATCHED \ - { unsigned this_reg; \ - for (this_reg = 0; this_reg < RE_NREGS; this_reg++) \ - { \ - if (IS_ACTIVE(reg_info[this_reg])) \ - MATCHED_SOMETHING(reg_info[this_reg]) = 1; \ - else \ - MATCHED_SOMETHING(reg_info[this_reg]) = 0; \ - } \ - } - -/* Test if at very beginning or at very end of the virtual concatenation - of string1 and string2. If there is only one string, we've put it in - string2. */ - -#define AT_STRINGS_BEG (d == (size1 ? string1 : string2) || !size2) -#define AT_STRINGS_END (d == end2) - -#define AT_WORD_BOUNDARY \ - (AT_STRINGS_BEG || AT_STRINGS_END || IS_A_LETTER (d - 1) != IS_A_LETTER (d)) - -/* We have two special cases to check for: - 1) if we're past the end of string1, we have to look at the first - character in string2; - 2) if we're before the beginning of string2, we have to look at the - last character in string1; we assume there is a string1, so use - this in conjunction with AT_STRINGS_BEG. */ -#define IS_A_LETTER(d) \ - (SYNTAX ((d) == end1 ? *string2 : (d) == string2 - 1 ? *(end1 - 1) : *(d))\ - == Sword) - - -/* Match the pattern described by PBUFP against the virtual - concatenation of STRING1 and STRING2, which are of SIZE1 and SIZE2, - respectively. Start the match at index POS in the virtual - concatenation of STRING1 and STRING2. In REGS, return the indices of - the virtual concatenation of STRING1 and STRING2 that matched the - entire PBUFP->buffer and its contained subexpressions. Do not - consider matching one past the index MSTOP in the virtual - concatenation of STRING1 and STRING2. - - If pbufp->fastmap is nonzero, then it had better be up to date. - - The reason that the data to match are specified as two components - which are to be regarded as concatenated is so this function can be - used directly on the contents of an Emacs buffer. - - -1 is returned if there is no match. -2 is returned if there is an - error (such as match stack overflow). Otherwise the value is the - length of the substring which was matched. */ - -int -re_match_2 (pbufp, string1_arg, size1, string2_arg, size2, pos, regs, mstop) - struct re_pattern_buffer *pbufp; - char *string1_arg, *string2_arg; - int size1, size2; - int pos; - struct re_registers *regs; - int mstop; -{ - register unsigned char *p = (unsigned char *) pbufp->buffer; - - /* Pointer to beyond end of buffer. */ - register unsigned char *pend = p + pbufp->used; - - unsigned char *string1 = (unsigned char *) string1_arg; - unsigned char *string2 = (unsigned char *) string2_arg; - unsigned char *end1; /* Just past end of first string. */ - unsigned char *end2; /* Just past end of second string. */ - - /* Pointers into string1 and string2, just past the last characters in - each to consider matching. */ - unsigned char *end_match_1, *end_match_2; - - register unsigned char *d, *dend; - register int mcnt; /* Multipurpose. */ - unsigned char *translate = (unsigned char *) pbufp->translate; - unsigned is_a_jump_n = 0; - - /* Failure point stack. Each place that can handle a failure further - down the line pushes a failure point on this stack. It consists of - restart, regend, and reg_info for all registers corresponding to the - subexpressions we're currently inside, plus the number of such - registers, and, finally, two char *'s. The first char * is where to - resume scanning the pattern; the second one is where to resume - scanning the strings. If the latter is zero, the failure point is a - ``dummy''; if a failure happens and the failure point is a dummy, it - gets discarded and the next next one is tried. */ - - unsigned char *initial_stack[MAX_NUM_FAILURE_ITEMS * NFAILURES]; - unsigned char **stackb = initial_stack; - unsigned char **stackp = stackb; - unsigned char **stacke = &stackb[MAX_NUM_FAILURE_ITEMS * NFAILURES]; - - - /* Information on the contents of registers. These are pointers into - the input strings; they record just what was matched (on this - attempt) by a subexpression part of the pattern, that is, the - regnum-th regstart pointer points to where in the pattern we began - matching and the regnum-th regend points to right after where we - stopped matching the regnum-th subexpression. (The zeroth register - keeps track of what the whole pattern matches.) */ - - unsigned char *regstart[RE_NREGS]; - unsigned char *regend[RE_NREGS]; - - /* The is_active field of reg_info helps us keep track of which (possibly - nested) subexpressions we are currently in. The matched_something - field of reg_info[reg_num] helps us tell whether or not we have - matched any of the pattern so far this time through the reg_num-th - subexpression. These two fields get reset each time through any - loop their register is in. */ - - struct register_info reg_info[RE_NREGS]; - - - /* The following record the register info as found in the above - variables when we find a match better than any we've seen before. - This happens as we backtrack through the failure points, which in - turn happens only if we have not yet matched the entire string. */ - - unsigned best_regs_set = 0; - unsigned char *best_regstart[RE_NREGS]; - unsigned char *best_regend[RE_NREGS]; - - /* Initialize subexpression text positions to -1 to mark ones that no - \( or ( and \) or ) has been seen for. Also set all registers to - inactive and mark them as not having matched anything or ever - failed. */ - for (mcnt = 0; mcnt < RE_NREGS; mcnt++) - { - regstart[mcnt] = regend[mcnt] = (unsigned char *) -1; - IS_ACTIVE (reg_info[mcnt]) = 0; - MATCHED_SOMETHING (reg_info[mcnt]) = 0; - } - - if (regs) - for (mcnt = 0; mcnt < RE_NREGS; mcnt++) - regs->start[mcnt] = regs->end[mcnt] = -1; - - /* Set up pointers to ends of strings. - Don't allow the second string to be empty unless both are empty. */ - if (size2 == 0) - { - string2 = string1; - size2 = size1; - string1 = 0; - size1 = 0; - } - end1 = string1 + size1; - end2 = string2 + size2; - - /* Compute where to stop matching, within the two strings. */ - if (mstop <= size1) - { - end_match_1 = string1 + mstop; - end_match_2 = string2; - } - else - { - end_match_1 = end1; - end_match_2 = string2 + mstop - size1; - } - - /* `p' scans through the pattern as `d' scans through the data. `dend' - is the end of the input string that `d' points within. `d' is - advanced into the following input string whenever necessary, but - this happens before fetching; therefore, at the beginning of the - loop, `d' can be pointing at the end of a string, but it cannot - equal string2. */ - - if (size1 != 0 && pos <= size1) - d = string1 + pos, dend = end_match_1; - else - d = string2 + pos - size1, dend = end_match_2; - - - /* This loops over pattern commands. It exits by returning from the - function if match is complete, or it drops through if match fails - at this starting point in the input data. */ - - while (1) - { - is_a_jump_n = 0; - /* End of pattern means we might have succeeded. */ - if (p == pend) - { - /* If not end of string, try backtracking. Otherwise done. */ - if (d != end_match_2) - { - if (stackp != stackb) - { - /* More failure points to try. */ - - unsigned in_same_string = - IS_IN_FIRST_STRING (best_regend[0]) - == MATCHING_IN_FIRST_STRING; - - /* If exceeds best match so far, save it. */ - if (! best_regs_set - || (in_same_string && d > best_regend[0]) - || (! in_same_string && ! MATCHING_IN_FIRST_STRING)) - { - best_regs_set = 1; - best_regend[0] = d; /* Never use regstart[0]. */ - - for (mcnt = 1; mcnt < RE_NREGS; mcnt++) - { - best_regstart[mcnt] = regstart[mcnt]; - best_regend[mcnt] = regend[mcnt]; - } - } - goto fail; - } - /* If no failure points, don't restore garbage. */ - else if (best_regs_set) - { - restore_best_regs: - /* Restore best match. */ - d = best_regend[0]; - - for (mcnt = 0; mcnt < RE_NREGS; mcnt++) - { - regstart[mcnt] = best_regstart[mcnt]; - regend[mcnt] = best_regend[mcnt]; - } - } - } - - /* If caller wants register contents data back, convert it - to indices. */ - if (regs) - { - regs->start[0] = pos; - if (MATCHING_IN_FIRST_STRING) - regs->end[0] = d - string1; - else - regs->end[0] = d - string2 + size1; - for (mcnt = 1; mcnt < RE_NREGS; mcnt++) - { - if (regend[mcnt] == (unsigned char *) -1) - { - regs->start[mcnt] = -1; - regs->end[mcnt] = -1; - continue; - } - if (IS_IN_FIRST_STRING (regstart[mcnt])) - regs->start[mcnt] = regstart[mcnt] - string1; - else - regs->start[mcnt] = regstart[mcnt] - string2 + size1; - - if (IS_IN_FIRST_STRING (regend[mcnt])) - regs->end[mcnt] = regend[mcnt] - string1; - else - regs->end[mcnt] = regend[mcnt] - string2 + size1; - } - } - return d - pos - (MATCHING_IN_FIRST_STRING - ? string1 - : string2 - size1); - } - - /* Otherwise match next pattern command. */ -#ifdef SWITCH_ENUM_BUG - switch ((int) ((enum regexpcode) *p++)) -#else - switch ((enum regexpcode) *p++) -#endif - { - - /* \( [or `(', as appropriate] is represented by start_memory, - \) by stop_memory. Both of those commands are followed by - a register number in the next byte. The text matched - within the \( and \) is recorded under that number. */ - case start_memory: - regstart[*p] = d; - IS_ACTIVE (reg_info[*p]) = 1; - MATCHED_SOMETHING (reg_info[*p]) = 0; - p++; - break; - - case stop_memory: - regend[*p] = d; - IS_ACTIVE (reg_info[*p]) = 0; - - /* If just failed to match something this time around with a sub- - expression that's in a loop, try to force exit from the loop. */ - if ((! MATCHED_SOMETHING (reg_info[*p]) - || (enum regexpcode) p[-3] == start_memory) - && (p + 1) != pend) - { - register unsigned char *p2 = p + 1; - mcnt = 0; - switch (*p2++) - { - case jump_n: - is_a_jump_n = 1; - case finalize_jump: - case maybe_finalize_jump: - case jump: - case dummy_failure_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p2); - if (is_a_jump_n) - p2 += 2; - break; - } - p2 += mcnt; - - /* If the next operation is a jump backwards in the pattern - to an on_failure_jump, exit from the loop by forcing a - failure after pushing on the stack the on_failure_jump's - jump in the pattern, and d. */ - if (mcnt < 0 && (enum regexpcode) *p2++ == on_failure_jump) - { - EXTRACT_NUMBER_AND_INCR (mcnt, p2); - PUSH_FAILURE_POINT (p2 + mcnt, d); - goto fail; - } - } - p++; - break; - - /* \<digit> has been turned into a `duplicate' command which is - followed by the numeric value of <digit> as the register number. */ - case duplicate: - { - int regno = *p++; /* Get which register to match against */ - register unsigned char *d2, *dend2; - - /* Where in input to try to start matching. */ - d2 = regstart[regno]; - - /* Where to stop matching; if both the place to start and - the place to stop matching are in the same string, then - set to the place to stop, otherwise, for now have to use - the end of the first string. */ - - dend2 = ((IS_IN_FIRST_STRING (regstart[regno]) - == IS_IN_FIRST_STRING (regend[regno])) - ? regend[regno] : end_match_1); - while (1) - { - /* If necessary, advance to next segment in register - contents. */ - while (d2 == dend2) - { - if (dend2 == end_match_2) break; - if (dend2 == regend[regno]) break; - d2 = string2, dend2 = regend[regno]; /* end of string1 => advance to string2. */ - } - /* At end of register contents => success */ - if (d2 == dend2) break; - - /* If necessary, advance to next segment in data. */ - PREFETCH; - - /* How many characters left in this segment to match. */ - mcnt = dend - d; - - /* Want how many consecutive characters we can match in - one shot, so, if necessary, adjust the count. */ - if (mcnt > dend2 - d2) - mcnt = dend2 - d2; - - /* Compare that many; failure if mismatch, else move - past them. */ - if (translate - ? bcmp_translate (d, d2, mcnt, translate) - : bcmp (d, d2, mcnt)) - goto fail; - d += mcnt, d2 += mcnt; - } - } - break; - - case anychar: - PREFETCH; /* Fetch a data character. */ - /* Match anything but a newline, maybe even a null. */ - if ((translate ? translate[*d] : *d) == '\n' - || ((obscure_syntax & RE_DOT_NOT_NULL) - && (translate ? translate[*d] : *d) == '\000')) - goto fail; - SET_REGS_MATCHED; - d++; - break; - - case charset: - case charset_not: - { - int not = 0; /* Nonzero for charset_not. */ - register int c; - if (*(p - 1) == (unsigned char) charset_not) - not = 1; - - PREFETCH; /* Fetch a data character. */ - - if (translate) - c = translate[*d]; - else - c = *d; - - if (c < *p * BYTEWIDTH - && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - p += 1 + *p; - - if (!not) goto fail; - SET_REGS_MATCHED; - d++; - break; - } - - case begline: - if ((size1 != 0 && d == string1) - || (size1 == 0 && size2 != 0 && d == string2) - || (d && d[-1] == '\n') - || (size1 == 0 && size2 == 0)) - break; - else - goto fail; - - case endline: - if (d == end2 - || (d == end1 ? (size2 == 0 || *string2 == '\n') : *d == '\n')) - break; - goto fail; - - /* `or' constructs are handled by starting each alternative with - an on_failure_jump that points to the start of the next - alternative. Each alternative except the last ends with a - jump to the joining point. (Actually, each jump except for - the last one really jumps to the following jump, because - tensioning the jumps is a hassle.) */ - - /* The start of a stupid repeat has an on_failure_jump that points - past the end of the repeat text. This makes a failure point so - that on failure to match a repetition, matching restarts past - as many repetitions have been found with no way to fail and - look for another one. */ - - /* A smart repeat is similar but loops back to the on_failure_jump - so that each repetition makes another failure point. */ - - case on_failure_jump: - on_failure: - EXTRACT_NUMBER_AND_INCR (mcnt, p); - PUSH_FAILURE_POINT (p + mcnt, d); - break; - - /* The end of a smart repeat has a maybe_finalize_jump back. - Change it either to a finalize_jump or an ordinary jump. */ - case maybe_finalize_jump: - EXTRACT_NUMBER_AND_INCR (mcnt, p); - { - register unsigned char *p2 = p; - /* Compare what follows with the beginning of the repeat. - If we can establish that there is nothing that they would - both match, we can change to finalize_jump. */ - while (p2 + 1 != pend - && (*p2 == (unsigned char) stop_memory - || *p2 == (unsigned char) start_memory)) - p2 += 2; /* Skip over reg number. */ - if (p2 == pend) - p[-3] = (unsigned char) finalize_jump; - else if (*p2 == (unsigned char) exactn - || *p2 == (unsigned char) endline) - { - register int c = *p2 == (unsigned char) endline ? '\n' : p2[2]; - register unsigned char *p1 = p + mcnt; - /* p1[0] ... p1[2] are an on_failure_jump. - Examine what follows that. */ - if (p1[3] == (unsigned char) exactn && p1[5] != c) - p[-3] = (unsigned char) finalize_jump; - else if (p1[3] == (unsigned char) charset - || p1[3] == (unsigned char) charset_not) - { - int not = p1[3] == (unsigned char) charset_not; - if (c < p1[4] * BYTEWIDTH - && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - /* `not' is 1 if c would match. */ - /* That means it is not safe to finalize. */ - if (!not) - p[-3] = (unsigned char) finalize_jump; - } - } - } - p -= 2; /* Point at relative address again. */ - if (p[-1] != (unsigned char) finalize_jump) - { - p[-1] = (unsigned char) jump; - goto nofinalize; - } - /* Note fall through. */ - - /* The end of a stupid repeat has a finalize_jump back to the - start, where another failure point will be made which will - point to after all the repetitions found so far. */ - - /* Take off failure points put on by matching on_failure_jump - because didn't fail. Also remove the register information - put on by the on_failure_jump. */ - case finalize_jump: - POP_FAILURE_POINT (); - /* Note fall through. */ - - /* Jump without taking off any failure points. */ - case jump: - nofinalize: - EXTRACT_NUMBER_AND_INCR (mcnt, p); - p += mcnt; - break; - - case dummy_failure_jump: - /* Normally, the on_failure_jump pushes a failure point, which - then gets popped at finalize_jump. We will end up at - finalize_jump, also, and with a pattern of, say, `a+', we - are skipping over the on_failure_jump, so we have to push - something meaningless for finalize_jump to pop. */ - PUSH_FAILURE_POINT (0, 0); - goto nofinalize; - - - /* Have to succeed matching what follows at least n times. Then - just handle like an on_failure_jump. */ - case succeed_n: - EXTRACT_NUMBER (mcnt, p + 2); - /* Originally, this is how many times we HAVE to succeed. */ - if (mcnt) - { - mcnt--; - p += 2; - STORE_NUMBER_AND_INCR (p, mcnt); - } - else if (mcnt == 0) - { - p[2] = unused; - p[3] = unused; - goto on_failure; - } - else - { - fprintf (stderr, "regex: the succeed_n's n is not set.\n"); - exit (1); - } - break; - - case jump_n: - EXTRACT_NUMBER (mcnt, p + 2); - /* Originally, this is how many times we CAN jump. */ - if (mcnt) - { - mcnt--; - STORE_NUMBER(p + 2, mcnt); - goto nofinalize; /* Do the jump without taking off - any failure points. */ - } - /* If don't have to jump any more, skip over the rest of command. */ - else - p += 4; - break; - - case set_number_at: - { - register unsigned char *p1; - - EXTRACT_NUMBER_AND_INCR (mcnt, p); - p1 = p + mcnt; - EXTRACT_NUMBER_AND_INCR (mcnt, p); - STORE_NUMBER (p1, mcnt); - break; - } - - /* Ignore these. Used to ignore the n of succeed_n's which - currently have n == 0. */ - case unused: - break; - - case wordbound: - if (AT_WORD_BOUNDARY) - break; - goto fail; - - case notwordbound: - if (AT_WORD_BOUNDARY) - goto fail; - break; - - case wordbeg: - /* Have to check if AT_STRINGS_BEG before looking at d - 1. */ - if (IS_A_LETTER (d) && (AT_STRINGS_BEG || !IS_A_LETTER (d - 1))) - break; - goto fail; - - case wordend: - /* Have to check if AT_STRINGS_BEG before looking at d - 1. */ - if (!AT_STRINGS_BEG && IS_A_LETTER (d - 1) - && (!IS_A_LETTER (d) || AT_STRINGS_END)) - break; - goto fail; - -#ifdef emacs - case before_dot: - if (PTR_CHAR_POS (d) >= point) - goto fail; - break; - - case at_dot: - if (PTR_CHAR_POS (d) != point) - goto fail; - break; - - case after_dot: - if (PTR_CHAR_POS (d) <= point) - goto fail; - break; - - case wordchar: - mcnt = (int) Sword; - goto matchsyntax; - - case syntaxspec: - mcnt = *p++; - matchsyntax: - PREFETCH; - if (SYNTAX (*d++) != (enum syntaxcode) mcnt) goto fail; - SET_REGS_MATCHED; - break; - - case notwordchar: - mcnt = (int) Sword; - goto matchnotsyntax; - - case notsyntaxspec: - mcnt = *p++; - matchnotsyntax: - PREFETCH; - if (SYNTAX (*d++) == (enum syntaxcode) mcnt) goto fail; - SET_REGS_MATCHED; - break; - -#else /* not emacs */ - - case wordchar: - PREFETCH; - if (!IS_A_LETTER (d)) - goto fail; - SET_REGS_MATCHED; - break; - - case notwordchar: - PREFETCH; - if (IS_A_LETTER (d)) - goto fail; - SET_REGS_MATCHED; - break; - -#endif /* not emacs */ - - case begbuf: - if (AT_STRINGS_BEG) - break; - goto fail; - - case endbuf: - if (AT_STRINGS_END) - break; - goto fail; - - case exactn: - /* Match the next few pattern characters exactly. - mcnt is how many characters to match. */ - mcnt = *p++; - /* This is written out as an if-else so we don't waste time - testing `translate' inside the loop. */ - if (translate) - { - do - { - PREFETCH; - if (translate[*d++] != *p++) goto fail; - } - while (--mcnt); - } - else - { - do - { - PREFETCH; - if (*d++ != *p++) goto fail; - } - while (--mcnt); - } - SET_REGS_MATCHED; - break; - } - continue; /* Successfully executed one pattern command; keep going. */ - - /* Jump here if any matching operation fails. */ - fail: - if (stackp != stackb) - /* A restart point is known. Restart there and pop it. */ - { - short last_used_reg, this_reg; - - /* If this failure point is from a dummy_failure_point, just - skip it. */ - if (!stackp[-2]) - { - POP_FAILURE_POINT (); - goto fail; - } - - d = *--stackp; - p = *--stackp; - if (d >= string1 && d <= end1) - dend = end_match_1; - /* Restore register info. */ - last_used_reg = (short) *--stackp; - - /* Make the ones that weren't saved -1 or 0 again. */ - for (this_reg = RE_NREGS - 1; this_reg > last_used_reg; this_reg--) - { - regend[this_reg] = (unsigned char *) -1; - regstart[this_reg] = (unsigned char *) -1; - IS_ACTIVE (reg_info[this_reg]) = 0; - MATCHED_SOMETHING (reg_info[this_reg]) = 0; - } - - /* And restore the rest from the stack. */ - for ( ; this_reg > 0; this_reg--) - { - reg_info[this_reg] = *(struct register_info *) *--stackp; - regend[this_reg] = *--stackp; - regstart[this_reg] = *--stackp; - } - } - else - break; /* Matching at this starting point really fails. */ - } - - if (best_regs_set) - goto restore_best_regs; - return -1; /* Failure to match. */ -} - - -static int -bcmp_translate (s1, s2, len, translate) - unsigned char *s1, *s2; - register int len; - unsigned char *translate; -{ - register unsigned char *p1 = s1, *p2 = s2; - while (len) - { - if (translate [*p1++] != translate [*p2++]) return 1; - len--; - } - return 0; -} - - - -/* Entry points compatible with 4.2 BSD regex library. */ - -#ifndef emacs - -static struct re_pattern_buffer re_comp_buf; - -char * -re_comp (s) - char *s; -{ - if (!s) - { - if (!re_comp_buf.buffer) - return "No previous regular expression"; - return 0; - } - - if (!re_comp_buf.buffer) - { - if (!(re_comp_buf.buffer = (char *) malloc (200))) - return "Memory exhausted"; - re_comp_buf.allocated = 200; - if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH))) - return "Memory exhausted"; - } - return re_compile_pattern (s, strlen (s), &re_comp_buf); -} - -int -re_exec (s) - char *s; -{ - int len = strlen (s); - return 0 <= re_search (&re_comp_buf, s, len, 0, len, - (struct re_registers *) 0); -} -#endif /* not emacs */ - - - -#ifdef test - -#include <stdio.h> - -/* Indexed by a character, gives the upper case equivalent of the - character. */ - -char upcase[0400] = - { 000, 001, 002, 003, 004, 005, 006, 007, - 010, 011, 012, 013, 014, 015, 016, 017, - 020, 021, 022, 023, 024, 025, 026, 027, - 030, 031, 032, 033, 034, 035, 036, 037, - 040, 041, 042, 043, 044, 045, 046, 047, - 050, 051, 052, 053, 054, 055, 056, 057, - 060, 061, 062, 063, 064, 065, 066, 067, - 070, 071, 072, 073, 074, 075, 076, 077, - 0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137, - 0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177, - 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, - 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, - 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, - 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, - 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, - 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, - 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, - 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, - 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, - 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, - 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, - 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, - 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, - 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, - 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, - 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377 - }; - -#ifdef canned - -#include "tests.h" - -typedef enum { extended_test, basic_test } test_type; - -/* Use this to run the tests we've thought of. */ - -void -main () -{ - test_type t = extended_test; - - if (t == basic_test) - { - printf ("Running basic tests:\n\n"); - test_posix_basic (); - } - else if (t == extended_test) - { - printf ("Running extended tests:\n\n"); - test_posix_extended (); - } -} - -#else /* not canned */ - -/* Use this to run interactive tests. */ - -void -main (argc, argv) - int argc; - char **argv; -{ - char pat[80]; - struct re_pattern_buffer buf; - int i; - char c; - char fastmap[(1 << BYTEWIDTH)]; - - /* Allow a command argument to specify the style of syntax. */ - if (argc > 1) - obscure_syntax = atoi (argv[1]); - - buf.allocated = 40; - buf.buffer = (char *) malloc (buf.allocated); - buf.fastmap = fastmap; - buf.translate = upcase; - - while (1) - { - gets (pat); - - if (*pat) - { - re_compile_pattern (pat, strlen(pat), &buf); - - for (i = 0; i < buf.used; i++) - printchar (buf.buffer[i]); - - putchar ('\n'); - - printf ("%d allocated, %d used.\n", buf.allocated, buf.used); - - re_compile_fastmap (&buf); - printf ("Allowed by fastmap: "); - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (fastmap[i]) printchar (i); - putchar ('\n'); - } - - gets (pat); /* Now read the string to match against */ - - i = re_match (&buf, pat, strlen (pat), 0, 0); - printf ("Match value %d.\n", i); - } -} - -#endif - - -#ifdef NOTDEF -print_buf (bufp) - struct re_pattern_buffer *bufp; -{ - int i; - - printf ("buf is :\n----------------\n"); - for (i = 0; i < bufp->used; i++) - printchar (bufp->buffer[i]); - - printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used); - - printf ("Allowed by fastmap: "); - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (bufp->fastmap[i]) - printchar (i); - printf ("\nAllowed by translate: "); - if (bufp->translate) - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (bufp->translate[i]) - printchar (i); - printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't"); - printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not"); -} -#endif /* NOTDEF */ - -printchar (c) - char c; -{ - if (c < 040 || c >= 0177) - { - putchar ('\\'); - putchar (((c >> 6) & 3) + '0'); - putchar (((c >> 3) & 7) + '0'); - putchar ((c & 7) + '0'); - } - else - putchar (c); -} - -error (string) - char *string; -{ - puts (string); - exit (1); -} -#endif /* test */ diff --git a/usr.bin/sed/regex.h b/usr.bin/sed/regex.h deleted file mode 100644 index b88abf9c3558..000000000000 --- a/usr.bin/sed/regex.h +++ /dev/null @@ -1,253 +0,0 @@ -/* 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. */ - - -#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/usr.bin/sed/sed.c b/usr.bin/sed/sed.c deleted file mode 100644 index e1cf70f3261f..000000000000 --- a/usr.bin/sed/sed.c +++ /dev/null @@ -1,1554 +0,0 @@ -/* GNU SED, a batch stream editor. - 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. */ - -#ifdef __STDC__ -#define VOID void -#else -#define VOID char -#endif - -#define _GNU_SOURCE -#include <ctype.h> -#ifndef isblank -#define isblank(c) ((c) == ' ' || (c) == '\t') -#endif -#include <stdio.h> -#include <regex.h> -#include <getopt.h> -#if defined(STDC_HEADERS) -#include <stdlib.h> -#endif -#if defined(USG) || defined(STDC_HEADERS) -#include <string.h> -#include <memory.h> -#define bcopy(s, d, n) (memcpy((d), (s), (n))) -#else -#include <strings.h> -VOID *memchr(); -#endif - -char *version_string = "GNU sed version 1.08"; - -/* Struct vector is used to describe a chunk of a sed program. There is one - vector for the main program, and one for each { } pair. */ -struct vector { - struct sed_cmd *v; - int v_length; - int v_allocated; - struct vector *up_one; - struct vector *next_one; -}; - - -/* Goto structure is used to hold both GOTO's and labels. There are two - separate lists, one of goto's, called 'jumps', and one of labels, called - 'labels'. - the V element points to the descriptor for the program-chunk in which the - goto was encountered. - the v_index element counts which element of the vector actually IS the - goto/label. The first element of the vector is zero. - the NAME element is the null-terminated name of the label. - next is the next goto/label in the list. */ - -struct sed_label { - struct vector *v; - int v_index; - char *name; - struct sed_label *next; -}; - -/* ADDR_TYPE is zero for a null address, - one if addr_number is valid, or - two if addr_regex is valid, - three, if the address is '$' - - Other values are undefined. - */ - -#define ADDR_NULL 0 -#define ADDR_NUM 1 -#define ADDR_REGEX 2 -#define ADDR_LAST 3 - -struct addr { - int addr_type; - struct re_pattern_buffer *addr_regex; - int addr_number; -}; - - -/* Aflags: If the low order bit is set, a1 has been - matched; apply this command until a2 matches. - If the next bit is set, apply this command to all - lines that DON'T match the address(es). - */ - -#define A1_MATCHED_BIT 01 -#define ADDR_BANG_BIT 02 - - -struct sed_cmd { - struct addr a1,a2; - int aflags; - - char cmd; - - union { - /* This structure is used for a, i, and c commands */ - struct { - char *text; - int text_len; - } cmd_txt; - - /* This is used for b and t commands */ - struct sed_cmd *label; - - /* This for r and w commands */ - FILE *io_file; - - /* This for the hairy s command */ - /* For the flags var: - low order bit means the 'g' option was given, - next bit means the 'p' option was given, - and the next bit means a 'w' option was given, - and wio_file contains the file to write to. */ - -#define S_GLOBAL_BIT 01 -#define S_PRINT_BIT 02 -#define S_WRITE_BIT 04 -#define S_NUM_BIT 010 - - struct { - struct re_pattern_buffer *regx; - char *replacement; - int replace_length; - int flags; - int numb; - FILE *wio_file; - } cmd_regex; - - /* This for the y command */ - unsigned char *translate; - - /* For { and } */ - struct vector *sub; - struct sed_label *jump; - } x; -}; - -/* Sed operates a line at a time. */ -struct line { - char *text; /* Pointer to line allocated by malloc. */ - int length; /* Length of text. */ - int alloc; /* Allocated space for text. */ -}; - -/* This structure holds information about files opend by the 'r', 'w', - and 's///w' commands. In paticular, it holds the FILE pointer to - use, the file's name, a flag that is non-zero if the file is being - read instead of written. */ - -#define NUM_FPS 32 -struct { - FILE *phile; - char *name; - int readit; -} file_ptrs[NUM_FPS]; - - -#if defined(__STDC__) -# define P_(s) s -#else -# define P_(s) () -#endif - -void panic P_((char *str, ...)); -char *__fp_name P_((FILE *fp)); -FILE *ck_fopen P_((char *name, char *mode)); -void ck_fwrite P_((char *ptr, int size, int nmemb, FILE *stream)); -void ck_fclose P_((FILE *stream)); -VOID *ck_malloc P_((int size)); -VOID *ck_realloc P_((VOID *ptr, int size)); -char *ck_strdup P_((char *str)); -VOID *init_buffer P_((void)); -void flush_buffer P_((VOID *bb)); -int size_buffer P_((VOID *b)); -void add_buffer P_((VOID *bb, char *p, int n)); -void add1_buffer P_((VOID *bb, int ch)); -char *get_buffer P_((VOID *bb)); - -void compile_string P_((char *str)); -void compile_file P_((char *str)); -struct vector *compile_program P_((struct vector *vector)); -void bad_prog P_((char *why)); -int inchar P_((void)); -void savchar P_((int ch)); -int compile_address P_((struct addr *addr)); -void compile_regex P_((int slash)); -struct sed_label *setup_jump P_((struct sed_label *list, struct sed_cmd *cmd, struct vector *vec)); -FILE *compile_filename P_((int readit)); -void read_file P_((char *name)); -void execute_program P_((struct vector *vec)); -int match_address P_((struct addr *addr)); -int read_pattern_space P_((void)); -void append_pattern_space P_((void)); -void line_copy P_((struct line *from, struct line *to)); -void line_append P_((struct line *from, struct line *to)); -void str_append P_((struct line *to, char *string, int length)); -void usage P_((void)); - -extern char *myname; - -/* If set, don't write out the line unless explictly told to */ -int no_default_output = 0; - -/* Current input line # */ -int input_line_number = 0; - -/* Are we on the last input file? */ -int last_input_file = 0; - -/* Have we hit EOF on the last input file? This is used to decide if we - have hit the '$' address yet. */ -int input_EOF = 0; - -/* non-zero if a quit command has been executed. */ -int quit_cmd = 0; - -/* Have we done any replacements lately? This is used by the 't' command. */ -int replaced = 0; - -/* How many '{'s are we executing at the moment */ -int program_depth = 0; - -/* The complete compiled SED program that we are going to run */ -struct vector *the_program = 0; - -/* information about labels and jumps-to-labels. This is used to do - the required backpatching after we have compiled all the scripts. */ -struct sed_label *jumps = 0; -struct sed_label *labels = 0; - -/* The 'current' input line. */ -struct line line; - -/* An input line that's been stored by later use by the program */ -struct line hold; - -/* A 'line' to append to the current line when it comes time to write it out */ -struct line append; - - -/* When we're reading a script command from a string, 'prog_start' and - 'prog_end' point to the beginning and end of the string. This - would allow us to compile script strings that contain nulls, except - that script strings are only read from the command line, which is - null-terminated */ -char *prog_start; -char *prog_end; - -/* When we're reading a script command from a string, 'prog_cur' points - to the current character in the string */ -char *prog_cur; - -/* This is the name of the current script file. - It is used for error messages. */ -char *prog_name; - -/* This is the current script file. If it is zero, we are reading - from a string stored in 'prog_start' instead. If both 'prog_file' - and 'prog_start' are zero, we're in trouble! */ -FILE *prog_file; - -/* this is the number of the current script line that we're compiling. It is - used to give out useful and informative error messages. */ -int prog_line = 1; - -/* This is the file pointer that we're currently reading data from. It may - be stdin */ -FILE *input_file; - -/* If this variable is non-zero at exit, one or more of the input - files couldn't be opened. */ - -int bad_input = 0; - -/* 'an empty regular expression is equivalent to the last regular - expression read' so we have to keep track of the last regex used. - Here's where we store a pointer to it (it is only malloc()'d once) */ -struct re_pattern_buffer *last_regex; - -/* Various error messages we may want to print */ -static char ONE_ADDR[] = "Command only uses one address"; -static char NO_ADDR[] = "Command doesn't take any addresses"; -static char LINE_JUNK[] = "Extra characters after command"; -static char BAD_EOF[] = "Unexpected End-of-file"; -static char NO_REGEX[] = "No previous regular expression"; - -static struct option longopts[] = -{ - {"expression", 1, NULL, 'e'}, - {"file", 1, NULL, 'f'}, - {"quiet", 0, NULL, 'n'}, - {"silent", 0, NULL, 'n'}, - {"version", 0, NULL, 'V'}, - {NULL, 0, NULL, 0} -}; - -/* Yes, the main program, which parses arguments, and does the right - thing with them; it also inits the temporary storage, etc. */ -void -main(argc,argv) -int argc; -char **argv; -{ - int opt; - char *e_strings = NULL; - int compiled = 0; - struct sed_label *go,*lbl; - - myname=argv[0]; - while((opt=getopt_long(argc,argv,"ne:f:V", longopts, (int *) 0)) - !=EOF) { - switch(opt) { - case 'n': - no_default_output = 1; - break; - case 'e': - if(e_strings == NULL) { - e_strings=ck_malloc(strlen(optarg)+2); - strcpy(e_strings,optarg); - } else { - e_strings=ck_realloc(e_strings,strlen(e_strings)+strlen(optarg)+2); - strcat(e_strings,optarg); - } - strcat(e_strings,"\n"); - compiled = 1; - break; - case 'f': - compile_file(optarg); - compiled = 1; - break; - case 'V': - fprintf(stderr, "%s\n", version_string); - break; - default: - usage(); - } - } - if(e_strings) { - compile_string(e_strings); - free(e_strings); - } - if(!compiled) { - if (optind == argc) - usage(); - compile_string(argv[optind++]); - } - - for(go=jumps;go;go=go->next) { - for(lbl=labels;lbl;lbl=lbl->next) - if(!strcmp(lbl->name,go->name)) - break; - if(*go->name && !lbl) - panic("Can't find label for jump to '%s'",go->name); - go->v->v[go->v_index].x.jump=lbl; - } - - line.length=0; - line.alloc=50; - line.text=ck_malloc(50); - - append.length=0; - append.alloc=50; - append.text=ck_malloc(50); - - hold.length=0; - hold.alloc=50; - hold.text=ck_malloc(50); - - if(argc<=optind) { - last_input_file++; - read_file("-"); - } else while(optind<argc) { - if(optind==argc-1) - last_input_file++; - read_file(argv[optind]); - optind++; - if(quit_cmd) - break; - } - if(bad_input) - exit(2); - exit(0); -} - -/* 'str' is a string (from the command line) that contains a sed command. - Compile the command, and add it to the end of 'the_program' */ -void -compile_string(str) -char *str; -{ - prog_file = 0; - prog_line=0; - prog_start=prog_cur=str; - prog_end=str+strlen(str); - the_program=compile_program(the_program); -} - -/* 'str' is the name of a file containing sed commands. Read them in - and add them to the end of 'the_program' */ -void -compile_file(str) -char *str; -{ - int ch; - - prog_start=prog_cur=prog_end=0; - prog_name=str; - prog_line=1; - if(str[0]=='-' && str[1]=='\0') - prog_file=stdin; - else - prog_file=ck_fopen(str,"r"); - ch=getc(prog_file); - if(ch=='#') { - ch=getc(prog_file); - if(ch=='n') - no_default_output++; - while(ch!=EOF && ch!='\n') - ch=getc(prog_file); - } else if(ch!=EOF) - ungetc(ch,prog_file); - the_program=compile_program(the_program); -} - -#define MORE_CMDS 40 - -/* Read a program (or a subprogram within '{' '}' pairs) in and store - the compiled form in *'vector' Return a pointer to the new vector. */ -struct vector * -compile_program(vector) -struct vector *vector; -{ - struct sed_cmd *cur_cmd; - int ch; - int slash; - VOID *b; - unsigned char *string; - int num; - - if(!vector) { - vector=(struct vector *)ck_malloc(sizeof(struct vector)); - vector->v=(struct sed_cmd *)ck_malloc(MORE_CMDS*sizeof(struct sed_cmd)); - vector->v_allocated=MORE_CMDS; - vector->v_length=0; - vector->up_one = 0; - vector->next_one = 0; - } - for(;;) { - skip_comment: - do ch=inchar(); - while(ch!=EOF && (isblank(ch) || ch=='\n' || ch==';')); - if(ch==EOF) - break; - savchar(ch); - - if(vector->v_length==vector->v_allocated) { - vector->v=(struct sed_cmd *)ck_realloc((VOID *)vector->v,(vector->v_length+MORE_CMDS)*sizeof(struct sed_cmd)); - vector->v_allocated+=MORE_CMDS; - } - cur_cmd=vector->v+vector->v_length; - vector->v_length++; - - cur_cmd->a1.addr_type=0; - cur_cmd->a2.addr_type=0; - cur_cmd->aflags=0; - cur_cmd->cmd=0; - - if(compile_address(&(cur_cmd->a1))) { - ch=inchar(); - if(ch==',') { - do ch=inchar(); - while(ch!=EOF && isblank(ch)); - savchar(ch); - if(compile_address(&(cur_cmd->a2))) - ; - else - bad_prog("Unexpected ','"); - } else - savchar(ch); - } - ch=inchar(); - if(ch==EOF) - break; - new_cmd: - switch(ch) { - case '#': - if(cur_cmd->a1.addr_type!=0) - bad_prog(NO_ADDR); - do ch=inchar(); - while(ch!=EOF && ch!='\n'); - vector->v_length--; - goto skip_comment; - case '!': - if(cur_cmd->aflags & ADDR_BANG_BIT) - bad_prog("Multiple '!'s"); - cur_cmd->aflags|= ADDR_BANG_BIT; - do ch=inchar(); - while(ch!=EOF && isblank(ch)); - if(ch==EOF) - bad_prog(BAD_EOF); -#if 0 - savchar(ch); -#endif - goto new_cmd; - case 'a': - case 'i': - if(cur_cmd->a2.addr_type!=0) - bad_prog(ONE_ADDR); - /* Fall Through */ - case 'c': - cur_cmd->cmd=ch; - if(inchar()!='\\' || inchar()!='\n') - bad_prog(LINE_JUNK); - b=init_buffer(); - while((ch=inchar())!=EOF && ch!='\n') { - if(ch=='\\') - ch=inchar(); - add1_buffer(b,ch); - } - if(ch!=EOF) - add1_buffer(b,ch); - num=size_buffer(b); - string=(unsigned char *)ck_malloc(num); - bcopy(get_buffer(b),string,num); - flush_buffer(b); - cur_cmd->x.cmd_txt.text_len=num; - cur_cmd->x.cmd_txt.text=(char *)string; - break; - case '{': - cur_cmd->cmd=ch; - program_depth++; -#if 0 - while((ch=inchar())!=EOF && ch!='\n') - if(!isblank(ch)) - bad_prog(LINE_JUNK); -#endif - cur_cmd->x.sub=compile_program((struct vector *)0); - /* FOO JF is this the right thing to do? */ - break; - case '}': - if(!program_depth) - bad_prog("Unexpected '}'"); - --(vector->v_length); - while((ch=inchar())!=EOF && ch!='\n' && ch!=';') - if(!isblank(ch)) - bad_prog(LINE_JUNK); - return vector; - case ':': - cur_cmd->cmd=ch; - if(cur_cmd->a1.addr_type!=0) - bad_prog(": doesn't want any addresses"); - labels=setup_jump(labels,cur_cmd,vector); - break; - case 'b': - case 't': - cur_cmd->cmd=ch; - jumps=setup_jump(jumps,cur_cmd,vector); - break; - case 'q': - case '=': - if(cur_cmd->a2.addr_type) - bad_prog(ONE_ADDR); - /* Fall Through */ - case 'd': - case 'D': - case 'g': - case 'G': - case 'h': - case 'H': - case 'l': - case 'n': - case 'N': - case 'p': - case 'P': - case 'x': - cur_cmd->cmd=ch; - do ch=inchar(); - while(ch!=EOF && isblank(ch) && ch!='\n' && ch!=';'); - if(ch!='\n' && ch!=';' && ch!=EOF) - bad_prog(LINE_JUNK); - break; - - case 'r': - if(cur_cmd->a2.addr_type!=0) - bad_prog(ONE_ADDR); - /* FALL THROUGH */ - case 'w': - cur_cmd->cmd=ch; - cur_cmd->x.io_file=compile_filename(ch=='r'); - break; - - case 's': - cur_cmd->cmd=ch; - slash=inchar(); - compile_regex(slash); - - cur_cmd->x.cmd_regex.regx=last_regex; - - b=init_buffer(); - while((ch=inchar())!=EOF && ch!=slash) { - if(ch=='\\') { - int ci; - - ci=inchar(); - if(ci!=EOF) { - if(ci!='\n') - add1_buffer(b,ch); - add1_buffer(b,ci); - } - } else - add1_buffer(b,ch); - } - cur_cmd->x.cmd_regex.replace_length=size_buffer(b); - cur_cmd->x.cmd_regex.replacement=ck_malloc(cur_cmd->x.cmd_regex.replace_length); - bcopy(get_buffer(b),cur_cmd->x.cmd_regex.replacement,cur_cmd->x.cmd_regex.replace_length); - flush_buffer(b); - - cur_cmd->x.cmd_regex.flags=0; - cur_cmd->x.cmd_regex.numb=0; - - if(ch==EOF) - break; - do { - ch=inchar(); - switch(ch) { - case 'p': - if(cur_cmd->x.cmd_regex.flags&S_PRINT_BIT) - bad_prog("multiple 'p' options to 's' command"); - cur_cmd->x.cmd_regex.flags|=S_PRINT_BIT; - break; - case 'g': - if(cur_cmd->x.cmd_regex.flags&S_NUM_BIT) - cur_cmd->x.cmd_regex.flags&= ~S_NUM_BIT; - if(cur_cmd->x.cmd_regex.flags&S_GLOBAL_BIT) - bad_prog("multiple 'g' options to 's' command"); - cur_cmd->x.cmd_regex.flags|=S_GLOBAL_BIT; - break; - case 'w': - cur_cmd->x.cmd_regex.flags|=S_WRITE_BIT; - cur_cmd->x.cmd_regex.wio_file=compile_filename(0); - ch='\n'; - break; - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - if(cur_cmd->x.cmd_regex.flags&S_NUM_BIT) - bad_prog("multiple number options to 's' command"); - if((cur_cmd->x.cmd_regex.flags&S_GLOBAL_BIT)==0) - cur_cmd->x.cmd_regex.flags|=S_NUM_BIT; - num = 0; - while(isdigit(ch)) { - num=num*10+ch-'0'; - ch=inchar(); - } - savchar(ch); - cur_cmd->x.cmd_regex.numb=num; - break; - case '\n': - case ';': - case EOF: - break; - default: - bad_prog("Unknown option to 's'"); - break; - } - } while(ch!=EOF && ch!='\n' && ch!=';'); - if(ch==EOF) - break; - break; - - case 'y': - cur_cmd->cmd=ch; - string=(unsigned char *)ck_malloc(256); - for(num=0;num<256;num++) - string[num]=num; - b=init_buffer(); - slash=inchar(); - while((ch=inchar())!=EOF && ch!=slash) - add1_buffer(b,ch); - cur_cmd->x.translate=string; - string=(unsigned char *)get_buffer(b); - for(num=size_buffer(b);num;--num) { - ch=inchar(); - if(ch==EOF) - bad_prog(BAD_EOF); - if(ch==slash) - bad_prog("strings for y command are different lengths"); - cur_cmd->x.translate[*string++]=ch; - } - flush_buffer(b); - if(inchar()!=slash || ((ch=inchar())!=EOF && ch!='\n' && ch!=';')) - bad_prog(LINE_JUNK); - break; - - default: - bad_prog("Unknown command"); - } - } - return vector; -} - -/* Complain about a programming error and exit. */ -void -bad_prog(why) -char *why; -{ - if(prog_line) - fprintf(stderr,"%s: file %s line %d: %s\n",myname,prog_name,prog_line,why); - else - fprintf(stderr,"%s: %s\n",myname,why); - exit(1); -} - -/* Read the next character from the program. Return EOF if there isn't - anything to read. Keep prog_line up to date, so error messages can - be meaningful. */ -int -inchar() -{ - int ch; - if(prog_file) { - if(feof(prog_file)) - return EOF; - else - ch=getc(prog_file); - } else { - if(!prog_cur) - return EOF; - else if(prog_cur==prog_end) { - ch=EOF; - prog_cur=0; - } else - ch= *prog_cur++; - } - if(ch=='\n' && prog_line) - prog_line++; - return ch; -} - -/* unget 'ch' so the next call to inchar will return it. 'ch' must not be - EOF or anything nasty like that. */ -void -savchar(ch) -int ch; -{ - if(ch==EOF) - return; - if(ch=='\n' && prog_line>1) - --prog_line; - if(prog_file) - ungetc(ch,prog_file); - else - *--prog_cur=ch; -} - - -/* Try to read an address for a sed command. If it succeeeds, - return non-zero and store the resulting address in *'addr'. - If the input doesn't look like an address read nothing - and return zero. */ -int -compile_address(addr) -struct addr *addr; -{ - int ch; - int num; - - ch=inchar(); - - if(isdigit(ch)) { - num=ch-'0'; - while((ch=inchar())!=EOF && isdigit(ch)) - num=num*10+ch-'0'; - while(ch!=EOF && isblank(ch)) - ch=inchar(); - savchar(ch); - addr->addr_type=ADDR_NUM; - addr->addr_number = num; - return 1; - } else if(ch=='/') { - addr->addr_type=ADDR_REGEX; - compile_regex('/'); - addr->addr_regex=last_regex; - do ch=inchar(); - while(ch!=EOF && isblank(ch)); - savchar(ch); - return 1; - } else if(ch=='$') { - addr->addr_type=ADDR_LAST; - do ch=inchar(); - while(ch!=EOF && isblank(ch)); - savchar(ch); - return 1; - } else - savchar(ch); - return 0; -} - -void -compile_regex (slash) - int slash; -{ - VOID *b; - int ch; - int in_char_class = 0; - - b=init_buffer(); - while((ch=inchar())!=EOF && (ch!=slash || in_char_class)) { - if(ch=='^') { - if(size_buffer(b)==0) { - add1_buffer(b,'\\'); - add1_buffer(b,'`'); - } else - add1_buffer(b,ch); - continue; - } else if(ch=='$') { - ch=inchar(); - savchar(ch); - if(ch==slash) { - add1_buffer(b,'\\'); - add1_buffer(b,'\''); - } else - add1_buffer(b,'$'); - continue; - } else if(ch == '[') { - add1_buffer(b,ch); - in_char_class = 1; - continue; - } else if(ch == ']') { - add1_buffer(b,ch); - in_char_class = 0; - continue; - } else if(ch!='\\') { - add1_buffer(b,ch); - continue; - } - ch=inchar(); - switch(ch) { - case 'n': - add1_buffer(b,'\n'); - break; -#if 0 - case 'b': - add1_buffer(b,'\b'); - break; - case 'f': - add1_buffer(b,'\f'); - break; - case 'r': - add1_buffer(b,'\r'); - break; - case 't': - add1_buffer(b,'\t'); - break; -#endif /* 0 */ - case EOF: - break; - default: - add1_buffer(b,'\\'); - add1_buffer(b,ch); - break; - } - } - if(ch==EOF) - bad_prog(BAD_EOF); - if(size_buffer(b)) { - last_regex=(struct re_pattern_buffer *)ck_malloc(sizeof(struct re_pattern_buffer)); - last_regex->allocated=size_buffer(b)+10; - last_regex->buffer=ck_malloc(last_regex->allocated); - last_regex->fastmap=ck_malloc(256); - last_regex->translate=0; - re_compile_pattern(get_buffer(b),size_buffer(b),last_regex); - } else if(!last_regex) - bad_prog(NO_REGEX); - flush_buffer(b); -} - -/* Store a label (or label reference) created by a ':', 'b', or 't' - comand so that the jump to/from the lable can be backpatched after - compilation is complete */ -struct sed_label * -setup_jump(list,cmd,vec) -struct sed_label *list; -struct sed_cmd *cmd; -struct vector *vec; -{ - struct sed_label *tmp; - VOID *b; - int ch; - - b=init_buffer(); - while((ch=inchar()) != EOF && isblank(ch)) - ; - while(ch!=EOF && ch!='\n') { - add1_buffer(b,ch); - ch=inchar(); - } - savchar(ch); - add1_buffer(b,'\0'); - tmp=(struct sed_label *)ck_malloc(sizeof(struct sed_label)); - tmp->v=vec; - tmp->v_index=cmd-vec->v; - tmp->name=ck_strdup(get_buffer(b)); - tmp->next=list; - flush_buffer(b); - return tmp; -} - -/* read in a filename for a 'r', 'w', or 's///w' command, and - update the internal structure about files. The file is - opened if it isn't already open. */ -FILE * -compile_filename(readit) - int readit; -{ - char *file_name; - int n; - VOID *b; - int ch; - - if(inchar()!=' ') - bad_prog("missing ' ' before filename"); - b=init_buffer(); - while((ch=inchar())!=EOF && ch!='\n') - add1_buffer(b,ch); - add1_buffer(b,'\0'); - file_name=get_buffer(b); - for(n=0;n<NUM_FPS;n++) { - if(!file_ptrs[n].name) - break; - if(!strcmp(file_ptrs[n].name,file_name)) { - if(file_ptrs[n].readit!=readit) - bad_prog("Can't open file for both reading and writing"); - flush_buffer(b); - return file_ptrs[n].phile; - } - } - if(n<NUM_FPS) { - file_ptrs[n].name=ck_strdup(file_name); - file_ptrs[n].readit=readit; - if (!readit) - file_ptrs[n].phile=ck_fopen(file_name,"a"); - else if (access(file_name, 4) == 0) - file_ptrs[n].phile=ck_fopen(file_name,"r"); - else - file_ptrs[n].phile=ck_fopen("/dev/null", "r"); - flush_buffer(b); - return file_ptrs[n].phile; - } else { - bad_prog("Hopelessely evil compiled in limit on number of open files. re-compile sed"); - return 0; - } -} - -/* Parse a filename given by a 'r' 'w' or 's///w' command. */ -void -read_file(name) -char *name; -{ - if(*name=='-' && name[1]=='\0') - input_file=stdin; - else { - input_file=fopen(name,"r"); - if(input_file==0) { - extern int errno; - extern char *sys_errlist[]; - extern int sys_nerr; - - char *ptr; - - ptr=(errno>=0 && errno<sys_nerr) ? sys_errlist[errno] : "Unknown error code"; - bad_input++; - fprintf(stderr,"%s: can't read %s: %s\n",myname,name,ptr); - - return; - } - } - while(read_pattern_space()) { - execute_program(the_program); - if(!no_default_output) - ck_fwrite(line.text,1,line.length,stdout); - if(append.length) { - ck_fwrite(append.text,1,append.length,stdout); - append.length=0; - } - if(quit_cmd) - break; - } - ck_fclose(input_file); -} - -/* Execute the program 'vec' on the current input line. */ -void -execute_program(vec) -struct vector *vec; -{ - struct sed_cmd *cur_cmd; - int n; - int addr_matched; - static int end_cycle; - - int start; - int remain; - int offset; - - static struct line tmp; - struct line t; - char *rep,*rep_end,*rep_next,*rep_cur; - - struct re_registers regs; - int count = 0; - - end_cycle = 0; - - for(cur_cmd=vec->v,n=vec->v_length;n;cur_cmd++,n--) { - - exe_loop: - addr_matched=0; - if(cur_cmd->aflags&A1_MATCHED_BIT) { - addr_matched=1; - if(match_address(&(cur_cmd->a2))) - cur_cmd->aflags&=~A1_MATCHED_BIT; - } else if(match_address(&(cur_cmd->a1))) { - addr_matched=1; - if(cur_cmd->a2.addr_type!=ADDR_NULL) - cur_cmd->aflags|=A1_MATCHED_BIT; - } - if(cur_cmd->aflags&ADDR_BANG_BIT) - addr_matched= !addr_matched; - if(!addr_matched) - continue; - switch(cur_cmd->cmd) { - case '{': /* Execute sub-program */ - execute_program(cur_cmd->x.sub); - break; - - case ':': /* Executing labels is easy. */ - break; - - case '=': - printf("%d\n",input_line_number); - break; - - case 'a': - while(append.alloc-append.length<cur_cmd->x.cmd_txt.text_len) { - append.alloc *= 2; - append.text=ck_realloc(append.text,append.alloc); - } - bcopy(cur_cmd->x.cmd_txt.text,append.text+append.length,cur_cmd->x.cmd_txt.text_len); - append.length+=cur_cmd->x.cmd_txt.text_len; - break; - - case 'b': - if(!cur_cmd->x.jump) - end_cycle++; - else { - struct sed_label *j = cur_cmd->x.jump; - - n= j->v->v_length - j->v_index; - cur_cmd= j->v->v + j->v_index; - goto exe_loop; - } - break; - - case 'c': - line.length=0; - if(!(cur_cmd->aflags&A1_MATCHED_BIT)) - ck_fwrite(cur_cmd->x.cmd_txt.text,1,cur_cmd->x.cmd_txt.text_len,stdout); - end_cycle++; - break; - - case 'd': - line.length=0; - end_cycle++; - break; - - case 'D': - { - char *tmp; - int newlength; - - tmp=memchr(line.text,'\n',line.length); - newlength=line.length-(tmp-line.text); - if(newlength) - memmove(line.text,tmp,newlength); - line.length=newlength; - } - end_cycle++; - break; - - case 'g': - line_copy(&hold,&line); - break; - - case 'G': - line_append(&hold,&line); - break; - - case 'h': - line_copy(&line,&hold); - break; - - case 'H': - line_append(&line,&hold); - break; - - case 'i': - ck_fwrite(cur_cmd->x.cmd_txt.text,1,cur_cmd->x.cmd_txt.text_len,stdout); - break; - - case 'l': - { - char *tmp; - int n; - int width = 0; - - n=line.length; - tmp=line.text; - /* Use --n so this'll skip the trailing newline */ - while(--n) { - if(width>77) { - width=0; - putchar('\n'); - } - if(*tmp == '\\') { - printf("\\\\"); - width+=2; - } else if(isprint(*tmp)) { - putchar(*tmp); - width++; - } else switch(*tmp) { -#if 0 - /* Should print \00 instead of \0 because (a) POSIX requires it, and - (b) this way \01 is unambiguous. */ - case '\0': - printf("\\0"); - width+=2; - break; -#endif - case 007: - printf("\\a"); - width+=2; - break; - case '\b': - printf("\\b"); - width+=2; - break; - case '\f': - printf("\\f"); - width+=2; - break; - case '\n': - printf("\\n"); - width+=2; - break; - case '\r': - printf("\\r"); - width+=2; - break; - case '\t': - printf("\\t"); - width+=2; - break; - case '\v': - printf("\\v"); - width+=2; - break; - default: - printf("\\%02x",(*tmp)&0xFF); - width+=2; - break; - } - tmp++; - } - putchar('\n'); - } - break; - - case 'n': - if (feof(input_file)) goto quit; - ck_fwrite(line.text,1,line.length,stdout); - read_pattern_space(); - break; - - case 'N': - if (feof(input_file)) goto quit; - append_pattern_space(); - break; - - case 'p': - ck_fwrite(line.text,1,line.length,stdout); - break; - - case 'P': - { - char *tmp; - - tmp=memchr(line.text,'\n',line.length); - ck_fwrite(line.text, 1, - tmp ? tmp - line.text + 1 - : line.length, stdout); - } - break; - - case 'q': quit: - quit_cmd++; - end_cycle++; - break; - - case 'r': - { - int n = 0; - - rewind(cur_cmd->x.io_file); - do { - append.length += n; - if(append.length==append.alloc) { - append.alloc *= 2; - append.text = ck_realloc(append.text, append.alloc); - } - } while((n=fread(append.text+append.length,sizeof(char),append.alloc-append.length,cur_cmd->x.io_file))>0); - if(ferror(cur_cmd->x.io_file)) - panic("Read error on input file to 'r' command"); - } - break; - - case 's': - if(!tmp.alloc) { - tmp.alloc=50; - tmp.text=ck_malloc(50); - } - count=0; - start = 0; - remain=line.length-1; - tmp.length=0; - rep = cur_cmd->x.cmd_regex.replacement; - rep_end=rep+cur_cmd->x.cmd_regex.replace_length; - - while((offset = re_search(cur_cmd->x.cmd_regex.regx, - line.text, - line.length-1, - start, - remain, - ®s))>=0) { - count++; - if(offset-start) - str_append(&tmp,line.text+start,offset-start); - - if(cur_cmd->x.cmd_regex.flags&S_NUM_BIT) { - if(count!=cur_cmd->x.cmd_regex.numb) { - str_append(&tmp,line.text+regs.start[0],regs.end[0]-regs.start[0]); - start = (offset == regs.end[0] ? offset + 1 : regs.end[0]); - remain = (line.length-1) - start; - continue; - } - } - - for(rep_next=rep_cur=rep;rep_next<rep_end;rep_next++) { - if(*rep_next=='&') { - if(rep_next-rep_cur) - str_append(&tmp,rep_cur,rep_next-rep_cur); - str_append(&tmp,line.text+regs.start[0],regs.end[0]-regs.start[0]); - rep_cur=rep_next+1; - } else if(*rep_next=='\\') { - if(rep_next-rep_cur) - str_append(&tmp,rep_cur,rep_next-rep_cur); - rep_next++; - if(rep_next!=rep_end) { - int n; - - if(*rep_next>='0' && *rep_next<='9') { - n= *rep_next -'0'; - str_append(&tmp,line.text+regs.start[n],regs.end[n]-regs.start[n]); - } else - str_append(&tmp,rep_next,1); - } - rep_cur=rep_next+1; - } - } - if(rep_next-rep_cur) - str_append(&tmp,rep_cur,rep_next-rep_cur); - if (offset == regs.end[0]) { - str_append(&tmp, line.text + offset, 1); - ++regs.end[0]; - } - start = regs.end[0]; - - remain = (line.length-1) - start; - if(remain<0) - break; - if(!(cur_cmd->x.cmd_regex.flags&S_GLOBAL_BIT)) - break; - } - if(!count) - break; - replaced=1; - str_append(&tmp,line.text+start,remain+1); - t.text=line.text; - t.length=line.length; - t.alloc=line.alloc; - line.text=tmp.text; - line.length=tmp.length; - line.alloc=tmp.alloc; - tmp.text=t.text; - tmp.length=t.length; - tmp.alloc=t.alloc; - if(cur_cmd->x.cmd_regex.flags&S_WRITE_BIT) - ck_fwrite(line.text,1,line.length,cur_cmd->x.cmd_regex.wio_file); - if(cur_cmd->x.cmd_regex.flags&S_PRINT_BIT) - ck_fwrite(line.text,1,line.length,stdout); - break; - - case 't': - if(replaced) { - replaced = 0; - if(!cur_cmd->x.jump) - end_cycle++; - else { - struct sed_label *j = cur_cmd->x.jump; - - n= j->v->v_length - j->v_index; - cur_cmd= j->v->v + j->v_index; - goto exe_loop; - } - } - break; - - case 'w': - ck_fwrite(line.text,1,line.length,cur_cmd->x.io_file); - break; - - case 'x': - { - struct line tmp; - - tmp=line; - line=hold; - hold=tmp; - } - break; - - case 'y': - { - unsigned char *p,*e; - - for(p=(unsigned char *)(line.text),e=p+line.length;p<e;p++) - *p=cur_cmd->x.translate[*p]; - } - break; - - default: - panic("INTERNAL ERROR: Bad cmd %c",cur_cmd->cmd); - } - if(end_cycle) - break; - } -} - - -/* Return non-zero if the current line matches the address - pointed to by 'addr'. */ -int -match_address(addr) -struct addr *addr; -{ - switch(addr->addr_type) { - case ADDR_NULL: - return 1; - case ADDR_NUM: - return (input_line_number==addr->addr_number); - - case ADDR_REGEX: - return (re_search(addr->addr_regex, - line.text, - line.length-1, - 0, - line.length-1, - (struct re_registers *)0)>=0) ? 1 : 0; - - case ADDR_LAST: - return (input_EOF) ? 1 : 0; - - default: - panic("INTERNAL ERROR: bad address type"); - break; - } - return -1; -} - -/* Read in the next line of input, and store it in the - pattern space. Return non-zero if this is the last line of input */ - -int -read_pattern_space() -{ - int n; - char *p; - int ch; - - p=line.text; - n=line.alloc; - - if(feof(input_file)) - return 0; - input_line_number++; - replaced=0; - for(;;) { - if(n==0) { - line.text=ck_realloc(line.text,line.alloc*2); - p=line.text+line.alloc; - n=line.alloc; - line.alloc*=2; - } - ch=getc(input_file); - if(ch==EOF) { - if(n==line.alloc) - return 0; - *p++='\n'; - --n; - line.length=line.alloc-n; - if(last_input_file) - input_EOF++; - return 1; - } - *p++=ch; - --n; - if(ch=='\n') { - line.length=line.alloc-n; - break; - } - } - ch=getc(input_file); - if(ch!=EOF) - ungetc(ch,input_file); - else if(last_input_file) - input_EOF++; - return 1; -} - -/* Inplement the 'N' command, which appends the next line of input to - the pattern space. */ -void -append_pattern_space() -{ - char *p; - int n; - int ch; - - p=line.text+line.length; - n=line.alloc-line.length; - - input_line_number++; - replaced=0; - for(;;) { - ch=getc(input_file); - if(ch==EOF) { - if(n==line.alloc) - return; - *p++='\n'; - --n; - line.length=line.alloc-n; - if(last_input_file) - input_EOF++; - return; - } - *p++=ch; - --n; - if(ch=='\n') { - line.length=line.alloc-n; - break; - } - if(n==0) { - line.text=ck_realloc(line.text,line.alloc*2); - p=line.text+line.alloc; - n=line.alloc; - line.alloc*=2; - } - } - ch=getc(input_file); - if(ch!=EOF) - ungetc(ch,input_file); - else if(last_input_file) - input_EOF++; -} - -/* Copy the contents of the line 'from' into the line 'to'. - This destroys the old contents of 'to'. It will still work - if the line 'from' contains nulls. */ -void -line_copy(from,to) -struct line *from,*to; -{ - if(from->length>to->alloc) { - to->alloc=from->length; - to->text=ck_realloc(to->text,to->alloc); - } - bcopy(from->text,to->text,from->length); - to->length=from->length; -} - -/* Append the contents of the line 'from' to the line 'to'. - This routine will work even if the line 'from' contains nulls */ -void -line_append(from,to) -struct line *from,*to; -{ - if(from->length>(to->alloc-to->length)) { - to->alloc+=from->length; - to->text=ck_realloc(to->text,to->alloc); - } - bcopy(from->text,to->text+to->length,from->length); - to->length+=from->length; -} - -/* Append 'length' bytes from 'string' to the line 'to' - This routine *will* append bytes with nulls in them, without - failing. */ -void -str_append(to,string,length) -struct line *to; -char *string; -int length; -{ - if(length>to->alloc-to->length) { - to->alloc+=length; - to->text=ck_realloc(to->text,to->alloc); - } - bcopy(string,to->text+to->length,length); - to->length+=length; -} - -void -usage() -{ - fprintf(stderr, "\ -Usage: %s [-nV] [+quiet] [+silent] [+version] [-e script] [-f script-file]\n\ - [+expression=script] [+file=script-file] [file...]\n", myname); - exit(4); -} diff --git a/usr.bin/sed/utils.c b/usr.bin/sed/utils.c deleted file mode 100644 index 2d39cfc9cbb0..000000000000 --- a/usr.bin/sed/utils.c +++ /dev/null @@ -1,359 +0,0 @@ -/* Functions from hack's utils library. - 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. */ - -/* These routines were written as part of a library (by hack), but since most - people don't have the library, here they are. */ - -#ifdef __STDC__ -#define VOID void -#else -#define VOID char -#endif - -#include <stdio.h> -#if defined(USG) || defined(STDC_HEADERS) -#include <string.h> -#define bcopy(src, dst, len) memcpy((dst), (src), (len)) -#else -#endif -#if defined(STDC_HEADERS) -#include <stdlib.h> -#else -VOID *malloc(); -VOID *realloc(); -#endif - -VOID *ck_malloc(); - -char *myname; - -#ifdef __STDC__ -#include <stdarg.h> - -/* Print an error message and exit */ -void -panic(char *str, ...) -{ - va_list iggy; - - fprintf(stderr,"%s: ",myname); - va_start(iggy,str); -#ifdef NO_VFPRINTF - _doprnt(str,&iggy,stderr); -#else - vfprintf(stderr,str,iggy); -#endif - va_end(iggy); - putc('\n',stderr); - exit(4); -} - -#else -#include <varargs.h> - -void -panic(str,va_alist) -char *str; -va_dcl -{ - va_list iggy; - - fprintf(stderr,"%s: ",myname); - va_start(iggy); -#ifdef NO_VFPRINTF - _doprnt(str,&iggy,stderr); -#else - vfprintf(stderr,str,iggy); -#endif - va_end(iggy); - putc('\n',stderr); - exit(4); -} - -#endif - -/* Store information about files opened with ck_fopen - so that error messages from ck_fread, etc can print the - name of the file that had the error */ -#define N_FILE 32 - -struct id { - FILE *fp; - char *name; -}; - -static struct id __id_s[N_FILE]; - -/* Internal routine to get a filename from __id_s */ -char * -__fp_name(fp) -FILE *fp; -{ - int n; - - for(n=0;n<N_FILE;n++) { - if(__id_s[n].fp==fp) - return __id_s[n].name; - } - return "{Unknown file pointer}"; -} - -/* Panic on failing fopen */ -FILE * -ck_fopen(name,mode) -char *name; -char *mode; -{ - FILE *ret; - int n; - - ret=fopen(name,mode); - if(ret==(FILE *)0) - panic("Couldn't open file %s",name); - for(n=0;n<N_FILE;n++) { - if(ret==__id_s[n].fp) { - free((VOID *)__id_s[n].name); - __id_s[n].name=(char *)ck_malloc(strlen(name)+1); - strcpy(__id_s[n].name,name); - break; - } - } - if(n==N_FILE) { - for(n=0;n<N_FILE;n++) - if(__id_s[n].fp==(FILE *)0) - break; - if(n==N_FILE) - panic("Internal error: too many files open"); - __id_s[n].fp=ret; - __id_s[n].name=(char *)ck_malloc(strlen(name)+1); - strcpy(__id_s[n].name,name); - } - return ret; -} - -/* Panic on failing fwrite */ -void -ck_fwrite(ptr,size,nmemb,stream) -char *ptr; -int size,nmemb; -FILE *stream; -{ - if(fwrite(ptr,size,nmemb,stream)!=nmemb) - panic("couldn't write %d items to %s",nmemb,__fp_name(stream)); -} - -/* Panic on failing fclose */ -void -ck_fclose(stream) -FILE *stream; -{ - if(fclose(stream)==EOF) - panic("Couldn't close %s",__fp_name(stream)); -} - -/* Panic on failing malloc */ -VOID * -ck_malloc(size) -int size; -{ - VOID *ret; - - if(!size) - size++; - ret=malloc(size); - if(ret==(VOID *)0) - panic("Couldn't allocate memory"); - return ret; -} - -/* Panic on failing realloc */ -VOID * -ck_realloc(ptr,size) -VOID *ptr; -int size; -{ - VOID *ret; - - ret=realloc(ptr,size); - if(ret==(VOID *)0) - panic("Couldn't re-allocate memory"); - return ret; -} - -/* Return a malloc()'d copy of a string */ -char * -ck_strdup(str) -char *str; -{ - char *ret; - - ret=(char *)ck_malloc(strlen(str)+2); - strcpy(ret,str); - return ret; -} - -#if !defined(USG) && !defined(STDC_HEADERS) -/* - * memchr - search for a byte - * - */ - -VOID * -memchr(s, ucharwanted, size) -VOID *s; -int ucharwanted; -int size; -{ - register char *scan; - register n; - register uc; - - scan = (char *)s; - uc = (ucharwanted&0xFF); - for (n = size; n > 0; n--) - if (((*scan)&0xFF) == uc) - return((VOID *)scan); - else - scan++; - - return 0; -} -#endif - -#if !defined(STDC_HEADERS) -/* - * memmove - copy bytes, being careful about overlap. - */ - -VOID * -memmove(dst, src, size) -VOID *dst; -VOID *src; -int size; -{ - register char *d; - register char *s; - register int n; - - if (size <= 0) - return(dst); - - s = (char *)src; - d = (char *)dst; - if (s <= d && s + (size-1) >= d) { - /* Overlap, must copy right-to-left. */ - s += size-1; - d += size-1; - for (n = size; n > 0; n--) - *d-- = *s--; - } else - for (n = size; n > 0; n--) - *d++ = *s++; - - return(dst); -} -#endif - -/* Implement a variable sized buffer of 'stuff'. We don't know what it is, - nor do we care, as long as it doesn't mind being aligned by malloc. */ - -struct buffer { - int allocated; - int length; - char *b; -}; - -#define MIN_ALLOCATE 50 - -VOID * -init_buffer() -{ - struct buffer *b; - - b=(struct buffer *)ck_malloc(sizeof(struct buffer)); - b->allocated=MIN_ALLOCATE; - b->b=(char *)ck_malloc(MIN_ALLOCATE); - b->length=0; - return (VOID *)b; -} - -void -flush_buffer(bb) -VOID *bb; -{ - struct buffer *b; - - b=(struct buffer *)bb; - free(b->b); - b->b=0; - b->allocated=0; - b->length=0; - free(b); -} - -int -size_buffer(b) -VOID *b; -{ - struct buffer *bb; - - bb=(struct buffer *)b; - return bb->length; -} - -void -add_buffer(bb,p,n) -VOID *bb; -char *p; -int n; -{ - struct buffer *b; - - b=(struct buffer *)bb; - if(b->length+n>b->allocated) { - b->allocated*=2; - b->b=(char *)ck_realloc(b->b,b->allocated); - } - bcopy(p,b->b+b->length,n); - b->length+=n; -} - -void -add1_buffer(bb,ch) -VOID *bb; -int ch; -{ - struct buffer *b; - - b=(struct buffer *)bb; - if(b->length+1>b->allocated) { - b->allocated*=2; - b->b=(char *)ck_realloc(b->b,b->allocated); - } - b->b[b->length]=ch; - b->length++; -} - -char * -get_buffer(bb) -VOID *bb; -{ - struct buffer *b; - - b=(struct buffer *)bb; - return b->b; -} diff --git a/usr.bin/vi/docs/structures b/usr.bin/vi/docs/structures deleted file mode 100644 index d49ab65cbeed..000000000000 --- a/usr.bin/vi/docs/structures +++ /dev/null @@ -1,61 +0,0 @@ -# @(#)structures 5.2 (Berkeley) 11/1/93 - -There are three major data structures in this package. The first is a -single global structure (named GS) which contains information common to -all files and screens. It's really pretty tiny, and functions more as a -single place to hang things than anything else. - -The second and third structures are the file structures (named EXF) and -the screen structures (named SCR). They contain information theoretically -unique to a screen or file, respectively. Each SCR structure has a set -of functions which update the screen and/or return information about the -screen from the underlying screen package. - -The GS structure contains linked lists SCR structures. The structures -can also be classed by persistence. The GS structure never goes away -and the SCR structure persists over instances of files. - -File names have different properties than files themselves, so the name -information for a file is held in an FREF structure which is chained from -the SCR structure. - -In general, functions are always passed an SCR structure and often an EXF -structure as well. The SCR structure is necessary for any routine that -wishes to talk to the screen, the EXF structure is necessary for any -routine that wants to modify the file. The relationship between an SCR -structure and its underlying EXF structure is not fixed, and although you -can translate from an SCR to the underlying EXF, it is discouraged. If -this becomes too onerous, I suspect I'll just stop passing around the EXF -in the future. - -The naming of the structures is consistent across the program. (Macros -even depend on it, so don't try and change it!) The global structure is -"gp", the screen structure is "sp", and the file structure is "ep". - -A few other data structures: - -TEXT In nvi/cut.h. This structure describes a portion of a line, - and is used by the input routines and as the "line" part of a - cut buffer. - -CB In nvi/cut.h. A cut buffer. A cut buffer is a place to - hang a list of TEXT structures. - -MARK In nvi/mark.h. A cursor position, consisting of a line number - and a column number. - -MSG In nvi/msg.h. A chain of messages for the user. - -SEQ In nvi/seq.h. An abbreviation or a map entry. - -EXCMDARG - In nvi/ex/excmd.h.stub. The structure that gets passed around - to the functions that implement the ex commands. (The main - ex command loop (see nvi/ex/ex.c) builds this up and then passes - it to the ex functions.) - -VICMDARG - In nvi/vi/vcmd.h. The structure that gets passed around to the - functions that implement the vi commands. (The main vi command - loop (see nvi/vi/vi.c) builds this up and then passes it to the - vi functions.) diff --git a/usr.bin/vi/docs/vi.ref.ps b/usr.bin/vi/docs/vi.ref.ps deleted file mode 100644 index b5cc15e64fc8..000000000000 --- a/usr.bin/vi/docs/vi.ref.ps +++ /dev/null @@ -1,1108 +0,0 @@ -%!PS-Adobe-3.0 -%%Creator: groff version 1.08 -%%DocumentNeededResources: font Times-Roman -%%+ font Times-Bold -%%+ font Courier-Bold -%%+ font Symbol -%%+ font Courier -%%+ font Times-Italic -%%DocumentSuppliedResources: procset grops 1.08 0 -%%Pages: 10 -%%PageOrder: Ascend -%%Orientation: Portrait -%%EndComments -%%BeginProlog -%%BeginResource: procset grops 1.08 0 -/setpacking where{ -pop -currentpacking -true setpacking -}if -/grops 120 dict dup begin -/SC 32 def -/A/show load def -/B{0 SC 3 -1 roll widthshow}bind def -/C{0 exch ashow}bind def -/D{0 exch 0 SC 5 2 roll awidthshow}bind def -/E{0 rmoveto show}bind def -/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def -/G{0 rmoveto 0 exch ashow}bind def -/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/I{0 exch rmoveto show}bind def -/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def -/K{0 exch rmoveto 0 exch ashow}bind def -/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/M{rmoveto show}bind def -/N{rmoveto 0 SC 3 -1 roll widthshow}bind def -/O{rmoveto 0 exch ashow}bind def -/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/Q{moveto show}bind def -/R{moveto 0 SC 3 -1 roll widthshow}bind def -/S{moveto 0 exch ashow}bind def -/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/SF{ -findfont exch -[exch dup 0 exch 0 exch neg 0 0]makefont -dup setfont -[exch/setfont cvx]cvx bind def -}bind def -/MF{ -findfont -[5 2 roll -0 3 1 roll -neg 0 0]makefont -dup setfont -[exch/setfont cvx]cvx bind def -}bind def -/level0 0 def -/RES 0 def -/PL 0 def -/LS 0 def -/PLG{ -gsave newpath clippath pathbbox grestore -exch pop add exch pop -}bind def -/BP{ -/level0 save def -1 setlinecap -1 setlinejoin -72 RES div dup scale -LS{ -90 rotate -}{ -0 PL translate -}ifelse -1 -1 scale -}bind def -/EP{ -level0 restore -showpage -}bind def -/DA{ -newpath arcn stroke -}bind def -/SN{ -transform -.25 sub exch .25 sub exch -round .25 add exch round .25 add exch -itransform -}bind def -/DL{ -SN -moveto -SN -lineto stroke -}bind def -/DC{ -newpath 0 360 arc closepath -}bind def -/TM matrix def -/DE{ -TM currentmatrix pop -translate scale newpath 0 0 .5 0 360 arc closepath -TM setmatrix -}bind def -/RC/rcurveto load def -/RL/rlineto load def -/ST/stroke load def -/MT/moveto load def -/CL/closepath load def -/FL{ -currentgray exch setgray fill setgray -}bind def -/BL/fill load def -/LW/setlinewidth load def -/RE{ -findfont -dup maxlength 1 index/FontName known not{1 add}if dict begin -{ -1 index/FID ne{def}{pop pop}ifelse -}forall -/Encoding exch def -dup/FontName exch def -currentdict end definefont pop -}bind def -/DEFS 0 def -/EBEGIN{ -moveto -DEFS begin -}bind def -/EEND/end load def -/CNT 0 def -/level1 0 def -/PBEGIN{ -/level1 save def -translate -div 3 1 roll div exch scale -neg exch neg exch translate -0 setgray -0 setlinecap -1 setlinewidth -0 setlinejoin -10 setmiterlimit -[]0 setdash -/setstrokeadjust where{ -pop -false setstrokeadjust -}if -/setoverprint where{ -pop -false setoverprint -}if -newpath -/CNT countdictstack def -userdict begin -/showpage{}def -}bind def -/PEND{ -clear -countdictstack CNT sub{end}repeat -level1 restore -}bind def -end def -/setpacking where{ -pop -setpacking -}if -%%EndResource -%%IncludeResource: font Times-Roman -%%IncludeResource: font Times-Bold -%%IncludeResource: font Courier-Bold -%%IncludeResource: font Symbol -%%IncludeResource: font Courier -%%IncludeResource: font Times-Italic -grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL -792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron/scaron/zcaron -/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef/.notdef/.notdef -/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef -/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/space -/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright/parenleft -/parenright/asterisk/plus/comma/hyphen/period/slash/zero/one/two/three/four -/five/six/seven/eight/nine/colon/semicolon/less/equal/greater/question/at/A/B/C -/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash -/bracketright/circumflex/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q -/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase -/guillemotleft/guillemotright/bullet/florin/fraction/perthousand/dagger -/daggerdbl/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut -/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash -/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar -/section/dieresis/copyright/ordfeminine/guilsinglleft/logicalnot/minus -/registered/macron/degree/plusminus/twosuperior/threesuperior/acute/mu -/paragraph/periodcentered/cedilla/onesuperior/ordmasculine/guilsinglright -/onequarter/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde -/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute -/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis -/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls -/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute -/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve -/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex -/udieresis/yacute/thorn/ydieresis]def/Times-Italic@0 ENC0/Times-Italic RE -/Courier@0 ENC0/Courier RE/Courier-Bold@0 ENC0/Courier-Bold RE/Times-Bold@0 -ENC0/Times-Bold RE/Times-Roman@0 ENC0/Times-Roman RE -%%EndProlog -%%Page: 1 1 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(EX/VI REFERENCE MANU)72 48 Q -.834(AL \( 1 \))-.4 F -(BSD Reference Manual)258.235 48 Q(EX/VI REFERENCE MANU)390.972 48 Q -.834 -(AL \( 1 \))-.4 F/F1 10/Times-Bold@0 SF -.2(NA)72 108 S(ME).2 E/F2 10 -/Courier-Bold@0 SF(ex, vi, view)102 120 Q F0 2.5<ad74>2.5 G -.15(ex)187.42 120 -S 2.5(te).15 G(ditors)206.43 120 Q F1(DESCRIPTION)72 144 Q F2(Vi)102 156 Q F0 -.176(is a screen oriented te)2.676 F .176(xt editor)-.15 F(.)-.55 E F2(Ex)5.176 -E F0 .176(is a line-oriented te)2.676 F .175(xt editor)-.15 F(.)-.55 E F2(Ex) -5.175 E F0(and)2.675 E F2(vi)2.675 E F0 .175(are dif)2.675 F .175 -(ferent interf)-.25 F .175(aces to the)-.1 F .56(same program, and it is possi\ -ble to switch back and forth during an edit session.)102 168 R F2(View)5.561 E -F0 .561(is the equi)3.061 F -.25(va)-.25 G .561(lent of).25 F(using the)102 180 -Q F2<ad52>4.166 E F0(\(read-only\) option of)2.5 E F2(vi)2.5 E F0(.)A .004 -(This reference manual is the one pro)102 198 R .004(vided with the)-.15 F F2 -(nex/nvi)2.504 E F0 -.15(ve)2.504 G .004(rsions of the).15 F F2(ex/vi)2.503 E -F0(te)2.503 E .003(xt editors.)-.15 F F2(Nex/nvi)5.003 E F0 .55 -(are intended as b)102 210 R(ug-for)-.2 E(-b)-.2 E .55 -(ug compatible replacements for the original F)-.2 F .55(ourth Berk)-.15 F(ele) --.1 E 3.05(yS)-.15 G(oftw)458.37 210 Q .55(are Distrib)-.1 F(ution)-.2 E -(\(4BSD\))102 222 Q F2(ex)3.804 E F0(and)3.804 E F2(vi)3.804 E F0 3.804 -(programs. This)3.804 F 1.303 -(reference manual is accompanied by a traditional-style manual page.)3.804 F -.399(That manual page describes the functionality found in)102 234 R F2(ex/vi) -2.899 E F0 .399(in f)2.899 F .399(ar less detail than the description here.)-.1 -F(In)5.399 E 1.211(addition, it describes the system interf)102 246 R 1.211 -(ace to)-.1 F F2(ex/vi)3.711 E F0 3.711(,e)C 1.211 -(.g. command line options, en)329.338 246 R 1.21(vironmental v)-.4 F(ariables,) --.25 E(and similar things.)102 258 Q .087 -(This reference is intended for users already f)102 276 R .087(amiliar with)-.1 -F F2(ex/vi)2.588 E F0 2.588(.A)C -.15(ny)374.652 276 S .088 -(one else should almost certainly read a).15 F .266 -(good tutorial on the editor \214rst.)102 288 R .266(If you')5.266 F .266 -(re in an unf)-.5 F .265(amiliar en)-.1 F .265 -(vironment, and you absolutely ha)-.4 F .565 -.15(ve t)-.2 H 2.765(og).15 G -.265(et w)509.565 288 R(ork)-.1 E .354(done immediately)102 300 R 2.854(,s)-.65 -G .354(ee the section entitled F)182.888 300 R .354(AST ST)-.74 F(AR)-.93 E -.354(TUP in the manual page.)-.6 F(It')5.355 E 2.855(sp)-.55 G .355 -(robably enough to get)451.445 300 R(you going.)102 312 Q -.15(Fo)102 330 S -3.261(rt).15 G .761(he rest of this reference,)121.781 330 R F2(nex/nvi)3.261 E -F0 .761(is used only when it')3.261 F 3.26(sn)-.55 G .76 -(ecessary to distinguish it from the historic)367.67 330 R(implementations of) -102 342 Q F2(ex/vi)2.5 E F0(.)A F1(ADDITION)72 366 Q 1.666(AL FEA)-.2 F(TURES) --.95 E F0 .616(There are a fe)102 378 R 3.116(wf)-.25 G .616(eatures in)172.504 -378 R F2(nex/nvi)3.116 E F0 .616(that are not found in historic v)3.116 F .616 -(ersions of)-.15 F F2(ex/vi)3.116 E F0 3.116(.Al)C .616(ist of those fea-) -476.222 378 R(tures is as follo)102 390 Q(ws:)-.25 E(8-bit clean data, lar)102 -408 Q(ge lines, \214les)-.18 E F2(Nvi/nex)143 420 Q F0 .864(will edit an)3.364 -F 3.364(yf)-.15 G .864(ormat \214le.)246.636 420 R .863 -(Line lengths are limited by a)5.863 F -.25(va)-.2 G .863(ilable memory).25 F -3.363(,a)-.65 G .863(nd \214le sizes)491.054 420 R .511(are limited by a)143 -432 R -.25(va)-.2 G .511(ilable disk space.).25 F .512(The command `)5.511 F -(`^Vx[0-9A-F)-.74 E(a-f])-.15 E/F3 10/Symbol SF(*)A F0 -.74('')C 3.012(,i).74 G -3.012(ni)439.892 432 S .512(nput mode, will insert)450.684 432 R(an)143 444 Q -2.5(yl)-.15 G -2.25 -.15(eg a)162.57 444 T 2.5(lc).15 G(haracter v)185.97 444 Q -(alue into the te)-.25 E(xt.)-.15 E(Split screens)102 462 Q .036(The command `) -143 474 R .036(`:sp[lit] [\214le ...]')-.74 F 2.536('s)-.74 G .036 -(plits the screen in vi mode.)280.01 474 R .035(The k)5.035 F .335 -.15(ey `) --.1 H(`^W')-.59 E 2.535('s)-.74 G .035(witches between the)458.84 474 R(fore) -143 486 Q .747(ground screens, and the `)-.15 F .747(`:resize count')-.74 F -3.247('c)-.74 G .747(ommand can be used to gro)329.952 486 R 3.248(wo)-.25 G -3.248(rs)459.166 486 S .748(hrink a particular)469.634 486 R(screen.)143 498 Q -(Background and fore)102 516 Q(ground screens)-.15 E .921(The command `)143 528 -R(`:bg')-.74 E 3.421('b)-.74 G .921 -(ackgrounds the current screen, and the command `)237.873 528 R .92 -(`:fg [\214le]')-.74 F 3.42('f)-.74 G(ore)495.16 528 Q(grounds)-.15 E .097 -(the backgrounded screen that is editing the speci\214ed \214le, or)143 540 R -2.597(,b)-.4 G 2.598(yd)391.31 540 S(ef)403.908 540 Q .098 -(ault, the \214rst background screen)-.1 F(on the queue.)143 552 Q -(The command `)5 E(`:di[splay] s[creens]')-.74 E 2.5('l)-.74 G -(ists the background screens.)355.63 552 Q(Shell screens)102 570 Q .128 -(The command `)143 582 R .128(`:sc[ript] [\214le ...]')-.74 F 2.628('r)-.74 G -.128(uns a shell in the screen.)284.9 582 R .127 -(Editing is unchanged, with the e)5.127 F(xcep-)-.15 E -(tion that a <carriage-return> enters the current line \(stripped of an)143 594 -Q 2.5(yp)-.15 G(rompt\) as input to the shell.)418.78 594 Q -.8(Ta)102 612 S -2.5(gs).8 G(tacks)123.14 612 Q -.8(Ta)143 624 S .234(gs are no).8 F 2.734(wm) --.25 G .234(aintained in a stack.)206.802 624 R .234(The command `)5.234 F -(`^T')-.74 E 2.734('r)-.74 G .235(eturns to the pre)379.97 624 R .235 -(vious tag location.)-.25 F(The)5.235 E .251(command `)143 636 R .251 -(`:tagpop [number)-.74 F(\214le]')7.168 E 2.751('r)-.74 G .251 -(eturns to the most recent tag location by def)293.021 636 R .251(ault, or)-.1 -F 2.75(,o)-.4 G(ptional-)508.89 636 Q .45(ly to a speci\214c tag number in the\ - tag stack, or the most recent tag from the speci\214ed \214le.)143 648 R .45 -(Use the)5.45 F .186(command `)143 660 R .186(`:di[splay] t[ags]')-.74 F 2.686 -('t)-.74 G 2.686(ov)266.218 660 S(ie)278.904 660 Q 2.686(wt)-.25 G .185 -(he tags stack.)298.56 660 R .185(The command `)5.185 F(`:tagtop')-.74 E 2.685 -('r)-.74 G .185(eturns to the top of)463.71 660 R(the tag stack.)143 672 Q(Ne) -102 690 Q 2.5(wd)-.25 G(isplays)128.13 690 Q 1.268(The command `)143 702 R -1.268(`:di[splay] b[uf)-.74 F 6.702(fers] s[creens] t[ags]')-.25 F 3.768('c) --.74 G 1.269(an be used to display)379.666 702 R 3.769(,r)-.65 G(especti) -477.571 702 Q -.15(ve)-.25 G(ly).15 E 3.769(,t)-.65 G(he)530.56 702 Q 167.75 -(4.4BSD March)72 750 R(18, 1994)2.5 E(1)535 750 Q EP -%%Page: 2 2 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(EX/VI REFERENCE MANU)72 48 Q -.834(AL \( 1 \))-.4 F -(BSD Reference Manual)258.235 48 Q(EX/VI REFERENCE MANU)390.972 48 Q -.834 -(AL \( 1 \))-.4 F(current cut b)143 96 Q(uf)-.2 E -(fers, the backgrounded screens, and the tags stack.)-.25 E(In\214nite undo)102 -114 Q 1.052(The changes made during an edit session may be rolled backw)143 126 -R 1.051(ard and forw)-.1 F 3.551(ard. A)-.1 F('.)3.551 E 3.551('c)-.7 G(ommand) -505 126 Q .369(immediately after a 'u' command continues either forw)143 138 R -.369(ard or backw)-.1 F .37(ard depending on whether the)-.1 F('u' command w) -143 150 Q(as an undo or a redo.)-.1 E(Usage information)102 168 Q .412 -(The command `)143 180 R(`:e)-.74 E .412(xu[sage] [cmd]')-.15 F 2.912('a)-.74 G -.412(nd `)291.298 180 R .412(`viu[sage] [k)-.74 F -.15(ey)-.1 G(]').15 E 2.912 -('p)-.74 G(ro)384.934 180 Q .411(vide usage information for all of the)-.15 F -.3 -.15(ex a)143 192 T(nd vi commands by def).15 E(ault, or)-.1 E 2.5(,o)-.4 G -(ptionally)290.94 192 Q 2.5(,f)-.65 G(or a speci\214c command or k)334.18 192 Q --.15(ey)-.1 G(.)-.5 E(Extended re)102 210 Q(gular e)-.15 E(xpressions)-.15 E -.811(The `)143 222 R .811(`:set e)-.74 F(xtended')-.15 E 3.311('c)-.74 G .812 -(ommand treats search and other command re)234.603 222 R .812(gular e)-.15 F -.812(xpressions as e)-.15 F(xtended)-.15 E(\(e)143 234 Q(grep\(1\) style\) re) --.15 E(gular e)-.15 E(xpressions.)-.15 E -.8(Wo)102 252 S(rd search).8 E -(The command `)143 264 Q(`^A')-.74 E 2.5('s)-.74 G(earches for the w)231.77 264 -Q(ord referenced by the cursor)-.1 E(.)-.55 E(Number increment)102 282 Q -(The command `)143 294 Q(`#')-.74 E 2.5('i)-.74 G -(ncrements the number referenced by the cursor)225.11 294 Q(.)-.55 E(Pre)102 -312 Q(vious \214le)-.25 E(The command `)143 324 Q(`:pre)-.74 E(v[ious][!]')-.25 -E 2.5('e)-.74 G(dits the pre)275.39 324 Q(vious \214le from the ar)-.25 E -(gument list.)-.18 E(Left-Right scrolling)102 342 Q .734(The command `)143 354 -R .733(`:set leftright')-.74 F 3.233('m)-.74 G(ak)276.653 354 Q(es)-.1 E/F1 10 -/Courier-Bold@0 SF(nvi)3.233 E F0 .733 -(do left-right screen scrolling, instead of the traditional)3.233 F F1(vi)143 -366 Q F0(line wrapping.)2.5 E/F2 10/Times-Bold@0 SF(RECO)72 390 Q(VER)-.5 E(Y) --.35 E F0 .128(There is no reco)102 402 R -.15(ve)-.15 G .128(ry program for) -.15 F F1(nvi)2.628 E F0 2.628(,n)C .128(or does)266.106 402 R F1(nvi)2.628 E F0 -.128(run setuid.)2.628 F .129(Users may reco)5.129 F -.15(ve)-.15 G 2.629(ra) -.15 G .429 -.15(ny \214)448.124 402 T .129(le which the).15 F 2.629(ym)-.15 G -(ay)530.56 402 Q(read, and the superuser may reco)102 414 Q -.15(ve)-.15 G 2.5 -(ra).15 G .3 -.15(ny e)253.03 414 T(dit session.).15 E 2.995 -(Edit sessions are back)102 432 R 2.994(ed by \214les in)-.1 F/F3 10/Courier@0 -SF(/var/tmp/vi.recover)5.494 E F0 5.494(,a)C 2.994(nd are named `)391.224 432 R -(`vi.XXXX')-.74 E 2.994(', where)-.74 F -.74(``)102 444 S(XXXX').74 E 3.104('i) --.74 G 3.104(san)148.604 444 S .605(umber related to the process id.)168.142 -444 R .605 -(When a \214le is \214rst modi\214ed, a second \214le, which contains)5.605 F -.185(an email message for the user)102 456 R 2.685(,i)-.4 G 2.685(sc)229.07 456 -S .185(reated, and is named `)240.085 456 R(`reco)-.74 E -.15(ve)-.15 G -.55 -(r.).15 G(XXXX').55 E .185(', where, ag)-.74 F .185(ain, `)-.05 F(`XXXX')-.74 E -2.685('i)-.74 G 2.685(sa)505.655 456 S(ssoci-)516.67 456 Q .098 -(ated with the process id.)102 468 R .098(Both \214les are remo)5.098 F -.15 -(ve)-.15 G 2.599(da).15 G 2.599(tt)302.273 468 S .099 -(he end of a normal edit session, b)310.432 468 R .099 -(ut will remain if the ed-)-.2 F 2.248 -(it session is abnormally terminated or the user enters the e)102 480 R 2.248 -(x/vi `)-.15 F(`preserv)-.74 E(e')-.15 E 4.748('c)-.74 G 4.748(ommand. The) -431.578 480 R 2.248(use of the)4.748 F F3(/var/tmp)102 492 Q F0 -(directory may be changed setting the)2.5 E F2 -.18(re)2.5 G(cdir).18 E F0 -(option in the user')2.5 E 2.5(so)-.55 G 2.5(rs)414.78 492 S -(ystem startup information.)424.5 492 Q .143(The reco)102 510 R -.15(ve)-.15 G -.143(ry directory should ha).15 F .443 -.15(ve t)-.2 H .143(he `).15 F(`stick) --.74 E(y-bit')-.15 E 2.643('s)-.74 G .143(et so that only the o)317.611 510 R -.144(wners of \214les may remo)-.25 F .444 -.15(ve t)-.15 H 2.644(hem. If).15 F -.106(this is not possible on the system, then a pseudo-user should o)102 522 R -.106(wn the reco)-.25 F -.15(ve)-.15 G .106(ry directory).15 F 5.106(.T)-.65 G -.105(he reco)467.35 522 R -.15(ve)-.15 G .105(ry direc-).15 F -(tory must be both read and write-able by an)102 534 Q 2.5(yu)-.15 G(ser)288.76 -534 Q(.)-.55 E .601(The reco)102 552 R -.15(ve)-.15 G .601(ry \214le has all o\ -f the necessary information in it to enable the user to reco).15 F -.15(ve)-.15 -G 3.101(rt).15 G .601(he edit session.)464.037 552 R(In)5.601 E .322 -(addition, it has all of the necessary email headers for sendmail.)102 564 R -.322(When the system is rebooted, all of the \214les)5.322 F(in)102 576 Q F3 -(/var/tmp/vi.recover)2.694 E F0 .194(named `)2.694 F(`reco)-.74 E -.15(ve)-.15 -G -.55(r.).15 G(XXXX').55 E 2.694('s)-.74 G .195 -(hould be sent by email, using the)337.456 576 R F1<ad74>4.361 E F0 .195 -(\215ag of send-)2.695 F .335 -(mail \(or a similar mechanism in other mailers\).)102 588 R 2.835(As)5.335 G -.335(imple w)311.935 588 R .335(ay to do this is to insert the follo)-.1 F .335 -(wing script into)-.25 F(your)102 600 Q F3(/etc/rc.local)2.5 E F0 -(\(or other startup\) \214le:)2.5 E F3 -(virecovery=`echo /var/tmp/vi.recover/recover.)132 612 Q/F4 10/Symbol SF(*)A F3 -(`)A(if [ "$virecovery" != "/var/tmp/vi.recover/recover.)132 624 Q F4(*)A F3 6 -("])C 6(;t)461 624 S(hen)479 624 Q(echo 'Recovering vi editor sessions')177 636 -Q(for i in $virecovery; do)177 648 Q(sendmail -t < $i)222 660 Q(done)177 672 Q -(fi)132 684 Q F0 167.75(4.4BSD March)72 750 R(18, 1994)2.5 E(2)535 750 Q EP -%%Page: 3 3 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(EX/VI REFERENCE MANU)72 48 Q -.834(AL \( 1 \))-.4 F -(BSD Reference Manual)258.235 48 Q(EX/VI REFERENCE MANU)390.972 48 Q -.834 -(AL \( 1 \))-.4 F(If)102 96 Q/F1 10/Courier-Bold@0 SF(ex/vi)2.5 E F0(recei)2.5 -E -.15(ve)-.25 G 2.5(sah).15 G(angup \(SIGHUP\) signal, it will email the reco) -190.46 96 Q -.15(ve)-.15 G(ry information to the user itself.).15 E .773 -(If you don')102 114 R 3.273(th)-.18 G -2.25 -.2(av e)159.409 114 T .773 -(the sendmail program on your system, the source \214le)3.473 F/F2 10/Courier@0 -SF(nvi/recover.c)3.274 E F0 .774(will ha)3.274 F 1.074 -.15(ve t)-.2 H 3.274 -(ob).15 G(e)535.56 114 Q(modi\214ed to use your local mail deli)102 126 Q -.15 -(ve)-.25 G(ry programs.).15 E/F3 10/Times-Bold@0 SF(ST)72 150 Q(AR)-.9 E 1.666 -(TUP INFORMA)-.4 F(TION)-.95 E F1(Ex/vi)102 162 Q F0 .098(interprets one of tw) -2.598 F 2.598(op)-.1 G .098(ossible en)225.43 162 R .098(vironmental v)-.4 F -.098(ariables and reads up to three of \214v)-.25 F 2.597(ep)-.15 G .097 -(ossible \214les dur)473.896 162 R(-)-.2 E .695(ing startup.)102 174 R .695 -(The v)5.695 F .695(ariables and \214les are e)-.25 F .695(xpected to contain) --.15 F F1(ex)3.195 E F0 .695(commands, not)3.195 F F1(vi)3.195 E F0 3.195 -(commands. In)3.195 F(addition,)3.195 E(the)102 186 Q 3.105(ya)-.15 G .605 -(re interpreted)126.615 186 R/F4 10/Times-Italic@0 SF(befor)3.105 E(e)-.37 E F0 -.604(the \214le to be edited is read, and therefore man)3.105 F(y)-.15 E F1(ex) -3.104 E F0 .604(commands may not be used.)3.104 F(Generally)102 198 Q 3.425(,a) --.65 G 1.225 -.15(ny c)151.145 198 T .925(ommand that requires output to the s\ -creen or that needs a \214le upon which to operate, will).15 F -(cause an error if included in a startup \214le or en)102 210 Q(vironmental v) --.4 E(ariable.)-.25 E 2.112(First, the \214le)102 228 R F2(/etc/vi.exrc)4.612 E -F0 2.112(is read.)4.612 F 2.112(Second, the en)7.112 F 2.111(vironmental v)-.4 -F(ariable)-.25 E F2(NEXINIT)4.611 E F0 2.111(\(or the v)4.611 F(ariable)-.25 E -F2(EXINIT)102 240 Q F0 4.085(,i)C(f)147.365 240 Q F2(NEXINIT)4.085 E F0(isn') -4.085 E 4.085(ts)-.18 G 1.585(et\) is interpreted.)226.44 240 R 1.586 -(Third, if neither)6.586 F F2(NEXINIT)4.086 E F0(or)4.086 E F2(EXINIT)4.086 E -F0 -.1(wa)4.086 G 4.086(ss).1 G 1.586(et, the \214le)497.108 240 R F2 -($HOME/.nexrc)102 252 Q F0 1.231(\(or the \214le)3.731 F F2($HOME/.exrc)3.731 E -F0 3.731(,i)C(f)300.595 252 Q F2($HOME/.nexrc)3.731 E F0(doesn')3.731 E 3.731 -(te)-.18 G 1.231(xist\) is read.)420.668 252 R -.15(Fo)6.23 G 1.23 -(urth, the \214le).15 F F2(.nexrc)102 264 Q F0(\(or the \214le)2.5 E F2(.exrc) -2.5 E F0 2.5(,i)C(f)222.44 264 Q F2(.nexrc)2.5 E F0(doesn')2.5 E 2.5(te)-.18 G -(xist\) is read.)302.82 264 Q .431(Startup \214les will not be read if the)102 -282 R 2.931(ya)-.15 G .431(re o)253.617 282 R .431(wned by an)-.25 F .431 -(yone other than the real user)-.15 F .431(-id of the user running)-.2 F F1(vi) -2.931 E F0(,)A .031(\(or by `)102 294 R(`root')-.74 E 2.531('i)-.74 G 2.531(nt) -161.983 294 S .031(he case of the \214le)172.294 294 R F2(/etc/vi.exrc)2.531 E -F0 2.531(\)o)C 2.531(ri)327.79 294 S 2.531(ft)336.431 294 S(he)345.072 294 Q -2.531(ya)-.15 G .031(re writable by an)366.333 294 R .031 -(yone other than the o)-.15 F(wner)-.25 E(.)-.55 E .725 -(Home directory startup \214les \(i.e.)102 306 R F2($HOME/.nexrc)5.725 E F0 -(and)3.225 E F2($HOME/.exrc)3.225 E F0 3.225(\)w)C .725 -(ill not be read if the `)413.27 306 R(`HOME')-.74 E(')-.74 E(en)102 318 Q .454 -(vironmental v)-.4 F .454(ariable is not set.)-.25 F .454 -(Local startup \214les \(i.e.)5.454 F F2(.nexrc)5.454 E F0(and)2.954 E F2 -(.exrc)2.954 E F0 2.954(\)w)C .454(ill not be read if the)438.038 318 R F3(exr) -2.953 E(c)-.18 E F0 .07(option is turned of)102 330 R 2.57(fi)-.25 G 2.57(nt) -184.25 330 S(he)194.6 330 Q F2(/etc/vi.exrc)2.57 E F0(,)A F2($HOME/.nexrc)2.57 -E F0 2.57(,o)C(r)365.75 330 Q F2($HOME/.exrc)2.57 E F0 .07(\214les, or in the) -2.57 F F2(NEXINIT)2.57 E F0(or)102 342 Q F2(EXINIT)2.888 E F0(en)2.887 E .387 -(vironmental v)-.4 F 2.887(ariables. It)-.25 F .387(is not an error for an) -2.887 F 2.887(yo)-.15 G 2.887(ft)361.688 342 S .387(he startup en)370.685 342 R -.387(vironmental v)-.4 F .387(ariables or \214les)-.25 F(not to e)102 354 Q -(xist.)-.15 E .711(Because the)102 372 R F1(ex)3.211 E F0 .712 -(command set supported by)3.211 F F1(nex/nvi)3.212 E F0 .712 -(is a superset of the command set supported by most)3.212 F .746 -(historical implementations of)102 384 R F1(ex)3.246 E F0(,)A F1(nex/nvi)3.246 -E F0 .746(can use the startup \214les created for the historical implementa-) -3.246 F(tions, b)102 396 Q(ut the con)-.2 E -.15(ve)-.4 G -(rse is often not true.).15 E F3 1.666(SIZING THE SCREEN)72 420 R F0 .325 -(The size of the screen can be set in a number of w)102 432 R(ays.)-.1 E F1 -(Ex/vi)5.326 E F0(tak)2.826 E .326(es the follo)-.1 F .326(wing steps until v) --.25 F .326(alues are ob-)-.25 F(tained for both the number of ro)102 444 Q -(ws and number of columns in the screen.)-.25 E 10(1. If)102 468 R(the en)2.5 E -(vironmental v)-.4 E(ariable)-.25 E F2(LINES)2.5 E F0 -.15(ex)2.5 G -(ists, it is used to specify the number of ro).15 E(ws in the screen.)-.25 E 10 -(2. If)102 480 R 1.904(the en)4.404 F 1.903(vironmental v)-.4 F(ariable)-.25 E -F2(COLUMNS)4.403 E F0 -.15(ex)4.403 G 1.903 -(ists, it is used to specify the number of columns in the).15 F(screen.)122 492 -Q 10(3. The)102 504 R(TIOCGWINSZ)2.5 E F2(ioctl)2.5 E F0 -(\(2\) is attempted on the standard error \214le descriptor)A(.)-.55 E 10 -(4. The)102 516 R(termcap entry is check)2.5 E(ed for the `)-.1 E(`li')-.74 E -2.5('e)-.74 G(ntry \(ro)295.36 516 Q(ws\) and the `)-.25 E(`co')-.74 E 2.5('e) --.74 G(ntry \(columns\).)402.2 516 Q 10(5. The)102 528 R(number of ro)2.5 E -(ws is set to 24, and the number of columns is set to 80.)-.25 E .021 -(If a windo)102 546 R 2.521(wc)-.25 G .021 -(hange size signal \(SIGWINCH\) is recei)157.073 546 R -.15(ve)-.25 G .022 -(d, the same steps are tak).15 F .022(en with the e)-.1 F .022 -(xception that the)-.15 F(\214rst tw)102 558 Q 2.5(os)-.1 G(teps are skipped.) -141.35 558 Q F3 1.666(REGULAR EXPRESSIONS AND REPLA)72 582 R 1.666 -(CEMENT STRINGS)-.55 F F0(Re)102 594 Q .105(gular e)-.15 F .105 -(xpressions are used in line addresses, as the \214rst part of)-.15 F F3 -(substitute)2.604 E F0(,)A F3(global)2.604 E F0 2.604(,a)C(nd)447.842 594 Q F3 -(vglobal)2.604 E F0(commands,)2.604 E(and in search patterns.)102 606 Q .323 -(The re)102 624 R .323(gular e)-.15 F .323(xpressions supported by)-.15 F F1 -(ex)2.824 E F0(and)2.824 E F1(vi)2.824 E F0 .324(are, by def)2.824 F .324 -(ault, the Basic Re)-.1 F .324(gular Expressions \(BRE')-.15 F .324(s\) de-) --.55 F .102(scribed in the IEEE POSIX Standard 1003.2.)102 636 R(The)5.101 E F3 -(extended)2.601 E F0 .101(option causes all re)2.601 F .101(gular e)-.15 F .101 -(xpressions to be inter)-.15 F(-)-.2 E .517(preted as the Extended Re)102 648 R -.518(gular Expressions \(ERE')-.15 F .518(s\) described by the same standard.) --.55 F(\(See)5.518 E F2(re_format)3.018 E F0(\(7\))A 1.615 -(for more information.)102 660 R 1.615(Generally speaking, BRE')6.615 F 4.115 -(sa)-.55 G(re)319.16 660 Q F2(ed)4.115 E F0 1.615(\(1\) and)B F2(grep)4.114 E -F0 1.614(\(1\) style re)B 1.614(gular e)-.15 F 1.614(xpressions, and)-.15 F -(ERE')102 672 Q 2.5(sa)-.55 G(re)134.5 672 Q F2(egrep)2.5 E F0(\(1\) style re)A -(gular e)-.15 E(xpressions.\))-.15 E 167.75(4.4BSD March)72 750 R(18, 1994)2.5 -E(3)535 750 Q EP -%%Page: 4 4 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(EX/VI REFERENCE MANU)72 48 Q -.834(AL \( 1 \))-.4 F -(BSD Reference Manual)258.235 48 Q(EX/VI REFERENCE MANU)390.972 48 Q -.834 -(AL \( 1 \))-.4 F -(There are some special strings and characters that can be used in RE')102 96 Q -(s:)-.55 E 10(1. An)102 108 R(empty RE \(e.g.)2.5 E -.74(``)5 G(//').74 E -('\) is equi)-.74 E -.25(va)-.25 G(lent to the last RE used.).25 E 10(2. The) -102 120 R(construct `)2.5 E(`\\<')-.74 E 2.5('m)-.74 G(atches the be)209.75 120 -Q(ginning of a w)-.15 E(ord.)-.1 E 10(3. The)102 132 R(construct `)2.5 E(`\\>') --.74 E 2.5('m)-.74 G(atches the end of a w)209.75 132 Q(ord.)-.1 E 10(4. The) -102 144 R(character `)2.5 E(`~')-.74 E 2.5('m)-.74 G -(atches the replacement part of the last)204.64 144 Q/F1 10/Times-Bold@0 SF -(substitute)2.5 E F0(command.)2.5 E .598(When the)102 162 R F1(magic)3.099 E F0 -.599(option is)3.099 F/F2 10/Times-Italic@0 SF(not)3.099 E F0 .599 -(set, the only characters with special meanings are `)3.099 F(`^')-.74 E 3.099 -('a)-.74 G 3.099(tt)454.984 162 S .599(he be)463.643 162 R .599(ginning of an) --.15 F 1.09(RE, `)102 174 R(`$')-.74 E 3.59('a)-.74 G 3.59(tt)145.74 174 S 1.09 -(he end of an RE, and the escaping character `)154.89 174 R(`\\')-.74 E 1.089 -('. The characters `)-.74 F(`.')-.74 E 1.089(', `)-.74 F(`)-.74 E/F3 10/Symbol -SF(*)A F0 -.74('')C 3.589(,`).74 G(`[')472.333 174 Q 1.089(', and `)-.74 F(`~') --.74 E 3.589('a)-.74 G(re)532.23 174 Q 1.05 -(treated as ordinary characters unless preceded by a `)102 186 R(`\\')-.74 E -1.05('; when preceded by a `)-.74 F(`\\')-.74 E 3.55('t)-.74 G(he)444.17 186 Q -3.55(yr)-.15 G -2.25 -.15(eg a)465.34 186 T 1.05(in their special).15 F -(meaning.)102 198 Q(Replacement strings are the second part of a)102 216 Q F1 -(substitute)2.5 E F0(command.)2.5 E 1.365(The character `)102 234 R(`&')-.74 E -3.865('\()-.74 G 1.365(or `)188.735 234 R(`\\&')-.74 E 3.864('i)-.74 G 3.864 -(ft)229.974 234 S(he)239.948 234 Q F1(magic)3.864 E F0 1.364(option is)3.864 F -F2(not)3.864 E F0 1.364(set\) in the replacement string stands for the te)3.864 -F(xt)-.15 E .713(matched by the RE that')102 246 R 3.213(sb)-.55 G .713 -(eing replaced.)213.615 246 R .714(The character `)5.714 F(`~')-.74 E 3.214 -('\()-.74 G .714(or `)356.464 246 R(`\\~')-.74 E 3.214('i)-.74 G 3.214(ft) -391.952 246 S(he)401.276 246 Q F1(magic)3.214 E F0 .714(option is)3.214 F F2 -(not)3.214 E F0 .714(set\) stands)3.214 F(for the replacement part of the pre) -102 258 Q(vious)-.25 E F1(substitute)2.5 E F0(command.)2.5 E .325(The string `) -102 276 R(`\\#')-.74 E .325(', where `)-.74 F(`#')-.74 E 2.825('i)-.74 G 2.825 -(sa)220.625 276 S 2.825(ni)231.78 276 S(nte)242.385 276 Q .325(ger v)-.15 F -.325(alue from 1 to 9, stands for the te)-.25 F .325 -(xt matched by the portion of the)-.15 F 1.239(RE enclosed in the #')102 288 R -1.239(th set of escaped parentheses, e.g.)-.18 F -.74(``)6.239 G(\\\(').74 E -3.74('a)-.74 G 1.24(nd `)366.4 288 R(`\\\)')-.74 E 1.24('. F)-.74 F 1.24(or e) --.15 F 1.24(xample, `)-.15 F(`s/abc\\\(.)-.74 E F3(*)A F0(\\\)def/\\1/')A(') --.74 E(deletes the strings `)102 300 Q(`abc')-.74 E 2.5('a)-.74 G(nd `)208.82 -300 Q(`def')-.74 E 2.5('f)-.74 G(rom the matched pattern.)251.76 300 Q .052 -(The strings `)102 318 R(`\\l')-.74 E .051(', `)-.74 F(`\\u')-.74 E .051(', `) --.74 F(`\\L')-.74 E .051(', and `)-.74 F(`\\U')-.74 E 2.551('c)-.74 G .051 -(an be used to modify the case of elements in the replacement string.)268.048 -318 R .287(The string `)102 330 R(`\\l')-.74 E 2.787('c)-.74 G .287 -(auses the ne)170.531 330 R .287(xt character to be con)-.15 F -.15(ve)-.4 G -.287(rted to lo).15 F .287(wercase; the string `)-.25 F(`\\u')-.74 E 2.787('b) --.74 G(eha)457.575 330 Q -.15(ve)-.2 G 2.787(ss).15 G(imilarly)491.112 330 Q -2.788(,b)-.65 G(ut)532.22 330 Q(con)102 342 Q -.15(ve)-.4 G .449 -(rts to uppercase.).15 F .449(The strings `)5.449 F(`\\L')-.74 E 2.949('c)-.74 -G .449(auses characters up to the end of the string or the ne)273.174 342 R -.448(xt occurrence)-.15 F .637(of the strings `)102 354 R(`\\e')-.74 E 3.137 -('o)-.74 G 3.137(r`)185.828 354 S(`\\E')194.885 354 Q 3.137('t)-.74 G 3.137(ob) -218.942 354 S 3.137(ec)232.079 354 S(on)244.096 354 Q -.15(ve)-.4 G .637 -(rted to lo).15 F .637(wercase; the string `)-.25 F(`\\U')-.74 E 3.137('b)-.74 -G(eha)409.488 354 Q -.15(ve)-.2 G 3.138(ss).15 G(imilarly)443.376 354 Q 3.138 -(,b)-.65 G .638(ut con)484.834 354 R -.15(ve)-.4 G .638(rts to).15 F -(uppercase.)102 366 Q(In)102 384 Q/F4 10/Courier-Bold@0 SF(vi)3.372 E F0 3.372 -(,i)C .872(nserting a <control-M> into the replacement string will cause the m\ -atched line to be split into tw)134.354 384 R(o)-.1 E(lines at that point.)102 -396 Q F1 1.666(SET OPTIONS)72 420 R F0 .518(There are a lar)102 432 R .518 -(ge number of options that may be set \(or unset\) to change the editor')-.18 F -3.019(sb)-.55 G(eha)453.612 432 Q(vior)-.2 E 5.519(.T)-.55 G .519(his section) -496.981 432 R(describes the options, their abbre)102 444 Q -(viations and their def)-.25 E(ault v)-.1 E(alues.)-.25 E .095 -(In each entry belo)102 462 R 1.395 -.65(w, t)-.25 H .095 -(he \214rst part of the tag line is the full name of the option, follo).65 F -.095(wed by an)-.25 F 2.595(ye)-.15 G(qui)487.915 462 Q -.25(va)-.25 G .095 -(lent ab-).25 F(bre)102 474 Q 2.973(viations. \(Re)-.25 F -.05(ga)-.15 G .473 -(rdless of the abbre).05 F .473 -(viations, it is only necessary to use the minimum number of characters)-.25 F -.164(necessary to distinguish an abbre)102 486 R .164 -(viation from all other commands for it to be accepted, in)-.25 F F4(nex/nvi) -2.663 E F0 2.663(.H)C(istor)519.09 486 Q(-)-.2 E(ically)102 498 Q 3.156(,o)-.65 -G .656(nly the full name and the of)134.226 498 R .656(\214cial abbre)-.25 F -.657(viations were accepted by)-.25 F F4(ex/vi)3.157 E F0 3.157(.U)C .657 -(sing full names in your)445.152 498 R .274(startup \214les and en)102 510 R -.274(vironmental v)-.4 F .274(ariables will probably mak)-.25 F 2.774(et)-.1 G -.274(hem more portable.\))351.192 510 R .274(The part in square brack-)5.274 F -.678(ets is the def)102 522 R .678(ault v)-.1 F .678(alue of the option.)-.25 F -.679(Most of the options are boolean, i.e. the)5.678 F 3.179(ya)-.15 G .679 -(re either on or of)433.706 522 R .679(f, and do)-.25 F(not ha)102 534 Q .3 --.15(ve a)-.2 H 2.5(na).15 G(ssociated v)154.69 534 Q(alue.)-.25 E -(Options apply to both)102 552 Q F4(ex)2.5 E F0(and)2.5 E F4(vi)2.5 E F0 -(modes, unless otherwise speci\214ed.)2.5 E -.15(Fo)102 570 S 3.542(ri).15 G -1.041(nformation on modifying the options or to display the options and their \ -current v)122.062 570 R 1.041(alues, see the `)-.25 F(`set')-.74 E(')-.74 E -(command in the Ex Commands section.)102 582 Q/F5 10/Courier@0 SF -(altwerase [off])102 594 Q F4(Vi)131 606 Q F0(only)3.119 E 5.619(.C)-.65 G .619 -(hange ho)178.038 606 R(w)-.25 E F4(vi)3.119 E F0 .619(does w)3.119 F .619 -(ord erase during te)-.1 F .619(xt input.)-.15 F .62 -(When this option is set, te)5.62 F .62(xt is brok)-.15 F(en)-.1 E .552(up int\ -o three classes: alphabetic, numeric and underscore characters, other non-blan\ -k characters, and)131 618 R .245(blank characters.)131 630 R .246 -(Changing from one class to another marks the end of a w)5.245 F 2.746(ord. In) --.1 F .246(addition, the class)2.746 F .411 -(of the \214rst character erased is ignored \(which is e)131 642 R .41 -(xactly what you w)-.15 F .41(ant when erasing pathname com-)-.1 F(ponents\).) -131 654 Q F5(autoindent, ai [off])102 666 Q F0 .317 -(If this option is set, whene)131 678 R -.15(ve)-.25 G 2.817(ry).15 G .317 -(ou create a ne)258.322 678 R 2.818(wl)-.25 G .318(ine \(using the)327.092 678 -R F4(vi)2.818 E F1(A)2.818 E F0(,)A F1(a)2.818 E F0(,)A F1(C)2.818 E F0(,)A F1 -(c)2.818 E F0(,)A F1(I)2.818 E F0(,)A F1(i)2.818 E F0(,)A F1(O)2.818 E F0(,)A -F1(o)2.818 E F0(,)A F1(R)2.818 E F0(,)A F1(r)2.818 E F0(,)A F1(S)2.818 E F0 -2.818(,a)C(nd)523.292 678 Q F1(s)2.818 E F0 .302(commands, or the)131 690 R F4 -(ex)2.802 E F1(append)2.802 E F0(,)A F1(change)2.802 E F0 2.802(,a)C(nd)297.312 -690 Q F1(insert)2.801 E F0 .301(commands\) the ne)2.801 F 2.801(wl)-.25 G .301 -(ine is automatically indented)423.827 690 R .443(to align the cursor with the\ - \214rst non-blank character of the line from which you created it.)131 702 R -.443(Lines are)5.443 F 167.75(4.4BSD March)72 750 R(18, 1994)2.5 E(4)535 750 Q -EP -%%Page: 5 5 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(EX/VI REFERENCE MANU)72 48 Q -.834(AL \( 1 \))-.4 F -(BSD Reference Manual)258.235 48 Q(EX/VI REFERENCE MANU)390.972 48 Q -.834 -(AL \( 1 \))-.4 F 1.112(indented using tab characters to the e)131 96 R 1.112 -(xtent possible \(based on the v)-.15 F 1.112(alue of the)-.25 F/F1 10 -/Times-Bold@0 SF(tabstop)3.612 E F0 1.111(option\) and)3.611 F .548 -(then using space characters as necessary)131 108 R 5.549(.F)-.65 G .549 -(or commands inserting te)307.88 108 R .549(xt into the middle of a line, an) --.15 F(y)-.15 E .47(blank characters to the right of the cursor are discarded,\ - and the \214rst non-blank character to the right)131 120 R -(of the cursor is aligned as described abo)131 132 Q -.15(ve)-.15 G(.).15 E -.874(The indent characters are themselv)131 150 R .874(es some)-.15 F .875 -(what special.)-.25 F .875(If you do not enter more characters on the)5.875 F -(ne)131 162 Q 3.705(wl)-.25 G 1.205(ine before mo)153.895 162 R 1.205(ving mo) --.15 F 1.205 -(ving to another line, or entering <escape>, the indent character will be)-.15 -F .676(deleted and the line will be empty)131 174 R 5.676(.F)-.65 G .676(or e) -283.532 174 R .676(xample, if you enter <carriage-return> twice in succession,) --.15 F .73(the line created by the \214rst <carriage-return> will not ha)131 -186 R 1.03 -.15(ve a)-.2 H 1.03 -.15(ny c).15 H .73(haracters in it, re).15 F --.05(ga)-.15 G .73(rdless of the in-).05 F(dentation of the pre)131 198 Q -(vious or subsequent line.)-.25 E .414(Indent characters also require that you\ - enter additional erase characters to delete them.)131 216 R -.15(Fo)5.415 G -2.915(re).15 G(xample,)508.06 216 Q .754(if you ha)131 228 R 1.054 -.15(ve a) --.2 H 3.254(ni).15 G .753(ndented line, containing only blanks, the \214rst <w) -195.876 228 R .753(ord-erase> character you enter will)-.1 F .676(erase up to \ -end of the indent characters, and the second will erase back to the be)131 240 -R .677(ginning of the line.)-.15 F(\(Historically)131 252 Q 2.88(,o)-.65 G .38 -(nly the)191.28 252 R F1(^D)2.88 E F0 -.1(ke)2.88 G 2.88(yw)-.05 G .38 -(ould erase the indent characters.)259.66 252 R .379(Both the)5.379 F F1(^D) -2.879 E F0 -.1(ke)2.879 G 2.879(ya)-.05 G .379(nd the usual erase)467.493 252 R --.1(ke)131 264 S .617(ys w)-.05 F .617(ork in)-.1 F/F2 10/Courier-Bold@0 SF -.618(nvi .\))3.118 F F0 .618(In addition, if the cursor is positioned at the e\ -nd of the indent characters, the)3.118 F -.1(ke)131 276 S .04(ys `)-.05 F -(`0^D')-.74 E 2.54('w)-.74 G .039(ill erase all of the indent characters for t\ -he current line, resetting the indentation le)188.77 276 R -.15(ve)-.25 G 2.539 -(lt).15 G(o)535 276 Q 2.736(0. Similarly)131 288 R 2.736(,t)-.65 G .236(he k) -188.332 288 R -.15(ey)-.1 G 2.736(s`).15 G(`^^D')223.914 288 Q 2.736('\()-.74 G -.237(i.e. a carat follo)253.11 288 R .237 -(wed by a <control-D>\) will erase all of the indent char)-.25 F(-)-.2 E -(acters for the current line, lea)131 300 Q(ving the indentation le)-.2 E -.15 -(ve)-.25 G 2.5(lf).15 G(or future created lines unaf)355.35 300 Q(fected.)-.25 -E(Finally)131 318 Q 2.644(,i)-.65 G(f)166.614 318 Q F1(autoindent)2.644 E F0 -.144(is set, the)2.644 F F1(S)2.644 E F0(and)2.644 E F1(cc)2.644 E F0 .143 -(commands change from the \214rst non-blank of the line to the)2.644 F -(end of the line, instead of from the be)131 330 Q -(ginning of the line to the end of the line.)-.15 E/F3 10/Courier@0 SF -(autoprint, ap [off])102 342 Q F2(Ex)131 354 Q F0(only)2.852 E(.)-.65 E F2(Ex) -5.353 E F0(only)2.853 E 5.353(.C)-.65 G .353 -(ause the current line to be automatically displayed after the)217.341 354 R F2 -(ex)2.853 E F0(commands)2.853 E F1(<)2.853 E F0(,)A F1(>)2.853 E F0(,)A F1 -(copy)131 366 Q F0(,)A F1(delete)2.576 E F0(,)A F1(join)2.576 E F0(,)A F1(mo) -2.576 E -.1(ve)-.1 G F0(,).1 E F1(put)2.576 E F0(,)A F1(t)2.576 E F0(,)A F1 -(Undo)2.576 E F0 2.576(,a)C(nd)296.322 366 Q F1(undo)2.576 E F0 2.576(.T)C .076 -(his automatic display is suppressed during)341.764 366 R F1(global)2.576 E F0 -(and)131 378 Q F1(vglobal)2.974 E F0 .474(commands, and for an)2.974 F 2.975 -(yc)-.15 G .475(ommand where optional \215ags are used to e)285.065 378 R .475 -(xplicitly display the)-.15 F(line.)131 390 Q F3(autowrite, aw [off])102 402 Q -F0 .663(If this option is set, the)131 414 R F2(vi)3.163 E F1 3.163(!^)3.163 G -3.163(^^)254.134 414 S(])263.957 414 Q F0(and)3.163 E F1(^Z)3.162 E F0 .662 -(commands, and the)3.162 F F2(ex)3.162 E F1(edit)3.162 E F0(,)A F1(next)3.162 E -F0(,)A F1 -.18(re)3.162 G(wind).18 E F0(,)A F1(stop)3.162 E F0(,)A F1(suspend) -3.162 E F0(,)A F1(tag)131 426 Q F0(,)A F1(tagpop)2.51 E F0 2.51(,a)C(nd)188.24 -426 Q F1(tagtop)2.51 E F0 .011(commands automatically write the current \214le\ - back to the current \214le name if)2.51 F .737 -(it has been modi\214ed since it w)131 438 R .737(as last written.)-.1 F .737 -(If the write f)5.737 F .737(ails, the command f)-.1 F .736 -(ails and goes no fur)-.1 F(-)-.2 E(ther)131 450 Q(.)-.55 E 2.307 -(Appending the optional force \215ag `)131 468 R(`!')-.74 E 4.807('t)-.74 G -4.807(ot)302.772 468 S(he)315.359 468 Q F2(ex)4.807 E F0(commands)4.807 E F1 -(next)4.807 E F0(,)A F1 -.18(re)4.807 G(wind).18 E F0(,)A F1(stop)4.807 E F0(,) -A F1(suspend)4.808 E F0(,)A F1(tag)4.808 E F0(,)A F1(tagpop)131 480 Q F0 2.5 -(,a)C(nd)169.89 480 Q F1(tagtop)2.5 E F0 -(stops the automatic write from being attempted.)2.5 E(\(Historically)131 498 Q -2.812(,t)-.65 G(he)188.992 498 Q F1(next)2.812 E F0 .312 -(command ignored the optional force \215ag.\))2.812 F .311(Note, the)5.311 F F2 -(ex)2.811 E F0(commands)2.811 E F1(edit)2.811 E F0(,)A F1(quit)2.811 E F0(,)A -F1(shell)131 510 Q F0 2.5(,a)C(nd)159.89 510 Q F1(xit)2.5 E F0(are)2.5 E/F4 10 -/Times-Italic@0 SF(not)2.5 E F0(af)2.5 E(fected by the)-.25 E F1(auto)2.5 E -(write)-.1 E F0(option.)2.5 E F3(beautify, bf [off])102 522 Q F0 .359(If this \ -option is set, all control characters that are not currently being specially i\ -nterpreted, other than)131 534 R 1.38(<tab>, <ne)131 546 R 1.38 -(wline>, and <form-feed>, are discarded from commands read in by)-.25 F F2(ex) -3.88 E F0 1.38(from command)3.88 F .51(\214les, and from input te)131 558 R .51 -(xt entered to)-.15 F F2(vi)3.01 E F0 .511 -(\(either into the \214le or to the colon command line\).)3.01 F -1.25 -.7 -(Te x)5.511 H 3.011<748c>.7 G(les)528.89 558 Q(read by)131 570 Q F2(ex/vi)2.5 E -F0(are)2.5 E F4(not)2.5 E F0(af)2.5 E(fected by the)-.25 E F1(beautify)2.5 E F0 -(option.)2.5 E F3(cdpath [environment variable CDPATH, or ``.''])102 582 Q F0 -.451(This option is used to specify a colon separated list of directories whic\ -h are used as path pre\214x)131 594 R .45(es for)-.15 F(an)131 606 Q 3.014(yr) --.15 G(elati)151.634 606 Q .814 -.15(ve p)-.25 H .514(ath names used as ar).15 -F .515(guments for the)-.18 F F1(cd)3.015 E F0 3.015(command. The)3.015 F -.25 -(va)3.015 G .515(lue of this option def).25 F .515(aults to)-.1 F 1.01(the v) -131 618 R 1.01(alue of the en)-.25 F 1.01(vironmental v)-.4 F(ariable)-.25 E F3 -(CDPATH)3.51 E F0 1.009(if it is set, otherwise to the current directory)3.509 -F 6.009(.F)-.65 G(or)531.67 618 Q .148 -(compatibility with the POSIX 1003.2 shell, the)131 630 R F1(cd)2.649 E F0 .149 -(command does)2.649 F F4(not)2.649 E F0 .149(check the current directory as a) -2.649 F .385(path pre\214x for relati)131 642 R .685 -.15(ve p)-.25 H .385 -(ath names unless it is e).15 F .385(xplicitly speci\214ed.)-.15 F .384 -(It may be so speci\214ed by entering)5.385 F(an empty string or a `)131 654 Q -(`.')-.74 E 2.5('i)-.74 G(nto the)233.11 654 Q F3(CDPATH)2.5 E F0 -.25(va)2.5 G -(riable or the option v).25 E(alue.)-.25 E F3(columns, co [80])102 666 Q F0 -.278(The number of columns in the screen.)131 678 R .278 -(Setting this option causes)5.278 F F2(ex/vi)2.778 E F0 .279 -(to set \(or reset\) the en)2.778 F(viron-)-.4 E 167.75(4.4BSD March)72 750 R -(18, 1994)2.5 E(5)535 750 Q EP -%%Page: 6 6 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(EX/VI REFERENCE MANU)72 48 Q -.834(AL \( 1 \))-.4 F -(BSD Reference Manual)258.235 48 Q(EX/VI REFERENCE MANU)390.972 48 Q -.834 -(AL \( 1 \))-.4 F(mental v)131 96 Q(ariable)-.25 E/F1 10/Courier@0 SF(COLUMNS) -2.5 E F0 2.5(.S)C(ee the SCREEN SIZING section for more information.)247.74 96 -Q F1(comment [off])102 108 Q/F2 10/Courier-Bold@0 SF(Vi)131 120 Q F0(only)3.265 -E 5.765(.I)-.65 G 3.265(ft)174.99 120 S .764 -(he \214rst non-empty line of the \214le be)184.365 120 R .764 -(gins with the string `)-.15 F(`/)-.74 E/F3 10/Symbol SF(*)A F0 -.74('')C 3.264 -(,t).74 G .764(his option causes)443.834 120 R F2(vi)3.264 E F0(to)3.264 E -(skip to the end of that C comment \(probably a terribly boring le)131 132 Q --.05(ga)-.15 G 2.5(ln).05 G(otice\) before displaying the \214le.)404.94 132 Q -F1(directory, dir [environment variable TMPDIR, or /tmp])102 144 Q F0 .545 -(The directory where temporary \214les are created.)131 156 R .546(The en)5.546 -F .546(vironmental v)-.4 F(ariable)-.25 E F1(TMPDIR)3.046 E F0 .546 -(is used as the)3.046 F(def)131 168 Q(ault v)-.1 E(alue if it e)-.25 E -(xists, otherwise)-.15 E F1(/tmp)2.5 E F0(is used.)2.5 E F1 -(edcompatible, ed [off])102 180 Q F0 .214 -(This option causes the presence or absence of)131 192 R/F4 10/Times-Bold@0 SF -(g)2.714 E F0(and)2.714 E F4(c)2.714 E F0(suf)2.714 E<8c78>-.25 E .214(es on) --.15 F F4(substitute)2.714 E F0 .214(commands to be remem-)2.714 F .654 -(bered, and to be toggled by repeating the suf)131 204 R 3.154(\214ces. The) --.25 F(suf)3.154 E<8c78>-.25 E F4(r)3.154 E F0(mak)3.154 E .654 -(es the substitution be as in the)-.1 F F4(~)3.155 E F0 -(command, instead of lik)131 216 Q 2.5(et)-.1 G(he)237.28 216 Q F4(&)2.5 E F0 -(command.)2.5 E/F5 10/Times-Italic@0 SF(This option is not yet implemented.)131 -228 Q F1(errorbells, eb [off])102 240 Q F2(Ex)131 252 Q F0(only)2.5 E 5(.C)-.65 -G(auses)176.8 252 Q F2(ex)2.5 E F0(error messages to be preceded by a bell.)2.5 -E F5(This option is not yet implemented.)131 264 Q F1(exrc, ex [off])102 276 Q -F0 .394(If this option is turned of)131 288 R 2.894(fi)-.25 G 2.894(nt)241.444 -288 S .394 -(he system or $HOME startup \214les, the local startup \214les are ne)252.118 -288 R -.15(ve)-.25 G 2.893(rr).15 G(ead)526.12 288 Q .404(\(unless the)131 300 -R 2.904(ya)-.15 G .405(re the same as the system or $HOME startup \214les\).) -186.648 300 R -.45(Tu)5.405 G .405(rning it on has no ef).45 F .405 -(fect, i.e. the)-.25 F .693 -(normal checks for local startup \214les are performed, re)131 312 R -.05(ga) --.15 G 3.192(rdless. See).05 F .692(the ST)3.192 F(AR)-.93 E .692(TUP INFORMA) --.6 F(TION)-1.11 E(section for more information.)131 324 Q F1(extended [off]) -102 336 Q F0 .007(This option causes all re)131 348 R .007(gular e)-.15 F .007 -(xpressions to be treated as POSIX 1003.2 e)-.15 F .008(xtended re)-.15 F .008 -(gular e)-.15 F(xpressions)-.15 E(\(which are similar to historic)131 360 Q F1 -(egrep)2.5 E F0(\(1\) style e)A(xpressions\).)-.15 E F1(flash [on])102 372 Q F0 -.077(This option causes the screen to \215ash instead of beeping the k)131 384 -R -.15(ey)-.1 G .077(board, on error).15 F 2.577(,i)-.4 G 2.577(ft)455.262 384 -S .077(he terminal has the)463.949 384 R(capability)131 396 Q(.)-.65 E F1 -(hardtabs, ht [8])102 408 Q F0 .269 -(This option de\214nes the spacing between hardw)131 420 R .269 -(are tab settings, i.e.)-.1 F .27(the tab e)5.269 F .27 -(xpansion done by the op-)-.15 F .577 -(erating system and/or the terminal itself.)131 432 R(As)5.577 E F2(nex/nvi) -3.077 E F0(ne)3.077 E -.15(ve)-.25 G 3.077(rw).15 G .576 -(rites tabs to the terminal, unlik)392.483 432 R 3.076(eh)-.1 G(is-)530 432 Q -(toric v)131 444 Q(ersions of)-.15 E F2(ex/vi)2.5 E F0 2.5(,t)C -(his option does not currently ha)236.12 444 Q .3 -.15(ve a)-.2 H .3 -.15(ny a) -.15 H -.25(ff).15 G(ect.).25 E F1(ignorecase, ic [off])102 456 Q F0 .977 -(This option causes re)131 468 R .977(gular e)-.15 F .977(xpressions, both in) --.15 F F2(ex)3.477 E F0 .978(commands and in searches, to be e)3.477 F -.25(va) --.25 G .978(luated in a).25 F(case-insensiti)131 480 Q .3 -.15(ve m)-.25 H -(anner).15 E(.)-.55 E F1(keytime [6])102 492 Q F0(The 10th')131 504 Q 2.5(so) --.55 G 2.5(fas)181 504 S(econd)197.66 504 Q F2(ex/vi)2.5 E F0 -.1(wa)2.5 G -(its for a subsequent k).1 E .3 -.15(ey t)-.1 H 2.5(oc).15 G(omplete a k)379.5 -504 Q .3 -.15(ey m)-.1 H(apping.).15 E F1(leftright [off])102 516 Q F2(Vi)131 -528 Q F0(only)3.198 E 5.697(.T)-.65 G .697 -(his option causes the screen to be scrolled left-right to vie)177.635 528 R -3.197(wl)-.25 G .697(ines longer than the screen,)428.072 528 R .98 -(instead of the traditional)131 540 R F2(vi)3.48 E F0 .98(screen interf)3.48 F -.98(ace which folds long lines at the right-hand mar)-.1 F .98(gin of the)-.18 -F(terminal.)131 552 Q F1(lines, li [24])102 564 Q F2(Vi)131 576 Q F0(only)2.569 -E 5.069(.T)-.65 G .069(he number of lines in the screen.)176.378 576 R .069 -(Setting this option causes)5.069 F F2(ex/vi)2.569 E F0 .069 -(to set \(or reset\) the en-)2.569 F(vironmental v)131 588 Q(ariable)-.25 E F1 -(LINES)2.5 E F0 2.5(.S)C(ee the Screen Sizing section for more information.) -256.85 588 Q F1(lisp [off])102 600 Q F2(Vi)131 612 Q F0(only)2.948 E 5.448(.T) --.65 G .448(his option changes the beha)177.136 612 R .448(vior of the)-.2 F F2 -(vi)2.948 E F4(\()2.948 E F0(,)A F4(\))2.948 E F0(,)A F4({)2.948 E F0(,)A F4(}) -2.948 E F0(,)A F4([[)2.948 E F0(and)2.948 E F4(]])2.948 E F0 .448 -(commands to match the Lisp)2.948 F 2.5(language. Also,)131 624 R(the)2.5 E F4 -(autoindent)2.5 E F0(option')2.5 E 2.5(sb)-.55 G(eha)301.56 624 Q -(vior is changed to be appropriate for Lisp.)-.2 E F5 -(This option is not yet implemented.)131 636 Q F1(list [off])102 648 Q F0 .639 -(This option causes lines to be displayed in an unambiguous f)131 660 R 3.139 -(ashion. Speci\214cally)-.1 F 3.139(,t)-.65 G .639(abs are displayed)469.852 -660 R(as control characters, i.e.)131 672 Q -.74(``)5 G(^I').74 E -(', and the ends of lines are mark)-.74 E(ed with a `)-.1 E(`$')-.74 E 2.5('c) --.74 G(haracter)441.72 672 Q(.)-.55 E F1(magic [on])102 684 Q F0 .992 -(This option is on by def)131 696 R 3.493(ault. T)-.1 F .993(urning the)-.45 F -F4(magic)3.493 E F0 .993(option of)3.493 F 3.493(fc)-.25 G .993(auses all re) -383.048 696 R .993(gular e)-.15 F .993(xpression characters)-.15 F -.15(ex)131 -708 S 1.235(cept for `).15 F(`^')-.74 E 3.735('a)-.74 G 1.235(nd `)199.425 708 -R(`$')-.74 E 1.235(', to be treated as ordinary characters.)-.74 F 2.835 -.8 -(To r)6.235 H 1.235(e-enable characters indi).8 F(vidually)-.25 E(,)-.65 E -167.75(4.4BSD March)72 756 R(18, 1994)2.5 E(6)535 756 Q EP -%%Page: 7 7 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(EX/VI REFERENCE MANU)72 48 Q -.834(AL \( 1 \))-.4 F -(BSD Reference Manual)258.235 48 Q(EX/VI REFERENCE MANU)390.972 48 Q -.834 -(AL \( 1 \))-.4 F .589(when the)131 96 R/F1 10/Times-Bold@0 SF(magic)3.089 E F0 -.589(option is of)3.089 F .589(f, precede them with an `)-.25 F(`\\')-.74 E .59 -('. See the REGULAR EXPRESSIONS AND)-.74 F(REPLA)131 108 Q -(CEMENT STRINGS section for more information.)-.4 E/F2 10/Courier@0 SF -(matchtime [7])102 120 Q/F3 10/Courier-Bold@0 SF(Vi)131 132 Q F0(only)2.885 E -5.385(.T)-.65 G .385(he 10th')177.01 132 R 2.885(so)-.55 G 2.885(fas)221.67 132 -S(econd)239.1 132 Q F3(ex/vi)2.884 E F0 .384 -(pauses on the matching character when the)2.884 F F1(sho)2.884 E(wmatch)-.1 E -F0(op-)2.884 E(tion is set.)131 144 Q F2(mesg [on])102 156 Q F0 .944 -(This option allo)131 168 R .944(ws other users to contact you using the)-.25 F -F2(talk)3.444 E F0 .944(\(1\) and)B F2(write)3.444 E F0 .944 -(\(1\) utilities, while you)B .751(are editing.)131 180 R F3(Ex/vi)5.751 E F0 -.751(does not turn message on, i.e. if messages were turned of)3.251 F 3.25(fw) --.25 G .75(hen the editor w)464.81 180 R(as)-.1 E(in)131 192 Q -.2(vo)-.4 G -.1 -(ke).2 G .12(d, the).1 F 2.62(yw)-.15 G .12(ill stay turned of)194.55 192 R -2.62(f. This)-.25 F .12(option only permits you to disallo)2.62 F 2.62(wm)-.25 -G .12(essages for the edit ses-)445.1 192 R 2.5(sion. See)131 204 R(the)2.5 E -F2(mesg)2.5 E F0(\(1\) utility for more information.)A F2 -(modelines, modeline [off])102 216 Q F0 .372(If the)131 228 R F1(modelines) -2.872 E F0 .371(option is set,)2.871 F F3(ex/vi)2.871 E F0 .371 -(has historically scanned the \214rst and last \214v)2.871 F 2.871(el)-.15 G -.371(ines of each \214le)475.847 228 R .281 -(as it is read for editing, looking for an)131 240 R(y)-.15 E F3(ex)2.781 E F0 -.281(commands that ha)2.781 F .581 -.15(ve b)-.2 H .281 -(een placed in those lines.).15 F .282(After the)5.281 F .3(startup informatio\ -n has been processed, and before the user starts editing the \214le, an)131 252 -R 2.8(yc)-.15 G .3(ommands em-)482.76 252 R .029(bedded in the \214le are e)131 -264 R -.15(xe)-.15 G 2.529(cuted. Commands).15 F .029 -(are recognized by the letters `)2.529 F(`e')-.74 E 2.53('o)-.74 G 2.53(r`) -447.57 264 S(`v')456.02 264 Q 2.53('f)-.74 G(ollo)476.13 264 Q .03(wed by `) --.25 F(`x')-.74 E(')-.74 E .398(or `)131 276 R(`i')-.74 E .398(', at the be) --.74 F .397(ginning of a line or follo)-.15 F .397 -(wing a tab or space character)-.25 F 2.897(,a)-.4 G .397(nd follo)424.318 276 -R .397(wed by a `)-.25 F(`:')-.74 E .397(', an)-.74 F F3(ex)2.897 E F0 .108 -(command, and another `)131 288 R(`:')-.74 E .109 -('. This option is a security problem of immense proportions, and should not) --.74 F(be used under an)131 300 Q 2.5(yc)-.15 G(ircumstances.)210.27 300 Q/F4 -10/Times-Italic@0 SF(This option will ne)131 312 Q(ver be implemented.)-.15 E -F2(number, nu [off])102 324 Q F0 -(Precede each line displayed with its current line number)131 336 Q(.)-.55 E F2 -(open [on])102 348 Q F3(Ex)131 360 Q F0(only)2.5 E 5(.I)-.65 G 2.5(ft)173.46 -360 S(his option is not set, the)182.07 360 Q F1(open)2.5 E F0(and)2.5 E F1 -(visual)2.5 E F0(commands are disallo)2.5 E(wed.)-.25 E F2(optimize, opt [on]) -102 372 Q F3(Vi)131 384 Q F0(only)3.104 E 5.604(.T)-.65 G .604(hroughput of te) -177.448 384 R .604(xt is e)-.15 F .604 -(xpedited by setting the terminal to no do automatic carriage returns)-.15 F -.084(when printing more than one \(logical\) line of output, greatly speeding \ -output on terminals without ad-)131 396 R(dressable cursors when te)131 408 Q -(xt with leading white space is printed.)-.15 E F4 -(This option is not yet implemented.)131 420 Q F2 -(paragraphs, para [IPLPPPQPP LIpplpipbp])102 432 Q F3(Vi)131 444 Q F0(only) -2.783 E 5.283(.D)-.65 G .283(e\214ne additional paragraph boundaries for the) -177.916 444 R F1({)2.783 E F0(and)2.782 E F1(})2.782 E F0 2.782(commands. The) -2.782 F -.25(va)2.782 G .282(lue of this option).25 F -(must be a character string consisting of zero or more character pairs.)131 456 -Q .59(In the te)131 474 R .59(xt to be edited, the character string <ne)-.15 F -(wline>.<char)-.25 E .59(-pair>, \(where <char)-.2 F .59(-pair> is one of the) --.2 F .686(character pairs in the option')131 486 R 3.186(sv)-.55 G .686 -(alue\) de\214nes a paragraph boundary)259.99 486 R 5.686(.F)-.65 G .686(or e) -416.19 486 R .686(xample, if the option were)-.15 F(set to `)131 498 Q -(`LaA ##')-.74 E(', then all of the follo)-.74 E -(wing additional paragraph boundaries w)-.25 E(ould be recognized:)-.1 E F2 -(<newline>.La)161 510 Q(<newline>.A<space>)161 522 Q(<newline>.##)161 534 Q -(prompt [on])102 546 Q F3(Ex)131 558 Q F0(only)2.697 E 5.197(.T)-.65 G .197 -(his option causes)176.634 558 R F3(ex)2.698 E F0 .198 -(to prompt for command input with a `)2.698 F(`:')-.74 E 2.698('c)-.74 G .198 -(haracter; when it')433.948 558 R 2.698(sn)-.55 G .198(ot set,)515.912 558 R -(no prompt is displayed.)131 570 Q F2(readonly, ro [off])102 582 Q F0 .05(This\ - option causes a force \215ag to be required to attempt to write the \214le ba\ -ck to the original \214le name.)131 594 R .833(Setting this option is equi)131 -606 R -.25(va)-.25 G .833(lent to using the).25 F F3<ad52>4.999 E F0 .833 -(command line option, or editing a \214le which lacks)3.333 F -(write permission.)131 618 Q F2(recdir [/var/tmp/vi.recover])102 630 Q F0 -(The directory where reco)131 642 Q -.15(ve)-.15 G(ry \214les are stored.).15 E -F2(redraw, re [off])102 654 Q F3(Vi)131 666 Q F0(only)2.837 E 5.337(.T)-.65 G -.336(he editor simulates \(using great amounts of output\), an intelligent ter\ -minal on a dumb ter)176.914 666 R(-)-.2 E .714(minal \(e.g. during insertions \ -in visual mode the characters to the right of the cursor are refreshed as)131 -678 R(each input character is typed\).)131 690 Q 167.75(4.4BSD March)72 750 R -(18, 1994)2.5 E(7)535 750 Q EP -%%Page: 8 8 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(EX/VI REFERENCE MANU)72 48 Q -.834(AL \( 1 \))-.4 F -(BSD Reference Manual)258.235 48 Q(EX/VI REFERENCE MANU)390.972 48 Q -.834 -(AL \( 1 \))-.4 F/F1 10/Times-Italic@0 SF(This option is not yet implemented.) -131 96 Q/F2 10/Courier@0 SF(remap [on])102 108 Q F0 .856 -(If this option is set, it')131 120 R 3.356(sp)-.55 G .856 -(ossible to de\214ne macros in terms of other macros.)235.316 120 R .855 -(Otherwise, each k)5.855 F 1.155 -.15(ey i)-.1 H(s).15 E .366 -(only remapped up to one time.)131 132 R -.15(Fo)5.366 G 2.866(re).15 G .366 -(xample, if `)281.302 132 R(`A')-.74 E 2.866('i)-.74 G 2.866(sm)349.79 132 S -.366(apped to `)364.326 132 R(`B')-.74 E .367(', and `)-.74 F(`B')-.74 E 2.867 -('i)-.74 G 2.867(sm)467.059 132 S .367(apped to `)481.596 132 R(`C')-.74 E(',) --.74 E(The k)131 144 Q -.15(ey)-.1 G(strok).15 E 2.5(e`)-.1 G(`A')192.67 144 Q -2.5('w)-.74 G(ill be mapped to `)218.86 144 Q(`C')-.74 E 2.5('i)-.74 G(f)309.87 -144 Q/F3 10/Times-Bold@0 SF -.18(re)2.5 G(map).18 E F0(is set, and to `)2.5 E -(`B')-.74 E 2.5('i)-.74 G 2.5(fi)422.08 144 S 2.5(ti)430.69 144 S 2.5(sn)438.75 -144 S(ot set.)450.14 144 Q F2(remapmax [on])102 156 Q F0 .259 -(If this option is set, a k)131 168 R .558 -.15(ey m)-.1 H .258 -(ay only be remapped 50 times.).15 F .258(If it is not set, a k)5.258 F .558 --.15(ey m)-.1 H .258(ay be remapped an).15 F(in\214nite number of times, and t\ -he editor can be placed into in\214nite loops.)131 180 Q F2(report [5])102 192 -Q F0 .083(Set the threshold of the number of lines that need to be changed bef\ -ore a message will be displayed to)131 204 R .824(the user)131 216 R 5.824(.T) --.55 G .824(he v)177.088 216 R .824(alue is the lar)-.25 F .824(gest v)-.18 F -.824(alue about which the editor is silent, i.e. by def)-.25 F .823 -(ault, 6 lines must)-.1 F(change before the user is noti\214ed.)131 228 Q F2 -(ruler [off])102 240 Q/F4 10/Courier-Bold@0 SF(Vi)131 252 Q F0(only)2.5 E 5(.D) --.65 G(isplay a ro)177.35 252 Q(w/column ruler on the colon command line.)-.25 -E F2(scroll, scr [window / 2])102 264 Q F0 -(Set the number of lines scrolled by the)131 276 Q F4(vi)2.5 E F0(commands)2.5 -E F3(^D)2.5 E F0(and)2.5 E F3(^U)2.5 E F0(.)A(Historically)131 294 Q 2.762(,t) --.65 G(he)185.612 294 Q F4(ex)2.762 E F3(z)2.762 E F0 .262 -(command, when speci\214ed without a count, used tw)2.762 F 2.763(ot)-.1 G .263 -(imes the size of the scroll)436.755 294 R -.25(va)131 306 S -(lue; the POSIX 1003.2 standard speci\214ed the windo).25 E 2.5(ws)-.25 G -(ize, which is a better choice.)361.31 306 Q F2(sections, sect [NHSHH HUnhsh]) -102 318 Q F4(Vi)131 330 Q F0(only)4.4 E 6.9(.D)-.65 G 1.899 -(e\214ne additional section boundaries for the)181.15 330 R F3([[)4.399 E F0 -(and)4.399 E F3(]])4.399 E F0 4.399(commands. The)4.399 F F3(sections)4.399 E -F0(option)4.399 E .369(should be set to a character string consisting of zero \ -or more character pairs.)131 342 R .37(In the te)5.37 F .37(xt to be edited,) --.15 F .108(the character string <ne)131 354 R(wline>.<char)-.25 E .107 -(-pair>, \(where <char)-.2 F .107 -(-pair> is one of the character pairs in the op-)-.2 F(tion')131 366 Q 3.422 -(sv)-.55 G .922(alue\), de\214nes a section boundary in the same manner that) -161.402 366 R F3(paragraph)3.422 E F0 .923(option boundaries are)3.422 F -(de\214ned.)131 378 Q F2(shell, sh [environment variable SHELL, or /bin/sh])102 -390 Q F0 .026(Select the shell used by the editor)131 402 R 5.026(.T)-.55 G -.026(he speci\214ed path is the pathname of the shell in)278.672 402 R -.2(vo) --.4 G -.1(ke).2 G 2.526(db).1 G 2.526(yt)499.872 402 S(he)510.178 402 Q F4(vi) -2.526 E F3(!)2.526 E F0 .383(shell escape command and by the)131 414 R F4(ex) -2.883 E F3(shell)2.883 E F0 2.883(command. This)2.883 F .383 -(program is also used to resolv)2.883 F 2.883(ea)-.15 G .683 -.15(ny s)508.377 -414 T(hell).15 E(meta-characters in)131 426 Q F4(ex)2.5 E F0(commands.)2.5 E F2 -(shiftwidth, sw [8])102 438 Q F0 .026 -(Set the autoindent and shift command indentation width.)131 450 R .025 -(This width is used by the)5.025 F F3(autoindent)2.525 E F0(option)2.525 E -(and by the)131 462 Q F3(<)2.5 E F0(,)A F3(>)2.5 E F0 2.5(,a)C(nd)201 462 Q F3 -(shift)2.5 E F0(commands.)2.5 E F2(showdirty [off])102 474 Q F4(Vi)131 486 Q F0 -(only)2.5 E 5(.D)-.65 G(isplay an asterisk on the colon command line if the \ -\214le has been modi\214ed.)177.35 486 Q F2(showmatch, sm [off])102 498 Q F4 -(Vi)131 510 Q F0(only)2.793 E 5.293(.T)-.65 G .293(his option causes)176.826 -510 R F4(vi)2.793 E F0 2.793(,w)C .294(hen a `)273.048 510 R(`}')-.74 E 2.794 -('o)-.74 G 2.794(r`)321.95 510 S(`\)')330.664 510 Q 2.794('i)-.74 G 2.794(se) -348.818 510 S .294(ntered, to brie\215y mo)359.942 510 R .594 -.15(ve t)-.15 H -.294(he cursor the match-).15 F(ing `)131 522 Q(`{')-.74 E 2.5('o)-.74 G 2.5 -(r`)170.42 522 S(`\(')178.84 522 Q('. See the)-.74 E F3(matchtime)2.5 E F0 -(option for more information.)2.5 E F2(showmode [off])102 534 Q F4(Vi)131 546 Q -F0(only)3.631 E 6.131(.T)-.65 G 1.131(his option causes)178.502 546 R F4(vi) -3.631 E F0 1.131(to display the strings `)3.631 F(`Command')-.74 E 3.63('o)-.74 -G 3.63(r`)420.58 546 S(`Input')430.13 546 Q 3.63('o)-.74 G 3.63(nt)469.12 546 S -1.13(he colon com-)480.53 546 R -(mand line, based on the current mode of the editor)131 558 Q(.)-.55 E F2 -(sidescroll [16])102 570 Q F4(Vi)131 582 Q F0(only)3.003 E 5.503(.S)-.65 G .504 -(ets the number of columns that are shifted to the left or right, when)176.696 -582 R F4(vi)3.004 E F0 .504(is doing left-right)3.004 F -(scrolling and the left or right mar)131 594 Q(gin is crossed.)-.18 E(See the)5 -E F3(leftright)2.5 E F0(option for more information.)2.5 E F2 -(slowopen, slow [off])102 606 Q F0 1.205(This option af)131 618 R 1.205 -(fects the display algorithm used by)-.25 F F4(vi)3.705 E F0 3.705(,h)C 1.205 -(olding of)361.915 618 R 3.704(fd)-.25 G 1.204(isplay updating during input of) -411.294 618 R(ne)131 630 Q 2.5(wt)-.25 G -.15(ex)152.69 630 S 2.5(tt).15 G 2.5 -(oi)170.04 630 S(mpro)180.32 630 Q .3 -.15(ve t)-.15 H -(hroughput when the terminal in use is slo).15 E 2.5(wa)-.25 G -(nd unintelligent.)395.03 630 Q F1(This option is not yet implemented.)131 642 -Q F2(sourceany [off])102 654 Q F0 .756(If this option is turned on,)131 666 R -F4(vi)3.256 E F0 .756(historically read startup \214les that were o)3.256 F -.756(wned by someone other than)-.25 F .834(the editor user)131 678 R 5.834(.S) --.55 G .834(ee the ST)203.222 678 R(AR)-.93 E .834(TUP INFORMA)-.6 F .834 -(TION section for more information.)-1.11 F .833(This option is a)5.833 F -(security problem of immense proportions, and should not be used under an)131 -690 Q 2.5(yc)-.15 G(ircumstances.)442.2 690 Q 167.75(4.4BSD March)72 750 R -(18, 1994)2.5 E(8)535 750 Q EP -%%Page: 9 9 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(EX/VI REFERENCE MANU)72 48 Q -.834(AL \( 1 \))-.4 F -(BSD Reference Manual)258.235 48 Q(EX/VI REFERENCE MANU)390.972 48 Q -.834 -(AL \( 1 \))-.4 F/F1 10/Times-Italic@0 SF(This option will ne)131 96 Q -(ver be implemented.)-.15 E/F2 10/Courier@0 SF(tabstop, ts [8])102 108 Q F0 -(This option sets tab widths for the editor display)131 120 Q(.)-.65 E F2 -(taglength, tl [0])102 132 Q F0 1.345(This option sets the maximum number of c\ -haracters that are considered signi\214cant in a tag name.)131 144 R -(Setting the v)131 156 Q(alue to 0 mak)-.25 E -(es all of the characters in the tag name signi\214cant.)-.1 E F2 -(tags, tag [tags /var/db/libc.tags /sys/kern/tags])102 168 Q F0 -(Sets the list of tags \214les, in search order)131 180 Q 2.5(,w)-.4 G -(hich are used when the editor searches for a tag.)301.97 180 Q F2 -(term, ttytype, tty [environment variable TERM])102 192 Q F0 .813 -(Set the terminal type.)131 204 R .813(Setting this option causes)5.813 F/F3 10 -/Courier-Bold@0 SF(ex/vi)3.313 E F0 .812(to set \(or reset\) the en)3.313 F -.812(vironmental v)-.4 F(ariable)-.25 E F2(TERM)131 216 Q F0(.)A F2 -(terse [off])102 228 Q F0 .759 -(This option has historically made editor messages less v)131 240 R 3.259 -(erbose. It)-.15 F .76(has no ef)3.259 F .76(fect in this implementa-)-.25 F -2.5(tion. See)131 252 R(the)2.5 E/F4 10/Times-Bold@0 SF -.1(ve)2.5 G(rbose).1 E -F0(option for more information.)2.5 E F2(timeout, to [on])102 264 Q F0 .684 -(If this option is set,)131 276 R F3(ex/vi)3.184 E F0 -.1(wa)3.184 G .684 -(its for a speci\214c period for a subsequent k).1 F .983 -.15(ey t)-.1 H 3.183 -(oc).15 G .683(omplete a k)459.051 276 R .983 -.15(ey m)-.1 H(ap-).15 E .481 -(ping \(see the)131 288 R F4 -.1(ke)2.981 G(ytime).1 E F0 2.981(option\). If) -2.981 F .482(the option is not set, the editor w)2.981 F .482 -(aits until enough k)-.1 F -.15(ey)-.1 G 2.982(sa).15 G .482(re entered)499.818 -288 R(to resolv)131 300 Q 2.5(et)-.15 G(he ambiguity)175.29 300 Q 2.5(,r)-.65 G --2.25 -.15(eg a)235.47 300 T(rdless of ho).15 E 2.5(wl)-.25 G(ong it tak)308.06 -300 Q(es.)-.1 E F2(ttywerase [off])102 312 Q F3(Vi)131 324 Q F0(only)2.95 E -5.45(.T)-.65 G .45(his option changes ho)177.14 324 R(w)-.25 E F3(vi)2.95 E F0 -.45(does w)2.95 F .449(ord erase during te)-.1 F .449(xt input.)-.15 F .449 -(If this option is set, te)5.449 F .449(xt is)-.15 F(brok)131 336 Q .881 -(en up into tw)-.1 F 3.381(oc)-.1 G .881 -(lasses, blank characters and non-blank characters.)217.094 336 R .882 -(Changing from one class to)5.882 F(another marks the end of a w)131 348 Q -(ord.)-.1 E F2(verbose [off])102 360 Q F0(only)131 372 Q(.)-.65 E F3(Vi)5.61 E -F0 .61(historically bells the terminal for man)3.11 F 3.11(yo)-.15 G -.15(bv) -338.18 372 S .61(ious mistak).15 F .61(es, e.g. trying to mo)-.1 F .91 -.15 -(ve p)-.15 H .61(ast the left-).15 F .462(hand mar)131 384 R .463 -(gin, or past the end of the \214le.)-.18 F .463 -(If this option is set, an error message is displayed for all er)5.463 F(-)-.2 -E(rors.)131 396 Q F2(w300 [no default])102 408 Q F3(Vi)131 420 Q F0(only)3.639 -E 6.139(.S)-.65 G 1.139(et the windo)177.968 420 R 3.639(ws)-.25 G 1.139 -(ize if the baud rate is less than 1200 baud.)244.185 420 R 1.139(See the)6.139 -F F4(windo)3.639 E(w)-.1 E F0 1.138(option for)3.639 F(more information.)131 -432 Q F2(w1200 [no default])102 444 Q F3(Vi)131 456 Q F0(only)2.568 E 5.068(.S) --.65 G .068(et the windo)175.826 456 R 2.568(ws)-.25 G .068 -(ize if the baud rate is equal to 1200 baud.)238.83 456 R .069(See the)5.069 F -F4(windo)2.569 E(w)-.1 E F0 .069(option for more)2.569 F(information.)131 468 Q -F2(w9600 [no default])102 480 Q F3(Vi)131 492 Q F0(only)2.968 E 5.468(.S)-.65 G -.468(et the windo)176.626 492 R 2.968(ws)-.25 G .467 -(ize if the baud rate is greater than 1200 baud.)240.83 492 R .467(See the) -5.467 F F4(windo)2.967 E(w)-.1 E F0 .467(option for)2.967 F(more information.) -131 504 Q F2(warn [on])102 516 Q F3(Ex)131 528 Q F0(only)2.978 E 5.478(.T)-.65 -G .479(his option causes a w)177.196 528 R .479 -(arning message to the terminal if the \214le has been modi\214ed, since it)-.1 -F -.1(wa)131 540 S 2.5(sl).1 G(ast written, before a)151.73 540 Q F4(!)2.5 E F0 -(command.)2.5 E F2(window, w, wi [environment variable LINES])102 552 Q F0 .185 -(This option determines the def)131 564 R .185 -(ault number of lines in a screenful, as written by the)-.1 F F4(z)2.685 E F0 -2.685(command. It)2.685 F(al-)2.685 E .25 -(so determines the number of lines scrolled by the)131 576 R F3(vi)2.751 E F0 -(commands)2.751 E F4(^F)2.751 E F0(and)2.751 E F4(^B)2.751 E F0 2.751(.T)C .251 -(he v)443.966 576 R .251(alue of windo)-.25 F 2.751(wc)-.25 G(an)530.56 576 Q -.246(be unrelated to the real screen size, although it starts out as the numbe\ -r of lines on the screen \(see the)131 588 R .09(SCREEN SIZING section\).)131 -600 R .09(Setting the v)5.09 F .09(alue of the)-.25 F F4(windo)2.59 E(w)-.1 E -F0 .09(option is the same as using the)2.59 F F3<ad77>4.257 E F0(com-)2.591 E -(mand line option.)131 612 Q .047(If the v)131 630 R .047(alue of)-.25 F F4 -(windo)2.547 E(w)-.1 E F0 .046(\(as set by the)2.547 F F4(windo)2.546 E(w)-.1 E -F0(,)A F4(w300)2.546 E F0(,)A F4(w1200)2.546 E F0(or)2.546 E F4(w9600)2.546 E -F0 .046(options\) is smaller than the ac-)2.546 F .648 -(tual size of the screen, lar)131 642 R .648(ge screen mo)-.18 F -.15(ve)-.15 G -.648(ments will result in displaying only that smaller number of).15 F .24 -(lines on the screen.)131 654 R .24(\(Further mo)5.24 F -.15(ve)-.15 G .24 -(ments in that same area will result in the screen being \214lled.\)).15 F -(This)5.24 E 1.116(can pro)131 666 R 1.116(vide a performance impro)-.15 F -.15 -(ve)-.15 G 1.116(ment when vie).15 F 1.116(wing dif)-.25 F 1.116 -(ferent places in one or more \214les o)-.25 F -.15(ve)-.15 G 3.616(ra).15 G -(slo)131 678 Q 2.5(wl)-.25 G(ink.)154.92 678 Q F2(wrapmargin, wm [0])102 690 Q -F3(Vi)131 702 Q F0(only)2.873 E 5.373(.I)-.65 G 2.873(ft)174.206 702 S .373 -(he v)183.189 702 R .373(alue of wrapmar)-.25 F .373(gin is non-zero,)-.18 F F3 -(vi)2.873 E F0 .373(will break lines, that are more than that number)2.873 F -167.75(4.4BSD March)72 750 R(18, 1994)2.5 E(9)535 750 Q EP -%%Page: 10 10 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(EX/VI REFERENCE MANU)72 48 Q -.834(AL \( 1 \))-.4 F -(BSD Reference Manual)258.235 48 Q(EX/VI REFERENCE MANU)390.972 48 Q -.834 -(AL \( 1 \))-.4 F .403(of characters long, into tw)131 96 R 2.903(ol)-.1 G .404 -(ines at the blank character closest to the v)247.895 96 R 2.904(alue. If)-.25 -F(wrapmar)2.904 E .404(gin is 0, or if)-.18 F(there is no blank character upon\ - which to break the line, the line will not be brok)131 108 Q(en.)-.1 E/F1 10 -/Courier@0 SF(wrapscan, ws [on])102 120 Q F0 .31 -(This option causes searches to wrap around the end or the be)131 132 R .31 -(ginning of the \214le, and back to the start-)-.15 F(ing point.)131 144 Q -(Otherwise, the end or be)5 E(ginning of the \214le terminates the search.)-.15 -E F1(writeany, wa [off])102 156 Q F0 .23(If this option is set, \214le-o)131 -168 R -.15(ve)-.15 G .23(rwriting checks that w).15 F .23 -(ould usually be made before the)-.1 F/F2 10/Times-Bold@0 SF(write)2.73 E F0 -(and)2.73 E F2(xit)2.73 E F0(com-)2.73 E .343 -(mands, or before an automatic write \(see the)131 180 R F2(auto)2.842 E(write) --.1 E F0 .342(option\), are not made.)2.842 F .342(This allo)5.342 F .342 -(ws a write to)-.25 F(an)131 192 Q 2.5<798c>-.15 G(le, pro)153.35 192 Q -(vided the \214le permissions allo)-.15 E 2.5(wi)-.25 G(t.)311 192 Q 167.75 -(4.4BSD March)72 750 R(18, 1994)2.5 E(10)530 750 Q EP -%%Trailer -end -%%EOF diff --git a/usr.bin/vi/docs/vi.ref.txt b/usr.bin/vi/docs/vi.ref.txt deleted file mode 100644 index e5fc627072db..000000000000 --- a/usr.bin/vi/docs/vi.ref.txt +++ /dev/null @@ -1,634 +0,0 @@ -EX/VI REFERENCE MANUAL(1) BSD Reference Manual EX/VI REFERENCE MANUAL(1) - -NNAAMMEE - eexx,, vvii,, vviieeww - text editors - -DDEESSCCRRIIPPTTIIOONN - VVii is a screen oriented text editor. EExx is a line-oriented text editor. - EExx and vvii are different interfaces to the same program, and it is possi- - ble to switch back and forth during an edit session. VViieeww is the equiva- - lent of using the --RR (read-only) option of vvii. - - This reference manual is the one provided with the nneexx//nnvvii versions of - the eexx//vvii text editors. NNeexx//nnvvii are intended as bug-for-bug compatible - replacements for the original Fourth Berkeley Software Distribution - (4BSD) eexx and vvii programs. This reference manual is accompanied by a - traditional-style manual page. That manual page describes the function- - ality found in eexx//vvii in far less detail than the description here. In - addition, it describes the system interface to eexx//vvii, e.g. command line - options, environmental variables, and similar things. - - This reference is intended for users already familiar with eexx//vvii. Anyone - else should almost certainly read a good tutorial on the editor first. - If you're in an unfamiliar environment, and you absolutely have to get - work done immediately, see the section entitled FAST STARTUP in the manu- - al page. It's probably enough to get you going. - - For the rest of this reference, nneexx//nnvvii is used only when it's necessary - to distinguish it from the historic implementations of eexx//vvii. - -AADDDDIITTIIOONNAALL FFEEAATTUURREESS - There are a few features in nneexx//nnvvii that are not found in historic ver- - sions of eexx//vvii. A list of those features is as follows: - - 8-bit clean data, large lines, files - NNvvii//nneexx will edit any format file. Line lengths are limited by - available memory, and file sizes are limited by available disk - space. The command ``^Vx[0-9A-Fa-f]*'', in input mode, will in- - sert any legal character value into the text. - - Split screens - The command ``:sp[lit] [file ...]'' splits the screen in vi mode. - The key ``^W'' switches between the foreground screens, and the - ``:resize count'' command can be used to grow or shrink a partic- - ular screen. - - Background and foreground screens - The command ``:bg'' backgrounds the current screen, and the com- - mand ``:fg [file]'' foregrounds the backgrounded screen that is - editing the specified file, or, by default, the first background - screen on the queue. The command ``:di[splay] s[creens]'' lists - the background screens. - - Shell screens - The command ``:sc[ript] [file ...]'' runs a shell in the screen. - Editing is unchanged, with the exception that a <carriage-return> - enters the current line (stripped of any prompt) as input to the - shell. - - Tag stacks - Tags are now maintained in a stack. The command ``^T'' returns - to the previous tag location. The command ``:tagpop [number - file]'' returns to the most recent tag location by default, or, - optionally to a specific tag number in the tag stack, or the most - recent tag from the specified file. Use the command ``:di[splay] - t[ags]'' to view the tags stack. The command ``:tagtop'' returns - - to the top of the tag stack. - - New displays - The command ``:di[splay] b[uffers] s[creens] t[ags]'' can be - used to display, respectively, the current cut buffers, the back- - grounded screens, and the tags stack. - - Infinite undo - The changes made during an edit session may be rolled backward - and forward. A '.' command immediately after a 'u' command con- - tinues either forward or backward depending on whether the 'u' - command was an undo or a redo. - - Usage information - The command ``:exu[sage] [cmd]'' and ``viu[sage] [key]'' provide - usage information for all of the ex and vi commands by default, - or, optionally, for a specific command or key. - - Extended regular expressions - The ``:set extended'' command treats search and other command - regular expressions as extended (egrep(1) style) regular expres- - sions. - - Word search - The command ``^A'' searches for the word referenced by the cur- - sor. - - Number increment - The command ``#'' increments the number referenced by the cursor. - - Previous file - The command ``:prev[ious][!]'' edits the previous file from the - argument list. - - Left-Right scrolling - The command ``:set leftright'' makes nnvvii do left-right screen - scrolling, instead of the traditional vvii line wrapping. - -RREECCOOVVEERRYY - There is no recovery program for nnvvii, nor does nnvvii run setuid. Users may - recover any file which they may read, and the superuser may recover any - edit session. - - Edit sessions are backed by files in _/_v_a_r_/_t_m_p_/_v_i_._r_e_c_o_v_e_r, and are named - ``vi.XXXX'', where ``XXXX'' is a number related to the process id. When - a file is first modified, a second file, which contains an email message - for the user, is created, and is named ``recover.XXXX'', where, again, - ``XXXX'' is associated with the process id. Both files are removed at - the end of a normal edit session, but will remain if the edit session is - abnormally terminated or the user enters the ex/vi ``preserve'' command. - The use of the _/_v_a_r_/_t_m_p directory may be changed setting the rreeccddiirr op- - tion in the user's or system startup information. - - The recovery directory should have the ``sticky-bit'' set so that only - the owners of files may remove them. If this is not possible on the sys- - tem, then a pseudo-user should own the recovery directory. The recovery - directory must be both read and write-able by any user. - - The recovery file has all of the necessary information in it to enable - the user to recover the edit session. In addition, it has all of the - necessary email headers for sendmail. When the system is rebooted, all - of the files in _/_v_a_r_/_t_m_p_/_v_i_._r_e_c_o_v_e_r named ``recover.XXXX'' should be sent - by email, using the --tt flag of sendmail (or a similar mechanism in other - mailers). A simple way to do this is to insert the following script into - - your _/_e_t_c_/_r_c_._l_o_c_a_l (or other startup) file: - virecovery=`echo /var/tmp/vi.recover/recover.*` - if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then - echo 'Recovering vi editor sessions' - for i in $virecovery; do - sendmail -t < $i - done - fi - - If eexx//vvii receives a hangup (SIGHUP) signal, it will email the recovery - information to the user itself. - - If you don't have the sendmail program on your system, the source file - _n_v_i_/_r_e_c_o_v_e_r_._c will have to be modified to use your local mail delivery - programs. - -SSTTAARRTTUUPP IINNFFOORRMMAATTIIOONN - EExx//vvii interprets one of two possible environmental variables and reads up - to three of five possible files during startup. The variables and files - are expected to contain eexx commands, not vvii commands. In addition, they - are interpreted _b_e_f_o_r_e the file to be edited is read, and therefore many - eexx commands may not be used. Generally, any command that requires output - to the screen or that needs a file upon which to operate, will cause an - error if included in a startup file or environmental variable. - - First, the file _/_e_t_c_/_v_i_._e_x_r_c is read. Second, the environmental variable - NEXINIT (or the variable EXINIT, if NEXINIT isn't set) is interpreted. - Third, if neither NEXINIT or EXINIT was set, the file _$_H_O_M_E_/_._n_e_x_r_c (or - the file _$_H_O_M_E_/_._e_x_r_c, if _$_H_O_M_E_/_._n_e_x_r_c doesn't exist) is read. Fourth, - the file _._n_e_x_r_c (or the file _._e_x_r_c, if _._n_e_x_r_c doesn't exist) is read. - - Startup files will not be read if they are owned by anyone other than the - real user-id of the user running vvii, (or by ``root'' in the case of the - file _/_e_t_c_/_v_i_._e_x_r_c) or if they are writable by anyone other than the own- - er. Home directory startup files (i.e. _$_H_O_M_E_/_._n_e_x_r_c and _$_H_O_M_E_/_._e_x_r_c) - will not be read if the ``HOME'' environmental variable is not set. Lo- - cal startup files (i.e. _._n_e_x_r_c and _._e_x_r_c) will not be read if the eexxrrcc - option is turned off in the _/_e_t_c_/_v_i_._e_x_r_c, _$_H_O_M_E_/_._n_e_x_r_c, or _$_H_O_M_E_/_._e_x_r_c - files, or in the NEXINIT or EXINIT environmental variables. It is not an - error for any of the startup environmental variables or files not to ex- - ist. - - Because the eexx command set supported by nneexx//nnvvii is a superset of the com- - mand set supported by most historical implementations of eexx, nneexx//nnvvii can - use the startup files created for the historical implementations, but the - converse is often not true. - -SSIIZZIINNGG TTHHEE SSCCRREEEENN - The size of the screen can be set in a number of ways. EExx//vvii takes the - following steps until values are obtained for both the number of rows and - number of columns in the screen. - - 1. If the environmental variable LINES exists, it is used to specify - the number of rows in the screen. - 2. If the environmental variable COLUMNS exists, it is used to specify - the number of columns in the screen. - 3. The TIOCGWINSZ ioctl(2) is attempted on the standard error file de- - scriptor. - 4. The termcap entry is checked for the ``li'' entry (rows) and the - ``co'' entry (columns). - 5. The number of rows is set to 24, and the number of columns is set to - 80. - - If a window change size signal (SIGWINCH) is received, the same steps are - taken with the exception that the first two steps are skipped. - -RREEGGUULLAARR EEXXPPRREESSSSIIOONNSS AANNDD RREEPPLLAACCEEMMEENNTT SSTTRRIINNGGSS - Regular expressions are used in line addresses, as the first part of - ssuubbssttiittuuttee, gglloobbaall, and vvgglloobbaall commands, and in search patterns. - - The regular expressions supported by eexx and vvii are, by default, the Basic - Regular Expressions (BRE's) described in the IEEE POSIX Standard 1003.2. - The eexxtteennddeedd option causes all regular expressions to be interpreted as - the Extended Regular Expressions (ERE's) described by the same standard. - (See re_format(7) for more information. Generally speaking, BRE's are - ed(1) and grep(1) style regular expressions, and ERE's are egrep(1) style - regular expressions.) - - There are some special strings and characters that can be used in RE's: - 1. An empty RE (e.g. ``//'') is equivalent to the last RE used. - 2. The construct ``\<'' matches the beginning of a word. - 3. The construct ``\>'' matches the end of a word. - 4. The character ``~'' matches the replacement part of the last - ssuubbssttiittuuttee command. - - When the mmaaggiicc option is _n_o_t set, the only characters with special mean- - ings are ``^'' at the beginning of an RE, ``$'' at the end of an RE, and - the escaping character ``\''. The characters ``.'', ``*'', ``['', and - ``~'' are treated as ordinary characters unless preceded by a ``\''; when - preceded by a ``\'' they regain their special meaning. - - Replacement strings are the second part of a ssuubbssttiittuuttee command. - - The character ``&'' (or ``\&'' if the mmaaggiicc option is _n_o_t set) in the re- - placement string stands for the text matched by the RE that's being re- - placed. The character ``~'' (or ``\~'' if the mmaaggiicc option is _n_o_t set) - stands for the replacement part of the previous ssuubbssttiittuuttee command. - - The string ``\#'', where ``#'' is an integer value from 1 to 9, stands - for the text matched by the portion of the RE enclosed in the #'th set of - escaped parentheses, e.g. ``\('' and ``\)''. For example, - ``s/abc\(.*\)def/\1/'' deletes the strings ``abc'' and ``def'' from the - matched pattern. - - The strings ``\l'', ``\u'', ``\L'', and ``\U'' can be used to modify the - case of elements in the replacement string. The string ``\l'' causes the - next character to be converted to lowercase; the string ``\u'' behaves - similarly, but converts to uppercase. The strings ``\L'' causes charac- - ters up to the end of the string or the next occurrence of the strings - ``\e'' or ``\E'' to be converted to lowercase; the string ``\U'' behaves - similarly, but converts to uppercase. - - In vvii, inserting a <control-M> into the replacement string will cause the - matched line to be split into two lines at that point. - -SSEETT OOPPTTIIOONNSS - There are a large number of options that may be set (or unset) to change - the editor's behavior. This section describes the options, their abbre- - viations and their default values. - - In each entry below, the first part of the tag line is the full name of - the option, followed by any equivalent abbreviations. (Regardless of the - abbreviations, it is only necessary to use the minimum number of charac- - ters necessary to distinguish an abbreviation from all other commands for - it to be accepted, in nneexx//nnvvii. Historically, only the full name and the - official abbreviations were accepted by eexx//vvii. Using full names in your - startup files and environmental variables will probably make them more - portable.) The part in square brackets is the default value of the op- - tion. Most of the options are boolean, i.e. they are either on or off, - and do not have an associated value. - - - Options apply to both eexx and vvii modes, unless otherwise specified. - - For information on modifying the options or to display the options and - their current values, see the ``set'' command in the Ex Commands section. - altwerase [off] - VVii only. Change how vvii does word erase during text input. When - this option is set, text is broken up into three classes: alphabet- - ic, numeric and underscore characters, other non-blank characters, - and blank characters. Changing from one class to another marks the - end of a word. In addition, the class of the first character - erased is ignored (which is exactly what you want when erasing - pathname components). - autoindent, ai [off] - If this option is set, whenever you create a new line (using the vvii - AA, aa, CC, cc, II, ii, OO, oo, RR, rr, SS, and ss commands, or the eexx aappppeenndd, - cchhaannggee, and iinnsseerrtt commands) the new line is automatically indented - to align the cursor with the first non-blank character of the line - from which you created it. Lines are indented using tab characters - to the extent possible (based on the value of the ttaabbssttoopp option) - and then using space characters as necessary. For commands insert- - ing text into the middle of a line, any blank characters to the - right of the cursor are discarded, and the first non-blank charac- - ter to the right of the cursor is aligned as described above. - - The indent characters are themselves somewhat special. If you do - not enter more characters on the new line before moving moving to - another line, or entering <escape>, the indent character will be - deleted and the line will be empty. For example, if you enter - <carriage-return> twice in succession, the line created by the - first <carriage-return> will not have any characters in it, regard- - less of the indentation of the previous or subsequent line. - - Indent characters also require that you enter additional erase - characters to delete them. For example, if you have an indented - line, containing only blanks, the first <word-erase> character you - enter will erase up to end of the indent characters, and the second - will erase back to the beginning of the line. (Historically, only - the ^^DD key would erase the indent characters. Both the ^^DD key and - the usual erase keys work in nnvvii ..)) In addition, if the cursor is - positioned at the end of the indent characters, the keys ``0^D'' - will erase all of the indent characters for the current line, re- - setting the indentation level to 0. Similarly, the keys ``^^D'' - (i.e. a carat followed by a <control-D>) will erase all of the in- - dent characters for the current line, leaving the indentation level - for future created lines unaffected. - - Finally, if aauuttooiinnddeenntt is set, the SS and cccc commands change from - the first non-blank of the line to the end of the line, instead of - from the beginning of the line to the end of the line. - autoprint, ap [off] - EExx only. EExx only. Cause the current line to be automatically dis- - played after the eexx commands <<, >>, ccooppyy, ddeelleettee, jjooiinn, mmoovvee, ppuutt, - tt, UUnnddoo, and uunnddoo. This automatic display is suppressed during - gglloobbaall and vvgglloobbaall commands, and for any command where optional - flags are used to explicitly display the line. - autowrite, aw [off] - If this option is set, the vvii !! ^^^^ ^^]] and ^^ZZ commands, and the eexx - eeddiitt, nneexxtt, rreewwiinndd, ssttoopp, ssuussppeenndd, ttaagg, ttaaggppoopp, and ttaaggttoopp commands - automatically write the current file back to the current file name - if it has been modified since it was last written. If the write - fails, the command fails and goes no further. - - Appending the optional force flag ``!'' to the eexx commands nneexxtt, - rreewwiinndd, ssttoopp, ssuussppeenndd, ttaagg, ttaaggppoopp, and ttaaggttoopp stops the automatic - write from being attempted. - - - (Historically, the nneexxtt command ignored the optional force flag.) - Note, the eexx commands eeddiitt, qquuiitt, sshheellll, and xxiitt are _n_o_t affected - by the aauuttoowwrriittee option. - beautify, bf [off] - If this option is set, all control characters that are not current- - ly being specially interpreted, other than <tab>, <newline>, and - <form-feed>, are discarded from commands read in by eexx from command - files, and from input text entered to vvii (either into the file or - to the colon command line). Text files read by eexx//vvii are _n_o_t af- - fected by the bbeeaauuttiiffyy option. - cdpath [environment variable CDPATH, or ``.''] - This option is used to specify a colon separated list of directo- - ries which are used as path prefixes for any relative path names - used as arguments for the ccdd command. The value of this option de- - faults to the value of the environmental variable CDPATH if it is - set, otherwise to the current directory. For compatibility with - the POSIX 1003.2 shell, the ccdd command does _n_o_t check the current - directory as a path prefix for relative path names unless it is ex- - plicitly specified. It may be so specified by entering an empty - string or a ``.'' into the CDPATH variable or the option value. - columns, co [80] - The number of columns in the screen. Setting this option causes - eexx//vvii to set (or reset) the environmental variable COLUMNS. See the - SCREEN SIZING section for more information. - comment [off] - VVii only. If the first non-empty line of the file begins with the - string ``/*'', this option causes vvii to skip to the end of that C - comment (probably a terribly boring legal notice) before displaying - the file. - directory, dir [environment variable TMPDIR, or /tmp] - The directory where temporary files are created. The environmental - variable TMPDIR is used as the default value if it exists, other- - wise _/_t_m_p is used. - edcompatible, ed [off] - This option causes the presence or absence of gg and cc suffixes on - ssuubbssttiittuuttee commands to be remembered, and to be toggled by repeat- - ing the suffices. The suffix rr makes the substitution be as in the - ~~ command, instead of like the && command. - _T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - errorbells, eb [off] - EExx only. Causes eexx error messages to be preceded by a bell. - _T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - exrc, ex [off] - If this option is turned off in the system or $HOME startup files, - the local startup files are never read (unless they are the same as - the system or $HOME startup files). Turning it on has no effect, - i.e. the normal checks for local startup files are performed, re- - gardless. See the STARTUP INFORMATION section for more informa- - tion. - extended [off] - This option causes all regular expressions to be treated as POSIX - 1003.2 extended regular expressions (which are similar to historic - egrep(1) style expressions). - flash [on] - This option causes the screen to flash instead of beeping the key- - board, on error, if the terminal has the capability. - hardtabs, ht [8] - This option defines the spacing between hardware tab settings, i.e. - the tab expansion done by the operating system and/or the terminal - itself. As nneexx//nnvvii never writes tabs to the terminal, unlike his- - toric versions of eexx//vvii, this option does not currently have any - affect. - ignorecase, ic [off] - This option causes regular expressions, both in eexx commands and in - - searches, to be evaluated in a case-insensitive manner. - keytime [6] - The 10th's of a second eexx//vvii waits for a subsequent key to complete - a key mapping. - leftright [off] - VVii only. This option causes the screen to be scrolled left-right - to view lines longer than the screen, instead of the traditional vvii - screen interface which folds long lines at the right-hand margin of - the terminal. - lines, li [24] - VVii only. The number of lines in the screen. Setting this option - causes eexx//vvii to set (or reset) the environmental variable LINES. - See the Screen Sizing section for more information. - lisp [off] - VVii only. This option changes the behavior of the vvii ((, )), {{, }}, [[[[ - and ]]]] commands to match the Lisp language. Also, the aauuttooiinnddeenntt - option's behavior is changed to be appropriate for Lisp. - _T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - list [off] - This option causes lines to be displayed in an unambiguous fashion. - Specifically, tabs are displayed as control characters, i.e. - ``^I'', and the ends of lines are marked with a ``$'' character. - magic [on] - This option is on by default. Turning the mmaaggiicc option off causes - all regular expression characters except for ``^'' and ``$'', to be - treated as ordinary characters. To re-enable characters individu- - ally, when the mmaaggiicc option is off, precede them with an ``\''. See - the REGULAR EXPRESSIONS AND REPLACEMENT STRINGS section for more - information. - matchtime [7] - VVii only. The 10th's of a second eexx//vvii pauses on the matching char- - acter when the sshhoowwmmaattcchh option is set. - mesg [on] - This option allows other users to contact you using the talk(1) and - write(1) utilities, while you are editing. EExx//vvii does not turn - message on, i.e. if messages were turned off when the editor was - invoked, they will stay turned off. This option only permits you - to disallow messages for the edit session. See the mesg(1) utility - for more information. - modelines, modeline [off] - If the mmooddeelliinneess option is set, eexx//vvii has historically scanned the - first and last five lines of each file as it is read for editing, - looking for any eexx commands that have been placed in those lines. - After the startup information has been processed, and before the - user starts editing the file, any commands embedded in the file are - executed. Commands are recognized by the letters ``e'' or ``v'' - followed by ``x'' or ``i'', at the beginning of a line or following - a tab or space character, and followed by a ``:'', an eexx command, - and another ``:''. This option is a security problem of immense - proportions, and should not be used under any circumstances. - _T_h_i_s _o_p_t_i_o_n _w_i_l_l _n_e_v_e_r _b_e _i_m_p_l_e_m_e_n_t_e_d_. - number, nu [off] - Precede each line displayed with its current line number. - open [on] - EExx only. If this option is not set, the ooppeenn and vviissuuaall commands - are disallowed. - optimize, opt [on] - VVii only. Throughput of text is expedited by setting the terminal - to no do automatic carriage returns when printing more than one - (logical) line of output, greatly speeding output on terminals - without addressable cursors when text with leading white space is - printed. - _T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - paragraphs, para [IPLPPPQPP LIpplpipbp] - VVii only. Define additional paragraph boundaries for the {{ and }} - commands. The value of this option must be a character string con- - sisting of zero or more character pairs. - - In the text to be edited, the character string <newline>.<char- - pair>, (where <char-pair> is one of the character pairs in the op- - tion's value) defines a paragraph boundary. For example, if the - option were set to ``LaA ##'', then all of the following additional - paragraph boundaries would be recognized: - <newline>.La - <newline>.A<space> - <newline>.## - prompt [on] - EExx only. This option causes eexx to prompt for command input with a - ``:'' character; when it's not set, no prompt is displayed. - readonly, ro [off] - This option causes a force flag to be required to attempt to write - the file back to the original file name. Setting this option is - equivalent to using the --RR command line option, or editing a file - which lacks write permission. - recdir [/var/tmp/vi.recover] - The directory where recovery files are stored. - redraw, re [off] - VVii only. The editor simulates (using great amounts of output), an - intelligent terminal on a dumb terminal (e.g. during insertions in - visual mode the characters to the right of the cursor are refreshed - as each input character is typed). - _T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - remap [on] - If this option is set, it's possible to define macros in terms of - other macros. Otherwise, each key is only remapped up to one time. - For example, if ``A'' is mapped to ``B'', and ``B'' is mapped to - ``C'', The keystroke ``A'' will be mapped to ``C'' if rreemmaapp is set, - and to ``B'' if it is not set. - remapmax [on] - If this option is set, a key may only be remapped 50 times. If it - is not set, a key may be remapped an infinite number of times, and - the editor can be placed into infinite loops. - report [5] - Set the threshold of the number of lines that need to be changed - before a message will be displayed to the user. The value is the - largest value about which the editor is silent, i.e. by default, 6 - lines must change before the user is notified. - ruler [off] - VVii only. Display a row/column ruler on the colon command line. - scroll, scr [window / 2] - Set the number of lines scrolled by the vvii commands ^^DD and ^^UU. - - Historically, the eexx zz command, when specified without a count, - used two times the size of the scroll value; the POSIX 1003.2 stan- - dard specified the window size, which is a better choice. - sections, sect [NHSHH HUnhsh] - VVii only. Define additional section boundaries for the [[[[ and ]]]] - commands. The sseeccttiioonnss option should be set to a character string - consisting of zero or more character pairs. In the text to be - edited, the character string <newline>.<char-pair>, (where <char- - pair> is one of the character pairs in the option's value), defines - a section boundary in the same manner that ppaarraaggrraapphh option bound- - aries are defined. - shell, sh [environment variable SHELL, or /bin/sh] - Select the shell used by the editor. The specified path is the - pathname of the shell invoked by the vvii !! shell escape command and - by the eexx sshheellll command. This program is also used to resolve any - shell meta-characters in eexx commands. - shiftwidth, sw [8] - Set the autoindent and shift command indentation width. This width - is used by the aauuttooiinnddeenntt option and by the <<, >>, and sshhiifftt com- - - mands. - showdirty [off] - VVii only. Display an asterisk on the colon command line if the file - has been modified. - showmatch, sm [off] - VVii only. This option causes vvii, when a ``}'' or ``)'' is entered, - to briefly move the cursor the matching ``{'' or ``(''. See the - mmaattcchhttiimmee option for more information. - showmode [off] - VVii only. This option causes vvii to display the strings ``Command'' - or ``Input'' on the colon command line, based on the current mode - of the editor. - sidescroll [16] - VVii only. Sets the number of columns that are shifted to the left - or right, when vvii is doing left-right scrolling and the left or - right margin is crossed. See the lleeffttrriigghhtt option for more infor- - mation. - slowopen, slow [off] - This option affects the display algorithm used by vvii, holding off - display updating during input of new text to improve throughput - when the terminal in use is slow and unintelligent. - _T_h_i_s _o_p_t_i_o_n _i_s _n_o_t _y_e_t _i_m_p_l_e_m_e_n_t_e_d_. - sourceany [off] - If this option is turned on, vvii historically read startup files - that were owned by someone other than the editor user. See the - STARTUP INFORMATION section for more information. This option is a - security problem of immense proportions, and should not be used un- - der any circumstances. - _T_h_i_s _o_p_t_i_o_n _w_i_l_l _n_e_v_e_r _b_e _i_m_p_l_e_m_e_n_t_e_d_. - tabstop, ts [8] - This option sets tab widths for the editor display. - taglength, tl [0] - This option sets the maximum number of characters that are consid- - ered significant in a tag name. Setting the value to 0 makes all - of the characters in the tag name significant. - tags, tag [tags /var/db/libc.tags /sys/kern/tags] - Sets the list of tags files, in search order, which are used when - the editor searches for a tag. - term, ttytype, tty [environment variable TERM] - Set the terminal type. Setting this option causes eexx//vvii to set (or - reset) the environmental variable TERM. - terse [off] - This option has historically made editor messages less verbose. It - has no effect in this implementation. See the vveerrbboossee option for - more information. - timeout, to [on] - If this option is set, eexx//vvii waits for a specific period for a sub- - sequent key to complete a key mapping (see the kkeeyyttiimmee option). If - the option is not set, the editor waits until enough keys are en- - tered to resolve the ambiguity, regardless of how long it takes. - ttywerase [off] - VVii only. This option changes how vvii does word erase during text - input. If this option is set, text is broken up into two classes, - blank characters and non-blank characters. Changing from one class - to another marks the end of a word. - verbose [off] - only. VVii historically bells the terminal for many obvious mis- - takes, e.g. trying to move past the left-hand margin, or past the - end of the file. If this option is set, an error message is dis- - played for all errors. - w300 [no default] - VVii only. Set the window size if the baud rate is less than 1200 - baud. See the wwiinnddooww option for more information. - w1200 [no default] - VVii only. Set the window size if the baud rate is equal to 1200 - - baud. See the wwiinnddooww option for more information. - w9600 [no default] - VVii only. Set the window size if the baud rate is greater than 1200 - baud. See the wwiinnddooww option for more information. - warn [on] - EExx only. This option causes a warning message to the terminal if - the file has been modified, since it was last written, before a !! - command. - window, w, wi [environment variable LINES] - This option determines the default number of lines in a screenful, - as written by the zz command. It also determines the number of - lines scrolled by the vvii commands ^^FF and ^^BB. The value of window - can be unrelated to the real screen size, although it starts out as - the number of lines on the screen (see the SCREEN SIZING section). - Setting the value of the wwiinnddooww option is the same as using the --ww - command line option. - - If the value of wwiinnddooww (as set by the wwiinnddooww, ww330000, ww11220000 or ww99660000 - options) is smaller than the actual size of the screen, large - screen movements will result in displaying only that smaller number - of lines on the screen. (Further movements in that same area will - result in the screen being filled.) This can provide a performance - improvement when viewing different places in one or more files over - a slow link. - wrapmargin, wm [0] - VVii only. If the value of wrapmargin is non-zero, vvii will break - lines, that are more than that number of characters long, into two - lines at the blank character closest to the value. If wrapmargin - is 0, or if there is no blank character upon which to break the - line, the line will not be broken. - wrapscan, ws [on] - This option causes searches to wrap around the end or the beginning - of the file, and back to the starting point. Otherwise, the end or - beginning of the file terminates the search. - writeany, wa [off] - If this option is set, file-overwriting checks that would usually - be made before the wwrriittee and xxiitt commands, or before an automatic - write (see the aauuttoowwrriittee option), are not made. This allows a - write to any file, provided the file permissions allow it. - -4.4BSD March 18, 1994 10 diff --git a/usr.bin/vi/line.c b/usr.bin/vi/line.c deleted file mode 100644 index 90b626b9d5a1..000000000000 --- a/usr.bin/vi/line.c +++ /dev/null @@ -1,476 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)line.c 8.23 (Berkeley) 3/15/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <errno.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <string.h> -#include <termios.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" -#include "excmd.h" - -static inline int scr_update __P((SCR *, EXF *, recno_t, enum operation, int)); - -/* - * file_gline -- - * Look in the text buffers for a line; if it's not there - * call file_rline to retrieve it from the database. - */ -char * -file_gline(sp, ep, lno, lenp) - SCR *sp; - EXF *ep; - recno_t lno; /* Line number. */ - size_t *lenp; /* Length store. */ -{ - TEXT *tp; - recno_t l1, l2; - - /* - * The underlying recno stuff handles zero by returning NULL, but - * have to have an oob condition for the look-aside into the input - * buffer anyway. - */ - if (lno == 0) - return (NULL); - - /* - * Look-aside into the TEXT buffers and see if the line we want - * is there. - */ - if (F_ISSET(sp, S_INPUT)) { - l1 = ((TEXT *)sp->tiq.cqh_first)->lno; - l2 = ((TEXT *)sp->tiq.cqh_last)->lno; - if (l1 <= lno && l2 >= lno) { - for (tp = sp->tiq.cqh_first; - tp->lno != lno; tp = tp->q.cqe_next); - if (lenp) - *lenp = tp->len; - return (tp->lb); - } - /* - * Adjust the line number for the number of lines used - * by the text input buffers. - */ - if (lno > l2) - lno -= l2 - l1; - } - return (file_rline(sp, ep, lno, lenp)); -} - -/* - * file_rline -- - * Look in the cache for a line; if it's not there retrieve - * it from the file. - */ -char * -file_rline(sp, ep, lno, lenp) - SCR *sp; - EXF *ep; - recno_t lno; /* Line number. */ - size_t *lenp; /* Length store. */ -{ - DBT data, key; - - /* Check the cache. */ - if (lno == ep->c_lno) { - if (lenp) - *lenp = ep->c_len; - return (ep->c_lp); - } - ep->c_lno = OOBLNO; - - /* Get the line from the underlying database. */ - key.data = &lno; - key.size = sizeof(lno); - switch (ep->db->get(ep->db, &key, &data, 0)) { - case -1: - msgq(sp, M_ERR, - "Error: %s/%d: unable to get line %u: %s.", - tail(__FILE__), __LINE__, lno, strerror(errno)); - /* FALLTHROUGH */ - case 1: - return (NULL); - /* NOTREACHED */ - } - if (lenp) - *lenp = data.size; - - /* Fill the cache. */ - ep->c_lno = lno; - ep->c_len = data.size; - ep->c_lp = data.data; - - return (data.data); -} - -/* - * file_dline -- - * Delete a line from the file. - */ -int -file_dline(sp, ep, lno) - SCR *sp; - EXF *ep; - recno_t lno; -{ - DBT key; - -#if defined(DEBUG) && 0 - TRACE(sp, "delete line %lu\n", lno); -#endif - /* - * XXX - * - * Marks and global commands have to know when lines are - * inserted or deleted. - */ - mark_insdel(sp, ep, LINE_DELETE, lno); - global_insdel(sp, ep, LINE_DELETE, lno); - - /* Log change. */ - log_line(sp, ep, lno, LOG_LINE_DELETE); - - /* Update file. */ - key.data = &lno; - key.size = sizeof(lno); - if (ep->db->del(ep->db, &key, 0) == 1) { - msgq(sp, M_ERR, - "Error: %s/%d: unable to delete line %u: %s.", - tail(__FILE__), __LINE__, lno, strerror(errno)); - return (1); - } - - /* Flush the cache, update line count, before screen update. */ - if (lno <= ep->c_lno) - ep->c_lno = OOBLNO; - if (ep->c_nlines != OOBLNO) - --ep->c_nlines; - - /* File now dirty. */ - if (F_ISSET(ep, F_FIRSTMODIFY)) - (void)rcv_init(sp, ep); - F_SET(ep, F_MODIFIED); - - /* Update screen. */ - return (scr_update(sp, ep, lno, LINE_DELETE, 1)); -} - -/* - * file_aline -- - * Append a line into the file. - */ -int -file_aline(sp, ep, update, lno, p, len) - SCR *sp; - EXF *ep; - int update; - recno_t lno; - char *p; - size_t len; -{ - DBT data, key; - recno_t lline; - -#if defined(DEBUG) && 0 - TRACE(sp, "append to %lu: len %u {%.*s}\n", lno, len, MIN(len, 20), p); -#endif - /* - * Very nasty special case. The historic vi code displays a single - * space (or a '$' if the list option is set) for the first line in - * an "empty" file. If we "insert" a line, that line gets scrolled - * down, not repainted, so it's incorrect when we refresh the the - * screen. This is really hard to find and fix in the vi code -- the - * text input functions detect it explicitly and don't insert a new - * line. The hack here is to repaint the screen if we're appending - * to an empty file. - */ - if (lno == 0) { - if (file_lline(sp, ep, &lline)) - return (1); - if (lline == 0) - F_SET(sp, S_REDRAW); - } - - /* Update file. */ - key.data = &lno; - key.size = sizeof(lno); - data.data = p; - data.size = len; - if (ep->db->put(ep->db, &key, &data, R_IAFTER) == -1) { - msgq(sp, M_ERR, - "Error: %s/%d: unable to append to line %u: %s.", - tail(__FILE__), __LINE__, lno, strerror(errno)); - return (1); - } - - /* Flush the cache, update line count, before screen update. */ - if (lno < ep->c_lno) - ep->c_lno = OOBLNO; - if (ep->c_nlines != OOBLNO) - ++ep->c_nlines; - - /* File now dirty. */ - if (F_ISSET(ep, F_FIRSTMODIFY)) - (void)rcv_init(sp, ep); - F_SET(ep, F_MODIFIED); - - /* Log change. */ - log_line(sp, ep, lno + 1, LOG_LINE_APPEND); - - /* - * XXX - * - * Marks and global commands have to know when lines are - * inserted or deleted. - */ - mark_insdel(sp, ep, LINE_INSERT, lno + 1); - global_insdel(sp, ep, LINE_INSERT, lno + 1); - - /* - * Update screen. - * - * XXX - * Nasty hack. If multiple lines are input by the user, they aren't - * committed until an <ESC> is entered. The problem is the screen was - * updated/scrolled as each line was entered. So, when this routine - * is called to copy the new lines from the cut buffer into the file, - * it has to know not to update the screen again. - */ - return (scr_update(sp, ep, lno, LINE_APPEND, update)); -} - -/* - * file_iline -- - * Insert a line into the file. - */ -int -file_iline(sp, ep, lno, p, len) - SCR *sp; - EXF *ep; - recno_t lno; - char *p; - size_t len; -{ - DBT data, key; - recno_t lline; - -#if defined(DEBUG) && 0 - TRACE(sp, - "insert before %lu: len %u {%.*s}\n", lno, len, MIN(len, 20), p); -#endif - - /* Very nasty special case. See comment in file_aline(). */ - if (lno == 1) { - if (file_lline(sp, ep, &lline)) - return (1); - if (lline == 0) - F_SET(sp, S_REDRAW); - } - - /* Update file. */ - key.data = &lno; - key.size = sizeof(lno); - data.data = p; - data.size = len; - if (ep->db->put(ep->db, &key, &data, R_IBEFORE) == -1) { - msgq(sp, M_ERR, - "Error: %s/%d: unable to insert at line %u: %s.", - tail(__FILE__), __LINE__, lno, strerror(errno)); - return (1); - } - - /* Flush the cache, update line count, before screen update. */ - if (lno >= ep->c_lno) - ep->c_lno = OOBLNO; - if (ep->c_nlines != OOBLNO) - ++ep->c_nlines; - - /* File now dirty. */ - if (F_ISSET(ep, F_FIRSTMODIFY)) - (void)rcv_init(sp, ep); - F_SET(ep, F_MODIFIED); - - /* Log change. */ - log_line(sp, ep, lno, LOG_LINE_INSERT); - - /* - * XXX - * - * Marks and global commands have to know when lines are - * inserted or deleted. - */ - mark_insdel(sp, ep, LINE_INSERT, lno); - global_insdel(sp, ep, LINE_INSERT, lno); - - /* Update screen. */ - return (scr_update(sp, ep, lno, LINE_INSERT, 1)); -} - -/* - * file_sline -- - * Store a line in the file. - */ -int -file_sline(sp, ep, lno, p, len) - SCR *sp; - EXF *ep; - recno_t lno; - char *p; - size_t len; -{ - DBT data, key; - -#if defined(DEBUG) && 0 - TRACE(sp, - "replace line %lu: len %u {%.*s}\n", lno, len, MIN(len, 20), p); -#endif - /* Log before change. */ - log_line(sp, ep, lno, LOG_LINE_RESET_B); - - /* Update file. */ - key.data = &lno; - key.size = sizeof(lno); - data.data = p; - data.size = len; - if (ep->db->put(ep->db, &key, &data, 0) == -1) { - msgq(sp, M_ERR, - "Error: %s/%d: unable to store line %u: %s.", - tail(__FILE__), __LINE__, lno, strerror(errno)); - return (1); - } - - /* Flush the cache, before logging or screen update. */ - if (lno == ep->c_lno) - ep->c_lno = OOBLNO; - - /* File now dirty. */ - if (F_ISSET(ep, F_FIRSTMODIFY)) - (void)rcv_init(sp, ep); - F_SET(ep, F_MODIFIED); - - /* Log after change. */ - log_line(sp, ep, lno, LOG_LINE_RESET_F); - - /* Update screen. */ - return (scr_update(sp, ep, lno, LINE_RESET, 1)); -} - -/* - * file_lline -- - * Return the number of lines in the file. - */ -int -file_lline(sp, ep, lnop) - SCR *sp; - EXF *ep; - recno_t *lnop; -{ - DBT data, key; - recno_t lno; - - /* Check the cache. */ - if (ep->c_nlines != OOBLNO) { - *lnop = (F_ISSET(sp, S_INPUT) && - ((TEXT *)sp->tiq.cqh_last)->lno > ep->c_nlines ? - ((TEXT *)sp->tiq.cqh_last)->lno : ep->c_nlines); - return (0); - } - - key.data = &lno; - key.size = sizeof(lno); - - switch (ep->db->seq(ep->db, &key, &data, R_LAST)) { - case -1: - msgq(sp, M_ERR, - "Error: %s/%d: unable to get last line: %s.", - tail(__FILE__), __LINE__, strerror(errno)); - *lnop = 0; - return (1); - case 1: - *lnop = 0; - return (0); - default: - break; - } - - /* Fill the cache. */ - memmove(&lno, key.data, sizeof(lno)); - ep->c_nlines = ep->c_lno = lno; - ep->c_len = data.size; - ep->c_lp = data.data; - - /* Return the value. */ - *lnop = (F_ISSET(sp, S_INPUT) && - ((TEXT *)sp->tiq.cqh_last)->lno > lno ? - ((TEXT *)sp->tiq.cqh_last)->lno : lno); - return (0); -} - -/* - * scr_update -- - * Update all of the screens that are backed by the file that - * just changed. - */ -static inline int -scr_update(sp, ep, lno, op, current) - SCR *sp; - EXF *ep; - recno_t lno; - enum operation op; - int current; -{ - SCR *tsp; - - if (ep->refcnt != 1) - for (tsp = sp->gp->dq.cqh_first; - tsp != (void *)&sp->gp->dq; tsp = tsp->q.cqe_next) - if (sp != tsp && tsp->ep == ep) - (void)sp->s_change(tsp, ep, lno, op); - return (current && sp->s_change(sp, ep, lno, op)); -} diff --git a/usr.bin/vi/log.c b/usr.bin/vi/log.c deleted file mode 100644 index 492e5ab9537e..000000000000 --- a/usr.bin/vi/log.c +++ /dev/null @@ -1,689 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)log.c 8.14 (Berkeley) 3/14/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/stat.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <errno.h> -#include <fcntl.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" - -/* - * The log consists of records, each containing a type byte and a variable - * length byte string, as follows: - * - * LOG_CURSOR_INIT MARK - * LOG_CURSOR_END MARK - * LOG_LINE_APPEND recno_t char * - * LOG_LINE_DELETE recno_t char * - * LOG_LINE_INSERT recno_t char * - * LOG_LINE_RESET_F recno_t char * - * LOG_LINE_RESET_B recno_t char * - * LOG_MARK LMARK - * - * We do before image physical logging. This means that the editor layer - * MAY NOT modify records in place, even if simply deleting or overwriting - * characters. Since the smallest unit of logging is a line, we're using - * up lots of space. This may eventually have to be reduced, probably by - * doing logical logging, which is a much cooler database phrase. - * - * The implementation of the historic vi 'u' command, using roll-forward and - * roll-back, is simple. Each set of changes has a LOG_CURSOR_INIT record, - * followed by a number of other records, followed by a LOG_CURSOR_END record. - * LOG_LINE_RESET records come in pairs. The first is a LOG_LINE_RESET_B - * record, and is the line before the change. The second is LOG_LINE_RESET_F, - * and is the line after the change. Roll-back is done by backing up to the - * first LOG_CURSOR_INIT record before a change. Roll-forward is done in a - * similar fashion. - * - * The 'U' command is implemented by rolling backward to a LOG_CURSOR_END - * record for a line different from the current one. It should be noted that - * this means that a subsequent 'u' command will make a change based on the - * new position of the log's cursor. This is okay, and, in fact, historic vi - * behaved that way. - */ - -static int log_cursor1 __P((SCR *, EXF *, int)); -#if defined(DEBUG) && 0 -static void log_trace __P((SCR *, char *, recno_t, u_char *)); -#endif - -/* Try and restart the log on failure, i.e. if we run out of memory. */ -#define LOG_ERR { \ - msgq(sp, M_ERR, "Error: %s/%d: put log error: %s.", \ - tail(__FILE__), __LINE__, strerror(errno)); \ - (void)ep->log->close(ep->log); \ - if (!log_init(sp, ep)) \ - msgq(sp, M_ERR, "Log restarted."); \ - return (1); \ -} - -/* - * log_init -- - * Initialize the logging subsystem. - */ -int -log_init(sp, ep) - SCR *sp; - EXF *ep; -{ - /* - * Initialize the buffer. The logging subsystem has its own - * buffers because the global ones are almost by definition - * going to be in use when the log runs. - */ - ep->l_lp = NULL; - ep->l_len = 0; - ep->l_cursor.lno = 1; /* XXX Any valid recno. */ - ep->l_cursor.cno = 0; - ep->l_high = ep->l_cur = 1; - - ep->log = dbopen(NULL, O_CREAT | O_NONBLOCK | O_RDWR, - S_IRUSR | S_IWUSR, DB_RECNO, NULL); - if (ep->log == NULL) { - msgq(sp, M_ERR, "log db: %s", strerror(errno)); - F_SET(ep, F_NOLOG); - return (1); - } - - return (0); -} - -/* - * log_end -- - * Close the logging subsystem. - */ -int -log_end(sp, ep) - SCR *sp; - EXF *ep; -{ - if (ep->log != NULL) { - (void)(ep->log->close)(ep->log); - ep->log = NULL; - } - if (ep->l_lp != NULL) { - free(ep->l_lp); - ep->l_lp = NULL; - } - ep->l_len = 0; - ep->l_cursor.lno = 1; /* XXX Any valid recno. */ - ep->l_cursor.cno = 0; - ep->l_high = ep->l_cur = 1; - return (0); -} - -/* - * log_cursor -- - * Log the current cursor position, starting an event. - */ -int -log_cursor(sp, ep) - SCR *sp; - EXF *ep; -{ - /* - * If any changes were made since the last cursor init, - * put out the ending cursor record. - */ - if (ep->l_cursor.lno == OOBLNO) { - ep->l_cursor.lno = sp->lno; - ep->l_cursor.cno = sp->cno; - return (log_cursor1(sp, ep, LOG_CURSOR_END)); - } - ep->l_cursor.lno = sp->lno; - ep->l_cursor.cno = sp->cno; - return (0); -} - -/* - * log_cursor1 -- - * Actually push a cursor record out. - */ -static int -log_cursor1(sp, ep, type) - SCR *sp; - EXF *ep; - int type; -{ - DBT data, key; - - BINC_RET(sp, ep->l_lp, ep->l_len, sizeof(u_char) + sizeof(MARK)); - ep->l_lp[0] = type; - memmove(ep->l_lp + sizeof(u_char), &ep->l_cursor, sizeof(MARK)); - - key.data = &ep->l_cur; - key.size = sizeof(recno_t); - data.data = ep->l_lp; - data.size = sizeof(u_char) + sizeof(MARK); - if (ep->log->put(ep->log, &key, &data, 0) == -1) - LOG_ERR; - -#if defined(DEBUG) && 0 - TRACE(sp, "%lu: %s: %u/%u\n", ep->l_cur, - type == LOG_CURSOR_INIT ? "log_cursor_init" : "log_cursor_end", - sp->lno, sp->cno); -#endif - /* Reset high water mark. */ - ep->l_high = ++ep->l_cur; - - return (0); -} - -/* - * log_line -- - * Log a line change. - */ -int -log_line(sp, ep, lno, action) - SCR *sp; - EXF *ep; - recno_t lno; - u_int action; -{ - DBT data, key; - size_t len; - char *lp; - - if (F_ISSET(ep, F_NOLOG)) - return (0); - - /* - * XXX - * - * Kluge for vi. Clear the EXF undo flag so that the - * next 'u' command does a roll-back, regardless. - */ - F_CLR(ep, F_UNDO); - - /* Put out one initial cursor record per set of changes. */ - if (ep->l_cursor.lno != OOBLNO) { - if (log_cursor1(sp, ep, LOG_CURSOR_INIT)) - return (1); - ep->l_cursor.lno = OOBLNO; - } - - /* - * Put out the changes. If it's a LOG_LINE_RESET_B call, it's a - * special case, avoid the caches. Also, if it fails and it's - * line 1, it just means that the user started with an empty file, - * so fake an empty length line. - */ - if (action == LOG_LINE_RESET_B) { - if ((lp = file_rline(sp, ep, lno, &len)) == NULL) { - if (lno != 1) { - GETLINE_ERR(sp, lno); - return (1); - } - len = 0; - lp = ""; - } - } else - if ((lp = file_gline(sp, ep, lno, &len)) == NULL) { - GETLINE_ERR(sp, lno); - return (1); - } - BINC_RET(sp, - ep->l_lp, ep->l_len, len + sizeof(u_char) + sizeof(recno_t)); - ep->l_lp[0] = action; - memmove(ep->l_lp + sizeof(u_char), &lno, sizeof(recno_t)); - memmove(ep->l_lp + sizeof(u_char) + sizeof(recno_t), lp, len); - - key.data = &ep->l_cur; - key.size = sizeof(recno_t); - data.data = ep->l_lp; - data.size = len + sizeof(u_char) + sizeof(recno_t); - if (ep->log->put(ep->log, &key, &data, 0) == -1) - LOG_ERR; - -#if defined(DEBUG) && 0 - switch (action) { - case LOG_LINE_APPEND: - TRACE(sp, "%u: log_line: append: %lu {%u}\n", - ep->l_cur, lno, len); - break; - case LOG_LINE_DELETE: - TRACE(sp, "%lu: log_line: delete: %lu {%u}\n", - ep->l_cur, lno, len); - break; - case LOG_LINE_INSERT: - TRACE(sp, "%lu: log_line: insert: %lu {%u}\n", - ep->l_cur, lno, len); - break; - case LOG_LINE_RESET_F: - TRACE(sp, "%lu: log_line: reset_f: %lu {%u}\n", - ep->l_cur, lno, len); - break; - case LOG_LINE_RESET_B: - TRACE(sp, "%lu: log_line: reset_b: %lu {%u}\n", - ep->l_cur, lno, len); - break; - } -#endif - /* Reset high water mark. */ - ep->l_high = ++ep->l_cur; - - return (0); -} - -/* - * log_mark -- - * Log a mark position. For the log to work, we assume that there - * aren't any operations that just put out a log record -- this - * would mean that undo operations would only reset marks, and not - * cause any other change. - */ -int -log_mark(sp, ep, lmp) - SCR *sp; - EXF *ep; - LMARK *lmp; -{ - DBT data, key; - - if (F_ISSET(ep, F_NOLOG)) - return (0); - - /* Put out one initial cursor record per set of changes. */ - if (ep->l_cursor.lno != OOBLNO) { - if (log_cursor1(sp, ep, LOG_CURSOR_INIT)) - return (1); - ep->l_cursor.lno = OOBLNO; - } - - BINC_RET(sp, ep->l_lp, - ep->l_len, sizeof(u_char) + sizeof(LMARK)); - ep->l_lp[0] = LOG_MARK; - memmove(ep->l_lp + sizeof(u_char), lmp, sizeof(LMARK)); - - key.data = &ep->l_cur; - key.size = sizeof(recno_t); - data.data = ep->l_lp; - data.size = sizeof(u_char) + sizeof(LMARK); - if (ep->log->put(ep->log, &key, &data, 0) == -1) - LOG_ERR; - -#if defined(DEBUG) && 0 - TRACE(sp, "%lu: mark %c: %lu/%u\n", - ep->l_cur, lmp->name, lmp->lno, lmp->cno); -#endif - /* Reset high water mark. */ - ep->l_high = ++ep->l_cur; - return (0); -} - -/* - * Log_backward -- - * Roll the log backward one operation. - */ -int -log_backward(sp, ep, rp) - SCR *sp; - EXF *ep; - MARK *rp; -{ - DBT key, data; - LMARK lm; - MARK m; - recno_t lno; - int didop; - u_char *p; - - if (F_ISSET(ep, F_NOLOG)) { - msgq(sp, M_ERR, - "Logging not being performed, undo not possible."); - return (1); - } - - if (ep->l_cur == 1) { - msgq(sp, M_BERR, "No changes to undo."); - return (1); - } - - F_SET(ep, F_NOLOG); /* Turn off logging. */ - - key.data = &ep->l_cur; /* Initialize db request. */ - key.size = sizeof(recno_t); - for (didop = 0;;) { - --ep->l_cur; - if (ep->log->get(ep->log, &key, &data, 0)) - LOG_ERR; -#if defined(DEBUG) && 0 - log_trace(sp, "log_backward", ep->l_cur, data.data); -#endif - switch (*(p = (u_char *)data.data)) { - case LOG_CURSOR_INIT: - if (didop) { - memmove(rp, p + sizeof(u_char), sizeof(MARK)); - F_CLR(ep, F_NOLOG); - return (0); - } - break; - case LOG_CURSOR_END: - break; - case LOG_LINE_APPEND: - case LOG_LINE_INSERT: - didop = 1; - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - if (file_dline(sp, ep, lno)) - goto err; - ++sp->rptlines[L_DELETED]; - break; - case LOG_LINE_DELETE: - didop = 1; - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - if (file_iline(sp, ep, lno, p + sizeof(u_char) + - sizeof(recno_t), data.size - sizeof(u_char) - - sizeof(recno_t))) - goto err; - ++sp->rptlines[L_ADDED]; - break; - case LOG_LINE_RESET_F: - break; - case LOG_LINE_RESET_B: - didop = 1; - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - if (file_sline(sp, ep, lno, p + sizeof(u_char) + - sizeof(recno_t), data.size - sizeof(u_char) - - sizeof(recno_t))) - goto err; - ++sp->rptlines[L_CHANGED]; - break; - case LOG_MARK: - didop = 1; - memmove(&lm, p + sizeof(u_char), sizeof(LMARK)); - m.lno = lm.lno; - m.cno = lm.cno; - if (mark_set(sp, ep, lm.name, &m, 0)) - goto err; - break; - default: - abort(); - } - } - -err: F_CLR(ep, F_NOLOG); - return (1); -} - -/* - * Log_setline -- - * Reset the line to its original appearance. - * - * XXX - * There's a bug in this code due to our not logging cursor movements - * unless a change was made. If you do a change, move off the line, - * then move back on and do a 'U', the line will be restored to the way - * it was before the original change. - */ -int -log_setline(sp, ep) - SCR *sp; - EXF *ep; -{ - DBT key, data; - LMARK lm; - MARK m; - recno_t lno; - u_char *p; - - if (F_ISSET(ep, F_NOLOG)) { - msgq(sp, M_ERR, - "Logging not being performed, undo not possible."); - return (1); - } - - if (ep->l_cur == 1) - return (1); - - F_SET(ep, F_NOLOG); /* Turn off logging. */ - - key.data = &ep->l_cur; /* Initialize db request. */ - key.size = sizeof(recno_t); - - for (;;) { - --ep->l_cur; - if (ep->log->get(ep->log, &key, &data, 0)) - LOG_ERR; -#if defined(DEBUG) && 0 - log_trace(sp, "log_setline", ep->l_cur, data.data); -#endif - switch (*(p = (u_char *)data.data)) { - case LOG_CURSOR_INIT: - memmove(&m, p + sizeof(u_char), sizeof(MARK)); - if (m.lno != sp->lno || ep->l_cur == 1) { - F_CLR(ep, F_NOLOG); - return (0); - } - break; - case LOG_CURSOR_END: - memmove(&m, p + sizeof(u_char), sizeof(MARK)); - if (m.lno != sp->lno) { - ++ep->l_cur; - F_CLR(ep, F_NOLOG); - return (0); - } - break; - case LOG_LINE_APPEND: - case LOG_LINE_INSERT: - case LOG_LINE_DELETE: - case LOG_LINE_RESET_F: - break; - case LOG_LINE_RESET_B: - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - if (lno == sp->lno && - file_sline(sp, ep, lno, p + sizeof(u_char) + - sizeof(recno_t), data.size - sizeof(u_char) - - sizeof(recno_t))) - goto err; - ++sp->rptlines[L_CHANGED]; - case LOG_MARK: - memmove(&lm, p + sizeof(u_char), sizeof(LMARK)); - m.lno = lm.lno; - m.cno = lm.cno; - if (mark_set(sp, ep, lm.name, &m, 0)) - goto err; - break; - default: - abort(); - } - } - -err: F_CLR(ep, F_NOLOG); - return (1); -} - -/* - * Log_forward -- - * Roll the log forward one operation. - */ -int -log_forward(sp, ep, rp) - SCR *sp; - EXF *ep; - MARK *rp; -{ - DBT key, data; - LMARK lm; - MARK m; - recno_t lno; - int didop; - u_char *p; - - if (F_ISSET(ep, F_NOLOG)) { - msgq(sp, M_ERR, - "Logging not being performed, roll-forward not possible."); - return (1); - } - - if (ep->l_cur == ep->l_high) { - msgq(sp, M_BERR, "No changes to re-do."); - return (1); - } - - F_SET(ep, F_NOLOG); /* Turn off logging. */ - - key.data = &ep->l_cur; /* Initialize db request. */ - key.size = sizeof(recno_t); - for (didop = 0;;) { - ++ep->l_cur; - if (ep->log->get(ep->log, &key, &data, 0)) - LOG_ERR; -#if defined(DEBUG) && 0 - log_trace(sp, "log_forward", ep->l_cur, data.data); -#endif - switch (*(p = (u_char *)data.data)) { - case LOG_CURSOR_END: - if (didop) { - ++ep->l_cur; - memmove(rp, p + sizeof(u_char), sizeof(MARK)); - F_CLR(ep, F_NOLOG); - return (0); - } - break; - case LOG_CURSOR_INIT: - break; - case LOG_LINE_APPEND: - case LOG_LINE_INSERT: - didop = 1; - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - if (file_iline(sp, ep, lno, p + sizeof(u_char) + - sizeof(recno_t), data.size - sizeof(u_char) - - sizeof(recno_t))) - goto err; - ++sp->rptlines[L_ADDED]; - break; - case LOG_LINE_DELETE: - didop = 1; - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - if (file_dline(sp, ep, lno)) - goto err; - ++sp->rptlines[L_DELETED]; - break; - case LOG_LINE_RESET_B: - break; - case LOG_LINE_RESET_F: - didop = 1; - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - if (file_sline(sp, ep, lno, p + sizeof(u_char) + - sizeof(recno_t), data.size - sizeof(u_char) - - sizeof(recno_t))) - goto err; - ++sp->rptlines[L_CHANGED]; - break; - case LOG_MARK: - didop = 1; - memmove(&lm, p + sizeof(u_char), sizeof(LMARK)); - m.lno = lm.lno; - m.cno = lm.cno; - if (mark_set(sp, ep, lm.name, &m, 0)) - goto err; - break; - default: - abort(); - } - } - -err: F_CLR(ep, F_NOLOG); - return (1); -} - -#if defined(DEBUG) && 0 -static void -log_trace(sp, msg, rno, p) - SCR *sp; - char *msg; - recno_t rno; - u_char *p; -{ - LMARK lm; - MARK m; - recno_t lno; - - switch (*p) { - case LOG_CURSOR_INIT: - memmove(&m, p + sizeof(u_char), sizeof(MARK)); - TRACE(sp, "%lu: %s: C_INIT: %u/%u\n", rno, msg, m.lno, m.cno); - break; - case LOG_CURSOR_END: - memmove(&m, p + sizeof(u_char), sizeof(MARK)); - TRACE(sp, "%lu: %s: C_END: %u/%u\n", rno, msg, m.lno, m.cno); - break; - case LOG_LINE_APPEND: - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - TRACE(sp, "%lu: %s: APPEND: %lu\n", rno, msg, lno); - break; - case LOG_LINE_INSERT: - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - TRACE(sp, "%lu: %s: INSERT: %lu\n", rno, msg, lno); - break; - case LOG_LINE_DELETE: - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - TRACE(sp, "%lu: %s: DELETE: %lu\n", rno, msg, lno); - break; - case LOG_LINE_RESET_F: - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - TRACE(sp, "%lu: %s: RESET_F: %lu\n", rno, msg, lno); - break; - case LOG_LINE_RESET_B: - memmove(&lno, p + sizeof(u_char), sizeof(recno_t)); - TRACE(sp, "%lu: %s: RESET_B: %lu\n", rno, msg, lno); - break; - case LOG_MARK: - memmove(&lm, p + sizeof(u_char), sizeof(LMARK)); - TRACE(sp, - "%lu: %s: MARK: %u/%u\n", rno, msg, lm.lno, lm.cno); - break; - default: - abort(); - } -} -#endif diff --git a/usr.bin/vi/log.h b/usr.bin/vi/log.h deleted file mode 100644 index 2974df4d14b6..000000000000 --- a/usr.bin/vi/log.h +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)log.h 8.5 (Berkeley) 3/16/94 - */ - -#define LOG_NOTYPE 0 -#define LOG_CURSOR_INIT 1 -#define LOG_CURSOR_END 2 -#define LOG_LINE_APPEND 3 -#define LOG_LINE_DELETE 4 -#define LOG_LINE_INSERT 5 -#define LOG_LINE_RESET_F 6 -#define LOG_LINE_RESET_B 7 -#define LOG_MARK 8 - -int log_backward __P((SCR *, EXF *, MARK *)); -int log_cursor __P((SCR *, EXF *)); -int log_end __P((SCR *, EXF *)); -int log_forward __P((SCR *, EXF *, MARK *)); -int log_init __P((SCR *, EXF *)); -int log_line __P((SCR *, EXF *, recno_t, u_int)); -int log_mark __P((SCR *, EXF *, LMARK *)); -int log_setline __P((SCR *, EXF *)); diff --git a/usr.bin/vi/main.c b/usr.bin/vi/main.c deleted file mode 100644 index 10b22356e9c9..000000000000 --- a/usr.bin/vi/main.c +++ /dev/null @@ -1,795 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)main.c 8.76 (Berkeley) 3/23/94"; -#endif /* not lint */ - -#include <sys/param.h> -#include <sys/queue.h> -#include <sys/stat.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <ctype.h> -#include <err.h> -#include <errno.h> -#include <fcntl.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> - -#ifdef __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -#include "compat.h" -#include <db.h> -#include <regex.h> -#include <pathnames.h> - -#include "vi.h" -#include "excmd.h" -#include "tag.h" - -enum rc { NOEXIST, NOPERM, OK }; - -static enum rc exrc_isok __P((SCR *, struct stat *, char *, int)); -static void gs_end __P((GS *)); -static GS *gs_init __P((void)); -static void h_hup __P((int)); -static void h_term __P((int)); -static void h_winch __P((int)); -static void obsolete __P((char *[])); -static void usage __P((int)); - -GS *__global_list; /* GLOBAL: List of screens. */ - -int -main(argc, argv) - int argc; - char *argv[]; -{ - extern int optind; - extern char *optarg; - static int reenter; /* STATIC: Re-entrancy check. */ - struct sigaction act; - struct stat hsb, lsb; - GS *gp; - FREF *frp; - SCR *sp; - u_int flags, saved_vi_mode; - int ch, eval, flagchk, readonly, silent, snapshot; - char *excmdarg, *myname, *p, *rec_f, *tag_f, *trace_f, *wsizearg; - char path[MAXPATHLEN]; - - /* Stop if indirecting through a NULL pointer. */ - if (reenter++) - abort(); - - /* Set screen type and mode based on the program name. */ - readonly = 0; - if ((myname = strrchr(*argv, '/')) == NULL) - myname = *argv; - else - ++myname; - if (!strcmp(myname, "ex") || !strcmp(myname, "nex")) - LF_INIT(S_EX); - else { - /* View is readonly. */ - if (!strcmp(myname, "view")) - readonly = 1; - LF_INIT(S_VI_CURSES); - } - saved_vi_mode = S_VI_CURSES; - - /* Convert old-style arguments into new-style ones. */ - obsolete(argv); - - /* Parse the arguments. */ - flagchk = '\0'; - excmdarg = rec_f = tag_f = trace_f = wsizearg = NULL; - silent = 0; - snapshot = 1; - while ((ch = getopt(argc, argv, "c:eFlRr:sT:t:vw:x:")) != EOF) - switch (ch) { - case 'c': /* Run the command. */ - excmdarg = optarg; - break; - case 'e': /* Ex mode. */ - LF_CLR(S_SCREENS); - LF_SET(S_EX); - break; - case 'F': /* No snapshot. */ - snapshot = 0; - break; - case 'l': - if (flagchk != '\0' && flagchk != 'l') - errx(1, - "only one of -%c and -l may be specified.", - flagchk); - flagchk = 'l'; - break; - case 'R': /* Readonly. */ - readonly = 1; - break; - case 'r': /* Recover. */ - if (flagchk == 'r') - errx(1, - "only one recovery file may be specified."); - if (flagchk != '\0') - errx(1, - "only one of -%c and -r may be specified.", - flagchk); - flagchk = 'r'; - rec_f = optarg; - break; - case 's': - if (!LF_ISSET(S_EX)) - errx(1, "-s only applicable to ex."); - silent = 1; - break; - case 'T': /* Trace. */ - trace_f = optarg; - break; - case 't': /* Tag. */ - if (flagchk == 't') - errx(1, - "only one tag file may be specified."); - if (flagchk != '\0') - errx(1, - "only one of -%c and -t may be specified.", - flagchk); - flagchk = 't'; - tag_f = optarg; - break; - case 'v': /* Vi mode. */ - LF_CLR(S_SCREENS); - LF_SET(S_VI_CURSES); - break; - case 'w': - wsizearg = optarg; - break; - case 'x': - if (!strcmp(optarg, "aw")) { - LF_CLR(S_SCREENS); - LF_SET(S_VI_XAW); - saved_vi_mode = S_VI_XAW; - break; - } - /* FALLTHROUGH */ - case '?': - default: - usage(LF_ISSET(S_EX)); - } - argc -= optind; - argv += optind; - - /* Build and initialize the GS structure. */ - __global_list = gp = gs_init(); - - if (snapshot) - F_SET(gp, G_SNAPSHOT); - - /* - * Build and initialize the first/current screen. This is a bit - * tricky. If an error is returned, we may or may not have a - * screen structure. If we have a screen structure, put it on a - * display queue so that the error messages get displayed. - */ - if (screen_init(NULL, &sp, flags)) { - if (sp != NULL) - CIRCLEQ_INSERT_HEAD(&__global_list->dq, sp, q); - goto err; - } - sp->saved_vi_mode = saved_vi_mode; - CIRCLEQ_INSERT_HEAD(&__global_list->dq, sp, q); - - if (trace_f != NULL) { -#ifdef DEBUG - if ((gp->tracefp = fopen(optarg, "w")) == NULL) - err(1, "%s", optarg); - (void)fprintf(gp->tracefp, "\n===\ntrace: open %s\n", optarg); -#else - msgq(sp, M_ERR, "-T support not compiled into this version."); -#endif - } - - if (set_window_size(sp, 0, 0)) /* Set the window size. */ - goto err; - if (opts_init(sp)) /* Options initialization. */ - goto err; - if (readonly) /* Global read-only bit. */ - O_SET(sp, O_READONLY); - if (silent) { /* Ex batch mode. */ - O_CLR(sp, O_AUTOPRINT); - O_CLR(sp, O_PROMPT); - O_CLR(sp, O_VERBOSE); - O_CLR(sp, O_WARN); - F_SET(sp, S_EXSILENT); - } - if (wsizearg != NULL) { - ARGS *av[2], a, b; - if (strtol(optarg, &p, 10) < 0 || *p) - errx(1, "illegal window size -- %s", optarg); - (void)snprintf(path, sizeof(path), "window=%s", optarg); - a.bp = (CHAR_T *)path; - a.len = strlen(path); - b.bp = NULL; - b.len = 0; - av[0] = &a; - av[1] = &b; - if (opts_set(sp, av)) - msgq(sp, M_ERR, - "Unable to set command line window option"); - } - - /* Keymaps, special keys, must follow option initializations. */ - if (term_init(sp)) - goto err; - -#ifdef DIGRAPHS - if (digraph_init(sp)) /* Digraph initialization. */ - goto err; -#endif - - /* - * Source the system, environment, $HOME and local .exrc values. - * Vi historically didn't check $HOME/.exrc if the environment - * variable EXINIT was set. This is all done before the file is - * read in because things in the .exrc information can set, for - * example, the recovery directory. - * - * !!! - * While nvi can handle any of the options settings of historic vi, - * the converse is not true. Since users are going to have to have - * files and environmental variables that work with both, we use nvi - * versions of both the $HOME and local startup files if they exist, - * otherwise the historic ones. - * - * !!! - * According to O'Reilly ("Learning the VI Editor", Fifth Ed., May - * 1992, page 106), System V release 3.2 and later, has an option - * "[no]exrc", causing vi to not "read .exrc files in the current - * directory unless the exrc option in the home directory's .exrc - * file" was set. The problem that this (hopefully) solves is that - * on System V you can give away files, so there's no possible test - * we can make to determine that the file is safe. - * - * We initialize the exrc variable to off. If it's explicitly turned - * off by the user, then we never read the local .exrc file. If the - * user didn't initialize it or initialized it to on, we make all of - * the standard checks of the file before reading it. - * - * !!! - * If the user started the historic of vi in $HOME, vi read the user's - * .exrc file twice, as $HOME/.exrc and as ./.exrc. We don't since - * it's going to make some commands behave oddly, and I can't imagine - * anyone depending on it. - */ - if (!silent) { - switch (exrc_isok(sp, &hsb, _PATH_SYSEXRC, 1)) { - case NOEXIST: - case NOPERM: - break; - case OK: - (void)ex_cfile(sp, NULL, _PATH_SYSEXRC); - break; - } - - if ((p = getenv("NEXINIT")) != NULL || - (p = getenv("EXINIT")) != NULL) - if ((p = strdup(p)) == NULL) { - msgq(sp, M_SYSERR, NULL); - goto err; - } else { - F_SET(sp, S_VLITONLY); - (void)ex_icmd(sp, NULL, p, strlen(p)); - F_CLR(sp, S_VLITONLY); - free(p); - } - else if ((p = getenv("HOME")) != NULL && *p) { - (void)snprintf(path, - sizeof(path), "%s/%s", p, _PATH_NEXRC); - switch (exrc_isok(sp, &hsb, path, 0)) { - case NOEXIST: - (void)snprintf(path, - sizeof(path), "%s/%s", p, _PATH_EXRC); - if (exrc_isok(sp, &hsb, path, 0) == OK) - (void)ex_cfile(sp, NULL, path); - break; - case NOPERM: - break; - case OK: - (void)ex_cfile(sp, NULL, path); - break; - } - } - - if (!F_ISSET(&sp->opts[O_EXRC], OPT_SET) || O_ISSET(sp, O_EXRC)) - switch (exrc_isok(sp, &lsb, _PATH_NEXRC, 0)) { - case NOEXIST: - if (exrc_isok(sp, &lsb, _PATH_EXRC, 0) == OK && - (lsb.st_dev != hsb.st_dev || - lsb.st_ino != hsb.st_ino)) - (void)ex_cfile(sp, NULL, _PATH_EXRC); - break; - case NOPERM: - break; - case OK: - if (lsb.st_dev != hsb.st_dev || - lsb.st_ino != hsb.st_ino) - (void)ex_cfile(sp, NULL, _PATH_NEXRC); - break; - } - } - - /* List recovery files if -l specified. */ - if (flagchk == 'l') - exit(rcv_list(sp)); - - /* Use a tag file or recovery file if specified. */ - if (tag_f != NULL && ex_tagfirst(sp, tag_f)) - goto err; - else if (rec_f != NULL && rcv_read(sp, rec_f)) - goto err; - - /* Append any remaining arguments as file names. */ - if (*argv != NULL) - for (; *argv != NULL; ++argv) - if (file_add(sp, NULL, *argv, 0) == NULL) - goto err; - - /* - * If no recovery or tag file, get an EXF structure. - * If no argv file, use a temporary file. - */ - if (tag_f == NULL && rec_f == NULL) { - if ((frp = file_first(sp)) == NULL && - (frp = file_add(sp, NULL, NULL, 1)) == NULL) - goto err; - if (file_init(sp, frp, NULL, 0)) - goto err; - } - - /* Set up the argument pointer. */ - sp->a_frp = sp->frp; - - /* - * Initialize the signals. Use sigaction(2), not signal(3), because - * we don't want to always restart system calls on 4BSD systems. It - * would be nice in some cases to restart system calls, but SA_RESTART - * is a 4BSD extension so we can't use it. - * - * SIGALRM: - * Walk structures and call handling routines. - * SIGHUP, SIGTERM, SIGWINCH: - * Catch and set a global bit. - * SIGQUIT: - * Always ignore. - */ - act.sa_handler = h_alrm; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if (sigaction(SIGALRM, &act, NULL)) { - msgq(sp, M_SYSERR, "timer: sigaction"); - goto err; - } - act.sa_handler = h_hup; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - (void)sigaction(SIGHUP, &act, NULL); - act.sa_handler = h_term; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - (void)sigaction(SIGTERM, &act, NULL); - act.sa_handler = h_winch; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - (void)sigaction(SIGWINCH, &act, NULL); - act.sa_handler = SIG_IGN; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - (void)sigaction(SIGQUIT, &act, NULL); - - /* - * If there's an initial command, push it on the command stack. - * Historically, it was always an ex command, not vi in vi mode - * or ex in ex mode. So, make it look like an ex command to vi. - */ - if (excmdarg != NULL) - if (IN_EX_MODE(sp)) { - if (term_push(sp, excmdarg, strlen(excmdarg), 0, 0)) - goto err; - } else if (IN_VI_MODE(sp)) { - if (term_push(sp, "\n", 1, 0, 0)) - goto err; - if (term_push(sp, excmdarg, strlen(excmdarg), 0, 0)) - goto err; - if (term_push(sp, ":", 1, 0, 0)) - goto err; - } - - /* Vi reads from the terminal. */ - if (!F_ISSET(gp, G_STDIN_TTY) && !F_ISSET(sp, S_EX)) { - msgq(sp, M_ERR, "Vi's standard input must be a terminal."); - goto err; - } - - for (;;) { - if (sp->s_edit(sp, sp->ep)) - goto err; - - /* - * Edit the next screen on the display queue, or, move - * a screen from the hidden queue to the display queue. - */ - if ((sp = __global_list->dq.cqh_first) == - (void *)&__global_list->dq) - if ((sp = __global_list->hq.cqh_first) != - (void *)&__global_list->hq) { - CIRCLEQ_REMOVE(&sp->gp->hq, sp, q); - CIRCLEQ_INSERT_TAIL(&sp->gp->dq, sp, q); - } else - break; - - /* - * The screen type may have changed -- reinitialize the - * functions in case it has. - */ - switch (F_ISSET(sp, S_SCREENS)) { - case S_EX: - if (sex_screen_init(sp)) - goto err; - break; - case S_VI_CURSES: - if (svi_screen_init(sp)) - goto err; - break; - case S_VI_XAW: - if (xaw_screen_init(sp)) - goto err; - break; - default: - abort(); - } - } - - eval = 0; - if (0) -err: eval = 1; - - /* - * NOTE: sp may be GONE when the screen returns, so only - * the gp can be trusted. - */ - gs_end(gp); - - /* - * XXX - * Make absolutely sure that the modes are restored correctly. - * - * This should no longer be needed, and it's here to handle what I - * believe are SunOS/Solaris curses problems. The problem is that - * for some unknown reason, when endwin() is called in the svi - * routines, it isn't resetting the terminal correctly. I have not - * been able to figure it out, so this resets the terminal to the - * right modes regardless. The problem is that, in most tty driver - * implementations, you can only reset the terminal modes once - * (changing from !ICANON to ICANON) without losing the re-parsing - * effect on the pending input. This means that this "fix" will make - * other systems mess up characters typed after the quit command to - * vi but before vi actually exits. - */ - if (F_ISSET(gp, G_TERMIOS_SET)) - (void)tcsetattr(STDIN_FILENO, TCSADRAIN, &gp->original_termios); - exit(eval); -} - -/* - * gs_init -- - * Build and initialize the GS structure. - */ -static GS * -gs_init() -{ - GS *gp; - int fd; - - CALLOC_NOMSG(NULL, gp, GS *, 1, sizeof(GS)); - if (gp == NULL) - err(1, NULL); - - CIRCLEQ_INIT(&gp->dq); - CIRCLEQ_INIT(&gp->hq); - LIST_INIT(&gp->msgq); - - /* Structures shared by screens so stored in the GS structure. */ - CALLOC_NOMSG(NULL, gp->tty, IBUF *, 1, sizeof(IBUF)); - if (gp->tty == NULL) - err(1, NULL); - - LIST_INIT(&gp->cutq); - LIST_INIT(&gp->seqq); - - /* Set a flag if we're reading from the tty. */ - if (isatty(STDIN_FILENO)) - F_SET(gp, G_STDIN_TTY); - - /* - * Set the G_STDIN_TTY flag. It's purpose is to avoid setting and - * resetting the tty if the input isn't from there. - * - * Set the G_TERMIOS_SET flag. It's purpose is to avoid using the - * original_termios information (mostly special character values) - * if it's not valid. We expect that if we've lost our controlling - * terminal that the open() (but not the tcgetattr()) will fail. - */ - if (F_ISSET(gp, G_STDIN_TTY)) { - if (tcgetattr(STDIN_FILENO, &gp->original_termios) == -1) - err(1, "tcgetattr"); - F_SET(gp, G_TERMIOS_SET); - } else if ((fd = open(_PATH_TTY, O_RDONLY, 0)) != -1) { - if (tcgetattr(fd, &gp->original_termios) == -1) - err(1, "tcgetattr"); - F_SET(gp, G_TERMIOS_SET); - (void)close(fd); - } - return (gp); -} - - -/* - * gs_end -- - * End the GS structure. - */ -static void -gs_end(gp) - GS *gp; -{ - MSG *mp; - SCR *sp; - char *tty; - - /* Reset anything that needs resetting. */ - if (gp->flags & G_SETMODE) /* O_MESG */ - if ((tty = ttyname(STDERR_FILENO)) == NULL) - warn("ttyname"); - else if (chmod(tty, gp->origmode) < 0) - warn("%s", tty); - - /* Ring the bell if scheduled. */ - if (F_ISSET(gp, G_BELLSCHED)) - (void)fprintf(stderr, "\07"); /* \a */ - - /* If there are any remaining screens, flush their messages. */ - for (sp = __global_list->dq.cqh_first; - sp != (void *)&__global_list->dq; sp = sp->q.cqe_next) - for (mp = sp->msgq.lh_first; - mp != NULL && !(F_ISSET(mp, M_EMPTY)); mp = mp->q.le_next) - (void)fprintf(stderr, "%.*s\n", (int)mp->len, mp->mbuf); - for (sp = __global_list->hq.cqh_first; - sp != (void *)&__global_list->hq; sp = sp->q.cqe_next) - for (mp = sp->msgq.lh_first; - mp != NULL && !(F_ISSET(mp, M_EMPTY)); mp = mp->q.le_next) - (void)fprintf(stderr, "%.*s\n", (int)mp->len, mp->mbuf); - /* Flush messages on the global queue. */ - for (mp = gp->msgq.lh_first; - mp != NULL && !(F_ISSET(mp, M_EMPTY)); mp = mp->q.le_next) - (void)fprintf(stderr, "%.*s\n", (int)mp->len, mp->mbuf); - - if (gp->special_key != NULL) - FREE(gp->special_key, MAX_FAST_KEY); - - /* - * DON'T FREE THE GLOBAL STRUCTURE -- WE DIDN'T TURN - * OFF SIGNALS/TIMERS, SO IT MAY STILL BE REFERENCED. - */ -} - -/* - * h_hup -- - * Handle SIGHUP. - */ -static void -h_hup(signo) - int signo; -{ - F_SET(__global_list, G_SIGHUP); - - /* - * If we're asleep, just die. - * - * XXX - * This isn't right if the windows are independent. - */ - if (F_ISSET(__global_list, G_SLEEPING)) - rcv_hup(); -} - -/* - * h_term -- - * Handle SIGTERM. - */ -static void -h_term(signo) - int signo; -{ - F_SET(__global_list, G_SIGTERM); - - /* - * If we're asleep, just die. - * - * XXX - * This isn't right if the windows are independent. - */ - if (F_ISSET(__global_list, G_SLEEPING)) - rcv_term(); -} - -/* - * h_winch -- - * Handle SIGWINCH. - */ -static void -h_winch(signo) - int signo; -{ - F_SET(__global_list, G_SIGWINCH); -} - -/* - * exrc_isok -- - * Check a .exrc for source-ability. - */ -static enum rc -exrc_isok(sp, sbp, path, rootok) - SCR *sp; - struct stat *sbp; - char *path; - int rootok; -{ - uid_t uid; - char *emsg, buf[MAXPATHLEN]; - - /* Check for the file's existence. */ - if (stat(path, sbp)) - return (NOEXIST); - - /* - * !!! - * Historically, vi did not read the .exrc files if they were owned - * by someone other than the user, unless the undocumented option - * sourceany was set. We don't support the sourceany option. We - * check that the user (or root, for system files) owns the file and - * require that it not be writeable by anyone other than the owner. - */ - - /* Owned by the user or root. */ - uid = getuid(); - if (rootok) { - if (sbp->st_uid != uid && sbp->st_uid != 0) { - emsg = "not owned by you or root"; - goto denied; - } - } else - if (sbp->st_uid != uid) { - emsg = "not owned by you"; - goto denied; - } - - /* Not writeable by anyone but the owner. */ - if (sbp->st_mode & (S_IWGRP | S_IWOTH)) { - emsg = "writeable by a user other than the owner"; -denied: if (strchr(path, '/') == NULL && - getcwd(buf, sizeof(buf)) != NULL) - msgq(sp, M_ERR, - "%s/%s: not sourced: %s.", buf, path, emsg); - else - msgq(sp, M_ERR, - "%s: not sourced: %s.", path, emsg); - return (NOPERM); - } - return (OK); -} - -static void -obsolete(argv) - char *argv[]; -{ - size_t len; - char *p; - - /* - * Translate old style arguments into something getopt will like. - * Make sure it's not text space memory, because ex changes the - * strings. - * Change "+" into "-c$". - * Change "+<anything else>" into "-c<anything else>". - * Change "-" into "-s" - * Change "-r" into "-l" - */ - while (*++argv) - if (argv[0][0] == '+') { - if (argv[0][1] == '\0') { - MALLOC_NOMSG(NULL, argv[0], char *, 4); - if (argv[0] == NULL) - err(1, NULL); - (void)strcpy(argv[0], "-c$"); - } else { - p = argv[0]; - len = strlen(argv[0]); - MALLOC_NOMSG(NULL, argv[0], char *, len + 2); - if (argv[0] == NULL) - err(1, NULL); - argv[0][0] = '-'; - argv[0][1] = 'c'; - (void)strcpy(argv[0] + 2, p + 1); - } - } else if (argv[0][0] == '-') { - if (argv[0][1] == 'r') { - if (argv[0][2] == '\0' && argv[1] == NULL) - argv[0][1] = 'l'; - } else if (argv[0][1] == '\0') { - MALLOC_NOMSG(NULL, argv[0], char *, 3); - if (argv[0] == NULL) - err(1, NULL); - (void)strcpy(argv[0], "-s"); - } - } -} - -static void -usage(is_ex) - int is_ex; -{ -#define EX_USAGE \ - "usage: ex [-eFlRsv] [-c command] [-r file] [-t tag] [-w size] [-x aw]" -#define VI_USAGE \ - "usage: vi [-eFlRv] [-c command] [-r file] [-t tag] [-w size] [-x aw]" - - (void)fprintf(stderr, "%s\n", is_ex ? EX_USAGE : VI_USAGE); - exit(1); -} diff --git a/usr.bin/vi/mark.c b/usr.bin/vi/mark.c deleted file mode 100644 index e3f1224aecdc..000000000000 --- a/usr.bin/vi/mark.c +++ /dev/null @@ -1,272 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)mark.c 8.17 (Berkeley) 3/15/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <errno.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" - -static LMARK *mark_find __P((SCR *, EXF *, ARG_CHAR_T)); - -/* - * Marks are maintained in a key sorted doubly linked list. We can't - * use arrays because we have no idea how big an index key could be. - * The underlying assumption is that users don't have more than, say, - * 10 marks at any one time, so this will be is fast enough. - * - * Marks are fixed, and modifications to the line don't update the mark's - * position in the line. This can be hard. If you add text to the line, - * place a mark in that text, undo the addition and use ` to move to the - * mark, the location will have disappeared. It's tempting to try to adjust - * the mark with the changes in the line, but this is hard to do, especially - * if we've given the line to v_ntext.c:v_ntext() for editing. Historic vi - * would move to the first non-blank on the line when the mark location was - * past the end of the line. This can be complicated by deleting to a mark - * that has disappeared using the ` command. Historic vi vi treated this as - * a line-mode motion and deleted the line. This implementation complains to - * the user. - * - * In historic vi, marks returned if the operation was undone, unless the - * mark had been subsequently reset. Tricky. This is hard to start with, - * but in the presence of repeated undo it gets nasty. When a line is - * deleted, we delete (and log) any marks on that line. An undo will create - * the mark. Any mark creations are noted as to whether the user created - * it or if it was created by an undo. The former cannot be reset by another - * undo, but the latter may. - * - * All of these routines translate ABSMARK2 to ABSMARK1. Setting either of - * the absolute mark locations sets both, so that "m'" and "m`" work like - * they, ah, for lack of a better word, "should". - */ - -/* - * mark_init -- - * Set up the marks. - */ -int -mark_init(sp, ep) - SCR *sp; - EXF *ep; -{ - LMARK *lmp; - - /* - * Make sure the marks have been set up. If they - * haven't, do so, and create the absolute mark. - */ - MALLOC_RET(sp, lmp, LMARK *, sizeof(LMARK)); - lmp->lno = 1; - lmp->cno = 0; - lmp->name = ABSMARK1; - lmp->flags = 0; - LIST_INSERT_HEAD(&ep->marks, lmp, q); - return (0); -} - -/* - * mark_end -- - * Free up the marks. - */ -int -mark_end(sp, ep) - SCR *sp; - EXF *ep; -{ - LMARK *lmp; - - while ((lmp = ep->marks.lh_first) != NULL) { - LIST_REMOVE(lmp, q); - FREE(lmp, sizeof(LMARK)); - } - return (0); -} - -/* - * mark_get -- - * Get the location referenced by a mark. - */ -int -mark_get(sp, ep, key, mp) - SCR *sp; - EXF *ep; - ARG_CHAR_T key; - MARK *mp; -{ - LMARK *lmp; - size_t len; - - if (key == ABSMARK2) - key = ABSMARK1; - - lmp = mark_find(sp, ep, key); - if (lmp == NULL || lmp->name != key) { - msgq(sp, M_BERR, "Mark %s: not set.", charname(sp, key)); - return (1); - } - if (F_ISSET(lmp, MARK_DELETED)) { - msgq(sp, M_BERR, - "Mark %s: the line was deleted.", charname(sp, key)); - return (1); - } - if (file_gline(sp, ep, lmp->lno, &len) == NULL || - lmp->cno > len || lmp->cno == len && len != 0) { - msgq(sp, M_BERR, "Mark %s: cursor position no longer exists.", - charname(sp, key)); - return (1); - } - mp->lno = lmp->lno; - mp->cno = lmp->cno; - return (0); -} - -/* - * mark_set -- - * Set the location referenced by a mark. - */ -int -mark_set(sp, ep, key, value, userset) - SCR *sp; - EXF *ep; - ARG_CHAR_T key; - MARK *value; - int userset; -{ - LMARK *lmp, *lmt; - - if (key == ABSMARK2) - key = ABSMARK1; - - /* - * The rules are simple. If the user is setting a mark (if it's a - * new mark this is always true), it always happens. If not, it's - * an undo, and we set it if it's not already set or if it was set - * by a previous undo. - */ - lmp = mark_find(sp, ep, key); - if (lmp == NULL || lmp->name != key) { - MALLOC_RET(sp, lmt, LMARK *, sizeof(LMARK)); - if (lmp == NULL) { - LIST_INSERT_HEAD(&ep->marks, lmt, q); - } else - LIST_INSERT_AFTER(lmp, lmt, q); - lmp = lmt; - } else if (!userset && - !F_ISSET(lmp, MARK_DELETED) && F_ISSET(lmp, MARK_USERSET)) - return (0); - - lmp->lno = value->lno; - lmp->cno = value->cno; - lmp->name = key; - lmp->flags = userset ? MARK_USERSET : 0; - return (0); -} - -/* - * mark_find -- - * Find the requested mark, or, the slot immediately before - * where it would go. - */ -static LMARK * -mark_find(sp, ep, key) - SCR *sp; - EXF *ep; - ARG_CHAR_T key; -{ - LMARK *lmp, *lastlmp; - - /* - * Return the requested mark or the slot immediately before - * where it should go. - */ - for (lastlmp = NULL, lmp = ep->marks.lh_first; - lmp != NULL; lastlmp = lmp, lmp = lmp->q.le_next) - if (lmp->name >= key) - return (lmp->name == key ? lmp : lastlmp); - return (lastlmp); -} - -/* - * mark_insdel -- - * Update the marks based on an insertion or deletion. - */ -void -mark_insdel(sp, ep, op, lno) - SCR *sp; - EXF *ep; - enum operation op; - recno_t lno; -{ - LMARK *lmp; - - switch (op) { - case LINE_APPEND: - return; - case LINE_DELETE: - for (lmp = ep->marks.lh_first; - lmp != NULL; lmp = lmp->q.le_next) - if (lmp->lno >= lno) - if (lmp->lno == lno) { - F_SET(lmp, MARK_DELETED); - (void)log_mark(sp, ep, lmp); - } else - --lmp->lno; - return; - case LINE_INSERT: - for (lmp = ep->marks.lh_first; - lmp != NULL; lmp = lmp->q.le_next) - if (lmp->lno >= lno) - ++lmp->lno; - return; - case LINE_RESET: - return; - } - /* NOTREACHED */ -} diff --git a/usr.bin/vi/mark.h b/usr.bin/vi/mark.h deleted file mode 100644 index 04b445298a7e..000000000000 --- a/usr.bin/vi/mark.h +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)mark.h 8.8 (Berkeley) 3/16/94 - */ - -/* - * The MARK and LMARK structures define positions in the file. There are - * two structures because the mark subroutines are the only places where - * anything cares about something other than line and column. - * - * Because of the different interfaces used by the db(3) package, curses, - * and users, the line number is 1 based and the column number is 0 based. - * Additionally, it is known that the out-of-band line number is less than - * any legal line number. The line number is of type recno_t, as that's - * the underlying type of the database. The column number is of type size_t, - * guaranteeing that we can malloc a line. - */ -struct _mark { -#define OOBLNO 0 /* Out-of-band line number. */ - recno_t lno; /* Line number. */ - size_t cno; /* Column number. */ -}; - -struct _lmark { - LIST_ENTRY(_lmark) q; /* Linked list of marks. */ - recno_t lno; /* Line number. */ - size_t cno; /* Column number. */ - CHAR_T name; /* Mark name. */ - -#define MARK_DELETED 0x01 /* Mark was deleted. */ -#define MARK_USERSET 0x02 /* User set this mark. */ - u_char flags; -}; - -#define ABSMARK1 '\'' /* Absolute mark name. */ -#define ABSMARK2 '`' /* Absolute mark name. */ - -/* Mark routines. */ -int mark_end __P((SCR *, EXF *)); -int mark_get __P((SCR *, EXF *, ARG_CHAR_T, MARK *)); -int mark_init __P((SCR *, EXF *)); -void mark_insdel __P((SCR *, EXF *, enum operation, recno_t)); -int mark_set __P((SCR *, EXF *, ARG_CHAR_T, MARK *, int)); diff --git a/usr.bin/vi/mem.h b/usr.bin/vi/mem.h deleted file mode 100644 index f604cbd0aeed..000000000000 --- a/usr.bin/vi/mem.h +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * Copyright (c) 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)mem.h 8.5 (Berkeley) 3/16/94 - */ - -/* Increase the size of a malloc'd buffer. Two versions, one that - * returns, one that jumps to an error label. - */ -#define BINC_GOTO(sp, lp, llen, nlen) { \ - if ((nlen) > llen && binc(sp, &(lp), &(llen), nlen)) \ - goto binc_err; \ -} -#define BINC_RET(sp, lp, llen, nlen) { \ - if ((nlen) > llen && binc(sp, &(lp), &(llen), nlen)) \ - return (1); \ -} - -/* - * Get some temporary space, preferably from the global temporary buffer, - * from a malloc'd buffer otherwise. Two versions, one that returns, one - * that jumps to an error label. - */ -#define GET_SPACE_GOTO(sp, bp, blen, nlen) { \ - GS *__gp = (sp)->gp; \ - if (F_ISSET(__gp, G_TMP_INUSE)) { \ - bp = NULL; \ - blen = 0; \ - BINC_GOTO(sp, bp, blen, nlen); \ - } else { \ - BINC_GOTO(sp, __gp->tmp_bp, __gp->tmp_blen, nlen); \ - bp = __gp->tmp_bp; \ - blen = __gp->tmp_blen; \ - F_SET(__gp, G_TMP_INUSE); \ - } \ -} -#define GET_SPACE_RET(sp, bp, blen, nlen) { \ - GS *__gp = (sp)->gp; \ - if (F_ISSET(__gp, G_TMP_INUSE)) { \ - bp = NULL; \ - blen = 0; \ - BINC_RET(sp, bp, blen, nlen); \ - } else { \ - BINC_RET(sp, __gp->tmp_bp, __gp->tmp_blen, nlen); \ - bp = __gp->tmp_bp; \ - blen = __gp->tmp_blen; \ - F_SET(__gp, G_TMP_INUSE); \ - } \ -} - -/* - * Add space to a GET_SPACE returned buffer. Two versions, one that - * returns, one that jumps to an error label. - */ -#define ADD_SPACE_GOTO(sp, bp, blen, nlen) { \ - GS *__gp = (sp)->gp; \ - if (bp == __gp->tmp_bp) { \ - F_CLR(__gp, G_TMP_INUSE); \ - BINC_GOTO(sp, __gp->tmp_bp, __gp->tmp_blen, nlen); \ - bp = __gp->tmp_bp; \ - blen = __gp->tmp_blen; \ - F_SET(__gp, G_TMP_INUSE); \ - } else \ - BINC_GOTO(sp, bp, blen, nlen); \ -} -#define ADD_SPACE_RET(sp, bp, blen, nlen) { \ - GS *__gp = (sp)->gp; \ - if (bp == __gp->tmp_bp) { \ - F_CLR(__gp, G_TMP_INUSE); \ - BINC_RET(sp, __gp->tmp_bp, __gp->tmp_blen, nlen); \ - bp = __gp->tmp_bp; \ - blen = __gp->tmp_blen; \ - F_SET(__gp, G_TMP_INUSE); \ - } else \ - BINC_RET(sp, bp, blen, nlen); \ -} - -/* Free memory, optionally making pointers unusable. */ -#ifdef DEBUG -#define FREE(p, sz) { \ - memset(p, 0xff, sz); \ - free(p); \ -} -#else -#define FREE(p, sz) free(p); -#endif - -/* Free a GET_SPACE returned buffer. */ -#define FREE_SPACE(sp, bp, blen) { \ - if (bp == sp->gp->tmp_bp) \ - F_CLR(sp->gp, G_TMP_INUSE); \ - else \ - FREE(bp, blen); \ -} - -/* - * Malloc a buffer, casting the return pointer. Various versions. - * - * !!! - * The cast should be unnecessary, malloc(3) and friends return void *'s, - * which is all we need. However, some systems that nvi needs to run on - * don't do it right yet, resulting in the compiler printing out roughly - * a million warnings. After awhile, it seemed easier to put the casts - * in instead of explaining it all the time. - */ -#define CALLOC_NOMSG(sp, p, cast, nmemb, size) { \ - p = (cast)calloc(nmemb, size); \ -} -#define CALLOC(sp, p, cast, nmemb, size) { \ - if ((p = (cast)calloc(nmemb, size)) == NULL) \ - msgq(sp, M_SYSERR, NULL); \ -} -#define CALLOC_RET(sp, p, cast, nmemb, size) { \ - if ((p = (cast)calloc(nmemb, size)) == NULL) { \ - msgq(sp, M_SYSERR, NULL); \ - return (1); \ - } \ -} -#define MALLOC_NOMSG(sp, p, cast, size) { \ - p = (cast)malloc(size); \ -} -#define MALLOC(sp, p, cast, size) { \ - if ((p = (cast)malloc(size)) == NULL) \ - msgq(sp, M_SYSERR, NULL); \ -} -#define MALLOC_RET(sp, p, cast, size) { \ - if ((p = (cast)malloc(size)) == NULL) { \ - msgq(sp, M_SYSERR, NULL); \ - return (1); \ - } \ -} -#define REALLOC(sp, p, cast, size) { \ - if ((p = (cast)realloc(p, size)) == NULL) \ - msgq(sp, M_SYSERR, NULL); \ -} - -/* - * Versions of memmove(3) and memset(3) that use the size of the - * initial pointer to figure out how much memory to manipulate. - */ -#define MEMMOVE(p, t, len) memmove(p, t, (len) * sizeof(*(p))) -#define MEMSET(p, value, len) memset(p, value, (len) * sizeof(*(p))) - -int binc __P((SCR *, void *, size_t *, size_t)); diff --git a/usr.bin/vi/msg.h b/usr.bin/vi/msg.h deleted file mode 100644 index 15eaf356ef4f..000000000000 --- a/usr.bin/vi/msg.h +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)msg.h 8.10 (Berkeley) 3/16/94 - */ - -/* - * Message types. - * - * !!! - * In historical vi, O_VERBOSE didn't exist, and O_TERSE made the error - * messages shorter. In this implementation, O_TERSE has no effect and - * O_VERBOSE results in informational displays about common errors for - * naive users. - * - * M_BERR Error: M_ERR if O_VERBOSE, else bell. - * M_ERR Error: Display in inverse video. - * M_INFO Info: Display in normal video. - * M_SYSERR Error: M_ERR, using strerror(3) message. - * M_VINFO Info: M_INFO if O_VERBOSE, else ignore. - */ -enum msgtype { M_BERR, M_ERR, M_INFO, M_SYSERR, M_VINFO }; - -typedef struct _msgh MSGH; /* MESG list head structure. */ -LIST_HEAD(_msgh, _msg); - -struct _msg { - LIST_ENTRY(_msg) q; /* Linked list of messages. */ - char *mbuf; /* Message buffer. */ - size_t blen; /* Message buffer length. */ - size_t len; /* Message length. */ - -#define M_EMPTY 0x01 /* No message. */ -#define M_INV_VIDEO 0x02 /* Inverse video. */ - u_int flags; /* Flags. */ -}; - -/* Messages. */ -void msg_app __P((GS *, SCR *, int, char *, size_t)); -int msg_rpt __P((SCR *, int)); -void msgq __P((SCR *, enum msgtype, const char *, ...)); diff --git a/usr.bin/vi/options.c b/usr.bin/vi/options.c deleted file mode 100644 index 9545661856b5..000000000000 --- a/usr.bin/vi/options.c +++ /dev/null @@ -1,857 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)options.c 8.52 (Berkeley) 3/24/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/stat.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <ctype.h> -#include <errno.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> -#include <pathnames.h> - -#include "vi.h" -#include "excmd.h" - -static int opts_abbcmp __P((const void *, const void *)); -static int opts_cmp __P((const void *, const void *)); -static OPTLIST const *opts_prefix __P((char *)); -static int opts_print __P((SCR *, OPTLIST const *)); - -/* - * O'Reilly noted options and abbreviations are from "Learning the VI Editor", - * Fifth Edition, May 1992. There's no way of knowing what systems they are - * actually from. - * - * HPUX noted options and abbreviations are from "The Ultimate Guide to the - * VI and EX Text Editors", 1990. - */ -static OPTLIST const optlist[] = { -/* O_ALTWERASE 4.4BSD */ - {"altwerase", f_altwerase, OPT_0BOOL, 0}, -/* O_AUTOINDENT 4BSD */ - {"autoindent", NULL, OPT_0BOOL, 0}, -/* O_AUTOPRINT 4BSD */ - {"autoprint", NULL, OPT_1BOOL, 0}, -/* O_AUTOWRITE 4BSD */ - {"autowrite", NULL, OPT_0BOOL, 0}, -/* O_BEAUTIFY 4BSD */ - {"beautify", NULL, OPT_0BOOL, 0}, -/* O_CDPATH 4.4BSD */ - {"cdpath", f_cdpath, OPT_STR, 0}, -/* O_COLUMNS 4.4BSD */ - {"columns", f_columns, OPT_NUM, OPT_NOSAVE}, -/* O_COMMENT 4.4BSD */ - {"comment", NULL, OPT_0BOOL, 0}, -/* O_DIGRAPH XXX: Elvis */ - {"digraph", NULL, OPT_0BOOL, 0}, -/* O_DIRECTORY 4BSD */ - {"directory", NULL, OPT_STR, 0}, -/* O_EDCOMPATIBLE 4BSD */ - {"edcompatible",NULL, OPT_0BOOL, 0}, -/* O_ERRORBELLS 4BSD */ - {"errorbells", NULL, OPT_0BOOL, 0}, -/* O_EXRC System V (undocumented) */ - {"exrc", NULL, OPT_0BOOL, 0}, -/* O_EXTENDED 4.4BSD */ - {"extended", NULL, OPT_0BOOL, 0}, -/* O_FLASH HPUX */ - {"flash", NULL, OPT_1BOOL, 0}, -/* O_HARDTABS 4BSD */ - {"hardtabs", NULL, OPT_NUM, 0}, -/* O_IGNORECASE 4BSD */ - {"ignorecase", NULL, OPT_0BOOL, 0}, -/* O_KEYTIME 4.4BSD */ - {"keytime", f_keytime, OPT_NUM, 0}, -/* O_LEFTRIGHT 4.4BSD */ - {"leftright", f_leftright, OPT_0BOOL, 0}, -/* O_LINES 4.4BSD */ - {"lines", f_lines, OPT_NUM, OPT_NOSAVE}, -/* O_LISP 4BSD */ -/* - * XXX - * When the lisp option is implemented, delete - * the OPT_NOSAVE flag, so that :mkexrc dumps it. - */ - {"lisp", f_lisp, OPT_0BOOL, OPT_NOSAVE}, -/* O_LIST 4BSD */ - {"list", f_list, OPT_0BOOL, 0}, -/* O_MAGIC 4BSD */ - {"magic", NULL, OPT_1BOOL, 0}, -/* O_MATCHTIME 4.4BSD */ - {"matchtime", f_matchtime, OPT_NUM, 0}, -/* O_MESG 4BSD */ - {"mesg", f_mesg, OPT_1BOOL, 0}, -/* O_MODELINE 4BSD */ - {"modeline", f_modeline, OPT_0BOOL, 0}, -/* O_NUMBER 4BSD */ - {"number", f_number, OPT_0BOOL, 0}, -/* O_OPEN 4BSD */ - {"open", NULL, OPT_1BOOL, 0}, -/* O_OPTIMIZE 4BSD */ - {"optimize", NULL, OPT_1BOOL, 0}, -/* O_PARAGRAPHS 4BSD */ - {"paragraphs", f_paragraph, OPT_STR, 0}, -/* O_PROMPT 4BSD */ - {"prompt", NULL, OPT_1BOOL, 0}, -/* O_READONLY 4BSD (undocumented) */ - {"readonly", f_readonly, OPT_0BOOL, 0}, -/* O_RECDIR 4.4BSD */ - {"recdir", NULL, OPT_STR, 0}, -/* O_REDRAW 4BSD */ - {"redraw", NULL, OPT_0BOOL, 0}, -/* O_REMAP 4BSD */ - {"remap", NULL, OPT_1BOOL, 0}, -/* O_REMAPMAX 4.4BSD */ - {"remapmax", NULL, OPT_1BOOL, 0}, -/* O_REPORT 4BSD */ - {"report", NULL, OPT_NUM, OPT_NOSTR}, -/* O_RULER 4.4BSD */ - {"ruler", f_ruler, OPT_0BOOL, 0}, -/* O_SCROLL 4BSD */ - {"scroll", NULL, OPT_NUM, 0}, -/* O_SECTIONS 4BSD */ - {"sections", f_section, OPT_STR, 0}, -/* O_SHELL 4BSD */ - {"shell", NULL, OPT_STR, 0}, -/* O_SHIFTWIDTH 4BSD */ - {"shiftwidth", f_shiftwidth, OPT_NUM, 0}, -/* O_SHOWDIRTY 4.4BSD */ - {"showdirty", NULL, OPT_0BOOL, 0}, -/* O_SHOWMATCH 4BSD */ - {"showmatch", NULL, OPT_0BOOL, 0}, -/* O_SHOWMODE 4.4BSD */ - {"showmode", NULL, OPT_0BOOL, 0}, -/* O_SIDESCROLL 4.4BSD */ - {"sidescroll", f_sidescroll, OPT_NUM, 0}, -/* O_SLOWOPEN 4BSD */ - {"slowopen", NULL, OPT_0BOOL, 0}, -/* O_SOURCEANY 4BSD (undocumented) */ - {"sourceany", f_sourceany, OPT_0BOOL, 0}, -/* O_TABSTOP 4BSD */ - {"tabstop", f_tabstop, OPT_NUM, 0}, -/* O_TAGLENGTH 4BSD */ - {"taglength", NULL, OPT_NUM, OPT_NOSTR}, -/* O_TAGS 4BSD */ - {"tags", f_tags, OPT_STR, 0}, -/* O_TERM 4BSD */ - {"term", f_term, OPT_STR, OPT_NOSAVE}, -/* O_TERSE 4BSD */ - {"terse", NULL, OPT_0BOOL, 0}, -/* O_TIMEOUT 4BSD (undocumented) */ - {"timeout", NULL, OPT_1BOOL, 0}, -/* O_TTYWERASE 4.4BSD */ - {"ttywerase", f_ttywerase, OPT_0BOOL, 0}, -/* O_VERBOSE 4.4BSD */ - {"verbose", NULL, OPT_0BOOL, 0}, -/* O_W1200 4BSD */ - {"w1200", f_w1200, OPT_NUM, OPT_NEVER|OPT_NOSAVE}, -/* O_W300 4BSD */ - {"w300", f_w300, OPT_NUM, OPT_NEVER|OPT_NOSAVE}, -/* O_W9600 4BSD */ - {"w9600", f_w9600, OPT_NUM, OPT_NEVER|OPT_NOSAVE}, -/* O_WARN 4BSD */ - {"warn", NULL, OPT_1BOOL, 0}, -/* O_WINDOW 4BSD */ - {"window", f_window, OPT_NUM, 0}, -/* O_WRAPMARGIN 4BSD */ - {"wrapmargin", f_wrapmargin, OPT_NUM, OPT_NOSTR}, -/* O_WRAPSCAN 4BSD */ - {"wrapscan", NULL, OPT_1BOOL, 0}, -/* O_WRITEANY 4BSD */ - {"writeany", NULL, OPT_0BOOL, 0}, - {NULL}, -}; - -typedef struct abbrev { - char *name; - int offset; -} OABBREV; - -static OABBREV const abbrev[] = { - {"ai", O_AUTOINDENT}, /* 4BSD */ - {"ap", O_AUTOPRINT}, /* 4BSD */ - {"aw", O_AUTOWRITE}, /* 4BSD */ - {"bf", O_BEAUTIFY}, /* 4BSD */ - {"co", O_COLUMNS}, /* 4.4BSD */ - {"dir", O_DIRECTORY}, /* 4BSD */ - {"eb", O_ERRORBELLS}, /* 4BSD */ - {"ed", O_EDCOMPATIBLE}, /* 4BSD (undocumented) */ - {"ex", O_EXRC}, /* System V (undocumented) */ - {"ht", O_HARDTABS}, /* 4BSD */ - {"ic", O_IGNORECASE}, /* 4BSD */ - {"li", O_LINES}, /* 4.4BSD */ - {"modelines", O_MODELINE}, /* HPUX */ - {"nu", O_NUMBER}, /* 4BSD */ - {"opt", O_OPTIMIZE}, /* 4BSD */ - {"para", O_PARAGRAPHS}, /* 4BSD */ - {"re", O_REDRAW}, /* O'Reilly */ - {"ro", O_READONLY}, /* 4BSD (undocumented) */ - {"scr", O_SCROLL}, /* 4BSD (undocumented) */ - {"sect", O_SECTIONS}, /* O'Reilly */ - {"sh", O_SHELL}, /* 4BSD */ - {"slow", O_SLOWOPEN}, /* 4BSD */ - {"sm", O_SHOWMATCH}, /* 4BSD */ - {"sw", O_SHIFTWIDTH}, /* 4BSD */ - {"tag", O_TAGS}, /* 4BSD (undocumented) */ - {"tl", O_TAGLENGTH}, /* 4BSD */ - {"to", O_TIMEOUT}, /* 4BSD (undocumented) */ - {"ts", O_TABSTOP}, /* 4BSD */ - {"tty", O_TERM}, /* 4BSD (undocumented) */ - {"ttytype", O_TERM}, /* 4BSD (undocumented) */ - {"w", O_WINDOW}, /* O'Reilly */ - {"wa", O_WRITEANY}, /* 4BSD */ - {"wi", O_WINDOW}, /* 4BSD (undocumented) */ - {"wm", O_WRAPMARGIN}, /* 4BSD */ - {"ws", O_WRAPSCAN}, /* 4BSD */ - {NULL}, -}; - -/* - * opts_init -- - * Initialize some of the options. Since the user isn't really - * "setting" these variables, don't set their OPT_SET bits. - */ -int -opts_init(sp) - SCR *sp; -{ - ARGS *argv[2], a, b; - OPTLIST const *op; - u_long v; - int cnt; - char *s, b1[1024]; - - a.bp = b1; - a.len = 0; - b.bp = NULL; - b.len = 0; - argv[0] = &a; - argv[1] = &b; - -#define SET_DEF(opt, str) { \ - if (str != b1) /* GCC puts strings in text-space. */ \ - (void)strcpy(b1, str); \ - a.len = strlen(b1); \ - if (opts_set(sp, argv)) { \ - msgq(sp, M_ERR, \ - "Unable to set default %s option", optlist[opt]); \ - return (1); \ - } \ - F_CLR(&sp->opts[opt], OPT_SET); \ -} - /* Set default values. */ - for (op = optlist, cnt = 0; op->name != NULL; ++op, ++cnt) - if (op->type == OPT_0BOOL) - O_CLR(sp, cnt); - else if (op->type == OPT_1BOOL) - O_SET(sp, cnt); - - (void)snprintf(b1, sizeof(b1), "cdpath=%s", - (s = getenv("CDPATH")) == NULL ? ":" : s); - SET_DEF(O_CDPATH, b1); - - /* - * !!! - * Vi historically stored temporary files in /var/tmp. We store them - * in /tmp by default, hoping it's a memory based file system. There - * are two ways to change this -- the user can set either the directory - * option or the TMPDIR environmental variable. - */ - (void)snprintf(b1, sizeof(b1), "directory=%s", - (s = getenv("TMPDIR")) == NULL ? _PATH_TMP : s); - SET_DEF(O_DIRECTORY, b1); - SET_DEF(O_KEYTIME, "keytime=6"); - SET_DEF(O_MATCHTIME, "matchtime=7"); - SET_DEF(O_REPORT, "report=5"); - SET_DEF(O_PARAGRAPHS, "paragraphs=IPLPPPQPP LIpplpipbp"); - (void)snprintf(b1, sizeof(b1), "recdir=%s", _PATH_PRESERVE); - SET_DEF(O_RECDIR, b1); - (void)snprintf(b1, sizeof(b1), "scroll=%ld", O_VAL(sp, O_LINES) / 2); - SET_DEF(O_SCROLL, b1); - SET_DEF(O_SECTIONS, "sections=NHSHH HUnhsh"); - (void)snprintf(b1, sizeof(b1), "shell=%s", - (s = getenv("SHELL")) == NULL ? _PATH_BSHELL : s); - SET_DEF(O_SHELL, b1); - SET_DEF(O_SHIFTWIDTH, "shiftwidth=8"); - SET_DEF(O_SIDESCROLL, "sidescroll=16"); - SET_DEF(O_TABSTOP, "tabstop=8"); - (void)snprintf(b1, sizeof(b1), "tags=%s", _PATH_TAGS); - SET_DEF(O_TAGS, b1); - (void)snprintf(b1, sizeof(b1), "term=%s", - (s = getenv("TERM")) == NULL ? "unknown" : s); - SET_DEF(O_TERM, b1); - - /* - * The default window option values are: - * 8 if baud rate <= 600 - * 16 if baud rate <= 1200 - * LINES - 1 if baud rate > 1200 - */ - v = baud_from_bval(sp); - if (v <= 600) - v = 8; - else if (v <= 1200) - v = 16; - else - v = O_VAL(sp, O_LINES) - 1; - (void)snprintf(b1, sizeof(b1), "window=%lu", v); - SET_DEF(O_WINDOW, b1); - - SET_DEF(O_WRAPMARGIN, "wrapmargin=0"); - - /* - * By default, the historic vi always displayed information - * about two options, redraw and term. Term seems sufficient. - */ - F_SET(&sp->opts[O_TERM], OPT_SET); - return (0); -} - -/* - * opts_set -- - * Change the values of one or more options. - */ -int -opts_set(sp, argv) - SCR *sp; - ARGS *argv[]; -{ - enum optdisp disp; - OABBREV atmp, *ap; - OPTLIST const *op; - OPTLIST otmp; - OPTION *spo; - u_long value, turnoff; - int ch, offset, rval; - char *endp, *equals, *name, *p; - - disp = NO_DISPLAY; - for (rval = 0; (*argv)->len != 0; ++argv) { - /* - * The historic vi dumped the options for each occurrence of - * "all" in the set list. Puhleeze. - */ - if (!strcmp(argv[0]->bp, "all")) { - disp = ALL_DISPLAY; - continue; - } - - /* Find equals sign or end of set, skipping backquoted chars. */ - for (equals = NULL, - p = name = argv[0]->bp; (ch = *p) != '\0'; ++p) - switch (ch) { - case '=': - equals = p; - break; - case '\\': - /* Historic vi just used the backslash. */ - if (p[1] == '\0') - break; - ++p; - break; - } - - turnoff = 0; - op = NULL; - if (equals) - *equals++ = '\0'; - - /* Check list of abbreviations. */ - atmp.name = name; - if ((ap = bsearch(&atmp, abbrev, - sizeof(abbrev) / sizeof(OABBREV) - 1, - sizeof(OABBREV), opts_abbcmp)) != NULL) { - op = optlist + ap->offset; - goto found; - } - - /* Check list of options. */ - otmp.name = name; - if ((op = bsearch(&otmp, optlist, - sizeof(optlist) / sizeof(OPTLIST) - 1, - sizeof(OPTLIST), opts_cmp)) != NULL) - goto found; - - /* Try the name without any leading "no". */ - if (name[0] == 'n' && name[1] == 'o') { - turnoff = 1; - name += 2; - } else - goto prefix; - - /* Check list of abbreviations. */ - atmp.name = name; - if ((ap = bsearch(&atmp, abbrev, - sizeof(abbrev) / sizeof(OABBREV) - 1, - sizeof(OABBREV), opts_abbcmp)) != NULL) { - op = optlist + ap->offset; - goto found; - } - - /* Check list of options. */ - otmp.name = name; - if ((op = bsearch(&otmp, optlist, - sizeof(optlist) / sizeof(OPTLIST) - 1, - sizeof(OPTLIST), opts_cmp)) != NULL) - goto found; - - /* Check for prefix match. */ -prefix: op = opts_prefix(name); - -found: if (op == NULL) { - msgq(sp, M_ERR, - "no %s option: 'set all' gives all option values", - name); - continue; - } - - /* Find current option values. */ - offset = op - optlist; - spo = sp->opts + offset; - - /* Set name, value. */ - switch (op->type) { - case OPT_0BOOL: - case OPT_1BOOL: - if (equals) { - msgq(sp, M_ERR, - "set: [no]%s option doesn't take a value", - name); - break; - } - if (op->func != NULL) { - if (op->func(sp, spo, NULL, turnoff)) { - rval = 1; - break; - } - } else if (turnoff) - O_CLR(sp, offset); - else - O_SET(sp, offset); - goto change; - case OPT_NUM: - /* - * !!! - * Extension to historic vi. If the OPT_NOSTR flag is - * set, a numeric option may be turned off by using a - * "no" prefix, e.g. "nowrapmargin". (We assume that - * setting the value to 0 turns a numeric option off.) - */ - if (turnoff) { - if (F_ISSET(op, OPT_NOSTR)) { - value = 0; - goto nostr; - } - msgq(sp, M_ERR, - "set: %s option isn't a boolean", name); - break; - } - if (!equals) { - if (!disp) - disp = SELECT_DISPLAY; - F_SET(spo, OPT_SELECTED); - break; - } - value = strtol(equals, &endp, 10); - if (*endp && !isblank(*endp)) { - msgq(sp, M_ERR, - "set %s: illegal number %s", name, equals); - break; - } -nostr: if (op->func != NULL) { - if (op->func(sp, spo, equals, value)) { - rval = 1; - break; - } - } else - O_VAL(sp, offset) = value; - goto change; - case OPT_STR: - if (turnoff) { - msgq(sp, M_ERR, - "set: %s option isn't a boolean", name); - break; - } - if (!equals) { - if (!disp) - disp = SELECT_DISPLAY; - F_SET(spo, OPT_SELECTED); - break; - } - if (op->func != NULL) { - if (op->func(sp, spo, equals, (u_long)0)) { - rval = 1; - break; - } - } else { - if (F_ISSET(&sp->opts[offset], OPT_ALLOCATED)) - free(O_STR(sp, offset)); - if ((O_STR(sp, offset) = - strdup(equals)) == NULL) { - msgq(sp, M_SYSERR, NULL); - rval = 1; - break; - } else - F_SET(&sp->opts[offset], OPT_ALLOCATED); - } -change: if (sp->s_optchange != NULL) - (void)sp->s_optchange(sp, offset); - F_SET(&sp->opts[offset], OPT_SET); - break; - default: - abort(); - } - } - if (disp != NO_DISPLAY) - opts_dump(sp, disp); - return (rval); -} - -/* - * opts_dump -- - * List the current values of selected options. - */ -void -opts_dump(sp, type) - SCR *sp; - enum optdisp type; -{ - OPTLIST const *op; - int base, b_num, cnt, col, colwidth, curlen, s_num; - int numcols, numrows, row; - int b_op[O_OPTIONCOUNT], s_op[O_OPTIONCOUNT]; - char nbuf[20]; - - /* - * XXX - * It's possible to get here by putting "set option" in the - * .exrc file. I can't think of a clean way to layer this, - * or a reasonable check to make, so we block it here. - */ - if (sp->stdfp == NULL) { - msgq(sp, M_ERR, - "Option display requires that the screen be initialized."); - return; - } - - /* - * Options are output in two groups -- those that fit in a column and - * those that don't. Output is done on 6 character "tab" boundaries - * for no particular reason. (Since we don't output tab characters, - * we can ignore the terminal's tab settings.) Ignore the user's tab - * setting because we have no idea how reasonable it is. - * - * Find a column width we can live with. - */ - for (cnt = 6; cnt > 1; --cnt) { - colwidth = (sp->cols - 1) / cnt & ~(STANDARD_TAB - 1); - if (colwidth >= 10) { - colwidth = - (colwidth + STANDARD_TAB) & ~(STANDARD_TAB - 1); - break; - } - colwidth = 0; - } - - /* - * Get the set of options to list, entering them into - * the column list or the overflow list. - */ - for (b_num = s_num = 0, op = optlist; op->name != NULL; ++op) { - cnt = op - optlist; - - /* If OPT_NEVER set, it's never displayed. */ - if (F_ISSET(op, OPT_NEVER)) - continue; - - switch (type) { - case ALL_DISPLAY: /* Display all. */ - break; - case CHANGED_DISPLAY: /* Display changed. */ - if (!F_ISSET(&sp->opts[cnt], OPT_SET)) - continue; - break; - case SELECT_DISPLAY: /* Display selected. */ - if (!F_ISSET(&sp->opts[cnt], OPT_SELECTED)) - continue; - break; - default: - case NO_DISPLAY: - abort(); - /* NOTREACHED */ - } - F_CLR(&sp->opts[cnt], OPT_SELECTED); - - curlen = strlen(op->name); - switch (op->type) { - case OPT_0BOOL: - case OPT_1BOOL: - if (!O_ISSET(sp, cnt)) - curlen += 2; - break; - case OPT_NUM: - (void)snprintf(nbuf, - sizeof(nbuf), "%ld", O_VAL(sp, cnt)); - curlen += strlen(nbuf); - break; - case OPT_STR: - curlen += strlen(O_STR(sp, cnt)) + 3; - break; - } - /* Offset by two so there's a gap. */ - if (curlen < colwidth - 2) - s_op[s_num++] = cnt; - else - b_op[b_num++] = cnt; - } - - if (s_num > 0) { - /* Figure out the number of columns. */ - numcols = (sp->cols - 1) / colwidth; - if (s_num > numcols) { - numrows = s_num / numcols; - if (s_num % numcols) - ++numrows; - } else - numrows = 1; - - /* Display the options in sorted order. */ - for (row = 0; row < numrows;) { - for (base = row, col = 0; col < numcols; ++col) { - cnt = opts_print(sp, &optlist[s_op[base]]); - if ((base += numrows) >= s_num) - break; - (void)ex_printf(EXCOOKIE, - "%*s", (int)(colwidth - cnt), ""); - } - if (++row < numrows || b_num) - (void)ex_printf(EXCOOKIE, "\n"); - } - } - - for (row = 0; row < b_num;) { - (void)opts_print(sp, &optlist[b_op[row]]); - if (++row < b_num) - (void)ex_printf(EXCOOKIE, "\n"); - } - (void)ex_printf(EXCOOKIE, "\n"); -} - -/* - * opts_print -- - * Print out an option. - */ -static int -opts_print(sp, op) - SCR *sp; - OPTLIST const *op; -{ - int curlen, offset; - - curlen = 0; - offset = op - optlist; - switch (op->type) { - case OPT_0BOOL: - case OPT_1BOOL: - curlen += ex_printf(EXCOOKIE, - "%s%s", O_ISSET(sp, offset) ? "" : "no", op->name); - break; - case OPT_NUM: - curlen += ex_printf(EXCOOKIE, - "%s=%ld", op->name, O_VAL(sp, offset)); - break; - case OPT_STR: - curlen += ex_printf(EXCOOKIE, - "%s=\"%s\"", op->name, O_STR(sp, offset)); - break; - } - return (curlen); -} - -/* - * opts_save -- - * Write the current configuration to a file. - */ -int -opts_save(sp, fp) - SCR *sp; - FILE *fp; -{ - OPTLIST const *op; - int ch, cnt; - char *p; - - for (op = optlist; op->name != NULL; ++op) { - if (F_ISSET(op, OPT_NOSAVE)) - continue; - cnt = op - optlist; - switch (op->type) { - case OPT_0BOOL: - case OPT_1BOOL: - if (O_ISSET(sp, cnt)) - (void)fprintf(fp, "set %s\n", op->name); - else - (void)fprintf(fp, "set no%s\n", op->name); - break; - case OPT_NUM: - (void)fprintf(fp, - "set %s=%-3d\n", op->name, O_VAL(sp, cnt)); - break; - case OPT_STR: - (void)fprintf(fp, "set "); - for (p = op->name; (ch = *p) != '\0'; ++p) { - if (isblank(ch)) - (void)putc('\\', fp); - (void)putc(ch, fp); - } - (void)putc('=', fp); - for (p = O_STR(sp, cnt); (ch = *p) != '\0'; ++p) { - if (isblank(ch)) - (void)putc('\\', fp); - (void)putc(ch, fp); - } - (void)putc('\n', fp); - break; - } - if (ferror(fp)) { - msgq(sp, M_ERR, "I/O error: %s", strerror(errno)); - return (1); - } - } - return (0); -} - -/* - * opts_prefix -- - * Check to see if the name is the prefix of one (and only one) - * option. If so, return the option. - */ -static OPTLIST const * -opts_prefix(name) - char *name; -{ - OPTLIST const *op, *save_op; - size_t len; - - save_op = NULL; - len = strlen(name); - for (op = optlist; op->name != NULL; ++op) { - if (op->name[0] < name[0]) - continue; - if (op->name[0] > name[0]) - break; - if (!memcmp(op->name, name, len)) { - if (save_op != NULL) - return (NULL); - save_op = op; - } - } - return (save_op); -} - -static int -opts_abbcmp(a, b) - const void *a, *b; -{ - return(strcmp(((OABBREV *)a)->name, ((OABBREV *)b)->name)); -} - -static int -opts_cmp(a, b) - const void *a, *b; -{ - return(strcmp(((OPTLIST *)a)->name, ((OPTLIST *)b)->name)); -} - -/* - * opts_free -- - * Free all option strings - */ -void -opts_free(sp) - SCR *sp; -{ - int cnt; - char *p; - - for (cnt = 0; cnt < O_OPTIONCOUNT; ++cnt) - if (F_ISSET(&sp->opts[cnt], OPT_ALLOCATED)) { - p = O_STR(sp, cnt); - FREE(p, strlen(p) + 1); - } -} - -/* - * opts_copy -- - * Copy a screen's OPTION array. - */ -int -opts_copy(orig, sp) - SCR *orig, *sp; -{ - OPTION *op; - int cnt; - - /* Copy most everything without change. */ - memmove(sp->opts, orig->opts, sizeof(orig->opts)); - - /* - * Allocate copies of the strings -- keep trying to reallocate - * after ENOMEM failure, otherwise end up with more than one - * screen referencing the original memory. - */ - for (op = sp->opts, cnt = 0; cnt < O_OPTIONCOUNT; ++cnt, ++op) - if (F_ISSET(&sp->opts[cnt], OPT_ALLOCATED) && - (O_STR(sp, cnt) = strdup(O_STR(sp, cnt))) == NULL) { - msgq(orig, M_SYSERR, NULL); - return (1); - } - return (0); -} diff --git a/usr.bin/vi/options.h.stub b/usr.bin/vi/options.h.stub deleted file mode 100644 index cb2725075b9e..000000000000 --- a/usr.bin/vi/options.h.stub +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)options.h.stub 8.18 (Berkeley) 3/17/94 - */ - -struct _option { - union { - u_long val; /* Value or boolean. */ - char *str; /* String. */ - } o_u; - size_t len; /* String length. */ - -#define OPT_ALLOCATED 0x01 /* Allocated space. */ -#define OPT_SELECTED 0x02 /* Selected for display. */ -#define OPT_SET 0x04 /* Set (display for the user). */ - u_char flags; -}; - -struct _optlist { - char *name; /* Name. */ - /* Change function. */ - int (*func) __P((SCR *, OPTION *, char *, u_long)); - /* Type of object. */ - enum { OPT_0BOOL, OPT_1BOOL, OPT_NUM, OPT_STR } type; - -#define OPT_NEVER 0x01 /* Never display the option. */ -#define OPT_NOSAVE 0x02 /* Mkexrc command doesn't save. */ -#define OPT_NOSTR 0x04 /* String that takes a "no". */ - u_int flags; -}; - -/* Clear, set, test boolean options. */ -#define O_SET(sp, o) (sp)->opts[(o)].o_u.val = 1 -#define O_CLR(sp, o) (sp)->opts[(o)].o_u.val = 0 -#define O_ISSET(sp, o) ((sp)->opts[(o)].o_u.val) - -/* Get option values. */ -#define O_LEN(sp, o) (sp)->opts[(o)].len -#define O_STR(sp, o) (sp)->opts[(o)].o_u.str -#define O_VAL(sp, o) (sp)->opts[(o)].o_u.val - -/* Option routines. */ -enum optdisp { NO_DISPLAY, ALL_DISPLAY, CHANGED_DISPLAY, SELECT_DISPLAY }; - -int opts_copy __P((SCR *, SCR *)); -void opts_dump __P((SCR *, enum optdisp)); -void opts_free __P((SCR *)); -int opts_init __P((SCR *)); -int opts_save __P((SCR *, FILE *)); -int opts_set __P((SCR *, ARGS *[])); - -/* Per-option change routines. */ -int f_altwerase __P((SCR *, OPTION *, char *, u_long)); -int f_cdpath __P((SCR *, OPTION *, char *, u_long)); -int f_columns __P((SCR *, OPTION *, char *, u_long)); -int f_keytime __P((SCR *, OPTION *, char *, u_long)); -int f_leftright __P((SCR *, OPTION *, char *, u_long)); -int f_lines __P((SCR *, OPTION *, char *, u_long)); -int f_lisp __P((SCR *, OPTION *, char *, u_long)); -int f_list __P((SCR *, OPTION *, char *, u_long)); -int f_matchtime __P((SCR *, OPTION *, char *, u_long)); -int f_mesg __P((SCR *, OPTION *, char *, u_long)); -int f_modeline __P((SCR *, OPTION *, char *, u_long)); -int f_number __P((SCR *, OPTION *, char *, u_long)); -int f_paragraph __P((SCR *, OPTION *, char *, u_long)); -int f_readonly __P((SCR *, OPTION *, char *, u_long)); -int f_ruler __P((SCR *, OPTION *, char *, u_long)); -int f_section __P((SCR *, OPTION *, char *, u_long)); -int f_shiftwidth __P((SCR *, OPTION *, char *, u_long)); -int f_sidescroll __P((SCR *, OPTION *, char *, u_long)); -int f_sourceany __P((SCR *, OPTION *, char *, u_long)); -int f_tabstop __P((SCR *, OPTION *, char *, u_long)); -int f_tags __P((SCR *, OPTION *, char *, u_long)); -int f_term __P((SCR *, OPTION *, char *, u_long)); -int f_ttywerase __P((SCR *, OPTION *, char *, u_long)); -int f_w1200 __P((SCR *, OPTION *, char *, u_long)); -int f_w300 __P((SCR *, OPTION *, char *, u_long)); -int f_w9600 __P((SCR *, OPTION *, char *, u_long)); -int f_window __P((SCR *, OPTION *, char *, u_long)); -int f_wrapmargin __P((SCR *, OPTION *, char *, u_long)); diff --git a/usr.bin/vi/options_f.c b/usr.bin/vi/options_f.c deleted file mode 100644 index 87228f2f50ed..000000000000 --- a/usr.bin/vi/options_f.c +++ /dev/null @@ -1,555 +0,0 @@ -/*- - * Copyright (c) 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)options_f.c 8.28 (Berkeley) 3/18/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/stat.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <ctype.h> -#include <errno.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" -#include "tag.h" - -static int opt_dup __P((SCR *, int, char *)); -static int opt_putenv __P((char *)); - -#define DECL(f) \ - int \ - f(sp, op, str, val) \ - SCR *sp; \ - OPTION *op; \ - char *str; \ - u_long val; -#define CALL(f) \ - f(sp, op, str, val) - -#define turnoff val - -DECL(f_altwerase) -{ - if (turnoff) - O_CLR(sp, O_ALTWERASE); - else { - O_SET(sp, O_ALTWERASE); - O_CLR(sp, O_TTYWERASE); - } - return (0); -} - -DECL(f_cdpath) -{ - return (opt_dup(sp, O_CDPATH, str)); -} - -DECL(f_columns) -{ - char buf[25]; - - /* Validate the number. */ - if (val < MINIMUM_SCREEN_COLS) { - msgq(sp, M_ERR, "Screen columns too small, less than %d.", - MINIMUM_SCREEN_COLS); - return (1); - } - if (val < O_VAL(sp, O_SHIFTWIDTH)) { - msgq(sp, M_ERR, - "Screen columns too small, less than shiftwidth."); - return (1); - } - if (val < O_VAL(sp, O_SIDESCROLL)) { - msgq(sp, M_ERR, - "Screen columns too small, less than sidescroll."); - return (1); - } - if (val < O_VAL(sp, O_TABSTOP)) { - msgq(sp, M_ERR, - "Screen columns too small, less than tabstop."); - return (1); - } - if (val < O_VAL(sp, O_WRAPMARGIN)) { - msgq(sp, M_ERR, - "Screen columns too small, less than wrapmargin."); - return (1); - } -#ifdef XXX_NOT_RIGHT - /* - * This has to be checked by reaching down into the screen code. - */ - if (val < O_NUMBER_LENGTH) { - msgq(sp, M_ERR, - "Screen columns too small, less than number option."); - return (1); - } -#endif - /* Set the columns value in the environment for curses. */ - (void)snprintf(buf, sizeof(buf), "COLUMNS=%lu", val); - if (opt_putenv(buf)) - return (1); - - /* This is expensive, don't do it unless it's necessary. */ - if (O_VAL(sp, O_COLUMNS) == val) - return (0); - - /* Set the value. */ - O_VAL(sp, O_COLUMNS) = val; - - F_SET(sp, S_RESIZE); - return (0); -} - -DECL(f_keytime) -{ - O_VAL(sp, O_KEYTIME) = val; - return (0); -} - -DECL(f_leftright) -{ - if (turnoff) - O_CLR(sp, O_LEFTRIGHT); - else - O_SET(sp, O_LEFTRIGHT); - F_SET(sp, S_REFORMAT | S_REDRAW); - return (0); -} - -DECL(f_lines) -{ - char buf[25]; - - /* Validate the number. */ - if (val < MINIMUM_SCREEN_ROWS) { - msgq(sp, M_ERR, "Screen lines too small, less than %d.", - MINIMUM_SCREEN_ROWS); - return (1); - } - - /* Set the rows value in the environment for curses. */ - (void)snprintf(buf, sizeof(buf), "ROWS=%lu", val); - if (opt_putenv(buf)) - return (1); - - /* This is expensive, don't do it unless it's necessary. */ - if (O_VAL(sp, O_LINES) == val) - return (0); - - /* Set the value. */ - O_VAL(sp, O_LINES) = val; - - /* - * If no window value set, set a new default window and, - * optionally, a new scroll value. - */ - if (!F_ISSET(&sp->opts[O_WINDOW], OPT_SET)) { - O_VAL(sp, O_WINDOW) = val - 1; - if (!F_ISSET(&sp->opts[O_SCROLL], OPT_SET)) - O_VAL(sp, O_SCROLL) = val / 2; - } - - F_SET(sp, S_RESIZE); - return (0); -} - -DECL(f_lisp) -{ - msgq(sp, M_ERR, "The lisp option is not implemented."); - return (0); -} - -DECL(f_list) -{ - if (turnoff) - O_CLR(sp, O_LIST); - else - O_SET(sp, O_LIST); - - F_SET(sp, S_REFORMAT | S_REDRAW); - return (0); -} - -DECL(f_matchtime) -{ - O_VAL(sp, O_MATCHTIME) = val; - return (0); -} - -DECL(f_mesg) -{ - struct stat sb; - char *tty; - - /* Find the tty. */ - if ((tty = ttyname(STDERR_FILENO)) == NULL) { - msgq(sp, M_ERR, "ttyname: %s.", strerror(errno)); - return (1); - } - - /* Save the tty mode for later; only save it once. */ - if (!F_ISSET(sp->gp, G_SETMODE)) { - F_SET(sp->gp, G_SETMODE); - if (stat(tty, &sb) < 0) { - msgq(sp, M_ERR, "%s: %s.", tty, strerror(errno)); - return (1); - } - sp->gp->origmode = sb.st_mode; - } - - if (turnoff) { - if (chmod(tty, sp->gp->origmode & ~S_IWGRP) < 0) { - msgq(sp, M_ERR, "messages not turned off: %s: %s.", - tty, strerror(errno)); - return (1); - } - O_CLR(sp, O_MESG); - } else { - if (chmod(tty, sp->gp->origmode | S_IWGRP) < 0) { - msgq(sp, M_ERR, "messages not turned on: %s: %s.", - tty, strerror(errno)); - return (1); - } - O_SET(sp, O_MESG); - } - return (0); -} - -/* - * f_modeline -- - * This has been documented in historical systems as both "modeline" - * and as "modelines". Regardless of the name, this option represents - * a security problem of mammoth proportions, not to mention a stunning - * example of what your intro CS professor referred to as the perils of - * mixing code and data. Don't add it, or I will kill you. - */ -DECL(f_modeline) -{ - if (!turnoff) - msgq(sp, M_ERR, "The modeline(s) option may never be set."); - return (0); -} - -DECL(f_number) -{ - if (turnoff) - O_CLR(sp, O_NUMBER); - else - O_SET(sp, O_NUMBER); - - F_SET(sp, S_REFORMAT | S_REDRAW); - return (0); -} - -DECL(f_paragraph) -{ - if (strlen(str) & 1) { - msgq(sp, M_ERR, - "Paragraph options must be in sets of two characters."); - return (1); - } - return (opt_dup(sp, O_PARAGRAPHS, str)); -} - -DECL(f_readonly) -{ - if (turnoff) { - O_CLR(sp, O_READONLY); - if (sp->frp != NULL) - F_CLR(sp->frp, FR_RDONLY); - } else { - O_SET(sp, O_READONLY); - if (sp->frp != NULL) - F_SET(sp->frp, FR_RDONLY); - } - return (0); -} - -DECL(f_ruler) -{ - if (turnoff) - O_CLR(sp, O_RULER); - else - O_SET(sp, O_RULER); - return (0); -} - -DECL(f_section) -{ - if (strlen(str) & 1) { - msgq(sp, M_ERR, - "Section options must be in sets of two characters."); - return (1); - } - return (opt_dup(sp, O_SECTIONS, str)); -} - -DECL(f_shiftwidth) -{ - if (val == 0) { - msgq(sp, M_ERR, "The shiftwidth can't be set to 0."); - return (1); - } - if (val > O_VAL(sp, O_COLUMNS)) { - msgq(sp, M_ERR, - "Shiftwidth can't be larger than screen size."); - return (1); - } - O_VAL(sp, O_SHIFTWIDTH) = val; - return (0); -} - -DECL(f_sidescroll) -{ - if (val > O_VAL(sp, O_COLUMNS)) { - msgq(sp, M_ERR, - "Sidescroll can't be larger than screen size."); - return (1); - } - O_VAL(sp, O_SIDESCROLL) = val; - return (0); -} - -/* - * f_sourceany -- - * Historic vi, on startup, source'd $HOME/.exrc and ./.exrc, if they - * were owned by the user. The sourceany option was an undocumented - * feature of historic vi which permitted the startup source'ing of - * .exrc files the user didn't own. This is an obvious security problem, - * and we ignore the option. - */ -DECL(f_sourceany) -{ - if (!turnoff) - msgq(sp, M_ERR, "The sourceany option may never be set."); - return (0); -} - -DECL(f_tabstop) -{ - if (val == 0) { - msgq(sp, M_ERR, "Tab stops can't be set to 0."); - return (1); - } -#define MAXTABSTOP 20 - if (val > MAXTABSTOP) { - msgq(sp, M_ERR, - "Tab stops can't be larger than %d.", MAXTABSTOP); - return (1); - } - if (val > O_VAL(sp, O_COLUMNS)) { - msgq(sp, M_ERR, - "Tab stops can't be larger than screen size.", - MAXTABSTOP); - return (1); - } - O_VAL(sp, O_TABSTOP) = val; - - F_SET(sp, S_REFORMAT | S_REDRAW); - return (0); -} - -DECL(f_tags) -{ - return (opt_dup(sp, O_TAGS, str)); -} - -DECL(f_term) -{ - char buf[256]; - - if (opt_dup(sp, O_TERM, str)) - return (1); - - /* Set the terminal value in the environment for curses. */ - (void)snprintf(buf, sizeof(buf), "TERM=%s", str); - if (opt_putenv(buf)) - return (1); - - if (set_window_size(sp, 0, 0)) - return (1); - return (0); -} - -DECL(f_ttywerase) -{ - if (turnoff) - O_CLR(sp, O_TTYWERASE); - else { - O_SET(sp, O_TTYWERASE); - O_CLR(sp, O_ALTWERASE); - } - return (0); -} - -DECL(f_w300) -{ - /* Historical behavior for w300 was < 1200. */ - if (baud_from_bval(sp) >= 1200) - return (0); - - if (CALL(f_window)) - return (1); - - if (val > O_VAL(sp, O_LINES) - 1) - val = O_VAL(sp, O_LINES) - 1; - O_VAL(sp, O_W300) = val; - return (0); -} - -DECL(f_w1200) -{ - u_long v; - - /* Historical behavior for w1200 was == 1200. */ - v = baud_from_bval(sp); - if (v < 1200 || v > 4800) - return (0); - - if (CALL(f_window)) - return (1); - - if (val > O_VAL(sp, O_LINES) - 1) - val = O_VAL(sp, O_LINES) - 1; - O_VAL(sp, O_W1200) = val; - return (0); -} - -DECL(f_w9600) -{ - speed_t v; - - /* Historical behavior for w9600 was > 1200. */ - v = baud_from_bval(sp); - if (v <= 4800) - return (0); - - if (CALL(f_window)) - return (1); - - if (val > O_VAL(sp, O_LINES) - 1) - val = O_VAL(sp, O_LINES) - 1; - O_VAL(sp, O_W9600) = val; - return (0); -} - -DECL(f_window) -{ - if (val < MINIMUM_SCREEN_ROWS) { - msgq(sp, M_ERR, "Window too small, less than %d.", - MINIMUM_SCREEN_ROWS); - return (1); - } - if (val > O_VAL(sp, O_LINES) - 1) - val = O_VAL(sp, O_LINES) - 1; - O_VAL(sp, O_WINDOW) = val; - O_VAL(sp, O_SCROLL) = val / 2; - - return (0); -} - -DECL(f_wrapmargin) -{ - if (val > O_VAL(sp, O_COLUMNS)) { - msgq(sp, M_ERR, - "Wrapmargin value can't be larger than screen size."); - return (1); - } - O_VAL(sp, O_WRAPMARGIN) = val; - return (0); -} - -/* - * opt_dup -- - * Copy a string value for user display. - */ -static int -opt_dup(sp, opt, str) - SCR *sp; - int opt; - char *str; -{ - char *p; - - /* Copy for user display. */ - if ((p = strdup(str)) == NULL) { - msgq(sp, M_SYSERR, NULL); - return (1); - } - - /* Free the old contents. */ - if (F_ISSET(&sp->opts[opt], OPT_ALLOCATED)) - free(O_STR(sp, opt)); - - /* Note that it's set and allocated. */ - F_SET(&sp->opts[opt], OPT_ALLOCATED | OPT_SET); - - /* Assign new contents. */ - O_STR(sp, opt) = p; - return (0); -} - -/* - * opt_putenv -- - * Put a value into the environment. We use putenv(3) because it's - * more portable. The following hack is because some moron decided - * to keep a reference to the memory passed to putenv(3), instead of - * having it allocate its own. Someone clearly needs to get promoted - * into management. - */ -static int -opt_putenv(s) - char *s; -{ - char *t; - - /* Memory leak. */ - if ((t = strdup(s)) == NULL) - return (1); - return (putenv(t)); -} diff --git a/usr.bin/vi/pathnames.h b/usr.bin/vi/pathnames.h deleted file mode 100644 index c6e6906dc63a..000000000000 --- a/usr.bin/vi/pathnames.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.6 (Berkeley) 3/16/94 - */ - -#define _PATH_BSHELL "/bin/sh" -#define _PATH_DEVNULL "/dev/null" -#define _PATH_EXRC ".exrc" -#define _PATH_NEXRC ".nexrc" -#define _PATH_PRESERVE "/var/tmp/vi.recover" -#define _PATH_SENDMAIL "/usr/sbin/sendmail" -#define _PATH_SYSEXRC "/etc/vi.exrc" -#define _PATH_TAGS "tags /var/db/libc.tags /sys/kern/tags" -#define _PATH_TMP "/tmp" -#define _PATH_TTY "/dev/tty" diff --git a/usr.bin/vi/put.c b/usr.bin/vi/put.c deleted file mode 100644 index aebefa6fd73a..000000000000 --- a/usr.bin/vi/put.c +++ /dev/null @@ -1,249 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)put.c 8.3 (Berkeley) 3/14/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <ctype.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" - -/* - * put -- - * Put text buffer contents into the file. - * - * !!! - * Historically, pasting into a file with no lines in vi would preserve - * the single blank line. This is almost certainly a result of the fact - * that historic vi couldn't deal with a file that had no lines in it. - * This implementation treats that as a bug, and does not retain the blank - * line. - */ -int -put(sp, ep, cbp, namep, cp, rp, append) - SCR *sp; - EXF *ep; - CB *cbp; - CHAR_T *namep; - MARK *cp, *rp; - int append; -{ - CHAR_T name; - TEXT *ltp, *tp; - recno_t lno; - size_t blen, clen, len; - char *bp, *p, *t; - - if (cbp == NULL) - if (namep == NULL) { - cbp = sp->gp->dcbp; - if (cbp == NULL) { - msgq(sp, M_ERR, "The default buffer is empty."); - return (1); - } - } else { - name = *namep; - CBNAME(sp, cbp, name); - if (cbp == NULL) { - msgq(sp, M_ERR, - "Buffer %s is empty.", charname(sp, name)); - return (1); - } - } - tp = cbp->textq.cqh_first; - - /* - * It's possible to do a put into an empty file, meaning that the - * cut buffer simply becomes the file. It's a special case so - * that we can ignore it in general. - * - * Historical practice is that the cursor ends up on the first - * non-blank character of the first line inserted. - */ - if (cp->lno == 1) { - if (file_lline(sp, ep, &lno)) - return (1); - if (lno == 0) { - for (; tp != (void *)&cbp->textq; - ++lno, tp = tp->q.cqe_next) - if (file_aline(sp, ep, 1, lno, tp->lb, tp->len)) - return (1); - rp->lno = 1; - rp->cno = 0; - (void)nonblank(sp, ep, rp->lno, &rp->cno); - goto ret; - } - } - - /* If a line mode buffer, append each new line into the file. */ - if (F_ISSET(cbp, CB_LMODE)) { - lno = append ? cp->lno : cp->lno - 1; - rp->lno = lno + 1; - for (; tp != (void *)&cbp->textq; ++lno, tp = tp->q.cqe_next) - if (file_aline(sp, ep, 1, lno, tp->lb, tp->len)) - return (1); - rp->cno = 0; - (void)nonblank(sp, ep, rp->lno, &rp->cno); - goto ret; - } - - /* - * If buffer was cut in character mode, replace the current line with - * one built from the portion of the first line to the left of the - * split plus the first line in the CB. Append each intermediate line - * in the CB. Append a line built from the portion of the first line - * to the right of the split plus the last line in the CB. - * - * Get the first line. - */ - lno = cp->lno; - if ((p = file_gline(sp, ep, lno, &len)) == NULL) { - GETLINE_ERR(sp, lno); - return (1); - } - - GET_SPACE_RET(sp, bp, blen, tp->len + len + 1); - t = bp; - - /* Original line, left of the split. */ - if (len > 0 && (clen = cp->cno + (append ? 1 : 0)) > 0) { - memmove(bp, p, clen); - p += clen; - t += clen; - } - - /* First line from the CB. */ - memmove(t, tp->lb, tp->len); - t += tp->len; - - /* Calculate length left in original line. */ - clen = len ? len - cp->cno - (append ? 1 : 0) : 0; - - /* - * If no more lines in the CB, append the rest of the original - * line and quit. Otherwise, build the last line before doing - * the intermediate lines, because the line changes will lose - * the cached line. - */ - if (tp->q.cqe_next == (void *)&cbp->textq) { - /* - * Historical practice is that if a non-line mode put - * is inside a single line, the cursor ends up on the - * last character inserted. - */ - rp->lno = lno; - rp->cno = (t - bp) - 1; - - if (clen > 0) { - memmove(t, p, clen); - t += clen; - } - if (file_sline(sp, ep, lno, bp, t - bp)) - goto mem; - } else { - /* - * Have to build both the first and last lines of the - * put before doing any sets or we'll lose the cached - * line. Build both the first and last lines in the - * same buffer, so we don't have to have another buffer - * floating around. - * - * Last part of original line; check for space, reset - * the pointer into the buffer. - */ - ltp = cbp->textq.cqh_last; - len = t - bp; - ADD_SPACE_RET(sp, bp, blen, ltp->len + clen); - t = bp + len; - - /* Add in last part of the CB. */ - memmove(t, ltp->lb, ltp->len); - if (clen) - memmove(t + ltp->len, p, clen); - clen += ltp->len; - - /* - * Now: bp points to the first character of the first - * line, t points to the last character of the last - * line, t - bp is the length of the first line, and - * clen is the length of the last. Just figured you'd - * want to know. - * - * Output the line replacing the original line. - */ - if (file_sline(sp, ep, lno, bp, t - bp)) - goto mem; - - /* - * Historical practice is that if a non-line mode put - * covers multiple lines, the cursor ends up on the - * first character inserted. (Of course.) - */ - rp->lno = lno; - rp->cno = (t - bp) - 1; - - /* Output any intermediate lines in the CB. */ - for (tp = tp->q.cqe_next; - tp->q.cqe_next != (void *)&cbp->textq; - ++lno, tp = tp->q.cqe_next) - if (file_aline(sp, ep, 1, lno, tp->lb, tp->len)) - goto mem; - - if (file_aline(sp, ep, 1, lno, t, clen)) { -mem: FREE_SPACE(sp, bp, blen); - return (1); - } - } - FREE_SPACE(sp, bp, blen); - - /* Reporting... */ -ret: sp->rptlines[L_PUT] += lno - cp->lno; - - return (0); -} diff --git a/usr.bin/vi/recover.c b/usr.bin/vi/recover.c deleted file mode 100644 index 86cb33228204..000000000000 --- a/usr.bin/vi/recover.c +++ /dev/null @@ -1,623 +0,0 @@ -/*- - * Copyright (c) 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)recover.c 8.50 (Berkeley) 3/23/94"; -#endif /* not lint */ - -#include <sys/param.h> -#include <sys/queue.h> -#include <sys/stat.h> -#include <sys/time.h> - -/* - * We include <sys/file.h>, because the flock(2) #defines were - * found there on historical systems. We also include <fcntl.h> - * because the open(2) #defines are found there on newer systems. - */ -#include <sys/file.h> - -#include <netdb.h> /* MAXHOSTNAMELEN on some systems. */ - -#include <bitstring.h> -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <limits.h> -#include <pwd.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> -#include <pathnames.h> - -#include "vi.h" - -/* - * Recovery code. - * - * The basic scheme is there's a btree file, whose name we specify. The first - * time a file is modified, and then at RCV_PERIOD intervals after that, the - * btree file is synced to disk. Each time a keystroke is requested for a file - * the terminal routines check to see if the file needs to be synced. This, of - * course means that the data structures had better be consistent each time the - * key routines are called. - * - * We don't use timers other than to flag that the file should be synced. This - * would require that the SCR and EXF data structures be locked, the dbopen(3) - * routines lock out the timers for each update, etc. It's just not worth it. - * The only way we can lose in the current scheme is if the file is saved, then - * the user types furiously for RCV_PERIOD - 1 seconds, and types nothing more. - * Not likely. - * - * When a file is first modified, a file which can be handed off to the mailer - * is created. The file contains normal headers, with two additions, which - * occur in THIS order, as the FIRST TWO headers: - * - * Vi-recover-file: file_name - * Vi-recover-path: recover_path - * - * Since newlines delimit the headers, this means that file names cannot - * have newlines in them, but that's probably okay. - * - * Btree files are named "vi.XXXX" and recovery files are named "recover.XXXX". - */ - -#define VI_FHEADER "Vi-recover-file: " -#define VI_PHEADER "Vi-recover-path: " - -static int rcv_mailfile __P((SCR *, EXF *)); -static void rcv_syncit __P((SCR *, int)); - -/* - * rcv_tmp -- - * Build a file name that will be used as the recovery file. - */ -int -rcv_tmp(sp, ep, name) - SCR *sp; - EXF *ep; - char *name; -{ - struct stat sb; - int fd; - char *dp, *p, path[MAXPATHLEN]; - - /* - * If the recovery directory doesn't exist, try and create it. As - * the recovery files are themselves protected from reading/writing - * by other than the owner, the worst that can happen is that a user - * would have permission to remove other users recovery files. If - * the sticky bit has the BSD semantics, that too will be impossible. - */ - dp = O_STR(sp, O_RECDIR); - if (stat(dp, &sb)) { - if (errno != ENOENT || mkdir(dp, 0)) { - msgq(sp, M_ERR, "Error: %s: %s", dp, strerror(errno)); - return (1); - } - (void)chmod(dp, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX); - } - - /* Newlines delimit the mail messages. */ - for (p = name; *p; ++p) - if (*p == '\n') { - msgq(sp, M_ERR, - "Files with newlines in the name are unrecoverable."); - return (1); - } - - (void)snprintf(path, sizeof(path), "%s/vi.XXXXXX", dp); - - /* - * !!! - * We depend on mkstemp(3) setting the permissions correctly. - * GP's, we do it ourselves, to keep the window as small as - * possible. - */ - if ((fd = mkstemp(path)) == -1) { - msgq(sp, M_ERR, "Error: %s: %s", dp, strerror(errno)); - return (1); - } - (void)chmod(path, S_IRUSR | S_IWUSR); - (void)close(fd); - - if ((ep->rcv_path = strdup(path)) == NULL) { - msgq(sp, M_SYSERR, NULL); - (void)unlink(path); - return (1); - } - - /* We believe the file is recoverable. */ - F_SET(ep, F_RCV_ON); - return (0); -} - -/* - * rcv_init -- - * Force the file to be snapshotted for recovery. - */ -int -rcv_init(sp, ep) - SCR *sp; - EXF *ep; -{ - recno_t lno; - int btear; - - F_CLR(ep, F_FIRSTMODIFY | F_RCV_ON); - - /* - * If not already recoverying a file, build a file to mail - * to the user. - */ - if (ep->rcv_mpath == NULL && rcv_mailfile(sp, ep)) - goto err; - - /* Force read of entire file. */ - if (file_lline(sp, ep, &lno)) - goto err; - - /* Turn on a busy message, and sync it to backing store. */ - - btear = F_ISSET(sp, S_EXSILENT) ? 0 : - !busy_on(sp, "Copying file for recovery..."); - if (ep->db->sync(ep->db, R_RECNOSYNC)) { - msgq(sp, M_ERR, "Preservation failed: %s: %s", - ep->rcv_path, strerror(errno)); - if (btear) - busy_off(sp); - goto err; - } - if (btear) - busy_off(sp); - - if (!F_ISSET(sp->gp, G_RECOVER_SET) && rcv_on(sp, ep)) { -err: msgq(sp, M_ERR, "Recovery after system crash not possible."); - return (1); - } - - /* We believe the file is recoverable. */ - F_SET(ep, F_RCV_ON); - return (0); -} - -/* - * rcv_mailfile -- - * Build the file to mail to the user. - */ -static int -rcv_mailfile(sp, ep) - SCR *sp; - EXF *ep; -{ - struct passwd *pw; - uid_t uid; - FILE *fp; - time_t now; - int fd; - char *p, *t, host[MAXHOSTNAMELEN], path[MAXPATHLEN]; - - if ((pw = getpwuid(uid = getuid())) == NULL) { - msgq(sp, M_ERR, "Information on user id %u not found.", uid); - return (1); - } - - (void)snprintf(path, sizeof(path), - "%s/recover.XXXXXX", O_STR(sp, O_RECDIR)); - if ((fd = mkstemp(path)) == -1 || (fp = fdopen(fd, "w")) == NULL) { - msgq(sp, M_ERR, - "Error: %s: %s", O_STR(sp, O_RECDIR), strerror(errno)); - if (fd != -1) - (void)close(fd); - return (1); - } - - /* - * We keep an open lock on the file so that the recover option can - * distinguish between files that are live and those that need to - * be recovered. There's an obvious window between the mkstemp call - * and the lock, but it's pretty small. - */ - if ((ep->rcv_fd = dup(fd)) == -1 || - flock(ep->rcv_fd, LOCK_EX | LOCK_NB)) - msgq(sp, M_SYSERR, "Unable to lock recovery file"); - - if ((ep->rcv_mpath = strdup(path)) == NULL) { - msgq(sp, M_SYSERR, NULL); - (void)fclose(fp); - return (1); - } - - t = FILENAME(sp->frp); - if ((p = strrchr(t, '/')) == NULL) - p = t; - else - ++p; - (void)time(&now); - (void)gethostname(host, sizeof(host)); - (void)fprintf(fp, "%s%s\n%s%s\n%s\n%s\n%s%s\n%s%s\n%s\n\n", - VI_FHEADER, p, /* Non-standard. */ - VI_PHEADER, ep->rcv_path, /* Non-standard. */ - "Reply-To: root", - "From: root (Nvi recovery program)", - "To: ", pw->pw_name, - "Subject: Nvi saved the file ", p, - "Precedence: bulk"); /* For vacation(1). */ - (void)fprintf(fp, "%s%.24s%s%s\n%s%s", - "On ", ctime(&now), - ", the user ", pw->pw_name, - "was editing a file named ", p); - if (p != t) - (void)fprintf(fp, " (%s)", t); - (void)fprintf(fp, "\n%s%s%s\n", - "on the machine ", host, ", when it was saved for\nrecovery."); - (void)fprintf(fp, "\n%s\n%s\n%s\n\n", - "You can recover most, if not all, of the changes", - "to this file using the -l and -r options to nvi(1)", - "or nex(1)."); - - if (fflush(fp) || ferror(fp)) { - msgq(sp, M_SYSERR, NULL); - (void)fclose(fp); - return (1); - } - (void)fclose(fp); - return (0); -} - -/* - * rcv_sync -- - * Sync the backing file. - */ -int -rcv_sync(sp, ep) - SCR *sp; - EXF *ep; -{ - if (ep->db->sync(ep->db, R_RECNOSYNC)) { - F_CLR(ep, F_RCV_ON); - msgq(sp, M_ERR, "Automatic file backup failed: %s: %s", - ep->rcv_path, strerror(errno)); - return (1); - } - return (0); -} - -/* - * rcv_hup -- - * Recovery SIGHUP interrupt handler. (Modem line dropped, or - * xterm window closed.) - */ -void -rcv_hup() -{ - SCR *sp; - - /* - * Walk the lists of screens, sync'ing the files; only sync - * each file once. Send email to the user for each file saved. - */ - for (sp = __global_list->dq.cqh_first; - sp != (void *)&__global_list->dq; sp = sp->q.cqe_next) - rcv_syncit(sp, 1); - for (sp = __global_list->hq.cqh_first; - sp != (void *)&__global_list->hq; sp = sp->q.cqe_next) - rcv_syncit(sp, 1); - - /* - * Die with the proper exit status. Don't bother using - * sigaction(2) 'cause we want the default behavior. - */ - (void)signal(SIGHUP, SIG_DFL); - (void)kill(0, SIGHUP); - - /* NOTREACHED */ - exit (1); -} - -/* - * rcv_term -- - * Recovery SIGTERM interrupt handler. (Reboot or halt is running.) - */ -void -rcv_term() -{ - SCR *sp; - - /* - * Walk the lists of screens, sync'ing the files; only sync - * each file once. - */ - for (sp = __global_list->dq.cqh_first; - sp != (void *)&__global_list->dq; sp = sp->q.cqe_next) - rcv_syncit(sp, 0); - for (sp = __global_list->hq.cqh_first; - sp != (void *)&__global_list->hq; sp = sp->q.cqe_next) - rcv_syncit(sp, 0); - - /* - * Die with the proper exit status. Don't bother using - * sigaction(2) 'cause we want the default behavior. - */ - (void)signal(SIGTERM, SIG_DFL); - (void)kill(0, SIGTERM); - - /* NOTREACHED */ - exit (1); -} - -/* - * rcv_syncit -- - * Sync the file, optionally send mail. - */ -static void -rcv_syncit(sp, email) - SCR *sp; - int email; -{ - EXF *ep; - char comm[1024]; - - if ((ep = sp->ep) == NULL || - !F_ISSET(ep, F_MODIFIED) || !F_ISSET(ep, F_RCV_ON)) - return; - - (void)ep->db->sync(ep->db, R_RECNOSYNC); - F_SET(ep, F_RCV_NORM); - - /* - * !!! - * If you need to port this to a system that doesn't have sendmail, - * the -t flag being used causes sendmail to read the message for - * the recipients instead of us specifying them some other way. - */ - if (email) { - (void)snprintf(comm, sizeof(comm), - "%s -t < %s", _PATH_SENDMAIL, ep->rcv_mpath); - (void)system(comm); - } - (void)file_end(sp, ep, 1); -} - -/* - * people making love - * never exactly the same - * just like a snowflake - * - * rcv_list -- - * List the files that can be recovered by this user. - */ -int -rcv_list(sp) - SCR *sp; -{ - struct dirent *dp; - struct stat sb; - DIR *dirp; - FILE *fp; - int found; - char *p, file[1024]; - - if (chdir(O_STR(sp, O_RECDIR)) || (dirp = opendir(".")) == NULL) { - (void)fprintf(stderr, - "vi: %s: %s\n", O_STR(sp, O_RECDIR), strerror(errno)); - return (1); - } - - for (found = 0; (dp = readdir(dirp)) != NULL;) { - if (strncmp(dp->d_name, "recover.", 8)) - continue; - - /* If it's readable, it's recoverable. */ - if ((fp = fopen(dp->d_name, "r")) == NULL) - continue; - - /* If it's locked, it's live. */ - if (flock(fileno(fp), LOCK_EX | LOCK_NB)) { - (void)fclose(fp); - continue; - } - - /* Check the header, get the file name. */ - if (fgets(file, sizeof(file), fp) == NULL || - strncmp(file, VI_FHEADER, sizeof(VI_FHEADER) - 1) || - (p = strchr(file, '\n')) == NULL) { - (void)fprintf(stderr, - "vi: %s: malformed recovery file.\n", dp->d_name); - goto next; - } - *p = '\0'; - - /* Get the last modification time. */ - if (fstat(fileno(fp), &sb)) { - (void)fprintf(stderr, - "vi: %s: %s\n", dp->d_name, strerror(errno)); - goto next; - } - - /* Display. */ - (void)printf("%s: %s", - file + sizeof(VI_FHEADER) - 1, ctime(&sb.st_mtime)); - found = 1; - -next: (void)fclose(fp); - } - if (found == 0) - (void)printf("vi: no files to recover.\n"); - (void)closedir(dirp); - return (0); -} - -/* - * rcv_read -- - * Start a recovered file as the file to edit. - */ -int -rcv_read(sp, name) - SCR *sp; - char *name; -{ - struct dirent *dp; - struct stat sb; - DIR *dirp; - FREF *frp; - FILE *fp, *sv_fp; - time_t rec_mtime; - int found, requested; - char *p, *t, *recp, *pathp; - char recpath[MAXPATHLEN], file[MAXPATHLEN], path[MAXPATHLEN]; - - if ((dirp = opendir(O_STR(sp, O_RECDIR))) == NULL) { - msgq(sp, M_ERR, - "%s: %s", O_STR(sp, O_RECDIR), strerror(errno)); - return (1); - } - - sv_fp = NULL; - rec_mtime = 0; - recp = pathp = NULL; - for (found = requested = 0; (dp = readdir(dirp)) != NULL;) { - if (strncmp(dp->d_name, "recover.", 8)) - continue; - - /* If it's readable, it's recoverable. */ - (void)snprintf(recpath, sizeof(recpath), - "%s/%s", O_STR(sp, O_RECDIR), dp->d_name); - if ((fp = fopen(recpath, "r")) == NULL) - continue; - - /* If it's locked, it's live. */ - if (flock(fileno(fp), LOCK_EX | LOCK_NB)) { - (void)fclose(fp); - continue; - } - - /* Check the headers. */ - if (fgets(file, sizeof(file), fp) == NULL || - strncmp(file, VI_FHEADER, sizeof(VI_FHEADER) - 1) || - (p = strchr(file, '\n')) == NULL || - fgets(path, sizeof(path), fp) == NULL || - strncmp(path, VI_PHEADER, sizeof(VI_PHEADER) - 1) || - (t = strchr(path, '\n')) == NULL) { - msgq(sp, M_ERR, - "%s: malformed recovery file.", recpath); - goto next; - } - ++found; - *t = *p = '\0'; - - /* Get the last modification time. */ - if (fstat(fileno(fp), &sb)) { - msgq(sp, M_ERR, - "vi: %s: %s", dp->d_name, strerror(errno)); - goto next; - } - - /* Check the file name. */ - if (strcmp(file + sizeof(VI_FHEADER) - 1, name)) - goto next; - - ++requested; - - /* If we've found more than one, take the most recent. */ - if (recp == NULL || rec_mtime < sb.st_mtime) { - p = recp; - t = pathp; - if ((recp = strdup(recpath)) == NULL) { - msgq(sp, M_ERR, - "vi: Error: %s.\n", strerror(errno)); - recp = p; - goto next; - } - if ((pathp = strdup(path)) == NULL) { - msgq(sp, M_ERR, - "vi: Error: %s.\n", strerror(errno)); - FREE(recp, strlen(recp) + 1); - recp = p; - pathp = t; - goto next; - } - if (p != NULL) { - FREE(p, strlen(p) + 1); - FREE(t, strlen(t) + 1); - } - rec_mtime = sb.st_mtime; - if (sv_fp != NULL) - (void)fclose(sv_fp); - sv_fp = fp; - } else -next: (void)fclose(fp); - } - (void)closedir(dirp); - - if (recp == NULL) { - msgq(sp, M_INFO, - "No files named %s, owned by you, to edit.", name); - return (1); - } - if (found) { - if (requested > 1) - msgq(sp, M_INFO, - "There are older versions of this file for you to recover."); - if (found > requested) - msgq(sp, M_INFO, - "There are other files for you to recover."); - } - - /* Create the FREF structure, start the btree file. */ - if ((frp = file_add(sp, NULL, name, 0)) == NULL || - file_init(sp, frp, pathp + sizeof(VI_PHEADER) - 1, 0)) { - FREE(recp, strlen(recp) + 1); - FREE(pathp, strlen(pathp) + 1); - (void)fclose(sv_fp); - return (1); - } - - /* - * We keep an open lock on the file so that the recover option can - * distinguish between files that are live and those that need to - * be recovered. The lock is already acquired, so just get a copy. - */ - if ((sp->ep->rcv_fd = dup(fileno(sv_fp))) != -1) - (void)fclose(sv_fp); - - sp->ep->rcv_mpath = recp; - return (0); -} diff --git a/usr.bin/vi/screen.c b/usr.bin/vi/screen.c deleted file mode 100644 index dd3782b73349..000000000000 --- a/usr.bin/vi/screen.c +++ /dev/null @@ -1,304 +0,0 @@ -/*- - * Copyright (c) 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)screen.c 8.56 (Berkeley) 3/14/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <errno.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" -#include "vcmd.h" -#include "excmd.h" -#include "tag.h" - -/* - * screen_init -- - * Do the default initialization of an SCR structure. - */ -int -screen_init(orig, spp, flags) - SCR *orig, **spp; - u_int flags; -{ - SCR *sp; - size_t len; - - *spp = NULL; - CALLOC_RET(orig, sp, SCR *, 1, sizeof(SCR)); - *spp = sp; - -/* INITIALIZED AT SCREEN CREATE. */ - sp->gp = __global_list; /* All ref the GS structure. */ - - LIST_INIT(&sp->msgq); - CIRCLEQ_INIT(&sp->frefq); - - sp->ccnt = 2; /* Anything > 1 */ - - FD_ZERO(&sp->rdfd); - - CIRCLEQ_INIT(&sp->tiq); - -/* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */ - if (orig == NULL) { - sp->searchdir = NOTSET; - - switch (flags & S_SCREENS) { - case S_EX: - if (sex_screen_init(sp)) - return (1); - break; - case S_VI_CURSES: - if (svi_screen_init(sp)) - return (1); - break; - case S_VI_XAW: - if (xaw_screen_init(sp)) - return (1); - break; - default: - abort(); - } - - sp->flags = flags; - } else { - if (orig->alt_name != NULL && - (sp->alt_name = strdup(orig->alt_name)) == NULL) - goto mem; - - /* Retain all searching/substitution information. */ - if (F_ISSET(orig, S_SRE_SET)) { - F_SET(sp, S_SRE_SET); - sp->sre = orig->sre; - } - if (F_ISSET(orig, S_SUBRE_SET)) { - F_SET(sp, S_SUBRE_SET); - sp->subre = orig->subre; - } - sp->searchdir = orig->searchdir == NOTSET ? NOTSET : FORWARD; - - if (orig->matchsize) { - len = orig->matchsize * sizeof(regmatch_t); - MALLOC(sp, sp->match, regmatch_t *, len); - if (sp->match == NULL) - goto mem; - sp->matchsize = orig->matchsize; - memmove(sp->match, orig->match, len); - } - if (orig->repl_len) { - MALLOC(sp, sp->repl, char *, orig->repl_len); - if (sp->repl == NULL) - goto mem; - sp->repl_len = orig->repl_len; - memmove(sp->repl, orig->repl, orig->repl_len); - } - if (orig->newl_len) { - len = orig->newl_len * sizeof(size_t); - MALLOC(sp, sp->newl, size_t *, len); - if (sp->newl == NULL) - goto mem; - sp->newl_len = orig->newl_len; - sp->newl_cnt = orig->newl_cnt; - memmove(sp->newl, orig->newl, len); - } - - sp->saved_vi_mode = orig->saved_vi_mode; - - if (opts_copy(orig, sp)) { -mem: msgq(orig, M_SYSERR, "new screen attributes"); - (void)screen_end(sp); - return (1); - } - - sp->s_bell = orig->s_bell; - sp->s_bg = orig->s_bg; - sp->s_busy = orig->s_busy; - sp->s_change = orig->s_change; - sp->s_clear = orig->s_clear; - sp->s_colpos = orig->s_colpos; - sp->s_column = orig->s_column; - sp->s_confirm = orig->s_confirm; - sp->s_crel = orig->s_crel; - sp->s_down = orig->s_down; - sp->s_edit = orig->s_edit; - sp->s_end = orig->s_end; - sp->s_ex_cmd = orig->s_ex_cmd; - sp->s_ex_run = orig->s_ex_run; - sp->s_ex_write = orig->s_ex_write; - sp->s_fg = orig->s_fg; - sp->s_fill = orig->s_fill; - sp->s_get = orig->s_get; - sp->s_key_read = orig->s_key_read; - sp->s_optchange = orig->s_optchange; - sp->s_position = orig->s_position; - sp->s_rabs = orig->s_rabs; - sp->s_rcm = orig->s_rcm; - sp->s_refresh = orig->s_refresh; - sp->s_split = orig->s_split; - sp->s_suspend = orig->s_suspend; - sp->s_up = orig->s_up; - - F_SET(sp, F_ISSET(orig, S_SCREENS)); - } - - if (xaw_screen_copy(orig, sp)) /* Init S_VI_XAW screen. */ - return (1); - if (svi_screen_copy(orig, sp)) /* Init S_VI_CURSES screen. */ - return (1); - if (sex_screen_copy(orig, sp)) /* Init S_EX screen. */ - return (1); - if (v_screen_copy(orig, sp)) /* Init vi. */ - return (1); - if (ex_screen_copy(orig, sp)) /* Init ex. */ - return (1); - - *spp = sp; - return (0); -} - -/* - * screen_end -- - * Release a screen. - */ -int -screen_end(sp) - SCR *sp; -{ - int rval; - - rval = 0; - if (xaw_screen_end(sp)) /* End S_VI_XAW screen. */ - rval = 1; - if (svi_screen_end(sp)) /* End S_VI_CURSES screen. */ - rval = 1; - if (sex_screen_end(sp)) /* End S_EX screen. */ - rval = 1; - if (v_screen_end(sp)) /* End vi. */ - rval = 1; - if (ex_screen_end(sp)) /* End ex. */ - rval = 1; - - /* Free FREF's. */ - { FREF *frp; - while ((frp = sp->frefq.cqh_first) != (FREF *)&sp->frefq) { - CIRCLEQ_REMOVE(&sp->frefq, frp, q); - if (frp->cname != NULL) - free(frp->cname); - if (frp->name != NULL) - free(frp->name); - if (frp->tname != NULL) - free(frp->tname); - FREE(frp, sizeof(FREF)); - } - } - - /* Free any text input. */ - text_lfree(&sp->tiq); - - /* Free any script information. */ - if (F_ISSET(sp, S_SCRIPT)) - sscr_end(sp); - - /* Free alternate file name. */ - if (sp->alt_name != NULL) - FREE(sp->alt_name, strlen(sp->alt_name) + 1); - - /* Free up search information. */ - if (sp->match != NULL) - FREE(sp->match, sizeof(regmatch_t)); - if (sp->repl != NULL) - FREE(sp->repl, sp->repl_len); - if (sp->newl != NULL) - FREE(sp->newl, sp->newl_len); - - /* Free all the options */ - opts_free(sp); - - /* - * Free the message chain last, so previous failures have a place - * to put messages. Copy messages to (in order) a related screen, - * any screen, the global area. - */ - { SCR *c_sp; MSG *mp, *next; - if ((c_sp = sp->q.cqe_prev) != (void *)&sp->gp->dq) { - if (F_ISSET(sp, S_BELLSCHED)) - F_SET(c_sp, S_BELLSCHED); - } else if ((c_sp = sp->q.cqe_next) != (void *)&sp->gp->dq) { - if (F_ISSET(sp, S_BELLSCHED)) - F_SET(c_sp, S_BELLSCHED); - } else if ((c_sp = - sp->gp->hq.cqh_first) != (void *)&sp->gp->hq) { - if (F_ISSET(sp, S_BELLSCHED)) - F_SET(c_sp, S_BELLSCHED); - } else { - c_sp = NULL; - if (F_ISSET(sp, S_BELLSCHED)) - F_SET(sp->gp, G_BELLSCHED); - } - - for (mp = sp->msgq.lh_first; mp != NULL; mp = next) { - if (!F_ISSET(mp, M_EMPTY)) - msg_app(sp->gp, c_sp, - mp->flags & M_INV_VIDEO, mp->mbuf, mp->len); - next = mp->q.le_next; - if (mp->mbuf != NULL) - FREE(mp->mbuf, mp->blen); - FREE(mp, sizeof(MSG)); - } - } - - /* Remove the screen from the displayed queue. */ - CIRCLEQ_REMOVE(&sp->gp->dq, sp, q); - - /* Free the screen itself. */ - FREE(sp, sizeof(SCR)); - - return (rval); -} diff --git a/usr.bin/vi/screen.h b/usr.bin/vi/screen.h deleted file mode 100644 index 741c41f01d34..000000000000 --- a/usr.bin/vi/screen.h +++ /dev/null @@ -1,327 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)screen.h 8.92 (Berkeley) 3/23/94 - */ - -/* - * There are minimum values that vi has to have to display a screen. The - * row minimum is fixed at 1 line for the text, and 1 line for any error - * messages. The column calculation is a lot trickier. For example, you - * have to have enough columns to display the line number, not to mention - * guaranteeing that tabstop and shiftwidth values are smaller than the - * current column value. It's a lot simpler to have a fixed value and not - * worry about it. - * - * XXX - * MINIMUM_SCREEN_COLS is probably wrong. - */ -#define MINIMUM_SCREEN_ROWS 2 -#define MINIMUM_SCREEN_COLS 20 - /* Line operations. */ -enum operation { LINE_APPEND, LINE_DELETE, LINE_INSERT, LINE_RESET }; - /* Position values. */ -enum position { P_BOTTOM, P_FILL, P_MIDDLE, P_TOP }; - /* Screen adjustment operations. */ -enum adjust { A_DECREASE, A_INCREASE, A_SET }; - -/* - * Structure for holding file references. Each SCR structure contains a - * linked list of these (the user's argument list) as well as pointers to - * the current and previous files. The structure contains the name of the - * file, along with the information that follows the name. A file has up - * to three "names". The tname field is the path of the temporary backing - * file, if any. The name field is the name the user originally used to - * specify the file to be edited. The cname field is the changed name if - * the user changed the name. - * - * Note that the read-only bit follows the file name, not the file itself. - * - * XXX - * The mtime field should be a struct timespec, but time_t is more portable. - */ -struct _fref { - CIRCLEQ_ENTRY(_fref) q; /* Linked list of file references. */ - char *cname; /* Changed file name. */ - char *name; /* File name. */ - char *tname; /* Temporary file name. */ - - recno_t lno; /* 1-N: file cursor line. */ - size_t cno; /* 0-N: file cursor column. */ - time_t mtime; /* Last modification time. */ - -#define FR_CHANGEWRITE 0x001 /* Name changed and then written. */ -#define FR_CURSORSET 0x002 /* If lno/cno valid. */ -#define FR_EDITED 0x004 /* If the file was ever edited. */ -#define FR_IGNORE 0x008 /* File isn't part of argument list. */ -#define FR_NEWFILE 0x010 /* File doesn't really exist yet. */ -#define FR_RDONLY 0x020 /* File is read-only. */ - u_int flags; -}; - -/* - * There's a file name hierarchy -- if the user has changed the name, we - * use it, otherwise, we use the original name, if there was one, othewise - * use the temporary name. - */ -#define FILENAME(frp) \ - ((frp)->cname != NULL) ? (frp)->cname : \ - ((frp)->name != NULL) ? (frp)->name : (frp)->tname - -/* - * SCR -- - * The screen structure. To the extent possible, all screen information - * is stored in the various private areas. The only information here - * is used by global routines or is shared by too many screens. - */ -struct _scr { -/* INITIALIZED AT SCREEN CREATE. */ - CIRCLEQ_ENTRY(_scr) q; /* Screens. */ - - GS *gp; /* Pointer to global area. */ - - SCR *nextdisp; /* Next display screen. */ - - EXF *ep; /* Screen's current EXF structure. */ - - MSGH msgq; /* Message list. */ - /* FREF list. */ - CIRCLEQ_HEAD(_frefh, _fref) frefq; - FREF *frp; /* FREF being edited. */ - FREF *a_frp; /* Last argument list FREF edited. */ - FREF *p_frp; /* Last FREF edited. */ - - u_long ccnt; /* Command count. */ - u_long q_ccnt; /* Quit or ZZ command count. */ - - /* Screen's: */ - size_t rows; /* 1-N: number of rows. */ - size_t cols; /* 1-N: number of columns. */ - size_t woff; /* 0-N: row offset in screen. */ - size_t t_rows; /* 1-N: cur number of text rows. */ - size_t t_maxrows; /* 1-N: max number of text rows. */ - size_t t_minrows; /* 1-N: min number of text rows. */ - - /* Cursor's: */ - recno_t lno; /* 1-N: file line. */ - size_t cno; /* 0-N: file character in line. */ - - size_t rcm; /* Vi: 0-N: Column suck. */ -#define RCM_FNB 0x01 /* Column suck: first non-blank. */ -#define RCM_LAST 0x02 /* Column suck: last. */ - u_int rcmflags; - -#define L_ADDED 0 /* Added lines. */ -#define L_CHANGED 1 /* Changed lines. */ -#define L_COPIED 2 /* Copied lines. */ -#define L_DELETED 3 /* Deleted lines. */ -#define L_JOINED 4 /* Joined lines. */ -#define L_MOVED 5 /* Moved lines. */ -#define L_PUT 6 /* Put lines. */ -#define L_LSHIFT 7 /* Left shift lines. */ -#define L_RSHIFT 8 /* Right shift lines. */ -#define L_YANKED 9 /* Yanked lines. */ - recno_t rptlines[L_YANKED + 1];/* Ex/vi: lines changed by last op. */ - - FILE *stdfp; /* Ex output file pointer. */ - - char *if_name; /* Ex input file name, for messages. */ - recno_t if_lno; /* Ex input file line, for messages. */ - - fd_set rdfd; /* Ex/vi: read fd select mask. */ - - TEXTH tiq; /* Ex/vi: text input queue. */ - - SCRIPT *script; /* Vi: script mode information .*/ - - struct timeval busy_tod; /* ITIMER_REAL: busy time-of-day. */ - char const *busy_msg; /* ITIMER_REAL: busy message. */ - - struct sigaction intr_act; /* Interrupt saved signal state. */ - struct termios intr_term; /* Interrupt saved terminal state. */ - int intr_level; /* 0-N: Interrupt level. */ - - void *vi_private; /* Vi private area. */ - void *ex_private; /* Ex private area. */ - void *svi_private; /* Vi curses screen private area. */ - void *xaw_private; /* Vi XAW screen private area. */ - -/* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */ - char *alt_name; /* Ex/vi: alternate file name. */ - - /* Ex/vi: search/substitute info. */ - regex_t sre; /* Last search RE. */ - regex_t subre; /* Last substitute RE. */ - enum direction searchdir; /* File search direction. */ - regmatch_t *match; /* Substitute match array. */ - size_t matchsize; /* Substitute match array size. */ - char *repl; /* Substitute replacement. */ - size_t repl_len; /* Substitute replacement length.*/ - size_t *newl; /* Newline offset array. */ - size_t newl_len; /* Newline array size. */ - size_t newl_cnt; /* Newlines in replacement. */ - - u_int saved_vi_mode; /* Saved vi display type. */ - - OPTION opts[O_OPTIONCOUNT]; /* Options. */ - -/* - * SCREEN SUPPORT ROUTINES. - * - * A SCR * MUST be the first argument to these routines. - */ - /* Ring the screen bell. */ - void (*s_bell) __P((SCR *)); - /* Background the screen. */ - int (*s_bg) __P((SCR *)); - /* Put up a busy message. */ - int (*s_busy) __P((SCR *, char const *)); - /* Change a screen line. */ - int (*s_change) __P((SCR *, EXF *, recno_t, enum operation)); - /* Clear the screen. */ - int (*s_clear) __P((SCR *)); - /* Return column close to specified. */ - size_t (*s_colpos) __P((SCR *, EXF *, recno_t, size_t)); - /* Return the logical cursor column. */ - int (*s_column) __P((SCR *, EXF *, size_t *)); - enum confirm /* Confirm an action with the user. */ - (*s_confirm) __P((SCR *, EXF *, MARK *, MARK *)); - /* Change the relative screen size. */ - int (*s_crel) __P((SCR *, long)); - /* Move down the screen. */ - int (*s_down) __P((SCR *, EXF *, MARK *, recno_t, int)); - /* Edit a file. */ - int (*s_edit) __P((SCR *, EXF *)); - /* End a screen. */ - int (*s_end) __P((SCR *)); - /* Run a single ex command. */ - int (*s_ex_cmd) __P((SCR *, EXF *, EXCMDARG *, MARK *)); - /* Run user's ex commands. */ - int (*s_ex_run) __P((SCR *, EXF *, MARK *)); - /* Screen's ex write function. */ - int (*s_ex_write) __P((void *, const char *, int)); - /* Foreground the screen. */ - int (*s_fg) __P((SCR *, CHAR_T *)); - /* Fill the screen's map. */ - int (*s_fill) __P((SCR *, EXF *, recno_t, enum position)); - enum input /* Get a line from the user. */ - (*s_get) __P((SCR *, EXF *, TEXTH *, int, u_int)); - enum input /* Get a key from the user. */ - (*s_key_read) __P((SCR *, int *, struct timeval *)); - /* Tell the screen an option changed. */ - int (*s_optchange) __P((SCR *, int)); - /* Return column at screen position. */ - int (*s_position) __P((SCR *, EXF *, - MARK *, u_long, enum position)); - /* Change the absolute screen size. */ - int (*s_rabs) __P((SCR *, long, enum adjust)); - /* Return column close to selection. */ - size_t (*s_rcm) __P((SCR *, EXF *, recno_t)); - /* Refresh the screen. */ - int (*s_refresh) __P((SCR *, EXF *)); - /* Split the screen. */ - int (*s_split) __P((SCR *, ARGS *[])); - /* Suspend the screen. */ - int (*s_suspend) __P((SCR *)); - /* Move up the screen. */ - int (*s_up) __P((SCR *, EXF *, MARK *, recno_t, int)); - -/* Editor screens. */ -#define S_EX 0x0000001 /* Ex screen. */ -#define S_VI_CURSES 0x0000002 /* Vi: curses screen. */ -#define S_VI_XAW 0x0000004 /* Vi: Athena widgets screen. */ - -#define IN_EX_MODE(sp) /* If in ex mode. */ \ - (F_ISSET(sp, S_EX)) -#define IN_VI_MODE(sp) /* If in vi mode. */ \ - (F_ISSET(sp, S_VI_CURSES | S_VI_XAW)) -#define S_SCREENS /* Screens. */ \ - (S_EX | S_VI_CURSES | S_VI_XAW) - -/* Major screen/file changes. */ -#define S_EXIT 0x0000008 /* Exiting (not forced). */ -#define S_EXIT_FORCE 0x0000010 /* Exiting (forced). */ -#define S_FSWITCH 0x0000020 /* Switch files. */ -#define S_SSWITCH 0x0000040 /* Switch screens. */ -#define S_MAJOR_CHANGE /* Screen or file changes. */ \ - (S_EXIT | S_EXIT_FORCE | S_FSWITCH | S_SSWITCH) - -#define S_BELLSCHED 0x0000080 /* Bell scheduled. */ -#define S_CONTINUE 0x0000100 /* Need to ask the user to continue. */ -#define S_EXSILENT 0x0000200 /* Ex batch script. */ -#define S_GLOBAL 0x0000400 /* Doing a global command. */ -#define S_INPUT 0x0000800 /* Doing text input. */ -#define S_INTERRUPTED 0x0001000 /* If have been interrupted. */ -#define S_INTERRUPTIBLE 0x0002000 /* If can be interrupted. */ -#define S_REDRAW 0x0004000 /* Redraw the screen. */ -#define S_REFORMAT 0x0008000 /* Reformat the screen. */ -#define S_REFRESH 0x0010000 /* Refresh the screen. */ -#define S_RENUMBER 0x0020000 /* Renumber the screen. */ -#define S_RESIZE 0x0040000 /* Resize the screen. */ -#define S_SCRIPT 0x0080000 /* Window is a shell script. */ -#define S_SRE_SET 0x0100000 /* The search RE has been set. */ -#define S_SUBRE_SET 0x0200000 /* The substitute RE has been set. */ -#define S_UPDATE_MODE 0x0400000 /* Don't repaint modeline. */ -#define S_VLITONLY 0x0800000 /* ^V literal next only. */ - u_int32_t flags; -}; - -/* Timers have no structure, so routines are here. */ -void h_alrm __P((int)); -int busy_on __P((SCR *, char const *)); -void busy_off __P((SCR *)); -int rcv_on __P((SCR *, EXF *)); - -/* Interrupts have no structure, so routines are here. */ -void intr_end __P((SCR *)); -int intr_init __P((SCR *)); - -/* Generic routines to start/stop a screen. */ -int screen_end __P((SCR *)); -int screen_init __P((SCR *, SCR **, u_int)); - -/* Public interfaces to the underlying screens. */ -int ex_screen_copy __P((SCR *, SCR *)); -int ex_screen_end __P((SCR *)); -int ex_screen_init __P((SCR *)); -int sex_screen_copy __P((SCR *, SCR *)); -int sex_screen_end __P((SCR *)); -int sex_screen_init __P((SCR *)); -int svi_screen_copy __P((SCR *, SCR *)); -int svi_screen_end __P((SCR *)); -int svi_screen_init __P((SCR *)); -int v_screen_copy __P((SCR *, SCR *)); -int v_screen_end __P((SCR *)); -int v_screen_init __P((SCR *)); -int xaw_screen_copy __P((SCR *, SCR *)); -int xaw_screen_end __P((SCR *)); -int xaw_screen_init __P((SCR *)); diff --git a/usr.bin/vi/search.c b/usr.bin/vi/search.c deleted file mode 100644 index 439eae5ddb5e..000000000000 --- a/usr.bin/vi/search.c +++ /dev/null @@ -1,839 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)search.c 8.40 (Berkeley) 3/23/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <ctype.h> -#include <errno.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" - -static int check_delta __P((SCR *, EXF *, long, recno_t)); -static int ctag_conv __P((SCR *, char **, int *)); -static int get_delta __P((SCR *, char **, long *, u_int *)); -static int resetup __P((SCR *, regex_t **, enum direction, - char *, char **, long *, u_int *)); - -/* - * resetup -- - * Set up a search for a regular expression. - */ -static int -resetup(sp, rep, dir, ptrn, epp, deltap, flagp) - SCR *sp; - regex_t **rep; - enum direction dir; - char *ptrn, **epp; - long *deltap; - u_int *flagp; -{ - u_int flags; - int delim, eval, re_flags, replaced; - char *p, *t; - - /* Set return information the default. */ - *deltap = 0; - - /* - * Use saved pattern if no pattern supplied, or if only a delimiter - * character is supplied. Only the pattern was saved, historic vi - * did not reuse any delta supplied. - */ - flags = *flagp; - if (ptrn == NULL) - goto prev; - if (ptrn[1] == '\0') { - if (epp != NULL) - *epp = ptrn + 1; - goto prev; - } - if (ptrn[0] == ptrn[1] && ptrn[2] == '\0') { - if (epp != NULL) - *epp = ptrn + 2; -prev: if (!F_ISSET(sp, S_SRE_SET)) { - msgq(sp, M_ERR, "No previous search pattern."); - return (1); - } - *rep = &sp->sre; - - /* Empty patterns set the direction. */ - if (LF_ISSET(SEARCH_SET)) { - F_SET(sp, S_SRE_SET); - sp->searchdir = dir; - sp->sre = **rep; - } - return (0); - } - - re_flags = 0; /* Set RE flags. */ - if (O_ISSET(sp, O_EXTENDED)) - re_flags |= REG_EXTENDED; - if (O_ISSET(sp, O_IGNORECASE)) - re_flags |= REG_ICASE; - - if (LF_ISSET(SEARCH_PARSE)) { /* Parse the string. */ - /* Set delimiter. */ - delim = *ptrn++; - - /* Find terminating delimiter, handling escaped delimiters. */ - for (p = t = ptrn;;) { - if (p[0] == '\0' || p[0] == delim) { - if (p[0] == delim) - ++p; - *t = '\0'; - break; - } - if (p[1] == delim && p[0] == '\\') - ++p; - *t++ = *p++; - } - - /* - * If characters after the terminating delimiter, it may - * be an error, or may be an offset. In either case, we - * return the end of the string, whatever it may be. - */ - if (*p) { - if (get_delta(sp, &p, deltap, flagp)) - return (1); - if (*p && LF_ISSET(SEARCH_TERM)) { - msgq(sp, M_ERR, - "Characters after search string and/or delta."); - return (1); - } - } - if (epp != NULL) - *epp = p; - - /* Check for "/ " or other such silliness. */ - if (*ptrn == '\0') - goto prev; - - if (re_conv(sp, &ptrn, &replaced)) - return (1); - } else if (LF_ISSET(SEARCH_TAG)) { - if (ctag_conv(sp, &ptrn, &replaced)) - return (1); - re_flags &= ~(REG_EXTENDED | REG_ICASE); - } - - /* Compile the RE. */ - if (eval = regcomp(*rep, ptrn, re_flags)) - re_error(sp, eval, *rep); - else if (LF_ISSET(SEARCH_SET)) { - F_SET(sp, S_SRE_SET); - sp->searchdir = dir; - sp->sre = **rep; - } - - /* Free up any extra memory. */ - if (replaced) - FREE_SPACE(sp, ptrn, 0); - return (eval); -} - -/* - * ctag_conv -- - * Convert a tags search path into something that the POSIX - * 1003.2 RE functions can handle. - */ -static int -ctag_conv(sp, ptrnp, replacedp) - SCR *sp; - char **ptrnp; - int *replacedp; -{ - size_t blen, len; - int lastdollar; - char *bp, *p, *t; - - *replacedp = 0; - - len = strlen(p = *ptrnp); - - /* Max memory usage is 2 times the length of the string. */ - GET_SPACE_RET(sp, bp, blen, len * 2); - - t = bp; - - /* The last charcter is a '/' or '?', we just strip it. */ - if (p[len - 1] == '/' || p[len - 1] == '?') - p[len - 1] = '\0'; - - /* The next-to-last character is a '$', and it's magic. */ - if (p[len - 2] == '$') { - lastdollar = 1; - p[len - 2] = '\0'; - } else - lastdollar = 0; - - /* The first character is a '/' or '?', we just strip it. */ - if (p[0] == '/' || p[0] == '?') - ++p; - - /* The second character is a '^', and it's magic. */ - if (p[0] == '^') - *t++ = *p++; - - /* - * Escape every other magic character we can find, stripping the - * backslashes ctags inserts to escape the search delimiter - * characters. - */ - while (p[0]) { - /* Ctags escapes the search delimiter characters. */ - if (p[0] == '\\' && (p[1] == '/' || p[1] == '?')) - ++p; - else if (strchr("^.[]$*", p[0])) - *t++ = '\\'; - *t++ = *p++; - } - if (lastdollar) - *t++ = '$'; - *t++ = '\0'; - - *ptrnp = bp; - *replacedp = 1; - return (0); -} - -#define EMPTYMSG "File empty; nothing to search." -#define EOFMSG "Reached end-of-file without finding the pattern." -#define NOTFOUND "Pattern not found." -#define SOFMSG "Reached top-of-file without finding the pattern." -#define WRAPMSG "Search wrapped." - -int -f_search(sp, ep, fm, rm, ptrn, eptrn, flagp) - SCR *sp; - EXF *ep; - MARK *fm, *rm; - char *ptrn, **eptrn; - u_int *flagp; -{ - regmatch_t match[1]; - regex_t *re, lre; - recno_t lno; - size_t coff, len; - long delta; - u_int flags; - int btear, eval, itear, rval, wrapped; - char *l; - - if (file_lline(sp, ep, &lno)) - return (1); - flags = *flagp; - if (lno == 0) { - if (LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, EMPTYMSG); - return (1); - } - - re = &lre; - if (resetup(sp, &re, FORWARD, ptrn, eptrn, &delta, flagp)) - return (1); - - /* - * Start searching immediately after the cursor. If at the end of the - * line, start searching on the next line. This is incompatible (read - * bug fix) with the historic vi -- searches for the '$' pattern never - * moved forward, and "-t foo" didn't work if "foo" was the first thing - * in the file. - */ - if (LF_ISSET(SEARCH_FILE)) { - lno = 1; - coff = 0; - } else { - if ((l = file_gline(sp, ep, fm->lno, &len)) == NULL) { - GETLINE_ERR(sp, fm->lno); - return (1); - } - if (fm->cno + 1 >= len) { - if (fm->lno == lno) { - if (!O_ISSET(sp, O_WRAPSCAN)) { - if (LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, EOFMSG); - return (1); - } - lno = 1; - } else - lno = fm->lno + 1; - coff = 0; - } else { - lno = fm->lno; - coff = fm->cno + 1; - } - } - - /* Set up busy message, interrupts. */ - btear = F_ISSET(sp, S_EXSILENT) ? 0 : !busy_on(sp, "Searching..."); - itear = !intr_init(sp); - - for (rval = 1, wrapped = 0;; ++lno, coff = 0) { - if (F_ISSET(sp, S_INTERRUPTED)) { - msgq(sp, M_INFO, "Interrupted."); - break; - } - if (wrapped && lno > fm->lno || - (l = file_gline(sp, ep, lno, &len)) == NULL) { - if (wrapped) { - if (LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, NOTFOUND); - break; - } - if (!O_ISSET(sp, O_WRAPSCAN)) { - if (LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, EOFMSG); - break; - } - lno = 0; - wrapped = 1; - continue; - } - - /* If already at EOL, just keep going. */ - if (len && coff == len) - continue; - - /* Set the termination. */ - match[0].rm_so = coff; - match[0].rm_eo = len; - -#if defined(DEBUG) && 0 - TRACE(sp, "F search: %lu from %u to %u\n", - lno, coff, len ? len - 1 : len); -#endif - /* Search the line. */ - eval = regexec(re, l, 1, match, - (match[0].rm_so == 0 ? 0 : REG_NOTBOL) | REG_STARTEND); - if (eval == REG_NOMATCH) - continue; - if (eval != 0) { - re_error(sp, eval, re); - break; - } - - /* Warn if wrapped. */ - if (wrapped && O_ISSET(sp, O_WARN) && LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, WRAPMSG); - - /* - * If an offset, see if it's legal. It's possible to match - * past the end of the line with $, so check for that case. - */ - if (delta) { - if (check_delta(sp, ep, delta, lno)) - break; - rm->lno = delta + lno; - rm->cno = 0; - } else { -#if defined(DEBUG) && 0 - TRACE(sp, "found: %qu to %qu\n", - match[0].rm_so, match[0].rm_eo); -#endif - rm->lno = lno; - rm->cno = match[0].rm_so; - - /* - * If a change command, it's possible to move beyond - * the end of a line. Historic vi generally got this - * wrong (try "c?$<cr>"). Not all that sure this gets - * it right, there are lots of strange cases. - */ - if (!LF_ISSET(SEARCH_EOL) && rm->cno >= len) - rm->cno = len ? len - 1 : 0; - } - rval = 0; - break; - } - - /* Turn off busy message, interrupts. */ - if (btear) - busy_off(sp); - if (itear) - intr_end(sp); - return (rval); -} - -int -b_search(sp, ep, fm, rm, ptrn, eptrn, flagp) - SCR *sp; - EXF *ep; - MARK *fm, *rm; - char *ptrn, **eptrn; - u_int *flagp; -{ - regmatch_t match[1]; - regex_t *re, lre; - recno_t lno; - size_t coff, len, last; - long delta; - u_int flags; - int btear, eval, itear, rval, wrapped; - char *l; - - if (file_lline(sp, ep, &lno)) - return (1); - flags = *flagp; - if (lno == 0) { - if (LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, EMPTYMSG); - return (1); - } - - re = &lre; - if (resetup(sp, &re, BACKWARD, ptrn, eptrn, &delta, flagp)) - return (1); - - /* If in the first column, start searching on the previous line. */ - if (fm->cno == 0) { - if (fm->lno == 1) { - if (!O_ISSET(sp, O_WRAPSCAN)) { - if (LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, SOFMSG); - return (1); - } - } else - lno = fm->lno - 1; - } else - lno = fm->lno; - - /* Turn on busy message, interrupts. */ - btear = F_ISSET(sp, S_EXSILENT) ? 0 : !busy_on(sp, "Searching..."); - itear = !intr_init(sp); - - for (rval = 1, wrapped = 0, coff = fm->cno;; --lno, coff = 0) { - if (F_ISSET(sp, S_INTERRUPTED)) { - msgq(sp, M_INFO, "Interrupted."); - break; - } - if (wrapped && lno < fm->lno || lno == 0) { - if (wrapped) { - if (LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, NOTFOUND); - break; - } - if (!O_ISSET(sp, O_WRAPSCAN)) { - if (LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, SOFMSG); - break; - } - if (file_lline(sp, ep, &lno)) - goto err; - if (lno == 0) { - if (LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, EMPTYMSG); - break; - } - ++lno; - wrapped = 1; - continue; - } - - if ((l = file_gline(sp, ep, lno, &len)) == NULL) - goto err; - - /* Set the termination. */ - match[0].rm_so = 0; - match[0].rm_eo = len; - -#if defined(DEBUG) && 0 - TRACE(sp, "B search: %lu from 0 to %qu\n", lno, match[0].rm_eo); -#endif - /* Search the line. */ - eval = regexec(re, l, 1, match, - (match[0].rm_eo == len ? 0 : REG_NOTEOL) | REG_STARTEND); - if (eval == REG_NOMATCH) - continue; - if (eval != 0) { - re_error(sp, eval, re); - break; - } - - /* Check for a match starting past the cursor. */ - if (coff != 0 && match[0].rm_so >= coff) - continue; - - /* Warn if wrapped. */ - if (wrapped && O_ISSET(sp, O_WARN) && LF_ISSET(SEARCH_MSG)) - msgq(sp, M_INFO, WRAPMSG); - - if (delta) { - if (check_delta(sp, ep, delta, lno)) - break; - rm->lno = delta + lno; - rm->cno = 0; - } else { -#if defined(DEBUG) && 0 - TRACE(sp, "found: %qu to %qu\n", - match[0].rm_so, match[0].rm_eo); -#endif - /* - * We now have the first match on the line. Step - * through the line character by character until we - * find the last acceptable match. This is painful, - * we need a better interface to regex to make this - * work. - */ - for (;;) { - last = match[0].rm_so++; - if (match[0].rm_so >= len) - break; - match[0].rm_eo = len; - eval = regexec(re, l, 1, match, - (match[0].rm_so == 0 ? 0 : REG_NOTBOL) | - REG_STARTEND); - if (eval == REG_NOMATCH) - break; - if (eval != 0) { - re_error(sp, eval, re); - goto err; - } - if (coff && match[0].rm_so >= coff) - break; - } - rm->lno = lno; - - /* See comment in f_search(). */ - if (!LF_ISSET(SEARCH_EOL) && last >= len) - rm->cno = len ? len - 1 : 0; - else - rm->cno = last; - } - rval = 0; - break; - } - - /* Turn off busy message, interrupts. */ -err: if (btear) - busy_off(sp); - if (itear) - intr_end(sp); - - return (rval); -} - -/* - * re_conv -- - * Convert vi's regular expressions into something that the - * the POSIX 1003.2 RE functions can handle. - * - * There are three conversions we make to make vi's RE's (specifically - * the global, search, and substitute patterns) work with POSIX RE's. - * - * 1: If O_MAGIC is not set, strip backslashes from the magic character - * set (.[]*~) that have them, and add them to the ones that don't. - * 2: If O_MAGIC is not set, the string "\~" is replaced with the text - * from the last substitute command's replacement string. If O_MAGIC - * is set, it's the string "~". - * 3: The pattern \<ptrn\> does "word" searches, convert it to use the - * new RE escapes. - */ -int -re_conv(sp, ptrnp, replacedp) - SCR *sp; - char **ptrnp; - int *replacedp; -{ - size_t blen, needlen; - int magic; - char *bp, *p, *t; - - /* - * First pass through, we figure out how much space we'll need. - * We do it in two passes, on the grounds that most of the time - * the user is doing a search and won't have magic characters. - * That way we can skip the malloc and memmove's. - */ - for (p = *ptrnp, magic = 0, needlen = 0; *p != '\0'; ++p) - switch (*p) { - case '\\': - switch (*++p) { - case '<': - magic = 1; - needlen += sizeof(RE_WSTART); - break; - case '>': - magic = 1; - needlen += sizeof(RE_WSTOP); - break; - case '~': - if (!O_ISSET(sp, O_MAGIC)) { - magic = 1; - needlen += sp->repl_len; - } - break; - case '.': - case '[': - case ']': - case '*': - if (!O_ISSET(sp, O_MAGIC)) { - magic = 1; - needlen += 1; - } - break; - default: - needlen += 2; - } - break; - case '~': - if (O_ISSET(sp, O_MAGIC)) { - magic = 1; - needlen += sp->repl_len; - } - break; - case '.': - case '[': - case ']': - case '*': - if (!O_ISSET(sp, O_MAGIC)) { - magic = 1; - needlen += 2; - } - break; - default: - needlen += 1; - break; - } - - if (!magic) { - *replacedp = 0; - return (0); - } - - /* - * Get enough memory to hold the final pattern. - * - * XXX - * It's nul-terminated, for now. - */ - GET_SPACE_RET(sp, bp, blen, needlen + 1); - - for (p = *ptrnp, t = bp; *p != '\0'; ++p) - switch (*p) { - case '\\': - switch (*++p) { - case '<': - memmove(t, RE_WSTART, sizeof(RE_WSTART) - 1); - t += sizeof(RE_WSTART) - 1; - break; - case '>': - memmove(t, RE_WSTOP, sizeof(RE_WSTOP) - 1); - t += sizeof(RE_WSTOP) - 1; - break; - case '~': - if (O_ISSET(sp, O_MAGIC)) - *t++ = '~'; - else { - memmove(t, sp->repl, sp->repl_len); - t += sp->repl_len; - } - break; - case '.': - case '[': - case ']': - case '*': - if (O_ISSET(sp, O_MAGIC)) - *t++ = '\\'; - *t++ = *p; - break; - default: - *t++ = '\\'; - *t++ = *p; - } - break; - case '~': - if (O_ISSET(sp, O_MAGIC)) { - memmove(t, sp->repl, sp->repl_len); - t += sp->repl_len; - } else - *t++ = '~'; - break; - case '.': - case '[': - case ']': - case '*': - if (!O_ISSET(sp, O_MAGIC)) - *t++ = '\\'; - *t++ = *p; - break; - default: - *t++ = *p; - break; - } - *t = '\0'; - - *ptrnp = bp; - *replacedp = 1; - return (0); -} - -/* - * get_delta -- - * Get a line delta. The trickiness is that the delta can be pretty - * complicated, i.e. "+3-2+3++- ++" is allowed. - * - * !!! - * In historic vi, if you had a delta on a search pattern which was used as - * a motion command, the command became a line mode command regardless of the - * cursor positions. A fairly common trick is to use a delta of "+0" to make - * the command a line mode command. This is the only place that knows about - * delta's, so we set the return flag information here. - */ -static int -get_delta(sp, dp, valp, flagp) - SCR *sp; - char **dp; - long *valp; - u_int *flagp; -{ - char *p; - long val, tval; - - for (tval = 0, p = *dp; *p != '\0'; *flagp |= SEARCH_DELTA) { - if (isblank(*p)) { - ++p; - continue; - } - if (*p == '+' || *p == '-') { - if (!isdigit(*(p + 1))) { - if (*p == '+') { - if (tval == LONG_MAX) - goto overflow; - ++tval; - } else { - if (tval == LONG_MIN) - goto underflow; - --tval; - } - ++p; - continue; - } - } else - if (!isdigit(*p)) - break; - - errno = 0; - val = strtol(p, &p, 10); - if (errno == ERANGE) { - if (val == LONG_MAX) -overflow: msgq(sp, M_ERR, "Delta value overflow."); - else if (val == LONG_MIN) -underflow: msgq(sp, M_ERR, "Delta value underflow."); - else - msgq(sp, M_SYSERR, NULL); - return (1); - } - if (val >= 0) { - if (LONG_MAX - val < tval) - goto overflow; - } else - if (-(LONG_MIN - tval) > val) - goto underflow; - tval += val; - } - *dp = p; - *valp = tval; - return (0); -} - -/* - * check_delta -- - * Check a line delta to see if it's legal. - */ -static int -check_delta(sp, ep, delta, lno) - SCR *sp; - EXF *ep; - long delta; - recno_t lno; -{ - /* A delta can overflow a record number. */ - if (delta < 0) { - if (lno < LONG_MAX && delta >= (long)lno) { - msgq(sp, M_ERR, "Search offset before line 1."); - return (1); - } - } else { - if (ULONG_MAX - lno < delta) { - msgq(sp, M_ERR, "Delta value overflow."); - return (1); - } - if (file_gline(sp, ep, lno + delta, NULL) == NULL) { - msgq(sp, M_ERR, "Search offset past end-of-file."); - return (1); - } - } - return (0); -} - -/* - * re_error -- - * Report a regular expression error. - */ -void -re_error(sp, errcode, preg) - SCR *sp; - int errcode; - regex_t *preg; -{ - size_t s; - char *oe; - - s = regerror(errcode, preg, "", 0); - if ((oe = malloc(s)) == NULL) - msgq(sp, M_SYSERR, NULL); - else { - (void)regerror(errcode, preg, oe, s); - msgq(sp, M_ERR, "RE error: %s", oe); - } - free(oe); -} diff --git a/usr.bin/vi/search.h b/usr.bin/vi/search.h deleted file mode 100644 index 1483a04c7b71..000000000000 --- a/usr.bin/vi/search.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)search.h 8.9 (Berkeley) 3/16/94 - */ - -#define RE_WSTART "[[:<:]]" /* Not-in-word search patterns. */ -#define RE_WSTOP "[[:>:]]" - -#define SEARCH_DELTA 0x001 /* A delta part of the search.*/ -#define SEARCH_EOL 0x002 /* Offset past EOL is okay. */ -#define SEARCH_FILE 0x004 /* Search the entire file. */ -#define SEARCH_MSG 0x008 /* Display search warning messages. */ -#define SEARCH_PARSE 0x010 /* Parse the search pattern. */ -#define SEARCH_SET 0x020 /* Set search direction. */ -#define SEARCH_TAG 0x040 /* Search pattern is a tag pattern. */ -#define SEARCH_TERM 0x080 /* Search pattern should terminate. */ - -enum direction { NOTSET, FORWARD, BACKWARD }; - -/* Search functions. */ -int b_search __P((SCR *, EXF *, MARK *, MARK *, char *, char **, u_int *)); -int f_search __P((SCR *, EXF *, MARK *, MARK *, char *, char **, u_int *)); -int re_conv __P((SCR *, char **, int *)); -void re_error __P((SCR *, int, regex_t *)); diff --git a/usr.bin/vi/seq.c b/usr.bin/vi/seq.c deleted file mode 100644 index 01969f2c83a4..000000000000 --- a/usr.bin/vi/seq.c +++ /dev/null @@ -1,340 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)seq.c 8.26 (Berkeley) 3/14/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <ctype.h> -#include <errno.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" -#include "seq.h" -#include "excmd.h" - -/* - * seq_set -- - * Internal version to enter a sequence. - */ -int -seq_set(sp, name, nlen, input, ilen, output, olen, stype, flags) - SCR *sp; - char *name, *input, *output; - size_t nlen, ilen, olen; - enum seqtype stype; - int flags; -{ - SEQ *lastqp, *qp; - CHAR_T *p; - int sv_errno; - - /* - * An input string must always be present. The output string - * can be NULL, when set internally, that's how we throw away - * input. - * - * Just replace the output field if the string already set. - */ - if ((qp = seq_find(sp, &lastqp, input, ilen, stype, NULL)) != NULL) { - if (output == NULL || olen == 0) { - p = NULL; - olen = 0; - } else if ((p = v_strdup(sp, output, olen)) == NULL) { - sv_errno = errno; - goto mem1; - } - if (qp->output != NULL) - free(qp->output); - qp->olen = olen; - qp->output = p; - return (0); - } - - /* Allocate and initialize SEQ structure. */ - CALLOC(sp, qp, SEQ *, 1, sizeof(SEQ)); - if (qp == NULL) { - sv_errno = errno; - goto mem1; - } - - /* Name. */ - if (name == NULL || nlen == 0) - qp->name = NULL; - else if ((qp->name = v_strdup(sp, name, nlen)) == NULL) { - sv_errno = errno; - goto mem2; - } - qp->nlen = nlen; - - /* Input. */ - if ((qp->input = v_strdup(sp, input, ilen)) == NULL) { - sv_errno = errno; - goto mem3; - } - qp->ilen = ilen; - - /* Output. */ - if (output == NULL) { - qp->output = NULL; - olen = 0; - } else if ((qp->output = v_strdup(sp, output, olen)) == NULL) { - sv_errno = errno; - free(qp->input); -mem3: if (qp->name != NULL) - free(qp->name); -mem2: FREE(qp, sizeof(SEQ)); -mem1: errno = sv_errno; - msgq(sp, M_SYSERR, NULL); - return (1); - } - qp->olen = olen; - - /* Type, flags. */ - qp->stype = stype; - qp->flags = flags; - - /* Link into the chain. */ - if (lastqp == NULL) { - LIST_INSERT_HEAD(&sp->gp->seqq, qp, q); - } else { - LIST_INSERT_AFTER(lastqp, qp, q); - } - - /* Set the fast lookup bit. */ - bit_set(sp->gp->seqb, qp->input[0]); - - return (0); -} - -/* - * seq_delete -- - * Delete a sequence. - */ -int -seq_delete(sp, input, ilen, stype) - SCR *sp; - char *input; - size_t ilen; - enum seqtype stype; -{ - SEQ *qp; - - if ((qp = seq_find(sp, NULL, input, ilen, stype, NULL)) == NULL) - return (1); - - LIST_REMOVE(qp, q); - if (qp->name != NULL) - free(qp->name); - free(qp->input); - if (qp->output != NULL) - free(qp->output); - FREE(qp, sizeof(SEQ)); - return (0); -} - -/* - * seq_find -- - * Search the sequence list for a match to a buffer, if ispartial - * isn't NULL, partial matches count. - */ -SEQ * -seq_find(sp, lastqp, input, ilen, stype, ispartialp) - SCR *sp; - SEQ **lastqp; - char *input; - size_t ilen; - enum seqtype stype; - int *ispartialp; -{ - SEQ *lqp, *qp; - int diff; - - /* - * Ispartialp is a location where we return if there was a - * partial match, i.e. if the string were extended it might - * match something. - * - * XXX - * Overload the meaning of ispartialp; only the terminal key - * search doesn't want the search limited to complete matches, - * i.e. ilen may be longer than the match. - */ - if (ispartialp != NULL) - *ispartialp = 0; - for (lqp = NULL, qp = sp->gp->seqq.lh_first; - qp != NULL; lqp = qp, qp = qp->q.le_next) { - /* Fast checks on the first character and type. */ - if (qp->input[0] > input[0]) - break; - if (qp->input[0] < input[0] || qp->stype != stype) - continue; - - /* Check on the real comparison. */ - diff = memcmp(qp->input, input, MIN(qp->ilen, ilen)); - if (diff > 0) - break; - if (diff < 0) - continue; - /* - * If the entry is the same length as the string, return a - * match. If the entry is shorter than the string, return a - * match if called from the terminal key routine. Otherwise, - * keep searching for a complete match. - */ - if (qp->ilen <= ilen) { - if (qp->ilen == ilen || ispartialp != NULL) { - if (lastqp != NULL) - *lastqp = lqp; - return (qp); - } - continue; - } - /* - * If the entry longer than the string, return partial match - * if called from the terminal key routine. Otherwise, no - * match. - */ - if (ispartialp != NULL) - *ispartialp = 1; - break; - } - if (lastqp != NULL) - *lastqp = lqp; - return (NULL); -} - -/* - * seq_dump -- - * Display the sequence entries of a specified type. - */ -int -seq_dump(sp, stype, isname) - SCR *sp; - enum seqtype stype; - int isname; -{ - CHNAME const *cname; - SEQ *qp; - int cnt, len, olen; - char *p; - - cnt = 0; - cname = sp->gp->cname; - for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next) { - if (stype != qp->stype) - continue; - ++cnt; - for (p = qp->input, - olen = qp->ilen, len = 0; olen > 0; --olen) - len += ex_printf(EXCOOKIE, "%s", cname[*p++].name); - for (len = STANDARD_TAB - len % STANDARD_TAB; len > 0;) - len -= ex_printf(EXCOOKIE, " "); - - if (qp->output != NULL) - for (p = qp->output, - olen = qp->olen, len = 0; olen > 0; --olen) - len += - ex_printf(EXCOOKIE, "%s", cname[*p++].name); - else - len = 0; - - if (isname && qp->name != NULL) { - for (len = STANDARD_TAB - len % STANDARD_TAB; len > 0;) - len -= ex_printf(EXCOOKIE, " "); - for (p = qp->name, olen = qp->nlen; olen > 0; --olen) - (void)ex_printf(EXCOOKIE, - "%s", cname[*p++].name); - } - (void)ex_printf(EXCOOKIE, "\n"); - } - return (cnt); -} - -/* - * seq_save -- - * Save the sequence entries to a file. - */ -int -seq_save(sp, fp, prefix, stype) - SCR *sp; - FILE *fp; - char *prefix; - enum seqtype stype; -{ - SEQ *qp; - size_t olen; - int ch; - char *p; - - /* Write a sequence command for all keys the user defined. */ - for (qp = sp->gp->seqq.lh_first; qp != NULL; qp = qp->q.le_next) { - if (!F_ISSET(qp, S_USERDEF) || stype != qp->stype) - continue; - if (prefix) - (void)fprintf(fp, "%s", prefix); - for (p = qp->input, olen = qp->ilen; olen > 0; --olen) { - ch = *p++; - if (ch == LITERAL_CH || ch == '|' || - isblank(ch) || term_key_val(sp, ch) == K_NL) - (void)putc(LITERAL_CH, fp); - (void)putc(ch, fp); - } - (void)putc(' ', fp); - if (qp->output != NULL) - for (p = qp->output, - olen = qp->olen; olen > 0; --olen) { - ch = *p++; - if (ch == LITERAL_CH || ch == '|' || - term_key_val(sp, ch) == K_NL) - (void)putc(LITERAL_CH, fp); - (void)putc(ch, fp); - } - (void)putc('\n', fp); - } - return (0); -} diff --git a/usr.bin/vi/seq.h b/usr.bin/vi/seq.h deleted file mode 100644 index 97f6e8ecd03c..000000000000 --- a/usr.bin/vi/seq.h +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)seq.h 8.9 (Berkeley) 3/16/94 - */ - -/* - * Map and abbreviation structures. - * - * The map structure is doubly linked list, sorted by input string and by - * input length within the string. (The latter is necessary so that short - * matches will happen before long matches when the list is searched.) - * Additionally, there is a bitmap which has bits set if there are entries - * starting with the corresponding character. This keeps us from walking - * the list unless it's necessary. - * - * The name and the output fields of a SEQ can be empty, i.e. NULL. - * Only the input field is required. - * - * XXX - * The fast-lookup bits are never turned off -- users don't usually unmap - * things, though, so it's probably not a big deal. - */ - /* Sequence type. */ -enum seqtype { SEQ_ABBREV, SEQ_COMMAND, SEQ_INPUT }; - -struct _seq { - LIST_ENTRY(_seq) q; /* Linked list of all sequences. */ - enum seqtype stype; /* Sequence type. */ - char *name; /* Sequence name (if any). */ - size_t nlen; /* Name length. */ - char *input; /* Sequence input keys. */ - size_t ilen; /* Input keys length. */ - char *output; /* Sequence output keys. */ - size_t olen; /* Output keys length. */ - -#define S_USERDEF 0x01 /* If sequence user defined. */ - u_char flags; -}; - -int abbr_save __P((SCR *, FILE *)); -int map_save __P((SCR *, FILE *)); -int seq_delete __P((SCR *, char *, size_t, enum seqtype)); -int seq_dump __P((SCR *, enum seqtype, int)); -SEQ *seq_find __P((SCR *, SEQ **, char *, size_t, enum seqtype, int *)); -void seq_init __P((SCR *)); -int seq_save __P((SCR *, FILE *, char *, enum seqtype)); -int seq_set __P((SCR *, char *, size_t, - char *, size_t, char *, size_t, enum seqtype, int)); diff --git a/usr.bin/vi/term.c b/usr.bin/vi/term.c deleted file mode 100644 index 0861ee175656..000000000000 --- a/usr.bin/vi/term.c +++ /dev/null @@ -1,758 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)term.c 8.56 (Berkeley) 3/23/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <ctype.h> -#include <curses.h> -#include <errno.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" -#include "seq.h" - -static int keycmp __P((const void *, const void *)); -static void termkeyset __P((GS *, int, int)); - -/* - * If we're reading less than 20 characters, up the size of the tty buffer. - * This shouldn't ever happen, other than the first time through, but it's - * possible if a map is large enough. - */ -#define term_read_grow(sp, tty) \ - (tty)->nelem - (tty)->cnt >= 20 ? 0 : __term_read_grow(sp, tty, 64) -static int __term_read_grow __P((SCR *, IBUF *, int)); - -/* - * XXX - * THIS REQUIRES THAT ALL SCREENS SHARE A TERMINAL TYPE. - */ -typedef struct _tklist { - char *ts; /* Key's termcap string. */ - char *output; /* Corresponding vi command. */ - char *name; /* Name. */ - u_char value; /* Special value (for lookup). */ -} TKLIST; -static TKLIST const c_tklist[] = { /* Command mappings. */ - {"kA", "O", "insert line"}, - {"kD", "x", "delete character"}, - {"kd", "j", "cursor down"}, - {"kE", "D", "delete to eol"}, - {"kF", "\004", "scroll down"}, - {"kH", "$", "go to eol"}, - {"kh", "^", "go to sol"}, - {"kI", "i", "insert at cursor"}, - {"kL", "dd", "delete line"}, - {"kl", "h", "cursor left"}, - {"kN", "\006", "page down"}, - {"kP", "\002", "page up"}, - {"kR", "\025", "scroll up"}, - {"kS", "dG", "delete to end of screen"}, - {"kr", "l", "cursor right"}, - {"ku", "k", "cursor up"}, - {NULL}, -}; -static TKLIST const m1_tklist[] = { /* Input mappings (lookup). */ - {"kl", NULL, "cursor erase", K_VERASE}, - {NULL}, -}; -static TKLIST const m2_tklist[] = { /* Input mappings (set or delete). */ - {"kd", NULL, "cursor down"}, - {"ku", NULL, "cursor up"}, - {"kr", " ", "cursor space"}, - {NULL}, -}; - -/* - * !!! - * Historic ex/vi always used: - * - * ^D: autoindent deletion - * ^H: last character deletion - * ^W: last word deletion - * ^Q: quote the next character (if not used in flow control). - * ^V: quote the next character - * - * regardless of the user's choices for these characters. The user's erase - * and kill characters worked in addition to these characters. Ex was not - * completely consistent with this scheme, as it did map the scroll command - * to the user's current EOF character. This implementation wires down the - * above characters, but in addition uses the VERASE, VINTR, VKILL and VWERASE - * characters described by the user's termios structure. We don't do the EOF - * mapping for ex, but I think I'm unlikely to get caught on that one. - * - * XXX - * THIS REQUIRES THAT ALL SCREENS SHARE A SPECIAL KEY SET. - */ -typedef struct _keylist { - u_char value; /* Special value. */ - CHAR_T ch; /* Key. */ -} KEYLIST; -static KEYLIST keylist[] = { - {K_CARAT, '^'}, /* ^ */ - {K_CNTRLD, '\004'}, /* ^D */ - {K_CNTRLR, '\022'}, /* ^R */ - {K_CNTRLT, '\024'}, /* ^T */ - {K_CNTRLZ, '\032'}, /* ^Z */ - {K_COLON, ':'}, /* : */ - {K_CR, '\r'}, /* \r */ - {K_ESCAPE, '\033'}, /* ^[ */ - {K_FORMFEED, '\f'}, /* \f */ - {K_NL, '\n'}, /* \n */ - {K_RIGHTBRACE, '}'}, /* } */ - {K_RIGHTPAREN, ')'}, /* ) */ - {K_TAB, '\t'}, /* \t */ - {K_VERASE, '\b'}, /* \b */ - {K_VINTR, '\003'}, /* ^C */ - {K_VKILL, '\025'}, /* ^U */ - {K_VLNEXT, '\021'}, /* ^Q */ - {K_VLNEXT, '\026'}, /* ^V */ - {K_VWERASE, '\027'}, /* ^W */ - {K_ZERO, '0'}, /* 0 */ - {K_NOTUSED, 0}, /* VERASE, VINTR, VKILL, VWERASE */ - {K_NOTUSED, 0}, - {K_NOTUSED, 0}, - {K_NOTUSED, 0}, -}; -static int nkeylist = (sizeof(keylist) / sizeof(keylist[0])) - 4; - -/* - * term_init -- - * Initialize the special key lookup table, and the special keys - * defined by the terminal's termcap entry. - */ -int -term_init(sp) - SCR *sp; -{ - extern CHNAME const asciiname[]; /* XXX */ - GS *gp; - KEYLIST *kp; - TKLIST const *tkp; - int cnt; - char *sbp, *t, buf[2 * 1024], sbuf[128]; - - /* - * XXX - * 8-bit, ASCII only, for now. Recompilation should get you - * any 8-bit character set, as long as nul isn't a character. - */ - gp = sp->gp; - gp->cname = asciiname; /* XXX */ - -#ifdef VERASE - termkeyset(gp, VERASE, K_VERASE); -#endif -#ifdef VINTR - termkeyset(gp, VINTR, K_VINTR); -#endif -#ifdef VKILL - termkeyset(gp, VKILL, K_VKILL); -#endif -#ifdef VWERASE - termkeyset(gp, VWERASE, K_VWERASE); -#endif - /* Sort the special key list. */ - qsort(keylist, nkeylist, sizeof(keylist[0]), keycmp); - - /* Initialize the fast lookup table. */ - CALLOC_RET(sp, - gp->special_key, u_char *, MAX_FAST_KEY + 1, sizeof(u_char)); - for (gp->max_special = 0, kp = keylist, cnt = nkeylist; cnt--; ++kp) { - if (gp->max_special < kp->value) - gp->max_special = kp->value; - if (kp->ch <= MAX_FAST_KEY) - gp->special_key[kp->ch] = kp->value; - } - - /* Set key sequences found in the termcap entry. */ - switch (tgetent(buf, O_STR(sp, O_TERM))) { - case -1: - msgq(sp, M_ERR, - "tgetent: %s: %s.", O_STR(sp, O_TERM), strerror(errno)); - return (0); - case 0: - msgq(sp, M_ERR, - "%s: unknown terminal type.", O_STR(sp, O_TERM)); - return (0); - } - - /* Command mappings. */ - for (tkp = c_tklist; tkp->name != NULL; ++tkp) { - sbp = sbuf; - if ((t = tgetstr(tkp->ts, &sbp)) == NULL) - continue; - if (seq_set(sp, tkp->name, strlen(tkp->name), t, strlen(t), - tkp->output, strlen(tkp->output), SEQ_COMMAND, 0)) - return (1); - } - /* Input mappings needing to be looked up. */ - for (tkp = m1_tklist; tkp->name != NULL; ++tkp) { - sbp = sbuf; - if ((t = tgetstr(tkp->ts, &sbp)) == NULL) - continue; - for (kp = keylist;; ++kp) - if (kp->value == tkp->value) - break; - if (kp == NULL) - continue; - if (seq_set(sp, tkp->name, strlen(tkp->name), - t, strlen(t), &kp->ch, 1, SEQ_INPUT, 0)) - return (1); - } - /* Input mappings that are already set or are text deletions. */ - for (tkp = m2_tklist; tkp->name != NULL; ++tkp) { - sbp = sbuf; - if ((t = tgetstr(tkp->ts, &sbp)) == NULL) - continue; - if (tkp->output == NULL) { - if (seq_set(sp, tkp->name, strlen(tkp->name), - t, strlen(t), NULL, 0, SEQ_INPUT, 0)) - return (1); - } else - if (seq_set(sp, tkp->name, strlen(tkp->name), - t, strlen(t), tkp->output, strlen(tkp->output), - SEQ_INPUT, 0)) - return (1); - } - return (0); -} - -/* - * termkeyset -- - * Set keys found in the termios structure. VERASE, VINTR and VKILL are - * required by POSIX 1003.1-1990, VWERASE is a 4.4BSD extension. We've - * left four open slots in the keylist table, if these values exist, put - * them into place. Note, they may reset (or duplicate) values already - * in the table, so we check for that first. - */ -static void -termkeyset(gp, name, val) - GS *gp; - int name, val; -{ - KEYLIST *kp; - cc_t ch; - - if (!F_ISSET(gp, G_TERMIOS_SET)) - return; - if ((ch = gp->original_termios.c_cc[(name)]) == _POSIX_VDISABLE) - return; - - /* Check for duplication. */ - for (kp = keylist; kp->value != K_NOTUSED; ++kp) - if (kp->ch == ch) { - kp->value = val; - return; - } - /* Add a new entry. */ - if (kp->value == K_NOTUSED) { - keylist[nkeylist].ch = ch; - keylist[nkeylist].value = val; - ++nkeylist; - } -} - -/* - * term_push -- - * Push keys onto the front of a buffer. - * - * There is a single input buffer in ex/vi. Characters are read onto the - * end of the buffer by the terminal input routines, and pushed onto the - * front of the buffer by various other functions in ex/vi. Each key has - * an associated flag value, which indicates if it has already been quoted, - * if it is the result of a mapping or an abbreviation, as well as a count - * of the number of times it has been mapped. - */ -int -term_push(sp, s, nchars, cmap, flags) - SCR *sp; - CHAR_T *s; /* Characters. */ - size_t nchars; /* Number of chars. */ - u_int cmap; /* Map count. */ - u_int flags; /* CH_* flags. */ -{ - IBUF *tty; - - /* If we have room, stuff the keys into the buffer. */ - tty = sp->gp->tty; - if (nchars <= tty->next || - (tty->ch != NULL && tty->cnt == 0 && nchars <= tty->nelem)) { - if (tty->cnt != 0) - tty->next -= nchars; - tty->cnt += nchars; - MEMMOVE(tty->ch + tty->next, s, nchars); - MEMSET(tty->chf + tty->next, flags, nchars); - MEMSET(tty->cmap + tty->next, cmap, nchars); - return (0); - } - - /* Get enough space plus a little extra. */ - if (tty->cnt + nchars >= tty->nelem && - __term_read_grow(sp, tty, MAX(nchars, 64))) - return (1); - - /* - * If there are currently characters in the queue, shift them up, - * leaving some extra room. - */ -#define TERM_PUSH_SHIFT 30 - if (tty->cnt) { - MEMMOVE(tty->ch + TERM_PUSH_SHIFT + nchars, - tty->ch + tty->next, tty->cnt); - MEMMOVE(tty->chf + TERM_PUSH_SHIFT + nchars, - tty->chf + tty->next, tty->cnt); - MEMMOVE(tty->cmap + TERM_PUSH_SHIFT + nchars, - tty->cmap + tty->next, tty->cnt); - } - - /* Put the new characters into the queue. */ - tty->next = TERM_PUSH_SHIFT; - tty->cnt += nchars; - MEMMOVE(tty->ch + TERM_PUSH_SHIFT, s, nchars); - MEMSET(tty->chf + TERM_PUSH_SHIFT, flags, nchars); - MEMSET(tty->cmap + TERM_PUSH_SHIFT, cmap, nchars); - return (0); -} - -/* - * Remove characters from the queue, simultaneously clearing the flag - * and map counts. - */ -#define QREM_HEAD(q, len) { \ - size_t __off = (q)->next; \ - if (len == 1) { \ - tty->chf[__off] = 0; \ - tty->cmap[__off] = 0; \ - } else { \ - MEMSET(tty->chf + __off, 0, len); \ - MEMSET(tty->cmap + __off, 0, len); \ - } \ - if (((q)->cnt -= len) == 0) \ - (q)->next = 0; \ - else \ - (q)->next += len; \ -} -#define QREM_TAIL(q, len) { \ - size_t __off = (q)->next + (q)->cnt - 1; \ - if (len == 1) { \ - tty->chf[__off] = 0; \ - tty->cmap[__off] = 0; \ - } else { \ - MEMSET(tty->chf + __off, 0, len); \ - MEMSET(tty->cmap + __off, 0, len); \ - } \ - if (((q)->cnt -= len) == 0) \ - (q)->next = 0; \ -} - -/* - * term_key -- - * Get the next key. - * - * !!! - * The flag TXT_MAPNODIGIT probably needs some explanation. First, the idea - * of mapping keys is that one or more keystrokes act like a function key. - * What's going on is that vi is reading a number, and the character following - * the number may or may not be mapped (TXT_MAPCOMMAND). For example, if the - * user is entering the z command, a valid command is "z40+", and we don't want - * to map the '+', i.e. if '+' is mapped to "xxx", we don't want to change it - * into "z40xxx". However, if the user enters "35x", we want to put all of the - * characters through the mapping code. - * - * Historical practice is a bit muddled here. (Surprise!) It always permitted - * mapping digits as long as they weren't the first character of the map, e.g. - * ":map ^A1 xxx" was okay. It also permitted the mapping of the digits 1-9 - * (the digit 0 was a special case as it doesn't indicate the start of a count) - * as the first character of the map, but then ignored those mappings. While - * it's probably stupid to map digits, vi isn't your mother. - * - * The way this works is that the TXT_MAPNODIGIT causes term_key to return the - * end-of-digit without "looking" at the next character, i.e. leaving it as the - * user entered it. Presumably, the next term_key call will tell us how the - * user wants it handled. - * - * There is one more complication. Users might map keys to digits, and, as - * it's described above, the commands "map g 1G|d2g" would return the keys - * "d2<end-of-digits>1G", when the user probably wanted "d21<end-of-digits>G". - * So, if a map starts off with a digit we continue as before, otherwise, we - * pretend that we haven't mapped the character and return <end-of-digits>. - * - * Now that that's out of the way, let's talk about Energizer Bunny macros. - * It's easy to create macros that expand to a loop, e.g. map x 3x. It's - * fairly easy to detect this example, because it's all internal to term_key. - * If we're expanding a macro and it gets big enough, at some point we can - * assume it's looping and kill it. The examples that are tough are the ones - * where the parser is involved, e.g. map x "ayyx"byy. We do an expansion - * on 'x', and get "ayyx"byy. We then return the first 4 characters, and then - * find the looping macro again. There is no way that we can detect this - * without doing a full parse of the command, because the character that might - * cause the loop (in this case 'x') may be a literal character, e.g. the map - * map x "ayy"xyy"byy is perfectly legal and won't cause a loop. - * - * Historic vi tried to detect looping macros by disallowing obvious cases in - * the map command, maps that that ended with the same letter as they started - * (which wrongly disallowed "map x 'x"), and detecting macros that expanded - * too many times before keys were returned to the command parser. It didn't - * get many (most?) of the tricky cases right, however, and it was certainly - * possible to create macros that ran forever. And, even if it did figure out - * what was going on, the user was usually tossed into ex mode. Finally, any - * changes made before vi realized that the macro was recursing were left in - * place. This implementation counts how many times each input character has - * been mapped. If it reaches some arbitrary value, we flush all mapped keys - * and return an error. - * - * XXX - * The final issue is recovery. It would be possible to undo all of the work - * that was done by the macro if we entered a record into the log so that we - * knew when the macro started, and, in fact, this might be worth doing at some - * point. Given that this might make the log grow unacceptably (consider that - * cursor keys are done with maps), for now we leave any changes made in place. - */ -enum input -term_key(sp, chp, flags) - SCR *sp; - CH *chp; - u_int flags; -{ - enum input rval; - struct timeval t, *tp; - CHAR_T ch; - GS *gp; - IBUF *tty; - SEQ *qp; - int cmap, ispartial, nr, itear; - - gp = sp->gp; - tty = gp->tty; - - /* - * If the queue is empty, read more keys in. Since no timeout is - * requested, s_key_read will either return an error or will read - * some number of characters. - */ -loop: if (tty->cnt == 0) { - if (term_read_grow(sp, tty)) - return (INP_ERR); - if (rval = sp->s_key_read(sp, &nr, NULL)) - return (rval); - /* - * If there's something on the mode line that we wanted - * the user to see, they just entered a character so we - * can presume they saw it. - */ - if (F_ISSET(sp, S_UPDATE_MODE)) - F_CLR(sp, S_UPDATE_MODE); - } - - /* If no limit on remaps, set it up so the user can interrupt. */ - itear = O_ISSET(sp, O_REMAPMAX) ? 0 : !intr_init(sp); - - /* If the key is mappable and should be mapped, look it up. */ - if (!(tty->chf[tty->next] & CH_NOMAP) && - LF_ISSET(TXT_MAPCOMMAND | TXT_MAPINPUT)) { - /* Set up timeout value. */ - if (O_ISSET(sp, O_TIMEOUT)) { - tp = &t; - t.tv_sec = O_VAL(sp, O_KEYTIME) / 10; - t.tv_usec = (O_VAL(sp, O_KEYTIME) % 10) * 100000L; - } else - tp = NULL; - - /* Get the next key. */ -newmap: ch = tty->ch[tty->next]; - if (ch < MAX_BIT_SEQ && !bit_test(gp->seqb, ch)) - goto nomap; - - /* Search the map. */ -remap: qp = seq_find(sp, NULL, &tty->ch[tty->next], tty->cnt, - LF_ISSET(TXT_MAPCOMMAND) ? SEQ_COMMAND : SEQ_INPUT, - &ispartial); - - /* - * If get a partial match, read more characters and retry - * the map. If no characters read, return the characters - * unmapped. - */ - if (ispartial) { - if (term_read_grow(sp, tty)) { - rval = INP_ERR; - goto ret; - } - if (rval = sp->s_key_read(sp, &nr, tp)) - goto ret; - if (nr) - goto remap; - goto nomap; - } - - /* If no map, return the character. */ - if (qp == NULL) - goto nomap; - - /* - * If looking for the end of a digit string, and the first - * character of the map is it, pretend we haven't seen the - * character. - */ - if (LF_ISSET(TXT_MAPNODIGIT) && - qp->output != NULL && !isdigit(qp->output[0])) - goto not_digit_ch; - - /* - * Only permit a character to be remapped a certain number - * of times before we figure that it's not going to finish. - */ - if (O_ISSET(sp, O_REMAPMAX)) { - if ((cmap = tty->cmap[tty->next]) > MAX_MAP_COUNT) - goto flush; - } else if (F_ISSET(sp, S_INTERRUPTED)) { -flush: term_map_flush(sp, "Character remapped too many times"); - rval = INP_ERR; - goto ret; - } else - cmap = 0; - - /* Delete the mapped characters from the queue. */ - QREM_HEAD(tty, qp->ilen); - - /* If keys mapped to nothing, go get more. */ - if (qp->output == NULL) - goto loop; - - /* If remapping characters, push the character on the queue. */ - if (O_ISSET(sp, O_REMAP)) { - if (term_push(sp, qp->output, qp->olen, ++cmap, 0)) { - rval = INP_ERR; - goto ret; - } - goto newmap; - } - - /* Else, push the characters on the queue and return one. */ - if (term_push(sp, qp->output, qp->olen, 0, CH_NOMAP)) { - rval = INP_ERR; - goto ret; - } - } - -nomap: ch = tty->ch[tty->next]; - if (LF_ISSET(TXT_MAPNODIGIT) && !isdigit(ch)) { -not_digit_ch: chp->ch = NOT_DIGIT_CH; - chp->value = 0; - chp->flags = 0; - rval = INP_OK; - goto ret; - } - - /* Fill in the return information. */ - chp->ch = ch; - chp->flags = tty->chf[tty->next]; - chp->value = term_key_val(sp, ch); - - /* Delete the character from the queue. */ - QREM_HEAD(tty, 1); - rval = INP_OK; - -ret: if (itear) - intr_end(sp); - return (rval); -} - -/* - * term_ab_flush -- - * Flush any abbreviated keys. - */ -void -term_ab_flush(sp, msg) - SCR *sp; - char *msg; -{ - IBUF *tty; - - tty = sp->gp->tty; - if (!tty->cnt || !(tty->chf[tty->next] & CH_ABBREVIATED)) - return; - do { - QREM_HEAD(tty, 1); - } while (tty->cnt && tty->chf[tty->next] & CH_ABBREVIATED); - msgq(sp, M_ERR, "%s: keys flushed.", msg); -} - -/* - * term_map_flush -- - * Flush any mapped keys. - */ -void -term_map_flush(sp, msg) - SCR *sp; - char *msg; -{ - IBUF *tty; - - tty = sp->gp->tty; - if (!tty->cnt || !tty->cmap[tty->next]) - return; - do { - QREM_HEAD(tty, 1); - } while (tty->cnt && tty->cmap[tty->next]); - msgq(sp, M_ERR, "%s: keys flushed.", msg); -} - -/* - * term_user_key -- - * Get the next key, but require the user enter one. - */ -enum input -term_user_key(sp, chp) - SCR *sp; - CH *chp; -{ - enum input rval; - IBUF *tty; - int nr; - - /* - * Read any keys the user has waiting. Make the race - * condition as short as possible. - */ - if (rval = term_key_queue(sp)) - return (rval); - - /* Wait and read another key. */ - if (rval = sp->s_key_read(sp, &nr, NULL)) - return (rval); - - /* Fill in the return information. */ - tty = sp->gp->tty; - chp->ch = tty->ch[tty->next + (tty->cnt - 1)]; - chp->flags = 0; - chp->value = term_key_val(sp, chp->ch); - - QREM_TAIL(tty, 1); - return (INP_OK); -} - -/* - * term_key_queue -- - * Read the keys off of the terminal queue until it's empty. - */ -int -term_key_queue(sp) - SCR *sp; -{ - enum input rval; - struct timeval t; - IBUF *tty; - int nr; - - t.tv_sec = 0; - t.tv_usec = 0; - for (tty = sp->gp->tty;;) { - if (term_read_grow(sp, tty)) - return (INP_ERR); - if (rval = sp->s_key_read(sp, &nr, &t)) - return (rval); - if (nr == 0) - break; - } - return (INP_OK); -} - -/* - * __term_key_val -- - * Fill in the value for a key. This routine is the backup - * for the term_key_val() macro. - */ -int -__term_key_val(sp, ch) - SCR *sp; - ARG_CHAR_T ch; -{ - KEYLIST k, *kp; - - k.ch = ch; - kp = bsearch(&k, keylist, nkeylist, sizeof(keylist[0]), keycmp); - return (kp == NULL ? K_NOTUSED : kp->value); -} - -/* - * __term_read_grow -- - * Grow the terminal queue. This routine is the backup for - * the term_read_grow() macro. - */ -static int -__term_read_grow(sp, tty, add) - SCR *sp; - IBUF *tty; - int add; -{ - size_t new_nelem, olen; - - new_nelem = tty->nelem + add; - olen = tty->nelem * sizeof(tty->ch[0]); - BINC_RET(sp, tty->ch, olen, new_nelem * sizeof(tty->ch[0])); - - olen = tty->nelem * sizeof(tty->chf[0]); - BINC_RET(sp, tty->chf, olen, new_nelem * sizeof(tty->chf[0])); - - olen = tty->nelem * sizeof(tty->cmap[0]); - BINC_RET(sp, tty->cmap, olen, new_nelem * sizeof(tty->cmap[0])); - - tty->nelem = new_nelem; - return (0); -} - -static int -keycmp(ap, bp) - const void *ap, *bp; -{ - return (((KEYLIST *)ap)->ch - ((KEYLIST *)bp)->ch); -} diff --git a/usr.bin/vi/term.h b/usr.bin/vi/term.h deleted file mode 100644 index 5b224cc01562..000000000000 --- a/usr.bin/vi/term.h +++ /dev/null @@ -1,201 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)term.h 8.37 (Berkeley) 3/22/94 - */ - -/* - * Fundamental character types. - * - * CHAR_T An integral type that can hold any character. - * ARG_CHAR_T The type of a CHAR_T when passed as an argument using - * traditional promotion rules. It should also be able - * to be compared against any CHAR_T for equality without - * problems. - * MAX_CHAR_T The maximum value of any character. - * - * If no integral type can hold a character, don't even try the port. - */ -typedef u_char CHAR_T; -typedef u_int ARG_CHAR_T; -#define MAX_CHAR_T 0xff - -/* The maximum number of columns any character can take up on a screen. */ -#define MAX_CHARACTER_COLUMNS 4 - -/* Structure to return a character and associated information. */ -struct _ch { - CHAR_T ch; /* Character. */ - -#define K_NOTUSED 0 -#define K_CARAT 1 -#define K_CNTRLD 2 -#define K_CNTRLR 3 -#define K_CNTRLT 4 -#define K_CNTRLZ 5 -#define K_COLON 6 -#define K_CR 7 -#define K_ESCAPE 8 -#define K_FORMFEED 9 -#define K_NL 10 -#define K_RIGHTBRACE 11 -#define K_RIGHTPAREN 12 -#define K_TAB 13 -#define K_VERASE 14 -#define K_VINTR 15 -#define K_VKILL 16 -#define K_VLNEXT 17 -#define K_VWERASE 18 -#define K_ZERO 19 - u_int8_t value; /* Special character flag values. */ - -#define CH_ABBREVIATED 0x01 /* Character from an abbreviation. */ -#define CH_NOMAP 0x02 /* Do not attempt to map the character. */ -#define CH_QUOTED 0x04 /* Character is already quoted. */ - u_int8_t flags; -}; - -/* Structure for the key input buffer. */ -struct _ibuf { - CHAR_T *ch; /* Array of characters. */ - u_int8_t *chf; /* Array of character flags (CH_*). */ -#define MAX_MAP_COUNT 50 /* Infinite loop check. */ - u_int8_t *cmap; /* Number of times character has been mapped. */ - - size_t cnt; /* Count of remaining characters. */ - size_t nelem; /* Numer of array elements. */ - size_t next; /* Offset of next array entry. */ -}; - /* Return if more keys in queue. */ -#define KEYS_WAITING(sp) ((sp)->gp->tty->cnt) -#define MAPPED_KEYS_WAITING(sp) \ - (KEYS_WAITING(sp) && sp->gp->tty->cmap[sp->gp->tty->next]) - -/* - * Structure to name a character. Used both as an interface to the - * screen and to name objects named by characters in error messages. - */ -struct _chname { - char *name; /* Character name. */ - u_int8_t len; /* Length of the character name. */ -}; - -/* - * Routines that return a key as a side-effect return: - * - * INP_OK Returning a character; must be 0. - * INP_EOF EOF. - * INP_ERR Error. - * - * The vi structure depends on the key routines being able to return INP_EOF - * multiple times without failing -- eventually enough things will end due to - * INP_EOF that vi will reach the command level for the screen, at which point - * the exit flags will be set and vi will exit. - */ -enum input { INP_OK=0, INP_EOF, INP_ERR }; - -/* - * Routines that return a confirmation return: - * - * CONF_NO User answered no. - * CONF_QUIT User answered quit, eof or an error. - * CONF_YES User answered yes. - */ -enum confirm { CONF_NO, CONF_QUIT, CONF_YES }; - -/* - * Ex/vi commands are generally separated by whitespace characters. We - * can't use the standard isspace(3) macro because it returns true for - * characters like ^K in the ASCII character set. The 4.4BSD isblank(3) - * macro does exactly what we want, but it's not portable yet. - * - * XXX - * Note side effect, ch is evaluated multiple times. - */ -#ifndef isblank -#define isblank(ch) ((ch) == ' ' || (ch) == '\t') -#endif - -/* The "standard" tab width, for displaying things to users. */ -#define STANDARD_TAB 6 - -/* Various special characters, messages. */ -#define CURSOR_CH ' ' /* Cursor character. */ -#define END_CH '$' /* End of a range. */ -#define HEX_CH 'x' /* Leading hex number. */ -#define LITERAL_CH '\026' /* Standard literal ^V. */ -#define NOT_DIGIT_CH 'a' /* A non-isdigit() character. */ -#define NO_CH 'n' /* No. */ -#define QUIT_CH 'q' /* Quit. */ -#define YES_CH 'y' /* Yes. */ - -#define CONFSTRING "confirm? [ynq]" -#define CONTMSG "Enter return to continue: " -#define CONTMSG_I "Enter return to continue [q to quit]: " - -/* Flags describing how input is handled. */ -#define TXT_AICHARS 0x0000001 /* Leading autoindent chars. */ -#define TXT_ALTWERASE 0x0000002 /* Option: altwerase. */ -#define TXT_APPENDEOL 0x0000004 /* Appending after EOL. */ -#define TXT_AUTOINDENT 0x0000008 /* Autoindent set this line. */ -#define TXT_BEAUTIFY 0x0000010 /* Only printable characters. */ -#define TXT_BS 0x0000020 /* Backspace returns the buffer. */ -#define TXT_CNTRLD 0x0000040 /* Control-D is a special command. */ -#define TXT_CNTRLT 0x0000080 /* Control-T is an indent special. */ -#define TXT_CR 0x0000100 /* CR returns the buffer. */ -#define TXT_EMARK 0x0000200 /* End of replacement mark. */ -#define TXT_ESCAPE 0x0000400 /* Escape returns the buffer. */ -#define TXT_INFOLINE 0x0000800 /* Editing the info line. */ -#define TXT_MAPCOMMAND 0x0001000 /* Apply the command map. */ -#define TXT_MAPINPUT 0x0002000 /* Apply the input map. */ -#define TXT_MAPNODIGIT 0x0004000 /* Return to a digit. */ -#define TXT_NLECHO 0x0008000 /* Echo the newline. */ -#define TXT_OVERWRITE 0x0010000 /* Overwrite characters. */ -#define TXT_PROMPT 0x0020000 /* Display a prompt. */ -#define TXT_RECORD 0x0040000 /* Record for replay. */ -#define TXT_REPLACE 0x0080000 /* Replace; don't delete overwrite. */ -#define TXT_REPLAY 0x0100000 /* Replay the last input. */ -#define TXT_RESOLVE 0x0200000 /* Resolve the text into the file. */ -#define TXT_SHOWMATCH 0x0400000 /* Option: showmatch. */ -#define TXT_TTYWERASE 0x0800000 /* Option: ttywerase. */ -#define TXT_WRAPMARGIN 0x1000000 /* Option: wrapmargin. */ - -/* Support keyboard routines. */ -int __term_key_val __P((SCR *, ARG_CHAR_T)); -void term_ab_flush __P((SCR *, char *)); -int term_init __P((SCR *)); -enum input term_key __P((SCR *, CH *, u_int)); -int term_key_queue __P((SCR *)); -void term_map_flush __P((SCR *, char *)); -int term_push __P((SCR *, CHAR_T *, size_t, u_int, u_int)); -enum input term_user_key __P((SCR *, CH *)); -int term_waiting __P((SCR *)); diff --git a/usr.bin/vi/timer.c b/usr.bin/vi/timer.c deleted file mode 100644 index d7fc9c6b1772..000000000000 --- a/usr.bin/vi/timer.c +++ /dev/null @@ -1,237 +0,0 @@ -/*- - * Copyright (c) 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)timer.c 8.13 (Berkeley) 3/23/94"; -#endif /* not lint */ - -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <termios.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" - -/* - * There are two uses of the ITIMER_REAL timer (SIGALRM) in nvi. The first - * is to push the recovery information out to disk at periodic intervals. - * The second is to display a "busy" message if an operation takes more time - * that users are willing to wait before seeing something happen. Each of - * these uses has a wall clock timer structure in each SCR structure. Since - * the busy timer has a much faster timeout than the recovery timer, most of - * the code ignores the recovery timer unless it's the only thing running. - * - * XXX - * It would be nice to reimplement this with two timers, a la POSIX 1003.1, - * but not many systems offer them yet. - */ - -/* - * busy_on -- - * Set a busy message timer. - */ -int -busy_on(sp, msg) - SCR *sp; - char const *msg; -{ - struct itimerval value; - struct timeval tod; - - /* - * Give the oldest busy message precedence, since it's - * the longer running operation. - */ - if (sp->busy_msg != NULL) - return (1); - - /* Get the current time of day, and create a target time. */ - if (gettimeofday(&tod, NULL)) - return (1); -#define USER_PATIENCE_USECS (8 * 100000L) - sp->busy_tod.tv_sec = tod.tv_sec; - sp->busy_tod.tv_usec = tod.tv_usec + USER_PATIENCE_USECS; - - /* We depend on this being an atomic instruction. */ - sp->busy_msg = msg; - - /* - * Busy messages turn around fast. Reset the timer regardless - * of its current state. - */ - value.it_value.tv_sec = 0; - value.it_value.tv_usec = USER_PATIENCE_USECS; - value.it_interval.tv_sec = 0; - value.it_interval.tv_usec = 0; - if (setitimer(ITIMER_REAL, &value, NULL)) - msgq(sp, M_SYSERR, "timer: setitimer"); - return (0); -} - -/* - * busy_off -- - * Turn off a busy message timer. - */ -void -busy_off(sp) - SCR *sp; -{ - /* We depend on this being an atomic instruction. */ - sp->busy_msg = NULL; -} - -/* - * rcv_on -- - * Turn on recovery timer. - */ -int -rcv_on(sp, ep) - SCR *sp; - EXF *ep; -{ - struct itimerval value; - struct timeval tod; - - /* Get the current time of day. */ - if (gettimeofday(&tod, NULL)) - return (1); - - /* Create target time of day. */ - ep->rcv_tod.tv_sec = tod.tv_sec + RCV_PERIOD; - ep->rcv_tod.tv_usec = 0; - - /* - * If there's a busy message happening, we're done, the - * interrupt handler will start our timer as necessary. - */ - if (sp->busy_msg != NULL) - return (0); - - value.it_value.tv_sec = RCV_PERIOD; - value.it_value.tv_usec = 0; - value.it_interval.tv_sec = 0; - value.it_interval.tv_usec = 0; - if (setitimer(ITIMER_REAL, &value, NULL)) { - msgq(sp, M_SYSERR, "timer: setitimer"); - return (1); - } - return (0); -} - -/* - * h_alrm -- - * Handle SIGALRM. - */ -void -h_alrm(signo) - int signo; -{ - struct itimerval value; - struct timeval ntod, tod; - SCR *sp; - EXF *ep; - - /* XXX: Get the current time of day; if this fails, we're dead. */ - if (gettimeofday(&tod, NULL)) - return; - - /* - * Fire any timers that are past due, or any that are due - * in a tenth of a second or less. - */ - for (ntod.tv_sec = 0, sp = __global_list->dq.cqh_first; - sp != (void *)&__global_list->dq; sp = sp->q.cqe_next) { - - /* Check the busy timer if the msg pointer is set. */ - if (sp->busy_msg == NULL) - goto skip_busy; - if (sp->busy_tod.tv_sec > tod.tv_sec || - sp->busy_tod.tv_sec == tod.tv_sec && - sp->busy_tod.tv_usec > tod.tv_usec && - sp->busy_tod.tv_usec - tod.tv_usec > 100000L) { - if (ntod.tv_sec == 0 || - ntod.tv_sec > sp->busy_tod.tv_sec || - ntod.tv_sec == sp->busy_tod.tv_sec && - ntod.tv_usec > sp->busy_tod.tv_usec) - ntod = sp->busy_tod; - } else { - (void)sp->s_busy(sp, sp->busy_msg); - sp->busy_msg = NULL; - } - - /* - * Check the recovery timer if there's an EXF structure - * and the recovery bit is set. - */ -skip_busy: if ((ep = sp->ep) == NULL || !F_ISSET(sp->ep, F_RCV_ON)) - continue; - if (ep->rcv_tod.tv_sec > tod.tv_sec || - ep->rcv_tod.tv_sec == tod.tv_sec && - ep->rcv_tod.tv_usec > tod.tv_usec && - ep->rcv_tod.tv_usec - tod.tv_usec > 100000L) { - if (ntod.tv_sec == 0 || - ntod.tv_sec > ep->rcv_tod.tv_sec || - ntod.tv_sec == ep->rcv_tod.tv_sec && - ntod.tv_usec > ep->rcv_tod.tv_usec) - ntod = ep->rcv_tod; - } else { - F_SET(sp->gp, G_SIGALRM); - ep->rcv_tod = tod; - ep->rcv_tod.tv_sec += RCV_PERIOD; - - if (ntod.tv_sec == 0 || - ntod.tv_sec > ep->rcv_tod.tv_sec || - ntod.tv_sec == ep->rcv_tod.tv_sec && - ntod.tv_usec > ep->rcv_tod.tv_usec) - ntod = ep->rcv_tod; - } - } - - if (ntod.tv_sec == 0) - return; - - /* XXX: Set the timer; if this fails, we're dead. */ - value.it_value.tv_sec = ntod.tv_sec - tod.tv_sec; - value.it_value.tv_usec = ntod.tv_usec - tod.tv_usec; - value.it_interval.tv_sec = 0; - value.it_interval.tv_usec = 0; - (void)setitimer(ITIMER_REAL, &value, NULL); -} diff --git a/usr.bin/vi/trace.c b/usr.bin/vi/trace.c deleted file mode 100644 index 1f63f6628a2e..000000000000 --- a/usr.bin/vi/trace.c +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)trace.c 8.2 (Berkeley) 3/8/94 - */ - -#ifdef DEBUG -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <termios.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" - -#ifdef __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -void -#ifdef __STDC__ -TRACE(SCR *sp, const char *fmt, ...) -#else -TRACE(sp, fmt, va_alist) - SCR *sp; - char *fmt; - va_dcl -#endif -{ - FILE *tfp; - va_list ap; - - if ((tfp = sp->gp->tracefp) == NULL) - return; -#ifdef __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)vfprintf(tfp, fmt, ap); - va_end(ap); - - (void)fflush(tfp); -} -#endif diff --git a/usr.bin/vi/util.c b/usr.bin/vi/util.c deleted file mode 100644 index c367c9a01519..000000000000 --- a/usr.bin/vi/util.c +++ /dev/null @@ -1,625 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)util.c 8.44 (Berkeley) 3/15/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <ctype.h> -#include <curses.h> -#include <errno.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> - -#ifdef __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" - -/* - * msgq -- - * Display a message. - */ -void -#ifdef __STDC__ -msgq(SCR *sp, enum msgtype mt, const char *fmt, ...) -#else -msgq(sp, mt, fmt, va_alist) - SCR *sp; - enum msgtype mt; - char *fmt; - va_dcl -#endif -{ - va_list ap; - int len; - char msgbuf[1024]; - -#ifdef __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - /* - * It's possible to enter msg when there's no screen to hold - * the message. Always check sp before using it, and, if it's - * NULL, use __global_list. - */ - switch (mt) { - case M_BERR: - if (sp != NULL && !F_ISSET(sp, S_EXSILENT) && - F_ISSET(sp->gp, G_STDIN_TTY) && !O_ISSET(sp, O_VERBOSE)) { - F_SET(sp, S_BELLSCHED); - return; - } - mt = M_ERR; - break; - case M_VINFO: - if (sp == NULL || !O_ISSET(sp, O_VERBOSE)) - return; - mt = M_INFO; - /* FALLTHROUGH */ - case M_INFO: - if (F_ISSET(sp, S_EXSILENT)) - return; - break; - case M_ERR: - case M_SYSERR: - break; - default: - abort(); - } - - /* Length is the min length of the message or the buffer. */ - if (mt == M_SYSERR) - if (sp->if_name != NULL) - len = snprintf(msgbuf, sizeof(msgbuf), - "Error: %s, %d: %s%s%s.", sp->if_name, sp->if_lno, - fmt == NULL ? "" : fmt, fmt == NULL ? "" : ": ", - strerror(errno)); - else - len = snprintf(msgbuf, sizeof(msgbuf), - "Error: %s%s%s.", - fmt == NULL ? "" : fmt, fmt == NULL ? "" : ": ", - strerror(errno)); - else { - len = sp->if_name == NULL ? 0 : snprintf(msgbuf, sizeof(msgbuf), - "%s, %d: ", sp->if_name, sp->if_lno); - len += vsnprintf(msgbuf + len, sizeof(msgbuf) - len, fmt, ap); - } - - /* - * If len >= the size, some characters were discarded. - * Ignore trailing nul. - */ - if (len >= sizeof(msgbuf)) - len = sizeof(msgbuf) - 1; - - msg_app(__global_list, sp, mt == M_ERR ? 1 : 0, msgbuf, len); -} - -/* - * msg_app -- - * Append a message into the queue. This can fail, but there's - * nothing we can do if it does. - */ -void -msg_app(gp, sp, inv_video, p, len) - GS *gp; - SCR *sp; - int inv_video; - char *p; - size_t len; -{ - static int reenter; /* STATIC: Re-entrancy check. */ - MSG *mp, *nmp; - - /* - * It's possible to reenter msg when it allocates space. - * We're probably dead anyway, but no reason to drop core. - */ - if (reenter) - return; - reenter = 1; - - /* - * Find an empty structure, or allocate a new one. Use the - * screen structure if possible, otherwise the global one. - */ - if (sp != NULL) { - if ((mp = sp->msgq.lh_first) == NULL) { - CALLOC(sp, mp, MSG *, 1, sizeof(MSG)); - if (mp == NULL) - goto ret; - LIST_INSERT_HEAD(&sp->msgq, mp, q); - goto store; - } - } else if ((mp = gp->msgq.lh_first) == NULL) { - CALLOC(sp, mp, MSG *, 1, sizeof(MSG)); - if (mp == NULL) - goto ret; - LIST_INSERT_HEAD(&gp->msgq, mp, q); - goto store; - } - while (!F_ISSET(mp, M_EMPTY) && mp->q.le_next != NULL) - mp = mp->q.le_next; - if (!F_ISSET(mp, M_EMPTY)) { - CALLOC(sp, nmp, MSG *, 1, sizeof(MSG)); - if (nmp == NULL) - goto ret; - LIST_INSERT_AFTER(mp, nmp, q); - mp = nmp; - } - - /* Get enough memory for the message. */ -store: if (len > mp->blen && binc(sp, &mp->mbuf, &mp->blen, len)) - goto ret; - - /* Store the message. */ - memmove(mp->mbuf, p, len); - mp->len = len; - mp->flags = inv_video ? M_INV_VIDEO : 0; - -ret: reenter = 0; -} - -/* - * msgrpt -- - * Report on the lines that changed. - * - * !!! - * Historic vi documentation (USD:15-8) claimed that "The editor will also - * always tell you when a change you make affects text which you cannot see." - * This isn't true -- edit a large file and do "100d|1". We don't implement - * this semantic as it would require that we track each line that changes - * during a command instead of just keeping count. - * - * Line counts weren't right in historic vi, either. For example, given the - * file: - * abc - * def - * the command 2d}, from the 'b' would report that two lines were deleted, - * not one. - */ -int -msg_rpt(sp, is_message) - SCR *sp; - int is_message; -{ - static const char *const action[] = { - "added", "changed", "copied", "deleted", "joined", "moved", - "put", "left shifted", "right shifted", "yanked", NULL, - }; - recno_t total; - u_long rval; - int first, cnt; - size_t blen, len; - const char *const *ap; - char *bp, *p, number[40]; - - if (F_ISSET(sp, S_EXSILENT)) - return (0); - - if ((rval = O_VAL(sp, O_REPORT)) == 0) - goto norpt; - - GET_SPACE_RET(sp, bp, blen, 512); - p = bp; - - total = 0; - for (ap = action, cnt = 0, first = 1; *ap != NULL; ++ap, ++cnt) - if (sp->rptlines[cnt] != 0) { - total += sp->rptlines[cnt]; - len = snprintf(number, sizeof(number), - "%s%lu line%s %s", first ? "" : "; ", - sp->rptlines[cnt], - sp->rptlines[cnt] > 1 ? "s" : "", *ap); - memmove(p, number, len); - p += len; - first = 0; - } - - /* - * If nothing to report, return. Note that the number of lines - * must be > than the user's value, not >=. This is historic - * practice and means that users cannot report on single line - * changes. - */ - if (total > rval) { - *p = '\0'; - - if (is_message) - msgq(sp, M_INFO, "%s", bp); - else - ex_printf(EXCOOKIE, "%s\n", bp); - } - - FREE_SPACE(sp, bp, blen); - - /* Clear after each report. */ -norpt: memset(sp->rptlines, 0, sizeof(sp->rptlines)); - return (0); -} - -/* - * binc -- - * Increase the size of a buffer. - */ -int -binc(sp, argp, bsizep, min) - SCR *sp; /* sp MAY BE NULL!!! */ - void *argp; - size_t *bsizep, min; -{ - size_t csize; - void *bpp; - - /* If already larger than the minimum, just return. */ - if (min && *bsizep >= min) - return (0); - - /* - * If the initial pointer is null, use calloc (for non-ANSI - * C realloc implementations). - */ - bpp = *(char **)argp; - csize = *bsizep + MAX(min, 256); - if (bpp == NULL) { - MALLOC(sp, bpp, void *, csize); - } else - REALLOC(sp, bpp, void *, csize); - - if (bpp == NULL) { - /* - * Theoretically, realloc is supposed to leave any already - * held memory alone if it can't get more. Don't trust it. - */ - *bsizep = 0; - return (1); - } - /* - * Memory is guaranteed to be zero-filled, various parts of - * nvi depend on this. - */ - memset((char *)bpp + *bsizep, 0, csize - *bsizep); - *(char **)argp = bpp; - *bsizep = csize; - return (0); -} -/* - * nonblank -- - * Set the column number of the first non-blank character - * including or after the starting column. On error, set - * the column to 0, it's safest. - */ -int -nonblank(sp, ep, lno, cnop) - SCR *sp; - EXF *ep; - recno_t lno; - size_t *cnop; -{ - char *p; - size_t cnt, len, off; - - /* Default. */ - off = *cnop; - *cnop = 0; - - /* Get the line. */ - if ((p = file_gline(sp, ep, lno, &len)) == NULL) { - if (file_lline(sp, ep, &lno)) - return (1); - if (lno == 0) - return (0); - GETLINE_ERR(sp, lno); - return (1); - } - - /* Set the offset. */ - if (len == 0 || off >= len) - return (0); - - for (cnt = off, p = &p[off], - len -= off; len && isblank(*p); ++cnt, ++p, --len); - - /* Set the return. */ - *cnop = len ? cnt : cnt - 1; - return (0); -} - -/* - * tail -- - * Return tail of a path. - */ -char * -tail(path) - char *path; -{ - char *p; - - if ((p = strrchr(path, '/')) == NULL) - return (path); - return (p + 1); -} - -/* - * set_window_size -- - * Set the window size, the row may be provided as an argument. - */ -int -set_window_size(sp, set_row, ign_env) - SCR *sp; - u_int set_row; - int ign_env; -{ - struct winsize win; - size_t col, row; - int user_set; - ARGS *argv[2], a, b; - char *s, buf[2048]; - - /* - * Get the screen rows and columns. If the values are wrong, it's - * not a big deal -- as soon as the user sets them explicitly the - * environment will be set and the screen package will use the new - * values. - * - * Try TIOCGWINSZ. - */ - row = col = 0; -#ifdef TIOCGWINSZ - if (ioctl(STDERR_FILENO, TIOCGWINSZ, &win) != -1) { - row = win.ws_row; - col = win.ws_col; - } -#endif - - /* If TIOCGWINSZ failed, or had entries of 0, try termcap. */ - if (row == 0 || col == 0) { - s = NULL; - if (F_ISSET(&sp->opts[O_TERM], OPT_SET)) - s = O_STR(sp, O_TERM); - else - s = getenv("TERM"); - if (s != NULL && tgetent(buf, s) == 1) { - if (row == 0) - row = tgetnum("li"); - if (col == 0) - col = tgetnum("co"); - } - } - /* If nothing else, well, it's probably a VT100. */ - if (row == 0) - row = 24; - if (col == 0) - col = 80; - - /* - * POSIX 1003.2 requires the environment to override, however, - * if we're here because of a signal, we don't want to use the - * old values. - */ - if (!ign_env) { - if ((s = getenv("LINES")) != NULL) - row = strtol(s, NULL, 10); - if ((s = getenv("COLUMNS")) != NULL) - col = strtol(s, NULL, 10); - } - - /* But, if we got an argument for the rows, use it. */ - if (set_row) - row = set_row; - - a.bp = buf; - b.bp = NULL; - b.len = 0; - argv[0] = &a; - argv[1] = &b;; - - /* - * Tell the options code that the screen size has changed. - * Since the user didn't do the set, clear the set bits. - */ - user_set = F_ISSET(&sp->opts[O_LINES], OPT_SET); - a.len = snprintf(buf, sizeof(buf), "lines=%u", row); - if (opts_set(sp, argv)) - return (1); - if (user_set) - F_CLR(&sp->opts[O_LINES], OPT_SET); - user_set = F_ISSET(&sp->opts[O_COLUMNS], OPT_SET); - a.len = snprintf(buf, sizeof(buf), "columns=%u", col); - if (opts_set(sp, argv)) - return (1); - if (user_set) - F_CLR(&sp->opts[O_COLUMNS], OPT_SET); - return (0); -} - -/* - * set_alt_name -- - * Set the alternate file name. - * - * Swap the alternate file name. It's a routine because I wanted some place - * to hang this comment. The alternate file name (normally referenced using - * the special character '#' during file expansion) is set by many - * operations. In the historic vi, the commands "ex", and "edit" obviously - * set the alternate file name because they switched the underlying file. - * Less obviously, the "read", "file", "write" and "wq" commands set it as - * well. In this implementation, some new commands have been added to the - * list. Where it gets interesting is that the alternate file name is set - * multiple times by some commands. If an edit attempt fails (for whatever - * reason, like the current file is modified but as yet unwritten), it is - * set to the file name that the user was unable to edit. If the edit - * succeeds, it is set to the last file name that was edited. Good fun. - * - * If the user edits a temporary file, there are time when there isn't an - * alternative file name. A name argument of NULL turns it off. - */ -void -set_alt_name(sp, name) - SCR *sp; - char *name; -{ - if (sp->alt_name != NULL) - FREE(sp->alt_name, strlen(sp->alt_name) + 1); - if (name == NULL) - sp->alt_name = NULL; - else if ((sp->alt_name = strdup(name)) == NULL) - msgq(sp, M_SYSERR, NULL); -} - -/* - * baud_from_bval -- - * Return the baud rate using the standard defines. - */ -u_long -baud_from_bval(sp) - SCR *sp; -{ - speed_t v; - - if (!F_ISSET(sp->gp, G_TERMIOS_SET)) - return (9600); - - switch (v = cfgetospeed(&sp->gp->original_termios)) { - case B50: - return (50); - case B75: - return (75); - case B110: - return (110); - case B134: - return (134); - case B150: - return (150); - case B200: - return (200); - case B300: - return (300); - case B600: - return (600); - case B1200: - return (1200); - case B1800: - return (1800); - case B2400: - return (2400); - case B4800: - return (4800); -#ifdef B7200 - case B7200: - return (7200); -#endif - case B0: /* Hangup -- ignore. */ - case B9600: - return (9600); -#ifdef B14400 - case B14400: - return (14400); -#endif - case B19200: - return (19200); -#ifdef B28800 - case B28800: - return (28800); -#endif - case B38400: - return (38400); -#ifdef B57600 - case B57600: - return (57600); -#endif -#ifdef B115200 - case B115200: - return (115200); -#endif -#ifdef B230400 - case B230400: - return (230400); -#endif - default: - /* - * EXTA and EXTB aren't required by POSIX 1003.1, and - * are almost certainly the same as some of the above - * values, so they can't be part of the case statement. - */ -#ifdef EXTA - if (v == EXTA) - return (19200); -#endif -#ifdef EXTB - if (v == EXTB) - return (38400); -#endif - msgq(sp, M_ERR, "Unknown terminal baud rate %u.\n", v); - return (9600); - } -} - -/* - * v_strdup -- - * Strdup for wide character strings with an associated length. - */ -CHAR_T * -v_strdup(sp, str, len) - SCR *sp; - CHAR_T *str; - size_t len; -{ - CHAR_T *copy; - - MALLOC(sp, copy, CHAR_T *, len); - if (copy == NULL) - return (NULL); - memmove(copy, str, len * sizeof(CHAR_T)); - return (copy); -} diff --git a/usr.bin/vi/vi.h b/usr.bin/vi/vi.h deleted file mode 100644 index e810a7e5c988..000000000000 --- a/usr.bin/vi/vi.h +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)vi.h 8.39 (Berkeley) 3/23/94 - */ - -/* - * Forward structure declarations. Not pretty, but the include files - * are far too interrelated for a clean solution. - */ -typedef struct _cb CB; -typedef struct _ch CH; -typedef struct _chname CHNAME; -typedef struct _excmdarg EXCMDARG; -typedef struct _exf EXF; -typedef struct _fref FREF; -typedef struct _gs GS; -typedef struct _ibuf IBUF; -typedef struct _lmark LMARK; -typedef struct _mark MARK; -typedef struct _msg MSG; -typedef struct _option OPTION; -typedef struct _optlist OPTLIST; -typedef struct _scr SCR; -typedef struct _script SCRIPT; -typedef struct _seq SEQ; -typedef struct _tag TAG; -typedef struct _tagf TAGF; -typedef struct _text TEXT; - -/* - * Local includes. - */ -#include "term.h" /* Required by args.h. */ -#include "args.h" /* Required by options.h. */ -#include "options.h" /* Required by screen.h. */ -#include "search.h" /* Required by screen.h. */ - -#include "msg.h" /* Required by gs.h. */ -#include "cut.h" /* Required by gs.h. */ -#include "gs.h" /* Required by screen.h. */ -#include "screen.h" /* Required by exf.h. */ -#include "mark.h" /* Required by exf.h. */ -#include "exf.h" -#include "log.h" -#include "mem.h" - -#if FWOPEN_NOT_AVAILABLE /* See PORT/clib/fwopen.c. */ -#define EXCOOKIE sp -int ex_fflush __P((SCR *)); -int ex_printf __P((SCR *, const char *, ...)); -FILE *fwopen __P((SCR *, void *)); -#else -#define EXCOOKIE sp->stdfp -#define ex_fflush fflush -#define ex_printf fprintf -#endif - -/* Macros to set/clear/test flags. */ -#define F_SET(p, f) (p)->flags |= (f) -#define F_CLR(p, f) (p)->flags &= ~(f) -#define F_ISSET(p, f) ((p)->flags & (f)) - -#define LF_INIT(f) flags = (f) -#define LF_SET(f) flags |= (f) -#define LF_CLR(f) flags &= ~(f) -#define LF_ISSET(f) (flags & (f)) - -/* - * XXX - * MIN/MAX have traditionally been in <sys/param.h>. Don't - * try to get them from there, it's just not worth the effort. - */ -#ifndef MAX -#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) -#endif -#ifndef MIN -#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) -#endif - -/* Function prototypes that don't seem to belong anywhere else. */ -u_long baud_from_bval __P((SCR *)); -char *charname __P((SCR *, ARG_CHAR_T)); -int nonblank __P((SCR *, EXF *, recno_t, size_t *)); -void set_alt_name __P((SCR *, char *)); -int set_window_size __P((SCR *, u_int, int)); -int status __P((SCR *, EXF *, recno_t, int)); -char *tail __P((char *)); -CHAR_T *v_strdup __P((SCR *, CHAR_T *, size_t)); - -#ifdef DEBUG -void TRACE __P((SCR *, const char *, ...)); -#endif - -/* Digraphs (not currently real). */ -int digraph __P((SCR *, int, int)); -int digraph_init __P((SCR *)); -void digraph_save __P((SCR *, int)); diff --git a/usr.bin/vi/vi/v_tag.c b/usr.bin/vi/vi/v_tag.c deleted file mode 100644 index 87315a788392..000000000000 --- a/usr.bin/vi/vi/v_tag.c +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)v_tag.c 8.4 (Berkeley) 3/8/94"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/queue.h> -#include <sys/time.h> - -#include <bitstring.h> -#include <limits.h> -#include <signal.h> -#include <stdio.h> -#include <string.h> -#include <termios.h> - -#include "compat.h" -#include <db.h> -#include <regex.h> - -#include "vi.h" -#include "excmd.h" -#include "vcmd.h" - -/* - * v_tagpush -- ^[ - * Do a tag search on a the cursor keyword. - */ -int -v_tagpush(sp, ep, vp) - SCR *sp; - EXF *ep; - VICMDARG *vp; -{ - EXCMDARG cmd; - - SETCMDARG(cmd, C_TAG, 0, OOBLNO, 0, 0, vp->keyword); - return (sp->s_ex_cmd(sp, ep, &cmd, &vp->m_final)); -} - -/* - * v_tagpop -- ^T - * Pop the tags stack. - */ -int -v_tagpop(sp, ep, vp) - SCR *sp; - EXF *ep; - VICMDARG *vp; -{ - EXCMDARG cmd; - - SETCMDARG(cmd, C_TAGPOP, 0, OOBLNO, 0, 0, NULL); - return (sp->s_ex_cmd(sp, ep, &cmd, &vp->m_final)); -} diff --git a/usr.sbin/amd/doc/amdref.vrs b/usr.sbin/amd/doc/amdref.vrs deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/usr.sbin/cron/CHANGES b/usr.sbin/cron/CHANGES deleted file mode 100644 index 59f6803dbc01..000000000000 --- a/usr.sbin/cron/CHANGES +++ /dev/null @@ -1,155 +0,0 @@ -Vixie Cron Changes from V2 to V3 -Paul Vixie -29-Dec-1993 - -The crontab command now conforms to POSIX 1003.2. This means that when you -install it, if you have any "crontab" command lines floating around in shell -scripts (such as /etc/rc or /etc/rc.local), you will need to change them. - -I have integrated several changes made by BSDi for their BSD/386 operating -system; these were offerred to me before I started consulting for them, so -it is safe to say that they were intended for publication. Most notably, -the name of the cron daemon has changed from "crond" to "cron". This was -done for compatibility with 4.3BSD. Another change made for the same reason -is the ability to read in an /etc/crontab file which has an extra field in -each entry, between the time fields and the command. This field is a user -name, and it permits the /etc/crontab command to contain commands which are -to be run by any user on the system. /etc/crontab is not "installed" via -the crontab(1) command; it is automatically read at startup time and it will -be reread whenever it changes. - -I also added a "-e" option to crontab(1). Nine people also sent me diffs -to add this option, but I had already implemented it on my own. I actually -released an interrim version (V2.2, I think) for limited testing, and got a -chance to fix a bad security bug in the "-e" option thanks to XXX. - -The daemon used to be extraordinarily sloppy in its use of file descriptors. -A heck of a lot of them were left open in spawned jobs, which caused problems -for the daemon and also caused problems with the spawned jobs if they were -shell scripts since "sh" and "csh" have traditionally used hidden file -descriptors to pass information to subshells, and cron was causing them to -think they were subshells. If you had trouble with "sh" or "csh" scripts in -V2, chances are good that V3 will fix your problems. - -About a dozen people have reminded me that I forgot to initialize -"crontab_fd" in database.c. Keith Cantrell was the first, so he gets the -point. - -Steve Simmons reminded me that once an account has been deleted from the -system, "crontab -u USER -d" will not work. My solution is to suggest to -all of you that before you delete a user's account, you first delete that -user's crontab file if any. From cron's point of view, usernames can never -be treated as arbitrary strings. Either they are valid user names, or they -are not. I will not make an exception for the "-d" case, for security -reasons that I consider reasonable. It is trivial for a root user to delete -the entry by hand if necessary. - -Dan O'Neil reminded me that I forgot to reset "log_fd" in misc.c. A lot of -others also reminded me of this, but Dan gets the point. I didn't fix it -there, since the real bug was that it should have been open in the parent. - -Peter Kabal reminded me that I forgot to "#ifdef DEBUGGING" some code in -misc.c. Hans Trompert actually told me first, but Peter sent the patch so -he gets the point. - -Russell Nelson told me that I'd forgotten to "#include <syslog.h>" in misc.c, -which explains why a lot of other people complained that it wasn't using -syslog even when they configured it that way :-). Steve Simmons told me -first, though, so he gets the point. - -An interrim version of the daemon tried to "stat" every file before -executing it; this turned out to be a horribly bad idea since finding the -name of a file from a shell command is a hard job (that's why we have -shells, right?) I removed this bogus code. Dave Burgess gets the point. - -Dennis R. Conley sent a suggestion for MMDF systems, which I've added to the -comments in cron.h. - -Mike Heisler noted that I use comments in the CONVERSION file which are -documented as illegal in the man pages. Thanks, Mike. - -Irving Wolfe sent me some very cheerful changes for a NeXT system, but I -consider the system itself broken and I can't bring myself to #ifdef for -something as screwed up as this system seems to be. However, various others -did send me smaller patches which appear to have cause cron to build and run -correctly on (the latest) NeXT machines, with or without the "-posix" CFLAG. -Irving also asked for a per-job MAILTO, and this was finally added later when -I integrated the BSD/386 changes contributed by BSDi, and generalized some of -the parsing. - -Lots of folks complained that the autogenerated "Date:" header wasn't in -ARPA format. I didn't understand this -- either folks will use Sendmail and -not generate a Date: at all (since Sendmail will do it), or folks will use -something other than Sendmail which won't care about Date: formats. But -I've "fixed" it anyway... - -Several people suggested that "*" should be able to take a "/step". One person -suggested that "N/step" ought to mean "N-last/step", but that's stretching things -a bit far. "*/step" seems quite intuitive to me, so I've added it. Colin Plumb -sent in the first and most polite request for this feature. - -As with every release of Cron, BIND, and seemingly everything else I do, one -user stands out with the most critical but also the most useful analysis. -Cron V3's high score belongs to Peter Holzer, who sent in the nicest looking -patch for the "%" interpretation problem and also helped me understand a -tricky bit of badness in the "log_fd" problem. - -agulbra@flode.nvg.unit.no wins the honors for being the first to point out the -nasty security hole in "crontab -r". 'Nuff said. - -Several folks pointed out that log_it() needed to exist even if logging was -disabled. Some day I will create a tool that will compile a subsystem with -every possible combination and permutation of #ifdef options, but meanwhile -thanks to everybody. - -job_runqueue() was using storage after freeing it, since Jordan told me back -in 1983 that C let you do that, and I believed him in 1986 when I wrote all -this junk. Linux was the first to die from this error, and the Linux people -sent me the most amazing, um, collection of patches for this problem. Thanks -for all the fish. - -Jeremy Bettis reminded me that popen() isn't safe. I grabbed Ken Arnold's -version of popen/pclose from the ftpd and hacked it to taste. We're safe now, -from this at least. - -Branko Lankester sent me a very timely and helpful fix for a looming security -problem in my "crontab -e" implementation. - --------- - -Vixie Cron Changes from V1 to V2 -Paul Vixie -8-Feb-1988 - -Many changes were made in a rash of activity about six months ago, the exact -list of which is no longer clear in my memory. I know that V1 used a file -called POKECRON in /usr/spool/cron to tell it that it was time to re-read -all the crontab files; V2 uses the modtime the crontab directory as a flag to -check out the crontab files; those whose modtime has changed will be re-read, -and the others left alone. Note that the crontab(1) command will do a utimes -call to make sure the mtime of the dir changes, since the filename/inode will -often remain the same after a replacement and the mtime wouldn't change in -that case. - -8-Feb-88: made it possible to use much larger environment variable strings. - V1 allowed 100 characters; V2 allows 1000. This was needed for PATH - variables on some systems. Thanks to Toerless Eckert for this idea. - E-mail: UUCP: ...pyramid!fauern!faui10!eckert - -16-Feb-88: added allow/deny, moved /usr/spool/cron/crontabs to - /usr/lib/cron/tabs. allow and deny are /usr/lib/cron/{allow,deny}, - since the sysv naming for this depends on 'at' using the same - dir, which would be stupid (hint: use /usr/{lib,spool}/at). - -22-Feb-88: made it read the spool directory for crontabs and look each one - up using getpwnam() rather than reading all passwds with getpwent() - and trying to open each crontab. - -9-Dec-88: made it sync to :00 after the minute, makes cron predictable. - added logging to /var/cron/log. - -14-Apr-90: (actually, changes since December 1989) - fixed a number of bugs reported from the net and from John Gilmore. - added syslog per Keith Bostic. security features including not - being willing to run a command owned or writable by other than - the owner of the crontab 9not working well yet) diff --git a/usr.sbin/cron/CONVERSION b/usr.sbin/cron/CONVERSION deleted file mode 100644 index 1347526b04c0..000000000000 --- a/usr.sbin/cron/CONVERSION +++ /dev/null @@ -1,85 +0,0 @@ -$Id: CONVERSION,v 1.1.1.1 1994/01/05 20:40:12 jtc Exp $ - -Conversion of BSD 4.[23] crontab files: - -Edit your current crontab (/usr/lib/crontab) into little pieces, with each -users' commands in a different file. This is different on 4.2 and 4.3, -but I'll get to that below. The biggest feature of this cron is that you -can move 'news' and 'uucp' cron commands into files owned and maintainable -by those two users. You also get to rip all the fancy 'su' footwork out -of the cron commands. On 4.3, there's no need for the 'su' stuff since the -user name appears on each command -- but I'd still rather have separate -crontabs with seperate environments and so on. - -Leave the original /usr/lib/crontab! This cron doesn't use it, so you may -as well keep it around for a while in case something goes wakko with this -fancy version. - -Most commands in most crontabs are run by root, have to run by root, and -should continue to be run by root. They still have to be in their own file; -I recommend /etc/crontab.src or /usr/adm/crontab.src. - -'uucp's commands need their own file; how about /usr/lib/uucp/crontab.src? -'news' also, perhaps in /usr/lib/news/crontab.src... - -I say `how about' and `perhaps' because it really doesn't matter to anyone -(except you) where you put the crontab source files. The `crontab' command -COPIES them into a protected directory (CRONDIR/SPOOL_DIR in cron.h), named -after the user whose crontab it is. If you want to examine, replace, or -delete a crontab, the `crontab' command does all of those things. The -various `crontab.src' (my suggested name for them) files are just source -files---they have to be copied to SPOOLDIR using `crontab' before they'll be -executed. - -On 4.2, your crontab might have a few lines like this: - - 5 * * * * su uucp < /usr/lib/uucp/uudemon.hr - 10 4 * * * su uucp < /usr/lib/uucp/uudemon.day - 15 5 * * 0 su uucp < /usr/lib/uucp/uudemon.wk - -...or like this: - - 5 * * * * echo /usr/lib/uucp/uudemon.hr | su uucp - 10 4 * * * echo /usr/lib/uucp/uudemon.day | su uucp - 15 5 * * 0 echo /usr/lib/uucp/uudemon.wk | su uucp - -On 4.3, they'd look a little bit better, but not much: - - 5 * * * * uucp /usr/lib/uucp/uudemon.hr - 10 4 * * * uucp /usr/lib/uucp/uudemon.day - 15 5 * * 0 uucp /usr/lib/uucp/uudemon.wk - -For this cron, you'd create /usr/lib/uucp/crontab.src (or wherever you want -to keep uucp's commands) which would look like this: - - # /usr/lib/uucp/crontab.src - uucp's crontab - # - PATH=/usr/lib/uucp:/bin:/usr/bin - SHELL=/bin/sh - HOME=/usr/lib/uucp - # - 5 * * * * uudemon.hr - 10 4 * * * uudemon.day - 15 5 * * 0 uudemon.wk - -The application to the `news' cron commands (if any) is left for you to -figure out. Likewise if there are any other cruddy-looking 'su' commands in -your crontab commands, you don't need them anymore: just find a good place -to put the `crontab.src' (or whatever you want to call it) file for that -user, put the cron commands into it, and install it using the `crontab' -command (probably with "-u USERNAME", but see the man page). - -If you run a 4.2-derived cron, you could of course just install your current -crontab in toto as root's crontab. It would work exactly the way your -current one does, barring the extra steps in installing or changing it. -There would still be advantages to this cron, mostly that you get mail if -there is any output from your cron commands. - -One note about getting mail from cron: you will probably find, after you -install this version of cron, that your cron commands are generating a lot -of irritating output. The work-around for this is to redirect all EXPECTED -output to a per-execution log file, which you can examine if you want to -see the output from the "last time" a command was executed; if you get any -UNEXPECTED output, it will be mailed to you. This takes a while to get -right, but it's amazingly convenient. Trust me. - diff --git a/usr.sbin/cron/FEATURES b/usr.sbin/cron/FEATURES deleted file mode 100644 index 9b0c5bfb2fe2..000000000000 --- a/usr.sbin/cron/FEATURES +++ /dev/null @@ -1,84 +0,0 @@ -$Id: FEATURES,v 1.1.1.2 1994/01/26 19:09:22 jtc Exp $ - -Features of Vixie's cron relative to BSD 4.[23] and SysV crons: - --- Environment variables can be set in each crontab. SHELL, USER, - LOGNAME, and HOME are set from the user's passwd entry; all except - USER can be changed in the crontab. PATH is especially useful to - set there. TZ can be set, but cron ignores it other than passing - it on through to the commands it runs. Format is - - variable=value - - Blanks surrounding the '=' will be eaten; other blanks in value are - okay. Leading or trailing blanks can be preserved by quoting, single - or double quotes are okay, just so they match. - - PATH=.:/bin:/usr/bin - SHELL=/bin/sh - FOOBAR = this is a long blanky example - - Above, FOOBAR would get "this is a long blanky example" as its value. - - SHELL and HOME will be used when it's time to run a command; if - you don't set them, HOME defaults to your /etc/passwd entry - and SHELL defaults to /bin/sh. - - MAILTO, if set to the login name of a user on your system, will be the - person that cron mails the output of commands in that crontab. This is - useful if you decide on BINMAIL when configuring cron.h, since binmail - doesn't know anything about aliasing. - --- Weekdays can be specified by name. Case is not significant, but only - the first three letters should be specified. - --- Months can likewise be specified by name. Three letters only. - --- Ranges and lists can be mixed. Standard crons won't allow '1,3-5'. - --- Ranges can specify 'step' values. '10-16/2' is like '10,12,14,16'. - --- Sunday is both day 0 and day 7 -- apparently BSD and ATT disagree - about this. - --- Each user gets their own crontab file. This is a win over BSD 4.2, - where only root has one, and over BSD 4.3, where they made the crontab - format incompatible and although the commands can be run by non-root - uid's, root is still the only one who can edit the crontab file. This - feature mimics the SysV cron. - --- The 'crontab' command is loosely compatible with SysV, but has more - options which just generally make more sense. Running crontab with - no arguments will print a cute little summary of the command syntax. - --- Comments and blank lines are allowed in the crontab file. Comments - must be on a line by themselves; leading whitespace is ignored, and - a '#' introduces the comment. - --- (big win) If the `crontab' command changes anything in any crontab, - the 'cron' daemon will reload all the tables before running the - next iteration. In some crons, you have to kill and restart the - daemon whenever you change a crontab. In other crons, the crontab - file is reread and reparsed every minute even if it didn't change. - --- In order to support the automatic reload, the crontab files are not - readable or writable except by 'crontab' or 'cron'. This is not a - problem, since 'crontab' will let you do pretty much whatever you - want to your own crontab, or if you are root, to anybody's crontab. - --- If any output is generated by a command (on stdout OR stderr), it will - be mailed to the owner of the crontab that contained the command (or - MAILTO, see discussion of environment variables, above). The headers - of the mail message will include the command that was run, and a - complete list of the environment that was passed to it, which will - contain (at least) the USER (LOGNAME on SysV), HOME, and SHELL. - --- the dom/dow situation is odd. '* * 1,15 * Sun' will run on the - first and fifteenth AND every Sunday; '* * * * Sun' will run *only* - on Sundays; '* * 1,15 * *' will run *only* the 1st and 15th. this - is why we keep 'e->dow_star' and 'e->dom_star'. I didn't think up - this behaviour; it's how cron has always worked but the documentation - hasn't been very clear. I have been told that some AT&T crons do not - act this way and do the more reasonable thing, which is (IMHO) to "or" - the various field-matches together. In that sense this cron may not - be completely similar to some AT&T crons. diff --git a/usr.sbin/cron/INSTALL b/usr.sbin/cron/INSTALL deleted file mode 100644 index a1673ad6551e..000000000000 --- a/usr.sbin/cron/INSTALL +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright 1993,1994 by Paul Vixie - * All rights reserved - * - * Distribute freely, except: don't remove my name from the source or - * documentation (don't take credit for my work), mark your changes (don't - * get me blamed for your possible bugs), don't alter or remove this - * notice. May be sold if buildable source is provided to buyer. No - * warrantee of any kind, express or implied, is included with this - * software; use at your own risk, responsibility for damages (if any) to - * anyone resulting from the use of this software rests entirely with the - * user. - * - * Send bug reports, bug fixes, enhancements, requests, flames, etc., and - * I'll try to keep a version up to date. I can be reached as follows: - * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul - */ - -$Id: INSTALL,v 1.1.1.3 1994/01/20 02:46:53 jtc Exp $ - -Read the comments at the top of the Makefile, then edit the area marked -'configurable stuff'. - -Edit config.h. The stuff I expect you to change is down a bit from the -top of the file, but it's clearly marked. Also look at pathnames.h. - -You don't have to create the /var/cron or /var/cron/tabs directories, since -both the daemon and the `crontab' program will do this the first time they -run if they don't exist. You do need to have a /var, though -- just "mkdir -/var" if you don't have one, or you can "mkdir /usr/var; ln -s /usr/var /var" -if you expect your /var to have a lot of stuff in it. - -You will also need /usr/local/etc and /usr/local/bin directories unless you -change the Makefile. These will have to be created by hand, but if you are -a long-time Usenet user you probably have them already. /usr/local/man is -where I keep my man pages, but I have the source for `man' and you probably -do not. Therefore you may have to put the man pages into /usr/man/manl, -which will be hard since there will be name collisions. (Note that the man -command was originally written by Bill Joy before he left Berkeley, and it -contains no AT&T code, so it is in UUNET's archive of freely-distributable -BSD code.) - -LINUX note: /usr/include/paths.h on some linux systems shows _PATH_SENDMAIL - to be /usr/bin/sendmail even though sendmail is installed in /usr/lib. - you should check this out. - -say: - make all - -su and say: - make install - -Note that if I can get you to "su and say" something just by asking, you have -a very serious security problem on your system and you should look into it. - -Edit your /usr/lib/crontab file into little pieces -- see the CONVERSION file -for help on this. - -Use the `crontab' command to install all the little pieces you just created. -Some examples (see below before trying any of these!) - - crontab -u uucp -r /usr/lib/uucp/crontab.src - crontab -u news -r /usr/lib/news/crontab.src - crontab -u root -r /usr/adm/crontab.src - -Notes on above examples: (1) the .src files are copied at the time the -command is issued; changing the source files later will have no effect until -they are reinstalled with another `crontab -r' command. (2) The crontab -command will affect the crontab of the person using the command unless `-u -USER' is given; `-u' only works for root. When using most `su' commands -under most BSD's, `crontab' will still think of you as yourself even though -you may think of yourself as root -- so use `-u' liberally. (3) the `-r' -option stands for `replace'; check the man page for crontab(1) for other -possibilities. - -Kill your existing cron daemon -- do `ps aux' and look for /etc/cron. - -Edit your /etc/rc or /etc/rc.local, looking for the line that starts up -/etc/cron. Comment it out and add a line to start the new cron daemon --- usually /usr/local/etc/cron, unless you changed it in the Makefile. - -Start up this cron daemon yourself as root. Just type /usr/local/etc/cron -(or whatever); no '&' is needed since the daemon forks itself and the -process you executed returns immediately. - -ATT notes: for those people unfortunate enough to be stuck on a AT&T UNIX, -you will need the public-domain "libndir", found in the B News source and in -any comp.sources.unix archive. You will also need to hack the code some. diff --git a/usr.sbin/cron/MAIL b/usr.sbin/cron/MAIL deleted file mode 100644 index f75ae72beab5..000000000000 --- a/usr.sbin/cron/MAIL +++ /dev/null @@ -1,475 +0,0 @@ -[ this is really old mail that came to me in response to my 1986 posting - to usenet asking for feature suggestions before releasing the first - version of cron. it is presented here for its entertainment value. - --vix ] - -$Id: MAIL,v 1.1.1.1 1994/01/05 20:40:12 jtc Exp $ - -From ptsfa!lll-crg!ames!acornrc!bob Wed Dec 31 10:07:08 1986 -Date: Wed, 31 Dec 86 08:59:31 pst -From: lll-crg!ames!acornrc!bob (Bob Weissman) -To: ptsfa!vixie!paul -Status: RO - -Sure, here's a suggestion: I'd like to be able to run a program, say, -every two hours. Current cron requires me to write -0,2,4,6,8,10,12,14,16,18,20,22 in the hours field. How about a notation -to handle this more elegantly? - -<< Okay, I've allowed 0-22/2 as a means of handling this. - The time specification for my cron is as follows: - specification = range {"," range} - range = (start "-" finish ["/" step]) | single-unit - This allows "1,3,5-7", which the current cron doesn't (it won't - do a range inside a list), and handles your specific need. >> - -From drw@mit-eddie Wed Dec 31 18:25:27 1986 -Date: Wed, 31 Dec 86 14:28:19 est -From: drw@mit-eddie (Dale Worley) -To: mit-eddie!vixie!paul -Status: RO - -We have a lot of lines in our crontab of the form - - 00 12 * * * su user < /usr/users/user/script.file - -This barfs (silently!) on our system (Dec Ultrix 1.2 == 4.2bsd) if -user's shell is csh. This, I am told, is because csh requires that -the environment be set up in certain ways, which cron doesn't do. -(Actually, I believe, it is because /etc/rc, which runs cron, doesn't -set up the environment enough for csh to run, and cron just inherits -the situation.) Anyway, the point is that if you find out what csh -really needs in its environment, you might want to set up cron to -provide some reasonable defaults (if it isn't supplied by cron's -parent). Also, could you tell me what csh needs, if you find out, so -we can hack our /etc/rc? - -<< well, the environment IS a problem. processes that cron forks - will inherit the environment of the person who ran the cron - daemon... I plan to edit out such useless things as TERMCAP, - TERM, and the like; supply correct values for HOME, USER, CWD, - and whatever else comes to mind. I'll make sure csh works... >> -From ptsfa!ames!seismo!dgis!generous Thu Jan 1 07:33:17 1987 -Date: Thu Jan 1 10:29:20 1987 -From: ames!seismo!dgis!generous (Curtis Generous) -To: nike!ptsfa!vixie!paul -Status: RO - -Paul: - -One of the limitations of the present versions of cron is the lack -of the capability of specifying a way to execute a command every -n units of time. - -Here is a good example: - -# Present method to start up uucico -02,12,22,32,42,52 * * * * exec /usr/lib/uucp/uucico -r1 - -# New method ?? (the ':' here is just one possibility for syntax) -02:10 * * * * exec /usr/lib/uucp/uucico -r1 - -This method would prove very helpful for those programs that get started -every few minutes, making the entry long and not easily readable. The first -number would specify the base time, and the second number the repetition -interval. - -<< Good idea, but bob@acornrc beat you to it. I used '/' instead of - ':'. This is my personal preference, and seems intuitive when you - think of the divide operator in C... Does anyone have a preference? >> - -From ptsfa!lll-lcc!seismo!decuac!c3pe!c3engr!charles Thu Jan 1 17:04:24 1987 -From: lll-lcc!seismo!c3pe!c3engr!charles (Charles Green) -To: c3pe!decuac!dolqci!vrdxhq!seismo!lll-lcc!ptsfa!vixie!paul -Date: Thu Jan 1 19:22:47 1987 -Status: RO - -Well, this isn't a compatible extension, but I have in times past wondered -about a facility to let you start a process at intervals of, say, 17 minutes, -instead of particular minutes out of each hour. - -<< This was a popular request! >> - -From seismo!uwvax!astroatc!nicmad!norvax!mann Sun Jan 4 13:04:01 1987 -Date: Fri, 2 Jan 87 09:23:53 cst -From: lll-lcc!seismo!uwvax!astroatc!nicmad!norvax!mann (Tom Mann) -To: ptsfa!vixie!paul -Status: RO - -I'm not sure if it is in cron (either SysV or BSD ... if it is, I haven't -figured it out ) but a comment feature would SURE BE NICE!. -There are times when I want to comment out an entry -for a period of time; it might also make it a lot more legible. - -<< My cron allows blank lines and standard #-type comments. I know - that one BSD4.2 cron I've used had it. I don't know about SysV. >> - -From ptsfa!hoptoad!hugh Mon Jan 5 10:26:46 1987 -Date: Mon, 5 Jan 87 01:22:17 PST -From: hoptoad!hugh (Hugh Daniel) -To: ptsfa!vixie!paul -Status: RO - - Hi, I do have a BIG one that I would like. I want to log ALL output -from command lines into a file for each line. Thus I might have a chance -of finding out why my crontab entry did not work. - This would seem to work best if done by cron, as it is now I have a google -of shell scripts laying about just to put the error output where I can see -it. - -<< My cron (and the SysV cron) will send mail to the owner of the - particular crontab file if a command generates any output on stdout - or stderr. This can be irritating, but if you write a script such - that any output means a problem occurred, you can avoid most logfile - needs, and not generate mail except in unforeseen circumstances. >> - -From ptsfa!dual!ucbvax!ihnp4!anvil!es!Robert_Toxen Mon Jan 5 13:08:46 1987 -From: dual!ucbvax!ihnp4!anvil!es!Robert_Toxen -Date: Fri, 2 Jan 87 14:25:29 EST -To: anvil!ihnp4!ucbvax!dual!ptsfa!vixie!paul -Status: RO - -Here are some suggestions: -1. Run it through the C preprocessor via "/lib/<whatever>". - -<< hmmm. this seems of limited utility, and if you really wanted - to do it that way, you could do it yourself (since users can - write to their own crontab files). I'll add '-' (read stdin) - to the crontab installer program to facilitate this. >> - -2. Allow specifying every Nth day of week, i.e., every second Wednesday. - I did this to calendar by separating the day of week (Wed=4, which one - to start on and N with slashes). I took modulo the day of year as a - starting point so that someone with a desk calendar documenting such - things can easily determine the offset (second number). I did this - while at SGI; alas I don't have a copy of the code. - -<< I can see how this could be useful, but I'm not sure how I'd - implement it. Cron currently doesn't keep track of the last time - a given command was run; whether the current Wednesday is the first - or second since the command was last run would be pretty hard to - figure out. I'd have to keep a database of commands and their - execution around, and purge it when the crontab was overwritten. - This is too much work for me, but if someone adds it, let me know. >> - -From ptsfa!ames!seismo!cbmvax!devon!paul Tue Jan 6 05:50:17 1987 -From: ames!seismo!cbmvax!devon!paul -To: cbmvax!seismo!nike!ptsfa!vixie!paul -Date: Mon Jan 5 09:29:57 1987 -Status: RO - -One problem that has always plagued me with cron is the assumed ORing. -I'd like to see some type of ANDing implemented. I guess I can best -describe this by example. Say I have the following line in my crontab -file: - -* * 4-31 * 1-6 /usr/bin/command - -What this does is run 'command' on the 4th thru 31st days of the -month, AND on Monday thru Saturday; which probably means running it -every day of the month (unless Sunday falls on days 1-3). This -happens because cron runs the command if the day-of-month OR the -day-of-week is true. - -What I'd like to happen with the above line is to run the command ONLY -on Monday thru Saturday any time after the 3rd of the month, e.g. if -the day-of-month AND the day-of-week are true. - -My proposal to you is to implement some special chars for the first -five fields. Examples: - -* * !1-3 * 1-6 /usr/bin/command - -(run command Mon-Sat, but NOT [!] on the first 3 days of the month) - -* * &4-31 * &1-6 /usr/bin/command - -(run command if day-of-month AND day-of-week are true) - -Get the picture? This would be compatable with existing versions of -cron (which wouldn't currently be using any special characters, so -that old crontabs would be handled correctly). - -<< This message made me aware of the actual boolean expression involved - in a crontab entry. I'd assumed that it was - (minute && hour && DoM && month && DoW) - But it's really - (minute && hour && month && (DoM || DoW)) - - I can see some value in changing this, but with a fixed order of - fields, operators get to be kindof unary, which && and || really - aren't. If someone has an idea on a syntax that allows useful - variations to the standard (&& && && (||)) default, please suggest. >> - -From bobkat!pedz Tue Jan 6 20:02:10 1987 -From: pedz@bobkat.UUCP (Pedz Thing) -Date: 2 Jan 87 17:34:44 GMT -Status: RO - -Log files! It would be nice to be able to specify a log for cron -itself and also a log for each program's stdout and stderr to go to. -The latter can of course be done with > and 2> but it would be nice if -there could be a single line with some sort of pattern like -`> /usr/spool/log/%' and the command would be substituted for the %. -Another thing which would be nice is to be able to specify which shell -to call to give the command to. - -<< Log files are done with mail. The '%' idea could be useful if - a different character were used (% is special to cron, see man - page); a different directory would have to be chosen, since each - user has their own crontab file; and something intelligent would - have to be done in the file naming, since the first word of the - command might be ambiguous (with other commands). In short, it's - too much work. Sorry. >> - -From guy%gorodish@sun Tue Jan 6 20:03:13 1987 -From: guy%gorodish@sun (Guy Harris) -Message-ID: <10944@sun.uucp> -Date: 5 Jan 87 12:09:09 GMT -References: <429@vixie.UUCP> <359@bobkat.UUCP> -Sender: news@sun.uucp -Status: RO - -> Another thing which would be nice is to be able to specify which shell -> to call to give the command to. - -Well, the obvious choice would be the user's shell, but this wouldn't work -for accounts like "uucico". - -<< I use the owning user's shell, and to handle "uucico" I check a - list of "acceptable shells" (currently compiled in, does anybody - mind?), substituting a default (compiled in) shell if the user's - shell isn't on the list. - - BTW, "compiled in" means that it's in a .h file, easily changed - during installation, but requiring recompilation to modify. You - don't have to go digging through the code to find it... >> - -From qantel!hplabs!ucbvax!mwm@violet.berkeley.edu Tue Jan 6 21:24:48 1987 -To: hplabs!qantel!vixie!paul (Paul Vixie Esq) -Date: 04 Jan 87 00:42:35 PST (Sun) -From: Mike Meyer <mwm@violet.berkeley.edu> -Status: RO - -<<[Discussion of RMS/FSF, and mwm's GNU Cron deleted]>> - -Oh, yeah - here are the extensions on my cron: - -1) Sunday is both day 0 and day 7, so it complies with both SysV and -BSD cron. - -<< Good idea. I did it too, thanks for informing me. >> - -2) At is integrated into the cron. Instead of atrun to scan the -/usr/spool/at directory, at files are put into the /usr/lib/cron -directory along with users cron files, and cron fabricates a line from -a crontab file to run them. This is considered a major win by all who -use it. - -<< I don't use 'at', and my cron doesn't do anything with it. To run - 'at', I use 'atrun' the same way the current BSD cron does. My - crontab files are in /usr/spool/cron/crontabs, in the SysV - tradition -- not in /usr/lib/cron. This is a configuration - parameter, of course. >> - -There are two known restrictions: - -1) I don't support any of the SysV security hooks. I don't have a use -for them, and RMS didn't like the idea at all :-). - -<< This means cron.allow and cron.deny. I plan to support them, as - they've been quite helpful at various HPUX sites I've administered. >> - -2) Cron expects to be able to create files with names longer than 14 -characters, which makes it hard to run on SysV. At least one person -was working on a port, but I don't know how it's going. That might -make for a good reason for releasing yours, right there. - -<< If someone has SysV (with the 14-character limit), they probably - won't want my cron, since it doesn't add much to the standard - version (which they may have support for). My cron is not currently - portable to non-BSD systems, since it relies on interval timers (I - needed to sleep for intervals more granular than seconds alone would - allow). The port would be trivial, and I will do it if a lot of - people ask for it... >> - -Oh, yeah - I'm going to see about getting this cron integrated into -the next 4BSD release. - -<< How does one go about this? I have a few nifty gadgets I'd like - to contribute, this cron being one of them... >> - -<<[more FSF/GNU discussion deleted]>> - -From qantel!hplabs!ames!ut-sally!ut-ngp!melpad!bigtex!james Tue Jan 6 21:24:57 1987 -Posted-Date: Fri, 2 Jan 87 19:26:16 est -Date: Fri, 2 Jan 87 19:26:16 est -From: hplabs!ames!ut-sally!ut-ngp!bigtex!james -To: vixie!paul -Status: RO - -Yes!!! There are several critical failures in System V cron... - -1. Pass all variables in cron's environment into the environment of things - cron starts up, or at least into the crontab entries started up (at jobs - will inherit the environment of the user). If nothing else it is critically - important that the TZ variable be passed on. PATH should be passed on too. - Basically, passing environment values allows one to design a standard - environment with TZ and PATH and have that run by everything. If anyone - tells you this is no big deal, consider what happens when uucico is - started by cron in CA to make a long distance phone link... Unless the - administrator is really on his/her toes, calls scheduled at 5pm will really - go at two in the afternoon, needlessly incurring huge phone bills, all - because System V refuses to pass the TZ from its environment down. There - are work arounds, but only putting it in cron will really work. This is - not a security hole. - -<< delete TERM and TERMCAP; modify HOME, USER, and CWD; pass TZ and - PATH through undisturbed. any other requests out there? - - BSD doesn't have this problem -- TZ is passed right on through if - you define it in the shell before starting my cron daemon. However, - the BSD I'm running this on doesn't need TZ to be defined anyway... - The default in the kernel has been just fine so far... But just the - same, if/when I port to SysV (I guess I really should), I'll make - sure this works right. - - I guess I've been spoiled. HPUX is SysV-based, and I never had a - problem with cron and TZ when I used it. >> - -2. A way to avoid logging stuff in /usr/lib/cron/log. I have a cron entry - run uudemon.hr every 10 minutes. This is 144 times/day. Each run generates - three lines of text, for a total of 432 lines of text I don't want to see. - Obviously this should be optional, but it would be nice if there were a - way to flag an entry so that it wasn't logged at all unless there was an - error. - -<< I don't know nothin' 'bout no /usr/lib/cron/log. What is this file? - I don't see any reason to create log entries, given the mail-the- - output behaviour. Opinions, anyone? >> - -I will come up with other ideas no doubt, but I can always implement them -myself. - -<< That's what I like about PD software. Please send me the diffs! >> - -The other problem you have is making sure you can run standard -crontabs. I would suggest something like this: if the command part of the -entry starts with an unescaped -, then flags and options follow immediately -thereafter. As in: - -2,12,22,32,42,52 * * * * -q /usr/lib/uucp/uudemon.hr - -This could mean do not log the uudemon.hr run unless there is a problem of -some kind. This is probably safe as not many filenames start with "-", and -those that do are already a problem for people. - -<< Since I don't plan on supporting /usr/lib/cron/log in ANY form unless - many people request it, I won't be needing -q as you've defined it. - I could use something like this to avoid sending mail on errors, for - the occasional script that you don't want to bullet-proof. - - The compatibility issue is CRITICAL. The 4.3BSD crontab format is - a crime against the whole philosophy of Unix(TM), in my opinion. >> - -One other minor thing to consider is the ulimit: can different users get -different ulimits for their crontab entries? - -<< Boy I'm ignorant today. What's a ulimit, and what should I do with - it in a crontab? Suggestions, enlightenment, etc ?? >> - -From qantel!lll-crg!ames!uw-beaver!uw-nsr!john Tue Jan 6 23:32:44 1987 -Date: Thu, 1 Jan 87 10:53:05 pst -From: lll-crg!ames!uw-beaver!uw-nsr!john (John Sambrook 5-7433) -To: vixie!paul -Status: RO - -How about not hardwiring the default environment that cron builds for its -children in the cron program itself? Our cron does this and it's the pits -because we are TZ=PST8PDT not TZ=EST5EDT ! - -<< yeachk. I assure you, I will not hardwire the TZ! >> -From ptsfa!well!dv Fri Jan 9 04:01:50 1987 -Date: Thu, 8 Jan 87 23:50:40 pst -From: well!dv (David W. Vezie) -To: ptsfa!vixie!paul -Status: RO - -6, have a special notation called 'H' which would expand to weekends - and holidays (you'd have to keep a database somewhere of real - holidays), and also 'W' for workdays (neither weekend or holiday). - -<< Too much work. There should be a standard way to define and - detect holidays under Unix(TM); if there were, I'd use it. As - it is, I'll leave this for someone else to add. - - I can see the usefulness; it just doesn't quite seem worth it. >> -From qantel!gatech!akgua!blnt1!jat Wed Jan 14 20:00:40 1987 -Date: Tue, 13 Jan 87 16:39:38 EST -From: gatech!akgua!blnt1!jat -Status: RO - -1) Add some way to tell cron to reread the files, say kill -1 <pid> - -<< whenever the 'crontab' program is run and updates a crontab file, - a file /usr/spool/cron/POKECRON is created; next time the cron - daemon wakes up, it sees it, and re-reads the crontab files. - - I thought of handling the signal; even implemented it. Then this - clever idea hit me and I ripped it all out and added a single - IF-statement to handle the POKECRON file. >> - -2) Have some kind of retry time so that if a command fails, cron will try to - execute it again after a certain period. This is useful if you have some - type of cleanup program that can run at the scheduled time for some reason - (such as locked device, unmounted filesystem, etc). - -<< Hmmm, sounds useful. I could do this by submitting an 'at' job... - I'll think about it. >> -From ptsfa!dual!ucbvax!ihnp4!mtuxo!ender Sat Jan 3 16:54:00 1987 -From: dual!ucbvax!ihnp4!mtuxo!ender -Date: Sat, 3 Jan 87 14:05:13 PST -To: ucbvax!dual!ptsfa!vixie!paul -Status: RO - -It would be nice if nonprivileged users can setup personal crontab files -(~/.cronrc, say) and be able to run personal jobs at regular intervals. - -<< this is done, but in the SysV style: the 'crontab' program installs - a new crontab file for the executing user (can be overridden by root - for setup of uucp and news). the advantage of this is that (1) when - a crontab is changed, the daemon can be informed automatically; and - (2) the file can be syntax-checked before installation. >> -From ptsfa!ames!seismo!ihnp4!lcc!richard Fri Jan 16 04:47:33 1987 -Date: Fri, 16 Jan 87 07:44:57 EST -To: nike!ptsfa!vixie!paul -Status: RO - -The System V cron is nice, but it has a few annoying features. One is that -its mail files will say that the previous message is the output of "one of your -cron commands." I wish it would say WHICH cron commmand. - -<< Done. Also which shell, which user (useful when the mail gets - forwarded), which home directory, and other useful crud. >> - -Another problem is with timezones. It is necessary to specify TZ=PST8PDT (or -whatever) when you invoke cron (from inittab, or /etc/rc) and it is also -necessary to add TZ=PST8PDT to each crontab line which might need it. Cron -should automatically export its idea of the "TZ" to each invoked command, and -it should be possible to put a line in the crontab file which overrides that -for every command in the file (e.g., most users are on EST, so cron is run -with TZ=EST5EDT; but one user is usually on PST and wants all of his cron -commands to run with TZ=PST8PDT). This might be extended to allow any -environment variable to be specified once for the whole crontab file (e.g., -PATH). - -<< Well, since I run the user's shell, you could put this into .cshrc. - generic environment-variable setting could be useful, though. Since - I have to modify the environment anyway, I'll consider this. >> - -A log file might be a nice idea, but the System V cron log is too verbose. -I seem to remember that cron keeps it open, too; so you can't even have -something go and periodically clean it out. - -<< I don't do /usr/lib/cron/log. I wasn't aware of this file until I - got all these suggestions. Do people want this file? Tell me! >> diff --git a/usr.sbin/cron/MANIFEST b/usr.sbin/cron/MANIFEST deleted file mode 100644 index aed1d4f8d973..000000000000 --- a/usr.sbin/cron/MANIFEST +++ /dev/null @@ -1,33 +0,0 @@ - File Name Archive # Description ------------------------------------------------------------ - CHANGES 2 - CONVERSION 1 - FEATURES 1 - INSTALL 1 - MAIL 2 - MANIFEST 1 This shipping list - Makefile 1 - README 1 - THANKS 1 - bitstring.3 1 - bitstring.h 1 - compat.c 1 - compat.h 1 - config.h 1 - cron.8 1 - cron.c 1 - cron.h 1 - crontab.1 1 - crontab.5 1 - crontab.c 2 - database.c 1 - do_command.c 2 - entry.c 2 - env.c 1 - externs.h 1 - job.c 1 - misc.c 2 - pathnames.h 1 - popen.c 1 - putman.sh 1 - user.c 1 diff --git a/usr.sbin/cron/README b/usr.sbin/cron/README deleted file mode 100644 index 28835bba6fb3..000000000000 --- a/usr.sbin/cron/README +++ /dev/null @@ -1,72 +0,0 @@ -#/* Copyright 1988,1990,1993 by Paul Vixie -# * All rights reserved -# * -# * Distribute freely, except: don't remove my name from the source or -# * documentation (don't take credit for my work), mark your changes (don't -# * get me blamed for your possible bugs), don't alter or remove this -# * notice. May be sold if buildable source is provided to buyer. No -# * warrantee of any kind, express or implied, is included with this -# * software; use at your own risk, responsibility for damages (if any) to -# * anyone resulting from the use of this software rests entirely with the -# * user. -# * -# * Send bug reports, bug fixes, enhancements, requests, flames, etc., and -# * I'll try to keep a version up to date. I can be reached as follows: -# * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul -# */ - -Vixie Cron V3.0 -December 27, 1993 -[V2.2 was some time in 1992] -[V2.1 was May 29, 1991] -[V2.0 was July 5, 1990] -[V2.0-beta was December 9, 1988] -[V1.0 was May 6, 1987] -Paul Vixie - -This is a version of 'cron' that is known to run on BSD 4.[23] systems. It -is functionally based on the SysV cron, which means that each user can have -their own crontab file (all crontab files are stored in a read-protected -directory, usually /var/cron/tabs). No direct support is provided for -'at'; you can continue to run 'atrun' from the crontab as you have been -doing. If you don't have atrun (i.e., System V) you are in trouble. - -A messages is logged each time a command is executed; also, the files -"allow" and "deny" in /var/cron can be used to control access to the -"crontab" command (which installs crontabs). It hasn't been tested on -SysV, although some effort has gone into making the port an easy one. - -This is more or less the copyright that USENET contributed software usually -has. Since ATT couldn't use this version if they had to freely distribute -source, and since I'd love to see them use it, I'll offer some rediculously -low license fee just to have them take it. In the unlikely event that they -do this, I will continue to support and distribute the pseudo-PD version, so -please, don't flame me for wanting my work to see a wider distribution. - -To use this: Sorry, folks, there is no cutesy 'Configure' script. You'll -have to go edit a couple of files... So, here's the checklist: - - Read all the FEATURES, INSTALL, and CONVERSION files - Edit config.h - Edit Makefile - (both of these files have instructions inside; note that - some things in config.h are definable in Makefile and are - therefore surrounded by #ifndef...#endif) - 'make' - 'su' and 'make install' - (you may have to install the man pages by hand) - kill your existing cron process - (actually you can run your existing cron if you want, but why?) - build new crontabs using /usr/lib/{crontab,crontab.local} - (either put them all in "root"'s crontab, or divide it up - and rip out all the 'su' commands, collapse the lengthy - lists into ranges with steps -- basically, this step is - as much work as you want to make it) - start up the new cron - (must be done as root) - watch it. test it with 'crontab -r' and watch the daemon track your - changes. - if you like it, change your /etc/{rc,rc.local} to use it instead of - the old one. - -$Id: README,v 1.1.1.1 1994/01/05 20:40:12 jtc Exp $ diff --git a/usr.sbin/cron/THANKS b/usr.sbin/cron/THANKS deleted file mode 100644 index 3787c2943d7a..000000000000 --- a/usr.sbin/cron/THANKS +++ /dev/null @@ -1,29 +0,0 @@ -15 January 1990 -Paul Vixie - -Many people have contributed to cron. Many more than I can remember, in fact. -Rich Salz and Carl Gutekunst were each of enormous help to me in V1; Carl for -helping me understand UNIX well enough to write it, and Rich for helping me -get the features right. - -John Gilmore wrote me a wonderful review of V2, which took me a whole year to -answer even though it made me clean up some really awful things in the code. -(According to John the most awful things are still in here, of course.) - -Paul Close made a suggestion which led to /etc/crond.pid and the mutex locking -on it. Kevin Braunsdorf of Purdue made a suggestion that led to @reboot and -its brothers and sisters; he also sent some diffs that lead cron toward compil- -ability with System V, though without at(1) capabilities, this cron isn't going -to be that useful on System V. Bob Alverson fixed a silly bug in the line -number counting. Brian Reid made suggestions which led to the run queue and -the source-file labelling in installed crontabs. - -Scott Narveson ported V2 to a Sequent, and sent in the most useful single batch -of diffs I got from anybody. Changes attributable to Scott are: - -> sendmail won't time out if the command is slow to generate output - -> day-of-week names aren't off by one anymore - -> crontab says the right thing if you do something you shouldn't do - -> crontab(5) man page is longer and more informative - -> misc changes related to the side effects of fclose() - -> Sequent "universe" support added (may also help on Pyramids) - -> null pw_shell is dealt with now; default is /bin/sh diff --git a/usr.sbin/cron/bitstring.3 b/usr.sbin/cron/bitstring.3 deleted file mode 100644 index efe9ae3c116e..000000000000 --- a/usr.sbin/cron/bitstring.3 +++ /dev/null @@ -1,168 +0,0 @@ -.\" Copyright (c) 1989 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Paul Vixie. -.\" -.\" Redistribution and use in source and binary forms are permitted -.\" provided that the above copyright notice and this paragraph are -.\" duplicated in all such forms and that any documentation, -.\" advertising materials, and other materials related to such -.\" distribution and use acknowledge that the software was developed -.\" by the University of California, Berkeley. The name of the -.\" University may not be used to endorse or promote products derived -.\" from this software without specific prior written permission. -.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -.\" -.\" @(#)bitstring.3 5.1 (Berkeley) 12/13/89 -.\" -.TH BITSTRING 3 "December 13, 1989" -.UC 4 -.SH NAME -bit_alloc, bit_clear, bit_decl, bit_ffs, bit_nclear, bit_nset, -bit_set, bitstr_size, bit_test \- bit-string manipulation macros -.SH SYNOPSIS -.ft B -.nf -#include <bitstring.h> - -name = bit_alloc(nbits) -bitstr_t *name; -int nbits; - -bit_decl(name, nbits) -bitstr_t name; -int nbits; - -bit_clear(name, bit) -bitstr_t name; -int bit; - -bit_ffc(name, nbits, value) -bitstr_t name; -int nbits, *value; - -bit_ffs(name, nbits, value) -bitstr_t name; -int nbits, *value; - -bit_nclear(name, start, stop) -bitstr_t name; -int start, stop; - -bit_nset(name, start, stop) -bitstr_t name; -int start, stop; - -bit_set(name, bit) -bitstr_t name; -int bit; - -bitstr_size(nbits) -int nbits; - -bit_test(name, bit) -bitstr_t name; -int bit; -.fi -.ft R -.SH DESCRIPTION -These macros operate on strings of bits. -.PP -.I Bit_alloc -returns a pointer of type -.I bitstr_t\ * -to sufficient space to store -.I nbits -bits, or NULL if no space is available. -.PP -.I Bit_decl -is a macro for allocating sufficient space to store -.I nbits -bits on the stack. -.PP -.I Bitstr_size -returns the number of elements of type -.I bitstr_t -necessary to store -.I nbits -bits. -This is useful for copying bit strings. -.PP -.I Bit_clear -and -.I bit_set -clear or set the zero-based numbered bit -.IR bit , -in the bit string -.IR name . -.PP -.I Bit_nset -and -.I bit_nclear -set or clear the zero-based numbered bits from -.I start -to -.I stop -in the bit string -.IR name . -.PP -.I Bit_test -evaluates to zero if the zero-based numbered bit -.I bit -of bit string -.I name -is set, and non-zero otherwise. -.PP -.I Bit_ffs -sets -.I *value -to the zero-based number of the first bit set in the array of -.I nbits -bits referenced by -.IR name . -If no bits are set, -.I *value -is set to -1. -.PP -.I Bit_ffc -sets -.I *value -to the zero-based number of the first bit not set in the array of -.I nbits -bits referenced by -.IR name . -If all bits are set, -.I value -is set to -1. -.SH EXAMPLE -.nf -.in +5 -#include <limits.h> -#include <bitstring.h> - -... -#define LPR_BUSY_BIT 0 -#define LPR_FORMAT_BIT 1 -#define LPR_DOWNLOAD_BIT 2 -... -#define LPR_AVAILABLE_BIT 9 -#define LPR_MAX_BITS 10 - -make_lpr_available() -{ - bitstr_t bit_decl(bitlist, LPR_MAX_BITS); - ... - bit_nclear(bitlist, 0, LPR_MAX_BITS - 1); - ... - if (!bit_test(bitlist, LPR_BUSY_BIT)) { - bit_clear(bitlist, LPR_FORMAT_BIT); - bit_clear(bitlist, LPR_DOWNLOAD_BIT); - bit_set(bitlist, LPR_AVAILABLE_BIT); - } -} -.fi -.SH "SEE ALSO" -malloc(3) diff --git a/usr.sbin/cron/bitstring.h b/usr.sbin/cron/bitstring.h deleted file mode 100644 index d054de3c51c1..000000000000 --- a/usr.sbin/cron/bitstring.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Vixie. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)bitstring.h 5.2 (Berkeley) 4/4/90 - */ - -typedef unsigned char bitstr_t; - -/* internal macros */ - /* byte of the bitstring bit is in */ -#define _bit_byte(bit) \ - ((bit) >> 3) - - /* mask for the bit within its byte */ -#define _bit_mask(bit) \ - (1 << ((bit)&0x7)) - -/* external macros */ - /* bytes in a bitstring of nbits bits */ -#define bitstr_size(nbits) \ - ((((nbits) - 1) >> 3) + 1) - - /* allocate a bitstring */ -#define bit_alloc(nbits) \ - (bitstr_t *)malloc(1, \ - (unsigned int)bitstr_size(nbits) * sizeof(bitstr_t)) - - /* allocate a bitstring on the stack */ -#define bit_decl(name, nbits) \ - (name)[bitstr_size(nbits)] - - /* is bit N of bitstring name set? */ -#define bit_test(name, bit) \ - ((name)[_bit_byte(bit)] & _bit_mask(bit)) - - /* set bit N of bitstring name */ -#define bit_set(name, bit) \ - (name)[_bit_byte(bit)] |= _bit_mask(bit) - - /* clear bit N of bitstring name */ -#define bit_clear(name, bit) \ - (name)[_bit_byte(bit)] &= ~_bit_mask(bit) - - /* clear bits start ... stop in bitstring */ -#define bit_nclear(name, start, stop) { \ - register bitstr_t *_name = name; \ - register int _start = start, _stop = stop; \ - register int _startbyte = _bit_byte(_start); \ - register int _stopbyte = _bit_byte(_stop); \ - if (_startbyte == _stopbyte) { \ - _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \ - (0xff << ((_stop&0x7) + 1))); \ - } else { \ - _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \ - while (++_startbyte < _stopbyte) \ - _name[_startbyte] = 0; \ - _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \ - } \ -} - - /* set bits start ... stop in bitstring */ -#define bit_nset(name, start, stop) { \ - register bitstr_t *_name = name; \ - register int _start = start, _stop = stop; \ - register int _startbyte = _bit_byte(_start); \ - register int _stopbyte = _bit_byte(_stop); \ - if (_startbyte == _stopbyte) { \ - _name[_startbyte] |= ((0xff << (_start&0x7)) & \ - (0xff >> (7 - (_stop&0x7)))); \ - } else { \ - _name[_startbyte] |= 0xff << ((_start)&0x7); \ - while (++_startbyte < _stopbyte) \ - _name[_startbyte] = 0xff; \ - _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \ - } \ -} - - /* find first bit clear in name */ -#define bit_ffc(name, nbits, value) { \ - register bitstr_t *_name = name; \ - register int _byte, _nbits = nbits; \ - register int _stopbyte = _bit_byte(_nbits), _value = -1; \ - for (_byte = 0; _byte <= _stopbyte; ++_byte) \ - if (_name[_byte] != 0xff) { \ - _value = _byte << 3; \ - for (_stopbyte = _name[_byte]; (_stopbyte&0x1); \ - ++_value, _stopbyte >>= 1); \ - break; \ - } \ - *(value) = _value; \ -} - - /* find first bit set in name */ -#define bit_ffs(name, nbits, value) { \ - register bitstr_t *_name = name; \ - register int _byte, _nbits = nbits; \ - register int _stopbyte = _bit_byte(_nbits), _value = -1; \ - for (_byte = 0; _byte <= _stopbyte; ++_byte) \ - if (_name[_byte]) { \ - _value = _byte << 3; \ - for (_stopbyte = _name[_byte]; !(_stopbyte&0x1); \ - ++_value, _stopbyte >>= 1); \ - break; \ - } \ - *(value) = _value; \ -} diff --git a/usr.sbin/cron/putman.sh b/usr.sbin/cron/putman.sh deleted file mode 100644 index 356ebf1bd305..000000000000 --- a/usr.sbin/cron/putman.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# putman.sh - install a man page according to local custom -# vixie 27dec93 [original] -# -# $Id: putman.sh,v 1.1.1.1 1994/01/05 20:40:16 jtc Exp $ - -PAGE=$1 -DIR=$2 - -SECT=`expr $PAGE : '[a-z]*.\([0-9]\)'` - -[ -d $DIR/man$SECT ] && { - set -x - cp $PAGE $DIR/man$SECT/$PAGE - set +x -} || { - set -x - nroff -man $PAGE >$DIR/cat$SECT/`basename $PAGE .$SECT`.0 - set +x -} - -exit 0 diff --git a/usr.sbin/sendmail/cf/cf/cchem.cf b/usr.sbin/sendmail/cf/cf/cchem.cf deleted file mode 100644 index 34a461ab6dd9..000000000000 --- a/usr.sbin/sendmail/cf/cf/cchem.cf +++ /dev/null @@ -1,547 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)cchem.mc 1.2 (Berkeley) 1/3/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by phil on Wed Jan 25 11:47:38 PST 1989 -# in /usr/src/local/nettables/sendmail.cf/cf on monet.Berkeley.EDU -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/usr/lib/sendmail.cw - - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDCChem.Berkeley.EDU - -# Internet relay host -- machines in our domain that are not -# registered with the NIC will be "hidden" behind this relay machine -# with the % kludge, although SMTP delivery will still be performed -# by the sending machine. Someday this will go away. -DAviolet.Berkeley.EDU - -# UUCP relay host -DRucbvax.Berkeley.EDU - -# csnet relay host -DCrelay.cs.net - -# bitnet relay host -DBjade.Berkeley.EDU - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - -############################################################ -############################################################ -##### -##### BERKELEY HOSTS REGISTERED WITH THE NIC -##### -############################################################ -############################################################ - - -CNbach ucbbach -CNbizet ucbbizet -CNcad ucbcad -CNdegas ucbdegas -CNeast ucbeast -CNernie ucbernie -CNesvax ucbesvax -CNjade ucbjade -CNji ucbji -CNmike ucbmike -CNmonet ucbmonet -CNpostgres -CNrenoir ucbrenoir -CNucbarpa -CNucbvax -CNviolet ucbviolet - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/usr/lib/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/usr/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/usr/lib/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.bitnet -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - - - -# resolve fake top level domains by forwarding to other hosts -R$*<@$+.BITNET>$* $#tcp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET -R$*<@$+.CSNET>$* $#tcp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET - - -# forward non-local UUCP traffic to our UUCP relay -R$*<@$*.UUCP>$* $#tcpld$@$R$:$1<@$2.UUCP> uucp mail - -# hide behind our internet relay when talking to people in the arpa domain -R$*<@$*.arpa>$* $#tcp$@$2.arpa$:$1<@$2.arpa>$3 user@host.arpa - -# but speak domains to them if they speak domains too -R$*<@$*>$* $#tcpld$@$2$:$1<@$2>$3 user@host.domain - -# remaining names must be local -R$+ $#local$:$1 everything else diff --git a/usr.sbin/sendmail/cf/cf/cchem.mc b/usr.sbin/sendmail/cf/cf/cchem.mc deleted file mode 100644 index 28c7300bc614..000000000000 --- a/usr.sbin/sendmail/cf/cf/cchem.mc +++ /dev/null @@ -1,15 +0,0 @@ -divert(10)dnl -# -# College of Chemistry configuration file -# -# @(#)cchem.mc 1.2 (Berkeley) 1/3/89 -# -define(DOMAIN, `DDCChem.Berkeley.EDU') -define(INTERNET_RELAY, `DAviolet.Berkeley.EDU') -define(UUCP_RELAY, `DRucbvax.Berkeley.EDU') -define(BITNET_RELAY, `DBjade.Berkeley.EDU') -define(CSNET_RELAY, `DCrelay.cs.net') -define(ARPAKLUDGE, `1') -define(EXTERNAL_VERSION, ``#' `@(#)cchem.mc 1.2' (Berkeley) `1/3/89'') -divert(0)dnl -include(proto.mc)dnl diff --git a/usr.sbin/sendmail/cf/cf/cogsci.cf b/usr.sbin/sendmail/cf/cf/cogsci.cf deleted file mode 100644 index 45b680872566..000000000000 --- a/usr.sbin/sendmail/cf/cf/cogsci.cf +++ /dev/null @@ -1,610 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)cogsci.mc 1.6 (Berkeley) 1/3/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by phil on Wed Jan 25 11:46:54 PST 1989 -# in /usr/src/local/nettables/sendmail.cf/cf on monet.Berkeley.EDU -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/usr/lib/sendmail.cw - -# uucp hostnames -DUcogsci -CUcogsci - -# local UUCP connections -CV capmkt -CV contessa -CV emind -CV hoptoad -CV nkainc -CV well -CV ferdy - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDBerkeley.EDU - -# Internet relay host -- machines in our domain that are not -# registered with the NIC will be "hidden" behind this relay machine -# with the % kludge, although SMTP delivery will still be performed -# by the sending machine. Someday this will go away. -DAucbvax.Berkeley.EDU - -# UUCP relay host -DRucbvax.Berkeley.EDU - -# csnet relay host -DCrelay.cs.net - -# bitnet relay host -DBjade.Berkeley.EDU - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - -############################################################ -############################################################ -##### -##### BERKELEY HOSTS REGISTERED WITH THE NIC -##### -############################################################ -############################################################ - - -CNbach ucbbach -CNbizet ucbbizet -CNcad ucbcad -CNdegas ucbdegas -CNeast ucbeast -CNernie ucbernie -CNesvax ucbesvax -CNjade ucbjade -CNji ucbji -CNmike ucbmike -CNmonet ucbmonet -CNpostgres -CNrenoir ucbrenoir -CNucbarpa -CNucbvax -CNviolet ucbviolet - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/usr/lib/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/usr/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/usr/lib/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.bitnet -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### UUCP Mailer specification -##### -############################################################ -############################################################ - - -Muucp, P=/usr/bin/uux, F=DFMhuU, S=13, R=23, M=100000, - A=uux - -r -z -a$f -gC $h!rmail ($u) - -S13 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$w!$+ $1 strip local name -R$+ $:$U!$1 stick on our host name -R$=U!$-%$- $:$1!$2@$3.$D ucbvax!user@host.domain - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $U!$1 a!b@here -> here!a!b -R$=U!$+ $2 here!a!b -> a!b -# sanity ... should not happen. -R$=U.$D!$+ $2 strip local name.domain - - -############################################################ -############################################################ -##### -##### Provide Backward Compatibility -##### -############################################################ -############################################################ - -##################################################### -# General code to convert back to old style names # -##################################################### -S5 - -R$+<@$w> $1 strip host -R$+<@$-.UUCP> $2!$1 u@host.UUCP => host!u - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - -# resolve local UUCP connections -R<@$=V.UUCP>:$+ $#uucp$@$1$:$2 @host.UUCP:... -R$+<@$=V.UUCP> $#uucp$@$2$:$1 user@host.UUCP - - -# resolve fake top level domains by forwarding to other hosts -R$*<@$+.BITNET>$* $#tcp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET -R$*<@$+.CSNET>$* $#tcp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET - - -# forward non-local UUCP traffic to our UUCP relay -R$*<@$*.UUCP>$* $#tcpld$@$R$:$1<@$2.UUCP> uucp mail - -# hide behind our internet relay when talking to people in the arpa domain -R$*<@$*.arpa>$* $#tcp$@$2.arpa$:$1<@$2.arpa>$3 user@host.arpa - -# but speak domains to them if they speak domains too -R$*<@$*>$* $#tcpld$@$2$:$1<@$2>$3 user@host.domain - -# remaining names must be local -R$+ $#local$:$1 everything else - diff --git a/usr.sbin/sendmail/cf/cf/hpux-cs-exposed.mc b/usr.sbin/sendmail/cf/cf/hpux-cs-exposed.mc deleted file mode 100644 index 4f61ffda450f..000000000000 --- a/usr.sbin/sendmail/cf/cf/hpux-cs-exposed.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)hpux-cs-exposed.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(hpux)dnl -DOMAIN(cs.exposed)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/hpux-cs-hidden.mc b/usr.sbin/sendmail/cf/cf/hpux-cs-hidden.mc deleted file mode 100644 index 33cf580d3977..000000000000 --- a/usr.sbin/sendmail/cf/cf/hpux-cs-hidden.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)hpux-cs-hidden.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(hpux)dnl -DOMAIN(cs.hidden)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/ic.cf b/usr.sbin/sendmail/cf/cf/ic.cf deleted file mode 100644 index c9f5e44abbe6..000000000000 --- a/usr.sbin/sendmail/cf/cf/ic.cf +++ /dev/null @@ -1,603 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)ic.mc 1.2 (Berkeley) 1/3/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by phil on Wed Jan 25 11:47:46 PST 1989 -# in /usr/src/local/nettables/sendmail.cf/cf on monet.Berkeley.EDU -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/usr/lib/sendmail.cw - -# uucp hostnames -DUic -CUic ucbic - -# local UUCP connections -CV foo - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDBerkeley.EDU - -# Internet relay host -- machines in our domain that are not -# registered with the NIC will be "hidden" behind this relay machine -# with the % kludge, although SMTP delivery will still be performed -# by the sending machine. Someday this will go away. -DAcad.Berkeley.EDU - -# UUCP relay host -DRcad.Berkeley.EDU - -# csnet relay host -DCrelay.cs.net - -# bitnet relay host -DBjade.Berkeley.EDU - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - -############################################################ -############################################################ -##### -##### BERKELEY HOSTS REGISTERED WITH THE NIC -##### -############################################################ -############################################################ - - -CNbach ucbbach -CNbizet ucbbizet -CNcad ucbcad -CNdegas ucbdegas -CNeast ucbeast -CNernie ucbernie -CNesvax ucbesvax -CNjade ucbjade -CNji ucbji -CNmike ucbmike -CNmonet ucbmonet -CNpostgres -CNrenoir ucbrenoir -CNucbarpa -CNucbvax -CNviolet ucbviolet - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/usr/lib/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/usr/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/usr/lib/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.bitnet -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### UUCP Mailer specification -##### -############################################################ -############################################################ - - -Muucp, P=/usr/bin/uux, F=DFMhuU, S=13, R=23, M=100000, - A=uux - -r -z -a$f -gC $h!rmail ($u) - -S13 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$w!$+ $1 strip local name -R$+ $:$U!$1 stick on our host name -R$=U!$-%$- $:$1!$2@$3.$D ucbvax!user@host.domain - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $U!$1 a!b@here -> here!a!b -R$=U!$+ $2 here!a!b -> a!b -# sanity ... should not happen. -R$=U.$D!$+ $2 strip local name.domain - - -############################################################ -############################################################ -##### -##### Provide Backward Compatibility -##### -############################################################ -############################################################ - -##################################################### -# General code to convert back to old style names # -##################################################### -S5 - -R$+<@$w> $1 strip host -R$+<@$-.UUCP> $2!$1 u@host.UUCP => host!u - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - -# resolve local UUCP connections -R<@$=V.UUCP>:$+ $#uucp$@$1$:$2 @host.UUCP:... -R$+<@$=V.UUCP> $#uucp$@$2$:$1 user@host.UUCP - - -# resolve fake top level domains by forwarding to other hosts -R$*<@$+.BITNET>$* $#tcp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET -R$*<@$+.CSNET>$* $#tcp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET - - -# forward non-local UUCP traffic to our UUCP relay -R$*<@$*.UUCP>$* $#tcpld$@$R$:$1<@$2.UUCP> uucp mail - -# hide behind our internet relay when talking to people in the arpa domain -R$*<@$*.arpa>$* $#tcp$@$2.arpa$:$1<@$2.arpa>$3 user@host.arpa - -# but speak domains to them if they speak domains too -R$*<@$*>$* $#tcpld$@$2$:$1<@$2>$3 user@host.domain - -# remaining names must be local -R$+ $#local$:$1 everything else diff --git a/usr.sbin/sendmail/cf/cf/ic.mc b/usr.sbin/sendmail/cf/cf/ic.mc deleted file mode 100644 index e45fe9211e50..000000000000 --- a/usr.sbin/sendmail/cf/cf/ic.mc +++ /dev/null @@ -1,18 +0,0 @@ -divert(10)dnl -# -# ic configuration file -# -# @(#)ic.mc 1.2 (Berkeley) 1/3/89 -# -define(DOMAIN, `DDBerkeley.EDU') -define(UUCP_NAME, DUic) -define(UUCP_ALIASES, CUic ucbic) -define(UUCP_HOSTS_FILE, ../sitedep/uucp.ic.m4) -define(INTERNET_RELAY, `DAcad.Berkeley.EDU') -define(UUCP_RELAY, `DRcad.Berkeley.EDU') -define(BITNET_RELAY, `DBjade.Berkeley.EDU') -define(CSNET_RELAY, `DCrelay.cs.net') -define(ARPAKLUDGE, `1') -define(EXTERNAL_VERSION, ``#' `@(#)ic.mc 1.2' (Berkeley) `1/3/89'') -divert(0)dnl -include(proto.mc)dnl diff --git a/usr.sbin/sendmail/cf/cf/id.cf b/usr.sbin/sendmail/cf/cf/id.cf deleted file mode 100644 index 7aa504c6db2b..000000000000 --- a/usr.sbin/sendmail/cf/cf/id.cf +++ /dev/null @@ -1,615 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# based on: @(#)ic.mc 1.2 (Berkeley) 1/3/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by rich on Mon May 11 19:31:56 CDT 1992 -# in /home/rich/sendmail/idcf/cf on id -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/etc/sendmail.cw - -# uucp hostnames -DUid -CUid uid - -# local UUCP connections -CVjpunix - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDjpunix.hou.tx.us - -# Internet relay host -- machines in our domain that are not -# registered with the NIC will be "hidden" behind this relay machine -# with the % kludge, although SMTP delivery will still be performed -# by the sending machine. Someday this will go away. -DAjpunix.hou.tx.us - -# UUCP relay host -DRjpunix - -# csnet relay host -DCrelay.cs.net - -# bitnet relay host -DBricevm1.Rice.EDU - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - -############################################################ -############################################################ -##### -##### BERKELEY HOSTS REGISTERED WITH THE NIC -##### -############################################################ -############################################################ - - -CNbach ucbbach -CNbizet ucbbizet -CNcad ucbcad -CNdegas ucbdegas -CNeast ucbeast -CNernie ucbernie -CNesvax ucbesvax -CNjade ucbjade -CNji ucbji -CNmike ucbmike -CNmonet ucbmonet -CNpostgres -CNrenoir ucbrenoir -CNucbarpa -CNucbvax -CNviolet ucbviolet - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/etc/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/share/misc/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/var/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/var/log/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/usr/libexec/mail.local, F=lsDFMmn, S=10, R=20, A=mail -r $g -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.bitnet -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - - -############################################################ -############################################################ -##### -##### Provide Backward Compatibility -##### -############################################################ -############################################################ - -##################################################### -# General code to convert back to old style names # -##################################################### -S5 - -R$+<@$w> $1 strip host -R$+<@$-.UUCP> $2!$1 u@host.UUCP => host!u - -############################################################ -############################################################ -##### -##### UUCP Mailer specification -##### -############################################################ -############################################################ - - -Muucp, P=/usr/local/bin/uux, F=DFMhuU, S=13, R=23, M=100000, - A=uux - -r -z -a$f -gC $h!rmail ($u) - -S13 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$w!$+ $1 strip local name -R$+ $:$U!$1 stick on our host name -R$=U!$-%$- $:$1!$2@$3.$D ucbvax!user@host.domain - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $U!$1 a!b@here -> here!a!b -R$=U!$+ $2 here!a!b -> a!b -# sanity ... should not happen. -R$=U.$D!$+ $2 strip local name.domain - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - -# resolve local UUCP connections -R<@$=V.UUCP>:$+ $#uucp$@$1$:$2 @host.UUCP:... -R$+<@$=V.UUCP> $#uucp$@$2$:$1 user@host.UUCP - - -# resolve fake top level domains by forwarding to other hosts - - -# forward non-local UUCP traffic to our UUCP relay -R$*<@$*.UUCP>$* $#tcpld$@$R$:$1<@$2.UUCP> uucp mail - -# hide behind our internet relay when talking to people in the arpa domain -R$*<@$*.arpa>$* $#tcp$@$2.arpa$:$1<@$2.arpa>$3 user@host.arpa - -# but speak domains to them if they speak domains too -R$*<@$*>$* $#tcpld$@$2$:$1<@$2>$3 user@host.domain -# -# Handle "fake" top level domains, by sending to a smarter -# host. Currently, we support: -# -# user@host.bitnet -> $B user@host.bitnet -# user@host.csnet -> $C user@host.csnet -# -# Eventually, all these should Go Away. -# -# @(#)fake_domains.m4 1.5 (Berkeley) 1/3/89 -# -R$*<@$+.BITNET>$* $#tcp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET -R$*<@$+.CSNET>$* $#tcp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET - - -# remaining names must be local -R$+ $#local$:$1 everything else diff --git a/usr.sbin/sendmail/cf/cf/id.mc b/usr.sbin/sendmail/cf/cf/id.mc deleted file mode 100644 index df1fa85e2ad6..000000000000 --- a/usr.sbin/sendmail/cf/cf/id.mc +++ /dev/null @@ -1,17 +0,0 @@ -divert(10)dnl -# -# ic configuration file -# -# From: @(#)ic.mc 1.2 (Berkeley) 1/3/89 -# -define(UUCP_NAME, DUid) -define(UUCP_ALIASES, CUid uid) -define(UUCP_HOSTS_FILE, ../sitedep/uucp.id.m4) -define(INTERNET_RELAY, `DAjpunix') -define(UUCP_RELAY, `DRjpunix') -define(BITNET_RELAY, `DBricevm1.Rice.EDU') -define(CSNET_RELAY, `DCrelay.cs.net') -define(ARPAKLUDGE, `1') -define(EXTERNAL_VERSION, ``#' `based on: @(#)ic.mc 1.2' (Berkeley) `1/3/89'') -divert(0)dnl -include(proto.mc)dnl diff --git a/usr.sbin/sendmail/cf/cf/kappa.cf b/usr.sbin/sendmail/cf/cf/kappa.cf deleted file mode 100644 index 722534e6732c..000000000000 --- a/usr.sbin/sendmail/cf/cf/kappa.cf +++ /dev/null @@ -1,649 +0,0 @@ -########################################################################### -########################################################################### -##### -##### SENDMAIL CONFIGURATION FILE FOR NON-GATEWAY MACHINES -##### -##### Use this configuration file only on machines that -##### are neither the Internet gateway nor the UUCP -##### gateway. There are separate configuration files -##### for these gateway functions. -##### -########################################################################### -########################################################################### - - - -########## -## -## Miscellaneous configuration. -## -## Define various macros and classes that define the local -## mail and network configuration. -## -########## - -# Official domain name. -DDrice.edu - -# List of domain names that we are (at least sort of) in. $D isn't -# included here since it is multiple "words" long. It is handled -# separately when needed. -CDarpa uucp -# Bogus Domains that we aren't in, but people keep sending us mail there. -# Would you believe we even get addresses like something.rice.csnet? Sigh... -CDrice csnet csnet-east csnet-west east west mmdf - -# List of pseudo host names to treat as local (alone or in $D or $=D). -CLrice localhost loopback local - -# Name of Internet mail gateway to the outside world. -DGrice.edu -# Name of uucp mail gateway for local connections. -DViapetus.rice.edu - -# Name of UUCP routing gateway. -DWseismo.css.gov - -# UUCP hostname. -DUrice - -# Non-Internet pseudo domain names. These will not be canonicalized. -CNUUCP CSNET BITNET MAILNET MFENET CSN CHUNET JUNET COSAC SPAN - - - -########## -## -## Critical macro definitions. -## -## These macros are used to import information from the -## configuration file into sendmail. -## -########## - -# SMTP daemon name. -DnMAILER-DAEMON -# UNIX header format. -DlFrom $g $d -# Delimiter (operator) characters. -Do.:%@!^=/[] -# Format of a total name. -Dq$?x$x <$g>$|$g$. -#Dq$g$?x ($x)$. -# My official hostname ($w is already official). -Dj$w -# SMTP login message. -De$j SMTP open for business at $b. - -########## -## -## Option definitions -## -## These define the default values for various sendmail options. -## These can be overridden on the senmail command line with -## the "-o" flag. -## -########## - -# Location of alias file. -OA/usr/lib/aliases -# Wait up to ten minutes for alias file rebuild. -Oa10 -# Default delivery mode (deliver in background). -Odbackground -# Don't connect to "expensive" mailers. -Oc -# Temporary file mode. -OF0600 -# Location of help file. -OH/usr/lib/sendmail.hf -# log level -OL9 -# Default network name. ??? -ON$D -# Messages might be in old style. -Oo -# Queue directory. -OQ/usr/spool/mqueue -# Read timeout -- violates protocols. -Or2h -# Status file. -OS/etc/sendmail.st -# Queue up everything before starting transmission. -Os -# Default timeout interval. -OT7d -# Default UID. -Ou1 -# Default GID. -Og1 -# Wizard's password. -OW* -# Load average at which we just queue messages. -Ox8 -# Load average at which we refuse connections. -OX12 - -########## -## -## Message precedences -## -########## - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -########## -## -## Trusted users -## -########## - -Troot -Tuucp -Tdaemon - -########## -## -## Format of headers -## -########## - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($i); $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - -########## -## -## Rewriting rules -## -## These are applied automatically by sendmail in the following order: -## -## +--> 0 --> 2 --> R --> 4 --> resolved address -## | -## | +--> 1 --> S --+ -## addr --> 3 ---> D --| |--> 4 --> message -## +--> 2 --> R --+ -## -## D - sender domaion addition -## S - mailer specific sender rewriting -## R - mailer specific recipient rewriting -## -########## - -########## -## -## Ruleset 0 -## -## Resolve addresses to specific mailer. -## -########## - -S0 - -# Focus on the next host name in the path. If we are already focused, -# though, just use it and don't do it again. Also, there's no need -# to try to focus on a single token, so optimize this out; these are -# just simple local addresses. -R$* $:<>$1 add a marker -R<>$*<@$*>$* $:$1<@$2>$3 focused, so unmark -R<>$- $:$1 single, so unmark -R<>$* $:$>3$1 focus - -# Handle special cases. -R@ $#local$:$n handle <> form - -# Remove our own host name if it's there and start over. -R$+<@$j> $@$>0$1 @thishost -R$+<@$w> $@$>0$1 @thishost -R$+<@$w.$=D> $@$>0$1 @thishost.local-domain -R$+<@$w.$=D.$=D> $@$>0$1 @thishost.local.local -R$+<@$w.$D> $@$>0$1 @thishost.local-domain -R$+<@$=w.$=D> $@$>0$1 @thishost.local-domain -R$+<@$=w.$=D.$=D> $@$>0$1 @thishost.local.local -R$+<@$=w.$D> $@$>0$1 @thishost.local-domain -R$+<@$=w> $@$>0$1 @thishost -R<@$j>:$+ $@$>0$1 @thishost -R<@$w>:$+ $@$>0$1 @thishost -R<@$w.$=D>:$+ $@$>0$2 @thishost.local-domain -R<@$w.$=D.$=D>:$+ $@$>0$3 @thishost.local.local -R<@$w.$D>:$+ $@$>0$1 @thishost.local-domain -R<@$=w.$=D>:$+ $@$>0$3 @thishost.local-domain -R<@$=w.$=D.$=D>:$+ $@$>0$4 @thishost.local.local -R<@$=w.$D>:$+ $@$>0$2 @thishost.local-domain -R<@$=w>:$+ $@$>0$2 @thishost - -# Treat the various forms of the names $=L as all local, too. -R$+<@$=L.$D> $@$>0$1 c@local -R$+<@$D> $@$>0$1 c@local -R$+<@$=L.$=D> $@$>0$1 c@local -R$+<@$=L.$=D.$=D> $@$>0$1 c@local -R$+<@$=L> $@$>0$1 c@local -R<@$=L.$D>:$+ $@$>0$2 @local:b@c -R<@$D>:$+ $@$>0$1 @local:b@c -R<@$=L.$=D>:$+ $@$>0$3 @local:b@c -R<@$=L.$=D.$=D>:$+ $@$>0$4 @local:b@c -R<@$=L>:$+ $@$>0$2 @local:b@c - -# For known local hosts, send directly there (both normal and route addrs). -# For compatibility with older mailers in the domain that don't accept -# the .$D form of their name, we use only the simple name without the .$D in -# the $: clause here. This shouldn't be a problem since these addresses -# don't leave the local domain. -R$*<@$-.$D>$* $#domain$@$2.$D$:$1<@$2>$3 - - -# Send all UUCP addresses to the UUCP gateway. -R$*<@$+.UUCP>$* $#domain$@$V$:$1<@$2.UUCP>$3 - - - -# Other non-local names will be passed off to the gateway. -R$*<@$*>$* $#domain$@$G$:$1<@$2>$3 user@somewhere - - -# Everything else is a local name. -R$+ $#local$:$1 local names - -########## -## -## Ruleset 1 -## -## Sender address pre-rewriting. -## -########## - -S1 - -########## -## -## Ruleset 2 -## -## Recipient address pre-rewriting. -## -## Since the "$:" part of what ruleset 0 returns is passed through -## rulesets 2, R, and 4, this rule MUST focus on the next host -## name in the path. We don't need (and don't want) all of the -## canonicalization of ruleset 3, though, so we just pass it through -## ruleset 9 only. -## -########## - -S2 - -# Focus on the next host name in the path. If we are already focused, -# though, just use it and don't do it again. Also, there's no need -# to try to focus on a single token, so optimize this out; these are -# just simple local addresses. -R$* $:<>$1 add a marker -R<>$*<@$*>$* $:$1<@$2>$3 focused, so unmark -R<>$- $:$1 single, so unmark -R<>$* $:$>9$1 focus - -########## -## -## Ruleset 3 -## -## Name canonicalization. -## -## This rule can not strip off @local-host-name since this is applied -## before the sender domain addition based on the 'C' mailer flag. -## Instead, this is deferred until ruleset 9, which is called at -## the beginning of rulesets 0, 1, and 2. -## -########## - -S3 - -# Handle "from:<>" special case. -R<> $@@ turn into magic token - -# Basic textual canonicalization -- note RFC733 heuristic here. -R<$*> $1 <> nested on outside -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 flush 822 comments -R$+ at $+ $1@$2 "at" -> "@" - -# Get rid of list-name addresses. ??? -#R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax - -# Make sure <@a,@b,@c:user@d> syntax is easy to parse. -# This is undone in ruleset 4 before it is seen outside of sendmail. -R@$+,@$+ @$1:@$2 change ",@" to ":@" - -# Focus on the next host name in the path. This places <> around the -# next @hostname. -R$+ $:$>9$1 focus on domain - -# Map old UUCP connections into Internet addresses. -R$*<@lbl-csam.UUCP>$* $:$1<@LBL-CSAM.ARPA>$2 -R$*<@ut-sally.UUCP>$* $:$1<@SALLY.UTEXAS.EDU>$2 -R$*<@ut-ngp.UUCP>$* $:$1<@NGP.UTEXAS.EDU>$2 -R$*<@cornell.UUCP>$* $:$1<@CU-ARPA.CS.CORNELL.EDU>$2 -R$*<@cmucsg.UUCP>$* $:$1<@G.CS.CMU.EDU>$2 - -# Handle UUCP name changes. -R$*<@parsec.UUCP>$* $:$1<@convex.UUCP>$2 -R$*<@drilltech.UUCP>$* $:$1<@drillsys.UUCP>$2 -R$*<@drilltec.UUCP>$* $:$1<@drillsys.UUCP>$2 -R$*<@drillte.UUCP>$* $:$1<@drillsys.UUCP>$2 - -# Translate a numeric Internet address back into a name if possible. -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 try it -R$*<@[$+]>$* $@$1<@[$2]>$3 couldn't get it - -# Canonicalize local host names that explicitly have our domain. -R$*<@$-.$D>$* $:$1<@$[$2.$D$]>$3 - -# Canonicalize local host names that don't explicitly have our domain. -# For names with no domain or those in the domains we are sort of in, -# try canonicalizing the name, but put back the old name if its not found. -R$*<@$->$* $:$1<@$2><$2>$3 hide old domain -R$*<@$-.>$* $:$1<@$2><$2.>$3 hide old domain -R$*<@$-.$=D>$* $:$1<@$2><$2.$3>$4 hide old domain -R$*<@$-.$=D.$=D>$* $:$1<@$2><$2.$3.$4>$5 hide old domain -R$*<@$-><$*>$* $:$1<@$[$2$]><$3>$4 map simple name -R$*<@$+.$D><$*>$* $:$1<@$2.$D>$4 keep result -R$*<@$*><$*>$* $:$1<@$3>$4 put old domain back - -# Map old-style pseudo domains to the new official names. -R$*<@$+.OZ>$* $:$1<@$2.OZ.AU>$3 Australia -R$*<@$+.DEC>$* $:$1<@$2.DEC.COM>$3 Digital Equipment Corp -R$*<@$+.ATT>$* $:$1<@$2.ATT.COM>$3 AT&T - -# Leave non Internet addresses alone now and just return them. -R$*<@$+.$=N>$* $@$1<@$2.$3>$4 - -# Try to canonicalize anything that's left. -R$*<@$+>$* $@$1<@$[$2$]>$3 try canonicalization - -########## -## -## Ruleset 4 -## -## Final output post-rewriting. -## -########## - -S4 - -R@ $@ handle <> error addr - -R$*<@$*.>$* $:$1<@$2>$3 remove trailing dot - -R$*<$*>$* $:$1$2$3 defocus - -# Turn addresses with mixed !'s and @'s into all !-form. -# Sigh.... removed since other mailers don't understand it.... ??? -#R$*!$*@$* $:$>6$1!$2@$3 mixed ! and @ -#R$*@$*!$* $:$>6$1@$2!$3 mixed @ and ! - -# Turn route address back into correct form. -R@$+:@$+ @$1,@$2 @a:@route => @a,@route - -########## -## -## Ruleset 6 (and rulesets 7 and 8) -## -## Convert address into UUCP !-style address. -## -## Ruleset 6 is called to do the conversion. This simply sets up the -## initial arguments for ruleset 7 to do recursion on. Ruleset 7 -## then recurses on itself for each element in the path, building up -## the resultant path in !-format one element at a time in the -## leading <>s. Ruleset 8 is used as a subroutine of ruleset 7 -## to focus on the next element in the path. This is just a copy -## of the domain focusing done in ruleset 3, but the initial -## path-so-far in <>s is allowed for. -## -########## - -# Set up for initial recursion by ruleset 7. Each new element of the -# path will be added to this "<>". -S6 -R$* $@$>7<>$1 set up for recursion - -# Recurse for each element of the path, translating it and adding it to -# the path-so-far in the leading "<>". -S7 -R<$*>$*<$*>$* $:<$1>$2$3$4 defocus -R<$*>$+ $:$>8<$1>$2 focus on next element -R<$*><@$+.UUCP>:$+ $@$>7<$1!$2>$3 move into result -R<$*><@$+>:$+ $@$>7<$1!$2>$3 move into result -R<$*>$+<@$+.UUCP> $@$>7<$1!$3>$2 move into result -R<$*>$+<@$+> $@$>7<$1!$3>$2 move into result -R<$*>$+ $:<$1!$2> get leftovers -R<!$+> $:<$1> remove leading ! -R<$+> $:$1 remove markers - -# Focus on the next element of the input path. -S8 - -# Localize and dispose of route-based addresses. -R<$*>@$+:$+ $@<$1><@$2>:$3 handle <route-addr> - -# Focus on the right-most domain in the address. -R<$*>$+@$+ $:<$1>$2<@$3> focus on domain -R<$*>$+<$+@$+> <$1>$2$3<@$4> move gaze right -R<$*>$+<$+%$+> <$1>$2$3<%$4> move gaze right -R<$*>$+<@$+> $@<$1>$2<@$3> already canonical -R<$*>$+<%$+> $@<$1>$2<@$3> already canonical -R<$*>$+%$+ $:<$1>$2<%$3> focus on domain -R<$*>$+<$+%$+> <$1>$2$3<%$4> move gaze right -R<$*>$+<%$+> $@<$1>$2<@$3> already canonical - -# Convert old-style UUCP addresses to domain-based addresses. -R<$*>$+^$+ <$1>$2!$3 convert ^ to ! -R<$*>$+!$+ $:<$1><$2>!$3 focus on path -R<$*><$+!$+>$+ <$1><$2>!$3$4 move gaze left -R<$*><$+.$*>!$+ $@<$1>$4<@$2.$3> x.y!b => b@x.y -R<$*><$+>!$+ $@<$1>$3<@$2.UUCP> a!b => b@a.UUCP - -# Convert old-style BITNET addresses to domain-based addresses. -R<$*>$-=$+ $@<$1>$3<@$2.BITNET> a=b => b@a.BITNET - -# Convert old-style Berknet-syntax addresses to domain-based addresses. -R<$*>$-:$+ $@<$1>$3<@$2> host:user - -# Anything else is a local address, so just leave it alone - -########## -## -## Ruleset 9 -## -## Focus on the next host name in the path. -## -########## - -S9 - -R$*<$*>$* $1$2$3 defocus - -# Localize and dispose of route-based addresses. -R@$+:$+ $@<@$1>:$2 handle <route-addr> - -# Focus on the right-most domain in the address. -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<$+%$+> $1$2<%$3> move gaze right -R$+<@$+> $@$1<@$2> already canonical -R$+<%$+> $@$1<@$2> already canonical -R$+%$+ $:$1<%$2> focus on domain -R$+<$+%$+> $1$2<%$3> move gaze right -R$+<%$+> $@$1<@$2> already canonical - -# Convert old-style UUCP addresses to domain-based addresses. -R$+^$+ $1!$2 convert ^ to ! -R$+!$+ $:<$1>!$2 focus on path -R<$+!$+>$+ <$1>!$2$3 move gaze left -R<$+.$*>!$+ $@$3<@$1.$2> x.y!b => b@x.y -R<$+>!$+ $@$2<@$1.UUCP> a!b => b@a.UUCP - -# Convert old-style BITNET addresses to domain-based addresses. -R$-=$+ $@$2<@$1.BITNET> a=b => b@a.BITNET - -# Convert old-style Berknet-syntax addresses to domain-based addresses. -R$-:$+ $@$2<@$1> host:user - -# Anything else is a local address, so just leave it alone. - -########## -## -## Local and program mailer specifications -## -########## - -# Mailer flags specified: -# l final delivery will be performed -# m accepts multiple recipients -# n do not insert Unix-style "From " line -# r mailer wants "-r" flag for sender -# s strip quote off before calling mailer -# D wants "Date:" header line -# F wants "From:" header line -# M wants "Message-id:" header line -# -Mlocal, P=/bin/mail, F=lmnrsDFM, S=10, R=20, A=mail -d $u - -# Mailer flags specified: -# e mailer is expensive -# l final delivery will be performed -# s strip quote off before calling mailer -# D wants "Date:" header line -# F wants "From:" header line -# M wants "Message-id:" header line -# -Mprog, P=/bin/sh, F=elsDFM, S=10, R=20, A=sh -c $u - -S10 -# Convert special <> token back into a name. -R@ $n errors from myself -# Make sure we have a host name on the address. ??? -#R$*<@$+>$* $@$1<@$2>$3 already ok -#R$+ $@$1<@$j> tack on our hostname - -S20 -# Convert special <> token back into a name. -R@ $n errors to myself -# Make sure we have a host name on the address. ??? -#R$*<@$+>$* $@$1<@$2>$3 already ok -#R$+ $@$1<@$j> tack on our hostname - -########## -## -## Intra-domain mailer specification -## -## This is used for all mail within our domain. -## -########## - -# Mailer flags specified: -# m accepts multiple recipients -# s strip quote off before calling mailer -# u preserve upper case in usernames -# C add sender domain when received from mailer -# D wants "Date:" header line -# F wants "From:" header line -# M wants "Message-id:" header line -# X use RFC821 hidden dot algorithm -# -Mdomain, P=[IPC], F=msuCDFMX, S=11, R=21, A=IPC $h, E=\r\n - -S11 -R$*<@$+>$* $@$1<@$2>$3 already ok -R$+ $@$1<@$j> tack on our hostname - -S21 -R$*<@$+>$* $@$1<@$2>$3 already ok -R$+ $@$1<@$j> tack on our hostname - -########## -## -## World mailer specification -## -## This is used for all mail to the outside world. -## -########## - -# Mailer flags specified: -# m accepts multiple recipients -# s strip quote off before calling mailer -# u preserve upper case in usernames -# C add sender domain when received from mailer -# D wants "Date:" header line -# F wants "From:" header line -# L limit line lengths from RFC821 -# M wants "Message-id:" header line -# X use RFC821 hidden dot algorithm -# -Mworld, P=[IPC], F=msuCDFLMX, S=12, R=22, A=IPC $h, E=\r\n - -S12 - -# Make it look like all mail to the outside world is from the gateway. -R$*<@$-.$D>$* $@$1<@$G>$3 known local names -R$*<@$D>$* $@$1<@$G>$2 known local names -R$*<@$=L>$* $@$1<@$G>$3 known local names - -R$*<@$+>$* $@$1<@$2>$3 already has hostname -R$+ $@$1<@$G> tack on gateway name - -S22 -R$*<@$+>$* $@$1<@$2>$3 already has hostname -R$+ $@$1<@$j> tack on our hostname - -########## -## -## UUCP mailer specification -## -########## - -# Mailer flags specified: -# h preserve upper case in hostnames -# s strip quote off before calling mailer -# u preserve upper case in usernames -# C add sender domain when received from mailer -# D wants "Date:" header line -# F wants "From:" header line -# M wants "Message-id:" header line -# U use ugly UUCP-style Unix-style "From " line -# -Muucp, P=/usr/bin/uux, F=hsuCDFMU, S=13, R=23, - A=uux - -r -n -a$g -gC $h!rmail ($u) - -S13 - -R$+ $:$>6$1 turn into all ! syntax - -# Make it look like all mail from local hosts is from the gateway. -R$+!$+ $:<$1>!$2 focus on path -R<$+!$+>$+ <$1>!$2$3 move gaze left -R<$-.$D>!$+ $@$U!$2 known local names -R<$D>!$+ $@$U!$1 known local names -R<$=L>!$+ $@$U!$2 known local names -R$*<$*>$* $:$1$2$3 defocus - -R$+ $@$U!$1 add our UUCP name - -S23 -R$+ $:$>6$1 turn into all !'s - -# Turn local host names into our UUCP name. This is the name that we -# are known by to the UUCP host that we are now sending to. -R$+!$+ $:<$1>!$2 focus on path -R<$+!$+>$+ <$1>!$2$3 move gaze left -R<$-.$D>!$+ $@$U!$2 known local names -R<$D>!$+ $@$U!$1 known local names -R<$=L>!$+ $@$U!$2 known local names -R$*<$*>$* $:$1$2$3 defocus diff --git a/usr.sbin/sendmail/cf/cf/knecht.mc b/usr.sbin/sendmail/cf/cf/knecht.mc deleted file mode 100644 index 0cd17fab688f..000000000000 --- a/usr.sbin/sendmail/cf/cf/knecht.mc +++ /dev/null @@ -1,44 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)knecht.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(ultrix4.1)dnl -DOMAIN(cs.exposed)dnl -define(`LOCAL_RELAY', CS.Berkeley.EDU)dnl -MAILER(smtp)dnl - -# our local domain -DDCS.Berkeley.EDU diff --git a/usr.sbin/sendmail/cf/cf/lamprey.cf b/usr.sbin/sendmail/cf/cf/lamprey.cf deleted file mode 100644 index 33f8bf2d5fec..000000000000 --- a/usr.sbin/sendmail/cf/cf/lamprey.cf +++ /dev/null @@ -1,311 +0,0 @@ -########################################################### -# -# SENDMAIL CONFIGURATION FILE FOR SUBSIDIARY MACHINES -# -# You should install this file as /etc/sendmail.cf -# if your machine is a subsidiary machine (that is, some -# other machine in your domain is the main mail-relaying -# machine). Then edit the file to customize it for your -# network configuration. -# -# See the manual "System Administration for the Sun Workstation". -# Look at "Setting Up The Mail Routing System" in the chapter on -# Communications. The Sendmail references in the back of the -# manual are also very useful. -# -# @(#)subsidiary.mc 1.11 88/02/08 SMI; from UCB arpa.mc 3.25 2/24/83 -# - -# local UUCP connections -- not forwarded to mailhost -CV - -# my official hostname -Dj$w - -# major relay mailer -DMether - -# major relay host -DRbeach.gal.utexas.edu -CRbeach.gal.utexas.edu - -################################################# -# -# General configuration information - -# local domain names -# -# These can now be determined from the domainname system call. -# The first component of the NIS domain name is stripped off unless -# it begins with a dot or a plus sign. -# If your NIS domain is not inside the domain name you would like to have -# appear in your mail headers, add a "Dm" line to define your domain name. -# The Dm value is what is used in outgoing mail. The Cm values are -# accepted in incoming mail. By default Cm is set from Dm, but you might -# want to have more than one Cm line to recognize more than one domain -# name on incoming mail during a transition. -# Example: -# DmCS.Podunk.EDU -# Cm cs cs.Podunk.EDU -# -DmGal.UTexas.Edu -Cm Gal Gal.UTexas.Edu - -# known hosts in this domain are obtained from gethostbyname() call - -# Version number of configuration file -DVSMI-4.1 - - -### Standard macros - -# name used for error messages -DnMailer-Daemon -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$V ready at $b - -### Options - -# Remote mode - send through server if mailbox directory is mounted -OR -# location of alias file -OA/etc/aliases -# default delivery mode (deliver in background) -Odbackground -# rebuild the alias file automagically -OD -# temporary file mode -- 0600 for secure mail, 0644 for permissive -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default messages to old style -Oo -# Cc my postmaster on error replies I generate -OPPostmaster -# queue directory -OQ/usr/spool/mqueue -# read timeout for SMTP protocols -Or15m -# status file -- none -OS/etc/sendmail.st -# queue up everything before starting transmission, for safety -Os -# return queued mail after this long -OT3d -# default UID -Ou1 - -### Message precedences -Pfirst-class=0 -Pspecial-delivery=100 -Pjunk=-100 - -### Trusted users -T root daemon uucp - -### Format of headers -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$V) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> -HErrors-To: - -########################### -### Rewriting rules ### -########################### - - -# Sender Field Pre-rewriting -S1 -# None needed. - -# Recipient Field Pre-rewriting -S2 -# None needed. - -# Name Canonicalization - -# Internal format of names within the rewriting rules is: -# anything<@host.domain.domain...>anything -# We try to get every kind of name into this format, except for local -# names, which have no host part. The reason for the "<>" stuff is -# that the relevant host name could be on the front of the name (for -# source routing), or on the back (normal form). We enclose the one that -# we want to route on in the <>'s to make it easy to find. -# -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -R$*<$+>$* $2 basic RFC822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+:$+ @$1:$2:$3 change all "," to ":" -R@$+:$+ $@$>6<@$1>:$2 src route canonical - -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style names to domain-based names -# All old-style names parse from left to right, without precedence. -R$-!$+ $@$>6$2<@$1.uucp> uucphost!user -R$-.$+!$+ $@$>6$3<@$1.$2> host.domain!user -R$+%$+ $@$>3$1@$2 user%host - -# Final Output Post-rewriting -S4 -R$+<@$+.uucp> $2!$1 u@h.uucp => h!u -R$+ $: $>9 $1 Clean up addr -R$*<$+>$* $1$2$3 defocus - - -# Clean up an name for passing to a mailer -# (but leave it focused) -S9 -R$=w!@ $@$w!$n -R@ $@$n handle <> error addr -R$*<$*LOCAL>$* $1<$2$m>$3 change local info -R<@$+>$*:$+:$+ <@$1>$2,$3:$4 <route-addr> canonical - - -####################### -# Rewriting rules - -# special local conversions -S6 -R$*<@$*$=m>$* $1<@$2LOCAL>$4 convert local domain - -# Local and Program Mailer specification - -Mlocal, P=/bin/mail, F=rlsDFMmnP, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMeuP, S=10, R=20, A=sh -c $u - -S10 -# None needed. - -S20 -# None needed. - -############################################################ -##### -##### Ethernet Mailer specification -##### -##### Messages processed by this configuration are assumed to remain -##### in the same domain. This really has nothing particular to do -##### with Ethernet - the name is historical. - -Mether, P=[TCP], F=msDFMuCX, S=11, R=21, A=TCP $h -S11 -R$*<@$+>$* $@$1<@$2>$3 already ok -R$+ $@$1<@$w> tack on our hostname - -S21 -# None needed. - - - -########################################################## -# General code to convert back to old style UUCP names -S5 -R$+<@LOCAL> $@ $w!$1 name@LOCAL => sun!name -R$+<@$-.LOCAL> $@ $2!$1 u@h.LOCAL => h!u -R$+<@$+.uucp> $@ $2!$1 u@h.uucp => h!u -R$+<@$*> $@ $2!$1 u@h => h!u -# Route-addrs do not work here. Punt til uucp-mail comes up with something. -R<@$+>$* $@ @$1$2 just defocus and punt -R$*<$*>$* $@ $1$2$3 Defocus strange stuff - -# UUCP Mailer specification - -Muucp, P=/usr/bin/uux, F=msDFMhuU, S=13, R=23, - A=uux - -r -a$f $h!rmail ($u) - -# Convert uucp sender (From) field -S13 -R$+ $:$>5$1 convert to old style -R$=w!$+ $2 strip local name -R$+ $:$w!$1 stick on real host name - -# Convert uucp recipient (To, Cc) fields -S23 -R$+ $:$>5$1 convert to old style - - -##### RULESET ZERO PREAMBLE - -# Ruleset 30 just calls rulesets 3 then 0. -S30 -R$* $: $>3 $1 First canonicalize -R$* $@ $>0 $1 Then rerun ruleset 0 - -S0 -# On entry, the address has been canonicalized and focused by ruleset 3. -# Handle special cases..... -R@ $#local $:$n handle <> form -# Earlier releases special-cased the [x.y.z.a] format, but SunOS 4.1 or later -# should handle these properly on input. - -# now delete redundant local info -R$*<$*$=w.LOCAL>$* $1<$2>$4 thishost.LOCAL -R$*<@LOCAL>$* $1<@$m>$2 host == domain gateway -R$*<$*$=w.uucp>$* $1<$2>$4 thishost.uucp -R$*<$*$=w>$* $1<$2>$4 thishost - -# arrange for local names to be fully qualified -R$*<@$%y>$* $1<@$2.LOCAL>$3 user@etherhost - -# For numeric spec, you can't pass spec on to receiver, since old rcvr's -# were not smart enough to know that [x.y.z.a] is their own name. -R<@[$+]>:$* $:$>9 <@[$1]>:$2 Clean it up, then... -R<@[$+]>:$* $#ether $@[$1] $:$2 numeric internet spec -R<@[$+]>,$* $#ether $@[$1] $:$2 numeric internet spec -R$*<@[$+]> $#ether $@[$2] $:$1 numeric internet spec - -R$*<$*.>$* $1<$2>$3 drop trailing dot -R<@>:$* $@$>30$1 retry after route strip -R$*<@> $@$>30$1 strip null trash & retry - - -################################################ -### Machine dependent part of ruleset zero ### -################################################ - -# resolve names we can handle locally -R<@$=V.uucp>:$+ $:$>9 $1 First clean up, then... -R<@$=V.uucp>:$+ $#uucp $@$1 $:$2 @host.uucp:... -R$+<@$=V.uucp> $#uucp $@$2 $:$1 user@host.uucp - -# optimize names of known ethernet hosts -R$*<@$%y.LOCAL>$* $#ether $@$2 $:$1<@$2>$3 user@host.here - -# other non-local names will be kicked upstairs -R$+ $:$>9 $1 Clean up, keep <> -R$*<@$+>$* $#$M $@$R $:$1<@$2>$3 user@some.where -R$*@$* $#$M $@$R $:$1<@$2> strangeness with @ - -# Local names with % are really not local! -R$+%$+ $@$>30$1@$2 turn % => @, retry - -# everything else is a local name -R$+ $#local $:$1 local names diff --git a/usr.sbin/sendmail/cf/cf/mail.cs.mc b/usr.sbin/sendmail/cf/cf/mail.cs.mc deleted file mode 100644 index 227e2fe52ecf..000000000000 --- a/usr.sbin/sendmail/cf/cf/mail.cs.mc +++ /dev/null @@ -1,55 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)mail.cs.mc 8.3 (Berkeley) 10/15/93') -OSTYPE(ultrix4.1)dnl -DOMAIN(Berkeley)dnl -MASQUERADE_AS(CS.Berkeley.EDU)dnl -FEATURE(notsticky)dnl -MAILER(local)dnl -MAILER(smtp)dnl -define(`confUSERDB_SPEC', ``/usr/local/lib/users.cs.db,/usr/local/lib/users.eecs.db'')dnl -DDBerkeley.EDU - -# hosts for which we accept and forward mail (must be in .Berkeley.EDU) -CF CS -FF/etc/sendmail.cw - -LOCAL_RULE_0 -R< @ $=F . $D . > : $* $@ $>7 $2 @here:... -> ... -R$* $=O $* < @ $=F . $D . > $@ $>7 $1 $2 $3 ...@here -> ... - -R$* < @ $=F . $D . > $#local $: $1 use UDB diff --git a/usr.sbin/sendmail/cf/cf/mail.eecs.mc b/usr.sbin/sendmail/cf/cf/mail.eecs.mc deleted file mode 100644 index 3b6200c3a841..000000000000 --- a/usr.sbin/sendmail/cf/cf/mail.eecs.mc +++ /dev/null @@ -1,54 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)mail.eecs.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(ultrix4.1)dnl -DOMAIN(eecs.hidden)dnl -FEATURE(notsticky)dnl -MAILER(local)dnl -MAILER(smtp)dnl -define(`confUSERDB_SPEC', `/usr/local/lib/users.cs.db,/usr/local/lib/users.eecs.db')dnl -DDBerkeley.EDU - -# hosts for which we accept and forward mail (must be in .Berkeley.EDU) -CF EECS -FF/etc/sendmail.cw - -LOCAL_RULE_0 -R< @ $=F . $D . > : $* $@ $>7 $2 @here:... -> ... -R$* $=O $* < @ $=F . $D . > $@ $>7 $1 $2 $3 ...@here -> ... - -R$* < @ $=F . $D . > $#local $: $1 use UDB diff --git a/usr.sbin/sendmail/cf/cf/okeeffe.cf b/usr.sbin/sendmail/cf/cf/okeeffe.cf deleted file mode 100644 index e8d3d41379ef..000000000000 --- a/usr.sbin/sendmail/cf/cf/okeeffe.cf +++ /dev/null @@ -1,606 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)okeeffe.mc 1.3 (Berkeley) 1/3/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by phil on Wed Jan 25 11:47:02 PST 1989 -# in /usr/src/local/nettables/sendmail.cf/cf on monet.Berkeley.EDU -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/usr/lib/sendmail.cw - -# uucp hostnames -DUokeeffe -CUokeeffe - -# local UUCP connections -CV blia -CV ccicpg -CV mjk -CV pixar -CV zulu - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDBerkeley.EDU - -# Internet relay host -- machines in our domain that are not -# registered with the NIC will be "hidden" behind this relay machine -# with the % kludge, although SMTP delivery will still be performed -# by the sending machine. Someday this will go away. -DAucbvax.Berkeley.EDU - -# UUCP relay host -DRucbvax.Berkeley.EDU - -# csnet relay host -DCrelay.cs.net - -# bitnet relay host -DBjade.Berkeley.EDU - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - -############################################################ -############################################################ -##### -##### BERKELEY HOSTS REGISTERED WITH THE NIC -##### -############################################################ -############################################################ - - -CNbach ucbbach -CNbizet ucbbizet -CNcad ucbcad -CNdegas ucbdegas -CNeast ucbeast -CNernie ucbernie -CNesvax ucbesvax -CNjade ucbjade -CNji ucbji -CNmike ucbmike -CNmonet ucbmonet -CNpostgres -CNrenoir ucbrenoir -CNucbarpa -CNucbvax -CNviolet ucbviolet - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/usr/lib/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/usr/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/usr/lib/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.bitnet -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### UUCP Mailer specification -##### -############################################################ -############################################################ - - -Muucp, P=/usr/bin/uux, F=DFMhuU, S=13, R=23, M=100000, - A=uux - -r -z -a$f -gC $h!rmail ($u) - -S13 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$w!$+ $1 strip local name -R$+ $:$U!$1 stick on our host name -R$=U!$-%$- $:$1!$2@$3.$D ucbvax!user@host.domain - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $U!$1 a!b@here -> here!a!b -R$=U!$+ $2 here!a!b -> a!b -# sanity ... should not happen. -R$=U.$D!$+ $2 strip local name.domain - - -############################################################ -############################################################ -##### -##### Provide Backward Compatibility -##### -############################################################ -############################################################ - -##################################################### -# General code to convert back to old style names # -##################################################### -S5 - -R$+<@$w> $1 strip host -R$+<@$-.UUCP> $2!$1 u@host.UUCP => host!u - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - -# resolve local UUCP connections -R<@$=V.UUCP>:$+ $#uucp$@$1$:$2 @host.UUCP:... -R$+<@$=V.UUCP> $#uucp$@$2$:$1 user@host.UUCP - - -# resolve fake top level domains by forwarding to other hosts -R$*<@$+.BITNET>$* $#tcp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET -R$*<@$+.CSNET>$* $#tcp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET - - -# forward non-local UUCP traffic to our UUCP relay -R$*<@$*.UUCP>$* $#tcpld$@$R$:$1<@$2.UUCP> uucp mail - -# resolve SMTP traffic -R$*<@$*.$D>$* $#tcpld$@$2.$D$:$1<@$2.$D>$3 user@host.ourdomain -R$*<@$+>$* $#tcp$@$2$:$1<@$2>$3 user@host.ourdomain - -# remaining names must be local -R$+ $#local$:$1 everything else - diff --git a/usr.sbin/sendmail/cf/cf/okeeffe.mc b/usr.sbin/sendmail/cf/cf/okeeffe.mc deleted file mode 100644 index 15f862948a5c..000000000000 --- a/usr.sbin/sendmail/cf/cf/okeeffe.mc +++ /dev/null @@ -1,17 +0,0 @@ -divert(10)dnl -# -# okeeffe configuration file -# -# @(#)okeeffe.mc 1.3 (Berkeley) 1/3/89 -# -define(DOMAIN, `DDBerkeley.EDU') -define(UUCP_NAME, DUokeeffe) -define(UUCP_ALIASES, CUokeeffe) -define(UUCP_HOSTS_FILE, ../sitedep/uucp.okeeffe.m4) -define(INTERNET_RELAY, `DAucbvax.Berkeley.EDU') -define(UUCP_RELAY, DRucbvax.Berkeley.EDU) -define(BITNET_RELAY, `DBjade.Berkeley.EDU') -define(CSNET_RELAY, `DCrelay.cs.net') -define(EXTERNAL_VERSION, ``#' `@(#)okeeffe.mc 1.3' (Berkeley) `1/3/89'') -divert(0)dnl -include(proto.mc) diff --git a/usr.sbin/sendmail/cf/cf/osf1-cs-exposed.mc b/usr.sbin/sendmail/cf/cf/osf1-cs-exposed.mc deleted file mode 100644 index eaed6cc4e529..000000000000 --- a/usr.sbin/sendmail/cf/cf/osf1-cs-exposed.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)osf1-cs-exposed.mc 8.1 (Berkeley) 10/15/93') -OSTYPE(osf1)dnl -DOMAIN(cs.exposed)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/osf1-cs-hidden.mc b/usr.sbin/sendmail/cf/cf/osf1-cs-hidden.mc deleted file mode 100644 index 2b85ba4be179..000000000000 --- a/usr.sbin/sendmail/cf/cf/osf1-cs-hidden.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)osf1-cs-hidden.mc 8.1 (Berkeley) 10/15/93') -OSTYPE(osf1)dnl -DOMAIN(cs.hidden)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/proto.mc b/usr.sbin/sendmail/cf/cf/proto.mc deleted file mode 100644 index f56d9373631f..000000000000 --- a/usr.sbin/sendmail/cf/cf/proto.mc +++ /dev/null @@ -1,113 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -ifdef(`EXTERNAL_VERSION', EXTERNAL_VERSION, `#') -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -sinclude(buildinfo)dnl -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -`#' file containing our internet aliases -Fw/etc/sendmail.cw - -ifdef(`UUCP_NAME', -`#' uucp hostnames -UUCP_NAME -UUCP_ALIASES - -`#' local UUCP connections -`include(UUCP_HOSTS_FILE)') - -############################# -### Setup Information ### -############################# - -include(../m4/nsmacros.m4) -include(../m4/nsclasses.m4) -ifdef(`INTERNET_RELAY', -`include(../sitedep/nicregistered.m4)') -include(../m4/version.m4) -include(../m4/boilerplate.m4) - -########################### -### Rewriting Rules ### -########################### - -include(../m4/prewriterule.m4) -include(../m4/postwriterule.m4) -include(../m4/rule3.m4) - -################### -### Mailers ### -################### - -include(../m4/localm.m4) -ifdef(`UUCP_ONLY',, -`include(../m4/nstcpldm.m4)') -include(../m4/nstcpm.m4) -ifdef(`UUCP_NAME', -`include(../m4/uucpm.m4)' -`include(../m4/rule5.m4)') -ifdef(`SMTPUUCP', -`include(../m4/smtpuucpm.m4)') - -##################### -### Rule Zero ### -##################### - -include(../m4/rule0.m4) - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - -ifdef(`SMTPUUCP', -`# resolve SMTP UUCP connections' -`include(SMTPUUCP)') - -ifdef(`UUCP_NAME', -`# resolve local UUCP connections' -`R<@$=V.UUCP>:$+ $#uucp$@$1$:$2 @host.UUCP:...' -`R$+<@$=V.UUCP> $#uucp$@$2$:$1 user@host.UUCP' -) - -ifdef(`UUCP_ONLY',, -`#' resolve fake top level domains by forwarding to other hosts -`include(../m4/fake_domains.m4)' - -`ifdef(`UUCP_RELAY', -`#' forward non-local UUCP traffic to our UUCP relay -R$*<@$*.UUCP>$* $`#'tcpld$@$R$:$1<@$2.UUCP> uucp mail)' - -`ifdef(`ARPAKLUDGE', -`#' hide behind our internet relay when talking to people in the arpa domain -R$*<@$*.arpa>$* $`#'tcp$@$2.arpa$:$1<@$2.arpa>$3 user@host.arpa - -`#' but speak domains to them if they speak domains too -R$*<@$*>$* $`#'tcpld$@$2$:$1<@$2>$3 user@host.domain, -`#' resolve SMTP traffic -`ifdef(`INTERNET_RELAY', -R$*<@$*.$D>$* $`#'tcpld$@$2.$D$:$1<@$2.$D>$3 user@host.ourdomain -R$*<@$+>$* $`#'tcp$@$2$:$1<@$2>$3 user@host.ourdomain, -R$*<@$+>$* $`#'tcpld$@$2$:$1<@$2>$3 user@host.domain)')') - -# remaining names must be local -R$+ $#local$:$1 everything else diff --git a/usr.sbin/sendmail/cf/cf/riscos-cs-exposed.mc b/usr.sbin/sendmail/cf/cf/riscos-cs-exposed.mc deleted file mode 100644 index a92b7709c2fb..000000000000 --- a/usr.sbin/sendmail/cf/cf/riscos-cs-exposed.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)riscos-cs-exposed.mc 8.1 (Berkeley) 12/1/93') -OSTYPE(riscos4.5)dnl -DOMAIN(cs.exposed)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/s2k.mc b/usr.sbin/sendmail/cf/cf/s2k.mc deleted file mode 100644 index e65fc9f54f19..000000000000 --- a/usr.sbin/sendmail/cf/cf/s2k.mc +++ /dev/null @@ -1,42 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)s2k.mc 8.1 (Berkeley) 6/7/93') -OLDSENDMAIL -OSTYPE(ultrix4.1)dnl -DOMAIN(s2k)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/sunos3.5-cs-exposed.mc b/usr.sbin/sendmail/cf/cf/sunos3.5-cs-exposed.mc deleted file mode 100644 index 46d04d96e2a0..000000000000 --- a/usr.sbin/sendmail/cf/cf/sunos3.5-cs-exposed.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)sunos3.5-cs-exposed.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(sunos3.5)dnl -DOMAIN(cs.exposed)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/sunos3.5-cs-hidden.mc b/usr.sbin/sendmail/cf/cf/sunos3.5-cs-hidden.mc deleted file mode 100644 index a3d6f20efb18..000000000000 --- a/usr.sbin/sendmail/cf/cf/sunos3.5-cs-hidden.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)sunos3.5-cs-hidden.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(sunos3.5)dnl -DOMAIN(cs.hidden)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/sunos4.1-cs-exposed.mc b/usr.sbin/sendmail/cf/cf/sunos4.1-cs-exposed.mc deleted file mode 100644 index 7c94ba5ab778..000000000000 --- a/usr.sbin/sendmail/cf/cf/sunos4.1-cs-exposed.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)sunos4.1-cs-exposed.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(sunos4.1)dnl -DOMAIN(cs.exposed)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/sunos4.1-cs-hidden.mc b/usr.sbin/sendmail/cf/cf/sunos4.1-cs-hidden.mc deleted file mode 100644 index 8e1dbb96844d..000000000000 --- a/usr.sbin/sendmail/cf/cf/sunos4.1-cs-hidden.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)sunos4.1-cs-hidden.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(sunos4.1)dnl -DOMAIN(cs.hidden)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/tcpproto.cf b/usr.sbin/sendmail/cf/cf/tcpproto.cf deleted file mode 100644 index ebe1238ae7e2..000000000000 --- a/usr.sbin/sendmail/cf/cf/tcpproto.cf +++ /dev/null @@ -1,517 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)tcpproto.mc 1.2 (Berkeley) 1/24/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by phil on Wed Jan 25 11:48:18 PST 1989 -# in /usr/src/local/nettables/sendmail.cf/cf on monet.Berkeley.EDU -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/usr/lib/sendmail.cw - - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDYOUR_DOMAIN_GOES_HERE - - - -# UUCP relay host -DRYOUR_UUCP_RELAY_GOES_HERE - -# csnet relay host -DCYOUR_CSNET_RELAY_GOES_HERE - -# bitnet relay host -DBYOUR_BITNET_RELAY_GOES_HERE - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/usr/lib/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/usr/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/usr/lib/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.bitnet -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - - - -# resolve fake top level domains by forwarding to other hosts -R$*<@$+.BITNET>$* $#tcp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET -R$*<@$+.CSNET>$* $#tcp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET - - -# forward non-local UUCP traffic to our UUCP relay -R$*<@$*.UUCP>$* $#tcpld$@$R$:$1<@$2.UUCP> uucp mail - -# hide behind our internet relay when talking to people in the arpa domain -R$*<@$*.arpa>$* $#tcp$@$2.arpa$:$1<@$2.arpa>$3 user@host.arpa - -# but speak domains to them if they speak domains too -R$*<@$*>$* $#tcpld$@$2$:$1<@$2>$3 user@host.domain - -# remaining names must be local -R$+ $#local$:$1 everything else diff --git a/usr.sbin/sendmail/cf/cf/tcpuucpproto.cf b/usr.sbin/sendmail/cf/cf/tcpuucpproto.cf deleted file mode 100644 index 173f1cf7448f..000000000000 --- a/usr.sbin/sendmail/cf/cf/tcpuucpproto.cf +++ /dev/null @@ -1,572 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)tcpuucpproto.mc 1.2 (Berkeley) 1/24/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by phil on Wed Jan 25 11:48:29 PST 1989 -# in /usr/src/local/nettables/sendmail.cf/cf on monet.Berkeley.EDU -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/usr/lib/sendmail.cw - -# uucp hostnames -DUYOUR_UUCP_NAME_GOES_HERE -CUYOUR_UUCP_ALIASES_GO_HERE - -# local UUCP connections -CV YOUR -CV UUCP -CV NEIGHBORS -CV GO -CV HERE - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDYOUR_DOMAIN_GOES_HERE - - - - - -# csnet relay host -DCYOUR_CSNET_RELAY_GOES_HERE - -# bitnet relay host -DBYOUR_BITNET_RELAY_GOES_HERE - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/usr/lib/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/usr/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/usr/lib/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.bitnet -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### UUCP Mailer specification -##### -############################################################ -############################################################ - - -Muucp, P=/usr/bin/uux, F=DFMhuU, S=13, R=23, M=100000, - A=uux - -r -z -a$f -gC $h!rmail ($u) - -S13 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$w!$+ $1 strip local name -R$+ $:$U!$1 stick on our host name -R$=U!$-%$- $:$1!$2@$3.$D ucbvax!user@host.domain - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $U!$1 a!b@here -> here!a!b -R$=U!$+ $2 here!a!b -> a!b -# sanity ... should not happen. -R$=U.$D!$+ $2 strip local name.domain - - -############################################################ -############################################################ -##### -##### Provide Backward Compatibility -##### -############################################################ -############################################################ - -##################################################### -# General code to convert back to old style names # -##################################################### -S5 - -R$+<@$w> $1 strip host -R$+<@$-.UUCP> $2!$1 u@host.UUCP => host!u - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - -# resolve local UUCP connections -R<@$=V.UUCP>:$+ $#uucp$@$1$:$2 @host.UUCP:... -R$+<@$=V.UUCP> $#uucp$@$2$:$1 user@host.UUCP - - -# resolve fake top level domains by forwarding to other hosts -R$*<@$+.BITNET>$* $#tcp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET -R$*<@$+.CSNET>$* $#tcp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET - - - - -# resolve SMTP traffic -R$*<@$+>$* $#tcpld$@$2$:$1<@$2>$3 user@host.domain - -# remaining names must be local -R$+ $#local$:$1 everything else diff --git a/usr.sbin/sendmail/cf/cf/tcpuucpproto.mc b/usr.sbin/sendmail/cf/cf/tcpuucpproto.mc deleted file mode 100644 index e4d672064bd4..000000000000 --- a/usr.sbin/sendmail/cf/cf/tcpuucpproto.mc +++ /dev/null @@ -1,15 +0,0 @@ -divert(10)dnl -# -# Prototype configuration file for a UUCP hub on a TCP/IP (SMTP) based network -# -# @(#)tcpuucpproto.mc 1.2 (Berkeley) 1/24/89 -# -define(DOMAIN, `DDYOUR_DOMAIN_GOES_HERE') -define(BITNET_RELAY, `DBYOUR_BITNET_RELAY_GOES_HERE') -define(CSNET_RELAY, `DCYOUR_CSNET_RELAY_GOES_HERE') -define(UUCP_NAME, `DUYOUR_UUCP_NAME_GOES_HERE') -define(UUCP_ALIASES, CUYOUR_UUCP_ALIASES_GO_HERE) -define(UUCP_HOSTS_FILE, ../sitedep/uucp.proto.m4) -define(EXTERNAL_VERSION, ``#' `@(#)tcpuucpproto.mc 1.2' (Berkeley) `1/24/89'') -divert(0)dnl -include(proto.mc)dnl diff --git a/usr.sbin/sendmail/cf/cf/telemuse.cf b/usr.sbin/sendmail/cf/cf/telemuse.cf deleted file mode 100644 index bedd9d1b1a79..000000000000 --- a/usr.sbin/sendmail/cf/cf/telemuse.cf +++ /dev/null @@ -1,649 +0,0 @@ -########################################################################### -########################################################################### -##### -##### SENDMAIL CONFIGURATION FILE FOR NON-GATEWAY MACHINES -##### -##### Use this configuration file only on machines that -##### are neither the Internet gateway nor the UUCP -##### gateway. There are separate configuration files -##### for these gateway functions. -##### -########################################################################### -########################################################################### - - - -########## -## -## Miscellaneous configuration. -## -## Define various macros and classes that define the local -## mail and network configuration. -## -########## - -# Official domain name. -DDTeleMuse.com - -# List of domain names that we are (at least sort of) in. $D isn't -# included here since it is multiple "words" long. It is handled -# separately when needed. -#CDarpa uucp -# Bogus Domains that we aren't in, but people keep sending us mail there. -# Would you believe we even get addresses like something.rice.csnet? Sigh... -#CDrice csnet csnet-east csnet-west east west mmdf - -# List of pseudo host names to treat as local (alone or in $D or $=D). -CLlocalhost loopback local - -# Name of Internet mail gateway to the outside world. -DGtelemuse.com -# Name of uucp mail gateway for local connections. -DVtelemuse.com - -# Name of UUCP routing gateway. -#DWseismo.css.gov - -# UUCP hostname. -DUtelemuse - -# Non-Internet pseudo domain names. These will not be canonicalized. -CNUUCP CSNET BITNET MAILNET MFENET CSN CHUNET JUNET COSAC SPAN - - - -########## -## -## Critical macro definitions. -## -## These macros are used to import information from the -## configuration file into sendmail. -## -########## - -# SMTP daemon name. -DnMAILER-DAEMON -# UNIX header format. -DlFrom $g $d -# Delimiter (operator) characters. -Do.:%@!^=/[] -# Format of a total name. -Dq$?x$x <$g>$|$g$. -#Dq$g$?x ($x)$. -# My official hostname ($w is already official). -Dj$w -# SMTP login message. -De$j SMTP open for business at $b. - -########## -## -## Option definitions -## -## These define the default values for various sendmail options. -## These can be overridden on the senmail command line with -## the "-o" flag. -## -########## - -# Location of alias file. -OA/etc/aliases -# Wait up to ten minutes for alias file rebuild. -Oa10 -# Default delivery mode (deliver in background). -Odbackground -# Don't connect to "expensive" mailers. -Oc -# Temporary file mode. -OF0600 -# Location of help file. -OH/usr/share/misc/sendmail.hf -# log level -OL9 -# Default network name. ??? -ON$D -# Messages might be in old style. -Oo -# Queue directory. -OQ/var/spool/mqueue -# Read timeout -- violates protocols. -Or2h -# Status file. -OS/etc/sendmail.st -# Queue up everything before starting transmission. -Os -# Default timeout interval. -OT7d -# Default UID. -Ou1 -# Default GID. -Og1 -# Wizard's password. -OW* -# Load average at which we just queue messages. -Ox8 -# Load average at which we refuse connections. -OX12 - -########## -## -## Message precedences -## -########## - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -########## -## -## Trusted users -## -########## - -Troot -Tuucp -Tdaemon - -########## -## -## Format of headers -## -########## - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($i); $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - -########## -## -## Rewriting rules -## -## These are applied automatically by sendmail in the following order: -## -## +--> 0 --> 2 --> R --> 4 --> resolved address -## | -## | +--> 1 --> S --+ -## addr --> 3 ---> D --| |--> 4 --> message -## +--> 2 --> R --+ -## -## D - sender domaion addition -## S - mailer specific sender rewriting -## R - mailer specific recipient rewriting -## -########## - -########## -## -## Ruleset 0 -## -## Resolve addresses to specific mailer. -## -########## - -S0 - -# Focus on the next host name in the path. If we are already focused, -# though, just use it and don't do it again. Also, there's no need -# to try to focus on a single token, so optimize this out; these are -# just simple local addresses. -R$* $:<>$1 add a marker -R<>$*<@$*>$* $:$1<@$2>$3 focused, so unmark -R<>$- $:$1 single, so unmark -R<>$* $:$>3$1 focus - -# Handle special cases. -R@ $#local$:$n handle <> form - -# Remove our own host name if it's there and start over. -R$+<@$j> $@$>0$1 @thishost -R$+<@$w> $@$>0$1 @thishost -R$+<@$w.$=D> $@$>0$1 @thishost.local-domain -R$+<@$w.$=D.$=D> $@$>0$1 @thishost.local.local -R$+<@$w.$D> $@$>0$1 @thishost.local-domain -R$+<@$=w.$=D> $@$>0$1 @thishost.local-domain -R$+<@$=w.$=D.$=D> $@$>0$1 @thishost.local.local -R$+<@$=w.$D> $@$>0$1 @thishost.local-domain -R$+<@$=w> $@$>0$1 @thishost -R<@$j>:$+ $@$>0$1 @thishost -R<@$w>:$+ $@$>0$1 @thishost -R<@$w.$=D>:$+ $@$>0$2 @thishost.local-domain -R<@$w.$=D.$=D>:$+ $@$>0$3 @thishost.local.local -R<@$w.$D>:$+ $@$>0$1 @thishost.local-domain -R<@$=w.$=D>:$+ $@$>0$3 @thishost.local-domain -R<@$=w.$=D.$=D>:$+ $@$>0$4 @thishost.local.local -R<@$=w.$D>:$+ $@$>0$2 @thishost.local-domain -R<@$=w>:$+ $@$>0$2 @thishost - -# Treat the various forms of the names $=L as all local, too. -R$+<@$=L.$D> $@$>0$1 c@local -R$+<@$D> $@$>0$1 c@local -R$+<@$=L.$=D> $@$>0$1 c@local -R$+<@$=L.$=D.$=D> $@$>0$1 c@local -R$+<@$=L> $@$>0$1 c@local -R<@$=L.$D>:$+ $@$>0$2 @local:b@c -R<@$D>:$+ $@$>0$1 @local:b@c -R<@$=L.$=D>:$+ $@$>0$3 @local:b@c -R<@$=L.$=D.$=D>:$+ $@$>0$4 @local:b@c -R<@$=L>:$+ $@$>0$2 @local:b@c - -# For known local hosts, send directly there (both normal and route addrs). -# For compatibility with older mailers in the domain that don't accept -# the .$D form of their name, we use only the simple name without the .$D in -# the $: clause here. This shouldn't be a problem since these addresses -# don't leave the local domain. -R$*<@$-.$D>$* $#domain$@$2.$D$:$1<@$2>$3 - - -# Send all UUCP addresses to the UUCP gateway. -R$*<@$+.UUCP>$* $#domain$@$V$:$1<@$2.UUCP>$3 - - - -# Other non-local names will be passed off to the gateway. -R$*<@$*>$* $#domain$@$G$:$1<@$2>$3 user@somewhere - - -# Everything else is a local name. -R$+ $#local$:$1 local names - -########## -## -## Ruleset 1 -## -## Sender address pre-rewriting. -## -########## - -S1 - -########## -## -## Ruleset 2 -## -## Recipient address pre-rewriting. -## -## Since the "$:" part of what ruleset 0 returns is passed through -## rulesets 2, R, and 4, this rule MUST focus on the next host -## name in the path. We don't need (and don't want) all of the -## canonicalization of ruleset 3, though, so we just pass it through -## ruleset 9 only. -## -########## - -S2 - -# Focus on the next host name in the path. If we are already focused, -# though, just use it and don't do it again. Also, there's no need -# to try to focus on a single token, so optimize this out; these are -# just simple local addresses. -R$* $:<>$1 add a marker -R<>$*<@$*>$* $:$1<@$2>$3 focused, so unmark -R<>$- $:$1 single, so unmark -R<>$* $:$>9$1 focus - -########## -## -## Ruleset 3 -## -## Name canonicalization. -## -## This rule can not strip off @local-host-name since this is applied -## before the sender domain addition based on the 'C' mailer flag. -## Instead, this is deferred until ruleset 9, which is called at -## the beginning of rulesets 0, 1, and 2. -## -########## - -S3 - -# Handle "from:<>" special case. -R<> $@@ turn into magic token - -# Basic textual canonicalization -- note RFC733 heuristic here. -R<$*> $1 <> nested on outside -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 flush 822 comments -R$+ at $+ $1@$2 "at" -> "@" - -# Get rid of list-name addresses. ??? -#R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax - -# Make sure <@a,@b,@c:user@d> syntax is easy to parse. -# This is undone in ruleset 4 before it is seen outside of sendmail. -R@$+,@$+ @$1:@$2 change ",@" to ":@" - -# Focus on the next host name in the path. This places <> around the -# next @hostname. -R$+ $:$>9$1 focus on domain - -# Map old UUCP connections into Internet addresses. -R$*<@lbl-csam.UUCP>$* $:$1<@LBL-CSAM.ARPA>$2 -R$*<@ut-sally.UUCP>$* $:$1<@SALLY.UTEXAS.EDU>$2 -R$*<@ut-ngp.UUCP>$* $:$1<@NGP.UTEXAS.EDU>$2 -R$*<@cornell.UUCP>$* $:$1<@CU-ARPA.CS.CORNELL.EDU>$2 -R$*<@cmucsg.UUCP>$* $:$1<@G.CS.CMU.EDU>$2 - -# Handle UUCP name changes. -R$*<@parsec.UUCP>$* $:$1<@convex.UUCP>$2 -R$*<@drilltech.UUCP>$* $:$1<@drillsys.UUCP>$2 -R$*<@drilltec.UUCP>$* $:$1<@drillsys.UUCP>$2 -R$*<@drillte.UUCP>$* $:$1<@drillsys.UUCP>$2 - -# Translate a numeric Internet address back into a name if possible. -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 try it -R$*<@[$+]>$* $@$1<@[$2]>$3 couldn't get it - -# Canonicalize local host names that explicitly have our domain. -R$*<@$-.$D>$* $:$1<@$[$2.$D$]>$3 - -# Canonicalize local host names that don't explicitly have our domain. -# For names with no domain or those in the domains we are sort of in, -# try canonicalizing the name, but put back the old name if its not found. -R$*<@$->$* $:$1<@$2><$2>$3 hide old domain -R$*<@$-.>$* $:$1<@$2><$2.>$3 hide old domain -R$*<@$-.$=D>$* $:$1<@$2><$2.$3>$4 hide old domain -R$*<@$-.$=D.$=D>$* $:$1<@$2><$2.$3.$4>$5 hide old domain -R$*<@$-><$*>$* $:$1<@$[$2$]><$3>$4 map simple name -R$*<@$+.$D><$*>$* $:$1<@$2.$D>$4 keep result -R$*<@$*><$*>$* $:$1<@$3>$4 put old domain back - -# Map old-style pseudo domains to the new official names. -R$*<@$+.OZ>$* $:$1<@$2.OZ.AU>$3 Australia -R$*<@$+.DEC>$* $:$1<@$2.DEC.COM>$3 Digital Equipment Corp -R$*<@$+.ATT>$* $:$1<@$2.ATT.COM>$3 AT&T - -# Leave non Internet addresses alone now and just return them. -R$*<@$+.$=N>$* $@$1<@$2.$3>$4 - -# Try to canonicalize anything that's left. -R$*<@$+>$* $@$1<@$[$2$]>$3 try canonicalization - -########## -## -## Ruleset 4 -## -## Final output post-rewriting. -## -########## - -S4 - -R@ $@ handle <> error addr - -R$*<@$*.>$* $:$1<@$2>$3 remove trailing dot - -R$*<$*>$* $:$1$2$3 defocus - -# Turn addresses with mixed !'s and @'s into all !-form. -# Sigh.... removed since other mailers don't understand it.... ??? -#R$*!$*@$* $:$>6$1!$2@$3 mixed ! and @ -#R$*@$*!$* $:$>6$1@$2!$3 mixed @ and ! - -# Turn route address back into correct form. -R@$+:@$+ @$1,@$2 @a:@route => @a,@route - -########## -## -## Ruleset 6 (and rulesets 7 and 8) -## -## Convert address into UUCP !-style address. -## -## Ruleset 6 is called to do the conversion. This simply sets up the -## initial arguments for ruleset 7 to do recursion on. Ruleset 7 -## then recurses on itself for each element in the path, building up -## the resultant path in !-format one element at a time in the -## leading <>s. Ruleset 8 is used as a subroutine of ruleset 7 -## to focus on the next element in the path. This is just a copy -## of the domain focusing done in ruleset 3, but the initial -## path-so-far in <>s is allowed for. -## -########## - -# Set up for initial recursion by ruleset 7. Each new element of the -# path will be added to this "<>". -S6 -R$* $@$>7<>$1 set up for recursion - -# Recurse for each element of the path, translating it and adding it to -# the path-so-far in the leading "<>". -S7 -R<$*>$*<$*>$* $:<$1>$2$3$4 defocus -R<$*>$+ $:$>8<$1>$2 focus on next element -R<$*><@$+.UUCP>:$+ $@$>7<$1!$2>$3 move into result -R<$*><@$+>:$+ $@$>7<$1!$2>$3 move into result -R<$*>$+<@$+.UUCP> $@$>7<$1!$3>$2 move into result -R<$*>$+<@$+> $@$>7<$1!$3>$2 move into result -R<$*>$+ $:<$1!$2> get leftovers -R<!$+> $:<$1> remove leading ! -R<$+> $:$1 remove markers - -# Focus on the next element of the input path. -S8 - -# Localize and dispose of route-based addresses. -R<$*>@$+:$+ $@<$1><@$2>:$3 handle <route-addr> - -# Focus on the right-most domain in the address. -R<$*>$+@$+ $:<$1>$2<@$3> focus on domain -R<$*>$+<$+@$+> <$1>$2$3<@$4> move gaze right -R<$*>$+<$+%$+> <$1>$2$3<%$4> move gaze right -R<$*>$+<@$+> $@<$1>$2<@$3> already canonical -R<$*>$+<%$+> $@<$1>$2<@$3> already canonical -R<$*>$+%$+ $:<$1>$2<%$3> focus on domain -R<$*>$+<$+%$+> <$1>$2$3<%$4> move gaze right -R<$*>$+<%$+> $@<$1>$2<@$3> already canonical - -# Convert old-style UUCP addresses to domain-based addresses. -R<$*>$+^$+ <$1>$2!$3 convert ^ to ! -R<$*>$+!$+ $:<$1><$2>!$3 focus on path -R<$*><$+!$+>$+ <$1><$2>!$3$4 move gaze left -R<$*><$+.$*>!$+ $@<$1>$4<@$2.$3> x.y!b => b@x.y -R<$*><$+>!$+ $@<$1>$3<@$2.UUCP> a!b => b@a.UUCP - -# Convert old-style BITNET addresses to domain-based addresses. -R<$*>$-=$+ $@<$1>$3<@$2.BITNET> a=b => b@a.BITNET - -# Convert old-style Berknet-syntax addresses to domain-based addresses. -R<$*>$-:$+ $@<$1>$3<@$2> host:user - -# Anything else is a local address, so just leave it alone - -########## -## -## Ruleset 9 -## -## Focus on the next host name in the path. -## -########## - -S9 - -R$*<$*>$* $1$2$3 defocus - -# Localize and dispose of route-based addresses. -R@$+:$+ $@<@$1>:$2 handle <route-addr> - -# Focus on the right-most domain in the address. -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<$+%$+> $1$2<%$3> move gaze right -R$+<@$+> $@$1<@$2> already canonical -R$+<%$+> $@$1<@$2> already canonical -R$+%$+ $:$1<%$2> focus on domain -R$+<$+%$+> $1$2<%$3> move gaze right -R$+<%$+> $@$1<@$2> already canonical - -# Convert old-style UUCP addresses to domain-based addresses. -R$+^$+ $1!$2 convert ^ to ! -R$+!$+ $:<$1>!$2 focus on path -R<$+!$+>$+ <$1>!$2$3 move gaze left -R<$+.$*>!$+ $@$3<@$1.$2> x.y!b => b@x.y -R<$+>!$+ $@$2<@$1.UUCP> a!b => b@a.UUCP - -# Convert old-style BITNET addresses to domain-based addresses. -R$-=$+ $@$2<@$1.BITNET> a=b => b@a.BITNET - -# Convert old-style Berknet-syntax addresses to domain-based addresses. -R$-:$+ $@$2<@$1> host:user - -# Anything else is a local address, so just leave it alone. - -########## -## -## Local and program mailer specifications -## -########## - -# Mailer flags specified: -# l final delivery will be performed -# m accepts multiple recipients -# n do not insert Unix-style "From " line -# r mailer wants "-r" flag for sender -# s strip quote off before calling mailer -# D wants "Date:" header line -# F wants "From:" header line -# M wants "Message-id:" header line -# -Mlocal, P=/bin/mail, F=lmnrsDFM, S=10, R=20, A=mail -d $u - -# Mailer flags specified: -# e mailer is expensive -# l final delivery will be performed -# s strip quote off before calling mailer -# D wants "Date:" header line -# F wants "From:" header line -# M wants "Message-id:" header line -# -Mprog, P=/bin/sh, F=elsDFM, S=10, R=20, A=sh -c $u - -S10 -# Convert special <> token back into a name. -R@ $n errors from myself -# Make sure we have a host name on the address. ??? -#R$*<@$+>$* $@$1<@$2>$3 already ok -#R$+ $@$1<@$j> tack on our hostname - -S20 -# Convert special <> token back into a name. -R@ $n errors to myself -# Make sure we have a host name on the address. ??? -#R$*<@$+>$* $@$1<@$2>$3 already ok -#R$+ $@$1<@$j> tack on our hostname - -########## -## -## Intra-domain mailer specification -## -## This is used for all mail within our domain. -## -########## - -# Mailer flags specified: -# m accepts multiple recipients -# s strip quote off before calling mailer -# u preserve upper case in usernames -# C add sender domain when received from mailer -# D wants "Date:" header line -# F wants "From:" header line -# M wants "Message-id:" header line -# X use RFC821 hidden dot algorithm -# -Mdomain, P=[IPC], F=msuCDFMX, S=11, R=21, A=IPC $h, E=\r\n - -S11 -R$*<@$+>$* $@$1<@$2>$3 already ok -R$+ $@$1<@$j> tack on our hostname - -S21 -R$*<@$+>$* $@$1<@$2>$3 already ok -R$+ $@$1<@$j> tack on our hostname - -########## -## -## World mailer specification -## -## This is used for all mail to the outside world. -## -########## - -# Mailer flags specified: -# m accepts multiple recipients -# s strip quote off before calling mailer -# u preserve upper case in usernames -# C add sender domain when received from mailer -# D wants "Date:" header line -# F wants "From:" header line -# L limit line lengths from RFC821 -# M wants "Message-id:" header line -# X use RFC821 hidden dot algorithm -# -Mworld, P=[IPC], F=msuCDFLMX, S=12, R=22, A=IPC $h, E=\r\n - -S12 - -# Make it look like all mail to the outside world is from the gateway. -R$*<@$-.$D>$* $@$1<@$G>$3 known local names -R$*<@$D>$* $@$1<@$G>$2 known local names -R$*<@$=L>$* $@$1<@$G>$3 known local names - -R$*<@$+>$* $@$1<@$2>$3 already has hostname -R$+ $@$1<@$G> tack on gateway name - -S22 -R$*<@$+>$* $@$1<@$2>$3 already has hostname -R$+ $@$1<@$j> tack on our hostname - -########## -## -## UUCP mailer specification -## -########## - -# Mailer flags specified: -# h preserve upper case in hostnames -# s strip quote off before calling mailer -# u preserve upper case in usernames -# C add sender domain when received from mailer -# D wants "Date:" header line -# F wants "From:" header line -# M wants "Message-id:" header line -# U use ugly UUCP-style Unix-style "From " line -# -Muucp, P=/usr/bin/uux, F=hsuCDFMU, S=13, R=23, - A=uux - -r -n -a$g -gC $h!rmail ($u) - -S13 - -R$+ $:$>6$1 turn into all ! syntax - -# Make it look like all mail from local hosts is from the gateway. -R$+!$+ $:<$1>!$2 focus on path -R<$+!$+>$+ <$1>!$2$3 move gaze left -R<$-.$D>!$+ $@$U!$2 known local names -R<$D>!$+ $@$U!$1 known local names -R<$=L>!$+ $@$U!$2 known local names -R$*<$*>$* $:$1$2$3 defocus - -R$+ $@$U!$1 add our UUCP name - -S23 -R$+ $:$>6$1 turn into all !'s - -# Turn local host names into our UUCP name. This is the name that we -# are known by to the UUCP host that we are now sending to. -R$+!$+ $:<$1>!$2 focus on path -R<$+!$+>$+ <$1>!$2$3 move gaze left -R<$-.$D>!$+ $@$U!$2 known local names -R<$D>!$+ $@$U!$1 known local names -R<$=L>!$+ $@$U!$2 known local names -R$*<$*>$* $:$1$2$3 defocus diff --git a/usr.sbin/sendmail/cf/cf/ucbarpa.cf b/usr.sbin/sendmail/cf/cf/ucbarpa.cf deleted file mode 100644 index d5a41fc39bc9..000000000000 --- a/usr.sbin/sendmail/cf/cf/ucbarpa.cf +++ /dev/null @@ -1,607 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)ucbarpa.mc 1.3 (Berkeley) 1/3/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by phil on Wed Jan 25 11:47:11 PST 1989 -# in /usr/src/local/nettables/sendmail.cf/cf on monet.Berkeley.EDU -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/usr/lib/sendmail.cw - -# uucp hostnames -DUucbarpa -CUucbarpa - -# local UUCP connections -CV endotsew -CV fateman -CV franz -CV interlan -CV metron - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDBerkeley.EDU - -# Internet relay host -- machines in our domain that are not -# registered with the NIC will be "hidden" behind this relay machine -# with the % kludge, although SMTP delivery will still be performed -# by the sending machine. Someday this will go away. -DAucbvax.Berkeley.EDU - -# UUCP relay host -DRucbvax.Berkeley.EDU - -# csnet relay host -DCrelay.cs.net - -# bitnet relay host -DBjade.Berkeley.EDU - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - -############################################################ -############################################################ -##### -##### BERKELEY HOSTS REGISTERED WITH THE NIC -##### -############################################################ -############################################################ - - -CNbach ucbbach -CNbizet ucbbizet -CNcad ucbcad -CNdegas ucbdegas -CNeast ucbeast -CNernie ucbernie -CNesvax ucbesvax -CNjade ucbjade -CNji ucbji -CNmike ucbmike -CNmonet ucbmonet -CNpostgres -CNrenoir ucbrenoir -CNucbarpa -CNucbvax -CNviolet ucbviolet - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/usr/lib/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/usr/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/usr/lib/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.bitnet -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### UUCP Mailer specification -##### -############################################################ -############################################################ - - -Muucp, P=/usr/bin/uux, F=DFMhuU, S=13, R=23, M=100000, - A=uux - -r -z -a$f -gC $h!rmail ($u) - -S13 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$w!$+ $1 strip local name -R$+ $:$U!$1 stick on our host name -R$=U!$-%$- $:$1!$2@$3.$D ucbvax!user@host.domain - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $U!$1 a!b@here -> here!a!b -R$=U!$+ $2 here!a!b -> a!b -# sanity ... should not happen. -R$=U.$D!$+ $2 strip local name.domain - - -############################################################ -############################################################ -##### -##### Provide Backward Compatibility -##### -############################################################ -############################################################ - -##################################################### -# General code to convert back to old style names # -##################################################### -S5 - -R$+<@$w> $1 strip host -R$+<@$-.UUCP> $2!$1 u@host.UUCP => host!u - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - -# resolve local UUCP connections -R<@$=V.UUCP>:$+ $#uucp$@$1$:$2 @host.UUCP:... -R$+<@$=V.UUCP> $#uucp$@$2$:$1 user@host.UUCP - - -# resolve fake top level domains by forwarding to other hosts -R$*<@$+.BITNET>$* $#tcp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET -R$*<@$+.CSNET>$* $#tcp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET - - -# forward non-local UUCP traffic to our UUCP relay -R$*<@$*.UUCP>$* $#tcpld$@$R$:$1<@$2.UUCP> uucp mail - -# hide behind our internet relay when talking to people in the arpa domain -R$*<@$*.arpa>$* $#tcp$@$2.arpa$:$1<@$2.arpa>$3 user@host.arpa - -# but speak domains to them if they speak domains too -R$*<@$*>$* $#tcpld$@$2$:$1<@$2>$3 user@host.domain - -# remaining names must be local -R$+ $#local$:$1 everything else diff --git a/usr.sbin/sendmail/cf/cf/ucbtcp.cf b/usr.sbin/sendmail/cf/cf/ucbtcp.cf deleted file mode 100644 index a6d6cb097ce9..000000000000 --- a/usr.sbin/sendmail/cf/cf/ucbtcp.cf +++ /dev/null @@ -1,547 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)ucbtcp.mc 1.3 (Berkeley) 1/3/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by phil on Wed Jan 25 11:47:55 PST 1989 -# in /usr/src/local/nettables/sendmail.cf/cf on monet.Berkeley.EDU -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/usr/lib/sendmail.cw - - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDBerkeley.EDU - -# Internet relay host -- machines in our domain that are not -# registered with the NIC will be "hidden" behind this relay machine -# with the % kludge, although SMTP delivery will still be performed -# by the sending machine. Someday this will go away. -DAucbvax.Berkeley.EDU - -# UUCP relay host -DRucbvax.Berkeley.EDU - -# csnet relay host -DCrelay.cs.net - -# bitnet relay host -DBjade.Berkeley.EDU - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - -############################################################ -############################################################ -##### -##### BERKELEY HOSTS REGISTERED WITH THE NIC -##### -############################################################ -############################################################ - - -CNbach ucbbach -CNbizet ucbbizet -CNcad ucbcad -CNdegas ucbdegas -CNeast ucbeast -CNernie ucbernie -CNesvax ucbesvax -CNjade ucbjade -CNji ucbji -CNmike ucbmike -CNmonet ucbmonet -CNpostgres -CNrenoir ucbrenoir -CNucbarpa -CNucbvax -CNviolet ucbviolet - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/usr/lib/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/usr/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/usr/lib/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.bitnet -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - - - -# resolve fake top level domains by forwarding to other hosts -R$*<@$+.BITNET>$* $#tcp$@$B$:$1<@$2.BITNET>$3 user@host.BITNET -R$*<@$+.CSNET>$* $#tcp$@$C$:$1<@$2.CSNET>$3 user@host.CSNET - - -# forward non-local UUCP traffic to our UUCP relay -R$*<@$*.UUCP>$* $#tcpld$@$R$:$1<@$2.UUCP> uucp mail - -# hide behind our internet relay when talking to people in the arpa domain -R$*<@$*.arpa>$* $#tcp$@$2.arpa$:$1<@$2.arpa>$3 user@host.arpa - -# but speak domains to them if they speak domains too -R$*<@$*>$* $#tcpld$@$2$:$1<@$2>$3 user@host.domain - -# remaining names must be local -R$+ $#local$:$1 everything else diff --git a/usr.sbin/sendmail/cf/cf/ucbtcp.mc b/usr.sbin/sendmail/cf/cf/ucbtcp.mc deleted file mode 100644 index c36aed86ca57..000000000000 --- a/usr.sbin/sendmail/cf/cf/ucbtcp.mc +++ /dev/null @@ -1,15 +0,0 @@ -divert(10)dnl -# -# Generic configuration file for Berkeley machines. -# -# @(#)ucbtcp.mc 1.3 (Berkeley) 1/3/89 -# -define(DOMAIN, `DDBerkeley.EDU') -define(INTERNET_RELAY, `DAucbvax.Berkeley.EDU') -define(UUCP_RELAY, DRucbvax.Berkeley.EDU) -define(BITNET_RELAY, `DBjade.Berkeley.EDU') -define(CSNET_RELAY, `DCrelay.cs.net') -define(ARPAKLUDGE, `1') -define(EXTERNAL_VERSION, ``#' `@(#)ucbtcp.mc 1.3' (Berkeley) `1/3/89'') -divert(0)dnl -include(proto.mc)dnl diff --git a/usr.sbin/sendmail/cf/cf/ucbvax.cf b/usr.sbin/sendmail/cf/cf/ucbvax.cf deleted file mode 100644 index a1cbfb9a479d..000000000000 --- a/usr.sbin/sendmail/cf/cf/ucbvax.cf +++ /dev/null @@ -1,837 +0,0 @@ -############################################################ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)ucbvax.mc 1.39 (Berkeley) 1/3/89 -# -# built by phil on Wed Jan 25 11:47:20 PST 1989 -# in /usr/src/local/nettables/sendmail.cf/cf on monet.Berkeley.EDU -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -##### This one is the big daddy. There is no "upstairs" -##### to bounce a message to -- except perhaps the arpanet. -##### -##### -############################################################ -############################################################ - - - -###################### -### local info ### -###################### - -# internet hostnames -Cwucbvax vax k UCB-VAX Berkeley UCB-C70 UCB - -# UUCP hostnames -DUucbvax -CUucbvax - -# local UUCP connections -CV Padova -CV Shasta -CV alice -CV allegra -CV amdcad -CV anlams -CV att -CV attunix -CV avsd -CV bellcore bellcor -CV calma -CV cithep -CV craylab -CV decusj -CV decvax -CV decwrl -CV dssovax -CV eagle -CV ecovax -CV floyd -CV geoff -CV harpo -CV ho3e2 -CV hpda -CV hplabs -CV ibmsupt ibmuupa ibmpa -CV iiasa70 -CV imagen -CV isunix menlo70 -CV kentmth -CV kentvax -CV lbl-csam lbl-csa -CV lime -CV mebazf -CV molbio -CV mothra -CV mseonyx -CV mtxinu -CV nbires -CV pixar -CV pur-ee -CV purdue -CV pwbd -CV research researc -CV sdcarl -CV sdcsvax -CV sftig -CV sgi olympus -CV sii -CV srivisi -CV ssyx -CV sun -CV tektronix tektron -CV tolerant toleran -CV trwrb -CV twg -CV ucbcad -CV ucdavis -CV ucivax -CV ucla-se ucla-cs -CV ucsbcsl ucsbhub -CV ucscc -CV ucsd -CV ucsfcgl -CV ucsfmis -CV ulysses -CV unisoft -CV unmvax -CV usenix -CV uw -CV uwvax -CV vax135 -CV voder -CV wheps -CV whuxle -CV whuxlj -CV xprin -CV zehntel -CV zilog - -# UUCP connections on ucbarpa -DWucbarpa.Berkeley.EDU -CW endotsew -CW fateman -CW franz -CW interlan -CW metron - -# UUCP connections on ucbcad -DXcad.Berkeley.EDU -CX a -CX ames -CX analog -CX ardent dana -CX arthur -CX biosys -CX black -CX boulder -CX evans -CX harpo -CX harris -CX hpda -CX hpsrla -CX island -CX jupiter -CX masscomp masscom -CX nsc -CX oakhill -CX octal -CX sda -CX stellar -CX teklds -CX tektronix tektron -CX binky tonto -CX toshiba tsb0 -CX ucbcad -CX ucbvax -CX voder -CX vogon - -# UUCP connections on cogsci -DYcogsci.Berkeley.EDU -CY capmkt -CY contessa -CY emind -CY hoptoad -CY nkainc -CY well -CY ferdy - -# known uucp connections with a smart uucp -CMdecvax - -# we have full sendmail support here -Oa - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -# YOUR DOMAIN NAME GOES HERE! -DDYOUR_DOMAIN_NAME - - - - - - - - - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - -############################################################ -############################################################ -##### -##### BERKELEY HOSTS REGISTERED WITH THE NIC -##### -############################################################ -############################################################ - - -CNbach ucbbach -CNbizet ucbbizet -CNcad ucbcad -CNdegas ucbdegas -CNeast ucbeast -CNernie ucbernie -CNesvax ucbesvax -CNjade ucbjade -CNji ucbji -CNmike ucbmike -CNmonet ucbmonet -CNpostgres -CNrenoir ucbrenoir -CNucbarpa -CNucbvax -CNviolet ucbviolet - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/usr/lib/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/usr/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/usr/lib/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -# addition to Post-rewrite Rule -R$+%$=w@$=w.EDU $1@$w u%UCB@UCB.edu => u@UCB.berk.edu -R$+%$=w@$=w.$=w.EDU $1@$w u%UCB@UCB.berk.edu => u@UCB - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -############################################################ -############################################################ -##### -##### Provide Backward Compatibility -##### -############################################################ -############################################################ - -##################################################### -# General code to convert back to old style names # -##################################################### -S5 - -R$+<@$w> $1 strip host -R$+<@$-.UUCP> $2!$1 u@host.UUCP => host!u - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - - -############################################################ -############################################################ -##### -##### UUCP Smart Mailer specification -##### (handles multiple recipients) -##### -############################################################ -############################################################ - - - -Msuucp, P=/usr/bin/uux, F=mDFMhuU, S=13, R=23, M=100000, - A=uux - -r $h!rmail ($u) - - - - -############################################################ -############################################################ -##### -##### UUCP Mailer specification -##### -############################################################ -############################################################ - - -Muucp, P=/usr/bin/uux, F=DFMhuU, S=13, R=23, M=100000, - A=uux - -r -z -a$f -gC $h!rmail ($u) - -S13 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$w!$+ $1 strip local name -R$+ $:$U!$1 stick on our host name -R$=U!$-%$- $:$1!$2@$3.$D ucbvax!user@host.domain - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $U!$1 a!b@here -> here!a!b -R$=U!$+ $2 here!a!b -> a!b -# sanity ... should not happen. -R$=U.$D!$+ $2 strip local name.domain - - -############################################################ -############################################################ -##### -##### SMTP UUCP Mailer specification -##### -##### This mailer sends UUCP traffic over an SMTP connection. -##### Obviously, we only want to do this with UUCP hosts with -##### whom we have SMTP connectivity. The idea here is to -##### avoid having to double queue (once for sendmail, once -##### for UUCP) when there's no need. Since we need to -##### preserve uucp-ness (e.g., bangs), we use the UUCP mailer -##### rewriting rulesets. -##### -############################################################ -############################################################ - -Msmtpuucp, P=[IPC], F=mDFMueXLC, S=13, R=23, A=IPC $h, E=\r\n - - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - - - -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - - - -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - - - -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - - - -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -################################################ -### Machine dependent part of ruleset zero ### -################################################ - -# resolve SMTP UUCP connections - -R<@bellcore.uucp>:$+ $#smtpuucp$@bellcore.com$:$2 -R$*<@bellcore.uucp> $#smtpuucp$@bellcore.com$:$1 -R<@decvax.uucp>:$+ $#smtpuucp$@decvax.dec.com$:$2 -R$*<@decvax.uucp> $#smtpuucp$@decvax.dec.com$:$1 -R<@decwrl.uucp>:$+ $#smtpuucp$@decwrl.dec.com$:$2 -R$*<@decwrl.uucp> $#smtpuucp$@decwrl.dec.com$:$1 -R<@hplabs.uucp>:$+ $#smtpuucp$@hplabs.hp.com$:$2 -R$*<@hplabs.uucp> $#smtpuucp$@hplabs.hp.com$:$1 -R<@lbl-csam.uucp>:$+ $#smtpuucp$@lbl-csam.arpa$:$2 -R$*<@lbl-csam.uucp> $#smtpuucp$@lbl-csam.arpa$:$1 -R<@pur-ee.uucp>:$+ $#smtpuucp$@ecn.purdue.edu$:$2 -R$*<@pur-ee.uucp> $#smtpuucp$@ecn.purdue.edu$:$1 -R<@purdue.uucp>:$+ $#smtpuucp$@purdue.edu$:$2 -R$*<@purdue.uucp> $#smtpuucp$@purdue.edu$:$1 -R<@sdcarl.uucp>:$+ $#smtpuucp$@sdcarl.ucsd.edu$:$2 -R$*<@sdcarl.uucp> $#smtpuucp$@sdcarl.ucsd.edu$:$1 -R<@sun.uucp>:$+ $#smtpuucp$@sun.com$:$2 -R$*<@sun.uucp> $#smtpuucp$@sun.com$:$1 -R<@ucbcad.uucp>:$+ $#smtpuucp$@cad.berkeley.edu$:$2 -R$*<@ucbcad.uucp> $#smtpuucp$@cad.berkeley.edu$:$1 -R<@ucdavis.uucp>:$+ $#smtpuucp$@ucdavis.ucdavis.edu$:$2 -R$*<@ucdavis.uucp> $#smtpuucp$@ucdavis.ucdavis.edu$:$1 -R<@ucla-se.uucp>:$+ $#smtpuucp$@seas.ucla.edu$:$2 -R$*<@ucla-se.uucp> $#smtpuucp$@seas.ucla.edu$:$1 -R<@ucscc.uucp>:$+ $#smtpuucp$@c.ucsc.edu$:$2 -R$*<@ucscc.uucp> $#smtpuucp$@c.ucsc.edu$:$1 -R<@ucsfcgl.uucp>:$+ $#smtpuucp$@cgl.ucsf.edu$:$2 -R$*<@ucsfcgl.uucp> $#smtpuucp$@cgl.ucsf.edu$:$1 -R<@uwvax.uucp>:$+ $#smtpuucp$@spool.cs.wisc.edu$:$2 -R$*<@uwvax.uucp> $#smtpuucp$@spool.cs.wisc.edu$:$1 - - -# resolve local UUCP links -R<@$=V.UUCP>:$+ $#uucp$@$1$:$1:$2 @host.UUCP: ... -R$+<@$=V.UUCP> $#uucp$@$2$:$1 user@host.UUCP - -# resolve explicit arpanet names (to avoid with machine name "arpa" below) -R$*<@$*$-.ARPA>$* $#tcp$@$3.ARPA$:$1<@$2$3.ARPA>$4 user@domain.ARPA - -# resolve fake top level domains by forwarding to other hosts - - - - -# resolve non-local UUCP links -R$*<@$=W.UUCP>$* $#tcpld$@$W$:$1<@$2.UUCP>$3 user@host.UUCP -R$*<@$=X.UUCP>$* $#tcpld$@$X$:$1<@$2.UUCP>$3 user@host.UUCP -R$*<@$=Y.UUCP>$* $#tcpld$@$Y$:$1<@$2.UUCP>$3 user@host.UUCP - -# this uucp stuff is wrong for domain uucp addresses -# - we should pass the whole "host.domain" to uucp so it can -# find the best route. But that depends on a uucp router -# which doesn't exist here yet, so for now, we'll settle for -# trying to route to the domain (pretending its a host). -# Suitable L.sys entries can make this work. If it doesn't -# then returned mail will just say "dom unknown", which is true .. - -# resolve smart UUCP links -R<@$=M.$-.UUCP>:$+ $#suucp$@$2$:@$1.$2.UUCP:$3 @host.domain.UUCP: ... -R<@$=M.UUCP>:$+ $#suucp$@$1$:$2 @host.UUCP: ... -R$+<@$=M.$-.UUCP> $#suucp$@$3$:$1@$2.$3.UUCP user@host.domain.UUCP -R$+<@$=M.UUCP> $#suucp$@$2$:$1 user@host.UUCP - -# local domain sites -R$*<@$*.$D>$* $#tcpld$@$2.$D$:$1<@$2.$D>$3 user@host.our.domain -R$*<@$->$* $#tcpld$@$2.$D$:$1<@$2.$D>$3 user@host -R$*<@$-.UUCP>$* $#tcpld$@$2.$D$:$1<@$2.$D>$3 user@host.UUCP - -# other non-local names will be kicked upstairs -R$*<@$+>$* $#tcp$@$2$:$1<@$2>$3 user@some.where - -# remaining names must be local -R$+ $#local$:$1 everything else - -######################################## -### Host dependent address cleanup ### -######################################## - -S8 -R$*$=U!$+@$+ $3@$4 drop uucp forward diff --git a/usr.sbin/sendmail/cf/cf/udb.mc b/usr.sbin/sendmail/cf/cf/udb.mc deleted file mode 100644 index 624d2d407105..000000000000 --- a/usr.sbin/sendmail/cf/cf/udb.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)udb.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(sunos4.1)dnl -DOMAIN(cs.hidden)dnl -MAILER(smtp)dnl -define(`USERDB_FILE', `/home/auspex/a/staff/gnn/UDB/UI')dnl diff --git a/usr.sbin/sendmail/cf/cf/uid.cf b/usr.sbin/sendmail/cf/cf/uid.cf deleted file mode 100644 index 1c357d03e6f0..000000000000 --- a/usr.sbin/sendmail/cf/cf/uid.cf +++ /dev/null @@ -1,480 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)uucpproto.mc 1.2 (Berkeley) 1/24/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by rich on Mon May 11 20:00:12 CDT 1992 -# in /home/rich/sendmail/idcf/cf on id -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/etc/sendmail.cw - -# uucp hostnames -DUid -CUid uid - -# local UUCP connections -CVjpunix - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDUUCP - - - - - - - - - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/etc/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/share/misc/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/var/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/var/log/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/usr/libexec/mail.local, F=lsDFMmn, S=10, R=20, A=mail -r $g -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - - - -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - - - -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - - -############################################################ -############################################################ -##### -##### Provide Backward Compatibility -##### -############################################################ -############################################################ - -##################################################### -# General code to convert back to old style names # -##################################################### -S5 - -R$+<@$w> $1 strip host -R$+<@$-.UUCP> $2!$1 u@host.UUCP => host!u - -############################################################ -############################################################ -##### -##### UUCP Mailer specification -##### -############################################################ -############################################################ - - -Muucp, P=/usr/local/bin/uux, F=DFMhuU, S=13, R=23, M=100000, - A=uux - -r -z -a$f -gC $h!rmail ($u) - -S13 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$w!$+ $1 strip local name -R$+ $:$U!$1 stick on our host name -R$=U!$-%$- $:$1!$2@$3.$D ucbvax!user@host.domain - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $U!$1 a!b@here -> here!a!b -R$=U!$+ $2 here!a!b -> a!b -# sanity ... should not happen. -R$=U.$D!$+ $2 strip local name.domain - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - -# resolve local UUCP connections -R<@$=V.UUCP>:$+ $#uucp$@$1$:$2 @host.UUCP:... -R$+<@$=V.UUCP> $#uucp$@$2$:$1 user@host.UUCP - - - - -# remaining names must be local -R$+ $#local$:$1 everything else diff --git a/usr.sbin/sendmail/cf/cf/uid.mc b/usr.sbin/sendmail/cf/cf/uid.mc deleted file mode 100644 index 219e798ec95d..000000000000 --- a/usr.sbin/sendmail/cf/cf/uid.mc +++ /dev/null @@ -1,14 +0,0 @@ -divert(10)dnl -# -# Prototype configuration file for systems only on UUCP networks -# -# @(#)uucpproto.mc 1.2 (Berkeley) 1/24/89 -# -define(DOMAIN, `DDUUCP') -define(UUCP_NAME, DUid) -define(UUCP_ALIASES, CUid uid) -define(UUCP_HOSTS_FILE, ../sitedep/uucp.proto.m4) -define(UUCP_ONLY, 1) -define(EXTERNAL_VERSION, ``#' `@(#)uucpproto.mc 1.2' (Berkeley) `1/24/89'') -divert(0)dnl -include(proto.mc)dnl diff --git a/usr.sbin/sendmail/cf/cf/ultrix4.1-cs-exposed.mc b/usr.sbin/sendmail/cf/cf/ultrix4.1-cs-exposed.mc deleted file mode 100644 index 093590fff190..000000000000 --- a/usr.sbin/sendmail/cf/cf/ultrix4.1-cs-exposed.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)ultrix4.1-cs-exposed.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(ultrix4.1)dnl -DOMAIN(cs.exposed)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/ultrix4.1-cs-hidden.mc b/usr.sbin/sendmail/cf/cf/ultrix4.1-cs-hidden.mc deleted file mode 100644 index ea25375924cf..000000000000 --- a/usr.sbin/sendmail/cf/cf/ultrix4.1-cs-hidden.mc +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -include(`../m4/cf.m4') -VERSIONID(`@(#)ultrix4.1-cs-hidden.mc 8.1 (Berkeley) 6/7/93') -OSTYPE(ultrix4.1)dnl -DOMAIN(cs.hidden)dnl -MAILER(local)dnl -MAILER(smtp)dnl diff --git a/usr.sbin/sendmail/cf/cf/uucpproto.cf b/usr.sbin/sendmail/cf/cf/uucpproto.cf deleted file mode 100644 index 3f90153846f1..000000000000 --- a/usr.sbin/sendmail/cf/cf/uucpproto.cf +++ /dev/null @@ -1,484 +0,0 @@ -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)uucpproto.mc 1.2 (Berkeley) 1/24/89 -# @(#)proto.mc 1.20 (Berkeley) 1/25/89 -# -# built by phil on Wed Jan 25 11:48:03 PST 1989 -# in /usr/src/local/nettables/sendmail.cf/cf on monet.Berkeley.EDU -# -############################################################ -############################################################ -##### -##### SENDMAIL CONFIGURATION FILE -##### -############################################################ -############################################################ - - -################## -# local info # -################## - -# file containing our internet aliases -Fw/usr/lib/sendmail.cw - -# uucp hostnames -DUYOUR_UUCP_HOSTNAME_HERE -CUYOUR_UUCP_ALIASES_HERE - -# local UUCP connections -CV YOUR -CV UUCP -CV NEIGHBORS -CV GO -CV HERE - - -############################# -### Setup Information ### -############################# - - -###################### -# General Macros # -###################### - -# local domain name -DDUUCP - - - - - - - - - -# my official hostname -Dj$w - - - -############### -# Classes # -############### - -# Internal ("fake") domains that we use in rewriting -CIUUCP BITNET CSNET - - - - -###################### -# Version Number # -###################### - -DZ1.34 - - -###################### -# Special macros # -###################### - -# my name -DnMAILER-DAEMON -# UNIX header format -DlFrom $g $d -# delimiter (operator) characters -Do.:%@!^=/[] -# format of a total name -Dq$g$?x ($x)$. -# SMTP login message -De$j Sendmail $v/$Z ready at $b - -############### -# Options # -############### - -# location of alias file -OA/usr/lib/aliases -# wait up to ten minutes for alias file rebuild -Oa10 -# substitution for space (blank) characters -OB. -# (don't) connect to "expensive" mailers -#Oc -# default delivery mode (deliver in background) -Odbackground -# temporary file mode -OF0600 -# default GID -Og1 -# location of help file -OH/usr/lib/sendmail.hf -# log level -OL9 -# default network name -ONARPA -# default messages to old style -Oo -# queue directory -OQ/usr/spool/mqueue -# read timeout -- violates protocols -Or2h -# status file -OS/usr/lib/sendmail.st -# queue up everything before starting transmission -Os -# default timeout interval -OT3d -# time zone names (V6 only) -OtPST,PDT -# default UID -Ou1 -# wizard's password -OW* -# load average at which we just queue messages -Ox8 -# load average at which we refuse connections -OX12 - -########################### -# Message precedences # -########################### - -Pfirst-class=0 -Pspecial-delivery=100 -Pbulk=-60 -Pjunk=-100 - -##################### -# Trusted users # -##################### - -Troot -Tdaemon -Tuucp - -######################### -# Format of headers # -######################### - -H?P?Return-Path: <$g> -HReceived: $?sfrom $s $.by $j ($v/$Z) - id $i; $b -H?D?Resent-Date: $a -H?D?Date: $a -H?F?Resent-From: $q -H?F?From: $q -H?x?Full-Name: $x -HSubject: -# HPosted-Date: $a -# H?l?Received-Date: $b -H?M?Resent-Message-Id: <$t.$i@$j> -H?M?Message-Id: <$t.$i@$j> - - - -########################### -### Rewriting Rules ### -########################### - - -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - - - -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host - - -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - - - -################### -### Mailers ### -################### - - -############################################################ -############################################################ -##### -##### Local and Program Mailer specification -##### -############################################################ -############################################################ - -Mlocal, P=/bin/mail, F=rlsDFMmn, S=10, R=20, A=mail -d $u -Mprog, P=/bin/sh, F=lsDFMe, S=10, R=20, A=sh -c $u - -S10 -R@ $n errors to mailer-daemon - - - -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - - - -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - - - -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - - - -############################################################ -############################################################ -##### -##### UUCP Mailer specification -##### -############################################################ -############################################################ - - -Muucp, P=/usr/bin/uux, F=DFMhuU, S=13, R=23, M=100000, - A=uux - -r -z -a$f -gC $h!rmail ($u) - -S13 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$w!$+ $1 strip local name -R$+ $:$U!$1 stick on our host name -R$=U!$-%$- $:$1!$2@$3.$D ucbvax!user@host.domain - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $U!$1 a!b@here -> here!a!b -R$=U!$+ $2 here!a!b -> a!b -# sanity ... should not happen. -R$=U.$D!$+ $2 strip local name.domain - - -############################################################ -############################################################ -##### -##### Provide Backward Compatibility -##### -############################################################ -############################################################ - -##################################################### -# General code to convert back to old style names # -##################################################### -S5 - -R$+<@$w> $1 strip host -R$+<@$-.UUCP> $2!$1 u@host.UUCP => host!u - - - -##################### -### Rule Zero ### -##################### - - -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## - - -############################################### -### Machine dependent part of Rule Zero ### -############################################### - - - -# resolve local UUCP connections -R<@$=V.UUCP>:$+ $#uucp$@$1$:$2 @host.UUCP:... -R$+<@$=V.UUCP> $#uucp$@$2$:$1 user@host.UUCP - - - - -# remaining names must be local -R$+ $#local$:$1 everything else diff --git a/usr.sbin/sendmail/cf/m4/nsmacros.m4 b/usr.sbin/sendmail/cf/m4/nsmacros.m4 deleted file mode 100644 index b0a5292c7a33..000000000000 --- a/usr.sbin/sendmail/cf/m4/nsmacros.m4 +++ /dev/null @@ -1,45 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)nsmacros.m4 1.9 (Berkeley) 1/3/89 -# -divert(0) -###################### -# General Macros # -###################### - -# local domain name -ifdef(`DOMAIN', -DOMAIN, -`#' YOUR DOMAIN NAME GOES HERE! -DDYOUR_DOMAIN_NAME) - -ifdef(`INTERNET_RELAY', -`#' Internet relay host -- machines in our domain that are not -`#' registered with the NIC will be "hidden" behind this relay machine -`#' with the % kludge`,' although SMTP delivery will still be performed -`#' by the sending machine. Someday this will go away. -INTERNET_RELAY) - -ifdef(`UUCP_RELAY', -`#' UUCP relay host -UUCP_RELAY) - -ifdef(`CSNET_RELAY', -`#' csnet relay host -CSNET_RELAY) - -ifdef(`BITNET_RELAY', -`#' bitnet relay host -BITNET_RELAY) - -# my official hostname -Dj$w - diff --git a/usr.sbin/sendmail/cf/m4/nstcpldm.m4 b/usr.sbin/sendmail/cf/m4/nstcpldm.m4 deleted file mode 100644 index 5381729369f4..000000000000 --- a/usr.sbin/sendmail/cf/m4/nstcpldm.m4 +++ /dev/null @@ -1,94 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)nstcpldm.m4 1.9 (Berkeley) 1/24/89 -# -divert(0) -############################################################ -############################################################ -##### -##### Local Domain SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to remain -##### the local domain. Hence, they can refer to hosts that are -##### not registered in the NIC host table. -##### -############################################################ -############################################################ - -Mtcpld, P=[IPC], F=mDFMueXLC, S=17, R=27, A=IPC $h, E=\r\n - -S17 - -# cleanup forwarding a bit -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 canonicalize -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -ifdef(`BITNET_RELAY', -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.bitnet) -ifdef(`CSNET_RELAY', -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET) -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S27 - -# cleanup -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form -R$*%$*<@$w> $:$>9$1%$2 user%localhost@localdomain - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host as user@host.domain -R$- $@$1<@$w> user w/o host -R$+<@$w> $@$1<@$w> this host -R$+<@$=w> $@$1<@$w> or an alias -R$+<@$-> $:$1<@$[$2$]> ask nameserver -R$+<@$w> $@$1<@$w> this host -R$+<@$-> $@$1<@$2.$D> if nameserver fails - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output fake domains as user%fake@relay - -ifdef(`BITNET_RELAY', -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET) -ifdef(`CSNET_RELAY', -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET) -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - diff --git a/usr.sbin/sendmail/cf/m4/nstcpm.m4 b/usr.sbin/sendmail/cf/m4/nstcpm.m4 deleted file mode 100644 index 8ade7721ab3b..000000000000 --- a/usr.sbin/sendmail/cf/m4/nstcpm.m4 +++ /dev/null @@ -1,89 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)nstcpm.m4 1.21 (Berkeley) 1/3/89 -# -divert(0) -############################################################ -############################################################ -##### -##### Internet SMTP Mailer specification -##### -##### Messages processed by this specification are assumed to leave -##### the local domain -- hence, they must be canonical according to -##### RFC822 etc. This means that machines not registered with -##### the NIC must be hidden behind our Internet relay. -##### -############################################################ -############################################################ - -Mtcp, P=[IPC], F=mDFMueXLC, S=14, R=24, A=IPC $h, E=\r\n - -S14 - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# output internal ("fake") domains as "user%host@relay" - -ifdef(`BITNET_RELAY', -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET) -ifdef(`CSNET_RELAY', -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET) -R$+<@$+.UUCP> $@$2!$1<@$w> user@host.UUCP - - -S24 - -# put in <> kludge -R$*<$*>$* $1$2$3 defocus -R$* $:$>3$1 now canonical form - -# pass <route-addr>'s through -R<@$+>$* $@<@$[$1$]>$2 resolve <route-addr> - -# map colons to dots everywhere..... -R$*:$* $1.$2 map colons to dots - -# output local host in user@host.domain syntax -R$- $1<@$w> user w/o host -R$+<@$=w> $:$1<@$w> this host -R$+<@$-> $:$1<@$[$2$]> canonicalize into dom -R$+<@$-> $:$1<@$2.$D> if nameserver fails -R$+<@$=N.$D> $@$1<@$2.$D> nic-reg hosts are ok -R$+<@$*.$D> $@$1%$2.$D<@$A> else -> u%h@gateway - -# if not local, and not a "fake" domain, ask the nameserver -R$+<@$+.$~I> $@$1<@$[$2.$3$]> user@host.domain -R$+<@[$+]> $@$1<@[$2]> already ok - -# Hide fake domains behind relays - -ifdef(`BITNET_RELAY', -R$+<@$+.BITNET> $@$1%$2.BITNET<@$B> user@host.BITNET) -ifdef(`CSNET_RELAY', -R$+<@$+.CSNET> $@$1%$2.CSNET<@$C> user@host.CSNET) -R$+<@$+.UUCP> $@$2!$1 user@host.UUCP - diff --git a/usr.sbin/sendmail/cf/m4/postwriterule.m4 b/usr.sbin/sendmail/cf/m4/postwriterule.m4 deleted file mode 100644 index 185a1b9daef3..000000000000 --- a/usr.sbin/sendmail/cf/m4/postwriterule.m4 +++ /dev/null @@ -1,33 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)postwriterule.m4 1.8 (Berkeley) 1/3/89 -# -divert(0) -################################# -# Final Output Post-rewriting # -################################# -S4 - -R@ $@ handle <> error addr - -# resolve numeric addresses to name if possible -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 lookup numeric internet addr - -# externalize local domain info -R$*<$+>$* $1$2$3 defocus -R@$+:@$+:$+ @$1,@$2:$3 <route-addr> canonical - -# UUCP must always be presented in old form -R$+@$-.UUCP $2!$1 u@h.UUCP => h!u - -# delete duplicate local names -R$+%$=w@$=w $1@$w u%host@host => u@host -R$+%$=w@$=w.$D $1@$w u%host@host => u@host diff --git a/usr.sbin/sendmail/cf/m4/prewriterule.m4 b/usr.sbin/sendmail/cf/m4/prewriterule.m4 deleted file mode 100644 index 907c4972a06c..000000000000 --- a/usr.sbin/sendmail/cf/m4/prewriterule.m4 +++ /dev/null @@ -1,25 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)prewriterule.m4 1.1 (Berkeley) 8/8/85 -# -divert(0) -################################ -# Sender Field Pre-rewriting # -################################ -S1 -#R$*<$*>$* $1$2$3 defocus - -################################### -# Recipient Field Pre-rewriting # -################################### -S2 -#R$*<$*>$* $1$2$3 defocus - diff --git a/usr.sbin/sendmail/cf/m4/rule0.m4 b/usr.sbin/sendmail/cf/m4/rule0.m4 deleted file mode 100644 index d456ebda9968..000000000000 --- a/usr.sbin/sendmail/cf/m4/rule0.m4 +++ /dev/null @@ -1,49 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)rule0.m4 1.10 (Berkeley) 1/3/89 -# -divert(0) -############################################################ -############################################################ -##### -##### RULESET ZERO PREAMBLE -##### -##### The beginning of ruleset zero is constant through all -##### configurations. -##### -############################################################ -############################################################ - -S0 - -# first make canonical -R$*<$*>$* $1$2$3 defocus -R$+ $:$>3$1 make canonical - -# handle special cases -R$*<@[$+]>$* $:$1<@$[[$2]$]>$3 numeric internet addr -R$*<@[$+]>$* $#tcp$@[$2]$:$1@[$2]$3 numeric internet spec -R$+ $:$>6$1 -R$-<@$w> $#local$:$1 -R@ $#error$:Invalid address handle <> form - -# canonicalize using the nameserver if not internal domain -R$*<@$*.$~I>$* $:$1<@$[$2.$3$]>$4 -R$*<@$->$* $:$1<@$[$2$]>$3 -R$*<@$->$* $:$1<@$2.$D>$3 if nameserver fails - -# now delete the local info -R<@$w>:$* $@$>0$1 @here:... -> ... -R$*<@$w> $@$>0$1 ...@here -> ... - -################################## -# End of ruleset zero preamble # -################################## diff --git a/usr.sbin/sendmail/cf/m4/rule3.m4 b/usr.sbin/sendmail/cf/m4/rule3.m4 deleted file mode 100644 index 392c0fe5c647..000000000000 --- a/usr.sbin/sendmail/cf/m4/rule3.m4 +++ /dev/null @@ -1,68 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)rule3.m4 1.17 (Berkeley) 1/3/89 -# -divert(0) -########################### -# Name Canonicalization # -########################### -S3 - -# handle "from:<>" special case -R$*<>$* $@@ turn into magic token - -# basic textual canonicalization -- note RFC733 heuristic here -R$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting -R$*<$*<$+>$*>$* $3 2-level <> nesting -R$*<$+>$* $2 basic RFC821/822 parsing - -# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later -R@$+,$+ @$1:$2 change all "," to ":" - -# localize and dispose of route-based addresses -R@$+:$+ $@$>6<@$1>:$2 handle <route-addr> - -# more miscellaneous cleanup -R$+ $:$>8$1 host dependent cleanup -R$+:$*;@$+ $@$1:$2;@$3 list syntax -R$+:$*; $@$1:$2; list syntax -R$+@$+ $:$1<@$2> focus on domain -R$+<$+@$+> $1$2<@$3> move gaze right -R$+<@$+> $@$>6$1<@$2> already canonical - -# convert old-style addresses to a domain-based address -R$+^$+ $1!$2 convert ^ to ! -R$-!$+ $@$>6$2<@$1.UUCP> resolve uucp names -R$+.$-!$+ $@$>6$3<@$1.$2> domain uucps -R$+!$+ $@$>6$2<@$1.UUCP> uucp subdomains -R$+%$+ $:$>9$1%$2 user%host -R$+<@$+> $@$>6$1<@$2> already canonical -R$-.$+ $@$>6$2<@$1> host.user - - -################################# -# special local conversions # -################################# - -S6 -R$*<@$=w>$* $:$1<@$w>$3 get into u@$w form -R$*<@$=w.$D>$* $:$1<@$w>$3 -R$*<@$=U.UUCP>$* $:$1<@$w>$3 - -################################ -# Change rightmost % to @. # -################################ - -S9 -R$*%$* $1@$2 First make them all @'s. -R$*@$*@$* $1%$2@$3 Undo all but the last. -R$*@$* $@$1<@$2> Put back the brackets. - diff --git a/usr.sbin/sendmail/cf/m4/rule5.m4 b/usr.sbin/sendmail/cf/m4/rule5.m4 deleted file mode 100644 index a6a1bbbc8935..000000000000 --- a/usr.sbin/sendmail/cf/m4/rule5.m4 +++ /dev/null @@ -1,28 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)rule5.m4 1.4 (Berkeley) 11/4/87 -# -divert(0) -############################################################ -############################################################ -##### -##### Provide Backward Compatibility -##### -############################################################ -############################################################ - -##################################################### -# General code to convert back to old style names # -##################################################### -S5 - -R$+<@$w> $1 strip host -R$+<@$-.UUCP> $2!$1 u@host.UUCP => host!u diff --git a/usr.sbin/sendmail/cf/m4/smtpuucpm.m4 b/usr.sbin/sendmail/cf/m4/smtpuucpm.m4 deleted file mode 100644 index 4dcfcc553ff8..000000000000 --- a/usr.sbin/sendmail/cf/m4/smtpuucpm.m4 +++ /dev/null @@ -1,34 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)smtpuucpm.m4 1.1 (Berkeley) 1/3/89 -# -divert(0) -############################################################ -############################################################ -##### -##### SMTP UUCP Mailer specification -##### -##### This mailer sends UUCP traffic over an SMTP connection. -##### Obviously, we only want to do this with UUCP hosts with -##### whom we have SMTP connectivity. The idea here is to -##### avoid having to double queue (once for sendmail, once -##### for UUCP) when there's no need. Since we need to -##### preserve uucp-ness (e.g., bangs), we use the UUCP mailer -##### rewriting rulesets. -##### -############################################################ -############################################################ - -Msmtpuucp, P=[IPC], F=mDFMueXLC, S=13, R=23, A=IPC $h, E=\r\n - -define(SMTPUUCPPAIR, -`R<@$1.uucp>:$+ $`#'smtpuucp$@$2$:`$'2 -R$*<@$1.uucp> $`#'smtpuucp$@$2$:`$'1') diff --git a/usr.sbin/sendmail/cf/m4/suucpm.m4 b/usr.sbin/sendmail/cf/m4/suucpm.m4 deleted file mode 100644 index 837ec4c4c276..000000000000 --- a/usr.sbin/sendmail/cf/m4/suucpm.m4 +++ /dev/null @@ -1,43 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)suucpm.m4 1.3 (Berkeley) 1/3/89 -# -divert(0) -############################################################ -############################################################ -##### -##### UUCP Smart Mailer specification -##### (handles multiple recipients) -##### -############################################################ -############################################################ - - - -Msuucp, P=/usr/bin/uux, F=mDFMhuU, S=13, R=23, M=100000, - A=uux - -r $h!rmail ($u) - -ifdef(`m4UUCP',`divert(10)',) - -S13 -R$+ $:$>5$1 convert to old style -R$=w!$+ $2 strip local name -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$+ $:$U!$1 stick on our host name - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$2.$D>$3 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $w!$1 uucp!u@local -> local!uucp!u - -ifdef(`m4UUCP',`divert(0)',) diff --git a/usr.sbin/sendmail/cf/m4/uucpm.m4 b/usr.sbin/sendmail/cf/m4/uucpm.m4 deleted file mode 100644 index 0d572c00298b..000000000000 --- a/usr.sbin/sendmail/cf/m4/uucpm.m4 +++ /dev/null @@ -1,42 +0,0 @@ -divert(10) -# -# Sendmail -# Copyright (c) 1983 Eric P. Allman -# Berkeley, California -# -# Copyright (c) 1983 Regents of the University of California. -# All rights reserved. The Berkeley software License Agreement -# specifies the terms and conditions for redistribution. -# -# @(#)uucpm.m4 1.11 (Berkeley) 1/3/89 -# -divert(0) -############################################################ -############################################################ -##### -##### UUCP Mailer specification -##### -############################################################ -############################################################ - - -Muucp, P=/usr/local/bin/uux, F=DFMhuU, S=13, R=23, M=100000, - A=uux - -r -z -a$f -gC $h!rmail ($u) - -S13 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$+> $2!$1 uucpize (no @'s in addr) -R$w!$+ $1 strip local name -R$+ $:$U!$1 stick on our host name -R$=U!$-%$- $:$1!$2@$3.$D ucbvax!user@host.domain - -S23 -R$+ $:$>5$1 convert to old style -R$*<@$=w>$* $1<@$w>$2 resolve abbreviations -R$*<@$->$* $1<@$2.$D>$3 resolve abbreviations -R$+<@$w> $U!$1 a!b@here -> here!a!b -R$=U!$+ $2 here!a!b -> a!b -# sanity ... should not happen. -R$=U.$D!$+ $2 strip local name.domain diff --git a/usr.sbin/sendmail/cf/ostype/hpux.m4 b/usr.sbin/sendmail/cf/ostype/hpux.m4 deleted file mode 100644 index 1be21f36c3c1..000000000000 --- a/usr.sbin/sendmail/cf/ostype/hpux.m4 +++ /dev/null @@ -1,44 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)hpux.m4 8.5 (Berkeley) 1/9/94') - -define(`QUEUE_DIR', /usr/spool/mqueue)dnl -define(`ALIAS_FILE', /usr/lib/aliases)dnl -define(`STATUS_FILE', /usr/lib/sendmail.st)dnl -define(`LOCAL_MAILER_FLAGS', `m')dnl -define(`UUCP_MAILER_ARGS', `uux - -r -a$f -gC $h!rmail ($u)')dnl -define(`confTIME_ZONE', `USE_TZ')dnl diff --git a/usr.sbin/sendmail/cf/ostype/irix.m4 b/usr.sbin/sendmail/cf/ostype/irix.m4 deleted file mode 100644 index 6cd7fc9a9599..000000000000 --- a/usr.sbin/sendmail/cf/ostype/irix.m4 +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)irix.m4 8.4 (Berkeley) 2/1/94') -define(`LOCAL_MAILER_FLAGS', Ehm)dnl -define(`QUEUE_DIR', /usr/spool/mqueue)dnl -define(`ALIAS_FILE', /usr/lib/aliases)dnl -define(`STATUS_FILE', /usr/lib/sendmail.st)dnl diff --git a/usr.sbin/sendmail/cf/ostype/linux.m4 b/usr.sbin/sendmail/cf/ostype/linux.m4 deleted file mode 100644 index 527b6fa3372b..000000000000 --- a/usr.sbin/sendmail/cf/ostype/linux.m4 +++ /dev/null @@ -1,38 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)linux.m4 8.2 (Berkeley) 8/21/93') -define(`LOCAL_MAILER_PATH', /bin/mail.local)dnl diff --git a/usr.sbin/sendmail/cf/ostype/nextstep.m4 b/usr.sbin/sendmail/cf/ostype/nextstep.m4 deleted file mode 100644 index 8144c3e69012..000000000000 --- a/usr.sbin/sendmail/cf/ostype/nextstep.m4 +++ /dev/null @@ -1,44 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)nextstep.m4 8.4 (Berkeley) 11/30/93') -define(`ALIAS_FILE', /etc/sendmail/aliases)dnl -define(`HELP_FILE', /usr/lib/sendmail.hf)dnl -define(`STATUS_FILE', /etc/sendmail/sendmail.st)dnl -define(`UUCP_MAILER_PATH', /usr/bin/uux)dnl -define(`QUEUE_DIR', /usr/spool/mqueue)dnl -define(`LOCAL_MAILER_FLAGS', `rmnP')dnl -define(`LOCAL_SHELL_FLAGS', `euP')dnl diff --git a/usr.sbin/sendmail/cf/ostype/osf1.m4 b/usr.sbin/sendmail/cf/ostype/osf1.m4 deleted file mode 100644 index fbc4832026e8..000000000000 --- a/usr.sbin/sendmail/cf/ostype/osf1.m4 +++ /dev/null @@ -1,41 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)osf1.m4 8.1 (Berkeley) 6/7/93') -ifdef(`_OLD_SENDMAIL_', `define(`NEED_DOMAIN', `')')dnl -define(`ALIAS_FILE', /usr/adm/sendmail/aliases)dnl -define(`STATUS_FILE', /usr/adm/sendmail/sendmail.st)dnl -define(`HELP_FILE', /usr/share/lib/sendmail.hf)dnl diff --git a/usr.sbin/sendmail/cf/ostype/riscos4.5.m4 b/usr.sbin/sendmail/cf/ostype/riscos4.5.m4 deleted file mode 100644 index b45b25263fd3..000000000000 --- a/usr.sbin/sendmail/cf/ostype/riscos4.5.m4 +++ /dev/null @@ -1,42 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)riscos4.5.m4 8.2 (Berkeley) 12/1/93') - -define(`LOCAL_MAILER_ARGS', `rmail -d $u')dnl -define(`ALIAS_FILE', `/usr/lib/aliases')dnl -define(`QUEUE_DIR', `/usr/spool/mqueue')dnl -define(`HELP_FILE', `/usr/lib/sendmail.hf')dnl diff --git a/usr.sbin/sendmail/cf/ostype/solaris2.m4 b/usr.sbin/sendmail/cf/ostype/solaris2.m4 deleted file mode 100644 index 5e87027253d2..000000000000 --- a/usr.sbin/sendmail/cf/ostype/solaris2.m4 +++ /dev/null @@ -1,43 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)solaris2.m4 8.2 (Berkeley) 1/23/94') -divert(-1) - -define(`ALIAS_FILE', /etc/mail/aliases) -define(`HELP_FILE', /etc/mail/sendmail.hf) -define(`STATUS_FILE', /etc/mail/sendmail.st) -define(`LOCAL_MAILER_FLAGS', `fSn') diff --git a/usr.sbin/sendmail/cf/ostype/sunos3.5.m4 b/usr.sbin/sendmail/cf/ostype/sunos3.5.m4 deleted file mode 100644 index fe76931880a2..000000000000 --- a/usr.sbin/sendmail/cf/ostype/sunos3.5.m4 +++ /dev/null @@ -1,37 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)sunos3.5.m4 8.1 (Berkeley) 6/7/93') diff --git a/usr.sbin/sendmail/cf/ostype/sunos4.1.m4 b/usr.sbin/sendmail/cf/ostype/sunos4.1.m4 deleted file mode 100644 index cfa7a9a02ac5..000000000000 --- a/usr.sbin/sendmail/cf/ostype/sunos4.1.m4 +++ /dev/null @@ -1,37 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)sunos4.1.m4 8.1 (Berkeley) 6/7/93') diff --git a/usr.sbin/sendmail/cf/ostype/svr4.m4 b/usr.sbin/sendmail/cf/ostype/svr4.m4 deleted file mode 100644 index dd50127d4e1a..000000000000 --- a/usr.sbin/sendmail/cf/ostype/svr4.m4 +++ /dev/null @@ -1,45 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)svr4.m4 8.1 (Berkeley) 8/24/93') - -ifdef(`ALIAS_FILE',,`define(`ALIAS_FILE', /usr/ucblib/aliases)')dnl -ifdef(`HELP_FILE',,`define(`HELP_FILE', /usr/ucblib/sendmail.hf)')dnl -ifdef(`STATUS_FILE',,`define(`STATUS_FILE', /usr/ucblib/sendmail.st)')dnl -define(`LOCAL_MAILER_PATH', `/usr/ucblib/binmail')dnl -define(`LOCAL_MAILER_FLAGS', `rmn')dnl -define(`LOCAL_SHELL_FLAGS', `ehuP')dnl -define(`UUCP_MAILER_ARGS', `uux - -r -a$f -gmedium $h!rmail ($u)')dnl diff --git a/usr.sbin/sendmail/cf/ostype/ultrix4.1.m4 b/usr.sbin/sendmail/cf/ostype/ultrix4.1.m4 deleted file mode 100644 index 87c4425bc10e..000000000000 --- a/usr.sbin/sendmail/cf/ostype/ultrix4.1.m4 +++ /dev/null @@ -1,38 +0,0 @@ -divert(-1) -# -# Copyright (c) 1983 Eric P. Allman -# Copyright (c) 1988, 1993 -# The Regents of the University of California. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -divert(0) -VERSIONID(`@(#)ultrix4.1.m4 8.1 (Berkeley) 6/7/93') -ifdef(`_OLD_SENDMAIL_', `define(`NEED_DOMAIN', `')')dnl diff --git a/usr.sbin/sendmail/cf/sitedep/uucp.cad.m4 b/usr.sbin/sendmail/cf/sitedep/uucp.cad.m4 deleted file mode 100644 index 5c340c8440e7..000000000000 --- a/usr.sbin/sendmail/cf/sitedep/uucp.cad.m4 +++ /dev/null @@ -1,36 +0,0 @@ -divert(10)dnl -# -# UUCP connections on cad -# -# @(#)uucp.cad.m4 1.15 (Berkeley) 9/30/88 -# -divert(0)dnl -CV a -CV ames -CV analog -CV ardent dana -CV arthur -CV biosys -CV black -CV boulder -CV evans -CV harpo -CV harris -CV hpda -CV hpsrla -CV island -CV jupiter -CV masscomp masscom -CV nsc -CV oakhill -CV octal -CV sda -CV stellar -CV teklds -CV tektronix tektron -CV binky tonto -CV toshiba tsb0 -CV ucbcad -CV ucbvax -CV voder -CV vogon diff --git a/usr.sbin/sendmail/cf/sitedep/uucp.cogsci.m4 b/usr.sbin/sendmail/cf/sitedep/uucp.cogsci.m4 deleted file mode 100644 index 60a617f28d04..000000000000 --- a/usr.sbin/sendmail/cf/sitedep/uucp.cogsci.m4 +++ /dev/null @@ -1,14 +0,0 @@ -divert(10)dnl -# -# UUCP connections on cogsci -# -# @(#)uucp.cogsci.m4 1.14 (Berkeley) 9/29/88 -# -divert(0)dnl -CV capmkt -CV contessa -CV emind -CV hoptoad -CV nkainc -CV well -CV ferdy diff --git a/usr.sbin/sendmail/cf/sitedep/uucp.ic.m4 b/usr.sbin/sendmail/cf/sitedep/uucp.ic.m4 deleted file mode 100644 index 2759c4c1ebf4..000000000000 --- a/usr.sbin/sendmail/cf/sitedep/uucp.ic.m4 +++ /dev/null @@ -1,8 +0,0 @@ -divert(10)dnl -# -# UUCP connections on ic -# -# @(#)uucp.ic.m4 1.1 (Berkeley) 9/16/88 -# -divert(0)dnl -CV foo diff --git a/usr.sbin/sendmail/cf/sitedep/uucp.id.m4 b/usr.sbin/sendmail/cf/sitedep/uucp.id.m4 deleted file mode 100644 index 2287f408e439..000000000000 --- a/usr.sbin/sendmail/cf/sitedep/uucp.id.m4 +++ /dev/null @@ -1,6 +0,0 @@ -divert(10)dnl -# -# UUCP connections on id -# -divert(0)dnl -CVjpunix diff --git a/usr.sbin/sendmail/cf/sitedep/uucp.okeeffe.m4 b/usr.sbin/sendmail/cf/sitedep/uucp.okeeffe.m4 deleted file mode 100644 index 92b9ab316ea5..000000000000 --- a/usr.sbin/sendmail/cf/sitedep/uucp.okeeffe.m4 +++ /dev/null @@ -1,12 +0,0 @@ -divert(10)dnl -# -# UUCP connections on okeeffe -# -# @(#)uucp.okeeffe.m4 1.1 (Berkeley) 10/28/87 -# -divert(0)dnl -CV blia -CV ccicpg -CV mjk -CV pixar -CV zulu diff --git a/usr.sbin/sendmail/cf/sitedep/uucp.proto.m4 b/usr.sbin/sendmail/cf/sitedep/uucp.proto.m4 deleted file mode 100644 index 52734c2aff19..000000000000 --- a/usr.sbin/sendmail/cf/sitedep/uucp.proto.m4 +++ /dev/null @@ -1,8 +0,0 @@ -divert(10)dnl -# -# Prototype UUCP neighbor file -# -# %W% (Berkeley) %G% -# -divert(0)dnl -CVjpunix diff --git a/usr.sbin/sendmail/cf/sitedep/uucp.ucbarpa.m4 b/usr.sbin/sendmail/cf/sitedep/uucp.ucbarpa.m4 deleted file mode 100644 index 2009d23b08ac..000000000000 --- a/usr.sbin/sendmail/cf/sitedep/uucp.ucbarpa.m4 +++ /dev/null @@ -1,12 +0,0 @@ -divert(10)dnl -# -# UUCP connections on ucbarpa -# -# @(#)uucp.ucbarpa.m4 1.4 (Berkeley) 7/5/87 -# -divert(0)dnl -CV endotsew -CV fateman -CV franz -CV interlan -CV metron diff --git a/usr.sbin/sendmail/cf/sitedep/uucp.ucbvax.m4 b/usr.sbin/sendmail/cf/sitedep/uucp.ucbvax.m4 deleted file mode 100644 index 8e28e73887a3..000000000000 --- a/usr.sbin/sendmail/cf/sitedep/uucp.ucbvax.m4 +++ /dev/null @@ -1,86 +0,0 @@ -divert(10)dnl -# -# UUCP connections on ucbvax -# -# @(#)uucp.ucbvax.m4 1.18 (Berkeley) 12/7/88 -# -divert(0)dnl -CV Padova -CV Shasta -CV alice -CV allegra -CV amdcad -CV anlams -CV att -CV attunix -CV avsd -CV bellcore bellcor -CV calma -CV cithep -CV craylab -CV decusj -CV decvax -CV decwrl -CV dssovax -CV eagle -CV ecovax -CV floyd -CV geoff -CV harpo -CV ho3e2 -CV hpda -CV hplabs -CV ibmsupt ibmuupa ibmpa -CV iiasa70 -CV imagen -CV isunix menlo70 -CV kentmth -CV kentvax -CV lbl-csam lbl-csa -CV lime -CV mebazf -CV molbio -CV mothra -CV mseonyx -CV mtxinu -CV nbires -CV pixar -CV pur-ee -CV purdue -CV pwbd -CV research researc -CV sdcarl -CV sdcsvax -CV sftig -CV sgi olympus -CV sii -CV srivisi -CV ssyx -CV sun -CV tektronix tektron -CV tolerant toleran -CV trwrb -CV twg -CV ucbcad -CV ucdavis -CV ucivax -CV ucla-se ucla-cs -CV ucsbcsl ucsbhub -CV ucscc -CV ucsd -CV ucsfcgl -CV ucsfmis -CV ulysses -CV unisoft -CV unmvax -CV usenix -CV uw -CV uwvax -CV vax135 -CV voder -CV wheps -CV whuxle -CV whuxlj -CV xprin -CV zehntel -CV zilog diff --git a/usr.sbin/sendmail/doc/usenix.me b/usr.sbin/sendmail/doc/usenix.me deleted file mode 100644 index 0c5b13bdecad..000000000000 --- a/usr.sbin/sendmail/doc/usenix.me +++ /dev/null @@ -1,1076 +0,0 @@ -.nr si 3n -.he 'Mail Systems and Addressing in 4.2bsd''%' -.fo 'Version 4.1'USENIX \- Jan 83'Last Mod 7/25/83' -.if n .ls 2 -.+c -.(l C -.sz 14 -Mail Systems and Addressing -in 4.2bsd -.sz -.sp -Eric Allman\(dg -.sp 0.5 -.i -Britton-Lee, Inc. -1919 Addison Street, Suite 105. -Berkeley, California 94704. -.sp 0.5 -.r -eric@Berkeley.ARPA -ucbvax!eric -.)l -.sp -.(l F -.ce -ABSTRACT -.sp \n(psu -Routing mail through a heterogeneous internet presents many new -problems. -Among the worst of these is that of address mapping. -Historically, this has been handled on an ad hoc basis. -However, -this approach has become unmanageable as internets grow. -.sp \n(psu -Sendmail acts a unified -.q "post office" -to which all mail can be -submitted. -Address interpretation is controlled by a production -system, -which can parse both old and new format addresses. -The -new format is -.q "domain-based," -a flexible technique that can -handle many common situations. -Sendmail is not intended to perform -user interface functions. -.sp \n(psu -Sendmail will replace delivermail in the Berkeley 4.2 distribution. -Several major hosts are now or will soon be running sendmail. -This change will affect any users that route mail through a sendmail -gateway. -The changes that will be user visible are emphasized. -.)l -.sp 2 -.(f -\(dgA considerable part of this work -was done while under the employ -of the INGRES Project -at the University of California at Berkeley. -.)f -.pp -The mail system to appear in 4.2bsd -will contain a number of changes. -Most of these changes are based on the replacement of -.i delivermail -with a new module called -.i sendmail. -.i Sendmail -implements a general internetwork mail routing facility, -featuring aliasing and forwarding, -automatic routing to network gateways, -and flexible configuration. -Of key interest to the mail system user -will be the changes in the network addressing structure. -.pp -In a simple network, -each node has an address, -and resources can be identified -with a host-resource pair; -in particular, -the mail system can refer to users -using a host-username pair. -Host names and numbers have to be administered by a central authority, -but usernames can be assigned locally to each host. -.pp -In an internet, -multiple networks with different characteristics -and managements -must communicate. -In particular, -the syntax and semantics of resource identification change. -Certain special cases can be handled trivially -by -.i "ad hoc" -techniques, -such as -providing network names that appear local to hosts -on other networks, -as with the Ethernet at Xerox PARC. -However, the general case is extremely complex. -For example, -some networks require that the route the message takes -be explicitly specified by the sender, -simplifying the database update problem -since only adjacent hosts must be entered -into the system tables, -while others use logical addressing, -where the sender specifies the location of the recipient -but not how to get there. -Some networks use a left-associative syntax -and others use a right-associative syntax, -causing ambiguity in mixed addresses. -.pp -Internet standards seek to eliminate these problems. -Initially, these proposed expanding the address pairs -to address triples, -consisting of -{network, host, username} -triples. -Network numbers must be universally agreed upon, -and hosts can be assigned locally -on each network. -The user-level presentation was changed -to address domains, -comprised of a local resource identification -and a hierarchical domain specification -with a common static root. -The domain technique -separates the issue of physical versus logical addressing. -For example, -an address of the form -.q "eric@a.cc.berkeley.arpa" -describes the logical -organization of the address space -(user -.q eric -on host -.q a -in the Computer Center -at Berkeley) -but not the physical networks used -(for example, this could go over different networks -depending on whether -.q a -were on an ethernet -or a store-and-forward network). -.pp -.i Sendmail -is intended to help bridge the gap -between the totally -.i "ad hoc" -world -of networks that know nothing of each other -and the clean, tightly-coupled world -of unique network numbers. -It can accept old arbitrary address syntaxes, -resolving ambiguities using heuristics -specified by the system administrator, -as well as domain-based addressing. -It helps guide the conversion of message formats -between disparate networks. -In short, -.i sendmail -is designed to assist a graceful transition -to consistent internetwork addressing schemes. -.sp -.pp -Section 1 defines some of the terms -frequently left fuzzy -when working in mail systems. -Section 2 discusses the design goals for -.i sendmail . -In section 3, -the new address formats -and basic features of -.i sendmail -are described. -Section 4 discusses some of the special problems -of the UUCP network. -The differences between -.i sendmail -and -.i delivermail -are presented in section 5. -.sp -.(l F -.b DISCLAIMER: -A number of examples -in this paper -use names of actual people -and organizations. -This is not intended -to imply a commitment -or even an intellectual agreement -on the part of these people or organizations. -In particular, -Bell Telephone Laboratories (BTL), -Digital Equipment Corporation (DEC), -Lawrence Berkeley Laboratories (LBL), -Britton-Lee Incorporated (BLI), -and the University of California at Berkeley -are not committed to any of these proposals at this time. -Much of this paper -represents no more than -the personal opinions of the author. -.)l -.sh 1 "DEFINITIONS" -.pp -There are four basic concepts -that must be clearly distinguished -when dealing with mail systems: -the user (or the user's agent), -the user's identification, -the user's address, -and the route. -These are distinguished primarily by their position independence. -.sh 2 "User and Identification" -.pp -The user is the being -(a person or program) -that is creating or receiving a message. -An -.i agent -is an entity operating on behalf of the user \*- -such as a secretary who handles my mail. -or a program that automatically returns a -message such as -.q "I am at the UNICOM conference." -.pp -The identification is the tag -that goes along with the particular user. -This tag is completely independent of location. -For example, -my identification is the string -.q "Eric Allman," -and this identification does not change -whether I am located at U.C. Berkeley, -at Britton-Lee, -or at a scientific institute in Austria. -.pp -Since the identification is frequently ambiguous -(e.g., there are two -.q "Robert Henry" s -at Berkeley) -it is common to add other disambiguating information -that is not strictly part of the identification -(e.g., -Robert -.q "Code Generator" -Henry -versus -Robert -.q "System Administrator" -Henry). -.sh 2 "Address" -.pp -The address specifies a location. -As I move around, -my address changes. -For example, -my address might change from -.q eric@Berkeley.ARPA -to -.q eric@bli.UUCP -or -.q allman@IIASA.Austria -depending on my current affiliation. -.pp -However, -an address is independent of the location of anyone else. -That is, -my address remains the same to everyone who might be sending me mail. -For example, -a person at MIT and a person at USC -could both send to -.q eric@Berkeley.ARPA -and have it arrive to the same mailbox. -.pp -Ideally a -.q "white pages" -service would be provided to map user identifications -into addresses -(for example, see -[Solomon81]). -Currently this is handled by passing around -scraps of paper -or by calling people on the telephone -to find out their address. -.sh 2 "Route" -.pp -While an address specifies -.i where -to find a mailbox, -a route specifies -.i how -to find the mailbox. -Specifically, -it specifies a path -from sender to receiver. -As such, the route is potentially different -for every pair of people in the electronic universe. -.pp -Normally the route is hidden from the user -by the software. -However, -some networks put the burden of determining the route -onto the sender. -Although this simplifies the software, -it also greatly impairs the usability -for most users. -The UUCP network is an example of such a network. -.sh 1 "DESIGN GOALS" -.pp -Design goals for -.i sendmail \** -.(f -\**This section makes no distinction between -.i delivermail -and -.i sendmail. -.)f -include: -.np -Compatibility with the existing mail programs, -including Bell version 6 mail, -Bell version 7 mail, -Berkeley -.i Mail -[Shoens79], -BerkNet mail -[Schmidt79], -and hopefully UUCP mail -[Nowitz78]. -ARPANET mail -[Crocker82] -was also required. -.np -Reliability, in the sense of guaranteeing -that every message is correctly delivered -or at least brought to the attention of a human -for correct disposal; -no message should ever be completely lost. -This goal was considered essential -because of the emphasis on mail in our environment. -It has turned out to be one of the hardest goals to satisfy, -especially in the face of the many anomalous message formats -produced by various ARPANET sites. -For example, -certain sites generate improperly formated addresses, -occasionally -causing error-message loops. -Some hosts use blanks in names, -causing problems with -mail programs that assume that an address -is one word. -The semantics of some fields -are interpreted slightly differently -by different sites. -In summary, -the obscure features of the ARPANET mail protocol -really -.i are -used and -are difficult to support, -but must be supported. -.np -Existing software to do actual delivery -should be used whenever possible. -This goal derives as much from political and practical considerations -as technical. -.np -Easy expansion to -fairly complex environments, -including multiple -connections to a single network type -(such as with multiple UUCP or Ethernets). -This goal requires consideration of the contents of an address -as well as its syntax -in order to determine which gateway to use. -.np -Configuration information should not be compiled into the code. -A single compiled program should be able to run as is at any site -(barring such basic changes as the CPU type or the operating system). -We have found this seemingly unimportant goal -to be critical in real life. -Besides the simple problems that occur when any program gets recompiled -in a different environment, -many sites like to -.q fiddle -with anything that they will be recompiling anyway. -.np -.i Sendmail -must be able to let various groups maintain their own mailing lists, -and let individuals specify their own forwarding, -without modifying the system alias file. -.np -Each user should be able to specify which mailer to execute -to process mail being delivered for him. -This feature allows users who are using specialized mailers -that use a different format to build their environment -without changing the system, -and facilitates specialized functions -(such as returning an -.q "I am on vacation" -message). -.np -Network traffic should be minimized -by batching addresses to a single host where possible, -without assistance from the user. -.pp -These goals motivated the architecture illustrated in figure 1. -.(z -.hl -.ie t \ -. sp 18 -.el \{\ -.(c -+---------+ +---------+ +---------+ -| sender1 | | sender2 | | sender3 | -+---------+ +---------+ +---------+ - | | | - +----------+ + +----------+ - | | | - v v v - +-------------+ - | sendmail | - +-------------+ - | | | - +----------+ + +----------+ - | | | - v v v -+---------+ +---------+ +---------+ -| mailer1 | | mailer2 | | mailer3 | -+---------+ +---------+ +---------+ -.)c -.\} - -.ce -Figure 1 \*- Sendmail System Structure. -.hl -.)z -The user interacts with a mail generating and sending program. -When the mail is created, -the generator calls -.i sendmail , -which routes the message to the correct mailer(s). -Since some of the senders may be network servers -and some of the mailers may be network clients, -.i sendmail -may be used as an internet mail gateway. -.sh 1 "USAGE" -.sh 2 "Address Formats" -.pp -Arguments may be flags or addresses. -Flags set various processing options. -Following flag arguments, -address arguments may be given. -Addresses follow the syntax in RFC822 -[Crocker82] -for ARPANET -address formats. -In brief, the format is: -.np -Anything in parentheses is thrown away -(as a comment). -.np -Anything in angle brackets (\c -.q "<\|>" ) -is preferred -over anything else. -This rule implements the ARPANET standard that addresses of the form -.(b -user name <machine-address> -.)b -will send to the electronic -.q machine-address -rather than the human -.q "user name." -.np -Double quotes -(\ "\ ) -quote phrases; -backslashes quote characters. -Backslashes are more powerful -in that they will cause otherwise equivalent phrases -to compare differently \*- for example, -.i user -and -.i -"user" -.r -are equivalent, -but -.i \euser -is different from either of them. -This might be used -to avoid normal aliasing -or duplicate suppression algorithms. -.pp -Parentheses, angle brackets, and double quotes -must be properly balanced and nested. -The rewriting rules control remaining parsing\**. -.(f -\**Disclaimer: Some special processing is done -after rewriting local names; see below. -.)f -.pp -Although old style addresses are still accepted -in most cases, -the preferred address format -is based on ARPANET-style domain-based addresses -[Su82a]. -These addresses are based on a hierarchical, logical decomposition -of the address space. -The addresses are hierarchical in a sense -similar to the U.S. postal addresses: -the messages may first be routed to the correct state, -with no initial consideration of the city -or other addressing details. -The addresses are logical -in that each step in the hierarchy -corresponds to a set of -.q "naming authorities" -rather than a physical network. -.pp -For example, -the address: -.(l -eric@HostA.BigSite.ARPA -.)l -would first look up the domain -BigSite -in the namespace administrated by -ARPA. -A query could then be sent to -BigSite -for interpretation of -HostA. -Eventually the mail would arrive at -HostA, -which would then do final delivery -to user -.q eric. -.sh 2 "Mail to Files and Programs" -.pp -Files and programs are legitimate message recipients. -Files provide archival storage of messages, -useful for project administration and history. -Programs are useful as recipients in a variety of situations, -for example, -to maintain a public repository of systems messages -(such as the Berkeley -.i msgs -program). -.pp -Any address passing through the initial parsing algorithm -as a local address -(i.e, not appearing to be a valid address for another mailer) -is scanned for two special cases. -If prefixed by a vertical bar (\c -.q \^|\^ ) -the rest of the address is processed as a shell command. -If the user name begins with a slash mark (\c -.q /\^ ) -the name is used as a file name, -instead of a login name. -.sh 2 "Aliasing, Forwarding, Inclusion" -.pp -.i Sendmail -reroutes mail three ways. -Aliasing applies system wide. -Forwarding allows each user to reroute incoming mail -destined for that account. -Inclusion directs -.i sendmail -to read a file for a list of addresses, -and is normally used -in conjunction with aliasing. -.sh 3 "Aliasing" -.pp -Aliasing maps local addresses to address lists using a system-wide file. -This file is hashed to speed access. -Only addresses that parse as local -are allowed as aliases; -this guarantees a unique key -(since there are no nicknames for the local host). -.sh 3 "Forwarding" -.pp -After aliasing, -if an recipient address specifies a local user -.i sendmail -searches for a -.q .forward -file in the recipient's home directory. -If it exists, -the message is -.i not -sent to that user, -but rather to the list of addresses in that file. -Often -this list will contain only one address, -and the feature will be used for network mail forwarding. -.pp -Forwarding also permits a user to specify a private incoming mailer. -For example, -forwarding to: -.(b -"\^|\|/usr/local/newmail myname" -.)b -will use a different incoming mailer. -.sh 3 "Inclusion" -.pp -Inclusion is specified in RFC 733 [Crocker77] syntax: -.(b -:Include: pathname -.)b -An address of this form reads the file specified by -.i pathname -and sends to all users listed in that file. -.pp -The intent is -.i not -to support direct use of this feature, -but rather to use this as a subset of aliasing. -For example, -an alias of the form: -.(b -project: :include:/usr/project/userlist -.)b -is a method of letting a project maintain a mailing list -without interaction with the system administration, -even if the alias file is protected. -.pp -It is not necessary to rebuild the index on the alias database -when a :include: list is changed. -.sh 2 "Message Collection" -.pp -Once all recipient addresses are parsed and verified, -the message is collected. -The message comes in two parts: -a message header and a message body, -separated by a blank line. -The body is an uninterpreted -sequence of text lines. -.pp -The header is formated as a series of lines -of the form -.(b - field-name: field-value -.)b -Field-value can be split across lines by starting the following -lines with a space or a tab. -Some header fields have special internal meaning, -and have appropriate special processing. -Other headers are simply passed through. -Some header fields may be added automatically, -such as time stamps. -.sh 1 "THE UUCP PROBLEM" -.pp -Of particular interest -is the UUCP network. -The explicit routing -used in the UUCP environment -causes a number of serious problems. -First, -giving out an address -is impossible -without knowing the address of your potential correspondent. -This is typically handled -by specifying the address -relative to some -.q "well-known" -host -(e.g., -ucbvax or decvax). -Second, -it is often difficult to compute -the set of addresses -to reply to -without some knowledge -of the topology of the network. -Although it may be easy for a human being -to do this -under many circumstances, -a program does not have equally sophisticated heuristics -built in. -Third, -certain addresses will become painfully and unnecessarily long, -as when a message is routed through many hosts in the USENET. -And finally, -certain -.q "mixed domain" -addresses -are impossible to parse unambiguously \*- -e.g., -.(l -decvax!ucbvax!lbl-h!user@LBL-CSAM -.)l -might have many possible resolutions, -depending on whether the message was first routed -to decvax -or to LBL-CSAM. -.pp -To solve this problem, -the UUCP syntax -would have to be changed to use addresses -rather than routes. -For example, -the address -.q decvax!ucbvax!eric -might be expressed as -.q eric@ucbvax.UUCP -(with the hop through decvax implied). -This address would itself be a domain-based address; -for example, -an address might be of the form: -.(l -mark@d.cbosg.btl.UUCP -.)l -Hosts outside of Bell Telephone Laboratories -would then only need to know -how to get to a designated BTL relay, -and the BTL topology -would only be maintained inside Bell. -.pp -There are three major problems -associated with turning UUCP addresses -into something reasonable: -defining the namespace, -creating and propagating the necessary software, -and building and maintaining the database. -.sh 2 "Defining the Namespace" -.pp -Putting all UUCP hosts into a flat namespace -(e.g., -.q \&...@host.UUCP ) -is not practical for a number of reasons. -First, -with over 1600 sites already, -and (with the increasing availability of inexpensive microcomputers -and autodialers) -several thousand more coming within a few years, -the database update problem -is simply intractable -if the namespace is flat. -Second, -there are almost certainly name conflicts today. -Third, -as the number of sites grow -the names become ever less mnemonic. -.pp -It seems inevitable -that there be some sort of naming authority -for the set of top level names -in the UUCP domain, -as unpleasant a possibility -as that may seem. -It will simply not be possible -to have one host resolving all names. -It may however be possible -to handle this -in a fashion similar to that of assigning names of newsgroups -in USENET. -However, -it will be essential to encourage everyone -to become subdomains of an existing domain -whenever possible \*- -even though this will certainly bruise some egos. -For example, -if a new host named -.q blid -were to be added to the UUCP network, -it would probably actually be addressed as -.q d.bli.UUCP -(i.e., -as host -.q d -in the pseudo-domain -.q bli -rather than as host -.q blid -in the UUCP domain). -.sh 2 "Creating and Propagating the Software" -.pp -The software required to implement a consistent namespace -is relatively trivial. -Two modules are needed, -one to handle incoming mail -and one to handle outgoing mail. -.pp -The incoming module -must be prepared to handle either old or new style addresses. -New-style addresses -can be passed through unchanged. -Old style addresses -must be turned into new style addresses -where possible. -.pp -The outgoing module -is slightly trickier. -It must do a database lookup on the recipient addresses -(passed on the command line) -to determine what hosts to send the message to. -If those hosts do not accept new-style addresses, -it must transform all addresses in the header of the message -into old style using the database lookup. -.pp -Both of these modules -are straightforward -except for the issue of modifying the header. -It seems prudent to choose one format -for the message headers. -For a number of reasons, -Berkeley has elected to use the ARPANET protocols -for message formats. -However, -this protocol is somewhat difficult to parse. -.pp -Propagation is somewhat more difficult. -There are a large number of hosts -connected to UUCP -that will want to run completely standard systems -(for very good reasons). -The strategy is not to convert the entire network \*- -only enough of it it alleviate the problem. -.sh 2 "Building and Maintaining the Database" -.pp -This is by far the most difficult problem. -A prototype for this database -already exists, -but it is maintained by hand -and does not pretend to be complete. -.pp -This problem will be reduced considerably -if people choose to group their hosts -into subdomains. -This would require a global update -only when a new top level domain -joined the network. -A message to a host in a subdomain -could simply be routed to a known domain gateway -for further processing. -For example, -the address -.q eric@a.bli.UUCP -might be routed to the -.q bli -gateway -for redistribution; -new hosts could be added -within BLI -without notifying the rest of the world. -Of course, -other hosts -.i could -be notified as an efficiency measure. -.pp -There may be more than one domain gateway. -A domain such as BTL, -for instance, -might have a dozen gateways to the outside world; -a non-BTL site -could choose the closest gateway. -The only restriction -would be that all gateways -maintain a consistent view of the domain -they represent. -.sh 2 "Logical Structure" -.pp -Logically, -domains are organized into a tree. -There need not be a host actually associated -with each level in the tree \*- -for example, -there will be no host associated with the name -.q UUCP. -Similarly, -an organization might group names together for administrative reasons; -for example, -the name -.(l -CAD.research.BigCorp.UUCP -.)l -might not actually have a host representing -.q research. -.pp -However, -it may frequently be convenient to have a host -or hosts -that -.q represent -a domain. -For example, -if a single host exists that -represents -Berkeley, -then mail from outside Berkeley -can forward mail to that host -for further resolution -without knowing Berkeley's -(rather volatile) -topology. -This is not unlike the operation -of the telephone network. -.pp -This may also be useful -inside certain large domains. -For example, -at Berkeley it may be presumed -that most hosts know about other hosts -inside the Berkeley domain. -But if they process an address -that is unknown, -they can pass it -.q upstairs -for further examination. -Thus as new hosts are added -only one host -(the domain master) -.i must -be updated immediately; -other hosts can be updated as convenient. -.pp -Ideally this name resolution process -would be performed by a name server -(e.g., [Su82b]) -to avoid unnecessary copying -of the message. -However, -in a batch network -such as UUCP -this could result in unnecessary delays. -.sh 1 "COMPARISON WITH DELIVERMAIL" -.pp -.i Sendmail -is an outgrowth of -.i delivermail . -The primary differences are: -.np -Configuration information is not compiled in. -This change simplifies many of the problems -of moving to other machines. -It also allows easy debugging of new mailers. -.np -Address parsing is more flexible. -For example, -.i delivermail -only supported one gateway to any network, -whereas -.i sendmail -can be sensitive to host names -and reroute to different gateways. -.np -Forwarding and -:include: -features eliminate the requirement that the system alias file -be writable by any user -(or that an update program be written, -or that the system administration make all changes). -.np -.i Sendmail -supports message batching across networks -when a message is being sent to multiple recipients. -.np -A mail queue is provided in -.i sendmail. -Mail that cannot be delivered immediately -but can potentially be delivered later -is stored in this queue for a later retry. -The queue also provides a buffer against system crashes; -after the message has been collected -it may be reliably redelivered -even if the system crashes during the initial delivery. -.np -.i Sendmail -uses the networking support provided by 4.2BSD -to provide a direct interface networks such as the ARPANET -and/or Ethernet -using SMTP (the Simple Mail Transfer Protocol) -over a TCP/IP connection. -.+c -.ce -REFERENCES -.nr ii 1.5i -.ip [Crocker77] -Crocker, D. H., -Vittal, J. J., -Pogran, K. T., -and -Henderson, D. A. Jr., -.ul -Standard for the Format of ARPA Network Text Messages. -RFC 733, -NIC 41952. -In [Feinler78]. -November 1977. -.ip [Crocker82] -Crocker, D. H., -.ul -Standard for the Format of Arpa Internet Text Messages. -RFC 822. -Network Information Center, -SRI International, -Menlo Park, California. -August 1982. -.ip [Feinler78] -Feinler, E., -and -Postel, J. -(eds.), -.ul -ARPANET Protocol Handbook. -NIC 7104, -Network Information Center, -SRI International, -Menlo Park, California. -1978. -.ip [Nowitz78] -Nowitz, D. A., -and -Lesk, M. E., -.ul -A Dial-Up Network of UNIX Systems. -Bell Laboratories. -In -UNIX Programmer's Manual, Seventh Edition, -Volume 2. -August, 1978. -.ip [Schmidt79] -Schmidt, E., -.ul -An Introduction to the Berkeley Network. -University of California, Berkeley California. -1979. -.ip [Shoens79] -Shoens, K., -.ul -Mail Reference Manual. -University of California, Berkeley. -In UNIX Programmer's Manual, -Seventh Edition, -Volume 2C. -December 1979. -.ip [Solomon81] -Solomon, M., -Landweber, L., -and -Neuhengen, D., -.ul -The Design of the CSNET Name Server. -CS-DN-2. -University of Wisconsin, -Madison. -October 1981. -.ip [Su82a] -Su, Zaw-Sing, -and -Postel, Jon, -.ul -The Domain Naming Convention for Internet User Applications. -RFC819. -Network Information Center, -SRI International, -Menlo Park, California. -August 1982. -.ip [Su82b] -Su, Zaw-Sing, -.ul -A Distributed System for Internet Name Service. -RFC830. -Network Information Center, -SRI International, -Menlo Park, California. -October 1982. diff --git a/usr.sbin/sendmail/src/Makefile.BSDI b/usr.sbin/sendmail/src/Makefile.BSDI deleted file mode 100644 index 82df036b1e43..000000000000 --- a/usr.sbin/sendmail/src/Makefile.BSDI +++ /dev/null @@ -1,97 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on BSDI's BSD/386 release 1.0. -# - -# use O=-O (usual) or O=-g (debugging) -O= -O - -# define the database mechanisms available for map & alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM -DNEWDB -DOLD_NEWDB - -# environment definitions (e.g., -D_AIX3) -ENVDEF= -DLA_TYPE=LA_SUBR - -# see also conf.h for additional compilation flags - -# include directories -#INCDIRS=-I/usr/sww/include/db - -# library directories -#LIBDIRS=-L/usr/sww/lib - -# libraries required on your system -LIBS= -lutil -lkvm - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/sbin - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/var/log - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/share/misc - -# additional .o files needed -OBJADD= - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/bin/newaliases ${DESTDIR}/usr/bin/mailq -BINOWN= root -BINGRP= kmem -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - install -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do (rm -f $$i; ln -s ${BINDIR}/sendmail $$i); done - install -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - install -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.ConvexOS b/usr.sbin/sendmail/src/Makefile.ConvexOS deleted file mode 100644 index 673e75c79791..000000000000 --- a/usr.sbin/sendmail/src/Makefile.ConvexOS +++ /dev/null @@ -1,98 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on CxOS 11.0 beta 1 and 10.x. -# - - -# use O=-O (usual) or O=-g (debugging) -O= -g -tm c1 -D__STDC__ -d non_int_bit_field - -# define the database mechanisms available for map & alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM -DYPCOMPAT -DNIS - -# environment definitions (e.g., -D_AIX3) -ENVDEF= - -# see also conf.h for additional compilation flags - -# include directories -#INCDIRS=-I/usr/sww/include/db - -# library directories -#LIBDIRS=-L/usr/sww/lib - -# libraries required on your system -LIBS= - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/lib - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/usr/lib - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/lib - -# additional .o files needed -OBJADD= - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq -BINOWN= root -BINGRP= kmem -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - install -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - install -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - install -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.Dell b/usr.sbin/sendmail/src/Makefile.Dell deleted file mode 100644 index 7d8a79cb4a40..000000000000 --- a/usr.sbin/sendmail/src/Makefile.Dell +++ /dev/null @@ -1,106 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# Based on a Makefile for Dell SVR4 Issue 2.2 from Kimmo Suominen -# <kim@grendel.lut.fi> -- I haven't tested this myself. It may -# work on other SVR4 ports. -# - -# make sure the shell constructs below use the right shell -SHELL= /bin/sh - -# use O=-O (usual) or O=-g (debugging) -O= -O2 - -CC= gcc -#DESTDIR=/usr/local/sendmail - -# define the database mechanism used for alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNEWDB -DNDBM - -# environment definitions (e.g., -D_AIX3) -ENVDEF= -D__svr4__ - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS= - -# library directories -LIBDIRS= - -# libraries required on your system -LIBS= -ldb -ldbm -lresolv -lsocket -lnsl -lelf - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/ucblib - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/usr/ucblib - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/ucblib - -# additional .o files needed -OBJADD= - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq -BINOWN= root -BINGRP= mail -BINMODE=6555 -INSTALL=/usr/ucb/install - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.HP-UX b/usr.sbin/sendmail/src/Makefile.HP-UX deleted file mode 100644 index 29baf17f25f7..000000000000 --- a/usr.sbin/sendmail/src/Makefile.HP-UX +++ /dev/null @@ -1,98 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on HP-UX 8.07 on 7xx series. -# - -# use O=-O (usual) or O=-g (debugging) -# +O is OK on 7xx, and 300xx at 9.0 -O= +O1 - -# define the database mechanism used for alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM -DNEWDB -DNIS - -# environment definitions (e.g., -D_AIX3) -ENVDEF= - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS=-I/usr/sww/include/db - -# library directories -LIBDIRS=-L/usr/sww/lib - -# libraries required on your system -LIBS= -ldb -ldbm - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/lib - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/usr/lib - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/lib - -# additional .o files needed -OBJADD= - - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/bin/newaliases ${DESTDIR}/usr/bin/mailq -BINOWN= root -BINGRP= mail -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - cpset sendmail ${BINDIR} ${BINMODE} ${BINOWN} ${BINGRP} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - cpset /dev/null ${STDIR}/sendmail.st 644 ${BINOWN} ${BINGRP} - cpset sendmail.hf ${HFDIR} 444 ${BINOWN} ${BINGRP} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.IRIX b/usr.sbin/sendmail/src/Makefile.IRIX deleted file mode 100644 index 9ddd03021fc6..000000000000 --- a/usr.sbin/sendmail/src/Makefile.IRIX +++ /dev/null @@ -1,98 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on IRIX 4.0.4. -# - -# use O=-O (usual) or O=-g (debugging) -O= -O -CC=gcc - -# define the database mechanisms available for map & alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM - -# environment definitions (e.g., -D_AIX3) -ENVDEF= -DIRIX - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS= - -# library directories -LIBDIRS= - -# libraries required on your system -LIBS= -lmld - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/lib - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/usr/lib - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/lib - -# additional .o files needed -OBJADD= - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/bsd/newaliases ${DESTDIR}/usr/bsd/mailq -BINOWN= root -BINGRP= sys -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - install -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - install -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - install -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.Linux b/usr.sbin/sendmail/src/Makefile.Linux deleted file mode 100644 index 0edcb4f56f3f..000000000000 --- a/usr.sbin/sendmail/src/Makefile.Linux +++ /dev/null @@ -1,112 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on Linux 0.99p10. -# - -# use O=-O (usual) or O=-g (debugging) -O= -O - -# define the database mechanisms available for map & alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM - -# environment definitions (e.g., -D_AIX3) -ENVDEF= -D__USE_BSD - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS=-I/usr/include/bsd - -# library directories -LIBDIRS=-L/usr/local/lib - -# libraries required on your system -LIBS= -lbsd -ldbm - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/lib - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/usr/lib - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/lib - -# additional .o files needed -OBJADD= - -# additional pseudo-sources needed -BEFORE= features.h - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/bin/newaliases ${DESTDIR}/usr/bin/mailq -BINOWN= root -BINGRP= kmem -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${OBJS} ${LIBDIRS} ${LIBS} - -unistd.h: - cp /dev/null unistd.h - -dirent.h: - echo "#include <sys/dir.h>" > dirent.h - echo "#define dirent direct" >> dirent.h - -features.h: - ln features.linux.h $@ - -NROFF= nroff - -aliases.0: aliases.5 - ${NROFF} -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - ${NROFF} -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - ${NROFF} -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - install -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - install -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - install -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.NeXT b/usr.sbin/sendmail/src/Makefile.NeXT deleted file mode 100644 index 89683140a10d..000000000000 --- a/usr.sbin/sendmail/src/Makefile.NeXT +++ /dev/null @@ -1,107 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on NeXT 2.1. -# - -# use O=-O (usual) or O=-g (debugging) -O= -O - -# define the database mechanisms available for map & alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM - -# environment definitions (e.g., -D_AIX3) -ENVDEF= -DNeXT -DNETINFO - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS= - -# library directories -LIBDIRS=-L/usr/local/lib - -# libraries required on your system -LIBS= -ldbm - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/lib - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/etc/sendmail - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/lib - -# additional .o files needed -OBJADD= - -# additional pseudo-sources needed -BEFORE= unistd.h dirent.h - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq -BINOWN= root -BINGRP= kmem -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${OBJS} ${LIBDIRS} ${LIBS} - -unistd.h: - cp /dev/null unistd.h - -dirent.h: - echo "#include <sys/dir.h>" > dirent.h - echo "#define dirent direct" >> dirent.h - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - install -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - install -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - install -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.OSF1 b/usr.sbin/sendmail/src/Makefile.OSF1 deleted file mode 100644 index 8a442648418d..000000000000 --- a/usr.sbin/sendmail/src/Makefile.OSF1 +++ /dev/null @@ -1,102 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on OSF/1 1.3 -# - -# use O=-O (usual) or O=-g (debugging) -O= -O - -# define the database mechanism used for alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM - -# environment definitions (e.g., -D_AIX3) -ENVDEF= -Olimit 1000 - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS=-I/usr/sww/include/db - -# library directories -LIBDIRS=-L/usr/sww/lib -L/usr/shlib -L/usr/lib - -# libraries required on your system -LIBS= -ldbm - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/sbin - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/var/adm/sendmail - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/share/lib - -# additional .o files needed -OBJADD= - -# additional link flags -#LDADD= -non_shared - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${BINDIR}/newaliases ${BINDIR}/mailq -BINOWN= root -BINGRP= kmem -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${LDADD} ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - installbsd -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - cp /dev/null ${STDIR}/sendmail.st - chmod 644 ${STDIR}/sendmail.st - chown ${BINOWN}.${BINGRP} ${STDIR}/sendmail.st - installbsd -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - rm -f /usr/sbin/smtpd - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.Solaris b/usr.sbin/sendmail/src/Makefile.Solaris deleted file mode 100644 index 1e006fdfb36e..000000000000 --- a/usr.sbin/sendmail/src/Makefile.Solaris +++ /dev/null @@ -1,102 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on Solaris 2.1 and 2.2. -# - -# use O=-O (usual) or O=-g (debugging) -# warning: do not use -O with gcc -O= - -CC= gcc - -# define the database mechanism used for alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM -DNIS - -# environment definitions (e.g., -D_AIX3) -# include -DSOLARIS_2_3 for version 2.3 and higher -ENVDEF= -DSOLARIS - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS=-I/usr/sww/include/db -I. - -# library directories -LIBDIRS=-L/usr/sww/lib - -# libraries required on your system -LIBS= -lresolv -lsocket -lnsl -lelf - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/lib - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/var/log - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/etc/mail - -# additional .o files needed -OBJADD= - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq -BINOWN= root -BINGRP= sys -BINMODE=6555 -INSTALL=/usr/ucb/install - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.SunOS b/usr.sbin/sendmail/src/Makefile.SunOS deleted file mode 100644 index 93409317348b..000000000000 --- a/usr.sbin/sendmail/src/Makefile.SunOS +++ /dev/null @@ -1,104 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on SunOS 4.1.[12]. -# For SunOS 4.0.3, add -DSUNOS403 to the ENVDEF macro, and -# create empty files stdlib.h and stddef.h in your -# compile directory. -# - -# use O=-O (usual) or O=-g (debugging) -O= -O - -# define the database mechanisms available for map & alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM -DNEWDB -DNIS - -# environment definitions (e.g., -D_AIX3) -# need to add -DSUNOS403 if you are on a SunOS 4.0.3 system -ENVDEF= - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS=-I/usr/sww/include/db - -# loader options -LDOPTS= -Bstatic - -# library directories -LIBDIRS=-L/usr/sww/lib - -# libraries required on your system -LIBS= -ldb -ldbm -lresolv - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/lib - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/etc - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/lib - -# additional .o files needed -OBJADD= - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq -BINOWN= root -BINGRP= kmem -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${LDOPTS} ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - install -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - install -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - install -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.ULTRIX b/usr.sbin/sendmail/src/Makefile.ULTRIX deleted file mode 100644 index 66c73fa4e271..000000000000 --- a/usr.sbin/sendmail/src/Makefile.ULTRIX +++ /dev/null @@ -1,100 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on Ultrix 4.2A and 4.3A. -# - -# use O=-O (usual) or O=-g (debugging) -O= -O - -# define the database mechanisms available for map & alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM -DNEWDB -DNIS - -# environment definitions (e.g., -D_AIX3) -ENVDEF= -Olimit 800 - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS=-I/usr/sww/include/db - -# loader options -LDOPTS= - -# library directories -LIBDIRS=-L/usr/sww/lib - -# libraries required on your system -LIBS= -ldb - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/lib - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/var/log - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/lib - -# additional .o files needed -OBJADD= - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq -BINOWN= root -BINGRP= kmem -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${LDOPTS} ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - install -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - install -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - install -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.UMAX b/usr.sbin/sendmail/src/Makefile.UMAX deleted file mode 100644 index d9d0db678adf..000000000000 --- a/usr.sbin/sendmail/src/Makefile.UMAX +++ /dev/null @@ -1,107 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# This has been tested on Encore UMAX V -# - -# use O=-O (usual) or O=-g (debugging) -O= -O - -# define the database mechanisms available for map & alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNIS - -# environment definitions (e.g., -D_AIX3) -ENVDEF= -DUMAXV - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS= - -# loader options -LDOPTS= - -# library directories -LIBDIRS= - -# libraries required on your system -LIBS= -lyp -lrpc - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/lib - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/var/log - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/lib - -# additional .o files needed -OBJADD= - -# things to do before compilation -BEFORE= stddef.h - -stddef.h: - echo "#define _STDDEF_H" > stddef.h - chmod 444 stddef.h - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq -BINOWN= root -BINGRP= kmem -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${LDOPTS} ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -install: install-sendmail install-docs - -install-sendmail: sendmail - install -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - install -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - install -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sendmail/src/Makefile.Utah b/usr.sbin/sendmail/src/Makefile.Utah deleted file mode 100644 index bc3ad393d166..000000000000 --- a/usr.sbin/sendmail/src/Makefile.Utah +++ /dev/null @@ -1,39 +0,0 @@ - -PROG= sendmail - -# define the database format to use for aliases et al. Can be -DNEWDB (for -# the new BSD database package -- this is preferred) or -DNDBM for the NDBM -# database package. The old putrescent V7 DBM package is no longer -# supported. -# You can define both NEWDB and NDBM during a transition period; old -# databases are read, but the new format will be used on any rebuilds. On -# really gnarly systems, you can set this to null; it will crawl like a high -# spiral snail, but it will work. -DBMDEF= -DNEWDB -DNDBM -DOLD_NEWDB - -CFLAGS+=-I${.CURDIR} ${DBMDEF} -Dsetpgid=setpgrp - -SRCS= alias.c arpadate.c clock.c collect.c conf.c convtime.c daemon.c \ - deliver.c domain.c envelope.c err.c headers.c macro.c main.c map.c \ - mci.c parseaddr.c queue.c readcf.c recipient.c savemail.c srvrsmtp.c \ - stab.c stats.c sysexits.c trace.c udb.c usersmtp.c \ - util.c version.c -DPADD= ${LIBDBM} ${LIBCOMPAT} -LDADD= -MAN1= newaliases.0 -MAN5= aliases.0 -MAN8= sendmail.0 -LINKS= ${DESTDIR}/usr/sbin/sendmail ${DESTDIR}/usr/bin/newaliases \ - ${DESTDIR}/usr/sbin/sendmail ${DESTDIR}/usr/bin/mailq -BINDIR= /usr/sbin -BINOWN= root -BINGRP= kmem -BINMODE=6555 - -beforeinstall: - install -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${DESTDIR}/var/log/sendmail.st - install -c -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/sendmail.hf \ - ${DESTDIR}/usr/share/misc - -.include <bsd.prog.mk> diff --git a/usr.sbin/sendmail/src/Makefile.dist b/usr.sbin/sendmail/src/Makefile.dist deleted file mode 100644 index 127e6a7bd7fb..000000000000 --- a/usr.sbin/sendmail/src/Makefile.dist +++ /dev/null @@ -1,102 +0,0 @@ -# -# This Makefile is designed to work on the old "make" program. It does -# not use the obj subdirectory. It also does not install documentation -# automatically -- think of it as a quick start for sites that have the -# old make program (I recommend that you get and port the new make if you -# are going to be doing any signficant work on sendmail). -# -# @(#)Makefile.dist 8.9 (Berkeley) 12/20/93 -# - -# use O=-O (usual) or O=-g (debugging) -O= -O - -# define the database mechanisms available for map & alias lookups: -# -DNDBM -- use new DBM -# -DNEWDB -- use new Berkeley DB -# -DNIS -- include NIS support -# The really old (V7) DBM library is no longer supported. -# See READ_ME for a description of how these flags interact. -# -DBMDEF= -DNDBM -DNEWDB - -# environment definitions (e.g., -D_AIX3) -ENVDEF= - -# see also conf.h for additional compilation flags - -# include directories -INCDIRS=-I/usr/sww/include/db - -# loader options -LDOPTS= - -# library directories -LIBDIRS=-L/usr/sww/lib - -# libraries required on your system -LIBS= -ldb -ldbm - -# location of sendmail binary (usually /usr/sbin or /usr/lib) -BINDIR= ${DESTDIR}/usr/sbin - -# location of sendmail.st file (usually /var/log or /usr/lib) -STDIR= ${DESTDIR}/var/log - -# location of sendmail.hf file (usually /usr/share/misc or /usr/lib) -HFDIR= ${DESTDIR}/usr/share/misc - -# additional .o files needed -OBJADD= - -################### end of user configuration flags ###################### - -CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF} - -OBJS= alias.o arpadate.o clock.o collect.o conf.o convtime.o daemon.o \ - deliver.o domain.o envelope.o err.o headers.o macro.o main.o \ - map.o mci.o parseaddr.o queue.o readcf.o recipient.o \ - savemail.o srvrsmtp.o stab.o stats.o sysexits.o \ - trace.o udb.o usersmtp.o util.o version.o ${OBJADD} - -LINKS= ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq -BINOWN= root -BINGRP= kmem -BINMODE=6555 - -ALL= sendmail aliases.0 newaliases.0 sendmail.0 - -all: ${ALL} - -sendmail: ${BEFORE} ${OBJS} - ${CC} -o sendmail ${LDOPTS} ${OBJS} ${LIBDIRS} ${LIBS} - -aliases.0: aliases.5 - nroff -h -mandoc aliases.5 > aliases.0 - -newaliases.0: newaliases.1 - nroff -h -mandoc newaliases.1 > newaliases.0 - -sendmail.0: sendmail.8 - nroff -h -mandoc sendmail.8 > sendmail.0 - -INSTALL=install - -install: install-sendmail install-docs - -install-sendmail: sendmail - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} sendmail ${BINDIR} - for i in ${LINKS}; do rm -f $$i; ln -s ${BINDIR}/sendmail $$i; done - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \ - ${STDIR}/sendmail.st - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 sendmail.hf ${HFDIR} - -# doesn't actually install them -- you may want to install pre-nroff versions -install-docs: aliases.0 newaliases.0 sendmail.0 - -clean: - rm -f ${OBJS} sendmail aliases.0 newaliases.0 sendmail.0 - -# dependencies -# gross overkill, and yet still not quite enough.... -${OBJS}: sendmail.h conf.h diff --git a/usr.sbin/sup/source/local_server.tar.UU b/usr.sbin/sup/source/local_server.tar.UU deleted file mode 100644 index 67dd25c675ef..000000000000 --- a/usr.sbin/sup/source/local_server.tar.UU +++ /dev/null @@ -1,2552 +0,0 @@ -begin 644 local_server.tar -M+B\````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````"`@(#<U-2``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`P -M("`T-38P-#<P,#8T("`@-#(S,@`@```````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````N+V)I;BYC;74O```````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````("`@-S4U(``@(#(T,C<@`"`@ -M(#8S,"``("`@("`@("`@(#`@(#0U-C`S-C$P-C,@("`U-38S`"`````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````"XO8FEN+F-M=2]C -M<GEP=``````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````@ -M("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@-B`@-#4V,#,U-C<W -M-B`@(#8V-C<`(``````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````0U)94%0*```````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````N+V)I;BYC;74O;&ES=``````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````("`@-C0T(``@(#(T -M,C<@`"`@(#8S,"``("`@("`@("`T,#0@(#0U-C`S-3<S-30@("`V-3,T`"`` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````````'5P9W)A -M9&4@971C+VAO<W1S(&5T8R]R9G-D+6AO<W1S"G5P9W)A9&4@971C+W)E<V]L -M=BYC;VYF"G5P9W)A9&4@971C+V%C8V5S<R!E=&,O86-C;W5N=`IU<&=R861E -M(&5T8R]M;W1D"G5P9W)A9&4@971C+W1E<FUC87`*=7!G<F%D92!E=&,O;F%M -M961B"@IU<&=R861E('-U<"]355!&24Q%"G5P9W)A9&4@=7-R+VQI8B]R8V]N -M<V]L97,*=7!G<F%D92!U<W(O8FEN+V5M86-S('5S<B]L;V-A;"]M86-L:6(* -M"F]M:71A;GD@*D)!2R`J0TM0("HN;VQD(&-O<F4*```````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````+B]B:6XN8VUU+VAO<W0````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````"`@(#8T-"``("`R-#(W(``@("`V,S`@ -M`"`@("`@("`@("`P("`T-38P,S4W,#0T("`@-C0V,@`@```````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````N+V)I;BYC;74O<')E9FEX -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````("`@-C0T -M(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#8@(#0U-C`S-C$P-#0@("`W -M,#`S`"`````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`$)!4T4O"F4@971C+VAO<W1S(&5T8R]R9G-D+6AO<W1S"G5P9W)A9&4@971C -M+W)E<V]L=BYC;VYF"G5P9W)A9&4@971C+V%C8V5S<R!E=&,O86-C;W5N=`IU -M<&=R861E(&5T8R]M;W1D"G5P9W)A9&4@971C+W1E<FUC87`*=7!G<F%D92!E -M=&,O;F%M961B"@IU<&=R861E('-U<"]355!&24Q%"G5P9W)A9&4@=7-R+VQI -M8B]R8V]N<V]L97,*=7!G<F%D92!U<W(O8FEN+V5M86-S('5S<B]L;V-A;"]M -M86-L:6(*"F]M:71A;GD@*D)!2R`J0TM0("HN;VQD(&-O<F4*```````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````+B]B:6XN8VUU+VQO9V9I;&4````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````"`@(#8T-"``("`R-#(W(``@ -M("`V,S`@`"`@("`@("`@("`P("`T-38P,S4V-S<V("`@-S$T,0`@```````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````N+V)I;BYR;V]T -M+P`````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M("`@-S4U(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-C$P -M-C,@("`U-S8R`"`````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````"XO8FEN+G)O;W0O8W)Y<'0````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@ -M("`@("`@-B`@-#4V,#,U-C<W-R`@(#<P-C<`(``````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````0U)94%0*92!E=&,O:&]S=',@971C -M+W)F<V0M:&]S=',*=7!G<F%D92!E=&,O<F5S;VQV+F-O;F8*=7!G<F%D92!E -M=&,O86-C97-S(&5T8R]A8V-O=6YT"G5P9W)A9&4@971C+VUO=&0*=7!G<F%D -M92!E=&,O=&5R;6-A<`IU<&=R861E(&5T8R]N86UE9&(*"G5P9W)A9&4@<W5P -M+U-54$9)3$4*=7!G<F%D92!U<W(O;&EB+W)C;VYS;VQE<PIU<&=R861E('5S -M<B]B:6XO96UA8W,@=7-R+VQO8V%L+VUA8VQI8@H*;VUI=&%N>2`J0D%+("I# -M2U`@*BYO;&0@8V]R90H````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````N+V)I -M;BYR;V]T+VQI<W0````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`V,38@(#0U -M-C`S-3<S-38@("`V-S0R`"`````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````'5P9W)A9&4@+F-S:')C("YP<F]F:6QE("YL;V=I;@IU -M<&=R861E(&)I;B!D978O34%+141%5B!E=&,@;&EB"@IO;6ET(&5T8R]P87-S -M=V0@971C+V=R;W5P(&5T8R]N971S=&%R="!E=&,O:&]S=',@971C+W)F<V0M -M:&]S=',*;VUI="!E=&,O<F5S;VQV+F-O;F8@971C+W1E<FUC87`@971C+VYA -M;65D+F)O;W0*;VUI="!E=&,O86-C97-S(&5T8R]A8V-O=6YT(&5T8R]C:&%N -M9V5U<V5R"F]M:70@971C+VUT86(@971C+VUO=&0@971C+V1U;7!D871E<R!E -M=&,O9G-T86(@971C+W5T;7`*;VUI="!E=&,O;F%M961B(&5T8R]N86UE9"YP -M:60@971C+W-Y<VQO9RYP:60*"G-Y;6QI;FL@;&EB+V9G8V,M8W!P"G-Y;6QI -M;FL@;&EB+V9G8V,M:6YC;'5D90H*;VUI=&%N>2`J0D%+("I#2U`@*BYO;&0@ -M(&-O<F4*```````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````+B]B:6XN<F]O="]H;W-T -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````````"`@(#8T -M-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`P("`T-38P,S4W,#0U("`@ -M-C8V,@`@```````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```N+V)I;BYR;V]T+W!R969I>``````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@ -M(#4@(#0U-C`S-C$P,30@("`W,3<V`"`````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````$)!4T4O9&4@+F-S:')C("YP<F]F:6QE("YL -M;V=I;@IU<&=R861E(&)I;B!D978O34%+141%5B!E=&,@;&EB"@IO;6ET(&5T -M8R]P87-S=V0@971C+V=R;W5P(&5T8R]N971S=&%R="!E=&,O:&]S=',@971C -M+W)F<V0M:&]S=',*;VUI="!E=&,O<F5S;VQV+F-O;F8@971C+W1E<FUC87`@ -M971C+VYA;65D+F)O;W0*;VUI="!E=&,O86-C97-S(&5T8R]A8V-O=6YT(&5T -M8R]C:&%N9V5U<V5R"F]M:70@971C+VUT86(@971C+VUO=&0@971C+V1U;7!D -M871E<R!E=&,O9G-T86(@971C+W5T;7`*;VUI="!E=&,O;F%M961B(&5T8R]N -M86UE9"YP:60@971C+W-Y<VQO9RYP:60*"G-Y;6QI;FL@;&EB+V9G8V,M8W!P -M"G-Y;6QI;FL@;&EB+V9G8V,M:6YC;'5D90H*;VUI=&%N>2`J0D%+("I#2U`@ -M*BYO;&0@(&-O<F4*```````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````+B]B:6XN<F]O -M="]L;V=F:6QE```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`P("`T-38P,S4V -M-S<V("`@-S,T,``@```````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````N+V)I;BYU<W(O```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````("`@-S4U(``@(#(T,C<@`"`@(#8S,"``("`@ -M("`@("`@(#`@(#0U-C`S-C$P-C0@("`U-C$Q`"`````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````"XO8FEN+G5S<B]C<GEP=``````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````@("`V-#0@`"`@ -M,C0R-R``("`@-C,P(``@("`@("`@("`@-B`@-#4V,#,U-S`P,"`@(#8V-S$` -M(``````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````````0U)9 -M4%0*92`N8W-H<F,@+G!R;V9I;&4@+FQO9VEN"G5P9W)A9&4@8FEN(&1E=B]- -M04M%1$56(&5T8R!L:6(*"F]M:70@971C+W!A<W-W9"!E=&,O9W)O=7`@971C -M+VYE='-T87)T(&5T8R]H;W-T<R!E=&,O<F9S9"UH;W-T<PIO;6ET(&5T8R]R -M97-O;'8N8V]N9B!E=&,O=&5R;6-A<"!E=&,O;F%M960N8F]O=`IO;6ET(&5T -M8R]A8V-E<W,@971C+V%C8V]U;G0@971C+V-H86YG975S97(*;VUI="!E=&,O -M;71A8B!E=&,O;6]T9"!E=&,O9'5M<&1A=&5S(&5T8R]F<W1A8B!E=&,O=71M -M<`IO;6ET(&5T8R]N86UE9&(@971C+VYA;65D+G!I9"!E=&,O<WES;&]G+G!I -M9`H*<WEM;&EN:R!L:6(O9F=C8RUC<'`*<WEM;&EN:R!L:6(O9F=C8RUI;F-L -M=61E"@IO;6ET86YY("I"04L@*D-+4"`J+F]L9"`@8V]R90H````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````N+V)I;BYU<W(O;&ES=``````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S -M,"``("`@("`@(#$V,C4@(#0U-C`S-C`W-S$@("`V-C`T`"`````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````'5P9W)A9&4@>V)I;BQD -M:6-T+&1O8RQG86UE<RQG=65S="QI;F-L=61E+&QI8BQL;V-A;"QM86XL;F5W -M+&]L9"QP<F5S97)V97T*=7!G<F%D92![<W!O;VPL=&5S=',L=6-B?0H*;VUI -M="!L:6(O<F-O;G-O;&5S"F]M:70@8FEN+V5M86-S(&QO8V%L+VUA8VQI8@IO -M;6ET(&QO8V%L+V)I;B]8,3$*;VUI="!L;V-A;"]L:6(O6#$Q"@IO;6ET('-P -M;V]L+VQP9"YL;V-K"@IO;6ET86YY("I"04L@*D-+4"`J+F]L9"!C;W)E"@IS -M>6UL:6YK(&=A;65S+V%T8PIS>6UL:6YK(&=A;65S+V)A8VMG86UM;VX*<WEM -M;&EN:R!G86UE<R]B871T;&5S=&%R"G-Y;6QI;FL@9V%M97,O8F]G9VQE"G-Y -M;6QI;FL@9V%M97,O8G1L9V%M;6]N"G-Y;6QI;FL@9V%M97,O8V%N9FEE;&0* -M<WEM;&EN:R!G86UE<R]C<FEB8F%G90IS>6UL:6YK(&=A;65S+V9I<V@*<WEM -M;&EN:R!G86UE<R]H86YG;6%N"G-Y;6QI;FL@9V%M97,O:'5N=`IS>6UL:6YK -M(&=A;65S+VUI;&QE"G-Y;6QI;FL@9V%M97,O;6]N;W`*<WEM;&EN:R!G86UE -M<R]P:&%N=&%S:6$*<WEM;&EN:R!G86UE<R]Q=6EZ"G-Y;6QI;FL@9V%M97,O -M<F]B;W1S"G-Y;6QI;FL@9V%M97,O<F]G=64*<WEM;&EN:R!G86UE<R]S86EL -M"G-Y;6QI;FL@9V%M97,O<VYA:V4*<WEM;&EN:R!G86UE<R]S;G-C;W)E"G-Y -M;6QI;FL@9V%M97,O=')E:PIS>6UL:6YK(&=A;65S+W=O<FT*<WEM;&EN:R!G -M86UE<R]W=6UP"@IS>6UL:6YK(&EN8VQU9&4O97)R;F\N:`IS>6UL:6YK(&EN -M8VQU9&4O9G)A;64N:`IS>6UL:6YK(&EN8VQU9&4O<VEG;F%L+F@*<WEM;&EN -M:R!I;F-L=61E+W-Y<VQO9RYH"G-Y;6QI;FL@:6YC;'5D92]M86-H:6YE"G-Y -M;6QI;FL@:6YC;'5D92]M86-H+VUA8VAI;F4*"G-Y;6QI;FL@;&EB+VQI;G0O -M;&QI8BUL=&5R;6QI8@IS>6UL:6YK(&QI8B]L:6YT+VQL:6(M;'1E<FUL:6(N -M;&X*9V%M97,O9FES:`IS>6UL:6YK(&=A;65S+VAA;F=M86X*<WEM;&EN:R!G -M86UE<R]H=6YT"G-Y;6QI;FL@9V%M97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M -M;VYO<`IS>6UL:6YK(&=A;65S+W`N+V)I;BYU<W(O:&]S=``````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````("`@-C0T(``@(#(T,C<@ -M`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P-#8@("`V-3$Q`"`````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````"XO8FEN+G5S -M<B]P<F5F:7@````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`Q,2`@-#4V,#,U -M-S,U-R`@(#<P-C``(``````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````0D%312]U<W(*<WEM;&EN:R!G86UE<R]Q=6EZ"G-Y;6QI;FL@ -M9V%M97,O<F]B;W1S"G-Y;6QI;FL@9V%M97,O<F]G=64*<WEM;&EN:R!G86UE -M<R]S86EL"G-Y;6QI;FL@9V%M97,O<VYA:V4*<WEM;&EN:R!G86UE<R]S;G-C -M;W)E"G-Y;6QI;FL@9V%M97,O=')E:PIS>6UL:6YK(&=A;65S+W=O<FT*<WEM -M;&EN:R!G86UE<R]W=6UP"@IS>6UL:6YK(&EN8VQU9&4O97)R;F\N:`IS>6UL -M:6YK(&EN8VQU9&4O9G)A;64N:`IS>6UL:6YK(&EN8VQU9&4O<VEG;F%L+F@* -M<WEM;&EN:R!I;F-L=61E+W-Y<VQO9RYH"G-Y;6QI;FL@:6YC;'5D92]M86-H -M:6YE"G-Y;6QI;FL@:6YC;'5D92]M86-H+VUA8VAI;F4*"G-Y;6QI;FL@;&EB -M+VQI;G0O;&QI8BUL=&5R;6QI8@IS>6UL:6YK(&QI8B]L:6YT+VQL:6(M;'1E -M<FUL:6(N;&X*9V%M97,O9FES:`IS>6UL:6YK(&=A;65S+VAA;F=M86X*<WEM -M;&EN:R!G86UE<R]H=6YT"G-Y;6QI;FL@9V%M97,O;6EL;&4*<WEM;&EN:R!G -M86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N+V)I;BYU<W(O;&]G9FEL90`` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````("`@-C0T(``@ -M(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-38W-S<@("`W,38W -M`"`````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````````````"XO -M;6%C:"YF<R\````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````@("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@,"`@ -M-#4V,#,U-S,V,B`@(#4U-38`(``````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````+B]M86-H+F9S+V-R>7!T```````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````"`@(#8T-"``("`R-#(W(``@("`V -M,S`@`"`@("`@("`@("`V("`T-38P,S4W,#`P("`@-C8S,``@```````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````!#4EE05`IS<@IS>6UL -M:6YK(&=A;65S+W%U:7H*<WEM;&EN:R!G86UE<R]R;V)O=',*<WEM;&EN:R!G -M86UE<R]R;V=U90IS>6UL:6YK(&=A;65S+W-A:6P*<WEM;&EN:R!G86UE<R]S -M;F%K90IS>6UL:6YK(&=A;65S+W-N<V-O<F4*<WEM;&EN:R!G86UE<R]T<F5K -M"G-Y;6QI;FL@9V%M97,O=V]R;0IS>6UL:6YK(&=A;65S+W=U;7`*"G-Y;6QI -M;FL@:6YC;'5D92]E<G)N;RYH"G-Y;6QI;FL@:6YC;'5D92]F<F%M92YH"G-Y -M;6QI;FL@:6YC;'5D92]S:6=N86PN:`IS>6UL:6YK(&EN8VQU9&4O<WES;&]G -M+F@*<WEM;&EN:R!I;F-L=61E+VUA8VAI;F4*<WEM;&EN:R!I;F-L=61E+VUA -M8V@O;6%C:&EN90H*<WEM;&EN:R!L:6(O;&EN="]L;&EB+6QT97)M;&EB"G-Y -M;6QI;FL@;&EB+VQI;G0O;&QI8BUL=&5R;6QI8BYL;@IG86UE<R]F:7-H"G-Y -M;6QI;FL@9V%M97,O:&%N9VUA;@IS>6UL:6YK(&=A;65S+VAU;G0*<WEM;&EN -M:R!G86UE<R]M:6QL90IS>6UL:6YK(&=A;65S+VUO;F]P"G-Y;6QI;FL@9V%M -M97,O<"XO;6%C:"YF<R]L:7-T```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@ -M(#(R,B`@-#4V,#,U-S,V,B`@(#8U,34`(``````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````=7!G<F%D92!A9G,*=7!G<F%D92!A9G-I -M;G0*=7!G<F%D92!K<G!C"G5P9W)A9&4@;F9S"G5P9W)A9&4@<G!C"G5P9W)A -M9&4@<G@*=7!G<F%D92!S<&5C9G,*=7!G<F%D92!V9G,*"F]M:71A;GD@*BYO -M("HN0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIE:PIS>6UL:6YK(&=A -M;65S+W=O<FT*<WEM;&EN:R!G86UE<R]W=6UP"@IS>6UL:6YK(&EN8VQU9&4O -M97)R;F\N:`IS>6UL:6YK(&EN8VQU9&4O9G)A;64N:`IS>6UL:6YK(&EN8VQU -M9&4O<VEG;F%L+F@*<WEM;&EN:R!I;F-L=61E+W-Y<VQO9RYH"G-Y;6QI;FL@ -M:6YC;'5D92]M86-H:6YE"G-Y;6QI;FL@:6YC;'5D92]M86-H+VUA8VAI;F4* -M"G-Y;6QI;FL@;&EB+VQI;G0O;&QI8BUL=&5R;6QI8@IS>6UL:6YK(&QI8B]L -M:6YT+VQL:6(M;'1E<FUL:6(N;&X*9V%M97,O9FES:`IS>6UL:6YK(&=A;65S -M+VAA;F=M86X*<WEM;&EN:R!G86UE<R]H=6YT"G-Y;6QI;FL@9V%M97,O;6EL -M;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N+VUA8V@N -M9G,O:&]S=``````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S -M-3<P-#<@("`V-#4Q`"`````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````"XO;6%C:"YF<R]P<F5F:7@````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@ -M("`@("`@("`R,2`@-#4V,#,U-S,V,2`@(#<P,3,`(``````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````0D%312]U<W(O<W)C+W-Y<PID -M92!A9G-I;G0*=7!G<F%D92!K<G!C"G5P9W)A9&4@;F9S"G5P9W)A9&4@<G!C -M"G5P9W)A9&4@<G@*=7!G<F%D92!S<&5C9G,*=7!G<F%D92!V9G,*"F]M:71A -M;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIE:PIS>6UL -M:6YK(&=A;65S+W=O<FT*<WEM;&EN:R!G86UE<R]W=6UP"@IS>6UL:6YK(&EN -M8VQU9&4O97)R;F\N:`IS>6UL:6YK(&EN8VQU9&4O9G)A;64N:`IS>6UL:6YK -M(&EN8VQU9&4O<VEG;F%L+F@*<WEM;&EN:R!I;F-L=61E+W-Y<VQO9RYH"G-Y -M;6QI;FL@:6YC;'5D92]M86-H:6YE"G-Y;6QI;FL@:6YC;'5D92]M86-H+VUA -M8VAI;F4*"G-Y;6QI;FL@;&EB+VQI;G0O;&QI8BUL=&5R;6QI8@IS>6UL:6YK -M(&QI8B]L:6YT+VQL:6(M;'1E<FUL:6(N;&X*9V%M97,O9FES:`IS>6UL:6YK -M(&=A;65S+VAA;F=M86X*<WEM;&EN:R!G86UE<R]H=6YT"G-Y;6QI;FL@9V%M -M97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N -M+VUA8V@N9G,O;&]G9FEL90`````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@ -M(#0U-C`S-3<P,#`@("`W,3`R`"`````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````"XO;6%C:"YS>7,O```````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````@("`W-34@`"`@,C0R-R``("`@ -M-C,P(``@("`@("`@("`@,"`@-#4V,#,V,3`V-"`@(#4W-38`(``````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````+B]M86-H+G-Y<R]C -M<GEP=``````````````````````````````````````````````````````` -M`````````````````````````````````````````````````````````"`@ -M(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`V("`T-38P,S4W,#`Q -M("`@-S`S-P`@```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````!#4EE05`IS<B]S<F,O<WES"F1E(&%F<VEN=`IU<&=R861E(&MR<&,* -M=7!G<F%D92!N9G,*=7!G<F%D92!R<&,*=7!G<F%D92!R>`IU<&=R861E('-P -M96-F<PIU<&=R861E('9F<PH*;VUI=&%N>2`J+F\@*BY"04L@*BY#2U`@*BYO -M;&0@*BYO<FEG("HN;F5W"F5K"G-Y;6QI;FL@9V%M97,O=V]R;0IS>6UL:6YK -M(&=A;65S+W=U;7`*"G-Y;6QI;FL@:6YC;'5D92]E<G)N;RYH"G-Y;6QI;FL@ -M:6YC;'5D92]F<F%M92YH"G-Y;6QI;FL@:6YC;'5D92]S:6=N86PN:`IS>6UL -M:6YK(&EN8VQU9&4O<WES;&]G+F@*<WEM;&EN:R!I;F-L=61E+VUA8VAI;F4* -M<WEM;&EN:R!I;F-L=61E+VUA8V@O;6%C:&EN90H*<WEM;&EN:R!L:6(O;&EN -M="]L;&EB+6QT97)M;&EB"G-Y;6QI;FL@;&EB+VQI;G0O;&QI8BUL=&5R;6QI -M8BYL;@IG86UE<R]F:7-H"G-Y;6QI;FL@9V%M97,O:&%N9VUA;@IS>6UL:6YK -M(&=A;65S+VAU;G0*<WEM;&EN:R!G86UE<R]M:6QL90IS>6UL:6YK(&=A;65S -M+VUO;F]P"G-Y;6QI;FL@9V%M97,O<"XO;6%C:"YS>7,O;&ES=``````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````@("`V-#0@`"`@,C0R -M-R``("`@-C,P(``@("`@("`@(#<R,R`@-#4V,#,V,#<Q-"`@(#8W,C0`(``` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````=7!G<F%D -M92!-86ME9FEL90IU<&=R861E(&)I;@IU<&=R861E(&)S9`IU<&=R861E(&)U -M:6QT:6X*=7!G<F%D92!C;VUP870*=7!G<F%D92!C;VYF"G5P9W)A9&4@:3,X -M-@IU<&=R861E(&DS.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI -M;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B -M=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP -M"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P -M9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G -M<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA -M8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE -M=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN -M;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL -M:6YK(&=A;65S+W`N+VUA8V@N<WES+VAO<W0````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"`` -M("`@("`@("`@(#`@(#0U-C`S-3<P-3`@("`V-C4Q`"`````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````"XO;6%C:"YS>7,O<')E9FEX -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````@("`V-#0@ -M`"`@,C0R-R``("`@-C,P(``@("`@("`@("`R,2`@-#4V,#,U-S,V,R`@(#<R -M,C,`(``````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M0D%312]U<W(O<W)C+W-Y<PIU<&=R861E(&)I;@IU<&=R861E(&)S9`IU<&=R -M861E(&)U:6QT:6X*=7!G<F%D92!C;VUP870*=7!G<F%D92!C;VYF"G5P9W)A -M9&4@:3,X-@IU<&=R861E(&DS.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D -M92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA -M8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@ -M;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@ -M<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S -M>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M -M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN -M+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN -M;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO -M<`IS>6UL:6YK(&=A;65S+W`N+VUA8V@N<WES+VQO9V9I;&4````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````("`@-C0T(``@(#(T,C<@`"`@ -M(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P,#$@("`W,S$Q`"`````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````"XO<W)C+DU)4T,O -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````@ -M("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@,"`@-#4V,#,V,3`V -M-"`@(#4U-3(`(``````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````+B]S<F,N34E30R]C<GEP=``````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@ -M("`@("`V("`T-38P,S4W,#`R("`@-C8S-``@```````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````!#4EE05`IS<B]S<F,O<WES"G5P9W)A -M9&4@8FEN"G5P9W)A9&4@8G-D"G5P9W)A9&4@8G5I;'1I;@IU<&=R861E(&-O -M;7!A=`IU<&=R861E(&-O;F8*=7!G<F%D92!I,S@V"G5P9W)A9&4@:3,X-F%T -M"G5P9W)A9&4@:3,X-F5X;`IU<&=R861E(&EN;&EN90IU<&=R861E(&ME<FX* -M=7!G<F%D92!M86-H"G5P9W)A9&4@;6%C:%]D96)U9PIU<&=R861E(&UA8VAI -M;F4*=7!G<F%D92!N970*=7!G<F%D92!N971I;7`*=7!G<F%D92!N971I;F5T -M"G5P9W)A9&4@;F5T;G,*=7!G<F%D92!R9G,*=7!G<F%D92!S<F,*=7!G<F%D -M92!S=&%N9&DS.#9A=`IU<&=R861E('-Y<PIU<&=R861E('-Y<U8*=7!G<F%D -M92!V;0H*<WEM;&EN:R!M86-H:6YE(&UA8V@O;6%C:&EN90IS>6UL:6YK('-T -M86YD:3,X-F%T+V)I;F%R:65S+WMB:6XL9&5V+&5T8RQT;7`L=7-R?0H*;VUI -M=&%N>2`J+F\@*BY"04L@*BY#2U`@*BYO;&0@*BYO<FEG("HN;F5W"FUE<R]M -M:6QL90IS>6UL:6YK(&=A;65S+VUO;F]P"G-Y;6QI;FL@9V%M97,O<"XO<W)C -M+DU)4T,O;&ES=``````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`U-2`@-#4V -M,#,V,#8V-R`@(#8U,#4`(``````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````=7!G<F%D92!;02U:72H*"F]M:71A;GD@*BY#2U`@*BY" -M04L@*BYA(&-O<F4*861E(&)U:6QT:6X*=7!G<F%D92!C;VUP870*=7!G<F%D -M92!C;VYF"G5P9W)A9&4@:3,X-@IU<&=R861E(&DS.#9A=`IU<&=R861E(&DS -M.#9E>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C -M:`IU<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@ -M;F5T"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE -M=&YS"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V -M870*=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI -M;FL@;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B -M:6YA<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN -M0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN -M:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N+W-R8RY-25-#+VAO<W0` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````("`@-C0T -M(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P-3$@("`V -M-#0V`"`````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`"XO<W)C+DU)4T,O<')E9FEX```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`Q -M-2`@-#4V,#,U-S,V-2`@(#<P,C0`(``````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````0D%312]U<W(O<W)C"BH*"F]M:71A;GD@*BY# -M2U`@*BY"04L@*BYA(&-O<F4*861E(&)U:6QT:6X*=7!G<F%D92!C;VUP870* -M=7!G<F%D92!C;VYF"G5P9W)A9&4@:3,X-@IU<&=R861E(&DS.#9A=`IU<&=R -M861E(&DS.#9E>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A -M9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P -M9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R -M861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A -M;F1I,S@V870*=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT* -M"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS -M.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@ -M*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4* -M<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N+W-R8RY-25-# -M+VQO9V9I;&4````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P -M,#$@("`W,3`U`"`````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````"XO<W)C+F)I;B\````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````@("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@ -M("`@("`@,"`@-#4V,#,V,3`V-"`@(#4U-C<`(``````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````+B]S<F,N8FEN+V-R>7!T```````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````"`@(#8T-"``("`R -M-#(W(``@("`V,S`@`"`@("`@("`@("`V("`T-38P,S4W,#`S("`@-C8U,@`@ -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````````!#4EE0 -M5`IS<B]S<F,**@H*;VUI=&%N>2`J+D-+4"`J+D)!2R`J+F$@8V]R90IA9&4@ -M8G5I;'1I;@IU<&=R861E(&-O;7!A=`IU<&=R861E(&-O;F8*=7!G<F%D92!I -M,S@V"G5P9W)A9&4@:3,X-F%T"G5P9W)A9&4@:3,X-F5X;`IU<&=R861E(&EN -M;&EN90IU<&=R861E(&ME<FX*=7!G<F%D92!M86-H"G5P9W)A9&4@;6%C:%]D -M96)U9PIU<&=R861E(&UA8VAI;F4*=7!G<F%D92!N970*=7!G<F%D92!N971I -M;7`*=7!G<F%D92!N971I;F5T"G5P9W)A9&4@;F5T;G,*=7!G<F%D92!R9G,* -M=7!G<F%D92!S<F,*=7!G<F%D92!S=&%N9&DS.#9A=`IU<&=R861E('-Y<PIU -M<&=R861E('-Y<U8*=7!G<F%D92!V;0H*<WEM;&EN:R!M86-H:6YE(&UA8V@O -M;6%C:&EN90IS>6UL:6YK('-T86YD:3,X-F%T+V)I;F%R:65S+WMB:6XL9&5V -M+&5T8RQT;7`L=7-R?0H*;VUI=&%N>2`J+F\@*BY"04L@*BY#2U`@*BYO;&0@ -M*BYO<FEG("HN;F5W"FUE<R]M:6QL90IS>6UL:6YK(&=A;65S+VUO;F]P"G-Y -M;6QI;FL@9V%M97,O<"XO<W)C+F)I;B]L:7-T```````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P -M(``@("`@("`@(#$Q-B`@-#4V,#,V,#8V,"`@(#8U,S$`(``````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````=7!G<F%D92`N"@IO;6ET -M86YY("HN0TM0("HN0D%+("HN82!C;W)E"@IS>6UL:6YK(&-S:"!M86ME"G-Y -M;6QI;FL@9'4N8R!T87(N8R`*92!C;VYF"G5P9W)A9&4@:3,X-@IU<&=R861E -M(&DS.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D -M92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D -M92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@ -M;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C -M"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6 -M"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM -M;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S -M<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE -M=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S -M+W`N+W-R8RYB:6XO:&]S=``````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@ -M(#`@(#0U-C`S-3<P-3(@("`V-#8T`"`````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````"XO<W)C+F)I;B]P<F5F:7@````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````@("`V-#0@`"`@,C0R-R`` -M("`@-C,P(``@("`@("`@("`R,2`@-#4V,#,U-S,V-R`@(#<P-#``(``````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````0D%312]U<W(O -M<W)C+V)I;@IY("HN0TM0("HN0D%+("HN82!C;W)E"@IS>6UL:6YK(&-S:"!M -M86ME"G-Y;6QI;FL@9'4N8R!T87(N8R`*92!C;VYF"G5P9W)A9&4@:3,X-@IU -M<&=R861E(&DS.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI;F4* -M=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B=6<* -M=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP"G5P -M9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P9W)A -M9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G<F%D -M92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA8VAI -M;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE=&,L -M=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I -M9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK -M(&=A;65S+W`N+W-R8RYB:6XO;&]G9FEL90`````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@ -M("`@("`@(#`@(#0U-C`S-3<P,#(@("`W,3(S`"`````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````"XO<W)C+F-C:2\````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````@("`W-34@`"`@ -M,C0R-R``("`@-C,P(``@("`@("`@("`@,"`@-#4V,#,V,3`V-"`@(#4U-34` -M(``````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````````+B]S -M<F,N8V-I+V-R>7!T```````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`V("`T -M-38P,S4W,#`T("`@-C8T,0`@```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````!#4EE05`IS<B]S<F,O8FEN"GD@*BY#2U`@*BY"04L@ -M*BYA(&-O<F4*"G-Y;6QI;FL@8W-H(&UA:V4*<WEM;&EN:R!D=2YC('1A<BYC -M(`IE(&-O;F8*=7!G<F%D92!I,S@V"G5P9W)A9&4@:3,X-F%T"G5P9W)A9&4@ -M:3,X-F5X;`IU<&=R861E(&EN;&EN90IU<&=R861E(&ME<FX*=7!G<F%D92!M -M86-H"G5P9W)A9&4@;6%C:%]D96)U9PIU<&=R861E(&UA8VAI;F4*=7!G<F%D -M92!N970*=7!G<F%D92!N971I;7`*=7!G<F%D92!N971I;F5T"G5P9W)A9&4@ -M;F5T;G,*=7!G<F%D92!R9G,*=7!G<F%D92!S<F,*=7!G<F%D92!S=&%N9&DS -M.#9A=`IU<&=R861E('-Y<PIU<&=R861E('-Y<U8*=7!G<F%D92!V;0H*<WEM -M;&EN:R!M86-H:6YE(&UA8V@O;6%C:&EN90IS>6UL:6YK('-T86YD:3,X-F%T -M+V)I;F%R:65S+WMB:6XL9&5V+&5T8RQT;7`L=7-R?0H*;VUI=&%N>2`J+F\@ -M*BY"04L@*BY#2U`@*BYO;&0@*BYO<FEG("HN;F5W"FUE<R]M:6QL90IS>6UL -M:6YK(&=A;65S+VUO;F]P"G-Y;6QI;FL@9V%M97,O<"XO<W)C+F-C:2]L:7-T -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````@("`V -M-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`U,"`@-#4V,#,V,#8U,"`@ -M(#8T-S,`(``````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````=7!G<F%D92`N"@IO;6ET86YY("HN0TM0("HN0D%+("HN82!C;W)E"@IS -M>6UL:6YK(&-S:"!M86ME"G-Y;6QI;FL@9'4N8R!T87(N8R`*92!C;VYF"G5P -M9W)A9&4@:3,X-@IU<&=R861E(&DS.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G -M<F%D92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E -M(&UA8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A -M9&4@;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A -M9&4@<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D -M92!S>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN -M92!M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][ -M8FEN+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0 -M("HN;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M -M;VYO<`IS>6UL:6YK(&=A;65S+W`N+W-R8RYC8VDO:&]S=``````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````("`@-C0T(``@(#(T,C<@ -M`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P-30@("`V-#4T`"`````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````"XO<W)C+F-C -M:2]P<F5F:7@````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`R,2`@-#4V,#,U -M-S,W,2`@(#<P,C$`(``````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````0D%312]U<W(O<W)C+V-C:0IY("HN0TM0("HN0D%+("HN82!C -M;W)E"@IS>6UL:6YK(&-S:"!M86ME"G-Y;6QI;FL@9'4N8R!T87(N8R`*92!C -M;VYF"G5P9W)A9&4@:3,X-@IU<&=R861E(&DS.#9A=`IU<&=R861E(&DS.#9E -M>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU -M<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T -M"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS -M"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870* -M=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@ -M;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA -M<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+ -M("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G -M86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N+W-R8RYC8VDO;&]G9FEL90`` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````("`@-C0T(``@ -M(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P,#,@("`W,3$R -M`"`````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````````````"XO -M<W)C+F1O8R\````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````@("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@,"`@ -M-#4V,#,V,3`V-"`@(#4U-C0`(``````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````+B]S<F,N9&]C+V-R>7!T```````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````"`@(#8T-"``("`R-#(W(``@("`V -M,S`@`"`@("`@("`@("`V("`T-38P,S4W,#`U("`@-C8U,0`@```````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````!#4EE05`IS<B]S<F,O -M8V-I"GD@*BY#2U`@*BY"04L@*BYA(&-O<F4*"G-Y;6QI;FL@8W-H(&UA:V4* -M<WEM;&EN:R!D=2YC('1A<BYC(`IE(&-O;F8*=7!G<F%D92!I,S@V"G5P9W)A -M9&4@:3,X-F%T"G5P9W)A9&4@:3,X-F5X;`IU<&=R861E(&EN;&EN90IU<&=R -M861E(&ME<FX*=7!G<F%D92!M86-H"G5P9W)A9&4@;6%C:%]D96)U9PIU<&=R -M861E(&UA8VAI;F4*=7!G<F%D92!N970*=7!G<F%D92!N971I;7`*=7!G<F%D -M92!N971I;F5T"G5P9W)A9&4@;F5T;G,*=7!G<F%D92!R9G,*=7!G<F%D92!S -M<F,*=7!G<F%D92!S=&%N9&DS.#9A=`IU<&=R861E('-Y<PIU<&=R861E('-Y -M<U8*=7!G<F%D92!V;0H*<WEM;&EN:R!M86-H:6YE(&UA8V@O;6%C:&EN90IS -M>6UL:6YK('-T86YD:3,X-F%T+V)I;F%R:65S+WMB:6XL9&5V+&5T8RQT;7`L -M=7-R?0H*;VUI=&%N>2`J+F\@*BY"04L@*BY#2U`@*BYO;&0@*BYO<FEG("HN -M;F5W"FUE<R]M:6QL90IS>6UL:6YK(&=A;65S+VUO;F]P"G-Y;6QI;FL@9V%M -M97,O<"XO<W)C+F1O8R]L:7-T```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@ -M("`U,"`@-#4V,#,V,#8T,"`@(#8U,#$`(``````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````=7!G<F%D92`N"@IO;6ET86YY("HN0TM0 -M("HN0D%+("HN82!C;W)E"@IS>6UL:6YK(&-S:"!M86ME"G-Y;6QI;FL@9'4N -M8R!T87(N8R`*92!C;VYF"G5P9W)A9&4@:3,X-@IU<&=R861E(&DS.#9A=`IU -M<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D92!K97)N"G5P -M9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE -M"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU -M<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@ -M<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@ -M=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N -M9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A -M;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL -M;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N+W-R8RYD -M;V,O:&]S=``````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S -M-3<P-34@("`V-#8T`"`````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````"XO<W)C+F1O8R]P<F5F:7@````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@ -M("`@("`@("`R,2`@-#4V,#,U-S,W,R`@(#<P,S(`(``````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````0D%312]U<W(O<W)C+V1O8PIY -M("HN0TM0("HN0D%+("HN82!C;W)E"@IS>6UL:6YK(&-S:"!M86ME"G-Y;6QI -M;FL@9'4N8R!T87(N8R`*92!C;VYF"G5P9W)A9&4@:3,X-@IU<&=R861E(&DS -M.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D92!K -M97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D92!M -M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@;F5T -M:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C"G5P -M9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6"G5P -M9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM;&EN -M:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S<GT* -M"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIM -M97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N -M+W-R8RYD;V,O;&]G9FEL90`````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@ -M(#0U-C`S-3<P,#0@("`W,3(R`"`````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````"XO<W)C+F5T8R\````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````@("`W-34@`"`@,C0R-R``("`@ -M-C,P(``@("`@("`@("`@,"`@-#4V,#,V,3`V-2`@(#4U-S,`(``````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````+B]S<F,N971C+V-R -M>7!T```````````````````````````````````````````````````````` -M`````````````````````````````````````````````````````````"`@ -M(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`V("`T-38P,S4W,#`U -M("`@-C8U-P`@```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````!#4EE05`IS<B]S<F,O9&]C"GD@*BY#2U`@*BY"04L@*BYA(&-O<F4* -M"G-Y;6QI;FL@8W-H(&UA:V4*<WEM;&EN:R!D=2YC('1A<BYC(`IE(&-O;F8* -M=7!G<F%D92!I,S@V"G5P9W)A9&4@:3,X-F%T"G5P9W)A9&4@:3,X-F5X;`IU -M<&=R861E(&EN;&EN90IU<&=R861E(&ME<FX*=7!G<F%D92!M86-H"G5P9W)A -M9&4@;6%C:%]D96)U9PIU<&=R861E(&UA8VAI;F4*=7!G<F%D92!N970*=7!G -M<F%D92!N971I;7`*=7!G<F%D92!N971I;F5T"G5P9W)A9&4@;F5T;G,*=7!G -M<F%D92!R9G,*=7!G<F%D92!S<F,*=7!G<F%D92!S=&%N9&DS.#9A=`IU<&=R -M861E('-Y<PIU<&=R861E('-Y<U8*=7!G<F%D92!V;0H*<WEM;&EN:R!M86-H -M:6YE(&UA8V@O;6%C:&EN90IS>6UL:6YK('-T86YD:3,X-F%T+V)I;F%R:65S -M+WMB:6XL9&5V+&5T8RQT;7`L=7-R?0H*;VUI=&%N>2`J+F\@*BY"04L@*BY# -M2U`@*BYO;&0@*BYO<FEG("HN;F5W"FUE<R]M:6QL90IS>6UL:6YK(&=A;65S -M+VUO;F]P"G-Y;6QI;FL@9V%M97,O<"XO<W)C+F5T8R]L:7-T```````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````@("`V-#0@`"`@,C0R -M-R``("`@-C,P(``@("`@("`@(#$U-"`@-#4V,#,V,#8R,B`@(#8U,S0`(``` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````=7!G<F%D -M92`N"@IO;6ET86YY("HN0TM0("HN0D%+("HN82!C;W)E"@IS>6UL:6YK(&9S -M8VL@<F5S=&]R90IS>6UL:6YK(&)A9'-E8W0N8R!D=6UP9G,N8R!I8VAE8VLN -M8R!M:W!R;W1O+F,*.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI -M;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B -M=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP -M"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P -M9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G -M<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA -M8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE -M=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN -M;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL -M:6YK(&=A;65S+W`N+W-R8RYE=&,O:&]S=``````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"`` -M("`@("`@("`@(#`@(#0U-C`S-3<P-3<@("`V-#<T`"`````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````"XO<W)C+F5T8R]P<F5F:7@` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````@("`V-#0@ -M`"`@,C0R-R``("`@-C,P(``@("`@("`@("`R,2`@-#4V,#,U-S,W-"`@(#<P -M-#$`(``````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M0D%312]U<W(O<W)C+V5T8PIY("HN0TM0("HN0D%+("HN82!C;W)E"@IS>6UL -M:6YK(&9S8VL@<F5S=&]R90IS>6UL:6YK(&)A9'-E8W0N8R!D=6UP9G,N8R!I -M8VAE8VLN8R!M:W!R;W1O+F,*.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D -M92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA -M8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@ -M;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@ -M<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S -M>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M -M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN -M+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN -M;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO -M<`IS>6UL:6YK(&=A;65S+W`N+W-R8RYE=&,O;&]G9FEL90`````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````("`@-C0T(``@(#(T,C<@`"`@ -M(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P,#4@("`W,3,Q`"`````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````"XO<W)C+F=A;65S -M+P`````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````@ -M("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@,"`@-#4V,#,V,3`V -M-2`@(#8Q,30`(``````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````+B]S<F,N9V%M97,O8W)Y<'0````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@ -M("`@("`V("`T-38P,S4W,#`V("`@-S(P,0`@```````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````!#4EE05`IS<B]S<F,O971C"GD@*BY# -M2U`@*BY"04L@*BYA(&-O<F4*"G-Y;6QI;FL@9G-C:R!R97-T;W)E"G-Y;6QI -M;FL@8F%D<V5C="YC(&1U;7!F<RYC(&EC:&5C:RYC(&UK<')O=&\N8PHX-F%T -M"G5P9W)A9&4@:3,X-F5X;`IU<&=R861E(&EN;&EN90IU<&=R861E(&ME<FX* -M=7!G<F%D92!M86-H"G5P9W)A9&4@;6%C:%]D96)U9PIU<&=R861E(&UA8VAI -M;F4*=7!G<F%D92!N970*=7!G<F%D92!N971I;7`*=7!G<F%D92!N971I;F5T -M"G5P9W)A9&4@;F5T;G,*=7!G<F%D92!R9G,*=7!G<F%D92!S<F,*=7!G<F%D -M92!S=&%N9&DS.#9A=`IU<&=R861E('-Y<PIU<&=R861E('-Y<U8*=7!G<F%D -M92!V;0H*<WEM;&EN:R!M86-H:6YE(&UA8V@O;6%C:&EN90IS>6UL:6YK('-T -M86YD:3,X-F%T+V)I;F%R:65S+WMB:6XL9&5V+&5T8RQT;7`L=7-R?0H*;VUI -M=&%N>2`J+F\@*BY"04L@*BY#2U`@*BYO;&0@*BYO<FEG("HN;F5W"FUE<R]M -M:6QL90IS>6UL:6YK(&=A;65S+VUO;F]P"G-Y;6QI;FL@9V%M97,O<"XO<W)C -M+F=A;65S+VQI<W0````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`U,"`@-#4V -M,#,V,#8Q,2`@(#<P,C8`(``````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````=7!G<F%D92`N"@IO;6ET86YY("HN0TM0("HN0D%+("HN -M82!C;W)E"@IS>6UL:6YK(&9S8VL@<F5S=&]R90IS>6UL:6YK(&)A9'-E8W0N -M8R!D=6UP9G,N8R!I8VAE8VLN8R!M:W!R;W1O+F,*.#9A=`IU<&=R861E(&DS -M.#9E>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C -M:`IU<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@ -M;F5T"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE -M=&YS"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V -M870*=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI -M;FL@;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B -M:6YA<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN -M0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN -M:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N+W-R8RYG86UE<R]H;W-T -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````("`@-C0T -M(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P-C`@("`W -M,#`W`"`````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`"XO<W)C+F=A;65S+W!R969I>``````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`R -M,R`@-#4V,#,U-S,W-B`@(#<S-C8`(``````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````0D%312]U<W(O<W)C+V=A;65S"BHN0TM0("HN -M0D%+("HN82!C;W)E"@IS>6UL:6YK(&9S8VL@<F5S=&]R90IS>6UL:6YK(&)A -M9'-E8W0N8R!D=6UP9G,N8R!I8VAE8VLN8R!M:W!R;W1O+F,*.#9A=`IU<&=R -M861E(&DS.#9E>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A -M9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P -M9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R -M861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A -M;F1I,S@V870*=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT* -M"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS -M.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@ -M*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4* -M<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N+W-R8RYG86UE -M<R]L;V=F:6QE```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P -M,#8@("`W-#4S`"`````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````"XO<W)C+F=N=2\````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````@("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@ -M("`@("`@,"`@-#4V,#,V,3`V-2`@(#4V,3$`(``````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````+B]S<F,N9VYU+V-R>7!T```````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````"`@(#8T-"``("`R -M-#(W(``@("`V,S`@`"`@("`@("`@("`V("`T-38P,S4W,#`W("`@-C8W-P`@ -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````````!#4EE0 -M5`IS<B]S<F,O9V%M97,**BY#2U`@*BY"04L@*BYA(&-O<F4*"G-Y;6QI;FL@ -M9G-C:R!R97-T;W)E"G-Y;6QI;FL@8F%D<V5C="YC(&1U;7!F<RYC(&EC:&5C -M:RYC(&UK<')O=&\N8PHX-F%T"G5P9W)A9&4@:3,X-F5X;`IU<&=R861E(&EN -M;&EN90IU<&=R861E(&ME<FX*=7!G<F%D92!M86-H"G5P9W)A9&4@;6%C:%]D -M96)U9PIU<&=R861E(&UA8VAI;F4*=7!G<F%D92!N970*=7!G<F%D92!N971I -M;7`*=7!G<F%D92!N971I;F5T"G5P9W)A9&4@;F5T;G,*=7!G<F%D92!R9G,* -M=7!G<F%D92!S<F,*=7!G<F%D92!S=&%N9&DS.#9A=`IU<&=R861E('-Y<PIU -M<&=R861E('-Y<U8*=7!G<F%D92!V;0H*<WEM;&EN:R!M86-H:6YE(&UA8V@O -M;6%C:&EN90IS>6UL:6YK('-T86YD:3,X-F%T+V)I;F%R:65S+WMB:6XL9&5V -M+&5T8RQT;7`L=7-R?0H*;VUI=&%N>2`J+F\@*BY"04L@*BY#2U`@*BYO;&0@ -M*BYO<FEG("HN;F5W"FUE<R]M:6QL90IS>6UL:6YK(&=A;65S+VUO;F]P"G-Y -M;6QI;FL@9V%M97,O<"XO<W)C+F=N=2]L:7-T```````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P -M(``@("`@("`@("`U,2`@-#4V,#,V,#8P,B`@(#8U,C0`(``````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````=7!G<F%D92`N"@IO;6ET -M86YY("HN0TM0("HN0D%+("HN82!C;W)E"@IS>6UL:6YK(&9S8VL@<F5S=&]R -M90IS>6UL:6YK(&)A9'-E8W0N8R!D=6UP9G,N8R!I8VAE8VLN8R!M:W!R;W1O -M+F,*.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D -M92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D -M92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@ -M;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C -M"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6 -M"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM -M;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S -M<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE -M=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S -M+W`N+W-R8RYG;G4O:&]S=``````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@ -M(#`@(#0U-C`S-3<P-C$@("`V-3`U`"`````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````"XO<W)C+F=N=2]P<F5F:7@````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````@("`V-#0@`"`@,C0R-R`` -M("`@-C,P(``@("`@("`@("`R,2`@-#4V,#,U-S0P,"`@(#<P-#4`(``````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````0D%312]U<W(O -M<W)C+V=N=0IY("HN0TM0("HN0D%+("HN82!C;W)E"@IS>6UL:6YK(&9S8VL@ -M<F5S=&]R90IS>6UL:6YK(&)A9'-E8W0N8R!D=6UP9G,N8R!I8VAE8VLN8R!M -M:W!R;W1O+F,*.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI;F4* -M=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B=6<* -M=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP"G5P -M9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P9W)A -M9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G<F%D -M92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA8VAI -M;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE=&,L -M=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I -M9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK -M(&=A;65S+W`N+W-R8RYG;G4O;&]G9FEL90`````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@ -M("`@("`@(#`@(#0U-C`S-3<P,#<@("`W,34Q`"`````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````"XO<W)C+FEN8VQU9&4O```````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````@("`W-34@`"`@ -M,C0R-R``("`@-C,P(``@("`@("`@("`@,"`@-#4V,#,V,3`V-2`@(#8T-#,` -M(``````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````````+B]S -M<F,N:6YC;'5D92]C<GEP=``````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`V("`T -M-38P,S4W,#$P("`@-S4R,P`@```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````!#4EE05`IS<B]S<F,O9VYU"GD@*BY#2U`@*BY"04L@ -M*BYA(&-O<F4*"G-Y;6QI;FL@9G-C:R!R97-T;W)E"G-Y;6QI;FL@8F%D<V5C -M="YC(&1U;7!F<RYC(&EC:&5C:RYC(&UK<')O=&\N8PHX-F%T"G5P9W)A9&4@ -M:3,X-F5X;`IU<&=R861E(&EN;&EN90IU<&=R861E(&ME<FX*=7!G<F%D92!M -M86-H"G5P9W)A9&4@;6%C:%]D96)U9PIU<&=R861E(&UA8VAI;F4*=7!G<F%D -M92!N970*=7!G<F%D92!N971I;7`*=7!G<F%D92!N971I;F5T"G5P9W)A9&4@ -M;F5T;G,*=7!G<F%D92!R9G,*=7!G<F%D92!S<F,*=7!G<F%D92!S=&%N9&DS -M.#9A=`IU<&=R861E('-Y<PIU<&=R861E('-Y<U8*=7!G<F%D92!V;0H*<WEM -M;&EN:R!M86-H:6YE(&UA8V@O;6%C:&EN90IS>6UL:6YK('-T86YD:3,X-F%T -M+V)I;F%R:65S+WMB:6XL9&5V+&5T8RQT;7`L=7-R?0H*;VUI=&%N>2`J+F\@ -M*BY"04L@*BY#2U`@*BYO;&0@*BYO<FEG("HN;F5W"FUE<R]M:6QL90IS>6UL -M:6YK(&=A;65S+VUO;F]P"G-Y;6QI;FL@9V%M97,O<"XO<W)C+FEN8VQU9&4O -M;&ES=``````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````@("`V -M-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`U,"`@-#4V,#,V,#4W,R`@ -M(#<S-C0`(``````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````=7!G<F%D92`N"@IO;6ET86YY("HN0TM0("HN0D%+("HN82!C;W)E"@IS -M>6UL:6YK(&9S8VL@<F5S=&]R90IS>6UL:6YK(&)A9'-E8W0N8R!D=6UP9G,N -M8R!I8VAE8VLN8R!M:W!R;W1O+F,*.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G -M<F%D92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E -M(&UA8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A -M9&4@;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A -M9&4@<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D -M92!S>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN -M92!M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][ -M8FEN+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0 -M("HN;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M -M;VYO<`IS>6UL:6YK(&=A;65S+W`N+W-R8RYI;F-L=61E+VAO<W0````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````("`@-C0T(``@(#(T,C<@ -M`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P-C(@("`W,S0P`"`````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````"XO<W)C+FEN -M8VQU9&4O<')E9FEX```````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`R-2`@-#4V,#,U -M-S0P,2`@(#<W,#0`(``````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````0D%312]U<W(O<W)C+VEN8VQU9&4*0TM0("HN0D%+("HN82!C -M;W)E"@IS>6UL:6YK(&9S8VL@<F5S=&]R90IS>6UL:6YK(&)A9'-E8W0N8R!D -M=6UP9G,N8R!I8VAE8VLN8R!M:W!R;W1O+F,*.#9A=`IU<&=R861E(&DS.#9E -M>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU -M<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T -M"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS -M"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870* -M=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@ -M;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA -M<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+ -M("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G -M86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N+W-R8RYI;F-L=61E+VQO9V9I -M;&4````````````````````````````````````````````````````````` -M````````````````````````````````````````````````("`@-C0T(``@ -M(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P,#<@(#$P,#`S -M`"`````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````````````"XO -M<W)C+FQI8B\````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````@("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@,"`@ -M-#4V,#,V,3`V-B`@(#4U-C<`(``````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````+B]S<F,N;&EB+V-R>7!T```````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````"`@(#8T-"``("`R-#(W(``@("`V -M,S`@`"`@("`@("`@("`V("`T-38P,S4W,#$Q("`@-C8T-P`@```````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````!#4EE05`IS<B]S<F,O -M:6YC;'5D90I#2U`@*BY"04L@*BYA(&-O<F4*"G-Y;6QI;FL@9G-C:R!R97-T -M;W)E"G-Y;6QI;FL@8F%D<V5C="YC(&1U;7!F<RYC(&EC:&5C:RYC(&UK<')O -M=&\N8PHX-F%T"G5P9W)A9&4@:3,X-F5X;`IU<&=R861E(&EN;&EN90IU<&=R -M861E(&ME<FX*=7!G<F%D92!M86-H"G5P9W)A9&4@;6%C:%]D96)U9PIU<&=R -M861E(&UA8VAI;F4*=7!G<F%D92!N970*=7!G<F%D92!N971I;7`*=7!G<F%D -M92!N971I;F5T"G5P9W)A9&4@;F5T;G,*=7!G<F%D92!R9G,*=7!G<F%D92!S -M<F,*=7!G<F%D92!S=&%N9&DS.#9A=`IU<&=R861E('-Y<PIU<&=R861E('-Y -M<U8*=7!G<F%D92!V;0H*<WEM;&EN:R!M86-H:6YE(&UA8V@O;6%C:&EN90IS -M>6UL:6YK('-T86YD:3,X-F%T+V)I;F%R:65S+WMB:6XL9&5V+&5T8RQT;7`L -M=7-R?0H*;VUI=&%N>2`J+F\@*BY"04L@*BY#2U`@*BYO;&0@*BYO<FEG("HN -M;F5W"FUE<R]M:6QL90IS>6UL:6YK(&=A;65S+VUO;F]P"G-Y;6QI;FL@9V%M -M97,O<"XO<W)C+FQI8B]L:7-T```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@ -M(#$Q,2`@-#4V,#,V,#4V,R`@(#8U,C0`(``````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````=7!G<F%D92`N"@IO;6ET(&]L9%]C;VUP -M:6QE<@H*;VUI=&%N>2`J+D-+4"`J+D)!2R`J+F$@8V]R90H*<WEM;&EN:R!C -M<'`*"G-E8W0N8R!D=6UP9G,N8R!I8VAE8VLN8R!M:W!R;W1O+F,*.#9A=`IU -M<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D92!K97)N"G5P -M9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE -M"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU -M<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@ -M<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@ -M=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N -M9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A -M;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL -M;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N+W-R8RYL -M:6(O:&]S=``````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S -M-3<P-C0@("`V-#8U`"`````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````"XO<W)C+FQI8B]P<F5F:7@````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@ -M("`@("`@("`R,2`@-#4V,#,U-S0P,R`@(#<P,C4`(``````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````0D%312]U<W(O<W)C+VQI8@IL -M9%]C;VUP:6QE<@H*;VUI=&%N>2`J+D-+4"`J+D)!2R`J+F$@8V]R90H*<WEM -M;&EN:R!C<'`*"G-E8W0N8R!D=6UP9G,N8R!I8VAE8VLN8R!M:W!R;W1O+F,* -M.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI;F4*=7!G<F%D92!K -M97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B=6<*=7!G<F%D92!M -M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP"G5P9W)A9&4@;F5T -M:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P9W)A9&4@<W)C"G5P -M9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G<F%D92!S>7-6"G5P -M9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA8VAI;F4*<WEM;&EN -M:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE=&,L=&UP+'5S<GT* -M"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN;W)I9R`J+FYE=PIM -M97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL:6YK(&=A;65S+W`N -M+W-R8RYL:6(O;&]G9FEL90`````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@ -M(#0U-C`S-3<P,3`@("`W,3(P`"`````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````"XO<W)C+FQO8V%L+P`````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````@("`W-34@`"`@,C0R-R``("`@ -M-C,P(``@("`@("`@("`@,"`@-#4V,#,V,3`V-B`@(#8Q,3,`(``````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````+B]S<F,N;&]C86PO -M8W)Y<'0````````````````````````````````````````````````````` -M`````````````````````````````````````````````````````````"`@ -M(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`V("`T-38P,S4W,#$Q -M("`@-S$W,P`@```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````!#4EE05`IS<B]S<F,O;&EB"FQD7V-O;7!I;&5R"@IO;6ET86YY("HN -M0TM0("HN0D%+("HN82!C;W)E"@IS>6UL:6YK(&-P<`H*<V5C="YC(&1U;7!F -M<RYC(&EC:&5C:RYC(&UK<')O=&\N8PHX-F%T"G5P9W)A9&4@:3,X-F5X;`IU -M<&=R861E(&EN;&EN90IU<&=R861E(&ME<FX*=7!G<F%D92!M86-H"G5P9W)A -M9&4@;6%C:%]D96)U9PIU<&=R861E(&UA8VAI;F4*=7!G<F%D92!N970*=7!G -M<F%D92!N971I;7`*=7!G<F%D92!N971I;F5T"G5P9W)A9&4@;F5T;G,*=7!G -M<F%D92!R9G,*=7!G<F%D92!S<F,*=7!G<F%D92!S=&%N9&DS.#9A=`IU<&=R -M861E('-Y<PIU<&=R861E('-Y<U8*=7!G<F%D92!V;0H*<WEM;&EN:R!M86-H -M:6YE(&UA8V@O;6%C:&EN90IS>6UL:6YK('-T86YD:3,X-F%T+V)I;F%R:65S -M+WMB:6XL9&5V+&5T8RQT;7`L=7-R?0H*;VUI=&%N>2`J+F\@*BY"04L@*BY# -M2U`@*BYO;&0@*BYO<FEG("HN;F5W"FUE<R]M:6QL90IS>6UL:6YK(&=A;65S -M+VUO;F]P"G-Y;6QI;FL@9V%M97,O<"XO<W)C+FQO8V%L+VQI<W0````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````@("`V-#0@`"`@,C0R -M-R``("`@-C,P(``@("`@("`@("`U,"`@-#4V,#,V,#4U,2`@(#<P,C<`(``` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````=7!G<F%D -M92`N"@IO;6ET86YY("HN0TM0("HN0D%+("HN82!C;W)E"D-+4"`J+D)!2R`J -M+F$@8V]R90H*<WEM;&EN:R!C<'`*"G-E8W0N8R!D=6UP9G,N8R!I8VAE8VLN -M8R!M:W!R;W1O+F,*.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D92!I;FQI -M;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA8VA?9&5B -M=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@;F5T:6UP -M"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@<F9S"G5P -M9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S>7,*=7!G -M<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M86-H+VUA -M8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN+&1E=BQE -M=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN;VQD("HN -M;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO<`IS>6UL -M:6YK(&=A;65S+W`N+W-R8RYL;V-A;"]H;W-T```````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"`` -M("`@("`@("`@(#`@(#0U-C`S-3<P-C4@("`W,#$R`"`````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````"XO<W)C+FQO8V%L+W!R969I -M>``````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````@("`V-#0@ -M`"`@,C0R-R``("`@-C,P(``@("`@("`@("`R,R`@-#4V,#,U-S0P-2`@(#<S -M-34`(``````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M0D%312]U<W(O<W)C+VQO8V%L"BHN0TM0("HN0D%+("HN82!C;W)E"D-+4"`J -M+D)!2R`J+F$@8V]R90H*<WEM;&EN:R!C<'`*"G-E8W0N8R!D=6UP9G,N8R!I -M8VAE8VLN8R!M:W!R;W1O+F,*.#9A=`IU<&=R861E(&DS.#9E>&P*=7!G<F%D -M92!I;FQI;F4*=7!G<F%D92!K97)N"G5P9W)A9&4@;6%C:`IU<&=R861E(&UA -M8VA?9&5B=6<*=7!G<F%D92!M86-H:6YE"G5P9W)A9&4@;F5T"G5P9W)A9&4@ -M;F5T:6UP"G5P9W)A9&4@;F5T:6YE=`IU<&=R861E(&YE=&YS"G5P9W)A9&4@ -M<F9S"G5P9W)A9&4@<W)C"G5P9W)A9&4@<W1A;F1I,S@V870*=7!G<F%D92!S -M>7,*=7!G<F%D92!S>7-6"G5P9W)A9&4@=FT*"G-Y;6QI;FL@;6%C:&EN92!M -M86-H+VUA8VAI;F4*<WEM;&EN:R!S=&%N9&DS.#9A="]B:6YA<FEE<R][8FEN -M+&1E=BQE=&,L=&UP+'5S<GT*"F]M:71A;GD@*BYO("HN0D%+("HN0TM0("HN -M;VQD("HN;W)I9R`J+FYE=PIM97,O;6EL;&4*<WEM;&EN:R!G86UE<R]M;VYO -M<`IS>6UL:6YK(&=A;65S+W`N+W-R8RYL;V-A;"]L;V=F:6QE```````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````("`@-C0T(``@(#(T,C<@`"`@ -M(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P,3$@("`W-#0U`"`````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````"XO3D]415,````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````@ -M("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@-#$R,R`@-#4V,#0W,#`U -M-2`@(#4Q,S(`(``````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````22!A;2!P<F]V:61I;F<@82!S:V5L971A;"!S970@;V8@8V]N=')O -M;"!F:6QE<R!T:&%T('EO=2!C;W5L9"!U<V4@=&\@86QL;W<*82!C;&EE;G0@ -M=&\@(G-U<"(@(&9R;VT@82!L;V-A;"!R97!O<VET;W)Y+B`@66]U('-H;W5L -M9"!R96%D('1H92!S=7`@;6%N=6%L"G!A9V4@86YD(&1E8VED92!H;W<@<W5P -M('=O<FMS+@H*26X@82!T>7!I8V%L(&1I<F5C=&]R>2P@<V%Y('-R8RYL:6(L -M('EO=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN9R!F:6QE<SH*"6QO9V9I;&4* -M"6AO<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0*"E1H92!L;V=F:6QE('=I;&P@ -M<F5C;W)D('1H92!A9&1R97-S(&%N9"!D871E(&]F(&AO<W1S(&1R87=I;F<@ -M9&%T82!F<F]M('1H90IR97!O<VET;W)Y+B`@268@:70@9&]E<R!N;W0@97AI -M<W0L('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I<R!N;W0@;&]G9V5D+@H*5&AE -M(&AO<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M97,@;V8@:&]S=',@=&AA="!A -M<F4@86QL;W=E9"!T;R!R97%U97-T(&1A=&$N"DEF('1H92!F:6QE(&1O97,@ -M;F]T(&5X:7-T+"!T:&5N(&%N>2!H;W-T('1H870@:VYO=W,@=&AE(&-R>7!T -M(&UA>2!R97%U97-T"F1A=&$N("!!9G1E<B!T:&4@:&]S=&YA;64L('EO=2!M -M87D@<W!E8VEF>2!A('!A<W-W;W)D('1H870@;75S="!B92!U<V5D(&)Y"G1H -M92!H;W-T(&EN(')E<75E<W1I;F<@9&%T82X*"E1H92!C<GEP="!I<R!T:&4@ -M<&%S<W=O<F0@=&AA="!T:&4@8VQI96YT(&UU<W0@<W!E8VEF>2!I;B!A<R!T -M:&4@8W)Y<'0]"F9I96QD(&]F(&ET<R!C;VYT<F]L(&9I;&4N("!4:&ES(&UA -M>2!B92!O=F5R<FED9&5N(&%S(&EN9&EC871E9"!A8F]V92!O;@IA('!E<B!H -M;W-T(&)A<VES+B`@22!H879E(&QE9G0@82!P;&%C96AO;&1E<B`B0U)94%0B -M(&EN('1H:7,@9FEL92X*"E1H92!P<F5F:7@@9FEL92!S<&5C:69I97,@=&AE -M('!A=&AN86UE(&]N('1H92!R97!O<VET;W)Y('1O(")C9"(@=&\@8F5F;W)E -M"FEN=&5R<')E='1I;F<@=&AE(")L:7-T(B!O9B!F:6QE<R!T;R!S=7!P;'DN -M("!!9V%I;BP@22!H879E(&QE9G0@82!R;W5G:`II;F1I8V%T:6]N(&]F('=H -M870@=&AE('!A=&@@<VAO=6QD(&)E+@H*3&%S=&QY+"!T:&4@;&ES="!F:6QE -M('-P96-I9FEE<R!W:&%T(&9I;&5S(')E;&%T:79E('1O('1H92!P<F5F:7@@ -M<VAO=6QD(&)E"G1R86YS9F5R960N("!4:&4@9&%T82!S=7!P;&EE9"!A<F4@ -M<')O8F%B;'D@8V]R<F5C="!F;W(@>6]U<B!S:71U871I;VXN"@I4;R!B92!A -M(&)I="!M;W)E(&-O;F-R971E+"!T:&4@<F5P;W-I=&]R>2!I<R!O;B!T:&4@ -M:&]S="!X,CDN;6%C:"YC<RYC;74N961U"F%T($--52X@(%1H92!R96QE=F%N -M="!F:6QE<R!A<F4@;&]C871E9"!U;F1E<B`O:3,X-BP@=VAI8V@@8F%S:6-A -M;&QY(&ES"G1H92!R;V]T(&9O<B!T:&4@23,X-B!F:6QE('-Y<W1E;2X@(%1H -M92!S;W5R8V5S(&%R92!A<R!E>'!E8W1E9"!I;@HO:3,X-B]U<W(O<W)C(&%N -M9"!K97)N96P@:6X@+VDS.#8O=7-R+W-R8R]S>7,N("!4:&4@8V]N=')O;"!F -M:6QE(&1I<F5C=&]R:65S"FQI=F4@=6YD97(@+VDS.#8O<W5P+B!3;R!T:&4@ -M<')E9FEX(&9I;&4@*&9O<B!S<F,N;&EB(%MI;B`O:3,X-B]S=7`O<W)C+FQI -M8ETI"G=O=6QD(&-O;G1A:6X@=&AE(&QI;F4Z"B]I,S@V+W5S<B]S<F,O;&EB -M"BA"05-%(&EN('1H92!P<F]T;W1Y<&4@9FEL92!W;W5L9"!B92`O:3,X-BXI -M"@I4:&4@;&EN92!I;B!T:&4@;&]C86Q?8VQI96YT(&-O;G1R;VP@9FEL92!T -M:&%T(')E<75E<W1S('1H:7,@8V]L;&5C=&EO;@IW;W5L9"!B90IS<F,N;&]C -M86P@(&AO<W0]>#(Y+FUA8V@N8W,N8VUU+F5D=2!H;W-T8F%S93TO:3,X-B!B -M87-E/2]U<W(O<W)C('!R969I>#UL:6(@8W)Y<'0]0U)94%0*07,@>6]U('-E -M92P@4T525D52(&ES('@R.2YM86-H+F-S+F-M=2YE9'4@86YD("]315)615)? -M0T].5%)/3%]$25)%0U1/4EE?0D%312`*:7,@+VDS.#8N("!B87-E/2]U<W(O -M<W)C('-A>7,@=&AA="!W92!S=&]R92!T:&4@8VQI96YT('-T871E(&9I;&5S -M(&EN"B]U<W(O<W)C(&%N9"!T:&4@<')E9FEX/6QI8B!M96%N<R!T:&%T('1H -M92!D871A(&9I;&5S(&%R92!R;V]T960@870@=&AE"F1I<F5C=&]R>2!L:6(@ -M<F5L871I=F4@=&\@=&AE(&)A<V4N"@`````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`"XO<W)C+FUA;B\````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````@("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@ -M,"`@-#4V,#,V,3`V-B`@(#4U-S0`(``````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````+B]S<F,N;6%N+V-R>7!T```````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````"`@(#8T-"``("`R-#(W(``@ -M("`V,S`@`"`@("`@("`@("`V("`T-38P,S4W,#$S("`@-C8U-@`@```````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````!#4EE05`IR;W9I -M9&EN9R!A('-K96QE=&%L('-E="!O9B!C;VYT<F]L(&9I;&5S('1H870@>6]U -M(&-O=6QD('5S92!T;R!A;&QO=PIA(&-L:65N="!T;R`B<W5P(B`@9G)O;2!A -M(&QO8V%L(')E<&]S:71O<GDN("!9;W4@<VAO=6QD(')E860@=&AE('-U<"!M -M86YU86P*<&%G92!A;F0@9&5C:61E(&AO=R!S=7`@=V]R:W,N"@I);B!A('1Y -M<&EC86P@9&ER96-T;W)Y+"!S87D@<W)C+FQI8BP@>6]U('=I;&P@9FEN9"!T -M:&4@9F]L;&]W:6YG(&9I;&5S.@H);&]G9FEL90H):&]S=`H)8W)Y<'0*"7!R -M969I>`H);&ES=`H*5&AE(&QO9V9I;&4@=VEL;"!R96-O<F0@=&AE(&%D9')E -M<W,@86YD(&1A=&4@;V8@:&]S=',@9')A=VEN9R!D871A(&9R;VT@=&AE"G)E -M<&]S:71O<GDN("!)9B!I="!D;V5S(&YO="!E>&ES="P@=&AE;B!T:&ES(&EN -M9F]R;6%T:6]N(&ES(&YO="!L;V=G960N"@I4:&4@:&]S="!F:6QE(&-O;G1A -M:6YS('1H92!N86UE<R!O9B!H;W-T<R!T:&%T(&%R92!A;&QO=V5D('1O(')E -M<75E<W0@9"XO<W)C+FUA;B]L:7-T```````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@ -M("`@("`U,"`@-#4V,#,V,#4Q-2`@(#8U,3``(``````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````=7!G<F%D92`N"@IO;6ET86YY("HN -M0TM0("HN0D%+("HN82!C;W)E"B!F:6QE<R!T:&%T('EO=2!C;W5L9"!U<V4@ -M=&\@86QL;W<*82!C;&EE;G0@=&\@(G-U<"(@(&9R;VT@82!L;V-A;"!R97!O -M<VET;W)Y+B`@66]U('-H;W5L9"!R96%D('1H92!S=7`@;6%N=6%L"G!A9V4@ -M86YD(&1E8VED92!H;W<@<W5P('=O<FMS+@H*26X@82!T>7!I8V%L(&1I<F5C -M=&]R>2P@<V%Y('-R8RYL:6(L('EO=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN -M9R!F:6QE<SH*"6QO9V9I;&4*"6AO<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0* -M"E1H92!L;V=F:6QE('=I;&P@<F5C;W)D('1H92!A9&1R97-S(&%N9"!D871E -M(&]F(&AO<W1S(&1R87=I;F<@9&%T82!F<F]M('1H90IR97!O<VET;W)Y+B`@ -M268@:70@9&]E<R!N;W0@97AI<W0L('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I -M<R!N;W0@;&]G9V5D+@H*5&AE(&AO<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M -M97,@;V8@:&]S=',@=&AA="!A<F4@86QL;W=E9"!T;R!R97%U97-T(&0N+W-R -M8RYM86XO:&]S=``````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U -M-C`S-3<P-C8@("`V-#<T`"`````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````"XO<W)C+FUA;B]P<F5F:7@````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P -M(``@("`@("`@("`R,2`@-#4V,#,U-S0Q,B`@(#<P,S(`(``````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````0D%312]U<W(O<W)C+VUA -M;@IY("HN0TM0("HN0D%+("HN82!C;W)E"B!F:6QE<R!T:&%T('EO=2!C;W5L -M9"!U<V4@=&\@86QL;W<*82!C;&EE;G0@=&\@(G-U<"(@(&9R;VT@82!L;V-A -M;"!R97!O<VET;W)Y+B`@66]U('-H;W5L9"!R96%D('1H92!S=7`@;6%N=6%L -M"G!A9V4@86YD(&1E8VED92!H;W<@<W5P('=O<FMS+@H*26X@82!T>7!I8V%L -M(&1I<F5C=&]R>2P@<V%Y('-R8RYL:6(L('EO=2!W:6QL(&9I;F0@=&AE(&9O -M;&QO=VEN9R!F:6QE<SH*"6QO9V9I;&4*"6AO<W0*"6-R>7!T"@EP<F5F:7@* -M"6QI<W0*"E1H92!L;V=F:6QE('=I;&P@<F5C;W)D('1H92!A9&1R97-S(&%N -M9"!D871E(&]F(&AO<W1S(&1R87=I;F<@9&%T82!F<F]M('1H90IR97!O<VET -M;W)Y+B`@268@:70@9&]E<R!N;W0@97AI<W0L('1H96X@=&AI<R!I;F9O<FUA -M=&EO;B!I<R!N;W0@;&]G9V5D+@H*5&AE(&AO<W0@9FEL92!C;VYT86EN<R!T -M:&4@;F%M97,@;V8@:&]S=',@=&AA="!A<F4@86QL;W=E9"!T;R!R97%U97-T -M(&0N+W-R8RYM86XO;&]G9FEL90`````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@ -M(#`@(#0U-C`S-3<P,3,@("`W,3,P`"`````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````"XO<W)C+FYE=R\````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````@("`W-34@`"`@,C0R-R`` -M("`@-C,P(``@("`@("`@("`@,"`@-#4V,#,V,3`V-B`@(#4V,3(`(``````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````+B]S<F,N;F5W -M+V-R>7!T```````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`V("`T-38P,S4W -M,#$T("`@-C8W-0`@```````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````!#4EE05`IS<B]S<F,O;6%N"GD@*BY#2U`@*BY"04L@*BYA(&-O -M<F4*(&9I;&5S('1H870@>6]U(&-O=6QD('5S92!T;R!A;&QO=PIA(&-L:65N -M="!T;R`B<W5P(B`@9G)O;2!A(&QO8V%L(')E<&]S:71O<GDN("!9;W4@<VAO -M=6QD(')E860@=&AE('-U<"!M86YU86P*<&%G92!A;F0@9&5C:61E(&AO=R!S -M=7`@=V]R:W,N"@I);B!A('1Y<&EC86P@9&ER96-T;W)Y+"!S87D@<W)C+FQI -M8BP@>6]U('=I;&P@9FEN9"!T:&4@9F]L;&]W:6YG(&9I;&5S.@H);&]G9FEL -M90H):&]S=`H)8W)Y<'0*"7!R969I>`H);&ES=`H*5&AE(&QO9V9I;&4@=VEL -M;"!R96-O<F0@=&AE(&%D9')E<W,@86YD(&1A=&4@;V8@:&]S=',@9')A=VEN -M9R!D871A(&9R;VT@=&AE"G)E<&]S:71O<GDN("!)9B!I="!D;V5S(&YO="!E -M>&ES="P@=&AE;B!T:&ES(&EN9F]R;6%T:6]N(&ES(&YO="!L;V=G960N"@I4 -M:&4@:&]S="!F:6QE(&-O;G1A:6YS('1H92!N86UE<R!O9B!H;W-T<R!T:&%T -M(&%R92!A;&QO=V5D('1O(')E<75E<W0@9"XO<W)C+FYE=R]L:7-T```````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````@("`V-#0@`"`@ -M,C0R-R``("`@-C,P(``@("`@("`@("`U,"`@-#4V,#,V,#4P-2`@(#8U,C4` -M(``````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````````=7!G -M<F%D92`N"@IO;6ET86YY("HN0TM0("HN0D%+("HN82!C;W)E"B!F:6QE<R!T -M:&%T('EO=2!C;W5L9"!U<V4@=&\@86QL;W<*82!C;&EE;G0@=&\@(G-U<"(@ -M(&9R;VT@82!L;V-A;"!R97!O<VET;W)Y+B`@66]U('-H;W5L9"!R96%D('1H -M92!S=7`@;6%N=6%L"G!A9V4@86YD(&1E8VED92!H;W<@<W5P('=O<FMS+@H* -M26X@82!T>7!I8V%L(&1I<F5C=&]R>2P@<V%Y('-R8RYL:6(L('EO=2!W:6QL -M(&9I;F0@=&AE(&9O;&QO=VEN9R!F:6QE<SH*"6QO9V9I;&4*"6AO<W0*"6-R -M>7!T"@EP<F5F:7@*"6QI<W0*"E1H92!L;V=F:6QE('=I;&P@<F5C;W)D('1H -M92!A9&1R97-S(&%N9"!D871E(&]F(&AO<W1S(&1R87=I;F<@9&%T82!F<F]M -M('1H90IR97!O<VET;W)Y+B`@268@:70@9&]E<R!N;W0@97AI<W0L('1H96X@ -M=&AI<R!I;F9O<FUA=&EO;B!I<R!N;W0@;&]G9V5D+@H*5&AE(&AO<W0@9FEL -M92!C;VYT86EN<R!T:&4@;F%M97,@;V8@:&]S=',@=&AA="!A<F4@86QL;W=E -M9"!T;R!R97%U97-T(&0N+W-R8RYN97<O:&]S=``````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S -M,"``("`@("`@("`@(#`@(#0U-C`S-3<P-C<@("`V-3$S`"`````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````"XO<W)C+FYE=R]P<F5F -M:7@````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````@("`V -M-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`R,2`@-#4V,#,U-S0Q-"`@ -M(#<P-3(`(``````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````0D%312]U<W(O<W)C+VYE=PIY("HN0TM0("HN0D%+("HN82!C;W)E"B!F -M:6QE<R!T:&%T('EO=2!C;W5L9"!U<V4@=&\@86QL;W<*82!C;&EE;G0@=&\@ -M(G-U<"(@(&9R;VT@82!L;V-A;"!R97!O<VET;W)Y+B`@66]U('-H;W5L9"!R -M96%D('1H92!S=7`@;6%N=6%L"G!A9V4@86YD(&1E8VED92!H;W<@<W5P('=O -M<FMS+@H*26X@82!T>7!I8V%L(&1I<F5C=&]R>2P@<V%Y('-R8RYL:6(L('EO -M=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN9R!F:6QE<SH*"6QO9V9I;&4*"6AO -M<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0*"E1H92!L;V=F:6QE('=I;&P@<F5C -M;W)D('1H92!A9&1R97-S(&%N9"!D871E(&]F(&AO<W1S(&1R87=I;F<@9&%T -M82!F<F]M('1H90IR97!O<VET;W)Y+B`@268@:70@9&]E<R!N;W0@97AI<W0L -M('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I<R!N;W0@;&]G9V5D+@H*5&AE(&AO -M<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M97,@;V8@:&]S=',@=&AA="!A<F4@ -M86QL;W=E9"!T;R!R97%U97-T(&0N+W-R8RYN97<O;&]G9FEL90`````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````("`@-C0T(``@(#(T,C<@ -M`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P,3,@("`W,30V`"`````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````"XO<W)C+FYF -M<W1O;VQS+P`````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```@("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@,"`@-#4V,#,V -M,3`V-R`@(#8V-S$`(``````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````+B]S<F,N;F9S=&]O;',O8W)Y<'0````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@ -M("`@("`@("`V("`T-38P,S4W,#$U("`@-S<U-``@```````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````!#4EE05`IS<B]S<F,O;F5W"GD@ -M*BY#2U`@*BY"04L@*BYA(&-O<F4*(&9I;&5S('1H870@>6]U(&-O=6QD('5S -M92!T;R!A;&QO=PIA(&-L:65N="!T;R`B<W5P(B`@9G)O;2!A(&QO8V%L(')E -M<&]S:71O<GDN("!9;W4@<VAO=6QD(')E860@=&AE('-U<"!M86YU86P*<&%G -M92!A;F0@9&5C:61E(&AO=R!S=7`@=V]R:W,N"@I);B!A('1Y<&EC86P@9&ER -M96-T;W)Y+"!S87D@<W)C+FQI8BP@>6]U('=I;&P@9FEN9"!T:&4@9F]L;&]W -M:6YG(&9I;&5S.@H);&]G9FEL90H):&]S=`H)8W)Y<'0*"7!R969I>`H);&ES -M=`H*5&AE(&QO9V9I;&4@=VEL;"!R96-O<F0@=&AE(&%D9')E<W,@86YD(&1A -M=&4@;V8@:&]S=',@9')A=VEN9R!D871A(&9R;VT@=&AE"G)E<&]S:71O<GDN -M("!)9B!I="!D;V5S(&YO="!E>&ES="P@=&AE;B!T:&ES(&EN9F]R;6%T:6]N -M(&ES(&YO="!L;V=G960N"@I4:&4@:&]S="!F:6QE(&-O;G1A:6YS('1H92!N -M86UE<R!O9B!H;W-T<R!T:&%T(&%R92!A;&QO=V5D('1O(')E<75E<W0@9"XO -M<W)C+FYF<W1O;VQS+VQI<W0````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@(#(W-"`@ -M-#4V,#,V,#0W,2`@(#<V,S4`(``````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````=7!G<F%D92`N"@H*<WEM;&EN:R!+15).14Q?4T]5 -M4D-%4PIS>6UL:6YK(&EN8VQU9&4O;6%C:"!I;F-L=61E+VUA8VAI;F4@:6YC -M;'5D92]N970@:6YC;'5D92]N971I;F5T(&EN8VQU9&4O=F9S"G-Y;6QI;FL@ -M:6YC;'5D92]E<G)N;RYH(&EN8VQU9&4O<VEG;F%L+F@@:6YC;'5D92]S>7-C -M86QL+F@@:6YC;'5D92]S>7-L;V<N:`IT>7!I8V%L(&1I<F5C=&]R>2P@<V%Y -M('-R8RYL:6(L('EO=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN9R!F:6QE<SH* -M"6QO9V9I;&4*"6AO<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0*"E1H92!L;V=F -M:6QE('=I;&P@<F5C;W)D('1H92!A9&1R97-S(&%N9"!D871E(&]F(&AO<W1S -M(&1R87=I;F<@9&%T82!F<F]M('1H90IR97!O<VET;W)Y+B`@268@:70@9&]E -M<R!N;W0@97AI<W0L('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I<R!N;W0@;&]G -M9V5D+@H*5&AE(&AO<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M97,@;V8@:&]S -M=',@=&AA="!A<F4@86QL;W=E9"!T;R!R97%U97-T(&0N+W-R8RYN9G-T;V]L -M<R]H;W-T```````````````````````````````````````````````````` -M````````````````````````````````````````````````````````("`@ -M-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P-S`@ -M("`W-38S`"`````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````"XO<W)C+FYF<W1O;VQS+W!R969I>``````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@ -M("`R-B`@-#4V,#,U-S0Q-R`@,3`Q-#``(``````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````0D%312]U<W(O<W)C+VYF<W1O;VQS"E). -M14Q?4T]54D-%4PIS>6UL:6YK(&EN8VQU9&4O;6%C:"!I;F-L=61E+VUA8VAI -M;F4@:6YC;'5D92]N970@:6YC;'5D92]N971I;F5T(&EN8VQU9&4O=F9S"G-Y -M;6QI;FL@:6YC;'5D92]E<G)N;RYH(&EN8VQU9&4O<VEG;F%L+F@@:6YC;'5D -M92]S>7-C86QL+F@@:6YC;'5D92]S>7-L;V<N:`IT>7!I8V%L(&1I<F5C=&]R -M>2P@<V%Y('-R8RYL:6(L('EO=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN9R!F -M:6QE<SH*"6QO9V9I;&4*"6AO<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0*"E1H -M92!L;V=F:6QE('=I;&P@<F5C;W)D('1H92!A9&1R97-S(&%N9"!D871E(&]F -M(&AO<W1S(&1R87=I;F<@9&%T82!F<F]M('1H90IR97!O<VET;W)Y+B`@268@ -M:70@9&]E<R!N;W0@97AI<W0L('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I<R!N -M;W0@;&]G9V5D+@H*5&AE(&AO<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M97,@ -M;V8@:&]S=',@=&AA="!A<F4@86QL;W=E9"!T;R!R97%U97-T(&0N+W-R8RYN -M9G-T;V]L<R]L;V=F:6QE```````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S -M-3<P,30@(#$P,C(U`"`````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````"XO<W)C+G1E<W1S+P`````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````@("`W-34@`"`@,C0R-R``("`@-C,P(``@ -M("`@("`@("`@,"`@-#4V,#,V,3`V-R`@(#8Q-C0`(``````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````+B]S<F,N=&5S=',O8W)Y<'0` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````"`@(#8T-"`` -M("`R-#(W(``@("`V,S`@`"`@("`@("`@("`V("`T-38P,S4W,#$U("`@-S(T -M-P`@```````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````````````!# -M4EE05`IS<B]S<F,O;F9S=&]O;',*4DY%3%]33U520T53"G-Y;6QI;FL@:6YC -M;'5D92]M86-H(&EN8VQU9&4O;6%C:&EN92!I;F-L=61E+VYE="!I;F-L=61E -M+VYE=&EN970@:6YC;'5D92]V9G,*<WEM;&EN:R!I;F-L=61E+V5R<FYO+F@@ -M:6YC;'5D92]S:6=N86PN:"!I;F-L=61E+W-Y<V-A;&PN:"!I;F-L=61E+W-Y -M<VQO9RYH"G1Y<&EC86P@9&ER96-T;W)Y+"!S87D@<W)C+FQI8BP@>6]U('=I -M;&P@9FEN9"!T:&4@9F]L;&]W:6YG(&9I;&5S.@H);&]G9FEL90H):&]S=`H) -M8W)Y<'0*"7!R969I>`H);&ES=`H*5&AE(&QO9V9I;&4@=VEL;"!R96-O<F0@ -M=&AE(&%D9')E<W,@86YD(&1A=&4@;V8@:&]S=',@9')A=VEN9R!D871A(&9R -M;VT@=&AE"G)E<&]S:71O<GDN("!)9B!I="!D;V5S(&YO="!E>&ES="P@=&AE -M;B!T:&ES(&EN9F]R;6%T:6]N(&ES(&YO="!L;V=G960N"@I4:&4@:&]S="!F -M:6QE(&-O;G1A:6YS('1H92!N86UE<R!O9B!H;W-T<R!T:&%T(&%R92!A;&QO -M=V5D('1O(')E<75E<W0@9"XO<W)C+G1E<W1S+VQI<W0````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````@("`V-#0@`"`@,C0R-R``("`@ -M-C,P(``@("`@("`@("`U,2`@-#4V,#,V,#0V,"`@(#<P-S<`(``````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````=7!G<F%D92`N"@IO -M;6ET86YY("HN0TM0("HN0D%+("HN82!C;W)E"@IK(&EN8VQU9&4O;6%C:"!I -M;F-L=61E+VUA8VAI;F4@:6YC;'5D92]N970@:6YC;'5D92]N971I;F5T(&EN -M8VQU9&4O=F9S"G-Y;6QI;FL@:6YC;'5D92]E<G)N;RYH(&EN8VQU9&4O<VEG -M;F%L+F@@:6YC;'5D92]S>7-C86QL+F@@:6YC;'5D92]S>7-L;V<N:`IT>7!I -M8V%L(&1I<F5C=&]R>2P@<V%Y('-R8RYL:6(L('EO=2!W:6QL(&9I;F0@=&AE -M(&9O;&QO=VEN9R!F:6QE<SH*"6QO9V9I;&4*"6AO<W0*"6-R>7!T"@EP<F5F -M:7@*"6QI<W0*"E1H92!L;V=F:6QE('=I;&P@<F5C;W)D('1H92!A9&1R97-S -M(&%N9"!D871E(&]F(&AO<W1S(&1R87=I;F<@9&%T82!F<F]M('1H90IR97!O -M<VET;W)Y+B`@268@:70@9&]E<R!N;W0@97AI<W0L('1H96X@=&AI<R!I;F9O -M<FUA=&EO;B!I<R!N;W0@;&]G9V5D+@H*5&AE(&AO<W0@9FEL92!C;VYT86EN -M<R!T:&4@;F%M97,@;V8@:&]S=',@=&AA="!A<F4@86QL;W=E9"!T;R!R97%U -M97-T(&0N+W-R8RYT97-T<R]H;W-T```````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@ -M("`@(#`@(#0U-C`S-3<P-S$@("`W,#4W`"`````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````"XO<W)C+G1E<W1S+W!R969I>``````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````@("`V-#0@`"`@,C0R -M-R``("`@-C,P(``@("`@("`@("`R,R`@-#4V,#,U-S0R,2`@(#<T,C,`(``` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````0D%312]U -M<W(O<W)C+W1E<W1S"BHN0TM0("HN0D%+("HN82!C;W)E"@IK(&EN8VQU9&4O -M;6%C:"!I;F-L=61E+VUA8VAI;F4@:6YC;'5D92]N970@:6YC;'5D92]N971I -M;F5T(&EN8VQU9&4O=F9S"G-Y;6QI;FL@:6YC;'5D92]E<G)N;RYH(&EN8VQU -M9&4O<VEG;F%L+F@@:6YC;'5D92]S>7-C86QL+F@@:6YC;'5D92]S>7-L;V<N -M:`IT>7!I8V%L(&1I<F5C=&]R>2P@<V%Y('-R8RYL:6(L('EO=2!W:6QL(&9I -M;F0@=&AE(&9O;&QO=VEN9R!F:6QE<SH*"6QO9V9I;&4*"6AO<W0*"6-R>7!T -M"@EP<F5F:7@*"6QI<W0*"E1H92!L;V=F:6QE('=I;&P@<F5C;W)D('1H92!A -M9&1R97-S(&%N9"!D871E(&]F(&AO<W1S(&1R87=I;F<@9&%T82!F<F]M('1H -M90IR97!O<VET;W)Y+B`@268@:70@9&]E<R!N;W0@97AI<W0L('1H96X@=&AI -M<R!I;F9O<FUA=&EO;B!I<R!N;W0@;&]G9V5D+@H*5&AE(&AO<W0@9FEL92!C -M;VYT86EN<R!T:&4@;F%M97,@;V8@:&]S=',@=&AA="!A<F4@86QL;W=E9"!T -M;R!R97%U97-T(&0N+W-R8RYT97-T<R]L;V=F:6QE```````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"`` -M("`@("`@("`@(#`@(#0U-C`S-3<P,34@("`W-3(Q`"`````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````"XO<W)C+G5C8B\````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````@("`W-34@ -M`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@,"`@-#4V,#,V,3`V-R`@(#4U -M-S,`(``````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M+B]S<F,N=6-B+V-R>7!T```````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`V -M("`T-38P,S4W,#$V("`@-C8U-P`@```````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````!#4EE05`IS<B]S<F,O=&5S=',**BY#2U`@*BY" -M04L@*BYA(&-O<F4*"FL@:6YC;'5D92]M86-H(&EN8VQU9&4O;6%C:&EN92!I -M;F-L=61E+VYE="!I;F-L=61E+VYE=&EN970@:6YC;'5D92]V9G,*<WEM;&EN -M:R!I;F-L=61E+V5R<FYO+F@@:6YC;'5D92]S:6=N86PN:"!I;F-L=61E+W-Y -M<V-A;&PN:"!I;F-L=61E+W-Y<VQO9RYH"G1Y<&EC86P@9&ER96-T;W)Y+"!S -M87D@<W)C+FQI8BP@>6]U('=I;&P@9FEN9"!T:&4@9F]L;&]W:6YG(&9I;&5S -M.@H);&]G9FEL90H):&]S=`H)8W)Y<'0*"7!R969I>`H);&ES=`H*5&AE(&QO -M9V9I;&4@=VEL;"!R96-O<F0@=&AE(&%D9')E<W,@86YD(&1A=&4@;V8@:&]S -M=',@9')A=VEN9R!D871A(&9R;VT@=&AE"G)E<&]S:71O<GDN("!)9B!I="!D -M;V5S(&YO="!E>&ES="P@=&AE;B!T:&ES(&EN9F]R;6%T:6]N(&ES(&YO="!L -M;V=G960N"@I4:&4@:&]S="!F:6QE(&-O;G1A:6YS('1H92!N86UE<R!O9B!H -M;W-T<R!T:&%T(&%R92!A;&QO=V5D('1O(')E<75E<W0@9"XO<W)C+G5C8B]L -M:7-T```````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````@ -M("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`W,B`@-#4V,#,V,#0U -M,2`@(#8U,3$`(``````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````=7!G<F%D92`N"@IO;6ET(&QI<W`@<&%S8V%L"@IO;6ET86YY("HN -M0TM0("HN0D%+("HN82!C;W)E"F-L=61E+VUA8VAI;F4@:6YC;'5D92]N970@ -M:6YC;'5D92]N971I;F5T(&EN8VQU9&4O=F9S"G-Y;6QI;FL@:6YC;'5D92]E -M<G)N;RYH(&EN8VQU9&4O<VEG;F%L+F@@:6YC;'5D92]S>7-C86QL+F@@:6YC -M;'5D92]S>7-L;V<N:`IT>7!I8V%L(&1I<F5C=&]R>2P@<V%Y('-R8RYL:6(L -M('EO=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN9R!F:6QE<SH*"6QO9V9I;&4* -M"6AO<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0*"E1H92!L;V=F:6QE('=I;&P@ -M<F5C;W)D('1H92!A9&1R97-S(&%N9"!D871E(&]F(&AO<W1S(&1R87=I;F<@ -M9&%T82!F<F]M('1H90IR97!O<VET;W)Y+B`@268@:70@9&]E<R!N;W0@97AI -M<W0L('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I<R!N;W0@;&]G9V5D+@H*5&AE -M(&AO<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M97,@;V8@:&]S=',@=&AA="!A -M<F4@86QL;W=E9"!T;R!R97%U97-T(&0N+W-R8RYU8V(O:&]S=``````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````("`@-C0T(``@(#(T -M,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P-S$@("`V-#8V`"`` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````````"XO<W)C -M+G5C8B]P<F5F:7@````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`R,2`@-#4V -M,#,U-S0R,R`@(#<P,S(`(``````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````0D%312]U<W(O<W)C+W5C8@II<W`@<&%S8V%L"@IO;6ET -M86YY("HN0TM0("HN0D%+("HN82!C;W)E"F-L=61E+VUA8VAI;F4@:6YC;'5D -M92]N970@:6YC;'5D92]N971I;F5T(&EN8VQU9&4O=F9S"G-Y;6QI;FL@:6YC -M;'5D92]E<G)N;RYH(&EN8VQU9&4O<VEG;F%L+F@@:6YC;'5D92]S>7-C86QL -M+F@@:6YC;'5D92]S>7-L;V<N:`IT>7!I8V%L(&1I<F5C=&]R>2P@<V%Y('-R -M8RYL:6(L('EO=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN9R!F:6QE<SH*"6QO -M9V9I;&4*"6AO<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0*"E1H92!L;V=F:6QE -M('=I;&P@<F5C;W)D('1H92!A9&1R97-S(&%N9"!D871E(&]F(&AO<W1S(&1R -M87=I;F<@9&%T82!F<F]M('1H90IR97!O<VET;W)Y+B`@268@:70@9&]E<R!N -M;W0@97AI<W0L('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I<R!N;W0@;&]G9V5D -M+@H*5&AE(&AO<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M97,@;V8@:&]S=',@ -M=&AA="!A<F4@86QL;W=E9"!T;R!R97%U97-T(&0N+W-R8RYU8V(O;&]G9FEL -M90`````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````("`@-C0T -M(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P,38@("`W -M,3,Q`"`````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`"XO<W)C+G5N9&]C+P`````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````@("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@ -M,"`@-#4V,#,V,3`V-R`@(#8Q,S(`(``````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````+B]S<F,N=6YD;V,O8W)Y<'0````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````"`@(#8T-"``("`R-#(W(``@ -M("`V,S`@`"`@("`@("`@("`V("`T-38P,S4W,#$W("`@-S(Q-P`@```````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````!#4EE05`IS<B]S -M<F,O=6-B"FES<"!P87-C86P*"F]M:71A;GD@*BY#2U`@*BY"04L@*BYA(&-O -M<F4*8VQU9&4O;6%C:&EN92!I;F-L=61E+VYE="!I;F-L=61E+VYE=&EN970@ -M:6YC;'5D92]V9G,*<WEM;&EN:R!I;F-L=61E+V5R<FYO+F@@:6YC;'5D92]S -M:6=N86PN:"!I;F-L=61E+W-Y<V-A;&PN:"!I;F-L=61E+W-Y<VQO9RYH"G1Y -M<&EC86P@9&ER96-T;W)Y+"!S87D@<W)C+FQI8BP@>6]U('=I;&P@9FEN9"!T -M:&4@9F]L;&]W:6YG(&9I;&5S.@H);&]G9FEL90H):&]S=`H)8W)Y<'0*"7!R -M969I>`H);&ES=`H*5&AE(&QO9V9I;&4@=VEL;"!R96-O<F0@=&AE(&%D9')E -M<W,@86YD(&1A=&4@;V8@:&]S=',@9')A=VEN9R!D871A(&9R;VT@=&AE"G)E -M<&]S:71O<GDN("!)9B!I="!D;V5S(&YO="!E>&ES="P@=&AE;B!T:&ES(&EN -M9F]R;6%T:6]N(&ES(&YO="!L;V=G960N"@I4:&4@:&]S="!F:6QE(&-O;G1A -M:6YS('1H92!N86UE<R!O9B!H;W-T<R!T:&%T(&%R92!A;&QO=V5D('1O(')E -M<75E<W0@9"XO<W)C+G5N9&]C+VQI<W0````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@ -M("`@("`U,"`@-#4V,#,V,#0S-"`@(#<P-#4`(``````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````=7!G<F%D92`N"@IO;6ET86YY("HN -M0TM0("HN0D%+("HN82!C;W)E"DM0("HN0D%+("HN82!C;W)E"F-L=61E+VUA -M8VAI;F4@:6YC;'5D92]N970@:6YC;'5D92]N971I;F5T(&EN8VQU9&4O=F9S -M"G-Y;6QI;FL@:6YC;'5D92]E<G)N;RYH(&EN8VQU9&4O<VEG;F%L+F@@:6YC -M;'5D92]S>7-C86QL+F@@:6YC;'5D92]S>7-L;V<N:`IT>7!I8V%L(&1I<F5C -M=&]R>2P@<V%Y('-R8RYL:6(L('EO=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN -M9R!F:6QE<SH*"6QO9V9I;&4*"6AO<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0* -M"E1H92!L;V=F:6QE('=I;&P@<F5C;W)D('1H92!A9&1R97-S(&%N9"!D871E -M(&]F(&AO<W1S(&1R87=I;F<@9&%T82!F<F]M('1H90IR97!O<VET;W)Y+B`@ -M268@:70@9&]E<R!N;W0@97AI<W0L('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I -M<R!N;W0@;&]G9V5D+@H*5&AE(&AO<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M -M97,@;V8@:&]S=',@=&AA="!A<F4@86QL;W=E9"!T;R!R97%U97-T(&0N+W-R -M8RYU;F1O8R]H;W-T```````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U -M-C`S-3<P-S(@("`W,#(V`"`````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````"XO<W)C+G5N9&]C+W!R969I>``````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P -M(``@("`@("`@("`R,R`@-#4V,#,U-S0R-2`@(#<S-S4`(``````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````0D%312]U<W(O<W)C+W5N -M9&]C"BHN0TM0("HN0D%+("HN82!C;W)E"DM0("HN0D%+("HN82!C;W)E"F-L -M=61E+VUA8VAI;F4@:6YC;'5D92]N970@:6YC;'5D92]N971I;F5T(&EN8VQU -M9&4O=F9S"G-Y;6QI;FL@:6YC;'5D92]E<G)N;RYH(&EN8VQU9&4O<VEG;F%L -M+F@@:6YC;'5D92]S>7-C86QL+F@@:6YC;'5D92]S>7-L;V<N:`IT>7!I8V%L -M(&1I<F5C=&]R>2P@<V%Y('-R8RYL:6(L('EO=2!W:6QL(&9I;F0@=&AE(&9O -M;&QO=VEN9R!F:6QE<SH*"6QO9V9I;&4*"6AO<W0*"6-R>7!T"@EP<F5F:7@* -M"6QI<W0*"E1H92!L;V=F:6QE('=I;&P@<F5C;W)D('1H92!A9&1R97-S(&%N -M9"!D871E(&]F(&AO<W1S(&1R87=I;F<@9&%T82!F<F]M('1H90IR97!O<VET -M;W)Y+B`@268@:70@9&]E<R!N;W0@97AI<W0L('1H96X@=&AI<R!I;F9O<FUA -M=&EO;B!I<R!N;W0@;&]G9V5D+@H*5&AE(&AO<W0@9FEL92!C;VYT86EN<R!T -M:&4@;F%M97,@;V8@:&]S=',@=&AA="!A<F4@86QL;W=E9"!T;R!R97%U97-T -M(&0N+W-R8RYU;F1O8R]L;V=F:6QE```````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@ -M(#`@(#0U-C`S-3<P,3<@("`W-#<Q`"`````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````"XO<W)C+G5S<BYB:6XO```````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````@("`W-34@`"`@,C0R-R`` -M("`@-C,P(``@("`@("`@("`@,"`@-#4V,#,V,3`V-R`@(#8T,#(`(``````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````+B]S<F,N=7-R -M+F)I;B]C<GEP=``````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`V("`T-38P,S4W -M,#(P("`@-S0V,0`@```````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````!#4EE05`IS<B]S<F,O=6YD;V,**BY#2U`@*BY"04L@*BYA(&-O -M<F4*2U`@*BY"04L@*BYA(&-O<F4*8VQU9&4O;6%C:&EN92!I;F-L=61E+VYE -M="!I;F-L=61E+VYE=&EN970@:6YC;'5D92]V9G,*<WEM;&EN:R!I;F-L=61E -M+V5R<FYO+F@@:6YC;'5D92]S:6=N86PN:"!I;F-L=61E+W-Y<V-A;&PN:"!I -M;F-L=61E+W-Y<VQO9RYH"G1Y<&EC86P@9&ER96-T;W)Y+"!S87D@<W)C+FQI -M8BP@>6]U('=I;&P@9FEN9"!T:&4@9F]L;&]W:6YG(&9I;&5S.@H);&]G9FEL -M90H):&]S=`H)8W)Y<'0*"7!R969I>`H);&ES=`H*5&AE(&QO9V9I;&4@=VEL -M;"!R96-O<F0@=&AE(&%D9')E<W,@86YD(&1A=&4@;V8@:&]S=',@9')A=VEN -M9R!D871A(&9R;VT@=&AE"G)E<&]S:71O<GDN("!)9B!I="!D;V5S(&YO="!E -M>&ES="P@=&AE;B!T:&ES(&EN9F]R;6%T:6]N(&ES(&YO="!L;V=G960N"@I4 -M:&4@:&]S="!F:6QE(&-O;G1A:6YS('1H92!N86UE<R!O9B!H;W-T<R!T:&%T -M(&%R92!A;&QO=V5D('1O(')E<75E<W0@9"XO<W)C+G5S<BYB:6XO;&ES=``` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````@("`V-#0@`"`@ -M,C0R-R``("`@-C,P(``@("`@("`@("`U,"`@-#4V,#,V,#0R,B`@(#<S,3(` -M(``````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````````=7!G -M<F%D92`N"@IO;6ET86YY("HN0TM0("HN0D%+("HN82!C;W)E"DM0("HN0D%+ -M("HN82!C;W)E"F-L=61E+VUA8VAI;F4@:6YC;'5D92]N970@:6YC;'5D92]N -M971I;F5T(&EN8VQU9&4O=F9S"G-Y;6QI;FL@:6YC;'5D92]E<G)N;RYH(&EN -M8VQU9&4O<VEG;F%L+F@@:6YC;'5D92]S>7-C86QL+F@@:6YC;'5D92]S>7-L -M;V<N:`IT>7!I8V%L(&1I<F5C=&]R>2P@<V%Y('-R8RYL:6(L('EO=2!W:6QL -M(&9I;F0@=&AE(&9O;&QO=VEN9R!F:6QE<SH*"6QO9V9I;&4*"6AO<W0*"6-R -M>7!T"@EP<F5F:7@*"6QI<W0*"E1H92!L;V=F:6QE('=I;&P@<F5C;W)D('1H -M92!A9&1R97-S(&%N9"!D871E(&]F(&AO<W1S(&1R87=I;F<@9&%T82!F<F]M -M('1H90IR97!O<VET;W)Y+B`@268@:70@9&]E<R!N;W0@97AI<W0L('1H96X@ -M=&AI<R!I;F9O<FUA=&EO;B!I<R!N;W0@;&]G9V5D+@H*5&AE(&AO<W0@9FEL -M92!C;VYT86EN<R!T:&4@;F%M97,@;V8@:&]S=',@=&AA="!A<F4@86QL;W=E -M9"!T;R!R97%U97-T(&0N+W-R8RYU<W(N8FEN+VAO<W0````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S -M,"``("`@("`@("`@(#`@(#0U-C`S-3<P-S,@("`W,C<W`"`````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````"XO<W)C+G5S<BYB:6XO -M<')E9FEX```````````````````````````````````````````````````` -M```````````````````````````````````````````````````````@("`V -M-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`R-2`@-#4V,#,U-S0R-R`@ -M(#<V-3$`(``````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````0D%312]U<W(O<W)C+W5S<BYB:6X*0TM0("HN0D%+("HN82!C;W)E"DM0 -M("HN0D%+("HN82!C;W)E"F-L=61E+VUA8VAI;F4@:6YC;'5D92]N970@:6YC -M;'5D92]N971I;F5T(&EN8VQU9&4O=F9S"G-Y;6QI;FL@:6YC;'5D92]E<G)N -M;RYH(&EN8VQU9&4O<VEG;F%L+F@@:6YC;'5D92]S>7-C86QL+F@@:6YC;'5D -M92]S>7-L;V<N:`IT>7!I8V%L(&1I<F5C=&]R>2P@<V%Y('-R8RYL:6(L('EO -M=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN9R!F:6QE<SH*"6QO9V9I;&4*"6AO -M<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0*"E1H92!L;V=F:6QE('=I;&P@<F5C -M;W)D('1H92!A9&1R97-S(&%N9"!D871E(&]F(&AO<W1S(&1R87=I;F<@9&%T -M82!F<F]M('1H90IR97!O<VET;W)Y+B`@268@:70@9&]E<R!N;W0@97AI<W0L -M('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I<R!N;W0@;&]G9V5D+@H*5&AE(&AO -M<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M97,@;V8@:&]S=',@=&AA="!A<F4@ -M86QL;W=E9"!T;R!R97%U97-T(&0N+W-R8RYU<W(N8FEN+VQO9V9I;&4````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````("`@-C0T(``@(#(T,C<@ -M`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P,3<@("`W-S0Q`"`````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````````"XO<W)C+G5S -M<BYL:6(O```````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```@("`W-34@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`@,"`@-#4V,#,V -M,3`W,"`@(#8S-S(`(``````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````+B]S<F,N=7-R+FQI8B]C<GEP=``````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@ -M("`@("`@("`V("`T-38P,S4W,#(Q("`@-S0V,``@```````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````!#4EE05`IS<B]S<F,O=7-R+F)I -M;@I#2U`@*BY"04L@*BYA(&-O<F4*2U`@*BY"04L@*BYA(&-O<F4*8VQU9&4O -M;6%C:&EN92!I;F-L=61E+VYE="!I;F-L=61E+VYE=&EN970@:6YC;'5D92]V -M9G,*<WEM;&EN:R!I;F-L=61E+V5R<FYO+F@@:6YC;'5D92]S:6=N86PN:"!I -M;F-L=61E+W-Y<V-A;&PN:"!I;F-L=61E+W-Y<VQO9RYH"G1Y<&EC86P@9&ER -M96-T;W)Y+"!S87D@<W)C+FQI8BP@>6]U('=I;&P@9FEN9"!T:&4@9F]L;&]W -M:6YG(&9I;&5S.@H);&]G9FEL90H):&]S=`H)8W)Y<'0*"7!R969I>`H);&ES -M=`H*5&AE(&QO9V9I;&4@=VEL;"!R96-O<F0@=&AE(&%D9')E<W,@86YD(&1A -M=&4@;V8@:&]S=',@9')A=VEN9R!D871A(&9R;VT@=&AE"G)E<&]S:71O<GDN -M("!)9B!I="!D;V5S(&YO="!E>&ES="P@=&AE;B!T:&ES(&EN9F]R;6%T:6]N -M(&ES(&YO="!L;V=G960N"@I4:&4@:&]S="!F:6QE(&-O;G1A:6YS('1H92!N -M86UE<R!O9B!H;W-T<R!T:&%T(&%R92!A;&QO=V5D('1O(')E<75E<W0@9"XO -M<W)C+G5S<BYL:6(O;&ES=``````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@("`U,"`@ -M-#4V,#,V,#0P-"`@(#<S,3``(``````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````=7!G<F%D92`N"@IO;6ET86YY("HN0TM0("HN0D%+ -M("HN82!C;W)E"DM0("HN0D%+("HN82!C;W)E"F-L=61E+VUA8VAI;F4@:6YC -M;'5D92]N970@:6YC;'5D92]N971I;F5T(&EN8VQU9&4O=F9S"G-Y;6QI;FL@ -M:6YC;'5D92]E<G)N;RYH(&EN8VQU9&4O<VEG;F%L+F@@:6YC;'5D92]S>7-C -M86QL+F@@:6YC;'5D92]S>7-L;V<N:`IT>7!I8V%L(&1I<F5C=&]R>2P@<V%Y -M('-R8RYL:6(L('EO=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN9R!F:6QE<SH* -M"6QO9V9I;&4*"6AO<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0*"E1H92!L;V=F -M:6QE('=I;&P@<F5C;W)D('1H92!A9&1R97-S(&%N9"!D871E(&]F(&AO<W1S -M(&1R87=I;F<@9&%T82!F<F]M('1H90IR97!O<VET;W)Y+B`@268@:70@9&]E -M<R!N;W0@97AI<W0L('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I<R!N;W0@;&]G -M9V5D+@H*5&AE(&AO<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M97,@;V8@:&]S -M=',@=&AA="!A<F4@86QL;W=E9"!T;R!R97%U97-T(&0N+W-R8RYU<W(N;&EB -M+VAO<W0````````````````````````````````````````````````````` -M````````````````````````````````````````````````````````("`@ -M-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S-3<P-S0@ -M("`W,C<V`"`````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````"XO<W)C+G5S<BYL:6(O<')E9FEX```````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````@("`V-#0@`"`@,C0R-R``("`@-C,P(``@("`@("`@ -M("`R-2`@-#4V,#,U-S0S,2`@(#<V-#(`(``````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````0D%312]U<W(O<W)C+W5S<BYL:6(*0TM0 -M("HN0D%+("HN82!C;W)E"DM0("HN0D%+("HN82!C;W)E"F-L=61E+VUA8VAI -M;F4@:6YC;'5D92]N970@:6YC;'5D92]N971I;F5T(&EN8VQU9&4O=F9S"G-Y -M;6QI;FL@:6YC;'5D92]E<G)N;RYH(&EN8VQU9&4O<VEG;F%L+F@@:6YC;'5D -M92]S>7-C86QL+F@@:6YC;'5D92]S>7-L;V<N:`IT>7!I8V%L(&1I<F5C=&]R -M>2P@<V%Y('-R8RYL:6(L('EO=2!W:6QL(&9I;F0@=&AE(&9O;&QO=VEN9R!F -M:6QE<SH*"6QO9V9I;&4*"6AO<W0*"6-R>7!T"@EP<F5F:7@*"6QI<W0*"E1H -M92!L;V=F:6QE('=I;&P@<F5C;W)D('1H92!A9&1R97-S(&%N9"!D871E(&]F -M(&AO<W1S(&1R87=I;F<@9&%T82!F<F]M('1H90IR97!O<VET;W)Y+B`@268@ -M:70@9&]E<R!N;W0@97AI<W0L('1H96X@=&AI<R!I;F9O<FUA=&EO;B!I<R!N -M;W0@;&]G9V5D+@H*5&AE(&AO<W0@9FEL92!C;VYT86EN<R!T:&4@;F%M97,@ -M;V8@:&]S=',@=&AA="!A<F4@86QL;W=E9"!T;R!R97%U97-T(&0N+W-R8RYU -M<W(N;&EB+VQO9V9I;&4````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@(#`@(#0U-C`S -M-3<P,C`@("`W-S,Q`"`````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````N -M+W-R8RYU<W(N;&EB+VQI<W0````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@("`@-3`@ -M(#0U-C`S-C`T,#0@("`W,S$P`"`````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````'5P9W)A9&4@+@H*;VUI=&%N>2`J+D-+4"`J+D)! -M2R`J+F$@8V]R90I+4"`J+D)!2R`J+F$@8V]R90IC;'5D92]M86-H:6YE(&EN -M8VQU9&4O;F5T(&EN8VQU9&4O;F5T:6YE="!I;F-L=61E+W9F<PIS>6UL:6YK -M(&EN8VQU9&4O97)R;F\N:"!I;F-L=61E+W-I9VYA;"YH(&EN8VQU9&4O<WES -M8V%L;"YH(&EN8VQU9&4O<WES;&]G+F@*='EP:6-A;"!D:7)E8W1O<GDL('-A -M>2!S<F,N;&EB+"!Y;W4@=VEL;"!F:6YD('1H92!F;VQL;W=I;F<@9FEL97,Z -M"@EL;V=F:6QE"@EH;W-T"@EC<GEP=`H)<')E9FEX"@EL:7-T"@I4:&4@;&]G -M9FEL92!W:6QL(')E8V]R9"!T:&4@861D<F5S<R!A;F0@9&%T92!O9B!H;W-T -M<R!D<F%W:6YG(&1A=&$@9G)O;2!T:&4*<F5P;W-I=&]R>2X@($EF(&ET(&1O -M97,@;F]T(&5X:7-T+"!T:&5N('1H:7,@:6YF;W)M871I;VX@:7,@;F]T(&QO -M9V=E9"X*"E1H92!H;W-T(&9I;&4@8V]N=&%I;G,@=&AE(&YA;65S(&]F(&AO -M<W1S('1H870@87)E(&%L;&]W960@=&\@<F5Q=65S="!D+B]S<F,N=7-R+FQI -M8B]H;W-T```````````````````````````````````````````````````` -M`````````````````````````````````````````````````````````"`@ -M(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`P("`T-38P,S4W,#<T -M("`@-S(W-@`@```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````N+W-R8RYU<W(N;&EB+W!R969I>``````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````("`@-C0T(``@(#(T,C<@`"`@(#8S,"``("`@("`@ -M("`@,C4@(#0U-C`S-3<T,S$@("`W-C0R`"`````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````$)!4T4O=7-R+W-R8R]U<W(N;&EB"D-+ -M4"`J+D)!2R`J+F$@8V]R90I+4"`J+D)!2R`J+F$@8V]R90IC;'5D92]M86-H -M:6YE(&EN8VQU9&4O;F5T(&EN8VQU9&4O;F5T:6YE="!I;F-L=61E+W9F<PIS -M>6UL:6YK(&EN8VQU9&4O97)R;F\N:"!I;F-L=61E+W-I9VYA;"YH(&EN8VQU -M9&4O<WES8V%L;"YH(&EN8VQU9&4O<WES;&]G+F@*='EP:6-A;"!D:7)E8W1O -M<GDL('-A>2!S<F,N;&EB+"!Y;W4@=VEL;"!F:6YD('1H92!F;VQL;W=I;F<@ -M9FEL97,Z"@EL;V=F:6QE"@EH;W-T"@EC<GEP=`H)<')E9FEX"@EL:7-T"@I4 -M:&4@;&]G9FEL92!W:6QL(')E8V]R9"!T:&4@861D<F5S<R!A;F0@9&%T92!O -M9B!H;W-T<R!D<F%W:6YG(&1A=&$@9G)O;2!T:&4*<F5P;W-I=&]R>2X@($EF -M(&ET(&1O97,@;F]T(&5X:7-T+"!T:&5N('1H:7,@:6YF;W)M871I;VX@:7,@ -M;F]T(&QO9V=E9"X*"E1H92!H;W-T(&9I;&4@8V]N=&%I;G,@=&AE(&YA;65S -M(&]F(&AO<W1S('1H870@87)E(&%L;&]W960@=&\@<F5Q=65S="!D+B]S<F,N -M=7-R+FQI8B]L;V=F:6QE```````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````"`@(#8T-"``("`R-#(W(``@("`V,S`@`"`@("`@("`@("`P("`T-38P -M,S4W,#(P("`@-S<S,0`@```````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -<```````````````````````````````````````` -` -end diff --git a/usr.sbin/sup/source/sup.doc b/usr.sbin/sup/source/sup.doc deleted file mode 100644 index 2c77cbe686cb..000000000000 --- a/usr.sbin/sup/source/sup.doc +++ /dev/null @@ -1,764 +0,0 @@ - - - - - - - - - - - - THE SUP SOFTWARE UPGRADE PROTOCOL - - - - - - - - - - - - - - - - - - - - - - - - Carnegie Mellon University - School of Computer Science - - Steven Shafer - Mary Thompson - - 8 September 1989 - - - - - - - - - - The SUP system is a set of programs for maintaining a set of files in -identical versions across a network of cooperating machines. It runs under the -Mach operating system. -1. Introduction - The SUP System is a set of programs that provide for collections of files to -be maintained in identical versions across a number of machines. These -programs are: - -SUP The "client" program, run by users or system maintainers, which - initiates the upgrade activity on a machine requesting the - latest version of a collection of files. SUP will normally be - run as a daemon, firing up once each night (week, etc.) to - upgrade the specified file collections. - -SUPFILESRV The "file server" program, a daemon that is run by the system - maintainer to service requests for files initiated by client - SUP programs. The file server runs on every machine used as a - "repository" of distributable versions of files. It runs - continuously and listens for network connection requests by - individual client processes; for each individual client - request, a process is forked to service that request. - -SUPSCAN The "file scanner" program, that may optionally be run - periodically to speed up execution of the file server. It - pre-compiles a list of files on the file system that match the - specifications for a given file collection so that the file - server need not do this during each upgrade of that collection. - The file scanner is normally used daily for very large file - collections that are upgraded by many clients each day; it is - not so useful for small file collections or for those that are - upgraded by only a few client machines per day. - - When SUP is run, the user designates the names of certain "file collections", -sets of files, that should be upgraded. All pre-defined system collections -have entries in the coll.host file that gives the name of the host will act as -the repository for that software collection. The file server on that machine -provides a list of the files included in the collection and which ones have -been changed since the last time this collection was upgraded from that client -machine; the client decides which of these files it needs to receive; and the -files are sent from the file server. In this way, files can be installed on -the repository machine once, and they will propagate to all machines upgrading -from that repository as soon as the respective users execute SUP to perform the -upgrade. This allows groups of cooperating users to establish sets of files -that can be relied upon to be the same across a set of host machines. - - SUP is intended to provide a broadcast facility for maintaining identical -versions of files across multiple machines. An alternative approach is to -provide a common file system; even when such a system is available, SUP is -useful for maintaining frequently used files on local disk storage, and for -maintaining files across the file server machines themselves. - - The SUP system does not address the issues of version control, nor of -maintaining compatibility of pieces of a system that are being independently -changed by different users or on different machines; what SUP provides is a -broadcast mechanism for issuing stable, reliable versions of software or data -files, produced by a small number of maintainers and needed by a larger number -of users. SUP is intended specifically to address these situations: - - - A large collection of system software prepared by a maintenance staff - for use by a large user community. For example, the CMU-CSD UNIX - software used by hundreds of workstations. In such situations, the - users know absolutely nothing about how to obtain such software, but - they need to keep it constantly upgraded on their machines. - Similarly, the maintainers cannot possibly maintain each user's - machine individually: they must rely on a broadcast mechanism such as - SUP. - - - A moderate collection of software and data files shared by the - members of a project. For example, the vision libraries used by - computer vision researchers at CMU. Again, a small number of - maintainers on a specific machine produce and maintain this software, - which is used by many users on many machines in the CMU environment. - However, SUP will not support the practice of some groups that have - large programs with different pieces being simultaneously modified - and tested in incompatible ways by various users. - - - A user with accounts on more than one machine. Such a user can set - up SUP to automatically copy a collection of files from one machine - to one or more others whenever they are changed on the repository - machine. - - If the system maintenance staff is involved on the repository machine a -"system" file collection can be set up for which client SUP programs need know -nothing but the name of the collection. Otherwise, the file collection will be -"private", and client SUP programs must be specifically told the name of the -repository host and the base directory name for the collection on that host. - - SUP provides facilities for upgrading read-protected files (i.e. files that -are not readable by the general public), data encryption of transmitted files -and filenames, allowing access only to selected host machines not on the local -network, automatically creating backup copies of critical files, executing -command-files or programs after upgrading files that require special handling, -and mailing progress and error messages to designated users. SUP is also as -clever as can be about ensuring that upgraded files have the same accounting -information (mode, owner, links, etc.) on the client machine as on the -repository machine, and ensuring that upgrade problems don't wipe out existing -files when this is avoidable. -2. How to Use SUP to Upgrade a File Collection - You will normally want to run SUP periodically, say every day or every week, -using the at program, to upgrade important file collections such as UNIX system -software. You can also execute SUP directly at any time. The SUP command -looks like this: - - $ sup [flags] [supfile] - -These are the flags and arguments: - --a (all files) Normally, SUP only upgrades files if they are out-of-date or - missing on your machine. If you specify the -a flag, then all - files in the collection will be upgraded regardless of whether - they meet these conditions. This is useful for recovering from - catastrophic file deletions or disk crashes. - --b (backup) If this flag is given, or the backup supfile option is - specified, the contents of regular files on the local system - will be saved before they are overwritten with new data. The - file collection maintainer can designate specific files to be - worthy of backing up whenever they are upgraded. However, such - backup will only take place if you specify this flag or the - backup option to allow backups for a file collection on your - machine. The backup mechanism will create a copy of the - current version of a file immediately before a new copy is - received from the file server; the copy is given the same name - as the original file but is put into a directory called BACKUP - within the directory containing the original file. For - example, /usr/sas/src/foo.c would have a backup copy called - /usr/sas/src/BACKUP/foo.c. There is no provision for - automatically maintaining multiple old versions of files; you - would have to do this yourself. - --B overrides and disables the -b flag and the backup supfile - option. - --d (delete) Files that are no longer in the collection on the repository - will be deleted if present on the local machine. This may also - be specified in a supfile with the deleteoption. - --D This flag overrides and disables the -d flag and the delete - supfile option. - --e (execute) Sup will execute commands sent from the repository that should - be run when a file is upgraded. If the -e flag is omitted, - Sup will print a message that specifies the command to execute. - This may also be specified in a supfile with the execute - option. - --E overrides and disables the -e flag and the execute supfile - option. - --f (file list) If you specify -f, then SUP will print a list of all the files - in the specified collections, indicating which ones need to be - upgraded, which are directories, and which require backup - copies to be created. The upgrade itself will not be - performed. - --l (local) Normally, SUP will not upgrade a collection if the repository - is on the same machine. This allows users to run upgrades on - all machines without having to make special checks for the - repository machine. If the -l flag is specified, collections - will be upgraded even if the repository is local. - --m (mail) Normally, SUP prints log messages on its standard output and - diagnostic output. With the -m flag, messages will be mailed - to you instead. This also allows the notify option to be - effective (see the discussion of supfiles below) to send mail - to someone else. - --N (network debugging) - The -N flag causes SUP to produce tons of output lines - describing the progress and status of the network - communications with the name server and file server. - --P (debugging ports) - The -P flag tells SUP to use an alternate set of TCP ports from - the normal ports. This is a debugging aid for system - maintenance. - --o (old files) This flag overrides the noold option if it appears in the - supfile. The -a flag also overrides the noold option. See - "Supfiles" below for details. - --O overrides and disables the -o flag and the old supfile option. - --s (system collections) - Normally, you will specify a specific supfile to describe the - file collections you want. If you use the -s flag, then a - specific supfile will be used that describes the system - software file collections. The supfile for system software is - /usr/cmu/lib/supfiles/coll.list. - --t (time) If you specify -t, then SUP will simply print out the last time - and date at which each specified file collection was - successfully upgraded; it will not perform any actual upgrade. - This is a diagnostic aid in case you suspect the upgrades - aren't working. - --v (verbose) Normally, SUP only produces messages to tell what's gone wrong - (if anything does go wrong). With the -v flag, messages will - be produced to tell what is happening when things are going - normally as well. - -supfile You must specify the name of a supfile, unless you use the -s - flag to indicate the system software supfile. The supfile, - described below, specifies which file collections you want to - upgrade. - - For example, to upgrade system software on your machine, type: - - $ sup -s - -or, to have detailed log messages mailed to you: - - $ sup -v -m -s - -Because SUP runs with your user-id, you will not be able to upgrade the system -software unless you are logged onto that account when you execute SUP. - - Each file collection being upgraded must have a base directory on your -machine, which will normally contain all the files in the collection. Within -this directory there should be a subdirectory called sup that will be used by -the SUP program; it will be created automatically if you do not create it. SUP -will put files into this directory as needed. - - If you want to find out what files need to be upgraded, type: - - $ sup -f supfile - -This will list all the files in the collection, indicating which need to be -upgraded (and why), which are directories, and which would have backup copies -created if the upgrade were performed. If you simply want to find out the date -and time of the last successful upgrades, type: - - $ sup -t supfile - -This will print the collection name and time of the last upgrade for each -collection described in the indicated supfile. For the system collections, you -can use: - - $ sup -s -t - -2.1 Supfiles - When you execute SUP, you specify a supfile either by name or by using the -s -flag. This file is a list of the file collections you wish to upgrade. - - The supfile is a text file, with each file collection described on a single -line. The line begins with the name of the collection, and may then have a -number of options separated by spaces. The options are: - -base=directory The name of the base directory on this machine for this file - collection, when you don't want to use the default - (/usr/collection). - -host=hostname The name of the host machine acting as the repository for this - file collection, used for "private" file collections. For - "system" file collections, this is unnecessary because the this - information is kept in /usr/cs/lib/supfiles/coll.host. - -hostbase=directory - The name of the base directory on the repository machine for - the file collection (see "How to Set Up a File Collection" - below). This is also used only for "private" file collections; - for "system" file collections, the information is obtained - automatically by the file server. The default name of the host - base directory is /usr/collection. - -login=accountid The name of the account to be used by the file server, when the - default is not acceptable (i.e. it doesn't have the necessary - file access privileges to read the file collection). The - default at CMU is the "Anonymous FTP" account if no data - encryption is used, or the owner of the directory - sup/collection within the repository machine's base directory - if encryption is used. - -password=password - The password used for the login account specified by the - "login" option. This password will be transmitted in encrypted - form over the network. - -crypt=key An optional encryption key for filenames and file data for this - file collection. If used, the same key must be specified on - the repository machine or the upgrade will not take place. - This key is used for filenames and data only -- not for - transmission of the passsword in the "password" option. The - use of data encryption also implies an alternate default - account for the file server (see the "login" option above). - -notify=mailaddress - The account name to which mail is to be addressed for log - messages for this file collection, when the -m flag is given to - SUP. The account name can be a complete mail address, possibly - including a network host name such as sas@cmu-cs-ius. - -noexec This option prevents the automatic execution of command files - on your machine with the upgrade is finished (see "What SUP - Does" below). - -backup This option enables backup copies of critical files to be - created by SUP as specified in "What SUP Does" below. - -nodelete This option prevents SUP from deleting files on your machine if - they are deleted from the file collection on the repository - machine. - -noold This option tells SUP not to check on files in the collection - that have not been modified or created since the last upgrade. - This allows SUP to run much faster on large file collections, - but prevents it from deleting files on the client machine if - they are deleted from the repository, or from restoring files - that have been accidentally deleted from the client machine. - This option is normally useful only for very large file - collections. Its function subsumes that of the nodelete - option. The noold flag will be ignored when either the -a or - -o flag is specified to SUP; this allows a complete file check - to be performed with the -o flag when needed to recover from, - say, accidental deletion of critical files. - - Here is an example of a supfile: - - cmu backup - vision crypt=pupil backup notify=vision@cmu-cs-ius - sas host=ius hostbase=/usr/sas/sun login=sas password=foo crypt=bletch - -This supfile specifies the following file collection upgrades: - -cmu The "cmu" file collection, which is a "system" file collection, - with local base directory /usr/cmu (the default). Backup - copies of critical files will be created during upgrading. - -vision The "vision" file collection, also a "system" file collection, - with local base directory /usr/vision. Backups will be - created. The data will be encrypted with key pupil, and log - messages will be sent to the vision account on cmu-cs-ius. - -sas A "private" file collection will be upgraded from the - cmu-cs-ius machine. The remote base directory is /usr/sas/sun, - but the local base directory is /usr/sas. The file server will - login on account sas with password foo; the data will be - encrypted with key bletch. -3. What SUP Does - An upgrade involves several steps: - - 1. SUP first reads the specified supfile, checking it for errors and - recording all the specifications and options. - - 2. If any collections do not specify a host name, SUP will look in - /usr/cs/supfiles/coll.host to find out the names of the hosts for - these collections. In the preceding example, the name server would - be asked to supply the host names for the cmu and vision file - collections. - - 3. For each collection on the list, SUP will connect to the file server - on the appropriate host and carry on the upgrade process. (If the - file server is on the same host machine as the client, and the base - directories are the same, then no upgrade is performed.) - - a. The file server and SUP exchange setup information, including - the host base directory, login account name, password, and - encryption key. SUP also reports the time of the last - upgrade, by looking in the file sup/collection/when (e.g. - /usr/vision/sup/vision/when) on the client machine. The file - server gets the base directory name, if needed, by looking in - the file /usr/cs/lib/supservers/coll.dir, and gets the - encryption key from sup/collection/crypt on the repository - machine. The connection may be refused by the file server for - such reasons as: - - - incorrect login name or password - - base directory is protected against access by the - specified account - - incorrect data encryption key - - host not allowed access - - b. Once the connection is established and access permission has - been granted as above, the file server builds a list of all - files and directories in the file collection. The list file - sup/collection/list (see "How to Set Up a File Collection" - below) is used to generate this list. The files indicated in - the list file are marked with a special flag if they are - indicated to have backup copies created in case of upgrade. - The last modification date of each file is checked against the - time of the last upgrade (reported by the client above), and - if it has been modified since the last upgrade, a flag is set - to indicate that the client's copy of this file is out of - date. The file list, along with the backup and out-of-date - flag for each file, is sent to the client. If a scan file - exists as created by SUPSCAN (sup/collection/scan), then the - file list is taken from the scan file instead of being - constructed from the list file by the file server. In this - case, the time of record for the upgrade will be the time at - which the scan file was created rather than the time at which - the upgrade actually occurs. If the noold option was - specified in the supfile (and not overridden by the -a or -o - flag to SUP), the list of filenames sent to the client process - will exclude those files that were not created or modified - since the last upgrade. - - c. The client SUP process receives the list of files and - constructs a list of the files it needs. This will normally - be those files that are either (1) out-of-date as indicated by - the flag sent from the file server, or (2) missing from the - local machine. However, if the -a flag was specified to SUP, - then every file in the list will be selected by the client - process. The list of needed files is sent to the file server. - For each selected file, if the backup flag was marked and the - user specified the backup option in the supfile, then a backup - copy of the file will be created. This will be a copy of the - file with "backup/" inserted in the filename just after the - directory name, i.e. /usr/vision/lib/libvision.a would have a - backup copy named /usr/vision/lib/backup/libvision.a. (The - indicated directory, e.g. /usr/vision/lib/backup, will be - created if needed.) Also at this time, if the nodelete option - was not specified, the client reads its list of files in the - collection during the last successful upgrade, - sup/collection/last, and deletes any files appearing in that - list that are not in the current file list. - - d. The file server receives the list of files requested by the - client. It checks to see that each file is on its list of - files for this collection, and that each file is accessible; - if a file fails either condition its name will be reported to - the client as being denied to that client. Each file will be - sent to the client machine, along with the owning account - name, the owning group name, the 12 low-order mode bits, and - the last modification time for that file. If a file has more - than one link (filename), both of which are requested by the - client, then the file will be sent once and the second (etc.) - filename will be accompanied only by a flag saying it's a link - and the name of the file actually sent. The client receives - each file and processes it as described under "File - Installation" below. Directories are treated similarly to - files; the mode, owning account and group, and modification - time are transmitted to the client machine whenever a - directory is upgraded. - - e. When all files have been transmitted, the file server looks at - the list of command-files to be executed after upgrading for - this collection (see "How to Set Up a File Collection" below). - If any of the command-files or their trigger files have been - upgraded, then the client is sent the filename of the - command-file. The client SUP process will normally execute - these files; however, if the user has specified noexec in the - supfile, then the files will not be executed. In this case, a - log message will be created and printed or mailed, telling the - user to please execute these files. When creating command - files to be executed by SUP, you should bear in mind that the - command file might be executed several times on the same - version of the trigger files. - - f. Finally, if the upgrade is successfully completed, the file - server reports the time (on its own clock) at which the - upgrade began; the client will record this time in the file - sup/collection/when to be reported as above at the start of - the next upgrade. If the nodelete option was not specified, - then the list of all files in the collection is written into - sup/collection/last. - - SUP and the server processes begin each connection by determining whether -byte-swapping is necessary for passing integers across the network. If so, the -server process performs byte-swapping on input or output of integers to the -network, while the client uses its natural representation for network I/O. - -3.1 File Installation - When SUP receives an ordinary file (i.e. one that is not a link to a -previously sent file), it follows this procedure: - - 1. If the file doesn't already exist on the local machine, it's a new - file. It will be created and the data will be read directly into - this file. - - 2. Otherwise, the file already exists. An attempt will be made to read - the file contents from the network into a temporary file, which will - later be renamed to replace the destination file. SUP will try to - create a temporary file in the following directories, proceeding - down the list until one of the attempts succeeds: - - a. destination-directory (the directory containing the file - itself) - b. sup (the sup subdirectory of the local base directory) - c. . (the local base directory) - d. /usr/tmp - e. /tmp - - If all these attempts fail, SUP will try to create the destination - file itself instead of using a temporary file. If that fails, SUP - will complain with a log message and go on to the next file. - - 3. The file data itself is read into the temporary or destination file. - Interrupts are disabled during this process. - - 4. If the file read was a temporary file, it is renamed to the - destination file. This is done via link/unlink, if possible, unless - the destination file has more than one link already on this machine. - If the link/unlink fails or if the destination file has multiple - links, then the temporary file is actually copied to the destination - and the temporary file is unlinked. - - 5. The owner, group, modification time, and low-order 12 mode bits of - the destination file are set to the values received from the file - server. The last-access time of the file is set to the current - local clock. - - 6. If the -v flag was specified to SUP, a log message is printed - indicating the successful receipt of the file. - - When SUP receives a new link to a file previously received, it simply tries -to unlink and link unless the two names are on different file systems on the -local machine. If this is the case, or if the link fails, then the previously -received file is actually copied to the new name (using exactly the same -process as described above for creating a temporary file if needed, etc.) The -file-system comparison checks the file system of the old file itself and the -directory containing the new name. - - In all cases, if the directory containing a received file or link does not -exist on the local machine, SUP creates it with mkdir (recursively if needed) -before creating that file or link. The mode, owner, group, and modification -time of the newly created directory will then be set to be the same as the mode -of the corresponding directory on the repository machine. This accounting -information will be updated whenever the directory is modified on the -repository machine. - - As can be seen from this description, SUP will work the most smoothly (i.e. -always using link/unlink for file name changing) if it has write permission in -the local base directory and in all subdirectories of that directory. -4. How to Set Up a File Collection - It takes only a little bit of effort to set up a file collection on a -repository machine to be upgraded by authorized clients. - - First, the file collection must be given a name and a base directory. There -can be several collections with different names sharing the same base -directory; for example, there might be a file collection called cmulib for the -CMU C library, and one called cmumathlib for just the math routines in the CMU -C library, both using /usr/cmu as the base directory. - - If it is a "private" file collection, client users must be told the name of -the repository host and the name of the host base directory for use in the host -and hostbase options in the supfile, described above. If it is a "system" -collection instead, the system maintainers must alert the name servers of the -host name (in /usr/cmu/lib/supservers/coll.host) and the appropriate file -server of the base directory name (if not the default, by putting it into -/usr/cmu/lib/supservers/coll.dir). - - Within the base directory, a subdirectory must be created called sup. Within -this subdirectory will be a further subdirectory whose name is the name of the -collection (there may be several of these if several collections share the same -base directory). Each collection's subdirectory will contain any or all of -four files: - -collection/list The list file, describing the files in the collection. The - format of this file is explained below. - -collection/host Normally, the file server allows access to a collection by all - machines. If you wish to allow access only to specific remote - hosts, you can list their names, one per line, in this text - file. If a remote host has several alias names, it need only - be listed once in this file. The name LOCAL can be used to - allow access to all machines on the local network. This access - control is in addition to the other forms of authentication - provided by SUP (data encryption and UNIX file protection - modes). - -collection/crypt - If you wish to apply data encryption to the filenames and file - contents in this collection during upgrading, create this file - and place in it the encryption key. This should be on a single - line of text containing nothing else except an optional newline - character. The client must supply the same key via the crypt - option in the supfile for this file collection; the file server - checks that explicitly before authorizing the upgrade to take - place. - -collection/scan To speed up execution of the file server, you may wish to - create a scan file periodically. This is done by executing the - SUPSCAN program: - - $ supscan [-v] collection [basedir] - - This will construct a list of all files matching the - specifications in the list file, and record it in the scan - file. When an upgrade is performed on the collection, the file - server will notice that the scan file is present and use this - list instead of actually building the filename list by - analyzing the list file. The time of record for the upgrade - will then be the time at which the scan file was created rather - than the time at which the upgrade occurs. A scan file is only - useful for very large file collections that are upgraded many - times each day. The options for the SUPSCAN program are -v - ("verbose") to produce messages as it scans the file list, and - basedir if the collection is a private collection whose base - directory name is not the default name. - - This is all the preparation required for a file collection to be upgraded. - - Note that the default user-id for the file server is "Anonymous FTP" if no -data encryption is used; if encryption is used, the default will be the owner -of the subdirectory sup/collection within the base directory. - -4.1 The List File - The list file contains a description of the files to be upgraded. It -contains any number of commands, each on a separate line of text. Each line -contains a keyword and a number of operands separated by spaces. All filenames -in the list are evaluated relative to the collection's base directory on the -repository machine for the file server, and relative to the base directory on -the client machine for the client SUP process. All (except execfile) may be -file specifications containing the shell's meta-characters *, ?, [...], and -{...}. - - The commands are: - -upgrade filename ... - These files will be included in the list of files to be - upgraded. If a directory name is given, all the files in that - directory will be included and any subdirectories will be - recursively included as well. - -omit filename ... - These files will not be included in the list; if a directory is - specified, it will not be included nor will its contents be - included. For example, the specifications upgrade lib and omit - lib/test will include all files and subdirectories of lib - except lib/test (and any subdirectories or files within - lib/test). - -omitany pattern ... - The specified patterns are compared against the files in the - upgrade list. If a pattern matches, the file is omitted. The - omitany command currently supports all wild-card patterns - except {...}. Also, the pattern must match the entire - filename, so a leading */, or a trailing /*, may be necessary - in the pattern. - -backup filename ... - The files will be marked for creating backup copies whenever - they are upgraded (as described above). Only files can be - included in this list -- not directories. As noted above, - actual backup copies will only be created by SUP when these - files are being upgraded, and then only if the user has - specified the backup option in the supfile. - -execute execfile (triggerfile ...) ... - The listed execfiles are command files or programs to be - executed after an upgrade to perform routine installation of - the upgraded files. Each execfile will be executed only when - it is upgraded itself, or when any of its listed triggerfiles - have been upgraded. The installation tasks performed by such - files might be, for example, creating a table of contents for - manual entries or for a subroutine library, or modifying a host - name field within a data file. - -include listfile ... - The named listfiles will be read at this point. This allows a - collection to contain another collection in its entirety, by - simply specifying the name of the listfile for that other - collection. - -backup filename... - The specified file(s) are marked for backup; if they are - upgraded and the client has specified the backup option in the - corresponding line of the supfile, then backup copies will be - created as described above. Directories may not be specified, - and no recursive filename construction is performed; you must - specify the names of the specific files to be backed up before - upgrading. - -symlink filename... - The specified file(s) are to be treated as symbolic links and - will be transfered as such and not followed. By default, SUP - will follow symbolic links. - -rsymlink dirname... - All the symbolic links in the specified subdirectories are to - be transferred as such and not followed. - - Blank lines may appear freely in the list file, and the order in which -command lines appear within the file does not matter. Filenames must generally -match as strings, e.g. with base directory /usr/vision, "lib" in the upgrade -command would not match "/usr/vision/lib" in the omit command; it would only -match "lib" in the omit command. However, one special exception exists: if -the base directory is specified via "dot" (.) in the upgrade command, the -filenames within that directory need not begin with "./" in other commands. -For example, with base directory /usr/vision, the commands "upgrade ." and -"omit exp" specify a file list including all files and directories within -/usr/vision except the subdirectory /usr/vision/exp and its subdirectories and -files. -5. Setup for SUP - You need to add the following entries to /etc/services: - - supfilesrv 871/tcp - supfiledbg 1127/tcp - - A supfilsrv daemon should be kept running on any machine that may act as a -repository for a collection. Since this includes private collections, it is -advisable to have supfilesrv running on all machines if SUP is to be widely -used. nanny can be used to start the supfilesrv. - - The program modcoll.8 is used to set up the control files for the "system" -collections. See /usr/cs/man/man8/modcoll.8 - Table of Contents - -1. Introduction 1 - -2. How to Use SUP to Upgrade a File Collection 2 - - 2.1 Supfiles 2 - -3. What SUP Does 4 - - 3.1 File Installation 4 - -4. How to Set Up a File Collection 5 - - 4.1 The List File 5 - -5. Setup for SUP 6